From 1e6f441a0daeac0f0cfc06344491477e0aceab46 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 18 Aug 2023 10:14:39 -0400 Subject: [PATCH 0001/1963] feat(`anvil`): Include `CREATE2` deployer by default on new instances (#5391) * chore: install create_2_deployer * chore: docs * chore: comment codes * fix: set proper runtime code * fmt --- crates/anvil/src/config.rs | 17 ++++++++++++++++- crates/anvil/src/eth/backend/mem/mod.rs | 8 ++++++++ crates/evm/src/executor/mod.rs | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index f32aaf1ad8a8e..f262cfb0c5595 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -32,7 +32,10 @@ use foundry_common::{ }; use foundry_config::Config; use foundry_evm::{ - executor::fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, + executor::{ + fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, + inspector::DEFAULT_CREATE2_DEPLOYER, + }, revm, revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv, U256 as rU256}, utils::{apply_chain_and_block_specific_env_changes, h256_to_b256, u256_to_ru256}, @@ -163,6 +166,8 @@ pub struct NodeConfig { pub init_state: Option, /// max number of blocks with transactions in memory pub transaction_block_keeper: Option, + /// Disable the default CREATE2 deployer + pub disable_default_create2_deployer: bool, } impl NodeConfig { @@ -398,6 +403,7 @@ impl Default for NodeConfig { prune_history: Default::default(), init_state: None, transaction_block_keeper: None, + disable_default_create2_deployer: false, } } } @@ -1005,6 +1011,15 @@ latest block number: {latest_block}" ) .await; + // Writes the default create2 deployer to the backend, + // if the option is not disabled and we are not forking. + if !self.disable_default_create2_deployer && self.eth_rpc_url.is_none() { + backend + .set_create2_deployer(DEFAULT_CREATE2_DEPLOYER) + .await + .expect("Failed to create default create2 deployer"); + } + if let Some(ref state) = self.init_state { backend .get_db() diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 98ba22c2eba25..c0d9b0bc3a054 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -60,6 +60,7 @@ use foundry_evm::{ executor::{ backend::{DatabaseError, DatabaseResult}, inspector::AccessListTracer, + DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, }, revm::{ self, @@ -235,6 +236,13 @@ impl Backend { backend } + /// Writes the CREATE2 deployer code directly to the database at the address provided. + pub async fn set_create2_deployer(&self, address: Address) -> DatabaseResult<()> { + self.set_code(address, Bytes::from_static(DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE)).await?; + + Ok(()) + } + /// Updates memory limits that should be more strict when auto-mine is enabled pub(crate) fn update_interval_mine_block_time(&self, block_time: Duration) { self.states.write().update_interval_mine_block_time(block_time) diff --git a/crates/evm/src/executor/mod.rs b/crates/evm/src/executor/mod.rs index 3de78fbc868a3..aa32860c60e4c 100644 --- a/crates/evm/src/executor/mod.rs +++ b/crates/evm/src/executor/mod.rs @@ -64,7 +64,10 @@ pub use builder::ExecutorBuilder; /// A mapping of addresses to their changed state. pub type StateChangeset = HashMap; +/// The initcode of the default create2 deployer. pub const DEFAULT_CREATE2_DEPLOYER_CODE: &[u8] = &hex!("604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); +/// The runtime code of the default create2 deployer. +pub const DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE: &[u8] = &hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); /// A type that can execute calls /// From fe1c1fc0f4f73a45aeb2e889f96808c413aae1d3 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 18 Aug 2023 12:05:32 -0400 Subject: [PATCH 0002/1963] fix(tests): only run heavy integration tests by tightening filters (#5657) --- .github/workflows/heavy-integration.yml | 2 +- crates/forge/tests/cli/heavy_integration.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index e051e706bc81d..1c9b8c914e8cc 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -58,7 +58,7 @@ jobs: matrix: job: - name: Long-running integration tests - filter: "!test(~live)" + filter: "!test(~live) & test(heavy)" env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: diff --git a/crates/forge/tests/cli/heavy_integration.rs b/crates/forge/tests/cli/heavy_integration.rs index 7363b0ca4ef68..200fe0fc6d8fa 100644 --- a/crates/forge/tests/cli/heavy_integration.rs +++ b/crates/forge/tests/cli/heavy_integration.rs @@ -1,5 +1,6 @@ //! Heavy integration tests that can take an hour to run or more. +//! All tests are prefixed with heavy so they can be filtered by nextest. use foundry_test_utils::forgetest_external; -forgetest_external!(maple, "maple-labs/maple-core-v2"); +forgetest_external!(heavy_maple, "maple-labs/maple-core-v2"); From 52ecd5c403885101057a73245c2a225b9183ab4e Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 18 Aug 2023 13:25:04 -0400 Subject: [PATCH 0003/1963] feat(`cheatcodes`): tryFfi (rebased) (#5660) * chore: add tryffi cheatcode to abi * feat: impl * chore: tests --- crates/abi/abi/HEVM.sol | 2 + crates/abi/src/bindings/hevm.rs | 101 ++++++++++++++++++ .../src/executor/inspector/cheatcodes/ext.rs | 51 +++++++++ testdata/cheats/TryFfi.sol | 33 ++++++ testdata/cheats/Vm.sol | 9 ++ 5 files changed, 196 insertions(+) create mode 100644 testdata/cheats/TryFfi.sol diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index 3e020e6640e49..ee657241d9ea3 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -3,9 +3,11 @@ struct Rpc { string name; string url; } 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 exit_code; bytes stdout; bytes stderr; } allowCheatcodes(address) +tryFfi(string[])(FfiResult) ffi(string[])(bytes) breakpoint(string) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index 34e50d45ef032..62b2a4467491b 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -4875,6 +4875,40 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("tryFfi"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("tryFfi"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers_core::abi::ethabi::ParamType::String, + ), + ), + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers_core::abi::ethabi::ParamType::Int(32usize), + ::ethers_core::abi::ethabi::ParamType::Bytes, + ::ethers_core::abi::ethabi::ParamType::Bytes, + ], + ), + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("txGasPrice"), ::std::vec![ @@ -7109,6 +7143,18 @@ pub mod hevm { .method_hash([77, 138, 188, 75], (p0, p1)) .expect("method not found (this should never happen)") } + ///Calls the contract's `tryFfi` (0xf45c1ce7) function + pub fn try_ffi( + &self, + p0: ::std::vec::Vec<::std::string::String>, + ) -> ::ethers_contract::builders::ContractCall< + M, + (i32, ::ethers_core::types::Bytes, ::ethers_core::types::Bytes), + > { + self.0 + .method_hash([244, 92, 28, 231], p0) + .expect("method not found (this should never happen)") + } ///Calls the contract's `txGasPrice` (0x48f50c0f) function pub fn tx_gas_price( &self, @@ -10012,6 +10058,19 @@ pub mod hevm { )] #[ethcall(name = "transact", abi = "transact(uint256,bytes32)")] pub struct Transact1Call(pub ::ethers_core::types::U256, pub [u8; 32]); + ///Container type for all input parameters for the `tryFfi` function with signature `tryFfi(string[])` and selector `0xf45c1ce7` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "tryFfi", abi = "tryFfi(string[])")] + pub struct TryFfiCall(pub ::std::vec::Vec<::std::string::String>); ///Container type for all input parameters for the `txGasPrice` function with signature `txGasPrice(uint256)` and selector `0x48f50c0f` #[derive( Clone, @@ -10310,6 +10369,7 @@ pub mod hevm { ToString5(ToString5Call), Transact0(Transact0Call), Transact1(Transact1Call), + TryFfi(TryFfiCall), TxGasPrice(TxGasPriceCall), Warp(WarpCall), WriteFile(WriteFileCall), @@ -11157,6 +11217,10 @@ pub mod hevm { = ::decode(data) { return Ok(Self::Transact1(decoded)); } + if let Ok(decoded) + = ::decode(data) { + return Ok(Self::TryFfi(decoded)); + } if let Ok(decoded) = ::decode(data) { return Ok(Self::TxGasPrice(decoded)); @@ -11668,6 +11732,7 @@ pub mod hevm { Self::Transact1(element) => { ::ethers_core::abi::AbiEncode::encode(element) } + Self::TryFfi(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::TxGasPrice(element) => { ::ethers_core::abi::AbiEncode::encode(element) } @@ -11910,6 +11975,7 @@ pub mod hevm { Self::ToString5(element) => ::core::fmt::Display::fmt(element, f), Self::Transact0(element) => ::core::fmt::Display::fmt(element, f), Self::Transact1(element) => ::core::fmt::Display::fmt(element, f), + Self::TryFfi(element) => ::core::fmt::Display::fmt(element, f), Self::TxGasPrice(element) => ::core::fmt::Display::fmt(element, f), Self::Warp(element) => ::core::fmt::Display::fmt(element, f), Self::WriteFile(element) => ::core::fmt::Display::fmt(element, f), @@ -12905,6 +12971,11 @@ pub mod hevm { Self::Transact1(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: TryFfiCall) -> Self { + Self::TryFfi(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: TxGasPriceCall) -> Self { Self::TxGasPrice(value) @@ -14270,6 +14341,20 @@ pub mod hevm { Hash )] pub struct SnapshotReturn(pub ::ethers_core::types::U256); + ///Container type for all return fields from the `tryFfi` function with signature `tryFfi(string[])` and selector `0xf45c1ce7` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct TryFfiReturn( + pub (i32, ::ethers_core::types::Bytes, ::ethers_core::types::Bytes), + ); ///`DirEntry(string,string,uint64,bool,bool)` #[derive( Clone, @@ -14288,6 +14373,22 @@ pub mod hevm { pub is_dir: bool, pub is_symlink: bool, } + ///`FfiResult(int32,bytes,bytes)` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct FfiResult { + pub exit_code: i32, + pub stdout: ::ethers_core::types::Bytes, + pub stderr: ::ethers_core::types::Bytes, + } ///`FsMetadata(bool,bool,uint256,bool,uint256,uint256,uint256)` #[derive( Clone, diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index ee4707019de58..a138e422e2d9d 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -11,6 +11,50 @@ use serde::Deserialize; use serde_json::Value; use std::{collections::BTreeMap, env, path::Path, process::Command}; +/// Invokes a `Command` with the given args and returns the exit code, stdout, and stderr. +/// +/// If stdout or stderr are valid hex, it returns the hex decoded value. +fn try_ffi(state: &Cheatcodes, args: &[String]) -> Result { + if args.is_empty() || args[0].is_empty() { + bail!("Can't execute empty command"); + } + let name = &args[0]; + let mut cmd = Command::new(name); + if args.len() > 1 { + cmd.args(&args[1..]); + } + + trace!(?args, "invoking try_ffi"); + + let output = cmd + .current_dir(&state.config.root) + .output() + .map_err(|err| fmt_err!("Failed to execute command: {err}"))?; + + let exit_code = output.status.code().unwrap_or(1); + + let trimmed_stdout = String::from_utf8(output.stdout)?; + let trimmed_stdout = trimmed_stdout.trim(); + + // The stdout might be encoded on valid hex, or it might just be a string, + // so we need to determine which it is to avoid improperly encoding later. + let encoded_stdout: Token = + if let Ok(hex) = hex::decode(trimmed_stdout.strip_prefix("0x").unwrap_or(trimmed_stdout)) { + Token::Bytes(hex) + } else { + Token::Bytes(trimmed_stdout.into()) + }; + + let res = abi::encode(&[Token::Tuple(vec![ + Token::Int(exit_code.into()), + encoded_stdout, + // We can grab the stderr output as-is. + Token::Bytes(output.stderr), + ])]); + + Ok(res.into()) +} + /// Invokes a `Command` with the given args and returns the abi encoded response /// /// If the output of the command is valid hex, it returns the hex decoded value @@ -461,6 +505,13 @@ pub fn apply(state: &mut Cheatcodes, call: &HEVMCalls) -> Option { Err(fmt_err!("FFI disabled: run again with `--ffi` if you want to allow tests to call external scripts.")) } } + HEVMCalls::TryFfi(inner) => { + if state.config.ffi { + try_ffi(state, &inner.0) + } else { + Err(fmt_err!("FFI disabled: run again with `--ffi` if you want to allow tests to call external scripts.")) + } + } HEVMCalls::GetCode(inner) => get_code(state, &inner.0), HEVMCalls::GetDeployedCode(inner) => get_deployed_code(state, &inner.0), HEVMCalls::SetEnv(inner) => set_env(&inner.0, &inner.1), diff --git a/testdata/cheats/TryFfi.sol b/testdata/cheats/TryFfi.sol new file mode 100644 index 0000000000000..f33769cc82b4e --- /dev/null +++ b/testdata/cheats/TryFfi.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity >=0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract TryFfiTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testTryFfi() public { + string[] memory inputs = new string[](3); + inputs[0] = "bash"; + inputs[1] = "-c"; + inputs[2] = + "echo -n 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000966666920776f726b730000000000000000000000000000000000000000000000"; + + Vm.FfiResult memory f = vm.tryFfi(inputs); + (string memory output) = abi.decode(f.stdout, (string)); + assertEq(output, "ffi works", "ffi failed"); + assertEq(f.exit_code, 0, "ffi failed"); + } + + function testTryFfiFail() public { + string[] memory inputs = new string[](3); + inputs[0] = "bash"; + inputs[1] = "-c"; + inputs[2] = "quikmafs"; + + Vm.FfiResult memory f = vm.tryFfi(inputs); + assert(f.exit_code != 0); + assertEq(string(f.stderr), string("bash: quikmafs: command not found\n")); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 2b35df6db0c8c..a83f70ed6a4e2 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -52,6 +52,12 @@ interface Vm { uint256 privateKey; } + struct FfiResult { + int32 exit_code; + bytes stdout; + bytes stderr; + } + // Set block.timestamp (newTimestamp) function warp(uint256) external; @@ -116,6 +122,9 @@ interface Vm { // Performs a foreign function call via terminal, (stringInputs) => (result) function ffi(string[] calldata) external returns (bytes memory); + // Performs a foreign function call via terminal and returns the exit code, stdout, and stderr + function tryFfi(string[] calldata) external returns (FfiResult memory); + // Set environment variables, (name, value) function setEnv(string calldata, string calldata) external; From 2b668d953482359d57689c1790c34c1f0e31b9fe Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 18 Aug 2023 20:09:06 +0200 Subject: [PATCH 0004/1963] fix(foundryup): check if file exists before moving (#5662) --- foundryup/foundryup | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 4ea420ecc39b6..af0d4d52c2c6a 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -206,7 +206,12 @@ EOF # Build the repo and install the binaries locally to the .foundry bin directory. ensure cargo build --bins --release for bin in "${BINS[@]}"; do - mv -f "target/release/$bin" "target/release/$bin.exe" "$FOUNDRY_DIR" + for try_path in target/release/$bin target/release/$bin.exe; do + if [ -f "$try_path" ]; then + [ -e "$FOUNDRY_BIN_DIR/$bin" ] && warn "overwriting existing $bin in $FOUNDRY_BIN_DIR" + mv -f "$try_path" "$FOUNDRY_BIN_DIR" + fi + done done # If help2man is installed, use it to add Foundry man pages. From d58ee4e9fbee7d14644da5aba5946f1d09cac291 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 18 Aug 2023 21:40:27 +0200 Subject: [PATCH 0005/1963] ci: improve test CI (#5661) --- .github/INTEGRATION_FAILURE.md | 6 +- .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md | 4 +- .github/scripts/matrices.py | 135 ++++++++++ .github/workflows/cross-platform.yml | 206 ---------------- .github/workflows/deny.yml | 1 + .github/workflows/dependencies.yml | 101 ++++---- .github/workflows/docker-publish.yml | 2 +- .github/workflows/heavy-integration.yml | 82 +----- .github/workflows/project.yml | 2 +- .github/workflows/test.yml | 260 +++++--------------- crates/forge/Cargo.toml | 3 - crates/forge/tests/cli/ext_integration.rs | 27 ++ crates/forge/tests/cli/heavy_integration.rs | 3 +- crates/forge/tests/cli/integration.rs | 37 --- crates/forge/tests/cli/main.rs | 19 +- crates/forge/tests/cli/svm.rs | 40 ++- crates/forge/tests/it/repros.rs | 2 +- 17 files changed, 313 insertions(+), 617 deletions(-) create mode 100644 .github/scripts/matrices.py delete mode 100644 .github/workflows/cross-platform.yml create mode 100644 crates/forge/tests/cli/ext_integration.rs delete mode 100644 crates/forge/tests/cli/integration.rs diff --git a/.github/INTEGRATION_FAILURE.md b/.github/INTEGRATION_FAILURE.md index afa055b18364e..bda129177f706 100644 --- a/.github/INTEGRATION_FAILURE.md +++ b/.github/INTEGRATION_FAILURE.md @@ -3,8 +3,8 @@ title: "bug: long-running integration tests failed" labels: P-high, T-bug --- -The heavy (long-running) integration tests have failed. This indicates a regression in foundry. +The heavy (long-running) integration tests have failed. This indicates a regression in Foundry. -Check the [heavy integration tests workflow page]({{env.WORKFLOW_URL}}) for details. +Check the [heavy integration tests workflow page]({{ env.WORKFLOW_URL }}) for details. -This issue was raised by the workflow at `.github/workflows/heavy-integration.yml`. \ No newline at end of file +This issue was raised by the workflow at `.github/workflows/heavy-integration.yml`. diff --git a/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md b/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md index eb33b48971ef4..2ff598cc1b371 100644 --- a/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md +++ b/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md @@ -5,6 +5,6 @@ labels: P-high, T-bug The release workflow has failed. Some or all binaries might have not been published correctly. -Check the [release workflow page]({{env.WORKFLOW_URL}}) for details. +Check the [release workflow page]({{ env.WORKFLOW_URL }}) for details. -This issue was raised by the workflow at `.github/workflows/release.yml`. \ No newline at end of file +This issue was raised by the workflow at `.github/workflows/release.yml`. diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py new file mode 100644 index 0000000000000..19b7be5a8a17c --- /dev/null +++ b/.github/scripts/matrices.py @@ -0,0 +1,135 @@ +import json +import os + + +class Target: + # GitHub runner OS + os_id: str + # Rust target triple + target: str + + def __init__(self, os_id: str, target: str): + self.os_id = os_id + self.target = target + + +class Case: + name: str + filter: str + n_partitions: int + xplatform: bool + + def __init__(self, name: str, filter: str, n_partitions: int, xplatform: bool): + self.name = name + self.filter = filter + self.n_partitions = n_partitions + self.xplatform = xplatform + + +class Expanded: + os: str + target: str + name: str + flags: str + partition: int + + def __init__(self, os: str, target: str, name: str, flags: str, partition: int): + self.os = os + self.target = target + self.name = name + self.flags = flags + self.partition = partition + + +default_target = Target("ubuntu-latest", "x86_64-unknown-linux-gnu") +if os.environ.get("EVENT_NAME") == "pull_request": + targets = [default_target] +else: + targets = [ + default_target, + Target("ubuntu-latest", "aarch64-unknown-linux-gnu"), + Target("macos-latest", "x86_64-apple-darwin"), + Target("macos-latest", "aarch64-apple-darwin"), + Target("windows-latest", "x86_64-pc-windows-msvc"), + ] + +config = [ + Case( + name="unit", + filter="kind(lib) | kind(bench) | kind(proc-macro)", + n_partitions=1, + xplatform=True, + ), + Case( + name="integration", + filter="kind(test) & !test(/issue|forge_std|ext_integration/)", + n_partitions=3, + xplatform=True, + ), + Case( + name="integration/issue-repros", + filter="package(=forge) & test(~issue)", + n_partitions=2, + xplatform=False, + ), + Case( + name="integration/forge-std", + filter="package(=forge) & test(~forge_std)", + n_partitions=1, + xplatform=False, + ), + Case( + name="integration/external", + filter="package(=forge) & test(~ext_integration)", + n_partitions=2, + xplatform=False, + ), +] + + +def build_matrix(): + os_ids = [] + targets_ = [] + for target in targets: + os_ids.append(target.os_id) + targets_.append(target.target) + print(json.dumps({"os": os_ids, "target": targets_})) + + +def test_matrix(): + expanded = [] + for target in targets: + for case in config: + if not case.xplatform and target != default_target: + continue + + for partition in range(1, case.n_partitions + 1): + os_str = "" + if len(targets) > 1: + os_str = f" ({target.target})" + + name = case.name + flags = f"-E '{case.filter}'" + if case.n_partitions > 1: + s = f"{partition}/{case.n_partitions}" + name += f" ({s})" + flags += f" --partition count:{s}" + name += os_str + + obj = Expanded( + os=target.os_id, + target=target.target, + name=name, + flags=flags, + partition=partition, + ) + expanded.append(vars(obj)) + + print(json.dumps({"include": expanded}), end="", flush=True) + + +if __name__ == "__main__": + if int(os.environ.get("TEST", "0")) == 0: + build_matrix() + else: + test_matrix() diff --git a/.github/workflows/cross-platform.yml b/.github/workflows/cross-platform.yml deleted file mode 100644 index bd9e19fc21db3..0000000000000 --- a/.github/workflows/cross-platform.yml +++ /dev/null @@ -1,206 +0,0 @@ -on: - workflow_dispatch: - workflow_call: - -name: cross-platform - -env: - CARGO_TERM_COLOR: always - -jobs: - build-tests: - name: building ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ matrix.archive.name }} - runs-on: ${{ matrix.job.os }} - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - archive: - - name: unit-tests - file: nextest-unit.tar.zst - flags: --workspace --all-features --lib --bins - - name: integration-tests - file: nextest-integration.tar.zst - flags: --workspace - job: - # The OS is used for the runner - # The target is used by Cargo - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - - os: macos-latest - target: x86_64-apple-darwin - - os: macos-latest - target: aarch64-apple-darwin - - os: windows-latest - target: x86_64-pc-windows-msvc - wsl: wsl - - os: windows-latest - target: x86_64-pc-windows-msvc - - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.job.target }} - - uses: Swatinem/rust-cache@v2 - - name: Install nextest - uses: taiki-e/install-action@nextest - - # Required for forge commands that use git - - name: Setup git - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: Apple M1 setup - if: ${{ matrix.job.target == 'aarch64-apple-darwin' }} - run: | - echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV - echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV - - - name: Linux ARM setup - if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} - run: | - sudo apt-get update -y - sudo apt-get install -y gcc-aarch64-linux-gnu - echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - - # For some reason the FFI cheatcode uses WSL bash instead of Git bash, so we need to install a WSL distribution - - name: Windows setup - if: ${{ matrix.job.wsl == 'wsl' }} - uses: Vampire/setup-wsl@v1 - with: - distribution: Ubuntu-20.04 - set-as-default: true - - - name: Build archive (unit tests) - run: | - cargo nextest archive --locked ${{ matrix.job.flags }} --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} - - name: Upload archive - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.job.target }}-${{ matrix.archive.name }} - path: ${{ matrix.job.target }}-${{ matrix.archive.file }} - - unit: - name: unit tests ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ matrix.archive.name }} / ${{ matrix.nextest.name }} - runs-on: ${{ matrix.job.os }} - needs: build-tests - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - archive: - - name: unit-tests - file: nextest-unit.tar.zst - job: - # The OS is used for the runner - # The target is used by Cargo - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - - os: macos-latest - target: x86_64-apple-darwin - - os: macos-latest - target: aarch64-apple-darwin - - os: windows-latest - target: x86_64-pc-windows-msvc - nextest: - - name: non-forking - filter: "!test(~fork) & !test(~live) & !test(~forge_std) & !test(~deploy_and_simulate)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.job.target }} - - uses: taiki-e/install-action@nextest - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: ${{ matrix.job.target }}-${{ matrix.archive.name }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest - shell: bash - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.filter }}' - - integration: - name: - integration tests ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ - matrix.archive.name }} / ${{ matrix.nextest.name }} - runs-on: ${{ matrix.job.os }} - timeout-minutes: 60 - needs: build-tests - strategy: - fail-fast: false - matrix: - archive: - - name: integration-tests - file: nextest-integration.tar.zst - job: - # The OS is used for the runner - # The target is used by Cargo - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - - os: macos-latest - target: x86_64-apple-darwin - - os: macos-latest - target: aarch64-apple-darwin - - os: windows-latest - target: x86_64-pc-windows-msvc - nextest: - - name: non-forking - # skip fork,verify,forge-std and script tests that use heavy simulation - filter: "!test(~fork) & !test(~live) & !test(~forge_std) & !test(~deploy_and_simulate)" - # the aarch64-apple-darwin runner is particularly slow with script related tests - macos-aarch-filter: "!test(~fork) & !test(~live) & !test(~forge_std) & !test(~deploy_)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: taiki-e/install-action@nextest - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: ${{ matrix.job.target }}-${{ matrix.archive.name }} - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.nextest.name != 'non-forking' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest - if: ${{ matrix.job.target == 'aarch64-apple-darwin' }} - shell: bash - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.macos-aarch-filter }}' - - - name: cargo nextest - if: ${{ matrix.job.target != 'aarch64-apple-darwin' }} - shell: bash - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.filter }}' diff --git a/.github/workflows/deny.yml b/.github/workflows/deny.yml index 9fac75ef56019..af8f4901ed5ed 100644 --- a/.github/workflows/deny.yml +++ b/.github/workflows/deny.yml @@ -15,6 +15,7 @@ jobs: cargo-deny: name: cargo deny check runs-on: ubuntu-latest + timeout-minutes: 30 steps: - uses: actions/checkout@v3 - uses: EmbarkStudios/cargo-deny-action@v1 diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index e731a7a56923f..531480b8232b1 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -3,59 +3,62 @@ name: Update Dependencies on: - schedule: - # Run weekly - - cron: "0 0 * * SUN" - workflow_dispatch: - # Needed so we can run it manually + schedule: + # Run weekly + - cron: "0 0 * * SUN" + workflow_dispatch: + # Needed so we can run it manually env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: cargo-update - TITLE: "chore(deps): weekly `cargo update`" - BODY: | - Automation to keep dependencies in `Cargo.lock` current. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: cargo-update + TITLE: "chore(deps): weekly `cargo update`" + BODY: | + Automation to keep dependencies in `Cargo.lock` current. -
cargo update log -

+

cargo update log +

- ```log - $cargo_update_log - ``` + ```log + $cargo_update_log + ``` -

-
+

+
jobs: - update: - name: Update - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly - - - name: cargo update - # Remove first line that always just says "Updating crates.io index" - run: cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log - - - name: craft commit message and PR body - id: msg - run: | - export cargo_update_log="$(cat cargo_update.log)" - - echo "commit_message<> $GITHUB_OUTPUT - printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - echo "body<> $GITHUB_OUTPUT - echo "$BODY" | envsubst >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - add-paths: ./Cargo.lock - commit-message: ${{ steps.msg.outputs.commit_message }} - title: ${{ env.TITLE }} - body: ${{ steps.msg.outputs.body }} - branch: ${{ env.BRANCH }} + update: + name: Update + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + + - name: cargo update + # Remove first line that always just says "Updating crates.io index" + run: + cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a + cargo_update.log + + - name: craft commit message and PR body + id: msg + run: | + export cargo_update_log="$(cat cargo_update.log)" + + echo "commit_message<> $GITHUB_OUTPUT + printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + echo "body<> $GITHUB_OUTPUT + echo "$BODY" | envsubst >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + add-paths: ./Cargo.lock + commit-message: ${{ steps.msg.outputs.commit_message }} + title: ${{ env.TITLE }} + body: ${{ steps.msg.outputs.body }} + branch: ${{ env.BRANCH }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ae4382f3e6a91..4f52a545d5a7c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -23,7 +23,7 @@ jobs: id-token: write packages: write contents: read - timeout-minutes: 60 + timeout-minutes: 30 steps: - name: Checkout repository diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index 1c9b8c914e8cc..db45353eb85da 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -10,94 +10,34 @@ env: CARGO_TERM_COLOR: always jobs: - build-tests: - name: build tests / ${{ matrix.archive.name }} - runs-on: ubuntu-latest - strategy: - matrix: - archive: - - name: heavy-integration-tests - file: heavy-integration.tar.zst - flags: -p forge --features heavy-integration-tests - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: taiki-e/install-action@nextest - - name: Build archive (long-running tests) - run: | - cargo nextest archive \ - --locked \ - --archive-file ${{ matrix.archive.file }} \ - ${{ matrix.archive.flags }} - - name: Upload archive - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.archive.name }} - path: ${{ matrix.archive.file }} - - install-svm-solc: - name: install svm and solidity / ${{ matrix.job.name }} - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Install svm - run: cargo install svm-rs - - name: Install Solidity 0.8.19 - run: svm install 0.8.19 - - name: Install Solidity 0.8.20 - run: svm install 0.8.20 - - name: Use Solidity 0.8.19 - run: svm use 0.8.19 - heavy-integration: - name: heavy (long-running) integration tests / ${{ matrix.job.name }} + name: heavy (long-running) integration tests runs-on: ubuntu-latest - needs: build-tests - strategy: - matrix: - job: - - name: Long-running integration tests - filter: "!test(~live) & test(heavy)" env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: heavy-integration-tests - + - uses: taiki-e/install-action@nextest + - uses: Swatinem/rust-cache@v2 - name: Forge RPC cache uses: actions/cache@v3 - if: matrix.job.name != 'non-forking' with: - path: "$HOME/.foundry/cache" + path: | + ~/.foundry/cache + ~/.config/.foundry/cache key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: Force use of HTTPS for submodules - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - - name: cargo nextest + - name: test run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file heavy-integration.tar.zst -E '${{ matrix.job.filter }}' + cargo nextest run -r -p forge --test cli --features heavy-integration-tests --retries 1 -E 'test(~heavy_integration)' - # If any of the steps fail, this will create a high-priority issue - # to signal so. + # If any of the steps fail, this will create a high-priority issue to signal so. - uses: JasonEtco/create-an-issue@v2 if: ${{ failure() }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + WORKFLOW_URL: | + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} with: update_existing: true filename: .github/INTEGRATION_FAILURE.md diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index f1dfd2727bb5f..9d450c2b757d2 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -7,7 +7,7 @@ jobs: add-to-project: name: add issue runs-on: ubuntu-latest - timeout-minutes: 60 + timeout-minutes: 30 steps: - uses: actions/add-to-project@main with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb89338c160f2..e877f25407364 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,237 +10,99 @@ env: CARGO_TERM_COLOR: always jobs: - build-tests: - name: build tests / ${{ matrix.archive.name }} + matrices: + name: build matrices runs-on: ubuntu-latest - strategy: - matrix: - archive: - - name: unit-tests - file: nextest-unit.tar.zst - flags: --workspace --all-features --lib --bins - - name: integration-tests - file: nextest-integration.tar.zst - flags: --workspace - - name: external-integration-tests - file: nextest-external-integration.tar.zst - flags: -p forge --features external-integration-tests + outputs: + build-matrix: ${{ steps.gen.outputs.build-matrix }} + test-matrix: ${{ steps.gen.outputs.test-matrix }} steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: taiki-e/install-action@nextest - - name: Build archive (unit tests) - run: | - cargo nextest archive \ - --locked \ - --archive-file ${{ matrix.archive.file }} \ - ${{ matrix.archive.flags }} - - name: Upload archive - uses: actions/upload-artifact@v3 + - uses: actions/setup-python@v4 with: - name: ${{ matrix.archive.name }} - path: ${{ matrix.archive.file }} - - install-svm-solc: - name: install svm and solidity / ${{ matrix.job.name }} - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Install svm - run: cargo install svm-rs - - name: Install Solidity 0.8.19 - run: svm install 0.8.19 - - name: Install Solidity 0.8.20 - run: svm install 0.8.20 - - name: Use Solidity 0.8.19 - run: svm use 0.8.19 - - unit: - name: unit tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests - timeout-minutes: 60 - strategy: - matrix: - job: - - name: non-forking - filter: "!test(~fork) & !test(~live)" - - name: forking - filter: "test(~fork) & !test(~live)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: unit-tests - - name: cargo nextest + python-version: "3.11" + - name: Generate matrices + id: gen + env: + EVENT_NAME: ${{ github.event_name }} run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file nextest-unit.tar.zst -E '${{ matrix.job.filter }}' + output=$(python3 .github/scripts/matrices.py) + echo "::debug::build-matrix=$output" + echo "build-matrix=$output" >> "$GITHUB_OUTPUT" - issue-repros-tests: - name: issue reproduction tests / ${{ matrix.job.name }} / ${{ matrix.job.partition }} - runs-on: ubuntu-latest - needs: build-tests - strategy: - matrix: - job: - - name: issue-repros - filter: "test(~issue)" - partition: [1, 2] - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: taiki-e/install-action@nextest - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: integration-tests - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.job.name != 'issue-repros' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" + export TEST=1 - - name: cargo nextest - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --partition count:${{ matrix.partition }}/2 --retries 3 --archive-file nextest-integration.tar.zst -E '${{ matrix.job.filter }}' + output=$(python3 .github/scripts/matrices.py) + echo "::debug::test-matrix=$output" + echo "test-matrix=$output" >> "$GITHUB_OUTPUT" - forge-std-tests: - name: forge std tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests + build-tests: + name: build tests + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + needs: matrices strategy: - matrix: - job: - - name: forge-std-test - filter: "test(~forge_std)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD + fail-fast: false + matrix: ${{ fromJson(needs.matrices.outputs.build-matrix) }} steps: - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 with: - name: integration-tests - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.job.name != 'forge-std-test' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest + target: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@nextest + - name: Build archive run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file nextest-integration.tar.zst -E '${{ matrix.job.filter }}' + cargo nextest archive \ + --workspace \ + --archive-file tests-${{ matrix.target }}.tar.zst + - name: Upload archive + uses: actions/upload-artifact@v3 + with: + name: tests-${{ matrix.target }} + path: tests-${{ matrix.target }}.tar.zst - integration: - name: integration tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests + test: + name: test ${{ matrix.name }} + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + needs: + - matrices + - build-tests strategy: - matrix: - job: - - name: non-forking - filter: "!test(~fork) & !test(~live) & !test(~issue) & !test(~forge_std)" - - name: forking - filter: "test(~fork) & !test(~live)" - partition: [1, 2] + fail-fast: false + matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 with: - name: integration-tests - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.job.name != 'non-forking' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --partition count:${{ matrix.partition }}/2 --retries 3 --archive-file nextest-integration.tar.zst -E '${{ matrix.job.filter }}' - - external-integration: - name: external integration tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests - strategy: - matrix: - job: - - name: non-forking - filter: "!test(~fork_integration) & !test(~live)" - - name: forking - filter: "test(~fork_integration) & !test(~live)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 + target: ${{ matrix.target }} - uses: taiki-e/install-action@nextest - - uses: dtolnay/rust-toolchain@stable - - name: Download archives + - name: Download archive uses: actions/download-artifact@v3 with: - name: external-integration-tests - + name: tests-${{ matrix.target }} - name: Forge RPC cache uses: actions/cache@v3 - if: matrix.job.name != 'non-forking' with: - path: "$HOME/.foundry/cache" + path: | + ~/.foundry/cache + ~/.config/.foundry/cache key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config run: | git config --global user.name "GitHub Actions Bot" git config --global user.email "<>" - - - name: Force use of HTTPS for submodules - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - - name: cargo nextest + - name: Test run: | # see https://github.com/foundry-rs/foundry/pull/3959 export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file nextest-external-integration.tar.zst -E '${{ matrix.job.filter }}' + cargo nextest run \ + --retries 2 \ + --archive-file tests-${{ matrix.target }}.tar.zst \ + ${{ matrix.flags }} doctests: name: doc tests @@ -251,13 +113,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: cargo test - run: cargo test --locked --workspace --all-features --doc - - cross-platform: - name: Cross-platform tests - if: github.event_name != 'pull_request' - needs: [unit, integration, doctests] - uses: ./.github/workflows/cross-platform.yml + run: cargo test --doc clippy: name: clippy diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index c7e48e46bd8b3..4ee9e0805ecc1 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -79,9 +79,6 @@ default = ["rustls"] rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-cli/openssl", "reqwest/default-tls"] -# feature for integration tests that test external projects -external-integration-tests = [] - # feature for heavy (long-running) integration tests heavy-integration-tests = [] diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs new file mode 100644 index 0000000000000..08edac73ec614 --- /dev/null +++ b/crates/forge/tests/cli/ext_integration.rs @@ -0,0 +1,27 @@ +use foundry_test_utils::forgetest_external; + +forgetest_external!(solmate, "transmissions11/solmate"); +forgetest_external!(prb_math, "PaulRBerg/prb-math"); +forgetest_external!(prb_proxy, "PaulRBerg/prb-proxy"); +forgetest_external!(solady, "Vectorized/solady"); +forgetest_external!( + geb, + "reflexer-labs/geb", + &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] +); +forgetest_external!(stringutils, "Arachnid/solidity-stringutils"); +forgetest_external!(lootloose, "gakonst/lootloose"); +forgetest_external!(lil_web3, "m1guelpf/lil-web3"); + +// Forking tests + +forgetest_external!(multicall, "makerdao/multicall", &["--block-number", "1"]); +forgetest_external!( + drai, + "mds1/drai", + 13633752, + &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] +); +forgetest_external!(gunilev, "hexonaut/guni-lev", 13633752); +forgetest_external!(convex, "mds1/convex-shutdown-simulation", 14445961); +forgetest_external!(sparklend, "marsfoundation/sparklend"); diff --git a/crates/forge/tests/cli/heavy_integration.rs b/crates/forge/tests/cli/heavy_integration.rs index 200fe0fc6d8fa..7363b0ca4ef68 100644 --- a/crates/forge/tests/cli/heavy_integration.rs +++ b/crates/forge/tests/cli/heavy_integration.rs @@ -1,6 +1,5 @@ //! Heavy integration tests that can take an hour to run or more. -//! All tests are prefixed with heavy so they can be filtered by nextest. use foundry_test_utils::forgetest_external; -forgetest_external!(heavy_maple, "maple-labs/maple-core-v2"); +forgetest_external!(maple, "maple-labs/maple-core-v2"); diff --git a/crates/forge/tests/cli/integration.rs b/crates/forge/tests/cli/integration.rs deleted file mode 100644 index a32bd95e22a4d..0000000000000 --- a/crates/forge/tests/cli/integration.rs +++ /dev/null @@ -1,37 +0,0 @@ -use foundry_test_utils::{forgetest_external, util::setup_forge_remote}; - -forgetest_external!(solmate, "transmissions11/solmate"); -forgetest_external!(prb_math, "PaulRBerg/prb-math"); -forgetest_external!(prb_proxy, "PaulRBerg/prb-proxy"); -forgetest_external!(solady, "Vectorized/solady"); -forgetest_external!( - geb, - "reflexer-labs/geb", - &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] -); -forgetest_external!(stringutils, "Arachnid/solidity-stringutils"); -forgetest_external!(lootloose, "gakonst/lootloose"); -forgetest_external!(lil_web3, "m1guelpf/lil-web3"); - -/// clone + build in one step -#[test] -#[ignore] -fn can_checkout_build() { - let (_prj, _cmd) = setup_forge_remote("transmissions11/solmate"); -} - -/// Forking tests -mod fork_integration { - use foundry_test_utils::forgetest_external; - - forgetest_external!(multicall, "makerdao/multicall", &["--block-number", "1"]); - forgetest_external!( - drai, - "mds1/drai", - 13633752, - &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] - ); - forgetest_external!(gunilev, "hexonaut/guni-lev", 13633752); - forgetest_external!(convex, "mds1/convex-shutdown-simulation", 14445961); - forgetest_external!(sparklend, "marsfoundation/sparklend"); -} diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 1892172dabecf..0a05fe038be88 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -1,29 +1,18 @@ -#[cfg(not(feature = "external-integration-tests"))] +pub mod constants; +pub mod utils; + mod cache; -#[cfg(not(feature = "external-integration-tests"))] mod cmd; -#[cfg(not(feature = "external-integration-tests"))] mod config; -#[cfg(not(feature = "external-integration-tests"))] mod create; -#[cfg(not(feature = "external-integration-tests"))] mod doc; -#[cfg(not(feature = "external-integration-tests"))] mod multi_script; -#[cfg(not(feature = "external-integration-tests"))] mod script; mod svm; -#[cfg(not(feature = "external-integration-tests"))] mod test_cmd; -#[cfg(not(feature = "external-integration-tests"))] -mod utils; -#[cfg(not(feature = "external-integration-tests"))] mod verify; -#[cfg(feature = "external-integration-tests")] -mod integration; +mod ext_integration; #[cfg(feature = "heavy-integration-tests")] mod heavy_integration; - -pub mod constants; diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index be761193d4954..5635098edf53e 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -2,7 +2,7 @@ use foundry_test_utils::{forgetest_init, TestCommand, TestProject}; use semver::Version; -use svm::{self, Platform}; +use svm::Platform; /// The latest solc release /// @@ -14,14 +14,12 @@ use svm::{self, Platform}; const LATEST_SOLC: Version = Version::new(0, 8, 21); macro_rules! ensure_svm_releases { - ($($test:ident => $platform:ident),*) => { - $( + ($($test:ident => $platform:ident),* $(,)?) => {$( #[tokio::test(flavor = "multi_thread")] async fn $test() { ensure_latest_release(Platform::$platform).await } - )* - }; + )*}; } async fn ensure_latest_release(platform: Platform) { @@ -30,7 +28,7 @@ async fn ensure_latest_release(platform: Platform) { .unwrap_or_else(|err| panic!("Could not fetch releases for {platform}: {err:?}")); assert!( releases.releases.contains_key(&LATEST_SOLC), - "platform {platform:?} is missing solc info {LATEST_SOLC}" + "platform {platform:?} is missing solc info for v{LATEST_SOLC}" ); } @@ -45,26 +43,20 @@ ensure_svm_releases!( // Ensures we can always test with the latest solc build forgetest_init!(can_test_with_latest_solc, |prj: TestProject, mut cmd: TestCommand| { - prj.inner() - .add_test( - "Counter", - r#" + let src = format!( + r#" // SPDX-License-Identifier: UNLICENSED -pragma solidity =; +pragma solidity ={LATEST_SOLC}; import "forge-std/Test.sol"; -contract CounterTest is Test { - - function testAssert() public { - assert(true); - } -} - "# - .replace("", &LATEST_SOLC.to_string()), - ) - .unwrap(); - - cmd.args(["test"]); - cmd.stdout().contains("[PASS]") +contract CounterTest is Test {{ + function testAssert() public {{ + assert(true); + }} +}} + "# + ); + prj.inner().add_test("Counter", src).unwrap(); + cmd.arg("test").stdout().contains("[PASS]") }); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 54cd9e4f84a64..1fc8522d407b0 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -286,6 +286,6 @@ async fn test_issue_5038() { // #[tokio::test(flavor = "multi_thread")] -async fn test_issue3792() { +async fn test_issue_3792() { test_repro!("Issue3792"); } From 4a12c6e65c91ab0aabfe1d05b660c4eee06e9303 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:57:00 +0200 Subject: [PATCH 0006/1963] ci: fix build matrix (#5664) --- .github/scripts/matrices.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) mode change 100644 => 100755 .github/scripts/matrices.py diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py old mode 100644 new mode 100755 index 19b7be5a8a17c..7c3e3f4bc896d --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import json import os @@ -88,12 +90,10 @@ def __init__(self, os: str, target: str, name: str, flags: str, partition: int): def build_matrix(): - os_ids = [] - targets_ = [] + expanded = [] for target in targets: - os_ids.append(target.os_id) - targets_.append(target.target) - print(json.dumps({"os": os_ids, "target": targets_})) + expanded.append({"os": target.os_id, "target": target.target}) + print_json({"include": expanded}) def test_matrix(): @@ -125,7 +125,11 @@ def test_matrix(): ) expanded.append(vars(obj)) - print(json.dumps({"include": expanded}), end="", flush=True) + print_json({"include": expanded}) + + +def print_json(obj): + print(json.dumps(obj), end="", flush=True) if __name__ == "__main__": From b2d9e9268d64f874ac07908fb8671b5ace112f28 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 18 Aug 2023 17:12:11 -0400 Subject: [PATCH 0007/1963] chore: fix name for correct casing (#5665) --- crates/abi/abi/HEVM.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index ee657241d9ea3..ec9f1eff31d3f 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -3,7 +3,7 @@ struct Rpc { string name; string url; } 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 exit_code; bytes stdout; bytes stderr; } +struct FfiResult { int32 exitCode; bytes stdout; bytes stderr; } allowCheatcodes(address) From 45b100f002b744e537a2e73739a37b9bbda6c26f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 18 Aug 2023 23:27:29 +0200 Subject: [PATCH 0008/1963] ci: explicitly set bash as shell (#5666) --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e877f25407364..3d5f3c0af4f8b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,6 +52,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - uses: taiki-e/install-action@nextest - name: Build archive + shell: bash run: | cargo nextest archive \ --workspace \ @@ -96,6 +97,7 @@ jobs: git config --global user.name "GitHub Actions Bot" git config --global user.email "<>" - name: Test + shell: bash run: | # see https://github.com/foundry-rs/foundry/pull/3959 export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" From 06a17bfe3265209a854353337cc4277c1a4c73d1 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 18 Aug 2023 19:12:47 -0400 Subject: [PATCH 0009/1963] fix(ci): force using http for submodules & setup git config on heavy (#5668) --- .github/workflows/heavy-integration.yml | 6 ++++++ .github/workflows/test.yml | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index db45353eb85da..dc5e7e08e50d1 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -27,6 +27,12 @@ jobs: ~/.foundry/cache ~/.config/.foundry/cache key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} + - name: Setup git config + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "<>" + - name: Force use of HTTPS for submodules + run: git config --global url."https://github.com/".insteadOf "git@github.com:" - name: test run: | cargo nextest run -r -p forge --test cli --features heavy-integration-tests --retries 1 -E 'test(~heavy_integration)' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d5f3c0af4f8b..99305949e713e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,6 +96,8 @@ jobs: run: | git config --global user.name "GitHub Actions Bot" git config --global user.email "<>" + - name: Force use of HTTPS for submodules + run: git config --global url."https://github.com/".insteadOf "git@github.com:" - name: Test shell: bash run: | From d8d1bdf5d8fdb6a5282c30bc6eaaed06def2ac3f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 19 Aug 2023 13:12:26 +0200 Subject: [PATCH 0010/1963] ci: relax timeout-minutes for release jobs (#5672) --- .github/workflows/docker-publish.yml | 3 +-- .github/workflows/heavy-integration.yml | 1 + .github/workflows/release.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4f52a545d5a7c..76414aae750ac 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -23,8 +23,7 @@ jobs: id-token: write packages: write contents: read - timeout-minutes: 30 - + timeout-minutes: 120 steps: - name: Checkout repository id: checkout diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index dc5e7e08e50d1..717a277fd3f94 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -13,6 +13,7 @@ jobs: heavy-integration: name: heavy (long-running) integration tests runs-on: ubuntu-latest + timeout-minutes: 120 env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43dc1178a1087..50224c8a81cc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,12 +16,11 @@ jobs: prepare: name: Prepare release runs-on: ubuntu-20.04 - + timeout-minutes: 30 outputs: tag_name: ${{ steps.release_info.outputs.tag_name }} release_name: ${{ steps.release_info.outputs.release_name }} changelog: ${{ steps.build_changelog.outputs.changelog }} - steps: - uses: actions/checkout@v3 with: @@ -69,6 +68,7 @@ jobs: release: name: ${{ matrix.job.target }} (${{ matrix.job.os }}) runs-on: ${{ matrix.job.os }} + timeout-minutes: 60 needs: prepare strategy: matrix: @@ -217,8 +217,8 @@ jobs: cleanup: name: Release cleanup runs-on: ubuntu-20.04 + timeout-minutes: 30 needs: release - steps: - uses: actions/checkout@v3 From 1f20a02cb8be7676629a867a25b1ff97d0bccb53 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 19 Aug 2023 13:12:59 +0200 Subject: [PATCH 0011/1963] ci: open an issue if any release job fails (#5673) --- .github/workflows/heavy-integration.yml | 8 ++++-- .github/workflows/release.yml | 34 +++++++++++++++---------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index 717a277fd3f94..6275f0424504b 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -38,9 +38,13 @@ jobs: run: | cargo nextest run -r -p forge --test cli --features heavy-integration-tests --retries 1 -E 'test(~heavy_integration)' - # If any of the steps fail, this will create a high-priority issue to signal so. + # If any of the jobs fail, this will create a high-priority issue to signal so. + issue: + name: Open an issue + runs-on: ubuntu-latest + if: ${{ failure() }} + steps: - uses: JasonEtco/create-an-issue@v2 - if: ${{ failure() }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_URL: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50224c8a81cc8..7bb49ff331c00 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -138,7 +138,8 @@ jobs: PLATFORM_NAME: ${{ matrix.job.platform }} TARGET: ${{ matrix.job.target }} ARCH: ${{ matrix.job.arch }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + VERSION_NAME: | + ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} run: | if [ "$PLATFORM_NAME" == "linux" ]; then tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel @@ -162,7 +163,8 @@ jobs: env: PLATFORM_NAME: ${{ matrix.job.platform }} TARGET: ${{ matrix.job.target }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + VERSION_NAME: | + ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} run: | sudo apt-get -y install help2man help2man -N ./target/${TARGET}/release/forge > forge.1 @@ -203,17 +205,6 @@ jobs: ${{ steps.artifacts.outputs.file_name }} ${{ steps.man.outputs.foundry_man }} - # If any of the steps fail, this will create a high-priority issue - # to signal so. - - uses: JasonEtco/create-an-issue@v2 - if: ${{ failure() }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - with: - update_existing: true - filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md - cleanup: name: Release cleanup runs-on: ubuntu-20.04 @@ -236,4 +227,19 @@ jobs: with: script: | const prunePrereleases = require('./.github/scripts/prune-prereleases.js') - await prunePrereleases({github, context}) \ No newline at end of file + await prunePrereleases({github, context}) + + # If any of the jobs fail, this will create a high-priority issue to signal so. + issue: + name: Open an issue + runs-on: ubuntu-latest + if: ${{ failure() }} + steps: + - uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_URL: | + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + update_existing: true + filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md From 225acf3aa105822f708e5f71d7ea2692c50a3d09 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 19 Aug 2023 13:13:52 +0200 Subject: [PATCH 0012/1963] test: fix some windows tests (#5671) --- crates/forge/tests/cli/config.rs | 15 +++++++++------ crates/forge/tests/it/invariant.rs | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 597f304f75154..e4912732bbcd9 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -223,14 +223,13 @@ forgetest_init!( let profile = Config::load_with_root(prj.root()); // ensure that the auto-generated internal remapping for forge-std's ds-test exists assert_eq!(profile.remappings.len(), 2); - pretty_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); + let [r, _] = &profile.remappings[..] else { unreachable!() }; + pretty_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", r.to_string()); - // ensure remappings contain test - pretty_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); // the loaded config has resolved, absolute paths pretty_eq!( "ds-test/=lib/forge-std/lib/ds-test/src/", - Remapping::from(profile.remappings[0].clone()).to_string() + Remapping::from(r.clone()).to_string() ); cmd.arg("config"); @@ -250,14 +249,18 @@ forgetest_init!( "solmate/=lib/solmate/src/\nsolmate-contracts/=lib/solmate/src/", ); let config = forge_utils::load_config_with_root(Some(prj.root().into())); + // trailing slashes are removed on windows `to_slash_lossy` + let path = prj.root().join("lib/solmate/src/").to_slash_lossy().into_owned(); + #[cfg(windows)] + let path = path + "/"; pretty_eq!( - format!("solmate/={}", prj.root().join("lib/solmate/src/").to_slash_lossy()), + format!("solmate/={path}"), Remapping::from(config.remappings[0].clone()).to_string() ); // As this is an user-generated remapping, it is not removed, even if it points to the same // location. pretty_eq!( - format!("solmate-contracts/={}", prj.root().join("lib/solmate/src/").to_slash_lossy()), + format!("solmate-contracts/={path}"), Remapping::from(config.remappings[1].clone()).to_string() ); pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 8b50f84acaf0a..9b9bde915474a 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -114,7 +114,7 @@ async fn test_invariant_storage() { let mut runner = runner().await; let mut opts = test_opts(); - opts.invariant.depth = 100; + opts.invariant.depth = 100 + (50 * cfg!(windows) as u32); opts.fuzz.seed = Some(U256::from(6u32)); runner.test_options = opts.clone(); From aad990c9c76d141d8bd55a84f87fcb6c0424b5dc Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 19 Aug 2023 17:09:51 +0200 Subject: [PATCH 0013/1963] ci: fix deprecation warnings (#5674) --- .github/workflows/docker-publish.yml | 6 +++--- .github/workflows/release.yml | 25 +++++++++++-------------- .github/workflows/test.yml | 4 ++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 76414aae750ac..8af9cfa2757f7 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -63,13 +63,13 @@ jobs: run: | if [[ "${{ github.event_name }}" == 'schedule' ]]; then echo "cron trigger, assigning nightly tag" - echo "::set-output name=docker_tags::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" + echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then echo "manual trigger from master/main branch, assigning latest tag" - echo "::set-output name=docker_tags::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" + echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT else echo "Neither scheduled nor manual release from main branch. Just tagging as branch name" - echo "::set-output name=docker_tags::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" + echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT fi # Log docker metadata to explicitly know what is being pushed diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bb49ff331c00..ea4b26b8decf0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,11 +30,11 @@ jobs: id: release_info run: | if [[ $IS_NIGHTLY ]]; then - echo "::set-output name=tag_name::nightly-${GITHUB_SHA}" - echo "::set-output name=release_name::Nightly ($(date '+%Y-%m-%d'))" + echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT + echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT else - echo "::set-output name=tag_name::${GITHUB_REF_NAME}" - echo "::set-output name=release_name::${GITHUB_REF_NAME}" + echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT + echo "release_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT fi # Creates a `nightly-SHA` tag for this specific nightly @@ -125,12 +125,9 @@ jobs: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - name: Build binaries - uses: actions-rs/cargo@v1 env: SVM_TARGET_PLATFORM: ${{ matrix.job.svm_target_platform }} - with: - command: build - args: --release --bins --target ${{ matrix.job.target }} + run: cargo build --release --bins --target ${{ matrix.job.target }} - name: Archive binaries id: artifacts @@ -140,22 +137,22 @@ jobs: ARCH: ${{ matrix.job.arch }} VERSION_NAME: | ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + shell: bash run: | if [ "$PLATFORM_NAME" == "linux" ]; then tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel - echo "::set-output name=file_name::foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT elif [ "$PLATFORM_NAME" == "darwin" ]; then # We need to use gtar here otherwise the archive is corrupt. # See: https://github.com/actions/virtual-environments/issues/2619 gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel - echo "::set-output name=file_name::foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT else cd ./target/${TARGET}/release 7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe anvil.exe chisel.exe mv "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../ - echo "::set-output name=file_name::foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT fi - shell: bash - name: Build man page id: man @@ -165,6 +162,7 @@ jobs: TARGET: ${{ matrix.job.target }} VERSION_NAME: | ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + shell: bash run: | sudo apt-get -y install help2man help2man -N ./target/${TARGET}/release/forge > forge.1 @@ -176,8 +174,7 @@ jobs: gzip anvil.1 gzip chisel.1 tar -czvf "foundry_man_${VERSION_NAME}.tar.gz" forge.1.gz cast.1.gz anvil.1.gz chisel.1.gz - echo "::set-output name=foundry_man::foundry_man_${VERSION_NAME}.tar.gz" - shell: bash + echo "foundry_man=foundry_man_${VERSION_NAME}.tar.gz" >> $GITHUB_OUTPUT # Creates the release for this specific version - name: Create release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99305949e713e..cc4ed94ddcd85 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,13 +28,13 @@ jobs: run: | output=$(python3 .github/scripts/matrices.py) echo "::debug::build-matrix=$output" - echo "build-matrix=$output" >> "$GITHUB_OUTPUT" + echo "build-matrix=$output" >> $GITHUB_OUTPUT export TEST=1 output=$(python3 .github/scripts/matrices.py) echo "::debug::test-matrix=$output" - echo "test-matrix=$output" >> "$GITHUB_OUTPUT" + echo "test-matrix=$output" >> $GITHUB_OUTPUT build-tests: name: build tests From 628686d33cf343ac7c4d2c81ac432cb318c34d9a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 19 Aug 2023 17:10:03 +0200 Subject: [PATCH 0014/1963] perf: tweak optimizations again (#5663) --- Cargo.toml | 18 ++++++++++++------ crates/cli/src/utils/cmd.rs | 4 ++-- crates/evm/src/fuzz/invariant/error.rs | 9 +++------ crates/evm/src/fuzz/invariant/executor.rs | 8 ++++---- crates/evm/src/trace/decoder.rs | 14 +++++++++++--- crates/forge/src/runner.rs | 7 +++---- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 71828bf6c14a7..d799d70f4b66e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,14 +19,22 @@ debug = 0 # Speed up tests and dev build [profile.dev.package] +# solc +ethers-solc.opt-level = 3 +solang-parser.opt-level = 3 +serde_json.opt-level = 3 + # evm revm.opt-level = 3 revm-primitives.opt-level = 3 revm-interpreter.opt-level = 3 revm-precompile.opt-level = 3 tiny-keccak.opt-level = 3 +sha2.opt-level = 3 +sha3.opt-level = 3 +keccak.opt-level = 3 ruint.opt-level = 3 -primitive-types.opt-level = 3 +hashbrown.opt-level = 3 # keystores scrypt.opt-level = 3 @@ -48,7 +56,6 @@ codegen-units = 1 # Package overrides foundry-evm.opt-level = 3 -ethers-solc.opt-level = 1 foundry-abi.opt-level = 1 mdbook.opt-level = 1 protobuf.opt-level = 1 @@ -93,12 +100,11 @@ wasm-bindgen-backend.opt-level = 0 # Local "release" mode, more optimized than dev but much faster to compile than release [profile.local] -inherits = "release" +inherits = "dev" opt-level = 1 -lto = "none" +strip = true +panic = "abort" codegen-units = 16 -# Empty, clears `profile.release.package` -package = {} [workspace.dependencies] anvil = { path = "crates/anvil" } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 44a5dbc6f4b92..e41790a27fcf9 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -393,7 +393,7 @@ pub async fn handle_traces( let (sources, bytecode) = etherscan_identifier.get_compiled_contracts().await?; run_debugger(result, decoder, bytecode, sources)?; } else { - print_traces(&mut result, decoder, verbose).await?; + print_traces(&mut result, &decoder, verbose).await?; } Ok(()) @@ -401,7 +401,7 @@ pub async fn handle_traces( pub async fn print_traces( result: &mut TraceResult, - decoder: CallTraceDecoder, + decoder: &CallTraceDecoder, verbose: bool, ) -> Result<()> { if result.traces.is_empty() { diff --git a/crates/evm/src/fuzz/invariant/error.rs b/crates/evm/src/fuzz/invariant/error.rs index c09e52e85ab3c..2f1be0c510a03 100644 --- a/crates/evm/src/fuzz/invariant/error.rs +++ b/crates/evm/src/fuzz/invariant/error.rs @@ -166,15 +166,12 @@ impl InvariantFuzzError { anchor: usize, removed_calls: &[usize], ) -> Result, ()> { - let calls = calls.iter().enumerate().filter_map(|(index, element)| { + let mut new_sequence = Vec::with_capacity(calls.len()); + for (index, details) in calls.iter().enumerate() { if anchor > index || removed_calls.contains(&index) { - return None + continue } - Some(element) - }); - let mut new_sequence = vec![]; - for details in calls { new_sequence.push(details); let (sender, (addr, bytes)) = details; diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index acbffe60347f9..3907884d02338 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -98,9 +98,9 @@ impl<'a> InvariantExecutor<'a> { /// Returns a list of all the consumed gas and calldata of every invariant fuzz case pub fn invariant_fuzz( &mut self, - invariant_contract: InvariantContract, + invariant_contract: &InvariantContract, ) -> eyre::Result { - let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract)?; + let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(invariant_contract)?; // Stores the consumed gas and calldata of every successful fuzz call. let fuzz_cases: RefCell> = RefCell::new(Default::default()); @@ -113,7 +113,7 @@ impl<'a> InvariantExecutor<'a> { let last_call_results = RefCell::new( assert_invariants( - &invariant_contract, + invariant_contract, &blank_executor.borrow(), &[], &mut failures.borrow_mut(), @@ -199,7 +199,7 @@ impl<'a> InvariantExecutor<'a> { }); let RichInvariantResults { success: can_continue, call_results } = can_continue( - &invariant_contract, + invariant_contract, call_result, &executor, &inputs, diff --git a/crates/evm/src/trace/decoder.rs b/crates/evm/src/trace/decoder.rs index f8e8ae651a1c3..c2a51c6dad77b 100644 --- a/crates/evm/src/trace/decoder.rs +++ b/crates/evm/src/trace/decoder.rs @@ -15,6 +15,7 @@ use ethers::{ }; use foundry_common::{abi::get_indexed_event, SELECTOR_LEN}; use hashbrown::HashSet; +use once_cell::sync::OnceCell; use std::collections::{BTreeMap, HashMap}; /// Build a new [CallTraceDecoder]. @@ -25,7 +26,7 @@ pub struct CallTraceDecoderBuilder { impl CallTraceDecoderBuilder { pub fn new() -> Self { - Self { decoder: CallTraceDecoder::new() } + Self { decoder: CallTraceDecoder::new().clone() } } /// Add known labels to the decoder. @@ -65,7 +66,7 @@ impl CallTraceDecoderBuilder { /// /// Note that a call trace decoder is required for each new set of traces, since addresses in /// different sets might overlap. -#[derive(Default, Debug)] +#[derive(Clone, Default, Debug)] pub struct CallTraceDecoder { /// Information for decoding precompile calls. pub precompiles: HashMap, @@ -115,7 +116,14 @@ impl CallTraceDecoder { /// /// The call trace decoder always knows how to decode calls to the cheatcode address, as well /// as DSTest-style logs. - pub fn new() -> Self { + pub fn new() -> &'static Self { + // If you want to take arguments in this function, assign them to the fields of the cloned + // lazy instead of removing it + static INIT: OnceCell = OnceCell::new(); + INIT.get_or_init(Self::init) + } + + fn init() -> Self { Self { // TODO: These are the Ethereum precompiles. We should add a way to support precompiles // for other networks, too. diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index b500309d4bc06..c489429696a80 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -451,15 +451,14 @@ impl<'a> ContractRunner<'a> { InvariantContract { address, invariant_functions: functions, abi: self.contract }; let Ok(InvariantFuzzTestResult { invariants, cases, reverts, last_run_inputs }) = - evm.invariant_fuzz(invariant_contract.clone()) + evm.invariant_fuzz(&invariant_contract) else { return vec![] }; invariants .into_values() - .map(|test_error| { - let (test_error, invariant) = test_error; + .map(|(test_error, invariant)| { let mut counterexample = None; let mut logs = logs.clone(); let mut traces = traces.clone(); @@ -495,7 +494,7 @@ impl<'a> ContractRunner<'a> { // If invariants ran successfully, replay the last run to collect logs and // traces. replay_run( - &invariant_contract.clone(), + &invariant_contract, self.executor.clone(), known_contracts, identified_contracts.clone(), From 2e90e35ee52efeba74c06a1484bdc1fb96d01a0e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:25:40 +0200 Subject: [PATCH 0015/1963] refactor: clean up evm inspectors (#5675) * refactor: clean up evm inspectors * tests --- crates/anvil/src/eth/backend/mem/inspector.rs | 110 ++---- crates/anvil/src/eth/backend/mem/mod.rs | 12 +- crates/chisel/src/executor.rs | 17 +- crates/chisel/src/runner.rs | 23 +- crates/evm/src/executor/builder.rs | 120 +++---- .../evm/src/executor/inspector/access_list.rs | 6 +- .../src/executor/inspector/cheatcodes/mod.rs | 28 +- .../src/executor/inspector/chisel_state.rs | 10 +- crates/evm/src/executor/inspector/coverage.rs | 9 +- crates/evm/src/executor/inspector/debugger.rs | 27 +- crates/evm/src/executor/inspector/fuzzer.rs | 8 +- crates/evm/src/executor/inspector/logs.rs | 5 +- crates/evm/src/executor/inspector/mod.rs | 108 +----- crates/evm/src/executor/inspector/printer.rs | 65 +--- crates/evm/src/executor/inspector/stack.rs | 319 +++++++++++++++--- crates/evm/src/executor/inspector/tracer.rs | 60 ++-- crates/evm/src/executor/mod.rs | 119 +++---- .../evm/src/fuzz/invariant/call_override.rs | 4 +- crates/evm/src/fuzz/invariant/executor.rs | 6 +- crates/evm/src/fuzz/invariant/mod.rs | 4 +- crates/evm/src/fuzz/mod.rs | 4 +- crates/evm/src/fuzz/strategies/state.rs | 18 +- crates/evm/src/trace/executor.rs | 20 +- crates/evm/src/utils.rs | 93 ++--- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/script/executor.rs | 23 +- crates/forge/bin/cmd/script/runner.rs | 17 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/multi_runner.rs | 24 +- crates/forge/src/runner.rs | 9 +- 30 files changed, 596 insertions(+), 676 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 805f01e3c3bc1..ca409b734a1f3 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -9,18 +9,15 @@ use foundry_evm::{ executor::inspector::{LogCollector, Tracer}, revm, revm::{ - inspectors::GasInspector, interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, primitives::{B160, B256}, EVMData, }, }; -use std::{cell::RefCell, rc::Rc}; /// The [`revm::Inspector`] used when transacting in the evm #[derive(Debug, Clone, Default)] pub struct Inspector { - pub gas: Option>>, pub tracer: Option, /// collects all `console.sol` logs pub log_collector: LogCollector, @@ -42,51 +39,42 @@ impl Inspector { self } - /// Enables steps recording for `Tracer` and attaches `GasInspector` to it - /// If `Tracer` wasn't configured before, configures it automatically + /// Enables steps recording for `Tracer`. pub fn with_steps_tracing(mut self) -> Self { - if self.tracer.is_none() { - self = self.with_tracing() - } - let gas_inspector = Rc::new(RefCell::new(GasInspector::default())); - self.gas = Some(gas_inspector.clone()); - self.tracer = self.tracer.map(|tracer| tracer.with_steps_recording(gas_inspector)); - + let tracer = self.tracer.get_or_insert_with(Default::default); + tracer.record_steps(); self } } impl revm::Inspector for Inspector { + #[inline] fn initialize_interp( &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, is_static: bool, ) -> InstructionResult { - call_inspectors!( - inspector, - [&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer], - { inspector.initialize_interp(interp, data, is_static) } - ); + call_inspectors!([&mut self.tracer], |inspector| { + inspector.initialize_interp(interp, data, is_static); + }); InstructionResult::Continue } + #[inline] fn step( &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, is_static: bool, ) -> InstructionResult { - call_inspectors!( - inspector, - [&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer], - { - inspector.step(interp, data, is_static); - } - ); + call_inspectors!([&mut self.tracer], |inspector| { + inspector.step(interp, data, is_static); + }); InstructionResult::Continue } + #[inline] fn log( &mut self, evm_data: &mut EVMData<'_, DB>, @@ -94,19 +82,12 @@ impl revm::Inspector for Inspector { topics: &[B256], data: &Bytes, ) { - call_inspectors!( - inspector, - [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), - &mut self.tracer, - Some(&mut self.log_collector) - ], - { - inspector.log(evm_data, address, topics, data); - } - ); + call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { + inspector.log(evm_data, address, topics, data); + }); } + #[inline] fn step_end( &mut self, interp: &mut Interpreter, @@ -114,37 +95,27 @@ impl revm::Inspector for Inspector { is_static: bool, eval: InstructionResult, ) -> InstructionResult { - call_inspectors!( - inspector, - [&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer], - { - inspector.step_end(interp, data, is_static, eval); - } - ); + call_inspectors!([&mut self.tracer], |inspector| { + inspector.step_end(interp, data, is_static, eval); + }); eval } + #[inline] fn call( &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, is_static: bool, ) -> (InstructionResult, Gas, Bytes) { - call_inspectors!( - inspector, - [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), - &mut self.tracer, - Some(&mut self.log_collector) - ], - { - inspector.call(data, call, is_static); - } - ); + call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { + inspector.call(data, call, is_static); + }); (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) } + #[inline] fn call_end( &mut self, data: &mut EVMData<'_, DB>, @@ -154,32 +125,26 @@ impl revm::Inspector for Inspector { out: Bytes, is_static: bool, ) -> (InstructionResult, Gas, Bytes) { - call_inspectors!( - inspector, - [&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer], - { - inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static); - } - ); + call_inspectors!([&mut self.tracer], |inspector| { + inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static); + }); (ret, remaining_gas, out) } + #[inline] fn create( &mut self, data: &mut EVMData<'_, DB>, call: &mut CreateInputs, ) -> (InstructionResult, Option, Gas, Bytes) { - call_inspectors!( - inspector, - [&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer], - { - inspector.create(data, call); - } - ); + call_inspectors!([&mut self.tracer], |inspector| { + inspector.create(data, call); + }); (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()) } + #[inline] fn create_end( &mut self, data: &mut EVMData<'_, DB>, @@ -189,18 +154,15 @@ impl revm::Inspector for Inspector { gas: Gas, retdata: Bytes, ) -> (InstructionResult, Option, Gas, Bytes) { - call_inspectors!( - inspector, - [&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer], - { - inspector.create_end(data, inputs, status, address, gas, retdata.clone()); - } - ); + call_inspectors!([&mut self.tracer], |inspector| { + inspector.create_end(data, inputs, status, address, gas, retdata.clone()); + }); (status, address, gas, retdata) } } /// Prints all the logs +#[inline] pub fn print_logs(logs: &[Log]) { for log in decode_console_logs(logs) { node_info!("{}", log); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index c0d9b0bc3a054..3b9a6bf263745 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -347,7 +347,7 @@ impl Backend { } pub fn precompiles(&self) -> Vec
{ - get_precompiles_for(self.env().read().cfg.spec_id) + get_precompiles_for(self.env.read().cfg.spec_id) } /// Resets the fork to a fresh state @@ -541,12 +541,12 @@ impl Backend { /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { - self.env().read().block.gas_limit.into() + self.env.read().block.gas_limit.into() } /// Sets the block gas limit pub fn set_gas_limit(&self, gas_limit: U256) { - self.env().write().block.gas_limit = gas_limit.into(); + self.env.write().block.gas_limit = gas_limit.into(); } /// Returns the current base fee @@ -791,7 +791,7 @@ impl Backend { let (outcome, header, block_hash) = { let current_base_fee = self.base_fee(); - let mut env = self.env().read().clone(); + let mut env = self.env.read().clone(); if env.block.basefee == revm::primitives::U256::ZERO { // this is an edge case because the evm fails if `tx.effective_gas_price < base_fee` @@ -1631,7 +1631,7 @@ impl Backend { // So this provides calls the given provided function `f` with a genesis aware database if let Some(fork) = self.get_fork() { if block_number == U256::from(fork.block_number()) { - let mut block = self.env().read().block.clone(); + let mut block = self.env.read().block.clone(); let db = self.db.read().await; let gen_db = self.genesis.state_db_at_genesis(Box::new(&*db)); @@ -1651,7 +1651,7 @@ impl Backend { } let db = self.db.read().await; - let block = self.env().read().block.clone(); + let block = self.env.read().block.clone(); Ok(f(Box::new(&*db), block)) } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index dc536d9801f42..246b6f5871ec1 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -290,14 +290,15 @@ impl SessionSource { }; // Build a new executor - let executor = ExecutorBuilder::default() - .with_config(env) - .with_chisel_state(final_pc) - .set_tracing(true) - .with_spec(foundry_evm::utils::evm_spec(&self.config.foundry_config.evm_version)) - .with_gas_limit(self.config.evm_opts.gas_limit()) - .with_cheatcodes(CheatsConfig::new(&self.config.foundry_config, &self.config.evm_opts)) - .build(backend); + let executor = ExecutorBuilder::new() + .inspectors(|stack| { + stack.chisel_state(final_pc).trace(true).cheatcodes( + CheatsConfig::new(&self.config.foundry_config, &self.config.evm_opts).into(), + ) + }) + .gas_limit(self.config.evm_opts.gas_limit()) + .spec(foundry_evm::utils::evm_spec(self.config.foundry_config.evm_version)) + .build(env, backend); // Create a [ChiselRunner] with a default balance of [U256::MAX] and // the sender [Address::zero]. diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 45aa46f93342f..e03a76e11e721 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -132,20 +132,19 @@ impl ChiselRunner { value: U256, commit: bool, ) -> eyre::Result { - let fs_commit_changed = - if let Some(ref mut cheatcodes) = self.executor.inspector_config_mut().cheatcodes { - let original_fs_commit = cheatcodes.fs_commit; - cheatcodes.fs_commit = false; - original_fs_commit != cheatcodes.fs_commit - } else { - false - }; + let fs_commit_changed = if let Some(cheatcodes) = &mut self.executor.inspector.cheatcodes { + let original_fs_commit = cheatcodes.fs_commit; + cheatcodes.fs_commit = false; + original_fs_commit != cheatcodes.fs_commit + } else { + false + }; let mut res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { // store the current gas limit and reset it later - let init_gas_limit = self.executor.env_mut().tx.gas_limit; + let init_gas_limit = self.executor.env.tx.gas_limit; // the executor will return the _exact_ gas value this transaction consumed, setting // this value as gas limit will result in `OutOfGas` so to come up with a @@ -156,7 +155,7 @@ impl ChiselRunner { let mut last_highest_gas_limit = highest_gas_limit; while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; - self.executor.env_mut().tx.gas_limit = mid_gas_limit; + self.executor.env.tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; match res.exit_reason { InstructionResult::Revert | @@ -182,13 +181,13 @@ impl ChiselRunner { } } // reset gas limit in the - self.executor.env_mut().tx.gas_limit = init_gas_limit; + self.executor.env.tx.gas_limit = init_gas_limit; } // if we changed `fs_commit` during gas limit search, re-execute the call with original // value if fs_commit_changed { - if let Some(ref mut cheatcodes) = self.executor.inspector_config_mut().cheatcodes { + if let Some(cheatcodes) = &mut self.executor.inspector.cheatcodes { cheatcodes.fs_commit = !cheatcodes.fs_commit; } diff --git a/crates/evm/src/executor/builder.rs b/crates/evm/src/executor/builder.rs index 5e021c7658c65..9369bc4f2a0a2 100644 --- a/crates/evm/src/executor/builder.rs +++ b/crates/evm/src/executor/builder.rs @@ -1,112 +1,74 @@ -use super::{ - inspector::{Cheatcodes, Fuzzer, InspectorStackConfig}, - Executor, -}; -use crate::{ - executor::{backend::Backend, inspector::CheatsConfig}, - fuzz::{invariant::RandomCallGenerator, strategies::EvmFuzzState}, -}; +use super::{inspector::InspectorStackBuilder, Executor}; +use crate::executor::backend::Backend; use ethers::types::U256; use revm::primitives::{Env, SpecId}; /// The builder that allows to configure an evm [`Executor`] which a stack of optional -/// [`revm::Inspector`]s, such as [`Cheatcodes`] +/// [`revm::Inspector`]s, such as [`Cheatcodes`]. /// -/// By default, the [`Executor`] will be configured with an empty [`InspectorStack`] -#[derive(Default, Debug)] +/// By default, the [`Executor`] will be configured with an empty [`InspectorStack`]. +/// +/// [`Cheatcodes`]: super::inspector::Cheatcodes +/// [`InspectorStack`]: super::inspector::InspectorStack +#[derive(Debug)] +#[must_use = "builders do nothing unless you call `build` on them"] pub struct ExecutorBuilder { - /// The execution environment configuration. - env: Env, /// The configuration used to build an [InspectorStack]. - inspector_config: InspectorStackConfig, + stack: InspectorStackBuilder, + /// The gas limit. gas_limit: Option, + /// The spec ID. + spec_id: SpecId, } -// === impl ExecutorBuilder === - -impl ExecutorBuilder { - /// Enables cheatcodes on the executor. - #[must_use] - pub fn with_cheatcodes(mut self, config: CheatsConfig) -> Self { - self.inspector_config.cheatcodes = - Some(Cheatcodes::new(self.env.block.clone(), self.env.tx.gas_price.into(), config)); - self - } - - /// Enables or disables tracing - #[must_use] - pub fn set_tracing(mut self, enable: bool) -> Self { - self.inspector_config.tracing = enable; - self - } - - /// Enables or disables the debugger - #[must_use] - pub fn set_debugger(mut self, enable: bool) -> Self { - self.inspector_config.debugger = enable; - self - } - - /// Enables or disables coverage collection - #[must_use] - pub fn set_coverage(mut self, enable: bool) -> Self { - self.inspector_config.coverage = enable; - self +impl Default for ExecutorBuilder { + #[inline] + fn default() -> Self { + Self { stack: InspectorStackBuilder::new(), gas_limit: None, spec_id: SpecId::LATEST } } +} - /// Enables or disabled trace printer. - #[must_use] - pub fn set_trace_printer(mut self, enable: bool) -> Self { - self.inspector_config.trace_printer = enable; - self +impl ExecutorBuilder { + /// Create a new executor builder. + #[inline] + pub fn new() -> Self { + Self::default() } - /// Enables the fuzzer for data collection and maybe call overriding - #[must_use] - pub fn with_fuzzer( + /// Modify the inspector stack. + #[inline] + pub fn inspectors( mut self, - call_generator: Option, - fuzz_state: EvmFuzzState, + f: impl FnOnce(InspectorStackBuilder) -> InspectorStackBuilder, ) -> Self { - self.inspector_config.fuzzer = Some(Fuzzer { call_generator, fuzz_state, collect: false }); + self.stack = f(self.stack); self } /// Sets the EVM spec to use - #[must_use] - pub fn with_spec(mut self, spec: SpecId) -> Self { - self.env.cfg.spec_id = spec; + #[inline] + pub fn spec(mut self, spec: SpecId) -> Self { + self.spec_id = spec; self } /// Sets the executor gas limit. /// /// See [Executor::gas_limit] for more info on why you might want to set this. - #[must_use] - pub fn with_gas_limit(mut self, gas_limit: U256) -> Self { + #[inline] + pub fn gas_limit(mut self, gas_limit: U256) -> Self { self.gas_limit = Some(gas_limit); self } - /// Configure the execution environment (gas limit, chain spec, ...) - #[must_use] - pub fn with_config(mut self, env: Env) -> Self { - self.inspector_config.block = env.block.clone(); - self.inspector_config.gas_price = env.tx.gas_price.into(); - self.env = env; - self - } - - /// Enable the chisel state inspector - #[must_use] - pub fn with_chisel_state(mut self, final_pc: usize) -> Self { - self.inspector_config.chisel_state = Some(final_pc); - self - } - /// Builds the executor as configured. - pub fn build(self, db: Backend) -> Executor { - let gas_limit = self.gas_limit.unwrap_or(self.env.block.gas_limit.into()); - Executor::new(db, self.env, self.inspector_config, gas_limit) + #[inline] + pub fn build(self, mut env: Env, db: Backend) -> Executor { + let Self { mut stack, gas_limit, spec_id } = self; + env.cfg.spec_id = spec_id; + stack.block = Some(env.block.clone()); + stack.gas_price = Some(env.tx.gas_price.into()); + let gas_limit = gas_limit.unwrap_or(env.block.gas_limit.into()); + Executor::new(db, env, stack.build(), gas_limit) } } diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/src/executor/inspector/access_list.rs index 2dbd4a3dfb4a4..88619de35da01 100644 --- a/crates/evm/src/executor/inspector/access_list.rs +++ b/crates/evm/src/executor/inspector/access_list.rs @@ -50,10 +50,8 @@ impl AccessListTracer { } } -impl Inspector for AccessListTracer -where - DB: Database, -{ +impl Inspector for AccessListTracer { + #[inline] fn step( &mut self, interpreter: &mut Interpreter, diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index afc14138d9a44..2a6d1c1d3db49 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -197,16 +197,10 @@ pub struct Cheatcodes { } impl Cheatcodes { - /// Creates a new `Cheatcodes` based on the given settings - pub fn new(block: BlockEnv, gas_price: U256, config: CheatsConfig) -> Self { - Self { - corrected_nonce: false, - block: Some(block), - gas_price: Some(gas_price), - config: Arc::new(config), - fs_commit: true, - ..Default::default() - } + /// Creates a new `Cheatcodes` with the given settings. + #[inline] + pub fn new(config: Arc) -> Self { + Self { config, fs_commit: true, ..Default::default() } } #[instrument(level = "error", name = "apply", target = "evm::cheatcodes", skip_all)] @@ -295,10 +289,8 @@ impl Cheatcodes { } } -impl Inspector for Cheatcodes -where - DB: DatabaseExt, -{ +impl Inspector for Cheatcodes { + #[inline] fn initialize_interp( &mut self, _: &mut Interpreter, @@ -1114,6 +1106,14 @@ impl Clone for Context { } } +impl Context { + /// Clears the context. + #[inline] + pub fn clear(&mut self) { + self.opened_read_files.clear(); + } +} + /// Records `deal` cheatcodes #[derive(Debug, Clone)] pub struct DealRecord { diff --git a/crates/evm/src/executor/inspector/chisel_state.rs b/crates/evm/src/executor/inspector/chisel_state.rs index e10720bba85a2..cb7a2a6c17e75 100644 --- a/crates/evm/src/executor/inspector/chisel_state.rs +++ b/crates/evm/src/executor/inspector/chisel_state.rs @@ -4,7 +4,7 @@ use revm::{ }; /// An inspector for Chisel -#[derive(Default)] +#[derive(Clone, Debug, Default)] pub struct ChiselState { /// The PC of the final instruction pub final_pc: usize, @@ -13,15 +13,15 @@ pub struct ChiselState { } impl ChiselState { + /// Create a new Chisel state inspector. + #[inline] pub fn new(final_pc: usize) -> Self { Self { final_pc, state: None } } } -impl Inspector for ChiselState -where - DB: Database, -{ +impl Inspector for ChiselState { + #[inline] fn step_end( &mut self, interp: &mut Interpreter, diff --git a/crates/evm/src/executor/inspector/coverage.rs b/crates/evm/src/executor/inspector/coverage.rs index 67b949a8c9720..b7af6f6609016 100644 --- a/crates/evm/src/executor/inspector/coverage.rs +++ b/crates/evm/src/executor/inspector/coverage.rs @@ -8,16 +8,14 @@ use revm::{ Database, EVMData, Inspector, }; -#[derive(Default, Debug)] +#[derive(Clone, Default, Debug)] pub struct CoverageCollector { /// Maps that track instruction hit data. pub maps: HitMaps, } -impl Inspector for CoverageCollector -where - DB: Database, -{ +impl Inspector for CoverageCollector { + #[inline] fn initialize_interp( &mut self, interpreter: &mut Interpreter, @@ -34,6 +32,7 @@ where InstructionResult::Continue } + #[inline] fn step( &mut self, interpreter: &mut Interpreter, diff --git a/crates/evm/src/executor/inspector/debugger.rs b/crates/evm/src/executor/inspector/debugger.rs index 24fce86c2ca54..e051ad73cf532 100644 --- a/crates/evm/src/executor/inspector/debugger.rs +++ b/crates/evm/src/executor/inspector/debugger.rs @@ -12,7 +12,6 @@ use bytes::Bytes; use ethers::types::Address; use foundry_utils::error::SolError; use revm::{ - inspectors::GasInspector, interpreter::{ opcode::{self, spec_opcode_gas}, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, @@ -20,10 +19,9 @@ use revm::{ primitives::B160, EVMData, Inspector, }; -use std::{cell::RefCell, rc::Rc}; /// An inspector that collects debug nodes on every step of the interpreter. -#[derive(Debug)] +#[derive(Clone, Default, Debug)] pub struct Debugger { /// The arena of [DebugNode]s pub arena: DebugArena, @@ -31,20 +29,9 @@ pub struct Debugger { pub head: usize, /// The current execution address. pub context: Address, - - gas_inspector: Rc>, } impl Debugger { - pub fn new(gas_inspector: Rc>) -> Self { - Self { - arena: Default::default(), - head: Default::default(), - context: Default::default(), - gas_inspector, - } - } - /// Enters a new execution context. pub fn enter(&mut self, depth: usize, address: Address, kind: CallKind) { self.context = address; @@ -62,10 +49,8 @@ impl Debugger { } } -impl Inspector for Debugger -where - DB: DatabaseExt, -{ +impl Inspector for Debugger { + #[inline] fn step( &mut self, interpreter: &mut Interpreter, @@ -92,7 +77,7 @@ where let total_gas_used = gas_used( data.env.cfg.spec_id, - interpreter.gas.limit().saturating_sub(self.gas_inspector.borrow().gas_remaining()), + interpreter.gas.limit().saturating_sub(interpreter.gas.remaining()), interpreter.gas.refunded() as u64, ); @@ -108,6 +93,7 @@ where InstructionResult::Continue } + #[inline] fn call( &mut self, data: &mut EVMData<'_, DB>, @@ -132,6 +118,7 @@ where (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) } + #[inline] fn call_end( &mut self, _: &mut EVMData<'_, DB>, @@ -146,6 +133,7 @@ where (status, gas, retdata) } + #[inline] fn create( &mut self, data: &mut EVMData<'_, DB>, @@ -167,6 +155,7 @@ where (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()) } + #[inline] fn create_end( &mut self, _: &mut EVMData<'_, DB>, diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/src/executor/inspector/fuzzer.rs index 021ac4f35f6a9..17926e887f1d4 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/src/executor/inspector/fuzzer.rs @@ -19,10 +19,8 @@ pub struct Fuzzer { pub fuzz_state: EvmFuzzState, } -impl Inspector for Fuzzer -where - DB: Database, -{ +impl Inspector for Fuzzer { + #[inline] fn step( &mut self, interpreter: &mut Interpreter, @@ -37,6 +35,7 @@ where InstructionResult::Continue } + #[inline] fn call( &mut self, data: &mut EVMData<'_, DB>, @@ -55,6 +54,7 @@ where (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) } + #[inline] fn call_end( &mut self, _: &mut EVMData<'_, DB>, diff --git a/crates/evm/src/executor/inspector/logs.rs b/crates/evm/src/executor/inspector/logs.rs index 5c92d2a355a53..c848e329c9f77 100644 --- a/crates/evm/src/executor/inspector/logs.rs +++ b/crates/evm/src/executor/inspector/logs.rs @@ -43,10 +43,7 @@ impl LogCollector { } } -impl Inspector for LogCollector -where - DB: Database, -{ +impl Inspector for LogCollector { fn log(&mut self, _: &mut EVMData<'_, DB>, address: &B160, topics: &[B256], data: &Bytes) { self.logs.push(Log { address: b160_to_h160(*address), diff --git a/crates/evm/src/executor/inspector/mod.rs b/crates/evm/src/executor/inspector/mod.rs index f4e5dd8c5acb5..f25a6ab434b9b 100644 --- a/crates/evm/src/executor/inspector/mod.rs +++ b/crates/evm/src/executor/inspector/mod.rs @@ -1,118 +1,32 @@ #[macro_use] mod utils; -mod logs; - -pub use logs::LogCollector; -use std::{cell::RefCell, rc::Rc}; - mod access_list; pub use access_list::AccessListTracer; -mod tracer; -pub use tracer::Tracer; - -mod debugger; -pub use debugger::Debugger; - -mod coverage; -pub use coverage::CoverageCollector; - -mod stack; -pub use stack::{InspectorData, InspectorStack}; - pub mod cheatcodes; pub use cheatcodes::{Cheatcodes, CheatsConfig, DEFAULT_CREATE2_DEPLOYER}; mod chisel_state; pub use chisel_state::ChiselState; -use ethers::types::U256; +mod coverage; +pub use coverage::CoverageCollector; -use revm::{inspectors::GasInspector, primitives::BlockEnv}; +mod debugger; +pub use debugger::Debugger; mod fuzzer; pub use fuzzer::Fuzzer; +mod logs; +pub use logs::LogCollector; + mod printer; pub use printer::TracePrinter; -#[derive(Default, Clone, Debug)] -pub struct InspectorStackConfig { - /// The cheatcode inspector and its state, if cheatcodes are enabled. - /// Whether cheatcodes are enabled - pub cheatcodes: Option, - /// The block environment - /// - /// Used in the cheatcode handler to overwrite the block environment separately from the - /// execution block environment. - pub block: BlockEnv, - /// The gas price - /// - /// Used in the cheatcode handler to overwrite the gas price separately from the gas price - /// in the execution environment. - pub gas_price: U256, - /// Whether tracing is enabled - pub tracing: bool, - /// Whether the debugger is enabled - pub debugger: bool, - /// The fuzzer inspector and its state, if it exists. - pub fuzzer: Option, - /// Whether coverage info should be collected - pub coverage: bool, - /// Should we print all opcode traces into console. Useful for debugging of EVM. - pub trace_printer: bool, - /// The chisel state inspector. - /// - /// If the inspector is enabled, Some(final_pc) - /// If not, None - pub chisel_state: Option, -} - -impl InspectorStackConfig { - /// Returns the stack of inspectors to use when transacting/committing on the EVM - /// - /// See also [`revm::Evm::inspect_ref`] and [`revm::Evm::commit_ref`] - pub fn stack(&self) -> InspectorStack { - let mut stack = - InspectorStack { log_collector: Some(LogCollector::default()), ..Default::default() }; - - stack.cheatcodes = self.create_cheatcodes(); - if let Some(ref mut cheatcodes) = stack.cheatcodes { - cheatcodes.block = Some(self.block.clone()); - cheatcodes.gas_price = Some(self.gas_price); - } - - if self.tracing { - stack.tracer = Some(Tracer::default()); - } - if self.debugger { - let gas_inspector = Rc::new(RefCell::new(GasInspector::default())); - stack.gas = Some(gas_inspector.clone()); - stack.debugger = Some(Debugger::new(gas_inspector)); - } - stack.fuzzer = self.fuzzer.clone(); - - if self.coverage { - stack.coverage = Some(CoverageCollector::default()); - } - - if self.trace_printer { - stack.printer = Some(TracePrinter::default()); - } - - if let Some(final_pc) = self.chisel_state { - stack.chisel_state = Some(ChiselState::new(final_pc)); - } - stack - } - - /// Configures the cheatcode inspector with a new and empty context - /// - /// Returns `None` if no cheatcodes inspector is set - fn create_cheatcodes(&self) -> Option { - let cheatcodes = self.cheatcodes.clone(); +mod stack; +pub use stack::{InspectorData, InspectorStack, InspectorStackBuilder}; - cheatcodes.map(|cheatcodes| Cheatcodes { context: Default::default(), ..cheatcodes }) - } -} +mod tracer; +pub use tracer::Tracer; diff --git a/crates/evm/src/executor/inspector/printer.rs b/crates/evm/src/executor/inspector/printer.rs index b9a1abc7f19d6..6b694f12f0eea 100644 --- a/crates/evm/src/executor/inspector/printer.rs +++ b/crates/evm/src/executor/inspector/printer.rs @@ -1,47 +1,33 @@ use bytes::Bytes; use revm::{ - inspectors::GasInspector, interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, primitives::B160, Database, EVMData, Inspector, }; -#[derive(Clone, Default)] -pub struct TracePrinter { - gas_inspector: GasInspector, -} +#[derive(Clone, Debug, Default)] +#[non_exhaustive] +pub struct TracePrinter; impl Inspector for TracePrinter { - fn initialize_interp( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - is_static: bool, - ) -> InstructionResult { - self.gas_inspector.initialize_interp(interp, data, is_static); - InstructionResult::Continue - } - // get opcode by calling `interp.contract.opcode(interp.program_counter())`. // all other information can be obtained from interp. fn step( &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, + _: bool, ) -> InstructionResult { let opcode = interp.current_opcode(); let opcode_str = opcode::OPCODE_JUMPMAP[opcode as usize]; - - let gas_remaining = self.gas_inspector.gas_remaining(); - + let gas_remaining = interp.gas.remaining(); println!( "depth:{}, PC:{}, gas:{:#x}({}), OPCODE: {:?}({:?}) refund:{:#x}({}) Stack:{:?}, Data size:{}, Data: 0x{}", data.journaled_state.depth(), interp.program_counter(), gas_remaining, gas_remaining, - opcode_str.unwrap(), + opcode_str.unwrap_or(""), opcode, interp.gas.refunded(), interp.gas.refunded(), @@ -50,19 +36,6 @@ impl Inspector for TracePrinter { hex::encode(interp.memory.data()), ); - self.gas_inspector.step(interp, data, is_static); - - InstructionResult::Continue - } - - fn step_end( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - is_static: bool, - eval: InstructionResult, - ) -> InstructionResult { - self.gas_inspector.step_end(interp, data, is_static, eval); InstructionResult::Continue } @@ -83,19 +56,6 @@ impl Inspector for TracePrinter { (InstructionResult::Continue, Gas::new(0), Bytes::new()) } - fn call_end( - &mut self, - data: &mut EVMData<'_, DB>, - inputs: &CallInputs, - remaining_gas: Gas, - ret: InstructionResult, - out: Bytes, - is_static: bool, - ) -> (InstructionResult, Gas, Bytes) { - self.gas_inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static); - (ret, remaining_gas, out) - } - fn create( &mut self, _data: &mut EVMData<'_, DB>, @@ -111,17 +71,4 @@ impl Inspector for TracePrinter { ); (InstructionResult::Continue, None, Gas::new(0), Bytes::new()) } - - fn create_end( - &mut self, - data: &mut EVMData<'_, DB>, - inputs: &CreateInputs, - ret: InstructionResult, - address: Option, - remaining_gas: Gas, - out: Bytes, - ) -> (InstructionResult, Option, Gas, Bytes) { - self.gas_inspector.create_end(data, inputs, ret, address, remaining_gas, out.clone()); - (ret, address, remaining_gas, out) - } } diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index 2a3763ce53924..7c22a4d65d55f 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -1,4 +1,6 @@ -use super::{Cheatcodes, ChiselState, Debugger, Fuzzer, LogCollector, TracePrinter, Tracer}; +use super::{ + Cheatcodes, CheatsConfig, ChiselState, Debugger, Fuzzer, LogCollector, TracePrinter, Tracer, +}; use crate::{ coverage::HitMaps, debug::DebugArena, @@ -8,38 +10,189 @@ use crate::{ use bytes::Bytes; use ethers::{ signers::LocalWallet, - types::{Address, Log}, + types::{Address, Log, U256}, }; use revm::{ - inspectors::GasInspector, interpreter::{ return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, Stack, }, - primitives::{B160, B256}, + primitives::{BlockEnv, Env, B160, B256}, EVMData, Inspector, }; -use std::{cell::RefCell, collections::BTreeMap, rc::Rc}; +use std::{collections::BTreeMap, sync::Arc}; + +#[derive(Clone, Debug, Default)] +#[must_use = "builders do nothing unless you call `build` on them"] +pub struct InspectorStackBuilder { + /// The block environment. + /// + /// Used in the cheatcode handler to overwrite the block environment separately from the + /// execution block environment. + pub block: Option, + /// The gas price. + /// + /// Used in the cheatcode handler to overwrite the gas price separately from the gas price + /// in the execution environment. + pub gas_price: Option, + /// The cheatcodes config. + pub cheatcodes: Option>, + /// The fuzzer inspector and its state, if it exists. + pub fuzzer: Option, + /// Whether to enable tracing. + pub trace: Option, + /// Whether to enable the debugger. + pub debug: Option, + /// Whether logs should be collected. + pub logs: Option, + /// Whether coverage info should be collected. + pub coverage: Option, + /// Whether to print all opcode traces into the console. Useful for debugging the EVM. + pub print: Option, + /// The chisel state inspector. + pub chisel_state: Option, +} + +impl InspectorStackBuilder { + /// Create a new inspector stack builder. + #[inline] + pub fn new() -> Self { + Self::default() + } + + /// Set the block environment. + #[inline] + pub fn block(mut self, block: BlockEnv) -> Self { + self.block = Some(block); + self + } + + /// Set the gas price. + #[inline] + pub fn gas_price(mut self, gas_price: U256) -> Self { + self.gas_price = Some(gas_price); + self + } + + /// Enable cheatcodes with the given config. + #[inline] + pub fn cheatcodes(mut self, config: Arc) -> Self { + self.cheatcodes = Some(config); + self + } + + /// Set the fuzzer inspector. + #[inline] + pub fn fuzzer(mut self, fuzzer: Fuzzer) -> Self { + self.fuzzer = Some(fuzzer); + self + } + + /// Set the Chisel inspector. + #[inline] + pub fn chisel_state(mut self, final_pc: usize) -> Self { + self.chisel_state = Some(final_pc); + self + } + + /// Set whether to collect logs. + #[inline] + pub fn logs(mut self, yes: bool) -> Self { + self.logs = Some(yes); + self + } + + /// Set whether to collect coverage information. + #[inline] + pub fn coverage(mut self, yes: bool) -> Self { + self.coverage = Some(yes); + self + } + + /// Set whether to enable the debugger. + #[inline] + pub fn debug(mut self, yes: bool) -> Self { + self.debug = Some(yes); + self + } + + /// Set whether to enable the trace printer. + #[inline] + pub fn print(mut self, yes: bool) -> Self { + self.print = Some(yes); + self + } + + /// Set whether to enable the tracer. + #[inline] + pub fn trace(mut self, yes: bool) -> Self { + self.trace = Some(yes); + self + } + + /// Builds the stack of inspectors to use when transacting/committing on the EVM. + /// + /// See also [`revm::Evm::inspect_ref`] and [`revm::Evm::commit_ref`]. + pub fn build(self) -> InspectorStack { + let Self { + block, + gas_price, + cheatcodes, + fuzzer, + trace, + debug, + logs, + coverage, + print, + chisel_state, + } = self; + let mut stack = InspectorStack::new(); + + // inspectors + if let Some(config) = cheatcodes { + stack.set_cheatcodes(Cheatcodes::new(config)); + } + if let Some(fuzzer) = fuzzer { + stack.set_fuzzer(fuzzer); + } + if let Some(chisel_state) = chisel_state { + stack.set_chisel(chisel_state); + } + stack.collect_coverage(coverage.unwrap_or(false)); + stack.collect_logs(logs.unwrap_or(true)); + stack.enable_debugger(debug.unwrap_or(false)); + stack.print(print.unwrap_or(false)); + stack.tracing(trace.unwrap_or(false)); + + // environment, must come after all of the inspectors + if let Some(block) = block { + stack.set_block(&block); + } + if let Some(gas_price) = gas_price { + stack.set_gas_price(gas_price); + } + + stack + } +} /// Helper macro to call the same method on multiple inspectors without resorting to dynamic -/// dispatch +/// dispatch. #[macro_export] macro_rules! call_inspectors { - ($id:ident, [ $($inspector:expr),+ ], $call:block) => { - $({ - if let Some($id) = $inspector { - $call; - } - })+ - } + ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr $(,)?) => {{$( + if let Some($id) = $inspector { + $call + } + )+}} } +/// The collected results of [`InspectorStack`]. pub struct InspectorData { pub logs: Vec, pub labels: BTreeMap, pub traces: Option, pub debug: Option, pub coverage: Option, - pub gas: Option, pub cheatcodes: Option, pub script_wallets: Vec, pub chisel_state: Option<(Stack, Memory, InstructionResult)>, @@ -49,21 +202,103 @@ pub struct InspectorData { /// /// If a call to an inspector returns a value other than [InstructionResult::Continue] (or /// equivalent) the remaining inspectors are not called. -#[derive(Default)] +#[derive(Debug, Clone, Default)] pub struct InspectorStack { - pub tracer: Option, - pub log_collector: Option, pub cheatcodes: Option, - pub gas: Option>>, + pub chisel_state: Option, + pub coverage: Option, pub debugger: Option, pub fuzzer: Option, - pub coverage: Option, + pub log_collector: Option, pub printer: Option, - pub chisel_state: Option, + pub tracer: Option, } impl InspectorStack { - pub fn collect_inspector_states(self) -> InspectorData { + /// Creates a new inspector stack. + /// + /// Note that the stack is empty by default, and you must add inspectors to it. + /// This is done by calling the `set_*` methods on the stack directly, or by building the stack + /// with [`InspectorStack`]. + #[inline] + pub fn new() -> Self { + Self::default() + } + + /// Set variables from an environment for the relevant inspectors. + #[inline] + pub fn set_env(&mut self, env: &Env) { + self.set_block(&env.block); + self.set_gas_price(env.tx.gas_price.into()); + } + + /// Sets the block for the relevant inspectors. + #[inline] + pub fn set_block(&mut self, block: &BlockEnv) { + if let Some(cheatcodes) = &mut self.cheatcodes { + cheatcodes.block = Some(block.clone()); + } + } + + /// Sets the gas price for the relevant inspectors. + #[inline] + pub fn set_gas_price(&mut self, gas_price: U256) { + if let Some(cheatcodes) = &mut self.cheatcodes { + cheatcodes.gas_price = Some(gas_price); + } + } + + /// Set the cheatcodes inspector. + #[inline] + pub fn set_cheatcodes(&mut self, cheatcodes: Cheatcodes) { + self.cheatcodes = Some(cheatcodes); + } + + /// Set the fuzzer inspector. + #[inline] + pub fn set_fuzzer(&mut self, fuzzer: Fuzzer) { + self.fuzzer = Some(fuzzer); + } + + /// Set the Chisel inspector. + #[inline] + pub fn set_chisel(&mut self, final_pc: usize) { + self.chisel_state = Some(ChiselState::new(final_pc)); + } + + /// Set whether to enable the coverage collector. + #[inline] + pub fn collect_coverage(&mut self, yes: bool) { + self.coverage = yes.then(Default::default); + } + + /// Set whether to enable the debugger. + #[inline] + pub fn enable_debugger(&mut self, yes: bool) { + self.debugger = yes.then(Default::default); + } + + /// Set whether to enable the log collector. + #[inline] + pub fn collect_logs(&mut self, yes: bool) { + self.log_collector = yes.then(Default::default); + } + + /// Set whether to enable the trace printer. + #[inline] + pub fn print(&mut self, yes: bool) { + self.printer = yes.then(Default::default); + } + + /// Set whether to enable the tracer. + #[inline] + pub fn tracing(&mut self, yes: bool) { + self.tracer = yes.then(Default::default); + } + + /// Collects all the data gathered during inspection into a single struct. + #[inline] + pub fn collect(self) -> InspectorData { InspectorData { logs: self.log_collector.map(|logs| logs.logs).unwrap_or_default(), labels: self @@ -74,14 +309,13 @@ impl InspectorStack { traces: self.tracer.map(|tracer| tracer.traces), debug: self.debugger.map(|debugger| debugger.arena), coverage: self.coverage.map(|coverage| coverage.maps), - gas: self.gas.map(|gas| gas.borrow().gas_remaining()), script_wallets: self .cheatcodes .as_ref() .map(|cheatcodes| cheatcodes.script_wallets.clone()) .unwrap_or_default(), cheatcodes: self.cheatcodes, - chisel_state: self.chisel_state.unwrap_or_default().state, + chisel_state: self.chisel_state.and_then(|state| state.state), } } @@ -95,9 +329,7 @@ impl InspectorStack { is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( - inspector, [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.fuzzer, &mut self.debugger, &mut self.tracer, @@ -106,7 +338,7 @@ impl InspectorStack { &mut self.cheatcodes, &mut self.printer ], - { + |inspector| { let (new_status, new_gas, new_retdata) = inspector.call_end( data, call, @@ -130,10 +362,7 @@ impl InspectorStack { } } -impl Inspector for InspectorStack -where - DB: DatabaseExt, -{ +impl Inspector for InspectorStack { fn initialize_interp( &mut self, interpreter: &mut Interpreter, @@ -141,9 +370,7 @@ where is_static: bool, ) -> InstructionResult { call_inspectors!( - inspector, [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.debugger, &mut self.coverage, &mut self.tracer, @@ -151,7 +378,7 @@ where &mut self.cheatcodes, &mut self.printer ], - { + |inspector| { let status = inspector.initialize_interp(interpreter, data, is_static); // Allow inspectors to exit early @@ -171,9 +398,7 @@ where is_static: bool, ) -> InstructionResult { call_inspectors!( - inspector, [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.fuzzer, &mut self.debugger, &mut self.tracer, @@ -182,7 +407,7 @@ where &mut self.cheatcodes, &mut self.printer ], - { + |inspector| { let status = inspector.step(interpreter, data, is_static); // Allow inspectors to exit early @@ -203,9 +428,8 @@ where data: &Bytes, ) { call_inspectors!( - inspector, [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], - { + |inspector| { inspector.log(evm_data, address, topics, data); } ); @@ -219,9 +443,7 @@ where status: InstructionResult, ) -> InstructionResult { call_inspectors!( - inspector, [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.debugger, &mut self.tracer, &mut self.log_collector, @@ -229,7 +451,7 @@ where &mut self.printer, &mut self.chisel_state ], - { + |inspector| { let status = inspector.step_end(interpreter, data, is_static, status); // Allow inspectors to exit early @@ -249,9 +471,7 @@ where is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( - inspector, [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.fuzzer, &mut self.debugger, &mut self.tracer, @@ -260,7 +480,7 @@ where &mut self.cheatcodes, &mut self.printer ], - { + |inspector| { let (status, gas, retdata) = inspector.call(data, call, is_static); // Allow inspectors to exit early @@ -302,9 +522,7 @@ where call: &mut CreateInputs, ) -> (InstructionResult, Option, Gas, Bytes) { call_inspectors!( - inspector, [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.debugger, &mut self.tracer, &mut self.coverage, @@ -312,7 +530,7 @@ where &mut self.cheatcodes, &mut self.printer ], - { + |inspector| { let (status, addr, gas, retdata) = inspector.create(data, call); // Allow inspectors to exit early @@ -335,9 +553,7 @@ where retdata: Bytes, ) -> (InstructionResult, Option, Gas, Bytes) { call_inspectors!( - inspector, [ - &mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.debugger, &mut self.tracer, &mut self.coverage, @@ -345,7 +561,7 @@ where &mut self.cheatcodes, &mut self.printer ], - { + |inspector| { let (new_status, new_address, new_gas, new_retdata) = inspector.create_end( data, call, @@ -366,7 +582,6 @@ where fn selfdestruct(&mut self, contract: B160, target: B160) { call_inspectors!( - inspector, [ &mut self.debugger, &mut self.tracer, @@ -375,7 +590,7 @@ where &mut self.printer, &mut self.chisel_state ], - { + |inspector| { Inspector::::selfdestruct(inspector, contract, target); } ); diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index 0b4edf0482712..5d5c80ba6b55c 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -14,7 +14,6 @@ use ethers::{ types::{Address, U256}, }; use revm::{ - inspectors::GasInspector, interpreter::{ opcode, return_ok, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, Interpreter, @@ -22,29 +21,20 @@ use revm::{ primitives::{B160, B256}, Database, EVMData, Inspector, JournalEntry, }; -use std::{cell::RefCell, rc::Rc}; /// An inspector that collects call traces. #[derive(Default, Debug, Clone)] pub struct Tracer { - record_steps: bool, - pub traces: CallTraceArena, trace_stack: Vec, step_stack: Vec<(usize, usize)>, // (trace_idx, step_idx) - - gas_inspector: Rc>, + record_steps: bool, } impl Tracer { - /// Enables step recording and uses [revm::GasInspector] to report gas costs for each step. - /// - /// Gas Inspector should be called externally **before** [Tracer], this is why we need it as - /// `Rc>` here. - pub fn with_steps_recording(mut self, gas_inspector: Rc>) -> Self { + /// Enables step recording. + pub fn record_steps(&mut self) { self.record_steps = true; - self.gas_inspector = gas_inspector; - self } fn start_trace( @@ -108,7 +98,7 @@ impl Tracer { contract: b160_to_h160(interp.contract.address), stack: interp.stack.clone(), memory: interp.memory.clone(), - gas: self.gas_inspector.borrow().gas_remaining(), + gas: interp.gas.remaining(), gas_refund_counter: interp.gas.refunded() as u64, gas_cost: 0, state_diff: None, @@ -148,7 +138,7 @@ impl Tracer { _ => None, }; - step.gas_cost = step.gas - self.gas_inspector.borrow().gas_remaining(); + step.gas_cost = step.gas - interp.gas.remaining(); } // Error codes only @@ -158,32 +148,21 @@ impl Tracer { } } -impl Inspector for Tracer -where - DB: Database, -{ +impl Inspector for Tracer { + #[inline] fn step( &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, _is_static: bool, ) -> InstructionResult { - if !self.record_steps { - return InstructionResult::Continue + if self.record_steps { + self.start_step(interp, data); } - - self.start_step(interp, data); - InstructionResult::Continue } - fn log(&mut self, _: &mut EVMData<'_, DB>, _: &B160, topics: &[B256], data: &Bytes) { - let node = &mut self.traces.arena[*self.trace_stack.last().expect("no ongoing trace")]; - let topics: Vec<_> = topics.iter().copied().map(b256_to_h256).collect(); - node.ordering.push(LogCallOrder::Log(node.logs.len())); - node.logs.push(RawOrDecodedLog::Raw(RawLog { topics, data: data.to_vec() })); - } - + #[inline] fn step_end( &mut self, interp: &mut Interpreter, @@ -191,15 +170,21 @@ where _: bool, status: InstructionResult, ) -> InstructionResult { - if !self.record_steps { - return InstructionResult::Continue + if self.record_steps { + self.fill_step(interp, data, status); } - - self.fill_step(interp, data, status); - status } + #[inline] + fn log(&mut self, _: &mut EVMData<'_, DB>, _: &B160, topics: &[B256], data: &Bytes) { + let node = &mut self.traces.arena[*self.trace_stack.last().expect("no ongoing trace")]; + let topics: Vec<_> = topics.iter().copied().map(b256_to_h256).collect(); + node.ordering.push(LogCallOrder::Log(node.logs.len())); + node.logs.push(RawOrDecodedLog::Raw(RawLog { topics, data: data.to_vec() })); + } + + #[inline] fn call( &mut self, data: &mut EVMData<'_, DB>, @@ -225,6 +210,7 @@ where (InstructionResult::Continue, Gas::new(inputs.gas_limit), Bytes::new()) } + #[inline] fn call_end( &mut self, data: &mut EVMData<'_, DB>, @@ -244,6 +230,7 @@ where (status, gas, retdata) } + #[inline] fn create( &mut self, data: &mut EVMData<'_, DB>, @@ -264,6 +251,7 @@ where (InstructionResult::Continue, None, Gas::new(inputs.gas_limit), Bytes::new()) } + #[inline] fn create_end( &mut self, data: &mut EVMData<'_, DB>, diff --git a/crates/evm/src/executor/mod.rs b/crates/evm/src/executor/mod.rs index aa32860c60e4c..d07d1bd112c79 100644 --- a/crates/evm/src/executor/mod.rs +++ b/crates/evm/src/executor/mod.rs @@ -1,6 +1,4 @@ -use self::inspector::{ - cheatcodes::util::BroadcastableTransactions, Cheatcodes, InspectorData, InspectorStackConfig, -}; +use self::inspector::{cheatcodes::util::BroadcastableTransactions, Cheatcodes, InspectorData}; use crate::{ debug::DebugArena, decode, @@ -79,14 +77,16 @@ pub const DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE: &[u8] = &hex!("7fffffffffffffff /// other words: the state of the underlying database remains unchanged. #[derive(Debug, Clone)] pub struct Executor { - /// The underlying `revm::Database` that contains the EVM storage + /// The underlying `revm::Database` that contains the EVM storage. // Note: We do not store an EVM here, since we are really // only interested in the database. REVM's `EVM` is a thin // wrapper around spawning a new EVM on every call anyway, // so the performance difference should be negligible. - backend: Backend, - env: Env, - inspector_config: InspectorStackConfig, + pub backend: Backend, + /// The EVM environment. + pub env: Env, + /// The Revm inspector stack. + pub inspector: InspectorStack, /// The gas limit for calls and deployments. This is different from the gas limit imposed by /// the passed in environment, as those limits are used by the EVM for certain opcodes like /// `gaslimit`. @@ -96,59 +96,26 @@ pub struct Executor { // === impl Executor === impl Executor { - pub fn new( - mut backend: Backend, - env: Env, - inspector_config: InspectorStackConfig, - gas_limit: U256, - ) -> Self { + #[inline] + pub fn new(mut backend: Backend, env: Env, inspector: InspectorStack, gas_limit: U256) -> Self { // Need to create a non-empty contract on the cheatcodes address so `extcodesize` checks // does not fail backend.insert_account_info( CHEATCODE_ADDRESS, revm::primitives::AccountInfo { - code: Some(Bytecode::new_raw(vec![0u8].into()).to_checked()), + code: Some(Bytecode::new_raw(Bytes::from_static(&[0])).to_checked()), ..Default::default() }, ); - Executor { backend, env, inspector_config, gas_limit } - } - - /// Returns a reference to the Env - pub fn env(&self) -> &Env { - &self.env - } - - /// Returns a mutable reference to the Env - pub fn env_mut(&mut self) -> &mut Env { - &mut self.env - } - - /// Returns a mutable reference to the Backend - pub fn backend_mut(&mut self) -> &mut Backend { - &mut self.backend - } - - pub fn backend(&self) -> &Backend { - &self.backend - } - - /// Returns an immutable reference to the InspectorStackConfig - pub fn inspector_config(&self) -> &InspectorStackConfig { - &self.inspector_config - } - - /// Returns a mutable reference to the InspectorStackConfig - pub fn inspector_config_mut(&mut self) -> &mut InspectorStackConfig { - &mut self.inspector_config + Executor { backend, env, inspector, gas_limit } } /// Creates the default CREATE2 Contract Deployer for local tests and scripts. pub fn deploy_create2_deployer(&mut self) -> eyre::Result<()> { trace!("deploying local create2 deployer"); let create2_deployer_account = self - .backend_mut() + .backend .basic(h160_to_b160(DEFAULT_CREATE2_DEPLOYER))? .ok_or(DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; @@ -172,17 +139,17 @@ impl Executor { /// Set the balance of an account. pub fn set_balance(&mut self, address: Address, amount: U256) -> DatabaseResult<&mut Self> { trace!(?address, ?amount, "setting account balance"); - let mut account = self.backend_mut().basic(h160_to_b160(address))?.unwrap_or_default(); + let mut account = self.backend.basic(h160_to_b160(address))?.unwrap_or_default(); account.balance = amount.into(); - self.backend_mut().insert_account_info(address, account); + self.backend.insert_account_info(address, account); Ok(self) } /// Gets the balance of an account pub fn get_balance(&self, address: Address) -> DatabaseResult { Ok(self - .backend() + .backend .basic(h160_to_b160(address))? .map(|acc| acc.balance.into()) .unwrap_or_default()) @@ -190,28 +157,32 @@ impl Executor { /// Set the nonce of an account. pub fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<&mut Self> { - let mut account = self.backend_mut().basic(h160_to_b160(address))?.unwrap_or_default(); + let mut account = self.backend.basic(h160_to_b160(address))?.unwrap_or_default(); account.nonce = nonce; - self.backend_mut().insert_account_info(address, account); + self.backend.insert_account_info(address, account); Ok(self) } + #[inline] pub fn set_tracing(&mut self, tracing: bool) -> &mut Self { - self.inspector_config.tracing = tracing; + self.inspector.tracing(tracing); self } + #[inline] pub fn set_debugger(&mut self, debugger: bool) -> &mut Self { - self.inspector_config.debugger = debugger; + self.inspector.enable_debugger(debugger); self } + #[inline] pub fn set_trace_printer(&mut self, trace_printer: bool) -> &mut Self { - self.inspector_config.trace_printer = trace_printer; + self.inspector.print(trace_printer); self } + #[inline] pub fn set_gas_limit(&mut self, gas_limit: U256) -> &mut Self { self.gas_limit = gas_limit; self @@ -231,7 +202,7 @@ impl Executor { trace!(?from, ?to, "setting up contract"); let from = from.unwrap_or(CALLER); - self.backend_mut().set_test_contract(to).set_caller(from); + self.backend.set_test_contract(to).set_caller(from); let res = self.call_committing::<(), _, _>(from, to, "setUp()", (), 0.into(), None)?; // record any changes made to the block's environment during setup @@ -353,18 +324,16 @@ impl Executor { calldata: Bytes, value: U256, ) -> eyre::Result { - // execute the call - let mut inspector = self.inspector_config.stack(); + let mut inspector = self.inspector.clone(); // Build VM let mut env = self.build_test_env(from, TransactTo::Call(h160_to_b160(to)), calldata, value); - let mut db = FuzzBackendWrapper::new(self.backend()); + let mut db = FuzzBackendWrapper::new(&self.backend); let result = db.inspect_ref(&mut env, &mut inspector)?; // Persist the snapshot failure recorded on the fuzz backend wrapper. - self.backend().set_snapshot_failure( - self.backend().has_snapshot_failure() || db.has_snapshot_failure(), - ); + self.backend + .set_snapshot_failure(self.backend.has_snapshot_failure() || db.has_snapshot_failure()); convert_executed_result(env, inspector, result) } @@ -379,20 +348,19 @@ impl Executor { /// Execute the transaction configured in `env.tx` pub fn call_raw_with_env(&mut self, mut env: Env) -> eyre::Result { // execute the call - let mut inspector = self.inspector_config.stack(); - let result = self.backend_mut().inspect_ref(&mut env, &mut inspector)?; + let mut inspector = self.inspector.clone(); + let result = self.backend.inspect_ref(&mut env, &mut inspector)?; convert_executed_result(env, inspector, result) } /// Commit the changeset to the database and adjust `self.inspector_config` /// values according to the executed call result fn commit(&mut self, result: &mut RawCallResult) { - // persist changes to db - if let Some(changes) = result.state_changeset.as_ref() { - self.backend_mut().commit(changes.clone()); + // Persist changes to db + if let Some(changes) = &result.state_changeset { + self.backend.commit(changes.clone()); } - // Persist the changed block environment - self.inspector_config.block = result.env.block.clone(); + // Persist cheatcode state let mut cheatcodes = result.cheatcodes.take(); if let Some(cheats) = cheatcodes.as_mut() { @@ -402,7 +370,10 @@ impl Executor { // corrected_nonce value is needed outside of this context (setUp), so we don't // reset it. } - self.inspector_config.cheatcodes = cheatcodes; + self.inspector.cheatcodes = cheatcodes; + + // Persist the changed environment + self.inspector.set_env(&result.env); } /// Deploys a contract using the given `env` and commits the new state to the underlying @@ -545,18 +516,18 @@ impl Executor { state_changeset: StateChangeset, should_fail: bool, ) -> Result { - if self.backend().has_snapshot_failure() { + if self.backend.has_snapshot_failure() { // a failure occurred in a reverted snapshot, which is considered a failed test return Ok(should_fail) } // Construct a new VM with the state changeset - let mut backend = self.backend().clone_empty(); + let mut backend = self.backend.clone_empty(); // we only clone the test contract and cheatcode accounts, that's all we need to evaluate // success for addr in [address, CHEATCODE_ADDRESS] { - let acc = self.backend().basic(h160_to_b160(addr))?.unwrap_or_default(); + let acc = self.backend.basic(h160_to_b160(addr))?.unwrap_or_default(); backend.insert_account_info(addr, acc); } @@ -565,7 +536,7 @@ impl Executor { // cheatcode address which are both read when call `"failed()(bool)"` in the next step backend.commit(state_changeset); let executor = - Executor::new(backend, self.env.clone(), self.inspector_config.clone(), self.gas_limit); + Executor::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); let mut success = !reverted; if success { @@ -814,15 +785,13 @@ fn convert_executed_result( logs, labels, traces, - gas, coverage, debug, cheatcodes, script_wallets, chisel_state, - } = inspector.collect_inspector_states(); + } = inspector.collect(); - let gas_refunded = gas.unwrap_or(gas_refunded); let transactions = match cheatcodes.as_ref() { Some(cheats) if !cheats.broadcastable_transactions.is_empty() => { Some(cheats.broadcastable_transactions.clone()) diff --git a/crates/evm/src/fuzz/invariant/call_override.rs b/crates/evm/src/fuzz/invariant/call_override.rs index 9a935e2e751a1..c843848bbd423 100644 --- a/crates/evm/src/fuzz/invariant/call_override.rs +++ b/crates/evm/src/fuzz/invariant/call_override.rs @@ -93,8 +93,8 @@ impl RandomCallGenerator { /// Sets up the calls generated by the internal fuzzer, if they exist. pub fn set_up_inner_replay(executor: &mut Executor, inner_sequence: &[Option]) { - if let Some(ref mut fuzzer) = executor.inspector_config_mut().fuzzer { - if let Some(ref mut call_generator) = fuzzer.call_generator { + if let Some(fuzzer) = &mut executor.inspector.fuzzer { + if let Some(call_generator) = &mut fuzzer.call_generator { call_generator.last_sequence = Arc::new(RwLock::new(inner_sequence.to_owned())); call_generator.set_replay(true); } diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index 3907884d02338..e45e988b91c99 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -190,7 +190,7 @@ impl<'a> InvariantExecutor<'a> { } // Commit changes to the database. - executor.backend_mut().commit(state_changeset.clone()); + executor.backend.commit(state_changeset.clone()); fuzz_runs.push(FuzzCase { calldata: calldata.clone(), @@ -275,7 +275,7 @@ impl<'a> InvariantExecutor<'a> { // Stores fuzz state for use with [fuzz_calldata_from_state]. let fuzz_state: EvmFuzzState = - build_initial_state(self.executor.backend().mem_db(), &self.config.dictionary); + build_initial_state(self.executor.backend.mem_db(), &self.config.dictionary); // During execution, any newly created contract is added here and used through the rest of // the fuzz run. @@ -310,7 +310,7 @@ impl<'a> InvariantExecutor<'a> { )); } - self.executor.inspector_config_mut().fuzzer = + self.executor.inspector.fuzzer = Some(Fuzzer { call_generator, fuzz_state: fuzz_state.clone(), collect: true }); Ok((fuzz_state, targeted_contracts, strat)) diff --git a/crates/evm/src/fuzz/invariant/mod.rs b/crates/evm/src/fuzz/invariant/mod.rs index 1b6ed27ee3b5e..850ec10fe51cb 100644 --- a/crates/evm/src/fuzz/invariant/mod.rs +++ b/crates/evm/src/fuzz/invariant/mod.rs @@ -52,8 +52,8 @@ pub fn assert_invariants( let mut found_case = false; let mut inner_sequence = vec![]; - if let Some(ref fuzzer) = executor.inspector_config().fuzzer { - if let Some(ref call_generator) = fuzzer.call_generator { + if let Some(fuzzer) = &executor.inspector.fuzzer { + if let Some(call_generator) = &fuzzer.call_generator { inner_sequence.extend(call_generator.last_sequence.read().iter().cloned()); } } diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index d8d4edbe64daa..c5f19bef36c95 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -80,10 +80,10 @@ impl<'a> FuzzedExecutor<'a> { let coverage: RefCell> = RefCell::default(); // Stores fuzz state for use with [fuzz_calldata_from_state] - let state: EvmFuzzState = if let Some(fork_db) = self.executor.backend().active_fork_db() { + let state: EvmFuzzState = if let Some(fork_db) = self.executor.backend.active_fork_db() { build_initial_state(fork_db, &self.config.dictionary) } else { - build_initial_state(self.executor.backend().mem_db(), &self.config.dictionary) + build_initial_state(self.executor.backend.mem_db(), &self.config.dictionary) }; let mut weights = vec![]; diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/src/fuzz/strategies/state.rs index 67c6c569e4e1c..2cad56de24988 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/src/fuzz/strategies/state.rs @@ -19,14 +19,14 @@ use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, }; -use std::{io::Write, sync::Arc}; +use std::{fmt, io::Write, sync::Arc}; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// /// Wrapped in a shareable container. pub type EvmFuzzState = Arc>; -#[derive(Debug, Default)] +#[derive(Default)] pub struct FuzzDictionary { /// Collected state values. state_values: HashSet<[u8; 32]>, @@ -34,6 +34,15 @@ pub struct FuzzDictionary { addresses: HashSet
, } +impl fmt::Debug for FuzzDictionary { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("FuzzDictionary") + .field("state_values", &self.state_values.len()) + .field("addresses", &self.addresses) + .finish() + } +} + impl FuzzDictionary { #[inline] pub fn values(&self) -> &HashSet<[u8; 32]> { @@ -73,9 +82,8 @@ pub fn fuzz_calldata_from_state( func.encode_input(&tokens) .unwrap_or_else(|_| { panic!( - r#"Fuzzer generated invalid tokens {:?} for function `{}` inputs {:?} -This is a bug, please open an issue: https://github.com/foundry-rs/foundry/issues"#, - tokens, func.name, func.inputs + "Fuzzer generated invalid tokens for function `{}` with inputs {:?}: {:?}", + func.name, func.inputs, tokens ) }) .into() diff --git a/crates/evm/src/trace/executor.rs b/crates/evm/src/trace/executor.rs index 6d941aa4435ef..7a57f68c42fe0 100644 --- a/crates/evm/src/trace/executor.rs +++ b/crates/evm/src/trace/executor.rs @@ -20,18 +20,14 @@ impl TracingExecutor { debug: bool, ) -> Self { let db = Backend::spawn(fork).await; - - // configures a bare version of the evm executor: no cheatcode inspector is enabled, - // tracing will be enabled only for the targeted transaction - let builder = ExecutorBuilder::default() - .with_config(env) - .with_spec(evm_spec(&version.unwrap_or_default())); - - let mut executor = builder.build(db); - - executor.set_tracing(true).set_debugger(debug); - - Self { executor } + Self { + // configures a bare version of the evm executor: no cheatcode inspector is enabled, + // tracing will be enabled only for the targeted transaction + executor: ExecutorBuilder::new() + .inspectors(|stack| stack.trace(true).debug(debug)) + .spec(evm_spec(version.unwrap_or_default())) + .build(env, db), + } } /// uses the fork block number from the config diff --git a/crates/evm/src/utils.rs b/crates/evm/src/utils.rs index 166878dcfa25c..2d22947ffa92a 100644 --- a/crates/evm/src/utils.rs +++ b/crates/evm/src/utils.rs @@ -5,12 +5,13 @@ use ethers::{ }; use eyre::ContextCompat; use revm::{ - interpreter::{opcode, opcode::spec_opcode_gas}, - primitives::SpecId, + interpreter::{opcode, opcode::spec_opcode_gas, InstructionResult}, + primitives::{Eval, Halt, SpecId}, }; use std::collections::BTreeMap; /// Small helper function to convert [U256] into [H256]. +#[inline] pub fn u256_to_h256_le(u: U256) -> H256 { let mut h = H256::default(); u.to_little_endian(h.as_mut()); @@ -18,6 +19,7 @@ pub fn u256_to_h256_le(u: U256) -> H256 { } /// Small helper function to convert [U256] into [H256]. +#[inline] pub fn u256_to_h256_be(u: U256) -> H256 { let mut h = H256::default(); u.to_big_endian(h.as_mut()); @@ -25,11 +27,13 @@ pub fn u256_to_h256_be(u: U256) -> H256 { } /// Small helper function to convert [H256] into [U256]. +#[inline] pub fn h256_to_u256_be(storage: H256) -> U256 { U256::from_big_endian(storage.as_bytes()) } /// Small helper function to convert [H256] into [U256]. +#[inline] pub fn h256_to_u256_le(storage: H256) -> U256 { U256::from_little_endian(storage.as_bytes()) } @@ -73,71 +77,44 @@ pub fn ru256_to_u256(u: revm::primitives::U256) -> ethers::types::U256 { } /// Small helper function to convert an Eval into an InstructionResult -pub fn eval_to_instruction_result( - eval: revm::primitives::Eval, -) -> revm::interpreter::InstructionResult { +#[inline] +pub fn eval_to_instruction_result(eval: Eval) -> InstructionResult { match eval { - revm::primitives::Eval::Return => revm::interpreter::InstructionResult::Return, - revm::primitives::Eval::Stop => revm::interpreter::InstructionResult::Stop, - revm::primitives::Eval::SelfDestruct => revm::interpreter::InstructionResult::SelfDestruct, + Eval::Return => InstructionResult::Return, + Eval::Stop => InstructionResult::Stop, + Eval::SelfDestruct => InstructionResult::SelfDestruct, } } /// Small helper function to convert a Halt into an InstructionResult -pub fn halt_to_instruction_result( - halt: revm::primitives::Halt, -) -> revm::interpreter::InstructionResult { +#[inline] +pub fn halt_to_instruction_result(halt: Halt) -> InstructionResult { match halt { - revm::primitives::Halt::OutOfGas(_) => revm::interpreter::InstructionResult::OutOfGas, - revm::primitives::Halt::OpcodeNotFound => { - revm::interpreter::InstructionResult::OpcodeNotFound - } - revm::primitives::Halt::InvalidFEOpcode => { - revm::interpreter::InstructionResult::InvalidFEOpcode - } - revm::primitives::Halt::InvalidJump => revm::interpreter::InstructionResult::InvalidJump, - revm::primitives::Halt::NotActivated => revm::interpreter::InstructionResult::NotActivated, - revm::primitives::Halt::StackOverflow => { - revm::interpreter::InstructionResult::StackOverflow - } - revm::primitives::Halt::StackUnderflow => { - revm::interpreter::InstructionResult::StackUnderflow - } - revm::primitives::Halt::OutOfOffset => revm::interpreter::InstructionResult::OutOfOffset, - revm::primitives::Halt::CreateCollision => { - revm::interpreter::InstructionResult::CreateCollision - } - revm::primitives::Halt::PrecompileError => { - revm::interpreter::InstructionResult::PrecompileError - } - revm::primitives::Halt::NonceOverflow => { - revm::interpreter::InstructionResult::NonceOverflow - } - revm::primitives::Halt::CreateContractSizeLimit => { - revm::interpreter::InstructionResult::CreateContractSizeLimit - } - revm::primitives::Halt::CreateContractStartingWithEF => { - revm::interpreter::InstructionResult::CreateContractStartingWithEF - } - revm::primitives::Halt::CreateInitcodeSizeLimit => { - revm::interpreter::InstructionResult::CreateInitcodeSizeLimit - } - revm::primitives::Halt::OverflowPayment => { - revm::interpreter::InstructionResult::OverflowPayment - } - revm::primitives::Halt::StateChangeDuringStaticCall => { - revm::interpreter::InstructionResult::StateChangeDuringStaticCall - } - revm::primitives::Halt::CallNotAllowedInsideStatic => { - revm::interpreter::InstructionResult::CallNotAllowedInsideStatic - } - revm::primitives::Halt::OutOfFund => revm::interpreter::InstructionResult::OutOfFund, - revm::primitives::Halt::CallTooDeep => revm::interpreter::InstructionResult::CallTooDeep, + Halt::OutOfGas(_) => InstructionResult::OutOfGas, + Halt::OpcodeNotFound => InstructionResult::OpcodeNotFound, + Halt::InvalidFEOpcode => InstructionResult::InvalidFEOpcode, + Halt::InvalidJump => InstructionResult::InvalidJump, + Halt::NotActivated => InstructionResult::NotActivated, + Halt::StackOverflow => InstructionResult::StackOverflow, + Halt::StackUnderflow => InstructionResult::StackUnderflow, + Halt::OutOfOffset => InstructionResult::OutOfOffset, + Halt::CreateCollision => InstructionResult::CreateCollision, + Halt::PrecompileError => InstructionResult::PrecompileError, + Halt::NonceOverflow => InstructionResult::NonceOverflow, + Halt::CreateContractSizeLimit => InstructionResult::CreateContractSizeLimit, + Halt::CreateContractStartingWithEF => InstructionResult::CreateContractStartingWithEF, + Halt::CreateInitcodeSizeLimit => InstructionResult::CreateInitcodeSizeLimit, + Halt::OverflowPayment => InstructionResult::OverflowPayment, + Halt::StateChangeDuringStaticCall => InstructionResult::StateChangeDuringStaticCall, + Halt::CallNotAllowedInsideStatic => InstructionResult::CallNotAllowedInsideStatic, + Halt::OutOfFund => InstructionResult::OutOfFund, + Halt::CallTooDeep => InstructionResult::CallTooDeep, } } -/// Converts an `EvmVersion` into a `SpecId` -pub fn evm_spec(evm: &EvmVersion) -> SpecId { +/// Converts an `EvmVersion` into a `SpecId`. +#[inline] +pub fn evm_spec(evm: EvmVersion) -> SpecId { match evm { EvmVersion::Homestead => SpecId::HOMESTEAD, EvmVersion::TangerineWhistle => SpecId::TANGERINE, diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index cab986aa2bfe8..ca0580f92331e 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -286,7 +286,7 @@ impl CoverageArgs { let root = project.paths.root; // Build the contract runner - let evm_spec = evm_spec(&config.evm_version); + let evm_spec = evm_spec(config.evm_version); let env = evm_opts.evm_env().await?; let mut runner = MultiContractRunnerBuilder::default() .initial_balance(evm_opts.initial_balance) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index faeb3147d3ead..ac42e3c2a9ee1 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -178,7 +178,7 @@ impl ScriptArgs { // Simulate mining the transaction if the user passes `--slow`. if self.slow { - runner.executor.env_mut().block.number += rU256::from(1); + runner.executor.env.block.number += rU256::from(1); } let is_fixed_gas_limit = tx.gas.is_some(); @@ -302,19 +302,20 @@ impl ScriptArgs { } }; - let mut builder = ExecutorBuilder::default() - .with_config(env) - .with_spec(evm_spec(&script_config.config.evm_version)) - .with_gas_limit(script_config.evm_opts.gas_limit()) - // We need it enabled to decode contract names: local or external. - .set_tracing(true); + // We need to enable tracing to decode contract names: local or external. + let mut builder = ExecutorBuilder::new() + .inspectors(|stack| stack.trace(true)) + .spec(evm_spec(script_config.config.evm_version)) + .gas_limit(script_config.evm_opts.gas_limit()); if let SimulationStage::Local = stage { - builder = builder - .set_debugger(self.debug) - .with_cheatcodes(CheatsConfig::new(&script_config.config, &script_config.evm_opts)); + builder = builder.inspectors(|stack| { + stack.debug(self.debug).cheatcodes( + CheatsConfig::new(&script_config.config, &script_config.evm_opts).into(), + ) + }); } - ScriptRunner::new(builder.build(db), script_config.evm_opts.initial_balance, sender) + ScriptRunner::new(builder.build(env, db), script_config.evm_opts.initial_balance, sender) } } diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 338befa271c0d..8a50bb21eaf32 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -88,7 +88,7 @@ impl ScriptRunner { // Optionally call the `setUp` function let (success, gas_used, labeled_addresses, transactions, debug, script_wallets) = if !setup { - self.executor.backend_mut().set_test_contract(address); + self.executor.backend.set_test_contract(address); ( true, 0, @@ -179,17 +179,12 @@ impl ScriptRunner { sender_initial_nonce: U256, libraries_len: usize, ) -> Result<()> { - if let Some(ref cheatcodes) = self.executor.inspector_config().cheatcodes { + if let Some(cheatcodes) = &self.executor.inspector.cheatcodes { if !cheatcodes.corrected_nonce { self.executor .set_nonce(self.sender, sender_initial_nonce.as_u64() + libraries_len as u64)?; } - self.executor - .inspector_config_mut() - .cheatcodes - .as_mut() - .expect("exists") - .corrected_nonce = false; + self.executor.inspector.cheatcodes.as_mut().unwrap().corrected_nonce = false; } Ok(()) } @@ -327,14 +322,14 @@ impl ScriptRunner { let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { // store the current gas limit and reset it later - let init_gas_limit = self.executor.env_mut().tx.gas_limit; + let init_gas_limit = self.executor.env.tx.gas_limit; let mut highest_gas_limit = gas_used * 3; let mut lowest_gas_limit = gas_used; let mut last_highest_gas_limit = highest_gas_limit; while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; - self.executor.env_mut().tx.gas_limit = mid_gas_limit; + self.executor.env.tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; match res.exit_reason { InstructionResult::Revert | @@ -360,7 +355,7 @@ impl ScriptRunner { } } // reset gas limit in the - self.executor.env_mut().tx.gas_limit = init_gas_limit; + self.executor.env.tx.gas_limit = init_gas_limit; } Ok(gas_used) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index f5648b850b899..e5a0b560acbe8 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -178,7 +178,7 @@ impl TestArgs { let env = evm_opts.evm_env().await?; // Prepare the test builder - let evm_spec = evm_spec(&config.evm_version); + let evm_spec = evm_spec(config.evm_version); let mut runner = MultiContractRunnerBuilder::default() .initial_balance(evm_opts.initial_balance) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 72094ac69cf65..24b06d63f088d 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -20,7 +20,7 @@ use revm::primitives::SpecId; use std::{ collections::{BTreeMap, HashSet}, path::Path, - sync::mpsc::Sender, + sync::{mpsc::Sender, Arc}, }; pub type DeployableContracts = BTreeMap)>; @@ -48,7 +48,7 @@ pub struct MultiContractRunner { /// The fork to use at launch pub fork: Option, /// Additional cheatcode inspector related settings derived from the `Config` - pub cheats_config: CheatsConfig, + pub cheats_config: Arc, /// Whether to collect coverage info pub coverage: bool, /// Settings related to fuzz and/or invariant tests @@ -139,14 +139,16 @@ impl MultiContractRunner { }) .filter(|(_, (abi, _, _))| abi.functions().any(|func| filter.matches_test(&func.name))) .map_with(stream_result, |stream_result, (id, (abi, deploy_code, libs))| { - let executor = ExecutorBuilder::default() - .with_cheatcodes(self.cheats_config.clone()) - .with_config(self.env.clone()) - .with_spec(self.evm_spec) - .with_gas_limit(self.evm_opts.gas_limit()) - .set_tracing(self.evm_opts.verbosity >= 3) - .set_coverage(self.coverage) - .build(db.clone()); + let executor = ExecutorBuilder::new() + .inspectors(|stack| { + stack + .cheatcodes(self.cheats_config.clone()) + .trace(self.evm_opts.verbosity >= 3) + .coverage(self.coverage) + }) + .spec(self.evm_spec) + .gas_limit(self.evm_opts.gas_limit()) + .build(self.env.clone(), db.clone()); let identifier = id.identifier(); trace!(contract=%identifier, "start executing all tests in contract"); @@ -320,7 +322,7 @@ impl MultiContractRunnerBuilder { errors: Some(execution_info.2), source_paths, fork: self.fork, - cheats_config: self.cheats_config.unwrap_or_default(), + cheats_config: self.cheats_config.unwrap_or_default().into(), coverage: self.coverage, test_options: self.test_options.unwrap_or_default(), }) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index c489429696a80..f4bddf893102f 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -211,13 +211,14 @@ impl<'a> ContractRunner<'a> { let has_invariants = self.contract.functions().any(|func| func.is_invariant_test()); // Invariant testing requires tracing to figure out what contracts were created. - let original_tracing = self.executor.inspector_config().tracing; - if has_invariants && needs_setup { + let tmp_tracing = self.executor.inspector.tracer.is_none() && has_invariants && needs_setup; + if tmp_tracing { self.executor.set_tracing(true); } - let setup = self.setup(needs_setup); - self.executor.set_tracing(original_tracing); + if tmp_tracing { + self.executor.set_tracing(false); + } if setup.reason.is_some() { // The setup failed, so we return a single test result for `setUp` From 434a6682c1aad9940d46260c88d28b54bfeb9d7e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Aug 2023 12:36:31 +0200 Subject: [PATCH 0016/1963] chore(deps): weekly `cargo update` (#5677) Updating git repository `https://github.com/bluealloy/revm/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating anyhow v1.0.72 -> v1.0.75 Updating clap v4.3.21 -> v4.3.23 Updating clap_builder v4.3.21 -> v4.3.23 Updating const-hex v1.6.1 -> v1.6.2 Updating ethers v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-addressbook v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-contract v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-contract-abigen v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-contract-derive v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-core v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-etherscan v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-middleware v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-providers v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-signers v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating ethers-solc v2.0.8 (https://github.com/gakonst/ethers-rs#fa301771) -> #179891d4 Updating flate2 v1.0.26 -> v1.0.27 Updating ordered-float v3.7.0 -> v3.9.0 Updating quote v1.0.32 -> v1.0.33 Downgrading serde v1.0.183 -> v1.0.171 Downgrading serde_derive v1.0.183 -> v1.0.171 Updating serde_json v1.0.104 -> v1.0.105 Updating syn v2.0.28 -> v2.0.29 Updating tempfile v3.7.1 -> v3.8.0 Updating thiserror v1.0.44 -> v1.0.47 Updating thiserror-impl v1.0.44 -> v1.0.47 Updating time v0.3.25 -> v0.3.26 Updating time-macros v0.2.11 -> v0.2.12 Updating tokio v1.31.0 -> v1.32.0 Updating windows-targets v0.48.2 -> v0.48.5 Updating windows_aarch64_gnullvm v0.48.2 -> v0.48.5 Updating windows_aarch64_msvc v0.48.2 -> v0.48.5 Updating windows_i686_gnu v0.48.2 -> v0.48.5 Updating windows_i686_msvc v0.48.2 -> v0.48.5 Updating windows_x86_64_gnu v0.48.2 -> v0.48.5 Updating windows_x86_64_gnullvm v0.48.2 -> v0.48.5 Updating windows_x86_64_msvc v0.48.2 -> v0.48.5 Updating winnow v0.5.10 -> v0.5.14 Co-authored-by: mattsse --- Cargo.lock | 205 ++++++++++++++++++++++++++--------------------------- 1 file changed, 102 insertions(+), 103 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ac2a96a23d8d..b262dd4564c86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,9 +261,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "ariadne" @@ -440,7 +440,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -451,7 +451,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -940,9 +940,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.21" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" dependencies = [ "clap_builder", "clap_derive", @@ -951,9 +951,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" dependencies = [ "anstream", "anstyle", @@ -993,7 +993,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1180,9 +1180,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268f52aae268980d03dd9544c1ea591965b2735b038d6998d6e4ab37c8c24445" +checksum = "ca268df6cd88e646b564e6aff1a016834e5f42077c736ef6b6789c31ef9ec5dc" dependencies = [ "cfg-if", "cpufeatures", @@ -1751,7 +1751,7 @@ checksum = "b893c4eb2dc092c811165f84dc7447fae16fb66521717968c34c509b39b1a5c5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1890,7 +1890,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1905,7 +1905,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "ethers-core", "once_cell", @@ -1916,14 +1916,13 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "const-hex", "ethers-contract-abigen", "ethers-contract-derive", "ethers-core", "ethers-providers", - "ethers-signers", "futures-util", "once_cell", "pin-project", @@ -1935,7 +1934,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "Inflector", "const-hex", @@ -1950,7 +1949,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.28", + "syn 2.0.29", "toml 0.7.6", "walkdir", ] @@ -1958,7 +1957,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "Inflector", "const-hex", @@ -1967,13 +1966,13 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "ethers-core" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "arrayvec", "bytes", @@ -1992,7 +1991,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.28", + "syn 2.0.29", "tempfile", "thiserror", "tiny-keccak", @@ -2002,7 +2001,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "ethers-core", "ethers-solc", @@ -2017,7 +2016,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "async-trait", "auto_impl", @@ -2043,7 +2042,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "async-trait", "auto_impl", @@ -2081,7 +2080,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "async-trait", "coins-bip32", @@ -2108,7 +2107,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#fa3017715a298728d9fb341933818a5d0d84c2dc" +source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" dependencies = [ "cfg-if", "const-hex", @@ -2195,7 +2194,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2276,9 +2275,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "miniz_oxide", @@ -2421,7 +2420,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-macros", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2586,7 +2585,7 @@ version = "0.2.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2737,7 +2736,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4034,7 +4033,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4291,7 +4290,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4395,7 +4394,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4424,9 +4423,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "3.7.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fc2dbde8f8a79f2102cc474ceb0ad68e3b80b85289ea62389b60e66777e4213" +checksum = "126d3e6f3926bfb0fb24495b4f4da50626f547e54956594748e3d8882a0320b4" dependencies = [ "num-traits", ] @@ -4528,7 +4527,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec 1.11.0", - "windows-targets 0.48.2", + "windows-targets 0.48.5", ] [[package]] @@ -4596,7 +4595,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4644,7 +4643,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4747,7 +4746,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4785,7 +4784,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4879,7 +4878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" dependencies = [ "proc-macro2", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4947,7 +4946,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "version_check", "yansi 1.0.0-rc.1", ] @@ -5022,9 +5021,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -5893,9 +5892,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.183" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] @@ -5913,20 +5912,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "indexmap 2.0.0", "itoa", @@ -5987,7 +5986,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -6302,7 +6301,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -6370,9 +6369,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -6405,9 +6404,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.7.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", @@ -6472,22 +6471,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -6502,9 +6501,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" +checksum = "a79d09ac6b08c1ab3906a2f7cc2e81a0e27c7ae89c63812df75e52bef0751e07" dependencies = [ "deranged", "itoa", @@ -6523,9 +6522,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" +checksum = "75c65469ed6b3a4809d987a41eb1dc918e9bc1d92211cbad7ae82931846f7451" dependencies = [ "time-core", ] @@ -6566,9 +6565,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.31.0" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ "backtrace", "bytes", @@ -6591,7 +6590,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -6828,7 +6827,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -7282,7 +7281,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -7316,7 +7315,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7461,7 +7460,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.2", + "windows-targets 0.48.5", ] [[package]] @@ -7479,7 +7478,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.2", + "windows-targets 0.48.5", ] [[package]] @@ -7499,17 +7498,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1eeca1c172a285ee6c2c84c341ccea837e7c01b12fbb2d0fe3c9e550ce49ec8" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.2", - "windows_aarch64_msvc 0.48.2", - "windows_i686_gnu 0.48.2", - "windows_i686_msvc 0.48.2", - "windows_x86_64_gnu 0.48.2", - "windows_x86_64_gnullvm 0.48.2", - "windows_x86_64_msvc 0.48.2", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -7520,9 +7519,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10d0c968ba7f6166195e13d593af609ec2e3d24f916f081690695cf5eaffb2f" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -7532,9 +7531,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571d8d4e62f26d4932099a9efe89660e8bd5087775a2ab5cdd8b747b811f1058" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -7544,9 +7543,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2229ad223e178db5fbbc8bd8d3835e51e566b8474bfca58d2e6150c48bb723cd" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -7556,9 +7555,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600956e2d840c194eedfc5d18f8242bc2e17c7775b6684488af3a9fff6fe3287" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -7568,9 +7567,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea99ff3f8b49fb7a8e0d305e5aec485bd068c2ba691b6e277d29eaeac945868a" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -7580,9 +7579,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1a05a1ece9a7a0d5a7ccf30ba2c33e3a61a30e042ffd247567d1de1d94120d" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -7592,15 +7591,15 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.10" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5504cc7644f4b593cbc05c4a55bf9bd4e94b867c3c0bd440934174d50482427d" +checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] @@ -7677,7 +7676,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] From 18388a8992f706a6d83c428b99457f4d3f00cda1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 20 Aug 2023 17:46:19 +0200 Subject: [PATCH 0017/1963] refactor: parallelize invariants (#5676) * refactor: parallelize invariants * chore: clippy * collect before --- .../src/executor/inspector/cheatcodes/mod.rs | 1 - crates/evm/src/fuzz/invariant/error.rs | 36 +- crates/evm/src/fuzz/invariant/executor.rs | 267 ++++++------- crates/evm/src/fuzz/invariant/mod.rs | 137 +++---- crates/evm/src/fuzz/mod.rs | 11 + crates/forge/src/result.rs | 2 +- crates/forge/src/runner.rs | 358 +++++++++--------- 7 files changed, 374 insertions(+), 438 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 2a6d1c1d3db49..2a0a24b7b06e5 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -217,7 +217,6 @@ impl Cheatcodes { // but only if the backend is in forking mode data.db.ensure_cheatcode_access_forking_mode(caller)?; - // TODO: Log the opcode for the debugger let opt = env::apply(self, data, caller, &decoded) .transpose() .or_else(|| util::apply(self, data, &decoded)) diff --git a/crates/evm/src/fuzz/invariant/error.rs b/crates/evm/src/fuzz/invariant/error.rs index 2f1be0c510a03..0f6157d329655 100644 --- a/crates/evm/src/fuzz/invariant/error.rs +++ b/crates/evm/src/fuzz/invariant/error.rs @@ -41,17 +41,18 @@ impl InvariantFuzzError { calldata: &[BasicTxDetails], call_result: RawCallResult, inner_sequence: &[Option], - shrink_sequence: bool, + shrink: bool, ) -> Self { - let mut func = None; - let origin: String; - - if let Some(f) = error_func { - func = Some(f.short_signature().into()); - origin = f.name.clone(); + let (func, origin) = if let Some(f) = error_func { + (Some(f.short_signature().into()), f.name.as_str()) } else { - origin = "Revert".to_string(); - } + (None, "Revert") + }; + let revert_reason = decode_revert( + call_result.result.as_ref(), + Some(invariant_contract.abi), + Some(call_result.exit_reason), + ); InvariantFuzzError { logs: call_result.logs, @@ -60,12 +61,8 @@ impl InvariantFuzzError { format!( "{}, reason: '{}'", origin, - match decode_revert( - call_result.result.as_ref(), - Some(invariant_contract.abi), - Some(call_result.exit_reason) - ) { - Ok(e) => e, + match &revert_reason { + Ok(s) => s.clone(), Err(e) => e.to_string(), } ) @@ -73,16 +70,11 @@ impl InvariantFuzzError { calldata.to_vec(), ), return_reason: "".into(), - revert_reason: decode_revert( - call_result.result.as_ref(), - Some(invariant_contract.abi), - Some(call_result.exit_reason), - ) - .unwrap_or_default(), + revert_reason: revert_reason.unwrap_or_default(), addr: invariant_contract.address, func, inner_sequence: inner_sequence.to_vec(), - shrink: shrink_sequence, + shrink, } } diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index e45e988b91c99..154bf729fb670 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -20,10 +20,10 @@ use crate::{ CALLER, }; use ethers::{ - abi::{Abi, Address, Detokenize, FixedBytes, Function, Tokenizable, TokenizableItem}, + abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem}, prelude::U256, }; -use eyre::ContextCompat; +use eyre::{ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; use parking_lot::{Mutex, RwLock}; @@ -46,12 +46,12 @@ type InvariantPreparation = /// Contains the success condition and call results of the last run struct RichInvariantResults { success: bool, - call_results: Option>, + call_result: Option, } impl RichInvariantResults { - fn new(success: bool, call_results: Option>) -> Self { - Self { success, call_results } + fn new(success: bool, call_result: Option) -> Self { + Self { success, call_result } } } @@ -61,7 +61,7 @@ impl RichInvariantResults { /// inputs, until it finds a counterexample sequence. The provided [`TestRunner`] contains all the /// configuration which can be overridden via [environment variables](https://docs.rs/proptest/1.0.0/proptest/test_runner/struct.Config.html) pub struct InvariantExecutor<'a> { - pub executor: &'a mut Executor, + pub executor: Executor, /// Proptest runner. runner: TestRunner, /// The invariant configuration @@ -78,7 +78,7 @@ pub struct InvariantExecutor<'a> { impl<'a> InvariantExecutor<'a> { /// Instantiates a fuzzed executor EVM given a testrunner pub fn new( - executor: &'a mut Executor, + executor: Executor, runner: TestRunner, config: InvariantConfig, setup_contracts: &'a ContractsByAddress, @@ -94,112 +94,96 @@ impl<'a> InvariantExecutor<'a> { } } - /// Fuzzes any deployed contract and checks any broken invariant at `invariant_address` - /// Returns a list of all the consumed gas and calldata of every invariant fuzz case + /// Fuzzes any deployed contract and checks any broken invariant at `invariant_address`. pub fn invariant_fuzz( &mut self, - invariant_contract: &InvariantContract, - ) -> eyre::Result { - let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(invariant_contract)?; + invariant_contract: InvariantContract, + ) -> Result { + let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract)?; // Stores the consumed gas and calldata of every successful fuzz call. let fuzz_cases: RefCell> = RefCell::new(Default::default()); // Stores data related to reverts or failed assertions of the test. - let failures = - RefCell::new(InvariantFailures::new(&invariant_contract.invariant_functions)); - - let blank_executor = RefCell::new(&mut *self.executor); - - let last_call_results = RefCell::new( - assert_invariants( - invariant_contract, - &blank_executor.borrow(), - &[], - &mut failures.borrow_mut(), - self.config.shrink_sequence, - ) - .ok(), - ); + let failures = RefCell::new(InvariantFailures::new()); + + let last_call_results = RefCell::new(assert_invariants( + &invariant_contract, + &self.executor, + &[], + &mut failures.borrow_mut(), + self.config.shrink_sequence, + )); let last_run_calldata: RefCell> = RefCell::new(vec![]); // Make sure invariants are sound even before starting to fuzz if last_call_results.borrow().is_none() { fuzz_cases.borrow_mut().push(FuzzedCases::new(vec![])); } - if failures.borrow().broken_invariants_count < invariant_contract.invariant_functions.len() - { - // The strategy only comes with the first `input`. We fill the rest of the `inputs` - // until the desired `depth` so we can use the evolving fuzz dictionary - // during the run. We need another proptest runner to query for random - // values. - let branch_runner = RefCell::new(self.runner.clone()); - let _ = self.runner.run(&strat, |mut inputs| { - // Scenarios where we want to fail as soon as possible. - { - if self.config.fail_on_revert && failures.borrow().reverts == 1 { - return Err(TestCaseError::fail("Revert occurred.")) - } - - if failures.borrow().broken_invariants_count == - invariant_contract.invariant_functions.len() - { - return Err(TestCaseError::fail("All invariants have been broken.")) - } - } + // The strategy only comes with the first `input`. We fill the rest of the `inputs` + // until the desired `depth` so we can use the evolving fuzz dictionary + // during the run. We need another proptest runner to query for random + // values. + let branch_runner = RefCell::new(self.runner.clone()); + let _ = self.runner.run(&strat, |mut inputs| { + // Scenarios where we want to fail as soon as possible. + if self.config.fail_on_revert && failures.borrow().reverts == 1 { + return Err(TestCaseError::fail("Revert occurred.")) + } - // Before each run, we must reset the backend state. - let mut executor = blank_executor.borrow().clone(); + // Before each run, we must reset the backend state. + let mut executor = self.executor.clone(); - // Used for stat reports (eg. gas usage). - let mut fuzz_runs = Vec::with_capacity(self.config.depth as usize); + // Used for stat reports (eg. gas usage). + let mut fuzz_runs = Vec::with_capacity(self.config.depth as usize); - // Created contracts during a run. - let mut created_contracts = vec![]; + // Created contracts during a run. + let mut created_contracts = vec![]; - 'fuzz_run: for current_run in 0..self.config.depth { - let (sender, (address, calldata)) = - inputs.last().expect("to have the next randomly generated input."); + for current_run in 0..self.config.depth { + let (sender, (address, calldata)) = + inputs.last().expect("to have the next randomly generated input."); - // Executes the call from the randomly generated sequence. - let call_result = executor - .call_raw(*sender, *address, calldata.0.clone(), U256::zero()) - .expect("could not make raw evm call"); + // Executes the call from the randomly generated sequence. + let call_result = executor + .call_raw(*sender, *address, calldata.0.clone(), U256::zero()) + .expect("could not make raw evm call"); - // Collect data for fuzzing from the state changeset. - let mut state_changeset = - call_result.state_changeset.to_owned().expect("no changesets"); + // Collect data for fuzzing from the state changeset. + let mut state_changeset = + call_result.state_changeset.to_owned().expect("no changesets"); - collect_data( - &mut state_changeset, - sender, - &call_result, - fuzz_state.clone(), - &self.config.dictionary, - ); + collect_data( + &mut state_changeset, + sender, + &call_result, + fuzz_state.clone(), + &self.config.dictionary, + ); + + if let Err(error) = collect_created_contracts( + &state_changeset, + self.project_contracts, + self.setup_contracts, + &self.artifact_filters, + targeted_contracts.clone(), + &mut created_contracts, + ) { + warn!(target: "forge::test", "{error}"); + } + + // Commit changes to the database. + executor.backend.commit(state_changeset.clone()); + + fuzz_runs.push(FuzzCase { + calldata: calldata.clone(), + gas: call_result.gas_used, + stipend: call_result.stipend, + }); - if let Err(error) = collect_created_contracts( - &state_changeset, - self.project_contracts, - self.setup_contracts, - &self.artifact_filters, - targeted_contracts.clone(), - &mut created_contracts, - ) { - warn!(target: "forge::test", "{error}"); - } - - // Commit changes to the database. - executor.backend.commit(state_changeset.clone()); - - fuzz_runs.push(FuzzCase { - calldata: calldata.clone(), - gas: call_result.gas_used, - stipend: call_result.stipend, - }); - - let RichInvariantResults { success: can_continue, call_results } = can_continue( - invariant_contract, + let RichInvariantResults { success: can_continue, call_result: call_results } = + can_continue( + &invariant_contract, call_result, &executor, &inputs, @@ -210,46 +194,45 @@ impl<'a> InvariantExecutor<'a> { self.config.shrink_sequence, ); - if !can_continue || current_run == self.config.depth - 1 { - *last_run_calldata.borrow_mut() = inputs.clone(); - } + if !can_continue || current_run == self.config.depth - 1 { + *last_run_calldata.borrow_mut() = inputs.clone(); + } - if !can_continue { - break 'fuzz_run - } + if !can_continue { + break + } - *last_call_results.borrow_mut() = call_results; + *last_call_results.borrow_mut() = call_results; - // Generates the next call from the run using the recently updated - // dictionary. - inputs.extend( - strat - .new_tree(&mut branch_runner.borrow_mut()) - .map_err(|_| TestCaseError::Fail("Could not generate case".into()))? - .current(), - ); - } + // Generates the next call from the run using the recently updated + // dictionary. + inputs.extend( + strat + .new_tree(&mut branch_runner.borrow_mut()) + .map_err(|_| TestCaseError::Fail("Could not generate case".into()))? + .current(), + ); + } - // We clear all the targeted contracts created during this run. - if !created_contracts.is_empty() { - let mut writable_targeted = targeted_contracts.lock(); - for addr in created_contracts.iter() { - writable_targeted.remove(addr); - } + // We clear all the targeted contracts created during this run. + if !created_contracts.is_empty() { + let mut writable_targeted = targeted_contracts.lock(); + for addr in created_contracts.iter() { + writable_targeted.remove(addr); } + } - fuzz_cases.borrow_mut().push(FuzzedCases::new(fuzz_runs)); + fuzz_cases.borrow_mut().push(FuzzedCases::new(fuzz_runs)); - Ok(()) - }); - } + Ok(()) + }); trace!(target: "forge::test::invariant::dictionary", "{:?}", fuzz_state.read().values().iter().map(hex::encode).collect::>()); - let (reverts, invariants) = failures.into_inner().into_inner(); + let (reverts, error) = failures.into_inner().into_inner(); Ok(InvariantFuzzTestResult { - invariants, + error, cases: fuzz_cases.into_inner(), reverts, last_run_inputs: last_run_calldata.take(), @@ -501,9 +484,11 @@ impl<'a> InvariantExecutor<'a> { address_selectors.push(get_function(name, &selector, abi)?); } } else { - let (name, abi) = self.setup_contracts.get(&address).wrap_err(format!( - "[targetSelectors] address does not have an associated contract: {address}" - ))?; + let (name, abi) = self.setup_contracts.get(&address).ok_or_else(|| { + eyre::eyre!( + "[targetSelectors] address does not have an associated contract: {address}" + ) + })?; let functions = bytes4_array .into_iter() @@ -600,8 +585,7 @@ fn can_continue( // Assert invariants IFF the call did not revert and the handlers did not fail. if !call_result.reverted && !handlers_failed { call_results = - assert_invariants(invariant_contract, executor, calldata, failures, shrink_sequence) - .ok(); + assert_invariants(invariant_contract, executor, calldata, failures, shrink_sequence); if call_results.is_none() { return RichInvariantResults::new(false, None) } @@ -622,48 +606,31 @@ fn can_continue( failures.revert_reason = Some(error.revert_reason.clone()); - // Hacky to provide the full error to the user. - for invariant in invariant_contract.invariant_functions.iter() { - failures.failed_invariants.insert( - invariant.name.clone(), - (Some(error.clone()), invariant.to_owned().clone()), - ); - } - return RichInvariantResults::new(false, None) } } RichInvariantResults::new(true, call_results) } -#[derive(Clone)] +#[derive(Clone, Default)] /// Stores information about failures and reverts of the invariant tests. pub struct InvariantFailures { - /// The latest revert reason of a run. - pub revert_reason: Option, /// Total number of reverts. pub reverts: usize, /// How many different invariants have been broken. pub broken_invariants_count: usize, + /// The latest revert reason of a run. + pub revert_reason: Option, /// Maps a broken invariant to its specific error. - pub failed_invariants: BTreeMap, Function)>, + pub error: Option, } impl InvariantFailures { - fn new(invariants: &[&Function]) -> Self { - InvariantFailures { - reverts: 0, - broken_invariants_count: 0, - failed_invariants: invariants - .iter() - .map(|f| (f.name.to_string(), (None, f.to_owned().clone()))) - .collect(), - revert_reason: None, - } + fn new() -> Self { + Self::default() } - /// Moves `reverts` and `failed_invariants` out of the struct. - fn into_inner(self) -> (usize, BTreeMap, Function)>) { - (self.reverts, self.failed_invariants) + fn into_inner(self) -> (usize, Option) { + (self.reverts, self.error) } } diff --git a/crates/evm/src/fuzz/invariant/mod.rs b/crates/evm/src/fuzz/invariant/mod.rs index 850ec10fe51cb..9bd5a828f0190 100644 --- a/crates/evm/src/fuzz/invariant/mod.rs +++ b/crates/evm/src/fuzz/invariant/mod.rs @@ -1,27 +1,33 @@ //! Fuzzing support abstracted over the [`Evm`](crate::Evm) used + use crate::{ + executor::Executor, fuzz::*, trace::{load_contracts, TraceKind, Traces}, CALLER, }; -mod error; -pub use error::InvariantFuzzError; -mod filters; -pub use filters::{ArtifactFilters, SenderFilters}; -mod call_override; -pub use call_override::{set_up_inner_replay, RandomCallGenerator}; -use foundry_common::ContractsByArtifact; -mod executor; -use crate::executor::Executor; use ethers::{ abi::{Abi, Function}, types::{Address, Bytes, U256}, }; -pub use executor::{InvariantExecutor, InvariantFailures}; +use foundry_common::ContractsByArtifact; use parking_lot::Mutex; -pub use proptest::test_runner::Config as FuzzConfig; use std::{collections::BTreeMap, sync::Arc}; +pub use proptest::test_runner::Config as FuzzConfig; + +mod error; +pub use error::InvariantFuzzError; + +mod call_override; +pub use call_override::{set_up_inner_replay, RandomCallGenerator}; + +mod executor; +pub use executor::{InvariantExecutor, InvariantFailures}; + +mod filters; +pub use filters::{ArtifactFilters, SenderFilters}; + pub type TargetedContracts = BTreeMap)>; pub type FuzzRunIdentifiedContracts = Arc>; @@ -34,7 +40,7 @@ pub struct InvariantContract<'a> { /// Address of the test contract. pub address: Address, /// Invariant functions present in the test contract. - pub invariant_functions: Vec<&'a Function>, + pub invariant_function: &'a Function, /// Abi of the test contract. pub abi: &'a Abi, } @@ -48,8 +54,7 @@ pub fn assert_invariants( calldata: &[BasicTxDetails], invariant_failures: &mut InvariantFailures, shrink_sequence: bool, -) -> eyre::Result> { - let mut found_case = false; +) -> Option { let mut inner_sequence = vec![]; if let Some(fuzzer) = &executor.inspector.fuzzer { @@ -58,80 +63,40 @@ pub fn assert_invariants( } } - let mut call_results = BTreeMap::new(); - for func in &invariant_contract.invariant_functions { - let mut call_result = executor - .call_raw( - CALLER, - invariant_contract.address, - func.encode_input(&[]).expect("invariant should have no inputs").into(), - U256::zero(), - ) - .expect("EVM error"); - - let err = if call_result.reverted { - Some(*func) - } else { - // This will panic and get caught by the executor - if !executor.is_success( - invariant_contract.address, - call_result.reverted, - call_result.state_changeset.take().expect("we should have a state changeset"), - false, - ) { - Some(*func) - } else { - None - } - }; - - if let Some(broken_invariant) = err { - let invariant_error = invariant_failures - .failed_invariants - .get(&broken_invariant.name) - .expect("to have been initialized."); - - // We only care about invariants which we haven't broken yet. - if invariant_error.0.is_none() { - invariant_failures.failed_invariants.insert( - broken_invariant.name.clone(), - ( - Some(InvariantFuzzError::new( - invariant_contract, - Some(broken_invariant), - calldata, - call_result, - &inner_sequence, - shrink_sequence, - )), - broken_invariant.clone().to_owned(), - ), - ); - found_case = true; - } else { - call_results.insert(func.name.clone(), call_result); - } - } else { - call_results.insert(func.name.clone(), call_result); - } - } - - if found_case { - let before = invariant_failures.broken_invariants_count; - - invariant_failures.broken_invariants_count = invariant_failures - .failed_invariants - .iter() - .filter(|(_function, error)| error.0.is_some()) - .count(); - - eyre::bail!( - "{} new invariants have been broken.", - invariant_failures.broken_invariants_count - before + let func = invariant_contract.invariant_function; + let mut call_result = executor + .call_raw( + CALLER, + invariant_contract.address, + func.encode_input(&[]).expect("invariant should have no inputs").into(), + U256::zero(), + ) + .expect("EVM error"); + + // This will panic and get caught by the executor + let is_err = call_result.reverted || + !executor.is_success( + invariant_contract.address, + call_result.reverted, + call_result.state_changeset.take().expect("we should have a state changeset"), + false, ); + if is_err { + // We only care about invariants which we haven't broken yet. + if invariant_failures.error.is_none() { + invariant_failures.error = Some(InvariantFuzzError::new( + invariant_contract, + Some(func), + calldata, + call_result, + &inner_sequence, + shrink_sequence, + )); + return None + } } - Ok(call_results) + Some(call_result) } /// Replays the provided invariant run for collecting the logs and traces from all depths. @@ -185,7 +150,7 @@ pub fn replay_run( /// The outcome of an invariant fuzz test #[derive(Debug)] pub struct InvariantFuzzTestResult { - pub invariants: BTreeMap, Function)>, + pub error: Option, /// Every successful fuzz test case pub cases: Vec, /// Number of reverted fuzz calls diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index c5f19bef36c95..3d7f0c559aaad 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -372,25 +372,30 @@ pub struct FuzzedCases { } impl FuzzedCases { + #[inline] pub fn new(mut cases: Vec) -> Self { cases.sort_by_key(|c| c.gas); Self { cases } } + #[inline] pub fn cases(&self) -> &[FuzzCase] { &self.cases } + #[inline] pub fn into_cases(self) -> Vec { self.cases } /// Get the last [FuzzCase] + #[inline] pub fn last(&self) -> Option<&FuzzCase> { self.cases.last() } /// Returns the median gas of all test cases + #[inline] pub fn median_gas(&self, with_stipend: bool) -> u64 { let mut values = self.gas_values(with_stipend); values.sort_unstable(); @@ -398,12 +403,14 @@ impl FuzzedCases { } /// Returns the average gas use of all test cases + #[inline] pub fn mean_gas(&self, with_stipend: bool) -> u64 { let mut values = self.gas_values(with_stipend); values.sort_unstable(); calc::mean(&values).as_u64() } + #[inline] fn gas_values(&self, with_stipend: bool) -> Vec { self.cases .iter() @@ -412,16 +419,19 @@ impl FuzzedCases { } /// Returns the case with the highest gas usage + #[inline] pub fn highest(&self) -> Option<&FuzzCase> { self.cases.last() } /// Returns the case with the lowest gas usage + #[inline] pub fn lowest(&self) -> Option<&FuzzCase> { self.cases.first() } /// Returns the highest amount of gas spent on a fuzz case + #[inline] pub fn highest_gas(&self, with_stipend: bool) -> u64 { self.highest() .map(|c| if with_stipend { c.gas } else { c.gas - c.stipend }) @@ -429,6 +439,7 @@ impl FuzzedCases { } /// Returns the lowest amount of gas spent on a fuzz case + #[inline] pub fn lowest_gas(&self) -> u64 { self.lowest().map(|c| c.gas).unwrap_or_default() } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 5cbc2296b48c0..1199a4d28f55a 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -17,7 +17,7 @@ use std::{collections::BTreeMap, fmt, time::Duration}; pub struct SuiteResult { /// Total duration of the test run for this block of tests pub duration: Duration, - /// Individual test results. `test method name -> TestResult` + /// Individual test results. `test fn signature -> TestResult` pub test_results: BTreeMap, /// Warnings pub warnings: Vec, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index f4bddf893102f..b81ce598aca64 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -198,12 +198,8 @@ impl<'a> ContractRunner<'a> { if setup_fns.len() > 1 { return SuiteResult::new( start.elapsed(), - [( - "setUp()".to_string(), - // TODO-f: get the breakpoints here - TestResult::fail("Multiple setUp functions".to_string()), - )] - .into(), + [("setUp()".to_string(), TestResult::fail("Multiple setUp functions".to_string()))] + .into(), warnings, ) } @@ -244,20 +240,18 @@ impl<'a> ContractRunner<'a> { ) } - let mut test_results = self - .contract - .functions + let functions: Vec<_> = self.contract.functions().collect(); + let mut test_results = functions .par_iter() - .flat_map(|(_, f)| f) - .filter(|&func| func.is_test() && filter.matches_test(func.signature())) - .map(|func| { + .filter(|&&func| func.is_test() && filter.matches_test(func.signature())) + .map(|&func| { let should_fail = func.is_test_fail(); let res = if func.is_fuzz_test() { let runner = test_options.fuzz_runner(self.name, &func.name); let fuzz_config = test_options.fuzz_config(self.name, &func.name); self.run_fuzz_test(func, should_fail, runner, setup.clone(), *fuzz_config) } else { - self.clone().run_test(func, should_fail, setup.clone()) + self.run_test(func, should_fail, setup.clone()) }; (func.signature(), res) }) @@ -265,27 +259,24 @@ impl<'a> ContractRunner<'a> { if has_invariants { let identified_contracts = load_contracts(setup.traces.clone(), known_contracts); - - // TODO: par_iter ? - let functions = self - .contract - .functions() - .filter(|&func| func.is_invariant_test() && filter.matches_test(func.signature())); - for func in functions { - let runner = test_options.invariant_runner(self.name, &func.name); - let invariant_config = test_options.invariant_config(self.name, &func.name); - let results = self.run_invariant_test( - runner, - setup.clone(), - *invariant_config, - vec![func], - known_contracts, - identified_contracts.clone(), - ); - for result in results { - test_results.insert(func.signature(), result); - } - } + let results: Vec<_> = functions + .par_iter() + .filter(|&&func| func.is_invariant_test() && filter.matches_test(func.signature())) + .map(|&func| { + let runner = test_options.invariant_runner(self.name, &func.name); + let invariant_config = test_options.invariant_config(self.name, &func.name); + let res = self.run_invariant_test( + runner, + setup.clone(), + *invariant_config, + func, + known_contracts, + &identified_contracts, + ); + (func.signature(), res) + }) + .collect(); + test_results.extend(results); } let duration = start.elapsed(); @@ -310,71 +301,77 @@ impl<'a> ContractRunner<'a> { /// State modifications are not committed to the evm database but discarded after the call, /// similar to `eth_call`. #[instrument(name = "test", skip_all, fields(name = %func.signature(), %should_fail))] - pub fn run_test(mut self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { + pub fn run_test(&self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { let TestSetup { address, mut logs, mut traces, mut labeled_addresses, .. } = setup; // Run unit test + let mut executor = self.executor.clone(); let start = Instant::now(); - let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = match self - .executor - .execute_test::<(), _, _>(self.sender, address, func.clone(), (), 0.into(), self.errors) - { - Ok(CallResult { - reverted, - gas_used: gas, - stipend, - logs: execution_logs, - traces: execution_trace, - coverage, - labels: new_labels, - state_changeset, - breakpoints, - .. - }) => { - traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(new_labels); - logs.extend(execution_logs); - (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) - } - Err(EvmError::Execution(err)) => { - traces.extend(err.traces.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(err.labels); - logs.extend(err.logs); - ( - err.reverted, - Some(err.reason), - err.gas_used, - err.stipend, - None, - err.state_changeset, - HashMap::new(), - ) - } - Err(EvmError::SkipError) => { - return TestResult { - status: TestStatus::Skipped, - reason: None, - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - kind: TestKind::Standard(0), - ..Default::default() + let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = + match executor.execute_test::<(), _, _>( + self.sender, + address, + func.clone(), + (), + 0.into(), + self.errors, + ) { + Ok(CallResult { + reverted, + gas_used: gas, + stipend, + logs: execution_logs, + traces: execution_trace, + coverage, + labels: new_labels, + state_changeset, + breakpoints, + .. + }) => { + traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); + labeled_addresses.extend(new_labels); + logs.extend(execution_logs); + (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) } - } - Err(err) => { - return TestResult { - status: TestStatus::Failure, - reason: Some(err.to_string()), - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - kind: TestKind::Standard(0), - ..Default::default() + Err(EvmError::Execution(err)) => { + traces.extend(err.traces.map(|traces| (TraceKind::Execution, traces))); + labeled_addresses.extend(err.labels); + logs.extend(err.logs); + ( + err.reverted, + Some(err.reason), + err.gas_used, + err.stipend, + None, + err.state_changeset, + HashMap::new(), + ) } - } - }; + Err(EvmError::SkipError) => { + return TestResult { + status: TestStatus::Skipped, + reason: None, + decoded_logs: decode_console_logs(&logs), + traces, + labeled_addresses, + kind: TestKind::Standard(0), + ..Default::default() + } + } + Err(err) => { + return TestResult { + status: TestStatus::Failure, + reason: Some(err.to_string()), + decoded_logs: decode_console_logs(&logs), + traces, + labeled_addresses, + kind: TestKind::Standard(0), + ..Default::default() + } + } + }; - let success = self.executor.is_success( + let success = executor.is_success( setup.address, reverted, state_changeset.expect("we should have a state changeset"), @@ -407,129 +404,134 @@ impl<'a> ContractRunner<'a> { #[instrument(name = "invariant-test", skip_all)] pub fn run_invariant_test( - &mut self, + &self, runner: TestRunner, setup: TestSetup, invariant_config: InvariantConfig, - functions: Vec<&Function>, + func: &Function, known_contracts: Option<&ContractsByArtifact>, - identified_contracts: ContractsByAddress, - ) -> Vec { - trace!(target: "forge::test::fuzz", "executing invariant test with invariant functions {:?}", functions.iter().map(|f|&f.name).collect::>()); + identified_contracts: &ContractsByAddress, + ) -> TestResult { + trace!(target: "forge::test::fuzz", "executing invariant test for {:?}", func.name); let empty = ContractsByArtifact::default(); let project_contracts = known_contracts.unwrap_or(&empty); let TestSetup { address, logs, traces, labeled_addresses, .. } = setup; // First, run the test normally to see if it needs to be skipped. - if let Err(EvmError::SkipError) = self.executor.execute_test::<(), _, _>( + if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<(), _, _>( self.sender, address, - functions[0].clone(), + func.clone(), (), 0.into(), self.errors, ) { - return vec![TestResult { + return TestResult { status: TestStatus::Skipped, reason: None, decoded_logs: decode_console_logs(&logs), traces, labeled_addresses, - kind: TestKind::Standard(0), + kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, ..Default::default() - }] + } }; let mut evm = InvariantExecutor::new( - &mut self.executor, + self.executor.clone(), runner, invariant_config, - &identified_contracts, + identified_contracts, project_contracts, ); let invariant_contract = - InvariantContract { address, invariant_functions: functions, abi: self.contract }; + InvariantContract { address, invariant_function: func, abi: self.contract }; - let Ok(InvariantFuzzTestResult { invariants, cases, reverts, last_run_inputs }) = - evm.invariant_fuzz(&invariant_contract) - else { - return vec![] + let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs } = match evm + .invariant_fuzz(invariant_contract.clone()) + { + Ok(x) => x, + Err(e) => { + return TestResult { + status: TestStatus::Failure, + reason: Some(format!("Failed to set up invariant testing environment: {e}")), + decoded_logs: decode_console_logs(&logs), + traces, + labeled_addresses, + kind: TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }, + ..Default::default() + } + } }; - invariants - .into_values() - .map(|(test_error, invariant)| { - let mut counterexample = None; - let mut logs = logs.clone(); - let mut traces = traces.clone(); - - let success = test_error.is_none(); - let reason = test_error.as_ref().and_then(|err| { - (!err.revert_reason.is_empty()).then(|| err.revert_reason.clone()) - }); - - match test_error { - // If invariants were broken, replay the error to collect logs and traces - Some(error @ InvariantFuzzError { test_error: TestError::Fail(_, _), .. }) => { - match error.replay( - self.executor.clone(), - known_contracts, - identified_contracts.clone(), - &mut logs, - &mut traces, - ) { - Ok(c) => counterexample = c, - Err(err) => { - error!(?err, "Failed to replay invariant error") - } - }; - - logs.extend(error.logs); - - if let Some(error_traces) = error.traces { - traces.push((TraceKind::Execution, error_traces)); - } - } - _ => { - // If invariants ran successfully, replay the last run to collect logs and - // traces. - replay_run( - &invariant_contract, - self.executor.clone(), - known_contracts, - identified_contracts.clone(), - &mut logs, - &mut traces, - invariant, - last_run_inputs.clone(), - ); + let mut counterexample = None; + let mut logs = logs.clone(); + let mut traces = traces.clone(); + let success = error.is_none(); + let reason = error + .as_ref() + .and_then(|err| (!err.revert_reason.is_empty()).then(|| err.revert_reason.clone())); + match error { + // If invariants were broken, replay the error to collect logs and traces + Some(error @ InvariantFuzzError { test_error: TestError::Fail(_, _), .. }) => { + match error.replay( + self.executor.clone(), + known_contracts, + identified_contracts.clone(), + &mut logs, + &mut traces, + ) { + Ok(c) => counterexample = c, + Err(err) => { + error!(?err, "Failed to replay invariant error") } - } - - let kind = TestKind::Invariant { - runs: cases.len(), - calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), - reverts, }; - TestResult { - status: match success { - true => TestStatus::Success, - false => TestStatus::Failure, - }, - reason, - counterexample, - decoded_logs: decode_console_logs(&logs), - logs, - kind, - coverage: None, // TODO ? - traces, - labeled_addresses: labeled_addresses.clone(), - breakpoints: Default::default(), + logs.extend(error.logs); + + if let Some(error_traces) = error.traces { + traces.push((TraceKind::Execution, error_traces)); } - }) - .collect() + } + + // If invariants ran successfully, replay the last run to collect logs and + // traces. + _ => { + replay_run( + &invariant_contract, + self.executor.clone(), + known_contracts, + identified_contracts.clone(), + &mut logs, + &mut traces, + func.clone(), + last_run_inputs.clone(), + ); + } + } + + let kind = TestKind::Invariant { + runs: cases.len(), + calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), + reverts, + }; + + TestResult { + status: match success { + true => TestStatus::Success, + false => TestStatus::Failure, + }, + reason, + counterexample, + decoded_logs: decode_console_logs(&logs), + logs, + kind, + coverage: None, // TODO ? + traces, + labeled_addresses: labeled_addresses.clone(), + breakpoints: Default::default(), + } } #[instrument(name = "fuzz-test", skip_all, fields(name = %func.signature(), %should_fail))] From 635950f8a73491666c836b01afda4d85583bdb4f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 20 Aug 2023 20:12:11 +0200 Subject: [PATCH 0018/1963] ci: fix release workflow (#5682) --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea4b26b8decf0..fef7c5db5d90d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -135,7 +135,7 @@ jobs: PLATFORM_NAME: ${{ matrix.job.platform }} TARGET: ${{ matrix.job.target }} ARCH: ${{ matrix.job.arch }} - VERSION_NAME: | + VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash run: | @@ -160,7 +160,7 @@ jobs: env: PLATFORM_NAME: ${{ matrix.job.platform }} TARGET: ${{ matrix.job.target }} - VERSION_NAME: | + VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash run: | From b536f518fb2b161c24d591f95e336194ec809c25 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 20 Aug 2023 20:14:58 +0200 Subject: [PATCH 0019/1963] ci: fix issue jobs (again) (#5681) --- .github/workflows/heavy-integration.yml | 1 + .github/workflows/release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index 6275f0424504b..d5138e9e9446f 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -42,6 +42,7 @@ jobs: issue: name: Open an issue runs-on: ubuntu-latest + needs: heavy-integration if: ${{ failure() }} steps: - uses: JasonEtco/create-an-issue@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fef7c5db5d90d..48c35af48e49e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -230,6 +230,7 @@ jobs: issue: name: Open an issue runs-on: ubuntu-latest + needs: [prepare, release-docker, release, cleanup] if: ${{ failure() }} steps: - uses: JasonEtco/create-an-issue@v2 From efedf1f9e8323bdb1c0fcf0ce728115d0a4a92f4 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 21 Aug 2023 09:29:08 -0400 Subject: [PATCH 0020/1963] feat(`evm`): Use latest `revm` main commit (#5669) * Revert "fix(`evm`): revert all revm changes (#5610)" This reverts commit a0a31c393279e08548920a54c49036a11c180a62. * upgrade revm * fmt --- Cargo.lock | 37 ++++++++++++++++--- Cargo.toml | 2 +- crates/anvil/src/eth/backend/mem/inspector.rs | 21 +++-------- crates/anvil/src/eth/error.rs | 8 +++- crates/anvil/src/genesis.rs | 2 +- crates/evm/src/executor/backend/mod.rs | 2 +- crates/evm/src/executor/fork/cache.rs | 17 ++++++--- .../evm/src/executor/inspector/access_list.rs | 1 - .../executor/inspector/cheatcodes/mapping.rs | 2 +- .../src/executor/inspector/cheatcodes/mod.rs | 8 +--- .../src/executor/inspector/chisel_state.rs | 1 - crates/evm/src/executor/inspector/coverage.rs | 6 +-- crates/evm/src/executor/inspector/debugger.rs | 3 -- crates/evm/src/executor/inspector/fuzzer.rs | 3 -- crates/evm/src/executor/inspector/logs.rs | 1 - crates/evm/src/executor/inspector/printer.rs | 10 +---- crates/evm/src/executor/inspector/stack.rs | 26 ++++--------- crates/evm/src/executor/inspector/tracer.rs | 10 +---- crates/evm/src/fuzz/strategies/state.rs | 2 +- 19 files changed, 75 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b262dd4564c86..96182a62a00d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,6 +69,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "alloy-rlp" version = "0.3.2" @@ -625,6 +631,9 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -3179,6 +3188,11 @@ name = "hashbrown" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +dependencies = [ + "ahash 0.8.3", + "allocator-api2", + "serde", +] [[package]] name = "hashers" @@ -5285,9 +5299,11 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" dependencies = [ "auto_impl", + "once_cell", + "rayon", "revm-interpreter", "revm-precompile", "serde", @@ -5297,7 +5313,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" dependencies = [ "derive_more", "enumn", @@ -5309,7 +5325,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" dependencies = [ "k256", "num", @@ -5325,15 +5341,16 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" dependencies = [ "auto_impl", + "bitflags 2.4.0", "bitvec 1.0.1", "bytes", "derive_more", "enumn", "fixed-hash", - "hashbrown 0.13.2", + "hashbrown 0.14.0", "hex", "hex-literal", "primitive-types", @@ -5341,6 +5358,7 @@ dependencies = [ "ruint", "serde", "sha3", + "to-binary", ] [[package]] @@ -6563,6 +6581,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "to-binary" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424552bc848fd1afbcd81f0e8a54b7401b90fd81bb418655ad6dc6d0823bbe3" +dependencies = [ + "hex", +] + [[package]] name = "tokio" version = "1.32.0" diff --git a/Cargo.toml b/Cargo.toml index d799d70f4b66e..59b5c182f8fa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,4 +154,4 @@ solang-parser = "=0.3.1" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" } +revm = { git = "https://github.com/bluealloy/revm/", rev = "eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index ca409b734a1f3..9ca7686c618b5 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -53,23 +53,17 @@ impl revm::Inspector for Inspector { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, ) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.initialize_interp(interp, data, is_static); + inspector.initialize_interp(interp, data); }); InstructionResult::Continue } #[inline] - fn step( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - is_static: bool, - ) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step(interp, data, is_static); + inspector.step(interp, data); }); InstructionResult::Continue } @@ -92,11 +86,10 @@ impl revm::Inspector for Inspector { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, eval: InstructionResult, ) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step_end(interp, data, is_static, eval); + inspector.step_end(interp, data, eval); }); eval } @@ -106,10 +99,9 @@ impl revm::Inspector for Inspector { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { - inspector.call(data, call, is_static); + inspector.call(data, call); }); (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) @@ -123,10 +115,9 @@ impl revm::Inspector for Inspector { remaining_gas: Gas, ret: InstructionResult, out: Bytes, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!([&mut self.tracer], |inspector| { - inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static); + inspector.call_end(data, inputs, remaining_gas, ret, out.clone()); }); (ret, remaining_gas, out) } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 888f185d5647a..8289fd289b375 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -181,6 +181,9 @@ pub enum InvalidTransactionError { /// Thrown when a legacy tx was signed for a different chain #[error("Incompatible EIP-155 transaction, signed for another chain")] IncompatibleEIP155, + /// Thrown when an access list is used before the berlin hard fork. + #[error("Access lists are not supported before the Berlin hardfork")] + AccessListNotSupported, } impl From for InvalidTransactionError { @@ -203,7 +206,7 @@ impl From for InvalidTransactionError { }) } InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA, - InvalidTransaction::LackOfFundForGasLimit { .. } => { + InvalidTransaction::LackOfFundForMaxFee { .. } => { InvalidTransactionError::InsufficientFunds } InvalidTransaction::OverflowPaymentInTransaction => { @@ -217,6 +220,9 @@ impl From for InvalidTransactionError { } InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh, InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow, + InvalidTransaction::AccessListNotSupported => { + InvalidTransactionError::AccessListNotSupported + } } } } diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 3ab285a1018ad..71b64feebd682 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -146,7 +146,7 @@ impl From for AccountInfo { AccountInfo { balance: balance.into(), nonce: nonce.unwrap_or_default(), - code_hash: code.as_ref().map(|code| code.hash).unwrap_or(KECCAK_EMPTY), + code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), code, } } diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index d286cb8a84b76..3e468f2235133 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -1099,7 +1099,7 @@ impl DatabaseExt for Backend { // prevent issues in the new journalstate, e.g. assumptions that accounts are loaded // if the account is not touched, we reload it, if it's touched we clone it for (addr, acc) in journaled_state.state.iter() { - if acc.is_touched { + if acc.is_touched() { merge_journaled_state_data( b160_to_h160(*addr), journaled_state, diff --git a/crates/evm/src/executor/fork/cache.rs b/crates/evm/src/executor/fork/cache.rs index dbd4cfe747c8e..bf1429589a0f4 100644 --- a/crates/evm/src/executor/fork/cache.rs +++ b/crates/evm/src/executor/fork/cache.rs @@ -1,9 +1,10 @@ //! Cache related abstraction use crate::executor::backend::snapshot::StateSnapshot; -use hashbrown::HashMap as Map; use parking_lot::RwLock; use revm::{ - primitives::{Account, AccountInfo, B160, B256, KECCAK_EMPTY, U256}, + primitives::{ + Account, AccountInfo, AccountStatus, HashMap as Map, B160, B256, KECCAK_EMPTY, U256, + }, DatabaseCommit, }; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; @@ -256,13 +257,17 @@ impl MemDb { let mut storage = self.storage.write(); let mut accounts = self.accounts.write(); for (add, mut acc) in changes { - if acc.is_empty() || acc.is_destroyed { + if acc.is_empty() || acc.is_selfdestructed() { accounts.remove(&add); storage.remove(&add); } else { // insert account - if let Some(code_hash) = - acc.info.code.as_ref().filter(|code| !code.is_empty()).map(|code| code.hash) + if let Some(code_hash) = acc + .info + .code + .as_ref() + .filter(|code| !code.is_empty()) + .map(|code| code.hash_slow()) { acc.info.code_hash = code_hash; } else if acc.info.code_hash.is_zero() { @@ -271,7 +276,7 @@ impl MemDb { accounts.insert(add, acc.info); let acc_storage = storage.entry(add).or_default(); - if acc.storage_cleared { + if acc.status.contains(AccountStatus::Created) { acc_storage.clear(); } for (index, value) in acc.storage { diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/src/executor/inspector/access_list.rs index 88619de35da01..65e15c300addb 100644 --- a/crates/evm/src/executor/inspector/access_list.rs +++ b/crates/evm/src/executor/inspector/access_list.rs @@ -56,7 +56,6 @@ impl Inspector for AccessListTracer { &mut self, interpreter: &mut Interpreter, _data: &mut EVMData<'_, DB>, - _is_static: bool, ) -> InstructionResult { let pc = interpreter.program_counter(); let op = interpreter.contract.bytecode.bytecode()[pc]; diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index cf81dc447eb1c..0ae5439a938b2 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -91,7 +91,7 @@ pub fn on_evm_step( _data: &mut EVMData<'_, DB>, ) { match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] { - opcode::SHA3 => { + opcode::KECCAK256 => { if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) { let address = interpreter.contract.address; let offset = interpreter.stack.peek(0).expect("stack size > 1").to::(); diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 2a0a24b7b06e5..e8900054929a6 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -294,7 +294,6 @@ impl Inspector for Cheatcodes { &mut self, _: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. @@ -312,7 +311,6 @@ impl Inspector for Cheatcodes { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { self.pc = interpreter.program_counter(); @@ -513,7 +511,7 @@ impl Inspector for Cheatcodes { (CALLCODE, 5, 6, true), (STATICCALL, 4, 5, true), (DELEGATECALL, 4, 5, true), - (SHA3, 0, 1, false), + (KECCAK256, 0, 1, false), (LOG0, 0, 1, false), (LOG1, 0, 1, false), (LOG2, 0, 1, false), @@ -568,7 +566,6 @@ impl Inspector for Cheatcodes { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, bytes::Bytes) { if call.contract == h160_to_b160(CHEATCODE_ADDRESS) { let gas = Gas::new(call.gas_limit); @@ -677,7 +674,7 @@ impl Inspector for Cheatcodes { // because we only need the from, to, value, and data. We can later change this // into 1559, in the cli package, relatively easily once we // know the target chain supports EIP-1559. - if !is_static { + if !call.is_static { if let Err(err) = data .journaled_state .load_account(h160_to_b160(broadcast.new_origin), data.db) @@ -742,7 +739,6 @@ impl Inspector for Cheatcodes { remaining_gas: Gas, status: InstructionResult, retdata: bytes::Bytes, - _: bool, ) -> (InstructionResult, Gas, bytes::Bytes) { if call.contract == h160_to_b160(CHEATCODE_ADDRESS) || call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) diff --git a/crates/evm/src/executor/inspector/chisel_state.rs b/crates/evm/src/executor/inspector/chisel_state.rs index cb7a2a6c17e75..958e33cb5cd9a 100644 --- a/crates/evm/src/executor/inspector/chisel_state.rs +++ b/crates/evm/src/executor/inspector/chisel_state.rs @@ -26,7 +26,6 @@ impl Inspector for ChiselState { &mut self, interp: &mut Interpreter, _: &mut revm::EVMData<'_, DB>, - _: bool, eval: InstructionResult, ) -> InstructionResult { // If we are at the final pc of the REPL contract execution, set the state. diff --git a/crates/evm/src/executor/inspector/coverage.rs b/crates/evm/src/executor/inspector/coverage.rs index b7af6f6609016..32a1f29839ad4 100644 --- a/crates/evm/src/executor/inspector/coverage.rs +++ b/crates/evm/src/executor/inspector/coverage.rs @@ -20,9 +20,8 @@ impl Inspector for CoverageCollector { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.bytecode.hash()); + let hash = b256_to_h256(interpreter.contract.bytecode.clone().unlock().hash_slow()); self.maps.entry(hash).or_insert_with(|| { HitMap::new(Bytes::copy_from_slice( interpreter.contract.bytecode.original_bytecode_slice(), @@ -37,9 +36,8 @@ impl Inspector for CoverageCollector { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.bytecode.hash()); + let hash = b256_to_h256(interpreter.contract.bytecode.clone().unlock().hash_slow()); self.maps.entry(hash).and_modify(|map| map.hit(interpreter.program_counter())); InstructionResult::Continue diff --git a/crates/evm/src/executor/inspector/debugger.rs b/crates/evm/src/executor/inspector/debugger.rs index e051ad73cf532..a21a0f3247a8c 100644 --- a/crates/evm/src/executor/inspector/debugger.rs +++ b/crates/evm/src/executor/inspector/debugger.rs @@ -55,7 +55,6 @@ impl Inspector for Debugger { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { let pc = interpreter.program_counter(); let op = interpreter.contract.bytecode.bytecode()[pc]; @@ -98,7 +97,6 @@ impl Inspector for Debugger { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { self.enter( data.journaled_state.depth() as usize, @@ -126,7 +124,6 @@ impl Inspector for Debugger { gas: Gas, status: InstructionResult, retdata: Bytes, - _: bool, ) -> (InstructionResult, Gas, Bytes) { self.exit(); diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/src/executor/inspector/fuzzer.rs index 17926e887f1d4..a7363614a01a2 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/src/executor/inspector/fuzzer.rs @@ -25,7 +25,6 @@ impl Inspector for Fuzzer { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { // We only collect `stack` and `memory` data before and after calls. if self.collect { @@ -40,7 +39,6 @@ impl Inspector for Fuzzer { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { // We don't want to override the very first call made to the test contract. if self.call_generator.is_some() && data.env.tx.caller != call.context.caller { @@ -62,7 +60,6 @@ impl Inspector for Fuzzer { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, - _: bool, ) -> (InstructionResult, Gas, Bytes) { if let Some(ref mut call_generator) = self.call_generator { call_generator.used = false; diff --git a/crates/evm/src/executor/inspector/logs.rs b/crates/evm/src/executor/inspector/logs.rs index c848e329c9f77..a4124d4695a62 100644 --- a/crates/evm/src/executor/inspector/logs.rs +++ b/crates/evm/src/executor/inspector/logs.rs @@ -57,7 +57,6 @@ impl Inspector for LogCollector { &mut self, _: &mut EVMData<'_, DB>, call: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { if call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) { let (status, reason) = self.hardhat_log(call.input.to_vec()); diff --git a/crates/evm/src/executor/inspector/printer.rs b/crates/evm/src/executor/inspector/printer.rs index 6b694f12f0eea..0f8d9127bf87b 100644 --- a/crates/evm/src/executor/inspector/printer.rs +++ b/crates/evm/src/executor/inspector/printer.rs @@ -12,12 +12,7 @@ pub struct TracePrinter; impl Inspector for TracePrinter { // get opcode by calling `interp.contract.opcode(interp.program_counter())`. // all other information can be obtained from interp. - fn step( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - _: bool, - ) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { let opcode = interp.current_opcode(); let opcode_str = opcode::OPCODE_JUMPMAP[opcode as usize]; let gas_remaining = interp.gas.remaining(); @@ -43,13 +38,12 @@ impl Inspector for TracePrinter { &mut self, _data: &mut EVMData<'_, DB>, inputs: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { println!( "SM CALL: {:?},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}", inputs.contract, inputs.context, - is_static, + inputs.is_static, inputs.transfer, inputs.input.len(), ); diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index 7c22a4d65d55f..d626fc3d4e33a 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -326,7 +326,6 @@ impl InspectorStack { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( [ @@ -339,14 +338,8 @@ impl InspectorStack { &mut self.printer ], |inspector| { - let (new_status, new_gas, new_retdata) = inspector.call_end( - data, - call, - remaining_gas, - status, - retdata.clone(), - is_static, - ); + let (new_status, new_gas, new_retdata) = + inspector.call_end(data, call, remaining_gas, status, retdata.clone()); // If the inspector returns a different status or a revert with a non-empty message, // we assume it wants to tell us something @@ -367,7 +360,6 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, ) -> InstructionResult { call_inspectors!( [ @@ -379,7 +371,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.initialize_interp(interpreter, data, is_static); + let status = inspector.initialize_interp(interpreter, data); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -395,7 +387,6 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, ) -> InstructionResult { call_inspectors!( [ @@ -408,7 +399,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.step(interpreter, data, is_static); + let status = inspector.step(interpreter, data); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -439,7 +430,6 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, status: InstructionResult, ) -> InstructionResult { call_inspectors!( @@ -452,7 +442,7 @@ impl Inspector for InspectorStack { &mut self.chisel_state ], |inspector| { - let status = inspector.step_end(interpreter, data, is_static, status); + let status = inspector.step_end(interpreter, data, status); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -468,7 +458,6 @@ impl Inspector for InspectorStack { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( [ @@ -481,7 +470,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let (status, gas, retdata) = inspector.call(data, call, is_static); + let (status, gas, retdata) = inspector.call(data, call); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -500,9 +489,8 @@ impl Inspector for InspectorStack { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { - let res = self.do_call_end(data, call, remaining_gas, status, retdata, is_static); + let res = self.do_call_end(data, call, remaining_gas, status, retdata); if matches!(res.0, return_revert!()) { // Encountered a revert, since cheatcodes may have altered the evm state in such a way diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index 5d5c80ba6b55c..c8851edf7ec75 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -150,12 +150,7 @@ impl Tracer { impl Inspector for Tracer { #[inline] - fn step( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - _is_static: bool, - ) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { if self.record_steps { self.start_step(interp, data); } @@ -167,7 +162,6 @@ impl Inspector for Tracer { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, status: InstructionResult, ) -> InstructionResult { if self.record_steps { @@ -189,7 +183,6 @@ impl Inspector for Tracer { &mut self, data: &mut EVMData<'_, DB>, inputs: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { let (from, to) = match inputs.context.scheme { CallScheme::DelegateCall | CallScheme::CallCode => { @@ -218,7 +211,6 @@ impl Inspector for Tracer { gas: Gas, status: InstructionResult, retdata: Bytes, - _: bool, ) -> (InstructionResult, Gas, Bytes) { self.fill_trace( status, diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/src/fuzz/strategies/state.rs index 2cad56de24988..ba62a0eb22564 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/src/fuzz/strategies/state.rs @@ -268,7 +268,7 @@ pub fn collect_created_contracts( for (address, account) in state_changeset { if !setup_contracts.contains_key(&b160_to_h160(*address)) { - if let (true, Some(code)) = (&account.is_touched, &account.info.code) { + if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { if !code.is_empty() { if let Some((artifact, (abi, _))) = project_contracts.find_by_code(code.bytes()) { From 369fb7282c1056f1833a872b1a4b60f677627b6f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:57:59 +0200 Subject: [PATCH 0021/1963] refactor: optimize trace identifiers (#5680) --- crates/chisel/src/dispatcher.rs | 14 +- crates/cli/src/utils/cmd.rs | 13 +- crates/evm/src/trace/decoder.rs | 74 +++--- crates/evm/src/trace/identifier/etherscan.rs | 10 +- crates/evm/src/trace/identifier/local.rs | 49 ++-- crates/evm/src/trace/identifier/mod.rs | 8 +- crates/evm/src/trace/mod.rs | 63 +++-- crates/evm/src/trace/utils.rs | 6 +- crates/forge/bin/cmd/script/mod.rs | 11 +- crates/forge/bin/cmd/test/mod.rs | 237 +++++++++---------- crates/forge/src/result.rs | 22 +- 11 files changed, 275 insertions(+), 232 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 1115514749b90..9aa4509f7884f 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -958,13 +958,13 @@ impl ChiselDispatcher { session_config.evm_opts.get_remote_chain_id(), )?; - let mut decoder = - CallTraceDecoderBuilder::new().with_labels(result.labeled_addresses.clone()).build(); - - decoder.add_signature_identifier(SignaturesIdentifier::new( - Config::foundry_cache_dir(), - session_config.foundry_config.offline, - )?); + let mut decoder = CallTraceDecoderBuilder::new() + .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) + .with_signature_identifier(SignaturesIdentifier::new( + Config::foundry_cache_dir(), + session_config.foundry_config.offline, + )?) + .build(); for (_, trace) in &mut result.traces { // decoder.identify(trace, &mut local_identifier); diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index e41790a27fcf9..4323ddb2c6463 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -378,12 +378,13 @@ pub async fn handle_traces( None }); - let mut decoder = CallTraceDecoderBuilder::new().with_labels(labeled_addresses).build(); - - decoder.add_signature_identifier(SignaturesIdentifier::new( - Config::foundry_cache_dir(), - config.offline, - )?); + let mut decoder = CallTraceDecoderBuilder::new() + .with_labels(labeled_addresses) + .with_signature_identifier(SignaturesIdentifier::new( + Config::foundry_cache_dir(), + config.offline, + )?) + .build(); for (_, trace) in &mut result.traces { decoder.identify(trace, &mut etherscan_identifier); diff --git a/crates/evm/src/trace/decoder.rs b/crates/evm/src/trace/decoder.rs index c2a51c6dad77b..39c00e38a4d69 100644 --- a/crates/evm/src/trace/decoder.rs +++ b/crates/evm/src/trace/decoder.rs @@ -1,5 +1,5 @@ use super::{ - identifier::{SingleSignaturesIdentifier, TraceIdentifier}, + identifier::{AddressIdentity, SingleSignaturesIdentifier, TraceIdentifier}, CallTraceArena, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, }; use crate::{ @@ -20,22 +20,27 @@ use std::collections::{BTreeMap, HashMap}; /// Build a new [CallTraceDecoder]. #[derive(Default)] +#[must_use = "builders do nothing unless you call `build` on them"] pub struct CallTraceDecoderBuilder { decoder: CallTraceDecoder, } impl CallTraceDecoderBuilder { + /// Create a new builder. + #[inline] pub fn new() -> Self { Self { decoder: CallTraceDecoder::new().clone() } } /// Add known labels to the decoder. + #[inline] pub fn with_labels(mut self, labels: impl IntoIterator) -> Self { self.decoder.labels.extend(labels); self } /// Add known events to the decoder. + #[inline] pub fn with_events(mut self, events: impl IntoIterator) -> Self { for event in events { self.decoder @@ -48,12 +53,21 @@ impl CallTraceDecoderBuilder { } /// Sets the verbosity level of the decoder. + #[inline] pub fn with_verbosity(mut self, level: u8) -> Self { self.decoder.verbosity = level; self } + /// Sets the signature identifier for events and functions. + #[inline] + pub fn with_signature_identifier(mut self, identifier: SingleSignaturesIdentifier) -> Self { + self.decoder.signature_identifier = Some(identifier); + self + } + /// Build the decoder. + #[inline] pub fn build(self) -> CallTraceDecoder { self.decoder } @@ -168,23 +182,26 @@ impl CallTraceDecoder { } } - pub fn add_signature_identifier(&mut self, identifier: SingleSignaturesIdentifier) { - self.signature_identifier = Some(identifier); - } - /// Identify unknown addresses in the specified call trace using the specified identifier. /// /// Unknown contracts are contracts that either lack a label or an ABI. + #[inline] pub fn identify(&mut self, trace: &CallTraceArena, identifier: &mut impl TraceIdentifier) { - let unidentified_addresses = trace - .addresses() - .into_iter() - .filter(|(address, _)| { - !self.labels.contains_key(address) || !self.contracts.contains_key(address) - }) - .collect(); - - identifier.identify_addresses(unidentified_addresses).iter().for_each(|identity| { + self.collect_identities(identifier.identify_addresses(self.addresses(trace))); + } + + #[inline(always)] + fn addresses<'a>( + &'a self, + trace: &'a CallTraceArena, + ) -> impl Iterator)> + 'a { + trace.addresses().into_iter().filter(|&(address, _)| { + !self.labels.contains_key(address) || !self.contracts.contains_key(address) + }) + } + + fn collect_identities(&mut self, identities: Vec) { + for identity in identities { let address = identity.address; if let Some(contract) = &identity.contract { @@ -197,30 +214,31 @@ impl CallTraceDecoder { if let Some(abi) = &identity.abi { // Store known functions for the address - abi.functions() - .map(|func| (func.short_signature(), func.clone())) - .for_each(|(sig, func)| self.functions.entry(sig).or_default().push(func)); + for function in abi.functions() { + self.functions + .entry(function.short_signature()) + .or_default() + .push(function.clone()) + } // Flatten events from all ABIs - abi.events() - .map(|event| ((event.signature(), indexed_inputs(event)), event.clone())) - .for_each(|(sig, event)| { - self.events.entry(sig).or_default().push(event); - }); + for event in abi.events() { + let sig = (event.signature(), indexed_inputs(event)); + self.events.entry(sig).or_default().push(event.clone()); + } // Flatten errors from all ABIs - abi.errors().for_each(|error| { - let entry = self.errors.errors.entry(error.name.clone()).or_default(); - entry.push(error.clone()); - }); + for error in abi.errors() { + self.errors.errors.entry(error.name.clone()).or_default().push(error.clone()); + } self.receive_contracts.entry(address).or_insert(abi.receive); } - }); + } } pub async fn decode(&self, traces: &mut CallTraceArena) { - for node in traces.arena.iter_mut() { + for node in &mut traces.arena { // Set contract name if let Some(contract) = self.contracts.get(&node.trace.address).cloned() { node.trace.contract = Some(contract); diff --git a/crates/evm/src/trace/identifier/etherscan.rs b/crates/evm/src/trace/identifier/etherscan.rs index e13570aa2448a..b9bdf43feb100 100644 --- a/crates/evm/src/trace/identifier/etherscan.rs +++ b/crates/evm/src/trace/identifier/etherscan.rs @@ -100,11 +100,11 @@ impl EtherscanIdentifier { } impl TraceIdentifier for EtherscanIdentifier { - fn identify_addresses( - &mut self, - addresses: Vec<(&Address, Option<&[u8]>)>, - ) -> Vec { - trace!(target: "etherscanidentifier", "identify {} addresses", addresses.len()); + fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec + where + A: Iterator)>, + { + trace!(target: "etherscanidentifier", "identify {:?} addresses", addresses.size_hint().1); let Some(client) = self.client.clone() else { // no client was configured diff --git a/crates/evm/src/trace/identifier/local.rs b/crates/evm/src/trace/identifier/local.rs index 9f07720ab1453..ec8fb0f668ca7 100644 --- a/crates/evm/src/trace/identifier/local.rs +++ b/crates/evm/src/trace/identifier/local.rs @@ -1,56 +1,45 @@ use super::{AddressIdentity, TraceIdentifier}; -use ethers::{ - abi::{Abi, Address, Event}, - prelude::ArtifactId, -}; +use ethers::abi::{Address, Event}; use foundry_common::contracts::{diff_score, ContractsByArtifact}; -use itertools::Itertools; use ordered_float::OrderedFloat; -use std::{borrow::Cow, collections::BTreeMap}; +use std::borrow::Cow; /// A trace identifier that tries to identify addresses using local contracts. -pub struct LocalTraceIdentifier { - local_contracts: BTreeMap, (ArtifactId, Abi)>, +pub struct LocalTraceIdentifier<'a> { + known_contracts: &'a ContractsByArtifact, } -impl LocalTraceIdentifier { - pub fn new(known_contracts: &ContractsByArtifact) -> Self { - Self { - local_contracts: known_contracts - .iter() - .map(|(id, (abi, runtime_code))| (runtime_code.clone(), (id.clone(), abi.clone()))) - .collect(), - } +impl<'a> LocalTraceIdentifier<'a> { + pub fn new(known_contracts: &'a ContractsByArtifact) -> Self { + Self { known_contracts } } /// Get all the events of the local contracts. pub fn events(&self) -> impl Iterator { - self.local_contracts.iter().flat_map(|(_, (_, abi))| abi.events()) + self.known_contracts.iter().flat_map(|(_, (abi, _))| abi.events()) } } -impl TraceIdentifier for LocalTraceIdentifier { - fn identify_addresses( - &mut self, - addresses: Vec<(&Address, Option<&[u8]>)>, - ) -> Vec { +impl TraceIdentifier for LocalTraceIdentifier<'_> { + fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec + where + A: Iterator)>, + { addresses - .into_iter() .filter_map(|(address, code)| { let code = code?; - let (_, (_, (id, abi))) = self - .local_contracts + let (_, id, abi) = self + .known_contracts .iter() - .filter_map(|entry| { - let score = diff_score(entry.0, code); + .filter_map(|(id, (abi, known_code))| { + let score = diff_score(known_code, code); if score < 0.1 { - Some((OrderedFloat(score), entry)) + Some((OrderedFloat(score), id, abi)) } else { None } }) - .sorted_by_key(|(score, _)| *score) - .next()?; + .min_by_key(|(score, _, _)| *score)?; Some(AddressIdentity { address: *address, diff --git a/crates/evm/src/trace/identifier/mod.rs b/crates/evm/src/trace/identifier/mod.rs index 6fca5d10a274e..dd755ee9082df 100644 --- a/crates/evm/src/trace/identifier/mod.rs +++ b/crates/evm/src/trace/identifier/mod.rs @@ -33,9 +33,7 @@ pub struct AddressIdentity<'a> { pub trait TraceIdentifier { // TODO: Update docs /// Attempts to identify an address in one or more call traces. - #[allow(clippy::type_complexity)] - fn identify_addresses( - &mut self, - addresses: Vec<(&Address, Option<&[u8]>)>, - ) -> Vec; + fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec + where + A: Iterator)>; } diff --git a/crates/evm/src/trace/mod.rs b/crates/evm/src/trace/mod.rs index 23b5d1fa47a69..af490b6448c8d 100644 --- a/crates/evm/src/trace/mod.rs +++ b/crates/evm/src/trace/mod.rs @@ -561,13 +561,39 @@ impl fmt::Display for CallTrace { } /// Specifies the kind of trace. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TraceKind { Deployment, Setup, Execution, } +impl TraceKind { + /// Returns `true` if the trace kind is [`Deployment`]. + /// + /// [`Deployment`]: TraceKind::Deployment + #[must_use] + pub fn is_deployment(self) -> bool { + matches!(self, Self::Deployment) + } + + /// Returns `true` if the trace kind is [`Setup`]. + /// + /// [`Setup`]: TraceKind::Setup + #[must_use] + pub fn is_setup(self) -> bool { + matches!(self, Self::Setup) + } + + /// Returns `true` if the trace kind is [`Execution`]. + /// + /// [`Execution`]: TraceKind::Execution + #[must_use] + pub fn is_execution(self) -> bool { + matches!(self, Self::Execution) + } +} + /// Chooses the color of the trace depending on the destination address and status of the call. fn trace_color(trace: &CallTrace) -> Color { if trace.address == CHEATCODE_ADDRESS { @@ -584,26 +610,23 @@ pub fn load_contracts( traces: Traces, known_contracts: Option<&ContractsByArtifact>, ) -> ContractsByAddress { - if let Some(contracts) = known_contracts { - let mut local_identifier = LocalTraceIdentifier::new(contracts); - let mut decoder = CallTraceDecoderBuilder::new().build(); - for (_, trace) in &traces { - decoder.identify(trace, &mut local_identifier); - } - - decoder - .contracts - .iter() - .filter_map(|(addr, name)| { - if let Ok(Some((_, (abi, _)))) = contracts.find_by_name_or_identifier(name) { - return Some((*addr, (name.clone(), abi.clone()))) - } - None - }) - .collect() - } else { - BTreeMap::new() + let Some(contracts) = known_contracts else { return BTreeMap::new() }; + let mut local_identifier = LocalTraceIdentifier::new(contracts); + let mut decoder = CallTraceDecoderBuilder::new().build(); + for (_, trace) in &traces { + decoder.identify(trace, &mut local_identifier); } + + decoder + .contracts + .iter() + .filter_map(|(addr, name)| { + if let Ok(Some((_, (abi, _)))) = contracts.find_by_name_or_identifier(name) { + return Some((*addr, (name.clone(), abi.clone()))) + } + None + }) + .collect() } /// creates the memory data in 32byte chunks diff --git a/crates/evm/src/trace/utils.rs b/crates/evm/src/trace/utils.rs index e65d6c30346ec..14d4f245d2f33 100644 --- a/crates/evm/src/trace/utils.rs +++ b/crates/evm/src/trace/utils.rs @@ -79,7 +79,7 @@ pub(crate) fn decode_cheatcode_inputs( "serializeBytes32" | "serializeString" | "serializeBytes" => { - if verbosity == 5 { + if verbosity >= 5 { None } else { let mut decoded = func.decode_input(&data[SELECTOR_LEN..]).ok()?; @@ -111,10 +111,10 @@ pub(crate) fn decode_cheatcode_outputs( // redacts derived private key return Some("".to_string()) } - if func.name == "parseJson" && verbosity != 5 { + if func.name == "parseJson" && verbosity < 5 { return Some("".to_string()) } - if func.name == "readFile" && verbosity != 5 { + if func.name == "readFile" && verbosity < 5 { return Some("".to_string()) } None diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 1825644c31295..4e10066332f3c 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -237,15 +237,14 @@ impl ScriptArgs { let mut local_identifier = LocalTraceIdentifier::new(known_contracts); let mut decoder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.clone()) + .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) .with_verbosity(verbosity) + .with_signature_identifier(SignaturesIdentifier::new( + Config::foundry_cache_dir(), + script_config.config.offline, + )?) .build(); - decoder.add_signature_identifier(SignaturesIdentifier::new( - Config::foundry_cache_dir(), - script_config.config.offline, - )?); - // Decoding traces using etherscan is costly as we run into rate limits, // causing scripts to run for a very long time unnecesarily. // Therefore, we only try and use etherscan if the user has provided an API key. diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index e5a0b560acbe8..3771eec91762a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -537,151 +537,146 @@ async fn test( if json { let results = runner.test(filter, None, test_options).await; println!("{}", serde_json::to_string(&results)?); - Ok(TestOutcome::new(results, allow_failure)) - } else { - // Set up identifiers - let mut local_identifier = LocalTraceIdentifier::new(&runner.known_contracts); - let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - // Do not re-query etherscan for contracts that you've already queried today. - let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; + return Ok(TestOutcome::new(results, allow_failure)) + } - // Set up test reporter channel - let (tx, rx) = channel::<(String, SuiteResult)>(); + // Set up identifiers + let known_contracts = runner.known_contracts.clone(); + let mut local_identifier = LocalTraceIdentifier::new(&known_contracts); + let remote_chain_id = runner.evm_opts.get_remote_chain_id(); + // Do not re-query etherscan for contracts that you've already queried today. + let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; - // Run tests - let handle = - tokio::task::spawn(async move { runner.test(filter, Some(tx), test_options).await }); + // Set up test reporter channel + let (tx, rx) = channel::<(String, SuiteResult)>(); - let mut results: BTreeMap = BTreeMap::new(); - let mut gas_report = GasReport::new(config.gas_reports, config.gas_reports_ignore); - let sig_identifier = - SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; + // Run tests + let handle = + tokio::task::spawn(async move { runner.test(filter, Some(tx), test_options).await }); - let mut total_passed = 0; - let mut total_failed = 0; - let mut total_skipped = 0; + let mut results: BTreeMap = BTreeMap::new(); + let mut gas_report = GasReport::new(config.gas_reports, config.gas_reports_ignore); + let sig_identifier = SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; - 'outer: for (contract_name, suite_result) in rx { - results.insert(contract_name.clone(), suite_result.clone()); + let mut total_passed = 0; + let mut total_failed = 0; + let mut total_skipped = 0; - let mut tests = suite_result.test_results.clone(); - println!(); - for warning in suite_result.warnings.iter() { - eprintln!("{} {warning}", Paint::yellow("Warning:").bold()); - } - if !tests.is_empty() { - let term = if tests.len() > 1 { "tests" } else { "test" }; - println!("Running {} {term} for {contract_name}", tests.len()); - } - for (name, result) in &mut tests { - short_test_result(name, result); + 'outer: for (contract_name, suite_result) in rx { + results.insert(contract_name.clone(), suite_result.clone()); - // If the test failed, we want to stop processing the rest of the tests - if fail_fast && result.status == TestStatus::Failure { - break 'outer - } + let mut tests = suite_result.test_results.clone(); + println!(); + for warning in suite_result.warnings.iter() { + eprintln!("{} {warning}", Paint::yellow("Warning:").bold()); + } + if !tests.is_empty() { + let term = if tests.len() > 1 { "tests" } else { "test" }; + println!("Running {} {term} for {contract_name}", tests.len()); + } + for (name, result) in &mut tests { + short_test_result(name, result); - // We only display logs at level 2 and above - if verbosity >= 2 { - // We only decode logs from Hardhat and DS-style console events - let console_logs = decode_console_logs(&result.logs); - if !console_logs.is_empty() { - println!("Logs:"); - for log in console_logs { - println!(" {log}"); - } - println!(); + // If the test failed, we want to stop processing the rest of the tests + if fail_fast && result.status == TestStatus::Failure { + break 'outer + } + + // We only display logs at level 2 and above + if verbosity >= 2 { + // We only decode logs from Hardhat and DS-style console events + let console_logs = decode_console_logs(&result.logs); + if !console_logs.is_empty() { + println!("Logs:"); + for log in console_logs { + println!(" {log}"); } + println!(); } + } - if !result.traces.is_empty() { - // Identify addresses in each trace - let mut decoder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.clone()) - .with_events(local_identifier.events().cloned()) - .with_verbosity(verbosity) - .build(); - - // Signatures are of no value for gas reports - if !gas_reporting { - decoder.add_signature_identifier(sig_identifier.clone()); - } + if result.traces.is_empty() { + continue + } - // Decode the traces - let mut decoded_traces = Vec::new(); - for (kind, trace) in &mut result.traces { - decoder.identify(trace, &mut local_identifier); - decoder.identify(trace, &mut etherscan_identifier); - - let should_include = match kind { - // At verbosity level 3, we only display traces for failed tests - // At verbosity level 4, we also display the setup trace for failed - // tests At verbosity level 5, we display - // all traces for all tests - TraceKind::Setup => { - (verbosity >= 5) || - (verbosity == 4 && result.status == TestStatus::Failure) - } - TraceKind::Execution => { - verbosity > 3 || - (verbosity == 3 && result.status == TestStatus::Failure) - } - _ => false, - }; - - // We decode the trace if we either need to build a gas report or we need - // to print it - if should_include || gas_reporting { - decoder.decode(trace).await; - } - - if should_include { - decoded_traces.push(trace.to_string()); - } - } + // Identify addresses in each trace + let mut builder = CallTraceDecoderBuilder::new() + .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) + .with_events(local_identifier.events().cloned()) + .with_verbosity(verbosity); - if !decoded_traces.is_empty() { - println!("Traces:"); - decoded_traces.into_iter().for_each(|trace| println!("{trace}")); - } + // Signatures are of no value for gas reports + if !gas_reporting { + builder = builder.with_signature_identifier(sig_identifier.clone()); + } - if gas_reporting { - gas_report.analyze(&result.traces); + let mut decoder = builder.build(); + + // Decode the traces + let mut decoded_traces = Vec::with_capacity(result.traces.len()); + for (kind, trace) in &mut result.traces { + decoder.identify(trace, &mut local_identifier); + decoder.identify(trace, &mut etherscan_identifier); + + // verbosity: + // - 0..3: nothing + // - 3: only display traces for failed tests + // - 4: also display the setup trace for failed tests + // - 5..: display all traces for all tests + let should_include = match kind { + TraceKind::Execution => { + (verbosity == 3 && result.status.is_failure()) || verbosity >= 4 + } + TraceKind::Setup => { + (verbosity == 4 && result.status.is_failure()) || verbosity >= 5 } + TraceKind::Deployment => false, + }; + + // Decode the trace if we either need to build a gas report or we need to print it + if should_include || gas_reporting { + decoder.decode(trace).await; + } + + if should_include { + decoded_traces.push(trace.to_string()); } } - let block_outcome = - TestOutcome::new([(contract_name, suite_result)].into(), allow_failure); - total_passed += block_outcome.successes().count(); - total_failed += block_outcome.failures().count(); - total_skipped += block_outcome.skips().count(); + if !decoded_traces.is_empty() { + println!("Traces:"); + decoded_traces.into_iter().for_each(|trace| println!("{trace}")); + } - println!("{}", block_outcome.summary()); + if gas_reporting { + gas_report.analyze(&result.traces); + } } + let block_outcome = TestOutcome::new([(contract_name, suite_result)].into(), allow_failure); - if gas_reporting { - println!("{}", gas_report.finalize()); - } + total_passed += block_outcome.successes().count(); + total_failed += block_outcome.failures().count(); + total_skipped += block_outcome.skips().count(); - let num_test_suites = results.len(); + println!("{}", block_outcome.summary()); + } - if num_test_suites > 0 { - println!( - "{}", - format_aggregated_summary( - num_test_suites, - total_passed, - total_failed, - total_skipped - ) - ); - } + if gas_reporting { + println!("{}", gas_report.finalize()); + } - // reattach the thread - let _results = handle.await?; + let num_test_suites = results.len(); - trace!(target: "forge::test", "received {} results", results.len()); - Ok(TestOutcome::new(results, allow_failure)) + if num_test_suites > 0 { + println!( + "{}", + format_aggregated_summary(num_test_suites, total_passed, total_failed, total_skipped) + ); } + + // reattach the thread + let _results = handle.await?; + + trace!(target: "forge::test", "received {} results", results.len()); + Ok(TestOutcome::new(results, allow_failure)) } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 1199a4d28f55a..c6363e0695ce2 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -58,7 +58,7 @@ impl SuiteResult { } } -#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub enum TestStatus { Success, #[default] @@ -66,6 +66,26 @@ pub enum TestStatus { Skipped, } +impl TestStatus { + /// Returns `true` if the test was successful. + #[inline] + pub fn is_success(self) -> bool { + matches!(self, Self::Success) + } + + /// Returns `true` if the test failed. + #[inline] + pub fn is_failure(self) -> bool { + matches!(self, Self::Failure) + } + + /// Returns `true` if the test was skipped. + #[inline] + pub fn is_skipped(self) -> bool { + matches!(self, Self::Skipped) + } +} + /// The result of an executed solidity test #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct TestResult { From 1b2a239ccda2df81e88bcfaabfea61802f384b28 Mon Sep 17 00:00:00 2001 From: puma314 Date: Mon, 21 Aug 2023 08:12:58 -0700 Subject: [PATCH 0022/1963] feat: `getLogs` cheatcode (#5297) * Initial implementation * More comprehensive test * Added TODOs * Test passes * Cleaning up PR * Tests pass * Cleaned up get_logs, starting to work on rpc * eth get logs should be done. still working on rpc * RPC test works with get_balance * Formatting * Removed pub * Minor solidity fixes * Remake public * Cheats -> vm * chore: docs * chore: docs * chore: clippy * fmt * chore: fix path * chore: enable permissions * enable permissions --------- Co-authored-by: Enrique Ortiz --- crates/abi/abi/HEVM.sol | 4 + crates/abi/src/bindings/hevm.rs | 249 ++++++++++++++++++ .../src/executor/inspector/cheatcodes/ext.rs | 2 +- .../src/executor/inspector/cheatcodes/fork.rs | 119 ++++++++- crates/forge/tests/it/fork.rs | 30 ++- testdata/cheats/Fork2.t.sol | 62 +++++ testdata/cheats/Vm.sol | 19 ++ testdata/fixtures/Rpc/README.md | 25 ++ testdata/fixtures/Rpc/balance_params.json | 1 + testdata/fixtures/Rpc/eth_getLogs.json | 44 ++++ 10 files changed, 549 insertions(+), 6 deletions(-) create mode 100644 testdata/fixtures/Rpc/README.md create mode 100644 testdata/fixtures/Rpc/balance_params.json create mode 100644 testdata/fixtures/Rpc/eth_getLogs.json diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index ec9f1eff31d3f..355eef58024ac 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -1,5 +1,6 @@ struct Log { bytes32[] topics; bytes data; } struct Rpc { string name; string url; } +struct EthGetLogs { address emitter; bytes32[] topics; bytes data; uint256 blockNumber; bytes32 transactionHash; uint256 transactionIndex; bytes32 blockHash; 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; } @@ -185,6 +186,9 @@ rollFork(uint256,bytes32) rpcUrl(string)(string) rpcUrls()(string[2][]) rpcUrlStructs()(Rpc[]) +eth_getLogs(uint256,uint256,address,bytes32[])(EthGetLogs[]) +rpc(string,string)(bytes) + writeJson(string, string) writeJson(string, string, string) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index 62b2a4467491b..74e896643d4d1 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -1539,6 +1539,69 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("eth_getLogs"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("eth_getLogs"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + internal_type: ::core::option::Option::None, + }, + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + internal_type: ::core::option::Option::None, + }, + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::None, + }, + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), + ), + ), + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers_core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers_core::abi::ethabi::ParamType::Address, + ::ethers_core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), + ), + ), + ::ethers_core::abi::ethabi::ParamType::Bytes, + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::Bool, + ], + ), + ), + ), + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("expectCall"), ::std::vec![ @@ -3810,6 +3873,35 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("rpc"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("rpc"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Bytes, + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("rpcUrl"), ::std::vec![ @@ -5755,6 +5847,33 @@ pub mod hevm { .method_hash([180, 214, 199, 130], (p0, p1)) .expect("method not found (this should never happen)") } + ///Calls the contract's `eth_getLogs` (0x35e1349b) function + pub fn eth_get_logs( + &self, + p0: ::ethers_core::types::U256, + p1: ::ethers_core::types::U256, + p2: ::ethers_core::types::Address, + p3: ::std::vec::Vec<[u8; 32]>, + ) -> ::ethers_contract::builders::ContractCall< + M, + ::std::vec::Vec< + ( + ::ethers_core::types::Address, + ::std::vec::Vec<[u8; 32]>, + ::ethers_core::types::Bytes, + ::ethers_core::types::U256, + [u8; 32], + ::ethers_core::types::U256, + [u8; 32], + ::ethers_core::types::U256, + bool, + ), + >, + > { + self.0 + .method_hash([53, 225, 52, 155], (p0, p1, p2, p3)) + .expect("method not found (this should never happen)") + } ///Calls the contract's `expectCall` (0xbd6af434) function pub fn expect_call_0( &self, @@ -6714,6 +6833,16 @@ pub mod hevm { .method_hash([242, 131, 15, 123], (p0, p1)) .expect("method not found (this should never happen)") } + ///Calls the contract's `rpc` (0x1206c8a8) function + pub fn rpc( + &self, + p0: ::std::string::String, + p1: ::std::string::String, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([18, 6, 200, 168], (p0, p1)) + .expect("method not found (this should never happen)") + } ///Calls the contract's `rpcUrl` (0x975a6ce9) function pub fn rpc_url( &self, @@ -8067,6 +8196,27 @@ pub mod hevm { pub ::ethers_core::types::Address, pub ::ethers_core::types::Bytes, ); + ///Container type for all input parameters for the `eth_getLogs` function with signature `eth_getLogs(uint256,uint256,address,bytes32[])` and selector `0x35e1349b` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall( + name = "eth_getLogs", + abi = "eth_getLogs(uint256,uint256,address,bytes32[])" + )] + pub struct EthGetLogsCall( + pub ::ethers_core::types::U256, + pub ::ethers_core::types::U256, + pub ::ethers_core::types::Address, + pub ::std::vec::Vec<[u8; 32]>, + ); ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,bytes)` and selector `0xbd6af434` #[derive( Clone, @@ -9415,6 +9565,19 @@ pub mod hevm { )] #[ethcall(name = "rollFork", abi = "rollFork(uint256,bytes32)")] pub struct RollFork3Call(pub ::ethers_core::types::U256, pub [u8; 32]); + ///Container type for all input parameters for the `rpc` function with signature `rpc(string,string)` and selector `0x1206c8a8` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "rpc", abi = "rpc(string,string)")] + pub struct RpcCall(pub ::std::string::String, pub ::std::string::String); ///Container type for all input parameters for the `rpcUrl` function with signature `rpcUrl(string)` and selector `0x975a6ce9` #[derive( Clone, @@ -10232,6 +10395,7 @@ pub mod hevm { EnvUint0(EnvUint0Call), EnvUint1(EnvUint1Call), Etch(EtchCall), + EthGetLogs(EthGetLogsCall), ExpectCall0(ExpectCall0Call), ExpectCall1(ExpectCall1Call), ExpectCall2(ExpectCall2Call), @@ -10325,6 +10489,7 @@ pub mod hevm { RollFork1(RollFork1Call), RollFork2(RollFork2Call), RollFork3(RollFork3Call), + Rpc(RpcCall), RpcUrl(RpcUrlCall), RpcUrlStructs(RpcUrlStructsCall), RpcUrls(RpcUrlsCall), @@ -10629,6 +10794,10 @@ pub mod hevm { = ::decode(data) { return Ok(Self::Etch(decoded)); } + if let Ok(decoded) + = ::decode(data) { + return Ok(Self::EthGetLogs(decoded)); + } if let Ok(decoded) = ::decode(data) { return Ok(Self::ExpectCall0(decoded)); @@ -11029,6 +11198,10 @@ pub mod hevm { = ::decode(data) { return Ok(Self::RollFork3(decoded)); } + if let Ok(decoded) + = ::decode(data) { + return Ok(Self::Rpc(decoded)); + } if let Ok(decoded) = ::decode(data) { return Ok(Self::RpcUrl(decoded)); @@ -11379,6 +11552,9 @@ pub mod hevm { Self::EnvUint0(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::EnvUint1(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::Etch(element) => ::ethers_core::abi::AbiEncode::encode(element), + Self::EthGetLogs(element) => { + ::ethers_core::abi::AbiEncode::encode(element) + } Self::ExpectCall0(element) => { ::ethers_core::abi::AbiEncode::encode(element) } @@ -11620,6 +11796,7 @@ pub mod hevm { Self::RollFork3(element) => { ::ethers_core::abi::AbiEncode::encode(element) } + Self::Rpc(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::RpcUrl(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::RpcUrlStructs(element) => { ::ethers_core::abi::AbiEncode::encode(element) @@ -11818,6 +11995,7 @@ pub mod hevm { Self::EnvUint0(element) => ::core::fmt::Display::fmt(element, f), Self::EnvUint1(element) => ::core::fmt::Display::fmt(element, f), Self::Etch(element) => ::core::fmt::Display::fmt(element, f), + Self::EthGetLogs(element) => ::core::fmt::Display::fmt(element, f), Self::ExpectCall0(element) => ::core::fmt::Display::fmt(element, f), Self::ExpectCall1(element) => ::core::fmt::Display::fmt(element, f), Self::ExpectCall2(element) => ::core::fmt::Display::fmt(element, f), @@ -11927,6 +12105,7 @@ pub mod hevm { Self::RollFork1(element) => ::core::fmt::Display::fmt(element, f), Self::RollFork2(element) => ::core::fmt::Display::fmt(element, f), Self::RollFork3(element) => ::core::fmt::Display::fmt(element, f), + Self::Rpc(element) => ::core::fmt::Display::fmt(element, f), Self::RpcUrl(element) => ::core::fmt::Display::fmt(element, f), Self::RpcUrlStructs(element) => ::core::fmt::Display::fmt(element, f), Self::RpcUrls(element) => ::core::fmt::Display::fmt(element, f), @@ -12286,6 +12465,11 @@ pub mod hevm { Self::Etch(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: EthGetLogsCall) -> Self { + Self::EthGetLogs(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: ExpectCall0Call) -> Self { Self::ExpectCall0(value) @@ -12751,6 +12935,11 @@ pub mod hevm { Self::RollFork3(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: RpcCall) -> Self { + Self::Rpc(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: RpcUrlCall) -> Self { Self::RpcUrl(value) @@ -13563,6 +13752,32 @@ pub mod hevm { Hash )] pub struct EnvUint1Return(pub ::std::vec::Vec<::ethers_core::types::U256>); + ///Container type for all return fields from the `eth_getLogs` function with signature `eth_getLogs(uint256,uint256,address,bytes32[])` and selector `0x35e1349b` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct EthGetLogsReturn( + pub ::std::vec::Vec< + ( + ::ethers_core::types::Address, + ::std::vec::Vec<[u8; 32]>, + ::ethers_core::types::Bytes, + ::ethers_core::types::U256, + [u8; 32], + ::ethers_core::types::U256, + [u8; 32], + ::ethers_core::types::U256, + bool, + ), + >, + ); ///Container type for all return fields from the `ffi` function with signature `ffi(string[])` and selector `0x89160467` #[derive( Clone, @@ -14099,6 +14314,18 @@ pub mod hevm { Hash )] pub struct RevertToReturn(pub bool); + ///Container type for all return fields from the `rpc` function with signature `rpc(string,string)` and selector `0x1206c8a8` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct RpcReturn(pub ::ethers_core::types::Bytes); ///Container type for all return fields from the `rpcUrl` function with signature `rpcUrl(string)` and selector `0x975a6ce9` #[derive( Clone, @@ -14373,6 +14600,28 @@ pub mod hevm { pub is_dir: bool, pub is_symlink: bool, } + ///`EthGetLogs(address,bytes32[],bytes,uint256,bytes32,uint256,bytes32,uint256,bool)` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct EthGetLogs { + pub emitter: ::ethers_core::types::Address, + pub topics: ::std::vec::Vec<[u8; 32]>, + pub data: ::ethers_core::types::Bytes, + pub block_number: ::ethers_core::types::U256, + pub transaction_hash: [u8; 32], + pub transaction_index: ::ethers_core::types::U256, + pub block_hash: [u8; 32], + pub log_index: ::ethers_core::types::U256, + pub removed: bool, + } ///`FfiResult(int32,bytes,bytes)` #[derive( Clone, diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index a138e422e2d9d..1fb57a4f6afd8 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -202,7 +202,7 @@ fn get_env(key: &str, ty: ParamType, delim: Option<&str>, default: Option Result { +pub fn value_to_token(value: &Value) -> Result { match value { Value::Null => Ok(Token::FixedBytes(vec![0; 32])), Value::Bool(boolean) => Ok(Token::Bool(*boolean)), diff --git a/crates/evm/src/executor/inspector/cheatcodes/fork.rs b/crates/evm/src/executor/inspector/cheatcodes/fork.rs index 8734071108395..234daeb053322 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fork.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fork.rs @@ -1,14 +1,21 @@ use super::{fmt_err, Cheatcodes, Error, Result}; use crate::{ abi::HEVMCalls, - executor::{backend::DatabaseExt, fork::CreateFork}, + executor::{ + backend::DatabaseExt, fork::CreateFork, inspector::cheatcodes::ext::value_to_token, + }, + utils::{b160_to_h160, RuntimeOrHandle}, }; use ethers::{ - abi::AbiEncode, + abi::{self, AbiEncode, Token, Tokenizable, Tokenize}, prelude::U256, - types::{Bytes, H256}, + providers::Middleware, + types::{Bytes, Filter, H256}, }; +use foundry_abi::hevm::{EthGetLogsCall, RpcCall}; +use foundry_common::ProviderBuilder; use revm::EVMData; +use serde_json::Value; fn empty(_: T) -> Bytes { Bytes::new() @@ -140,6 +147,8 @@ pub fn apply( ) .map(empty) .map_err(Into::into), + HEVMCalls::EthGetLogs(inner) => eth_getlogs(data, inner), + HEVMCalls::Rpc(inner) => rpc(data, inner), _ => return None, }; Some(result) @@ -246,3 +255,107 @@ fn create_fork_request( }; Ok(fork) } + +/// Retrieve the logs specified for the current fork. +/// Equivalent to eth_getLogs but on a cheatcode. +fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> Result { + let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; + if inner.0 > U256::from(u64::MAX) || inner.1 > U256::from(u64::MAX) { + return Err(fmt_err!("Blocks in block range must be less than 2^64 - 1")) + } + // Cannot possibly have more than 4 topics in the topics array. + if inner.3.len() > 4 { + return Err(fmt_err!("Topics array must be less than 4 elements")) + } + + let provider = ProviderBuilder::new(url).build()?; + let mut filter = Filter::new() + .address(b160_to_h160(inner.2.into())) + .from_block(inner.0.as_u64()) + .to_block(inner.1.as_u64()); + for (i, item) in inner.3.iter().enumerate() { + match i { + 0 => filter = filter.topic0(U256::from(item)), + 1 => filter = filter.topic1(U256::from(item)), + 2 => filter = filter.topic2(U256::from(item)), + 3 => filter = filter.topic3(U256::from(item)), + _ => return Err(fmt_err!("Topics array should be less than 4 elements")), + }; + } + + let logs = RuntimeOrHandle::new() + .block_on(provider.get_logs(&filter)) + .map_err(|_| fmt_err!("Error in calling eth_getLogs"))?; + + if logs.is_empty() { + let empty: Bytes = abi::encode(&[Token::Array(vec![])]).into(); + return Ok(empty) + } + + let result = abi::encode( + &logs + .iter() + .map(|entry| { + Token::Tuple(vec![ + entry.address.into_token(), + entry.topics.clone().into_token(), + Token::Bytes(entry.data.to_vec()), + entry + .block_number + .expect("eth_getLogs response should include block_number field") + .as_u64() + .into_token(), + entry + .transaction_hash + .expect("eth_getLogs response should include transaction_hash field") + .into_token(), + entry + .transaction_index + .expect("eth_getLogs response should include transaction_index field") + .as_u64() + .into_token(), + entry + .block_hash + .expect("eth_getLogs response should include block_hash field") + .into_token(), + entry + .log_index + .expect("eth_getLogs response should include log_index field") + .into_token(), + entry + .removed + .expect("eth_getLogs response should include removed field") + .into_token(), + ]) + }) + .collect::>() + .into_tokens(), + ) + .into(); + Ok(result) +} + +fn rpc(data: &EVMData, inner: &RpcCall) -> Result { + let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; + let provider = ProviderBuilder::new(url).build()?; + + let method = inner.0.as_str(); + let params = inner.1.as_str(); + let params_json: Value = serde_json::from_str(params)?; + + let result: Value = RuntimeOrHandle::new() + .block_on(provider.request(method, params_json)) + .map_err(|err| fmt_err!("Error in calling {:?}: {:?}", method, err))?; + + let result_as_tokens = + value_to_token(&result).map_err(|err| fmt_err!("Failed to parse result: {err}"))?; + + let abi_encoded: Vec = match result_as_tokens { + Token::Tuple(vec) | Token::Array(vec) | Token::FixedArray(vec) => abi::encode(&vec), + _ => { + let vec = vec![result_as_tokens]; + abi::encode(&vec) + } + }; + Ok(abi_encoded.into()) +} diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 79ef6a9b0805f..0d52239ef9b8f 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -2,9 +2,10 @@ use crate::{ config::*, - test_helpers::{filter::Filter, RE_PATH_SEPARATOR}, + test_helpers::{filter::Filter, PROJECT, RE_PATH_SEPARATOR}, }; use forge::result::SuiteResult; +use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; /// Executes reverting fork test #[tokio::test(flavor = "multi_thread")] @@ -36,9 +37,34 @@ async fn test_cheats_fork_revert() { /// Executes all non-reverting fork cheatcodes #[tokio::test(flavor = "multi_thread")] async fn test_cheats_fork() { + let mut config = Config::with_root(PROJECT.root()); + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + let runner = runner_with_config(config); let filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); - TestConfig::filter(filter).await.run().await; + TestConfig::with_filter(runner.await, filter).run().await; +} + +/// Executes eth_getLogs cheatcode +#[tokio::test(flavor = "multi_thread")] +async fn test_get_logs_fork() { + let mut config = Config::with_root(PROJECT.root()); + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + let runner = runner_with_config(config); + let filter = Filter::new("testEthGetLogs", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) + .exclude_tests(".*Revert"); + TestConfig::with_filter(runner.await, filter).run().await; +} + +/// Executes rpc cheatcode +#[tokio::test(flavor = "multi_thread")] +async fn test_rpc_fork() { + let mut config = Config::with_root(PROJECT.root()); + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + let runner = runner_with_config(config); + let filter = Filter::new("testRpc", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) + .exclude_tests(".*Revert"); + TestConfig::with_filter(runner.await, filter).run().await; } /// Tests that we can launch in forking mode diff --git a/testdata/cheats/Fork2.t.sol b/testdata/cheats/Fork2.t.sol index c090255f2e1e4..35a1309bbbf95 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/cheats/Fork2.t.sol @@ -2,6 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; +import "../logs/console.sol"; import "./Vm.sol"; struct MyStruct { @@ -165,6 +166,67 @@ contract ForkTest is DSTest { // this will revert since `dummy` does not exists on the currently active fork string memory msg2 = dummy.hello(); } + + struct EthGetLogsJsonParseable { + bytes32 blockHash; + bytes blockNumber; // Should be uint256, but is returned from RPC in 0x... format + bytes32 data; // Should be bytes, but in our particular example is bytes32 + address emitter; + bytes logIndex; // Should be uint256, but is returned from RPC in 0x... format + bool removed; + bytes32[] topics; + bytes32 transactionHash; + bytes transactionIndex; // Should be uint256, but is returned from RPC in 0x... format + } + + function testEthGetLogs() public { + vm.selectFork(mainnetFork); + address weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); + bytes32 withdrawalTopic = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65; + uint256 blockNumber = 17623835; + + string memory path = "fixtures/Rpc/eth_getLogs.json"; + string memory file = vm.readFile(path); + bytes memory parsed = vm.parseJson(file); + EthGetLogsJsonParseable[] memory fixtureLogs = abi.decode(parsed, (EthGetLogsJsonParseable[])); + + bytes32[] memory topics = new bytes32[](1); + topics[0] = withdrawalTopic; + Vm.EthGetLogs[] memory logs = vm.eth_getLogs(blockNumber, blockNumber, weth, topics); + assertEq(logs.length, 3); + + for (uint256 i = 0; i < logs.length; i++) { + Vm.EthGetLogs memory log = logs[i]; + assertEq(log.emitter, fixtureLogs[i].emitter); + + string memory i_str; + if (i == 0) i_str = "0"; + if (i == 1) i_str = "1"; + if (i == 2) i_str = "2"; + + assertEq(log.blockNumber, vm.parseJsonUint(file, string.concat("[", i_str, "].blockNumber"))); + assertEq(log.logIndex, vm.parseJsonUint(file, string.concat("[", i_str, "].logIndex"))); + assertEq(log.transactionIndex, vm.parseJsonUint(file, string.concat("[", i_str, "].transactionIndex"))); + + assertEq(log.blockHash, fixtureLogs[i].blockHash); + assertEq(log.removed, fixtureLogs[i].removed); + assertEq(log.transactionHash, fixtureLogs[i].transactionHash); + + // In this specific example, the log.data is bytes32 + assertEq(bytes32(log.data), fixtureLogs[i].data); + assertEq(log.topics.length, 2); + assertEq(log.topics[0], withdrawalTopic); + assertEq(log.topics[1], fixtureLogs[i].topics[1]); + } + } + + function testRpc() public { + vm.selectFork(mainnetFork); + string memory path = "fixtures/Rpc/balance_params.json"; + string memory file = vm.readFile(path); + bytes memory result = vm.rpc("eth_getBalance", file); + assertEq(result, hex"65a221ccb194dc"); + } } contract DummyContract { diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index a83f70ed6a4e2..5c0368e24ea71 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -24,6 +24,19 @@ interface Vm { string url; } + // Used in eth_getLogs + struct EthGetLogs { + address emitter; + bytes32[] topics; + bytes data; + uint256 blockNumber; + bytes32 transactionHash; + uint256 transactionIndex; + bytes32 blockHash; + uint256 logIndex; + bool removed; + } + // Used in readDir struct DirEntry { string errorMessage; @@ -559,6 +572,12 @@ interface Vm { /// Returns all rpc urls and their aliases as an array of structs function rpcUrlStructs() external returns (Rpc[] memory); + // Gets all the logs according to specified filter + function eth_getLogs(uint256, uint256, address, bytes32[] memory) external returns (EthGetLogs[] memory); + + // Generic rpc call function + function rpc(string calldata, string calldata) external returns (bytes memory); + function parseJson(string calldata, string calldata) external returns (bytes memory); function parseJson(string calldata) external returns (bytes memory); diff --git a/testdata/fixtures/Rpc/README.md b/testdata/fixtures/Rpc/README.md new file mode 100644 index 0000000000000..0d7abd79cd1f7 --- /dev/null +++ b/testdata/fixtures/Rpc/README.md @@ -0,0 +1,25 @@ +# Fixture Generation Instructions + +### `eth_getLogs.json` + +To generate this fixture, send a POST request to a Eth Mainnet (chainId = 1) RPC + +``` +{ + "jsonrpc": "2.0", + "method": "eth_getLogs", + "id": "1", + "params": [ + { + "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "fromBlock": "0x10CEB1B", + "toBlock": "0x10CEB1B", + "topics": [ + "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65" + ] + } + ] +} +``` + +Then you must change the `address` key to `emitter` because in Solidity, a struct's name cannot be `address` as that is a keyword. diff --git a/testdata/fixtures/Rpc/balance_params.json b/testdata/fixtures/Rpc/balance_params.json new file mode 100644 index 0000000000000..740491452728d --- /dev/null +++ b/testdata/fixtures/Rpc/balance_params.json @@ -0,0 +1 @@ +["0x8D97689C9818892B700e27F316cc3E41e17fBeb9", "latest"] \ No newline at end of file diff --git a/testdata/fixtures/Rpc/eth_getLogs.json b/testdata/fixtures/Rpc/eth_getLogs.json new file mode 100644 index 0000000000000..c7c7bac8184c8 --- /dev/null +++ b/testdata/fixtures/Rpc/eth_getLogs.json @@ -0,0 +1,44 @@ +[ + { + "emitter": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "topics": [ + "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65", + "0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d" + ], + "data": "0x0000000000000000000000000000000000000000000000000186faccfe3e2bcc", + "blockNumber": "0x10ceb1b", + "transactionHash": "0xa08f7b4aaa57cb2baec601ad96878d227ae3289a8dd48df98cce30c168588ce7", + "transactionIndex": "0xc", + "blockHash": "0xe4299c95a140ddad351e9831cfb16c35cc0014e8cbd8465de2e5112847d70465", + "logIndex": "0x42", + "removed": false + }, + { + "emitter": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "topics": [ + "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65", + "0x0000000000000000000000002ec705d306b51e486b1bc0d6ebee708e0661add1" + ], + "data": "0x000000000000000000000000000000000000000000000000004befaedcfaea00", + "blockNumber": "0x10ceb1b", + "transactionHash": "0x2cd5355bd917ec5c28194735ad539a4cb58e4b08815a038f6e2373290caeee1d", + "transactionIndex": "0x11", + "blockHash": "0xe4299c95a140ddad351e9831cfb16c35cc0014e8cbd8465de2e5112847d70465", + "logIndex": "0x56", + "removed": false + }, + { + "emitter": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "topics": [ + "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65", + "0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d" + ], + "data": "0x000000000000000000000000000000000000000000000000003432a29cd0ed22", + "blockNumber": "0x10ceb1b", + "transactionHash": "0x4e762d9a572084e0ec412ddf6c4e6d0b746b10e9714d4e786c13579e2e3c3187", + "transactionIndex": "0x16", + "blockHash": "0xe4299c95a140ddad351e9831cfb16c35cc0014e8cbd8465de2e5112847d70465", + "logIndex": "0x68", + "removed": false + } +] \ No newline at end of file From a6bd607eb64a63659c0bb3ef487951ceb82d6c81 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:17:40 +0200 Subject: [PATCH 0023/1963] chore: avoid cloning `CompileOutput` to parse inline config (#5683) * chore: avoid cloning `CompileOutput` to parse inline config * chore: clippy * use new solc methods * chore: bump ethers * chore: clippy * fmt --- Cargo.lock | 22 ++-- crates/config/src/inline/conf_parser.rs | 7 +- crates/config/src/inline/natspec.rs | 59 +++++----- crates/forge/bin/cmd/test/mod.rs | 3 +- crates/forge/src/lib.rs | 138 +++++++++--------------- crates/forge/tests/it/inline.rs | 9 +- 6 files changed, 93 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96182a62a00d2..d345e736f91dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1899,7 +1899,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1914,7 +1914,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "ethers-core", "once_cell", @@ -1925,7 +1925,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -1943,7 +1943,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "Inflector", "const-hex", @@ -1966,7 +1966,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "Inflector", "const-hex", @@ -1981,7 +1981,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "arrayvec", "bytes", @@ -2010,7 +2010,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "ethers-core", "ethers-solc", @@ -2025,7 +2025,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "async-trait", "auto_impl", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "async-trait", "auto_impl", @@ -2089,7 +2089,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "async-trait", "coins-bip32", @@ -2116,7 +2116,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#179891d45cc7b50941f2b8c30b206355ab76d94c" +source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" dependencies = [ "cfg-if", "const-hex", diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index a64cd67299184..c5e5a9be61f3e 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -71,11 +71,8 @@ where fn validate_configs(natspec: &NatSpec) -> Result<(), InlineConfigError> { let config_key = Self::config_key(); - let configs = natspec - .config_lines() - .into_iter() - .filter(|l| l.contains(&config_key)) - .collect::>(); + let configs = + natspec.config_lines().filter(|l| l.contains(&config_key)).collect::>(); Self::default().try_merge(&configs).map_err(|e| { let line = natspec.debug_context(); diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 36d8cefeca2b6..eda0a1fec078b 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -1,12 +1,10 @@ -use std::{collections::BTreeMap, path::Path}; - +use super::{remove_whitespaces, INLINE_CONFIG_PREFIX, INLINE_CONFIG_PREFIX_SELECTED_PROFILE}; use ethers_solc::{ artifacts::{ast::NodeType, Node}, ProjectCompileOutput, }; use serde_json::Value; - -use super::{remove_whitespaces, INLINE_CONFIG_PREFIX, INLINE_CONFIG_PREFIX_SELECTED_PROFILE}; +use std::{collections::BTreeMap, path::Path}; /// Convenient struct to hold in-line per-test configurations pub struct NatSpec { @@ -26,21 +24,19 @@ impl NatSpec { /// Factory function that extracts a vector of [`NatSpec`] instances from /// a solc compiler output. The root path is to express contract base dirs. /// That is essential to match per-test configs at runtime. - pub fn parse

(output: &ProjectCompileOutput, root: &P) -> Vec - where - P: AsRef, - { + pub fn parse(output: &ProjectCompileOutput, root: &Path) -> Vec { let mut natspecs: Vec = vec![]; - let output = output.clone(); - for artifact in output.with_stripped_file_prefixes(root).into_artifacts() { - if let Some(ast) = artifact.1.ast.as_ref() { - let contract: String = artifact.0.identifier(); - if let Some(node) = contract_root_node(&ast.nodes, &contract) { - apply(&mut natspecs, &contract, node) - } - } + for (id, artifact) in output.artifact_ids() { + let Some(ast) = &artifact.ast else { continue }; + let path = id.source.as_path(); + let path = path.strip_prefix(root).unwrap_or(path); + // id.identifier + let contract = format!("{}:{}", path.display(), id.name); + let Some(node) = contract_root_node(&ast.nodes, &contract) else { continue }; + apply(&mut natspecs, &contract, node) } + natspecs } @@ -52,24 +48,21 @@ impl NatSpec { } /// Returns a list of configuration lines that match the current profile - pub fn current_profile_configs(&self) -> Vec { - let prefix: &str = INLINE_CONFIG_PREFIX_SELECTED_PROFILE.as_ref(); - self.config_lines_with_prefix(prefix) + pub fn current_profile_configs(&self) -> impl Iterator + '_ { + self.config_lines_with_prefix(INLINE_CONFIG_PREFIX_SELECTED_PROFILE.as_str()) } /// Returns a list of configuration lines that match a specific string prefix - pub fn config_lines_with_prefix>(&self, prefix: S) -> Vec { - let prefix: String = prefix.into(); - self.config_lines().into_iter().filter(|l| l.starts_with(&prefix)).collect() + pub fn config_lines_with_prefix<'a>( + &'a self, + prefix: &'a str, + ) -> impl Iterator + 'a { + self.config_lines().filter(move |l| l.starts_with(prefix)) } /// Returns a list of all the configuration lines available in the natspec - pub fn config_lines(&self) -> Vec { - self.docs - .split('\n') - .map(remove_whitespaces) - .filter(|line| line.contains(INLINE_CONFIG_PREFIX)) - .collect::>() + pub fn config_lines(&self) -> impl Iterator + '_ { + self.docs.lines().map(remove_whitespaces).filter(|line| line.contains(INLINE_CONFIG_PREFIX)) } } @@ -137,7 +130,7 @@ fn get_fn_docs(fn_data: &BTreeMap) -> Option<(String, String)> { let mut src_line = fn_docs .get("src") .map(|src| src.to_string()) - .unwrap_or(String::from("")); + .unwrap_or_else(|| String::from("")); src_line.retain(|c| c != '"'); return Some((comment.into(), src_line)) @@ -158,7 +151,7 @@ mod tests { let natspec = natspec(); let config_lines = natspec.config_lines(); assert_eq!( - config_lines, + config_lines.collect::>(), vec![ "forge-config:default.fuzz.runs=600".to_string(), "forge-config:ci.fuzz.runs=500".to_string(), @@ -173,7 +166,7 @@ mod tests { let config_lines = natspec.current_profile_configs(); assert_eq!( - config_lines, + config_lines.collect::>(), vec![ "forge-config:default.fuzz.runs=600".to_string(), "forge-config:default.invariant.runs=1".to_string() @@ -186,9 +179,9 @@ mod tests { use super::INLINE_CONFIG_PREFIX; let natspec = natspec(); let prefix = format!("{INLINE_CONFIG_PREFIX}:default"); - let config_lines = natspec.config_lines_with_prefix(prefix); + let config_lines = natspec.config_lines_with_prefix(&prefix); assert_eq!( - config_lines, + config_lines.collect::>(), vec![ "forge-config:default.fuzz.runs=600".to_string(), "forge-config:default.invariant.runs=1".to_string() diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3771eec91762a..d1686f166a3a0 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -165,9 +165,8 @@ impl TestArgs { let test_options: TestOptions = TestOptionsBuilder::default() .fuzz(config.fuzz) .invariant(config.invariant) - .compile_output(&output) .profiles(profiles) - .build(project_root)?; + .build(&output, project_root)?; // Determine print verbosity and executor verbosity let verbosity = evm_opts.verbosity; diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 35537bde685a2..24bebfd7c1380 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -47,6 +47,47 @@ pub struct TestOptions { } impl TestOptions { + /// Tries to create a new instance by detecting inline configurations from the project compile + /// output. + pub fn new( + output: &ProjectCompileOutput, + root: &Path, + profiles: Vec, + base_fuzz: FuzzConfig, + base_invariant: InvariantConfig, + ) -> Result { + let natspecs: Vec = NatSpec::parse(output, root); + let mut inline_invariant = InlineConfig::::default(); + let mut inline_fuzz = InlineConfig::::default(); + + for natspec in natspecs { + // Perform general validation + validate_profiles(&natspec, &profiles)?; + FuzzConfig::validate_configs(&natspec)?; + InvariantConfig::validate_configs(&natspec)?; + + // Apply in-line configurations for the current profile + let configs: Vec = natspec.current_profile_configs().collect(); + let c: &str = &natspec.contract; + let f: &str = &natspec.function; + let line: String = natspec.debug_context(); + + match base_fuzz.try_merge(&configs) { + Ok(Some(conf)) => inline_fuzz.insert(c, f, conf), + Ok(None) => { /* No inline config found, do nothing */ } + Err(e) => Err(InlineConfigError { line: line.clone(), source: e })?, + } + + match base_invariant.try_merge(&configs) { + Ok(Some(conf)) => inline_invariant.insert(c, f, conf), + Ok(None) => { /* No inline config found, do nothing */ } + Err(e) => Err(InlineConfigError { line: line.clone(), source: e })?, + } + } + + Ok(Self { fuzz: base_fuzz, invariant: base_invariant, inline_fuzz, inline_invariant }) + } + /// Returns a "fuzz" test runner instance. Parameters are used to select tight scoped fuzz /// configs that apply for a contract-function pair. A fallback configuration is applied /// if no specific setup is found for a given input. @@ -127,83 +168,23 @@ impl TestOptions { } } -impl<'a, P> TryFrom<(&'a ProjectCompileOutput, &'a P, Vec, FuzzConfig, InvariantConfig)> - for TestOptions -where - P: AsRef, -{ - type Error = InlineConfigError; - - /// Tries to create an instance of `Self`, detecting inline configurations from the project - /// compile output. - /// - /// Param is a tuple, whose elements are: - /// 1. Solidity compiler output, essential to extract natspec test configs. - /// 2. Root path to express contract base dirs. This is essential to match inline configs at - /// runtime. 3. List of available configuration profiles - /// 4. Reference to a fuzz base configuration. - /// 5. Reference to an invariant base configuration. - fn try_from( - value: (&'a ProjectCompileOutput, &'a P, Vec, FuzzConfig, InvariantConfig), - ) -> Result { - let output = value.0; - let root = value.1; - let profiles = &value.2; - let base_fuzz: FuzzConfig = value.3; - let base_invariant: InvariantConfig = value.4; - - let natspecs: Vec = NatSpec::parse(output, root); - let mut inline_invariant = InlineConfig::::default(); - let mut inline_fuzz = InlineConfig::::default(); - - for natspec in natspecs { - // Perform general validation - validate_profiles(&natspec, profiles)?; - FuzzConfig::validate_configs(&natspec)?; - InvariantConfig::validate_configs(&natspec)?; - - // Apply in-line configurations for the current profile - let configs: Vec = natspec.current_profile_configs(); - let c: &str = &natspec.contract; - let f: &str = &natspec.function; - let line: String = natspec.debug_context(); - - match base_fuzz.try_merge(&configs) { - Ok(Some(conf)) => inline_fuzz.insert(c, f, conf), - Err(e) => Err(InlineConfigError { line: line.clone(), source: e })?, - _ => { /* No inline config found, do nothing */ } - } - - match base_invariant.try_merge(&configs) { - Ok(Some(conf)) => inline_invariant.insert(c, f, conf), - Err(e) => Err(InlineConfigError { line: line.clone(), source: e })?, - _ => { /* No inline config found, do nothing */ } - } - } - - Ok(Self { fuzz: base_fuzz, invariant: base_invariant, inline_fuzz, inline_invariant }) - } -} - /// Builder utility to create a [`TestOptions`] instance. #[derive(Default)] +#[must_use = "builders do nothing unless you call `build` on them"] pub struct TestOptionsBuilder { fuzz: Option, invariant: Option, profiles: Option>, - output: Option, } impl TestOptionsBuilder { /// Sets a [`FuzzConfig`] to be used as base "fuzz" configuration. - #[must_use = "A base 'fuzz' config must be provided"] pub fn fuzz(mut self, conf: FuzzConfig) -> Self { self.fuzz = Some(conf); self } /// Sets a [`InvariantConfig`] to be used as base "invariant" configuration. - #[must_use = "A base 'invariant' config must be provided"] pub fn invariant(mut self, conf: InvariantConfig) -> Self { self.invariant = Some(conf); self @@ -216,40 +197,21 @@ impl TestOptionsBuilder { self } - /// Sets a project compiler output instance. This is used to extract - /// inline test configurations that override `self.fuzz` and `self.invariant` - /// specs when necessary. - pub fn compile_output(mut self, output: &ProjectCompileOutput) -> Self { - self.output = Some(output.clone()); - self - } - /// Creates an instance of [`TestOptions`]. This takes care of creating "fuzz" and /// "invariant" fallbacks, and extracting all inline test configs, if available. /// /// `root` is a reference to the user's project root dir. This is essential /// to determine the base path of generated contract identifiers. This is to provide correct /// matchers for inline test configs. - pub fn build(self, root: impl AsRef) -> Result { - let default_profiles = vec![Config::selected_profile().into()]; - let profiles: Vec = self.profiles.unwrap_or(default_profiles); + pub fn build( + self, + output: &ProjectCompileOutput, + root: &Path, + ) -> Result { + let profiles: Vec = + self.profiles.unwrap_or_else(|| vec![Config::selected_profile().into()]); let base_fuzz = self.fuzz.unwrap_or_default(); let base_invariant = self.invariant.unwrap_or_default(); - - match self.output { - Some(compile_output) => Ok(TestOptions::try_from(( - &compile_output, - &root, - profiles, - base_fuzz, - base_invariant, - ))?), - None => Ok(TestOptions { - fuzz: base_fuzz, - invariant: base_invariant, - inline_fuzz: InlineConfig::default(), - inline_invariant: InlineConfig::default(), - }), - } + TestOptions::new(output, root, profiles, base_fuzz, base_invariant) } } diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 4f76391373a76..fb32da49c4351 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -76,9 +76,8 @@ fn build_test_options() { let build_result = TestOptionsBuilder::default() .fuzz(FuzzConfig::default()) .invariant(InvariantConfig::default()) - .compile_output(&COMPILED) .profiles(profiles) - .build(root); + .build(&COMPILED, root); assert!(build_result.is_ok()); } @@ -90,9 +89,8 @@ fn build_test_options_just_one_valid_profile() { let build_result = TestOptionsBuilder::default() .fuzz(FuzzConfig::default()) .invariant(InvariantConfig::default()) - .compile_output(&COMPILED) .profiles(valid_profiles) - .build(root); + .build(&COMPILED, root); // We expect an error, since COMPILED contains in-line // per-test configs for "default" and "ci" profiles @@ -104,7 +102,6 @@ fn test_options() -> TestOptions { TestOptionsBuilder::default() .fuzz(FuzzConfig::default()) .invariant(InvariantConfig::default()) - .compile_output(&COMPILED) - .build(root) + .build(&COMPILED, root) .expect("Config loaded") } From 5457cb7829d3e88e84eeeca9289b66c5182a6708 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:30:06 +0200 Subject: [PATCH 0024/1963] test: fix some tests (#5691) --- crates/chisel/src/executor.rs | 29 +++++++++++++++++------------ crates/forge/tests/cli/script.rs | 2 +- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 246b6f5871ec1..f1c3a5c33caf2 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1343,7 +1343,6 @@ impl<'a> Iterator for InstructionIter<'a> { mod tests { use super::*; use ethers_solc::{error::SolcError, Solc}; - use once_cell::sync::Lazy; use std::sync::Mutex; #[test] @@ -1613,25 +1612,31 @@ mod tests { #[track_caller] fn source() -> SessionSource { // synchronize solc install - static PRE_INSTALL_SOLC_LOCK: Lazy> = Lazy::new(|| Mutex::new(false)); + static PRE_INSTALL_SOLC_LOCK: Mutex = Mutex::new(false); // on some CI targets installing results in weird malformed solc files, we try installing it // multiple times + let version = "0.8.19"; for _ in 0..3 { let mut is_preinstalled = PRE_INSTALL_SOLC_LOCK.lock().unwrap(); if !*is_preinstalled { - let solc = - Solc::find_or_install_svm_version("0.8.19").and_then(|solc| solc.version()); - if solc.is_err() { - // try reinstalling - let solc = Solc::blocking_install(&"0.8.19".parse().unwrap()); - if solc.map_err(SolcError::from).and_then(|solc| solc.version()).is_ok() { - *is_preinstalled = true; + let solc = Solc::find_or_install_svm_version(version) + .and_then(|solc| solc.version().map(|v| (solc, v))); + match solc { + Ok((solc, v)) => { + // successfully installed + eprintln!("found installed Solc v{v} @ {}", solc.solc.display()); break } - } else { - // successfully installed - break + Err(e) => { + // try reinstalling + eprintln!("error: {e}\n trying to re-install Solc v{version}"); + let solc = Solc::blocking_install(&version.parse().unwrap()); + if solc.map_err(SolcError::from).and_then(|solc| solc.version()).is_ok() { + *is_preinstalled = true; + break + } + } } } } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index a6ce2d588cbcd..d2382af5467a4 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -751,7 +751,7 @@ forgetest_async!( let run_log = re.replace_all(&run_log, ""); // Clean up carriage return OS differences - let re = Regex::new(r"\\r\\n").unwrap(); + let re = Regex::new(r"\r\n").unwrap(); let fixtures_log = re.replace_all(&fixtures_log, "\n"); let run_log = re.replace_all(&run_log, "\n"); From 6676e81e2eab70ac2924dd94182d10f2d606bfe2 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:09:57 -0400 Subject: [PATCH 0025/1963] feat(cast): add JWT secret configuration (#5501) * feat(cast): add JWT secret configuration * set patches to branch * fix cli test * remove patches * change `jwt` to `jwt-secret` * change usages oops * fix rpc_jwt_secret docs, add usage docs * chore: use const-hex --------- Co-authored-by: Enrique Ortiz --- Cargo.lock | 45 ++++++++++++++++---------------- crates/cli/src/opts/ethereum.rs | 25 ++++++++++++++++++ crates/cli/src/utils/mod.rs | 10 ++++++- crates/common/Cargo.toml | 2 ++ crates/common/src/provider.rs | 40 +++++++++++++++++++++++++--- crates/config/src/lib.rs | 22 ++++++++++++++++ crates/forge/tests/cli/config.rs | 1 + 7 files changed, 117 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d345e736f91dd..949d33496f888 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -850,9 +850,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", "libc", @@ -1513,9 +1513,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" [[package]] name = "derivative" @@ -2488,6 +2488,7 @@ dependencies = [ "auto_impl", "clap", "comfy-table", + "const-hex", "dunce", "ethers-core", "ethers-etherscan", @@ -3112,9 +3113,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -4673,12 +4674,12 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap 2.0.0", ] [[package]] @@ -5255,9 +5256,9 @@ checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "20b9b67e2ca7dd9e9f9285b759de30ff538aab981abaaf7bc9bd90b84a0126c3" dependencies = [ "base64 0.21.2", "bytes", @@ -5292,7 +5293,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.22.6", + "webpki-roots 0.25.2", "winreg", ] @@ -7423,21 +7424,18 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "webpki", + "rustls-webpki 0.100.1", ] [[package]] name = "webpki-roots" -version = "0.23.1" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.1", -] +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "which" @@ -7633,11 +7631,12 @@ dependencies = [ [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 4686925daac3d..96a82c31e1a8f 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -23,6 +23,18 @@ pub struct RpcOpts { /// Use the Flashbots RPC URL (https://rpc.flashbots.net). #[clap(long)] pub flashbots: bool, + + /// JWT Secret for the RPC endpoint. + /// + /// The JWT secret will be used to create a JWT for a RPC. For example, the following can be + /// used to simulate a CL `engine_forkchoiceUpdated` call: + /// + /// cast rpc --jwt-secret engine_forkchoiceUpdatedV2 + /// '["0x6bb38c26db65749ab6e472080a3d20a2f35776494e72016d1e339593f21c59bc", + /// "0x6bb38c26db65749ab6e472080a3d20a2f35776494e72016d1e339593f21c59bc", + /// "0x6bb38c26db65749ab6e472080a3d20a2f35776494e72016d1e339593f21c59bc"]' + #[clap(long, env = "ETH_RPC_JWT_SECRET")] + pub jwt_secret: Option, } impl_figment_convert_cast!(RpcOpts); @@ -49,11 +61,24 @@ impl RpcOpts { Ok(url) } + /// Returns the JWT secret. + pub fn jwt<'a>(&'a self, config: Option<&'a Config>) -> Result>> { + let jwt = match (self.jwt_secret.as_deref(), config) { + (Some(jwt), _) => Some(Cow::Borrowed(jwt)), + (None, Some(config)) => config.get_rpc_jwt_secret()?, + (None, None) => None, + }; + Ok(jwt) + } + pub fn dict(&self) -> Dict { let mut dict = Dict::new(); if let Ok(Some(url)) = self.url(None) { dict.insert("eth_rpc_url".into(), url.into_owned().into()); } + if let Ok(Some(jwt)) = self.jwt(None) { + dict.insert("eth_rpc_jwt".into(), jwt.into_owned().into()); + } dict } } diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index d94119cd5ad62..5215b88562b77 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -90,6 +90,7 @@ pub fn parse_u256(s: &str) -> Result { pub fn get_provider(config: &Config) -> Result { get_provider_builder(config)?.build() } + /// Returns a [ProviderBuilder](foundry_common::ProviderBuilder) instantiated using [Config]'s RPC /// URL and chain. /// @@ -97,7 +98,14 @@ pub fn get_provider(config: &Config) -> Result { pub fn get_provider_builder(config: &Config) -> Result { let url = config.get_rpc_url_or_localhost_http()?; let chain = config.chain_id.unwrap_or_default(); - Ok(foundry_common::ProviderBuilder::new(url.as_ref()).chain(chain)) + let mut builder = foundry_common::ProviderBuilder::new(url.as_ref()).chain(chain); + + let jwt = config.get_rpc_jwt_secret()?; + if let Some(jwt) = jwt { + builder = builder.jwt(jwt.as_ref()); + } + + Ok(builder) } pub async fn get_chain(chain: Option, provider: M) -> Result diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 0333b6d6b0950..e945b45ce0947 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -43,6 +43,8 @@ once_cell = "1" dunce = "1" regex = "1" globset = "0.4" +# Using const-hex instead of hex for speed +hex.workspace = true [dev-dependencies] tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index f0322722cf6bf..1efd29bee63f2 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -4,11 +4,11 @@ use crate::{ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT}; use ethers_core::types::{Chain, U256}; use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use ethers_providers::{ - is_local_endpoint, Http, HttpRateLimitRetryPolicy, Middleware, Provider, RetryClient, - RetryClientBuilder, DEFAULT_LOCAL_POLL_INTERVAL, + is_local_endpoint, Authorization, Http, HttpRateLimitRetryPolicy, JwtAuth, JwtKey, Middleware, + Provider, RetryClient, RetryClientBuilder, DEFAULT_LOCAL_POLL_INTERVAL, }; use eyre::WrapErr; -use reqwest::{IntoUrl, Url}; +use reqwest::{header::HeaderValue, IntoUrl, Url}; use std::{borrow::Cow, time::Duration}; /// Helper type alias for a retry provider @@ -53,6 +53,8 @@ pub struct ProviderBuilder { timeout: Duration, /// available CUPS compute_units_per_second: u64, + /// JWT Secret + jwt: Option, } // === impl ProviderBuilder === @@ -76,6 +78,7 @@ impl ProviderBuilder { timeout: REQUEST_TIMEOUT, // alchemy max cpus compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, + jwt: None, } } @@ -141,6 +144,12 @@ impl ProviderBuilder { self.max_retry(100).initial_backoff(100) } + /// Sets the JWT secret + pub fn jwt(mut self, jwt: impl Into) -> Self { + self.jwt = Some(jwt.into()); + self + } + /// Same as [`Self:build()`] but also retrieves the `chainId` in order to derive an appropriate /// interval pub async fn connect(self) -> eyre::Result { @@ -163,10 +172,33 @@ impl ProviderBuilder { initial_backoff, timeout, compute_units_per_second, + jwt, } = self; let url = url?; - let client = reqwest::Client::builder().timeout(timeout).build()?; + let mut client_builder = reqwest::Client::builder().timeout(timeout); + + // Set the JWT auth as a header if present + if let Some(jwt) = jwt { + // Decode jwt from hex, then generate claims (iat with current timestamp) + let jwt = hex::decode(jwt)?; + let secret = + JwtKey::from_slice(&jwt).map_err(|err| eyre::eyre!("Invalid JWT: {}", err))?; + let auth = JwtAuth::new(secret, None, None); + let token = auth.generate_token()?; + + // Essentially unrolled ethers-rs new_with_auth to accomodate the custom timeout + let auth = Authorization::Bearer(token); + let mut auth_value = HeaderValue::from_str(&auth.to_string())?; + auth_value.set_sensitive(true); + + let mut headers = reqwest::header::HeaderMap::new(); + headers.insert(reqwest::header::AUTHORIZATION, auth_value); + + client_builder = client_builder.default_headers(headers); + } + + let client = client_builder.build()?; let is_local = is_local_endpoint(url.as_str()); let provider = Http::new_with_client(url, client); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 80899815fd1c9..a3cac6b3e18bf 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -205,6 +205,8 @@ pub struct Config { pub verbosity: u8, /// url of the rpc server that should be used for any rpc calls pub eth_rpc_url: Option, + /// JWT secret that should be used for any rpc calls + pub eth_rpc_jwt: Option, /// etherscan API key, or alias for an `EtherscanConfig` in `etherscan` table pub etherscan_api_key: Option, /// Multiple etherscan api configs and their aliases @@ -752,6 +754,25 @@ impl Config { self.remappings.iter().map(|m| m.clone().into()).collect() } + /// Returns the configured rpc jwt secret + /// + /// Returns: + /// - The jwt secret, if configured + /// + /// # Example + /// + /// ``` + /// + /// use foundry_config::Config; + /// # fn t() { + /// let config = Config::with_root("./"); + /// let rpc_jwt = config.get_rpc_jwt_secret().unwrap().unwrap(); + /// # } + /// ``` + pub fn get_rpc_jwt_secret(&self) -> Result>, UnresolvedEnvVarError> { + Ok(self.eth_rpc_jwt.as_ref().map(|jwt| Cow::Borrowed(jwt.as_str()))) + } + /// Returns the configured rpc url /// /// Returns: @@ -1774,6 +1795,7 @@ impl Default for Config { block_gas_limit: None, memory_limit: 2u64.pow(25), eth_rpc_url: None, + eth_rpc_jwt: None, etherscan_api_key: None, verbosity: 0, remappings: vec![], diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index e4912732bbcd9..ba85a509b989a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -84,6 +84,7 @@ forgetest!(can_extract_config_values, |prj: TestProject, mut cmd: TestCommand| { block_gas_limit: Some(100u64.into()), memory_limit: 2u64.pow(25), eth_rpc_url: Some("localhost".to_string()), + eth_rpc_jwt: None, etherscan_api_key: None, etherscan: Default::default(), verbosity: 4, From f8a07c3d089dc57c39d15fb97f579d89a5e0b709 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 22 Aug 2023 23:13:16 +0200 Subject: [PATCH 0026/1963] Revert "feat(evm): Use latest revm main commit (#5669)" (#5695) * Revert "feat(`evm`): Use latest `revm` main commit (#5669)" This reverts commit efedf1f9e8323bdb1c0fcf0ce728115d0a4a92f4. * test: add basic coverage test * bump --- Cargo.lock | 61 ++++++------------- Cargo.toml | 2 +- crates/anvil/src/eth/backend/mem/inspector.rs | 21 +++++-- crates/anvil/src/eth/error.rs | 8 +-- crates/anvil/src/genesis.rs | 2 +- crates/evm/src/executor/backend/mod.rs | 2 +- crates/evm/src/executor/fork/cache.rs | 17 ++---- .../evm/src/executor/inspector/access_list.rs | 1 + .../executor/inspector/cheatcodes/mapping.rs | 2 +- .../src/executor/inspector/cheatcodes/mod.rs | 8 ++- .../src/executor/inspector/chisel_state.rs | 1 + crates/evm/src/executor/inspector/coverage.rs | 6 +- crates/evm/src/executor/inspector/debugger.rs | 3 + crates/evm/src/executor/inspector/fuzzer.rs | 3 + crates/evm/src/executor/inspector/logs.rs | 1 + crates/evm/src/executor/inspector/printer.rs | 10 ++- crates/evm/src/executor/inspector/stack.rs | 26 +++++--- crates/evm/src/executor/inspector/tracer.rs | 10 ++- crates/evm/src/fuzz/strategies/state.rs | 2 +- crates/forge/tests/cli/coverage.rs | 6 ++ crates/forge/tests/cli/main.rs | 1 + 21 files changed, 106 insertions(+), 87 deletions(-) create mode 100644 crates/forge/tests/cli/coverage.rs diff --git a/Cargo.lock b/Cargo.lock index 949d33496f888..c40e8931cea98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,12 +69,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - [[package]] name = "alloy-rlp" version = "0.3.2" @@ -631,9 +625,6 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" -dependencies = [ - "serde", -] [[package]] name = "bitvec" @@ -1484,9 +1475,9 @@ dependencies = [ [[package]] name = "dashmap" -version = "5.5.0" +version = "5.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6943ae99c34386c84a470c499d3414f66502a41340aa895406e0d2e4a207b91d" +checksum = "edd72493923899c6f10c641bdbdeddc7183d6396641d99c1a0d1597f37f92e28" dependencies = [ "cfg-if", "hashbrown 0.14.0", @@ -3189,11 +3180,6 @@ name = "hashbrown" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" -dependencies = [ - "ahash 0.8.3", - "allocator-api2", - "serde", -] [[package]] name = "hashers" @@ -5300,11 +5286,9 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" +source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" dependencies = [ "auto_impl", - "once_cell", - "rayon", "revm-interpreter", "revm-precompile", "serde", @@ -5314,7 +5298,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" +source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" dependencies = [ "derive_more", "enumn", @@ -5326,7 +5310,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" +source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" dependencies = [ "k256", "num", @@ -5342,16 +5326,15 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" +source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" dependencies = [ "auto_impl", - "bitflags 2.4.0", "bitvec 1.0.1", "bytes", "derive_more", "enumn", "fixed-hash", - "hashbrown 0.14.0", + "hashbrown 0.13.2", "hex", "hex-literal", "primitive-types", @@ -5359,7 +5342,6 @@ dependencies = [ "ruint", "serde", "sha3", - "to-binary", ] [[package]] @@ -5638,7 +5620,7 @@ checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" dependencies = [ "log", "ring", - "rustls-webpki 0.101.3", + "rustls-webpki 0.101.4", "sct", ] @@ -5665,9 +5647,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.100.1" +version = "0.100.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" dependencies = [ "ring", "untrusted", @@ -5675,9 +5657,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.3" +version = "0.101.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261e9e0888cba427c3316e6322805653c9425240b6fd96cee7cb671ab70ab8d0" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" dependencies = [ "ring", "untrusted", @@ -6157,9 +6139,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -6582,15 +6564,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "to-binary" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424552bc848fd1afbcd81f0e8a54b7401b90fd81bb418655ad6dc6d0823bbe3" -dependencies = [ - "hex", -] - [[package]] name = "tokio" version = "1.32.0" @@ -7097,9 +7070,9 @@ dependencies = [ [[package]] name = "unicase" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" dependencies = [ "version_check", ] @@ -7428,7 +7401,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "rustls-webpki 0.100.1", + "rustls-webpki 0.100.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 59b5c182f8fa4..d799d70f4b66e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,4 +154,4 @@ solang-parser = "=0.3.1" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm/", rev = "eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" } +revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 9ca7686c618b5..ca409b734a1f3 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -53,17 +53,23 @@ impl revm::Inspector for Inspector { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, + is_static: bool, ) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.initialize_interp(interp, data); + inspector.initialize_interp(interp, data, is_static); }); InstructionResult::Continue } #[inline] - fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { + fn step( + &mut self, + interp: &mut Interpreter, + data: &mut EVMData<'_, DB>, + is_static: bool, + ) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step(interp, data); + inspector.step(interp, data, is_static); }); InstructionResult::Continue } @@ -86,10 +92,11 @@ impl revm::Inspector for Inspector { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, + is_static: bool, eval: InstructionResult, ) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step_end(interp, data, eval); + inspector.step_end(interp, data, is_static, eval); }); eval } @@ -99,9 +106,10 @@ impl revm::Inspector for Inspector { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, + is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { - inspector.call(data, call); + inspector.call(data, call, is_static); }); (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) @@ -115,9 +123,10 @@ impl revm::Inspector for Inspector { remaining_gas: Gas, ret: InstructionResult, out: Bytes, + is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!([&mut self.tracer], |inspector| { - inspector.call_end(data, inputs, remaining_gas, ret, out.clone()); + inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static); }); (ret, remaining_gas, out) } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 8289fd289b375..888f185d5647a 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -181,9 +181,6 @@ pub enum InvalidTransactionError { /// Thrown when a legacy tx was signed for a different chain #[error("Incompatible EIP-155 transaction, signed for another chain")] IncompatibleEIP155, - /// Thrown when an access list is used before the berlin hard fork. - #[error("Access lists are not supported before the Berlin hardfork")] - AccessListNotSupported, } impl From for InvalidTransactionError { @@ -206,7 +203,7 @@ impl From for InvalidTransactionError { }) } InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA, - InvalidTransaction::LackOfFundForMaxFee { .. } => { + InvalidTransaction::LackOfFundForGasLimit { .. } => { InvalidTransactionError::InsufficientFunds } InvalidTransaction::OverflowPaymentInTransaction => { @@ -220,9 +217,6 @@ impl From for InvalidTransactionError { } InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh, InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow, - InvalidTransaction::AccessListNotSupported => { - InvalidTransactionError::AccessListNotSupported - } } } } diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 71b64feebd682..3ab285a1018ad 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -146,7 +146,7 @@ impl From for AccountInfo { AccountInfo { balance: balance.into(), nonce: nonce.unwrap_or_default(), - code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), + code_hash: code.as_ref().map(|code| code.hash).unwrap_or(KECCAK_EMPTY), code, } } diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index 3e468f2235133..d286cb8a84b76 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -1099,7 +1099,7 @@ impl DatabaseExt for Backend { // prevent issues in the new journalstate, e.g. assumptions that accounts are loaded // if the account is not touched, we reload it, if it's touched we clone it for (addr, acc) in journaled_state.state.iter() { - if acc.is_touched() { + if acc.is_touched { merge_journaled_state_data( b160_to_h160(*addr), journaled_state, diff --git a/crates/evm/src/executor/fork/cache.rs b/crates/evm/src/executor/fork/cache.rs index bf1429589a0f4..dbd4cfe747c8e 100644 --- a/crates/evm/src/executor/fork/cache.rs +++ b/crates/evm/src/executor/fork/cache.rs @@ -1,10 +1,9 @@ //! Cache related abstraction use crate::executor::backend::snapshot::StateSnapshot; +use hashbrown::HashMap as Map; use parking_lot::RwLock; use revm::{ - primitives::{ - Account, AccountInfo, AccountStatus, HashMap as Map, B160, B256, KECCAK_EMPTY, U256, - }, + primitives::{Account, AccountInfo, B160, B256, KECCAK_EMPTY, U256}, DatabaseCommit, }; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; @@ -257,17 +256,13 @@ impl MemDb { let mut storage = self.storage.write(); let mut accounts = self.accounts.write(); for (add, mut acc) in changes { - if acc.is_empty() || acc.is_selfdestructed() { + if acc.is_empty() || acc.is_destroyed { accounts.remove(&add); storage.remove(&add); } else { // insert account - if let Some(code_hash) = acc - .info - .code - .as_ref() - .filter(|code| !code.is_empty()) - .map(|code| code.hash_slow()) + if let Some(code_hash) = + acc.info.code.as_ref().filter(|code| !code.is_empty()).map(|code| code.hash) { acc.info.code_hash = code_hash; } else if acc.info.code_hash.is_zero() { @@ -276,7 +271,7 @@ impl MemDb { accounts.insert(add, acc.info); let acc_storage = storage.entry(add).or_default(); - if acc.status.contains(AccountStatus::Created) { + if acc.storage_cleared { acc_storage.clear(); } for (index, value) in acc.storage { diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/src/executor/inspector/access_list.rs index 65e15c300addb..88619de35da01 100644 --- a/crates/evm/src/executor/inspector/access_list.rs +++ b/crates/evm/src/executor/inspector/access_list.rs @@ -56,6 +56,7 @@ impl Inspector for AccessListTracer { &mut self, interpreter: &mut Interpreter, _data: &mut EVMData<'_, DB>, + _is_static: bool, ) -> InstructionResult { let pc = interpreter.program_counter(); let op = interpreter.contract.bytecode.bytecode()[pc]; diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index 0ae5439a938b2..cf81dc447eb1c 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -91,7 +91,7 @@ pub fn on_evm_step( _data: &mut EVMData<'_, DB>, ) { match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] { - opcode::KECCAK256 => { + opcode::SHA3 => { if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) { let address = interpreter.contract.address; let offset = interpreter.stack.peek(0).expect("stack size > 1").to::(); diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index e8900054929a6..2a0a24b7b06e5 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -294,6 +294,7 @@ impl Inspector for Cheatcodes { &mut self, _: &mut Interpreter, data: &mut EVMData<'_, DB>, + _: bool, ) -> InstructionResult { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. @@ -311,6 +312,7 @@ impl Inspector for Cheatcodes { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, + _: bool, ) -> InstructionResult { self.pc = interpreter.program_counter(); @@ -511,7 +513,7 @@ impl Inspector for Cheatcodes { (CALLCODE, 5, 6, true), (STATICCALL, 4, 5, true), (DELEGATECALL, 4, 5, true), - (KECCAK256, 0, 1, false), + (SHA3, 0, 1, false), (LOG0, 0, 1, false), (LOG1, 0, 1, false), (LOG2, 0, 1, false), @@ -566,6 +568,7 @@ impl Inspector for Cheatcodes { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, + is_static: bool, ) -> (InstructionResult, Gas, bytes::Bytes) { if call.contract == h160_to_b160(CHEATCODE_ADDRESS) { let gas = Gas::new(call.gas_limit); @@ -674,7 +677,7 @@ impl Inspector for Cheatcodes { // because we only need the from, to, value, and data. We can later change this // into 1559, in the cli package, relatively easily once we // know the target chain supports EIP-1559. - if !call.is_static { + if !is_static { if let Err(err) = data .journaled_state .load_account(h160_to_b160(broadcast.new_origin), data.db) @@ -739,6 +742,7 @@ impl Inspector for Cheatcodes { remaining_gas: Gas, status: InstructionResult, retdata: bytes::Bytes, + _: bool, ) -> (InstructionResult, Gas, bytes::Bytes) { if call.contract == h160_to_b160(CHEATCODE_ADDRESS) || call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) diff --git a/crates/evm/src/executor/inspector/chisel_state.rs b/crates/evm/src/executor/inspector/chisel_state.rs index 958e33cb5cd9a..cb7a2a6c17e75 100644 --- a/crates/evm/src/executor/inspector/chisel_state.rs +++ b/crates/evm/src/executor/inspector/chisel_state.rs @@ -26,6 +26,7 @@ impl Inspector for ChiselState { &mut self, interp: &mut Interpreter, _: &mut revm::EVMData<'_, DB>, + _: bool, eval: InstructionResult, ) -> InstructionResult { // If we are at the final pc of the REPL contract execution, set the state. diff --git a/crates/evm/src/executor/inspector/coverage.rs b/crates/evm/src/executor/inspector/coverage.rs index 32a1f29839ad4..b7af6f6609016 100644 --- a/crates/evm/src/executor/inspector/coverage.rs +++ b/crates/evm/src/executor/inspector/coverage.rs @@ -20,8 +20,9 @@ impl Inspector for CoverageCollector { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, + _: bool, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.bytecode.clone().unlock().hash_slow()); + let hash = b256_to_h256(interpreter.contract.bytecode.hash()); self.maps.entry(hash).or_insert_with(|| { HitMap::new(Bytes::copy_from_slice( interpreter.contract.bytecode.original_bytecode_slice(), @@ -36,8 +37,9 @@ impl Inspector for CoverageCollector { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, + _: bool, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.bytecode.clone().unlock().hash_slow()); + let hash = b256_to_h256(interpreter.contract.bytecode.hash()); self.maps.entry(hash).and_modify(|map| map.hit(interpreter.program_counter())); InstructionResult::Continue diff --git a/crates/evm/src/executor/inspector/debugger.rs b/crates/evm/src/executor/inspector/debugger.rs index a21a0f3247a8c..e051ad73cf532 100644 --- a/crates/evm/src/executor/inspector/debugger.rs +++ b/crates/evm/src/executor/inspector/debugger.rs @@ -55,6 +55,7 @@ impl Inspector for Debugger { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, + _: bool, ) -> InstructionResult { let pc = interpreter.program_counter(); let op = interpreter.contract.bytecode.bytecode()[pc]; @@ -97,6 +98,7 @@ impl Inspector for Debugger { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, + _: bool, ) -> (InstructionResult, Gas, Bytes) { self.enter( data.journaled_state.depth() as usize, @@ -124,6 +126,7 @@ impl Inspector for Debugger { gas: Gas, status: InstructionResult, retdata: Bytes, + _: bool, ) -> (InstructionResult, Gas, Bytes) { self.exit(); diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/src/executor/inspector/fuzzer.rs index a7363614a01a2..17926e887f1d4 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/src/executor/inspector/fuzzer.rs @@ -25,6 +25,7 @@ impl Inspector for Fuzzer { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, + _: bool, ) -> InstructionResult { // We only collect `stack` and `memory` data before and after calls. if self.collect { @@ -39,6 +40,7 @@ impl Inspector for Fuzzer { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, + _: bool, ) -> (InstructionResult, Gas, Bytes) { // We don't want to override the very first call made to the test contract. if self.call_generator.is_some() && data.env.tx.caller != call.context.caller { @@ -60,6 +62,7 @@ impl Inspector for Fuzzer { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, + _: bool, ) -> (InstructionResult, Gas, Bytes) { if let Some(ref mut call_generator) = self.call_generator { call_generator.used = false; diff --git a/crates/evm/src/executor/inspector/logs.rs b/crates/evm/src/executor/inspector/logs.rs index a4124d4695a62..c848e329c9f77 100644 --- a/crates/evm/src/executor/inspector/logs.rs +++ b/crates/evm/src/executor/inspector/logs.rs @@ -57,6 +57,7 @@ impl Inspector for LogCollector { &mut self, _: &mut EVMData<'_, DB>, call: &mut CallInputs, + _: bool, ) -> (InstructionResult, Gas, Bytes) { if call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) { let (status, reason) = self.hardhat_log(call.input.to_vec()); diff --git a/crates/evm/src/executor/inspector/printer.rs b/crates/evm/src/executor/inspector/printer.rs index 0f8d9127bf87b..6b694f12f0eea 100644 --- a/crates/evm/src/executor/inspector/printer.rs +++ b/crates/evm/src/executor/inspector/printer.rs @@ -12,7 +12,12 @@ pub struct TracePrinter; impl Inspector for TracePrinter { // get opcode by calling `interp.contract.opcode(interp.program_counter())`. // all other information can be obtained from interp. - fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { + fn step( + &mut self, + interp: &mut Interpreter, + data: &mut EVMData<'_, DB>, + _: bool, + ) -> InstructionResult { let opcode = interp.current_opcode(); let opcode_str = opcode::OPCODE_JUMPMAP[opcode as usize]; let gas_remaining = interp.gas.remaining(); @@ -38,12 +43,13 @@ impl Inspector for TracePrinter { &mut self, _data: &mut EVMData<'_, DB>, inputs: &mut CallInputs, + is_static: bool, ) -> (InstructionResult, Gas, Bytes) { println!( "SM CALL: {:?},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}", inputs.contract, inputs.context, - inputs.is_static, + is_static, inputs.transfer, inputs.input.len(), ); diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index d626fc3d4e33a..7c22a4d65d55f 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -326,6 +326,7 @@ impl InspectorStack { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, + is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( [ @@ -338,8 +339,14 @@ impl InspectorStack { &mut self.printer ], |inspector| { - let (new_status, new_gas, new_retdata) = - inspector.call_end(data, call, remaining_gas, status, retdata.clone()); + let (new_status, new_gas, new_retdata) = inspector.call_end( + data, + call, + remaining_gas, + status, + retdata.clone(), + is_static, + ); // If the inspector returns a different status or a revert with a non-empty message, // we assume it wants to tell us something @@ -360,6 +367,7 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, + is_static: bool, ) -> InstructionResult { call_inspectors!( [ @@ -371,7 +379,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.initialize_interp(interpreter, data); + let status = inspector.initialize_interp(interpreter, data, is_static); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -387,6 +395,7 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, + is_static: bool, ) -> InstructionResult { call_inspectors!( [ @@ -399,7 +408,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.step(interpreter, data); + let status = inspector.step(interpreter, data, is_static); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -430,6 +439,7 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, + is_static: bool, status: InstructionResult, ) -> InstructionResult { call_inspectors!( @@ -442,7 +452,7 @@ impl Inspector for InspectorStack { &mut self.chisel_state ], |inspector| { - let status = inspector.step_end(interpreter, data, status); + let status = inspector.step_end(interpreter, data, is_static, status); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -458,6 +468,7 @@ impl Inspector for InspectorStack { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, + is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( [ @@ -470,7 +481,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let (status, gas, retdata) = inspector.call(data, call); + let (status, gas, retdata) = inspector.call(data, call, is_static); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -489,8 +500,9 @@ impl Inspector for InspectorStack { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, + is_static: bool, ) -> (InstructionResult, Gas, Bytes) { - let res = self.do_call_end(data, call, remaining_gas, status, retdata); + let res = self.do_call_end(data, call, remaining_gas, status, retdata, is_static); if matches!(res.0, return_revert!()) { // Encountered a revert, since cheatcodes may have altered the evm state in such a way diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index c8851edf7ec75..5d5c80ba6b55c 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -150,7 +150,12 @@ impl Tracer { impl Inspector for Tracer { #[inline] - fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { + fn step( + &mut self, + interp: &mut Interpreter, + data: &mut EVMData<'_, DB>, + _is_static: bool, + ) -> InstructionResult { if self.record_steps { self.start_step(interp, data); } @@ -162,6 +167,7 @@ impl Inspector for Tracer { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, + _: bool, status: InstructionResult, ) -> InstructionResult { if self.record_steps { @@ -183,6 +189,7 @@ impl Inspector for Tracer { &mut self, data: &mut EVMData<'_, DB>, inputs: &mut CallInputs, + _: bool, ) -> (InstructionResult, Gas, Bytes) { let (from, to) = match inputs.context.scheme { CallScheme::DelegateCall | CallScheme::CallCode => { @@ -211,6 +218,7 @@ impl Inspector for Tracer { gas: Gas, status: InstructionResult, retdata: Bytes, + _: bool, ) -> (InstructionResult, Gas, Bytes) { self.fill_trace( status, diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/src/fuzz/strategies/state.rs index ba62a0eb22564..2cad56de24988 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/src/fuzz/strategies/state.rs @@ -268,7 +268,7 @@ pub fn collect_created_contracts( for (address, account) in state_changeset { if !setup_contracts.contains_key(&b160_to_h160(*address)) { - if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { + if let (true, Some(code)) = (&account.is_touched, &account.info.code) { if !code.is_empty() { if let Some((artifact, (abi, _))) = project_contracts.find_by_code(code.bytes()) { diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs new file mode 100644 index 0000000000000..05b76a06fdf1c --- /dev/null +++ b/crates/forge/tests/cli/coverage.rs @@ -0,0 +1,6 @@ +use foundry_test_utils::{forgetest, TestCommand, TestProject}; + +forgetest!(basic_coverage, |_prj: TestProject, mut cmd: TestCommand| { + cmd.args(["coverage"]); + cmd.assert_success(); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 0a05fe038be88..69868c93a7c8e 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -4,6 +4,7 @@ pub mod utils; mod cache; mod cmd; mod config; +mod coverage; mod create; mod doc; mod multi_script; From d44540f8b41493971a2690412d7dfdfece6e1693 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 22 Aug 2023 17:47:16 -0400 Subject: [PATCH 0027/1963] chore: re-add --from-utf8 as alias from book (#5702) --- crates/cast/bin/opts.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index e5c7b89a264cd..c2d1fede147a6 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -74,6 +74,7 @@ pub enum Subcommands { #[clap( visible_aliases = &[ "--from-ascii", + "--from-utf8", "from-ascii", "fu", "fa"] From f95fb9b543cab101e89b9d29f9b330c1203d4e33 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 22 Aug 2023 18:34:20 -0400 Subject: [PATCH 0028/1963] fix(`ci`): exclude `rusoto` & `ethers-providers` from `cargo-deny` (#5703) * fix(ci): exclude rusoto/ethers-providers from deny * chore: add deny.toml to paths --- .github/workflows/deny.yml | 4 ++-- deny.toml | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deny.yml b/.github/workflows/deny.yml index af8f4901ed5ed..d0a5e2f35df4a 100644 --- a/.github/workflows/deny.yml +++ b/.github/workflows/deny.yml @@ -3,10 +3,10 @@ name: deny on: push: branches: [master] - paths: [Cargo.lock] + paths: [Cargo.lock, deny.toml] pull_request: branches: [master] - paths: [Cargo.lock] + paths: [Cargo.lock, deny.toml] env: CARGO_TERM_COLOR: always diff --git a/deny.toml b/deny.toml index 37d7afc5b3ed9..4c6a182fe6be7 100644 --- a/deny.toml +++ b/deny.toml @@ -1,3 +1,7 @@ +# Temporarily exclude rusoto and ethers-providers from bans since we've yet to transition to the +# Rust AWS SDK. +exclude = ["rusoto_core", "rusoto_kms", "rusoto_credential", "ethers-providers"] + # This section is considered when running `cargo deny check advisories` # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html From 5816d52c618587b3d3ed581b2bdb4fbd3f7f4648 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 23 Aug 2023 10:06:42 -0400 Subject: [PATCH 0029/1963] chore(`deps`): remove `tui` for `ratatui` (#5700) * fix: remove tui from cargo * fix: switch to ratatui * chore: clippy --- Cargo.lock | 56 +++++++++++++++++++------------------------- crates/ui/Cargo.toml | 2 +- crates/ui/src/lib.rs | 52 ++++++++++++++++++++-------------------- 3 files changed, 51 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c40e8931cea98..3a5f3ab783b89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1147,7 +1147,7 @@ version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" dependencies = [ - "crossterm 0.26.1", + "crossterm", "strum 0.24.1", "strum_macros 0.24.3", "unicode-width", @@ -1347,22 +1347,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossterm" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" -dependencies = [ - "bitflags 1.3.2", - "crossterm_winapi", - "libc", - "mio", - "parking_lot", - "signal-hook", - "signal-hook-mio", - "winapi", -] - [[package]] name = "crossterm" version = "0.26.1" @@ -3553,6 +3537,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "indoc" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" + [[package]] name = "inlinable_string" version = "0.1.15" @@ -5131,6 +5121,21 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "ratatui" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8285baa38bdc9f879d92c0e37cb562ef38aa3aeefca22b3200186bc39242d3d5" +dependencies = [ + "bitflags 2.4.0", + "cassowary", + "crossterm", + "indoc", + "paste", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "rayon" version = "1.7.0" @@ -6943,19 +6948,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "tui" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" -dependencies = [ - "bitflags 1.3.2", - "cassowary", - "crossterm 0.25.0", - "unicode-segmentation", - "unicode-width", -] - [[package]] name = "tungstenite" version = "0.17.3" @@ -7032,13 +7024,13 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" name = "ui" version = "0.2.0" dependencies = [ - "crossterm 0.26.1", + "crossterm", "ethers", "eyre", "foundry-common", "foundry-evm", + "ratatui", "revm", - "tui", ] [[package]] diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 4a7f767d45e4f..7efe80c1aa530 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -18,4 +18,4 @@ ethers.workspace = true crossterm = "0.26" eyre = "0.6" revm = { version = "3", features = ["std", "serde"] } -tui = { version = "0.19", default-features = false, features = ["crossterm"] } +ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"]} \ No newline at end of file diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index 0588fc2bd4086..53ce831eb85b8 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -16,6 +16,15 @@ use foundry_evm::{ utils::{build_pc_ic_map, PCICMap}, CallKind, }; +use ratatui::{ + backend::{Backend, CrosstermBackend}, + layout::{Alignment, Constraint, Direction, Layout, Rect}, + style::{Color, Modifier, Style}, + terminal::Frame, + text::{Line, Span, Text}, + widgets::{Block, Borders, Paragraph, Wrap}, + Terminal, +}; use revm::{interpreter::opcode, primitives::SpecId}; use std::{ cmp::{max, min}, @@ -25,15 +34,6 @@ use std::{ thread, time::{Duration, Instant}, }; -use tui::{ - backend::{Backend, CrosstermBackend}, - layout::{Alignment, Constraint, Direction, Layout, Rect}, - style::{Color, Modifier, Style}, - terminal::Frame, - text::{Span, Spans, Text}, - widgets::{Block, Borders, Paragraph, Wrap}, - Terminal, -}; /// Trait for starting the UI pub trait Ui { @@ -367,9 +367,9 @@ impl Tui { fn draw_footer(f: &mut Frame, area: Rect) { let block_controls = Block::default(); - let text_output = vec![Spans::from(Span::styled( + let text_output = vec![Line::from(Span::styled( "[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end", Style::default().add_modifier(Modifier::DIM))), -Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | [']: goto breakpoint | [h] toggle help", Style::default().add_modifier(Modifier::DIM)))]; +Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | [']: goto breakpoint | [h] toggle help", Style::default().add_modifier(Modifier::DIM)))]; let paragraph = Paragraph::new(text_output) .block(block_controls) @@ -486,7 +486,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ if let Some(last) = before.pop() { if !last.ends_with('\n') { before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Spans::from(vec![ + text_output.lines.push(Line::from(vec![ Span::styled( format!( "{: >max_line_num$}", @@ -506,7 +506,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ line_number += 1; }); - text_output.lines.push(Spans::from(vec![ + text_output.lines.push(Line::from(vec![ Span::styled( format!( "{: >max_line_num$}", @@ -530,7 +530,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ line_number += 1; actual.iter().skip(1).for_each(|s| { - text_output.lines.push(Spans::from(vec![ + text_output.lines.push(Line::from(vec![ Span::styled( format!( "{: >max_line_num$}", @@ -561,7 +561,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ } else { before.push(last); before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Spans::from(vec![ + text_output.lines.push(Line::from(vec![ Span::styled( format!( "{: >max_line_num$}", @@ -582,7 +582,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ line_number += 1; }); actual.iter().for_each(|s| { - text_output.lines.push(Spans::from(vec![ + text_output.lines.push(Line::from(vec![ Span::styled( format!( "{: >max_line_num$}", @@ -611,7 +611,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ } } else { actual.iter().for_each(|s| { - text_output.lines.push(Spans::from(vec![ + text_output.lines.push(Line::from(vec![ Span::styled( format!( "{: >max_line_num$}", @@ -644,7 +644,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ if !last.ends_with('\n') { if let Some(post) = after.pop_front() { if let Some(last) = text_output.lines.last_mut() { - last.0.push(Span::raw(post)); + last.spans.push(Span::raw(post)); } } } @@ -655,7 +655,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ after.pop_back(); } after.iter().for_each(|line| { - text_output.lines.push(Spans::from(vec![ + text_output.lines.push(Line::from(vec![ Span::styled( format!( "{: >max_line_num$}", @@ -721,7 +721,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ debug_steps[current_step].total_gas_used, )) .borders(Borders::ALL); - let mut text_output: Vec = Vec::new(); + let mut text_output: Vec = Vec::new(); // Scroll: // Focused line is line that should always be at the center of the screen. @@ -776,12 +776,12 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ }; if let Some(op) = opcode_list.get(line_number) { - text_output.push(Spans::from(Span::styled( + text_output.push(Line::from(Span::styled( format!("{line_number_format}{op}"), Style::default().fg(Color::White).bg(bg_color), ))); } else { - text_output.push(Spans::from(Span::styled( + text_output.push(Line::from(Span::styled( line_number_format, Style::default().fg(Color::White).bg(bg_color), ))); @@ -818,7 +818,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ vec![] }; - let text: Vec = stack + let text: Vec = stack .iter() .rev() .enumerate() @@ -861,7 +861,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ spans.extend(words); spans.push(Span::raw("\n")); - Spans::from(spans) + Line::from(spans) }) .collect(); @@ -923,7 +923,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ let height = area.height as usize; let end_line = draw_mem.current_mem_startline + height; - let text: Vec = memory + let text: Vec = memory .chunks(32) .enumerate() .skip(draw_mem.current_mem_startline) @@ -975,7 +975,7 @@ Spans::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/ spans.push(Span::raw("\n")); - Spans::from(spans) + Line::from(spans) }) .collect(); let paragraph = Paragraph::new(text).block(stack_space).wrap(Wrap { trim: true }); From c2de1400ced5b982553d54e561c155884b15a734 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 23 Aug 2023 13:45:59 -0400 Subject: [PATCH 0030/1963] chore: bump `revm` (#5698) * chore: bump revm * chore: fix breaking changes * feat: add coverage test * chore: clippy * chore: switch revm to latest main * Revert "Revert "feat(evm): Use latest revm main commit (#5669)" (#5695)" This reverts commit f8a07c3d089dc57c39d15fb97f579d89a5e0b709. * re-add coverage test * fmt * chore: clippy * chore: fix test * chore: fix test * chore: remove unused/unnecessary stuff --- Cargo.lock | 93 ++++++++++++------- Cargo.toml | 2 +- crates/anvil/src/config.rs | 23 ++--- crates/anvil/src/eth/backend/mem/inspector.rs | 21 ++--- crates/anvil/src/eth/error.rs | 8 +- crates/anvil/src/genesis.rs | 2 +- crates/evm/src/executor/backend/mod.rs | 2 +- crates/evm/src/executor/fork/cache.rs | 18 ++-- crates/evm/src/executor/fork/init.rs | 19 ++-- .../evm/src/executor/inspector/access_list.rs | 1 - .../executor/inspector/cheatcodes/mapping.rs | 2 +- .../src/executor/inspector/cheatcodes/mod.rs | 8 +- .../src/executor/inspector/chisel_state.rs | 1 - crates/evm/src/executor/inspector/coverage.rs | 6 +- crates/evm/src/executor/inspector/debugger.rs | 3 - crates/evm/src/executor/inspector/fuzzer.rs | 3 - crates/evm/src/executor/inspector/logs.rs | 1 - crates/evm/src/executor/inspector/printer.rs | 10 +- crates/evm/src/executor/inspector/stack.rs | 26 ++---- crates/evm/src/executor/inspector/tracer.rs | 10 +- crates/evm/src/executor/opts.rs | 22 ++--- crates/evm/src/fuzz/strategies/state.rs | 2 +- crates/evm/test-data/storage.json | 2 +- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/src/lib.rs | 1 + 25 files changed, 139 insertions(+), 149 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a5f3ab783b89..9c13a4d5c488c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -69,6 +69,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "alloy-rlp" version = "0.3.2" @@ -547,9 +553,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -625,6 +631,9 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -940,9 +949,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.23" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" +checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" dependencies = [ "clap_builder", "clap_derive", @@ -951,9 +960,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.23" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" +checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" dependencies = [ "anstream", "anstyle", @@ -1695,9 +1704,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -2810,9 +2819,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "git2" @@ -3164,6 +3173,11 @@ name = "hashbrown" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +dependencies = [ + "ahash 0.8.3", + "allocator-api2", + "serde", +] [[package]] name = "hashers" @@ -4192,9 +4206,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -4301,9 +4315,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" dependencies = [ "memchr", ] @@ -4414,9 +4428,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "3.9.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126d3e6f3926bfb0fb24495b4f4da50626f547e54956594748e3d8882a0320b4" +checksum = "2a54938017eacd63036332b4ae5c8a49fc8c0c1d6d629893057e4f13609edd06" dependencies = [ "num-traits", ] @@ -5291,9 +5305,11 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" dependencies = [ "auto_impl", + "once_cell", + "rayon", "revm-interpreter", "revm-precompile", "serde", @@ -5303,7 +5319,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" dependencies = [ "derive_more", "enumn", @@ -5315,7 +5331,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" dependencies = [ "k256", "num", @@ -5331,15 +5347,16 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?branch=release/v25#88337924f4d16ed1f5e4cde12a03d0cb755cd658" +source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" dependencies = [ "auto_impl", + "bitflags 2.4.0", "bitvec 1.0.1", "bytes", "derive_more", "enumn", "fixed-hash", - "hashbrown 0.13.2", + "hashbrown 0.14.0", "hex", "hex-literal", "primitive-types", @@ -5347,6 +5364,7 @@ dependencies = [ "ruint", "serde", "sha3", + "to-binary", ] [[package]] @@ -5898,9 +5916,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.171" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" dependencies = [ "serde_derive", ] @@ -5918,9 +5936,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" dependencies = [ "proc-macro2", "quote", @@ -6138,9 +6156,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" @@ -6507,9 +6525,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a79d09ac6b08c1ab3906a2f7cc2e81a0e27c7ae89c63812df75e52bef0751e07" +checksum = "0bb39ee79a6d8de55f48f2293a830e040392f1c5f16e336bdd1788cd0aadce07" dependencies = [ "deranged", "itoa", @@ -6528,9 +6546,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c65469ed6b3a4809d987a41eb1dc918e9bc1d92211cbad7ae82931846f7451" +checksum = "733d258752e9303d392b94b75230d07b0b9c489350c69b851fc6c065fde3e8f9" dependencies = [ "time-core", ] @@ -6569,6 +6587,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "to-binary" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424552bc848fd1afbcd81f0e8a54b7401b90fd81bb418655ad6dc6d0823bbe3" +dependencies = [ + "hex", +] + [[package]] name = "tokio" version = "1.32.0" diff --git a/Cargo.toml b/Cargo.toml index d799d70f4b66e..daa47cfd0170c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,4 +154,4 @@ solang-parser = "=0.3.1" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" } +revm = { git = "https://github.com/bluealloy/revm/", rev = "6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index f262cfb0c5595..653847839a279 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -781,18 +781,19 @@ impl NodeConfig { /// *Note*: only memory based backend for now pub(crate) async fn setup(&mut self) -> mem::Backend { // configure the revm environment + + let mut cfg = CfgEnv::default(); + cfg.spec_id = self.get_hardfork().into(); + cfg.chain_id = rU256::from(self.get_chain_id()); + cfg.limit_contract_code_size = self.code_size_limit; + // EIP-3607 rejects transactions from senders with deployed code. + // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the + // caller is a contract. So we disable the check by default. + cfg.disable_eip3607 = true; + cfg.disable_block_gas_limit = self.disable_block_gas_limit; + let mut env = revm::primitives::Env { - cfg: CfgEnv { - spec_id: self.get_hardfork().into(), - chain_id: rU256::from(self.get_chain_id()), - limit_contract_code_size: self.code_size_limit, - // EIP-3607 rejects transactions from senders with deployed code. - // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the - // caller is a contract. So we disable the check by default. - disable_eip3607: true, - disable_block_gas_limit: self.disable_block_gas_limit, - ..Default::default() - }, + cfg, block: BlockEnv { gas_limit: self.gas_limit.into(), basefee: self.get_base_fee().into(), diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index ca409b734a1f3..9ca7686c618b5 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -53,23 +53,17 @@ impl revm::Inspector for Inspector { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, ) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.initialize_interp(interp, data, is_static); + inspector.initialize_interp(interp, data); }); InstructionResult::Continue } #[inline] - fn step( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - is_static: bool, - ) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step(interp, data, is_static); + inspector.step(interp, data); }); InstructionResult::Continue } @@ -92,11 +86,10 @@ impl revm::Inspector for Inspector { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, eval: InstructionResult, ) -> InstructionResult { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step_end(interp, data, is_static, eval); + inspector.step_end(interp, data, eval); }); eval } @@ -106,10 +99,9 @@ impl revm::Inspector for Inspector { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { - inspector.call(data, call, is_static); + inspector.call(data, call); }); (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) @@ -123,10 +115,9 @@ impl revm::Inspector for Inspector { remaining_gas: Gas, ret: InstructionResult, out: Bytes, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!([&mut self.tracer], |inspector| { - inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static); + inspector.call_end(data, inputs, remaining_gas, ret, out.clone()); }); (ret, remaining_gas, out) } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 888f185d5647a..8289fd289b375 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -181,6 +181,9 @@ pub enum InvalidTransactionError { /// Thrown when a legacy tx was signed for a different chain #[error("Incompatible EIP-155 transaction, signed for another chain")] IncompatibleEIP155, + /// Thrown when an access list is used before the berlin hard fork. + #[error("Access lists are not supported before the Berlin hardfork")] + AccessListNotSupported, } impl From for InvalidTransactionError { @@ -203,7 +206,7 @@ impl From for InvalidTransactionError { }) } InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA, - InvalidTransaction::LackOfFundForGasLimit { .. } => { + InvalidTransaction::LackOfFundForMaxFee { .. } => { InvalidTransactionError::InsufficientFunds } InvalidTransaction::OverflowPaymentInTransaction => { @@ -217,6 +220,9 @@ impl From for InvalidTransactionError { } InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh, InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow, + InvalidTransaction::AccessListNotSupported => { + InvalidTransactionError::AccessListNotSupported + } } } } diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 3ab285a1018ad..71b64feebd682 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -146,7 +146,7 @@ impl From for AccountInfo { AccountInfo { balance: balance.into(), nonce: nonce.unwrap_or_default(), - code_hash: code.as_ref().map(|code| code.hash).unwrap_or(KECCAK_EMPTY), + code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), code, } } diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index d286cb8a84b76..3e468f2235133 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -1099,7 +1099,7 @@ impl DatabaseExt for Backend { // prevent issues in the new journalstate, e.g. assumptions that accounts are loaded // if the account is not touched, we reload it, if it's touched we clone it for (addr, acc) in journaled_state.state.iter() { - if acc.is_touched { + if acc.is_touched() { merge_journaled_state_data( b160_to_h160(*addr), journaled_state, diff --git a/crates/evm/src/executor/fork/cache.rs b/crates/evm/src/executor/fork/cache.rs index dbd4cfe747c8e..8a5f18dc6edfa 100644 --- a/crates/evm/src/executor/fork/cache.rs +++ b/crates/evm/src/executor/fork/cache.rs @@ -1,9 +1,10 @@ //! Cache related abstraction use crate::executor::backend::snapshot::StateSnapshot; -use hashbrown::HashMap as Map; use parking_lot::RwLock; use revm::{ - primitives::{Account, AccountInfo, B160, B256, KECCAK_EMPTY, U256}, + primitives::{ + Account, AccountInfo, AccountStatus, HashMap as Map, B160, B256, KECCAK_EMPTY, U256, + }, DatabaseCommit, }; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; @@ -256,13 +257,17 @@ impl MemDb { let mut storage = self.storage.write(); let mut accounts = self.accounts.write(); for (add, mut acc) in changes { - if acc.is_empty() || acc.is_destroyed { + if acc.is_empty() || acc.is_selfdestructed() { accounts.remove(&add); storage.remove(&add); } else { // insert account - if let Some(code_hash) = - acc.info.code.as_ref().filter(|code| !code.is_empty()).map(|code| code.hash) + if let Some(code_hash) = acc + .info + .code + .as_ref() + .filter(|code| !code.is_empty()) + .map(|code| code.hash_slow()) { acc.info.code_hash = code_hash; } else if acc.info.code_hash.is_zero() { @@ -271,7 +276,7 @@ impl MemDb { accounts.insert(add, acc.info); let acc_storage = storage.entry(add).or_default(); - if acc.storage_cleared { + if acc.status.contains(AccountStatus::Created) { acc_storage.clear(); } for (index, value) in acc.storage { @@ -474,6 +479,7 @@ mod tests { "chain_id": "0x539", "spec_id": "LATEST", "perf_all_precompiles_have_balance": false, + "disable_coinbase_tip": false, "perf_analyse_created_bytecodes": "Analyse", "limit_contract_code_size": 18446744073709551615, "memory_limit": 4294967295 diff --git a/crates/evm/src/executor/fork/init.rs b/crates/evm/src/executor/fork/init.rs index 849b46f51cf00..886129053b1e5 100644 --- a/crates/evm/src/executor/fork/init.rs +++ b/crates/evm/src/executor/fork/init.rs @@ -58,17 +58,16 @@ where eyre::bail!("Failed to get block for block number: {}", block_number) }; + let mut cfg = CfgEnv::default(); + cfg.chain_id = u256_to_ru256(override_chain_id.unwrap_or(rpc_chain_id.as_u64()).into()); + cfg.memory_limit = memory_limit; + cfg.limit_contract_code_size = Some(usize::MAX); + // EIP-3607 rejects transactions from senders with deployed code. + // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the caller + // is a contract. So we disable the check by default. + cfg.disable_eip3607 = true; let mut env = Env { - cfg: CfgEnv { - chain_id: u256_to_ru256(override_chain_id.unwrap_or(rpc_chain_id.as_u64()).into()), - memory_limit, - limit_contract_code_size: Some(usize::MAX), - // EIP-3607 rejects transactions from senders with deployed code. - // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the caller - // is a contract. So we disable the check by default. - disable_eip3607: true, - ..Default::default() - }, + cfg, block: BlockEnv { number: u256_to_ru256(block.number.expect("block number not found").as_u64().into()), timestamp: block.timestamp.into(), diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/src/executor/inspector/access_list.rs index 88619de35da01..65e15c300addb 100644 --- a/crates/evm/src/executor/inspector/access_list.rs +++ b/crates/evm/src/executor/inspector/access_list.rs @@ -56,7 +56,6 @@ impl Inspector for AccessListTracer { &mut self, interpreter: &mut Interpreter, _data: &mut EVMData<'_, DB>, - _is_static: bool, ) -> InstructionResult { let pc = interpreter.program_counter(); let op = interpreter.contract.bytecode.bytecode()[pc]; diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index cf81dc447eb1c..0ae5439a938b2 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -91,7 +91,7 @@ pub fn on_evm_step( _data: &mut EVMData<'_, DB>, ) { match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] { - opcode::SHA3 => { + opcode::KECCAK256 => { if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) { let address = interpreter.contract.address; let offset = interpreter.stack.peek(0).expect("stack size > 1").to::(); diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 2a0a24b7b06e5..e8900054929a6 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -294,7 +294,6 @@ impl Inspector for Cheatcodes { &mut self, _: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. @@ -312,7 +311,6 @@ impl Inspector for Cheatcodes { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { self.pc = interpreter.program_counter(); @@ -513,7 +511,7 @@ impl Inspector for Cheatcodes { (CALLCODE, 5, 6, true), (STATICCALL, 4, 5, true), (DELEGATECALL, 4, 5, true), - (SHA3, 0, 1, false), + (KECCAK256, 0, 1, false), (LOG0, 0, 1, false), (LOG1, 0, 1, false), (LOG2, 0, 1, false), @@ -568,7 +566,6 @@ impl Inspector for Cheatcodes { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, bytes::Bytes) { if call.contract == h160_to_b160(CHEATCODE_ADDRESS) { let gas = Gas::new(call.gas_limit); @@ -677,7 +674,7 @@ impl Inspector for Cheatcodes { // because we only need the from, to, value, and data. We can later change this // into 1559, in the cli package, relatively easily once we // know the target chain supports EIP-1559. - if !is_static { + if !call.is_static { if let Err(err) = data .journaled_state .load_account(h160_to_b160(broadcast.new_origin), data.db) @@ -742,7 +739,6 @@ impl Inspector for Cheatcodes { remaining_gas: Gas, status: InstructionResult, retdata: bytes::Bytes, - _: bool, ) -> (InstructionResult, Gas, bytes::Bytes) { if call.contract == h160_to_b160(CHEATCODE_ADDRESS) || call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) diff --git a/crates/evm/src/executor/inspector/chisel_state.rs b/crates/evm/src/executor/inspector/chisel_state.rs index cb7a2a6c17e75..958e33cb5cd9a 100644 --- a/crates/evm/src/executor/inspector/chisel_state.rs +++ b/crates/evm/src/executor/inspector/chisel_state.rs @@ -26,7 +26,6 @@ impl Inspector for ChiselState { &mut self, interp: &mut Interpreter, _: &mut revm::EVMData<'_, DB>, - _: bool, eval: InstructionResult, ) -> InstructionResult { // If we are at the final pc of the REPL contract execution, set the state. diff --git a/crates/evm/src/executor/inspector/coverage.rs b/crates/evm/src/executor/inspector/coverage.rs index b7af6f6609016..1a549de04e95d 100644 --- a/crates/evm/src/executor/inspector/coverage.rs +++ b/crates/evm/src/executor/inspector/coverage.rs @@ -20,9 +20,8 @@ impl Inspector for CoverageCollector { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.bytecode.hash()); + let hash = b256_to_h256(interpreter.contract.hash); self.maps.entry(hash).or_insert_with(|| { HitMap::new(Bytes::copy_from_slice( interpreter.contract.bytecode.original_bytecode_slice(), @@ -37,9 +36,8 @@ impl Inspector for CoverageCollector { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.bytecode.hash()); + let hash = b256_to_h256(interpreter.contract.hash); self.maps.entry(hash).and_modify(|map| map.hit(interpreter.program_counter())); InstructionResult::Continue diff --git a/crates/evm/src/executor/inspector/debugger.rs b/crates/evm/src/executor/inspector/debugger.rs index e051ad73cf532..a21a0f3247a8c 100644 --- a/crates/evm/src/executor/inspector/debugger.rs +++ b/crates/evm/src/executor/inspector/debugger.rs @@ -55,7 +55,6 @@ impl Inspector for Debugger { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { let pc = interpreter.program_counter(); let op = interpreter.contract.bytecode.bytecode()[pc]; @@ -98,7 +97,6 @@ impl Inspector for Debugger { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { self.enter( data.journaled_state.depth() as usize, @@ -126,7 +124,6 @@ impl Inspector for Debugger { gas: Gas, status: InstructionResult, retdata: Bytes, - _: bool, ) -> (InstructionResult, Gas, Bytes) { self.exit(); diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/src/executor/inspector/fuzzer.rs index 17926e887f1d4..a7363614a01a2 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/src/executor/inspector/fuzzer.rs @@ -25,7 +25,6 @@ impl Inspector for Fuzzer { &mut self, interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, - _: bool, ) -> InstructionResult { // We only collect `stack` and `memory` data before and after calls. if self.collect { @@ -40,7 +39,6 @@ impl Inspector for Fuzzer { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { // We don't want to override the very first call made to the test contract. if self.call_generator.is_some() && data.env.tx.caller != call.context.caller { @@ -62,7 +60,6 @@ impl Inspector for Fuzzer { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, - _: bool, ) -> (InstructionResult, Gas, Bytes) { if let Some(ref mut call_generator) = self.call_generator { call_generator.used = false; diff --git a/crates/evm/src/executor/inspector/logs.rs b/crates/evm/src/executor/inspector/logs.rs index c848e329c9f77..a4124d4695a62 100644 --- a/crates/evm/src/executor/inspector/logs.rs +++ b/crates/evm/src/executor/inspector/logs.rs @@ -57,7 +57,6 @@ impl Inspector for LogCollector { &mut self, _: &mut EVMData<'_, DB>, call: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { if call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) { let (status, reason) = self.hardhat_log(call.input.to_vec()); diff --git a/crates/evm/src/executor/inspector/printer.rs b/crates/evm/src/executor/inspector/printer.rs index 6b694f12f0eea..0f8d9127bf87b 100644 --- a/crates/evm/src/executor/inspector/printer.rs +++ b/crates/evm/src/executor/inspector/printer.rs @@ -12,12 +12,7 @@ pub struct TracePrinter; impl Inspector for TracePrinter { // get opcode by calling `interp.contract.opcode(interp.program_counter())`. // all other information can be obtained from interp. - fn step( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - _: bool, - ) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { let opcode = interp.current_opcode(); let opcode_str = opcode::OPCODE_JUMPMAP[opcode as usize]; let gas_remaining = interp.gas.remaining(); @@ -43,13 +38,12 @@ impl Inspector for TracePrinter { &mut self, _data: &mut EVMData<'_, DB>, inputs: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { println!( "SM CALL: {:?},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}", inputs.contract, inputs.context, - is_static, + inputs.is_static, inputs.transfer, inputs.input.len(), ); diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index 7c22a4d65d55f..d626fc3d4e33a 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -326,7 +326,6 @@ impl InspectorStack { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( [ @@ -339,14 +338,8 @@ impl InspectorStack { &mut self.printer ], |inspector| { - let (new_status, new_gas, new_retdata) = inspector.call_end( - data, - call, - remaining_gas, - status, - retdata.clone(), - is_static, - ); + let (new_status, new_gas, new_retdata) = + inspector.call_end(data, call, remaining_gas, status, retdata.clone()); // If the inspector returns a different status or a revert with a non-empty message, // we assume it wants to tell us something @@ -367,7 +360,6 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, ) -> InstructionResult { call_inspectors!( [ @@ -379,7 +371,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.initialize_interp(interpreter, data, is_static); + let status = inspector.initialize_interp(interpreter, data); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -395,7 +387,6 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, ) -> InstructionResult { call_inspectors!( [ @@ -408,7 +399,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.step(interpreter, data, is_static); + let status = inspector.step(interpreter, data); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -439,7 +430,6 @@ impl Inspector for InspectorStack { &mut self, interpreter: &mut Interpreter, data: &mut EVMData<'_, DB>, - is_static: bool, status: InstructionResult, ) -> InstructionResult { call_inspectors!( @@ -452,7 +442,7 @@ impl Inspector for InspectorStack { &mut self.chisel_state ], |inspector| { - let status = inspector.step_end(interpreter, data, is_static, status); + let status = inspector.step_end(interpreter, data, status); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -468,7 +458,6 @@ impl Inspector for InspectorStack { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { call_inspectors!( [ @@ -481,7 +470,7 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let (status, gas, retdata) = inspector.call(data, call, is_static); + let (status, gas, retdata) = inspector.call(data, call); // Allow inspectors to exit early if status != InstructionResult::Continue { @@ -500,9 +489,8 @@ impl Inspector for InspectorStack { remaining_gas: Gas, status: InstructionResult, retdata: Bytes, - is_static: bool, ) -> (InstructionResult, Gas, Bytes) { - let res = self.do_call_end(data, call, remaining_gas, status, retdata, is_static); + let res = self.do_call_end(data, call, remaining_gas, status, retdata); if matches!(res.0, return_revert!()) { // Encountered a revert, since cheatcodes may have altered the evm state in such a way diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index 5d5c80ba6b55c..c8851edf7ec75 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -150,12 +150,7 @@ impl Tracer { impl Inspector for Tracer { #[inline] - fn step( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - _is_static: bool, - ) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { if self.record_steps { self.start_step(interp, data); } @@ -167,7 +162,6 @@ impl Inspector for Tracer { &mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>, - _: bool, status: InstructionResult, ) -> InstructionResult { if self.record_steps { @@ -189,7 +183,6 @@ impl Inspector for Tracer { &mut self, data: &mut EVMData<'_, DB>, inputs: &mut CallInputs, - _: bool, ) -> (InstructionResult, Gas, Bytes) { let (from, to) = match inputs.context.scheme { CallScheme::DelegateCall | CallScheme::CallCode => { @@ -218,7 +211,6 @@ impl Inspector for Tracer { gas: Gas, status: InstructionResult, retdata: Bytes, - _: bool, ) -> (InstructionResult, Gas, Bytes) { self.fill_trace( status, diff --git a/crates/evm/src/executor/opts.rs b/crates/evm/src/executor/opts.rs index 944a46206dfe0..e572ff81dbf9b 100644 --- a/crates/evm/src/executor/opts.rs +++ b/crates/evm/src/executor/opts.rs @@ -93,6 +93,16 @@ impl EvmOpts { /// Returns the `revm::Env` configured with only local settings pub fn local_evm_env(&self) -> revm::primitives::Env { + let mut cfg = CfgEnv::default(); + cfg.chain_id = rU256::from(self.env.chain_id.unwrap_or(foundry_common::DEV_CHAIN_ID)); + cfg.spec_id = SpecId::MERGE; + cfg.limit_contract_code_size = self.env.code_size_limit.or(Some(usize::MAX)); + cfg.memory_limit = self.memory_limit; + // EIP-3607 rejects transactions from senders with deployed code. + // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the + // caller is a contract. So we disable the check by default. + cfg.disable_eip3607 = true; + revm::primitives::Env { block: BlockEnv { number: rU256::from(self.env.block_number), @@ -103,17 +113,7 @@ impl EvmOpts { basefee: rU256::from(self.env.block_base_fee_per_gas), gas_limit: self.gas_limit().into(), }, - cfg: CfgEnv { - chain_id: rU256::from(self.env.chain_id.unwrap_or(foundry_common::DEV_CHAIN_ID)), - spec_id: SpecId::MERGE, - limit_contract_code_size: self.env.code_size_limit.or(Some(usize::MAX)), - memory_limit: self.memory_limit, - // EIP-3607 rejects transactions from senders with deployed code. - // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the - // caller is a contract. So we disable the check by default. - disable_eip3607: true, - ..Default::default() - }, + cfg, tx: TxEnv { gas_price: rU256::from(self.env.gas_price.unwrap_or_default()), gas_limit: self.gas_limit().as_u64(), diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/src/fuzz/strategies/state.rs index 2cad56de24988..ba62a0eb22564 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/src/fuzz/strategies/state.rs @@ -268,7 +268,7 @@ pub fn collect_created_contracts( for (address, account) in state_changeset { if !setup_contracts.contains_key(&b160_to_h160(*address)) { - if let (true, Some(code)) = (&account.is_touched, &account.info.code) { + if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { if !code.is_empty() { if let Some((artifact, (abi, _))) = project_contracts.find_by_code(code.bytes()) { diff --git a/crates/evm/test-data/storage.json b/crates/evm/test-data/storage.json index 41114b2cc39be..7544ef1be56c7 100644 --- a/crates/evm/test-data/storage.json +++ b/crates/evm/test-data/storage.json @@ -1 +1 @@ -{"meta":{"cfg_env":{"chain_id":"0x1","spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295, "perf_analyse_created_bytecodes":"Analyse", "limit_contract_code_size": 24576},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} \ No newline at end of file +{"meta":{"cfg_env":{"chain_id":"0x1","spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295, "perf_analyse_created_bytecodes":"Analyse", "limit_contract_code_size": 24576, "disable_coinbase_tip": false},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} \ No newline at end of file diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index c4c955f6486f2..1359067578b90 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -275,7 +275,7 @@ macro_rules! impl_value_enum { (enum $name:ident { $($field:ident => $main:literal $(| $alias:literal)*),+ $(,)? }) => { impl $name { /// All the variants of this enum. - pub const ALL: &[Self] = &[$(Self::$field),+]; + pub const ALL: &'static [Self] = &[$(Self::$field),+]; /// Returns the string representation of `self`. #[inline] diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 24bebfd7c1380..99af3a7e9841c 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -3,6 +3,7 @@ use foundry_config::{ validate_profiles, Config, FuzzConfig, InlineConfig, InlineConfigError, InlineConfigParser, InvariantConfig, NatSpec, }; + use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; use std::path::Path; From 1143e57fd4eb706d2f2b8d040d3945c0b27a47f7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 23 Aug 2023 20:05:31 +0200 Subject: [PATCH 0031/1963] chore: use `Interpreter::current_opcode` (#5701) Co-authored-by: Enrique Ortiz --- Cargo.lock | 56 +++++++++---------- .../evm/src/executor/inspector/access_list.rs | 5 +- .../executor/inspector/cheatcodes/mapping.rs | 2 +- .../src/executor/inspector/cheatcodes/mod.rs | 6 +- .../src/executor/inspector/chisel_state.rs | 1 + crates/evm/src/executor/inspector/debugger.rs | 2 +- crates/evm/src/executor/inspector/tracer.rs | 54 ++++++++---------- 7 files changed, 59 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c13a4d5c488c..4f4526452a1d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.21.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" dependencies = [ "gimli", ] @@ -553,9 +553,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" dependencies = [ "addr2line", "cc", @@ -949,9 +949,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.24" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" +checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" dependencies = [ "clap_builder", "clap_derive", @@ -960,9 +960,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.24" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" +checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" dependencies = [ "anstream", "anstyle", @@ -1704,9 +1704,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ "cfg-if", ] @@ -2819,9 +2819,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "git2" @@ -4206,9 +4206,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ "autocfg", "num-integer", @@ -4315,9 +4315,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.32.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" dependencies = [ "memchr", ] @@ -4428,9 +4428,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "3.9.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a54938017eacd63036332b4ae5c8a49fc8c0c1d6d629893057e4f13609edd06" +checksum = "126d3e6f3926bfb0fb24495b4f4da50626f547e54956594748e3d8882a0320b4" dependencies = [ "num-traits", ] @@ -5916,9 +5916,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.185" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] @@ -5936,9 +5936,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.185" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", @@ -6156,9 +6156,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.11" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" @@ -6525,9 +6525,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.27" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb39ee79a6d8de55f48f2293a830e040392f1c5f16e336bdd1788cd0aadce07" +checksum = "a79d09ac6b08c1ab3906a2f7cc2e81a0e27c7ae89c63812df75e52bef0751e07" dependencies = [ "deranged", "itoa", @@ -6546,9 +6546,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.13" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733d258752e9303d392b94b75230d07b0b9c489350c69b851fc6c065fde3e8f9" +checksum = "75c65469ed6b3a4809d987a41eb1dc918e9bc1d92211cbad7ae82931846f7451" dependencies = [ "time-core", ] diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/src/executor/inspector/access_list.rs index 65e15c300addb..bd059b2e64d05 100644 --- a/crates/evm/src/executor/inspector/access_list.rs +++ b/crates/evm/src/executor/inspector/access_list.rs @@ -57,10 +57,7 @@ impl Inspector for AccessListTracer { interpreter: &mut Interpreter, _data: &mut EVMData<'_, DB>, ) -> InstructionResult { - let pc = interpreter.program_counter(); - let op = interpreter.contract.bytecode.bytecode()[pc]; - - match op { + match interpreter.current_opcode() { opcode::SLOAD | opcode::SSTORE => { if let Ok(slot) = interpreter.stack().peek(0) { let cur_contract = interpreter.contract.address; diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index 0ae5439a938b2..52eaae37801d5 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -90,7 +90,7 @@ pub fn on_evm_step( interpreter: &Interpreter, _data: &mut EVMData<'_, DB>, ) { - match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] { + match interpreter.current_opcode() { opcode::KECCAK256 => { if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) { let address = interpreter.contract.address; diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index e8900054929a6..cd2c84808b5c5 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -321,7 +321,7 @@ impl Inspector for Cheatcodes { self.gas_metering = Some(Some(interpreter.gas)); } Some(Some(gas)) => { - match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] { + match interpreter.current_opcode() { opcode::CREATE | opcode::CREATE2 => { // set we're about to enter CREATE frame to meter its gas on first opcode // inside it @@ -373,7 +373,7 @@ impl Inspector for Cheatcodes { // Record writes and reads if `record` has been called if let Some(storage_accesses) = &mut self.accesses { - match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] { + match interpreter.current_opcode() { opcode::SLOAD => { let key = try_or_continue!(interpreter.stack().peek(0)); storage_accesses @@ -416,7 +416,7 @@ impl Inspector for Cheatcodes { // size of the memory write is implicit, so these cases are hard-coded. macro_rules! mem_opcode_match { ([$(($opcode:ident, $offset_depth:expr, $size_depth:expr, $writes:expr)),*]) => { - match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] { + match interpreter.current_opcode() { //////////////////////////////////////////////////////////////// // OPERATIONS THAT CAN EXPAND/MUTATE MEMORY BY WRITING // //////////////////////////////////////////////////////////////// diff --git a/crates/evm/src/executor/inspector/chisel_state.rs b/crates/evm/src/executor/inspector/chisel_state.rs index 958e33cb5cd9a..614cafeeb9679 100644 --- a/crates/evm/src/executor/inspector/chisel_state.rs +++ b/crates/evm/src/executor/inspector/chisel_state.rs @@ -29,6 +29,7 @@ impl Inspector for ChiselState { eval: InstructionResult, ) -> InstructionResult { // If we are at the final pc of the REPL contract execution, set the state. + // Subtraction can't overflow because `pc` is always at least 1 in `step_end`. if self.final_pc == interp.program_counter() - 1 { self.state = Some((interp.stack().clone(), interp.memory.clone(), eval)) } diff --git a/crates/evm/src/executor/inspector/debugger.rs b/crates/evm/src/executor/inspector/debugger.rs index a21a0f3247a8c..9c49326056dc6 100644 --- a/crates/evm/src/executor/inspector/debugger.rs +++ b/crates/evm/src/executor/inspector/debugger.rs @@ -57,7 +57,7 @@ impl Inspector for Debugger { data: &mut EVMData<'_, DB>, ) -> InstructionResult { let pc = interpreter.program_counter(); - let op = interpreter.contract.bytecode.bytecode()[pc]; + let op = interpreter.current_opcode(); // Get opcode information let opcode_infos = spec_opcode_gas(data.env.cfg.spec_id); diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index c8851edf7ec75..77609946c6e8a 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -85,16 +85,14 @@ impl Tracer { fn start_step(&mut self, interp: &Interpreter, data: &EVMData<'_, DB>) { let trace_idx = *self.trace_stack.last().expect("can't start step without starting a trace first"); - let trace = &mut self.traces.arena[trace_idx]; + let node = &mut self.traces.arena[trace_idx]; - self.step_stack.push((trace_idx, trace.trace.steps.len())); + self.step_stack.push((trace_idx, node.trace.steps.len())); - let pc = interp.program_counter(); - - trace.trace.steps.push(CallTraceStep { + node.trace.steps.push(CallTraceStep { depth: data.journaled_state.depth(), - pc, - op: OpCode(interp.contract.bytecode.bytecode()[pc]), + pc: interp.program_counter(), + op: OpCode(interp.current_opcode()), contract: b160_to_h160(interp.contract.address), stack: interp.stack.clone(), memory: interp.memory.clone(), @@ -116,30 +114,26 @@ impl Tracer { self.step_stack.pop().expect("can't fill step without starting a step first"); let step = &mut self.traces.arena[trace_idx].trace.steps[step_idx]; - if let Some(pc) = interp.program_counter().checked_sub(1) { - let op = interp.contract.bytecode.bytecode()[pc]; - - let journal_entry = data - .journaled_state - .journal - .last() - // This should always work because revm initializes it as `vec![vec![]]` - .unwrap() - .last(); - - step.state_diff = match (op, journal_entry) { - ( - opcode::SLOAD | opcode::SSTORE, - Some(JournalEntry::StorageChange { address, key, .. }), - ) => { - let value = data.journaled_state.state[address].storage[key].present_value(); - Some((ru256_to_u256(*key), value.into())) - } - _ => None, - }; + let op = interp.current_opcode(); + let journal_entry = data + .journaled_state + .journal + .last() + // This should always work because revm initializes it as `vec![vec![]]` + .unwrap() + .last(); + step.state_diff = match (op, journal_entry) { + ( + opcode::SLOAD | opcode::SSTORE, + Some(JournalEntry::StorageChange { address, key, .. }), + ) => { + let value = data.journaled_state.state[address].storage[key].present_value(); + Some((ru256_to_u256(*key), value.into())) + } + _ => None, + }; - step.gas_cost = step.gas - interp.gas.remaining(); - } + step.gas_cost = step.gas - interp.gas.remaining(); // Error codes only if status as u8 > InstructionResult::OutOfGas as u8 { From 00d1256b49a5c73f36a56b641441a92a037e4bec Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 24 Aug 2023 13:44:39 +0200 Subject: [PATCH 0032/1963] chore: name std threads (#5710) --- crates/anvil/src/service.rs | 6 +- crates/common/src/term.rs | 95 +++++++++++-------------- crates/doc/src/server.rs | 8 +-- crates/evm/src/executor/fork/backend.rs | 6 +- crates/evm/src/executor/fork/multi.rs | 15 ++-- crates/ui/src/lib.rs | 47 ++++++------ 6 files changed, 82 insertions(+), 95 deletions(-) diff --git a/crates/anvil/src/service.rs b/crates/anvil/src/service.rs index b1555a79c1664..f4b1003bcfc59 100644 --- a/crates/anvil/src/service.rs +++ b/crates/anvil/src/service.rs @@ -93,11 +93,9 @@ impl Future for NodeService { if pin.filter_eviction_interval.poll_tick(cx).is_ready() { let filters = pin.filters.clone(); + // evict filters that timed out #[allow(clippy::redundant_async_block)] - tokio::task::spawn(async move { - // evict filters that timed out - filters.evict().await - }); + tokio::task::spawn(async move { filters.evict().await }); } Poll::Pending diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 8b20006ad3949..40f36da1fe65c 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -10,10 +10,8 @@ use std::{ io, io::{prelude::*, IsTerminal}, path::{Path, PathBuf}, - sync::{ - mpsc::{self, TryRecvError}, - Arc, Mutex, - }, + sync::mpsc::{self, TryRecvError}, + thread, time::Duration, }; use yansi::Paint; @@ -71,17 +69,12 @@ impl Spinner { return } - print!( - "\r\x33[2K\r{} {}", - Paint::new(format!("[{}]", Paint::green(self.indicator[self.idx]))).bold(), - self.message - ); + let indicator = Paint::green(self.indicator[self.idx % self.indicator.len()]); + let indicator = Paint::new(format!("[{indicator}]")).bold(); + print!("\r\x33[2K\r{indicator} {}", self.message); io::stdout().flush().unwrap(); - self.idx += 1; - if self.idx >= self.indicator.len() { - self.idx = 0; - } + self.idx = self.idx.wrapping_add(1); } pub fn message(&mut self, msg: impl Into) { @@ -94,12 +87,16 @@ impl Spinner { /// This reporter will prefix messages with a spinning cursor #[derive(Debug)] pub struct SpinnerReporter { - /// the timeout in ms - sender: Arc>>, - /// A reporter that logs solc compiler input and output to separate files if configured via env - /// var + /// The sender to the spinner thread. + sender: mpsc::Sender, + /// Reporter that logs Solc compiler input and output to separate files if configured via env + /// var. solc_io_report: SolcCompilerIoReporter, } + +// `mpsc::Sender: Sync` was stabilized in 1.72 https://github.com/rust-lang/rust/pull/111087 +unsafe impl Sync for SpinnerReporter {} + impl SpinnerReporter { /// Spawns the [`Spinner`] on a new thread /// @@ -108,43 +105,37 @@ impl SpinnerReporter { /// On drop the channel will disconnect and the thread will terminate pub fn spawn() -> Self { let (sender, rx) = mpsc::channel::(); - std::thread::spawn(move || { - let mut spinner = Spinner::new("Compiling..."); - loop { - spinner.tick(); - match rx.try_recv() { - Ok(msg) => { - match msg { - SpinnerMsg::Msg(msg) => { - spinner.message(msg); - // new line so past messages are not overwritten - println!(); - } - SpinnerMsg::Shutdown(ack) => { - // end with a newline - println!(); - let _ = ack.send(()); - break - } + + std::thread::Builder::new() + .name("spinner".into()) + .spawn(move || { + let mut spinner = Spinner::new("Compiling..."); + loop { + spinner.tick(); + match rx.try_recv() { + Ok(SpinnerMsg::Msg(msg)) => { + spinner.message(msg); + // new line so past messages are not overwritten + println!(); } - } - Err(TryRecvError::Disconnected) => break, - Err(TryRecvError::Empty) => { - std::thread::sleep(std::time::Duration::from_millis(100)); + Ok(SpinnerMsg::Shutdown(ack)) => { + // end with a newline + println!(); + let _ = ack.send(()); + break + } + Err(TryRecvError::Disconnected) => break, + Err(TryRecvError::Empty) => thread::sleep(Duration::from_millis(100)), } } - } - }); - SpinnerReporter { - sender: Arc::new(Mutex::new(sender)), - solc_io_report: SolcCompilerIoReporter::from_default_env(), - } + }) + .expect("failed to spawn thread"); + + SpinnerReporter { sender, solc_io_report: SolcCompilerIoReporter::from_default_env() } } fn send_msg(&self, msg: impl Into) { - if let Ok(sender) = self.sender.lock() { - let _ = sender.send(SpinnerMsg::Msg(msg.into())); - } + let _ = self.sender.send(SpinnerMsg::Msg(msg.into())); } } @@ -155,11 +146,9 @@ enum SpinnerMsg { impl Drop for SpinnerReporter { fn drop(&mut self) { - if let Ok(sender) = self.sender.lock() { - let (tx, rx) = mpsc::channel(); - if sender.send(SpinnerMsg::Shutdown(tx)).is_ok() { - let _ = rx.recv(); - } + let (tx, rx) = mpsc::channel(); + if self.sender.send(SpinnerMsg::Shutdown(tx)).is_ok() { + let _ = rx.recv(); } } } diff --git a/crates/doc/src/server.rs b/crates/doc/src/server.rs index f4ac6567ccece..bd2cc801a927b 100644 --- a/crates/doc/src/server.rs +++ b/crates/doc/src/server.rs @@ -74,14 +74,8 @@ impl Server { // A channel used to broadcast to any websockets to reload when a file changes. let (tx, _rx) = tokio::sync::broadcast::channel::(100); - let thread_handle = std::thread::spawn(move || { - serve(build_dir, sockaddr, tx, &file_404); - }); - println!("Serving on: http://{address}"); - - let _ = thread_handle.join(); - + serve(build_dir, sockaddr, tx, &file_404); Ok(()) } } diff --git a/crates/evm/src/executor/fork/backend.rs b/crates/evm/src/executor/fork/backend.rs index cb5f9f9593964..e8b458248b806 100644 --- a/crates/evm/src/executor/fork/backend.rs +++ b/crates/evm/src/executor/fork/backend.rs @@ -551,16 +551,16 @@ impl SharedBackend { // spawn a light-weight thread with a thread-local async runtime just for // sending and receiving data from the remote client std::thread::Builder::new() - .name("fork-backend-thread".to_string()) + .name("fork-backend".into()) .spawn(move || { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() - .expect("failed to create fork-backend-thread tokio runtime"); + .expect("failed to build tokio runtime"); rt.block_on(handler); }) - .expect("failed to spawn backendhandler thread"); + .expect("failed to spawn thread"); trace!(target: "backendhandler", "spawned Backendhandler thread"); shared diff --git a/crates/evm/src/executor/fork/multi.rs b/crates/evm/src/executor/fork/multi.rs index 66631b6dc3b9a..600078b249562 100644 --- a/crates/evm/src/executor/fork/multi.rs +++ b/crates/evm/src/executor/fork/multi.rs @@ -89,12 +89,12 @@ impl MultiFork { // spawn a light-weight thread with a thread-local async runtime just for // sending and receiving data from the remote client(s) std::thread::Builder::new() - .name("multi-fork-backend-thread".to_string()) + .name("multi-fork-backend".into()) .spawn(move || { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() - .expect("failed to create multi-fork-backend-thread tokio runtime"); + .expect("failed to build tokio runtime"); rt.block_on(async move { // flush cache every 60s, this ensures that long-running fork tests get their @@ -105,7 +105,7 @@ impl MultiFork { handler.await }); }) - .expect("failed to spawn multi fork handler thread"); + .expect("failed to spawn thread"); trace!(target: "fork::multi", "spawned MultiForkHandler thread"); fork } @@ -408,9 +408,12 @@ impl Future for MultiForkHandler { trace!(target: "fork::multi", "tick flushing caches"); let forks = pin.forks.values().map(|f| f.backend.clone()).collect::>(); // flush this on new thread to not block here - std::thread::spawn(move || { - forks.into_iter().for_each(|fork| fork.flush_cache()); - }); + std::thread::Builder::new() + .name("flusher".into()) + .spawn(move || { + forks.into_iter().for_each(|fork| fork.flush_cache()); + }) + .expect("failed to spawn thread"); } Poll::Pending diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index 53ce831eb85b8..ca13218fa726f 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -998,33 +998,36 @@ impl Ui for Tui { // Setup a channel to send interrupts let (tx, rx) = mpsc::channel(); - thread::spawn(move || { - let mut last_tick = Instant::now(); - loop { - // Poll events since last tick - if last tick is greater than tick_rate, we demand - // immediate availability of the event. This may affect - // interactivity, but I'm not sure as it is hard to test. - if event::poll(tick_rate.saturating_sub(last_tick.elapsed())).unwrap() { - let event = event::read().unwrap(); - if let Event::Key(key) = event { - if tx.send(Interrupt::KeyPressed(key)).is_err() { - return + thread::Builder::new() + .name("event-listener".into()) + .spawn(move || { + let mut last_tick = Instant::now(); + loop { + // Poll events since last tick - if last tick is greater than tick_rate, we + // demand immediate availability of the event. This may affect interactivity, + // but I'm not sure as it is hard to test. + if event::poll(tick_rate.saturating_sub(last_tick.elapsed())).unwrap() { + let event = event::read().unwrap(); + if let Event::Key(key) = event { + if tx.send(Interrupt::KeyPressed(key)).is_err() { + return + } + } else if let Event::Mouse(mouse) = event { + if tx.send(Interrupt::MouseEvent(mouse)).is_err() { + return + } } - } else if let Event::Mouse(mouse) = event { - if tx.send(Interrupt::MouseEvent(mouse)).is_err() { + } + // Force update if time has passed + if last_tick.elapsed() > tick_rate { + if tx.send(Interrupt::IntervalElapsed).is_err() { return } + last_tick = Instant::now(); } } - // Force update if time has passed - if last_tick.elapsed() > tick_rate { - if tx.send(Interrupt::IntervalElapsed).is_err() { - return - } - last_tick = Instant::now(); - } - } - }); + }) + .expect("failed to spawn thread"); self.terminal.clear()?; let mut draw_memory: DrawMemory = DrawMemory::default(); From 42da4256e8f94024d7b976bb3a6d8b7f41c2df85 Mon Sep 17 00:00:00 2001 From: Tereza Burianova Date: Thu, 24 Aug 2023 14:04:42 +0200 Subject: [PATCH 0033/1963] Fixing the installation command in Anvil README (#5707) --- crates/anvil/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/README.md b/crates/anvil/README.md index 48e42c24412a3..165f6285b8999 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -20,7 +20,7 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** ```sh git clone https://github.com/foundry-rs/foundry cd foundry -cargo install --path ./anvil --bins --locked --force +cargo install --path ./crates/anvil --profile local --force ``` ## Getting started From ef2931f178aeb31f909d600e74d7d26bb9d84c3b Mon Sep 17 00:00:00 2001 From: Igor Line Date: Thu, 24 Aug 2023 13:18:21 +0000 Subject: [PATCH 0034/1963] Fix prefix/suffix Handling in cast create2 after switching to const-hex crate (#5713) * fix(cast): remove unnecessary 0x prefix strips * fix(cast): fix and refactor prefix/suffix checks for create2 address generation * fix(cast): remove strip 0x in init code and init code hash for create2 * fix(cast): remove extra 0x strips in rlp and tx * fix: remove extra strip 0x prefix from common abi and evm --- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/create2.rs | 59 +++++++++++++++---- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/send.rs | 2 +- crates/cast/src/lib.rs | 10 ++-- crates/cast/src/rlp_converter.rs | 5 +- crates/cast/src/tx.rs | 4 +- crates/common/src/abi.rs | 1 - .../src/executor/inspector/cheatcodes/ext.rs | 13 ++-- .../src/executor/inspector/cheatcodes/util.rs | 2 +- 10 files changed, 63 insertions(+), 37 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 5c3ff7a9e4334..3659bcf2c098a 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -226,7 +226,7 @@ async fn fill_create( ) -> Result<()> { builder.value(value); - let mut data = hex::decode(code.strip_prefix("0x").unwrap_or(&code))?; + let mut data = hex::decode(code)?; if let Some(s) = sig { let (mut sigdata, _func) = builder.create_args(&s, args).await?; diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 65bad5f1c5877..e7da7bd0cbb89 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -90,16 +90,15 @@ impl Create2Args { } if let Some(prefix) = starts_with { - let pad_width = prefix.len() + prefix.len() % 2; - hex::decode(format!("{prefix:0>pad_width$}")) - .wrap_err("invalid prefix hex provided")?; - regexs.push(format!(r"^{prefix}")); + regexs.push(format!( + r"^{}", + get_regex_hex_string(prefix).wrap_err("invalid prefix hex provided")? + )); } if let Some(suffix) = ends_with { - let pad_width = suffix.len() + suffix.len() % 2; - hex::decode(format!("{suffix:0>pad_width$}")) - .wrap_err("invalid suffix hex provided")?; - regexs.push(format!(r"{suffix}$")); + regexs.push( + (get_regex_hex_string(suffix).wrap_err("invalid suffix hex provided")?).to_string(), + ); } debug_assert!( @@ -111,12 +110,11 @@ impl Create2Args { let init_code_hash = if let Some(init_code_hash) = init_code_hash { let mut a: [u8; 32] = [0; 32]; - let init_code_hash = init_code_hash.strip_prefix("0x").unwrap_or(&init_code_hash); - assert!(init_code_hash.len() == 64, "init code hash should be 32 bytes long"); // 32 bytes * 2 - a.copy_from_slice(&hex::decode(init_code_hash)?[..32]); + let init_code_hash_bytes = hex::decode(init_code_hash)?; + assert!(init_code_hash_bytes.len() == 32, "init code hash should be 32 bytes long"); + a.copy_from_slice(&init_code_hash_bytes); a } else { - let init_code = init_code.strip_prefix("0x").unwrap_or(&init_code).as_bytes(); keccak256(hex::decode(init_code)?) }; @@ -157,6 +155,13 @@ impl Create2Args { } } +fn get_regex_hex_string(s: String) -> Result { + let s = s.strip_prefix("0x").unwrap_or(&s); + let pad_width = s.len() + s.len() % 2; + hex::decode(format!("{s:0>pad_width$}"))?; + Ok(s.to_string()) +} + #[cfg(test)] mod tests { use ethers::{abi::AbiEncode, utils::get_create2_address}; @@ -167,12 +172,42 @@ mod tests { #[test] fn basic_create2() { + // even hex chars let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "aa"]); let create2_out = args.run().unwrap(); let address = create2_out.address; let address = format!("{address:x}"); assert!(address.starts_with("aa")); + + // odd hex chars + let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "aaa"]); + let create2_out = args.run().unwrap(); + let address = create2_out.address; + let address = format!("{address:x}"); + + assert!(address.starts_with("aaa")); + + // even hex chars with 0x prefix + let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xaa"]); + let create2_out = args.run().unwrap(); + let address = create2_out.address; + let address = format!("{address:x}"); + + assert!(address.starts_with("aa")); + + // odd hex chars with 0x prefix + let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xaaa"]); + let create2_out = args.run().unwrap(); + let address = create2_out.address; + let address = format!("{address:x}"); + + assert!(address.starts_with("aaa")); + + // TODO: add check fails on wrong chars + // let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xtest"]); + // let create2_out = args.run(); + // assert_eq!(create2_out, Err("invalid prefix hex provided")); } #[test] diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index e2f992b2c9731..402ea7de56b03 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -92,7 +92,7 @@ impl EstimateArgs { Some(EstimateSubcommands::Create { code, sig, args, value }) => { builder.value(value); - let mut data = hex::decode(code.strip_prefix("0x").unwrap_or(&code))?; + let mut data = hex::decode(code)?; if let Some(s) = sig { let (mut sigdata, _func) = builder.create_args(&s, args).await?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 22e4f7d03c3a1..cf9d95e56f114 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -225,7 +225,7 @@ where .nonce(tx.nonce); if let Some(code) = code { - let mut data = hex::decode(code.strip_prefix("0x").unwrap_or(&code))?; + let mut data = hex::decode(code)?; if let Some((sig, args)) = params { let (mut sigdata, _) = builder.create_args(sig, args).await?; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 7df722fe87639..55171592e9e3c 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1201,8 +1201,7 @@ impl SimpleCast { /// } /// ``` pub fn from_rlp(value: impl AsRef) -> Result { - let data = strip_0x(value.as_ref()); - let bytes = hex::decode(data).wrap_err("Could not decode hex")?; + let bytes = hex::decode(value.as_ref()).wrap_err("Could not decode hex")?; let item = rlp::decode::(&bytes).wrap_err("Could not decode rlp")?; Ok(item.to_string()) } @@ -1302,12 +1301,11 @@ impl SimpleCast { /// Decodes string from bytes32 value pub fn parse_bytes32_string(s: &str) -> Result { - let s = strip_0x(s); - if s.len() != 64 { - eyre::bail!("expected 64 byte hex-string, got {s}"); + let bytes = hex::decode(s)?; + if bytes.len() != 32 { + eyre::bail!("expected 64 byte hex-string, got {}", strip_0x(s)); } - let bytes = hex::decode(s)?; let mut buffer = [0u8; 32]; buffer.copy_from_slice(&bytes); diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index 5c64556daa8cf..0ca8597d4e23e 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -46,10 +46,7 @@ impl Item { } // If a value is passed without quotes we cast it to string Value::Number(n) => Ok(Item::value_to_item(&Value::String(n.to_string()))?), - Value::String(s) => { - let hex_string = s.strip_prefix("0x").unwrap_or(s); - Ok(Item::Data(hex::decode(hex_string).expect("Could not decode hex"))) - } + Value::String(s) => Ok(Item::Data(hex::decode(s).expect("Could not decode hex"))), Value::Array(values) => values.iter().map(Item::value_to_item).collect(), Value::Object(_) => { eyre::bail!("RLP input can not contain objects") diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs index fae149129bce0..b1708deb5d6d4 100644 --- a/crates/cast/src/tx.rs +++ b/crates/cast/src/tx.rs @@ -12,8 +12,6 @@ use foundry_common::abi::{encode_args, get_func, get_func_etherscan}; use foundry_config::Chain; use futures::future::join_all; -use crate::strip_0x; - pub struct TxBuilder<'a, M: Middleware> { to: Option, chain: Chain, @@ -200,7 +198,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { }; if sig.starts_with("0x") { - Ok((hex::decode(strip_0x(sig))?, func)) + Ok((hex::decode(sig)?, func)) } else { Ok((encode_args(&func, &args)?, func)) } diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 5497858cfacc1..d934d816c521d 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -35,7 +35,6 @@ pub fn encode_args(func: &Function, args: &[impl AsRef]) -> Result> /// If the `sig` is an invalid function signature pub fn abi_decode(sig: &str, calldata: &str, input: bool, fn_selector: bool) -> Result> { let func = IntoFunction::into(sig); - let calldata = calldata.strip_prefix("0x").unwrap_or(calldata); let calldata = hex::decode(calldata)?; let res = if input { // If function selector is prefixed in "calldata", remove it (first 4 bytes) diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index 1fb57a4f6afd8..95f88e4cd89f0 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -38,12 +38,11 @@ fn try_ffi(state: &Cheatcodes, args: &[String]) -> Result { // The stdout might be encoded on valid hex, or it might just be a string, // so we need to determine which it is to avoid improperly encoding later. - let encoded_stdout: Token = - if let Ok(hex) = hex::decode(trimmed_stdout.strip_prefix("0x").unwrap_or(trimmed_stdout)) { - Token::Bytes(hex) - } else { - Token::Bytes(trimmed_stdout.into()) - }; + let encoded_stdout: Token = if let Ok(hex) = hex::decode(trimmed_stdout) { + Token::Bytes(hex) + } else { + Token::Bytes(trimmed_stdout.into()) + }; let res = abi::encode(&[Token::Tuple(vec![ Token::Int(exit_code.into()), @@ -82,7 +81,7 @@ fn ffi(state: &Cheatcodes, args: &[String]) -> Result { let output = String::from_utf8(output.stdout)?; let trimmed = output.trim(); - if let Ok(hex) = hex::decode(trimmed.strip_prefix("0x").unwrap_or(trimmed)) { + if let Ok(hex) = hex::decode(trimmed) { Ok(abi::encode(&[Token::Bytes(hex)]).into()) } else { Ok(trimmed.encode().into()) diff --git a/crates/evm/src/executor/inspector/cheatcodes/util.rs b/crates/evm/src/executor/inspector/cheatcodes/util.rs index b3863c0a55c5d..3989421a70e09 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/util.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/util.rs @@ -439,7 +439,7 @@ fn parse_uint(s: &str) -> Result { } fn parse_bytes(s: &str) -> Result, String> { - hex::decode(s.strip_prefix("0x").unwrap_or(s)).map_err(|e| e.to_string()) + hex::decode(s).map_err(|e| e.to_string()) } pub fn parse_private_key(private_key: U256) -> Result { From 7f2dae3898b5ea36811f581e68543c8886630efe Mon Sep 17 00:00:00 2001 From: Igor Line Date: Thu, 24 Aug 2023 15:44:04 +0000 Subject: [PATCH 0035/1963] fix(cast): append extra 0 to prefix to avoid getting wrong hex strings (#5714) --- crates/cast/bin/cmd/create2.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index e7da7bd0cbb89..e51cdd91df9c0 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -158,7 +158,7 @@ impl Create2Args { fn get_regex_hex_string(s: String) -> Result { let s = s.strip_prefix("0x").unwrap_or(&s); let pad_width = s.len() + s.len() % 2; - hex::decode(format!("{s:0>pad_width$}"))?; + hex::decode(format!("{s:0 Date: Thu, 24 Aug 2023 20:18:20 +0200 Subject: [PATCH 0036/1963] fix: do not run proc-macro tests (#5717) --- crates/macros/impl/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/macros/impl/Cargo.toml b/crates/macros/impl/Cargo.toml index aea855be63a48..f2b4e70a7e932 100644 --- a/crates/macros/impl/Cargo.toml +++ b/crates/macros/impl/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true [lib] proc-macro = true +# proc-macro tests aren't fully supported by cargo-nextest archives +test = false +doc = false [dependencies] proc-macro2 = "1.0" From 95a93cd397f25f3f8d49d2851eb52bc2d52dd983 Mon Sep 17 00:00:00 2001 From: Ruvaag Date: Fri, 25 Aug 2023 02:44:18 +0530 Subject: [PATCH 0037/1963] feat: add exists, isFile, and isDir cheatcodes (#5719) --- crates/abi/abi/HEVM.sol | 3 + crates/abi/src/bindings/hevm.rs | 210 ++++++++++++++++++ .../src/executor/inspector/cheatcodes/fs.rs | 42 ++++ testdata/cheats/Fs.t.sol | 66 ++++++ testdata/cheats/Vm.sol | 9 + 5 files changed, 330 insertions(+) diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index 355eef58024ac..c59df22510d52 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -146,6 +146,9 @@ readDir(string, uint64)(DirEntry[]) readDir(string, uint64, bool)(DirEntry[]) readLink(string)(string) fsMetadata(string)(FsMetadata) +exists(string)(bool) +isFile(string)(bool) +isDir(string)(bool) toString(bytes) toString(address) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index 74e896643d4d1..ab2a1899a26df 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -1602,6 +1602,30 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("exists"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("exists"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Bool, + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("expectCall"), ::std::vec![ @@ -2297,6 +2321,54 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("isDir"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("isDir"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Bool, + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), + ( + ::std::borrow::ToOwned::to_owned("isFile"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("isFile"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Bool, + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("isPersistent"), ::std::vec![ @@ -5874,6 +5946,15 @@ pub mod hevm { .method_hash([53, 225, 52, 155], (p0, p1, p2, p3)) .expect("method not found (this should never happen)") } + ///Calls the contract's `exists` (0x261a323e) function + pub fn exists( + &self, + p0: ::std::string::String, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([38, 26, 50, 62], p0) + .expect("method not found (this should never happen)") + } ///Calls the contract's `expectCall` (0xbd6af434) function pub fn expect_call_0( &self, @@ -6179,6 +6260,24 @@ pub mod hevm { .method_hash([25, 21, 83, 164], ()) .expect("method not found (this should never happen)") } + ///Calls the contract's `isDir` (0x7d15d019) function + pub fn is_dir( + &self, + p0: ::std::string::String, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([125, 21, 208, 25], p0) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `isFile` (0xe0eb04d4) function + pub fn is_file( + &self, + p0: ::std::string::String, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([224, 235, 4, 212], p0) + .expect("method not found (this should never happen)") + } ///Calls the contract's `isPersistent` (0xd92d8efd) function pub fn is_persistent( &self, @@ -8217,6 +8316,19 @@ pub mod hevm { pub ::ethers_core::types::Address, pub ::std::vec::Vec<[u8; 32]>, ); + ///Container type for all input parameters for the `exists` function with signature `exists(string)` and selector `0x261a323e` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "exists", abi = "exists(string)")] + pub struct ExistsCall(pub ::std::string::String); ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,bytes)` and selector `0xbd6af434` #[derive( Clone, @@ -8663,6 +8775,32 @@ pub mod hevm { )] #[ethcall(name = "getRecordedLogs", abi = "getRecordedLogs()")] pub struct GetRecordedLogsCall; + ///Container type for all input parameters for the `isDir` function with signature `isDir(string)` and selector `0x7d15d019` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "isDir", abi = "isDir(string)")] + pub struct IsDirCall(pub ::std::string::String); + ///Container type for all input parameters for the `isFile` function with signature `isFile(string)` and selector `0xe0eb04d4` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "isFile", abi = "isFile(string)")] + pub struct IsFileCall(pub ::std::string::String); ///Container type for all input parameters for the `isPersistent` function with signature `isPersistent(address)` and selector `0xd92d8efd` #[derive( Clone, @@ -10396,6 +10534,7 @@ pub mod hevm { EnvUint1(EnvUint1Call), Etch(EtchCall), EthGetLogs(EthGetLogsCall), + Exists(ExistsCall), ExpectCall0(ExpectCall0Call), ExpectCall1(ExpectCall1Call), ExpectCall2(ExpectCall2Call), @@ -10425,6 +10564,8 @@ pub mod hevm { GetNonce0(GetNonce0Call), GetNonce1(GetNonce1Call), GetRecordedLogs(GetRecordedLogsCall), + IsDir(IsDirCall), + IsFile(IsFileCall), IsPersistent(IsPersistentCall), KeyExists(KeyExistsCall), Label(LabelCall), @@ -10798,6 +10939,10 @@ pub mod hevm { = ::decode(data) { return Ok(Self::EthGetLogs(decoded)); } + if let Ok(decoded) + = ::decode(data) { + return Ok(Self::Exists(decoded)); + } if let Ok(decoded) = ::decode(data) { return Ok(Self::ExpectCall0(decoded)); @@ -10922,6 +11067,14 @@ pub mod hevm { = ::decode(data) { return Ok(Self::GetRecordedLogs(decoded)); } + if let Ok(decoded) + = ::decode(data) { + return Ok(Self::IsDir(decoded)); + } + if let Ok(decoded) + = ::decode(data) { + return Ok(Self::IsFile(decoded)); + } if let Ok(decoded) = ::decode(data) { return Ok(Self::IsPersistent(decoded)); @@ -11555,6 +11708,7 @@ pub mod hevm { Self::EthGetLogs(element) => { ::ethers_core::abi::AbiEncode::encode(element) } + Self::Exists(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::ExpectCall0(element) => { ::ethers_core::abi::AbiEncode::encode(element) } @@ -11634,6 +11788,8 @@ pub mod hevm { Self::GetRecordedLogs(element) => { ::ethers_core::abi::AbiEncode::encode(element) } + Self::IsDir(element) => ::ethers_core::abi::AbiEncode::encode(element), + Self::IsFile(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::IsPersistent(element) => { ::ethers_core::abi::AbiEncode::encode(element) } @@ -11996,6 +12152,7 @@ pub mod hevm { Self::EnvUint1(element) => ::core::fmt::Display::fmt(element, f), Self::Etch(element) => ::core::fmt::Display::fmt(element, f), Self::EthGetLogs(element) => ::core::fmt::Display::fmt(element, f), + Self::Exists(element) => ::core::fmt::Display::fmt(element, f), Self::ExpectCall0(element) => ::core::fmt::Display::fmt(element, f), Self::ExpectCall1(element) => ::core::fmt::Display::fmt(element, f), Self::ExpectCall2(element) => ::core::fmt::Display::fmt(element, f), @@ -12029,6 +12186,8 @@ pub mod hevm { Self::GetNonce0(element) => ::core::fmt::Display::fmt(element, f), Self::GetNonce1(element) => ::core::fmt::Display::fmt(element, f), Self::GetRecordedLogs(element) => ::core::fmt::Display::fmt(element, f), + Self::IsDir(element) => ::core::fmt::Display::fmt(element, f), + Self::IsFile(element) => ::core::fmt::Display::fmt(element, f), Self::IsPersistent(element) => ::core::fmt::Display::fmt(element, f), Self::KeyExists(element) => ::core::fmt::Display::fmt(element, f), Self::Label(element) => ::core::fmt::Display::fmt(element, f), @@ -12470,6 +12629,11 @@ pub mod hevm { Self::EthGetLogs(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: ExistsCall) -> Self { + Self::Exists(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: ExpectCall0Call) -> Self { Self::ExpectCall0(value) @@ -12615,6 +12779,16 @@ pub mod hevm { Self::GetRecordedLogs(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: IsDirCall) -> Self { + Self::IsDir(value) + } + } + impl ::core::convert::From for HEVMCalls { + fn from(value: IsFileCall) -> Self { + Self::IsFile(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: IsPersistentCall) -> Self { Self::IsPersistent(value) @@ -13778,6 +13952,18 @@ pub mod hevm { ), >, ); + ///Container type for all return fields from the `exists` function with signature `exists(string)` and selector `0x261a323e` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct ExistsReturn(pub bool); ///Container type for all return fields from the `ffi` function with signature `ffi(string[])` and selector `0x89160467` #[derive( Clone, @@ -13850,6 +14036,30 @@ pub mod hevm { pub struct GetRecordedLogsReturn( pub ::std::vec::Vec<(::std::vec::Vec<[u8; 32]>, ::ethers_core::types::Bytes)>, ); + ///Container type for all return fields from the `isDir` function with signature `isDir(string)` and selector `0x7d15d019` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct IsDirReturn(pub bool); + ///Container type for all return fields from the `isFile` function with signature `isFile(string)` and selector `0xe0eb04d4` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct IsFileReturn(pub bool); ///Container type for all return fields from the `isPersistent` function with signature `isPersistent(address)` and selector `0xd92d8efd` #[derive( Clone, diff --git a/crates/evm/src/executor/inspector/cheatcodes/fs.rs b/crates/evm/src/executor/inspector/cheatcodes/fs.rs index e6616c30341fa..26a6a97744cab 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fs.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fs.rs @@ -250,6 +250,45 @@ fn fs_metadata(state: &Cheatcodes, path: impl AsRef) -> Result { Ok(metadata.encode().into()) } +/// Verifies if a given path points to a valid entity +/// +/// This function will return `true` if `path` points to a valid filesystem entity, otherwise it +/// will return `false` +/// +/// Note: This function does not verify if a user has necessary permissions to access the path, +/// only that such a path exists +fn exists(path: impl AsRef) -> Result { + let path = path.as_ref(); + + Ok(abi::encode(&[Token::Bool(path.exists())]).into()) +} + +/// Verifies if a given path exists on disk and points at a regular file +/// +/// This function will return `true` if `path` points to a regular file that exists on the disk, +/// otherwise it will return `false` +/// +/// Note: This function does not verify if a user has necessary permissions to access the file, +/// only that such a file exists on disk +fn is_file(path: impl AsRef) -> Result { + let path = path.as_ref(); + + Ok(abi::encode(&[Token::Bool(path.is_file())]).into()) +} + +/// Verifies if a given path exists on disk and points at a directory +/// +/// This function will return `true` if `path` points to a directory that exists on the disk, +/// otherwise it will return `false` +/// +/// Note: This function does not verify if a user has necessary permissions to access the directory, +/// only that such a directory exists +fn is_dir(path: impl AsRef) -> Result { + let path = path.as_ref(); + + Ok(abi::encode(&[Token::Bool(path.is_dir())]).into()) +} + #[instrument(level = "error", name = "fs", target = "evm::cheatcodes", skip_all)] pub fn apply(state: &mut Cheatcodes, call: &HEVMCalls) -> Option { let res = match call { @@ -270,6 +309,9 @@ pub fn apply(state: &mut Cheatcodes, call: &HEVMCalls) -> Option { HEVMCalls::ReadDir0(inner) => read_dir(state, &inner.0, 1, false), HEVMCalls::ReadDir1(inner) => read_dir(state, &inner.0, inner.1, false), HEVMCalls::ReadDir2(inner) => read_dir(state, &inner.0, inner.1, inner.2), + HEVMCalls::Exists(inner) => exists(&inner.0), + HEVMCalls::IsFile(inner) => is_file(&inner.0), + HEVMCalls::IsDir(inner) => is_dir(&inner.0), _ => return None, }; diff --git a/testdata/cheats/Fs.t.sol b/testdata/cheats/Fs.t.sol index 81aec047f7080..5110e362d3f6a 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/cheats/Fs.t.sol @@ -50,6 +50,24 @@ contract FsProxy is DSTest { function createDir(string calldata path, bool recursive) external { return vm.createDir(path, recursive); } + + /// @notice Verifies if a given path exists on the disk + /// @dev Returns true if the given path points to an existing entity, else returns false + function exists(string calldata path) external returns (bool) { + return vm.exists(path); + } + + /// @notice Verifies if a given path points at a file + /// @dev Returns true if the given path points at a regular file, else returns false + function isFile(string calldata path) external returns (bool) { + return vm.isFile(path); + } + + /// @notice Verifies if a given path points at a directory + /// @dev Returns true if the given path points at a directory, else returns false + function isDir(string calldata path) external returns (bool) { + return vm.isDir(path); + } } contract FsTest is DSTest { @@ -307,4 +325,52 @@ contract FsTest is DSTest { assertEq(err, abi.encodeWithSignature("CheatCodeError", FOUNDRY_READ_ERR)); } } + + function testExists() public { + fsProxy = new FsProxy(); + + string memory validFilePath = "fixtures/File/read.txt"; + assertTrue(vm.exists(validFilePath)); + assertTrue(fsProxy.exists(validFilePath)); + + string memory validDirPath = "fixtures/File"; + assertTrue(vm.exists(validDirPath)); + assertTrue(fsProxy.exists(validDirPath)); + + string memory invalidPath = "fixtures/File/invalidfile.txt"; + assertTrue(vm.exists(invalidPath) == false); + assertTrue(fsProxy.exists(invalidPath) == false); + } + + function testIsFile() public { + fsProxy = new FsProxy(); + + string memory validFilePath = "fixtures/File/read.txt"; + assertTrue(vm.isFile(validFilePath)); + assertTrue(fsProxy.isFile(validFilePath)); + + string memory invalidFilePath = "fixtures/File/invalidfile.txt"; + assertTrue(vm.isFile(invalidFilePath) == false); + assertTrue(fsProxy.isFile(invalidFilePath) == false); + + string memory dirPath = "fixtures/File"; + assertTrue(vm.isFile(dirPath) == false); + assertTrue(fsProxy.isFile(dirPath) == false); + } + + function testIsDir() public { + fsProxy = new FsProxy(); + + string memory validDirPath = "fixtures/File"; + assertTrue(vm.isDir(validDirPath)); + assertTrue(fsProxy.isDir(validDirPath)); + + string memory invalidDirPath = "fixtures/InvalidDir"; + assertTrue(vm.isDir(invalidDirPath) == false); + assertTrue(fsProxy.isDir(invalidDirPath) == false); + + string memory filePath = "fixtures/File/read.txt"; + assertTrue(vm.isDir(filePath) == false); + assertTrue(fsProxy.isDir(filePath) == false); + } } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 5c0368e24ea71..fa22bac6b2951 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -667,4 +667,13 @@ interface Vm { // Gets the map key and parent of a mapping at a given slot, for a given address. function getMappingKeyAndParentOf(address target, bytes32 slot) external returns (bool, bytes32, bytes32); + + // Returns true if the given path points to an existing entity, else returns false + function exists(string calldata path) external returns (bool); + + // Returns true if the path exists on disk and is pointing at a regular file, else returns false + function isFile(string calldata path) external returns (bool); + + // Returns true if the path exists on disk and is pointing at a directory, else returns false + function isDir(string calldata path) external returns (bool); } From ae3ec74234fe30a88279b3850c99ff191f373781 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:49:47 +0200 Subject: [PATCH 0038/1963] chore: bump ethers and solang-parser (#5725) --- Cargo.lock | 63 ++++++++++++++--------------- Cargo.toml | 2 +- crates/chisel/src/session_source.rs | 6 ++- crates/fmt/src/formatter.rs | 28 +++++++------ crates/fmt/src/helpers.rs | 7 ++++ crates/fmt/src/solang_ext/ast_eq.rs | 6 +++ crates/fmt/src/solang_ext/loc.rs | 9 +++++ crates/fmt/src/solang_ext/mod.rs | 12 +++--- crates/fmt/src/visit.rs | 6 +-- 9 files changed, 83 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f4526452a1d3..2b384951b10a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1882,8 +1882,8 @@ dependencies = [ [[package]] name = "ethers" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1897,8 +1897,8 @@ dependencies = [ [[package]] name = "ethers-addressbook" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "ethers-core", "once_cell", @@ -1908,8 +1908,8 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -1926,8 +1926,8 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "Inflector", "const-hex", @@ -1949,8 +1949,8 @@ dependencies = [ [[package]] name = "ethers-contract-derive" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "Inflector", "const-hex", @@ -1964,8 +1964,8 @@ dependencies = [ [[package]] name = "ethers-core" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "arrayvec", "bytes", @@ -1993,8 +1993,8 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "ethers-core", "ethers-solc", @@ -2008,8 +2008,8 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "async-trait", "auto_impl", @@ -2034,8 +2034,8 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "async-trait", "auto_impl", @@ -2059,7 +2059,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-tungstenite 0.19.0", + "tokio-tungstenite 0.20.0", "tracing", "tracing-futures", "url", @@ -2072,8 +2072,8 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "async-trait", "coins-bip32", @@ -2099,8 +2099,8 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.8" -source = "git+https://github.com/gakonst/ethers-rs#7603af021be920ca39b610f88c0012328b337cd6" +version = "2.0.9" +source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" dependencies = [ "cfg-if", "const-hex", @@ -6215,11 +6215,11 @@ dependencies = [ [[package]] name = "solang-parser" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c792fe9fae2a2f716846f214ca10d5a1e21133e0bf36cef34bcc4a852467b21" +checksum = "7cb9fa2fa2fa6837be8a2495486ff92e3ffe68a99b6eeba288e139efdd842457" dependencies = [ - "itertools 0.10.5", + "itertools 0.11.0", "lalrpop", "lalrpop-util", "phf 0.11.2", @@ -6694,9 +6694,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec509ac96e9a0c43427c74f003127d953a265737636129424288d27cb5c4b12c" +checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2" dependencies = [ "futures-util", "log", @@ -6705,7 +6705,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", - "tungstenite 0.19.0", + "tungstenite 0.20.0", "webpki-roots 0.23.1", ] @@ -7015,9 +7015,9 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" +checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649" dependencies = [ "byteorder", "bytes", @@ -7032,7 +7032,6 @@ dependencies = [ "thiserror", "url", "utf-8", - "webpki", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index daa47cfd0170c..7a1564785042e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -139,7 +139,7 @@ ethers-solc = { git = "https://github.com/gakonst/ethers-rs", default-features = chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.11" -solang-parser = "=0.3.1" +solang-parser = "=0.3.2" #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index c7bea2b5fd567..33b7caf7b4d44 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -513,7 +513,11 @@ contract {} {{ pt::Import::Plain(s, _) | pt::Import::Rename(s, _, _) | pt::Import::GlobalSymbol(s, _, _) => { - let path = PathBuf::from(s.string); + let s = match s { + pt::ImportPath::Filename(s) => s.string.clone(), + pt::ImportPath::Path(p) => p.to_string(), + }; + let path = PathBuf::from(s); match fs::read_to_string(path) { Ok(source) => { diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 60bb6d4e256ee..9303ff768dd7d 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -6,6 +6,7 @@ use crate::{ comments::{ CommentPosition, CommentState, CommentStringExt, CommentType, CommentWithMetadata, Comments, }, + helpers::import_path_string, macros::*, solang_ext::{pt::*, *}, string::{QuoteState, QuotedStringExt}, @@ -15,6 +16,7 @@ use crate::{ use ethers_core::{types::H160, utils::to_checksum}; use foundry_config::fmt::{MultilineFuncHeaderStyle, SingleLineBlockStyle}; use itertools::{Either, Itertools}; +use solang_parser::pt::ImportPath; use std::{fmt::Write, str::FromStr}; use thiserror::Error; @@ -1810,12 +1812,12 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { } #[instrument(name = "import_plain", skip_all)] - fn visit_import_plain(&mut self, loc: Loc, import: &mut StringLiteral) -> Result<()> { + fn visit_import_plain(&mut self, loc: Loc, import: &mut ImportPath) -> Result<()> { return_source_if_disabled!(self, loc, ';'); self.grouped(|fmt| { - write_chunk!(fmt, loc.start(), import.loc.start(), "import")?; - fmt.write_quoted_str(import.loc, None, &import.string)?; + write_chunk!(fmt, loc.start(), import.loc().start(), "import")?; + fmt.write_quoted_str(import.loc(), None, &import_path_string(import))?; fmt.write_semicolon()?; Ok(()) })?; @@ -1826,14 +1828,14 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { fn visit_import_global( &mut self, loc: Loc, - global: &mut StringLiteral, + global: &mut ImportPath, alias: &mut Identifier, ) -> Result<()> { return_source_if_disabled!(self, loc, ';'); self.grouped(|fmt| { - write_chunk!(fmt, loc.start(), global.loc.start(), "import")?; - fmt.write_quoted_str(global.loc, None, &global.string)?; + write_chunk!(fmt, loc.start(), global.loc().start(), "import")?; + fmt.write_quoted_str(global.loc(), None, &import_path_string(global))?; write_chunk!(fmt, loc.start(), alias.loc.start(), "as")?; alias.visit(fmt)?; fmt.write_semicolon()?; @@ -1847,7 +1849,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { &mut self, loc: Loc, imports: &mut [(Identifier, Option)], - from: &mut StringLiteral, + from: &mut ImportPath, ) -> Result<()> { return_source_if_disabled!(self, loc, ';'); @@ -1855,8 +1857,8 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { self.grouped(|fmt| { write_chunk!(fmt, loc.start(), "import")?; fmt.write_empty_brackets()?; - write_chunk!(fmt, loc.start(), from.loc.start(), "from")?; - fmt.write_quoted_str(from.loc, None, &from.string)?; + write_chunk!(fmt, loc.start(), from.loc().start(), "from")?; + fmt.write_quoted_str(from.loc(), None, &import_path_string(from))?; fmt.write_semicolon()?; Ok(()) })?; @@ -1869,7 +1871,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { self.surrounded( SurroundingChunk::new("{", Some(imports_start), None), - SurroundingChunk::new("}", None, Some(from.loc.start())), + SurroundingChunk::new("}", None, Some(from.loc().start())), |fmt, _multiline| { let mut imports = imports.iter_mut().peekable(); let mut import_chunks = Vec::new(); @@ -1892,7 +1894,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { } let multiline = fmt.are_chunks_separated_multiline( - &format!("{{}} }} from \"{}\";", from.string), + &format!("{{}} }} from \"{}\";", import_path_string(from)), &import_chunks, ",", )?; @@ -1902,8 +1904,8 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { )?; self.grouped(|fmt| { - write_chunk!(fmt, imports_start, from.loc.start(), "from")?; - fmt.write_quoted_str(from.loc, None, &from.string)?; + write_chunk!(fmt, imports_start, from.loc().start(), "from")?; + fmt.write_quoted_str(from.loc(), None, &import_path_string(from))?; fmt.write_semicolon()?; Ok(()) })?; diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index d419b88a9d4a3..719f85d80160a 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -98,3 +98,10 @@ pub fn print_diagnostics_report( } Ok(()) } + +pub fn import_path_string(path: &ImportPath) -> String { + match path { + ImportPath::Filename(s) => s.string.clone(), + ImportPath::Path(p) => p.to_string(), + } +} diff --git a/crates/fmt/src/solang_ext/ast_eq.rs b/crates/fmt/src/solang_ext/ast_eq.rs index 7beef80a711e2..1258f94ea0d44 100644 --- a/crates/fmt/src/solang_ext/ast_eq.rs +++ b/crates/fmt/src/solang_ext/ast_eq.rs @@ -629,6 +629,12 @@ derive_ast_eq! { enum SourceUnitPart { Annotation(annotation), _ }} +derive_ast_eq! { enum ImportPath { + _ + Filename(lit), + Path(path), + _ +}} derive_ast_eq! { enum Import { _ Plain(string, loc), diff --git a/crates/fmt/src/solang_ext/loc.rs b/crates/fmt/src/solang_ext/loc.rs index e8b3184e8fa82..2fcbaf995b4f3 100644 --- a/crates/fmt/src/solang_ext/loc.rs +++ b/crates/fmt/src/solang_ext/loc.rs @@ -81,6 +81,15 @@ impl CodeLocationExt for pt::SourceUnitPart { } } +impl CodeLocationExt for pt::ImportPath { + fn loc(&self) -> pt::Loc { + match self { + Self::Filename(s) => s.loc(), + Self::Path(i) => i.loc(), + } + } +} + macro_rules! impl_delegate { ($($t:ty),+ $(,)?) => {$( impl CodeLocationExt for $t { diff --git a/crates/fmt/src/solang_ext/mod.rs b/crates/fmt/src/solang_ext/mod.rs index 2a34c1a349b93..aa4fe734ee64f 100644 --- a/crates/fmt/src/solang_ext/mod.rs +++ b/crates/fmt/src/solang_ext/mod.rs @@ -10,12 +10,12 @@ pub mod pt { Annotation, Base, CatchClause, Comment, ContractDefinition, ContractPart, ContractTy, EnumDefinition, ErrorDefinition, ErrorParameter, EventDefinition, EventParameter, Expression, FunctionAttribute, FunctionDefinition, FunctionTy, HexLiteral, Identifier, - IdentifierPath, Import, Loc, Mutability, NamedArgument, OptionalCodeLocation, Parameter, - ParameterList, SourceUnit, SourceUnitPart, Statement, StorageLocation, StringLiteral, - StructDefinition, Type, TypeDefinition, UserDefinedOperator, Using, UsingFunction, - UsingList, VariableAttribute, VariableDeclaration, VariableDefinition, Visibility, - YulBlock, YulExpression, YulFor, YulFunctionCall, YulFunctionDefinition, YulStatement, - YulSwitch, YulSwitchOptions, YulTypedIdentifier, + IdentifierPath, Import, ImportPath, Loc, Mutability, NamedArgument, OptionalCodeLocation, + Parameter, ParameterList, SourceUnit, SourceUnitPart, Statement, StorageLocation, + StringLiteral, StructDefinition, Type, TypeDefinition, UserDefinedOperator, Using, + UsingFunction, UsingList, VariableAttribute, VariableDeclaration, VariableDefinition, + Visibility, YulBlock, YulExpression, YulFor, YulFunctionCall, YulFunctionDefinition, + YulStatement, YulSwitch, YulSwitchOptions, YulTypedIdentifier, }; } diff --git a/crates/fmt/src/visit.rs b/crates/fmt/src/visit.rs index 6a80c8d12ea4e..e48f912e4a96f 100644 --- a/crates/fmt/src/visit.rs +++ b/crates/fmt/src/visit.rs @@ -37,7 +37,7 @@ pub trait Visitor { fn visit_import_plain( &mut self, _loc: Loc, - _import: &mut StringLiteral, + _import: &mut ImportPath, ) -> Result<(), Self::Error> { Ok(()) } @@ -45,7 +45,7 @@ pub trait Visitor { fn visit_import_global( &mut self, _loc: Loc, - _global: &mut StringLiteral, + _global: &mut ImportPath, _alias: &mut Identifier, ) -> Result<(), Self::Error> { Ok(()) @@ -55,7 +55,7 @@ pub trait Visitor { &mut self, _loc: Loc, _imports: &mut [(Identifier, Option)], - _from: &mut StringLiteral, + _from: &mut ImportPath, ) -> Result<(), Self::Error> { Ok(()) } From 7d21c646e9731eb6e3211cee4bab6b3c6f096c9c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Aug 2023 13:44:50 -0700 Subject: [PATCH 0039/1963] chore(deps): weekly `cargo update` (#5735) Updating git repository `https://github.com/bluealloy/revm/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating addr2line v0.20.0 -> v0.21.0 Updating anstream v0.3.2 -> v0.5.0 Updating anstyle v1.0.1 -> v1.0.2 Updating anstyle-wincon v1.0.2 -> v2.1.0 Updating backtrace v0.3.68 -> v0.3.69 Updating base64 v0.21.2 -> v0.21.3 Updating bech32 v0.7.3 -> v0.9.1 Removing bincode v1.3.3 Removing bitvec v0.17.4 Updating bs58 v0.4.0 -> v0.5.0 Updating clap v4.3.23 -> v4.4.0 Updating clap_builder v4.3.23 -> v4.4.0 Updating clap_complete v4.3.2 -> v4.4.0 Updating clap_complete_fig v4.3.1 -> v4.4.0 Updating clap_derive v4.3.12 -> v4.4.0 Updating clap_lex v0.5.0 -> v0.5.1 Updating coins-bip32 v0.8.3 -> v0.8.7 Updating coins-bip39 v0.8.6 -> v0.8.7 Updating coins-core v0.8.3 -> v0.8.7 Updating coins-ledger v0.8.3 -> v0.8.7 Updating encoding_rs v0.8.32 -> v0.8.33 Updating gimli v0.27.3 -> v0.28.0 Updating num-bigint v0.4.3 -> v0.4.4 Updating object v0.31.1 -> v0.32.0 Updating ordered-float v3.9.0 -> v3.9.1 Updating pin-project-lite v0.2.12 -> v0.2.13 Updating portable-atomic v1.4.2 -> v1.4.3 Removing radium v0.3.0 Updating regex v1.9.3 -> v1.9.4 Updating regex-automata v0.3.6 -> v0.3.7 Updating regex-syntax v0.7.4 -> v0.7.5 Updating reqwest v0.11.19 -> v0.11.20 Updating rusb v0.9.2 -> v0.9.3 Updating rustix v0.38.8 -> v0.38.9 Updating serde v1.0.171 -> v1.0.188 Updating serde_derive v1.0.171 -> v1.0.188 Updating siphasher v0.3.10 -> v0.3.11 Updating time v0.3.26 -> v0.3.27 Updating time-macros v0.2.12 -> v0.2.13 Updating winnow v0.5.14 -> v0.5.15 Co-authored-by: mattsse --- Cargo.lock | 218 +++++++++++++++++++++++------------------------------ 1 file changed, 95 insertions(+), 123 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b384951b10a5..ac80fba9c1bc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -122,24 +122,23 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle-parse" @@ -161,9 +160,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -553,9 +552,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -580,9 +579,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -592,18 +591,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bech32" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1" - -[[package]] -name = "bincode" -version = "1.3.3" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" [[package]] name = "bit-set" @@ -635,16 +625,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitvec" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" -dependencies = [ - "either", - "radium 0.3.0", -] - [[package]] name = "bitvec" version = "1.0.1" @@ -652,7 +632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", - "radium 0.7.0", + "radium", "serde", "tap", "wyz", @@ -678,11 +658,12 @@ dependencies = [ [[package]] name = "bs58" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ - "sha2 0.9.9", + "sha2 0.10.7", + "tinyvec", ] [[package]] @@ -692,7 +673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", - "regex-automata 0.3.6", + "regex-automata 0.3.7", "serde", ] @@ -949,9 +930,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.23" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" +checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" dependencies = [ "clap_builder", "clap_derive", @@ -960,9 +941,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.23" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" +checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" dependencies = [ "anstream", "anstyle", @@ -976,18 +957,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.3.2" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" +checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "4.3.1" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fee1d30a51305a6c2ed3fc5709be3c8af626c9c958e04dd9ae94e27bcbce9f" +checksum = "9e9bae21b3f6eb417ad3054c8b1094aa0542116eba4979b1b271baefbfa6b965" dependencies = [ "clap", "clap_complete", @@ -995,9 +976,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" dependencies = [ "heck", "proc-macro2", @@ -1007,9 +988,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "clearscreen" @@ -1037,18 +1018,15 @@ dependencies = [ [[package]] name = "coins-bip32" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30a84aab436fcb256a2ab3c80663d8aec686e6bae12827bb05fef3e1e439c9f" +checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" dependencies = [ - "bincode", "bs58", "coins-core", "digest 0.10.7", - "getrandom 0.2.10", "hmac 0.12.1", "k256", - "lazy_static", "serde", "sha2 0.10.7", "thiserror", @@ -1056,13 +1034,12 @@ dependencies = [ [[package]] name = "coins-bip39" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f4d04ee18e58356accd644896aeb2094ddeafb6a713e056cef0c0a8e468c15" +checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" dependencies = [ - "bitvec 0.17.4", + "bitvec", "coins-bip32", - "getrandom 0.2.10", "hmac 0.12.1", "once_cell", "pbkdf2 0.12.2", @@ -1073,11 +1050,11 @@ dependencies = [ [[package]] name = "coins-core" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b949a1c63fb7eb591eb7ba438746326aedf0ae843e51ec92ba6bec5bb382c4f" +checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bech32", "bs58", "digest 0.10.7", @@ -1093,14 +1070,15 @@ dependencies = [ [[package]] name = "coins-ledger" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863cc93703bfc6f02f4401b42663b767783179f4080d89a0c4876766c7c0fb78" +checksum = "8fa6094030951ce3efad50fdba0efe088a93ffe05ec58c2f47cc60d9e90c715d" dependencies = [ "async-trait", "byteorder", "cfg-if", "futures", + "getrandom 0.2.10", "hex", "hidapi-rusb", "js-sys", @@ -1704,9 +1682,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -1723,7 +1701,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0be7b2ac146c1f99fe245c02d16af0696450d8e06c135db75e10eeb9e642c20d" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bytes", "hex", "k256", @@ -2039,7 +2017,7 @@ source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d26 dependencies = [ "async-trait", "auto_impl", - "base64 0.21.2", + "base64 0.21.3", "bytes", "const-hex", "enr", @@ -2197,7 +2175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.8", + "rustix 0.38.9", "windows-sys 0.48.0", ] @@ -2819,9 +2797,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "git2" @@ -3625,7 +3603,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.8", + "rustix 0.38.9", "windows-sys 0.48.0", ] @@ -3688,7 +3666,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "pem", "ring", "serde", @@ -3765,7 +3743,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", "string_cache", "term", "tiny-keccak", @@ -4206,9 +4184,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -4315,9 +4293,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.31.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" dependencies = [ "memchr", ] @@ -4428,9 +4406,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "3.9.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126d3e6f3926bfb0fb24495b4f4da50626f547e54956594748e3d8882a0320b4" +checksum = "2a54938017eacd63036332b4ae5c8a49fc8c0c1d6d629893057e4f13609edd06" dependencies = [ "num-traits", ] @@ -4454,7 +4432,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec", - "bitvec 1.0.1", + "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", @@ -4794,9 +4772,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -4850,9 +4828,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f32154ba0af3a075eefa1eda8bb414ee928f62303a54ea85b8d6638ff1a6ee9e" +checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" [[package]] name = "ppv-lite86" @@ -5033,12 +5011,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" - [[package]] name = "radium" version = "0.7.0" @@ -5217,14 +5189,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.6", - "regex-syntax 0.7.4", + "regex-automata 0.3.7", + "regex-syntax 0.7.5", ] [[package]] @@ -5238,13 +5210,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", ] [[package]] @@ -5255,17 +5227,17 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "reqwest" -version = "0.11.19" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20b9b67e2ca7dd9e9f9285b759de30ff538aab981abaaf7bc9bd90b84a0126c3" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bytes", "encoding_rs", "futures-core", @@ -5351,7 +5323,7 @@ source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f dependencies = [ "auto_impl", "bitflags 2.4.0", - "bitvec 1.0.1", + "bitvec", "bytes", "derive_more", "enumn", @@ -5475,9 +5447,9 @@ checksum = "e666a5496a0b2186dbcd0ff6106e29e093c15591bde62c20d3842007c6978a09" [[package]] name = "rusb" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44a8c36914f9b1a3be712c1dfa48c9b397131f9a75707e570a391735f785c5d1" +checksum = "45fff149b6033f25e825cbb7b2c625a11ee8e6dac09264d49beb125e39aa97bf" dependencies = [ "libc", "libusb1-sys", @@ -5612,9 +5584,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.8" +version = "0.38.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49" dependencies = [ "bitflags 2.4.0", "errno", @@ -5665,7 +5637,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", ] [[package]] @@ -5916,9 +5888,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -5936,9 +5908,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -6156,9 +6128,9 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" @@ -6435,7 +6407,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.8", + "rustix 0.38.9", "windows-sys 0.48.0", ] @@ -6525,9 +6497,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a79d09ac6b08c1ab3906a2f7cc2e81a0e27c7ae89c63812df75e52bef0751e07" +checksum = "0bb39ee79a6d8de55f48f2293a830e040392f1c5f16e336bdd1788cd0aadce07" dependencies = [ "deranged", "itoa", @@ -6546,9 +6518,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c65469ed6b3a4809d987a41eb1dc918e9bc1d92211cbad7ae82931846f7451" +checksum = "733d258752e9303d392b94b75230d07b0b9c489350c69b851fc6c065fde3e8f9" dependencies = [ "time-core", ] @@ -7613,9 +7585,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] From bff4ed912bb023d7bf9b20eda581aa4867a1cf70 Mon Sep 17 00:00:00 2001 From: Martin Beckmann Date: Mon, 28 Aug 2023 00:10:41 +0200 Subject: [PATCH 0040/1963] Make eth_accounts return impersonated accounts (#5734) * Return impersonated accounts * Return unique accounts in deterministic order --- crates/anvil/src/eth/api.rs | 12 ++++++++++-- crates/anvil/src/eth/backend/cheats.rs | 5 +++++ crates/anvil/tests/it/anvil_api.rs | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 19a28b4a5ac54..c0046ce2064a0 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -67,7 +67,7 @@ use foundry_evm::{ }; use futures::channel::mpsc::Receiver; use parking_lot::RwLock; -use std::{sync::Arc, time::Duration}; +use std::{collections::HashSet, sync::Arc, time::Duration}; use tracing::{trace, warn}; use super::{backend::mem::BlockRequest, sign::build_typed_transaction}; @@ -528,10 +528,18 @@ impl EthApi { /// Handler for ETH RPC call: `eth_accounts` pub fn accounts(&self) -> Result> { node_info!("eth_accounts"); + let mut unique = HashSet::new(); let mut accounts = Vec::new(); for signer in self.signers.iter() { - accounts.append(&mut signer.accounts()); + accounts.extend(signer.accounts().into_iter().filter(|acc| unique.insert(*acc))); } + accounts.extend( + self.backend + .cheats() + .impersonated_accounts() + .into_iter() + .filter(|acc| unique.insert(*acc)), + ); Ok(accounts) } diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 336f4672e8976..a207a0ce25b7b 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -60,6 +60,11 @@ impl CheatsManager { trace!(target: "cheats", "Auto impersonation set to {:?}", enabled); self.state.write().auto_impersonate_accounts = enabled } + + /// Returns all accounts that are currently being impersonated. + pub fn impersonated_accounts(&self) -> HashSet

{ + self.state.read().impersonated_accounts.clone() + } } /// Container type for all the state variables diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index a4213dc495d5b..d0e5873beba4e 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -82,6 +82,7 @@ async fn can_impersonate_account() { res.unwrap_err(); api.anvil_impersonate_account(impersonate).await.unwrap(); + assert!(api.accounts().unwrap().contains(&impersonate)); let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); assert_eq!(res.from, impersonate); From b678c8b0941ca98eecf1b8077e6856986221fdb8 Mon Sep 17 00:00:00 2001 From: Martin Beckmann Date: Tue, 29 Aug 2023 18:40:11 +0200 Subject: [PATCH 0041/1963] Add impersonated account while auto impersonating (#5740) * Add impersonated account while auto-impersonating * Extend unit test * Fix unit test * Add comment * Add more context to comment --- crates/anvil/src/eth/backend/cheats.rs | 3 +++ crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/tests/it/anvil_api.rs | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index a207a0ce25b7b..128ad440df6ae 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -27,6 +27,9 @@ impl CheatsManager { pub fn impersonate(&self, addr: Address) -> bool { trace!(target: "cheats", "Start impersonating {:?}", addr); let mut state = self.state.write(); + // When somebody **explicitly** impersonates an account we need to store it so we are able + // to return it from `eth_accounts`. That's why we do not simply call `is_impersonated()` + // which does not check that list when auto impersonation is enabeld. if state.impersonated_accounts.contains(&addr) { // need to check if already impersonated, so we don't overwrite the code return true diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 3b9a6bf263745..488e5f3f194fe 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -304,7 +304,7 @@ impl Backend { /// /// Returns `true` if the account is already impersonated pub async fn impersonate(&self, addr: Address) -> DatabaseResult { - if self.cheats.is_impersonated(addr) { + if self.cheats.impersonated_accounts().contains(&addr) { return Ok(true) } // Ensure EIP-3607 is disabled diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index d0e5873beba4e..9b8b51a178771 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -132,6 +132,10 @@ async fn can_auto_impersonate_account() { api.anvil_auto_impersonate_account(false).await.unwrap(); let res = provider.send_transaction(tx, None).await; res.unwrap_err(); + + // explicitly impersonated accounts get returned by `eth_accounts` + api.anvil_impersonate_account(impersonate).await.unwrap(); + assert!(api.accounts().unwrap().contains(&impersonate)); } #[tokio::test(flavor = "multi_thread")] From aaca7d34ff3896174f4b9830c8a17d22ef066129 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 29 Aug 2023 18:44:59 +0200 Subject: [PATCH 0042/1963] perf: use `jemalloc` as the global allocator on unix (#5690) --- Cargo.lock | 24 ++++++++++++++++++++++++ Cargo.toml | 1 + crates/anvil/Cargo.toml | 6 +++++- crates/anvil/src/anvil.rs | 4 ++++ crates/cast/Cargo.toml | 6 +++++- crates/cast/bin/main.rs | 4 ++++ crates/chisel/Cargo.toml | 6 +++++- crates/chisel/bin/main.rs | 4 ++++ crates/forge/Cargo.toml | 6 +++++- crates/forge/bin/main.rs | 4 ++++ 10 files changed, 61 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac80fba9c1bc1..684c151c88c5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,6 +205,7 @@ dependencies = [ "serde_json", "tempfile", "thiserror", + "tikv-jemallocator", "tokio", "tower", "tower-http 0.4.3", @@ -817,6 +818,7 @@ dependencies = [ "serde", "serde_json", "tempfile", + "tikv-jemallocator", "tokio", "tracing", "vergen", @@ -872,6 +874,7 @@ dependencies = [ "serial_test", "solang-parser", "strum 0.25.0", + "tikv-jemallocator", "time", "tokio", "vergen", @@ -2321,6 +2324,7 @@ dependencies = [ "strum 0.25.0", "svm-rs", "thiserror", + "tikv-jemallocator", "tokio", "tracing", "ui", @@ -6495,6 +6499,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.27" diff --git a/Cargo.toml b/Cargo.toml index 7a1564785042e..f131b57cd1005 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,6 +140,7 @@ chrono = { version = "0.4", default-features = false, features = ["clock", "std" hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.11" solang-parser = "=0.3.2" +tikv-jemallocator = "0.5.4" #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 9d7a24ba379ba..9f003b5e1b5ec 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -70,6 +70,9 @@ fdlimit = { version = "0.2", optional = true } clap_complete_fig = "4" ethereum-forkid = "0.12" +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] ethers = { workspace = true, features = ["abigen"] } ethers-solc = { workspace = true, features = ["project-util", "full"] } @@ -78,6 +81,7 @@ tokio = { version = "1", features = ["full"] } crc = "3.0.1" [features] -default = ["cli"] +default = ["cli", "jemalloc"] +jemalloc = ["dep:tikv-jemallocator"] cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"] cli = ["tokio/full", "cmd", "fdlimit"] diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index ebdb1fadb7975..c179fbcc27e03 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -2,6 +2,10 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + /// A fast local Ethereum development node. #[derive(Debug, Parser)] #[clap(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index d73c1cc1c0d7f..e752e113bc883 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -64,13 +64,17 @@ tokio = { version = "1", features = ["macros"] } tracing = "0.1" yansi = "0.5" +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] foundry-test-utils.workspace = true async-trait = "0.1" criterion = "0.5" [features] -default = ["rustls"] +default = ["rustls", "jemalloc"] +jemalloc = ["dep:tikv-jemallocator"] rustls = ["foundry-cli/rustls"] openssl = ["foundry-cli/openssl"] diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index a431b9213b9f7..88367ca9c65ee 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -25,6 +25,10 @@ pub mod opts; use opts::{Opts, Subcommands, ToBaseArgs}; +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + #[tokio::main] async fn main() -> Result<()> { utils::load_dotenv(); diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 679063eb1b1c9..bd910cc7786c0 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -49,13 +49,17 @@ dirs = "5" time = { version = "0.3", features = ["formatting"] } regex = "1" +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } serial_test = "2" once_cell = "1" [features] -default = ["rustls"] +default = ["rustls", "jemalloc"] +jemalloc = ["dep:tikv-jemallocator"] rustls = ["ethers/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["ethers/openssl", "reqwest/default-tls"] diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 55de1f0649edb..3b7f26a9c4cac 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -23,6 +23,10 @@ use foundry_config::{ use rustyline::{config::Configurer, error::ReadlineError, Editor}; use yansi::Paint; +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(ChiselParser, opts, evm_opts); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 4ee9e0805ecc1..958754b00472e 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -63,6 +63,9 @@ thiserror = "1" tokio = { version = "1", features = ["time"] } watchexec = "2" +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true @@ -75,7 +78,8 @@ serial_test = "2" svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } [features] -default = ["rustls"] +default = ["rustls", "jemalloc"] +jemalloc = ["dep:tikv-jemallocator"] rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-cli/openssl", "reqwest/default-tls"] diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 633b7b8002ef0..d311007f8134a 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -9,6 +9,10 @@ mod opts; use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; use opts::{Opts, Subcommands}; +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + fn main() -> Result<()> { utils::load_dotenv(); handler::install()?; From 1cb61404d670f064a64cb53c0a99640688df9957 Mon Sep 17 00:00:00 2001 From: Pranesh A S <42379522+PraneshASP@users.noreply.github.com> Date: Wed, 30 Aug 2023 02:36:21 +0800 Subject: [PATCH 0043/1963] =?UTF-8?q?=E2=9A=A1=20Improve=20test=20summary?= =?UTF-8?q?=20formatting=20(#5731)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: add colors to the test result * chore: remove redundant summary * chore: remove whitespace * chore: change skipped test count color to yellow * refactor: add test summary * chore: update fixtures * chore: update --------- Co-authored-by: Enrique Ortiz --- crates/forge/bin/cmd/test/mod.rs | 16 ++++++++++------ .../tests/fixtures/can_check_snapshot.stdout | 1 + .../can_run_test_in_custom_test_folder.stdout | 1 + .../tests/fixtures/can_test_repeatedly.stdout | 1 + .../fixtures/can_use_libs_in_multi_fork.stdout | 1 + ...ctly_once_with_changed_versions.0.8.10.stdout | 1 + ...ctly_once_with_changed_versions.0.8.13.stdout | 1 + 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index d1686f166a3a0..6bf9441ec3a43 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -397,13 +397,13 @@ impl TestOutcome { } println!(); } - let successes = self.successes().count(); println!( "Encountered a total of {} failing tests, {} tests succeeded", Paint::red(failures.to_string()), Paint::green(successes.to_string()) ); + std::process::exit(1); } @@ -419,9 +419,9 @@ impl TestOutcome { format!( "Test result: {}. {} passed; {} failed; {} skipped; finished in {:.2?}", result, - self.successes().count(), - failed, - self.skips().count(), + Paint::green(self.successes().count()), + Paint::red(failed), + Paint::yellow(self.skips().count()), self.duration() ) } @@ -472,8 +472,12 @@ fn format_aggregated_summary( ) -> String { let total_tests = total_passed + total_failed + total_skipped; format!( - "Ran {} test suites: {} tests passed, {} failed, {} skipped ({} total tests)", - num_test_suites, total_passed, total_failed, total_skipped, total_tests + " \nRan {} test suites: {} tests passed, {} failed, {} skipped ({} total tests)", + num_test_suites, + Paint::green(total_passed), + Paint::red(total_failed), + Paint::yellow(total_skipped), + total_tests ) } diff --git a/crates/forge/tests/fixtures/can_check_snapshot.stdout b/crates/forge/tests/fixtures/can_check_snapshot.stdout index 1cd927836ae65..6a5df56b3fca3 100644 --- a/crates/forge/tests/fixtures/can_check_snapshot.stdout +++ b/crates/forge/tests/fixtures/can_check_snapshot.stdout @@ -5,4 +5,5 @@ Compiler run successful! Running 1 test for src/ATest.t.sol:ATest [PASS] testExample() (gas: 168) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.42ms + Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout index 4becd823dbbea..28a027349260e 100644 --- a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout +++ b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout @@ -5,4 +5,5 @@ Compiler run successful! Running 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest [PASS] testTrue() (gas: 168) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93ms + Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout index 6cec559ab0430..9a044e74e69cb 100644 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ b/crates/forge/tests/fixtures/can_test_repeatedly.stdout @@ -4,4 +4,5 @@ Running 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) [PASS] test_Increment() (gas: 28357) Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms + Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout index 4d4022a5a4faf..3d5da024a361c 100644 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout @@ -5,4 +5,5 @@ Compiler run successful! Running 1 test for test/Contract.t.sol:ContractTest [PASS] test() (gas: 70373) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s + Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout index 478d164a65b45..3a027e1825bba 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout @@ -5,4 +5,5 @@ Compiler run successful! Running 1 test for src/Contract.t.sol:ContractTest [PASS] testExample() (gas: 190) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms + Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout index 16e259e943075..006c3cfc478ca 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout @@ -5,4 +5,5 @@ Compiler run successful! Running 1 test for src/Contract.t.sol:ContractTest [PASS] testExample() (gas: 190) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms + Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) From b73b3c31b210ea5ec7b007ba98e6b7c10e0a1898 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 29 Aug 2023 21:04:40 +0200 Subject: [PATCH 0044/1963] chore: bump msrv to 1.72 (#5738) * chore: bump msrv to 1.72 * update --- Cargo.toml | 2 +- clippy.toml | 1 + crates/common/src/term.rs | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 clippy.toml diff --git a/Cargo.toml b/Cargo.toml index f131b57cd1005..ed52a22b2859b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.71" +rust-version = "1.72" authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000000000..ebba0354acd0b --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +msrv = "1.72" diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 40f36da1fe65c..82dc5b29bf738 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -94,9 +94,6 @@ pub struct SpinnerReporter { solc_io_report: SolcCompilerIoReporter, } -// `mpsc::Sender: Sync` was stabilized in 1.72 https://github.com/rust-lang/rust/pull/111087 -unsafe impl Sync for SpinnerReporter {} - impl SpinnerReporter { /// Spawns the [`Spinner`] on a new thread /// From f3f9dc3816926ebecd307267e140f91b0cf61da7 Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Tue, 29 Aug 2023 21:08:58 +0200 Subject: [PATCH 0045/1963] feat(forge): allow invariant tests to target interfaces (#5605) * feat(forge): allow invariant tests to target proxy * removed toggle in setup * document combined map and rework invariant function * include interfaces * cleanup bytecode early exit * split logic into target_interfaces * chore: fmt * forge fmt --------- Co-authored-by: Enrique Ortiz --- crates/evm/src/fuzz/invariant/executor.rs | 52 ++++++++++++++ crates/forge/bin/cmd/script/build.rs | 6 +- crates/forge/src/multi_runner.rs | 18 ++--- crates/forge/tests/it/invariant.rs | 4 ++ crates/utils/src/lib.rs | 17 ++++- .../invariant/target/TargetInterfaces.t.sol | 72 +++++++++++++++++++ 6 files changed, 158 insertions(+), 11 deletions(-) create mode 100644 testdata/fuzz/invariant/target/TargetInterfaces.t.sol diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index 154bf729fb670..9aaa714ec7c77 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -429,11 +429,63 @@ impl<'a> InvariantExecutor<'a> { .map(|(addr, (identifier, abi))| (addr, (identifier, abi, vec![]))) .collect(); + self.target_interfaces(invariant_address, abi, &mut contracts)?; + self.select_selectors(invariant_address, abi, &mut contracts)?; Ok((SenderFilters::new(targeted_senders, excluded_senders), contracts)) } + /// Extends the contracts and selectors to fuzz with the addresses and ABIs specified in + /// `targetInterfaces() -> (address, string[])[]`. Enables targeting of addresses that are + /// not deployed during `setUp` such as when fuzzing in a forked environment. Also enables + /// targeting of delegate proxies and contracts deployed with `create` or `create2`. + pub fn target_interfaces( + &self, + invariant_address: Address, + abi: &Abi, + targeted_contracts: &mut TargetedContracts, + ) -> eyre::Result<()> { + let interfaces = + self.get_list::<(Address, Vec)>(invariant_address, abi, "targetInterfaces"); + + // Since `targetInterfaces` returns a tuple array there is no guarantee + // that the addresses are unique this map is used to merge functions of + // the specified interfaces for the same address. For example: + // `[(addr1, ["IERC20", "IOwnable"])]` and `[(addr1, ["IERC20"]), (addr1, ("IOwnable"))]` + // should be equivalent. + let mut combined: TargetedContracts = BTreeMap::new(); + + // Loop through each address and its associated artifact identifiers. + // We're borrowing here to avoid taking full ownership. + for (addr, identifiers) in &interfaces { + // Identifiers are specified as an array, so we loop through them. + for identifier in identifiers { + // Try to find the contract by name or identifier in the project's contracts. + if let Some((_, (abi, _))) = + self.project_contracts.find_by_name_or_identifier(identifier)? + { + combined + // Check if there's an entry for the given key in the 'combined' map. + .entry(*addr) + // If the entry exists, extends its ABI with the function list. + .and_modify(|entry| { + let (_, contract_abi, _) = entry; + + // Extend the ABI's function list with the new functions. + contract_abi.functions.extend(abi.functions.clone()); + }) + // Otherwise insert it into the map. + .or_insert_with(|| (identifier.clone(), abi.clone(), vec![])); + } + } + } + + targeted_contracts.extend(combined); + + Ok(()) + } + /// Selects the functions to fuzz based on the contract method `targetSelectors()` and /// `targetArtifactSelectors()`. pub fn select_selectors( diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index c905662af0b1a..e80a4ec922494 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -167,8 +167,10 @@ impl ScriptArgs { } } - let tc: ContractBytecode = contract.into(); - highlevel_known_contracts.insert(id, tc.unwrap()); + if let Ok(tc) = ContractBytecode::from(contract).try_into() { + highlevel_known_contracts.insert(id, tc); + } + Ok(()) }, project.root(), diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 24b06d63f088d..55b2c34e13646 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -277,15 +277,17 @@ impl MultiContractRunnerBuilder { } = post_link_input; let dependencies = unique_deps(dependencies); - // get bytes - let bytecode = - if let Some(b) = contract.bytecode.expect("No bytecode").object.into_bytes() { - b - } else { - return Ok(()) - }; - let abi = contract.abi.expect("We should have an abi by now"); + + // get bytes if deployable, else add to known contracts and return. + // interfaces and abstract contracts should be known to enable fuzzing of their ABI + // but they should not be deployable and their source code should be skipped by the + // debugger and linker. + let Some(bytecode) = contract.bytecode.and_then(|b| b.object.into_bytes()) else { + known_contracts.insert(id.clone(), (abi.clone(), vec![])); + return Ok(()) + }; + // if it's a test, add it to deployable contracts if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && abi.functions() diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 9b9bde915474a..291959f6cbceb 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -53,6 +53,10 @@ async fn test_invariant() { "fuzz/invariant/target/TargetSenders.t.sol:TargetSenders", vec![("invariantTrueWorld()", false, Some("false world.".into()), None, None)], ), + ( + "fuzz/invariant/target/TargetInterfaces.t.sol:TargetWorldInterfaces", + vec![("invariantTrueWorld()", false, Some("false world.".into()), None, None)], + ), ( "fuzz/invariant/target/ExcludeSenders.t.sol:ExcludeSenders", vec![("invariantTrueWorld()", true, None, None, None)], diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index df519a8d64590..b361ddc0bb9ee 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -226,7 +226,22 @@ pub fn link_with_nonce_or_address( } BytecodeObject::Bytecode(ref bytes) => { if bytes.as_ref().is_empty() { - // abstract, skip + // Handle case where bytecode bytes are empty + let tc = CompactContractBytecode { + abi: Some(abi.clone()), + bytecode: None, + deployed_bytecode: None, + }; + + let post_link_input = PostLinkInput { + contract: tc, + known_contracts, + id, + extra, + dependencies, + }; + + post_link(post_link_input)?; continue } } diff --git a/testdata/fuzz/invariant/target/TargetInterfaces.t.sol b/testdata/fuzz/invariant/target/TargetInterfaces.t.sol new file mode 100644 index 0000000000000..3f6d39f6ece5d --- /dev/null +++ b/testdata/fuzz/invariant/target/TargetInterfaces.t.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +struct FuzzInterface { + address target; + string[] artifacts; +} + +contract Hello { + bool public world; + + function changeWorld() external { + world = true; + } +} + +interface IHello { + function world() external view returns (bool); + function changeWorld() external; +} + +contract HelloProxy { + address internal immutable _implementation; + + constructor(address implementation_) { + _implementation = implementation_; + } + + function _delegate(address implementation) internal { + assembly { + calldatacopy(0, 0, calldatasize()) + + let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) + + returndatacopy(0, 0, returndatasize()) + + switch result + case 0 { revert(0, returndatasize()) } + default { return(0, returndatasize()) } + } + } + + fallback() external payable { + _delegate(_implementation); + } +} + +contract TargetWorldInterfaces is DSTest { + IHello proxy; + + function setUp() public { + Hello hello = new Hello(); + proxy = IHello(address(new HelloProxy(address(hello)))); + } + + function targetInterfaces() public returns (FuzzInterface[] memory) { + FuzzInterface[] memory targets = new FuzzInterface[](1); + + string[] memory artifacts = new string[](1); + artifacts[0] = "IHello"; + + targets[0] = FuzzInterface(address(proxy), artifacts); + + return targets; + } + + function invariantTrueWorld() public { + require(proxy.world() == false, "false world."); + } +} From 1dd54101979ddacf14bae17e60a25de524af1115 Mon Sep 17 00:00:00 2001 From: Alejandro Munoz Date: Tue, 29 Aug 2023 23:16:22 +0200 Subject: [PATCH 0046/1963] Added branch functionality to forge init command (#5742) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added branch functionality to forge init command * fmt * clippy * clippy --------- Co-authored-by: Alejandro Muñoz-McDonald Co-authored-by: Enrique Ortiz --- Cargo.lock | 97 ++++++++++++++-------------- crates/anvil/src/eth/backend/time.rs | 5 +- crates/cli/src/utils/mod.rs | 19 ++++++ crates/forge/bin/cmd/init.rs | 14 +++- crates/forge/tests/cli/cmd.rs | 13 ++++ 5 files changed, 95 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 684c151c88c5c..55770e24631af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -883,15 +883,15 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "winapi", + "windows-targets 0.48.5", ] [[package]] @@ -933,9 +933,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" +checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" dependencies = [ "clap_builder", "clap_derive", @@ -944,9 +944,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" +checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" dependencies = [ "anstream", "anstyle", @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.6.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca268df6cd88e646b564e6aff1a016834e5f42077c736ef6b6789c31ef9ec5dc" +checksum = "08849ed393c907c90016652a01465a12d86361cd38ad2a7de026c56a520cc259" dependencies = [ "cfg-if", "cpufeatures", @@ -1449,9 +1449,9 @@ dependencies = [ [[package]] name = "dashmap" -version = "5.5.1" +version = "5.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd72493923899c6f10c641bdbdeddc7183d6396641d99c1a0d1597f37f92e28" +checksum = "9b101bb8960ab42ada6ae98eb82afcea4452294294c45b681295af26610d6d28" dependencies = [ "cfg-if", "hashbrown 0.14.0", @@ -1749,9 +1749,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -2178,7 +2178,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.9", + "rustix 0.38.10", "windows-sys 0.48.0", ] @@ -3355,7 +3355,7 @@ dependencies = [ "http", "hyper", "log", - "rustls 0.20.8", + "rustls 0.20.9", "rustls-native-certs", "tokio", "tokio-rustls 0.23.4", @@ -3370,7 +3370,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.6", + "rustls 0.21.7", "tokio", "tokio-rustls 0.24.1", ] @@ -3607,7 +3607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.9", + "rustix 0.38.10", "windows-sys 0.48.0", ] @@ -3958,9 +3958,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c" [[package]] name = "memmap2" @@ -4101,16 +4101,15 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", "pin-utils", - "static_assertions", ] [[package]] @@ -4360,11 +4359,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.56" +version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "cfg-if", "foreign-types", "libc", @@ -4392,9 +4391,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.91" +version = "0.9.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" +checksum = "db7e971c2c2bba161b2d2fdf37080177eff520b3bc044787c7f1f5f9e78d869b" dependencies = [ "cc", "libc", @@ -4431,9 +4430,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "parity-scale-codec" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" dependencies = [ "arrayvec", "bitvec", @@ -4445,9 +4444,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5260,7 +5259,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.6", + "rustls 0.21.7", "rustls-native-certs", "rustls-pemfile", "serde", @@ -5588,9 +5587,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.9" +version = "0.38.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49" +checksum = "ed6248e1caa625eb708e266e06159f135e8c26f2bb7ceb72dc4b2766d0340964" dependencies = [ "bitflags 2.4.0", "errno", @@ -5601,9 +5600,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", "ring", @@ -5613,9 +5612,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.6" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", @@ -6411,7 +6410,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.9", + "rustix 0.38.10", "windows-sys 0.48.0", ] @@ -6521,9 +6520,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb39ee79a6d8de55f48f2293a830e040392f1c5f16e336bdd1788cd0aadce07" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ "deranged", "itoa", @@ -6542,9 +6541,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733d258752e9303d392b94b75230d07b0b9c489350c69b851fc6c065fde3e8f9" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -6638,7 +6637,7 @@ version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ - "rustls 0.20.8", + "rustls 0.20.9", "tokio", "webpki", ] @@ -6649,7 +6648,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.6", + "rustls 0.21.7", "tokio", ] @@ -6697,7 +6696,7 @@ dependencies = [ "futures-util", "log", "native-tls", - "rustls 0.21.6", + "rustls 0.21.7", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -7023,7 +7022,7 @@ dependencies = [ "log", "native-tls", "rand 0.8.5", - "rustls 0.21.6", + "rustls 0.21.7", "sha1", "thiserror", "url", @@ -7144,9 +7143,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index 87a4aad7b2ce2..253acd24f9435 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -9,7 +9,10 @@ use crate::eth::error::BlockchainError; /// Returns the `Utc` datetime for the given seconds since unix epoch pub fn utc_from_secs(secs: u64) -> DateTime { - DateTime::::from_utc(NaiveDateTime::from_timestamp_opt(secs as i64, 0).unwrap(), Utc) + DateTime::::from_naive_utc_and_offset( + NaiveDateTime::from_timestamp_opt(secs as i64, 0).unwrap(), + Utc, + ) } /// Manages block time diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 5215b88562b77..d36b1de2b1c07 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -332,6 +332,25 @@ impl<'a> Git<'a> { Ok(PathBuf::from(output)) } + pub fn clone_with_branch( + shallow: bool, + from: impl AsRef, + branch: impl AsRef, + to: Option>, + ) -> Result<()> { + Self::cmd_no_root() + .stderr(Stdio::inherit()) + .args(["clone", "--recurse-submodules"]) + .args(shallow.then_some("--depth=1")) + .args(shallow.then_some("--shallow-submodules")) + .arg("-b") + .arg(branch) + .arg(from) + .args(to) + .exec() + .map(drop) + } + pub fn clone( shallow: bool, from: impl AsRef, diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 2ae3c91844e0c..a1b2f2c78c210 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -19,6 +19,11 @@ pub struct InitArgs { #[clap(long, short)] template: Option, + /// Branch argument that can only be used with template option. + /// If not specified, the default branch is used. + #[clap(long, short, requires = "template")] + branch: Option, + /// Do not install dependencies from the network. #[clap(long, conflicts_with = "template", visible_alias = "no-deps")] offline: bool, @@ -38,7 +43,7 @@ pub struct InitArgs { impl InitArgs { pub fn run(self) -> Result<()> { - let InitArgs { root, template, opts, offline, force, vscode } = self; + let InitArgs { root, template, branch, opts, offline, force, vscode } = self; let DependencyInstallOpts { shallow, no_git, no_commit, quiet } = opts; // create the root dir if it does not exist @@ -59,8 +64,11 @@ impl InitArgs { }; p_println!(!quiet => "Initializing {} from {}...", root.display(), template); - Git::clone(shallow, &template, Some(&root))?; - + if let Some(branch) = branch { + Git::clone_with_branch(shallow, &template, branch, Some(&root))?; + } else { + Git::clone(shallow, &template, Some(&root))?; + } // Modify the git history. let commit_hash = git.commit_hash(true)?; std::fs::remove_dir_all(".git")?; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 09a504ffe0db0..d8a0b64db6481 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -382,6 +382,19 @@ forgetest!(can_init_template, |prj: TestProject, mut cmd: TestCommand| { assert!(prj.root().join("test").exists()); }); +// checks that forge can init with template and branch +forgetest!(can_init_template_with_branch, |prj: TestProject, mut cmd: TestCommand| { + prj.wipe(); + cmd.args(["init", "--template", "foundry-rs/forge-template", "--branch", "test/deployments"]) + .arg(prj.root()); + cmd.assert_non_empty_stdout(); + assert!(prj.root().join(".git").exists()); + assert!(prj.root().join(".dapprc").exists()); + assert!(prj.root().join("lib/ds-test").exists()); + assert!(prj.root().join("src").exists()); + assert!(prj.root().join("scripts").exists()); +}); + // checks that init fails when the provided template doesn't exist forgetest!(fail_init_nonexistent_template, |prj: TestProject, mut cmd: TestCommand| { prj.wipe(); From a07bdb8f6ede121011fa04e48b4ada2d0609e0e2 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 29 Aug 2023 15:22:20 -0700 Subject: [PATCH 0047/1963] fix(`cheatcodes`): properly filter cheatcode tests (#5744) * chore: use proper filter * chore: fix tests * chore: remove cruft * fmt * clippy * chore: use simpler error * drop clunky cross-platform comparison --- .../src/executor/inspector/cheatcodes/fs.rs | 18 ++-- crates/forge/tests/it/cheats.rs | 11 ++- testdata/cheats/Derive.t.sol | 85 ------------------- testdata/cheats/ExpectCall.t.sol | 6 -- testdata/cheats/ExpectRevert.t.sol | 5 -- testdata/cheats/Fs.t.sol | 16 ++-- testdata/cheats/Json.t.sol | 10 +-- testdata/cheats/ProjectRoot.t.sol | 7 +- testdata/cheats/TryFfi.sol | 10 +-- 9 files changed, 36 insertions(+), 132 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/fs.rs b/crates/evm/src/executor/inspector/cheatcodes/fs.rs index 26a6a97744cab..31ed6cc9d42d9 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fs.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fs.rs @@ -257,8 +257,8 @@ fn fs_metadata(state: &Cheatcodes, path: impl AsRef) -> Result { /// /// Note: This function does not verify if a user has necessary permissions to access the path, /// only that such a path exists -fn exists(path: impl AsRef) -> Result { - let path = path.as_ref(); +fn exists(state: &Cheatcodes, path: impl AsRef) -> Result { + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; Ok(abi::encode(&[Token::Bool(path.exists())]).into()) } @@ -270,8 +270,8 @@ fn exists(path: impl AsRef) -> Result { /// /// Note: This function does not verify if a user has necessary permissions to access the file, /// only that such a file exists on disk -fn is_file(path: impl AsRef) -> Result { - let path = path.as_ref(); +fn is_file(state: &Cheatcodes, path: impl AsRef) -> Result { + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; Ok(abi::encode(&[Token::Bool(path.is_file())]).into()) } @@ -283,8 +283,8 @@ fn is_file(path: impl AsRef) -> Result { /// /// Note: This function does not verify if a user has necessary permissions to access the directory, /// only that such a directory exists -fn is_dir(path: impl AsRef) -> Result { - let path = path.as_ref(); +fn is_dir(state: &Cheatcodes, path: impl AsRef) -> Result { + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; Ok(abi::encode(&[Token::Bool(path.is_dir())]).into()) } @@ -309,9 +309,9 @@ pub fn apply(state: &mut Cheatcodes, call: &HEVMCalls) -> Option { HEVMCalls::ReadDir0(inner) => read_dir(state, &inner.0, 1, false), HEVMCalls::ReadDir1(inner) => read_dir(state, &inner.0, inner.1, false), HEVMCalls::ReadDir2(inner) => read_dir(state, &inner.0, inner.1, inner.2), - HEVMCalls::Exists(inner) => exists(&inner.0), - HEVMCalls::IsFile(inner) => is_file(&inner.0), - HEVMCalls::IsDir(inner) => is_dir(&inner.0), + HEVMCalls::Exists(inner) => exists(state, &inner.0), + HEVMCalls::IsFile(inner) => is_file(state, &inner.0), + HEVMCalls::IsDir(inner) => is_dir(state, &inner.0), _ => return None, }; diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index f2769793bddd1..5cc668665a1a7 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -1,19 +1,24 @@ //! forge tests for cheat codes +use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; + use crate::{ config::*, - test_helpers::{filter::Filter, RE_PATH_SEPARATOR}, + test_helpers::{filter::Filter, PROJECT, RE_PATH_SEPARATOR}, }; /// Executes all cheat code tests but not fork cheat codes #[tokio::test(flavor = "multi_thread")] async fn test_cheats_local() { + let mut config = Config::with_root(PROJECT.root()); + config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); + let runner = runner_with_config(config); let filter = - Filter::new(".*", "Skip*", &format!(".*cheats{RE_PATH_SEPARATOR}*")).exclude_paths("Fork"); + Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}*")).exclude_paths("Fork"); // on windows exclude ffi tests since no echo and file test that expect a certain file path #[cfg(windows)] let filter = filter.exclude_tests("(Ffi|File|Line|Root)"); - TestConfig::filter(filter).await.run().await; + TestConfig::with_filter(runner.await, filter).run().await; } diff --git a/testdata/cheats/Derive.t.sol b/testdata/cheats/Derive.t.sol index 868ed790bc722..e80790e8b958c 100644 --- a/testdata/cheats/Derive.t.sol +++ b/testdata/cheats/Derive.t.sol @@ -15,90 +15,5 @@ contract DeriveTest is DSTest { uint256 privateKeyDerivationPathChanged = vm.deriveKey(mnemonic, "m/44'/60'/0'/1/", 0); assertEq(privateKeyDerivationPathChanged, 0x6abb89895f93b02c1b9470db0fa675297f6cca832a5fc66d5dfd7661a42b37be); - - uint256 privateKeyFile = vm.deriveKey("fixtures/Derive/mnemonic_english.txt", 2); - assertEq(privateKeyFile, 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a); - } - - uint256 constant numLanguages = 10; - - function testDeriveLang() public { - string[numLanguages] memory mnemonics = [ - unicode"谐 谐 谐 谐 谐 谐 谐 谐 谐 谐 谐 宗", - unicode"諧 諧 諧 諧 諧 諧 諧 諧 諧 諧 諧 宗", - "uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina nevina", - "test test test test test test test test test test test junk", - unicode"sonde sonde sonde sonde sonde sonde sonde sonde sonde sonde sonde hématome", - "surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato mansarda", - unicode"ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ぜんご", - unicode"큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 시스템", - "sobra sobra sobra sobra sobra sobra sobra sobra sobra sobra sobra guarani", - "tacto tacto tacto tacto tacto tacto tacto tacto tacto tacto tacto lacra" - ]; - string[numLanguages] memory languages = [ - "chinese_simplified", - "chinese_traditional", - "czech", - "english", - "french", - "italian", - "japanese", - "korean", - "portuguese", - "spanish" - ]; - uint256[numLanguages] memory privateKeys = [ - 0x533bbfc4a21d5cc6ca8ac3a4b6b1dc76e15804e078b0d53d72ba698ca0733a5d, - 0x3ed7268b64e326a75fd4e894a979eed93cc1480f1badebc869542d8508168fe8, - 0x56ab29e6a8d77caeb67976faf95980ee5bbd672a6ae98cac507e8a0cb252b47c, - 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80, - 0xcdb159305d67bfba6096f47090c34895a75b8f9cc96b6d7e01b99f271e039586, - 0x9976dba80160dd3b89735ea2af8e2b474011972fc92883f4100dd3955f8d921d, - 0xff0bda7ec337713c62b948f307d8197f1a7f95db93b739b0c354654395005b7f, - 0x0ca388477381e73413bbc6188fdac45c583d0215cc43eebec49dc90e4903591a, - 0x857c78c7e0866fcd734077d92892ba215a7b5a9afb6ff437be271686fb0ef9bd, - 0x7eb53bee6299530662f3c91a9b1754cf80aa2d9d89b254ae241825f9414a4a0a - ]; - uint256[numLanguages] memory privateKeysDerivationPathChanged = [ - 0xce09fd1ec0fa74f801f85faa6eeb20019c7378180fed673676ddfb48f1360fc8, - 0x504425bc503d1a6842acbda23e76e852d568a947a7f3ee6cae3bebb677baf1ee, - 0x2e5ff4571add07ecb1f3aac0d394a5564582f9c57c01c12229121e5dff2582f3, - 0x6abb89895f93b02c1b9470db0fa675297f6cca832a5fc66d5dfd7661a42b37be, - 0xe8b159aa146238eaab2b44614aaec7e5f1e0cffa2c3526c198cf101a833e222f, - 0xe2099cc4ccacb8cd902213c5056e54460dfde550a0cf036bd3070e5b176c2f42, - 0xef82b00bb18b2efb9ac1af3530afcba8c1b4c2b16041993d898cfa5d04b81e09, - 0xa851aca713f11e2b971c1a34c448fb112974321d13f4ecf1db19554d72a9c6c7, - 0xcaec3e6839b0eeebcbea3861951721846d4d38bac91b78f1a5c8d2e1269f61fe, - 0x41211f5e0f7373cbd8728cbf2431d4ea0732136475e885328f36e5fd3cee2a43 - ]; - uint256[numLanguages] memory privateKeysFile = [ - 0xa540f6a3a6df6d39dc8b5b2290c9d08cc1e2a2a240023933b10940ec9320a7d9, - 0xacfa4014ea48cb4849422952ac083f49e95409d4d7ac6131ec1481c6e91ffbb0, - 0x3f498bf39f2c211208edac088674526d2edd9acf02464fb0e559bb9352b90ccd, - 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a, - 0x18031c4ccc75784e1b9f772a9d158efe3ca83a525ca2b4bf29f09e09d19ce195, - 0x4da226c5aacbba261bc160f9e43e7147c0b9bfa581f7160d5f2bb9d2e34358f9, - 0x59d7d5fb59d74775cae83c162c49da9af6ded75664200f675168c9322403b291, - 0xd515ca4969e31a59a4a8f23a2fcdad0c7702137ae7cb59fdfbe863c617ca4794, - 0x81b81ee315311874aab9a6560e775e74af5e4003832746df4bf044a9c3987c2f, - 0x2ba37b948b89117cde7ebb7e22bb3954249fa0575f05bfbf47cd3ec20c6f7ebd - ]; - - for (uint256 i = 0; i < numLanguages; ++i) { - string memory language = languages[i]; - string memory mnemonic = mnemonics[i]; - - uint256 privateKey = vm.deriveKey(mnemonic, 0, language); - assertEq(privateKey, privateKeys[i]); - - uint256 privateKeyDerivationPathChanged = vm.deriveKey(mnemonic, "m/44'/60'/0'/1/", 0, language); - assertEq(privateKeyDerivationPathChanged, privateKeysDerivationPathChanged[i]); - - string memory prefix = "fixtures/Derive/mnemonic_"; - string memory postfix = ".txt"; - string memory mnemonicPath = string(abi.encodePacked(prefix, language, postfix)); - uint256 privateKeyFile = vm.deriveKey(mnemonicPath, 2, language); - assertEq(privateKeyFile, privateKeysFile[i]); - } } } diff --git a/testdata/cheats/ExpectCall.t.sol b/testdata/cheats/ExpectCall.t.sol index 9508f63e6dbcd..2b08adab1d43d 100644 --- a/testdata/cheats/ExpectCall.t.sol +++ b/testdata/cheats/ExpectCall.t.sol @@ -69,12 +69,6 @@ contract ExpectCallTest is DSTest { this.exposed_callTargetNTimes(target, 1, 2, 1); } - function testFailExpectCallDirectly() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 1); - target.add(1, 2); - } - function testExpectMultipleCallsWithData() public { Contract target = new Contract(); vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); diff --git a/testdata/cheats/ExpectRevert.t.sol b/testdata/cheats/ExpectRevert.t.sol index dd68a5b38f484..00200477bf748 100644 --- a/testdata/cheats/ExpectRevert.t.sol +++ b/testdata/cheats/ExpectRevert.t.sol @@ -90,11 +90,6 @@ contract ExpectRevertTest is DSTest { reverter.revertWithMessage("revert"); } - function testFailDanglingOnInternalCall() public { - vm.expectRevert(); - shouldRevert(); - } - function testExpectRevertConstructor() public { vm.expectRevert("constructor revert"); new ConstructorReverter("constructor revert"); diff --git a/testdata/cheats/Fs.t.sol b/testdata/cheats/Fs.t.sol index 5110e362d3f6a..81be8beb640c3 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/cheats/Fs.t.sol @@ -190,16 +190,16 @@ contract FsTest is DSTest { string memory root = vm.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeLine(foundryToml, "\nffi = true\n"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeLine("foundry.toml", "\nffi = true\n"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeLine("./foundry.toml", "\nffi = true\n"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeLine("./Foundry.toml", "\nffi = true\n"); } @@ -209,16 +209,16 @@ contract FsTest is DSTest { string memory root = vm.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeFile(foundryToml, "\nffi = true\n"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeFile("foundry.toml", "\nffi = true\n"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeFile("./foundry.toml", "\nffi = true\n"); - vm.expectRevert(FOUNDRY_TOML_ACCESS_ERR); + vm.expectRevert(); fsProxy.writeFile("./Foundry.toml", "\nffi = true\n"); } diff --git a/testdata/cheats/Json.t.sol b/testdata/cheats/Json.t.sol index fca9d8a546a71..81643a6918c56 100644 --- a/testdata/cheats/Json.t.sol +++ b/testdata/cheats/Json.t.sol @@ -152,12 +152,6 @@ contract ParseJsonTest is DSTest { function test_nonExistentKey() public { bytes memory data = vm.parseJson(json, ".thisKeyDoesNotExist"); assertEq(0, data.length); - - data = vm.parseJson(json, ".this.path.does.n.0.t.exist"); - assertEq(0, data.length); - - data = vm.parseJson("", "."); - assertEq(0, data.length); } function test_parseJsonKeys() public { @@ -282,14 +276,14 @@ contract WriteJsonTest is DSTest { function test_checkKeyExists() public { string memory path = "fixtures/Json/write_complex_test.json"; string memory json = vm.readFile(path); - bool exists = vm.keyExists(json, "a"); + bool exists = vm.keyExists(json, ".a"); assertTrue(exists); } function test_checkKeyDoesNotExist() public { string memory path = "fixtures/Json/write_complex_test.json"; string memory json = vm.readFile(path); - bool exists = vm.keyExists(json, "d"); + bool exists = vm.keyExists(json, ".d"); assertTrue(!exists); } diff --git a/testdata/cheats/ProjectRoot.t.sol b/testdata/cheats/ProjectRoot.t.sol index 49bc7be018e56..9f22b61fe3fa3 100644 --- a/testdata/cheats/ProjectRoot.t.sol +++ b/testdata/cheats/ProjectRoot.t.sol @@ -6,10 +6,13 @@ import "./Vm.sol"; contract ProjectRootTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); + bytes public manifestDirBytes; function testProjectRoot() public { - bytes memory manifestDirBytes = bytes(vm.envString("CARGO_MANIFEST_DIR")); - + manifestDirBytes = bytes(vm.envString("CARGO_MANIFEST_DIR")); + for (uint256 i = 0; i < 7; i++) { + manifestDirBytes.pop(); + } // replace "forge" suffix with "testdata" suffix to get expected project root from manifest dir bytes memory expectedRootSuffix = bytes("testd"); for (uint256 i = 1; i < 6; i++) { diff --git a/testdata/cheats/TryFfi.sol b/testdata/cheats/TryFfi.sol index f33769cc82b4e..aa24842390a43 100644 --- a/testdata/cheats/TryFfi.sol +++ b/testdata/cheats/TryFfi.sol @@ -21,13 +21,11 @@ contract TryFfiTest is DSTest { } function testTryFfiFail() public { - string[] memory inputs = new string[](3); - inputs[0] = "bash"; - inputs[1] = "-c"; - inputs[2] = "quikmafs"; + string[] memory inputs = new string[](2); + inputs[0] = "ls"; + inputs[1] = "wad"; Vm.FfiResult memory f = vm.tryFfi(inputs); - assert(f.exit_code != 0); - assertEq(string(f.stderr), string("bash: quikmafs: command not found\n")); + assertTrue(f.exit_code != 0); } } From 6c4c68a7031581bb8b8a10bb44db8dff4e04277f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov <62447812+klkvr@users.noreply.github.com> Date: Wed, 30 Aug 2023 01:54:13 +0200 Subject: [PATCH 0048/1963] Fix single broadcast/prank nonce setting (#5727) * Fix single broadcast * Add comments * rustfmt --------- Co-authored-by: Enrique Ortiz --- .../src/executor/inspector/cheatcodes/mod.rs | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index cd2c84808b5c5..ebd4d9c0b3107 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -758,9 +758,11 @@ impl Inspector for Cheatcodes { if let Some(prank) = &self.prank { if data.journaled_state.depth() == prank.depth { data.env.tx.caller = h160_to_b160(prank.prank_origin); - } - if prank.single_call { - std::mem::take(&mut self.prank); + + // Clean single-call prank once we have returned to the original depth + if prank.single_call { + std::mem::take(&mut self.prank); + } } } @@ -768,10 +770,11 @@ impl Inspector for Cheatcodes { if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { data.env.tx.caller = h160_to_b160(broadcast.original_origin); - } - if broadcast.single_call { - std::mem::take(&mut self.broadcast); + // Clean single-call broadcast once we have returned to the original depth + if broadcast.single_call { + std::mem::take(&mut self.broadcast); + } } } @@ -1043,9 +1046,11 @@ impl Inspector for Cheatcodes { if let Some(prank) = &self.prank { if data.journaled_state.depth() == prank.depth { data.env.tx.caller = h160_to_b160(prank.prank_origin); - } - if prank.single_call { - std::mem::take(&mut self.prank); + + // Clean single-call prank once we have returned to the original depth + if prank.single_call { + std::mem::take(&mut self.prank); + } } } @@ -1053,10 +1058,11 @@ impl Inspector for Cheatcodes { if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { data.env.tx.caller = h160_to_b160(broadcast.original_origin); - } - if broadcast.single_call { - std::mem::take(&mut self.broadcast); + // Clean single-call broadcast once we have returned to the original depth + if broadcast.single_call { + std::mem::take(&mut self.broadcast); + } } } From b6607c66ddec6d467ea558bbed901f517a9f75a4 Mon Sep 17 00:00:00 2001 From: clabby Date: Wed, 30 Aug 2023 09:17:38 -0700 Subject: [PATCH 0049/1963] Add `--json` to `cast interface` (#5748) New clippy lints :crab: Remove `cast abi` in favor of `cast interface
--json` Write to file if the output location is specified Improve --- crates/cast/bin/cmd/interface.rs | 29 +++++++++++++++++++++++------ crates/cast/src/lib.rs | 7 ++++++- crates/common/src/selectors.rs | 2 +- crates/fmt/src/solang_ext/ast_eq.rs | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 3bd52e07b3591..ac67a412f9e3d 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -33,14 +33,24 @@ pub struct InterfaceArgs { )] output: Option, + /// If specified, the interface will be output as JSON rather than Solidity. + #[clap(long, short)] + json: bool, + #[clap(flatten)] etherscan: EtherscanOpts, } impl InterfaceArgs { pub async fn run(self) -> Result<()> { - let InterfaceArgs { path_or_address, name, pragma, output: output_location, etherscan } = - self; + let InterfaceArgs { + path_or_address, + name, + pragma, + output: output_location, + etherscan, + json, + } = self; let config = Config::from(ðerscan); let chain = config.chain_id.unwrap_or_default(); let source = if Path::new(&path_or_address).exists() { @@ -53,10 +63,17 @@ impl InterfaceArgs { let interfaces = SimpleCast::generate_interface(source).await?; // put it all together - let pragma = format!("pragma solidity {pragma};"); - let interfaces = - interfaces.iter().map(|iface| iface.source.to_string()).collect::>().join("\n"); - let res = format!("{pragma}\n\n{interfaces}"); + let res = if json { + interfaces.into_iter().map(|iface| iface.json_abi).collect::>().join("\n") + } else { + let pragma = format!("pragma solidity {pragma};"); + let interfaces = interfaces + .iter() + .map(|iface| iface.source.to_string()) + .collect::>() + .join("\n"); + format!("{pragma}\n\n{interfaces}") + }; // print or write to file if let Some(loc) = output_location { diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 55171592e9e3c..e1b4a13a0862a 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -820,6 +820,7 @@ where pub struct InterfaceSource { pub name: String, + pub json_abi: String, pub source: String, } @@ -1535,7 +1536,11 @@ impl SimpleCast { .zip(contract_names) .map(|(contract_abi, name)| { let source = foundry_utils::abi::abi_to_solidity(contract_abi, &name)?; - Ok(InterfaceSource { name, source }) + Ok(InterfaceSource { + name, + json_abi: serde_json::to_string_pretty(contract_abi)?, + source, + }) }) .collect::>>() } diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index e87c55148b5e0..870c6d3c77828 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -224,8 +224,8 @@ impl SignEthClient { // filter for signatures that can be decoded Ok(sigs .iter() - .cloned() .filter(|sig| abi_decode(sig, calldata, true, true).is_ok()) + .cloned() .collect::>()) } diff --git a/crates/fmt/src/solang_ext/ast_eq.rs b/crates/fmt/src/solang_ext/ast_eq.rs index 1258f94ea0d44..42383ac1c8a86 100644 --- a/crates/fmt/src/solang_ext/ast_eq.rs +++ b/crates/fmt/src/solang_ext/ast_eq.rs @@ -22,7 +22,7 @@ fn to_num_reversed(string: &str) -> U256 { /// Helper to filter [ParameterList] to omit empty /// parameters fn filter_params(list: &ParameterList) -> ParameterList { - list.iter().cloned().filter(|(_, param)| param.is_some()).collect::>() + list.iter().filter(|(_, param)| param.is_some()).cloned().collect::>() } /// Check if two ParseTrees are equal ignoring location information or ordering if ordering does From c97661960054e400e9ed5af096db734349084f83 Mon Sep 17 00:00:00 2001 From: Franfran <51274081+iFrostizz@users.noreply.github.com> Date: Wed, 30 Aug 2023 19:22:55 +0300 Subject: [PATCH 0050/1963] Debugger Refactor #1: fuzz single (#5692) * fuzz single refactor * add struct docs * Update crates/evm/src/fuzz/mod.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * add docs and move types to types.rs * fmt * add docki docs * fmt --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/evm/src/fuzz/mod.rs | 171 ++++++++++++++++++++--------------- crates/evm/src/fuzz/types.rs | 51 +++++++++++ crates/forge/src/result.rs | 2 +- 3 files changed, 148 insertions(+), 76 deletions(-) create mode 100644 crates/evm/src/fuzz/types.rs diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index 3d7f0c559aaad..e0dc9e466fbba 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -20,10 +20,12 @@ use strategies::{ build_initial_state, collect_state_from_call, fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState, }; +use types::{CaseOutcome, CounterExampleOutcome, FuzzCase, FuzzOutcome}; pub mod error; pub mod invariant; pub mod strategies; +pub mod types; /// Wrapper around an [`Executor`] which provides fuzzing support using [`proptest`](https://docs.rs/proptest/1.0.0/proptest/). /// @@ -101,72 +103,45 @@ impl<'a> FuzzedExecutor<'a> { let strat = proptest::strategy::Union::new_weighted(weights); debug!(func = ?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { - let call = self - .executor - .call_raw(self.sender, address, calldata.0.clone(), 0.into()) - .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; - let state_changeset = call - .state_changeset - .as_ref() - .ok_or_else(|| TestCaseError::fail(FuzzError::EmptyChangeset))?; - - // Build fuzzer state - collect_state_from_call( - &call.logs, - state_changeset, - state.clone(), - &self.config.dictionary, - ); - - // When assume cheat code is triggered return a special string "FOUNDRY::ASSUME" - if call.result.as_ref() == ASSUME_MAGIC_RETURN_CODE { - return Err(TestCaseError::reject(FuzzError::AssumeReject)) - } - - let success = self.executor.is_success( - address, - call.reverted, - state_changeset.clone(), - should_fail, - ); - - if success { - let mut first_case = first_case.borrow_mut(); - if first_case.is_none() { - first_case.replace(FuzzCase { - calldata, - gas: call.gas_used, - stipend: call.stipend, - }); + let fuzz_res = self.single_fuzz(&state, address, should_fail, calldata)?; + + match fuzz_res { + FuzzOutcome::Case(case) => { + let mut first_case = first_case.borrow_mut(); + gas_by_case.borrow_mut().push((case.case.gas, case.case.stipend)); + if first_case.is_none() { + first_case.replace(case.case); + } + + traces.replace(case.traces); + + if let Some(prev) = coverage.take() { + // Safety: If `Option::or` evaluates to `Some`, then `call.coverage` must + // necessarily also be `Some` + coverage.replace(Some(prev.merge(case.coverage.unwrap()))); + } else { + coverage.replace(case.coverage); + } + + Ok(()) } - gas_by_case.borrow_mut().push((call.gas_used, call.stipend)); - - traces.replace(call.traces); - - if let Some(prev) = coverage.take() { - // Safety: If `Option::or` evaluates to `Some`, then `call.coverage` must - // necessarily also be `Some` - coverage.replace(Some(prev.merge(call.coverage.unwrap()))); - } else { - coverage.replace(call.coverage); + FuzzOutcome::CounterExample(CounterExampleOutcome { + exit_reason, + counterexample: _counterexample, + .. + }) => { + let status = exit_reason; + // We cannot use the calldata returned by the test runner in `TestError::Fail`, + // since that input represents the last run case, which may not correspond with + // our failure - when a fuzz case fails, proptest will try + // to run at least one more case to find a minimal failure + // case. + let call_res = _counterexample.1.result.clone(); + *counterexample.borrow_mut() = _counterexample; + Err(TestCaseError::fail( + decode::decode_revert(&call_res, errors, Some(status)).unwrap_or_default(), + )) } - - Ok(()) - } else { - let status = call.exit_reason; - // We cannot use the calldata returned by the test runner in `TestError::Fail`, - // since that input represents the last run case, which may not correspond with our - // failure - when a fuzz case fails, proptest will try to run at least one more - // case to find a minimal failure case. - *counterexample.borrow_mut() = (calldata, call); - Err(TestCaseError::fail( - decode::decode_revert( - counterexample.borrow().1.result.as_ref(), - errors, - Some(status), - ) - .unwrap_or_default(), - )) } }); @@ -216,6 +191,63 @@ impl<'a> FuzzedExecutor<'a> { result } + + /// Granular and single-step function that runs only one fuzz and returns either a `CaseOutcome` + /// or a `CounterExampleOutcome` + pub fn single_fuzz( + &self, + state: &EvmFuzzState, + address: Address, + should_fail: bool, + calldata: ethers::types::Bytes, + ) -> Result { + let call = self + .executor + .call_raw(self.sender, address, calldata.0.clone(), 0.into()) + .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; + let state_changeset = call + .state_changeset + .as_ref() + .ok_or_else(|| TestCaseError::fail(FuzzError::EmptyChangeset))?; + + // Build fuzzer state + collect_state_from_call( + &call.logs, + state_changeset, + state.clone(), + &self.config.dictionary, + ); + + // When assume cheat code is triggered return a special string "FOUNDRY::ASSUME" + if call.result.as_ref() == ASSUME_MAGIC_RETURN_CODE { + return Err(TestCaseError::reject(FuzzError::AssumeReject)) + } + + let breakpoints = call + .cheatcodes + .as_ref() + .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); + + let success = + self.executor.is_success(address, call.reverted, state_changeset.clone(), should_fail); + + if success { + Ok(FuzzOutcome::Case(CaseOutcome { + case: FuzzCase { calldata, gas: call.gas_used, stipend: call.stipend }, + traces: call.traces, + coverage: call.coverage, + debug: call.debug, + breakpoints, + })) + } else { + Ok(FuzzOutcome::CounterExample(CounterExampleOutcome { + debug: call.debug.clone(), + exit_reason: call.exit_reason, + counterexample: (calldata, call), + breakpoints, + })) + } + } } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -444,14 +476,3 @@ impl FuzzedCases { self.lowest().map(|c| c.gas).unwrap_or_default() } } - -/// Data of a single fuzz test case -#[derive(Clone, Debug, Default, Serialize, Deserialize)] -pub struct FuzzCase { - /// The calldata used for this fuzz test - pub calldata: Bytes, - /// Consumed gas - pub gas: u64, - /// The initial gas stipend for the transaction - pub stipend: u64, -} diff --git a/crates/evm/src/fuzz/types.rs b/crates/evm/src/fuzz/types.rs new file mode 100644 index 0000000000000..7178376a67a74 --- /dev/null +++ b/crates/evm/src/fuzz/types.rs @@ -0,0 +1,51 @@ +use crate::{coverage::HitMaps, debug::DebugArena, executor::RawCallResult, trace::CallTraceArena}; +use ethers::types::Bytes; +use foundry_common::evm::Breakpoints; +use revm::interpreter::InstructionResult; +use serde::{Deserialize, Serialize}; + +/// Data of a single fuzz test case +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct FuzzCase { + /// The calldata used for this fuzz test + pub calldata: Bytes, + /// Consumed gas + pub gas: u64, + /// The initial gas stipend for the transaction + pub stipend: u64, +} + +/// Returned by a single fuzz in the case of a successful run +#[derive(Debug)] +pub struct CaseOutcome { + /// Data of a single fuzz test case + pub case: FuzzCase, + /// The traces of the call + pub traces: Option, + /// The coverage info collected during the call + pub coverage: Option, + /// The debug nodes of the call + pub debug: Option, + /// Breakpoints char pc map + pub breakpoints: Breakpoints, +} + +/// Returned by a single fuzz when a counterexample has been discovered +#[derive(Debug)] +pub struct CounterExampleOutcome { + /// Minimal reproduction test case for failing test + pub counterexample: (ethers::types::Bytes, RawCallResult), + /// The status of the call + pub exit_reason: InstructionResult, + /// The debug nodes of the call + pub debug: Option, + /// Breakpoints char pc map + pub breakpoints: Breakpoints, +} + +/// Outcome of a single fuzz +#[derive(Debug)] +pub enum FuzzOutcome { + Case(CaseOutcome), + CounterExample(CounterExampleOutcome), +} diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index c6363e0695ce2..ca717e61b6484 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -6,7 +6,7 @@ use foundry_common::evm::Breakpoints; use foundry_evm::{ coverage::HitMaps, executor::EvmError, - fuzz::{CounterExample, FuzzCase}, + fuzz::{types::FuzzCase, CounterExample}, trace::{TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; From 8515d4a613d7edf95f54b3769543c8ee4188b61f Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 30 Aug 2023 13:04:24 -0700 Subject: [PATCH 0051/1963] fix(remappings): do not output debug info (#5752) --- crates/config/src/providers/remappings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index f6c84eb1fce4e..fd434d2134a4d 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -163,7 +163,7 @@ impl<'a> RemappingsProvider<'a> { { // this is an additional safety check for weird auto-detected remappings if ["lib/", "src/", "contracts/"].contains(&r.name.as_str()) { - println!("- skipping the remapping"); + trace!(target: "forge", "- skipping the remapping"); continue } insert_closest(&mut lib_remappings, r.context, r.name, r.path.into()); From 2f4a77ed320a6ed138dd51faaccf31fee87fbac6 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 30 Aug 2023 17:29:33 -0700 Subject: [PATCH 0052/1963] fix(anvil): remove jemalloc (#5759) --- Cargo.lock | 1 - crates/anvil/Cargo.toml | 6 +----- crates/anvil/src/anvil.rs | 4 ---- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55770e24631af..44e201c455d00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,7 +205,6 @@ dependencies = [ "serde_json", "tempfile", "thiserror", - "tikv-jemallocator", "tokio", "tower", "tower-http 0.4.3", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 9f003b5e1b5ec..9d7a24ba379ba 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -70,9 +70,6 @@ fdlimit = { version = "0.2", optional = true } clap_complete_fig = "4" ethereum-forkid = "0.12" -[target.'cfg(not(target_env = "msvc"))'.dependencies] -tikv-jemallocator = { workspace = true, optional = true } - [dev-dependencies] ethers = { workspace = true, features = ["abigen"] } ethers-solc = { workspace = true, features = ["project-util", "full"] } @@ -81,7 +78,6 @@ tokio = { version = "1", features = ["full"] } crc = "3.0.1" [features] -default = ["cli", "jemalloc"] -jemalloc = ["dep:tikv-jemallocator"] +default = ["cli"] cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"] cli = ["tokio/full", "cmd", "fdlimit"] diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index c179fbcc27e03..ebdb1fadb7975 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -2,10 +2,6 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; -#[cfg(not(target_env = "msvc"))] -#[global_allocator] -static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; - /// A fast local Ethereum development node. #[derive(Debug, Parser)] #[clap(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] From ee6390598e2475adad66872f868cfda58bb348da Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 30 Aug 2023 17:50:35 -0700 Subject: [PATCH 0053/1963] chore(`cheatcodes`): clean up cheatcodes `util.rs` with new `wallet` and `parsing` (#5758) * feat: add new wallet/parsing files with respective funcs * chore: dedupe * chore: re-use new cheatcodes * chore: move skip to ext * fmt * chore: parsing -> parse --- .../src/executor/inspector/cheatcodes/ext.rs | 38 +- .../src/executor/inspector/cheatcodes/mod.rs | 12 +- .../executor/inspector/cheatcodes/parse.rs | 151 ++++++++ .../src/executor/inspector/cheatcodes/util.rs | 350 +----------------- .../executor/inspector/cheatcodes/wallet.rs | 211 +++++++++++ 5 files changed, 409 insertions(+), 353 deletions(-) create mode 100644 crates/evm/src/executor/inspector/cheatcodes/parse.rs create mode 100644 crates/evm/src/executor/inspector/cheatcodes/wallet.rs diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index 95f88e4cd89f0..e2a6a5cab11a7 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -1,5 +1,5 @@ -use super::{bail, ensure, fmt_err, Cheatcodes, Result}; -use crate::{abi::HEVMCalls, executor::inspector::cheatcodes::util}; +use super::{bail, ensure, fmt_err, util::MAGIC_SKIP_BYTES, Cheatcodes, Error, Result}; +use crate::{abi::HEVMCalls, executor::inspector::cheatcodes::parse}; use ethers::{ abi::{self, AbiEncode, JsonAbi, ParamType, Token}, prelude::artifacts::CompactContractBytecode, @@ -7,6 +7,7 @@ use ethers::{ }; use foundry_common::{fmt::*, fs, get_artifact_path}; use foundry_config::fs_permissions::FsAccessKind; +use revm::{Database, EVMData}; use serde::Deserialize; use serde_json::Value; use std::{collections::BTreeMap, env, path::Path, process::Command}; @@ -190,9 +191,9 @@ fn get_env(key: &str, ty: ParamType, delim: Option<&str>, default: Option) -> Result { }; trace!(target : "forge::evm", ?values, "parsign values"); return if let Some(array) = values[0].as_array() { - util::parse_array(array.iter().map(to_string), &coercion_type) + parse::parse_array(array.iter().map(to_string), &coercion_type) } else { - util::parse(&to_string(values[0]), &coercion_type) + parse::parse(&to_string(values[0]), &coercion_type) } } @@ -482,7 +483,7 @@ fn key_exists(json_str: &str, key: &str) -> Result { let json: Value = serde_json::from_str(json_str).map_err(|e| format!("Could not convert to JSON: {e}"))?; let values = jsonpath_lib::select(&json, &canonicalize_json_key(key))?; - let exists = util::parse(&(!values.is_empty()).to_string(), &ParamType::Bool)?; + let exists = parse::parse(&(!values.is_empty()).to_string(), &ParamType::Bool)?; Ok(exists) } @@ -494,8 +495,28 @@ fn sleep(milliseconds: &U256) -> Result { Ok(Default::default()) } +/// Skip the current test, by returning a magic value that will be checked by the test runner. +pub fn skip(state: &mut Cheatcodes, depth: u64, skip: bool) -> Result { + if !skip { + return Ok(b"".into()) + } + + // Skip should not work if called deeper than at test level. + // As we're not returning the magic skip bytes, this will cause a test failure. + if depth > 1 { + return Err(Error::custom("The skip cheatcode can only be used at test level")) + } + + state.skip = true; + Err(Error::custom_bytes(MAGIC_SKIP_BYTES)) +} + #[instrument(level = "error", name = "ext", target = "evm::cheatcodes", skip_all)] -pub fn apply(state: &mut Cheatcodes, call: &HEVMCalls) -> Option { +pub fn apply( + state: &mut Cheatcodes, + data: &mut EVMData<'_, DB>, + call: &HEVMCalls, +) -> Option { Some(match call { HEVMCalls::Ffi(inner) => { if state.config.ffi { @@ -680,6 +701,7 @@ pub fn apply(state: &mut Cheatcodes, call: &HEVMCalls) -> Option { HEVMCalls::WriteJson0(inner) => write_json(state, &inner.0, &inner.1, None), HEVMCalls::WriteJson1(inner) => write_json(state, &inner.0, &inner.1, Some(&inner.2)), HEVMCalls::KeyExists(inner) => key_exists(&inner.0, &inner.1), + HEVMCalls::Skip(inner) => skip(state, data.journaled_state.depth(), inner.0), _ => return None, }) } diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index ebd4d9c0b3107..0e048399d4201 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -57,10 +57,15 @@ mod fs; mod fuzz; /// Mapping related cheatcodes mod mapping; +/// Parsing related cheatcodes. +/// Does not include JSON-related cheatcodes to cut complexity. +mod parse; /// Snapshot related cheatcodes mod snapshot; -/// Utility cheatcodes (`sign` etc.) +/// Utility functions and constants. pub mod util; +/// Wallet / key management related cheatcodes +mod wallet; pub use util::{BroadcastableTransaction, DEFAULT_CREATE2_DEPLOYER}; mod config; @@ -219,10 +224,11 @@ impl Cheatcodes { let opt = env::apply(self, data, caller, &decoded) .transpose() - .or_else(|| util::apply(self, data, &decoded)) + .or_else(|| wallet::apply(self, data, &decoded)) + .or_else(|| parse::apply(self, data, &decoded)) .or_else(|| expect::apply(self, data, &decoded)) .or_else(|| fuzz::apply(&decoded)) - .or_else(|| ext::apply(self, &decoded)) + .or_else(|| ext::apply(self, data, &decoded)) .or_else(|| fs::apply(self, &decoded)) .or_else(|| snapshot::apply(data, &decoded)) .or_else(|| fork::apply(self, data, &decoded)); diff --git a/crates/evm/src/executor/inspector/cheatcodes/parse.rs b/crates/evm/src/executor/inspector/cheatcodes/parse.rs new file mode 100644 index 0000000000000..904a3d502574e --- /dev/null +++ b/crates/evm/src/executor/inspector/cheatcodes/parse.rs @@ -0,0 +1,151 @@ +use super::{fmt_err, Cheatcodes, Result}; +use crate::abi::HEVMCalls; +use ethers::{ + abi::{ParamType, Token}, + prelude::*, +}; +use foundry_macros::UIfmt; +use revm::{Database, EVMData}; + +pub fn parse(s: &str, ty: &ParamType) -> Result { + parse_token(s, ty) + .map(|token| abi::encode(&[token]).into()) + .map_err(|e| fmt_err!("Failed to parse `{s}` as type `{ty}`: {e}")) +} + +pub fn parse_array(values: I, ty: &ParamType) -> Result +where + I: IntoIterator, + T: AsRef, +{ + let mut values = values.into_iter(); + match values.next() { + Some(first) if !first.as_ref().is_empty() => { + let tokens = std::iter::once(first) + .chain(values) + .map(|v| parse_token(v.as_ref(), ty)) + .collect::, _>>()?; + Ok(abi::encode(&[Token::Array(tokens)]).into()) + } + // return the empty encoded Bytes when values is empty or the first element is empty + _ => Ok(abi::encode(&[Token::String(String::new())]).into()), + } +} + +fn parse_token(s: &str, ty: &ParamType) -> Result { + match ty { + ParamType::Bool => { + s.to_ascii_lowercase().parse().map(Token::Bool).map_err(|e| e.to_string()) + } + ParamType::Uint(256) => parse_uint(s).map(Token::Uint), + ParamType::Int(256) => parse_int(s).map(Token::Int), + ParamType::Address => s.parse().map(Token::Address).map_err(|e| e.to_string()), + ParamType::FixedBytes(32) => parse_bytes(s).map(Token::FixedBytes), + ParamType::Bytes => parse_bytes(s).map(Token::Bytes), + ParamType::String => Ok(Token::String(s.to_string())), + _ => Err("unsupported type".into()), + } +} + +fn parse_int(s: &str) -> Result { + // hex string may start with "0x", "+0x", or "-0x" which needs to be stripped for + // `I256::from_hex_str` + if s.starts_with("0x") || s.starts_with("+0x") || s.starts_with("-0x") { + s.replacen("0x", "", 1).parse::().map_err(|err| err.to_string()) + } else { + match I256::from_dec_str(s) { + Ok(val) => Ok(val), + Err(dec_err) => s.parse::().map_err(|hex_err| { + format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") + }), + } + } + .map(|v| v.into_raw()) +} + +fn parse_uint(s: &str) -> Result { + if s.starts_with("0x") { + s.parse::().map_err(|err| err.to_string()) + } else { + match U256::from_dec_str(s) { + Ok(val) => Ok(val), + Err(dec_err) => s.parse::().map_err(|hex_err| { + format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") + }), + } + } +} + +fn parse_bytes(s: &str) -> Result, String> { + hex::decode(s).map_err(|e| e.to_string()) +} + +#[instrument(level = "error", name = "util", target = "evm::cheatcodes", skip_all)] +pub fn apply( + _state: &mut Cheatcodes, + _data: &mut EVMData<'_, DB>, + call: &HEVMCalls, +) -> Option { + Some(match call { + HEVMCalls::ToString0(inner) => { + Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + } + HEVMCalls::ToString1(inner) => { + Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + } + HEVMCalls::ToString2(inner) => { + Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + } + HEVMCalls::ToString3(inner) => { + Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + } + HEVMCalls::ToString4(inner) => { + Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + } + HEVMCalls::ToString5(inner) => { + Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + } + HEVMCalls::ParseBytes(inner) => parse(&inner.0, &ParamType::Bytes), + HEVMCalls::ParseAddress(inner) => parse(&inner.0, &ParamType::Address), + HEVMCalls::ParseUint(inner) => parse(&inner.0, &ParamType::Uint(256)), + HEVMCalls::ParseInt(inner) => parse(&inner.0, &ParamType::Int(256)), + HEVMCalls::ParseBytes32(inner) => parse(&inner.0, &ParamType::FixedBytes(32)), + HEVMCalls::ParseBool(inner) => parse(&inner.0, &ParamType::Bool), + _ => return None, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use ethers::abi::AbiDecode; + + #[test] + fn test_uint_env() { + let pk = "0x10532cc9d0d992825c3f709c62c969748e317a549634fb2a9fa949326022e81f"; + let val: U256 = pk.parse().unwrap(); + let parsed = parse(pk, &ParamType::Uint(256)).unwrap(); + let decoded = U256::decode(&parsed).unwrap(); + assert_eq!(val, decoded); + + let parsed = parse(pk.strip_prefix("0x").unwrap(), &ParamType::Uint(256)).unwrap(); + let decoded = U256::decode(&parsed).unwrap(); + assert_eq!(val, decoded); + + let parsed = parse("1337", &ParamType::Uint(256)).unwrap(); + let decoded = U256::decode(&parsed).unwrap(); + assert_eq!(U256::from(1337u64), decoded); + } + + #[test] + fn test_int_env() { + let val = U256::from(100u64); + let parsed = parse(&val.to_string(), &ParamType::Int(256)).unwrap(); + let decoded = I256::decode(parsed).unwrap(); + assert_eq!(val, decoded.try_into().unwrap()); + + let parsed = parse("100", &ParamType::Int(256)).unwrap(); + let decoded = I256::decode(parsed).unwrap(); + assert_eq!(U256::from(100u64), decoded.try_into().unwrap()); + } +} diff --git a/crates/evm/src/executor/inspector/cheatcodes/util.rs b/crates/evm/src/executor/inspector/cheatcodes/util.rs index 3989421a70e09..886948e7e7890 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/util.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/util.rs @@ -1,6 +1,5 @@ -use super::{ensure, fmt_err, Cheatcodes, Error, Result}; +use super::{ensure, Result}; use crate::{ - abi::HEVMCalls, executor::backend::{ error::{DatabaseError, DatabaseResult}, DatabaseExt, @@ -9,43 +8,29 @@ use crate::{ }; use bytes::{BufMut, Bytes, BytesMut}; use ethers::{ - abi::{AbiEncode, Address, ParamType, Token}, + abi::Address, core::k256::elliptic_curve::Curve, prelude::{ - k256::{ - ecdsa::SigningKey, - elliptic_curve::{bigint::Encoding, sec1::ToEncodedPoint}, - Secp256k1, - }, - LocalWallet, Signer, H160, *, + k256::{ecdsa::SigningKey, elliptic_curve::bigint::Encoding, Secp256k1}, + H160, *, }, - signers::{ - coins_bip39::{ - ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, - Korean, Portuguese, Spanish, Wordlist, - }, - MnemonicBuilder, - }, - types::{transaction::eip2718::TypedTransaction, NameOrAddress, H256, U256}, - utils::{self, keccak256}, + types::{transaction::eip2718::TypedTransaction, NameOrAddress, U256}, }; -use foundry_common::{fmt::*, RpcUrl}; +use foundry_common::RpcUrl; use revm::{ interpreter::CreateInputs, primitives::{Account, TransactTo}, Database, EVMData, JournaledState, }; -use std::{collections::VecDeque, str::FromStr}; +use std::collections::VecDeque; -const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; +pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; /// Address of the default CREATE2 deployer 0x4e59b44847b379578588920ca78fbf26c0b4956c pub const DEFAULT_CREATE2_DEPLOYER: H160 = H160([ 78, 89, 180, 72, 71, 179, 121, 87, 133, 136, 146, 12, 167, 143, 191, 38, 192, 180, 149, 108, ]); -pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; - /// Helps collecting transactions from different forks. #[derive(Debug, Clone, Default)] pub struct BroadcastableTransaction { @@ -100,223 +85,6 @@ where Ok(f(account)) } -fn addr(private_key: U256) -> Result { - let key = parse_private_key(private_key)?; - let addr = utils::secret_key_to_address(&key); - Ok(addr.encode().into()) -} - -fn sign(private_key: U256, digest: H256, chain_id: U256) -> Result { - let key = parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.as_u64()); - - // The `ecrecover` precompile does not use EIP-155 - let sig = wallet.sign_hash(digest)?; - let recovered = sig.recover(digest)?; - - assert_eq!(recovered, wallet.address()); - - let mut r_bytes = [0u8; 32]; - let mut s_bytes = [0u8; 32]; - sig.r.to_big_endian(&mut r_bytes); - sig.s.to_big_endian(&mut s_bytes); - - Ok((sig.v, r_bytes, s_bytes).encode().into()) -} - -/// Using a given private key, return its public ETH address, its public key affine x and y -/// coodinates, and its private key (see the 'Wallet' struct) -/// -/// If 'label' is set to 'Some()', assign that label to the associated ETH address in state -fn create_wallet(private_key: U256, label: Option, state: &mut Cheatcodes) -> Result { - let key = parse_private_key(private_key)?; - let addr = utils::secret_key_to_address(&key); - - let pub_key = key.verifying_key().as_affine().to_encoded_point(false); - let pub_key_x = pub_key.x().ok_or("No x coordinate was found")?; - let pub_key_y = pub_key.y().ok_or("No y coordinate was found")?; - - let pub_key_x = U256::from(pub_key_x.as_slice()); - let pub_key_y = U256::from(pub_key_y.as_slice()); - - if let Some(label) = label { - state.labels.insert(addr, label); - } - - Ok((addr, pub_key_x, pub_key_y, private_key).encode().into()) -} - -enum WordlistLang { - ChineseSimplified, - ChineseTraditional, - Czech, - English, - French, - Italian, - Japanese, - Korean, - Portuguese, - Spanish, -} - -impl FromStr for WordlistLang { - type Err = String; - - fn from_str(input: &str) -> Result { - match input { - "chinese_simplified" => Ok(Self::ChineseSimplified), - "chinese_traditional" => Ok(Self::ChineseTraditional), - "czech" => Ok(Self::Czech), - "english" => Ok(Self::English), - "french" => Ok(Self::French), - "italian" => Ok(Self::Italian), - "japanese" => Ok(Self::Japanese), - "korean" => Ok(Self::Korean), - "portuguese" => Ok(Self::Portuguese), - "spanish" => Ok(Self::Spanish), - _ => Err(format!("the language `{}` has no wordlist", input)), - } - } -} - -fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { - let derivation_path = - if path.ends_with('/') { format!("{path}{index}") } else { format!("{path}/{index}") }; - - let wallet = MnemonicBuilder::::default() - .phrase(mnemonic) - .derivation_path(&derivation_path)? - .build()?; - - let private_key = U256::from_big_endian(wallet.signer().to_bytes().as_slice()); - - Ok(private_key.encode().into()) -} - -fn derive_key_with_wordlist(mnemonic: &str, path: &str, index: u32, lang: &str) -> Result { - let lang = WordlistLang::from_str(lang)?; - match lang { - WordlistLang::ChineseSimplified => derive_key::(mnemonic, path, index), - WordlistLang::ChineseTraditional => derive_key::(mnemonic, path, index), - WordlistLang::Czech => derive_key::(mnemonic, path, index), - WordlistLang::English => derive_key::(mnemonic, path, index), - WordlistLang::French => derive_key::(mnemonic, path, index), - WordlistLang::Italian => derive_key::(mnemonic, path, index), - WordlistLang::Japanese => derive_key::(mnemonic, path, index), - WordlistLang::Korean => derive_key::(mnemonic, path, index), - WordlistLang::Portuguese => derive_key::(mnemonic, path, index), - WordlistLang::Spanish => derive_key::(mnemonic, path, index), - } -} - -fn remember_key(state: &mut Cheatcodes, private_key: U256, chain_id: U256) -> Result { - let key = parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.as_u64()); - let address = wallet.address(); - - state.script_wallets.push(wallet); - - Ok(address.encode().into()) -} - -pub fn parse(s: &str, ty: &ParamType) -> Result { - parse_token(s, ty) - .map(|token| abi::encode(&[token]).into()) - .map_err(|e| fmt_err!("Failed to parse `{s}` as type `{ty}`: {e}")) -} - -pub fn skip(state: &mut Cheatcodes, depth: u64, skip: bool) -> Result { - if !skip { - return Ok(b"".into()) - } - - // Skip should not work if called deeper than at test level. - // As we're not returning the magic skip bytes, this will cause a test failure. - if depth > 1 { - return Err(Error::custom("The skip cheatcode can only be used at test level")) - } - - state.skip = true; - Err(Error::custom_bytes(MAGIC_SKIP_BYTES)) -} - -#[instrument(level = "error", name = "util", target = "evm::cheatcodes", skip_all)] -pub fn apply( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - call: &HEVMCalls, -) -> Option { - Some(match call { - HEVMCalls::Addr(inner) => addr(inner.0), - // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given private key - HEVMCalls::Sign0(inner) => sign(inner.0, inner.1.into(), data.env.cfg.chain_id.into()), - // [function createWallet(string)] Used to derive private key and label the wallet with the - // same string - HEVMCalls::CreateWallet0(inner) => { - create_wallet(U256::from(keccak256(&inner.0)), Some(inner.0.clone()), state) - } - // [function createWallet(uint256)] creates a new wallet with the given private key - HEVMCalls::CreateWallet1(inner) => create_wallet(inner.0, None, state), - // [function createWallet(uint256,string)] creates a new wallet with the given private key - // and labels it with the given string - HEVMCalls::CreateWallet2(inner) => create_wallet(inner.0, Some(inner.1.clone()), state), - // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given Wallet's - // private key - HEVMCalls::Sign1(inner) => { - sign(inner.0.private_key, inner.1.into(), data.env.cfg.chain_id.into()) - } - HEVMCalls::DeriveKey0(inner) => { - derive_key::(&inner.0, DEFAULT_DERIVATION_PATH_PREFIX, inner.1) - } - HEVMCalls::DeriveKey1(inner) => derive_key::(&inner.0, &inner.1, inner.2), - HEVMCalls::DeriveKey2(inner) => { - derive_key_with_wordlist(&inner.0, DEFAULT_DERIVATION_PATH_PREFIX, inner.1, &inner.2) - } - HEVMCalls::DeriveKey3(inner) => { - derive_key_with_wordlist(&inner.0, &inner.1, inner.2, &inner.3) - } - HEVMCalls::RememberKey(inner) => remember_key(state, inner.0, data.env.cfg.chain_id.into()), - HEVMCalls::Label(inner) => { - state.labels.insert(inner.0, inner.1.clone()); - Ok(Default::default()) - } - HEVMCalls::GetLabel(inner) => { - let label = state - .labels - .get(&inner.0) - .cloned() - .unwrap_or_else(|| format!("unlabeled:{:?}", inner.0)); - Ok(ethers::abi::encode(&[Token::String(label)]).into()) - } - HEVMCalls::ToString0(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) - } - HEVMCalls::ToString1(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) - } - HEVMCalls::ToString2(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) - } - HEVMCalls::ToString3(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) - } - HEVMCalls::ToString4(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) - } - HEVMCalls::ToString5(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) - } - HEVMCalls::ParseBytes(inner) => parse(&inner.0, &ParamType::Bytes), - HEVMCalls::ParseAddress(inner) => parse(&inner.0, &ParamType::Address), - HEVMCalls::ParseUint(inner) => parse(&inner.0, &ParamType::Uint(256)), - HEVMCalls::ParseInt(inner) => parse(&inner.0, &ParamType::Int(256)), - HEVMCalls::ParseBytes32(inner) => parse(&inner.0, &ParamType::FixedBytes(32)), - HEVMCalls::ParseBool(inner) => parse(&inner.0, &ParamType::Bool), - HEVMCalls::Skip(inner) => skip(state, data.journaled_state.depth(), inner.0), - _ => return None, - }) -} - pub fn process_create( broadcast_sender: Address, bytecode: Bytes, @@ -375,73 +143,6 @@ where } } -pub fn parse_array(values: I, ty: &ParamType) -> Result -where - I: IntoIterator, - T: AsRef, -{ - let mut values = values.into_iter(); - match values.next() { - Some(first) if !first.as_ref().is_empty() => { - let tokens = std::iter::once(first) - .chain(values) - .map(|v| parse_token(v.as_ref(), ty)) - .collect::, _>>()?; - Ok(abi::encode(&[Token::Array(tokens)]).into()) - } - // return the empty encoded Bytes when values is empty or the first element is empty - _ => Ok(abi::encode(&[Token::String(String::new())]).into()), - } -} - -fn parse_token(s: &str, ty: &ParamType) -> Result { - match ty { - ParamType::Bool => { - s.to_ascii_lowercase().parse().map(Token::Bool).map_err(|e| e.to_string()) - } - ParamType::Uint(256) => parse_uint(s).map(Token::Uint), - ParamType::Int(256) => parse_int(s).map(Token::Int), - ParamType::Address => s.parse().map(Token::Address).map_err(|e| e.to_string()), - ParamType::FixedBytes(32) => parse_bytes(s).map(Token::FixedBytes), - ParamType::Bytes => parse_bytes(s).map(Token::Bytes), - ParamType::String => Ok(Token::String(s.to_string())), - _ => Err("unsupported type".into()), - } -} - -fn parse_int(s: &str) -> Result { - // hex string may start with "0x", "+0x", or "-0x" which needs to be stripped for - // `I256::from_hex_str` - if s.starts_with("0x") || s.starts_with("+0x") || s.starts_with("-0x") { - s.replacen("0x", "", 1).parse::().map_err(|err| err.to_string()) - } else { - match I256::from_dec_str(s) { - Ok(val) => Ok(val), - Err(dec_err) => s.parse::().map_err(|hex_err| { - format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") - }), - } - } - .map(|v| v.into_raw()) -} - -fn parse_uint(s: &str) -> Result { - if s.starts_with("0x") { - s.parse::().map_err(|err| err.to_string()) - } else { - match U256::from_dec_str(s) { - Ok(val) => Ok(val), - Err(dec_err) => s.parse::().map_err(|hex_err| { - format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") - }), - } - } -} - -fn parse_bytes(s: &str) -> Result, String> { - hex::decode(s).map_err(|e| e.to_string()) -} - pub fn parse_private_key(private_key: U256) -> Result { ensure!(!private_key.is_zero(), "Private key cannot be 0."); ensure!( @@ -475,38 +176,3 @@ pub fn check_if_fixed_gas_limit( pub fn is_potential_precompile(address: H160) -> bool { address < H160::from_low_u64_be(10) && address != H160::zero() } - -#[cfg(test)] -mod tests { - use super::*; - use ethers::abi::AbiDecode; - - #[test] - fn test_uint_env() { - let pk = "0x10532cc9d0d992825c3f709c62c969748e317a549634fb2a9fa949326022e81f"; - let val: U256 = pk.parse().unwrap(); - let parsed = parse(pk, &ParamType::Uint(256)).unwrap(); - let decoded = U256::decode(&parsed).unwrap(); - assert_eq!(val, decoded); - - let parsed = parse(pk.strip_prefix("0x").unwrap(), &ParamType::Uint(256)).unwrap(); - let decoded = U256::decode(&parsed).unwrap(); - assert_eq!(val, decoded); - - let parsed = parse("1337", &ParamType::Uint(256)).unwrap(); - let decoded = U256::decode(&parsed).unwrap(); - assert_eq!(U256::from(1337u64), decoded); - } - - #[test] - fn test_int_env() { - let val = U256::from(100u64); - let parsed = parse(&val.to_string(), &ParamType::Int(256)).unwrap(); - let decoded = I256::decode(parsed).unwrap(); - assert_eq!(val, decoded.try_into().unwrap()); - - let parsed = parse("100", &ParamType::Int(256)).unwrap(); - let decoded = I256::decode(parsed).unwrap(); - assert_eq!(U256::from(100u64), decoded.try_into().unwrap()); - } -} diff --git a/crates/evm/src/executor/inspector/cheatcodes/wallet.rs b/crates/evm/src/executor/inspector/cheatcodes/wallet.rs new file mode 100644 index 0000000000000..3c1d55048aa90 --- /dev/null +++ b/crates/evm/src/executor/inspector/cheatcodes/wallet.rs @@ -0,0 +1,211 @@ +use super::{ensure, Cheatcodes, Result}; +use crate::abi::HEVMCalls; +use ethers::{ + abi::{AbiEncode, Token}, + core::k256::elliptic_curve::Curve, + prelude::{ + k256::{ + ecdsa::SigningKey, + elliptic_curve::{bigint::Encoding, sec1::ToEncodedPoint}, + Secp256k1, + }, + LocalWallet, Signer, + }, + signers::{ + coins_bip39::{ + ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, + Korean, Portuguese, Spanish, Wordlist, + }, + MnemonicBuilder, + }, + types::{H256, U256}, + utils::{self, keccak256}, +}; +use revm::{Database, EVMData}; +use std::str::FromStr; + +/// The BIP32 default derivation path prefix. +const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; + +pub fn parse_private_key(private_key: U256) -> Result { + ensure!(!private_key.is_zero(), "Private key cannot be 0."); + ensure!( + private_key < U256::from_big_endian(&Secp256k1::ORDER.to_be_bytes()), + "Private key must be less than the secp256k1 curve order \ + (115792089237316195423570985008687907852837564279074904382605163141518161494337).", + ); + let mut bytes: [u8; 32] = [0; 32]; + private_key.to_big_endian(&mut bytes); + SigningKey::from_bytes((&bytes).into()).map_err(Into::into) +} + +fn addr(private_key: U256) -> Result { + let key = parse_private_key(private_key)?; + let addr = utils::secret_key_to_address(&key); + Ok(addr.encode().into()) +} + +fn sign(private_key: U256, digest: H256, chain_id: U256) -> Result { + let key = parse_private_key(private_key)?; + let wallet = LocalWallet::from(key).with_chain_id(chain_id.as_u64()); + + // The `ecrecover` precompile does not use EIP-155 + let sig = wallet.sign_hash(digest)?; + let recovered = sig.recover(digest)?; + + assert_eq!(recovered, wallet.address()); + + let mut r_bytes = [0u8; 32]; + let mut s_bytes = [0u8; 32]; + sig.r.to_big_endian(&mut r_bytes); + sig.s.to_big_endian(&mut s_bytes); + + Ok((sig.v, r_bytes, s_bytes).encode().into()) +} + +/// Using a given private key, return its public ETH address, its public key affine x and y +/// coodinates, and its private key (see the 'Wallet' struct) +/// +/// If 'label' is set to 'Some()', assign that label to the associated ETH address in state +fn create_wallet(private_key: U256, label: Option, state: &mut Cheatcodes) -> Result { + let key = parse_private_key(private_key)?; + let addr = utils::secret_key_to_address(&key); + + let pub_key = key.verifying_key().as_affine().to_encoded_point(false); + let pub_key_x = pub_key.x().ok_or("No x coordinate was found")?; + let pub_key_y = pub_key.y().ok_or("No y coordinate was found")?; + + let pub_key_x = U256::from(pub_key_x.as_slice()); + let pub_key_y = U256::from(pub_key_y.as_slice()); + + if let Some(label) = label { + state.labels.insert(addr, label); + } + + Ok((addr, pub_key_x, pub_key_y, private_key).encode().into()) +} + +enum WordlistLang { + ChineseSimplified, + ChineseTraditional, + Czech, + English, + French, + Italian, + Japanese, + Korean, + Portuguese, + Spanish, +} + +impl FromStr for WordlistLang { + type Err = String; + + fn from_str(input: &str) -> Result { + match input { + "chinese_simplified" => Ok(Self::ChineseSimplified), + "chinese_traditional" => Ok(Self::ChineseTraditional), + "czech" => Ok(Self::Czech), + "english" => Ok(Self::English), + "french" => Ok(Self::French), + "italian" => Ok(Self::Italian), + "japanese" => Ok(Self::Japanese), + "korean" => Ok(Self::Korean), + "portuguese" => Ok(Self::Portuguese), + "spanish" => Ok(Self::Spanish), + _ => Err(format!("the language `{}` has no wordlist", input)), + } + } +} + +fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { + let derivation_path = + if path.ends_with('/') { format!("{path}{index}") } else { format!("{path}/{index}") }; + + let wallet = MnemonicBuilder::::default() + .phrase(mnemonic) + .derivation_path(&derivation_path)? + .build()?; + + let private_key = U256::from_big_endian(wallet.signer().to_bytes().as_slice()); + + Ok(private_key.encode().into()) +} + +fn derive_key_with_wordlist(mnemonic: &str, path: &str, index: u32, lang: &str) -> Result { + let lang = WordlistLang::from_str(lang)?; + match lang { + WordlistLang::ChineseSimplified => derive_key::(mnemonic, path, index), + WordlistLang::ChineseTraditional => derive_key::(mnemonic, path, index), + WordlistLang::Czech => derive_key::(mnemonic, path, index), + WordlistLang::English => derive_key::(mnemonic, path, index), + WordlistLang::French => derive_key::(mnemonic, path, index), + WordlistLang::Italian => derive_key::(mnemonic, path, index), + WordlistLang::Japanese => derive_key::(mnemonic, path, index), + WordlistLang::Korean => derive_key::(mnemonic, path, index), + WordlistLang::Portuguese => derive_key::(mnemonic, path, index), + WordlistLang::Spanish => derive_key::(mnemonic, path, index), + } +} + +fn remember_key(state: &mut Cheatcodes, private_key: U256, chain_id: U256) -> Result { + let key = parse_private_key(private_key)?; + let wallet = LocalWallet::from(key).with_chain_id(chain_id.as_u64()); + let address = wallet.address(); + + state.script_wallets.push(wallet); + + Ok(address.encode().into()) +} + +#[instrument(level = "error", name = "util", target = "evm::cheatcodes", skip_all)] +pub fn apply( + state: &mut Cheatcodes, + data: &mut EVMData<'_, DB>, + call: &HEVMCalls, +) -> Option { + Some(match call { + HEVMCalls::Addr(inner) => addr(inner.0), + // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given private key + HEVMCalls::Sign0(inner) => sign(inner.0, inner.1.into(), data.env.cfg.chain_id.into()), + // [function createWallet(string)] Used to derive private key and label the wallet with the + // same string + HEVMCalls::CreateWallet0(inner) => { + create_wallet(U256::from(keccak256(&inner.0)), Some(inner.0.clone()), state) + } + // [function createWallet(uint256)] creates a new wallet with the given private key + HEVMCalls::CreateWallet1(inner) => create_wallet(inner.0, None, state), + // [function createWallet(uint256,string)] creates a new wallet with the given private key + // and labels it with the given string + HEVMCalls::CreateWallet2(inner) => create_wallet(inner.0, Some(inner.1.clone()), state), + // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given Wallet's + // private key + HEVMCalls::Sign1(inner) => { + sign(inner.0.private_key, inner.1.into(), data.env.cfg.chain_id.into()) + } + HEVMCalls::DeriveKey0(inner) => { + derive_key::(&inner.0, DEFAULT_DERIVATION_PATH_PREFIX, inner.1) + } + HEVMCalls::DeriveKey1(inner) => derive_key::(&inner.0, &inner.1, inner.2), + HEVMCalls::DeriveKey2(inner) => { + derive_key_with_wordlist(&inner.0, DEFAULT_DERIVATION_PATH_PREFIX, inner.1, &inner.2) + } + HEVMCalls::DeriveKey3(inner) => { + derive_key_with_wordlist(&inner.0, &inner.1, inner.2, &inner.3) + } + HEVMCalls::RememberKey(inner) => remember_key(state, inner.0, data.env.cfg.chain_id.into()), + HEVMCalls::Label(inner) => { + state.labels.insert(inner.0, inner.1.clone()); + Ok(Default::default()) + } + HEVMCalls::GetLabel(inner) => { + let label = state + .labels + .get(&inner.0) + .cloned() + .unwrap_or_else(|| format!("unlabeled:{:?}", inner.0)); + Ok(ethers::abi::encode(&[Token::String(label)]).into()) + } + _ => return None, + }) +} From 3c954bc3908ab030c7f9235460bf45edd90a825a Mon Sep 17 00:00:00 2001 From: 0xCalibur <92554750+0xCalibur@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:17:36 -0400 Subject: [PATCH 0054/1963] Update call option documentation about sig format (#5760) --- crates/cast/bin/opts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index c2d1fede147a6..3f8ae06ad0b98 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -336,7 +336,7 @@ pub enum Subcommands { /// ABI-encode a function with arguments. #[clap(name = "calldata", visible_alias = "cd")] CalldataEncode { - /// The function signature in the form () + /// The function signature in the format `()()` sig: String, /// The arguments to encode. From 577dae3f632b392856d1d62a5016c765fadd872d Mon Sep 17 00:00:00 2001 From: ruvaag Date: Thu, 31 Aug 2023 23:29:14 +0530 Subject: [PATCH 0055/1963] fix: invariant tests with input args don't panic (#5766) --- crates/evm/src/fuzz/invariant/executor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index 9aaa714ec7c77..4a977a934e103 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -23,7 +23,7 @@ use ethers::{ abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem}, prelude::U256, }; -use eyre::{ContextCompat, Result}; +use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; use parking_lot::{Mutex, RwLock}; @@ -99,6 +99,11 @@ impl<'a> InvariantExecutor<'a> { &mut self, invariant_contract: InvariantContract, ) -> Result { + // Throw an error to abort test run if the invariant function accepts input params + if !invariant_contract.invariant_function.inputs.is_empty() { + return Err(eyre!("Invariant test function should have no inputs")) + } + let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract)?; // Stores the consumed gas and calldata of every successful fuzz call. From b1c03fa5f21b5872ba5f91085b9d8ae04a008f8d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:51:55 +0200 Subject: [PATCH 0056/1963] chore(deps): weekly `cargo update` (#5777) Updating git repository `https://github.com/bluealloy/revm/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating aho-corasick v1.0.4 -> v1.0.5 Updating async-recursion v1.0.4 -> v1.0.5 Updating bstr v1.6.0 -> v1.6.2 Updating chrono v0.4.27 -> v0.4.28 Updating clap v4.4.1 -> v4.4.2 Updating clap_builder v4.4.1 -> v4.4.2 Updating clap_derive v4.4.0 -> v4.4.2 Updating dashmap v5.5.2 -> v5.5.3 Updating enumn v0.1.11 -> v0.1.12 Updating ethers v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-addressbook v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-contract v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-contract-abigen v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-contract-derive v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-core v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-etherscan v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-middleware v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-providers v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-signers v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating ethers-solc v2.0.9 (https://github.com/gakonst/ethers-rs#ade11128) -> #df28b2a4 Updating handlebars v4.3.7 -> v4.4.0 Updating headers v0.3.8 -> v0.3.9 Updating memchr v2.6.0 -> v2.6.3 Updating pest v2.7.2 -> v2.7.3 Updating pest_derive v2.7.2 -> v2.7.3 Updating pest_generator v2.7.2 -> v2.7.3 Updating pest_meta v2.7.2 -> v2.7.3 Updating regex v1.9.4 -> v1.9.5 Updating regex-automata v0.3.7 -> v0.3.8 Updating rustix v0.38.10 -> v0.38.11 Updating thiserror v1.0.47 -> v1.0.48 Updating thiserror-impl v1.0.47 -> v1.0.48 Updating tower-http v0.4.3 -> v0.4.4 Updating webpki v0.22.0 -> v0.22.1 Co-authored-by: mattsse --- Cargo.lock | 134 ++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44e201c455d00..1c89d1084b906 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -207,7 +207,7 @@ dependencies = [ "thiserror", "tokio", "tower", - "tower-http 0.4.3", + "tower-http 0.4.4", "tracing", "tracing-subscriber", "trie-db", @@ -260,7 +260,7 @@ dependencies = [ "serde_json", "thiserror", "tokio-util", - "tower-http 0.4.3", + "tower-http 0.4.4", "tracing", ] @@ -439,9 +439,9 @@ dependencies = [ [[package]] name = "async-recursion" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", @@ -668,12 +668,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", - "regex-automata 0.3.7", + "regex-automata 0.3.8", "serde", ] @@ -882,9 +882,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", @@ -932,25 +932,23 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.4.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", "clap_lex", - "once_cell", "strsim", "terminal_size", "unicase", @@ -978,9 +976,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", @@ -1448,9 +1446,9 @@ dependencies = [ [[package]] name = "dashmap" -version = "5.5.2" +version = "5.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b101bb8960ab42ada6ae98eb82afcea4452294294c45b681295af26610d6d28" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", "hashbrown 0.14.0", @@ -1718,9 +1716,9 @@ dependencies = [ [[package]] name = "enumn" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b893c4eb2dc092c811165f84dc7447fae16fb66521717968c34c509b39b1a5c5" +checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", @@ -1863,7 +1861,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1878,7 +1876,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "ethers-core", "once_cell", @@ -1889,7 +1887,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -1907,7 +1905,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "Inflector", "const-hex", @@ -1930,7 +1928,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "Inflector", "const-hex", @@ -1945,7 +1943,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "arrayvec", "bytes", @@ -1974,7 +1972,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "ethers-core", "ethers-solc", @@ -1989,7 +1987,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "async-trait", "auto_impl", @@ -2015,7 +2013,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "async-trait", "auto_impl", @@ -2053,7 +2051,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "async-trait", "coins-bip32", @@ -2080,7 +2078,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#ade111281604ee1e5bb304d554d2618d8ea8b411" +source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" dependencies = [ "cfg-if", "const-hex", @@ -2177,7 +2175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.10", + "rustix 0.38.11", "windows-sys 0.48.0", ] @@ -3103,9 +3101,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.3.7" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" +checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" dependencies = [ "log", "pest", @@ -3171,12 +3169,11 @@ dependencies = [ [[package]] name = "headers" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" +checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.3", "bytes", "headers-core", "http", @@ -3606,7 +3603,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.10", + "rustix 0.38.11", "windows-sys 0.48.0", ] @@ -3957,9 +3954,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memmap2" @@ -4600,19 +4597,20 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" +checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" +checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" dependencies = [ "pest", "pest_generator", @@ -4620,9 +4618,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" +checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" dependencies = [ "pest", "pest_meta", @@ -4633,9 +4631,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" +checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" dependencies = [ "once_cell", "pest", @@ -5191,13 +5189,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.7", + "regex-automata 0.3.8", "regex-syntax 0.7.5", ] @@ -5212,9 +5210,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", @@ -5586,9 +5584,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.10" +version = "0.38.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6248e1caa625eb708e266e06159f135e8c26f2bb7ceb72dc4b2766d0340964" +checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" dependencies = [ "bitflags 2.4.0", "errno", @@ -6409,7 +6407,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.10", + "rustix 0.38.11", "windows-sys 0.48.0", ] @@ -6469,18 +6467,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", @@ -6804,9 +6802,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ "bitflags 2.4.0", "bytes", @@ -7399,9 +7397,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" dependencies = [ "ring", "untrusted", From 0f530f2ae63342b136ad65e1c7d3b3231b939a6b Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Mon, 4 Sep 2023 17:54:51 +0200 Subject: [PATCH 0057/1963] feat(cast): support websockets (#5571) * feat(cast): support websockets * add tests and rework ipc path --- Cargo.lock | 2 + crates/anvil/src/lib.rs | 26 +-- crates/cast/bin/cmd/call.rs | 4 +- crates/cast/tests/cli/main.rs | 12 +- crates/common/Cargo.toml | 4 + crates/common/src/lib.rs | 1 + crates/common/src/provider.rs | 90 ++++---- crates/common/src/runtime_client.rs | 258 +++++++++++++++++++++++ crates/evm/src/executor/fork/multi.rs | 6 +- crates/forge/bin/cmd/script/providers.rs | 6 +- crates/forge/tests/it/fork.rs | 9 + crates/utils/src/rpc.rs | 23 ++ 12 files changed, 373 insertions(+), 68 deletions(-) create mode 100644 crates/common/src/runtime_client.rs diff --git a/Cargo.lock b/Cargo.lock index 1c89d1084b906..bc598c5f6e041 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2448,6 +2448,7 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ + "async-trait", "auto_impl", "clap", "comfy-table", @@ -2472,6 +2473,7 @@ dependencies = [ "thiserror", "tokio", "tracing", + "url", "walkdir", "yansi 0.5.1", ] diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 17005bb598e06..134de3db3d0d0 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -17,10 +17,10 @@ use eth::backend::fork::ClientFork; use ethers::{ core::k256::ecdsa::SigningKey, prelude::Wallet, - providers::{Http, Provider, Ws}, signers::Signer, types::{Address, U256}, }; +use foundry_common::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; use parking_lot::Mutex; @@ -267,27 +267,23 @@ impl NodeHandle { } /// Returns a Provider for the http endpoint - pub fn http_provider(&self) -> Provider { - Provider::::try_from(self.http_endpoint()) - .unwrap() + pub fn http_provider(&self) -> RetryProvider { + ProviderBuilder::new(self.http_endpoint()) + .build() + .expect("Failed to connect using http provider") .interval(Duration::from_millis(500)) } /// Connects to the websocket Provider of the node - pub async fn ws_provider(&self) -> Provider { - Provider::new( - Ws::connect(self.ws_endpoint()).await.expect("Failed to connect to node's websocket"), - ) + pub async fn ws_provider(&self) -> RetryProvider { + ProviderBuilder::new(self.ws_endpoint()) + .build() + .expect("Failed to connect to node's websocket") } /// Connects to the ipc endpoint of the node, if spawned - pub async fn ipc_provider(&self) -> Option> { - let ipc_path = self.config.get_ipc_path()?; - tracing::trace!(target: "ipc", ?ipc_path, "connecting ipc provider"); - let provider = Provider::connect_ipc(&ipc_path).await.unwrap_or_else(|err| { - panic!("Failed to connect to node's ipc endpoint {ipc_path}: {err:?}") - }); - Some(provider) + pub async fn ipc_provider(&self) -> Option { + ProviderBuilder::new(self.config.get_ipc_path()?).build().ok() } /// Signer accounts that can sign messages/transactions from the EVM node diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 3659bcf2c098a..ec89196590131 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -9,12 +9,12 @@ use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils::{self, handle_traces, parse_ether_value, TraceResult}, }; +use foundry_common::runtime_client::RuntimeClient; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{executor::opts::EvmOpts, trace::TracingExecutor}; use std::str::FromStr; -type Provider = - ethers::providers::Provider>; +type Provider = ethers::providers::Provider; /// CLI arguments for `cast call`. #[derive(Debug, Parser)] diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 9eff595b69695..cbc999079262a 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -4,7 +4,7 @@ use foundry_test_utils::{ casttest, util::{OutputExt, TestCommand, TestProject}, }; -use foundry_utils::rpc::next_http_rpc_endpoint; +use foundry_utils::rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}; use std::{io::Write, path::Path}; // tests `--help` is printed to std out @@ -243,6 +243,16 @@ casttest!(cast_rpc_no_args, |_: TestProject, mut cmd: TestCommand| { assert_eq!(output.trim_end(), r#""0x1""#); }); +// test for cast_rpc without arguments using websocket +casttest!(cast_ws_rpc_no_args, |_: TestProject, mut cmd: TestCommand| { + let eth_rpc_url = next_ws_rpc_endpoint(); + + // Call `cast rpc eth_chainId` + cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_chainId"]); + let output = cmd.stdout_lossy(); + assert_eq!(output.trim_end(), r#""0x1""#); +}); + // test for cast_rpc with arguments casttest!(cast_rpc_with_args, |_: TestProject, mut cmd: TestCommand| { let eth_rpc_url = next_http_rpc_endpoint(); diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index e945b45ce0947..daf66d33b3afc 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -33,6 +33,7 @@ tempfile = "3" # misc auto_impl = "1.1.0" +async-trait = "0.1" serde = "1" serde_json = "1" thiserror = "1" @@ -43,8 +44,11 @@ once_cell = "1" dunce = "1" regex = "1" globset = "0.4" +tokio = "1" +url = "2" # Using const-hex instead of hex for speed hex.workspace = true + [dev-dependencies] tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index cb045a25bb279..bd7162e7c8dd4 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -14,6 +14,7 @@ pub mod fmt; pub mod fs; pub mod glob; pub mod provider; +pub mod runtime_client; pub mod selectors; pub mod shell; pub mod term; diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index 1efd29bee63f2..0af44f320ef16 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -1,18 +1,16 @@ //! Commonly used helpers to construct `Provider`s -use crate::{ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT}; +use crate::{runtime_client::RuntimeClient, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT}; use ethers_core::types::{Chain, U256}; use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; -use ethers_providers::{ - is_local_endpoint, Authorization, Http, HttpRateLimitRetryPolicy, JwtAuth, JwtKey, Middleware, - Provider, RetryClient, RetryClientBuilder, DEFAULT_LOCAL_POLL_INTERVAL, -}; +use ethers_providers::{is_local_endpoint, Middleware, Provider, DEFAULT_LOCAL_POLL_INTERVAL}; use eyre::WrapErr; -use reqwest::{header::HeaderValue, IntoUrl, Url}; -use std::{borrow::Cow, time::Duration}; +use reqwest::{IntoUrl, Url}; +use std::{borrow::Cow, env, path::Path, time::Duration}; +use url::ParseError; /// Helper type alias for a retry provider -pub type RetryProvider = Provider>; +pub type RetryProvider = Provider; /// Helper type alias for a rpc url pub type RpcUrl = String; @@ -68,9 +66,38 @@ impl ProviderBuilder { // prefix return Self::new(format!("http://{url_str}")) } - let err = format!("Invalid provider url: {url_str}"); + + let url = Url::parse(url_str) + .or_else(|err| { + match err { + ParseError::RelativeUrlWithoutBase => { + let path = Path::new(url_str); + let absolute_path = if path.is_absolute() { + path.to_path_buf() + } else { + // Assume the path is relative to the current directory. + // Don't use `std::fs::canonicalize` as it requires the path to exist. + // It should be possible to construct a provider and only + // attempt to establish a connection later + let current_dir = + env::current_dir().expect("Current directory should exist"); + current_dir.join(path) + }; + + let path_str = + absolute_path.to_str().expect("Path should be a valid string"); + + // invalid url: non-prefixed URL scheme is not allowed, so we assume the URL + // is for a local file + Url::parse(format!("file://{path_str}").as_str()) + } + _ => Err(err), + } + }) + .wrap_err(format!("Invalid provider url: {url_str}")); + Self { - url: url.into_url().wrap_err(err), + url, chain: Chain::Mainnet, max_retry: 100, timeout_retry: 5, @@ -176,43 +203,18 @@ impl ProviderBuilder { } = self; let url = url?; - let mut client_builder = reqwest::Client::builder().timeout(timeout); - - // Set the JWT auth as a header if present - if let Some(jwt) = jwt { - // Decode jwt from hex, then generate claims (iat with current timestamp) - let jwt = hex::decode(jwt)?; - let secret = - JwtKey::from_slice(&jwt).map_err(|err| eyre::eyre!("Invalid JWT: {}", err))?; - let auth = JwtAuth::new(secret, None, None); - let token = auth.generate_token()?; - - // Essentially unrolled ethers-rs new_with_auth to accomodate the custom timeout - let auth = Authorization::Bearer(token); - let mut auth_value = HeaderValue::from_str(&auth.to_string())?; - auth_value.set_sensitive(true); - - let mut headers = reqwest::header::HeaderMap::new(); - headers.insert(reqwest::header::AUTHORIZATION, auth_value); - - client_builder = client_builder.default_headers(headers); - } + let mut provider = Provider::new(RuntimeClient::new( + url.clone(), + max_retry, + timeout_retry, + initial_backoff, + timeout, + compute_units_per_second, + jwt, + )); - let client = client_builder.build()?; let is_local = is_local_endpoint(url.as_str()); - let provider = Http::new_with_client(url, client); - - #[allow(clippy::box_default)] - let mut provider = Provider::new( - RetryClientBuilder::default() - .initial_backoff(Duration::from_millis(initial_backoff)) - .rate_limit_retries(max_retry) - .timeout_retries(timeout_retry) - .compute_units_per_second(compute_units_per_second) - .build(provider, Box::new(HttpRateLimitRetryPolicy)), - ); - if is_local { provider = provider.interval(DEFAULT_LOCAL_POLL_INTERVAL); } else if let Some(blocktime) = chain.average_blocktime_hint() { diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs new file mode 100644 index 0000000000000..cd89736aab6b2 --- /dev/null +++ b/crates/common/src/runtime_client.rs @@ -0,0 +1,258 @@ +//! Wrap different providers + +use async_trait::async_trait; +use ethers_core::types::U256; +use ethers_providers::{ + Authorization, ConnectionDetails, Http, HttpRateLimitRetryPolicy, Ipc, JsonRpcClient, + JsonRpcError, JwtAuth, JwtKey, ProviderError, PubsubClient, RetryClient, RetryClientBuilder, + RpcError, Ws, +}; +use reqwest::{header::HeaderValue, Url}; +use serde::{de::DeserializeOwned, Serialize}; +use std::{fmt::Debug, sync::Arc, time::Duration}; +use thiserror::Error; +use tokio::sync::RwLock; + +/// Enum representing a the client types supported by the runtime provider +#[derive(Debug)] +enum InnerClient { + /// HTTP client + Http(RetryClient), + /// WebSocket client + Ws(Ws), + /// IPC client + Ipc(Ipc), +} + +/// Error type for the runtime provider +#[derive(Error, Debug)] +pub enum RuntimeClientError { + /// Internal provider error + #[error(transparent)] + ProviderError(ProviderError), + + /// Failed to lock the client + #[error("Failed to lock the client")] + LockError, + + /// Invalid URL scheme + #[error("URL scheme is not supported: {0}")] + BadScheme(String), + + /// Invalid file path + #[error("Invalid IPC file path: {0}")] + BadPath(String), +} + +impl RpcError for RuntimeClientError { + fn as_error_response(&self) -> Option<&JsonRpcError> { + match self { + RuntimeClientError::ProviderError(err) => err.as_error_response(), + _ => None, + } + } + + fn as_serde_error(&self) -> Option<&serde_json::Error> { + match self { + RuntimeClientError::ProviderError(e) => e.as_serde_error(), + _ => None, + } + } +} + +impl From for ProviderError { + fn from(src: RuntimeClientError) -> Self { + match src { + RuntimeClientError::ProviderError(err) => err, + _ => ProviderError::JsonRpcClientError(Box::new(src)), + } + } +} + +/// A provider that connects on first request allowing handling of different provider types at +/// runtime +#[derive(Clone, Debug, Error)] +pub struct RuntimeClient { + client: Arc>>, + url: Url, + max_retry: u32, + timeout_retry: u32, + initial_backoff: u64, + timeout: Duration, + /// available CUPS + compute_units_per_second: u64, + jwt: Option, +} + +impl ::core::fmt::Display for RuntimeClient { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "RuntimeClient") + } +} + +fn build_auth(jwt: String) -> eyre::Result { + // Decode jwt from hex, then generate claims (iat with current timestamp) + let jwt = hex::decode(jwt)?; + let secret = JwtKey::from_slice(&jwt).map_err(|err| eyre::eyre!("Invalid JWT: {}", err))?; + let auth = JwtAuth::new(secret, None, None); + let token = auth.generate_token()?; + + // Essentially unrolled ethers-rs new_with_auth to accomodate the custom timeout + let auth = Authorization::Bearer(token); + + Ok(auth) +} + +impl RuntimeClient { + /// Creates a new dynamic provider from a URL + pub fn new( + url: Url, + max_retry: u32, + timeout_retry: u32, + initial_backoff: u64, + timeout: Duration, + compute_units_per_second: u64, + jwt: Option, + ) -> Self { + Self { + client: Arc::new(RwLock::new(None)), + url, + max_retry, + timeout_retry, + initial_backoff, + timeout, + compute_units_per_second, + jwt, + } + } + + async fn connect(&self) -> Result { + match self.url.scheme() { + "http" | "https" => { + let mut client_builder = reqwest::Client::builder().timeout(self.timeout); + + if let Some(jwt) = self.jwt.as_ref() { + let auth = build_auth(jwt.clone()).map_err(|err| { + RuntimeClientError::ProviderError(ProviderError::CustomError( + err.to_string(), + )) + })?; + + let mut auth_value: HeaderValue = HeaderValue::from_str(&auth.to_string()) + .expect("Header should be valid string"); + auth_value.set_sensitive(true); + + let mut headers = reqwest::header::HeaderMap::new(); + headers.insert(reqwest::header::AUTHORIZATION, auth_value); + + client_builder = client_builder.default_headers(headers); + }; + + let client = client_builder + .build() + .map_err(|e| RuntimeClientError::ProviderError(e.into()))?; + + let provider = Http::new_with_client(self.url.clone(), client); + + #[allow(clippy::box_default)] + let provider = RetryClientBuilder::default() + .initial_backoff(Duration::from_millis(self.initial_backoff)) + .rate_limit_retries(self.max_retry) + .timeout_retries(self.timeout_retry) + .compute_units_per_second(self.compute_units_per_second) + .build(provider, Box::new(HttpRateLimitRetryPolicy)); + Ok(InnerClient::Http(provider)) + } + "ws" | "wss" => { + let auth: Option = + self.jwt.as_ref().and_then(|jwt| build_auth(jwt.clone()).ok()); + let connection_details = ConnectionDetails::new(self.url.as_str(), auth); + + let client = + Ws::connect_with_reconnects(connection_details, self.max_retry as usize) + .await + .map_err(|e| RuntimeClientError::ProviderError(e.into()))?; + + Ok(InnerClient::Ws(client)) + } + "file" => { + let path = self + .url + .to_file_path() + .map_err(|_| RuntimeClientError::BadPath(self.url.to_string()))?; + + let client = Ipc::connect(path) + .await + .map_err(|e| RuntimeClientError::ProviderError(e.into()))?; + + Ok(InnerClient::Ipc(client)) + } + _ => Err(RuntimeClientError::BadScheme(self.url.to_string())), + } + } +} + +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] +impl JsonRpcClient for RuntimeClient { + type Error = RuntimeClientError; + + #[allow(implied_bounds_entailment)] + async fn request(&self, method: &str, params: T) -> Result + where + T: Debug + Serialize + Send + Sync, + R: DeserializeOwned + Send, + { + if self.client.read().await.is_none() { + let mut w = self.client.write().await; + *w = Some( + self.connect().await.map_err(|e| RuntimeClientError::ProviderError(e.into()))?, + ); + } + + let res = match self.client.read().await.as_ref().unwrap() { + InnerClient::Http(http) => RetryClient::request(http, method, params) + .await + .map_err(|e| RuntimeClientError::ProviderError(e.into())), + InnerClient::Ws(ws) => JsonRpcClient::request(ws, method, params) + .await + .map_err(|e| RuntimeClientError::ProviderError(e.into())), + InnerClient::Ipc(ipc) => JsonRpcClient::request(ipc, method, params) + .await + .map_err(|e| RuntimeClientError::ProviderError(e.into())), + }?; + Ok(res) + } +} + +// We can also implement [`PubsubClient`] for our dynamic provider. +impl PubsubClient for RuntimeClient { + // Since both `Ws` and `Ipc`'s `NotificationStream` associated type is the same, + // we can simply return one of them. + type NotificationStream = ::NotificationStream; + + fn subscribe>(&self, id: T) -> Result { + match self.client.try_read().map_err(|_| RuntimeClientError::LockError)?.as_ref().unwrap() { + InnerClient::Http(_) => { + Err(RuntimeClientError::ProviderError(ProviderError::UnsupportedRPC)) + } + InnerClient::Ws(client) => Ok(PubsubClient::subscribe(client, id) + .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), + InnerClient::Ipc(client) => Ok(PubsubClient::subscribe(client, id) + .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), + } + } + + fn unsubscribe>(&self, id: T) -> Result<(), Self::Error> { + match self.client.try_read().map_err(|_| (RuntimeClientError::LockError))?.as_ref().unwrap() + { + InnerClient::Http(_) => { + Err(RuntimeClientError::ProviderError(ProviderError::UnsupportedRPC)) + } + InnerClient::Ws(client) => Ok(PubsubClient::unsubscribe(client, id) + .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), + InnerClient::Ipc(client) => Ok(PubsubClient::unsubscribe(client, id) + .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), + } + } +} diff --git a/crates/evm/src/executor/fork/multi.rs b/crates/evm/src/executor/fork/multi.rs index 600078b249562..27ab759eb97a9 100644 --- a/crates/evm/src/executor/fork/multi.rs +++ b/crates/evm/src/executor/fork/multi.rs @@ -9,10 +9,10 @@ use crate::{ }; use ethers::{ abi::{AbiDecode, AbiEncode, AbiError}, - providers::{Http, Provider, RetryClient}, + providers::Provider, types::{BlockId, BlockNumber}, }; -use foundry_common::ProviderBuilder; +use foundry_common::{runtime_client::RuntimeClient, ProviderBuilder}; use foundry_config::Config; use futures::{ channel::mpsc::{channel, Receiver, Sender}, @@ -168,7 +168,7 @@ impl MultiFork { } } -type Handler = BackendHandler>>>; +type Handler = BackendHandler>>; type CreateFuture = Pin> + Send>>; type CreateSender = OneshotSender>; diff --git a/crates/forge/bin/cmd/script/providers.rs b/crates/forge/bin/cmd/script/providers.rs index df05b852c1a39..93ff19a658f88 100644 --- a/crates/forge/bin/cmd/script/providers.rs +++ b/crates/forge/bin/cmd/script/providers.rs @@ -1,6 +1,6 @@ -use ethers::prelude::{Http, Middleware, Provider, RetryClient, U256}; +use ethers::prelude::{Middleware, Provider, U256}; use eyre::{Result, WrapErr}; -use foundry_common::{get_http_provider, RpcUrl}; +use foundry_common::{get_http_provider, runtime_client::RuntimeClient, RpcUrl}; use foundry_config::Chain; use std::{ collections::{hash_map::Entry, HashMap}, @@ -42,7 +42,7 @@ impl Deref for ProvidersManager { /// Holds related metadata to each provider RPC. #[derive(Debug)] pub struct ProviderInfo { - pub provider: Arc>>, + pub provider: Arc>, pub chain: u64, pub gas_price: GasPrice, pub is_legacy: bool, diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 0d52239ef9b8f..9d10e8a5def84 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -76,6 +76,15 @@ async fn test_launch_fork() { TestConfig::with_filter(runner, filter).run().await; } +/// Smoke test that forking workings with websockets +#[tokio::test(flavor = "multi_thread")] +async fn test_launch_fork_ws() { + let rpc_url = foundry_utils::rpc::next_ws_archive_rpc_endpoint(); + let runner = forked_runner(&rpc_url).await; + let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); + TestConfig::with_filter(runner, filter).run().await; +} + /// Tests that we can transact transactions in forking mode #[tokio::test(flavor = "multi_thread")] async fn test_transact_fork() { diff --git a/crates/utils/src/rpc.rs b/crates/utils/src/rpc.rs index c32cbe199f12c..a41f2dddaba42 100644 --- a/crates/utils/src/rpc.rs +++ b/crates/utils/src/rpc.rs @@ -70,6 +70,13 @@ pub fn next_http_rpc_endpoint() -> String { next_rpc_endpoint("mainnet") } +/// Returns the next _mainnet_ rpc endpoint in inline +/// +/// This will rotate all available rpc endpoints +pub fn next_ws_rpc_endpoint() -> String { + next_ws_endpoint("mainnet") +} + pub fn next_rpc_endpoint(network: &str) -> String { let idx = next() % num_keys(); if idx < INFURA_KEYS.len() { @@ -80,12 +87,28 @@ pub fn next_rpc_endpoint(network: &str) -> String { } } +pub fn next_ws_endpoint(network: &str) -> String { + let idx = next() % num_keys(); + if idx < INFURA_KEYS.len() { + format!("wss://{network}.infura.io/v3/{}", INFURA_KEYS[idx]) + } else { + let idx = idx - INFURA_KEYS.len(); + format!("wss://eth-{network}.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) + } +} + /// Returns endpoint that has access to archive state pub fn next_http_archive_rpc_endpoint() -> String { let idx = next() % ALCHEMY_MAINNET_KEYS.len(); format!("https://eth-mainnet.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) } +/// Returns endpoint that has access to archive state +pub fn next_ws_archive_rpc_endpoint() -> String { + let idx = next() % ALCHEMY_MAINNET_KEYS.len(); + format!("wss://eth-mainnet.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) +} + #[cfg(test)] mod tests { use super::*; From 1ac45a54356ba808dbfff7200864aa4133e86624 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 6 Sep 2023 14:19:18 +0200 Subject: [PATCH 0058/1963] refactor: move evm-spec-id to config (#5786) * refactor: move evm-spec-id to config * chore: make util general and wrap it on config * chore: remove duped util on evm crate * chore: fix fixtures --------- Co-authored-by: Enrique Ortiz --- Cargo.lock | 20 +--------------- Cargo.toml | 5 ++++ crates/anvil/core/Cargo.toml | 2 +- crates/chisel/Cargo.toml | 2 +- crates/chisel/src/executor.rs | 2 +- crates/config/Cargo.toml | 1 + crates/config/src/lib.rs | 7 ++++++ crates/config/src/utils.rs | 24 ++++++++++++++++++- crates/evm/Cargo.toml | 2 +- crates/evm/src/trace/executor.rs | 9 +++---- crates/evm/src/utils.rs | 19 --------------- crates/forge/bin/cmd/coverage.rs | 4 +--- crates/forge/bin/cmd/script/executor.rs | 3 +-- crates/forge/bin/cmd/test/mod.rs | 6 ++--- .../tests/fixtures/can_test_repeatedly.stdout | 2 +- .../can_use_libs_in_multi_fork.stdout | 2 +- crates/ui/Cargo.toml | 2 +- 17 files changed, 51 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc598c5f6e041..81da6b2be3294 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2497,6 +2497,7 @@ dependencies = [ "pretty_assertions", "regex", "reqwest", + "revm-primitives", "semver 1.0.18", "serde", "serde_json", @@ -5312,7 +5313,6 @@ dependencies = [ "once_cell", "revm-primitives", "ripemd", - "secp256k1", "sha2 0.10.7", "sha3", "substrate-bn", @@ -5808,24 +5808,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "secp256k1" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" -dependencies = [ - "cc", -] - [[package]] name = "security-framework" version = "2.9.2" diff --git a/Cargo.toml b/Cargo.toml index ed52a22b2859b..494fa3f545793 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,6 +125,10 @@ foundry-test-utils = { path = "crates/test-utils" } foundry-utils = { path = "crates/utils" } ui = { path = "crates/ui" } +## revm +revm = { version = "3", default-features = false } +revm-primitives = { version = "1", default-features = false } + ethers = { git = "https://github.com/gakonst/ethers-rs", default-features = false } ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", default-features = false } ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false } @@ -156,3 +160,4 @@ tikv-jemallocator = "0.5.4" [patch.crates-io] revm = { git = "https://github.com/bluealloy/revm/", rev = "6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" } +revm-primitives = { git = "https://github.com/bluealloy/revm/", rev = "6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 2bf66e8d9756b..9c371cb851353 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -12,7 +12,7 @@ repository.workspace = true [dependencies] # foundry internal foundry-evm = { path = "../../evm" } -revm = { version = "3", default-features = false, features = ["std", "serde", "memory_limit"] } +revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } ethers-core.workspace = true serde = { version = "1", features = ["derive"], optional = true } diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index bd910cc7786c0..9633386b58a68 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -43,7 +43,7 @@ serde = "1" serde_json = { version = "1", features = ["raw_value"] } semver = "1" bytes = "1" -revm = "3" +revm.workspace = true eyre = "0.6" dirs = "5" time = { version = "0.3", features = ["formatting"] } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index f1c3a5c33caf2..3aa973eb89cf8 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -297,7 +297,7 @@ impl SessionSource { ) }) .gas_limit(self.config.evm_opts.gas_limit()) - .spec(foundry_evm::utils::evm_spec(self.config.foundry_config.evm_version)) + .spec(self.config.foundry_config.evm_spec_id()) .build(env, backend); // Create a [ChiselRunner] with a default balance of [U256::MAX] and diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index d24450f0ab3e2..391bb926caf32 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -15,6 +15,7 @@ repository.workspace = true ethers-core.workspace = true ethers-solc = { workspace = true, features = ["async", "svm-solc"] } ethers-etherscan.workspace = true +revm-primitives.workspace = true # formats Inflector = "0.11" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index a3cac6b3e18bf..622ad699b37f6 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -76,6 +76,7 @@ pub mod fix; // reexport so cli types can implement `figment::Provider` to easily merge compiler arguments pub use figment; +use revm_primitives::SpecId; use tracing::warn; /// config providers @@ -685,6 +686,12 @@ impl Config { Ok(None) } + /// Returns the [SpecId] derived from the configured [EvmVersion] + #[inline] + pub fn evm_spec_id(&self) -> SpecId { + evm_spec_id(&self.evm_version) + } + /// Returns whether the compiler version should be auto-detected /// /// Returns `false` if `solc_version` is explicitly set, otherwise returns the value of diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index d71419481bf25..5bb383bdc8a37 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -2,8 +2,12 @@ use crate::Config; use ethers_core::types::{serde_helpers::Numeric, U256}; -use ethers_solc::remappings::{Remapping, RemappingError}; +use ethers_solc::{ + remappings::{Remapping, RemappingError}, + EvmVersion, +}; use figment::value::Value; +use revm_primitives::SpecId; use serde::{de::Error, Deserialize, Deserializer}; use std::{ path::{Path, PathBuf}, @@ -255,6 +259,24 @@ where Ok(num) } +/// Returns the [SpecId] derived from [EvmVersion] +#[inline] +pub fn evm_spec_id(evm_version: &EvmVersion) -> SpecId { + match evm_version { + EvmVersion::Homestead => SpecId::HOMESTEAD, + EvmVersion::TangerineWhistle => SpecId::TANGERINE, + EvmVersion::SpuriousDragon => SpecId::SPURIOUS_DRAGON, + EvmVersion::Byzantium => SpecId::BYZANTIUM, + EvmVersion::Constantinople => SpecId::CONSTANTINOPLE, + EvmVersion::Petersburg => SpecId::PETERSBURG, + EvmVersion::Istanbul => SpecId::ISTANBUL, + EvmVersion::Berlin => SpecId::BERLIN, + EvmVersion::London => SpecId::LONDON, + EvmVersion::Paris => SpecId::MERGE, + EvmVersion::Shanghai => SpecId::SHANGHAI, + } +} + #[cfg(test)] mod tests { use crate::get_available_profiles; diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 4ebb920539d46..55d0e0c04469e 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -40,7 +40,7 @@ once_cell = "1" # EVM bytes = "1" hashbrown = { version = "0.13", features = ["serde"] } -revm = { version = "3", default-features = false, features = [ +revm = { workspace = true, default-features = false, features = [ "std", "serde", "memory_limit", diff --git a/crates/evm/src/trace/executor.rs b/crates/evm/src/trace/executor.rs index 7a57f68c42fe0..6cd9263bb855d 100644 --- a/crates/evm/src/trace/executor.rs +++ b/crates/evm/src/trace/executor.rs @@ -1,9 +1,6 @@ -use crate::{ - executor::{fork::CreateFork, opts::EvmOpts, Backend, Executor, ExecutorBuilder}, - utils::evm_spec, -}; +use crate::executor::{fork::CreateFork, opts::EvmOpts, Backend, Executor, ExecutorBuilder}; use ethers::solc::EvmVersion; -use foundry_config::Config; +use foundry_config::{utils::evm_spec_id, Config}; use revm::primitives::Env; use std::ops::{Deref, DerefMut}; @@ -25,7 +22,7 @@ impl TracingExecutor { // tracing will be enabled only for the targeted transaction executor: ExecutorBuilder::new() .inspectors(|stack| stack.trace(true).debug(debug)) - .spec(evm_spec(version.unwrap_or_default())) + .spec(evm_spec_id(&version.unwrap_or_default())) .build(env, db), } } diff --git a/crates/evm/src/utils.rs b/crates/evm/src/utils.rs index 2d22947ffa92a..3f15523d7822d 100644 --- a/crates/evm/src/utils.rs +++ b/crates/evm/src/utils.rs @@ -1,6 +1,5 @@ use ethers::{ abi::{Abi, FixedBytes, Function}, - solc::EvmVersion, types::{Block, Chain, H256, U256}, }; use eyre::ContextCompat; @@ -112,24 +111,6 @@ pub fn halt_to_instruction_result(halt: Halt) -> InstructionResult { } } -/// Converts an `EvmVersion` into a `SpecId`. -#[inline] -pub fn evm_spec(evm: EvmVersion) -> SpecId { - match evm { - EvmVersion::Homestead => SpecId::HOMESTEAD, - EvmVersion::TangerineWhistle => SpecId::TANGERINE, - EvmVersion::SpuriousDragon => SpecId::SPURIOUS_DRAGON, - EvmVersion::Byzantium => SpecId::BYZANTIUM, - EvmVersion::Constantinople => SpecId::CONSTANTINOPLE, - EvmVersion::Petersburg => SpecId::PETERSBURG, - EvmVersion::Istanbul => SpecId::ISTANBUL, - EvmVersion::Berlin => SpecId::BERLIN, - EvmVersion::London => SpecId::LONDON, - EvmVersion::Paris => SpecId::MERGE, - EvmVersion::Shanghai => SpecId::SHANGHAI, - } -} - /// Depending on the configured chain id and block number this should apply any specific changes /// /// This checks for: diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index ca0580f92331e..0ce7fdbc40f1a 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -27,7 +27,6 @@ use foundry_cli::{ }; use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; use foundry_config::{Config, SolcReq}; -use foundry_evm::utils::evm_spec; use semver::Version; use std::{collections::HashMap, sync::mpsc::channel}; use tracing::trace; @@ -286,11 +285,10 @@ impl CoverageArgs { let root = project.paths.root; // Build the contract runner - let evm_spec = evm_spec(config.evm_version); let env = evm_opts.evm_env().await?; let mut runner = MultiContractRunnerBuilder::default() .initial_balance(evm_opts.initial_balance) - .evm_spec(evm_spec) + .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index ac42e3c2a9ee1..bc31d78bfe916 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -20,7 +20,6 @@ use forge::{ }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{shell, RpcUrl}; -use foundry_evm::utils::evm_spec; use futures::future::join_all; use parking_lot::RwLock; use std::{collections::VecDeque, sync::Arc}; @@ -305,7 +304,7 @@ impl ScriptArgs { // We need to enable tracing to decode contract names: local or external. let mut builder = ExecutorBuilder::new() .inspectors(|stack| stack.trace(true)) - .spec(evm_spec(script_config.config.evm_version)) + .spec(script_config.config.evm_spec_id()) .gas_limit(script_config.evm_opts.gas_limit()); if let SimulationStage::Local = stage { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 6bf9441ec3a43..d2ab5c0de80ff 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -30,7 +30,7 @@ use foundry_config::{ }, get_available_profiles, Config, }; -use foundry_evm::{fuzz::CounterExample, utils::evm_spec}; +use foundry_evm::fuzz::CounterExample; use regex::Regex; use std::{collections::BTreeMap, path::PathBuf, sync::mpsc::channel, time::Duration}; use tracing::trace; @@ -177,11 +177,9 @@ impl TestArgs { let env = evm_opts.evm_env().await?; // Prepare the test builder - let evm_spec = evm_spec(config.evm_version); - let mut runner = MultiContractRunnerBuilder::default() .initial_balance(evm_opts.initial_balance) - .evm_spec(evm_spec) + .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout index 9a044e74e69cb..6d645a5606b55 100644 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ b/crates/forge/tests/fixtures/can_test_repeatedly.stdout @@ -2,7 +2,7 @@ No files changed, compilation skipped Running 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) -[PASS] test_Increment() (gas: 28357) +[PASS] test_Increment() (gas: 28379) Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout index 3d5da024a361c..499648933b44c 100644 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout @@ -3,7 +3,7 @@ Solc 0.8.13 finished in 1.95s Compiler run successful! Running 1 test for test/Contract.t.sol:ContractTest -[PASS] test() (gas: 70373) +[PASS] test() (gas: 70351) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 7efe80c1aa530..74bce4d2fea8b 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -17,5 +17,5 @@ ethers.workspace = true crossterm = "0.26" eyre = "0.6" -revm = { version = "3", features = ["std", "serde"] } +revm = { workspace = true, features = ["std", "serde"] } ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"]} \ No newline at end of file From 80c0347ca91d94b20bab9deb9c7e5079fed33ab7 Mon Sep 17 00:00:00 2001 From: ruvaag Date: Wed, 6 Sep 2023 17:51:44 +0530 Subject: [PATCH 0059/1963] feat: cast decode can decode raw eip2718 txns (#5779) * feat: cast decode can decode raw eip2718 txns * fix: refactor impl, reformat result, qol changes * fix: failing doctests * refactor: merged json output object --- crates/cast/bin/main.rs | 13 +++++++++++++ crates/cast/bin/opts.rs | 4 ++++ crates/cast/src/lib.rs | 22 +++++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 88367ca9c65ee..c50c5a77cc9f4 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -489,6 +489,19 @@ async fn main() -> Result<()> { &mut std::io::stdout(), ), Subcommands::Logs(cmd) => cmd.run().await?, + Subcommands::DecodeTransaction { tx } => { + let tx = stdin::unwrap_line(tx)?; + let (tx, sig) = SimpleCast::decode_raw_transaction(&tx)?; + + // Serialize tx, sig and constructed a merged json string + let mut tx = serde_json::to_value(&tx)?; + let tx_map = tx.as_object_mut().unwrap(); + serde_json::to_value(sig)?.as_object().unwrap().iter().for_each(|(k, v)| { + tx_map.entry(k).or_insert(v.clone()); + }); + + println!("{}", serde_json::to_string_pretty(&tx)?); + } }; Ok(()) } diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 3f8ae06ad0b98..379d537ff3495 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -859,6 +859,10 @@ pub enum Subcommands { #[clap(value_name = "BYTES")] bytes: Option, }, + + /// Decodes a raw signed EIP 2718 typed transaction + #[clap(visible_alias = "dt")] + DecodeTransaction { tx: Option }, } /// CLI arguments for `cast --to-base`. diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index e1b4a13a0862a..d51d9e20bda9e 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -6,7 +6,7 @@ use ethers_core::{ token::{LenientTokenizer, Tokenizer}, Function, HumanReadableParser, ParamType, RawAbi, Token, }, - types::{Chain, *}, + types::{transaction::eip2718::TypedTransaction, Chain, *}, utils::{ format_bytes32_string, format_units, get_contract_address, keccak256, parse_bytes32_string, parse_units, rlp, Units, @@ -1824,6 +1824,26 @@ impl SimpleCast { None => eyre::bail!("No selector found"), } } + + /// Decodes a raw EIP2718 transaction payload + /// Returns details about the typed transaction and ECSDA signature components + /// + /// # Example + /// + /// ``` + /// use cast::SimpleCast as Cast; + /// + /// fn main() -> eyre::Result<()> { + /// let tx = "0x02f8f582a86a82058d8459682f008508351050808303fd84948e42f2f4101563bf679975178e880fd87d3efd4e80b884659ac74b00000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000000000000000000000000000000000000007ff4e20000000000000000000000000000000000000000000000000000000000000064c001a05d429597befe2835396206781b199122f2e8297327ed4a05483339e7a8b2022aa04c23a7f70fb29dda1b4ee342fb10a625e9b8ddc6a603fb4e170d4f6f37700cb8"; + /// let (tx, sig) = Cast::decode_raw_transaction(&tx)?; + /// + /// Ok(()) + /// } + pub fn decode_raw_transaction(tx: &str) -> Result<(TypedTransaction, Signature)> { + let tx_hex = hex::decode(strip_0x(tx))?; + let tx_rlp = rlp::Rlp::new(tx_hex.as_slice()); + Ok(TypedTransaction::decode_signed(&tx_rlp)?) + } } fn strip_0x(s: &str) -> &str { From dbfd8d95d6ec81ad8b7755fbbed2c06dba5ce447 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 6 Sep 2023 14:55:49 +0200 Subject: [PATCH 0060/1963] feat: add tmp cancun config value (#5790) --- crates/config/src/lib.rs | 11 +++++++++++ crates/forge/tests/cli/config.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 622ad699b37f6..9be852fb7826e 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -356,6 +356,13 @@ pub struct Config { /// /// This includes what operations can be executed (read, write) pub fs_permissions: FsPermissions, + + /// Temporary config to enable [SpecId::CANCUN] + /// + /// + /// Should be removed once EvmVersion Cancun is supported by solc + pub cancun: bool, + /// The root path where the config detection started from, `Config::with_root` #[doc(hidden)] // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] @@ -689,6 +696,9 @@ impl Config { /// Returns the [SpecId] derived from the configured [EvmVersion] #[inline] pub fn evm_spec_id(&self) -> SpecId { + if self.cancun { + return SpecId::CANCUN + } evm_spec_id(&self.evm_version) } @@ -1750,6 +1760,7 @@ impl Default for Config { Self { profile: Self::DEFAULT_PROFILE, fs_permissions: FsPermissions::new([PathPermission::read("out")]), + cancun: false, __root: Default::default(), src: "src".into(), test: "test".into(), diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index ba85a509b989a..763c0d497f7ad 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -114,6 +114,7 @@ forgetest!(can_extract_config_values, |prj: TestProject, mut cmd: TestCommand| { fmt: Default::default(), doc: Default::default(), fs_permissions: Default::default(), + cancun: true, __non_exhaustive: (), __warnings: vec![], }; From 675a824648b6259c1566009b79356a4fc109b6ac Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Wed, 6 Sep 2023 15:03:43 +0200 Subject: [PATCH 0061/1963] fix(common): include ws and ipc features (#5787) --- crates/common/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index daf66d33b3afc..24183a8ef2721 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -17,7 +17,7 @@ foundry-macros.workspace = true # eth ethers-core.workspace = true ethers-solc.workspace = true -ethers-providers.workspace = true +ethers-providers = { workspace = true, features = ["ws", "ipc"] } ethers-middleware.workspace = true ethers-etherscan = { workspace = true, features = ["ethers-solc"] } From 97963a4c0c274bedd499aa2e1b8f6ed705ee84ec Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:44:10 +0200 Subject: [PATCH 0062/1963] chore: add providers feature to foundry-abi (#5798) --- crates/abi/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/abi/Cargo.toml b/crates/abi/Cargo.toml index e6d53e9989aed..d23c952ac4427 100644 --- a/crates/abi/Cargo.toml +++ b/crates/abi/Cargo.toml @@ -20,5 +20,5 @@ syn = "2.0" foundry-macros.workspace = true ethers-core.workspace = true -ethers-contract = { workspace = true, features = ["abigen"] } +ethers-contract = { workspace = true, features = ["abigen", "providers"] } ethers-providers.workspace = true From 75836a776deb16a558bd6a785de191cb1f04eb5a Mon Sep 17 00:00:00 2001 From: V Date: Fri, 8 Sep 2023 18:34:25 -0300 Subject: [PATCH 0063/1963] feat: serializeJson cheatcode (#5755) * feat: add new serializeJson cheatcode that receives an id and a json string * Add comment to test_serializeRootObject --------- Co-authored-by: Enrique Ortiz --- crates/abi/abi/HEVM.sol | 1 + crates/abi/src/bindings/hevm.rs | 78 +++++++++++++++++++ .../src/executor/inspector/cheatcodes/ext.rs | 67 +++++++++------- testdata/cheats/Json.t.sol | 13 ++++ testdata/cheats/Vm.sol | 2 + 5 files changed, 134 insertions(+), 27 deletions(-) diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index c59df22510d52..fdabab9c6f4e9 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -212,6 +212,7 @@ parseJsonBytes(string, string)(bytes) parseJsonBytesArray(string, string)(bytes[]) parseJsonBytes32(string, string)(bytes32) parseJsonBytes32Array(string, string)(bytes32[]) +serializeJson(string,string)(string) serializeBool(string,string,bool)(string) serializeBool(string,string,bool[])(string) serializeUint(string,string,uint256)(string) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index ab2a1899a26df..af713b60b45f1 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -4407,6 +4407,35 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("serializeJson"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("serializeJson"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::String, + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("serializeString"), ::std::vec![ @@ -7092,6 +7121,16 @@ pub mod hevm { .method_hash([118, 118, 225, 39], (p0, p1, p2)) .expect("method not found (this should never happen)") } + ///Calls the contract's `serializeJson` (0x9b3358b0) function + pub fn serialize_json( + &self, + p0: ::std::string::String, + p1: ::std::string::String, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([155, 51, 88, 176], (p0, p1)) + .expect("method not found (this should never happen)") + } ///Calls the contract's `serializeString` (0x88da6d35) function pub fn serialize_string_0( &self, @@ -9950,6 +9989,19 @@ pub mod hevm { pub ::std::string::String, pub ::std::vec::Vec<::ethers_core::types::I256>, ); + ///Container type for all input parameters for the `serializeJson` function with signature `serializeJson(string,string)` and selector `0x9b3358b0` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "serializeJson", abi = "serializeJson(string,string)")] + pub struct SerializeJsonCall(pub ::std::string::String, pub ::std::string::String); ///Container type for all input parameters for the `serializeString` function with signature `serializeString(string,string,string)` and selector `0x88da6d35` #[derive( Clone, @@ -10645,6 +10697,7 @@ pub mod hevm { SerializeBytes321(SerializeBytes321Call), SerializeInt0(SerializeInt0Call), SerializeInt1(SerializeInt1Call), + SerializeJson(SerializeJsonCall), SerializeString0(SerializeString0Call), SerializeString1(SerializeString1Call), SerializeUint0(SerializeUint0Call), @@ -11419,6 +11472,10 @@ pub mod hevm { = ::decode(data) { return Ok(Self::SerializeInt1(decoded)); } + if let Ok(decoded) + = ::decode(data) { + return Ok(Self::SerializeJson(decoded)); + } if let Ok(decoded) = ::decode(data) { return Ok(Self::SerializeString0(decoded)); @@ -11991,6 +12048,9 @@ pub mod hevm { Self::SerializeInt1(element) => { ::ethers_core::abi::AbiEncode::encode(element) } + Self::SerializeJson(element) => { + ::ethers_core::abi::AbiEncode::encode(element) + } Self::SerializeString0(element) => { ::ethers_core::abi::AbiEncode::encode(element) } @@ -12279,6 +12339,7 @@ pub mod hevm { Self::SerializeBytes321(element) => ::core::fmt::Display::fmt(element, f), Self::SerializeInt0(element) => ::core::fmt::Display::fmt(element, f), Self::SerializeInt1(element) => ::core::fmt::Display::fmt(element, f), + Self::SerializeJson(element) => ::core::fmt::Display::fmt(element, f), Self::SerializeString0(element) => ::core::fmt::Display::fmt(element, f), Self::SerializeString1(element) => ::core::fmt::Display::fmt(element, f), Self::SerializeUint0(element) => ::core::fmt::Display::fmt(element, f), @@ -13184,6 +13245,11 @@ pub mod hevm { Self::SerializeInt1(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: SerializeJsonCall) -> Self { + Self::SerializeJson(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: SerializeString0Call) -> Self { Self::SerializeString0(value) @@ -14694,6 +14760,18 @@ pub mod hevm { Hash )] pub struct SerializeInt1Return(pub ::std::string::String); + ///Container type for all return fields from the `serializeJson` function with signature `serializeJson(string,string)` and selector `0x9b3358b0` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct SerializeJsonReturn(pub ::std::string::String); ///Container type for all return fields from the `serializeString` function with signature `serializeString(string,string,string)` and selector `0x88da6d35` #[derive( Clone, diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index e2a6a5cab11a7..8f26e74e00a11 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -388,29 +388,41 @@ fn parse_json_keys(json_str: &str, key: &str) -> Result { Ok(abi_encoded.into()) } -/// Serializes a key:value pair to a specific object. By calling this function multiple times, +/// Serializes a key:value pair to a specific object. If the key is None, the value is expected to +/// be an object, which will be set as the root object for the provided object key, overriding +/// the whole root object if the object key already exists. By calling this function multiple times, /// the user can serialize multiple KV pairs to the same object. The value can be of any type, even -/// a new object in itself. The function will return -/// a stringified version of the object, so that the user can use that as a value to a new -/// invocation of the same function with a new object key. This enables the user to reuse the same -/// function to crate arbitrarily complex object structures (JSON). +/// a new object in itself. The function will return a stringified version of the object, so that +/// the user can use that as a value to a new invocation of the same function with a new object key. +/// This enables the user to reuse the same function to crate arbitrarily complex object structures +/// (JSON). fn serialize_json( state: &mut Cheatcodes, object_key: &str, - value_key: &str, + value_key: Option<&str>, value: &str, ) -> Result { - let parsed_value = - serde_json::from_str(value).unwrap_or_else(|_| Value::String(value.to_string())); - let json = if let Some(serialization) = state.serialized_jsons.get_mut(object_key) { - serialization.insert(value_key.to_string(), parsed_value); - serialization.clone() + let json = if let Some(key) = value_key { + let parsed_value = + serde_json::from_str(value).unwrap_or_else(|_| Value::String(value.to_string())); + if let Some(serialization) = state.serialized_jsons.get_mut(object_key) { + serialization.insert(key.to_string(), parsed_value); + serialization.clone() + } else { + let mut serialization = BTreeMap::new(); + serialization.insert(key.to_string(), parsed_value); + state.serialized_jsons.insert(object_key.to_string(), serialization.clone()); + serialization.clone() + } } else { - let mut serialization = BTreeMap::new(); - serialization.insert(value_key.to_string(), parsed_value); + // value must be a JSON object + let parsed_value: BTreeMap = serde_json::from_str(value) + .map_err(|err| fmt_err!("Failed to parse JSON object: {err}"))?; + let serialization = parsed_value; state.serialized_jsons.insert(object_key.to_string(), serialization.clone()); serialization.clone() }; + let stringified = serde_json::to_string(&json) .map_err(|err| fmt_err!("Failed to stringify hashmap: {err}"))?; Ok(abi::encode(&[Token::String(stringified)]).into()) @@ -655,47 +667,48 @@ pub fn apply( HEVMCalls::ParseJsonBytes32Array(inner) => { parse_json(&inner.0, &inner.1, Some(ParamType::FixedBytes(32))) } + HEVMCalls::SerializeJson(inner) => serialize_json(state, &inner.0, None, &inner.1.pretty()), HEVMCalls::SerializeBool0(inner) => { - serialize_json(state, &inner.0, &inner.1, &inner.2.pretty()) + serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) } HEVMCalls::SerializeBool1(inner) => { - serialize_json(state, &inner.0, &inner.1, &array_eval_to_str(&inner.2)) + serialize_json(state, &inner.0, Some(&inner.1), &array_eval_to_str(&inner.2)) } HEVMCalls::SerializeUint0(inner) => { - serialize_json(state, &inner.0, &inner.1, &inner.2.pretty()) + serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) } HEVMCalls::SerializeUint1(inner) => { - serialize_json(state, &inner.0, &inner.1, &array_eval_to_str(&inner.2)) + serialize_json(state, &inner.0, Some(&inner.1), &array_eval_to_str(&inner.2)) } HEVMCalls::SerializeInt0(inner) => { - serialize_json(state, &inner.0, &inner.1, &inner.2.pretty()) + serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) } HEVMCalls::SerializeInt1(inner) => { - serialize_json(state, &inner.0, &inner.1, &array_eval_to_str(&inner.2)) + serialize_json(state, &inner.0, Some(&inner.1), &array_eval_to_str(&inner.2)) } HEVMCalls::SerializeAddress0(inner) => { - serialize_json(state, &inner.0, &inner.1, &inner.2.pretty()) + serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) } HEVMCalls::SerializeAddress1(inner) => { - serialize_json(state, &inner.0, &inner.1, &array_str_to_str(&inner.2)) + serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) } HEVMCalls::SerializeBytes320(inner) => { - serialize_json(state, &inner.0, &inner.1, &inner.2.pretty()) + serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) } HEVMCalls::SerializeBytes321(inner) => { - serialize_json(state, &inner.0, &inner.1, &array_str_to_str(&inner.2)) + serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) } HEVMCalls::SerializeString0(inner) => { - serialize_json(state, &inner.0, &inner.1, &inner.2.pretty()) + serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) } HEVMCalls::SerializeString1(inner) => { - serialize_json(state, &inner.0, &inner.1, &array_str_to_str(&inner.2)) + serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) } HEVMCalls::SerializeBytes0(inner) => { - serialize_json(state, &inner.0, &inner.1, &inner.2.pretty()) + serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) } HEVMCalls::SerializeBytes1(inner) => { - serialize_json(state, &inner.0, &inner.1, &array_str_to_str(&inner.2)) + serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) } HEVMCalls::Sleep(inner) => sleep(&inner.0), HEVMCalls::WriteJson0(inner) => write_json(state, &inner.0, &inner.1, None), diff --git a/testdata/cheats/Json.t.sol b/testdata/cheats/Json.t.sol index 81643a6918c56..06e4e44a8b41c 100644 --- a/testdata/cheats/Json.t.sol +++ b/testdata/cheats/Json.t.sol @@ -240,6 +240,19 @@ contract WriteJsonTest is DSTest { vm.removeFile(path); } + // The serializeJson cheatcode was added to support assigning an existing json string to an object key. + // Github issue: https://github.com/foundry-rs/foundry/issues/5745 + function test_serializeRootObject() public { + string memory serialized = vm.serializeJson(json1, '{"foo": "bar"}'); + assertEq(serialized, '{"foo":"bar"}'); + serialized = vm.serializeBool(json1, "boolean", true); + assertEq(vm.parseJsonString(serialized, ".foo"), "bar"); + assertEq(vm.parseJsonBool(serialized, ".boolean"), true); + + string memory overwritten = vm.serializeJson(json1, '{"value": 123}'); + assertEq(overwritten, '{"value":123}'); + } + struct simpleJson { uint256 a; string b; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index fa22bac6b2951..cf51823a75f64 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -612,6 +612,8 @@ interface Vm { function parseJsonBytes32Array(string calldata, string calldata) external returns (bytes32[] memory); + function serializeJson(string calldata, string calldata) external returns (string memory); + function serializeBool(string calldata, string calldata, bool) external returns (string memory); function serializeUint(string calldata, string calldata, uint256) external returns (string memory); From d5c51a5007805486ee5a456d35865e0ee440c8a7 Mon Sep 17 00:00:00 2001 From: Igor Line Date: Sat, 9 Sep 2023 11:34:21 +0000 Subject: [PATCH 0064/1963] fix: add $ to suffix regex to ensure wallet address ending with specified hex string (#5802) --- crates/cast/bin/cmd/create2.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index e51cdd91df9c0..911292da6744f 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -96,9 +96,10 @@ impl Create2Args { )); } if let Some(suffix) = ends_with { - regexs.push( - (get_regex_hex_string(suffix).wrap_err("invalid suffix hex provided")?).to_string(), - ); + regexs.push(format!( + r"{}$", + get_regex_hex_string(suffix).wrap_err("invalid prefix hex provided")? + )) } debug_assert!( @@ -204,6 +205,14 @@ mod tests { assert!(address.starts_with("aaa")); + // odd hex chars with 0x suffix + let args = Create2Args::parse_from(["foundry-cli", "--ends-with", "bb"]); + let create2_out = args.run().unwrap(); + let address = create2_out.address; + let address = format!("{address:x}"); + + assert!(address.ends_with("bb")); + // check fails on wrong chars let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xerr"]); let create2_out = args.run(); From 2bb29c29f9cb999a03c5f3f3178f5dda29e62172 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 10 Sep 2023 10:06:55 +0200 Subject: [PATCH 0065/1963] chore(deps): weekly `cargo update` (#5804) Updating git repository `https://github.com/bluealloy/revm/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating bytes v1.4.0 -> v1.5.0 Updating chrono v0.4.28 -> v0.4.30 Updating clap_complete v4.4.0 -> v4.4.1 Updating crypto-bigint v0.5.2 -> v0.5.3 Updating ctrlc v3.4.0 -> v3.4.1 Updating ethers v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-addressbook v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-contract v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-contract-abigen v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-contract-derive v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-core v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-etherscan v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-middleware v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-providers v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-signers v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating ethers-solc v2.0.9 (https://github.com/gakonst/ethers-rs#df28b2a4) -> #a28c5ae9 Updating linux-raw-sys v0.4.5 -> v0.4.7 Adding nix v0.27.1 Updating object v0.32.0 -> v0.32.1 Updating openssl-sys v0.9.92 -> v0.9.93 Updating prettyplease v0.2.12 -> v0.2.15 Updating rustix v0.38.11 -> v0.38.12 Updating serde_json v1.0.105 -> v1.0.106 Updating shlex v1.1.0 -> v1.2.0 Updating syn v2.0.29 -> v2.0.31 Updating toml v0.7.6 -> v0.7.8 Updating toml_edit v0.19.14 -> v0.19.15 Updating walkdir v2.3.3 -> v2.4.0 Updating which v4.4.0 -> v4.4.2 Updating xml-rs v0.8.16 -> v0.8.18 Co-authored-by: mattsse --- Cargo.lock | 222 ++++++++++++++++++++++++++++------------------------- 1 file changed, 117 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81da6b2be3294..f711b3dcf3cd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,7 +445,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -456,7 +456,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -712,9 +712,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" dependencies = [ "serde", ] @@ -882,9 +882,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" dependencies = [ "android-tzdata", "iana-time-zone", @@ -957,9 +957,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" +checksum = "4110a1e6af615a9e6d0a36f805d5c99099f8bab9b8042f5bc1fa220a4a89e36f" dependencies = [ "clap", ] @@ -983,7 +983,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -998,7 +998,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72f3f22f1a586604e62efd23f78218f3ccdecf7a33c4500db2d37d85a24fe994" dependencies = [ - "nix", + "nix 0.26.4", "terminfo", "thiserror", "which", @@ -1086,7 +1086,7 @@ dependencies = [ "libc", "log", "matches", - "nix", + "nix 0.26.4", "serde", "tap", "thiserror", @@ -1147,7 +1147,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5080df6b0f0ecb76cab30808f00d937ba725cebe266a3da8cd89dff92f2a9916" dependencies = [ "async-trait", - "nix", + "nix 0.26.4", "tokio", "winapi", ] @@ -1367,9 +1367,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -1408,11 +1408,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a011bbe2c35ce9c1f143b7af6f94f29a167beb4cd1d29e6740ce836f723120e" +checksum = "82e95fbd621905b854affdc67943b043a0fbb6ed7385fd5a25650d19a8a6cfdf" dependencies = [ - "nix", + "nix 0.27.1", "windows-sys 0.48.0", ] @@ -1722,7 +1722,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1860,8 +1860,8 @@ dependencies = [ [[package]] name = "ethers" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1875,8 +1875,8 @@ dependencies = [ [[package]] name = "ethers-addressbook" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "ethers-core", "once_cell", @@ -1886,8 +1886,8 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -1904,8 +1904,8 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "Inflector", "const-hex", @@ -1920,15 +1920,15 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.29", - "toml 0.7.6", + "syn 2.0.31", + "toml 0.7.8", "walkdir", ] [[package]] name = "ethers-contract-derive" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "Inflector", "const-hex", @@ -1937,13 +1937,13 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] name = "ethers-core" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "arrayvec", "bytes", @@ -1962,7 +1962,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.29", + "syn 2.0.31", "tempfile", "thiserror", "tiny-keccak", @@ -1971,8 +1971,8 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "ethers-core", "ethers-solc", @@ -1986,8 +1986,8 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "async-trait", "auto_impl", @@ -2012,8 +2012,8 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "async-trait", "auto_impl", @@ -2050,8 +2050,8 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "async-trait", "coins-bip32", @@ -2077,8 +2077,8 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.9" -source = "git+https://github.com/gakonst/ethers-rs#df28b2a4ad07d63e768f6605650e2daa5eb3ada4" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" dependencies = [ "cfg-if", "const-hex", @@ -2165,7 +2165,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2175,7 +2175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.11", + "rustix 0.38.12", "windows-sys 0.48.0", ] @@ -2209,7 +2209,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.7.6", + "toml 0.7.8", "uncased", "version_check", ] @@ -2352,7 +2352,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.7.6", + "toml 0.7.8", "tracing", "warp", ] @@ -2368,7 +2368,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.7.6", + "toml 0.7.8", "tracing", "tracing-subscriber", ] @@ -2392,7 +2392,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-macros", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2504,7 +2504,7 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.7.6", + "toml 0.7.8", "toml_edit", "tracing", "walkdir", @@ -2561,7 +2561,7 @@ version = "0.2.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2712,7 +2712,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -3606,7 +3606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.11", + "rustix 0.38.12", "windows-sys 0.48.0", ] @@ -3834,9 +3834,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" @@ -4019,7 +4019,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4111,6 +4111,17 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.4.0", + "cfg-if", + "libc", +] + [[package]] name = "nodrop" version = "0.1.14" @@ -4275,7 +4286,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4295,9 +4306,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -4379,7 +4390,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4390,9 +4401,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.92" +version = "0.9.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7e971c2c2bba161b2d2fdf37080177eff520b3bc044787c7f1f5f9e78d869b" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ "cc", "libc", @@ -4580,7 +4591,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4629,7 +4640,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4732,7 +4743,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4770,7 +4781,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4859,12 +4870,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4932,7 +4943,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", "version_check", "yansi 1.0.0-rc.1", ] @@ -5586,14 +5597,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "bdf14a7a466ce88b5eac3da815b53aefc208ce7e74d1c263aabb04d88c4abeb1" dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys 0.4.7", "windows-sys 0.48.0", ] @@ -5694,7 +5705,7 @@ dependencies = [ "libc", "log", "memchr", - "nix", + "nix 0.26.4", "radix_trie", "scopeguard", "unicode-segmentation", @@ -5898,14 +5909,14 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" dependencies = [ "indexmap 2.0.0", "itoa", @@ -5966,7 +5977,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -6048,9 +6059,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shlex" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signal-hook" @@ -6281,7 +6292,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -6349,9 +6360,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", "quote", @@ -6391,7 +6402,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.11", + "rustix 0.38.12", "windows-sys 0.48.0", ] @@ -6466,7 +6477,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -6599,7 +6610,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -6710,9 +6721,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "indexmap 2.0.0", "serde", @@ -6732,9 +6743,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.0.0", "serde", @@ -6836,7 +6847,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -7196,9 +7207,9 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -7276,7 +7287,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", "wasm-bindgen-shared", ] @@ -7310,7 +7321,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7335,7 +7346,7 @@ dependencies = [ "futures", "ignore-files", "miette", - "nix", + "nix 0.26.4", "normalize-path", "notify", "once_cell", @@ -7353,7 +7364,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01603bbe02fd75918f010dadad456d47eda14fb8fdcab276b0b4b8362f142ae3" dependencies = [ - "nix", + "nix 0.26.4", "notify", "watchexec-signals", ] @@ -7365,7 +7376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc2a5df96c388901c94ca04055fcd51d4196ca3e971c5e805bd4a4b61dd6a7e5" dependencies = [ "miette", - "nix", + "nix 0.26.4", "thiserror", ] @@ -7406,13 +7417,14 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "which" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ "either", - "libc", + "home", "once_cell", + "rustix 0.38.12", ] [[package]] @@ -7636,9 +7648,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1" +checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a" [[package]] name = "yansi" @@ -7669,7 +7681,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] From 3a53c9bdcf81d592b63a3678fcde3f1316440c57 Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Sun, 10 Sep 2023 11:35:30 +0200 Subject: [PATCH 0066/1963] feat(ci): feature-checks (#5789) --- .github/workflows/test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc4ed94ddcd85..a1eeea521be70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -152,3 +152,15 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: forge fmt run: cargo run --bin forge -- fmt --check testdata/ + + feature-checks: + name: feature checks + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@cargo-hack + - uses: Swatinem/rust-cache@v2 + - name: cargo hack + run: cargo hack check \ No newline at end of file From 5cfed63071ef1bb06f90190d2f678f546bfc971c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 10 Sep 2023 12:05:35 +0200 Subject: [PATCH 0067/1963] test: add test for #5808 (#5809) --- .../src/executor/inspector/cheatcodes/ext.rs | 2 +- crates/forge/tests/it/repros.rs | 6 ++++++ testdata/repros/Issue5808.t.sol | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 testdata/repros/Issue5808.t.sol diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index 8f26e74e00a11..f61bcbaf6bb70 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -341,7 +341,7 @@ fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { s.retain(|c: char| c != '"'); s }; - trace!(target : "forge::evm", ?values, "parsign values"); + trace!(target : "forge::evm", ?values, "parsing values"); return if let Some(array) = values[0].as_array() { parse::parse_array(array.iter().map(to_string), &coercion_type) } else { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 1fc8522d407b0..b46a46abb360c 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -289,3 +289,9 @@ async fn test_issue_5038() { async fn test_issue_3792() { test_repro!("Issue3792"); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_issue_5808() { + test_repro!("Issue5808"); +} diff --git a/testdata/repros/Issue5808.t.sol b/testdata/repros/Issue5808.t.sol new file mode 100644 index 0000000000000..2c5845a0b1bcb --- /dev/null +++ b/testdata/repros/Issue5808.t.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/5808 +contract Issue5808Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testReadInt() public { + string memory json = '["ffffffff","00000010"]'; + int256[] memory ints = vm.parseJsonIntArray(json, ""); + assertEq(ints[0], 4294967295); + assertEq(ints[1], 10); + } +} From 7e896535382e6bb3075f4583c0cc415fe756cf6d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:00:46 +0200 Subject: [PATCH 0068/1963] chore: bump revm (#5792) * chore: bump revm * chore: update env chain ID to u64 * chore: drop fork * fix tests * bump --- Cargo.lock | 350 ++++-------------- Cargo.toml | 6 +- crates/anvil/src/config.rs | 4 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/genesis.rs | 2 +- crates/evm/Cargo.toml | 1 + .../evm/src/executor/backend/in_memory_db.rs | 19 +- crates/evm/src/executor/fork/cache.rs | 2 +- crates/evm/src/executor/fork/init.rs | 2 +- crates/evm/src/executor/fork/multi.rs | 2 +- .../src/executor/inspector/cheatcodes/env.rs | 2 +- crates/evm/src/executor/inspector/stack.rs | 6 +- crates/evm/src/executor/opts.rs | 4 +- crates/evm/src/utils.rs | 2 +- crates/evm/test-data/storage.json | 2 +- 15 files changed, 100 insertions(+), 306 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f711b3dcf3cd8..7c213c98e1f9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,17 +75,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" -[[package]] -name = "alloy-rlp" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f938f00332d63a5b0ac687bd6f46d03884638948921d9f8b50c59563d421ae25" -dependencies = [ - "arrayvec", - "bytes", - "smol_str", -] - [[package]] name = "ammonia" version = "3.3.0" @@ -280,130 +269,6 @@ dependencies = [ "yansi 0.5.1", ] -[[package]] -name = "ark-ff" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" -dependencies = [ - "ark-ff-asm 0.3.0", - "ark-ff-macros 0.3.0", - "ark-serialize 0.3.0", - "ark-std 0.3.0", - "derivative", - "num-bigint", - "num-traits", - "paste", - "rustc_version 0.3.3", - "zeroize", -] - -[[package]] -name = "ark-ff" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" -dependencies = [ - "ark-ff-asm 0.4.2", - "ark-ff-macros 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "derivative", - "digest 0.10.7", - "itertools 0.10.5", - "num-bigint", - "num-traits", - "paste", - "rustc_version 0.4.0", - "zeroize", -] - -[[package]] -name = "ark-ff-asm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-asm" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" -dependencies = [ - "num-bigint", - "num-traits", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-serialize" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" -dependencies = [ - "ark-std 0.3.0", - "digest 0.9.0", -] - -[[package]] -name = "ark-serialize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" -dependencies = [ - "ark-std 0.4.0", - "digest 0.10.7", - "num-bigint", -] - -[[package]] -name = "ark-std" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" -dependencies = [ - "num-traits", - "rand 0.8.5", -] - -[[package]] -name = "ark-std" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" -dependencies = [ - "num-traits", - "rand 0.8.5", -] - [[package]] name = "array-init" version = "0.0.4" @@ -445,7 +310,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -456,7 +321,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -467,7 +332,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version 0.4.0", + "rustc_version", ] [[package]] @@ -579,9 +444,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -766,7 +631,7 @@ checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" dependencies = [ "camino", "cargo-platform", - "semver 1.0.18", + "semver", "serde", "serde_json", "thiserror", @@ -813,7 +678,7 @@ dependencies = [ "rpassword", "rusoto_core", "rusoto_kms", - "semver 1.0.18", + "semver", "serde", "serde_json", "tempfile", @@ -867,7 +732,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.18", + "semver", "serde", "serde_json", "serial_test", @@ -983,7 +848,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -1054,7 +919,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bech32", "bs58", "digest 0.10.7", @@ -1479,17 +1344,6 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -1499,7 +1353,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", + "rustc_version", "syn 1.0.109", ] @@ -1701,7 +1555,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0be7b2ac146c1f99fe245c02d16af0696450d8e06c135db75e10eeb9e642c20d" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "hex", "k256", @@ -1722,7 +1576,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -1920,7 +1774,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.31", + "syn 2.0.32", "toml 0.7.8", "walkdir", ] @@ -1937,7 +1791,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -1962,7 +1816,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.31", + "syn 2.0.32", "tempfile", "thiserror", "tiny-keccak", @@ -1977,7 +1831,7 @@ dependencies = [ "ethers-core", "ethers-solc", "reqwest", - "semver 1.0.18", + "semver", "serde", "serde_json", "thiserror", @@ -2017,7 +1871,7 @@ source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd7 dependencies = [ "async-trait", "auto_impl", - "base64 0.21.3", + "base64 0.21.4", "bytes", "const-hex", "enr", @@ -2067,7 +1921,7 @@ dependencies = [ "rand 0.8.5", "rusoto_core", "rusoto_kms", - "semver 1.0.18", + "semver", "sha2 0.10.7", "spki", "thiserror", @@ -2096,7 +1950,7 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", - "semver 1.0.18", + "semver", "serde", "serde_json", "sha2 0.10.7", @@ -2165,7 +2019,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -2175,7 +2029,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.12", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -2312,7 +2166,7 @@ dependencies = [ "rayon", "regex", "reqwest", - "semver 1.0.18", + "semver", "serde", "serde_json", "serial_test", @@ -2392,7 +2246,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-macros", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -2466,7 +2320,7 @@ dependencies = [ "once_cell", "regex", "reqwest", - "semver 1.0.18", + "semver", "serde", "serde_json", "tempfile", @@ -2498,7 +2352,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.18", + "semver", "serde", "serde_json", "serde_regex", @@ -2533,7 +2387,7 @@ dependencies = [ "parking_lot", "proptest", "revm", - "semver 1.0.18", + "semver", "serde", "serde_json", "tempfile", @@ -2561,7 +2415,7 @@ version = "0.2.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -2712,7 +2566,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -3176,7 +3030,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "headers-core", "http", @@ -3606,7 +3460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.12", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -3669,7 +3523,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "pem", "ring", "serde", @@ -4019,7 +3873,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4286,7 +4140,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4390,7 +4244,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4591,7 +4445,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4640,7 +4494,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4671,7 +4525,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ "futures", - "rustc_version 0.4.0", + "rustc_version", ] [[package]] @@ -4743,7 +4597,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4781,7 +4635,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4875,7 +4729,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -4943,7 +4797,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", "version_check", "yansi 1.0.0-rc.1", ] @@ -5251,7 +5105,7 @@ version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -5291,10 +5145,9 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" +source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" dependencies = [ "auto_impl", - "once_cell", "rayon", "revm-interpreter", "revm-precompile", @@ -5305,7 +5158,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" +source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" dependencies = [ "derive_more", "enumn", @@ -5317,7 +5170,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" +source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" dependencies = [ "k256", "num", @@ -5332,7 +5185,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=6b55b9c0ab264c000e087c2f54f2d8dc24b869aa#6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" +source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" dependencies = [ "auto_impl", "bitflags 2.4.0", @@ -5349,7 +5202,6 @@ dependencies = [ "ruint", "serde", "sha3", - "to-binary", ] [[package]] @@ -5435,13 +5287,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" dependencies = [ - "alloy-rlp", - "ark-ff 0.3.0", - "ark-ff 0.4.2", - "bytes", - "fastrlp", - "num-bigint", - "parity-scale-codec", "primitive-types", "proptest", "rand 0.8.5", @@ -5486,7 +5331,7 @@ dependencies = [ "log", "rusoto_credential", "rusoto_signature", - "rustc_version 0.4.0", + "rustc_version", "serde", "serde_json", "tokio", @@ -5545,7 +5390,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rusoto_credential", - "rustc_version 0.4.0", + "rustc_version", "serde", "sha2 0.9.9", "tokio", @@ -5563,22 +5408,13 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.18", + "semver", ] [[package]] @@ -5597,9 +5433,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.12" +version = "0.38.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf14a7a466ce88b5eac3da815b53aefc208ce7e74d1c263aabb04d88c4abeb1" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" dependencies = [ "bitflags 2.4.0", "errno", @@ -5650,7 +5486,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", ] [[package]] @@ -5842,15 +5678,6 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.18" @@ -5860,15 +5687,6 @@ dependencies = [ "serde", ] -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "send_wrapper" version = "0.4.0" @@ -5909,7 +5727,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -5977,7 +5795,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -6151,15 +5969,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" -[[package]] -name = "smol_str" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" -dependencies = [ - "serde", -] - [[package]] name = "socket2" version = "0.4.9" @@ -6292,7 +6101,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -6325,7 +6134,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver 1.0.18", + "semver", "serde", "serde_json", "sha2 0.10.7", @@ -6342,7 +6151,7 @@ checksum = "2271abd7d01895a3e5bfa4b578e32f09155002ce1ec239532e297f82aafad06b" dependencies = [ "build_const", "hex", - "semver 1.0.18", + "semver", "serde_json", "svm-rs", ] @@ -6360,9 +6169,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.31" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote", @@ -6402,7 +6211,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.12", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -6477,7 +6286,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -6574,15 +6383,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "to-binary" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424552bc848fd1afbcd81f0e8a54b7401b90fd81bb418655ad6dc6d0823bbe3" -dependencies = [ - "hex", -] - [[package]] name = "tokio" version = "1.32.0" @@ -6610,7 +6410,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -6847,7 +6647,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -7287,7 +7087,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", "wasm-bindgen-shared", ] @@ -7321,7 +7121,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.31", + "syn 2.0.32", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7424,7 +7224,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.12", + "rustix 0.38.13", ] [[package]] @@ -7629,7 +7429,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version 0.4.0", + "rustc_version", "send_wrapper 0.6.0", "thiserror", "wasm-bindgen", @@ -7669,20 +7469,6 @@ name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.31", -] [[package]] name = "zip" diff --git a/Cargo.toml b/Cargo.toml index 494fa3f545793..97cc3a9ddceb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,5 +159,7 @@ tikv-jemallocator = "0.5.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm/", rev = "6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" } -revm-primitives = { git = "https://github.com/bluealloy/revm/", rev = "6b55b9c0ab264c000e087c2f54f2d8dc24b869aa" } +revm = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } +revm-interpreter = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } +revm-precompile = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } +revm-primitives = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 653847839a279..e9e4a7ae2866b 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -784,7 +784,7 @@ impl NodeConfig { let mut cfg = CfgEnv::default(); cfg.spec_id = self.get_hardfork().into(); - cfg.chain_id = rU256::from(self.get_chain_id()); + cfg.chain_id = self.get_chain_id(); cfg.limit_contract_code_size = self.code_size_limit; // EIP-3607 rejects transactions from senders with deployed code. // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the @@ -936,7 +936,7 @@ latest block number: {latest_block}" // need to update the dev signers and env with the chain id self.set_chain_id(Some(chain_id)); - env.cfg.chain_id = rU256::from(chain_id); + env.cfg.chain_id = chain_id; env.tx.chain_id = chain_id.into(); chain_id }; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 488e5f3f194fe..b443ea2e365d0 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -365,7 +365,7 @@ impl Backend { // update all settings related to the forked block { let mut env = self.env.write(); - env.cfg.chain_id = rU256::from(fork.chain_id()); + env.cfg.chain_id = fork.chain_id(); env.block = BlockEnv { number: rU256::from(fork_block_number), diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 71b64feebd682..093ab0ddb0d50 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -86,7 +86,7 @@ impl Genesis { /// Applies all settings to the given `env` pub fn apply(&self, env: &mut Env) { if let Some(chain_id) = self.chain_id() { - env.cfg.chain_id = rU256::from(chain_id); + env.cfg.chain_id = chain_id; } if let Some(timestamp) = self.timestamp { env.block.timestamp = rU256::from(timestamp); diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 55d0e0c04469e..257d849e3010f 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -66,5 +66,6 @@ walkdir = "2" semver = "1" [dev-dependencies] +ethers = { workspace = true, features = ["ethers-solc", "rustls"] } foundry-utils.workspace = true tempfile = "3" diff --git a/crates/evm/src/executor/backend/in_memory_db.rs b/crates/evm/src/executor/backend/in_memory_db.rs index 0340d2de770cf..73373343497c8 100644 --- a/crates/evm/src/executor/backend/in_memory_db.rs +++ b/crates/evm/src/executor/backend/in_memory_db.rs @@ -81,24 +81,28 @@ impl DatabaseCommit for MemDb { /// /// This will also _always_ return `Some(AccountInfo)`: /// -/// The [`Database`](revm::Database) implementation for `CacheDB` manages an `AccountState` for the `DbAccount`, this will be set to `AccountState::NotExisting` if the account does not exist yet. This is because there's a distinction between "non-existing" and "empty", See +/// The [`Database`](revm::Database) implementation for `CacheDB` manages an `AccountState` for the +/// `DbAccount`, this will be set to `AccountState::NotExisting` if the account does not exist yet. +/// This is because there's a distinction between "non-existing" and "empty", +/// see . /// If an account is `NotExisting`, `Database(Ref)::basic` will always return `None` for the -/// requested `AccountInfo`. To prevent -/// -/// This will ensure that a missing account is never marked as `NotExisting` +/// requested `AccountInfo`. To prevent this, we ensure that a missing account is never marked as +/// `NotExisting` by always returning `Some` with this type. #[derive(Debug, Default, Clone)] pub struct EmptyDBWrapper(EmptyDB); impl DatabaseRef for EmptyDBWrapper { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, _address: B160) -> Result, Self::Error> { // Note: this will always return `Some(AccountInfo)`, for the reason explained above - Ok(Some(self.0.basic(address)?.unwrap_or_default())) + Ok(Some(AccountInfo::default())) } + fn code_by_hash(&self, code_hash: B256) -> Result { Ok(self.0.code_by_hash(code_hash)?) } + fn storage(&self, address: B160, index: U256) -> Result { Ok(self.0.storage(address, index)?) } @@ -128,7 +132,8 @@ mod tests { // insert the modified account info db.insert_account_info(address, info); - // when fetching again, the `AccountInfo` is still `None` because the state of the account is `AccountState::NotExisting`, See + // when fetching again, the `AccountInfo` is still `None` because the state of the account + // is `AccountState::NotExisting`, see let info = Database::basic(&mut db, address).unwrap(); assert!(info.is_none()); } diff --git a/crates/evm/src/executor/fork/cache.rs b/crates/evm/src/executor/fork/cache.rs index 8a5f18dc6edfa..12d04869ce531 100644 --- a/crates/evm/src/executor/fork/cache.rs +++ b/crates/evm/src/executor/fork/cache.rs @@ -476,7 +476,7 @@ mod tests { let s = r#"{ "meta": { "cfg_env": { - "chain_id": "0x539", + "chain_id": 1337, "spec_id": "LATEST", "perf_all_precompiles_have_balance": false, "disable_coinbase_tip": false, diff --git a/crates/evm/src/executor/fork/init.rs b/crates/evm/src/executor/fork/init.rs index 886129053b1e5..0c42b3e03bb3a 100644 --- a/crates/evm/src/executor/fork/init.rs +++ b/crates/evm/src/executor/fork/init.rs @@ -59,7 +59,7 @@ where }; let mut cfg = CfgEnv::default(); - cfg.chain_id = u256_to_ru256(override_chain_id.unwrap_or(rpc_chain_id.as_u64()).into()); + cfg.chain_id = override_chain_id.unwrap_or(rpc_chain_id.as_u64()); cfg.memory_limit = memory_limit; cfg.limit_contract_code_size = Some(usize::MAX); // EIP-3607 rejects transactions from senders with deployed code. diff --git a/crates/evm/src/executor/fork/multi.rs b/crates/evm/src/executor/fork/multi.rs index 27ab759eb97a9..a3edb576a8608 100644 --- a/crates/evm/src/executor/fork/multi.rs +++ b/crates/evm/src/executor/fork/multi.rs @@ -501,7 +501,7 @@ async fn create_fork( // determine the cache path if caching is enabled let cache_path = if fork.enable_caching { - Config::foundry_block_cache_dir(ru256_to_u256(meta.cfg_env.chain_id).as_u64(), number) + Config::foundry_block_cache_dir(meta.cfg_env.chain_id, number) } else { None }; diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index bd122387697e2..70110229ee95f 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -547,7 +547,7 @@ pub fn apply( } HEVMCalls::ChainId(inner) => { ensure!(inner.0 <= U256::from(u64::MAX), "Chain ID must be less than 2^64 - 1"); - data.env.cfg.chain_id = inner.0.into(); + data.env.cfg.chain_id = inner.0.as_u64(); Bytes::new() } HEVMCalls::TxGasPrice(inner) => { diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index d626fc3d4e33a..759131d3088e2 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -16,7 +16,7 @@ use revm::{ interpreter::{ return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, Stack, }, - primitives::{BlockEnv, Env, B160, B256}, + primitives::{BlockEnv, Env, B160, B256, U256 as rU256}, EVMData, Inspector, }; use std::{collections::BTreeMap, sync::Arc}; @@ -568,7 +568,7 @@ impl Inspector for InspectorStack { (status, address, remaining_gas, retdata) } - fn selfdestruct(&mut self, contract: B160, target: B160) { + fn selfdestruct(&mut self, contract: B160, target: B160, value: rU256) { call_inspectors!( [ &mut self.debugger, @@ -579,7 +579,7 @@ impl Inspector for InspectorStack { &mut self.chisel_state ], |inspector| { - Inspector::::selfdestruct(inspector, contract, target); + Inspector::::selfdestruct(inspector, contract, target, value); } ); } diff --git a/crates/evm/src/executor/opts.rs b/crates/evm/src/executor/opts.rs index e572ff81dbf9b..eeef6924f51c4 100644 --- a/crates/evm/src/executor/opts.rs +++ b/crates/evm/src/executor/opts.rs @@ -94,7 +94,7 @@ impl EvmOpts { /// Returns the `revm::Env` configured with only local settings pub fn local_evm_env(&self) -> revm::primitives::Env { let mut cfg = CfgEnv::default(); - cfg.chain_id = rU256::from(self.env.chain_id.unwrap_or(foundry_common::DEV_CHAIN_ID)); + cfg.chain_id = self.env.chain_id.unwrap_or(foundry_common::DEV_CHAIN_ID); cfg.spec_id = SpecId::MERGE; cfg.limit_contract_code_size = self.env.code_size_limit.or(Some(usize::MAX)); cfg.memory_limit = self.memory_limit; @@ -138,7 +138,7 @@ impl EvmOpts { /// be at `~/.foundry/cache/mainnet/14435000/storage.json` pub fn get_fork(&self, config: &Config, env: revm::primitives::Env) -> Option { let url = self.fork_url.clone()?; - let enable_caching = config.enable_caching(&url, env.cfg.chain_id.to::()); + let enable_caching = config.enable_caching(&url, env.cfg.chain_id); Some(CreateFork { url, enable_caching, env, evm_opts: self.clone() }) } diff --git a/crates/evm/src/utils.rs b/crates/evm/src/utils.rs index 3f15523d7822d..23f83b2640850 100644 --- a/crates/evm/src/utils.rs +++ b/crates/evm/src/utils.rs @@ -119,7 +119,7 @@ pub fn apply_chain_and_block_specific_env_changes( env: &mut revm::primitives::Env, block: &Block, ) { - if let Ok(chain) = Chain::try_from(ru256_to_u256(env.cfg.chain_id)) { + if let Ok(chain) = Chain::try_from(env.cfg.chain_id) { let block_number = block.number.unwrap_or_default(); match chain { diff --git a/crates/evm/test-data/storage.json b/crates/evm/test-data/storage.json index 7544ef1be56c7..4f25625919b23 100644 --- a/crates/evm/test-data/storage.json +++ b/crates/evm/test-data/storage.json @@ -1 +1 @@ -{"meta":{"cfg_env":{"chain_id":"0x1","spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295, "perf_analyse_created_bytecodes":"Analyse", "limit_contract_code_size": 24576, "disable_coinbase_tip": false},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} \ No newline at end of file +{"meta":{"cfg_env":{"chain_id":1,"spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295, "perf_analyse_created_bytecodes":"Analyse", "limit_contract_code_size": 24576, "disable_coinbase_tip": false},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} \ No newline at end of file From 523354e96b33082aea10019573b27b52af01a82c Mon Sep 17 00:00:00 2001 From: Franfran <51274081+iFrostizz@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:48:25 +0200 Subject: [PATCH 0069/1963] Debugger Refactor #2: `DebuggerArgs` (#5753) * fuzz single refactor * add struct docs * Update crates/evm/src/fuzz/mod.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * add docs and move types to types.rs * fmt * add new debugger args type * add minimal debugger-refactor changes * finish him! * fmt * remove TODO * minimal diff * apply review suggestions * add TODO * looks better * make ContractSources wrapper * add more docki docs * write file_id docs! --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 1 + crates/cli/src/utils/cmd.rs | 46 +- crates/common/src/compile.rs | 28 +- crates/common/src/contracts.rs | 19 +- crates/evm/src/debug.rs | 6 +- crates/evm/src/fuzz/mod.rs | 16 +- crates/evm/src/trace/identifier/etherscan.rs | 25 +- crates/forge/bin/cmd/debug.rs | 7 +- crates/forge/bin/cmd/script/build.rs | 101 +-- crates/forge/bin/cmd/script/cmd.rs | 17 +- crates/forge/bin/cmd/script/executor.rs | 1 + crates/forge/bin/cmd/script/mod.rs | 59 +- crates/forge/bin/cmd/script/runner.rs | 7 +- crates/forge/bin/cmd/test/mod.rs | 208 +++++-- crates/forge/bin/main.rs | 4 +- crates/forge/src/multi_runner.rs | 42 +- crates/forge/src/result.rs | 4 + crates/forge/src/runner.rs | 68 +- crates/ui/Cargo.toml | 3 +- crates/ui/src/debugger.rs | 47 ++ crates/ui/src/lib.rs | 621 +++++++++---------- 21 files changed, 727 insertions(+), 603 deletions(-) create mode 100644 crates/ui/src/debugger.rs diff --git a/Cargo.lock b/Cargo.lock index 7c213c98e1f9f..c0fe3f39c3da9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6844,6 +6844,7 @@ dependencies = [ "foundry-evm", "ratatui", "revm", + "tracing", ] [[package]] diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 4323ddb2c6463..8e58fe8d9bc85 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -2,11 +2,11 @@ use ethers::{ abi::Abi, core::types::Chain, solc::{ - artifacts::{CompactBytecode, CompactDeployedBytecode, ContractBytecodeSome}, + artifacts::{CompactBytecode, CompactDeployedBytecode}, cache::{CacheEntry, SolFilesCache}, info::ContractInfo, utils::read_json_file, - Artifact, ArtifactId, ProjectCompileOutput, + Artifact, ProjectCompileOutput, }, }; use eyre::{Result, WrapErr}; @@ -20,9 +20,9 @@ use foundry_evm::{ CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, }; -use std::{collections::BTreeMap, fmt::Write, path::PathBuf, str::FromStr}; +use std::{fmt::Write, path::PathBuf, str::FromStr}; use tracing::trace; -use ui::{TUIExitReason, Tui, Ui}; +use ui::DebuggerArgs; use yansi::Paint; /// Given a `Project`'s output, removes the matching ABI, Bytecode and @@ -391,8 +391,14 @@ pub async fn handle_traces( } if debug { - let (sources, bytecode) = etherscan_identifier.get_compiled_contracts().await?; - run_debugger(result, decoder, bytecode, sources)?; + let sources = etherscan_identifier.get_compiled_contracts().await?; + let debugger = DebuggerArgs { + debug: vec![result.debug], + decoder: &decoder, + sources, + breakpoints: Default::default(), + }; + debugger.run()?; } else { print_traces(&mut result, &decoder, verbose).await?; } @@ -429,31 +435,3 @@ pub async fn print_traces( println!("Gas used: {}", result.gas_used); Ok(()) } - -pub fn run_debugger( - result: TraceResult, - decoder: CallTraceDecoder, - known_contracts: BTreeMap, - sources: BTreeMap, -) -> Result<()> { - let calls: Vec = vec![result.debug]; - let flattened = calls.last().expect("we should have collected debug info").flatten(0); - let tui = Tui::new( - flattened, - 0, - decoder.contracts, - known_contracts.into_iter().map(|(id, artifact)| (id.name, artifact)).collect(), - sources - .into_iter() - .map(|(id, source)| { - let mut sources = BTreeMap::new(); - sources.insert(0, source); - (id.name, sources) - }) - .collect(), - Default::default(), - )?; - match tui.start().expect("Failed to start tui") { - TUIExitReason::CharExit => Ok(()), - } -} diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 37d765ae2b747..bfe9ec9901a30 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,5 +1,5 @@ //! Support for compiling [ethers::solc::Project] -use crate::{glob::GlobMatcher, term, TestFunctionExt}; +use crate::{compact_to_contract, glob::GlobMatcher, term, TestFunctionExt}; use comfy_table::{presets::ASCII_MARKDOWN, *}; use ethers_etherscan::contract::Metadata; use ethers_solc::{ @@ -11,7 +11,7 @@ use ethers_solc::{ }; use eyre::Result; use std::{ - collections::BTreeMap, + collections::{BTreeMap, HashMap}, convert::Infallible, fmt::Display, path::{Path, PathBuf}, @@ -171,6 +171,10 @@ impl ProjectCompiler { } } +/// Map over artifacts contract sources name -> file_id -> (source, contract) +#[derive(Default, Debug, Clone)] +pub struct ContractSources(pub HashMap>); + // https://eips.ethereum.org/EIPS/eip-170 const CONTRACT_SIZE_LIMIT: usize = 24576; @@ -398,10 +402,11 @@ pub fn compile_target_with_filter( } } -/// Creates and compiles a project from an Etherscan source. +/// Compiles an Etherscan source from metadata by creating a project. +/// Returns the artifact_id, the file_id, and the bytecode pub async fn compile_from_source( metadata: &Metadata, -) -> Result<(ArtifactId, ContractBytecodeSome)> { +) -> Result<(ArtifactId, u32, ContractBytecodeSome)> { let root = tempfile::tempdir()?; let root_path = root.path(); let project = etherscan_project(metadata, root_path)?; @@ -412,19 +417,18 @@ pub async fn compile_from_source( eyre::bail!(project_output.to_string()) } - let (artifact_id, contract) = project_output - .into_contract_bytecodes() + let (artifact_id, file_id, contract) = project_output + .into_artifacts() .find(|(artifact_id, _)| artifact_id.name == metadata.contract_name) + .map(|(aid, art)| { + (aid, art.source_file().expect("no source file").id, art.into_contract_bytecode()) + }) .expect("there should be a contract with bytecode"); - let bytecode = ContractBytecodeSome { - abi: contract.abi.unwrap(), - bytecode: contract.bytecode.unwrap().into(), - deployed_bytecode: contract.deployed_bytecode.unwrap().into(), - }; + let bytecode = compact_to_contract(contract)?; root.close()?; - Ok((artifact_id, bytecode)) + Ok((artifact_id, file_id, bytecode)) } /// Creates a [Project] from an Etherscan source. diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 0440b000d9821..c819c41aefc3f 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -5,7 +5,10 @@ use ethers_core::{ types::{Address, H256}, utils::hex, }; -use ethers_solc::{artifacts::ContractBytecodeSome, ArtifactId, ProjectPathsConfig}; +use ethers_solc::{ + artifacts::{CompactContractBytecode, ContractBytecodeSome}, + ArtifactId, ProjectPathsConfig, +}; use once_cell::sync::Lazy; use regex::Regex; use std::{ @@ -265,3 +268,17 @@ mod tests { let _decoded = abi::decode(¶ms, args).unwrap(); } } + +/// Helper function to convert CompactContractBytecode ~> ContractBytecodeSome +pub fn compact_to_contract( + contract: CompactContractBytecode, +) -> eyre::Result { + Ok(ContractBytecodeSome { + abi: contract.abi.ok_or(eyre::eyre!("No contract abi"))?, + bytecode: contract.bytecode.ok_or(eyre::eyre!("No contract bytecode"))?.into(), + deployed_bytecode: contract + .deployed_bytecode + .ok_or(eyre::eyre!("No contract deployed bytecode"))? + .into(), + }) +} diff --git a/crates/evm/src/debug.rs b/crates/evm/src/debug.rs index 885830abb4da1..c229dbca90b3e 100644 --- a/crates/evm/src/debug.rs +++ b/crates/evm/src/debug.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use std::fmt::Display; /// An arena of [DebugNode]s -#[derive(Default, Debug, Clone)] +#[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct DebugArena { /// The arena of nodes pub arena: Vec, @@ -78,7 +78,7 @@ impl DebugArena { } /// A node in the arena -#[derive(Default, Debug, Clone)] +#[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct DebugNode { /// Parent node index in the arena pub parent: Option, @@ -109,7 +109,7 @@ impl DebugNode { /// It holds the current program counter (where in the program you are), /// the stack and memory (prior to the opcodes execution), any bytes to be /// pushed onto the stack, and the instruction counter for use with sourcemap. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct DebugStep { /// Stack *prior* to running the associated opcode pub stack: Vec, diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index e0dc9e466fbba..f704a0696f88c 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -81,12 +81,7 @@ impl<'a> FuzzedExecutor<'a> { // Stores coverage information for all fuzz cases let coverage: RefCell> = RefCell::default(); - // Stores fuzz state for use with [fuzz_calldata_from_state] - let state: EvmFuzzState = if let Some(fork_db) = self.executor.backend.active_fork_db() { - build_initial_state(fork_db, &self.config.dictionary) - } else { - build_initial_state(self.executor.backend.mem_db(), &self.config.dictionary) - }; + let state = self.build_fuzz_state(); let mut weights = vec![]; let dictionary_weight = self.config.dictionary.dictionary_weight.min(100); @@ -248,6 +243,15 @@ impl<'a> FuzzedExecutor<'a> { })) } } + + /// Stores fuzz state for use with [fuzz_calldata_from_state] + pub fn build_fuzz_state(&self) -> EvmFuzzState { + if let Some(fork_db) = self.executor.backend.active_fork_db() { + build_initial_state(fork_db, &self.config.dictionary) + } else { + build_initial_state(self.executor.backend.mem_db(), &self.config.dictionary) + } + } } #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/crates/evm/src/trace/identifier/etherscan.rs b/crates/evm/src/trace/identifier/etherscan.rs index b9bdf43feb100..2658c032aac37 100644 --- a/crates/evm/src/trace/identifier/etherscan.rs +++ b/crates/evm/src/trace/identifier/etherscan.rs @@ -4,10 +4,10 @@ use ethers::{ abi::Address, etherscan, etherscan::contract::{ContractMetadata, Metadata}, - prelude::{artifacts::ContractBytecodeSome, errors::EtherscanError, ArtifactId}, + prelude::errors::EtherscanError, types::H160, }; -use foundry_common::compile; +use foundry_common::compile::{self, ContractSources}; use foundry_config::{Chain, Config}; use futures::{ future::{join_all, Future}, @@ -58,13 +58,7 @@ impl EtherscanIdentifier { /// Goes over the list of contracts we have pulled from the traces, clones their source from /// Etherscan and compiles them locally, for usage in the debugger. - pub async fn get_compiled_contracts( - &self, - ) -> eyre::Result<(BTreeMap, BTreeMap)> - { - let mut compiled_contracts = BTreeMap::new(); - let mut sources = BTreeMap::new(); - + pub async fn get_compiled_contracts(&self) -> eyre::Result { // TODO: Add caching so we dont double-fetch contracts. let contracts_iter = self .contracts @@ -87,15 +81,20 @@ impl EtherscanIdentifier { // poll all the futures concurrently let artifacts = join_all(outputs_fut).await; + let mut sources: ContractSources = Default::default(); + // construct the map for (results, (_, metadata)) in artifacts.into_iter().zip(contracts_iter) { // get the inner type - let (artifact_id, bytecode) = results?; - compiled_contracts.insert(artifact_id.clone(), bytecode); - sources.insert(artifact_id, metadata.source_code()); + let (artifact_id, file_id, bytecode) = results?; + sources + .0 + .entry(artifact_id.clone().name) + .or_default() + .insert(file_id, (metadata.source_code(), bytecode)); } - Ok((sources, compiled_contracts)) + Ok(sources) } } diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs index abd7362720870..bdcea1c0db60c 100644 --- a/crates/forge/bin/cmd/debug.rs +++ b/crates/forge/bin/cmd/debug.rs @@ -1,8 +1,7 @@ use super::{build::BuildArgs, retry::RETRY_VERIFY_ON_CREATE, script::ScriptArgs}; use clap::{Parser, ValueHint}; -use eyre::Result; use foundry_cli::opts::CoreBuildArgs; -use foundry_common::evm::{Breakpoints, EvmArgs}; +use foundry_common::evm::EvmArgs; use std::path::PathBuf; // Loads project's figment and merges the build cli arguments into it @@ -41,7 +40,7 @@ pub struct DebugArgs { } impl DebugArgs { - pub async fn debug(self, breakpoints: Breakpoints) -> Result<()> { + pub async fn run(self) -> eyre::Result<()> { let script = ScriptArgs { path: self.path.to_str().expect("Invalid path string.").to_string(), args: self.args, @@ -54,6 +53,6 @@ impl DebugArgs { retry: RETRY_VERIFY_ON_CREATE, ..Default::default() }; - script.run_script(breakpoints).await + script.run_script().await } } diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index e80a4ec922494..1ed67955aba11 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,8 +1,7 @@ use super::*; use ethers::{ prelude::{ - artifacts::Libraries, cache::SolFilesCache, ArtifactId, Graph, Project, - ProjectCompileOutput, + artifacts::Libraries, cache::SolFilesCache, ArtifactId, Project, ProjectCompileOutput, }, solc::{ artifacts::{CompactContractBytecode, ContractBytecode, ContractBytecodeSome}, @@ -13,7 +12,10 @@ use ethers::{ }; use eyre::{Context, ContextCompat, Result}; use foundry_cli::utils::get_cached_entry_by_name; -use foundry_common::compile; +use foundry_common::{ + compact_to_contract, + compile::{self, ContractSources}, +}; use foundry_utils::{PostLinkInput, ResolvedDependency}; use std::{collections::BTreeMap, fs, str::FromStr}; use tracing::{trace, warn}; @@ -31,7 +33,7 @@ impl ScriptArgs { let (project, output) = self.get_project_and_output(script_config)?; let output = output.with_stripped_file_prefixes(project.root()); - let mut sources: BTreeMap = BTreeMap::new(); + let mut sources: ContractSources = Default::default(); let contracts = output .into_artifacts() @@ -39,13 +41,18 @@ impl ScriptArgs { // Sources are only required for the debugger, but it *might* mean that there's // something wrong with the build and/or artifacts. if let Some(source) = artifact.source_file() { - sources.insert( - source.id, - source - .ast - .ok_or(eyre::eyre!("Source from artifact has no AST."))? - .absolute_path, - ); + let abs_path = source + .ast + .ok_or(eyre::eyre!("Source from artifact has no AST."))? + .absolute_path; + let source_code = fs::read_to_string(abs_path)?; + let contract = artifact.clone().into_contract_bytecode(); + let source_contract = compact_to_contract(contract)?; + sources + .0 + .entry(id.clone().name) + .or_default() + .insert(source.id, (source_code, source_contract)); } else { warn!("source not found for artifact={:?}", id); } @@ -195,7 +202,7 @@ impl ScriptArgs { known_contracts: contracts, highlevel_known_contracts: ArtifactContracts(highlevel_known_contracts), predeploy_libraries, - sources: BTreeMap::new(), + sources: Default::default(), project, libraries: new_libraries, }) @@ -261,74 +268,6 @@ impl ScriptArgs { } } -/// Resolve the import tree of our target path, and get only the artifacts and -/// sources we need. If it's a standalone script, don't filter anything out. -pub fn filter_sources_and_artifacts( - target: &str, - sources: BTreeMap, - highlevel_known_contracts: ArtifactContracts, - project: Project, -) -> Result<(BTreeMap, HashMap)> { - // Find all imports - let graph = Graph::resolve(&project.paths)?; - let target_path = project.root().join(target); - let mut target_tree = BTreeMap::new(); - let mut is_standalone = false; - - if let Some(target_index) = graph.files().get(&target_path) { - target_tree.extend( - graph - .all_imported_nodes(*target_index) - .map(|index| graph.node(index).unpack()) - .collect::>(), - ); - - // Add our target into the tree as well. - let (target_path, target_source) = graph.node(*target_index).unpack(); - target_tree.insert(target_path, target_source); - } else { - is_standalone = true; - } - - let sources = sources - .into_iter() - .filter_map(|(id, path)| { - let mut resolved = project - .paths - .resolve_library_import(project.root(), &PathBuf::from(&path)) - .unwrap_or_else(|| PathBuf::from(&path)); - - if !resolved.is_absolute() { - resolved = project.root().join(&resolved); - } - - if !is_standalone { - target_tree.get(&resolved).map(|source| (id, source.content.as_str().to_string())) - } else { - Some(( - id, - fs::read_to_string(&resolved).unwrap_or_else(|_| { - panic!("Something went wrong reading the source file: {path:?}") - }), - )) - } - }) - .collect(); - - let artifacts = highlevel_known_contracts - .into_iter() - .filter_map(|(id, artifact)| { - if !is_standalone { - target_tree.get(&id.source).map(|_| (id.name, artifact)) - } else { - Some((id.name, artifact)) - } - }) - .collect(); - - Ok((sources, artifacts)) -} - struct ExtraLinkingInfo<'a> { no_target_name: bool, target_fname: String, @@ -346,5 +285,5 @@ pub struct BuildOutput { pub highlevel_known_contracts: ArtifactContracts, pub libraries: Libraries, pub predeploy_libraries: Vec, - pub sources: BTreeMap, + pub sources: ContractSources, } diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 70c836877cdcb..8185e6e9e7e9d 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -8,13 +8,14 @@ use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; use std::sync::Arc; use tracing::trace; +use ui::DebuggerArgs; /// Helper alias type for the collection of data changed due to the new sender. type NewSenderChanges = (CallTraceDecoder, Libraries, ArtifactContracts); impl ScriptArgs { /// Executes the script - pub async fn run_script(mut self, breakpoints: Breakpoints) -> Result<()> { + pub async fn run_script(mut self) -> Result<()> { trace!(target: "script", "executing script command"); let (config, evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; @@ -23,6 +24,7 @@ impl ScriptArgs { sender_nonce: U256::one(), config, evm_opts, + debug: self.debug, ..Default::default() }; @@ -83,14 +85,13 @@ impl ScriptArgs { let mut decoder = self.decode_traces(&script_config, &mut result, &known_contracts)?; if self.debug { - return self.run_debugger( - &decoder, + let debugger = DebuggerArgs { + debug: result.debug.clone().unwrap_or_default(), + decoder: &decoder, sources, - result, - project, - highlevel_known_contracts, - breakpoints, - ) + breakpoints: result.breakpoints.clone(), + }; + debugger.run()?; } if let Some((new_traces, updated_libraries, updated_contracts)) = self diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index bc31d78bfe916..d084c8caa7053 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -72,6 +72,7 @@ impl ScriptArgs { result.labeled_addresses.extend(script_result.labeled_addresses); result.returned = script_result.returned; result.script_wallets.extend(script_result.script_wallets); + result.breakpoints = script_result.breakpoints; match (&mut result.transactions, script_result.transactions) { (Some(txs), Some(new_txs)) => { diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 4e10066332f3c..519b35da2d570 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -1,7 +1,4 @@ -use self::{ - build::{filter_sources_and_artifacts, BuildOutput}, - runner::ScriptRunner, -}; +use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; use clap::{Parser, ValueHint}; use dialoguer::Confirm; @@ -56,12 +53,7 @@ use foundry_evm::{ }; use futures::future; use serde::{Deserialize, Serialize}; -use std::{ - collections::{BTreeMap, HashMap, HashSet, VecDeque}, - path::PathBuf, -}; -use tracing::log::trace; -use ui::{TUIExitReason, Tui, Ui}; +use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use yansi::Paint; mod artifacts; @@ -449,49 +441,6 @@ impl ScriptArgs { .collect() } - fn run_debugger( - &self, - decoder: &CallTraceDecoder, - sources: BTreeMap, - result: ScriptResult, - project: Project, - highlevel_known_contracts: ArtifactContracts, - breakpoints: Breakpoints, - ) -> Result<()> { - trace!(target: "script", "debugging script"); - - let (sources, artifacts) = filter_sources_and_artifacts( - &self.path, - sources, - highlevel_known_contracts.clone(), - project, - )?; - let flattened = result - .debug - .and_then(|arena| arena.last().map(|arena| arena.flatten(0))) - .expect("We should have collected debug information"); - let identified_contracts = decoder - .contracts - .iter() - .map(|(addr, identifier)| (*addr, get_contract_name(identifier).to_string())) - .collect(); - - let tui = Tui::new( - flattened, - 0, - identified_contracts, - artifacts, - highlevel_known_contracts - .into_iter() - .map(|(id, _)| (id.name, sources.clone())) - .collect(), - breakpoints, - )?; - match tui.start().expect("Failed to start tui") { - TUIExitReason::CharExit => Ok(()), - } - } - /// Returns the Function and calldata based on the signature /// /// If the `sig` is a valid human-readable function we find the corresponding function in the @@ -656,6 +605,7 @@ impl Provider for ScriptArgs { } } +#[derive(Default)] pub struct ScriptResult { pub success: bool, pub logs: Vec, @@ -667,6 +617,7 @@ pub struct ScriptResult { pub returned: bytes::Bytes, pub address: Option
, pub script_wallets: Vec, + pub breakpoints: Breakpoints, } #[derive(Serialize, Deserialize)] @@ -697,6 +648,8 @@ pub struct ScriptConfig { pub total_rpcs: HashSet, /// If true, one of the transactions did not have a rpc pub missing_rpc: bool, + /// Should return some debug information + pub debug: bool, } impl ScriptConfig { diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 8a50bb21eaf32..1781d9f9f5d57 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -167,6 +167,7 @@ impl ScriptRunner { debug, address: None, script_wallets, + ..Default::default() }, )) } @@ -236,10 +237,8 @@ impl ScriptRunner { }) .unwrap_or_default(), debug: vec![debug].into_iter().collect(), - labeled_addresses: Default::default(), - transactions: Default::default(), address: Some(address), - script_wallets: vec![], + ..Default::default() }) } else { eyre::bail!("ENS not supported."); @@ -284,6 +283,7 @@ impl ScriptRunner { script_wallets, .. } = res; + let breakpoints = res.cheatcodes.map(|cheats| cheats.breakpoints).unwrap_or_default(); Ok(ScriptResult { returned: result, @@ -302,6 +302,7 @@ impl ScriptRunner { transactions, address: None, script_wallets, + breakpoints, }) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index d2ab5c0de80ff..b04f799e1550d 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -1,4 +1,4 @@ -use super::{debug::DebugArgs, install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; +use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; use clap::Parser; use ethers::types::U256; use eyre::Result; @@ -6,7 +6,7 @@ use forge::{ decode::decode_console_logs, executor::inspector::CheatsConfig, gas_report::GasReport, - result::{SuiteResult, TestKind, TestResult, TestStatus}, + result::{SuiteResult, TestResult, TestStatus}, trace::{ identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, CallTraceDecoderBuilder, TraceKind, @@ -18,7 +18,8 @@ use foundry_cli::{ utils::{self, LoadConfig}, }; use foundry_common::{ - compile::{self, ProjectCompiler}, + compact_to_contract, + compile::{self, ContractSources, ProjectCompiler}, evm::EvmArgs, get_contract_name, get_file_name, shell, }; @@ -32,8 +33,9 @@ use foundry_config::{ }; use foundry_evm::fuzz::CounterExample; use regex::Regex; -use std::{collections::BTreeMap, path::PathBuf, sync::mpsc::channel, time::Duration}; +use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use tracing::trace; +use ui::DebuggerArgs; use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; @@ -177,64 +179,167 @@ impl TestArgs { let env = evm_opts.evm_env().await?; // Prepare the test builder - let mut runner = MultiContractRunnerBuilder::default() + let should_debug = self.debug.is_some(); + + let mut runner_builder = MultiContractRunnerBuilder::default() + .set_debug(should_debug) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) - .with_test_options(test_options.clone()) - .build(project_root, output, env, evm_opts)?; + .with_test_options(test_options.clone()); + + let mut runner = runner_builder.clone().build( + project_root, + output.clone(), + env.clone(), + evm_opts.clone(), + )?; + + if should_debug { + filter.args_mut().test_pattern = self.debug.clone(); + let n = runner.count_filtered_tests(&filter); + if n != 1 { + return Err( + eyre::eyre!("{n} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n + \n + Use --match-contract and --match-path to further limit the search.")); + } + let test_funcs = runner.get_typed_tests(&filter); + // if we debug a fuzz test, we should not collect data on the first run + if !test_funcs.get(0).unwrap().inputs.is_empty() { + runner_builder = runner_builder.set_debug(false); + runner = runner_builder.clone().build( + project_root, + output.clone(), + env.clone(), + evm_opts.clone(), + )?; + } + } - if self.debug.is_some() { - filter.args_mut().test_pattern = self.debug; - - match runner.count_filtered_tests(&filter) { - 1 => { - // Run the test - let results = runner.test(&filter, None, test_options).await; - - // Get the result of the single test - let (id, sig, test_kind, counterexample, breakpoints) = results.iter().map(|(id, SuiteResult{ test_results, .. })| { - let (sig, result) = test_results.iter().next().unwrap(); - - (id.clone(), sig.clone(), result.kind.clone(), result.counterexample.clone(), result.breakpoints.clone()) - }).next().unwrap(); - - // Build debugger args if this is a fuzz test - let sig = match test_kind { - TestKind::Fuzz { first_case, .. } => { - if let Some(CounterExample::Single(counterexample)) = counterexample { - counterexample.calldata.to_string() - } else { - first_case.calldata.to_string() - } - }, - _ => sig, - }; + let known_contracts = runner.known_contracts.clone(); + let mut local_identifier = LocalTraceIdentifier::new(&known_contracts); + let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - // Run the debugger - let mut opts = self.opts.clone(); - opts.silent = true; - let debugger = DebugArgs { - path: PathBuf::from(runner.source_paths.get(&id).unwrap()), - target_contract: Some(get_contract_name(&id).to_string()), - sig, - args: Vec::new(), - debug: true, - opts, - evm_opts: self.evm_opts, + let outcome = self + .run_tests(runner, config.clone(), verbosity, filter.clone(), test_options.clone()) + .await?; + let tests = outcome.clone().into_tests(); + + let mut decoded_traces = Vec::new(); + let mut decoders = Vec::new(); + for test in tests { + let mut result = test.result; + // Identify addresses in each trace + let mut builder = CallTraceDecoderBuilder::new() + .with_labels(result.labeled_addresses.clone()) + .with_events(local_identifier.events().cloned()) + .with_verbosity(verbosity); + + // Signatures are of no value for gas reports + if !self.gas_report { + let sig_identifier = + SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; + builder = builder.with_signature_identifier(sig_identifier.clone()); + } + + let mut decoder = builder.build(); + + if !result.traces.is_empty() { + // Set up identifiers + // Do not re-query etherscan for contracts that you've already queried today. + let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; + + // Decode the traces + for (kind, trace) in &mut result.traces { + decoder.identify(trace, &mut local_identifier); + decoder.identify(trace, &mut etherscan_identifier); + + let should_include = match kind { + // At verbosity level 3, we only display traces for failed tests + // At verbosity level 4, we also display the setup trace for failed + // tests At verbosity level 5, we display + // all traces for all tests + TraceKind::Setup => { + (verbosity >= 5) || + (verbosity == 4 && result.status == TestStatus::Failure) + } + TraceKind::Execution => { + verbosity > 3 || + (verbosity == 3 && result.status == TestStatus::Failure) + } + _ => false, }; - debugger.debug(breakpoints).await?; - Ok(TestOutcome::new(results, self.allow_failure)) + // We decode the trace if we either need to build a gas report or we need + // to print it + if should_include || self.gas_report { + decoder.decode(trace).await; + } + + if should_include { + decoded_traces.push(trace.to_string()); + } + } + } + + decoders.push(decoder); + } + + if should_debug { + let mut sources: ContractSources = Default::default(); + for (id, artifact) in output.into_artifacts() { + // Sources are only required for the debugger, but it *might* mean that there's + // something wrong with the build and/or artifacts. + if let Some(source) = artifact.source_file() { + let abs_path = source + .ast + .ok_or(eyre::eyre!("Source from artifact has no AST."))? + .absolute_path; + let source_code = fs::read_to_string(abs_path)?; + let contract = artifact.clone().into_contract_bytecode(); + let source_contract = compact_to_contract(contract)?; + sources + .0 + .entry(id.clone().name) + .or_default() + .insert(source.id, (source_code, source_contract)); } - n => - Err( - eyre::eyre!("{n} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n - \n - Use --match-contract and --match-path to further limit the search.")) } + + let test = outcome.clone().into_tests().next().unwrap(); + let result = test.result; + + // Run the debugger + let debugger = DebuggerArgs { + debug: result.debug.map_or(vec![], |debug| vec![debug]), + decoder: decoders.first().unwrap(), + sources, + breakpoints: result.breakpoints, + }; + debugger.run()?; + } + + Ok(outcome) + } + + /// Run all tests that matches the filter predicate from a test runner + pub async fn run_tests( + &self, + mut runner: MultiContractRunner, + config: Config, + verbosity: u8, + mut filter: ProjectPathsAwareFilter, + test_options: TestOptions, + ) -> eyre::Result { + if self.debug.is_some() { + filter.args_mut().test_pattern = self.debug.clone(); + // Run the test + let results = runner.test(&filter, None, test_options).await; + + Ok(TestOutcome::new(results, self.allow_failure)) } else if self.list { list(runner, filter, self.json) } else { @@ -327,6 +432,7 @@ impl Test { } /// Represents the bundled results of all tests +#[derive(Clone)] pub struct TestOutcome { /// Whether failures are allowed pub allow_failure: bool, diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index d311007f8134a..5ef7e7581632c 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -35,7 +35,7 @@ fn main() -> Result<()> { cmd.opts.args.silent, cmd.json, ))?; - utils::block_on(cmd.run_script(Default::default())) + utils::block_on(cmd.run_script()) } Subcommands::Coverage(cmd) => utils::block_on(cmd.run()), Subcommands::Bind(cmd) => cmd.run(), @@ -46,7 +46,7 @@ fn main() -> Result<()> { cmd.run().map(|_| ()) } } - Subcommands::Debug(cmd) => utils::block_on(cmd.debug(Default::default())), + Subcommands::Debug(cmd) => utils::block_on(cmd.run()), Subcommands::VerifyContract(args) => utils::block_on(args.run()), Subcommands::VerifyCheck(args) => utils::block_on(args.run()), Subcommands::Cache(cmd) => match cmd.sub { diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 55b2c34e13646..ad2c2846f413d 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,6 +1,6 @@ use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; use ethers::{ - abi::Abi, + abi::{Abi, Function}, prelude::{artifacts::CompactContractBytecode, ArtifactId, ArtifactOutput}, solc::{contracts::ArtifactContracts, Artifact, ProjectCompileOutput}, types::{Address, Bytes, U256}, @@ -19,6 +19,7 @@ use rayon::prelude::*; use revm::primitives::SpecId; use std::{ collections::{BTreeMap, HashSet}, + iter::Iterator, path::Path, sync::{mpsc::Sender, Arc}, }; @@ -51,6 +52,8 @@ pub struct MultiContractRunner { pub cheats_config: Arc, /// Whether to collect coverage info pub coverage: bool, + /// Whether to collect debug info + pub debug: bool, /// Settings related to fuzz and/or invariant tests pub test_options: TestOptions, } @@ -70,19 +73,33 @@ impl MultiContractRunner { .count() } - // Get all tests of matching path and contract - pub fn get_tests(&self, filter: &impl TestFilter) -> Vec { + /// Get an iterator over all test functions that matches the filter path and contract name + fn filtered_tests<'a>( + &'a self, + filter: &'a impl TestFilter, + ) -> impl Iterator { self.contracts .iter() .filter(|(id, _)| { filter.matches_path(id.source.to_string_lossy()) && filter.matches_contract(&id.name) }) - .flat_map(|(_, (abi, _, _))| abi.functions().map(|func| func.name.clone())) - .filter(|sig| sig.is_test()) + .flat_map(|(_, (abi, _, _))| abi.functions()) + } + + /// Get all test names matching the filter + pub fn get_tests(&self, filter: &impl TestFilter) -> Vec { + self.filtered_tests(filter) + .map(|func| func.name.clone()) + .filter(|name| name.is_test()) .collect() } + /// Returns all test functions matching the filter + pub fn get_typed_tests<'a>(&'a self, filter: &'a impl TestFilter) -> Vec<&Function> { + self.filtered_tests(filter).filter(|func| func.name.is_test()).collect() + } + /// Returns all matching tests grouped by contract grouped by file (file -> (contract -> tests)) pub fn list( &self, @@ -143,7 +160,8 @@ impl MultiContractRunner { .inspectors(|stack| { stack .cheatcodes(self.cheats_config.clone()) - .trace(self.evm_opts.verbosity >= 3) + .trace(self.evm_opts.verbosity >= 3 || self.debug) + .debug(self.debug) .coverage(self.coverage) }) .spec(self.evm_spec) @@ -193,13 +211,14 @@ impl MultiContractRunner { self.sender, self.errors.as_ref(), libs, + self.debug, ); runner.run_tests(filter, test_options, Some(&self.known_contracts)) } } /// Builder used for instantiating the multi-contract runner -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct MultiContractRunnerBuilder { /// The address which will be used to deploy the initial contracts and send all /// transactions @@ -214,6 +233,8 @@ pub struct MultiContractRunnerBuilder { pub cheats_config: Option, /// Whether or not to collect coverage info pub coverage: bool, + /// Whether or not to collect debug info + pub debug: bool, /// Settings related to fuzz and/or invariant tests pub test_options: Option, } @@ -326,6 +347,7 @@ impl MultiContractRunnerBuilder { fork: self.fork, cheats_config: self.cheats_config.unwrap_or_default().into(), coverage: self.coverage, + debug: self.debug, test_options: self.test_options.unwrap_or_default(), }) } @@ -371,4 +393,10 @@ impl MultiContractRunnerBuilder { self.coverage = enable; self } + + #[must_use] + pub fn set_debug(mut self, enable: bool) -> Self { + self.debug = enable; + self + } } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index ca717e61b6484..bd80de843c6c0 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -5,6 +5,7 @@ use ethers::prelude::Log; use foundry_common::evm::Breakpoints; use foundry_evm::{ coverage::HitMaps, + debug::DebugArena, executor::EvmError, fuzz::{types::FuzzCase, CounterExample}, trace::{TraceKind, Traces}, @@ -122,6 +123,9 @@ pub struct TestResult { /// Labeled addresses pub labeled_addresses: BTreeMap, + /// The debug nodes of the call + pub debug: Option, + /// pc breakpoint char map pub breakpoints: Breakpoints, } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index b81ce598aca64..1d1bd5e13ded0 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -20,7 +20,8 @@ use foundry_evm::{ replay_run, InvariantContract, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult, }, - FuzzedExecutor, + types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}, + CounterExample, FuzzedExecutor, }, trace::{load_contracts, TraceKind}, CALLER, @@ -46,11 +47,12 @@ pub struct ContractRunner<'a> { pub contract: &'a Abi, /// All known errors, used to decode reverts pub errors: Option<&'a Abi>, - /// The initial balance of the test contract pub initial_balance: U256, /// The address which will be used as the `from` field in all EVM calls pub sender: Address, + /// Should generate debug traces + pub debug: bool, } impl<'a> ContractRunner<'a> { @@ -64,6 +66,7 @@ impl<'a> ContractRunner<'a> { sender: Option
, errors: Option<&'a Abi>, predeploy_libs: &'a [Bytes], + debug: bool, ) -> Self { Self { name, @@ -74,6 +77,7 @@ impl<'a> ContractRunner<'a> { sender: sender.unwrap_or_default(), errors, predeploy_libs, + debug, } } } @@ -232,7 +236,7 @@ impl<'a> ContractRunner<'a> { traces: setup.traces, coverage: None, labeled_addresses: setup.labeled_addresses, - breakpoints: Default::default(), + ..Default::default() }, )] .into(), @@ -307,6 +311,7 @@ impl<'a> ContractRunner<'a> { // Run unit test let mut executor = self.executor.clone(); let start = Instant::now(); + let mut debug_arena = None; let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = match executor.execute_test::<(), _, _>( self.sender, @@ -325,12 +330,14 @@ impl<'a> ContractRunner<'a> { coverage, labels: new_labels, state_changeset, + debug, breakpoints, .. }) => { traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); labeled_addresses.extend(new_labels); logs.extend(execution_logs); + debug_arena = debug; (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) } Err(EvmError::Execution(err)) => { @@ -398,6 +405,7 @@ impl<'a> ContractRunner<'a> { traces, coverage, labeled_addresses, + debug: debug_arena, breakpoints, } } @@ -530,7 +538,7 @@ impl<'a> ContractRunner<'a> { coverage: None, // TODO ? traces, labeled_addresses: labeled_addresses.clone(), - breakpoints: Default::default(), + ..Default::default() // TODO collect debug traces on the last run or error } } @@ -547,8 +555,13 @@ impl<'a> ContractRunner<'a> { // Run fuzz test let start = Instant::now(); - let mut result = FuzzedExecutor::new(&self.executor, runner, self.sender, fuzz_config) - .fuzz(func, address, should_fail, self.errors); + let fuzzed_executor = + FuzzedExecutor::new(&self.executor, runner.clone(), self.sender, fuzz_config); + let state = fuzzed_executor.build_fuzz_state(); + let mut result = fuzzed_executor.fuzz(func, address, should_fail, self.errors); + + let mut debug = Default::default(); + let mut breakpoints = Default::default(); // Check the last test result and skip the test // if it's marked as so. @@ -560,10 +573,50 @@ impl<'a> ContractRunner<'a> { traces, labeled_addresses, kind: TestKind::Standard(0), + debug, + breakpoints, ..Default::default() } } + // if should debug + if self.debug { + let mut debug_executor = self.executor.clone(); + // turn the debug traces on + debug_executor.inspector.enable_debugger(true); + debug_executor.inspector.tracing(true); + let calldata = if let Some(counterexample) = result.counterexample.as_ref() { + match counterexample { + CounterExample::Single(ce) => ce.calldata.clone(), + _ => unimplemented!(), + } + } else { + result.first_case.calldata.clone() + }; + // rerun the last relevant test with traces + let debug_result = FuzzedExecutor::new( + &debug_executor, + runner, + self.sender, + fuzz_config, + ) + .single_fuzz(&state, address, should_fail, calldata); + + (debug, breakpoints) = match debug_result { + Ok(fuzz_outcome) => match fuzz_outcome { + FuzzOutcome::Case(CaseOutcome { debug, breakpoints, .. }) => { + (debug, breakpoints) + } + FuzzOutcome::CounterExample(CounterExampleOutcome { + debug, + breakpoints, + .. + }) => (debug, breakpoints), + }, + Err(_) => (Default::default(), Default::default()), + }; + } + let kind = TestKind::Fuzz { median_gas: result.median_gas(false), mean_gas: result.mean_gas(false), @@ -595,7 +648,8 @@ impl<'a> ContractRunner<'a> { traces, coverage: result.coverage, labeled_addresses, - breakpoints: Default::default(), + debug, + breakpoints, } } } diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 74bce4d2fea8b..0fdc22ded8121 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -17,5 +17,6 @@ ethers.workspace = true crossterm = "0.26" eyre = "0.6" +tracing = "0.1" revm = { workspace = true, features = ["std", "serde"] } -ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"]} \ No newline at end of file +ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"]} diff --git a/crates/ui/src/debugger.rs b/crates/ui/src/debugger.rs new file mode 100644 index 0000000000000..55ddcbd92a29e --- /dev/null +++ b/crates/ui/src/debugger.rs @@ -0,0 +1,47 @@ +use crate::Ui; +use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; +use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder}; +use tracing::trace; + +use crate::{TUIExitReason, Tui}; + +/// Standardized way of firing up the debugger +pub struct DebuggerArgs<'a> { + /// debug traces returned from the execution + pub debug: Vec, + /// trace decoder + pub decoder: &'a CallTraceDecoder, + /// map of source files + pub sources: ContractSources, + /// map of the debugger breakpoints + pub breakpoints: Breakpoints, +} + +impl DebuggerArgs<'_> { + pub fn run(&self) -> eyre::Result { + trace!(target: "debugger", "running debugger"); + + let flattened = self + .debug + .last() + .map(|arena| arena.flatten(0)) + .expect("We should have collected debug information"); + + let identified_contracts = self + .decoder + .contracts + .iter() + .map(|(addr, identifier)| (*addr, get_contract_name(identifier).to_string())) + .collect(); + + let tui = Tui::new( + flattened, + 0, + identified_contracts, + self.sources.clone(), + self.breakpoints.clone(), + )?; + + tui.start() + } +} diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index ca13218fa726f..7b25d2aa0d0b2 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -8,9 +8,9 @@ use crossterm::{ execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; -use ethers::{solc::artifacts::ContractBytecodeSome, types::Address}; +use ethers::types::Address; use eyre::Result; -use foundry_common::evm::Breakpoints; +use foundry_common::{compile::ContractSources, evm::Breakpoints}; use foundry_evm::{ debug::{DebugStep, Instruction}, utils::{build_pc_ic_map, PCICMap}, @@ -50,6 +50,9 @@ pub enum TUIExitReason { mod op_effects; use op_effects::stack_indices_affected; +mod debugger; +pub use debugger::*; + pub struct Tui { debug_arena: Vec<(Address, Vec, CallKind)>, terminal: Terminal>, @@ -58,8 +61,8 @@ pub struct Tui { /// Current step in the debug steps current_step: usize, identified_contracts: HashMap, - known_contracts: HashMap, - known_contracts_sources: HashMap>, + /// Source map of contract sources + contracts_sources: ContractSources, /// A mapping of source -> (PC -> IC map for deploy code, PC -> IC map for runtime code) pc_ic_maps: BTreeMap, breakpoints: Breakpoints, @@ -72,8 +75,7 @@ impl Tui { debug_arena: Vec<(Address, Vec, CallKind)>, current_step: usize, identified_contracts: HashMap, - known_contracts: HashMap, - known_contracts_sources: HashMap>, + contracts_sources: ContractSources, breakpoints: Breakpoints, ) -> Result { enable_raw_mode()?; @@ -82,28 +84,31 @@ impl Tui { let backend = CrosstermBackend::new(stdout); let mut terminal = Terminal::new(backend)?; terminal.hide_cursor(); - let pc_ic_maps = known_contracts + let pc_ic_maps = contracts_sources + .0 .iter() - .filter_map(|(contract_name, bytecode)| { - Some(( - contract_name.clone(), - ( - build_pc_ic_map( - SpecId::LATEST, - bytecode.bytecode.object.as_bytes()?.as_ref(), - ), - build_pc_ic_map( - SpecId::LATEST, - bytecode - .deployed_bytecode - .bytecode - .as_ref()? - .object - .as_bytes()? - .as_ref(), + .flat_map(|(contract_name, files_sources)| { + files_sources.iter().filter_map(|(_, (_, contract))| { + Some(( + contract_name.clone(), + ( + build_pc_ic_map( + SpecId::LATEST, + contract.bytecode.object.as_bytes()?.as_ref(), + ), + build_pc_ic_map( + SpecId::LATEST, + contract + .deployed_bytecode + .bytecode + .as_ref()? + .object + .as_bytes()? + .as_ref(), + ), ), - ), - )) + )) + }) }) .collect(); Ok(Tui { @@ -112,8 +117,7 @@ impl Tui { key_buffer: String::new(), current_step, identified_contracts, - known_contracts, - known_contracts_sources, + contracts_sources, pc_ic_maps, breakpoints, }) @@ -138,9 +142,8 @@ impl Tui { f: &mut Frame, address: Address, identified_contracts: &HashMap, - known_contracts: &HashMap, pc_ic_maps: &BTreeMap, - known_contracts_sources: &HashMap>, + contracts_sources: &ContractSources, debug_steps: &[DebugStep], opcode_list: &[String], current_step: usize, @@ -156,9 +159,8 @@ impl Tui { f, address, identified_contracts, - known_contracts, pc_ic_maps, - known_contracts_sources, + contracts_sources, debug_steps, opcode_list, current_step, @@ -173,9 +175,8 @@ impl Tui { f, address, identified_contracts, - known_contracts, pc_ic_maps, - known_contracts_sources, + contracts_sources, debug_steps, opcode_list, current_step, @@ -193,9 +194,8 @@ impl Tui { f: &mut Frame, address: Address, identified_contracts: &HashMap, - known_contracts: &HashMap, pc_ic_maps: &BTreeMap, - known_contracts_sources: &HashMap>, + contracts_sources: &ContractSources, debug_steps: &[DebugStep], opcode_list: &[String], current_step: usize, @@ -235,9 +235,8 @@ impl Tui { f, address, identified_contracts, - known_contracts, pc_ic_maps, - known_contracts_sources, + contracts_sources, debug_steps[current_step].pc, call_kind, src_pane, @@ -273,9 +272,8 @@ impl Tui { f: &mut Frame, address: Address, identified_contracts: &HashMap, - known_contracts: &HashMap, pc_ic_maps: &BTreeMap, - known_contracts_sources: &HashMap>, + contracts_sources: &ContractSources, debug_steps: &[DebugStep], opcode_list: &[String], current_step: usize, @@ -320,9 +318,8 @@ impl Tui { f, address, identified_contracts, - known_contracts, pc_ic_maps, - known_contracts_sources, + contracts_sources, debug_steps[current_step].pc, call_kind, src_pane, @@ -384,9 +381,8 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k f: &mut Frame, address: Address, identified_contracts: &HashMap, - known_contracts: &HashMap, pc_ic_maps: &BTreeMap, - known_contracts_sources: &HashMap>, + contracts_sources: &ContractSources, pc: usize, call_kind: CallKind, area: Rect, @@ -404,291 +400,283 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let mut text_output: Text = Text::from(""); if let Some(contract_name) = identified_contracts.get(&address) { - if let (Some(known), Some(source_code)) = - (known_contracts.get(contract_name), known_contracts_sources.get(contract_name)) - { + if let Some(files_source_code) = contracts_sources.0.get(contract_name) { let pc_ic_map = pc_ic_maps.get(contract_name); - // grab either the creation source map or runtime sourcemap - if let Some((sourcemap, ic)) = - if matches!(call_kind, CallKind::Create | CallKind::Create2) { - known.bytecode.source_map().zip(pc_ic_map.and_then(|(c, _)| c.get(&pc))) + // find the contract source with the correct source_element's file_id + if let Some((source_element, source_code)) = files_source_code.iter().find_map( + |(file_id, (source_code, contract_source))| { + // grab either the creation source map or runtime sourcemap + if let Some((Ok(source_map), ic)) = + if matches!(call_kind, CallKind::Create | CallKind::Create2) { + contract_source + .bytecode + .source_map() + .zip(pc_ic_map.and_then(|(c, _)| c.get(&pc))) + } else { + contract_source + .deployed_bytecode + .bytecode + .as_ref() + .expect("no bytecode") + .source_map() + .zip(pc_ic_map.and_then(|(_, r)| r.get(&pc))) + } + { + let source_element = source_map[*ic].clone(); + if let Some(index) = source_element.index { + if *file_id == index { + Some((source_element, source_code)) + } else { + None + } + } else { + None + } + } else { + None + } + }, + ) { + // we are handed a vector of SourceElements that give + // us a span of sourcecode that is currently being executed + // This includes an offset and length. This vector is in + // instruction pointer order, meaning the location of + // the instruction - sum(push_bytes[..pc]) + let offset = source_element.offset; + let len = source_element.length; + let max = source_code.len(); + + // split source into before, relevant, and after chunks + // split by line as well to do some formatting stuff + let mut before = source_code[..std::cmp::min(offset, max)] + .split_inclusive('\n') + .collect::>(); + let actual = source_code + [std::cmp::min(offset, max)..std::cmp::min(offset + len, max)] + .split_inclusive('\n') + .map(|s| s.to_string()) + .collect::>(); + let mut after = source_code[std::cmp::min(offset + len, max)..] + .split_inclusive('\n') + .collect::>(); + + let mut line_number = 0; + + let num_lines = before.len() + actual.len() + after.len(); + let height = area.height as usize; + let needed_highlight = actual.len(); + let mid_len = before.len() + actual.len(); + + // adjust what text we show of the source code + let (start_line, end_line) = if needed_highlight > height { + // highlighted section is more lines than we have avail + (before.len(), before.len() + needed_highlight) + } else if height > num_lines { + // we can fit entire source + (0, num_lines) } else { - known - .deployed_bytecode - .bytecode - .as_ref() - .expect("no bytecode") - .source_map() - .zip(pc_ic_map.and_then(|(_, r)| r.get(&pc))) - } - { - match sourcemap { - Ok(sourcemap) => { - // we are handed a vector of SourceElements that give - // us a span of sourcecode that is currently being executed - // This includes an offset and length. This vector is in - // instruction pointer order, meaning the location of - // the instruction - sum(push_bytes[..pc]) - if let Some(source_idx) = sourcemap[*ic].index { - if let Some(source) = source_code.get(&source_idx) { - let offset = sourcemap[*ic].offset; - let len = sourcemap[*ic].length; - let max = source.len(); - - // split source into before, relevant, and after chunks - // split by line as well to do some formatting stuff - let mut before = source[..std::cmp::min(offset, max)] - .split_inclusive('\n') - .collect::>(); - let actual = source[std::cmp::min(offset, max).. - std::cmp::min(offset + len, max)] - .split_inclusive('\n') - .map(|s| s.to_string()) - .collect::>(); - let mut after = source[std::cmp::min(offset + len, max)..] - .split_inclusive('\n') - .collect::>(); - - let mut line_number = 0; - - let num_lines = before.len() + actual.len() + after.len(); - let height = area.height as usize; - let needed_highlight = actual.len(); - let mid_len = before.len() + actual.len(); - - // adjust what text we show of the source code - let (start_line, end_line) = if needed_highlight > height { - // highlighted section is more lines than we have avail - (before.len(), before.len() + needed_highlight) - } else if height > num_lines { - // we can fit entire source - (0, num_lines) - } else { - let remaining = height - needed_highlight; - let mut above = remaining / 2; - let mut below = remaining / 2; - if below > after.len() { - // unused space below the highlight - above += below - after.len(); - } else if above > before.len() { - // we have unused space above the highlight - below += above - before.len(); - } else { - // no unused space - } + let remaining = height - needed_highlight; + let mut above = remaining / 2; + let mut below = remaining / 2; + if below > after.len() { + // unused space below the highlight + above += below - after.len(); + } else if above > before.len() { + // we have unused space above the highlight + below += above - before.len(); + } else { + // no unused space + } - (before.len().saturating_sub(above), mid_len + below) - }; - - let max_line_num = num_lines.to_string().len(); - // We check if there is other text on the same line before the - // highlight starts - if let Some(last) = before.pop() { - if !last.ends_with('\n') { - before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Gray) - .bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default() - .add_modifier(Modifier::DIM), - ), - ])); - line_number += 1; - }); - - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::raw(last), - Span::styled( - actual[0].to_string(), - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - - actual.iter().skip(1).for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - // this is a hack to add coloring - // because tui does weird trimming - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); + (before.len().saturating_sub(above), mid_len + below) + }; + + let max_line_num = num_lines.to_string().len(); + // We check if there is other text on the same line before the + // highlight starts + if let Some(last) = before.pop() { + if !last.ends_with('\n') { + before.iter().skip(start_line).for_each(|line| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default().fg(Color::Gray).bg(Color::DarkGray), + ), + Span::styled( + "\u{2800} ".to_string() + line, + Style::default().add_modifier(Modifier::DIM), + ), + ])); + line_number += 1; + }); + + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::raw(last), + Span::styled( + actual[0].to_string(), + Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + + actual.iter().skip(1).for_each(|s| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::styled( + // this is a hack to add coloring + // because tui does weird trimming + if s.is_empty() || s == "\n" { + "\u{2800} \n".to_string() } else { - before.push(last); - before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Gray) - .bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default() - .add_modifier(Modifier::DIM), - ), - ])); - - line_number += 1; - }); - actual.iter().for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } + s.to_string() + }, + Style::default() + .fg(Color::Cyan) + .add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + }); + } else { + before.push(last); + before.iter().skip(start_line).for_each(|line| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default().fg(Color::Gray).bg(Color::DarkGray), + ), + Span::styled( + "\u{2800} ".to_string() + line, + Style::default().add_modifier(Modifier::DIM), + ), + ])); + + line_number += 1; + }); + actual.iter().for_each(|s| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::styled( + if s.is_empty() || s == "\n" { + "\u{2800} \n".to_string() + } else { + s.to_string() + }, + Style::default() + .fg(Color::Cyan) + .add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + }); + } + } else { + actual.iter().for_each(|s| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::styled( + if s.is_empty() || s == "\n" { + "\u{2800} \n".to_string() } else { - actual.iter().for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } - - // fill in the rest of the line as unhighlighted - if let Some(last) = actual.last() { - if !last.ends_with('\n') { - if let Some(post) = after.pop_front() { - if let Some(last) = text_output.lines.last_mut() { - last.spans.push(Span::raw(post)); - } - } - } - } + s.to_string() + }, + Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + }); + } - // add after highlighted text - while mid_len + after.len() > end_line { - after.pop_back(); - } - after.iter().for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Gray) - .bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default().add_modifier(Modifier::DIM), - ), - ])); - line_number += 1; - }); - } else { - text_output.extend(Text::from("No source for srcmap index")); + // fill in the rest of the line as unhighlighted + if let Some(last) = actual.last() { + if !last.ends_with('\n') { + if let Some(post) = after.pop_front() { + if let Some(last) = text_output.lines.last_mut() { + last.spans.push(Span::raw(post)); } - } else { - text_output.extend(Text::from("No srcmap index")); } } - Err(e) => text_output.extend(Text::from(format!( - "Error in source map parsing: '{e}', please open an issue" - ))), } + + // add after highlighted text + while mid_len + after.len() > end_line { + after.pop_back(); + } + after.iter().for_each(|line| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default().fg(Color::Gray).bg(Color::DarkGray), + ), + Span::styled( + "\u{2800} ".to_string() + line, + Style::default().add_modifier(Modifier::DIM), + ), + ])); + line_number += 1; + }); } else { text_output.extend(Text::from("No sourcemap for contract")); } } else { - text_output.extend(Text::from(format!("Unknown contract at address {address:?}"))); + text_output.extend(Text::from("No srcmap index for contract {contract_name}")); } } else { text_output.extend(Text::from(format!("Unknown contract at address {address:?}"))); @@ -1290,9 +1278,8 @@ impl Ui for Tui { f, debug_call[draw_memory.inner_call_index].0, &self.identified_contracts, - &self.known_contracts, &self.pc_ic_maps, - &self.known_contracts_sources, + &self.contracts_sources, &debug_call[draw_memory.inner_call_index].1[..], &opcode_list, current_step, From 09489b0530a40464e89c3c8de0bb666359a85e72 Mon Sep 17 00:00:00 2001 From: Matt Solomon Date: Mon, 11 Sep 2023 08:00:12 -0700 Subject: [PATCH 0070/1963] chore: better create2 warning (#5814) --- crates/evm/src/executor/backend/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/src/executor/backend/error.rs b/crates/evm/src/executor/backend/error.rs index eb3a595b10c2d..d40dc06fb6481 100644 --- a/crates/evm/src/executor/backend/error.rs +++ b/crates/evm/src/executor/backend/error.rs @@ -38,7 +38,7 @@ pub enum DatabaseError { #[error("Transaction {0:?} not found")] TransactionNotFound(H256), #[error( - "CREATE2 Deployer not present on this chain. [0x4e59b44847b379578588920ca78fbf26c0b4956c]" + "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n\nFor a production environment, you can deploy it using the pre-signed transaction from https://github.com/Arachnid/deterministic-deployment-proxy.\n\nFor a test environment, you can use vm.etch to place the required bytecode at that address." )] MissingCreate2Deployer, #[error(transparent)] From 0a512883aab8883aa6415615cd460eab5a83a74b Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 11 Sep 2023 11:17:57 -0400 Subject: [PATCH 0071/1963] feat(cargo): add fast debug profile for perf (#5815) --- Cargo.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 97cc3a9ddceb5..9eeb19e8dee71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ scrypt.opt-level = 3 # forking axum.opt-level = 3 +# Optimized release profile [profile.release] opt-level = "s" lto = "fat" @@ -49,6 +50,14 @@ strip = true panic = "abort" codegen-units = 1 +# Like release, but with full debug symbols and with stack unwinds. Useful for e.g. `perf`. +[profile.debug-fast] +inherits = "release" +debug = "full" +strip = "none" +panic = "unwind" +incremental = false + [profile.release.package] # Optimize all non-workspace packages for speed "*".opt-level = 3 From 893fc9f79810cd1a7fb8b612c708f1ad2f78f749 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 11 Sep 2023 20:10:27 -0400 Subject: [PATCH 0072/1963] chore: rename ui to foundry-debugger (#5816) --- Cargo.lock | 32 +- Cargo.toml | 2 +- crates/abi/src/bindings/hardhat_console.rs | 1905 ++++++++++++-------- crates/abi/src/bindings/hevm.rs | 1101 ++++++----- crates/cli/Cargo.toml | 2 +- crates/cli/src/utils/cmd.rs | 2 +- crates/{ui => debugger}/Cargo.toml | 2 +- crates/{ui => debugger}/src/debugger.rs | 0 crates/{ui => debugger}/src/lib.rs | 0 crates/{ui => debugger}/src/op_effects.rs | 0 crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/script/cmd.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- 13 files changed, 1799 insertions(+), 1253 deletions(-) rename crates/{ui => debugger}/Cargo.toml (94%) rename crates/{ui => debugger}/src/debugger.rs (100%) rename crates/{ui => debugger}/src/lib.rs (100%) rename crates/{ui => debugger}/src/op_effects.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index c0fe3f39c3da9..a3b5d40dc9a90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2151,6 +2151,7 @@ dependencies = [ "foundry-cli", "foundry-common", "foundry-config", + "foundry-debugger", "foundry-evm", "foundry-test-utils", "foundry-utils", @@ -2178,7 +2179,6 @@ dependencies = [ "tikv-jemallocator", "tokio", "tracing", - "ui", "vergen", "watchexec", "yansi 0.5.1", @@ -2277,6 +2277,7 @@ dependencies = [ "eyre", "foundry-common", "foundry-config", + "foundry-debugger", "foundry-evm", "indicatif", "itertools 0.11.0", @@ -2294,7 +2295,6 @@ dependencies = [ "tracing", "tracing-error", "tracing-subscriber", - "ui", "yansi 0.5.1", ] @@ -2364,6 +2364,20 @@ dependencies = [ "walkdir", ] +[[package]] +name = "foundry-debugger" +version = "0.2.0" +dependencies = [ + "crossterm", + "ethers", + "eyre", + "foundry-common", + "foundry-evm", + "ratatui", + "revm", + "tracing", +] + [[package]] name = "foundry-evm" version = "0.2.0" @@ -6833,20 +6847,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" -[[package]] -name = "ui" -version = "0.2.0" -dependencies = [ - "crossterm", - "ethers", - "eyre", - "foundry-common", - "foundry-evm", - "ratatui", - "revm", - "tracing", -] - [[package]] name = "uint" version = "0.9.5" diff --git a/Cargo.toml b/Cargo.toml index 9eeb19e8dee71..9069bc4f123cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,7 +132,7 @@ foundry-evm = { path = "crates/evm" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } foundry-utils = { path = "crates/utils" } -ui = { path = "crates/ui" } +foundry-debugger = { path = "crates/debugger" } ## revm revm = { version = "3", default-features = false } diff --git a/crates/abi/src/bindings/hardhat_console.rs b/crates/abi/src/bindings/hardhat_console.rs index 01cefc866dec9..72875ab4bc4d7 100644 --- a/crates/abi/src/bindings/hardhat_console.rs +++ b/crates/abi/src/bindings/hardhat_console.rs @@ -24173,1528 +24173,1909 @@ pub mod hardhat_console { data: impl AsRef<[u8]>, ) -> ::core::result::Result { let data = data.as_ref(); - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log23(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log87(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log24(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log88(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log89(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log90(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log91(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log25(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log92(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log93(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log94(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log95(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log96(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log26(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log97(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log98(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log99(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log100(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log101(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log102(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log27(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log28(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log103(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log29(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log104(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log105(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log106(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log107(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log108(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log109(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log110(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log111(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log30(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log31(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log112(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log113(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log114(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log115(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log116(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log32(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log6(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log117(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log118(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log119(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log120(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log33(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log121(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log34(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log122(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log35(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log123(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log124(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log125(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log126(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log127(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log128(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log129(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log36(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log130(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log131(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log132(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log7(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log133(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log134(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log135(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log136(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log137(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log37(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log138(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log139(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log8(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log140(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log141(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log38(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log142(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log143(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log39(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log144(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log40(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log145(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log146(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log9(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log147(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log148(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log149(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log150(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log151(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log152(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log153(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log154(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log155(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log156(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log157(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log158(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log159(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log160(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log161(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log41(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log162(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log163(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log164(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log165(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log10(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log166(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log42(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log167(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log43(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log168(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log169(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log170(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log171(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log172(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log173(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log44(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log45(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log174(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log175(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log46(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log176(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log177(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log178(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log47(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log179(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log180(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log181(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log182(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log183(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log184(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log185(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log186(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log187(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log188(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log48(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log189(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log190(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log191(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log49(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log192(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log11(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log193(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log194(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log195(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log196(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log50(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log51(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log197(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log198(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log12(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log199(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log200(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log201(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log202(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log203(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log204(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log205(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log206(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log207(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log208(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log209(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log210(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log52(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log211(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log212(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log213(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log13(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log14(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log214(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log215(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log216(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log53(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log54(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log217(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log218(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log219(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log220(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log221(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log222(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log223(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log224(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log225(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log226(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log227(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log15(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log55(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log16(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log228(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log56(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log229(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log230(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log231(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log232(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log233(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log234(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log235(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log236(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log237(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log238(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log239(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log240(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log241(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log17(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log242(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log243(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log244(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log245(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log246(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log57(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log247(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log248(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log249(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log58(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log59(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log250(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log251(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log252(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log253(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log60(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log254(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log61(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log255(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log256(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log257(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log258(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log259(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log260(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log261(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log262(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log62(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log263(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log264(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log265(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log266(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log267(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log268(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log269(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log270(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log271(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log272(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log273(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log274(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log275(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log276(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log277(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log63(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log64(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log65(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log278(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log279(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log280(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log18(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log66(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log281(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log282(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log283(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log284(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log285(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log67(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log286(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log287(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log288(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log289(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log290(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log291(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log292(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log19(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log68(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log293(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log294(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log295(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log296(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log297(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log69(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log70(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log71(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log72(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log298(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log299(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log300(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log301(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log302(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log73(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log303(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log304(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log74(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log75(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log305(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log306(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log307(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log308(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log309(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log20(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log76(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log310(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log311(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log312(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log313(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log314(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log77(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log315(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log316(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log317(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log78(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log318(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log79(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log319(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log320(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log321(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log322(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log323(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log324(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log80(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log325(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log326(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log81(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log327(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log328(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log329(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log330(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log331(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log82(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log83(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log84(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log332(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log333(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log334(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log21(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log335(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log336(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log4(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log337(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log338(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log339(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log85(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log340(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log86(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log341(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log342(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log5(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Log22(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogAddress(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBool(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes10(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes11(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes12(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes13(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes14(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes15(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes16(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes17(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes18(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes19(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes20(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes21(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes22(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes23(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes24(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes25(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes26(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes27(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes28(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes29(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes30(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes31(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes32(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes4(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes5(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes6(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes7(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes8(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogBytes9(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogInt(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogString(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::LogUint(decoded)); } Err(::ethers_core::abi::Error::InvalidData.into()) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index af713b60b45f1..1955336ec209e 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -10742,894 +10742,1059 @@ pub mod hevm { data: impl AsRef<[u8]>, ) -> ::core::result::Result { let data = data.as_ref(); - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Accesses(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ActiveFork(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Addr(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::AllowCheatcodes(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Assume(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Breakpoint0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Breakpoint1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Broadcast0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Broadcast1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Broadcast2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ChainId(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ClearMockedCalls(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CloseFile(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Coinbase(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CopyFile(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateDir(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateFork1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateFork2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateFork0(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateSelectFork1(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateSelectFork2(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateSelectFork0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateWallet0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateWallet1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::CreateWallet2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Deal(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::DeriveKey0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::DeriveKey1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::DeriveKey2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::DeriveKey3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Difficulty(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvAddress0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvAddress1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvBool0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvBool1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvBytes0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvBytes1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvBytes320(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvBytes321(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvInt0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvInt1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr4(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr5(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr6(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr7(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr8(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr9(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr10(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr11(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr12(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvOr13(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvString0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvString1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvUint0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EnvUint1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Etch(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::EthGetLogs(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Exists(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCall0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCall1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCall2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCall3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCall4(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCall5(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCallMinGas0(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectCallMinGas1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectEmit0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectEmit1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectEmit2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectEmit3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectRevert0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectRevert1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectRevert2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectSafeMemory(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ExpectSafeMemoryCall(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Fee(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Ffi(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::FsMetadata(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetCode(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetDeployedCode(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetLabel(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetMappingKeyAndParentOf(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetMappingLength(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetMappingSlotAt(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetNonce0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetNonce1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::GetRecordedLogs(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::IsDir(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::IsFile(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::IsPersistent(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::KeyExists(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Label(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Load(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MakePersistent0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MakePersistent2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MakePersistent3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MakePersistent1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MockCall0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MockCall1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MockCallRevert0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::MockCallRevert1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::OpenFile(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseAddress(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseBool(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseBytes(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseBytes32(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseInt(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJson0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJson1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonAddress(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonAddressArray(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonBool(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonBoolArray(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonBytes(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonBytes32(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonBytes32Array(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonBytesArray(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonInt(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonIntArray(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonKeys(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonString(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonStringArray(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonUint(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseJsonUintArray(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ParseUint(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::PauseGasMetering(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Prank0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Prank1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Prevrandao(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ProjectRoot(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadCallers(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadDir0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadDir1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadDir2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadFile(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadFileBinary(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadLine(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ReadLink(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Record(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RecordLogs(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RememberKey(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RemoveDir(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RemoveFile(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ResetNonce(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ResumeGasMetering(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RevertTo(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RevokePersistent0(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RevokePersistent1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Roll(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RollFork0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RollFork1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RollFork2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RollFork3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Rpc(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RpcUrl(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RpcUrlStructs(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::RpcUrls(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SelectFork(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeAddress0(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeAddress1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeBool0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeBool1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeBytes0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeBytes1(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeBytes320(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeBytes321(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeInt0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeInt1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeJson(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeString0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeString1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeUint0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SerializeUint1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SetEnv(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SetNonce(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::SetNonceUnsafe(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Sign0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Sign1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Skip(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Sleep(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Snapshot(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StartBroadcast0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StartBroadcast1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StartBroadcast2(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StartMappingRecording(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StartPrank0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StartPrank1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StopBroadcast(decoded)); } - if let Ok(decoded) - = ::decode( - data, - ) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StopMappingRecording(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::StopPrank(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Store(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ToString0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ToString1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ToString2(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ToString3(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ToString4(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::ToString5(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Transact0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Transact1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::TryFfi(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::TxGasPrice(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::Warp(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::WriteFile(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::WriteFileBinary(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::WriteJson0(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::WriteJson1(decoded)); } - if let Ok(decoded) - = ::decode(data) { + if let Ok(decoded) = ::decode( + data, + ) { return Ok(Self::WriteLine(decoded)); } Err(::ethers_core::abi::Error::InvalidData.into()) diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 07734dd122ac6..67e9b6a21f9af 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -14,7 +14,7 @@ repository.workspace = true foundry-config.workspace = true foundry-common.workspace = true foundry-evm.workspace = true -ui.workspace = true +foundry-debugger.workspace = true # aws rusoto_core = { version = "0.48", default-features = false } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 8e58fe8d9bc85..3ede6b0d85ecf 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -12,6 +12,7 @@ use ethers::{ use eyre::{Result, WrapErr}; use foundry_common::{cli_warn, fs, TestFunctionExt}; use foundry_config::{error::ExtractConfigError, figment::Figment, Chain as ConfigChain, Config}; +use foundry_debugger::DebuggerArgs; use foundry_evm::{ debug::DebugArena, executor::{opts::EvmOpts, DeployResult, EvmError, ExecutionErr, RawCallResult}, @@ -22,7 +23,6 @@ use foundry_evm::{ }; use std::{fmt::Write, path::PathBuf, str::FromStr}; use tracing::trace; -use ui::DebuggerArgs; use yansi::Paint; /// Given a `Project`'s output, removes the matching ABI, Bytecode and diff --git a/crates/ui/Cargo.toml b/crates/debugger/Cargo.toml similarity index 94% rename from crates/ui/Cargo.toml rename to crates/debugger/Cargo.toml index 0fdc22ded8121..f2875467a4e5c 100644 --- a/crates/ui/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ui" +name = "foundry-debugger" version.workspace = true edition.workspace = true diff --git a/crates/ui/src/debugger.rs b/crates/debugger/src/debugger.rs similarity index 100% rename from crates/ui/src/debugger.rs rename to crates/debugger/src/debugger.rs diff --git a/crates/ui/src/lib.rs b/crates/debugger/src/lib.rs similarity index 100% rename from crates/ui/src/lib.rs rename to crates/debugger/src/lib.rs diff --git a/crates/ui/src/op_effects.rs b/crates/debugger/src/op_effects.rs similarity index 100% rename from crates/ui/src/op_effects.rs rename to crates/debugger/src/op_effects.rs diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 958754b00472e..e52b800c837ed 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -37,7 +37,7 @@ yansi = "0.5" forge-fmt.workspace = true forge-doc.workspace = true foundry-cli.workspace = true -ui.workspace = true +foundry-debugger.workspace = true async-trait = "0.1" bytes = "1.4" diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 8185e6e9e7e9d..93aab18eac3dd 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -6,9 +6,9 @@ use ethers::{ use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; +use foundry_debugger::DebuggerArgs; use std::sync::Arc; use tracing::trace; -use ui::DebuggerArgs; /// Helper alias type for the collection of data changed due to the new sender. type NewSenderChanges = (CallTraceDecoder, Libraries, ArtifactContracts); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index b04f799e1550d..9b44267a432e9 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -31,11 +31,11 @@ use foundry_config::{ }, get_available_profiles, Config, }; +use foundry_debugger::DebuggerArgs; use foundry_evm::fuzz::CounterExample; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use tracing::trace; -use ui::DebuggerArgs; use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; From d135838b4e9d0a345e406b5f1805eaafa5f64223 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 11 Sep 2023 20:54:30 -0400 Subject: [PATCH 0073/1963] fix(forge): properly clean git dir on path when installing thru template (#5817) --- crates/forge/bin/cmd/init.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index a1b2f2c78c210..5dcd596491ea5 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -71,7 +71,7 @@ impl InitArgs { } // Modify the git history. let commit_hash = git.commit_hash(true)?; - std::fs::remove_dir_all(".git")?; + std::fs::remove_dir_all(root.join(".git"))?; git.init()?; git.add(Some("--all"))?; From 2885b0db02e620d3a2ce7a7e52650932005fa8ac Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Tue, 12 Sep 2023 16:57:46 +0200 Subject: [PATCH 0074/1963] feat(cast): subscribe to logs using websockets (#5743) * feat(cast): subscribe to logs * undo generic signal * fix tokio signal feature --------- Co-authored-by: Enrique Ortiz --- crates/cast/Cargo.toml | 2 +- crates/cast/bin/cmd/logs.rs | 81 ++++++++++---------- crates/cast/src/lib.rs | 146 +++++++++++++++++++++++++++++++++++- 3 files changed, 186 insertions(+), 43 deletions(-) diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index e752e113bc883..a59dac5e096c3 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -60,7 +60,7 @@ regex = { version = "1", default-features = false } rpassword = "7" semver = "1" tempfile = "3" -tokio = { version = "1", features = ["macros"] } +tokio = { version = "1", features = ["macros", "signal"] } tracing = "0.1" yansi = "0.5" diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 433f90969469e..3bfc2608d742c 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -1,16 +1,17 @@ +use std::{io, str::FromStr}; + use cast::Cast; use clap::Parser; -use ethers::{ +use ethers::{providers::Middleware, types::NameOrAddress}; +use ethers_core::{ abi::{Address, Event, RawTopicFilter, Topic, TopicFilter}, - providers::Middleware, - types::{BlockId, BlockNumber, Filter, FilterBlockOption, NameOrAddress, ValueOrArray, H256}, + types::{BlockId, BlockNumber, Filter, FilterBlockOption, ValueOrArray, H256}, }; use eyre::Result; use foundry_cli::{opts::EthereumOpts, utils}; use foundry_common::abi::{get_event, parse_tokens}; use foundry_config::Config; use itertools::Itertools; -use std::str::FromStr; /// CLI arguments for `cast logs`. #[derive(Debug, Parser)] @@ -44,7 +45,12 @@ pub struct LogsArgs { #[clap(value_name = "TOPICS_OR_ARGS")] topics_or_args: Vec, - /// Print the logs as JSON. + /// If the RPC type and endpoints supports `eth_subscribe` stream logs instead of printing and + /// exiting. Will continue until interrupted or TO_BLOCK is reached. + #[clap(long)] + subscribe: bool, + + /// Print the logs as JSON.s #[clap(long, short, help_heading = "Display options")] json: bool, @@ -55,12 +61,21 @@ pub struct LogsArgs { impl LogsArgs { pub async fn run(self) -> Result<()> { let LogsArgs { - from_block, to_block, address, topics_or_args, sig_or_topic, json, eth, .. + from_block, + to_block, + address, + sig_or_topic, + topics_or_args, + subscribe, + json, + eth, } = self; let config = Config::from(ð); let provider = utils::get_provider(&config)?; + let cast = Cast::new(&provider); + let address = match address { Some(address) => { let address = match address { @@ -72,48 +87,29 @@ impl LogsArgs { None => None, }; - let from_block = convert_block_number(&provider, from_block).await?; - let to_block = convert_block_number(&provider, to_block).await?; - - let cast = Cast::new(&provider); + let from_block = cast.convert_block_number(from_block).await?; + let to_block = cast.convert_block_number(to_block).await?; let filter = build_filter(from_block, to_block, address, sig_or_topic, topics_or_args)?; - let logs = cast.filter_logs(filter, json).await?; + if !subscribe { + let logs = cast.filter_logs(filter, json).await?; - println!("{}", logs); + println!("{}", logs); - Ok(()) - } -} + return Ok(()) + } -/// Converts a block identifier into a block number. -/// -/// If the block identifier is a block number, then this function returns the block number. If the -/// block identifier is a block hash, then this function returns the block number of that block -/// hash. If the block identifier is `None`, then this function returns `None`. -async fn convert_block_number( - provider: M, - block: Option, -) -> Result, eyre::Error> -where - M::Error: 'static, -{ - match block { - Some(block) => match block { - BlockId::Number(block_number) => Ok(Some(block_number)), - BlockId::Hash(hash) => { - let block = provider.get_block(hash).await?; - Ok(block.map(|block| block.number.unwrap()).map(BlockNumber::from)) - } - }, - None => Ok(None), + let mut stdout = io::stdout(); + cast.subscribe(filter, &mut stdout, json).await?; + + Ok(()) } } -// First tries to parse the `sig_or_topic` as an event signature. If successful, `topics_or_args` is -// parsed as indexed inputs and converted to topics. Otherwise, `sig_or_topic` is prepended to -// `topics_or_args` and used as raw topics. +/// Builds a Filter by first trying to parse the `sig_or_topic` as an event signature. If +/// successful, `topics_or_args` is parsed as indexed inputs and converted to topics. Otherwise, +/// `sig_or_topic` is prepended to `topics_or_args` and used as raw topics. fn build_filter( from_block: Option, to_block: Option, @@ -154,7 +150,7 @@ fn build_filter( Ok(filter) } -// Creates a TopicFilter for the given event signature and arguments. +/// Creates a TopicFilter from the given event signature and arguments. fn build_filter_event_sig(event: Event, args: Vec) -> Result { let args = args.iter().map(|arg| arg.as_str()).collect::>(); @@ -195,7 +191,7 @@ fn build_filter_event_sig(event: Event, args: Vec) -> Result) -> Result { let mut topics = topics .into_iter() @@ -214,8 +210,11 @@ fn build_filter_topics(topics: Vec) -> Result #[cfg(test)] mod tests { + use std::str::FromStr; + use super::*; use ethers::types::H160; + use ethers_core::types::H256; const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"; const TRANSFER_SIG: &str = "Transfer(address indexed,address indexed,uint256)"; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index d51d9e20bda9e..ed7d5b26dabca 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -13,11 +13,12 @@ use ethers_core::{ }, }; use ethers_etherscan::{errors::EtherscanError, Client}; -use ethers_providers::{Middleware, PendingTransaction}; +use ethers_providers::{Middleware, PendingTransaction, PubsubClient}; use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; use eyre::{Context, Result}; use foundry_common::{abi::encode_args, fmt::*, TransactionReceiptWithRevertReason}; pub use foundry_evm::*; +use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; pub use rusoto_core::{ credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, @@ -25,10 +26,12 @@ pub use rusoto_core::{ }; pub use rusoto_kms::KmsClient; use std::{ + io, path::PathBuf, str::FromStr, sync::atomic::{AtomicBool, Ordering}, }; +use tokio::signal::ctrl_c; pub use tx::TxBuilder; use tx::{TxBuilderOutput, TxBuilderPeekOutput}; @@ -816,6 +819,147 @@ where }; Ok(res) } + + /// Converts a block identifier into a block number. + /// + /// If the block identifier is a block number, then this function returns the block number. If + /// the block identifier is a block hash, then this function returns the block number of + /// that block hash. If the block identifier is `None`, then this function returns `None`. + /// + /// # Example + /// + /// ```no_run + /// use cast::Cast; + /// use ethers_providers::{Provider, Http}; + /// use ethers_core::types::{BlockId, BlockNumber}; + /// use std::convert::TryFrom; + /// + /// # async fn foo() -> eyre::Result<()> { + /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let cast = Cast::new(provider); + /// + /// let block_number = cast.convert_block_number(Some(BlockId::Number(BlockNumber::from(5)))).await?; + /// assert_eq!(block_number, Some(BlockNumber::from(5))); + /// + /// let block_number = cast.convert_block_number(Some(BlockId::Hash("0x1234".parse().unwrap()))).await?; + /// assert_eq!(block_number, Some(BlockNumber::from(1234))); + /// + /// let block_number = cast.convert_block_number(None).await?; + /// assert_eq!(block_number, None); + /// # Ok(()) + /// # } + /// ``` + pub async fn convert_block_number( + &self, + block: Option, + ) -> Result, eyre::Error> { + match block { + Some(block) => match block { + BlockId::Number(block_number) => Ok(Some(block_number)), + BlockId::Hash(hash) => { + let block = self.provider.get_block(hash).await?; + Ok(block.map(|block| block.number.unwrap()).map(BlockNumber::from)) + } + }, + None => Ok(None), + } + } + + /// Sets up a subscription to the given filter and writes the logs to the given output. + /// + /// # Example + /// + /// ```no_run + /// use cast::Cast; + /// use ethers_core::abi::Address; + /// use ethers_providers::{Provider, Ws}; + /// use ethers_core::types::Filter; + /// use std::{str::FromStr, convert::TryFrom}; + /// use std::io; + /// + /// # async fn foo() -> eyre::Result<()> { + /// let provider = Provider::new(Ws::connect("wss://localhost:8545").await?); + /// let cast = Cast::new(provider); + /// + /// let filter = Filter::new().address(Address::from_str("0x00000000006c3852cbEf3e08E8dF289169EdE581")?); + /// let mut output = io::stdout(); + /// cast.subscribe(filter, &mut output, false).await?; + /// # Ok(()) + /// # } + /// ``` + pub async fn subscribe( + &self, + filter: Filter, + output: &mut dyn io::Write, + to_json: bool, + ) -> Result<()> + where + ::Provider: PubsubClient, + { + // Initialize the subscription stream for logs + let mut subscription = self.provider.subscribe_logs(&filter).await?; + + // Check if a to_block is specified, if so, subscribe to blocks + let mut block_subscription = if filter.get_to_block().is_some() { + Some(self.provider.subscribe_blocks().await?) + } else { + None + }; + + let to_block_number = filter.get_to_block(); + + // If output should be JSON, start with an opening bracket + if to_json { + write!(output, "[")?; + } + + let mut first = true; + + loop { + tokio::select! { + // If block subscription is present, listen to it to avoid blocking indefinitely past the desired to_block + block = if let Some(bs) = &mut block_subscription { + Either::Left(bs.next().fuse()) + } else { + Either::Right(futures::future::pending()) + } => { + if let (Some(block), Some(to_block)) = (block, to_block_number) { + if block.number.map_or(false, |bn| bn > to_block) { + break; + } + } + }, + // Process incoming log + log = subscription.next() => { + if to_json { + if !first { + write!(output, ",")?; + } + first = false; + let log_str = serde_json::to_string(&log).unwrap(); + write!(output, "{}", log_str)?; + } else { + let log_str = log.pretty() + .replacen('\n', "- ", 1) // Remove empty first line + .replace('\n', "\n "); // Indent + writeln!(output, "{}", log_str)?; + } + }, + // Break on cancel signal, to allow for closing JSON bracket + _ = ctrl_c() => { + break; + }, + else => break, + } + } + + // If output was JSON, end with a closing bracket + if to_json { + write!(output, "]")?; + } + + Ok(()) + } } pub struct InterfaceSource { From 97087ffb537a2c7da9d227d9a8ca66e81f59c3cf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 13 Sep 2023 14:14:02 +0200 Subject: [PATCH 0075/1963] chore: log full address (#5827) --- crates/cast/bin/cmd/wallet/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 1fdaa923e25ea..ee6923a97420c 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -232,7 +232,7 @@ flag to set your key via: )?; let address = wallet.address(); let success_message = format!( - "`{}` keystore was saved successfully. Address: {}", + "`{}` keystore was saved successfully. Address: {:?}", &account_name, address, ); println!("{}", Paint::green(success_message)); From 74c03182d41c75c40e5a1c398aca9400305ff678 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 13 Sep 2023 10:23:40 -0400 Subject: [PATCH 0076/1963] chore(deps): bump revm (#5828) --- Cargo.lock | 8 ++++---- Cargo.toml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3b5d40dc9a90..c59308fcae617 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5159,7 +5159,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" +source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" dependencies = [ "auto_impl", "rayon", @@ -5172,7 +5172,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" +source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" dependencies = [ "derive_more", "enumn", @@ -5184,7 +5184,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" +source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" dependencies = [ "k256", "num", @@ -5199,7 +5199,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=7eacc3a728b8a9cf3c15db609753e5d9f69e08ce#7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" +source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" dependencies = [ "auto_impl", "bitflags 2.4.0", diff --git a/Cargo.toml b/Cargo.toml index 9069bc4f123cf..04dc284000d39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,7 +168,7 @@ tikv-jemallocator = "0.5.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } -revm-interpreter = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } -revm-precompile = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } -revm-primitives = { git = "https://github.com/bluealloy/revm/", rev = "7eacc3a728b8a9cf3c15db609753e5d9f69e08ce" } +revm = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } +revm-interpreter = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } +revm-precompile = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } +revm-primitives = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } From d78309da5868b3d3dbf9bf6d0fddb0c615d04b04 Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Thu, 14 Sep 2023 13:54:37 +0200 Subject: [PATCH 0077/1963] fix(common): ipc provider windows (#5831) * fix(common): ipc provider windows * temp: run windows action * Revert "temp: run windows action" This reverts commit a4f39a09f9d752119ecc318ecc38521a22e16cc6. --- crates/common/src/provider.rs | 67 ++++++++++++++++++----------- crates/common/src/runtime_client.rs | 26 +++++++++-- 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index 0af44f320ef16..7695260d9b4e6 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -6,7 +6,12 @@ use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use ethers_providers::{is_local_endpoint, Middleware, Provider, DEFAULT_LOCAL_POLL_INTERVAL}; use eyre::WrapErr; use reqwest::{IntoUrl, Url}; -use std::{borrow::Cow, env, path::Path, time::Duration}; +use std::{ + borrow::Cow, + env, + path::{Path, PathBuf}, + time::Duration, +}; use url::ParseError; /// Helper type alias for a retry provider @@ -68,31 +73,23 @@ impl ProviderBuilder { } let url = Url::parse(url_str) - .or_else(|err| { - match err { - ParseError::RelativeUrlWithoutBase => { - let path = Path::new(url_str); - let absolute_path = if path.is_absolute() { - path.to_path_buf() - } else { - // Assume the path is relative to the current directory. - // Don't use `std::fs::canonicalize` as it requires the path to exist. - // It should be possible to construct a provider and only - // attempt to establish a connection later - let current_dir = - env::current_dir().expect("Current directory should exist"); - current_dir.join(path) - }; - - let path_str = - absolute_path.to_str().expect("Path should be a valid string"); - - // invalid url: non-prefixed URL scheme is not allowed, so we assume the URL - // is for a local file - Url::parse(format!("file://{path_str}").as_str()) + .or_else(|err| match err { + ParseError::RelativeUrlWithoutBase => { + let path = Path::new(url_str); + + if let Ok(path) = resolve_path(path) { + Url::parse( + format!( + "file://{path_str}", + path_str = path.to_str().expect("Should be valid string") + ) + .as_str(), + ) + } else { + Err(err) } - _ => Err(err), } + _ => Err(err), }) .wrap_err(format!("Invalid provider url: {url_str}")); @@ -280,6 +277,28 @@ where provider.estimate_eip1559_fees(None).await.wrap_err("Failed fetch EIP1559 fees") } +#[cfg(not(windows))] +fn resolve_path(path: &Path) -> Result { + if path.is_absolute() { + Ok(path.to_path_buf()) + } else { + Ok(env::current_dir() + .map(|current_dir| current_dir.join(path)) + .expect("Current directory should exist")) + } +} + +#[cfg(windows)] +fn resolve_path(path: &Path) -> Result { + let path_str = path.to_str().expect("Path should be a valid string"); + + if path_str.starts_with(r"\\.\pipe\") { + Ok(PathBuf::from(path_str)) + } else { + Err(()) + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index cd89736aab6b2..d09f17d638c2c 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -9,7 +9,7 @@ use ethers_providers::{ }; use reqwest::{header::HeaderValue, Url}; use serde::{de::DeserializeOwned, Serialize}; -use std::{fmt::Debug, sync::Arc, time::Duration}; +use std::{fmt::Debug, path::PathBuf, sync::Arc, time::Duration}; use thiserror::Error; use tokio::sync::RwLock; @@ -176,9 +176,7 @@ impl RuntimeClient { Ok(InnerClient::Ws(client)) } "file" => { - let path = self - .url - .to_file_path() + let path = url_to_file_path(&self.url) .map_err(|_| RuntimeClientError::BadPath(self.url.to_string()))?; let client = Ipc::connect(path) @@ -192,6 +190,26 @@ impl RuntimeClient { } } +#[cfg(windows)] +fn url_to_file_path(url: &Url) -> Result { + const PREFIX: &str = "file:///pipe/"; + + let url_str = url.as_str(); + + if url_str.starts_with(PREFIX) { + let pipe_name = &url_str[PREFIX.len()..]; + let pipe_path = format!(r"\\.\pipe\{}", pipe_name); + return Ok(PathBuf::from(pipe_path)) + } + + url.to_file_path() +} + +#[cfg(not(windows))] +fn url_to_file_path(url: &Url) -> Result { + url.to_file_path() +} + #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl JsonRpcClient for RuntimeClient { From a8047032e6b9acac07d24c75975686c5c747249d Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 14 Sep 2023 10:47:32 -0400 Subject: [PATCH 0078/1963] chore(all): remove jemalloc (#5833) --- Cargo.lock | 23 ----------------------- Cargo.toml | 1 - crates/cast/Cargo.toml | 6 +----- crates/cast/bin/main.rs | 4 ---- crates/chisel/Cargo.toml | 6 +----- crates/chisel/bin/main.rs | 4 ---- crates/forge/Cargo.toml | 6 +----- crates/forge/bin/main.rs | 4 ---- 8 files changed, 3 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c59308fcae617..525858b87263c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -682,7 +682,6 @@ dependencies = [ "serde", "serde_json", "tempfile", - "tikv-jemallocator", "tokio", "tracing", "vergen", @@ -738,7 +737,6 @@ dependencies = [ "serial_test", "solang-parser", "strum 0.25.0", - "tikv-jemallocator", "time", "tokio", "vergen", @@ -2176,7 +2174,6 @@ dependencies = [ "strum 0.25.0", "svm-rs", "thiserror", - "tikv-jemallocator", "tokio", "tracing", "vergen", @@ -6313,26 +6310,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "tikv-jemallocator" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" -dependencies = [ - "libc", - "tikv-jemalloc-sys", -] - [[package]] name = "time" version = "0.3.28" diff --git a/Cargo.toml b/Cargo.toml index 04dc284000d39..a8b30b376edd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,7 +153,6 @@ chrono = { version = "0.4", default-features = false, features = ["clock", "std" hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.11" solang-parser = "=0.3.2" -tikv-jemallocator = "0.5.4" #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index a59dac5e096c3..141b67244dc0b 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -64,17 +64,13 @@ tokio = { version = "1", features = ["macros", "signal"] } tracing = "0.1" yansi = "0.5" -[target.'cfg(not(target_env = "msvc"))'.dependencies] -tikv-jemallocator = { workspace = true, optional = true } - [dev-dependencies] foundry-test-utils.workspace = true async-trait = "0.1" criterion = "0.5" [features] -default = ["rustls", "jemalloc"] -jemalloc = ["dep:tikv-jemallocator"] +default = ["rustls"] rustls = ["foundry-cli/rustls"] openssl = ["foundry-cli/openssl"] diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index c50c5a77cc9f4..0536c555ead68 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -25,10 +25,6 @@ pub mod opts; use opts::{Opts, Subcommands, ToBaseArgs}; -#[cfg(not(target_env = "msvc"))] -#[global_allocator] -static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; - #[tokio::main] async fn main() -> Result<()> { utils::load_dotenv(); diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 9633386b58a68..043e3424bfd37 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -49,17 +49,13 @@ dirs = "5" time = { version = "0.3", features = ["formatting"] } regex = "1" -[target.'cfg(not(target_env = "msvc"))'.dependencies] -tikv-jemallocator = { workspace = true, optional = true } - [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } serial_test = "2" once_cell = "1" [features] -default = ["rustls", "jemalloc"] -jemalloc = ["dep:tikv-jemallocator"] +default = ["rustls"] rustls = ["ethers/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["ethers/openssl", "reqwest/default-tls"] diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 3b7f26a9c4cac..55de1f0649edb 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -23,10 +23,6 @@ use foundry_config::{ use rustyline::{config::Configurer, error::ReadlineError, Editor}; use yansi::Paint; -#[cfg(not(target_env = "msvc"))] -#[global_allocator] -static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; - // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(ChiselParser, opts, evm_opts); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index e52b800c837ed..25519e290a450 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -63,9 +63,6 @@ thiserror = "1" tokio = { version = "1", features = ["time"] } watchexec = "2" -[target.'cfg(not(target_env = "msvc"))'.dependencies] -tikv-jemallocator = { workspace = true, optional = true } - [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true @@ -78,8 +75,7 @@ serial_test = "2" svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } [features] -default = ["rustls", "jemalloc"] -jemalloc = ["dep:tikv-jemallocator"] +default = ["rustls"] rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-cli/openssl", "reqwest/default-tls"] diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 5ef7e7581632c..08f1afefc168e 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -9,10 +9,6 @@ mod opts; use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; use opts::{Opts, Subcommands}; -#[cfg(not(target_env = "msvc"))] -#[global_allocator] -static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; - fn main() -> Result<()> { utils::load_dotenv(); handler::install()?; From ae89c92ee32b38d525429fe9c216a0919bc7bed1 Mon Sep 17 00:00:00 2001 From: DittoETH <136378658+ditto-eth@users.noreply.github.com> Date: Thu, 14 Sep 2023 08:07:13 -0700 Subject: [PATCH 0079/1963] feat: `cool` cheatcode (#5830) * feat: `cool` cheatcode * refactor: extract to a function, remove check --- crates/abi/abi/HEVM.sol | 1 + crates/abi/src/bindings/hevm.rs | 53 ++++++++++++++++ .../src/executor/inspector/cheatcodes/env.rs | 13 ++++ testdata/cheats/Cool.t.sol | 60 +++++++++++++++++++ testdata/cheats/Vm.sol | 3 + 5 files changed, 130 insertions(+) create mode 100644 testdata/cheats/Cool.t.sol diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index fdabab9c6f4e9..cec6414ad653e 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -22,6 +22,7 @@ fee(uint256) coinbase(address) store(address,bytes32,bytes32) load(address,bytes32)(bytes32) +cool(address) setEnv(string,string) envBool(string)(bool) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index 1955336ec209e..69efd2c2fa3ec 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -270,6 +270,24 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("cool"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("cool"), + inputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::None, + }, + ], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("copyFile"), ::std::vec![ @@ -5429,6 +5447,15 @@ pub mod hevm { .method_hash([255, 72, 60, 84], p0) .expect("method not found (this should never happen)") } + ///Calls the contract's `cool` (0x40ff9f21) function + pub fn cool( + &self, + p0: ::ethers_core::types::Address, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([64, 255, 159, 33], p0) + .expect("method not found (this should never happen)") + } ///Calls the contract's `copyFile` (0xa54a87d8) function pub fn copy_file( &self, @@ -7680,6 +7707,19 @@ pub mod hevm { )] #[ethcall(name = "coinbase", abi = "coinbase(address)")] pub struct CoinbaseCall(pub ::ethers_core::types::Address); + ///Container type for all input parameters for the `cool` function with signature `cool(address)` and selector `0x40ff9f21` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "cool", abi = "cool(address)")] + pub struct CoolCall(pub ::ethers_core::types::Address); ///Container type for all input parameters for the `copyFile` function with signature `copyFile(string,string)` and selector `0xa54a87d8` #[derive( Clone, @@ -10539,6 +10579,7 @@ pub mod hevm { ClearMockedCalls(ClearMockedCallsCall), CloseFile(CloseFileCall), Coinbase(CoinbaseCall), + Cool(CoolCall), CopyFile(CopyFileCall), CreateDir(CreateDirCall), CreateFork1(CreateFork1Call), @@ -10812,6 +10853,11 @@ pub mod hevm { ) { return Ok(Self::Coinbase(decoded)); } + if let Ok(decoded) = ::decode( + data, + ) { + return Ok(Self::Cool(decoded)); + } if let Ok(decoded) = ::decode( data, ) { @@ -11835,6 +11881,7 @@ pub mod hevm { ::ethers_core::abi::AbiEncode::encode(element) } Self::Coinbase(element) => ::ethers_core::abi::AbiEncode::encode(element), + Self::Cool(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::CopyFile(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::CreateDir(element) => { ::ethers_core::abi::AbiEncode::encode(element) @@ -12330,6 +12377,7 @@ pub mod hevm { Self::ClearMockedCalls(element) => ::core::fmt::Display::fmt(element, f), Self::CloseFile(element) => ::core::fmt::Display::fmt(element, f), Self::Coinbase(element) => ::core::fmt::Display::fmt(element, f), + Self::Cool(element) => ::core::fmt::Display::fmt(element, f), Self::CopyFile(element) => ::core::fmt::Display::fmt(element, f), Self::CreateDir(element) => ::core::fmt::Display::fmt(element, f), Self::CreateFork1(element) => ::core::fmt::Display::fmt(element, f), @@ -12620,6 +12668,11 @@ pub mod hevm { Self::Coinbase(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: CoolCall) -> Self { + Self::Cool(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: CopyFileCall) -> Self { Self::CopyFile(value) diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index 70110229ee95f..ef0320b78fdbe 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -318,6 +318,18 @@ fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: boo Ok(Bytes::new()) } +// mark the slots of an account and the account address as cold +fn cool_account(data: &mut EVMData<'_, DB>, address: Address) -> Result { + if let Some(account) = data.journaled_state.state.get_mut(&h160_to_b160(address)) { + if account.is_touched() { + account.unmark_touch(); + } + account.storage.clear(); + } + + Ok(Bytes::new()) +} + #[instrument(level = "error", name = "env", target = "evm::cheatcodes", skip_all)] pub fn apply( state: &mut Cheatcodes, @@ -387,6 +399,7 @@ pub fn apply( )?; ru256_to_u256(val).encode().into() } + HEVMCalls::Cool(inner) => cool_account(data, inner.0)?, HEVMCalls::Breakpoint0(inner) => add_breakpoint(state, caller, &inner.0, true)?, HEVMCalls::Breakpoint1(inner) => add_breakpoint(state, caller, &inner.0, inner.1)?, HEVMCalls::Etch(inner) => { diff --git a/testdata/cheats/Cool.t.sol b/testdata/cheats/Cool.t.sol new file mode 100644 index 0000000000000..674b9abbd3426 --- /dev/null +++ b/testdata/cheats/Cool.t.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "../lib/ds-test/src/test.sol"; +import "./Vm.sol"; + +contract CoolTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + uint256 public slot0 = 1; + + function testCool_SLOAD_normal() public { + uint256 startGas; + uint256 endGas; + uint256 val; + uint256 beforeCoolGas; + uint256 noCoolGas; + + startGas = gasleft(); + val = slot0; + endGas = gasleft(); + beforeCoolGas = startGas - endGas; + + startGas = gasleft(); + val = slot0; + endGas = gasleft(); + noCoolGas = startGas - endGas; + + assertGt(beforeCoolGas, noCoolGas); + } + + function testCool_SLOAD() public { + uint256 startGas; + uint256 endGas; + uint256 val; + uint256 beforeCoolGas; + uint256 afterCoolGas; + uint256 noCoolGas; + + startGas = gasleft(); + val = slot0; + endGas = gasleft(); + beforeCoolGas = startGas - endGas; + + vm.cool(address(this)); + + startGas = gasleft(); + val = slot0; + endGas = gasleft(); + afterCoolGas = startGas - endGas; + + assertEq(beforeCoolGas, afterCoolGas); + + startGas = gasleft(); + val = slot0; + endGas = gasleft(); + noCoolGas = startGas - endGas; + + assertGt(beforeCoolGas, noCoolGas); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index cf51823a75f64..eaa459170e046 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -96,6 +96,9 @@ interface Vm { // Stores a value to an address' storage slot, (who, slot, value) function store(address, bytes32, bytes32) external; + // Cools off a warm address and its storage slots + function cool(address) external; + // Signs data, (privateKey, digest) => (v, r, s) function sign(uint256, bytes32) external returns (uint8, bytes32, bytes32); From ecf9a10bab059130ef9b90d1b160b6a725a6e21a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 16 Sep 2023 11:17:46 +0200 Subject: [PATCH 0080/1963] test: fix some tests (#5839) * test: fix some tests * fix tests --- crates/chisel/src/executor.rs | 2 +- crates/chisel/src/session_source.rs | 3 ++- testdata/cheats/Fs.t.sol | 17 +++++++++-------- testdata/fixtures/File/symlink | 3 +-- 4 files changed, 13 insertions(+), 12 deletions(-) mode change 100644 => 120000 testdata/fixtures/File/symlink diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 3aa973eb89cf8..073f2c6cc2998 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1630,7 +1630,7 @@ mod tests { } Err(e) => { // try reinstalling - eprintln!("error: {e}\n trying to re-install Solc v{version}"); + eprintln!("error while trying to re-install Solc v{version}: {e}"); let solc = Solc::blocking_install(&version.parse().unwrap()); if solc.map_err(SolcError::from).and_then(|solc| solc.version()).is_ok() { *is_preinstalled = true; diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 33b7caf7b4d44..bad2cd92715c3 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -185,7 +185,8 @@ impl SessionSource { /// A new instance of [SessionSource] #[track_caller] pub fn new(solc: Solc, config: SessionSourceConfig) -> Self { - debug_assert!(solc.version().is_ok(), "{:?}", solc.version()); + #[cfg(debug_assertions)] + let _ = solc.version().unwrap(); Self { file_name: PathBuf::from("ReplContract.sol".to_string()), diff --git a/testdata/cheats/Fs.t.sol b/testdata/cheats/Fs.t.sol index 81be8beb640c3..31739c08ccc75 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/cheats/Fs.t.sol @@ -290,24 +290,25 @@ contract FsTest is DSTest { function testFsMetadata() public { fsProxy = new FsProxy(); - string memory path = "fixtures/File"; - Vm.FsMetadata memory metadata = vm.fsMetadata(path); + Vm.FsMetadata memory metadata = vm.fsMetadata("fixtures/File"); assertEq(metadata.isDir, true); assertEq(metadata.isSymlink, false); assertEq(metadata.readOnly, false); - assertGt(metadata.length, 0); // These fields aren't available on all platforms, default to zero + // assertGt(metadata.length, 0); // assertGt(metadata.modified, 0); // assertGt(metadata.accessed, 0); // assertGt(metadata.created, 0); - path = "fixtures/File/read.txt"; - metadata = vm.fsMetadata(path); + metadata = vm.fsMetadata("fixtures/File/read.txt"); assertEq(metadata.isDir, false); - - path = "fixtures/File/symlink"; - metadata = vm.fsMetadata(path); assertEq(metadata.isSymlink, false); + assertEq(metadata.length, 45); + + metadata = vm.fsMetadata("fixtures/File/symlink"); + assertEq(metadata.isDir, false); + // TODO: symlinks are canonicalized away in `ensure_path_allowed` + // assertEq(metadata.isSymlink, true); vm.expectRevert(); fsProxy.fsMetadata("../not-found"); diff --git a/testdata/fixtures/File/symlink b/testdata/fixtures/File/symlink deleted file mode 100644 index c727e632c8883..0000000000000 --- a/testdata/fixtures/File/symlink +++ /dev/null @@ -1,2 +0,0 @@ -hello readable world -this is the second line! \ No newline at end of file diff --git a/testdata/fixtures/File/symlink b/testdata/fixtures/File/symlink new file mode 120000 index 0000000000000..2fe9fd1c6dc4c --- /dev/null +++ b/testdata/fixtures/File/symlink @@ -0,0 +1 @@ +read.txt \ No newline at end of file From 49f4530c3a879427ab62823528236d9881d45ced Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 18 Sep 2023 10:31:01 -0400 Subject: [PATCH 0081/1963] (#1) Alloy Migration: first batch (type conversions) (#5768) * feat: use alloy revm branch * fuzz/mod migrated * progress * progress, fmt * fix imdb * feat: cheatcodes compile * feat: fork backend compiles * feat: trace * fuzz * anvil progress * chore: mem, fmt * chore: db.rs * chore: it lives * fix test * chore: clippy * workin * main backend stuff migrated * chore: add glue on other crates * chore: make executor use alloy types * add glue for executor migration * chore: use workspace alloy * chore: undo revm bump changes * chore: remove unneded prefix * chore: fix fork fixture * chore: uncomment tests * chore: switch to up-to-date revm * chore: clippy * (#2) Alloy Migration: Migrate non-cheatcode inspectors (#5770) * feat: migrate non-cheatcode inspectors * fix: properly create both create and create2 addresses * chore: clippy * (#3) Alloy Migration: migrate fork-adjacent files to alloy primitives (#5771) * chore: use create2_from_code * borrow it brah * chore: use from word * chore: drop to_be_bytes * fmt * chore: use from_word on both palces * chore: use address::random * chore: make failure slot b256 * chore: use address::random * chore: fix indexes * chore: use contract.hash * chore: do not collect * chore: use display on alloy nums * use + operator * chore: unwrap bytes and replace import * chore: Into:: -> ::from * chore: fix test * chore: use alloy imports * chore: switch to alloy typesd * chore: fix test --- Cargo.lock | 200 +++++++++++------- Cargo.toml | 10 +- crates/anvil/Cargo.toml | 1 + crates/anvil/core/Cargo.toml | 2 + crates/anvil/core/src/eth/proof.rs | 3 +- crates/anvil/core/src/eth/receipt.rs | 10 +- crates/anvil/core/src/eth/transaction/mod.rs | 33 +-- crates/anvil/core/src/eth/utils.rs | 4 +- crates/anvil/src/config.rs | 16 +- crates/anvil/src/eth/api.rs | 3 +- crates/anvil/src/eth/backend/db.rs | 28 +-- crates/anvil/src/eth/backend/executor.rs | 14 +- crates/anvil/src/eth/backend/genesis.rs | 16 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 15 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 62 +++--- crates/anvil/src/eth/backend/mem/inspector.rs | 11 +- crates/anvil/src/eth/backend/mem/mod.rs | 102 ++++----- crates/anvil/src/eth/backend/mem/state.rs | 33 +-- crates/anvil/src/eth/backend/mem/storage.rs | 16 +- crates/anvil/src/genesis.rs | 6 +- crates/anvil/tests/it/fork.rs | 4 +- crates/anvil/tests/it/proof/mod.rs | 4 +- crates/cast/bin/cmd/call.rs | 18 +- crates/cast/bin/cmd/run.rs | 12 +- crates/chisel/src/runner.rs | 46 +++- crates/debugger/src/debugger.rs | 4 +- crates/debugger/src/lib.rs | 8 +- crates/evm/Cargo.toml | 2 + crates/evm/src/debug.rs | 2 +- crates/evm/src/executor/abi/mod.rs | 8 +- crates/evm/src/executor/backend/diagnostic.rs | 15 +- crates/evm/src/executor/backend/error.rs | 9 +- crates/evm/src/executor/backend/fuzz.rs | 38 ++-- .../evm/src/executor/backend/in_memory_db.rs | 28 +-- crates/evm/src/executor/backend/mod.rs | 133 ++++++------ crates/evm/src/executor/backend/snapshot.rs | 7 +- crates/evm/src/executor/builder.rs | 6 +- crates/evm/src/executor/fork/backend.rs | 120 ++++++----- crates/evm/src/executor/fork/cache.rs | 19 +- crates/evm/src/executor/fork/database.rs | 31 +-- crates/evm/src/executor/fork/init.rs | 16 +- crates/evm/src/executor/fork/multi.rs | 2 +- .../evm/src/executor/inspector/access_list.rs | 36 ++-- .../src/executor/inspector/cheatcodes/env.rs | 23 +- .../executor/inspector/cheatcodes/expect.rs | 4 +- .../src/executor/inspector/cheatcodes/fork.rs | 81 ++++--- .../src/executor/inspector/cheatcodes/mod.rs | 122 ++++++----- .../executor/inspector/cheatcodes/snapshot.rs | 10 +- .../src/executor/inspector/cheatcodes/util.rs | 29 +-- crates/evm/src/executor/inspector/debugger.rs | 24 ++- crates/evm/src/executor/inspector/fuzzer.rs | 4 +- crates/evm/src/executor/inspector/logs.rs | 13 +- crates/evm/src/executor/inspector/printer.rs | 5 +- crates/evm/src/executor/inspector/stack.rs | 33 +-- crates/evm/src/executor/inspector/tracer.rs | 38 ++-- crates/evm/src/executor/inspector/utils.rs | 15 +- crates/evm/src/executor/mod.rs | 84 ++++---- crates/evm/src/executor/opts.rs | 34 ++- crates/evm/src/executor/snapshot.rs | 12 +- crates/evm/src/fuzz/invariant/error.rs | 25 ++- crates/evm/src/fuzz/invariant/executor.rs | 33 +-- crates/evm/src/fuzz/invariant/mod.rs | 21 +- crates/evm/src/fuzz/mod.rs | 20 +- crates/evm/src/fuzz/strategies/state.rs | 12 +- crates/evm/src/lib.rs | 11 +- crates/evm/src/trace/decoder.rs | 13 +- crates/evm/src/trace/mod.rs | 10 +- crates/evm/src/trace/node.rs | 5 +- crates/evm/src/utils.rs | 24 ++- crates/forge/Cargo.toml | 2 + crates/forge/bin/cmd/coverage.rs | 5 +- crates/forge/bin/cmd/script/build.rs | 3 +- crates/forge/bin/cmd/script/cmd.rs | 18 +- crates/forge/bin/cmd/script/executor.rs | 14 +- crates/forge/bin/cmd/script/mod.rs | 5 +- crates/forge/bin/cmd/script/runner.rs | 66 ++++-- crates/forge/bin/cmd/script/transaction.rs | 5 +- crates/forge/bin/cmd/test/mod.rs | 9 +- crates/forge/src/gas_report.rs | 5 +- crates/forge/src/multi_runner.rs | 5 +- crates/forge/src/result.rs | 3 +- crates/forge/src/runner.rs | 61 ++++-- crates/forge/tests/it/config.rs | 3 +- crates/forge/tests/it/test_helpers.rs | 9 +- testdata/cheats/Fork2.t.sol | 2 +- 85 files changed, 1170 insertions(+), 903 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 525858b87263c..881409d99680c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,6 +75,49 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy-primitives" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if", + "const-hex", + "derive_more", + "getrandom 0.2.10", + "hex-literal", + "itoa", + "proptest", + "ruint", + "serde", + "tiny-keccak", +] + +[[package]] +name = "alloy-rlp" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f938f00332d63a5b0ac687bd6f46d03884638948921d9f8b50c59563d421ae25" +dependencies = [ + "alloy-rlp-derive", + "arrayvec", + "bytes", + "smol_str", +] + +[[package]] +name = "alloy-rlp-derive" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa5bb468bc7c46e0c5074d418f575262ff79451242e5ac1380121ed4e23c4fd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.33", +] + [[package]] name = "ammonia" version = "3.3.0" @@ -125,9 +168,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" [[package]] name = "anstyle-parse" @@ -161,6 +204,7 @@ dependencies = [ name = "anvil" version = "0.2.0" dependencies = [ + "alloy-primitives", "anvil-core", "anvil-rpc", "anvil-server", @@ -208,6 +252,7 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ + "alloy-primitives", "bytes", "ethers-core", "foundry-evm", @@ -310,7 +355,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -321,7 +366,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -625,9 +670,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "fb9ac64500cc83ce4b9f8dafa78186aa008c8dea77a09b94cd307fd0cd5022a8" dependencies = [ "camino", "cargo-platform", @@ -795,9 +840,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.2" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" dependencies = [ "clap_builder", "clap_derive", @@ -846,7 +891,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -1574,7 +1619,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -1713,7 +1758,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1728,7 +1773,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "ethers-core", "once_cell", @@ -1739,7 +1784,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -1757,7 +1802,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "Inflector", "const-hex", @@ -1772,7 +1817,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.32", + "syn 2.0.33", "toml 0.7.8", "walkdir", ] @@ -1780,7 +1825,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "Inflector", "const-hex", @@ -1789,13 +1834,13 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "arrayvec", "bytes", @@ -1814,7 +1859,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.32", + "syn 2.0.33", "tempfile", "thiserror", "tiny-keccak", @@ -1824,7 +1869,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "ethers-core", "ethers-solc", @@ -1839,7 +1884,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "async-trait", "auto_impl", @@ -1865,7 +1910,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "async-trait", "auto_impl", @@ -1903,7 +1948,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "async-trait", "coins-bip32", @@ -1930,7 +1975,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a28c5ae9b76d04a8b4ab39e5afcd772bfd43bd1f" +source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" dependencies = [ "cfg-if", "const-hex", @@ -2017,7 +2062,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -2131,6 +2176,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" name = "forge" version = "0.2.0" dependencies = [ + "alloy-primitives", "anvil", "async-trait", "bytes", @@ -2243,7 +2289,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-macros", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -2379,6 +2425,7 @@ dependencies = [ name = "foundry-evm" version = "0.2.0" dependencies = [ + "alloy-primitives", "auto_impl", "bytes", "const-hex", @@ -2426,7 +2473,7 @@ version = "0.2.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -2577,7 +2624,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -3635,9 +3682,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libgit2-sys" @@ -3884,7 +3931,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4151,7 +4198,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4255,7 +4302,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4456,7 +4503,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4505,7 +4552,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4608,7 +4655,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4646,7 +4693,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4740,7 +4787,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -4793,9 +4840,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -4808,7 +4855,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", "version_check", "yansi 1.0.0-rc.1", ] @@ -5156,10 +5203,9 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" dependencies = [ "auto_impl", - "rayon", "revm-interpreter", "revm-precompile", "serde", @@ -5169,19 +5215,18 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" dependencies = [ "derive_more", "enumn", "revm-primitives", "serde", - "sha3", ] [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" dependencies = [ "k256", "num", @@ -5189,30 +5234,27 @@ dependencies = [ "revm-primitives", "ripemd", "sha2 0.10.7", - "sha3", "substrate-bn", ] [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/bluealloy/revm/?rev=429da731cd8efdc0939ed912240b2667b9155834#429da731cd8efdc0939ed912240b2667b9155834" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" dependencies = [ + "alloy-primitives", + "alloy-rlp", "auto_impl", "bitflags 2.4.0", "bitvec", "bytes", "derive_more", "enumn", - "fixed-hash", "hashbrown 0.14.0", "hex", "hex-literal", "primitive-types", - "rlp", - "ruint", "serde", - "sha3", ] [[package]] @@ -5298,10 +5340,9 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" dependencies = [ - "primitive-types", + "alloy-rlp", "proptest", "rand 0.8.5", - "rlp", "ruint-macro", "serde", "valuable", @@ -5475,7 +5516,7 @@ checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", - "rustls-webpki 0.101.4", + "rustls-webpki 0.101.5", "sct", ] @@ -5502,9 +5543,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.100.2" +version = "0.100.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" +checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" dependencies = [ "ring", "untrusted", @@ -5512,9 +5553,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.4" +version = "0.101.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" dependencies = [ "ring", "untrusted", @@ -5738,7 +5779,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -5806,7 +5847,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -5980,6 +6021,15 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +[[package]] +name = "smol_str" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" +dependencies = [ + "serde", +] + [[package]] name = "socket2" version = "0.4.9" @@ -5992,9 +6042,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -6112,7 +6162,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -6180,9 +6230,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.32" +version = "2.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" dependencies = [ "proc-macro2", "quote", @@ -6297,7 +6347,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -6388,7 +6438,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.4", "tokio-macros", "windows-sys 0.48.0", ] @@ -6401,7 +6451,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -6638,7 +6688,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", ] [[package]] @@ -6874,9 +6924,9 @@ checksum = "98e90c70c9f0d4d1ee6d0a7d04aa06cb9bbd53d8cfbdd62a0269a7c2eb640552" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -7065,7 +7115,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", "wasm-bindgen-shared", ] @@ -7099,7 +7149,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.33", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7184,7 +7234,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "rustls-webpki 0.100.2", + "rustls-webpki 0.100.3", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a8b30b376edd9..faadc171fcfbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,6 +154,8 @@ hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.11" solang-parser = "=0.3.2" +alloy-primitives = { version = "0.3", default-features = false } + #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } #ethers-addressbook = { path = "../ethers-rs/ethers-addressbook" } @@ -167,7 +169,7 @@ solang-parser = "=0.3.2" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } -revm-interpreter = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } -revm-precompile = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } -revm-primitives = { git = "https://github.com/bluealloy/revm/", rev = "429da731cd8efdc0939ed912240b2667b9155834" } +revm = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } +revm-interpreter = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } +revm-precompile = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } +revm-primitives = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 9d7a24ba379ba..058123836405f 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -34,6 +34,7 @@ ethers = { workspace = true, features = ["rustls", "ws", "ipc"] } trie-db = { version = "0.23" } hash-db = { version = "0.15" } memory-db = { version = "0.29" } +alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde"] } # axum related axum = { version = "0.5", features = ["ws"] } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 9c371cb851353..3b49e4bc5819e 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -14,6 +14,8 @@ repository.workspace = true foundry-evm = { path = "../../evm" } revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } + +alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde"] } ethers-core.workspace = true serde = { version = "1", features = ["derive"], optional = true } serde_json = "1" diff --git a/crates/anvil/core/src/eth/proof.rs b/crates/anvil/core/src/eth/proof.rs index a1a2f3b5a3c24..a0714ab29e2df 100644 --- a/crates/anvil/core/src/eth/proof.rs +++ b/crates/anvil/core/src/eth/proof.rs @@ -5,6 +5,7 @@ use ethers_core::{ types::{H256, U256}, utils::rlp, }; +use foundry_evm::utils::b256_to_h256; use revm::primitives::KECCAK_EMPTY; // reexport for convenience pub use ethers_core::types::{EIP1186ProofResponse as AccountProof, StorageProof}; @@ -28,7 +29,7 @@ impl Default for BasicAccount { BasicAccount { balance: 0.into(), nonce: 0.into(), - code_hash: KECCAK_EMPTY.into(), + code_hash: b256_to_h256(KECCAK_EMPTY), storage_root: KECCAK_NULL_RLP, } } diff --git a/crates/anvil/core/src/eth/receipt.rs b/crates/anvil/core/src/eth/receipt.rs index e663b33329086..5b3a15eee0690 100644 --- a/crates/anvil/core/src/eth/receipt.rs +++ b/crates/anvil/core/src/eth/receipt.rs @@ -6,7 +6,7 @@ use ethers_core::{ rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, }, }; -use foundry_evm::utils::{b256_to_h256, h256_to_b256}; +use foundry_evm::utils::{b160_to_h160, b256_to_h256, h160_to_b160, h256_to_b256}; #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] @@ -21,9 +21,9 @@ impl From for Log { fn from(log: revm::primitives::Log) -> Self { let revm::primitives::Log { address, topics, data } = log; Log { - address: address.into(), + address: b160_to_h160(address), topics: topics.into_iter().map(b256_to_h256).collect(), - data: data.into(), + data: ethers_core::types::Bytes(data.0), } } } @@ -32,9 +32,9 @@ impl From for revm::primitives::Log { fn from(log: Log) -> Self { let Log { address, topics, data } = log; revm::primitives::Log { - address: address.into(), + address: h160_to_b160(address), topics: topics.into_iter().map(h256_to_b256).collect(), - data: data.0, + data: alloy_primitives::Bytes(data.0), } } } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 8445f7dfd663c..ae3fd15983d07 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -14,7 +14,10 @@ use ethers_core::{ rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, }, }; -use foundry_evm::trace::CallTraceArena; +use foundry_evm::{ + trace::CallTraceArena, + utils::{h160_to_b160, u256_to_ru256}, +}; use revm::{ interpreter::InstructionResult, primitives::{CreateScheme, TransactTo, TxEnv}, @@ -1185,7 +1188,7 @@ impl PendingTransaction { pub fn to_revm_tx_env(&self) -> TxEnv { fn transact_to(kind: &TransactionKind) -> TransactTo { match kind { - TransactionKind::Call(c) => TransactTo::Call((*c).into()), + TransactionKind::Call(c) => TransactTo::Call(h160_to_b160(*c)), TransactionKind::Create => TransactTo::Create(CreateScheme::Create), } } @@ -1196,13 +1199,13 @@ impl PendingTransaction { let chain_id = tx.chain_id(); let LegacyTransaction { nonce, gas_price, gas_limit, value, kind, input, .. } = tx; TxEnv { - caller: caller.into(), + caller: h160_to_b160(caller), transact_to: transact_to(kind), - data: input.0.clone(), + data: alloy_primitives::Bytes(input.0.clone()), chain_id, nonce: Some(nonce.as_u64()), - value: (*value).into(), - gas_price: (*gas_price).into(), + value: u256_to_ru256(*value), + gas_price: u256_to_ru256(*gas_price), gas_priority_fee: None, gas_limit: gas_limit.as_u64(), access_list: vec![], @@ -1221,13 +1224,13 @@ impl PendingTransaction { .. } = tx; TxEnv { - caller: caller.into(), + caller: h160_to_b160(caller), transact_to: transact_to(kind), - data: input.0.clone(), + data: alloy_primitives::Bytes(input.0.clone()), chain_id: Some(*chain_id), nonce: Some(nonce.as_u64()), - value: (*value).into(), - gas_price: (*gas_price).into(), + value: u256_to_ru256(*value), + gas_price: u256_to_ru256(*gas_price), gas_priority_fee: None, gas_limit: gas_limit.as_u64(), access_list: to_revm_access_list(access_list.0.clone()), @@ -1247,14 +1250,14 @@ impl PendingTransaction { .. } = tx; TxEnv { - caller: caller.into(), + caller: h160_to_b160(caller), transact_to: transact_to(kind), - data: input.0.clone(), + data: alloy_primitives::Bytes(input.0.clone()), chain_id: Some(*chain_id), nonce: Some(nonce.as_u64()), - value: (*value).into(), - gas_price: (*max_fee_per_gas).into(), - gas_priority_fee: Some((*max_priority_fee_per_gas).into()), + value: u256_to_ru256(*value), + gas_price: u256_to_ru256(*max_fee_per_gas), + gas_priority_fee: Some(u256_to_ru256(*max_priority_fee_per_gas)), gas_limit: gas_limit.as_u64(), access_list: to_revm_access_list(access_list.0.clone()), } diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index f6a0f6f412b28..7ee856195cd1f 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,3 +1,4 @@ +use alloy_primitives::{Address as rAddress, U256 as rU256}; use ethers_core::{ types::{transaction::eip2930::AccessListItem, Address, U256}, utils::{ @@ -6,7 +7,6 @@ use ethers_core::{ }, }; use foundry_evm::utils::{h160_to_b160, h256_to_u256_be, u256_to_ru256}; -use revm::primitives::{B160, U256 as rU256}; pub fn enveloped(id: u8, v: &T, s: &mut RlpStream) { let encoded = rlp::encode(v); @@ -22,7 +22,7 @@ pub fn to_access_list(list: Vec) -> Vec<(Address, Vec)> { .collect() } -pub fn to_revm_access_list(list: Vec) -> Vec<(B160, Vec)> { +pub fn to_revm_access_list(list: Vec) -> Vec<(rAddress, Vec)> { list.into_iter() .map(|item| { ( diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index e9e4a7ae2866b..1f33c17890743 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -38,7 +38,9 @@ use foundry_evm::{ }, revm, revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv, U256 as rU256}, - utils::{apply_chain_and_block_specific_env_changes, h256_to_b256, u256_to_ru256}, + utils::{ + apply_chain_and_block_specific_env_changes, b160_to_h160, h256_to_b256, u256_to_ru256, + }, }; use parking_lot::RwLock; use serde_json::{json, to_writer, Value}; @@ -795,8 +797,8 @@ impl NodeConfig { let mut env = revm::primitives::Env { cfg, block: BlockEnv { - gas_limit: self.gas_limit.into(), - basefee: self.get_base_fee().into(), + gas_limit: u256_to_ru256(self.gas_limit), + basefee: u256_to_ru256(self.get_base_fee()), ..Default::default() }, tx: TxEnv { chain_id: self.get_chain_id().into(), ..Default::default() }, @@ -884,8 +886,8 @@ latest block number: {latest_block}" env.block = BlockEnv { number: rU256::from(fork_block_number), - timestamp: block.timestamp.into(), - difficulty: block.difficulty.into(), + timestamp: u256_to_ru256(block.timestamp), + difficulty: u256_to_ru256(block.difficulty), // ensures prevrandao is set prevrandao: Some(block.mix_hash.unwrap_or_default()).map(h256_to_b256), gas_limit, @@ -992,7 +994,7 @@ latest block number: {latest_block}" let genesis = GenesisConfig { timestamp: self.get_genesis_timestamp(), - balance: self.genesis_balance.into(), + balance: u256_to_ru256(self.genesis_balance), accounts: self.genesis_accounts.iter().map(|acc| acc.address()).collect(), fork_genesis_account_infos: Arc::new(Default::default()), genesis_init: self.genesis.clone(), @@ -1016,7 +1018,7 @@ latest block number: {latest_block}" // if the option is not disabled and we are not forking. if !self.disable_default_create2_deployer && self.eth_rpc_url.is_none() { backend - .set_create2_deployer(DEFAULT_CREATE2_DEPLOYER) + .set_create2_deployer(b160_to_h160(DEFAULT_CREATE2_DEPLOYER)) .await .expect("Failed to create default create2 deployer"); } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index c0046ce2064a0..5c2d107b1ce39 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -64,6 +64,7 @@ use foundry_evm::{ interpreter::{return_ok, return_revert, InstructionResult}, primitives::BlockEnv, }, + utils::ru256_to_u256, }; use futures::channel::mpsc::Receiver; use parking_lot::RwLock; @@ -2062,7 +2063,7 @@ impl EthApi { // get the highest possible gas limit, either the request's set value or the currently // configured gas limit - let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit.into()); + let mut highest_gas_limit = request.gas.unwrap_or(ru256_to_u256(block_env.gas_limit)); // check with the funds of the sender if let Some(from) = request.from { diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 6967b79d13f8c..d64b7247bf426 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -1,6 +1,7 @@ //! Helper types for working with [revm](foundry_evm::revm) use crate::{mem::state::trie_hash_db, revm::primitives::AccountInfo, U256}; +use alloy_primitives::{Address as B160, B256, U256 as rU256}; use anvil_core::eth::trie::KeccakHasher; use ethers::{ prelude::{Address, Bytes}, @@ -15,9 +16,10 @@ use foundry_evm::{ }, revm::{ db::{CacheDB, DbAccount}, - primitives::{Bytecode, B160, B256, KECCAK_EMPTY, U256 as rU256}, + primitives::{Bytecode, KECCAK_EMPTY}, Database, DatabaseCommit, }, + utils::{h160_to_b160, h256_to_b256, u256_to_ru256}, HashMap, }; use hash_db::HashDB; @@ -84,7 +86,7 @@ pub trait Db: /// Sets the nonce of the given address fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()> { - let mut info = self.basic(address.into())?.unwrap_or_default(); + let mut info = self.basic(h160_to_b160(address))?.unwrap_or_default(); info.nonce = nonce; self.insert_account(address, info); Ok(()) @@ -92,22 +94,22 @@ pub trait Db: /// Sets the balance of the given address fn set_balance(&mut self, address: Address, balance: U256) -> DatabaseResult<()> { - let mut info = self.basic(address.into())?.unwrap_or_default(); - info.balance = balance.into(); + let mut info = self.basic(h160_to_b160(address))?.unwrap_or_default(); + info.balance = u256_to_ru256(balance); self.insert_account(address, info); Ok(()) } /// Sets the balance of the given address fn set_code(&mut self, address: Address, code: Bytes) -> DatabaseResult<()> { - let mut info = self.basic(address.into())?.unwrap_or_default(); + let mut info = self.basic(h160_to_b160(address))?.unwrap_or_default(); let code_hash = if code.as_ref().is_empty() { KECCAK_EMPTY } else { B256::from_slice(&keccak256(code.as_ref())[..]) }; info.code_hash = code_hash; - info.code = Some(Bytecode::new_raw(code.0).to_checked()); + info.code = Some(Bytecode::new_raw(alloy_primitives::Bytes(code.0)).to_checked()); self.insert_account(address, info); Ok(()) } @@ -124,7 +126,7 @@ pub trait Db: /// Deserialize and add all chain data to the backend storage fn load_state(&mut self, state: SerializableState) -> DatabaseResult { for (addr, account) in state.accounts.into_iter() { - let old_account_nonce = DatabaseRef::basic(self, addr.into()) + let old_account_nonce = DatabaseRef::basic(self, h160_to_b160(addr)) .ok() .and_then(|acc| acc.map(|acc| acc.nonce)) .unwrap_or_default(); @@ -135,12 +137,14 @@ pub trait Db: self.insert_account( addr, AccountInfo { - balance: account.balance.into(), + balance: u256_to_ru256(account.balance), code_hash: KECCAK_EMPTY, // will be set automatically code: if account.code.0.is_empty() { None } else { - Some(Bytecode::new_raw(account.code.0).to_checked()) + Some( + Bytecode::new_raw(alloy_primitives::Bytes(account.code.0)).to_checked(), + ) }, nonce, }, @@ -176,15 +180,15 @@ pub trait Db: /// [Backend::pending_block()](crate::eth::backend::mem::Backend::pending_block()) impl + Send + Sync + Clone + fmt::Debug> Db for CacheDB { fn insert_account(&mut self, address: Address, account: AccountInfo) { - self.insert_account_info(address.into(), account) + self.insert_account_info(h160_to_b160(address), account) } fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.insert_account_storage(address.into(), slot.into(), val.into()) + self.insert_account_storage(h160_to_b160(address), u256_to_ru256(slot), u256_to_ru256(val)) } fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.block_hashes.insert(number.into(), hash.into()); + self.block_hashes.insert(u256_to_ru256(number), h256_to_b256(hash)); } fn dump_state(&self) -> DatabaseResult> { diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 7198e160cd0ab..ddbfb7f9d1931 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -170,8 +170,8 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' traces: CallTraceArena { arena: traces }, exit, out: match out { - Some(Output::Call(b)) => Some(b.into()), - Some(Output::Create(b, _)) => Some(b.into()), + Some(Output::Call(b)) => Some(ethers::types::Bytes(b.0)), + Some(Output::Create(b, _)) => Some(ethers::types::Bytes(b.0)), _ => None, }, }; @@ -190,15 +190,15 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' state_root: self.db.maybe_state_root().unwrap_or_default(), receipts_root, logs_bloom: bloom, - difficulty: difficulty.into(), - number: block_number.into(), - gas_limit: gas_limit.into(), + difficulty: ru256_to_u256(difficulty), + number: ru256_to_u256(block_number), + gas_limit: ru256_to_u256(gas_limit), gas_used: cumulative_gas_used, timestamp, extra_data: Default::default(), mix_hash: Default::default(), nonce: Default::default(), - base_fee: base_fee.map(|x| x.into()), + base_fee: base_fee.map(ru256_to_u256), }; let block = Block::new(partial_header, transactions.clone(), ommers); @@ -238,7 +238,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator let env = self.env_for(&transaction.pending_transaction); // check that we comply with the block's gas limit let max_gas = self.gas_used.saturating_add(U256::from(env.tx.gas_limit)); - if max_gas > env.block.gas_limit.into() { + if max_gas > ru256_to_u256(env.block.gas_limit) { return Some(TransactionExecutionOutcome::Exhausted(transaction)) } diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 4f1c0f92c3a96..25cc3207dc97a 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -4,6 +4,7 @@ use crate::{ eth::backend::db::{Db, MaybeHashDatabase}, genesis::Genesis, }; +use alloy_primitives::{Address as B160, B256, U256}; use ethers::{ abi::ethereum_types::BigEndianHash, types::{Address, H256}, @@ -13,8 +14,8 @@ use foundry_evm::{ backend::{snapshot::StateSnapshot, DatabaseError, DatabaseResult}, DatabaseRef, }, - revm::primitives::{AccountInfo, Bytecode, B160, B256, KECCAK_EMPTY, U256}, - utils::b160_to_h160, + revm::primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, + utils::{b160_to_h160, ru256_to_u256, u256_to_ru256}, }; use parking_lot::Mutex; use std::{collections::HashMap, sync::Arc}; @@ -103,7 +104,7 @@ pub(crate) struct AtGenesisStateDb<'a> { impl<'a> DatabaseRef for AtGenesisStateDb<'a> { type Error = DatabaseError; fn basic(&self, address: B160) -> DatabaseResult> { - if let Some(acc) = self.accounts.get(&address.into()).cloned() { + if let Some(acc) = self.accounts.get(&b160_to_h160(address)).cloned() { return Ok(Some(acc)) } self.db.basic(address) @@ -122,9 +123,12 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> { .as_ref() .and_then(|genesis| genesis.alloc.accounts.get(&b160_to_h160(address))) { - let value = - acc.storage.get(&H256::from_uint(&index.into())).copied().unwrap_or_default(); - return Ok(value.into_uint().into()) + let value = acc + .storage + .get(&H256::from_uint(&ru256_to_u256(index))) + .copied() + .unwrap_or_default(); + return Ok(u256_to_ru256(value.into_uint())) } self.db.storage(address, index) } diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 593fae025a7e5..bb6b4e1bd91f4 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -13,6 +13,7 @@ use foundry_evm::{ fork::database::ForkDbSnapshot, }, revm::Database, + utils::{b160_to_h160, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256}, }; /// Implement the helper for the fork database @@ -23,12 +24,12 @@ impl Db for ForkedDatabase { fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { // this ensures the account is loaded first - let _ = Database::basic(self, address.into())?; + let _ = Database::basic(self, h160_to_b160(address))?; self.database_mut().set_storage_at(address, slot, val) } fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.inner().block_hashes().write().insert(number.into(), hash.into()); + self.inner().block_hashes().write().insert(u256_to_ru256(number), h256_to_b256(hash)); } fn dump_state(&self) -> DatabaseResult> { @@ -46,15 +47,15 @@ impl Db for ForkedDatabase { } .to_checked(); Ok(( - k.into(), + b160_to_h160(k), SerializableAccountRecord { nonce: v.info.nonce, - balance: v.info.balance.into(), + balance: ru256_to_u256(v.info.balance), code: code.bytes()[..code.len()].to_vec().into(), storage: v .storage .into_iter() - .map(|kv| (kv.0.into(), kv.1.into())) + .map(|kv| (ru256_to_u256(kv.0), ru256_to_u256(kv.1))) .collect(), }, )) @@ -64,11 +65,11 @@ impl Db for ForkedDatabase { } fn snapshot(&mut self) -> U256 { - self.insert_snapshot() + ru256_to_u256(self.insert_snapshot()) } fn revert(&mut self, id: U256) -> bool { - self.revert_snapshot(id) + self.revert_snapshot(u256_to_ru256(id)) } fn current_state(&self) -> StateDb { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 18b0c83690ef7..23733f168a38e 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -9,7 +9,7 @@ use crate::{ Address, U256, }; use ethers::prelude::H256; -use foundry_evm::utils::h160_to_b160; +use foundry_evm::utils::{b160_to_h160, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256}; use tracing::{trace, warn}; // reexport for convenience @@ -19,15 +19,19 @@ pub use foundry_evm::executor::{backend::MemDb, DatabaseRef}; impl Db for MemDb { fn insert_account(&mut self, address: Address, account: AccountInfo) { - self.inner.insert_account_info(address.into(), account) + self.inner.insert_account_info(h160_to_b160(address), account) } fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.inner.insert_account_storage(address.into(), slot.into(), val.into()) + self.inner.insert_account_storage( + h160_to_b160(address), + u256_to_ru256(slot), + u256_to_ru256(val), + ) } fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.inner.block_hashes.insert(number.into(), hash.into()); + self.inner.block_hashes.insert(u256_to_ru256(number), h256_to_b256(hash)); } fn dump_state(&self) -> DatabaseResult> { @@ -44,12 +48,16 @@ impl Db for MemDb { } .to_checked(); Ok(( - k.into(), + b160_to_h160(k), SerializableAccountRecord { nonce: v.info.nonce, - balance: v.info.balance.into(), + balance: ru256_to_u256(v.info.balance), code: code.bytes()[..code.len()].to_vec().into(), - storage: v.storage.into_iter().map(|k| (k.0.into(), k.1.into())).collect(), + storage: v + .storage + .into_iter() + .map(|k| (ru256_to_u256(k.0), ru256_to_u256(k.1))) + .collect(), }, )) }) @@ -62,11 +70,11 @@ impl Db for MemDb { fn snapshot(&mut self) -> U256 { let id = self.snapshots.insert(self.inner.clone()); trace!(target: "backend::memdb", "Created new snapshot {}", id); - id + ru256_to_u256(id) } fn revert(&mut self, id: U256) -> bool { - if let Some(snapshot) = self.snapshots.remove(id) { + if let Some(snapshot) = self.snapshots.remove(u256_to_ru256(id)) { self.inner = snapshot; trace!(target: "backend::memdb", "Reverted snapshot {}", id); true @@ -118,11 +126,13 @@ mod tests { revm::primitives::AccountInfo, Address, }; + use alloy_primitives::U256 as rU256; use bytes::Bytes; use ethers::types::U256; use foundry_evm::{ executor::{backend::MemDb, DatabaseRef}, - revm::primitives::{Bytecode, KECCAK_EMPTY, U256 as rU256}, + revm::primitives::{Bytecode, KECCAK_EMPTY}, + utils::h160_to_b160, }; use std::{collections::BTreeMap, str::FromStr}; @@ -136,7 +146,8 @@ mod tests { let mut dump_db = MemDb::default(); let contract_code: Bytecode = - Bytecode::new_raw(Bytes::from("fake contract code")).to_checked(); + Bytecode::new_raw(alloy_primitives::Bytes(Bytes::from("fake contract code"))) + .to_checked(); dump_db.insert_account( test_addr, @@ -148,7 +159,7 @@ mod tests { }, ); - dump_db.set_storage_at(test_addr, "0x1234567".into(), "0x1".into()).unwrap(); + dump_db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); let state = dump_db.dump_state().unwrap().unwrap(); @@ -156,14 +167,14 @@ mod tests { load_db.load_state(state).unwrap(); - let loaded_account = load_db.basic(test_addr.into()).unwrap().unwrap(); + let loaded_account = load_db.basic(h160_to_b160(test_addr)).unwrap().unwrap(); assert_eq!(loaded_account.balance, rU256::from(123456)); assert_eq!(load_db.code_by_hash(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); assert_eq!( - load_db.storage(test_addr.into(), Into::::into("0x1234567").into()).unwrap(), - Into::::into("0x1").into() + load_db.storage(h160_to_b160(test_addr), rU256::from(1234567)).unwrap(), + rU256::from(1) ); } @@ -177,7 +188,8 @@ mod tests { Address::from_str("0x70997970c51812dc3a010c7d01b50e0d17dc79c8").unwrap(); let contract_code: Bytecode = - Bytecode::new_raw(Bytes::from("fake contract code")).to_checked(); + Bytecode::new_raw(alloy_primitives::Bytes(Bytes::from("fake contract code"))) + .to_checked(); let mut db = MemDb::default(); @@ -191,8 +203,8 @@ mod tests { }, ); - db.set_storage_at(test_addr, "0x1234567".into(), "0x1".into()).unwrap(); - db.set_storage_at(test_addr, "0x1234568".into(), "0x2".into()).unwrap(); + db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); + db.set_storage_at(test_addr, U256::from(1234568), U256::from(2)).unwrap(); let mut new_state = SerializableState::default(); @@ -207,7 +219,7 @@ mod tests { ); let mut new_storage = BTreeMap::default(); - new_storage.insert("0x1234568".into(), "0x5".into()); + new_storage.insert(U256::from(1234568), U256::from(5)); new_state.accounts.insert( test_addr, @@ -221,8 +233,8 @@ mod tests { db.load_state(new_state).unwrap(); - let loaded_account = db.basic(test_addr.into()).unwrap().unwrap(); - let loaded_account2 = db.basic(test_addr2.into()).unwrap().unwrap(); + let loaded_account = db.basic(h160_to_b160(test_addr)).unwrap().unwrap(); + let loaded_account2 = db.basic(h160_to_b160(test_addr2)).unwrap().unwrap(); assert_eq!(loaded_account2.nonce, 1); @@ -230,12 +242,12 @@ mod tests { assert_eq!(db.code_by_hash(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); assert_eq!( - db.storage(test_addr.into(), Into::::into("0x1234567").into()).unwrap(), - Into::::into("0x1").into() + db.storage(h160_to_b160(test_addr), rU256::from(1234567)).unwrap(), + rU256::from(1) ); assert_eq!( - db.storage(test_addr.into(), Into::::into("0x1234568").into()).unwrap(), - Into::::into("0x5").into() + db.storage(h160_to_b160(test_addr), rU256::from(1234568)).unwrap(), + rU256::from(5) ); } } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 9ca7686c618b5..2f83ee97a116f 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -1,7 +1,6 @@ //! Anvil specific [`revm::Inspector`] implementation use crate::{eth::macros::node_info, revm::Database}; -use bytes::Bytes; use ethers::types::Log; use foundry_evm::{ call_inspectors, @@ -10,7 +9,7 @@ use foundry_evm::{ revm, revm::{ interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, - primitives::{B160, B256}, + primitives::{Address as rAddress, Bytes, B256}, EVMData, }, }; @@ -72,7 +71,7 @@ impl revm::Inspector for Inspector { fn log( &mut self, evm_data: &mut EVMData<'_, DB>, - address: &B160, + address: &rAddress, topics: &[B256], data: &Bytes, ) { @@ -127,7 +126,7 @@ impl revm::Inspector for Inspector { &mut self, data: &mut EVMData<'_, DB>, call: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option, Gas, Bytes) { call_inspectors!([&mut self.tracer], |inspector| { inspector.create(data, call); }); @@ -141,10 +140,10 @@ impl revm::Inspector for Inspector { data: &mut EVMData<'_, DB>, inputs: &CreateInputs, status: InstructionResult, - address: Option, + address: Option, gas: Gas, retdata: Bytes, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option, Gas, Bytes) { call_inspectors!([&mut self.tracer], |inspector| { inspector.create_end(data, inputs, status, address, gas, retdata.clone()); }); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index b443ea2e365d0..ec0f7a3a64c66 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -72,8 +72,8 @@ use foundry_evm::{ }, }, utils::{ - eval_to_instruction_result, h256_to_b256, halt_to_instruction_result, ru256_to_u256, - u256_to_h256_be, u256_to_ru256, + b160_to_h160, eval_to_instruction_result, h160_to_b160, h256_to_b256, + halt_to_instruction_result, ru256_to_u256, u256_to_h256_be, u256_to_ru256, }, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; @@ -264,7 +264,7 @@ impl Backend { // accounts concurrently by spawning the job to a new task genesis_accounts_futures.push(tokio::task::spawn(async move { let db = db.read().await; - let info = db.basic(address.into())?.unwrap_or_default(); + let info = db.basic(h160_to_b160(address))?.unwrap_or_default(); Ok::<_, DatabaseError>((address, info)) })); } @@ -338,7 +338,7 @@ impl Backend { /// Returns the `AccountInfo` from the database pub async fn get_account(&self, address: Address) -> DatabaseResult { - Ok(self.db.read().await.basic(address.into())?.unwrap_or_default()) + Ok(self.db.read().await.basic(h160_to_b160(address))?.unwrap_or_default()) } /// Whether we're forked off some remote client @@ -369,9 +369,9 @@ impl Backend { env.block = BlockEnv { number: rU256::from(fork_block_number), - timestamp: fork_block.timestamp.into(), - gas_limit: fork_block.gas_limit.into(), - difficulty: fork_block.difficulty.into(), + timestamp: u256_to_ru256(fork_block.timestamp), + gas_limit: u256_to_ru256(fork_block.gas_limit), + difficulty: u256_to_ru256(fork_block.difficulty), prevrandao: fork_block.mix_hash.map(h256_to_b256), // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, @@ -379,7 +379,7 @@ impl Backend { }; self.time.reset(ru256_to_u256(env.block.timestamp).as_u64()); - self.fees.set_base_fee(env.block.basefee.into()); + self.fees.set_base_fee(ru256_to_u256(env.block.basefee)); // also reset the total difficulty self.blockchain.storage.write().total_difficulty = fork.total_difficulty(); @@ -450,12 +450,12 @@ impl Backend { /// Sets the block number pub fn set_block_number(&self, number: U256) { let mut env = self.env.write(); - env.block.number = number.into(); + env.block.number = u256_to_ru256(number); } /// Returns the client coinbase address. pub fn coinbase(&self) -> Address { - self.env.read().block.coinbase.into() + b160_to_h160(self.env.read().block.coinbase) } /// Returns the client coinbase address. @@ -465,7 +465,7 @@ impl Backend { /// Returns balance of the given account. pub async fn current_balance(&self, address: Address) -> DatabaseResult { - Ok(self.get_account(address).await?.balance.into()) + Ok(self.get_account(address).await?.balance).map(ru256_to_u256) } /// Returns balance of the given account. @@ -475,7 +475,7 @@ impl Backend { /// Sets the coinbase address pub fn set_coinbase(&self, address: Address) { - self.env.write().block.coinbase = address.into(); + self.env.write().block.coinbase = h160_to_b160(address); } /// Sets the nonce of the given address @@ -541,12 +541,12 @@ impl Backend { /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { - self.env.read().block.gas_limit.into() + ru256_to_u256(self.env.read().block.gas_limit) } /// Sets the block gas limit pub fn set_gas_limit(&self, gas_limit: U256) { - self.env.write().block.gas_limit = gas_limit.into(); + self.env.write().block.gas_limit = u256_to_ru256(gas_limit); } /// Returns the current base fee @@ -685,7 +685,7 @@ impl Backend { let mut env = self.env.read().clone(); // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = self.base_fee().into(); + env.block.basefee = u256_to_ru256(self.base_fee()); env.block.timestamp = rU256::from(self.time.current_call_timestamp()); env } @@ -712,7 +712,7 @@ impl Backend { }; let state = result_and_state.state; let state: revm::primitives::HashMap = - state.into_iter().map(|kv| (kv.0.into(), kv.1)).collect(); + state.into_iter().map(|kv| (b160_to_h160(kv.0), kv.1)).collect(); let (exit_reason, gas_used, out, logs) = match result_and_state.result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { (eval_to_instruction_result(reason), gas_used, Some(output), Some(logs)) @@ -801,7 +801,7 @@ impl Backend { // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = current_base_fee.into(); + env.block.basefee = u256_to_ru256(current_base_fee); env.block.timestamp = rU256::from(self.time.next_timestamp()); let best_hash = self.blockchain.storage.read().best_hash; @@ -1007,7 +1007,7 @@ impl Backend { let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = fee_details; - let gas_limit = gas.unwrap_or(block_env.gas_limit.into()); + let gas_limit = gas.unwrap_or(ru256_to_u256(block_env.gas_limit)); let mut env = self.env.read().clone(); env.block = block_env; // we want to disable this in eth_call, since this is common practice used by other node @@ -1015,22 +1015,22 @@ impl Backend { env.cfg.disable_block_gas_limit = true; if let Some(base) = max_fee_per_gas { - env.block.basefee = base.into(); + env.block.basefee = u256_to_ru256(base); } let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); let caller = from.unwrap_or_default(); env.tx = TxEnv { - caller: caller.into(), + caller: h160_to_b160(caller), gas_limit: gas_limit.as_u64(), - gas_price: gas_price.into(), + gas_price: u256_to_ru256(gas_price), gas_priority_fee: max_priority_fee_per_gas.map(u256_to_ru256), transact_to: match to { - Some(addr) => TransactTo::Call(addr.into()), + Some(addr) => TransactTo::Call(h160_to_b160(addr)), None => TransactTo::Create(CreateScheme::Create), }, - value: value.unwrap_or_default().into(), + value: value.map(u256_to_ru256).unwrap_or_default(), data: data.unwrap_or_default().to_vec().into(), chain_id: None, nonce: nonce.map(|n| n.as_u64()), @@ -1072,7 +1072,7 @@ impl Backend { }; let state = result_and_state.state; let state: revm::primitives::HashMap = - state.into_iter().map(|kv| (kv.0.into(), kv.1)).collect(); + state.into_iter().map(|kv| (b160_to_h160(kv.0), kv.1)).collect(); let (exit_reason, gas_used, out) = match result_and_state.result { ExecutionResult::Success { reason, gas_used, output, .. } => { (eval_to_instruction_result(reason), gas_used, Some(output)) @@ -1138,15 +1138,15 @@ impl Backend { let to = if let Some(to) = request.to { to } else { - let nonce = state.basic(from.into())?.unwrap_or_default().nonce; + let nonce = state.basic(h160_to_b160(from))?.unwrap_or_default().nonce; get_contract_address(from, nonce) }; let mut tracer = AccessListTracer::new( AccessList(request.access_list.clone().unwrap_or_default()), - from, - to, - self.precompiles(), + h160_to_b160(from), + h160_to_b160(to), + self.precompiles().into_iter().map(h160_to_b160).collect(), ); let mut evm = revm::EVM::new(); @@ -1585,13 +1585,15 @@ impl Backend { .with_pending_block(pool_transactions, |state, block| { let block = block.block; let block = BlockEnv { - number: block.header.number.into(), - coinbase: block.header.beneficiary.into(), + number: u256_to_ru256(block.header.number), + coinbase: h160_to_b160(block.header.beneficiary), timestamp: rU256::from(block.header.timestamp), - difficulty: block.header.difficulty.into(), - prevrandao: Some(block.header.mix_hash.into()), - basefee: block.header.base_fee_per_gas.unwrap_or_default().into(), - gas_limit: block.header.gas_limit.into(), + difficulty: u256_to_ru256(block.header.difficulty), + prevrandao: Some(block.header.mix_hash).map(h256_to_b256), + basefee: u256_to_ru256( + block.header.base_fee_per_gas.unwrap_or_default(), + ), + gas_limit: u256_to_ru256(block.header.gas_limit), }; f(state, block) }) @@ -1603,7 +1605,7 @@ impl Backend { }; let block_number: U256 = self.convert_block_number(block_number).into(); - if block_number < self.env.read().block.number.into() { + if u256_to_ru256(block_number) < self.env.read().block.number { { let mut states = self.states.write(); @@ -1612,13 +1614,13 @@ impl Backend { .and_then(|block| Some((states.get(&block.header.hash())?, block))) { let block = BlockEnv { - number: block.header.number.into(), - coinbase: block.header.beneficiary.into(), + number: u256_to_ru256(block.header.number), + coinbase: h160_to_b160(block.header.beneficiary), timestamp: rU256::from(block.header.timestamp), - difficulty: block.header.difficulty.into(), - prevrandao: Some(block.header.mix_hash).map(Into::into), - basefee: block.header.base_fee_per_gas.unwrap_or_default().into(), - gas_limit: block.header.gas_limit.into(), + difficulty: u256_to_ru256(block.header.difficulty), + prevrandao: Some(block.header.mix_hash).map(h256_to_b256), + basefee: u256_to_ru256(block.header.base_fee_per_gas.unwrap_or_default()), + gas_limit: u256_to_ru256(block.header.gas_limit), }; return Ok(f(Box::new(state), block)) } @@ -1635,9 +1637,9 @@ impl Backend { let db = self.db.read().await; let gen_db = self.genesis.state_db_at_genesis(Box::new(&*db)); - block.number = block_number.into(); + block.number = u256_to_ru256(block_number); block.timestamp = rU256::from(fork.timestamp()); - block.basefee = fork.base_fee().unwrap_or_default().into(); + block.basefee = u256_to_ru256(fork.base_fee().unwrap_or_default()); return Ok(f(Box::new(&gen_db), block)) } @@ -1663,7 +1665,7 @@ impl Backend { ) -> Result { self.with_database_at(block_request, |db, _| { trace!(target: "backend", "get storage for {:?} at {:?}", address, index); - let val = db.storage(address.into(), index.into())?; + let val = db.storage(h160_to_b160(address), u256_to_ru256(index))?; Ok(u256_to_h256_be(ru256_to_u256(val))) }) .await? @@ -1690,7 +1692,7 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get code for {:?}", address); - let account = state.basic(address.into())?.unwrap_or_default(); + let account = state.basic(h160_to_b160(address))?.unwrap_or_default(); if account.code_hash == KECCAK_EMPTY { // if the code hash is `KECCAK_EMPTY`, we check no further return Ok(Default::default()) @@ -1724,7 +1726,7 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get balance for {:?}", address); - Ok(state.basic(address.into())?.unwrap_or_default().balance.into()) + Ok(state.basic(h160_to_b160(address))?.unwrap_or_default().balance).map(ru256_to_u256) } /// Returns the nonce of the address @@ -1747,7 +1749,7 @@ impl Backend { }; self.with_database_at(final_block_request, |db, _| { trace!(target: "backend", "get nonce for {:?}", address); - Ok(db.basic(address.into())?.unwrap_or_default().nonce.into()) + Ok(db.basic(h160_to_b160(address))?.unwrap_or_default().nonce.into()) }) .await? } @@ -2189,7 +2191,7 @@ impl TransactionValidator for Backend { } // Check gas limit, iff block gas limit is set. - if !env.cfg.disable_block_gas_limit && tx.gas_limit() > env.block.gas_limit.into() { + if !env.cfg.disable_block_gas_limit && tx.gas_limit() > ru256_to_u256(env.block.gas_limit) { warn!(target: "backend", "[{:?}] gas too high", tx.hash()); return Err(InvalidTransactionError::GasTooHigh(ErrDetail { detail: String::from("tx.gas_limit > env.block.gas_limit"), @@ -2205,7 +2207,7 @@ impl TransactionValidator for Backend { } if (env.cfg.spec_id as u8) >= (SpecId::LONDON as u8) { - if tx.gas_price() < env.block.basefee.into() { + if tx.gas_price() < ru256_to_u256(env.block.basefee) { warn!(target: "backend", "max fee per gas={}, too low, block basefee={}",tx.gas_price(), env.block.basefee); return Err(InvalidTransactionError::FeeCapTooLow) } @@ -2229,7 +2231,7 @@ impl TransactionValidator for Backend { InvalidTransactionError::InsufficientFunds })?; - if account.balance < req_funds.into() { + if account.balance < u256_to_ru256(req_funds) { warn!(target: "backend", "[{:?}] insufficient allowance={}, required={} account={:?}", tx.hash(), account.balance, req_funds, *pending.sender()); return Err(InvalidTransactionError::InsufficientFunds) } diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index b36f8bf8df923..ad90b6bddb192 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -1,6 +1,7 @@ //! Support for generating the state root for memdb storage use crate::eth::{backend::db::AsHashDB, error::BlockchainError}; +use alloy_primitives::{Address as rAddress, U256 as rU256}; use anvil_core::eth::{state::StateOverride, trie::RefSecTrieDBMut}; use bytes::Bytes; use ethers::{ @@ -12,9 +13,9 @@ use foundry_evm::{ executor::{backend::DatabaseError, DatabaseRef}, revm::{ db::{CacheDB, DbAccount}, - primitives::{AccountInfo, Bytecode, Log, B160, U256 as rU256}, + primitives::{AccountInfo, Bytecode, Log}, }, - utils::{b160_to_h160, b256_to_h256, ru256_to_u256, u256_to_ru256}, + utils::{b160_to_h160, b256_to_h256, h160_to_b160, ru256_to_u256, u256_to_ru256}, HashMap as Map, }; use memory_db::HashKey; @@ -31,7 +32,7 @@ pub fn log_rlp_hash(logs: Vec) -> H256 { stream.begin_list(3); stream.append(&b160_to_h160(log.address)); stream.append_list(&topics); - stream.append(&log.data); + stream.append(&log.data.0); } stream.finalize_unbounded_list(); let out = stream.out().freeze(); @@ -52,7 +53,7 @@ pub fn storage_trie_db(storage: &Map) -> (AsHashDB, H256) { let mut temp: [u8; 32] = [0; 32]; ru256_to_u256(*k).to_big_endian(&mut temp); let key = H256::from(temp); - let value = rlp::encode(v); + let value = rlp::encode(&ru256_to_u256(*v)); trie.insert(key.as_bytes(), value.as_ref()).unwrap(); } } @@ -63,7 +64,7 @@ pub fn storage_trie_db(storage: &Map) -> (AsHashDB, H256) { } /// Returns the account data as `HashDB` -pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { +pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { let accounts = trie_accounts(accounts); // Populate DB with full trie from entries. @@ -83,7 +84,7 @@ pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { } /// Returns all RLP-encoded Accounts -pub fn trie_accounts(accounts: &Map) -> Vec<(B160, Bytes)> { +pub fn trie_accounts(accounts: &Map) -> Vec<(rAddress, Bytes)> { accounts .iter() .map(|(address, account)| { @@ -93,7 +94,7 @@ pub fn trie_accounts(accounts: &Map) -> Vec<(B160, Bytes)> { .collect() } -pub fn state_merkle_trie_root(accounts: &Map) -> H256 { +pub fn state_merkle_trie_root(accounts: &Map) -> H256 { trie_hash_db(accounts).1 } @@ -101,9 +102,9 @@ pub fn state_merkle_trie_root(accounts: &Map) -> H256 { pub fn trie_account_rlp(info: &AccountInfo, storage: &Map) -> Bytes { let mut stream = RlpStream::new_list(4); stream.append(&info.nonce); - stream.append(&info.balance); + stream.append(&ru256_to_u256(info.balance)); stream.append(&storage_trie_db(storage).1); - stream.append(&info.code_hash.as_bytes()); + stream.append(&info.code_hash.as_slice()); stream.out().freeze() } @@ -117,7 +118,7 @@ where { let mut cache_db = CacheDB::new(state); for (account, account_overrides) in overrides.iter() { - let mut account_info = cache_db.basic((*account).into())?.unwrap_or_default(); + let mut account_info = cache_db.basic(h160_to_b160(*account))?.unwrap_or_default(); if let Some(nonce) = account_overrides.nonce { account_info.nonce = nonce; @@ -126,10 +127,10 @@ where account_info.code = Some(Bytecode::new_raw(code.to_vec().into())); } if let Some(balance) = account_overrides.balance { - account_info.balance = balance.into(); + account_info.balance = u256_to_ru256(balance); } - cache_db.insert_account_info((*account).into(), account_info); + cache_db.insert_account_info(h160_to_b160(*account), account_info); // We ensure that not both state and state_diff are set. // If state is set, we must mark the account as "NewlyCreated", so that the old storage @@ -143,7 +144,7 @@ where (None, None) => (), (Some(new_account_state), None) => { cache_db.replace_account_storage( - (*account).into(), + h160_to_b160(*account), new_account_state .iter() .map(|(key, value)| { @@ -155,9 +156,9 @@ where (None, Some(account_state_diff)) => { for (key, value) in account_state_diff.iter() { cache_db.insert_account_storage( - (*account).into(), - key.into_uint().into(), - value.into_uint().into(), + h160_to_b160(*account), + u256_to_ru256(key.into_uint()), + u256_to_ru256(value.into_uint()), )?; } } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 17f65910c8144..bbd379c30fe50 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -15,7 +15,10 @@ use ethers::{ prelude::{BlockId, BlockNumber, DefaultFrame, Trace, H256, H256 as TxHash, U64}, types::{ActionType, Bytes, GethDebugTracingOptions, TransactionReceipt, U256}, }; -use foundry_evm::revm::{interpreter::InstructionResult, primitives::Env}; +use foundry_evm::{ + revm::{interpreter::InstructionResult, primitives::Env}, + utils::{b160_to_h160, ru256_to_u256}, +}; use parking_lot::RwLock; use std::{ collections::{HashMap, VecDeque}, @@ -226,9 +229,9 @@ impl BlockchainStorage { let partial_header = PartialHeader { timestamp, base_fee, - gas_limit: env.block.gas_limit.into(), - beneficiary: env.block.coinbase.into(), - difficulty: env.block.difficulty.into(), + gas_limit: ru256_to_u256(env.block.gas_limit), + beneficiary: b160_to_h160(env.block.coinbase), + difficulty: ru256_to_u256(env.block.difficulty), ..Default::default() }; let block = Block::new::(partial_header, vec![], vec![]); @@ -429,6 +432,7 @@ mod tests { db::DatabaseRef, primitives::{AccountInfo, U256 as rU256}, }, + utils::h160_to_b160, }; #[test] @@ -459,7 +463,7 @@ mod tests { let loaded = storage.get(&one).unwrap(); - let acc = loaded.basic(addr.into()).unwrap().unwrap(); + let acc = loaded.basic(h160_to_b160(addr)).unwrap().unwrap(); assert_eq!(acc.balance, rU256::from(1337u64)); } @@ -489,7 +493,7 @@ mod tests { let hash = H256::from_uint(&U256::from(idx)); let addr = Address::from(hash); let loaded = storage.get(&hash).unwrap(); - let acc = loaded.basic(addr.into()).unwrap().unwrap(); + let acc = loaded.basic(h160_to_b160(addr)).unwrap().unwrap(); let balance = (idx * 2) as u64; assert_eq!(acc.balance, rU256::from(balance)); } diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 093ab0ddb0d50..52deb5b27b0a0 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -7,7 +7,7 @@ use ethers::{ use foundry_common::errors::FsPathError; use foundry_evm::{ revm::primitives::{Bytecode, Env, KECCAK_EMPTY, U256 as rU256}, - utils::h160_to_b160, + utils::{h160_to_b160, u256_to_ru256}, }; use serde::{Deserialize, Serialize}; use std::{ @@ -92,7 +92,7 @@ impl Genesis { env.block.timestamp = rU256::from(timestamp); } if let Some(base_fee) = self.base_fee_per_gas { - env.block.basefee = base_fee.into(); + env.block.basefee = u256_to_ru256(base_fee); } if let Some(number) = self.number { env.block.number = rU256::from(number); @@ -144,7 +144,7 @@ impl From for AccountInfo { let GenesisAccount { code, balance, nonce, .. } = acc; let code = code.map(|code| Bytecode::new_raw(code.to_vec().into())); AccountInfo { - balance: balance.into(), + balance: u256_to_ru256(balance), nonce: nonce.unwrap_or_default(), code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), code, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index c539445be2b6d..2ea81e2519d1b 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -15,7 +15,7 @@ use ethers::{ }; use foundry_common::get_http_provider; use foundry_config::Config; -use foundry_evm::utils::h160_to_b160; +use foundry_evm::utils::{h160_to_b160, u256_to_ru256}; use foundry_utils::{rpc, rpc::next_http_rpc_endpoint}; use futures::StreamExt; use std::{sync::Arc, time::Duration}; @@ -280,7 +280,7 @@ async fn test_separate_states() { let fork_db = fork.database.read().await; let acc = fork_db.inner().db().accounts.read().get(&h160_to_b160(addr)).cloned().unwrap(); - assert_eq!(acc.balance, remote_balance.into()) + assert_eq!(acc.balance, u256_to_ru256(remote_balance)) } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs index c82de8a2f5d8f..e56e8169ba8af 100644 --- a/crates/anvil/tests/it/proof/mod.rs +++ b/crates/anvil/tests/it/proof/mod.rs @@ -11,7 +11,7 @@ use anvil_core::eth::proof::{AccountProof, BasicAccount}; use crate::proof::eip1186::verify_proof; use anvil_core::eth::trie::ExtensionLayout; use ethers::utils::{keccak256, rlp}; -use foundry_evm::revm::primitives::KECCAK_EMPTY; +use foundry_evm::{revm::primitives::KECCAK_EMPTY, utils::b256_to_h256}; mod eip1186; @@ -32,7 +32,7 @@ async fn can_get_proof() { nonce: 0.into(), balance: 0.into(), storage_root: proof.storage_hash, - code_hash: KECCAK_EMPTY.into(), + code_hash: b256_to_h256(KECCAK_EMPTY), }; let rlp_account = rlp::encode(&account); diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index ec89196590131..08e759610be68 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -11,7 +11,11 @@ use foundry_cli::{ }; use foundry_common::runtime_client::RuntimeClient; use foundry_config::{find_project_root_path, Config}; -use foundry_evm::{executor::opts::EvmOpts, trace::TracingExecutor}; +use foundry_evm::{ + executor::opts::EvmOpts, + trace::TracingExecutor, + utils::{h160_to_b160, u256_to_ru256}, +}; use std::str::FromStr; type Provider = ethers::providers::Provider; @@ -155,9 +159,9 @@ impl CallArgs { .await; let trace = match executor.deploy( - sender, - code.into(), - value.unwrap_or(U256::zero()), + h160_to_b160(sender), + code.into_bytes().into(), + u256_to_ru256(value.unwrap_or(U256::zero())), None, ) { Ok(deploy_result) => TraceResult::from(deploy_result), @@ -192,10 +196,10 @@ impl CallArgs { let (tx, _) = builder.build(); let trace = TraceResult::from(executor.call_raw_committing( - sender, - tx.to_addr().copied().expect("an address to be here"), + h160_to_b160(sender), + h160_to_b160(tx.to_addr().copied().expect("an address to be here")), tx.data().cloned().unwrap_or_default().to_vec().into(), - tx.value().copied().unwrap_or_default(), + u256_to_ru256(tx.value().copied().unwrap_or_default()), )?); handle_traces(trace, &config, chain, labels, verbose, debug).await?; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 902271adf76bf..919195337b25a 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -12,7 +12,7 @@ use foundry_evm::{ executor::{inspector::cheatcodes::util::configure_tx_env, opts::EvmOpts, EvmError}, revm::primitives::U256 as rU256, trace::TracingExecutor, - utils::h256_to_b256, + utils::{h160_to_b160, h256_to_b256, u256_to_ru256}, }; use tracing::trace; @@ -117,12 +117,12 @@ impl RunArgs { let block = provider.get_block_with_txs(tx_block_number).await?; if let Some(ref block) = block { - env.block.timestamp = block.timestamp.into(); - env.block.coinbase = block.author.unwrap_or_default().into(); - env.block.difficulty = block.difficulty.into(); + env.block.timestamp = u256_to_ru256(block.timestamp); + env.block.coinbase = h160_to_b160(block.author.unwrap_or_default()); + env.block.difficulty = u256_to_ru256(block.difficulty); env.block.prevrandao = block.mix_hash.map(h256_to_b256); - env.block.basefee = block.base_fee_per_gas.unwrap_or_default().into(); - env.block.gas_limit = block.gas_limit.into(); + env.block.basefee = u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()); + env.block.gas_limit = u256_to_ru256(block.gas_limit); } // Set the state to the moment right before the transaction diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index e03a76e11e721..72b888b4e984c 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -10,7 +10,9 @@ use ethers::{ use eyre::Result; use foundry_evm::{ executor::{DeployResult, Executor, RawCallResult}, + revm::primitives::U256 as rU256, trace::{CallTraceArena, TraceKind}, + utils::{b160_to_h160, h160_to_b160, u256_to_ru256}, }; use revm::interpreter::{return_ok, InstructionResult}; use std::collections::BTreeMap; @@ -92,17 +94,18 @@ impl ChiselRunner { /// contract. pub fn run(&mut self, bytecode: Bytes) -> Result<(Address, ChiselResult)> { // Set the sender's balance to [U256::MAX] for deployment of the REPL contract. - self.executor.set_balance(self.sender, U256::MAX)?; + self.executor.set_balance(h160_to_b160(self.sender), rU256::MAX)?; // Deploy an instance of the REPL contract // We don't care about deployment traces / logs here let DeployResult { address, .. } = self .executor - .deploy(self.sender, bytecode.0, 0.into(), None) + .deploy(h160_to_b160(self.sender), bytecode.0.into(), rU256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy REPL contract:\n{}", err))?; // Reset the sender's balance to the initial balance for calls. - self.executor.set_balance(self.sender, self.initial_balance)?; + self.executor + .set_balance(h160_to_b160(self.sender), u256_to_ru256(self.initial_balance))?; // Append the input to the `RUN_SELECTOR` to form the calldata let mut calldata = RUN_SELECTOR.to_vec(); @@ -111,9 +114,10 @@ impl ChiselRunner { } // Call the "run()" function of the REPL contract - let call_res = self.call(self.sender, address, Bytes::from(calldata), 0.into(), true); + let call_res = + self.call(self.sender, b160_to_h160(address), Bytes::from(calldata), 0.into(), true); - call_res.map(|res| (address, res)) + call_res.map(|res| (b160_to_h160(address), res)) } /// Executes the call @@ -140,7 +144,12 @@ impl ChiselRunner { false }; - let mut res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; + let mut res = self.executor.call_raw( + h160_to_b160(from), + h160_to_b160(to), + calldata.0.clone().into(), + u256_to_ru256(value), + )?; let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { // store the current gas limit and reset it later @@ -156,7 +165,12 @@ impl ChiselRunner { while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; self.executor.env.tx.gas_limit = mid_gas_limit; - let res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; + let res = self.executor.call_raw( + h160_to_b160(from), + h160_to_b160(to), + calldata.0.clone().into(), + u256_to_ru256(value), + )?; match res.exit_reason { InstructionResult::Revert | InstructionResult::OutOfGas | @@ -191,18 +205,28 @@ impl ChiselRunner { cheatcodes.fs_commit = !cheatcodes.fs_commit; } - res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; + res = self.executor.call_raw( + h160_to_b160(from), + h160_to_b160(to), + calldata.0.clone().into(), + u256_to_ru256(value), + )?; } if commit { // if explicitly requested we can now commit the call - res = self.executor.call_raw_committing(from, to, calldata.0, value)?; + res = self.executor.call_raw_committing( + h160_to_b160(from), + h160_to_b160(to), + calldata.0.clone().into(), + u256_to_ru256(value), + )?; } let RawCallResult { result, reverted, logs, traces, labels, chisel_state, .. } = res; Ok(ChiselResult { - returned: result, + returned: result.0, success: !reverted, gas_used, logs, @@ -214,7 +238,7 @@ impl ChiselRunner { vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), - labeled_addresses: labels, + labeled_addresses: labels.into_iter().map(|l| (b160_to_h160(l.0), l.1)).collect(), address: None, state: chisel_state, }) diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index 55ddcbd92a29e..16587c7616699 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,6 +1,6 @@ use crate::Ui; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder}; +use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder, utils::b160_to_h160}; use tracing::trace; use crate::{TUIExitReason, Tui}; @@ -35,7 +35,7 @@ impl DebuggerArgs<'_> { .collect(); let tui = Tui::new( - flattened, + flattened.into_iter().map(|i| (b160_to_h160(i.0), i.1, i.2)).collect(), 0, identified_contracts, self.sources.clone(), diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 7b25d2aa0d0b2..680b7af484219 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -875,7 +875,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let min_len = format!("{:x}", max_i * 32).len(); // color memory words based on write/read - let mut word = None; + let mut word: Option = None; let mut color = None; if let Instruction::OpCode(op) = debug_steps[current_step].instruction { let stack_len = debug_steps[current_step].stack.len(); @@ -883,11 +883,11 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let w = debug_steps[current_step].stack[stack_len - 1]; match op { opcode::MLOAD => { - word = Some(w.as_usize()); + word = Some(w.to()); color = Some(Color::Cyan); } opcode::MSTORE => { - word = Some(w.as_usize()); + word = Some(w.to()); color = Some(Color::Red); } _ => {} @@ -902,7 +902,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k if let Instruction::OpCode(op) = debug_steps[prev_step].instruction { if op == opcode::MSTORE { let prev_top = debug_steps[prev_step].stack[stack_len - 1]; - word = Some(prev_top.as_usize()); + word = Some(prev_top.to()); color = Some(Color::Green); } } diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 257d849e3010f..a12497faa0481 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -49,6 +49,8 @@ revm = { workspace = true, default-features = false, features = [ "optional_no_base_fee", ] } +alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde", "getrandom"] } + # Fuzzer proptest = "1" diff --git a/crates/evm/src/debug.rs b/crates/evm/src/debug.rs index c229dbca90b3e..6fa9c00dafe23 100644 --- a/crates/evm/src/debug.rs +++ b/crates/evm/src/debug.rs @@ -1,5 +1,5 @@ use crate::{abi::HEVM_ABI, CallKind}; -use ethers::types::{Address, U256}; +use alloy_primitives::{Address, U256}; use revm::interpreter::{Memory, OpCode}; use serde::{Deserialize, Serialize}; use std::fmt::Display; diff --git a/crates/evm/src/executor/abi/mod.rs b/crates/evm/src/executor/abi/mod.rs index 276fd27d917da..273c13502dc46 100644 --- a/crates/evm/src/executor/abi/mod.rs +++ b/crates/evm/src/executor/abi/mod.rs @@ -1,4 +1,6 @@ -use ethers::types::{Address, Selector, H160}; +//! Several ABI-related utilities for executors. + +use alloy_primitives::{Address, Selector}; pub use foundry_abi::{ console::{self, ConsoleEvents, CONSOLE_ABI}, hardhat_console::{self, HardhatConsoleCalls, HARDHATCONSOLE_ABI as HARDHAT_CONSOLE_ABI}, @@ -11,7 +13,7 @@ use std::collections::HashMap; /// /// This is the same address as the one used in DappTools's HEVM. /// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))` -pub const CHEATCODE_ADDRESS: Address = H160([ +pub const CHEATCODE_ADDRESS: Address = Address::new([ 0x71, 0x09, 0x70, 0x9E, 0xcf, 0xa9, 0x1a, 0x80, 0x62, 0x6f, 0xf3, 0x98, 0x9d, 0x68, 0xf6, 0x7f, 0x5b, 0x1d, 0xd1, 0x2d, ]); @@ -19,7 +21,7 @@ pub const CHEATCODE_ADDRESS: Address = H160([ /// The Hardhat console address (0x000000000000000000636F6e736F6c652e6c6f67). /// /// See: https://github.com/nomiclabs/hardhat/blob/master/packages/hardhat-core/console.sol -pub const HARDHAT_CONSOLE_ADDRESS: Address = H160([ +pub const HARDHAT_CONSOLE_ADDRESS: Address = Address::new([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, ]); diff --git a/crates/evm/src/executor/backend/diagnostic.rs b/crates/evm/src/executor/backend/diagnostic.rs index 2baec89ecf97b..10fbb43d87ec4 100644 --- a/crates/evm/src/executor/backend/diagnostic.rs +++ b/crates/evm/src/executor/backend/diagnostic.rs @@ -1,8 +1,10 @@ use crate::{ executor::{backend::LocalForkId, inspector::Cheatcodes}, - Address, + utils::b160_to_h160, }; +use alloy_primitives::Address; use foundry_common::fmt::UIfmt; +use itertools::Itertools; /// Represents possible diagnostic cases on revert #[derive(Debug, Clone)] @@ -29,15 +31,18 @@ impl RevertDiagnostic { match self { RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => { - let contract_label = get_label(contract); + let contract_label = get_label(&b160_to_h160(*contract)); format!( - r#"Contract {contract_label} does not exist on active fork with id `{active}` - But exists on non active forks: `{available_on:?}`"# + r#"Contract {} does not exist on active fork with id `{}` + But exists on non active forks: `[{}]`"#, + contract_label, + active, + available_on.iter().format(", ") ) } RevertDiagnostic::ContractDoesNotExist { contract, persistent, .. } => { - let contract_label = get_label(contract); + let contract_label = get_label(&b160_to_h160(*contract)); if *persistent { format!("Contract {contract_label} does not exist") } else { diff --git a/crates/evm/src/executor/backend/error.rs b/crates/evm/src/executor/backend/error.rs index d40dc06fb6481..f7bf27fcd1dc3 100644 --- a/crates/evm/src/executor/backend/error.rs +++ b/crates/evm/src/executor/backend/error.rs @@ -1,4 +1,5 @@ -use ethers::types::{Address, BlockId, H256, U256}; +use alloy_primitives::{Address, B256, U256}; +use ethers::types::BlockId; use foundry_utils::error::SolError; use futures::channel::mpsc::{SendError, TrySendError}; use std::{ @@ -16,7 +17,7 @@ pub enum DatabaseError { #[error("Failed to fetch AccountInfo {0:?}")] MissingAccount(Address), #[error("Could should already be loaded: {0:?}")] - MissingCode(H256), + MissingCode(B256), #[error(transparent)] Recv(#[from] RecvError), #[error(transparent)] @@ -34,9 +35,9 @@ pub enum DatabaseError { #[error("Block {0:?} does not exist")] BlockNotFound(BlockId), #[error("Failed to get transaction {0:?}: {1:?}")] - GetTransaction(H256, Arc), + GetTransaction(B256, Arc), #[error("Transaction {0:?} not found")] - TransactionNotFound(H256), + TransactionNotFound(B256), #[error( "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n\nFor a production environment, you can deploy it using the pre-signed transaction from https://github.com/Arachnid/deterministic-deployment-proxy.\n\nFor a test environment, you can use vm.etch to place the required bytecode at that address." )] diff --git a/crates/evm/src/executor/backend/fuzz.rs b/crates/evm/src/executor/backend/fuzz.rs index b1c98bfbf2b2e..738fa8a34c2a7 100644 --- a/crates/evm/src/executor/backend/fuzz.rs +++ b/crates/evm/src/executor/backend/fuzz.rs @@ -1,18 +1,16 @@ -use crate::{ - executor::{ - backend::{ - diagnostic::RevertDiagnostic, error::DatabaseError, Backend, DatabaseExt, LocalForkId, - }, - fork::{CreateFork, ForkId}, - inspector::cheatcodes::Cheatcodes, +//! A wrapper around `Backend` that is clone-on-write used for fuzzing. + +use crate::executor::{ + backend::{ + diagnostic::RevertDiagnostic, error::DatabaseError, Backend, DatabaseExt, LocalForkId, }, - Address, + fork::{CreateFork, ForkId}, + inspector::cheatcodes::Cheatcodes, }; -use ethers::prelude::{H256, U256}; - +use alloy_primitives::{Address, B256, U256}; use revm::{ db::DatabaseRef, - primitives::{AccountInfo, Bytecode, Env, ResultAndState, B160, B256, U256 as rU256}, + primitives::{AccountInfo, Bytecode, Env, ResultAndState}, Database, Inspector, JournaledState, }; use std::borrow::Cow; @@ -129,7 +127,7 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { fn create_fork_at_transaction( &mut self, fork: CreateFork, - transaction: H256, + transaction: B256, ) -> eyre::Result { trace!(?transaction, "fuzz: create fork at"); self.backend.to_mut().create_fork_at_transaction(fork, transaction) @@ -159,7 +157,7 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { fn roll_fork_to_transaction( &mut self, id: Option, - transaction: H256, + transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()> { @@ -170,7 +168,7 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { fn transact( &mut self, id: Option, - transaction: H256, + transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, cheatcodes_inspector: Option<&mut Cheatcodes>, @@ -231,7 +229,7 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { impl<'a> DatabaseRef for FuzzBackendWrapper<'a> { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, address: Address) -> Result, Self::Error> { DatabaseRef::basic(self.backend.as_ref(), address) } @@ -239,11 +237,11 @@ impl<'a> DatabaseRef for FuzzBackendWrapper<'a> { DatabaseRef::code_by_hash(self.backend.as_ref(), code_hash) } - fn storage(&self, address: B160, index: rU256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { DatabaseRef::storage(self.backend.as_ref(), address, index) } - fn block_hash(&self, number: rU256) -> Result { + fn block_hash(&self, number: U256) -> Result { DatabaseRef::block_hash(self.backend.as_ref(), number) } } @@ -251,7 +249,7 @@ impl<'a> DatabaseRef for FuzzBackendWrapper<'a> { impl<'a> Database for FuzzBackendWrapper<'a> { type Error = DatabaseError; - fn basic(&mut self, address: B160) -> Result, Self::Error> { + fn basic(&mut self, address: Address) -> Result, Self::Error> { DatabaseRef::basic(self, address) } @@ -259,11 +257,11 @@ impl<'a> Database for FuzzBackendWrapper<'a> { DatabaseRef::code_by_hash(self, code_hash) } - fn storage(&mut self, address: B160, index: rU256) -> Result { + fn storage(&mut self, address: Address, index: U256) -> Result { DatabaseRef::storage(self, address, index) } - fn block_hash(&mut self, number: rU256) -> Result { + fn block_hash(&mut self, number: U256) -> Result { DatabaseRef::block_hash(self, number) } } diff --git a/crates/evm/src/executor/backend/in_memory_db.rs b/crates/evm/src/executor/backend/in_memory_db.rs index 73373343497c8..4687db7804e95 100644 --- a/crates/evm/src/executor/backend/in_memory_db.rs +++ b/crates/evm/src/executor/backend/in_memory_db.rs @@ -1,8 +1,9 @@ //! The in memory DB use crate::executor::backend::error::DatabaseError; +use alloy_primitives::{Address, B256, U256}; use revm::{ db::{CacheDB, DatabaseRef, EmptyDB}, - primitives::{Account, AccountInfo, Bytecode, HashMap as Map, B160, B256, U256}, + primitives::{Account, AccountInfo, Bytecode, HashMap as Map}, Database, DatabaseCommit, }; @@ -30,7 +31,7 @@ impl Default for MemDb { impl DatabaseRef for MemDb { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, address: Address) -> Result, Self::Error> { DatabaseRef::basic(&self.inner, address) } @@ -38,7 +39,7 @@ impl DatabaseRef for MemDb { DatabaseRef::code_by_hash(&self.inner, code_hash) } - fn storage(&self, address: B160, index: U256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { DatabaseRef::storage(&self.inner, address, index) } @@ -50,7 +51,7 @@ impl DatabaseRef for MemDb { impl Database for MemDb { type Error = DatabaseError; - fn basic(&mut self, address: B160) -> Result, Self::Error> { + fn basic(&mut self, address: Address) -> Result, Self::Error> { // Note: this will always return `Some(AccountInfo)`, See `EmptyDBWrapper` Database::basic(&mut self.inner, address) } @@ -59,7 +60,7 @@ impl Database for MemDb { Database::code_by_hash(&mut self.inner, code_hash) } - fn storage(&mut self, address: B160, index: U256) -> Result { + fn storage(&mut self, address: Address, index: U256) -> Result { Database::storage(&mut self.inner, address, index) } @@ -69,7 +70,7 @@ impl Database for MemDb { } impl DatabaseCommit for MemDb { - fn commit(&mut self, changes: Map) { + fn commit(&mut self, changes: Map) { DatabaseCommit::commit(&mut self.inner, changes) } } @@ -94,7 +95,7 @@ pub struct EmptyDBWrapper(EmptyDB); impl DatabaseRef for EmptyDBWrapper { type Error = DatabaseError; - fn basic(&self, _address: B160) -> Result, Self::Error> { + fn basic(&self, _address: Address) -> Result, Self::Error> { // Note: this will always return `Some(AccountInfo)`, for the reason explained above Ok(Some(AccountInfo::default())) } @@ -102,8 +103,7 @@ impl DatabaseRef for EmptyDBWrapper { fn code_by_hash(&self, code_hash: B256) -> Result { Ok(self.0.code_by_hash(code_hash)?) } - - fn storage(&self, address: B160, index: U256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { Ok(self.0.storage(address, index)?) } @@ -114,6 +114,8 @@ impl DatabaseRef for EmptyDBWrapper { #[cfg(test)] mod tests { + use alloy_primitives::b256; + use super::*; /// Ensures the `Database(Ref)` implementation for `revm::CacheDB` works as expected @@ -122,7 +124,7 @@ mod tests { #[test] fn cache_db_insert_basic_non_existing() { let mut db = CacheDB::new(EmptyDB::default()); - let address = B160::random(); + let address = Address::random(); // call `basic` on a non-existing account let info = Database::basic(&mut db, address).unwrap(); assert!(info.is_none()); @@ -142,7 +144,7 @@ mod tests { #[test] fn cache_db_insert_basic_default() { let mut db = CacheDB::new(EmptyDB::default()); - let address = B160::random(); + let address = Address::random(); let info = DatabaseRef::basic(&db, address).unwrap(); assert!(info.is_none()); @@ -161,7 +163,9 @@ mod tests { #[test] fn mem_db_insert_basic_default() { let mut db = MemDb::default(); - let address = B160::random(); + let address = Address::from_word(b256!( + "000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045" + )); let info = Database::basic(&mut db, address).unwrap(); assert!(info.is_some()); diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index 3e468f2235133..227e94eea5f08 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -1,3 +1,5 @@ +//! Foundry's main executor backend abstraction and implementation. + use crate::{ abi::CHEATCODE_ADDRESS, executor::{ @@ -6,12 +8,13 @@ use crate::{ inspector::{cheatcodes::Cheatcodes, DEFAULT_CREATE2_DEPLOYER}, snapshot::Snapshots, }, - utils::{b160_to_h160, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256}, + utils::{b256_to_h256, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256, u64_to_ru64}, CALLER, TEST_CONTRACT_ADDRESS, }; +use alloy_primitives::{b256, Address, B256, U256, U64}; use ethers::{ - prelude::{Block, H160, H256, U256}, - types::{Address, BlockNumber, Transaction, U64}, + prelude::Block, + types::{BlockNumber, Transaction}, utils::keccak256, }; pub use in_memory_db::MemDb; @@ -20,7 +23,7 @@ use revm::{ precompile::{Precompiles, SpecId}, primitives::{ Account, AccountInfo, Bytecode, CreateScheme, Env, HashMap as Map, Log, ResultAndState, - TransactTo, B160, B256, KECCAK_EMPTY, U256 as rU256, + TransactTo, KECCAK_EMPTY, }, Database, DatabaseCommit, Inspector, JournaledState, EVM, }; @@ -61,12 +64,13 @@ pub type LocalForkId = U256; type ForkLookupIndex = usize; /// All accounts that will have persistent storage across fork swaps. See also [`clone_data()`] -const DEFAULT_PERSISTENT_ACCOUNTS: [H160; 3] = +const DEFAULT_PERSISTENT_ACCOUNTS: [Address; 3] = [CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, CALLER]; /// Slot corresponding to "failed" in bytes on the cheatcodes (HEVM) address. -const GLOBAL_FAILURE_SLOT: &str = - "0x6661696c65640000000000000000000000000000000000000000000000000000"; +/// Not prefixed with 0x. +const GLOBAL_FAILURE_SLOT: B256 = + b256!("6661696c65640000000000000000000000000000000000000000000000000000"); /// An extension trait that allows us to easily extend the `revm::Inspector` capabilities #[auto_impl::auto_impl(&mut, Box)] @@ -116,7 +120,7 @@ pub trait DatabaseExt: Database { fork: CreateFork, env: &mut Env, journaled_state: &mut JournaledState, - transaction: H256, + transaction: B256, ) -> eyre::Result { let id = self.create_fork_at_transaction(fork, transaction)?; self.select_fork(id, env, journaled_state)?; @@ -130,7 +134,7 @@ pub trait DatabaseExt: Database { fn create_fork_at_transaction( &mut self, fork: CreateFork, - transaction: H256, + transaction: B256, ) -> eyre::Result; /// Selects the fork's state @@ -175,7 +179,7 @@ pub trait DatabaseExt: Database { fn roll_fork_to_transaction( &mut self, id: Option, - transaction: H256, + transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()>; @@ -184,7 +188,7 @@ pub trait DatabaseExt: Database { fn transact( &mut self, id: Option, - transaction: H256, + transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, cheatcodes_inspector: Option<&mut Cheatcodes>, @@ -462,28 +466,28 @@ impl Backend { } } - pub fn insert_account_info(&mut self, address: H160, account: AccountInfo) { + pub fn insert_account_info(&mut self, address: Address, account: AccountInfo) { if let Some(db) = self.active_fork_db_mut() { - db.insert_account_info(h160_to_b160(address), account) + db.insert_account_info(address, account) } else { - self.mem_db.insert_account_info(h160_to_b160(address), account) + self.mem_db.insert_account_info(address, account) } } /// Inserts a value on an account's storage without overriding account info pub fn insert_account_storage( &mut self, - address: H160, + address: Address, slot: U256, value: U256, ) -> Result<(), DatabaseError> { let ret = if let Some(db) = self.active_fork_db_mut() { - db.insert_account_storage(h160_to_b160(address), slot.into(), value.into()) + db.insert_account_storage(address, slot, value) } else { - self.mem_db.insert_account_storage(h160_to_b160(address), slot.into(), value.into()) + self.mem_db.insert_account_storage(address, slot, value) }; - debug_assert!(self.storage(h160_to_b160(address), slot.into()).unwrap() == value.into()); + debug_assert!(self.storage(address, slot).unwrap() == value); ret } @@ -514,7 +518,7 @@ impl Backend { } /// Sets the caller address - pub fn set_caller(&mut self, acc: H160) -> &mut Self { + pub fn set_caller(&mut self, acc: Address) -> &mut Self { trace!(?acc, "setting caller account"); self.inner.caller = Some(acc); self.allow_cheatcode_access(acc); @@ -573,7 +577,7 @@ impl Backend { bool private _failed; } */ - let value = self.storage(h160_to_b160(address), U256::zero().into()).unwrap_or_default(); + let value = self.storage(address, U256::ZERO).unwrap_or_default(); value.as_le_bytes()[1] != 0 } @@ -588,7 +592,6 @@ impl Backend { address: Address, current_state: &JournaledState, ) -> bool { - let address = h160_to_b160(address); if let Some(account) = current_state.state.get(&address) { let value = account .storage @@ -606,10 +609,9 @@ impl Backend { /// in "failed" /// See pub fn is_global_failure(&self, current_state: &JournaledState) -> bool { - let index: rU256 = - U256::from_str_radix(GLOBAL_FAILURE_SLOT, 16).expect("This is a bug.").into(); - if let Some(account) = current_state.state.get(&h160_to_b160(CHEATCODE_ADDRESS)) { - let value = account.storage.get(&index).cloned().unwrap_or_default().present_value(); + if let Some(account) = current_state.state.get(&CHEATCODE_ADDRESS) { + let slot: U256 = GLOBAL_FAILURE_SLOT.into(); + let value = account.storage.get(&slot).cloned().unwrap_or_default().present_value(); return value == revm::primitives::U256::from(1) } @@ -722,7 +724,7 @@ impl Backend { /// /// We need to track these mainly to prevent issues when switching between different evms pub(crate) fn initialize(&mut self, env: &Env) { - self.set_caller(b160_to_h160(env.tx.caller)); + self.set_caller(env.tx.caller); self.set_spec_id(SpecId::from_spec_id(env.cfg.spec_id)); let test_contract = match env.tx.transact_to { @@ -731,11 +733,11 @@ impl Backend { revm::primitives::create_address(env.tx.caller, env.tx.nonce.unwrap_or_default()) } TransactTo::Create(CreateScheme::Create2 { salt }) => { - let code_hash = H256::from_slice(keccak256(&env.tx.data).as_slice()); - revm::primitives::create2_address(env.tx.caller, h256_to_b256(code_hash), salt) + let code_hash = B256::from_slice(keccak256(&env.tx.data).as_slice()); + revm::primitives::create2_address(env.tx.caller, code_hash, salt) } }; - self.set_test_contract(b160_to_h160(test_contract)); + self.set_test_contract(test_contract); } /// Executes the configured test call of the `env` without committing state changes @@ -756,7 +758,7 @@ impl Backend { } /// Returns true if the address is a precompile - pub fn is_existing_precompile(&self, addr: &B160) -> bool { + pub fn is_existing_precompile(&self, addr: &Address) -> bool { self.inner.precompiles().contains(addr) } @@ -774,9 +776,7 @@ impl Backend { .fork_init_journaled_state .state .iter() - .filter(|(addr, _)| { - !self.is_existing_precompile(addr) && !self.is_persistent(&b160_to_h160(**addr)) - }) + .filter(|(addr, _)| !self.is_existing_precompile(addr) && !self.is_persistent(addr)) .map(|(addr, _)| addr) .copied() .collect::>(); @@ -786,7 +786,7 @@ impl Backend { for loaded_account in loaded_accounts.iter().copied() { trace!(?loaded_account, "replacing account on init"); let fork_account = Database::basic(&mut fork.db, loaded_account)? - .ok_or(DatabaseError::MissingAccount(b160_to_h160(loaded_account)))?; + .ok_or(DatabaseError::MissingAccount(loaded_account))?; let init_account = journaled_state.state.get_mut(&loaded_account).expect("exists; qed"); init_account.info = fork_account; @@ -800,7 +800,7 @@ impl Backend { fn get_block_number_and_block_for_transaction( &self, id: LocalForkId, - transaction: H256, + transaction: B256, ) -> eyre::Result<(U64, Block)> { let fork = self.inner.get_fork_by_id(id)?; let tx = fork.db.db.get_transaction(transaction)?; @@ -812,7 +812,7 @@ impl Backend { // we need to subtract 1 here because we want the state before the transaction // was mined let fork_block = tx_block - 1; - Ok((fork_block, block)) + Ok((U64::from(fork_block.as_u64()), block)) } else { let block = fork.db.db.get_full_block(BlockNumber::Latest)?; @@ -820,7 +820,7 @@ impl Backend { .number .ok_or_else(|| DatabaseError::BlockNotFound(BlockNumber::Latest.into()))?; - Ok((number, block)) + Ok((U64::from(number.as_u64()), block)) } } @@ -831,7 +831,7 @@ impl Backend { &mut self, id: LocalForkId, env: Env, - tx_hash: H256, + tx_hash: B256, journaled_state: &mut JournaledState, ) -> eyre::Result> { trace!(?id, ?tx_hash, "replay until transaction"); @@ -845,7 +845,7 @@ impl Backend { .get_full_block(BlockNumber::Number(ru256_to_u256(env.block.number).as_u64().into()))?; for tx in full_block.transactions.into_iter() { - if tx.hash().eq(&tx_hash) { + if tx.hash().eq(&b256_to_h256(tx_hash)) { // found the target transaction return Ok(Some(tx)) } @@ -941,7 +941,7 @@ impl DatabaseExt for Backend { fn create_fork_at_transaction( &mut self, fork: CreateFork, - transaction: H256, + transaction: B256, ) -> eyre::Result { trace!(?transaction, "create fork at transaction"); let id = self.create_fork(fork)?; @@ -962,6 +962,7 @@ impl DatabaseExt for Backend { Ok(id) } + /// Select an existing fork by id. /// When switching forks we copy the shared state fn select_fork( &mut self, @@ -996,7 +997,7 @@ impl DatabaseExt for Backend { // Initialize caller with its fork info if let Some(mut acc) = caller_account { let fork_account = Database::basic(&mut target_fork.db, caller)? - .ok_or(DatabaseError::MissingAccount(b160_to_h160(caller)))?; + .ok_or(DatabaseError::MissingAccount(caller))?; acc.info = fork_account; target_fork.journaled_state.state.insert(caller, acc); @@ -1068,7 +1069,7 @@ impl DatabaseExt for Backend { trace!(?id, ?block_number, "roll fork"); let id = self.ensure_fork(id)?; let (fork_id, backend, fork_env) = - self.forks.roll_fork(self.inner.ensure_fork_id(id).cloned()?, block_number.as_u64())?; + self.forks.roll_fork(self.inner.ensure_fork_id(id).cloned()?, block_number.to())?; // this will update the local mapping self.inner.roll_fork(id, fork_id, backend)?; @@ -1101,7 +1102,7 @@ impl DatabaseExt for Backend { for (addr, acc) in journaled_state.state.iter() { if acc.is_touched() { merge_journaled_state_data( - b160_to_h160(*addr), + *addr, journaled_state, &mut active.journaled_state, ); @@ -1119,7 +1120,7 @@ impl DatabaseExt for Backend { fn roll_fork_to_transaction( &mut self, id: Option, - transaction: H256, + transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()> { @@ -1130,16 +1131,16 @@ impl DatabaseExt for Backend { self.get_block_number_and_block_for_transaction(id, transaction)?; // roll the fork to the transaction's block or latest if it's pending - self.roll_fork(Some(id), fork_block.as_u64().into(), env, journaled_state)?; + self.roll_fork(Some(id), fork_block.to(), env, journaled_state)?; // update the block's env accordingly - env.block.timestamp = block.timestamp.into(); + env.block.timestamp = u256_to_ru256(block.timestamp); env.block.coinbase = h160_to_b160(block.author.unwrap_or_default()); - env.block.difficulty = block.difficulty.into(); + env.block.difficulty = u256_to_ru256(block.difficulty); env.block.prevrandao = block.mix_hash.map(h256_to_b256); - env.block.basefee = block.base_fee_per_gas.unwrap_or_default().into(); - env.block.gas_limit = block.gas_limit.into(); - env.block.number = u256_to_ru256(block.number.unwrap_or(fork_block).as_u64().into()); + env.block.basefee = u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()); + env.block.gas_limit = u256_to_ru256(block.gas_limit); + env.block.number = block.number.map(u64_to_ru64).unwrap_or(fork_block).to(); // replay all transactions that came before let env = env.clone(); @@ -1152,7 +1153,7 @@ impl DatabaseExt for Backend { fn transact( &mut self, maybe_id: Option, - transaction: H256, + transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, cheatcodes_inspector: Option<&mut Cheatcodes>, @@ -1279,7 +1280,7 @@ impl DatabaseExt for Backend { impl DatabaseRef for Backend { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, address: Address) -> Result, Self::Error> { if let Some(db) = self.active_fork_db() { db.basic(address) } else { @@ -1295,7 +1296,7 @@ impl DatabaseRef for Backend { } } - fn storage(&self, address: B160, index: rU256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { if let Some(db) = self.active_fork_db() { DatabaseRef::storage(db, address, index) } else { @@ -1303,7 +1304,7 @@ impl DatabaseRef for Backend { } } - fn block_hash(&self, number: rU256) -> Result { + fn block_hash(&self, number: U256) -> Result { if let Some(db) = self.active_fork_db() { db.block_hash(number) } else { @@ -1314,7 +1315,7 @@ impl DatabaseRef for Backend { impl<'a> DatabaseRef for &'a mut Backend { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, address: Address) -> Result, Self::Error> { if let Some(db) = self.active_fork_db() { DatabaseRef::basic(db, address) } else { @@ -1330,7 +1331,7 @@ impl<'a> DatabaseRef for &'a mut Backend { } } - fn storage(&self, address: B160, index: rU256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { if let Some(db) = self.active_fork_db() { DatabaseRef::storage(db, address, index) } else { @@ -1338,7 +1339,7 @@ impl<'a> DatabaseRef for &'a mut Backend { } } - fn block_hash(&self, number: rU256) -> Result { + fn block_hash(&self, number: U256) -> Result { if let Some(db) = self.active_fork_db() { DatabaseRef::block_hash(db, number) } else { @@ -1348,7 +1349,7 @@ impl<'a> DatabaseRef for &'a mut Backend { } impl DatabaseCommit for Backend { - fn commit(&mut self, changes: Map) { + fn commit(&mut self, changes: Map) { if let Some(db) = self.active_fork_db_mut() { db.commit(changes) } else { @@ -1359,7 +1360,7 @@ impl DatabaseCommit for Backend { impl Database for Backend { type Error = DatabaseError; - fn basic(&mut self, address: B160) -> Result, Self::Error> { + fn basic(&mut self, address: Address) -> Result, Self::Error> { if let Some(db) = self.active_fork_db_mut() { db.basic(address) } else { @@ -1375,7 +1376,7 @@ impl Database for Backend { } } - fn storage(&mut self, address: B160, index: rU256) -> Result { + fn storage(&mut self, address: Address, index: U256) -> Result { if let Some(db) = self.active_fork_db_mut() { Database::storage(db, address, index) } else { @@ -1383,7 +1384,7 @@ impl Database for Backend { } } - fn block_hash(&mut self, number: rU256) -> Result { + fn block_hash(&mut self, number: U256) -> Result { if let Some(db) = self.active_fork_db_mut() { db.block_hash(number) } else { @@ -1413,7 +1414,7 @@ pub struct Fork { impl Fork { /// Returns true if the account is a contract pub fn is_contract(&self, acc: Address) -> bool { - if let Ok(Some(acc)) = self.db.basic(h160_to_b160(acc)) { + if let Ok(Some(acc)) = self.db.basic(acc) { if acc.code_hash != KECCAK_EMPTY { return true } @@ -1624,7 +1625,7 @@ impl BackendInner { fn next_id(&mut self) -> U256 { let id = self.next_fork_id; - self.next_fork_id += U256::one(); + self.next_fork_id += U256::from(1); id } @@ -1707,8 +1708,6 @@ fn merge_journaled_state_data( active_journaled_state: &JournaledState, fork_journaled_state: &mut JournaledState, ) { - let addr = h160_to_b160(addr); - if let Some(mut acc) = active_journaled_state.state.get(&addr).cloned() { trace!(?addr, "updating journaled_state account data"); if let Some(fork_account) = fork_journaled_state.state.get_mut(&addr) { @@ -1729,8 +1728,6 @@ fn merge_db_account_data( ) { trace!(?addr, "merging database data"); - let addr = h160_to_b160(addr); - let mut acc = if let Some(acc) = active.accounts.get(&addr).cloned() { acc } else { @@ -1754,8 +1751,6 @@ fn merge_db_account_data( /// Returns true of the address is a contract fn is_contract_in_state(journaled_state: &JournaledState, acc: Address) -> bool { - let acc = h160_to_b160(acc); - journaled_state .state .get(&acc) diff --git a/crates/evm/src/executor/backend/snapshot.rs b/crates/evm/src/executor/backend/snapshot.rs index 36f1aa611788c..73ec8c5d7df76 100644 --- a/crates/evm/src/executor/backend/snapshot.rs +++ b/crates/evm/src/executor/backend/snapshot.rs @@ -1,5 +1,6 @@ +use alloy_primitives::{Address, B256, U256}; use revm::{ - primitives::{AccountInfo, Env, HashMap as Map, B160, B256, U256}, + primitives::{AccountInfo, Env, HashMap as Map}, JournaledState, }; use serde::{Deserialize, Serialize}; @@ -7,8 +8,8 @@ use serde::{Deserialize, Serialize}; /// A minimal abstraction of a state at a certain point in time #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StateSnapshot { - pub accounts: Map, - pub storage: Map>, + pub accounts: Map, + pub storage: Map>, pub block_hashes: Map, } diff --git a/crates/evm/src/executor/builder.rs b/crates/evm/src/executor/builder.rs index 9369bc4f2a0a2..5cbf6e453d650 100644 --- a/crates/evm/src/executor/builder.rs +++ b/crates/evm/src/executor/builder.rs @@ -1,6 +1,6 @@ use super::{inspector::InspectorStackBuilder, Executor}; use crate::executor::backend::Backend; -use ethers::types::U256; +use alloy_primitives::U256; use revm::primitives::{Env, SpecId}; /// The builder that allows to configure an evm [`Executor`] which a stack of optional @@ -67,8 +67,8 @@ impl ExecutorBuilder { let Self { mut stack, gas_limit, spec_id } = self; env.cfg.spec_id = spec_id; stack.block = Some(env.block.clone()); - stack.gas_price = Some(env.tx.gas_price.into()); - let gas_limit = gas_limit.unwrap_or(env.block.gas_limit.into()); + stack.gas_price = Some(env.tx.gas_price); + let gas_limit = gas_limit.unwrap_or(env.block.gas_limit); Executor::new(db, env, stack.build(), gas_limit) } } diff --git a/crates/evm/src/executor/fork/backend.rs b/crates/evm/src/executor/fork/backend.rs index e8b458248b806..ade1e6382363a 100644 --- a/crates/evm/src/executor/fork/backend.rs +++ b/crates/evm/src/executor/fork/backend.rs @@ -4,12 +4,13 @@ use crate::{ backend::error::{DatabaseError, DatabaseResult}, fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }, - utils::{b160_to_h160, b256_to_h256, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256}, + utils::{b160_to_h160, b256_to_h256, h256_to_b256, u256_to_ru256}, }; +use alloy_primitives::{Address, Bytes, B256, U256}; use ethers::{ core::abi::ethereum_types::BigEndianHash, providers::Middleware, - types::{Address, Block, BlockId, Bytes, Transaction, H256, U256}, + types::{Block, BlockId, NameOrAddress, Transaction}, utils::keccak256, }; use foundry_common::NON_ARCHIVE_NODE_WARNING; @@ -21,7 +22,7 @@ use futures::{ }; use revm::{ db::DatabaseRef, - primitives::{AccountInfo, Bytecode, B160, B256, KECCAK_EMPTY, U256 as rU256}, + primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, @@ -37,7 +38,7 @@ use std::{ type AccountFuture = Pin, Address)> + Send>>; type StorageFuture = Pin, Address, U256)> + Send>>; -type BlockHashFuture = Pin, u64)> + Send>>; +type BlockHashFuture = Pin, u64)> + Send>>; type FullBlockFuture = Pin< Box< dyn Future>, Err>, BlockId)> @@ -45,12 +46,12 @@ type FullBlockFuture = Pin< >, >; type TransactionFuture = Pin< - Box, Err>, H256)> + Send>, + Box, Err>, B256)> + Send>, >; type AccountInfoSender = OneshotSender>; type StorageSender = OneshotSender>; -type BlockHashSender = OneshotSender>; +type BlockHashSender = OneshotSender>; type FullBlockSender = OneshotSender>>; type TransactionSender = OneshotSender>; @@ -75,7 +76,7 @@ enum BackendRequest { /// Fetch an entire block with transactions FullBlock(BlockId, FullBlockSender), /// Fetch a transaction - Transaction(H256, TransactionSender), + Transaction(B256, TransactionSender), /// Sets the pinned block to fetch data from SetPinnedBlock(BlockId), } @@ -139,7 +140,7 @@ where match req { BackendRequest::Basic(addr, sender) => { trace!(target: "backendhandler", "received request basic address={:?}", addr); - let acc = self.db.accounts().read().get(&h160_to_b160(addr)).cloned(); + let acc = self.db.accounts().read().get(&addr).cloned(); if let Some(basic) = acc { let _ = sender.send(Ok(basic)); } else { @@ -147,9 +148,9 @@ where } } BackendRequest::BlockHash(number, sender) => { - let hash = self.db.block_hashes().read().get(&rU256::from(number)).cloned(); + let hash = self.db.block_hashes().read().get(&U256::from(number)).cloned(); if let Some(hash) = hash { - let _ = sender.send(Ok(hash.into())); + let _ = sender.send(Ok(hash)); } else { self.request_hash(number, sender); } @@ -162,14 +163,10 @@ where } BackendRequest::Storage(addr, idx, sender) => { // account is already stored in the cache - let value = self - .db - .storage() - .read() - .get(&h160_to_b160(addr)) - .and_then(|acc| acc.get(&u256_to_ru256(idx)).copied()); + let value = + self.db.storage().read().get(&addr).and_then(|acc| acc.get(&idx).copied()); if let Some(value) = value { - let _ = sender.send(Ok(ru256_to_u256(value))); + let _ = sender.send(Ok(value)); } else { // account present but not storage -> fetch storage self.request_account_storage(addr, idx, sender); @@ -194,9 +191,15 @@ where let block_id = self.block_id; let fut = Box::pin(async move { // serialize & deserialize back to U256 - let idx_req = H256::from_uint(&idx); - let storage = provider.get_storage_at(address, idx_req, block_id).await; - let storage = storage.map(|storage| storage.into_uint()); + let idx_req = B256::from(idx); + let storage = provider + .get_storage_at( + NameOrAddress::Address(b160_to_h160(address)), + b256_to_h256(idx_req), + block_id, + ) + .await; + let storage = storage.map(|storage| storage.into_uint()).map(u256_to_ru256); (storage, address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); @@ -210,10 +213,14 @@ where let provider = self.provider.clone(); let block_id = self.block_id; let fut = Box::pin(async move { - let balance = provider.get_balance(address, block_id); - let nonce = provider.get_transaction_count(address, block_id); - let code = provider.get_code(address, block_id); - let resp = tokio::try_join!(balance, nonce, code); + let balance = + provider.get_balance(NameOrAddress::Address(b160_to_h160(address)), block_id); + let nonce = provider + .get_transaction_count(NameOrAddress::Address(b160_to_h160(address)), block_id); + let code = provider.get_code(NameOrAddress::Address(b160_to_h160(address)), block_id); + let resp = tokio::try_join!(balance, nonce, code).map(|(balance, nonce, code)| { + (u256_to_ru256(balance), u256_to_ru256(nonce), Bytes::from(code.0)) + }); (resp, address) }); ProviderRequest::Account(fut) @@ -244,10 +251,10 @@ where } /// process a request for a transactions - fn request_transaction(&mut self, tx: H256, sender: TransactionSender) { + fn request_transaction(&mut self, tx: B256, sender: TransactionSender) { let provider = self.provider.clone(); let fut = Box::pin(async move { - let block = provider.get_transaction(tx).await; + let block = provider.get_transaction(b256_to_h256(tx)).await; (sender, block, tx) }); @@ -282,7 +289,7 @@ where Err(err) } }; - (block_hash, number) + (block_hash.map(h256_to_b256), number) }); self.pending_requests.push(ProviderRequest::BlockHash(fut)); } @@ -350,12 +357,14 @@ where // update the cache let acc = AccountInfo { - nonce: nonce.as_u64(), - balance: balance.into(), - code: code.map(|bytes| Bytecode::new_raw(bytes).to_checked()), + nonce: nonce.to(), + balance, + code: code.map(|bytes| { + Bytecode::new_raw(alloy_primitives::Bytes(bytes)).to_checked() + }), code_hash, }; - pin.db.accounts().write().insert(addr.into(), acc.clone()); + pin.db.accounts().write().insert(addr, acc.clone()); // notify all listeners if let Some(listeners) = pin.account_requests.remove(&addr) { @@ -389,12 +398,7 @@ where }; // update the cache - pin.db - .storage() - .write() - .entry(addr.into()) - .or_default() - .insert(idx.into(), value.into()); + pin.db.storage().write().entry(addr).or_default().insert(idx, value); // notify all listeners if let Some(listeners) = pin.storage_requests.remove(&(addr, idx)) { @@ -425,7 +429,7 @@ where }; // update the cache - pin.db.block_hashes().write().insert(rU256::from(number), value.into()); + pin.db.block_hashes().write().insert(U256::from(number), value); // notify all listeners if let Some(listeners) = pin.block_requests.remove(&number) { @@ -598,7 +602,7 @@ impl SharedBackend { } /// Returns the transaction for the hash - pub fn get_transaction(&self, tx: H256) -> DatabaseResult { + pub fn get_transaction(&self, tx: B256) -> DatabaseResult { tokio::task::block_in_place(|| { let (sender, rx) = oneshot_channel(); let req = BackendRequest::Transaction(tx, sender); @@ -625,7 +629,7 @@ impl SharedBackend { }) } - fn do_get_block_hash(&self, number: u64) -> DatabaseResult { + fn do_get_block_hash(&self, number: u64) -> DatabaseResult { tokio::task::block_in_place(|| { let (sender, rx) = oneshot_channel(); let req = BackendRequest::BlockHash(number, sender); @@ -643,9 +647,9 @@ impl SharedBackend { impl DatabaseRef for SharedBackend { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, address: Address) -> Result, Self::Error> { trace!( target: "sharedbackend", "request basic {:?}", address); - self.do_get_basic(b160_to_h160(address)).map_err(|err| { + self.do_get_basic(address).map_err(|err| { error!(target: "sharedbackend", ?err, ?address, "Failed to send/recv `basic`"); if err.is_possibly_non_archive_node_error() { error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); @@ -655,29 +659,29 @@ impl DatabaseRef for SharedBackend { } fn code_by_hash(&self, hash: B256) -> Result { - Err(DatabaseError::MissingCode(b256_to_h256(hash))) + Err(DatabaseError::MissingCode(hash)) } - fn storage(&self, address: B160, index: rU256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { trace!( target: "sharedbackend", "request storage {:?} at {:?}", address, index); - match self.do_get_storage(b160_to_h160(address), index.into()).map_err(|err| { + match self.do_get_storage(address, index).map_err(|err| { error!( target: "sharedbackend", ?err, ?address, ?index, "Failed to send/recv `storage`"); if err.is_possibly_non_archive_node_error() { error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); } err }) { - Ok(val) => Ok(val.into()), + Ok(val) => Ok(val), Err(err) => Err(err), } } - fn block_hash(&self, number: rU256) -> Result { - if number > rU256::from(u64::MAX) { + fn block_hash(&self, number: U256) -> Result { + if number > U256::from(u64::MAX) { return Ok(KECCAK_EMPTY) } - let number: U256 = number.into(); - let number = number.as_u64(); + let number: U256 = number; + let number = number.to(); trace!( target: "sharedbackend", "request block hash for number {:?}", number); match self.do_get_block_hash(number).map_err(|err| { error!(target: "sharedbackend",?err, ?number, "Failed to send/recv `block_hash`"); @@ -686,7 +690,7 @@ impl DatabaseRef for SharedBackend { } err }) { - Ok(val) => Ok(h256_to_b256(val)), + Ok(val) => Ok(val), Err(err) => Err(err), } } @@ -719,9 +723,9 @@ mod tests { let backend = SharedBackend::spawn_backend(Arc::new(provider), db.clone(), None).await; // some rng contract from etherscan - let address: B160 = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); + let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); - let idx = rU256::from(0u64); + let idx = U256::from(0u64); let value = backend.storage(address, idx).unwrap(); let account = backend.basic(address).unwrap().unwrap(); @@ -732,7 +736,7 @@ mod tests { assert_eq!(slots.len(), 1); assert_eq!(slots.get(&idx).copied().unwrap(), value); - let num = rU256::from(10u64); + let num = U256::from(10u64); let hash = backend.block_hash(num).unwrap(); let mem_hash = *db.block_hashes().read().get(&num).unwrap(); assert_eq!(hash, mem_hash); @@ -740,7 +744,7 @@ mod tests { let max_slots = 5; let handle = std::thread::spawn(move || { for i in 1..max_slots { - let idx = rU256::from(i); + let idx = U256::from(i); let _ = backend.storage(address, idx); } }); @@ -778,16 +782,16 @@ mod tests { let backend = Backend::spawn(Some(fork)).await; // some rng contract from etherscan - let address: B160 = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); + let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); - let idx = rU256::from(0u64); + let idx = U256::from(0u64); let _value = backend.storage(address, idx); let _account = backend.basic(address); // fill some slots let num_slots = 10u64; for idx in 1..num_slots { - let _ = backend.storage(address, rU256::from(idx)); + let _ = backend.storage(address, U256::from(idx)); } drop(backend); diff --git a/crates/evm/src/executor/fork/cache.rs b/crates/evm/src/executor/fork/cache.rs index 12d04869ce531..f9a96772ce34d 100644 --- a/crates/evm/src/executor/fork/cache.rs +++ b/crates/evm/src/executor/fork/cache.rs @@ -1,10 +1,9 @@ //! Cache related abstraction use crate::executor::backend::snapshot::StateSnapshot; +use alloy_primitives::{Address, B256, U256}; use parking_lot::RwLock; use revm::{ - primitives::{ - Account, AccountInfo, AccountStatus, HashMap as Map, B160, B256, KECCAK_EMPTY, U256, - }, + primitives::{Account, AccountInfo, AccountStatus, HashMap as Map, KECCAK_EMPTY}, DatabaseCommit, }; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; @@ -87,12 +86,12 @@ impl BlockchainDb { } /// Returns the map that holds the account related info - pub fn accounts(&self) -> &RwLock> { + pub fn accounts(&self) -> &RwLock> { &self.db.accounts } /// Returns the map that holds the storage related info - pub fn storage(&self) -> &RwLock> { + pub fn storage(&self) -> &RwLock> { &self.db.storage } @@ -232,9 +231,9 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { #[derive(Debug, Default)] pub struct MemDb { /// Account related data - pub accounts: RwLock>, + pub accounts: RwLock>, /// Storage related data - pub storage: RwLock>, + pub storage: RwLock>, /// All retrieved block hashes pub block_hashes: RwLock>, } @@ -248,12 +247,12 @@ impl MemDb { } // Inserts the account, replacing it if it exists already - pub fn do_insert_account(&self, address: B160, account: AccountInfo) { + pub fn do_insert_account(&self, address: Address, account: AccountInfo) { self.accounts.write().insert(address, account); } /// The implementation of [DatabaseCommit::commit()] - pub fn do_commit(&self, changes: Map) { + pub fn do_commit(&self, changes: Map) { let mut storage = self.storage.write(); let mut accounts = self.accounts.write(); for (add, mut acc) in changes { @@ -305,7 +304,7 @@ impl Clone for MemDb { } impl DatabaseCommit for MemDb { - fn commit(&mut self, changes: Map) { + fn commit(&mut self, changes: Map) { self.do_commit(changes) } } diff --git a/crates/evm/src/executor/fork/database.rs b/crates/evm/src/executor/fork/database.rs index c9b58c839de89..8da324b24cf29 100644 --- a/crates/evm/src/executor/fork/database.rs +++ b/crates/evm/src/executor/fork/database.rs @@ -8,11 +8,12 @@ use crate::{ }, revm::db::CacheDB, }; -use ethers::{prelude::U256, types::BlockId}; +use alloy_primitives::{Address, B256, U256}; +use ethers::types::BlockId; use parking_lot::Mutex; use revm::{ db::DatabaseRef, - primitives::{Account, AccountInfo, Bytecode, HashMap as Map, B160, B256, U256 as rU256}, + primitives::{Account, AccountInfo, Bytecode, HashMap as Map}, Database, DatabaseCommit, }; use std::sync::Arc; @@ -151,7 +152,7 @@ impl ForkedDatabase { impl Database for ForkedDatabase { type Error = DatabaseError; - fn basic(&mut self, address: B160) -> Result, Self::Error> { + fn basic(&mut self, address: Address) -> Result, Self::Error> { // Note: this will always return Some, since the `SharedBackend` will always load the // account, this differs from `::basic`, See also // [MemDb::ensure_loaded](crate::executor::backend::MemDb::ensure_loaded) @@ -162,11 +163,11 @@ impl Database for ForkedDatabase { Database::code_by_hash(&mut self.cache_db, code_hash) } - fn storage(&mut self, address: B160, index: rU256) -> Result { + fn storage(&mut self, address: Address, index: U256) -> Result { Database::storage(&mut self.cache_db, address, index) } - fn block_hash(&mut self, number: rU256) -> Result { + fn block_hash(&mut self, number: U256) -> Result { Database::block_hash(&mut self.cache_db, number) } } @@ -174,7 +175,7 @@ impl Database for ForkedDatabase { impl DatabaseRef for ForkedDatabase { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, address: Address) -> Result, Self::Error> { self.cache_db.basic(address) } @@ -182,17 +183,17 @@ impl DatabaseRef for ForkedDatabase { self.cache_db.code_by_hash(code_hash) } - fn storage(&self, address: B160, index: rU256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { DatabaseRef::storage(&self.cache_db, address, index) } - fn block_hash(&self, number: rU256) -> Result { + fn block_hash(&self, number: U256) -> Result { self.cache_db.block_hash(number) } } impl DatabaseCommit for ForkedDatabase { - fn commit(&mut self, changes: Map) { + fn commit(&mut self, changes: Map) { self.database_mut().commit(changes) } } @@ -209,7 +210,7 @@ pub struct ForkDbSnapshot { // === impl DbSnapshot === impl ForkDbSnapshot { - fn get_storage(&self, address: B160, index: rU256) -> Option { + fn get_storage(&self, address: Address, index: U256) -> Option { self.local.accounts.get(&address).and_then(|account| account.storage.get(&index)).copied() } } @@ -220,7 +221,7 @@ impl ForkDbSnapshot { impl DatabaseRef for ForkDbSnapshot { type Error = DatabaseError; - fn basic(&self, address: B160) -> Result, Self::Error> { + fn basic(&self, address: Address) -> Result, Self::Error> { match self.local.accounts.get(&address) { Some(account) => Ok(Some(account.info.clone())), None => { @@ -238,7 +239,7 @@ impl DatabaseRef for ForkDbSnapshot { self.local.code_by_hash(code_hash) } - fn storage(&self, address: B160, index: rU256) -> Result { + fn storage(&self, address: Address, index: U256) -> Result { match self.local.accounts.get(&address) { Some(account) => match account.storage.get(&index) { Some(entry) => Ok(*entry), @@ -254,7 +255,7 @@ impl DatabaseRef for ForkDbSnapshot { } } - fn block_hash(&self, number: rU256) -> Result { + fn block_hash(&self, number: U256) -> Result { match self.snapshot.block_hashes.get(&number).copied() { None => self.local.block_hash(number), Some(block_hash) => Ok(block_hash), @@ -285,12 +286,12 @@ mod tests { let backend = SharedBackend::spawn_backend(Arc::new(provider), db.clone(), None).await; let mut db = ForkedDatabase::new(backend, db); - let address = B160::random(); + let address = Address::random(); let info = Database::basic(&mut db, address).unwrap(); assert!(info.is_some()); let mut info = info.unwrap(); - info.balance = rU256::from(500u64); + info.balance = U256::from(500u64); // insert the modified account info db.database_mut().insert_account_info(address, info.clone()); diff --git a/crates/evm/src/executor/fork/init.rs b/crates/evm/src/executor/fork/init.rs index 0c42b3e03bb3a..539e4f888d505 100644 --- a/crates/evm/src/executor/fork/init.rs +++ b/crates/evm/src/executor/fork/init.rs @@ -1,9 +1,10 @@ use crate::utils::{ apply_chain_and_block_specific_env_changes, h160_to_b160, h256_to_b256, u256_to_ru256, }; +use alloy_primitives::{Address, U256}; use ethers::{ providers::Middleware, - types::{Address, Block, TxHash, U256}, + types::{Block, TxHash}, }; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; @@ -66,20 +67,21 @@ where // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the caller // is a contract. So we disable the check by default. cfg.disable_eip3607 = true; + let mut env = Env { cfg, block: BlockEnv { number: u256_to_ru256(block.number.expect("block number not found").as_u64().into()), - timestamp: block.timestamp.into(), + timestamp: u256_to_ru256(block.timestamp), coinbase: h160_to_b160(block.author.unwrap_or_default()), - difficulty: block.difficulty.into(), + difficulty: u256_to_ru256(block.difficulty), prevrandao: Some(block.mix_hash.map(h256_to_b256).unwrap_or_default()), - basefee: block.base_fee_per_gas.unwrap_or_default().into(), - gas_limit: block.gas_limit.into(), + basefee: u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()), + gas_limit: u256_to_ru256(block.gas_limit), }, tx: TxEnv { - caller: h160_to_b160(origin), - gas_price: gas_price.map(U256::from).unwrap_or(fork_gas_price).into(), + caller: origin, + gas_price: gas_price.map(U256::from).unwrap_or(u256_to_ru256(fork_gas_price)), chain_id: Some(override_chain_id.unwrap_or(rpc_chain_id.as_u64())), gas_limit: block.gas_limit.as_u64(), ..Default::default() diff --git a/crates/evm/src/executor/fork/multi.rs b/crates/evm/src/executor/fork/multi.rs index a3edb576a8608..f2dafbfc333c1 100644 --- a/crates/evm/src/executor/fork/multi.rs +++ b/crates/evm/src/executor/fork/multi.rs @@ -1,4 +1,4 @@ -//! Support for running multiple fork backend +//! Support for running multiple fork backends //! //! The design is similar to the single `SharedBackend`, `BackendHandler` but supports multiple //! concurrently active pairs at once. diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/src/executor/inspector/access_list.rs index bd059b2e64d05..108b90ff1f0dd 100644 --- a/crates/evm/src/executor/inspector/access_list.rs +++ b/crates/evm/src/executor/inspector/access_list.rs @@ -1,23 +1,18 @@ -use ethers::{ - abi::{ethereum_types::BigEndianHash, Address}, - types::{ - transaction::eip2930::{AccessList, AccessListItem}, - H256, - }, -}; +use alloy_primitives::{Address, B256}; +use ethers::types::transaction::eip2930::{AccessList, AccessListItem}; use hashbrown::{HashMap, HashSet}; use revm::{ interpreter::{opcode, InstructionResult, Interpreter}, Database, EVMData, Inspector, }; -use crate::utils::{b160_to_h160, ru256_to_u256}; +use crate::utils::{b160_to_h160, b256_to_h256, h160_to_b160, h256_to_b256}; /// An inspector that collects touched accounts and storage slots. #[derive(Default, Debug)] pub struct AccessListTracer { excluded: HashSet
, - access_list: HashMap>, + access_list: HashMap>, } impl AccessListTracer { @@ -32,24 +27,27 @@ impl AccessListTracer { access_list: access_list .0 .iter() - .map(|v| (v.address, v.storage_keys.iter().copied().collect())) + .map(|v| { + ( + h160_to_b160(v.address), + v.storage_keys.iter().copied().map(h256_to_b256).collect(), + ) + }) .collect(), } } - pub fn access_list(&self) -> AccessList { AccessList::from( self.access_list .iter() .map(|(address, slots)| AccessListItem { - address: *address, - storage_keys: slots.iter().copied().collect(), + address: b160_to_h160(*address), + storage_keys: slots.iter().copied().map(b256_to_h256).collect(), }) .collect::>(), ) } } - impl Inspector for AccessListTracer { #[inline] fn step( @@ -61,10 +59,7 @@ impl Inspector for AccessListTracer { opcode::SLOAD | opcode::SSTORE => { if let Ok(slot) = interpreter.stack().peek(0) { let cur_contract = interpreter.contract.address; - self.access_list - .entry(b160_to_h160(cur_contract)) - .or_default() - .insert(H256::from_uint(&ru256_to_u256(slot))); + self.access_list.entry(cur_contract).or_default().insert(slot.into()); } } opcode::EXTCODECOPY | @@ -73,7 +68,7 @@ impl Inspector for AccessListTracer { opcode::BALANCE | opcode::SELFDESTRUCT => { if let Ok(slot) = interpreter.stack().peek(0) { - let addr: Address = H256::from_uint(&ru256_to_u256(slot)).into(); + let addr: Address = Address::from_word(slot.into()); if !self.excluded.contains(&addr) { self.access_list.entry(addr).or_default(); } @@ -81,7 +76,7 @@ impl Inspector for AccessListTracer { } opcode::DELEGATECALL | opcode::CALL | opcode::STATICCALL | opcode::CALLCODE => { if let Ok(slot) = interpreter.stack().peek(1) { - let addr: Address = H256::from_uint(&ru256_to_u256(slot)).into(); + let addr: Address = Address::from_word(slot.into()); if !self.excluded.contains(&addr) { self.access_list.entry(addr).or_default(); } @@ -89,7 +84,6 @@ impl Inspector for AccessListTracer { } _ => (), } - InstructionResult::Continue } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index ef0320b78fdbe..4bdb066e16712 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -11,6 +11,7 @@ use crate::{ }, utils::{b160_to_h160, h160_to_b160, ru256_to_u256, u256_to_ru256}, }; +use alloy_primitives::B256; use ethers::{ abi::{self, AbiEncode, RawLog, Token, Tokenizable, Tokenize}, signers::{LocalWallet, Signer}, @@ -18,7 +19,7 @@ use ethers::{ }; use foundry_config::Config; use revm::{ - primitives::{Bytecode, SpecId, B256, KECCAK_EMPTY}, + primitives::{Bytecode, SpecId, KECCAK_EMPTY}, Database, EVMData, }; use std::collections::BTreeMap; @@ -339,7 +340,7 @@ pub fn apply( ) -> Result> { let result = match call { HEVMCalls::Warp(inner) => { - data.env.block.timestamp = inner.0.into(); + data.env.block.timestamp = u256_to_ru256(inner.0); Bytes::new() } HEVMCalls::Difficulty(inner) => { @@ -349,7 +350,7 @@ pub fn apply( use `prevrandao` instead. \ For more information, please see https://eips.ethereum.org/EIPS/eip-4399" ); - data.env.block.difficulty = inner.0.into(); + data.env.block.difficulty = u256_to_ru256(inner.0); Bytes::new() } HEVMCalls::Prevrandao(inner) => { @@ -363,11 +364,11 @@ pub fn apply( Bytes::new() } HEVMCalls::Roll(inner) => { - data.env.block.number = inner.0.into(); + data.env.block.number = u256_to_ru256(inner.0); Bytes::new() } HEVMCalls::Fee(inner) => { - data.env.block.basefee = inner.0.into(); + data.env.block.basefee = u256_to_ru256(inner.0); Bytes::new() } HEVMCalls::Coinbase(inner) => { @@ -408,8 +409,10 @@ pub fn apply( trace!(address=?inner.0, code=?hex::encode(&code), "etch cheatcode"); // TODO: Does this increase gas usage? data.journaled_state.load_account(h160_to_b160(inner.0), data.db)?; - data.journaled_state - .set_code(h160_to_b160(inner.0), Bytecode::new_raw(code.0).to_checked()); + data.journaled_state.set_code( + h160_to_b160(inner.0), + Bytecode::new_raw(alloy_primitives::Bytes(code.0)).to_checked(), + ); Bytes::new() } HEVMCalls::Deal(inner) => { @@ -420,12 +423,12 @@ pub fn apply( // record the deal let record = DealRecord { address: who, - old_balance: account.info.balance.into(), + old_balance: ru256_to_u256(account.info.balance), new_balance: value, }; state.eth_deals.push(record); - account.info.balance = value.into(); + account.info.balance = u256_to_ru256(value); })?; Bytes::new() } @@ -564,7 +567,7 @@ pub fn apply( Bytes::new() } HEVMCalls::TxGasPrice(inner) => { - data.env.tx.gas_price = inner.0.into(); + data.env.tx.gas_price = u256_to_ru256(inner.0); Bytes::new() } HEVMCalls::Broadcast0(_) => { diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/src/executor/inspector/cheatcodes/expect.rs index 0f15381144bd6..0feb4f8a88323 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/expect.rs @@ -497,7 +497,9 @@ pub fn apply( .as_ref() .map_or(true, Bytecode::is_empty); if empty_bytecode { - let code = Bytecode::new_raw(bytes::Bytes::from_static(&[0u8])).to_checked(); + let code = + Bytecode::new_raw(alloy_primitives::Bytes(bytes::Bytes::from_static(&[0u8]))) + .to_checked(); data.journaled_state.set_code(h160_to_b160(inner.0), code); } state.mocked_calls.entry(inner.0).or_default().insert( diff --git a/crates/evm/src/executor/inspector/cheatcodes/fork.rs b/crates/evm/src/executor/inspector/cheatcodes/fork.rs index 234daeb053322..766457c988c43 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fork.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fork.rs @@ -4,13 +4,13 @@ use crate::{ executor::{ backend::DatabaseExt, fork::CreateFork, inspector::cheatcodes::ext::value_to_token, }, - utils::{b160_to_h160, RuntimeOrHandle}, + utils::{h160_to_b160, ru256_to_u256, u256_to_ru256, RuntimeOrHandle}, }; +use alloy_primitives::{B256, U256}; use ethers::{ abi::{self, AbiEncode, Token, Tokenizable, Tokenize}, - prelude::U256, providers::Middleware, - types::{Bytes, Filter, H256}, + types::{Bytes, Filter, U256 as eU256}, }; use foundry_abi::hevm::{EthGetLogsCall, RpcCall}; use foundry_common::ProviderBuilder; @@ -43,43 +43,49 @@ pub fn apply( HEVMCalls::CreateSelectFork2(fork) => { create_select_fork_at_transaction(state, data, fork.0.clone(), fork.1.into()) } - HEVMCalls::SelectFork(fork_id) => select_fork(state, data, fork_id.0), + HEVMCalls::SelectFork(fork_id) => select_fork(state, data, u256_to_ru256(fork_id.0)), HEVMCalls::MakePersistent0(acc) => { - data.db.add_persistent_account(acc.0); + data.db.add_persistent_account(h160_to_b160(acc.0)); Ok(Bytes::new()) } HEVMCalls::MakePersistent1(acc) => { - data.db.extend_persistent_accounts(acc.0.clone()); + data.db.extend_persistent_accounts( + (acc.0.clone().into_iter().map(h160_to_b160)).collect::>(), + ); Ok(Bytes::new()) } HEVMCalls::MakePersistent2(acc) => { - data.db.add_persistent_account(acc.0); - data.db.add_persistent_account(acc.1); + data.db.add_persistent_account(h160_to_b160(acc.0)); + data.db.add_persistent_account(h160_to_b160(acc.1)); Ok(Bytes::new()) } HEVMCalls::MakePersistent3(acc) => { - data.db.add_persistent_account(acc.0); - data.db.add_persistent_account(acc.1); - data.db.add_persistent_account(acc.2); + data.db.add_persistent_account(h160_to_b160(acc.0)); + data.db.add_persistent_account(h160_to_b160(acc.1)); + data.db.add_persistent_account(h160_to_b160(acc.2)); Ok(Bytes::new()) } - HEVMCalls::IsPersistent(acc) => Ok(data.db.is_persistent(&acc.0).encode().into()), + HEVMCalls::IsPersistent(acc) => { + Ok(data.db.is_persistent(&h160_to_b160(acc.0)).encode().into()) + } HEVMCalls::RevokePersistent0(acc) => { - data.db.remove_persistent_account(&acc.0); + data.db.remove_persistent_account(&h160_to_b160(acc.0)); Ok(Bytes::new()) } HEVMCalls::RevokePersistent1(acc) => { - data.db.remove_persistent_accounts(acc.0.clone()); + data.db.remove_persistent_accounts( + acc.0.clone().into_iter().map(h160_to_b160).collect::>(), + ); Ok(Bytes::new()) } HEVMCalls::ActiveFork(_) => data .db .active_fork_id() - .map(|id| id.encode().into()) + .map(|id| ru256_to_u256(id).encode().into()) .ok_or_else(|| fmt_err!("No active fork")), HEVMCalls::RollFork0(fork) => data .db - .roll_fork(None, fork.0, data.env, &mut data.journaled_state) + .roll_fork(None, u256_to_ru256(fork.0), data.env, &mut data.journaled_state) .map(empty) .map_err(Into::into), HEVMCalls::RollFork1(fork) => data @@ -89,13 +95,18 @@ pub fn apply( .map_err(Into::into), HEVMCalls::RollFork2(fork) => data .db - .roll_fork(Some(fork.0), fork.1, data.env, &mut data.journaled_state) + .roll_fork( + Some(fork.0).map(u256_to_ru256), + u256_to_ru256(fork.1), + data.env, + &mut data.journaled_state, + ) .map(empty) .map_err(Into::into), HEVMCalls::RollFork3(fork) => data .db .roll_fork_to_transaction( - Some(fork.0), + Some(fork.0).map(u256_to_ru256), fork.1.into(), data.env, &mut data.journaled_state, @@ -128,7 +139,7 @@ pub fn apply( Ok(urls.encode().into()) } HEVMCalls::AllowCheatcodes(addr) => { - data.db.allow_cheatcode_access(addr.0); + data.db.allow_cheatcode_access(h160_to_b160(addr.0)); Ok(Bytes::new()) } HEVMCalls::Transact0(inner) => data @@ -139,7 +150,7 @@ pub fn apply( HEVMCalls::Transact1(inner) => data .db .transact( - Some(inner.0), + Some(u256_to_ru256(inner.0)), inner.1.into(), data.env, &mut data.journaled_state, @@ -187,7 +198,7 @@ fn create_select_fork( let fork = create_fork_request(state, url_or_alias, block, data)?; let id = data.db.create_select_fork(fork, data.env, &mut data.journaled_state)?; - Ok(id.encode().into()) + Ok(ru256_to_u256(id).encode().into()) } /// Creates a new fork @@ -199,14 +210,14 @@ fn create_fork( ) -> Result { let fork = create_fork_request(state, url_or_alias, block, data)?; let id = data.db.create_fork(fork)?; - Ok(id.encode().into()) + Ok(ru256_to_u256(id).encode().into()) } /// Creates and then also selects the new fork at the given transaction fn create_select_fork_at_transaction( state: &mut Cheatcodes, data: &mut EVMData<'_, DB>, url_or_alias: String, - transaction: H256, + transaction: B256, ) -> Result { if state.broadcast.is_some() { return Err(Error::SelectForkDuringBroadcast) @@ -222,7 +233,7 @@ fn create_select_fork_at_transaction( &mut data.journaled_state, transaction, )?; - Ok(id.encode().into()) + Ok(ru256_to_u256(id).encode().into()) } /// Creates a new fork at the given transaction @@ -230,11 +241,11 @@ fn create_fork_at_transaction( state: &Cheatcodes, data: &mut EVMData<'_, DB>, url_or_alias: String, - transaction: H256, + transaction: B256, ) -> Result { let fork = create_fork_request(state, url_or_alias, None, data)?; let id = data.db.create_fork_at_transaction(fork, transaction)?; - Ok(id.encode().into()) + Ok(ru256_to_u256(id).encode().into()) } /// Creates the request object for a new fork request @@ -260,7 +271,9 @@ fn create_fork_request( /// Equivalent to eth_getLogs but on a cheatcode. fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> Result { let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; - if inner.0 > U256::from(u64::MAX) || inner.1 > U256::from(u64::MAX) { + if u256_to_ru256(inner.0) > U256::from(u64::MAX) || + u256_to_ru256(inner.1) > U256::from(u64::MAX) + { return Err(fmt_err!("Blocks in block range must be less than 2^64 - 1")) } // Cannot possibly have more than 4 topics in the topics array. @@ -269,16 +282,14 @@ fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> R } let provider = ProviderBuilder::new(url).build()?; - let mut filter = Filter::new() - .address(b160_to_h160(inner.2.into())) - .from_block(inner.0.as_u64()) - .to_block(inner.1.as_u64()); + let mut filter = + Filter::new().address(inner.2).from_block(inner.0.as_u64()).to_block(inner.1.as_u64()); for (i, item) in inner.3.iter().enumerate() { match i { - 0 => filter = filter.topic0(U256::from(item)), - 1 => filter = filter.topic1(U256::from(item)), - 2 => filter = filter.topic2(U256::from(item)), - 3 => filter = filter.topic3(U256::from(item)), + 0 => filter = filter.topic0(eU256::from(item)), + 1 => filter = filter.topic1(eU256::from(item)), + 2 => filter = filter.topic2(eU256::from(item)), + 3 => filter = filter.topic3(eU256::from(item)), _ => return Err(fmt_err!("Topics array should be less than 4 elements")), }; } diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 0e048399d4201..ba94fbb9704e3 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -10,8 +10,9 @@ use crate::{ backend::DatabaseExt, inspector::cheatcodes::env::RecordedLogs, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, }, - utils::{b160_to_h160, b256_to_h256, h160_to_b160, ru256_to_u256}, + utils::{b160_to_h160, b256_to_h256, h160_to_b160, ru256_to_u256, u256_to_ru256}, }; +use alloy_primitives::{Address as rAddress, B256}; use ethers::{ abi::{AbiDecode, AbiEncode, RawLog}, signers::LocalWallet, @@ -25,7 +26,7 @@ use foundry_utils::error::SolError; use itertools::Itertools; use revm::{ interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, - primitives::{BlockEnv, TransactTo, B160, B256}, + primitives::{BlockEnv, TransactTo}, EVMData, Inspector, }; use serde_json::Value; @@ -220,7 +221,7 @@ impl Cheatcodes { // ensure the caller is allowed to execute cheatcodes, // but only if the backend is in forking mode - data.db.ensure_cheatcode_access_forking_mode(caller)?; + data.db.ensure_cheatcode_access_forking_mode(h160_to_b160(caller))?; let opt = env::apply(self, data, caller, &decoded) .transpose() @@ -255,9 +256,7 @@ impl Cheatcodes { .unwrap_or_default(); let created_address = get_create_address(inputs, old_nonce); - if data.journaled_state.depth > 1 && - !data.db.has_cheatcode_access(b160_to_h160(inputs.caller)) - { + if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { // we only grant cheat code access for new contracts if the caller also has // cheatcode access and the new contract is created in top most call return @@ -288,7 +287,7 @@ impl Cheatcodes { // which rolls back any transfers. while let Some(record) = self.eth_deals.pop() { if let Some(acc) = data.journaled_state.state.get_mut(&h160_to_b160(record.address)) { - acc.info.balance = record.old_balance.into(); + acc.info.balance = u256_to_ru256(record.old_balance); } } } @@ -307,7 +306,7 @@ impl Inspector for Cheatcodes { data.env.block = block; } if let Some(gas_price) = self.gas_price.take() { - data.env.tx.gas_price = gas_price.into(); + data.env.tx.gas_price = u256_to_ru256(gas_price); } InstructionResult::Continue @@ -386,7 +385,7 @@ impl Inspector for Cheatcodes { .reads .entry(b160_to_h160(interpreter.contract().address)) .or_insert_with(Vec::new) - .push(key.into()); + .push(ru256_to_u256(key)); } opcode::SSTORE => { let key = try_or_continue!(interpreter.stack().peek(0)); @@ -396,12 +395,12 @@ impl Inspector for Cheatcodes { .reads .entry(b160_to_h160(interpreter.contract().address)) .or_insert_with(Vec::new) - .push(key.into()); + .push(ru256_to_u256(key)); storage_accesses .writes .entry(b160_to_h160(interpreter.contract().address)) .or_insert_with(Vec::new) - .push(key.into()); + .push(ru256_to_u256(key)); } _ => (), } @@ -541,9 +540,9 @@ impl Inspector for Cheatcodes { fn log( &mut self, _: &mut EVMData<'_, DB>, - address: &B160, + address: &rAddress, topics: &[B256], - data: &bytes::Bytes, + data: &alloy_primitives::Bytes, ) { if !self.expected_emits.is_empty() { handle_expect_emit( @@ -572,14 +571,16 @@ impl Inspector for Cheatcodes { &mut self, data: &mut EVMData<'_, DB>, call: &mut CallInputs, - ) -> (InstructionResult, Gas, bytes::Bytes) { - if call.contract == h160_to_b160(CHEATCODE_ADDRESS) { + ) -> (InstructionResult, Gas, alloy_primitives::Bytes) { + if call.contract == CHEATCODE_ADDRESS { let gas = Gas::new(call.gas_limit); match self.apply_cheatcode(data, b160_to_h160(call.context.caller), call) { - Ok(retdata) => (InstructionResult::Return, gas, retdata.0), - Err(err) => (InstructionResult::Revert, gas, err.encode_error().0), + Ok(retdata) => (InstructionResult::Return, gas, alloy_primitives::Bytes(retdata.0)), + Err(err) => { + (InstructionResult::Revert, gas, alloy_primitives::Bytes(err.encode_error().0)) + } } - } else if call.contract != h160_to_b160(HARDHAT_CONSOLE_ADDRESS) { + } else if call.contract != HARDHAT_CONSOLE_ADDRESS { // Handle expected calls // Grab the different calldatas expected. @@ -596,7 +597,7 @@ impl Inspector for Cheatcodes { // The value matches, if provided expected .value - .map_or(true, |value| value == call.transfer.value.into()) && + .map_or(true, |value| value == ru256_to_u256(call.transfer.value)) && // The gas matches, if provided expected.gas.map_or(true, |gas| gas == call.gas_limit) && // The minimum gas matches, if provided @@ -610,24 +611,25 @@ impl Inspector for Cheatcodes { // Handle mocked calls if let Some(mocks) = self.mocked_calls.get(&b160_to_h160(call.contract)) { let ctx = MockCallDataContext { - calldata: call.input.clone().into(), - value: Some(call.transfer.value.into()), + calldata: ethers::types::Bytes::from(call.input.clone().0), + value: Some(call.transfer.value).map(ru256_to_u256), }; if let Some(mock_retdata) = mocks.get(&ctx) { return ( mock_retdata.ret_type, Gas::new(call.gas_limit), - mock_retdata.data.clone().0, + alloy_primitives::Bytes(mock_retdata.data.clone().0), ) } else if let Some((_, mock_retdata)) = mocks.iter().find(|(mock, _)| { mock.calldata.len() <= call.input.len() && *mock.calldata == call.input[..mock.calldata.len()] && - mock.value.map_or(true, |value| value == call.transfer.value.into()) + mock.value + .map_or(true, |value| value == ru256_to_u256(call.transfer.value)) }) { return ( mock_retdata.ret_type, Gas::new(call.gas_limit), - mock_retdata.data.0.clone(), + alloy_primitives::Bytes(mock_retdata.data.0.clone()), ) } } @@ -688,7 +690,7 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, Gas::new(call.gas_limit), - err.encode_string().0, + alloy_primitives::Bytes(err.encode_string().0), ) } @@ -705,8 +707,8 @@ impl Inspector for Cheatcodes { transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(broadcast.new_origin), to: Some(NameOrAddress::Address(b160_to_h160(call.contract))), - value: Some(call.transfer.value.into()), - data: Some(call.input.clone().into()), + value: Some(call.transfer.value).map(ru256_to_u256), + data: Some(call.input.clone().0).map(ethers::types::Bytes), nonce: Some(account.info.nonce.into()), gas: if is_fixed_gas_limit { Some(call.gas_limit.into()) @@ -732,9 +734,9 @@ impl Inspector for Cheatcodes { } } - (InstructionResult::Continue, Gas::new(call.gas_limit), bytes::Bytes::new()) + (InstructionResult::Continue, Gas::new(call.gas_limit), alloy_primitives::Bytes::new()) } else { - (InstructionResult::Continue, Gas::new(call.gas_limit), bytes::Bytes::new()) + (InstructionResult::Continue, Gas::new(call.gas_limit), alloy_primitives::Bytes::new()) } } @@ -744,11 +746,9 @@ impl Inspector for Cheatcodes { call: &CallInputs, remaining_gas: Gas, status: InstructionResult, - retdata: bytes::Bytes, - ) -> (InstructionResult, Gas, bytes::Bytes) { - if call.contract == h160_to_b160(CHEATCODE_ADDRESS) || - call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) - { + retdata: alloy_primitives::Bytes, + ) -> (InstructionResult, Gas, alloy_primitives::Bytes) { + if call.contract == CHEATCODE_ADDRESS || call.contract == HARDHAT_CONSOLE_ADDRESS { return (status, remaining_gas, retdata) } @@ -756,7 +756,7 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, remaining_gas, - Error::custom_bytes(MAGIC_SKIP_BYTES).encode_error().0, + alloy_primitives::Bytes(Error::custom_bytes(MAGIC_SKIP_BYTES).encode_error().0), ) } @@ -792,13 +792,21 @@ impl Inspector for Cheatcodes { false, expected_revert.reason.as_ref(), status, - retdata.into(), + ethers::types::Bytes(retdata.0), ) { Err(error) => { trace!(expected=?expected_revert, ?error, ?status, "Expected revert mismatch"); - (InstructionResult::Revert, remaining_gas, error.encode_error().0) + ( + InstructionResult::Revert, + remaining_gas, + alloy_primitives::Bytes(error.encode_error().0), + ) } - Ok((_, retdata)) => (InstructionResult::Return, remaining_gas, retdata.0), + Ok((_, retdata)) => ( + InstructionResult::Return, + remaining_gas, + alloy_primitives::Bytes(retdata.0), + ), } } } @@ -946,7 +954,7 @@ impl Inspector for Cheatcodes { call.contract != test_contract { self.fork_revert_diagnostic = - data.db.diagnose_revert(b160_to_h160(call.contract), &data.journaled_state); + data.db.diagnose_revert(call.contract, &data.journaled_state); } } @@ -957,7 +965,7 @@ impl Inspector for Cheatcodes { &mut self, data: &mut EVMData<'_, DB>, call: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, bytes::Bytes) { + ) -> (InstructionResult, Option, Gas, alloy_primitives::Bytes) { // allow cheatcodes from the address of the new contract self.allow_cheatcodes_on_create(data, call); @@ -990,7 +998,7 @@ impl Inspector for Cheatcodes { InstructionResult::Revert, None, Gas::new(call.gas_limit), - err.encode_string().0, + alloy_primitives::Bytes(err.encode_string().0), ) } @@ -999,7 +1007,7 @@ impl Inspector for Cheatcodes { if data.journaled_state.depth() == broadcast.depth { let (bytecode, to, nonce) = match process_create( broadcast.new_origin, - call.init_code.clone(), + call.init_code.clone().0, data, call, ) { @@ -1009,7 +1017,7 @@ impl Inspector for Cheatcodes { InstructionResult::Revert, None, Gas::new(call.gas_limit), - err.encode_string().0, + alloy_primitives::Bytes(err.encode_string().0), ) } }; @@ -1021,7 +1029,7 @@ impl Inspector for Cheatcodes { transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(broadcast.new_origin), to, - value: Some(call.value.into()), + value: Some(call.value).map(ru256_to_u256), data: Some(bytecode.into()), nonce: Some(nonce.into()), gas: if is_fixed_gas_limit { @@ -1036,7 +1044,12 @@ impl Inspector for Cheatcodes { } } - (InstructionResult::Continue, None, Gas::new(call.gas_limit), bytes::Bytes::new()) + ( + InstructionResult::Continue, + None, + Gas::new(call.gas_limit), + alloy_primitives::Bytes::new(), + ) } fn create_end( @@ -1044,10 +1057,10 @@ impl Inspector for Cheatcodes { data: &mut EVMData<'_, DB>, _: &CreateInputs, status: InstructionResult, - address: Option, + address: Option, remaining_gas: Gas, - retdata: bytes::Bytes, - ) -> (InstructionResult, Option, Gas, bytes::Bytes) { + retdata: alloy_primitives::Bytes, + ) -> (InstructionResult, Option, Gas, alloy_primitives::Bytes) { // Clean up pranks if let Some(prank) = &self.prank { if data.journaled_state.depth() == prank.depth { @@ -1080,17 +1093,20 @@ impl Inspector for Cheatcodes { true, expected_revert.reason.as_ref(), status, - retdata.into(), + ethers::types::Bytes(retdata.0), ) { Ok((address, retdata)) => ( InstructionResult::Return, address.map(h160_to_b160), remaining_gas, - retdata.0, + alloy_primitives::Bytes(retdata.0), + ), + Err(err) => ( + InstructionResult::Revert, + None, + remaining_gas, + alloy_primitives::Bytes(err.encode_error().0), ), - Err(err) => { - (InstructionResult::Revert, None, remaining_gas, err.encode_error().0) - } } } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs b/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs index f34d61e54038e..1449155ad5afa 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs @@ -1,5 +1,9 @@ use super::Result; -use crate::{abi::HEVMCalls, executor::backend::DatabaseExt}; +use crate::{ + abi::HEVMCalls, + executor::backend::DatabaseExt, + utils::{ru256_to_u256, u256_to_ru256}, +}; use ethers::abi::AbiEncode; use revm::EVMData; @@ -8,11 +12,11 @@ use revm::EVMData; pub fn apply(data: &mut EVMData<'_, DB>, call: &HEVMCalls) -> Option { Some(match call { HEVMCalls::Snapshot(_) => { - Ok(data.db.snapshot(&data.journaled_state, data.env).encode().into()) + Ok(ru256_to_u256(data.db.snapshot(&data.journaled_state, data.env)).encode().into()) } HEVMCalls::RevertTo(snapshot) => { let res = if let Some(journaled_state) = - data.db.revert(snapshot.0, &data.journaled_state, data.env) + data.db.revert(u256_to_ru256(snapshot.0), &data.journaled_state, data.env) { // we reset the evm's journaled_state to the state of the snapshot previous state data.journaled_state = journaled_state; diff --git a/crates/evm/src/executor/inspector/cheatcodes/util.rs b/crates/evm/src/executor/inspector/cheatcodes/util.rs index 886948e7e7890..c59937a3a7c10 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/util.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/util.rs @@ -4,8 +4,9 @@ use crate::{ error::{DatabaseError, DatabaseResult}, DatabaseExt, }, - utils::{h160_to_b160, h256_to_u256_be, ru256_to_u256, u256_to_ru256}, + utils::{b160_to_h160, h160_to_b160, h256_to_u256_be, ru256_to_u256, u256_to_ru256}, }; +use alloy_primitives::Address as rAddress; use bytes::{BufMut, Bytes, BytesMut}; use ethers::{ abi::Address, @@ -27,7 +28,7 @@ use std::collections::VecDeque; pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; /// Address of the default CREATE2 deployer 0x4e59b44847b379578588920ca78fbf26c0b4956c -pub const DEFAULT_CREATE2_DEPLOYER: H160 = H160([ +pub const DEFAULT_CREATE2_DEPLOYER: rAddress = rAddress::new([ 78, 89, 180, 72, 71, 179, 121, 87, 133, 136, 146, 12, 167, 143, 191, 38, 192, 180, 149, 108, ]); @@ -44,8 +45,8 @@ pub type BroadcastableTransactions = VecDeque; pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { env.tx.caller = h160_to_b160(tx.from); env.tx.gas_limit = tx.gas.as_u64(); - env.tx.gas_price = tx.gas_price.unwrap_or_default().into(); - env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(Into::into); + env.tx.gas_price = u256_to_ru256(tx.gas_price.unwrap_or_default()); + env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(u256_to_ru256); env.tx.nonce = Some(tx.nonce.as_u64()); env.tx.access_list = tx .access_list @@ -60,8 +61,8 @@ pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { ) }) .collect(); - env.tx.value = tx.value.into(); - env.tx.data = tx.input.0.clone(); + env.tx.value = u256_to_ru256(tx.value); + env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); env.tx.transact_to = tx.to.map(h160_to_b160).map(TransactTo::Call).unwrap_or_else(TransactTo::create) } @@ -103,9 +104,9 @@ where } revm::primitives::CreateScheme::Create2 { salt } => { // Sanity checks for our CREATE2 deployer - data.journaled_state.load_account(h160_to_b160(DEFAULT_CREATE2_DEPLOYER), data.db)?; + data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?; - let info = &data.journaled_state.account(h160_to_b160(DEFAULT_CREATE2_DEPLOYER)).info; + let info = &data.journaled_state.account(DEFAULT_CREATE2_DEPLOYER).info; match &info.code { Some(code) => { if code.is_empty() { @@ -122,7 +123,7 @@ where } } - call.caller = h160_to_b160(DEFAULT_CREATE2_DEPLOYER); + call.caller = DEFAULT_CREATE2_DEPLOYER; // We have to increment the nonce of the user address, since this create2 will be done // by the create2_deployer @@ -138,7 +139,11 @@ where calldata.put_slice(&salt_bytes); calldata.put(bytecode); - Ok((calldata.freeze(), Some(NameOrAddress::Address(DEFAULT_CREATE2_DEPLOYER)), nonce)) + Ok(( + calldata.freeze(), + Some(NameOrAddress::Address(b160_to_h160(DEFAULT_CREATE2_DEPLOYER))), + nonce, + )) } } } @@ -165,8 +170,8 @@ pub fn check_if_fixed_gas_limit( // time of the call, which should be rather close to configured gas limit. // TODO: Find a way to reliably make this determination. (for example by // generating it in the compilation or evm simulation process) - U256::from(data.env.tx.gas_limit) > data.env.block.gas_limit.into() && - U256::from(call_gas_limit) <= data.env.block.gas_limit.into() + U256::from(data.env.tx.gas_limit) > ru256_to_u256(data.env.block.gas_limit) && + U256::from(call_gas_limit) <= ru256_to_u256(data.env.block.gas_limit) // Transfers in forge scripts seem to be estimated at 2300 by revm leading to "Intrinsic // gas too low" failure when simulated on chain && call_gas_limit > 2300 diff --git a/crates/evm/src/executor/inspector/debugger.rs b/crates/evm/src/executor/inspector/debugger.rs index 9c49326056dc6..2e59b1f700298 100644 --- a/crates/evm/src/executor/inspector/debugger.rs +++ b/crates/evm/src/executor/inspector/debugger.rs @@ -5,18 +5,15 @@ use crate::{ inspector::utils::{gas_used, get_create_address}, CHEATCODE_ADDRESS, }, - utils::b160_to_h160, CallKind, }; -use bytes::Bytes; -use ethers::types::Address; +use alloy_primitives::{Address, Bytes}; use foundry_utils::error::SolError; use revm::{ interpreter::{ opcode::{self, spec_opcode_gas}, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, }, - primitives::B160, EVMData, Inspector, }; @@ -82,7 +79,7 @@ impl Inspector for Debugger { self.arena.arena[self.head].steps.push(DebugStep { pc, - stack: interpreter.stack().data().iter().copied().map(|d| d.into()).collect(), + stack: interpreter.stack().data().clone(), memory: interpreter.memory.clone(), instruction: Instruction::OpCode(op), push_bytes, @@ -100,10 +97,10 @@ impl Inspector for Debugger { ) -> (InstructionResult, Gas, Bytes) { self.enter( data.journaled_state.depth() as usize, - b160_to_h160(call.context.code_address), + call.context.code_address, call.context.scheme.into(), ); - if CHEATCODE_ADDRESS == b160_to_h160(call.contract) { + if CHEATCODE_ADDRESS == call.contract { self.arena.arena[self.head].steps.push(DebugStep { memory: Memory::new(), instruction: Instruction::Cheatcode( @@ -135,11 +132,16 @@ impl Inspector for Debugger { &mut self, data: &mut EVMData<'_, DB>, call: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { // TODO: Does this increase gas cost? if let Err(err) = data.journaled_state.load_account(call.caller, data.db) { let gas = Gas::new(call.gas_limit); - return (InstructionResult::Revert, None, gas, err.encode_string().0) + return ( + InstructionResult::Revert, + None, + gas, + alloy_primitives::Bytes(err.encode_string().0), + ) } let nonce = data.journaled_state.account(call.caller).info.nonce; @@ -158,10 +160,10 @@ impl Inspector for Debugger { _: &mut EVMData<'_, DB>, _: &CreateInputs, status: InstructionResult, - address: Option, + address: Option
, gas: Gas, retdata: Bytes, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { self.exit(); (status, address, gas, retdata) diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/src/executor/inspector/fuzzer.rs index a7363614a01a2..be46192c92974 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/src/executor/inspector/fuzzer.rs @@ -2,7 +2,7 @@ use crate::{ fuzz::{invariant::RandomCallGenerator, strategies::EvmFuzzState}, utils::{self, b160_to_h160, h160_to_b160}, }; -use bytes::Bytes; +use alloy_primitives::Bytes; use revm::{ interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, Database, EVMData, Inspector, @@ -103,7 +103,7 @@ impl Fuzzer { if let Some((sender, (contract, input))) = call_generator .next(b160_to_h160(call.context.caller), b160_to_h160(call.contract)) { - call.input = input.0; + *call.input = input.0; call.context.caller = h160_to_b160(sender); call.contract = h160_to_b160(contract); diff --git a/crates/evm/src/executor/inspector/logs.rs b/crates/evm/src/executor/inspector/logs.rs index a4124d4695a62..56b9897a7aaa8 100644 --- a/crates/evm/src/executor/inspector/logs.rs +++ b/crates/evm/src/executor/inspector/logs.rs @@ -1,16 +1,15 @@ use crate::{ executor::{patch_hardhat_console_selector, HardhatConsoleCalls, HARDHAT_CONSOLE_ADDRESS}, - utils::{b160_to_h160, b256_to_h256, h160_to_b160}, + utils::{b160_to_h160, b256_to_h256}, }; -use bytes::Bytes; +use alloy_primitives::{Address, Bytes, B256}; use ethers::{ abi::{AbiDecode, Token}, - types::{Log, H256}, + types::{Bytes as ethersBytes, Log, H256}, }; use foundry_macros::ConsoleFmt; use revm::{ interpreter::{CallInputs, Gas, InstructionResult}, - primitives::{B160, B256}, Database, EVMData, Inspector, }; @@ -44,11 +43,11 @@ impl LogCollector { } impl Inspector for LogCollector { - fn log(&mut self, _: &mut EVMData<'_, DB>, address: &B160, topics: &[B256], data: &Bytes) { + fn log(&mut self, _: &mut EVMData<'_, DB>, address: &Address, topics: &[B256], data: &Bytes) { self.logs.push(Log { address: b160_to_h160(*address), topics: topics.iter().copied().map(b256_to_h256).collect(), - data: data.clone().into(), + data: ethersBytes::from(data.clone().0), ..Default::default() }); } @@ -58,7 +57,7 @@ impl Inspector for LogCollector { _: &mut EVMData<'_, DB>, call: &mut CallInputs, ) -> (InstructionResult, Gas, Bytes) { - if call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS) { + if call.contract == HARDHAT_CONSOLE_ADDRESS { let (status, reason) = self.hardhat_log(call.input.to_vec()); (status, Gas::new(call.gas_limit), reason) } else { diff --git a/crates/evm/src/executor/inspector/printer.rs b/crates/evm/src/executor/inspector/printer.rs index 0f8d9127bf87b..a4afb10373c35 100644 --- a/crates/evm/src/executor/inspector/printer.rs +++ b/crates/evm/src/executor/inspector/printer.rs @@ -1,7 +1,6 @@ -use bytes::Bytes; +use alloy_primitives::{Address, Bytes}; use revm::{ interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, - primitives::B160, Database, EVMData, Inspector, }; @@ -54,7 +53,7 @@ impl Inspector for TracePrinter { &mut self, _data: &mut EVMData<'_, DB>, inputs: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { println!( "CREATE CALL: caller:{:?}, scheme:{:?}, value:{:?}, init_code:{:?}, gas:{:?}", inputs.caller, diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index 759131d3088e2..5c97b6ca8e4f7 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -6,17 +6,15 @@ use crate::{ debug::DebugArena, executor::{backend::DatabaseExt, inspector::CoverageCollector}, trace::CallTraceArena, + utils::{h160_to_b160, ru256_to_u256}, }; -use bytes::Bytes; -use ethers::{ - signers::LocalWallet, - types::{Address, Log, U256}, -}; +use alloy_primitives::{Address, Bytes, B256, U256}; +use ethers::{signers::LocalWallet, types::Log}; use revm::{ interpreter::{ return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, Stack, }, - primitives::{BlockEnv, Env, B160, B256, U256 as rU256}, + primitives::{BlockEnv, Env}, EVMData, Inspector, }; use std::{collections::BTreeMap, sync::Arc}; @@ -229,7 +227,7 @@ impl InspectorStack { #[inline] pub fn set_env(&mut self, env: &Env) { self.set_block(&env.block); - self.set_gas_price(env.tx.gas_price.into()); + self.set_gas_price(env.tx.gas_price); } /// Sets the block for the relevant inspectors. @@ -244,7 +242,7 @@ impl InspectorStack { #[inline] pub fn set_gas_price(&mut self, gas_price: U256) { if let Some(cheatcodes) = &mut self.cheatcodes { - cheatcodes.gas_price = Some(gas_price); + cheatcodes.gas_price = Some(gas_price).map(ru256_to_u256); } } @@ -304,7 +302,14 @@ impl InspectorStack { labels: self .cheatcodes .as_ref() - .map(|cheatcodes| cheatcodes.labels.clone()) + .map(|cheatcodes| { + cheatcodes + .labels + .clone() + .into_iter() + .map(|l| (h160_to_b160(l.0), l.1)) + .collect() + }) .unwrap_or_default(), traces: self.tracer.map(|tracer| tracer.traces), debug: self.debugger.map(|debugger| debugger.arena), @@ -414,7 +419,7 @@ impl Inspector for InspectorStack { fn log( &mut self, evm_data: &mut EVMData<'_, DB>, - address: &B160, + address: &Address, topics: &[B256], data: &Bytes, ) { @@ -508,7 +513,7 @@ impl Inspector for InspectorStack { &mut self, data: &mut EVMData<'_, DB>, call: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { call_inspectors!( [ &mut self.debugger, @@ -536,10 +541,10 @@ impl Inspector for InspectorStack { data: &mut EVMData<'_, DB>, call: &CreateInputs, status: InstructionResult, - address: Option, + address: Option
, remaining_gas: Gas, retdata: Bytes, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { call_inspectors!( [ &mut self.debugger, @@ -568,7 +573,7 @@ impl Inspector for InspectorStack { (status, address, remaining_gas, retdata) } - fn selfdestruct(&mut self, contract: B160, target: B160, value: rU256) { + fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { call_inspectors!( [ &mut self.debugger, diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index 77609946c6e8a..392ae6c1a6196 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -8,17 +8,13 @@ use crate::{ utils::{b160_to_h160, b256_to_h256, ru256_to_u256}, CallKind, }; -use bytes::Bytes; -use ethers::{ - abi::RawLog, - types::{Address, U256}, -}; +use alloy_primitives::{Address, Bytes, B256, U256}; +use ethers::abi::RawLog; use revm::{ interpreter::{ opcode, return_ok, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, Interpreter, }, - primitives::{B160, B256}, Database, EVMData, Inspector, JournalEntry, }; @@ -50,12 +46,12 @@ impl Tracer { 0, CallTrace { depth, - address, + address: b160_to_h160(address), kind, data: RawOrDecodedCall::Raw(data.into()), - value, + value: ru256_to_u256(value), status: InstructionResult::Continue, - caller, + caller: b160_to_h160(caller), ..Default::default() }, )); @@ -78,7 +74,7 @@ impl Tracer { trace.output = RawOrDecodedReturnData::Raw(output.into()); if let Some(address) = address { - trace.address = address; + trace.address = b160_to_h160(address); } } @@ -128,7 +124,7 @@ impl Tracer { Some(JournalEntry::StorageChange { address, key, .. }), ) => { let value = data.journaled_state.state[address].storage[key].present_value(); - Some((ru256_to_u256(*key), value.into())) + Some((ru256_to_u256(*key), ru256_to_u256(value))) } _ => None, }; @@ -165,7 +161,7 @@ impl Inspector for Tracer { } #[inline] - fn log(&mut self, _: &mut EVMData<'_, DB>, _: &B160, topics: &[B256], data: &Bytes) { + fn log(&mut self, _: &mut EVMData<'_, DB>, _: &Address, topics: &[B256], data: &Bytes) { let node = &mut self.traces.arena[*self.trace_stack.last().expect("no ongoing trace")]; let topics: Vec<_> = topics.iter().copied().map(b256_to_h256).collect(); node.ordering.push(LogCallOrder::Log(node.logs.len())); @@ -187,11 +183,11 @@ impl Inspector for Tracer { self.start_trace( data.journaled_state.depth() as usize, - b160_to_h160(to), + to, inputs.input.to_vec(), - inputs.transfer.value.into(), + inputs.transfer.value, inputs.context.scheme.into(), - b160_to_h160(from), + from, ); (InstructionResult::Continue, Gas::new(inputs.gas_limit), Bytes::new()) @@ -221,7 +217,7 @@ impl Inspector for Tracer { &mut self, data: &mut EVMData<'_, DB>, inputs: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { // TODO: Does this increase gas cost? let _ = data.journaled_state.load_account(inputs.caller, data.db); let nonce = data.journaled_state.account(inputs.caller).info.nonce; @@ -229,9 +225,9 @@ impl Inspector for Tracer { data.journaled_state.depth() as usize, get_create_address(inputs, nonce), inputs.init_code.to_vec(), - inputs.value.into(), + inputs.value, inputs.scheme.into(), - b160_to_h160(inputs.caller), + inputs.caller, ); (InstructionResult::Continue, None, Gas::new(inputs.gas_limit), Bytes::new()) @@ -243,10 +239,10 @@ impl Inspector for Tracer { data: &mut EVMData<'_, DB>, _inputs: &CreateInputs, status: InstructionResult, - address: Option, + address: Option
, gas: Gas, retdata: Bytes, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { let code = match address { Some(address) => data .journaled_state @@ -261,7 +257,7 @@ impl Inspector for Tracer { status, gas_used(data.env.cfg.spec_id, gas.spend(), gas.refunded() as u64), code, - address.map(b160_to_h160), + address, ); (status, address, gas, retdata) diff --git a/crates/evm/src/executor/inspector/utils.rs b/crates/evm/src/executor/inspector/utils.rs index 22fecc6b7b05d..5c828e8ac9bd0 100644 --- a/crates/evm/src/executor/inspector/utils.rs +++ b/crates/evm/src/executor/inspector/utils.rs @@ -1,14 +1,10 @@ -use ethers::{ - types::Address, - utils::{get_contract_address, get_create2_address}, -}; +use alloy_primitives::{Address, B256}; + use revm::{ interpreter::CreateInputs, primitives::{CreateScheme, SpecId}, }; -use crate::utils::{b160_to_h160, ru256_to_u256}; - /// Returns [InstructionResult::Continue] on an error, discarding the error. /// /// Useful for inspectors that read state that might be invalid, but do not want to emit @@ -25,12 +21,9 @@ macro_rules! try_or_continue { /// Get the address of a contract creation pub fn get_create_address(call: &CreateInputs, nonce: u64) -> Address { match call.scheme { - CreateScheme::Create => get_contract_address(b160_to_h160(call.caller), nonce), + CreateScheme::Create => call.caller.create(nonce), CreateScheme::Create2 { salt } => { - let salt = ru256_to_u256(salt); - let mut salt_bytes = [0u8; 32]; - salt.to_big_endian(&mut salt_bytes); - get_create2_address(b160_to_h160(call.caller), salt_bytes, call.init_code.clone()) + call.caller.create2_from_code(B256::from(salt), &call.init_code) } } } diff --git a/crates/evm/src/executor/mod.rs b/crates/evm/src/executor/mod.rs index d07d1bd112c79..cc7f03c0d7d39 100644 --- a/crates/evm/src/executor/mod.rs +++ b/crates/evm/src/executor/mod.rs @@ -1,33 +1,35 @@ +//! Main Foundry executor abstractions, which can execute calls. +//! Used for running tests, scripts, and interacting with the inner backend which holds the state. + use self::inspector::{cheatcodes::util::BroadcastableTransactions, Cheatcodes, InspectorData}; use crate::{ debug::DebugArena, decode, trace::CallTraceArena, - utils::{b160_to_h160, eval_to_instruction_result, h160_to_b160, halt_to_instruction_result}, + utils::{eval_to_instruction_result, halt_to_instruction_result}, CALLER, }; pub use abi::{ patch_hardhat_console_selector, HardhatConsoleCalls, CHEATCODE_ADDRESS, CONSOLE_ABI, HARDHAT_CONSOLE_ABI, HARDHAT_CONSOLE_ADDRESS, }; +/// Reexport commonly used revm types +pub use alloy_primitives::{Address, Bytes, U256}; use backend::FuzzBackendWrapper; -use bytes::Bytes; use ethers::{ abi::{Abi, Contract, Detokenize, Function, Tokenize}, - prelude::{decode_function_data, encode_function_data, Address, U256}, + prelude::{decode_function_data, encode_function_data}, signers::LocalWallet, types::Log, }; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; use revm::primitives::hex_literal::hex; -/// Reexport commonly used revm types -pub use revm::primitives::{Env, SpecId}; pub use revm::{ db::{DatabaseCommit, DatabaseRef}, interpreter::{return_ok, CreateScheme, InstructionResult, Memory, Stack}, primitives::{ - Account, BlockEnv, Bytecode, ExecutionResult, HashMap, Output, ResultAndState, TransactTo, - TxEnv, B160, U256 as rU256, + Account, BlockEnv, Bytecode, Env, ExecutionResult, HashMap, Output, ResultAndState, SpecId, + TransactTo, TxEnv, }, }; use std::collections::BTreeMap; @@ -60,7 +62,7 @@ use crate::{ pub use builder::ExecutorBuilder; /// A mapping of addresses to their changed state. -pub type StateChangeset = HashMap; +pub type StateChangeset = HashMap; /// The initcode of the default create2 deployer. pub const DEFAULT_CREATE2_DEPLOYER_CODE: &[u8] = &hex!("604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); @@ -116,7 +118,7 @@ impl Executor { trace!("deploying local create2 deployer"); let create2_deployer_account = self .backend - .basic(h160_to_b160(DEFAULT_CREATE2_DEPLOYER))? + .basic(DEFAULT_CREATE2_DEPLOYER)? .ok_or(DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; // if the deployer is not currently deployed, deploy the default one @@ -128,7 +130,7 @@ impl Executor { self.set_balance(creator, U256::MAX)?; let res = - self.deploy(creator, DEFAULT_CREATE2_DEPLOYER_CODE.into(), U256::zero(), None)?; + self.deploy(creator, DEFAULT_CREATE2_DEPLOYER_CODE.into(), U256::ZERO, None)?; trace!(create2=?res.address, "deployed local create2 deployer"); self.set_balance(creator, initial_balance)?; @@ -139,8 +141,8 @@ impl Executor { /// Set the balance of an account. pub fn set_balance(&mut self, address: Address, amount: U256) -> DatabaseResult<&mut Self> { trace!(?address, ?amount, "setting account balance"); - let mut account = self.backend.basic(h160_to_b160(address))?.unwrap_or_default(); - account.balance = amount.into(); + let mut account = self.backend.basic(address)?.unwrap_or_default(); + account.balance = amount; self.backend.insert_account_info(address, account); Ok(self) @@ -148,16 +150,12 @@ impl Executor { /// Gets the balance of an account pub fn get_balance(&self, address: Address) -> DatabaseResult { - Ok(self - .backend - .basic(h160_to_b160(address))? - .map(|acc| acc.balance.into()) - .unwrap_or_default()) + Ok(self.backend.basic(address)?.map(|acc| acc.balance).unwrap_or_default()) } /// Set the nonce of an account. pub fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<&mut Self> { - let mut account = self.backend.basic(h160_to_b160(address))?.unwrap_or_default(); + let mut account = self.backend.basic(address)?.unwrap_or_default(); account.nonce = nonce; self.backend.insert_account_info(address, account); @@ -203,7 +201,7 @@ impl Executor { let from = from.unwrap_or(CALLER); self.backend.set_test_contract(to).set_caller(from); - let res = self.call_committing::<(), _, _>(from, to, "setUp()", (), 0.into(), None)?; + let res = self.call_committing::<(), _, _>(from, to, "setUp()", (), U256::ZERO, None)?; // record any changes made to the block's environment during setup self.env.block = res.env.block.clone(); @@ -266,7 +264,7 @@ impl Executor { calldata: Bytes, value: U256, ) -> eyre::Result { - let env = self.build_test_env(from, TransactTo::Call(h160_to_b160(to)), calldata, value); + let env = self.build_test_env(from, TransactTo::Call(to), calldata, value); let mut result = self.call_raw_with_env(env)?; self.commit(&mut result); Ok(result) @@ -286,12 +284,7 @@ impl Executor { let calldata = Bytes::from(encode_function_data(&func, args)?.to_vec()); // execute the call - let env = self.build_test_env( - from, - TransactTo::Call(h160_to_b160(test_contract)), - calldata, - value, - ); + let env = self.build_test_env(from, TransactTo::Call(test_contract), calldata, value); let call_result = self.call_raw_with_env(env)?; convert_call_result(abi, &func, call_result) } @@ -326,8 +319,7 @@ impl Executor { ) -> eyre::Result { let mut inspector = self.inspector.clone(); // Build VM - let mut env = - self.build_test_env(from, TransactTo::Call(h160_to_b160(to)), calldata, value); + let mut env = self.build_test_env(from, TransactTo::Call(to), calldata, value); let mut db = FuzzBackendWrapper::new(&self.backend); let result = db.inspect_ref(&mut env, &mut inspector)?; @@ -454,19 +446,11 @@ impl Executor { // also mark this library as persistent, this will ensure that the state of the library is // persistent across fork swaps in forking mode - self.backend.add_persistent_account(b160_to_h160(address)); + self.backend.add_persistent_account(address); trace!(address=?address, "deployed contract"); - Ok(DeployResult { - address: b160_to_h160(address), - gas_used, - gas_refunded, - logs, - traces, - debug, - env, - }) + Ok(DeployResult { address, gas_used, gas_refunded, logs, traces, debug, env }) } /// Deploys a contract and commits the new state to the underlying database. @@ -527,7 +511,7 @@ impl Executor { // we only clone the test contract and cheatcode accounts, that's all we need to evaluate // success for addr in [address, CHEATCODE_ADDRESS] { - let acc = self.backend.basic(h160_to_b160(addr))?.unwrap_or_default(); + let acc = self.backend.basic(addr)?.unwrap_or_default(); backend.insert_account_info(addr, acc); } @@ -541,8 +525,14 @@ impl Executor { let mut success = !reverted; if success { // Check if a DSTest assertion failed - let call = - executor.call::(CALLER, address, "failed()(bool)", (), 0.into(), None); + let call = executor.call::( + CALLER, + address, + "failed()(bool)", + (), + U256::ZERO, + None, + ); if let Ok(CallResult { result: failed, .. }) = call { success = !failed; @@ -569,19 +559,19 @@ impl Executor { // network conditions - the actual gas price is kept in `self.block` and is applied by // the cheatcode handler if it is enabled block: BlockEnv { - basefee: rU256::from(0), - gas_limit: self.gas_limit.into(), + basefee: U256::from(0), + gas_limit: self.gas_limit, ..self.env.block.clone() }, tx: TxEnv { - caller: h160_to_b160(caller), + caller, transact_to, data, - value: value.into(), + value, // As above, we set the gas price to 0. - gas_price: rU256::from(0), + gas_price: U256::from(0), gas_priority_fee: None, - gas_limit: self.gas_limit.as_u64(), + gas_limit: self.gas_limit.to(), ..self.env.tx.clone() }, } diff --git a/crates/evm/src/executor/opts.rs b/crates/evm/src/executor/opts.rs index eeef6924f51c4..71c0b1347dbde 100644 --- a/crates/evm/src/executor/opts.rs +++ b/crates/evm/src/executor/opts.rs @@ -1,15 +1,13 @@ -use crate::{ - executor::fork::CreateFork, - utils::{h160_to_b160, h256_to_b256, RuntimeOrHandle}, -}; +use crate::{executor::fork::CreateFork, utils::RuntimeOrHandle}; +use alloy_primitives::{Address, B256, U256}; use ethers::{ providers::{Middleware, Provider}, - types::{Address, Block, Chain, TxHash, H256, U256}, + types::{Block, Chain, TxHash}, }; use eyre::WrapErr; use foundry_common::{self, ProviderBuilder, RpcUrl, ALCHEMY_FREE_TIER_CUPS}; use foundry_config::Config; -use revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv, U256 as rU256}; +use revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}; use serde::{Deserialize, Deserializer, Serialize}; use super::fork::environment; @@ -105,19 +103,19 @@ impl EvmOpts { revm::primitives::Env { block: BlockEnv { - number: rU256::from(self.env.block_number), - coinbase: h160_to_b160(self.env.block_coinbase), - timestamp: rU256::from(self.env.block_timestamp), - difficulty: rU256::from(self.env.block_difficulty), - prevrandao: Some(h256_to_b256(self.env.block_prevrandao)), - basefee: rU256::from(self.env.block_base_fee_per_gas), - gas_limit: self.gas_limit().into(), + number: U256::from(self.env.block_number), + coinbase: self.env.block_coinbase, + timestamp: U256::from(self.env.block_timestamp), + difficulty: U256::from(self.env.block_difficulty), + prevrandao: Some(self.env.block_prevrandao), + basefee: U256::from(self.env.block_base_fee_per_gas), + gas_limit: self.gas_limit(), }, cfg, tx: TxEnv { - gas_price: rU256::from(self.env.gas_price.unwrap_or_default()), - gas_limit: self.gas_limit().as_u64(), - caller: h160_to_b160(self.sender), + gas_price: U256::from(self.env.gas_price.unwrap_or_default()), + gas_limit: self.gas_limit().to(), + caller: self.sender, ..Default::default() }, } @@ -144,7 +142,7 @@ impl EvmOpts { /// Returns the gas limit to use pub fn gas_limit(&self) -> U256 { - self.env.block_gas_limit.unwrap_or(self.env.gas_limit).into() + U256::from(self.env.block_gas_limit.unwrap_or(self.env.gas_limit)) } /// Returns the configured chain id, which will be @@ -228,7 +226,7 @@ pub struct Env { pub block_difficulty: u64, /// Previous block beacon chain random value. Before merge this field is used for mix_hash - pub block_prevrandao: H256, + pub block_prevrandao: B256, /// the block.gaslimit value during EVM execution #[serde( diff --git a/crates/evm/src/executor/snapshot.rs b/crates/evm/src/executor/snapshot.rs index a549362b101ae..d931e45f7e145 100644 --- a/crates/evm/src/executor/snapshot.rs +++ b/crates/evm/src/executor/snapshot.rs @@ -1,7 +1,7 @@ //! support for snapshotting different states -use ethers::types::U256; -use std::collections::HashMap; +use alloy_primitives::U256; +use std::{collections::HashMap, ops::Add}; /// Represents all snapshots #[derive(Debug, Clone)] @@ -15,7 +15,7 @@ pub struct Snapshots { impl Snapshots { fn next_id(&mut self) -> U256 { let id = self.id; - self.id = id.saturating_add(U256::one()); + self.id = id.saturating_add(U256::from(1)); id } @@ -32,10 +32,10 @@ impl Snapshots { let snapshot = self.snapshots.remove(&id); // revert all snapshots taken after the snapshot - let mut to_revert = id + 1; + let mut to_revert = id.add(U256::from(1)); while to_revert < self.id { self.snapshots.remove(&to_revert); - to_revert = to_revert + 1; + to_revert += U256::from(1); } snapshot @@ -66,6 +66,6 @@ impl Snapshots { impl Default for Snapshots { fn default() -> Self { - Self { id: U256::zero(), snapshots: HashMap::new() } + Self { id: U256::ZERO, snapshots: HashMap::new() } } } diff --git a/crates/evm/src/fuzz/invariant/error.rs b/crates/evm/src/fuzz/invariant/error.rs index 0f6157d329655..b917a1ca83a08 100644 --- a/crates/evm/src/fuzz/invariant/error.rs +++ b/crates/evm/src/fuzz/invariant/error.rs @@ -4,15 +4,14 @@ use crate::{ executor::{Executor, RawCallResult}, fuzz::{invariant::set_up_inner_replay, *}, trace::{load_contracts, TraceKind, Traces}, + utils::h160_to_b160, CALLER, }; -use ethers::{ - abi::Function, - types::{Address, U256}, -}; +use ethers::abi::Function; use eyre::{Result, WrapErr}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use proptest::test_runner::TestError; +use revm::primitives::U256; #[derive(Debug, Clone)] pub struct InvariantFuzzError { @@ -108,7 +107,12 @@ impl InvariantFuzzError { // Replay each call from the sequence until we break the invariant. for (sender, (addr, bytes)) in calls.iter() { let call_result = executor - .call_raw_committing(*sender, *addr, bytes.0.clone(), U256::zero()) + .call_raw_committing( + h160_to_b160(*sender), + h160_to_b160(*addr), + bytes.0.clone().into(), + U256::ZERO, + ) .expect("bad call to evm"); logs.extend(call_result.logs); @@ -134,7 +138,7 @@ impl InvariantFuzzError { // Checks the invariant. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, self.addr, func.0.clone(), U256::zero()) + .call_raw(CALLER, h160_to_b160(self.addr), func.0.clone().into(), U256::ZERO) .expect("bad call to evm"); traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); @@ -169,13 +173,18 @@ impl InvariantFuzzError { let (sender, (addr, bytes)) = details; executor - .call_raw_committing(*sender, *addr, bytes.0.clone(), 0.into()) + .call_raw_committing( + h160_to_b160(*sender), + h160_to_b160(*addr), + bytes.0.clone().into(), + U256::ZERO, + ) .expect("bad call to evm"); // Checks the invariant. If we exit before the last call, all the better. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, self.addr, func.0.clone(), 0.into()) + .call_raw(CALLER, h160_to_b160(self.addr), func.0.clone().into(), U256::ZERO) .expect("bad call to evm"); if error_call_result.reverted { diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index 4a977a934e103..a16a51c224595 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -16,13 +16,10 @@ use crate::{ }, FuzzCase, FuzzedCases, }, - utils::{get_function, h160_to_b160}, + utils::{b160_to_h160, get_function, h160_to_b160}, CALLER, }; -use ethers::{ - abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem}, - prelude::U256, -}; +use ethers::abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; @@ -32,7 +29,7 @@ use proptest::{ test_runner::{TestCaseError, TestRunner}, }; use revm::{ - primitives::{HashMap, B160}, + primitives::{Address as rAddress, HashMap, U256 as rU256}, DatabaseCommit, }; use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; @@ -151,7 +148,12 @@ impl<'a> InvariantExecutor<'a> { // Executes the call from the randomly generated sequence. let call_result = executor - .call_raw(*sender, *address, calldata.0.clone(), U256::zero()) + .call_raw( + h160_to_b160(*sender), + h160_to_b160(*address), + calldata.0.clone().into(), + rU256::ZERO, + ) .expect("could not make raw evm call"); // Collect data for fuzzing from the state changeset. @@ -422,8 +424,8 @@ impl<'a> InvariantExecutor<'a> { .into_iter() .filter(|(addr, (identifier, _))| { *addr != invariant_address && - *addr != CHEATCODE_ADDRESS && - *addr != HARDHAT_CONSOLE_ADDRESS && + *addr != b160_to_h160(CHEATCODE_ADDRESS) && + *addr != b160_to_h160(HARDHAT_CONSOLE_ADDRESS) && (selected.is_empty() || selected.contains(addr)) && (self.artifact_filters.targeted.is_empty() || self.artifact_filters.targeted.contains_key(identifier)) && @@ -565,10 +567,10 @@ impl<'a> InvariantExecutor<'a> { if let Some(func) = abi.functions().find(|func| func.name == method_name) { if let Ok(call_result) = self.executor.call::, _, _>( CALLER, - address, + h160_to_b160(address), func.clone(), (), - U256::zero(), + rU256::ZERO, Some(abi), ) { return call_result.result @@ -588,7 +590,7 @@ impl<'a> InvariantExecutor<'a> { /// before inserting it into the dictionary. Otherwise, we flood the dictionary with /// randomly generated addresses. fn collect_data( - state_changeset: &mut HashMap, + state_changeset: &mut HashMap, sender: &Address, call_result: &RawCallResult, fuzz_state: EvmFuzzState, @@ -634,10 +636,9 @@ fn can_continue( let mut call_results = None; // Detect handler assertion failures first. - let handlers_failed = targeted_contracts - .lock() - .iter() - .any(|contract| !executor.is_success(*contract.0, false, state_changeset.clone(), false)); + let handlers_failed = targeted_contracts.lock().iter().any(|contract| { + !executor.is_success(h160_to_b160(*contract.0), false, state_changeset.clone(), false) + }); // Assert invariants IFF the call did not revert and the handlers did not fail. if !call_result.reverted && !handlers_failed { diff --git a/crates/evm/src/fuzz/invariant/mod.rs b/crates/evm/src/fuzz/invariant/mod.rs index 9bd5a828f0190..38761753ecb72 100644 --- a/crates/evm/src/fuzz/invariant/mod.rs +++ b/crates/evm/src/fuzz/invariant/mod.rs @@ -4,14 +4,16 @@ use crate::{ executor::Executor, fuzz::*, trace::{load_contracts, TraceKind, Traces}, + utils::h160_to_b160, CALLER, }; use ethers::{ abi::{Abi, Function}, - types::{Address, Bytes, U256}, + types::{Address, Bytes}, }; use foundry_common::ContractsByArtifact; use parking_lot::Mutex; +use revm::primitives::U256; use std::{collections::BTreeMap, sync::Arc}; pub use proptest::test_runner::Config as FuzzConfig; @@ -67,16 +69,16 @@ pub fn assert_invariants( let mut call_result = executor .call_raw( CALLER, - invariant_contract.address, + h160_to_b160(invariant_contract.address), func.encode_input(&[]).expect("invariant should have no inputs").into(), - U256::zero(), + U256::ZERO, ) .expect("EVM error"); // This will panic and get caught by the executor let is_err = call_result.reverted || !executor.is_success( - invariant_contract.address, + h160_to_b160(invariant_contract.address), call_result.reverted, call_result.state_changeset.take().expect("we should have a state changeset"), false, @@ -119,7 +121,12 @@ pub fn replay_run( // Replay each call from the sequence until we break the invariant. for (sender, (addr, bytes)) in inputs.iter() { let call_result = executor - .call_raw_committing(*sender, *addr, bytes.0.clone(), U256::zero()) + .call_raw_committing( + h160_to_b160(*sender), + h160_to_b160(*addr), + bytes.0.clone().into(), + U256::ZERO, + ) .expect("bad call to evm"); logs.extend(call_result.logs); @@ -135,9 +142,9 @@ pub fn replay_run( let error_call_result = executor .call_raw( CALLER, - invariant_contract.address, + h160_to_b160(invariant_contract.address), func.encode_input(&[]).expect("invariant should have no inputs").into(), - U256::zero(), + U256::ZERO, ) .expect("bad call to evm"); diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index f704a0696f88c..9ff21ef33b791 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -1,9 +1,12 @@ +//! Executor wrapper which can be used for fuzzing, using [`proptest`](https://docs.rs/proptest/1.0.0/proptest/) use crate::{ coverage::HitMaps, decode::{self, decode_console_logs}, executor::{Executor, RawCallResult}, trace::CallTraceArena, + utils::{b160_to_h160, h160_to_b160}, }; +use alloy_primitives::U256; use error::{FuzzError, ASSUME_MAGIC_RETURN_CODE}; use ethers::{ abi::{Abi, Function, Token}, @@ -149,7 +152,7 @@ impl<'a> FuzzedExecutor<'a> { counterexample: None, decoded_logs: decode_console_logs(&call.logs), logs: call.logs, - labeled_addresses: call.labels, + labeled_addresses: call.labels.into_iter().map(|l| (b160_to_h160(l.0), l.1)).collect(), traces: if run_result.is_ok() { traces.into_inner() } else { call.traces.clone() }, coverage: coverage.into_inner(), }; @@ -198,7 +201,12 @@ impl<'a> FuzzedExecutor<'a> { ) -> Result { let call = self .executor - .call_raw(self.sender, address, calldata.0.clone(), 0.into()) + .call_raw( + h160_to_b160(self.sender), + h160_to_b160(address), + calldata.0.clone().into(), + U256::ZERO, + ) .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; let state_changeset = call .state_changeset @@ -223,8 +231,12 @@ impl<'a> FuzzedExecutor<'a> { .as_ref() .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); - let success = - self.executor.is_success(address, call.reverted, state_changeset.clone(), should_fail); + let success = self.executor.is_success( + h160_to_b160(address), + call.reverted, + state_changeset.clone(), + should_fail, + ); if success { Ok(FuzzOutcome::Case(CaseOutcome { diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/src/fuzz/strategies/state.rs index ba62a0eb22564..7a8439b36da9e 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/src/fuzz/strategies/state.rs @@ -100,7 +100,7 @@ pub fn build_initial_state( let mut state = FuzzDictionary::default(); for (address, account) in db.accounts.iter() { - let address: Address = (*address).into(); + let address: Address = b160_to_h160(*address); // Insert basic account information state.values_mut().insert(H256::from(address).into()); @@ -108,7 +108,7 @@ pub fn build_initial_state( if config.include_push_bytes { if let Some(code) = &account.info.code { if state.addresses_mut().insert(address) { - for push_byte in collect_push_bytes(code.bytes().clone()) { + for push_byte in collect_push_bytes(code.bytes().clone().0) { state.values_mut().insert(push_byte); } } @@ -118,8 +118,8 @@ pub fn build_initial_state( if config.include_storage { // Insert storage for (slot, value) in &account.storage { - let slot = (*slot).into(); - let value = (*value).into(); + let slot = ru256_to_u256(*slot); + let value = ru256_to_u256(*value); state.values_mut().insert(utils::u256_to_h256_be(slot).into()); state.values_mut().insert(utils::u256_to_h256_be(value).into()); // also add the value below and above the storage value to the dictionary. @@ -164,7 +164,7 @@ pub fn collect_state_from_call( // Insert push bytes if let Some(code) = &account.info.code { if state.addresses_mut().insert(b160_to_h160(*address)) { - for push_byte in collect_push_bytes(code.bytes().clone()) { + for push_byte in collect_push_bytes(code.bytes().clone().0) { state.values_mut().insert(push_byte); } } @@ -174,7 +174,7 @@ pub fn collect_state_from_call( if config.include_storage && state.state_values.len() < config.max_fuzz_dictionary_values { // Insert storage for (slot, value) in &account.storage { - let slot = (*slot).into(); + let slot = ru256_to_u256(*slot); let value = ru256_to_u256(value.present_value()); state.values_mut().insert(utils::u256_to_h256_be(slot).into()); state.values_mut().insert(utils::u256_to_h256_be(value).into()); diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 1d4d04ce89ad1..f39abbfe1fdf5 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -19,7 +19,7 @@ pub mod coverage; /// Forge test execution backends pub mod executor; -use ethers::types::{ActionType, CallType, H160}; +use ethers::types::{ActionType, CallType}; pub use executor::abi; /// Fuzzing wrapper for executors @@ -32,7 +32,10 @@ pub mod utils; pub use ethers::types::Address; pub use hashbrown; use revm::interpreter::{CallScheme, CreateScheme}; -pub use revm::{self, primitives::HashMap}; +pub use revm::{ + self, + primitives::{Address as aB160, HashMap}, +}; use serde::{Deserialize, Serialize}; /// Stores the caller address to be used as _sender_ account for: @@ -41,13 +44,13 @@ use serde::{Deserialize, Serialize}; /// /// The address was derived from `address(uint160(uint256(keccak256("foundry default caller"))))` /// and is equal to 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38. -pub const CALLER: Address = H160([ +pub const CALLER: aB160 = aB160::new([ 0x18, 0x04, 0xc8, 0xAB, 0x1F, 0x12, 0xE6, 0xbb, 0xF3, 0x89, 0x4D, 0x40, 0x83, 0xF3, 0x3E, 0x07, 0x30, 0x9D, 0x1F, 0x38, ]); /// Stores the default test contract address: 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 -pub const TEST_CONTRACT_ADDRESS: Address = H160([ +pub const TEST_CONTRACT_ADDRESS: aB160 = aB160::new([ 180, 199, 157, 171, 143, 37, 156, 122, 238, 110, 91, 42, 167, 41, 130, 24, 100, 34, 126, 132, ]); diff --git a/crates/evm/src/trace/decoder.rs b/crates/evm/src/trace/decoder.rs index 39c00e38a4d69..11db65c2fca10 100644 --- a/crates/evm/src/trace/decoder.rs +++ b/crates/evm/src/trace/decoder.rs @@ -7,6 +7,7 @@ use crate::{ decode, executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::{node::CallTraceNode, utils}, + utils::b160_to_h160, CALLER, TEST_CONTRACT_ADDRESS, }; use ethers::{ @@ -156,11 +157,11 @@ impl CallTraceDecoder { contracts: Default::default(), labels: [ - (CHEATCODE_ADDRESS, "VM".to_string()), - (HARDHAT_CONSOLE_ADDRESS, "console".to_string()), - (DEFAULT_CREATE2_DEPLOYER, "Create2Deployer".to_string()), - (CALLER, "DefaultSender".to_string()), - (TEST_CONTRACT_ADDRESS, "DefaultTestContract".to_string()), + (b160_to_h160(CHEATCODE_ADDRESS), "VM".to_string()), + (b160_to_h160(HARDHAT_CONSOLE_ADDRESS), "console".to_string()), + (b160_to_h160(DEFAULT_CREATE2_DEPLOYER), "Create2Deployer".to_string()), + (b160_to_h160(CALLER), "DefaultSender".to_string()), + (b160_to_h160(TEST_CONTRACT_ADDRESS), "DefaultTestContract".to_string()), ] .into(), @@ -256,7 +257,7 @@ impl CallTraceDecoder { if bytes.len() >= 4 { if let Some(funcs) = self.functions.get(&bytes[..SELECTOR_LEN]) { node.decode_function(funcs, &self.labels, &self.errors, self.verbosity); - } else if node.trace.address == DEFAULT_CREATE2_DEPLOYER { + } else if node.trace.address == b160_to_h160(DEFAULT_CREATE2_DEPLOYER) { node.trace.data = RawOrDecodedCall::Decoded("create2".to_string(), String::new(), vec![]); } else if let Some(identifier) = &self.signature_identifier { diff --git a/crates/evm/src/trace/mod.rs b/crates/evm/src/trace/mod.rs index af490b6448c8d..5b7365333d7c6 100644 --- a/crates/evm/src/trace/mod.rs +++ b/crates/evm/src/trace/mod.rs @@ -1,5 +1,9 @@ use crate::{ - abi::CHEATCODE_ADDRESS, debug::Instruction, trace::identifier::LocalTraceIdentifier, CallKind, + abi::CHEATCODE_ADDRESS, + debug::Instruction, + trace::identifier::LocalTraceIdentifier, + utils::{b160_to_h160, ru256_to_u256}, + CallKind, }; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; use ethers::{ @@ -429,7 +433,7 @@ impl From<&CallTraceStep> for StructLog { } else { None }, - stack: Some(step.stack.data().iter().copied().map(|data| data.into()).collect()), + stack: Some(step.stack.data().iter().copied().map(ru256_to_u256).collect()), // Filled in `CallTraceArena::geth_trace` as a result of compounding all slot changes storage: None, } @@ -596,7 +600,7 @@ impl TraceKind { /// Chooses the color of the trace depending on the destination address and status of the call. fn trace_color(trace: &CallTrace) -> Color { - if trace.address == CHEATCODE_ADDRESS { + if trace.address == b160_to_h160(CHEATCODE_ADDRESS) { Color::Blue } else if trace.success { Color::Green diff --git a/crates/evm/src/trace/node.rs b/crates/evm/src/trace/node.rs index be0c55162a113..7b9a2930e9c02 100644 --- a/crates/evm/src/trace/node.rs +++ b/crates/evm/src/trace/node.rs @@ -5,6 +5,7 @@ use crate::{ utils, utils::decode_cheatcode_outputs, CallTrace, LogCallOrder, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, }, + utils::b160_to_h160, CallKind, }; use ethers::{ @@ -109,7 +110,7 @@ impl CallTraceNode { if let RawOrDecodedCall::Raw(ref bytes) = self.trace.data { let inputs = if bytes.len() >= SELECTOR_LEN { - if self.trace.address == CHEATCODE_ADDRESS { + if self.trace.address == b160_to_h160(CHEATCODE_ADDRESS) { // Try to decode cheatcode inputs in a more custom way utils::decode_cheatcode_inputs(func, bytes, errors, verbosity).unwrap_or_else( || { @@ -136,7 +137,7 @@ impl CallTraceNode { if let RawOrDecodedReturnData::Raw(bytes) = &self.trace.output { if !bytes.is_empty() && self.trace.success { - if self.trace.address == CHEATCODE_ADDRESS { + if self.trace.address == b160_to_h160(CHEATCODE_ADDRESS) { if let Some(decoded) = funcs .iter() .find_map(|func| decode_cheatcode_outputs(func, bytes, verbosity)) diff --git a/crates/evm/src/utils.rs b/crates/evm/src/utils.rs index 23f83b2640850..ad0b0851e5dc2 100644 --- a/crates/evm/src/utils.rs +++ b/crates/evm/src/utils.rs @@ -1,6 +1,6 @@ use ethers::{ abi::{Abi, FixedBytes, Function}, - types::{Block, Chain, H256, U256}, + types::{Block, Chain, H160, H256, U256}, }; use eyre::ContextCompat; use revm::{ @@ -39,14 +39,14 @@ pub fn h256_to_u256_le(storage: H256) -> U256 { /// Small helper function to convert revm's [B160] into ethers's [H160]. #[inline] -pub fn b160_to_h160(b: revm::primitives::B160) -> ethers::types::H160 { - ethers::types::H160(b.0) +pub fn b160_to_h160(b: alloy_primitives::Address) -> ethers::types::H160 { + H160::from_slice(b.as_slice()) } /// Small helper function to convert ethers's [H160] into revm's [B160]. #[inline] -pub fn h160_to_b160(h: ethers::types::H160) -> revm::primitives::B160 { - revm::primitives::B160(h.0) +pub fn h160_to_b160(h: ethers::types::H160) -> alloy_primitives::Address { + alloy_primitives::Address::from_slice(h.as_bytes()) } /// Small helper function to convert revm's [B256] into ethers's [H256]. @@ -57,8 +57,8 @@ pub fn b256_to_h256(b: revm::primitives::B256) -> ethers::types::H256 { /// Small helper function to convert ether's [H256] into revm's [B256]. #[inline] -pub fn h256_to_b256(h: ethers::types::H256) -> revm::primitives::B256 { - revm::primitives::B256(h.0) +pub fn h256_to_b256(h: ethers::types::H256) -> alloy_primitives::B256 { + alloy_primitives::B256::from_slice(h.as_bytes()) } /// Small helper function to convert ether's [U256] into revm's [U256]. @@ -69,9 +69,15 @@ pub fn u256_to_ru256(u: ethers::types::U256) -> revm::primitives::U256 { revm::primitives::U256::from_le_bytes(buffer) } +// Small helper function to convert ethers's [U64] into alloy's [U64]. +#[inline] +pub fn u64_to_ru64(u: ethers::types::U64) -> alloy_primitives::U64 { + alloy_primitives::U64::from(u.as_u64()) +} + /// Small helper function to convert revm's [U256] into ethers's [U256]. #[inline] -pub fn ru256_to_u256(u: revm::primitives::U256) -> ethers::types::U256 { +pub fn ru256_to_u256(u: alloy_primitives::U256) -> ethers::types::U256 { ethers::types::U256::from_little_endian(&u.as_le_bytes()) } @@ -139,7 +145,7 @@ pub fn apply_chain_and_block_specific_env_changes( // `l1BlockNumber` field if let Some(l1_block_number) = block.other.get("l1BlockNumber").cloned() { if let Ok(l1_block_number) = serde_json::from_value::(l1_block_number) { - env.block.number = l1_block_number.into(); + env.block.number = u256_to_ru256(l1_block_number); } } } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 25519e290a450..9b96d44016d41 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -39,6 +39,8 @@ forge-doc.workspace = true foundry-cli.workspace = true foundry-debugger.workspace = true +alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde"] } + async-trait = "0.1" bytes = "1.4" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 0ce7fdbc40f1a..473cb59ba8a2b 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -27,6 +27,7 @@ use foundry_cli::{ }; use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; use foundry_config::{Config, SolcReq}; +use foundry_evm::utils::{b160_to_h160, ru256_to_u256}; use semver::Version; use std::{collections::HashMap, sync::mpsc::channel}; use tracing::trace; @@ -287,9 +288,9 @@ impl CoverageArgs { // Build the contract runner let env = evm_opts.evm_env().await?; let mut runner = MultiContractRunnerBuilder::default() - .initial_balance(evm_opts.initial_balance) + .initial_balance(ru256_to_u256(evm_opts.initial_balance)) .evm_spec(config.evm_spec_id()) - .sender(evm_opts.sender) + .sender(b160_to_h160(evm_opts.sender)) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) .with_test_options(TestOptions { fuzz: config.fuzz, ..Default::default() }) diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 1ed67955aba11..aee3846933c87 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -16,6 +16,7 @@ use foundry_common::{ compact_to_contract, compile::{self, ContractSources}, }; +use foundry_evm::utils::b160_to_h160; use foundry_utils::{PostLinkInput, ResolvedDependency}; use std::{collections::BTreeMap, fs, str::FromStr}; use tracing::{trace, warn}; @@ -64,7 +65,7 @@ impl ScriptArgs { project, contracts, script_config.config.parsed_libraries()?, - script_config.evm_opts.sender, + b160_to_h160(script_config.evm_opts.sender), script_config.sender_nonce, )?; diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 93aab18eac3dd..8c602180f247a 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -7,6 +7,7 @@ use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; use foundry_debugger::DebuggerArgs; +use foundry_evm::utils::b160_to_h160; use std::sync::Arc; use tracing::trace; @@ -32,8 +33,12 @@ impl ScriptArgs { if let Some(ref fork_url) = script_config.evm_opts.fork_url { // when forking, override the sender's nonce to the onchain value - script_config.sender_nonce = - foundry_utils::next_nonce(script_config.evm_opts.sender, fork_url, None).await? + script_config.sender_nonce = foundry_utils::next_nonce( + b160_to_h160(script_config.evm_opts.sender), + fork_url, + None, + ) + .await? } else { // if not forking, then ignore any pre-deployed library addresses script_config.config.libraries = Default::default(); @@ -65,8 +70,9 @@ impl ScriptArgs { // We need to execute the script even if just resuming, in case we need to collect private // keys from the execution. - let mut result = - self.execute(&mut script_config, contract, sender, &predeploy_libraries).await?; + let mut result = self + .execute(&mut script_config, contract, b160_to_h160(sender), &predeploy_libraries) + .await?; if self.resume || (self.verify && !self.broadcast) { return self @@ -160,7 +166,7 @@ impl ScriptArgs { // Add predeploy libraries to the list of broadcastable transactions. let mut lib_deploy = self.create_deploy_transactions( - script_config.evm_opts.sender, + b160_to_h160(script_config.evm_opts.sender), script_config.sender_nonce, &predeploy_libraries, &script_config.evm_opts.fork_url, @@ -350,7 +356,7 @@ impl ScriptArgs { } if let Some(wallets) = self.wallets.private_keys()? { if wallets.len() == 1 { - script_config.evm_opts.sender = wallets.get(0).unwrap().address() + script_config.evm_opts.sender = h160_to_b160(wallets.get(0).unwrap().address()) } } Ok(()) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index d084c8caa7053..39915a8b3d421 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -20,6 +20,7 @@ use forge::{ }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{shell, RpcUrl}; +use foundry_evm::utils::{b160_to_h160, ru256_to_u256}; use futures::future::join_all; use parking_lot::RwLock; use std::{collections::VecDeque, sync::Arc}; @@ -261,7 +262,12 @@ impl ScriptArgs { ( rpc.clone(), - self.prepare_runner(&mut script_config, sender, SimulationStage::OnChain).await, + self.prepare_runner( + &mut script_config, + b160_to_h160(sender), + SimulationStage::OnChain, + ) + .await, ) }) .collect::>(); @@ -316,6 +322,10 @@ impl ScriptArgs { }); } - ScriptRunner::new(builder.build(env, db), script_config.evm_opts.initial_balance, sender) + ScriptRunner::new( + builder.build(env, db), + ru256_to_u256(script_config.evm_opts.initial_balance), + sender, + ) } } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 519b35da2d570..693eed7dad0a8 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -50,6 +50,7 @@ use foundry_evm::{ cheatcodes::{util::BroadcastableTransactions, BroadcastableTransaction}, DEFAULT_CREATE2_DEPLOYER, }, + utils::h160_to_b160, }; use futures::future; use serde::{Deserialize, Serialize}; @@ -405,7 +406,7 @@ impl ScriptArgs { shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; return Ok(None) } - } else if sender != evm_opts.sender { + } else if h160_to_b160(sender) != evm_opts.sender { new_sender = Some(sender); } } @@ -550,7 +551,7 @@ impl ScriptArgs { // Find if it's a CREATE or CREATE2. Otherwise, skip transaction. if let Some(NameOrAddress::Address(to)) = to { - if *to == DEFAULT_CREATE2_DEPLOYER { + if h160_to_b160(*to) == DEFAULT_CREATE2_DEPLOYER { // Size of the salt prefix. offset = 32; } diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 1781d9f9f5d57..e088a222f1a3f 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -3,10 +3,14 @@ use ethers::types::{Address, Bytes, NameOrAddress, U256}; use eyre::Result; use forge::{ executor::{CallResult, DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, - revm::interpreter::{return_ok, InstructionResult}, + revm::{ + interpreter::{return_ok, InstructionResult}, + primitives::U256 as rU256, + }, trace::{TraceKind, Traces}, CALLER, }; +use foundry_evm::utils::{b160_to_h160, u256_to_ru256}; use tracing::log::trace; /// Represents which simulation stage is the script execution at. @@ -43,7 +47,7 @@ impl ScriptRunner { if !is_broadcast { if self.sender == Config::DEFAULT_SENDER { // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(self.sender, U256::MAX)?; + self.executor.set_balance(h160_to_b160(self.sender), rU256::MAX)?; } if need_create2_deployer { @@ -51,10 +55,10 @@ impl ScriptRunner { } } - self.executor.set_nonce(self.sender, sender_nonce.as_u64())?; + self.executor.set_nonce(h160_to_b160(self.sender), sender_nonce.as_u64())?; // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(CALLER, U256::MAX)?; + self.executor.set_balance(CALLER, rU256::MAX)?; // Deploy libraries let mut traces: Traces = libraries @@ -62,7 +66,7 @@ impl ScriptRunner { .filter_map(|code| { let DeployResult { traces, .. } = self .executor - .deploy(self.sender, code.0.clone(), 0u32.into(), None) + .deploy(h160_to_b160(self.sender), code.0.clone().into(), rU256::ZERO, None) .expect("couldn't deploy library"); traces @@ -79,11 +83,11 @@ impl ScriptRunner { .. } = self .executor - .deploy(CALLER, code.0, 0u32.into(), None) + .deploy(CALLER, code.0.into(), rU256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy script:\n{}", err))?; traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); - self.executor.set_balance(address, self.initial_balance)?; + self.executor.set_balance(address, u256_to_ru256(self.initial_balance))?; // Optionally call the `setUp` function let (success, gas_used, labeled_addresses, transactions, debug, script_wallets) = if !setup @@ -98,7 +102,7 @@ impl ScriptRunner { vec![], ) } else { - match self.executor.setup(Some(self.sender), address) { + match self.executor.setup(Some(h160_to_b160(self.sender)), address) { Ok(CallResult { reverted, traces: setup_traces, @@ -155,12 +159,15 @@ impl ScriptRunner { }; Ok(( - address, + b160_to_h160(address), ScriptResult { returned: bytes::Bytes::new(), success, gas_used, - labeled_addresses, + labeled_addresses: labeled_addresses + .into_iter() + .map(|l| (b160_to_h160(l.0), l.1)) + .collect::>(), transactions, logs, traces, @@ -182,8 +189,10 @@ impl ScriptRunner { ) -> Result<()> { if let Some(cheatcodes) = &self.executor.inspector.cheatcodes { if !cheatcodes.corrected_nonce { - self.executor - .set_nonce(self.sender, sender_initial_nonce.as_u64() + libraries_len as u64)?; + self.executor.set_nonce( + h160_to_b160(self.sender), + sender_initial_nonce.as_u64() + libraries_len as u64, + )?; } self.executor.inspector.cheatcodes.as_mut().unwrap().corrected_nonce = false; } @@ -207,13 +216,13 @@ impl ScriptRunner { self.call(from, to, calldata.unwrap_or_default(), value.unwrap_or(U256::zero()), true) } else if to.is_none() { let (address, gas_used, logs, traces, debug) = match self.executor.deploy( - from, - calldata.expect("No data for create transaction").0, - value.unwrap_or(U256::zero()), + h160_to_b160(from), + calldata.expect("No data for create transaction").0.into(), + u256_to_ru256(value.unwrap_or(U256::zero())), None, ) { Ok(DeployResult { address, gas_used, logs, traces, debug, .. }) => { - (address, gas_used, logs, traces, debug) + (b160_to_h160(address), gas_used, logs, traces, debug) } Err(EvmError::Execution(err)) => { let ExecutionErr { reason, traces, gas_used, logs, debug, .. } = *err; @@ -259,7 +268,12 @@ impl ScriptRunner { value: U256, commit: bool, ) -> Result { - let mut res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; + let mut res = self.executor.call_raw( + h160_to_b160(from), + h160_to_b160(to), + calldata.0.clone().into(), + u256_to_ru256(value), + )?; let mut gas_used = res.gas_used; // We should only need to calculate realistic gas costs when preparing to broadcast @@ -269,7 +283,12 @@ impl ScriptRunner { // Otherwise don't re-execute, or some usecases might be broken: https://github.com/foundry-rs/foundry/issues/3921 if commit { gas_used = self.search_optimal_gas_usage(&res, from, to, &calldata, value)?; - res = self.executor.call_raw_committing(from, to, calldata.0, value)?; + res = self.executor.call_raw_committing( + h160_to_b160(from), + h160_to_b160(to), + calldata.0.into(), + u256_to_ru256(value), + )?; } let RawCallResult { @@ -286,7 +305,7 @@ impl ScriptRunner { let breakpoints = res.cheatcodes.map(|cheats| cheats.breakpoints).unwrap_or_default(); Ok(ScriptResult { - returned: result, + returned: result.0, success: !reverted, gas_used, logs, @@ -298,7 +317,7 @@ impl ScriptRunner { }) .unwrap_or_default(), debug: vec![debug].into_iter().collect(), - labeled_addresses: labels, + labeled_addresses: labels.into_iter().map(|l| (b160_to_h160(l.0), l.1)).collect(), transactions, address: None, script_wallets, @@ -331,7 +350,12 @@ impl ScriptRunner { while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; self.executor.env.tx.gas_limit = mid_gas_limit; - let res = self.executor.call_raw(from, to, calldata.0.clone(), value)?; + let res = self.executor.call_raw( + h160_to_b160(from), + h160_to_b160(to), + calldata.0.clone().into(), + u256_to_ru256(value), + )?; match res.exit_reason { InstructionResult::Revert | InstructionResult::OutOfGas | diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 73d466f3a460b..2190a835ab4f5 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -8,7 +8,8 @@ use ethers::{ use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{abi::format_token_raw, RpcUrl, SELECTOR_LEN}; use foundry_evm::{ - executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::CallTraceDecoder, CallKind, + executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::CallTraceDecoder, utils::h160_to_b160, + CallKind, }; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -76,7 +77,7 @@ impl TransactionWithMetadata { // Specify if any contract was directly created with this transaction if let Some(NameOrAddress::Address(to)) = metadata.transaction.to().cloned() { - if to == DEFAULT_CREATE2_DEPLOYER { + if h160_to_b160(to) == DEFAULT_CREATE2_DEPLOYER { metadata.set_create( true, Address::from_slice(&result.returned), diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 9b44267a432e9..83e528bf1908a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -32,7 +32,10 @@ use foundry_config::{ get_available_profiles, Config, }; use foundry_debugger::DebuggerArgs; -use foundry_evm::fuzz::CounterExample; +use foundry_evm::{ + fuzz::CounterExample, + utils::{b160_to_h160, ru256_to_u256}, +}; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use tracing::trace; @@ -183,9 +186,9 @@ impl TestArgs { let mut runner_builder = MultiContractRunnerBuilder::default() .set_debug(should_debug) - .initial_balance(evm_opts.initial_balance) + .initial_balance(ru256_to_u256(evm_opts.initial_balance)) .evm_spec(config.evm_spec_id()) - .sender(evm_opts.sender) + .sender(b160_to_h160(evm_opts.sender)) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) .with_test_options(test_options.clone()); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index d610a19190a68..24d335ab33b71 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -5,6 +5,7 @@ use crate::{ use comfy_table::{presets::ASCII_MARKDOWN, *}; use ethers::types::U256; use foundry_common::{calc, TestFunctionExt}; +use foundry_evm::utils::b160_to_h160; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; @@ -46,7 +47,9 @@ impl GasReport { let node = &arena.arena[node_index]; let trace = &node.trace; - if trace.address == CHEATCODE_ADDRESS || trace.address == HARDHAT_CONSOLE_ADDRESS { + if trace.address == b160_to_h160(CHEATCODE_ADDRESS) || + trace.address == b160_to_h160(HARDHAT_CONSOLE_ADDRESS) + { return } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index ad2c2846f413d..32ebcd8fed5ca 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -13,6 +13,7 @@ use foundry_evm::{ ExecutorBuilder, }, revm, + utils::{b160_to_h160, ru256_to_u256}, }; use foundry_utils::{PostLinkInput, ResolvedDependency}; use rayon::prelude::*; @@ -207,7 +208,7 @@ impl MultiContractRunner { executor, contract, deploy_code, - self.evm_opts.initial_balance, + ru256_to_u256(self.evm_opts.initial_balance), self.sender, self.errors.as_ref(), libs, @@ -285,7 +286,7 @@ impl MultiContractRunnerBuilder { ArtifactContracts::from_iter(contracts), &mut known_contracts, Default::default(), - evm_opts.sender, + b160_to_h160(evm_opts.sender), U256::one(), &mut deployable_contracts, |post_link_input| { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index bd80de843c6c0..a7fccef0f9377 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -9,6 +9,7 @@ use foundry_evm::{ executor::EvmError, fuzz::{types::FuzzCase, CounterExample}, trace::{TraceKind, Traces}, + utils::b160_to_h160, }; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt, time::Duration}; @@ -244,7 +245,7 @@ impl TestSetup { // force the tracekind to be setup so a trace is shown. traces.extend(err.traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(err.logs); - labeled_addresses.extend(err.labels); + labeled_addresses.extend(err.labels.into_iter().map(|l| (b160_to_h160(l.0), l.1))); Self::failed_with(logs, traces, labeled_addresses, err.reason) } e => Self::failed_with( diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 1d1bd5e13ded0..d48138eabecb2 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -2,6 +2,7 @@ use crate::{ result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, }; +use alloy_primitives::U256 as rU256; use ethers::{ abi::{Abi, Function}, types::{Address, Bytes, U256}, @@ -24,6 +25,7 @@ use foundry_evm::{ CounterExample, FuzzedExecutor, }, trace::{load_contracts, TraceKind}, + utils::{b160_to_h160, h160_to_b160, u256_to_ru256}, CALLER, }; use proptest::test_runner::{TestError, TestRunner}; @@ -96,17 +98,22 @@ impl<'a> ContractRunner<'a> { trace!(?setup, "Setting test contract"); // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(self.sender, U256::MAX)?; - self.executor.set_balance(CALLER, U256::MAX)?; + self.executor.set_balance(h160_to_b160(self.sender), rU256::MAX)?; + self.executor.set_balance(CALLER, rU256::MAX)?; // We set the nonce of the deployer accounts to 1 to get the same addresses as DappTools - self.executor.set_nonce(self.sender, 1)?; + self.executor.set_nonce(h160_to_b160(self.sender), 1)?; // Deploy libraries let mut logs = Vec::new(); let mut traces = Vec::with_capacity(self.predeploy_libs.len()); for code in self.predeploy_libs.iter() { - match self.executor.deploy(self.sender, code.0.clone(), 0u32.into(), self.errors) { + match self.executor.deploy( + h160_to_b160(self.sender), + code.0.clone().into(), + rU256::ZERO, + self.errors, + ) { Ok(d) => { logs.extend(d.logs); traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); @@ -119,9 +126,9 @@ impl<'a> ContractRunner<'a> { // Deploy the test contract let address = match self.executor.deploy( - self.sender, - self.code.0.clone(), - 0u32.into(), + h160_to_b160(self.sender), + self.code.0.clone().into(), + rU256::ZERO, self.errors, ) { Ok(d) => { @@ -136,9 +143,10 @@ impl<'a> ContractRunner<'a> { // Now we set the contracts initial balance, and we also reset `self.sender`s and `CALLER`s // balance to the initial balance we want - self.executor.set_balance(address, self.initial_balance)?; - self.executor.set_balance(self.sender, self.initial_balance)?; - self.executor.set_balance(CALLER, self.initial_balance)?; + self.executor.set_balance(address, u256_to_ru256(self.initial_balance))?; + self.executor + .set_balance(h160_to_b160(self.sender), u256_to_ru256(self.initial_balance))?; + self.executor.set_balance(CALLER, u256_to_ru256(self.initial_balance))?; self.executor.deploy_create2_deployer()?; @@ -164,9 +172,18 @@ impl<'a> ContractRunner<'a> { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(setup_logs); - TestSetup { address, logs, traces, labeled_addresses, reason } + TestSetup { + address: b160_to_h160(address), + logs, + traces, + labeled_addresses: labeled_addresses + .into_iter() + .map(|l| (b160_to_h160(l.0), l.1)) + .collect(), + reason, + } } else { - TestSetup::success(address, logs, traces, Default::default()) + TestSetup::success(b160_to_h160(address), logs, traces, Default::default()) }; Ok(setup) @@ -314,11 +331,11 @@ impl<'a> ContractRunner<'a> { let mut debug_arena = None; let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = match executor.execute_test::<(), _, _>( - self.sender, - address, + h160_to_b160(self.sender), + h160_to_b160(address), func.clone(), (), - 0.into(), + rU256::ZERO, self.errors, ) { Ok(CallResult { @@ -335,14 +352,16 @@ impl<'a> ContractRunner<'a> { .. }) => { traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(new_labels); + labeled_addresses + .extend(new_labels.into_iter().map(|l| (b160_to_h160(l.0), l.1))); logs.extend(execution_logs); debug_arena = debug; (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) } Err(EvmError::Execution(err)) => { traces.extend(err.traces.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(err.labels); + labeled_addresses + .extend(err.labels.into_iter().map(|l| (b160_to_h160(l.0), l.1))); logs.extend(err.logs); ( err.reverted, @@ -379,7 +398,7 @@ impl<'a> ContractRunner<'a> { }; let success = executor.is_success( - setup.address, + h160_to_b160(setup.address), reverted, state_changeset.expect("we should have a state changeset"), should_fail, @@ -427,11 +446,11 @@ impl<'a> ContractRunner<'a> { // First, run the test normally to see if it needs to be skipped. if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<(), _, _>( - self.sender, - address, + h160_to_b160(self.sender), + h160_to_b160(address), func.clone(), (), - 0.into(), + rU256::ZERO, self.errors, ) { return TestResult { diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index f81472045d69a..6490d7076da0f 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -13,6 +13,7 @@ use foundry_config::{ }; use foundry_evm::{ decode::decode_console_logs, executor::inspector::CheatsConfig, revm::primitives::SpecId, + utils::b160_to_h160, }; use std::{ collections::BTreeMap, @@ -143,7 +144,7 @@ pub fn manifest_root() -> PathBuf { /// Builds a base runner pub fn base_runner() -> MultiContractRunnerBuilder { - MultiContractRunnerBuilder::default().sender(EVM_OPTS.sender) + MultiContractRunnerBuilder::default().sender(b160_to_h160(EVM_OPTS.sender)) } /// Builds a non-tracing runner diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index b28a3cca0c958..ac66e43a7a067 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -14,6 +14,7 @@ use foundry_evm::{ DatabaseRef, Executor, ExecutorBuilder, }, fuzz::FuzzedExecutor, + utils::{b160_to_h160, h160_to_b160, u256_to_ru256}, CALLER, }; use std::{path::PathBuf, str::FromStr}; @@ -64,13 +65,13 @@ pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { env: Env { gas_limit: 18446744073709551615, chain_id: None, - tx_origin: Config::DEFAULT_SENDER, + tx_origin: h160_to_b160(Config::DEFAULT_SENDER), block_number: 1, block_timestamp: 1, ..Default::default() }, - sender: Config::DEFAULT_SENDER, - initial_balance: U256::MAX, + sender: h160_to_b160(Config::DEFAULT_SENDER), + initial_balance: u256_to_ru256(U256::MAX), ffi: true, memory_limit: 2u64.pow(24), ..Default::default() @@ -82,7 +83,7 @@ pub fn fuzz_executor(executor: &Executor) -> FuzzedExecutor { FuzzedExecutor::new( executor, proptest::test_runner::TestRunner::new(cfg), - CALLER, + b160_to_h160(CALLER), config::test_opts().fuzz, ) } diff --git a/testdata/cheats/Fork2.t.sol b/testdata/cheats/Fork2.t.sol index 35a1309bbbf95..6d9237e9978e5 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/cheats/Fork2.t.sol @@ -225,7 +225,7 @@ contract ForkTest is DSTest { string memory path = "fixtures/Rpc/balance_params.json"; string memory file = vm.readFile(path); bytes memory result = vm.rpc("eth_getBalance", file); - assertEq(result, hex"65a221ccb194dc"); + assertEq(result, hex"34f4d7c595f11e"); } } From 71744dff7b6033e531ffcf0c97ae8f8e174fbce4 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 18 Sep 2023 12:24:46 -0400 Subject: [PATCH 0082/1963] feat(`utils`): Add primitive types conversion traits (#5846) * chore: add needed deps * feat(anvil, evm): use conv traits on minor sections to test ergonomics * implement dani suggestions --- Cargo.lock | 1 + crates/anvil/src/eth/backend/db.rs | 20 +++--- crates/evm/src/executor/backend/diagnostic.rs | 3 +- crates/utils/Cargo.toml | 2 + crates/utils/src/lib.rs | 1 + crates/utils/src/types.rs | 68 +++++++++++++++++++ 6 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 crates/utils/src/types.rs diff --git a/Cargo.lock b/Cargo.lock index 881409d99680c..64e4b68f90f22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2498,6 +2498,7 @@ dependencies = [ name = "foundry-utils" version = "0.2.0" dependencies = [ + "alloy-primitives", "const-hex", "dunce", "ethers-addressbook", diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index d64b7247bf426..fef6d55074844 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -19,9 +19,9 @@ use foundry_evm::{ primitives::{Bytecode, KECCAK_EMPTY}, Database, DatabaseCommit, }, - utils::{h160_to_b160, h256_to_b256, u256_to_ru256}, HashMap, }; +use foundry_utils::types::ToAlloy; use hash_db::HashDB; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt, path::Path}; @@ -86,7 +86,7 @@ pub trait Db: /// Sets the nonce of the given address fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()> { - let mut info = self.basic(h160_to_b160(address))?.unwrap_or_default(); + let mut info = self.basic(address.to_alloy())?.unwrap_or_default(); info.nonce = nonce; self.insert_account(address, info); Ok(()) @@ -94,15 +94,15 @@ pub trait Db: /// Sets the balance of the given address fn set_balance(&mut self, address: Address, balance: U256) -> DatabaseResult<()> { - let mut info = self.basic(h160_to_b160(address))?.unwrap_or_default(); - info.balance = u256_to_ru256(balance); + let mut info = self.basic(address.to_alloy())?.unwrap_or_default(); + info.balance = balance.to_alloy(); self.insert_account(address, info); Ok(()) } /// Sets the balance of the given address fn set_code(&mut self, address: Address, code: Bytes) -> DatabaseResult<()> { - let mut info = self.basic(h160_to_b160(address))?.unwrap_or_default(); + let mut info = self.basic(address.to_alloy())?.unwrap_or_default(); let code_hash = if code.as_ref().is_empty() { KECCAK_EMPTY } else { @@ -126,7 +126,7 @@ pub trait Db: /// Deserialize and add all chain data to the backend storage fn load_state(&mut self, state: SerializableState) -> DatabaseResult { for (addr, account) in state.accounts.into_iter() { - let old_account_nonce = DatabaseRef::basic(self, h160_to_b160(addr)) + let old_account_nonce = DatabaseRef::basic(self, addr.to_alloy()) .ok() .and_then(|acc| acc.map(|acc| acc.nonce)) .unwrap_or_default(); @@ -137,7 +137,7 @@ pub trait Db: self.insert_account( addr, AccountInfo { - balance: u256_to_ru256(account.balance), + balance: account.balance.to_alloy(), code_hash: KECCAK_EMPTY, // will be set automatically code: if account.code.0.is_empty() { None @@ -180,15 +180,15 @@ pub trait Db: /// [Backend::pending_block()](crate::eth::backend::mem::Backend::pending_block()) impl + Send + Sync + Clone + fmt::Debug> Db for CacheDB { fn insert_account(&mut self, address: Address, account: AccountInfo) { - self.insert_account_info(h160_to_b160(address), account) + self.insert_account_info(address.to_alloy(), account) } fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.insert_account_storage(h160_to_b160(address), u256_to_ru256(slot), u256_to_ru256(val)) + self.insert_account_storage(address.to_alloy(), slot.to_alloy(), val.to_alloy()) } fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.block_hashes.insert(u256_to_ru256(number), h256_to_b256(hash)); + self.block_hashes.insert(number.to_alloy(), hash.to_alloy()); } fn dump_state(&self) -> DatabaseResult> { diff --git a/crates/evm/src/executor/backend/diagnostic.rs b/crates/evm/src/executor/backend/diagnostic.rs index 10fbb43d87ec4..66e0857288661 100644 --- a/crates/evm/src/executor/backend/diagnostic.rs +++ b/crates/evm/src/executor/backend/diagnostic.rs @@ -4,6 +4,7 @@ use crate::{ }; use alloy_primitives::Address; use foundry_common::fmt::UIfmt; +use foundry_utils::types::ToEthers; use itertools::Itertools; /// Represents possible diagnostic cases on revert @@ -31,7 +32,7 @@ impl RevertDiagnostic { match self { RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => { - let contract_label = get_label(&b160_to_h160(*contract)); + let contract_label = get_label(&(*contract).to_ethers()); format!( r#"Contract {} does not exist on active fork with id `{}` diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 8d455e305fee3..740adcb86cd62 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -18,6 +18,8 @@ ethers-addressbook.workspace = true ethers-providers.workspace = true ethers-solc.workspace = true +alloy-primitives = { workspace = true, features = ["std"]} + eyre = { version = "0.6", default-features = false } futures = "0.3" glob = "0.3" diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index b361ddc0bb9ee..458fdaaea7bc0 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -26,6 +26,7 @@ pub mod error; pub mod glob; pub mod path; pub mod rpc; +pub mod types; /// Data passed to the post link handler of the linker for each linked artifact. #[derive(Debug)] diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs new file mode 100644 index 0000000000000..61aa86af72084 --- /dev/null +++ b/crates/utils/src/types.rs @@ -0,0 +1,68 @@ +//! Temporary utility conversion traits between ethers-rs and alloy types. + +use alloy_primitives::{Address, B256, U256 as AlloyU256}; +use ethers_core::types::{H160, H256, U256}; + +/// Conversion trait to easily convert from ethers-rs types to alloy primitive types. +pub trait ToAlloy { + type To; + + /// Converts the alloy type to the corresponding ethers-rs type. + fn to_alloy(self) -> Self::To; +} + +impl ToAlloy for H160 { + type To = Address; + + fn to_alloy(self) -> Self::To { + Address::from_slice(self.as_bytes()) + } +} + +impl ToAlloy for H256 { + type To = B256; + + fn to_alloy(self) -> Self::To { + B256::new(self.0) + } +} + +impl ToAlloy for U256 { + type To = AlloyU256; + + fn to_alloy(self) -> Self::To { + AlloyU256::from_limbs(self.0) + } +} + +/// Conversion trait to easily convert from alloy primitive types to ethers-rs types. +pub trait ToEthers { + type To; + + /// Converts the alloy type to the corresponding ethers-rs type. + fn to_ethers(self) -> Self::To; +} + +impl ToEthers for Address { + type To = H160; + + fn to_ethers(self) -> Self::To { + H160::from_slice(self.as_slice()) + } +} + +impl ToEthers for B256 { + type To = H256; + + fn to_ethers(self) -> Self::To { + H256(self.0) + } +} + +impl ToEthers for AlloyU256 { + type To = U256; + + fn to_ethers(self) -> Self::To { + U256::from_little_endian(&self.as_le_bytes()) + } +} From 8c1a569ae1f56f9c0e06ecf486b4a84e4f9f59aa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:17:44 -0400 Subject: [PATCH 0083/1963] chore(deps): weekly `cargo update` (#5843) Updating git repository `https://github.com/bluealloy/revm/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating anstyle v1.0.2 -> v1.0.3 Updating bumpalo v3.13.0 -> v3.14.0 Updating cargo_metadata v0.17.0 -> v0.18.0 Updating chrono v0.4.30 -> v0.4.31 Updating clap v4.4.2 -> v4.4.3 Updating ethers v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-addressbook v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-contract v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-contract-abigen v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-contract-derive v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-core v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-etherscan v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-middleware v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-providers v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-signers v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating ethers-solc v2.0.10 (https://github.com/gakonst/ethers-rs#a28c5ae9) -> #4ac0058f Updating indoc v2.0.3 -> v2.0.4 Updating libc v0.2.147 -> v0.2.148 Updating proc-macro2 v1.0.66 -> v1.0.67 Removing rustls-webpki v0.100.2 Removing rustls-webpki v0.101.4 Adding rustls-webpki v0.100.3 Adding rustls-webpki v0.101.5 Updating serde_json v1.0.106 -> v1.0.107 Updating socket2 v0.5.3 -> v0.5.4 Updating syn v2.0.32 -> v2.0.36 Adding toml v0.8.0 Adding toml_edit v0.20.0 Updating typenum v1.16.0 -> v1.17.0 Updating unicode-ident v1.0.11 -> v1.0.12 Co-authored-by: mattsse Co-authored-by: Enrique Ortiz --- Cargo.lock | 141 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64e4b68f90f22..c98d177987688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0" dependencies = [ "memchr", ] @@ -115,7 +115,7 @@ checksum = "9aa5bb468bc7c46e0c5074d418f575262ff79451242e5ac1380121ed4e23c4fd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -355,7 +355,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -366,7 +366,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -604,9 +604,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byte-slice-cast" @@ -790,9 +790,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", @@ -891,7 +891,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -1619,7 +1619,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -1758,7 +1758,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1773,7 +1773,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "ethers-core", "once_cell", @@ -1784,7 +1784,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -1802,7 +1802,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "Inflector", "const-hex", @@ -1817,15 +1817,15 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.33", - "toml 0.7.8", + "syn 2.0.37", + "toml 0.8.0", "walkdir", ] [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "Inflector", "const-hex", @@ -1834,13 +1834,13 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "arrayvec", "bytes", @@ -1859,7 +1859,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.33", + "syn 2.0.37", "tempfile", "thiserror", "tiny-keccak", @@ -1869,7 +1869,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "ethers-core", "ethers-solc", @@ -1884,7 +1884,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "async-trait", "auto_impl", @@ -1910,7 +1910,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "async-trait", "auto_impl", @@ -1948,7 +1948,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "async-trait", "coins-bip32", @@ -1975,7 +1975,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#90b87bd85be98caa8bb592b67f3f9acbc8a409cf" +source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" dependencies = [ "cfg-if", "const-hex", @@ -2062,7 +2062,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2289,7 +2289,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-macros", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2402,7 +2402,7 @@ dependencies = [ "tempfile", "thiserror", "toml 0.7.8", - "toml_edit", + "toml_edit 0.19.15", "tracing", "walkdir", ] @@ -2473,7 +2473,7 @@ version = "0.2.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2625,7 +2625,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -3447,9 +3447,9 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "inlinable_string" @@ -3932,7 +3932,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4199,7 +4199,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4303,7 +4303,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4504,7 +4504,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4553,7 +4553,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4656,7 +4656,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4694,7 +4694,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4788,7 +4788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4812,7 +4812,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -4856,7 +4856,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", "version_check", "yansi 1.0.0-rc.1", ] @@ -5780,14 +5780,14 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] name = "serde_json" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "indexmap 2.0.0", "itoa", @@ -5848,7 +5848,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -6163,7 +6163,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -6231,9 +6231,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.33" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -6348,7 +6348,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -6452,7 +6452,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -6571,7 +6571,19 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.0", ] [[package]] @@ -6596,6 +6608,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "topological-sort" version = "0.2.2" @@ -6689,7 +6714,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -6865,9 +6890,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" @@ -7116,7 +7141,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", "wasm-bindgen-shared", ] @@ -7150,7 +7175,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] From 285b5438269d125698e93c651948fd77038bdb3d Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 19 Sep 2023 07:26:48 -0400 Subject: [PATCH 0084/1963] feat: migrate formatter crate (#5851) --- Cargo.lock | 2 +- crates/fmt/Cargo.toml | 4 ++-- crates/fmt/src/formatter.rs | 4 ++-- crates/fmt/src/solang_ext/ast_eq.rs | 6 +++--- crates/fmt/src/string.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c98d177987688..cae938565febc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2258,8 +2258,8 @@ dependencies = [ name = "forge-fmt" version = "0.2.0" dependencies = [ + "alloy-primitives", "ariadne", - "ethers-core", "foundry-config", "itertools 0.11.0", "pretty_assertions", diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index fd57b6ec80bc5..1d8a5390ed7ea 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -13,8 +13,8 @@ repository.workspace = true # foundry dep foundry-config.workspace = true -# ethers -ethers-core.workspace = true +# alloy +alloy-primitives.workspace = true # parser solang-parser.workspace = true diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 9303ff768dd7d..614d93f6123ac 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -13,7 +13,7 @@ use crate::{ visit::{Visitable, Visitor}, FormatterConfig, InlineConfig, IntTypes, NumberUnderscore, }; -use ethers_core::{types::H160, utils::to_checksum}; +use alloy_primitives::Address; use foundry_config::fmt::{MultilineFuncHeaderStyle, SingleLineBlockStyle}; use itertools::{Either, Itertools}; use solang_parser::pt::ImportPath; @@ -2029,7 +2029,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Expression::HexNumberLiteral(loc, val, unit) => { // ref: https://docs.soliditylang.org/en/latest/types.html?highlight=address%20literal#address-literals let val = if val.len() == 42 { - to_checksum(&H160::from_str(val).expect(""), None) + Address::from_str(val).expect("").to_checksum(None) } else { val.to_owned() }; diff --git a/crates/fmt/src/solang_ext/ast_eq.rs b/crates/fmt/src/solang_ext/ast_eq.rs index 42383ac1c8a86..9990618df5655 100644 --- a/crates/fmt/src/solang_ext/ast_eq.rs +++ b/crates/fmt/src/solang_ext/ast_eq.rs @@ -1,11 +1,11 @@ -use ethers_core::types::{H160, I256, U256}; +use alloy_primitives::{Address, I256, U256}; use solang_parser::pt::*; use std::str::FromStr; /// Helper to convert a string number into a comparable one fn to_num(string: &str) -> I256 { if string.is_empty() { - return I256::from(0) + return I256::ZERO } string.replace('_', "").trim().parse().unwrap() } @@ -147,7 +147,7 @@ where impl AstEq for String { fn ast_eq(&self, other: &Self) -> bool { - match (H160::from_str(self), H160::from_str(other)) { + match (Address::from_str(self), Address::from_str(other)) { (Ok(left), Ok(right)) => left.eq(&right), _ => self == other, } diff --git a/crates/fmt/src/string.rs b/crates/fmt/src/string.rs index 5abfc7d3a1e92..76f3a0df6c7dc 100644 --- a/crates/fmt/src/string.rs +++ b/crates/fmt/src/string.rs @@ -1,4 +1,4 @@ -//! Helpfers for dealing with quoted strings +//! Helpers for dealing with quoted strings /// The state of a character in a string with quotable components /// This is a simplified version of the From ec3f9bd42795c9b2238b5f4c9f51997b22cc9e27 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 19 Sep 2023 09:28:52 -0400 Subject: [PATCH 0085/1963] chore: bump ethers (#5853) --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cae938565febc..6800c8d3cb8cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1758,7 +1758,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1773,7 +1773,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "ethers-core", "once_cell", @@ -1784,7 +1784,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -1802,7 +1802,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "Inflector", "const-hex", @@ -1825,7 +1825,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "Inflector", "const-hex", @@ -1840,7 +1840,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "arrayvec", "bytes", @@ -1869,7 +1869,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "ethers-core", "ethers-solc", @@ -1884,7 +1884,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "async-trait", "auto_impl", @@ -1910,7 +1910,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "async-trait", "auto_impl", @@ -1948,7 +1948,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "async-trait", "coins-bip32", @@ -1975,7 +1975,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4ac0058f50571954596cabbe13a3d57351d9adac" +source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" dependencies = [ "cfg-if", "const-hex", From 81f876129912d9ce7628d7a4cf8a31e21dc5fa88 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 19 Sep 2023 12:00:54 -0400 Subject: [PATCH 0086/1963] chore: migrate debugger crate to alloy (#5854) --- Cargo.lock | 3 ++- crates/debugger/Cargo.toml | 3 ++- crates/debugger/src/debugger.rs | 9 ++++++--- crates/debugger/src/lib.rs | 5 +++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6800c8d3cb8cc..4aa000aaba5dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2411,11 +2411,12 @@ dependencies = [ name = "foundry-debugger" version = "0.2.0" dependencies = [ + "alloy-primitives", "crossterm", - "ethers", "eyre", "foundry-common", "foundry-evm", + "foundry-utils", "ratatui", "revm", "tracing", diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index f2875467a4e5c..ec3c656d8d7e4 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -12,8 +12,9 @@ repository.workspace = true [dependencies] foundry-evm.workspace = true foundry-common.workspace = true +foundry-utils.workspace = true -ethers.workspace = true +alloy-primitives.workspace = true crossterm = "0.26" eyre = "0.6" diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index 16587c7616699..ea5770e635640 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,6 +1,7 @@ use crate::Ui; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder, utils::b160_to_h160}; +use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder}; +use foundry_utils::types::ToAlloy; use tracing::trace; use crate::{TUIExitReason, Tui}; @@ -31,11 +32,13 @@ impl DebuggerArgs<'_> { .decoder .contracts .iter() - .map(|(addr, identifier)| (*addr, get_contract_name(identifier).to_string())) + .map(|(addr, identifier)| { + ((*addr).to_alloy(), get_contract_name(identifier).to_string()) + }) .collect(); let tui = Tui::new( - flattened.into_iter().map(|i| (b160_to_h160(i.0), i.1, i.2)).collect(), + flattened.into_iter().map(|i| (i.0, i.1, i.2)).collect(), 0, identified_contracts, self.sources.clone(), diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 680b7af484219..723b78e94f271 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -1,5 +1,6 @@ #![warn(unused_crate_dependencies)] +use alloy_primitives::Address; use crossterm::{ event::{ self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, @@ -8,7 +9,6 @@ use crossterm::{ execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; -use ethers::types::Address; use eyre::Result; use foundry_common::{compile::ContractSources, evm::Breakpoints}; use foundry_evm::{ @@ -16,6 +16,7 @@ use foundry_evm::{ utils::{build_pc_ic_map, PCICMap}, CallKind, }; +use foundry_utils::types::ToAlloy; use ratatui::{ backend::{Backend, CrosstermBackend}, layout::{Alignment, Constraint, Direction, Layout, Rect}, @@ -1048,7 +1049,7 @@ impl Ui for Tui { // address with this pc) if let Some((caller, pc)) = self.breakpoints.get(&c) { for (i, (_caller, debug_steps, _)) in debug_call.iter().enumerate() { - if _caller == caller { + if _caller == &caller.to_alloy() { if let Some(step) = debug_steps.iter().position(|step| step.pc == *pc) { From ad37842abc9748622200781cfa0cd990301204e7 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 19 Sep 2023 12:43:10 -0400 Subject: [PATCH 0087/1963] feat(`evm`): Migrate `SolError` trait to use `dyn-abi`, adapt cheatcodes (#5849) * chore: add deps * feat: migrate SolError encoding trait to dyn-abi * chore: migrate cheatcodes/error --- Cargo.lock | 547 ++++++++++++++---- Cargo.toml | 4 +- crates/evm/Cargo.toml | 3 +- .../src/executor/inspector/cheatcodes/env.rs | 14 +- .../executor/inspector/cheatcodes/error.rs | 8 +- .../executor/inspector/cheatcodes/expect.rs | 30 +- .../src/executor/inspector/cheatcodes/ext.rs | 16 +- .../src/executor/inspector/cheatcodes/fork.rs | 4 +- .../src/executor/inspector/cheatcodes/fs.rs | 6 +- .../src/executor/inspector/cheatcodes/fuzz.rs | 2 +- .../executor/inspector/cheatcodes/mapping.rs | 3 +- .../src/executor/inspector/cheatcodes/mod.rs | 11 +- crates/utils/Cargo.toml | 1 + crates/utils/src/error.rs | 10 +- crates/utils/src/types.rs | 8 + 15 files changed, 510 insertions(+), 157 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4aa000aaba5dd..b8398817c54a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,6 +75,37 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy-dyn-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b954c58532b0b327fa0cc7ce7d1a6b5a1554639620d99d812e27443cb486c7" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-type-parser", + "alloy-sol-types", + "arbitrary", + "const-hex", + "derive_arbitrary", + "itoa", + "proptest", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-json-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fe46acf61ad5bd7a5c21839bb2526358382fb8a6526f7ba393bdf593e2ae43f" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", + "serde_json", +] + [[package]] name = "alloy-primitives" version = "0.3.3" @@ -82,14 +113,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" dependencies = [ "alloy-rlp", + "arbitrary", "bytes", "cfg-if", "const-hex", + "derive_arbitrary", "derive_more", "getrandom 0.2.10", "hex-literal", "itoa", "proptest", + "proptest-derive", "ruint", "serde", "tiny-keccak", @@ -113,11 +147,44 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aa5bb468bc7c46e0c5074d418f575262ff79451242e5ac1380121ed4e23c4fd" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] +[[package]] +name = "alloy-sol-macro" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7720130c58db647103587b0c39aad4e669eea261e256040301d6c7983fdbb461" +dependencies = [ + "dunce", + "heck", + "proc-macro2 1.0.67", + "quote 1.0.33", + "syn 2.0.37", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "627a32998aee7a7eedd351e9b6d4cacef9426935219a3a61befa332db1be5ca3" + +[[package]] +name = "alloy-sol-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaa7c9a4354b1ff9f1c85adf22802af046e20e4bb55e19b9dc6ca8cbc6f7f4e5" +dependencies = [ + "alloy-primitives", + "alloy-sol-macro", + "const-hex", + "serde", +] + [[package]] name = "ammonia" version = "3.3.0" @@ -304,6 +371,12 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" + [[package]] name = "ariadne" version = "0.2.0" @@ -314,6 +387,130 @@ dependencies = [ "yansi 0.5.1", ] +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm 0.3.0", + "ark-ff-macros 0.3.0", + "ark-serialize 0.3.0", + "ark-std 0.3.0", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm 0.4.2", + "ark-ff-macros 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.0", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2 1.0.67", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-std 0.3.0", + "digest 0.9.0", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-std 0.4.0", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "array-init" version = "0.0.4" @@ -353,8 +550,8 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -364,8 +561,8 @@ version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -377,7 +574,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version", + "rustc_version 0.4.0", ] [[package]] @@ -399,8 +596,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" dependencies = [ "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", ] @@ -676,7 +873,7 @@ checksum = "fb9ac64500cc83ce4b9f8dafa78186aa008c8dea77a09b94cd307fd0cd5022a8" dependencies = [ "camino", "cargo-platform", - "semver", + "semver 1.0.18", "serde", "serde_json", "thiserror", @@ -723,7 +920,7 @@ dependencies = [ "rpassword", "rusoto_core", "rusoto_kms", - "semver", + "semver 1.0.18", "serde", "serde_json", "tempfile", @@ -776,7 +973,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver", + "semver 1.0.18", "serde", "serde_json", "serial_test", @@ -889,8 +1086,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -1387,6 +1584,28 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2 1.0.67", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "derive_arbitrary" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" +dependencies = [ + "proc-macro2 1.0.67", + "quote 1.0.33", + "syn 2.0.37", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1394,9 +1613,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case", - "proc-macro2", - "quote", - "rustc_version", + "proc-macro2 1.0.67", + "quote 1.0.33", + "rustc_version 0.4.0", "syn 1.0.109", ] @@ -1617,8 +1836,8 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -1811,8 +2030,8 @@ dependencies = [ "ethers-etherscan", "eyre", "prettyplease", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "regex", "reqwest", "serde", @@ -1831,8 +2050,8 @@ dependencies = [ "const-hex", "ethers-contract-abigen", "ethers-core", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "serde_json", "syn 2.0.37", ] @@ -1863,7 +2082,7 @@ dependencies = [ "tempfile", "thiserror", "tiny-keccak", - "unicode-xid", + "unicode-xid 0.2.4", ] [[package]] @@ -1874,7 +2093,7 @@ dependencies = [ "ethers-core", "ethers-solc", "reqwest", - "semver", + "semver 1.0.18", "serde", "serde_json", "thiserror", @@ -1964,7 +2183,7 @@ dependencies = [ "rand 0.8.5", "rusoto_core", "rusoto_kms", - "semver", + "semver 1.0.18", "sha2 0.10.7", "spki", "thiserror", @@ -1993,7 +2212,7 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", - "semver", + "semver 1.0.18", "serde", "serde_json", "sha2 0.10.7", @@ -2060,8 +2279,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4caf31122bfc780557fdcd80897e95f12cc4d7217f8ac6b9d150df828a38ee8" dependencies = [ "bytes", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -2211,7 +2430,7 @@ dependencies = [ "rayon", "regex", "reqwest", - "semver", + "semver 1.0.18", "serde", "serde_json", "serial_test", @@ -2363,7 +2582,7 @@ dependencies = [ "once_cell", "regex", "reqwest", - "semver", + "semver 1.0.18", "serde", "serde_json", "tempfile", @@ -2395,7 +2614,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver", + "semver 1.0.18", "serde", "serde_json", "serde_regex", @@ -2426,6 +2645,7 @@ dependencies = [ name = "foundry-evm" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", "alloy-primitives", "auto_impl", "bytes", @@ -2446,7 +2666,7 @@ dependencies = [ "parking_lot", "proptest", "revm", - "semver", + "semver 1.0.18", "serde", "serde_json", "tempfile", @@ -2472,8 +2692,8 @@ dependencies = [ name = "foundry-macros-impl" version = "0.2.0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -2499,6 +2719,7 @@ dependencies = [ name = "foundry-utils" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", "alloy-primitives", "const-hex", "dunce", @@ -2624,8 +2845,8 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -3184,8 +3405,8 @@ dependencies = [ "log", "mac", "markup5ever", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", ] @@ -3402,8 +3623,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", ] @@ -3664,7 +3885,7 @@ dependencies = [ "string_cache", "term", "tiny-keccak", - "unicode-xid", + "unicode-xid 0.2.4", ] [[package]] @@ -3931,8 +4152,8 @@ version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -4198,8 +4419,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" dependencies = [ "proc-macro-crate", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -4265,8 +4486,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" dependencies = [ "bytes", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", ] @@ -4302,8 +4523,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -4373,8 +4594,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", ] @@ -4412,7 +4633,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.67", "syn 1.0.109", "synstructure", ] @@ -4502,9 +4723,9 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da9f0f13dac8069c139e8300a6510e3f4143ecf5259c60b116a9b271b4ca0d54" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.67", "proc-macro2-diagnostics", - "quote", + "quote 1.0.33", "syn 2.0.37", ] @@ -4552,8 +4773,8 @@ checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" dependencies = [ "pest", "pest_meta", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -4585,7 +4806,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ "futures", - "rustc_version", + "rustc_version 0.4.0", ] [[package]] @@ -4655,8 +4876,8 @@ checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" dependencies = [ "phf_generator 0.11.2", "phf_shared 0.11.2", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -4693,8 +4914,8 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -4788,7 +5009,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.67", "syn 2.0.37", ] @@ -4823,8 +5044,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", "version_check", ] @@ -4835,11 +5056,20 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "version_check", ] +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + [[package]] name = "proc-macro2" version = "1.0.67" @@ -4855,8 +5085,8 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", "version_check", "yansi 1.0.0-rc.1", @@ -4893,6 +5123,17 @@ dependencies = [ "unarray", ] +[[package]] +name = "proptest-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90b46295382dc76166cb7cf2bb4a97952464e4b7ed5a43e6cd34e1fec3349ddc" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + [[package]] name = "protobuf" version = "3.2.0" @@ -4930,13 +5171,22 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.67", ] [[package]] @@ -5310,8 +5560,8 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", ] @@ -5343,8 +5593,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" dependencies = [ "alloy-rlp", + "arbitrary", + "ark-ff 0.3.0", + "ark-ff 0.4.2", + "bytes", + "fastrlp", + "num-bigint", + "parity-scale-codec", + "primitive-types", "proptest", "rand 0.8.5", + "rlp", "ruint-macro", "serde", "valuable", @@ -5385,7 +5644,7 @@ dependencies = [ "log", "rusoto_credential", "rusoto_signature", - "rustc_version", + "rustc_version 0.4.0", "serde", "serde_json", "tokio", @@ -5444,7 +5703,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rusoto_credential", - "rustc_version", + "rustc_version 0.4.0", "serde", "sha2 0.9.9", "tokio", @@ -5462,13 +5721,22 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.18", ] [[package]] @@ -5647,8 +5915,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", ] @@ -5732,6 +6000,15 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.18" @@ -5741,6 +6018,15 @@ dependencies = [ "serde", ] +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "send_wrapper" version = "0.4.0" @@ -5779,8 +6065,8 @@ version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -5847,8 +6133,8 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -6063,7 +6349,7 @@ dependencies = [ "lalrpop-util", "phf 0.11.2", "thiserror", - "unicode-xid", + "unicode-xid 0.2.4", ] [[package]] @@ -6116,8 +6402,8 @@ checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" dependencies = [ "phf_generator 0.10.0", "phf_shared 0.10.0", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", ] [[package]] @@ -6148,8 +6434,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "rustversion", "syn 1.0.109", ] @@ -6161,8 +6447,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "rustversion", "syn 2.0.37", ] @@ -6197,7 +6483,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver", + "semver 1.0.18", "serde", "serde_json", "sha2 0.10.7", @@ -6214,19 +6500,30 @@ checksum = "2271abd7d01895a3e5bfa4b578e32f09155002ce1ec239532e297f82aafad06b" dependencies = [ "build_const", "hex", - "semver", + "semver 1.0.18", "serde_json", "svm-rs", ] +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid 0.1.0", +] + [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "unicode-ident", ] @@ -6236,11 +6533,23 @@ version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "unicode-ident", ] +[[package]] +name = "syn-solidity" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397f229dc34c7b8231b6ef85502f9ca4e3425b8625e6d403bb74779e6b1917b5" +dependencies = [ + "paste", + "proc-macro2 1.0.67", + "quote 1.0.33", + "syn 2.0.37", +] + [[package]] name = "sync_wrapper" version = "0.1.2" @@ -6253,10 +6562,10 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 1.0.109", - "unicode-xid", + "unicode-xid 0.2.4", ] [[package]] @@ -6347,8 +6656,8 @@ version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -6451,8 +6760,8 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -6713,8 +7022,8 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", ] @@ -6976,6 +7285,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -7140,8 +7455,8 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", "wasm-bindgen-shared", ] @@ -7164,7 +7479,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ - "quote", + "quote 1.0.33", "wasm-bindgen-macro-support", ] @@ -7174,8 +7489,8 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.67", + "quote 1.0.33", "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -7484,7 +7799,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version", + "rustc_version 0.4.0", "send_wrapper 0.6.0", "thiserror", "wasm-bindgen", @@ -7524,6 +7839,20 @@ name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2 1.0.67", + "quote 1.0.33", + "syn 2.0.37", +] [[package]] name = "zip" diff --git a/Cargo.toml b/Cargo.toml index faadc171fcfbe..e334b6008f44a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -149,12 +149,14 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", default-feat ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", default-features = false } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", default-features = false } +alloy-primitives = { version = "0.3", default-features = false } +alloy-dyn-abi = { version = "0.3", default-features = false} + chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.11" solang-parser = "=0.3.2" -alloy-primitives = { version = "0.3", default-features = false } #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index a12497faa0481..50455bc787002 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -49,7 +49,8 @@ revm = { workspace = true, default-features = false, features = [ "optional_no_base_fee", ] } -alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde", "getrandom"] } +alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde", "getrandom", "arbitrary", "rlp"] } +alloy-dyn-abi = { workspace = true, default-features = false, features = ["std", "arbitrary"] } # Fuzzer proptest = "1" diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index 4bdb066e16712..5afa17285ba03 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -11,13 +11,15 @@ use crate::{ }, utils::{b160_to_h160, h160_to_b160, ru256_to_u256, u256_to_ru256}, }; -use alloy_primitives::B256; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{Bytes, B256}; use ethers::{ - abi::{self, AbiEncode, RawLog, Token, Tokenizable, Tokenize}, + abi::{self, RawLog, Token, Tokenizable, Tokenize}, signers::{LocalWallet, Signer}, - types::{Address, Bytes, U256}, + types::{Address, U256}, }; use foundry_config::Config; +use foundry_utils::types::ToAlloy; use revm::{ primitives::{Bytecode, SpecId, KECCAK_EMPTY}, Database, EVMData, @@ -398,7 +400,7 @@ pub fn apply( u256_to_ru256(inner.1.into()), data.db, )?; - ru256_to_u256(val).encode().into() + DynSolValue::from(val).encode_single().into() } HEVMCalls::Cool(inner) => cool_account(data, inner.0)?, HEVMCalls::Breakpoint0(inner) => add_breakpoint(state, caller, &inner.0, true)?, @@ -542,7 +544,7 @@ pub fn apply( // we can safely unwrap because `load_account` insert inner.0 to DB. let account = data.journaled_state.state().get(&h160_to_b160(inner.0)).unwrap(); - abi::encode(&[Token::Uint(account.info.nonce.into())]).into() + DynSolValue::from(account.info.nonce).encode_single().into() } // [function getNonce(Wallet)] returns the current nonce of the Wallet's ETH address HEVMCalls::GetNonce0(inner) => { @@ -559,7 +561,7 @@ pub fn apply( // we can safely unwrap because `load_account` insert inner.0 to DB. let account = data.journaled_state.state().get(&h160_to_b160(inner.0.addr)).unwrap(); - abi::encode(&[Token::Uint(account.info.nonce.into())]).into() + DynSolValue::from(account.info.nonce.to_alloy()).encode_single().into() } HEVMCalls::ChainId(inner) => { ensure!(inner.0 <= U256::from(u64::MAX), "Chain ID must be less than 2^64 - 1"); diff --git a/crates/evm/src/executor/inspector/cheatcodes/error.rs b/crates/evm/src/executor/inspector/cheatcodes/error.rs index 5461a9fa6a0bd..5fea6a3517f50 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/error.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/error.rs @@ -1,7 +1,7 @@ use crate::executor::backend::{error::NoCheatcodeAccessError, DatabaseError}; -use ethers::{ - abi::AbiEncode, prelude::k256::ecdsa::signature::Error as SignatureError, types::Bytes, -}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::Bytes; +use ethers::prelude::k256::ecdsa::signature::Error as SignatureError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; use foundry_utils::error::{encode_error, SolError}; @@ -179,7 +179,7 @@ impl SolError for Error { fn encode_string(&self) -> Bytes { match self { Self::CustomBytes(cow) => cow_to_bytes(cow), - e => e.to_string().encode().into(), + e => DynSolValue::String(e.to_string()).encode_single().into(), } } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/src/executor/inspector/cheatcodes/expect.rs index 0feb4f8a88323..10f9983de7904 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/expect.rs @@ -1,9 +1,10 @@ use super::{bail, ensure, fmt_err, Cheatcodes, Result}; use crate::{abi::HEVMCalls, executor::backend::DatabaseExt, utils::h160_to_b160}; +use alloy_primitives::Bytes; use ethers::{ abi::{AbiDecode, RawLog}, contract::Lazy, - types::{Address, Bytes, H160, U256}, + types::{Address, H160, U256}, }; use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; use revm::{ @@ -65,8 +66,8 @@ pub fn handle_expect_revert( } // If None, accept any revert - let expected_revert = match expected_revert { - Some(x) => x, + let mut expected_revert = match expected_revert { + Some(x) => x.clone(), None => return success_return!(), }; @@ -78,24 +79,24 @@ pub fn handle_expect_revert( if actual_revert.len() >= 4 && matches!(actual_revert[..4].try_into(), Ok(ERROR_PREFIX | REVERT_PREFIX)) { - if let Ok(bytes) = Bytes::decode(&actual_revert[4..]) { - actual_revert = bytes; + if let Ok(bytes) = ethers::types::Bytes::decode(&actual_revert[4..]) { + actual_revert = bytes.0.into(); } } if actual_revert == *expected_revert { success_return!() } else { - let stringify = |data: &[u8]| { - String::decode(data) + let stringify = |data: &mut Bytes| { + String::decode(data.0.as_ref()) .ok() - .or_else(|| std::str::from_utf8(data).ok().map(ToOwned::to_owned)) + .or_else(|| std::str::from_utf8(data.as_ref()).ok().map(ToOwned::to_owned)) .unwrap_or_else(|| format!("0x{}", hex::encode(data))) }; Err(fmt_err!( "Error != expected error: {} != {}", - stringify(&actual_revert), - stringify(expected_revert), + stringify(&mut actual_revert), + stringify(&mut expected_revert), )) } } @@ -334,7 +335,7 @@ pub fn apply( let result = match call { HEVMCalls::ExpectRevert0(_) => expect_revert(state, None, data.journaled_state.depth()), HEVMCalls::ExpectRevert1(inner) => { - expect_revert(state, Some(inner.0.clone()), data.journaled_state.depth()) + expect_revert(state, Some(inner.0.clone().0.into()), data.journaled_state.depth()) } HEVMCalls::ExpectRevert2(inner) => { expect_revert(state, Some(inner.0.into()), data.journaled_state.depth()) @@ -503,8 +504,11 @@ pub fn apply( data.journaled_state.set_code(h160_to_b160(inner.0), code); } state.mocked_calls.entry(inner.0).or_default().insert( - MockCallDataContext { calldata: inner.1.clone(), value: None }, - MockCallReturnData { data: inner.2.clone(), ret_type: InstructionResult::Return }, + MockCallDataContext { calldata: inner.1.clone().0.into(), value: None }, + MockCallReturnData { + data: inner.2.clone().0.into(), + ret_type: InstructionResult::Return, + }, ); Ok(Bytes::new()) } diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index f61bcbaf6bb70..e19db71af6210 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -1,5 +1,6 @@ use super::{bail, ensure, fmt_err, util::MAGIC_SKIP_BYTES, Cheatcodes, Error, Result}; use crate::{abi::HEVMCalls, executor::inspector::cheatcodes::parse}; +use alloy_primitives::Bytes; use ethers::{ abi::{self, AbiEncode, JsonAbi, ParamType, Token}, prelude::artifacts::CompactContractBytecode, @@ -106,9 +107,9 @@ impl ArtifactBytecode { match self { ArtifactBytecode::Hardhat(inner) => Some(inner.bytecode), ArtifactBytecode::Forge(inner) => { - inner.bytecode.and_then(|bytecode| bytecode.object.into_bytes()) + inner.bytecode.and_then(|bytecode| bytecode.object.into_bytes()).map(|b| b.0.into()) } - ArtifactBytecode::Solc(inner) => inner.bytecode(), + ArtifactBytecode::Solc(inner) => inner.bytecode().map(|b| b.0.into()), ArtifactBytecode::Huff(inner) => Some(inner.bytecode), } } @@ -117,9 +118,12 @@ impl ArtifactBytecode { match self { ArtifactBytecode::Hardhat(inner) => Some(inner.deployed_bytecode), ArtifactBytecode::Forge(inner) => inner.deployed_bytecode.and_then(|bytecode| { - bytecode.bytecode.and_then(|bytecode| bytecode.object.into_bytes()) + bytecode + .bytecode + .and_then(|bytecode| bytecode.object.into_bytes()) + .map(|b| b.0.into()) }), - ArtifactBytecode::Solc(inner) => inner.deployed_bytecode(), + ArtifactBytecode::Solc(inner) => inner.deployed_bytecode().map(|b| b.0.into()), ArtifactBytecode::Huff(inner) => Some(inner.runtime), } } @@ -143,7 +147,7 @@ struct HuffArtifact { fn get_code(state: &Cheatcodes, path: &str) -> Result { let bytecode = read_bytecode(state, path)?; if let Some(bin) = bytecode.into_bytecode() { - Ok(bin.encode().into()) + Ok(bin.0.clone().encode().into()) } else { Err(fmt_err!("No bytecode for contract. Is it abstract or unlinked?")) } @@ -153,7 +157,7 @@ fn get_code(state: &Cheatcodes, path: &str) -> Result { fn get_deployed_code(state: &Cheatcodes, path: &str) -> Result { let bytecode = read_bytecode(state, path)?; if let Some(bin) = bytecode.into_deployed_bytecode() { - Ok(bin.encode().into()) + Ok(bin.0.clone().encode().into()) } else { Err(fmt_err!("No deployed bytecode for contract. Is it abstract or unlinked?")) } diff --git a/crates/evm/src/executor/inspector/cheatcodes/fork.rs b/crates/evm/src/executor/inspector/cheatcodes/fork.rs index 766457c988c43..447b04b561743 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fork.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fork.rs @@ -6,11 +6,11 @@ use crate::{ }, utils::{h160_to_b160, ru256_to_u256, u256_to_ru256, RuntimeOrHandle}, }; -use alloy_primitives::{B256, U256}; +use alloy_primitives::{Bytes, B256, U256}; use ethers::{ abi::{self, AbiEncode, Token, Tokenizable, Tokenize}, providers::Middleware, - types::{Bytes, Filter, U256 as eU256}, + types::{Filter, U256 as eU256}, }; use foundry_abi::hevm::{EthGetLogsCall, RpcCall}; use foundry_common::ProviderBuilder; diff --git a/crates/evm/src/executor/inspector/cheatcodes/fs.rs b/crates/evm/src/executor/inspector/cheatcodes/fs.rs index 31ed6cc9d42d9..19a85d5f4227a 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fs.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fs.rs @@ -1,9 +1,7 @@ use super::{Cheatcodes, Result}; use crate::abi::hevm::{DirEntry, FsMetadata, HEVMCalls}; -use ethers::{ - abi::{self, AbiEncode, Token, Tokenize}, - types::Bytes, -}; +use alloy_primitives::Bytes; +use ethers::abi::{self, AbiEncode, Token, Tokenize}; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; use std::{ diff --git a/crates/evm/src/executor/inspector/cheatcodes/fuzz.rs b/crates/evm/src/executor/inspector/cheatcodes/fuzz.rs index 6ed597d574d49..e833abdb402e2 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fuzz.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fuzz.rs @@ -1,6 +1,6 @@ use super::{Error, Result}; use crate::{abi::HEVMCalls, fuzz::error::ASSUME_MAGIC_RETURN_CODE}; -use ethers::types::Bytes; +use alloy_primitives::Bytes; #[instrument(level = "error", name = "fuzz", target = "evm::cheatcodes", skip_all)] pub fn apply(call: &HEVMCalls) -> Option { diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index 52eaae37801d5..4d34b5f3373fb 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -1,8 +1,9 @@ use super::Cheatcodes; use crate::utils::{b160_to_h160, ru256_to_u256}; +use alloy_primitives::Bytes; use ethers::{ abi::{self, Token}, - types::{Address, Bytes, U256}, + types::{Address, U256}, utils::keccak256, }; use revm::{ diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index ba94fbb9704e3..58a85fdda8a73 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -12,13 +12,12 @@ use crate::{ }, utils::{b160_to_h160, b256_to_h256, h160_to_b160, ru256_to_u256, u256_to_ru256}, }; -use alloy_primitives::{Address as rAddress, B256}; +use alloy_primitives::{Address as rAddress, Bytes, B256}; use ethers::{ abi::{AbiDecode, AbiEncode, RawLog}, signers::LocalWallet, types::{ - transaction::eip2718::TypedTransaction, Address, Bytes, NameOrAddress, TransactionRequest, - U256, + transaction::eip2718::TypedTransaction, Address, NameOrAddress, TransactionRequest, U256, }, }; use foundry_common::evm::Breakpoints; @@ -611,7 +610,7 @@ impl Inspector for Cheatcodes { // Handle mocked calls if let Some(mocks) = self.mocked_calls.get(&b160_to_h160(call.contract)) { let ctx = MockCallDataContext { - calldata: ethers::types::Bytes::from(call.input.clone().0), + calldata: call.input.clone().0.into(), value: Some(call.transfer.value).map(ru256_to_u256), }; if let Some(mock_retdata) = mocks.get(&ctx) { @@ -792,7 +791,7 @@ impl Inspector for Cheatcodes { false, expected_revert.reason.as_ref(), status, - ethers::types::Bytes(retdata.0), + retdata, ) { Err(error) => { trace!(expected=?expected_revert, ?error, ?status, "Expected revert mismatch"); @@ -1093,7 +1092,7 @@ impl Inspector for Cheatcodes { true, expected_revert.reason.as_ref(), status, - ethers::types::Bytes(retdata.0), + retdata, ) { Ok((address, retdata)) => ( InstructionResult::Return, diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 740adcb86cd62..4240bf42508d3 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -19,6 +19,7 @@ ethers-providers.workspace = true ethers-solc.workspace = true alloy-primitives = { workspace = true, features = ["std"]} +alloy-dyn-abi = { workspace = true, features = ["std"]} eyre = { version = "0.6", default-features = false } futures = "0.3" diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index e92dee054d157..5e0cdad185401 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -1,6 +1,7 @@ //! error handling and support -use ethers_core::{abi::AbiEncode, types::Bytes}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::Bytes; use std::fmt::Display; /// Solidity revert prefix. @@ -26,11 +27,14 @@ pub trait SolError: std::error::Error { /// /// See also [`AbiEncode`](ethers::abi::AbiEncode) fn encode_string(&self) -> Bytes { - self.to_string().encode().into() + let err = DynSolValue::from(self.to_string()); + err.encode_single().into() } } /// Encodes the given messages as solidity custom error pub fn encode_error(reason: impl Display) -> Bytes { - [ERROR_PREFIX.as_slice(), reason.to_string().encode().as_slice()].concat().into() + [ERROR_PREFIX.as_slice(), DynSolValue::String(reason.to_string()).encode_single().as_slice()] + .concat() + .into() } diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index 61aa86af72084..5f3efb593ead0 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -35,6 +35,14 @@ impl ToAlloy for U256 { } } +impl ToAlloy for u64 { + type To = AlloyU256; + + fn to_alloy(self) -> Self::To { + AlloyU256::from(self) + } +} + /// Conversion trait to easily convert from alloy primitive types to ethers-rs types. pub trait ToEthers { type To; From aeefc742064d1d3c6423cc05b453ffb594451921 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 20 Sep 2023 03:05:15 -0400 Subject: [PATCH 0088/1963] chore: bump revm + accomodate cancun struct changes (#5858) --- Cargo.lock | 118 ++++++++++++++++++- crates/anvil/core/src/eth/transaction/mod.rs | 3 + crates/anvil/src/config.rs | 1 + crates/anvil/src/eth/backend/mem/mod.rs | 5 + crates/anvil/src/eth/error.rs | 26 ++++ crates/evm/src/executor/fork/init.rs | 1 + crates/evm/src/executor/opts.rs | 1 + 7 files changed, 151 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8398817c54a1..b70dff174dea5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -702,6 +702,29 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.4.0", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2 1.0.67", + "quote 1.0.33", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.37", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -763,6 +786,18 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blst" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + [[package]] name = "bs58" version = "0.5.0" @@ -847,6 +882,19 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "c-kzg" +version = "0.1.0" +source = "git+https://github.com/ethereum/c-kzg-4844#fbef59a3f9e8fa998bdb5069d212daf83d586aa5" +dependencies = [ + "bindgen", + "blst", + "cc", + "glob", + "hex", + "libc", +] + [[package]] name = "camino" version = "1.1.6" @@ -946,6 +994,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -1035,6 +1092,17 @@ dependencies = [ "inout", ] +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "4.4.3" @@ -3903,6 +3971,12 @@ dependencies = [ "spin", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.148" @@ -3921,6 +3995,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + [[package]] name = "libm" version = "0.2.7" @@ -4729,6 +4813,12 @@ dependencies = [ "syn 2.0.37", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "pem" version = "1.1.1" @@ -5455,7 +5545,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" dependencies = [ "auto_impl", "revm-interpreter", @@ -5467,7 +5557,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" dependencies = [ "derive_more", "enumn", @@ -5478,21 +5568,24 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" dependencies = [ + "c-kzg", + "hex", "k256", "num", "once_cell", "revm-primitives", "ripemd", "sha2 0.10.7", + "sha3", "substrate-bn", ] [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#5845079baf8df56f624a1ecae579a05f8423a2df" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -5500,11 +5593,13 @@ dependencies = [ "bitflags 2.4.0", "bitvec", "bytes", + "c-kzg", "derive_more", "enumn", "hashbrown 0.14.0", "hex", "hex-literal", + "once_cell", "primitive-types", "serde", ] @@ -5715,6 +5810,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -6671,6 +6772,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.28" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index ae3fd15983d07..159471613c3bf 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1209,6 +1209,7 @@ impl PendingTransaction { gas_priority_fee: None, gas_limit: gas_limit.as_u64(), access_list: vec![], + ..Default::default() } } TypedTransaction::EIP2930(tx) => { @@ -1234,6 +1235,7 @@ impl PendingTransaction { gas_priority_fee: None, gas_limit: gas_limit.as_u64(), access_list: to_revm_access_list(access_list.0.clone()), + ..Default::default() } } TypedTransaction::EIP1559(tx) => { @@ -1260,6 +1262,7 @@ impl PendingTransaction { gas_priority_fee: Some(u256_to_ru256(*max_priority_fee_per_gas)), gas_limit: gas_limit.as_u64(), access_list: to_revm_access_list(access_list.0.clone()), + ..Default::default() } } } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 1f33c17890743..15f3833926daf 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -894,6 +894,7 @@ latest block number: {latest_block}" // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, + ..Default::default() }; // apply changes such as difficulty -> prevrandao diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ec0f7a3a64c66..b04dde23f98c9 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -376,6 +376,7 @@ impl Backend { // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, + ..Default::default() }; self.time.reset(ru256_to_u256(env.block.timestamp).as_u64()); @@ -1035,6 +1036,7 @@ impl Backend { chain_id: None, nonce: nonce.map(|n| n.as_u64()), access_list: to_revm_access_list(access_list.unwrap_or_default()), + ..Default::default() }; if env.block.basefee == revm::primitives::U256::ZERO { @@ -1068,6 +1070,7 @@ impl Backend { } EVMError::PrevrandaoNotSet => return Err(BlockchainError::PrevrandaoNotSet), EVMError::Database(e) => return Err(BlockchainError::DatabaseError(e)), + EVMError::ExcessBlobGasNotSet => return Err(BlockchainError::ExcessBlobGasNotSet), }, }; let state = result_and_state.state; @@ -1594,6 +1597,7 @@ impl Backend { block.header.base_fee_per_gas.unwrap_or_default(), ), gas_limit: u256_to_ru256(block.header.gas_limit), + ..Default::default() }; f(state, block) }) @@ -1621,6 +1625,7 @@ impl Backend { prevrandao: Some(block.header.mix_hash).map(h256_to_b256), basefee: u256_to_ru256(block.header.base_fee_per_gas.unwrap_or_default()), gas_limit: u256_to_ru256(block.header.gas_limit), + ..Default::default() }; return Ok(f(Box::new(state), block)) } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 8289fd289b375..6be7ae5e72876 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -81,6 +81,8 @@ pub enum BlockchainError { EIP1559TransactionUnsupportedAtHardfork, #[error("Access list received but is not supported by the current hardfork.\n\nYou can use it by running anvil with '--hardfork berlin' or later.")] EIP2930TransactionUnsupportedAtHardfork, + #[error("Excess blob gas not set.")] + ExcessBlobGasNotSet, } impl From for BlockchainError { @@ -98,6 +100,7 @@ where EVMError::Transaction(err) => InvalidTransactionError::from(err).into(), EVMError::PrevrandaoNotSet => BlockchainError::PrevrandaoNotSet, EVMError::Database(err) => err.into(), + EVMError::ExcessBlobGasNotSet => BlockchainError::ExcessBlobGasNotSet, } } } @@ -184,6 +187,17 @@ pub enum InvalidTransactionError { /// Thrown when an access list is used before the berlin hard fork. #[error("Access lists are not supported before the Berlin hardfork")] AccessListNotSupported, + /// Thrown when the block's `blob_gas_price` is greater than tx-specified + /// `max_fee_per_blob_gas` after Cancun. + #[error("Block `blob_gas_price` is greater than tx-specified `max_fee_per_blob_gas`")] + BlobGasPriceGreaterThanMax, + /// Thrown when we receive a tx with `blob_versioned_hashes` and we're not on the Cancun hard + /// fork. + #[error("Block `blob_versioned_hashes` is not supported before the Cancun hardfork")] + BlobVersionedHashesNotSupported, + /// Thrown when `max_fee_per_blob_gas` is not supported for blocks before the Cancun hardfork. + #[error("`max_fee_per_blob_gas` is not supported for blocks before the Cancun hardfork.")] + MaxFeePerBlobGasNotSupported, } impl From for InvalidTransactionError { @@ -223,6 +237,15 @@ impl From for InvalidTransactionError { InvalidTransaction::AccessListNotSupported => { InvalidTransactionError::AccessListNotSupported } + InvalidTransaction::BlobGasPriceGreaterThanMax => { + InvalidTransactionError::BlobGasPriceGreaterThanMax + } + InvalidTransaction::BlobVersionedHashesNotSupported => { + InvalidTransactionError::BlobVersionedHashesNotSupported + } + InvalidTransaction::MaxFeePerBlobGasNotSupported => { + InvalidTransactionError::MaxFeePerBlobGasNotSupported + } } } } @@ -374,6 +397,9 @@ impl ToRpcResponseResult for Result { err @ BlockchainError::EIP2930TransactionUnsupportedAtHardfork => { RpcError::invalid_params(err.to_string()) } + err @ BlockchainError::ExcessBlobGasNotSet => { + RpcError::invalid_params(err.to_string()) + } } .into(), } diff --git a/crates/evm/src/executor/fork/init.rs b/crates/evm/src/executor/fork/init.rs index 539e4f888d505..09c607bedb54e 100644 --- a/crates/evm/src/executor/fork/init.rs +++ b/crates/evm/src/executor/fork/init.rs @@ -78,6 +78,7 @@ where prevrandao: Some(block.mix_hash.map(h256_to_b256).unwrap_or_default()), basefee: u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()), gas_limit: u256_to_ru256(block.gas_limit), + ..Default::default() }, tx: TxEnv { caller: origin, diff --git a/crates/evm/src/executor/opts.rs b/crates/evm/src/executor/opts.rs index 71c0b1347dbde..a09e7c44d2087 100644 --- a/crates/evm/src/executor/opts.rs +++ b/crates/evm/src/executor/opts.rs @@ -110,6 +110,7 @@ impl EvmOpts { prevrandao: Some(self.env.block_prevrandao), basefee: U256::from(self.env.block_base_fee_per_gas), gas_limit: self.gas_limit(), + ..Default::default() }, cfg, tx: TxEnv { From 3a7178c234a6735aa6f8cde3f36f80b8e1e1bedc Mon Sep 17 00:00:00 2001 From: Nicholas Rodrigues Lordello Date: Wed, 20 Sep 2023 11:51:17 +0200 Subject: [PATCH 0089/1963] Expose `replace_account_storage` Method In Foundry EVM Backend (#5861) --- crates/evm/src/executor/backend/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index 227e94eea5f08..768d8767b49bb 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -492,6 +492,22 @@ impl Backend { ret } + /// Completely replace an account's storage without overriding account info. + /// + /// When forking, this causes the backend to assume a `0` value for all + /// unset storage slots instead of trying to fetch it. + pub fn replace_account_storage( + &mut self, + address: Address, + storage: Map, + ) -> Result<(), DatabaseError> { + if let Some(db) = self.active_fork_db_mut() { + db.replace_account_storage(address, storage) + } else { + self.mem_db.replace_account_storage(address, storage) + } + } + /// Returns all snapshots created in this backend pub fn snapshots(&self) -> &Snapshots> { &self.inner.snapshots From 0fadb850175f044637a773abe7af2d40ad0a2044 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 20 Sep 2023 13:57:44 +0200 Subject: [PATCH 0090/1963] chore(deps): move toml to ws (#5862) --- Cargo.lock | 4 ++-- Cargo.toml | 8 +++++--- crates/doc/Cargo.toml | 2 +- crates/fmt/Cargo.toml | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b70dff174dea5..38f6f630699ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2536,7 +2536,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.7.8", + "toml 0.8.0", "tracing", "warp", ] @@ -2552,7 +2552,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.7.8", + "toml 0.8.0", "tracing", "tracing-subscriber", ] diff --git a/Cargo.toml b/Cargo.toml index e334b6008f44a..7ef6d2eec0451 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,11 +152,13 @@ ethers-solc = { git = "https://github.com/gakonst/ethers-rs", default-features = alloy-primitives = { version = "0.3", default-features = false } alloy-dyn-abi = { version = "0.3", default-features = false} -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } -hex = { package = "const-hex", version = "1.6", features = ["hex"] } -itertools = "0.11" solang-parser = "=0.3.2" +## misc +toml = "0.8" +itertools = "0.11" +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +hex = { package = "const-hex", version = "1.6", features = ["hex"] } #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index b189f3732f69e..f2448c87fc55e 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -35,7 +35,7 @@ eyre = "0.6" thiserror = "1" rayon = "1" itertools.workspace = true -toml = "0.7" +toml.workspace = true auto_impl = "1" derive_more = "0.99" once_cell = "1" diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index 1d8a5390ed7ea..4e02a2340bf08 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -28,5 +28,5 @@ tracing = "0.1" [dev-dependencies] pretty_assertions = "1" itertools.workspace = true -toml = "0.7" +toml.workspace = true tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 99b5cedbae0a460d0990d56ba1231e3ec9568b98 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 20 Sep 2023 10:40:52 -0400 Subject: [PATCH 0091/1963] fix(cast): properly bail if no api key is set when fetching remote contract (#5865) --- crates/cast/bin/cmd/storage.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 3afc441360c32..22d85802cf799 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -120,6 +120,10 @@ impl StorageArgs { // Get code from Etherscan eprintln!("No matching artifacts found, fetching source code from Etherscan..."); + if self.etherscan.key.is_none() { + eyre::bail!("You must provide an Etherscan API key if you're fetching a remote contract's storage."); + } + let chain = utils::get_chain(config.chain_id, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); let client = Client::new(chain.named()?, api_key)?; From 83b9176a6d579e8cfd03741fe322a4420b3c9903 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 20 Sep 2023 11:23:58 -0400 Subject: [PATCH 0092/1963] chore(general): replace conversion functions with `ToAlloy`/`ToEthers` conv trait (#5857) * chore: replace types with conv trait * chore: remove conv functions --- Cargo.lock | 2 + crates/anvil/core/Cargo.toml | 1 + crates/anvil/core/src/eth/proof.rs | 4 +- crates/anvil/core/src/eth/receipt.rs | 10 +- crates/anvil/core/src/eth/transaction/mod.rs | 28 ++--- crates/anvil/core/src/eth/utils.rs | 7 +- crates/anvil/src/config.rs | 25 ++-- crates/anvil/src/eth/api.rs | 4 +- crates/anvil/src/eth/backend/executor.rs | 24 ++-- crates/anvil/src/eth/backend/genesis.rs | 10 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 16 +-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 44 +++---- crates/anvil/src/eth/backend/mem/mod.rs | 118 +++++++++--------- crates/anvil/src/eth/backend/mem/state.rs | 31 +++-- crates/anvil/src/eth/backend/mem/storage.rs | 18 ++- crates/anvil/src/genesis.rs | 12 +- crates/anvil/tests/it/fork.rs | 7 +- crates/anvil/tests/it/proof/mod.rs | 5 +- crates/cast/bin/cmd/call.rs | 17 ++- crates/cast/bin/cmd/run.rs | 14 +-- crates/chisel/Cargo.toml | 1 + crates/chisel/src/executor.rs | 4 +- crates/chisel/src/runner.rs | 39 +++--- crates/evm/src/executor/backend/diagnostic.rs | 7 +- crates/evm/src/executor/backend/mod.rs | 20 +-- crates/evm/src/executor/fork/backend.rs | 30 +++-- crates/evm/src/executor/fork/init.rs | 21 ++-- crates/evm/src/executor/fork/multi.rs | 8 +- .../evm/src/executor/inspector/access_list.rs | 11 +- .../src/executor/inspector/cheatcodes/env.rs | 93 +++++++------- .../executor/inspector/cheatcodes/expect.rs | 15 ++- .../src/executor/inspector/cheatcodes/fork.rs | 51 ++++---- .../executor/inspector/cheatcodes/mapping.rs | 8 +- .../src/executor/inspector/cheatcodes/mod.rs | 105 ++++++++-------- .../executor/inspector/cheatcodes/snapshot.rs | 11 +- .../src/executor/inspector/cheatcodes/util.rs | 29 ++--- crates/evm/src/executor/inspector/coverage.rs | 10 +- crates/evm/src/executor/inspector/fuzzer.rs | 19 +-- crates/evm/src/executor/inspector/logs.rs | 10 +- crates/evm/src/executor/inspector/stack.rs | 11 +- crates/evm/src/executor/inspector/tracer.rs | 16 +-- crates/evm/src/fuzz/invariant/error.rs | 13 +- crates/evm/src/fuzz/invariant/executor.rs | 21 ++-- crates/evm/src/fuzz/invariant/mod.rs | 11 +- crates/evm/src/fuzz/mod.rs | 10 +- crates/evm/src/fuzz/strategies/state.rs | 23 ++-- crates/evm/src/trace/decoder.rs | 14 +-- crates/evm/src/trace/mod.rs | 11 +- crates/evm/src/trace/node.rs | 6 +- crates/evm/src/utils.rs | 49 +------- crates/forge/bin/cmd/coverage.rs | 6 +- crates/forge/bin/cmd/script/build.rs | 5 +- crates/forge/bin/cmd/script/cmd.rs | 17 ++- crates/forge/bin/cmd/script/executor.rs | 6 +- crates/forge/bin/cmd/script/mod.rs | 6 +- crates/forge/bin/cmd/script/runner.rs | 44 +++---- crates/forge/bin/cmd/script/transaction.rs | 6 +- crates/forge/bin/cmd/test/mod.rs | 10 +- crates/forge/src/gas_report.rs | 6 +- crates/forge/src/multi_runner.rs | 7 +- crates/forge/src/result.rs | 4 +- crates/forge/src/runner.rs | 37 +++--- crates/forge/tests/it/config.rs | 4 +- crates/forge/tests/it/test_helpers.rs | 10 +- crates/utils/src/types.rs | 12 +- 65 files changed, 585 insertions(+), 669 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38f6f630699ee..ee89149c5edb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,6 +323,7 @@ dependencies = [ "bytes", "ethers-core", "foundry-evm", + "foundry-utils", "hash-db", "hash256-std-hasher", "keccak-hasher", @@ -1025,6 +1026,7 @@ dependencies = [ "foundry-common", "foundry-config", "foundry-evm", + "foundry-utils", "once_cell", "regex", "reqwest", diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 3b49e4bc5819e..196d5d7f0add8 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -12,6 +12,7 @@ repository.workspace = true [dependencies] # foundry internal foundry-evm = { path = "../../evm" } +foundry-utils = { path = "../../utils"} revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } diff --git a/crates/anvil/core/src/eth/proof.rs b/crates/anvil/core/src/eth/proof.rs index a0714ab29e2df..733cd044f634a 100644 --- a/crates/anvil/core/src/eth/proof.rs +++ b/crates/anvil/core/src/eth/proof.rs @@ -5,7 +5,7 @@ use ethers_core::{ types::{H256, U256}, utils::rlp, }; -use foundry_evm::utils::b256_to_h256; +use foundry_utils::types::ToEthers; use revm::primitives::KECCAK_EMPTY; // reexport for convenience pub use ethers_core::types::{EIP1186ProofResponse as AccountProof, StorageProof}; @@ -29,7 +29,7 @@ impl Default for BasicAccount { BasicAccount { balance: 0.into(), nonce: 0.into(), - code_hash: b256_to_h256(KECCAK_EMPTY), + code_hash: KECCAK_EMPTY.to_ethers(), storage_root: KECCAK_NULL_RLP, } } diff --git a/crates/anvil/core/src/eth/receipt.rs b/crates/anvil/core/src/eth/receipt.rs index 5b3a15eee0690..cebcd0735f629 100644 --- a/crates/anvil/core/src/eth/receipt.rs +++ b/crates/anvil/core/src/eth/receipt.rs @@ -6,7 +6,7 @@ use ethers_core::{ rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, }, }; -use foundry_evm::utils::{b160_to_h160, b256_to_h256, h160_to_b160, h256_to_b256}; +use foundry_utils::types::{ToAlloy, ToEthers}; #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] @@ -21,8 +21,8 @@ impl From for Log { fn from(log: revm::primitives::Log) -> Self { let revm::primitives::Log { address, topics, data } = log; Log { - address: b160_to_h160(address), - topics: topics.into_iter().map(b256_to_h256).collect(), + address: address.to_ethers(), + topics: topics.into_iter().map(|h| h.to_ethers()).collect(), data: ethers_core::types::Bytes(data.0), } } @@ -32,8 +32,8 @@ impl From for revm::primitives::Log { fn from(log: Log) -> Self { let Log { address, topics, data } = log; revm::primitives::Log { - address: h160_to_b160(address), - topics: topics.into_iter().map(h256_to_b256).collect(), + address: address.to_alloy(), + topics: topics.into_iter().map(|t| t.to_alloy()).collect(), data: alloy_primitives::Bytes(data.0), } } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 159471613c3bf..925f715febae5 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -14,10 +14,8 @@ use ethers_core::{ rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, }, }; -use foundry_evm::{ - trace::CallTraceArena, - utils::{h160_to_b160, u256_to_ru256}, -}; +use foundry_evm::trace::CallTraceArena; +use foundry_utils::types::ToAlloy; use revm::{ interpreter::InstructionResult, primitives::{CreateScheme, TransactTo, TxEnv}, @@ -1188,7 +1186,7 @@ impl PendingTransaction { pub fn to_revm_tx_env(&self) -> TxEnv { fn transact_to(kind: &TransactionKind) -> TransactTo { match kind { - TransactionKind::Call(c) => TransactTo::Call(h160_to_b160(*c)), + TransactionKind::Call(c) => TransactTo::Call((*c).to_alloy()), TransactionKind::Create => TransactTo::Create(CreateScheme::Create), } } @@ -1199,13 +1197,13 @@ impl PendingTransaction { let chain_id = tx.chain_id(); let LegacyTransaction { nonce, gas_price, gas_limit, value, kind, input, .. } = tx; TxEnv { - caller: h160_to_b160(caller), + caller: caller.to_alloy(), transact_to: transact_to(kind), data: alloy_primitives::Bytes(input.0.clone()), chain_id, nonce: Some(nonce.as_u64()), - value: u256_to_ru256(*value), - gas_price: u256_to_ru256(*gas_price), + value: (*value).to_alloy(), + gas_price: (*gas_price).to_alloy(), gas_priority_fee: None, gas_limit: gas_limit.as_u64(), access_list: vec![], @@ -1225,13 +1223,13 @@ impl PendingTransaction { .. } = tx; TxEnv { - caller: h160_to_b160(caller), + caller: (caller).to_alloy(), transact_to: transact_to(kind), data: alloy_primitives::Bytes(input.0.clone()), chain_id: Some(*chain_id), nonce: Some(nonce.as_u64()), - value: u256_to_ru256(*value), - gas_price: u256_to_ru256(*gas_price), + value: (*value).to_alloy(), + gas_price: (*gas_price).to_alloy(), gas_priority_fee: None, gas_limit: gas_limit.as_u64(), access_list: to_revm_access_list(access_list.0.clone()), @@ -1252,14 +1250,14 @@ impl PendingTransaction { .. } = tx; TxEnv { - caller: h160_to_b160(caller), + caller: (caller).to_alloy(), transact_to: transact_to(kind), data: alloy_primitives::Bytes(input.0.clone()), chain_id: Some(*chain_id), nonce: Some(nonce.as_u64()), - value: u256_to_ru256(*value), - gas_price: u256_to_ru256(*max_fee_per_gas), - gas_priority_fee: Some(u256_to_ru256(*max_priority_fee_per_gas)), + value: (*value).to_alloy(), + gas_price: (*max_fee_per_gas).to_alloy(), + gas_priority_fee: Some((*max_priority_fee_per_gas).to_alloy()), gas_limit: gas_limit.as_u64(), access_list: to_revm_access_list(access_list.0.clone()), ..Default::default() diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index 7ee856195cd1f..ffc1286d272a5 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -6,7 +6,8 @@ use ethers_core::{ rlp::{Encodable, RlpStream}, }, }; -use foundry_evm::utils::{h160_to_b160, h256_to_u256_be, u256_to_ru256}; +use foundry_evm::utils::h256_to_u256_be; +use foundry_utils::types::ToAlloy; pub fn enveloped(id: u8, v: &T, s: &mut RlpStream) { let encoded = rlp::encode(v); @@ -26,8 +27,8 @@ pub fn to_revm_access_list(list: Vec) -> Vec<(rAddress, Vec let gas_limit = if self.disable_block_gas_limit || block.gas_limit.is_zero() { - u256_to_ru256(u64::MAX.into()) + rU256::from(u64::MAX) } else { - u256_to_ru256(block.gas_limit) + block.gas_limit.to_alloy() }; env.block = BlockEnv { number: rU256::from(fork_block_number), - timestamp: u256_to_ru256(block.timestamp), - difficulty: u256_to_ru256(block.difficulty), + timestamp: block.timestamp.to_alloy(), + difficulty: block.difficulty.to_alloy(), // ensures prevrandao is set - prevrandao: Some(block.mix_hash.unwrap_or_default()).map(h256_to_b256), + prevrandao: Some(block.mix_hash.unwrap_or_default()).map(|h| h.to_alloy()), gas_limit, // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, @@ -904,7 +903,7 @@ latest block number: {latest_block}" if self.base_fee.is_none() { if let Some(base_fee) = block.base_fee_per_gas { self.base_fee = Some(base_fee); - env.block.basefee = u256_to_ru256(base_fee); + env.block.basefee = base_fee.to_alloy(); // this is the base fee of the current block, but we need the base fee of // the next block let next_block_base_fee = fees.get_next_block_base_fee_per_gas( @@ -995,7 +994,7 @@ latest block number: {latest_block}" let genesis = GenesisConfig { timestamp: self.get_genesis_timestamp(), - balance: u256_to_ru256(self.genesis_balance), + balance: self.genesis_balance.to_alloy(), accounts: self.genesis_accounts.iter().map(|acc| acc.address()).collect(), fork_genesis_account_infos: Arc::new(Default::default()), genesis_init: self.genesis.clone(), @@ -1019,7 +1018,7 @@ latest block number: {latest_block}" // if the option is not disabled and we are not forking. if !self.disable_default_create2_deployer && self.eth_rpc_url.is_none() { backend - .set_create2_deployer(b160_to_h160(DEFAULT_CREATE2_DEPLOYER)) + .set_create2_deployer(DEFAULT_CREATE2_DEPLOYER.to_ethers()) .await .expect("Failed to create default create2 deployer"); } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 5c2d107b1ce39..c705ce81ee484 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -64,8 +64,8 @@ use foundry_evm::{ interpreter::{return_ok, return_revert, InstructionResult}, primitives::BlockEnv, }, - utils::ru256_to_u256, }; +use foundry_utils::types::ToEthers; use futures::channel::mpsc::Receiver; use parking_lot::RwLock; use std::{collections::HashSet, sync::Arc, time::Duration}; @@ -2063,7 +2063,7 @@ impl EthApi { // get the highest possible gas limit, either the request's set value or the currently // configured gas limit - let mut highest_gas_limit = request.gas.unwrap_or(ru256_to_u256(block_env.gas_limit)); + let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit.to_ethers()); // check with the funds of the sender if let Some(from) = request.from { diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index ddbfb7f9d1931..8cbf6381163df 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -25,11 +25,9 @@ use foundry_evm::{ primitives::{BlockEnv, CfgEnv, EVMError, Env, ExecutionResult, Output, SpecId}, }, trace::{node::CallTraceNode, CallTraceArena}, - utils::{ - b160_to_h160, eval_to_instruction_result, h160_to_b160, halt_to_instruction_result, - ru256_to_u256, - }, + utils::{eval_to_instruction_result, halt_to_instruction_result}, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::sync::Arc; use tracing::{trace, warn}; @@ -121,7 +119,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let block_number = self.block_env.number; let difficulty = self.block_env.difficulty; let beneficiary = self.block_env.coinbase; - let timestamp = ru256_to_u256(self.block_env.timestamp).as_u64(); + let timestamp = self.block_env.timestamp.to_ethers().as_u64(); let base_fee = if (self.cfg_env.spec_id as u8) >= (SpecId::LONDON as u8) { Some(self.block_env.basefee) } else { @@ -164,7 +162,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' transaction_index, from: *transaction.pending_transaction.sender(), to: transaction.pending_transaction.transaction.to().copied(), - contract_address: contract_address.map(b160_to_h160), + contract_address: contract_address.map(|c| c.to_ethers()), logs, logs_bloom: *receipt.logs_bloom(), traces: CallTraceArena { arena: traces }, @@ -186,19 +184,19 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let partial_header = PartialHeader { parent_hash, - beneficiary: b160_to_h160(beneficiary), + beneficiary: beneficiary.to_ethers(), state_root: self.db.maybe_state_root().unwrap_or_default(), receipts_root, logs_bloom: bloom, - difficulty: ru256_to_u256(difficulty), - number: ru256_to_u256(block_number), - gas_limit: ru256_to_u256(gas_limit), + difficulty: difficulty.to_ethers(), + number: block_number.to_ethers(), + gas_limit: gas_limit.to_ethers(), gas_used: cumulative_gas_used, timestamp, extra_data: Default::default(), mix_hash: Default::default(), nonce: Default::default(), - base_fee: base_fee.map(ru256_to_u256), + base_fee: base_fee.map(|b| b.to_ethers()), }; let block = Block::new(partial_header, transactions.clone(), ommers); @@ -231,14 +229,14 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator fn next(&mut self) -> Option { let transaction = self.pending.next()?; let sender = *transaction.pending_transaction.sender(); - let account = match self.db.basic(h160_to_b160(sender)).map(|acc| acc.unwrap_or_default()) { + let account = match self.db.basic(sender.to_alloy()).map(|acc| acc.unwrap_or_default()) { Ok(account) => account, Err(err) => return Some(TransactionExecutionOutcome::DatabaseError(transaction, err)), }; let env = self.env_for(&transaction.pending_transaction); // check that we comply with the block's gas limit let max_gas = self.gas_used.saturating_add(U256::from(env.tx.gas_limit)); - if max_gas > ru256_to_u256(env.block.gas_limit) { + if max_gas > env.block.gas_limit.to_ethers() { return Some(TransactionExecutionOutcome::Exhausted(transaction)) } diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 25cc3207dc97a..a9bca220ec016 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -15,8 +15,8 @@ use foundry_evm::{ DatabaseRef, }, revm::primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, - utils::{b160_to_h160, ru256_to_u256, u256_to_ru256}, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::Mutex; use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLockWriteGuard; @@ -104,7 +104,7 @@ pub(crate) struct AtGenesisStateDb<'a> { impl<'a> DatabaseRef for AtGenesisStateDb<'a> { type Error = DatabaseError; fn basic(&self, address: B160) -> DatabaseResult> { - if let Some(acc) = self.accounts.get(&b160_to_h160(address)).cloned() { + if let Some(acc) = self.accounts.get(&(address.to_ethers())).cloned() { return Ok(Some(acc)) } self.db.basic(address) @@ -121,14 +121,14 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> { if let Some(acc) = self .genesis .as_ref() - .and_then(|genesis| genesis.alloc.accounts.get(&b160_to_h160(address))) + .and_then(|genesis| genesis.alloc.accounts.get(&(address.to_ethers()))) { let value = acc .storage - .get(&H256::from_uint(&ru256_to_u256(index))) + .get(&H256::from_uint(&(index.to_ethers()))) .copied() .unwrap_or_default(); - return Ok(u256_to_ru256(value.into_uint())) + return Ok(value.into_uint().to_alloy()) } self.db.storage(address, index) } diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index bb6b4e1bd91f4..caff8da45a8cc 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -13,8 +13,8 @@ use foundry_evm::{ fork::database::ForkDbSnapshot, }, revm::Database, - utils::{b160_to_h160, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256}, }; +use foundry_utils::types::{ToAlloy, ToEthers}; /// Implement the helper for the fork database impl Db for ForkedDatabase { @@ -24,12 +24,12 @@ impl Db for ForkedDatabase { fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { // this ensures the account is loaded first - let _ = Database::basic(self, h160_to_b160(address))?; + let _ = Database::basic(self, address.to_alloy())?; self.database_mut().set_storage_at(address, slot, val) } fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.inner().block_hashes().write().insert(u256_to_ru256(number), h256_to_b256(hash)); + self.inner().block_hashes().write().insert(number.to_alloy(), hash.to_alloy()); } fn dump_state(&self) -> DatabaseResult> { @@ -47,15 +47,15 @@ impl Db for ForkedDatabase { } .to_checked(); Ok(( - b160_to_h160(k), + k.to_ethers(), SerializableAccountRecord { nonce: v.info.nonce, - balance: ru256_to_u256(v.info.balance), + balance: v.info.balance.to_ethers(), code: code.bytes()[..code.len()].to_vec().into(), storage: v .storage .into_iter() - .map(|kv| (ru256_to_u256(kv.0), ru256_to_u256(kv.1))) + .map(|kv| (kv.0.to_ethers(), kv.1.to_ethers())) .collect(), }, )) @@ -65,11 +65,11 @@ impl Db for ForkedDatabase { } fn snapshot(&mut self) -> U256 { - ru256_to_u256(self.insert_snapshot()) + self.insert_snapshot().to_ethers() } fn revert(&mut self, id: U256) -> bool { - self.revert_snapshot(u256_to_ru256(id)) + self.revert_snapshot(id.to_alloy()) } fn current_state(&self) -> StateDb { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 23733f168a38e..cd23529166185 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -9,7 +9,7 @@ use crate::{ Address, U256, }; use ethers::prelude::H256; -use foundry_evm::utils::{b160_to_h160, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256}; +use foundry_utils::types::{ToAlloy, ToEthers}; use tracing::{trace, warn}; // reexport for convenience @@ -19,19 +19,15 @@ pub use foundry_evm::executor::{backend::MemDb, DatabaseRef}; impl Db for MemDb { fn insert_account(&mut self, address: Address, account: AccountInfo) { - self.inner.insert_account_info(h160_to_b160(address), account) + self.inner.insert_account_info(address.to_alloy(), account) } fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.inner.insert_account_storage( - h160_to_b160(address), - u256_to_ru256(slot), - u256_to_ru256(val), - ) + self.inner.insert_account_storage(address.to_alloy(), slot.to_alloy(), val.to_alloy()) } fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.inner.block_hashes.insert(u256_to_ru256(number), h256_to_b256(hash)); + self.inner.block_hashes.insert(number.to_alloy(), hash.to_alloy()); } fn dump_state(&self) -> DatabaseResult> { @@ -48,15 +44,15 @@ impl Db for MemDb { } .to_checked(); Ok(( - b160_to_h160(k), + k.to_ethers(), SerializableAccountRecord { nonce: v.info.nonce, - balance: ru256_to_u256(v.info.balance), + balance: v.info.balance.to_ethers(), code: code.bytes()[..code.len()].to_vec().into(), storage: v .storage .into_iter() - .map(|k| (ru256_to_u256(k.0), ru256_to_u256(k.1))) + .map(|k| (k.0.to_ethers(), k.1.to_ethers())) .collect(), }, )) @@ -70,11 +66,11 @@ impl Db for MemDb { fn snapshot(&mut self) -> U256 { let id = self.snapshots.insert(self.inner.clone()); trace!(target: "backend::memdb", "Created new snapshot {}", id); - ru256_to_u256(id) + id.to_ethers() } fn revert(&mut self, id: U256) -> bool { - if let Some(snapshot) = self.snapshots.remove(u256_to_ru256(id)) { + if let Some(snapshot) = self.snapshots.remove(id.to_alloy()) { self.inner = snapshot; trace!(target: "backend::memdb", "Reverted snapshot {}", id); true @@ -99,7 +95,7 @@ impl MaybeHashDatabase for MemDb { } fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, H256)> { - if let Some(acc) = self.inner.accounts.get(&h160_to_b160(addr)) { + if let Some(acc) = self.inner.accounts.get(&addr.to_alloy()) { Some(storage_trie_db(&acc.storage)) } else { Some(storage_trie_db(&Default::default())) @@ -132,8 +128,8 @@ mod tests { use foundry_evm::{ executor::{backend::MemDb, DatabaseRef}, revm::primitives::{Bytecode, KECCAK_EMPTY}, - utils::h160_to_b160, }; + use foundry_utils::types::ToAlloy; use std::{collections::BTreeMap, str::FromStr}; // verifies that all substantial aspects of a loaded account remain the state after an account @@ -167,13 +163,13 @@ mod tests { load_db.load_state(state).unwrap(); - let loaded_account = load_db.basic(h160_to_b160(test_addr)).unwrap().unwrap(); + let loaded_account = load_db.basic(test_addr.to_alloy()).unwrap().unwrap(); assert_eq!(loaded_account.balance, rU256::from(123456)); assert_eq!(load_db.code_by_hash(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); assert_eq!( - load_db.storage(h160_to_b160(test_addr), rU256::from(1234567)).unwrap(), + load_db.storage(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), rU256::from(1) ); } @@ -233,21 +229,15 @@ mod tests { db.load_state(new_state).unwrap(); - let loaded_account = db.basic(h160_to_b160(test_addr)).unwrap().unwrap(); - let loaded_account2 = db.basic(h160_to_b160(test_addr2)).unwrap().unwrap(); + let loaded_account = db.basic(test_addr.to_alloy()).unwrap().unwrap(); + let loaded_account2 = db.basic(test_addr2.to_alloy()).unwrap().unwrap(); assert_eq!(loaded_account2.nonce, 1); assert_eq!(loaded_account.balance, rU256::from(100100)); assert_eq!(db.code_by_hash(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); - assert_eq!( - db.storage(h160_to_b160(test_addr), rU256::from(1234567)).unwrap(), - rU256::from(1) - ); - assert_eq!( - db.storage(h160_to_b160(test_addr), rU256::from(1234568)).unwrap(), - rU256::from(5) - ); + assert_eq!(db.storage(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), rU256::from(1)); + assert_eq!(db.storage(test_addr.to_alloy(), rU256::from(1234568)).unwrap(), rU256::from(5)); } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index b04dde23f98c9..2cd1cf35de3a1 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -71,11 +71,9 @@ use foundry_evm::{ TransactTo, TxEnv, KECCAK_EMPTY, }, }, - utils::{ - b160_to_h160, eval_to_instruction_result, h160_to_b160, h256_to_b256, - halt_to_instruction_result, ru256_to_u256, u256_to_h256_be, u256_to_ru256, - }, + utils::{eval_to_instruction_result, halt_to_instruction_result, u256_to_h256_be}, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::channel::mpsc::{unbounded, UnboundedSender}; use hash_db::HashDB; use parking_lot::{Mutex, RwLock}; @@ -264,7 +262,7 @@ impl Backend { // accounts concurrently by spawning the job to a new task genesis_accounts_futures.push(tokio::task::spawn(async move { let db = db.read().await; - let info = db.basic(h160_to_b160(address))?.unwrap_or_default(); + let info = db.basic(address.to_alloy())?.unwrap_or_default(); Ok::<_, DatabaseError>((address, info)) })); } @@ -338,7 +336,7 @@ impl Backend { /// Returns the `AccountInfo` from the database pub async fn get_account(&self, address: Address) -> DatabaseResult { - Ok(self.db.read().await.basic(h160_to_b160(address))?.unwrap_or_default()) + Ok(self.db.read().await.basic(address.to_alloy())?.unwrap_or_default()) } /// Whether we're forked off some remote client @@ -369,18 +367,18 @@ impl Backend { env.block = BlockEnv { number: rU256::from(fork_block_number), - timestamp: u256_to_ru256(fork_block.timestamp), - gas_limit: u256_to_ru256(fork_block.gas_limit), - difficulty: u256_to_ru256(fork_block.difficulty), - prevrandao: fork_block.mix_hash.map(h256_to_b256), + timestamp: fork_block.timestamp.to_alloy(), + gas_limit: fork_block.gas_limit.to_alloy(), + difficulty: fork_block.difficulty.to_alloy(), + prevrandao: fork_block.mix_hash.map(|h| h.to_alloy()), // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, ..Default::default() }; - self.time.reset(ru256_to_u256(env.block.timestamp).as_u64()); - self.fees.set_base_fee(ru256_to_u256(env.block.basefee)); + self.time.reset((env.block.timestamp.to_ethers()).as_u64()); + self.fees.set_base_fee(env.block.basefee.to_ethers()); // also reset the total difficulty self.blockchain.storage.write().total_difficulty = fork.total_difficulty(); @@ -451,12 +449,12 @@ impl Backend { /// Sets the block number pub fn set_block_number(&self, number: U256) { let mut env = self.env.write(); - env.block.number = u256_to_ru256(number); + env.block.number = number.to_alloy(); } /// Returns the client coinbase address. pub fn coinbase(&self) -> Address { - b160_to_h160(self.env.read().block.coinbase) + self.env.read().block.coinbase.to_ethers() } /// Returns the client coinbase address. @@ -466,7 +464,7 @@ impl Backend { /// Returns balance of the given account. pub async fn current_balance(&self, address: Address) -> DatabaseResult { - Ok(self.get_account(address).await?.balance).map(ru256_to_u256) + Ok(self.get_account(address).await?.balance.to_ethers()) } /// Returns balance of the given account. @@ -476,7 +474,7 @@ impl Backend { /// Sets the coinbase address pub fn set_coinbase(&self, address: Address) { - self.env.write().block.coinbase = h160_to_b160(address); + self.env.write().block.coinbase = address.to_alloy(); } /// Sets the nonce of the given address @@ -542,12 +540,12 @@ impl Backend { /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { - ru256_to_u256(self.env.read().block.gas_limit) + self.env.read().block.gas_limit.to_ethers() } /// Sets the block gas limit pub fn set_gas_limit(&self, gas_limit: U256) { - self.env.write().block.gas_limit = u256_to_ru256(gas_limit); + self.env.write().block.gas_limit = gas_limit.to_alloy(); } /// Returns the current base fee @@ -686,7 +684,7 @@ impl Backend { let mut env = self.env.read().clone(); // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = u256_to_ru256(self.base_fee()); + env.block.basefee = self.base_fee().to_alloy(); env.block.timestamp = rU256::from(self.time.current_call_timestamp()); env } @@ -713,7 +711,7 @@ impl Backend { }; let state = result_and_state.state; let state: revm::primitives::HashMap = - state.into_iter().map(|kv| (b160_to_h160(kv.0), kv.1)).collect(); + state.into_iter().map(|kv| (kv.0.to_ethers(), kv.1)).collect(); let (exit_reason, gas_used, out, logs) = match result_and_state.result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { (eval_to_instruction_result(reason), gas_used, Some(output), Some(logs)) @@ -802,7 +800,7 @@ impl Backend { // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = u256_to_ru256(current_base_fee); + env.block.basefee = current_base_fee.to_alloy(); env.block.timestamp = rU256::from(self.time.next_timestamp()); let best_hash = self.blockchain.storage.read().best_hash; @@ -839,7 +837,7 @@ impl Backend { let BlockInfo { block, transactions, receipts } = block; let header = block.header.clone(); - let block_number: U64 = ru256_to_u256(env.block.number).as_u64().into(); + let block_number: U64 = (env.block.number.to_ethers()).as_u64().into(); trace!( target: "backend", @@ -985,7 +983,7 @@ impl Backend { overrides: Option, ) -> Result<(InstructionResult, Option, u64, State), BlockchainError> { self.with_database_at(block_request, |state, block| { - let block_number = ru256_to_u256(block.number).as_u64(); + let block_number = (block.number.to_ethers()).as_u64(); let (exit, out, gas, state) = match overrides { None => self.call_with_state(state, request, fee_details, block), Some(overrides) => { @@ -1008,7 +1006,7 @@ impl Backend { let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = fee_details; - let gas_limit = gas.unwrap_or(ru256_to_u256(block_env.gas_limit)); + let gas_limit = gas.unwrap_or(block_env.gas_limit.to_ethers()); let mut env = self.env.read().clone(); env.block = block_env; // we want to disable this in eth_call, since this is common practice used by other node @@ -1016,22 +1014,22 @@ impl Backend { env.cfg.disable_block_gas_limit = true; if let Some(base) = max_fee_per_gas { - env.block.basefee = u256_to_ru256(base); + env.block.basefee = base.to_alloy(); } let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); let caller = from.unwrap_or_default(); env.tx = TxEnv { - caller: h160_to_b160(caller), + caller: caller.to_alloy(), gas_limit: gas_limit.as_u64(), - gas_price: u256_to_ru256(gas_price), - gas_priority_fee: max_priority_fee_per_gas.map(u256_to_ru256), + gas_price: gas_price.to_alloy(), + gas_priority_fee: max_priority_fee_per_gas.map(|f| f.to_alloy()), transact_to: match to { - Some(addr) => TransactTo::Call(h160_to_b160(addr)), + Some(addr) => TransactTo::Call(addr.to_alloy()), None => TransactTo::Create(CreateScheme::Create), }, - value: value.map(u256_to_ru256).unwrap_or_default(), + value: value.unwrap_or_default().to_alloy(), data: data.unwrap_or_default().to_vec().into(), chain_id: None, nonce: nonce.map(|n| n.as_u64()), @@ -1075,7 +1073,7 @@ impl Backend { }; let state = result_and_state.state; let state: revm::primitives::HashMap = - state.into_iter().map(|kv| (b160_to_h160(kv.0), kv.1)).collect(); + state.into_iter().map(|kv| (kv.0.to_ethers(), kv.1)).collect(); let (exit_reason, gas_used, out) = match result_and_state.result { ExecutionResult::Success { reason, gas_used, output, .. } => { (eval_to_instruction_result(reason), gas_used, Some(output)) @@ -1141,15 +1139,15 @@ impl Backend { let to = if let Some(to) = request.to { to } else { - let nonce = state.basic(h160_to_b160(from))?.unwrap_or_default().nonce; + let nonce = state.basic(from.to_alloy())?.unwrap_or_default().nonce; get_contract_address(from, nonce) }; let mut tracer = AccessListTracer::new( AccessList(request.access_list.clone().unwrap_or_default()), - h160_to_b160(from), - h160_to_b160(to), - self.precompiles().into_iter().map(h160_to_b160).collect(), + from.to_alloy(), + to.to_alloy(), + self.precompiles().into_iter().map(|p| p.to_alloy()).collect(), ); let mut evm = revm::EVM::new(); @@ -1588,15 +1586,13 @@ impl Backend { .with_pending_block(pool_transactions, |state, block| { let block = block.block; let block = BlockEnv { - number: u256_to_ru256(block.header.number), - coinbase: h160_to_b160(block.header.beneficiary), + number: block.header.number.to_alloy(), + coinbase: block.header.beneficiary.to_alloy(), timestamp: rU256::from(block.header.timestamp), - difficulty: u256_to_ru256(block.header.difficulty), - prevrandao: Some(block.header.mix_hash).map(h256_to_b256), - basefee: u256_to_ru256( - block.header.base_fee_per_gas.unwrap_or_default(), - ), - gas_limit: u256_to_ru256(block.header.gas_limit), + difficulty: block.header.difficulty.to_alloy(), + prevrandao: Some(block.header.mix_hash).map(|h| h.to_alloy()), + basefee: block.header.base_fee_per_gas.unwrap_or_default().to_alloy(), + gas_limit: block.header.gas_limit.to_alloy(), ..Default::default() }; f(state, block) @@ -1609,7 +1605,7 @@ impl Backend { }; let block_number: U256 = self.convert_block_number(block_number).into(); - if u256_to_ru256(block_number) < self.env.read().block.number { + if block_number.to_alloy() < self.env.read().block.number { { let mut states = self.states.write(); @@ -1618,13 +1614,13 @@ impl Backend { .and_then(|block| Some((states.get(&block.header.hash())?, block))) { let block = BlockEnv { - number: u256_to_ru256(block.header.number), - coinbase: h160_to_b160(block.header.beneficiary), + number: block.header.number.to_alloy(), + coinbase: block.header.beneficiary.to_alloy(), timestamp: rU256::from(block.header.timestamp), - difficulty: u256_to_ru256(block.header.difficulty), - prevrandao: Some(block.header.mix_hash).map(h256_to_b256), - basefee: u256_to_ru256(block.header.base_fee_per_gas.unwrap_or_default()), - gas_limit: u256_to_ru256(block.header.gas_limit), + difficulty: block.header.difficulty.to_alloy(), + prevrandao: Some(block.header.mix_hash).map(|h| h.to_alloy()), + basefee: block.header.base_fee_per_gas.unwrap_or_default().to_alloy(), + gas_limit: block.header.gas_limit.to_alloy(), ..Default::default() }; return Ok(f(Box::new(state), block)) @@ -1642,9 +1638,9 @@ impl Backend { let db = self.db.read().await; let gen_db = self.genesis.state_db_at_genesis(Box::new(&*db)); - block.number = u256_to_ru256(block_number); + block.number = block_number.to_alloy(); block.timestamp = rU256::from(fork.timestamp()); - block.basefee = u256_to_ru256(fork.base_fee().unwrap_or_default()); + block.basefee = fork.base_fee().unwrap_or_default().to_alloy(); return Ok(f(Box::new(&gen_db), block)) } @@ -1652,7 +1648,7 @@ impl Backend { warn!(target: "backend", "Not historic state found for block={}", block_number); return Err(BlockchainError::BlockOutOfRange( - ru256_to_u256(self.env.read().block.number).as_u64(), + self.env.read().block.number.to_ethers().as_u64(), block_number.as_u64(), )) } @@ -1670,8 +1666,8 @@ impl Backend { ) -> Result { self.with_database_at(block_request, |db, _| { trace!(target: "backend", "get storage for {:?} at {:?}", address, index); - let val = db.storage(h160_to_b160(address), u256_to_ru256(index))?; - Ok(u256_to_h256_be(ru256_to_u256(val))) + let val = db.storage(address.to_alloy(), index.to_alloy())?; + Ok(u256_to_h256_be(val.to_ethers())) }) .await? } @@ -1697,7 +1693,7 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get code for {:?}", address); - let account = state.basic(h160_to_b160(address))?.unwrap_or_default(); + let account = state.basic(address.to_alloy())?.unwrap_or_default(); if account.code_hash == KECCAK_EMPTY { // if the code hash is `KECCAK_EMPTY`, we check no further return Ok(Default::default()) @@ -1731,7 +1727,7 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get balance for {:?}", address); - Ok(state.basic(h160_to_b160(address))?.unwrap_or_default().balance).map(ru256_to_u256) + Ok(state.basic(address.to_alloy())?.unwrap_or_default().balance.to_ethers()) } /// Returns the nonce of the address @@ -1754,7 +1750,7 @@ impl Backend { }; self.with_database_at(final_block_request, |db, _| { trace!(target: "backend", "get nonce for {:?}", address); - Ok(db.basic(h160_to_b160(address))?.unwrap_or_default().nonce.into()) + Ok(db.basic(address.to_alloy())?.unwrap_or_default().nonce.into()) }) .await? } @@ -2196,7 +2192,7 @@ impl TransactionValidator for Backend { } // Check gas limit, iff block gas limit is set. - if !env.cfg.disable_block_gas_limit && tx.gas_limit() > ru256_to_u256(env.block.gas_limit) { + if !env.cfg.disable_block_gas_limit && tx.gas_limit() > env.block.gas_limit.to_ethers() { warn!(target: "backend", "[{:?}] gas too high", tx.hash()); return Err(InvalidTransactionError::GasTooHigh(ErrDetail { detail: String::from("tx.gas_limit > env.block.gas_limit"), @@ -2212,7 +2208,7 @@ impl TransactionValidator for Backend { } if (env.cfg.spec_id as u8) >= (SpecId::LONDON as u8) { - if tx.gas_price() < ru256_to_u256(env.block.basefee) { + if tx.gas_price() < env.block.basefee.to_ethers() { warn!(target: "backend", "max fee per gas={}, too low, block basefee={}",tx.gas_price(), env.block.basefee); return Err(InvalidTransactionError::FeeCapTooLow) } @@ -2236,7 +2232,7 @@ impl TransactionValidator for Backend { InvalidTransactionError::InsufficientFunds })?; - if account.balance < u256_to_ru256(req_funds) { + if account.balance < req_funds.to_alloy() { warn!(target: "backend", "[{:?}] insufficient allowance={}, required={} account={:?}", tx.hash(), account.balance, req_funds, *pending.sender()); return Err(InvalidTransactionError::InsufficientFunds) } diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index ad90b6bddb192..81e2789a42b84 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -5,7 +5,6 @@ use alloy_primitives::{Address as rAddress, U256 as rU256}; use anvil_core::eth::{state::StateOverride, trie::RefSecTrieDBMut}; use bytes::Bytes; use ethers::{ - abi::ethereum_types::BigEndianHash, types::H256, utils::{rlp, rlp::RlpStream}, }; @@ -15,9 +14,9 @@ use foundry_evm::{ db::{CacheDB, DbAccount}, primitives::{AccountInfo, Bytecode, Log}, }, - utils::{b160_to_h160, b256_to_h256, h160_to_b160, ru256_to_u256, u256_to_ru256}, HashMap as Map, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use memory_db::HashKey; use trie_db::TrieMut; @@ -28,9 +27,9 @@ pub fn log_rlp_hash(logs: Vec) -> H256 { let mut stream = RlpStream::new(); stream.begin_unbounded_list(); for log in logs { - let topics = log.topics.into_iter().map(b256_to_h256).collect::>(); + let topics = log.topics.into_iter().map(|t| t.to_ethers()).collect::>(); stream.begin_list(3); - stream.append(&b160_to_h160(log.address)); + stream.append(&(log.address.to_ethers())); stream.append_list(&topics); stream.append(&log.data.0); } @@ -51,9 +50,9 @@ pub fn storage_trie_db(storage: &Map) -> (AsHashDB, H256) { let mut trie = RefSecTrieDBMut::new(&mut db, &mut root); for (k, v) in storage.iter().filter(|(_k, v)| *v != &rU256::from(0)) { let mut temp: [u8; 32] = [0; 32]; - ru256_to_u256(*k).to_big_endian(&mut temp); + (*k).to_ethers().to_big_endian(&mut temp); let key = H256::from(temp); - let value = rlp::encode(&ru256_to_u256(*v)); + let value = rlp::encode(&(*v).to_ethers()); trie.insert(key.as_bytes(), value.as_ref()).unwrap(); } } @@ -102,7 +101,7 @@ pub fn state_merkle_trie_root(accounts: &Map) -> H256 { pub fn trie_account_rlp(info: &AccountInfo, storage: &Map) -> Bytes { let mut stream = RlpStream::new_list(4); stream.append(&info.nonce); - stream.append(&ru256_to_u256(info.balance)); + stream.append(&info.balance.to_ethers()); stream.append(&storage_trie_db(storage).1); stream.append(&info.code_hash.as_slice()); stream.out().freeze() @@ -118,7 +117,7 @@ where { let mut cache_db = CacheDB::new(state); for (account, account_overrides) in overrides.iter() { - let mut account_info = cache_db.basic(h160_to_b160(*account))?.unwrap_or_default(); + let mut account_info = cache_db.basic((*account).to_alloy())?.unwrap_or_default(); if let Some(nonce) = account_overrides.nonce { account_info.nonce = nonce; @@ -127,10 +126,10 @@ where account_info.code = Some(Bytecode::new_raw(code.to_vec().into())); } if let Some(balance) = account_overrides.balance { - account_info.balance = u256_to_ru256(balance); + account_info.balance = balance.to_alloy(); } - cache_db.insert_account_info(h160_to_b160(*account), account_info); + cache_db.insert_account_info((*account).to_alloy(), account_info); // We ensure that not both state and state_diff are set. // If state is set, we must mark the account as "NewlyCreated", so that the old storage @@ -144,21 +143,19 @@ where (None, None) => (), (Some(new_account_state), None) => { cache_db.replace_account_storage( - h160_to_b160(*account), + (*account).to_alloy(), new_account_state .iter() - .map(|(key, value)| { - (u256_to_ru256(key.into_uint()), u256_to_ru256(value.into_uint())) - }) + .map(|(key, value)| (key.to_alloy().into(), (value.to_alloy().into()))) .collect(), )?; } (None, Some(account_state_diff)) => { for (key, value) in account_state_diff.iter() { cache_db.insert_account_storage( - h160_to_b160(*account), - u256_to_ru256(key.into_uint()), - u256_to_ru256(value.into_uint()), + (*account).to_alloy(), + key.to_alloy().into(), + value.to_alloy().into(), )?; } } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index bbd379c30fe50..39b885e47f5f2 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -15,10 +15,8 @@ use ethers::{ prelude::{BlockId, BlockNumber, DefaultFrame, Trace, H256, H256 as TxHash, U64}, types::{ActionType, Bytes, GethDebugTracingOptions, TransactionReceipt, U256}, }; -use foundry_evm::{ - revm::{interpreter::InstructionResult, primitives::Env}, - utils::{b160_to_h160, ru256_to_u256}, -}; +use foundry_evm::revm::{interpreter::InstructionResult, primitives::Env}; +use foundry_utils::types::ToEthers; use parking_lot::RwLock; use std::{ collections::{HashMap, VecDeque}, @@ -229,9 +227,9 @@ impl BlockchainStorage { let partial_header = PartialHeader { timestamp, base_fee, - gas_limit: ru256_to_u256(env.block.gas_limit), - beneficiary: b160_to_h160(env.block.coinbase), - difficulty: ru256_to_u256(env.block.difficulty), + gas_limit: env.block.gas_limit.to_ethers(), + beneficiary: env.block.coinbase.to_ethers(), + difficulty: env.block.difficulty.to_ethers(), ..Default::default() }; let block = Block::new::(partial_header, vec![], vec![]); @@ -432,8 +430,8 @@ mod tests { db::DatabaseRef, primitives::{AccountInfo, U256 as rU256}, }, - utils::h160_to_b160, }; + use foundry_utils::types::ToAlloy; #[test] fn test_interval_update() { @@ -463,7 +461,7 @@ mod tests { let loaded = storage.get(&one).unwrap(); - let acc = loaded.basic(h160_to_b160(addr)).unwrap().unwrap(); + let acc = loaded.basic(addr.to_alloy()).unwrap().unwrap(); assert_eq!(acc.balance, rU256::from(1337u64)); } @@ -493,7 +491,7 @@ mod tests { let hash = H256::from_uint(&U256::from(idx)); let addr = Address::from(hash); let loaded = storage.get(&hash).unwrap(); - let acc = loaded.basic(h160_to_b160(addr)).unwrap().unwrap(); + let acc = loaded.basic(addr.to_alloy()).unwrap().unwrap(); let balance = (idx * 2) as u64; assert_eq!(acc.balance, rU256::from(balance)); } diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 52deb5b27b0a0..56cba8360483e 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -5,10 +5,8 @@ use ethers::{ types::{serde_helpers::*, Address, Bytes, H256, U256}, }; use foundry_common::errors::FsPathError; -use foundry_evm::{ - revm::primitives::{Bytecode, Env, KECCAK_EMPTY, U256 as rU256}, - utils::{h160_to_b160, u256_to_ru256}, -}; +use foundry_evm::revm::primitives::{Bytecode, Env, KECCAK_EMPTY, U256 as rU256}; +use foundry_utils::types::ToAlloy; use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashMap}, @@ -92,13 +90,13 @@ impl Genesis { env.block.timestamp = rU256::from(timestamp); } if let Some(base_fee) = self.base_fee_per_gas { - env.block.basefee = u256_to_ru256(base_fee); + env.block.basefee = base_fee.to_alloy(); } if let Some(number) = self.number { env.block.number = rU256::from(number); } if let Some(coinbase) = self.coinbase { - env.block.coinbase = h160_to_b160(coinbase); + env.block.coinbase = coinbase.to_alloy(); } env.block.difficulty = rU256::from(self.difficulty); env.block.gas_limit = rU256::from(self.gas_limit); @@ -144,7 +142,7 @@ impl From for AccountInfo { let GenesisAccount { code, balance, nonce, .. } = acc; let code = code.map(|code| Bytecode::new_raw(code.to_vec().into())); AccountInfo { - balance: u256_to_ru256(balance), + balance: balance.to_alloy(), nonce: nonce.unwrap_or_default(), code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), code, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 2ea81e2519d1b..6165929ae8510 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -15,8 +15,7 @@ use ethers::{ }; use foundry_common::get_http_provider; use foundry_config::Config; -use foundry_evm::utils::{h160_to_b160, u256_to_ru256}; -use foundry_utils::{rpc, rpc::next_http_rpc_endpoint}; +use foundry_utils::{rpc, rpc::next_http_rpc_endpoint, types::ToAlloy}; use futures::StreamExt; use std::{sync::Arc, time::Duration}; @@ -278,9 +277,9 @@ async fn test_separate_states() { let fork = api.get_fork().unwrap(); let fork_db = fork.database.read().await; - let acc = fork_db.inner().db().accounts.read().get(&h160_to_b160(addr)).cloned().unwrap(); + let acc = fork_db.inner().db().accounts.read().get(&addr.to_alloy()).cloned().unwrap(); - assert_eq!(acc.balance, u256_to_ru256(remote_balance)) + assert_eq!(acc.balance, remote_balance.to_alloy()) } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs index e56e8169ba8af..a85a1bacacf51 100644 --- a/crates/anvil/tests/it/proof/mod.rs +++ b/crates/anvil/tests/it/proof/mod.rs @@ -7,11 +7,12 @@ use ethers::{ }; use anvil_core::eth::proof::{AccountProof, BasicAccount}; +use foundry_utils::types::ToEthers; use crate::proof::eip1186::verify_proof; use anvil_core::eth::trie::ExtensionLayout; use ethers::utils::{keccak256, rlp}; -use foundry_evm::{revm::primitives::KECCAK_EMPTY, utils::b256_to_h256}; +use foundry_evm::revm::primitives::KECCAK_EMPTY; mod eip1186; @@ -32,7 +33,7 @@ async fn can_get_proof() { nonce: 0.into(), balance: 0.into(), storage_root: proof.storage_hash, - code_hash: b256_to_h256(KECCAK_EMPTY), + code_hash: KECCAK_EMPTY.to_ethers(), }; let rlp_account = rlp::encode(&account); diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 08e759610be68..bb7f05195e010 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -11,11 +11,8 @@ use foundry_cli::{ }; use foundry_common::runtime_client::RuntimeClient; use foundry_config::{find_project_root_path, Config}; -use foundry_evm::{ - executor::opts::EvmOpts, - trace::TracingExecutor, - utils::{h160_to_b160, u256_to_ru256}, -}; +use foundry_evm::{executor::opts::EvmOpts, trace::TracingExecutor}; +use foundry_utils::types::ToAlloy; use std::str::FromStr; type Provider = ethers::providers::Provider; @@ -159,9 +156,9 @@ impl CallArgs { .await; let trace = match executor.deploy( - h160_to_b160(sender), + sender.to_alloy(), code.into_bytes().into(), - u256_to_ru256(value.unwrap_or(U256::zero())), + value.unwrap_or(U256::zero()).to_alloy(), None, ) { Ok(deploy_result) => TraceResult::from(deploy_result), @@ -196,10 +193,10 @@ impl CallArgs { let (tx, _) = builder.build(); let trace = TraceResult::from(executor.call_raw_committing( - h160_to_b160(sender), - h160_to_b160(tx.to_addr().copied().expect("an address to be here")), + sender.to_alloy(), + tx.to_addr().copied().expect("an address to be here").to_alloy(), tx.data().cloned().unwrap_or_default().to_vec().into(), - u256_to_ru256(tx.value().copied().unwrap_or_default()), + tx.value().copied().unwrap_or_default().to_alloy(), )?); handle_traces(trace, &config, chain, labels, verbose, debug).await?; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 919195337b25a..4ab9299511755 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -12,8 +12,8 @@ use foundry_evm::{ executor::{inspector::cheatcodes::util::configure_tx_env, opts::EvmOpts, EvmError}, revm::primitives::U256 as rU256, trace::TracingExecutor, - utils::{h160_to_b160, h256_to_b256, u256_to_ru256}, }; +use foundry_utils::types::ToAlloy; use tracing::trace; const ARBITRUM_SENDER: H160 = H160([ @@ -117,12 +117,12 @@ impl RunArgs { let block = provider.get_block_with_txs(tx_block_number).await?; if let Some(ref block) = block { - env.block.timestamp = u256_to_ru256(block.timestamp); - env.block.coinbase = h160_to_b160(block.author.unwrap_or_default()); - env.block.difficulty = u256_to_ru256(block.difficulty); - env.block.prevrandao = block.mix_hash.map(h256_to_b256); - env.block.basefee = u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()); - env.block.gas_limit = u256_to_ru256(block.gas_limit); + env.block.timestamp = block.timestamp.to_alloy(); + env.block.coinbase = block.author.unwrap_or_default().to_alloy(); + env.block.difficulty = block.difficulty.to_alloy(); + env.block.prevrandao = block.mix_hash.map(|h| h.to_alloy()); + env.block.basefee = block.base_fee_per_gas.unwrap_or_default().to_alloy(); + env.block.gas_limit = block.gas_limit.to_alloy(); } // Set the state to the moment right before the transaction diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 043e3424bfd37..43fa2f5a53573 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -23,6 +23,7 @@ foundry-evm.workspace = true foundry-config.workspace = true foundry-cli.workspace = true foundry-common.workspace = true +foundry-utils.workspace = true forge-fmt.workspace = true # ethers diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 073f2c6cc2998..eb86917dd54ef 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -16,8 +16,8 @@ use eyre::{Result, WrapErr}; use foundry_evm::{ decode::decode_console_logs, executor::{inspector::CheatsConfig, Backend, ExecutorBuilder}, - utils::ru256_to_u256, }; +use foundry_utils::types::ToEthers; use solang_parser::pt::{self, CodeLocation}; use yansi::Paint; @@ -223,7 +223,7 @@ impl SessionSource { // the file compiled correctly, thus the last stack item must be the memory offset of // the `bytes memory inspectoor` value - let mut offset = ru256_to_u256(*stack.data().last().unwrap()).as_usize(); + let mut offset = stack.data().last().unwrap().to_ethers().as_usize(); let mem = memory.data(); let len = U256::from(&mem[offset..offset + 32]).as_usize(); offset += 32; diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 72b888b4e984c..e0e1cfa57300c 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -12,8 +12,8 @@ use foundry_evm::{ executor::{DeployResult, Executor, RawCallResult}, revm::primitives::U256 as rU256, trace::{CallTraceArena, TraceKind}, - utils::{b160_to_h160, h160_to_b160, u256_to_ru256}, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::interpreter::{return_ok, InstructionResult}; use std::collections::BTreeMap; @@ -94,18 +94,17 @@ impl ChiselRunner { /// contract. pub fn run(&mut self, bytecode: Bytes) -> Result<(Address, ChiselResult)> { // Set the sender's balance to [U256::MAX] for deployment of the REPL contract. - self.executor.set_balance(h160_to_b160(self.sender), rU256::MAX)?; + self.executor.set_balance(self.sender.to_alloy(), rU256::MAX)?; // Deploy an instance of the REPL contract // We don't care about deployment traces / logs here let DeployResult { address, .. } = self .executor - .deploy(h160_to_b160(self.sender), bytecode.0.into(), rU256::ZERO, None) + .deploy(self.sender.to_alloy(), bytecode.0.into(), rU256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy REPL contract:\n{}", err))?; // Reset the sender's balance to the initial balance for calls. - self.executor - .set_balance(h160_to_b160(self.sender), u256_to_ru256(self.initial_balance))?; + self.executor.set_balance(self.sender.to_alloy(), self.initial_balance.to_alloy())?; // Append the input to the `RUN_SELECTOR` to form the calldata let mut calldata = RUN_SELECTOR.to_vec(); @@ -115,9 +114,9 @@ impl ChiselRunner { // Call the "run()" function of the REPL contract let call_res = - self.call(self.sender, b160_to_h160(address), Bytes::from(calldata), 0.into(), true); + self.call(self.sender, address.to_ethers(), Bytes::from(calldata), 0.into(), true); - call_res.map(|res| (b160_to_h160(address), res)) + call_res.map(|res| (address.to_ethers(), res)) } /// Executes the call @@ -145,10 +144,10 @@ impl ChiselRunner { }; let mut res = self.executor.call_raw( - h160_to_b160(from), - h160_to_b160(to), + from.to_alloy(), + to.to_alloy(), calldata.0.clone().into(), - u256_to_ru256(value), + value.to_alloy(), )?; let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { @@ -166,10 +165,10 @@ impl ChiselRunner { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; self.executor.env.tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw( - h160_to_b160(from), - h160_to_b160(to), + from.to_alloy(), + to.to_alloy(), calldata.0.clone().into(), - u256_to_ru256(value), + value.to_alloy(), )?; match res.exit_reason { InstructionResult::Revert | @@ -206,20 +205,20 @@ impl ChiselRunner { } res = self.executor.call_raw( - h160_to_b160(from), - h160_to_b160(to), + from.to_alloy(), + to.to_alloy(), calldata.0.clone().into(), - u256_to_ru256(value), + value.to_alloy(), )?; } if commit { // if explicitly requested we can now commit the call res = self.executor.call_raw_committing( - h160_to_b160(from), - h160_to_b160(to), + from.to_alloy(), + to.to_alloy(), calldata.0.clone().into(), - u256_to_ru256(value), + value.to_alloy(), )?; } @@ -238,7 +237,7 @@ impl ChiselRunner { vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), - labeled_addresses: labels.into_iter().map(|l| (b160_to_h160(l.0), l.1)).collect(), + labeled_addresses: labels.into_iter().map(|l| (l.0.to_ethers(), l.1)).collect(), address: None, state: chisel_state, }) diff --git a/crates/evm/src/executor/backend/diagnostic.rs b/crates/evm/src/executor/backend/diagnostic.rs index 66e0857288661..6f3b48a9bb707 100644 --- a/crates/evm/src/executor/backend/diagnostic.rs +++ b/crates/evm/src/executor/backend/diagnostic.rs @@ -1,7 +1,4 @@ -use crate::{ - executor::{backend::LocalForkId, inspector::Cheatcodes}, - utils::b160_to_h160, -}; +use crate::executor::{backend::LocalForkId, inspector::Cheatcodes}; use alloy_primitives::Address; use foundry_common::fmt::UIfmt; use foundry_utils::types::ToEthers; @@ -43,7 +40,7 @@ impl RevertDiagnostic { ) } RevertDiagnostic::ContractDoesNotExist { contract, persistent, .. } => { - let contract_label = get_label(&b160_to_h160(*contract)); + let contract_label = get_label(&contract.to_ethers()); if *persistent { format!("Contract {contract_label} does not exist") } else { diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index 768d8767b49bb..11dee7b3c8d7e 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -8,7 +8,6 @@ use crate::{ inspector::{cheatcodes::Cheatcodes, DEFAULT_CREATE2_DEPLOYER}, snapshot::Snapshots, }, - utils::{b256_to_h256, h160_to_b160, h256_to_b256, ru256_to_u256, u256_to_ru256, u64_to_ru64}, CALLER, TEST_CONTRACT_ADDRESS, }; use alloy_primitives::{b256, Address, B256, U256, U64}; @@ -17,6 +16,7 @@ use ethers::{ types::{BlockNumber, Transaction}, utils::keccak256, }; +use foundry_utils::types::{ToAlloy, ToEthers}; pub use in_memory_db::MemDb; use revm::{ db::{CacheDB, DatabaseRef}, @@ -858,10 +858,10 @@ impl Backend { let full_block = fork .db .db - .get_full_block(BlockNumber::Number(ru256_to_u256(env.block.number).as_u64().into()))?; + .get_full_block(BlockNumber::Number(env.block.number.to_ethers().as_u64().into()))?; for tx in full_block.transactions.into_iter() { - if tx.hash().eq(&b256_to_h256(tx_hash)) { + if tx.hash().eq(&tx_hash.to_ethers()) { // found the target transaction return Ok(Some(tx)) } @@ -1150,13 +1150,13 @@ impl DatabaseExt for Backend { self.roll_fork(Some(id), fork_block.to(), env, journaled_state)?; // update the block's env accordingly - env.block.timestamp = u256_to_ru256(block.timestamp); - env.block.coinbase = h160_to_b160(block.author.unwrap_or_default()); - env.block.difficulty = u256_to_ru256(block.difficulty); - env.block.prevrandao = block.mix_hash.map(h256_to_b256); - env.block.basefee = u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()); - env.block.gas_limit = u256_to_ru256(block.gas_limit); - env.block.number = block.number.map(u64_to_ru64).unwrap_or(fork_block).to(); + env.block.timestamp = block.timestamp.to_alloy(); + env.block.coinbase = block.author.unwrap_or_default().to_alloy(); + env.block.difficulty = block.difficulty.to_alloy(); + env.block.prevrandao = block.mix_hash.map(|h| h.to_alloy()); + env.block.basefee = block.base_fee_per_gas.unwrap_or_default().to_alloy(); + env.block.gas_limit = block.gas_limit.to_alloy(); + env.block.number = block.number.map(|n| n.to_alloy()).unwrap_or(fork_block).to(); // replay all transactions that came before let env = env.clone(); diff --git a/crates/evm/src/executor/fork/backend.rs b/crates/evm/src/executor/fork/backend.rs index ade1e6382363a..b589f0c2ad0c8 100644 --- a/crates/evm/src/executor/fork/backend.rs +++ b/crates/evm/src/executor/fork/backend.rs @@ -1,10 +1,7 @@ //! Smart caching and deduplication of requests when using a forking provider -use crate::{ - executor::{ - backend::error::{DatabaseError, DatabaseResult}, - fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, - }, - utils::{b160_to_h160, b256_to_h256, h256_to_b256, u256_to_ru256}, +use crate::executor::{ + backend::error::{DatabaseError, DatabaseResult}, + fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers::{ @@ -14,6 +11,7 @@ use ethers::{ utils::keccak256, }; use foundry_common::NON_ARCHIVE_NODE_WARNING; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::{ channel::mpsc::{channel, Receiver, Sender}, stream::Stream, @@ -194,12 +192,12 @@ where let idx_req = B256::from(idx); let storage = provider .get_storage_at( - NameOrAddress::Address(b160_to_h160(address)), - b256_to_h256(idx_req), + NameOrAddress::Address(address.to_ethers()), + idx_req.to_ethers(), block_id, ) .await; - let storage = storage.map(|storage| storage.into_uint()).map(u256_to_ru256); + let storage = storage.map(|storage| storage.into_uint()).map(|s| s.to_alloy()); (storage, address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); @@ -214,12 +212,12 @@ where let block_id = self.block_id; let fut = Box::pin(async move { let balance = - provider.get_balance(NameOrAddress::Address(b160_to_h160(address)), block_id); + provider.get_balance(NameOrAddress::Address(address.to_ethers()), block_id); let nonce = provider - .get_transaction_count(NameOrAddress::Address(b160_to_h160(address)), block_id); - let code = provider.get_code(NameOrAddress::Address(b160_to_h160(address)), block_id); + .get_transaction_count(NameOrAddress::Address(address.to_ethers()), block_id); + let code = provider.get_code(NameOrAddress::Address(address.to_ethers()), block_id); let resp = tokio::try_join!(balance, nonce, code).map(|(balance, nonce, code)| { - (u256_to_ru256(balance), u256_to_ru256(nonce), Bytes::from(code.0)) + (balance.to_alloy(), nonce.to_alloy(), Bytes::from(code.0)) }); (resp, address) }); @@ -254,7 +252,7 @@ where fn request_transaction(&mut self, tx: B256, sender: TransactionSender) { let provider = self.provider.clone(); let fut = Box::pin(async move { - let block = provider.get_transaction(b256_to_h256(tx)).await; + let block = provider.get_transaction(tx.to_ethers()).await; (sender, block, tx) }); @@ -282,14 +280,14 @@ where warn!(target: "backendhandler", ?number, "block not found"); // if no block was returned then the block does not exist, in which case // we return empty hash - Ok(b256_to_h256(KECCAK_EMPTY)) + Ok(KECCAK_EMPTY.to_ethers()) } Err(err) => { error!(target: "backendhandler", ?err, ?number, "failed to get block"); Err(err) } }; - (block_hash.map(h256_to_b256), number) + (block_hash.map(|h| h.to_alloy()), number) }); self.pending_requests.push(ProviderRequest::BlockHash(fut)); } diff --git a/crates/evm/src/executor/fork/init.rs b/crates/evm/src/executor/fork/init.rs index 09c607bedb54e..f04a19a89cb80 100644 --- a/crates/evm/src/executor/fork/init.rs +++ b/crates/evm/src/executor/fork/init.rs @@ -1,6 +1,4 @@ -use crate::utils::{ - apply_chain_and_block_specific_env_changes, h160_to_b160, h256_to_b256, u256_to_ru256, -}; +use crate::utils::apply_chain_and_block_specific_env_changes; use alloy_primitives::{Address, U256}; use ethers::{ providers::Middleware, @@ -8,6 +6,7 @@ use ethers::{ }; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; +use foundry_utils::types::ToAlloy; use futures::TryFutureExt; use revm::primitives::{BlockEnv, CfgEnv, Env, TxEnv}; @@ -71,18 +70,18 @@ where let mut env = Env { cfg, block: BlockEnv { - number: u256_to_ru256(block.number.expect("block number not found").as_u64().into()), - timestamp: u256_to_ru256(block.timestamp), - coinbase: h160_to_b160(block.author.unwrap_or_default()), - difficulty: u256_to_ru256(block.difficulty), - prevrandao: Some(block.mix_hash.map(h256_to_b256).unwrap_or_default()), - basefee: u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()), - gas_limit: u256_to_ru256(block.gas_limit), + number: U256::from(block.number.expect("block number not found").as_u64()), + timestamp: block.timestamp.to_alloy(), + coinbase: block.author.unwrap_or_default().to_alloy(), + difficulty: block.difficulty.to_alloy(), + prevrandao: Some(block.mix_hash.map(|h| h.to_alloy()).unwrap_or_default()), + basefee: block.base_fee_per_gas.unwrap_or_default().to_alloy(), + gas_limit: block.gas_limit.to_alloy(), ..Default::default() }, tx: TxEnv { caller: origin, - gas_price: gas_price.map(U256::from).unwrap_or(u256_to_ru256(fork_gas_price)), + gas_price: gas_price.map(U256::from).unwrap_or(fork_gas_price.to_alloy()), chain_id: Some(override_chain_id.unwrap_or(rpc_chain_id.as_u64())), gas_limit: block.gas_limit.as_u64(), ..Default::default() diff --git a/crates/evm/src/executor/fork/multi.rs b/crates/evm/src/executor/fork/multi.rs index f2dafbfc333c1..2393cd450c075 100644 --- a/crates/evm/src/executor/fork/multi.rs +++ b/crates/evm/src/executor/fork/multi.rs @@ -3,9 +3,8 @@ //! The design is similar to the single `SharedBackend`, `BackendHandler` but supports multiple //! concurrently active pairs at once. -use crate::{ - executor::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}, - utils::ru256_to_u256, +use crate::executor::fork::{ + BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend, }; use ethers::{ abi::{AbiDecode, AbiEncode, AbiError}, @@ -14,6 +13,7 @@ use ethers::{ }; use foundry_common::{runtime_client::RuntimeClient, ProviderBuilder}; use foundry_config::Config; +use foundry_utils::types::ToEthers; use futures::{ channel::mpsc::{channel, Receiver, Sender}, stream::{Fuse, Stream}, @@ -497,7 +497,7 @@ async fn create_fork( let number = block .number .map(|num| num.as_u64()) - .unwrap_or_else(|| ru256_to_u256(meta.block_env.number).as_u64()); + .unwrap_or_else(|| meta.block_env.number.to_ethers().as_u64()); // determine the cache path if caching is enabled let cache_path = if fork.enable_caching { diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/src/executor/inspector/access_list.rs index 108b90ff1f0dd..5deaa800b0cb7 100644 --- a/crates/evm/src/executor/inspector/access_list.rs +++ b/crates/evm/src/executor/inspector/access_list.rs @@ -1,13 +1,12 @@ use alloy_primitives::{Address, B256}; use ethers::types::transaction::eip2930::{AccessList, AccessListItem}; +use foundry_utils::types::{ToAlloy, ToEthers}; use hashbrown::{HashMap, HashSet}; use revm::{ interpreter::{opcode, InstructionResult, Interpreter}, Database, EVMData, Inspector, }; -use crate::utils::{b160_to_h160, b256_to_h256, h160_to_b160, h256_to_b256}; - /// An inspector that collects touched accounts and storage slots. #[derive(Default, Debug)] pub struct AccessListTracer { @@ -29,8 +28,8 @@ impl AccessListTracer { .iter() .map(|v| { ( - h160_to_b160(v.address), - v.storage_keys.iter().copied().map(h256_to_b256).collect(), + v.address.to_alloy(), + v.storage_keys.iter().copied().map(|v| v.to_alloy()).collect(), ) }) .collect(), @@ -41,8 +40,8 @@ impl AccessListTracer { self.access_list .iter() .map(|(address, slots)| AccessListItem { - address: b160_to_h160(*address), - storage_keys: slots.iter().copied().map(b256_to_h256).collect(), + address: address.to_ethers(), + storage_keys: slots.iter().copied().map(|k| k.to_ethers()).collect(), }) .collect::>(), ) diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index 5afa17285ba03..1e96024cce9c9 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -9,17 +9,16 @@ use crate::{ DealRecord, }, }, - utils::{b160_to_h160, h160_to_b160, ru256_to_u256, u256_to_ru256}, }; use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{Bytes, B256}; +use alloy_primitives::{Bytes, B256, U256 as rU256}; use ethers::{ abi::{self, RawLog, Token, Tokenizable, Tokenize}, signers::{LocalWallet, Signer}, types::{Address, U256}, }; use foundry_config::Config; -use foundry_utils::types::ToAlloy; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::{ primitives::{Bytecode, SpecId, KECCAK_EMPTY}, Database, EVMData, @@ -323,7 +322,7 @@ fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: boo // mark the slots of an account and the account address as cold fn cool_account(data: &mut EVMData<'_, DB>, address: Address) -> Result { - if let Some(account) = data.journaled_state.state.get_mut(&h160_to_b160(address)) { + if let Some(account) = data.journaled_state.state.get_mut(&address.to_alloy()) { if account.is_touched() { account.unmark_touch(); } @@ -342,7 +341,7 @@ pub fn apply( ) -> Result> { let result = match call { HEVMCalls::Warp(inner) => { - data.env.block.timestamp = u256_to_ru256(inner.0); + data.env.block.timestamp = inner.0.to_alloy(); Bytes::new() } HEVMCalls::Difficulty(inner) => { @@ -352,7 +351,7 @@ pub fn apply( use `prevrandao` instead. \ For more information, please see https://eips.ethereum.org/EIPS/eip-4399" ); - data.env.block.difficulty = u256_to_ru256(inner.0); + data.env.block.difficulty = inner.0.to_alloy(); Bytes::new() } HEVMCalls::Prevrandao(inner) => { @@ -366,27 +365,27 @@ pub fn apply( Bytes::new() } HEVMCalls::Roll(inner) => { - data.env.block.number = u256_to_ru256(inner.0); + data.env.block.number = inner.0.to_alloy(); Bytes::new() } HEVMCalls::Fee(inner) => { - data.env.block.basefee = u256_to_ru256(inner.0); + data.env.block.basefee = inner.0.to_alloy(); Bytes::new() } HEVMCalls::Coinbase(inner) => { - data.env.block.coinbase = h160_to_b160(inner.0); + data.env.block.coinbase = inner.0.to_alloy(); Bytes::new() } HEVMCalls::Store(inner) => { ensure!(!is_potential_precompile(inner.0), "Store cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); - data.journaled_state.load_account(h160_to_b160(inner.0), data.db)?; + data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; // ensure the account is touched - data.journaled_state.touch(&h160_to_b160(inner.0)); + data.journaled_state.touch(&inner.0.to_alloy()); data.journaled_state.sstore( - h160_to_b160(inner.0), - u256_to_ru256(inner.1.into()), - u256_to_ru256(inner.2.into()), + inner.0.to_alloy(), + rU256::from_be_bytes(inner.1), + rU256::from_be_bytes(inner.2), data.db, )?; Bytes::new() @@ -394,10 +393,10 @@ pub fn apply( HEVMCalls::Load(inner) => { ensure!(!is_potential_precompile(inner.0), "Load cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); // TODO: Does this increase gas usage? - data.journaled_state.load_account(h160_to_b160(inner.0), data.db)?; + data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; let (val, _) = data.journaled_state.sload( - h160_to_b160(inner.0), - u256_to_ru256(inner.1.into()), + inner.0.to_alloy(), + rU256::from_be_bytes(inner.1), data.db, )?; DynSolValue::from(val).encode_single().into() @@ -410,9 +409,9 @@ pub fn apply( let code = inner.1.clone(); trace!(address=?inner.0, code=?hex::encode(&code), "etch cheatcode"); // TODO: Does this increase gas usage? - data.journaled_state.load_account(h160_to_b160(inner.0), data.db)?; + data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; data.journaled_state.set_code( - h160_to_b160(inner.0), + inner.0.to_alloy(), Bytecode::new_raw(alloy_primitives::Bytes(code.0)).to_checked(), ); Bytes::new() @@ -425,19 +424,19 @@ pub fn apply( // record the deal let record = DealRecord { address: who, - old_balance: ru256_to_u256(account.info.balance), + old_balance: account.info.balance.to_ethers(), new_balance: value, }; state.eth_deals.push(record); - account.info.balance = u256_to_ru256(value); + account.info.balance = value.to_alloy(); })?; Bytes::new() } HEVMCalls::Prank0(inner) => prank( state, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), inner.0, None, data.journaled_state.depth(), @@ -446,7 +445,7 @@ pub fn apply( HEVMCalls::Prank1(inner) => prank( state, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), inner.0, Some(inner.1), data.journaled_state.depth(), @@ -455,7 +454,7 @@ pub fn apply( HEVMCalls::StartPrank0(inner) => prank( state, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), inner.0, None, data.journaled_state.depth(), @@ -464,7 +463,7 @@ pub fn apply( HEVMCalls::StartPrank1(inner) => prank( state, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), inner.0, Some(inner.1), data.journaled_state.depth(), @@ -475,7 +474,7 @@ pub fn apply( state.prank = None; Bytes::new() } - HEVMCalls::ReadCallers(_) => read_callers(state, b160_to_h160(data.env.tx.caller)), + HEVMCalls::ReadCallers(_) => read_callers(state, data.env.tx.caller.to_ethers()), HEVMCalls::Record(_) => { start_record(state); Bytes::new() @@ -532,7 +531,7 @@ pub fn apply( // [function getNonce(address)] returns the current nonce of a given ETH address HEVMCalls::GetNonce1(inner) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, @@ -540,16 +539,16 @@ pub fn apply( // TODO: this is probably not a good long-term solution since it might mess up the gas // calculations - data.journaled_state.load_account(h160_to_b160(inner.0), data.db)?; + data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; // we can safely unwrap because `load_account` insert inner.0 to DB. - let account = data.journaled_state.state().get(&h160_to_b160(inner.0)).unwrap(); + let account = data.journaled_state.state().get(&inner.0.to_alloy()).unwrap(); DynSolValue::from(account.info.nonce).encode_single().into() } // [function getNonce(Wallet)] returns the current nonce of the Wallet's ETH address HEVMCalls::GetNonce0(inner) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, @@ -557,10 +556,10 @@ pub fn apply( // TODO: this is probably not a good long-term solution since it might mess up the gas // calculations - data.journaled_state.load_account(h160_to_b160(inner.0.addr), data.db)?; + data.journaled_state.load_account(inner.0.addr.to_alloy(), data.db)?; // we can safely unwrap because `load_account` insert inner.0 to DB. - let account = data.journaled_state.state().get(&h160_to_b160(inner.0.addr)).unwrap(); + let account = data.journaled_state.state().get(&inner.0.addr.to_alloy()).unwrap(); DynSolValue::from(account.info.nonce.to_alloy()).encode_single().into() } HEVMCalls::ChainId(inner) => { @@ -569,28 +568,28 @@ pub fn apply( Bytes::new() } HEVMCalls::TxGasPrice(inner) => { - data.env.tx.gas_price = u256_to_ru256(inner.0); + data.env.tx.gas_price = inner.0.to_alloy(); Bytes::new() } HEVMCalls::Broadcast0(_) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, )?; broadcast( state, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), data.journaled_state.depth(), true, )? } HEVMCalls::Broadcast1(inner) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, @@ -599,14 +598,14 @@ pub fn apply( state, inner.0, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), data.journaled_state.depth(), true, )? } HEVMCalls::Broadcast2(inner) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, @@ -615,7 +614,7 @@ pub fn apply( state, inner.0, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), data.env.cfg.chain_id.into(), data.journaled_state.depth(), true, @@ -623,23 +622,23 @@ pub fn apply( } HEVMCalls::StartBroadcast0(_) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, )?; broadcast( state, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), data.journaled_state.depth(), false, )? } HEVMCalls::StartBroadcast1(inner) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, @@ -648,14 +647,14 @@ pub fn apply( state, inner.0, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), data.journaled_state.depth(), false, )? } HEVMCalls::StartBroadcast2(inner) => { correct_sender_nonce( - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), &mut data.journaled_state, &mut data.db, state, @@ -664,7 +663,7 @@ pub fn apply( state, inner.0, caller, - b160_to_h160(data.env.tx.caller), + data.env.tx.caller.to_ethers(), data.env.cfg.chain_id.into(), data.journaled_state.depth(), false, diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/src/executor/inspector/cheatcodes/expect.rs index 10f9983de7904..2ed5d88dc57f5 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/expect.rs @@ -1,12 +1,15 @@ use super::{bail, ensure, fmt_err, Cheatcodes, Result}; -use crate::{abi::HEVMCalls, executor::backend::DatabaseExt, utils::h160_to_b160}; +use crate::{abi::HEVMCalls, executor::backend::DatabaseExt}; use alloy_primitives::Bytes; use ethers::{ abi::{AbiDecode, RawLog}, contract::Lazy, types::{Address, H160, U256}, }; -use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; +use foundry_utils::{ + error::{ERROR_PREFIX, REVERT_PREFIX}, + types::ToAlloy, +}; use revm::{ interpreter::{return_ok, InstructionResult}, primitives::Bytecode, @@ -484,7 +487,7 @@ pub fn apply( } HEVMCalls::MockCall0(inner) => { // TODO: Does this increase gas usage? - if let Err(err) = data.journaled_state.load_account(h160_to_b160(inner.0), data.db) { + if let Err(err) = data.journaled_state.load_account(inner.0.to_alloy(), data.db) { return Some(Err(err.into())) } @@ -492,7 +495,7 @@ pub fn apply( // check Solidity might perform. let empty_bytecode = data .journaled_state - .account(h160_to_b160(inner.0)) + .account(inner.0.to_alloy()) .info .code .as_ref() @@ -501,7 +504,7 @@ pub fn apply( let code = Bytecode::new_raw(alloy_primitives::Bytes(bytes::Bytes::from_static(&[0u8]))) .to_checked(); - data.journaled_state.set_code(h160_to_b160(inner.0), code); + data.journaled_state.set_code(inner.0.to_alloy(), code); } state.mocked_calls.entry(inner.0).or_default().insert( MockCallDataContext { calldata: inner.1.clone().0.into(), value: None }, @@ -513,7 +516,7 @@ pub fn apply( Ok(Bytes::new()) } HEVMCalls::MockCall1(inner) => { - if let Err(err) = data.journaled_state.load_account(h160_to_b160(inner.0), data.db) { + if let Err(err) = data.journaled_state.load_account(inner.0.to_alloy(), data.db) { return Some(Err(err.into())) } diff --git a/crates/evm/src/executor/inspector/cheatcodes/fork.rs b/crates/evm/src/executor/inspector/cheatcodes/fork.rs index 447b04b561743..a29bca651bf50 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fork.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fork.rs @@ -4,7 +4,7 @@ use crate::{ executor::{ backend::DatabaseExt, fork::CreateFork, inspector::cheatcodes::ext::value_to_token, }, - utils::{h160_to_b160, ru256_to_u256, u256_to_ru256, RuntimeOrHandle}, + utils::RuntimeOrHandle, }; use alloy_primitives::{Bytes, B256, U256}; use ethers::{ @@ -14,6 +14,7 @@ use ethers::{ }; use foundry_abi::hevm::{EthGetLogsCall, RpcCall}; use foundry_common::ProviderBuilder; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::EVMData; use serde_json::Value; @@ -43,49 +44,49 @@ pub fn apply( HEVMCalls::CreateSelectFork2(fork) => { create_select_fork_at_transaction(state, data, fork.0.clone(), fork.1.into()) } - HEVMCalls::SelectFork(fork_id) => select_fork(state, data, u256_to_ru256(fork_id.0)), + HEVMCalls::SelectFork(fork_id) => select_fork(state, data, fork_id.0.to_alloy()), HEVMCalls::MakePersistent0(acc) => { - data.db.add_persistent_account(h160_to_b160(acc.0)); + data.db.add_persistent_account(acc.0.to_alloy()); Ok(Bytes::new()) } HEVMCalls::MakePersistent1(acc) => { data.db.extend_persistent_accounts( - (acc.0.clone().into_iter().map(h160_to_b160)).collect::>(), + (acc.0.clone().into_iter().map(|acc| acc.to_alloy())).collect::>(), ); Ok(Bytes::new()) } HEVMCalls::MakePersistent2(acc) => { - data.db.add_persistent_account(h160_to_b160(acc.0)); - data.db.add_persistent_account(h160_to_b160(acc.1)); + data.db.add_persistent_account(acc.0.to_alloy()); + data.db.add_persistent_account(acc.1.to_alloy()); Ok(Bytes::new()) } HEVMCalls::MakePersistent3(acc) => { - data.db.add_persistent_account(h160_to_b160(acc.0)); - data.db.add_persistent_account(h160_to_b160(acc.1)); - data.db.add_persistent_account(h160_to_b160(acc.2)); + data.db.add_persistent_account(acc.0.to_alloy()); + data.db.add_persistent_account(acc.1.to_alloy()); + data.db.add_persistent_account(acc.2.to_alloy()); Ok(Bytes::new()) } HEVMCalls::IsPersistent(acc) => { - Ok(data.db.is_persistent(&h160_to_b160(acc.0)).encode().into()) + Ok(data.db.is_persistent(&acc.0.to_alloy()).encode().into()) } HEVMCalls::RevokePersistent0(acc) => { - data.db.remove_persistent_account(&h160_to_b160(acc.0)); + data.db.remove_persistent_account(&acc.0.to_alloy()); Ok(Bytes::new()) } HEVMCalls::RevokePersistent1(acc) => { data.db.remove_persistent_accounts( - acc.0.clone().into_iter().map(h160_to_b160).collect::>(), + acc.0.clone().into_iter().map(|acc| acc.to_alloy()).collect::>(), ); Ok(Bytes::new()) } HEVMCalls::ActiveFork(_) => data .db .active_fork_id() - .map(|id| ru256_to_u256(id).encode().into()) + .map(|id| id.to_ethers().encode().into()) .ok_or_else(|| fmt_err!("No active fork")), HEVMCalls::RollFork0(fork) => data .db - .roll_fork(None, u256_to_ru256(fork.0), data.env, &mut data.journaled_state) + .roll_fork(None, fork.0.to_alloy(), data.env, &mut data.journaled_state) .map(empty) .map_err(Into::into), HEVMCalls::RollFork1(fork) => data @@ -96,8 +97,8 @@ pub fn apply( HEVMCalls::RollFork2(fork) => data .db .roll_fork( - Some(fork.0).map(u256_to_ru256), - u256_to_ru256(fork.1), + Some(fork.0).map(|id| id.to_alloy()), + fork.1.to_alloy(), data.env, &mut data.journaled_state, ) @@ -106,7 +107,7 @@ pub fn apply( HEVMCalls::RollFork3(fork) => data .db .roll_fork_to_transaction( - Some(fork.0).map(u256_to_ru256), + Some(fork.0).map(|f| f.to_alloy()), fork.1.into(), data.env, &mut data.journaled_state, @@ -139,7 +140,7 @@ pub fn apply( Ok(urls.encode().into()) } HEVMCalls::AllowCheatcodes(addr) => { - data.db.allow_cheatcode_access(h160_to_b160(addr.0)); + data.db.allow_cheatcode_access(addr.0.to_alloy()); Ok(Bytes::new()) } HEVMCalls::Transact0(inner) => data @@ -150,7 +151,7 @@ pub fn apply( HEVMCalls::Transact1(inner) => data .db .transact( - Some(u256_to_ru256(inner.0)), + Some(inner.0.to_alloy()), inner.1.into(), data.env, &mut data.journaled_state, @@ -198,7 +199,7 @@ fn create_select_fork( let fork = create_fork_request(state, url_or_alias, block, data)?; let id = data.db.create_select_fork(fork, data.env, &mut data.journaled_state)?; - Ok(ru256_to_u256(id).encode().into()) + Ok(id.to_ethers().encode().into()) } /// Creates a new fork @@ -210,7 +211,7 @@ fn create_fork( ) -> Result { let fork = create_fork_request(state, url_or_alias, block, data)?; let id = data.db.create_fork(fork)?; - Ok(ru256_to_u256(id).encode().into()) + Ok(id.to_ethers().encode().into()) } /// Creates and then also selects the new fork at the given transaction fn create_select_fork_at_transaction( @@ -233,7 +234,7 @@ fn create_select_fork_at_transaction( &mut data.journaled_state, transaction, )?; - Ok(ru256_to_u256(id).encode().into()) + Ok(id.to_ethers().encode().into()) } /// Creates a new fork at the given transaction @@ -245,7 +246,7 @@ fn create_fork_at_transaction( ) -> Result { let fork = create_fork_request(state, url_or_alias, None, data)?; let id = data.db.create_fork_at_transaction(fork, transaction)?; - Ok(ru256_to_u256(id).encode().into()) + Ok(id.to_ethers().encode().into()) } /// Creates the request object for a new fork request @@ -271,9 +272,7 @@ fn create_fork_request( /// Equivalent to eth_getLogs but on a cheatcode. fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> Result { let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; - if u256_to_ru256(inner.0) > U256::from(u64::MAX) || - u256_to_ru256(inner.1) > U256::from(u64::MAX) - { + if inner.0.to_alloy() > U256::from(u64::MAX) || inner.1.to_alloy() > U256::from(u64::MAX) { return Err(fmt_err!("Blocks in block range must be less than 2^64 - 1")) } // Cannot possibly have more than 4 topics in the topics array. diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index 4d34b5f3373fb..dd041075ae568 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -1,11 +1,11 @@ use super::Cheatcodes; -use crate::utils::{b160_to_h160, ru256_to_u256}; use alloy_primitives::Bytes; use ethers::{ abi::{self, Token}, types::{Address, U256}, utils::keccak256, }; +use foundry_utils::types::ToEthers; use revm::{ interpreter::{opcode, Interpreter}, Database, EVMData, @@ -101,7 +101,7 @@ pub fn on_evm_step( let result = U256::from(keccak256(interpreter.memory.get_slice(offset, 0x40))); mapping_slots - .entry(b160_to_h160(address)) + .entry(address.to_ethers()) .or_default() .seen_sha3 .insert(result, (low, high)); @@ -109,10 +109,10 @@ pub fn on_evm_step( } opcode::SSTORE => { if let Some(mapping_slots) = - mapping_slots.get_mut(&b160_to_h160(interpreter.contract.address)) + mapping_slots.get_mut(&interpreter.contract.address.to_ethers()) { if let Ok(slot) = interpreter.stack.peek(0) { - mapping_slots.insert(ru256_to_u256(slot)); + mapping_slots.insert(slot.to_ethers()); } } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 58a85fdda8a73..dde13e5e35c68 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -10,7 +10,6 @@ use crate::{ backend::DatabaseExt, inspector::cheatcodes::env::RecordedLogs, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, }, - utils::{b160_to_h160, b256_to_h256, h160_to_b160, ru256_to_u256, u256_to_ru256}, }; use alloy_primitives::{Address as rAddress, Bytes, B256}; use ethers::{ @@ -21,7 +20,10 @@ use ethers::{ }, }; use foundry_common::evm::Breakpoints; -use foundry_utils::error::SolError; +use foundry_utils::{ + error::SolError, + types::{ToAlloy, ToEthers}, +}; use itertools::Itertools; use revm::{ interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, @@ -220,7 +222,7 @@ impl Cheatcodes { // ensure the caller is allowed to execute cheatcodes, // but only if the backend is in forking mode - data.db.ensure_cheatcode_access_forking_mode(h160_to_b160(caller))?; + data.db.ensure_cheatcode_access_forking_mode(caller.to_alloy())?; let opt = env::apply(self, data, caller, &decoded) .transpose() @@ -285,8 +287,8 @@ impl Cheatcodes { // This will prevent overflow issues in revm's [`JournaledState::journal_revert`] routine // which rolls back any transfers. while let Some(record) = self.eth_deals.pop() { - if let Some(acc) = data.journaled_state.state.get_mut(&h160_to_b160(record.address)) { - acc.info.balance = u256_to_ru256(record.old_balance); + if let Some(acc) = data.journaled_state.state.get_mut(&record.address.to_alloy()) { + acc.info.balance = record.old_balance.to_alloy(); } } } @@ -305,7 +307,7 @@ impl Inspector for Cheatcodes { data.env.block = block; } if let Some(gas_price) = self.gas_price.take() { - data.env.tx.gas_price = u256_to_ru256(gas_price); + data.env.tx.gas_price = gas_price.to_alloy(); } InstructionResult::Continue @@ -382,9 +384,9 @@ impl Inspector for Cheatcodes { let key = try_or_continue!(interpreter.stack().peek(0)); storage_accesses .reads - .entry(b160_to_h160(interpreter.contract().address)) + .entry(interpreter.contract().address.to_ethers()) .or_insert_with(Vec::new) - .push(ru256_to_u256(key)); + .push(key.to_ethers()); } opcode::SSTORE => { let key = try_or_continue!(interpreter.stack().peek(0)); @@ -392,14 +394,14 @@ impl Inspector for Cheatcodes { // An SSTORE does an SLOAD internally storage_accesses .reads - .entry(b160_to_h160(interpreter.contract().address)) + .entry(interpreter.contract().address.to_ethers()) .or_insert_with(Vec::new) - .push(ru256_to_u256(key)); + .push(key.to_ethers()); storage_accesses .writes - .entry(b160_to_h160(interpreter.contract().address)) + .entry(interpreter.contract().address.to_ethers()) .or_insert_with(Vec::new) - .push(ru256_to_u256(key)); + .push(key.to_ethers()); } _ => (), } @@ -427,7 +429,7 @@ impl Inspector for Cheatcodes { opcode::MSTORE => { // The offset of the mstore operation is at the top of the stack. - let offset = ru256_to_u256(try_or_continue!(interpreter.stack().peek(0))).as_u64(); + let offset = try_or_continue!(interpreter.stack().peek(0)).to_ethers().as_u64(); // If none of the allowed ranges contain [offset, offset + 32), memory has been // unexpectedly mutated. @@ -440,7 +442,7 @@ impl Inspector for Cheatcodes { } opcode::MSTORE8 => { // The offset of the mstore8 operation is at the top of the stack. - let offset = ru256_to_u256(try_or_continue!(interpreter.stack().peek(0))).as_u64(); + let offset = try_or_continue!(interpreter.stack().peek(0)).to_ethers().as_u64(); // If none of the allowed ranges contain the offset, memory has been // unexpectedly mutated. @@ -456,7 +458,7 @@ impl Inspector for Cheatcodes { opcode::MLOAD => { // The offset of the mload operation is at the top of the stack - let offset = ru256_to_u256(try_or_continue!(interpreter.stack().peek(0))).as_u64(); + let offset = try_or_continue!(interpreter.stack().peek(0)).to_ethers().as_u64(); // If the offset being loaded is >= than the memory size, the // memory is being expanded. If none of the allowed ranges contain @@ -475,10 +477,10 @@ impl Inspector for Cheatcodes { $(opcode::$opcode => { // The destination offset of the operation is at the top of the stack. - let dest_offset = ru256_to_u256(try_or_continue!(interpreter.stack().peek($offset_depth))).as_u64(); + let dest_offset = try_or_continue!(interpreter.stack().peek($offset_depth)).to_ethers().as_u64(); // The size of the data that will be copied is the third item on the stack. - let size = ru256_to_u256(try_or_continue!(interpreter.stack().peek($size_depth))).as_u64(); + let size = try_or_continue!(interpreter.stack().peek($size_depth)).to_ethers().as_u64(); // If none of the allowed ranges contain [dest_offset, dest_offset + size), // memory outside of the expected ranges has been touched. If the opcode @@ -547,19 +549,19 @@ impl Inspector for Cheatcodes { handle_expect_emit( self, RawLog { - topics: topics.iter().copied().map(b256_to_h256).collect_vec(), + topics: topics.iter().copied().map(|t| t.to_ethers()).collect_vec(), data: data.to_vec(), }, - &b160_to_h160(*address), + &address.to_ethers(), ); } // Stores this log if `recordLogs` has been called if let Some(storage_recorded_logs) = &mut self.recorded_logs { storage_recorded_logs.entries.push(Log { - emitter: b160_to_h160(*address), + emitter: address.to_ethers(), inner: RawLog { - topics: topics.iter().copied().map(b256_to_h256).collect_vec(), + topics: topics.iter().copied().map(|t| t.to_ethers()).collect_vec(), data: data.to_vec(), }, }); @@ -573,7 +575,7 @@ impl Inspector for Cheatcodes { ) -> (InstructionResult, Gas, alloy_primitives::Bytes) { if call.contract == CHEATCODE_ADDRESS { let gas = Gas::new(call.gas_limit); - match self.apply_cheatcode(data, b160_to_h160(call.context.caller), call) { + match self.apply_cheatcode(data, call.context.caller.to_ethers(), call) { Ok(retdata) => (InstructionResult::Return, gas, alloy_primitives::Bytes(retdata.0)), Err(err) => { (InstructionResult::Revert, gas, alloy_primitives::Bytes(err.encode_error().0)) @@ -584,7 +586,7 @@ impl Inspector for Cheatcodes { // Grab the different calldatas expected. if let Some(expected_calls_for_target) = - self.expected_calls.get_mut(&(b160_to_h160(call.contract))) + self.expected_calls.get_mut(&(call.contract.to_ethers())) { // Match every partial/full calldata for (calldata, (expected, actual_count)) in expected_calls_for_target.iter_mut() { @@ -596,7 +598,7 @@ impl Inspector for Cheatcodes { // The value matches, if provided expected .value - .map_or(true, |value| value == ru256_to_u256(call.transfer.value)) && + .map_or(true, |value| value == call.transfer.value.to_ethers()) && // The gas matches, if provided expected.gas.map_or(true, |gas| gas == call.gas_limit) && // The minimum gas matches, if provided @@ -608,10 +610,10 @@ impl Inspector for Cheatcodes { } // Handle mocked calls - if let Some(mocks) = self.mocked_calls.get(&b160_to_h160(call.contract)) { + if let Some(mocks) = self.mocked_calls.get(&call.contract.to_ethers()) { let ctx = MockCallDataContext { calldata: call.input.clone().0.into(), - value: Some(call.transfer.value).map(ru256_to_u256), + value: Some(call.transfer.value).map(|v| v.to_ethers()), }; if let Some(mock_retdata) = mocks.get(&ctx) { return ( @@ -622,8 +624,7 @@ impl Inspector for Cheatcodes { } else if let Some((_, mock_retdata)) = mocks.iter().find(|(mock, _)| { mock.calldata.len() <= call.input.len() && *mock.calldata == call.input[..mock.calldata.len()] && - mock.value - .map_or(true, |value| value == ru256_to_u256(call.transfer.value)) + mock.value.map_or(true, |value| value == call.transfer.value.to_ethers()) }) { return ( mock_retdata.ret_type, @@ -636,19 +637,19 @@ impl Inspector for Cheatcodes { // Apply our prank if let Some(prank) = &self.prank { if data.journaled_state.depth() >= prank.depth && - call.context.caller == h160_to_b160(prank.prank_caller) + call.context.caller == prank.prank_caller.to_alloy() { let mut prank_applied = false; // At the target depth we set `msg.sender` if data.journaled_state.depth() == prank.depth { - call.context.caller = h160_to_b160(prank.new_caller); - call.transfer.source = h160_to_b160(prank.new_caller); + call.context.caller = prank.new_caller.to_alloy(); + call.transfer.source = prank.new_caller.to_alloy(); prank_applied = true; } // At the target depth, or deeper, we set `tx.origin` if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = h160_to_b160(new_origin); + data.env.tx.caller = new_origin.to_alloy(); prank_applied = true; } @@ -668,15 +669,15 @@ impl Inspector for Cheatcodes { // We do this because any subsequent contract calls *must* exist on chain and // we only want to grab *this* call, not internal ones if data.journaled_state.depth() == broadcast.depth && - call.context.caller == h160_to_b160(broadcast.original_caller) + call.context.caller == broadcast.original_caller.to_alloy() { // 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 // broadcast.origin. - data.env.tx.caller = h160_to_b160(broadcast.new_origin); + data.env.tx.caller = broadcast.new_origin.to_alloy(); - call.context.caller = h160_to_b160(broadcast.new_origin); - call.transfer.source = h160_to_b160(broadcast.new_origin); + call.context.caller = broadcast.new_origin.to_alloy(); + call.transfer.source = broadcast.new_origin.to_alloy(); // Add a `legacy` transaction to the VecDeque. We use a legacy transaction here // because we only need the from, to, value, and data. We can later change this // into 1559, in the cli package, relatively easily once we @@ -684,7 +685,7 @@ impl Inspector for Cheatcodes { if !call.is_static { if let Err(err) = data .journaled_state - .load_account(h160_to_b160(broadcast.new_origin), data.db) + .load_account(broadcast.new_origin.to_alloy(), data.db) { return ( InstructionResult::Revert, @@ -698,15 +699,15 @@ impl Inspector for Cheatcodes { let account = data .journaled_state .state() - .get_mut(&h160_to_b160(broadcast.new_origin)) + .get_mut(&broadcast.new_origin.to_alloy()) .unwrap(); self.broadcastable_transactions.push_back(BroadcastableTransaction { rpc: data.db.active_fork_url(), transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(broadcast.new_origin), - to: Some(NameOrAddress::Address(b160_to_h160(call.contract))), - value: Some(call.transfer.value).map(ru256_to_u256), + to: Some(NameOrAddress::Address(call.contract.to_ethers())), + value: Some(call.transfer.value).map(|v| v.to_ethers()), data: Some(call.input.clone().0).map(ethers::types::Bytes), nonce: Some(account.info.nonce.into()), gas: if is_fixed_gas_limit { @@ -762,7 +763,7 @@ impl Inspector for Cheatcodes { // Clean up pranks if let Some(prank) = &self.prank { if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = h160_to_b160(prank.prank_origin); + data.env.tx.caller = prank.prank_origin.to_alloy(); // Clean single-call prank once we have returned to the original depth if prank.single_call { @@ -774,7 +775,7 @@ impl Inspector for Cheatcodes { // Clean up broadcast if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = h160_to_b160(broadcast.original_origin); + data.env.tx.caller = broadcast.original_origin.to_alloy(); // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { @@ -971,16 +972,16 @@ impl Inspector for Cheatcodes { // Apply our prank if let Some(prank) = &self.prank { if data.journaled_state.depth() >= prank.depth && - call.caller == h160_to_b160(prank.prank_caller) + call.caller == prank.prank_caller.to_alloy() { // At the target depth we set `msg.sender` if data.journaled_state.depth() == prank.depth { - call.caller = h160_to_b160(prank.new_caller); + call.caller = prank.new_caller.to_alloy(); } // At the target depth, or deeper, we set `tx.origin` if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = h160_to_b160(new_origin); + data.env.tx.caller = new_origin.to_alloy(); } } } @@ -988,10 +989,10 @@ impl Inspector for Cheatcodes { // Apply our broadcast if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() >= broadcast.depth && - call.caller == h160_to_b160(broadcast.original_caller) + call.caller == broadcast.original_caller.to_alloy() { if let Err(err) = - data.journaled_state.load_account(h160_to_b160(broadcast.new_origin), data.db) + data.journaled_state.load_account(broadcast.new_origin.to_alloy(), data.db) { return ( InstructionResult::Revert, @@ -1001,7 +1002,7 @@ impl Inspector for Cheatcodes { ) } - data.env.tx.caller = h160_to_b160(broadcast.new_origin); + data.env.tx.caller = broadcast.new_origin.to_alloy(); if data.journaled_state.depth() == broadcast.depth { let (bytecode, to, nonce) = match process_create( @@ -1028,7 +1029,7 @@ impl Inspector for Cheatcodes { transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(broadcast.new_origin), to, - value: Some(call.value).map(ru256_to_u256), + value: Some(call.value).map(|v| v.to_ethers()), data: Some(bytecode.into()), nonce: Some(nonce.into()), gas: if is_fixed_gas_limit { @@ -1063,7 +1064,7 @@ impl Inspector for Cheatcodes { // Clean up pranks if let Some(prank) = &self.prank { if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = h160_to_b160(prank.prank_origin); + data.env.tx.caller = prank.prank_origin.to_alloy(); // Clean single-call prank once we have returned to the original depth if prank.single_call { @@ -1075,7 +1076,7 @@ impl Inspector for Cheatcodes { // Clean up broadcasts if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = h160_to_b160(broadcast.original_origin); + data.env.tx.caller = broadcast.original_origin.to_alloy(); // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { @@ -1096,7 +1097,7 @@ impl Inspector for Cheatcodes { ) { Ok((address, retdata)) => ( InstructionResult::Return, - address.map(h160_to_b160), + address.map(|a| a.to_alloy()), remaining_gas, alloy_primitives::Bytes(retdata.0), ), diff --git a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs b/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs index 1449155ad5afa..b68ea9e5d366d 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs @@ -1,10 +1,7 @@ use super::Result; -use crate::{ - abi::HEVMCalls, - executor::backend::DatabaseExt, - utils::{ru256_to_u256, u256_to_ru256}, -}; +use crate::{abi::HEVMCalls, executor::backend::DatabaseExt}; use ethers::abi::AbiEncode; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::EVMData; /// Handles fork related cheatcodes @@ -12,11 +9,11 @@ use revm::EVMData; pub fn apply(data: &mut EVMData<'_, DB>, call: &HEVMCalls) -> Option { Some(match call { HEVMCalls::Snapshot(_) => { - Ok(ru256_to_u256(data.db.snapshot(&data.journaled_state, data.env)).encode().into()) + Ok((data.db.snapshot(&data.journaled_state, data.env)).to_ethers().encode().into()) } HEVMCalls::RevertTo(snapshot) => { let res = if let Some(journaled_state) = - data.db.revert(u256_to_ru256(snapshot.0), &data.journaled_state, data.env) + data.db.revert(snapshot.0.to_alloy(), &data.journaled_state, data.env) { // we reset the evm's journaled_state to the state of the snapshot previous state data.journaled_state = journaled_state; diff --git a/crates/evm/src/executor/inspector/cheatcodes/util.rs b/crates/evm/src/executor/inspector/cheatcodes/util.rs index c59937a3a7c10..721dd6493c945 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/util.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/util.rs @@ -4,7 +4,7 @@ use crate::{ error::{DatabaseError, DatabaseResult}, DatabaseExt, }, - utils::{b160_to_h160, h160_to_b160, h256_to_u256_be, ru256_to_u256, u256_to_ru256}, + utils::h256_to_u256_be, }; use alloy_primitives::Address as rAddress; use bytes::{BufMut, Bytes, BytesMut}; @@ -18,6 +18,7 @@ use ethers::{ types::{transaction::eip2718::TypedTransaction, NameOrAddress, U256}, }; use foundry_common::RpcUrl; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::{ interpreter::CreateInputs, primitives::{Account, TransactTo}, @@ -43,10 +44,10 @@ pub type BroadcastableTransactions = VecDeque; /// Configures the env for the transaction pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { - env.tx.caller = h160_to_b160(tx.from); + env.tx.caller = tx.from.to_alloy(); env.tx.gas_limit = tx.gas.as_u64(); - env.tx.gas_price = u256_to_ru256(tx.gas_price.unwrap_or_default()); - env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(u256_to_ru256); + env.tx.gas_price = tx.gas_price.unwrap_or_default().to_alloy(); + env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(|g| g.to_alloy()); env.tx.nonce = Some(tx.nonce.as_u64()); env.tx.access_list = tx .access_list @@ -56,15 +57,15 @@ pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { .into_iter() .map(|item| { ( - h160_to_b160(item.address), - item.storage_keys.into_iter().map(h256_to_u256_be).map(u256_to_ru256).collect(), + item.address.to_alloy(), + item.storage_keys.into_iter().map(h256_to_u256_be).map(|g| g.to_alloy()).collect(), ) }) .collect(); - env.tx.value = u256_to_ru256(tx.value); + env.tx.value = tx.value.to_alloy(); env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); env.tx.transact_to = - tx.to.map(h160_to_b160).map(TransactTo::Call).unwrap_or_else(TransactTo::create) + tx.to.map(|tx| tx.to_alloy()).map(TransactTo::Call).unwrap_or_else(TransactTo::create) } /// Applies the given function `f` to the `revm::Account` belonging to the `addr` @@ -79,7 +80,7 @@ pub fn with_journaled_account( where F: FnMut(&mut Account) -> R, { - let addr = h160_to_b160(addr); + let addr = addr.to_alloy(); journaled_state.load_account(addr, db)?; journaled_state.touch(&addr); let account = journaled_state.state.get_mut(&addr).expect("account loaded;"); @@ -95,7 +96,7 @@ pub fn process_create( where DB: Database, { - let broadcast_sender = h160_to_b160(broadcast_sender); + let broadcast_sender = broadcast_sender.to_alloy(); match call.scheme { revm::primitives::CreateScheme::Create => { call.caller = broadcast_sender; @@ -133,7 +134,7 @@ where // Proxy deployer requires the data to be on the following format `salt.init_code` let mut calldata = BytesMut::with_capacity(32 + bytecode.len()); - let salt = ru256_to_u256(salt); + let salt = salt.to_ethers(); let mut salt_bytes = [0u8; 32]; salt.to_big_endian(&mut salt_bytes); calldata.put_slice(&salt_bytes); @@ -141,7 +142,7 @@ where Ok(( calldata.freeze(), - Some(NameOrAddress::Address(b160_to_h160(DEFAULT_CREATE2_DEPLOYER))), + Some(NameOrAddress::Address(DEFAULT_CREATE2_DEPLOYER.to_ethers())), nonce, )) } @@ -170,8 +171,8 @@ pub fn check_if_fixed_gas_limit( // time of the call, which should be rather close to configured gas limit. // TODO: Find a way to reliably make this determination. (for example by // generating it in the compilation or evm simulation process) - U256::from(data.env.tx.gas_limit) > ru256_to_u256(data.env.block.gas_limit) && - U256::from(call_gas_limit) <= ru256_to_u256(data.env.block.gas_limit) + U256::from(data.env.tx.gas_limit) > data.env.block.gas_limit.to_ethers() && + U256::from(call_gas_limit) <= data.env.block.gas_limit.to_ethers() // Transfers in forge scripts seem to be estimated at 2300 by revm leading to "Intrinsic // gas too low" failure when simulated on chain && call_gas_limit > 2300 diff --git a/crates/evm/src/executor/inspector/coverage.rs b/crates/evm/src/executor/inspector/coverage.rs index 1a549de04e95d..ba8dadc5f8564 100644 --- a/crates/evm/src/executor/inspector/coverage.rs +++ b/crates/evm/src/executor/inspector/coverage.rs @@ -1,8 +1,6 @@ -use crate::{ - coverage::{HitMap, HitMaps}, - utils::b256_to_h256, -}; +use crate::coverage::{HitMap, HitMaps}; use bytes::Bytes; +use foundry_utils::types::ToEthers; use revm::{ interpreter::{InstructionResult, Interpreter}, Database, EVMData, Inspector, @@ -21,7 +19,7 @@ impl Inspector for CoverageCollector { interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.hash); + let hash = interpreter.contract.hash.to_ethers(); self.maps.entry(hash).or_insert_with(|| { HitMap::new(Bytes::copy_from_slice( interpreter.contract.bytecode.original_bytecode_slice(), @@ -37,7 +35,7 @@ impl Inspector for CoverageCollector { interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, ) -> InstructionResult { - let hash = b256_to_h256(interpreter.contract.hash); + let hash = interpreter.contract.hash.to_ethers(); self.maps.entry(hash).and_modify(|map| map.hit(interpreter.program_counter())); InstructionResult::Continue diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/src/executor/inspector/fuzzer.rs index be46192c92974..3c873b5673859 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/src/executor/inspector/fuzzer.rs @@ -1,8 +1,9 @@ use crate::{ fuzz::{invariant::RandomCallGenerator, strategies::EvmFuzzState}, - utils::{self, b160_to_h160, h160_to_b160}, + utils, }; use alloy_primitives::Bytes; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::{ interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, Database, EVMData, Inspector, @@ -79,7 +80,7 @@ impl Fuzzer { let mut state = self.fuzz_state.write(); for slot in interpreter.stack().data() { - state.values_mut().insert(utils::u256_to_h256_be(utils::ru256_to_u256(*slot)).into()); + state.values_mut().insert(utils::u256_to_h256_be(slot.to_ethers()).into()); } // TODO: disabled for now since it's flooding the dictionary @@ -95,21 +96,21 @@ impl Fuzzer { fn override_call(&mut self, call: &mut CallInputs) { if let Some(ref mut call_generator) = self.call_generator { // We only override external calls which are not coming from the test contract. - if call.context.caller != h160_to_b160(call_generator.test_address) && + if call.context.caller != call_generator.test_address.to_alloy() && call.context.scheme == CallScheme::Call && !call_generator.used { // There's only a 30% chance that an override happens. - if let Some((sender, (contract, input))) = call_generator - .next(b160_to_h160(call.context.caller), b160_to_h160(call.contract)) + if let Some((sender, (contract, input))) = + call_generator.next(call.context.caller.to_ethers(), call.contract.to_ethers()) { *call.input = input.0; - call.context.caller = h160_to_b160(sender); - call.contract = h160_to_b160(contract); + call.context.caller = sender.to_alloy(); + call.contract = contract.to_alloy(); // TODO: in what scenarios can the following be problematic - call.context.code_address = h160_to_b160(contract); - call.context.address = h160_to_b160(contract); + call.context.code_address = contract.to_alloy(); + call.context.address = contract.to_alloy(); call_generator.used = true; } diff --git a/crates/evm/src/executor/inspector/logs.rs b/crates/evm/src/executor/inspector/logs.rs index 56b9897a7aaa8..a0c1d8be2adf0 100644 --- a/crates/evm/src/executor/inspector/logs.rs +++ b/crates/evm/src/executor/inspector/logs.rs @@ -1,6 +1,5 @@ -use crate::{ - executor::{patch_hardhat_console_selector, HardhatConsoleCalls, HARDHAT_CONSOLE_ADDRESS}, - utils::{b160_to_h160, b256_to_h256}, +use crate::executor::{ + patch_hardhat_console_selector, HardhatConsoleCalls, HARDHAT_CONSOLE_ADDRESS, }; use alloy_primitives::{Address, Bytes, B256}; use ethers::{ @@ -8,6 +7,7 @@ use ethers::{ types::{Bytes as ethersBytes, Log, H256}, }; use foundry_macros::ConsoleFmt; +use foundry_utils::types::ToEthers; use revm::{ interpreter::{CallInputs, Gas, InstructionResult}, Database, EVMData, Inspector, @@ -45,8 +45,8 @@ impl LogCollector { impl Inspector for LogCollector { fn log(&mut self, _: &mut EVMData<'_, DB>, address: &Address, topics: &[B256], data: &Bytes) { self.logs.push(Log { - address: b160_to_h160(*address), - topics: topics.iter().copied().map(b256_to_h256).collect(), + address: address.to_ethers(), + topics: topics.iter().copied().map(|t| t.to_ethers()).collect(), data: ethersBytes::from(data.clone().0), ..Default::default() }); diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index 5c97b6ca8e4f7..3cd392521c407 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -6,10 +6,10 @@ use crate::{ debug::DebugArena, executor::{backend::DatabaseExt, inspector::CoverageCollector}, trace::CallTraceArena, - utils::{h160_to_b160, ru256_to_u256}, }; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers::{signers::LocalWallet, types::Log}; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::{ interpreter::{ return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, Stack, @@ -242,7 +242,7 @@ impl InspectorStack { #[inline] pub fn set_gas_price(&mut self, gas_price: U256) { if let Some(cheatcodes) = &mut self.cheatcodes { - cheatcodes.gas_price = Some(gas_price).map(ru256_to_u256); + cheatcodes.gas_price = Some(gas_price).map(|g| g.to_ethers()); } } @@ -303,12 +303,7 @@ impl InspectorStack { .cheatcodes .as_ref() .map(|cheatcodes| { - cheatcodes - .labels - .clone() - .into_iter() - .map(|l| (h160_to_b160(l.0), l.1)) - .collect() + cheatcodes.labels.clone().into_iter().map(|l| (l.0.to_alloy(), l.1)).collect() }) .unwrap_or_default(), traces: self.tracer.map(|tracer| tracer.traces), diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index 392ae6c1a6196..349df0f8eeee8 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -5,11 +5,11 @@ use crate::{ CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, }, - utils::{b160_to_h160, b256_to_h256, ru256_to_u256}, CallKind, }; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers::abi::RawLog; +use foundry_utils::types::ToEthers; use revm::{ interpreter::{ opcode, return_ok, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, @@ -46,12 +46,12 @@ impl Tracer { 0, CallTrace { depth, - address: b160_to_h160(address), + address: address.to_ethers(), kind, data: RawOrDecodedCall::Raw(data.into()), - value: ru256_to_u256(value), + value: value.to_ethers(), status: InstructionResult::Continue, - caller: b160_to_h160(caller), + caller: caller.to_ethers(), ..Default::default() }, )); @@ -74,7 +74,7 @@ impl Tracer { trace.output = RawOrDecodedReturnData::Raw(output.into()); if let Some(address) = address { - trace.address = b160_to_h160(address); + trace.address = address.to_ethers(); } } @@ -89,7 +89,7 @@ impl Tracer { depth: data.journaled_state.depth(), pc: interp.program_counter(), op: OpCode(interp.current_opcode()), - contract: b160_to_h160(interp.contract.address), + contract: interp.contract.address.to_ethers(), stack: interp.stack.clone(), memory: interp.memory.clone(), gas: interp.gas.remaining(), @@ -124,7 +124,7 @@ impl Tracer { Some(JournalEntry::StorageChange { address, key, .. }), ) => { let value = data.journaled_state.state[address].storage[key].present_value(); - Some((ru256_to_u256(*key), ru256_to_u256(value))) + Some((key.to_ethers(), value.to_ethers())) } _ => None, }; @@ -163,7 +163,7 @@ impl Inspector for Tracer { #[inline] fn log(&mut self, _: &mut EVMData<'_, DB>, _: &Address, topics: &[B256], data: &Bytes) { let node = &mut self.traces.arena[*self.trace_stack.last().expect("no ongoing trace")]; - let topics: Vec<_> = topics.iter().copied().map(b256_to_h256).collect(); + let topics: Vec<_> = topics.iter().copied().map(|t| t.to_ethers()).collect(); node.ordering.push(LogCallOrder::Log(node.logs.len())); node.logs.push(RawOrDecodedLog::Raw(RawLog { topics, data: data.to_vec() })); } diff --git a/crates/evm/src/fuzz/invariant/error.rs b/crates/evm/src/fuzz/invariant/error.rs index b917a1ca83a08..89d95da4a1c77 100644 --- a/crates/evm/src/fuzz/invariant/error.rs +++ b/crates/evm/src/fuzz/invariant/error.rs @@ -4,7 +4,6 @@ use crate::{ executor::{Executor, RawCallResult}, fuzz::{invariant::set_up_inner_replay, *}, trace::{load_contracts, TraceKind, Traces}, - utils::h160_to_b160, CALLER, }; use ethers::abi::Function; @@ -108,8 +107,8 @@ impl InvariantFuzzError { for (sender, (addr, bytes)) in calls.iter() { let call_result = executor .call_raw_committing( - h160_to_b160(*sender), - h160_to_b160(*addr), + sender.to_alloy(), + addr.to_alloy(), bytes.0.clone().into(), U256::ZERO, ) @@ -138,7 +137,7 @@ impl InvariantFuzzError { // Checks the invariant. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, h160_to_b160(self.addr), func.0.clone().into(), U256::ZERO) + .call_raw(CALLER, self.addr.to_alloy(), func.0.clone().into(), U256::ZERO) .expect("bad call to evm"); traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); @@ -174,8 +173,8 @@ impl InvariantFuzzError { executor .call_raw_committing( - h160_to_b160(*sender), - h160_to_b160(*addr), + sender.to_alloy(), + addr.to_alloy(), bytes.0.clone().into(), U256::ZERO, ) @@ -184,7 +183,7 @@ impl InvariantFuzzError { // Checks the invariant. If we exit before the last call, all the better. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, h160_to_b160(self.addr), func.0.clone().into(), U256::ZERO) + .call_raw(CALLER, self.addr.to_alloy(), func.0.clone().into(), U256::ZERO) .expect("bad call to evm"); if error_call_result.reverted { diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index a16a51c224595..a1b9faee9b0d4 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -16,13 +16,14 @@ use crate::{ }, FuzzCase, FuzzedCases, }, - utils::{b160_to_h160, get_function, h160_to_b160}, + utils::get_function, CALLER, }; use ethers::abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; +use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::{Mutex, RwLock}; use proptest::{ strategy::{BoxedStrategy, Strategy, ValueTree}, @@ -149,8 +150,8 @@ impl<'a> InvariantExecutor<'a> { // Executes the call from the randomly generated sequence. let call_result = executor .call_raw( - h160_to_b160(*sender), - h160_to_b160(*address), + sender.to_alloy(), + address.to_alloy(), calldata.0.clone().into(), rU256::ZERO, ) @@ -424,8 +425,8 @@ impl<'a> InvariantExecutor<'a> { .into_iter() .filter(|(addr, (identifier, _))| { *addr != invariant_address && - *addr != b160_to_h160(CHEATCODE_ADDRESS) && - *addr != b160_to_h160(HARDHAT_CONSOLE_ADDRESS) && + *addr != CHEATCODE_ADDRESS.to_ethers() && + *addr != HARDHAT_CONSOLE_ADDRESS.to_ethers() && (selected.is_empty() || selected.contains(addr)) && (self.artifact_filters.targeted.is_empty() || self.artifact_filters.targeted.contains_key(identifier)) && @@ -567,7 +568,7 @@ impl<'a> InvariantExecutor<'a> { if let Some(func) = abi.functions().find(|func| func.name == method_name) { if let Ok(call_result) = self.executor.call::, _, _>( CALLER, - h160_to_b160(address), + address.to_alloy(), func.clone(), (), rU256::ZERO, @@ -599,7 +600,7 @@ fn collect_data( // Verify it has no code. let mut has_code = false; if let Some(Some(code)) = - state_changeset.get(&h160_to_b160(*sender)).map(|account| account.info.code.as_ref()) + state_changeset.get(&sender.to_alloy()).map(|account| account.info.code.as_ref()) { has_code = !code.is_empty(); } @@ -607,14 +608,14 @@ fn collect_data( // We keep the nonce changes to apply later. let mut sender_changeset = None; if !has_code { - sender_changeset = state_changeset.remove(&h160_to_b160(*sender)); + sender_changeset = state_changeset.remove(&sender.to_alloy()); } collect_state_from_call(&call_result.logs, &*state_changeset, fuzz_state, config); // Re-add changes if let Some(changed) = sender_changeset { - state_changeset.insert(h160_to_b160(*sender), changed); + state_changeset.insert(sender.to_alloy(), changed); } } @@ -637,7 +638,7 @@ fn can_continue( // Detect handler assertion failures first. let handlers_failed = targeted_contracts.lock().iter().any(|contract| { - !executor.is_success(h160_to_b160(*contract.0), false, state_changeset.clone(), false) + !executor.is_success(contract.0.to_alloy(), false, state_changeset.clone(), false) }); // Assert invariants IFF the call did not revert and the handlers did not fail. diff --git a/crates/evm/src/fuzz/invariant/mod.rs b/crates/evm/src/fuzz/invariant/mod.rs index 38761753ecb72..7072382797c6c 100644 --- a/crates/evm/src/fuzz/invariant/mod.rs +++ b/crates/evm/src/fuzz/invariant/mod.rs @@ -4,7 +4,6 @@ use crate::{ executor::Executor, fuzz::*, trace::{load_contracts, TraceKind, Traces}, - utils::h160_to_b160, CALLER, }; use ethers::{ @@ -69,7 +68,7 @@ pub fn assert_invariants( let mut call_result = executor .call_raw( CALLER, - h160_to_b160(invariant_contract.address), + invariant_contract.address.to_alloy(), func.encode_input(&[]).expect("invariant should have no inputs").into(), U256::ZERO, ) @@ -78,7 +77,7 @@ pub fn assert_invariants( // This will panic and get caught by the executor let is_err = call_result.reverted || !executor.is_success( - h160_to_b160(invariant_contract.address), + invariant_contract.address.to_alloy(), call_result.reverted, call_result.state_changeset.take().expect("we should have a state changeset"), false, @@ -122,8 +121,8 @@ pub fn replay_run( for (sender, (addr, bytes)) in inputs.iter() { let call_result = executor .call_raw_committing( - h160_to_b160(*sender), - h160_to_b160(*addr), + sender.to_alloy(), + addr.to_alloy(), bytes.0.clone().into(), U256::ZERO, ) @@ -142,7 +141,7 @@ pub fn replay_run( let error_call_result = executor .call_raw( CALLER, - h160_to_b160(invariant_contract.address), + invariant_contract.address.to_alloy(), func.encode_input(&[]).expect("invariant should have no inputs").into(), U256::ZERO, ) diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index 9ff21ef33b791..c22b00ed460cd 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -4,7 +4,6 @@ use crate::{ decode::{self, decode_console_logs}, executor::{Executor, RawCallResult}, trace::CallTraceArena, - utils::{b160_to_h160, h160_to_b160}, }; use alloy_primitives::U256; use error::{FuzzError, ASSUME_MAGIC_RETURN_CODE}; @@ -15,6 +14,7 @@ use ethers::{ use eyre::Result; use foundry_common::{calc, contracts::ContractsByAddress}; use foundry_config::FuzzConfig; +use foundry_utils::types::{ToAlloy, ToEthers}; pub use proptest::test_runner::Reason; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; use serde::{Deserialize, Serialize}; @@ -152,7 +152,7 @@ impl<'a> FuzzedExecutor<'a> { counterexample: None, decoded_logs: decode_console_logs(&call.logs), logs: call.logs, - labeled_addresses: call.labels.into_iter().map(|l| (b160_to_h160(l.0), l.1)).collect(), + labeled_addresses: call.labels.into_iter().map(|l| (l.0.to_ethers(), l.1)).collect(), traces: if run_result.is_ok() { traces.into_inner() } else { call.traces.clone() }, coverage: coverage.into_inner(), }; @@ -202,8 +202,8 @@ impl<'a> FuzzedExecutor<'a> { let call = self .executor .call_raw( - h160_to_b160(self.sender), - h160_to_b160(address), + self.sender.to_alloy(), + address.to_alloy(), calldata.0.clone().into(), U256::ZERO, ) @@ -232,7 +232,7 @@ impl<'a> FuzzedExecutor<'a> { .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); let success = self.executor.is_success( - h160_to_b160(address), + address.to_alloy(), call.reverted, state_changeset.clone(), should_fail, diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/src/fuzz/strategies/state.rs index 7a8439b36da9e..85584b4fed4cc 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/src/fuzz/strategies/state.rs @@ -2,7 +2,7 @@ use super::fuzz_param_from_state; use crate::{ executor::StateChangeset, fuzz::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}, - utils::{self, b160_to_h160, ru256_to_u256}, + utils, }; use bytes::Bytes; use ethers::{ @@ -11,6 +11,7 @@ use ethers::{ }; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; +use foundry_utils::types::ToEthers; use hashbrown::HashSet; use parking_lot::RwLock; use proptest::prelude::{BoxedStrategy, Strategy}; @@ -100,7 +101,7 @@ pub fn build_initial_state( let mut state = FuzzDictionary::default(); for (address, account) in db.accounts.iter() { - let address: Address = b160_to_h160(*address); + let address: Address = address.to_ethers(); // Insert basic account information state.values_mut().insert(H256::from(address).into()); @@ -118,8 +119,8 @@ pub fn build_initial_state( if config.include_storage { // Insert storage for (slot, value) in &account.storage { - let slot = ru256_to_u256(*slot); - let value = ru256_to_u256(*value); + let slot = slot.to_ethers(); + let value = value.to_ethers(); state.values_mut().insert(utils::u256_to_h256_be(slot).into()); state.values_mut().insert(utils::u256_to_h256_be(value).into()); // also add the value below and above the storage value to the dictionary. @@ -157,13 +158,13 @@ pub fn collect_state_from_call( for (address, account) in state_changeset { // Insert basic account information - state.values_mut().insert(H256::from(b160_to_h160(*address)).into()); + state.values_mut().insert(H256::from(address.to_ethers()).into()); if config.include_push_bytes && state.addresses.len() < config.max_fuzz_dictionary_addresses { // Insert push bytes if let Some(code) = &account.info.code { - if state.addresses_mut().insert(b160_to_h160(*address)) { + if state.addresses_mut().insert(address.to_ethers()) { for push_byte in collect_push_bytes(code.bytes().clone().0) { state.values_mut().insert(push_byte); } @@ -174,8 +175,8 @@ pub fn collect_state_from_call( if config.include_storage && state.state_values.len() < config.max_fuzz_dictionary_values { // Insert storage for (slot, value) in &account.storage { - let slot = ru256_to_u256(*slot); - let value = ru256_to_u256(value.present_value()); + let slot = slot.to_ethers(); + let value = value.present_value().to_ethers(); state.values_mut().insert(utils::u256_to_h256_be(slot).into()); state.values_mut().insert(utils::u256_to_h256_be(value).into()); // also add the value below and above the storage value to the dictionary. @@ -267,7 +268,7 @@ pub fn collect_created_contracts( let mut writable_targeted = targeted_contracts.lock(); for (address, account) in state_changeset { - if !setup_contracts.contains_key(&b160_to_h160(*address)) { + if !setup_contracts.contains_key(&address.to_ethers()) { if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { if !code.is_empty() { if let Some((artifact, (abi, _))) = project_contracts.find_by_code(code.bytes()) @@ -275,9 +276,9 @@ pub fn collect_created_contracts( if let Some(functions) = artifact_filters.get_targeted_functions(artifact, abi)? { - created_contracts.push(b160_to_h160(*address)); + created_contracts.push(address.to_ethers()); writable_targeted.insert( - b160_to_h160(*address), + address.to_ethers(), (artifact.name.clone(), abi.clone(), functions), ); } diff --git a/crates/evm/src/trace/decoder.rs b/crates/evm/src/trace/decoder.rs index 11db65c2fca10..3924c38125315 100644 --- a/crates/evm/src/trace/decoder.rs +++ b/crates/evm/src/trace/decoder.rs @@ -7,7 +7,6 @@ use crate::{ decode, executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::{node::CallTraceNode, utils}, - utils::b160_to_h160, CALLER, TEST_CONTRACT_ADDRESS, }; use ethers::{ @@ -15,6 +14,7 @@ use ethers::{ types::{H160, H256}, }; use foundry_common::{abi::get_indexed_event, SELECTOR_LEN}; +use foundry_utils::types::ToEthers; use hashbrown::HashSet; use once_cell::sync::OnceCell; use std::collections::{BTreeMap, HashMap}; @@ -157,11 +157,11 @@ impl CallTraceDecoder { contracts: Default::default(), labels: [ - (b160_to_h160(CHEATCODE_ADDRESS), "VM".to_string()), - (b160_to_h160(HARDHAT_CONSOLE_ADDRESS), "console".to_string()), - (b160_to_h160(DEFAULT_CREATE2_DEPLOYER), "Create2Deployer".to_string()), - (b160_to_h160(CALLER), "DefaultSender".to_string()), - (b160_to_h160(TEST_CONTRACT_ADDRESS), "DefaultTestContract".to_string()), + (CHEATCODE_ADDRESS.to_ethers(), "VM".to_string()), + (HARDHAT_CONSOLE_ADDRESS.to_ethers(), "console".to_string()), + (DEFAULT_CREATE2_DEPLOYER.to_ethers(), "Create2Deployer".to_string()), + (CALLER.to_ethers(), "DefaultSender".to_string()), + (TEST_CONTRACT_ADDRESS.to_ethers(), "DefaultTestContract".to_string()), ] .into(), @@ -257,7 +257,7 @@ impl CallTraceDecoder { if bytes.len() >= 4 { if let Some(funcs) = self.functions.get(&bytes[..SELECTOR_LEN]) { node.decode_function(funcs, &self.labels, &self.errors, self.verbosity); - } else if node.trace.address == b160_to_h160(DEFAULT_CREATE2_DEPLOYER) { + } else if node.trace.address == DEFAULT_CREATE2_DEPLOYER.to_ethers() { node.trace.data = RawOrDecodedCall::Decoded("create2".to_string(), String::new(), vec![]); } else if let Some(identifier) = &self.signature_identifier { diff --git a/crates/evm/src/trace/mod.rs b/crates/evm/src/trace/mod.rs index 5b7365333d7c6..fd479dc795a45 100644 --- a/crates/evm/src/trace/mod.rs +++ b/crates/evm/src/trace/mod.rs @@ -1,9 +1,5 @@ use crate::{ - abi::CHEATCODE_ADDRESS, - debug::Instruction, - trace::identifier::LocalTraceIdentifier, - utils::{b160_to_h160, ru256_to_u256}, - CallKind, + abi::CHEATCODE_ADDRESS, debug::Instruction, trace::identifier::LocalTraceIdentifier, CallKind, }; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; use ethers::{ @@ -13,6 +9,7 @@ use ethers::{ }; pub use executor::TracingExecutor; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_utils::types::ToEthers; use hashbrown::HashMap; use node::CallTraceNode; use revm::interpreter::{opcode, CallContext, InstructionResult, Memory, Stack}; @@ -433,7 +430,7 @@ impl From<&CallTraceStep> for StructLog { } else { None }, - stack: Some(step.stack.data().iter().copied().map(ru256_to_u256).collect()), + stack: Some(step.stack.data().iter().copied().map(|s| s.to_ethers()).collect()), // Filled in `CallTraceArena::geth_trace` as a result of compounding all slot changes storage: None, } @@ -600,7 +597,7 @@ impl TraceKind { /// Chooses the color of the trace depending on the destination address and status of the call. fn trace_color(trace: &CallTrace) -> Color { - if trace.address == b160_to_h160(CHEATCODE_ADDRESS) { + if trace.address == CHEATCODE_ADDRESS.to_ethers() { Color::Blue } else if trace.success { Color::Green diff --git a/crates/evm/src/trace/node.rs b/crates/evm/src/trace/node.rs index 7b9a2930e9c02..dc0c58f2017d4 100644 --- a/crates/evm/src/trace/node.rs +++ b/crates/evm/src/trace/node.rs @@ -5,7 +5,6 @@ use crate::{ utils, utils::decode_cheatcode_outputs, CallTrace, LogCallOrder, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, }, - utils::b160_to_h160, CallKind, }; use ethers::{ @@ -13,6 +12,7 @@ use ethers::{ types::{Action, Address, Call, CallResult, Create, CreateResult, Res, Suicide}, }; use foundry_common::SELECTOR_LEN; +use foundry_utils::types::ToEthers; use revm::interpreter::InstructionResult; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -110,7 +110,7 @@ impl CallTraceNode { if let RawOrDecodedCall::Raw(ref bytes) = self.trace.data { let inputs = if bytes.len() >= SELECTOR_LEN { - if self.trace.address == b160_to_h160(CHEATCODE_ADDRESS) { + if self.trace.address == CHEATCODE_ADDRESS.to_ethers() { // Try to decode cheatcode inputs in a more custom way utils::decode_cheatcode_inputs(func, bytes, errors, verbosity).unwrap_or_else( || { @@ -137,7 +137,7 @@ impl CallTraceNode { if let RawOrDecodedReturnData::Raw(bytes) = &self.trace.output { if !bytes.is_empty() && self.trace.success { - if self.trace.address == b160_to_h160(CHEATCODE_ADDRESS) { + if self.trace.address == CHEATCODE_ADDRESS.to_ethers() { if let Some(decoded) = funcs .iter() .find_map(|func| decode_cheatcode_outputs(func, bytes, verbosity)) diff --git a/crates/evm/src/utils.rs b/crates/evm/src/utils.rs index ad0b0851e5dc2..51f45070255a3 100644 --- a/crates/evm/src/utils.rs +++ b/crates/evm/src/utils.rs @@ -1,8 +1,9 @@ use ethers::{ abi::{Abi, FixedBytes, Function}, - types::{Block, Chain, H160, H256, U256}, + types::{Block, Chain, H256, U256}, }; use eyre::ContextCompat; +use foundry_utils::types::ToAlloy; use revm::{ interpreter::{opcode, opcode::spec_opcode_gas, InstructionResult}, primitives::{Eval, Halt, SpecId}, @@ -37,50 +38,6 @@ pub fn h256_to_u256_le(storage: H256) -> U256 { U256::from_little_endian(storage.as_bytes()) } -/// Small helper function to convert revm's [B160] into ethers's [H160]. -#[inline] -pub fn b160_to_h160(b: alloy_primitives::Address) -> ethers::types::H160 { - H160::from_slice(b.as_slice()) -} - -/// Small helper function to convert ethers's [H160] into revm's [B160]. -#[inline] -pub fn h160_to_b160(h: ethers::types::H160) -> alloy_primitives::Address { - alloy_primitives::Address::from_slice(h.as_bytes()) -} - -/// Small helper function to convert revm's [B256] into ethers's [H256]. -#[inline] -pub fn b256_to_h256(b: revm::primitives::B256) -> ethers::types::H256 { - ethers::types::H256(b.0) -} - -/// Small helper function to convert ether's [H256] into revm's [B256]. -#[inline] -pub fn h256_to_b256(h: ethers::types::H256) -> alloy_primitives::B256 { - alloy_primitives::B256::from_slice(h.as_bytes()) -} - -/// Small helper function to convert ether's [U256] into revm's [U256]. -#[inline] -pub fn u256_to_ru256(u: ethers::types::U256) -> revm::primitives::U256 { - let mut buffer = [0u8; 32]; - u.to_little_endian(buffer.as_mut_slice()); - revm::primitives::U256::from_le_bytes(buffer) -} - -// Small helper function to convert ethers's [U64] into alloy's [U64]. -#[inline] -pub fn u64_to_ru64(u: ethers::types::U64) -> alloy_primitives::U64 { - alloy_primitives::U64::from(u.as_u64()) -} - -/// Small helper function to convert revm's [U256] into ethers's [U256]. -#[inline] -pub fn ru256_to_u256(u: alloy_primitives::U256) -> ethers::types::U256 { - ethers::types::U256::from_little_endian(&u.as_le_bytes()) -} - /// Small helper function to convert an Eval into an InstructionResult #[inline] pub fn eval_to_instruction_result(eval: Eval) -> InstructionResult { @@ -145,7 +102,7 @@ pub fn apply_chain_and_block_specific_env_changes( // `l1BlockNumber` field if let Some(l1_block_number) = block.other.get("l1BlockNumber").cloned() { if let Ok(l1_block_number) = serde_json::from_value::(l1_block_number) { - env.block.number = u256_to_ru256(l1_block_number); + env.block.number = l1_block_number.to_alloy(); } } } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 473cb59ba8a2b..48e19dfd60bdd 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -27,7 +27,7 @@ use foundry_cli::{ }; use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; use foundry_config::{Config, SolcReq}; -use foundry_evm::utils::{b160_to_h160, ru256_to_u256}; +use foundry_utils::types::ToEthers; use semver::Version; use std::{collections::HashMap, sync::mpsc::channel}; use tracing::trace; @@ -288,9 +288,9 @@ impl CoverageArgs { // Build the contract runner let env = evm_opts.evm_env().await?; let mut runner = MultiContractRunnerBuilder::default() - .initial_balance(ru256_to_u256(evm_opts.initial_balance)) + .initial_balance(evm_opts.initial_balance.to_ethers()) .evm_spec(config.evm_spec_id()) - .sender(b160_to_h160(evm_opts.sender)) + .sender(evm_opts.sender.to_ethers()) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) .with_test_options(TestOptions { fuzz: config.fuzz, ..Default::default() }) diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index aee3846933c87..fc959a240d45b 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -16,8 +16,7 @@ use foundry_common::{ compact_to_contract, compile::{self, ContractSources}, }; -use foundry_evm::utils::b160_to_h160; -use foundry_utils::{PostLinkInput, ResolvedDependency}; +use foundry_utils::{types::ToEthers, PostLinkInput, ResolvedDependency}; use std::{collections::BTreeMap, fs, str::FromStr}; use tracing::{trace, warn}; @@ -65,7 +64,7 @@ impl ScriptArgs { project, contracts, script_config.config.parsed_libraries()?, - b160_to_h160(script_config.evm_opts.sender), + script_config.evm_opts.sender.to_ethers(), script_config.sender_nonce, )?; diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 8c602180f247a..b54a3921796b3 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -7,7 +7,7 @@ use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; use foundry_debugger::DebuggerArgs; -use foundry_evm::utils::b160_to_h160; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::sync::Arc; use tracing::trace; @@ -33,12 +33,9 @@ impl ScriptArgs { if let Some(ref fork_url) = script_config.evm_opts.fork_url { // when forking, override the sender's nonce to the onchain value - script_config.sender_nonce = foundry_utils::next_nonce( - b160_to_h160(script_config.evm_opts.sender), - fork_url, - None, - ) - .await? + script_config.sender_nonce = + foundry_utils::next_nonce(script_config.evm_opts.sender.to_ethers(), fork_url, None) + .await? } else { // if not forking, then ignore any pre-deployed library addresses script_config.config.libraries = Default::default(); @@ -71,7 +68,7 @@ impl ScriptArgs { // We need to execute the script even if just resuming, in case we need to collect private // keys from the execution. let mut result = self - .execute(&mut script_config, contract, b160_to_h160(sender), &predeploy_libraries) + .execute(&mut script_config, contract, sender.to_ethers(), &predeploy_libraries) .await?; if self.resume || (self.verify && !self.broadcast) { @@ -166,7 +163,7 @@ impl ScriptArgs { // Add predeploy libraries to the list of broadcastable transactions. let mut lib_deploy = self.create_deploy_transactions( - b160_to_h160(script_config.evm_opts.sender), + script_config.evm_opts.sender.to_ethers(), script_config.sender_nonce, &predeploy_libraries, &script_config.evm_opts.fork_url, @@ -356,7 +353,7 @@ impl ScriptArgs { } if let Some(wallets) = self.wallets.private_keys()? { if wallets.len() == 1 { - script_config.evm_opts.sender = h160_to_b160(wallets.get(0).unwrap().address()) + script_config.evm_opts.sender = wallets.get(0).unwrap().address().to_alloy() } } Ok(()) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 39915a8b3d421..e2eb27b176e63 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -20,7 +20,7 @@ use forge::{ }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{shell, RpcUrl}; -use foundry_evm::utils::{b160_to_h160, ru256_to_u256}; +use foundry_utils::types::ToEthers; use futures::future::join_all; use parking_lot::RwLock; use std::{collections::VecDeque, sync::Arc}; @@ -264,7 +264,7 @@ impl ScriptArgs { rpc.clone(), self.prepare_runner( &mut script_config, - b160_to_h160(sender), + sender.to_ethers(), SimulationStage::OnChain, ) .await, @@ -324,7 +324,7 @@ impl ScriptArgs { ScriptRunner::new( builder.build(env, db), - ru256_to_u256(script_config.evm_opts.initial_balance), + script_config.evm_opts.initial_balance.to_ethers(), sender, ) } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 693eed7dad0a8..31e62e5e8c9d0 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -50,8 +50,8 @@ use foundry_evm::{ cheatcodes::{util::BroadcastableTransactions, BroadcastableTransaction}, DEFAULT_CREATE2_DEPLOYER, }, - utils::h160_to_b160, }; +use foundry_utils::types::ToAlloy; use futures::future; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; @@ -406,7 +406,7 @@ impl ScriptArgs { shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; return Ok(None) } - } else if h160_to_b160(sender) != evm_opts.sender { + } else if sender.to_alloy() != evm_opts.sender { new_sender = Some(sender); } } @@ -551,7 +551,7 @@ impl ScriptArgs { // Find if it's a CREATE or CREATE2. Otherwise, skip transaction. if let Some(NameOrAddress::Address(to)) = to { - if h160_to_b160(*to) == DEFAULT_CREATE2_DEPLOYER { + if to.to_alloy() == DEFAULT_CREATE2_DEPLOYER { // Size of the salt prefix. offset = 32; } diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index e088a222f1a3f..56592a92c4944 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -10,7 +10,7 @@ use forge::{ trace::{TraceKind, Traces}, CALLER, }; -use foundry_evm::utils::{b160_to_h160, u256_to_ru256}; +use foundry_utils::types::{ToAlloy, ToEthers}; use tracing::log::trace; /// Represents which simulation stage is the script execution at. @@ -47,7 +47,7 @@ impl ScriptRunner { if !is_broadcast { if self.sender == Config::DEFAULT_SENDER { // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(h160_to_b160(self.sender), rU256::MAX)?; + self.executor.set_balance(self.sender.to_alloy(), rU256::MAX)?; } if need_create2_deployer { @@ -55,7 +55,7 @@ impl ScriptRunner { } } - self.executor.set_nonce(h160_to_b160(self.sender), sender_nonce.as_u64())?; + self.executor.set_nonce(self.sender.to_alloy(), sender_nonce.as_u64())?; // We max out their balance so that they can deploy and make calls. self.executor.set_balance(CALLER, rU256::MAX)?; @@ -66,7 +66,7 @@ impl ScriptRunner { .filter_map(|code| { let DeployResult { traces, .. } = self .executor - .deploy(h160_to_b160(self.sender), code.0.clone().into(), rU256::ZERO, None) + .deploy(self.sender.to_alloy(), code.0.clone().into(), rU256::ZERO, None) .expect("couldn't deploy library"); traces @@ -87,7 +87,7 @@ impl ScriptRunner { .map_err(|err| eyre::eyre!("Failed to deploy script:\n{}", err))?; traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); - self.executor.set_balance(address, u256_to_ru256(self.initial_balance))?; + self.executor.set_balance(address, self.initial_balance.to_alloy())?; // Optionally call the `setUp` function let (success, gas_used, labeled_addresses, transactions, debug, script_wallets) = if !setup @@ -102,7 +102,7 @@ impl ScriptRunner { vec![], ) } else { - match self.executor.setup(Some(h160_to_b160(self.sender)), address) { + match self.executor.setup(Some(self.sender.to_alloy()), address) { Ok(CallResult { reverted, traces: setup_traces, @@ -159,14 +159,14 @@ impl ScriptRunner { }; Ok(( - b160_to_h160(address), + address.to_ethers(), ScriptResult { returned: bytes::Bytes::new(), success, gas_used, labeled_addresses: labeled_addresses .into_iter() - .map(|l| (b160_to_h160(l.0), l.1)) + .map(|l| (l.0.to_ethers(), l.1)) .collect::>(), transactions, logs, @@ -190,7 +190,7 @@ impl ScriptRunner { if let Some(cheatcodes) = &self.executor.inspector.cheatcodes { if !cheatcodes.corrected_nonce { self.executor.set_nonce( - h160_to_b160(self.sender), + self.sender.to_alloy(), sender_initial_nonce.as_u64() + libraries_len as u64, )?; } @@ -216,13 +216,13 @@ impl ScriptRunner { self.call(from, to, calldata.unwrap_or_default(), value.unwrap_or(U256::zero()), true) } else if to.is_none() { let (address, gas_used, logs, traces, debug) = match self.executor.deploy( - h160_to_b160(from), + from.to_alloy(), calldata.expect("No data for create transaction").0.into(), - u256_to_ru256(value.unwrap_or(U256::zero())), + value.unwrap_or(U256::zero()).to_alloy(), None, ) { Ok(DeployResult { address, gas_used, logs, traces, debug, .. }) => { - (b160_to_h160(address), gas_used, logs, traces, debug) + (address.to_ethers(), gas_used, logs, traces, debug) } Err(EvmError::Execution(err)) => { let ExecutionErr { reason, traces, gas_used, logs, debug, .. } = *err; @@ -269,10 +269,10 @@ impl ScriptRunner { commit: bool, ) -> Result { let mut res = self.executor.call_raw( - h160_to_b160(from), - h160_to_b160(to), + from.to_alloy(), + to.to_alloy(), calldata.0.clone().into(), - u256_to_ru256(value), + value.to_alloy(), )?; let mut gas_used = res.gas_used; @@ -284,10 +284,10 @@ impl ScriptRunner { if commit { gas_used = self.search_optimal_gas_usage(&res, from, to, &calldata, value)?; res = self.executor.call_raw_committing( - h160_to_b160(from), - h160_to_b160(to), + from.to_alloy(), + to.to_alloy(), calldata.0.into(), - u256_to_ru256(value), + value.to_alloy(), )?; } @@ -317,7 +317,7 @@ impl ScriptRunner { }) .unwrap_or_default(), debug: vec![debug].into_iter().collect(), - labeled_addresses: labels.into_iter().map(|l| (b160_to_h160(l.0), l.1)).collect(), + labeled_addresses: labels.into_iter().map(|l| (l.0.to_ethers(), l.1)).collect(), transactions, address: None, script_wallets, @@ -351,10 +351,10 @@ impl ScriptRunner { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; self.executor.env.tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw( - h160_to_b160(from), - h160_to_b160(to), + from.to_alloy(), + to.to_alloy(), calldata.0.clone().into(), - u256_to_ru256(value), + value.to_alloy(), )?; match res.exit_reason { InstructionResult::Revert | diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 2190a835ab4f5..9b31c9cce118d 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -8,9 +8,9 @@ use ethers::{ use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{abi::format_token_raw, RpcUrl, SELECTOR_LEN}; use foundry_evm::{ - executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::CallTraceDecoder, utils::h160_to_b160, - CallKind, + executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::CallTraceDecoder, CallKind, }; +use foundry_utils::types::ToAlloy; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use tracing::error; @@ -77,7 +77,7 @@ impl TransactionWithMetadata { // Specify if any contract was directly created with this transaction if let Some(NameOrAddress::Address(to)) = metadata.transaction.to().cloned() { - if h160_to_b160(to) == DEFAULT_CREATE2_DEPLOYER { + if to.to_alloy() == DEFAULT_CREATE2_DEPLOYER { metadata.set_create( true, Address::from_slice(&result.returned), diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 83e528bf1908a..7538d95eaac55 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -32,10 +32,8 @@ use foundry_config::{ get_available_profiles, Config, }; use foundry_debugger::DebuggerArgs; -use foundry_evm::{ - fuzz::CounterExample, - utils::{b160_to_h160, ru256_to_u256}, -}; +use foundry_evm::fuzz::CounterExample; +use foundry_utils::types::ToEthers; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use tracing::trace; @@ -186,9 +184,9 @@ impl TestArgs { let mut runner_builder = MultiContractRunnerBuilder::default() .set_debug(should_debug) - .initial_balance(ru256_to_u256(evm_opts.initial_balance)) + .initial_balance(evm_opts.initial_balance.to_ethers()) .evm_spec(config.evm_spec_id()) - .sender(b160_to_h160(evm_opts.sender)) + .sender(evm_opts.sender.to_ethers()) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) .with_test_options(test_options.clone()); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 24d335ab33b71..59e51e78fc888 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -5,7 +5,7 @@ use crate::{ use comfy_table::{presets::ASCII_MARKDOWN, *}; use ethers::types::U256; use foundry_common::{calc, TestFunctionExt}; -use foundry_evm::utils::b160_to_h160; +use foundry_utils::types::ToEthers; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; @@ -47,8 +47,8 @@ impl GasReport { let node = &arena.arena[node_index]; let trace = &node.trace; - if trace.address == b160_to_h160(CHEATCODE_ADDRESS) || - trace.address == b160_to_h160(HARDHAT_CONSOLE_ADDRESS) + if trace.address == CHEATCODE_ADDRESS.to_ethers() || + trace.address == HARDHAT_CONSOLE_ADDRESS.to_ethers() { return } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 32ebcd8fed5ca..e126467d0e4ea 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -13,9 +13,8 @@ use foundry_evm::{ ExecutorBuilder, }, revm, - utils::{b160_to_h160, ru256_to_u256}, }; -use foundry_utils::{PostLinkInput, ResolvedDependency}; +use foundry_utils::{types::ToEthers, PostLinkInput, ResolvedDependency}; use rayon::prelude::*; use revm::primitives::SpecId; use std::{ @@ -208,7 +207,7 @@ impl MultiContractRunner { executor, contract, deploy_code, - ru256_to_u256(self.evm_opts.initial_balance), + self.evm_opts.initial_balance.to_ethers(), self.sender, self.errors.as_ref(), libs, @@ -286,7 +285,7 @@ impl MultiContractRunnerBuilder { ArtifactContracts::from_iter(contracts), &mut known_contracts, Default::default(), - b160_to_h160(evm_opts.sender), + evm_opts.sender.to_ethers(), U256::one(), &mut deployable_contracts, |post_link_input| { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index a7fccef0f9377..cb26320bb33a2 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -9,8 +9,8 @@ use foundry_evm::{ executor::EvmError, fuzz::{types::FuzzCase, CounterExample}, trace::{TraceKind, Traces}, - utils::b160_to_h160, }; +use foundry_utils::types::ToEthers; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt, time::Duration}; @@ -245,7 +245,7 @@ impl TestSetup { // force the tracekind to be setup so a trace is shown. traces.extend(err.traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(err.logs); - labeled_addresses.extend(err.labels.into_iter().map(|l| (b160_to_h160(l.0), l.1))); + labeled_addresses.extend(err.labels.into_iter().map(|l| (l.0.to_ethers(), l.1))); Self::failed_with(logs, traces, labeled_addresses, err.reason) } e => Self::failed_with( diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index d48138eabecb2..5e791300d71ab 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -25,9 +25,9 @@ use foundry_evm::{ CounterExample, FuzzedExecutor, }, trace::{load_contracts, TraceKind}, - utils::{b160_to_h160, h160_to_b160, u256_to_ru256}, CALLER, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use proptest::test_runner::{TestError, TestRunner}; use rayon::prelude::*; use std::{ @@ -98,18 +98,18 @@ impl<'a> ContractRunner<'a> { trace!(?setup, "Setting test contract"); // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(h160_to_b160(self.sender), rU256::MAX)?; + self.executor.set_balance(self.sender.to_alloy(), rU256::MAX)?; self.executor.set_balance(CALLER, rU256::MAX)?; // We set the nonce of the deployer accounts to 1 to get the same addresses as DappTools - self.executor.set_nonce(h160_to_b160(self.sender), 1)?; + self.executor.set_nonce(self.sender.to_alloy(), 1)?; // Deploy libraries let mut logs = Vec::new(); let mut traces = Vec::with_capacity(self.predeploy_libs.len()); for code in self.predeploy_libs.iter() { match self.executor.deploy( - h160_to_b160(self.sender), + self.sender.to_alloy(), code.0.clone().into(), rU256::ZERO, self.errors, @@ -126,7 +126,7 @@ impl<'a> ContractRunner<'a> { // Deploy the test contract let address = match self.executor.deploy( - h160_to_b160(self.sender), + self.sender.to_alloy(), self.code.0.clone().into(), rU256::ZERO, self.errors, @@ -143,10 +143,9 @@ impl<'a> ContractRunner<'a> { // Now we set the contracts initial balance, and we also reset `self.sender`s and `CALLER`s // balance to the initial balance we want - self.executor.set_balance(address, u256_to_ru256(self.initial_balance))?; - self.executor - .set_balance(h160_to_b160(self.sender), u256_to_ru256(self.initial_balance))?; - self.executor.set_balance(CALLER, u256_to_ru256(self.initial_balance))?; + self.executor.set_balance(address, self.initial_balance.to_alloy())?; + self.executor.set_balance(self.sender.to_alloy(), self.initial_balance.to_alloy())?; + self.executor.set_balance(CALLER, self.initial_balance.to_alloy())?; self.executor.deploy_create2_deployer()?; @@ -173,17 +172,17 @@ impl<'a> ContractRunner<'a> { logs.extend(setup_logs); TestSetup { - address: b160_to_h160(address), + address: address.to_ethers(), logs, traces, labeled_addresses: labeled_addresses .into_iter() - .map(|l| (b160_to_h160(l.0), l.1)) + .map(|l| (l.0.to_ethers(), l.1)) .collect(), reason, } } else { - TestSetup::success(b160_to_h160(address), logs, traces, Default::default()) + TestSetup::success(address.to_ethers(), logs, traces, Default::default()) }; Ok(setup) @@ -331,8 +330,8 @@ impl<'a> ContractRunner<'a> { let mut debug_arena = None; let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = match executor.execute_test::<(), _, _>( - h160_to_b160(self.sender), - h160_to_b160(address), + self.sender.to_alloy(), + address.to_alloy(), func.clone(), (), rU256::ZERO, @@ -353,7 +352,7 @@ impl<'a> ContractRunner<'a> { }) => { traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); labeled_addresses - .extend(new_labels.into_iter().map(|l| (b160_to_h160(l.0), l.1))); + .extend(new_labels.into_iter().map(|l| (l.0.to_ethers(), l.1))); logs.extend(execution_logs); debug_arena = debug; (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) @@ -361,7 +360,7 @@ impl<'a> ContractRunner<'a> { Err(EvmError::Execution(err)) => { traces.extend(err.traces.map(|traces| (TraceKind::Execution, traces))); labeled_addresses - .extend(err.labels.into_iter().map(|l| (b160_to_h160(l.0), l.1))); + .extend(err.labels.into_iter().map(|l| (l.0.to_ethers(), l.1))); logs.extend(err.logs); ( err.reverted, @@ -398,7 +397,7 @@ impl<'a> ContractRunner<'a> { }; let success = executor.is_success( - h160_to_b160(setup.address), + setup.address.to_alloy(), reverted, state_changeset.expect("we should have a state changeset"), should_fail, @@ -446,8 +445,8 @@ impl<'a> ContractRunner<'a> { // First, run the test normally to see if it needs to be skipped. if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<(), _, _>( - h160_to_b160(self.sender), - h160_to_b160(address), + self.sender.to_alloy(), + address.to_alloy(), func.clone(), (), rU256::ZERO, diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 6490d7076da0f..473ea33260a84 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -13,8 +13,8 @@ use foundry_config::{ }; use foundry_evm::{ decode::decode_console_logs, executor::inspector::CheatsConfig, revm::primitives::SpecId, - utils::b160_to_h160, }; +use foundry_utils::types::ToEthers; use std::{ collections::BTreeMap, path::{Path, PathBuf}, @@ -144,7 +144,7 @@ pub fn manifest_root() -> PathBuf { /// Builds a base runner pub fn base_runner() -> MultiContractRunnerBuilder { - MultiContractRunnerBuilder::default().sender(b160_to_h160(EVM_OPTS.sender)) + MultiContractRunnerBuilder::default().sender(EVM_OPTS.sender.to_ethers()) } /// Builds a non-tracing runner diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index ac66e43a7a067..fe219b10954de 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -14,9 +14,9 @@ use foundry_evm::{ DatabaseRef, Executor, ExecutorBuilder, }, fuzz::FuzzedExecutor, - utils::{b160_to_h160, h160_to_b160, u256_to_ru256}, CALLER, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::{path::PathBuf, str::FromStr}; pub static PROJECT: Lazy = Lazy::new(|| { @@ -65,13 +65,13 @@ pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { env: Env { gas_limit: 18446744073709551615, chain_id: None, - tx_origin: h160_to_b160(Config::DEFAULT_SENDER), + tx_origin: Config::DEFAULT_SENDER.to_alloy(), block_number: 1, block_timestamp: 1, ..Default::default() }, - sender: h160_to_b160(Config::DEFAULT_SENDER), - initial_balance: u256_to_ru256(U256::MAX), + sender: Config::DEFAULT_SENDER.to_alloy(), + initial_balance: U256::MAX.to_alloy(), ffi: true, memory_limit: 2u64.pow(24), ..Default::default() @@ -83,7 +83,7 @@ pub fn fuzz_executor(executor: &Executor) -> FuzzedExecutor { FuzzedExecutor::new( executor, proptest::test_runner::TestRunner::new(cfg), - b160_to_h160(CALLER), + CALLER.to_ethers(), config::test_opts().fuzz, ) } diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index 5f3efb593ead0..20406c9e3241b 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -1,7 +1,7 @@ //! Temporary utility conversion traits between ethers-rs and alloy types. -use alloy_primitives::{Address, B256, U256 as AlloyU256}; -use ethers_core::types::{H160, H256, U256}; +use alloy_primitives::{Address, B256, U256 as AlloyU256, U64 as AlloyU64}; +use ethers_core::types::{H160, H256, U256, U64}; /// Conversion trait to easily convert from ethers-rs types to alloy primitive types. pub trait ToAlloy { @@ -35,6 +35,14 @@ impl ToAlloy for U256 { } } +impl ToAlloy for U64 { + type To = AlloyU64; + + fn to_alloy(self) -> Self::To { + AlloyU64::from_limbs(self.0) + } +} + impl ToAlloy for u64 { type To = AlloyU256; From cdba27348d8ac52e0e652d42c5154120f9bb11f8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 21 Sep 2023 14:12:40 +0200 Subject: [PATCH 0093/1963] chore: use crates ethers and patch (#5869) --- Cargo.toml | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7ef6d2eec0451..ae2049af2e331 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,16 +138,18 @@ foundry-debugger = { path = "crates/debugger" } revm = { version = "3", default-features = false } revm-primitives = { version = "1", default-features = false } -ethers = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", default-features = false } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", default-features = false } +## ethers + +ethers = { version = "2.0", default-features = false } +ethers-addressbook = { version = "2.0", default-features = false } +ethers-core = { version = "2.0", default-features = false } +ethers-contract = { version = "2.0", default-features = false } +ethers-contract-abigen = { version = "2.0", default-features = false } +ethers-providers = { version = "2.0", default-features = false } +ethers-signers = { version = "2.0", default-features = false } +ethers-middleware = { version = "2.0", default-features = false } +ethers-etherscan = { version = "2.0", default-features = false } +ethers-solc = { version = "2.0", default-features = false } alloy-primitives = { version = "0.3", default-features = false } alloy-dyn-abi = { version = "0.3", default-features = false} @@ -173,6 +175,18 @@ hex = { package = "const-hex", version = "1.6", features = ["hex"] } #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] + +ethers = { git = "https://github.com/gakonst/ethers-rs" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs" } + revm = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } revm-interpreter = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } revm-precompile = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } From 92900269bd38751d868afaf901f23c402e3e22b1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 21 Sep 2023 19:08:29 +0200 Subject: [PATCH 0094/1963] fix: clean watch command from concatenated short flags (#5872) --- Cargo.lock | 55 +++++++------------------------- crates/forge/bin/cmd/test/mod.rs | 45 ++++++++++++++++++++++++++ crates/forge/bin/cmd/watch.rs | 41 ++++++++++++++++++++++-- 3 files changed, 96 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee89149c5edb8..d4b6823607890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1107,9 +1107,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.3" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" +checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" dependencies = [ "clap_builder", "clap_derive", @@ -1117,9 +1117,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ "anstream", "anstyle", @@ -2361,7 +2361,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.13", + "rustix", "windows-sys 0.48.0", ] @@ -3787,17 +3787,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "ipnet" version = "2.8.0" @@ -3811,7 +3800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.13", + "rustix", "windows-sys 0.48.0", ] @@ -4047,12 +4036,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.7" @@ -5842,20 +5825,6 @@ dependencies = [ "semver 1.0.18", ] -[[package]] -name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - [[package]] name = "rustix" version = "0.38.13" @@ -5865,7 +5834,7 @@ dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.7", + "linux-raw-sys", "windows-sys 0.48.0", ] @@ -6686,7 +6655,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.13", + "rustix", "windows-sys 0.48.0", ] @@ -6723,11 +6692,11 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.37.23", + "rustix", "windows-sys 0.48.0", ] @@ -7706,7 +7675,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.13", + "rustix", ] [[package]] diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 7538d95eaac55..90d6ce2cf1a5e 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -788,3 +788,48 @@ async fn test( trace!(target: "forge::test", "received {} results", results.len()); Ok(TestOutcome::new(results, allow_failure)) } + +#[cfg(test)] +mod tests { + use super::*; + + // Sanity test that unknown args are rejected + #[test] + fn test_verbosity() { + #[derive(Debug, Parser)] + pub struct VerbosityArgs { + #[clap(long, short, action = clap::ArgAction::Count)] + verbosity: u8, + } + let res = VerbosityArgs::try_parse_from(["foundry-cli", "-vw"]); + assert!(res.is_err()); + + let res = VerbosityArgs::try_parse_from(["foundry-cli", "-vv"]); + assert!(res.is_ok()); + } + + #[test] + fn test_verbosity_multi_short() { + #[derive(Debug, Parser)] + pub struct VerbosityArgs { + #[clap(long, short)] + verbosity: bool, + #[clap( + long, + short, + num_args(0..), + value_name = "PATH", + )] + watch: Option>, + } + // this is supported by clap + let res = VerbosityArgs::try_parse_from(["foundry-cli", "-vw"]); + assert!(res.is_ok()) + } + + #[test] + fn test_watch_parse() { + let args: TestArgs = TestArgs::parse_from(["foundry-cli", "-vw"]); + assert!(args.watch.watch.is_some()); + } +} diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index bdee1e3d0456c..558a10d5e05b0 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -263,12 +263,37 @@ fn watch_command(mut args: Vec) -> Command { /// Returns the env args without the `--watch` flag from the args for the Watchexec command fn cmd_args(num: usize) -> Vec { - // all the forge arguments including path to forge bin - let mut cmd_args: Vec<_> = std::env::args().collect(); + clean_cmd_args(num, std::env::args().collect()) +} +fn clean_cmd_args(num: usize, mut cmd_args: Vec) -> Vec { if let Some(pos) = cmd_args.iter().position(|arg| arg == "--watch" || arg == "-w") { cmd_args.drain(pos..=(pos + num)); } + // There's another edge case where short flags are combined into one which is supported by clap, + // like `-vw` for verbosity and watch + // this removes any `w` from concatenated short flags + if let Some(pos) = cmd_args.iter().position(|arg| { + fn contains_w_in_short(arg: &str) -> Option { + let mut iter = arg.chars(); + if iter.next()? != '-' { + return None + } + if iter.next()? == '-' { + return None + } + Some(iter.any(|c| c == 'w')) + } + contains_w_in_short(arg).unwrap_or(false) + }) { + let clean_arg = cmd_args[pos].replace('w', ""); + if clean_arg == "-" { + cmd_args.remove(pos); + } else { + cmd_args[pos] = clean_arg; + } + } + cmd_args } @@ -413,3 +438,15 @@ pub fn runtime(args: &WatchArgs) -> Result { Ok(config) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_cmd_args() { + let args = vec!["-vw".to_string()]; + let cleaned = clean_cmd_args(0, args); + assert_eq!(cleaned, vec!["-v".to_string()]); + } +} From adb526bc1db52db96ba6c69be178022f97e76ec5 Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 21 Sep 2023 19:31:44 -0400 Subject: [PATCH 0095/1963] docs(`contributing`): add note about using a debugger with foundry (#5875) * docs(contributing): add note about using a debugger with foundry * chore: link to cargo.toml --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4365c0b9badac..a4e6d1d4a8b86 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -101,6 +101,8 @@ If you are working on a larger feature, we encourage you to open up a draft pull If you would like to test the binaries built from your change, see [foundryup](https://github.com/foundry-rs/foundry/tree/master/foundryup). +If you would like to use a debugger with breakpoints to debug a patch you might be working on, keep in mind we currently strip debug info for faster builds, which is *not* the default. Therefore, to use a debugger, you need to enable it on the workspace [`Cargo.toml`'s `dev` profile](https://github.com/foundry-rs/foundry/tree/master/Cargo.toml#L15-L18). + #### Adding tests If the change being proposed alters code, it is either adding new functionality to Foundry, or fixing existing, broken functionality. From 58742660c93580f97ba79e7bfe647e709451497d Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 22 Sep 2023 09:03:11 -0400 Subject: [PATCH 0096/1963] chore: migrate test-utils crate (#5874) --- Cargo.lock | 2 ++ crates/forge/tests/cli/multi_script.rs | 33 ++++++++++++++++++++++---- crates/forge/tests/cli/script.rs | 26 ++++++++++---------- crates/test-utils/Cargo.toml | 2 ++ crates/test-utils/src/script.rs | 28 +++++++++++----------- 5 files changed, 60 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4b6823607890..264b041955868 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2771,11 +2771,13 @@ dependencies = [ name = "foundry-test-utils" version = "0.2.0" dependencies = [ + "alloy-primitives", "ethers", "ethers-solc", "eyre", "foundry-common", "foundry-config", + "foundry-utils", "once_cell", "parking_lot", "pretty_assertions", diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index f571585b96b66..2320b793849e3 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -5,6 +5,7 @@ use foundry_test_utils::{ util::{TestCommand, TestProject}, ScriptOutcome, ScriptTester, }; +use foundry_utils::types::ToEthers; forgetest_async!( can_deploy_multi_chain_script_without_lib, @@ -20,11 +21,35 @@ forgetest_async!( .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) .broadcast(ScriptOutcome::OkBroadcast); - assert!(1 == api1.transaction_count(tester.accounts_pub[0], None).await.unwrap().as_u32()); - assert!(1 == api1.transaction_count(tester.accounts_pub[1], None).await.unwrap().as_u32()); + assert!( + 1 == api1 + .transaction_count(tester.accounts_pub[0].to_ethers(), None) + .await + .unwrap() + .as_u32() + ); + assert!( + 1 == api1 + .transaction_count(tester.accounts_pub[1].to_ethers(), None) + .await + .unwrap() + .as_u32() + ); - assert!(2 == api2.transaction_count(tester.accounts_pub[0], None).await.unwrap().as_u32()); - assert!(3 == api2.transaction_count(tester.accounts_pub[1], None).await.unwrap().as_u32()); + assert!( + 2 == api2 + .transaction_count(tester.accounts_pub[0].to_ethers(), None) + .await + .unwrap() + .as_u32() + ); + assert!( + 3 == api2 + .transaction_count(tester.accounts_pub[1].to_ethers(), None) + .await + .unwrap() + .as_u32() + ); } ); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index d2382af5467a4..2797f8b22b824 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -8,7 +8,7 @@ use foundry_test_utils::{ util::{OutputExt, TestCommand, TestProject}, ScriptOutcome, ScriptTester, }; -use foundry_utils::rpc; +use foundry_utils::{rpc, types::ToAlloy}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; @@ -456,15 +456,15 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_addresses(vec![ - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() - ]) + .load_addresses(vec![Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906") + .unwrap() + .to_alloy()]) .await .add_sig("BroadcastTest", "deployPrivateKey()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) .assert_nonce_increment_addresses(vec![( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap().to_alloy(), 3, )]) .await; @@ -495,15 +495,15 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_addresses(vec![ - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() - ]) + .load_addresses(vec![Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906") + .unwrap() + .to_alloy()]) .await .add_sig("BroadcastTest", "deployRememberKey()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) .assert_nonce_increment_addresses(vec![( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap().to_alloy(), 2, )]) .await; @@ -519,9 +519,9 @@ forgetest_async!( tester .add_deployer(0) - .load_addresses(vec![ - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() - ]) + .load_addresses(vec![Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906") + .unwrap() + .to_alloy()]) .await .add_sig("BroadcastTest", "deployRememberKeyResume()") .simulate(ScriptOutcome::OkSimulation) @@ -531,7 +531,7 @@ forgetest_async!( .await .run(ScriptOutcome::OkBroadcast) .assert_nonce_increment_addresses(vec![( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap().to_alloy(), 1, )]) .await diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 849ba66fdf7ff..e572c104ef9fe 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -14,9 +14,11 @@ repository.workspace = true [dependencies] foundry-config.workspace = true foundry-common.workspace = true +foundry-utils.workspace = true ethers.workspace = true ethers-solc = { workspace = true, features = ["project-util"] } +alloy-primitives = { workspace = true, features = ["std"]} eyre = "0.6" once_cell = "1" diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 4ff1b47aede3a..2ed5fc5b7aa6f 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,11 +1,9 @@ use crate::TestCommand; -use ethers::{ - abi::Address, - prelude::{Middleware, NameOrAddress, U256}, - utils::hex, -}; +use alloy_primitives::{hex, Address, U256}; +use ethers::prelude::{Middleware, NameOrAddress}; use eyre::Result; use foundry_common::{get_http_provider, RetryProvider}; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::{collections::BTreeMap, path::Path, str::FromStr}; pub const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; @@ -112,12 +110,12 @@ impl ScriptTester { if let Some(provider) = &self.provider { let nonce = provider .get_transaction_count( - NameOrAddress::Address(self.accounts_pub[index as usize]), + NameOrAddress::Address(self.accounts_pub[index as usize].to_ethers()), None, ) .await .unwrap(); - self.nonces.insert(index, nonce); + self.nonces.insert(index, nonce.to_alloy()); } } self @@ -129,10 +127,10 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(NameOrAddress::Address(address), None) + .get_transaction_count(NameOrAddress::Address(address.to_ethers()), None) .await .unwrap(); - self.address_nonces.insert(address, nonce); + self.address_nonces.insert(address, nonce.to_alloy()); } self } @@ -140,7 +138,7 @@ impl ScriptTester { pub fn add_deployer(&mut self, index: u32) -> &mut Self { self.cmd.args([ "--sender", - &format!("0x{}", hex::encode(self.accounts_pub[index as usize].as_bytes())), + &format!("0x{}", hex::encode(self.accounts_pub[index as usize].to_ethers())), ]); self } @@ -184,14 +182,16 @@ impl ScriptTester { .as_ref() .unwrap() .get_transaction_count( - NameOrAddress::Address(self.accounts_pub[private_key_slot as usize]), + NameOrAddress::Address( + self.accounts_pub[private_key_slot as usize].to_ethers(), + ), None, ) .await .unwrap(); let prev_nonce = self.nonces.get(&private_key_slot).unwrap(); - assert_eq!(nonce, prev_nonce + U256::from(expected_increment)); + assert_eq!(nonce, (prev_nonce + U256::from(expected_increment)).to_ethers()); } self } @@ -206,12 +206,12 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(NameOrAddress::Address(address), None) + .get_transaction_count(NameOrAddress::Address(address.to_ethers()), None) .await .unwrap(); let prev_nonce = self.address_nonces.get(&address).unwrap(); - assert_eq!(nonce, prev_nonce + U256::from(expected_increment)); + assert_eq!(nonce, (prev_nonce + U256::from(expected_increment)).to_ethers()); } self } From 862bba55c5fdfe181ef7dc275194faf312289758 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 22 Sep 2023 12:28:03 -0400 Subject: [PATCH 0097/1963] feat(forge): partial alloy primitives migration (#5873) --- crates/evm/src/coverage/anchors.rs | 6 +- crates/evm/src/coverage/mod.rs | 6 +- crates/evm/src/executor/inspector/coverage.rs | 5 +- crates/forge/bin/cmd/coverage.rs | 14 +- crates/forge/bin/cmd/create.rs | 12 +- crates/forge/bin/cmd/script/broadcast.rs | 64 ++++--- crates/forge/bin/cmd/script/build.rs | 10 +- crates/forge/bin/cmd/script/cmd.rs | 21 ++- crates/forge/bin/cmd/script/executor.rs | 156 +++++++++--------- crates/forge/bin/cmd/script/mod.rs | 24 +-- crates/forge/bin/cmd/script/providers.rs | 16 +- crates/forge/bin/cmd/script/receipts.rs | 16 +- crates/forge/bin/cmd/script/runner.rs | 76 ++++----- crates/forge/bin/cmd/script/sequence.rs | 9 +- crates/forge/bin/cmd/script/transaction.rs | 28 ++-- crates/forge/bin/cmd/script/verify.rs | 6 +- crates/forge/bin/cmd/snapshot.rs | 4 +- crates/forge/bin/cmd/test/mod.rs | 7 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 6 +- crates/forge/bin/cmd/verify/mod.rs | 3 +- crates/forge/bin/cmd/verify/sourcify.rs | 4 +- crates/forge/src/multi_runner.rs | 20 ++- crates/forge/tests/it/config.rs | 6 +- crates/utils/src/lib.rs | 68 ++++---- 24 files changed, 298 insertions(+), 289 deletions(-) diff --git a/crates/evm/src/coverage/anchors.rs b/crates/evm/src/coverage/anchors.rs index 9aa1bd9efcb9a..750388c088b6c 100644 --- a/crates/evm/src/coverage/anchors.rs +++ b/crates/evm/src/coverage/anchors.rs @@ -1,9 +1,7 @@ use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; use crate::utils::ICPCMap; -use ethers::prelude::{ - sourcemap::{SourceElement, SourceMap}, - Bytes, -}; +use alloy_primitives::Bytes; +use ethers::prelude::sourcemap::{SourceElement, SourceMap}; use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, diff --git a/crates/evm/src/coverage/mod.rs b/crates/evm/src/coverage/mod.rs index 59ee950c2c8a4..7d78e9b519478 100644 --- a/crates/evm/src/coverage/mod.rs +++ b/crates/evm/src/coverage/mod.rs @@ -1,8 +1,8 @@ pub mod analysis; pub mod anchors; +use alloy_primitives::B256; use bytes::Bytes; -use ethers::types::H256; use semver::Version; use std::{ collections::{BTreeMap, HashMap}, @@ -115,7 +115,7 @@ impl CoverageReport { /// A collection of [HitMap]s #[derive(Default, Clone, Debug)] -pub struct HitMaps(pub HashMap); +pub struct HitMaps(pub HashMap); impl HitMaps { pub fn merge(mut self, other: HitMaps) -> Self { @@ -132,7 +132,7 @@ impl HitMaps { } impl Deref for HitMaps { - type Target = HashMap; + type Target = HashMap; fn deref(&self) -> &Self::Target { &self.0 diff --git a/crates/evm/src/executor/inspector/coverage.rs b/crates/evm/src/executor/inspector/coverage.rs index ba8dadc5f8564..3f06c490e4160 100644 --- a/crates/evm/src/executor/inspector/coverage.rs +++ b/crates/evm/src/executor/inspector/coverage.rs @@ -1,6 +1,5 @@ use crate::coverage::{HitMap, HitMaps}; use bytes::Bytes; -use foundry_utils::types::ToEthers; use revm::{ interpreter::{InstructionResult, Interpreter}, Database, EVMData, Inspector, @@ -19,7 +18,7 @@ impl Inspector for CoverageCollector { interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, ) -> InstructionResult { - let hash = interpreter.contract.hash.to_ethers(); + let hash = interpreter.contract.hash; self.maps.entry(hash).or_insert_with(|| { HitMap::new(Bytes::copy_from_slice( interpreter.contract.bytecode.original_bytecode_slice(), @@ -35,7 +34,7 @@ impl Inspector for CoverageCollector { interpreter: &mut Interpreter, _: &mut EVMData<'_, DB>, ) -> InstructionResult { - let hash = interpreter.contract.hash.to_ethers(); + let hash = interpreter.contract.hash; self.maps.entry(hash).and_modify(|map| map.hit(interpreter.program_counter())); InstructionResult::Continue diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 48e19dfd60bdd..70a44aa108780 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -1,10 +1,10 @@ use super::{install, test::FilterArgs}; +use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueEnum}; use ethers::{ - abi::Address, prelude::{ artifacts::{Ast, CompactBytecode, CompactDeployedBytecode}, - Artifact, Bytes, Project, ProjectCompileOutput, U256, + Artifact, Project, ProjectCompileOutput, }, solc::{artifacts::contract::CompactContractBytecode, sourcemap::SourceMap}, }; @@ -78,7 +78,7 @@ impl CoverageArgs { } // Set fuzz seed so coverage reports are deterministic - config.fuzz.seed = Some(U256::from_big_endian(&STATIC_FUZZ_SEED)); + config.fuzz.seed = Some(U256::from_be_bytes(STATIC_FUZZ_SEED).to_ethers()); let (project, output) = self.build(&config)?; p_println!(!self.opts.silent => "Analysing contracts..."); @@ -288,9 +288,9 @@ impl CoverageArgs { // Build the contract runner let env = evm_opts.evm_env().await?; let mut runner = MultiContractRunnerBuilder::default() - .initial_balance(evm_opts.initial_balance.to_ethers()) + .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) - .sender(evm_opts.sender.to_ethers()) + .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) .with_test_options(TestOptions { fuzz: config.fuzz, ..Default::default() }) @@ -373,12 +373,12 @@ fn dummy_link_bytecode(mut obj: CompactBytecode) -> Option { let link_references = obj.link_references.clone(); for (file, libraries) in link_references { for library in libraries.keys() { - obj.link(&file, library, Address::zero()); + obj.link(&file, library, Address::ZERO.to_ethers()); } } obj.object.resolve(); - obj.object.into_bytes() + obj.object.into_bytes().map(|o| o.0.into()) } /// Helper function that will link references in unlinked bytecode to the 0 address. diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index ad82163aa72f6..99d1aceba26dc 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -5,7 +5,6 @@ use ethers::{ prelude::{artifacts::BytecodeObject, ContractFactory, Middleware, MiddlewareBuilder}, solc::{info::ContractInfo, utils::canonicalized}, types::{transaction::eip2718::TypedTransaction, Chain}, - utils::to_checksum, }; use eyre::{Context, Result}; use foundry_cli::{ @@ -13,6 +12,7 @@ use foundry_cli::{ utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; use foundry_common::{abi::parse_tokens, compile, estimate_eip1559_fees}; +use foundry_utils::types::ToAlloy; use serde_json::json; use std::{path::PathBuf, sync::Arc}; @@ -268,17 +268,17 @@ impl CreateArgs { // Deploy the actual contract let (deployed_contract, receipt) = deployer.send_with_receipt().await?; - let address = deployed_contract.address(); + let address = deployed_contract.address().to_alloy(); if self.json { let output = json!({ - "deployer": to_checksum(&deployer_address, None), - "deployedTo": to_checksum(&address, None), + "deployer": deployer_address.to_alloy().to_checksum(None), + "deployedTo": address.to_checksum(None), "transactionHash": receipt.transaction_hash }); println!("{output}"); } else { - println!("Deployer: {}", to_checksum(&deployer_address, None)); - println!("Deployed to: {}", to_checksum(&address, None)); + println!("Deployer: {}", deployer_address.to_alloy().to_checksum(None)); + println!("Deployed to: {}", address.to_checksum(None)); println!("Transaction hash: {:?}", receipt.transaction_hash); }; diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 5414c0d9284a5..88118d13dca1d 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -31,11 +31,11 @@ impl ScriptArgs { let already_broadcasted = deployment_sequence.receipts.len(); if already_broadcasted < deployment_sequence.transactions.len() { - let required_addresses = deployment_sequence + let required_addresses: HashSet
= deployment_sequence .typed_transactions() .into_iter() .skip(already_broadcasted) - .map(|(_, tx)| *tx.from().expect("No sender for onchain transaction!")) + .map(|(_, tx)| (*tx.from().expect("No sender for onchain transaction!")).to_alloy()) .collect(); let (send_kind, chain) = if self.unlocked { @@ -43,22 +43,32 @@ impl ScriptArgs { let mut senders = HashSet::from([self .evm_opts .sender + .map(|sender| sender.to_alloy()) .wrap_err("--sender must be set with --unlocked")?]); // also take all additional senders that where set manually via broadcast senders.extend( deployment_sequence .typed_transactions() .iter() - .filter_map(|(_, tx)| tx.from().copied()), + .filter_map(|(_, tx)| tx.from().copied().map(|addr| addr.to_alloy())), ); (SendTransactionsKind::Unlocked(senders), chain.as_u64()) } else { let local_wallets = self .wallets - .find_all(provider.clone(), required_addresses, script_wallets) + .find_all( + provider.clone(), + required_addresses.into_iter().map(|addr| addr.to_ethers()).collect(), + script_wallets, + ) .await?; let chain = local_wallets.values().last().wrap_err("Error accessing local wallet when trying to send onchain transaction, did you set a private key, mnemonic or keystore?")?.chain_id(); - (SendTransactionsKind::Raw(local_wallets), chain) + ( + SendTransactionsKind::Raw( + local_wallets.into_iter().map(|m| (m.0.to_alloy(), m.1)).collect(), + ), + chain, + ) }; // We only wait for a transaction receipt before sending the next transaction, if there @@ -91,7 +101,7 @@ impl ScriptArgs { .skip(already_broadcasted) .map(|tx_with_metadata| { let tx = tx_with_metadata.typed_tx(); - let from = *tx.from().expect("No sender for onchain transaction!"); + let from = (*tx.from().expect("No sender for onchain transaction!")).to_alloy(); let kind = send_kind.for_sender(&from)?; let is_fixed_gas_limit = tx_with_metadata.is_fixed_gas_limit; @@ -101,7 +111,7 @@ impl ScriptArgs { tx.set_chain_id(chain); if let Some(gas_price) = self.with_gas_price { - tx.set_gas_price(gas_price); + tx.set_gas_price(gas_price.to_ethers()); } else { // fill gas price match tx { @@ -112,7 +122,8 @@ impl ScriptArgs { let eip1559_fees = eip1559_fees.expect("Could not get eip1559 fee estimation."); if let Some(priority_gas_price) = self.priority_gas_price { - inner.max_priority_fee_per_gas = Some(priority_gas_price); + inner.max_priority_fee_per_gas = + Some(priority_gas_price.to_ethers()); } else { inner.max_priority_fee_per_gas = Some(eip1559_fees.1); } @@ -153,13 +164,17 @@ impl ScriptArgs { if sequential_broadcast { let tx_hash = tx_hash.await?; - deployment_sequence.add_pending(index, tx_hash); + deployment_sequence.add_pending(index, tx_hash.to_alloy()); update_progress!(pb, (index + already_broadcasted)); index += 1; - clear_pendings(provider.clone(), deployment_sequence, Some(vec![tx_hash])) - .await?; + clear_pendings( + provider.clone(), + deployment_sequence, + Some(vec![tx_hash.to_alloy()]), + ) + .await?; } else { pending_transactions.push(tx_hash); } @@ -170,7 +185,7 @@ impl ScriptArgs { while let Some(tx_hash) = buffer.next().await { let tx_hash = tx_hash?; - deployment_sequence.add_pending(index, tx_hash); + deployment_sequence.add_pending(index, tx_hash.to_alloy()); update_progress!(pb, (index + already_broadcasted)); index += 1; @@ -194,16 +209,17 @@ impl ScriptArgs { shell::println("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; let (total_gas, total_gas_price, total_paid) = deployment_sequence.receipts.iter().fold( - (U256::zero(), U256::zero(), U256::zero()), + (U256::ZERO, U256::ZERO, U256::ZERO), |acc, receipt| { - let gas_used = receipt.gas_used.unwrap_or_default(); - let gas_price = receipt.effective_gas_price.unwrap_or_default(); + let gas_used = receipt.gas_used.unwrap_or_default().to_alloy(); + let gas_price = receipt.effective_gas_price.unwrap_or_default().to_alloy(); (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used.mul(gas_price)) }, ); - let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); - let avg_gas_price = format_units(total_gas_price / deployment_sequence.receipts.len(), 9) - .unwrap_or_else(|_| "N/A".to_string()); + let paid = format_units(total_paid.to_ethers(), 18).unwrap_or_else(|_| "N/A".to_string()); + let avg_gas_price = + format_units(total_gas_price.to_ethers() / deployment_sequence.receipts.len(), 9) + .unwrap_or_else(|_| "N/A".to_string()); shell::println(format!( "Total Paid: {} ETH ({} gas * avg {} gwei)", paid.trim_end_matches('0'), @@ -226,13 +242,13 @@ impl ScriptArgs { let from = tx.from().expect("no sender"); if sequential_broadcast { - let nonce = foundry_utils::next_nonce(*from, fork_url, None) + let nonce = foundry_utils::next_nonce((*from).to_alloy(), fork_url, None) .await .map_err(|_| eyre::eyre!("Not able to query the EOA nonce."))?; let tx_nonce = tx.nonce().expect("no nonce"); - if nonce != *tx_nonce { + if nonce != (*tx_nonce).to_alloy() { bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") } } @@ -493,8 +509,8 @@ impl ScriptArgs { } } - let total_gas = total_gas_per_rpc.entry(tx_rpc.clone()).or_insert(U256::zero()); - *total_gas += *typed_tx.gas().expect("gas is set"); + let total_gas = total_gas_per_rpc.entry(tx_rpc.clone()).or_insert(U256::ZERO); + *total_gas += (*typed_tx.gas().expect("gas is set")).to_alloy(); } new_sequence.push_back(tx); @@ -543,7 +559,7 @@ impl ScriptArgs { shell::println(format!( "\nEstimated gas price: {} gwei", - format_units(per_gas, 9) + format_units(per_gas.to_ethers(), 9) .unwrap_or_else(|_| "[Could not calculate]".to_string()) .trim_end_matches('0') .trim_end_matches('.') @@ -551,7 +567,7 @@ impl ScriptArgs { shell::println(format!("\nEstimated total gas used for script: {total_gas}"))?; shell::println(format!( "\nEstimated amount required: {} ETH", - format_units(total_gas.saturating_mul(per_gas), 18) + format_units(total_gas.saturating_mul(per_gas).to_ethers(), 18) .unwrap_or_else(|_| "[Could not calculate]".to_string()) .trim_end_matches('0') ))?; diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index fc959a240d45b..e54ac4fc523b6 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,4 +1,5 @@ use super::*; +use alloy_primitives::{Address, Bytes, U256}; use ethers::{ prelude::{ artifacts::Libraries, cache::SolFilesCache, ArtifactId, Project, ProjectCompileOutput, @@ -8,7 +9,6 @@ use ethers::{ contracts::ArtifactContracts, info::ContractInfo, }, - types::{Address, U256}, }; use eyre::{Context, ContextCompat, Result}; use foundry_cli::utils::get_cached_entry_by_name; @@ -16,7 +16,7 @@ use foundry_common::{ compact_to_contract, compile::{self, ContractSources}, }; -use foundry_utils::{types::ToEthers, PostLinkInput, ResolvedDependency}; +use foundry_utils::{PostLinkInput, ResolvedDependency}; use std::{collections::BTreeMap, fs, str::FromStr}; use tracing::{trace, warn}; @@ -64,7 +64,7 @@ impl ScriptArgs { project, contracts, script_config.config.parsed_libraries()?, - script_config.evm_opts.sender.to_ethers(), + script_config.evm_opts.sender, script_config.sender_nonce, )?; @@ -272,7 +272,7 @@ struct ExtraLinkingInfo<'a> { no_target_name: bool, target_fname: String, contract: &'a mut CompactContractBytecode, - dependencies: &'a mut Vec<(String, ethers::types::Bytes)>, + dependencies: &'a mut Vec<(String, Bytes)>, matched: bool, target_id: Option, } @@ -284,6 +284,6 @@ pub struct BuildOutput { pub known_contracts: ArtifactContracts, pub highlevel_known_contracts: ArtifactContracts, pub libraries: Libraries, - pub predeploy_libraries: Vec, + pub predeploy_libraries: Vec, pub sources: ContractSources, } diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index b54a3921796b3..6683b3f251478 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -1,13 +1,14 @@ use super::{multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, *}; +use alloy_primitives::{Bytes, U256}; use ethers::{ prelude::{Middleware, Signer}, - types::{transaction::eip2718::TypedTransaction, U256}, + types::transaction::eip2718::TypedTransaction, }; use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; use foundry_debugger::DebuggerArgs; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_utils::types::ToAlloy; use std::sync::Arc; use tracing::trace; @@ -22,7 +23,7 @@ impl ScriptArgs { let (config, evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; let mut script_config = ScriptConfig { // dapptools compatibility - sender_nonce: U256::one(), + sender_nonce: U256::from(1), config, evm_opts, debug: self.debug, @@ -34,8 +35,7 @@ impl ScriptArgs { if let Some(ref fork_url) = script_config.evm_opts.fork_url { // when forking, override the sender's nonce to the onchain value script_config.sender_nonce = - foundry_utils::next_nonce(script_config.evm_opts.sender.to_ethers(), fork_url, None) - .await? + foundry_utils::next_nonce(script_config.evm_opts.sender, fork_url, None).await? } else { // if not forking, then ignore any pre-deployed library addresses script_config.config.libraries = Default::default(); @@ -67,9 +67,8 @@ impl ScriptArgs { // We need to execute the script even if just resuming, in case we need to collect private // keys from the execution. - let mut result = self - .execute(&mut script_config, contract, sender.to_ethers(), &predeploy_libraries) - .await?; + let mut result = + self.execute(&mut script_config, contract, sender, &predeploy_libraries).await?; if self.resume || (self.verify && !self.broadcast) { return self @@ -163,7 +162,7 @@ impl ScriptArgs { // Add predeploy libraries to the list of broadcastable transactions. let mut lib_deploy = self.create_deploy_transactions( - script_config.evm_opts.sender.to_ethers(), + script_config.evm_opts.sender, script_config.sender_nonce, &predeploy_libraries, &script_config.evm_opts.fork_url, @@ -277,8 +276,8 @@ impl ScriptArgs { project, default_known_contracts, Libraries::parse(&deployment_sequence.libraries)?, - script_config.config.sender, // irrelevant, since we're not creating any - U256::zero(), // irrelevant, since we're not creating any + script_config.config.sender.to_alloy(), // irrelevant, since we're not creating any + U256::ZERO, // irrelevant, since we're not creating any )?; verify.known_contracts = flatten_contracts(&highlevel_known_contracts, false); diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index e2eb27b176e63..b2cb4868d3b32 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -4,9 +4,9 @@ use super::{ transaction::{AdditionalContract, TransactionWithMetadata}, *, }; +use alloy_primitives::{Address, Bytes, U256}; use ethers::{ - solc::artifacts::CompactContractBytecode, - types::{transaction::eip2718::TypedTransaction, Address, U256}, + solc::artifacts::CompactContractBytecode, types::transaction::eip2718::TypedTransaction, }; use eyre::Result; use forge::{ @@ -37,7 +37,7 @@ impl ScriptArgs { script_config: &mut ScriptConfig, contract: CompactContractBytecode, sender: Address, - predeploy_libraries: &[ethers::types::Bytes], + predeploy_libraries: &[Bytes], ) -> Result { trace!(target: "script", "start executing script"); @@ -48,10 +48,12 @@ impl ScriptArgs { ensure_clean_constructor(&abi)?; + let predeploy_libraries = + predeploy_libraries.iter().map(|b| b.0.clone().into()).collect::>(); let mut runner = self.prepare_runner(script_config, sender, SimulationStage::Local).await; let (address, mut result) = runner.setup( - predeploy_libraries, - bytecode, + &predeploy_libraries, + bytecode.0.into(), needs_setup(&abi), script_config.sender_nonce, self.broadcast, @@ -63,7 +65,7 @@ impl ScriptArgs { // Only call the method if `setUp()` succeeded. if result.success { - let script_result = runner.script(address, calldata)?; + let script_result = runner.script(address, calldata.0.into())?; result.success &= script_result.success; result.gas_used = script_result.gas_used; @@ -127,7 +129,7 @@ impl ScriptArgs { abi, code, }; - return Some((*addr, info)) + return Some(((*addr).to_alloy(), info)) } None }) @@ -136,78 +138,81 @@ impl ScriptArgs { let mut final_txs = VecDeque::new(); // Executes all transactions from the different forks concurrently. - let futs = transactions - .into_iter() - .map(|transaction| async { - let mut runner = runners - .get(transaction.rpc.as_ref().expect("to have been filled already.")) - .expect("to have been built.") - .write(); - - if let TypedTransaction::Legacy(mut tx) = transaction.transaction { - let result = runner + let futs = + transactions + .into_iter() + .map(|transaction| async { + let mut runner = runners + .get(transaction.rpc.as_ref().expect("to have been filled already.")) + .expect("to have been built.") + .write(); + + if let TypedTransaction::Legacy(mut tx) = transaction.transaction { + let result = runner .simulate( tx.from.expect( "Transaction doesn't have a `from` address at execution time", - ), + ).to_alloy(), tx.to.clone(), - tx.data.clone(), - tx.value, + tx.data.clone().map(|b| b.0.into()), + tx.value.map(|v| v.to_alloy()), ) .expect("Internal EVM error"); - if !result.success || result.traces.is_empty() { - return Ok((None, result.traces)) - } - - let created_contracts = result - .traces - .iter() - .flat_map(|(_, traces)| { - traces.arena.iter().filter_map(|node| { - if matches!(node.kind(), CallKind::Create | CallKind::Create2) { - return Some(AdditionalContract { - opcode: node.kind(), - address: node.trace.address, - init_code: node.trace.data.to_raw(), - }) - } - None + if !result.success || result.traces.is_empty() { + return Ok((None, result.traces)) + } + + let created_contracts = result + .traces + .iter() + .flat_map(|(_, traces)| { + traces.arena.iter().filter_map(|node| { + if matches!(node.kind(), CallKind::Create | CallKind::Create2) { + return Some(AdditionalContract { + opcode: node.kind(), + address: node.trace.address.to_alloy(), + init_code: node.trace.data.to_raw(), + }) + } + None + }) }) - }) - .collect(); - - // Simulate mining the transaction if the user passes `--slow`. - if self.slow { - runner.executor.env.block.number += rU256::from(1); - } - - let is_fixed_gas_limit = tx.gas.is_some(); - // If tx.gas is already set that means it was specified in script - if !is_fixed_gas_limit { - // We inflate the gas used by the user specified percentage - tx.gas = - Some(U256::from(result.gas_used * self.gas_estimate_multiplier / 100)); + .collect(); + + // Simulate mining the transaction if the user passes `--slow`. + if self.slow { + runner.executor.env.block.number += rU256::from(1); + } + + let is_fixed_gas_limit = tx.gas.is_some(); + // If tx.gas is already set that means it was specified in script + if !is_fixed_gas_limit { + // We inflate the gas used by the user specified percentage + tx.gas = Some( + U256::from(result.gas_used * self.gas_estimate_multiplier / 100) + .to_ethers(), + ); + } else { + println!("Gas limit was set in script to {:}", tx.gas.unwrap()); + } + + let tx = TransactionWithMetadata::new( + tx.into(), + transaction.rpc, + &result, + &address_to_abi, + decoder, + created_contracts, + is_fixed_gas_limit, + )?; + + Ok((Some(tx), result.traces)) } else { - println!("Gas limit was set in script to {:}", tx.gas.unwrap()); + unreachable!() } - - let tx = TransactionWithMetadata::new( - tx.into(), - transaction.rpc, - &result, - &address_to_abi, - decoder, - created_contracts, - is_fixed_gas_limit, - )?; - - Ok((Some(tx), result.traces)) - } else { - unreachable!() - } - }) - .collect::>(); + }) + .collect::>(); let mut abort = false; for res in join_all(futs).await { @@ -262,12 +267,7 @@ impl ScriptArgs { ( rpc.clone(), - self.prepare_runner( - &mut script_config, - sender.to_ethers(), - SimulationStage::OnChain, - ) - .await, + self.prepare_runner(&mut script_config, sender, SimulationStage::OnChain).await, ) }) .collect::>(); @@ -322,10 +322,6 @@ impl ScriptArgs { }); } - ScriptRunner::new( - builder.build(env, db), - script_config.evm_opts.initial_balance.to_ethers(), - sender, - ) + ScriptRunner::new(builder.build(env, db), script_config.evm_opts.initial_balance, sender) } } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 31e62e5e8c9d0..f5281a62cde4b 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -1,19 +1,19 @@ use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; +use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueHint}; use dialoguer::Confirm; use ethers::{ abi::{Abi, Function, HumanReadableParser}, prelude::{ artifacts::{ContractBytecodeSome, Libraries}, - ArtifactId, Bytes, Project, + ArtifactId, Project, }, providers::{Http, Middleware}, signers::LocalWallet, solc::contracts::ArtifactContracts, types::{ - transaction::eip2718::TypedTransaction, Address, Chain, Log, NameOrAddress, - TransactionRequest, U256, + transaction::eip2718::TypedTransaction, Chain, Log, NameOrAddress, TransactionRequest, }, }; use eyre::{ContextCompat, Result, WrapErr}; @@ -51,7 +51,7 @@ use foundry_evm::{ DEFAULT_CREATE2_DEPLOYER, }, }; -use foundry_utils::types::ToAlloy; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; @@ -230,7 +230,9 @@ impl ScriptArgs { let mut local_identifier = LocalTraceIdentifier::new(known_contracts); let mut decoder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) + .with_labels( + result.labeled_addresses.iter().map(|(a, s)| ((*a).to_ethers(), s.clone())), + ) .with_verbosity(verbosity) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), @@ -400,13 +402,13 @@ impl ScriptArgs { match &tx.transaction { TypedTransaction::Legacy(tx) => { if tx.to.is_none() { - let sender = tx.from.expect("no sender"); + let sender = tx.from.expect("no sender").to_alloy(); if let Some(ns) = new_sender { if sender != ns { shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; return Ok(None) } - } else if sender.to_alloy() != evm_opts.sender { + } else if sender != evm_opts.sender { new_sender = Some(sender); } } @@ -433,9 +435,9 @@ impl ScriptArgs { .map(|(i, bytes)| BroadcastableTransaction { rpc: fork_url.clone(), transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(from), - data: Some(bytes.clone()), - nonce: Some(nonce + i), + from: Some(from.to_ethers()), + data: Some(bytes.clone().0.into()), + nonce: Some(nonce + U256::from(i)).map(|n| n.to_ethers()), ..Default::default() }), }) @@ -767,7 +769,7 @@ mod tests { ]); assert!(args.unlocked); - let key = U256::zero(); + let key = U256::ZERO; let args = ScriptArgs::try_parse_from([ "foundry-cli", "Contract.sol", diff --git a/crates/forge/bin/cmd/script/providers.rs b/crates/forge/bin/cmd/script/providers.rs index 93ff19a658f88..6031a76fea59d 100644 --- a/crates/forge/bin/cmd/script/providers.rs +++ b/crates/forge/bin/cmd/script/providers.rs @@ -1,7 +1,9 @@ -use ethers::prelude::{Middleware, Provider, U256}; +use alloy_primitives::U256; +use ethers::prelude::{Middleware, Provider}; use eyre::{Result, WrapErr}; use foundry_common::{get_http_provider, runtime_client::RuntimeClient, RpcUrl}; use foundry_config::Chain; +use foundry_utils::types::ToAlloy; use std::{ collections::{hash_map::Entry, HashMap}, ops::Deref, @@ -66,11 +68,19 @@ impl ProviderInfo { let gas_price = if is_legacy { GasPrice::Legacy( - provider.get_gas_price().await.wrap_err("Failed to get legacy gas price"), + provider + .get_gas_price() + .await + .wrap_err("Failed to get legacy gas price") + .map(|p| p.to_alloy()), ) } else { GasPrice::EIP1559( - provider.estimate_eip1559_fees(None).await.wrap_err("Failed to get EIP-1559 fees"), + provider + .estimate_eip1559_fees(None) + .await + .wrap_err("Failed to get EIP-1559 fees") + .map(|p| (p.0.to_alloy(), p.1.to_alloy())), ) }; diff --git a/crates/forge/bin/cmd/script/receipts.rs b/crates/forge/bin/cmd/script/receipts.rs index 57b531caf9f94..f09329c35c9cf 100644 --- a/crates/forge/bin/cmd/script/receipts.rs +++ b/crates/forge/bin/cmd/script/receipts.rs @@ -1,12 +1,10 @@ use super::sequence::ScriptSequence; -use ethers::{ - prelude::{PendingTransaction, TxHash}, - providers::Middleware, - types::TransactionReceipt, -}; +use alloy_primitives::TxHash; +use ethers::{prelude::PendingTransaction, providers::Middleware, types::TransactionReceipt}; use eyre::Result; use foundry_cli::{init_progress, update_progress, utils::print_receipt}; use foundry_common::RetryProvider; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::StreamExt; use std::sync::Arc; use tracing::{trace, warn}; @@ -87,7 +85,7 @@ pub async fn clear_pendings( } Ok(TxStatus::Success(receipt)) => { trace!(tx_hash = ?tx_hash, "received tx receipt"); - deployment_sequence.remove_pending(receipt.transaction_hash); + deployment_sequence.remove_pending(receipt.transaction_hash.to_alloy()); receipts.push(receipt); } Ok(TxStatus::Revert(receipt)) => { @@ -95,7 +93,7 @@ pub async fn clear_pendings( // if this is not removed from pending, then the script becomes // un-resumable. Is this desirable on reverts? warn!(tx_hash = ?tx_hash, "Transaction Failure"); - deployment_sequence.remove_pending(receipt.transaction_hash); + deployment_sequence.remove_pending(receipt.transaction_hash.to_alloy()); errors.push(format!("Transaction Failure: {:?}", receipt.transaction_hash)); } } @@ -136,14 +134,14 @@ async fn check_tx_status( // still neatly return the tuple let result = async move { // First check if there's a receipt - let receipt_opt = provider.get_transaction_receipt(hash).await?; + let receipt_opt = provider.get_transaction_receipt(hash.to_ethers()).await?; if let Some(receipt) = receipt_opt { return Ok(receipt.into()) } // If the tx is present in the mempool, run the pending tx future, and // assume the next drop is really really real - let pending_res = PendingTransaction::new(hash, provider).await?; + let pending_res = PendingTransaction::new(hash.to_ethers(), provider).await?; match pending_res { Some(receipt) => Ok(receipt.into()), None => Ok(TxStatus::Dropped), diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 56592a92c4944..1d42dc4676678 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -1,16 +1,13 @@ use super::*; -use ethers::types::{Address, Bytes, NameOrAddress, U256}; +use alloy_primitives::{Address, Bytes, U256}; +use ethers::types::NameOrAddress; use eyre::Result; use forge::{ executor::{CallResult, DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, - revm::{ - interpreter::{return_ok, InstructionResult}, - primitives::U256 as rU256, - }, + revm::interpreter::{return_ok, InstructionResult}, trace::{TraceKind, Traces}, CALLER, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use tracing::log::trace; /// Represents which simulation stage is the script execution at. @@ -45,9 +42,9 @@ impl ScriptRunner { trace!(target: "script", "executing setUP()"); if !is_broadcast { - if self.sender == Config::DEFAULT_SENDER { + if self.sender == Config::DEFAULT_SENDER.to_alloy() { // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(self.sender.to_alloy(), rU256::MAX)?; + self.executor.set_balance(self.sender, U256::MAX)?; } if need_create2_deployer { @@ -55,10 +52,10 @@ impl ScriptRunner { } } - self.executor.set_nonce(self.sender.to_alloy(), sender_nonce.as_u64())?; + self.executor.set_nonce(self.sender, sender_nonce.to())?; // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(CALLER, rU256::MAX)?; + self.executor.set_balance(CALLER, U256::MAX)?; // Deploy libraries let mut traces: Traces = libraries @@ -66,7 +63,7 @@ impl ScriptRunner { .filter_map(|code| { let DeployResult { traces, .. } = self .executor - .deploy(self.sender.to_alloy(), code.0.clone().into(), rU256::ZERO, None) + .deploy(self.sender, code.0.clone().into(), U256::ZERO, None) .expect("couldn't deploy library"); traces @@ -83,11 +80,11 @@ impl ScriptRunner { .. } = self .executor - .deploy(CALLER, code.0.into(), rU256::ZERO, None) + .deploy(CALLER, code.0.into(), U256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy script:\n{}", err))?; traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); - self.executor.set_balance(address, self.initial_balance.to_alloy())?; + self.executor.set_balance(address, self.initial_balance)?; // Optionally call the `setUp` function let (success, gas_used, labeled_addresses, transactions, debug, script_wallets) = if !setup @@ -102,7 +99,7 @@ impl ScriptRunner { vec![], ) } else { - match self.executor.setup(Some(self.sender.to_alloy()), address) { + match self.executor.setup(Some(self.sender), address) { Ok(CallResult { reverted, traces: setup_traces, @@ -159,14 +156,14 @@ impl ScriptRunner { }; Ok(( - address.to_ethers(), + address, ScriptResult { returned: bytes::Bytes::new(), success, gas_used, labeled_addresses: labeled_addresses .into_iter() - .map(|l| (l.0.to_ethers(), l.1)) + .map(|l| (l.0, l.1)) .collect::>(), transactions, logs, @@ -190,8 +187,8 @@ impl ScriptRunner { if let Some(cheatcodes) = &self.executor.inspector.cheatcodes { if !cheatcodes.corrected_nonce { self.executor.set_nonce( - self.sender.to_alloy(), - sender_initial_nonce.as_u64() + libraries_len as u64, + self.sender, + sender_initial_nonce.to::() + libraries_len as u64, )?; } self.executor.inspector.cheatcodes.as_mut().unwrap().corrected_nonce = false; @@ -201,7 +198,7 @@ impl ScriptRunner { /// Executes the method that will collect all broadcastable transactions. pub fn script(&mut self, address: Address, calldata: Bytes) -> Result { - self.call(self.sender, address, calldata, U256::zero(), false) + self.call(self.sender, address, calldata, U256::ZERO, false) } /// Runs a broadcastable transaction locally and persists its state. @@ -213,29 +210,35 @@ impl ScriptRunner { value: Option, ) -> Result { if let Some(NameOrAddress::Address(to)) = to { - self.call(from, to, calldata.unwrap_or_default(), value.unwrap_or(U256::zero()), true) + self.call( + from, + to.to_alloy(), + calldata.unwrap_or_default(), + value.unwrap_or(U256::ZERO), + true, + ) } else if to.is_none() { let (address, gas_used, logs, traces, debug) = match self.executor.deploy( - from.to_alloy(), + from, calldata.expect("No data for create transaction").0.into(), - value.unwrap_or(U256::zero()).to_alloy(), + value.unwrap_or(U256::ZERO), None, ) { Ok(DeployResult { address, gas_used, logs, traces, debug, .. }) => { - (address.to_ethers(), gas_used, logs, traces, debug) + (address, gas_used, logs, traces, debug) } Err(EvmError::Execution(err)) => { let ExecutionErr { reason, traces, gas_used, logs, debug, .. } = *err; println!("{}", Paint::red(format!("\nFailed with `{reason}`:\n"))); - (Address::zero(), gas_used, logs, traces, debug) + (Address::ZERO, gas_used, logs, traces, debug) } Err(e) => eyre::bail!("Failed deploying contract: {e:?}"), }; Ok(ScriptResult { returned: bytes::Bytes::new(), - success: address != Address::zero(), + success: address != Address::ZERO, gas_used, logs, traces: traces @@ -268,12 +271,7 @@ impl ScriptRunner { value: U256, commit: bool, ) -> Result { - let mut res = self.executor.call_raw( - from.to_alloy(), - to.to_alloy(), - calldata.0.clone().into(), - value.to_alloy(), - )?; + let mut res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; let mut gas_used = res.gas_used; // We should only need to calculate realistic gas costs when preparing to broadcast @@ -283,12 +281,7 @@ impl ScriptRunner { // Otherwise don't re-execute, or some usecases might be broken: https://github.com/foundry-rs/foundry/issues/3921 if commit { gas_used = self.search_optimal_gas_usage(&res, from, to, &calldata, value)?; - res = self.executor.call_raw_committing( - from.to_alloy(), - to.to_alloy(), - calldata.0.into(), - value.to_alloy(), - )?; + res = self.executor.call_raw_committing(from, to, calldata.0.into(), value)?; } let RawCallResult { @@ -317,7 +310,7 @@ impl ScriptRunner { }) .unwrap_or_default(), debug: vec![debug].into_iter().collect(), - labeled_addresses: labels.into_iter().map(|l| (l.0.to_ethers(), l.1)).collect(), + labeled_addresses: labels, transactions, address: None, script_wallets, @@ -350,12 +343,7 @@ impl ScriptRunner { while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; self.executor.env.tx.gas_limit = mid_gas_limit; - let res = self.executor.call_raw( - from.to_alloy(), - to.to_alloy(), - calldata.0.clone().into(), - value.to_alloy(), - )?; + let res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; match res.exit_reason { InstructionResult::Revert | InstructionResult::OutOfGas | diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 0c9d0ad20bde3..90b7f75f400df 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -7,15 +7,16 @@ use crate::cmd::{ }, verify::provider::VerificationProviderType, }; +use alloy_primitives::{Address, TxHash}; use ethers::{ - abi::Address, - prelude::{artifacts::Libraries, ArtifactId, TransactionReceipt, TxHash}, + prelude::{artifacts::Libraries, ArtifactId, TransactionReceipt}, types::transaction::eip2718::TypedTransaction, }; use eyre::{ContextCompat, Result, WrapErr}; use foundry_cli::utils::now; use foundry_common::{fs, shell, SELECTOR_LEN}; use foundry_config::Config; +use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; use std::{ collections::{HashMap, VecDeque}, @@ -275,13 +276,13 @@ impl ScriptSequence { let mut offset = 0; if tx.is_create2() { - receipt.contract_address = tx.contract_address; + receipt.contract_address = tx.contract_address.map(|a| a.to_ethers()); offset = 32; } // Verify contract created directly from the transaction if let (Some(address), Some(data)) = - (receipt.contract_address, tx.typed_tx().data()) + (receipt.contract_address.map(|h| h.to_alloy()), tx.typed_tx().data()) { match verify.get_verify_args(address, offset, &data.0, &self.libraries) { Some(verify) => future_verifications.push(verify.run()), diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 9b31c9cce118d..a6d0822ea7144 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -1,16 +1,12 @@ use super::{artifacts::ArtifactInfo, ScriptResult}; -use ethers::{ - abi, - abi::Address, - prelude::{NameOrAddress, H256 as TxHash}, - types::transaction::eip2718::TypedTransaction, -}; +use alloy_primitives::{Address, B256}; +use ethers::{abi, prelude::NameOrAddress, types::transaction::eip2718::TypedTransaction}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{abi::format_token_raw, RpcUrl, SELECTOR_LEN}; use foundry_evm::{ executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::CallTraceDecoder, CallKind, }; -use foundry_utils::types::ToAlloy; +use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use tracing::error; @@ -29,7 +25,7 @@ pub struct AdditionalContract { #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[serde(rename_all = "camelCase")] pub struct TransactionWithMetadata { - pub hash: Option, + pub hash: Option, #[serde(rename = "transactionType")] pub opcode: CallKind, #[serde(default = "default_string")] @@ -52,7 +48,7 @@ fn default_string() -> Option { } fn default_address() -> Option
{ - Some(Address::zero()) + Some(Address::ZERO) } fn default_vec_of_strings() -> Option> { @@ -86,7 +82,7 @@ impl TransactionWithMetadata { )?; } else { metadata - .set_call(to, local_contracts, decoder) + .set_call(to.to_alloy(), local_contracts, decoder) .wrap_err("Could not decode transaction type.")?; } } else if metadata.transaction.to().is_none() { @@ -234,7 +230,7 @@ impl TransactionWithMetadata { .get(&data.0[..SELECTOR_LEN]) .map(|functions| functions.first()) { - self.contract_name = decoder.contracts.get(&target).cloned(); + self.contract_name = decoder.contracts.get(&target.to_ethers()).cloned(); self.function = Some(function.signature()); self.arguments = Some( @@ -288,7 +284,7 @@ pub mod wrapper { where S: serde::Serializer, { - serializer.serialize_str(&to_checksum(addr, None)) + serializer.serialize_str(&to_checksum(&addr.to_ethers(), None)) } pub fn serialize_opt_addr(opt: &Option
, serializer: S) -> Result @@ -373,7 +369,7 @@ pub mod wrapper { impl From for WrappedLog { fn from(log: Log) -> Self { Self { - address: log.address, + address: log.address.to_alloy(), topics: log.topics, data: log.data, block_hash: log.block_hash, @@ -455,11 +451,11 @@ pub mod wrapper { transaction_index: receipt.transaction_index, block_hash: receipt.block_hash, block_number: receipt.block_number, - from: receipt.from, - to: receipt.to, + from: receipt.from.to_alloy(), + to: receipt.to.map(|addr| addr.to_alloy()), cumulative_gas_used: receipt.cumulative_gas_used, gas_used: receipt.gas_used, - contract_address: receipt.contract_address, + contract_address: receipt.contract_address.map(|addr| addr.to_alloy()), logs: receipt.logs, status: receipt.status, root: receipt.root, diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 1ec2a050d0458..95972f3a5a0de 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -2,10 +2,8 @@ use crate::cmd::{ retry::RetryArgs, verify::{VerifierArgs, VerifyArgs}, }; -use ethers::{ - abi::Address, - solc::{info::ContractInfo, Project}, -}; +use alloy_primitives::Address; +use ethers::solc::{info::ContractInfo, Project}; use foundry_cli::opts::{EtherscanOpts, ProjectPathsArgs}; use foundry_common::ContractsByArtifact; use foundry_config::{Chain, Config}; diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index ebc1f242cec74..cee3a66e98328 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -2,8 +2,8 @@ use super::{ test, test::{Test, TestOutcome}, }; +use alloy_primitives::U256; use clap::{builder::RangedU64ValueParser, Parser, ValueHint}; -use ethers::types::U256; use eyre::{Context, Result}; use forge::result::TestKindReport; use foundry_cli::utils::STATIC_FUZZ_SEED; @@ -98,7 +98,7 @@ impl SnapshotArgs { pub async fn run(mut self) -> Result<()> { // Set fuzz seed so gas snapshots are deterministic - self.test.fuzz_seed = Some(U256::from_big_endian(&STATIC_FUZZ_SEED)); + self.test.fuzz_seed = Some(U256::from_be_bytes(STATIC_FUZZ_SEED)); let outcome = self.test.execute_tests().await?; outcome.ensure_ok()?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 90d6ce2cf1a5e..4ebe9d634cd29 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -1,6 +1,6 @@ use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; +use alloy_primitives::U256; use clap::Parser; -use ethers::types::U256; use eyre::Result; use forge::{ decode::decode_console_logs, @@ -33,7 +33,6 @@ use foundry_config::{ }; use foundry_debugger::DebuggerArgs; use foundry_evm::fuzz::CounterExample; -use foundry_utils::types::ToEthers; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use tracing::trace; @@ -184,9 +183,9 @@ impl TestArgs { let mut runner_builder = MultiContractRunnerBuilder::default() .set_debug(should_debug) - .initial_balance(evm_opts.initial_balance.to_ethers()) + .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) - .sender(evm_opts.sender.to_ethers()) + .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) .with_test_options(test_options.clone()); diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index b0d5edbe4e16e..474aa2636e04c 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -15,7 +15,7 @@ use eyre::{eyre, Context, Result}; use foundry_cli::utils::{get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; use foundry_common::abi::encode_args; use foundry_config::{Chain, Config, SolcReq}; -use foundry_utils::Retry; +use foundry_utils::{types::ToEthers, Retry}; use futures::FutureExt; use once_cell::sync::Lazy; use regex::Regex; @@ -119,7 +119,7 @@ impl VerificationProvider for EtherscanVerificationProvider { {}", resp.message, resp.result, - etherscan.address_url(args.address) + etherscan.address_url(args.address.to_ethers()) ); if args.watch { @@ -312,7 +312,7 @@ impl EtherscanVerificationProvider { let compiler_version = format!("v{}", ensure_solc_build_metadata(compiler_version).await?); let constructor_args = self.constructor_args(args, &project)?; let mut verify_args = - VerifyContract::new(args.address, contract_name, source, compiler_version) + VerifyContract::new(args.address.to_ethers(), contract_name, source, compiler_version) .constructor_arguments(constructor_args) .code_format(code_format); diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index bd17d1418b9b7..bbdbe42a5ac0f 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -1,6 +1,7 @@ use super::retry::RetryArgs; +use alloy_primitives::Address; use clap::{Parser, ValueHint}; -use ethers::{abi::Address, solc::info::ContractInfo}; +use ethers::solc::info::ContractInfo; use eyre::Result; use foundry_cli::{opts::EtherscanOpts, utils::LoadConfig}; use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config}; diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index 30a5139ba61ad..aae526e827800 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -1,6 +1,6 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use async_trait::async_trait; -use ethers::{solc::ConfigurableContractArtifact, utils::to_checksum}; +use ethers::solc::ConfigurableContractArtifact; use eyre::Result; use foundry_cli::utils::{get_cached_entry_by_name, LoadConfig}; use foundry_common::fs; @@ -38,7 +38,7 @@ impl VerificationProvider for SourcifyVerificationProvider { println!( "\nSubmitting verification for [{}] {:?}.", args.contract.name, - to_checksum(&args.address, None) + args.address.to_checksum(None) ); let response = client .post(args.verifier.verifier_url.as_deref().unwrap_or(SOURCIFY_URL)) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index e126467d0e4ea..4c9bf65c3ac30 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,9 +1,9 @@ use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; +use alloy_primitives::{Address, Bytes, U256}; use ethers::{ abi::{Abi, Function}, prelude::{artifacts::CompactContractBytecode, ArtifactId, ArtifactOutput}, solc::{contracts::ArtifactContracts, Artifact, ProjectCompileOutput}, - types::{Address, Bytes, U256}, }; use eyre::Result; use foundry_common::{ContractsByArtifact, TestFunctionExt}; @@ -202,15 +202,16 @@ impl MultiContractRunner { filter: impl TestFilter, test_options: TestOptions, ) -> SuiteResult { + let libs = libs.iter().map(|l| l.0.clone().into()).collect::>(); let runner = ContractRunner::new( name, executor, contract, - deploy_code, + deploy_code.0.into(), self.evm_opts.initial_balance.to_ethers(), - self.sender, + self.sender.map(|a| a.to_ethers()), self.errors.as_ref(), - libs, + &libs, self.debug, ); runner.run_tests(filter, test_options, Some(&self.known_contracts)) @@ -285,8 +286,8 @@ impl MultiContractRunnerBuilder { ArtifactContracts::from_iter(contracts), &mut known_contracts, Default::default(), - evm_opts.sender.to_ethers(), - U256::one(), + evm_opts.sender, + U256::from(1), &mut deployable_contracts, |post_link_input| { let PostLinkInput { @@ -318,8 +319,11 @@ impl MultiContractRunnerBuilder { id.clone(), ( abi.clone(), - bytecode, - dependencies.into_iter().map(|dep| dep.bytecode).collect::>(), + bytecode.0.into(), + dependencies + .into_iter() + .map(|dep| dep.bytecode.0.into()) + .collect::>(), ), ); } diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 473ea33260a84..da56c326ba103 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -14,7 +14,7 @@ use foundry_config::{ use foundry_evm::{ decode::decode_console_logs, executor::inspector::CheatsConfig, revm::primitives::SpecId, }; -use foundry_utils::types::ToEthers; +use foundry_utils::types::ToAlloy; use std::{ collections::BTreeMap, path::{Path, PathBuf}, @@ -144,7 +144,7 @@ pub fn manifest_root() -> PathBuf { /// Builds a base runner pub fn base_runner() -> MultiContractRunnerBuilder { - MultiContractRunnerBuilder::default().sender(EVM_OPTS.sender.to_ethers()) + MultiContractRunnerBuilder::default().sender(EVM_OPTS.sender) } /// Builds a non-tracing runner @@ -161,7 +161,7 @@ pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { base_runner() .with_cheats_config(CheatsConfig::new(&config, &EVM_OPTS)) - .sender(config.sender) + .sender(config.sender.to_alloy()) .build( &PROJECT.paths.root, (*COMPILED).clone(), diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 458fdaaea7bc0..a12c8efdb28d1 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -1,8 +1,9 @@ #![doc = include_str!("../README.md")] #![warn(unused_crate_dependencies)] +use alloy_primitives::{Address, Bytes, U256}; use ethers_addressbook::contract; -use ethers_core::types::*; +use ethers_core::types::{BlockId, Chain, NameOrAddress}; use ethers_providers::{Middleware, Provider}; use ethers_solc::{ artifacts::{BytecodeObject, CompactBytecode, CompactContractBytecode, Libraries}, @@ -21,6 +22,8 @@ use std::{ }; use tracing::trace; +use crate::types::{ToAlloy, ToEthers}; + pub mod abi; pub mod error; pub mod glob; @@ -136,6 +139,7 @@ impl std::fmt::Display for ResolvedDependency { /// /// For an example of this, see [here](https://github.com/foundry-rs/foundry/blob/2308972dbc3a89c03488a05aceb3c428bb3e08c0/cli/src/cmd/forge/script/build.rs#L130-L151C9). #[allow(clippy::too_many_arguments)] + pub fn link_with_nonce_or_address( contracts: ArtifactContracts, known_contracts: &mut BTreeMap, @@ -378,7 +382,7 @@ fn recurse_link<'a>( id: library, address: *deployed_address, nonce: *cached_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!( "Bytecode should be linked for {next_target}")), + bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!( "Bytecode should be linked for {next_target}")).0.into(), }); *deployed_address } else { @@ -386,27 +390,27 @@ fn recurse_link<'a>( // we need to deploy the library let used_nonce = *nonce; - let computed_address = ethers_core::utils::get_contract_address(sender, used_nonce); - *nonce += 1.into(); + let computed_address = ethers_core::utils::get_contract_address(sender.to_ethers(), used_nonce.to_ethers()); + *nonce += U256::from(1); let library = format!("{file}:{key}:0x{}", hex::encode(computed_address)); // push the dependency into the library deployment vector deployment.push(ResolvedDependency { id: library, - address: computed_address, + address: computed_address.to_alloy(), nonce: used_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!( "Bytecode should be linked for {next_target}")), + bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!( "Bytecode should be linked for {next_target}")).0.into(), }); // remember this library for later - internally_deployed_libraries.insert(format!("{file}:{key}"), (used_nonce, computed_address)); + internally_deployed_libraries.insert(format!("{file}:{key}"), (used_nonce, computed_address.to_alloy())); - computed_address + computed_address.to_alloy() }; // link the dependency to the target - target_bytecode.0.link(file.clone(), key.clone(), address); - target_bytecode.1.link(file.clone(), key.clone(), address); + target_bytecode.0.link(file.clone(), key.clone(), address.to_ethers()); + target_bytecode.1.link(file.clone(), key.clone(), address.to_ethers()); trace!(target : "forge::link", ?target, dependency = next_target, file, key, "linking dependency done"); }); } @@ -525,7 +529,7 @@ pub async fn next_nonce( ) -> Result { let provider = Provider::try_from(provider_url) .wrap_err_with(|| format!("Bad fork_url provider: {provider_url}"))?; - Ok(provider.get_transaction_count(caller, block).await?) + Ok(provider.get_transaction_count(caller.to_ethers(), block).await?).map(|n| n.to_alloy()) } #[cfg(test)] @@ -580,7 +584,7 @@ mod tests { self.contracts, &mut ContractsByArtifact::default(), Default::default(), - sender, + sender.to_alloy(), initial_nonce, &mut called_once, |post_link_input| { @@ -610,7 +614,7 @@ mod tests { let expected_lib_id = format!("{}:{:?}", expected.0, expected.2); assert_eq!(expected_lib_id, actual.id, "unexpected dependency, expected: {}, got: {}", expected_lib_id, actual.id); assert_eq!(actual.nonce, expected.1, "nonce wrong for dependency, expected: {}, got: {}", expected.1, actual.nonce); - assert_eq!(actual.address, expected.2, "address wrong for dependency, expected: {}, got: {}", expected.2, actual.address); + assert_eq!(actual.address.to_ethers(), expected.2, "address wrong for dependency, expected: {}, got: {}", expected.2, actual.address); } Ok(()) @@ -631,7 +635,7 @@ mod tests { "simple/Simple.t.sol:LibraryConsumer".to_string(), vec![( "simple/Simple.t.sol:Lib".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -639,11 +643,11 @@ mod tests { "simple/Simple.t.sol:SimpleLibraryLinkingTest".to_string(), vec![( "simple/Simple.t.sol:Lib".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) - .test_with_sender_and_nonce(Address::default(), U256::one()); + .test_with_sender_and_nonce(Address::default(), U256::from(1)); } #[test] @@ -654,7 +658,7 @@ mod tests { "nested/Nested.t.sol:NestedLib".to_string(), vec![( "nested/Nested.t.sol:Lib".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -665,12 +669,12 @@ mod tests { // have the same address and nonce. ( "nested/Nested.t.sol:Lib".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "nested/Nested.t.sol:Lib".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -685,12 +689,12 @@ mod tests { vec![ ( "nested/Nested.t.sol:Lib".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "nested/Nested.t.sol:Lib".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -700,7 +704,7 @@ mod tests { ), ], ) - .test_with_sender_and_nonce(Address::default(), U256::one()); + .test_with_sender_and_nonce(Address::default(), U256::from(1)); } /// This test ensures that complicated setups with many libraries, some of which are referenced @@ -723,7 +727,7 @@ mod tests { "duplicate/Duplicate.t.sol:C".to_string(), vec![( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -731,7 +735,7 @@ mod tests { "duplicate/Duplicate.t.sol:D".to_string(), vec![( "duplicate/Duplicate.t.sol:B".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -740,7 +744,7 @@ mod tests { vec![ ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -755,7 +759,7 @@ mod tests { vec![ ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -765,7 +769,7 @@ mod tests { ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -785,7 +789,7 @@ mod tests { ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -805,7 +809,7 @@ mod tests { vec![ ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -815,7 +819,7 @@ mod tests { ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -835,7 +839,7 @@ mod tests { ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::one(), + U256::from(1), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( @@ -850,7 +854,7 @@ mod tests { ), ], ) - .test_with_sender_and_nonce(Address::default(), U256::one()); + .test_with_sender_and_nonce(Address::default(), U256::from(1)); } #[test] From a91869fb53eddce8c000bffe9cceeb9853604d28 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 22 Sep 2023 13:49:59 -0400 Subject: [PATCH 0098/1963] chore(deps): bump revm to accomodate latest changes (#5877) * chore: update revm to accomodate latest changes * chore: remove debug info, point latest to berlin * chore: remove sparklend (will re-add as separate job) --- Cargo.lock | 10 ++++------ crates/anvil/src/eth/backend/mem/mod.rs | 14 ++++++++++---- crates/anvil/src/eth/error.rs | 17 +++++++++++++---- crates/debugger/src/lib.rs | 2 +- crates/evm/src/debug.rs | 2 +- crates/evm/src/executor/backend/mod.rs | 19 ++++++++++++++++++- .../executor/inspector/cheatcodes/mapping.rs | 6 +++--- .../src/executor/inspector/cheatcodes/mod.rs | 3 ++- crates/forge/tests/cli/ext_integration.rs | 1 - 9 files changed, 52 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 264b041955868..1140ce6999fb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5532,7 +5532,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" dependencies = [ "auto_impl", "revm-interpreter", @@ -5544,7 +5544,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" dependencies = [ "derive_more", "enumn", @@ -5555,10 +5555,9 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" dependencies = [ "c-kzg", - "hex", "k256", "num", "once_cell", @@ -5572,7 +5571,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#04395590d58de5351057f51cb84b6172f83f0e7f" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -5585,7 +5584,6 @@ dependencies = [ "enumn", "hashbrown 0.14.0", "hex", - "hex-literal", "once_cell", "primitive-types", "serde", diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 2cd1cf35de3a1..ae9ac2656281d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -67,8 +67,8 @@ use foundry_evm::{ db::CacheDB, interpreter::{return_ok, InstructionResult}, primitives::{ - Account, BlockEnv, CreateScheme, EVMError, Env, ExecutionResult, Output, SpecId, - TransactTo, TxEnv, KECCAK_EMPTY, + Account, BlockEnv, CreateScheme, EVMError, Env, ExecutionResult, InvalidHeader, Output, + SpecId, TransactTo, TxEnv, KECCAK_EMPTY, }, }, utils::{eval_to_instruction_result, halt_to_instruction_result, u256_to_h256_be}, @@ -1066,9 +1066,15 @@ impl Backend { EVMError::Transaction(invalid_tx) => { return Err(BlockchainError::InvalidTransaction(invalid_tx.into())) } - EVMError::PrevrandaoNotSet => return Err(BlockchainError::PrevrandaoNotSet), EVMError::Database(e) => return Err(BlockchainError::DatabaseError(e)), - EVMError::ExcessBlobGasNotSet => return Err(BlockchainError::ExcessBlobGasNotSet), + EVMError::Header(e) => match e { + InvalidHeader::ExcessBlobGasNotSet => { + return Err(BlockchainError::ExcessBlobGasNotSet) + } + InvalidHeader::PrevrandaoNotSet => { + return Err(BlockchainError::PrevrandaoNotSet) + } + }, }, }; let state = result_and_state.state; diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 6be7ae5e72876..3fa9e6c732d35 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -14,7 +14,11 @@ use ethers::{ use foundry_common::SELECTOR_LEN; use foundry_evm::{ executor::backend::DatabaseError, - revm::{self, interpreter::InstructionResult, primitives::EVMError}, + revm::{ + self, + interpreter::InstructionResult, + primitives::{EVMError, InvalidHeader}, + }, }; use serde::Serialize; use tracing::error; @@ -98,9 +102,11 @@ where fn from(err: EVMError) -> Self { match err { EVMError::Transaction(err) => InvalidTransactionError::from(err).into(), - EVMError::PrevrandaoNotSet => BlockchainError::PrevrandaoNotSet, + EVMError::Header(err) => match err { + InvalidHeader::ExcessBlobGasNotSet => BlockchainError::ExcessBlobGasNotSet, + InvalidHeader::PrevrandaoNotSet => BlockchainError::PrevrandaoNotSet, + }, EVMError::Database(err) => err.into(), - EVMError::ExcessBlobGasNotSet => BlockchainError::ExcessBlobGasNotSet, } } } @@ -205,7 +211,7 @@ impl From for InvalidTransactionError { use revm::primitives::InvalidTransaction; match err { InvalidTransaction::InvalidChainId => InvalidTransactionError::InvalidChainId, - InvalidTransaction::GasMaxFeeGreaterThanPriorityFee => { + InvalidTransaction::PriorityFeeGreaterThanMaxFee => { InvalidTransactionError::TipAboveFeeCap } InvalidTransaction::GasPriceLessThanBasefee => InvalidTransactionError::FeeCapTooLow, @@ -246,6 +252,9 @@ impl From for InvalidTransactionError { InvalidTransaction::MaxFeePerBlobGasNotSupported => { InvalidTransactionError::MaxFeePerBlobGasNotSupported } + // TODO: Blob-related errors should be handled once the Reth migration is done and code + // is moved over. + _ => todo!(), } } } diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 723b78e94f271..5a72342e9cd47 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -869,7 +869,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k ) { let memory = &debug_steps[current_step].memory; let stack_space = Block::default() - .title(format!("Memory (max expansion: {} bytes)", memory.effective_len())) + .title(format!("Memory (max expansion: {} bytes)", memory.len())) .borders(Borders::ALL); let memory = memory.data(); let max_i = memory.len() / 32; diff --git a/crates/evm/src/debug.rs b/crates/evm/src/debug.rs index 6fa9c00dafe23..be6252109e72c 100644 --- a/crates/evm/src/debug.rs +++ b/crates/evm/src/debug.rs @@ -170,7 +170,7 @@ impl Display for Instruction { Instruction::OpCode(op) => write!( f, "{}", - OpCode::try_from_u8(*op).map_or_else( + OpCode::new(*op).map_or_else( || format!("UNDEFINED(0x{op:02x})"), |opcode| opcode.as_str().to_string(), ) diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index 11dee7b3c8d7e..f2751643df9f5 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -1661,7 +1661,24 @@ impl BackendInner { /// Returns a new, empty, `JournaledState` with set precompiles pub fn new_journaled_state(&self) -> JournaledState { - JournaledState::new(self.precompiles().len()) + /// Helper function to convert from a `revm::precompile::SpecId` into a + /// `revm::primitives::SpecId` This only matters if the spec is Cancun or later, or + /// pre-Spurious Dragon. + fn precompiles_spec_id_to_primitives_spec_id(spec: SpecId) -> revm::primitives::SpecId { + match spec { + SpecId::HOMESTEAD => revm::primitives::SpecId::HOMESTEAD, + SpecId::BYZANTIUM => revm::primitives::SpecId::BYZANTIUM, + SpecId::ISTANBUL => revm::primitives::ISTANBUL, + SpecId::BERLIN => revm::primitives::BERLIN, + SpecId::CANCUN => revm::primitives::CANCUN, + // Point latest to berlin for now, as we don't wanna accidentally point to Cancun. + SpecId::LATEST => revm::primitives::BERLIN, + } + } + JournaledState::new( + self.precompiles().len(), + precompiles_spec_id_to_primitives_spec_id(self.precompile_id), + ) } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index dd041075ae568..777d503813f12 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -96,9 +96,9 @@ pub fn on_evm_step( if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) { let address = interpreter.contract.address; let offset = interpreter.stack.peek(0).expect("stack size > 1").to::(); - let low = U256::from(interpreter.memory.get_slice(offset, 0x20)); - let high = U256::from(interpreter.memory.get_slice(offset + 0x20, 0x20)); - let result = U256::from(keccak256(interpreter.memory.get_slice(offset, 0x40))); + let low = U256::from(interpreter.memory.slice(offset, 0x20)); + let high = U256::from(interpreter.memory.slice(offset + 0x20, 0x20)); + let result = U256::from(keccak256(interpreter.memory.slice(offset, 0x40))); mapping_slots .entry(address.to_ethers()) diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index dde13e5e35c68..fdc595a4b6d82 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -1177,6 +1177,7 @@ mod revert_helper { let starting_offset = interpreter.memory.len(); interpreter.memory.resize(starting_offset + bytes.len()); interpreter.memory.set_data(starting_offset, 0, bytes.len(), &bytes); - interpreter.return_range = starting_offset..interpreter.memory.len(); + interpreter.return_offset = starting_offset; + interpreter.return_len = interpreter.memory.len() - starting_offset } } diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 08edac73ec614..049d8eca35c5a 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -24,4 +24,3 @@ forgetest_external!( ); forgetest_external!(gunilev, "hexonaut/guni-lev", 13633752); forgetest_external!(convex, "mds1/convex-shutdown-simulation", 14445961); -forgetest_external!(sparklend, "marsfoundation/sparklend"); From 26b668e301050f8be8593032dcd6e54f1ef13399 Mon Sep 17 00:00:00 2001 From: Trevor Johnson <27569194+trevorgjohnson@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:10:17 -0500 Subject: [PATCH 0099/1963] chore(test): ensure decoder building occurs only when --debug is present (#5879) Co-authored-by: Enrique Ortiz --- crates/forge/bin/cmd/test/mod.rs | 112 ++++++++++++++++--------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 4ebe9d634cd29..3eca31ebfcd76 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -226,69 +226,71 @@ impl TestArgs { let outcome = self .run_tests(runner, config.clone(), verbosity, filter.clone(), test_options.clone()) .await?; - let tests = outcome.clone().into_tests(); - let mut decoded_traces = Vec::new(); - let mut decoders = Vec::new(); - for test in tests { - let mut result = test.result; - // Identify addresses in each trace - let mut builder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.clone()) - .with_events(local_identifier.events().cloned()) - .with_verbosity(verbosity); - - // Signatures are of no value for gas reports - if !self.gas_report { - let sig_identifier = - SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; - builder = builder.with_signature_identifier(sig_identifier.clone()); - } - - let mut decoder = builder.build(); + if should_debug { + let tests = outcome.clone().into_tests(); + + let mut decoded_traces = Vec::new(); + let mut decoders = Vec::new(); + for test in tests { + let mut result = test.result; + // Identify addresses in each trace + let mut builder = CallTraceDecoderBuilder::new() + .with_labels(result.labeled_addresses.clone()) + .with_events(local_identifier.events().cloned()) + .with_verbosity(verbosity); + + // Signatures are of no value for gas reports + if !self.gas_report { + let sig_identifier = + SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; + builder = builder.with_signature_identifier(sig_identifier.clone()); + } - if !result.traces.is_empty() { - // Set up identifiers - // Do not re-query etherscan for contracts that you've already queried today. - let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; - - // Decode the traces - for (kind, trace) in &mut result.traces { - decoder.identify(trace, &mut local_identifier); - decoder.identify(trace, &mut etherscan_identifier); - - let should_include = match kind { - // At verbosity level 3, we only display traces for failed tests - // At verbosity level 4, we also display the setup trace for failed - // tests At verbosity level 5, we display - // all traces for all tests - TraceKind::Setup => { - (verbosity >= 5) || - (verbosity == 4 && result.status == TestStatus::Failure) - } - TraceKind::Execution => { - verbosity > 3 || - (verbosity == 3 && result.status == TestStatus::Failure) + let mut decoder = builder.build(); + + if !result.traces.is_empty() { + // Set up identifiers + // Do not re-query etherscan for contracts that you've already queried today. + let mut etherscan_identifier = + EtherscanIdentifier::new(&config, remote_chain_id)?; + + // Decode the traces + for (kind, trace) in &mut result.traces { + decoder.identify(trace, &mut local_identifier); + decoder.identify(trace, &mut etherscan_identifier); + + let should_include = match kind { + // At verbosity level 3, we only display traces for failed tests + // At verbosity level 4, we also display the setup trace for failed + // tests At verbosity level 5, we display + // all traces for all tests + TraceKind::Setup => { + (verbosity >= 5) || + (verbosity == 4 && result.status == TestStatus::Failure) + } + TraceKind::Execution => { + verbosity > 3 || + (verbosity == 3 && result.status == TestStatus::Failure) + } + _ => false, + }; + + // We decode the trace if we either need to build a gas report or we need + // to print it + if should_include || self.gas_report { + decoder.decode(trace).await; } - _ => false, - }; - - // We decode the trace if we either need to build a gas report or we need - // to print it - if should_include || self.gas_report { - decoder.decode(trace).await; - } - if should_include { - decoded_traces.push(trace.to_string()); + if should_include { + decoded_traces.push(trace.to_string()); + } } } - } - decoders.push(decoder); - } + decoders.push(decoder); + } - if should_debug { let mut sources: ContractSources = Default::default(); for (id, artifact) in output.into_artifacts() { // Sources are only required for the debugger, but it *might* mean that there's From 4665d7ce4b3b572163cc04b33b4fd190e28f2c5f Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 22 Sep 2023 17:23:08 -0400 Subject: [PATCH 0100/1963] chore(forge): do not re-build decoded traces for all tests (#5880) --- crates/forge/bin/cmd/test/mod.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3eca31ebfcd76..5869679538e29 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -230,7 +230,6 @@ impl TestArgs { if should_debug { let tests = outcome.clone().into_tests(); - let mut decoded_traces = Vec::new(); let mut decoders = Vec::new(); for test in tests { let mut result = test.result; @@ -281,10 +280,6 @@ impl TestArgs { if should_include || self.gas_report { decoder.decode(trace).await; } - - if should_include { - decoded_traces.push(trace.to_string()); - } } } From 2f1a198eb7fbb565750efe57e4ba9eac524bbf21 Mon Sep 17 00:00:00 2001 From: Resende <17102689+ZePedroResende@users.noreply.github.com> Date: Sat, 23 Sep 2023 09:55:58 +0100 Subject: [PATCH 0101/1963] fix(anvil): Fix ots_blockDetails (#5881) --- crates/anvil/src/eth/otterscan/api.rs | 4 ++-- crates/anvil/src/eth/otterscan/types.rs | 10 ++++------ crates/anvil/tests/it/otterscan.rs | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index f5da4b287a78b..ee254b6ae5a3a 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -86,7 +86,7 @@ impl EthApi { pub async fn ots_get_block_details(&self, number: BlockNumber) -> Result { node_info!("ots_getBlockDetails"); - if let Some(block) = self.backend.block_by_number_full(number).await? { + if let Some(block) = self.backend.block_by_number(number).await? { let ots_block = OtsBlockDetails::build(block, &self.backend).await?; Ok(ots_block) @@ -101,7 +101,7 @@ impl EthApi { pub async fn ots_get_block_details_by_hash(&self, hash: H256) -> Result { node_info!("ots_getBlockDetailsByHash"); - if let Some(block) = self.backend.block_by_hash_full(hash).await? { + if let Some(block) = self.backend.block_by_hash(hash).await? { let ots_block = OtsBlockDetails::build(block, &self.backend).await?; Ok(ots_block) diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index e1b9fd6039f6c..d7578da765367 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -23,7 +23,7 @@ pub struct OtsBlock { #[derive(Serialize, Debug)] #[serde(rename_all = "camelCase")] pub struct OtsBlockDetails { - pub block: OtsBlock, + pub block: OtsBlock, pub total_fees: U256, pub issuance: Issuance, } @@ -121,11 +121,9 @@ impl OtsBlockDetails { /// - It breaks the abstraction built in `OtsBlock` which computes `transaction_count` /// based on the existing list. /// Therefore we keep it simple by keeping the data in the response - pub async fn build(block: Block, backend: &Backend) -> Result { - let receipts_futs = block - .transactions - .iter() - .map(|tx| async { backend.transaction_receipt(tx.hash).await }); + pub async fn build(block: Block, backend: &Backend) -> Result { + let receipts_futs = + block.transactions.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); // fetch all receipts let receipts: Vec = join_all(receipts_futs) diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index f4c4913ca7081..4c5b4ec6f2e70 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -260,7 +260,7 @@ async fn can_call_ots_get_block_details() { let result = api.ots_get_block_details(1.into()).await.unwrap(); assert_eq!(result.block.transaction_count, 1); - assert_eq!(result.block.block.transactions[0].hash, receipt.transaction_hash); + assert_eq!(result.block.block.transactions[0], receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] @@ -278,7 +278,7 @@ async fn can_call_ots_get_block_details_by_hash() { let result = api.ots_get_block_details_by_hash(block_hash).await.unwrap(); assert_eq!(result.block.transaction_count, 1); - assert_eq!(result.block.block.transactions[0].hash, receipt.transaction_hash); + assert_eq!(result.block.block.transactions[0], receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] From f6104d14371e79cbe68f06a4e9cea5bd9f35a7d4 Mon Sep 17 00:00:00 2001 From: ruvaag Date: Sat, 23 Sep 2023 16:43:44 +0530 Subject: [PATCH 0102/1963] fix: enforce 0x prefix for numeric hex strings (#5882) * fix: enforce 0x prefix for numeric hex strings * fix: add checks for signed numeric literal --- .../executor/inspector/cheatcodes/parse.rs | 45 ++++++++++++++----- testdata/repros/Issue5808.t.sol | 12 +++-- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/parse.rs b/crates/evm/src/executor/inspector/cheatcodes/parse.rs index 904a3d502574e..d956731304bb3 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/parse.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/parse.rs @@ -1,7 +1,7 @@ use super::{fmt_err, Cheatcodes, Result}; use crate::abi::HEVMCalls; use ethers::{ - abi::{ParamType, Token}, + abi::{ethereum_types::FromDecStrErr, ParamType, Token}, prelude::*, }; use foundry_macros::UIfmt; @@ -48,32 +48,53 @@ fn parse_token(s: &str, ty: &ParamType) -> Result { } fn parse_int(s: &str) -> Result { - // hex string may start with "0x", "+0x", or "-0x" which needs to be stripped for + // Only parse hex strings prefixed by 0x or decimal integer strings + + // Hex string may start with "0x", "+0x", or "-0x" which needs to be stripped for // `I256::from_hex_str` if s.starts_with("0x") || s.starts_with("+0x") || s.starts_with("-0x") { - s.replacen("0x", "", 1).parse::().map_err(|err| err.to_string()) - } else { - match I256::from_dec_str(s) { + return s + .replacen("0x", "", 1) + .parse::() + .map_err(|err| err.to_string()) + .map(|v| v.into_raw()) + } + + // Decimal string may start with '+' or '-' followed by numeric characters + if s.chars().all(|c| c.is_numeric() || c == '+' || c == '-') { + return match I256::from_dec_str(s) { Ok(val) => Ok(val), Err(dec_err) => s.parse::().map_err(|hex_err| { format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") }), } - } - .map(|v| v.into_raw()) + .map(|v| v.into_raw()) + }; + + // Throw if string doesn't conform to either of the two patterns + Err(ParseI256Error::InvalidDigit.to_string()) } fn parse_uint(s: &str) -> Result { + // Only parse hex strings prefixed by 0x or decimal numeric strings + + // Hex strings prefixed by 0x if s.starts_with("0x") { - s.parse::().map_err(|err| err.to_string()) - } else { - match U256::from_dec_str(s) { + return s.parse::().map_err(|err| err.to_string()) + }; + + // Decimal strings containing only numeric characters + if s.chars().all(|c| c.is_numeric()) { + return match U256::from_dec_str(s) { Ok(val) => Ok(val), Err(dec_err) => s.parse::().map_err(|hex_err| { format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") }), } - } + }; + + // Throw if string doesn't conform to either of the two patterns + Err(FromDecStrErr::InvalidCharacter.to_string()) } fn parse_bytes(s: &str) -> Result, String> { @@ -128,7 +149,7 @@ mod tests { let decoded = U256::decode(&parsed).unwrap(); assert_eq!(val, decoded); - let parsed = parse(pk.strip_prefix("0x").unwrap(), &ParamType::Uint(256)).unwrap(); + let parsed = parse(pk, &ParamType::Uint(256)).unwrap(); let decoded = U256::decode(&parsed).unwrap(); assert_eq!(val, decoded); diff --git a/testdata/repros/Issue5808.t.sol b/testdata/repros/Issue5808.t.sol index 2c5845a0b1bcb..b721dfa105c02 100644 --- a/testdata/repros/Issue5808.t.sol +++ b/testdata/repros/Issue5808.t.sol @@ -9,9 +9,13 @@ contract Issue5808Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testReadInt() public { - string memory json = '["ffffffff","00000010"]'; - int256[] memory ints = vm.parseJsonIntArray(json, ""); - assertEq(ints[0], 4294967295); - assertEq(ints[1], 10); + string memory str1 = '["ffffffff","00000010"]'; + vm.expectRevert(); + int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); + + string memory str2 = '["0xffffffff","0x00000010"]'; + int256[] memory ints2 = vm.parseJsonIntArray(str2, ""); + assertEq(ints2[0], 4294967295); + assertEq(ints2[1], 10); } } From 908de5e0cf9f698af8a1c412844564caff50c5d6 Mon Sep 17 00:00:00 2001 From: Devan Non <89424366+devanoneth@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:30:37 +0200 Subject: [PATCH 0103/1963] feat(anvil): reset forking can start a fork (#5834) * compiles, might not work as intended yet * edit node_config in place * make fork RwLock * return Option because it's always consumed as Option * chore: fmt * change fork_db_setup to setup_fork_db and document function * assert balance of dead address at certain block * chore: clippy * comment out new test that is failing --- crates/anvil/src/cmd.rs | 2 +- crates/anvil/src/config.rs | 366 ++++++++++++------------ crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 47 ++- crates/anvil/src/lib.rs | 2 +- crates/anvil/tests/it/fork.rs | 25 ++ 6 files changed, 254 insertions(+), 190 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 98c6b0d851570..00762c8e190f6 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -241,7 +241,7 @@ impl NodeArgs { let (api, mut handle) = crate::spawn(self.into_node_config()).await; // sets the signal handler to gracefully shutdown. - let mut fork = api.get_fork().cloned(); + let mut fork = api.get_fork(); let running = Arc::new(AtomicUsize::new(0)); // handle for the currently running rt, this must be obtained before setting the crtlc diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 60de4145c328c..d82e76678c503 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -806,183 +806,7 @@ impl NodeConfig { let (db, fork): (Arc>, Option) = if let Some(eth_rpc_url) = self.eth_rpc_url.clone() { - // TODO make provider agnostic - let provider = Arc::new( - ProviderBuilder::new(ð_rpc_url) - .timeout(self.fork_request_timeout) - .timeout_retry(self.fork_request_retries) - .initial_backoff(self.fork_retry_backoff.as_millis() as u64) - .compute_units_per_second(self.compute_units_per_second) - .max_retry(10) - .initial_backoff(1000) - .build() - .expect("Failed to establish provider to fork url"), - ); - - let (fork_block_number, fork_chain_id) = if let Some(fork_block_number) = - self.fork_block_number - { - let chain_id = if let Some(chain_id) = self.fork_chain_id { - Some(chain_id) - } else if self.hardfork.is_none() { - // auto adjust hardfork if not specified - // but only if we're forking mainnet - let chain_id = - provider.get_chainid().await.expect("Failed to fetch network chain id"); - if chain_id == ethers::types::Chain::Mainnet.into() { - let hardfork: Hardfork = fork_block_number.into(); - env.cfg.spec_id = hardfork.into(); - self.hardfork = Some(hardfork); - } - Some(chain_id) - } else { - None - }; - - (fork_block_number, chain_id) - } else { - // pick the last block number but also ensure it's not pending anymore - ( - find_latest_fork_block(&provider) - .await - .expect("Failed to get fork block number"), - None, - ) - }; - - let block = provider - .get_block(BlockNumber::Number(fork_block_number.into())) - .await - .expect("Failed to get fork block"); - - let block = if let Some(block) = block { - block - } else { - if let Ok(latest_block) = provider.get_block_number().await { - let mut message = format!( - "Failed to get block for block number: {fork_block_number}\n\ -latest block number: {latest_block}" - ); - // If the `eth_getBlockByNumber` call succeeds, but returns null instead of - // the block, and the block number is less than equal the latest block, then - // the user is forking from a non-archive node with an older block number. - if fork_block_number <= latest_block.as_u64() { - message.push_str(&format!("\n{}", NON_ARCHIVE_NODE_WARNING)); - } - panic!("{}", message); - } - panic!("Failed to get block for block number: {fork_block_number}") - }; - - // we only use the gas limit value of the block if it is non-zero and the block gas - // limit is enabled, since there are networks where this is not used and is always - // `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also - let gas_limit = if self.disable_block_gas_limit || block.gas_limit.is_zero() { - rU256::from(u64::MAX) - } else { - block.gas_limit.to_alloy() - }; - - env.block = BlockEnv { - number: rU256::from(fork_block_number), - timestamp: block.timestamp.to_alloy(), - difficulty: block.difficulty.to_alloy(), - // ensures prevrandao is set - prevrandao: Some(block.mix_hash.unwrap_or_default()).map(|h| h.to_alloy()), - gas_limit, - // Keep previous `coinbase` and `basefee` value - coinbase: env.block.coinbase, - basefee: env.block.basefee, - ..Default::default() - }; - - // apply changes such as difficulty -> prevrandao - apply_chain_and_block_specific_env_changes(&mut env, &block); - - // if not set explicitly we use the base fee of the latest block - if self.base_fee.is_none() { - if let Some(base_fee) = block.base_fee_per_gas { - self.base_fee = Some(base_fee); - env.block.basefee = base_fee.to_alloy(); - // this is the base fee of the current block, but we need the base fee of - // the next block - let next_block_base_fee = fees.get_next_block_base_fee_per_gas( - block.gas_used, - block.gas_limit, - block.base_fee_per_gas.unwrap_or_default(), - ); - // update next base fee - fees.set_base_fee(next_block_base_fee.into()); - } - } - - // use remote gas price - if self.gas_price.is_none() { - if let Ok(gas_price) = provider.get_gas_price().await { - self.gas_price = Some(gas_price); - fees.set_gas_price(gas_price); - } - } - - let block_hash = block.hash.unwrap_or_default(); - - let chain_id = if let Some(chain_id) = self.chain_id { - chain_id - } else { - let chain_id = if let Some(fork_chain_id) = fork_chain_id { - fork_chain_id - } else { - provider.get_chainid().await.unwrap() - } - .as_u64(); - - // need to update the dev signers and env with the chain id - self.set_chain_id(Some(chain_id)); - env.cfg.chain_id = chain_id; - env.tx.chain_id = chain_id.into(); - chain_id - }; - let override_chain_id = self.chain_id; - - let meta = BlockchainDbMeta::new(env.clone(), eth_rpc_url.clone()); - let block_chain_db = if self.fork_chain_id.is_some() { - BlockchainDb::new_skip_check(meta, self.block_cache_path(fork_block_number)) - } else { - BlockchainDb::new(meta, self.block_cache_path(fork_block_number)) - }; - - // This will spawn the background thread that will use the provider to fetch - // blockchain data from the other client - let backend = SharedBackend::spawn_backend_thread( - Arc::clone(&provider), - block_chain_db.clone(), - Some(fork_block_number.into()), - ); - - let db = Arc::new(tokio::sync::RwLock::new(ForkedDatabase::new( - backend, - block_chain_db, - ))); - let fork = ClientFork::new( - ClientForkConfig { - eth_rpc_url, - block_number: fork_block_number, - block_hash, - provider, - chain_id, - override_chain_id, - timestamp: block.timestamp.as_u64(), - base_fee: block.base_fee_per_gas, - timeout: self.fork_request_timeout, - retries: self.fork_request_retries, - backoff: self.fork_retry_backoff, - compute_units_per_second: self.compute_units_per_second, - total_difficulty: block.total_difficulty.unwrap_or_default(), - }, - Arc::clone(&db), - ); - - (db, Some(fork)) + self.setup_fork_db(eth_rpc_url, &mut env, &fees).await } else { (Arc::new(tokio::sync::RwLock::new(MemDb::default())), None) }; @@ -1006,11 +830,12 @@ latest block number: {latest_block}" Arc::new(RwLock::new(env)), genesis, fees, - fork, + Arc::new(RwLock::new(fork)), self.enable_steps_tracing, self.prune_history, self.transaction_block_keeper, self.block_time, + Arc::new(tokio::sync::RwLock::new(self.clone())), ) .await; @@ -1034,6 +859,191 @@ latest block number: {latest_block}" backend } + + /// Configures everything related to forking based on the passed `eth_rpc_url`: + /// - returning a tuple of a [ForkedDatabase](ForkedDatabase) and [ClientFork](ClientFork) + /// which can be used in a [Backend](mem::Backend) to fork from. + /// - modifying some parameters of the passed `env` + /// - mutating some members of `self` + pub async fn setup_fork_db( + &mut self, + eth_rpc_url: String, + env: &mut revm::primitives::Env, + fees: &FeeManager, + ) -> (Arc>, Option) { + // TODO make provider agnostic + let provider = Arc::new( + ProviderBuilder::new(ð_rpc_url) + .timeout(self.fork_request_timeout) + .timeout_retry(self.fork_request_retries) + .initial_backoff(self.fork_retry_backoff.as_millis() as u64) + .compute_units_per_second(self.compute_units_per_second) + .max_retry(10) + .initial_backoff(1000) + .build() + .expect("Failed to establish provider to fork url"), + ); + + let (fork_block_number, fork_chain_id) = if let Some(fork_block_number) = + self.fork_block_number + { + let chain_id = if let Some(chain_id) = self.fork_chain_id { + Some(chain_id) + } else if self.hardfork.is_none() { + // auto adjust hardfork if not specified + // but only if we're forking mainnet + let chain_id = + provider.get_chainid().await.expect("Failed to fetch network chain id"); + if chain_id == ethers::types::Chain::Mainnet.into() { + let hardfork: Hardfork = fork_block_number.into(); + env.cfg.spec_id = hardfork.into(); + self.hardfork = Some(hardfork); + } + Some(chain_id) + } else { + None + }; + + (fork_block_number, chain_id) + } else { + // pick the last block number but also ensure it's not pending anymore + ( + find_latest_fork_block(&provider).await.expect("Failed to get fork block number"), + None, + ) + }; + + let block = provider + .get_block(BlockNumber::Number(fork_block_number.into())) + .await + .expect("Failed to get fork block"); + + let block = if let Some(block) = block { + block + } else { + if let Ok(latest_block) = provider.get_block_number().await { + let mut message = format!( + "Failed to get block for block number: {fork_block_number}\n\ +latest block number: {latest_block}" + ); + // If the `eth_getBlockByNumber` call succeeds, but returns null instead of + // the block, and the block number is less than equal the latest block, then + // the user is forking from a non-archive node with an older block number. + if fork_block_number <= latest_block.as_u64() { + message.push_str(&format!("\n{}", NON_ARCHIVE_NODE_WARNING)); + } + panic!("{}", message); + } + panic!("Failed to get block for block number: {fork_block_number}") + }; + + // we only use the gas limit value of the block if it is non-zero and the block gas + // limit is enabled, since there are networks where this is not used and is always + // `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also + let gas_limit = if self.disable_block_gas_limit || block.gas_limit.is_zero() { + rU256::from(u64::MAX) + } else { + block.gas_limit.to_alloy() + }; + + env.block = BlockEnv { + number: rU256::from(fork_block_number), + timestamp: block.timestamp.to_alloy(), + difficulty: block.difficulty.to_alloy(), + // ensures prevrandao is set + prevrandao: Some(block.mix_hash.unwrap_or_default()).map(|h| h.to_alloy()), + gas_limit, + // Keep previous `coinbase` and `basefee` value + coinbase: env.block.coinbase, + basefee: env.block.basefee, + ..Default::default() + }; + + // apply changes such as difficulty -> prevrandao + apply_chain_and_block_specific_env_changes(env, &block); + + // if not set explicitly we use the base fee of the latest block + if self.base_fee.is_none() { + if let Some(base_fee) = block.base_fee_per_gas { + self.base_fee = Some(base_fee); + env.block.basefee = base_fee.to_alloy(); + // this is the base fee of the current block, but we need the base fee of + // the next block + let next_block_base_fee = fees.get_next_block_base_fee_per_gas( + block.gas_used, + block.gas_limit, + block.base_fee_per_gas.unwrap_or_default(), + ); + // update next base fee + fees.set_base_fee(next_block_base_fee.into()); + } + } + + // use remote gas price + if self.gas_price.is_none() { + if let Ok(gas_price) = provider.get_gas_price().await { + self.gas_price = Some(gas_price); + fees.set_gas_price(gas_price); + } + } + + let block_hash = block.hash.unwrap_or_default(); + + let chain_id = if let Some(chain_id) = self.chain_id { + chain_id + } else { + let chain_id = if let Some(fork_chain_id) = fork_chain_id { + fork_chain_id + } else { + provider.get_chainid().await.unwrap() + } + .as_u64(); + + // need to update the dev signers and env with the chain id + self.set_chain_id(Some(chain_id)); + env.cfg.chain_id = chain_id; + env.tx.chain_id = chain_id.into(); + chain_id + }; + let override_chain_id = self.chain_id; + + let meta = BlockchainDbMeta::new(env.clone(), eth_rpc_url.clone()); + let block_chain_db = if self.fork_chain_id.is_some() { + BlockchainDb::new_skip_check(meta, self.block_cache_path(fork_block_number)) + } else { + BlockchainDb::new(meta, self.block_cache_path(fork_block_number)) + }; + + // This will spawn the background thread that will use the provider to fetch + // blockchain data from the other client + let backend = SharedBackend::spawn_backend_thread( + Arc::clone(&provider), + block_chain_db.clone(), + Some(fork_block_number.into()), + ); + + let db = Arc::new(tokio::sync::RwLock::new(ForkedDatabase::new(backend, block_chain_db))); + let fork = ClientFork::new( + ClientForkConfig { + eth_rpc_url, + block_number: fork_block_number, + block_hash, + provider, + chain_id, + override_chain_id, + timestamp: block.timestamp.as_u64(), + base_fee: block.base_fee_per_gas, + timeout: self.fork_request_timeout, + retries: self.fork_request_retries, + backoff: self.fork_retry_backoff, + compute_units_per_second: self.compute_units_per_second, + total_difficulty: block.total_difficulty.unwrap_or_default(), + }, + Arc::clone(&db), + ); + + (db, Some(fork)) + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index c705ce81ee484..949f32f0f290e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2235,7 +2235,7 @@ impl EthApi { self.backend.chain_id().as_u64() } - pub fn get_fork(&self) -> Option<&ClientFork> { + pub fn get_fork(&self) -> Option { self.backend.get_fork() } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ae9ac2656281d..b9b2af8749a1b 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -27,6 +27,7 @@ use crate::{ db::DatabaseRef, primitives::{AccountInfo, U256 as rU256}, }, + NodeConfig, }; use anvil_core::{ eth::{ @@ -148,7 +149,7 @@ pub struct Backend { /// env data of the chain env: Arc>, /// this is set if this is currently forked off another client - fork: Option, + fork: Arc>>, /// provides time related info, like timestamp time: TimeManager, /// Contains state of custom overrides @@ -166,6 +167,7 @@ pub struct Backend { prune_state_history_config: PruneStateHistoryConfig, /// max number of blocks with transactions in memory transaction_block_keeper: Option, + node_config: Arc>, } impl Backend { @@ -176,14 +178,15 @@ impl Backend { env: Arc>, genesis: GenesisConfig, fees: FeeManager, - fork: Option, + fork: Arc>>, enable_steps_tracing: bool, prune_state_history_config: PruneStateHistoryConfig, transaction_block_keeper: Option, automine_block_time: Option, + node_config: Arc>, ) -> Self { // if this is a fork then adjust the blockchain storage - let blockchain = if let Some(ref fork) = fork { + let blockchain = if let Some(fork) = fork.read().as_ref() { trace!(target: "backend", "using forked blockchain at {}", fork.block_number()); Blockchain::forked(fork.block_number(), fork.block_hash(), fork.total_difficulty()) } else { @@ -194,8 +197,11 @@ impl Backend { ) }; - let start_timestamp = - if let Some(fork) = fork.as_ref() { fork.timestamp() } else { genesis.timestamp }; + let start_timestamp = if let Some(fork) = fork.read().as_ref() { + fork.timestamp() + } else { + genesis.timestamp + }; let states = if prune_state_history_config.is_config_enabled() { // if prune state history is enabled, configure the state cache only for memory @@ -223,6 +229,7 @@ impl Backend { enable_steps_tracing, prune_state_history_config, transaction_block_keeper, + node_config, }; if let Some(interval_block_time) = automine_block_time { @@ -252,7 +259,7 @@ impl Backend { async fn apply_genesis(&self) -> DatabaseResult<()> { trace!(target: "backend", "setting genesis balances"); - if self.fork.is_some() { + if self.fork.read().is_some() { // fetch all account first let mut genesis_accounts_futures = Vec::with_capacity(self.genesis.accounts.len()); for address in self.genesis.accounts.iter().copied() { @@ -325,8 +332,8 @@ impl Backend { } /// Returns the configured fork, if any - pub fn get_fork(&self) -> Option<&ClientFork> { - self.fork.as_ref() + pub fn get_fork(&self) -> Option { + self.fork.read().clone() } /// Returns the database @@ -341,7 +348,7 @@ impl Backend { /// Whether we're forked off some remote client pub fn is_fork(&self) -> bool { - self.fork.is_some() + self.fork.read().is_some() } pub fn precompiles(&self) -> Vec
{ @@ -350,6 +357,28 @@ impl Backend { /// Resets the fork to a fresh state pub async fn reset_fork(&self, forking: Forking) -> Result<(), BlockchainError> { + if !self.is_fork() { + if let Some(eth_rpc_url) = forking.clone().json_rpc_url { + let mut env = self.env.read().clone(); + + let mut node_config = self.node_config.write().await; + let (_db, forking) = + node_config.setup_fork_db(eth_rpc_url, &mut env, &self.fees).await; + + // TODO: Something like this is needed but... + // This won't compile because dyn Db is not Sized (and AFAIK cannot be made Sized) + // *self.db.write().await = *db.read().await; + + *self.env.write() = env; + *self.fork.write() = forking; + } else { + return Err(RpcError::invalid_params( + "Forking not enabled and RPC URL not provided to start forking", + ) + .into()) + } + } + if let Some(fork) = self.get_fork() { let block_number = forking.block_number.map(BlockNumber::from).unwrap_or(BlockNumber::Latest); diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 134de3db3d0d0..b816d53d9a358 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -100,7 +100,7 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { backend.auto_impersonate_account(true).await; } - let fork = backend.get_fork().cloned(); + let fork = backend.get_fork(); let NodeConfig { signer_accounts, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 6165929ae8510..ccce2ada6a9ba 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -222,6 +222,31 @@ async fn test_fork_reset() { assert!(new_block_num > block_number); } +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_reset_setup() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + let block_number = provider.get_block_number().await.unwrap(); + assert_eq!(block_number, 0.into()); + + api.anvil_reset(Some(Forking { + json_rpc_url: Some(rpc::next_http_archive_rpc_endpoint()), + block_number: Some(BLOCK_NUMBER), + })) + .await + .unwrap(); + + let block_number = provider.get_block_number().await.unwrap(); + assert_eq!(block_number, BLOCK_NUMBER.into()); + + // TODO: This won't work because we don't replace the DB with a ForkedDatabase yet + // let addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); + + // let remote_balance = provider.get_balance(addr, None).await.unwrap(); + // assert_eq!(remote_balance, 12556069338441120059867u128.into()); +} + #[tokio::test(flavor = "multi_thread")] async fn test_fork_snapshotting() { let (api, handle) = spawn(fork_config()).await; From 7ed1cb43c92b89777da9f0a1def57ccc5a896de6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:58:21 +0200 Subject: [PATCH 0104/1963] ci: fix issue jobs (again) (for real this time) (#5893) --- .github/workflows/heavy-integration.yml | 1 + .github/workflows/release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index d5138e9e9446f..09de5de31d967 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -45,6 +45,7 @@ jobs: needs: heavy-integration if: ${{ failure() }} steps: + - uses: actions/checkout@v3 - uses: JasonEtco/create-an-issue@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48c35af48e49e..4e7edd596c57c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -233,6 +233,7 @@ jobs: needs: [prepare, release-docker, release, cleanup] if: ${{ failure() }} steps: + - uses: actions/checkout@v3 - uses: JasonEtco/create-an-issue@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ac4e264fdb60aedc202d3ebebb37ef7edf8dcd69 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:01:52 +0200 Subject: [PATCH 0105/1963] chore(deps): weekly `cargo update` (#5887) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/Evalir/revm/` Updating git repository `https://github.com/ethereum/c-kzg-4844` Updating git submodule `https://github.com/supranational/blst` Updating aho-corasick v1.1.0 -> v1.1.1 Updating alloy-rlp v0.3.2 -> v0.3.3 Updating alloy-rlp-derive v0.3.2 -> v0.3.3 Removing array-init v0.0.4 Updating clap_complete_fig v4.4.0 -> v4.4.1 Updating const-hex v1.8.0 -> v1.9.0 Updating curl-sys v0.4.65+curl-8.2.1 -> v0.4.66+curl-8.3.0 Updating enr v0.9.0 -> v0.9.1 Updating ethers v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-addressbook v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-contract v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-contract-abigen v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-contract-derive v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-core v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-etherscan v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-middleware v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-providers v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-signers v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating ethers-solc v2.0.10 (https://github.com/gakonst/ethers-rs#4b5e08ce) -> #08bcb67c Updating hermit-abi v0.3.2 -> v0.3.3 Updating indicatif v0.17.6 -> v0.17.7 Removing maybe-uninit v2.0.0 Updating md-5 v0.10.5 -> v0.10.6 Removing nodrop v0.1.14 Updating rayon v1.7.0 -> v1.8.0 Updating rayon-core v1.11.0 -> v1.12.0 Updating rustix v0.38.13 -> v0.38.14 Removing rustls-webpki v0.100.3 Removing rustls-webpki v0.101.5 Adding rustls-webpki v0.101.6 Updating semver v1.0.18 -> v1.0.19 Removing serde-hex v0.1.0 Updating sha1 v0.10.5 -> v0.10.6 Removing smallvec v0.6.14 Removing smallvec v1.11.0 Adding smallvec v1.11.1 Updating termcolor v1.2.0 -> v1.3.0 Updating tokio-tungstenite v0.20.0 -> v0.20.1 Updating tokio-util v0.7.8 -> v0.7.9 Updating tungstenite v0.20.0 -> v0.20.1 Updating unicode-width v0.1.10 -> v0.1.11 Removing webpki-roots v0.23.1 Updating winapi-util v0.1.5 -> v0.1.6 Updating xml-rs v0.8.18 -> v0.8.19 Co-authored-by: mattsse --- Cargo.lock | 234 ++++++++++++++++++++--------------------------------- 1 file changed, 86 insertions(+), 148 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1140ce6999fb5..bda49e1fb4453 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f938f00332d63a5b0ac687bd6f46d03884638948921d9f8b50c59563d421ae25" +checksum = "cc0fac0fc16baf1f63f78b47c3d24718f3619b0714076f6a02957d808d52cbef" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -143,9 +143,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aa5bb468bc7c46e0c5074d418f575262ff79451242e5ac1380121ed4e23c4fd" +checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" dependencies = [ "proc-macro2 1.0.67", "quote 1.0.33", @@ -512,15 +512,6 @@ dependencies = [ "rand 0.8.5", ] -[[package]] -name = "array-init" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" -dependencies = [ - "nodrop", -] - [[package]] name = "arrayvec" version = "0.7.4" @@ -922,7 +913,7 @@ checksum = "fb9ac64500cc83ce4b9f8dafa78186aa008c8dea77a09b94cd307fd0cd5022a8" dependencies = [ "camino", "cargo-platform", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "thiserror", @@ -969,7 +960,7 @@ dependencies = [ "rpassword", "rusoto_core", "rusoto_kms", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "tempfile", @@ -1032,7 +1023,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "serial_test", @@ -1141,9 +1132,9 @@ dependencies = [ [[package]] name = "clap_complete_fig" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9bae21b3f6eb417ad3054c8b1094aa0542116eba4979b1b271baefbfa6b965" +checksum = "29bdbe21a263b628f83fcbeac86a4416a1d588c7669dd41473bc4149e4e7d2f1" dependencies = [ "clap", "clap_complete", @@ -1342,9 +1333,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08849ed393c907c90016652a01465a12d86361cd38ad2a7de026c56a520cc259" +checksum = "aa72a10d0e914cad6bcad4e7409e68d230c1c2db67896e19a37f758b1fcbdab5" dependencies = [ "cfg-if", "cpufeatures", @@ -1606,9 +1597,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.65+curl-8.2.1" +version = "0.4.66+curl-8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961ba061c9ef2fe34bbd12b807152d96f0badd2bebe7b90ce6c8c8b7572a0986" +checksum = "70c44a72e830f0e40ad90dda8a6ab6ed6314d39776599a58a2e5e37fbc6db5b9" dependencies = [ "cc", "libc", @@ -1616,7 +1607,7 @@ dependencies = [ "libz-sys", "pkg-config", "vcpkg", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1883,9 +1874,9 @@ checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" [[package]] name = "enr" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0be7b2ac146c1f99fe245c02d16af0696450d8e06c135db75e10eeb9e642c20d" +checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" dependencies = [ "base64 0.21.4", "bytes", @@ -1895,7 +1886,6 @@ dependencies = [ "rand 0.8.5", "rlp", "serde", - "serde-hex", "sha3", "zeroize", ] @@ -2047,7 +2037,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2062,7 +2052,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "ethers-core", "once_cell", @@ -2073,7 +2063,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2091,7 +2081,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "Inflector", "const-hex", @@ -2114,7 +2104,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "Inflector", "const-hex", @@ -2129,7 +2119,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "arrayvec", "bytes", @@ -2158,12 +2148,12 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "ethers-core", "ethers-solc", "reqwest", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "thiserror", @@ -2173,7 +2163,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "async-trait", "auto_impl", @@ -2199,7 +2189,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "async-trait", "auto_impl", @@ -2223,7 +2213,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-tungstenite 0.20.0", + "tokio-tungstenite 0.20.1", "tracing", "tracing-futures", "url", @@ -2237,7 +2227,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "async-trait", "coins-bip32", @@ -2253,7 +2243,7 @@ dependencies = [ "rand 0.8.5", "rusoto_core", "rusoto_kms", - "semver 1.0.18", + "semver 1.0.19", "sha2 0.10.7", "spki", "thiserror", @@ -2264,7 +2254,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#4b5e08ce73047ac49af1f1197a980374839d950c" +source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" dependencies = [ "cfg-if", "const-hex", @@ -2275,14 +2265,14 @@ dependencies = [ "futures-util", "glob", "home", - "md-5 0.10.5", + "md-5 0.10.6", "num_cpus", "once_cell", "path-slash", "rand 0.8.5", "rayon", "regex", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "sha2 0.10.7", @@ -2500,7 +2490,7 @@ dependencies = [ "rayon", "regex", "reqwest", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "serial_test", @@ -2652,7 +2642,7 @@ dependencies = [ "once_cell", "regex", "reqwest", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "tempfile", @@ -2684,7 +2674,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "serde_regex", @@ -2736,7 +2726,7 @@ dependencies = [ "parking_lot", "proptest", "revm", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "tempfile", @@ -3056,7 +3046,7 @@ dependencies = [ "memchr", "nom", "once_cell", - "smallvec 1.11.0", + "smallvec", "thiserror", "unicode-bom", ] @@ -3155,7 +3145,7 @@ dependencies = [ "hex", "itoa", "nom", - "smallvec 1.11.0", + "smallvec", "thiserror", ] @@ -3409,9 +3399,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -3728,9 +3718,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.6" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b297dc40733f23a0e52728a58fa9489a5b7638a324932de16b41adc3ef80730" +checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" dependencies = [ "console", "instant", @@ -4107,12 +4097,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "md-5" version = "0.9.1" @@ -4126,10 +4110,11 @@ dependencies = [ [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ + "cfg-if", "digest 0.10.7", ] @@ -4301,7 +4286,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" dependencies = [ - "smallvec 1.11.0", + "smallvec", ] [[package]] @@ -4328,12 +4313,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - [[package]] name = "nom" version = "7.1.3" @@ -4728,7 +4707,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.3.5", - "smallvec 1.11.0", + "smallvec", "windows-targets 0.48.5", ] @@ -5379,9 +5358,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -5389,14 +5368,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -5525,7 +5502,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.2", + "webpki-roots", "winreg", ] @@ -5822,14 +5799,14 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.18", + "semver 1.0.19", ] [[package]] name = "rustix" -version = "0.38.13" +version = "0.38.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" dependencies = [ "bitflags 2.4.0", "errno", @@ -5858,7 +5835,7 @@ checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", - "rustls-webpki 0.101.5", + "rustls-webpki", "sct", ] @@ -5885,19 +5862,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.100.3" +version = "0.101.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" +checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" dependencies = [ "ring", "untrusted", @@ -6083,9 +6050,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" dependencies = [ "serde", ] @@ -6120,17 +6087,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-hex" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca37e3e4d1b39afd7ff11ee4e947efae85adfddf4841787bfa47c470e96dc26d" -dependencies = [ - "array-init", - "serde", - "smallvec 0.6.14", -] - [[package]] name = "serde_derive" version = "1.0.188" @@ -6223,9 +6179,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -6368,18 +6324,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "0.6.14" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "smol_str" @@ -6555,7 +6502,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver 1.0.18", + "semver 1.0.19", "serde", "serde_json", "sha2 0.10.7", @@ -6572,7 +6519,7 @@ checksum = "2271abd7d01895a3e5bfa4b578e32f09155002ce1ec239532e297f82aafad06b" dependencies = [ "build_const", "hex", - "semver 1.0.18", + "semver 1.0.19", "serde_json", "svm-rs", ] @@ -6683,9 +6630,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -6914,9 +6861,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", @@ -6925,15 +6872,15 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", - "tungstenite 0.20.0", - "webpki-roots 0.23.1", + "tungstenite 0.20.1", + "webpki-roots", ] [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" dependencies = [ "bytes", "futures-core", @@ -7160,7 +7107,7 @@ dependencies = [ "once_cell", "regex", "sharded-slab", - "smallvec 1.11.0", + "smallvec", "thread_local", "tracing", "tracing-core", @@ -7192,7 +7139,7 @@ dependencies = [ "hashbrown 0.12.3", "log", "rustc-hex", - "smallvec 1.11.0", + "smallvec", ] [[package]] @@ -7260,9 +7207,9 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ "byteorder", "bytes", @@ -7362,9 +7309,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -7651,15 +7598,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.3", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -7696,9 +7634,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -7899,9 +7837,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a" +checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" [[package]] name = "yansi" From 8920fd4cf4082d678fb569e3fb7b0267366f59bb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:04:02 +0200 Subject: [PATCH 0106/1963] ci: use latest ubuntu runners (#5895) --- .github/workflows/docker-publish.yml | 2 +- .github/workflows/release.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8af9cfa2757f7..0df58b104eb0a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -17,7 +17,7 @@ env: jobs: container: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest # https://docs.github.com/en/actions/reference/authentication-in-a-workflow permissions: id-token: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e7edd596c57c..aef8d563c4b32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ env: jobs: prepare: name: Prepare release - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest timeout-minutes: 30 outputs: tag_name: ${{ steps.release_info.outputs.tag_name }} @@ -78,12 +78,12 @@ jobs: # The target is used by Cargo # The arch is either 386, arm64 or amd64 # The svm target platform to use for the binary https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 - - os: ubuntu-20.04 + - os: ubuntu-latest platform: linux target: x86_64-unknown-linux-gnu arch: amd64 svm_target_platform: linux-amd64 - - os: ubuntu-20.04 + - os: ubuntu-latest platform: linux target: aarch64-unknown-linux-gnu arch: arm64 @@ -204,7 +204,7 @@ jobs: cleanup: name: Release cleanup - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest timeout-minutes: 30 needs: release steps: From 9ef63920a963670db3b7e1e8d02823fe7f191d3d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:12:29 +0200 Subject: [PATCH 0107/1963] ci: update some actions (#5894) --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aef8d563c4b32..ffddf974e9943 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,7 @@ jobs: # the changelog. - name: Create build-specific nightly tag if: ${{ env.IS_NIGHTLY }} - uses: actions/github-script@v5 + uses: actions/github-script@v6 env: TAG_NAME: ${{ steps.release_info.outputs.tag_name }} with: @@ -53,7 +53,7 @@ jobs: - name: Build changelog id: build_changelog - uses: mikepenz/release-changelog-builder-action@v2 + uses: mikepenz/release-changelog-builder-action@v4 with: configuration: "./.github/changelog.json" fromTag: ${{ env.IS_NIGHTLY && 'nightly' || '' }} @@ -213,14 +213,14 @@ jobs: # Moves the `nightly` tag to `HEAD` - name: Move nightly tag if: ${{ env.IS_NIGHTLY }} - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: script: | const moveTag = require('./.github/scripts/move-tag.js') await moveTag({ github, context }, 'nightly') - name: Delete old nightlies - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: script: | const prunePrereleases = require('./.github/scripts/prune-prereleases.js') From 7d0412e61021db88615d767e5d283a5f7d7d5731 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 25 Sep 2023 13:11:37 -0400 Subject: [PATCH 0108/1963] chore(dockerfile): upgrade alpine to 3.18 (#5896) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4d048ab603fa3..e5ce88c0139ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM alpine:3.16 as build-environment +FROM alpine:3.18 as build-environment ARG TARGETARCH WORKDIR /opt From 35b6c011678ed8b7563819de095a9a68600a9752 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:44:34 +0200 Subject: [PATCH 0109/1963] chore: use boolean for profile.debug for backwards compatibility (#5897) --- Cargo.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ae2049af2e331..5cd9d3baad415 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ codegen-units = 1 # Like release, but with full debug symbols and with stack unwinds. Useful for e.g. `perf`. [profile.debug-fast] inherits = "release" -debug = "full" +debug = true strip = "none" panic = "unwind" incremental = false @@ -152,7 +152,7 @@ ethers-etherscan = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } alloy-primitives = { version = "0.3", default-features = false } -alloy-dyn-abi = { version = "0.3", default-features = false} +alloy-dyn-abi = { version = "0.3", default-features = false } solang-parser = "=0.3.2" @@ -175,7 +175,6 @@ hex = { package = "const-hex", version = "1.6", features = ["hex"] } #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] - ethers = { git = "https://github.com/gakonst/ethers-rs" } ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs" } ethers-core = { git = "https://github.com/gakonst/ethers-rs" } From 67526666f3a776d73f727fd6ac5b08efe7858f9b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 25 Sep 2023 20:35:13 +0200 Subject: [PATCH 0110/1963] ci: cache on failure (#5899) --- .github/workflows/heavy-integration.yml | 2 ++ .github/workflows/release.yml | 2 ++ .github/workflows/test.yml | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index 09de5de31d967..8fe20560e3d62 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -21,6 +21,8 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - name: Forge RPC cache uses: actions/cache@v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ffddf974e9943..a74923835a388 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,6 +110,8 @@ jobs: with: targets: ${{ matrix.job.target }} - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - name: Apple M1 setup if: ${{ matrix.job.target == 'aarch64-apple-darwin' }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1eeea521be70..a92fcdc18a158 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,6 +50,8 @@ jobs: with: target: ${{ matrix.target }} - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - uses: taiki-e/install-action@nextest - name: Build archive shell: bash @@ -116,6 +118,8 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - name: cargo test run: cargo test --doc @@ -127,6 +131,8 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@clippy - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - run: cargo clippy --workspace --all-targets --all-features env: RUSTFLAGS: -Dwarnings @@ -150,6 +156,8 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - name: forge fmt run: cargo run --bin forge -- fmt --check testdata/ @@ -162,5 +170,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@cargo-hack - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true - name: cargo hack - run: cargo hack check \ No newline at end of file + run: cargo hack check From 08e2281c6e75a0da0e672200d66414482a213b17 Mon Sep 17 00:00:00 2001 From: Tiago Carvalho Date: Mon, 25 Sep 2023 22:18:03 +0100 Subject: [PATCH 0111/1963] Chisel prelude files (#5823) * feat(chisel): allow loading prelude files * feat: parse both single files and folders for prelude files * chore: docs * no emojis * style match if let --------- Co-authored-by: Enrique Ortiz Co-authored-by: Matthias Seitz --- crates/chisel/bin/main.rs | 80 ++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 55de1f0649edb..376f89ab534ca 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -3,16 +3,19 @@ //! This module contains the core readline loop for the Chisel CLI as well as the //! executable's `main` function. +use std::path::PathBuf; + use chisel::{ history::chisel_history_file, prelude::{ChiselCommand, ChiselDispatcher, DispatchResult, SolidityHelper}, }; use clap::Parser; +use eyre::Context; use foundry_cli::{ opts::CoreBuildArgs, utils::{self, LoadConfig}, }; -use foundry_common::evm::EvmArgs; +use foundry_common::{evm::EvmArgs, fs}; use foundry_config::{ figment::{ value::{Dict, Map}, @@ -42,6 +45,13 @@ pub struct ChiselParser { #[command(subcommand)] pub sub: Option, + /// Path to a directory containing Solidity files to import, or path to a single Solidity file. + /// + /// These files will be evaluated before the top-level of the + /// REPL, therefore functioning as a prelude + #[clap(long, help_heading = "REPL options")] + pub prelude: Option, + #[clap(flatten)] pub opts: CoreBuildArgs, @@ -99,6 +109,9 @@ async fn main() -> eyre::Result<()> { calldata: None, })?; + // Execute prelude Solidity source files + evaluate_prelude(&mut dispatcher, args.prelude).await?; + // Check for chisel subcommands match &args.sub { Some(ChiselParserSub::List) => { @@ -177,19 +190,7 @@ async fn main() -> eyre::Result<()> { interrupt = false; // Dispatch and match results - match dispatcher.dispatch(&line).await { - DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => if let Some(msg) = msg { - println!("{}", Paint::green(msg)); - }, - DispatchResult::UnrecognizedCommand(e) => eprintln!("{e}"), - DispatchResult::SolangParserFailed(e) => { - eprintln!("{}", Paint::red("Compilation error")); - eprintln!("{}", Paint::red(format!("{e:?}"))); - } - DispatchResult::FileIoError(e) => eprintln!("{}", Paint::red(format!("⚒️ Chisel File IO Error - {e}"))), - DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => eprintln!("{}", Paint::red(msg)), - DispatchResult::Failure(None) => eprintln!("{}\nPlease Report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose", Paint::red("⚒️ Unknown Chisel Error ⚒️")), - } + dispatch_repl_line(&mut dispatcher, &line).await; } Err(ReadlineError::Interrupted) => { if interrupt { @@ -224,3 +225,54 @@ impl Provider for ChiselParser { Ok(Map::from([(Config::selected_profile(), Dict::default())])) } } + +/// Evaluate a single Solidity line. +async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) { + match dispatcher.dispatch(line).await { + DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => if let Some(msg) = msg { + println!("{}", Paint::green(msg)); + }, + DispatchResult::UnrecognizedCommand(e) => eprintln!("{e}"), + DispatchResult::SolangParserFailed(e) => { + eprintln!("{}", Paint::red("Compilation error")); + eprintln!("{}", Paint::red(format!("{e:?}"))); + } + DispatchResult::FileIoError(e) => eprintln!("{}", Paint::red(format!("⚒️ Chisel File IO Error - {e}"))), + DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => eprintln!("{}", Paint::red(msg)), + DispatchResult::Failure(None) => eprintln!("{}\nPlease Report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose", Paint::red("⚒️ Unknown Chisel Error ⚒️")), + } +} + +/// Evaluate multiple Solidity source files contained within a +/// Chisel prelude directory. +async fn evaluate_prelude( + dispatcher: &mut ChiselDispatcher, + maybe_prelude: Option, +) -> eyre::Result<()> { + let Some(prelude_dir) = maybe_prelude else { return Ok(()) }; + if prelude_dir.is_file() { + println!("{} {}", Paint::yellow("Loading prelude source file:"), prelude_dir.display(),); + load_prelude_file(dispatcher, prelude_dir).await?; + println!("{}\n", Paint::green("Prelude source file loaded successfully!")); + } else { + let prelude_sources = fs::files_with_ext(prelude_dir, "sol"); + let print_success_msg = !prelude_sources.is_empty(); + for source_file in prelude_sources { + println!("{} {}", Paint::yellow("Loading prelude source file:"), source_file.display(),); + load_prelude_file(dispatcher, source_file).await?; + } + + if print_success_msg { + println!("{}\n", Paint::green("All prelude source files loaded successfully!")); + } + } + Ok(()) +} + +/// Loads a single Solidity file into the prelude. +async fn load_prelude_file(dispatcher: &mut ChiselDispatcher, file: PathBuf) -> eyre::Result<()> { + let prelude = fs::read_to_string(file) + .wrap_err("Could not load source file. Are you sure this path is correct?")?; + dispatch_repl_line(dispatcher, &prelude).await; + Ok(()) +} From a1f5842c62a5fdd6f6b52cc2a852d2cca7e73f47 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 25 Sep 2023 23:34:05 +0200 Subject: [PATCH 0112/1963] Revert "ci: use latest ubuntu runners (#5895)" (#5904) This reverts commit 8920fd4cf4082d678fb569e3fb7b0267366f59bb. --- .github/workflows/docker-publish.yml | 2 +- .github/workflows/release.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0df58b104eb0a..8af9cfa2757f7 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -17,7 +17,7 @@ env: jobs: container: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 # https://docs.github.com/en/actions/reference/authentication-in-a-workflow permissions: id-token: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a74923835a388..7338f46867831 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ env: jobs: prepare: name: Prepare release - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 timeout-minutes: 30 outputs: tag_name: ${{ steps.release_info.outputs.tag_name }} @@ -78,12 +78,12 @@ jobs: # The target is used by Cargo # The arch is either 386, arm64 or amd64 # The svm target platform to use for the binary https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 - - os: ubuntu-latest + - os: ubuntu-20.04 platform: linux target: x86_64-unknown-linux-gnu arch: amd64 svm_target_platform: linux-amd64 - - os: ubuntu-latest + - os: ubuntu-20.04 platform: linux target: aarch64-unknown-linux-gnu arch: arm64 @@ -206,7 +206,7 @@ jobs: cleanup: name: Release cleanup - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 timeout-minutes: 30 needs: release steps: From 479656ce9ed11e0950f1183883ad466883fa233f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Sep 2023 12:38:45 +0200 Subject: [PATCH 0113/1963] ci: add multilib deps (#5914) --- .github/workflows/release.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7338f46867831..cd6217401f3a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -126,6 +126,12 @@ jobs: sudo apt-get install -y gcc-aarch64-linux-gnu echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV + - name: GCC Multilib setup + if: ${{ matrix.job.platform == 'linux' }} + run: | + sudo apt-get update -y + sudo apt-get install gcc-multilib g++-multilib + - name: Build binaries env: SVM_TARGET_PLATFORM: ${{ matrix.job.svm_target_platform }} From c74fd945ed129d67b2df69386c3139750cb3c534 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Sep 2023 12:43:37 +0200 Subject: [PATCH 0114/1963] ci: add multilib deps (#5915) --- .github/workflows/release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd6217401f3a6..a7df4d5326160 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,6 +119,12 @@ jobs: echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV + - name: GCC Multilib setup + if: ${{ matrix.job.platform == 'linux' }} + run: | + sudo apt-get update -y + sudo apt-get install -y gcc-multilib g++-multilib gcc-aarch64-linux-gnu + - name: Linux ARM setup if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} run: | @@ -126,12 +132,6 @@ jobs: sudo apt-get install -y gcc-aarch64-linux-gnu echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - - name: GCC Multilib setup - if: ${{ matrix.job.platform == 'linux' }} - run: | - sudo apt-get update -y - sudo apt-get install gcc-multilib g++-multilib - - name: Build binaries env: SVM_TARGET_PLATFORM: ${{ matrix.job.svm_target_platform }} From b79f87d5cb9be0ca9cb1e263af2be981a6dcf9be Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Sep 2023 12:46:04 +0200 Subject: [PATCH 0115/1963] ci: fix gcc-aarch64 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7df4d5326160..7628877311710 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -123,7 +123,7 @@ jobs: if: ${{ matrix.job.platform == 'linux' }} run: | sudo apt-get update -y - sudo apt-get install -y gcc-multilib g++-multilib gcc-aarch64-linux-gnu + sudo apt-get install -y gcc-multilib g++-multilib - name: Linux ARM setup if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} From 73991e2d2c50c3773814e8ab2db063ec19d0b5eb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Sep 2023 12:52:08 +0200 Subject: [PATCH 0116/1963] ci: only install gcc-multilib --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7628877311710..6fdee0cf62b87 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -123,7 +123,7 @@ jobs: if: ${{ matrix.job.platform == 'linux' }} run: | sudo apt-get update -y - sudo apt-get install -y gcc-multilib g++-multilib + sudo apt-get install -y gcc-multilib - name: Linux ARM setup if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} From 532fdba6e46d27098e6f4701d972095a2950c039 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Sep 2023 12:58:31 +0200 Subject: [PATCH 0117/1963] ci: undo multilib stuff --- .github/workflows/release.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6fdee0cf62b87..7338f46867831 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,12 +119,6 @@ jobs: echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV - - name: GCC Multilib setup - if: ${{ matrix.job.platform == 'linux' }} - run: | - sudo apt-get update -y - sudo apt-get install -y gcc-multilib - - name: Linux ARM setup if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} run: | From 7d503a3ce746c896ff4e110c44b73b332a53cd81 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Sep 2023 15:17:53 +0200 Subject: [PATCH 0118/1963] fix: add input alias (#5918) --- crates/anvil/core/src/eth/transaction/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 925f715febae5..6cbd7e8a464a9 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -67,6 +67,7 @@ pub struct EthTransactionRequest { /// value of th tx in wei pub value: Option, /// Any additional data sent + #[cfg_attr(feature = "serde", serde(alias = "input"))] pub data: Option, /// Transaction nonce pub nonce: Option, From b830d97db91a0192d685bbeae301d6988904938a Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 26 Sep 2023 09:33:28 -0400 Subject: [PATCH 0119/1963] feat(`deps`): bump revm and disable kzg (#5919) * feat: bump revm and disable kzg * chore: always turn off default features for revm --- Cargo.lock | 51 ++++++++++++++++++++++++++++++++++---- crates/chisel/Cargo.toml | 2 +- crates/config/Cargo.toml | 2 +- crates/debugger/Cargo.toml | 4 +-- crates/evm/Cargo.toml | 1 + 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bda49e1fb4453..3ce26ff9757c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,7 +123,7 @@ dependencies = [ "hex-literal", "itoa", "proptest", - "proptest-derive", + "proptest-derive 0.3.0", "ruint", "serde", "tiny-keccak", @@ -377,6 +377,9 @@ name = "arbitrary" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +dependencies = [ + "derive_arbitrary", +] [[package]] name = "ariadne" @@ -744,6 +747,7 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" dependencies = [ + "arbitrary", "serde", ] @@ -885,6 +889,7 @@ dependencies = [ "glob", "hex", "libc", + "serde", ] [[package]] @@ -5190,6 +5195,17 @@ dependencies = [ "syn 0.15.44", ] +[[package]] +name = "proptest-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf16337405ca084e9c78985114633b6827711d22b9e6ef6c6c0d665eb3f0b6e" +dependencies = [ + "proc-macro2 1.0.67", + "quote 1.0.33", + "syn 1.0.109", +] + [[package]] name = "protobuf" version = "3.2.0" @@ -5509,7 +5525,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ "auto_impl", "revm-interpreter", @@ -5521,10 +5537,13 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ + "arbitrary", "derive_more", "enumn", + "proptest", + "proptest-derive 0.4.0", "revm-primitives", "serde", ] @@ -5532,7 +5551,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ "c-kzg", "k256", @@ -5540,6 +5559,7 @@ dependencies = [ "once_cell", "revm-primitives", "ripemd", + "secp256k1", "sha2 0.10.7", "sha3", "substrate-bn", @@ -5548,10 +5568,11 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#ded453ea768a80dbcf27de56b0d35b68c92f140c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ "alloy-primitives", "alloy-rlp", + "arbitrary", "auto_impl", "bitflags 2.4.0", "bitvec", @@ -5563,6 +5584,8 @@ dependencies = [ "hex", "once_cell", "primitive-types", + "proptest", + "proptest-derive 0.4.0", "serde", ] @@ -6016,6 +6039,24 @@ dependencies = [ "zeroize", ] +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "2.9.2" diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 43fa2f5a53573..c2e48b5f4d7a0 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -44,7 +44,7 @@ serde = "1" serde_json = { version = "1", features = ["raw_value"] } semver = "1" bytes = "1" -revm.workspace = true +revm = { workspace = true, default-features = false, features = ["std"] } eyre = "0.6" dirs = "5" time = { version = "0.3", features = ["formatting"] } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 391bb926caf32..0151e321f594a 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -15,7 +15,7 @@ repository.workspace = true ethers-core.workspace = true ethers-solc = { workspace = true, features = ["async", "svm-solc"] } ethers-etherscan.workspace = true -revm-primitives.workspace = true +revm-primitives = { workspace = true, default-features = false, features = ["std"] } # formats Inflector = "0.11" diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index ec3c656d8d7e4..e024882afa3a4 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -19,5 +19,5 @@ alloy-primitives.workspace = true crossterm = "0.26" eyre = "0.6" tracing = "0.1" -revm = { workspace = true, features = ["std", "serde"] } -ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"]} +revm = { workspace = true, default-features = false,features = ["std", "serde", "arbitrary"] } +ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"] } diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 50455bc787002..0727dd7373669 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -47,6 +47,7 @@ revm = { workspace = true, default-features = false, features = [ "optional_eip3607", "optional_block_gas_limit", "optional_no_base_fee", + "arbitrary" ] } alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde", "getrandom", "arbitrary", "rlp"] } From bdea91c79055e8adcf33e714984edba9a3e33d2a Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 26 Sep 2023 09:49:32 -0400 Subject: [PATCH 0120/1963] feat: chisel migration (#5908) * feat: migrate executor * feat: migrate runner * chore: finish executor/dispatcher mig * chore: cleanup * chore: use once_cell instead of contract::Lazy --- Cargo.lock | 3 + Cargo.toml | 3 + crates/chisel/Cargo.toml | 6 + crates/chisel/src/dispatcher.rs | 35 ++-- crates/chisel/src/executor.rs | 290 +++++++++++++++++--------------- crates/chisel/src/runner.rs | 49 ++---- 6 files changed, 195 insertions(+), 191 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ce26ff9757c8..5713f4d9fc096 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1010,6 +1010,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" name = "chisel" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", "bytes", "clap", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 5cd9d3baad415..41f1dd5ef26f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -151,8 +151,11 @@ ethers-middleware = { version = "2.0", default-features = false } ethers-etherscan = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } +## alloy + alloy-primitives = { version = "0.3", default-features = false } alloy-dyn-abi = { version = "0.3", default-features = false } +alloy-json-abi = { version = "0.3", default-features = false } solang-parser = "=0.3.2" diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index c2e48b5f4d7a0..7b8960551e548 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -30,6 +30,11 @@ forge-fmt.workspace = true ethers.workspace = true ethers-solc = { workspace = true, features = ["project-util", "full"] } +# alloy +alloy-dyn-abi = { workspace = true, default-features = false, features = ["std", "arbitrary"] } +alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde", "getrandom", "arbitrary", "rlp"] } +alloy-json-abi = { workspace = true, default-features = false, features = ["std"]} + # async tokio = { version = "1", features = ["full"] } reqwest = { version = "0.11", default-features = false } @@ -49,6 +54,7 @@ eyre = "0.6" dirs = "5" time = { version = "0.3", features = ["formatting"] } regex = "1" +once_cell = "1.18.0" [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 9aa4509f7884f..f9fbc2ad36c1a 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -7,7 +7,8 @@ use crate::prelude::{ ChiselCommand, ChiselResult, ChiselSession, CmdCategory, CmdDescriptor, SessionSourceConfig, SolidityHelper, }; -use ethers::{abi::ParamType, contract::Lazy, types::Address, utils::hex}; +use alloy_json_abi::JsonAbi; +use alloy_primitives::{hex, Address}; use forge_fmt::FormatterConfig; use foundry_config::{Config, RpcEndpoint}; use foundry_evm::{ @@ -17,6 +18,8 @@ use foundry_evm::{ CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, }; +use foundry_utils::types::ToEthers; +use once_cell::sync::Lazy; use regex::Regex; use reqwest::Url; use serde::{Deserialize, Serialize}; @@ -87,17 +90,7 @@ pub struct EtherscanABIResponse { macro_rules! format_param { ($param:expr) => {{ let param = $param; - format!( - "{}{}", - param.kind, - if param.kind.is_dynamic() || - matches!(param.kind, ParamType::FixedArray(_, _) | ParamType::Tuple(_)) - { - " memory" - } else { - "" - } - ) + format!("{}{}", param.ty, if param.is_complex_type() { " memory" } else { "" }) }}; } @@ -537,7 +530,9 @@ impl ChiselDispatcher { let json = response.json::().await.unwrap(); if json.status == "1" && json.result.is_some() { let abi = json.result.unwrap(); - if let Ok(abi) = ethers::abi::Abi::load(abi.as_bytes()) { + let abi: serde_json::Result = + serde_json::from_slice(abi.as_bytes()); + if let Ok(abi) = abi { let mut interface = format!( "// Interface of {}\ninterface {} {{\n", args[0], args[1] @@ -564,7 +559,7 @@ impl ChiselDispatcher { .inputs .iter() .map(|input| { - let mut formatted = format!("{}", input.kind); + let mut formatted = input.ty.to_string(); if input.indexed { formatted.push_str(" indexed"); } @@ -585,9 +580,9 @@ impl ChiselDispatcher { .collect::>() .join(","), match func.state_mutability { - ethers::abi::StateMutability::Pure => " pure", - ethers::abi::StateMutability::View => " view", - ethers::abi::StateMutability::Payable => " payable", + alloy_json_abi::StateMutability::Pure => " pure", + alloy_json_abi::StateMutability::View => " view", + alloy_json_abi::StateMutability::Payable => " payable", _ => "", }, if func.outputs.is_empty() { @@ -844,7 +839,7 @@ impl ChiselDispatcher { // We can always safely unwrap here due to the regex matching. let addr: Address = match_str.parse().expect("Valid address regex"); // Replace all occurrences of the address with a checksummed version - heap_input = heap_input.replace(match_str, ðers::utils::to_checksum(&addr, None)); + heap_input = heap_input.replace(match_str, &addr.to_checksum(None)); }); // Replace the old input with the formatted input. input = &heap_input; @@ -959,7 +954,9 @@ impl ChiselDispatcher { )?; let mut decoder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) + .with_labels( + result.labeled_addresses.iter().map(|(a, s)| ((*a).to_ethers(), s.clone())), + ) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), session_config.foundry_config.offline, diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index eb86917dd54ef..548e202e397cf 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -5,12 +5,10 @@ use crate::prelude::{ ChiselDispatcher, ChiselResult, ChiselRunner, IntermediateOutput, SessionSource, SolidityHelper, }; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_json_abi::EventParam; +use alloy_primitives::{hex, Address, U256}; use core::fmt::Debug; -use ethers::{ - abi::{ethabi, ParamType, Token}, - types::{Address, I256, U256}, - utils::hex, -}; use ethers_solc::Artifact; use eyre::{Result, WrapErr}; use foundry_evm::{ @@ -19,9 +17,10 @@ use foundry_evm::{ }; use foundry_utils::types::ToEthers; use solang_parser::pt::{self, CodeLocation}; +use std::str::FromStr; use yansi::Paint; -const USIZE_MAX_AS_U256: U256 = U256([usize::MAX as u64, 0, 0, 0]); +const USIZE_MAX_AS_U256: U256 = U256::from_limbs([usize::MAX as u64, 0, 0, 0]); /// Executor implementation for [SessionSource] impl SessionSource { @@ -108,10 +107,10 @@ impl SessionSource { let mut runner = self.prepare_runner(final_pc).await; // Return [ChiselResult] or bubble up error - runner.run(bytecode.into_owned()) + runner.run(bytecode.into_owned().0.into()) } else { // Return a default result if no statements are present. - Ok((Address::zero(), ChiselResult::default())) + Ok((Address::ZERO, ChiselResult::default())) } } else { eyre::bail!("Failed to find REPL contract!") @@ -225,13 +224,13 @@ impl SessionSource { // the `bytes memory inspectoor` value let mut offset = stack.data().last().unwrap().to_ethers().as_usize(); let mem = memory.data(); - let len = U256::from(&mem[offset..offset + 32]).as_usize(); + let mem_offset = &mem[offset..offset + 32]; + let len = U256::try_from_be_slice(mem_offset).unwrap().to::(); offset += 32; let data = &mem[offset..offset + len]; - let mut tokens = - ethabi::decode(&[ty], data).wrap_err("Could not decode inspected values")?; // `tokens` is guaranteed to have the same length as the provided types - let token = tokens.pop().unwrap(); + let token = + DynSolType::decode_single(&ty, data).wrap_err("Could not decode inspected values")?; Ok((should_continue(contract_expr), Some(format_token(token)))) } @@ -302,7 +301,7 @@ impl SessionSource { // Create a [ChiselRunner] with a default balance of [U256::MAX] and // the sender [Address::zero]. - ChiselRunner::new(executor, U256::MAX, Address::zero(), self.config.calldata.clone()) + ChiselRunner::new(executor, U256::MAX, Address::ZERO, self.config.calldata.clone()) } } @@ -317,27 +316,27 @@ impl SessionSource { /// A formatted [Token] for use in inspection output. /// /// TODO: Verbosity option -fn format_token(token: Token) -> String { +fn format_token(token: DynSolValue) -> String { match token { - Token::Address(a) => { + DynSolValue::Address(a) => { format!("Type: {}\n└ Data: {}", Paint::red("address"), Paint::cyan(format!("0x{a:x}"))) } - Token::FixedBytes(b) => { + DynSolValue::FixedBytes(b, _) => { format!( "Type: {}\n└ Data: {}", Paint::red(format!("bytes{}", b.len())), Paint::cyan(format!("0x{}", hex::encode(b))) ) } - Token::Int(i) => { + DynSolValue::Int(i, _) => { format!( "Type: {}\n├ Hex: {}\n└ Decimal: {}", Paint::red("int"), Paint::cyan(format!("0x{i:x}")), - Paint::cyan(I256::from_raw(i)) + Paint::cyan(i) ) } - Token::Uint(i) => { + DynSolValue::Uint(i, _) => { format!( "Type: {}\n├ Hex: {}\n└ Decimal: {}", Paint::red("uint"), @@ -345,12 +344,12 @@ fn format_token(token: Token) -> String { Paint::cyan(i) ) } - Token::Bool(b) => { + DynSolValue::Bool(b) => { format!("Type: {}\n└ Value: {}", Paint::red("bool"), Paint::cyan(b)) } - Token::String(_) | Token::Bytes(_) => { - let hex = hex::encode(ethers::abi::encode(&[token.clone()])); - let s = token.into_string(); + DynSolValue::String(_) | DynSolValue::Bytes(_) => { + let hex = hex::encode(token.encode_single()); + let s = token.as_str().map(|s| s.to_owned()); format!( "Type: {}\n{}├ Hex (Memory):\n├─ Length ({}): {}\n├─ Contents ({}): {}\n├ Hex (Tuple Encoded):\n├─ Pointer ({}): {}\n├─ Length ({}): {}\n└─ Contents ({}): {}", Paint::red(if s.is_some() { "string" } else { "dynamic bytes" }), @@ -371,7 +370,7 @@ fn format_token(token: Token) -> String { Paint::cyan(format!("0x{}", &hex[128..])), ) } - Token::FixedArray(tokens) | Token::Array(tokens) => { + DynSolValue::FixedArray(tokens) | DynSolValue::Array(tokens) => { let mut out = format!( "{}({}) = {}", Paint::red("array"), @@ -386,11 +385,17 @@ fn format_token(token: Token) -> String { out.push_str(&Paint::red(']').to_string()); out } - Token::Tuple(tokens) => { + DynSolValue::Tuple(tokens) => { + let displayed_types = tokens + .iter() + .map(|t| t.sol_type_name().to_owned()) + .map(|t| t.unwrap_or_default().into_owned()) + .collect::>() + .join(", "); let mut out = format!( "{}({}) = {}", Paint::red("tuple"), - Paint::yellow(tokens.iter().map(ToString::to_string).collect::>().join(",")), + Paint::yellow(displayed_types), Paint::red('(') ); for token in tokens { @@ -401,6 +406,9 @@ fn format_token(token: Token) -> String { out.push_str(&Paint::red(')').to_string()); out } + _ => { + unimplemented!() + } } } @@ -429,10 +437,17 @@ fn format_event_definition(event_definition: &pt::EventDefinition) -> Result>>()?; - let event = ethabi::Event { name: event_name, inputs, anonymous: event_definition.anonymous }; + let event = + alloy_json_abi::Event { name: event_name, inputs, anonymous: event_definition.anonymous }; Ok(format!( "Type: {}\n├ Name: {}\n└ Signature: {:?}", @@ -445,7 +460,7 @@ fn format_event_definition(event_definition: &pt::EventDefinition) -> Result Result), @@ -519,7 +534,7 @@ impl Type { if n > USIZE_MAX_AS_U256 { None } else { - Some(n.as_usize()) + Some(n.to::()) } }); match expr.as_ref() { @@ -586,19 +601,19 @@ impl Type { } // address - pt::Expression::AddressLiteral(_, _) => Some(Self::Builtin(ParamType::Address)), + pt::Expression::AddressLiteral(_, _) => Some(Self::Builtin(DynSolType::Address)), pt::Expression::HexNumberLiteral(_, s, _) => { match s.parse() { Ok(addr) => { let checksummed = ethers::utils::to_checksum(&addr, None); if *s == checksummed { - Some(Self::Builtin(ParamType::Address)) + Some(Self::Builtin(DynSolType::Address)) } else { - Some(Self::Builtin(ParamType::Uint(256))) + Some(Self::Builtin(DynSolType::Uint(256))) } }, _ => { - Some(Self::Builtin(ParamType::Uint(256))) + Some(Self::Builtin(DynSolType::Uint(256))) } } } @@ -615,13 +630,13 @@ impl Type { pt::Expression::Multiply(_, lhs, rhs) | pt::Expression::Divide(_, lhs, rhs) => { match (Self::ethabi(lhs, None), Self::ethabi(rhs, None)) { - (Some(ParamType::Int(_)), Some(ParamType::Int(_))) | - (Some(ParamType::Int(_)), Some(ParamType::Uint(_))) | - (Some(ParamType::Uint(_)), Some(ParamType::Int(_))) => { - Some(Self::Builtin(ParamType::Int(256))) + (Some(DynSolType::Int(_)), Some(DynSolType::Int(_))) | + (Some(DynSolType::Int(_)), Some(DynSolType::Uint(_))) | + (Some(DynSolType::Uint(_)), Some(DynSolType::Int(_))) => { + Some(Self::Builtin(DynSolType::Int(256))) } _ => { - Some(Self::Builtin(ParamType::Uint(256))) + Some(Self::Builtin(DynSolType::Uint(256))) } } } @@ -634,11 +649,11 @@ impl Type { pt::Expression::BitwiseXor(_, _, _) | pt::Expression::ShiftRight(_, _, _) | pt::Expression::ShiftLeft(_, _, _) | - pt::Expression::NumberLiteral(_, _, _, _) => Some(Self::Builtin(ParamType::Uint(256))), + pt::Expression::NumberLiteral(_, _, _, _) => Some(Self::Builtin(DynSolType::Uint(256))), // TODO: Rational numbers pt::Expression::RationalNumberLiteral(_, _, _, _, _) => { - Some(Self::Builtin(ParamType::Uint(256))) + Some(Self::Builtin(DynSolType::Uint(256))) } // bool @@ -651,13 +666,13 @@ impl Type { pt::Expression::LessEqual(_, _, _) | pt::Expression::More(_, _, _) | pt::Expression::MoreEqual(_, _, _) | - pt::Expression::Not(_, _) => Some(Self::Builtin(ParamType::Bool)), + pt::Expression::Not(_, _) => Some(Self::Builtin(DynSolType::Bool)), // string - pt::Expression::StringLiteral(_) => Some(Self::Builtin(ParamType::String)), + pt::Expression::StringLiteral(_) => Some(Self::Builtin(DynSolType::String)), // bytes - pt::Expression::HexLiteral(_) => Some(Self::Builtin(ParamType::Bytes)), + pt::Expression::HexLiteral(_) => Some(Self::Builtin(DynSolType::Bytes)), // function pt::Expression::FunctionCall(_, name, args) => { @@ -690,14 +705,14 @@ impl Type { fn from_type(ty: &pt::Type) -> Option { let ty = match ty { pt::Type::Address | pt::Type::AddressPayable | pt::Type::Payable => { - Self::Builtin(ParamType::Address) + Self::Builtin(DynSolType::Address) } - pt::Type::Bool => Self::Builtin(ParamType::Bool), - pt::Type::String => Self::Builtin(ParamType::String), - pt::Type::Int(size) => Self::Builtin(ParamType::Int(*size as usize)), - pt::Type::Uint(size) => Self::Builtin(ParamType::Uint(*size as usize)), - pt::Type::Bytes(size) => Self::Builtin(ParamType::FixedBytes(*size as usize)), - pt::Type::DynamicBytes => Self::Builtin(ParamType::Bytes), + pt::Type::Bool => Self::Builtin(DynSolType::Bool), + pt::Type::String => Self::Builtin(DynSolType::String), + pt::Type::Int(size) => Self::Builtin(DynSolType::Int(*size as usize)), + pt::Type::Uint(size) => Self::Builtin(DynSolType::Uint(*size as usize)), + pt::Type::Bytes(size) => Self::Builtin(DynSolType::FixedBytes(*size as usize)), + pt::Type::DynamicBytes => Self::Builtin(DynSolType::Bytes), pt::Type::Mapping { value, .. } => Self::from_expression(value)?, pt::Type::Function { params, returns, .. } => { let params = map_parameters(params); @@ -741,7 +756,7 @@ impl Type { let ty = Self::Builtin(ty); match access.as_str() { "length" if ty.is_dynamic() || ty.is_array() => { - return Self::Builtin(ParamType::Uint(256)) + return Self::Builtin(DynSolType::Uint(256)) } "pop" if ty.is_dynamic_array() => return ty, _ => {} @@ -756,31 +771,31 @@ impl Type { match len { 0 => unreachable!(), 1 => match name { - "gasleft" | "addmod" | "mulmod" => Some(ParamType::Uint(256)), - "keccak256" | "sha256" | "blockhash" => Some(ParamType::FixedBytes(32)), - "ripemd160" => Some(ParamType::FixedBytes(20)), - "ecrecover" => Some(ParamType::Address), + "gasleft" | "addmod" | "mulmod" => Some(DynSolType::Uint(256)), + "keccak256" | "sha256" | "blockhash" => Some(DynSolType::FixedBytes(32)), + "ripemd160" => Some(DynSolType::FixedBytes(20)), + "ecrecover" => Some(DynSolType::Address), _ => None, }, 2 => { let access = types.first().unwrap().as_str(); match name { "block" => match access { - "coinbase" => Some(ParamType::Address), + "coinbase" => Some(DynSolType::Address), "basefee" | "chainid" | "difficulty" | "gaslimit" | "number" | - "timestamp" => Some(ParamType::Uint(256)), + "timestamp" => Some(DynSolType::Uint(256)), _ => None, }, "msg" => match access { - "data" => Some(ParamType::Bytes), - "sender" => Some(ParamType::Address), - "sig" => Some(ParamType::FixedBytes(4)), - "value" => Some(ParamType::Uint(256)), + "data" => Some(DynSolType::Bytes), + "sender" => Some(DynSolType::Address), + "sig" => Some(DynSolType::FixedBytes(4)), + "value" => Some(DynSolType::Uint(256)), _ => None, }, "tx" => match access { - "gasprice" => Some(ParamType::Uint(256)), - "origin" => Some(ParamType::Address), + "gasprice" => Some(DynSolType::Uint(256)), + "origin" => Some(DynSolType::Address), _ => None, }, "abi" => match access { @@ -800,20 +815,20 @@ impl Type { None => None, } } - s if s.starts_with("encode") => Some(ParamType::Bytes), + s if s.starts_with("encode") => Some(DynSolType::Bytes), _ => None, }, "address" => match access { - "balance" => Some(ParamType::Uint(256)), - "code" => Some(ParamType::Bytes), - "codehash" => Some(ParamType::FixedBytes(32)), - "send" => Some(ParamType::Bool), + "balance" => Some(DynSolType::Uint(256)), + "code" => Some(DynSolType::Bytes), + "codehash" => Some(DynSolType::FixedBytes(32)), + "send" => Some(DynSolType::Bool), _ => None, }, "type" => match access { - "name" => Some(ParamType::String), - "creationCode" | "runtimeCode" => Some(ParamType::Bytes), - "interfaceId" => Some(ParamType::FixedBytes(4)), + "name" => Some(DynSolType::String), + "creationCode" | "runtimeCode" => Some(DynSolType::Bytes), + "interfaceId" => Some(DynSolType::FixedBytes(4)), "min" | "max" => { let arg = args.unwrap().pop().flatten().unwrap(); Some(arg.into_builtin().unwrap()) @@ -821,11 +836,11 @@ impl Type { _ => None, }, "string" => match access { - "concat" => Some(ParamType::String), + "concat" => Some(DynSolType::String), _ => None, }, "bytes" => match access { - "concat" => Some(ParamType::Bytes), + "concat" => Some(DynSolType::Bytes), _ => None, }, _ => None, @@ -875,14 +890,14 @@ impl Type { /// /// ### Returns /// - /// If successful, an `Ok(Some(ParamType))` variant. + /// If successful, an `Ok(Some(DynSolType))` variant. /// If gracefully failed, an `Ok(None)` variant. /// If failed, an `Err(e)` variant. fn infer_custom_type( intermediate: &IntermediateOutput, custom_type: &mut Vec, contract_name: Option, - ) -> Result> { + ) -> Result> { if let Some("this") | Some("super") = custom_type.last().map(String::as_str) { custom_type.pop(); } @@ -953,7 +968,7 @@ impl Type { .ok_or_else(|| eyre::eyre!("Struct `{cur_type}` has invalid fields")) }) .collect::>>()?; - Ok(Some(ParamType::Tuple(inner_types))) + Ok(Some(DynSolType::Tuple(inner_types))) } else { eyre::bail!("Could not find any definition in contract \"{contract_name}\" for type: {custom_type:?}") } @@ -991,7 +1006,7 @@ impl Type { expr: &pt::Expression, intermediate: Option<&IntermediateOutput>, custom_type: &mut Vec, - ) -> Result> { + ) -> Result> { // Resolve local (in `run` function) or global (in the `REPL` or other contract) variable let res = match &expr { // Custom variable handling @@ -1009,7 +1024,7 @@ impl Type { Self::infer_custom_type(intermediate, custom_type, Some(name.clone())) } else { // We have no types left to recurse: return the address of the contract. - Ok(Some(ParamType::Address)) + Ok(Some(DynSolType::Address)) } } else { Err(eyre::eyre!("Could not infer variable type")) @@ -1036,28 +1051,28 @@ impl Type { } } - /// Attempt to convert this type into a [ParamType] + /// Attempt to convert this type into a [DynSolType] /// /// ### Takes /// An immutable reference to an [IntermediateOutput] /// /// ### Returns - /// Optionally, a [ParamType] - fn try_as_ethabi(self, intermediate: Option<&IntermediateOutput>) -> Option { + /// Optionally, a [DynSolType] + fn try_as_ethabi(self, intermediate: Option<&IntermediateOutput>) -> Option { match self { Self::Builtin(ty) => Some(ty), - Self::Tuple(types) => Some(ParamType::Tuple(types_to_parameters(types, intermediate))), + Self::Tuple(types) => Some(DynSolType::Tuple(types_to_parameters(types, intermediate))), Self::Array(inner) => match *inner { ty @ Self::Custom(_) => ty.try_as_ethabi(intermediate), - _ => { - inner.try_as_ethabi(intermediate).map(|inner| ParamType::Array(Box::new(inner))) - } + _ => inner + .try_as_ethabi(intermediate) + .map(|inner| DynSolType::Array(Box::new(inner))), }, Self::FixedArray(inner, size) => match *inner { ty @ Self::Custom(_) => ty.try_as_ethabi(intermediate), _ => inner .try_as_ethabi(intermediate) - .map(|inner| ParamType::FixedArray(Box::new(inner), size)), + .map(|inner| DynSolType::FixedArray(Box::new(inner), size)), }, ty @ Self::ArrayIndex(_, _) => ty.into_array_index(intermediate), Self::Function(ty, _, _) => ty.try_as_ethabi(intermediate), @@ -1076,7 +1091,7 @@ impl Type { fn ethabi( expr: &pt::Expression, intermediate: Option<&IntermediateOutput>, - ) -> Option { + ) -> Option { Self::from_expression(expr) .map(Self::map_special) .and_then(|ty| ty.try_as_ethabi(intermediate)) @@ -1086,7 +1101,7 @@ impl Type { fn get_function_return_type<'a>( contract_expr: Option<&'a pt::Expression>, intermediate: &IntermediateOutput, - ) -> Option<(&'a pt::Expression, ParamType)> { + ) -> Option<(&'a pt::Expression, DynSolType)> { let function_call = match contract_expr? { pt::Expression::FunctionCall(_, function_call, _) => function_call, _ => return None, @@ -1120,31 +1135,31 @@ impl Type { /// Inverts Int to Uint and viceversa. fn invert_int(self) -> Self { match self { - Self::Builtin(ParamType::Uint(n)) => Self::Builtin(ParamType::Int(n)), - Self::Builtin(ParamType::Int(n)) => Self::Builtin(ParamType::Uint(n)), + Self::Builtin(DynSolType::Uint(n)) => Self::Builtin(DynSolType::Int(n)), + Self::Builtin(DynSolType::Int(n)) => Self::Builtin(DynSolType::Uint(n)), x => x, } } - /// Returns the `ParamType` contained by `Type::Builtin` + /// Returns the `DynSolType` contained by `Type::Builtin` #[inline] - fn into_builtin(self) -> Option { + fn into_builtin(self) -> Option { match self { Self::Builtin(ty) => Some(ty), _ => None, } } - /// Returns the resulting `ParamType` of indexing self - fn into_array_index(self, intermediate: Option<&IntermediateOutput>) -> Option { + /// Returns the resulting `DynSolType` of indexing self + fn into_array_index(self, intermediate: Option<&IntermediateOutput>) -> Option { match self { Self::Array(inner) | Self::FixedArray(inner, _) | Self::ArrayIndex(inner, _) => { match inner.try_as_ethabi(intermediate) { - Some(ParamType::Array(inner)) | Some(ParamType::FixedArray(inner, _)) => { + Some(DynSolType::Array(inner)) | Some(DynSolType::FixedArray(inner, _)) => { Some(*inner) } - Some(ParamType::Bytes) | Some(ParamType::String) => { - Some(ParamType::FixedBytes(1)) + Some(DynSolType::Bytes) | Some(DynSolType::String) => { + Some(DynSolType::FixedBytes(1)) } ty => ty, } @@ -1157,7 +1172,12 @@ impl Type { #[inline] fn is_dynamic(&self) -> bool { match self { - Self::Builtin(ty) => ty.is_dynamic(), + Self::Builtin(ty) => match ty { + // TODO: Note, this is not entirely correct. Fixed arrays of non-dynamic types are + // not dynamic, nor are tuples of non-dynamic types. + DynSolType::Bytes | DynSolType::String | DynSolType::Array(_) => true, + _ => false, + }, Self::Array(_) => true, _ => false, } @@ -1170,15 +1190,15 @@ impl Type { self, Self::Array(_) | Self::FixedArray(_, _) | - Self::Builtin(ParamType::Array(_)) | - Self::Builtin(ParamType::FixedArray(_, _)) + Self::Builtin(DynSolType::Array(_)) | + Self::Builtin(DynSolType::FixedArray(_, _)) ) } /// Returns whether this type is a dynamic array (can call push, pop) #[inline] fn is_dynamic_array(&self) -> bool { - matches!(self, Self::Array(_) | Self::Builtin(ParamType::Array(_))) + matches!(self, Self::Array(_) | Self::Builtin(DynSolType::Array(_))) } } @@ -1186,7 +1206,7 @@ impl Type { /// /// Ref: #[inline] -fn func_members(func: &pt::FunctionDefinition, custom_type: &[String]) -> Option { +fn func_members(func: &pt::FunctionDefinition, custom_type: &[String]) -> Option { if !matches!(func.ty, pt::FunctionTy::Function) { return None } @@ -1198,8 +1218,8 @@ fn func_members(func: &pt::FunctionDefinition, custom_type: &[String]) -> Option match vis { Some(pt::Visibility::External(_)) | Some(pt::Visibility::Public(_)) => { match custom_type.first().unwrap().as_str() { - "address" => Some(ParamType::Address), - "selector" => Some(ParamType::FixedBytes(4)), + "address" => Some(DynSolType::Address), + "selector" => Some(DynSolType::FixedBytes(4)), _ => None, } } @@ -1254,14 +1274,14 @@ fn map_parameters(params: &[(pt::Loc, Option)]) -> Vec>, intermediate: Option<&IntermediateOutput>, -) -> Vec { +) -> Vec { types.into_iter().filter_map(|ty| ty.and_then(|ty| ty.try_as_ethabi(intermediate))).collect() } fn parse_number_literal(expr: &pt::Expression) -> Option { match expr { pt::Expression::NumberLiteral(_, num, exp, unit) => { - let num = U256::from_dec_str(num).unwrap_or(U256::zero()); + let num = U256::from_str(num).unwrap_or(U256::ZERO); let exp = exp.parse().unwrap_or(0u32); if exp > 77 { None @@ -1295,9 +1315,9 @@ fn unit_multiplier(unit: &Option) -> Result { "ether" => 10_usize.pow(18), other => eyre::bail!("unknown unit: {other}"), }; - Ok(mul.into()) + Ok(U256::from(mul)) } else { - Ok(U256::one()) + Ok(U256::from(1)) } } @@ -1347,14 +1367,14 @@ mod tests { #[test] fn test_const() { - assert_eq!(USIZE_MAX_AS_U256.low_u64(), usize::MAX as u64); - assert_eq!(USIZE_MAX_AS_U256.as_u64(), usize::MAX as u64); + assert_eq!(USIZE_MAX_AS_U256.to::(), usize::MAX as u64); + assert_eq!(USIZE_MAX_AS_U256.to::(), usize::MAX as u64); } #[test] fn test_expressions() { - static EXPRESSIONS: &[(&str, ParamType)] = { - use ParamType::*; + static EXPRESSIONS: &[(&str, DynSolType)] = { + use DynSolType::*; &[ // units // uint @@ -1439,13 +1459,13 @@ mod tests { let source = &mut source(); - let array_expressions: &[(&str, ParamType)] = &[ - ("[1, 2, 3]", fixed_array(ParamType::Uint(256), 3)), - ("[uint8(1), 2, 3]", fixed_array(ParamType::Uint(8), 3)), - ("[int8(1), 2, 3]", fixed_array(ParamType::Int(8), 3)), - ("new uint256[](3)", array(ParamType::Uint(256))), - ("uint256[] memory a = new uint256[](3);\na[0]", ParamType::Uint(256)), - ("uint256[] memory a = new uint256[](3);\na[0:3]", array(ParamType::Uint(256))), + let array_expressions: &[(&str, DynSolType)] = &[ + ("[1, 2, 3]", fixed_array(DynSolType::Uint(256), 3)), + ("[uint8(1), 2, 3]", fixed_array(DynSolType::Uint(8), 3)), + ("[int8(1), 2, 3]", fixed_array(DynSolType::Int(8), 3)), + ("new uint256[](3)", array(DynSolType::Uint(256))), + ("uint256[] memory a = new uint256[](3);\na[0]", DynSolType::Uint(256)), + ("uint256[] memory a = new uint256[](3);\na[0:3]", array(DynSolType::Uint(256))), ]; generic_type_test(source, array_expressions); generic_type_test(source, EXPRESSIONS); @@ -1453,8 +1473,8 @@ mod tests { #[test] fn test_types() { - static TYPES: &[(&str, ParamType)] = { - use ParamType::*; + static TYPES: &[(&str, DynSolType)] = { + use DynSolType::*; &[ // bool ("bool", Bool), @@ -1498,17 +1518,17 @@ mod tests { ] }; - let mut types: Vec<(String, ParamType)> = Vec::with_capacity(96 + 32 + 100); + let mut types: Vec<(String, DynSolType)> = Vec::with_capacity(96 + 32 + 100); for (n, b) in (8..=256).step_by(8).zip(1..=32) { - types.push((format!("uint{n}(0)"), ParamType::Uint(n))); - types.push((format!("int{n}(0)"), ParamType::Int(n))); - types.push((format!("bytes{b}(0x00)"), ParamType::FixedBytes(b))); + types.push((format!("uint{n}(0)"), DynSolType::Uint(n))); + types.push((format!("int{n}(0)"), DynSolType::Int(n))); + types.push((format!("bytes{b}(0x00)"), DynSolType::FixedBytes(b))); } for n in 0..=32 { types.push(( format!("uint256[{n}]"), - ParamType::FixedArray(Box::new(ParamType::Uint(256)), n), + DynSolType::FixedArray(Box::new(DynSolType::Uint(256)), n), )); } @@ -1520,7 +1540,7 @@ mod tests { fn test_global_vars() { // https://docs.soliditylang.org/en/latest/cheatsheet.html#global-variables let global_variables = { - use ParamType::*; + use DynSolType::*; &[ // abi ("abi.decode(bytes, (uint8[13]))", Tuple(vec![FixedArray(Box::new(Uint(8)), 13)])), @@ -1645,12 +1665,12 @@ mod tests { SessionSource::new(solc, Default::default()) } - fn array(ty: ParamType) -> ParamType { - ParamType::Array(Box::new(ty)) + fn array(ty: DynSolType) -> DynSolType { + DynSolType::Array(Box::new(ty)) } - fn fixed_array(ty: ParamType, len: usize) -> ParamType { - ParamType::FixedArray(Box::new(ty), len) + fn fixed_array(ty: DynSolType, len: usize) -> DynSolType { + DynSolType::FixedArray(Box::new(ty), len) } fn parse(s: &mut SessionSource, input: &str, clear: bool) -> IntermediateOutput { @@ -1693,7 +1713,7 @@ mod tests { (Type::from_expression(&expr).map(Type::map_special), intermediate) } - fn get_type_ethabi(s: &mut SessionSource, input: &str, clear: bool) -> Option { + fn get_type_ethabi(s: &mut SessionSource, input: &str, clear: bool) -> Option { let (ty, intermediate) = get_type(s, input, clear); ty.and_then(|ty| ty.try_as_ethabi(Some(&intermediate))) } @@ -1702,7 +1722,7 @@ mod tests { fn generic_type_test<'a, T, I>(s: &mut SessionSource, input: I) where T: AsRef + std::fmt::Display + 'a, - I: IntoIterator + 'a, + I: IntoIterator + 'a, { for (input, expected) in input.into_iter() { let input = input.as_ref(); diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index e0e1cfa57300c..b99eeee47c15c 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -3,17 +3,13 @@ //! This module contains the `ChiselRunner` struct, which assists with deploying //! and calling the REPL contract on a in-memory REVM instance. -use ethers::{ - prelude::{types::U256, Address}, - types::{Bytes, Log}, -}; +use alloy_primitives::{Address, Bytes, U256}; +use ethers::types::Log; use eyre::Result; use foundry_evm::{ executor::{DeployResult, Executor, RawCallResult}, - revm::primitives::U256 as rU256, trace::{CallTraceArena, TraceKind}, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use revm::interpreter::{return_ok, InstructionResult}; use std::collections::BTreeMap; @@ -94,17 +90,17 @@ impl ChiselRunner { /// contract. pub fn run(&mut self, bytecode: Bytes) -> Result<(Address, ChiselResult)> { // Set the sender's balance to [U256::MAX] for deployment of the REPL contract. - self.executor.set_balance(self.sender.to_alloy(), rU256::MAX)?; + self.executor.set_balance(self.sender, U256::MAX)?; // Deploy an instance of the REPL contract // We don't care about deployment traces / logs here let DeployResult { address, .. } = self .executor - .deploy(self.sender.to_alloy(), bytecode.0.into(), rU256::ZERO, None) + .deploy(self.sender, bytecode.0.into(), U256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy REPL contract:\n{}", err))?; // Reset the sender's balance to the initial balance for calls. - self.executor.set_balance(self.sender.to_alloy(), self.initial_balance.to_alloy())?; + self.executor.set_balance(self.sender, self.initial_balance)?; // Append the input to the `RUN_SELECTOR` to form the calldata let mut calldata = RUN_SELECTOR.to_vec(); @@ -113,10 +109,9 @@ impl ChiselRunner { } // Call the "run()" function of the REPL contract - let call_res = - self.call(self.sender, address.to_ethers(), Bytes::from(calldata), 0.into(), true); + let call_res = self.call(self.sender, address, Bytes::from(calldata), U256::from(0), true); - call_res.map(|res| (address.to_ethers(), res)) + call_res.map(|res| (address, res)) } /// Executes the call @@ -143,12 +138,7 @@ impl ChiselRunner { false }; - let mut res = self.executor.call_raw( - from.to_alloy(), - to.to_alloy(), - calldata.0.clone().into(), - value.to_alloy(), - )?; + let mut res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { // store the current gas limit and reset it later @@ -164,12 +154,7 @@ impl ChiselRunner { while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; self.executor.env.tx.gas_limit = mid_gas_limit; - let res = self.executor.call_raw( - from.to_alloy(), - to.to_alloy(), - calldata.0.clone().into(), - value.to_alloy(), - )?; + let res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; match res.exit_reason { InstructionResult::Revert | InstructionResult::OutOfGas | @@ -204,22 +189,12 @@ impl ChiselRunner { cheatcodes.fs_commit = !cheatcodes.fs_commit; } - res = self.executor.call_raw( - from.to_alloy(), - to.to_alloy(), - calldata.0.clone().into(), - value.to_alloy(), - )?; + res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; } if commit { // if explicitly requested we can now commit the call - res = self.executor.call_raw_committing( - from.to_alloy(), - to.to_alloy(), - calldata.0.clone().into(), - value.to_alloy(), - )?; + res = self.executor.call_raw_committing(from, to, calldata.0.clone().into(), value)?; } let RawCallResult { result, reverted, logs, traces, labels, chisel_state, .. } = res; @@ -237,7 +212,7 @@ impl ChiselRunner { vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), - labeled_addresses: labels.into_iter().map(|l| (l.0.to_ethers(), l.1)).collect(), + labeled_addresses: labels, address: None, state: chisel_state, }) From 80df71fccb138e6c8a9399f2cc8f2264ef1288bc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Sep 2023 19:55:13 +0200 Subject: [PATCH 0121/1963] test: add fuzz-seed tests (#5916) * test: add fuzz-seed tests * fix: value parser for alloy types --- Cargo.lock | 2 ++ crates/cast/bin/cmd/estimate.rs | 11 +++++++++++ crates/cli/Cargo.toml | 4 ++++ crates/cli/src/opts/transaction.rs | 12 ++++++++++++ crates/cli/src/utils/mod.rs | 13 +++++++++++++ crates/forge/bin/cmd/script/mod.rs | 14 +++++++++++--- crates/forge/bin/cmd/test/mod.rs | 16 +++++++++++++++- 7 files changed, 68 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5713f4d9fc096..510ebc0346b70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2598,6 +2598,7 @@ dependencies = [ name = "foundry-cli" version = "0.2.0" dependencies = [ + "alloy-primitives", "async-trait", "clap", "color-eyre", @@ -2609,6 +2610,7 @@ dependencies = [ "foundry-config", "foundry-debugger", "foundry-evm", + "foundry-utils", "indicatif", "itertools 0.11.0", "once_cell", diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 402ea7de56b03..8d2e002945731 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -113,3 +113,14 @@ impl EstimateArgs { Ok(()) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_estimate_value() { + let args: EstimateArgs = EstimateArgs::parse_from(["foundry-cli", "--value", "100"]); + assert!(args.value.is_some()); + } +} diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 67e9b6a21f9af..602cafdcb74ad 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -15,6 +15,7 @@ foundry-config.workspace = true foundry-common.workspace = true foundry-evm.workspace = true foundry-debugger.workspace = true +foundry-utils.workspace = true # aws rusoto_core = { version = "0.48", default-features = false } @@ -23,6 +24,9 @@ rusoto_kms = { version = "0.48", default-features = false } # eth ethers = { workspace = true, features = ["aws", "ledger", "trezor"] } +# alloy +alloy-primitives.workspace = true + async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } color-eyre = "0.6" diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index d32cff8a80588..7b8ca8d48d549 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -46,3 +46,15 @@ pub struct TransactionOpts { #[clap(long)] pub legacy: bool, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_priority_gas_tx_opts() { + let args: TransactionOpts = + TransactionOpts::parse_from(["foundry-cli", "--priority-gas-price", "100"]); + assert!(args.priority_gas_price.is_some()); + } +} diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index d36b1de2b1c07..ba67324eda944 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -83,6 +83,13 @@ pub fn parse_u256(s: &str) -> Result { Ok(if s.starts_with("0x") { U256::from_str(s)? } else { U256::from_dec_str(s)? }) } +/// parse a hex str or decimal str as U256 +// TODO: rm after alloy transition +pub fn alloy_parse_u256(s: &str) -> Result { + use foundry_utils::types::ToAlloy; + Ok(parse_u256(s)?.to_alloy()) +} + /// Returns a [RetryProvider](foundry_common::RetryProvider) instantiated using [Config]'s RPC URL /// and chain. /// @@ -133,6 +140,12 @@ pub fn parse_ether_value(value: &str) -> Result { }) } +// TODO: rm after alloy transition +pub fn alloy_parse_ether_value(value: &str) -> Result { + use foundry_utils::types::ToAlloy; + Ok(parse_ether_value(value)?.to_alloy()) +} + /// Parses a `Duration` from a &str pub fn parse_delay(delay: &str) -> Result { let delay = if delay.ends_with("ms") { diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index f5281a62cde4b..18097142bc4be 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -28,7 +28,7 @@ use forge::{ }, CallKind, }; -use foundry_cli::{opts::MultiWallet, utils::parse_ether_value}; +use foundry_cli::opts::MultiWallet; use foundry_common::{ abi::{encode_args, format_token}, contracts::get_contract_name, @@ -115,7 +115,7 @@ pub struct ScriptArgs { #[clap( long, env = "ETH_PRIORITY_GAS_PRICE", - value_parser = parse_ether_value, + value_parser = foundry_cli::utils::alloy_parse_ether_value, value_name = "PRICE" )] pub priority_gas_price: Option, @@ -192,7 +192,7 @@ pub struct ScriptArgs { #[clap( long, env = "ETH_GAS_PRICE", - value_parser = parse_ether_value, + value_parser = foundry_cli::utils::alloy_parse_ether_value, value_name = "PRICE", )] pub with_gas_price: Option, @@ -982,4 +982,12 @@ mod tests { let etherscan = config.get_etherscan_api_key(Option::::None); assert_eq!(etherscan, Some("polygonkey".to_string())); } + + // + #[test] + fn test_5923() { + let args: ScriptArgs = + ScriptArgs::parse_from(["foundry-cli", "DeployV1", "--priority-gas-price", "100"]); + assert!(args.priority_gas_price.is_some()); + } } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 5869679538e29..15912e5944ca7 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -92,7 +92,7 @@ pub struct TestArgs { list: bool, /// Set seed used to generate randomness during your fuzz runs. - #[clap(long, value_parser = utils::parse_u256)] + #[clap(long, value_parser = utils::alloy_parse_u256)] pub fuzz_seed: Option, #[clap(long, env = "FOUNDRY_FUZZ_RUNS", value_name = "RUNS")] @@ -828,4 +828,18 @@ mod tests { let args: TestArgs = TestArgs::parse_from(["foundry-cli", "-vw"]); assert!(args.watch.watch.is_some()); } + + #[test] + fn test_fuzz_seed() { + let args: TestArgs = TestArgs::parse_from(["foundry-cli", "--fuzz-seed", "0x10"]); + assert!(args.fuzz_seed.is_some()); + } + + // + #[test] + fn test_5913() { + let args: TestArgs = + TestArgs::parse_from(["foundry-cli", "-vvv", "--gas-report", "--fuzz-seed", "0x10"]); + assert!(args.fuzz_seed.is_some()); + } } From dfa3e4cd0ff11e7d9b25580a4880e20e1cefba77 Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Wed, 27 Sep 2023 10:10:45 -0700 Subject: [PATCH 0122/1963] fix(forge):`forge init --template` correctly handles submodules (#5911) * fix: forge init template submodules * appease clippy * update test * add modules check to regular template test --------- Co-authored-by: James Wenzel --- crates/cli/src/utils/mod.rs | 54 +++++++++++++++++++++++++++++++-- crates/forge/bin/cmd/doc.rs | 2 +- crates/forge/bin/cmd/init.rs | 39 +++++++++++++++--------- crates/forge/bin/cmd/install.rs | 4 +-- crates/forge/bin/cmd/update.rs | 2 +- crates/forge/tests/cli/cmd.rs | 4 +++ 6 files changed, 83 insertions(+), 22 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index ba67324eda944..1ae4c08a09be9 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -380,6 +380,22 @@ impl<'a> Git<'a> { .map(drop) } + pub fn fetch( + shallow: bool, + remote: impl AsRef, + branch: Option>, + ) -> Result<()> { + Self::cmd_no_root() + .stderr(Stdio::inherit()) + .arg("fetch") + .args(shallow.then_some("--no-tags")) + .args(shallow.then_some("--depth=1")) + .arg(remote) + .args(branch) + .exec() + .map(drop) + } + #[inline] pub fn root(self, root: &Path) -> Git<'_> { Git { root, ..self } @@ -418,6 +434,23 @@ impl<'a> Git<'a> { self.cmd().arg("add").args(paths).exec().map(drop) } + pub fn reset(self, hard: bool, tree: impl AsRef) -> Result<()> { + self.cmd().arg("reset").args(hard.then_some("--hard")).arg(tree).exec().map(drop) + } + + pub fn commit_tree( + self, + tree: impl AsRef, + msg: Option>, + ) -> Result { + self.cmd() + .arg("commit-tree") + .arg(tree) + .args(msg.as_ref().is_some().then_some("-m")) + .args(msg) + .get_stdout_lossy() + } + pub fn rm(self, force: bool, paths: I) -> Result<()> where I: IntoIterator, @@ -484,8 +517,12 @@ https://github.com/foundry-rs/foundry/issues/new/choose" } } - pub fn commit_hash(self, short: bool) -> Result { - self.cmd().arg("rev-parse").args(short.then_some("--short")).arg("HEAD").get_stdout_lossy() + pub fn commit_hash(self, short: bool, revision: &str) -> Result { + self.cmd() + .arg("rev-parse") + .args(short.then_some("--short")) + .arg(revision) + .get_stdout_lossy() } pub fn tag(self) -> Result { @@ -521,7 +558,13 @@ https://github.com/foundry-rs/foundry/issues/new/choose" .map(drop) } - pub fn submodule_update(self, force: bool, remote: bool, paths: I) -> Result<()> + pub fn submodule_update( + self, + force: bool, + remote: bool, + no_fetch: bool, + paths: I, + ) -> Result<()> where I: IntoIterator, S: AsRef, @@ -532,11 +575,16 @@ https://github.com/foundry-rs/foundry/issues/new/choose" .args(self.shallow.then_some("--depth=1")) .args(force.then_some("--force")) .args(remote.then_some("--remote")) + .args(no_fetch.then_some("--no-fetch")) .args(paths) .exec() .map(drop) } + pub fn submodule_init(self) -> Result<()> { + self.cmd().stderr(self.stderr()).args(["submodule", "init"]).exec().map(drop) + } + pub fn cmd(self) -> Command { let mut cmd = Self::cmd_no_root(); cmd.current_dir(self.root); diff --git a/crates/forge/bin/cmd/doc.rs b/crates/forge/bin/cmd/doc.rs index 04e3cc87a5584..e30afa21f0430 100644 --- a/crates/forge/bin/cmd/doc.rs +++ b/crates/forge/bin/cmd/doc.rs @@ -74,7 +74,7 @@ impl DocArgs { } } - let commit = foundry_cli::utils::Git::new(&root).commit_hash(false).ok(); + let commit = foundry_cli::utils::Git::new(&root).commit_hash(false, "HEAD").ok(); let mut builder = DocBuilder::new(root.clone(), config.project_paths().sources) .with_should_build(self.build) diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 5dcd596491ea5..4d8c6c7155af8 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -53,9 +53,9 @@ impl InitArgs { let root = dunce::canonicalize(root)?; let git = Git::new(&root).quiet(quiet).shallow(shallow); - // if a template is provided, then this command clones the template repo, removes the .git - // folder, and initializes a new git repo—-this ensures there is no history from the - // template and the template is not set as a remote. + // if a template is provided, then this command initializes a git repo, + // fetches the template repo, and resets the git history to the head of the fetched + // repo with no other history if let Some(template) = template { let template = if template.contains("://") { template @@ -63,20 +63,29 @@ impl InitArgs { "https://github.com/".to_string() + &template }; p_println!(!quiet => "Initializing {} from {}...", root.display(), template); + // initialize the git repository + git.init()?; - if let Some(branch) = branch { - Git::clone_with_branch(shallow, &template, branch, Some(&root))?; + // fetch the template - always fetch shallow for templates since git history will be + // collapsed. gitmodules will be initialized after the template is fetched + Git::fetch(true, &template, branch)?; + // reset git history to the head of the template + // first get the commit hash that was fetched + let commit_hash = git.commit_hash(true, "FETCH_HEAD")?; + // format a commit message for the new repo + let commit_msg = format!("chore: init from {template} at {commit_hash}"); + // get the hash of the FETCH_HEAD with the new commit message + let new_commit_hash = git.commit_tree("FETCH_HEAD^{tree}", Some(commit_msg))?; + // reset head of this repo to be the head of the template repo + git.reset(true, new_commit_hash)?; + + // if shallow, just initialize submodules + if shallow { + git.submodule_init()?; } else { - Git::clone(shallow, &template, Some(&root))?; + // if not shallow, initialize and clone submodules (without fetching latest) + git.submodule_update(false, false, true, None::)?; } - // Modify the git history. - let commit_hash = git.commit_hash(true)?; - std::fs::remove_dir_all(root.join(".git"))?; - - git.init()?; - git.add(Some("--all"))?; - let commit_msg = format!("chore: init from {template} at {commit_hash}"); - git.commit(&commit_msg)?; } else { // if target is not empty if root.read_dir().map_or(false, |mut i| i.next().is_some()) { @@ -157,7 +166,7 @@ impl InitArgs { /// Returns the commit hash of the project if it exists pub fn get_commit_hash(root: &Path) -> Option { - Git::new(root).commit_hash(true).ok() + Git::new(root).commit_hash(true, "HEAD").ok() } /// Initialises `root` as a git repository, if it isn't one already. diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 5dcf3960adf17..d5568b8234641 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -126,7 +126,7 @@ impl DependencyInstallOpts { if dependencies.is_empty() && !self.no_git { p_println!(!self.quiet => "Updating dependencies in {}", libs.display()); - git.submodule_update(false, false, Some(&libs))?; + git.submodule_update(false, false, false, Some(&libs))?; } fs::create_dir_all(&libs)?; @@ -304,7 +304,7 @@ impl Installer<'_> { self.git.submodule_add(true, url, path)?; trace!("updating submodule recursively"); - self.git.submodule_update(false, false, Some(path)) + self.git.submodule_update(false, false, false, Some(path)) } fn git_checkout(self, dep: &Dependency, path: &Path, recurse: bool) -> Result { diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index 9f1f2969a77d3..083c889246f97 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -30,7 +30,7 @@ impl UpdateArgs { pub fn run(self) -> Result<()> { let config = self.try_load_config_emit_warnings()?; let (root, paths) = dependencies_paths(&self.dependencies, &config)?; - Git::new(&root).submodule_update(self.force, true, paths) + Git::new(&root).submodule_update(self.force, true, false, paths) } } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index d8a0b64db6481..a45fade65ce2c 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -378,6 +378,8 @@ forgetest!(can_init_template, |prj: TestProject, mut cmd: TestCommand| { assert!(prj.root().join(".git").exists()); assert!(prj.root().join("foundry.toml").exists()); assert!(prj.root().join("lib/forge-std").exists()); + // assert that gitmodules were correctly initialized + assert!(prj.root().join(".git/modules").exists()); assert!(prj.root().join("src").exists()); assert!(prj.root().join("test").exists()); }); @@ -391,6 +393,8 @@ forgetest!(can_init_template_with_branch, |prj: TestProject, mut cmd: TestComman assert!(prj.root().join(".git").exists()); assert!(prj.root().join(".dapprc").exists()); assert!(prj.root().join("lib/ds-test").exists()); + // assert that gitmodules were correctly initialized + assert!(prj.root().join(".git/modules").exists()); assert!(prj.root().join("src").exists()); assert!(prj.root().join("scripts").exists()); }); From 5bb886f41afe9a31c01847303e09b6f4835fdc78 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 27 Sep 2023 14:47:32 -0400 Subject: [PATCH 0123/1963] chore(`ci`): fix some flaky tests (#5900) --- crates/chisel/src/executor.rs | 2 +- testdata/cheats/Fs.t.sol | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 548e202e397cf..a033b5196980f 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1636,7 +1636,7 @@ mod tests { // on some CI targets installing results in weird malformed solc files, we try installing it // multiple times - let version = "0.8.19"; + let version = "0.8.20"; for _ in 0..3 { let mut is_preinstalled = PRE_INSTALL_SOLC_LOCK.lock().unwrap(); if !*is_preinstalled { diff --git a/testdata/cheats/Fs.t.sol b/testdata/cheats/Fs.t.sol index 31739c08ccc75..3ccc3e1216b83 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/cheats/Fs.t.sol @@ -303,7 +303,10 @@ contract FsTest is DSTest { metadata = vm.fsMetadata("fixtures/File/read.txt"); assertEq(metadata.isDir, false); assertEq(metadata.isSymlink, false); - assertEq(metadata.length, 45); + // This test will fail on windows if we compared to 45, as windows + // ends files with both line feed and carriage return, unlike + // unix which only uses the first one. + assertTrue(metadata.length == 45 || metadata.length == 46); metadata = vm.fsMetadata("fixtures/File/symlink"); assertEq(metadata.isDir, false); From 163cccd7ee863aa0a7a78824639ea5c64cf99fdc Mon Sep 17 00:00:00 2001 From: Bjerg Date: Wed, 27 Sep 2023 21:09:48 +0200 Subject: [PATCH 0124/1963] chore: fix clippy (#5931) * chore: fix clippy * chore: fix clippy --- crates/anvil/tests/it/traces.rs | 8 +- crates/config/src/inline/conf_parser.rs | 8 +- crates/config/src/inline/natspec.rs | 4 +- crates/config/src/lib.rs | 80 +++++++++---------- crates/config/src/utils.rs | 4 +- crates/doc/src/builder.rs | 2 +- crates/doc/src/parser/mod.rs | 12 +-- .../src/executor/inspector/cheatcodes/mod.rs | 2 +- crates/fmt/src/buffer.rs | 8 +- crates/fmt/tests/formatter.rs | 2 +- crates/forge/bin/cmd/geiger/find.rs | 8 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 4 +- crates/forge/tests/cli/cmd.rs | 28 +++---- crates/forge/tests/cli/config.rs | 16 ++-- crates/forge/tests/cli/create.rs | 8 +- crates/forge/tests/cli/script.rs | 2 +- crates/forge/tests/cli/test_cmd.rs | 16 ++-- crates/macros/src/fmt/ui.rs | 4 +- crates/test-utils/src/util.rs | 4 +- 19 files changed, 110 insertions(+), 110 deletions(-) diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 53c86b926c01d..d8c08f15e2fae 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -51,7 +51,7 @@ async fn test_parity_suicide_trace() { let prj = TempProject::dapptools().unwrap(); prj.add_source( "Contract", - r#" + r" pragma solidity 0.8.13; contract Contract { address payable private owner; @@ -62,7 +62,7 @@ contract Contract { selfdestruct(owner); } } -"#, +", ) .unwrap(); @@ -98,7 +98,7 @@ async fn test_transfer_debug_trace_call() { let prj = TempProject::dapptools().unwrap(); prj.add_source( "Contract", - r#" + r" pragma solidity 0.8.13; contract Contract { address payable private owner; @@ -109,7 +109,7 @@ contract Contract { selfdestruct(owner); } } -"#, +", ) .unwrap(); diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index c5e5a9be61f3e..7402ce6de0e0c 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -172,10 +172,10 @@ mod tests { contract: Default::default(), function: Default::default(), line: Default::default(), - docs: r#" + docs: r" forge-config: ciii.invariant.depth = 1 forge-config: default.invariant.depth = 1 - "# + " .into(), }; @@ -190,10 +190,10 @@ mod tests { contract: Default::default(), function: Default::default(), line: Default::default(), - docs: r#" + docs: r" forge-config: ci.invariant.depth = 1 forge-config: default.invariant.depth = 1 - "# + " .into(), }; diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index eda0a1fec078b..6bb2862de6473 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -209,7 +209,7 @@ mod tests { } fn natspec() -> NatSpec { - let conf = r#" + let conf = r" forge-config: default.fuzz.runs = 600 forge-config: ci.fuzz.runs = 500 ========= SOME NOISY TEXT ============= @@ -219,7 +219,7 @@ mod tests { 醤㭊r􎜕󷾸𶚏 ܖ̹灱녗V*竅􋹲⒪苏贗񾦼=숽ؓ򗋲бݧ󫥛𛲍ʹ園Ьi ======================================= forge-config: default.invariant.runs = 1 - "#; + "; NatSpec { contract: "dir/TestContract.t.sol:FuzzContract".to_string(), diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 9be852fb7826e..dda24f05700f4 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2565,20 +2565,20 @@ mod tests { assert_eq!(config.install_lib_dir(), PathBuf::from("lib")); jail.create_file( "foundry.toml", - r#" + r" [profile.default] libs = ['node_modules', 'lib'] - "#, + ", )?; let config = Config::load(); assert_eq!(config.install_lib_dir(), PathBuf::from("lib")); jail.create_file( "foundry.toml", - r#" + r" [profile.default] libs = ['custom', 'node_modules', 'lib'] - "#, + ", )?; let config = Config::load(); assert_eq!(config.install_lib_dir(), PathBuf::from("custom")); @@ -2636,12 +2636,12 @@ mod tests { jail.create_file( "foundry.toml", - r#" + r" [profile.default] libs = ['lib'] [profile.local] libs = ['modules'] - "#, + ", )?; jail.set_env("FOUNDRY_PROFILE", "local"); let config = Config::load(); @@ -2745,10 +2745,10 @@ mod tests { jail.create_file( "remappings.txt", - r#" + r" file-ds-test/=lib/ds-test/ file-other/=lib/other/ - "#, + ", )?; let config = Config::load(); @@ -2796,10 +2796,10 @@ mod tests { jail.create_file( "remappings.txt", - r#" + r" ds-test/=lib/ds-test/ other/=lib/other/ - "#, + ", )?; let config = Config::load(); @@ -3348,10 +3348,10 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [profile.default] remappings = ['nested/=lib/nested/'] - "#, + ", )?; let config = Config::load_with_root(jail.directory()); @@ -3588,7 +3588,7 @@ mod tests { } ); - jail.set_env("FOUNDRY_SRC", r#"other-src"#); + jail.set_env("FOUNDRY_SRC", r"other-src"); let config = Config::load(); assert_eq!( config, @@ -3638,7 +3638,7 @@ mod tests { remappings: default.remappings.clone(), } ); - jail.set_env("FOUNDRY_PROFILE", r#"other"#); + jail.set_env("FOUNDRY_PROFILE", r"other"); let base = Config::figment().extract::().unwrap(); assert_eq!( base, @@ -3660,10 +3660,10 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [fuzz] dictionary_weight = 101 - "#, + ", )?; let _config = Config::load(); Ok(()) @@ -3675,7 +3675,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [fuzz] runs = 1 include_storage = false @@ -3689,7 +3689,7 @@ mod tests { [profile.ci.invariant] runs = 400 - "#, + ", )?; let invariant_default = InvariantConfig::default(); @@ -3735,7 +3735,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [fuzz] runs = 100 @@ -3747,7 +3747,7 @@ mod tests { [profile.ci.invariant] runs = 500 - "#, + ", )?; let config = Config::load(); @@ -3838,7 +3838,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [profile.default] libraries= [ './src/SizeAuctionDiscount.sol:Chainlink:0xffedba5e171c4f15abaaabc86e8bd01f9b54dae5', @@ -3847,7 +3847,7 @@ mod tests { './src/test/ChainlinkTWAP.t.sol:ChainlinkTWAP:0xffedba5e171c4f15abaaabc86e8bd01f9b54dae5', './src/SizeAuctionDiscount.sol:Math:0x902f6cf364b8d9470d5793a9b2b2e86bddd21e0c', ] - "#, + ", )?; let config = Config::load(); @@ -3955,7 +3955,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [profile.default] optimizer = true @@ -3964,7 +3964,7 @@ mod tests { [profile.default.optimizer_details.yulDetails] stackAllocation = true - "#, + ", )?; let mut loaded = Config::load(); clear_warning(&mut loaded); @@ -3996,7 +3996,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [profile.default] [profile.default.model_checker] @@ -4004,7 +4004,7 @@ mod tests { engine = 'chc' targets = [ 'assert', 'outOfBounds' ] timeout = 10000 - "#, + ", )?; let mut loaded = Config::load(); clear_warning(&mut loaded); @@ -4046,7 +4046,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [profile.default] [profile.default.model_checker] @@ -4054,7 +4054,7 @@ mod tests { engine = 'chc' targets = [ 'assert', 'outOfBounds' ] timeout = 10000 - "#, + ", )?; let loaded = Config::load().sanitized(); @@ -4101,12 +4101,12 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [fmt] line_length = 100 tab_width = 2 bracket_spacing = true - "#, + ", )?; let loaded = Config::load().sanitized(); assert_eq!( @@ -4128,11 +4128,11 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [invariant] runs = 512 depth = 10 - "#, + ", )?; let loaded = Config::load().sanitized(); @@ -4150,13 +4150,13 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [fuzz] runs = 100 [invariant] depth = 1 - "#, + ", )?; jail.set_env("FOUNDRY_FMT_LINE_LENGTH", "95"); @@ -4174,14 +4174,14 @@ mod tests { #[test] fn test_parse_with_profile() { - let foundry_str = r#" + let foundry_str = r" [profile.default] src = 'src' out = 'out' libs = ['lib'] # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options - "#; + "; assert_eq!( parse_with_profile::(foundry_str).unwrap().unwrap(), ( @@ -4202,11 +4202,11 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [default] src = 'my-src' out = 'my-out' - "#, + ", )?; let loaded = Config::load().sanitized(); assert_eq!(loaded.src.file_name().unwrap(), "my-src"); @@ -4378,10 +4378,10 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [default] [profile.default.optimizer_details] - "#, + ", )?; let config = Config::load(); diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 5bb383bdc8a37..4c0263e5b1e71 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -287,7 +287,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", - r#" + r" [foo.baz] libs = ['node_modules', 'lib'] @@ -299,7 +299,7 @@ mod tests { [profile.local] libs = ['node_modules', 'lib'] - "#, + ", )?; let path = Path::new("./foundry.toml"); diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index d015c21d379b9..ecc9bd3ac14f9 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -255,7 +255,7 @@ impl DocBuilder { }; let readme_path = out_dir_src.join(Self::README); - fs::write(&readme_path, homepage_content)?; + fs::write(readme_path, homepage_content)?; // Write summary and section readmes let mut summary = BufWriter::default(); diff --git a/crates/doc/src/parser/mod.rs b/crates/doc/src/parser/mod.rs index ae1621aa777c5..5a57535d5c585 100644 --- a/crates/doc/src/parser/mod.rs +++ b/crates/doc/src/parser/mod.rs @@ -264,11 +264,11 @@ mod tests { #[test] fn multiple_shallow_contracts() { let items = parse_source( - r#" + r" contract A { } contract B { } contract C { } - "#, + ", ); assert_eq!(items.len(), 3); @@ -288,7 +288,7 @@ mod tests { #[test] fn contract_with_children_items() { let items = parse_source( - r#" + r" event TopLevelEvent(); contract Contract { @@ -304,7 +304,7 @@ mod tests { bool localVar; // must be ignored } } - "#, + ", ); assert_eq!(items.len(), 2); @@ -327,11 +327,11 @@ mod tests { #[test] fn contract_with_fallback() { let items = parse_source( - r#" + r" contract Contract { fallback() external payable {} } - "#, + ", ); assert_eq!(items.len(), 1); diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index fdc595a4b6d82..2cc77a4c2720d 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -708,7 +708,7 @@ impl Inspector for Cheatcodes { from: Some(broadcast.new_origin), to: Some(NameOrAddress::Address(call.contract.to_ethers())), value: Some(call.transfer.value).map(|v| v.to_ethers()), - data: Some(call.input.clone().0).map(ethers::types::Bytes), + data: Some(ethers::types::Bytes(call.input.clone().0)), nonce: Some(account.info.nonce.into()), gas: if is_fixed_gas_limit { Some(call.gas_limit.into()) diff --git a/crates/fmt/src/buffer.rs b/crates/fmt/src/buffer.rs index 6d4c113cb6bc6..d1842a2951b08 100644 --- a/crates/fmt/src/buffer.rs +++ b/crates/fmt/src/buffer.rs @@ -415,17 +415,17 @@ mod tests { fn test_preserves_original_content_with_default_settings() -> std::fmt::Result { let contents = [ "simple line", - r#" + r" some multiline - content"#, + content", "// comment", "/* comment */", - r#"mutliline + r"mutliline content // comment1 with comments - /* comment2 */ "#, + /* comment2 */ ", ]; for content in contents.iter() { diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index e736edebab87b..563147fd222da 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -36,7 +36,7 @@ fn test_directory(base_name: &str) { let default_config = FormatterConfig { line_length: 80, ..Default::default() }; - let mut config = toml::Value::try_from(&default_config).unwrap(); + let mut config = toml::Value::try_from(default_config).unwrap(); let config_table = config.as_table_mut().unwrap(); let mut lines = source.split('\n').peekable(); let mut line_num = 1; diff --git a/crates/forge/bin/cmd/geiger/find.rs b/crates/forge/bin/cmd/geiger/find.rs index 80a31c395dac8..315381b556111 100644 --- a/crates/forge/bin/cmd/geiger/find.rs +++ b/crates/forge/bin/cmd/geiger/find.rs @@ -136,14 +136,14 @@ mod tests { #[test] fn can_find_calls() { - let s = r#" + let s = r" contract A is Test { function do_ffi() public { string[] memory inputs = new string[](1); vm.ffi(inputs); } } - "#; + "; let count = find_cheatcodes_in_string(s).unwrap(); assert_eq!(count.ffi.len(), 1); @@ -152,14 +152,14 @@ mod tests { #[test] fn can_find_call_in_assignment() { - let s = r#" + let s = r" contract A is Test { function do_ffi() public { string[] memory inputs = new string[](1); bytes stuff = vm.ffi(inputs); } } - "#; + "; let count = find_cheatcodes_in_string(s).unwrap(); assert_eq!(count.ffi.len(), 1); diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 474aa2636e04c..7b57d13dbde56 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -530,10 +530,10 @@ mod tests { let root = temp.path(); let root_path = root.as_os_str().to_str().unwrap(); - let config = r#" + let config = r" [profile.default] cache = false - "#; + "; let toml_file = root.join(Config::FILE_NAME); fs::write(toml_file, config).unwrap(); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index a45fade65ce2c..71d6805c1e798 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -498,7 +498,7 @@ forgetest!(can_print_warnings, |prj: TestProject, mut cmd: TestCommand| { prj.inner() .add_source( "Foo", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity >0.8.9; contract Greeter { @@ -506,7 +506,7 @@ contract Greeter { uint256 x = 1; } } - "#, + ", ) .unwrap(); @@ -678,12 +678,12 @@ forgetest!(can_compile_without_warnings, |prj: TestProject, mut cmd: TestCommand prj.inner() .add_source( "A", - r#" + r" pragma solidity 0.8.10; contract A { function testExample() public {} } - "#, + ", ) .unwrap(); @@ -714,12 +714,12 @@ forgetest!(can_fail_compile_with_warnings, |prj: TestProject, mut cmd: TestComma prj.inner() .add_source( "A", - r#" + r" pragma solidity 0.8.10; contract A { function testExample() public {} } - "#, + ", ) .unwrap(); @@ -1430,11 +1430,11 @@ forgetest_init!(can_use_absolute_imports, |prj: TestProject, mut cmd: TestComman prj.inner() .add_lib( "myDepdendency/src/interfaces/IConfig.sol", - r#" + r" pragma solidity ^0.8.10; interface IConfig {} - "#, + ", ) .unwrap(); @@ -1474,11 +1474,11 @@ forgetest_init!( prj.inner() .add_script( "IMyScript.sol", - r#" + r" pragma solidity ^0.8.10; interface IMyScript {} - "#, + ", ) .unwrap(); @@ -1497,11 +1497,11 @@ forgetest_init!( prj.inner() .add_test( "IMyTest.sol", - r#" + r" pragma solidity ^0.8.10; interface IMyTest {} - "#, + ", ) .unwrap(); @@ -1588,12 +1588,12 @@ forgetest_init!(can_build_skip_glob, |prj: TestProject, mut cmd: TestCommand| { prj.inner() .add_test( "Foo", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.17; contract TestDemo { function test_run() external {} -}"#, +}", ) .unwrap(); // only builds the single template contract `src/*` even if `*.t.sol` or `.s.sol` is absent diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 763c0d497f7ad..40da4c6b9013f 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -325,11 +325,11 @@ forgetest!(can_set_solc_explicitly, |prj: TestProject, mut cmd: TestCommand| { prj.inner() .add_source( "Foo", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity >0.8.9; contract Greeter {} - "#, + ", ) .unwrap(); @@ -351,11 +351,11 @@ forgetest!(can_use_solc, |prj: TestProject, mut cmd: TestCommand| { prj.inner() .add_source( "Foo", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.7.0; contract Foo {} - "#, + ", ) .unwrap(); @@ -385,7 +385,7 @@ forgetest!(can_set_yul_optimizer, |prj: TestProject, mut cmd: TestCommand| { prj.inner() .add_source( "Foo", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.10; contract Foo { @@ -395,7 +395,7 @@ contract Foo { } } } - "#, + ", ) .unwrap(); @@ -602,10 +602,10 @@ forgetest!(config_emit_warnings, |prj: TestProject, mut cmd: TestCommand| { cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]); cmd.assert_non_empty_stdout(); - let faulty_toml = r#"[default] + let faulty_toml = r"[default] src = 'src' out = 'out' - libs = ['lib']"#; + libs = ['lib']"; fs::write(prj.root().join("foundry.toml"), faulty_toml).unwrap(); fs::write(prj.root().join("lib").join("forge-std").join("foundry.toml"), faulty_toml).unwrap(); diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 4f2d67ff58d43..acdbc06eb5a17 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -51,14 +51,14 @@ contract LinkTest { prj.inner() .add_lib( "remapping/MyLib", - r#" + r" // SPDX-License-Identifier: MIT library MyLib { function foobar(uint256 a) public view returns (uint256) { return a * 100; } } -"#, +", ) .unwrap(); @@ -94,7 +94,7 @@ contract Contract { prj.inner() .add_source( "libraries/ChainlinkTWAP", - r#" + r" // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; @@ -103,7 +103,7 @@ library ChainlinkTWAP { return 0; } } -"#, +", ) .unwrap(); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 2797f8b22b824..0cd73f95b8797 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -737,7 +737,7 @@ forgetest_async!( // Check sensitive logs // Ignore port number since it can change inbetween runs - let re = Regex::new(r#":[0-9]+"#).unwrap(); + let re = Regex::new(r":[0-9]+").unwrap(); let fixtures_log = std::fs::read_to_string( PathBuf::from(env!("CARGO_MANIFEST_DIR")) diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 7cf7da5216dd2..79c37007ec427 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -39,12 +39,12 @@ forgetest!(warn_no_tests, |prj: TestProject, mut cmd: TestCommand| { prj.inner() .add_source( "dummy", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity =0.8.13; contract Dummy {} -"#, +", ) .unwrap(); // set up command @@ -61,12 +61,12 @@ forgetest!(warn_no_tests_match, |prj: TestProject, mut cmd: TestCommand| { prj.inner() .add_source( "dummy", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity =0.8.13; contract Dummy {} -"#, +", ) .unwrap(); @@ -87,7 +87,7 @@ forgetest!(suggest_when_no_tests_match, |prj: TestProject, mut cmd: TestCommand| prj.inner() .add_source( "TestE.t.sol", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.10; @@ -95,7 +95,7 @@ contract TestC { function test1() public { } } - "#, + ", ) .unwrap(); @@ -313,7 +313,7 @@ forgetest_init!(can_use_libs_in_multi_fork, |prj: TestProject, mut cmd: TestComm prj.inner() .add_source( "Contract.sol", - r#" + r" // SPDX-License-Identifier: UNLICENSED pragma solidity =0.8.13; @@ -330,7 +330,7 @@ contract Contract { c = Library.f(1, 2); } } - "#, + ", ) .unwrap(); diff --git a/crates/macros/src/fmt/ui.rs b/crates/macros/src/fmt/ui.rs index d6d9971a30dba..84b14b259436e 100644 --- a/crates/macros/src/fmt/ui.rs +++ b/crates/macros/src/fmt/ui.rs @@ -449,7 +449,7 @@ mod tests { let tx: Transaction = serde_json::from_str(s).unwrap(); assert_eq!(tx.pretty().trim(), - r#" + r" blockHash 0x02b853cf50bc1c335b70790f93d5a390a35a166bea9c895e685cc866e4961cae blockNumber 436 from 0x3b179DcfC5fAa677044c27dCe958e4BC0ad696A6 @@ -472,7 +472,7 @@ queueIndex null queueOrigin sequencer rawTransaction 0xf86681a28084011cbbdc944a16a42407aa491564643e1dfc1fd50af29794ef8084d294f09338a06fca94073a0cf3381978662d46cf890602d3e9ccf6a31e4b69e8ecbd995e2beea00e804161a2b56a37ca1f6f4c4b8bce926587afa0d9b1acc5165e6556c959d583 txType -"#.trim() +".trim() ); } diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 1bccadb2249c4..3f4c44a450eb0 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -852,12 +852,12 @@ mod tests { #[test] fn fixture_regex_matches() { assert!(IGNORE_IN_FIXTURES.is_match( - r#" + r" Location: cli/src/compile.rs:151 Backtrace omitted. - "# + " )); } } From 96ab9131e6735df35aca0249968c7d339590de20 Mon Sep 17 00:00:00 2001 From: Bjerg Date: Wed, 27 Sep 2023 23:02:35 +0200 Subject: [PATCH 0125/1963] ci: disable aarch64 mac tests (#5932) --- .github/scripts/matrices.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 7c3e3f4bc896d..803795b457737 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -51,7 +51,9 @@ def __init__(self, os: str, target: str, name: str, flags: str, partition: int): default_target, Target("ubuntu-latest", "aarch64-unknown-linux-gnu"), Target("macos-latest", "x86_64-apple-darwin"), - Target("macos-latest", "aarch64-apple-darwin"), + # Disabled since the test binary will be built for M1/M2, but there are no + # GitHub runners capable of executing those binaries. + # Target("macos-latest", "aarch64-apple-darwin"), Target("windows-latest", "x86_64-pc-windows-msvc"), ] From 49f1c79ffacea5286a9477b58c21a6ae7d2f3dfe Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Thu, 28 Sep 2023 16:13:26 +0200 Subject: [PATCH 0126/1963] fix(forge): BaseCounterExample for targetInterface (#5936) * fix(forge): BaseCounterExample for targetInterface * remove unnecessary result wrapping --- crates/evm/src/fuzz/error.rs | 4 --- crates/evm/src/fuzz/invariant/error.rs | 19 ++++++------ crates/evm/src/fuzz/mod.rs | 40 +++++++++++++++----------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/crates/evm/src/fuzz/error.rs b/crates/evm/src/fuzz/error.rs index 3165ededdd6c3..fc3e6279600bd 100644 --- a/crates/evm/src/fuzz/error.rs +++ b/crates/evm/src/fuzz/error.rs @@ -9,10 +9,6 @@ pub const ASSUME_MAGIC_RETURN_CODE: &[u8] = b"FOUNDRY::ASSUME"; pub enum FuzzError { #[error("Couldn't call unknown contract")] UnknownContract, - #[error("Couldn't find function")] - UnknownFunction, - #[error("Failed to decode fuzzer inputs")] - FailedDecodeInput, #[error("Failed contract call")] FailedContractCall, #[error("Empty state changeset")] diff --git a/crates/evm/src/fuzz/invariant/error.rs b/crates/evm/src/fuzz/invariant/error.rs index 89d95da4a1c77..99e3efb59c9ea 100644 --- a/crates/evm/src/fuzz/invariant/error.rs +++ b/crates/evm/src/fuzz/invariant/error.rs @@ -7,7 +7,7 @@ use crate::{ CALLER, }; use ethers::abi::Function; -use eyre::{Result, WrapErr}; +use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use proptest::test_runner::TestError; use revm::primitives::U256; @@ -123,16 +123,13 @@ impl InvariantFuzzError { known_contracts, )); - counterexample_sequence.push( - BaseCounterExample::create( - *sender, - *addr, - bytes, - &ided_contracts, - call_result.traces, - ) - .wrap_err("Failed to create counter example")?, - ); + counterexample_sequence.push(BaseCounterExample::create( + *sender, + *addr, + bytes, + &ided_contracts, + call_result.traces, + )); // Checks the invariant. if let Some(func) = &self.func { diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index c22b00ed460cd..d34170f1e683f 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -300,27 +300,35 @@ impl BaseCounterExample { bytes: &Bytes, contracts: &ContractsByAddress, traces: Option, - ) -> Result { - let (name, abi) = &contracts.get(&addr).ok_or(FuzzError::UnknownContract)?; - - let func = abi - .functions() - .find(|f| f.short_signature() == bytes.0.as_ref()[0..4]) - .ok_or(FuzzError::UnknownFunction)?; - - // skip the function selector when decoding - let args = - func.decode_input(&bytes.0.as_ref()[4..]).map_err(|_| FuzzError::FailedDecodeInput)?; + ) -> Self { + if let Some((name, abi)) = &contracts.get(&addr) { + if let Some(func) = + abi.functions().find(|f| f.short_signature() == bytes.0.as_ref()[0..4]) + { + // skip the function selector when decoding + if let Ok(args) = func.decode_input(&bytes.0.as_ref()[4..]) { + return BaseCounterExample { + sender: Some(sender), + addr: Some(addr), + calldata: bytes.clone(), + signature: Some(func.signature()), + contract_name: Some(name.clone()), + traces, + args, + } + } + } + } - Ok(BaseCounterExample { + BaseCounterExample { sender: Some(sender), addr: Some(addr), calldata: bytes.clone(), - signature: Some(func.signature()), - contract_name: Some(name.clone()), + signature: None, + contract_name: None, traces, - args, - }) + args: vec![], + } } } From 524dfedef7995b62abe1096f998316c09e00dbf4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 28 Sep 2023 18:24:37 +0200 Subject: [PATCH 0127/1963] fix(anvil): log gas price request (#5942) --- crates/anvil/src/eth/api.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 949f32f0f290e..964f26482f078 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -158,7 +158,7 @@ impl EthApi { EthRequest::EthChainId(_) => self.eth_chain_id().to_rpc_result(), EthRequest::EthNetworkId(_) => self.network_id().to_rpc_result(), EthRequest::NetListening(_) => self.net_listening().to_rpc_result(), - EthRequest::EthGasPrice(_) => self.gas_price().to_rpc_result(), + EthRequest::EthGasPrice(_) => self.eth_gas_price().to_rpc_result(), EthRequest::EthMaxPriorityFeePerGas(_) => { self.gas_max_priority_fee_per_gas().to_rpc_result() } @@ -506,6 +506,12 @@ impl EthApi { Ok(self.net_listening) } + /// Returns the current gas price + fn eth_gas_price(&self) -> Result { + node_info!("eth_gasPrice"); + self.gas_price() + } + /// Returns the current gas price pub fn gas_price(&self) -> Result { Ok(self.backend.gas_price()) From 578d8fe179898a425c6d84a94519edc2fb61833d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 28 Sep 2023 19:14:11 +0200 Subject: [PATCH 0128/1963] chore: add aave alias (#5944) --- crates/cli/src/opts/dependency.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index ee6b0ee99021f..71a00b5042adc 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -20,7 +20,8 @@ const ALIAS_SEPARATOR: char = '='; /// Commonly used aliases for solidity repos, /// /// These will be autocorrected when used in place of the `org` -const COMMON_ORG_ALIASES: &[(&str, &str); 1] = &[("@openzeppelin", "openzeppelin")]; +const COMMON_ORG_ALIASES: &[(&str, &str); 2] = + &[("@openzeppelin", "openzeppelin"), ("@aave", "aave")]; /// A git dependency which will be installed as a submodule /// @@ -334,6 +335,21 @@ mod tests { ); } + #[test] + fn can_parse_aave() { + let dep = Dependency::from_str("@aave/aave-v3-core").unwrap(); + assert_eq!(dep.name, "aave-v3-core"); + assert_eq!(dep.url, Some("https://github.com/aave/aave-v3-core".to_string())); + } + + #[test] + fn can_parse_aave_with_alias() { + let dep = Dependency::from_str("@aave=aave/aave-v3-core").unwrap(); + assert_eq!(dep.name, "aave-v3-core"); + assert_eq!(dep.alias, Some("@aave".to_string())); + assert_eq!(dep.url, Some("https://github.com/aave/aave-v3-core".to_string())); + } + #[test] fn can_parse_org_ssh_url() { let org_url = "org-git12345678@github.com:my-org/my-repo.git"; From ddca274340319fbd264dfa019a6de2a8146f50f6 Mon Sep 17 00:00:00 2001 From: Colin Nielsen <33375223+colinnielsen@users.noreply.github.com> Date: Thu, 28 Sep 2023 18:21:11 -0400 Subject: [PATCH 0129/1963] fix(script): decode create2 constructor args (#5946) * fix: decode create2 constructor args * fix: make clippy happy * chore: remove print --- crates/forge/bin/cmd/script/transaction.rs | 90 +++++++++------------- 1 file changed, 35 insertions(+), 55 deletions(-) diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index a6d0822ea7144..873d33a29a1d0 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -78,7 +78,6 @@ impl TransactionWithMetadata { true, Address::from_slice(&result.returned), local_contracts, - decoder, )?; } else { metadata @@ -90,7 +89,6 @@ impl TransactionWithMetadata { false, result.address.wrap_err("There should be a contract address from CREATE.")?, local_contracts, - decoder, )?; } @@ -121,7 +119,6 @@ impl TransactionWithMetadata { is_create2: bool, address: Address, contracts: &BTreeMap, - decoder: &CallTraceDecoder, ) -> Result<()> { if is_create2 { self.opcode = CallKind::Create2; @@ -133,60 +130,43 @@ impl TransactionWithMetadata { self.contract_address = Some(address); if let Some(data) = self.transaction.data() { - // a CREATE2 transaction is a CALL to the CREATE2 deployer function, so we need to - // decode the arguments from the function call - if is_create2 { - // this will be the `deploy()` function of the CREATE2 call, we assume the contract - // is already deployed and will try to fetch it via its signature - if let Some(Some(function)) = decoder - .functions - .get(&data.0[..SELECTOR_LEN]) - .map(|functions| functions.first()) - { - self.function = Some(function.signature()); - self.arguments = Some( - function - .decode_input(&data.0[SELECTOR_LEN..]) - .map(|tokens| tokens.iter().map(format_token_raw).collect()) - .map_err(|_| eyre::eyre!("Failed to decode CREATE2 call arguments"))?, - ); - } - } else { - // This is a regular CREATE via the constructor, in which case we expect the - // contract has a constructor and if so decode its input params - if let Some(info) = contracts.get(&address) { - // set constructor arguments - if data.len() > info.code.len() { - if let Some(constructor) = info.abi.constructor() { - let on_err = || { - let inputs = constructor - .inputs - .iter() - .map(|p| p.kind.to_string()) - .collect::>() - .join(","); - let signature = format!("constructor({inputs})"); - let bytecode = hex::encode(&data.0); - (signature, bytecode) - }; - - let params = constructor + if let Some(info) = contracts.get(&address) { + // constructor args are postfixed to creation code + // and create2 transactions are prefixed by 32 byte salt + let contains_constructor_args = if is_create2 { + data.len() - 32 > info.code.len() + } else { + data.len() > info.code.len() + }; + + if contains_constructor_args { + if let Some(constructor) = info.abi.constructor() { + let creation_code = if is_create2 { &data[32..] } else { data }; + + let on_err = || { + let inputs = constructor .inputs .iter() - .map(|p| p.kind.clone()) - .collect::>(); - - // the constructor args start after bytecode - let constructor_args = &data.0[info.code.len()..]; - - if let Ok(arguments) = abi::decode(¶ms, constructor_args) { - self.arguments = - Some(arguments.iter().map(format_token_raw).collect()); - } else { - let (signature, bytecode) = on_err(); - error!(constructor=?signature, contract=?self.contract_name, bytecode, "Failed to decode constructor arguments") - }; - } + .map(|p| p.kind.to_string()) + .collect::>() + .join(","); + let signature = format!("constructor({inputs})"); + let bytecode = hex::encode(creation_code); + (signature, bytecode) + }; + + let params = + constructor.inputs.iter().map(|p| p.kind.clone()).collect::>(); + + // the constructor args start after bytecode + let constructor_args = &creation_code[info.code.len()..]; + + if let Ok(arguments) = abi::decode(¶ms, constructor_args) { + self.arguments = Some(arguments.iter().map(format_token_raw).collect()); + } else { + let (signature, bytecode) = on_err(); + error!(constructor=?signature, contract=?self.contract_name, bytecode, "Failed to decode constructor arguments") + }; } } } From 8e64cff4f591aa6c2dbf889a6954856356333aa3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 30 Sep 2023 18:23:08 +0200 Subject: [PATCH 0130/1963] chore(deps): bump ethers (#5960) --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 510ebc0346b70..470beec6238c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2045,7 +2045,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2060,7 +2060,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "ethers-core", "once_cell", @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2089,7 +2089,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "Inflector", "const-hex", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "Inflector", "const-hex", @@ -2127,7 +2127,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "arrayvec", "bytes", @@ -2156,7 +2156,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "ethers-core", "ethers-solc", @@ -2171,7 +2171,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "async-trait", "auto_impl", @@ -2197,7 +2197,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "async-trait", "auto_impl", @@ -2235,7 +2235,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "async-trait", "coins-bip32", @@ -2262,7 +2262,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#08bcb67c36d9a2869950e51ecf76124c9febe035" +source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" dependencies = [ "cfg-if", "const-hex", From 5be158ba6dc7c798a6f032026fe60fc01686b33b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 1 Oct 2023 16:08:18 +0200 Subject: [PATCH 0131/1963] test: add sig test case (#5969) --- crates/cast/bin/main.rs | 4 ++-- crates/cast/bin/opts.rs | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 0536c555ead68..169592669f295 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -7,7 +7,7 @@ use ethers::{ types::Address, utils::keccak256, }; -use eyre::Result; +use eyre::{Result, WrapErr}; use foundry_cli::{handler, prompt, stdin, utils}; use foundry_common::{ abi::{format_tokens, get_event}, @@ -174,7 +174,7 @@ async fn main() -> Result<()> { println!("{}", pretty_calldata(&calldata, offline).await?); } Subcommands::Sig { sig, optimize } => { - let sig = stdin::unwrap_line(sig)?; + let sig = stdin::unwrap_line(sig).wrap_err("Failed to read signature")?; if optimize.is_none() { println!("{}", SimpleCast::get_selector(&sig, None)?.0); } else { diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 379d537ff3495..4c7bfd24a3349 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -886,6 +886,7 @@ pub fn parse_slot(s: &str) -> Result { #[cfg(test)] mod tests { use super::*; + use cast::SimpleCast; use ethers::types::BlockNumber; #[test] @@ -908,6 +909,29 @@ mod tests { }; } + // + #[test] + fn parse_signature() { + let args: Opts = Opts::parse_from([ + "foundry-cli", + "sig", + "__$_$__$$$$$__$$_$$$_$$__$$___$$(address,address,uint256)", + ]); + match args.sub { + Subcommands::Sig { sig, .. } => { + let sig = sig.unwrap(); + assert_eq!( + sig, + "__$_$__$$$$$__$$_$$$_$$__$$___$$(address,address,uint256)".to_string() + ); + + let selector = SimpleCast::get_selector(&sig, None).unwrap(); + assert_eq!(selector.0, "0x23b872dd".to_string()); + } + _ => unreachable!(), + }; + } + #[test] fn parse_block_ids() { struct TestCase { From 844b918076a234e8a350ab3a22324b323708fa98 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:42:24 +0900 Subject: [PATCH 0132/1963] chore(deps): weekly `cargo update` (#5964) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/Evalir/revm/` Adding alloy-primitives v0.4.0 Updating anstream v0.5.0 -> v0.6.4 Updating anstyle v1.0.3 -> v1.0.4 Updating anstyle-parse v0.2.1 -> v0.2.2 Updating anstyle-wincon v2.1.0 -> v3.0.1 Adding c-kzg v0.1.1 Removing c-kzg v0.1.0 (https://github.com/ethereum/c-kzg-4844#fbef59a3) Updating clap v4.4.4 -> v4.4.6 Updating clap_builder v4.4.4 -> v4.4.6 Updating clap_complete v4.4.1 -> v4.4.3 Updating fastrand v2.0.0 -> v2.0.1 Updating hashbrown v0.14.0 -> v0.14.1 Updating indexmap v2.0.0 -> v2.0.2 Updating linux-raw-sys v0.4.7 -> v0.4.8 Updating mdbook v0.4.34 -> v0.4.35 Updating pest v2.7.3 -> v2.7.4 Updating pest_derive v2.7.3 -> v2.7.4 Updating pest_generator v2.7.3 -> v2.7.4 Updating pest_meta v2.7.3 -> v2.7.4 Updating proptest v1.2.0 -> v1.3.0 Updating regex v1.9.5 -> v1.9.6 Updating regex-automata v0.3.8 -> v0.3.9 Updating revm v3.3.0 (https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2f) -> #988e0d79 Updating revm-interpreter v1.1.2 (https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2f) -> #988e0d79 Updating revm-precompile v2.0.3 (https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2f) -> #988e0d79 Updating revm-primitives v1.1.2 (https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2f) -> #988e0d79 Updating rustix v0.38.14 -> v0.38.15 Updating sha2 v0.10.7 -> v0.10.8 Updating sharded-slab v0.1.4 -> v0.1.6 Updating thiserror v1.0.48 -> v1.0.49 Updating thiserror-impl v1.0.48 -> v1.0.49 Updating time v0.3.28 -> v0.3.29 Updating time-core v0.1.1 -> v0.1.2 Updating time-macros v0.2.14 -> v0.2.15 Removing tokio-tungstenite v0.18.0 Updating toml v0.8.0 -> v0.8.1 Updating toml_edit v0.20.0 -> v0.20.1 Removing tungstenite v0.18.0 Updating warp v0.3.5 -> v0.3.6 Updating webpki v0.22.1 -> v0.22.2 Co-authored-by: mattsse --- Cargo.lock | 297 ++++++++++++++++++++++++----------------------------- 1 file changed, 137 insertions(+), 160 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 470beec6238c9..8d58782b798ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,7 +82,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9b954c58532b0b327fa0cc7ce7d1a6b5a1554639620d99d812e27443cb486c7" dependencies = [ "alloy-json-abi", - "alloy-primitives", + "alloy-primitives 0.3.3", "alloy-sol-type-parser", "alloy-sol-types", "arbitrary", @@ -100,7 +100,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fe46acf61ad5bd7a5c21839bb2526358382fb8a6526f7ba393bdf593e2ae43f" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "alloy-sol-type-parser", "serde", "serde_json", @@ -129,6 +129,29 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "alloy-primitives" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4084879b7257d5b95b9009837c07a1868bd7d60e66418a7764b9b580ae64e0" +dependencies = [ + "alloy-rlp", + "arbitrary", + "bytes", + "cfg-if", + "const-hex", + "derive_arbitrary", + "derive_more", + "hex-literal", + "itoa", + "proptest", + "proptest-derive 0.4.0", + "rand 0.8.5", + "ruint", + "serde", + "tiny-keccak", +] + [[package]] name = "alloy-rlp" version = "0.3.3" @@ -179,7 +202,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaa7c9a4354b1ff9f1c85adf22802af046e20e4bb55e19b9dc6ca8cbc6f7f4e5" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "alloy-sol-macro", "const-hex", "serde", @@ -221,9 +244,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -235,15 +258,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -259,9 +282,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -271,7 +294,7 @@ dependencies = [ name = "anvil" version = "0.2.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "anvil-core", "anvil-rpc", "anvil-server", @@ -319,7 +342,7 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "bytes", "ethers-core", "foundry-evm", @@ -377,9 +400,6 @@ name = "arbitrary" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" -dependencies = [ - "derive_arbitrary", -] [[package]] name = "ariadne" @@ -800,7 +820,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ - "sha2 0.10.7", + "sha2 0.10.8", "tinyvec", ] @@ -811,7 +831,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", - "regex-automata 0.3.8", + "regex-automata 0.3.9", "serde", ] @@ -880,8 +900,9 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.1.0" -source = "git+https://github.com/ethereum/c-kzg-4844#fbef59a3f9e8fa998bdb5069d212daf83d586aa5" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac926d808fb72fe09ebf471a091d6d72918876ccf0b4989766093d2d0d24a0ef" dependencies = [ "bindgen", "blst", @@ -1012,7 +1033,7 @@ version = "0.2.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", - "alloy-primitives", + "alloy-primitives 0.3.3", "bytes", "clap", "criterion", @@ -1106,9 +1127,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.4" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", "clap_derive", @@ -1116,9 +1137,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.4" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", @@ -1131,9 +1152,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.1" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4110a1e6af615a9e6d0a36f805d5c99099f8bab9b8042f5bc1fa220a4a89e36f" +checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" dependencies = [ "clap", ] @@ -1202,7 +1223,7 @@ dependencies = [ "hmac 0.12.1", "k256", "serde", - "sha2 0.10.7", + "sha2 0.10.8", "thiserror", ] @@ -1218,7 +1239,7 @@ dependencies = [ "once_cell", "pbkdf2 0.12.2", "rand 0.8.5", - "sha2 0.10.7", + "sha2 0.10.8", "thiserror", ] @@ -1237,7 +1258,7 @@ dependencies = [ "ripemd", "serde", "serde_derive", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "thiserror", ] @@ -1625,7 +1646,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "lock_api", "once_cell", "parking_lot_core", @@ -1975,7 +1996,7 @@ dependencies = [ "scrypt", "serde", "serde_json", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "thiserror", "uuid", @@ -2105,7 +2126,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.37", - "toml 0.8.0", + "toml 0.8.1", "walkdir", ] @@ -2252,7 +2273,7 @@ dependencies = [ "rusoto_core", "rusoto_kms", "semver 1.0.19", - "sha2 0.10.7", + "sha2 0.10.8", "spki", "thiserror", "tracing", @@ -2283,7 +2304,7 @@ dependencies = [ "semver 1.0.19", "serde", "serde_json", - "sha2 0.10.7", + "sha2 0.10.8", "solang-parser", "svm-rs", "svm-rs-builds", @@ -2324,9 +2345,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fastrlp" @@ -2463,7 +2484,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" name = "forge" version = "0.2.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "anvil", "async-trait", "bytes", @@ -2536,7 +2557,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.8.0", + "toml 0.8.1", "tracing", "warp", ] @@ -2545,14 +2566,14 @@ dependencies = [ name = "forge-fmt" version = "0.2.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "ariadne", "foundry-config", "itertools 0.11.0", "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.0", + "toml 0.8.1", "tracing", "tracing-subscriber", ] @@ -2598,7 +2619,7 @@ dependencies = [ name = "foundry-cli" version = "0.2.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "async-trait", "clap", "color-eyre", @@ -2700,7 +2721,7 @@ dependencies = [ name = "foundry-debugger" version = "0.2.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "crossterm", "eyre", "foundry-common", @@ -2716,7 +2737,7 @@ name = "foundry-evm" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-primitives", + "alloy-primitives 0.3.3", "auto_impl", "bytes", "const-hex", @@ -2771,7 +2792,7 @@ dependencies = [ name = "foundry-test-utils" version = "0.2.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.3.3", "ethers", "ethers-solc", "eyre", @@ -2792,7 +2813,7 @@ name = "foundry-utils" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-primitives", + "alloy-primitives 0.3.3", "const-hex", "dunce", "ethers-addressbook", @@ -3359,9 +3380,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" dependencies = [ "ahash 0.8.3", "allocator-api2", @@ -3718,12 +3739,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.1", ] [[package]] @@ -3883,7 +3904,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2 0.10.7", + "sha2 0.10.8", "signature", ] @@ -4040,9 +4061,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" [[package]] name = "lock_api" @@ -4130,9 +4151,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55eb7c4dad20cc5bc15181c2aaf43d5689d5c3e0b80b50cc4cf0b7fe72a26d9" +checksum = "1c3f88addd34930bc5f01b9dc19f780447e51c92bf2536e3ded058018271775d" dependencies = [ "ammonia", "anyhow", @@ -4753,7 +4774,7 @@ dependencies = [ "digest 0.10.7", "hmac 0.12.1", "password-hash", - "sha2 0.10.7", + "sha2 0.10.8", ] [[package]] @@ -4812,9 +4833,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" +checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" dependencies = [ "memchr", "thiserror", @@ -4823,9 +4844,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" +checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" dependencies = [ "pest", "pest_generator", @@ -4833,9 +4854,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" +checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" dependencies = [ "pest", "pest_meta", @@ -4846,13 +4867,13 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" +checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" dependencies = [ "once_cell", "pest", - "sha2 0.10.7", + "sha2 0.10.8", ] [[package]] @@ -4862,7 +4883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.0.2", ] [[package]] @@ -5171,19 +5192,19 @@ dependencies = [ [[package]] name = "proptest" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e35c06b98bf36aba164cc17cb25f7e232f5c4aeea73baa14b8a9f0d92dbfa65" +checksum = "59d6ddf4877c954130eb46772d1efba4ec0f5b3ee3189925d6a78ee61c41227f" dependencies = [ "bit-set", - "bitflags 1.3.2", - "byteorder", + "bit-vec", + "bitflags 2.4.0", "lazy_static", "num-traits", "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.6.29", + "regex-syntax 0.7.5", "rusty-fork", "tempfile", "unarray", @@ -5442,13 +5463,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.5" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.8", + "regex-automata 0.3.9", "regex-syntax 0.7.5", ] @@ -5463,9 +5484,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", @@ -5530,7 +5551,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" dependencies = [ "auto_impl", "revm-interpreter", @@ -5542,13 +5563,8 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" dependencies = [ - "arbitrary", - "derive_more", - "enumn", - "proptest", - "proptest-derive 0.4.0", "revm-primitives", "serde", ] @@ -5556,7 +5572,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" dependencies = [ "c-kzg", "k256", @@ -5565,32 +5581,24 @@ dependencies = [ "revm-primitives", "ripemd", "secp256k1", - "sha2 0.10.7", - "sha3", + "sha2 0.10.8", "substrate-bn", ] [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.4.0", "alloy-rlp", - "arbitrary", "auto_impl", "bitflags 2.4.0", "bitvec", - "bytes", "c-kzg", - "derive_more", "enumn", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "hex", - "once_cell", - "primitive-types", - "proptest", - "proptest-derive 0.4.0", "serde", ] @@ -5832,9 +5840,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.14" +version = "0.38.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" +checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" dependencies = [ "bitflags 2.4.0", "errno", @@ -6017,7 +6025,7 @@ dependencies = [ "hmac 0.12.1", "pbkdf2 0.11.0", "salsa20", - "sha2 0.10.7", + "sha2 0.10.8", ] [[package]] @@ -6150,7 +6158,7 @@ version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "itoa", "ryu", "serde", @@ -6255,9 +6263,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -6276,9 +6284,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b" dependencies = [ "lazy_static", ] @@ -6551,7 +6559,7 @@ dependencies = [ "semver 1.0.19", "serde", "serde_json", - "sha2 0.10.7", + "sha2 0.10.8", "thiserror", "url", "zip", @@ -6708,18 +6716,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2 1.0.67", "quote 1.0.33", @@ -6747,9 +6755,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" dependencies = [ "deranged", "itoa", @@ -6762,15 +6770,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" dependencies = [ "time-core", ] @@ -6893,18 +6901,6 @@ dependencies = [ "tungstenite 0.17.3", ] -[[package]] -name = "tokio-tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.18.0", -] - [[package]] name = "tokio-tungstenite" version = "0.20.1" @@ -6951,7 +6947,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", @@ -6960,14 +6956,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +checksum = "1bc1433177506450fe920e46a4f9812d0c211f5dd556da10e731a0a3dfa151f0" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.0", + "toml_edit 0.20.1", ] [[package]] @@ -6985,7 +6981,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", @@ -6994,11 +6990,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +checksum = "ca676d9ba1a322c1b64eb8045a5ec5c0cfb0c9d08e15e9ff622589ad5221c8fe" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", @@ -7232,25 +7228,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" -dependencies = [ - "base64 0.13.1", - "byteorder", - "bytes", - "http", - "httparse", - "log", - "rand 0.8.5", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.20.1" @@ -7470,9 +7447,9 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69" +checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" dependencies = [ "bytes", "futures-channel", @@ -7492,7 +7469,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-stream", - "tokio-tungstenite 0.18.0", + "tokio-tungstenite 0.20.1", "tokio-util", "tower-service", "tracing", @@ -7636,9 +7613,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" +checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" dependencies = [ "ring", "untrusted", From 08531c64167cc0b3d042610e796603b8b3edaeef Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 2 Oct 2023 13:31:05 +0900 Subject: [PATCH 0133/1963] Revert "chore(deps): weekly `cargo update` (#5964)" (#5974) --- Cargo.lock | 297 +++++++++++++++++++++++++++++------------------------ 1 file changed, 160 insertions(+), 137 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d58782b798ca..470beec6238c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,7 +82,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9b954c58532b0b327fa0cc7ce7d1a6b5a1554639620d99d812e27443cb486c7" dependencies = [ "alloy-json-abi", - "alloy-primitives 0.3.3", + "alloy-primitives", "alloy-sol-type-parser", "alloy-sol-types", "arbitrary", @@ -100,7 +100,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fe46acf61ad5bd7a5c21839bb2526358382fb8a6526f7ba393bdf593e2ae43f" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "alloy-sol-type-parser", "serde", "serde_json", @@ -129,29 +129,6 @@ dependencies = [ "tiny-keccak", ] -[[package]] -name = "alloy-primitives" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4084879b7257d5b95b9009837c07a1868bd7d60e66418a7764b9b580ae64e0" -dependencies = [ - "alloy-rlp", - "arbitrary", - "bytes", - "cfg-if", - "const-hex", - "derive_arbitrary", - "derive_more", - "hex-literal", - "itoa", - "proptest", - "proptest-derive 0.4.0", - "rand 0.8.5", - "ruint", - "serde", - "tiny-keccak", -] - [[package]] name = "alloy-rlp" version = "0.3.3" @@ -202,7 +179,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaa7c9a4354b1ff9f1c85adf22802af046e20e4bb55e19b9dc6ca8cbc6f7f4e5" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "alloy-sol-macro", "const-hex", "serde", @@ -244,9 +221,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", @@ -258,15 +235,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -282,9 +259,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -294,7 +271,7 @@ dependencies = [ name = "anvil" version = "0.2.0" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "anvil-core", "anvil-rpc", "anvil-server", @@ -342,7 +319,7 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "bytes", "ethers-core", "foundry-evm", @@ -400,6 +377,9 @@ name = "arbitrary" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +dependencies = [ + "derive_arbitrary", +] [[package]] name = "ariadne" @@ -820,7 +800,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ - "sha2 0.10.8", + "sha2 0.10.7", "tinyvec", ] @@ -831,7 +811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", - "regex-automata 0.3.9", + "regex-automata 0.3.8", "serde", ] @@ -900,9 +880,8 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac926d808fb72fe09ebf471a091d6d72918876ccf0b4989766093d2d0d24a0ef" +version = "0.1.0" +source = "git+https://github.com/ethereum/c-kzg-4844#fbef59a3f9e8fa998bdb5069d212daf83d586aa5" dependencies = [ "bindgen", "blst", @@ -1033,7 +1012,7 @@ version = "0.2.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", - "alloy-primitives 0.3.3", + "alloy-primitives", "bytes", "clap", "criterion", @@ -1127,9 +1106,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.6" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" dependencies = [ "clap_builder", "clap_derive", @@ -1137,9 +1116,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ "anstream", "anstyle", @@ -1152,9 +1131,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.3" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" +checksum = "4110a1e6af615a9e6d0a36f805d5c99099f8bab9b8042f5bc1fa220a4a89e36f" dependencies = [ "clap", ] @@ -1223,7 +1202,7 @@ dependencies = [ "hmac 0.12.1", "k256", "serde", - "sha2 0.10.8", + "sha2 0.10.7", "thiserror", ] @@ -1239,7 +1218,7 @@ dependencies = [ "once_cell", "pbkdf2 0.12.2", "rand 0.8.5", - "sha2 0.10.8", + "sha2 0.10.7", "thiserror", ] @@ -1258,7 +1237,7 @@ dependencies = [ "ripemd", "serde", "serde_derive", - "sha2 0.10.8", + "sha2 0.10.7", "sha3", "thiserror", ] @@ -1646,7 +1625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.1", + "hashbrown 0.14.0", "lock_api", "once_cell", "parking_lot_core", @@ -1996,7 +1975,7 @@ dependencies = [ "scrypt", "serde", "serde_json", - "sha2 0.10.8", + "sha2 0.10.7", "sha3", "thiserror", "uuid", @@ -2126,7 +2105,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.37", - "toml 0.8.1", + "toml 0.8.0", "walkdir", ] @@ -2273,7 +2252,7 @@ dependencies = [ "rusoto_core", "rusoto_kms", "semver 1.0.19", - "sha2 0.10.8", + "sha2 0.10.7", "spki", "thiserror", "tracing", @@ -2304,7 +2283,7 @@ dependencies = [ "semver 1.0.19", "serde", "serde_json", - "sha2 0.10.8", + "sha2 0.10.7", "solang-parser", "svm-rs", "svm-rs-builds", @@ -2345,9 +2324,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "fastrlp" @@ -2484,7 +2463,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" name = "forge" version = "0.2.0" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "anvil", "async-trait", "bytes", @@ -2557,7 +2536,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.8.1", + "toml 0.8.0", "tracing", "warp", ] @@ -2566,14 +2545,14 @@ dependencies = [ name = "forge-fmt" version = "0.2.0" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "ariadne", "foundry-config", "itertools 0.11.0", "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.1", + "toml 0.8.0", "tracing", "tracing-subscriber", ] @@ -2619,7 +2598,7 @@ dependencies = [ name = "foundry-cli" version = "0.2.0" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "async-trait", "clap", "color-eyre", @@ -2721,7 +2700,7 @@ dependencies = [ name = "foundry-debugger" version = "0.2.0" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "crossterm", "eyre", "foundry-common", @@ -2737,7 +2716,7 @@ name = "foundry-evm" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-primitives 0.3.3", + "alloy-primitives", "auto_impl", "bytes", "const-hex", @@ -2792,7 +2771,7 @@ dependencies = [ name = "foundry-test-utils" version = "0.2.0" dependencies = [ - "alloy-primitives 0.3.3", + "alloy-primitives", "ethers", "ethers-solc", "eyre", @@ -2813,7 +2792,7 @@ name = "foundry-utils" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-primitives 0.3.3", + "alloy-primitives", "const-hex", "dunce", "ethers-addressbook", @@ -3380,9 +3359,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" dependencies = [ "ahash 0.8.3", "allocator-api2", @@ -3739,12 +3718,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.0", ] [[package]] @@ -3904,7 +3883,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2 0.10.8", + "sha2 0.10.7", "signature", ] @@ -4061,9 +4040,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" @@ -4151,9 +4130,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.35" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c3f88addd34930bc5f01b9dc19f780447e51c92bf2536e3ded058018271775d" +checksum = "c55eb7c4dad20cc5bc15181c2aaf43d5689d5c3e0b80b50cc4cf0b7fe72a26d9" dependencies = [ "ammonia", "anyhow", @@ -4774,7 +4753,7 @@ dependencies = [ "digest 0.10.7", "hmac 0.12.1", "password-hash", - "sha2 0.10.8", + "sha2 0.10.7", ] [[package]] @@ -4833,9 +4812,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" dependencies = [ "memchr", "thiserror", @@ -4844,9 +4823,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" dependencies = [ "pest", "pest_generator", @@ -4854,9 +4833,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" dependencies = [ "pest", "pest_meta", @@ -4867,13 +4846,13 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" dependencies = [ "once_cell", "pest", - "sha2 0.10.8", + "sha2 0.10.7", ] [[package]] @@ -4883,7 +4862,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.2", + "indexmap 2.0.0", ] [[package]] @@ -5192,19 +5171,19 @@ dependencies = [ [[package]] name = "proptest" -version = "1.3.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59d6ddf4877c954130eb46772d1efba4ec0f5b3ee3189925d6a78ee61c41227f" +checksum = "4e35c06b98bf36aba164cc17cb25f7e232f5c4aeea73baa14b8a9f0d92dbfa65" dependencies = [ "bit-set", - "bit-vec", - "bitflags 2.4.0", + "bitflags 1.3.2", + "byteorder", "lazy_static", "num-traits", "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.7.5", + "regex-syntax 0.6.29", "rusty-fork", "tempfile", "unarray", @@ -5463,13 +5442,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.6" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.9", + "regex-automata 0.3.8", "regex-syntax 0.7.5", ] @@ -5484,9 +5463,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", @@ -5551,7 +5530,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ "auto_impl", "revm-interpreter", @@ -5563,8 +5542,13 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ + "arbitrary", + "derive_more", + "enumn", + "proptest", + "proptest-derive 0.4.0", "revm-primitives", "serde", ] @@ -5572,7 +5556,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ "c-kzg", "k256", @@ -5581,24 +5565,32 @@ dependencies = [ "revm-primitives", "ripemd", "secp256k1", - "sha2 0.10.8", + "sha2 0.10.7", + "sha3", "substrate-bn", ] [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#988e0d7920ab20c3d0a12dd5582654a58e7f9f2c" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" dependencies = [ - "alloy-primitives 0.4.0", + "alloy-primitives", "alloy-rlp", + "arbitrary", "auto_impl", "bitflags 2.4.0", "bitvec", + "bytes", "c-kzg", + "derive_more", "enumn", - "hashbrown 0.14.1", + "hashbrown 0.14.0", "hex", + "once_cell", + "primitive-types", + "proptest", + "proptest-derive 0.4.0", "serde", ] @@ -5840,9 +5832,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.15" +version = "0.38.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" +checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" dependencies = [ "bitflags 2.4.0", "errno", @@ -6025,7 +6017,7 @@ dependencies = [ "hmac 0.12.1", "pbkdf2 0.11.0", "salsa20", - "sha2 0.10.8", + "sha2 0.10.7", ] [[package]] @@ -6158,7 +6150,7 @@ version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.0.0", "itoa", "ryu", "serde", @@ -6263,9 +6255,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -6284,9 +6276,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.6" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" dependencies = [ "lazy_static", ] @@ -6559,7 +6551,7 @@ dependencies = [ "semver 1.0.19", "serde", "serde_json", - "sha2 0.10.8", + "sha2 0.10.7", "thiserror", "url", "zip", @@ -6716,18 +6708,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2 1.0.67", "quote 1.0.33", @@ -6755,9 +6747,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ "deranged", "itoa", @@ -6770,15 +6762,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -6901,6 +6893,18 @@ dependencies = [ "tungstenite 0.17.3", ] +[[package]] +name = "tokio-tungstenite" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.18.0", +] + [[package]] name = "tokio-tungstenite" version = "0.20.1" @@ -6947,7 +6951,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -6956,14 +6960,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc1433177506450fe920e46a4f9812d0c211f5dd556da10e731a0a3dfa151f0" +checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.1", + "toml_edit 0.20.0", ] [[package]] @@ -6981,7 +6985,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -6990,11 +6994,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca676d9ba1a322c1b64eb8045a5ec5c0cfb0c9d08e15e9ff622589ad5221c8fe" +checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -7228,6 +7232,25 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tungstenite" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" +dependencies = [ + "base64 0.13.1", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "rand 0.8.5", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "tungstenite" version = "0.20.1" @@ -7447,9 +7470,9 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.6" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" +checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69" dependencies = [ "bytes", "futures-channel", @@ -7469,7 +7492,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-stream", - "tokio-tungstenite 0.20.1", + "tokio-tungstenite 0.18.0", "tokio-util", "tower-service", "tracing", @@ -7613,9 +7636,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" +checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" dependencies = [ "ring", "untrusted", From a893e50d998659de37c16cb225265b107f2ef213 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 2 Oct 2023 13:07:10 +0200 Subject: [PATCH 0134/1963] chore: bump alloy (#5968) * chore: bump alloy * chore: update revm branch * chore: solve conflicts * chore: properly handle patching selectors * chore: use array type --------- Co-authored-by: Enrique Ortiz --- Cargo.lock | 328 +++--- Cargo.toml | 6 +- crates/chisel/src/executor.rs | 4 +- crates/evm/src/executor/abi/mod.rs | 1035 +++++++++-------- .../src/executor/inspector/cheatcodes/env.rs | 6 +- .../executor/inspector/cheatcodes/error.rs | 2 +- crates/utils/src/error.rs | 4 +- 7 files changed, 665 insertions(+), 720 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 470beec6238c9..8c7a30d2f9e8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,9 +77,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b954c58532b0b327fa0cc7ce7d1a6b5a1554639620d99d812e27443cb486c7" +checksum = "b4a2c94da79130a80677c497eb56e465f72e376e0d85720228be2cf6c85ec5b0" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe46acf61ad5bd7a5c21839bb2526358382fb8a6526f7ba393bdf593e2ae43f" +checksum = "d187c265879ea8fc1fb574f75f95942e9502d2a67eba7e5c9f6ba9879375ddd6" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" +checksum = "6b4084879b7257d5b95b9009837c07a1868bd7d60e66418a7764b9b580ae64e0" dependencies = [ "alloy-rlp", "arbitrary", @@ -123,7 +123,8 @@ dependencies = [ "hex-literal", "itoa", "proptest", - "proptest-derive 0.3.0", + "proptest-derive", + "rand 0.8.5", "ruint", "serde", "tiny-keccak", @@ -147,21 +148,22 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] [[package]] name = "alloy-sol-macro" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7720130c58db647103587b0c39aad4e669eea261e256040301d6c7983fdbb461" +checksum = "de84480ac5979d8513164f7e668f837839cd6d5c4bdb8beecbb8cf062b61cb48" dependencies = [ + "const-hex", "dunce", "heck", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", "syn-solidity", "tiny-keccak", @@ -169,15 +171,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "627a32998aee7a7eedd351e9b6d4cacef9426935219a3a61befa332db1be5ca3" +checksum = "3427d2135d3c28696b437fdf44b86e334f36639d367abc8a5af2f718b3c1992b" +dependencies = [ + "winnow", +] [[package]] name = "alloy-sol-types" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaa7c9a4354b1ff9f1c85adf22802af046e20e4bb55e19b9dc6ca8cbc6f7f4e5" +checksum = "fa7e42aa2983db6676af5d762bc8d9371dd74f5948739790d3080c3d652a957b" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -377,9 +382,6 @@ name = "arbitrary" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" -dependencies = [ - "derive_arbitrary", -] [[package]] name = "ariadne" @@ -435,7 +437,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" dependencies = [ - "quote 1.0.33", + "quote", "syn 1.0.109", ] @@ -445,7 +447,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ - "quote 1.0.33", + "quote", "syn 1.0.109", ] @@ -457,7 +459,7 @@ checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ "num-bigint", "num-traits", - "quote 1.0.33", + "quote", "syn 1.0.109", ] @@ -469,8 +471,8 @@ checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", "num-traits", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -545,8 +547,8 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -556,8 +558,8 @@ version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -591,8 +593,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -711,8 +713,8 @@ dependencies = [ "log", "peeking_take_while", "prettyplease", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "regex", "rustc-hash", "shlex", @@ -880,8 +882,9 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.1.0" -source = "git+https://github.com/ethereum/c-kzg-4844#fbef59a3f9e8fa998bdb5069d212daf83d586aa5" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac926d808fb72fe09ebf471a091d6d72918876ccf0b4989766093d2d0d24a0ef" dependencies = [ "bindgen", "blst", @@ -1155,8 +1158,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -1659,8 +1662,8 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -1670,8 +1673,8 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -1682,8 +1685,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "rustc_version 0.4.0", "syn 1.0.109", ] @@ -1904,8 +1907,8 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -2098,8 +2101,8 @@ dependencies = [ "ethers-etherscan", "eyre", "prettyplease", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "regex", "reqwest", "serde", @@ -2118,8 +2121,8 @@ dependencies = [ "const-hex", "ethers-contract-abigen", "ethers-core", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "serde_json", "syn 2.0.37", ] @@ -2150,7 +2153,7 @@ dependencies = [ "tempfile", "thiserror", "tiny-keccak", - "unicode-xid 0.2.4", + "unicode-xid", ] [[package]] @@ -2347,8 +2350,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4caf31122bfc780557fdcd80897e95f12cc4d7217f8ac6b9d150df828a38ee8" dependencies = [ "bytes", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -2762,8 +2765,8 @@ dependencies = [ name = "foundry-macros-impl" version = "0.2.0" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -2917,8 +2920,8 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -3477,8 +3480,8 @@ dependencies = [ "log", "mac", "markup5ever", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3695,8 +3698,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3946,7 +3949,7 @@ dependencies = [ "string_cache", "term", "tiny-keccak", - "unicode-xid 0.2.4", + "unicode-xid", ] [[package]] @@ -4218,8 +4221,8 @@ version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -4479,8 +4482,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -4546,8 +4549,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" dependencies = [ "bytes", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -4583,8 +4586,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -4654,8 +4657,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -4693,7 +4696,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2", "syn 1.0.109", "synstructure", ] @@ -4783,9 +4786,9 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da9f0f13dac8069c139e8300a6510e3f4143ecf5259c60b116a9b271b4ca0d54" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2", "proc-macro2-diagnostics", - "quote 1.0.33", + "quote", "syn 2.0.37", ] @@ -4839,8 +4842,8 @@ checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -4942,8 +4945,8 @@ checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" dependencies = [ "phf_generator 0.11.2", "phf_shared 0.11.2", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -4980,8 +4983,8 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -5075,7 +5078,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2", "syn 2.0.37", ] @@ -5110,8 +5113,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", "version_check", ] @@ -5122,20 +5125,11 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "version_check", ] -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.67" @@ -5151,8 +5145,8 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", "version_check", "yansi 1.0.0-rc.1", @@ -5189,25 +5183,14 @@ dependencies = [ "unarray", ] -[[package]] -name = "proptest-derive" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90b46295382dc76166cb7cf2bb4a97952464e4b7ed5a43e6cd34e1fec3349ddc" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - [[package]] name = "proptest-derive" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cf16337405ca084e9c78985114633b6827711d22b9e6ef6c6c0d665eb3f0b6e" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -5248,22 +5231,13 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ - "proc-macro2 1.0.67", + "proc-macro2", ] [[package]] @@ -5530,7 +5504,7 @@ dependencies = [ [[package]] name = "revm" version = "3.3.0" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" dependencies = [ "auto_impl", "revm-interpreter", @@ -5542,13 +5516,8 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" dependencies = [ - "arbitrary", - "derive_more", - "enumn", - "proptest", - "proptest-derive 0.4.0", "revm-primitives", "serde", ] @@ -5556,7 +5525,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.0.3" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" dependencies = [ "c-kzg", "k256", @@ -5566,31 +5535,23 @@ dependencies = [ "ripemd", "secp256k1", "sha2 0.10.7", - "sha3", "substrate-bn", ] [[package]] name = "revm-primitives" version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#91942a2fd7306f7916624fed51ca99b294ac3825" +source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" dependencies = [ "alloy-primitives", "alloy-rlp", - "arbitrary", "auto_impl", "bitflags 2.4.0", "bitvec", - "bytes", "c-kzg", - "derive_more", "enumn", "hashbrown 0.14.0", "hex", - "once_cell", - "primitive-types", - "proptest", - "proptest-derive 0.4.0", "serde", ] @@ -5645,8 +5606,8 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -5982,8 +5943,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -6139,8 +6100,8 @@ version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -6207,8 +6168,8 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -6414,7 +6375,7 @@ dependencies = [ "lalrpop-util", "phf 0.11.2", "thiserror", - "unicode-xid 0.2.4", + "unicode-xid", ] [[package]] @@ -6467,8 +6428,8 @@ checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" dependencies = [ "phf_generator 0.10.0", "phf_shared 0.10.0", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", ] [[package]] @@ -6499,8 +6460,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "rustversion", "syn 1.0.109", ] @@ -6512,8 +6473,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "rustversion", "syn 2.0.37", ] @@ -6570,25 +6531,14 @@ dependencies = [ "svm-rs", ] -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "unicode-ident", ] @@ -6598,20 +6548,20 @@ version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "unicode-ident", ] [[package]] name = "syn-solidity" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397f229dc34c7b8231b6ef85502f9ca4e3425b8625e6d403bb74779e6b1917b5" +checksum = "1b8a5a633f1172a0c80b1516a988e7e8efa7ce9cededf56590f54e593e4513b3" dependencies = [ "paste", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -6627,10 +6577,10 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 1.0.109", - "unicode-xid 0.2.4", + "unicode-xid", ] [[package]] @@ -6721,8 +6671,8 @@ version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -6834,8 +6784,8 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -7096,8 +7046,8 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] @@ -7359,12 +7309,6 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -7529,8 +7473,8 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", "wasm-bindgen-shared", ] @@ -7553,7 +7497,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ - "quote 1.0.33", + "quote", "wasm-bindgen-macro-support", ] @@ -7563,8 +7507,8 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -7914,8 +7858,8 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.67", - "quote 1.0.33", + "proc-macro2", + "quote", "syn 2.0.37", ] diff --git a/Cargo.toml b/Cargo.toml index 41f1dd5ef26f0..79d855bfe5e61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,9 +153,9 @@ ethers-solc = { version = "2.0", default-features = false } ## alloy -alloy-primitives = { version = "0.3", default-features = false } -alloy-dyn-abi = { version = "0.3", default-features = false } -alloy-json-abi = { version = "0.3", default-features = false } +alloy-primitives = { version = "0.4", default-features = false } +alloy-dyn-abi = { version = "0.4", default-features = false } +alloy-json-abi = { version = "0.4", default-features = false } solang-parser = "=0.3.2" diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index a033b5196980f..4d6aa1df2b193 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -230,7 +230,7 @@ impl SessionSource { let data = &mem[offset..offset + len]; // `tokens` is guaranteed to have the same length as the provided types let token = - DynSolType::decode_single(&ty, data).wrap_err("Could not decode inspected values")?; + DynSolType::abi_decode(&ty, data).wrap_err("Could not decode inspected values")?; Ok((should_continue(contract_expr), Some(format_token(token)))) } @@ -348,7 +348,7 @@ fn format_token(token: DynSolValue) -> String { format!("Type: {}\n└ Value: {}", Paint::red("bool"), Paint::cyan(b)) } DynSolValue::String(_) | DynSolValue::Bytes(_) => { - let hex = hex::encode(token.encode_single()); + let hex = hex::encode(token.abi_encode()); let s = token.as_str().map(|s| s.to_owned()); format!( "Type: {}\n{}├ Hex (Memory):\n├─ Length ({}): {}\n├─ Contents ({}): {}\n├ Hex (Tuple Encoded):\n├─ Pointer ({}): {}\n├─ Length ({}): {}\n└─ Contents ({}): {}", diff --git a/crates/evm/src/executor/abi/mod.rs b/crates/evm/src/executor/abi/mod.rs index 273c13502dc46..c75898acb8b9d 100644 --- a/crates/evm/src/executor/abi/mod.rs +++ b/crates/evm/src/executor/abi/mod.rs @@ -1,6 +1,6 @@ //! Several ABI-related utilities for executors. -use alloy_primitives::{Address, Selector}; +use alloy_primitives::Address; pub use foundry_abi::{ console::{self, ConsoleEvents, CONSOLE_ABI}, hardhat_console::{self, HardhatConsoleCalls, HARDHATCONSOLE_ABI as HARDHAT_CONSOLE_ABI}, @@ -28,12 +28,10 @@ pub const HARDHAT_CONSOLE_ADDRESS: Address = Address::new([ /// If the input starts with a known `hardhat/console.log` `uint` selector, then this will replace /// it with the selector `abigen!` bindings expect. -pub fn patch_hardhat_console_selector(input: &mut [u8]) { +pub fn patch_hardhat_console_selector(input: &mut Vec) { if input.len() < 4 { return } - - // SAFETY: length checked above; see [<[T]>::split_array_mut]. let selector = unsafe { &mut *(input.get_unchecked_mut(..4) as *mut [u8] as *mut [u8; 4]) }; if let Some(abigen_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { *selector = *abigen_selector; @@ -47,517 +45,520 @@ pub fn patch_hardhat_console_selector(input: &mut [u8]) { /// bindings which `abigen!` creates. `hardhat/console.log` logs its events in functions that accept /// `uint` manually as `abi.encodeWithSignature("log(int)", p0)`, but `abigen!` uses `uint256` for /// its call bindings (`HardhatConsoleCalls`) as generated by solc. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { - HashMap::from([ - // log(bool,uint256,uint256,address) - ([241, 97, 178, 33], [0, 221, 135, 185]), - // log(uint256,address,address,string) - ([121, 67, 220, 102], [3, 28, 111, 115]), - // log(uint256,bool,address,uint256) - ([65, 181, 239, 59], [7, 130, 135, 245]), - // log(bool,address,bool,uint256) - ([76, 182, 15, 209], [7, 131, 21, 2]), - // log(bool,uint256,address) - ([196, 210, 53, 7], [8, 142, 249, 210]), - // log(uint256,address,address,bool) - ([1, 85, 11, 4], [9, 31, 250, 245]), - // log(address,bool,uint256,string) - ([155, 88, 142, 204], [10, 166, 207, 173]), - // log(bool,bool,uint256,uint256) - ([70, 103, 222, 142], [11, 176, 14, 171]), - // log(bool,address,address,uint256) - ([82, 132, 189, 108], [12, 102, 209, 190]), - // log(uint256,address,uint256,uint256) - ([202, 154, 62, 180], [12, 156, 217, 193]), - // log(string,address,uint256) - ([7, 200, 18, 23], [13, 38, 185, 37]), - // log(address,string,uint256,bool) - ([126, 37, 13, 91], [14, 247, 224, 80]), - // log(address,uint256,address,uint256) - ([165, 217, 135, 104], [16, 15, 101, 14]), - // log(string,string,uint256,address) - ([93, 79, 70, 128], [16, 35, 247, 178]), - // log(bool,string,uint256) - ([192, 56, 42, 172], [16, 147, 238, 17]), - // log(bool,bool,uint256) - ([176, 19, 101, 187], [18, 242, 22, 2]), - // log(bool,address,uint256,address) - ([104, 241, 88, 181], [19, 107, 5, 221]), - // log(bool,uint256,address,uint256) - ([202, 165, 35, 106], [21, 55, 220, 135]), - // log(bool,string,uint256,address) - ([91, 34, 185, 56], [21, 150, 161, 206]), - // log(address,string,string,uint256) - ([161, 79, 208, 57], [21, 159, 137, 39]), - // log(uint256,address,uint256,address) - ([253, 178, 236, 212], [21, 193, 39, 181]), - // log(uint256,uint256,address,bool) - ([168, 232, 32, 174], [21, 202, 196, 118]), - // log(bool,string,bool,uint256) - ([141, 111, 156, 165], [22, 6, 163, 147]), - // log(address,address,uint256) - ([108, 54, 109, 114], [23, 254, 97, 133]), - // log(uint256,uint256,uint256,uint256) - ([92, 160, 173, 62], [25, 63, 184, 0]), - // log(bool,string,uint256,string) - ([119, 161, 171, 237], [26, 217, 109, 230]), - // log(bool,uint256,address,string) - ([24, 9, 19, 65], [27, 179, 176, 154]), - // log(string,uint256,address) - ([227, 132, 159, 121], [28, 126, 196, 72]), - // log(uint256,bool) - ([30, 109, 212, 236], [28, 157, 126, 179]), - // log(address,uint256,address,string) - ([93, 113, 243, 158], [29, 169, 134, 234]), - // log(address,string,uint256,uint256) - ([164, 201, 42, 96], [29, 200, 225, 184]), - // log(uint256,bool,uint256) - ([90, 77, 153, 34], [32, 9, 128, 20]), - // log(uint256,bool,bool) - ([213, 206, 172, 224], [32, 113, 134, 80]), - // log(address,uint256,uint256,address) - ([30, 246, 52, 52], [32, 227, 152, 77]), - // log(uint256,string,string,string) - ([87, 221, 10, 17], [33, 173, 6, 131]), - // log(address,uint256,bool,uint256) - ([105, 143, 67, 146], [34, 246, 185, 153]), - // log(uint256,address,address,address) - ([85, 71, 69, 249], [36, 136, 180, 20]), - // log(string,bool,string,uint256) - ([52, 203, 48, 141], [36, 249, 20, 101]), - // log(bool,uint256,address,address) - ([138, 47, 144, 170], [38, 245, 96, 168]), - // log(uint256,uint256,string,string) - ([124, 3, 42, 50], [39, 216, 175, 210]), - // log(bool,string,uint256,uint256) - ([142, 74, 232, 110], [40, 134, 63, 203]), - // log(uint256,bool,string,uint256) - ([145, 95, 219, 40], [44, 29, 7, 70]), - // log(address,uint256,uint256,uint256) - ([61, 14, 157, 228], [52, 240, 230, 54]), - // log(uint256,bool,address) - ([66, 78, 255, 191], [53, 8, 95, 123]), - // log(string,uint256,bool,bool) - ([227, 127, 243, 208], [53, 76, 54, 214]), - // log(bool,uint256,uint256) - ([59, 92, 3, 224], [55, 16, 51, 103]), - // log(bool,uint256,uint256,uint256) - ([50, 223, 165, 36], [55, 75, 180, 178]), - // log(uint256,string,uint256) - ([91, 109, 232, 63], [55, 170, 125, 76]), - // log(address,bool,uint256,uint256) - ([194, 16, 160, 30], [56, 111, 245, 244]), - // log(address,address,bool,uint256) - ([149, 214, 95, 17], [57, 113, 231, 140]), - // log(bool,uint256) - ([54, 75, 106, 146], [57, 145, 116, 211]), - // log(uint256,string,uint256,address) - ([171, 123, 217, 253], [59, 34, 121, 180]), - // log(address,uint256,bool,bool) - ([254, 161, 213, 90], [59, 245, 229, 55]), - // log(uint256,address,string,string) - ([141, 119, 134, 36], [62, 18, 140, 163]), - // log(string,address,bool,uint256) - ([197, 209, 187, 139], [62, 159, 134, 106]), - // log(uint256,uint256,string,address) - ([67, 50, 133, 162], [66, 210, 29, 183]), - // log(address,string,uint256,string) - ([93, 19, 101, 201], [68, 136, 48, 168]), - // log(uint256,bool,address,bool) - ([145, 251, 18, 66], [69, 77, 84, 165]), - // log(address,string,address,uint256) - ([140, 25, 51, 169], [69, 127, 227, 207]), - // log(uint256,address,string,uint256) - ([160, 196, 20, 232], [70, 130, 107, 93]), - // log(uint256,uint256,bool) - ([103, 87, 15, 247], [71, 102, 218, 114]), - // log(address,uint256,address,address) - ([236, 36, 132, 111], [71, 141, 28, 98]), - // log(address,uint256,uint256,string) - ([137, 52, 13, 171], [74, 40, 192, 23]), - // log(bool,bool,address,uint256) - ([96, 147, 134, 231], [76, 18, 61, 87]), - // log(uint256,string,bool) - ([70, 167, 208, 206], [76, 237, 167, 90]), - // log(string,uint256,address,uint256) - ([88, 73, 122, 254], [79, 4, 253, 198]), - // log(address,string,bool,uint256) - ([231, 32, 82, 28], [81, 94, 56, 182]), - // log(bool,address,uint256,string) - ([160, 104, 88, 51], [81, 240, 159, 248]), - // log(bool,bool,uint256,address) - ([11, 255, 149, 13], [84, 167, 169, 160]), - // log(uint256,uint256,address,address) - ([202, 147, 155, 32], [86, 165, 209, 177]), - // log(string,string,uint256) - ([243, 98, 202, 89], [88, 33, 239, 161]), - // log(string,uint256,string) - ([163, 245, 199, 57], [89, 112, 224, 137]), - // log(uint256,uint256,uint256,string) - ([120, 173, 122, 12], [89, 207, 203, 227]), - // log(string,address,uint256,string) - ([76, 85, 242, 52], [90, 71, 118, 50]), - // log(uint256,address,uint256) - ([136, 67, 67, 170], [90, 155, 94, 213]), - // log(string,uint256,string,string) - ([108, 152, 218, 226], [90, 184, 78, 31]), - // log(uint256,address,bool,uint256) - ([123, 8, 232, 235], [90, 189, 153, 42]), - // log(address,uint256,string,address) - ([220, 121, 38, 4], [92, 67, 13, 71]), - // log(uint256,uint256,address) - ([190, 51, 73, 27], [92, 150, 179, 49]), - // log(string,bool,address,uint256) - ([40, 223, 78, 150], [93, 8, 187, 5]), - // log(string,string,uint256,string) - ([141, 20, 44, 221], [93, 26, 151, 26]), - // log(uint256,uint256,string,uint256) - ([56, 148, 22, 61], [93, 162, 151, 235]), - // log(string,uint256,address,address) - ([234, 200, 146, 129], [94, 162, 183, 174]), - // log(uint256,address,uint256,bool) - ([25, 246, 115, 105], [95, 116, 58, 124]), - // log(bool,address,uint256) - ([235, 112, 75, 175], [95, 123, 154, 251]), - // log(uint256,string,address,address) - ([127, 165, 69, 139], [97, 104, 237, 97]), - // log(bool,bool,uint256,bool) - ([171, 92, 193, 196], [97, 158, 77, 14]), - // log(address,string,uint256,address) - ([223, 215, 216, 11], [99, 24, 54, 120]), - // log(uint256,address,string) - ([206, 131, 4, 123], [99, 203, 65, 249]), - // log(string,address,uint256,address) - ([163, 102, 236, 128], [99, 251, 139, 197]), - // log(uint256,string) - ([15, 163, 243, 69], [100, 63, 208, 223]), - // log(string,bool,uint256,uint256) - ([93, 191, 240, 56], [100, 181, 187, 103]), - // log(address,uint256,uint256,bool) - ([236, 75, 168, 162], [102, 241, 188, 103]), - // log(address,uint256,bool) - ([229, 74, 225, 68], [103, 130, 9, 168]), - // log(address,string,uint256) - ([28, 218, 242, 138], [103, 221, 111, 241]), - // log(uint256,bool,string,string) - ([164, 51, 252, 253], [104, 200, 184, 189]), - // log(uint256,string,uint256,bool) - ([135, 90, 110, 46], [105, 26, 143, 116]), - // log(uint256,address) - ([88, 235, 134, 12], [105, 39, 108, 134]), - // log(uint256,bool,bool,address) - ([83, 6, 34, 93], [105, 100, 11, 89]), - // log(bool,uint256,string,uint256) - ([65, 128, 1, 27], [106, 17, 153, 226]), - // log(bool,string,uint256,bool) - ([32, 187, 201, 175], [107, 14, 93, 83]), - // log(uint256,uint256,address,string) - ([214, 162, 209, 222], [108, 222, 64, 184]), - // log(bool,bool,bool,uint256) - ([194, 72, 131, 77], [109, 112, 69, 193]), - // log(uint256,uint256,string) - ([125, 105, 14, 230], [113, 208, 74, 242]), - // log(uint256,address,address,uint256) - ([154, 60, 191, 150], [115, 110, 251, 182]), - // log(string,bool,uint256,string) - ([66, 185, 162, 39], [116, 45, 110, 231]), - // log(uint256,bool,bool,uint256) - ([189, 37, 173, 89], [116, 100, 206, 35]), - // log(string,uint256,uint256,bool) - ([247, 60, 126, 61], [118, 38, 219, 146]), - // log(uint256,uint256,string,bool) - ([178, 46, 175, 6], [122, 246, 171, 37]), - // log(uint256,string,address) - ([31, 144, 242, 74], [122, 250, 201, 89]), - // log(address,uint256,address) - ([151, 236, 163, 148], [123, 192, 216, 72]), - // log(bool,string,string,uint256) - ([93, 219, 37, 146], [123, 224, 195, 235]), - // log(bool,address,uint256,uint256) - ([155, 254, 114, 188], [123, 241, 129, 161]), - // log(string,uint256,string,address) - ([187, 114, 53, 233], [124, 70, 50, 164]), - // log(string,string,address,uint256) - ([74, 129, 165, 106], [124, 195, 198, 7]), - // log(string,uint256,string,bool) - ([233, 159, 130, 207], [125, 36, 73, 29]), - // log(bool,bool,uint256,string) - ([80, 97, 137, 55], [125, 212, 208, 224]), - // log(bool,uint256,bool,uint256) - ([211, 222, 85, 147], [127, 155, 188, 162]), - // log(address,bool,string,uint256) - ([158, 18, 123, 110], [128, 230, 162, 11]), - // log(string,uint256,address,bool) - ([17, 6, 168, 247], [130, 17, 42, 66]), - // log(uint256,string,uint256,uint256) - ([192, 4, 56, 7], [130, 194, 91, 116]), - // log(address,uint256) - ([34, 67, 207, 163], [131, 9, 232, 168]), - // log(string,uint256,uint256,string) - ([165, 78, 212, 189], [133, 75, 52, 150]), - // log(uint256,bool,string) - ([139, 14, 20, 254], [133, 119, 80, 33]), - // log(address,uint256,string,string) - ([126, 86, 198, 147], [136, 168, 196, 6]), - // log(uint256,bool,uint256,address) - ([79, 64, 5, 142], [136, 203, 96, 65]), - // log(uint256,uint256,address,uint256) - ([97, 11, 168, 192], [136, 246, 228, 178]), - // log(string,bool,uint256,bool) - ([60, 197, 181, 211], [138, 247, 207, 138]), - // log(address,bool,bool,uint256) - ([207, 181, 135, 86], [140, 78, 93, 230]), - // log(address,address,uint256,address) - ([214, 198, 82, 118], [141, 166, 222, 245]), - // log(string,bool,bool,uint256) - ([128, 117, 49, 232], [142, 63, 120, 169]), - // log(bool,uint256,uint256,string) - ([218, 6, 102, 200], [142, 105, 251, 93]), - // log(string,string,string,uint256) - ([159, 208, 9, 245], [142, 175, 176, 43]), - // log(string,address,address,uint256) - ([110, 183, 148, 61], [142, 243, 243, 153]), - // log(uint256,string,address,bool) - ([249, 63, 255, 55], [144, 195, 10, 86]), - // log(uint256,address,bool,string) - ([99, 240, 226, 66], [144, 251, 6, 170]), - // log(bool,uint256,bool,string) - ([182, 213, 105, 212], [145, 67, 219, 177]), - // log(uint256,bool,uint256,bool) - ([210, 171, 196, 253], [145, 160, 46, 42]), - // log(string,address,string,uint256) - ([143, 98, 75, 233], [145, 209, 17, 46]), - // log(string,bool,uint256,address) - ([113, 211, 133, 13], [147, 94, 9, 191]), - // log(address,address,address,uint256) - ([237, 94, 172, 135], [148, 37, 13, 119]), - // log(uint256,uint256,bool,address) - ([225, 23, 116, 79], [154, 129, 106, 131]), - // log(bool,uint256,bool,address) - ([66, 103, 199, 248], [154, 205, 54, 22]), - // log(address,address,uint256,bool) - ([194, 246, 136, 236], [155, 66, 84, 226]), - // log(uint256,address,bool) - ([122, 208, 18, 142], [155, 110, 192, 66]), - // log(uint256,string,address,string) - ([248, 152, 87, 127], [156, 58, 223, 161]), - // log(address,bool,uint256) - ([44, 70, 141, 21], [156, 79, 153, 251]), - // log(uint256,address,string,address) - ([203, 229, 142, 253], [156, 186, 143, 255]), - // log(string,uint256,address,string) - ([50, 84, 194, 232], [159, 251, 47, 147]), - // log(address,uint256,address,bool) - ([241, 129, 161, 233], [161, 188, 201, 179]), - // log(uint256,bool,address,address) - ([134, 237, 193, 12], [161, 239, 76, 187]), - // log(address,uint256,string) - ([186, 249, 104, 73], [161, 242, 232, 170]), - // log(address,uint256,bool,address) - ([35, 229, 73, 114], [163, 27, 253, 204]), - // log(uint256,uint256,bool,string) - ([239, 217, 203, 238], [165, 180, 252, 153]), - // log(bool,string,address,uint256) - ([27, 11, 149, 91], [165, 202, 218, 148]), - // log(address,bool,address,uint256) - ([220, 113, 22, 210], [167, 92, 89, 222]), - // log(string,uint256,uint256,uint256) - ([8, 238, 86, 102], [167, 168, 120, 83]), - // log(uint256,uint256,bool,bool) - ([148, 190, 59, 177], [171, 8, 90, 230]), - // log(string,uint256,bool,string) - ([118, 204, 96, 100], [171, 247, 58, 152]), - // log(uint256,bool,address,string) - ([162, 48, 118, 30], [173, 224, 82, 199]), - // log(uint256,string,bool,address) - ([121, 111, 40, 160], [174, 46, 197, 129]), - // log(uint256,string,string,uint256) - ([118, 236, 99, 94], [176, 40, 201, 189]), - // log(uint256,string,string) - ([63, 87, 194, 149], [177, 21, 97, 31]), - // log(uint256,string,string,bool) - ([18, 134, 43, 152], [179, 166, 182, 189]), - // log(bool,uint256,address,bool) - ([101, 173, 244, 8], [180, 195, 20, 255]), - // log(string,uint256) - ([151, 16, 169, 208], [182, 14, 114, 204]), - // log(address,uint256,uint256) - ([135, 134, 19, 94], [182, 155, 202, 246]), - // log(uint256,bool,bool,bool) - ([78, 108, 83, 21], [182, 245, 119, 161]), - // log(uint256,string,uint256,string) - ([162, 188, 12, 153], [183, 185, 20, 202]), - // log(uint256,string,bool,bool) - ([81, 188, 43, 193], [186, 83, 93, 156]), - // log(uint256,address,address) - ([125, 119, 166, 27], [188, 253, 155, 224]), - // log(address,address,uint256,uint256) - ([84, 253, 243, 228], [190, 85, 52, 129]), - // log(bool,uint256,uint256,bool) - ([164, 29, 129, 222], [190, 152, 67, 83]), - // log(address,uint256,string,uint256) - ([245, 18, 207, 155], [191, 1, 248, 145]), - // log(bool,address,string,uint256) - ([11, 153, 252, 34], [194, 31, 100, 199]), - // log(string,string,uint256,bool) - ([230, 86, 88, 202], [195, 168, 166, 84]), - // log(bool,uint256,string) - ([200, 57, 126, 176], [195, 252, 57, 112]), - // log(address,bool,uint256,bool) - ([133, 205, 197, 175], [196, 100, 62, 32]), - // log(uint256,uint256,uint256,bool) - ([100, 82, 185, 203], [197, 152, 209, 133]), - // log(address,uint256,bool,string) - ([142, 142, 78, 117], [197, 173, 133, 249]), - // log(string,uint256,string,uint256) - ([160, 196, 178, 37], [198, 126, 169, 209]), - // log(uint256,bool,uint256,uint256) - ([86, 130, 141, 164], [198, 172, 199, 168]), - // log(string,bool,uint256) - ([41, 27, 185, 208], [201, 89, 88, 214]), - // log(string,uint256,uint256) - ([150, 156, 221, 3], [202, 71, 196, 235]), - // log(string,uint256,bool) - ([241, 2, 238, 5], [202, 119, 51, 177]), - // log(uint256,address,string,bool) - ([34, 164, 121, 166], [204, 50, 171, 7]), - // log(address,bool,uint256,address) - ([13, 140, 230, 30], [204, 247, 144, 161]), - // log(bool,uint256,bool,bool) - ([158, 1, 247, 65], [206, 181, 244, 215]), - // log(uint256,string,bool,uint256) - ([164, 180, 138, 127], [207, 0, 152, 128]), - // log(address,uint256,string,bool) - ([164, 2, 79, 17], [207, 24, 16, 92]), - // log(uint256,uint256,uint256) - ([231, 130, 10, 116], [209, 237, 122, 60]), - // log(uint256,string,bool,string) - ([141, 72, 156, 160], [210, 212, 35, 205]), - // log(uint256,string,string,address) - ([204, 152, 138, 160], [213, 131, 198, 2]), - // log(bool,address,uint256,bool) - ([238, 141, 134, 114], [214, 1, 159, 28]), - // log(string,string,bool,uint256) - ([134, 129, 138, 122], [214, 174, 250, 210]), - // log(uint256,address,uint256,string) - ([62, 211, 189, 40], [221, 176, 101, 33]), - // log(uint256,bool,bool,string) - ([49, 138, 229, 155], [221, 219, 149, 97]), - // log(uint256,bool,uint256,string) - ([232, 221, 188, 86], [222, 3, 231, 116]), - // log(string,uint256,bool,address) - ([229, 84, 157, 145], [224, 233, 91, 152]), - // log(string,uint256,uint256,address) - ([190, 215, 40, 191], [226, 29, 226, 120]), - // log(uint256,address,bool,bool) - ([126, 39, 65, 13], [227, 81, 20, 15]), - // log(bool,bool,string,uint256) - ([23, 139, 70, 133], [227, 169, 202, 47]), - // log(string,uint256,bool,uint256) - ([85, 14, 110, 245], [228, 27, 111, 111]), - // log(bool,uint256,string,bool) - ([145, 210, 248, 19], [229, 231, 11, 43]), - // log(uint256,string,address,uint256) - ([152, 231, 243, 243], [232, 211, 1, 141]), - // log(bool,uint256,bool) - ([27, 173, 201, 235], [232, 222, 251, 169]), - // log(uint256,uint256,bool,uint256) - ([108, 100, 124, 140], [235, 127, 111, 210]), - // log(uint256,bool,string,bool) - ([52, 110, 184, 199], [235, 146, 141, 127]), - // log(address,address,string,uint256) - ([4, 40, 147, 0], [239, 28, 239, 231]), - // log(uint256,bool,string,address) - ([73, 110, 43, 180], [239, 82, 144, 24]), - // log(uint256,address,bool,address) - ([182, 49, 48, 148], [239, 114, 197, 19]), - // log(string,string,uint256,uint256) - ([213, 207, 23, 208], [244, 93, 125, 44]), - // log(bool,uint256,string,string) - ([211, 42, 101, 72], [245, 188, 34, 73]), - // log(uint256,uint256) - ([108, 15, 105, 128], [246, 102, 113, 90]), - // log(uint256) and logUint(uint256) - ([245, 177, 187, 169], [248, 44, 80, 241]), - // log(string,address,uint256,uint256) - ([218, 163, 148, 189], [248, 245, 27, 30]), - // log(uint256,uint256,uint256,address) - ([224, 133, 63, 105], [250, 129, 133, 175]), - // log(string,address,uint256,bool) - ([90, 193, 193, 60], [252, 72, 69, 240]), - // log(address,address,uint256,string) - ([157, 209, 46, 173], [253, 180, 249, 144]), - // log(bool,uint256,string,address) - ([165, 199, 13, 41], [254, 221, 31, 255]), - // logInt(int256) - ([78, 12, 29, 29], [101, 37, 181, 245]), - // logBytes(bytes) - ([11, 231, 127, 86], [225, 123, 249, 86]), - // logBytes1(bytes1) - ([110, 24, 161, 40], [111, 65, 113, 201]), - // logBytes2(bytes2) - ([233, 182, 34, 150], [155, 94, 148, 62]), - // logBytes3(bytes3) - ([45, 131, 73, 38], [119, 130, 250, 45]), - // logBytes4(bytes4) - ([224, 95, 72, 209], [251, 163, 173, 57]), - // logBytes5(bytes5) - ([166, 132, 128, 141], [85, 131, 190, 46]), - // logBytes6(bytes6) - ([174, 132, 165, 145], [73, 66, 173, 198]), - // logBytes7(bytes7) - ([78, 213, 126, 40], [69, 116, 175, 171]), - // logBytes8(bytes8) - ([79, 132, 37, 46], [153, 2, 228, 127]), - // logBytes9(bytes9) - ([144, 189, 140, 208], [80, 161, 56, 223]), - // logBytes10(bytes10) - ([1, 61, 23, 139], [157, 194, 168, 151]), - // logBytes11(bytes11) - ([4, 0, 74, 46], [220, 8, 182, 167]), - // logBytes12(bytes12) - ([134, 160, 106, 189], [118, 86, 214, 199]), - // logBytes13(bytes13) - ([148, 82, 158, 52], [52, 193, 216, 27]), - // logBytes14(bytes14) - ([146, 102, 240, 127], [60, 234, 186, 101]), - // logBytes15(bytes15) - ([218, 149, 116, 224], [89, 26, 61, 162]), - // logBytes16(bytes16) - ([102, 92, 97, 4], [31, 141, 115, 18]), - // logBytes17(bytes17) - ([51, 159, 103, 58], [248, 154, 83, 47]), - // logBytes18(bytes18) - ([196, 210, 61, 154], [216, 101, 38, 66]), - // logBytes19(bytes19) - ([94, 107, 90, 51], [0, 245, 107, 201]), - // logBytes20(bytes20) - ([81, 136, 227, 233], [236, 184, 86, 126]), - // logBytes21(bytes21) - ([233, 218, 53, 96], [48, 82, 192, 143]), - // logBytes22(bytes22) - ([213, 250, 232, 156], [128, 122, 180, 52]), - // logBytes23(bytes23) - ([171, 161, 207, 13], [73, 121, 176, 55]), - // logBytes24(bytes24) - ([241, 179, 91, 52], [9, 119, 174, 252]), - // logBytes25(bytes25) - ([11, 132, 188, 88], [174, 169, 150, 63]), - // logBytes26(bytes26) - ([248, 177, 73, 241], [211, 99, 86, 40]), - // logBytes27(bytes27) - ([58, 55, 87, 221], [252, 55, 47, 159]), - // logBytes28(bytes28) - ([200, 42, 234, 238], [56, 47, 154, 52]), - // logBytes29(bytes29) - ([75, 105, 195, 213], [122, 24, 118, 65]), - // logBytes30(bytes30) - ([238, 18, 196, 237], [196, 52, 14, 246]), - // logBytes31(bytes31) - ([194, 133, 77, 146], [129, 252, 134, 72]), - // logBytes32(bytes32) - ([39, 183, 207, 133], [45, 33, 214, 247]), - ]) +pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { + HashMap::from( + [ + // log(bool,uint256,uint256,address) + ([241, 97, 178, 33], [0, 221, 135, 185]), + // log(uint256,address,address,string) + ([121, 67, 220, 102], [3, 28, 111, 115]), + // log(uint256,bool,address,uint256) + ([65, 181, 239, 59], [7, 130, 135, 245]), + // log(bool,address,bool,uint256) + ([76, 182, 15, 209], [7, 131, 21, 2]), + // log(bool,uint256,address) + ([196, 210, 53, 7], [8, 142, 249, 210]), + // log(uint256,address,address,bool) + ([1, 85, 11, 4], [9, 31, 250, 245]), + // log(address,bool,uint256,string) + ([155, 88, 142, 204], [10, 166, 207, 173]), + // log(bool,bool,uint256,uint256) + ([70, 103, 222, 142], [11, 176, 14, 171]), + // log(bool,address,address,uint256) + ([82, 132, 189, 108], [12, 102, 209, 190]), + // log(uint256,address,uint256,uint256) + ([202, 154, 62, 180], [12, 156, 217, 193]), + // log(string,address,uint256) + ([7, 200, 18, 23], [13, 38, 185, 37]), + // log(address,string,uint256,bool) + ([126, 37, 13, 91], [14, 247, 224, 80]), + // log(address,uint256,address,uint256) + ([165, 217, 135, 104], [16, 15, 101, 14]), + // log(string,string,uint256,address) + ([93, 79, 70, 128], [16, 35, 247, 178]), + // log(bool,string,uint256) + ([192, 56, 42, 172], [16, 147, 238, 17]), + // log(bool,bool,uint256) + ([176, 19, 101, 187], [18, 242, 22, 2]), + // log(bool,address,uint256,address) + ([104, 241, 88, 181], [19, 107, 5, 221]), + // log(bool,uint256,address,uint256) + ([202, 165, 35, 106], [21, 55, 220, 135]), + // log(bool,string,uint256,address) + ([91, 34, 185, 56], [21, 150, 161, 206]), + // log(address,string,string,uint256) + ([161, 79, 208, 57], [21, 159, 137, 39]), + // log(uint256,address,uint256,address) + ([253, 178, 236, 212], [21, 193, 39, 181]), + // log(uint256,uint256,address,bool) + ([168, 232, 32, 174], [21, 202, 196, 118]), + // log(bool,string,bool,uint256) + ([141, 111, 156, 165], [22, 6, 163, 147]), + // log(address,address,uint256) + ([108, 54, 109, 114], [23, 254, 97, 133]), + // log(uint256,uint256,uint256,uint256) + ([92, 160, 173, 62], [25, 63, 184, 0]), + // log(bool,string,uint256,string) + ([119, 161, 171, 237], [26, 217, 109, 230]), + // log(bool,uint256,address,string) + ([24, 9, 19, 65], [27, 179, 176, 154]), + // log(string,uint256,address) + ([227, 132, 159, 121], [28, 126, 196, 72]), + // log(uint256,bool) + ([30, 109, 212, 236], [28, 157, 126, 179]), + // log(address,uint256,address,string) + ([93, 113, 243, 158], [29, 169, 134, 234]), + // log(address,string,uint256,uint256) + ([164, 201, 42, 96], [29, 200, 225, 184]), + // log(uint256,bool,uint256) + ([90, 77, 153, 34], [32, 9, 128, 20]), + // log(uint256,bool,bool) + ([213, 206, 172, 224], [32, 113, 134, 80]), + // log(address,uint256,uint256,address) + ([30, 246, 52, 52], [32, 227, 152, 77]), + // log(uint256,string,string,string) + ([87, 221, 10, 17], [33, 173, 6, 131]), + // log(address,uint256,bool,uint256) + ([105, 143, 67, 146], [34, 246, 185, 153]), + // log(uint256,address,address,address) + ([85, 71, 69, 249], [36, 136, 180, 20]), + // log(string,bool,string,uint256) + ([52, 203, 48, 141], [36, 249, 20, 101]), + // log(bool,uint256,address,address) + ([138, 47, 144, 170], [38, 245, 96, 168]), + // log(uint256,uint256,string,string) + ([124, 3, 42, 50], [39, 216, 175, 210]), + // log(bool,string,uint256,uint256) + ([142, 74, 232, 110], [40, 134, 63, 203]), + // log(uint256,bool,string,uint256) + ([145, 95, 219, 40], [44, 29, 7, 70]), + // log(address,uint256,uint256,uint256) + ([61, 14, 157, 228], [52, 240, 230, 54]), + // log(uint256,bool,address) + ([66, 78, 255, 191], [53, 8, 95, 123]), + // log(string,uint256,bool,bool) + ([227, 127, 243, 208], [53, 76, 54, 214]), + // log(bool,uint256,uint256) + ([59, 92, 3, 224], [55, 16, 51, 103]), + // log(bool,uint256,uint256,uint256) + ([50, 223, 165, 36], [55, 75, 180, 178]), + // log(uint256,string,uint256) + ([91, 109, 232, 63], [55, 170, 125, 76]), + // log(address,bool,uint256,uint256) + ([194, 16, 160, 30], [56, 111, 245, 244]), + // log(address,address,bool,uint256) + ([149, 214, 95, 17], [57, 113, 231, 140]), + // log(bool,uint256) + ([54, 75, 106, 146], [57, 145, 116, 211]), + // log(uint256,string,uint256,address) + ([171, 123, 217, 253], [59, 34, 121, 180]), + // log(address,uint256,bool,bool) + ([254, 161, 213, 90], [59, 245, 229, 55]), + // log(uint256,address,string,string) + ([141, 119, 134, 36], [62, 18, 140, 163]), + // log(string,address,bool,uint256) + ([197, 209, 187, 139], [62, 159, 134, 106]), + // log(uint256,uint256,string,address) + ([67, 50, 133, 162], [66, 210, 29, 183]), + // log(address,string,uint256,string) + ([93, 19, 101, 201], [68, 136, 48, 168]), + // log(uint256,bool,address,bool) + ([145, 251, 18, 66], [69, 77, 84, 165]), + // log(address,string,address,uint256) + ([140, 25, 51, 169], [69, 127, 227, 207]), + // log(uint256,address,string,uint256) + ([160, 196, 20, 232], [70, 130, 107, 93]), + // log(uint256,uint256,bool) + ([103, 87, 15, 247], [71, 102, 218, 114]), + // log(address,uint256,address,address) + ([236, 36, 132, 111], [71, 141, 28, 98]), + // log(address,uint256,uint256,string) + ([137, 52, 13, 171], [74, 40, 192, 23]), + // log(bool,bool,address,uint256) + ([96, 147, 134, 231], [76, 18, 61, 87]), + // log(uint256,string,bool) + ([70, 167, 208, 206], [76, 237, 167, 90]), + // log(string,uint256,address,uint256) + ([88, 73, 122, 254], [79, 4, 253, 198]), + // log(address,string,bool,uint256) + ([231, 32, 82, 28], [81, 94, 56, 182]), + // log(bool,address,uint256,string) + ([160, 104, 88, 51], [81, 240, 159, 248]), + // log(bool,bool,uint256,address) + ([11, 255, 149, 13], [84, 167, 169, 160]), + // log(uint256,uint256,address,address) + ([202, 147, 155, 32], [86, 165, 209, 177]), + // log(string,string,uint256) + ([243, 98, 202, 89], [88, 33, 239, 161]), + // log(string,uint256,string) + ([163, 245, 199, 57], [89, 112, 224, 137]), + // log(uint256,uint256,uint256,string) + ([120, 173, 122, 12], [89, 207, 203, 227]), + // log(string,address,uint256,string) + ([76, 85, 242, 52], [90, 71, 118, 50]), + // log(uint256,address,uint256) + ([136, 67, 67, 170], [90, 155, 94, 213]), + // log(string,uint256,string,string) + ([108, 152, 218, 226], [90, 184, 78, 31]), + // log(uint256,address,bool,uint256) + ([123, 8, 232, 235], [90, 189, 153, 42]), + // log(address,uint256,string,address) + ([220, 121, 38, 4], [92, 67, 13, 71]), + // log(uint256,uint256,address) + ([190, 51, 73, 27], [92, 150, 179, 49]), + // log(string,bool,address,uint256) + ([40, 223, 78, 150], [93, 8, 187, 5]), + // log(string,string,uint256,string) + ([141, 20, 44, 221], [93, 26, 151, 26]), + // log(uint256,uint256,string,uint256) + ([56, 148, 22, 61], [93, 162, 151, 235]), + // log(string,uint256,address,address) + ([234, 200, 146, 129], [94, 162, 183, 174]), + // log(uint256,address,uint256,bool) + ([25, 246, 115, 105], [95, 116, 58, 124]), + // log(bool,address,uint256) + ([235, 112, 75, 175], [95, 123, 154, 251]), + // log(uint256,string,address,address) + ([127, 165, 69, 139], [97, 104, 237, 97]), + // log(bool,bool,uint256,bool) + ([171, 92, 193, 196], [97, 158, 77, 14]), + // log(address,string,uint256,address) + ([223, 215, 216, 11], [99, 24, 54, 120]), + // log(uint256,address,string) + ([206, 131, 4, 123], [99, 203, 65, 249]), + // log(string,address,uint256,address) + ([163, 102, 236, 128], [99, 251, 139, 197]), + // log(uint256,string) + ([15, 163, 243, 69], [100, 63, 208, 223]), + // log(string,bool,uint256,uint256) + ([93, 191, 240, 56], [100, 181, 187, 103]), + // log(address,uint256,uint256,bool) + ([236, 75, 168, 162], [102, 241, 188, 103]), + // log(address,uint256,bool) + ([229, 74, 225, 68], [103, 130, 9, 168]), + // log(address,string,uint256) + ([28, 218, 242, 138], [103, 221, 111, 241]), + // log(uint256,bool,string,string) + ([164, 51, 252, 253], [104, 200, 184, 189]), + // log(uint256,string,uint256,bool) + ([135, 90, 110, 46], [105, 26, 143, 116]), + // log(uint256,address) + ([88, 235, 134, 12], [105, 39, 108, 134]), + // log(uint256,bool,bool,address) + ([83, 6, 34, 93], [105, 100, 11, 89]), + // log(bool,uint256,string,uint256) + ([65, 128, 1, 27], [106, 17, 153, 226]), + // log(bool,string,uint256,bool) + ([32, 187, 201, 175], [107, 14, 93, 83]), + // log(uint256,uint256,address,string) + ([214, 162, 209, 222], [108, 222, 64, 184]), + // log(bool,bool,bool,uint256) + ([194, 72, 131, 77], [109, 112, 69, 193]), + // log(uint256,uint256,string) + ([125, 105, 14, 230], [113, 208, 74, 242]), + // log(uint256,address,address,uint256) + ([154, 60, 191, 150], [115, 110, 251, 182]), + // log(string,bool,uint256,string) + ([66, 185, 162, 39], [116, 45, 110, 231]), + // log(uint256,bool,bool,uint256) + ([189, 37, 173, 89], [116, 100, 206, 35]), + // log(string,uint256,uint256,bool) + ([247, 60, 126, 61], [118, 38, 219, 146]), + // log(uint256,uint256,string,bool) + ([178, 46, 175, 6], [122, 246, 171, 37]), + // log(uint256,string,address) + ([31, 144, 242, 74], [122, 250, 201, 89]), + // log(address,uint256,address) + ([151, 236, 163, 148], [123, 192, 216, 72]), + // log(bool,string,string,uint256) + ([93, 219, 37, 146], [123, 224, 195, 235]), + // log(bool,address,uint256,uint256) + ([155, 254, 114, 188], [123, 241, 129, 161]), + // log(string,uint256,string,address) + ([187, 114, 53, 233], [124, 70, 50, 164]), + // log(string,string,address,uint256) + ([74, 129, 165, 106], [124, 195, 198, 7]), + // log(string,uint256,string,bool) + ([233, 159, 130, 207], [125, 36, 73, 29]), + // log(bool,bool,uint256,string) + ([80, 97, 137, 55], [125, 212, 208, 224]), + // log(bool,uint256,bool,uint256) + ([211, 222, 85, 147], [127, 155, 188, 162]), + // log(address,bool,string,uint256) + ([158, 18, 123, 110], [128, 230, 162, 11]), + // log(string,uint256,address,bool) + ([17, 6, 168, 247], [130, 17, 42, 66]), + // log(uint256,string,uint256,uint256) + ([192, 4, 56, 7], [130, 194, 91, 116]), + // log(address,uint256) + ([34, 67, 207, 163], [131, 9, 232, 168]), + // log(string,uint256,uint256,string) + ([165, 78, 212, 189], [133, 75, 52, 150]), + // log(uint256,bool,string) + ([139, 14, 20, 254], [133, 119, 80, 33]), + // log(address,uint256,string,string) + ([126, 86, 198, 147], [136, 168, 196, 6]), + // log(uint256,bool,uint256,address) + ([79, 64, 5, 142], [136, 203, 96, 65]), + // log(uint256,uint256,address,uint256) + ([97, 11, 168, 192], [136, 246, 228, 178]), + // log(string,bool,uint256,bool) + ([60, 197, 181, 211], [138, 247, 207, 138]), + // log(address,bool,bool,uint256) + ([207, 181, 135, 86], [140, 78, 93, 230]), + // log(address,address,uint256,address) + ([214, 198, 82, 118], [141, 166, 222, 245]), + // log(string,bool,bool,uint256) + ([128, 117, 49, 232], [142, 63, 120, 169]), + // log(bool,uint256,uint256,string) + ([218, 6, 102, 200], [142, 105, 251, 93]), + // log(string,string,string,uint256) + ([159, 208, 9, 245], [142, 175, 176, 43]), + // log(string,address,address,uint256) + ([110, 183, 148, 61], [142, 243, 243, 153]), + // log(uint256,string,address,bool) + ([249, 63, 255, 55], [144, 195, 10, 86]), + // log(uint256,address,bool,string) + ([99, 240, 226, 66], [144, 251, 6, 170]), + // log(bool,uint256,bool,string) + ([182, 213, 105, 212], [145, 67, 219, 177]), + // log(uint256,bool,uint256,bool) + ([210, 171, 196, 253], [145, 160, 46, 42]), + // log(string,address,string,uint256) + ([143, 98, 75, 233], [145, 209, 17, 46]), + // log(string,bool,uint256,address) + ([113, 211, 133, 13], [147, 94, 9, 191]), + // log(address,address,address,uint256) + ([237, 94, 172, 135], [148, 37, 13, 119]), + // log(uint256,uint256,bool,address) + ([225, 23, 116, 79], [154, 129, 106, 131]), + // log(bool,uint256,bool,address) + ([66, 103, 199, 248], [154, 205, 54, 22]), + // log(address,address,uint256,bool) + ([194, 246, 136, 236], [155, 66, 84, 226]), + // log(uint256,address,bool) + ([122, 208, 18, 142], [155, 110, 192, 66]), + // log(uint256,string,address,string) + ([248, 152, 87, 127], [156, 58, 223, 161]), + // log(address,bool,uint256) + ([44, 70, 141, 21], [156, 79, 153, 251]), + // log(uint256,address,string,address) + ([203, 229, 142, 253], [156, 186, 143, 255]), + // log(string,uint256,address,string) + ([50, 84, 194, 232], [159, 251, 47, 147]), + // log(address,uint256,address,bool) + ([241, 129, 161, 233], [161, 188, 201, 179]), + // log(uint256,bool,address,address) + ([134, 237, 193, 12], [161, 239, 76, 187]), + // log(address,uint256,string) + ([186, 249, 104, 73], [161, 242, 232, 170]), + // log(address,uint256,bool,address) + ([35, 229, 73, 114], [163, 27, 253, 204]), + // log(uint256,uint256,bool,string) + ([239, 217, 203, 238], [165, 180, 252, 153]), + // log(bool,string,address,uint256) + ([27, 11, 149, 91], [165, 202, 218, 148]), + // log(address,bool,address,uint256) + ([220, 113, 22, 210], [167, 92, 89, 222]), + // log(string,uint256,uint256,uint256) + ([8, 238, 86, 102], [167, 168, 120, 83]), + // log(uint256,uint256,bool,bool) + ([148, 190, 59, 177], [171, 8, 90, 230]), + // log(string,uint256,bool,string) + ([118, 204, 96, 100], [171, 247, 58, 152]), + // log(uint256,bool,address,string) + ([162, 48, 118, 30], [173, 224, 82, 199]), + // log(uint256,string,bool,address) + ([121, 111, 40, 160], [174, 46, 197, 129]), + // log(uint256,string,string,uint256) + ([118, 236, 99, 94], [176, 40, 201, 189]), + // log(uint256,string,string) + ([63, 87, 194, 149], [177, 21, 97, 31]), + // log(uint256,string,string,bool) + ([18, 134, 43, 152], [179, 166, 182, 189]), + // log(bool,uint256,address,bool) + ([101, 173, 244, 8], [180, 195, 20, 255]), + // log(string,uint256) + ([151, 16, 169, 208], [182, 14, 114, 204]), + // log(address,uint256,uint256) + ([135, 134, 19, 94], [182, 155, 202, 246]), + // log(uint256,bool,bool,bool) + ([78, 108, 83, 21], [182, 245, 119, 161]), + // log(uint256,string,uint256,string) + ([162, 188, 12, 153], [183, 185, 20, 202]), + // log(uint256,string,bool,bool) + ([81, 188, 43, 193], [186, 83, 93, 156]), + // log(uint256,address,address) + ([125, 119, 166, 27], [188, 253, 155, 224]), + // log(address,address,uint256,uint256) + ([84, 253, 243, 228], [190, 85, 52, 129]), + // log(bool,uint256,uint256,bool) + ([164, 29, 129, 222], [190, 152, 67, 83]), + // log(address,uint256,string,uint256) + ([245, 18, 207, 155], [191, 1, 248, 145]), + // log(bool,address,string,uint256) + ([11, 153, 252, 34], [194, 31, 100, 199]), + // log(string,string,uint256,bool) + ([230, 86, 88, 202], [195, 168, 166, 84]), + // log(bool,uint256,string) + ([200, 57, 126, 176], [195, 252, 57, 112]), + // log(address,bool,uint256,bool) + ([133, 205, 197, 175], [196, 100, 62, 32]), + // log(uint256,uint256,uint256,bool) + ([100, 82, 185, 203], [197, 152, 209, 133]), + // log(address,uint256,bool,string) + ([142, 142, 78, 117], [197, 173, 133, 249]), + // log(string,uint256,string,uint256) + ([160, 196, 178, 37], [198, 126, 169, 209]), + // log(uint256,bool,uint256,uint256) + ([86, 130, 141, 164], [198, 172, 199, 168]), + // log(string,bool,uint256) + ([41, 27, 185, 208], [201, 89, 88, 214]), + // log(string,uint256,uint256) + ([150, 156, 221, 3], [202, 71, 196, 235]), + // log(string,uint256,bool) + ([241, 2, 238, 5], [202, 119, 51, 177]), + // log(uint256,address,string,bool) + ([34, 164, 121, 166], [204, 50, 171, 7]), + // log(address,bool,uint256,address) + ([13, 140, 230, 30], [204, 247, 144, 161]), + // log(bool,uint256,bool,bool) + ([158, 1, 247, 65], [206, 181, 244, 215]), + // log(uint256,string,bool,uint256) + ([164, 180, 138, 127], [207, 0, 152, 128]), + // log(address,uint256,string,bool) + ([164, 2, 79, 17], [207, 24, 16, 92]), + // log(uint256,uint256,uint256) + ([231, 130, 10, 116], [209, 237, 122, 60]), + // log(uint256,string,bool,string) + ([141, 72, 156, 160], [210, 212, 35, 205]), + // log(uint256,string,string,address) + ([204, 152, 138, 160], [213, 131, 198, 2]), + // log(bool,address,uint256,bool) + ([238, 141, 134, 114], [214, 1, 159, 28]), + // log(string,string,bool,uint256) + ([134, 129, 138, 122], [214, 174, 250, 210]), + // log(uint256,address,uint256,string) + ([62, 211, 189, 40], [221, 176, 101, 33]), + // log(uint256,bool,bool,string) + ([49, 138, 229, 155], [221, 219, 149, 97]), + // log(uint256,bool,uint256,string) + ([232, 221, 188, 86], [222, 3, 231, 116]), + // log(string,uint256,bool,address) + ([229, 84, 157, 145], [224, 233, 91, 152]), + // log(string,uint256,uint256,address) + ([190, 215, 40, 191], [226, 29, 226, 120]), + // log(uint256,address,bool,bool) + ([126, 39, 65, 13], [227, 81, 20, 15]), + // log(bool,bool,string,uint256) + ([23, 139, 70, 133], [227, 169, 202, 47]), + // log(string,uint256,bool,uint256) + ([85, 14, 110, 245], [228, 27, 111, 111]), + // log(bool,uint256,string,bool) + ([145, 210, 248, 19], [229, 231, 11, 43]), + // log(uint256,string,address,uint256) + ([152, 231, 243, 243], [232, 211, 1, 141]), + // log(bool,uint256,bool) + ([27, 173, 201, 235], [232, 222, 251, 169]), + // log(uint256,uint256,bool,uint256) + ([108, 100, 124, 140], [235, 127, 111, 210]), + // log(uint256,bool,string,bool) + ([52, 110, 184, 199], [235, 146, 141, 127]), + // log(address,address,string,uint256) + ([4, 40, 147, 0], [239, 28, 239, 231]), + // log(uint256,bool,string,address) + ([73, 110, 43, 180], [239, 82, 144, 24]), + // log(uint256,address,bool,address) + ([182, 49, 48, 148], [239, 114, 197, 19]), + // log(string,string,uint256,uint256) + ([213, 207, 23, 208], [244, 93, 125, 44]), + // log(bool,uint256,string,string) + ([211, 42, 101, 72], [245, 188, 34, 73]), + // log(uint256,uint256) + ([108, 15, 105, 128], [246, 102, 113, 90]), + // log(uint256) and logUint(uint256) + ([245, 177, 187, 169], [248, 44, 80, 241]), + // log(string,address,uint256,uint256) + ([218, 163, 148, 189], [248, 245, 27, 30]), + // log(uint256,uint256,uint256,address) + ([224, 133, 63, 105], [250, 129, 133, 175]), + // log(string,address,uint256,bool) + ([90, 193, 193, 60], [252, 72, 69, 240]), + // log(address,address,uint256,string) + ([157, 209, 46, 173], [253, 180, 249, 144]), + // log(bool,uint256,string,address) + ([165, 199, 13, 41], [254, 221, 31, 255]), + // logInt(int256) + ([78, 12, 29, 29], [101, 37, 181, 245]), + // logBytes(bytes) + ([11, 231, 127, 86], [225, 123, 249, 86]), + // logBytes1(bytes1) + ([110, 24, 161, 40], [111, 65, 113, 201]), + // logBytes2(bytes2) + ([233, 182, 34, 150], [155, 94, 148, 62]), + // logBytes3(bytes3) + ([45, 131, 73, 38], [119, 130, 250, 45]), + // logBytes4(bytes4) + ([224, 95, 72, 209], [251, 163, 173, 57]), + // logBytes5(bytes5) + ([166, 132, 128, 141], [85, 131, 190, 46]), + // logBytes6(bytes6) + ([174, 132, 165, 145], [73, 66, 173, 198]), + // logBytes7(bytes7) + ([78, 213, 126, 40], [69, 116, 175, 171]), + // logBytes8(bytes8) + ([79, 132, 37, 46], [153, 2, 228, 127]), + // logBytes9(bytes9) + ([144, 189, 140, 208], [80, 161, 56, 223]), + // logBytes10(bytes10) + ([1, 61, 23, 139], [157, 194, 168, 151]), + // logBytes11(bytes11) + ([4, 0, 74, 46], [220, 8, 182, 167]), + // logBytes12(bytes12) + ([134, 160, 106, 189], [118, 86, 214, 199]), + // logBytes13(bytes13) + ([148, 82, 158, 52], [52, 193, 216, 27]), + // logBytes14(bytes14) + ([146, 102, 240, 127], [60, 234, 186, 101]), + // logBytes15(bytes15) + ([218, 149, 116, 224], [89, 26, 61, 162]), + // logBytes16(bytes16) + ([102, 92, 97, 4], [31, 141, 115, 18]), + // logBytes17(bytes17) + ([51, 159, 103, 58], [248, 154, 83, 47]), + // logBytes18(bytes18) + ([196, 210, 61, 154], [216, 101, 38, 66]), + // logBytes19(bytes19) + ([94, 107, 90, 51], [0, 245, 107, 201]), + // logBytes20(bytes20) + ([81, 136, 227, 233], [236, 184, 86, 126]), + // logBytes21(bytes21) + ([233, 218, 53, 96], [48, 82, 192, 143]), + // logBytes22(bytes22) + ([213, 250, 232, 156], [128, 122, 180, 52]), + // logBytes23(bytes23) + ([171, 161, 207, 13], [73, 121, 176, 55]), + // logBytes24(bytes24) + ([241, 179, 91, 52], [9, 119, 174, 252]), + // logBytes25(bytes25) + ([11, 132, 188, 88], [174, 169, 150, 63]), + // logBytes26(bytes26) + ([248, 177, 73, 241], [211, 99, 86, 40]), + // logBytes27(bytes27) + ([58, 55, 87, 221], [252, 55, 47, 159]), + // logBytes28(bytes28) + ([200, 42, 234, 238], [56, 47, 154, 52]), + // logBytes29(bytes29) + ([75, 105, 195, 213], [122, 24, 118, 65]), + // logBytes30(bytes30) + ([238, 18, 196, 237], [196, 52, 14, 246]), + // logBytes31(bytes31) + ([194, 133, 77, 146], [129, 252, 134, 72]), + // logBytes32(bytes32) + ([39, 183, 207, 133], [45, 33, 214, 247]), + ] + .map(|s| (s.0, s.1)), + ) }); #[cfg(test)] @@ -567,9 +568,9 @@ mod tests { #[test] fn hardhat_console_path_works() { for (hh, abigen) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { - let mut hh = *hh; + let mut hh = (*hh).to_vec(); patch_hardhat_console_selector(&mut hh); - assert_eq!(*abigen, hh); + assert_eq!((*abigen).to_vec(), hh); } } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index 1e96024cce9c9..9358b2791df09 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -399,7 +399,7 @@ pub fn apply( rU256::from_be_bytes(inner.1), data.db, )?; - DynSolValue::from(val).encode_single().into() + DynSolValue::from(val).abi_encode().into() } HEVMCalls::Cool(inner) => cool_account(data, inner.0)?, HEVMCalls::Breakpoint0(inner) => add_breakpoint(state, caller, &inner.0, true)?, @@ -543,7 +543,7 @@ pub fn apply( // we can safely unwrap because `load_account` insert inner.0 to DB. let account = data.journaled_state.state().get(&inner.0.to_alloy()).unwrap(); - DynSolValue::from(account.info.nonce).encode_single().into() + DynSolValue::from(account.info.nonce).abi_encode().into() } // [function getNonce(Wallet)] returns the current nonce of the Wallet's ETH address HEVMCalls::GetNonce0(inner) => { @@ -560,7 +560,7 @@ pub fn apply( // we can safely unwrap because `load_account` insert inner.0 to DB. let account = data.journaled_state.state().get(&inner.0.addr.to_alloy()).unwrap(); - DynSolValue::from(account.info.nonce.to_alloy()).encode_single().into() + DynSolValue::from(account.info.nonce.to_alloy()).abi_encode().into() } HEVMCalls::ChainId(inner) => { ensure!(inner.0 <= U256::from(u64::MAX), "Chain ID must be less than 2^64 - 1"); diff --git a/crates/evm/src/executor/inspector/cheatcodes/error.rs b/crates/evm/src/executor/inspector/cheatcodes/error.rs index 5fea6a3517f50..a67163a0d14e7 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/error.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/error.rs @@ -179,7 +179,7 @@ impl SolError for Error { fn encode_string(&self) -> Bytes { match self { Self::CustomBytes(cow) => cow_to_bytes(cow), - e => DynSolValue::String(e.to_string()).encode_single().into(), + e => DynSolValue::String(e.to_string()).abi_encode().into(), } } } diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 5e0cdad185401..cab6522848f5d 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -28,13 +28,13 @@ pub trait SolError: std::error::Error { /// See also [`AbiEncode`](ethers::abi::AbiEncode) fn encode_string(&self) -> Bytes { let err = DynSolValue::from(self.to_string()); - err.encode_single().into() + err.abi_encode().into() } } /// Encodes the given messages as solidity custom error pub fn encode_error(reason: impl Display) -> Bytes { - [ERROR_PREFIX.as_slice(), DynSolValue::String(reason.to_string()).encode_single().as_slice()] + [ERROR_PREFIX.as_slice(), DynSolValue::String(reason.to_string()).abi_encode().as_slice()] .concat() .into() } From ab4d57f8fd9d5a38981bb143b7e5d0ba90366929 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 2 Oct 2023 20:15:33 +0900 Subject: [PATCH 0135/1963] fix(ci): ignore tungstenite in deps for anvil (#5973) --- deny.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deny.toml b/deny.toml index 4c6a182fe6be7..021da25edd9ec 100644 --- a/deny.toml +++ b/deny.toml @@ -1,6 +1,6 @@ # Temporarily exclude rusoto and ethers-providers from bans since we've yet to transition to the # Rust AWS SDK. -exclude = ["rusoto_core", "rusoto_kms", "rusoto_credential", "ethers-providers"] +exclude = ["rusoto_core", "rusoto_kms", "rusoto_credential", "ethers-providers", "tungstenite"] # This section is considered when running `cargo deny check advisories` # More documentation for the advisories section can be found here: From 5118b78fe76e8a2a6fd91fd8c4e874e0b464472b Mon Sep 17 00:00:00 2001 From: Yotam Bar-On Date: Mon, 2 Oct 2023 14:42:41 +0300 Subject: [PATCH 0136/1963] Add vm.unixTime() cheatcode (#5952) * Add time() to HEVM.sol and generate bindings * Add vm.time() implementation * Rename time() in ext.rs & encode Result properly * Rename vm.time() cheatcode to vm.unixTime() * Update cheatcode name in ext.rs duration_since_epoch() expect message * Fix fmt issue with duration_since_epoch in ext.rs --- crates/abi/abi/HEVM.sol | 1 + crates/abi/src/bindings/hevm.rs | 64 +++++++++++++++++++ .../src/executor/inspector/cheatcodes/ext.rs | 22 ++++++- testdata/cheats/UnixTime.t.sol | 37 +++++++++++ testdata/cheats/Vm.sol | 3 + 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 testdata/cheats/UnixTime.t.sol diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index cec6414ad653e..911b6580dc88a 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -239,3 +239,4 @@ getMappingSlotAt(address,bytes32,uint256) getMappingKeyAndParentOf(address,bytes32) sleep(uint256) +unixTime()(uint256) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index 69efd2c2fa3ec..8ed992f4d1a5a 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -5138,6 +5138,24 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("unixTime"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("unixTime"), + inputs: ::std::vec![], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("warp"), ::std::vec![ @@ -7458,6 +7476,14 @@ pub mod hevm { .method_hash([72, 245, 12, 15], p0) .expect("method not found (this should never happen)") } + ///Calls the contract's `unixTime` (0x625387dc) function + pub fn unix_time( + &self, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([98, 83, 135, 220], ()) + .expect("method not found (this should never happen)") + } ///Calls the contract's `warp` (0xe5d6bf02) function pub fn warp( &self, @@ -10477,6 +10503,19 @@ pub mod hevm { )] #[ethcall(name = "txGasPrice", abi = "txGasPrice(uint256)")] pub struct TxGasPriceCall(pub ::ethers_core::types::U256); + ///Container type for all input parameters for the `unixTime` function with signature `unixTime()` and selector `0x625387dc` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "unixTime", abi = "unixTime()")] + pub struct UnixTimeCall; ///Container type for all input parameters for the `warp` function with signature `warp(uint256)` and selector `0xe5d6bf02` #[derive( Clone, @@ -10771,6 +10810,7 @@ pub mod hevm { Transact1(Transact1Call), TryFfi(TryFfiCall), TxGasPrice(TxGasPriceCall), + UnixTime(UnixTimeCall), Warp(WarpCall), WriteFile(WriteFileCall), WriteFileBinary(WriteFileBinaryCall), @@ -11813,6 +11853,11 @@ pub mod hevm { ) { return Ok(Self::TxGasPrice(decoded)); } + if let Ok(decoded) = ::decode( + data, + ) { + return Ok(Self::UnixTime(decoded)); + } if let Ok(decoded) = ::decode( data, ) { @@ -12341,6 +12386,7 @@ pub mod hevm { Self::TxGasPrice(element) => { ::ethers_core::abi::AbiEncode::encode(element) } + Self::UnixTime(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::Warp(element) => ::ethers_core::abi::AbiEncode::encode(element), Self::WriteFile(element) => { ::ethers_core::abi::AbiEncode::encode(element) @@ -12589,6 +12635,7 @@ pub mod hevm { Self::Transact1(element) => ::core::fmt::Display::fmt(element, f), Self::TryFfi(element) => ::core::fmt::Display::fmt(element, f), Self::TxGasPrice(element) => ::core::fmt::Display::fmt(element, f), + Self::UnixTime(element) => ::core::fmt::Display::fmt(element, f), Self::Warp(element) => ::core::fmt::Display::fmt(element, f), Self::WriteFile(element) => ::core::fmt::Display::fmt(element, f), Self::WriteFileBinary(element) => ::core::fmt::Display::fmt(element, f), @@ -13628,6 +13675,11 @@ pub mod hevm { Self::TxGasPrice(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: UnixTimeCall) -> Self { + Self::UnixTime(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: WarpCall) -> Self { Self::Warp(value) @@ -15088,6 +15140,18 @@ pub mod hevm { pub struct TryFfiReturn( pub (i32, ::ethers_core::types::Bytes, ::ethers_core::types::Bytes), ); + ///Container type for all return fields from the `unixTime` function with signature `unixTime()` and selector `0x625387dc` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct UnixTimeReturn(pub ::ethers_core::types::U256); ///`DirEntry(string,string,uint64,bool,bool)` #[derive( Clone, diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index e19db71af6210..ee4b9a0e85273 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -1,6 +1,6 @@ use super::{bail, ensure, fmt_err, util::MAGIC_SKIP_BYTES, Cheatcodes, Error, Result}; use crate::{abi::HEVMCalls, executor::inspector::cheatcodes::parse}; -use alloy_primitives::Bytes; +use alloy_primitives::{Bytes, U256 as rU256}; use ethers::{ abi::{self, AbiEncode, JsonAbi, ParamType, Token}, prelude::artifacts::CompactContractBytecode, @@ -8,10 +8,17 @@ use ethers::{ }; use foundry_common::{fmt::*, fs, get_artifact_path}; use foundry_config::fs_permissions::FsAccessKind; +use foundry_utils::types::ToEthers; use revm::{Database, EVMData}; use serde::Deserialize; use serde_json::Value; -use std::{collections::BTreeMap, env, path::Path, process::Command}; +use std::{ + collections::BTreeMap, + env, + path::Path, + process::Command, + time::{SystemTime, UNIX_EPOCH}, +}; /// Invokes a `Command` with the given args and returns the exit code, stdout, and stderr. /// @@ -511,6 +518,16 @@ fn sleep(milliseconds: &U256) -> Result { Ok(Default::default()) } +/// Returns the time since unix epoch in milliseconds +fn duration_since_epoch() -> Result { + let sys_time = SystemTime::now(); + let difference = sys_time + .duration_since(UNIX_EPOCH) + .expect("Failed getting timestamp in unixTime cheatcode"); + let millis = difference.as_millis(); + Ok(rU256::from(millis).to_ethers().encode().into()) +} + /// Skip the current test, by returning a magic value that will be checked by the test runner. pub fn skip(state: &mut Cheatcodes, depth: u64, skip: bool) -> Result { if !skip { @@ -715,6 +732,7 @@ pub fn apply( serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) } HEVMCalls::Sleep(inner) => sleep(&inner.0), + HEVMCalls::UnixTime(_) => duration_since_epoch(), HEVMCalls::WriteJson0(inner) => write_json(state, &inner.0, &inner.1, None), HEVMCalls::WriteJson1(inner) => write_json(state, &inner.0, &inner.1, Some(&inner.2)), HEVMCalls::KeyExists(inner) => key_exists(&inner.0, &inner.1), diff --git a/testdata/cheats/UnixTime.t.sol b/testdata/cheats/UnixTime.t.sol new file mode 100644 index 0000000000000..9e689a223543a --- /dev/null +++ b/testdata/cheats/UnixTime.t.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract UnixTimeTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + uint256 errMargin = 100; // allow errors of up to errMargin milliseconds + + function testUnixTimeAgainstDate() public { + string[] memory inputs = new string[](2); + inputs[0] = "date"; + // OS X does not support precision more than 1 second + inputs[1] = "+%s000"; + + bytes memory res = vm.ffi(inputs); + uint256 date = vm.parseUint(string(res)); + + // Limit precision to 1000 ms + uint256 time = vm.unixTime() / 1000 * 1000; + + assertEq(date, time, ".unixTime() is inaccurate"); + } + + function testUnixTime() public { + uint256 sleepTime = 2000; + + uint256 start = vm.unixTime(); + vm.sleep(sleepTime); + uint256 end = vm.unixTime(); + uint256 interval = end - start; + + assertGe(interval, sleepTime - errMargin, ".unixTime() is inaccurate"); + assertLe(interval, sleepTime + errMargin, ".unixTime() is inaccurate"); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index eaa459170e046..05b4bd315f5e8 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -234,6 +234,9 @@ interface Vm { // Sleeps for a given number of milliseconds. function sleep(uint256) external; + /// Returns the time since unix epoch in milliseconds + function unixTime() external returns (uint256); + // Expects an error on next call function expectRevert() external; From dd89d646aea95bf22109e9db2158b463dd603ea4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:45:58 +0200 Subject: [PATCH 0137/1963] chore: some alloy cleanup (#5975) * chore: some alloy cleanup * features * fix * chrono --- Cargo.lock | 2 +- Cargo.toml | 12 +- crates/anvil/Cargo.toml | 2 +- crates/anvil/core/Cargo.toml | 7 +- crates/anvil/src/eth/backend/mem/mod.rs | 14 +-- crates/cast/bin/main.rs | 2 +- crates/cast/src/lib.rs | 6 +- crates/cast/src/tx.rs | 2 +- crates/chisel/Cargo.toml | 8 +- crates/chisel/src/dispatcher.rs | 7 +- crates/chisel/src/executor.rs | 6 +- crates/common/src/abi.rs | 4 +- crates/config/Cargo.toml | 2 +- crates/debugger/Cargo.toml | 2 +- crates/debugger/src/lib.rs | 7 +- crates/doc/src/writer/buf_writer.rs | 3 +- crates/evm/Cargo.toml | 10 +- crates/evm/src/decode.rs | 5 +- crates/evm/src/executor/backend/error.rs | 2 +- .../executor/inspector/cheatcodes/expect.rs | 2 +- crates/evm/src/executor/inspector/printer.rs | 4 +- crates/evm/src/fuzz/mod.rs | 2 +- crates/evm/src/trace/identifier/signatures.rs | 2 +- crates/evm/src/trace/mod.rs | 12 +- crates/fmt/src/formatter.rs | 2 +- crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/create.rs | 8 +- crates/forge/bin/cmd/script/broadcast.rs | 7 +- crates/forge/bin/cmd/script/build.rs | 4 +- crates/forge/bin/cmd/script/cmd.rs | 6 +- crates/forge/bin/cmd/script/mod.rs | 6 +- crates/forge/bin/cmd/script/runner.rs | 12 +- crates/forge/bin/cmd/verify/mod.rs | 2 +- crates/forge/bin/cmd/verify/sourcify.rs | 4 +- crates/forge/src/multi_runner.rs | 2 +- crates/macros/src/fmt/token.rs | 4 +- crates/macros/src/fmt/ui.rs | 2 +- crates/test-utils/Cargo.toml | 2 +- crates/test-utils/src/script.rs | 10 +- crates/utils/Cargo.toml | 5 +- crates/utils/src/lib.rs | 103 +++++++++--------- 41 files changed, 146 insertions(+), 160 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c7a30d2f9e8e..d943bdc17503b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2796,7 +2796,6 @@ version = "0.2.0" dependencies = [ "alloy-dyn-abi", "alloy-primitives", - "const-hex", "dunce", "ethers-addressbook", "ethers-contract", @@ -5552,6 +5551,7 @@ dependencies = [ "enumn", "hashbrown 0.14.0", "hex", + "once_cell", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 79d855bfe5e61..330c67777515d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,11 +135,10 @@ foundry-utils = { path = "crates/utils" } foundry-debugger = { path = "crates/debugger" } ## revm -revm = { version = "3", default-features = false } -revm-primitives = { version = "1", default-features = false } +revm = "3" +revm-primitives = "1" ## ethers - ethers = { version = "2.0", default-features = false } ethers-addressbook = { version = "2.0", default-features = false } ethers-core = { version = "2.0", default-features = false } @@ -152,10 +151,9 @@ ethers-etherscan = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy - -alloy-primitives = { version = "0.4", default-features = false } -alloy-dyn-abi = { version = "0.4", default-features = false } -alloy-json-abi = { version = "0.4", default-features = false } +alloy-primitives = "0.4" +alloy-dyn-abi = "0.4" +alloy-json-abi = "0.4" solang-parser = "=0.3.2" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 058123836405f..f794d32c9ba66 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -34,7 +34,7 @@ ethers = { workspace = true, features = ["rustls", "ws", "ipc"] } trie-db = { version = "0.23" } hash-db = { version = "0.15" } memory-db = { version = "0.29" } -alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde"] } +alloy-primitives = { workspace = true, features = ["serde"] } # axum related axum = { version = "0.5", features = ["ws"] } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 196d5d7f0add8..0a55d62f01e31 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -12,11 +12,10 @@ repository.workspace = true [dependencies] # foundry internal foundry-evm = { path = "../../evm" } -foundry-utils = { path = "../../utils"} -revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } +foundry-utils = { path = "../../utils" } +revm = { workspace = true, features = ["serde", "memory_limit"] } - -alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde"] } +alloy-primitives = { workspace = true, features = ["serde"] } ethers-core.workspace = true serde = { version = "1", features = ["derive"], optional = true } serde_json = "1" diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index b9b2af8749a1b..cea99ed1ecc55 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -53,7 +53,7 @@ use ethers::{ DefaultFrame, Filter, FilteredParams, GethDebugTracingOptions, GethTrace, Log, OtherFields, Trace, Transaction, TransactionReceipt, H160, }, - utils::{get_contract_address, hex, keccak256, rlp}, + utils::{hex, keccak256, rlp}, }; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ @@ -1170,18 +1170,18 @@ impl Backend { where D: DatabaseRef, { - let from = request.from.unwrap_or_default(); + let from = request.from.unwrap_or_default().to_alloy(); let to = if let Some(to) = request.to { - to + to.to_alloy() } else { - let nonce = state.basic(from.to_alloy())?.unwrap_or_default().nonce; - get_contract_address(from, nonce) + let nonce = state.basic(from)?.unwrap_or_default().nonce; + from.create(nonce) }; let mut tracer = AccessListTracer::new( AccessList(request.access_list.clone().unwrap_or_default()), - from.to_alloy(), - to.to_alloy(), + from, + to, self.precompiles().into_iter().map(|p| p.to_alloy()).collect(), ); diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 169592669f295..8949f5c877ca7 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -78,7 +78,7 @@ async fn main() -> Result<()> { } Subcommands::FromBin => { let hex = stdin::read_bytes(false)?; - println!("0x{}", hex::encode(hex)); + println!("{}", hex::encode_prefixed(hex)); } Subcommands::ToHexdata { input } => { let value = stdin::unwrap_line(input)?; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index ed7d5b26dabca..253252711d9ba 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1441,7 +1441,7 @@ impl SimpleCast { /// Encodes string into bytes32 value pub fn format_bytes32_string(s: &str) -> Result { let formatted = format_bytes32_string(s)?; - Ok(format!("0x{}", hex::encode(formatted))) + Ok(hex::encode_prefixed(formatted)) } /// Decodes string from bytes32 value @@ -1933,7 +1933,7 @@ impl SimpleCast { } if optimize == 0 { let selector = HumanReadableParser::parse_function(signature)?.short_signature(); - return Ok((format!("0x{}", hex::encode(selector)), String::from(signature))) + return Ok((hex::encode_prefixed(selector), String::from(signature))) } let Some((name, params)) = signature.split_once('(') else { eyre::bail!("Invalid signature"); @@ -1955,7 +1955,7 @@ impl SimpleCast { if selector.iter().take_while(|&&byte| byte == 0).count() == optimize { found.store(true, Ordering::Relaxed); - return Some((nonce, format!("0x{}", hex::encode(selector)), input)) + return Some((nonce, hex::encode_prefixed(selector), input)) } nonce += nonce_step; diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs index b1708deb5d6d4..2de54f1e4c6f8 100644 --- a/crates/cast/src/tx.rs +++ b/crates/cast/src/tx.rs @@ -258,7 +258,7 @@ async fn resolve_name_args(args: &[String], provider: &M) -> Vec< if arg.contains('.') { let addr = provider.resolve_name(arg).await; match addr { - Ok(addr) => format!("0x{}", hex::encode(addr.as_bytes())), + Ok(addr) => format!("{addr:?}"), Err(_) => arg.to_string(), } } else { diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 7b8960551e548..f7b03894b85df 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -31,9 +31,9 @@ ethers.workspace = true ethers-solc = { workspace = true, features = ["project-util", "full"] } # alloy -alloy-dyn-abi = { workspace = true, default-features = false, features = ["std", "arbitrary"] } -alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde", "getrandom", "arbitrary", "rlp"] } -alloy-json-abi = { workspace = true, default-features = false, features = ["std"]} +alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-json-abi.workspace = true # async tokio = { version = "1", features = ["full"] } @@ -49,7 +49,7 @@ serde = "1" serde_json = { version = "1", features = ["raw_value"] } semver = "1" bytes = "1" -revm = { workspace = true, default-features = false, features = ["std"] } +revm.workspace = true eyre = "0.6" dirs = "5" time = { version = "0.3", features = ["formatting"] } diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index f9fbc2ad36c1a..56cef195e5e2f 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -421,9 +421,8 @@ impl ChiselDispatcher { i, i + 32 )), - Paint::cyan(format!( - "0x{}", - hex::encode(&mem.data()[i..i + 32]) + Paint::cyan(hex::encode_prefixed( + &mem.data()[i..i + 32] )) ); }); @@ -839,7 +838,7 @@ impl ChiselDispatcher { // We can always safely unwrap here due to the regex matching. let addr: Address = match_str.parse().expect("Valid address regex"); // Replace all occurrences of the address with a checksummed version - heap_input = heap_input.replace(match_str, &addr.to_checksum(None)); + heap_input = heap_input.replace(match_str, &addr.to_string()); }); // Replace the old input with the formatted input. input = &heap_input; diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 4d6aa1df2b193..96a5cc2a214ea 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -319,13 +319,13 @@ impl SessionSource { fn format_token(token: DynSolValue) -> String { match token { DynSolValue::Address(a) => { - format!("Type: {}\n└ Data: {}", Paint::red("address"), Paint::cyan(format!("0x{a:x}"))) + format!("Type: {}\n└ Data: {}", Paint::red("address"), Paint::cyan(a.to_string())) } DynSolValue::FixedBytes(b, _) => { format!( "Type: {}\n└ Data: {}", Paint::red(format!("bytes{}", b.len())), - Paint::cyan(format!("0x{}", hex::encode(b))) + Paint::cyan(hex::encode_prefixed(b)) ) } DynSolValue::Int(i, _) => { @@ -349,7 +349,7 @@ fn format_token(token: DynSolValue) -> String { } DynSolValue::String(_) | DynSolValue::Bytes(_) => { let hex = hex::encode(token.abi_encode()); - let s = token.as_str().map(|s| s.to_owned()); + let s = token.as_str(); format!( "Type: {}\n{}├ Hex (Memory):\n├─ Length ({}): {}\n├─ Contents ({}): {}\n├ Hex (Tuple Encoded):\n├─ Pointer ({}): {}\n├─ Length ({}): {}\n└─ Contents ({}): {}", Paint::red(if s.is_some() { "string" } else { "dynamic bytes" }), diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index d934d816c521d..703205a656571 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -160,8 +160,8 @@ pub fn format_tokens(tokens: &[Token]) -> impl Iterator + '_ { pub fn format_token(param: &Token) -> String { match param { Token::Address(addr) => to_checksum(addr, None), - Token::FixedBytes(bytes) => format!("0x{}", hex::encode(bytes)), - Token::Bytes(bytes) => format!("0x{}", hex::encode(bytes)), + Token::FixedBytes(bytes) => hex::encode_prefixed(bytes), + Token::Bytes(bytes) => hex::encode_prefixed(bytes), Token::Int(num) => format!("{}", I256::from_raw(*num)), Token::Uint(num) => format_uint_with_exponential_notation_hint(*num), Token::Bool(b) => format!("{b}"), diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 0151e321f594a..391bb926caf32 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -15,7 +15,7 @@ repository.workspace = true ethers-core.workspace = true ethers-solc = { workspace = true, features = ["async", "svm-solc"] } ethers-etherscan.workspace = true -revm-primitives = { workspace = true, default-features = false, features = ["std"] } +revm-primitives.workspace = true # formats Inflector = "0.11" diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index e024882afa3a4..fc2e8f5fcc19b 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -19,5 +19,5 @@ alloy-primitives.workspace = true crossterm = "0.26" eyre = "0.6" tracing = "0.1" -revm = { workspace = true, default-features = false,features = ["std", "serde", "arbitrary"] } +revm = { workspace = true, features = ["serde", "arbitrary"] } ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"] } diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 5a72342e9cd47..8d6cb92fdd983 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -677,10 +677,11 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k text_output.extend(Text::from("No sourcemap for contract")); } } else { - text_output.extend(Text::from("No srcmap index for contract {contract_name}")); + text_output + .extend(Text::from(format!("No srcmap index for contract {contract_name}"))); } } else { - text_output.extend(Text::from(format!("Unknown contract at address {address:?}"))); + text_output.extend(Text::from(format!("Unknown contract at address {address}"))); } let paragraph = @@ -700,7 +701,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k ) { let block_source_code = Block::default() .title(format!( - "Address: {:?} | PC: {} | Gas used in call: {}", + "Address: {} | PC: {} | Gas used in call: {}", address, if let Some(step) = debug_steps.get(current_step) { step.pc.to_string() diff --git a/crates/doc/src/writer/buf_writer.rs b/crates/doc/src/writer/buf_writer.rs index 5e75089ec9058..f391fa400c15e 100644 --- a/crates/doc/src/writer/buf_writer.rs +++ b/crates/doc/src/writer/buf_writer.rs @@ -1,4 +1,3 @@ -use ethers_core::utils::hex; use itertools::Itertools; use once_cell::sync::Lazy; use solang_parser::pt::Parameter; @@ -183,7 +182,7 @@ impl BufWriter { let row = [ Markdown::Bold(&network).as_doc()?, - Markdown::Code(&format!("0x{}", hex::encode(deployment.address))).as_doc()?, + Markdown::Code(&format!("{:?}", deployment.address)).as_doc()?, ]; self.write_piped(&row.join("|"))?; } diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 0727dd7373669..6292d3defa41f 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -40,18 +40,16 @@ once_cell = "1" # EVM bytes = "1" hashbrown = { version = "0.13", features = ["serde"] } -revm = { workspace = true, default-features = false, features = [ - "std", +revm = { workspace = true, features = [ "serde", "memory_limit", "optional_eip3607", "optional_block_gas_limit", "optional_no_base_fee", - "arbitrary" + "arbitrary", ] } - -alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde", "getrandom", "arbitrary", "rlp"] } -alloy-dyn-abi = { workspace = true, default-features = false, features = ["std", "arbitrary"] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } # Fuzzer proptest = "1" diff --git a/crates/evm/src/decode.rs b/crates/evm/src/decode.rs index bf65f2bcedd88..261adbfc4a3b4 100644 --- a/crates/evm/src/decode.rs +++ b/crates/evm/src/decode.rs @@ -3,6 +3,7 @@ use crate::{ abi::ConsoleEvents::{self, *}, executor::inspector::cheatcodes::util::MAGIC_SKIP_BYTES, }; +use alloy_primitives::B256; use ethers::{ abi::{decode, AbiDecode, Contract as Abi, ParamType, RawLog, Token}, contract::EthLogDecode, @@ -33,7 +34,7 @@ pub fn decode_console_log(log: &Log) -> Option { LogBytesFilter(inner) => format!("{}", inner.0), LogNamedAddressFilter(inner) => format!("{}: {:?}", inner.key, inner.val), LogNamedBytes32Filter(inner) => { - format!("{}: 0x{}", inner.key, hex::encode(inner.val)) + format!("{}: {}", inner.key, B256::new(inner.val)) } LogNamedDecimalIntFilter(inner) => { let (sign, val) = inner.val.into_sign_and_abs(); @@ -54,7 +55,7 @@ pub fn decode_console_log(log: &Log) -> Option { LogNamedIntFilter(inner) => format!("{}: {:?}", inner.key, inner.val), LogNamedUintFilter(inner) => format!("{}: {:?}", inner.key, inner.val), LogNamedBytesFilter(inner) => { - format!("{}: 0x{}", inner.key, hex::encode(inner.val)) + format!("{}: {}", inner.key, inner.val) } LogNamedStringFilter(inner) => format!("{}: {}", inner.key, inner.val), LogNamedArray1Filter(inner) => format!("{}: {:?}", inner.key, inner.val), diff --git a/crates/evm/src/executor/backend/error.rs b/crates/evm/src/executor/backend/error.rs index f7bf27fcd1dc3..a23a16c3828cd 100644 --- a/crates/evm/src/executor/backend/error.rs +++ b/crates/evm/src/executor/backend/error.rs @@ -105,7 +105,7 @@ pub struct NoCheatcodeAccessError(pub Address); impl fmt::Display for NoCheatcodeAccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "No cheatcode access granted for: {:?}, see `vm.allowCheatcodes()`", self.0) + write!(f, "No cheatcode access granted for: {}, see `vm.allowCheatcodes()`", self.0) } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/src/executor/inspector/cheatcodes/expect.rs index 2ed5d88dc57f5..298b78c4cd7e1 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/expect.rs @@ -94,7 +94,7 @@ pub fn handle_expect_revert( String::decode(data.0.as_ref()) .ok() .or_else(|| std::str::from_utf8(data.as_ref()).ok().map(ToOwned::to_owned)) - .unwrap_or_else(|| format!("0x{}", hex::encode(data))) + .unwrap_or_else(|| hex::encode_prefixed(data)) }; Err(fmt_err!( "Error != expected error: {} != {}", diff --git a/crates/evm/src/executor/inspector/printer.rs b/crates/evm/src/executor/inspector/printer.rs index a4afb10373c35..016e1c2e16309 100644 --- a/crates/evm/src/executor/inspector/printer.rs +++ b/crates/evm/src/executor/inspector/printer.rs @@ -39,7 +39,7 @@ impl Inspector for TracePrinter { inputs: &mut CallInputs, ) -> (InstructionResult, Gas, Bytes) { println!( - "SM CALL: {:?},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}", + "SM CALL: {},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}", inputs.contract, inputs.context, inputs.is_static, @@ -55,7 +55,7 @@ impl Inspector for TracePrinter { inputs: &mut CreateInputs, ) -> (InstructionResult, Option
, Gas, Bytes) { println!( - "CREATE CALL: caller:{:?}, scheme:{:?}, value:{:?}, init_code:{:?}, gas:{:?}", + "CREATE CALL: caller:{}, scheme:{:?}, value:{:?}, init_code:{:?}, gas:{:?}", inputs.caller, inputs.scheme, inputs.value, diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index d34170f1e683f..edf079343121a 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -351,7 +351,7 @@ impl fmt::Display for BaseCounterExample { if let Some(sig) = &self.signature { write!(f, "calldata={}", &sig)? } else { - write!(f, "calldata=0x{}", hex::encode(&self.calldata))? + write!(f, "calldata=0x{}", self.calldata)? } write!(f, ", args=[{args}]") diff --git a/crates/evm/src/trace/identifier/signatures.rs b/crates/evm/src/trace/identifier/signatures.rs index afed2d8278d4c..eba4ec3ad5991 100644 --- a/crates/evm/src/trace/identifier/signatures.rs +++ b/crates/evm/src/trace/identifier/signatures.rs @@ -102,7 +102,7 @@ impl SignaturesIdentifier { SelectorType::Event => &mut self.cached.events, }; - let hex_identifier = format!("0x{}", hex::encode(identifier)); + let hex_identifier = hex::encode_prefixed(identifier); if !self.offline && !map.contains_key(&hex_identifier) { if let Ok(signatures) = diff --git a/crates/evm/src/trace/mod.rs b/crates/evm/src/trace/mod.rs index fd479dc795a45..7bfaa55cbc39d 100644 --- a/crates/evm/src/trace/mod.rs +++ b/crates/evm/src/trace/mod.rs @@ -280,15 +280,11 @@ impl fmt::Display for RawOrDecodedLog { f, "{:>13}: {}", if i == 0 { "emit topic 0".to_string() } else { format!("topic {i}") }, - Paint::cyan(format!("0x{}", hex::encode(topic))) + Paint::cyan(format!("{topic:?}")) )?; } - write!( - f, - " data: {}", - Paint::cyan(format!("0x{}", hex::encode(&log.data))) - ) + write!(f, " data: {}", Paint::cyan(hex::encode_prefixed(&log.data))) } RawOrDecodedLog::Decoded(name, params) => { let params = params @@ -378,10 +374,10 @@ impl fmt::Display for RawOrDecodedReturnData { if bytes.is_empty() { write!(f, "()") } else { - write!(f, "0x{}", hex::encode(bytes)) + bytes.fmt(f) } } - RawOrDecodedReturnData::Decoded(decoded) => write!(f, "{}", decoded.clone()), + RawOrDecodedReturnData::Decoded(decoded) => f.write_str(decoded), } } } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 614d93f6123ac..39b6c74846d73 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -2029,7 +2029,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Expression::HexNumberLiteral(loc, val, unit) => { // ref: https://docs.soliditylang.org/en/latest/types.html?highlight=address%20literal#address-literals let val = if val.len() == 42 { - Address::from_str(val).expect("").to_checksum(None) + Address::from_str(val).expect("").to_string() } else { val.to_owned() }; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 9b96d44016d41..5cbe46be72ef0 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -39,7 +39,7 @@ forge-doc.workspace = true foundry-cli.workspace = true foundry-debugger.workspace = true -alloy-primitives = { workspace = true, default-features = false, features = ["std", "serde"] } +alloy-primitives = { workspace = true, features = ["serde"] } async-trait = "0.1" bytes = "1.4" diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 99d1aceba26dc..709806bc0bf8d 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -271,14 +271,14 @@ impl CreateArgs { let address = deployed_contract.address().to_alloy(); if self.json { let output = json!({ - "deployer": deployer_address.to_alloy().to_checksum(None), - "deployedTo": address.to_checksum(None), + "deployer": deployer_address.to_alloy().to_string(), + "deployedTo": address.to_string(), "transactionHash": receipt.transaction_hash }); println!("{output}"); } else { - println!("Deployer: {}", deployer_address.to_alloy().to_checksum(None)); - println!("Deployed to: {}", address.to_checksum(None)); + println!("Deployer: {}", deployer_address.to_alloy()); + println!("Deployed to: {address}"); println!("Transaction hash: {:?}", receipt.transaction_hash); }; diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 88118d13dca1d..c493ecb74a2ab 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -247,9 +247,10 @@ impl ScriptArgs { .map_err(|_| eyre::eyre!("Not able to query the EOA nonce."))?; let tx_nonce = tx.nonce().expect("no nonce"); - - if nonce != (*tx_nonce).to_alloy() { - bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") + if let Ok(tx_nonce) = u64::try_from(tx_nonce.to_alloy()) { + if nonce != tx_nonce { + bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") + } } } diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index e54ac4fc523b6..c0a176213d452 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,5 +1,5 @@ use super::*; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{Address, Bytes}; use ethers::{ prelude::{ artifacts::Libraries, cache::SolFilesCache, ArtifactId, Project, ProjectCompileOutput, @@ -80,7 +80,7 @@ impl ScriptArgs { contracts: ArtifactContracts, libraries_addresses: Libraries, sender: Address, - nonce: U256, + nonce: u64, ) -> Result { let mut run_dependencies = vec![]; let mut contract = CompactContractBytecode::default(); diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 6683b3f251478..77cd60e7837a0 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -1,5 +1,5 @@ use super::{multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, *}; -use alloy_primitives::{Bytes, U256}; +use alloy_primitives::Bytes; use ethers::{ prelude::{Middleware, Signer}, types::transaction::eip2718::TypedTransaction, @@ -23,7 +23,7 @@ impl ScriptArgs { let (config, evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; let mut script_config = ScriptConfig { // dapptools compatibility - sender_nonce: U256::from(1), + sender_nonce: 1, config, evm_opts, debug: self.debug, @@ -277,7 +277,7 @@ impl ScriptArgs { default_known_contracts, Libraries::parse(&deployment_sequence.libraries)?, script_config.config.sender.to_alloy(), // irrelevant, since we're not creating any - U256::ZERO, // irrelevant, since we're not creating any + 0, // irrelevant, since we're not creating any )?; verify.known_contracts = flatten_contracts(&highlevel_known_contracts, false); diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 18097142bc4be..f2261047d7b48 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -426,7 +426,7 @@ impl ScriptArgs { fn create_deploy_transactions( &self, from: Address, - nonce: U256, + nonce: u64, data: &[Bytes], fork_url: &Option, ) -> BroadcastableTransactions { @@ -437,7 +437,7 @@ impl ScriptArgs { transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(from.to_ethers()), data: Some(bytes.clone().0.into()), - nonce: Some(nonce + U256::from(i)).map(|n| n.to_ethers()), + nonce: Some(ethers::types::U256::from(nonce + i as u64)), ..Default::default() }), }) @@ -640,7 +640,7 @@ pub struct NestedValue { pub struct ScriptConfig { pub config: Config, pub evm_opts: EvmOpts, - pub sender_nonce: U256, + pub sender_nonce: u64, /// Maps a rpc url to a backend pub backends: HashMap, /// Script target contract diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 1d42dc4676678..00846749cef6f 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -35,7 +35,7 @@ impl ScriptRunner { libraries: &[Bytes], code: Bytes, setup: bool, - sender_nonce: U256, + sender_nonce: u64, is_broadcast: bool, need_create2_deployer: bool, ) -> Result<(Address, ScriptResult)> { @@ -52,7 +52,7 @@ impl ScriptRunner { } } - self.executor.set_nonce(self.sender, sender_nonce.to())?; + self.executor.set_nonce(self.sender, sender_nonce)?; // We max out their balance so that they can deploy and make calls. self.executor.set_balance(CALLER, U256::MAX)?; @@ -181,15 +181,13 @@ impl ScriptRunner { /// So we have to. fn maybe_correct_nonce( &mut self, - sender_initial_nonce: U256, + sender_initial_nonce: u64, libraries_len: usize, ) -> Result<()> { if let Some(cheatcodes) = &self.executor.inspector.cheatcodes { if !cheatcodes.corrected_nonce { - self.executor.set_nonce( - self.sender, - sender_initial_nonce.to::() + libraries_len as u64, - )?; + self.executor + .set_nonce(self.sender, sender_initial_nonce + libraries_len as u64)?; } self.executor.inspector.cheatcodes.as_mut().unwrap().corrected_nonce = false; } diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index bbdbe42a5ac0f..7b9738191158c 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -140,7 +140,7 @@ impl VerifyArgs { } let verifier_url = self.verifier.verifier_url.clone(); - println!("Start verifying contract `{:?}` deployed on {chain}", self.address); + println!("Start verifying contract `{}` deployed on {chain}", self.address); self.verifier.verifier.client(&self.etherscan.key)?.verify(self).await.map_err(|err| { if let Some(verifier_url) = verifier_url { match Url::parse(&verifier_url) { diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index aae526e827800..43ef6bbe8a968 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -38,7 +38,7 @@ impl VerificationProvider for SourcifyVerificationProvider { println!( "\nSubmitting verification for [{}] {:?}.", args.contract.name, - args.address.to_checksum(None) + args.address.to_string() ); let response = client .post(args.verifier.verifier_url.as_deref().unwrap_or(SOURCIFY_URL)) @@ -158,7 +158,7 @@ metadata output can be enabled via `extra_output = ["metadata"]` in `foundry.tom } let req = SourcifyVerifyRequest { - address: format!("{:?}", args.address), + address: args.address.to_string(), chain: args.etherscan.chain.unwrap_or_default().id().to_string(), files, chosen_contract: None, diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 4c9bf65c3ac30..334a9c3a4572f 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -287,7 +287,7 @@ impl MultiContractRunnerBuilder { &mut known_contracts, Default::default(), evm_opts.sender, - U256::from(1), + 1, &mut deployable_contracts, |post_link_input| { let PostLinkInput { diff --git a/crates/macros/src/fmt/token.rs b/crates/macros/src/fmt/token.rs index cc2808d9e7b3d..0de2b9b7771f4 100644 --- a/crates/macros/src/fmt/token.rs +++ b/crates/macros/src/fmt/token.rs @@ -19,8 +19,8 @@ fn fmt_token(f: &mut fmt::Formatter, item: &Token) -> fmt::Result { write!(f, "{}", utils::to_checksum(inner, None)) } // add 0x - Token::Bytes(inner) => write!(f, "0x{}", hex::encode(inner)), - Token::FixedBytes(inner) => write!(f, "0x{}", hex::encode(inner)), + Token::Bytes(inner) => f.write_str(&hex::encode_prefixed(inner)), + Token::FixedBytes(inner) => f.write_str(&hex::encode_prefixed(inner)), // print as decimal Token::Uint(inner) => write!(f, "{inner}"), Token::Int(inner) => write!(f, "{}", I256::from_raw(*inner)), diff --git a/crates/macros/src/fmt/ui.rs b/crates/macros/src/fmt/ui.rs index 84b14b259436e..675ad798872ee 100644 --- a/crates/macros/src/fmt/ui.rs +++ b/crates/macros/src/fmt/ui.rs @@ -71,7 +71,7 @@ impl UIfmt for Bytes { impl UIfmt for [u8; N] { fn pretty(&self) -> String { - format!("0x{}", hex::encode(&self[..])) + hex::encode_prefixed(&self[..]) } } diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index e572c104ef9fe..a18ff1ffa4b2a 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -18,7 +18,7 @@ foundry-utils.workspace = true ethers.workspace = true ethers-solc = { workspace = true, features = ["project-util"] } -alloy-primitives = { workspace = true, features = ["std"]} +alloy-primitives.workspace = true eyre = "0.6" once_cell = "1" diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 2ed5fc5b7aa6f..3434c92b91543 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,5 +1,5 @@ use crate::TestCommand; -use alloy_primitives::{hex, Address, U256}; +use alloy_primitives::{Address, U256}; use ethers::prelude::{Middleware, NameOrAddress}; use eyre::Result; use foundry_common::{get_http_provider, RetryProvider}; @@ -136,16 +136,12 @@ impl ScriptTester { } pub fn add_deployer(&mut self, index: u32) -> &mut Self { - self.cmd.args([ - "--sender", - &format!("0x{}", hex::encode(self.accounts_pub[index as usize].to_ethers())), - ]); - self + self.sender(self.accounts_pub[index as usize]) } /// Adds given address as sender pub fn sender(&mut self, addr: Address) -> &mut Self { - self.cmd.args(["--sender", format!("{addr:?}").as_str()]); + self.cmd.args(["--sender", addr.to_string().as_str()]); self } diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 4240bf42508d3..6acc065f35184 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -18,13 +18,12 @@ ethers-addressbook.workspace = true ethers-providers.workspace = true ethers-solc.workspace = true -alloy-primitives = { workspace = true, features = ["std"]} -alloy-dyn-abi = { workspace = true, features = ["std"]} +alloy-primitives.workspace = true +alloy-dyn-abi.workspace = true eyre = { version = "0.6", default-features = false } futures = "0.3" glob = "0.3" -hex.workspace = true once_cell = "1" rand = "0.8" serde_json = { version = "1", default-features = false } diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index a12c8efdb28d1..66676f36facd4 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -1,7 +1,7 @@ #![doc = include_str!("../README.md")] #![warn(unused_crate_dependencies)] -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{Address, Bytes}; use ethers_addressbook::contract; use ethers_core::types::{BlockId, Chain, NameOrAddress}; use ethers_providers::{Middleware, Provider}; @@ -98,7 +98,7 @@ pub struct ResolvedDependency { /// The address the linker resolved pub address: Address, /// The nonce used to resolve the dependency - pub nonce: U256, + pub nonce: u64, pub id: String, pub bytecode: Bytes, } @@ -145,7 +145,7 @@ pub fn link_with_nonce_or_address( known_contracts: &mut BTreeMap, deployed_library_addresses: Libraries, sender: Address, - nonce: U256, + nonce: u64, extra: &mut U, post_link: impl Fn(PostLinkInput) -> eyre::Result<()>, root: impl AsRef, @@ -285,11 +285,11 @@ fn recurse_link<'a>( deployment: &'a mut Vec, // libraries we have already deployed during the linking process. // the key is `file:contract` and the value is the address we computed - internally_deployed_libraries: &'a mut HashMap, + internally_deployed_libraries: &'a mut HashMap, // deployed library addresses fname => adddress deployed_library_addresses: &'a Libraries, // nonce to start at - nonce: &mut U256, + nonce: &mut u64, // sender sender: Address, // project root path @@ -375,7 +375,7 @@ fn recurse_link<'a>( trace!(target : "forge::link", dependency = next_target, file, key, "dependency was previously deployed"); // we previously deployed the library - let library = format!("{file}:{key}:0x{}", hex::encode(deployed_address)); + let library = format!("{file}:{key}:0x{deployed_address:x}"); // push the dependency into the library deployment vector deployment.push(ResolvedDependency { @@ -390,22 +390,22 @@ fn recurse_link<'a>( // we need to deploy the library let used_nonce = *nonce; - let computed_address = ethers_core::utils::get_contract_address(sender.to_ethers(), used_nonce.to_ethers()); - *nonce += U256::from(1); - let library = format!("{file}:{key}:0x{}", hex::encode(computed_address)); + let computed_address = sender.create(used_nonce); + *nonce += 1; + let library = format!("{file}:{key}:0x{computed_address:x}"); // push the dependency into the library deployment vector deployment.push(ResolvedDependency { id: library, - address: computed_address.to_alloy(), + address: computed_address, nonce: used_nonce, bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!( "Bytecode should be linked for {next_target}")).0.into(), }); // remember this library for later - internally_deployed_libraries.insert(format!("{file}:{key}"), (used_nonce, computed_address.to_alloy())); + internally_deployed_libraries.insert(format!("{file}:{key}"), (used_nonce, computed_address)); - computed_address.to_alloy() + computed_address }; // link the dependency to the target @@ -526,10 +526,11 @@ pub async fn next_nonce( caller: Address, provider_url: &str, block: Option, -) -> Result { +) -> Result { let provider = Provider::try_from(provider_url) .wrap_err_with(|| format!("Bad fork_url provider: {provider_url}"))?; - Ok(provider.get_transaction_count(caller.to_ethers(), block).await?).map(|n| n.to_alloy()) + let res = provider.get_transaction_count(caller.to_ethers(), block).await?.to_alloy(); + res.try_into().map_err(|e| eyre::eyre!("{e}")) } #[cfg(test)] @@ -541,7 +542,7 @@ mod tests { struct LinkerTest { contracts: ArtifactContracts, - dependency_assertions: HashMap>, + dependency_assertions: HashMap>, project: Project, } @@ -572,13 +573,13 @@ mod tests { fn assert_dependencies( mut self, artifact_id: String, - deps: Vec<(String, U256, Address)>, + deps: Vec<(String, u64, Address)>, ) -> Self { self.dependency_assertions.insert(artifact_id, deps); self } - fn test_with_sender_and_nonce(self, sender: Address, initial_nonce: U256) { + fn test_with_sender_and_nonce(self, sender: Address, initial_nonce: u64) { let mut called_once = false; link_with_nonce_or_address( self.contracts, @@ -635,7 +636,7 @@ mod tests { "simple/Simple.t.sol:LibraryConsumer".to_string(), vec![( "simple/Simple.t.sol:Lib".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -643,11 +644,11 @@ mod tests { "simple/Simple.t.sol:SimpleLibraryLinkingTest".to_string(), vec![( "simple/Simple.t.sol:Lib".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) - .test_with_sender_and_nonce(Address::default(), U256::from(1)); + .test_with_sender_and_nonce(Address::default(), 1); } #[test] @@ -658,7 +659,7 @@ mod tests { "nested/Nested.t.sol:NestedLib".to_string(), vec![( "nested/Nested.t.sol:Lib".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -669,17 +670,17 @@ mod tests { // have the same address and nonce. ( "nested/Nested.t.sol:Lib".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "nested/Nested.t.sol:Lib".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "nested/Nested.t.sol:NestedLib".to_string(), - U256::from(2), + 2, Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), ), ], @@ -689,22 +690,22 @@ mod tests { vec![ ( "nested/Nested.t.sol:Lib".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "nested/Nested.t.sol:Lib".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "nested/Nested.t.sol:NestedLib".to_string(), - U256::from(2), + 2, Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), ), ], ) - .test_with_sender_and_nonce(Address::default(), U256::from(1)); + .test_with_sender_and_nonce(Address::default(), 1); } /// This test ensures that complicated setups with many libraries, some of which are referenced @@ -727,7 +728,7 @@ mod tests { "duplicate/Duplicate.t.sol:C".to_string(), vec![( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -735,7 +736,7 @@ mod tests { "duplicate/Duplicate.t.sol:D".to_string(), vec![( "duplicate/Duplicate.t.sol:B".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -744,12 +745,12 @@ mod tests { vec![ ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "duplicate/Duplicate.t.sol:C".to_string(), - U256::from(2), + 2, Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), ), ], @@ -759,47 +760,47 @@ mod tests { vec![ ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "duplicate/Duplicate.t.sol:B".to_string(), - U256::from(2), + 2, Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "duplicate/Duplicate.t.sol:C".to_string(), - U256::from(3), + 3, Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), ), ( "duplicate/Duplicate.t.sol:B".to_string(), - U256::from(2), + 2, Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), ), ( "duplicate/Duplicate.t.sol:D".to_string(), - U256::from(4), + 4, Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782").unwrap(), ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "duplicate/Duplicate.t.sol:C".to_string(), - U256::from(3), + 3, Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), ), ( "duplicate/Duplicate.t.sol:E".to_string(), - U256::from(5), + 5, Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f").unwrap(), ), ], @@ -809,52 +810,52 @@ mod tests { vec![ ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "duplicate/Duplicate.t.sol:B".to_string(), - U256::from(2), + 2, Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "duplicate/Duplicate.t.sol:C".to_string(), - U256::from(3), + 3, Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), ), ( "duplicate/Duplicate.t.sol:B".to_string(), - U256::from(2), + 2, Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), ), ( "duplicate/Duplicate.t.sol:D".to_string(), - U256::from(4), + 4, Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782").unwrap(), ), ( "duplicate/Duplicate.t.sol:A".to_string(), - U256::from(1), + 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), ), ( "duplicate/Duplicate.t.sol:C".to_string(), - U256::from(3), + 3, Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), ), ( "duplicate/Duplicate.t.sol:E".to_string(), - U256::from(5), + 5, Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f").unwrap(), ), ], ) - .test_with_sender_and_nonce(Address::default(), U256::from(1)); + .test_with_sender_and_nonce(Address::default(), 1); } #[test] From 49007938138ae26379e7a19bf3b2ec2ba6822017 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 3 Oct 2023 19:40:05 +0900 Subject: [PATCH 0138/1963] feat: use main revm branch (#5977) --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d943bdc17503b..fe589e8e2aee4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5502,8 +5502,8 @@ dependencies = [ [[package]] name = "revm" -version = "3.3.0" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" +version = "3.4.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" dependencies = [ "auto_impl", "revm-interpreter", @@ -5514,8 +5514,8 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" +version = "1.2.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" dependencies = [ "revm-primitives", "serde", @@ -5523,8 +5523,8 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "2.0.3" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" +version = "2.1.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" dependencies = [ "c-kzg", "k256", @@ -5539,8 +5539,8 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "1.1.2" -source = "git+https://github.com/Evalir/revm/?branch=reintroduce-alloy-rebased#f7d211e27dc6e56abcaa09e3097158bf063f5190" +version = "1.2.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" dependencies = [ "alloy-primitives", "alloy-rlp", diff --git a/Cargo.toml b/Cargo.toml index 330c67777515d..35607919f9e35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -187,7 +187,7 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs" } ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs" } -revm = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } -revm-interpreter = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } -revm-precompile = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } -revm-primitives = { git = "https://github.com/Evalir/revm/", branch = "reintroduce-alloy-rebased" } +revm = { git = "https://github.com/bluealloy/revm/", branch = "main" } +revm-interpreter = { git = "https://github.com/bluealloy/revm/", branch = "main" } +revm-precompile = { git = "https://github.com/bluealloy/revm/", branch = "main" } +revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "main" } From 7b291d43778be31620a9b45b19a68339f7286f08 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:16:11 +0200 Subject: [PATCH 0139/1963] chore: bump deps (#5979) * chore: bump deps * cargo update * bump ethers --- Cargo.lock | 454 +++++++++++++++++-------------------- Cargo.toml | 1 + crates/binder/Cargo.toml | 4 +- crates/binder/src/lib.rs | 2 + crates/binder/src/utils.rs | 15 -- crates/cast/Cargo.toml | 2 +- crates/chisel/Cargo.toml | 2 +- crates/common/Cargo.toml | 3 +- crates/config/Cargo.toml | 4 +- crates/debugger/Cargo.toml | 4 +- crates/evm/Cargo.toml | 4 +- crates/fmt/Cargo.toml | 2 +- crates/forge/Cargo.toml | 4 +- 13 files changed, 221 insertions(+), 280 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe589e8e2aee4..5d4e1f3bd76f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,9 +226,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -240,15 +240,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -264,9 +264,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -385,9 +385,9 @@ checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" [[package]] name = "ariadne" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "367fd0ad87307588d087544707bc5fbf4805ded96c7db922b70d368fa1cb5702" +checksum = "72fe02fc62033df9ba41cba57ee19acf5e742511a140c7dbc3a873e19a19a1bd" dependencies = [ "unicode-width", "yansi 0.5.1", @@ -576,9 +576,12 @@ dependencies = [ [[package]] name = "atomic" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] [[package]] name = "atomic-take" @@ -802,7 +805,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ - "sha2 0.10.7", + "sha2 0.10.8", "tinyvec", ] @@ -813,7 +816,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", - "regex-automata 0.3.8", + "regex-automata 0.3.9", "serde", ] @@ -844,6 +847,12 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" +[[package]] +name = "bytemuck" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" + [[package]] name = "byteorder" version = "1.4.3" @@ -1109,9 +1118,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.4" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", "clap_derive", @@ -1119,9 +1128,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.4" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", @@ -1134,9 +1143,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.1" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4110a1e6af615a9e6d0a36f805d5c99099f8bab9b8042f5bc1fa220a4a89e36f" +checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" dependencies = [ "clap", ] @@ -1205,7 +1214,7 @@ dependencies = [ "hmac 0.12.1", "k256", "serde", - "sha2 0.10.7", + "sha2 0.10.8", "thiserror", ] @@ -1221,7 +1230,7 @@ dependencies = [ "once_cell", "pbkdf2 0.12.2", "rand 0.8.5", - "sha2 0.10.7", + "sha2 0.10.8", "thiserror", ] @@ -1240,7 +1249,7 @@ dependencies = [ "ripemd", "serde", "serde_derive", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "thiserror", ] @@ -1307,11 +1316,11 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "6.2.0" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" +checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" dependencies = [ - "crossterm", + "crossterm 0.26.1", "strum 0.24.1", "strum_macros 0.24.3", "unicode-width", @@ -1344,9 +1353,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa72a10d0e914cad6bcad4e7409e68d230c1c2db67896e19a37f758b1fcbdab5" +checksum = "c37be52ef5e3b394db27a2341010685ad5103c72ac15ce2e9420a7e8f93f342c" dependencies = [ "cfg-if", "cpufeatures", @@ -1527,6 +1536,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "crossterm" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" +dependencies = [ + "bitflags 2.4.0", + "crossterm_winapi", + "libc", + "mio", + "parking_lot", + "signal-hook", + "signal-hook-mio", + "winapi", +] + [[package]] name = "crossterm_winapi" version = "0.9.1" @@ -1593,34 +1618,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "curl" -version = "0.4.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" -dependencies = [ - "curl-sys", - "libc", - "schannel", - "socket2 0.4.9", - "winapi", -] - -[[package]] -name = "curl-sys" -version = "0.4.66+curl-8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70c44a72e830f0e40ad90dda8a6ab6ed6314d39776599a58a2e5e37fbc6db5b9" -dependencies = [ - "cc", - "libc", - "libnghttp2-sys", - "libz-sys", - "pkg-config", - "vcpkg", - "windows-sys 0.48.0", -] - [[package]] name = "dashmap" version = "5.5.3" @@ -1628,7 +1625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "lock_api", "once_cell", "parking_lot_core", @@ -1693,12 +1690,13 @@ dependencies = [ [[package]] name = "dialoguer" -version = "0.10.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" dependencies = [ "console", "shell-words", + "thiserror", ] [[package]] @@ -1836,9 +1834,9 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" dependencies = [ "base16ct", "crypto-bigint", @@ -1933,9 +1931,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" dependencies = [ "errno-dragonfly", "libc", @@ -1978,7 +1976,7 @@ dependencies = [ "scrypt", "serde", "serde_json", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", "thiserror", "uuid", @@ -2048,7 +2046,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2063,7 +2061,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "ethers-core", "once_cell", @@ -2074,7 +2072,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2092,7 +2090,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "Inflector", "const-hex", @@ -2108,14 +2106,14 @@ dependencies = [ "serde", "serde_json", "syn 2.0.37", - "toml 0.8.0", + "toml 0.8.2", "walkdir", ] [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "Inflector", "const-hex", @@ -2130,7 +2128,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "arrayvec", "bytes", @@ -2159,7 +2157,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "ethers-core", "ethers-solc", @@ -2174,7 +2172,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "async-trait", "auto_impl", @@ -2200,7 +2198,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "async-trait", "auto_impl", @@ -2238,7 +2236,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "async-trait", "coins-bip32", @@ -2251,11 +2249,12 @@ dependencies = [ "futures-executor", "futures-util", "home", + "protobuf", "rand 0.8.5", "rusoto_core", "rusoto_kms", "semver 1.0.19", - "sha2 0.10.7", + "sha2 0.10.8", "spki", "thiserror", "tracing", @@ -2265,7 +2264,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#70e5f022b1bd94c26dbc85d57b5342e5e23ba8c2" +source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" dependencies = [ "cfg-if", "const-hex", @@ -2286,7 +2285,7 @@ dependencies = [ "semver 1.0.19", "serde", "serde_json", - "sha2 0.10.7", + "sha2 0.10.8", "solang-parser", "svm-rs", "svm-rs-builds", @@ -2327,9 +2326,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fastrlp" @@ -2387,16 +2386,16 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.10" +version = "0.10.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4547e226f4c9ab860571e070a9034192b3175580ecea38da34fcdb53a018c9a5" +checksum = "a014ac935975a70ad13a3bff2463b1c1b083b35ae4cb6309cfc59476aa7a181f" dependencies = [ "atomic", "parking_lot", "pear", "serde", "tempfile", - "toml 0.7.8", + "toml 0.8.2", "uncased", "version_check", ] @@ -2539,7 +2538,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.8.0", + "toml 0.8.2", "tracing", "warp", ] @@ -2555,7 +2554,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.0", + "toml 0.8.2", "tracing", "tracing-subscriber", ] @@ -2586,9 +2585,7 @@ dependencies = [ name = "foundry-binder" version = "0.2.0" dependencies = [ - "curl", "ethers-contract", - "ethers-solc", "eyre", "foundry-config", "git2", @@ -2693,8 +2690,8 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.7.8", - "toml_edit 0.19.15", + "toml 0.8.2", + "toml_edit 0.20.2", "tracing", "walkdir", ] @@ -2704,7 +2701,7 @@ name = "foundry-debugger" version = "0.2.0" dependencies = [ "alloy-primitives", - "crossterm", + "crossterm 0.27.0", "eyre", "foundry-common", "foundry-evm", @@ -2731,7 +2728,7 @@ dependencies = [ "foundry-macros", "foundry-utils", "futures", - "hashbrown 0.13.2", + "hashbrown 0.14.1", "itertools 0.11.0", "jsonpath_lib", "once_cell", @@ -3016,11 +3013,11 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "git2" -version = "0.17.2" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b989d6a7ca95a362cf2cfc5ad688b3a467be1f87e480b8dad07fee8c79b0044" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "libc", "libgit2-sys", "log", @@ -3351,19 +3348,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.3", - "serde", -] - -[[package]] -name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" dependencies = [ "ahash 0.8.3", "allocator-api2", @@ -3720,12 +3707,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.1", ] [[package]] @@ -3885,7 +3872,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2 0.10.7", + "sha2 0.10.8", "signature", ] @@ -3980,9 +3967,9 @@ checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libgit2-sys" -version = "0.15.2+1.6.4" +version = "0.16.1+1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" dependencies = [ "cc", "libc", @@ -4006,16 +3993,6 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" -[[package]] -name = "libnghttp2-sys" -version = "0.1.8+1.55.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fae956c192dadcdb5dace96db71fa0b827333cce7c7b38dc71446f024d8a340" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "libusb1-sys" version = "0.6.4" @@ -4042,9 +4019,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" [[package]] name = "lock_api" @@ -4132,9 +4109,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55eb7c4dad20cc5bc15181c2aaf43d5689d5c3e0b80b50cc4cf0b7fe72a26d9" +checksum = "1c3f88addd34930bc5f01b9dc19f780447e51c92bf2536e3ded058018271775d" dependencies = [ "ammonia", "anyhow", @@ -4160,9 +4137,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" @@ -4616,9 +4593,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "3.9.1" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a54938017eacd63036332b4ae5c8a49fc8c0c1d6d629893057e4f13609edd06" +checksum = "e3a540f3e3b3d7929c884e46d093d344e4e5bdeed54d08bf007df50c93cc85d5" dependencies = [ "num-traits", ] @@ -4755,7 +4732,7 @@ dependencies = [ "digest 0.10.7", "hmac 0.12.1", "password-hash", - "sha2 0.10.7", + "sha2 0.10.8", ] [[package]] @@ -4814,9 +4791,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" +checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" dependencies = [ "memchr", "thiserror", @@ -4825,9 +4802,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" +checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" dependencies = [ "pest", "pest_generator", @@ -4835,9 +4812,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" +checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" dependencies = [ "pest", "pest_meta", @@ -4848,13 +4825,13 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.3" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" +checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" dependencies = [ "once_cell", "pest", - "sha2 0.10.7", + "sha2 0.10.8", ] [[package]] @@ -4864,7 +4841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.0.2", ] [[package]] @@ -5164,19 +5141,19 @@ dependencies = [ [[package]] name = "proptest" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e35c06b98bf36aba164cc17cb25f7e232f5c4aeea73baa14b8a9f0d92dbfa65" +checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" dependencies = [ "bit-set", - "bitflags 1.3.2", - "byteorder", + "bit-vec", + "bitflags 2.4.0", "lazy_static", "num-traits", "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.6.29", + "regex-syntax 0.7.5", "rusty-fork", "tempfile", "unarray", @@ -5337,15 +5314,17 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8285baa38bdc9f879d92c0e37cb562ef38aa3aeefca22b3200186bc39242d3d5" +checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" dependencies = [ "bitflags 2.4.0", "cassowary", - "crossterm", + "crossterm 0.27.0", "indoc", + "itertools 0.11.0", "paste", + "strum 0.25.0", "unicode-segmentation", "unicode-width", ] @@ -5415,13 +5394,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.5" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.8", + "regex-automata 0.3.9", "regex-syntax 0.7.5", ] @@ -5436,9 +5415,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", @@ -5459,9 +5438,9 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "base64 0.21.4", "bytes", @@ -5488,6 +5467,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -5502,8 +5482,8 @@ dependencies = [ [[package]] name = "revm" -version = "3.4.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" +version = "3.5.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" dependencies = [ "auto_impl", "revm-interpreter", @@ -5514,8 +5494,8 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "1.2.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" +version = "1.3.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" dependencies = [ "revm-primitives", "serde", @@ -5523,8 +5503,8 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "2.1.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" +version = "2.2.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" dependencies = [ "c-kzg", "k256", @@ -5533,14 +5513,14 @@ dependencies = [ "revm-primitives", "ripemd", "secp256k1", - "sha2 0.10.7", + "sha2 0.10.8", "substrate-bn", ] [[package]] name = "revm-primitives" -version = "1.2.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#4e78fbe86ef4d030968d00f461926abbcb813943" +version = "1.3.0" +source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -5549,7 +5529,7 @@ dependencies = [ "bitvec", "c-kzg", "enumn", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "hex", "once_cell", "serde", @@ -5793,9 +5773,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.14" +version = "0.38.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" +checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" dependencies = [ "bitflags 2.4.0", "errno", @@ -5879,15 +5859,15 @@ dependencies = [ [[package]] name = "rustyline" -version = "11.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfc8644681285d1fb67a467fb3021bfea306b99b4146b166a1fe3ada965eece" +checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "cfg-if", "clipboard-win", - "dirs-next", "fd-lock", + "home", "libc", "log", "memchr", @@ -5978,7 +5958,7 @@ dependencies = [ "hmac 0.12.1", "pbkdf2 0.11.0", "salsa20", - "sha2 0.10.7", + "sha2 0.10.8", ] [[package]] @@ -6111,7 +6091,7 @@ version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "itoa", "ryu", "serde", @@ -6216,9 +6196,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -6237,9 +6217,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b" dependencies = [ "lazy_static", ] @@ -6512,7 +6492,7 @@ dependencies = [ "semver 1.0.19", "serde", "serde_json", - "sha2 0.10.7", + "sha2 0.10.8", "thiserror", "url", "zip", @@ -6583,6 +6563,27 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -6658,18 +6659,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", @@ -6697,9 +6698,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" dependencies = [ "deranged", "itoa", @@ -6712,15 +6713,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" dependencies = [ "time-core", ] @@ -6843,18 +6844,6 @@ dependencies = [ "tungstenite 0.17.3", ] -[[package]] -name = "tokio-tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.18.0", -] - [[package]] name = "tokio-tungstenite" version = "0.20.1" @@ -6897,27 +6886,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" -dependencies = [ - "indexmap 2.0.0", - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.19.15", -] - -[[package]] -name = "toml" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.0", + "toml_edit 0.20.2", ] [[package]] @@ -6935,20 +6912,18 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", - "serde", - "serde_spanned", + "indexmap 2.0.2", "toml_datetime", "winnow", ] [[package]] name = "toml_edit" -version = "0.20.0" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", @@ -7182,25 +7157,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" -dependencies = [ - "base64 0.13.1", - "byteorder", - "bytes", - "http", - "httparse", - "log", - "rand 0.8.5", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.20.1" @@ -7368,9 +7324,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.4" +version = "8.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbc5ad0d9d26b2c49a5ab7da76c3e79d3ee37e7821799f8223fcb8f2f391a2e7" +checksum = "85e7dc29b3c54a2ea67ef4f953d5ec0c4085035c0ae2d325be1c0d2144bd9f16" dependencies = [ "anyhow", "git2", @@ -7414,9 +7370,9 @@ dependencies = [ [[package]] name = "warp" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba431ef570df1287f7f8b07e376491ad54f84d26ac473489427231e1718e1f69" +checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" dependencies = [ "bytes", "futures-channel", @@ -7436,7 +7392,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-stream", - "tokio-tungstenite 0.18.0", + "tokio-tungstenite 0.20.1", "tokio-util", "tower-service", "tracing", @@ -7580,9 +7536,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" +checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" dependencies = [ "ring", "untrusted", diff --git a/Cargo.toml b/Cargo.toml index 35607919f9e35..568216f67b2ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -162,6 +162,7 @@ toml = "0.8" itertools = "0.11" chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } hex = { package = "const-hex", version = "1.6", features = ["hex"] } +protobuf = "=3.2.0" #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/binder/Cargo.toml b/crates/binder/Cargo.toml index cf761f7927523..28d4a7f010450 100644 --- a/crates/binder/Cargo.toml +++ b/crates/binder/Cargo.toml @@ -12,11 +12,9 @@ repository.workspace = true [dependencies] foundry-config.workspace = true -ethers-solc = { workspace = true, features = ["async", "svm-solc", "project-util"] } ethers-contract = { workspace = true, features = ["abigen"] } -curl = { version = "0.4", default-features = false, features = ["http2"] } eyre = "0.6" -git2 = { version = "0.17", default-features = false } +git2 = { version = "0.18", default-features = false } url = "2" tracing = "0.1" tempfile = "3" diff --git a/crates/binder/src/lib.rs b/crates/binder/src/lib.rs index e57d8c95a7cf9..8bc3e49067d4d 100644 --- a/crates/binder/src/lib.rs +++ b/crates/binder/src/lib.rs @@ -1,5 +1,7 @@ //! Generate [ethers-rs]("https://github.com/gakonst/ethers-rs") bindings for solidity projects in a build script. +#![warn(unused_crate_dependencies)] + use crate::utils::{GitReference, GitRemote}; use ethers_contract::MultiAbigen; pub use foundry_config::Config; diff --git a/crates/binder/src/utils.rs b/crates/binder/src/utils.rs index 1d73e942b56c3..479c32892aef0 100644 --- a/crates/binder/src/utils.rs +++ b/crates/binder/src/utils.rs @@ -421,21 +421,6 @@ fn maybe_spurious(err: &eyre::Error) -> bool { _ => (), } } - if let Some(curl_err) = err.downcast_ref::() { - if curl_err.is_couldnt_connect() || - curl_err.is_couldnt_resolve_proxy() || - curl_err.is_couldnt_resolve_host() || - curl_err.is_operation_timedout() || - curl_err.is_recv_error() || - curl_err.is_send_error() || - curl_err.is_http2_error() || - curl_err.is_http2_stream_error() || - curl_err.is_ssl_connect_error() || - curl_err.is_partial_file() - { - return true - } - } false } diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 141b67244dc0b..890ccda69af29 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -52,7 +52,7 @@ bytes = "1.4" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" -comfy-table = "6" +comfy-table = "7" dunce = "1" indicatif = "0.17" itertools.workspace = true diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index f7b03894b85df..701416630e5a5 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -41,7 +41,7 @@ reqwest = { version = "0.11", default-features = false } # misc clap = { version = "4", features = ["derive", "env", "wrap_help"] } -rustyline = "11" +rustyline = "12" solang-parser.workspace = true yansi = "0.5" strum = { version = "0.25", features = ["derive"] } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 24183a8ef2721..448ccd973dd86 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -26,7 +26,7 @@ reqwest = { version = "0.11", default-features = false } # cli clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } -comfy-table = "6" +comfy-table = "7" tracing = "0.1" yansi = "0.5" tempfile = "3" @@ -49,6 +49,5 @@ url = "2" # Using const-hex instead of hex for speed hex.workspace = true - [dev-dependencies] tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 391bb926caf32..3b6a3f567aa75 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -24,8 +24,8 @@ number_prefix = "0.4" serde = { version = "1", features = ["derive"] } serde_regex = "1" serde_json = "1" -toml = { version = "0.7", features = ["preserve_order"] } -toml_edit = "0.19" +toml = { version = "0.8", features = ["preserve_order"] } +toml_edit = "0.20" # dirs dirs-next = "2" diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index fc2e8f5fcc19b..bd4de10bc9c7f 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -16,8 +16,8 @@ foundry-utils.workspace = true alloy-primitives.workspace = true -crossterm = "0.26" +crossterm = "0.27" eyre = "0.6" tracing = "0.1" revm = { workspace = true, features = ["serde", "arbitrary"] } -ratatui = { version = "0.22.0", default-features = false, features = ["crossterm"] } +ratatui = { version = "0.23.0", default-features = false, features = ["crossterm"] } diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 6292d3defa41f..9fc512d1e572b 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -39,7 +39,7 @@ once_cell = "1" # EVM bytes = "1" -hashbrown = { version = "0.13", features = ["serde"] } +hashbrown = { version = "0.14", features = ["serde"] } revm = { workspace = true, features = [ "serde", "memory_limit", @@ -61,7 +61,7 @@ yansi = "0.5" url = "2" auto_impl = "1" itertools.workspace = true -ordered-float = "3" +ordered-float = "4" walkdir = "2" # Coverage diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index 4e02a2340bf08..f4e4366e5388e 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -22,7 +22,7 @@ solang-parser.workspace = true # misc itertools.workspace = true thiserror = "1" -ariadne = "0.2" +ariadne = "0.3" tracing = "0.1" [dev-dependencies] diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 5cbe46be72ef0..3f2fc2697620f 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -24,7 +24,7 @@ foundry-common.workspace = true foundry-config.workspace = true foundry-evm.workspace = true -comfy-table = "6" +comfy-table = "7" ethers = { workspace = true, features = ["solc-full"] } eyre = "0.6" proptest = "1" @@ -46,7 +46,7 @@ bytes = "1.4" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" -dialoguer = { version = "0.10", default-features = false } +dialoguer = { version = "0.11", default-features = false } dunce = "1" futures = "0.3" hex.workspace = true From f74e78ccf9b80a6723376b5ad7942e44fb282bab Mon Sep 17 00:00:00 2001 From: vigneshwar <133866568+wiggnash@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:09:21 +0530 Subject: [PATCH 0140/1963] Support all ether units in to-unit #5962 (#5978) * Support all ether units in to-unit #5962 * fix typo trim_end_matches * rustfmt --------- Co-authored-by: Matthias Seitz --- crates/cast/src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 253252711d9ba..659886678984d 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1271,9 +1271,21 @@ impl SimpleCast { "eth" | "ether" => ethers_core::utils::format_units(value, 18)? .trim_end_matches(".000000000000000000") .to_string(), + "milli" | "milliether" => ethers_core::utils::format_units(value, 15)? + .trim_end_matches(".000000000000000") + .to_string(), + "micro" | "microether" => ethers_core::utils::format_units(value, 12)? + .trim_end_matches(".000000000000") + .to_string(), "gwei" | "nano" | "nanoether" => ethers_core::utils::format_units(value, 9)? .trim_end_matches(".000000000") .to_string(), + "mwei" | "mega" | "megaether" => { + ethers_core::utils::format_units(value, 6)?.trim_end_matches(".000000").to_string() + } + "kwei" | "kilo" | "kiloether" => { + ethers_core::utils::format_units(value, 3)?.trim_end_matches(".000").to_string() + } "wei" => ethers_core::utils::format_units(value, 0)?.trim_end_matches(".0").to_string(), _ => eyre::bail!("invalid unit: \"{}\"", unit), }) From 39eee9e1a4eea92c55accc5ac7c8e5df8af00b59 Mon Sep 17 00:00:00 2001 From: Cheng-Kang Chen Date: Wed, 4 Oct 2023 22:03:49 +0800 Subject: [PATCH 0141/1963] feat(debugger): Highlight memory region for any instruction (#5940) * Highlight memory region for any instruction in debugger * Update comments Move some in-function comments to the be function docs. Since now not only a memory word but a region of memory is highlighted, we changed some var name to be clear. --- crates/debugger/src/lib.rs | 95 ++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 20 deletions(-) diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 8d6cb92fdd983..f3518cbad2a69 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -1,6 +1,6 @@ #![warn(unused_crate_dependencies)] -use alloy_primitives::Address; +use alloy_primitives::{Address, U256}; use crossterm::{ event::{ self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, @@ -859,6 +859,53 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k f.render_widget(paragraph, area); } + /// The memory_access variable stores the index on the stack that indicates the memory + /// offset/size accessed by the given opcode: + /// (read memory offset, read memory size, write memory offset, write memory size) + /// >= 1: the stack index + /// 0: no memory access + /// -1: a fixed size of 32 bytes + /// -2: a fixed size of 1 byte + /// The return value is a tuple about accessed memory region by the given opcode: + /// (read memory offset, read memory size, write memory offset, write memory size) + fn get_memory_access( + op: u8, + stack: &Vec, + ) -> (Option, Option, Option, Option) { + let memory_access = match op { + opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => (1, 2, 0, 0), + opcode::CALLDATACOPY | opcode::CODECOPY | opcode::RETURNDATACOPY => (0, 0, 1, 3), + opcode::EXTCODECOPY => (0, 0, 2, 4), + opcode::MLOAD => (1, -1, 0, 0), + opcode::MSTORE => (0, 0, 1, -1), + opcode::MSTORE8 => (0, 0, 1, -2), + opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => { + (1, 2, 0, 0) + } + opcode::CREATE | opcode::CREATE2 => (2, 3, 0, 0), + opcode::CALL | opcode::CALLCODE => (4, 5, 0, 0), + opcode::DELEGATECALL | opcode::STATICCALL => (3, 4, 0, 0), + _ => Default::default(), + }; + + let stack_len = stack.len(); + let get_size = |stack_index| match stack_index { + -2 => Some(1), + -1 => Some(32), + 0 => None, + 1.. => Some(stack[stack_len - stack_index as usize].to()), + _ => panic!("invalid stack index"), + }; + + let (read_offset, read_size, write_offset, write_size) = ( + get_size(memory_access.0), + get_size(memory_access.1), + get_size(memory_access.2), + get_size(memory_access.3), + ); + (read_offset, read_size, write_offset, write_size) + } + /// Draw memory in memory pane fn draw_memory( f: &mut Frame, @@ -876,23 +923,23 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let max_i = memory.len() / 32; let min_len = format!("{:x}", max_i * 32).len(); - // color memory words based on write/read - let mut word: Option = None; + // color memory region based on write/read + let mut offset: Option = None; + let mut size: Option = None; let mut color = None; if let Instruction::OpCode(op) = debug_steps[current_step].instruction { let stack_len = debug_steps[current_step].stack.len(); if stack_len > 0 { - let w = debug_steps[current_step].stack[stack_len - 1]; - match op { - opcode::MLOAD => { - word = Some(w.to()); - color = Some(Color::Cyan); - } - opcode::MSTORE => { - word = Some(w.to()); - color = Some(Color::Red); - } - _ => {} + let (read_offset, read_size, write_offset, write_size) = + Tui::get_memory_access(op, &debug_steps[current_step].stack); + if read_offset.is_some() { + offset = read_offset; + size = read_size; + color = Some(Color::Cyan); + } else if write_offset.is_some() { + offset = write_offset; + size = write_size; + color = Some(Color::Red); } } } @@ -900,11 +947,12 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k // color word on previous write op if current_step > 0 { let prev_step = current_step - 1; - let stack_len = debug_steps[prev_step].stack.len(); if let Instruction::OpCode(op) = debug_steps[prev_step].instruction { - if op == opcode::MSTORE { - let prev_top = debug_steps[prev_step].stack[stack_len - 1]; - word = Some(prev_top.to()); + let (_, _, write_offset, write_size) = + Tui::get_memory_access(op, &debug_steps[prev_step].stack); + if write_offset.is_some() { + offset = write_offset; + size = write_size; color = Some(Color::Green); } } @@ -925,8 +973,15 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k .map(|(j, byte)| { Span::styled( format!("{byte:02x} "), - if let (Some(w), Some(color)) = (word, color) { - if (i == w / 32 && j >= w % 32) || (i == w / 32 + 1 && j < w % 32) { + if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { + if (i == offset / 32 && j >= offset % 32) || + (i > offset / 32 && i < (offset + size - 1) / 32) || + (i == (offset + size - 1) / 32 && + j <= (offset + size - 1) % 32) + { + // [offset, offset + size] is the memory region to be colored. + // If a byte at row i and column j in the memory panel + // falls in this region, set the color. Style::default().fg(color) } else if *byte == 0 { Style::default().add_modifier(Modifier::DIM) From 6262870fb1b8d9b605e5c1552b730af844ba3a3e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 4 Oct 2023 17:59:27 +0200 Subject: [PATCH 0142/1963] chore(deps): no c-kzg default feature (#5981) --- Cargo.toml | 2 +- crates/anvil/core/Cargo.toml | 2 +- crates/debugger/Cargo.toml | 2 +- crates/evm/Cargo.toml | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 568216f67b2ca..04ba1432c07ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,7 +135,7 @@ foundry-utils = { path = "crates/utils" } foundry-debugger = { path = "crates/debugger" } ## revm -revm = "3" +revm = { version = "3", default-features = false } # no default features to avoid c-kzg revm-primitives = "1" ## ethers diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 0a55d62f01e31..36584310be567 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true # foundry internal foundry-evm = { path = "../../evm" } foundry-utils = { path = "../../utils" } -revm = { workspace = true, features = ["serde", "memory_limit"] } +revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } alloy-primitives = { workspace = true, features = ["serde"] } ethers-core.workspace = true diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index bd4de10bc9c7f..a4e5a524d423c 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -19,5 +19,5 @@ alloy-primitives.workspace = true crossterm = "0.27" eyre = "0.6" tracing = "0.1" -revm = { workspace = true, features = ["serde", "arbitrary"] } +revm = { workspace = true, default-features = false, features = ["std", "serde", "arbitrary"] } ratatui = { version = "0.23.0", default-features = false, features = ["crossterm"] } diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 9fc512d1e572b..6182921ee90ad 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -40,7 +40,8 @@ once_cell = "1" # EVM bytes = "1" hashbrown = { version = "0.14", features = ["serde"] } -revm = { workspace = true, features = [ +revm = { workspace = true, default-features = false, features = [ + "std", "serde", "memory_limit", "optional_eip3607", From d180f65095998c4b2eafda3bb45663b77811eced Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 4 Oct 2023 19:01:40 +0200 Subject: [PATCH 0143/1963] fix: incorrect fuzz filter check (#5982) --- crates/anvil/src/eth/otterscan/api.rs | 3 +-- crates/anvil/tests/it/otterscan.rs | 6 +----- crates/debugger/src/debugger.rs | 9 ++++++--- crates/evm/src/executor/mod.rs | 1 - crates/forge/bin/cmd/test/mod.rs | 14 ++++++-------- crates/forge/src/multi_runner.rs | 27 +++++++++++++++++++-------- crates/forge/src/runner.rs | 3 ++- 7 files changed, 35 insertions(+), 28 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index ee254b6ae5a3a..c22354c3083ac 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -146,7 +146,6 @@ impl EthApi { let mut res: Vec<_> = vec![]; - dbg!(to, from); for n in (to..=from).rev() { if n == to { last_page = true; @@ -271,7 +270,7 @@ impl EthApi { // loop in reverse, since we want the latest deploy to the address for n in (from..=to).rev() { - if let Some(traces) = dbg!(self.backend.mined_parity_trace_block(n)) { + if let Some(traces) = self.backend.mined_parity_trace_block(n) { for trace in traces.into_iter().rev() { match (trace.action, trace.result) { ( diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 4c5b4ec6f2e70..2c4959cd52236 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -238,9 +238,7 @@ contract Contract { let call = contract.method::<_, ()>("trigger_revert", ()).unwrap().gas(150_000u64); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - let block = api.block_by_number_full(BlockNumber::Latest).await.unwrap().unwrap(); - dbg!(block); - // let tx = block.transactions[0].hashVg + let _block = api.block_by_number_full(BlockNumber::Latest).await.unwrap().unwrap(); let res = api.ots_get_transaction_error(receipt.transaction_hash).await.unwrap().unwrap(); assert_eq!(res, Bytes::from_str("0x8d6ea8be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012526576657274537472696e67466f6f4261720000000000000000000000000000").unwrap()); @@ -299,13 +297,11 @@ async fn can_call_ots_get_block_transactions() { hashes.push_back(receipt.tx_hash()); } - dbg!(&hashes); api.mine_one().await; let page_size = 3; for page in 0..4 { let result = api.ots_get_block_transactions(1, page, page_size).await.unwrap(); - dbg!(&result); assert!(result.receipts.len() <= page_size); assert!(result.fullblock.block.transactions.len() <= page_size); diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index ea5770e635640..3b92c47747155 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -2,7 +2,7 @@ use crate::Ui; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder}; use foundry_utils::types::ToAlloy; -use tracing::trace; +use tracing::{error, trace}; use crate::{TUIExitReason, Tui}; @@ -19,14 +19,17 @@ pub struct DebuggerArgs<'a> { } impl DebuggerArgs<'_> { + /// Starts the debugger pub fn run(&self) -> eyre::Result { trace!(target: "debugger", "running debugger"); - let flattened = self .debug .last() .map(|arena| arena.flatten(0)) - .expect("We should have collected debug information"); + .ok_or_else(|| { + error!(target: "debugger", debug_entries=?self.debug.len(), "Failed to get debug information for arena"); + eyre::eyre!("Unable to collected debug information") + })?; let identified_contracts = self .decoder diff --git a/crates/evm/src/executor/mod.rs b/crates/evm/src/executor/mod.rs index cc7f03c0d7d39..4740dacb8c62c 100644 --- a/crates/evm/src/executor/mod.rs +++ b/crates/evm/src/executor/mod.rs @@ -326,7 +326,6 @@ impl Executor { // Persist the snapshot failure recorded on the fuzz backend wrapper. self.backend .set_snapshot_failure(self.backend.has_snapshot_failure() || db.has_snapshot_failure()); - convert_executed_result(env, inspector, result) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 15912e5944ca7..3c6b03019e283 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -199,16 +199,16 @@ impl TestArgs { if should_debug { filter.args_mut().test_pattern = self.debug.clone(); - let n = runner.count_filtered_tests(&filter); - if n != 1 { + let num_filtered = runner.matching_test_function_count(&filter); + if num_filtered != 1 { return Err( - eyre::eyre!("{n} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n + eyre::eyre!("{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n \n Use --match-contract and --match-path to further limit the search.")); } - let test_funcs = runner.get_typed_tests(&filter); + let test_funcs = runner.get_matching_test_functions(&filter); // if we debug a fuzz test, we should not collect data on the first run - if !test_funcs.get(0).unwrap().inputs.is_empty() { + if !test_funcs.get(0).expect("matching function exists").inputs.is_empty() { runner_builder = runner_builder.set_debug(false); runner = runner_builder.clone().build( project_root, @@ -229,7 +229,6 @@ impl TestArgs { if should_debug { let tests = outcome.clone().into_tests(); - let mut decoders = Vec::new(); for test in tests { let mut result = test.result; @@ -308,7 +307,6 @@ impl TestArgs { let test = outcome.clone().into_tests().next().unwrap(); let result = test.result; - // Run the debugger let debugger = DebuggerArgs { debug: result.debug.map_or(vec![], |debug| vec![debug]), @@ -618,7 +616,7 @@ async fn test( fail_fast: bool, ) -> Result { trace!(target: "forge::test", "running all tests"); - if runner.count_filtered_tests(&filter) == 0 { + if runner.matching_test_function_count(&filter) == 0 { let filter_str = filter.to_string(); if filter_str.is_empty() { println!( diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 334a9c3a4572f..6f26d6755845b 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -60,7 +60,23 @@ pub struct MultiContractRunner { impl MultiContractRunner { /// Returns the number of matching tests - pub fn count_filtered_tests(&self, filter: &impl TestFilter) -> usize { + pub fn matching_test_function_count(&self, filter: &impl TestFilter) -> usize { + self.matching_test_functions(filter).count() + } + + /// Returns all test functions matching the filter + pub fn get_matching_test_functions<'a>( + &'a self, + filter: &'a impl TestFilter, + ) -> Vec<&Function> { + self.matching_test_functions(filter).collect() + } + + /// Returns all test functions matching the filter + pub fn matching_test_functions<'a>( + &'a self, + filter: &'a impl TestFilter, + ) -> impl Iterator { self.contracts .iter() .filter(|(id, _)| { @@ -70,10 +86,10 @@ impl MultiContractRunner { .flat_map(|(_, (abi, _, _))| { abi.functions().filter(|func| filter.matches_test(func.signature())) }) - .count() } - /// Get an iterator over all test functions that matches the filter path and contract name + /// Get an iterator over all test contract functions that matches the filter path and contract + /// name fn filtered_tests<'a>( &'a self, filter: &'a impl TestFilter, @@ -95,11 +111,6 @@ impl MultiContractRunner { .collect() } - /// Returns all test functions matching the filter - pub fn get_typed_tests<'a>(&'a self, filter: &'a impl TestFilter) -> Vec<&Function> { - self.filtered_tests(filter).filter(|func| func.name.is_test()).collect() - } - /// Returns all matching tests grouped by contract grouped by file (file -> (contract -> tests)) pub fn list( &self, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 5e791300d71ab..6b91fb07fda67 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -327,7 +327,7 @@ impl<'a> ContractRunner<'a> { // Run unit test let mut executor = self.executor.clone(); let start = Instant::now(); - let mut debug_arena = None; + let debug_arena; let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = match executor.execute_test::<(), _, _>( self.sender.to_alloy(), @@ -362,6 +362,7 @@ impl<'a> ContractRunner<'a> { labeled_addresses .extend(err.labels.into_iter().map(|l| (l.0.to_ethers(), l.1))); logs.extend(err.logs); + debug_arena = err.debug; ( err.reverted, Some(err.reason), From 2fc85cb4a2d296b916a413f9f13caadebcf4cf47 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 4 Oct 2023 19:01:49 +0200 Subject: [PATCH 0144/1963] chore(deps): no c-kzg default feature (#5983) --- Cargo.lock | 1 - Cargo.toml | 5 +++-- crates/config/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d4e1f3bd76f6..98c01a38dac90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5531,7 +5531,6 @@ dependencies = [ "enumn", "hashbrown 0.14.1", "hex", - "once_cell", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 04ba1432c07ff..a3323dd7d8996 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,8 +135,9 @@ foundry-utils = { path = "crates/utils" } foundry-debugger = { path = "crates/debugger" } ## revm -revm = { version = "3", default-features = false } # no default features to avoid c-kzg -revm-primitives = "1" +# no default features to avoid c-kzg +revm = { version = "3", default-features = false } # +revm-primitives = { version = "1" , default-features = false } ## ethers ethers = { version = "2.0", default-features = false } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 3b6a3f567aa75..908018e1f41b8 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -15,7 +15,7 @@ repository.workspace = true ethers-core.workspace = true ethers-solc = { workspace = true, features = ["async", "svm-solc"] } ethers-etherscan.workspace = true -revm-primitives.workspace = true +revm-primitives = { workspace = true, default-features = false, features = ["std"] } # formats Inflector = "0.11" From a88afa91c288137839a88edfa59a85038b0bf3e2 Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 5 Oct 2023 10:04:39 +0900 Subject: [PATCH 0145/1963] feat(`evm`): migrate cheatcodes to `dyn-abi` (#5928) * feat: migrate most cheatcodes * feat: migrate non-critical cheatcodes * feat: finish migrating cheatcodes to abi * chore: remove prints * chore: fixture * chore: move back to original impl * clippy * chore: 32 -> 256 plus clippy * chore: review comments * chore: updated error msg * fix: correct scientific notation parsing + fix bad coercion test * chore: fix encoding for accesses * chore: clippy/fmt * chore: regen bindings with tuple * feat: pad bytes32 values accurately for compatibility * chore: resolve review comments, clippy/fmt * chore: clippy --- Cargo.lock | 21 +- Cargo.toml | 13 +- crates/abi/abi/HEVM.sol | 2 +- crates/evm/src/executor/backend/diagnostic.rs | 9 +- .../src/executor/inspector/cheatcodes/env.rs | 244 ++++++++++-------- .../executor/inspector/cheatcodes/expect.rs | 91 ++++--- .../src/executor/inspector/cheatcodes/ext.rs | 229 ++++++++-------- .../src/executor/inspector/cheatcodes/fork.rs | 164 +++++++----- .../src/executor/inspector/cheatcodes/fs.rs | 47 ++-- .../executor/inspector/cheatcodes/mapping.rs | 50 ++-- .../src/executor/inspector/cheatcodes/mod.rs | 167 ++++++------ .../executor/inspector/cheatcodes/parse.rs | 131 +++++----- .../executor/inspector/cheatcodes/snapshot.rs | 10 +- .../src/executor/inspector/cheatcodes/util.rs | 30 +-- .../executor/inspector/cheatcodes/wallet.rs | 86 +++--- crates/evm/src/executor/inspector/stack.rs | 6 +- testdata/cheats/Env.t.sol | 8 +- testdata/fixtures/Json/test.json | 2 +- 18 files changed, 710 insertions(+), 600 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98c01a38dac90..8c7ca4054884e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,8 +78,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a2c94da79130a80677c497eb56e465f72e376e0d85720228be2cf6c85ec5b0" +source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -97,8 +96,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d187c265879ea8fc1fb574f75f95942e9502d2a67eba7e5c9f6ba9879375ddd6" +source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -109,8 +107,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4084879b7257d5b95b9009837c07a1868bd7d60e66418a7764b9b580ae64e0" +source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,8 +153,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de84480ac5979d8513164f7e668f837839cd6d5c4bdb8beecbb8cf062b61cb48" +source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" dependencies = [ "const-hex", "dunce", @@ -172,8 +168,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3427d2135d3c28696b437fdf44b86e334f36639d367abc8a5af2f718b3c1992b" +source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" dependencies = [ "winnow", ] @@ -181,8 +176,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7e42aa2983db6676af5d762bc8d9371dd74f5948739790d3080c3d652a957b" +source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -6535,8 +6529,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8a5a633f1172a0c80b1516a988e7e8efa7ce9cededf56590f54e593e4513b3" +source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index a3323dd7d8996..90cdfcf382b51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,9 +152,11 @@ ethers-etherscan = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy -alloy-primitives = "0.4" -alloy-dyn-abi = "0.4" -alloy-json-abi = "0.4" + +alloy-primitives = { version = "0.4", default-features = false } +alloy-dyn-abi = { version = "0.4", default-features = false } +alloy-json-abi = { version = "0.4", default-features = false } +alloy-sol-types = { version = "0.4", default-features = false } solang-parser = "=0.3.2" @@ -193,3 +195,8 @@ revm = { git = "https://github.com/bluealloy/revm/", branch = "main" } revm-interpreter = { git = "https://github.com/bluealloy/revm/", branch = "main" } revm-precompile = { git = "https://github.com/bluealloy/revm/", branch = "main" } revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "main" } + +alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/", branch = "main"} +alloy-primitives = { git = "https://github.com/alloy-rs/core/", branch = "main"} +alloy-json-abi = { git = "https://github.com/alloy-rs/core/", branch = "main"} +alloy-sol-types = { git = "https://github.com/alloy-rs/core/", branch = "main"} diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index 911b6580dc88a..47c66ae517749 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -81,7 +81,7 @@ expectRevert() expectRevert(bytes) expectRevert(bytes4) record() -accesses(address)(bytes32[],bytes32[]) +accesses(address)(bytes32[], bytes32[]) skip(bool) recordLogs() diff --git a/crates/evm/src/executor/backend/diagnostic.rs b/crates/evm/src/executor/backend/diagnostic.rs index 6f3b48a9bb707..ff179460e3008 100644 --- a/crates/evm/src/executor/backend/diagnostic.rs +++ b/crates/evm/src/executor/backend/diagnostic.rs @@ -1,6 +1,7 @@ use crate::executor::{backend::LocalForkId, inspector::Cheatcodes}; use alloy_primitives::Address; use foundry_common::fmt::UIfmt; + use foundry_utils::types::ToEthers; use itertools::Itertools; @@ -25,11 +26,13 @@ pub enum RevertDiagnostic { impl RevertDiagnostic { /// Converts the diagnostic to a readable error message pub fn to_error_msg(&self, cheats: &Cheatcodes) -> String { - let get_label = |addr| cheats.labels.get(addr).cloned().unwrap_or_else(|| addr.pretty()); + let get_label = |addr: &Address| { + cheats.labels.get(addr).cloned().unwrap_or_else(|| addr.to_ethers().pretty()) + }; match self { RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => { - let contract_label = get_label(&(*contract).to_ethers()); + let contract_label = get_label(contract); format!( r#"Contract {} does not exist on active fork with id `{}` @@ -40,7 +43,7 @@ impl RevertDiagnostic { ) } RevertDiagnostic::ContractDoesNotExist { contract, persistent, .. } => { - let contract_label = get_label(&contract.to_ethers()); + let contract_label = get_label(contract); if *persistent { format!("Contract {contract_label} does not exist") } else { diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index 9358b2791df09..96cf49ce929c9 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -11,12 +11,8 @@ use crate::{ }, }; use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{Bytes, B256, U256 as rU256}; -use ethers::{ - abi::{self, RawLog, Token, Tokenizable, Tokenize}, - signers::{LocalWallet, Signer}, - types::{Address, U256}, -}; +use alloy_primitives::{Address, Bytes, Log, B256, U256}; +use ethers::signers::{LocalWallet, Signer}; use foundry_config::Config; use foundry_utils::types::{ToAlloy, ToEthers}; use revm::{ @@ -104,7 +100,7 @@ enum CallerMode { impl From for U256 { fn from(value: CallerMode) -> Self { - (value as i8).into() + U256::from(value as u8) } } @@ -142,10 +138,17 @@ fn broadcast_key( single_call: bool, ) -> Result { let key = super::util::parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.as_u64()); + let wallet = LocalWallet::from(key).with_chain_id(chain_id.to::()); let new_origin = wallet.address(); - let result = broadcast(state, new_origin, original_caller, original_origin, depth, single_call); + let result = broadcast( + state, + new_origin.to_alloy(), + original_caller, + original_origin, + depth, + single_call, + ); if result.is_ok() { state.script_wallets.push(wallet); } @@ -210,10 +213,10 @@ fn read_callers(state: &Cheatcodes, default_sender: Address) -> Bytes { let caller_mode = if prank.single_call { CallerMode::Prank } else { CallerMode::RecurrentPrank }; - [ - Token::Uint(caller_mode.into()), - Token::Address(prank.new_caller), - Token::Address(prank.new_origin.unwrap_or(default_sender)), + vec![ + DynSolValue::Uint(caller_mode.into(), 256), + DynSolValue::Address(prank.new_caller), + DynSolValue::Address(prank.new_origin.unwrap_or(default_sender)), ] } else if let Some(broadcast) = broadcast { let caller_mode = if broadcast.single_call { @@ -222,20 +225,20 @@ fn read_callers(state: &Cheatcodes, default_sender: Address) -> Bytes { CallerMode::RecurrentBroadcast }; - [ - Token::Uint(caller_mode.into()), - Token::Address(broadcast.new_origin), - Token::Address(broadcast.new_origin), + vec![ + DynSolValue::Uint(caller_mode.into(), 256), + DynSolValue::Address(broadcast.new_origin), + DynSolValue::Address(broadcast.new_origin), ] } else { - [ - Token::Uint(CallerMode::None.into()), - Token::Address(default_sender), - Token::Address(default_sender), + vec![ + DynSolValue::Uint(CallerMode::None.into(), 256), + DynSolValue::Address(default_sender), + DynSolValue::Address(default_sender), ] }; - abi::encode(&data).into() + DynSolValue::Tuple(data).abi_encode().into() } #[derive(Clone, Debug, Default)] @@ -250,27 +253,42 @@ fn start_record(state: &mut Cheatcodes) { fn accesses(state: &mut Cheatcodes, address: Address) -> Bytes { if let Some(storage_accesses) = &mut state.accesses { - let first_token = - |x: Option>| x.unwrap_or_default().into_tokens().into_iter().next().unwrap(); - ethers::abi::encode(&[ - first_token(storage_accesses.reads.remove(&address)), - first_token(storage_accesses.writes.remove(&address)), + let write_accesses: Vec = storage_accesses + .writes + .entry(address) + .or_default() + .iter_mut() + .map(|u| DynSolValue::FixedBytes(u.to_owned().into(), 32)) + .collect(); + let read_accesses = storage_accesses + .reads + .entry(address) + .or_default() + .iter_mut() + .map(|u| DynSolValue::FixedBytes(u.to_owned().into(), 32)) + .collect(); + DynSolValue::Tuple(vec![ + DynSolValue::Array(read_accesses), + DynSolValue::Array(write_accesses), ]) + .abi_encode_params() .into() } else { - ethers::abi::encode(&[Token::Array(vec![]), Token::Array(vec![])]).into() + DynSolValue::Tuple(vec![DynSolValue::Array(vec![]), DynSolValue::Array(vec![])]) + .abi_encode_params() + .into() } } #[derive(Clone, Debug, Default)] pub struct RecordedLogs { - pub entries: Vec, + pub entries: Vec, } #[derive(Clone, Debug)] -pub struct Log { +pub struct RecordedLog { pub emitter: Address, - pub inner: RawLog, + pub inner: Log, } fn start_record_logs(state: &mut Cheatcodes) { @@ -279,23 +297,30 @@ fn start_record_logs(state: &mut Cheatcodes) { fn get_recorded_logs(state: &mut Cheatcodes) -> Bytes { if let Some(recorded_logs) = state.recorded_logs.replace(Default::default()) { - abi::encode( - &recorded_logs + DynSolValue::Array( + recorded_logs .entries .iter() .map(|entry| { - Token::Tuple(vec![ - entry.inner.topics.clone().into_token(), - Token::Bytes(entry.inner.data.clone()), - entry.emitter.into_token(), + DynSolValue::Tuple(vec![ + DynSolValue::Array( + entry + .inner + .topics() + .iter() + .map(|t| DynSolValue::FixedBytes(*t, 32)) + .collect(), + ), + DynSolValue::Bytes(entry.inner.data.clone().to_vec()), + DynSolValue::Address(entry.emitter), ]) }) - .collect::>() - .into_tokens(), + .collect::>(), ) + .abi_encode() .into() } else { - abi::encode(&[Token::Array(vec![])]).into() + DynSolValue::Array(vec![]).abi_encode().into() } } @@ -312,7 +337,7 @@ fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: boo // add a breakpoint from the interpreter if add { - state.breakpoints.insert(point, (caller, state.pc)); + state.breakpoints.insert(point, (caller.to_ethers(), state.pc)); } else { state.breakpoints.remove(&point); } @@ -322,7 +347,7 @@ fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: boo // mark the slots of an account and the account address as cold fn cool_account(data: &mut EVMData<'_, DB>, address: Address) -> Result { - if let Some(account) = data.journaled_state.state.get_mut(&address.to_alloy()) { + if let Some(account) = data.journaled_state.state.get_mut(&address) { if account.is_touched() { account.unmark_touch(); } @@ -377,35 +402,35 @@ pub fn apply( Bytes::new() } HEVMCalls::Store(inner) => { - ensure!(!is_potential_precompile(inner.0), "Store cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); + ensure!(!is_potential_precompile(inner.0.to_alloy()), "Store cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; // ensure the account is touched data.journaled_state.touch(&inner.0.to_alloy()); data.journaled_state.sstore( inner.0.to_alloy(), - rU256::from_be_bytes(inner.1), - rU256::from_be_bytes(inner.2), + U256::from_be_bytes(inner.1), + U256::from_be_bytes(inner.2), data.db, )?; Bytes::new() } HEVMCalls::Load(inner) => { - ensure!(!is_potential_precompile(inner.0), "Load cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); + ensure!(!is_potential_precompile(inner.0.to_alloy()), "Load cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); // TODO: Does this increase gas usage? data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; let (val, _) = data.journaled_state.sload( inner.0.to_alloy(), - rU256::from_be_bytes(inner.1), + U256::from_be_bytes(inner.1), data.db, )?; DynSolValue::from(val).abi_encode().into() } - HEVMCalls::Cool(inner) => cool_account(data, inner.0)?, + HEVMCalls::Cool(inner) => cool_account(data, inner.0.to_alloy())?, HEVMCalls::Breakpoint0(inner) => add_breakpoint(state, caller, &inner.0, true)?, HEVMCalls::Breakpoint1(inner) => add_breakpoint(state, caller, &inner.0, inner.1)?, HEVMCalls::Etch(inner) => { - ensure!(!is_potential_precompile(inner.0), "Etch cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); + ensure!(!is_potential_precompile(inner.0.to_alloy()), "Etch cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); let code = inner.1.clone(); trace!(address=?inner.0, code=?hex::encode(&code), "etch cheatcode"); // TODO: Does this increase gas usage? @@ -420,24 +445,29 @@ pub fn apply( let who = inner.0; let value = inner.1; trace!(?who, ?value, "deal cheatcode"); - with_journaled_account(&mut data.journaled_state, data.db, who, |account| { - // record the deal - let record = DealRecord { - address: who, - old_balance: account.info.balance.to_ethers(), - new_balance: value, - }; - state.eth_deals.push(record); - - account.info.balance = value.to_alloy(); - })?; + with_journaled_account( + &mut data.journaled_state, + data.db, + who.to_alloy(), + |account| { + // record the deal + let record = DealRecord { + address: who.to_alloy(), + old_balance: account.info.balance, + new_balance: value.to_alloy(), + }; + state.eth_deals.push(record); + + account.info.balance = value.to_alloy(); + }, + )?; Bytes::new() } HEVMCalls::Prank0(inner) => prank( state, caller, - data.env.tx.caller.to_ethers(), - inner.0, + data.env.tx.caller, + inner.0.to_alloy(), None, data.journaled_state.depth(), true, @@ -445,17 +475,17 @@ pub fn apply( HEVMCalls::Prank1(inner) => prank( state, caller, - data.env.tx.caller.to_ethers(), - inner.0, - Some(inner.1), + data.env.tx.caller, + inner.0.to_alloy(), + Some(inner.1.to_alloy()), data.journaled_state.depth(), true, )?, HEVMCalls::StartPrank0(inner) => prank( state, caller, - data.env.tx.caller.to_ethers(), - inner.0, + data.env.tx.caller, + inner.0.to_alloy(), None, data.journaled_state.depth(), false, @@ -463,9 +493,9 @@ pub fn apply( HEVMCalls::StartPrank1(inner) => prank( state, caller, - data.env.tx.caller.to_ethers(), - inner.0, - Some(inner.1), + data.env.tx.caller, + inner.0.to_alloy(), + Some(inner.1.to_alloy()), data.journaled_state.depth(), false, )?, @@ -474,12 +504,12 @@ pub fn apply( state.prank = None; Bytes::new() } - HEVMCalls::ReadCallers(_) => read_callers(state, data.env.tx.caller.to_ethers()), + HEVMCalls::ReadCallers(_) => read_callers(state, data.env.tx.caller), HEVMCalls::Record(_) => { start_record(state); Bytes::new() } - HEVMCalls::Accesses(inner) => accesses(state, inner.0), + HEVMCalls::Accesses(inner) => accesses(state, inner.0.to_alloy()), HEVMCalls::RecordLogs(_) => { start_record_logs(state); Bytes::new() @@ -489,7 +519,7 @@ pub fn apply( with_journaled_account( &mut data.journaled_state, data.db, - inner.0, + inner.0.to_alloy(), |account| -> Result { // nonce must increment only let current = account.info.nonce; @@ -507,7 +537,7 @@ pub fn apply( HEVMCalls::SetNonceUnsafe(inner) => with_journaled_account( &mut data.journaled_state, data.db, - inner.0, + inner.0.to_alloy(), |account| -> Result { let new = inner.1; account.info.nonce = new; @@ -517,7 +547,7 @@ pub fn apply( HEVMCalls::ResetNonce(inner) => with_journaled_account( &mut data.journaled_state, data.db, - inner.0, + inner.0.to_alloy(), |account| -> Result { // Per EIP-161, EOA nonces start at 0, but contract nonces // start at 1. Comparing by code_hash instead of code @@ -531,7 +561,7 @@ pub fn apply( // [function getNonce(address)] returns the current nonce of a given ETH address HEVMCalls::GetNonce1(inner) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, @@ -548,7 +578,7 @@ pub fn apply( // [function getNonce(Wallet)] returns the current nonce of the Wallet's ETH address HEVMCalls::GetNonce0(inner) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, @@ -563,7 +593,10 @@ pub fn apply( DynSolValue::from(account.info.nonce.to_alloy()).abi_encode().into() } HEVMCalls::ChainId(inner) => { - ensure!(inner.0 <= U256::from(u64::MAX), "Chain ID must be less than 2^64 - 1"); + ensure!( + inner.0.to_alloy() <= U256::from(u64::MAX), + "Chain ID must be less than 2^64 - 1" + ); data.env.cfg.chain_id = inner.0.as_u64(); Bytes::new() } @@ -573,98 +606,98 @@ pub fn apply( } HEVMCalls::Broadcast0(_) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, )?; broadcast( state, - data.env.tx.caller.to_ethers(), + data.env.tx.caller, caller, - data.env.tx.caller.to_ethers(), + data.env.tx.caller, data.journaled_state.depth(), true, )? } HEVMCalls::Broadcast1(inner) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, )?; broadcast( state, - inner.0, + inner.0.to_alloy(), caller, - data.env.tx.caller.to_ethers(), + data.env.tx.caller, data.journaled_state.depth(), true, )? } HEVMCalls::Broadcast2(inner) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, )?; broadcast_key( state, - inner.0, + inner.0.to_alloy(), caller, - data.env.tx.caller.to_ethers(), - data.env.cfg.chain_id.into(), + data.env.tx.caller, + U256::from(data.env.cfg.chain_id), data.journaled_state.depth(), true, )? } HEVMCalls::StartBroadcast0(_) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, )?; broadcast( state, - data.env.tx.caller.to_ethers(), + data.env.tx.caller, caller, - data.env.tx.caller.to_ethers(), + data.env.tx.caller, data.journaled_state.depth(), false, )? } HEVMCalls::StartBroadcast1(inner) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, )?; broadcast( state, - inner.0, + inner.0.to_alloy(), caller, - data.env.tx.caller.to_ethers(), + data.env.tx.caller, data.journaled_state.depth(), false, )? } HEVMCalls::StartBroadcast2(inner) => { correct_sender_nonce( - data.env.tx.caller.to_ethers(), + data.env.tx.caller, &mut data.journaled_state, &mut data.db, state, )?; broadcast_key( state, - inner.0, + inner.0.to_alloy(), caller, - data.env.tx.caller.to_ethers(), - data.env.cfg.chain_id.into(), + data.env.tx.caller, + U256::from(data.env.cfg.chain_id), data.journaled_state.depth(), false, )? @@ -694,12 +727,17 @@ pub fn apply( state.mapping_slots = None; Bytes::new() } - HEVMCalls::GetMappingLength(inner) => get_mapping_length(state, inner.0, inner.1.into()), - HEVMCalls::GetMappingSlotAt(inner) => { - get_mapping_slot_at(state, inner.0, inner.1.into(), inner.2) + HEVMCalls::GetMappingLength(inner) => { + get_mapping_length(state, inner.0.to_alloy(), U256::from_be_bytes(inner.1)) } + HEVMCalls::GetMappingSlotAt(inner) => get_mapping_slot_at( + state, + inner.0.to_alloy(), + U256::from_be_bytes(inner.1), + inner.2.to_alloy(), + ), HEVMCalls::GetMappingKeyAndParentOf(inner) => { - get_mapping_key_and_parent(state, inner.0, inner.1.into()) + get_mapping_key_and_parent(state, inner.0.to_alloy(), U256::from_be_bytes(inner.1)) } _ => return Ok(None), }; @@ -715,7 +753,7 @@ fn correct_sender_nonce( db: &mut DB, state: &mut Cheatcodes, ) -> Result<(), DB::Error> { - if !state.corrected_nonce && sender != Config::DEFAULT_SENDER { + if !state.corrected_nonce && sender.to_ethers() != Config::DEFAULT_SENDER { with_journaled_account(journaled_state, db, sender, |account| { account.info.nonce = account.info.nonce.saturating_sub(1); state.corrected_nonce = true; diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/src/executor/inspector/cheatcodes/expect.rs index 298b78c4cd7e1..51ff72f91978c 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/expect.rs @@ -1,15 +1,12 @@ use super::{bail, ensure, fmt_err, Cheatcodes, Result}; use crate::{abi::HEVMCalls, executor::backend::DatabaseExt}; -use alloy_primitives::Bytes; -use ethers::{ - abi::{AbiDecode, RawLog}, - contract::Lazy, - types::{Address, H160, U256}, -}; +use alloy_dyn_abi::DynSolType; +use alloy_primitives::{Address, Bytes, Log as RawLog, U256}; use foundry_utils::{ error::{ERROR_PREFIX, REVERT_PREFIX}, types::ToAlloy, }; +use once_cell::sync::Lazy; use revm::{ interpreter::{return_ok, InstructionResult}, primitives::Bytecode, @@ -27,7 +24,7 @@ static DUMMY_CALL_OUTPUT: Lazy = Lazy::new(|| Bytes::from_static(&[0u8; 8 /// Same reasoning as [DUMMY_CALL_OUTPUT], but for creates. static DUMMY_CREATE_ADDRESS: Address = - H160([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); + Address::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); #[derive(Clone, Debug, Default)] pub struct ExpectedRevert { @@ -82,8 +79,10 @@ pub fn handle_expect_revert( if actual_revert.len() >= 4 && matches!(actual_revert[..4].try_into(), Ok(ERROR_PREFIX | REVERT_PREFIX)) { - if let Ok(bytes) = ethers::types::Bytes::decode(&actual_revert[4..]) { - actual_revert = bytes.0.into(); + if let Ok(parsed_bytes) = DynSolType::Bytes.abi_decode(&actual_revert[4..]) { + if let Some(bytes) = parsed_bytes.as_bytes().map(|b| b.to_vec()) { + actual_revert = bytes.into(); + } } } @@ -91,8 +90,10 @@ pub fn handle_expect_revert( success_return!() } else { let stringify = |data: &mut Bytes| { - String::decode(data.0.as_ref()) + DynSolType::String + .abi_decode(data.0.as_ref()) .ok() + .and_then(|d| d.as_str().map(|s| s.to_owned())) .or_else(|| std::str::from_utf8(data.as_ref()).ok().map(ToOwned::to_owned)) .unwrap_or_else(|| hex::encode_prefixed(data)) }; @@ -152,23 +153,23 @@ pub fn handle_expect_emit(state: &mut Cheatcodes, log: RawLog, address: &Address match event_to_fill_or_check.log { Some(ref expected) => { - let expected_topic_0 = expected.topics.get(0); - let log_topic_0 = log.topics.get(0); + let expected_topic_0 = expected.topics().get(0); + let log_topic_0 = log.topics().get(0); // same topic0 and equal number of topics should be verified further, others are a no // match if expected_topic_0 .zip(log_topic_0) - .map_or(false, |(a, b)| a == b && expected.topics.len() == log.topics.len()) + .map_or(false, |(a, b)| a == b && expected.topics().len() == log.topics().len()) { // Match topics event_to_fill_or_check.found = log - .topics + .topics() .iter() .skip(1) .enumerate() .filter(|(i, _)| event_to_fill_or_check.checks[*i]) - .all(|(i, topic)| topic == &expected.topics[i + 1]); + .all(|(i, topic)| topic == &expected.topics()[i + 1]); // Maybe match source address if let Some(addr) = event_to_fill_or_check.address { @@ -284,7 +285,7 @@ fn expect_safe_memory(state: &mut Cheatcodes, start: u64, end: u64, depth: u64) #[allow(clippy::too_many_arguments)] fn expect_call( state: &mut Cheatcodes, - target: H160, + target: Address, calldata: Vec, value: Option, gas: Option, @@ -355,7 +356,7 @@ pub fn apply( state.expected_emits.push_back(ExpectedEmit { depth: data.journaled_state.depth(), checks: [true, true, true, true], - address: Some(inner.0), + address: Some(inner.0.to_alloy()), ..Default::default() }); Ok(Bytes::new()) @@ -372,14 +373,14 @@ pub fn apply( state.expected_emits.push_back(ExpectedEmit { depth: data.journaled_state.depth(), checks: [inner.0, inner.1, inner.2, inner.3], - address: Some(inner.4), + address: Some(inner.4.to_alloy()), ..Default::default() }); Ok(Bytes::new()) } HEVMCalls::ExpectCall0(inner) => expect_call( state, - inner.0, + inner.0.to_alloy(), inner.1.to_vec(), None, None, @@ -389,7 +390,7 @@ pub fn apply( ), HEVMCalls::ExpectCall1(inner) => expect_call( state, - inner.0, + inner.0.to_alloy(), inner.1.to_vec(), None, None, @@ -399,9 +400,9 @@ pub fn apply( ), HEVMCalls::ExpectCall2(inner) => expect_call( state, - inner.0, + inner.0.to_alloy(), inner.2.to_vec(), - Some(inner.1), + Some(inner.1.to_alloy()), None, None, 1, @@ -409,23 +410,23 @@ pub fn apply( ), HEVMCalls::ExpectCall3(inner) => expect_call( state, - inner.0, + inner.0.to_alloy(), inner.2.to_vec(), - Some(inner.1), + Some(inner.1.to_alloy()), None, None, inner.3, ExpectedCallType::Count, ), HEVMCalls::ExpectCall4(inner) => { - let value = inner.1; + let value = inner.1.to_alloy(); // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::zero() { 2300 } else { 0 }; + let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; expect_call( state, - inner.0, + inner.0.to_alloy(), inner.3.to_vec(), Some(value), Some(inner.2 + positive_value_cost_stipend), @@ -435,14 +436,14 @@ pub fn apply( ) } HEVMCalls::ExpectCall5(inner) => { - let value = inner.1; + let value = inner.1.to_alloy(); // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::zero() { 2300 } else { 0 }; + let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; expect_call( state, - inner.0, + inner.0.to_alloy(), inner.3.to_vec(), Some(value), Some(inner.2 + positive_value_cost_stipend), @@ -452,14 +453,14 @@ pub fn apply( ) } HEVMCalls::ExpectCallMinGas0(inner) => { - let value = inner.1; + let value = inner.1.to_alloy(); // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::zero() { 2300 } else { 0 }; + let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; expect_call( state, - inner.0, + inner.0.to_alloy(), inner.3.to_vec(), Some(value), None, @@ -469,14 +470,14 @@ pub fn apply( ) } HEVMCalls::ExpectCallMinGas1(inner) => { - let value = inner.1; + let value = inner.1.to_alloy(); // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::zero() { 2300 } else { 0 }; + let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; expect_call( state, - inner.0, + inner.0.to_alloy(), inner.3.to_vec(), Some(value), None, @@ -506,7 +507,7 @@ pub fn apply( .to_checked(); data.journaled_state.set_code(inner.0.to_alloy(), code); } - state.mocked_calls.entry(inner.0).or_default().insert( + state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( MockCallDataContext { calldata: inner.1.clone().0.into(), value: None }, MockCallReturnData { data: inner.2.clone().0.into(), @@ -520,8 +521,11 @@ pub fn apply( return Some(Err(err.into())) } - state.mocked_calls.entry(inner.0).or_default().insert( - MockCallDataContext { calldata: inner.2.to_vec().into(), value: Some(inner.1) }, + state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( + MockCallDataContext { + calldata: inner.2.to_vec().into(), + value: Some(inner.1.to_alloy()), + }, MockCallReturnData { data: inner.3.to_vec().into(), ret_type: InstructionResult::Return, @@ -530,7 +534,7 @@ pub fn apply( Ok(Bytes::new()) } HEVMCalls::MockCallRevert0(inner) => { - state.mocked_calls.entry(inner.0).or_default().insert( + state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( MockCallDataContext { calldata: inner.1.to_vec().into(), value: None }, MockCallReturnData { data: inner.2.to_vec().into(), @@ -540,8 +544,11 @@ pub fn apply( Ok(Bytes::new()) } HEVMCalls::MockCallRevert1(inner) => { - state.mocked_calls.entry(inner.0).or_default().insert( - MockCallDataContext { calldata: inner.2.to_vec().into(), value: Some(inner.1) }, + state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( + MockCallDataContext { + calldata: inner.2.to_vec().into(), + value: Some(inner.1.to_alloy()), + }, MockCallReturnData { data: inner.3.to_vec().into(), ret_type: InstructionResult::Revert, diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index ee4b9a0e85273..0ce26a1e5af80 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -1,14 +1,11 @@ use super::{bail, ensure, fmt_err, util::MAGIC_SKIP_BYTES, Cheatcodes, Error, Result}; use crate::{abi::HEVMCalls, executor::inspector::cheatcodes::parse}; -use alloy_primitives::{Bytes, U256 as rU256}; -use ethers::{ - abi::{self, AbiEncode, JsonAbi, ParamType, Token}, - prelude::artifacts::CompactContractBytecode, - types::*, -}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_primitives::{Address, Bytes, B256, I256, U256}; +use ethers::{abi::JsonAbi, prelude::artifacts::CompactContractBytecode}; use foundry_common::{fmt::*, fs, get_artifact_path}; use foundry_config::fs_permissions::FsAccessKind; -use foundry_utils::types::ToEthers; +use foundry_utils::types::ToAlloy; use revm::{Database, EVMData}; use serde::Deserialize; use serde_json::Value; @@ -17,6 +14,7 @@ use std::{ env, path::Path, process::Command, + str::FromStr, time::{SystemTime, UNIX_EPOCH}, }; @@ -47,20 +45,21 @@ fn try_ffi(state: &Cheatcodes, args: &[String]) -> Result { // The stdout might be encoded on valid hex, or it might just be a string, // so we need to determine which it is to avoid improperly encoding later. - let encoded_stdout: Token = if let Ok(hex) = hex::decode(trimmed_stdout) { - Token::Bytes(hex) + let encoded_stdout: DynSolValue = if let Ok(hex) = hex::decode(trimmed_stdout) { + DynSolValue::Bytes(hex) } else { - Token::Bytes(trimmed_stdout.into()) + DynSolValue::Bytes(trimmed_stdout.into()) }; - - let res = abi::encode(&[Token::Tuple(vec![ - Token::Int(exit_code.into()), + let exit_code = I256::from_dec_str(&exit_code.to_string()) + .map_err(|err| fmt_err!("Could not convert exit code: {err}"))?; + let res = DynSolValue::Tuple(vec![ + DynSolValue::Int(exit_code, 256), encoded_stdout, // We can grab the stderr output as-is. - Token::Bytes(output.stderr), - ])]); + DynSolValue::Bytes(output.stderr), + ]); - Ok(res.into()) + Ok(res.abi_encode().into()) } /// Invokes a `Command` with the given args and returns the abi encoded response @@ -91,9 +90,9 @@ fn ffi(state: &Cheatcodes, args: &[String]) -> Result { let output = String::from_utf8(output.stdout)?; let trimmed = output.trim(); if let Ok(hex) = hex::decode(trimmed) { - Ok(abi::encode(&[Token::Bytes(hex)]).into()) + Ok(DynSolValue::Bytes(hex).abi_encode().into()) } else { - Ok(trimmed.encode().into()) + Ok(DynSolValue::String(trimmed.to_owned()).abi_encode().into()) } } @@ -154,7 +153,7 @@ struct HuffArtifact { fn get_code(state: &Cheatcodes, path: &str) -> Result { let bytecode = read_bytecode(state, path)?; if let Some(bin) = bytecode.into_bytecode() { - Ok(bin.0.clone().encode().into()) + Ok(DynSolValue::Bytes(bin.to_vec()).abi_encode().into()) } else { Err(fmt_err!("No bytecode for contract. Is it abstract or unlinked?")) } @@ -164,7 +163,7 @@ fn get_code(state: &Cheatcodes, path: &str) -> Result { fn get_deployed_code(state: &Cheatcodes, path: &str) -> Result { let bytecode = read_bytecode(state, path)?; if let Some(bin) = bytecode.into_deployed_bytecode() { - Ok(bin.0.clone().encode().into()) + Ok(DynSolValue::Bytes(bin.to_vec()).abi_encode().into()) } else { Err(fmt_err!("No deployed bytecode for contract. Is it abstract or unlinked?")) } @@ -195,12 +194,13 @@ fn set_env(key: &str, val: &str) -> Result { } } -fn get_env(key: &str, ty: ParamType, delim: Option<&str>, default: Option) -> Result { +fn get_env(key: &str, ty: DynSolType, delim: Option<&str>, default: Option) -> Result { let val = env::var(key).or_else(|e| { default.ok_or_else(|| { fmt_err!("Failed to get environment variable `{key}` as type `{ty}`: {e}") }) })?; + println!("got val: {}", val); if let Some(d) = delim { parse::parse_array(val.split(d).map(str::trim), &ty) } else { @@ -208,25 +208,25 @@ fn get_env(key: &str, ty: ParamType, delim: Option<&str>, default: Option Result { +pub fn value_to_token(value: &Value) -> Result { match value { - Value::Null => Ok(Token::FixedBytes(vec![0; 32])), - Value::Bool(boolean) => Ok(Token::Bool(*boolean)), + Value::Null => Ok(DynSolValue::FixedBytes(B256::ZERO, 32)), + Value::Bool(boolean) => Ok(DynSolValue::Bool(*boolean)), Value::Array(array) => { let values = array.iter().map(value_to_token).collect::>>()?; - Ok(Token::Array(values)) + Ok(DynSolValue::Array(values)) } value @ Value::Object(_) => { // See: [#3647](https://github.com/foundry-rs/foundry/pull/3647) let ordered_object: BTreeMap = serde_json::from_value(value.clone()).unwrap(); let values = ordered_object.values().map(value_to_token).collect::>>()?; - Ok(Token::Tuple(values)) + Ok(DynSolValue::Tuple(values)) } Value::Number(number) => { if let Some(f) = number.as_f64() { @@ -240,24 +240,29 @@ pub fn value_to_token(value: &Value) -> Result { // to f64. let s = number.to_string(); - // Calling Number::to_string with powers of ten formats the number using - // scientific notation and causes from_dec_str to fail. Using format! with f64 - // keeps the full number representation. - // Example: 100000000000000000000 becomes 1e20 when Number::to_string is - // used. - let fallback_s = format!("{f}"); - - if let Ok(n) = U256::from_dec_str(&s) { - return Ok(Token::Uint(n)) - } - if let Ok(n) = I256::from_dec_str(&s) { - return Ok(Token::Int(n.into_raw())) + // Coerced to scientific notation, so short-ciruit to using fallback. + // This will not have a problem with hex numbers, as for parsing these + // We'd need to prefix this with 0x. + if s.starts_with("1e") { + // Calling Number::to_string with powers of ten formats the number using + // scientific notation and causes from_dec_str to fail. Using format! with + // f64 keeps the full number representation. + // Example: 100000000000000000000 becomes 1e20 when Number::to_string is + // used. + let fallback_s = format!("{f}"); + if let Ok(n) = U256::from_str(&fallback_s) { + return Ok(DynSolValue::Uint(n, 256)) + } + if let Ok(n) = I256::from_dec_str(&fallback_s) { + return Ok(DynSolValue::Int(n, 256)) + } } - if let Ok(n) = U256::from_dec_str(&fallback_s) { - return Ok(Token::Uint(n)) + + if let Ok(n) = U256::from_str(&s) { + return Ok(DynSolValue::Uint(n, 256)) } - if let Ok(n) = I256::from_dec_str(&fallback_s) { - return Ok(Token::Int(n.into_raw())) + if let Ok(n) = I256::from_str(&s) { + return Ok(DynSolValue::Int(n, 256)) } } } @@ -273,12 +278,12 @@ pub fn value_to_token(value: &Value) -> Result { } let bytes = hex::decode(val)?; Ok(match bytes.len() { - 20 => Token::Address(Address::from_slice(&bytes)), - 32 => Token::FixedBytes(bytes), - _ => Token::Bytes(bytes), + 20 => DynSolValue::Address(Address::from_slice(&bytes)), + 32 => DynSolValue::FixedBytes(B256::from_slice(&bytes), 32), + _ => DynSolValue::Bytes(bytes), }) } else { - Ok(Token::String(string.to_owned())) + Ok(DynSolValue::String(string.to_owned())) } } } @@ -294,32 +299,32 @@ fn canonicalize_json_key(key: &str) -> String { } } -/// Encodes a vector of [`Token`] into a vector of bytes. -fn encode_abi_values(values: Vec) -> Vec { +/// Encodes a vector of [`DynSolValue`] into a vector of bytes. +fn encode_abi_values(values: Vec) -> Vec { if values.is_empty() { - abi::encode(&[Token::Bytes(Vec::new())]) + DynSolValue::Bytes(Vec::new()).abi_encode() } else if values.len() == 1 { - abi::encode(&[Token::Bytes(abi::encode(&values))]) + DynSolValue::Bytes(values[0].abi_encode()).abi_encode() } else { - abi::encode(&[Token::Bytes(abi::encode(&[Token::Array(values)]))]) + DynSolValue::Bytes(DynSolValue::Array(values).abi_encode()).abi_encode() } } -/// Parses a vector of [`Value`]s into a vector of [`Token`]s. -fn parse_json_values(values: Vec<&Value>, key: &str) -> Result> { +/// Parses a vector of [`Value`]s into a vector of [`DynSolValue`]s. +fn parse_json_values(values: Vec<&Value>, key: &str) -> Result> { values .iter() .map(|inner| { value_to_token(inner).map_err(|err| fmt_err!("Failed to parse key \"{key}\": {err}")) }) - .collect::>>() + .collect::>>() } /// Parses a JSON and returns a single value, an array or an entire JSON object encoded as tuple. /// As the JSON object is parsed serially, with the keys ordered alphabetically, they must be /// deserialized in the same order. That means that the solidity `struct` should order it's fields /// alphabetically and not by efficient packing or some other taxonomy. -fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { +fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { let json = serde_json::from_str(json_str).map_err(|err| fmt_err!("Failed to parse JSON: {err}"))?; match key { @@ -335,15 +340,14 @@ fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { } _ => { let values = jsonpath_lib::select(&json, &canonicalize_json_key(key))?; - // values is an array of items. Depending on the JsonPath key, they // can be many or a single item. An item can be a single value or // an entire JSON object. if let Some(coercion_type) = coerce { ensure!( - values.iter().all(|value| !value.is_object()), - "You can only coerce values or arrays, not JSON objects. The key '{key}' returns an object", - ); + values.iter().all(|value| !value.is_object()), + "You can only coerce values or arrays, not JSON objects. The key '{key}' returns an object", + ); ensure!(!values.is_empty(), "No matching value or array found for key {key}"); @@ -361,7 +365,6 @@ fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { } let res = parse_json_values(values, key)?; - // encode the bytes as the 'bytes' solidity type let abi_encoded = encode_abi_values(res); Ok(abi_encoded.into()) @@ -391,11 +394,11 @@ fn parse_json_keys(json_str: &str, key: &str) -> Result { .as_object() .ok_or(eyre::eyre!("Unexpected error while extracting JSON-object"))? .keys() - .map(|key| Token::String(key.to_owned())) - .collect::>(); + .map(|key| DynSolValue::String(key.to_owned())) + .collect::>(); // encode the bytes as the 'bytes' solidity type - let abi_encoded = abi::encode(&[Token::Array(res)]); + let abi_encoded = DynSolValue::Array(res).abi_encode(); Ok(abi_encoded.into()) } @@ -436,7 +439,7 @@ fn serialize_json( let stringified = serde_json::to_string(&json) .map_err(|err| fmt_err!("Failed to stringify hashmap: {err}"))?; - Ok(abi::encode(&[Token::String(stringified)]).into()) + Ok(DynSolValue::String(stringified).abi_encode().into()) } /// Converts an array to it's stringified version, adding the appropriate quotes around it's @@ -506,13 +509,13 @@ fn key_exists(json_str: &str, key: &str) -> Result { let json: Value = serde_json::from_str(json_str).map_err(|e| format!("Could not convert to JSON: {e}"))?; let values = jsonpath_lib::select(&json, &canonicalize_json_key(key))?; - let exists = parse::parse(&(!values.is_empty()).to_string(), &ParamType::Bool)?; + let exists = parse::parse(&(!values.is_empty()).to_string(), &DynSolType::Bool)?; Ok(exists) } /// Sleeps for a given amount of milliseconds. fn sleep(milliseconds: &U256) -> Result { - let sleep_duration = std::time::Duration::from_millis(milliseconds.as_u64()); + let sleep_duration = std::time::Duration::from_millis(milliseconds.to::()); std::thread::sleep(sleep_duration); Ok(Default::default()) @@ -525,7 +528,7 @@ fn duration_since_epoch() -> Result { .duration_since(UNIX_EPOCH) .expect("Failed getting timestamp in unixTime cheatcode"); let millis = difference.as_millis(); - Ok(rU256::from(millis).to_ethers().encode().into()) + Ok(DynSolValue::Uint(U256::from(millis), 256).abi_encode().into()) } /// Skip the current test, by returning a magic value that will be checked by the test runner. @@ -568,81 +571,83 @@ pub fn apply( HEVMCalls::GetCode(inner) => get_code(state, &inner.0), HEVMCalls::GetDeployedCode(inner) => get_deployed_code(state, &inner.0), HEVMCalls::SetEnv(inner) => set_env(&inner.0, &inner.1), - HEVMCalls::EnvBool0(inner) => get_env(&inner.0, ParamType::Bool, None, None), - HEVMCalls::EnvUint0(inner) => get_env(&inner.0, ParamType::Uint(256), None, None), - HEVMCalls::EnvInt0(inner) => get_env(&inner.0, ParamType::Int(256), None, None), - HEVMCalls::EnvAddress0(inner) => get_env(&inner.0, ParamType::Address, None, None), - HEVMCalls::EnvBytes320(inner) => get_env(&inner.0, ParamType::FixedBytes(32), None, None), - HEVMCalls::EnvString0(inner) => get_env(&inner.0, ParamType::String, None, None), - HEVMCalls::EnvBytes0(inner) => get_env(&inner.0, ParamType::Bytes, None, None), - HEVMCalls::EnvBool1(inner) => get_env(&inner.0, ParamType::Bool, Some(&inner.1), None), - HEVMCalls::EnvUint1(inner) => get_env(&inner.0, ParamType::Uint(256), Some(&inner.1), None), - HEVMCalls::EnvInt1(inner) => get_env(&inner.0, ParamType::Int(256), Some(&inner.1), None), + HEVMCalls::EnvBool0(inner) => get_env(&inner.0, DynSolType::Bool, None, None), + HEVMCalls::EnvUint0(inner) => get_env(&inner.0, DynSolType::Uint(256), None, None), + HEVMCalls::EnvInt0(inner) => get_env(&inner.0, DynSolType::Int(256), None, None), + HEVMCalls::EnvAddress0(inner) => get_env(&inner.0, DynSolType::Address, None, None), + HEVMCalls::EnvBytes320(inner) => get_env(&inner.0, DynSolType::FixedBytes(32), None, None), + HEVMCalls::EnvString0(inner) => get_env(&inner.0, DynSolType::String, None, None), + HEVMCalls::EnvBytes0(inner) => get_env(&inner.0, DynSolType::Bytes, None, None), + HEVMCalls::EnvBool1(inner) => get_env(&inner.0, DynSolType::Bool, Some(&inner.1), None), + HEVMCalls::EnvUint1(inner) => { + get_env(&inner.0, DynSolType::Uint(256), Some(&inner.1), None) + } + HEVMCalls::EnvInt1(inner) => get_env(&inner.0, DynSolType::Int(256), Some(&inner.1), None), HEVMCalls::EnvAddress1(inner) => { - get_env(&inner.0, ParamType::Address, Some(&inner.1), None) + get_env(&inner.0, DynSolType::Address, Some(&inner.1), None) } HEVMCalls::EnvBytes321(inner) => { - get_env(&inner.0, ParamType::FixedBytes(32), Some(&inner.1), None) + get_env(&inner.0, DynSolType::FixedBytes(32), Some(&inner.1), None) } - HEVMCalls::EnvString1(inner) => get_env(&inner.0, ParamType::String, Some(&inner.1), None), - HEVMCalls::EnvBytes1(inner) => get_env(&inner.0, ParamType::Bytes, Some(&inner.1), None), + HEVMCalls::EnvString1(inner) => get_env(&inner.0, DynSolType::String, Some(&inner.1), None), + HEVMCalls::EnvBytes1(inner) => get_env(&inner.0, DynSolType::Bytes, Some(&inner.1), None), HEVMCalls::EnvOr0(inner) => { - get_env(&inner.0, ParamType::Bool, None, Some(inner.1.to_string())) + get_env(&inner.0, DynSolType::Bool, None, Some(inner.1.to_string())) } HEVMCalls::EnvOr1(inner) => { - get_env(&inner.0, ParamType::Uint(256), None, Some(inner.1.to_string())) + get_env(&inner.0, DynSolType::Uint(256), None, Some(inner.1.to_string())) } HEVMCalls::EnvOr2(inner) => { - get_env(&inner.0, ParamType::Int(256), None, Some(inner.1.to_string())) + get_env(&inner.0, DynSolType::Int(256), None, Some(inner.1.to_string())) } HEVMCalls::EnvOr3(inner) => { - get_env(&inner.0, ParamType::Address, None, Some(hex::encode(inner.1))) + get_env(&inner.0, DynSolType::Address, None, Some(hex::encode(inner.1))) } HEVMCalls::EnvOr4(inner) => { - get_env(&inner.0, ParamType::FixedBytes(32), None, Some(hex::encode(inner.1))) + get_env(&inner.0, DynSolType::FixedBytes(32), None, Some(hex::encode(inner.1))) } HEVMCalls::EnvOr5(inner) => { - get_env(&inner.0, ParamType::String, None, Some(inner.1.to_string())) + get_env(&inner.0, DynSolType::String, None, Some(inner.1.to_string())) } HEVMCalls::EnvOr6(inner) => { - get_env(&inner.0, ParamType::Bytes, None, Some(hex::encode(&inner.1))) + get_env(&inner.0, DynSolType::Bytes, None, Some(hex::encode(&inner.1))) } HEVMCalls::EnvOr7(inner) => get_env( &inner.0, - ParamType::Bool, + DynSolType::Bool, Some(&inner.1), Some(inner.2.iter().map(|v| v.to_string()).collect::>().join(&inner.1)), ), HEVMCalls::EnvOr8(inner) => get_env( &inner.0, - ParamType::Uint(256), + DynSolType::Uint(256), Some(&inner.1), Some(inner.2.iter().map(|v| v.to_string()).collect::>().join(&inner.1)), ), HEVMCalls::EnvOr9(inner) => get_env( &inner.0, - ParamType::Int(256), + DynSolType::Int(256), Some(&inner.1), Some(inner.2.iter().map(|v| v.to_string()).collect::>().join(&inner.1)), ), HEVMCalls::EnvOr10(inner) => get_env( &inner.0, - ParamType::Address, + DynSolType::Address, Some(&inner.1), Some(inner.2.iter().map(hex::encode).collect::>().join(&inner.1)), ), HEVMCalls::EnvOr11(inner) => get_env( &inner.0, - ParamType::FixedBytes(32), + DynSolType::FixedBytes(32), Some(&inner.1), Some(inner.2.iter().map(hex::encode).collect::>().join(&inner.1)), ), HEVMCalls::EnvOr12(inner) => { - get_env(&inner.0, ParamType::String, Some(&inner.1), Some(inner.2.join(&inner.1))) + get_env(&inner.0, DynSolType::String, Some(&inner.1), Some(inner.2.join(&inner.1))) } HEVMCalls::EnvOr13(inner) => get_env( &inner.0, - ParamType::Bytes, + DynSolType::Bytes, Some(&inner.1), Some(inner.2.iter().map(hex::encode).collect::>().join(&inner.1)), ), @@ -651,42 +656,44 @@ pub fn apply( // "$" is the JSONPath key for the root of the object HEVMCalls::ParseJson0(inner) => parse_json(&inner.0, "$", None), HEVMCalls::ParseJson1(inner) => parse_json(&inner.0, &inner.1, None), - HEVMCalls::ParseJsonBool(inner) => parse_json(&inner.0, &inner.1, Some(ParamType::Bool)), + HEVMCalls::ParseJsonBool(inner) => parse_json(&inner.0, &inner.1, Some(DynSolType::Bool)), HEVMCalls::ParseJsonKeys(inner) => parse_json_keys(&inner.0, &inner.1), HEVMCalls::ParseJsonBoolArray(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::Bool)) + parse_json(&inner.0, &inner.1, Some(DynSolType::Bool)) } HEVMCalls::ParseJsonUint(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::Uint(256))) + parse_json(&inner.0, &inner.1, Some(DynSolType::Uint(256))) } HEVMCalls::ParseJsonUintArray(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::Uint(256))) + parse_json(&inner.0, &inner.1, Some(DynSolType::Uint(256))) + } + HEVMCalls::ParseJsonInt(inner) => { + parse_json(&inner.0, &inner.1, Some(DynSolType::Int(256))) } - HEVMCalls::ParseJsonInt(inner) => parse_json(&inner.0, &inner.1, Some(ParamType::Int(256))), HEVMCalls::ParseJsonIntArray(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::Int(256))) + parse_json(&inner.0, &inner.1, Some(DynSolType::Int(256))) } HEVMCalls::ParseJsonString(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::String)) + parse_json(&inner.0, &inner.1, Some(DynSolType::String)) } HEVMCalls::ParseJsonStringArray(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::String)) + parse_json(&inner.0, &inner.1, Some(DynSolType::String)) } HEVMCalls::ParseJsonAddress(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::Address)) + parse_json(&inner.0, &inner.1, Some(DynSolType::Address)) } HEVMCalls::ParseJsonAddressArray(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::Address)) + parse_json(&inner.0, &inner.1, Some(DynSolType::Address)) } - HEVMCalls::ParseJsonBytes(inner) => parse_json(&inner.0, &inner.1, Some(ParamType::Bytes)), + HEVMCalls::ParseJsonBytes(inner) => parse_json(&inner.0, &inner.1, Some(DynSolType::Bytes)), HEVMCalls::ParseJsonBytesArray(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::Bytes)) + parse_json(&inner.0, &inner.1, Some(DynSolType::Bytes)) } HEVMCalls::ParseJsonBytes32(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::FixedBytes(32))) + parse_json(&inner.0, &inner.1, Some(DynSolType::FixedBytes(32))) } HEVMCalls::ParseJsonBytes32Array(inner) => { - parse_json(&inner.0, &inner.1, Some(ParamType::FixedBytes(32))) + parse_json(&inner.0, &inner.1, Some(DynSolType::FixedBytes(32))) } HEVMCalls::SerializeJson(inner) => serialize_json(state, &inner.0, None, &inner.1.pretty()), HEVMCalls::SerializeBool0(inner) => { @@ -731,7 +738,7 @@ pub fn apply( HEVMCalls::SerializeBytes1(inner) => { serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) } - HEVMCalls::Sleep(inner) => sleep(&inner.0), + HEVMCalls::Sleep(inner) => sleep(&inner.0.to_alloy()), HEVMCalls::UnixTime(_) => duration_since_epoch(), HEVMCalls::WriteJson0(inner) => write_json(state, &inner.0, &inner.1, None), HEVMCalls::WriteJson1(inner) => write_json(state, &inner.0, &inner.1, Some(&inner.2)), diff --git a/crates/evm/src/executor/inspector/cheatcodes/fork.rs b/crates/evm/src/executor/inspector/cheatcodes/fork.rs index a29bca651bf50..b6c38cd0ec650 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fork.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fork.rs @@ -6,15 +6,13 @@ use crate::{ }, utils::RuntimeOrHandle, }; +use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Bytes, B256, U256}; -use ethers::{ - abi::{self, AbiEncode, Token, Tokenizable, Tokenize}, - providers::Middleware, - types::{Filter, U256 as eU256}, -}; +use ethers::{providers::Middleware, types::Filter}; use foundry_abi::hevm::{EthGetLogsCall, RpcCall}; use foundry_common::ProviderBuilder; use foundry_utils::types::{ToAlloy, ToEthers}; +use itertools::Itertools; use revm::EVMData; use serde_json::Value; @@ -67,7 +65,7 @@ pub fn apply( Ok(Bytes::new()) } HEVMCalls::IsPersistent(acc) => { - Ok(data.db.is_persistent(&acc.0.to_alloy()).encode().into()) + Ok(DynSolValue::Bool(data.db.is_persistent(&acc.0.to_alloy())).abi_encode().into()) } HEVMCalls::RevokePersistent0(acc) => { data.db.remove_persistent_account(&acc.0.to_alloy()); @@ -82,7 +80,7 @@ pub fn apply( HEVMCalls::ActiveFork(_) => data .db .active_fork_id() - .map(|id| id.to_ethers().encode().into()) + .map(|id| DynSolValue::Uint(id, 256).abi_encode().into()) .ok_or_else(|| fmt_err!("No active fork")), HEVMCalls::RollFork0(fork) => data .db @@ -114,7 +112,9 @@ pub fn apply( ) .map(empty) .map_err(Into::into), - HEVMCalls::RpcUrl(rpc) => state.config.get_rpc_url(&rpc.0).map(|url| url.encode().into()), + HEVMCalls::RpcUrl(rpc) => { + state.config.get_rpc_url(&rpc.0).map(|url| DynSolValue::String(url).abi_encode().into()) + } HEVMCalls::RpcUrls(_) => { let mut urls = Vec::with_capacity(state.config.rpc_endpoints.len()); for alias in state.config.rpc_endpoints.keys().cloned() { @@ -125,7 +125,18 @@ pub fn apply( Err(err) => return Some(Err(err)), } } - Ok(urls.encode().into()) + Ok(DynSolValue::Array( + urls.into_iter() + .map(|t| { + DynSolValue::FixedArray(vec![ + DynSolValue::String(t[0].clone()), + DynSolValue::String(t[1].clone()), + ]) + }) + .collect_vec(), + ) + .abi_encode() + .into()) } HEVMCalls::RpcUrlStructs(_) => { let mut urls = Vec::with_capacity(state.config.rpc_endpoints.len()); @@ -137,7 +148,17 @@ pub fn apply( Err(err) => return Some(Err(err)), } } - Ok(urls.encode().into()) + let urls = DynSolValue::Array( + urls.into_iter() + .map(|u| { + DynSolValue::Tuple(vec![ + DynSolValue::String(u[0].clone()), + DynSolValue::String(u[1].clone()), + ]) + }) + .collect_vec(), + ); + Ok(urls.abi_encode().into()) } HEVMCalls::AllowCheatcodes(addr) => { data.db.allow_cheatcode_access(addr.0.to_alloy()); @@ -199,7 +220,7 @@ fn create_select_fork( let fork = create_fork_request(state, url_or_alias, block, data)?; let id = data.db.create_select_fork(fork, data.env, &mut data.journaled_state)?; - Ok(id.to_ethers().encode().into()) + Ok(DynSolValue::Uint(id, 256).abi_encode().into()) } /// Creates a new fork @@ -211,7 +232,7 @@ fn create_fork( ) -> Result { let fork = create_fork_request(state, url_or_alias, block, data)?; let id = data.db.create_fork(fork)?; - Ok(id.to_ethers().encode().into()) + Ok(DynSolValue::Uint(id, 256).abi_encode().into()) } /// Creates and then also selects the new fork at the given transaction fn create_select_fork_at_transaction( @@ -234,7 +255,7 @@ fn create_select_fork_at_transaction( &mut data.journaled_state, transaction, )?; - Ok(id.to_ethers().encode().into()) + Ok(DynSolValue::Uint(id, 256).abi_encode().into()) } /// Creates a new fork at the given transaction @@ -246,7 +267,7 @@ fn create_fork_at_transaction( ) -> Result { let fork = create_fork_request(state, url_or_alias, None, data)?; let id = data.db.create_fork_at_transaction(fork, transaction)?; - Ok(id.to_ethers().encode().into()) + Ok(DynSolValue::Uint(id, 256).abi_encode().into()) } /// Creates the request object for a new fork request @@ -285,10 +306,10 @@ fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> R Filter::new().address(inner.2).from_block(inner.0.as_u64()).to_block(inner.1.as_u64()); for (i, item) in inner.3.iter().enumerate() { match i { - 0 => filter = filter.topic0(eU256::from(item)), - 1 => filter = filter.topic1(eU256::from(item)), - 2 => filter = filter.topic2(eU256::from(item)), - 3 => filter = filter.topic3(eU256::from(item)), + 0 => filter = filter.topic0(U256::from_be_bytes(item.to_owned()).to_ethers()), + 1 => filter = filter.topic1(U256::from_be_bytes(item.to_owned()).to_ethers()), + 2 => filter = filter.topic2(U256::from_be_bytes(item.to_owned()).to_ethers()), + 3 => filter = filter.topic3(U256::from_be_bytes(item.to_owned()).to_ethers()), _ => return Err(fmt_err!("Topics array should be less than 4 elements")), }; } @@ -298,49 +319,75 @@ fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> R .map_err(|_| fmt_err!("Error in calling eth_getLogs"))?; if logs.is_empty() { - let empty: Bytes = abi::encode(&[Token::Array(vec![])]).into(); + let empty: Bytes = DynSolValue::Array(vec![]).abi_encode().into(); return Ok(empty) } - let result = abi::encode( - &logs - .iter() + let result = DynSolValue::Array( + logs.iter() .map(|entry| { - Token::Tuple(vec![ - entry.address.into_token(), - entry.topics.clone().into_token(), - Token::Bytes(entry.data.to_vec()), - entry - .block_number - .expect("eth_getLogs response should include block_number field") - .as_u64() - .into_token(), - entry - .transaction_hash - .expect("eth_getLogs response should include transaction_hash field") - .into_token(), - entry - .transaction_index - .expect("eth_getLogs response should include transaction_index field") - .as_u64() - .into_token(), - entry - .block_hash - .expect("eth_getLogs response should include block_hash field") - .into_token(), - entry - .log_index - .expect("eth_getLogs response should include log_index field") - .into_token(), - entry - .removed - .expect("eth_getLogs response should include removed field") - .into_token(), + DynSolValue::Tuple(vec![ + DynSolValue::Address(entry.address.to_alloy()), + DynSolValue::Array( + entry + .topics + .clone() + .into_iter() + .map(|h| DynSolValue::FixedBytes(h.to_alloy(), 32)) + .collect_vec(), + ), + DynSolValue::Bytes(entry.data.0.clone().into()), + DynSolValue::Uint( + U256::from( + entry + .block_number + .expect("eth_getLogs response should include block_number field") + .to_alloy(), + ), + 32, + ), + DynSolValue::FixedBytes( + entry + .transaction_hash + .expect("eth_getLogs response should include transaction_hash field") + .to_alloy(), + 32, + ), + DynSolValue::Uint( + U256::from( + entry + .transaction_index + .expect( + "eth_getLogs response should include transaction_index field", + ) + .to_alloy(), + ), + 32, + ), + DynSolValue::FixedBytes( + entry + .block_hash + .expect("eth_getLogs response should include block_hash field") + .to_alloy(), + 32, + ), + DynSolValue::Uint( + U256::from( + entry + .log_index + .expect("eth_getLogs response should include log_index field") + .to_alloy(), + ), + 32, + ), + DynSolValue::Bool( + entry.removed.expect("eth_getLogs response should include removed field"), + ), ]) }) - .collect::>() - .into_tokens(), + .collect::>(), ) + .abi_encode() .into(); Ok(result) } @@ -360,12 +407,5 @@ fn rpc(data: &EVMData, inner: &RpcCall) -> Result { let result_as_tokens = value_to_token(&result).map_err(|err| fmt_err!("Failed to parse result: {err}"))?; - let abi_encoded: Vec = match result_as_tokens { - Token::Tuple(vec) | Token::Array(vec) | Token::FixedArray(vec) => abi::encode(&vec), - _ => { - let vec = vec![result_as_tokens]; - abi::encode(&vec) - } - }; - Ok(abi_encoded.into()) + Ok(result_as_tokens.abi_encode().into()) } diff --git a/crates/evm/src/executor/inspector/cheatcodes/fs.rs b/crates/evm/src/executor/inspector/cheatcodes/fs.rs index 19a85d5f4227a..e59d08a7344f8 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fs.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fs.rs @@ -1,9 +1,10 @@ use super::{Cheatcodes, Result}; use crate::abi::hevm::{DirEntry, FsMetadata, HEVMCalls}; -use alloy_primitives::Bytes; -use ethers::abi::{self, AbiEncode, Token, Tokenize}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{Bytes, U256}; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; +use foundry_utils::types::ToAlloy; use std::{ io::{BufRead, BufReader, Write}, path::Path, @@ -13,19 +14,19 @@ use walkdir::WalkDir; fn project_root(state: &Cheatcodes) -> Result { let root = state.config.root.display().to_string(); - Ok(abi::encode(&[Token::String(root)]).into()) + Ok(DynSolValue::String(root).abi_encode().into()) } fn read_file(state: &Cheatcodes, path: impl AsRef) -> Result { let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; let data = fs::read_to_string(path)?; - Ok(abi::encode(&[Token::String(data)]).into()) + Ok(DynSolValue::String(data).abi_encode().into()) } fn read_file_binary(state: &Cheatcodes, path: impl AsRef) -> Result { let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; let data = fs::read(path)?; - Ok(abi::encode(&[Token::Bytes(data)]).into()) + Ok(DynSolValue::Bytes(data).abi_encode().into()) } fn read_line(state: &mut Cheatcodes, path: impl AsRef) -> Result { @@ -49,7 +50,7 @@ fn read_line(state: &mut Cheatcodes, path: impl AsRef) -> Result { } } - Ok(abi::encode(&[Token::String(line)]).into()) + Ok(DynSolValue::String(line).abi_encode().into()) } /// Writes `content` to `path`. @@ -97,7 +98,7 @@ fn copy_file(state: &Cheatcodes, from: impl AsRef, to: impl AsRef) - state.config.ensure_not_foundry_toml(&to)?; let n = fs::copy(from, to)?; - Ok(abi::encode(&[Token::Uint(n.into())]).into()) + Ok(DynSolValue::Uint(U256::from(n), 256).abi_encode().into()) } fn close_file(state: &mut Cheatcodes, path: impl AsRef) -> Result { @@ -174,7 +175,7 @@ fn read_dir( follow_links: bool, ) -> Result { let root = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - let paths: Vec = WalkDir::new(root) + let paths: Vec = WalkDir::new(root) .min_depth(1) .max_depth(max_depth.try_into()?) .follow_links(follow_links) @@ -199,10 +200,16 @@ fn read_dir( is_symlink: false, }, }; - Token::Tuple(entry.into_tokens()) + DynSolValue::Tuple(vec![ + DynSolValue::String(entry.error_message), + DynSolValue::String(entry.path), + DynSolValue::Uint(U256::from(entry.depth), 8), + DynSolValue::Bool(entry.is_dir), + DynSolValue::Bool(entry.is_symlink), + ]) }) .collect(); - Ok(abi::encode(&[Token::Array(paths)]).into()) + Ok(DynSolValue::Array(paths).abi_encode().into()) } /// Reads a symbolic link, returning the path that the link points to. @@ -219,7 +226,7 @@ fn read_link(state: &Cheatcodes, path: impl AsRef) -> Result { let target = fs::read_link(path)?; - Ok(abi::encode(&[Token::String(target.display().to_string())]).into()) + Ok(DynSolValue::String(target.display().to_string()).abi_encode().into()) } /// Gets the metadata of a file/directory @@ -245,7 +252,17 @@ fn fs_metadata(state: &Cheatcodes, path: impl AsRef) -> Result { accessed: accessed.into(), created: created.into(), }; - Ok(metadata.encode().into()) + Ok(DynSolValue::Tuple(vec![ + DynSolValue::Bool(metadata.is_dir), + DynSolValue::Bool(metadata.is_symlink), + DynSolValue::Uint(U256::from(metadata.length.to_alloy()), 256), + DynSolValue::Bool(metadata.read_only), + DynSolValue::Uint(U256::from(metadata.modified.to_alloy()), 256), + DynSolValue::Uint(U256::from(metadata.accessed.to_alloy()), 256), + DynSolValue::Uint(U256::from(metadata.created.to_alloy()), 256), + ]) + .abi_encode() + .into()) } /// Verifies if a given path points to a valid entity @@ -258,7 +275,7 @@ fn fs_metadata(state: &Cheatcodes, path: impl AsRef) -> Result { fn exists(state: &Cheatcodes, path: impl AsRef) -> Result { let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - Ok(abi::encode(&[Token::Bool(path.exists())]).into()) + Ok(DynSolValue::Bool(path.exists()).abi_encode().into()) } /// Verifies if a given path exists on disk and points at a regular file @@ -271,7 +288,7 @@ fn exists(state: &Cheatcodes, path: impl AsRef) -> Result { fn is_file(state: &Cheatcodes, path: impl AsRef) -> Result { let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - Ok(abi::encode(&[Token::Bool(path.is_file())]).into()) + Ok(DynSolValue::Bool(path.is_file()).abi_encode().into()) } /// Verifies if a given path exists on disk and points at a directory @@ -284,7 +301,7 @@ fn is_file(state: &Cheatcodes, path: impl AsRef) -> Result { fn is_dir(state: &Cheatcodes, path: impl AsRef) -> Result { let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - Ok(abi::encode(&[Token::Bool(path.is_dir())]).into()) + Ok(DynSolValue::Bool(path.is_dir()).abi_encode().into()) } #[instrument(level = "error", name = "fs", target = "evm::cheatcodes", skip_all)] diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs index 777d503813f12..2f881ddb78378 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mapping.rs @@ -1,11 +1,6 @@ use super::Cheatcodes; -use alloy_primitives::Bytes; -use ethers::{ - abi::{self, Token}, - types::{Address, U256}, - utils::keccak256, -}; -use foundry_utils::types::ToEthers; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{keccak256, Address, Bytes, U256}; use revm::{ interpreter::{opcode, Interpreter}, Database, EVMData, @@ -55,7 +50,7 @@ pub fn get_mapping_length(state: &Cheatcodes, address: Address, slot: U256) -> B } None => 0, }; - abi::encode(&[Token::Uint(result.into())]).into() + DynSolValue::Uint(U256::from(result), 256).abi_encode().into() } pub fn get_mapping_slot_at(state: &Cheatcodes, address: Address, slot: U256, index: U256) -> Bytes { @@ -63,12 +58,12 @@ pub fn get_mapping_slot_at(state: &Cheatcodes, address: Address, slot: U256, ind Some(mapping_slots) => mapping_slots .children .get(&slot) - .and_then(|set| set.get(index.as_usize())) + .and_then(|set| set.get(index.to::())) .copied() .unwrap_or_default(), - None => 0.into(), + None => U256::from(0), }; - abi::encode(&[Token::Uint(result)]).into() + DynSolValue::FixedBytes(U256::from(result).into(), 256).abi_encode().into() } pub fn get_mapping_key_and_parent(state: &Cheatcodes, address: Address, slot: U256) -> Bytes { @@ -78,12 +73,18 @@ pub fn get_mapping_key_and_parent(state: &Cheatcodes, address: Address, slot: U2 Some(key) => (true, *key, mapping_slots.parent_slots[&slot]), None => match mapping_slots.seen_sha3.get(&slot).copied() { Some(maybe_info) => (true, maybe_info.0, maybe_info.1), - None => (false, U256::zero(), U256::zero()), + None => (false, U256::ZERO, U256::ZERO), }, }, - None => (false, U256::zero(), U256::zero()), + None => (false, U256::ZERO, U256::ZERO), }; - abi::encode(&[Token::Bool(found), Token::Uint(key), Token::Uint(parent)]).into() + DynSolValue::Tuple(vec![ + DynSolValue::Bool(found), + DynSolValue::FixedBytes(key.into(), 256), + DynSolValue::FixedBytes(parent.into(), 256), + ]) + .abi_encode() + .into() } pub fn on_evm_step( @@ -96,23 +97,20 @@ pub fn on_evm_step( if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) { let address = interpreter.contract.address; let offset = interpreter.stack.peek(0).expect("stack size > 1").to::(); - let low = U256::from(interpreter.memory.slice(offset, 0x20)); - let high = U256::from(interpreter.memory.slice(offset + 0x20, 0x20)); - let result = U256::from(keccak256(interpreter.memory.slice(offset, 0x40))); + let low = U256::try_from_be_slice(interpreter.memory.slice(offset, 0x20)) + .expect("This should be a 32 byte slice and therefore should not fail."); + let high = U256::try_from_be_slice(interpreter.memory.slice(offset + 0x20, 0x20)) + .expect("This should be a 32 byte slice and therefore should not fail."); + let result = + U256::from_be_bytes(keccak256(interpreter.memory.slice(offset, 0x40)).0); - mapping_slots - .entry(address.to_ethers()) - .or_default() - .seen_sha3 - .insert(result, (low, high)); + mapping_slots.entry(address).or_default().seen_sha3.insert(result, (low, high)); } } opcode::SSTORE => { - if let Some(mapping_slots) = - mapping_slots.get_mut(&interpreter.contract.address.to_ethers()) - { + if let Some(mapping_slots) = mapping_slots.get_mut(&interpreter.contract.address) { if let Ok(slot) = interpreter.stack.peek(0) { - mapping_slots.insert(slot.to_ethers()); + mapping_slots.insert(slot); } } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 2cc77a4c2720d..81c8c3b80fdf4 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -11,19 +11,15 @@ use crate::{ HARDHAT_CONSOLE_ADDRESS, }, }; -use alloy_primitives::{Address as rAddress, Bytes, B256}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; use ethers::{ - abi::{AbiDecode, AbiEncode, RawLog}, + abi::AbiDecode, signers::LocalWallet, - types::{ - transaction::eip2718::TypedTransaction, Address, NameOrAddress, TransactionRequest, U256, - }, + types::{transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest}, }; use foundry_common::evm::Breakpoints; -use foundry_utils::{ - error::SolError, - types::{ToAlloy, ToEthers}, -}; +use foundry_utils::{error::SolError, types::ToEthers}; use itertools::Itertools; use revm::{ interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, @@ -42,7 +38,7 @@ use std::{ /// Cheatcodes related to the execution environment. mod env; -pub use env::{Log, Prank, RecordAccess}; +pub use env::{Prank, RecordAccess, RecordedLog}; /// Assertion helpers (such as `expectEmit`) mod expect; pub use expect::{ @@ -222,7 +218,7 @@ impl Cheatcodes { // ensure the caller is allowed to execute cheatcodes, // but only if the backend is in forking mode - data.db.ensure_cheatcode_access_forking_mode(caller.to_alloy())?; + data.db.ensure_cheatcode_access_forking_mode(caller)?; let opt = env::apply(self, data, caller, &decoded) .transpose() @@ -287,8 +283,8 @@ impl Cheatcodes { // This will prevent overflow issues in revm's [`JournaledState::journal_revert`] routine // which rolls back any transfers. while let Some(record) = self.eth_deals.pop() { - if let Some(acc) = data.journaled_state.state.get_mut(&record.address.to_alloy()) { - acc.info.balance = record.old_balance.to_alloy(); + if let Some(acc) = data.journaled_state.state.get_mut(&record.address) { + acc.info.balance = record.old_balance; } } } @@ -307,7 +303,7 @@ impl Inspector for Cheatcodes { data.env.block = block; } if let Some(gas_price) = self.gas_price.take() { - data.env.tx.gas_price = gas_price.to_alloy(); + data.env.tx.gas_price = gas_price; } InstructionResult::Continue @@ -384,9 +380,9 @@ impl Inspector for Cheatcodes { let key = try_or_continue!(interpreter.stack().peek(0)); storage_accesses .reads - .entry(interpreter.contract().address.to_ethers()) + .entry(interpreter.contract().address) .or_insert_with(Vec::new) - .push(key.to_ethers()); + .push(key); } opcode::SSTORE => { let key = try_or_continue!(interpreter.stack().peek(0)); @@ -394,14 +390,14 @@ impl Inspector for Cheatcodes { // An SSTORE does an SLOAD internally storage_accesses .reads - .entry(interpreter.contract().address.to_ethers()) + .entry(interpreter.contract().address) .or_insert_with(Vec::new) - .push(key.to_ethers()); + .push(key); storage_accesses .writes - .entry(interpreter.contract().address.to_ethers()) + .entry(interpreter.contract().address) .or_insert_with(Vec::new) - .push(key.to_ethers()); + .push(key); } _ => (), } @@ -541,29 +537,26 @@ impl Inspector for Cheatcodes { fn log( &mut self, _: &mut EVMData<'_, DB>, - address: &rAddress, + address: &Address, topics: &[B256], data: &alloy_primitives::Bytes, ) { if !self.expected_emits.is_empty() { handle_expect_emit( self, - RawLog { - topics: topics.iter().copied().map(|t| t.to_ethers()).collect_vec(), - data: data.to_vec(), - }, - &address.to_ethers(), + RawLog::new_unchecked(topics.iter().copied().collect_vec(), data.to_vec().into()), + address, ); } // Stores this log if `recordLogs` has been called if let Some(storage_recorded_logs) = &mut self.recorded_logs { - storage_recorded_logs.entries.push(Log { - emitter: address.to_ethers(), - inner: RawLog { - topics: topics.iter().copied().map(|t| t.to_ethers()).collect_vec(), - data: data.to_vec(), - }, + storage_recorded_logs.entries.push(RecordedLog { + emitter: *address, + inner: RawLog::new_unchecked( + topics.iter().copied().collect_vec(), + data.to_vec().into(), + ), }); } } @@ -575,7 +568,7 @@ impl Inspector for Cheatcodes { ) -> (InstructionResult, Gas, alloy_primitives::Bytes) { if call.contract == CHEATCODE_ADDRESS { let gas = Gas::new(call.gas_limit); - match self.apply_cheatcode(data, call.context.caller.to_ethers(), call) { + match self.apply_cheatcode(data, call.context.caller, call) { Ok(retdata) => (InstructionResult::Return, gas, alloy_primitives::Bytes(retdata.0)), Err(err) => { (InstructionResult::Revert, gas, alloy_primitives::Bytes(err.encode_error().0)) @@ -585,9 +578,7 @@ impl Inspector for Cheatcodes { // Handle expected calls // Grab the different calldatas expected. - if let Some(expected_calls_for_target) = - self.expected_calls.get_mut(&(call.contract.to_ethers())) - { + if let Some(expected_calls_for_target) = self.expected_calls.get_mut(&(call.contract)) { // Match every partial/full calldata for (calldata, (expected, actual_count)) in expected_calls_for_target.iter_mut() { // Increment actual times seen if... @@ -598,7 +589,7 @@ impl Inspector for Cheatcodes { // The value matches, if provided expected .value - .map_or(true, |value| value == call.transfer.value.to_ethers()) && + .map_or(true, |value| value == call.transfer.value) && // The gas matches, if provided expected.gas.map_or(true, |gas| gas == call.gas_limit) && // The minimum gas matches, if provided @@ -610,10 +601,10 @@ impl Inspector for Cheatcodes { } // Handle mocked calls - if let Some(mocks) = self.mocked_calls.get(&call.contract.to_ethers()) { + if let Some(mocks) = self.mocked_calls.get(&call.contract) { let ctx = MockCallDataContext { calldata: call.input.clone().0.into(), - value: Some(call.transfer.value).map(|v| v.to_ethers()), + value: Some(call.transfer.value), }; if let Some(mock_retdata) = mocks.get(&ctx) { return ( @@ -624,7 +615,7 @@ impl Inspector for Cheatcodes { } else if let Some((_, mock_retdata)) = mocks.iter().find(|(mock, _)| { mock.calldata.len() <= call.input.len() && *mock.calldata == call.input[..mock.calldata.len()] && - mock.value.map_or(true, |value| value == call.transfer.value.to_ethers()) + mock.value.map_or(true, |value| value == call.transfer.value) }) { return ( mock_retdata.ret_type, @@ -637,19 +628,19 @@ impl Inspector for Cheatcodes { // Apply our prank if let Some(prank) = &self.prank { if data.journaled_state.depth() >= prank.depth && - call.context.caller == prank.prank_caller.to_alloy() + call.context.caller == prank.prank_caller { let mut prank_applied = false; // At the target depth we set `msg.sender` if data.journaled_state.depth() == prank.depth { - call.context.caller = prank.new_caller.to_alloy(); - call.transfer.source = prank.new_caller.to_alloy(); + call.context.caller = prank.new_caller; + call.transfer.source = prank.new_caller; prank_applied = true; } // At the target depth, or deeper, we set `tx.origin` if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = new_origin.to_alloy(); + data.env.tx.caller = new_origin; prank_applied = true; } @@ -669,23 +660,22 @@ impl Inspector for Cheatcodes { // We do this because any subsequent contract calls *must* exist on chain and // we only want to grab *this* call, not internal ones if data.journaled_state.depth() == broadcast.depth && - call.context.caller == broadcast.original_caller.to_alloy() + call.context.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 // broadcast.origin. - data.env.tx.caller = broadcast.new_origin.to_alloy(); + data.env.tx.caller = broadcast.new_origin; - call.context.caller = broadcast.new_origin.to_alloy(); - call.transfer.source = broadcast.new_origin.to_alloy(); + call.context.caller = broadcast.new_origin; + call.transfer.source = broadcast.new_origin; // Add a `legacy` transaction to the VecDeque. We use a legacy transaction here // because we only need the from, to, value, and data. We can later change this // into 1559, in the cli package, relatively easily once we // know the target chain supports EIP-1559. if !call.is_static { - if let Err(err) = data - .journaled_state - .load_account(broadcast.new_origin.to_alloy(), data.db) + if let Err(err) = + data.journaled_state.load_account(broadcast.new_origin, data.db) { return ( InstructionResult::Revert, @@ -696,19 +686,16 @@ impl Inspector for Cheatcodes { let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); - let account = data - .journaled_state - .state() - .get_mut(&broadcast.new_origin.to_alloy()) - .unwrap(); + let account = + data.journaled_state.state().get_mut(&broadcast.new_origin).unwrap(); self.broadcastable_transactions.push_back(BroadcastableTransaction { rpc: data.db.active_fork_url(), transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(broadcast.new_origin), + from: Some(broadcast.new_origin.to_ethers()), to: Some(NameOrAddress::Address(call.contract.to_ethers())), value: Some(call.transfer.value).map(|v| v.to_ethers()), - data: Some(ethers::types::Bytes(call.input.clone().0)), + data: Some(call.input.clone().0.into()), nonce: Some(account.info.nonce.into()), gas: if is_fixed_gas_limit { Some(call.gas_limit.into()) @@ -725,9 +712,9 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, Gas::new(0), - "Staticcalls are not allowed after vm.broadcast. Either remove it, or use vm.startBroadcast instead." - .to_string() - .encode() + DynSolValue::String("Staticcalls are not allowed after vm.broadcast. Either remove it, or use vm.startBroadcast instead." + .to_string()) + .abi_encode() .into() ); } @@ -763,7 +750,7 @@ impl Inspector for Cheatcodes { // Clean up pranks if let Some(prank) = &self.prank { if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = prank.prank_origin.to_alloy(); + data.env.tx.caller = prank.prank_origin; // Clean single-call prank once we have returned to the original depth if prank.single_call { @@ -775,7 +762,7 @@ impl Inspector for Cheatcodes { // Clean up broadcast if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = broadcast.original_origin.to_alloy(); + data.env.tx.caller = broadcast.original_origin; // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { @@ -835,7 +822,7 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, remaining_gas, - "Log != expected log".to_string().encode().into(), + DynSolValue::String("Log != expected log".to_string()).abi_encode().into(), ) } else { // All emits were found, we're good. @@ -879,7 +866,7 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, remaining_gas, - failure_message.encode().into(), + DynSolValue::String(failure_message).abi_encode().into(), ) } } @@ -906,7 +893,7 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, remaining_gas, - failure_message.encode().into(), + DynSolValue::String(failure_message).abi_encode().into(), ) } } @@ -927,7 +914,7 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, remaining_gas, - failure_message.to_string().encode().into(), + DynSolValue::String(failure_message.to_string()).abi_encode().into(), ) } } @@ -936,7 +923,11 @@ impl Inspector for Cheatcodes { // return a better error here if status == InstructionResult::Revert { if let Some(err) = self.fork_revert_diagnostic.take() { - return (status, remaining_gas, err.to_error_msg(self).encode().into()) + return ( + status, + remaining_gas, + DynSolValue::String(err.to_error_msg(self)).abi_encode().into(), + ) } } @@ -965,23 +956,21 @@ impl Inspector for Cheatcodes { &mut self, data: &mut EVMData<'_, DB>, call: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, alloy_primitives::Bytes) { + ) -> (InstructionResult, Option
, Gas, alloy_primitives::Bytes) { // allow cheatcodes from the address of the new contract self.allow_cheatcodes_on_create(data, call); // Apply our prank if let Some(prank) = &self.prank { - if data.journaled_state.depth() >= prank.depth && - call.caller == prank.prank_caller.to_alloy() - { + if data.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { // At the target depth we set `msg.sender` if data.journaled_state.depth() == prank.depth { - call.caller = prank.new_caller.to_alloy(); + call.caller = prank.new_caller; } // At the target depth, or deeper, we set `tx.origin` if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = new_origin.to_alloy(); + data.env.tx.caller = new_origin; } } } @@ -989,11 +978,9 @@ impl Inspector for Cheatcodes { // Apply our broadcast if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() >= broadcast.depth && - call.caller == broadcast.original_caller.to_alloy() + call.caller == broadcast.original_caller { - if let Err(err) = - data.journaled_state.load_account(broadcast.new_origin.to_alloy(), data.db) - { + if let Err(err) = data.journaled_state.load_account(broadcast.new_origin, data.db) { return ( InstructionResult::Revert, None, @@ -1002,12 +989,12 @@ impl Inspector for Cheatcodes { ) } - data.env.tx.caller = broadcast.new_origin.to_alloy(); + data.env.tx.caller = broadcast.new_origin; if data.journaled_state.depth() == broadcast.depth { let (bytecode, to, nonce) = match process_create( broadcast.new_origin, - call.init_code.clone().0, + call.init_code.clone(), data, call, ) { @@ -1027,10 +1014,10 @@ impl Inspector for Cheatcodes { self.broadcastable_transactions.push_back(BroadcastableTransaction { rpc: data.db.active_fork_url(), transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(broadcast.new_origin), + from: Some(broadcast.new_origin.to_ethers()), to, value: Some(call.value).map(|v| v.to_ethers()), - data: Some(bytecode.into()), + data: Some(bytecode.0.into()), nonce: Some(nonce.into()), gas: if is_fixed_gas_limit { Some(call.gas_limit.into()) @@ -1057,14 +1044,14 @@ impl Inspector for Cheatcodes { data: &mut EVMData<'_, DB>, _: &CreateInputs, status: InstructionResult, - address: Option, + address: Option
, remaining_gas: Gas, retdata: alloy_primitives::Bytes, - ) -> (InstructionResult, Option, Gas, alloy_primitives::Bytes) { + ) -> (InstructionResult, Option
, Gas, alloy_primitives::Bytes) { // Clean up pranks if let Some(prank) = &self.prank { if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = prank.prank_origin.to_alloy(); + data.env.tx.caller = prank.prank_origin; // Clean single-call prank once we have returned to the original depth if prank.single_call { @@ -1076,7 +1063,7 @@ impl Inspector for Cheatcodes { // Clean up broadcasts if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = broadcast.original_origin.to_alloy(); + data.env.tx.caller = broadcast.original_origin; // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { @@ -1097,7 +1084,7 @@ impl Inspector for Cheatcodes { ) { Ok((address, retdata)) => ( InstructionResult::Return, - address.map(|a| a.to_alloy()), + address, remaining_gas, alloy_primitives::Bytes(retdata.0), ), @@ -1160,13 +1147,13 @@ mod revert_helper { interpreter: &mut Interpreter, ranges: &[Range], ) { - let revert_string: Bytes = format!( + let revert_string: Bytes = DynSolValue::String(format!( "Memory write at offset 0x{:02X} of size 0x{:02X} not allowed. Safe range: {}", dest_offset, size, ranges.iter().map(|r| format!("(0x{:02X}, 0x{:02X}]", r.start, r.end)).join(" ∪ ") - ) - .encode() + )) + .abi_encode() .into(); mstore_revert_string(revert_string, interpreter); } diff --git a/crates/evm/src/executor/inspector/cheatcodes/parse.rs b/crates/evm/src/executor/inspector/cheatcodes/parse.rs index d956731304bb3..322fd510b57c9 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/parse.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/parse.rs @@ -1,19 +1,17 @@ use super::{fmt_err, Cheatcodes, Result}; use crate::abi::HEVMCalls; -use ethers::{ - abi::{ethereum_types::FromDecStrErr, ParamType, Token}, - prelude::*, -}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_primitives::{FixedBytes, I256, U256}; use foundry_macros::UIfmt; use revm::{Database, EVMData}; -pub fn parse(s: &str, ty: &ParamType) -> Result { +pub fn parse(s: &str, ty: &DynSolType) -> Result { parse_token(s, ty) - .map(|token| abi::encode(&[token]).into()) + .map(|token| token.abi_encode().into()) .map_err(|e| fmt_err!("Failed to parse `{s}` as type `{ty}`: {e}")) } -pub fn parse_array(values: I, ty: &ParamType) -> Result +pub fn parse_array(values: I, ty: &DynSolType) -> Result where I: IntoIterator, T: AsRef, @@ -25,24 +23,42 @@ where .chain(values) .map(|v| parse_token(v.as_ref(), ty)) .collect::, _>>()?; - Ok(abi::encode(&[Token::Array(tokens)]).into()) + Ok(DynSolValue::Array(tokens).abi_encode().into()) } // return the empty encoded Bytes when values is empty or the first element is empty - _ => Ok(abi::encode(&[Token::String(String::new())]).into()), + _ => Ok(DynSolValue::String(String::new()).abi_encode().into()), } } -fn parse_token(s: &str, ty: &ParamType) -> Result { +fn parse_token(s: &str, ty: &DynSolType) -> Result { match ty { - ParamType::Bool => { - s.to_ascii_lowercase().parse().map(Token::Bool).map_err(|e| e.to_string()) + DynSolType::Bool => { + s.to_ascii_lowercase().parse().map(DynSolValue::Bool).map_err(|e| e.to_string()) } - ParamType::Uint(256) => parse_uint(s).map(Token::Uint), - ParamType::Int(256) => parse_int(s).map(Token::Int), - ParamType::Address => s.parse().map(Token::Address).map_err(|e| e.to_string()), - ParamType::FixedBytes(32) => parse_bytes(s).map(Token::FixedBytes), - ParamType::Bytes => parse_bytes(s).map(Token::Bytes), - ParamType::String => Ok(Token::String(s.to_string())), + DynSolType::Uint(256) => { + s.parse().map(|u| DynSolValue::Uint(u, 256)).map_err(|e| e.to_string()) + } + DynSolType::Int(256) => parse_int(s).map(|s| DynSolValue::Int(I256::from_raw(s), 256)), + DynSolType::Address => s.parse().map(DynSolValue::Address).map_err(|e| e.to_string()), + DynSolType::FixedBytes(32) => { + let mut val = s.to_string(); + // Previously with ethabi, strings were automatically padded to 32 bytes if it wasn't + // the case. This is not the case anymore, so we need to do it manually for + // compatibility reasons. Get the total length, either for a prefixed or + // unprefixed string. + let total_len = if val.starts_with("0x") { 66 } else { 64 }; + // Pad accordingly until it's the correct size. + if val.len() != total_len { + while val.len() < total_len { + val.push('0') + } + } + val.parse::>() + .map(|b| DynSolValue::FixedBytes(b, 32)) + .map_err(|e| e.to_string()) + } + DynSolType::Bytes => parse_bytes(s).map(DynSolValue::Bytes), + DynSolType::String => Ok(DynSolValue::String(s.to_string())), _ => Err("unsupported type".into()), } } @@ -53,11 +69,7 @@ fn parse_int(s: &str) -> Result { // Hex string may start with "0x", "+0x", or "-0x" which needs to be stripped for // `I256::from_hex_str` if s.starts_with("0x") || s.starts_with("+0x") || s.starts_with("-0x") { - return s - .replacen("0x", "", 1) - .parse::() - .map_err(|err| err.to_string()) - .map(|v| v.into_raw()) + return I256::from_hex_str(s).map_err(|err| err.to_string()).map(|v| v.into_raw()) } // Decimal string may start with '+' or '-' followed by numeric characters @@ -72,29 +84,7 @@ fn parse_int(s: &str) -> Result { }; // Throw if string doesn't conform to either of the two patterns - Err(ParseI256Error::InvalidDigit.to_string()) -} - -fn parse_uint(s: &str) -> Result { - // Only parse hex strings prefixed by 0x or decimal numeric strings - - // Hex strings prefixed by 0x - if s.starts_with("0x") { - return s.parse::().map_err(|err| err.to_string()) - }; - - // Decimal strings containing only numeric characters - if s.chars().all(|c| c.is_numeric()) { - return match U256::from_dec_str(s) { - Ok(val) => Ok(val), - Err(dec_err) => s.parse::().map_err(|hex_err| { - format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") - }), - } - }; - - // Throw if string doesn't conform to either of the two patterns - Err(FromDecStrErr::InvalidCharacter.to_string()) + Err("Invalid conversion. Make sure that either the hex string or the decimal number passed is valid.".to_string()) } fn parse_bytes(s: &str) -> Result, String> { @@ -109,29 +99,29 @@ pub fn apply( ) -> Option { Some(match call { HEVMCalls::ToString0(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) } HEVMCalls::ToString1(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) } HEVMCalls::ToString2(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) } HEVMCalls::ToString3(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) } HEVMCalls::ToString4(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) } HEVMCalls::ToString5(inner) => { - Ok(ethers::abi::encode(&[Token::String(inner.0.pretty())]).into()) + Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) } - HEVMCalls::ParseBytes(inner) => parse(&inner.0, &ParamType::Bytes), - HEVMCalls::ParseAddress(inner) => parse(&inner.0, &ParamType::Address), - HEVMCalls::ParseUint(inner) => parse(&inner.0, &ParamType::Uint(256)), - HEVMCalls::ParseInt(inner) => parse(&inner.0, &ParamType::Int(256)), - HEVMCalls::ParseBytes32(inner) => parse(&inner.0, &ParamType::FixedBytes(32)), - HEVMCalls::ParseBool(inner) => parse(&inner.0, &ParamType::Bool), + HEVMCalls::ParseBytes(inner) => parse(&inner.0, &DynSolType::Bytes), + HEVMCalls::ParseAddress(inner) => parse(&inner.0, &DynSolType::Address), + HEVMCalls::ParseUint(inner) => parse(&inner.0, &DynSolType::Uint(256)), + HEVMCalls::ParseInt(inner) => parse(&inner.0, &DynSolType::Int(256)), + HEVMCalls::ParseBytes32(inner) => parse(&inner.0, &DynSolType::FixedBytes(32)), + HEVMCalls::ParseBool(inner) => parse(&inner.0, &DynSolType::Bool), _ => return None, }) } @@ -139,34 +129,33 @@ pub fn apply( #[cfg(test)] mod tests { use super::*; - use ethers::abi::AbiDecode; #[test] fn test_uint_env() { let pk = "0x10532cc9d0d992825c3f709c62c969748e317a549634fb2a9fa949326022e81f"; let val: U256 = pk.parse().unwrap(); - let parsed = parse(pk, &ParamType::Uint(256)).unwrap(); - let decoded = U256::decode(&parsed).unwrap(); + let parsed = parse(pk, &DynSolType::Uint(256)).unwrap(); + let decoded = DynSolType::Uint(256).abi_decode(&parsed).unwrap().as_uint().unwrap().0; assert_eq!(val, decoded); - let parsed = parse(pk, &ParamType::Uint(256)).unwrap(); - let decoded = U256::decode(&parsed).unwrap(); + let parsed = parse(pk, &DynSolType::Uint(256)).unwrap(); + let decoded = DynSolType::Uint(256).abi_decode(&parsed).unwrap().as_uint().unwrap().0; assert_eq!(val, decoded); - let parsed = parse("1337", &ParamType::Uint(256)).unwrap(); - let decoded = U256::decode(&parsed).unwrap(); + let parsed = parse("1337", &DynSolType::Uint(256)).unwrap(); + let decoded = DynSolType::Uint(256).abi_decode(&parsed).unwrap().as_uint().unwrap().0; assert_eq!(U256::from(1337u64), decoded); } #[test] fn test_int_env() { let val = U256::from(100u64); - let parsed = parse(&val.to_string(), &ParamType::Int(256)).unwrap(); - let decoded = I256::decode(parsed).unwrap(); - assert_eq!(val, decoded.try_into().unwrap()); + let parsed = parse(&val.to_string(), &DynSolType::Int(256)).unwrap(); + let decoded = DynSolType::Int(256).abi_decode(&parsed).unwrap().as_int().unwrap().0; + assert_eq!(val, decoded.into_raw()); - let parsed = parse("100", &ParamType::Int(256)).unwrap(); - let decoded = I256::decode(parsed).unwrap(); - assert_eq!(U256::from(100u64), decoded.try_into().unwrap()); + let parsed = parse("100", &DynSolType::Int(256)).unwrap(); + let decoded = DynSolType::Int(256).abi_decode(&parsed).unwrap().as_int().unwrap().0; + assert_eq!(U256::from(100u64), decoded.into_raw()); } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs b/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs index b68ea9e5d366d..c2daff5cdc24d 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs @@ -1,7 +1,7 @@ use super::Result; use crate::{abi::HEVMCalls, executor::backend::DatabaseExt}; -use ethers::abi::AbiEncode; -use foundry_utils::types::{ToAlloy, ToEthers}; +use alloy_dyn_abi::DynSolValue; +use foundry_utils::types::ToAlloy; use revm::EVMData; /// Handles fork related cheatcodes @@ -9,7 +9,9 @@ use revm::EVMData; pub fn apply(data: &mut EVMData<'_, DB>, call: &HEVMCalls) -> Option { Some(match call { HEVMCalls::Snapshot(_) => { - Ok((data.db.snapshot(&data.journaled_state, data.env)).to_ethers().encode().into()) + Ok(DynSolValue::Uint(data.db.snapshot(&data.journaled_state, data.env), 256) + .abi_encode() + .into()) } HEVMCalls::RevertTo(snapshot) => { let res = if let Some(journaled_state) = @@ -21,7 +23,7 @@ pub fn apply(data: &mut EVMData<'_, DB>, call: &HEVMCalls) -> O } else { false }; - Ok(res.encode().into()) + Ok(DynSolValue::Bool(res).abi_encode().into()) } _ => return None, }) diff --git a/crates/evm/src/executor/inspector/cheatcodes/util.rs b/crates/evm/src/executor/inspector/cheatcodes/util.rs index 721dd6493c945..b21af6b1dce7e 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/util.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/util.rs @@ -6,16 +6,15 @@ use crate::{ }, utils::h256_to_u256_be, }; -use alloy_primitives::Address as rAddress; -use bytes::{BufMut, Bytes, BytesMut}; +use alloy_primitives::{Address, Bytes, U256}; +use bytes::{BufMut, BytesMut}; use ethers::{ - abi::Address, core::k256::elliptic_curve::Curve, prelude::{ k256::{ecdsa::SigningKey, elliptic_curve::bigint::Encoding, Secp256k1}, - H160, *, + Transaction, }, - types::{transaction::eip2718::TypedTransaction, NameOrAddress, U256}, + types::{transaction::eip2718::TypedTransaction, NameOrAddress}, }; use foundry_common::RpcUrl; use foundry_utils::types::{ToAlloy, ToEthers}; @@ -29,7 +28,7 @@ use std::collections::VecDeque; pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; /// Address of the default CREATE2 deployer 0x4e59b44847b379578588920ca78fbf26c0b4956c -pub const DEFAULT_CREATE2_DEPLOYER: rAddress = rAddress::new([ +pub const DEFAULT_CREATE2_DEPLOYER: Address = Address::new([ 78, 89, 180, 72, 71, 179, 121, 87, 133, 136, 146, 12, 167, 143, 191, 38, 192, 180, 149, 108, ]); @@ -80,7 +79,6 @@ pub fn with_journaled_account( where F: FnMut(&mut Account) -> R, { - let addr = addr.to_alloy(); journaled_state.load_account(addr, db)?; journaled_state.touch(&addr); let account = journaled_state.state.get_mut(&addr).expect("account loaded;"); @@ -96,7 +94,6 @@ pub fn process_create( where DB: Database, { - let broadcast_sender = broadcast_sender.to_alloy(); match call.scheme { revm::primitives::CreateScheme::Create => { call.caller = broadcast_sender; @@ -141,7 +138,7 @@ where calldata.put(bytecode); Ok(( - calldata.freeze(), + calldata.freeze().into(), Some(NameOrAddress::Address(DEFAULT_CREATE2_DEPLOYER.to_ethers())), nonce, )) @@ -150,14 +147,13 @@ where } pub fn parse_private_key(private_key: U256) -> Result { - ensure!(!private_key.is_zero(), "Private key cannot be 0."); + ensure!(private_key != U256::ZERO, "Private key cannot be 0."); ensure!( - private_key < U256::from_big_endian(&Secp256k1::ORDER.to_be_bytes()), + private_key < U256::from_be_bytes(Secp256k1::ORDER.to_be_bytes()), "Private key must be less than the secp256k1 curve order \ (115792089237316195423570985008687907852837564279074904382605163141518161494337).", ); - let mut bytes: [u8; 32] = [0; 32]; - private_key.to_big_endian(&mut bytes); + let bytes = private_key.to_be_bytes(); SigningKey::from_bytes((&bytes).into()).map_err(Into::into) } @@ -171,14 +167,14 @@ pub fn check_if_fixed_gas_limit( // time of the call, which should be rather close to configured gas limit. // TODO: Find a way to reliably make this determination. (for example by // generating it in the compilation or evm simulation process) - U256::from(data.env.tx.gas_limit) > data.env.block.gas_limit.to_ethers() && - U256::from(call_gas_limit) <= data.env.block.gas_limit.to_ethers() + U256::from(data.env.tx.gas_limit) > data.env.block.gas_limit && + U256::from(call_gas_limit) <= data.env.block.gas_limit // Transfers in forge scripts seem to be estimated at 2300 by revm leading to "Intrinsic // gas too low" failure when simulated on chain && call_gas_limit > 2300 } /// Small utility function that checks if an address is a potential precompile. -pub fn is_potential_precompile(address: H160) -> bool { - address < H160::from_low_u64_be(10) && address != H160::zero() +pub fn is_potential_precompile(address: Address) -> bool { + address < Address::with_last_byte(10) && address != Address::ZERO } diff --git a/crates/evm/src/executor/inspector/cheatcodes/wallet.rs b/crates/evm/src/executor/inspector/cheatcodes/wallet.rs index 3c1d55048aa90..a3cebf34f1d2a 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/wallet.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/wallet.rs @@ -1,7 +1,8 @@ use super::{ensure, Cheatcodes, Result}; use crate::abi::HEVMCalls; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{keccak256, B256, U256}; use ethers::{ - abi::{AbiEncode, Token}, core::k256::elliptic_curve::Curve, prelude::{ k256::{ @@ -18,9 +19,9 @@ use ethers::{ }, MnemonicBuilder, }, - types::{H256, U256}, - utils::{self, keccak256}, + utils, }; +use foundry_utils::types::{ToAlloy, ToEthers}; use revm::{Database, EVMData}; use std::str::FromStr; @@ -28,39 +29,44 @@ use std::str::FromStr; const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; pub fn parse_private_key(private_key: U256) -> Result { - ensure!(!private_key.is_zero(), "Private key cannot be 0."); + ensure!(private_key != U256::ZERO, "Private key cannot be 0."); ensure!( - private_key < U256::from_big_endian(&Secp256k1::ORDER.to_be_bytes()), + private_key < U256::from_be_bytes(Secp256k1::ORDER.to_be_bytes()), "Private key must be less than the secp256k1 curve order \ (115792089237316195423570985008687907852837564279074904382605163141518161494337).", ); - let mut bytes: [u8; 32] = [0; 32]; - private_key.to_big_endian(&mut bytes); + let bytes = private_key.to_be_bytes(); SigningKey::from_bytes((&bytes).into()).map_err(Into::into) } fn addr(private_key: U256) -> Result { let key = parse_private_key(private_key)?; let addr = utils::secret_key_to_address(&key); - Ok(addr.encode().into()) + Ok(DynSolValue::Address(addr.to_alloy()).abi_encode().into()) } -fn sign(private_key: U256, digest: H256, chain_id: U256) -> Result { +fn sign(private_key: U256, digest: B256, chain_id: U256) -> Result { let key = parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.as_u64()); + let wallet = LocalWallet::from(key).with_chain_id(chain_id.to::()); // The `ecrecover` precompile does not use EIP-155 - let sig = wallet.sign_hash(digest)?; - let recovered = sig.recover(digest)?; + let sig = wallet.sign_hash(digest.to_ethers())?; + let recovered = sig.recover(digest.to_ethers())?.to_alloy(); - assert_eq!(recovered, wallet.address()); + assert_eq!(recovered, wallet.address().to_alloy()); let mut r_bytes = [0u8; 32]; let mut s_bytes = [0u8; 32]; sig.r.to_big_endian(&mut r_bytes); sig.s.to_big_endian(&mut s_bytes); - Ok((sig.v, r_bytes, s_bytes).encode().into()) + Ok(DynSolValue::Tuple(vec![ + DynSolValue::Uint(U256::from(sig.v), 8), + DynSolValue::FixedBytes(r_bytes.into(), 32), + DynSolValue::FixedBytes(s_bytes.into(), 32), + ]) + .abi_encode() + .into()) } /// Using a given private key, return its public ETH address, its public key affine x and y @@ -75,14 +81,21 @@ fn create_wallet(private_key: U256, label: Option, state: &mut Cheatcode let pub_key_x = pub_key.x().ok_or("No x coordinate was found")?; let pub_key_y = pub_key.y().ok_or("No y coordinate was found")?; - let pub_key_x = U256::from(pub_key_x.as_slice()); - let pub_key_y = U256::from(pub_key_y.as_slice()); + let pub_key_x = U256::from_be_bytes((*pub_key_x).into()); + let pub_key_y = U256::from_be_bytes((*pub_key_y).into()); if let Some(label) = label { - state.labels.insert(addr, label); + state.labels.insert(addr.to_alloy(), label); } - Ok((addr, pub_key_x, pub_key_y, private_key).encode().into()) + Ok(DynSolValue::Tuple(vec![ + DynSolValue::Address(addr.to_alloy()), + DynSolValue::Uint(pub_key_x, 256), + DynSolValue::Uint(pub_key_y, 256), + DynSolValue::Uint(private_key, 256), + ]) + .abi_encode() + .into()) } enum WordlistLang { @@ -127,9 +140,12 @@ fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { .derivation_path(&derivation_path)? .build()?; - let private_key = U256::from_big_endian(wallet.signer().to_bytes().as_slice()); + let private_key = match U256::try_from_be_slice(wallet.signer().to_bytes().as_slice()) { + Some(key) => key, + None => return Err("Failed to parse private key.".to_string().into()), + }; - Ok(private_key.encode().into()) + Ok(DynSolValue::Uint(private_key, 256).abi_encode().into()) } fn derive_key_with_wordlist(mnemonic: &str, path: &str, index: u32, lang: &str) -> Result { @@ -150,12 +166,12 @@ fn derive_key_with_wordlist(mnemonic: &str, path: &str, index: u32, lang: &str) fn remember_key(state: &mut Cheatcodes, private_key: U256, chain_id: U256) -> Result { let key = parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.as_u64()); + let wallet = LocalWallet::from(key).with_chain_id(chain_id.to::()); let address = wallet.address(); state.script_wallets.push(wallet); - Ok(address.encode().into()) + Ok(DynSolValue::Address(address.to_alloy()).abi_encode().into()) } #[instrument(level = "error", name = "util", target = "evm::cheatcodes", skip_all)] @@ -165,23 +181,27 @@ pub fn apply( call: &HEVMCalls, ) -> Option { Some(match call { - HEVMCalls::Addr(inner) => addr(inner.0), + HEVMCalls::Addr(inner) => addr(inner.0.to_alloy()), // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given private key - HEVMCalls::Sign0(inner) => sign(inner.0, inner.1.into(), data.env.cfg.chain_id.into()), + HEVMCalls::Sign0(inner) => { + sign(inner.0.to_alloy(), inner.1.into(), U256::from(data.env.cfg.chain_id)) + } // [function createWallet(string)] Used to derive private key and label the wallet with the // same string HEVMCalls::CreateWallet0(inner) => { - create_wallet(U256::from(keccak256(&inner.0)), Some(inner.0.clone()), state) + create_wallet(U256::from_be_bytes(keccak256(&inner.0).0), Some(inner.0.clone()), state) } // [function createWallet(uint256)] creates a new wallet with the given private key - HEVMCalls::CreateWallet1(inner) => create_wallet(inner.0, None, state), + HEVMCalls::CreateWallet1(inner) => create_wallet(inner.0.to_alloy(), None, state), // [function createWallet(uint256,string)] creates a new wallet with the given private key // and labels it with the given string - HEVMCalls::CreateWallet2(inner) => create_wallet(inner.0, Some(inner.1.clone()), state), + HEVMCalls::CreateWallet2(inner) => { + create_wallet(inner.0.to_alloy(), Some(inner.1.clone()), state) + } // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given Wallet's // private key HEVMCalls::Sign1(inner) => { - sign(inner.0.private_key, inner.1.into(), data.env.cfg.chain_id.into()) + sign(inner.0.private_key.to_alloy(), inner.1.into(), U256::from(data.env.cfg.chain_id)) } HEVMCalls::DeriveKey0(inner) => { derive_key::(&inner.0, DEFAULT_DERIVATION_PATH_PREFIX, inner.1) @@ -193,18 +213,20 @@ pub fn apply( HEVMCalls::DeriveKey3(inner) => { derive_key_with_wordlist(&inner.0, &inner.1, inner.2, &inner.3) } - HEVMCalls::RememberKey(inner) => remember_key(state, inner.0, data.env.cfg.chain_id.into()), + HEVMCalls::RememberKey(inner) => { + remember_key(state, inner.0.to_alloy(), U256::from(data.env.cfg.chain_id)) + } HEVMCalls::Label(inner) => { - state.labels.insert(inner.0, inner.1.clone()); + state.labels.insert(inner.0.to_alloy(), inner.1.clone()); Ok(Default::default()) } HEVMCalls::GetLabel(inner) => { let label = state .labels - .get(&inner.0) + .get(&inner.0.to_alloy()) .cloned() .unwrap_or_else(|| format!("unlabeled:{:?}", inner.0)); - Ok(ethers::abi::encode(&[Token::String(label)]).into()) + Ok(DynSolValue::String(label).abi_encode().into()) } _ => return None, }) diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/src/executor/inspector/stack.rs index 3cd392521c407..71e95c81fae6a 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/src/executor/inspector/stack.rs @@ -9,7 +9,7 @@ use crate::{ }; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers::{signers::LocalWallet, types::Log}; -use foundry_utils::types::{ToAlloy, ToEthers}; + use revm::{ interpreter::{ return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, Stack, @@ -242,7 +242,7 @@ impl InspectorStack { #[inline] pub fn set_gas_price(&mut self, gas_price: U256) { if let Some(cheatcodes) = &mut self.cheatcodes { - cheatcodes.gas_price = Some(gas_price).map(|g| g.to_ethers()); + cheatcodes.gas_price = Some(gas_price); } } @@ -303,7 +303,7 @@ impl InspectorStack { .cheatcodes .as_ref() .map(|cheatcodes| { - cheatcodes.labels.clone().into_iter().map(|l| (l.0.to_alloy(), l.1)).collect() + cheatcodes.labels.clone().into_iter().map(|l| (l.0, l.1)).collect() }) .unwrap_or_default(), traces: self.tracer.map(|tracer| tracer.traces), diff --git a/testdata/cheats/Env.t.sol b/testdata/cheats/Env.t.sol index 9e4b4360d1b98..fa1738de270bf 100644 --- a/testdata/cheats/Env.t.sol +++ b/testdata/cheats/Env.t.sol @@ -91,7 +91,10 @@ contract EnvTest is DSTest { function testEnvBytes32() public { string memory key = "_foundryCheatcodeEnvBytes32TestKey"; - string[numEnvBytes32Tests] memory values = ["0x7109709ECfa91a80626fF3989D68f67F5b1DD12D", "0x00"]; + string[numEnvBytes32Tests] memory values = [ + "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ]; bytes32[numEnvBytes32Tests] memory expected = [ bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) @@ -187,7 +190,8 @@ contract EnvTest is DSTest { function testEnvBytes32Arr() public { string memory key = "_foundryCheatcodeEnvBytes32ArrTestKey"; - string memory value = "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D," "0x00"; + string memory value = "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000," + "0x0000000000000000000000000000000000000000000000000000000000000000"; bytes32[2] memory expected = [ bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) diff --git a/testdata/fixtures/Json/test.json b/testdata/fixtures/Json/test.json index 5277d6d2d454a..4e4ade7830170 100644 --- a/testdata/fixtures/Json/test.json +++ b/testdata/fixtures/Json/test.json @@ -21,7 +21,7 @@ "arrayUint": [1231232, "0x12C980", "1231232"], "stringInt": "-12", "numberInt": -12, - "hexInt": "0x-C", + "hexInt": "-0xC", "booleanString": "true", "booleanArray": [true, "false"], "advancedJsonPath": [{ "id": 1 }, { "id": 2 }] From 469b856912e7e67187c86c795fe479511dbd4c49 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 6 Oct 2023 00:15:12 +0200 Subject: [PATCH 0146/1963] fix: add missing checks for system transactions (#5991) --- crates/cast/bin/cmd/run.rs | 42 +++++++++++++++++------- crates/common/src/constants.rs | 44 ++++++++++++++++++++++++++ crates/evm/src/executor/backend/mod.rs | 25 +++++++++++---- 3 files changed, 92 insertions(+), 19 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 4ab9299511755..ee6f94ef23ce5 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,5 +1,5 @@ use clap::Parser; -use ethers::{prelude::Middleware, solc::EvmVersion, types::H160}; +use ethers::{prelude::Middleware, solc::EvmVersion}; use eyre::{Result, WrapErr}; use foundry_cli::{ init_progress, @@ -7,6 +7,7 @@ use foundry_cli::{ update_progress, utils, utils::{handle_traces, TraceResult}, }; +use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{ executor::{inspector::cheatcodes::util::configure_tx_env, opts::EvmOpts, EvmError}, @@ -16,11 +17,6 @@ use foundry_evm::{ use foundry_utils::types::ToAlloy; use tracing::trace; -const ARBITRUM_SENDER: H160 = H160([ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0a, 0x4b, 0x05, -]); - /// CLI arguments for `cast run`. #[derive(Debug, Clone, Parser)] pub struct RunArgs { @@ -101,11 +97,22 @@ impl RunArgs { .await? .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; + // check if the tx is a system transaction + if is_known_system_sender(tx.from) || + tx.transaction_type.map(|ty| ty.as_u64()) == Some(SYSTEM_TRANSACTION_TYPE) + { + return Err(eyre::eyre!( + "{:?} is a system transaction.\nReplaying system transactions is currently not supported.", + tx.hash + )) + } + let tx_block_number = tx .block_number .ok_or_else(|| eyre::eyre!("tx may still be pending: {:?}", tx_hash))? .as_u64(); + // we need to fork off the parent block config.fork_block_number = Some(tx_block_number - 1); let (mut env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; @@ -125,6 +132,8 @@ impl RunArgs { env.block.gas_limit = block.gas_limit.to_alloy(); } + std::fs::write("block.json", serde_json::to_string_pretty(&block).unwrap()).unwrap(); + // Set the state to the moment right before the transaction if !self.quick { println!("Executing previous transactions from the block."); @@ -134,13 +143,16 @@ impl RunArgs { pb.set_position(0); for (index, tx) in block.transactions.into_iter().enumerate() { - // arbitrum L1 transaction at the start of every block that has gas price 0 - // and gas limit 0 which causes reverts, so we skip it - if tx.from == ARBITRUM_SENDER { + // System transactions such as on L2s don't contain any pricing info so we skip + // them otherwise this would cause reverts + if is_known_system_sender(tx.from) || + tx.transaction_type.map(|ty| ty.as_u64()) == + Some(SYSTEM_TRANSACTION_TYPE) + { update_progress!(pb, index); continue } - if tx.hash().eq(&tx_hash) { + if tx.hash.eq(&tx_hash) { break } @@ -149,7 +161,10 @@ impl RunArgs { if let Some(to) = tx.to { trace!(tx=?tx.hash,?to, "executing previous call transaction"); executor.commit_tx_with_env(env.clone()).wrap_err_with(|| { - format!("Failed to execute transaction: {:?}", tx.hash()) + format!( + "Failed to execute transaction: {:?} in block {}", + tx.hash, env.block.number + ) })?; } else { trace!(tx=?tx.hash, "executing previous create transaction"); @@ -159,7 +174,10 @@ impl RunArgs { EvmError::Execution(_) => (), error => { return Err(error).wrap_err_with(|| { - format!("Failed to deploy transaction: {:?}", tx.hash()) + format!( + "Failed to deploy transaction: {:?} in block {}", + tx.hash, env.block.number + ) }) } } diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 2478fa81edb93..5a457422a681b 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -1,5 +1,6 @@ //! Commonly used constants +use ethers_core::types::H160; use std::time::Duration; /// The dev chain-id, inherited from hardhat @@ -25,3 +26,46 @@ pub const ALCHEMY_FREE_TIER_CUPS: u64 = 330; pub const NON_ARCHIVE_NODE_WARNING: &str = "\ It looks like you're trying to fork from an older block with a non-archive node which is not \ supported. Please try to change your RPC url to an archive node if the issue persists."; + +/// Arbitrum L1 sender address of the first transaction in every block. +/// `0x00000000000000000000000000000000000a4b05` +pub const ARBITRUM_SENDER: H160 = H160([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0a, 0x4b, 0x05, +]); + +/// The system address, the sender of the first transaction in every block: +/// `0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001` +/// +/// See also +pub const OPTIMISM_SYSTEM_ADDRESS: H160 = H160([ + 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, + 0xDE, 0xAD, 0x00, 0x01, +]); + +/// Transaction identifier of System transaction types +pub const SYSTEM_TRANSACTION_TYPE: u64 = 126u64; + +/// Returns whether the sender is a known L2 system sender that is the first tx in every block. +/// +/// Transactions from these senders usually don't have a any fee information. +/// +/// See: [ARBITRUM_SENDER], [OPTIMISM_SYSTEM_ADDRESS] +#[inline] +pub fn is_known_system_sender(sender: H160) -> bool { + [ARBITRUM_SENDER, OPTIMISM_SYSTEM_ADDRESS].contains(&sender) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::str::FromStr; + + #[test] + fn test_constant_sender() { + let arb = H160::from_str("0x00000000000000000000000000000000000a4b05").unwrap(); + assert_eq!(arb, ARBITRUM_SENDER); + let base = H160::from_str("0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001").unwrap(); + assert_eq!(base, OPTIMISM_SYSTEM_ADDRESS); + } +} diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index f2751643df9f5..f429e552a3c98 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -3,9 +3,15 @@ use crate::{ abi::CHEATCODE_ADDRESS, executor::{ - backend::snapshot::BackendSnapshot, + backend::{ + error::NoCheatcodeAccessError, in_memory_db::FoundryEvmInMemoryDB, + snapshot::BackendSnapshot, + }, fork::{CreateFork, ForkId, MultiFork, SharedBackend}, - inspector::{cheatcodes::Cheatcodes, DEFAULT_CREATE2_DEPLOYER}, + inspector::{ + cheatcodes::{util::configure_tx_env, Cheatcodes}, + DEFAULT_CREATE2_DEPLOYER, + }, snapshot::Snapshots, }, CALLER, TEST_CONTRACT_ADDRESS, @@ -16,6 +22,7 @@ use ethers::{ types::{BlockNumber, Transaction}, utils::keccak256, }; +use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_utils::types::{ToAlloy, ToEthers}; pub use in_memory_db::MemDb; use revm::{ @@ -43,10 +50,6 @@ mod diagnostic; pub use diagnostic::RevertDiagnostic; pub mod error; -use crate::executor::{ - backend::{error::NoCheatcodeAccessError, in_memory_db::FoundryEvmInMemoryDB}, - inspector::cheatcodes::util::configure_tx_env, -}; pub use error::{DatabaseError, DatabaseResult}; mod in_memory_db; @@ -861,7 +864,15 @@ impl Backend { .get_full_block(BlockNumber::Number(env.block.number.to_ethers().as_u64().into()))?; for tx in full_block.transactions.into_iter() { - if tx.hash().eq(&tx_hash.to_ethers()) { + // System transactions such as on L2s don't contain any pricing info so we skip them + // otherwise this would cause reverts + if is_known_system_sender(tx.from) || + tx.transaction_type.map(|ty| ty.as_u64()) == Some(SYSTEM_TRANSACTION_TYPE) + { + continue + } + + if tx.hash.eq(&tx_hash.to_ethers()) { // found the target transaction return Ok(Some(tx)) } From 87283bc9f5657eed126ecb2d2370a471ff409bb7 Mon Sep 17 00:00:00 2001 From: Perelyn <64838956+Perelyn-sama@users.noreply.github.com> Date: Thu, 5 Oct 2023 23:23:11 +0100 Subject: [PATCH 0147/1963] added report-file option and new coverage test (#5888) * add report-file and test * chore: clean code by removing unused comments * fmt * add corrections * fmt --------- Co-authored-by: Enrique Ortiz --- crates/forge/bin/cmd/coverage.rs | 24 ++++++++++++++++++++---- crates/forge/tests/cli/coverage.rs | 10 ++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 70a44aa108780..08173dbaa94e7 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -1,6 +1,6 @@ use super::{install, test::FilterArgs}; use alloy_primitives::{Address, Bytes, U256}; -use clap::{Parser, ValueEnum}; +use clap::{Parser, ValueEnum, ValueHint}; use ethers::{ prelude::{ artifacts::{Ast, CompactBytecode, CompactDeployedBytecode}, @@ -29,7 +29,7 @@ use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; use foundry_config::{Config, SolcReq}; use foundry_utils::types::ToEthers; use semver::Version; -use std::{collections::HashMap, sync::mpsc::channel}; +use std::{collections::HashMap, path::PathBuf, sync::mpsc::channel}; use tracing::trace; use yansi::Paint; @@ -55,6 +55,17 @@ pub struct CoverageArgs { #[clap(long)] ir_minimum: bool, + /// The path to output the report. + /// + /// If not specified, the report will be stored in the root of the project. + #[clap( + long, + short, + value_hint = ValueHint::FilePath, + value_name = "PATH" + )] + report_file: Option, + #[clap(flatten)] filter: FilterArgs, @@ -342,9 +353,14 @@ impl CoverageArgs { for report_kind in self.report { match report_kind { CoverageReportKind::Summary => SummaryReporter::default().report(&report), - // TODO: Sensible place to put the LCOV file CoverageReportKind::Lcov => { - LcovReporter::new(&mut fs::create_file(root.join("lcov.info"))?).report(&report) + if let Some(report_file) = self.report_file { + return LcovReporter::new(&mut fs::create_file(root.join(report_file))?) + .report(&report) + } else { + return LcovReporter::new(&mut fs::create_file(root.join("lcov.info"))?) + .report(&report) + } } CoverageReportKind::Debug => DebugReporter.report(&report), }?; diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 05b76a06fdf1c..eb950832dfd18 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -4,3 +4,13 @@ forgetest!(basic_coverage, |_prj: TestProject, mut cmd: TestCommand| { cmd.args(["coverage"]); cmd.assert_success(); }); + +forgetest!(report_file_coverage, |prj: TestProject, mut cmd: TestCommand| { + cmd.arg("coverage").args([ + "--report".to_string(), + "lcov".to_string(), + "--report-file".to_string(), + prj.root().join("lcov.info").to_str().unwrap().to_string(), + ]); + cmd.assert_success(); +}); From 4baf8b904d28996763e77efadc92ee25b0f9b020 Mon Sep 17 00:00:00 2001 From: ruvaag Date: Sat, 7 Oct 2023 14:28:15 +0530 Subject: [PATCH 0148/1963] fix: forge create respects chain id cmd args (#6001) * fix: forge create respects chain id cmd args * add sanity test --------- Co-authored-by: Matthias Seitz --- crates/forge/bin/cmd/create.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 709806bc0bf8d..7cc49c29402c4 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -117,7 +117,12 @@ impl CreateArgs { None => vec![], }; - let chain_id = provider.get_chainid().await?.as_u64(); + // respect chain, if set explicitly via cmd args + let chain_id = if let Some(chain_id) = self.chain_id() { + chain_id + } else { + provider.get_chainid().await?.as_u64() + }; if self.unlocked { // Deploy with unlocked account let sender = self.eth.wallet.from.expect("required"); @@ -131,6 +136,11 @@ impl CreateArgs { } } + /// Returns the provided chain id, if any. + fn chain_id(&self) -> Option { + self.eth.etherscan.chain.map(|chain| chain.id()) + } + /// Ensures the verify command can be executed. /// /// This is supposed to check any things that might go wrong when preparing a verify request @@ -345,4 +355,19 @@ mod tests { assert_eq!(args.retry.retries, 10); assert_eq!(args.retry.delay, 30); } + #[test] + fn can_parse_chain_id() { + let args: CreateArgs = CreateArgs::parse_from([ + "foundry-cli", + "src/Domains.sol:Domains", + "--verify", + "--retries", + "10", + "--delay", + "30", + "--chain-id", + "9999", + ]); + assert_eq!(args.chain_id(), Some(9999)); + } } From cb3d2f24fa1df7e9c92fe0e4393edff9ff7651c3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 7 Oct 2023 10:58:57 +0200 Subject: [PATCH 0149/1963] chore: simplify foundry-macros (#6002) * chore: simplify foundry-macros * chore: clippy --- crates/common/src/contracts.rs | 28 ++++++------- crates/macros/Cargo.toml | 2 +- crates/macros/impl/src/console_fmt.rs | 60 +++++++++++++-------------- crates/macros/impl/src/lib.rs | 5 +-- crates/macros/src/lib.rs | 2 + 5 files changed, 48 insertions(+), 49 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index c819c41aefc3f..a0b3384d5c0ed 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -222,6 +222,20 @@ pub fn find_constructor_args(data: &[u8]) -> Option<&[u8]> { Some(args) } +/// Helper function to convert CompactContractBytecode ~> ContractBytecodeSome +pub fn compact_to_contract( + contract: CompactContractBytecode, +) -> eyre::Result { + Ok(ContractBytecodeSome { + abi: contract.abi.ok_or(eyre::eyre!("No contract abi"))?, + bytecode: contract.bytecode.ok_or(eyre::eyre!("No contract bytecode"))?.into(), + deployed_bytecode: contract + .deployed_bytecode + .ok_or(eyre::eyre!("No contract deployed bytecode"))? + .into(), + }) +} + #[cfg(test)] mod tests { use super::*; @@ -268,17 +282,3 @@ mod tests { let _decoded = abi::decode(¶ms, args).unwrap(); } } - -/// Helper function to convert CompactContractBytecode ~> ContractBytecodeSome -pub fn compact_to_contract( - contract: CompactContractBytecode, -) -> eyre::Result { - Ok(ContractBytecodeSome { - abi: contract.abi.ok_or(eyre::eyre!("No contract abi"))?, - bytecode: contract.bytecode.ok_or(eyre::eyre!("No contract bytecode"))?.into(), - deployed_bytecode: contract - .deployed_bytecode - .ok_or(eyre::eyre!("No contract deployed bytecode"))? - .into(), - }) -} diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index 41ac67dc495ea..add53ae6b8aef 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -10,7 +10,7 @@ homepage.workspace = true repository.workspace = true [dependencies] -foundry-macros-impl.path = "impl" +foundry-macros-impl = { path = "impl" } ethers-core.workspace = true serde = "1.0" diff --git a/crates/macros/impl/src/console_fmt.rs b/crates/macros/impl/src/console_fmt.rs index 9817fdef57bf8..f555b846cc0b6 100644 --- a/crates/macros/impl/src/console_fmt.rs +++ b/crates/macros/impl/src/console_fmt.rs @@ -1,38 +1,36 @@ use proc_macro2::{Delimiter, Group, Ident, TokenStream}; use quote::{format_ident, quote}; use syn::{ - punctuated::Punctuated, Data, DataEnum, DataStruct, DeriveInput, Field, Fields, Path, Token, - Type, + punctuated::Punctuated, Data, DataEnum, DataStruct, DeriveInput, Field, Fields, Token, Type, }; -pub fn console_fmt(input: DeriveInput) -> TokenStream { - let krate = crate::krate(); - let name = input.ident; - let tokens = match input.data { - Data::Struct(s) => derive_struct(s, &krate), - Data::Enum(e) => derive_enum(e, &krate), +pub fn console_fmt(input: &DeriveInput) -> TokenStream { + let name = &input.ident; + let tokens = match &input.data { + Data::Struct(s) => derive_struct(s), + Data::Enum(e) => derive_enum(e), Data::Union(_) => return quote!(compile_error!("Unions are unsupported");), }; quote! { - impl #krate::ConsoleFmt for #name { + impl ::foundry_macros::ConsoleFmt for #name { #tokens } } } -fn derive_struct(s: DataStruct, krate: &Path) -> TokenStream { - let imp = impl_struct(s, krate).unwrap_or_else(|| quote!(String::new())); +fn derive_struct(s: &DataStruct) -> TokenStream { + let imp = impl_struct(s).unwrap_or_else(|| quote!(String::new())); quote! { - fn fmt(&self, _spec: #krate::FormatSpec) -> String { + fn fmt(&self, _spec: ::foundry_macros::FormatSpec) -> String { #imp } } } -fn impl_struct(s: DataStruct, krate: &Path) -> Option { - let fields: Punctuated = match s.fields { - Fields::Named(fields) => fields.named.into_iter(), - Fields::Unnamed(fields) => fields.unnamed.into_iter(), +fn impl_struct(s: &DataStruct) -> Option { + let fields: Punctuated<&Field, Token![,]> = match &s.fields { + Fields::Named(fields) => fields.named.iter(), + Fields::Unnamed(fields) => fields.unnamed.iter(), Fields::Unit => return None, } .collect(); @@ -51,7 +49,7 @@ fn impl_struct(s: DataStruct, krate: &Path) -> Option { .into_iter() .enumerate() .map(|(i, field)| { - let ident = field.ident.unwrap_or_else(|| format_ident!("{i}")); + let ident = field.ident.as_ref().cloned().unwrap_or_else(|| format_ident!("{i}")); quote!(&self.#ident) }) .collect(); @@ -63,14 +61,14 @@ fn impl_struct(s: DataStruct, krate: &Path) -> Option { let first = first.value(); let n = n - 1; quote! { - let args: [&dyn #krate::ConsoleFmt; #n] = [#(#args)*]; - #krate::console_format((#first).as_str(), args) + let args: [&dyn ::foundry_macros::ConsoleFmt; #n] = [#(#args)*]; + ::foundry_macros::console_format((#first).as_str(), args) } } else { // console_format("", [...args]) quote! { - let args: [&dyn #krate::ConsoleFmt; #n] = [#args]; - #krate::console_format("", args) + let args: [&dyn ::foundry_macros::ConsoleFmt; #n] = [#args]; + ::foundry_macros::console_format("", args) } }; @@ -78,18 +76,20 @@ fn impl_struct(s: DataStruct, krate: &Path) -> Option { } /// Delegates to variants. -fn derive_enum(e: DataEnum, krate: &Path) -> TokenStream { - let arms = e.variants.into_iter().map(|variant| { - let name = variant.ident; - let (fields, delimiter) = match variant.fields { - Fields::Named(fields) => (fields.named.into_iter(), Delimiter::Brace), - Fields::Unnamed(fields) => (fields.unnamed.into_iter(), Delimiter::Parenthesis), +fn derive_enum(e: &DataEnum) -> TokenStream { + let arms = e.variants.iter().map(|variant| { + let name = &variant.ident; + let (fields, delimiter) = match &variant.fields { + Fields::Named(fields) => (fields.named.iter(), Delimiter::Brace), + Fields::Unnamed(fields) => (fields.unnamed.iter(), Delimiter::Parenthesis), Fields::Unit => return quote!(), }; let fields: Punctuated = fields .enumerate() - .map(|(i, field)| field.ident.unwrap_or_else(|| format_ident!("__var_{i}"))) + .map(|(i, field)| { + field.ident.as_ref().cloned().unwrap_or_else(|| format_ident!("__var_{i}")) + }) .collect(); if fields.len() != 1 { @@ -99,12 +99,12 @@ fn derive_enum(e: DataEnum, krate: &Path) -> TokenStream { let field = fields.into_iter().next().unwrap(); let fields = Group::new(delimiter, quote!(#field)); quote! { - Self::#name #fields => #krate::ConsoleFmt::fmt(#field, spec), + Self::#name #fields => ::foundry_macros::ConsoleFmt::fmt(#field, spec), } }); quote! { - fn fmt(&self, spec: #krate::FormatSpec) -> String { + fn fmt(&self, spec: ::foundry_macros::FormatSpec) -> String { match self { #(#arms)* diff --git a/crates/macros/impl/src/lib.rs b/crates/macros/impl/src/lib.rs index c56e51060bc4c..cf947684a5b1f 100644 --- a/crates/macros/impl/src/lib.rs +++ b/crates/macros/impl/src/lib.rs @@ -1,9 +1,6 @@ #![warn(unused_crate_dependencies)] mod console_fmt; -mod utils; - -pub(crate) use utils::*; use proc_macro::TokenStream; use syn::{parse_macro_input, DeriveInput}; @@ -11,5 +8,5 @@ use syn::{parse_macro_input, DeriveInput}; #[proc_macro_derive(ConsoleFmt)] pub fn console_fmt(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - console_fmt::console_fmt(input).into() + console_fmt::console_fmt(&input).into() } diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index c1b94f5b6a141..6c37eaacacc53 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -4,6 +4,8 @@ #![warn(unused_crate_dependencies)] +extern crate self as foundry_macros; + pub mod fmt; pub use fmt::{console_format, ConsoleFmt, FormatSpec, TokenDisplay, UIfmt}; From 1ada785fc0cf9dc6083ba6bfa4068ff32f7c1732 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 7 Oct 2023 10:59:40 +0200 Subject: [PATCH 0150/1963] ci: add concurrency (#6003) --- .github/workflows/project.yml | 1 + .github/workflows/test.yml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 9d450c2b757d2..dd2899dd36972 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -1,4 +1,5 @@ name: project + on: issues: types: [opened, transferred] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a92fcdc18a158..08fb48197472b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,14 @@ +name: test + on: push: branches: - master pull_request: -name: test +concurrency: + cancel-in-progress: true + group: ${{github.workflow}}-${{github.ref}} env: CARGO_TERM_COLOR: always From fcae63a03e6a2fc6b0b8ecdb64bcef259c0d7f54 Mon Sep 17 00:00:00 2001 From: evalir Date: Sat, 7 Oct 2023 19:48:17 +0900 Subject: [PATCH 0151/1963] chore(deps): use latest revm release instead of patch (#6005) --- Cargo.lock | 12 ++++++++---- Cargo.toml | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c7ca4054884e..ec3aed8c9fc56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5477,7 +5477,8 @@ dependencies = [ [[package]] name = "revm" version = "3.5.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f4ca8ae0345104523b4af1a8a7ea97cfa1865cdb7a7c25d23c1a18d9b48598" dependencies = [ "auto_impl", "revm-interpreter", @@ -5489,7 +5490,8 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f959cafdf64a7f89b014fa73dc2325001cf654b3d9400260b212d19a2ebe3da0" dependencies = [ "revm-primitives", "serde", @@ -5498,7 +5500,8 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.2.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d360a88223d85709d2e95d4609eb1e19c649c47e28954bfabae5e92bb37e83e" dependencies = [ "c-kzg", "k256", @@ -5514,7 +5517,8 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm/?branch=main#23cbac479f616eba5ab11ddfe6d5814b9c492202" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51187b852d9e458816a2e19c81f1dd6c924077e1a8fccd16e4f044f865f299d7" dependencies = [ "alloy-primitives", "alloy-rlp", diff --git a/Cargo.toml b/Cargo.toml index 90cdfcf382b51..d58fa6f594647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -191,10 +191,10 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs" } ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs" } -revm = { git = "https://github.com/bluealloy/revm/", branch = "main" } -revm-interpreter = { git = "https://github.com/bluealloy/revm/", branch = "main" } -revm-precompile = { git = "https://github.com/bluealloy/revm/", branch = "main" } -revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "main" } +# revm = { git = "https://github.com/bluealloy/revm/", branch = "main" } +# revm-interpreter = { git = "https://github.com/bluealloy/revm/", branch = "main" } +# revm-precompile = { git = "https://github.com/bluealloy/revm/", branch = "main" } +# revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "main" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/", branch = "main"} alloy-primitives = { git = "https://github.com/alloy-rs/core/", branch = "main"} From 316b6e752d977f8d249469aa111b82adbae3d2d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:14:15 +0200 Subject: [PATCH 0152/1963] chore(deps): weekly `cargo update` (#6007) Updating git repository `https://github.com/alloy-rs/core/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating alloy-dyn-abi v0.4.0 (https://github.com/alloy-rs/core/?branch=main#fe4a5353) -> #88ef37f6 Updating alloy-json-abi v0.4.0 (https://github.com/alloy-rs/core/?branch=main#fe4a5353) -> #88ef37f6 Updating alloy-primitives v0.4.0 (https://github.com/alloy-rs/core/?branch=main#fe4a5353) -> #88ef37f6 Updating alloy-sol-macro v0.4.0 (https://github.com/alloy-rs/core/?branch=main#fe4a5353) -> #88ef37f6 Updating alloy-sol-type-parser v0.4.0 (https://github.com/alloy-rs/core/?branch=main#fe4a5353) -> #88ef37f6 Updating alloy-sol-types v0.4.0 (https://github.com/alloy-rs/core/?branch=main#fe4a5353) -> #88ef37f6 Updating byteorder v1.4.3 -> v1.5.0 Updating cargo-platform v0.1.3 -> v0.1.4 Updating ethers v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-addressbook v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-contract v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-contract-abigen v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-contract-derive v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-core v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-etherscan v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-middleware v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-providers v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-signers v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating ethers-solc v2.0.10 (https://github.com/gakonst/ethers-rs#edf3353c) -> #66dd13c4 Updating libc v0.2.148 -> v0.2.149 Updating libm v0.2.7 -> v0.2.8 Updating num-traits v0.2.16 -> v0.2.17 Updating proc-macro2 v1.0.67 -> v1.0.68 Updating rustix v0.38.15 -> v0.38.17 Updating sharded-slab v0.1.6 -> v0.1.7 Updating similar v2.2.1 -> v2.3.0 Updating syn v2.0.37 -> v2.0.38 Updating syn-solidity v0.4.0 (https://github.com/alloy-rs/core/?branch=main#fe4a5353) -> #88ef37f6 Updating winnow v0.5.15 -> v0.5.16 Co-authored-by: mattsse --- Cargo.lock | 148 ++++++++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec3aed8c9fc56..4abce17aa7be5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,7 +78,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" +source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -96,7 +96,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" +source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" +source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" dependencies = [ "alloy-rlp", "arbitrary", @@ -147,20 +147,20 @@ checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] name = "alloy-sol-macro" version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" +source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" dependencies = [ "const-hex", "dunce", "heck", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "syn-solidity", "tiny-keccak", ] @@ -168,7 +168,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" +source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" dependencies = [ "winnow", ] @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" +source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -543,7 +543,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -554,7 +554,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -715,7 +715,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.37", + "syn 2.0.38", "which", ] @@ -849,9 +849,9 @@ checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -909,9 +909,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" dependencies = [ "serde", ] @@ -1163,7 +1163,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1666,7 +1666,7 @@ checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1901,7 +1901,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -2040,7 +2040,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2055,7 +2055,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "ethers-core", "once_cell", @@ -2066,7 +2066,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2084,7 +2084,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "Inflector", "const-hex", @@ -2099,7 +2099,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.37", + "syn 2.0.38", "toml 0.8.2", "walkdir", ] @@ -2107,7 +2107,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "Inflector", "const-hex", @@ -2116,13 +2116,13 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "arrayvec", "bytes", @@ -2141,7 +2141,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.37", + "syn 2.0.38", "tempfile", "thiserror", "tiny-keccak", @@ -2151,7 +2151,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "ethers-core", "ethers-solc", @@ -2166,7 +2166,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "async-trait", "auto_impl", @@ -2192,7 +2192,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "async-trait", "auto_impl", @@ -2230,7 +2230,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "async-trait", "coins-bip32", @@ -2258,7 +2258,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#edf3353cb419451a5eb2e89685e3e26e10783670" +source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" dependencies = [ "cfg-if", "const-hex", @@ -2345,7 +2345,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -2572,7 +2572,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-macros", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -2758,7 +2758,7 @@ version = "0.2.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -2912,7 +2912,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -3955,9 +3955,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libgit2-sys" @@ -3983,9 +3983,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libusb1-sys" @@ -4193,7 +4193,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4418,9 +4418,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", "libm", @@ -4454,7 +4454,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4558,7 +4558,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4759,7 +4759,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4814,7 +4814,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4917,7 +4917,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4955,7 +4955,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -5049,7 +5049,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -5102,9 +5102,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" dependencies = [ "unicode-ident", ] @@ -5117,7 +5117,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "version_check", "yansi 1.0.0-rc.1", ] @@ -5770,9 +5770,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.15" +version = "0.38.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" +checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" dependencies = [ "bitflags 2.4.0", "errno", @@ -6079,7 +6079,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -6147,7 +6147,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -6214,9 +6214,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] @@ -6275,9 +6275,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" [[package]] name = "simple_asn1" @@ -6453,7 +6453,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -6521,9 +6521,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -6533,12 +6533,12 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#fe4a5353080471fe966df5d12edc71727a03da1e" +source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -6670,7 +6670,7 @@ checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -6783,7 +6783,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -7019,7 +7019,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -7427,7 +7427,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -7461,7 +7461,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7732,9 +7732,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] @@ -7812,7 +7812,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] From fb51f2a80773786033f35a5e12964ce074b2f270 Mon Sep 17 00:00:00 2001 From: Pranesh A S <42379522+PraneshASP@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:47:39 +0530 Subject: [PATCH 0153/1963] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Add=20`--summary?= =?UTF-8?q?`=20flag=20to=20print=20test=20summary=20table=20(#5961)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: test summary table * chore: update comment format * refactor: add test summary reporter struct * chore: remove old code * refactor: add is_detailed option to struct * chore: add help_heading * feat: add conditional coloring to cells * feat: sort based on test suite name * chore: fix fmt and clippy warns * chore: fmt * chore: update column name * some touchups --------- Co-authored-by: Matthias Seitz --- crates/forge/bin/cmd/test/mod.rs | 37 ++++++++- crates/forge/bin/cmd/test/summary.rs | 111 +++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 crates/forge/bin/cmd/test/summary.rs diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3c6b03019e283..8570509875f85 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -1,6 +1,7 @@ use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; use alloy_primitives::U256; use clap::Parser; + use eyre::Result; use forge::{ decode::decode_console_logs, @@ -40,6 +41,9 @@ use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; mod filter; +mod summary; +use summary::TestSummaryReporter; + pub use filter::FilterArgs; // Loads project's figment and merges the build cli arguments into it @@ -109,6 +113,14 @@ pub struct TestArgs { #[clap(flatten)] pub watch: WatchArgs, + + /// Print test summary table + #[clap(long, help_heading = "Display options")] + pub summary: bool, + + /// Print detailed test summary table + #[clap(long, help_heading = "Display options")] + pub detailed: bool, } impl TestArgs { @@ -338,6 +350,11 @@ impl TestArgs { } else if self.list { list(runner, filter, self.json) } else { + if self.detailed && !self.summary { + return Err(eyre::eyre!( + "Missing `--summary` option in your command. You must pass it along with the `--detailed` option to view detailed test summary." + )); + } test( config, runner, @@ -348,6 +365,8 @@ impl TestArgs { test_options, self.gas_report, self.fail_fast, + self.summary, + self.detailed, ) .await } @@ -614,8 +633,11 @@ async fn test( test_options: TestOptions, gas_reporting: bool, fail_fast: bool, + summary: bool, + detailed: bool, ) -> Result { trace!(target: "forge::test", "running all tests"); + if runner.matching_test_function_count(&filter) == 0 { let filter_str = filter.to_string(); if filter_str.is_empty() { @@ -663,6 +685,7 @@ async fn test( let mut total_passed = 0; let mut total_failed = 0; let mut total_skipped = 0; + let mut suite_results: Vec = Vec::new(); 'outer: for (contract_name, suite_result) in rx { results.insert(contract_name.clone(), suite_result.clone()); @@ -754,13 +777,18 @@ async fn test( gas_report.analyze(&result.traces); } } - let block_outcome = TestOutcome::new([(contract_name, suite_result)].into(), allow_failure); + let block_outcome = + TestOutcome::new([(contract_name.clone(), suite_result)].into(), allow_failure); total_passed += block_outcome.successes().count(); total_failed += block_outcome.failures().count(); total_skipped += block_outcome.skips().count(); println!("{}", block_outcome.summary()); + + if summary { + suite_results.push(block_outcome.clone()); + } } if gas_reporting { @@ -774,12 +802,19 @@ async fn test( "{}", format_aggregated_summary(num_test_suites, total_passed, total_failed, total_skipped) ); + + if summary { + let mut summary_table = TestSummaryReporter::new(detailed); + println!("\n\nTest Summary:"); + summary_table.print_summary(suite_results); + } } // reattach the thread let _results = handle.await?; trace!(target: "forge::test", "received {} results", results.len()); + Ok(TestOutcome::new(results, allow_failure)) } diff --git a/crates/forge/bin/cmd/test/summary.rs b/crates/forge/bin/cmd/test/summary.rs new file mode 100644 index 0000000000000..5f8bd9650bd8b --- /dev/null +++ b/crates/forge/bin/cmd/test/summary.rs @@ -0,0 +1,111 @@ +use crate::cmd::test::TestOutcome; +use comfy_table::{ + modifiers::UTF8_ROUND_CORNERS, Attribute, Cell, CellAlignment, Color, Row, Table, +}; + +/// A simple summary reporter that prints the test results in a table. +pub struct TestSummaryReporter { + /// The test summary table. + pub(crate) table: Table, + pub(crate) is_detailed: bool, +} + +impl TestSummaryReporter { + pub(crate) fn new(is_detailed: bool) -> Self { + let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); + let mut row = Row::from(vec![ + Cell::new("Test Suite") + .set_alignment(CellAlignment::Center) + .add_attribute(Attribute::Bold), + Cell::new("Passed") + .set_alignment(CellAlignment::Center) + .add_attribute(Attribute::Bold) + .fg(Color::Green), + Cell::new("Failed") + .set_alignment(CellAlignment::Center) + .add_attribute(Attribute::Bold) + .fg(Color::Red), + Cell::new("Skipped") + .set_alignment(CellAlignment::Center) + .add_attribute(Attribute::Bold) + .fg(Color::Yellow), + ]); + if is_detailed { + row.add_cell( + Cell::new("File Path") + .set_alignment(CellAlignment::Center) + .add_attribute(Attribute::Bold), + ); + row.add_cell( + Cell::new("Duration") + .set_alignment(CellAlignment::Center) + .add_attribute(Attribute::Bold), + ); + } + table.set_header(row); + + Self { table, is_detailed } + } + + pub(crate) fn print_summary(&mut self, mut test_results: Vec) { + // Sort by suite name first + + // Using `sort_by_cached_key` so that the key extraction logic runs only once + test_results.sort_by_cached_key(|test_outcome| { + test_outcome + .results + .keys() + .next() + .and_then(|suite| suite.split(':').nth(1)) + .unwrap() + .to_string() + }); + + // Traverse the test_results vector and build the table + for suite in &test_results { + for contract in suite.results.keys() { + let mut row = Row::new(); + let suite_name = contract.split(':').nth(1).unwrap(); + let suite_path = contract.split(':').nth(0).unwrap(); + + let passed = suite.successes().count(); + let mut passed_cell = Cell::new(passed).set_alignment(CellAlignment::Center); + + let failed = suite.failures().count(); + let mut failed_cell = Cell::new(failed).set_alignment(CellAlignment::Center); + + let skipped = suite.skips().count(); + let mut skipped_cell = Cell::new(skipped).set_alignment(CellAlignment::Center); + + let duration = suite.duration(); + + row.add_cell(Cell::new(suite_name)); + + if passed > 0 { + passed_cell = passed_cell.fg(Color::Green); + } + row.add_cell(passed_cell); + + if failed > 0 { + failed_cell = failed_cell.fg(Color::Red); + } + row.add_cell(failed_cell); + + if skipped > 0 { + skipped_cell = skipped_cell.fg(Color::Yellow); + } + row.add_cell(skipped_cell); + + if self.is_detailed { + row.add_cell(Cell::new(suite_path)); + row.add_cell(Cell::new(format!("{:.2?}", duration).to_string())); + } + + self.table.add_row(row); + } + } + // Print the summary table + println!("\n{}", self.table); + } +} From f9ca6ecefe48c396433df2e55361ed5c9b06de5e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 8 Oct 2023 22:33:18 +0200 Subject: [PATCH 0154/1963] fix: correct check for scientific notation (#6009) --- Cargo.lock | 1 + .../src/executor/inspector/cheatcodes/ext.rs | 8 +++-- .../src/executor/inspector/cheatcodes/mod.rs | 2 +- crates/forge/Cargo.toml | 1 + crates/forge/tests/it/config.rs | 7 ++++ crates/forge/tests/it/repros.rs | 6 ++++ testdata/repros/Issue6006.t.sol | 35 +++++++++++++++++++ 7 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 testdata/repros/Issue6006.t.sol diff --git a/Cargo.lock b/Cargo.lock index 4abce17aa7be5..017196c0d0460 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2505,6 +2505,7 @@ dependencies = [ "thiserror", "tokio", "tracing", + "tracing-subscriber", "vergen", "watchexec", "yansi 0.5.1", diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index 0ce26a1e5af80..0398935d4007c 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -239,11 +239,11 @@ pub fn value_to_token(value: &Value) -> Result { // Example: 18446744073709551615 becomes 18446744073709552000 after parsing it // to f64. let s = number.to_string(); - // Coerced to scientific notation, so short-ciruit to using fallback. // This will not have a problem with hex numbers, as for parsing these // We'd need to prefix this with 0x. - if s.starts_with("1e") { + // See also + if s.contains('e') { // Calling Number::to_string with powers of ten formats the number using // scientific notation and causes from_dec_str to fail. Using format! with // f64 keeps the full number representation. @@ -312,6 +312,7 @@ fn encode_abi_values(values: Vec) -> Vec { /// Parses a vector of [`Value`]s into a vector of [`DynSolValue`]s. fn parse_json_values(values: Vec<&Value>, key: &str) -> Result> { + trace!(?values, %key, "parseing json values"); values .iter() .map(|inner| { @@ -325,6 +326,7 @@ fn parse_json_values(values: Vec<&Value>, key: &str) -> Result> /// deserialized in the same order. That means that the solidity `struct` should order it's fields /// alphabetically and not by efficient packing or some other taxonomy. fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { + trace!(%json_str, %key, ?coerce, "parsing json"); let json = serde_json::from_str(json_str).map_err(|err| fmt_err!("Failed to parse JSON: {err}"))?; match key { @@ -340,6 +342,8 @@ fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { } _ => { let values = jsonpath_lib::select(&json, &canonicalize_json_key(key))?; + trace!(?values, "selected json values"); + // values is an array of items. Depending on the JsonPath key, they // can be many or a single item. An item can be a single value or // an entire JSON object. diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 81c8c3b80fdf4..9dab9c7f0e737 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -206,7 +206,7 @@ impl Cheatcodes { Self { config, fs_commit: true, ..Default::default() } } - #[instrument(level = "error", name = "apply", target = "evm::cheatcodes", skip_all)] + #[instrument(level = "error", name = "apply", skip_all)] fn apply_cheatcode( &mut self, data: &mut EVMData<'_, DB>, diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 3f2fc2697620f..e195c1be21b1c 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -75,6 +75,7 @@ path-slash = "0.2" pretty_assertions = "1" serial_test = "2" svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } +tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } [features] default = ["rustls"] diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index da56c326ba103..31c21f0609f2e 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -132,6 +132,13 @@ pub fn test_opts() -> TestOptions { } } +#[allow(unused)] +pub(crate) fn init_tracing() { + let _ = tracing_subscriber::FmtSubscriber::builder() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .try_init(); +} + pub fn manifest_root() -> PathBuf { let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); // need to check here where we're executing the test from, if in `forge` we need to also allow diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index b46a46abb360c..73d0d64e23ee4 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -290,6 +290,12 @@ async fn test_issue_3792() { test_repro!("Issue3792"); } +// +#[tokio::test(flavor = "multi_thread")] +async fn test_issue_6006() { + test_repro!("Issue6006"); +} + // #[tokio::test(flavor = "multi_thread")] async fn test_issue_5808() { diff --git a/testdata/repros/Issue6006.t.sol b/testdata/repros/Issue6006.t.sol new file mode 100644 index 0000000000000..63e2cd5c6232f --- /dev/null +++ b/testdata/repros/Issue6006.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6006 +contract Issue6066Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_parse_11e20_sci() public { + string memory json = '{"value": 1.1e20}'; + bytes memory parsed = vm.parseJson(json); + Value memory data = abi.decode(parsed, (Value)); + assertEq(data.value, 1.1e20); + } + + function test_parse_22e20_sci() public { + string memory json = '{"value": 2.2e20}'; + bytes memory parsed = vm.parseJson(json); + Value memory data = abi.decode(parsed, (Value)); + assertEq(data.value, 2.2e20); + } + + function test_parse_2e_sci() public { + string memory json = '{"value": 2e10}'; + bytes memory parsed = vm.parseJson(json); + Value memory data = abi.decode(parsed, (Value)); + assertEq(data.value, 2e10); + } +} + +struct Value { + uint256 value; +} From 94f82d5050c89348e3b11a130b032ab82fcff748 Mon Sep 17 00:00:00 2001 From: WardenJakx <114708157+WardenJakx@users.noreply.github.com> Date: Mon, 9 Oct 2023 04:07:35 -0400 Subject: [PATCH 0155/1963] fix prevrando on `cast run` (#6011) --- crates/cast/bin/cmd/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index ee6f94ef23ce5..e5ae74615de27 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -127,7 +127,7 @@ impl RunArgs { env.block.timestamp = block.timestamp.to_alloy(); env.block.coinbase = block.author.unwrap_or_default().to_alloy(); env.block.difficulty = block.difficulty.to_alloy(); - env.block.prevrandao = block.mix_hash.map(|h| h.to_alloy()); + env.block.prevrandao = Some(block.mix_hash.map(|h| h.to_alloy()).unwrap_or_default()); env.block.basefee = block.base_fee_per_gas.unwrap_or_default().to_alloy(); env.block.gas_limit = block.gas_limit.to_alloy(); } From 9cc1a81d2766d8ef767b7e8557531bd16adc9ae8 Mon Sep 17 00:00:00 2001 From: WardenJakx <114708157+WardenJakx@users.noreply.github.com> Date: Mon, 9 Oct 2023 04:07:45 -0400 Subject: [PATCH 0156/1963] remove json file write (#6012) --- crates/cast/bin/cmd/run.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index e5ae74615de27..0d5833cdc116d 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -132,8 +132,6 @@ impl RunArgs { env.block.gas_limit = block.gas_limit.to_alloy(); } - std::fs::write("block.json", serde_json::to_string_pretty(&block).unwrap()).unwrap(); - // Set the state to the moment right before the transaction if !self.quick { println!("Executing previous transactions from the block."); From 8055d573fbc48b90dc66f0dbd9c38370db553534 Mon Sep 17 00:00:00 2001 From: Devan Non <89424366+devanoneth@users.noreply.github.com> Date: Mon, 9 Oct 2023 13:55:01 +0200 Subject: [PATCH 0157/1963] fix: remove println in get_env function (#6015) --- crates/evm/src/executor/inspector/cheatcodes/ext.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index 0398935d4007c..609463b36eedf 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -200,7 +200,6 @@ fn get_env(key: &str, ty: DynSolType, delim: Option<&str>, default: Option Date: Mon, 9 Oct 2023 19:40:45 +0200 Subject: [PATCH 0158/1963] chore(deps): bump Alloy to crates.io 0.4.2 (#6016) --- Cargo.lock | 125 +++++++++++++++++++++++++++++++---------------------- Cargo.toml | 16 +++---- 2 files changed, 79 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 017196c0d0460..a58c8fb76feeb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -77,8 +77,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" -version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e0daba57ddaba12dc9b21f608b843251f3de017f94a431dca4e7f4f72e5ba9" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -95,8 +96,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63c9319ad8b2b623c6a3ac15899f8ffb71479224762dbaedc385c16efbb6cfe3" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -106,8 +108,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0628ec0ba5b98b3370bb6be17b12f23bfce8ee4ad83823325a20546d9b03b78" dependencies = [ "alloy-rlp", "arbitrary", @@ -152,12 +155,14 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a98ad1696a2e17f010ae8e43e9f2a1e930ed176a8e3ff77acfeff6dfb07b42c" dependencies = [ "const-hex", "dunce", "heck", + "proc-macro-error", "proc-macro2", "quote", "syn 2.0.38", @@ -167,16 +172,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81c61ccc29e7c58bf16a2f780898852348183f58b127bde03ced6d07ad544787" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98d7107bed88e8f09f0ddcc3335622d87bfb6821f3e0c7473329fb1cfad5e015" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -1925,25 +1932,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys 0.48.0", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "error-code" version = "2.3.1" @@ -3851,7 +3847,7 @@ checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ "base64 0.21.4", "pem", - "ring", + "ring 0.16.20", "serde", "serde_json", "simple_asn1", @@ -3945,7 +3941,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] @@ -4014,9 +4010,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" @@ -5103,9 +5099,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -5552,12 +5548,26 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "911b295d2d302948838c8ac142da1ee09fa7863163b44e6715bc9357905878b8" +dependencies = [ + "cc", + "getrandom 0.2.10", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -5771,9 +5781,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.17" +version = "0.38.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" +checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" dependencies = [ "bitflags 2.4.0", "errno", @@ -5789,7 +5799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", - "ring", + "ring 0.16.20", "sct", "webpki", ] @@ -5801,7 +5811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", - "ring", + "ring 0.16.20", "rustls-webpki", "sct", ] @@ -5833,8 +5843,8 @@ version = "0.101.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -5965,8 +5975,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -6362,6 +6372,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.2" @@ -6533,8 +6549,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.4.0" -source = "git+https://github.com/alloy-rs/core/?branch=main#88ef37f68305aed254f2580d7ff3ac500ebe0c1c" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b837ef12ab88835251726eb12237655e61ec8dc8a280085d1961cdc3dfd047" dependencies = [ "paste", "proc-macro2", @@ -6759,9 +6776,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", @@ -7274,6 +7291,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.1" @@ -7533,12 +7556,12 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.2" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring", - "untrusted", + "ring 0.17.2", + "untrusted 0.9.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d58fa6f594647..d242337108eaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,7 +137,7 @@ foundry-debugger = { path = "crates/debugger" } ## revm # no default features to avoid c-kzg revm = { version = "3", default-features = false } # -revm-primitives = { version = "1" , default-features = false } +revm-primitives = { version = "1", default-features = false } ## ethers ethers = { version = "2.0", default-features = false } @@ -152,11 +152,10 @@ ethers-etherscan = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy - -alloy-primitives = { version = "0.4", default-features = false } -alloy-dyn-abi = { version = "0.4", default-features = false } -alloy-json-abi = { version = "0.4", default-features = false } -alloy-sol-types = { version = "0.4", default-features = false } +alloy-primitives = "0.4.1" +alloy-dyn-abi = "0.4.1" +alloy-json-abi = "0.4.1" +alloy-sol-types = "0.4.1" solang-parser = "=0.3.2" @@ -195,8 +194,3 @@ ethers-solc = { git = "https://github.com/gakonst/ethers-rs" } # revm-interpreter = { git = "https://github.com/bluealloy/revm/", branch = "main" } # revm-precompile = { git = "https://github.com/bluealloy/revm/", branch = "main" } # revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "main" } - -alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/", branch = "main"} -alloy-primitives = { git = "https://github.com/alloy-rs/core/", branch = "main"} -alloy-json-abi = { git = "https://github.com/alloy-rs/core/", branch = "main"} -alloy-sol-types = { git = "https://github.com/alloy-rs/core/", branch = "main"} From e30993e3c07e4a900558c64cd7f1dfc056fabf12 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 10 Oct 2023 18:14:49 +0200 Subject: [PATCH 0159/1963] fix: get_proof encoding bug (#6020) * fix: get_proof encoding bug * return key as is * update test --- crates/anvil/src/eth/backend/mem/mod.rs | 30 ++++++++++++++++++++----- crates/anvil/tests/it/proof/mod.rs | 12 +++++++--- testdata/cheats/Fork2.t.sol | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index cea99ed1ecc55..f8d83a8c15c96 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2079,7 +2079,7 @@ impl Backend { pub async fn prove_account_at( &self, address: Address, - values: Vec, + keys: Vec, block_request: Option, ) -> Result { let account_key = H256::from(keccak256(address.as_bytes())); @@ -2106,8 +2106,17 @@ impl Backend { }; let account = maybe_account.unwrap_or_default(); - let proof = - recorder.drain().into_iter().map(|r| r.data).map(Into::into).collect::>(); + let proof = recorder + .drain() + .into_iter() + .map(|r| r.data) + .map(|record| { + // proof is rlp encoded: + // + // + rlp::encode(&record).to_vec().into() + }) + .collect::>(); let account_db = block_db.maybe_account_db(address).ok_or(BlockchainError::DataUnavailable)?; @@ -2119,15 +2128,24 @@ impl Backend { code_hash: account.code_hash, storage_hash: account.storage_root, account_proof: proof, - storage_proof: values + storage_proof: keys .into_iter() .map(|storage_key| { + // the key that should be proofed is the keccak256 of the storage key let key = H256::from(keccak256(storage_key)); prove_storage(&account, &account_db.0, key).map( |(storage_proof, storage_value)| StorageProof { - key, + key: storage_key, value: storage_value.into_uint(), - proof: storage_proof.into_iter().map(Into::into).collect(), + proof: storage_proof + .into_iter() + .map(|proof| { + // proof is rlp encoded: + // + // + rlp::encode(&proof).to_vec().into() + }) + .collect(), }, ) }) diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs index a85a1bacacf51..78e90e064f0db 100644 --- a/crates/anvil/tests/it/proof/mod.rs +++ b/crates/anvil/tests/it/proof/mod.rs @@ -39,7 +39,11 @@ async fn can_get_proof() { let rlp_account = rlp::encode(&account); let root: H256 = api.state_root().await.unwrap(); - let acc_proof: Vec> = proof.account_proof.into_iter().map(|b| b.to_vec()).collect(); + let acc_proof: Vec> = proof + .account_proof + .into_iter() + .map(|node| rlp::decode::>(&node).unwrap()) + .collect(); verify_proof::( &root.0, @@ -52,11 +56,13 @@ async fn can_get_proof() { assert_eq!(proof.storage_proof.len(), 1); let expected_value = rlp::encode(&value); let proof = proof.storage_proof[0].clone(); - let storage_proof: Vec> = proof.proof.into_iter().map(|b| b.to_vec()).collect(); + let storage_proof: Vec> = + proof.proof.into_iter().map(|node| rlp::decode::>(&node).unwrap()).collect(); + let key = H256::from(keccak256(proof.key.as_bytes())); verify_proof::( &account.storage_root.0, &storage_proof, - proof.key.as_bytes(), + key.as_bytes(), Some(expected_value.as_ref()), ) .unwrap(); diff --git a/testdata/cheats/Fork2.t.sol b/testdata/cheats/Fork2.t.sol index 6d9237e9978e5..eb313fd5d014a 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/cheats/Fork2.t.sol @@ -225,7 +225,7 @@ contract ForkTest is DSTest { string memory path = "fixtures/Rpc/balance_params.json"; string memory file = vm.readFile(path); bytes memory result = vm.rpc("eth_getBalance", file); - assertEq(result, hex"34f4d7c595f11e"); + assertEq(result, hex"3582f71d817d46"); } } From 846d3262d6e0e953993be38a61e2ab4a87d697e7 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 11 Oct 2023 00:42:48 +0200 Subject: [PATCH 0160/1963] chore: bump ethers (#6021) --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a58c8fb76feeb..4b85bc9562ffe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2036,7 +2036,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "ethers-core", "once_cell", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2080,7 +2080,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "Inflector", "const-hex", @@ -2103,7 +2103,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "Inflector", "const-hex", @@ -2118,7 +2118,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "arrayvec", "bytes", @@ -2147,7 +2147,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "ethers-core", "ethers-solc", @@ -2162,7 +2162,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "async-trait", "auto_impl", @@ -2188,7 +2188,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "async-trait", "auto_impl", @@ -2226,7 +2226,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "async-trait", "coins-bip32", @@ -2254,7 +2254,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#66dd13c406975cbe8cac18185ca63b369a0934fd" +source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" dependencies = [ "cfg-if", "const-hex", From deae4f1f37a3ef081b62d7488e876d1a5bec815e Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Tue, 10 Oct 2023 16:33:36 -0700 Subject: [PATCH 0161/1963] feat(forge-bind): `add_derives` for serde in contract bindings (#5836) * feat: `add_derives` for serde * fix: include dependencies for crate bindings * serde 1.0 * smol touchup --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 22 +++++++++++----------- crates/forge/bin/cmd/bind.rs | 10 +++++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b85bc9562ffe..9f4ee8c43b872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2036,7 +2036,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "ethers-core", "once_cell", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2080,7 +2080,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "Inflector", "const-hex", @@ -2103,7 +2103,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "Inflector", "const-hex", @@ -2118,7 +2118,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "arrayvec", "bytes", @@ -2147,7 +2147,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "ethers-core", "ethers-solc", @@ -2162,7 +2162,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "async-trait", "auto_impl", @@ -2188,7 +2188,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "async-trait", "auto_impl", @@ -2226,7 +2226,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "async-trait", "coins-bip32", @@ -2254,7 +2254,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#1d4a11231dc3c2b3c231b42e4864100c1f09ca64" +source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" dependencies = [ "cfg-if", "const-hex", diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 237af98b87534..1a88d20289c96 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -111,7 +111,7 @@ impl BindArgs { "console[2]?", "CommonBase", "Components", - "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Assertions|Storage(Safe)?)", + "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Storage(Safe)?)", "[Vv]m.*", ]) .extend_names(["IMulticall3"]) @@ -131,7 +131,11 @@ impl BindArgs { Some(path) } }) - .map(Abigen::from_file) + .map(|x| { + Abigen::from_file(x)? + .add_derive("serde::Serialize")? + .add_derive("serde::Deserialize") + }) .collect::, _>>()?; let multi = MultiAbigen::from_abigens(abigens).with_filter(self.get_filter()); @@ -168,7 +172,7 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin let bindings = self.get_multi(&artifacts)?.build()?; println!("Generating bindings for {} contracts", bindings.len()); if !self.module { - bindings.write_to_crate( + bindings.dependencies([r#"serde = "1""#]).write_to_crate( &self.crate_name, &self.crate_version, self.bindings_root(&artifacts), From 5068b7a06df7d25afe22ecd8b433b9ecfec2810a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 12 Oct 2023 00:14:58 +0200 Subject: [PATCH 0162/1963] chore: convert panics into errors (#6031) --- crates/forge/bin/cmd/script/executor.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index b2cb4868d3b32..8e241b5bdec70 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -43,8 +43,14 @@ impl ScriptArgs { let CompactContractBytecode { abi, bytecode, .. } = contract; - let abi = abi.expect("no ABI for contract"); - let bytecode = bytecode.expect("no bytecode for contract").object.into_bytes().unwrap(); + let abi = abi.ok_or_else(|| eyre::eyre!("no ABI found for contract"))?; + let bytecode = bytecode + .ok_or_else(|| eyre::eyre!("no bytecode found for contract"))? + .object + .into_bytes() + .ok_or_else(|| { + eyre::eyre!("expected fully linked bytecode, found unlinked bytecode") + })?; ensure_clean_constructor(&abi)?; From 4b1809c26c641b6d7da6aa7494349a7786825c0b Mon Sep 17 00:00:00 2001 From: Devan Non <89424366+devanoneth@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:10:59 +0200 Subject: [PATCH 0163/1963] feat(anvil): resume work on anvil reset starting a fork (#6026) * resume work on anvil reset starting a fork * change db properly in anvil backend --- crates/anvil/src/cmd.rs | 6 +- crates/anvil/src/config.rs | 67 ++++++++++++------- crates/anvil/src/eth/backend/db.rs | 29 +++++++- crates/anvil/src/eth/backend/fork.rs | 8 +-- crates/anvil/src/eth/backend/genesis.rs | 2 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 23 ++++++- .../anvil/src/eth/backend/mem/in_memory_db.rs | 24 ++++++- crates/anvil/src/eth/backend/mem/mod.rs | 19 +++--- crates/anvil/tests/it/fork.rs | 23 +++++-- 9 files changed, 149 insertions(+), 52 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 00762c8e190f6..412ad3650308a 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -288,7 +288,11 @@ impl NodeArgs { // this will make sure that the fork RPC cache is flushed if caching is configured if let Some(fork) = fork.take() { trace!("flushing cache on shutdown"); - fork.database.read().await.flush_cache(); + fork.database + .read() + .await + .maybe_flush_cache() + .expect("Could not flush cache on fork DB"); // cleaning up and shutting down // this will make sure that the fork RPC cache is flushed if caching is configured } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index d82e76678c503..7c588b57ace31 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -804,11 +804,11 @@ impl NodeConfig { }; let fees = FeeManager::new(env.cfg.spec_id, self.get_base_fee(), self.get_gas_price()); - let (db, fork): (Arc>, Option) = + let (db, fork): (Arc>>, Option) = if let Some(eth_rpc_url) = self.eth_rpc_url.clone() { self.setup_fork_db(eth_rpc_url, &mut env, &fees).await } else { - (Arc::new(tokio::sync::RwLock::new(MemDb::default())), None) + (Arc::new(tokio::sync::RwLock::new(Box::::default())), None) }; // if provided use all settings of `genesis.json` @@ -861,7 +861,8 @@ impl NodeConfig { } /// Configures everything related to forking based on the passed `eth_rpc_url`: - /// - returning a tuple of a [ForkedDatabase](ForkedDatabase) and [ClientFork](ClientFork) + /// - returning a tuple of a [ForkedDatabase](ForkedDatabase) wrapped in an [Arc](Arc) + /// [RwLock](tokio::sync::RwLock) and [ClientFork](ClientFork) wrapped in an [Option](Option) /// which can be used in a [Backend](mem::Backend) to fork from. /// - modifying some parameters of the passed `env` /// - mutating some members of `self` @@ -870,7 +871,29 @@ impl NodeConfig { eth_rpc_url: String, env: &mut revm::primitives::Env, fees: &FeeManager, - ) -> (Arc>, Option) { + ) -> (Arc>>, Option) { + let (db, config) = self.setup_fork_db_config(eth_rpc_url, env, fees).await; + + let db: Arc>> = + Arc::new(tokio::sync::RwLock::new(Box::new(db))); + + let fork = ClientFork::new(config, Arc::clone(&db)); + + (db, Some(fork)) + } + + /// Configures everything related to forking based on the passed `eth_rpc_url`: + /// - returning a tuple of a [ForkedDatabase](ForkedDatabase) and + /// [ClientForkConfig](ClientForkConfig) which can be used to build a + /// [ClientFork](ClientFork) to fork from. + /// - modifying some parameters of the passed `env` + /// - mutating some members of `self` + pub async fn setup_fork_db_config( + &mut self, + eth_rpc_url: String, + env: &mut revm::primitives::Env, + fees: &FeeManager, + ) -> (ForkedDatabase, ClientForkConfig) { // TODO make provider agnostic let provider = Arc::new( ProviderBuilder::new(ð_rpc_url) @@ -1022,27 +1045,23 @@ latest block number: {latest_block}" Some(fork_block_number.into()), ); - let db = Arc::new(tokio::sync::RwLock::new(ForkedDatabase::new(backend, block_chain_db))); - let fork = ClientFork::new( - ClientForkConfig { - eth_rpc_url, - block_number: fork_block_number, - block_hash, - provider, - chain_id, - override_chain_id, - timestamp: block.timestamp.as_u64(), - base_fee: block.base_fee_per_gas, - timeout: self.fork_request_timeout, - retries: self.fork_request_retries, - backoff: self.fork_retry_backoff, - compute_units_per_second: self.compute_units_per_second, - total_difficulty: block.total_difficulty.unwrap_or_default(), - }, - Arc::clone(&db), - ); + let config = ClientForkConfig { + eth_rpc_url, + block_number: fork_block_number, + block_hash, + provider, + chain_id, + override_chain_id, + timestamp: block.timestamp.as_u64(), + base_fee: block.base_fee_per_gas, + timeout: self.fork_request_timeout, + retries: self.fork_request_retries, + backoff: self.fork_retry_backoff, + compute_units_per_second: self.compute_units_per_second, + total_difficulty: block.total_difficulty.unwrap_or_default(), + }; - (db, Some(fork)) + (ForkedDatabase::new(backend, block_chain_db), config) } } diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index fef6d55074844..ff924eff848ca 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -5,13 +5,14 @@ use alloy_primitives::{Address as B160, B256, U256 as rU256}; use anvil_core::eth::trie::KeccakHasher; use ethers::{ prelude::{Address, Bytes}, - types::H256, + types::{BlockId, H256}, utils::keccak256, }; use foundry_common::errors::FsPathError; use foundry_evm::{ executor::{ backend::{snapshot::StateSnapshot, DatabaseError, DatabaseResult, MemDb}, + fork::BlockchainDb, DatabaseRef, }, revm::{ @@ -71,12 +72,24 @@ where fn init_from_snapshot(&mut self, _snapshot: StateSnapshot) {} } +/// Helper trait to reset the DB if it's forked +#[auto_impl::auto_impl(Box)] +pub trait MaybeForkedDatabase { + fn maybe_reset(&mut self, _url: Option, block_number: BlockId) -> Result<(), String>; + + fn maybe_flush_cache(&self) -> Result<(), String>; + + fn maybe_inner(&self) -> Result<&BlockchainDb, String>; +} + /// This bundles all required revm traits +#[auto_impl::auto_impl(Box)] pub trait Db: DatabaseRef + Database + DatabaseCommit + MaybeHashDatabase + + MaybeForkedDatabase + fmt::Debug + Send + Sync @@ -251,6 +264,20 @@ impl> MaybeHashDatabase for CacheDB { } } +impl> MaybeForkedDatabase for CacheDB { + fn maybe_reset(&mut self, _url: Option, _block_number: BlockId) -> Result<(), String> { + Err("not supported".to_string()) + } + + fn maybe_flush_cache(&self) -> Result<(), String> { + Err("not supported".to_string()) + } + + fn maybe_inner(&self) -> Result<&BlockchainDb, String> { + Err("not supported".to_string()) + } +} + /// Represents a state at certain point pub struct StateDb(pub(crate) Box); diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 0445573405d85..7c33888937839 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -1,6 +1,6 @@ //! Support for forking off another client -use crate::eth::{backend::mem::fork_db::ForkedDatabase, error::BlockchainError}; +use crate::eth::{backend::db::Db, error::BlockchainError}; use anvil_core::eth::{proof::AccountProof, transaction::EthTransactionRequest}; use ethers::{ prelude::BlockNumber, @@ -34,14 +34,14 @@ pub struct ClientFork { // endpoints pub config: Arc>, /// This also holds a handle to the underlying database - pub database: Arc>, + pub database: Arc>>, } // === impl ClientFork === impl ClientFork { /// Creates a new instance of the fork - pub fn new(config: ClientForkConfig, database: Arc>) -> Self { + pub fn new(config: ClientForkConfig, database: Arc>>) -> Self { Self { storage: Default::default(), config: Arc::new(RwLock::new(config)), database } } @@ -56,7 +56,7 @@ impl ClientFork { self.database .write() .await - .reset(url.clone(), block_number) + .maybe_reset(url.clone(), block_number) .map_err(BlockchainError::Internal)?; } diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index a9bca220ec016..d72f18c87f51e 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -59,7 +59,7 @@ impl GenesisConfig { /// If an initial `genesis.json` was provided, this applies the account alloc to the db pub fn apply_genesis_json_alloc( &self, - mut db: RwLockWriteGuard<'_, dyn Db>, + mut db: RwLockWriteGuard<'_, Box>, ) -> DatabaseResult<()> { if let Some(ref genesis) = self.genesis_init { for (addr, mut acc) in genesis.alloc.accounts.clone() { diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index caff8da45a8cc..8039442a4286b 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -1,16 +1,17 @@ use crate::{ eth::backend::db::{ - Db, MaybeHashDatabase, SerializableAccountRecord, SerializableState, StateDb, + Db, MaybeForkedDatabase, MaybeHashDatabase, SerializableAccountRecord, SerializableState, + StateDb, }, revm::primitives::AccountInfo, Address, U256, }; -use ethers::prelude::H256; +use ethers::{prelude::H256, types::BlockId}; pub use foundry_evm::executor::fork::database::ForkedDatabase; use foundry_evm::{ executor::{ backend::{snapshot::StateSnapshot, DatabaseResult}, - fork::database::ForkDbSnapshot, + fork::{database::ForkDbSnapshot, BlockchainDb}, }, revm::Database, }; @@ -99,6 +100,7 @@ impl MaybeHashDatabase for ForkedDatabase { *db.block_hashes.write() = block_hashes; } } + impl MaybeHashDatabase for ForkDbSnapshot { fn clear_into_snapshot(&mut self) -> StateSnapshot { std::mem::take(&mut self.snapshot) @@ -113,3 +115,18 @@ impl MaybeHashDatabase for ForkDbSnapshot { self.snapshot = snapshot; } } + +impl MaybeForkedDatabase for ForkedDatabase { + fn maybe_reset(&mut self, url: Option, block_number: BlockId) -> Result<(), String> { + self.reset(url, block_number) + } + + fn maybe_flush_cache(&self) -> Result<(), String> { + self.flush_cache(); + Ok(()) + } + + fn maybe_inner(&self) -> Result<&BlockchainDb, String> { + Ok(self.inner()) + } +} diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index cd23529166185..cd5c7f12af1d7 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -2,20 +2,24 @@ use crate::{ eth::backend::db::{ - AsHashDB, Db, MaybeHashDatabase, SerializableAccountRecord, SerializableState, StateDb, + AsHashDB, Db, MaybeForkedDatabase, MaybeHashDatabase, SerializableAccountRecord, + SerializableState, StateDb, }, mem::state::{state_merkle_trie_root, trie_hash_db}, revm::primitives::AccountInfo, Address, U256, }; -use ethers::prelude::H256; +use ethers::{prelude::H256, types::BlockId}; use foundry_utils::types::{ToAlloy, ToEthers}; use tracing::{trace, warn}; // reexport for convenience use crate::mem::state::storage_trie_db; -use foundry_evm::executor::backend::{snapshot::StateSnapshot, DatabaseResult}; pub use foundry_evm::executor::{backend::MemDb, DatabaseRef}; +use foundry_evm::executor::{ + backend::{snapshot::StateSnapshot, DatabaseResult}, + fork::BlockchainDb, +}; impl Db for MemDb { fn insert_account(&mut self, address: Address, account: AccountInfo) { @@ -115,6 +119,20 @@ impl MaybeHashDatabase for MemDb { } } +impl MaybeForkedDatabase for MemDb { + fn maybe_reset(&mut self, _url: Option, _block_number: BlockId) -> Result<(), String> { + Err("not supported".to_string()) + } + + fn maybe_flush_cache(&self) -> Result<(), String> { + Err("not supported".to_string()) + } + + fn maybe_inner(&self) -> Result<&BlockchainDb, String> { + Err("not supported".to_string()) + } +} + #[cfg(test)] mod tests { use crate::{ diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f8d83a8c15c96..e6da9110c8d61 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -141,7 +141,7 @@ pub struct Backend { /// endpoints. Therefor the `Db` is guarded by a `tokio::sync::RwLock` here so calls that /// need to read from it, while it's currently written to, don't block. E.g. a new block is /// currently mined and a new [`Self::set_storage()`] request is being executed. - db: Arc>, + db: Arc>>, /// stores all block related data in memory blockchain: Blockchain, /// Historic states of previous blocks @@ -174,7 +174,7 @@ impl Backend { /// Initialises the balance of the given accounts #[allow(clippy::too_many_arguments)] pub async fn with_genesis( - db: Arc>, + db: Arc>>, env: Arc>, genesis: GenesisConfig, fees: FeeManager, @@ -337,7 +337,7 @@ impl Backend { } /// Returns the database - pub fn get_db(&self) -> &Arc> { + pub fn get_db(&self) -> &Arc>> { &self.db } @@ -362,15 +362,16 @@ impl Backend { let mut env = self.env.read().clone(); let mut node_config = self.node_config.write().await; - let (_db, forking) = - node_config.setup_fork_db(eth_rpc_url, &mut env, &self.fees).await; - // TODO: Something like this is needed but... - // This won't compile because dyn Db is not Sized (and AFAIK cannot be made Sized) - // *self.db.write().await = *db.read().await; + let (db, config) = + node_config.setup_fork_db_config(eth_rpc_url, &mut env, &self.fees).await; + + *self.db.write().await = Box::new(db); + + let fork = ClientFork::new(config, Arc::clone(&self.db)); *self.env.write() = env; - *self.fork.write() = forking; + *self.fork.write() = Some(fork); } else { return Err(RpcError::invalid_params( "Forking not enabled and RPC URL not provided to start forking", diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index ccce2ada6a9ba..1b0cbca9c38e0 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -20,6 +20,7 @@ use futures::StreamExt; use std::{sync::Arc, time::Duration}; const BLOCK_NUMBER: u64 = 14_608_400u64; +const DEAD_BALANCE_AT_BLOCK_NUMBER: u128 = 12_556_069_338_441_120_059_867u128; const BLOCK_TIMESTAMP: u64 = 1_650_274_250u64; @@ -227,9 +228,14 @@ async fn test_fork_reset_setup() { let (api, handle) = spawn(NodeConfig::test()).await; let provider = handle.http_provider(); + let dead_addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); + let block_number = provider.get_block_number().await.unwrap(); assert_eq!(block_number, 0.into()); + let local_balance = provider.get_balance(dead_addr, None).await.unwrap(); + assert_eq!(local_balance, 0.into()); + api.anvil_reset(Some(Forking { json_rpc_url: Some(rpc::next_http_archive_rpc_endpoint()), block_number: Some(BLOCK_NUMBER), @@ -240,11 +246,8 @@ async fn test_fork_reset_setup() { let block_number = provider.get_block_number().await.unwrap(); assert_eq!(block_number, BLOCK_NUMBER.into()); - // TODO: This won't work because we don't replace the DB with a ForkedDatabase yet - // let addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); - - // let remote_balance = provider.get_balance(addr, None).await.unwrap(); - // assert_eq!(remote_balance, 12556069338441120059867u128.into()); + let remote_balance = provider.get_balance(dead_addr, None).await.unwrap(); + assert_eq!(remote_balance, DEAD_BALANCE_AT_BLOCK_NUMBER.into()); } #[tokio::test(flavor = "multi_thread")] @@ -302,7 +305,15 @@ async fn test_separate_states() { let fork = api.get_fork().unwrap(); let fork_db = fork.database.read().await; - let acc = fork_db.inner().db().accounts.read().get(&addr.to_alloy()).cloned().unwrap(); + let acc = fork_db + .maybe_inner() + .expect("could not get fork db inner") + .db() + .accounts + .read() + .get(&addr.to_alloy()) + .cloned() + .unwrap(); assert_eq!(acc.balance, remote_balance.to_alloy()) } From 0232ee56a20324af443e69b0c42db7c0b12031d8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 13 Oct 2023 13:58:07 +0200 Subject: [PATCH 0164/1963] chore: spawn eth call on blocking task (#6037) * chore: spawn eth call on blocking task * update test --- crates/anvil/src/eth/api.rs | 36 ++++++++++++++++++++++++++++++------ testdata/cheats/Fork2.t.sol | 2 +- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 964f26482f078..80dcb92b48bc9 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -66,9 +66,9 @@ use foundry_evm::{ }, }; use foundry_utils::types::ToEthers; -use futures::channel::mpsc::Receiver; +use futures::channel::{mpsc::Receiver, oneshot}; use parking_lot::RwLock; -use std::{collections::HashSet, sync::Arc, time::Duration}; +use std::{collections::HashSet, future::Future, sync::Arc, time::Duration}; use tracing::{trace, warn}; use super::{backend::mem::BlockRequest, sign::build_typed_transaction}; @@ -939,11 +939,16 @@ impl EthApi { )? .or_zero_fees(); - let (exit, out, gas, _) = - self.backend.call(request, fees, Some(block_request), overrides).await?; - trace!(target : "node", "Call status {:?}, gas {}", exit, gas); + // this can be blocking for a bit, especially in forking mode + // + self.on_blocking_task(|this| async move { + let (exit, out, gas, _) = + this.backend.call(request, fees, Some(block_request), overrides).await?; + trace!(target : "node", "Call status {:?}, gas {}", exit, gas); - ensure_return_ok(exit, &out) + ensure_return_ok(exit, &out) + }) + .await } /// This method creates an EIP2930 type accessList based on a given Transaction. The accessList @@ -1985,6 +1990,25 @@ impl EthApi { // === impl EthApi utility functions === impl EthApi { + /// Executes the future on a new blocking task. + async fn on_blocking_task(&self, c: C) -> Result + where + C: FnOnce(Self) -> F, + F: Future> + Send + 'static, + R: Send + 'static, + { + let (tx, rx) = oneshot::channel(); + let this = self.clone(); + let f = c(this); + tokio::task::spawn_blocking(move || { + tokio::runtime::Handle::current().block_on(async move { + let res = f.await; + let _ = tx.send(res); + }) + }); + rx.await.map_err(|_| BlockchainError::Internal("blocking task panicked".to_string()))? + } + /// Executes the `evm_mine` and returns the number of blocks mined async fn do_evm_mine(&self, opts: Option) -> Result { let mut blocks_to_mine = 1u64; diff --git a/testdata/cheats/Fork2.t.sol b/testdata/cheats/Fork2.t.sol index eb313fd5d014a..e67e82ea7345a 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/cheats/Fork2.t.sol @@ -225,7 +225,7 @@ contract ForkTest is DSTest { string memory path = "fixtures/Rpc/balance_params.json"; string memory file = vm.readFile(path); bytes memory result = vm.rpc("eth_getBalance", file); - assertEq(result, hex"3582f71d817d46"); + assertEq(result, hex"10b7c11bcb51e6"); } } From 31fbdef090a829964ee10ef66024f5120f2af438 Mon Sep 17 00:00:00 2001 From: Mateusz Radomski <33978857+mateuszradomski@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:25:42 +0200 Subject: [PATCH 0165/1963] fix(forge): filter remapping with context (#5901) * fix(forge): filter remapping with context This commit changes the remapping filtering behaviour to take into consideration the context of a remapping. If two contexts are different but have the same prefix then they both should be included. * feat: clippy/fmt * chore: docs --------- Co-authored-by: Enrique Ortiz --- crates/config/src/providers/remappings.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index fd434d2134a4d..dde49ce8f9016 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -30,11 +30,19 @@ impl Remappings { Self { remappings } } + /// Filters the remappings vector by name and context. + fn filter_key(r: &Remapping) -> String { + match &r.context { + Some(str) => str.clone() + &r.name.clone(), + None => r.name.clone(), + } + } + /// Consumes the wrapper and returns the inner remappings vector. pub fn into_inner(self) -> Vec { let mut tmp = HashSet::new(); let remappings = - self.remappings.iter().filter(|r| tmp.insert(r.name.clone())).cloned().collect(); + self.remappings.iter().filter(|r| tmp.insert(Self::filter_key(r))).cloned().collect(); remappings } From 1e6b5edaa0153c3f83a1d49d06b2d11820c68310 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:52:25 +0200 Subject: [PATCH 0166/1963] chore(deps): weekly `cargo update` (#6043) Updating git repository `https://github.com/gakonst/ethers-rs` Updating arbitrary v1.3.0 -> v1.3.1 Updating bstr v1.6.2 -> v1.7.0 Updating cargo_metadata v0.18.0 -> v0.18.1 Updating deranged v0.3.8 -> v0.3.9 Updating ethers v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-addressbook v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-contract v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-contract-abigen v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-contract-derive v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-core v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-etherscan v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-middleware v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-providers v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-signers v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating ethers-solc v2.0.10 (https://github.com/gakonst/ethers-rs#a13233a5) -> #9d01a981 Updating flate2 v1.0.27 -> v1.0.28 Updating jobserver v0.1.26 -> v0.1.27 Updating ordered-float v4.1.0 -> v4.1.1 Adding powerfmt v0.2.0 Updating primitive-types v0.12.1 -> v0.12.2 Updating regex v1.9.6 -> v1.10.1 Updating regex-automata v0.3.9 -> v0.4.2 Adding regex-syntax v0.8.2 Updating ring v0.17.2 -> v0.17.3 Updating rustix v0.38.18 -> v0.38.19 Updating semver v1.0.19 -> v1.0.20 Updating serde v1.0.188 -> v1.0.189 Updating serde_derive v1.0.188 -> v1.0.189 Updating time v0.3.29 -> v0.3.30 Updating tracing v0.1.37 -> v0.1.39 Updating tracing-attributes v0.1.26 -> v0.1.27 Updating tracing-core v0.1.31 -> v0.1.32 Updating winnow v0.5.16 -> v0.5.17 Updating zstd-sys v2.0.8+zstd.1.5.5 -> v2.0.9+zstd.1.5.5 Co-authored-by: mattsse --- Cargo.lock | 160 +++++++++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f4ee8c43b872..2cdce41d5942a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -380,9 +380,9 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arbitrary" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +checksum = "a2e1373abdaa212b704512ec2bd8b26bd0b7d5c3f70117411a5d9a451383c859" [[package]] name = "ariadne" @@ -812,12 +812,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" +checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" dependencies = [ "memchr", - "regex-automata 0.3.9", + "regex-automata 0.4.2", "serde", ] @@ -925,13 +925,13 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb9ac64500cc83ce4b9f8dafa78186aa008c8dea77a09b94cd307fd0cd5022a8" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "thiserror", @@ -978,7 +978,7 @@ dependencies = [ "rpassword", "rusoto_core", "rusoto_kms", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "tempfile", @@ -1044,7 +1044,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "serial_test", @@ -1650,9 +1650,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] [[package]] name = "derivative" @@ -2036,7 +2039,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2051,7 +2054,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "ethers-core", "once_cell", @@ -2062,7 +2065,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2080,7 +2083,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "Inflector", "const-hex", @@ -2103,7 +2106,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "Inflector", "const-hex", @@ -2118,7 +2121,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "arrayvec", "bytes", @@ -2147,12 +2150,12 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "ethers-core", "ethers-solc", "reqwest", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "thiserror", @@ -2162,7 +2165,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "async-trait", "auto_impl", @@ -2188,7 +2191,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "async-trait", "auto_impl", @@ -2226,7 +2229,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "async-trait", "coins-bip32", @@ -2243,7 +2246,7 @@ dependencies = [ "rand 0.8.5", "rusoto_core", "rusoto_kms", - "semver 1.0.19", + "semver 1.0.20", "sha2 0.10.8", "spki", "thiserror", @@ -2254,7 +2257,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#a13233a5e681a11f54978dbaa8f61eeff5248d41" +source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" dependencies = [ "cfg-if", "const-hex", @@ -2272,7 +2275,7 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "sha2 0.10.8", @@ -2422,9 +2425,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -2490,7 +2493,7 @@ dependencies = [ "rayon", "regex", "reqwest", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "serial_test", @@ -2643,7 +2646,7 @@ dependencies = [ "once_cell", "regex", "reqwest", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "tempfile", @@ -2675,7 +2678,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "serde_regex", @@ -2727,7 +2730,7 @@ dependencies = [ "parking_lot", "proptest", "revm", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "tempfile", @@ -3812,9 +3815,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] @@ -4584,9 +4587,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "4.1.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a540f3e3b3d7929c884e46d093d344e4e5bdeed54d08bf007df50c93cc85d5" +checksum = "536900a8093134cf9ccf00a27deb3532421099e958d9dd431135d0c7543ca1e8" dependencies = [ "num-traits", ] @@ -5017,6 +5020,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -5051,9 +5060,9 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -5385,14 +5394,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.6" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "aaac441002f822bc9705a681810a4dd2963094b9ca0ddc41cb963a4c189189ea" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.9", - "regex-syntax 0.7.5", + "regex-automata 0.4.2", + "regex-syntax 0.8.2", ] [[package]] @@ -5406,13 +5415,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "5011c7e263a695dc8ca064cddb722af1be54e517a280b12a5356f98366899e5d" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] @@ -5427,6 +5436,12 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + [[package]] name = "reqwest" version = "0.11.22" @@ -5556,9 +5571,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.2" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "911b295d2d302948838c8ac142da1ee09fa7863163b44e6715bc9357905878b8" +checksum = "9babe80d5c16becf6594aa32ad2be8fe08498e7ae60b77de8df700e67f191d7e" dependencies = [ "cc", "getrandom 0.2.10", @@ -5776,14 +5791,14 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.19", + "semver 1.0.20", ] [[package]] name = "rustix" -version = "0.38.18" +version = "0.38.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" +checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" dependencies = [ "bitflags 2.4.0", "errno", @@ -6045,9 +6060,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" dependencies = [ "serde", ] @@ -6075,18 +6090,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", @@ -6503,7 +6518,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver 1.0.19", + "semver 1.0.20", "serde", "serde_json", "sha2 0.10.8", @@ -6520,7 +6535,7 @@ checksum = "2271abd7d01895a3e5bfa4b578e32f09155002ce1ec239532e297f82aafad06b" dependencies = [ "build_const", "hex", - "semver 1.0.19", + "semver 1.0.20", "serde_json", "svm-rs", ] @@ -6712,14 +6727,15 @@ dependencies = [ [[package]] name = "time" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", "itoa", "libc", "num_threads", + "powerfmt", "serde", "time-core", "time-macros", @@ -7018,11 +7034,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -7031,9 +7046,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", @@ -7042,9 +7057,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -7560,7 +7575,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.2", + "ring 0.17.3", "untrusted 0.9.0", ] @@ -7756,9 +7771,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.16" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" +checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" dependencies = [ "memchr", ] @@ -7880,11 +7895,10 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] From dbd935b33004ec6241fec21427284024d8477d54 Mon Sep 17 00:00:00 2001 From: Ape Dev <83542848+ape-dev-cs@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:14:01 +0100 Subject: [PATCH 0167/1963] feat: set chain id endpoint (#6047) --- crates/anvil/core/src/eth/mod.rs | 4 ++++ crates/anvil/src/eth/api.rs | 7 +++++++ crates/anvil/src/eth/backend/mem/mod.rs | 4 ++++ crates/anvil/tests/it/anvil_api.rs | 15 +++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index c0ea52c65e70d..e57d1583ec042 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -421,6 +421,10 @@ pub enum EthRequest { )] SetCoinbase(Address), + /// Sets the chain id + #[cfg_attr(feature = "serde", serde(rename = "anvil_setChainId", with = "sequence"))] + SetChainId(u64), + /// Enable or disable logging #[cfg_attr( feature = "serde", diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 80dcb92b48bc9..d7f875c4fa726 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -303,6 +303,7 @@ impl EthApi { self.anvil_set_storage_at(addr, slot, val).await.to_rpc_result() } EthRequest::SetCoinbase(addr) => self.anvil_set_coinbase(addr).await.to_rpc_result(), + EthRequest::SetChainId(id) => self.anvil_set_chain_id(id).await.to_rpc_result(), EthRequest::SetLogging(log) => self.anvil_set_logging(log).await.to_rpc_result(), EthRequest::SetMinGasPrice(gas) => { self.anvil_set_min_gas_price(gas).await.to_rpc_result() @@ -1536,6 +1537,12 @@ impl EthApi { } } + pub async fn anvil_set_chain_id(&self, chain_id: u64) -> Result<()> { + node_info!("anvil_setChainId"); + self.backend.set_chain_id(chain_id); + Ok(()) + } + /// Modifies the balance of an account. /// /// Handler for RPC call: `anvil_setBalance` diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index e6da9110c8d61..4022172e7f30c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -492,6 +492,10 @@ impl Backend { self.env.read().cfg.chain_id.into() } + pub fn set_chain_id(&self, chain_id: u64) { + self.env.write().cfg.chain_id = chain_id; + } + /// Returns balance of the given account. pub async fn current_balance(&self, address: Address) -> DatabaseResult { Ok(self.get_account(address).await?.balance.to_ethers()) diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 9b8b51a178771..03b72e5061bb7 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -483,3 +483,18 @@ async fn test_get_transaction_receipt() { new_receipt.unwrap().effective_gas_price.unwrap().as_u64() ); } + +// test can set chain id +#[tokio::test(flavor = "multi_thread")] +async fn test_set_chain_id() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + let chain_id = provider.get_chainid().await.unwrap(); + assert_eq!(chain_id, U256::from(31337)); + + let chain_id = 1234; + api.anvil_set_chain_id(chain_id).await.unwrap(); + + let chain_id = provider.get_chainid().await.unwrap(); + assert_eq!(chain_id, U256::from(1234)); +} From bd473eb9d6cd90771b530d211e16fb7adb8240f6 Mon Sep 17 00:00:00 2001 From: Mizuki Date: Tue, 17 Oct 2023 23:17:53 +0900 Subject: [PATCH 0168/1963] feat(foundryup): add options to select platform and architecture (#6049) * feat(foundryup): add options to select platform and architecture * Add available arch/platforms in usage --- foundryup/foundryup | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index af0d4d52c2c6a..44962d6c3c890 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -24,6 +24,8 @@ main() { -p|--path) shift; FOUNDRYUP_LOCAL_REPO=$1;; -P|--pr) shift; FOUNDRYUP_PR=$1;; -C|--commit) shift; FOUNDRYUP_COMMIT=$1;; + --arch) shift; FOUNDRYUP_ARCH=$1;; + --platform) shift; FOUNDRYUP_PLATFORM=$1;; -h|--help) usage exit 0 @@ -98,16 +100,14 @@ main() { say "installing foundry (version ${FOUNDRYUP_VERSION}, tag ${FOUNDRYUP_TAG})" - PLATFORM="$(uname -s)" + PLATFORM=$(tolower "${FOUNDRYUP_PLATFORM:-$(uname -s)}") EXT="tar.gz" case $PLATFORM in - Linux) - PLATFORM="linux" - ;; - Darwin) + linux) ;; + darwin|mac*) PLATFORM="darwin" ;; - MINGW*) + mingw*|win*) EXT="zip" PLATFORM="win32" ;; @@ -116,7 +116,7 @@ main() { ;; esac - ARCHITECTURE="$(uname -m)" + ARCHITECTURE=$(tolower "${FOUNDRYUP_ARCH:-$(uname -m)}") if [ "${ARCHITECTURE}" = "x86_64" ]; then # Redirect stderr to /dev/null to avoid printing errors if non Rosetta. if [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = "1" ]; then @@ -242,6 +242,8 @@ OPTIONS: -C, --commit Install a specific commit -r, --repo Install from a remote GitHub repo (uses default branch if no other options are set) -p, --path Install a local repository + --arch Install a specific architecture (supports amd64 and arm64) + --platform Install a specific platform (supports win32, linux, and darwin) EOF } @@ -258,6 +260,10 @@ err() { exit 1 } +tolower() { + echo "$1" | awk '{print tolower($0)}' +} + need_cmd() { if ! check_cmd "$1"; then err "need '$1' (command not found)" From b89418f26efe3ea3e154931b1ce80ad9a2ae883a Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Tue, 17 Oct 2023 18:07:44 +0200 Subject: [PATCH 0169/1963] fix(forge): correctly suppress compiler output for sparse compilation and json (#6051) --- crates/forge/bin/cmd/test/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 8570509875f85..3c0e55c0dfdd0 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -162,14 +162,12 @@ impl TestArgs { } let compiler = ProjectCompiler::default(); - let output = if config.sparse_mode { - compiler.compile_sparse(&project, filter.clone()) - } else if self.opts.silent { - compile::suppress_compile(&project) - } else { - compiler.compile(&project) + let output = match (config.sparse_mode, self.opts.silent | self.json) { + (false, false) => compiler.compile(&project), + (true, false) => compiler.compile_sparse(&project, filter.clone()), + (false, true) => compile::suppress_compile(&project), + (true, true) => compile::suppress_compile_sparse(&project, filter.clone()), }?; - // Create test options from general project settings // and compiler output let project_root = &project.paths.root; From ee5d02c3ef5f55a06b069e4a70a820661a9130c8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 17 Oct 2023 19:26:01 +0200 Subject: [PATCH 0170/1963] feat: foundry-cheatcodes (#5998) --- .cargo/config.toml | 3 + Cargo.lock | 69 + Cargo.toml | 8 + crates/cheatcodes/Cargo.toml | 59 + crates/cheatcodes/README.md | 5 + crates/cheatcodes/assets/cheatcodes.json | 3764 +++++++++++++++++ .../cheatcodes/assets/cheatcodes.schema.json | 274 ++ crates/cheatcodes/src/defs/mod.rs | 265 ++ crates/cheatcodes/src/defs/vm.rs | 1119 +++++ crates/cheatcodes/src/impls/config.rs | 232 + crates/cheatcodes/src/impls/db.rs | 307 ++ crates/cheatcodes/src/impls/db/error.rs | 103 + crates/cheatcodes/src/impls/env.rs | 270 ++ crates/cheatcodes/src/impls/error.rs | 297 ++ crates/cheatcodes/src/impls/evm.rs | 370 ++ crates/cheatcodes/src/impls/evm/fork.rs | 299 ++ crates/cheatcodes/src/impls/evm/mapping.rs | 140 + crates/cheatcodes/src/impls/evm/mock.rs | 97 + crates/cheatcodes/src/impls/evm/prank.rs | 126 + crates/cheatcodes/src/impls/fs.rs | 416 ++ crates/cheatcodes/src/impls/inspector.rs | 1098 +++++ crates/cheatcodes/src/impls/json.rs | 505 +++ crates/cheatcodes/src/impls/mod.rs | 71 + crates/cheatcodes/src/impls/script.rs | 127 + crates/cheatcodes/src/impls/string.rs | 133 + crates/cheatcodes/src/impls/test.rs | 102 + crates/cheatcodes/src/impls/test/expect.rs | 510 +++ crates/cheatcodes/src/impls/utils.rs | 201 + crates/cheatcodes/src/lib.rs | 97 + crates/macros/Cargo.toml | 4 +- crates/macros/impl/Cargo.toml | 1 + crates/macros/impl/src/cheatcodes.rs | 256 ++ crates/macros/impl/src/lib.rs | 14 +- crates/macros/impl/src/utils.rs | 12 - crates/macros/src/fmt/ui.rs | 8 +- crates/macros/src/lib.rs | 2 +- 36 files changed, 11344 insertions(+), 20 deletions(-) create mode 100644 crates/cheatcodes/Cargo.toml create mode 100644 crates/cheatcodes/README.md create mode 100644 crates/cheatcodes/assets/cheatcodes.json create mode 100644 crates/cheatcodes/assets/cheatcodes.schema.json create mode 100644 crates/cheatcodes/src/defs/mod.rs create mode 100644 crates/cheatcodes/src/defs/vm.rs create mode 100644 crates/cheatcodes/src/impls/config.rs create mode 100644 crates/cheatcodes/src/impls/db.rs create mode 100644 crates/cheatcodes/src/impls/db/error.rs create mode 100644 crates/cheatcodes/src/impls/env.rs create mode 100644 crates/cheatcodes/src/impls/error.rs create mode 100644 crates/cheatcodes/src/impls/evm.rs create mode 100644 crates/cheatcodes/src/impls/evm/fork.rs create mode 100644 crates/cheatcodes/src/impls/evm/mapping.rs create mode 100644 crates/cheatcodes/src/impls/evm/mock.rs create mode 100644 crates/cheatcodes/src/impls/evm/prank.rs create mode 100644 crates/cheatcodes/src/impls/fs.rs create mode 100644 crates/cheatcodes/src/impls/inspector.rs create mode 100644 crates/cheatcodes/src/impls/json.rs create mode 100644 crates/cheatcodes/src/impls/mod.rs create mode 100644 crates/cheatcodes/src/impls/script.rs create mode 100644 crates/cheatcodes/src/impls/string.rs create mode 100644 crates/cheatcodes/src/impls/test.rs create mode 100644 crates/cheatcodes/src/impls/test/expect.rs create mode 100644 crates/cheatcodes/src/impls/utils.rs create mode 100644 crates/cheatcodes/src/lib.rs create mode 100644 crates/macros/impl/src/cheatcodes.rs delete mode 100644 crates/macros/impl/src/utils.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index e7f653d39dcc3..a42c43c86c18c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,6 @@ +[alias] +cheats = "test -p foundry-cheatcodes --features schema tests::" + [target.x86_64-pc-windows-msvc] rustflags = [ # Increases the stack size to 10MB, which is diff --git a/Cargo.lock b/Cargo.lock index 2cdce41d5942a..4ac8fa985a4bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1804,6 +1804,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "dyn-clone" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" + [[package]] name = "ecdsa" version = "0.16.8" @@ -2588,6 +2594,33 @@ dependencies = [ "url", ] +[[package]] +name = "foundry-cheatcodes" +version = "0.2.0" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-types", + "const-hex", + "ethers", + "eyre", + "foundry-common", + "foundry-config", + "foundry-macros", + "foundry-utils", + "futures", + "itertools 0.11.0", + "jsonpath_lib", + "revm", + "schemars", + "serde", + "serde_json", + "thiserror", + "tracing", + "walkdir", +] + [[package]] name = "foundry-cli" version = "0.2.0" @@ -2756,6 +2789,7 @@ dependencies = [ name = "foundry-macros-impl" version = "0.2.0" dependencies = [ + "proc-macro-error", "proc-macro2", "quote", "syn 2.0.38", @@ -5960,6 +5994,30 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "schemars" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 1.0.109", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -6108,6 +6166,17 @@ dependencies = [ "syn 2.0.38", ] +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "serde_json" version = "1.0.107" diff --git a/Cargo.toml b/Cargo.toml index d242337108eaf..f3280a0591b57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,6 +127,7 @@ foundry-abi = { path = "crates/abi" } foundry-binder = { path = "crates/binder" } foundry-cli = { path = "crates/cli" } foundry-common = { path = "crates/common" } +foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-config = { path = "crates/config" } foundry-evm = { path = "crates/evm" } foundry-macros = { path = "crates/macros" } @@ -156,6 +157,7 @@ alloy-primitives = "0.4.1" alloy-dyn-abi = "0.4.1" alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" +syn-solidity = "0.4.1" solang-parser = "=0.3.2" @@ -165,6 +167,12 @@ itertools = "0.11" chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } hex = { package = "const-hex", version = "1.6", features = ["hex"] } protobuf = "=3.2.0" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +tracing = "0.1" +jsonpath_lib = "0.3" +eyre = "0.6" +color-eyre = "0.6" #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml new file mode 100644 index 0000000000000..0e517efdabf0e --- /dev/null +++ b/crates/cheatcodes/Cargo.toml @@ -0,0 +1,59 @@ +[package] +name = "foundry-cheatcodes" +description = "Foundry cheatcodes definitions and implementations" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +exclude.workspace = true + +[dependencies] +foundry-macros.workspace = true +alloy-primitives.workspace = true +alloy-sol-types.workspace = true +serde.workspace = true +serde_json.workspace = true + +# schema +schemars = { version = "0.8.15", optional = true } + +# impls +foundry-common = { workspace = true, optional = true } +foundry-config = { workspace = true, optional = true } +foundry-utils = { workspace = true, optional = true } +alloy-dyn-abi = { workspace = true, optional = true } +alloy-json-abi = { workspace = true, optional = true } +ethers = { workspace = true, optional = true, features = ["ethers-solc"] } +eyre = { workspace = true, optional = true } +futures = { version = "0.3", optional = true } +hex = { workspace = true, optional = true } +itertools = { workspace = true, optional = true } +jsonpath_lib = { workspace = true, optional = true } +revm = { workspace = true, optional = true } +thiserror = { version = "1", optional = true } +tracing = { workspace = true, optional = true } +walkdir = { version = "2", optional = true } + +[features] +schema = ["dep:schemars"] +impls = [ + "dep:foundry-common", + "dep:foundry-config", + "dep:foundry-utils", + "dep:alloy-dyn-abi", + "dep:alloy-json-abi", + "dep:ethers", + "dep:eyre", + "dep:futures", + "dep:hex", + "dep:itertools", + "dep:jsonpath_lib", + "dep:revm", + "dep:thiserror", + "dep:tracing", + "dep:walkdir", +] diff --git a/crates/cheatcodes/README.md b/crates/cheatcodes/README.md new file mode 100644 index 0000000000000..0992f2c3a3d0e --- /dev/null +++ b/crates/cheatcodes/README.md @@ -0,0 +1,5 @@ +# foundry-cheatcodes + +Foundry cheatcodes definitions and implementations. + +All cheatcodes are defined in a single macro call. diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json new file mode 100644 index 0000000000000..895a2c75b19c4 --- /dev/null +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -0,0 +1,3764 @@ +[ + { + "id": "accesses", + "declaration": "function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);", + "visibility": "external", + "mutability": "", + "signature": "accesses(address)", + "selector": "0x65bc9481", + "selectorBytes": [ + 101, + 188, + 148, + 129 + ], + "description": "Gets all accessed reads and write slot from a `vm.record` session, for a given address.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "activeFork", + "declaration": "function activeFork() external view returns (uint256 forkId);", + "visibility": "external", + "mutability": "view", + "signature": "activeFork()", + "selector": "0x2f103f22", + "selectorBytes": [ + 47, + 16, + 63, + 34 + ], + "description": "Returns the identifier of the currently active fork. Reverts if no fork is currently active.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "addr", + "declaration": "function addr(uint256 privateKey) external pure returns (address keyAddr);", + "visibility": "external", + "mutability": "pure", + "signature": "addr(uint256)", + "selector": "0xffa18649", + "selectorBytes": [ + 255, + 161, + 134, + 73 + ], + "description": "Gets the address for a given private key.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "allowCheatcodes", + "declaration": "function allowCheatcodes(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "allowCheatcodes(address)", + "selector": "0xea060291", + "selectorBytes": [ + 234, + 6, + 2, + 145 + ], + "description": "In forking mode, explicitly grant the given address cheatcode access.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "assume", + "declaration": "function assume(bool condition) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assume(bool)", + "selector": "0x4c63e562", + "selectorBytes": [ + 76, + 99, + 229, + 98 + ], + "description": "If the condition is false, discard this run's fuzz inputs and generate new ones.", + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "id": "breakpoint_0", + "declaration": "function breakpoint(string calldata char) external;", + "visibility": "external", + "mutability": "", + "signature": "breakpoint(string)", + "selector": "0xf0259e92", + "selectorBytes": [ + 240, + 37, + 158, + 146 + ], + "description": "Writes a breakpoint to jump to in the debugger.", + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "id": "breakpoint_1", + "declaration": "function breakpoint(string calldata char, bool value) external;", + "visibility": "external", + "mutability": "", + "signature": "breakpoint(string,bool)", + "selector": "0xf7d39a8d", + "selectorBytes": [ + 247, + 211, + 154, + 141 + ], + "description": "Writes a conditional breakpoint to jump to in the debugger.", + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "id": "broadcast_0", + "declaration": "function broadcast() external;", + "visibility": "external", + "mutability": "", + "signature": "broadcast()", + "selector": "0xafc98040", + "selectorBytes": [ + 175, + 201, + 128, + 64 + ], + "description": "Using the address that calls the test contract, has the next call (at this call depth only)\ncreate a transaction that can later be signed and sent onchain.", + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "id": "broadcast_1", + "declaration": "function broadcast(address signer) external;", + "visibility": "external", + "mutability": "", + "signature": "broadcast(address)", + "selector": "0xe6962cdb", + "selectorBytes": [ + 230, + 150, + 44, + 219 + ], + "description": "Has the next call (at this call depth only) create a transaction with the address provided\nas the sender that can later be signed and sent onchain.", + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "id": "broadcast_2", + "declaration": "function broadcast(uint256 privateKey) external;", + "visibility": "external", + "mutability": "", + "signature": "broadcast(uint256)", + "selector": "0xf67a965b", + "selectorBytes": [ + 246, + 122, + 150, + 91 + ], + "description": "Has the next call (at this call depth only) create a transaction with the private key\nprovided as the sender that can later be signed and sent onchain.", + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "id": "chainId", + "declaration": "function chainId(uint256 newChainId) external;", + "visibility": "external", + "mutability": "", + "signature": "chainId(uint256)", + "selector": "0x4049ddd2", + "selectorBytes": [ + 64, + 73, + 221, + 210 + ], + "description": "Sets `block.chainid`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "clearMockedCalls", + "declaration": "function clearMockedCalls() external;", + "visibility": "external", + "mutability": "", + "signature": "clearMockedCalls()", + "selector": "0x3fdf4e15", + "selectorBytes": [ + 63, + 223, + 78, + 21 + ], + "description": "Clears all mocked calls.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "closeFile", + "declaration": "function closeFile(string calldata path) external;", + "visibility": "external", + "mutability": "", + "signature": "closeFile(string)", + "selector": "0x48c3241f", + "selectorBytes": [ + 72, + 195, + 36, + 31 + ], + "description": "Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.\n`path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "coinbase", + "declaration": "function coinbase(address newCoinbase) external;", + "visibility": "external", + "mutability": "", + "signature": "coinbase(address)", + "selector": "0xff483c54", + "selectorBytes": [ + 255, + 72, + 60, + 84 + ], + "description": "Sets `block.coinbase`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "copyFile", + "declaration": "function copyFile(string calldata from, string calldata to) external returns (uint64 copied);", + "visibility": "external", + "mutability": "", + "signature": "copyFile(string,string)", + "selector": "0xa54a87d8", + "selectorBytes": [ + 165, + 74, + 135, + 216 + ], + "description": "Copies the contents of one file to another. This function will **overwrite** the contents of `to`.\nOn success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`.\nBoth `from` and `to` are relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "createDir", + "declaration": "function createDir(string calldata path, bool recursive) external;", + "visibility": "external", + "mutability": "", + "signature": "createDir(string,bool)", + "selector": "0x168b64d3", + "selectorBytes": [ + 22, + 139, + 100, + 211 + ], + "description": "Creates a new, empty directory at the provided path.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- User lacks permissions to modify `path`.\n- A parent of the given path doesn't exist and `recursive` is false.\n- `path` already exists and `recursive` is false.\n`path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "createFork_0", + "declaration": "function createFork(string calldata urlOrAlias) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createFork(string)", + "selector": "0x31ba3498", + "selectorBytes": [ + 49, + 186, + 52, + 152 + ], + "description": "Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "createFork_1", + "declaration": "function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createFork(string,uint256)", + "selector": "0x6ba3ba2b", + "selectorBytes": [ + 107, + 163, + 186, + 43 + ], + "description": "Creates a new fork with the given endpoint and block and returns the identifier of the fork.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "createFork_2", + "declaration": "function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createFork(string,bytes32)", + "selector": "0x7ca29682", + "selectorBytes": [ + 124, + 162, + 150, + 130 + ], + "description": "Creates a new fork with the given endpoint and at the block the given transaction was mined in,\nreplays all transaction mined in the block before the transaction, and returns the identifier of the fork.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "createSelectFork_0", + "declaration": "function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createSelectFork(string)", + "selector": "0x98680034", + "selectorBytes": [ + 152, + 104, + 0, + 52 + ], + "description": "Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "createSelectFork_1", + "declaration": "function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createSelectFork(string,uint256)", + "selector": "0x71ee464d", + "selectorBytes": [ + 113, + 238, + 70, + 77 + ], + "description": "Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "createSelectFork_2", + "declaration": "function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createSelectFork(string,bytes32)", + "selector": "0x84d52b7a", + "selectorBytes": [ + 132, + 213, + 43, + 122 + ], + "description": "Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in,\nreplays all transaction mined in the block before the transaction, returns the identifier of the fork.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "createWallet_0", + "declaration": "function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);", + "visibility": "external", + "mutability": "", + "signature": "createWallet(string)", + "selector": "0x7404f1d2", + "selectorBytes": [ + 116, + 4, + 241, + 210 + ], + "description": "Derives a private key from the name, labels the account with that name, and returns the wallet.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "createWallet_1", + "declaration": "function createWallet(uint256 privateKey) external returns (Wallet memory wallet);", + "visibility": "external", + "mutability": "", + "signature": "createWallet(uint256)", + "selector": "0x7a675bb6", + "selectorBytes": [ + 122, + 103, + 91, + 182 + ], + "description": "Generates a wallet from the private key and returns the wallet.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "createWallet_2", + "declaration": "function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);", + "visibility": "external", + "mutability": "", + "signature": "createWallet(uint256,string)", + "selector": "0xed7c5462", + "selectorBytes": [ + 237, + 124, + 84, + 98 + ], + "description": "Generates a wallet from the private key, labels the account with that name, and returns the wallet.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "deal", + "declaration": "function deal(address account, uint256 newBalance) external;", + "visibility": "external", + "mutability": "", + "signature": "deal(address,uint256)", + "selector": "0xc88a5e6d", + "selectorBytes": [ + 200, + 138, + 94, + 109 + ], + "description": "Sets an address' balance.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "deriveKey_0", + "declaration": "function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,uint32)", + "selector": "0x6229498b", + "selectorBytes": [ + 98, + 41, + 73, + 139 + ], + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path)\nat the derivation path `m/44'/60'/0'/0/{index}`.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "deriveKey_1", + "declaration": "function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,string,uint32)", + "selector": "0x6bcb2c1b", + "selectorBytes": [ + 107, + 203, + 44, + 27 + ], + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path)\nat `{derivationPath}{index}`.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "deriveKey_2", + "declaration": "function deriveKey(string calldata mnemonic, uint32 index, string calldata language) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,uint32,string)", + "selector": "0x32c8176d", + "selectorBytes": [ + 50, + 200, + 23, + 109 + ], + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language\nat the derivation path `m/44'/60'/0'/0/{index}`.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "deriveKey_3", + "declaration": "function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,string,uint32,string)", + "selector": "0x29233b1f", + "selectorBytes": [ + 41, + 35, + 59, + 31 + ], + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language\nat `{derivationPath}{index}`.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "difficulty", + "declaration": "function difficulty(uint256 newDifficulty) external;", + "visibility": "external", + "mutability": "", + "signature": "difficulty(uint256)", + "selector": "0x46cc92d9", + "selectorBytes": [ + 70, + 204, + 146, + 217 + ], + "description": "Sets `block.difficulty`.\nNot available on EVM versions from Paris onwards. Use `prevrandao` instead.\nReverts if used on unsupported EVM versions.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "envAddress_0", + "declaration": "function envAddress(string calldata name) external view returns (address value);", + "visibility": "external", + "mutability": "view", + "signature": "envAddress(string)", + "selector": "0x350d56bf", + "selectorBytes": [ + 53, + 13, + 86, + 191 + ], + "description": "Gets the environment variable `name` and parses it as `address`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envAddress_1", + "declaration": "function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envAddress(string,string)", + "selector": "0xad31b9fa", + "selectorBytes": [ + 173, + 49, + 185, + 250 + ], + "description": "Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envBool_0", + "declaration": "function envBool(string calldata name) external view returns (bool value);", + "visibility": "external", + "mutability": "view", + "signature": "envBool(string)", + "selector": "0x7ed1ec7d", + "selectorBytes": [ + 126, + 209, + 236, + 125 + ], + "description": "Gets the environment variable `name` and parses it as `bool`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envBool_1", + "declaration": "function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBool(string,string)", + "selector": "0xaaaddeaf", + "selectorBytes": [ + 170, + 173, + 222, + 175 + ], + "description": "Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envBytes32_0", + "declaration": "function envBytes32(string calldata name) external view returns (bytes32 value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes32(string)", + "selector": "0x97949042", + "selectorBytes": [ + 151, + 148, + 144, + 66 + ], + "description": "Gets the environment variable `name` and parses it as `bytes32`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envBytes32_1", + "declaration": "function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes32(string,string)", + "selector": "0x5af231c1", + "selectorBytes": [ + 90, + 242, + 49, + 193 + ], + "description": "Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envBytes_0", + "declaration": "function envBytes(string calldata name) external view returns (bytes memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes(string)", + "selector": "0x4d7baf06", + "selectorBytes": [ + 77, + 123, + 175, + 6 + ], + "description": "Gets the environment variable `name` and parses it as `bytes`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envBytes_1", + "declaration": "function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes(string,string)", + "selector": "0xddc2651b", + "selectorBytes": [ + 221, + 194, + 101, + 27 + ], + "description": "Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envInt_0", + "declaration": "function envInt(string calldata name) external view returns (int256 value);", + "visibility": "external", + "mutability": "view", + "signature": "envInt(string)", + "selector": "0x892a0c61", + "selectorBytes": [ + 137, + 42, + 12, + 97 + ], + "description": "Gets the environment variable `name` and parses it as `int256`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envInt_1", + "declaration": "function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envInt(string,string)", + "selector": "0x42181150", + "selectorBytes": [ + 66, + 24, + 17, + 80 + ], + "description": "Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_0", + "declaration": "function envOr(string calldata name, bool defaultValue) external returns (bool value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,bool)", + "selector": "0x4777f3cf", + "selectorBytes": [ + 71, + 119, + 243, + 207 + ], + "description": "Gets the environment variable `name` and parses it as `bool`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_1", + "declaration": "function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,uint256)", + "selector": "0x5e97348f", + "selectorBytes": [ + 94, + 151, + 52, + 143 + ], + "description": "Gets the environment variable `name` and parses it as `uint256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_10", + "declaration": "function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external returns (address[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,address[])", + "selector": "0xc74e9deb", + "selectorBytes": [ + 199, + 78, + 157, + 235 + ], + "description": "Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_11", + "declaration": "function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external returns (bytes32[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,bytes32[])", + "selector": "0x2281f367", + "selectorBytes": [ + 34, + 129, + 243, + 103 + ], + "description": "Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_12", + "declaration": "function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external returns (string[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,string[])", + "selector": "0x859216bc", + "selectorBytes": [ + 133, + 146, + 22, + 188 + ], + "description": "Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_13", + "declaration": "function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external returns (bytes[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,bytes[])", + "selector": "0x64bc3e64", + "selectorBytes": [ + 100, + 188, + 62, + 100 + ], + "description": "Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_2", + "declaration": "function envOr(string calldata name, int256 defaultValue) external returns (int256 value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,int256)", + "selector": "0xbbcb713e", + "selectorBytes": [ + 187, + 203, + 113, + 62 + ], + "description": "Gets the environment variable `name` and parses it as `int256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_3", + "declaration": "function envOr(string calldata name, address defaultValue) external returns (address value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,address)", + "selector": "0x561fe540", + "selectorBytes": [ + 86, + 31, + 229, + 64 + ], + "description": "Gets the environment variable `name` and parses it as `address`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_4", + "declaration": "function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,bytes32)", + "selector": "0xb4a85892", + "selectorBytes": [ + 180, + 168, + 88, + 146 + ], + "description": "Gets the environment variable `name` and parses it as `bytes32`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_5", + "declaration": "function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string)", + "selector": "0xd145736c", + "selectorBytes": [ + 209, + 69, + 115, + 108 + ], + "description": "Gets the environment variable `name` and parses it as `string`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_6", + "declaration": "function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,bytes)", + "selector": "0xb3e47705", + "selectorBytes": [ + 179, + 228, + 119, + 5 + ], + "description": "Gets the environment variable `name` and parses it as `bytes`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_7", + "declaration": "function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external returns (bool[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,bool[])", + "selector": "0xeb85e83b", + "selectorBytes": [ + 235, + 133, + 232, + 59 + ], + "description": "Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_8", + "declaration": "function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external returns (uint256[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,uint256[])", + "selector": "0x74318528", + "selectorBytes": [ + 116, + 49, + 133, + 40 + ], + "description": "Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envOr_9", + "declaration": "function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external returns (int256[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,int256[])", + "selector": "0x4700d74b", + "selectorBytes": [ + 71, + 0, + 215, + 75 + ], + "description": "Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envString_0", + "declaration": "function envString(string calldata name) external view returns (string memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envString(string)", + "selector": "0xf877cb19", + "selectorBytes": [ + 248, + 119, + 203, + 25 + ], + "description": "Gets the environment variable `name` and parses it as `string`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envString_1", + "declaration": "function envString(string calldata name, string calldata delim) external view returns (string[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envString(string,string)", + "selector": "0x14b02bc9", + "selectorBytes": [ + 20, + 176, + 43, + 201 + ], + "description": "Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envUint_0", + "declaration": "function envUint(string calldata name) external view returns (uint256 value);", + "visibility": "external", + "mutability": "view", + "signature": "envUint(string)", + "selector": "0xc1978d1f", + "selectorBytes": [ + 193, + 151, + 141, + 31 + ], + "description": "Gets the environment variable `name` and parses it as `uint256`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "envUint_1", + "declaration": "function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envUint(string,string)", + "selector": "0xf3dec099", + "selectorBytes": [ + 243, + 222, + 192, + 153 + ], + "description": "Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "etch", + "declaration": "function etch(address target, bytes calldata newRuntimeBytecode) external;", + "visibility": "external", + "mutability": "", + "signature": "etch(address,bytes)", + "selector": "0xb4d6c782", + "selectorBytes": [ + 180, + 214, + 199, + 130 + ], + "description": "Sets an address' code.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "exists", + "declaration": "function exists(string calldata path) external returns (bool result);", + "visibility": "external", + "mutability": "", + "signature": "exists(string)", + "selector": "0x261a323e", + "selectorBytes": [ + 38, + 26, + 50, + 62 + ], + "description": "Returns true if the given path points to an existing entity, else returns false.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "expectCallMinGas_0", + "declaration": "function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCallMinGas(address,uint256,uint64,bytes)", + "selector": "0x08e4e116", + "selectorBytes": [ + 8, + 228, + 225, + 22 + ], + "description": "Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectCallMinGas_1", + "declaration": "function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCallMinGas(address,uint256,uint64,bytes,uint64)", + "selector": "0xe13a1834", + "selectorBytes": [ + 225, + 58, + 24, + 52 + ], + "description": "Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectCall_0", + "declaration": "function expectCall(address callee, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,bytes)", + "selector": "0xbd6af434", + "selectorBytes": [ + 189, + 106, + 244, + 52 + ], + "description": "Expects a call to an address with the specified calldata.\nCalldata can either be a strict or a partial match.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectCall_1", + "declaration": "function expectCall(address callee, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,bytes,uint64)", + "selector": "0xc1adbbff", + "selectorBytes": [ + 193, + 173, + 187, + 255 + ], + "description": "Expects given number of calls to an address with the specified calldata.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectCall_2", + "declaration": "function expectCall(address callee, uint256 msgValue, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,bytes)", + "selector": "0xf30c7ba3", + "selectorBytes": [ + 243, + 12, + 123, + 163 + ], + "description": "Expects a call to an address with the specified `msg.value` and calldata.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectCall_3", + "declaration": "function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,bytes,uint64)", + "selector": "0xa2b1a1ae", + "selectorBytes": [ + 162, + 177, + 161, + 174 + ], + "description": "Expects given number of calls to an address with the specified `msg.value` and calldata.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectCall_4", + "declaration": "function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,uint64,bytes)", + "selector": "0x23361207", + "selectorBytes": [ + 35, + 54, + 18, + 7 + ], + "description": "Expect a call to an address with the specified `msg.value`, gas, and calldata.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectCall_5", + "declaration": "function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,uint64,bytes,uint64)", + "selector": "0x65b7b7cc", + "selectorBytes": [ + 101, + 183, + 183, + 204 + ], + "description": "Expects given number of calls to an address with the specified `msg.value`, gas, and calldata.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectEmit_0", + "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(bool,bool,bool,bool)", + "selector": "0x491cc7c2", + "selectorBytes": [ + 73, + 28, + 199, + 194 + ], + "description": "Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).\nCall this function, then emit an event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data (as specified by the booleans).", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectEmit_1", + "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(bool,bool,bool,bool,address)", + "selector": "0x81bad6f3", + "selectorBytes": [ + 129, + 186, + 214, + 243 + ], + "description": "Same as the previous method, but also checks supplied address against emitting contract.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectEmit_2", + "declaration": "function expectEmit() external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit()", + "selector": "0x440ed10d", + "selectorBytes": [ + 68, + 14, + 209, + 13 + ], + "description": "Prepare an expected log with all topic and data checks enabled.\nCall this function, then emit an event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectEmit_3", + "declaration": "function expectEmit(address emitter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(address)", + "selector": "0x86b9620d", + "selectorBytes": [ + 134, + 185, + 98, + 13 + ], + "description": "Same as the previous method, but also checks supplied address against emitting contract.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectRevert_0", + "declaration": "function expectRevert() external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert()", + "selector": "0xf4844814", + "selectorBytes": [ + 244, + 132, + 72, + 20 + ], + "description": "Expects an error on next call with any revert data.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectRevert_1", + "declaration": "function expectRevert(bytes4 revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes4)", + "selector": "0xc31eb0e0", + "selectorBytes": [ + 195, + 30, + 176, + 224 + ], + "description": "Expects an error on next call that starts with the revert data.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectRevert_2", + "declaration": "function expectRevert(bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes)", + "selector": "0xf28dceb3", + "selectorBytes": [ + 242, + 141, + 206, + 179 + ], + "description": "Expects an error on next call that exactly matches the revert data.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectSafeMemory", + "declaration": "function expectSafeMemory(uint64 min, uint64 max) external;", + "visibility": "external", + "mutability": "", + "signature": "expectSafeMemory(uint64,uint64)", + "selector": "0x6d016688", + "selectorBytes": [ + 109, + 1, + 102, + 136 + ], + "description": "Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other\nmemory is written to, the test will fail. Can be called multiple times to add more ranges to the set.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "expectSafeMemoryCall", + "declaration": "function expectSafeMemoryCall(uint64 min, uint64 max) external;", + "visibility": "external", + "mutability": "", + "signature": "expectSafeMemoryCall(uint64,uint64)", + "selector": "0x05838bf4", + "selectorBytes": [ + 5, + 131, + 139, + 244 + ], + "description": "Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext.\nIf any other memory is written to, the test will fail. Can be called multiple times to add more ranges\nto the set.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "fee", + "declaration": "function fee(uint256 newBasefee) external;", + "visibility": "external", + "mutability": "", + "signature": "fee(uint256)", + "selector": "0x39b37ab0", + "selectorBytes": [ + 57, + 179, + 122, + 176 + ], + "description": "Sets `block.basefee`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "ffi", + "declaration": "function ffi(string[] calldata commandInput) external returns (bytes memory result);", + "visibility": "external", + "mutability": "", + "signature": "ffi(string[])", + "selector": "0x89160467", + "selectorBytes": [ + 137, + 22, + 4, + 103 + ], + "description": "Performs a foreign function call via the terminal.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "fsMetadata", + "declaration": "function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);", + "visibility": "external", + "mutability": "view", + "signature": "fsMetadata(string)", + "selector": "0xaf368a08", + "selectorBytes": [ + 175, + 54, + 138, + 8 + ], + "description": "Given a path, query the file system to get information about a file, directory, etc.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "getCode", + "declaration": "function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);", + "visibility": "external", + "mutability": "view", + "signature": "getCode(string)", + "selector": "0x8d1cc925", + "selectorBytes": [ + 141, + 28, + 201, + 37 + ], + "description": "Gets the creation bytecode from an artifact file. Takes in the relative path to the json file.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "getDeployedCode", + "declaration": "function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);", + "visibility": "external", + "mutability": "view", + "signature": "getDeployedCode(string)", + "selector": "0x3ebf73b4", + "selectorBytes": [ + 62, + 191, + 115, + 180 + ], + "description": "Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "getLabel", + "declaration": "function getLabel(address account) external returns (string memory currentLabel);", + "visibility": "external", + "mutability": "", + "signature": "getLabel(address)", + "selector": "0x28a249b0", + "selectorBytes": [ + 40, + 162, + 73, + 176 + ], + "description": "Gets the label for the specified address.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "getMappingKeyAndParentOf", + "declaration": "function getMappingKeyAndParentOf(address target, bytes32 elementSlot) external returns (bool found, bytes32 key, bytes32 parent);", + "visibility": "external", + "mutability": "", + "signature": "getMappingKeyAndParentOf(address,bytes32)", + "selector": "0x876e24e6", + "selectorBytes": [ + 135, + 110, + 36, + 230 + ], + "description": "Gets the map key and parent of a mapping at a given slot, for a given address.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "getMappingLength", + "declaration": "function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);", + "visibility": "external", + "mutability": "", + "signature": "getMappingLength(address,bytes32)", + "selector": "0x2f2fd63f", + "selectorBytes": [ + 47, + 47, + 214, + 63 + ], + "description": "Gets the number of elements in the mapping at the given slot, for a given address.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "getMappingSlotAt", + "declaration": "function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);", + "visibility": "external", + "mutability": "", + "signature": "getMappingSlotAt(address,bytes32,uint256)", + "selector": "0xebc73ab4", + "selectorBytes": [ + 235, + 199, + 58, + 180 + ], + "description": "Gets the elements at index idx of the mapping at the given slot, for a given address. The\nindex must be less than the length of the mapping (i.e. the number of keys in the mapping).", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "getNonce_0", + "declaration": "function getNonce(address account) external view returns (uint64 nonce);", + "visibility": "external", + "mutability": "view", + "signature": "getNonce(address)", + "selector": "0x2d0335ab", + "selectorBytes": [ + 45, + 3, + 53, + 171 + ], + "description": "Gets the nonce of an account.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "getNonce_1", + "declaration": "function getNonce(Wallet calldata wallet) external returns (uint64 nonce);", + "visibility": "external", + "mutability": "", + "signature": "getNonce((address,uint256,uint256,uint256))", + "selector": "0xa5748aad", + "selectorBytes": [ + 165, + 116, + 138, + 173 + ], + "description": "Get a `Wallet`'s nonce.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "getRecordedLogs", + "declaration": "function getRecordedLogs() external returns (Log[] memory logs);", + "visibility": "external", + "mutability": "", + "signature": "getRecordedLogs()", + "selector": "0x191553a4", + "selectorBytes": [ + 25, + 21, + 83, + 164 + ], + "description": "Gets all the recorded logs.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "isDir", + "declaration": "function isDir(string calldata path) external returns (bool result);", + "visibility": "external", + "mutability": "", + "signature": "isDir(string)", + "selector": "0x7d15d019", + "selectorBytes": [ + 125, + 21, + 208, + 25 + ], + "description": "Returns true if the path exists on disk and is pointing at a directory, else returns false.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "isFile", + "declaration": "function isFile(string calldata path) external returns (bool result);", + "visibility": "external", + "mutability": "", + "signature": "isFile(string)", + "selector": "0xe0eb04d4", + "selectorBytes": [ + 224, + 235, + 4, + 212 + ], + "description": "Returns true if the path exists on disk and is pointing at a regular file, else returns false.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "isPersistent", + "declaration": "function isPersistent(address account) external view returns (bool persistent);", + "visibility": "external", + "mutability": "view", + "signature": "isPersistent(address)", + "selector": "0xd92d8efd", + "selectorBytes": [ + 217, + 45, + 142, + 253 + ], + "description": "Returns true if the account is marked as persistent.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "keyExists", + "declaration": "function keyExists(string calldata json, string calldata key) external view returns (bool);", + "visibility": "external", + "mutability": "view", + "signature": "keyExists(string,string)", + "selector": "0x528a683c", + "selectorBytes": [ + 82, + 138, + 104, + 60 + ], + "description": "Checks if `key` exists in a JSON object.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "label", + "declaration": "function label(address account, string calldata newLabel) external;", + "visibility": "external", + "mutability": "", + "signature": "label(address,string)", + "selector": "0xc657c718", + "selectorBytes": [ + 198, + 87, + 199, + 24 + ], + "description": "Labels an address in call traces.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "load", + "declaration": "function load(address target, bytes32 slot) external view returns (bytes32 data);", + "visibility": "external", + "mutability": "view", + "signature": "load(address,bytes32)", + "selector": "0x667f9d70", + "selectorBytes": [ + 102, + 127, + 157, + 112 + ], + "description": "Loads a storage slot from an address.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "makePersistent_0", + "declaration": "function makePersistent(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address)", + "selector": "0x57e22dde", + "selectorBytes": [ + 87, + 226, + 45, + 222 + ], + "description": "Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\nMeaning, changes made to the state of this account will be kept when switching forks.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "makePersistent_1", + "declaration": "function makePersistent(address account0, address account1) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address,address)", + "selector": "0x4074e0a8", + "selectorBytes": [ + 64, + 116, + 224, + 168 + ], + "description": "See `makePersistent(address)`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "makePersistent_2", + "declaration": "function makePersistent(address account0, address account1, address account2) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address,address,address)", + "selector": "0xefb77a75", + "selectorBytes": [ + 239, + 183, + 122, + 117 + ], + "description": "See `makePersistent(address)`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "makePersistent_3", + "declaration": "function makePersistent(address[] calldata accounts) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address[])", + "selector": "0x1d9e269e", + "selectorBytes": [ + 29, + 158, + 38, + 158 + ], + "description": "See `makePersistent(address)`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "mockCallRevert_0", + "declaration": "function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCallRevert(address,bytes,bytes)", + "selector": "0xdbaad147", + "selectorBytes": [ + 219, + 170, + 209, + 71 + ], + "description": "Reverts a call to an address with specified revert data.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "mockCallRevert_1", + "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCallRevert(address,uint256,bytes,bytes)", + "selector": "0xd23cd037", + "selectorBytes": [ + 210, + 60, + 208, + 55 + ], + "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "mockCall_0", + "declaration": "function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCall(address,bytes,bytes)", + "selector": "0xb96213e4", + "selectorBytes": [ + 185, + 98, + 19, + 228 + ], + "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "mockCall_1", + "declaration": "function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCall(address,uint256,bytes,bytes)", + "selector": "0x81409b91", + "selectorBytes": [ + 129, + 64, + 155, + 145 + ], + "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "parseAddress", + "declaration": "function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseAddress(string)", + "selector": "0xc6ce059d", + "selectorBytes": [ + 198, + 206, + 5, + 157 + ], + "description": "Parses the given `string` into an `address`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseBool", + "declaration": "function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseBool(string)", + "selector": "0x974ef924", + "selectorBytes": [ + 151, + 78, + 249, + 36 + ], + "description": "Parses the given `string` into a `bool`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseBytes", + "declaration": "function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseBytes(string)", + "selector": "0x8f5d232d", + "selectorBytes": [ + 143, + 93, + 35, + 45 + ], + "description": "Parses the given `string` into `bytes`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseBytes32", + "declaration": "function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseBytes32(string)", + "selector": "0x087e6e81", + "selectorBytes": [ + 8, + 126, + 110, + 129 + ], + "description": "Parses the given `string` into a `bytes32`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseInt", + "declaration": "function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseInt(string)", + "selector": "0x42346c5e", + "selectorBytes": [ + 66, + 52, + 108, + 94 + ], + "description": "Parses the given `string` into a `int256`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonAddress", + "declaration": "function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonAddress(string,string)", + "selector": "0x1e19e657", + "selectorBytes": [ + 30, + 25, + 230, + 87 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `address`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonAddressArray", + "declaration": "function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonAddressArray(string,string)", + "selector": "0x2fce7883", + "selectorBytes": [ + 47, + 206, + 120, + 131 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `address[]`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonBool", + "declaration": "function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBool(string,string)", + "selector": "0x9f86dc91", + "selectorBytes": [ + 159, + 134, + 220, + 145 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `bool`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonBoolArray", + "declaration": "function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBoolArray(string,string)", + "selector": "0x91f3b94f", + "selectorBytes": [ + 145, + 243, + 185, + 79 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `bool[]`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonBytes", + "declaration": "function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytes(string,string)", + "selector": "0xfd921be8", + "selectorBytes": [ + 253, + 146, + 27, + 232 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `bytes`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonBytes32", + "declaration": "function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytes32(string,string)", + "selector": "0x1777e59d", + "selectorBytes": [ + 23, + 119, + 229, + 157 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `bytes32`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonBytes32Array", + "declaration": "function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytes32Array(string,string)", + "selector": "0x91c75bc3", + "selectorBytes": [ + 145, + 199, + 91, + 195 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `bytes32[]`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonBytesArray", + "declaration": "function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytesArray(string,string)", + "selector": "0x6631aa99", + "selectorBytes": [ + 102, + 49, + 170, + 153 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `bytes[]`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonInt", + "declaration": "function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonInt(string,string)", + "selector": "0x7b048ccd", + "selectorBytes": [ + 123, + 4, + 140, + 205 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `int256`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonIntArray", + "declaration": "function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonIntArray(string,string)", + "selector": "0x9983c28a", + "selectorBytes": [ + 153, + 131, + 194, + 138 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `int256[]`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonKeys", + "declaration": "function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonKeys(string,string)", + "selector": "0x213e4198", + "selectorBytes": [ + 33, + 62, + 65, + 152 + ], + "description": "Returns an array of all the keys in a JSON object.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonString", + "declaration": "function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonString(string,string)", + "selector": "0x49c4fac8", + "selectorBytes": [ + 73, + 196, + 250, + 200 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `string`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonStringArray", + "declaration": "function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonStringArray(string,string)", + "selector": "0x498fdcf4", + "selectorBytes": [ + 73, + 143, + 220, + 244 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `string[]`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonUint", + "declaration": "function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonUint(string,string)", + "selector": "0xaddde2b6", + "selectorBytes": [ + 173, + 221, + 226, + 182 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `uint256`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJsonUintArray", + "declaration": "function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonUintArray(string,string)", + "selector": "0x522074ab", + "selectorBytes": [ + 82, + 32, + 116, + 171 + ], + "description": "Parses a string of JSON data at `key` and coerces it to `uint256[]`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJson_0", + "declaration": "function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJson(string)", + "selector": "0x6a82600a", + "selectorBytes": [ + 106, + 130, + 96, + 10 + ], + "description": "ABI-encodes a JSON object.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseJson_1", + "declaration": "function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJson(string,string)", + "selector": "0x85940ef1", + "selectorBytes": [ + 133, + 148, + 14, + 241 + ], + "description": "ABI-encodes a JSON object at `key`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "parseUint", + "declaration": "function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseUint(string)", + "selector": "0xfa91454d", + "selectorBytes": [ + 250, + 145, + 69, + 77 + ], + "description": "Parses the given `string` into a `uint256`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "pauseGasMetering", + "declaration": "function pauseGasMetering() external;", + "visibility": "external", + "mutability": "", + "signature": "pauseGasMetering()", + "selector": "0xd1a5b36f", + "selectorBytes": [ + 209, + 165, + 179, + 111 + ], + "description": "Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "prank_0", + "declaration": "function prank(address msgSender) external;", + "visibility": "external", + "mutability": "", + "signature": "prank(address)", + "selector": "0xca669fa7", + "selectorBytes": [ + 202, + 102, + 159, + 167 + ], + "description": "Sets the *next* call's `msg.sender` to be the input address.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "prank_1", + "declaration": "function prank(address msgSender, address txOrigin) external;", + "visibility": "external", + "mutability": "", + "signature": "prank(address,address)", + "selector": "0x47e50cce", + "selectorBytes": [ + 71, + 229, + 12, + 206 + ], + "description": "Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "prevrandao", + "declaration": "function prevrandao(bytes32 newPrevrandao) external;", + "visibility": "external", + "mutability": "", + "signature": "prevrandao(bytes32)", + "selector": "0x3b925549", + "selectorBytes": [ + 59, + 146, + 85, + 73 + ], + "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "projectRoot", + "declaration": "function projectRoot() external view returns (string memory path);", + "visibility": "external", + "mutability": "view", + "signature": "projectRoot()", + "selector": "0xd930a0e6", + "selectorBytes": [ + 217, + 48, + 160, + 230 + ], + "description": "Get the path of the current project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "readCallers", + "declaration": "function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);", + "visibility": "external", + "mutability": "", + "signature": "readCallers()", + "selector": "0x4ad0bac9", + "selectorBytes": [ + 74, + 208, + 186, + 201 + ], + "description": "Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "readDir_0", + "declaration": "function readDir(string calldata path) external view returns (DirEntry[] memory entries);", + "visibility": "external", + "mutability": "view", + "signature": "readDir(string)", + "selector": "0xc4bc59e0", + "selectorBytes": [ + 196, + 188, + 89, + 224 + ], + "description": "Reads the directory at the given path recursively, up to `maxDepth`.\n`maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.\nFollows symbolic links if `followLinks` is true.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "readDir_1", + "declaration": "function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);", + "visibility": "external", + "mutability": "view", + "signature": "readDir(string,uint64)", + "selector": "0x1497876c", + "selectorBytes": [ + 20, + 151, + 135, + 108 + ], + "description": "See `readDir(string)`.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "readDir_2", + "declaration": "function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries);", + "visibility": "external", + "mutability": "view", + "signature": "readDir(string,uint64,bool)", + "selector": "0x8102d70d", + "selectorBytes": [ + 129, + 2, + 215, + 13 + ], + "description": "See `readDir(string)`.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "readFile", + "declaration": "function readFile(string calldata path) external view returns (string memory data);", + "visibility": "external", + "mutability": "view", + "signature": "readFile(string)", + "selector": "0x60f9bb11", + "selectorBytes": [ + 96, + 249, + 187, + 17 + ], + "description": "Reads the entire content of file to string. `path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "readFileBinary", + "declaration": "function readFileBinary(string calldata path) external view returns (bytes memory data);", + "visibility": "external", + "mutability": "view", + "signature": "readFileBinary(string)", + "selector": "0x16ed7bc4", + "selectorBytes": [ + 22, + 237, + 123, + 196 + ], + "description": "Reads the entire content of file as binary. `path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "readLine", + "declaration": "function readLine(string calldata path) external view returns (string memory line);", + "visibility": "external", + "mutability": "view", + "signature": "readLine(string)", + "selector": "0x70f55728", + "selectorBytes": [ + 112, + 245, + 87, + 40 + ], + "description": "Reads next line of file to string.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "readLink", + "declaration": "function readLink(string calldata linkPath) external view returns (string memory targetPath);", + "visibility": "external", + "mutability": "view", + "signature": "readLink(string)", + "selector": "0x9f5684a2", + "selectorBytes": [ + 159, + 86, + 132, + 162 + ], + "description": "Reads a symbolic link, returning the path that the link points to.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` is not a symbolic link.\n- `path` does not exist.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "record", + "declaration": "function record() external;", + "visibility": "external", + "mutability": "", + "signature": "record()", + "selector": "0x266cf109", + "selectorBytes": [ + 38, + 108, + 241, + 9 + ], + "description": "Records all storage reads and writes.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "recordLogs", + "declaration": "function recordLogs() external;", + "visibility": "external", + "mutability": "", + "signature": "recordLogs()", + "selector": "0x41af2f52", + "selectorBytes": [ + 65, + 175, + 47, + 82 + ], + "description": "Record all the transaction logs.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "rememberKey", + "declaration": "function rememberKey(uint256 privateKey) external returns (address keyAddr);", + "visibility": "external", + "mutability": "", + "signature": "rememberKey(uint256)", + "selector": "0x22100064", + "selectorBytes": [ + 34, + 16, + 0, + 100 + ], + "description": "Adds a private key to the local forge wallet and returns the address.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "removeDir", + "declaration": "function removeDir(string calldata path, bool recursive) external;", + "visibility": "external", + "mutability": "", + "signature": "removeDir(string,bool)", + "selector": "0x45c62011", + "selectorBytes": [ + 69, + 198, + 32, + 17 + ], + "description": "Removes a directory at the provided path.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` doesn't exist.\n- `path` isn't a directory.\n- User lacks permissions to modify `path`.\n- The directory is not empty and `recursive` is false.\n`path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "removeFile", + "declaration": "function removeFile(string calldata path) external;", + "visibility": "external", + "mutability": "", + "signature": "removeFile(string)", + "selector": "0xf1afe04d", + "selectorBytes": [ + 241, + 175, + 224, + 77 + ], + "description": "Removes a file from the filesystem.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` points to a directory.\n- The file doesn't exist.\n- The user lacks permissions to remove the file.\n`path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "resetNonce", + "declaration": "function resetNonce(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "resetNonce(address)", + "selector": "0x1c72346d", + "selectorBytes": [ + 28, + 114, + 52, + 109 + ], + "description": "Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "resumeGasMetering", + "declaration": "function resumeGasMetering() external;", + "visibility": "external", + "mutability": "", + "signature": "resumeGasMetering()", + "selector": "0x2bcd50e0", + "selectorBytes": [ + 43, + 205, + 80, + 224 + ], + "description": "Resumes gas metering (i.e. gas usage is counted again). Noop if already on.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "revertTo", + "declaration": "function revertTo(uint256 snapshotId) external returns (bool success);", + "visibility": "external", + "mutability": "", + "signature": "revertTo(uint256)", + "selector": "0x44d7f0a4", + "selectorBytes": [ + 68, + 215, + 240, + 164 + ], + "description": "Revert the state of the EVM to a previous snapshot\nTakes the snapshot ID to revert to.\nThis deletes the snapshot and all snapshots taken after the given snapshot ID.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "revokePersistent_0", + "declaration": "function revokePersistent(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "revokePersistent(address)", + "selector": "0x997a0222", + "selectorBytes": [ + 153, + 122, + 2, + 34 + ], + "description": "Revokes persistent status from the address, previously added via `makePersistent`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "revokePersistent_1", + "declaration": "function revokePersistent(address[] calldata accounts) external;", + "visibility": "external", + "mutability": "", + "signature": "revokePersistent(address[])", + "selector": "0x3ce969e6", + "selectorBytes": [ + 60, + 233, + 105, + 230 + ], + "description": "See `revokePersistent(address)`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "roll", + "declaration": "function roll(uint256 newHeight) external;", + "visibility": "external", + "mutability": "", + "signature": "roll(uint256)", + "selector": "0x1f7b4f30", + "selectorBytes": [ + 31, + 123, + 79, + 48 + ], + "description": "Sets `block.height`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "rollFork_0", + "declaration": "function rollFork(uint256 blockNumber) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(uint256)", + "selector": "0xd9bbf3a1", + "selectorBytes": [ + 217, + 187, + 243, + 161 + ], + "description": "Updates the currently active fork to given block number\nThis is similar to `roll` but for the currently active fork.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "rollFork_1", + "declaration": "function rollFork(bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(bytes32)", + "selector": "0x0f29772b", + "selectorBytes": [ + 15, + 41, + 119, + 43 + ], + "description": "Updates the currently active fork to given transaction. This will `rollFork` with the number\nof the block the transaction was mined in and replays all transaction mined before it in the block.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "rollFork_2", + "declaration": "function rollFork(uint256 forkId, uint256 blockNumber) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(uint256,uint256)", + "selector": "0xd74c83a4", + "selectorBytes": [ + 215, + 76, + 131, + 164 + ], + "description": "Updates the given fork to given block number.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "rollFork_3", + "declaration": "function rollFork(uint256 forkId, bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(uint256,bytes32)", + "selector": "0xf2830f7b", + "selectorBytes": [ + 242, + 131, + 15, + 123 + ], + "description": "Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "rpcUrl", + "declaration": "function rpcUrl(string calldata rpcAlias) external view returns (string memory json);", + "visibility": "external", + "mutability": "view", + "signature": "rpcUrl(string)", + "selector": "0x975a6ce9", + "selectorBytes": [ + 151, + 90, + 108, + 233 + ], + "description": "Returns the RPC url for the given alias.", + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "id": "rpcUrlStructs", + "declaration": "function rpcUrlStructs() external view returns (Rpc[] memory urls);", + "visibility": "external", + "mutability": "view", + "signature": "rpcUrlStructs()", + "selector": "0x9d2ad72a", + "selectorBytes": [ + 157, + 42, + 215, + 42 + ], + "description": "Returns all rpc urls and their aliases as structs.", + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "id": "rpcUrls", + "declaration": "function rpcUrls() external view returns (string[2][] memory urls);", + "visibility": "external", + "mutability": "view", + "signature": "rpcUrls()", + "selector": "0xa85a8418", + "selectorBytes": [ + 168, + 90, + 132, + 24 + ], + "description": "Returns all rpc urls and their aliases `[alias, url][]`.", + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "id": "selectFork", + "declaration": "function selectFork(uint256 forkId) external;", + "visibility": "external", + "mutability": "", + "signature": "selectFork(uint256)", + "selector": "0x9ebf6827", + "selectorBytes": [ + 158, + 191, + 104, + 39 + ], + "description": "Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "serializeAddress_0", + "declaration": "function serializeAddress(string calldata objectKey, string calldata valueKey, address value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeAddress(string,string,address)", + "selector": "0x972c6062", + "selectorBytes": [ + 151, + 44, + 96, + 98 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeAddress_1", + "declaration": "function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeAddress(string,string,address[])", + "selector": "0x1e356e1a", + "selectorBytes": [ + 30, + 53, + 110, + 26 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeBool_0", + "declaration": "function serializeBool(string calldata objectKey, string calldata valueKey, bool value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBool(string,string,bool)", + "selector": "0xac22e971", + "selectorBytes": [ + 172, + 34, + 233, + 113 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeBool_1", + "declaration": "function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBool(string,string,bool[])", + "selector": "0x92925aa1", + "selectorBytes": [ + 146, + 146, + 90, + 161 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeBytes32_0", + "declaration": "function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes32(string,string,bytes32)", + "selector": "0x2d812b44", + "selectorBytes": [ + 45, + 129, + 43, + 68 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeBytes32_1", + "declaration": "function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes32(string,string,bytes32[])", + "selector": "0x201e43e2", + "selectorBytes": [ + 32, + 30, + 67, + 226 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeBytes_0", + "declaration": "function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes(string,string,bytes)", + "selector": "0xf21d52c7", + "selectorBytes": [ + 242, + 29, + 82, + 199 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeBytes_1", + "declaration": "function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes(string,string,bytes[])", + "selector": "0x9884b232", + "selectorBytes": [ + 152, + 132, + 178, + 50 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeInt_0", + "declaration": "function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeInt(string,string,int256)", + "selector": "0x3f33db60", + "selectorBytes": [ + 63, + 51, + 219, + 96 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeInt_1", + "declaration": "function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeInt(string,string,int256[])", + "selector": "0x7676e127", + "selectorBytes": [ + 118, + 118, + 225, + 39 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeJson", + "declaration": "function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeJson(string,string)", + "selector": "0x9b3358b0", + "selectorBytes": [ + 155, + 51, + 88, + 176 + ], + "description": "Serializes a key and value to a JSON object stored in-memory that can be later written to a file.\nReturns the stringified version of the specific JSON file up to that moment.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeString_0", + "declaration": "function serializeString(string calldata objectKey, string calldata valueKey, string calldata value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeString(string,string,string)", + "selector": "0x88da6d35", + "selectorBytes": [ + 136, + 218, + 109, + 53 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeString_1", + "declaration": "function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeString(string,string,string[])", + "selector": "0x561cd6f3", + "selectorBytes": [ + 86, + 28, + 214, + 243 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeUint_0", + "declaration": "function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeUint(string,string,uint256)", + "selector": "0x129e9002", + "selectorBytes": [ + 18, + 158, + 144, + 2 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "serializeUint_1", + "declaration": "function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeUint(string,string,uint256[])", + "selector": "0xfee9a469", + "selectorBytes": [ + 254, + 233, + 164, + 105 + ], + "description": "See `serializeJson`.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "setEnv", + "declaration": "function setEnv(string calldata name, string calldata value) external;", + "visibility": "external", + "mutability": "", + "signature": "setEnv(string,string)", + "selector": "0x3d5923ee", + "selectorBytes": [ + 61, + 89, + 35, + 238 + ], + "description": "Sets environment variables.", + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "id": "setNonce", + "declaration": "function setNonce(address account, uint64 newNonce) external;", + "visibility": "external", + "mutability": "", + "signature": "setNonce(address,uint64)", + "selector": "0xf8e18b57", + "selectorBytes": [ + 248, + 225, + 139, + 87 + ], + "description": "Sets the nonce of an account. Must be higher than the current nonce of the account.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "setNonceUnsafe", + "declaration": "function setNonceUnsafe(address account, uint64 newNonce) external;", + "visibility": "external", + "mutability": "", + "signature": "setNonceUnsafe(address,uint64)", + "selector": "0x9b67b21c", + "selectorBytes": [ + 155, + 103, + 178, + 28 + ], + "description": "Sets the nonce of an account to an arbitrary value.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "sign_0", + "declaration": "function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "pure", + "signature": "sign(uint256,bytes32)", + "selector": "0xe341eaa4", + "selectorBytes": [ + 227, + 65, + 234, + 164 + ], + "description": "Signs data.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "sign_1", + "declaration": "function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "", + "signature": "sign((address,uint256,uint256,uint256),bytes32)", + "selector": "0xb25c5a25", + "selectorBytes": [ + 178, + 92, + 90, + 37 + ], + "description": "Signs data with a `Wallet`.", + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "id": "skip", + "declaration": "function skip(bool skipTest) external;", + "visibility": "external", + "mutability": "", + "signature": "skip(bool)", + "selector": "0xdd82d13e", + "selectorBytes": [ + 221, + 130, + 209, + 62 + ], + "description": "Marks a test as skipped. Must be called at the top of the test.", + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "sleep", + "declaration": "function sleep(uint256 duration) external;", + "visibility": "external", + "mutability": "", + "signature": "sleep(uint256)", + "selector": "0xfa9d8713", + "selectorBytes": [ + 250, + 157, + 135, + 19 + ], + "description": "Suspends execution of the main thread for `duration` milliseconds.", + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "id": "snapshot", + "declaration": "function snapshot() external returns (uint256 snapshotId);", + "visibility": "external", + "mutability": "", + "signature": "snapshot()", + "selector": "0x9711715a", + "selectorBytes": [ + 151, + 17, + 113, + 90 + ], + "description": "Snapshot the current state of the evm.\nReturns the ID of the snapshot that was created.\nTo revert a snapshot use `revertTo`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "startBroadcast_0", + "declaration": "function startBroadcast() external;", + "visibility": "external", + "mutability": "", + "signature": "startBroadcast()", + "selector": "0x7fb5297f", + "selectorBytes": [ + 127, + 181, + 41, + 127 + ], + "description": "Using the address that calls the test contract, has all subsequent calls\n(at this call depth only) create transactions that can later be signed and sent onchain.", + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "id": "startBroadcast_1", + "declaration": "function startBroadcast(address signer) external;", + "visibility": "external", + "mutability": "", + "signature": "startBroadcast(address)", + "selector": "0x7fec2a8d", + "selectorBytes": [ + 127, + 236, + 42, + 141 + ], + "description": "Has all subsequent calls (at this call depth only) create transactions with the address\nprovided that can later be signed and sent onchain.", + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "id": "startBroadcast_2", + "declaration": "function startBroadcast(uint256 privateKey) external;", + "visibility": "external", + "mutability": "", + "signature": "startBroadcast(uint256)", + "selector": "0xce817d47", + "selectorBytes": [ + 206, + 129, + 125, + 71 + ], + "description": "Has all subsequent calls (at this call depth only) create transactions with the private key\nprovided that can later be signed and sent onchain.", + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "id": "startMappingRecording", + "declaration": "function startMappingRecording() external;", + "visibility": "external", + "mutability": "", + "signature": "startMappingRecording()", + "selector": "0x3e9705c0", + "selectorBytes": [ + 62, + 151, + 5, + 192 + ], + "description": "Starts recording all map SSTOREs for later retrieval.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "startPrank_0", + "declaration": "function startPrank(address msgSender) external;", + "visibility": "external", + "mutability": "", + "signature": "startPrank(address)", + "selector": "0x06447d56", + "selectorBytes": [ + 6, + 68, + 125, + 86 + ], + "description": "Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "startPrank_1", + "declaration": "function startPrank(address msgSender, address txOrigin) external;", + "visibility": "external", + "mutability": "", + "signature": "startPrank(address,address)", + "selector": "0x45b56078", + "selectorBytes": [ + 69, + 181, + 96, + 120 + ], + "description": "Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "stopBroadcast", + "declaration": "function stopBroadcast() external;", + "visibility": "external", + "mutability": "", + "signature": "stopBroadcast()", + "selector": "0x76eadd36", + "selectorBytes": [ + 118, + 234, + 221, + 54 + ], + "description": "Stops collecting onchain transactions.", + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "id": "stopMappingRecording", + "declaration": "function stopMappingRecording() external;", + "visibility": "external", + "mutability": "", + "signature": "stopMappingRecording()", + "selector": "0x0d4aae9b", + "selectorBytes": [ + 13, + 74, + 174, + 155 + ], + "description": "Stops recording all map SSTOREs for later retrieval and clears the recorded data.", + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "id": "stopPrank", + "declaration": "function stopPrank() external;", + "visibility": "external", + "mutability": "", + "signature": "stopPrank()", + "selector": "0x90c5013b", + "selectorBytes": [ + 144, + 197, + 1, + 59 + ], + "description": "Resets subsequent calls' `msg.sender` to be `address(this)`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "store", + "declaration": "function store(address target, bytes32 slot, bytes32 value) external;", + "visibility": "external", + "mutability": "", + "signature": "store(address,bytes32,bytes32)", + "selector": "0x70ca10bb", + "selectorBytes": [ + 112, + 202, + 16, + 187 + ], + "description": "Stores a value to an address' storage slot.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "toString_0", + "declaration": "function toString(address value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(address)", + "selector": "0x56ca623e", + "selectorBytes": [ + 86, + 202, + 98, + 62 + ], + "description": "Converts the given value to a `string`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "toString_1", + "declaration": "function toString(bytes calldata value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(bytes)", + "selector": "0x71aad10d", + "selectorBytes": [ + 113, + 170, + 209, + 13 + ], + "description": "Converts the given value to a `string`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "toString_2", + "declaration": "function toString(bytes32 value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(bytes32)", + "selector": "0xb11a19e8", + "selectorBytes": [ + 177, + 26, + 25, + 232 + ], + "description": "Converts the given value to a `string`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "toString_3", + "declaration": "function toString(bool value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(bool)", + "selector": "0x71dce7da", + "selectorBytes": [ + 113, + 220, + 231, + 218 + ], + "description": "Converts the given value to a `string`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "toString_4", + "declaration": "function toString(uint256 value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(uint256)", + "selector": "0x6900a3ae", + "selectorBytes": [ + 105, + 0, + 163, + 174 + ], + "description": "Converts the given value to a `string`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "toString_5", + "declaration": "function toString(int256 value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(int256)", + "selector": "0xa322c40e", + "selectorBytes": [ + 163, + 34, + 196, + 14 + ], + "description": "Converts the given value to a `string`.", + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "id": "transact_0", + "declaration": "function transact(bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "transact(bytes32)", + "selector": "0xbe646da1", + "selectorBytes": [ + 190, + 100, + 109, + 161 + ], + "description": "Fetches the given transaction from the active fork and executes it on the current state.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "transact_1", + "declaration": "function transact(uint256 forkId, bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "transact(uint256,bytes32)", + "selector": "0x4d8abc4b", + "selectorBytes": [ + 77, + 138, + 188, + 75 + ], + "description": "Fetches the given transaction from the given fork and executes it on the current state.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "tryFfi", + "declaration": "function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);", + "visibility": "external", + "mutability": "", + "signature": "tryFfi(string[])", + "selector": "0xf45c1ce7", + "selectorBytes": [ + 244, + 92, + 28, + 231 + ], + "description": "Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "txGasPrice", + "declaration": "function txGasPrice(uint256 newGasPrice) external;", + "visibility": "external", + "mutability": "", + "signature": "txGasPrice(uint256)", + "selector": "0x48f50c0f", + "selectorBytes": [ + 72, + 245, + 12, + 15 + ], + "description": "Sets `tx.gasprice`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "unixTime", + "declaration": "function unixTime() external returns (uint256 milliseconds);", + "visibility": "external", + "mutability": "", + "signature": "unixTime()", + "selector": "0x625387dc", + "selectorBytes": [ + 98, + 83, + 135, + 220 + ], + "description": "Returns the time since unix epoch in milliseconds.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "warp", + "declaration": "function warp(uint256 newTimestamp) external;", + "visibility": "external", + "mutability": "", + "signature": "warp(uint256)", + "selector": "0xe5d6bf02", + "selectorBytes": [ + 229, + 214, + 191, + 2 + ], + "description": "Sets `block.timestamp`.", + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "id": "writeFile", + "declaration": "function writeFile(string calldata path, string calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "writeFile(string,string)", + "selector": "0x897e0a97", + "selectorBytes": [ + 137, + 126, + 10, + 151 + ], + "description": "Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.\n`path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "writeFileBinary", + "declaration": "function writeFileBinary(string calldata path, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "writeFileBinary(string,bytes)", + "selector": "0x1f21fc80", + "selectorBytes": [ + 31, + 33, + 252, + 128 + ], + "description": "Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.\n`path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "id": "writeJson_0", + "declaration": "function writeJson(string calldata json, string calldata path) external;", + "visibility": "external", + "mutability": "", + "signature": "writeJson(string,string)", + "selector": "0xe23cd19f", + "selectorBytes": [ + 226, + 60, + 209, + 159 + ], + "description": "Write a serialized JSON object to a file. If the file exists, it will be overwritten.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "writeJson_1", + "declaration": "function writeJson(string calldata json, string calldata path, string calldata valueKey) external;", + "visibility": "external", + "mutability": "", + "signature": "writeJson(string,string,string)", + "selector": "0x35d6ad46", + "selectorBytes": [ + 53, + 214, + 173, + 70 + ], + "description": "Write a serialized JSON object to an **existing** JSON file, replacing a value with key = \nThis is useful to replace a specific value of a JSON file, without having to parse the entire thing.", + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "id": "writeLine", + "declaration": "function writeLine(string calldata path, string calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "writeLine(string,string)", + "selector": "0x619d897f", + "selectorBytes": [ + 97, + 157, + 137, + 127 + ], + "description": "Writes line to file, creating a file if it does not exist.\n`path` is relative to the project root.", + "group": "filesystem", + "status": "stable", + "safety": "safe" + } +] \ No newline at end of file diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json new file mode 100644 index 0000000000000..8b28cc11e3ea6 --- /dev/null +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -0,0 +1,274 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Cheatcodes", + "description": "Foundry cheatcodes. Learn more: ", + "type": "array", + "items": { + "$ref": "#/definitions/Cheatcode" + }, + "definitions": { + "Cheatcode": { + "description": "Specification of a single cheatcode.", + "type": "object", + "required": [ + "declaration", + "description", + "group", + "id", + "mutability", + "safety", + "selector", + "selectorBytes", + "signature", + "status", + "visibility" + ], + "properties": { + "declaration": { + "description": "The Solidity function declaration string, including full type and parameter names, visibility, etc.", + "type": "string" + }, + "description": { + "description": "The description of the cheatcode. This is a markdown string derived from the documentation of the function declaration.", + "type": "string" + }, + "group": { + "description": "The group this cheatcode belongs to. Has to be specified for each cheatcode.", + "allOf": [ + { + "$ref": "#/definitions/Group" + } + ] + }, + "id": { + "description": "The cheatcode's unique identifier. This is the function name, optionally appended with an index if it is overloaded.", + "type": "string" + }, + "mutability": { + "description": "The Solidity function state mutability attribute.", + "allOf": [ + { + "$ref": "#/definitions/Mutability" + } + ] + }, + "safety": { + "description": "Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an unexpected way.\n\nDefaults first to the group's safety if unspecified. If the group is ambiguous, then it must be specified manually.", + "allOf": [ + { + "$ref": "#/definitions/Safety" + } + ] + }, + "selector": { + "description": "The hex-encoded, \"0x\"-prefixed 4-byte function selector, which is the Keccak-256 hash of `signature`.", + "type": "string" + }, + "selectorBytes": { + "description": "The 4-byte function selector as a byte array.", + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + }, + "maxItems": 4, + "minItems": 4 + }, + "signature": { + "description": "The standard function signature used to calculate `selector`. See the [Solidity docs] for more information.\n\n[Solidity docs]: https://docs.soliditylang.org/en/latest/abi-spec.html#function-selector", + "type": "string" + }, + "status": { + "description": "The current status of the cheatcode. E.g. whether it is stable or experimental, etc. Has to be specified for each cheatcode.", + "allOf": [ + { + "$ref": "#/definitions/Status" + } + ] + }, + "visibility": { + "description": "The Solidity function visibility attribute. This is currently always `external`, but this may change in the future.", + "allOf": [ + { + "$ref": "#/definitions/Visibility" + } + ] + } + }, + "additionalProperties": false + }, + "Group": { + "description": "Cheatcode groups. Initially derived and modified from inline comments in [`forge-std`'s `Vm.sol`][vmsol].\n\n[vmsol]: https://github.com/foundry-rs/forge-std/blob/dcb0d52bc4399d37a6545848e3b8f9d03c77b98d/src/Vm.sol", + "oneOf": [ + { + "description": "Cheatcodes that read from, or write to the current EVM execution state.\n\nExamples: any of the `record` cheatcodes, `chainId`, `coinbase`.\n\nSafety: ambiguous, depends on whether the cheatcode is read-only or not.", + "type": "string", + "enum": [ + "evm" + ] + }, + { + "description": "Cheatcodes that interact with how a test is run.\n\nExamples: `assume`, `skip`, `expectRevert`.\n\nSafety: ambiguous, depends on whether the cheatcode is read-only or not.", + "type": "string", + "enum": [ + "testing" + ] + }, + { + "description": "Cheatcodes that interact with how a script is run.\n\nExamples: `broadcast`, `startBroadcast`, `stopBroadcast`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "scripting" + ] + }, + { + "description": "Cheatcodes that interact with the OS or filesystem.\n\nExamples: `ffi`, `projectRoot`, `writeFile`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "filesystem" + ] + }, + { + "description": "Cheatcodes that interact with the program's environment variables.\n\nExamples: `setEnv`, `envBool`, `envOr`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "environment" + ] + }, + { + "description": "Utility cheatcodes that deal with string parsing and manipulation.\n\nExamples: `toString`. `parseBytes`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "string" + ] + }, + { + "description": "Utility cheatcodes that deal with parsing values from and converting values to JSON.\n\nExamples: `serializeJson`, `parseJsonUint`, `writeJson`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "json" + ] + }, + { + "description": "Generic, uncategorized utilities.\n\nExamples: `toString`, `parse*`, `serialize*`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "utilities" + ] + } + ] + }, + "Mutability": { + "description": "Solidity function state mutability attribute. See the [Solidity docs] for more information.\n\n[Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#state-mutability", + "oneOf": [ + { + "description": "Disallows modification or access of state.", + "type": "string", + "enum": [ + "pure" + ] + }, + { + "description": "Disallows modification of state.", + "type": "string", + "enum": [ + "view" + ] + }, + { + "description": "Allows modification of state.", + "type": "string", + "enum": [ + "" + ] + } + ] + }, + "Safety": { + "description": "Cheatcode safety.", + "oneOf": [ + { + "description": "The cheatcode is not safe to use in scripts.", + "type": "string", + "enum": [ + "unsafe" + ] + }, + { + "description": "The cheatcode is safe to use in scripts.", + "type": "string", + "enum": [ + "safe" + ] + } + ] + }, + "Status": { + "description": "The status of a cheatcode.", + "oneOf": [ + { + "description": "The cheatcode and its API is currently stable.", + "type": "string", + "enum": [ + "stable" + ] + }, + { + "description": "The cheatcode is unstable, meaning it may contain bugs and may break its API on any release.\n\nUse of experimental cheatcodes will result in a warning.", + "type": "string", + "enum": [ + "experimental" + ] + }, + { + "description": "The cheatcode has been deprecated, meaning it will be removed in a future release.\n\nUse of deprecated cheatcodes is discouraged and will result in a warning.", + "type": "string", + "enum": [ + "deprecated" + ] + }, + { + "description": "The cheatcode has been removed and is no longer available for use.\n\nUse of removed cheatcodes will result in a hard error.", + "type": "string", + "enum": [ + "removed" + ] + } + ] + }, + "Visibility": { + "description": "Solidity function visibility attribute. See the [Solidity docs] for more information.\n\n[Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#function-visibility", + "oneOf": [ + { + "description": "The function is only visible externally.", + "type": "string", + "enum": [ + "external" + ] + }, + { + "description": "Visible externally and internally.", + "type": "string", + "enum": [ + "public" + ] + }, + { + "description": "Only visible internally.", + "type": "string", + "enum": [ + "internal" + ] + }, + { + "description": "Only visible in the current contract", + "type": "string", + "enum": [ + "private" + ] + } + ] + } + } +} \ No newline at end of file diff --git a/crates/cheatcodes/src/defs/mod.rs b/crates/cheatcodes/src/defs/mod.rs new file mode 100644 index 0000000000000..1ab640f29bf1c --- /dev/null +++ b/crates/cheatcodes/src/defs/mod.rs @@ -0,0 +1,265 @@ +//! Cheatcode definitions. + +use alloy_sol_types::SolCall; +use serde::{Deserialize, Serialize}; + +mod vm; +pub use vm::Vm; + +/// Cheatcode definition trait. Implemented by all [`Vm`] functions. +pub trait CheatcodeDef: std::fmt::Debug + Clone + SolCall { + /// The static cheatcode definition. + const CHEATCODE: &'static Cheatcode<'static>; +} + +/// Specification of a single cheatcode. +#[derive(Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Cheatcode<'a> { + // Automatically-generated fields. + /// The cheatcode's unique identifier. This is the function name, optionally appended with an + /// index if it is overloaded. + pub id: &'a str, + /// The Solidity function declaration string, including full type and parameter names, + /// visibility, etc. + pub declaration: &'a str, + /// The Solidity function visibility attribute. This is currently always `external`, but this + /// may change in the future. + pub visibility: Visibility, + /// The Solidity function state mutability attribute. + pub mutability: Mutability, + /// The standard function signature used to calculate `selector`. + /// See the [Solidity docs] for more information. + /// + /// [Solidity docs]: https://docs.soliditylang.org/en/latest/abi-spec.html#function-selector + pub signature: &'a str, + /// The hex-encoded, "0x"-prefixed 4-byte function selector, + /// which is the Keccak-256 hash of `signature`. + pub selector: &'a str, + /// The 4-byte function selector as a byte array. + pub selector_bytes: [u8; 4], + /// The description of the cheatcode. + /// This is a markdown string derived from the documentation of the function declaration. + pub description: &'a str, + + // Manually-specified fields. + /// The group this cheatcode belongs to. + /// Has to be specified for each cheatcode. + pub group: Group, + /// The current status of the cheatcode. E.g. whether it is stable or experimental, etc. + /// Has to be specified for each cheatcode. + pub status: Status, + /// Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an + /// unexpected way. + /// + /// Defaults first to the group's safety if unspecified. If the group is ambiguous, then it + /// must be specified manually. + pub safety: Safety, +} + +/// Solidity function visibility attribute. See the [Solidity docs] for more information. +/// +/// [Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#function-visibility +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub enum Visibility { + /// The function is only visible externally. + External, + /// Visible externally and internally. + Public, + /// Only visible internally. + Internal, + /// Only visible in the current contract + Private, +} + +impl Visibility { + /// Returns the string representation of the visibility. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::External => "external", + Self::Public => "public", + Self::Internal => "internal", + Self::Private => "private", + } + } +} + +/// Solidity function state mutability attribute. See the [Solidity docs] for more information. +/// +/// [Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#state-mutability +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub enum Mutability { + /// Disallows modification or access of state. + Pure, + /// Disallows modification of state. + View, + /// Allows modification of state. + #[serde(rename = "")] + None, +} + +impl Mutability { + /// Returns the string representation of the mutability. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::Pure => "pure", + Self::View => "view", + Self::None => "", + } + } +} + +/// The status of a cheatcode. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub enum Status { + /// The cheatcode and its API is currently stable. + Stable, + /// The cheatcode is unstable, meaning it may contain bugs and may break its API on any + /// release. + /// + /// Use of experimental cheatcodes will result in a warning. + Experimental, + /// The cheatcode has been deprecated, meaning it will be removed in a future release. + /// + /// Use of deprecated cheatcodes is discouraged and will result in a warning. + Deprecated, + /// The cheatcode has been removed and is no longer available for use. + /// + /// Use of removed cheatcodes will result in a hard error. + Removed, +} + +/// Cheatcode groups. +/// Initially derived and modified from inline comments in [`forge-std`'s `Vm.sol`][vmsol]. +/// +/// [vmsol]: https://github.com/foundry-rs/forge-std/blob/dcb0d52bc4399d37a6545848e3b8f9d03c77b98d/src/Vm.sol +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub enum Group { + /// Cheatcodes that read from, or write to the current EVM execution state. + /// + /// Examples: any of the `record` cheatcodes, `chainId`, `coinbase`. + /// + /// Safety: ambiguous, depends on whether the cheatcode is read-only or not. + Evm, + /// Cheatcodes that interact with how a test is run. + /// + /// Examples: `assume`, `skip`, `expectRevert`. + /// + /// Safety: ambiguous, depends on whether the cheatcode is read-only or not. + Testing, + /// Cheatcodes that interact with how a script is run. + /// + /// Examples: `broadcast`, `startBroadcast`, `stopBroadcast`. + /// + /// Safety: safe. + Scripting, + /// Cheatcodes that interact with the OS or filesystem. + /// + /// Examples: `ffi`, `projectRoot`, `writeFile`. + /// + /// Safety: safe. + Filesystem, + /// Cheatcodes that interact with the program's environment variables. + /// + /// Examples: `setEnv`, `envBool`, `envOr`. + /// + /// Safety: safe. + Environment, + /// Utility cheatcodes that deal with string parsing and manipulation. + /// + /// Examples: `toString`. `parseBytes`. + /// + /// Safety: safe. + String, + /// Utility cheatcodes that deal with parsing values from and converting values to JSON. + /// + /// Examples: `serializeJson`, `parseJsonUint`, `writeJson`. + /// + /// Safety: safe. + Json, + /// Generic, uncategorized utilities. + /// + /// Examples: `toString`, `parse*`, `serialize*`. + /// + /// Safety: safe. + Utilities, +} + +impl Group { + /// Returns the safety of this cheatcode group. + /// + /// Some groups are inherently safe or unsafe, while others are ambiguous and will return + /// `None`. + #[inline] + pub const fn safety(self) -> Option { + match self { + Self::Evm | Self::Testing => None, + Self::Scripting | + Self::Filesystem | + Self::Environment | + Self::String | + Self::Json | + Self::Utilities => Some(Safety::Safe), + } + } + + /// Returns this value as a string. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::Evm => "evm", + Self::Testing => "testing", + Self::Scripting => "scripting", + Self::Filesystem => "filesystem", + Self::Environment => "environment", + Self::String => "string", + Self::Json => "json", + Self::Utilities => "utilities", + } + } +} + +// TODO: Find a better name for this +/// Cheatcode safety. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub enum Safety { + /// The cheatcode is not safe to use in scripts. + Unsafe, + /// The cheatcode is safe to use in scripts. + #[default] + Safe, +} + +impl Safety { + /// Returns this value as a string. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::Safe => "safe", + Self::Unsafe => "unsafe", + } + } + + /// Returns whether this value is safe. + #[inline] + pub const fn is_safe(self) -> bool { + matches!(self, Self::Safe) + } +} diff --git a/crates/cheatcodes/src/defs/vm.rs b/crates/cheatcodes/src/defs/vm.rs new file mode 100644 index 0000000000000..e615d3129f455 --- /dev/null +++ b/crates/cheatcodes/src/defs/vm.rs @@ -0,0 +1,1119 @@ +// We don't document function parameters individually so we can't enable `missing_docs` for this +// module. Instead, we emit custom diagnostics in `#[derive(Cheatcode)]`. +#![allow(missing_docs)] + +use crate::{Cheatcode, CheatcodeDef, Group, Mutability, Safety, Status, Visibility}; +use alloy_sol_types::sol; +use foundry_macros::Cheatcode; + +sol! { +// Cheatcodes are marked as view/pure/none using the following rules: +// 0. A call's observable behaviour includes its return value, logs, reverts and state writes, +// 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure` +// (you are modifying some state be it the EVM, interpreter, filesystem, etc), +// 2. Otherwise if you can be influenced by an earlier call, or if reading some state, you're `view`, +// 3. Otherwise you're `pure`. + +/// Foundry cheatcodes interface. +#[derive(Debug, Cheatcode)] // Keep this list small to avoid unnecessary bloat. +interface Vm { + // ======== Types ======== + + /// Error thrown by a cheatcode. + error CheatCodeError(string message); + + /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. + enum CallerMode { + /// No caller modification is currently active. + None, + /// A one time broadcast triggered by a `vm.broadcast()` call is currently active. + Broadcast, + /// A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active. + RecurrentBroadcast, + /// A one time prank triggered by a `vm.prank()` call is currently active. + Prank, + /// A recurrent prank triggered by a `vm.startPrank()` call is currently active. + RecurrentPrank, + } + + /// An Ethereum log. Returned by `getRecordedLogs`. + struct Log { + /// The topics of the log, including the signature, if any. + bytes32[] topics; + /// The raw data of the log. + bytes data; + /// The address of the log's emitter. + address emitter; + } + + /// An RPC URL and its alias. Returned by `rpcUrlStructs`. + struct Rpc { + /// The alias of the RPC URL. + string key; + /// The RPC URL. + string url; + } + + /// A single entry in a directory listing. Returned by `readDir`. + struct DirEntry { + /// The error message, if any. + string errorMessage; + /// The path of the entry. + string path; + /// The depth of the entry. + uint64 depth; + /// Whether the entry is a directory. + bool isDir; + /// Whether the entry is a symlink. + bool isSymlink; + } + + /// Metadata information about a file. + /// + /// This structure is returned from the [`fsMetadata`] function and represents known + /// metadata about a file such as its permissions, size, modification + /// times, etc. + struct FsMetadata { + /// True if this metadata is for a directory. + bool isDir; + /// True if this metadata is for a symlink. + bool isSymlink; + /// The size of the file, in bytes, this metadata is for. + uint256 length; + /// True if this metadata is for a readonly (unwritable) file. + bool readOnly; + /// The last modification time listed in this metadata. + uint256 modified; + /// The last access time of this metadata. + uint256 accessed; + /// The creation time listed in this metadata. + uint256 created; + } + + /// A wallet with a public and private key. + struct Wallet { + /// The wallet's address. + address addr; + /// The wallet's public key `X`. + uint256 publicKeyX; + /// The wallet's public key `Y`. + uint256 publicKeyY; + /// The wallet's private key. + uint256 privateKey; + } + + /// The result of a [`tryFfi`](tryFfiCall) call. + struct FfiResult { + /// The exit code of the call. + int32 exitCode; + /// The optionally hex-decoded `stdout` data. + bytes stdout; + /// The `stderr` data. + bytes stderr; + } + + // ======== EVM ======== + + /// Gets the address for a given private key. + #[cheatcode(group = Evm, safety = Safe)] + function addr(uint256 privateKey) external pure returns (address keyAddr); + + /// Gets the nonce of an account. + #[cheatcode(group = Evm, safety = Safe)] + function getNonce(address account) external view returns (uint64 nonce); + + /// Loads a storage slot from an address. + #[cheatcode(group = Evm, safety = Safe)] + function load(address target, bytes32 slot) external view returns (bytes32 data); + + /// Signs data. + #[cheatcode(group = Evm, safety = Safe)] + function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + + // -------- Record Storage -------- + + /// Records all storage reads and writes. + #[cheatcode(group = Evm, safety = Safe)] + function record() external; + + /// Gets all accessed reads and write slot from a `vm.record` session, for a given address. + #[cheatcode(group = Evm, safety = Safe)] + function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots); + + // -------- Recording Map Writes -------- + + /// Starts recording all map SSTOREs for later retrieval. + #[cheatcode(group = Evm, safety = Safe)] + function startMappingRecording() external; + + /// Stops recording all map SSTOREs for later retrieval and clears the recorded data. + #[cheatcode(group = Evm, safety = Safe)] + function stopMappingRecording() external; + + /// Gets the number of elements in the mapping at the given slot, for a given address. + #[cheatcode(group = Evm, safety = Safe)] + function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length); + + /// Gets the elements at index idx of the mapping at the given slot, for a given address. The + /// index must be less than the length of the mapping (i.e. the number of keys in the mapping). + #[cheatcode(group = Evm, safety = Safe)] + function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value); + + /// Gets the map key and parent of a mapping at a given slot, for a given address. + #[cheatcode(group = Evm, safety = Safe)] + function getMappingKeyAndParentOf(address target, bytes32 elementSlot) + external + returns (bool found, bytes32 key, bytes32 parent); + + // -------- Block and Transaction Properties -------- + + /// Sets `block.chainid`. + #[cheatcode(group = Evm, safety = Unsafe)] + function chainId(uint256 newChainId) external; + + /// Sets `block.coinbase`. + #[cheatcode(group = Evm, safety = Unsafe)] + function coinbase(address newCoinbase) external; + + /// Sets `block.difficulty`. + /// Not available on EVM versions from Paris onwards. Use `prevrandao` instead. + /// Reverts if used on unsupported EVM versions. + #[cheatcode(group = Evm, safety = Unsafe)] + function difficulty(uint256 newDifficulty) external; + + /// Sets `block.basefee`. + #[cheatcode(group = Evm, safety = Unsafe)] + function fee(uint256 newBasefee) external; + + /// Sets `block.prevrandao`. + /// Not available on EVM versions before Paris. Use `difficulty` instead. + /// If used on unsupported EVM versions it will revert. + #[cheatcode(group = Evm, safety = Unsafe)] + function prevrandao(bytes32 newPrevrandao) external; + + /// Sets `block.height`. + #[cheatcode(group = Evm, safety = Unsafe)] + function roll(uint256 newHeight) external; + + /// Sets `tx.gasprice`. + #[cheatcode(group = Evm, safety = Unsafe)] + function txGasPrice(uint256 newGasPrice) external; + + /// Sets `block.timestamp`. + #[cheatcode(group = Evm, safety = Unsafe)] + function warp(uint256 newTimestamp) external; + + // -------- Account State -------- + + /// Sets an address' balance. + #[cheatcode(group = Evm, safety = Unsafe)] + function deal(address account, uint256 newBalance) external; + + /// Sets an address' code. + #[cheatcode(group = Evm, safety = Unsafe)] + function etch(address target, bytes calldata newRuntimeBytecode) external; + + /// Resets the nonce of an account to 0 for EOAs and 1 for contract accounts. + #[cheatcode(group = Evm, safety = Unsafe)] + function resetNonce(address account) external; + + /// Sets the nonce of an account. Must be higher than the current nonce of the account. + #[cheatcode(group = Evm, safety = Unsafe)] + function setNonce(address account, uint64 newNonce) external; + + /// Sets the nonce of an account to an arbitrary value. + #[cheatcode(group = Evm, safety = Unsafe)] + function setNonceUnsafe(address account, uint64 newNonce) external; + + /// Stores a value to an address' storage slot. + #[cheatcode(group = Evm, safety = Unsafe)] + function store(address target, bytes32 slot, bytes32 value) external; + + // -------- Call Manipulation -------- + // --- Mocks --- + + /// Clears all mocked calls. + #[cheatcode(group = Evm, safety = Unsafe)] + function clearMockedCalls() external; + + /// Mocks a call to an address, returning specified data. + /// Calldata can either be strict or a partial match, e.g. if you only + /// pass a Solidity selector to the expected calldata, then the entire Solidity + /// function will be mocked. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCall(address callee, bytes calldata data, bytes calldata returnData) external; + + /// Mocks a call to an address with a specific `msg.value`, returning specified data. + /// Calldata match takes precedence over `msg.value` in case of ambiguity. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; + + /// Reverts a call to an address with specified revert data. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; + + /// Reverts a call to an address with a specific `msg.value`, with specified revert data. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) + external; + + // --- Impersonation (pranks) --- + + /// Sets the *next* call's `msg.sender` to be the input address. + #[cheatcode(group = Evm, safety = Unsafe)] + function prank(address msgSender) external; + + /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called. + #[cheatcode(group = Evm, safety = Unsafe)] + function startPrank(address msgSender) external; + + /// Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input. + #[cheatcode(group = Evm, safety = Unsafe)] + function prank(address msgSender, address txOrigin) external; + + /// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input. + #[cheatcode(group = Evm, safety = Unsafe)] + function startPrank(address msgSender, address txOrigin) external; + + /// Resets subsequent calls' `msg.sender` to be `address(this)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function stopPrank() external; + + /// Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification. + #[cheatcode(group = Evm, safety = Unsafe)] + function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin); + + // -------- State Snapshots -------- + + /// Snapshot the current state of the evm. + /// Returns the ID of the snapshot that was created. + /// To revert a snapshot use `revertTo`. + #[cheatcode(group = Evm, safety = Unsafe)] + function snapshot() external returns (uint256 snapshotId); + + /// Revert the state of the EVM to a previous snapshot + /// Takes the snapshot ID to revert to. + /// This deletes the snapshot and all snapshots taken after the given snapshot ID. + #[cheatcode(group = Evm, safety = Unsafe)] + function revertTo(uint256 snapshotId) external returns (bool success); + + // -------- Forking -------- + // --- Creation and Selection --- + + /// Returns the identifier of the currently active fork. Reverts if no fork is currently active. + #[cheatcode(group = Evm, safety = Unsafe)] + function activeFork() external view returns (uint256 forkId); + + /// Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork. + #[cheatcode(group = Evm, safety = Unsafe)] + function createFork(string calldata urlOrAlias) external returns (uint256 forkId); + /// Creates a new fork with the given endpoint and block and returns the identifier of the fork. + #[cheatcode(group = Evm, safety = Unsafe)] + function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId); + /// Creates a new fork with the given endpoint and at the block the given transaction was mined in, + /// replays all transaction mined in the block before the transaction, and returns the identifier of the fork. + #[cheatcode(group = Evm, safety = Unsafe)] + function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId); + + /// Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork. + #[cheatcode(group = Evm, safety = Unsafe)] + function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId); + /// Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork. + #[cheatcode(group = Evm, safety = Unsafe)] + function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId); + /// Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in, + /// replays all transaction mined in the block before the transaction, returns the identifier of the fork. + #[cheatcode(group = Evm, safety = Unsafe)] + function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId); + + /// Updates the currently active fork to given block number + /// This is similar to `roll` but for the currently active fork. + #[cheatcode(group = Evm, safety = Unsafe)] + function rollFork(uint256 blockNumber) external; + /// Updates the currently active fork to given transaction. This will `rollFork` with the number + /// of the block the transaction was mined in and replays all transaction mined before it in the block. + #[cheatcode(group = Evm, safety = Unsafe)] + function rollFork(bytes32 txHash) external; + /// Updates the given fork to given block number. + #[cheatcode(group = Evm, safety = Unsafe)] + function rollFork(uint256 forkId, uint256 blockNumber) external; + /// Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block. + #[cheatcode(group = Evm, safety = Unsafe)] + function rollFork(uint256 forkId, bytes32 txHash) external; + + /// Takes a fork identifier created by `createFork` and sets the corresponding forked state as active. + #[cheatcode(group = Evm, safety = Unsafe)] + function selectFork(uint256 forkId) external; + + /// Fetches the given transaction from the active fork and executes it on the current state. + #[cheatcode(group = Evm, safety = Unsafe)] + function transact(bytes32 txHash) external; + /// Fetches the given transaction from the given fork and executes it on the current state. + #[cheatcode(group = Evm, safety = Unsafe)] + function transact(uint256 forkId, bytes32 txHash) external; + + // --- Behavior --- + + /// In forking mode, explicitly grant the given address cheatcode access. + #[cheatcode(group = Evm, safety = Unsafe)] + function allowCheatcodes(address account) external; + + /// Marks that the account(s) should use persistent storage across fork swaps in a multifork setup + /// Meaning, changes made to the state of this account will be kept when switching forks. + #[cheatcode(group = Evm, safety = Unsafe)] + function makePersistent(address account) external; + /// See `makePersistent(address)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function makePersistent(address account0, address account1) external; + /// See `makePersistent(address)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function makePersistent(address account0, address account1, address account2) external; + /// See `makePersistent(address)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function makePersistent(address[] calldata accounts) external; + + /// Revokes persistent status from the address, previously added via `makePersistent`. + #[cheatcode(group = Evm, safety = Unsafe)] + function revokePersistent(address account) external; + /// See `revokePersistent(address)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function revokePersistent(address[] calldata accounts) external; + + /// Returns true if the account is marked as persistent. + #[cheatcode(group = Evm, safety = Unsafe)] + function isPersistent(address account) external view returns (bool persistent); + + // -------- Record Logs -------- + + /// Record all the transaction logs. + #[cheatcode(group = Evm, safety = Safe)] + function recordLogs() external; + + /// Gets all the recorded logs. + #[cheatcode(group = Evm, safety = Safe)] + function getRecordedLogs() external returns (Log[] memory logs); + + // -------- Gas Metering -------- + // It's recommend to use the `noGasMetering` modifier included with forge-std, instead of + // using these functions directly. + + /// Pauses gas metering (i.e. gas usage is not counted). Noop if already paused. + #[cheatcode(group = Evm, safety = Safe)] + function pauseGasMetering() external; + + /// Resumes gas metering (i.e. gas usage is counted again). Noop if already on. + #[cheatcode(group = Evm, safety = Safe)] + function resumeGasMetering() external; + + // ======== Test Assertions and Utilities ======== + + /// If the condition is false, discard this run's fuzz inputs and generate new ones. + #[cheatcode(group = Testing, safety = Safe)] + function assume(bool condition) external pure; + + /// Writes a breakpoint to jump to in the debugger. + #[cheatcode(group = Testing, safety = Safe)] + function breakpoint(string calldata char) external; + + /// Writes a conditional breakpoint to jump to in the debugger. + #[cheatcode(group = Testing, safety = Safe)] + function breakpoint(string calldata char, bool value) external; + + /// Returns the RPC url for the given alias. + #[cheatcode(group = Testing, safety = Safe)] + function rpcUrl(string calldata rpcAlias) external view returns (string memory json); + + /// Returns all rpc urls and their aliases `[alias, url][]`. + #[cheatcode(group = Testing, safety = Safe)] + function rpcUrls() external view returns (string[2][] memory urls); + + /// Returns all rpc urls and their aliases as structs. + #[cheatcode(group = Testing, safety = Safe)] + function rpcUrlStructs() external view returns (Rpc[] memory urls); + + /// Suspends execution of the main thread for `duration` milliseconds. + #[cheatcode(group = Testing, safety = Safe)] + function sleep(uint256 duration) external; + + /// Expects a call to an address with the specified calldata. + /// Calldata can either be a strict or a partial match. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCall(address callee, bytes calldata data) external; + + /// Expects given number of calls to an address with the specified calldata. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCall(address callee, bytes calldata data, uint64 count) external; + + /// Expects a call to an address with the specified `msg.value` and calldata. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCall(address callee, uint256 msgValue, bytes calldata data) external; + + /// Expects given number of calls to an address with the specified `msg.value` and calldata. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external; + + /// Expect a call to an address with the specified `msg.value`, gas, and calldata. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external; + + /// Expects given number of calls to an address with the specified `msg.value`, gas, and calldata. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external; + + /// Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external; + + /// Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count) + external; + + /// Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). + /// Call this function, then emit an event, then call a function. Internally after the call, we check if + /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans). + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; + + /// Same as the previous method, but also checks supplied address against emitting contract. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) + external; + + /// Prepare an expected log with all topic and data checks enabled. + /// Call this function, then emit an event, then call a function. Internally after the call, we check if + /// logs were emitted in the expected order with the expected topics and data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit() external; + + /// Same as the previous method, but also checks supplied address against emitting contract. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit(address emitter) external; + + /// Expects an error on next call with any revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert() external; + + /// Expects an error on next call that starts with the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes4 revertData) external; + + /// Expects an error on next call that exactly matches the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes calldata revertData) external; + + /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other + /// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectSafeMemory(uint64 min, uint64 max) external; + + /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. + /// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges + /// to the set. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectSafeMemoryCall(uint64 min, uint64 max) external; + + /// Marks a test as skipped. Must be called at the top of the test. + #[cheatcode(group = Testing, safety = Unsafe)] + function skip(bool skipTest) external; + + // ======== OS and Filesystem ======== + + // -------- Metadata -------- + + /// Returns true if the given path points to an existing entity, else returns false. + #[cheatcode(group = Filesystem)] + function exists(string calldata path) external returns (bool result); + + /// Given a path, query the file system to get information about a file, directory, etc. + #[cheatcode(group = Filesystem)] + function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); + + /// Returns true if the path exists on disk and is pointing at a directory, else returns false. + #[cheatcode(group = Filesystem)] + function isDir(string calldata path) external returns (bool result); + + /// Returns true if the path exists on disk and is pointing at a regular file, else returns false. + #[cheatcode(group = Filesystem)] + function isFile(string calldata path) external returns (bool result); + + /// Get the path of the current project root. + #[cheatcode(group = Filesystem)] + function projectRoot() external view returns (string memory path); + + /// Returns the time since unix epoch in milliseconds. + #[cheatcode(group = Filesystem)] + function unixTime() external returns (uint256 milliseconds); + + // -------- Reading and writing -------- + + /// Closes file for reading, resetting the offset and allowing to read it from beginning with readLine. + /// `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function closeFile(string calldata path) external; + + /// Copies the contents of one file to another. This function will **overwrite** the contents of `to`. + /// On success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`. + /// Both `from` and `to` are relative to the project root. + #[cheatcode(group = Filesystem)] + function copyFile(string calldata from, string calldata to) external returns (uint64 copied); + + /// Creates a new, empty directory at the provided path. + /// This cheatcode will revert in the following situations, but is not limited to just these cases: + /// - User lacks permissions to modify `path`. + /// - A parent of the given path doesn't exist and `recursive` is false. + /// - `path` already exists and `recursive` is false. + /// `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function createDir(string calldata path, bool recursive) external; + + /// Reads the directory at the given path recursively, up to `maxDepth`. + /// `maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned. + /// Follows symbolic links if `followLinks` is true. + #[cheatcode(group = Filesystem)] + function readDir(string calldata path) external view returns (DirEntry[] memory entries); + /// See `readDir(string)`. + #[cheatcode(group = Filesystem)] + function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries); + /// See `readDir(string)`. + #[cheatcode(group = Filesystem)] + function readDir(string calldata path, uint64 maxDepth, bool followLinks) + external + view + returns (DirEntry[] memory entries); + + /// Reads the entire content of file to string. `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function readFile(string calldata path) external view returns (string memory data); + + /// Reads the entire content of file as binary. `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function readFileBinary(string calldata path) external view returns (bytes memory data); + + /// Reads next line of file to string. + #[cheatcode(group = Filesystem)] + function readLine(string calldata path) external view returns (string memory line); + + /// Reads a symbolic link, returning the path that the link points to. + /// This cheatcode will revert in the following situations, but is not limited to just these cases: + /// - `path` is not a symbolic link. + /// - `path` does not exist. + #[cheatcode(group = Filesystem)] + function readLink(string calldata linkPath) external view returns (string memory targetPath); + + /// Removes a directory at the provided path. + /// This cheatcode will revert in the following situations, but is not limited to just these cases: + /// - `path` doesn't exist. + /// - `path` isn't a directory. + /// - User lacks permissions to modify `path`. + /// - The directory is not empty and `recursive` is false. + /// `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function removeDir(string calldata path, bool recursive) external; + + /// Removes a file from the filesystem. + /// This cheatcode will revert in the following situations, but is not limited to just these cases: + /// - `path` points to a directory. + /// - The file doesn't exist. + /// - The user lacks permissions to remove the file. + /// `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function removeFile(string calldata path) external; + + /// Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does. + /// `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function writeFile(string calldata path, string calldata data) external; + + /// Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does. + /// `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function writeFileBinary(string calldata path, bytes calldata data) external; + + /// Writes line to file, creating a file if it does not exist. + /// `path` is relative to the project root. + #[cheatcode(group = Filesystem)] + function writeLine(string calldata path, string calldata data) external; + + /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file. + #[cheatcode(group = Filesystem)] + function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); + + /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file. + #[cheatcode(group = Filesystem)] + function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); + + // -------- Foreign Function Interface -------- + + /// Performs a foreign function call via the terminal. + #[cheatcode(group = Filesystem)] + function ffi(string[] calldata commandInput) external returns (bytes memory result); + + /// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr. + #[cheatcode(group = Filesystem)] + function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result); + + // ======== Environment Variables ======== + + /// Sets environment variables. + #[cheatcode(group = Environment)] + function setEnv(string calldata name, string calldata value) external; + + /// Gets the environment variable `name` and parses it as `bool`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envBool(string calldata name) external view returns (bool value); + /// Gets the environment variable `name` and parses it as `uint256`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envUint(string calldata name) external view returns (uint256 value); + /// Gets the environment variable `name` and parses it as `int256`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envInt(string calldata name) external view returns (int256 value); + /// Gets the environment variable `name` and parses it as `address`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envAddress(string calldata name) external view returns (address value); + /// Gets the environment variable `name` and parses it as `bytes32`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envBytes32(string calldata name) external view returns (bytes32 value); + /// Gets the environment variable `name` and parses it as `string`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envString(string calldata name) external view returns (string memory value); + /// Gets the environment variable `name` and parses it as `bytes`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envBytes(string calldata name) external view returns (bytes memory value); + + /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value); + /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value); + /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value); + /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value); + /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value); + /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envString(string calldata name, string calldata delim) external view returns (string[] memory value); + /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`. + /// Reverts if the variable was not found or could not be parsed. + #[cheatcode(group = Environment)] + function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value); + + /// Gets the environment variable `name` and parses it as `bool`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, bool defaultValue) external returns (bool value); + /// Gets the environment variable `name` and parses it as `uint256`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value); + /// Gets the environment variable `name` and parses it as `int256`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, int256 defaultValue) external returns (int256 value); + /// Gets the environment variable `name` and parses it as `address`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, address defaultValue) external returns (address value); + /// Gets the environment variable `name` and parses it as `bytes32`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value); + /// Gets the environment variable `name` and parses it as `string`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata defaultValue) external returns (string memory value); + /// Gets the environment variable `name` and parses it as `bytes`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value); + + /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) + external + returns (bool[] memory value); + /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) + external + returns (uint256[] memory value); + /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) + external + returns (int256[] memory value); + /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) + external + returns (address[] memory value); + /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) + external + returns (bytes32[] memory value); + /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) + external + returns (string[] memory value); + /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`. + /// Reverts if the variable could not be parsed. + /// Returns `defaultValue` if the variable was not found. + #[cheatcode(group = Environment)] + function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) + external + returns (bytes[] memory value); + + // ======== Scripts ======== + + // -------- Broadcasting Transactions -------- + + /// Using the address that calls the test contract, has the next call (at this call depth only) + /// create a transaction that can later be signed and sent onchain. + #[cheatcode(group = Scripting)] + function broadcast() external; + + /// Has the next call (at this call depth only) create a transaction with the address provided + /// as the sender that can later be signed and sent onchain. + #[cheatcode(group = Scripting)] + function broadcast(address signer) external; + + /// Has the next call (at this call depth only) create a transaction with the private key + /// provided as the sender that can later be signed and sent onchain. + #[cheatcode(group = Scripting)] + function broadcast(uint256 privateKey) external; + + /// Using the address that calls the test contract, has all subsequent calls + /// (at this call depth only) create transactions that can later be signed and sent onchain. + #[cheatcode(group = Scripting)] + function startBroadcast() external; + + /// Has all subsequent calls (at this call depth only) create transactions with the address + /// provided that can later be signed and sent onchain. + #[cheatcode(group = Scripting)] + function startBroadcast(address signer) external; + + /// Has all subsequent calls (at this call depth only) create transactions with the private key + /// provided that can later be signed and sent onchain. + #[cheatcode(group = Scripting)] + function startBroadcast(uint256 privateKey) external; + + /// Stops collecting onchain transactions. + #[cheatcode(group = Scripting)] + function stopBroadcast() external; + + // ======== Utilities ======== + + // -------- Strings -------- + + /// Converts the given value to a `string`. + #[cheatcode(group = String)] + function toString(address value) external pure returns (string memory stringifiedValue); + /// Converts the given value to a `string`. + #[cheatcode(group = String)] + function toString(bytes calldata value) external pure returns (string memory stringifiedValue); + /// Converts the given value to a `string`. + #[cheatcode(group = String)] + function toString(bytes32 value) external pure returns (string memory stringifiedValue); + /// Converts the given value to a `string`. + #[cheatcode(group = String)] + function toString(bool value) external pure returns (string memory stringifiedValue); + /// Converts the given value to a `string`. + #[cheatcode(group = String)] + function toString(uint256 value) external pure returns (string memory stringifiedValue); + /// Converts the given value to a `string`. + #[cheatcode(group = String)] + function toString(int256 value) external pure returns (string memory stringifiedValue); + + /// Parses the given `string` into `bytes`. + #[cheatcode(group = String)] + function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue); + /// Parses the given `string` into an `address`. + #[cheatcode(group = String)] + function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue); + /// Parses the given `string` into a `uint256`. + #[cheatcode(group = String)] + function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue); + /// Parses the given `string` into a `int256`. + #[cheatcode(group = String)] + function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue); + /// Parses the given `string` into a `bytes32`. + #[cheatcode(group = String)] + function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue); + /// Parses the given `string` into a `bool`. + #[cheatcode(group = String)] + function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); + + // ======== JSON Parsing and Manipulation ======== + + // -------- Reading -------- + + // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-json to understand the + // limitations and caveats of the JSON parsing cheats. + + /// Checks if `key` exists in a JSON object. + #[cheatcode(group = Json)] + function keyExists(string calldata json, string calldata key) external view returns (bool); + + /// ABI-encodes a JSON object. + #[cheatcode(group = Json)] + function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData); + /// ABI-encodes a JSON object at `key`. + #[cheatcode(group = Json)] + function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData); + + // The following parseJson cheatcodes will do type coercion, for the type that they indicate. + // For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12.' + // and hex numbers '0xEF.'. + // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not + // a JSON object. + + /// Parses a string of JSON data at `key` and coerces it to `uint256`. + #[cheatcode(group = Json)] + function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256); + /// Parses a string of JSON data at `key` and coerces it to `uint256[]`. + #[cheatcode(group = Json)] + function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory); + /// Parses a string of JSON data at `key` and coerces it to `int256`. + #[cheatcode(group = Json)] + function parseJsonInt(string calldata json, string calldata key) external pure returns (int256); + /// Parses a string of JSON data at `key` and coerces it to `int256[]`. + #[cheatcode(group = Json)] + function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory); + /// Parses a string of JSON data at `key` and coerces it to `bool`. + #[cheatcode(group = Json)] + function parseJsonBool(string calldata json, string calldata key) external pure returns (bool); + /// Parses a string of JSON data at `key` and coerces it to `bool[]`. + #[cheatcode(group = Json)] + function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory); + /// Parses a string of JSON data at `key` and coerces it to `address`. + #[cheatcode(group = Json)] + function parseJsonAddress(string calldata json, string calldata key) external pure returns (address); + /// Parses a string of JSON data at `key` and coerces it to `address[]`. + #[cheatcode(group = Json)] + function parseJsonAddressArray(string calldata json, string calldata key) + external + pure + returns (address[] memory); + /// Parses a string of JSON data at `key` and coerces it to `string`. + #[cheatcode(group = Json)] + function parseJsonString(string calldata json, string calldata key) external pure returns (string memory); + /// Parses a string of JSON data at `key` and coerces it to `string[]`. + #[cheatcode(group = Json)] + function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory); + /// Parses a string of JSON data at `key` and coerces it to `bytes`. + #[cheatcode(group = Json)] + function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory); + /// Parses a string of JSON data at `key` and coerces it to `bytes[]`. + #[cheatcode(group = Json)] + function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory); + /// Parses a string of JSON data at `key` and coerces it to `bytes32`. + #[cheatcode(group = Json)] + function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32); + /// Parses a string of JSON data at `key` and coerces it to `bytes32[]`. + #[cheatcode(group = Json)] + function parseJsonBytes32Array(string calldata json, string calldata key) + external + pure + returns (bytes32[] memory); + + /// Returns an array of all the keys in a JSON object. + #[cheatcode(group = Json)] + function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys); + + // -------- Writing -------- + + // NOTE: Please read https://book.getfoundry.sh/cheatcodes/serialize-json to understand how + // to use the serialization cheats. + + /// Serializes a key and value to a JSON object stored in-memory that can be later written to a file. + /// Returns the stringified version of the specific JSON file up to that moment. + #[cheatcode(group = Json)] + function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json); + + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeBool(string calldata objectKey, string calldata valueKey, bool value) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeAddress(string calldata objectKey, string calldata valueKey, address value) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeString(string calldata objectKey, string calldata valueKey, string calldata value) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value) + external + returns (string memory json); + + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) + external + returns (string memory json); + + // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-json to understand how + // to use the JSON writing cheats. + + /// Write a serialized JSON object to a file. If the file exists, it will be overwritten. + #[cheatcode(group = Json)] + function writeJson(string calldata json, string calldata path) external; + + /// Write a serialized JSON object to an **existing** JSON file, replacing a value with key = + /// This is useful to replace a specific value of a JSON file, without having to parse the entire thing. + #[cheatcode(group = Json)] + function writeJson(string calldata json, string calldata path, string calldata valueKey) external; + + // -------- Key Management -------- + + /// Derives a private key from the name, labels the account with that name, and returns the wallet. + #[cheatcode(group = Utilities)] + function createWallet(string calldata walletLabel) external returns (Wallet memory wallet); + + /// Generates a wallet from the private key and returns the wallet. + #[cheatcode(group = Utilities)] + function createWallet(uint256 privateKey) external returns (Wallet memory wallet); + + /// Generates a wallet from the private key, labels the account with that name, and returns the wallet. + #[cheatcode(group = Utilities)] + function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet); + + /// Get a `Wallet`'s nonce. + #[cheatcode(group = Utilities)] + function getNonce(Wallet calldata wallet) external returns (uint64 nonce); + + /// Signs data with a `Wallet`. + #[cheatcode(group = Utilities)] + function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); + + /// Derive a private key from a provided mnenomic string (or mnenomic file path) + /// at the derivation path `m/44'/60'/0'/0/{index}`. + #[cheatcode(group = Utilities)] + function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey); + /// Derive a private key from a provided mnenomic string (or mnenomic file path) + /// at `{derivationPath}{index}`. + #[cheatcode(group = Utilities)] + function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) + external + pure + returns (uint256 privateKey); + /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language + /// at the derivation path `m/44'/60'/0'/0/{index}`. + #[cheatcode(group = Utilities)] + function deriveKey(string calldata mnemonic, uint32 index, string calldata language) + external + pure + returns (uint256 privateKey); + /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language + /// at `{derivationPath}{index}`. + #[cheatcode(group = Utilities)] + function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) + external + pure + returns (uint256 privateKey); + + /// Adds a private key to the local forge wallet and returns the address. + #[cheatcode(group = Utilities)] + function rememberKey(uint256 privateKey) external returns (address keyAddr); + + // -------- Uncategorized Utilities -------- + + /// Labels an address in call traces. + #[cheatcode(group = Utilities)] + function label(address account, string calldata newLabel) external; + + /// Gets the label for the specified address. + #[cheatcode(group = Utilities)] + function getLabel(address account) external returns (string memory currentLabel); +} +} diff --git a/crates/cheatcodes/src/impls/config.rs b/crates/cheatcodes/src/impls/config.rs new file mode 100644 index 0000000000000..9e7a1a2d9a6de --- /dev/null +++ b/crates/cheatcodes/src/impls/config.rs @@ -0,0 +1,232 @@ +use super::Result; +use crate::Vm::Rpc; +use ethers::solc::{utils::canonicalize, ProjectPathsConfig}; +use foundry_common::fs::normalize_path; +use foundry_config::{ + cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, + ResolvedRpcEndpoints, +}; +use std::path::{Path, PathBuf}; + +// TODO +#[derive(Clone, Debug, Default)] +pub struct EvmOpts { + pub ffi: bool, + pub fork_block_number: Option, +} + +impl EvmOpts { + pub fn get_compute_units_per_second(&self) -> u64 { + unimplemented!() + } + + pub async fn fork_evm_env( + &self, + _x: &str, + ) -> Result< + (revm::primitives::Env, ethers::types::Block), + core::convert::Infallible, + > { + unimplemented!() + } +} + +/// Additional, configurable context the `Cheatcodes` inspector has access to +/// +/// This is essentially a subset of various `Config` settings `Cheatcodes` needs to know. +#[derive(Clone, Debug)] +pub struct CheatsConfig { + /// Whether the FFI cheatcode is enabled. + pub ffi: bool, + /// RPC storage caching settings determines what chains and endpoints to cache + pub rpc_storage_caching: StorageCachingConfig, + /// All known endpoints and their aliases + pub rpc_endpoints: ResolvedRpcEndpoints, + /// Project's paths as configured + pub paths: ProjectPathsConfig, + /// Filesystem permissions for cheatcodes like `writeFile`, `readFile` + pub fs_permissions: FsPermissions, + /// Project root + pub root: PathBuf, + /// Paths (directories) where file reading/writing is allowed + pub allowed_paths: Vec, + /// How the evm was configured by the user + pub evm_opts: EvmOpts, +} + +impl CheatsConfig { + /// Extracts the necessary settings from the Config + pub fn new(config: &Config, evm_opts: EvmOpts) -> Self { + let mut allowed_paths = vec![config.__root.0.clone()]; + allowed_paths.extend(config.libs.clone()); + allowed_paths.extend(config.allow_paths.clone()); + + let rpc_endpoints = config.rpc_endpoints.clone().resolved(); + trace!(?rpc_endpoints, "using resolved rpc endpoints"); + + Self { + ffi: evm_opts.ffi, + rpc_storage_caching: config.rpc_storage_caching.clone(), + rpc_endpoints, + paths: config.project_paths(), + fs_permissions: config.fs_permissions.clone().joined(&config.__root), + root: config.__root.0.clone(), + allowed_paths, + evm_opts, + } + } + + /// Attempts to canonicalize (see [std::fs::canonicalize]) the path. + /// + /// Canonicalization fails for non-existing paths, in which case we just normalize the path. + pub fn normalized_path(&self, path: impl AsRef) -> PathBuf { + let path = self.root.join(path); + canonicalize(&path).unwrap_or_else(|_| normalize_path(&path)) + } + + /// Returns true if the given path is allowed, if any path `allowed_paths` is an ancestor of the + /// path + /// + /// We only allow paths that are inside allowed paths. To prevent path traversal + /// ("../../etc/passwd") we canonicalize/normalize the path first. We always join with the + /// configured root directory. + pub fn is_path_allowed(&self, path: impl AsRef, kind: FsAccessKind) -> bool { + self.is_normalized_path_allowed(&self.normalized_path(path), kind) + } + + fn is_normalized_path_allowed(&self, path: &Path, kind: FsAccessKind) -> bool { + self.fs_permissions.is_path_allowed(path, kind) + } + + /// Returns an error if no access is granted to access `path`, See also [Self::is_path_allowed] + /// + /// Returns the normalized version of `path`, see [`CheatsConfig::normalized_path`] + pub fn ensure_path_allowed( + &self, + path: impl AsRef, + kind: FsAccessKind, + ) -> Result { + let path = path.as_ref(); + let normalized = self.normalized_path(path); + ensure!( + self.is_normalized_path_allowed(&normalized, kind), + "the path {} is not allowed to be accessed for {kind} operations", + normalized.strip_prefix(&self.root).unwrap_or(path).display() + ); + Ok(normalized) + } + + /// Returns true if the given `path` is the project's foundry.toml file + /// + /// Note: this should be called with normalized path + pub fn is_foundry_toml(&self, path: impl AsRef) -> bool { + // path methods that do not access the filesystem are such as [`Path::starts_with`], are + // case-sensitive no matter the platform or filesystem. to make this case-sensitive + // we convert the underlying `OssStr` to lowercase checking that `path` and + // `foundry.toml` are the same file by comparing the FD, because it may not exist + let foundry_toml = self.root.join(Config::FILE_NAME); + Path::new(&foundry_toml.to_string_lossy().to_lowercase()) + .starts_with(Path::new(&path.as_ref().to_string_lossy().to_lowercase())) + } + + /// Same as [`Self::is_foundry_toml`] but returns an `Err` if [`Self::is_foundry_toml`] returns + /// true + pub fn ensure_not_foundry_toml(&self, path: impl AsRef) -> Result<()> { + ensure!(!self.is_foundry_toml(path), "access to `foundry.toml` is not allowed"); + Ok(()) + } + + /// Returns the RPC to use + /// + /// If `url_or_alias` is a known alias in the `ResolvedRpcEndpoints` then it returns the + /// corresponding URL of that alias. otherwise this assumes `url_or_alias` is itself a URL + /// if it starts with a `http` or `ws` scheme + /// + /// # Errors + /// + /// - Returns an error if `url_or_alias` is a known alias but references an unresolved env var. + /// - Returns an error if `url_or_alias` is not an alias but does not start with a `http` or + /// `scheme` + pub fn rpc_url(&self, url_or_alias: &str) -> Result { + match self.rpc_endpoints.get(url_or_alias) { + Some(Ok(url)) => Ok(url.clone()), + Some(Err(err)) => { + // try resolve again, by checking if env vars are now set + err.try_resolve().map_err(Into::into) + } + None => { + if url_or_alias.starts_with("http") || url_or_alias.starts_with("ws") { + Ok(url_or_alias.into()) + } else { + Err(fmt_err!("invalid rpc url: {url_or_alias}")) + } + } + } + } + + /// Returns all the RPC urls and their alias. + pub fn rpc_urls(&self) -> Result> { + let mut urls = Vec::with_capacity(self.rpc_endpoints.len()); + for alias in self.rpc_endpoints.keys() { + let url = self.rpc_url(alias)?; + urls.push(Rpc { key: alias.clone(), url }); + } + Ok(urls) + } +} + +impl Default for CheatsConfig { + fn default() -> Self { + Self { + ffi: false, + rpc_storage_caching: Default::default(), + rpc_endpoints: Default::default(), + paths: ProjectPathsConfig::builder().build_with_root("./"), + fs_permissions: Default::default(), + root: Default::default(), + allowed_paths: vec![], + evm_opts: Default::default(), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use foundry_config::fs_permissions::PathPermission; + + fn config(root: &str, fs_permissions: FsPermissions) -> CheatsConfig { + CheatsConfig::new( + &Config { __root: PathBuf::from(root).into(), fs_permissions, ..Default::default() }, + Default::default(), + ) + } + + #[test] + fn test_allowed_paths() { + let root = "/my/project/root/"; + let config = config(root, FsPermissions::new(vec![PathPermission::read_write("./")])); + + assert!(config.ensure_path_allowed("./t.txt", FsAccessKind::Read).is_ok()); + assert!(config.ensure_path_allowed("./t.txt", FsAccessKind::Write).is_ok()); + assert!(config.ensure_path_allowed("../root/t.txt", FsAccessKind::Read).is_ok()); + assert!(config.ensure_path_allowed("../root/t.txt", FsAccessKind::Write).is_ok()); + assert!(config.ensure_path_allowed("../../root/t.txt", FsAccessKind::Read).is_err()); + assert!(config.ensure_path_allowed("../../root/t.txt", FsAccessKind::Write).is_err()); + } + + #[test] + fn test_is_foundry_toml() { + let root = "/my/project/root/"; + let config = config(root, FsPermissions::new(vec![PathPermission::read_write("./")])); + + let f = format!("{root}foundry.toml"); + assert!(config.is_foundry_toml(f)); + + let f = format!("{root}Foundry.toml"); + assert!(config.is_foundry_toml(f)); + + let f = format!("{root}lib/other/foundry.toml"); + assert!(!config.is_foundry_toml(f)); + } +} diff --git a/crates/cheatcodes/src/impls/db.rs b/crates/cheatcodes/src/impls/db.rs new file mode 100644 index 0000000000000..869a4952ac85e --- /dev/null +++ b/crates/cheatcodes/src/impls/db.rs @@ -0,0 +1,307 @@ +use super::config::EvmOpts; +use crate::Cheatcodes; +use alloy_primitives::{Address, B256, U256}; +use itertools::Itertools; +use revm::{primitives::Env, Database, JournaledState}; + +mod error; +pub use error::{DatabaseError, DatabaseResult}; + +/// Represents a numeric `ForkId` valid only for the existence of the `Backend`. +/// The difference between `ForkId` and `LocalForkId` is that `ForkId` tracks pairs of `endpoint + +/// block` which can be reused by multiple tests, whereas the `LocalForkId` is unique within a test +pub type LocalForkId = U256; + +/// Represents possible diagnostic cases on revert +#[derive(Debug, Clone)] +#[allow(missing_docs)] +pub enum RevertDiagnostic { + /// The `contract` does not exist on the `active` fork but exist on other fork(s) + ContractExistsOnOtherForks { + contract: Address, + active: LocalForkId, + available_on: Vec, + }, + ContractDoesNotExist { + contract: Address, + active: LocalForkId, + persistent: bool, + }, +} + +impl RevertDiagnostic { + /// Converts the diagnostic to a readable error message + pub fn to_error_msg(&self, cheats: &Cheatcodes) -> String { + let get_label = + |addr: &Address| cheats.labels.get(addr).cloned().unwrap_or_else(|| addr.to_string()); + + match self { + RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => { + let contract_label = get_label(contract); + + format!( + "Contract {contract_label} does not exist on active fork with id `{active}` + but exists on non active forks: `[{}]`", + available_on.iter().format(", ") + ) + } + RevertDiagnostic::ContractDoesNotExist { contract, persistent, .. } => { + let contract_label = get_label(contract); + if *persistent { + format!("Contract {contract_label} does not exist") + } else { + format!( + "Contract {contract_label} does not exist and is not marked \ + as persistent, see `makePersistent`" + ) + } + } + } + } +} + +/// Represents a _fork_ of a remote chain whose data is available only via the `url` endpoint. +#[derive(Debug, Clone)] +pub struct CreateFork { + /// Whether to enable rpc storage caching for this fork. + pub enable_caching: bool, + /// The URL to a node for fetching remote state. + pub url: String, + /// The env to create this fork, main purpose is to provide some metadata for the fork. + pub env: Env, + /// All env settings as configured by the user + pub evm_opts: EvmOpts, +} + +/// Extend the [`revm::Database`] with cheatcodes specific functionality. +pub trait DatabaseExt: Database { + /// Creates a new snapshot at the current point of execution. + /// + /// A snapshot is associated with a new unique id that's created for the snapshot. + /// Snapshots can be reverted: [DatabaseExt::revert], however a snapshot can only be reverted + /// once. After a successful revert, the same snapshot id cannot be used again. + fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256; + + /// Reverts the snapshot if it exists + /// + /// Returns `true` if the snapshot was successfully reverted, `false` if no snapshot for that id + /// exists. + /// + /// **N.B.** While this reverts the state of the evm to the snapshot, it keeps new logs made + /// since the snapshots was created. This way we can show logs that were emitted between + /// snapshot and its revert. + /// This will also revert any changes in the `Env` and replace it with the captured `Env` of + /// `Self::snapshot` + fn revert( + &mut self, + id: U256, + journaled_state: &JournaledState, + env: &mut Env, + ) -> Option; + + /// Creates and also selects a new fork + /// + /// This is basically `create_fork` + `select_fork` + fn create_select_fork( + &mut self, + fork: CreateFork, + env: &mut Env, + journaled_state: &mut JournaledState, + ) -> eyre::Result { + let id = self.create_fork(fork)?; + self.select_fork(id, env, journaled_state)?; + Ok(id) + } + + /// Creates and also selects a new fork + /// + /// This is basically `create_fork` + `select_fork` + fn create_select_fork_at_transaction( + &mut self, + fork: CreateFork, + env: &mut Env, + journaled_state: &mut JournaledState, + transaction: B256, + ) -> eyre::Result { + let id = self.create_fork_at_transaction(fork, transaction)?; + self.select_fork(id, env, journaled_state)?; + Ok(id) + } + + /// Creates a new fork but does _not_ select it + fn create_fork(&mut self, fork: CreateFork) -> eyre::Result; + + /// Creates a new fork but does _not_ select it + fn create_fork_at_transaction( + &mut self, + fork: CreateFork, + transaction: B256, + ) -> eyre::Result; + + /// Selects the fork's state + /// + /// This will also modify the current `Env`. + /// + /// **Note**: this does not change the local state, but swaps the remote state + /// + /// # Errors + /// + /// Returns an error if no fork with the given `id` exists + fn select_fork( + &mut self, + id: LocalForkId, + env: &mut Env, + journaled_state: &mut JournaledState, + ) -> eyre::Result<()>; + + /// Updates the fork to given block number. + /// + /// This will essentially create a new fork at the given block height. + /// + /// # Errors + /// + /// Returns an error if not matching fork was found. + fn roll_fork( + &mut self, + id: Option, + block_number: U256, + env: &mut Env, + journaled_state: &mut JournaledState, + ) -> eyre::Result<()>; + + /// Updates the fork to given transaction hash + /// + /// This will essentially create a new fork at the block this transaction was mined and replays + /// all transactions up until the given transaction. + /// + /// # Errors + /// + /// Returns an error if not matching fork was found. + fn roll_fork_to_transaction( + &mut self, + id: Option, + transaction: B256, + env: &mut Env, + journaled_state: &mut JournaledState, + ) -> eyre::Result<()>; + + /// Fetches the given transaction for the fork and executes it, committing the state in the DB + fn transact( + &mut self, + id: Option, + transaction: B256, + env: &mut Env, + journaled_state: &mut JournaledState, + cheatcodes_inspector: Option<&mut Cheatcodes>, + ) -> eyre::Result<()>; + + /// Returns the `ForkId` that's currently used in the database, if fork mode is on + fn active_fork_id(&self) -> Option; + + /// Returns the Fork url that's currently used in the database, if fork mode is on + fn active_fork_url(&self) -> Option; + + /// Whether the database is currently in forked + fn is_forked_mode(&self) -> bool { + self.active_fork_id().is_some() + } + + /// Ensures that an appropriate fork exits + /// + /// If `id` contains a requested `Fork` this will ensure it exits. + /// Otherwise, this returns the currently active fork. + /// + /// # Errors + /// + /// Returns an error if the given `id` does not match any forks + /// + /// Returns an error if no fork exits + fn ensure_fork(&self, id: Option) -> eyre::Result; + + /// Handling multiple accounts/new contracts in a multifork environment can be challenging since + /// every fork has its own standalone storage section. So this can be a common error to run + /// into: + /// + /// ```solidity + /// function testCanDeploy() public { + /// vm.selectFork(mainnetFork); + /// // contract created while on `mainnetFork` + /// DummyContract dummy = new DummyContract(); + /// // this will succeed + /// dummy.hello(); + /// + /// vm.selectFork(optimismFork); + /// + /// vm.expectRevert(); + /// // this will revert since `dummy` contract only exists on `mainnetFork` + /// dummy.hello(); + /// } + /// ``` + /// + /// If this happens (`dummy.hello()`), or more general, a call on an address that's not a + /// contract, revm will revert without useful context. This call will check in this context if + /// `address(dummy)` belongs to an existing contract and if not will check all other forks if + /// the contract is deployed there. + /// + /// Returns a more useful error message if that's the case + fn diagnose_revert( + &self, + callee: Address, + journaled_state: &JournaledState, + ) -> Option; + + /// Returns true if the given account is currently marked as persistent. + fn is_persistent(&self, acc: &Address) -> bool; + + /// Revokes persistent status from the given account. + fn remove_persistent_account(&mut self, account: &Address) -> bool; + + /// Marks the given account as persistent. + fn add_persistent_account(&mut self, account: Address) -> bool; + + /// Removes persistent status from all given accounts + fn remove_persistent_accounts(&mut self, accounts: impl IntoIterator) { + for acc in accounts { + self.remove_persistent_account(&acc); + } + } + + /// Extends the persistent accounts with the accounts the iterator yields. + fn extend_persistent_accounts(&mut self, accounts: impl IntoIterator) { + for acc in accounts { + self.add_persistent_account(acc); + } + } + + /// Grants cheatcode access for the given `account` + /// + /// Returns true if the `account` already has access + fn allow_cheatcode_access(&mut self, account: Address) -> bool; + + /// Revokes cheatcode access for the given account + /// + /// Returns true if the `account` was previously allowed cheatcode access + fn revoke_cheatcode_access(&mut self, account: Address) -> bool; + + /// Returns `true` if the given account is allowed to execute cheatcodes + fn has_cheatcode_access(&self, account: Address) -> bool; + + /// Ensures that `account` is allowed to execute cheatcodes + /// + /// Returns an error if [`Self::has_cheatcode_access`] returns `false` + fn ensure_cheatcode_access(&self, account: Address) -> Result<(), DatabaseError> { + if !self.has_cheatcode_access(account) { + return Err(DatabaseError::NoCheats(account)) + } + Ok(()) + } + + /// Same as [`Self::ensure_cheatcode_access()`] but only enforces it if the backend is currently + /// in forking mode + fn ensure_cheatcode_access_forking_mode(&self, account: Address) -> Result<(), DatabaseError> { + if self.is_forked_mode() { + return self.ensure_cheatcode_access(account) + } + Ok(()) + } +} diff --git a/crates/cheatcodes/src/impls/db/error.rs b/crates/cheatcodes/src/impls/db/error.rs new file mode 100644 index 0000000000000..93eb536ee8092 --- /dev/null +++ b/crates/cheatcodes/src/impls/db/error.rs @@ -0,0 +1,103 @@ +use alloy_primitives::{Address, B256, U256}; +use ethers::types::BlockId; +use futures::channel::mpsc::{SendError, TrySendError}; +use std::{ + convert::Infallible, + sync::{mpsc::RecvError, Arc}, +}; + +/// Result alias with `DatabaseError` as error +pub type DatabaseResult = Result; + +/// Errors that can happen when working with [`revm::Database`] +#[derive(Debug, thiserror::Error)] +#[allow(missing_docs)] +pub enum DatabaseError { + #[error("{0}")] + Message(String), + #[error("no cheats available for {0}")] + NoCheats(Address), + #[error("failed to fetch AccountInfo {0}")] + MissingAccount(Address), + #[error("code should already be loaded: {0}")] + MissingCode(B256), + #[error(transparent)] + Recv(#[from] RecvError), + #[error(transparent)] + Send(#[from] SendError), + #[error("failed to get account for {0}: {1}")] + GetAccount(Address, Arc), + #[error("failed to get storage for {0} at {1}: {2}")] + GetStorage(Address, U256, Arc), + #[error("failed to get block hash for {0}: {1}")] + GetBlockHash(u64, Arc), + #[error("failed to get full block for {0:?}: {1}")] + GetFullBlock(BlockId, Arc), + #[error("block {0:?} does not exist")] + BlockNotFound(BlockId), + #[error("failed to get transaction {0}: {1}")] + GetTransaction(B256, Arc), + #[error("transaction {0} not found")] + TransactionNotFound(B256), + #[error( + "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n\ + For a production environment, you can deploy it using the pre-signed transaction from \ + https://github.com/Arachnid/deterministic-deployment-proxy.\n\ + For a test environment, you can use `etch` to place the required bytecode at that address." + )] + MissingCreate2Deployer, +} + +impl DatabaseError { + /// Create a new error with a message + pub fn msg(msg: impl Into) -> Self { + DatabaseError::Message(msg.into()) + } + + /// Create a new error with a message + pub fn display(msg: impl std::fmt::Display) -> Self { + DatabaseError::Message(msg.to_string()) + } + + fn get_rpc_error(&self) -> Option<&eyre::Error> { + match self { + Self::GetAccount(_, err) => Some(err), + Self::GetStorage(_, _, err) => Some(err), + Self::GetBlockHash(_, err) => Some(err), + Self::GetFullBlock(_, err) => Some(err), + Self::GetTransaction(_, err) => Some(err), + // Enumerate explicitly to make sure errors are updated if a new one is added. + Self::NoCheats(_) | + Self::MissingAccount(_) | + Self::MissingCode(_) | + Self::Recv(_) | + Self::Send(_) | + Self::Message(_) | + Self::BlockNotFound(_) | + Self::TransactionNotFound(_) | + Self::MissingCreate2Deployer => None, + } + } + + /// Whether the error is potentially caused by the user forking from an older block in a + /// non-archive node. + pub fn is_possibly_non_archive_node_error(&self) -> bool { + static GETH_MESSAGE: &str = "missing trie node"; + + self.get_rpc_error() + .map(|err| err.to_string().to_lowercase().contains(GETH_MESSAGE)) + .unwrap_or(false) + } +} + +impl From> for DatabaseError { + fn from(err: TrySendError) -> Self { + err.into_send_error().into() + } +} + +impl From for DatabaseError { + fn from(value: Infallible) -> Self { + match value {} + } +} diff --git a/crates/cheatcodes/src/impls/env.rs b/crates/cheatcodes/src/impls/env.rs new file mode 100644 index 0000000000000..590a04c81421a --- /dev/null +++ b/crates/cheatcodes/src/impls/env.rs @@ -0,0 +1,270 @@ +//! Implementations of [`Environment`](crate::Group::Environment) cheatcodes. + +use super::{string, Cheatcode, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_primitives::{Address, Bytes, B256, I256, U256}; +use alloy_sol_types::SolValue; +use std::env; + +impl Cheatcode for setEnvCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name: key, value } = self; + if key.is_empty() { + Err(fmt_err!("environment variable key can't be empty")) + } else if key.contains('=') { + Err(fmt_err!("environment variable key can't contain equal sign `=`")) + } else if key.contains('\0') { + Err(fmt_err!("environment variable key can't contain NUL character `\\0`")) + } else if value.contains('\0') { + Err(fmt_err!("environment variable value can't contain NUL character `\\0`")) + } else { + env::set_var(key, value); + Ok(Default::default()) + } + } +} + +impl Cheatcode for envBool_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + env::(name, None) + } +} + +impl Cheatcode for envUint_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + env::(name, None) + } +} + +impl Cheatcode for envInt_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + env::(name, None) + } +} + +impl Cheatcode for envAddress_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + env::
(name, None) + } +} + +impl Cheatcode for envBytes32_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + env::(name, None) + } +} + +impl Cheatcode for envString_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + env::(name, None) + } +} + +impl Cheatcode for envBytes_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + env::(name, None) + } +} + +impl Cheatcode for envBool_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim } = self; + env_array::(name, delim, None) + } +} + +impl Cheatcode for envUint_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim } = self; + env_array::(name, delim, None) + } +} + +impl Cheatcode for envInt_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim } = self; + env_array::(name, delim, None) + } +} + +impl Cheatcode for envAddress_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim } = self; + env_array::
(name, delim, None) + } +} + +impl Cheatcode for envBytes32_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim } = self; + env_array::(name, delim, None) + } +} + +impl Cheatcode for envString_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim } = self; + env_array::(name, delim, None) + } +} + +impl Cheatcode for envBytes_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim } = self; + env_array::(name, delim, None) + } +} + +// bool +impl Cheatcode for envOr_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, defaultValue } = self; + env::(name, Some(defaultValue)) + } +} + +// uint256 +impl Cheatcode for envOr_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, defaultValue } = self; + env::(name, Some(defaultValue)) + } +} + +// int256 +impl Cheatcode for envOr_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, defaultValue } = self; + env::(name, Some(defaultValue)) + } +} + +// address +impl Cheatcode for envOr_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, defaultValue } = self; + env::
(name, Some(defaultValue)) + } +} + +// bytes32 +impl Cheatcode for envOr_4Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, defaultValue } = self; + env::(name, Some(defaultValue)) + } +} + +// string +impl Cheatcode for envOr_5Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, defaultValue } = self; + env::(name, Some(defaultValue)) + } +} + +// bytes +impl Cheatcode for envOr_6Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, defaultValue } = self; + env::(name, Some(&defaultValue.clone().into())) + } +} + +// bool[] +impl Cheatcode for envOr_7Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim, defaultValue } = self; + env_array::(name, delim, Some(defaultValue)) + } +} + +// uint256[] +impl Cheatcode for envOr_8Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim, defaultValue } = self; + env_array::(name, delim, Some(defaultValue)) + } +} + +// int256[] +impl Cheatcode for envOr_9Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim, defaultValue } = self; + env_array::(name, delim, Some(defaultValue)) + } +} + +// address[] +impl Cheatcode for envOr_10Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim, defaultValue } = self; + env_array::
(name, delim, Some(defaultValue)) + } +} + +// bytes32[] +impl Cheatcode for envOr_11Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim, defaultValue } = self; + env_array::(name, delim, Some(defaultValue)) + } +} + +// string[] +impl Cheatcode for envOr_12Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim, defaultValue } = self; + env_array::(name, delim, Some(defaultValue)) + } +} + +// bytes[] +impl Cheatcode for envOr_13Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name, delim, defaultValue } = self; + let default = defaultValue.iter().map(|vec| vec.clone().into()).collect::>(); + env_array::(name, delim, Some(&default)) + } +} + +fn env(key: &str, default: Option<&T>) -> Result +where + T: SolValue + std::str::FromStr, + T::Err: std::fmt::Display, +{ + match (get_env(key), default) { + (Ok(val), _) => string::parse::(&val), + (Err(_), Some(default)) => Ok(default.abi_encode()), + (Err(e), None) => Err(e), + } +} + +fn env_array(key: &str, delim: &str, default: Option<&[T]>) -> Result +where + T: SolValue + std::str::FromStr, + T::Err: std::fmt::Display, +{ + match (get_env(key), default) { + (Ok(val), _) => string::parse_array::<_, _, T>(val.split(delim).map(str::trim)), + (Err(_), Some(default)) => Ok(default.abi_encode()), + (Err(e), None) => Err(e), + } +} + +fn get_env(key: &str) -> Result { + match env::var(key) { + Ok(val) => Ok(val), + Err(env::VarError::NotPresent) => Err(fmt_err!("environment variable {key:?} not found")), + Err(env::VarError::NotUnicode(s)) => { + Err(fmt_err!("environment variable {key:?} was not valid unicode: {s:?}")) + } + } +} diff --git a/crates/cheatcodes/src/impls/error.rs b/crates/cheatcodes/src/impls/error.rs new file mode 100644 index 0000000000000..f24f91784e617 --- /dev/null +++ b/crates/cheatcodes/src/impls/error.rs @@ -0,0 +1,297 @@ +use alloy_primitives::{Address, Bytes}; +use alloy_sol_types::{Revert, SolError, SolValue}; +use ethers::{core::k256::ecdsa::signature::Error as SignatureError, signers::WalletError}; +use foundry_common::errors::FsPathError; +use foundry_config::UnresolvedEnvVarError; +use std::{borrow::Cow, fmt, ptr::NonNull}; + +/// Cheatcode result type. +/// +/// Type alias with a default Ok type of [`Vec`], and default Err type of [`Error`]. +pub type Result, E = Error> = std::result::Result; + +macro_rules! fmt_err { + ($msg:literal $(,)?) => { + $crate::impls::Error::fmt(::std::format_args!($msg)) + }; + ($err:expr $(,)?) => { + <$crate::impls::Error as ::std::convert::From<_>>::from($err) + }; + ($fmt:expr, $($arg:tt)*) => { + $crate::impls::Error::fmt(::std::format_args!($fmt, $($arg)*)) + }; +} + +macro_rules! bail { + ($msg:literal $(,)?) => { + return ::std::result::Result::Err(fmt_err!($msg)) + }; + ($err:expr $(,)?) => { + return ::std::result::Result::Err(fmt_err!($err)) + }; + ($fmt:expr, $($arg:tt)*) => { + return ::std::result::Result::Err(fmt_err!($fmt, $($arg)*)) + }; +} + +macro_rules! ensure { + ($cond:expr $(,)?) => { + if !$cond { + return ::std::result::Result::Err($crate::impls::Error::custom( + ::std::concat!("Condition failed: `", ::std::stringify!($cond), "`") + )); + } + }; + ($cond:expr, $msg:literal $(,)?) => { + if !$cond { + return ::std::result::Result::Err(fmt_err!($msg)); + } + }; + ($cond:expr, $err:expr $(,)?) => { + if !$cond { + return ::std::result::Result::Err(fmt_err!($err)); + } + }; + ($cond:expr, $fmt:expr, $($arg:tt)*) => { + if !$cond { + return ::std::result::Result::Err(fmt_err!($fmt, $($arg)*)); + } + }; +} + +macro_rules! ensure_not_precompile { + ($address:expr, $ctxt:expr) => { + if $ctxt.is_precompile($address) { + return Err($crate::impls::error::precompile_error( + ::CHEATCODE.id, + $address, + )) + } + }; +} + +#[cold] +pub(crate) fn precompile_error(id: &'static str, address: &Address) -> Error { + fmt_err!("cannot call {id} on precompile {address}") +} + +/// Error thrown by cheatcodes. +// This uses a custom repr to minimize the size of the error. +// The repr is basically `enum { Cow<'static, str>, Cow<'static, [u8]> }` +pub struct Error { + /// If true, encode `data` as `Error(string)`, otherwise encode it directly as `bytes`. + is_str: bool, + /// Whether this was constructed from an owned byte vec, which means we have to drop the data + /// in `impl Drop`. + drop: bool, + /// The error data. Always a valid pointer, and never modified. + data: NonNull<[u8]>, +} + +impl std::error::Error for Error {} + +impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.kind().fmt(f) + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.kind().fmt(f) + } +} + +/// Kind of cheatcode errors. +/// +/// Constructed by [`Error::kind`]. +#[derive(Debug)] +pub enum ErrorKind<'a> { + /// A string error, encoded as `Error(string)`. + String(&'a str), + /// A bytes error, encoded directly as just `bytes`. + Bytes(&'a [u8]), +} + +impl fmt::Display for ErrorKind<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::String(ss) => f.write_str(ss), + Self::Bytes(b) => f.write_str(&hex::encode_prefixed(b)), + } + } +} + +impl Error { + /// Creates a new error and ABI encodes it. + pub fn encode(error: impl Into) -> Bytes { + error.into().abi_encode().into() + } + + /// Creates a new error with a custom message. + pub fn display(msg: impl fmt::Display) -> Self { + Self::fmt(format_args!("{msg}")) + } + + /// Creates a new error with a custom `fmt::Arguments` message. + pub fn fmt(args: fmt::Arguments<'_>) -> Self { + match args.as_str() { + Some(s) => Self::new_str(s), + None => Self::new_string(std::fmt::format(args)), + } + } + + /// ABI-encodes this error. + pub fn abi_encode(&self) -> Vec { + match self.kind() { + ErrorKind::String(string) => Revert::from(string).abi_encode(), + ErrorKind::Bytes(bytes) => bytes.abi_encode(), + } + } + + /// ABI-encodes this error as `bytes`. + pub fn abi_encode_bytes(&self) -> Vec { + self.data().abi_encode() + } + + /// Returns the kind of this error. + #[inline(always)] + pub fn kind(&self) -> ErrorKind<'_> { + let data = self.data(); + if self.is_str { + ErrorKind::String(unsafe { std::str::from_utf8_unchecked(data) }) + } else { + ErrorKind::Bytes(data) + } + } + + /// Returns the raw data of this error. + #[inline(always)] + pub fn data(&self) -> &[u8] { + unsafe { &*self.data.as_ptr() } + } + + #[inline(always)] + fn new_str(data: &'static str) -> Self { + Self::new(true, false, data.as_bytes() as *const [u8] as *mut [u8]) + } + + #[inline(always)] + fn new_string(data: String) -> Self { + Self::new(true, true, Box::into_raw(data.into_boxed_str().into_boxed_bytes())) + } + + #[inline(always)] + fn new_bytes(data: &'static [u8]) -> Self { + Self::new(false, false, data as *const [u8] as *mut [u8]) + } + + #[inline(always)] + fn new_vec(data: Vec) -> Self { + Self::new(false, true, Box::into_raw(data.into_boxed_slice())) + } + + #[inline(always)] + fn new(is_str: bool, drop: bool, data: *mut [u8]) -> Self { + Self { is_str, drop, data: unsafe { NonNull::new_unchecked(data) } } + } +} + +impl Drop for Error { + #[inline] + fn drop(&mut self) { + if self.drop { + drop(unsafe { Box::from_raw(self.data.as_ptr()) }); + } + } +} + +impl From> for Error { + fn from(value: Cow<'static, str>) -> Self { + match value { + Cow::Borrowed(str) => Self::new_str(str), + Cow::Owned(string) => Self::new_string(string), + } + } +} + +impl From for Error { + #[inline] + fn from(value: String) -> Self { + Self::new_string(value) + } +} + +impl From<&'static str> for Error { + #[inline] + fn from(value: &'static str) -> Self { + Self::new_str(value) + } +} + +impl From> for Error { + #[inline] + fn from(value: Cow<'static, [u8]>) -> Self { + match value { + Cow::Borrowed(bytes) => Self::new_bytes(bytes), + Cow::Owned(vec) => Self::new_vec(vec), + } + } +} + +impl From<&'static [u8]> for Error { + #[inline] + fn from(value: &'static [u8]) -> Self { + Self::new_bytes(value) + } +} + +impl From<&'static [u8; N]> for Error { + #[inline] + fn from(value: &'static [u8; N]) -> Self { + Self::new_bytes(value) + } +} + +impl From> for Error { + #[inline] + fn from(value: Vec) -> Self { + Self::new_vec(value) + } +} + +impl From for Error { + #[inline] + fn from(value: Bytes) -> Self { + Self::new_vec(value.into()) + } +} + +macro_rules! impl_from { + ($($t:ty),* $(,)?) => {$( + impl From<$t> for Error { + #[inline] + fn from(value: $t) -> Self { + Self::display(value) + } + } + )*}; +} + +impl_from!( + alloy_sol_types::Error, + ethers::types::SignatureError, + FsPathError, + hex::FromHexError, + eyre::Error, + super::db::DatabaseError, + jsonpath_lib::JsonPathError, + serde_json::Error, + SignatureError, + std::io::Error, + std::num::TryFromIntError, + std::str::Utf8Error, + std::string::FromUtf8Error, + UnresolvedEnvVarError, + WalletError, +); diff --git a/crates/cheatcodes/src/impls/evm.rs b/crates/cheatcodes/src/impls/evm.rs new file mode 100644 index 0000000000000..d75ec06b6ce62 --- /dev/null +++ b/crates/cheatcodes/src/impls/evm.rs @@ -0,0 +1,370 @@ +//! Implementations of [`Evm`](crate::Group::Evm) cheatcodes. + +use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_primitives::{Address, U256}; +use alloy_sol_types::SolValue; +use ethers::signers::Signer; +use foundry_utils::types::ToAlloy; +use revm::{ + primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, + EVMData, +}; +use std::collections::HashMap; + +mod fork; +pub(crate) mod mapping; +pub(crate) mod mock; +pub(crate) mod prank; + +/// Records storage slots reads and writes. +#[derive(Clone, Debug, Default)] +pub struct RecordAccess { + /// Storage slots reads. + pub reads: HashMap>, + /// Storage slots writes. + pub writes: HashMap>, +} + +/// Records `deal` cheatcodes +#[derive(Debug, Clone)] +pub struct DealRecord { + /// Target of the deal. + pub address: Address, + /// The balance of the address before deal was applied + pub old_balance: U256, + /// Balance after deal was applied + pub new_balance: U256, +} + +impl Cheatcode for addrCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { privateKey } = self; + let wallet = super::utils::parse_wallet(privateKey)?; + Ok(wallet.address().to_alloy().abi_encode()) + } +} + +impl Cheatcode for getNonce_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account } = self; + get_nonce(ccx, account) + } +} + +impl Cheatcode for loadCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { target, slot } = *self; + ensure_not_precompile!(&target, ccx); + ccx.data.journaled_state.load_account(target, ccx.data.db)?; + let (val, _) = ccx.data.journaled_state.sload(target, slot.into(), ccx.data.db)?; + Ok(val.abi_encode()) + } +} + +impl Cheatcode for sign_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { privateKey, digest } = self; + super::utils::sign(privateKey, digest, ccx.data.env.cfg.chain_id) + } +} + +impl Cheatcode for recordCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.accesses = Some(Default::default()); + Ok(Default::default()) + } +} + +impl Cheatcode for accessesCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { target } = *self; + let result = state + .accesses + .as_mut() + .map(|accesses| { + ( + &accesses.reads.entry(target).or_default()[..], + &accesses.writes.entry(target).or_default()[..], + ) + }) + .unwrap_or_default(); + Ok(result.abi_encode_params()) + } +} + +impl Cheatcode for recordLogsCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.recorded_logs = Some(Default::default()); + Ok(Default::default()) + } +} + +impl Cheatcode for getRecordedLogsCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + Ok(state.recorded_logs.replace(Default::default()).unwrap_or_default().abi_encode()) + } +} + +impl Cheatcode for pauseGasMeteringCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + if state.gas_metering.is_none() { + state.gas_metering = Some(None); + } + Ok(Default::default()) + } +} + +impl Cheatcode for resumeGasMeteringCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.gas_metering = None; + Ok(Default::default()) + } +} + +impl Cheatcode for chainIdCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newChainId } = self; + ensure!(*newChainId <= U256::from(u64::MAX), "chain ID must be less than 2^64 - 1"); + ccx.data.env.cfg.chain_id = newChainId.to(); + Ok(Default::default()) + } +} + +impl Cheatcode for coinbaseCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newCoinbase } = self; + ccx.data.env.block.coinbase = *newCoinbase; + Ok(Default::default()) + } +} + +impl Cheatcode for difficultyCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newDifficulty } = self; + ensure!( + ccx.data.env.cfg.spec_id < SpecId::MERGE, + "`difficulty` is not supported after the Paris hard fork, use `prevrandao` instead; \ + see EIP-4399: https://eips.ethereum.org/EIPS/eip-4399" + ); + ccx.data.env.block.difficulty = *newDifficulty; + Ok(Default::default()) + } +} + +impl Cheatcode for feeCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newBasefee } = self; + ccx.data.env.block.basefee = *newBasefee; + Ok(Default::default()) + } +} + +impl Cheatcode for prevrandaoCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newPrevrandao } = self; + ensure!( + ccx.data.env.cfg.spec_id >= SpecId::MERGE, + "`prevrandao` is not supported before the Paris hard fork, use `difficulty` instead; \ + see EIP-4399: https://eips.ethereum.org/EIPS/eip-4399" + ); + ccx.data.env.block.prevrandao = Some(*newPrevrandao); + Ok(Default::default()) + } +} + +impl Cheatcode for rollCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newHeight } = self; + ccx.data.env.block.number = *newHeight; + Ok(Default::default()) + } +} + +impl Cheatcode for txGasPriceCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newGasPrice } = self; + ccx.data.env.tx.gas_price = *newGasPrice; + Ok(Default::default()) + } +} + +impl Cheatcode for warpCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newTimestamp } = self; + ccx.data.env.block.timestamp = *newTimestamp; + Ok(Default::default()) + } +} + +impl Cheatcode for dealCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account: address, newBalance: new_balance } = *self; + ensure_not_precompile!(&address, ccx); + let account = journaled_account(ccx.data, address)?; + let old_balance = std::mem::replace(&mut account.info.balance, new_balance); + let record = DealRecord { address, old_balance, new_balance }; + ccx.state.eth_deals.push(record); + Ok(Default::default()) + } +} + +impl Cheatcode for etchCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { target, newRuntimeBytecode } = self; + ensure_not_precompile!(target, ccx); + ccx.data.journaled_state.load_account(*target, ccx.data.db)?; + let bytecode = Bytecode::new_raw(newRuntimeBytecode.clone().into()).to_checked(); + ccx.data.journaled_state.set_code(*target, bytecode); + Ok(Default::default()) + } +} + +impl Cheatcode for resetNonceCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account } = self; + let account = journaled_account(ccx.data, *account)?; + // Per EIP-161, EOA nonces start at 0, but contract nonces + // start at 1. Comparing by code_hash instead of code + // to avoid hitting the case where account's code is None. + let empty = account.info.code_hash == KECCAK_EMPTY; + let nonce = if empty { 0 } else { 1 }; + account.info.nonce = nonce; + Ok(Default::default()) + } +} + +impl Cheatcode for setNonceCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account, newNonce } = *self; + let account = journaled_account(ccx.data, account)?; + // nonce must increment only + let current = account.info.nonce; + ensure!( + newNonce >= current, + "new nonce ({newNonce}) must be strictly equal to or higher than the \ + account's current nonce ({current})" + ); + account.info.nonce = newNonce; + Ok(Default::default()) + } +} + +impl Cheatcode for setNonceUnsafeCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account, newNonce } = *self; + let account = journaled_account(ccx.data, account)?; + account.info.nonce = newNonce; + Ok(Default::default()) + } +} + +impl Cheatcode for storeCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { target, slot, value } = *self; + ensure_not_precompile!(&target, ccx); + // ensure the account is touched + let _ = journaled_account(ccx.data, target)?; + ccx.data.journaled_state.sstore(target, slot.into(), value.into(), ccx.data.db)?; + Ok(Default::default()) + } +} + +impl Cheatcode for readCallersCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + read_callers(ccx.state, &ccx.data.env.tx.caller) + } +} + +impl Cheatcode for snapshotCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + Ok(ccx.data.db.snapshot(&ccx.data.journaled_state, ccx.data.env).abi_encode()) + } +} + +impl Cheatcode for revertToCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { snapshotId } = self; + let result = if let Some(journaled_state) = + ccx.data.db.revert(*snapshotId, &ccx.data.journaled_state, ccx.data.env) + { + // we reset the evm's journaled_state to the state of the snapshot previous state + ccx.data.journaled_state = journaled_state; + true + } else { + false + }; + Ok(result.abi_encode()) + } +} + +pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { + super::script::correct_sender_nonce(ccx)?; + let (account, _) = ccx.data.journaled_state.load_account(*address, ccx.data.db)?; + Ok(account.info.nonce.abi_encode()) +} + +/// Reads the current caller information and returns the current [CallerMode], `msg.sender` and +/// `tx.origin`. +/// +/// Depending on the current caller mode, one of the following results will be returned: +/// - If there is an active prank: +/// - caller_mode will be equal to: +/// - [CallerMode::Prank] if the prank has been set with `vm.prank(..)`. +/// - [CallerMode::RecurrentPrank] if the prank has been set with `vm.startPrank(..)`. +/// - `msg.sender` will be equal to the address set for the prank. +/// - `tx.origin` will be equal to the default sender address unless an alternative one has been +/// set when configuring the prank. +/// +/// - If there is an active broadcast: +/// - caller_mode will be equal to: +/// - [CallerMode::Broadcast] if the broadcast has been set with `vm.broadcast(..)`. +/// - [CallerMode::RecurrentBroadcast] if the broadcast has been set with +/// `vm.startBroadcast(..)`. +/// - `msg.sender` and `tx.origin` will be equal to the address provided when setting the +/// broadcast. +/// +/// - If no caller modification is active: +/// - caller_mode will be equal to [CallerMode::None], +/// - `msg.sender` and `tx.origin` will be equal to the default sender address. +fn read_callers(state: &Cheatcodes, default_sender: &Address) -> Result { + let Cheatcodes { prank, broadcast, .. } = state; + + let mut mode = CallerMode::None; + let mut new_caller = default_sender; + let mut new_origin = default_sender; + if let Some(prank) = prank { + mode = if prank.single_call { CallerMode::Prank } else { CallerMode::RecurrentPrank }; + new_caller = &prank.new_caller; + if let Some(new) = &prank.new_origin { + new_origin = new; + } + } else if let Some(broadcast) = broadcast { + mode = if broadcast.single_call { + CallerMode::Broadcast + } else { + CallerMode::RecurrentBroadcast + }; + new_caller = &broadcast.new_origin; + new_origin = &broadcast.new_origin; + } + + Ok((mode, new_caller, new_origin).abi_encode_params()) +} + +/// Ensures the `Account` is loaded and touched. +pub(super) fn journaled_account<'a, DB: DatabaseExt>( + data: &'a mut EVMData<'_, DB>, + addr: Address, +) -> Result<&'a mut Account> { + data.journaled_state.load_account(addr, data.db)?; + data.journaled_state.touch(&addr); + Ok(data.journaled_state.state.get_mut(&addr).expect("account is loaded")) +} diff --git a/crates/cheatcodes/src/impls/evm/fork.rs b/crates/cheatcodes/src/impls/evm/fork.rs new file mode 100644 index 0000000000000..c192db302315c --- /dev/null +++ b/crates/cheatcodes/src/impls/evm/fork.rs @@ -0,0 +1,299 @@ +use alloy_primitives::B256; +use alloy_sol_types::SolValue; + +use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use crate::{impls::CreateFork, Cheatcodes, Vm::*}; + +impl Cheatcode for activeForkCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + ccx.data + .db + .active_fork_id() + .map(|id| id.abi_encode()) + .ok_or_else(|| fmt_err!("no active fork")) + } +} + +impl Cheatcode for createFork_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { urlOrAlias } = self; + create_fork(ccx, urlOrAlias, None) + } +} + +impl Cheatcode for createFork_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { urlOrAlias, blockNumber } = self; + create_fork(ccx, urlOrAlias, Some(blockNumber.saturating_to())) + } +} + +impl Cheatcode for createFork_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { urlOrAlias, txHash } = self; + create_fork_at_transaction(ccx, urlOrAlias, txHash) + } +} + +impl Cheatcode for createSelectFork_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { urlOrAlias } = self; + create_select_fork(ccx, urlOrAlias, None) + } +} + +impl Cheatcode for createSelectFork_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { urlOrAlias, blockNumber } = self; + create_select_fork(ccx, urlOrAlias, Some(blockNumber.saturating_to())) + } +} + +impl Cheatcode for createSelectFork_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { urlOrAlias, txHash } = self; + create_select_fork_at_transaction(ccx, urlOrAlias, txHash) + } +} + +impl Cheatcode for rollFork_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { blockNumber } = self; + ccx.data.db.roll_fork(None, *blockNumber, ccx.data.env, &mut ccx.data.journaled_state)?; + Ok(Default::default()) + } +} + +impl Cheatcode for rollFork_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { txHash } = self; + ccx.data.db.roll_fork_to_transaction( + None, + *txHash, + ccx.data.env, + &mut ccx.data.journaled_state, + )?; + Ok(Default::default()) + } +} + +impl Cheatcode for rollFork_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { forkId, blockNumber } = self; + ccx.data.db.roll_fork( + Some(*forkId), + *blockNumber, + ccx.data.env, + &mut ccx.data.journaled_state, + )?; + Ok(Default::default()) + } +} + +impl Cheatcode for rollFork_3Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { forkId, txHash } = self; + ccx.data.db.roll_fork_to_transaction( + Some(*forkId), + *txHash, + ccx.data.env, + &mut ccx.data.journaled_state, + )?; + Ok(Default::default()) + } +} + +impl Cheatcode for selectForkCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { forkId } = self; + check_broadcast(ccx.state)?; + + // No need to correct since the sender's nonce does not get incremented when selecting a + // fork. + ccx.state.corrected_nonce = true; + + ccx.data.db.select_fork(*forkId, ccx.data.env, &mut ccx.data.journaled_state)?; + Ok(Default::default()) + } +} + +impl Cheatcode for transact_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { txHash } = *self; + ccx.data.db.transact( + None, + txHash, + ccx.data.env, + &mut ccx.data.journaled_state, + Some(ccx.state), + )?; + Ok(Default::default()) + } +} + +impl Cheatcode for transact_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { forkId, txHash } = *self; + ccx.data.db.transact( + Some(forkId), + txHash, + ccx.data.env, + &mut ccx.data.journaled_state, + Some(ccx.state), + )?; + Ok(Default::default()) + } +} + +impl Cheatcode for allowCheatcodesCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account } = self; + ccx.data.db.allow_cheatcode_access(*account); + Ok(Default::default()) + } +} + +impl Cheatcode for makePersistent_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account } = self; + ccx.data.db.add_persistent_account(*account); + Ok(Default::default()) + } +} + +impl Cheatcode for makePersistent_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account0, account1 } = self; + ccx.data.db.add_persistent_account(*account0); + ccx.data.db.add_persistent_account(*account1); + Ok(Default::default()) + } +} + +impl Cheatcode for makePersistent_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account0, account1, account2 } = self; + ccx.data.db.add_persistent_account(*account0); + ccx.data.db.add_persistent_account(*account1); + ccx.data.db.add_persistent_account(*account2); + Ok(Default::default()) + } +} + +impl Cheatcode for makePersistent_3Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { accounts } = self; + ccx.data.db.extend_persistent_accounts(accounts.iter().copied()); + Ok(Default::default()) + } +} + +impl Cheatcode for revokePersistent_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account } = self; + ccx.data.db.remove_persistent_account(account); + Ok(Default::default()) + } +} + +impl Cheatcode for revokePersistent_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { accounts } = self; + ccx.data.db.remove_persistent_accounts(accounts.iter().copied()); + Ok(Default::default()) + } +} + +impl Cheatcode for isPersistentCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { account } = self; + Ok(ccx.data.db.is_persistent(account).abi_encode()) + } +} + +/// Creates and then also selects the new fork +fn create_select_fork( + ccx: &mut CheatsCtxt, + url_or_alias: &str, + block: Option, +) -> Result { + check_broadcast(ccx.state)?; + + // No need to correct since the sender's nonce does not get incremented when selecting a fork. + ccx.state.corrected_nonce = true; + + let fork = create_fork_request(ccx, url_or_alias, block)?; + let id = ccx.data.db.create_select_fork(fork, ccx.data.env, &mut ccx.data.journaled_state)?; + Ok(id.abi_encode()) +} + +/// Creates a new fork +fn create_fork( + ccx: &mut CheatsCtxt, + url_or_alias: &str, + block: Option, +) -> Result { + let fork = create_fork_request(ccx, url_or_alias, block)?; + let id = ccx.data.db.create_fork(fork)?; + Ok(id.abi_encode()) +} + +/// Creates and then also selects the new fork at the given transaction +fn create_select_fork_at_transaction( + ccx: &mut CheatsCtxt, + url_or_alias: &str, + transaction: &B256, +) -> Result { + check_broadcast(ccx.state)?; + + // No need to correct since the sender's nonce does not get incremented when selecting a fork. + ccx.state.corrected_nonce = true; + + let fork = create_fork_request(ccx, url_or_alias, None)?; + let id = ccx.data.db.create_select_fork_at_transaction( + fork, + ccx.data.env, + &mut ccx.data.journaled_state, + *transaction, + )?; + Ok(id.abi_encode()) +} + +/// Creates a new fork at the given transaction +fn create_fork_at_transaction( + ccx: &mut CheatsCtxt, + url_or_alias: &str, + transaction: &B256, +) -> Result { + let fork = create_fork_request(ccx, url_or_alias, None)?; + let id = ccx.data.db.create_fork_at_transaction(fork, *transaction)?; + Ok(id.abi_encode()) +} + +/// Creates the request object for a new fork request +fn create_fork_request( + ccx: &mut CheatsCtxt, + url_or_alias: &str, + block: Option, +) -> Result { + let url = ccx.state.config.rpc_url(url_or_alias)?; + let mut evm_opts = ccx.state.config.evm_opts.clone(); + evm_opts.fork_block_number = block; + let fork = CreateFork { + enable_caching: ccx.state.config.rpc_storage_caching.enable_for_endpoint(&url), + url, + env: ccx.data.env.clone(), + evm_opts, + }; + Ok(fork) +} + +#[inline] +fn check_broadcast(state: &Cheatcodes) -> Result<()> { + if state.broadcast.is_none() { + Ok(()) + } else { + Err(fmt_err!("cannot select forks during a broadcast")) + } +} diff --git a/crates/cheatcodes/src/impls/evm/mapping.rs b/crates/cheatcodes/src/impls/evm/mapping.rs new file mode 100644 index 0000000000000..2713807b95075 --- /dev/null +++ b/crates/cheatcodes/src/impls/evm/mapping.rs @@ -0,0 +1,140 @@ +use super::{Cheatcode, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_sol_types::SolValue; +use revm::interpreter::{opcode, Interpreter}; +use std::collections::HashMap; + +/// Recorded mapping slots. +#[derive(Clone, Debug, Default)] +pub struct MappingSlots { + /// Holds mapping parent (slots => slots) + pub parent_slots: HashMap, + + /// Holds mapping key (slots => key) + pub keys: HashMap, + + /// Holds mapping child (slots => slots[]) + pub children: HashMap>, + + /// Holds the last sha3 result `sha3_result => (data_low, data_high)`, this would only record + /// when sha3 is called with `size == 0x40`, and the lower 256 bits would be stored in + /// `data_low`, higher 256 bits in `data_high`. + /// This is needed for mapping_key detect if the slot is for some mapping and record that. + pub seen_sha3: HashMap, +} + +impl MappingSlots { + /// Tries to insert a mapping slot. Returns true if it was inserted. + pub fn insert(&mut self, slot: B256) -> bool { + match self.seen_sha3.get(&slot).copied() { + Some((key, parent)) => { + if self.keys.contains_key(&slot) { + return false + } + self.keys.insert(slot, key); + self.parent_slots.insert(slot, parent); + self.children.entry(parent).or_default().push(slot); + self.insert(parent); + true + } + None => false, + } + } +} + +impl Cheatcode for startMappingRecordingCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + if state.mapping_slots.is_none() { + state.mapping_slots = Some(Default::default()); + } + Ok(Default::default()) + } +} + +impl Cheatcode for stopMappingRecordingCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.mapping_slots = None; + Ok(Default::default()) + } +} + +impl Cheatcode for getMappingLengthCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { target, mappingSlot } = self; + let result = slot_child(state, target, mappingSlot).map(Vec::len).unwrap_or(0); + Ok((result as u64).abi_encode()) + } +} + +impl Cheatcode for getMappingSlotAtCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { target, mappingSlot, idx } = self; + let result = slot_child(state, target, mappingSlot) + .and_then(|set| set.get(idx.saturating_to::())) + .copied() + .unwrap_or_default(); + Ok(result.abi_encode()) + } +} + +impl Cheatcode for getMappingKeyAndParentOfCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { target, elementSlot: slot } = self; + let mut found = false; + let mut key = &B256::ZERO; + let mut parent = &B256::ZERO; + if let Some(slots) = mapping_slot(state, target) { + if let Some(key2) = slots.keys.get(slot) { + found = true; + key = key2; + parent = &slots.parent_slots[slot]; + } else if let Some((key2, parent2)) = slots.seen_sha3.get(slot) { + found = true; + key = key2; + parent = parent2; + } + } + Ok((found, key, parent).abi_encode_params()) + } +} + +fn mapping_slot<'a>(state: &'a Cheatcodes, target: &'a Address) -> Option<&'a MappingSlots> { + state.mapping_slots.as_ref()?.get(target) +} + +fn slot_child<'a>( + state: &'a Cheatcodes, + target: &'a Address, + slot: &'a B256, +) -> Option<&'a Vec> { + mapping_slot(state, target)?.children.get(slot) +} + +#[inline] +pub(crate) fn step(mapping_slots: &mut HashMap, interpreter: &Interpreter) { + match interpreter.current_opcode() { + opcode::KECCAK256 => { + if interpreter.stack.peek(1) == Ok(U256::from(0x40)) { + let address = interpreter.contract.address; + let offset = interpreter.stack.peek(0).expect("stack size > 1").saturating_to(); + let data = interpreter.memory.slice(offset, 0x40); + let low = B256::from_slice(&data[..0x20]); + let high = B256::from_slice(&data[0x20..]); + let result = keccak256(data); + + mapping_slots.entry(address).or_default().seen_sha3.insert(result, (low, high)); + } + } + opcode::SSTORE => { + if let Some(mapping_slots) = mapping_slots.get_mut(&interpreter.contract.address) { + if let Ok(slot) = interpreter.stack.peek(0) { + mapping_slots.insert(slot.into()); + } + } + } + _ => {} + } +} diff --git a/crates/cheatcodes/src/impls/evm/mock.rs b/crates/cheatcodes/src/impls/evm/mock.rs new file mode 100644 index 0000000000000..5e70b33ac0c6e --- /dev/null +++ b/crates/cheatcodes/src/impls/evm/mock.rs @@ -0,0 +1,97 @@ +use super::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result}; +use crate::Vm::*; +use alloy_primitives::{Address, Bytes, U256}; +use revm::interpreter::InstructionResult; +use std::cmp::Ordering; + +/// Mocked call data. +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +pub struct MockCallDataContext { + /// The partial calldata to match for mock + pub calldata: Bytes, + /// The value to match for mock + pub value: Option, +} + +/// Mocked return data. +#[derive(Clone, Debug)] +pub struct MockCallReturnData { + /// The return type for the mocked call + pub ret_type: InstructionResult, + /// Return data or error + pub data: Bytes, +} + +impl PartialOrd for MockCallDataContext { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for MockCallDataContext { + fn cmp(&self, other: &Self) -> Ordering { + // Calldata matching is reversed to ensure that a tighter match is + // returned if an exact match is not found. In case, there is + // a partial match to calldata that is more specific than + // a match to a msg.value, then the more specific calldata takes + // precedence. + self.calldata.cmp(&other.calldata).reverse().then(self.value.cmp(&other.value).reverse()) + } +} + +impl Cheatcode for clearMockedCallsCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.mocked_calls = Default::default(); + Ok(Default::default()) + } +} + +impl Cheatcode for mockCall_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, data, returnData } = self; + ccx.data.journaled_state.load_account(*callee, ccx.data.db)?; + mock_call(ccx.state, callee, data, None, returnData, InstructionResult::Return); + Ok(Default::default()) + } +} + +impl Cheatcode for mockCall_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, msgValue, data, returnData } = self; + ccx.data.journaled_state.load_account(*callee, ccx.data.db)?; + mock_call(ccx.state, callee, data, Some(msgValue), returnData, InstructionResult::Return); + Ok(Default::default()) + } +} + +impl Cheatcode for mockCallRevert_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, data, revertData } = self; + mock_call(state, callee, data, None, revertData, InstructionResult::Return); + Ok(Default::default()) + } +} + +impl Cheatcode for mockCallRevert_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, msgValue, data, revertData } = self; + mock_call(state, callee, data, Some(msgValue), revertData, InstructionResult::Return); + Ok(Default::default()) + } +} + +#[allow(clippy::ptr_arg)] // Not public API, doesn't matter +fn mock_call( + state: &mut Cheatcodes, + callee: &Address, + cdata: &Vec, + value: Option<&U256>, + rdata: &Vec, + ret_type: InstructionResult, +) { + state.mocked_calls.entry(*callee).or_default().insert( + MockCallDataContext { calldata: Bytes::copy_from_slice(cdata), value: value.cloned() }, + MockCallReturnData { ret_type, data: Bytes::copy_from_slice(rdata) }, + ); +} diff --git a/crates/cheatcodes/src/impls/evm/prank.rs b/crates/cheatcodes/src/impls/evm/prank.rs new file mode 100644 index 0000000000000..e7764dfe94c17 --- /dev/null +++ b/crates/cheatcodes/src/impls/evm/prank.rs @@ -0,0 +1,126 @@ +use super::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result}; +use crate::Vm::*; +use alloy_primitives::Address; + +/// Prank information. +#[derive(Clone, Debug, Default)] +pub struct Prank { + /// Address of the contract that initiated the prank + pub prank_caller: Address, + /// Address of `tx.origin` when the prank was initiated + pub prank_origin: Address, + /// The address to assign to `msg.sender` + pub new_caller: Address, + /// The address to assign to `tx.origin` + pub new_origin: Option
, + /// The depth at which the prank was called + pub depth: u64, + /// Whether the prank stops by itself after the next call + pub single_call: bool, + /// Whether the prank has been used yet (false if unused) + pub used: bool, +} + +impl Prank { + /// Create a new prank. + pub fn new( + prank_caller: Address, + prank_origin: Address, + new_caller: Address, + new_origin: Option
, + depth: u64, + single_call: bool, + ) -> Prank { + Prank { + prank_caller, + prank_origin, + new_caller, + new_origin, + depth, + single_call, + used: false, + } + } + + /// Apply the prank by setting `used` to true iff it is false + /// Only returns self in the case it is updated (first application) + pub fn first_time_applied(&self) -> Option { + if self.used { + None + } else { + Some(Prank { used: true, ..self.clone() }) + } + } +} + +impl Cheatcode for prank_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender } = self; + prank(ccx, msgSender, None, true) + } +} + +impl Cheatcode for startPrank_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender } = self; + prank(ccx, msgSender, None, false) + } +} + +impl Cheatcode for prank_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender, txOrigin } = self; + prank(ccx, msgSender, Some(txOrigin), true) + } +} + +impl Cheatcode for startPrank_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender, txOrigin } = self; + prank(ccx, msgSender, Some(txOrigin), false) + } +} + +impl Cheatcode for stopPrankCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.prank = None; + Ok(Default::default()) + } +} + +fn prank( + ccx: &mut CheatsCtxt, + new_caller: &Address, + new_origin: Option<&Address>, + single_call: bool, +) -> Result { + let prank = Prank::new( + ccx.caller, + ccx.data.env.tx.caller, + *new_caller, + new_origin.copied(), + ccx.data.journaled_state.depth(), + single_call, + ); + + if let Some(Prank { used, single_call: current_single_call, .. }) = ccx.state.prank { + ensure!(used, "cannot overwrite a prank until it is applied at least once"); + // This case can only fail if the user calls `vm.startPrank` and then `vm.prank` later on. + // This should not be possible without first calling `stopPrank` + ensure!( + single_call == current_single_call, + "cannot override an ongoing prank with a single vm.prank; \ + use vm.startPrank to override the current prank" + ); + } + + ensure!( + ccx.state.broadcast.is_none(), + "cannot `prank` for a broadcasted transaction; \ + pass the desired `tx.origin` into the `broadcast` cheatcode call" + ); + + ccx.state.prank = Some(prank); + Ok(Default::default()) +} diff --git a/crates/cheatcodes/src/impls/fs.rs b/crates/cheatcodes/src/impls/fs.rs new file mode 100644 index 0000000000000..36b1912a9fcdf --- /dev/null +++ b/crates/cheatcodes/src/impls/fs.rs @@ -0,0 +1,416 @@ +//! Implementations of [`Filesystem`](crate::Group::Filesystem) cheatcodes. + +use super::{Cheatcode, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_json_abi::ContractObject; +use alloy_primitives::U256; +use alloy_sol_types::SolValue; +use foundry_common::{fs, get_artifact_path}; +use foundry_config::fs_permissions::FsAccessKind; +use std::{ + collections::hash_map::Entry, + io::{BufRead, BufReader, Write}, + path::Path, + process::Command, + time::{SystemTime, UNIX_EPOCH}, +}; +use walkdir::WalkDir; + +impl Cheatcode for existsCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + Ok(path.exists().abi_encode()) + } +} + +impl Cheatcode for fsMetadataCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + + let metadata = path.metadata()?; + + // These fields not available on all platforms; default to 0 + let [modified, accessed, created] = + [metadata.modified(), metadata.accessed(), metadata.created()].map(|time| { + time.unwrap_or(UNIX_EPOCH).duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() + }); + + Ok(FsMetadata { + isDir: metadata.is_dir(), + isSymlink: metadata.is_symlink(), + length: U256::from(metadata.len()), + readOnly: metadata.permissions().readonly(), + modified: U256::from(modified), + accessed: U256::from(accessed), + created: U256::from(created), + } + .abi_encode()) + } +} + +impl Cheatcode for isDirCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + Ok(path.is_dir().abi_encode()) + } +} + +impl Cheatcode for isFileCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + Ok(path.is_file().abi_encode()) + } +} + +impl Cheatcode for projectRootCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + Ok(state.config.root.display().to_string().abi_encode()) + } +} + +impl Cheatcode for unixTimeCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self {} = self; + let difference = SystemTime::now() + .duration_since(UNIX_EPOCH) + .map_err(|e| fmt_err!("failed getting Unix timestamp: {e}"))?; + Ok(difference.as_millis().abi_encode()) + } +} + +impl Cheatcode for closeFileCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + + state.context.opened_read_files.remove(&path); + + Ok(Default::default()) + } +} + +impl Cheatcode for copyFileCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { from, to } = self; + let from = state.config.ensure_path_allowed(from, FsAccessKind::Read)?; + let to = state.config.ensure_path_allowed(to, FsAccessKind::Write)?; + state.config.ensure_not_foundry_toml(&to)?; + + let n = fs::copy(from, to)?; + Ok(n.abi_encode()) + } +} + +impl Cheatcode for createDirCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path, recursive } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; + if *recursive { fs::create_dir_all(path) } else { fs::create_dir(path) }?; + Ok(Default::default()) + } +} + +impl Cheatcode for readDir_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + read_dir(state, path.as_ref(), 1, false) + } +} + +impl Cheatcode for readDir_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path, maxDepth } = self; + read_dir(state, path.as_ref(), *maxDepth, false) + } +} + +impl Cheatcode for readDir_2Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path, maxDepth, followLinks } = self; + read_dir(state, path.as_ref(), *maxDepth, *followLinks) + } +} + +impl Cheatcode for readFileCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + Ok(fs::read_to_string(path)?.abi_encode()) + } +} + +impl Cheatcode for readFileBinaryCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + Ok(fs::read(path)?.abi_encode()) + } +} + +impl Cheatcode for readLineCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + + // Get reader for previously opened file to continue reading OR initialize new reader + let reader = match state.context.opened_read_files.entry(path.clone()) { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => entry.insert(BufReader::new(fs::open(path)?)), + }; + + let mut line: String = String::new(); + reader.read_line(&mut line)?; + + // Remove trailing newline character, preserving others for cases where it may be important + if line.ends_with('\n') { + line.pop(); + if line.ends_with('\r') { + line.pop(); + } + } + + Ok(line.abi_encode()) + } +} + +impl Cheatcode for readLinkCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { linkPath: path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + let target = fs::read_link(path)?; + Ok(target.display().to_string().abi_encode()) + } +} + +impl Cheatcode for removeDirCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path, recursive } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; + if *recursive { fs::remove_dir_all(path) } else { fs::remove_dir(path) }?; + Ok(Default::default()) + } +} + +impl Cheatcode for removeFileCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; + state.config.ensure_not_foundry_toml(&path)?; + + // also remove from the set if opened previously + state.context.opened_read_files.remove(&path); + + if state.fs_commit { + fs::remove_file(&path)?; + } + + Ok(Default::default()) + } +} + +impl Cheatcode for writeFileCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path, data } = self; + write_file(state, path.as_ref(), data.as_bytes()) + } +} + +impl Cheatcode for writeFileBinaryCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path, data } = self; + write_file(state, path.as_ref(), data) + } +} + +impl Cheatcode for writeLineCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { path, data: line } = self; + let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; + state.config.ensure_not_foundry_toml(&path)?; + + if state.fs_commit { + let mut file = std::fs::OpenOptions::new().append(true).create(true).open(path)?; + + writeln!(file, "{line}")?; + } + + Ok(Default::default()) + } +} + +impl Cheatcode for getCodeCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { artifactPath: path } = self; + let object = read_bytecode(state, path)?; + if let Some(bin) = object.bytecode { + Ok(bin.abi_encode()) + } else { + Err(fmt_err!("No bytecode for contract. Is it abstract or unlinked?")) + } + } +} + +impl Cheatcode for getDeployedCodeCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { artifactPath: path } = self; + let object = read_bytecode(state, path)?; + if let Some(bin) = object.deployed_bytecode { + Ok(bin.abi_encode()) + } else { + Err(fmt_err!("No deployed bytecode for contract. Is it abstract or unlinked?")) + } + } +} + +/// Reads the bytecode object(s) from the matching artifact +fn read_bytecode(state: &Cheatcodes, path: &str) -> Result { + let path = get_artifact_path(&state.config.paths, path); + let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + let data = fs::read_to_string(path)?; + serde_json::from_str::(&data).map_err(Into::into) +} + +impl Cheatcode for ffiCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { commandInput: input } = self; + + let output = ffi(state, input)?; + // TODO: check exit code? + if !output.stderr.is_empty() { + let stderr = String::from_utf8_lossy(&output.stderr); + error!(target: "cheatcodes", ?input, ?stderr, "non-empty stderr"); + } + // we already hex-decoded the stdout in `ffi` + Ok(output.stdout.abi_encode()) + } +} + +impl Cheatcode for tryFfiCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { commandInput: input } = self; + ffi(state, input).map(|res| res.abi_encode()) + } +} + +pub(super) fn write_file(state: &Cheatcodes, path: &Path, contents: &[u8]) -> Result { + let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; + // write access to foundry.toml is not allowed + state.config.ensure_not_foundry_toml(&path)?; + + if state.fs_commit { + fs::write(path, contents)?; + } + + Ok(Default::default()) +} + +fn read_dir(state: &Cheatcodes, path: &Path, max_depth: u64, follow_links: bool) -> Result { + let root = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + let paths: Vec = WalkDir::new(root) + .min_depth(1) + .max_depth(max_depth.try_into().unwrap_or(usize::MAX)) + .follow_links(follow_links) + .contents_first(false) + .same_file_system(true) + .sort_by_file_name() + .into_iter() + .map(|entry| match entry { + Ok(entry) => DirEntry { + errorMessage: String::new(), + path: entry.path().display().to_string(), + depth: entry.depth() as u64, + isDir: entry.file_type().is_dir(), + isSymlink: entry.path_is_symlink(), + }, + Err(e) => DirEntry { + errorMessage: e.to_string(), + path: e.path().map(|p| p.display().to_string()).unwrap_or_default(), + depth: e.depth() as u64, + isDir: false, + isSymlink: false, + }, + }) + .collect(); + Ok(paths.abi_encode()) +} + +fn ffi(state: &Cheatcodes, input: &[String]) -> Result { + ensure!( + state.config.ffi, + "FFI is disabled; add the `--ffi` flag to allow tests to call external commands" + ); + ensure!(!input.is_empty() && !input[0].is_empty(), "can't execute empty command"); + let mut cmd = Command::new(&input[0]); + cmd.args(&input[1..]); + + debug!(target: "cheatcodes", ?cmd, "invoking ffi"); + + let output = cmd + .current_dir(&state.config.root) + .output() + .map_err(|err| fmt_err!("failed to execute command {cmd:?}: {err}"))?; + + // The stdout might be encoded on valid hex, or it might just be a string, + // so we need to determine which it is to avoid improperly encoding later. + let trimmed_stdout = String::from_utf8(output.stdout)?; + let trimmed_stdout = trimmed_stdout.trim(); + let encoded_stdout = if let Ok(hex) = hex::decode(trimmed_stdout) { + hex + } else { + trimmed_stdout.as_bytes().to_vec() + }; + Ok(FfiResult { + exitCode: output.status.code().unwrap_or(69), + stdout: encoded_stdout, + stderr: output.stderr, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::CheatsConfig; + use std::{path::PathBuf, sync::Arc}; + + fn cheats() -> Cheatcodes { + let config = CheatsConfig { + ffi: true, + root: PathBuf::from(&env!("CARGO_MANIFEST_DIR")), + ..Default::default() + }; + Cheatcodes { config: Arc::new(config), ..Default::default() } + } + + #[test] + fn test_ffi_hex() { + let msg = b"gm"; + let cheats = cheats(); + let args = ["echo".to_string(), hex::encode(msg)]; + let output = ffi(&cheats, &args).unwrap(); + assert_eq!(output.stdout, msg); + } + + #[test] + fn test_ffi_string() { + let msg = "gm"; + let cheats = cheats(); + let args = ["echo".to_string(), msg.to_string()]; + let output = ffi(&cheats, &args).unwrap(); + assert_eq!(output.stdout, msg.as_bytes()); + } + + #[test] + fn test_artifact_parsing() { + let s = include_str!("../../../evm/test-data/solc-obj.json"); + let artifact: ContractObject = serde_json::from_str(s).unwrap(); + assert!(artifact.bytecode.is_some()); + + let artifact: ContractObject = serde_json::from_str(s).unwrap(); + assert!(artifact.deployed_bytecode.is_some()); + } +} diff --git a/crates/cheatcodes/src/impls/inspector.rs b/crates/cheatcodes/src/impls/inspector.rs new file mode 100644 index 0000000000000..46faa6fdd86eb --- /dev/null +++ b/crates/cheatcodes/src/impls/inspector.rs @@ -0,0 +1,1098 @@ +//! Cheatcode EVM [Inspector]. + +use super::{ + evm::{ + mapping::{self, MappingSlots}, + mock::{MockCallDataContext, MockCallReturnData}, + prank::Prank, + DealRecord, RecordAccess, + }, + script::Broadcast, + test::expect::{ + self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, ExpectedRevert, + }, + CheatsCtxt, DatabaseExt, Error, Result, RevertDiagnostic, MAGIC_SKIP_BYTES, +}; +use crate::{ + CheatsConfig, Vm, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, +}; +use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_sol_types::{SolInterface, SolValue}; +use ethers::{ + signers::LocalWallet, + types::{transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest}, +}; +use foundry_common::RpcUrl; +use foundry_utils::types::ToEthers; +use itertools::Itertools; +use revm::{ + interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, + primitives::{BlockEnv, CreateScheme, TransactTo}, + EVMData, Inspector, +}; +use serde_json::Value; +use std::{ + collections::{HashMap, VecDeque}, + fs::File, + io::BufReader, + ops::Range, + path::PathBuf, + sync::Arc, +}; + +macro_rules! try_or_continue { + ($e:expr) => { + match $e { + Ok(v) => v, + Err(_) => return InstructionResult::Continue, + } + }; +} + +/// Contains additional, test specific resources that should be kept for the duration of the test +#[derive(Debug, Default)] +pub struct Context { + /// Buffered readers for files opened for reading (path => BufReader mapping) + pub opened_read_files: HashMap>, +} + +/// Every time we clone `Context`, we want it to be empty +impl Clone for Context { + fn clone(&self) -> Self { + Default::default() + } +} + +impl Context { + /// Clears the context. + #[inline] + pub fn clear(&mut self) { + self.opened_read_files.clear(); + } +} + +/// Helps collecting transactions from different forks. +#[derive(Debug, Clone, Default)] +pub struct BroadcastableTransaction { + /// The optional RPC URL. + pub rpc: Option, + /// The transaction to broadcast. + pub transaction: TypedTransaction, +} + +/// List of transactions that can be broadcasted. +pub type BroadcastableTransactions = VecDeque; + +/// An EVM inspector that handles calls to various cheatcodes, each with their own behavior. +/// +/// Cheatcodes can be called by contracts during execution to modify the VM environment, such as +/// mocking addresses, signatures and altering call reverts. +/// +/// Executing cheatcodes can be very powerful. Most cheatcodes are limited to evm internals, but +/// there are also cheatcodes like `ffi` which can execute arbitrary commands or `writeFile` and +/// `readFile` which can manipulate files of the filesystem. Therefore, several restrictions are +/// implemented for these cheatcodes: +/// - `ffi`, and file cheatcodes are _always_ opt-in (via foundry config) and never enabled by +/// default: all respective cheatcode handlers implement the appropriate checks +/// - File cheatcodes require explicit permissions which paths are allowed for which operation, see +/// `Config.fs_permission` +/// - Only permitted accounts are allowed to execute cheatcodes in forking mode, this ensures no +/// contract deployed on the live network is able to execute cheatcodes by simply calling the +/// cheatcode address: by default, the caller, test contract and newly deployed contracts are +/// allowed to execute cheatcodes +#[derive(Clone, Debug, Default)] +pub struct Cheatcodes { + /// The block environment + /// + /// Used in the cheatcode handler to overwrite the block environment separately from the + /// execution block environment. + pub block: Option, + + /// The gas price + /// + /// Used in the cheatcode handler to overwrite the gas price separately from the gas price + /// in the execution environment. + pub gas_price: Option, + + /// Address labels + pub labels: HashMap, + + /// Rememebered private keys + pub script_wallets: Vec, + + /// Whether the skip cheatcode was activated + pub skip: bool, + + /// Prank information + pub prank: Option, + + /// Expected revert information + pub expected_revert: Option, + + /// Additional diagnostic for reverts + pub fork_revert_diagnostic: Option, + + /// Recorded storage reads and writes + pub accesses: Option, + + /// Recorded logs + pub recorded_logs: Option>, + + /// Mocked calls + pub mocked_calls: HashMap>, + + /// Expected calls + pub expected_calls: ExpectedCallTracker, + /// Expected emits + pub expected_emits: VecDeque, + + /// Map of context depths to memory offset ranges that may be written to within the call depth. + pub allowed_mem_writes: HashMap>>, + + /// Current broadcasting information + pub broadcast: Option, + + /// Used to correct the nonce of --sender after the initiating call. For more, check + /// `docs/scripting`. + pub corrected_nonce: bool, + + /// Scripting based transactions + pub broadcastable_transactions: BroadcastableTransactions, + + /// Additional, user configurable context this Inspector has access to when inspecting a call + pub config: Arc, + + /// Test-scoped context holding data that needs to be reset every test run + pub context: Context, + + /// Commit FS changes such as file creations, writes and deletes. + /// Used to prevent duplicate changes file executing non-committing calls. + pub fs_commit: bool, + + /// Serialized JSON values. + pub serialized_jsons: HashMap>, + + /// Records all eth deals + pub eth_deals: Vec, + + /// Holds the stored gas info for when we pause gas metering. It is an `Option>` + /// because the `call` callback in an `Inspector` doesn't get access to + /// the `revm::Interpreter` which holds the `revm::Gas` struct that + /// we need to copy. So we convert it to a `Some(None)` in `apply_cheatcode`, and once we have + /// the interpreter, we copy the gas struct. Then each time there is an execution of an + /// operation, we reset the gas. + pub gas_metering: Option>, + + /// Holds stored gas info for when we pause gas metering, and we're entering/inside + /// CREATE / CREATE2 frames. This is needed to make gas meter pausing work correctly when + /// paused and creating new contracts. + pub gas_metering_create: Option>, + + /// Holds mapping slots info + pub mapping_slots: Option>, + + /// current program counter + pub pc: usize, + /// Breakpoints supplied by the `breakpoint` cheatcode. + /// `char -> pc` + // TODO: don't use ethers address + pub breakpoints: HashMap, +} + +impl Cheatcodes { + /// Creates a new `Cheatcodes` with the given settings. + #[inline] + pub fn new(config: Arc) -> Self { + Self { config, fs_commit: true, ..Default::default() } + } + + fn apply_cheatcode( + &mut self, + data: &mut EVMData<'_, DB>, + call: &CallInputs, + ) -> Result { + // decode the cheatcode call + let decoded = Vm::VmCalls::abi_decode(&call.input, false)?; + let caller = call.context.caller; + + // ensure the caller is allowed to execute cheatcodes, + // but only if the backend is in forking mode + data.db.ensure_cheatcode_access_forking_mode(caller)?; + + // apply the cheatcode to the current state + decoded.apply(&mut CheatsCtxt { state: self, data, caller }) + } + + /// Determines the address of the contract and marks it as allowed + /// + /// There may be cheatcodes in the constructor of the new contract, in order to allow them + /// automatically we need to determine the new address + fn allow_cheatcodes_on_create( + &self, + data: &mut EVMData<'_, DB>, + inputs: &CreateInputs, + ) { + if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { + // we only grant cheat code access for new contracts if the caller also has + // cheatcode access and the new contract is created in top most call + return + } + + let old_nonce = data + .journaled_state + .state + .get(&inputs.caller) + .map(|acc| acc.info.nonce) + .unwrap_or_default(); + let created_address = get_create_address(inputs, old_nonce); + + data.db.allow_cheatcode_access(created_address); + } + + /// Called when there was a revert. + /// + /// Cleanup any previously applied cheatcodes that altered the state in such a way that revm's + /// revert would run into issues. + #[allow(private_bounds)] // TODO + pub fn on_revert(&mut self, data: &mut EVMData<'_, DB>) { + trace!(deals = ?self.eth_deals.len(), "rolling back deals"); + + // Delay revert clean up until expected revert is handled, if set. + if self.expected_revert.is_some() { + return + } + + // we only want to apply cleanup top level + if data.journaled_state.depth() > 0 { + return + } + + // Roll back all previously applied deals + // This will prevent overflow issues in revm's [`JournaledState::journal_revert`] routine + // which rolls back any transfers. + while let Some(record) = self.eth_deals.pop() { + if let Some(acc) = data.journaled_state.state.get_mut(&record.address) { + acc.info.balance = record.old_balance; + } + } + } +} + +impl Inspector for Cheatcodes { + #[inline] + fn initialize_interp( + &mut self, + _: &mut Interpreter, + data: &mut EVMData<'_, DB>, + ) -> InstructionResult { + // When the first interpreter is initialized we've circumvented the balance and gas checks, + // so we apply our actual block data with the correct fees and all. + if let Some(block) = self.block.take() { + data.env.block = block; + } + if let Some(gas_price) = self.gas_price.take() { + data.env.tx.gas_price = gas_price; + } + + InstructionResult::Continue + } + + fn step( + &mut self, + interpreter: &mut Interpreter, + data: &mut EVMData<'_, DB>, + ) -> InstructionResult { + self.pc = interpreter.program_counter(); + + // reset gas if gas metering is turned off + match self.gas_metering { + Some(None) => { + // need to store gas metering + self.gas_metering = Some(Some(interpreter.gas)); + } + Some(Some(gas)) => { + match interpreter.current_opcode() { + opcode::CREATE | opcode::CREATE2 => { + // set we're about to enter CREATE frame to meter its gas on first opcode + // inside it + self.gas_metering_create = Some(None) + } + opcode::STOP | opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { + // If we are ending current execution frame, we want to just fully reset gas + // otherwise weird things with returning gas from a call happen + // ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/evm_impl.rs#L190 + // + // It would be nice if we had access to the interpreter in `call_end`, as we + // could just do this there instead. + match self.gas_metering_create { + None | Some(None) => { + interpreter.gas = Gas::new(0); + } + Some(Some(gas)) => { + // If this was CREATE frame, set correct gas limit. This is needed + // because CREATE opcodes deduct additional gas for code storage, + // and deducted amount is compared to gas limit. If we set this to + // 0, the CREATE would fail with out of gas. + // + // If we however set gas limit to the limit of outer frame, it would + // cause a panic after erasing gas cost post-create. Reason for this + // is pre-create REVM records `gas_limit - (gas_limit / 64)` as gas + // used, and erases costs by `remaining` gas post-create. + // gas used ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L254-L258 + // post-create erase ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L279 + interpreter.gas = Gas::new(gas.limit()); + + // reset CREATE gas metering because we're about to exit its frame + self.gas_metering_create = None + } + } + } + _ => { + // if just starting with CREATE opcodes, record its inner frame gas + if let Some(None) = self.gas_metering_create { + self.gas_metering_create = Some(Some(interpreter.gas)) + } + + // dont monitor gas changes, keep it constant + interpreter.gas = gas; + } + } + } + _ => {} + } + + // Record writes and reads if `record` has been called + if let Some(storage_accesses) = &mut self.accesses { + match interpreter.current_opcode() { + opcode::SLOAD => { + let key = try_or_continue!(interpreter.stack().peek(0)); + storage_accesses + .reads + .entry(interpreter.contract().address) + .or_default() + .push(key); + } + opcode::SSTORE => { + let key = try_or_continue!(interpreter.stack().peek(0)); + + // An SSTORE does an SLOAD internally + storage_accesses + .reads + .entry(interpreter.contract().address) + .or_default() + .push(key); + storage_accesses + .writes + .entry(interpreter.contract().address) + .or_default() + .push(key); + } + _ => (), + } + } + + // If the allowed memory writes cheatcode is active at this context depth, check to see + // if the current opcode can either mutate directly or expand memory. If the opcode at + // the current program counter is a match, check if the modified memory lies within the + // allowed ranges. If not, revert and fail the test. + if let Some(ranges) = self.allowed_mem_writes.get(&data.journaled_state.depth()) { + // The `mem_opcode_match` macro is used to match the current opcode against a list of + // opcodes that can mutate memory (either directly or expansion via reading). If the + // opcode is a match, the memory offsets that are being written to are checked to be + // within the allowed ranges. If not, the test is failed and the transaction is + // reverted. For all opcodes that can mutate memory aside from MSTORE, + // MSTORE8, and MLOAD, the size and destination offset are on the stack, and + // the macro expands all of these cases. For MSTORE, MSTORE8, and MLOAD, the + // size of the memory write is implicit, so these cases are hard-coded. + macro_rules! mem_opcode_match { + ($(($opcode:ident, $offset_depth:expr, $size_depth:expr, $writes:expr)),* $(,)?) => { + match interpreter.current_opcode() { + //////////////////////////////////////////////////////////////// + // OPERATIONS THAT CAN EXPAND/MUTATE MEMORY BY WRITING // + //////////////////////////////////////////////////////////////// + + opcode::MSTORE => { + // The offset of the mstore operation is at the top of the stack. + let offset = try_or_continue!(interpreter.stack().peek(0)).saturating_to::(); + + // If none of the allowed ranges contain [offset, offset + 32), memory has been + // unexpectedly mutated. + if !ranges.iter().any(|range| { + range.contains(&offset) && range.contains(&(offset + 31)) + }) { + disallowed_mem_write(offset, 32, interpreter, ranges); + return InstructionResult::Revert + } + } + opcode::MSTORE8 => { + // The offset of the mstore8 operation is at the top of the stack. + let offset = try_or_continue!(interpreter.stack().peek(0)).saturating_to::(); + + // If none of the allowed ranges contain the offset, memory has been + // unexpectedly mutated. + if !ranges.iter().any(|range| range.contains(&offset)) { + disallowed_mem_write(offset, 1, interpreter, ranges); + return InstructionResult::Revert + } + } + + //////////////////////////////////////////////////////////////// + // OPERATIONS THAT CAN EXPAND MEMORY BY READING // + //////////////////////////////////////////////////////////////// + + opcode::MLOAD => { + // The offset of the mload operation is at the top of the stack + let offset = try_or_continue!(interpreter.stack().peek(0)).saturating_to::(); + + // If the offset being loaded is >= than the memory size, the + // memory is being expanded. If none of the allowed ranges contain + // [offset, offset + 32), memory has been unexpectedly mutated. + if offset >= interpreter.memory.len() as u64 && !ranges.iter().any(|range| { + range.contains(&offset) && range.contains(&(offset + 31)) + }) { + disallowed_mem_write(offset, 32, interpreter, ranges); + return InstructionResult::Revert + } + } + + //////////////////////////////////////////////////////////////// + // OPERATIONS WITH OFFSET AND SIZE ON STACK // + //////////////////////////////////////////////////////////////// + + $(opcode::$opcode => { + // The destination offset of the operation is at the top of the stack. + let dest_offset = try_or_continue!(interpreter.stack().peek($offset_depth)).saturating_to::(); + + // The size of the data that will be copied is the third item on the stack. + let size = try_or_continue!(interpreter.stack().peek($size_depth)).saturating_to::(); + + // If none of the allowed ranges contain [dest_offset, dest_offset + size), + // memory outside of the expected ranges has been touched. If the opcode + // only reads from memory, this is okay as long as the memory is not expanded. + let fail_cond = !ranges.iter().any(|range| { + range.contains(&dest_offset) && + range.contains(&(dest_offset + size.saturating_sub(1))) + }) && ($writes || + [dest_offset, (dest_offset + size).saturating_sub(1)].into_iter().any(|offset| { + offset >= interpreter.memory.len() as u64 + }) + ); + + // If the failure condition is met, set the output buffer to a revert string + // that gives information about the allowed ranges and revert. + if fail_cond { + disallowed_mem_write(dest_offset, size, interpreter, ranges); + return InstructionResult::Revert + } + })* + _ => () + } + } + } + + // Check if the current opcode can write to memory, and if so, check if the memory + // being written to is registered as safe to modify. + mem_opcode_match!( + (CALLDATACOPY, 0, 2, true), + (CODECOPY, 0, 2, true), + (RETURNDATACOPY, 0, 2, true), + (EXTCODECOPY, 1, 3, true), + (CALL, 5, 6, true), + (CALLCODE, 5, 6, true), + (STATICCALL, 4, 5, true), + (DELEGATECALL, 4, 5, true), + (KECCAK256, 0, 1, false), + (LOG0, 0, 1, false), + (LOG1, 0, 1, false), + (LOG2, 0, 1, false), + (LOG3, 0, 1, false), + (LOG4, 0, 1, false), + (CREATE, 1, 2, false), + (CREATE2, 1, 2, false), + (RETURN, 0, 1, false), + (REVERT, 0, 1, false), + ) + } + + // Record writes with sstore (and sha3) if `StartMappingRecording` has been called + if let Some(mapping_slots) = &mut self.mapping_slots { + mapping::step(mapping_slots, interpreter); + } + + InstructionResult::Continue + } + + fn log(&mut self, _: &mut EVMData<'_, DB>, address: &Address, topics: &[B256], data: &Bytes) { + if !self.expected_emits.is_empty() { + expect::handle_expect_emit(self, address, topics, data); + } + + // Stores this log if `recordLogs` has been called + if let Some(storage_recorded_logs) = &mut self.recorded_logs { + storage_recorded_logs.push(Vm::Log { + topics: topics.to_vec(), + data: data.to_vec(), + emitter: *address, + }); + } + } + + fn call( + &mut self, + data: &mut EVMData<'_, DB>, + call: &mut CallInputs, + ) -> (InstructionResult, Gas, Bytes) { + let gas = Gas::new(call.gas_limit); + + if call.contract == CHEATCODE_ADDRESS { + return match self.apply_cheatcode(data, call) { + Ok(retdata) => (InstructionResult::Return, gas, retdata.into()), + Err(err) => (InstructionResult::Revert, gas, err.abi_encode().into()), + } + } + + if call.contract == HARDHAT_CONSOLE_ADDRESS { + return (InstructionResult::Continue, gas, Bytes::new()) + } + + // Handle expected calls + + // Grab the different calldatas expected. + if let Some(expected_calls_for_target) = self.expected_calls.get_mut(&(call.contract)) { + // Match every partial/full calldata + for (calldata, (expected, actual_count)) in expected_calls_for_target { + // Increment actual times seen if... + // The calldata is at most, as big as this call's input, and + if calldata.len() <= call.input.len() && + // Both calldata match, taking the length of the assumed smaller one (which will have at least the selector), and + *calldata == call.input[..calldata.len()] && + // The value matches, if provided + expected + .value + .map_or(true, |value| value == call.transfer.value) && + // The gas matches, if provided + expected.gas.map_or(true, |gas| gas == call.gas_limit) && + // The minimum gas matches, if provided + expected.min_gas.map_or(true, |min_gas| min_gas <= call.gas_limit) + { + *actual_count += 1; + } + } + } + + // Handle mocked calls + if let Some(mocks) = self.mocked_calls.get(&call.contract) { + let ctx = MockCallDataContext { + calldata: call.input.clone().0.into(), + value: Some(call.transfer.value), + }; + if let Some(mock_retdata) = mocks.get(&ctx) { + return (mock_retdata.ret_type, gas, Bytes(mock_retdata.data.clone().0)) + } else if let Some((_, mock_retdata)) = mocks.iter().find(|(mock, _)| { + mock.calldata.len() <= call.input.len() && + *mock.calldata == call.input[..mock.calldata.len()] && + mock.value.map_or(true, |value| value == call.transfer.value) + }) { + return (mock_retdata.ret_type, gas, Bytes(mock_retdata.data.0.clone())) + } + } + + // Apply our prank + if let Some(prank) = &self.prank { + if data.journaled_state.depth() >= prank.depth && + call.context.caller == prank.prank_caller + { + let mut prank_applied = false; + + // At the target depth we set `msg.sender` + if data.journaled_state.depth() == prank.depth { + call.context.caller = prank.new_caller; + call.transfer.source = prank.new_caller; + prank_applied = true; + } + + // At the target depth, or deeper, we set `tx.origin` + if let Some(new_origin) = prank.new_origin { + data.env.tx.caller = new_origin; + prank_applied = true; + } + + // If prank applied for first time, then update + if prank_applied { + if let Some(applied_prank) = prank.first_time_applied() { + self.prank = Some(applied_prank); + } + } + } + } + + // Apply our broadcast + if let Some(broadcast) = &self.broadcast { + // We only apply a broadcast *to a specific depth*. + // + // We do this because any subsequent contract calls *must* exist on chain and + // we only want to grab *this* call, not internal ones + if data.journaled_state.depth() == broadcast.depth && + call.context.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 + // broadcast.origin. + data.env.tx.caller = broadcast.new_origin; + + call.context.caller = broadcast.new_origin; + call.transfer.source = broadcast.new_origin; + // Add a `legacy` transaction to the VecDeque. We use a legacy transaction here + // because we only need the from, to, value, and data. We can later change this + // into 1559, in the cli package, relatively easily once we + // know the target chain supports EIP-1559. + #[allow(unused)] // TODO + if !call.is_static { + if let Err(err) = + data.journaled_state.load_account(broadcast.new_origin, data.db) + { + return (InstructionResult::Revert, gas, Error::encode(err)) + } + + let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); + + let account = + data.journaled_state.state().get_mut(&broadcast.new_origin).unwrap(); + + self.broadcastable_transactions.push_back(BroadcastableTransaction { + rpc: data.db.active_fork_url(), + transaction: TypedTransaction::Legacy(TransactionRequest { + from: Some(broadcast.new_origin.to_ethers()), + to: Some(NameOrAddress::Address(call.contract.to_ethers())), + value: Some(call.transfer.value).map(|v| v.to_ethers()), + data: Some(call.input.clone().0.into()), + nonce: Some(account.info.nonce.into()), + gas: if is_fixed_gas_limit { + Some(call.gas_limit.into()) + } else { + None + }, + ..Default::default() + }), + }); + + // call_inner does not increase nonces, so we have to do it ourselves + account.info.nonce += 1; + } else if broadcast.single_call { + let msg = "`staticcall`s are not allowed after `broadcast`; use vm.startBroadcast instead"; + return (InstructionResult::Revert, Gas::new(0), Error::encode(msg)) + } + } + } + + (InstructionResult::Continue, gas, Bytes::new()) + } + + fn call_end( + &mut self, + data: &mut EVMData<'_, DB>, + call: &CallInputs, + remaining_gas: Gas, + status: InstructionResult, + retdata: Bytes, + ) -> (InstructionResult, Gas, Bytes) { + if call.contract == CHEATCODE_ADDRESS || call.contract == HARDHAT_CONSOLE_ADDRESS { + return (status, remaining_gas, retdata) + } + + if data.journaled_state.depth() == 0 && self.skip { + return ( + InstructionResult::Revert, + remaining_gas, + super::Error::from(MAGIC_SKIP_BYTES).abi_encode().into(), + ) + } + + // Clean up pranks + if let Some(prank) = &self.prank { + if data.journaled_state.depth() == prank.depth { + data.env.tx.caller = prank.prank_origin; + + // Clean single-call prank once we have returned to the original depth + if prank.single_call { + let _ = self.prank.take(); + } + } + } + + // Clean up broadcast + if let Some(broadcast) = &self.broadcast { + if data.journaled_state.depth() == broadcast.depth { + data.env.tx.caller = broadcast.original_origin; + + // Clean single-call broadcast once we have returned to the original depth + if broadcast.single_call { + let _ = self.broadcast.take(); + } + } + } + + // Handle expected reverts + if let Some(expected_revert) = &self.expected_revert { + if data.journaled_state.depth() <= expected_revert.depth { + let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); + return match expect::handle_expect_revert( + false, + expected_revert.reason.as_ref(), + status, + retdata, + ) { + Err(error) => { + trace!(expected=?expected_revert, ?error, ?status, "Expected revert mismatch"); + (InstructionResult::Revert, remaining_gas, error.abi_encode().into()) + } + Ok((_, retdata)) => (InstructionResult::Return, remaining_gas, retdata), + } + } + } + + // At the end of the call, + // we need to check if we've found all the emits. + // We know we've found all the expected emits in the right order + // if the queue is fully matched. + // If it's not fully matched, then either: + // 1. Not enough events were emitted (we'll know this because the amount of times we + // inspected events will be less than the size of the queue) 2. The wrong events + // were emitted (The inspected events should match the size of the queue, but still some + // events will not be matched) + + // First, check that we're at the call depth where the emits were declared from. + let should_check_emits = self + .expected_emits + .iter() + .any(|expected| expected.depth == data.journaled_state.depth()) && + // Ignore staticcalls + !call.is_static; + if should_check_emits { + // Not all emits were matched. + if self.expected_emits.iter().any(|expected| !expected.found) { + return ( + InstructionResult::Revert, + remaining_gas, + "log != expected log".abi_encode().into(), + ) + } else { + // All emits were found, we're good. + // Clear the queue, as we expect the user to declare more events for the next call + // if they wanna match further events. + self.expected_emits.clear() + } + } + + // If the depth is 0, then this is the root call terminating + if data.journaled_state.depth() == 0 { + // Match expected calls + for (address, calldatas) in &self.expected_calls { + // Loop over each address, and for each address, loop over each calldata it expects. + for (calldata, (expected, actual_count)) in calldatas { + // Grab the values we expect to see + let ExpectedCallData { gas, min_gas, value, count, call_type } = expected; + + let failed = match call_type { + // If the cheatcode was called with a `count` argument, + // we must check that the EVM performed a CALL with this calldata exactly + // `count` times. + ExpectedCallType::Count => *count != *actual_count, + // If the cheatcode was called without a `count` argument, + // we must check that the EVM performed a CALL with this calldata at least + // `count` times. The amount of times to check was + // the amount of time the cheatcode was called. + ExpectedCallType::NonCount => *count > *actual_count, + }; + if failed { + let expected_values = [ + Some(format!("data {}", hex::encode_prefixed(calldata))), + value.as_ref().map(|v| format!("value {v}")), + gas.map(|g| format!("gas {g}")), + min_gas.map(|g| format!("minimum gas {g}")), + ] + .into_iter() + .flatten() + .join(", "); + let but = if status.is_ok() { + let s = if *actual_count == 1 { "" } else { "s" }; + format!("was called {actual_count} time{s}") + } else { + "the call reverted instead; \ + ensure you're testing the happy path when using `expectCall`" + .to_string() + }; + let s = if *count == 1 { "" } else { "s" }; + let msg = format!( + "Expected call to {address} with {expected_values} \ + to be called {count} time{s}, but {but}" + ); + return (InstructionResult::Revert, remaining_gas, Error::encode(msg)) + } + } + } + + // Check if we have any leftover expected emits + // First, if any emits were found at the root call, then we its ok and we remove them. + self.expected_emits.retain(|expected| !expected.found); + // If not empty, we got mismatched emits + if !self.expected_emits.is_empty() { + let msg = if status.is_ok() { + "expected an emit, but no logs were emitted afterwards. \ + you might have mismatched events or not enough events were emitted" + } else { + "expected an emit, but the call reverted instead. \ + ensure you're testing the happy path when using `expectEmit`" + }; + return (InstructionResult::Revert, remaining_gas, Error::encode(msg)) + } + } + + // if there's a revert and a previous call was diagnosed as fork related revert then we can + // return a better error here + if status == InstructionResult::Revert { + if let Some(err) = self.fork_revert_diagnostic.take() { + return (status, remaining_gas, Error::encode(err.to_error_msg(self))) + } + } + + // this will ensure we don't have false positives when trying to diagnose reverts in fork + // mode + let _ = self.fork_revert_diagnostic.take(); + + // try to diagnose reverts in multi-fork mode where a call is made to an address that does + // not exist + if let TransactTo::Call(test_contract) = data.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 data.db.is_forked_mode() && + status == InstructionResult::Stop && + call.contract != test_contract + { + self.fork_revert_diagnostic = + data.db.diagnose_revert(call.contract, &data.journaled_state); + } + } + + (status, remaining_gas, retdata) + } + + fn create( + &mut self, + data: &mut EVMData<'_, DB>, + call: &mut CreateInputs, + ) -> (InstructionResult, Option
, Gas, Bytes) { + let gas = Gas::new(call.gas_limit); + + // allow cheatcodes from the address of the new contract + self.allow_cheatcodes_on_create(data, call); + + // Apply our prank + if let Some(prank) = &self.prank { + if data.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { + // At the target depth we set `msg.sender` + if data.journaled_state.depth() == prank.depth { + call.caller = prank.new_caller; + } + + // At the target depth, or deeper, we set `tx.origin` + if let Some(new_origin) = prank.new_origin { + data.env.tx.caller = new_origin; + } + } + } + + // Apply our broadcast + if let Some(broadcast) = &self.broadcast { + if data.journaled_state.depth() >= broadcast.depth && + call.caller == broadcast.original_caller + { + if let Err(err) = data.journaled_state.load_account(broadcast.new_origin, data.db) { + return (InstructionResult::Revert, None, gas, Error::encode(err)) + } + + data.env.tx.caller = broadcast.new_origin; + + #[allow(unused)] // TODO + if data.journaled_state.depth() == broadcast.depth { + let (bytecode, to, nonce) = match process_create( + broadcast.new_origin, + call.init_code.clone(), + data, + call, + ) { + Ok(val) => val, + Err(err) => { + return (InstructionResult::Revert, None, gas, Error::encode(err)) + } + }; + + let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); + + self.broadcastable_transactions.push_back(BroadcastableTransaction { + rpc: data.db.active_fork_url(), + transaction: TypedTransaction::Legacy(TransactionRequest { + from: Some(broadcast.new_origin.to_ethers()), + to: to.map(|a| NameOrAddress::Address(a.to_ethers())), + value: Some(call.value.to_ethers()), + data: Some(bytecode.0.into()), + nonce: Some(nonce.into()), + gas: if is_fixed_gas_limit { + Some(call.gas_limit.into()) + } else { + None + }, + ..Default::default() + }), + }); + } + } + } + + (InstructionResult::Continue, None, gas, Bytes::new()) + } + + fn create_end( + &mut self, + data: &mut EVMData<'_, DB>, + _: &CreateInputs, + status: InstructionResult, + address: Option
, + remaining_gas: Gas, + retdata: Bytes, + ) -> (InstructionResult, Option
, Gas, Bytes) { + // Clean up pranks + if let Some(prank) = &self.prank { + if data.journaled_state.depth() == prank.depth { + data.env.tx.caller = prank.prank_origin; + + // Clean single-call prank once we have returned to the original depth + if prank.single_call { + std::mem::take(&mut self.prank); + } + } + } + + // Clean up broadcasts + if let Some(broadcast) = &self.broadcast { + if data.journaled_state.depth() == broadcast.depth { + data.env.tx.caller = broadcast.original_origin; + + // Clean single-call broadcast once we have returned to the original depth + if broadcast.single_call { + std::mem::take(&mut self.broadcast); + } + } + } + + // Handle expected reverts + if let Some(expected_revert) = &self.expected_revert { + if data.journaled_state.depth() <= expected_revert.depth { + let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); + return match expect::handle_expect_revert( + true, + expected_revert.reason.as_ref(), + status, + retdata, + ) { + Ok((address, retdata)) => { + (InstructionResult::Return, address, remaining_gas, retdata) + } + Err(err) => { + (InstructionResult::Revert, None, remaining_gas, err.abi_encode().into()) + } + } + } + } + + (status, address, remaining_gas, retdata) + } +} + +/// Helper that expands memory, stores a revert string pertaining to a disallowed memory write, +/// and sets the return range to the revert string's location in memory. +fn disallowed_mem_write( + dest_offset: u64, + size: u64, + interpreter: &mut Interpreter, + ranges: &[Range], +) { + let revert_string = format!( + "memory write at offset 0x{:02X} of size 0x{:02X} not allowed; safe range: {}", + dest_offset, + size, + ranges.iter().map(|r| format!("(0x{:02X}, 0x{:02X}]", r.start, r.end)).join(" ∪ ") + ) + .abi_encode() + .into(); + mstore_revert_string(revert_string, interpreter); +} + +/// Expands memory, stores a revert string, and sets the return range to the revert +/// string's location in memory. +fn mstore_revert_string(bytes: Bytes, interpreter: &mut Interpreter) { + let starting_offset = interpreter.memory.len(); + interpreter.memory.resize(starting_offset + bytes.len()); + interpreter.memory.set_data(starting_offset, 0, bytes.len(), &bytes); + interpreter.return_offset = starting_offset; + interpreter.return_len = interpreter.memory.len() - starting_offset +} + +fn process_create( + broadcast_sender: Address, + bytecode: Bytes, + data: &mut EVMData<'_, DB>, + call: &mut CreateInputs, +) -> Result<(Bytes, Option
, u64), DB::Error> { + match call.scheme { + CreateScheme::Create => { + call.caller = broadcast_sender; + + Ok((bytecode, None, data.journaled_state.account(broadcast_sender).info.nonce)) + } + CreateScheme::Create2 { salt } => { + // Sanity checks for our CREATE2 deployer + data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?; + + let info = &data.journaled_state.account(DEFAULT_CREATE2_DEPLOYER).info; + if info.code.is_none() || info.code.as_ref().is_some_and(|code| code.is_empty()) { + return Err(DB::Error::MissingCreate2Deployer) + } + + call.caller = DEFAULT_CREATE2_DEPLOYER; + + // We have to increment the nonce of the user address, since this create2 will be done + // by the create2_deployer + let account = data.journaled_state.state().get_mut(&broadcast_sender).unwrap(); + let nonce = account.info.nonce; + account.info.nonce += 1; + + // Proxy deployer requires the data to be `salt ++ init_code` + let calldata = [&salt.to_be_bytes::<32>()[..], &bytecode[..]].concat(); + Ok((calldata.into(), Some(DEFAULT_CREATE2_DEPLOYER), nonce)) + } + } +} + +// Determines if the gas limit on a given call was manually set in the script and should therefore +// not be overwritten by later estimations +fn check_if_fixed_gas_limit(data: &EVMData<'_, DB>, call_gas_limit: u64) -> bool { + // If the gas limit was not set in the source code it is set to the estimated gas left at the + // time of the call, which should be rather close to configured gas limit. + // TODO: Find a way to reliably make this determination. + // For example by generating it in the compilation or EVM simulation process + U256::from(data.env.tx.gas_limit) > data.env.block.gas_limit && + U256::from(call_gas_limit) <= data.env.block.gas_limit + // Transfers in forge scripts seem to be estimated at 2300 by revm leading to "Intrinsic + // gas too low" failure when simulated on chain + && call_gas_limit > 2300 +} + +fn get_create_address(inputs: &CreateInputs, nonce: u64) -> Address { + match inputs.scheme { + CreateScheme::Create => inputs.caller.create(nonce), + CreateScheme::Create2 { salt } => { + inputs.caller.create2_from_code(salt.to_be_bytes(), &inputs.init_code) + } + } +} diff --git a/crates/cheatcodes/src/impls/json.rs b/crates/cheatcodes/src/impls/json.rs new file mode 100644 index 0000000000000..8e4510515ca90 --- /dev/null +++ b/crates/cheatcodes/src/impls/json.rs @@ -0,0 +1,505 @@ +//! Implementations of [`Json`](crate::Group::Json) cheatcodes. + +use super::{string, Cheatcode, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{Address, Bytes, B256, I256, U256}; +use alloy_sol_types::SolValue; +use foundry_common::fs; +use foundry_config::fs_permissions::FsAccessKind; +use serde_json::Value; +use std::{borrow::Cow, collections::BTreeMap, fmt::Write}; + +impl Cheatcode for keyExistsCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + let json = parse_json_str(json)?; + let values = select(&json, key)?; + let exists = !values.is_empty(); + Ok(exists.abi_encode()) + } +} + +impl Cheatcode for parseJson_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json } = self; + parse_json(json, "$") + } +} + +impl Cheatcode for parseJson_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json(json, key) + } +} + +impl Cheatcode for parseJsonUintCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonUintArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonIntCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonIntArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonBoolCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonBoolArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonAddressCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::
(json, key) + } +} + +impl Cheatcode for parseJsonAddressArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::
(json, key) + } +} + +impl Cheatcode for parseJsonStringCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonStringArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonBytesCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonBytesArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonBytes32Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonBytes32ArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + parse_json_coerce::(json, key) + } +} + +impl Cheatcode for parseJsonKeysCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + let json = parse_json_str(json)?; + let values = select(&json, key)?; + let [value] = values[..] else { + bail!("key {key:?} must return exactly one JSON object"); + }; + let Value::Object(object) = value else { + bail!("JSON value at {key:?} is not an object"); + }; + let keys = object.keys().collect::>(); + Ok(keys.abi_encode()) + } +} + +impl Cheatcode for serializeJsonCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, value } = self; + serialize_json(state, objectKey, None, value) + } +} + +impl Cheatcode for serializeBool_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + } +} + +impl Cheatcode for serializeUint_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + } +} + +impl Cheatcode for serializeInt_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + } +} + +impl Cheatcode for serializeAddress_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + } +} + +impl Cheatcode for serializeBytes32_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + } +} + +impl Cheatcode for serializeString_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + } +} + +impl Cheatcode for serializeBytes_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + serialize_json(state, objectKey, Some(valueKey), &hex::encode_prefixed(value)) + } +} + +impl Cheatcode for serializeBool_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, values } = self; + serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + } +} + +impl Cheatcode for serializeUint_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, values } = self; + serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + } +} + +impl Cheatcode for serializeInt_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, values } = self; + serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + } +} + +impl Cheatcode for serializeAddress_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, values } = self; + serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + } +} + +impl Cheatcode for serializeBytes32_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, values } = self; + serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + } +} + +impl Cheatcode for serializeString_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, values } = self; + serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + } +} + +impl Cheatcode for serializeBytes_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, values } = self; + let values = values.iter().map(hex::encode_prefixed); + serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + } +} + +impl Cheatcode for writeJson_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { json, path } = self; + let json = serde_json::from_str(json).unwrap_or_else(|_| Value::String(json.to_owned())); + let json_string = serde_json::to_string_pretty(&json)?; + super::fs::write_file(state, path.as_ref(), json_string.as_bytes()) + } +} + +impl Cheatcode for writeJson_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { json, path, valueKey } = self; + let json = serde_json::from_str(json).unwrap_or_else(|_| Value::String(json.to_owned())); + + let data_path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + let data_s = fs::read_to_string(data_path)?; + let data = serde_json::from_str(&data_s)?; + let value = + jsonpath_lib::replace_with(data, &canonicalize_json_path(valueKey), &mut |_| { + Some(json.clone()) + })?; + + let json_string = serde_json::to_string_pretty(&value)?; + super::fs::write_file(state, path.as_ref(), json_string.as_bytes()) + } +} + +fn parse_json(json: &str, path: &str) -> Result { + parse_json_inner(json, path, None::) -> Result>) +} + +fn parse_json_coerce(json: &str, path: &str) -> Result +where + T: SolValue + std::str::FromStr, + T::Err: std::fmt::Display, +{ + parse_json_inner( + json, + path, + Some(|values: Vec<&Value>| { + ensure!(!values.is_empty(), "no matching value found at {path:?}"); + + ensure!( + values.iter().all(|value| !value.is_object()), + "values at {path:?} must not be JSON objects" + ); + + let to_string = |v: &Value| { + let mut s = v.to_string(); + s.retain(|c: char| c != '"'); + s + }; + if let Some(array) = values[0].as_array() { + string::parse_array::<_, _, T>(array.iter().map(to_string)) + } else { + string::parse::(&to_string(values[0])) + } + }), + ) +} + +fn parse_json_inner(json: &str, key: &str, coerce: Option) -> Result +where + F: FnOnce(Vec<&Value>) -> Result, +{ + let value = parse_json_str(json)?; + let selected = select(&value, key)?; + + // don't coerce when selecting the root value + if !matches!(key, "$" | ".") { + if let Some(coerce) = coerce { + return coerce(selected) + } + } + + let sol = json_to_sol(&selected)?; + Ok(encode(sol)) +} + +fn parse_json_str(json: &str) -> Result { + serde_json::from_str(json).map_err(|e| fmt_err!("failed parsing JSON: {e}")) +} + +fn json_to_sol(json: &[&Value]) -> Result> { + let mut sol = Vec::with_capacity(json.len()); + for value in json { + sol.push(value_to_token(value)?); + } + Ok(sol) +} + +fn select<'a>(value: &'a Value, mut path: &str) -> Result> { + // Handle the special case of the root key + if path == "." { + path = "$"; + } + jsonpath_lib::select(value, &canonicalize_json_path(path)) + .map_err(|e| fmt_err!("failed selecting from JSON: {:?}", e.to_string())) +} + +fn encode(values: Vec) -> Vec { + // Double `abi_encode` is intentional + let bytes = match &values[..] { + [] => Vec::new(), + [one] => one.abi_encode(), + _ => DynSolValue::Array(values).abi_encode(), + }; + bytes.abi_encode() +} + +/// Canonicalize a json path key to always start from the root of the document. +/// Read more about json path syntax: +fn canonicalize_json_path(path: &str) -> Cow<'_, str> { + if !path.starts_with('$') { + format!("${path}").into() + } else { + path.into() + } +} + +/// Converts a JSON [`Value`] to a [`DynSolValue`]. +/// +/// The function is designed to run recursively, so that in case of an object +/// it will call itself to convert each of it's value and encode the whole as a +/// Tuple +fn value_to_token(value: &Value) -> Result { + match value { + Value::Null => Ok(DynSolValue::FixedBytes(B256::ZERO, 32)), + Value::Bool(boolean) => Ok(DynSolValue::Bool(*boolean)), + Value::Array(array) => { + array.iter().map(value_to_token).collect::>().map(DynSolValue::Array) + } + value @ Value::Object(_) => { + // See: [#3647](https://github.com/foundry-rs/foundry/pull/3647) + let ordered_object: BTreeMap = + serde_json::from_value(value.clone()).unwrap(); + ordered_object + .values() + .map(value_to_token) + .collect::>() + .map(DynSolValue::Tuple) + } + Value::Number(number) => { + if let Some(f) = number.as_f64() { + // Check if the number has decimal digits because the EVM does not support floating + // point math + if f.fract() == 0.0 { + // Use the string representation of the `serde_json` Number type instead of + // calling f.to_string(), because some numbers are wrongly rounded up after + // being convented to f64. + // Example: 18446744073709551615 becomes 18446744073709552000 after parsing it + // to f64. + let s = number.to_string(); + + // Coerced to scientific notation, so short-ciruit to using fallback. + // This will not have a problem with hex numbers, as for parsing these + // We'd need to prefix this with 0x. + // See also + if s.contains('e') { + // Calling Number::to_string with powers of ten formats the number using + // scientific notation and causes from_dec_str to fail. Using format! with + // f64 keeps the full number representation. + // Example: 100000000000000000000 becomes 1e20 when Number::to_string is + // used. + let fallback_s = f.to_string(); + if let Ok(n) = fallback_s.parse() { + return Ok(DynSolValue::Uint(n, 256)) + } + if let Ok(n) = I256::from_dec_str(&fallback_s) { + return Ok(DynSolValue::Int(n, 256)) + } + } + + if let Ok(n) = s.parse() { + return Ok(DynSolValue::Uint(n, 256)) + } + if let Ok(n) = s.parse() { + return Ok(DynSolValue::Int(n, 256)) + } + } + } + + Err(fmt_err!("unsupported JSON number: {number}")) + } + Value::String(string) => { + if let Some(mut val) = string.strip_prefix("0x") { + let s; + if val.len() % 2 != 0 { + s = format!("0{}", val); + val = &s[..]; + } + let bytes = hex::decode(val)?; + Ok(match bytes.len() { + 20 => DynSolValue::Address(Address::from_slice(&bytes)), + 32 => DynSolValue::FixedBytes(B256::from_slice(&bytes), 32), + _ => DynSolValue::Bytes(bytes), + }) + } else { + Ok(DynSolValue::String(string.to_owned())) + } + } + } +} + +/// Serializes a key:value pair to a specific object. If the key is Some(valueKey), the value is +/// expected to be an object, which will be set as the root object for the provided object key, +/// overriding the whole root object if the object key already exists. By calling this function +/// multiple times, the user can serialize multiple KV pairs to the same object. The value can be of +/// any type, even a new object in itself. The function will return a stringified version of the +/// object, so that the user can use that as a value to a new invocation of the same function with a +/// new object key. This enables the user to reuse the same function to crate arbitrarily complex +/// object structures (JSON). +fn serialize_json( + state: &mut Cheatcodes, + object_key: &str, + value_key: Option<&str>, + value: &str, +) -> Result { + let map = state.serialized_jsons.entry(object_key.into()).or_default(); + if let Some(value_key) = value_key { + let parsed_value = + serde_json::from_str(value).unwrap_or_else(|_| Value::String(value.into())); + map.insert(value_key.into(), parsed_value); + } else { + *map = serde_json::from_str(value) + .map_err(|err| fmt_err!("Failed to parse JSON object: {err}"))?; + } + let stringified = serde_json::to_string(map).unwrap(); + Ok(stringified.abi_encode()) +} + +fn array_str(values: I) -> String +where + I: IntoIterator, + I::IntoIter: ExactSizeIterator, + T: std::fmt::Display, +{ + let iter = values.into_iter(); + let mut s = String::with_capacity(2 + iter.len() * 32); + s.push('['); + for (i, item) in iter.enumerate() { + if i > 0 { + s.push(','); + } + write!(s, "{item}").unwrap(); + } + s.push(']'); + s +} diff --git a/crates/cheatcodes/src/impls/mod.rs b/crates/cheatcodes/src/impls/mod.rs new file mode 100644 index 0000000000000..2668b3803944a --- /dev/null +++ b/crates/cheatcodes/src/impls/mod.rs @@ -0,0 +1,71 @@ +//! Cheatcode implementations. + +use crate::CheatcodeDef; +use alloy_primitives::Address; +use revm::EVMData; + +#[macro_use] +mod error; +pub use error::{Error, ErrorKind, Result}; + +mod db; +pub use db::{ + CreateFork, DatabaseError, DatabaseExt, DatabaseResult, LocalForkId, RevertDiagnostic, +}; + +mod config; +pub use config::CheatsConfig; + +mod inspector; +pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; + +mod env; +mod evm; +mod fs; +mod json; +mod script; +mod string; +mod test; +mod utils; + +pub use test::{expect::ExpectedCallTracker, ASSUME_MAGIC_RETURN_CODE, MAGIC_SKIP_BYTES}; + +/// Cheatcode implementation. +pub(crate) trait Cheatcode: CheatcodeDef { + /// Applies this cheatcode to the given state. + /// + /// Implement this function if you don't need access to the EVM data. + fn apply(&self, state: &mut Cheatcodes) -> Result { + let _ = state; + unimplemented!("{}", Self::CHEATCODE.id) + } + + /// Applies this cheatcode to the given context. + /// + /// Implement this function if you need access to the EVM data. + #[inline(always)] + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + self.apply(ccx.state) + } + + #[instrument(target = "cheatcodes", name = "apply", level = "trace", skip(ccx), ret)] + #[inline] + fn apply_traced(&self, ccx: &mut CheatsCtxt) -> Result { + debug!("applying {}", Self::CHEATCODE.id); + self.apply_full(ccx) + } +} + +/// The cheatcode context, used in [`Cheatcode`]. +pub(crate) struct CheatsCtxt<'a, 'b, 'c, DB: DatabaseExt> { + pub(crate) state: &'a mut Cheatcodes, + pub(crate) data: &'b mut EVMData<'c, DB>, + pub(crate) caller: Address, +} + +impl CheatsCtxt<'_, '_, '_, DB> { + #[inline] + pub(crate) fn is_precompile(&self, address: &Address) -> bool { + self.data.precompiles.contains(address) + } +} diff --git a/crates/cheatcodes/src/impls/script.rs b/crates/cheatcodes/src/impls/script.rs new file mode 100644 index 0000000000000..4b533d85e091e --- /dev/null +++ b/crates/cheatcodes/src/impls/script.rs @@ -0,0 +1,127 @@ +//! Implementations of [`Scripting`](crate::Group::Scripting) cheatcodes. + +use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use crate::Vm::*; +use alloy_primitives::{Address, U256}; +use ethers::signers::Signer; +use foundry_config::Config; + +impl Cheatcode for broadcast_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + broadcast(ccx, None, true) + } +} + +impl Cheatcode for broadcast_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { signer } = self; + broadcast(ccx, Some(signer), true) + } +} + +impl Cheatcode for broadcast_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { privateKey } = self; + broadcast_key(ccx, privateKey, true) + } +} + +impl Cheatcode for startBroadcast_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + broadcast(ccx, None, false) + } +} + +impl Cheatcode for startBroadcast_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { signer } = self; + broadcast(ccx, Some(signer), false) + } +} + +impl Cheatcode for startBroadcast_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { privateKey } = self; + broadcast_key(ccx, privateKey, false) + } +} + +impl Cheatcode for stopBroadcastCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + ensure!(ccx.state.broadcast.is_some(), "no broadcast in progress to stop"); + ccx.state.broadcast = None; + Ok(Default::default()) + } +} + +#[derive(Clone, Debug, Default)] +pub struct Broadcast { + /// Address of the transaction origin + pub new_origin: Address, + /// Original caller + pub original_caller: Address, + /// Original `tx.origin` + pub original_origin: Address, + /// Depth of the broadcast + pub depth: u64, + /// Whether the prank stops by itself after the next call + pub single_call: bool, +} + +/// Sets up broadcasting from a script using `new_origin` as the sender. +fn broadcast( + ccx: &mut CheatsCtxt, + new_origin: Option<&Address>, + single_call: bool, +) -> Result { + ensure!( + ccx.state.prank.is_none(), + "you have an active prank; broadcasting and pranks are not compatible" + ); + ensure!(ccx.state.broadcast.is_none(), "a broadcast is active already"); + + correct_sender_nonce(ccx)?; + + ccx.state.broadcast = Some(Broadcast { + new_origin: *new_origin.unwrap_or(&ccx.data.env.tx.caller), + original_origin: ccx.caller, + original_caller: ccx.data.env.tx.caller, + depth: ccx.data.journaled_state.depth(), + single_call, + }); + Ok(Default::default()) +} + +/// Sets up broadcasting from a script with the sender derived from `private_key`. +/// Adds this private key to `state`'s `script_wallets` vector to later be used for signing +/// if broadcast is successful. +fn broadcast_key( + ccx: &mut CheatsCtxt, + private_key: &U256, + single_call: bool, +) -> Result { + let wallet = super::utils::parse_wallet(private_key)?.with_chain_id(ccx.data.env.cfg.chain_id); + let new_origin = &wallet.address().0.into(); + + let result = broadcast(ccx, Some(new_origin), single_call); + if result.is_ok() { + ccx.state.script_wallets.push(wallet); + } + result +} + +/// When using `forge script`, the script method is called using the address from `--sender`. +/// That leads to its nonce being incremented by `call_raw`. In a `broadcast` scenario this is +/// undesirable. Therefore, we make sure to fix the sender's nonce **once**. +pub(super) fn correct_sender_nonce(ccx: &mut CheatsCtxt) -> Result<()> { + let caller = ccx.data.env.tx.caller; + if !ccx.state.corrected_nonce && caller.0 != Config::DEFAULT_SENDER.0 { + let account = super::evm::journaled_account(ccx.data, caller)?; + account.info.nonce = account.info.nonce.saturating_sub(1); + ccx.state.corrected_nonce = true; + } + Ok(()) +} diff --git a/crates/cheatcodes/src/impls/string.rs b/crates/cheatcodes/src/impls/string.rs new file mode 100644 index 0000000000000..43fc2b9f04461 --- /dev/null +++ b/crates/cheatcodes/src/impls/string.rs @@ -0,0 +1,133 @@ +//! Implementations of [`String`](crate::Group::String) cheatcodes. + +use super::{Cheatcode, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_primitives::{Address, Bytes, B256, I256, U256}; +use alloy_sol_types::{SolType, SolValue}; + +// address +impl Cheatcode for toString_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { value } = self; + Ok(value.to_string().abi_encode()) + } +} + +// bytes +impl Cheatcode for toString_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { value } = self; + Ok(hex::encode_prefixed(value).abi_encode()) + } +} + +// bytes32 +impl Cheatcode for toString_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { value } = self; + Ok(value.to_string().abi_encode()) + } +} + +// bool +impl Cheatcode for toString_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { value } = self; + Ok(value.to_string().abi_encode()) + } +} + +// uint256 +impl Cheatcode for toString_4Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { value } = self; + Ok(value.to_string().abi_encode()) + } +} + +// int256 +impl Cheatcode for toString_5Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { value } = self; + Ok(value.to_string().abi_encode()) + } +} + +impl Cheatcode for parseBytesCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { stringifiedValue } = self; + parse::(stringifiedValue) + } +} + +impl Cheatcode for parseAddressCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { stringifiedValue } = self; + parse::
(stringifiedValue) + } +} + +impl Cheatcode for parseUintCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { stringifiedValue } = self; + parse::(stringifiedValue) + } +} + +impl Cheatcode for parseIntCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { stringifiedValue } = self; + parse::(stringifiedValue) + } +} + +impl Cheatcode for parseBytes32Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { stringifiedValue } = self; + parse::(stringifiedValue) + } +} + +impl Cheatcode for parseBoolCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { stringifiedValue } = self; + parse::(stringifiedValue) + } +} + +pub(super) fn parse(s: &str) -> Result +where + T: SolValue + std::str::FromStr, + T::Err: std::fmt::Display, +{ + parse_t::(s).map(|v| v.abi_encode()) +} + +pub(super) fn parse_array(values: I) -> Result +where + I: IntoIterator, + S: AsRef, + T: SolValue + std::str::FromStr, + T::Err: std::fmt::Display, +{ + let mut values = values.into_iter(); + match values.next() { + Some(first) if !first.as_ref().is_empty() => std::iter::once(first) + .chain(values) + .map(|s| parse_t::(s.as_ref())) + .collect::, _>>() + .map(|vec| vec.abi_encode()), + // return the empty encoded Bytes when values is empty or the first element is empty + _ => Ok("".abi_encode()), + } +} + +fn parse_t(s: &str) -> Result +where + T: SolValue + std::str::FromStr, + T::Err: std::fmt::Display, +{ + s.parse::().map_err(|e| { + fmt_err!("failed parsing {s:?} as type `{}`: {e}", T::SolType::sol_type_name()) + }) +} diff --git a/crates/cheatcodes/src/impls/test.rs b/crates/cheatcodes/src/impls/test.rs new file mode 100644 index 0000000000000..ebe2e2f56355d --- /dev/null +++ b/crates/cheatcodes/src/impls/test.rs @@ -0,0 +1,102 @@ +//! Implementations of [`Testing`](crate::Group::Testing) cheatcodes. + +use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_primitives::Address; +use alloy_sol_types::SolValue; +use foundry_utils::types::ToEthers; + +pub(crate) mod expect; + +/// Magic return value returned by the [`assume` cheatcode](assumeCall). +pub const ASSUME_MAGIC_RETURN_CODE: &[u8] = b"FOUNDRY::ASSUME"; + +/// Magic return value returned by the [`skip` cheatcode](skipCall). +pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; + +impl Cheatcode for assumeCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { condition } = self; + if *condition { + Ok(Default::default()) + } else { + Err(ASSUME_MAGIC_RETURN_CODE.into()) + } + } +} + +impl Cheatcode for breakpoint_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { char } = self; + breakpoint(ccx.state, &ccx.caller, char, true) + } +} + +impl Cheatcode for breakpoint_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { char, value } = self; + breakpoint(ccx.state, &ccx.caller, char, *value) + } +} + +impl Cheatcode for rpcUrlCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { rpcAlias } = self; + state.config.rpc_url(rpcAlias).map(|url| url.abi_encode()) + } +} + +impl Cheatcode for rpcUrlsCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.config.rpc_urls().map(|urls| urls.abi_encode()) + } +} + +impl Cheatcode for rpcUrlStructsCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.config.rpc_urls().map(|urls| urls.abi_encode()) + } +} + +impl Cheatcode for sleepCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { duration } = self; + let sleep_duration = std::time::Duration::from_millis(duration.saturating_to()); + std::thread::sleep(sleep_duration); + Ok(Default::default()) + } +} + +impl Cheatcode for skipCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { skipTest } = *self; + if skipTest { + // Skip should not work if called deeper than at test level. + // Since we're not returning the magic skip bytes, this will cause a test failure. + ensure!(ccx.data.journaled_state.depth() <= 1, "`skip` can only be used at test level"); + ccx.state.skip = true; + Err(MAGIC_SKIP_BYTES.into()) + } else { + Ok(Default::default()) + } + } +} + +/// Adds or removes the given breakpoint to the state. +fn breakpoint(state: &mut Cheatcodes, caller: &Address, s: &str, add: bool) -> Result { + let mut chars = s.chars(); + let (Some(point), None) = (chars.next(), chars.next()) else { + bail!("breakpoints must be exactly one character"); + }; + ensure!(point.is_alphabetic(), "only alphabetic characters are accepted as breakpoints"); + + if add { + state.breakpoints.insert(point, (caller.to_ethers(), state.pc)); + } else { + state.breakpoints.remove(&point); + } + + Ok(Default::default()) +} diff --git a/crates/cheatcodes/src/impls/test/expect.rs b/crates/cheatcodes/src/impls/test/expect.rs new file mode 100644 index 0000000000000..1551440f5ec0e --- /dev/null +++ b/crates/cheatcodes/src/impls/test/expect.rs @@ -0,0 +1,510 @@ +use super::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result}; +use crate::Vm::*; +use alloy_dyn_abi::DynSolType; +use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; +use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; +use revm::interpreter::{return_ok, InstructionResult}; +use std::collections::{hash_map::Entry, HashMap}; + +/// For some cheatcodes we may internally change the status of the call, i.e. in `expectRevert`. +/// Solidity will see a successful call and attempt to decode the return data. Therefore, we need +/// to populate the return with dummy bytes so the decode doesn't fail. +/// +/// 8192 bytes was arbitrarily chosen because it is long enough for return values up to 256 words in +/// size. +static DUMMY_CALL_OUTPUT: Bytes = Bytes::from_static(&[0u8; 8192]); + +/// Same reasoning as [DUMMY_CALL_OUTPUT], but for creates. +static DUMMY_CREATE_ADDRESS: Address = + Address::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); + +/// Tracks the expected calls per address. +/// +/// For each address, we track the expected calls per call data. We track it in such manner +/// so that we don't mix together calldatas that only contain selectors and calldatas that contain +/// selector and arguments (partial and full matches). +/// +/// This then allows us to customize the matching behavior for each call data on the +/// `ExpectedCallData` struct and track how many times we've actually seen the call on the second +/// element of the tuple. +pub type ExpectedCallTracker = HashMap, (ExpectedCallData, u64)>>; + +#[derive(Clone, Debug)] +pub struct ExpectedCallData { + /// The expected value sent in the call + pub value: Option, + /// The expected gas supplied to the call + pub gas: Option, + /// The expected *minimum* gas supplied to the call + pub min_gas: Option, + /// The number of times the call is expected to be made. + /// If the type of call is `NonCount`, this is the lower bound for the number of calls + /// that must be seen. + /// If the type of call is `Count`, this is the exact number of calls that must be seen. + pub count: u64, + /// The type of expected call. + pub call_type: ExpectedCallType, +} + +/// The type of expected call. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ExpectedCallType { + /// The call is expected to be made at least once. + NonCount, + /// The exact number of calls expected. + Count, +} + +#[derive(Clone, Debug, Default)] +pub struct ExpectedRevert { + /// The expected data returned by the revert, None being any + pub reason: Option, + /// The depth at which the revert is expected + pub depth: u64, +} + +#[derive(Clone, Debug)] +pub struct ExpectedEmit { + /// The depth at which we expect this emit to have occurred + pub depth: u64, + /// The log we expect + pub log: Option, + /// The checks to perform: + /// ```text + /// ┌───────┬───────┬───────┬────┐ + /// │topic 1│topic 2│topic 3│data│ + /// └───────┴───────┴───────┴────┘ + /// ``` + pub checks: [bool; 4], + /// If present, check originating address against this + pub address: Option
, + /// Whether the log was actually found in the subcalls + pub found: bool, +} + +impl Cheatcode for expectCall_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, data } = self; + expect_call(state, callee, data, None, None, None, 1, ExpectedCallType::NonCount) + } +} + +impl Cheatcode for expectCall_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, data, count } = self; + expect_call(state, callee, data, None, None, None, *count, ExpectedCallType::Count) + } +} + +impl Cheatcode for expectCall_2Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, msgValue, data } = self; + expect_call(state, callee, data, Some(msgValue), None, None, 1, ExpectedCallType::NonCount) + } +} + +impl Cheatcode for expectCall_3Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, msgValue, data, count } = self; + expect_call( + state, + callee, + data, + Some(msgValue), + None, + None, + *count, + ExpectedCallType::Count, + ) + } +} + +impl Cheatcode for expectCall_4Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, msgValue, gas, data } = self; + expect_call( + state, + callee, + data, + Some(msgValue), + Some(*gas), + None, + 1, + ExpectedCallType::NonCount, + ) + } +} + +impl Cheatcode for expectCall_5Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, msgValue, gas, data, count } = self; + expect_call( + state, + callee, + data, + Some(msgValue), + Some(*gas), + None, + *count, + ExpectedCallType::Count, + ) + } +} + +impl Cheatcode for expectCallMinGas_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, msgValue, minGas, data } = self; + expect_call( + state, + callee, + data, + Some(msgValue), + None, + Some(*minGas), + 1, + ExpectedCallType::NonCount, + ) + } +} + +impl Cheatcode for expectCallMinGas_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, msgValue, minGas, data, count } = self; + expect_call( + state, + callee, + data, + Some(msgValue), + None, + Some(*minGas), + *count, + ExpectedCallType::Count, + ) + } +} + +impl Cheatcode for expectEmit_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { checkTopic1, checkTopic2, checkTopic3, checkData } = *self; + expect_emit( + ccx.state, + ccx.data.journaled_state.depth(), + [checkTopic1, checkTopic2, checkTopic3, checkData], + None, + ) + } +} + +impl Cheatcode for expectEmit_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { checkTopic1, checkTopic2, checkTopic3, checkData, emitter } = *self; + expect_emit( + ccx.state, + ccx.data.journaled_state.depth(), + [checkTopic1, checkTopic2, checkTopic3, checkData], + Some(emitter), + ) + } +} + +impl Cheatcode for expectEmit_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + expect_emit(ccx.state, ccx.data.journaled_state.depth(), [true; 4], None) + } +} + +impl Cheatcode for expectEmit_3Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { emitter } = *self; + expect_emit(ccx.state, ccx.data.journaled_state.depth(), [true; 4], Some(emitter)) + } +} + +impl Cheatcode for expectRevert_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + expect_revert(ccx.state, None, ccx.data.journaled_state.depth()) + } +} + +impl Cheatcode for expectRevert_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData } = self; + expect_revert(ccx.state, Some(revertData.as_ref()), ccx.data.journaled_state.depth()) + } +} + +impl Cheatcode for expectRevert_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData } = self; + expect_revert(ccx.state, Some(revertData), ccx.data.journaled_state.depth()) + } +} + +impl Cheatcode for expectSafeMemoryCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { min, max } = *self; + expect_safe_memory(ccx.state, min, max, ccx.data.journaled_state.depth()) + } +} + +impl Cheatcode for expectSafeMemoryCallCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { min, max } = *self; + expect_safe_memory(ccx.state, min, max, ccx.data.journaled_state.depth() + 1) + } +} + +/// Handles expected calls specified by the `expectCall` cheatcodes. +/// +/// It can handle calls in two ways: +/// - If the cheatcode was used with a `count` argument, it will expect the call to be made exactly +/// `count` times. +/// e.g. `vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f), 4)` will expect the +/// call to address(0xc4f3) with selector `0xd34db33f` to be made exactly 4 times. If the amount of +/// calls is less or more than 4, the test will fail. Note that the `count` argument cannot be +/// overwritten with another `vm.expectCall`. If this is attempted, `expectCall` will revert. +/// - If the cheatcode was used without a `count` argument, it will expect the call to be made at +/// least the amount of times the cheatcode +/// was called. This means that `vm.expectCall` without a count argument can be called many times, +/// but cannot be called with a `count` argument after it was called without one. If the latter +/// happens, `expectCall` will revert. e.g `vm.expectCall(address(0xc4f3), +/// abi.encodeWithSelector(0xd34db33f))` will expect the call to address(0xc4f3) and selector +/// `0xd34db33f` to be made at least once. If the amount of calls is 0, the test will fail. If the +/// call is made more than once, the test will pass. +#[allow(clippy::too_many_arguments)] // It is what it is +fn expect_call( + state: &mut Cheatcodes, + target: &Address, + calldata: &Vec, + value: Option<&U256>, + mut gas: Option, + mut min_gas: Option, + count: u64, + call_type: ExpectedCallType, +) -> Result { + let expecteds = state.expected_calls.entry(*target).or_default(); + + if let Some(val) = value { + if *val >= U256::ZERO { + // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas + // to ensure that the basic fallback function can be called. + let positive_value_cost_stipend = 2300; + if let Some(gas) = &mut gas { + *gas += positive_value_cost_stipend; + } + if let Some(min_gas) = &mut min_gas { + *min_gas += positive_value_cost_stipend; + } + } + } + + match call_type { + ExpectedCallType::Count => { + // Get the expected calls for this target. + // In this case, as we're using counted expectCalls, we should not be able to set them + // more than once. + ensure!( + !expecteds.contains_key(calldata), + "counted expected calls can only bet set once" + ); + expecteds.insert( + calldata.to_vec(), + (ExpectedCallData { value: value.copied(), gas, min_gas, count, call_type }, 0), + ); + } + ExpectedCallType::NonCount => { + // Check if the expected calldata exists. + // If it does, increment the count by one as we expect to see it one more time. + match expecteds.entry(calldata.clone()) { + Entry::Occupied(mut entry) => { + let (expected, _) = entry.get_mut(); + // Ensure we're not overwriting a counted expectCall. + ensure!( + expected.call_type == ExpectedCallType::NonCount, + "cannot overwrite a counted expectCall with a non-counted expectCall" + ); + expected.count += 1; + } + // If it does not exist, then create it. + Entry::Vacant(entry) => { + entry.insert(( + ExpectedCallData { value: value.copied(), gas, min_gas, count, call_type }, + 0, + )); + } + } + } + } + + Ok(Default::default()) +} + +fn expect_emit( + state: &mut Cheatcodes, + depth: u64, + checks: [bool; 4], + address: Option
, +) -> Result { + state.expected_emits.push_back(ExpectedEmit { + depth, + checks, + address, + found: false, + log: None, + }); + Ok(Default::default()) +} + +pub(crate) fn handle_expect_emit( + state: &mut Cheatcodes, + address: &Address, + topics: &[B256], + data: &Bytes, +) { + // Fill or check the expected emits. + // We expect for emit checks to be filled as they're declared (from oldest to newest), + // so we fill them and push them to the back of the queue. + // If the user has properly filled all the emits, they'll end up in their original order. + // If not, the queue will not be in the order the events will be intended to be filled, + // and we'll be able to later detect this and bail. + + // First, we can return early if all events have been matched. + // This allows a contract to arbitrarily emit more events than expected (additive behavior), + // as long as all the previous events were matched in the order they were expected to be. + if state.expected_emits.iter().all(|expected| expected.found) { + return + } + + // if there's anything to fill, we need to pop back. + // Otherwise, if there are any events that are unmatched, we try to match to match them + // in the order declared, so we start popping from the front (like a queue). + let mut event_to_fill_or_check = + if state.expected_emits.iter().any(|expected| expected.log.is_none()) { + state.expected_emits.pop_back() + } else { + state.expected_emits.pop_front() + } + .expect("we should have an emit to fill or check"); + + let Some(expected) = &event_to_fill_or_check.log else { + // Fill the event. + event_to_fill_or_check.log = Some(RawLog::new_unchecked(topics.to_vec(), data.clone())); + state.expected_emits.push_back(event_to_fill_or_check); + return + }; + + let expected_topic_0 = expected.topics().get(0); + let log_topic_0 = topics.get(0); + + if expected_topic_0 + .zip(log_topic_0) + .map_or(false, |(a, b)| a == b && expected.topics().len() == topics.len()) + { + // Match topics + event_to_fill_or_check.found = topics + .iter() + .skip(1) + .enumerate() + .filter(|(i, _)| event_to_fill_or_check.checks[*i]) + .all(|(i, topic)| topic == &expected.topics()[i + 1]); + + // Maybe match source address + if let Some(addr) = event_to_fill_or_check.address { + event_to_fill_or_check.found &= addr == *address; + } + + // Maybe match data + if event_to_fill_or_check.checks[3] { + event_to_fill_or_check.found &= expected.data == *data; + } + } + + // If we found the event, we can push it to the back of the queue + // and begin expecting the next event. + if event_to_fill_or_check.found { + state.expected_emits.push_back(event_to_fill_or_check); + } else { + // We did not match this event, so we need to keep waiting for the right one to + // appear. + state.expected_emits.push_front(event_to_fill_or_check); + } +} + +fn expect_revert(state: &mut Cheatcodes, reason: Option<&[u8]>, depth: u64) -> Result { + ensure!( + state.expected_revert.is_none(), + "you must call another function prior to expecting a second revert" + ); + state.expected_revert = + Some(ExpectedRevert { reason: reason.map(Bytes::copy_from_slice), depth }); + Ok(Default::default()) +} + +pub(crate) fn handle_expect_revert( + is_create: bool, + expected_revert: Option<&Bytes>, + status: InstructionResult, + retdata: Bytes, +) -> Result<(Option
, Bytes)> { + ensure!(!matches!(status, return_ok!()), "call did not revert as expected"); + + macro_rules! success_return { + () => { + Ok(if is_create { + (Some(DUMMY_CREATE_ADDRESS), Default::default()) + } else { + trace!("successfully handled expected revert"); + (None, DUMMY_CALL_OUTPUT.clone()) + }) + }; + } + + // If None, accept any revert + let mut expected_revert = match expected_revert { + Some(x) => x.clone(), + None => return success_return!(), + }; + + if !expected_revert.is_empty() && retdata.is_empty() { + bail!("call reverted as expected, but without data"); + } + + let mut actual_revert = retdata; + if actual_revert.len() >= 4 && + matches!(actual_revert[..4].try_into(), Ok(ERROR_PREFIX | REVERT_PREFIX)) + { + if let Ok(parsed_bytes) = DynSolType::Bytes.abi_decode(&actual_revert[4..]) { + if let Some(bytes) = parsed_bytes.as_bytes().map(|b| b.to_vec()) { + actual_revert = bytes.into(); + } + } + } + + if actual_revert == *expected_revert { + success_return!() + } else { + let stringify = |data: &mut Bytes| { + DynSolType::String + .abi_decode(data.0.as_ref()) + .ok() + .and_then(|d| d.as_str().map(|s| s.to_owned())) + .or_else(|| std::str::from_utf8(data.as_ref()).ok().map(ToOwned::to_owned)) + .unwrap_or_else(|| hex::encode_prefixed(data)) + }; + Err(fmt_err!( + "Error != expected error: {} != {}", + stringify(&mut actual_revert), + stringify(&mut expected_revert), + )) + } +} + +fn expect_safe_memory(state: &mut Cheatcodes, start: u64, end: u64, depth: u64) -> Result { + ensure!(start < end, "memory range start ({start}) is greater than end ({end})"); + #[allow(clippy::single_range_in_vec_init)] // Wanted behaviour + let offsets = state.allowed_mem_writes.entry(depth).or_insert_with(|| vec![0..0x60]); + offsets.push(start..end); + Ok(Default::default()) +} diff --git a/crates/cheatcodes/src/impls/utils.rs b/crates/cheatcodes/src/impls/utils.rs new file mode 100644 index 0000000000000..ec32ff7926f03 --- /dev/null +++ b/crates/cheatcodes/src/impls/utils.rs @@ -0,0 +1,201 @@ +//! Implementations of [`Utils`](crate::Group::Utils) cheatcodes. + +use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use crate::{Cheatcodes, Vm::*}; +use alloy_primitives::{keccak256, B256, U256}; +use alloy_sol_types::SolValue; +use ethers::{ + core::k256::{ + ecdsa::SigningKey, + elliptic_curve::{sec1::ToEncodedPoint, Curve}, + Secp256k1, + }, + signers::{ + coins_bip39::{ + ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, + Korean, Portuguese, Spanish, Wordlist, + }, + LocalWallet, MnemonicBuilder, Signer, + }, +}; +use foundry_utils::types::{ToAlloy, ToEthers}; + +/// The BIP32 default derivation path prefix. +const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; + +impl Cheatcode for createWallet_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { walletLabel } = self; + create_wallet(&U256::from_be_bytes(keccak256(walletLabel).0), Some(walletLabel), state) + } +} + +impl Cheatcode for createWallet_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { privateKey } = self; + create_wallet(privateKey, None, state) + } +} + +impl Cheatcode for createWallet_2Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { privateKey, walletLabel } = self; + create_wallet(privateKey, Some(walletLabel), state) + } +} + +impl Cheatcode for getNonce_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { wallet } = self; + super::evm::get_nonce(ccx, &wallet.addr) + } +} + +impl Cheatcode for sign_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { wallet, digest } = self; + sign(&wallet.privateKey, digest, ccx.data.env.cfg.chain_id) + } +} + +impl Cheatcode for deriveKey_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, index } = self; + derive_key::(mnemonic, DEFAULT_DERIVATION_PATH_PREFIX, *index) + } +} + +impl Cheatcode for deriveKey_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, derivationPath, index } = self; + derive_key::(mnemonic, derivationPath, *index) + } +} + +impl Cheatcode for deriveKey_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, index, language } = self; + derive_key_str(mnemonic, DEFAULT_DERIVATION_PATH_PREFIX, *index, language) + } +} + +impl Cheatcode for deriveKey_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, derivationPath, index, language } = self; + derive_key_str(mnemonic, derivationPath, *index, language) + } +} + +impl Cheatcode for rememberKeyCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { privateKey } = self; + let wallet = parse_wallet(privateKey)?.with_chain_id(ccx.data.env.cfg.chain_id); + let address = wallet.address(); + ccx.state.script_wallets.push(wallet); + Ok(address.to_alloy().abi_encode()) + } +} + +impl Cheatcode for labelCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { account, newLabel } = self; + state.labels.insert(*account, newLabel.clone()); + Ok(Default::default()) + } +} + +impl Cheatcode for getLabelCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { account } = self; + Ok(match state.labels.get(account) { + Some(label) => label.abi_encode(), + None => format!("unlabeled:{account}").abi_encode(), + }) + } +} + +/// Using a given private key, return its public ETH address, its public key affine x and y +/// coodinates, and its private key (see the 'Wallet' struct) +/// +/// If 'label' is set to 'Some()', assign that label to the associated ETH address in state +fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes) -> Result { + let key = parse_private_key(private_key)?; + let addr = ethers::utils::secret_key_to_address(&key).0.into(); + + let pub_key = key.verifying_key().as_affine().to_encoded_point(false); + let pub_key_x = U256::from_be_bytes((*pub_key.x().unwrap()).into()); + let pub_key_y = U256::from_be_bytes((*pub_key.y().unwrap()).into()); + + if let Some(label) = label { + state.labels.insert(addr, label.into()); + } + + Ok(Wallet { addr, publicKeyX: pub_key_x, publicKeyY: pub_key_y, privateKey: *private_key } + .abi_encode()) +} + +pub(super) fn sign(private_key: &U256, digest: &B256, chain_id: u64) -> Result { + let wallet = parse_wallet(private_key)?.with_chain_id(chain_id); + + // The `ecrecover` precompile does not use EIP-155 + let sig = wallet.sign_hash(digest.to_ethers())?; + let recovered = sig.recover(digest.to_ethers())?.to_alloy(); + + assert_eq!(recovered, wallet.address().to_alloy()); + + let mut r_bytes = [0u8; 32]; + let mut s_bytes = [0u8; 32]; + sig.r.to_big_endian(&mut r_bytes); + sig.s.to_big_endian(&mut s_bytes); + + Ok((sig.v, r_bytes, s_bytes).abi_encode()) +} + +pub(super) fn parse_private_key(private_key: &U256) -> Result { + ensure!(*private_key != U256::ZERO, "private key cannot be 0"); + ensure!( + *private_key < U256::from_limbs(*Secp256k1::ORDER.as_words()), + "private key must be less than the secp256k1 curve order \ + (115792089237316195423570985008687907852837564279074904382605163141518161494337)", + ); + let bytes = private_key.to_be_bytes(); + SigningKey::from_bytes((&bytes).into()).map_err(Into::into) +} + +pub(super) fn parse_wallet(private_key: &U256) -> Result { + parse_private_key(private_key).map(LocalWallet::from) +} + +fn derive_key_str(mnemonic: &str, path: &str, index: u32, language: &str) -> Result { + match language { + "chinese_simplified" => derive_key::(mnemonic, path, index), + "chinese_traditional" => derive_key::(mnemonic, path, index), + "czech" => derive_key::(mnemonic, path, index), + "english" => derive_key::(mnemonic, path, index), + "french" => derive_key::(mnemonic, path, index), + "italian" => derive_key::(mnemonic, path, index), + "japanese" => derive_key::(mnemonic, path, index), + "korean" => derive_key::(mnemonic, path, index), + "portuguese" => derive_key::(mnemonic, path, index), + "spanish" => derive_key::(mnemonic, path, index), + _ => Err(fmt_err!("unsupported mnemonic language: {language:?}")), + } +} + +fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { + fn derive_key_path(path: &str, index: u32) -> String { + let mut out = path.to_string(); + if !out.ends_with('/') { + out.push('/'); + } + out.push_str(&index.to_string()); + out + } + + let wallet = MnemonicBuilder::::default() + .phrase(mnemonic) + .derivation_path(&derive_key_path(path, index))? + .build()?; + let private_key = U256::from_be_bytes(wallet.signer().to_bytes().into()); + Ok(private_key.abi_encode()) +} diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs new file mode 100644 index 0000000000000..45591a0347580 --- /dev/null +++ b/crates/cheatcodes/src/lib.rs @@ -0,0 +1,97 @@ +//! # foundry-cheatcodes +//! +//! Foundry cheatcodes definitions and implementations. + +#![warn(missing_docs, unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] +#![allow(elided_lifetimes_in_paths)] // Cheats context uses 3 lifetimes + +#[cfg(feature = "impls")] +#[macro_use] +extern crate tracing; + +use alloy_primitives::{address, Address}; + +mod defs; +pub use defs::{Cheatcode, CheatcodeDef, Group, Mutability, Safety, Status, Visibility, Vm}; + +#[cfg(feature = "impls")] +pub mod impls; +#[cfg(feature = "impls")] +pub use impls::{Cheatcodes, CheatsConfig}; + +/// The cheatcode handler address. +/// +/// This is the same address as the one used in DappTools's HEVM. +/// It is calculated as: +/// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))` +pub const CHEATCODE_ADDRESS: Address = address!("7109709ECfa91a80626fF3989D68f67F5b1DD12D"); + +/// The Hardhat console address. +/// +/// See: +pub const HARDHAT_CONSOLE_ADDRESS: Address = address!("000000000000000000636F6e736F6c652e6c6f67"); + +/// Address of the default `CREATE2` deployer. +pub const DEFAULT_CREATE2_DEPLOYER: Address = address!("4e59b44847b379578588920ca78fbf26c0b4956c"); + +/// Generates the `cheatcodes.json` file contents. +pub fn json_cheatcodes() -> String { + serde_json::to_string_pretty(Vm::CHEATCODES).unwrap() +} + +/// Generates the [cheatcodes](json_cheatcodes) JSON schema. +#[cfg(feature = "schema")] +pub fn json_schema() -> String { + // use a custom type to add a title and description to the schema + /// Foundry cheatcodes. Learn more: + #[derive(schemars::JsonSchema)] + struct Cheatcodes([Cheatcode<'static>]); + + serde_json::to_string_pretty(&schemars::schema_for!(Cheatcodes)).unwrap() +} + +#[cfg(test)] +mod tests { + use super::*; + use std::{fs, path::Path}; + + const JSON_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/cheatcodes.json"); + #[cfg(feature = "schema")] + const SCHEMA_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/cheatcodes.schema.json"); + + #[test] + fn defs_up_to_date() { + ensure_file_contents(Path::new(JSON_PATH), &json_cheatcodes()); + } + + #[test] + #[cfg(feature = "schema")] + fn schema_up_to_date() { + ensure_file_contents(Path::new(SCHEMA_PATH), &json_schema()); + } + + /// Checks that the `file` has the specified `contents`. If that is not the + /// case, updates the file and then fails the test. + fn ensure_file_contents(file: &Path, contents: &str) { + if let Ok(old_contents) = fs::read_to_string(file) { + if normalize_newlines(&old_contents) == normalize_newlines(contents) { + // File is already up to date. + return + } + } + + eprintln!("\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n", file.display()); + if std::env::var("CI").is_ok() { + eprintln!(" NOTE: run `cargo test` locally and commit the updated files\n"); + } + if let Some(parent) = file.parent() { + let _ = fs::create_dir_all(parent); + } + fs::write(file, contents).unwrap(); + panic!("some file was not up to date and has been updated, simply re-run the tests"); + } + + fn normalize_newlines(s: &str) -> String { + s.replace("\r\n", "\n") + } +} diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index add53ae6b8aef..de56c69b6b82a 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -13,5 +13,5 @@ repository.workspace = true foundry-macros-impl = { path = "impl" } ethers-core.workspace = true -serde = "1.0" -serde_json = "1.0" +serde.workspace = true +serde_json.workspace = true diff --git a/crates/macros/impl/Cargo.toml b/crates/macros/impl/Cargo.toml index f2b4e70a7e932..83b12193239f8 100644 --- a/crates/macros/impl/Cargo.toml +++ b/crates/macros/impl/Cargo.toml @@ -20,3 +20,4 @@ doc = false proc-macro2 = "1.0" quote = "1.0" syn = "2.0" +proc-macro-error = "1" diff --git a/crates/macros/impl/src/cheatcodes.rs b/crates/macros/impl/src/cheatcodes.rs new file mode 100644 index 0000000000000..4bd978e52a699 --- /dev/null +++ b/crates/macros/impl/src/cheatcodes.rs @@ -0,0 +1,256 @@ +use proc_macro2::{Ident, Span, TokenStream}; +use quote::{quote, quote_spanned}; +use syn::{Attribute, Data, DataStruct, DeriveInput, Error, Result}; + +// Skip warnings for these items. +const ALLOWED_ITEMS: &[&str] = &["CheatCodeError", "VmErrors"]; + +pub fn derive_cheatcode(input: &DeriveInput) -> Result { + let name = &input.ident; + let name_s = name.to_string(); + match &input.data { + Data::Struct(s) if name_s.ends_with("Call") => return derive_struct(name, s, &input.attrs), + Data::Enum(e) if name_s.ends_with("Calls") => return derive_enum(name, e), + _ => {} + } + + if name_s.ends_with("Return") || ALLOWED_ITEMS.contains(&name_s.as_str()) { + if let Data::Struct(data) = &input.data { + check_named_fields(data, name); + } + return Ok(TokenStream::new()) + } + + if get_docstring(&input.attrs).trim().is_empty() { + emit_warning!(input.ident, "missing documentation for an item"); + } + match &input.data { + Data::Struct(s) => { + for field in s.fields.iter() { + if get_docstring(&field.attrs).trim().is_empty() { + emit_warning!(field.ident, "missing documentation for a field"); + } + } + } + Data::Enum(e) => { + for variant in e.variants.iter() { + if get_docstring(&variant.attrs).trim().is_empty() { + emit_warning!(variant.ident, "missing documentation for a variant"); + } + } + } + _ => {} + } + Ok(TokenStream::new()) +} + +/// Implements `CheatcodeDef` for a struct. +fn derive_struct(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result { + let mut group = None::; + let mut status = None::; + let mut safety = None::; + for attr in attrs.iter().filter(|a| a.path().is_ident("cheatcode")) { + attr.meta.require_list()?.parse_nested_meta(|meta| { + let path = meta.path.get_ident().ok_or_else(|| meta.error("expected ident"))?; + let path_s = path.to_string(); + match path_s.as_str() { + "group" if group.is_none() => group = Some(meta.value()?.parse()?), + "status" if status.is_none() => status = Some(meta.value()?.parse()?), + "safety" if safety.is_none() => safety = Some(meta.value()?.parse()?), + _ => return Err(meta.error("unexpected attribute")), + }; + Ok(()) + })?; + } + let group = group.ok_or_else(|| { + syn::Error::new(name.span(), "missing #[cheatcode(group = ...)] attribute") + })?; + let status = status.unwrap_or_else(|| Ident::new("Stable", Span::call_site())); + let safety = if let Some(safety) = safety { + quote!(Safety::#safety) + } else { + let panic = quote_spanned! {name.span()=> + panic!("cannot determine safety from the group, add a `#[cheatcode(safety = ...)]` attribute") + }; + quote! { + match Group::#group.safety() { + Some(s) => s, + None => #panic, + } + } + }; + + check_named_fields(data, name); + + let id = name.to_string(); + let id = id.strip_suffix("Call").expect("function struct ends in Call"); + + let doc = get_docstring(attrs); + let (signature, selector, declaration, description) = func_docstring(&doc); + + let (visibility, mutability) = parse_function_attrs(declaration, name.span())?; + let visibility = Ident::new(visibility, Span::call_site()); + let mutability = Ident::new(mutability, Span::call_site()); + + if description.is_empty() { + emit_warning!(name.span(), "missing documentation for a cheatcode") + } + let description = description.replace("\n ", "\n"); + + Ok(quote! { + impl CheatcodeDef for #name { + const CHEATCODE: &'static Cheatcode<'static> = &Cheatcode { + id: #id, + declaration: #declaration, + visibility: Visibility::#visibility, + mutability: Mutability::#mutability, + signature: #signature, + selector: #selector, + selector_bytes: ::SELECTOR, + description: #description, + group: Group::#group, + status: Status::#status, + safety: #safety, + }; + } + }) +} + +/// Generates the `CHEATCODES` constant and implements `CheatcodeImpl` dispatch for an enum. +fn derive_enum(name: &Ident, input: &syn::DataEnum) -> Result { + if input.variants.iter().any(|v| v.fields.len() != 1) { + return Err(syn::Error::new(name.span(), "expected all variants to have a single field")) + } + + // keep original order for matching + let variants_names = input.variants.iter().map(|v| &v.ident); + + let mut variants = input.variants.iter().collect::>(); + variants.sort_by(|a, b| a.ident.cmp(&b.ident)); + let variant_tys = variants.iter().map(|v| { + assert_eq!(v.fields.len(), 1); + &v.fields.iter().next().unwrap().ty + }); + Ok(quote! { + /// All the cheatcodes in [this contract](self). + pub const CHEATCODES: &'static [&'static Cheatcode<'static>] = &[#(<#variant_tys as CheatcodeDef>::CHEATCODE,)*]; + + #[cfg(feature = "impls")] + impl #name { + pub(crate) fn apply(&self, ccx: &mut crate::impls::CheatsCtxt) -> crate::impls::Result { + match self { + #(Self::#variants_names(c) => crate::impls::Cheatcode::apply_traced(c, ccx),)* + } + } + } + }) +} + +fn check_named_fields(data: &DataStruct, ident: &Ident) { + for field in data.fields.iter() { + if field.ident.is_none() { + emit_warning!(ident, "all params must be named"); + } + } +} + +/// Flattens all the `#[doc = "..."]` attributes into a single string. +fn get_docstring(attrs: &[syn::Attribute]) -> String { + let mut doc = String::new(); + for attr in attrs { + if !attr.path().is_ident("doc") { + continue + } + let syn::Meta::NameValue(syn::MetaNameValue { + value: syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(s), .. }), + .. + }) = &attr.meta + else { + continue + }; + + let value = s.value(); + if !value.is_empty() { + if !doc.is_empty() { + doc.push('\n'); + } + doc.push_str(&value); + } + } + doc +} + +/// Returns `(signature, hex_selector, declaration, description)` from a given `sol!`-generated +/// docstring for a function. +/// +/// # Examples +/// +/// The following docstring (string literals are joined with newlines): +/// ```text +/// "Function with signature `foo(uint256)` and selector `0x1234abcd`." +/// "```solidity" +/// "function foo(uint256 x) external view returns (bool y);" +/// "```" +/// "Description of the function." +/// ``` +/// +/// Will return: +/// ```text +/// ( +/// "foo(uint256)", +/// "0x1234abcd", +/// "function foo(uint256 x) external view returns (bool y);", +/// "Description of the function." +/// ) +/// ``` +fn func_docstring(doc: &str) -> (&str, &str, &str, &str) { + let expected_start = "Function with signature `"; + let start = doc.find(expected_start).expect("no auto docstring"); + let (descr_before, auto) = doc.split_at(start); + + let mut lines = auto.lines(); + let mut next = || lines.next().expect("unexpected end of docstring"); + + let sig_line = next(); + let example_start = next(); + assert_eq!(example_start, "```solidity"); + let declaration = next(); + let example_end = next(); + assert_eq!(example_end, "```"); + + let n = expected_start.len(); + let mut sig_end = n; + sig_end += sig_line[n..].find('`').unwrap(); + let sig = &sig_line[n..sig_end]; + assert!(!sig.starts_with('`') && !sig.ends_with('`')); + + let selector_end = sig_line.rfind('`').unwrap(); + let selector = sig_line[sig_end..selector_end].strip_prefix("` and selector `").unwrap(); + assert!(!selector.starts_with('`') && !selector.ends_with('`')); + assert!(selector.starts_with("0x")); + + let description = match doc.find("```\n") { + Some(i) => &doc[i + 4..], + None => descr_before, + }; + + (sig, selector, declaration, description.trim()) +} + +/// Returns `(visibility, mutability)` from a given Solidity function declaration. +fn parse_function_attrs(f: &str, span: Span) -> Result<(&str, &str)> { + let Some(ext_start) = f.find("external") else { + return Err(Error::new(span, "functions must have `external` visibility")) + }; + let visibility = "External"; + + let f = &f[ext_start..]; + let mutability = if f.contains("view") { + "View" + } else if f.contains("pure") { + "Pure" + } else { + "None" + }; + Ok((visibility, mutability)) +} diff --git a/crates/macros/impl/src/lib.rs b/crates/macros/impl/src/lib.rs index cf947684a5b1f..d7981523eb7af 100644 --- a/crates/macros/impl/src/lib.rs +++ b/crates/macros/impl/src/lib.rs @@ -1,12 +1,24 @@ #![warn(unused_crate_dependencies)] -mod console_fmt; +#[macro_use] +extern crate proc_macro_error; use proc_macro::TokenStream; +use proc_macro_error::proc_macro_error; use syn::{parse_macro_input, DeriveInput}; +mod cheatcodes; +mod console_fmt; + #[proc_macro_derive(ConsoleFmt)] pub fn console_fmt(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); console_fmt::console_fmt(&input).into() } + +#[proc_macro_derive(Cheatcode, attributes(cheatcode))] +#[proc_macro_error] +pub fn cheatcode(input: TokenStream) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + cheatcodes::derive_cheatcode(&input).unwrap_or_else(syn::Error::into_compile_error).into() +} diff --git a/crates/macros/impl/src/utils.rs b/crates/macros/impl/src/utils.rs deleted file mode 100644 index cfcd35a09804a..0000000000000 --- a/crates/macros/impl/src/utils.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[inline] -pub fn krate() -> syn::Path { - syn::parse_str(crate_str()).unwrap() -} - -#[inline] -pub fn crate_str() -> &'static str { - match std::env::var("CARGO_MANIFEST_DIR") { - Ok(var) if var.ends_with("macros") => "crate", - _ => "::foundry_macros", - } -} diff --git a/crates/macros/src/fmt/ui.rs b/crates/macros/src/fmt/ui.rs index 675ad798872ee..d55a6a17c1ce0 100644 --- a/crates/macros/src/fmt/ui.rs +++ b/crates/macros/src/fmt/ui.rs @@ -92,7 +92,7 @@ impl UIfmt for Option { if let Some(ref inner) = self { inner.pretty() } else { - "".to_string() + String::new() } } } @@ -501,7 +501,7 @@ value 0".to_string(); #[test] fn uifmt_option_u64() { let empty: Option = None; - assert_eq!("".to_string(), empty.pretty()); + assert_eq!(String::new(), empty.pretty()); assert_eq!("100".to_string(), U64::from_dec_str("100").unwrap().pretty()); assert_eq!("100".to_string(), Option::from(U64::from_dec_str("100").unwrap()).pretty()) } @@ -509,7 +509,7 @@ value 0".to_string(); #[test] fn uifmt_option_h64() { let empty: Option = None; - assert_eq!("".to_string(), empty.pretty()); + assert_eq!(String::new(), empty.pretty()); H256::from_low_u64_be(100); assert_eq!( "0x0000000000000000000000000000000000000000000000000000000000000064", @@ -523,7 +523,7 @@ value 0".to_string(); #[test] fn uifmt_option_bytes() { let empty: Option = None; - assert_eq!("".to_string(), empty.pretty()); + assert_eq!(String::new(), empty.pretty()); assert_eq!( "0x0000000000000000000000000000000000000000000000000000000000000064".to_string(), Bytes::from_str("0x0000000000000000000000000000000000000000000000000000000000000064") diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index 6c37eaacacc53..79c552b5cc0a7 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -10,4 +10,4 @@ pub mod fmt; pub use fmt::{console_format, ConsoleFmt, FormatSpec, TokenDisplay, UIfmt}; #[doc(inline)] -pub use foundry_macros_impl::ConsoleFmt; +pub use foundry_macros_impl::{Cheatcode, ConsoleFmt}; From b0b8cfbcef4bb39cb1759b3d25cc5132a8ee6316 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 18 Oct 2023 00:17:12 +0200 Subject: [PATCH 0171/1963] fix: dont replace solc with solc_version (#6054) --- crates/config/src/lib.rs | 43 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index dda24f05700f4..15bed4ff20249 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2053,8 +2053,14 @@ impl Provider for BackwardsCompatTomlProvider

{ .map(Value::from) .ok(); for (profile, mut dict) in self.0.data()? { - if let Some(v) = solc_env.clone().or_else(|| dict.remove("solc_version")) { + if let Some(v) = solc_env.clone() { + // ENV var takes precedence over config file dict.insert("solc".to_string(), v); + } else if let Some(v) = dict.remove("solc_version") { + // only insert older variant if not already included + if !dict.contains_key("solc") { + dict.insert("solc".to_string(), v); + } } map.insert(profile, dict); } @@ -3506,6 +3512,41 @@ mod tests { }); } + // ensures the newer `solc` takes precedence over `solc_version` + #[test] + fn test_backwards_solc_version() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [default] + solc = "0.8.12" + solc_version = "0.8.20" + "#, + )?; + + let config = Config::load(); + assert_eq!(config.solc, Some(SolcReq::Version("0.8.12".parse().unwrap()))); + + Ok(()) + }); + + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [default] + solc_version = "0.8.20" + "#, + )?; + + let config = Config::load(); + assert_eq!(config.solc, Some(SolcReq::Version("0.8.20".parse().unwrap()))); + + Ok(()) + }); + } + #[test] fn test_toml_casing_file() { figment::Jail::expect_with(|jail| { From 82af905cee0efe6549358601096ae7caef5641ea Mon Sep 17 00:00:00 2001 From: shuoer86 <129674997+shuoer86@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:41:12 +0800 Subject: [PATCH 0172/1963] fix: some typos (#6056) --- crates/anvil/src/eth/otterscan/types.rs | 2 +- crates/cast/bin/cmd/send.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/script/mod.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index d7578da765367..7606c68e3f7f4 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -116,7 +116,7 @@ impl OtsBlockDetails { /// their `gas_used`. This would be extremely inefficient in a real blockchain RPC, but we can /// get away with that in this context. /// - /// The [original spec](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) also mentions we can hardcode `transactions` and `logsBloom` to an empty array to save bandwith, because fields weren't intended to be used in the Otterscan UI at this point. This has two problems though: + /// The [original spec](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) also mentions we can hardcode `transactions` and `logsBloom` to an empty array to save bandwidth, because fields weren't intended to be used in the Otterscan UI at this point. This has two problems though: /// - It makes the endpoint too specific to Otterscan's implementation /// - It breaks the abstraction built in `OtsBlock` which computes `transaction_count` /// based on the existing list. diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index cf9d95e56f114..3313980c6cd09 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -151,7 +151,7 @@ impl SendTxArgs { .await // Case 2: // An option to use a local signer was provided. - // If we cannot successfully instanciate a local signer, then we will assume we don't have + // If we cannot successfully instantiate a local signer, then we will assume we don't have // enough information to sign and we must bail. } else { // Retrieve the signer, and bail if it can't be constructed. diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 08173dbaa94e7..502fb9913fce3 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -108,7 +108,7 @@ impl CoverageArgs { if self.ir_minimum { // TODO: How to detect solc version if the user does not specify a solc version in // config case1: specify local installed solc ? - // case2: mutliple solc versions used and auto_detect_solc == true + // case2: multiple solc versions used and auto_detect_solc == true if let Some(SolcReq::Version(version)) = &config.solc { if *version < Version::new(0, 8, 13) { return Err(eyre::eyre!( diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index f2261047d7b48..cff45e3af1ef3 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -241,7 +241,7 @@ impl ScriptArgs { .build(); // Decoding traces using etherscan is costly as we run into rate limits, - // causing scripts to run for a very long time unnecesarily. + // causing scripts to run for a very long time unnecessarily. // Therefore, we only try and use etherscan if the user has provided an API key. let should_use_etherscan_traces = script_config.config.etherscan_api_key.is_some(); From 2ef08142fb117d3e643537d4a5c48574553d3dd0 Mon Sep 17 00:00:00 2001 From: Daniel Viau <14304708+DJViau@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:56:08 -0400 Subject: [PATCH 0173/1963] tstore debugger highlighting (#6059) Co-authored-by: djviau --- crates/debugger/src/op_effects.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/debugger/src/op_effects.rs b/crates/debugger/src/op_effects.rs index d34c6aa8a6464..ad1b9fd0d0515 100644 --- a/crates/debugger/src/op_effects.rs +++ b/crates/debugger/src/op_effects.rs @@ -44,6 +44,8 @@ pub fn stack_indices_affected(op: u8) -> Vec<(usize, &'static str)> { 0x55 => vec![(0, "key"), (1, "value")], 0x56 => vec![(0, "jump_to")], 0x57 => vec![(0, "jump_to"), (1, "if")], + 0x5c => vec![(0, "key")], + 0x5d => vec![(0, "key"), (1, "value")], 0x80 => vec![(0, "dup_value")], 0x81 => vec![(1, "dup_value")], 0x82 => vec![(2, "dup_value")], From 490b588244a149453e7c6f55641fad89d30b0754 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:25:19 +0200 Subject: [PATCH 0174/1963] chore: misc cleanup (#6060) --- Cargo.lock | 3 -- crates/abi/Cargo.toml | 2 +- crates/anvil/Cargo.toml | 6 ++-- crates/anvil/core/Cargo.toml | 8 ++--- crates/anvil/core/src/eth/utils.rs | 4 +-- crates/anvil/rpc/Cargo.toml | 4 +-- crates/anvil/server/Cargo.toml | 6 ++-- crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/backend/genesis.rs | 6 ++-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 11 ++----- crates/anvil/src/eth/backend/mem/inspector.rs | 10 +++---- crates/anvil/src/eth/backend/mem/state.rs | 11 ++++--- crates/binder/Cargo.toml | 4 +-- crates/cast/Cargo.toml | 9 +++--- crates/cast/bin/cmd/logs.rs | 4 +-- crates/cast/bin/cmd/wallet/vanity.rs | 2 +- crates/chisel/Cargo.toml | 7 ++--- crates/chisel/src/runner.rs | 4 +-- crates/cli/Cargo.toml | 8 ++--- crates/common/Cargo.toml | 8 ++--- crates/common/src/abi.rs | 10 +++---- crates/common/src/constants.rs | 2 +- crates/common/src/traits.rs | 29 ++++++++++--------- crates/config/Cargo.toml | 8 ++--- crates/debugger/Cargo.toml | 4 +-- crates/debugger/src/debugger.rs | 4 +-- crates/doc/Cargo.toml | 8 ++--- crates/doc/src/parser/comment.rs | 2 +- crates/fmt/Cargo.toml | 2 +- crates/fmt/src/formatter.rs | 2 +- crates/forge/Cargo.toml | 9 +++--- crates/forge/bin/cmd/script/mod.rs | 6 ++-- crates/forge/bin/cmd/script/runner.rs | 6 ++-- crates/forge/tests/it/test_helpers.rs | 2 +- crates/test-utils/Cargo.toml | 4 +-- crates/test-utils/src/util.rs | 2 +- crates/utils/Cargo.toml | 4 +-- crates/utils/src/lib.rs | 2 +- crates/utils/src/types.rs | 14 +++++++-- 39 files changed, 117 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ac8fa985a4bd..efb80963ec37d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -948,7 +948,6 @@ name = "cast" version = "0.2.0" dependencies = [ "async-trait", - "bytes", "chrono", "clap", "clap_complete", @@ -1026,7 +1025,6 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "bytes", "clap", "criterion", "dirs 5.0.1", @@ -2467,7 +2465,6 @@ dependencies = [ "alloy-primitives", "anvil", "async-trait", - "bytes", "clap", "clap_complete", "clap_complete_fig", diff --git a/crates/abi/Cargo.toml b/crates/abi/Cargo.toml index d23c952ac4427..752cdb1328215 100644 --- a/crates/abi/Cargo.toml +++ b/crates/abi/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true [build-dependencies] ethers-contract-abigen.workspace = true -eyre = "0.6" +eyre.workspace = true syn = "2.0" [dependencies] diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index f794d32c9ba66..a6bc9532e6b2d 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -43,7 +43,7 @@ tower = "0.4" tower-http = { version = "0.4", features = ["trace"] } # tracing -tracing = "0.1" +tracing.workspace = true tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } # async @@ -54,8 +54,8 @@ async-trait = "0.1" # misc flate2 = "1.0" -serde_json = "1" -serde = { version = "1", features = ["derive"] } +serde_json.workspace = true +serde.workspace = true thiserror = "1" yansi = "0.5" tempfile = "3" diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 36584310be567..d91061334cab6 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -13,12 +13,12 @@ repository.workspace = true # foundry internal foundry-evm = { path = "../../evm" } foundry-utils = { path = "../../utils" } -revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } +revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } alloy-primitives = { workspace = true, features = ["serde"] } ethers-core.workspace = true -serde = { version = "1", features = ["derive"], optional = true } -serde_json = "1" +serde = { workspace = true, optional = true } +serde_json.workspace = true bytes = { version = "1.4" } open-fastrlp = { version = "0.1.4", optional = true } @@ -30,7 +30,7 @@ reference-trie = { version = "0.25" } keccak-hasher = { version = "0.15" } [dev-dependencies] -serde = { version = "1.0", features = ["derive"] } +serde.workspace = true [features] default = [] diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index ffc1286d272a5..e15d494acacd5 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address as rAddress, U256 as rU256}; +use alloy_primitives::{Address as aAddress, U256 as rU256}; use ethers_core::{ types::{transaction::eip2930::AccessListItem, Address, U256}, utils::{ @@ -23,7 +23,7 @@ pub fn to_access_list(list: Vec) -> Vec<(Address, Vec)> { .collect() } -pub fn to_revm_access_list(list: Vec) -> Vec<(rAddress, Vec)> { +pub fn to_revm_access_list(list: Vec) -> Vec<(aAddress, Vec)> { list.into_iter() .map(|item| { ( diff --git a/crates/anvil/rpc/Cargo.toml b/crates/anvil/rpc/Cargo.toml index 5a66eb8419d32..6d4e76540fbe6 100644 --- a/crates/anvil/rpc/Cargo.toml +++ b/crates/anvil/rpc/Cargo.toml @@ -10,8 +10,8 @@ homepage.workspace = true repository.workspace = true [dependencies] -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } +serde.workspace = true +serde_json.workspace = true [dev-dependencies] rand = "0.8" diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index ae70fcfee34bb..d934d611a4d36 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -19,7 +19,7 @@ hyper = "0.14" tower-http = { version = "0.4", features = ["trace", "cors"] } # tracing -tracing = "0.1" +tracing.workspace = true # async parking_lot = "0.12" @@ -31,8 +31,8 @@ bytes = { version = "1.4", optional = true } tokio-util = { version = "0.7", features = ["codec"], optional = true } # misc -serde_json = "1" -serde = { version = "1", features = ["derive"] } +serde_json.workspace = true +serde.workspace = true async-trait = "0.1" thiserror = "1" diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 7c588b57ace31..265fbd972650f 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -173,7 +173,7 @@ pub struct NodeConfig { impl NodeConfig { fn as_string(&self, fork: Option<&ClientFork>) -> String { - let mut config_string: String = "".to_owned(); + let mut config_string: String = String::new(); let _ = write!(config_string, "\n{}", Paint::green(BANNER)); let _ = write!(config_string, "\n {VERSION_MESSAGE}"); let _ = write!( diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index d72f18c87f51e..ade5ac6f5c79e 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -4,7 +4,7 @@ use crate::{ eth::backend::db::{Db, MaybeHashDatabase}, genesis::Genesis, }; -use alloy_primitives::{Address as B160, B256, U256}; +use alloy_primitives::{Address as aAddress, B256, U256}; use ethers::{ abi::ethereum_types::BigEndianHash, types::{Address, H256}, @@ -103,7 +103,7 @@ pub(crate) struct AtGenesisStateDb<'a> { impl<'a> DatabaseRef for AtGenesisStateDb<'a> { type Error = DatabaseError; - fn basic(&self, address: B160) -> DatabaseResult> { + fn basic(&self, address: aAddress) -> DatabaseResult> { if let Some(acc) = self.accounts.get(&(address.to_ethers())).cloned() { return Ok(Some(acc)) } @@ -117,7 +117,7 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> { self.db.code_by_hash(code_hash) } - fn storage(&self, address: B160, index: U256) -> DatabaseResult { + fn storage(&self, address: aAddress, index: U256) -> DatabaseResult { if let Some(acc) = self .genesis .as_ref() diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index cd5c7f12af1d7..ebba405fc806c 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -140,8 +140,7 @@ mod tests { revm::primitives::AccountInfo, Address, }; - use alloy_primitives::U256 as rU256; - use bytes::Bytes; + use alloy_primitives::{Bytes, U256 as rU256}; use ethers::types::U256; use foundry_evm::{ executor::{backend::MemDb, DatabaseRef}, @@ -159,9 +158,7 @@ mod tests { let mut dump_db = MemDb::default(); - let contract_code: Bytecode = - Bytecode::new_raw(alloy_primitives::Bytes(Bytes::from("fake contract code"))) - .to_checked(); + let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")).to_checked(); dump_db.insert_account( test_addr, @@ -201,9 +198,7 @@ mod tests { let test_addr2: Address = Address::from_str("0x70997970c51812dc3a010c7d01b50e0d17dc79c8").unwrap(); - let contract_code: Bytecode = - Bytecode::new_raw(alloy_primitives::Bytes(Bytes::from("fake contract code"))) - .to_checked(); + let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")).to_checked(); let mut db = MemDb::default(); diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 2f83ee97a116f..ee46ea101d14c 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -9,7 +9,7 @@ use foundry_evm::{ revm, revm::{ interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, - primitives::{Address as rAddress, Bytes, B256}, + primitives::{Address, Bytes, B256}, EVMData, }, }; @@ -71,7 +71,7 @@ impl revm::Inspector for Inspector { fn log( &mut self, evm_data: &mut EVMData<'_, DB>, - address: &rAddress, + address: &Address, topics: &[B256], data: &Bytes, ) { @@ -126,7 +126,7 @@ impl revm::Inspector for Inspector { &mut self, data: &mut EVMData<'_, DB>, call: &mut CreateInputs, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option

, Gas, Bytes) { call_inspectors!([&mut self.tracer], |inspector| { inspector.create(data, call); }); @@ -140,10 +140,10 @@ impl revm::Inspector for Inspector { data: &mut EVMData<'_, DB>, inputs: &CreateInputs, status: InstructionResult, - address: Option, + address: Option
, gas: Gas, retdata: Bytes, - ) -> (InstructionResult, Option, Gas, Bytes) { + ) -> (InstructionResult, Option
, Gas, Bytes) { call_inspectors!([&mut self.tracer], |inspector| { inspector.create_end(data, inputs, status, address, gas, retdata.clone()); }); diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index 81e2789a42b84..c0d5271ab85bd 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -1,9 +1,8 @@ //! Support for generating the state root for memdb storage use crate::eth::{backend::db::AsHashDB, error::BlockchainError}; -use alloy_primitives::{Address as rAddress, U256 as rU256}; +use alloy_primitives::{Address, Bytes, U256 as rU256}; use anvil_core::eth::{state::StateOverride, trie::RefSecTrieDBMut}; -use bytes::Bytes; use ethers::{ types::H256, utils::{rlp, rlp::RlpStream}, @@ -63,7 +62,7 @@ pub fn storage_trie_db(storage: &Map) -> (AsHashDB, H256) { } /// Returns the account data as `HashDB` -pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { +pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { let accounts = trie_accounts(accounts); // Populate DB with full trie from entries. @@ -83,7 +82,7 @@ pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { } /// Returns all RLP-encoded Accounts -pub fn trie_accounts(accounts: &Map) -> Vec<(rAddress, Bytes)> { +pub fn trie_accounts(accounts: &Map) -> Vec<(Address, Bytes)> { accounts .iter() .map(|(address, account)| { @@ -93,7 +92,7 @@ pub fn trie_accounts(accounts: &Map) -> Vec<(rAddress, Byte .collect() } -pub fn state_merkle_trie_root(accounts: &Map) -> H256 { +pub fn state_merkle_trie_root(accounts: &Map) -> H256 { trie_hash_db(accounts).1 } @@ -104,7 +103,7 @@ pub fn trie_account_rlp(info: &AccountInfo, storage: &Map) -> Byte stream.append(&info.balance.to_ethers()); stream.append(&storage_trie_db(storage).1); stream.append(&info.code_hash.as_slice()); - stream.out().freeze() + stream.out().freeze().into() } /// Applies the given state overrides to the state, returning a new CacheDB state diff --git a/crates/binder/Cargo.toml b/crates/binder/Cargo.toml index 28d4a7f010450..aa8c3681ead9b 100644 --- a/crates/binder/Cargo.toml +++ b/crates/binder/Cargo.toml @@ -13,8 +13,8 @@ repository.workspace = true [dependencies] foundry-config.workspace = true ethers-contract = { workspace = true, features = ["abigen"] } -eyre = "0.6" +eyre.workspace = true git2 = { version = "0.18", default-features = false } url = "2" -tracing = "0.1" +tracing.workspace = true tempfile = "3" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 890ccda69af29..644672e233c5a 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -29,12 +29,12 @@ ethers-core.workspace = true ethers-providers.workspace = true chrono.workspace = true evm-disassembler = "0.2" -eyre = "0.6" +eyre.workspace = true futures = "0.3" hex.workspace = true rayon = "1" -serde = "1" -serde_json = "1" +serde.workspace = true +serde_json.workspace = true # aws rusoto_core = { version = "0.48", default-features = false } @@ -48,7 +48,6 @@ foundry-cli.workspace = true ethers = { workspace = true, features = ["rustls"] } eth-keystore = "0.5" -bytes = "1.4" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" @@ -61,7 +60,7 @@ rpassword = "7" semver = "1" tempfile = "3" tokio = { version = "1", features = ["macros", "signal"] } -tracing = "0.1" +tracing.workspace = true yansi = "0.5" [dev-dependencies] diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 3bfc2608d742c..3e43476d70d6a 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -305,7 +305,7 @@ mod tests { None, None, Some(TRANSFER_SIG.to_string()), - vec!["".to_string(), ADDRESS.to_string()], + vec![String::new(), ADDRESS.to_string()], ) .unwrap(); assert_eq!(filter, expected) @@ -352,7 +352,7 @@ mod tests { None, None, Some(TRANSFER_TOPIC.to_string()), - vec!["".to_string(), TRANSFER_TOPIC.to_string()], + vec![String::new(), TRANSFER_TOPIC.to_string()], ) .unwrap(); diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 9252c9b9c8959..9ac378face556 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -122,7 +122,7 @@ impl VanityArgs { nonce.unwrap(), )) } else { - "".to_string() + String::new() }, SimpleCast::to_checksum_address(&wallet.address()), hex::encode(wallet.signer().to_bytes()), diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 701416630e5a5..161b3b4f028ef 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -45,12 +45,11 @@ rustyline = "12" solang-parser.workspace = true yansi = "0.5" strum = { version = "0.25", features = ["derive"] } -serde = "1" -serde_json = { version = "1", features = ["raw_value"] } +serde.workspace = true +serde_json.workspace = true semver = "1" -bytes = "1" revm.workspace = true -eyre = "0.6" +eyre.workspace = true dirs = "5" time = { version = "0.3", features = ["formatting"] } regex = "1" diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index b99eeee47c15c..86826ad588674 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -46,7 +46,7 @@ pub struct ChiselResult { /// Map of addresses to their labels pub labeled_addresses: BTreeMap, /// Return data - pub returned: bytes::Bytes, + pub returned: Bytes, /// Called address pub address: Option
, /// EVM State at the final instruction of the `run()` function @@ -200,7 +200,7 @@ impl ChiselRunner { let RawCallResult { result, reverted, logs, traces, labels, chisel_state, .. } = res; Ok(ChiselResult { - returned: result.0, + returned: result, success: !reverted, gas_used, logs, diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 602cafdcb74ad..6ff7b2cf57c47 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -29,21 +29,21 @@ alloy-primitives.workspace = true async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } -color-eyre = "0.6" +color-eyre.workspace = true dotenvy = "0.15" -eyre = "0.6" +eyre.workspace = true hex = { workspace = true, features = ["serde"] } indicatif = "0.17" itertools.workspace = true once_cell = "1" regex = { version = "1", default-features = false } rpassword = "7" -serde = { version = "1", features = ["derive"] } +serde.workspace = true strsim = "0.10" strum = { version = "0.25", features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["macros"] } -tracing = "0.1" +tracing.workspace = true tracing-error = "0.2" tracing-subscriber = { version = "0.3", features = ["registry", "env-filter", "fmt"] } yansi = "0.5" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 448ccd973dd86..df83bb020b711 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -27,17 +27,17 @@ reqwest = { version = "0.11", default-features = false } # cli clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" -tracing = "0.1" +tracing.workspace = true yansi = "0.5" tempfile = "3" # misc auto_impl = "1.1.0" async-trait = "0.1" -serde = "1" -serde_json = "1" +serde.workspace = true +serde_json.workspace = true thiserror = "1" -eyre = "0.6" +eyre.workspace = true walkdir = "2" semver = "1" once_cell = "1" diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 703205a656571..e43650d39e4af 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -136,7 +136,7 @@ pub fn sanitize_token(token: Token) -> Token { Token::String(val) => { let val = match val.as_str() { // this is supposed to be an empty string - "\"\"" | "''" => "".to_string(), + "\"\"" | "''" => String::new(), _ => val, }; Token::String(val) @@ -369,12 +369,12 @@ mod tests { let token = Token::Array(LenientTokenizer::tokenize_array("[\"\"]", &ParamType::String).unwrap()); let sanitized = sanitize_token(token); - assert_eq!(sanitized, Token::Array(vec![Token::String("".to_string())])); + assert_eq!(sanitized, Token::Array(vec![Token::String(String::new())])); let token = Token::Array(LenientTokenizer::tokenize_array("['']", &ParamType::String).unwrap()); let sanitized = sanitize_token(token); - assert_eq!(sanitized, Token::Array(vec![Token::String("".to_string())])); + assert_eq!(sanitized, Token::Array(vec![Token::String(String::new())])); let token = Token::Array( LenientTokenizer::tokenize_array("[\"\",\"\"]", &ParamType::String).unwrap(), @@ -382,7 +382,7 @@ mod tests { let sanitized = sanitize_token(token); assert_eq!( sanitized, - Token::Array(vec![Token::String("".to_string()), Token::String("".to_string())]) + Token::Array(vec![Token::String(String::new()), Token::String(String::new())]) ); let token = @@ -390,7 +390,7 @@ mod tests { let sanitized = sanitize_token(token); assert_eq!( sanitized, - Token::Array(vec![Token::String("".to_string()), Token::String("".to_string())]) + Token::Array(vec![Token::String(String::new()), Token::String(String::new())]) ); } diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 5a457422a681b..c17ebd9deff5e 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -19,7 +19,7 @@ pub const CONTRACT_MAX_SIZE: usize = 24576; /// responses. This timeout should be a reasonable amount of time to wait for a request. pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(45); -/// Alchemy free tier cups +/// Alchemy free tier cups: pub const ALCHEMY_FREE_TIER_CUPS: u64 = 330; /// Logged when an error is indicative that the user is trying to fork from a non-archive node. diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index a80421a4b84e3..fd18acaa1c3c0 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -1,9 +1,10 @@ //! Commonly used traits +use auto_impl::auto_impl; use ethers_core::abi::Function; /// Extension trait for matching tests -#[auto_impl::auto_impl(&)] +#[auto_impl(&)] pub trait TestFilter: Send + Sync { /// Returns whether the test should be included fn matches_test(&self, test_name: impl AsRef) -> bool; @@ -14,7 +15,7 @@ pub trait TestFilter: Send + Sync { } /// Extension trait for `Function` -#[auto_impl::auto_impl(&)] +#[auto_impl(&)] pub trait TestFunctionExt { /// Whether this function should be executed as invariant test fn is_invariant_test(&self) -> bool; @@ -51,46 +52,46 @@ impl TestFunctionExt for Function { } } -impl<'a> TestFunctionExt for &'a str { +impl TestFunctionExt for String { fn is_invariant_test(&self) -> bool { - self.starts_with("invariant") || self.starts_with("statefulFuzz") + self.as_str().is_invariant_test() } fn is_fuzz_test(&self) -> bool { - unimplemented!("no naming convention for fuzz tests.") + self.as_str().is_fuzz_test() } fn is_test(&self) -> bool { - self.starts_with("test") + self.as_str().is_test() } fn is_test_fail(&self) -> bool { - self.starts_with("testFail") + self.as_str().is_test_fail() } fn is_setup(&self) -> bool { - self.eq_ignore_ascii_case("setup") + self.as_str().is_setup() } } -impl TestFunctionExt for String { +impl TestFunctionExt for str { fn is_invariant_test(&self) -> bool { - self.as_str().is_invariant_test() + self.starts_with("invariant") || self.starts_with("statefulFuzz") } fn is_fuzz_test(&self) -> bool { - self.as_str().is_fuzz_test() + unimplemented!("no naming convention for fuzz tests.") } fn is_test(&self) -> bool { - self.as_str().is_test() + self.starts_with("test") } fn is_test_fail(&self) -> bool { - self.as_str().is_test_fail() + self.starts_with("testFail") } fn is_setup(&self) -> bool { - self.as_str().is_setup() + self.eq_ignore_ascii_case("setup") } } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 908018e1f41b8..0a2faa6c89a6b 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -21,9 +21,9 @@ revm-primitives = { workspace = true, default-features = false, features = ["std Inflector = "0.11" figment = { version = "0.10", features = ["toml", "env"] } number_prefix = "0.4" -serde = { version = "1", features = ["derive"] } +serde.workspace = true serde_regex = "1" -serde_json = "1" +serde_json.workspace = true toml = { version = "0.8", features = ["preserve_order"] } toml_edit = "0.20" @@ -36,10 +36,10 @@ walkdir = "2" open-fastrlp = "0.1" # misc -eyre = "0.6" +eyre.workspace = true regex = "1" semver = { version = "1", features = ["serde"] } -tracing = "0.1" +tracing.workspace = true once_cell = "1" thiserror = "1" reqwest = { version = "0.11", default-features = false } diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index a4e5a524d423c..c90f8f87fa2d4 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -17,7 +17,7 @@ foundry-utils.workspace = true alloy-primitives.workspace = true crossterm = "0.27" -eyre = "0.6" -tracing = "0.1" +eyre.workspace = true +tracing.workspace = true revm = { workspace = true, default-features = false, features = ["std", "serde", "arbitrary"] } ratatui = { version = "0.23.0", default-features = false, features = ["crossterm"] } diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index 3b92c47747155..3c7b54abe500c 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,11 +1,9 @@ -use crate::Ui; +use crate::{TUIExitReason, Tui, Ui}; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder}; use foundry_utils::types::ToAlloy; use tracing::{error, trace}; -use crate::{TUIExitReason, Tui}; - /// Standardized way of firing up the debugger pub struct DebuggerArgs<'a> { /// debug traces returned from the execution diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index f2448c87fc55e..4b82a0bced8ed 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -21,7 +21,7 @@ ethers-solc = { workspace = true, features = ["async"] } ethers-core.workspace = true # tracing -tracing = "0.1" +tracing.workspace = true # mdbook mdbook = { version = "0.4", default-features = false, features = ["search"] } @@ -31,7 +31,7 @@ futures-util = "0.3" # misc solang-parser.workspace = true -eyre = "0.6" +eyre.workspace = true thiserror = "1" rayon = "1" itertools.workspace = true @@ -39,5 +39,5 @@ toml.workspace = true auto_impl = "1" derive_more = "0.99" once_cell = "1" -serde = "1.0.163" -serde_json = "1.0.96" +serde.workspace = true +serde_json.workspace = true diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index a897804496be1..0cac1978bcdda 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -213,7 +213,7 @@ mod tests { assert_eq!(CommentTag::from_str("param"), Some(CommentTag::Param)); assert_eq!(CommentTag::from_str("return"), Some(CommentTag::Return)); assert_eq!(CommentTag::from_str("inheritdoc"), Some(CommentTag::Inheritdoc)); - assert_eq!(CommentTag::from_str("custom:"), Some(CommentTag::Custom("".to_owned()))); + assert_eq!(CommentTag::from_str("custom:"), Some(CommentTag::Custom(String::new()))); assert_eq!( CommentTag::from_str("custom:some"), Some(CommentTag::Custom("some".to_owned())) diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index f4e4366e5388e..a954d14527b95 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -23,7 +23,7 @@ solang-parser.workspace = true itertools.workspace = true thiserror = "1" ariadne = "0.3" -tracing = "0.1" +tracing.workspace = true [dev-dependencies] pretty_assertions = "1" diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 39b6c74846d73..d74ae2df19120 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1254,7 +1254,7 @@ impl<'a, W: Write> Formatter<'a, W> { ident: &mut Option, ) -> Result<()> { let ident = - if let Some(ident) = ident { format!(":{}", ident.name) } else { "".to_owned() }; + if let Some(ident) = ident { format!(":{}", ident.name) } else { String::new() }; write_chunk!(self, loc.start(), loc.end(), "{val}{ident}")?; Ok(()) } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index e195c1be21b1c..2d76b0404365d 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -26,11 +26,11 @@ foundry-evm.workspace = true comfy-table = "7" ethers = { workspace = true, features = ["solc-full"] } -eyre = "0.6" +eyre.workspace = true proptest = "1" rayon = "1" -serde = "1" -tracing = "0.1" +serde.workspace = true +tracing.workspace = true yansi = "0.5" # bin @@ -42,7 +42,6 @@ foundry-debugger.workspace = true alloy-primitives = { workspace = true, features = ["serde"] } async-trait = "0.1" -bytes = "1.4" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" @@ -57,7 +56,7 @@ parking_lot = "0.12" regex = { version = "1", default-features = false } reqwest = { version = "0.11", default-features = false, features = ["json"] } semver = "1" -serde_json = "1" +serde_json.workspace = true similar = { version = "2", features = ["inline"] } solang-parser.workspace = true strum = { version = "0.25", features = ["derive"] } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index cff45e3af1ef3..e18c4b2cce6d8 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -257,7 +257,7 @@ impl ScriptArgs { pub fn get_returns( &self, script_config: &ScriptConfig, - returned: &bytes::Bytes, + returned: &Bytes, ) -> Result> { let func = script_config.called_function.as_ref().expect("There should be a function."); let mut returns = HashMap::new(); @@ -283,7 +283,7 @@ impl ScriptArgs { } } Err(_) => { - shell::println(format!("{:x?}", (&returned)))?; + shell::println(format!("{returned:?}"))?; } } @@ -617,7 +617,7 @@ pub struct ScriptResult { pub gas_used: u64, pub labeled_addresses: BTreeMap, pub transactions: Option, - pub returned: bytes::Bytes, + pub returned: Bytes, pub address: Option
, pub script_wallets: Vec, pub breakpoints: Breakpoints, diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 00846749cef6f..7fd4d8d14d1bc 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -158,7 +158,7 @@ impl ScriptRunner { Ok(( address, ScriptResult { - returned: bytes::Bytes::new(), + returned: Bytes::new(), success, gas_used, labeled_addresses: labeled_addresses @@ -235,7 +235,7 @@ impl ScriptRunner { }; Ok(ScriptResult { - returned: bytes::Bytes::new(), + returned: Bytes::new(), success: address != Address::ZERO, gas_used, logs, @@ -296,7 +296,7 @@ impl ScriptRunner { let breakpoints = res.cheatcodes.map(|cheats| cheats.breakpoints).unwrap_or_default(); Ok(ScriptResult { - returned: result.0, + returned: result, success: !reverted, gas_used, logs, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index fe219b10954de..90ce1bc80e854 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -63,7 +63,7 @@ pub static COMPILED_WITH_LIBS: Lazy = Lazy::new(|| { pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { env: Env { - gas_limit: 18446744073709551615, + gas_limit: u64::MAX, chain_id: None, tx_origin: Config::DEFAULT_SENDER.to_alloy(), block_number: 1, diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index a18ff1ffa4b2a..7294914d735a6 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -20,12 +20,12 @@ ethers.workspace = true ethers-solc = { workspace = true, features = ["project-util"] } alloy-primitives.workspace = true -eyre = "0.6" +eyre.workspace = true once_cell = "1" parking_lot = "0.12" pretty_assertions = "1" regex = "1" -serde_json = "1" +serde_json.workspace = true tempfile = "3" walkdir = "2" diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 3f4c44a450eb0..8cf30f291a830 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -740,7 +740,7 @@ impl TestCommand { let suggest = if out.stderr.is_empty() { "\n\nDid your forge command end up with no output?".to_string() } else { - "".to_string() + String::new() }; eyre::bail!( "\n\n==========\n\ diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 6acc065f35184..fc840d5bc5dda 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -26,8 +26,8 @@ futures = "0.3" glob = "0.3" once_cell = "1" rand = "0.8" -serde_json = { version = "1", default-features = false } -tracing = "0.1" +serde_json.workspace = true +tracing.workspace = true dunce = "1" [dev-dependencies] diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 66676f36facd4..bad34b4b96fa1 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -427,7 +427,7 @@ pub fn to_table(value: serde_json::Value) -> String { } s } - _ => "".to_owned(), + _ => String::new(), } } diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index 20406c9e3241b..e8e8e46a4953a 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -14,14 +14,16 @@ pub trait ToAlloy { impl ToAlloy for H160 { type To = Address; + #[inline(always)] fn to_alloy(self) -> Self::To { - Address::from_slice(self.as_bytes()) + Address::new(self.0) } } impl ToAlloy for H256 { type To = B256; + #[inline(always)] fn to_alloy(self) -> Self::To { B256::new(self.0) } @@ -30,6 +32,7 @@ impl ToAlloy for H256 { impl ToAlloy for U256 { type To = AlloyU256; + #[inline(always)] fn to_alloy(self) -> Self::To { AlloyU256::from_limbs(self.0) } @@ -38,6 +41,7 @@ impl ToAlloy for U256 { impl ToAlloy for U64 { type To = AlloyU64; + #[inline(always)] fn to_alloy(self) -> Self::To { AlloyU64::from_limbs(self.0) } @@ -46,6 +50,7 @@ impl ToAlloy for U64 { impl ToAlloy for u64 { type To = AlloyU256; + #[inline(always)] fn to_alloy(self) -> Self::To { AlloyU256::from(self) } @@ -62,14 +67,16 @@ pub trait ToEthers { impl ToEthers for Address { type To = H160; + #[inline(always)] fn to_ethers(self) -> Self::To { - H160::from_slice(self.as_slice()) + H160(self.0 .0) } } impl ToEthers for B256 { type To = H256; + #[inline(always)] fn to_ethers(self) -> Self::To { H256(self.0) } @@ -78,7 +85,8 @@ impl ToEthers for B256 { impl ToEthers for AlloyU256 { type To = U256; + #[inline(always)] fn to_ethers(self) -> Self::To { - U256::from_little_endian(&self.as_le_bytes()) + U256(self.into_limbs()) } } From 619f3c56302b5a665164002cb98263cd9812e4d5 Mon Sep 17 00:00:00 2001 From: Resende <17102689+ZePedroResende@users.noreply.github.com> Date: Thu, 19 Oct 2023 23:21:57 +0100 Subject: [PATCH 0175/1963] feat(anvil): Fix `ots_getInternalOperations` (#6068) * feat(anvil): Fix `ots_getInternalOperations` * Motivation The otterscan `ots_getInternalOperations` was given incorrect values and fully crashing when `SELFDESTRUCTS` where present. The `type` field in the response for this endpoint is incorrectly serialized. * Solution Use the `MinedTransaction` instead of a parity traces to have more granular controll on the specific transactions that we want to filter out in the internal operations and the specific parameters that we want to have access to. Fix the serialization for the`type` field in the response. * feat(anvil): fix create2 handling in `ots_getInternalOperations` --- Cargo.lock | 12 ++ crates/anvil/Cargo.toml | 1 + crates/anvil/src/eth/backend/mem/mod.rs | 5 + crates/anvil/src/eth/otterscan/api.rs | 2 +- crates/anvil/src/eth/otterscan/types.rs | 91 +++++++-------- crates/anvil/tests/it/otterscan.rs | 149 +++++++++++++++++++++++- 6 files changed, 205 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efb80963ec37d..0b25edb4a35df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -309,6 +309,7 @@ dependencies = [ "pretty_assertions", "serde", "serde_json", + "serde_repr", "tempfile", "thiserror", "tokio", @@ -6196,6 +6197,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "serde_spanned" version = "0.6.3" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index a6bc9532e6b2d..4183cc13396af 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -54,6 +54,7 @@ async-trait = "0.1" # misc flate2 = "1.0" +serde_repr = "0.1" serde_json.workspace = true serde.workspace = true thiserror = "1" diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 4022172e7f30c..ecc1b3ca6108e 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1813,6 +1813,11 @@ impl Backend { self.blockchain.storage.read().transactions.get(&hash).map(|tx| tx.parity_traces()) } + /// Returns the traces for the given transaction + pub(crate) fn mined_transaction(&self, hash: H256) -> Option { + self.blockchain.storage.read().transactions.get(&hash).cloned() + } + /// Returns the traces for the given block pub(crate) fn mined_parity_trace_block(&self, block: u64) -> Option> { let block = self.get_block(block)?; diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index c22354c3083ac..114f407406c75 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -48,7 +48,7 @@ impl EthApi { node_info!("ots_getInternalOperations"); self.backend - .mined_parity_trace_transaction(hash) + .mined_transaction(hash) .map(OtsInternalOperation::batch_build) .ok_or_else(|| BlockchainError::DataUnavailable) } diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 7606c68e3f7f4..04b1a85e16e8d 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -1,12 +1,13 @@ use ethers::types::{ - Action, Address, Block, Bytes, Call, CallType, Create, CreateResult, Res, Suicide, Trace, - Transaction, TransactionReceipt, H256, U256, + Action, Address, Block, Bytes, CallType, Trace, Transaction, TransactionReceipt, H256, U256, }; +use foundry_evm::{executor::InstructionResult, CallKind}; use futures::future::join_all; use serde::{de::DeserializeOwned, Serialize}; +use serde_repr::Serialize_repr; use crate::eth::{ - backend::mem::Backend, + backend::mem::{storage::MinedTransaction, Backend}, error::{BlockchainError, Result}, }; @@ -80,12 +81,13 @@ pub struct OtsInternalOperation { } /// Types of internal operations recognized by Otterscan -#[derive(Serialize, Debug, PartialEq)] +#[derive(Serialize_repr, Debug, PartialEq)] +#[repr(u8)] pub enum OtsInternalOperationType { Transfer = 0, SelfDestruct = 1, Create = 2, - // The spec asks for a Create2 entry as well, but we don't have that info + Create2 = 3, } /// Otterscan's representation of a trace @@ -231,59 +233,44 @@ impl OtsSearchTransactions { impl OtsInternalOperation { /// Converts a batch of traces into a batch of internal operations, to comply with the spec for /// [`ots_getInternalOperations`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getinternaloperations) - pub fn batch_build(traces: Vec) -> Vec { + pub fn batch_build(traces: MinedTransaction) -> Vec { traces + .info + .traces + .arena .iter() - .filter_map(|trace| { - match (trace.action.clone(), trace.result.clone()) { - (Action::Call(Call { from, to, value, .. }), _) if !value.is_zero() => { - Some(Self { r#type: OtsInternalOperationType::Transfer, from, to, value }) - } - ( - Action::Create(Create { from, value, .. }), - Some(Res::Create(CreateResult { address, .. })), - ) => Some(Self { - r#type: OtsInternalOperationType::Create, - from, - to: address, - value, - }), - (Action::Suicide(Suicide { address, .. }), _) => { - // this assumes a suicide trace always has a parent trace - let (from, value) = - Self::find_suicide_caller(&traces, &trace.trace_address).unwrap(); - - Some(Self { - r#type: OtsInternalOperationType::SelfDestruct, - from, - to: address, - value, - }) - } - _ => None, + .filter_map(|node| match (node.kind(), node.status()) { + (CallKind::Call, _) if !node.trace.value.is_zero() => Some(Self { + r#type: OtsInternalOperationType::Transfer, + from: node.trace.caller, + to: node.trace.address, + value: node.trace.value, + }), + (CallKind::Create, _) => Some(Self { + r#type: OtsInternalOperationType::Create, + from: node.trace.caller, + to: node.trace.address, + value: node.trace.value, + }), + (CallKind::Create2, _) => Some(Self { + r#type: OtsInternalOperationType::Create2, + from: node.trace.caller, + to: node.trace.address, + value: node.trace.value, + }), + (_, InstructionResult::SelfDestruct) => { + Some(Self { + r#type: OtsInternalOperationType::SelfDestruct, + from: node.trace.address, + // the foundry CallTraceNode doesn't have a refund address + to: Default::default(), + value: node.trace.value, + }) } + _ => None, }) .collect() } - - /// finds the trace that parents a given trace_address - fn find_suicide_caller( - traces: &Vec, - suicide_address: &Vec, - ) -> Option<(Address, U256)> { - traces.iter().find(|t| t.trace_address == suicide_address[..suicide_address.len() - 1]).map( - |t| match t.action { - Action::Call(Call { from, value, .. }) => (from, value), - - Action::Create(Create { from, value, .. }) => (from, value), - - // we assume here a suicice trace can never be parented by another suicide trace - Action::Suicide(_) => Self::find_suicide_caller(traces, &t.trace_address).unwrap(), - - Action::Reward(_) => unreachable!(), - }, - ) - } } impl OtsTrace { diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 2c4959cd52236..32271f5ec07b5 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -64,6 +64,153 @@ async fn can_call_ots_get_internal_operations_contract_deploy() { ); } +#[tokio::test(flavor = "multi_thread")] +async fn can_call_ots_get_internal_operations_contract_trasfer() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let from = accounts[0].address(); + let to = accounts[1].address(); + //let client = Arc::new(SignerMiddleware::new(provider, wallet)); + + let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + + let tx = TransactionRequest::new().to(to).value(amount).from(from); + + let receipt = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + + let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); + + assert_eq!(res.len(), 1); + assert_eq!( + res[0], + OtsInternalOperation { + r#type: OtsInternalOperationType::Transfer, + from, + to, + value: amount + } + ); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_call_ots_get_internal_operations_contract_create2() { + let prj = TempProject::dapptools().unwrap(); + prj.add_source( + "Contract", + r" +pragma solidity 0.8.13; +contract Contract { + address constant CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + constructor() {} + function deploy() public { + uint256 salt = 0; + uint256 code = 0; + bytes memory creationCode = abi.encodePacked(code); + (bool success,) = address(CREATE2_DEPLOYER).call(abi.encodePacked(salt, creationCode)); + require(success); + } +} +", + ) + .unwrap(); + + let mut compiled = prj.compile().unwrap(); + assert!(!compiled.has_compiler_errors()); + let contract = compiled.remove_first("Contract").unwrap(); + let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.ws_provider().await; + let wallets = handle.dev_wallets().collect::>(); + let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + + // deploy successfully + let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let contract = factory.deploy(()).unwrap().send().await.unwrap(); + + let contract = ContractInstance::new( + contract.address(), + abi.unwrap(), + SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), + ); + let call = contract.method::<_, ()>("deploy", ()).unwrap(); + + let receipt = call.send().await.unwrap().await.unwrap().unwrap(); + dbg!(&receipt); + + let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); + + assert_eq!(res.len(), 1); + assert_eq!( + res[0], + OtsInternalOperation { + r#type: OtsInternalOperationType::Create2, + from: Address::from_str("0x4e59b44847b379578588920cA78FbF26c0B4956C").unwrap(), + to: Address::from_str("0x347bcdad821abc09b8c275881b368de36476b62c").unwrap(), + value: 0.into() + } + ); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_call_ots_get_internal_operations_contract_selfdestruct() { + let prj = TempProject::dapptools().unwrap(); + prj.add_source( + "Contract", + r" +pragma solidity 0.8.13; +contract Contract { + address payable private owner; + constructor() public { + owner = payable(msg.sender); + } + function goodbye() public { + selfdestruct(owner); + } +} +", + ) + .unwrap(); + + let mut compiled = prj.compile().unwrap(); + assert!(!compiled.has_compiler_errors()); + let contract = compiled.remove_first("Contract").unwrap(); + let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.ws_provider().await; + let wallets = handle.dev_wallets().collect::>(); + let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + + // deploy successfully + let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let contract = factory.deploy(()).unwrap().send().await.unwrap(); + + let contract = ContractInstance::new( + contract.address(), + abi.unwrap(), + SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), + ); + let call = contract.method::<_, ()>("goodbye", ()).unwrap(); + + let receipt = call.send().await.unwrap().await.unwrap().unwrap(); + + let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); + + assert_eq!(res.len(), 1); + assert_eq!( + res[0], + OtsInternalOperation { + r#type: OtsInternalOperationType::SelfDestruct, + from: contract.address(), + to: Default::default(), + value: 0.into() + } + ); +} + #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_has_code() { let (api, handle) = spawn(NodeConfig::test()).await; @@ -238,8 +385,6 @@ contract Contract { let call = contract.method::<_, ()>("trigger_revert", ()).unwrap().gas(150_000u64); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - let _block = api.block_by_number_full(BlockNumber::Latest).await.unwrap().unwrap(); - let res = api.ots_get_transaction_error(receipt.transaction_hash).await.unwrap().unwrap(); assert_eq!(res, Bytes::from_str("0x8d6ea8be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012526576657274537472696e67466f6f4261720000000000000000000000000000").unwrap()); } From 2937e4fec3d22ba60708a347b363e48e734b5853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Sun, 22 Oct 2023 10:42:41 +0200 Subject: [PATCH 0176/1963] chore(cast): update `from-bin` command description (#6077) --- crates/cast/bin/opts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 4c7bfd24a3349..63890c2941576 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -91,7 +91,7 @@ pub enum Subcommands { data: Vec, }, - /// "Convert binary data into hex data." + /// Convert binary data into hex data. #[clap(visible_aliases = &["--from-bin", "from-binx", "fb"])] FromBin, From 040934240267ba381bb68ddc7425d8177ac50a56 Mon Sep 17 00:00:00 2001 From: evalir Date: Sun, 22 Oct 2023 18:04:38 +0900 Subject: [PATCH 0177/1963] chore: new clippy (#6080) --- crates/anvil/src/eth/api.rs | 4 ++-- crates/cast/bin/main.rs | 2 +- crates/cheatcodes/src/impls/test/expect.rs | 4 ++-- crates/doc/src/parser/mod.rs | 4 ++-- crates/evm/src/executor/inspector/cheatcodes/expect.rs | 4 ++-- crates/forge/bin/cmd/script/cmd.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index d7f875c4fa726..313ecfb4efb9a 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -805,7 +805,7 @@ impl EthApi { node_info!("eth_signTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { - self.accounts()?.get(0).cloned().ok_or(BlockchainError::NoSignerAvailable) + self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) })?; let (nonce, _) = self.request_nonce(&request, from).await?; @@ -824,7 +824,7 @@ impl EthApi { node_info!("eth_sendTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { - self.accounts()?.get(0).cloned().ok_or(BlockchainError::NoSignerAvailable) + self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) })?; let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 8949f5c877ca7..b2ac3a66716d3 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -358,7 +358,7 @@ async fn main() -> Result<()> { let sig = match sigs.len() { 0 => eyre::bail!("No signatures found"), - 1 => sigs.get(0).unwrap(), + 1 => sigs.first().unwrap(), _ => { let i: usize = prompt!("Select a function signature by number: ")?; sigs.get(i - 1).ok_or_else(|| eyre::eyre!("Invalid signature index"))? diff --git a/crates/cheatcodes/src/impls/test/expect.rs b/crates/cheatcodes/src/impls/test/expect.rs index 1551440f5ec0e..218fdd1b9c7e0 100644 --- a/crates/cheatcodes/src/impls/test/expect.rs +++ b/crates/cheatcodes/src/impls/test/expect.rs @@ -395,8 +395,8 @@ pub(crate) fn handle_expect_emit( return }; - let expected_topic_0 = expected.topics().get(0); - let log_topic_0 = topics.get(0); + let expected_topic_0 = expected.topics().first(); + let log_topic_0 = topics.first(); if expected_topic_0 .zip(log_topic_0) diff --git a/crates/doc/src/parser/mod.rs b/crates/doc/src/parser/mod.rs index 5a57535d5c585..4b3e99ce13b03 100644 --- a/crates/doc/src/parser/mod.rs +++ b/crates/doc/src/parser/mod.rs @@ -272,7 +272,7 @@ mod tests { ); assert_eq!(items.len(), 3); - let first_item = items.get(0).unwrap(); + let first_item = items.first().unwrap(); assert!(matches!(first_item.source, ParseSource::Contract(_))); assert_eq!(first_item.source.ident(), "A"); @@ -309,7 +309,7 @@ mod tests { assert_eq!(items.len(), 2); - let event = items.get(0).unwrap(); + let event = items.first().unwrap(); assert!(event.comments.is_empty()); assert!(event.children.is_empty()); assert_eq!(event.source.ident(), "TopLevelEvent"); diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/src/executor/inspector/cheatcodes/expect.rs index 51ff72f91978c..a14344a92e966 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/expect.rs @@ -153,8 +153,8 @@ pub fn handle_expect_emit(state: &mut Cheatcodes, log: RawLog, address: &Address match event_to_fill_or_check.log { Some(ref expected) => { - let expected_topic_0 = expected.topics().get(0); - let log_topic_0 = log.topics().get(0); + let expected_topic_0 = expected.topics().first(); + let log_topic_0 = log.topics().first(); // same topic0 and equal number of topics should be verified further, others are a no // match diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 77cd60e7837a0..556422f4f86bf 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -352,7 +352,7 @@ impl ScriptArgs { } if let Some(wallets) = self.wallets.private_keys()? { if wallets.len() == 1 { - script_config.evm_opts.sender = wallets.get(0).unwrap().address().to_alloy() + script_config.evm_opts.sender = wallets.first().unwrap().address().to_alloy() } } Ok(()) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3c0e55c0dfdd0..21f0ddf044272 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -218,7 +218,7 @@ impl TestArgs { } let test_funcs = runner.get_matching_test_functions(&filter); // if we debug a fuzz test, we should not collect data on the first run - if !test_funcs.get(0).expect("matching function exists").inputs.is_empty() { + if !test_funcs.first().expect("matching function exists").inputs.is_empty() { runner_builder = runner_builder.set_debug(false); runner = runner_builder.clone().build( project_root, From ba6c85112f4c34fc8eb081645bad278f48343ec4 Mon Sep 17 00:00:00 2001 From: tsite Date: Sun, 22 Oct 2023 05:45:05 -0500 Subject: [PATCH 0178/1963] fix(forge): fix `verify-contract` etherscan cloudflare bug (#6079) * fix `forge verify-contract` etherscan cloudflare bug Etherscan verification for non-mainnet chains requires a question mark at the end of the verifier url in order to prevent a forward slash from being added to the url which trips a cloudflare rule on requests from ec2 boxes. Verification on both Goerli and Sepolia both fails without this character present. Hardhat-verify does not add the extra forward slash to the verifier url and has no issues verifying contracts on etherscan. Fixes #4865, #5251, #5741 * run cargo +nightly fmt -- --check * check if the api url already ends with ? Also apply the fix to --verifier-url urls --- crates/forge/bin/cmd/verify/etherscan/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 7b57d13dbde56..35f0de49f2cc8 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -264,8 +264,12 @@ impl EtherscanVerificationProvider { ) -> Result { let etherscan_config = config.get_etherscan_config_with_chain(Some(chain))?; - let api_url = - verifier_url.or_else(|| etherscan_config.as_ref().map(|c| c.api_url.as_str())); + let etherscan_api_url = verifier_url + .or_else(|| etherscan_config.as_ref().map(|c| c.api_url.as_str())) + .map(str::to_owned) + .map(|url| if url.ends_with('?') { url } else { url + "?" }); + + let api_url = etherscan_api_url.as_deref(); let base_url = etherscan_config .as_ref() .and_then(|c| c.browser_url.as_deref()) From 602460eb99e1645eab970bacc5a6d01368a07457 Mon Sep 17 00:00:00 2001 From: Daniel Viau <14304708+DJViau@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:27:00 -0400 Subject: [PATCH 0179/1963] Update README.md (#6083) Adds documentation of `disable-start` and `disable-end`. See https://github.com/foundry-rs/foundry/issues/4998 --- crates/fmt/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/fmt/README.md b/crates/fmt/README.md index 7e51bf7f8a111..11e0c5ea3024b 100644 --- a/crates/fmt/README.md +++ b/crates/fmt/README.md @@ -134,6 +134,17 @@ Alternatively, the comment can also be placed at the end of the line. In this ca uint x = 100; // forgefmt: disable-line ``` +### Disable Block + +The formatter can be disabled for a section of code by adding a comment `// forgefmt: disable-start` before and a comment `// forgefmt: disable-end` after, like this: + +```solidity +// forgefmt: disable-start +uint x = 100; +uint y = 101; +// forgefmt: disable-end +``` + ### Testing Tests reside under the `fmt/testdata` folder and specify the malformatted & expected Solidity code. The source code file is named `original.sol` and expected file(s) are named in a format `({prefix}.)?fmt.sol`. Multiple expected files are needed for tests covering available configuration options. From 843e1350b516772ff41b2caec8a09db011b41b99 Mon Sep 17 00:00:00 2001 From: christn Date: Tue, 24 Oct 2023 20:11:14 +0800 Subject: [PATCH 0180/1963] Update evm-disassembler dependency to support new cancun opcodes (#6089) Co-authored-by: test --- Cargo.lock | 4 ++-- crates/cast/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b25edb4a35df..ad97cc76f0a2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2304,9 +2304,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm-disassembler" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "584e7334177d2dc76c4d618967e5ef102be68c35f454ac363d88b72b854db4a9" +checksum = "7ef8b778f0f7ba24aaa7c1d8fa7ec75db869f8a8508907be49eac899865ea52d" dependencies = [ "eyre", "hex", diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 644672e233c5a..0c9cb488b802e 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -28,7 +28,7 @@ ethers-etherscan.workspace = true ethers-core.workspace = true ethers-providers.workspace = true chrono.workspace = true -evm-disassembler = "0.2" +evm-disassembler = "0.3" eyre.workspace = true futures = "0.3" hex.workspace = true From 3f6f16a5ad99c9cdc3fa2eac7bdbf4309fc9bd29 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 24 Oct 2023 16:37:48 +0200 Subject: [PATCH 0181/1963] chore: bump ethers (#6091) --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad97cc76f0a2a..67b946f8f60d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2044,7 +2044,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2059,7 +2059,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "ethers-core", "once_cell", @@ -2070,7 +2070,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2088,7 +2088,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "Inflector", "const-hex", @@ -2111,7 +2111,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "Inflector", "const-hex", @@ -2126,7 +2126,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "arrayvec", "bytes", @@ -2155,7 +2155,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "ethers-core", "ethers-solc", @@ -2170,7 +2170,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "async-trait", "auto_impl", @@ -2196,7 +2196,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "async-trait", "auto_impl", @@ -2234,7 +2234,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "async-trait", "coins-bip32", @@ -2262,7 +2262,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9d01a9810940d3acd7c78bf2b2f2ca85a74f73eb" +source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "cfg-if", "const-hex", From e82f5bd0380a5990065cf1ea43a4ce4fb6648271 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 24 Oct 2023 16:38:06 +0200 Subject: [PATCH 0182/1963] chore(clippy): make clippy happy (#6092) --- crates/chisel/src/lib.rs | 3 +-- crates/forge/bin/cmd/script/mod.rs | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/chisel/src/lib.rs b/crates/chisel/src/lib.rs index c5668909ff750..2004ed0c41c92 100644 --- a/crates/chisel/src/lib.rs +++ b/crates/chisel/src/lib.rs @@ -30,7 +30,6 @@ pub mod solidity_helper; /// Prelude of all chisel modules pub mod prelude { pub use crate::{ - cmd::*, dispatcher::*, executor::*, runner::*, session::*, session_source::*, - solidity_helper::*, + cmd::*, dispatcher::*, runner::*, session::*, session_source::*, solidity_helper::*, }; } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index e18c4b2cce6d8..1f6a5d3a6b8f2 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -70,8 +70,6 @@ mod sequence; pub mod transaction; mod verify; -pub use transaction::TransactionWithMetadata; - /// List of Chains that support Shanghai. static SHANGHAI_ENABLED_CHAINS: &[Chain] = &[ // Ethereum Mainnet From 6ac22dfb99bb5df7f5bdde2290ea500b13356175 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 24 Oct 2023 21:33:24 +0200 Subject: [PATCH 0183/1963] fix: wrong subtract timestamp (#6097) --- crates/anvil/src/eth/backend/mem/mod.rs | 4 +--- crates/anvil/tests/it/anvil_api.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ecc1b3ca6108e..17a32a70fef0b 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -659,9 +659,7 @@ impl Backend { let block = self.block_by_hash(best_block_hash).await?.ok_or(BlockchainError::BlockNotFound)?; - // Note: In [`TimeManager::compute_next_timestamp`] we ensure that the next timestamp is - // always increasing by at least one. By subtracting 1 here, this is mitigated. - let reset_time = block.timestamp.as_u64().saturating_sub(1); + let reset_time = block.timestamp.as_u64(); self.time.reset(reset_time); self.set_block_number(num.into()); } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 03b72e5061bb7..b46cb2f5e0984 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -498,3 +498,23 @@ async fn test_set_chain_id() { let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id, U256::from(1234)); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_revert_next_block_timestamp() { + let (api, _handle) = spawn(fork_config()).await; + + // Mine a new block, and check the new block gas limit + api.mine_one().await; + let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + + let snapshot_id = api.evm_snapshot().await.unwrap(); + api.mine_one().await; + api.evm_revert(snapshot_id).await.unwrap(); + let block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + assert_eq!(block, latest_block); + + api.mine_one().await; + let block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + assert!(block.timestamp > latest_block.timestamp); +} From 251ef74e04c6ad11eb02787c4b6190858d4ec1d7 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 25 Oct 2023 16:57:39 +0900 Subject: [PATCH 0184/1963] feat(deps): Move to Alloy ABI encoding/decoding & alloy types (#5986) * feat: find and replace all ethers_solc mentions outside anvil * chore: keep resolving errors as fuzz is getting migrated * feat: fuzz/trace changes * feat: partial trace migration * chore: use temporal sol! macro in diff file for decode migration * feat: use proptest traits instead of custom impl * chore: address comments * chore: remove alloy console bindings * feat: introduce foundry-block-explorers * chore: partial common abi helpers migration * feat: partial decode migration * feat: re-introduce block-explorers * feat: fix compiler errors * chore * chore: tentative inspector migration * feat: switch to using static decoder to decode errors * chore: clippy * feat: migrate trace types temporarily * chore: replace ethers tracing types for local tracing types * fix: handle decoding with static decoder, tests * chore: use JsonAbi for console/hardhat/hevm abis * chore: add todo * chore: replace types downstream and remove glue * feat: fix last evm issues, start fixing downstream type issues * chore: cargo * chore: more downstream error fixes * chore: fix test files * chore: more downstream fixes * chore: fmt * feat: migrate unit utils, replace * chore: fix tests, fmt * compiles * clippy * chore: clippy * chore: last fixes * chore: update block explorers * chore: actually coerce values correctly * chore: fix broken test * chore: fix estimation test, parse values as alloy nums * chore: fix abi parsing * chore: selector tests * chore: fix more tests, remove more glue * chore: properly decode logs * chore: use selector_type to handle tuples correctly * chore: clippy and fix another test * chore: fix remaining abi tests * chore: use proptest traits for fuzzer * more test fixes ongod * clippy * chore: use abigen for console logs for now * fix: generate valid values in fuzzer * chore: clippy * chore: readd settings * chore: various fixes * chore: fix script arguments decoding * chore: fix more tests * chore: last ots fixes * fix: decoding * chore: clippy * chore: fmt * chore: fix deny check * chore: deny fixes * chore: force default features off * chore: update block-explorers * chore: doc fixes * chore: ignore invariant storage test due to flakyness * chore: update foundry-block-explorers * chore: cleanup, config migration * chore: resolve comments, more cleanup, remove unwraps * chore: remove last mentions of ethers::etherscan * chore: remove ethers-solc feat * chore: use alloy master again * chore: readd NameOrAddress * chore: clippy/fmt * chore: readd support on storage * fix: add remappings on settings * chore: address comments (remove create2, noop map, remove eyre from decode.rs) * chore: use NameOrAddress --- Cargo.lock | 635 +++++++++++------ Cargo.toml | 38 +- crates/abi/Cargo.toml | 2 +- crates/anvil/src/cmd.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/eth/backend/mem/storage.rs | 4 +- crates/anvil/src/eth/otterscan/types.rs | 60 +- crates/anvil/tests/it/fork.rs | 10 +- crates/cast/Cargo.toml | 9 + crates/cast/bin/cmd/access_list.rs | 4 +- crates/cast/bin/cmd/call.rs | 19 +- crates/cast/bin/cmd/create2.rs | 29 +- crates/cast/bin/cmd/estimate.rs | 3 +- crates/cast/bin/cmd/find_block.rs | 14 +- crates/cast/bin/cmd/logs.rs | 87 ++- crates/cast/bin/cmd/run.rs | 7 +- crates/cast/bin/cmd/send.rs | 14 +- crates/cast/bin/cmd/storage.rs | 37 +- crates/cast/bin/cmd/wallet/mod.rs | 13 +- crates/cast/bin/cmd/wallet/vanity.rs | 9 +- crates/cast/bin/main.rs | 24 +- crates/cast/bin/opts.rs | 24 +- crates/cast/src/lib.rs | 256 ++++--- crates/cast/src/tx.rs | 59 +- crates/cast/tests/cli/main.rs | 2 +- crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/src/impls/config.rs | 2 +- crates/chisel/Cargo.toml | 5 +- crates/chisel/benches/session_source.rs | 2 +- crates/chisel/src/dispatcher.rs | 5 +- crates/chisel/src/executor.rs | 4 +- crates/chisel/src/runner.rs | 8 +- crates/chisel/src/session_source.rs | 8 +- crates/chisel/tests/cache.rs | 2 +- crates/cli/Cargo.toml | 6 +- crates/cli/src/opts/build/core.rs | 4 +- crates/cli/src/opts/build/mod.rs | 2 +- crates/cli/src/opts/build/paths.rs | 2 +- crates/cli/src/opts/dependency.rs | 2 +- crates/cli/src/opts/transaction.rs | 8 +- crates/cli/src/opts/wallet/mod.rs | 12 +- crates/cli/src/opts/wallet/multi_wallet.rs | 11 +- crates/cli/src/utils/cmd.rs | 25 +- crates/cli/src/utils/mod.rs | 46 +- crates/common/Cargo.toml | 8 +- crates/common/src/abi.rs | 319 +++------ crates/common/src/calc.rs | 60 +- crates/common/src/compile.rs | 20 +- crates/common/src/constants.rs | 18 +- crates/common/src/contracts.rs | 19 +- crates/common/src/evm.rs | 4 +- crates/common/src/lib.rs | 2 + crates/common/src/selectors.rs | 6 +- crates/common/src/serde_helpers.rs | 39 ++ crates/common/src/term.rs | 2 +- crates/common/src/traits.rs | 2 +- crates/common/src/units.rs | 329 +++++++++ crates/config/Cargo.toml | 6 +- crates/config/src/chain.rs | 9 +- crates/config/src/etherscan.rs | 7 +- crates/config/src/fuzz.rs | 5 +- crates/config/src/inline/natspec.rs | 2 +- crates/config/src/lib.rs | 43 +- crates/config/src/providers/remappings.rs | 2 +- crates/config/src/utils.rs | 42 +- crates/debugger/Cargo.toml | 1 - crates/debugger/src/debugger.rs | 5 +- crates/debugger/src/lib.rs | 3 +- crates/doc/Cargo.toml | 3 +- crates/doc/src/builder.rs | 2 +- crates/evm/Cargo.toml | 9 +- crates/evm/src/coverage/analysis.rs | 4 +- crates/evm/src/coverage/anchors.rs | 2 +- crates/evm/src/debug.rs | 2 +- crates/evm/src/decode.rs | 174 +++-- crates/evm/src/executor/abi/mod.rs | 642 +++++++++++++++++- crates/evm/src/executor/backend/mod.rs | 5 +- crates/evm/src/executor/fork/backend.rs | 5 +- crates/evm/src/executor/fork/multi.rs | 13 - .../executor/inspector/cheatcodes/config.rs | 2 +- .../src/executor/inspector/cheatcodes/env.rs | 6 +- crates/evm/src/executor/inspector/fuzzer.rs | 14 +- crates/evm/src/executor/inspector/tracer.rs | 22 +- crates/evm/src/executor/mod.rs | 70 +- .../evm/src/fuzz/invariant/call_override.rs | 2 +- crates/evm/src/fuzz/invariant/error.rs | 22 +- crates/evm/src/fuzz/invariant/executor.rs | 178 +++-- crates/evm/src/fuzz/invariant/filters.rs | 23 +- crates/evm/src/fuzz/invariant/mod.rs | 24 +- crates/evm/src/fuzz/mod.rs | 61 +- crates/evm/src/fuzz/strategies/calldata.rs | 14 +- crates/evm/src/fuzz/strategies/int.rs | 43 +- crates/evm/src/fuzz/strategies/invariants.rs | 35 +- crates/evm/src/fuzz/strategies/param.rs | 178 +++-- crates/evm/src/fuzz/strategies/state.rs | 113 ++- crates/evm/src/fuzz/strategies/uint.rs | 35 +- crates/evm/src/fuzz/types.rs | 4 +- crates/evm/src/lib.rs | 4 +- crates/evm/src/trace/decoder.rs | 110 ++- crates/evm/src/trace/executor.rs | 2 +- crates/evm/src/trace/identifier/etherscan.rs | 18 +- crates/evm/src/trace/identifier/local.rs | 3 +- crates/evm/src/trace/identifier/mod.rs | 7 +- crates/evm/src/trace/identifier/signatures.rs | 2 +- crates/evm/src/trace/mod.rs | 34 +- crates/evm/src/trace/node.rs | 39 +- crates/evm/src/trace/utils.rs | 29 +- crates/evm/src/utils.rs | 13 +- crates/forge/Cargo.toml | 4 + crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 17 +- crates/forge/bin/cmd/create.rs | 268 +++++++- crates/forge/bin/cmd/fmt.rs | 2 +- crates/forge/bin/cmd/fourbyte.rs | 2 +- crates/forge/bin/cmd/geiger/mod.rs | 2 +- crates/forge/bin/cmd/init.rs | 4 +- crates/forge/bin/cmd/inspect.rs | 30 +- crates/forge/bin/cmd/remappings.rs | 2 +- crates/forge/bin/cmd/script/artifacts.rs | 4 +- crates/forge/bin/cmd/script/broadcast.rs | 14 +- crates/forge/bin/cmd/script/build.rs | 17 +- crates/forge/bin/cmd/script/cmd.rs | 4 +- crates/forge/bin/cmd/script/executor.rs | 16 +- crates/forge/bin/cmd/script/mod.rs | 54 +- crates/forge/bin/cmd/script/multi.rs | 8 +- crates/forge/bin/cmd/script/runner.rs | 8 +- crates/forge/bin/cmd/script/sequence.rs | 10 +- crates/forge/bin/cmd/script/transaction.rs | 28 +- crates/forge/bin/cmd/script/verify.rs | 2 +- crates/forge/bin/cmd/selectors.rs | 2 +- crates/forge/bin/cmd/test/filter.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 3 +- crates/forge/bin/cmd/tree.rs | 6 +- .../forge/bin/cmd/verify/etherscan/flatten.rs | 12 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 40 +- .../bin/cmd/verify/etherscan/standard_json.rs | 5 +- crates/forge/bin/cmd/verify/mod.rs | 2 +- crates/forge/bin/cmd/verify/sourcify.rs | 2 +- crates/forge/src/gas_report.rs | 15 +- crates/forge/src/lib.rs | 7 +- crates/forge/src/multi_runner.rs | 19 +- crates/forge/src/result.rs | 7 +- crates/forge/src/runner.rs | 94 +-- crates/forge/tests/cli/cmd.rs | 22 +- crates/forge/tests/cli/config.rs | 19 +- crates/forge/tests/cli/create.rs | 6 +- crates/forge/tests/it/config.rs | 3 +- crates/forge/tests/it/fuzz.rs | 2 +- crates/forge/tests/it/invariant.rs | 11 +- crates/forge/tests/it/repros.rs | 3 +- crates/forge/tests/it/test_helpers.rs | 17 +- crates/macros/Cargo.toml | 3 + crates/macros/src/fmt/token.rs | 31 +- crates/test-utils/Cargo.toml | 3 +- crates/test-utils/src/lib.rs | 2 +- crates/test-utils/src/macros.rs | 14 +- crates/test-utils/src/util.rs | 4 +- crates/utils/Cargo.toml | 3 +- crates/utils/src/error.rs | 2 - crates/utils/src/lib.rs | 10 +- crates/utils/src/types.rs | 9 + 161 files changed, 3382 insertions(+), 1935 deletions(-) create mode 100644 crates/common/src/serde_helpers.rs create mode 100644 crates/common/src/units.rs diff --git a/Cargo.lock b/Cargo.lock index 67b946f8f60d2..fe6261cf97d51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom 0.2.10", "once_cell", @@ -51,13 +51,14 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -78,8 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4e0daba57ddaba12dc9b21f608b843251f3de017f94a431dca4e7f4f72e5ba9" +source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -88,17 +88,18 @@ dependencies = [ "arbitrary", "const-hex", "derive_arbitrary", + "derive_more", "itoa", "proptest", "serde", "serde_json", + "winnow", ] [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63c9319ad8b2b623c6a3ac15899f8ffb71479224762dbaedc385c16efbb6cfe3" +source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -109,8 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0628ec0ba5b98b3370bb6be17b12f23bfce8ee4ad83823325a20546d9b03b78" +source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,12 +156,12 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a98ad1696a2e17f010ae8e43e9f2a1e930ed176a8e3ff77acfeff6dfb07b42c" +source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" dependencies = [ "const-hex", "dunce", "heck", + "indexmap 2.0.2", "proc-macro-error", "proc-macro2", "quote", @@ -173,8 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81c61ccc29e7c58bf16a2f780898852348183f58b127bde03ced6d07ad544787" +source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" dependencies = [ "winnow", ] @@ -182,8 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98d7107bed88e8f09f0ddcc3335622d87bfb6821f3e0c7473329fb1cfad5e015" +source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -293,7 +291,7 @@ dependencies = [ "ctrlc", "ethereum-forkid", "ethers", - "ethers-solc", + "ethers-solc 2.0.4", "fdlimit", "flate2", "foundry-common", @@ -556,9 +554,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", @@ -688,9 +686,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -710,7 +708,7 @@ version = "0.66.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cexpr", "clang-sys", "lazy_static", @@ -750,9 +748,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" dependencies = [ "arbitrary", "serde", @@ -818,7 +816,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" dependencies = [ "memchr", - "regex-automata 0.4.2", + "regex-automata 0.4.3", "serde", ] @@ -948,6 +946,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" name = "cast" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", "async-trait", "chrono", "clap", @@ -964,8 +965,10 @@ dependencies = [ "ethers-providers", "evm-disassembler", "eyre", + "foundry-block-explorers", "foundry-cli", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-evm", "foundry-test-utils", @@ -1030,11 +1033,11 @@ dependencies = [ "criterion", "dirs 5.0.1", "ethers", - "ethers-solc", "eyre", "forge-fmt", "foundry-cli", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-evm", "foundry-utils", @@ -1047,8 +1050,8 @@ dependencies = [ "serde", "serde_json", "serial_test", - "solang-parser", - "strum 0.25.0", + "solang-parser 0.3.2", + "strum", "time", "tokio", "vergen", @@ -1240,7 +1243,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bech32", "bs58", "digest 0.10.7", @@ -1316,13 +1319,13 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.0.1" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" +checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ - "crossterm 0.26.1", - "strum 0.24.1", - "strum_macros 0.24.3", + "crossterm", + "strum", + "strum_macros", "unicode-width", ] @@ -1399,9 +1402,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" dependencies = [ "libc", ] @@ -1520,29 +1523,13 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossterm" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" -dependencies = [ - "bitflags 1.3.2", - "crossterm_winapi", - "libc", - "mio", - "parking_lot", - "signal-hook", - "signal-hook-mio", - "winapi", -] - [[package]] name = "crossterm" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "crossterm_winapi", "libc", "mio", @@ -1625,7 +1612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.1", + "hashbrown 0.14.2", "lock_api", "once_cell", "parking_lot_core", @@ -1896,7 +1883,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "hex", "k256", @@ -2044,7 +2031,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2053,13 +2040,13 @@ dependencies = [ "ethers-middleware", "ethers-providers", "ethers-signers", - "ethers-solc", + "ethers-solc 2.0.10", ] [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "ethers-core", "once_cell", @@ -2070,7 +2057,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2088,7 +2075,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "Inflector", "const-hex", @@ -2104,14 +2091,14 @@ dependencies = [ "serde", "serde_json", "syn 2.0.38", - "toml 0.8.2", + "toml 0.8.4", "walkdir", ] [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "Inflector", "const-hex", @@ -2126,7 +2113,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "arrayvec", "bytes", @@ -2144,7 +2131,7 @@ dependencies = [ "rlp", "serde", "serde_json", - "strum 0.25.0", + "strum", "syn 2.0.38", "tempfile", "thiserror", @@ -2155,10 +2142,10 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "ethers-core", - "ethers-solc", + "ethers-solc 2.0.10", "reqwest", "semver 1.0.20", "serde", @@ -2170,7 +2157,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "async-trait", "auto_impl", @@ -2196,11 +2183,11 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "async-trait", "auto_impl", - "base64 0.21.4", + "base64 0.21.5", "bytes", "const-hex", "enr", @@ -2234,7 +2221,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "async-trait", "coins-bip32", @@ -2261,17 +2248,18 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs#9754f22d06a2defe5608c4c9b809cc361443a3dc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2284784306de73d8ad1bc792ecc1b87da0268185683698d60fd096d23d168c99" dependencies = [ "cfg-if", - "const-hex", - "dirs 5.0.1", "dunce", "ethers-core", "fs_extra", "futures-util", + "getrandom 0.2.10", "glob", + "hex", "home", "md-5 0.10.6", "num_cpus", @@ -2284,9 +2272,9 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "solang-parser", - "svm-rs", - "svm-rs-builds", + "solang-parser 0.2.4", + "svm-rs 0.2.23", + "svm-rs-builds 0.1.15", "tempfile", "thiserror", "tiny-keccak", @@ -2296,6 +2284,40 @@ dependencies = [ "yansi 0.5.1", ] +[[package]] +name = "ethers-solc" +version = "2.0.10" +source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +dependencies = [ + "cfg-if", + "const-hex", + "dirs 5.0.1", + "dunce", + "ethers-core", + "futures-util", + "glob", + "home", + "md-5 0.10.6", + "num_cpus", + "once_cell", + "path-slash", + "rayon", + "regex", + "semver 1.0.20", + "serde", + "serde_json", + "sha2 0.10.8", + "solang-parser 0.3.2", + "svm-rs 0.3.0", + "svm-rs-builds 0.2.0", + "thiserror", + "tiny-keccak", + "tokio", + "tracing", + "walkdir", + "yansi 0.5.1", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -2393,7 +2415,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.2", + "toml 0.8.4", "uncased", "version_check", ] @@ -2463,6 +2485,8 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" name = "forge" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", "alloy-primitives", "anvil", "async-trait", @@ -2478,8 +2502,10 @@ dependencies = [ "eyre", "forge-doc", "forge-fmt", + "foundry-block-explorers", "foundry-cli", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-debugger", "foundry-evm", @@ -2502,9 +2528,9 @@ dependencies = [ "serde_json", "serial_test", "similar", - "solang-parser", - "strum 0.25.0", - "svm-rs", + "solang-parser 0.3.2", + "strum", + "svm-rs 0.3.0", "thiserror", "tokio", "tracing", @@ -2521,9 +2547,9 @@ dependencies = [ "auto_impl", "derive_more", "ethers-core", - "ethers-solc", "eyre", "forge-fmt", + "foundry-compilers", "foundry-config", "foundry-utils", "futures-util", @@ -2533,10 +2559,10 @@ dependencies = [ "rayon", "serde", "serde_json", - "solang-parser", + "solang-parser 0.3.2", "thiserror", "tokio", - "toml 0.8.2", + "toml 0.8.4", "tracing", "warp", ] @@ -2550,9 +2576,9 @@ dependencies = [ "foundry-config", "itertools 0.11.0", "pretty_assertions", - "solang-parser", + "solang-parser 0.3.2", "thiserror", - "toml 0.8.2", + "toml 0.8.4", "tracing", "tracing-subscriber", ] @@ -2592,6 +2618,23 @@ dependencies = [ "url", ] +[[package]] +name = "foundry-block-explorers" +version = "0.1.0" +source = "git+https://github.com/foundry-rs/block-explorers#5cbf6d32fa1ba39bc06a0d2b6202a021b3b8f0ff" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "ethers-core", + "foundry-compilers", + "reqwest", + "semver 1.0.20", + "serde", + "serde_json", + "thiserror", + "tracing", +] + [[package]] name = "foundry-cheatcodes" version = "0.2.0" @@ -2604,6 +2647,7 @@ dependencies = [ "ethers", "eyre", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-macros", "foundry-utils", @@ -2623,6 +2667,8 @@ dependencies = [ name = "foundry-cli" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", "alloy-primitives", "async-trait", "clap", @@ -2632,6 +2678,7 @@ dependencies = [ "ethers", "eyre", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-debugger", "foundry-evm", @@ -2645,7 +2692,7 @@ dependencies = [ "rusoto_kms", "serde", "strsim", - "strum 0.25.0", + "strum", "tempfile", "thiserror", "tokio", @@ -2659,6 +2706,9 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", "async-trait", "auto_impl", "clap", @@ -2666,11 +2716,11 @@ dependencies = [ "const-hex", "dunce", "ethers-core", - "ethers-etherscan", "ethers-middleware", "ethers-providers", - "ethers-solc", "eyre", + "foundry-block-explorers", + "foundry-compilers", "foundry-config", "foundry-macros", "globset", @@ -2689,17 +2739,57 @@ dependencies = [ "yansi 0.5.1", ] +[[package]] +name = "foundry-compilers" +version = "0.1.0" +source = "git+https://github.com/foundry-rs/compilers#7b63c75c8a06e66e56bcfbb7ba0920fd9ad15fc7" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "cfg-if", + "const-hex", + "dirs 5.0.1", + "dunce", + "fs_extra", + "futures-util", + "glob", + "home", + "md-5 0.10.6", + "num_cpus", + "once_cell", + "path-slash", + "rand 0.8.5", + "rayon", + "regex", + "semver 1.0.20", + "serde", + "serde_json", + "sha2 0.10.8", + "solang-parser 0.3.2", + "svm-rs 0.3.0", + "svm-rs-builds 0.2.0", + "tempfile", + "thiserror", + "tiny-keccak", + "tokio", + "tracing", + "walkdir", + "yansi 0.5.1", +] + [[package]] name = "foundry-config" version = "0.2.0" dependencies = [ "Inflector", + "alloy-primitives", "dirs-next", "ethers-core", - "ethers-etherscan", - "ethers-solc", "eyre", "figment", + "foundry-block-explorers", + "foundry-compilers", "globset", "number_prefix", "once_cell", @@ -2715,8 +2805,8 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.2", - "toml_edit 0.20.2", + "toml 0.8.4", + "toml_edit 0.20.4", "tracing", "walkdir", ] @@ -2726,11 +2816,10 @@ name = "foundry-debugger" version = "0.2.0" dependencies = [ "alloy-primitives", - "crossterm 0.27.0", + "crossterm", "eyre", "foundry-common", "foundry-evm", - "foundry-utils", "ratatui", "revm", "tracing", @@ -2741,19 +2830,23 @@ name = "foundry-evm" version = "0.2.0" dependencies = [ "alloy-dyn-abi", + "alloy-json-abi", "alloy-primitives", + "alloy-sol-types", "auto_impl", "bytes", "const-hex", "ethers", "eyre", "foundry-abi", + "foundry-block-explorers", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-macros", "foundry-utils", "futures", - "hashbrown 0.14.1", + "hashbrown 0.14.2", "itertools 0.11.0", "jsonpath_lib", "once_cell", @@ -2777,6 +2870,8 @@ dependencies = [ name = "foundry-macros" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", + "alloy-primitives", "ethers-core", "foundry-macros-impl", "serde", @@ -2799,9 +2894,9 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "ethers", - "ethers-solc", "eyre", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-utils", "once_cell", @@ -2824,10 +2919,10 @@ dependencies = [ "ethers-contract", "ethers-core", "ethers-providers", - "ethers-solc", "eyre", "forge-fmt", "foundry-common", + "foundry-compilers", "futures", "glob", "once_cell", @@ -3043,7 +3138,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "libc", "libgit2-sys", "log", @@ -3092,7 +3187,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "bstr", "gix-path", "libc", @@ -3138,7 +3233,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "bstr", "gix-features", "gix-path", @@ -3223,7 +3318,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "gix-path", "libc", "windows", @@ -3369,16 +3464,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.5", "allocator-api2", "serde", ] @@ -3398,7 +3493,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "headers-core", "http", @@ -3560,7 +3655,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -3591,7 +3686,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.7", + "rustls 0.21.8", "tokio", "tokio-rustls 0.24.1", ] @@ -3611,16 +3706,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -3738,7 +3833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.2", ] [[package]] @@ -3806,9 +3901,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -3880,7 +3975,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "pem", "ring 0.16.20", "serde", @@ -3942,6 +4037,28 @@ dependencies = [ "libc", ] +[[package]] +name = "lalrpop" +version = "0.19.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" +dependencies = [ + "ascii-canvas", + "bit-set", + "diff", + "ena", + "is-terminal", + "itertools 0.10.5", + "lalrpop-util 0.19.12", + "petgraph", + "regex", + "regex-syntax 0.6.29", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + [[package]] name = "lalrpop" version = "0.20.0" @@ -3954,7 +4071,7 @@ dependencies = [ "ena", "is-terminal", "itertools 0.10.5", - "lalrpop-util", + "lalrpop-util 0.20.0", "petgraph", "regex", "regex-syntax 0.7.5", @@ -3964,6 +4081,15 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "lalrpop-util" +version = "0.19.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" +dependencies = [ + "regex", +] + [[package]] name = "lalrpop-util" version = "0.20.0" @@ -4051,9 +4177,9 @@ checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -4261,9 +4387,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", @@ -4323,7 +4449,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "libc", ] @@ -4573,7 +4699,7 @@ version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -4715,13 +4841,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.4.1", "smallvec", "windows-targets 0.48.5", ] @@ -4817,9 +4943,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ "memchr", "thiserror", @@ -4828,9 +4954,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -4838,9 +4964,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", @@ -4851,9 +4977,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", @@ -5048,9 +5174,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +checksum = "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023" [[package]] name = "powerfmt" @@ -5179,7 +5305,7 @@ checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.0", + "bitflags 2.4.1", "lazy_static", "num-traits", "rand 0.8.5", @@ -5350,13 +5476,13 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cassowary", - "crossterm 0.27.0", + "crossterm", "indoc", "itertools 0.11.0", "paste", - "strum 0.25.0", + "strum", "unicode-segmentation", "unicode-width", ] @@ -5399,6 +5525,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -5426,13 +5561,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaac441002f822bc9705a681810a4dd2963094b9ca0ddc41cb963a4c189189ea" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.2", + "regex-automata 0.4.3", "regex-syntax 0.8.2", ] @@ -5447,9 +5582,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5011c7e263a695dc8ca064cddb722af1be54e517a280b12a5356f98366899e5d" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -5480,7 +5615,7 @@ version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "encoding_rs", "futures-core", @@ -5499,7 +5634,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.7", + "rustls 0.21.8", "rustls-native-certs", "rustls-pemfile", "serde", @@ -5567,11 +5702,11 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "auto_impl", - "bitflags 2.4.0", + "bitflags 2.4.1", "bitvec", "c-kzg", "enumn", - "hashbrown 0.14.1", + "hashbrown 0.14.2", "hex", "serde", ] @@ -5603,9 +5738,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.3" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babe80d5c16becf6594aa32ad2be8fe08498e7ae60b77de8df700e67f191d7e" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", "getrandom 0.2.10", @@ -5828,11 +5963,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.19" +version = "0.38.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" +checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -5853,12 +5988,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring 0.16.20", + "ring 0.17.5", "rustls-webpki", "sct", ] @@ -5881,17 +6016,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -5918,7 +6053,7 @@ version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "clipboard-win", "fd-lock", @@ -5961,9 +6096,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "cfg-if", "derive_more", @@ -5973,9 +6108,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6210,9 +6345,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -6427,9 +6562,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -6437,14 +6572,28 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", ] +[[package]] +name = "solang-parser" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c5ead679f39243782be98c2689e592fc0fc9489ca2e47c9e027bd30f948df31" +dependencies = [ + "itertools 0.10.5", + "lalrpop 0.19.12", + "lalrpop-util 0.19.12", + "phf 0.11.2", + "thiserror", + "unicode-xid", +] + [[package]] name = "solang-parser" version = "0.3.2" @@ -6452,8 +6601,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cb9fa2fa2fa6837be8a2495486ff92e3ffe68a99b6eeba288e139efdd842457" dependencies = [ "itertools 0.11.0", - "lalrpop", - "lalrpop-util", + "lalrpop 0.20.0", + "lalrpop-util 0.20.0", "phf 0.11.2", "thiserror", "unicode-xid", @@ -6525,39 +6674,20 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "strum" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" - [[package]] name = "strum" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" dependencies = [ - "strum_macros 0.25.2", -] - -[[package]] -name = "strum_macros" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", + "strum_macros", ] [[package]] name = "strum_macros" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck", "proc-macro2", @@ -6585,6 +6715,26 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +[[package]] +name = "svm-rs" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a04fc4f5cd35c700153b233f5575ccb3237e0f941fa5049d9e98254d10bf2fe" +dependencies = [ + "fs2", + "hex", + "home", + "once_cell", + "reqwest", + "semver 1.0.20", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", + "url", + "zip", +] + [[package]] name = "svm-rs" version = "0.3.0" @@ -6605,6 +6755,19 @@ dependencies = [ "zip", ] +[[package]] +name = "svm-rs-builds" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32deae08684d03d8a4ba99b8a3b0a1575364820339930f6fa2afdfa3a6d98c84" +dependencies = [ + "build_const", + "hex", + "semver 1.0.20", + "serde_json", + "svm-rs 0.2.23", +] + [[package]] name = "svm-rs-builds" version = "0.2.0" @@ -6615,7 +6778,7 @@ dependencies = [ "hex", "semver 1.0.20", "serde_json", - "svm-rs", + "svm-rs 0.3.0", ] [[package]] @@ -6643,8 +6806,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b837ef12ab88835251726eb12237655e61ec8dc8a280085d1961cdc3dfd047" +source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" dependencies = [ "paste", "proc-macro2", @@ -6766,18 +6928,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -6882,7 +7044,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.4", + "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", ] @@ -6925,7 +7087,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.8", "tokio", ] @@ -6961,7 +7123,7 @@ dependencies = [ "futures-util", "log", "native-tls", - "rustls 0.21.7", + "rustls 0.21.8", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -6994,22 +7156,22 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +checksum = "2ef75d881185fd2df4a040793927c153d863651108a93c7e17a9e591baa95cc6" dependencies = [ "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.2", + "toml_edit 0.20.4", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -7027,9 +7189,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "380f9e8120405471f7c9ad1860a713ef5ece6a670c7eae39225e477340f32fc4" dependencies = [ "indexmap 2.0.2", "serde", @@ -7085,7 +7247,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "bytes", "futures-core", "futures-util", @@ -7112,9 +7274,9 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.39" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite", @@ -7165,12 +7327,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -7278,7 +7440,7 @@ dependencies = [ "log", "native-tls", "rand 0.8.5", - "rustls 0.21.7", + "rustls 0.21.8", "sha1", "thiserror", "url", @@ -7653,7 +7815,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.3", + "ring 0.17.5", "untrusted 0.9.0", ] @@ -7715,6 +7877,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -7912,6 +8083,26 @@ version = "1.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" +[[package]] +name = "zerocopy" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index f3280a0591b57..72636473ad957 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,6 +159,11 @@ alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" +# solc utils +foundry-compilers = { version = "0.1", default-features = false } +# block explorer utils +foundry-block-explorers = { version = "0.1", default-features = false } + solang-parser = "=0.3.2" ## misc @@ -187,18 +192,21 @@ color-eyre = "0.6" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs" } - -# revm = { git = "https://github.com/bluealloy/revm/", branch = "main" } -# revm-interpreter = { git = "https://github.com/bluealloy/revm/", branch = "main" } -# revm-precompile = { git = "https://github.com/bluealloy/revm/", branch = "main" } -# revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "main" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } + +foundry-compilers = { git = "https://github.com/foundry-rs/compilers" } +foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers"} + +alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } +alloy-primitives = { git = "https://github.com/alloy-rs/core/" } +alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } +alloy-sol-types = { git = "https://github.com/alloy-rs/core/" } diff --git a/crates/abi/Cargo.toml b/crates/abi/Cargo.toml index 752cdb1328215..7d8e4432ad389 100644 --- a/crates/abi/Cargo.toml +++ b/crates/abi/Cargo.toml @@ -21,4 +21,4 @@ foundry-macros.workspace = true ethers-core.workspace = true ethers-contract = { workspace = true, features = ["abigen", "providers"] } -ethers-providers.workspace = true +ethers-providers.workspace = true \ No newline at end of file diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 412ad3650308a..533272f44675c 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -188,7 +188,7 @@ impl NodeArgs { .fork_block_number .or_else(|| self.evm_opts.fork_url.as_ref().and_then(|f| f.block)), ) - .with_fork_chain_id(self.evm_opts.fork_chain_id) + .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from)) .fork_request_timeout(self.evm_opts.fork_request_timeout.map(Duration::from_millis)) .fork_request_retries(self.evm_opts.fork_request_retries) .fork_retry_backoff(self.evm_opts.fork_retry_backoff.map(Duration::from_millis)) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 17a32a70fef0b..0f9f79ddb8002 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1156,7 +1156,7 @@ impl Backend { (halt_to_instruction_result(reason), gas_used, None) }, }; - let res = inspector.tracer.unwrap_or_default().traces.geth_trace(gas_used.into(), opts); + let res = inspector.tracer.unwrap_or_default().traces.geth_trace(rU256::from(gas_used), opts); trace!(target: "backend", "trace call return {:?} out: {:?} gas {} on block {}", exit_reason, out, gas_used, block_number); Ok(res) }) diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 39b885e47f5f2..4d693ed060119 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -16,7 +16,7 @@ use ethers::{ types::{ActionType, Bytes, GethDebugTracingOptions, TransactionReceipt, U256}, }; use foundry_evm::revm::{interpreter::InstructionResult, primitives::Env}; -use foundry_utils::types::ToEthers; +use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::RwLock; use std::{ collections::{HashMap, VecDeque}, @@ -406,7 +406,7 @@ impl MinedTransaction { } pub fn geth_trace(&self, opts: GethDebugTracingOptions) -> DefaultFrame { - self.info.traces.geth_trace(self.receipt.gas_used(), opts) + self.info.traces.geth_trace(self.receipt.gas_used().to_alloy(), opts) } } diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 04b1a85e16e8d..bd2567d749a56 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -1,7 +1,9 @@ +use alloy_primitives::U256 as rU256; use ethers::types::{ Action, Address, Block, Bytes, CallType, Trace, Transaction, TransactionReceipt, H256, U256, }; use foundry_evm::{executor::InstructionResult, CallKind}; +use foundry_utils::types::ToEthers; use futures::future::join_all; use serde::{de::DeserializeOwned, Serialize}; use serde_repr::Serialize_repr; @@ -239,35 +241,37 @@ impl OtsInternalOperation { .traces .arena .iter() - .filter_map(|node| match (node.kind(), node.status()) { - (CallKind::Call, _) if !node.trace.value.is_zero() => Some(Self { - r#type: OtsInternalOperationType::Transfer, - from: node.trace.caller, - to: node.trace.address, - value: node.trace.value, - }), - (CallKind::Create, _) => Some(Self { - r#type: OtsInternalOperationType::Create, - from: node.trace.caller, - to: node.trace.address, - value: node.trace.value, - }), - (CallKind::Create2, _) => Some(Self { - r#type: OtsInternalOperationType::Create2, - from: node.trace.caller, - to: node.trace.address, - value: node.trace.value, - }), - (_, InstructionResult::SelfDestruct) => { - Some(Self { - r#type: OtsInternalOperationType::SelfDestruct, - from: node.trace.address, - // the foundry CallTraceNode doesn't have a refund address - to: Default::default(), - value: node.trace.value, - }) + .filter_map(|node| { + match (node.kind(), node.status()) { + (CallKind::Call, _) if node.trace.value != rU256::ZERO => Some(Self { + r#type: OtsInternalOperationType::Transfer, + from: node.trace.caller.to_ethers(), + to: node.trace.address.to_ethers(), + value: node.trace.value.to_ethers(), + }), + (CallKind::Create, _) => Some(Self { + r#type: OtsInternalOperationType::Create, + from: node.trace.caller.to_ethers(), + to: node.trace.address.to_ethers(), + value: node.trace.value.to_ethers(), + }), + (CallKind::Create2, _) => Some(Self { + r#type: OtsInternalOperationType::Create2, + from: node.trace.caller.to_ethers(), + to: node.trace.address.to_ethers(), + value: node.trace.value.to_ethers(), + }), + (_, InstructionResult::SelfDestruct) => { + Some(Self { + r#type: OtsInternalOperationType::SelfDestruct, + from: node.trace.address.to_ethers(), + // the foundry CallTraceNode doesn't have a refund address + to: Default::default(), + value: node.trace.value.to_ethers(), + }) + } + _ => None, } - _ => None, }) .collect() } diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 1b0cbca9c38e0..a99a7c6466062 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -15,7 +15,11 @@ use ethers::{ }; use foundry_common::get_http_provider; use foundry_config::Config; -use foundry_utils::{rpc, rpc::next_http_rpc_endpoint, types::ToAlloy}; +use foundry_utils::{ + rpc, + rpc::next_http_rpc_endpoint, + types::{ToAlloy, ToEthers}, +}; use futures::StreamExt; use std::{sync::Arc, time::Duration}; @@ -160,8 +164,8 @@ async fn test_fork_eth_get_nonce() { } let addr = Config::DEFAULT_SENDER; - let api_nonce = api.transaction_count(addr, None).await.unwrap(); - let provider_nonce = provider.get_transaction_count(addr, None).await.unwrap(); + let api_nonce = api.transaction_count(addr.to_ethers(), None).await.unwrap(); + let provider_nonce = provider.get_transaction_count(addr.to_ethers(), None).await.unwrap(); assert_eq!(api_nonce, provider_nonce); } diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 0c9cb488b802e..e2dfb5358d558 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -27,6 +27,15 @@ foundry-common.workspace = true ethers-etherscan.workspace = true ethers-core.workspace = true ethers-providers.workspace = true + +alloy-primitives.workspace = true +alloy-json-abi.workspace = true +alloy-dyn-abi.workspace = true + +foundry-compilers = { workspace = true, default-features = false } +foundry-block-explorers = { workspace = true } + + chrono.workspace = true evm-disassembler = "0.3" eyre.workspace = true diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 261975a14f7cd..0a0c12738fe6b 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -10,6 +10,7 @@ use foundry_cli::{ utils, }; use foundry_config::{Chain, Config}; +use foundry_utils::types::ToEthers; use std::str::FromStr; /// CLI arguments for `cast access-list`. @@ -65,7 +66,8 @@ impl AccessListArgs { let chain = utils::get_chain(config.chain_id, &provider).await?; let sender = eth.wallet.sender().await; - access_list(&provider, sender, to, sig, args, data, tx, chain, block, to_json).await?; + access_list(&provider, sender.to_ethers(), to, sig, args, data, tx, chain, block, to_json) + .await?; Ok(()) } } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index bb7f05195e010..30c8fa4c20f88 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,18 +1,17 @@ +use alloy_primitives::U256; use cast::{Cast, TxBuilder}; use clap::Parser; -use ethers::{ - solc::EvmVersion, - types::{BlockId, NameOrAddress, U256}, -}; +use ethers::types::{BlockId, NameOrAddress}; use eyre::{Result, WrapErr}; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils::{self, handle_traces, parse_ether_value, TraceResult}, }; use foundry_common::runtime_client::RuntimeClient; +use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{executor::opts::EvmOpts, trace::TracingExecutor}; -use foundry_utils::types::ToAlloy; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::str::FromStr; type Provider = ethers::providers::Provider; @@ -131,7 +130,7 @@ impl CallArgs { let sender = eth.wallet.sender().await; let mut builder: TxBuilder<'_, Provider> = - TxBuilder::new(&provider, sender, to, chain, tx.legacy).await?; + TxBuilder::new(&provider, sender.to_ethers(), to, chain, tx.legacy).await?; builder .gas(tx.gas_limit) @@ -156,9 +155,9 @@ impl CallArgs { .await; let trace = match executor.deploy( - sender.to_alloy(), + sender, code.into_bytes().into(), - value.unwrap_or(U256::zero()).to_alloy(), + value.unwrap_or(U256::ZERO), None, ) { Ok(deploy_result) => TraceResult::from(deploy_result), @@ -193,7 +192,7 @@ impl CallArgs { let (tx, _) = builder.build(); let trace = TraceResult::from(executor.call_raw_committing( - sender.to_alloy(), + sender, tx.to_addr().copied().expect("an address to be here").to_alloy(), tx.data().cloned().unwrap_or_default().to_vec().into(), tx.value().copied().unwrap_or_default().to_alloy(), @@ -208,7 +207,7 @@ impl CallArgs { let builder_output: ( ethers::types::transaction::eip2718::TypedTransaction, - Option, + Option, ) = builder.build(); println!("{}", Cast::new(provider).call(builder_output, block).await?); diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 911292da6744f..fa4010bd0bdbb 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -1,10 +1,5 @@ -use cast::SimpleCast; +use alloy_primitives::{keccak256, Address, B256, U256}; use clap::Parser; -use ethers::{ - core::rand::thread_rng, - types::{Address, Bytes, H256, U256}, - utils::{get_create2_address_from_hash, keccak256}, -}; use eyre::{Result, WrapErr}; use rayon::prelude::*; use regex::RegexSetBuilder; @@ -114,7 +109,7 @@ impl Create2Args { let init_code_hash_bytes = hex::decode(init_code_hash)?; assert!(init_code_hash_bytes.len() == 32, "init code hash should be 32 bytes long"); a.copy_from_slice(&init_code_hash_bytes); - a + a.into() } else { keccak256(hex::decode(init_code)?) }; @@ -124,14 +119,9 @@ impl Create2Args { let (salt, addr) = std::iter::repeat(()) .par_bridge() .map(|_| { - let salt = H256::random_using(&mut thread_rng()); - let salt = Bytes::from(salt.to_fixed_bytes()); + let salt = B256::random(); - let addr = SimpleCast::to_checksum_address(&get_create2_address_from_hash( - deployer, - salt.clone(), - init_code_hash, - )); + let addr = deployer.create2(salt, init_code_hash).to_checksum(None); (salt, addr) }) @@ -142,7 +132,7 @@ impl Create2Args { }) .unwrap(); - let salt = U256::from(salt.to_vec().as_slice()); + let salt = U256::from_be_bytes(*salt); let address = Address::from_str(&addr).unwrap(); println!( @@ -165,8 +155,6 @@ fn get_regex_hex_string(s: String) -> Result { #[cfg(test)] mod tests { - use ethers::{abi::AbiEncode, utils::get_create2_address}; - use super::*; const DEPLOYER: &str = "0x4e59b44847b379578588920ca78fbf26c0b4956c"; @@ -304,11 +292,12 @@ mod tests { } fn verify_create2(deployer: Address, salt: U256, init_code: Vec) -> Address { - // let init_code_hash = keccak256(init_code); - get_create2_address(deployer, salt.encode(), init_code) + let init_code_hash = keccak256(init_code); + deployer.create2(salt.to_be_bytes(), init_code_hash) } fn verify_create2_hash(deployer: Address, salt: U256, init_code_hash: Vec) -> Address { - get_create2_address_from_hash(deployer, salt.encode(), init_code_hash) + let init_code_hash = B256::from_slice(&init_code_hash); + deployer.create2(salt.to_be_bytes(), init_code_hash) } } diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 8d2e002945731..d21eec50fd54a 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,6 +1,7 @@ +use alloy_primitives::U256; use cast::{Cast, TxBuilder}; use clap::Parser; -use ethers::types::{NameOrAddress, U256}; +use ethers::types::NameOrAddress; use eyre::Result; use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index 6f1ed25b02c52..188655ca3dae7 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -1,9 +1,11 @@ +use alloy_primitives::{U256, U64}; use cast::Cast; use clap::Parser; -use ethers::prelude::*; +use ethers_providers::Middleware; use eyre::Result; use foundry_cli::{opts::RpcOpts, utils}; use foundry_config::Config; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::join; /// CLI arguments for `cast find-block`. @@ -33,14 +35,14 @@ impl FindBlockArgs { let block_num = if ts_block_latest < ts_target { // If the most recent block's timestamp is below the target, return it - last_block_num + last_block_num.to_alloy() } else if ts_block_1 > ts_target { // If the target timestamp is below block 1's timestamp, return that U64::from(1_u64) } else { // Otherwise, find the block that is closest to the timestamp let mut low_block = U64::from(1_u64); // block 0 has a timestamp of 0: https://github.com/ethereum/go-ethereum/issues/17042#issuecomment-559414137 - let mut high_block = last_block_num; + let mut high_block = last_block_num.to_alloy(); let mut matching_block: Option = None; while high_block > low_block && matching_block.is_none() { // Get timestamp of middle block (this approach approach to avoids overflow) @@ -51,7 +53,7 @@ impl FindBlockArgs { .checked_div(U64::from(2_u64)) .unwrap(); let mid_block = high_block.checked_sub(high_minus_low_over_2).unwrap(); - let ts_mid_block = cast_provider.timestamp(mid_block).await?; + let ts_mid_block = cast_provider.timestamp(mid_block.to_ethers()).await?; // Check if we've found a match or should keep searching if ts_mid_block == ts_target { @@ -60,8 +62,8 @@ impl FindBlockArgs { // The target timestamp is in between these blocks. This rounds to the // highest block if timestamp is equidistant between blocks let res = join!( - cast_provider.timestamp(high_block), - cast_provider.timestamp(low_block) + cast_provider.timestamp(high_block.to_ethers()), + cast_provider.timestamp(low_block.to_ethers()) ); let ts_high = res.0.unwrap(); let ts_low = res.1.unwrap(); diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 3e43476d70d6a..94cf85b0bca89 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -4,12 +4,15 @@ use cast::Cast; use clap::Parser; use ethers::{providers::Middleware, types::NameOrAddress}; use ethers_core::{ - abi::{Address, Event, RawTopicFilter, Topic, TopicFilter}, - types::{BlockId, BlockNumber, Filter, FilterBlockOption, ValueOrArray, H256}, + abi::{ + token::{LenientTokenizer, StrictTokenizer, Tokenizer}, + Address, Event, HumanReadableParser, ParamType, RawTopicFilter, Token, Topic, TopicFilter, + }, + types::{BlockId, BlockNumber, Filter, FilterBlockOption, ValueOrArray, H256, U256}, }; -use eyre::Result; +use eyre::{Result, WrapErr}; use foundry_cli::{opts::EthereumOpts, utils}; -use foundry_common::abi::{get_event, parse_tokens}; + use foundry_config::Config; use itertools::Itertools; @@ -120,7 +123,7 @@ fn build_filter( let block_option = FilterBlockOption::Range { from_block, to_block }; let topic_filter = match sig_or_topic { // Try and parse the signature as an event signature - Some(sig_or_topic) => match get_event(sig_or_topic.as_str()) { + Some(sig_or_topic) => match HumanReadableParser::parse_event(sig_or_topic.as_str()) { Ok(event) => build_filter_event_sig(event, topics_or_args)?, Err(_) => { let topics = [vec![sig_or_topic], topics_or_args].concat(); @@ -167,7 +170,7 @@ fn build_filter_event_sig(event: Event, args: Vec) -> Result>(), true)?; + parse_params(with_args.clone().into_iter().map(|(_, p)| p).collect::>(), true)?; // Merge the inputs restoring the original ordering let mut tokens = with_args @@ -208,6 +211,78 @@ fn build_filter_topics(topics: Vec) -> Result }) } +fn parse_params<'a, I: IntoIterator>( + params: I, + lenient: bool, +) -> eyre::Result> { + let mut tokens = Vec::new(); + + for (param, value) in params.into_iter() { + let mut token = if lenient { + LenientTokenizer::tokenize(param, value) + } else { + StrictTokenizer::tokenize(param, value) + }; + if token.is_err() && value.starts_with("0x") { + match param { + ParamType::FixedBytes(32) => { + if value.len() < 66 { + let padded_value = [value, &"0".repeat(66 - value.len())].concat(); + token = if lenient { + LenientTokenizer::tokenize(param, &padded_value) + } else { + StrictTokenizer::tokenize(param, &padded_value) + }; + } + } + ParamType::Uint(_) => { + // try again if value is hex + if let Ok(value) = U256::from_str(value).map(|v| v.to_string()) { + token = if lenient { + LenientTokenizer::tokenize(param, &value) + } else { + StrictTokenizer::tokenize(param, &value) + }; + } + } + // TODO: Not sure what to do here. Put the no effect in for now, but that is not + // ideal. We could attempt massage for every value type? + _ => {} + } + } + + let token = token.map(sanitize_token).wrap_err_with(|| { + format!("Failed to parse `{value}`, expected value of type: {param}") + })?; + tokens.push(token); + } + Ok(tokens) +} + +pub fn sanitize_token(token: Token) -> Token { + match token { + Token::Array(tokens) => { + let mut sanitized = Vec::with_capacity(tokens.len()); + for token in tokens { + let token = match token { + Token::String(val) => { + let val = match val.as_str() { + // this is supposed to be an empty string + "\"\"" | "''" => String::new(), + _ => val, + }; + Token::String(val) + } + _ => sanitize_token(token), + }; + sanitized.push(token) + } + Token::Array(sanitized) + } + _ => token, + } +} + #[cfg(test)] mod tests { use std::str::FromStr; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 0d5833cdc116d..2ba8016ff1250 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,5 +1,5 @@ use clap::Parser; -use ethers::{prelude::Middleware, solc::EvmVersion}; +use ethers::prelude::Middleware; use eyre::{Result, WrapErr}; use foundry_cli::{ init_progress, @@ -8,6 +8,7 @@ use foundry_cli::{ utils::{handle_traces, TraceResult}, }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; +use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{ executor::{inspector::cheatcodes::util::configure_tx_env, opts::EvmOpts, EvmError}, @@ -98,7 +99,7 @@ impl RunArgs { .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; // check if the tx is a system transaction - if is_known_system_sender(tx.from) || + if is_known_system_sender(tx.from.to_alloy()) || tx.transaction_type.map(|ty| ty.as_u64()) == Some(SYSTEM_TRANSACTION_TYPE) { return Err(eyre::eyre!( @@ -143,7 +144,7 @@ impl RunArgs { for (index, tx) in block.transactions.into_iter().enumerate() { // System transactions such as on L2s don't contain any pricing info so we skip // them otherwise this would cause reverts - if is_known_system_sender(tx.from) || + if is_known_system_sender(tx.from.to_alloy()) || tx.transaction_type.map(|ty| ty.as_u64()) == Some(SYSTEM_TRANSACTION_TYPE) { diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 3313980c6cd09..e3fefd394c4e5 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -10,6 +10,7 @@ use foundry_cli::{ }; use foundry_common::cli_warn; use foundry_config::{Chain, Config}; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::str::FromStr; /// CLI arguments for `cast send`. @@ -132,12 +133,17 @@ impl SendTxArgs { } if resend { - tx.nonce = Some(provider.get_transaction_count(config.sender, None).await?); + tx.nonce = Some( + provider + .get_transaction_count(config.sender.to_ethers(), None) + .await? + .to_alloy(), + ); } cast_send( provider, - config.sender, + config.sender.to_ethers(), to, code, (sig, args), @@ -161,7 +167,7 @@ impl SendTxArgs { // prevent misconfigured hwlib from sending a transaction that defies // user-specified --from if let Some(specified_from) = eth.wallet.from { - if specified_from != from { + if specified_from != from.to_alloy() { eyre::bail!( "\ The specified sender via CLI/env vars does not match the sender configured via @@ -173,7 +179,7 @@ corresponds to the sender, or let foundry automatically detect it by not specify } if resend { - tx.nonce = Some(provider.get_transaction_count(from, None).await?); + tx.nonce = Some(provider.get_transaction_count(from, None).await?.to_alloy()); } let provider = provider.with_signer(signer); diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 22d85802cf799..2169df9835ace 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -1,12 +1,15 @@ use crate::opts::parse_slot; +use alloy_primitives::{B256, U256}; use cast::Cast; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; use ethers::{ - abi::ethabi::ethereum_types::BigEndianHash, etherscan::Client, prelude::*, - solc::artifacts::StorageLayout, + abi::ethabi::ethereum_types::BigEndianHash, + prelude::{BlockId, NameOrAddress}, + providers::Middleware, }; use eyre::Result; +use foundry_block_explorers::Client; use foundry_cli::{ opts::{CoreBuildArgs, EtherscanOpts, RpcOpts}, utils, @@ -16,10 +19,15 @@ use foundry_common::{ compile::{compile, etherscan_project, suppress_compile}, RetryProvider, }; +use foundry_compilers::{artifacts::StorageLayout, ConfigurableContractArtifact, Project, Solc}; use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, impl_figment_convert_cast, Config, }; +use foundry_utils::{ + resolve_addr, + types::{ToAlloy, ToEthers}, +}; use futures::future::join_all; use semver::Version; use std::str::FromStr; @@ -38,7 +46,7 @@ pub struct StorageArgs { /// The storage slot number. #[clap(value_parser = parse_slot)] - slot: Option, + slot: Option, /// The block height to query at. /// @@ -79,21 +87,18 @@ impl StorageArgs { let Self { address, slot, block, build, .. } = self; let provider = utils::get_provider(&config)?; - let address = match address { - NameOrAddress::Name(name) => provider.resolve_name(&name).await?, - NameOrAddress::Address(address) => address, - }; // Slot was provided, perform a simple RPC call if let Some(slot) = slot { let cast = Cast::new(provider); - println!("{}", cast.storage(address, slot, block).await?); + println!("{}", cast.storage(address, slot.to_ethers(), block).await?); return Ok(()) } // No slot was provided // Get deployed bytecode at given address - let address_code = provider.get_code(address, block).await?; + let address_code: alloy_primitives::Bytes = + provider.get_code(address.clone(), block).await?.0.into(); if address_code.is_empty() { eyre::bail!("Provided address has no deployed code and thus no storage"); } @@ -112,7 +117,7 @@ impl StorageArgs { let artifact = out.artifacts().find(|(_, artifact)| match_code(artifact).unwrap_or_default()); if let Some((_, artifact)) = artifact { - return fetch_and_print_storage(provider, address, artifact, true).await + return fetch_and_print_storage(provider, address.clone(), artifact, true).await } } @@ -127,7 +132,9 @@ impl StorageArgs { let chain = utils::get_chain(config.chain_id, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); let client = Client::new(chain.named()?, api_key)?; - let source = find_source(client, address).await?; + let addr = resolve_addr(address.clone(), Some(chain.named()?))?; + let addr = addr.as_address().ok_or(eyre::eyre!("Could not resolve address"))?.to_alloy(); + let source = find_source(client, addr).await?; let metadata = source.items.first().unwrap(); if metadata.is_vyper() { eyre::bail!("Contract at provided address is not a valid Solidity contract") @@ -180,7 +187,7 @@ impl StorageArgs { async fn fetch_and_print_storage( provider: RetryProvider, - address: Address, + address: NameOrAddress, artifact: &ConfigurableContractArtifact, pretty: bool, ) -> Result<()> { @@ -198,7 +205,7 @@ async fn fetch_and_print_storage( /// structures. async fn fetch_storage_values( provider: RetryProvider, - address: Address, + address: NameOrAddress, layout: &StorageLayout, ) -> Result> { // TODO: Batch request; handle array values @@ -206,8 +213,8 @@ async fn fetch_storage_values( .storage .iter() .map(|slot| { - let slot_h256 = H256::from_uint(&U256::from_dec_str(&slot.slot)?); - Ok(provider.get_storage_at(address, slot_h256, None)) + let slot_h256 = B256::from(U256::from_str(&slot.slot)?); + Ok(provider.get_storage_at(address.clone(), slot_h256.to_ethers(), None)) }) .collect::>()?; diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index ee6923a97420c..6f14585e52786 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,14 +1,15 @@ -use cast::SimpleCast; +use alloy_primitives::Address; use clap::Parser; use ethers::{ core::rand::thread_rng, signers::{LocalWallet, Signer}, - types::{transaction::eip712::TypedData, Address, Signature}, + types::{transaction::eip712::TypedData, Signature}, }; use eyre::{Context, Result}; use foundry_cli::opts::{RawWallet, Wallet}; use foundry_common::fs; use foundry_config::Config; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::path::Path; use yansi::Paint; @@ -140,11 +141,11 @@ impl WalletSubcommands { LocalWallet::new_keystore(&path, &mut rng, password, None)?; println!("Created new encrypted keystore file: {}", path.join(uuid).display()); - println!("Address: {}", SimpleCast::to_checksum_address(&wallet.address())); + println!("Address: {}", wallet.address().to_alloy().to_checksum(None)); } else { let wallet = LocalWallet::new(&mut rng); println!("Successfully created new keypair."); - println!("Address: {}", SimpleCast::to_checksum_address(&wallet.address())); + println!("Address: {}", wallet.address().to_alloy().to_checksum(None)); println!("Private key: 0x{}", hex::encode(wallet.signer().to_bytes())); } } @@ -161,7 +162,7 @@ impl WalletSubcommands { .signer(0) .await?; let addr = wallet.address(); - println!("{}", SimpleCast::to_checksum_address(&addr)); + println!("{}", addr.to_alloy().to_checksum(None)); } WalletSubcommands::Sign { message, data, from_file, wallet } => { let wallet = wallet.signer(0).await?; @@ -180,7 +181,7 @@ impl WalletSubcommands { println!("0x{sig}"); } WalletSubcommands::Verify { message, signature, address } => { - match signature.verify(Self::hex_str_to_bytes(&message)?, address) { + match signature.verify(Self::hex_str_to_bytes(&message)?, address.to_ethers()) { Ok(_) => { println!("Validation succeeded. Address {address} signed this message.") } diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 9ac378face556..c5762a7b24282 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,4 +1,3 @@ -use cast::SimpleCast; use clap::{builder::TypedValueParser, Parser}; use ethers::{ core::{k256::ecdsa::SigningKey, rand::thread_rng}, @@ -8,6 +7,7 @@ use ethers::{ }; use eyre::Result; +use foundry_utils::types::ToAlloy; use rayon::iter::{self, ParallelIterator}; use regex::Regex; use std::time::Instant; @@ -117,14 +117,11 @@ impl VanityArgs { timer.elapsed().as_secs(), if nonce.is_some() { "\nContract address: " } else { "" }, if nonce.is_some() { - SimpleCast::to_checksum_address(&get_contract_address( - wallet.address(), - nonce.unwrap(), - )) + wallet.address().to_alloy().create(nonce.unwrap()).to_checksum(None) } else { String::new() }, - SimpleCast::to_checksum_address(&wallet.address()), + wallet.address().to_alloy().to_checksum(None), hex::encode(wallet.signer().to_bytes()), ); diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index b2ac3a66716d3..3ce40ef6feb90 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -1,11 +1,10 @@ +use alloy_primitives::{keccak256, Address, B256}; use cast::{Cast, SimpleCast}; use clap::{CommandFactory, Parser}; use clap_complete::generate; use ethers::{ - core::types::{BlockId, BlockNumber::Latest, H256}, + core::types::{BlockId, BlockNumber::Latest}, providers::Middleware, - types::Address, - utils::keccak256, }; use eyre::{Result, WrapErr}; use foundry_cli::{handler, prompt, stdin, utils}; @@ -18,6 +17,7 @@ use foundry_common::{ }, }; use foundry_config::Config; +use foundry_utils::types::{ToAlloy, ToEthers}; use std::time::Instant; pub mod cmd; @@ -45,10 +45,10 @@ async fn main() -> Result<()> { println!("{}", SimpleCast::max_int(&r#type)?); } Subcommands::AddressZero => { - println!("{:?}", Address::zero()); + println!("{:?}", Address::ZERO); } Subcommands::HashZero => { - println!("{:?}", H256::zero()); + println!("{:?}", B256::ZERO); } // Conversions & transformations @@ -91,7 +91,7 @@ async fn main() -> Result<()> { } Subcommands::ToCheckSumAddress { address } => { let value = stdin::unwrap_line(address)?; - println!("{}", SimpleCast::to_checksum_address(&value)); + println!("{}", value.to_checksum(None)); } Subcommands::ToUint256 { value } => { let value = stdin::unwrap_line(value)?; @@ -262,7 +262,7 @@ async fn main() -> Result<()> { let address: Address = stdin::unwrap_line(address)?.parse()?; let computed = Cast::new(&provider).compute_address(address, nonce).await?; - println!("Computed Address: {}", SimpleCast::to_checksum_address(&computed)); + println!("Computed Address: {}", computed.to_checksum(None)); } Subcommands::Disassemble { bytecode } => { println!("{}", SimpleCast::disassemble(&bytecode)?); @@ -294,7 +294,9 @@ async fn main() -> Result<()> { Subcommands::Proof { address, slots, rpc, block } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - let value = provider.get_proof(address, slots, block).await?; + let value = provider + .get_proof(address, slots.into_iter().map(|s| s.to_ethers()).collect(), block) + .await?; println!("{}", serde_json::to_string(&value)?); } Subcommands::Rpc(cmd) => cmd.run().await?, @@ -401,9 +403,9 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let who = stdin::unwrap_line(who)?; - let name = provider.lookup_address(who).await?; + let name = provider.lookup_address(who.to_ethers()).await?; if verify { - let address = provider.resolve_name(&name).await?; + let address = provider.resolve_name(&name).await?.to_alloy(); eyre::ensure!( address == who, "Forward lookup verification failed: got `{name:?}`, expected `{who:?}`" @@ -424,7 +426,7 @@ async fn main() -> Result<()> { "forward lookup verification failed. got {name}, expected {who}" ); } - println!("{}", SimpleCast::to_checksum_address(&address)); + println!("{}", address.to_alloy().to_checksum(None)); } // Misc diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 63890c2941576..39ac4364045c1 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -3,16 +3,12 @@ use crate::cmd::{ estimate::EstimateArgs, find_block::FindBlockArgs, interface::InterfaceArgs, logs::LogsArgs, rpc::RpcArgs, run::RunArgs, send::SendTxArgs, storage::StorageArgs, wallet::WalletSubcommands, }; +use alloy_primitives::{Address, B256, U256}; use clap::{Parser, Subcommand, ValueHint}; -use ethers::{ - abi::ethabi::ethereum_types::BigEndianHash, - types::{serde_helpers::Numeric, Address, BlockId, NameOrAddress, H256, U256}, -}; +use ethers::types::{BlockId, NameOrAddress}; use eyre::Result; -use foundry_cli::{ - opts::{EtherscanOpts, RpcOpts}, - utils::parse_u256, -}; +use foundry_cli::opts::{EtherscanOpts, RpcOpts}; +use foundry_common::serde_helpers::Numeric; use std::{path::PathBuf, str::FromStr}; const VERSION_MESSAGE: &str = concat!( @@ -371,7 +367,7 @@ pub enum Subcommands { address: Option, /// The nonce of the deployer address. - #[clap(long, value_parser = parse_u256)] + #[clap(long)] nonce: Option, #[clap(flatten)] @@ -743,7 +739,7 @@ pub enum Subcommands { /// The storage slot numbers (hex or decimal). #[clap(value_parser = parse_slot)] - slots: Vec, + slots: Vec, /// The block height to query at. /// @@ -877,10 +873,10 @@ pub struct ToBaseArgs { pub base_in: Option, } -pub fn parse_slot(s: &str) -> Result { - Numeric::from_str(s) - .map_err(|e| eyre::eyre!("Could not parse slot number: {e}")) - .map(|n| H256::from_uint(&n.into())) +pub fn parse_slot(s: &str) -> Result { + let slot = Numeric::from_str(s).map_err(|e| eyre::eyre!("Could not parse slot number: {e}"))?; + let slot: U256 = slot.into(); + Ok(B256::from(slot)) } #[cfg(test)] diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 659886678984d..4cfe2dc04de21 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1,23 +1,24 @@ use crate::rlp_converter::Item; +use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; +use alloy_json_abi::Function; +use alloy_primitives::{Address, I256, U256}; use base::{Base, NumberWithBase, ToBase}; use chrono::NaiveDateTime; use ethers_core::{ - abi::{ - token::{LenientTokenizer, Tokenizer}, - Function, HumanReadableParser, ParamType, RawAbi, Token, - }, + abi::RawAbi, types::{transaction::eip2718::TypedTransaction, Chain, *}, utils::{ format_bytes32_string, format_units, get_contract_address, keccak256, parse_bytes32_string, parse_units, rlp, Units, }, }; -use ethers_etherscan::{errors::EtherscanError, Client}; use ethers_providers::{Middleware, PendingTransaction, PubsubClient}; use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; -use eyre::{Context, Result}; -use foundry_common::{abi::encode_args, fmt::*, TransactionReceiptWithRevertReason}; +use eyre::{Context, ContextCompat, Result}; +use foundry_block_explorers::{errors::EtherscanError, Client}; +use foundry_common::{abi::encode_function_args, fmt::*, TransactionReceiptWithRevertReason}; pub use foundry_evm::*; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; pub use rusoto_core::{ @@ -105,7 +106,7 @@ where if let Some(func) = func { // decode args into tokens - decoded = match func.decode_output(res.as_ref()) { + decoded = match func.abi_decode_output(res.as_ref(), false) { Ok(decoded) => decoded, Err(err) => { // ensure the address is a contract @@ -177,7 +178,7 @@ where let mut s = vec![format!("gas used: {}", access_list.gas_used), "access list:".to_string()]; for al in access_list.access_list.0 { - s.push(format!("- address: {}", SimpleCast::to_checksum_address(&al.address))); + s.push(format!("- address: {}", &al.address.to_alloy().to_checksum(None))); if !al.storage_keys.is_empty() { s.push(" keys:".to_string()); for key in al.storage_keys { @@ -196,7 +197,7 @@ where who: T, block: Option, ) -> Result { - Ok(self.provider.get_balance(who, block).await?) + Ok(self.provider.get_balance(who, block).await?.to_alloy()) } /// Sends a transaction to the specified address @@ -205,20 +206,21 @@ where /// /// ```no_run /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Address, Chain, U256}; + /// use ethers_core::types::{Chain, Address as eAddress}; + /// use alloy_primitives::{Address, U256}; /// use ethers_providers::{Provider, Http}; /// use std::{str::FromStr, convert::TryFrom}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let from = "vitalik.eth"; - /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; + /// let to = eAddress::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; /// let sig = "greet(string)()"; /// let args = vec!["hello".to_owned()]; /// let gas = U256::from_str("200000").unwrap(); /// let value = U256::from_str("1").unwrap(); /// let nonce = U256::from_str("1").unwrap(); - /// let mut builder = TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; + /// let mut builder = TxBuilder::new(&provider, from, Some(to), Chain::Mainnet, false).await?; /// builder /// .set_args(sig, args).await? /// .set_gas(gas) @@ -274,13 +276,14 @@ where /// /// ```no_run /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Address, Chain, U256}; + /// use ethers_core::types::{Address, Chain}; + /// use alloy_primitives::U256; /// use ethers_providers::{Provider, Http}; /// use std::{str::FromStr, convert::TryFrom}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; - /// let from = "vitalik.eth"; + /// let from = Address::from_str("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")?; /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; /// let sig = "greet(string)()"; /// let args = vec!["5".to_owned()]; @@ -301,7 +304,7 @@ where let res = self.provider.estimate_gas(tx, None).await?; - Ok::<_, eyre::Error>(res) + Ok::<_, eyre::Error>(res.to_alloy()) } /// # Example @@ -460,7 +463,7 @@ where } pub async fn chain_id(&self) -> Result { - Ok(self.provider.get_chainid().await?) + Ok(self.provider.get_chainid().await?.to_alloy()) } pub async fn block_number(&self) -> Result { @@ -468,7 +471,7 @@ where } pub async fn gas_price(&self) -> Result { - Ok(self.provider.get_gas_price().await?) + Ok(self.provider.get_gas_price().await?.to_alloy()) } /// # Example @@ -476,13 +479,13 @@ where /// ```no_run /// use cast::Cast; /// use ethers_providers::{Provider, Http}; - /// use ethers_core::types::Address; + /// use ethers::types::NameOrAddress; /// use std::{str::FromStr, convert::TryFrom}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let cast = Cast::new(provider); - /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; + /// let addr = NameOrAddress::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; /// let nonce = cast.nonce(addr, None).await?; /// println!("{}", nonce); /// # Ok(()) @@ -493,7 +496,7 @@ where who: T, block: Option, ) -> Result { - Ok(self.provider.get_transaction_count(who, block).await?) + Ok(self.provider.get_transaction_count(who, block).await?.to_alloy()) } /// # Example @@ -559,14 +562,16 @@ where /// ```no_run /// use cast::Cast; /// use ethers_providers::{Provider, Http}; - /// use ethers_core::types::Address; + /// use ethers::types::NameOrAddress; + /// use alloy_primitives::{Address, U256}; /// use std::{str::FromStr, convert::TryFrom}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let cast = Cast::new(provider); - /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; - /// let nonce = cast.nonce(addr, None).await? + 5; + /// let nonce_addr = NameOrAddress::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; + /// let addr = Address::from_str("7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; + /// let nonce = cast.nonce(nonce_addr, None).await? + U256::from(5); /// let computed_address = cast.compute_address(addr, Some(nonce)).await?; /// println!("Computed address for address {} with nonce {}: {}", addr, nonce, computed_address); /// let computed_address_no_nonce = cast.compute_address(addr, None).await?; @@ -582,10 +587,10 @@ where let unpacked = if let Some(n) = nonce { n } else { - self.provider.get_transaction_count(address.into(), None).await? + self.provider.get_transaction_count(address.into().to_ethers(), None).await?.to_alloy() }; - Ok(get_contract_address(address, unpacked)) + Ok(get_contract_address(address.into().to_ethers(), unpacked.to_ethers()).to_alloy()) } /// # Example @@ -1011,24 +1016,23 @@ impl SimpleCast { } fn max_min_int(s: &str) -> Result { - let ty = HumanReadableParser::parse_type(s) - .wrap_err("Invalid type, expected `(u)int`")?; + let ty = DynSolType::parse(s).wrap_err("Invalid type, expected `(u)int`")?; match ty { - ParamType::Int(n) => { - let mask = U256::one() << U256::from(n - 1); - let max = (U256::MAX & mask) - 1; + DynSolType::Int(n) => { + let mask = U256::from(1).wrapping_shl(n - 1); + let max = (U256::MAX & mask).saturating_sub(U256::from(1)); if MAX { Ok(max.to_string()) } else { - let min = I256::from_raw(max).wrapping_neg() + I256::minus_one(); + let min = I256::from_raw(max).wrapping_neg() + I256::MINUS_ONE; Ok(min.to_string()) } } - ParamType::Uint(n) => { + DynSolType::Uint(n) => { if MAX { let mut max = U256::MAX; if n < 255 { - max &= U256::one() << U256::from(n); + max &= U256::from(1).wrapping_shl(n); } Ok(max.to_string()) } else { @@ -1173,28 +1177,6 @@ impl SimpleCast { format!("0x{out}") } - /// Converts an Ethereum address to its checksum format - /// according to [EIP-55](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md) - /// - /// # Example - /// - /// ``` - /// use cast::SimpleCast as Cast; - /// use ethers_core::types::Address; - /// use std::str::FromStr; - /// - /// # fn main() -> eyre::Result<()> { - /// let addr = Address::from_str("0xb7e390864a90b7b923c9f9310c6f98aafe43f707")?; - /// let addr = Cast::to_checksum_address(&addr); - /// assert_eq!(addr, "0xB7e390864a90b7b923C9f9310C6F98aafE43F707"); - /// - /// # Ok(()) - /// # } - /// ``` - pub fn to_checksum_address(address: &Address) -> String { - ethers_core::utils::to_checksum(address, None) - } - /// Converts a number into uint256 hex string with 0x prefix /// /// # Example @@ -1265,28 +1247,33 @@ impl SimpleCast { /// } /// ``` pub fn to_unit(value: &str, unit: &str) -> Result { - let value = U256::from(LenientTokenizer::tokenize_uint(value)?); + let value = DynSolType::coerce_str(&DynSolType::Uint(256), value)? + .as_uint() + .wrap_err("Could not convert to uint")? + .0; Ok(match unit { - "eth" | "ether" => ethers_core::utils::format_units(value, 18)? + "eth" | "ether" => foundry_common::units::format_units(value, 18)? .trim_end_matches(".000000000000000000") .to_string(), - "milli" | "milliether" => ethers_core::utils::format_units(value, 15)? + "milli" | "milliether" => foundry_common::units::format_units(value, 15)? .trim_end_matches(".000000000000000") .to_string(), - "micro" | "microether" => ethers_core::utils::format_units(value, 12)? + "micro" | "microether" => foundry_common::units::format_units(value, 12)? .trim_end_matches(".000000000000") .to_string(), - "gwei" | "nano" | "nanoether" => ethers_core::utils::format_units(value, 9)? + "gwei" | "nano" | "nanoether" => foundry_common::units::format_units(value, 9)? .trim_end_matches(".000000000") .to_string(), - "mwei" | "mega" | "megaether" => { - ethers_core::utils::format_units(value, 6)?.trim_end_matches(".000000").to_string() - } + "mwei" | "mega" | "megaether" => foundry_common::units::format_units(value, 6)? + .trim_end_matches(".000000") + .to_string(), "kwei" | "kilo" | "kiloether" => { - ethers_core::utils::format_units(value, 3)?.trim_end_matches(".000").to_string() + foundry_common::units::format_units(value, 3)?.trim_end_matches(".000").to_string() + } + "wei" => { + foundry_common::units::format_units(value, 0)?.trim_end_matches(".0").to_string() } - "wei" => ethers_core::utils::format_units(value, 0)?.trim_end_matches(".0").to_string(), _ => eyre::bail!("invalid unit: \"{}\"", unit), }) } @@ -1485,7 +1472,7 @@ impl SimpleCast { let lowercase_address_string = format!("0x{s}"); let lowercase_address = Address::from_str(&lowercase_address_string)?; - Ok(ethers_core::utils::to_checksum(&lowercase_address, None)) + Ok(lowercase_address.to_checksum(None)) } /// Decodes abi-encoded hex input or output @@ -1496,6 +1483,7 @@ impl SimpleCast { /// /// ``` /// use cast::SimpleCast as Cast; + /// use hex; /// /// fn main() -> eyre::Result<()> { /// // Passing `input = false` will decode the data as the output type. @@ -1503,7 +1491,7 @@ impl SimpleCast { /// // you could also pass `balanceOf()(uint256)` and it'd still work. /// let data = "0x0000000000000000000000000000000000000000000000000000000000000001"; /// let sig = "balanceOf(address, uint256)(uint256)"; - /// let decoded = Cast::abi_decode(sig, data, false)?[0].to_string(); + /// let decoded = Cast::abi_decode(sig, data, false)?[0].as_uint().unwrap().0.to_string(); /// assert_eq!(decoded, "1"); /// /// // Passing `input = true` will decode the data with the input function signature. @@ -1511,18 +1499,27 @@ impl SimpleCast { /// let data = "0x0000000000000000000000008dbd1b711dc621e1404633da156fcc779e1c6f3e000000000000000000000000d9f3c9cc99548bf3b44a43e0a2d07399eb918adc000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000"; /// let sig = "safeTransferFrom(address, address, uint256, uint256, bytes)"; /// let decoded = Cast::abi_decode(sig, data, true)?; - /// let decoded = decoded.iter().map(ToString::to_string).collect::>(); + /// let decoded = [ + /// decoded[0].as_address().unwrap().to_string().to_lowercase(), + /// decoded[1].as_address().unwrap().to_string().to_lowercase(), + /// decoded[2].as_uint().unwrap().0.to_string(), + /// decoded[3].as_uint().unwrap().0.to_string(), + /// hex::encode(decoded[4].as_bytes().unwrap()) + /// ] + /// .into_iter() + /// .collect::>(); + /// /// assert_eq!( /// decoded, - /// vec!["8dbd1b711dc621e1404633da156fcc779e1c6f3e", "d9f3c9cc99548bf3b44a43e0a2d07399eb918adc", "2a", "1", ""] + /// vec!["0x8dbd1b711dc621e1404633da156fcc779e1c6f3e", "0xd9f3c9cc99548bf3b44a43e0a2d07399eb918adc", "42", "1", ""] /// ); /// /// /// # Ok(()) /// } /// ``` - pub fn abi_decode(sig: &str, calldata: &str, input: bool) -> Result> { - foundry_common::abi::abi_decode(sig, calldata, input, false) + pub fn abi_decode(sig: &str, calldata: &str, input: bool) -> Result> { + foundry_common::abi::abi_decode_calldata(sig, calldata, input, false) } /// Decodes calldata-encoded hex input or output @@ -1533,6 +1530,7 @@ impl SimpleCast { /// /// ``` /// use cast::SimpleCast as Cast; + /// use hex; /// /// fn main() -> eyre::Result<()> { /// // Passing `input = false` will decode the data as the output type. @@ -1540,25 +1538,33 @@ impl SimpleCast { /// // you could also pass `balanceOf()(uint256)` and it'd still work. /// let data = "0x0000000000000000000000000000000000000000000000000000000000000001"; /// let sig = "balanceOf(address, uint256)(uint256)"; - /// let decoded = Cast::calldata_decode(sig, data, false)?[0].to_string(); + /// let decoded = Cast::calldata_decode(sig, data, false)?[0].as_uint().unwrap().0.to_string(); /// assert_eq!(decoded, "1"); /// /// // Passing `input = true` will decode the data with the input function signature. /// let data = "0xf242432a0000000000000000000000008dbd1b711dc621e1404633da156fcc779e1c6f3e000000000000000000000000d9f3c9cc99548bf3b44a43e0a2d07399eb918adc000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000"; /// let sig = "safeTransferFrom(address, address, uint256, uint256, bytes)"; /// let decoded = Cast::calldata_decode(sig, data, true)?; - /// let decoded = decoded.iter().map(ToString::to_string).collect::>(); + /// let decoded = [ + /// decoded[0].as_address().unwrap().to_string().to_lowercase(), + /// decoded[1].as_address().unwrap().to_string().to_lowercase(), + /// decoded[2].as_uint().unwrap().0.to_string(), + /// decoded[3].as_uint().unwrap().0.to_string(), + /// hex::encode(decoded[4].as_bytes().unwrap()), + /// ] + /// .into_iter() + /// .collect::>(); /// assert_eq!( /// decoded, - /// vec!["8dbd1b711dc621e1404633da156fcc779e1c6f3e", "d9f3c9cc99548bf3b44a43e0a2d07399eb918adc", "2a", "1", ""] + /// vec!["0x8dbd1b711dc621e1404633da156fcc779e1c6f3e", "0xd9f3c9cc99548bf3b44a43e0a2d07399eb918adc", "42", "1", ""] /// ); /// /// /// # Ok(()) /// } /// ``` - pub fn calldata_decode(sig: &str, calldata: &str, input: bool) -> Result> { - foundry_common::abi::abi_decode(sig, calldata, input, true) + pub fn calldata_decode(sig: &str, calldata: &str, input: bool) -> Result> { + foundry_common::abi::abi_decode_calldata(sig, calldata, input, true) } /// Performs ABI encoding based off of the function signature. Does not include @@ -1582,28 +1588,13 @@ impl SimpleCast { /// # } /// ``` pub fn abi_encode(sig: &str, args: &[impl AsRef]) -> Result { - let func = match HumanReadableParser::parse_function(sig) { + let func = match Function::parse(sig) { Ok(func) => func, Err(err) => { - if let Ok(constructor) = HumanReadableParser::parse_constructor(sig) { - #[allow(deprecated)] - Function { - name: "constructor".to_string(), - inputs: constructor.inputs, - outputs: vec![], - constant: None, - state_mutability: Default::default(), - } - } else { - // we return the `Function` parse error as this case is more likely - eyre::bail!("Could not process human-readable ABI. Please check if you've left the parenthesis unclosed or if some type is incomplete.\nError:\n{}", err) - // return Err(err.into()).wrap_err("Could not process human-readable ABI. Please - // check if you've left the parenthesis unclosed or if some type is - // incomplete.") - } + eyre::bail!("Could not process human-readable ABI. Please check if you've left the parenthesis unclosed or if some type is incomplete.\nError:\n{}", err) } }; - let calldata = match encode_args(&func, args) { + let calldata = match encode_function_args(&func, args) { Ok(res) => hex::encode(res), Err(e) => eyre::bail!("Could not ABI encode the function and arguments. Did you pass in the right types?\nError\n{}", e), }; @@ -1620,15 +1611,15 @@ impl SimpleCast { /// /// # fn main() -> eyre::Result<()> { /// assert_eq!( - /// "0xb3de648b0000000000000000000000000000000000000000000000000000000000000001", + /// "0x693c61390000000000000000000000000000000000000000000000000000000000000001", /// Cast::calldata_encode("f(uint a)", &["1"]).unwrap().as_str() /// ); /// # Ok(()) /// # } /// ``` pub fn calldata_encode(sig: impl AsRef, args: &[impl AsRef]) -> Result { - let func = HumanReadableParser::parse_function(sig.as_ref())?; - let calldata = encode_args(&func, args)?; + let func = Function::parse(sig.as_ref())?; + let calldata = encode_function_args(&func, args)?; Ok(hex::encode_prefixed(calldata)) } @@ -1944,8 +1935,8 @@ impl SimpleCast { eyre::bail!("Number of leading zeroes must not be greater than 4"); } if optimize == 0 { - let selector = HumanReadableParser::parse_function(signature)?.short_signature(); - return Ok((hex::encode_prefixed(selector), String::from(signature))) + let selector = Function::parse(signature)?.selector(); + return Ok((selector.to_string(), String::from(signature))) } let Some((name, params)) = signature.split_once('(') else { eyre::bail!("Invalid signature"); @@ -2009,11 +2000,25 @@ fn strip_0x(s: &str) -> &str { #[cfg(test)] mod tests { use super::SimpleCast as Cast; + use alloy_primitives::hex; + + #[test] + fn simple_selector() { + assert_eq!("0xc2985578", Cast::get_selector("foo()", None).unwrap().0.as_str()) + } + + #[test] + fn selector_with_arg() { + assert_eq!( + "0xbd0d639f", + Cast::get_selector("foo(address,uint256)", None).unwrap().0.as_str() + ) + } #[test] fn calldata_uint() { assert_eq!( - "0xb3de648b0000000000000000000000000000000000000000000000000000000000000001", + "0x693c61390000000000000000000000000000000000000000000000000000000000000001", Cast::calldata_encode("f(uint a)", &["1"]).unwrap().as_str() ); } @@ -2039,18 +2044,42 @@ mod tests { fn abi_decode() { let data = "0x0000000000000000000000000000000000000000000000000000000000000001"; let sig = "balanceOf(address, uint256)(uint256)"; - assert_eq!("1", Cast::abi_decode(sig, data, false).unwrap()[0].to_string()); + assert_eq!( + "1", + Cast::abi_decode(sig, data, false).unwrap()[0].as_uint().unwrap().0.to_string() + ); let data = "0x0000000000000000000000008dbd1b711dc621e1404633da156fcc779e1c6f3e000000000000000000000000d9f3c9cc99548bf3b44a43e0a2d07399eb918adc000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000"; let sig = "safeTransferFrom(address,address,uint256,uint256,bytes)"; let decoded = Cast::abi_decode(sig, data, true).unwrap(); - let decoded = decoded.iter().map(ToString::to_string).collect::>(); + let decoded = [ + decoded[0] + .as_address() + .unwrap() + .to_string() + .strip_prefix("0x") + .unwrap() + .to_owned() + .to_lowercase(), + decoded[1] + .as_address() + .unwrap() + .to_string() + .strip_prefix("0x") + .unwrap() + .to_owned() + .to_lowercase(), + decoded[2].as_uint().unwrap().0.to_string(), + decoded[3].as_uint().unwrap().0.to_string(), + hex::encode(decoded[4].as_bytes().unwrap()), + ] + .to_vec(); assert_eq!( decoded, vec![ "8dbd1b711dc621e1404633da156fcc779e1c6f3e", "d9f3c9cc99548bf3b44a43e0a2d07399eb918adc", - "2a", + "42", "1", "" ] @@ -2061,7 +2090,8 @@ mod tests { fn calldata_decode() { let data = "0x0000000000000000000000000000000000000000000000000000000000000001"; let sig = "balanceOf(address, uint256)(uint256)"; - let decoded = Cast::calldata_decode(sig, data, false).unwrap()[0].to_string(); + let decoded = + Cast::calldata_decode(sig, data, false).unwrap()[0].as_uint().unwrap().0.to_string(); assert_eq!(decoded, "1"); // Passing `input = true` will decode the data with the input function signature. @@ -2069,13 +2099,21 @@ mod tests { let data = "0xf242432a0000000000000000000000008dbd1b711dc621e1404633da156fcc779e1c6f3e000000000000000000000000d9f3c9cc99548bf3b44a43e0a2d07399eb918adc000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000"; let sig = "safeTransferFrom(address, address, uint256, uint256, bytes)"; let decoded = Cast::calldata_decode(sig, data, true).unwrap(); - let decoded = decoded.iter().map(ToString::to_string).collect::>(); + let decoded = [ + decoded[0].as_address().unwrap().to_string().to_lowercase(), + decoded[1].as_address().unwrap().to_string().to_lowercase(), + decoded[2].as_uint().unwrap().0.to_string(), + decoded[3].as_uint().unwrap().0.to_string(), + hex::encode(decoded[4].as_bytes().unwrap()), + ] + .into_iter() + .collect::>(); assert_eq!( decoded, vec![ - "8dbd1b711dc621e1404633da156fcc779e1c6f3e", - "d9f3c9cc99548bf3b44a43e0a2d07399eb918adc", - "2a", + "0x8dbd1b711dc621e1404633da156fcc779e1c6f3e", + "0xd9f3c9cc99548bf3b44a43e0a2d07399eb918adc", + "42", "1", "" ] diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs index 2de54f1e4c6f8..2b376edff4225 100644 --- a/crates/cast/src/tx.rs +++ b/crates/cast/src/tx.rs @@ -1,19 +1,19 @@ use crate::errors::FunctionSignatureError; -use ethers_core::{ - abi::Function, - types::{ - transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, NameOrAddress, - TransactionRequest, H160, U256, - }, +use alloy_json_abi::Function; +use alloy_primitives::{Address, U256}; +use ethers_core::types::{ + transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, NameOrAddress, + TransactionRequest, }; use ethers_providers::Middleware; use eyre::{eyre, Result}; -use foundry_common::abi::{encode_args, get_func, get_func_etherscan}; +use foundry_common::abi::{encode_function_args, get_func, get_func_etherscan}; use foundry_config::Chain; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future::join_all; pub struct TxBuilder<'a, M: Middleware> { - to: Option, + to: Option
, chain: Chain, tx: TypedTransaction, func: Option, @@ -27,7 +27,8 @@ pub type TxBuilderPeekOutput<'a> = (&'a TypedTransaction, &'a Option); /// Transaction builder /// ``` /// async fn foo() -> eyre::Result<()> { -/// use ethers_core::types::{Chain, U256}; +/// use ethers_core::types::Chain; +/// use alloy_primitives::U256; /// use cast::TxBuilder; /// let provider = ethers_providers::test_provider::MAINNET.provider(); /// let mut builder = TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await?; @@ -55,16 +56,16 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { let from_addr = resolve_ens(provider, from).await?; let mut tx: TypedTransaction = if chain.is_legacy() || legacy { - TransactionRequest::new().from(from_addr).chain_id(chain.id()).into() + TransactionRequest::new().from(from_addr.to_ethers()).chain_id(chain.id()).into() } else { - Eip1559TransactionRequest::new().from(from_addr).chain_id(chain.id()).into() + Eip1559TransactionRequest::new().from(from_addr.to_ethers()).chain_id(chain.id()).into() }; let to_addr = if let Some(to) = to { let addr = resolve_ens(provider, foundry_utils::resolve_addr(to, chain.try_into().ok())?) .await?; - tx.set_to(addr); + tx.set_to(addr.to_ethers()); Some(addr) } else { None @@ -74,7 +75,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { /// Set gas for tx pub fn set_gas(&mut self, v: U256) -> &mut Self { - self.tx.set_gas(v); + self.tx.set_gas(v.to_ethers()); self } @@ -88,7 +89,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { /// Set gas price pub fn set_gas_price(&mut self, v: U256) -> &mut Self { - self.tx.set_gas_price(v); + self.tx.set_gas_price(v.to_ethers()); self } @@ -103,7 +104,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { /// Set priority gas price pub fn set_priority_gas_price(&mut self, v: U256) -> &mut Self { if let TypedTransaction::Eip1559(tx) = &mut self.tx { - tx.max_priority_fee_per_gas = Some(v) + tx.max_priority_fee_per_gas = Some(v.to_ethers()) } self } @@ -118,7 +119,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { /// Set value pub fn set_value(&mut self, v: U256) -> &mut Self { - self.tx.set_value(v); + self.tx.set_value(v.to_ethers()); self } @@ -132,7 +133,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { /// Set nonce pub fn set_nonce(&mut self, v: U256) -> &mut Self { - self.tx.set_nonce(v); + self.tx.set_nonce(v.to_ethers()); self } @@ -200,7 +201,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { if sig.starts_with("0x") { Ok((hex::decode(sig)?, func)) } else { - Ok((encode_args(&func, &args)?, func)) + Ok((encode_function_args(&func, &args)?, func)) } } @@ -244,13 +245,16 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { } } -async fn resolve_ens>(provider: &M, addr: T) -> Result { +async fn resolve_ens>( + provider: &M, + addr: T, +) -> Result
{ let from_addr = match addr.into() { NameOrAddress::Name(ref ens_name) => provider.resolve_name(ens_name).await, NameOrAddress::Address(addr) => Ok(addr), } .map_err(|x| eyre!("Failed to resolve ENS name: {x}"))?; - Ok(from_addr) + Ok(from_addr.to_alloy()) } async fn resolve_name_args(args: &[String], provider: &M) -> Vec { @@ -271,11 +275,11 @@ async fn resolve_name_args(args: &[String], provider: &M) -> Vec< #[cfg(test)] mod tests { use crate::TxBuilder; + use alloy_primitives::{Address, U256}; use async_trait::async_trait; - use ethers_core::types::{ - transaction::eip2718::TypedTransaction, Address, Chain, NameOrAddress, H160, U256, - }; + use ethers_core::types::{transaction::eip2718::TypedTransaction, Chain, NameOrAddress, H160}; use ethers_providers::{JsonRpcClient, Middleware, ProviderError}; + use foundry_utils::types::ToEthers; use serde::{de::DeserializeOwned, Serialize}; use std::str::FromStr; @@ -309,7 +313,7 @@ mod tests { self } - async fn resolve_name(&self, ens_name: &str) -> Result { + async fn resolve_name(&self, ens_name: &str) -> Result { match ens_name { "a.eth" => Ok(H160::from_str(ADDR_1).unwrap()), "b.eth" => Ok(H160::from_str(ADDR_2).unwrap()), @@ -323,8 +327,11 @@ mod tests { let builder = TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await?; let (tx, args) = builder.build(); - assert_eq!(*tx.from().unwrap(), H160::from_str(ADDR_1).unwrap()); - assert_eq!(*tx.to().unwrap(), NameOrAddress::Address(H160::from_str(ADDR_2).unwrap())); + assert_eq!(*tx.from().unwrap(), Address::from_str(ADDR_1).unwrap().to_ethers()); + assert_eq!( + *tx.to().unwrap(), + NameOrAddress::Address(Address::from_str(ADDR_2).unwrap().to_ethers()) + ); assert_eq!(args, None); match tx { diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index cbc999079262a..7b752e1ee618e 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -139,7 +139,7 @@ casttest!(estimate_function_gas, |_: TestProject, mut cmd: TestCommand| { let eth_rpc_url = next_http_rpc_endpoint(); cmd.args([ "estimate", - "vitalik.eth", + "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // vitalik.eth "--value", "100", "deposit()", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 0e517efdabf0e..b7ab0e287cd6c 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -28,6 +28,7 @@ foundry-utils = { workspace = true, optional = true } alloy-dyn-abi = { workspace = true, optional = true } alloy-json-abi = { workspace = true, optional = true } ethers = { workspace = true, optional = true, features = ["ethers-solc"] } +foundry-compilers = { workspace = true, optional = true, default-features = false } eyre = { workspace = true, optional = true } futures = { version = "0.3", optional = true } hex = { workspace = true, optional = true } diff --git a/crates/cheatcodes/src/impls/config.rs b/crates/cheatcodes/src/impls/config.rs index 9e7a1a2d9a6de..0bc4c25a1b12e 100644 --- a/crates/cheatcodes/src/impls/config.rs +++ b/crates/cheatcodes/src/impls/config.rs @@ -1,7 +1,7 @@ use super::Result; use crate::Vm::Rpc; -use ethers::solc::{utils::canonicalize, ProjectPathsConfig}; use foundry_common::fs::normalize_path; +use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, ResolvedRpcEndpoints, diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 161b3b4f028ef..51f9930786e78 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -26,9 +26,10 @@ foundry-common.workspace = true foundry-utils.workspace = true forge-fmt.workspace = true +foundry-compilers = { workspace = true, default-features = false, features = ["project-util", "full"]} + # ethers ethers.workspace = true -ethers-solc = { workspace = true, features = ["project-util", "full"] } # alloy alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } @@ -63,7 +64,7 @@ once_cell = "1" [features] default = ["rustls"] rustls = ["ethers/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] -openssl = ["ethers/openssl", "reqwest/default-tls"] +openssl = ["ethers/openssl", "foundry-compilers/openssl", "reqwest/default-tls"] [[bench]] name = "session_source" diff --git a/crates/chisel/benches/session_source.rs b/crates/chisel/benches/session_source.rs index 696c57c9745a0..784de2c4b03df 100644 --- a/crates/chisel/benches/session_source.rs +++ b/crates/chisel/benches/session_source.rs @@ -1,6 +1,6 @@ use chisel::session_source::{SessionSource, SessionSourceConfig}; use criterion::{criterion_group, Criterion}; -use ethers_solc::Solc; +use foundry_compilers::Solc; use foundry_config::Config; use foundry_evm::executor::opts::EvmOpts; use once_cell::sync::Lazy; diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 56cef195e5e2f..db8950ca1323d 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -18,7 +18,6 @@ use foundry_evm::{ CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, }; -use foundry_utils::types::ToEthers; use once_cell::sync::Lazy; use regex::Regex; use reqwest::Url; @@ -953,9 +952,7 @@ impl ChiselDispatcher { )?; let mut decoder = CallTraceDecoderBuilder::new() - .with_labels( - result.labeled_addresses.iter().map(|(a, s)| ((*a).to_ethers(), s.clone())), - ) + .with_labels(result.labeled_addresses.clone()) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), session_config.foundry_config.offline, diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 96a5cc2a214ea..5979743bcbc50 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -9,8 +9,8 @@ use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_json_abi::EventParam; use alloy_primitives::{hex, Address, U256}; use core::fmt::Debug; -use ethers_solc::Artifact; use eyre::{Result, WrapErr}; +use foundry_compilers::Artifact; use foundry_evm::{ decode::decode_console_logs, executor::{inspector::CheatsConfig, Backend, ExecutorBuilder}, @@ -1362,7 +1362,7 @@ impl<'a> Iterator for InstructionIter<'a> { #[cfg(test)] mod tests { use super::*; - use ethers_solc::{error::SolcError, Solc}; + use foundry_compilers::{error::SolcError, Solc}; use std::sync::Mutex; #[test] diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 86826ad588674..043cde85c7bc3 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -138,7 +138,7 @@ impl ChiselRunner { false }; - let mut res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; + let mut res = self.executor.call_raw(from, to, calldata.clone(), value)?; let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { // store the current gas limit and reset it later @@ -154,7 +154,7 @@ impl ChiselRunner { while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; self.executor.env.tx.gas_limit = mid_gas_limit; - let res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; + let res = self.executor.call_raw(from, to, calldata.clone(), value)?; match res.exit_reason { InstructionResult::Revert | InstructionResult::OutOfGas | @@ -189,12 +189,12 @@ impl ChiselRunner { cheatcodes.fs_commit = !cheatcodes.fs_commit; } - res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; + res = self.executor.call_raw(from, to, calldata.clone(), value)?; } if commit { // if explicitly requested we can now commit the call - res = self.executor.call_raw_committing(from, to, calldata.0.clone().into(), value)?; + res = self.executor.call_raw_committing(from, to, calldata, value)?; } let RawCallResult { result, reverted, logs, traces, labels, chisel_state, .. } = res; diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index bad2cd92715c3..5fbb0a1e104a8 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -4,12 +4,12 @@ //! the REPL contract's source code. It provides simple compilation, parsing, and //! execution helpers. -use ethers_solc::{ +use eyre::Result; +use forge_fmt::solang_ext::SafeUnwrap; +use foundry_compilers::{ artifacts::{Source, Sources}, CompilerInput, CompilerOutput, EvmVersion, Solc, }; -use eyre::Result; -use forge_fmt::solang_ext::SafeUnwrap; use foundry_config::{Config, SolcReq}; use foundry_evm::executor::{opts::EvmOpts, Backend}; use semver::Version; @@ -304,7 +304,7 @@ impl SessionSource { self } - /// Generates and ethers_solc::CompilerInput from the source + /// Generates and foundry_compilers::CompilerInput from the source /// /// ### Returns /// diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index 9ff4e325719fb..7ea13c64de986 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -1,5 +1,5 @@ use chisel::session::ChiselSession; -use ethers_solc::EvmVersion; +use foundry_compilers::EvmVersion; use foundry_config::Config; use foundry_evm::executor::opts::EvmOpts; use serial_test::serial; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 6ff7b2cf57c47..d0b253499d9fc 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -17,6 +17,8 @@ foundry-evm.workspace = true foundry-debugger.workspace = true foundry-utils.workspace = true +foundry-compilers = { workspace = true, default-features = false, features = ["full"] } + # aws rusoto_core = { version = "0.48", default-features = false } rusoto_kms = { version = "0.48", default-features = false } @@ -26,6 +28,8 @@ ethers = { workspace = true, features = ["aws", "ledger", "trezor"] } # alloy alloy-primitives.workspace = true +alloy-json-abi.workspace = true +alloy-dyn-abi.workspace = true async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } @@ -54,4 +58,4 @@ tempfile = "3.7" [features] default = ["rustls"] rustls = ["ethers/rustls", "rusoto_core/rustls"] -openssl = ["ethers/openssl"] +openssl = ["ethers/openssl", "foundry-compilers/openssl"] diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index a9fbffabb16b3..9d5bee89c20b9 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -1,10 +1,10 @@ use super::ProjectPathsArgs; use crate::{opts::CompilerArgs, utils::LoadConfig}; use clap::{Parser, ValueHint}; -use ethers::solc::{ +use eyre::Result; +use foundry_compilers::{ artifacts::RevertStrings, remappings::Remapping, utils::canonicalized, Project, }; -use eyre::Result; use foundry_config::{ figment, figment::{ diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index 0014f5bfb61f0..aca7fba75a1c0 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -1,5 +1,5 @@ use clap::Parser; -use ethers::solc::{artifacts::output_selection::ContractOutputSelection, EvmVersion}; +use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, EvmVersion}; use serde::Serialize; mod core; diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index b067f39517ed2..4989bf7d911c7 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -1,6 +1,6 @@ use clap::{Parser, ValueHint}; -use ethers::solc::remappings::Remapping; use eyre::Result; +use foundry_compilers::remappings::Remapping; use foundry_config::{ figment, figment::{ diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index 71a00b5042adc..a4478f358d7ee 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -139,7 +139,7 @@ impl Dependency { #[cfg(test)] mod tests { use super::*; - use ethers::solc::info::ContractInfo; + use foundry_compilers::info::ContractInfo; #[test] fn parses_dependencies() { diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index 7b8ca8d48d549..ec92ce3ef457b 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -1,13 +1,13 @@ -use crate::utils::{parse_ether_value, parse_u256}; +use crate::utils::parse_ether_value; +use alloy_primitives::U256; use clap::Parser; -use ethers::types::U256; use serde::Serialize; #[derive(Parser, Debug, Clone, Serialize)] #[clap(next_help_heading = "Transaction options")] pub struct TransactionOpts { /// Gas limit for the transaction. - #[clap(long, env = "ETH_GAS_LIMIT", value_parser = parse_u256)] + #[clap(long, env = "ETH_GAS_LIMIT")] pub gas_limit: Option, /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions. @@ -37,7 +37,7 @@ pub struct TransactionOpts { pub value: Option, /// Nonce for the transaction. - #[clap(long, value_parser = parse_u256)] + #[clap(long)] pub nonce: Option, /// Send a legacy transaction instead of an EIP1559 transaction. diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/cli/src/opts/wallet/mod.rs index a85b4e7c77026..cd9fb07811130 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/cli/src/opts/wallet/mod.rs @@ -1,4 +1,5 @@ use crate::opts::error::PrivateKeyError; +use alloy_primitives::Address; use async_trait::async_trait; use clap::Parser; use ethers::{ @@ -9,12 +10,13 @@ use ethers::{ }, types::{ transaction::{eip2718::TypedTransaction, eip712::Eip712}, - Address, Signature, + Signature, }, }; use eyre::{bail, Result, WrapErr}; use foundry_common::fs; use foundry_config::Config; +use foundry_utils::types::ToAlloy; use rusoto_core::{ credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, request::HttpClient as AwsHttpClient, Client as AwsClient, @@ -202,9 +204,9 @@ impl Wallet { /// Returns the sender address of the signer or `from`. pub async fn sender(&self) -> Address { if let Ok(signer) = self.signer(0).await { - signer.address() + signer.address().to_alloy() } else { - self.from.unwrap_or_else(Address::zero) + self.from.unwrap_or(Address::ZERO) } } @@ -497,7 +499,7 @@ impl Signer for WalletSigner { delegate!(self, inner => inner.sign_typed_data(payload).await.map_err(Into::into)) } - fn address(&self) -> Address { + fn address(&self) -> ethers::types::Address { delegate!(self, inner => inner.address()) } @@ -537,7 +539,7 @@ impl Signer for &WalletSigner { (*self).sign_typed_data(payload).await } - fn address(&self) -> Address { + fn address(&self) -> ethers::types::Address { (*self).address() } diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index 92091e2263d6c..63fdb6110abd2 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -1,13 +1,14 @@ use super::{WalletSigner, WalletTrait}; +use alloy_primitives::Address; use clap::Parser; use ethers::{ prelude::{Middleware, Signer}, signers::{AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, Trezor, TrezorHDPath}, - types::Address, }; use eyre::{Context, ContextCompat, Result}; use foundry_common::RetryProvider; use foundry_config::Config; +use foundry_utils::types::ToAlloy; use itertools::izip; use rusoto_core::{ credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, @@ -239,18 +240,18 @@ impl MultiWallet { ], for wallet in wallets.into_iter() { let address = wallet.address(); - if addresses.contains(&address) { - addresses.remove(&address); + if addresses.contains(&address.to_alloy()) { + addresses.remove(&address.to_alloy()); let signer = WalletSigner::from(wallet.with_chain_id(chain)); - local_wallets.insert(address, signer); + local_wallets.insert(address.to_alloy(), signer); if addresses.is_empty() { return Ok(local_wallets) } } else { // Just to show on error. - unused_wallets.push(address); + unused_wallets.push(address.to_alloy()); } } ); diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 3ede6b0d85ecf..e43c0e2968608 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -1,16 +1,15 @@ -use ethers::{ - abi::Abi, - core::types::Chain, - solc::{ - artifacts::{CompactBytecode, CompactDeployedBytecode}, - cache::{CacheEntry, SolFilesCache}, - info::ContractInfo, - utils::read_json_file, - Artifact, ProjectCompileOutput, - }, -}; +use alloy_json_abi::JsonAbi as Abi; +use alloy_primitives::Address; +use ethers::core::types::Chain; use eyre::{Result, WrapErr}; use foundry_common::{cli_warn, fs, TestFunctionExt}; +use foundry_compilers::{ + artifacts::{CompactBytecode, CompactDeployedBytecode}, + cache::{CacheEntry, SolFilesCache}, + info::ContractInfo, + utils::read_json_file, + Artifact, ProjectCompileOutput, +}; use foundry_config::{error::ExtractConfigError, figment::Figment, Chain as ConfigChain, Config}; use foundry_debugger::DebuggerArgs; use foundry_evm::{ @@ -369,9 +368,7 @@ pub async fn handle_traces( let mut iter = label_str.split(':'); if let Some(addr) = iter.next() { - if let (Ok(address), Some(label)) = - (ethers::types::Address::from_str(addr), iter.next()) - { + if let (Ok(address), Some(label)) = (Address::from_str(addr), iter.next()) { return Some((address, label.to_string())) } } diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 1ae4c08a09be9..eab7a5b141e90 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -1,19 +1,15 @@ -use ethers::{ - abi::token::{LenientTokenizer, Tokenizer}, - prelude::TransactionReceipt, - providers::Middleware, - types::U256, - utils::{format_units, to_checksum}, -}; -use eyre::Result; +use alloy_primitives::U256; +use ethers::{prelude::TransactionReceipt, providers::Middleware}; +use eyre::{ContextCompat, Result}; +use foundry_common::units::format_units; use foundry_config::{Chain, Config}; +use foundry_utils::types::ToAlloy; use std::{ ffi::OsStr, future::Future, ops::Mul, path::{Path, PathBuf}, process::{Command, Output, Stdio}, - str::FromStr, time::{Duration, SystemTime, UNIX_EPOCH}, }; use tracing_error::ErrorLayer; @@ -78,18 +74,6 @@ pub fn subscriber() { .init() } -/// parse a hex str or decimal str as U256 -pub fn parse_u256(s: &str) -> Result { - Ok(if s.starts_with("0x") { U256::from_str(s)? } else { U256::from_dec_str(s)? }) -} - -/// parse a hex str or decimal str as U256 -// TODO: rm after alloy transition -pub fn alloy_parse_u256(s: &str) -> Result { - use foundry_utils::types::ToAlloy; - Ok(parse_u256(s)?.to_alloy()) -} - /// Returns a [RetryProvider](foundry_common::RetryProvider) instantiated using [Config]'s RPC URL /// and chain. /// @@ -134,18 +118,15 @@ where /// it is interpreted as wei. pub fn parse_ether_value(value: &str) -> Result { Ok(if value.starts_with("0x") { - U256::from_str(value)? + U256::from_str_radix(value, 16)? } else { - U256::from(LenientTokenizer::tokenize_uint(value)?) + alloy_dyn_abi::DynSolType::coerce_str(&alloy_dyn_abi::DynSolType::Uint(256), value)? + .as_uint() + .wrap_err("Could not parse ether value from string")? + .0 }) } -// TODO: rm after alloy transition -pub fn alloy_parse_ether_value(value: &str) -> Result { - use foundry_utils::types::ToAlloy; - Ok(parse_ether_value(value)?.to_alloy()) -} - /// Parses a `Duration` from a &str pub fn parse_delay(delay: &str) -> Result { let delay = if delay.ends_with("ms") { @@ -241,7 +222,7 @@ pub fn print_receipt(chain: Chain, receipt: &TransactionReceipt) { }, tx_hash = receipt.transaction_hash, caddr = if let Some(addr) = &receipt.contract_address { - format!("\nContract Address: {}", to_checksum(addr, None)) + format!("\nContract Address: {}", addr.to_alloy().to_checksum(None)) } else { String::new() }, @@ -249,8 +230,9 @@ pub fn print_receipt(chain: Chain, receipt: &TransactionReceipt) { gas = if gas_price.is_zero() { format!("Gas Used: {gas_used}") } else { - let paid = format_units(gas_used.mul(gas_price), 18).unwrap_or_else(|_| "N/A".into()); - let gas_price = format_units(gas_price, 9).unwrap_or_else(|_| "N/A".into()); + let paid = format_units(gas_used.mul(gas_price).to_alloy(), 18) + .unwrap_or_else(|_| "N/A".into()); + let gas_price = format_units(gas_price.to_alloy(), 9).unwrap_or_else(|_| "N/A".into()); format!( "Paid: {} ETH ({gas_used} gas * {} gwei)", paid.trim_end_matches('0'), diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index df83bb020b711..e2ab1df43f31c 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -16,11 +16,15 @@ foundry-macros.workspace = true # eth ethers-core.workspace = true -ethers-solc.workspace = true ethers-providers = { workspace = true, features = ["ws", "ipc"] } ethers-middleware.workspace = true -ethers-etherscan = { workspace = true, features = ["ethers-solc"] } +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } +# alloy +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-json-abi.workspace = true +foundry-compilers = { workspace = true, default-features = false } # io reqwest = { version = "0.11", default-features = false } diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index e43650d39e4af..abfee8d06c5c7 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -1,50 +1,46 @@ //! ABI related helper functions - -use ethers_core::{ - abi::{ - token::{LenientTokenizer, StrictTokenizer, Tokenizer}, - Event, Function, HumanReadableParser, ParamType, RawLog, Token, - }, - types::{Address, Chain, I256, U256}, - utils::{hex, to_checksum}, -}; -use ethers_etherscan::{contract::ContractMetadata, errors::EtherscanError, Client}; -use eyre::{ContextCompat, Result, WrapErr}; -use std::{future::Future, pin::Pin, str::FromStr}; +use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; +use alloy_json_abi::{Event, Function}; +use alloy_primitives::{hex, Address, Log, U256}; +use ethers_core::types::Chain; +use eyre::{ContextCompat, Result}; +use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; +use std::{future::Future, pin::Pin}; use yansi::Paint; use crate::calc::to_exponential_notation; -/// Given a function and a vector of string arguments, it proceeds to convert the args to ethabi -/// Tokens and then ABI encode them. -pub fn encode_args(func: &Function, args: &[impl AsRef]) -> Result> { - let params = func +/// Given a function and a vector of string arguments, it proceeds to convert the args to alloy +/// [DynSolValue]s and then ABI encode them. +pub fn encode_function_args(func: &Function, args: &[impl AsRef]) -> Result> { + let params: Result> = func .inputs .iter() .zip(args) - .map(|(input, arg)| (&input.kind, arg.as_ref())) - .collect::>(); - let tokens = parse_tokens(params, true)?; - Ok(func.encode_input(&tokens)?) + .map(|(input, arg)| (input.selector_type().clone(), arg.as_ref())) + .map(|(ty, arg)| coerce_value(&ty, arg)) + .collect(); + Ok(func.abi_encode_input(params?.as_slice())?) } /// Decodes the calldata of the function -/// -/// # Panics -/// -/// If the `sig` is an invalid function signature -pub fn abi_decode(sig: &str, calldata: &str, input: bool, fn_selector: bool) -> Result> { - let func = IntoFunction::into(sig); +pub fn abi_decode_calldata( + sig: &str, + calldata: &str, + input: bool, + fn_selector: bool, +) -> Result> { + let func = Function::parse(sig)?; let calldata = hex::decode(calldata)?; let res = if input { // If function selector is prefixed in "calldata", remove it (first 4 bytes) if fn_selector { - func.decode_input(&calldata[4..])? + func.abi_decode_input(&calldata[4..], false)? } else { - func.decode_input(&calldata)? + func.abi_decode_input(&calldata, false)? } } else { - func.decode_output(&calldata)? + func.abi_decode_output(&calldata, false)? }; // in case the decoding worked but nothing was decoded @@ -56,141 +52,65 @@ pub fn abi_decode(sig: &str, calldata: &str, input: bool, fn_selector: bool) -> } /// Parses string input as Token against the expected ParamType -pub fn parse_tokens<'a, I: IntoIterator>( +pub fn parse_tokens<'a, I: IntoIterator>( params: I, - lenient: bool, -) -> Result> { +) -> Result> { let mut tokens = Vec::new(); for (param, value) in params.into_iter() { - let mut token = if lenient { - LenientTokenizer::tokenize(param, value) - } else { - StrictTokenizer::tokenize(param, value) - }; - if token.is_err() && value.starts_with("0x") { - match param { - ParamType::FixedBytes(32) => { - if value.len() < 66 { - let padded_value = [value, &"0".repeat(66 - value.len())].concat(); - token = if lenient { - LenientTokenizer::tokenize(param, &padded_value) - } else { - StrictTokenizer::tokenize(param, &padded_value) - }; - } - } - ParamType::Uint(_) => { - // try again if value is hex - if let Ok(value) = U256::from_str(value).map(|v| v.to_string()) { - token = if lenient { - LenientTokenizer::tokenize(param, &value) - } else { - StrictTokenizer::tokenize(param, &value) - }; - } - } - // TODO: Not sure what to do here. Put the no effect in for now, but that is not - // ideal. We could attempt massage for every value type? - _ => {} - } - } - - let token = token.map(sanitize_token).wrap_err_with(|| { - format!("Failed to parse `{value}`, expected value of type: {param}") - })?; + let token = DynSolType::coerce_str(param, value)?; tokens.push(token); } Ok(tokens) } -/// Cleans up potential shortcomings of the ethabi Tokenizer. -/// -/// For example: parsing a string array with a single empty string: `[""]`, is returned as -/// -/// ```text -/// [ -/// String( -/// "\"\"", -/// ), -/// ], -/// ``` -/// -/// But should just be -/// -/// ```text -/// [ -/// String( -/// "", -/// ), -/// ], -/// ``` -/// -/// This will handle this edge case -pub fn sanitize_token(token: Token) -> Token { - match token { - Token::Array(tokens) => { - let mut sanitized = Vec::with_capacity(tokens.len()); - for token in tokens { - let token = match token { - Token::String(val) => { - let val = match val.as_str() { - // this is supposed to be an empty string - "\"\"" | "''" => String::new(), - _ => val, - }; - Token::String(val) - } - _ => sanitize_token(token), - }; - sanitized.push(token) - } - Token::Array(sanitized) - } - _ => token, - } -} - /// Pretty print a slice of tokens. -pub fn format_tokens(tokens: &[Token]) -> impl Iterator + '_ { +pub fn format_tokens(tokens: &[DynSolValue]) -> impl Iterator + '_ { tokens.iter().map(format_token) } /// Gets pretty print strings for tokens -pub fn format_token(param: &Token) -> String { +pub fn format_token(param: &DynSolValue) -> String { match param { - Token::Address(addr) => to_checksum(addr, None), - Token::FixedBytes(bytes) => hex::encode_prefixed(bytes), - Token::Bytes(bytes) => hex::encode_prefixed(bytes), - Token::Int(num) => format!("{}", I256::from_raw(*num)), - Token::Uint(num) => format_uint_with_exponential_notation_hint(*num), - Token::Bool(b) => format!("{b}"), - Token::String(s) => s.to_string(), - Token::FixedArray(tokens) => { + DynSolValue::Address(addr) => addr.to_checksum(None), + DynSolValue::FixedBytes(bytes, _) => hex::encode_prefixed(bytes), + DynSolValue::Bytes(bytes) => hex::encode_prefixed(bytes), + DynSolValue::Int(num, _) => format!("{}", num), + DynSolValue::Uint(num, _) => format_uint_with_exponential_notation_hint(*num), + DynSolValue::Bool(b) => format!("{b}"), + DynSolValue::String(s) => s.to_string(), + DynSolValue::FixedArray(tokens) => { let string = tokens.iter().map(format_token).collect::>().join(", "); format!("[{string}]") } - Token::Array(tokens) => { + DynSolValue::Array(tokens) => { let string = tokens.iter().map(format_token).collect::>().join(", "); format!("[{string}]") } - Token::Tuple(tokens) => { + DynSolValue::Tuple(tokens) => { let string = tokens.iter().map(format_token).collect::>().join(", "); format!("({string})") } + DynSolValue::CustomStruct { name: _, prop_names: _, tuple } => { + let string = tuple.iter().map(format_token).collect::>().join(", "); + format!("({string})") + } + DynSolValue::Function(f) => { + format!("{}", f.to_address_and_selector().1) + } } } /// Gets pretty print strings for tokens, without adding /// exponential notation hints for large numbers (e.g. [1e7] for 10000000) -pub fn format_token_raw(param: &Token) -> String { +pub fn format_token_raw(param: &DynSolValue) -> String { match param { - Token::Uint(num) => format!("{}", num), - Token::FixedArray(tokens) | Token::Array(tokens) => { + DynSolValue::Uint(num, _) => format!("{}", num), + DynSolValue::FixedArray(tokens) | DynSolValue::Array(tokens) => { let string = tokens.iter().map(format_token_raw).collect::>().join(", "); format!("[{string}]") } - Token::Tuple(tokens) => { + DynSolValue::Tuple(tokens) => { let string = tokens.iter().map(format_token_raw).collect::>().join(", "); format!("({string})") } @@ -246,53 +166,41 @@ impl IntoFunction for String { impl<'a> IntoFunction for &'a str { fn into(self) -> Function { - HumanReadableParser::parse_function(self) - .unwrap_or_else(|_| panic!("could not convert {self} to function")) + Function::parse(self).expect("could not parse function") } } /// Given a function signature string, it tries to parse it as a `Function` pub fn get_func(sig: &str) -> Result { - Ok(match HumanReadableParser::parse_function(sig) { + Ok(match Function::parse(sig) { Ok(func) => func, Err(err) => { - if let Ok(constructor) = HumanReadableParser::parse_constructor(sig) { - #[allow(deprecated)] - Function { - name: "constructor".to_string(), - inputs: constructor.inputs, - outputs: vec![], - constant: None, - state_mutability: Default::default(), - } - } else { - // we return the `Function` parse error as this case is more likely - return Err(err.into()) - } + // we return the `Function` parse error as this case is more likely + return Err(err.into()) } }) } /// Given an event signature string, it tries to parse it as a `Event` pub fn get_event(sig: &str) -> Result { - Ok(HumanReadableParser::parse_event(sig)?) + let sig = sig.strip_prefix("event").unwrap_or(sig).trim(); + Ok(Event::parse(sig)?) } /// Given an event without indexed parameters and a rawlog, it tries to return the event with the /// proper indexed parameters. Otherwise, it returns the original event. -pub fn get_indexed_event(mut event: Event, raw_log: &RawLog) -> Event { - if !event.anonymous && raw_log.topics.len() > 1 { - let indexed_params = raw_log.topics.len() - 1; +pub fn get_indexed_event(mut event: Event, raw_log: &Log) -> Event { + if !event.anonymous && raw_log.topics().len() > 1 { + let indexed_params = raw_log.topics().len() - 1; let num_inputs = event.inputs.len(); - let num_address_params = - event.inputs.iter().filter(|p| p.kind == ParamType::Address).count(); + let num_address_params = event.inputs.iter().filter(|p| p.ty == "address").count(); event.inputs.iter_mut().enumerate().for_each(|(index, param)| { if param.name.is_empty() { param.name = format!("param{index}"); } if num_inputs == indexed_params || - (num_address_params == indexed_params && param.kind == ParamType::Address) + (num_address_params == indexed_params && param.ty == "address") { param.indexed = true; } @@ -318,7 +226,7 @@ pub async fn get_func_etherscan( let funcs = abi.functions.remove(function_name).unwrap_or_default(); for func in funcs { - let res = encode_args(&func, args); + let res = encode_function_args(&func, args); if res.is_ok() { return Ok(func) } @@ -359,103 +267,76 @@ pub fn find_source( }) } +/// Helper function to coerce a value to a [DynSolValue] given a type string +fn coerce_value(ty: &str, arg: &str) -> Result { + let ty = DynSolType::parse(ty)?; + Ok(DynSolType::coerce_str(&ty, arg)?) +} + #[cfg(test)] mod tests { - use super::*; - use ethers_core::types::H256; + use std::str::FromStr; - #[test] - fn can_sanitize_token() { - let token = - Token::Array(LenientTokenizer::tokenize_array("[\"\"]", &ParamType::String).unwrap()); - let sanitized = sanitize_token(token); - assert_eq!(sanitized, Token::Array(vec![Token::String(String::new())])); - - let token = - Token::Array(LenientTokenizer::tokenize_array("['']", &ParamType::String).unwrap()); - let sanitized = sanitize_token(token); - assert_eq!(sanitized, Token::Array(vec![Token::String(String::new())])); - - let token = Token::Array( - LenientTokenizer::tokenize_array("[\"\",\"\"]", &ParamType::String).unwrap(), - ); - let sanitized = sanitize_token(token); - assert_eq!( - sanitized, - Token::Array(vec![Token::String(String::new()), Token::String(String::new())]) - ); - - let token = - Token::Array(LenientTokenizer::tokenize_array("['','']", &ParamType::String).unwrap()); - let sanitized = sanitize_token(token); - assert_eq!( - sanitized, - Token::Array(vec![Token::String(String::new()), Token::String(String::new())]) - ); - } + use super::*; + use alloy_dyn_abi::EventExt; + use alloy_primitives::B256; #[test] fn parse_hex_uint_tokens() { - let param = ParamType::Uint(256); + let param = DynSolType::Uint(256); - let tokens = parse_tokens(std::iter::once((¶m, "100")), true).unwrap(); - assert_eq!(tokens, vec![Token::Uint(100u64.into())]); + let tokens = parse_tokens(std::iter::once((¶m, "100"))).unwrap(); + assert_eq!(tokens, vec![DynSolValue::Uint(U256::from(100), 256)]); - let val: U256 = 100u64.into(); + let val: U256 = U256::from(100u64); let hex_val = format!("0x{val:x}"); - let tokens = parse_tokens(std::iter::once((¶m, hex_val.as_str())), true).unwrap(); - assert_eq!(tokens, vec![Token::Uint(100u64.into())]); + let tokens = parse_tokens(std::iter::once((¶m, hex_val.as_str()))).unwrap(); + assert_eq!(tokens, vec![DynSolValue::Uint(U256::from(100), 256)]); } #[test] fn test_indexed_only_address() { let event = get_event("event Ev(address,uint256,address)").unwrap(); - let param0 = H256::random(); + let param0 = B256::random(); let param1 = vec![3; 32]; - let param2 = H256::random(); - let log = RawLog { topics: vec![event.signature(), param0, param2], data: param1.clone() }; + let param2 = B256::random(); + let log = Log::new_unchecked(vec![event.selector(), param0, param2], param1.clone().into()); let event = get_indexed_event(event, &log); assert_eq!(event.inputs.len(), 3); // Only the address fields get indexed since total_params > num_indexed_params - let parsed = event.parse_log(log).unwrap(); + let parsed = event.decode_log(&log, false).unwrap(); assert_eq!(event.inputs.iter().filter(|param| param.indexed).count(), 2); - assert_eq!(parsed.params[0].name, "param0"); - assert_eq!(parsed.params[0].value, Token::Address(param0.into())); - assert_eq!(parsed.params[1].name, "param1"); - assert_eq!(parsed.params[1].value, Token::Uint(U256::from_big_endian(¶m1))); - assert_eq!(parsed.params[2].name, "param2"); - assert_eq!(parsed.params[2].value, Token::Address(param2.into())); + assert_eq!(parsed.indexed[0], DynSolValue::Address(Address::from_word(param0))); + assert_eq!(parsed.body[0], DynSolValue::Uint(U256::from_be_bytes([3; 32]), 256)); + assert_eq!(parsed.indexed[1], DynSolValue::Address(Address::from_word(param2))); } #[test] fn test_indexed_all() { let event = get_event("event Ev(address,uint256,address)").unwrap(); - let param0 = H256::random(); + let param0 = B256::random(); let param1 = vec![3; 32]; - let param2 = H256::random(); - let log = RawLog { - topics: vec![event.signature(), param0, H256::from_slice(¶m1), param2], - data: vec![], - }; + let param2 = B256::random(); + let log = Log::new_unchecked( + vec![event.selector(), param0, B256::from_slice(¶m1), param2], + vec![].into(), + ); let event = get_indexed_event(event, &log); assert_eq!(event.inputs.len(), 3); // All parameters get indexed since num_indexed_params == total_params assert_eq!(event.inputs.iter().filter(|param| param.indexed).count(), 3); - let parsed = event.parse_log(log).unwrap(); - - assert_eq!(parsed.params[0].name, "param0"); - assert_eq!(parsed.params[0].value, Token::Address(param0.into())); - assert_eq!(parsed.params[1].name, "param1"); - assert_eq!(parsed.params[1].value, Token::Uint(U256::from_big_endian(¶m1))); - assert_eq!(parsed.params[2].name, "param2"); - assert_eq!(parsed.params[2].value, Token::Address(param2.into())); + let parsed = event.decode_log(&log, false).unwrap(); + + assert_eq!(parsed.indexed[0], DynSolValue::Address(Address::from_word(param0))); + assert_eq!(parsed.indexed[1], DynSolValue::Uint(U256::from_be_bytes([3; 32]), 256)); + assert_eq!(parsed.indexed[2], DynSolValue::Address(Address::from_word(param2))); } #[test] @@ -463,14 +344,16 @@ mod tests { // copied from testcases in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md let eip55 = "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"; assert_eq!( - format_token(&Token::Address(Address::from_str(&eip55.to_lowercase()).unwrap())), + format_token(&DynSolValue::Address(Address::from_str(&eip55.to_lowercase()).unwrap())), eip55.to_string() ); // copied from testcases in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md let eip1191 = "0xFb6916095cA1Df60bb79ce92cE3EA74c37c5d359"; assert_ne!( - format_token(&Token::Address(Address::from_str(&eip1191.to_lowercase()).unwrap())), + format_token(&DynSolValue::Address( + Address::from_str(&eip1191.to_lowercase()).unwrap() + )), eip1191.to_string() ); } diff --git a/crates/common/src/calc.rs b/crates/common/src/calc.rs index 295fb0a45d22e..848c4c6129520 100644 --- a/crates/common/src/calc.rs +++ b/crates/common/src/calc.rs @@ -1,35 +1,29 @@ //! commonly used calculations -use ethers_core::types::U256; -use std::ops::{Add, Div}; +use alloy_primitives::U256; +use std::ops::Div; /// Returns the mean of the slice #[inline] -pub fn mean(values: &[T]) -> U256 -where - T: Into + Copy, -{ +pub fn mean(values: &[U256]) -> U256 { if values.is_empty() { - return U256::zero() + return U256::ZERO } - values.iter().copied().fold(U256::zero(), |sum, val| sum + val.into()) / values.len() + values.iter().copied().fold(U256::ZERO, |sum, val| sum + val).div(U256::from(values.len())) } /// Returns the median of a _sorted_ slice #[inline] -pub fn median_sorted(values: &[T]) -> T -where - T: Add + Div + From + Copy, -{ +pub fn median_sorted(values: &[U256]) -> U256 { if values.is_empty() { - return 0u64.into() + return U256::ZERO } let len = values.len(); let mid = len / 2; if len % 2 == 0 { - (values[mid - 1] + values[mid]) / 2u64 + (values[mid - 1] + values[mid]) / U256::from(2u64) } else { values[mid] } @@ -76,57 +70,67 @@ mod tests { #[test] fn calc_mean_empty() { - let values: [u64; 0] = []; + let values: [U256; 0] = []; let m = mean(&values); - assert_eq!(m, U256::zero()); + assert_eq!(m, U256::ZERO); } #[test] fn calc_mean() { - let values = [0u64, 1u64, 2u64, 3u64, 4u64, 5u64, 6u64]; + let values = [ + U256::ZERO, + U256::from(1), + U256::from(2u64), + U256::from(3u64), + U256::from(4u64), + U256::from(5u64), + U256::from(6u64), + ]; let m = mean(&values); - assert_eq!(m, 3u64.into()); + assert_eq!(m, U256::from(3u64)); } #[test] fn calc_median_empty() { - let values: Vec = vec![]; + let values: Vec = vec![]; let m = median_sorted(&values); - assert_eq!(m, 0); + assert_eq!(m, U256::from(0)); } #[test] fn calc_median() { - let mut values = vec![29, 30, 31, 40, 59, 61, 71]; + let mut values = + vec![29, 30, 31, 40, 59, 61, 71].into_iter().map(U256::from).collect::>(); values.sort(); let m = median_sorted(&values); - assert_eq!(m, 40); + assert_eq!(m, U256::from(40)); } #[test] fn calc_median_even() { - let mut values = vec![80, 90, 30, 40, 50, 60, 10, 20]; + let mut values = + vec![80, 90, 30, 40, 50, 60, 10, 20].into_iter().map(U256::from).collect::>(); values.sort(); let m = median_sorted(&values); - assert_eq!(m, 45); + assert_eq!(m, U256::from(45)); } #[test] fn test_format_to_exponential_notation() { let value = 1234124124u64; - let formatted = to_exponential_notation(value.into(), 4, false); + let formatted = to_exponential_notation(U256::from(value), 4, false); assert_eq!(formatted, "1.234e9"); - let formatted = to_exponential_notation(value.into(), 3, true); + let formatted = to_exponential_notation(U256::from(value), 3, true); assert_eq!(formatted, "1.23e9"); let value = 10000000u64; - let formatted = to_exponential_notation(value.into(), 4, false); + let formatted = to_exponential_notation(U256::from(value), 4, false); assert_eq!(formatted, "1.000e7"); - let formatted = to_exponential_notation(value.into(), 3, true); + let formatted = to_exponential_notation(U256::from(value), 3, true); assert_eq!(formatted, "1e7"); } } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index bfe9ec9901a30..a08287beac1d2 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,15 +1,15 @@ -//! Support for compiling [ethers::solc::Project] +//! Support for compiling [foundry_compilers::Project] use crate::{compact_to_contract, glob::GlobMatcher, term, TestFunctionExt}; use comfy_table::{presets::ASCII_MARKDOWN, *}; -use ethers_etherscan::contract::Metadata; -use ethers_solc::{ +use eyre::Result; +use foundry_block_explorers::contract::Metadata; +use foundry_compilers::{ artifacts::{BytecodeObject, ContractBytecodeSome}, remappings::Remapping, report::NoReporter, Artifact, ArtifactId, FileFilter, Graph, Project, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig, }; -use eyre::Result; use std::{ collections::{BTreeMap, HashMap}, convert::Infallible, @@ -288,8 +288,8 @@ pub fn compile_with_filter( /// compilation was successful or if there was a cache hit. /// Doesn't print anything to stdout, thus is "suppressed". pub fn suppress_compile(project: &Project) -> Result { - let output = ethers_solc::report::with_scoped( - ðers_solc::report::Report::new(NoReporter::default()), + let output = foundry_compilers::report::with_scoped( + &foundry_compilers::report::Report::new(NoReporter::default()), || project.compile(), )?; @@ -322,8 +322,8 @@ pub fn suppress_compile_sparse( project: &Project, filter: F, ) -> Result { - let output = ethers_solc::report::with_scoped( - ðers_solc::report::Report::new(NoReporter::default()), + let output = foundry_compilers::report::with_scoped( + &foundry_compilers::report::Report::new(NoReporter::default()), || project.compile_sparse(filter), )?; @@ -343,8 +343,8 @@ pub fn compile_files( silent: bool, ) -> Result { let output = if silent { - ethers_solc::report::with_scoped( - ðers_solc::report::Report::new(NoReporter::default()), + foundry_compilers::report::with_scoped( + &foundry_compilers::report::Report::new(NoReporter::default()), || project.compile_files(files), ) } else { diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index c17ebd9deff5e..d4f3763874158 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -1,6 +1,6 @@ //! Commonly used constants -use ethers_core::types::H160; +use alloy_primitives::{address, Address}; use std::time::Duration; /// The dev chain-id, inherited from hardhat @@ -29,19 +29,13 @@ supported. Please try to change your RPC url to an archive node if the issue per /// Arbitrum L1 sender address of the first transaction in every block. /// `0x00000000000000000000000000000000000a4b05` -pub const ARBITRUM_SENDER: H160 = H160([ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0a, 0x4b, 0x05, -]); +pub const ARBITRUM_SENDER: Address = address!("00000000000000000000000000000000000a4b05"); /// The system address, the sender of the first transaction in every block: /// `0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001` /// /// See also -pub const OPTIMISM_SYSTEM_ADDRESS: H160 = H160([ - 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, - 0xDE, 0xAD, 0x00, 0x01, -]); +pub const OPTIMISM_SYSTEM_ADDRESS: Address = address!("deaddeaddeaddeaddeaddeaddeaddeaddead0001"); /// Transaction identifier of System transaction types pub const SYSTEM_TRANSACTION_TYPE: u64 = 126u64; @@ -52,7 +46,7 @@ pub const SYSTEM_TRANSACTION_TYPE: u64 = 126u64; /// /// See: [ARBITRUM_SENDER], [OPTIMISM_SYSTEM_ADDRESS] #[inline] -pub fn is_known_system_sender(sender: H160) -> bool { +pub fn is_known_system_sender(sender: Address) -> bool { [ARBITRUM_SENDER, OPTIMISM_SYSTEM_ADDRESS].contains(&sender) } @@ -63,9 +57,9 @@ mod tests { #[test] fn test_constant_sender() { - let arb = H160::from_str("0x00000000000000000000000000000000000a4b05").unwrap(); + let arb = Address::from_str("0x00000000000000000000000000000000000a4b05").unwrap(); assert_eq!(arb, ARBITRUM_SENDER); - let base = H160::from_str("0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001").unwrap(); + let base = Address::from_str("0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001").unwrap(); assert_eq!(base, OPTIMISM_SYSTEM_ADDRESS); } } diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index a0b3384d5c0ed..e5338c5ddd4eb 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -1,11 +1,8 @@ //! commonly used contract types and functions -use ethers_core::{ - abi::{Abi, Event, Function}, - types::{Address, H256}, - utils::hex, -}; -use ethers_solc::{ +use alloy_json_abi::{Event, Function, JsonAbi as Abi}; +use alloy_primitives::{hex, Address, B256}; +use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecodeSome}, ArtifactId, ProjectPathsConfig, }; @@ -47,22 +44,22 @@ impl ContractsByArtifact { } /// Flattens a group of contracts into maps of all events and functions - pub fn flatten(&self) -> (BTreeMap<[u8; 4], Function>, BTreeMap, Abi) { + pub fn flatten(&self) -> (BTreeMap<[u8; 4], Function>, BTreeMap, Abi) { let flattened_funcs: BTreeMap<[u8; 4], Function> = self .iter() .flat_map(|(_name, (abi, _code))| { abi.functions() - .map(|func| (func.short_signature(), func.clone())) + .map(|func| (func.selector().into(), func.clone())) .collect::>() }) .collect(); - let flattened_events: BTreeMap = self + let flattened_events: BTreeMap = self .iter() .flat_map(|(_name, (abi, _code))| { abi.events() - .map(|event| (event.signature(), event.clone())) - .collect::>() + .map(|event| (event.selector(), event.clone())) + .collect::>() }) .collect(); diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 23990af881363..5672057f5a3d6 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -1,6 +1,6 @@ //! cli arguments for configuring the evm settings +use alloy_primitives::{Address, B256, U256}; use clap::{ArgAction, Parser}; -use ethers_core::types::{Address, H256, U256}; use eyre::ContextCompat; use foundry_config::{ figment::{ @@ -228,7 +228,7 @@ pub struct EnvArgs { /// The block prevrandao value. NOTE: Before merge this field was mix_hash. #[clap(long, value_name = "PREVRANDAO")] #[serde(skip_serializing_if = "Option::is_none")] - pub block_prevrandao: Option, + pub block_prevrandao: Option, /// The block gas limit. #[clap(long, value_name = "GAS_LIMIT")] diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index bd7162e7c8dd4..8b6484a024e15 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -16,10 +16,12 @@ pub mod glob; pub mod provider; pub mod runtime_client; pub mod selectors; +pub mod serde_helpers; pub mod shell; pub mod term; pub mod traits; pub mod transactions; +pub mod units; pub use constants::*; pub use contracts::*; diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 870c6d3c77828..a1220b6b6a800 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -1,7 +1,7 @@ #![allow(missing_docs)] //! Support for handling/identifying selectors -use crate::abi::abi_decode; -use ethers_solc::artifacts::LosslessAbi; +use crate::abi::abi_decode_calldata; +use foundry_compilers::artifacts::LosslessAbi; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{ @@ -224,7 +224,7 @@ impl SignEthClient { // filter for signatures that can be decoded Ok(sigs .iter() - .filter(|sig| abi_decode(sig, calldata, true, true).is_ok()) + .filter(|sig| abi_decode_calldata(sig, calldata, true, true).is_ok()) .cloned() .collect::>()) } diff --git a/crates/common/src/serde_helpers.rs b/crates/common/src/serde_helpers.rs new file mode 100644 index 0000000000000..366a71012f04a --- /dev/null +++ b/crates/common/src/serde_helpers.rs @@ -0,0 +1,39 @@ +//! Misc serde helpers for foundry crates. + +use std::str::FromStr; + +use alloy_primitives::U256; +use serde::Deserialize; + +/// Helper type to parse both `u64` and `U256` +#[derive(Copy, Clone, Deserialize)] +#[serde(untagged)] +pub enum Numeric { + /// A [U256] value. + U256(U256), + /// A `u64` value. + Num(u64), +} + +impl From for U256 { + fn from(n: Numeric) -> U256 { + match n { + Numeric::U256(n) => n, + Numeric::Num(n) => U256::from(n), + } + } +} + +impl FromStr for Numeric { + type Err = String; + + fn from_str(s: &str) -> Result { + if let Ok(val) = s.parse::() { + Ok(Numeric::U256(U256::from(val))) + } else if s.starts_with("0x") { + U256::from_str_radix(s, 16).map(Numeric::U256).map_err(|err| err.to_string()) + } else { + U256::from_str(s).map(Numeric::U256).map_err(|err| err.to_string()) + } + } +} diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 82dc5b29bf738..22e9730de5d3b 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -1,5 +1,5 @@ //! terminal utils -use ethers_solc::{ +use foundry_compilers::{ remappings::Remapping, report::{self, BasicStdoutReporter, Reporter, SolcCompilerIoReporter}, CompilerInput, CompilerOutput, Solc, diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index fd18acaa1c3c0..ca46e0f56c709 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -1,7 +1,7 @@ //! Commonly used traits +use alloy_json_abi::Function; use auto_impl::auto_impl; -use ethers_core::abi::Function; /// Extension trait for matching tests #[auto_impl(&)] diff --git a/crates/common/src/units.rs b/crates/common/src/units.rs new file mode 100644 index 0000000000000..937c954988534 --- /dev/null +++ b/crates/common/src/units.rs @@ -0,0 +1,329 @@ +//! Unit conversion utilities. + +use alloy_primitives::{Address, ParseSignedError, I256, U256}; +use std::{convert::TryFrom, fmt, str::FromStr}; +use thiserror::Error; + +/// I256 overflows for numbers wider than 77 units. +const OVERFLOW_I256_UNITS: usize = 77; +/// U256 overflows for numbers wider than 78 units. +const OVERFLOW_U256_UNITS: usize = 78; + +/// Common Ethereum unit types. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum Units { + /// Wei is equivalent to 1 wei. + Wei, + /// Kwei is equivalent to 1e3 wei. + Kwei, + /// Mwei is equivalent to 1e6 wei. + Mwei, + /// Gwei is equivalent to 1e9 wei. + Gwei, + /// Twei is equivalent to 1e12 wei. + Twei, + /// Pwei is equivalent to 1e15 wei. + Pwei, + /// Ether is equivalent to 1e18 wei. + Ether, + /// Other less frequent unit sizes, equivalent to 1e{0} wei. + Other(u32), +} + +impl fmt::Display for Units { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.pad(self.as_num().to_string().as_str()) + } +} + +impl TryFrom for Units { + type Error = ConversionError; + + fn try_from(value: u32) -> Result { + Ok(Units::Other(value)) + } +} + +impl TryFrom for Units { + type Error = ConversionError; + + fn try_from(value: i32) -> Result { + Ok(Units::Other(value as u32)) + } +} + +impl TryFrom for Units { + type Error = ConversionError; + + fn try_from(value: usize) -> Result { + Ok(Units::Other(value as u32)) + } +} + +impl TryFrom for Units { + type Error = ConversionError; + + fn try_from(value: String) -> Result { + Self::from_str(&value) + } +} + +impl<'a> TryFrom<&'a String> for Units { + type Error = ConversionError; + + fn try_from(value: &'a String) -> Result { + Self::from_str(value) + } +} + +impl TryFrom<&str> for Units { + type Error = ConversionError; + + fn try_from(value: &str) -> Result { + Self::from_str(value) + } +} + +impl FromStr for Units { + type Err = ConversionError; + + fn from_str(s: &str) -> Result { + Ok(match s.to_lowercase().as_str() { + "eth" | "ether" => Units::Ether, + "pwei" | "milli" | "milliether" | "finney" => Units::Pwei, + "twei" | "micro" | "microether" | "szabo" => Units::Twei, + "gwei" | "nano" | "nanoether" | "shannon" => Units::Gwei, + "mwei" | "pico" | "picoether" | "lovelace" => Units::Mwei, + "kwei" | "femto" | "femtoether" | "babbage" => Units::Kwei, + "wei" => Units::Wei, + _ => return Err(ConversionError::UnrecognizedUnits(s.to_string())), + }) + } +} + +impl From for u32 { + fn from(units: Units) -> Self { + units.as_num() + } +} + +impl From for i32 { + fn from(units: Units) -> Self { + units.as_num() as i32 + } +} + +impl From for usize { + fn from(units: Units) -> Self { + units.as_num() as usize + } +} + +impl Units { + /// Converts the ethereum unit to its numeric representation. + pub fn as_num(&self) -> u32 { + match self { + Units::Wei => 0, + Units::Kwei => 3, + Units::Mwei => 6, + Units::Gwei => 9, + Units::Twei => 12, + Units::Pwei => 15, + Units::Ether => 18, + Units::Other(inner) => *inner, + } + } +} + +/// This enum holds the numeric types that a possible to be returned by `parse_units` and +/// that are taken by `format_units`. +#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] +pub enum ParseUnits { + /// Unsigned 256-bit integer. + U256(U256), + /// Signed 256-bit integer. + I256(I256), +} + +impl From for U256 { + fn from(n: ParseUnits) -> Self { + match n { + ParseUnits::U256(n) => n, + ParseUnits::I256(n) => n.into_raw(), + } + } +} + +impl From for I256 { + fn from(n: ParseUnits) -> Self { + match n { + ParseUnits::I256(n) => n, + ParseUnits::U256(n) => I256::from_raw(n), + } + } +} + +impl From> for ParseUnits { + fn from(n: alloy_primitives::Signed<256, 4>) -> Self { + Self::I256(n) + } +} + +impl fmt::Display for ParseUnits { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ParseUnits::U256(val) => val.fmt(f), + ParseUnits::I256(val) => val.fmt(f), + } + } +} + +macro_rules! construct_format_units_from { + ($( $t:ty[$convert:ident] ),*) => { + $( + impl From<$t> for ParseUnits { + fn from(num: $t) -> Self { + Self::$convert(U256::from(num)) + } + } + )* + } +} + +macro_rules! construct_signed_format_units_from { + ($( $t:ty[$convert:ident] ),*) => { + $( + impl From<$t> for ParseUnits { + fn from(num: $t) -> Self { + Self::$convert(I256::from_raw(U256::from(num))) + } + } + )* + } +} + +// Generate the From code for the given numeric types below. +construct_format_units_from! { + u8[U256], u16[U256], u32[U256], u64[U256], u128[U256], U256[U256], usize[U256] +} + +construct_signed_format_units_from! { + i8[I256], i16[I256], i32[I256], i64[I256], i128[I256], isize[I256] +} + +/// Handles all possible conversion errors. +#[derive(Error, Debug)] +pub enum ConversionError { + /// The unit is unrecognized. + #[error("Unknown units: {0}")] + UnrecognizedUnits(String), + /// The provided hex string is invalid (too long). + #[error("bytes32 strings must not exceed 32 bytes in length")] + TextTooLong, + /// The provided string cannot be converted from Utf8. + #[error(transparent)] + Utf8Error(#[from] std::str::Utf8Error), + /// Invalid float. + #[error(transparent)] + InvalidFloat(#[from] std::num::ParseFloatError), + /// Could not convert from decimal string. + #[error("Invalid decimal string: {0}")] + FromDecStrError(String), + /// Overflowed while parsing. + #[error("Overflow parsing string")] + ParseOverflow, + /// Could not convert from signed decimal string. + #[error("Parse Signed Error")] + ParseI256Error(#[from] ParseSignedError), + /// Invalid checksum. + #[error("Invalid address checksum")] + InvalidAddressChecksum, + /// Invalid hex. + #[error(transparent)] + FromHexError(
::Err), +} + +/// Divides the provided amount with 10^{units} provided. +pub fn format_units(amount: T, units: K) -> Result +where + T: Into, + K: TryInto, +{ + let units: usize = units.try_into()?.into(); + let amount = amount.into(); + + match amount { + // 2**256 ~= 1.16e77 + ParseUnits::U256(_) if units >= OVERFLOW_U256_UNITS => { + return Err(ConversionError::ParseOverflow) + } + // 2**255 ~= 5.79e76 + ParseUnits::I256(_) if units >= OVERFLOW_I256_UNITS => { + return Err(ConversionError::ParseOverflow) + } + _ => {} + }; + let exp10 = U256::pow(U256::from(10), U256::from(units)); + + // `decimals` are formatted twice because U256 does not support alignment (`:0>width`). + match amount { + ParseUnits::U256(amount) => { + let integer = amount / exp10; + let decimals = (amount % exp10).to_string(); + Ok(format!("{integer}.{decimals:0>units$}")) + } + ParseUnits::I256(amount) => { + let exp10 = I256::from_raw(exp10); + let sign = if amount.is_negative() { "-" } else { "" }; + let integer = (amount / exp10).twos_complement(); + let decimals = ((amount % exp10).twos_complement()).to_string(); + Ok(format!("{sign}{integer}.{decimals:0>units$}")) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use Units::*; + + #[test] + fn test_units() { + assert_eq!(Wei.as_num(), 0); + assert_eq!(Kwei.as_num(), 3); + assert_eq!(Mwei.as_num(), 6); + assert_eq!(Gwei.as_num(), 9); + assert_eq!(Twei.as_num(), 12); + assert_eq!(Pwei.as_num(), 15); + assert_eq!(Ether.as_num(), 18); + assert_eq!(Other(10).as_num(), 10); + assert_eq!(Other(20).as_num(), 20); + } + + #[test] + fn test_into() { + assert_eq!(Units::try_from("wei").unwrap(), Wei); + assert_eq!(Units::try_from("kwei").unwrap(), Kwei); + assert_eq!(Units::try_from("mwei").unwrap(), Mwei); + assert_eq!(Units::try_from("gwei").unwrap(), Gwei); + assert_eq!(Units::try_from("twei").unwrap(), Twei); + assert_eq!(Units::try_from("pwei").unwrap(), Pwei); + assert_eq!(Units::try_from("ether").unwrap(), Ether); + + assert_eq!(Units::try_from("wei".to_string()).unwrap(), Wei); + assert_eq!(Units::try_from("kwei".to_string()).unwrap(), Kwei); + assert_eq!(Units::try_from("mwei".to_string()).unwrap(), Mwei); + assert_eq!(Units::try_from("gwei".to_string()).unwrap(), Gwei); + assert_eq!(Units::try_from("twei".to_string()).unwrap(), Twei); + assert_eq!(Units::try_from("pwei".to_string()).unwrap(), Pwei); + assert_eq!(Units::try_from("ether".to_string()).unwrap(), Ether); + + assert_eq!(Units::try_from(&"wei".to_string()).unwrap(), Wei); + assert_eq!(Units::try_from(&"kwei".to_string()).unwrap(), Kwei); + assert_eq!(Units::try_from(&"mwei".to_string()).unwrap(), Mwei); + assert_eq!(Units::try_from(&"gwei".to_string()).unwrap(), Gwei); + assert_eq!(Units::try_from(&"twei".to_string()).unwrap(), Twei); + assert_eq!(Units::try_from(&"pwei".to_string()).unwrap(), Pwei); + assert_eq!(Units::try_from(&"ether".to_string()).unwrap(), Ether); + } +} diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 0a2faa6c89a6b..637f87d0f12f9 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -13,10 +13,12 @@ repository.workspace = true [dependencies] # eth ethers-core.workspace = true -ethers-solc = { workspace = true, features = ["async", "svm-solc"] } -ethers-etherscan.workspace = true +alloy-primitives = { workspace = true, features = ["std", "serde"] } revm-primitives = { workspace = true, default-features = false, features = ["std"] } +foundry-compilers = { workspace = true, features = ["async", "svm-solc"] } +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"]} + # formats Inflector = "0.11" figment = { version = "0.10", features = ["toml", "env"] } diff --git a/crates/config/src/chain.rs b/crates/config/src/chain.rs index 8e60eafdff701..40dac60cc3c88 100644 --- a/crates/config/src/chain.rs +++ b/crates/config/src/chain.rs @@ -1,5 +1,6 @@ use crate::U256; -use ethers_core::types::{Chain as NamedChain, U64}; +use alloy_primitives::U64; +use ethers_core::types::Chain as NamedChain; use eyre::Result; use open_fastrlp::{Decodable, Encodable}; use serde::{Deserialize, Deserializer, Serialize}; @@ -76,7 +77,7 @@ impl From for Chain { impl From for Chain { fn from(id: U256) -> Self { - id.as_u64().into() + id.to::().into() } } @@ -91,13 +92,13 @@ impl From for u64 { impl From for U64 { fn from(c: Chain) -> Self { - u64::from(c).into() + U64::from(u64::from(c)) } } impl From for U256 { fn from(c: Chain) -> Self { - u64::from(c).into() + U256::from(u64::from(c)) } } diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index aaf1e42abf98e..d78621d317e72 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -251,11 +251,12 @@ impl ResolvedEtherscanConfig { self } - /// Returns the corresponding `ethers_etherscan::Client`, configured with the `api_url`, + /// Returns the corresponding `foundry_block_explorers::Client`, configured with the `api_url`, /// `api_key` and cache pub fn into_client( self, - ) -> Result { + ) -> Result + { let ResolvedEtherscanConfig { api_url, browser_url, key: api_key, chain } = self; let (mainnet_api, mainnet_url) = ethers_core::types::Chain::Mainnet.etherscan_urls().expect("exist; qed"); @@ -278,7 +279,7 @@ impl ResolvedEtherscanConfig { } } - ethers_etherscan::Client::builder() + foundry_block_explorers::Client::builder() .with_client(reqwest::Client::builder().user_agent(ETHERSCAN_USER_AGENT).build()?) .with_api_key(api_key) .with_api_url(api_url.as_str())? diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index 5601c10b5c32b..af579763a846a 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -1,6 +1,6 @@ //! Configuration for fuzz testing -use ethers_core::types::U256; +use alloy_primitives::U256; use serde::{Deserialize, Serialize}; use crate::inline::{ @@ -19,9 +19,6 @@ pub struct FuzzConfig { /// `prop_filter`. pub max_test_rejects: u32, /// Optional seed for the fuzzing RNG algorithm - #[serde( - deserialize_with = "ethers_core::types::serde_helpers::deserialize_stringified_numeric_opt" - )] pub seed: Option, /// The fuzz dictionary configuration #[serde(flatten)] diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 6bb2862de6473..407317d32894d 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -1,5 +1,5 @@ use super::{remove_whitespaces, INLINE_CONFIG_PREFIX, INLINE_CONFIG_PREFIX_SELECTED_PROFILE}; -use ethers_solc::{ +use foundry_compilers::{ artifacts::{ast::NodeType, Node}, ProjectCompileOutput, }; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 15bed4ff20249..04598261086c3 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -3,9 +3,16 @@ #![warn(missing_docs, unused_crate_dependencies)] use crate::cache::StorageCachingConfig; -use ethers_core::types::{Address, Chain::Mainnet, H160, H256, U256}; -pub use ethers_solc::{self, artifacts::OptimizerDetails}; -use ethers_solc::{ +use alloy_primitives::{address, Address, B256, U256}; +use ethers_core::types::Chain::Mainnet; +use eyre::{ContextCompat, WrapErr}; +use figment::{ + providers::{Env, Format, Serialized, Toml}, + value::{Dict, Map, Value}, + Error, Figment, Metadata, Profile, Provider, +}; +pub use foundry_compilers::{self, artifacts::OptimizerDetails}; +use foundry_compilers::{ artifacts::{ output_selection::ContractOutputSelection, serde_helpers, BytecodeHash, DebuggingSettings, Libraries, ModelCheckerSettings, ModelCheckerTarget, Optimizer, RevertStrings, Settings, @@ -16,12 +23,6 @@ use ethers_solc::{ remappings::{RelativeRemapping, Remapping}, ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, SolcConfig, }; -use eyre::{ContextCompat, WrapErr}; -use figment::{ - providers::{Env, Format, Serialized, Toml}, - value::{Dict, Map, Value}, - Error, Figment, Metadata, Profile, Provider, -}; use inflector::Inflector; use once_cell::sync::Lazy; use regex::Regex; @@ -271,7 +272,7 @@ pub struct Config { /// the `block.difficulty` value during EVM execution pub block_difficulty: u64, /// Before merge the `block.max_hash` after merge it is `block.prevrandao` - pub block_prevrandao: H256, + pub block_prevrandao: B256, /// the `block.gaslimit` value during EVM execution pub block_gas_limit: Option, /// The memory limit of the EVM (32 MB by default) @@ -339,7 +340,7 @@ pub struct Config { /// /// If this option is enabled, only the required contracts/files will be selected to be /// included in solc's output selection, see also - /// [OutputSelection](ethers_solc::artifacts::output_selection::OutputSelection) + /// [OutputSelection](foundry_compilers::artifacts::output_selection::OutputSelection) pub sparse_mode: bool, /// Whether to emit additional build info files /// @@ -419,10 +420,7 @@ impl Config { /// Default address for tx.origin /// /// `0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38` - pub const DEFAULT_SENDER: H160 = H160([ - 0x18, 0x04, 0xc8, 0xAB, 0x1F, 0x12, 0xE6, 0xbb, 0xF3, 0x89, 0x4D, 0x40, 0x83, 0xF3, 0x3E, - 0x07, 0x30, 0x9D, 0x1F, 0x38, - ]); + pub const DEFAULT_SENDER: Address = address!("1804c8AB1F12E6bbf3894d4083f33e07309d1f38"); /// Returns the current `Config` /// @@ -999,7 +997,7 @@ impl Config { Optimizer { enabled: Some(self.optimizer), runs: Some(self.optimizer_runs), details } } - /// returns the [`ethers_solc::ConfigurableArtifacts`] for this config, that includes the + /// returns the [`foundry_compilers::ConfigurableArtifacts`] for this config, that includes the /// `extra_output` fields pub fn configured_artifacts_handler(&self) -> ConfigurableArtifacts { let mut extra_output = self.extra_output.clone(); @@ -1806,7 +1804,7 @@ impl Default for Config { code_size_limit: None, gas_price: None, block_base_fee_per_gas: 0, - block_coinbase: Address::zero(), + block_coinbase: Address::ZERO, block_timestamp: 1, block_difficulty: 0, block_prevrandao: Default::default(), @@ -2517,7 +2515,7 @@ pub(crate) mod from_str_lowercase { fn canonic(path: impl Into) -> PathBuf { let path = path.into(); - ethers_solc::utils::canonicalize(&path).unwrap_or(path) + foundry_compilers::utils::canonicalize(&path).unwrap_or(path) } #[cfg(test)] @@ -2529,9 +2527,10 @@ mod tests { etherscan::ResolvedEtherscanConfigs, fs_permissions::PathPermission, }; + use alloy_primitives::Address; use ethers_core::types::Chain::Moonbeam; - use ethers_solc::artifacts::{ModelCheckerEngine, YulDetails}; use figment::{error::Kind::InvalidType, value::Value, Figment}; + use foundry_compilers::artifacts::{ModelCheckerEngine, YulDetails}; use pretty_assertions::assert_eq; use std::{collections::BTreeMap, fs::File, io::Write, str::FromStr}; use tempfile::tempdir; @@ -2546,7 +2545,7 @@ mod tests { fn default_sender() { assert_eq!( Config::DEFAULT_SENDER, - "0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38".parse().unwrap() + Address::from_str("0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38").unwrap() ); } @@ -3445,7 +3444,7 @@ mod tests { let config = Config::load_with_root(jail.directory()); - assert_eq!(config.fuzz.seed, Some(1000.into())); + assert_eq!(config.fuzz.seed, Some(U256::from(1000))); assert_eq!( config.remappings, vec![Remapping::from_str("nested/=lib/nested/").unwrap().into()] @@ -4103,7 +4102,7 @@ mod tests { // canonicalize the jail path using the standard library. The standard library *always* // transforms Windows paths to some weird extended format, which none of our code base // does. - let dir = ethers_solc::utils::canonicalize(jail.directory()) + let dir = foundry_compilers::utils::canonicalize(jail.directory()) .expect("Could not canonicalize jail path"); assert_eq!( loaded.model_checker, diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index dde49ce8f9016..bb5a852a9c66d 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -1,9 +1,9 @@ use crate::{foundry_toml_dirs, remappings_from_env_var, remappings_from_newline, Config}; -use ethers_solc::remappings::{RelativeRemapping, Remapping}; use figment::{ value::{Dict, Map}, Error, Metadata, Profile, Provider, }; +use foundry_compilers::remappings::{RelativeRemapping, Remapping}; use std::{ borrow::Cow, collections::{btree_map::Entry, BTreeMap, HashSet}, diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 4c0263e5b1e71..5651dac409a7a 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -1,12 +1,12 @@ //! Utility functions use crate::Config; -use ethers_core::types::{serde_helpers::Numeric, U256}; -use ethers_solc::{ +use alloy_primitives::U256; +use figment::value::Value; +use foundry_compilers::{ remappings::{Remapping, RemappingError}, EvmVersion, }; -use figment::value::Value; use revm_primitives::SpecId; use serde::{de::Error, Deserialize, Deserializer}; use std::{ @@ -155,7 +155,7 @@ pub fn foundry_toml_dirs(root: impl AsRef) -> Vec { .into_iter() .filter_map(Result::ok) .filter(|e| e.file_type().is_dir()) - .filter_map(|e| ethers_solc::utils::canonicalize(e.path()).ok()) + .filter_map(|e| foundry_compilers::utils::canonicalize(e.path()).ok()) .filter(|p| p.join(Config::FILE_NAME).exists()) .collect() } @@ -222,8 +222,7 @@ pub(crate) fn deserialize_stringified_percent<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, { - let num: U256 = - Numeric::deserialize(deserializer)?.try_into().map_err(serde::de::Error::custom)?; + let num: U256 = Numeric::deserialize(deserializer)?.into(); let num: u64 = num.try_into().map_err(serde::de::Error::custom)?; if num <= 100 { num.try_into().map_err(serde::de::Error::custom) @@ -259,6 +258,37 @@ where Ok(num) } +/// Helper type to parse both `u64` and `U256` +#[derive(Copy, Clone, Deserialize)] +#[serde(untagged)] +pub enum Numeric { + /// A [U256] value. + U256(U256), + /// A `u64` value. + Num(u64), +} + +impl From for U256 { + fn from(n: Numeric) -> U256 { + match n { + Numeric::U256(n) => n, + Numeric::Num(n) => U256::from(n), + } + } +} + +impl FromStr for Numeric { + type Err = String; + + fn from_str(s: &str) -> Result { + if s.starts_with("0x") { + U256::from_str_radix(s, 16).map(Numeric::U256).map_err(|err| err.to_string()) + } else { + U256::from_str(s).map(Numeric::U256).map_err(|err| err.to_string()) + } + } +} + /// Returns the [SpecId] derived from [EvmVersion] #[inline] pub fn evm_spec_id(evm_version: &EvmVersion) -> SpecId { diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index c90f8f87fa2d4..2a01594606fb8 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -12,7 +12,6 @@ repository.workspace = true [dependencies] foundry-evm.workspace = true foundry-common.workspace = true -foundry-utils.workspace = true alloy-primitives.workspace = true diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index 3c7b54abe500c..eb59780194b0f 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,7 +1,6 @@ use crate::{TUIExitReason, Tui, Ui}; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder}; -use foundry_utils::types::ToAlloy; use tracing::{error, trace}; /// Standardized way of firing up the debugger @@ -33,9 +32,7 @@ impl DebuggerArgs<'_> { .decoder .contracts .iter() - .map(|(addr, identifier)| { - ((*addr).to_alloy(), get_contract_name(identifier).to_string()) - }) + .map(|(addr, identifier)| ((*addr), get_contract_name(identifier).to_string())) .collect(); let tui = Tui::new( diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index f3518cbad2a69..7fc74325dcb7f 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -16,7 +16,6 @@ use foundry_evm::{ utils::{build_pc_ic_map, PCICMap}, CallKind, }; -use foundry_utils::types::ToAlloy; use ratatui::{ backend::{Backend, CrosstermBackend}, layout::{Alignment, Constraint, Direction, Layout, Rect}, @@ -1105,7 +1104,7 @@ impl Ui for Tui { // address with this pc) if let Some((caller, pc)) = self.breakpoints.get(&c) { for (i, (_caller, debug_steps, _)) in debug_call.iter().enumerate() { - if _caller == &caller.to_alloy() { + if _caller == caller { if let Some(step) = debug_steps.iter().position(|step| step.pc == *pc) { diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 4b82a0bced8ed..fb5f8dcc14f1b 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -17,9 +17,10 @@ foundry-config.workspace = true foundry-utils.workspace = true # ethers -ethers-solc = { workspace = true, features = ["async"] } ethers-core.workspace = true +foundry-compilers = { workspace = true, features = ["async"] } + # tracing tracing.workspace = true diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index ecc9bd3ac14f9..09594e8c458ca 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -2,8 +2,8 @@ use crate::{ document::DocumentContent, helpers::merge_toml_table, AsDoc, BufWriter, Document, ParseItem, ParseSource, Parser, Preprocessor, }; -use ethers_solc::utils::source_files_iter; use forge_fmt::{FormatterConfig, Visitable}; +use foundry_compilers::utils::source_files_iter; use foundry_config::DocConfig; use foundry_utils::glob::expand_globs; use itertools::Itertools; diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 6182921ee90ad..2716133d914a5 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -16,7 +16,10 @@ foundry-common.workspace = true foundry-config.workspace = true foundry-macros.workspace = true -ethers = { workspace = true, features = ["ethers-solc"] } +ethers = { workspace = true, features = ["ethers-solc"]} + +foundry-compilers = { workspace = true, default-features = false } +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } # Encoding/decoding serde_json = "1" @@ -50,7 +53,9 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } -alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } +alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-json-abi = { workspace = true } +alloy-sol-types.workspace = true # Fuzzer proptest = "1" diff --git a/crates/evm/src/coverage/analysis.rs b/crates/evm/src/coverage/analysis.rs index b9f54a7499b90..a28dc6ea77db4 100644 --- a/crates/evm/src/coverage/analysis.rs +++ b/crates/evm/src/coverage/analysis.rs @@ -1,6 +1,6 @@ use super::{ContractId, CoverageItem, CoverageItemKind, SourceLocation}; -use ethers::solc::artifacts::ast::{self, Ast, Node, NodeType}; use foundry_common::TestFunctionExt; +use foundry_compilers::artifacts::ast::{self, Ast, Node, NodeType}; use semver::Version; use std::collections::{HashMap, HashSet}; @@ -211,7 +211,7 @@ impl<'a> ContractVisitor<'a> { // is virtually impossible to correctly map instructions back to branches that // include more complex logic like conditional logic. self.push_branches( - ðers::solc::artifacts::ast::LowFidelitySourceLocation { + &foundry_compilers::artifacts::ast::LowFidelitySourceLocation { start: node.src.start, length: true_body .src diff --git a/crates/evm/src/coverage/anchors.rs b/crates/evm/src/coverage/anchors.rs index 750388c088b6c..bbba9544286ce 100644 --- a/crates/evm/src/coverage/anchors.rs +++ b/crates/evm/src/coverage/anchors.rs @@ -1,7 +1,7 @@ use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; use crate::utils::ICPCMap; use alloy_primitives::Bytes; -use ethers::prelude::sourcemap::{SourceElement, SourceMap}; +use foundry_compilers::sourcemap::{SourceElement, SourceMap}; use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, diff --git a/crates/evm/src/debug.rs b/crates/evm/src/debug.rs index be6252109e72c..d4c97fedf95be 100644 --- a/crates/evm/src/debug.rs +++ b/crates/evm/src/debug.rs @@ -180,7 +180,7 @@ impl Display for Instruction { "VM_{}", &*HEVM_ABI .functions() - .find(|func| func.short_signature() == *cheat) + .find(|func| func.selector() == *cheat) .expect("unknown cheatcode found in debugger") .name .to_uppercase() diff --git a/crates/evm/src/decode.rs b/crates/evm/src/decode.rs index 261adbfc4a3b4..9386c098548f2 100644 --- a/crates/evm/src/decode.rs +++ b/crates/evm/src/decode.rs @@ -1,26 +1,22 @@ //! Various utilities to decode test results -use crate::{ - abi::ConsoleEvents::{self, *}, - executor::inspector::cheatcodes::util::MAGIC_SKIP_BYTES, -}; -use alloy_primitives::B256; -use ethers::{ - abi::{decode, AbiDecode, Contract as Abi, ParamType, RawLog, Token}, - contract::EthLogDecode, - prelude::U256, - types::Log, -}; +use crate::executor::inspector::cheatcodes::util::MAGIC_SKIP_BYTES; +use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; +use alloy_json_abi::JsonAbi; +use alloy_primitives::{B256, U256}; +use alloy_sol_types::{sol_data::String as SolString, SolType}; +use ethers::{abi::RawLog, contract::EthLogDecode, types::Log}; +use foundry_abi::console::ConsoleEvents::{self, *}; use foundry_common::{abi::format_token, SELECTOR_LEN}; use foundry_utils::error::ERROR_PREFIX; use itertools::Itertools; use once_cell::sync::Lazy; use revm::interpreter::{return_ok, InstructionResult}; +use thiserror::Error; /// Decode a set of logs, only returning logs from DSTest logging events and Hardhat's `console.log` pub fn decode_console_logs(logs: &[Log]) -> Vec { logs.iter().filter_map(decode_console_log).collect() } - /// Decode a single log. /// /// This function returns [None] if it is not a DSTest log or the result of a Hardhat @@ -67,20 +63,41 @@ pub fn decode_console_log(log: &Log) -> Option { Some(decoded) } +/// Possible errors when decoding a revert error string. +#[derive(Debug, Clone, Error)] +pub enum RevertDecodingError { + #[error("Not enough data to decode")] + InsufficientErrorData, + #[error("Unsupported solidity builtin panic")] + UnsupportedSolidityBuiltinPanic, + #[error("Could not decode slice")] + SliceDecodingError, + #[error("Non-native error and not string")] + NonNativeErrorAndNotString, + #[error("Unknown Error Selector")] + UnknownErrorSelector, + #[error("Could not decode cheatcode string")] + UnknownCheatcodeErrorString, + #[error("Bad String decode")] + BadStringDecode, + #[error(transparent)] + AlloyDecodingError(alloy_dyn_abi::Error), +} + /// Given an ABI encoded error string with the function signature `Error(string)`, it decodes /// it and returns the revert error message. pub fn decode_revert( err: &[u8], - maybe_abi: Option<&Abi>, + maybe_abi: Option<&JsonAbi>, status: Option, -) -> eyre::Result { +) -> Result { if err.len() < SELECTOR_LEN { if let Some(status) = status { if !matches!(status, return_ok!()) { return Ok(format!("EvmError: {status:?}")) } } - eyre::bail!("Not enough error data to decode") + return Err(RevertDecodingError::InsufficientErrorData) } match err[..SELECTOR_LEN] { // keccak(Panic(uint256)) @@ -123,20 +140,23 @@ pub fn decode_revert( // calling a zero initialized variable of internal function type Ok("Calling a zero initialized variable of internal function type".to_string()) } - _ => { - eyre::bail!("Unsupported solidity builtin panic") - } + _ => Err(RevertDecodingError::UnsupportedSolidityBuiltinPanic), } } // keccak(Error(string)) - [8, 195, 121, 160] => { - String::decode(&err[SELECTOR_LEN..]).map_err(|_| eyre::eyre!("Bad string decode")) - } + [8, 195, 121, 160] => DynSolType::abi_decode(&DynSolType::String, &err[SELECTOR_LEN..]) + .map_err(RevertDecodingError::AlloyDecodingError) + .and_then(|v| { + v.clone().as_str().map(|s| s.to_owned()).ok_or(RevertDecodingError::BadStringDecode) + }) + .to_owned(), // keccak(expectRevert(bytes)) [242, 141, 206, 179] => { let err_data = &err[SELECTOR_LEN..]; if err_data.len() > 64 { - let len = U256::from(&err_data[32..64]).as_usize(); + let len = U256::try_from_be_slice(&err_data[32..64]) + .ok_or(RevertDecodingError::SliceDecodingError)? + .to::(); if err_data.len() > 64 + len { let actual_err = &err_data[64..64 + len]; if let Ok(decoded) = decode_revert(actual_err, maybe_abi, None) { @@ -148,7 +168,7 @@ pub fn decode_revert( } } } - eyre::bail!("Non-native error and not string") + Err(RevertDecodingError::NonNativeErrorAndNotString) } // keccak(expectRevert(bytes4)) [195, 30, 176, 224] => { @@ -160,7 +180,7 @@ pub fn decode_revert( return Ok(decoded) } } - eyre::bail!("Unknown error selector") + Err(RevertDecodingError::UnknownErrorSelector) } _ => { // See if the revert is caused by a skip() call. @@ -170,10 +190,11 @@ pub fn decode_revert( // try to decode a custom error if provided an abi if let Some(abi) = maybe_abi { for abi_error in abi.errors() { - if abi_error.signature()[..SELECTOR_LEN] == err[..SELECTOR_LEN] { + if abi_error.signature()[..SELECTOR_LEN].as_bytes() == &err[..SELECTOR_LEN] { // if we don't decode, don't return an error, try to decode as a // string later - if let Ok(decoded) = abi_error.decode(&err[SELECTOR_LEN..]) { + if let Ok(decoded) = abi_error.abi_decode_input(&err[SELECTOR_LEN..], false) + { let inputs = decoded .iter() .map(foundry_common::abi::format_token) @@ -184,20 +205,35 @@ pub fn decode_revert( } } } + // optimistically try to decode as string, unknown selector or `CheatcodeError` - String::decode(err) - .ok() + let error = DynSolType::abi_decode(&DynSolType::String, err) + .map_err(|_| RevertDecodingError::BadStringDecode) + .and_then(|v| { + v.as_str().map(|s| s.to_owned()).ok_or(RevertDecodingError::BadStringDecode) + }) + .ok(); + + let error = error.filter(|err| err.as_str() != ""); + error .or_else(|| { // try decoding as cheatcode error if err.starts_with(ERROR_PREFIX.as_slice()) { - String::decode(&err[ERROR_PREFIX.len()..]).ok() + DynSolType::abi_decode(&DynSolType::String, &err[ERROR_PREFIX.len()..]) + .map_err(|_| RevertDecodingError::UnknownCheatcodeErrorString) + .and_then(|v| { + v.as_str() + .map(|s| s.to_owned()) + .ok_or(RevertDecodingError::UnknownCheatcodeErrorString) + }) + .ok() } else { None } }) .or_else(|| { // try decoding as unknown err - String::decode(&err[SELECTOR_LEN..]) + SolString::abi_decode(&err[SELECTOR_LEN..], false) .map(|err_str| format!("{}:{err_str}", hex::encode(&err[..SELECTOR_LEN]))) .ok() }) @@ -214,49 +250,43 @@ pub fn decode_revert( } }) }) - .ok_or_else(|| eyre::eyre!("Non-native error and not string")) + .ok_or_else(|| RevertDecodingError::NonNativeErrorAndNotString) } } } /// Tries to optimistically decode a custom solc error, with at most 4 arguments -pub fn decode_custom_error(err: &[u8]) -> Option { +pub fn decode_custom_error(err: &[u8]) -> Option { decode_custom_error_args(err, 4) } /// Tries to optimistically decode a custom solc error with a maximal amount of arguments /// /// This will brute force decoding of custom errors with up to `args` arguments -pub fn decode_custom_error_args(err: &[u8], args: usize) -> Option { +pub fn decode_custom_error_args(err: &[u8], args: usize) -> Option { if err.len() <= SELECTOR_LEN { return None } let err = &err[SELECTOR_LEN..]; /// types we check against - static TYPES: Lazy> = Lazy::new(|| { + static TYPES: Lazy> = Lazy::new(|| { vec![ - ParamType::Address, - ParamType::Bool, - ParamType::Uint(256), - ParamType::Int(256), - ParamType::Bytes, - ParamType::String, + DynSolType::Address, + DynSolType::Bool, + DynSolType::Uint(256), + DynSolType::Int(256), + DynSolType::Bytes, + DynSolType::String, ] }); - macro_rules! try_decode { - ($ty:ident) => { - if let Ok(mut decoded) = decode(&[$ty], err) { - return Some(decoded.remove(0)) - } - }; - } - // check if single param, but only if it's a single word if err.len() == 32 { - for ty in TYPES.iter().cloned() { - try_decode!(ty); + for ty in TYPES.iter() { + if let Ok(decoded) = ty.abi_decode(err) { + return Some(decoded) + } } return None } @@ -264,15 +294,17 @@ pub fn decode_custom_error_args(err: &[u8], args: usize) -> Option { // brute force decode all possible combinations for num in (2..=args).rev() { for candidate in TYPES.iter().cloned().combinations(num) { - if let Ok(decoded) = decode(&candidate, err) { - return Some(Token::Tuple(decoded)) + if let Ok(decoded) = DynSolType::abi_decode(&DynSolType::Tuple(candidate), err) { + return Some(decoded) } } } // try as array - for ty in TYPES.iter().cloned().map(|ty| ParamType::Array(Box::new(ty))) { - try_decode!(ty); + for ty in TYPES.iter().cloned().map(|ty| DynSolType::Array(Box::new(ty))) { + if let Ok(decoded) = ty.abi_decode(err) { + return Some(decoded) + } } None @@ -281,36 +313,36 @@ pub fn decode_custom_error_args(err: &[u8], args: usize) -> Option { #[cfg(test)] mod tests { use super::*; - use ethers::{ - abi::{AbiEncode, Address}, - contract::EthError, - }; + use alloy_primitives::{Address, U256}; + use alloy_sol_types::{sol, SolError}; #[test] fn test_decode_custom_error_address() { - #[derive(Debug, Clone, EthError)] - struct AddressErr(Address); - let err = AddressErr(Address::random()); + sol! { + error AddressErr(address addr); + } + let err = AddressErr { addr: Address::random() }; - let encoded = err.clone().encode(); + let encoded = err.abi_encode(); let decoded = decode_custom_error(&encoded).unwrap(); - assert_eq!(decoded, Token::Address(err.0)); + assert_eq!(decoded, DynSolValue::Address(err.addr)); } #[test] fn test_decode_custom_error_args3() { - #[derive(Debug, Clone, EthError)] - struct MyError(Address, bool, U256); - let err = MyError(Address::random(), true, 100u64.into()); + sol! { + error MyError(address addr, bool b, uint256 val); + } + let err = MyError { addr: Address::random(), b: true, val: U256::from(100u64) }; - let encoded = err.clone().encode(); + let encoded = err.clone().abi_encode(); let decoded = decode_custom_error(&encoded).unwrap(); assert_eq!( decoded, - Token::Tuple(vec![ - Token::Address(err.0), - Token::Bool(err.1), - Token::Uint(100u64.into()), + DynSolValue::Tuple(vec![ + DynSolValue::Address(err.addr), + DynSolValue::Bool(err.b), + DynSolValue::Uint(U256::from(100u64), 256), ]) ); } diff --git a/crates/evm/src/executor/abi/mod.rs b/crates/evm/src/executor/abi/mod.rs index c75898acb8b9d..ecd17a870beb2 100644 --- a/crates/evm/src/executor/abi/mod.rs +++ b/crates/evm/src/executor/abi/mod.rs @@ -1,10 +1,11 @@ //! Several ABI-related utilities for executors. +use alloy_json_abi::JsonAbi; use alloy_primitives::Address; pub use foundry_abi::{ - console::{self, ConsoleEvents, CONSOLE_ABI}, - hardhat_console::{self, HardhatConsoleCalls, HARDHATCONSOLE_ABI as HARDHAT_CONSOLE_ABI}, - hevm::{self, HEVMCalls, HEVM_ABI}, + console::{self, ConsoleEvents}, + hardhat_console::{self, HardhatConsoleCalls}, + hevm::{self, HEVMCalls}, }; use once_cell::sync::Lazy; use std::collections::HashMap; @@ -38,6 +39,641 @@ pub fn patch_hardhat_console_selector(input: &mut Vec) { } } +pub static HEVM_ABI: Lazy = Lazy::new(|| { + // TODO: Move to file & find a way to sync with actual HEVM.sol + JsonAbi::parse([ + "function allowCheatcodes(address)", +"function tryFfi(string[])(tuple(int32,bytes,bytes))", +"function ffi(string[])(bytes)", +"function breakpoint(string)", +"function breakpoint(string,bool)", +"function roll(uint256)", +"function warp(uint256)", +"function difficulty(uint256)", +"function prevrandao(bytes32)", +"function fee(uint256)", +"function coinbase(address)", +"function store(address,bytes32,bytes32)", +"function load(address,bytes32)(bytes32)", +"function cool(address)", +"function setEnv(string,string)", +"function envBool(string)(bool)", +"function envUint(string)(uint256)", +"function envInt(string)(int256)", +"function envAddress(string)(address)", +"function envBytes32(string)(bytes32)", +"function envString(string)(string)", +"function envBytes(string)(bytes)", +"function envBool(string,string)(bool[])", +"function envUint(string,string)(uint256[])", +"function envInt(string,string)(int256[])", +"function envAddress(string,string)(address[])", +"function envBytes32(string,string)(bytes32[])", +"function envString(string,string)(string[])", +"function envBytes(string,string)(bytes[])", +"function envOr(string,bool)(bool)", +"function envOr(string,uint256)(uint256)", +"function envOr(string,int256)(int256)", +"function envOr(string,address)(address)", +"function envOr(string,bytes32)(bytes32)", +"function envOr(string,string)(string)", +"function envOr(string,bytes)(bytes)", +"function envOr(string,string,bool[])(bool[])", +"function envOr(string,string,uint256[])(uint256[])", +"function envOr(string,string,int256[])(int256[])", +"function envOr(string,string,address[])(address[])", +"function envOr(string,string,bytes32[])(bytes32[])", +"function envOr(string,string,string[])(string[])", +"function envOr(string,string,bytes[])(bytes[])", +"function addr(uint256)(address)", +"function sign(uint256,bytes32)(uint8,bytes32,bytes32)", +"function deriveKey(string,uint32)(uint256)", +"function deriveKey(string,string,uint32)(uint256)", +"function deriveKey(string,uint32,string)(uint256)", +"function deriveKey(string,string,uint32,string)(uint256)", +"function rememberKey(uint256)(address)", +"function createWallet(string)(tuple(address,uint256,uint256,uint256))", +"function createWallet(uint256)(tuple(address,uint256,uint256,uint256))", +"function createWallet(uint256,string)(tuple(address,uint256,uint256,uint256))", +"function sign(tuple(address,uint256,uint256,uint256),bytes32)(uint8,bytes32,bytes32)", +"function getNonce(tuple(address,uint256,uint256,uint256))(uint64)", +"function prank(address)", +"function prank(address,address)", +"function readCallers()(uint256,address,address)", +"function startPrank(address)", +"function startPrank(address,address)", +"function stopPrank()", +"function deal(address,uint256)", +"function etch(address,bytes)", +"function expectRevert()", +"function expectRevert(bytes)", +"function expectRevert(bytes4)", +"function record()", +"function accesses(address)(bytes32[], bytes32[])", +"function skip(bool)", +"function recordLogs()", +"function getRecordedLogs()(tuple(bytes32,bytes)[])", +"function expectEmit()", +"function expectEmit(address)", +"function expectEmit(bool,bool,bool,bool)", +"function expectEmit(bool,bool,bool,bool,address)", +"function mockCall(address,bytes,bytes)", +"function mockCall(address,uint256,bytes,bytes)", +"function mockCallRevert(address,bytes,bytes)", +"function mockCallRevert(address,uint256,bytes,bytes)", +"function clearMockedCalls()", +"function expectCall(address,bytes)", +"function expectCall(address,bytes,uint64)", +"function expectCall(address,uint256,bytes)", +"function expectCall(address,uint256,bytes,uint64)", +"function expectCall(address,uint256,uint64,bytes)", +"function expectCall(address,uint256,uint64,bytes,uint64)", +"function expectCallMinGas(address,uint256,uint64,bytes)", +"function expectCallMinGas(address,uint256,uint64,bytes,uint64)", +"function expectSafeMemory(uint64,uint64)", +"function expectSafeMemoryCall(uint64,uint64)", +"function getCode(string)", +"function getDeployedCode(string)", +"function label(address,string)", +"function getLabel(address)(string)", +"function assume(bool)", +"function setNonce(address,uint64)", +"function getNonce(address)", +"function resetNonce(address)", +"function setNonceUnsafe(address,uint64)", +"function chainId(uint256)", +"function txGasPrice(uint256)", +"function broadcast()", +"function broadcast(address)", +"function broadcast(uint256)", +"function startBroadcast()", +"function startBroadcast(address)", +"function startBroadcast(uint256)", +"function stopBroadcast()", +"function projectRoot()(string)", +"function openFile(string)", +"function readFile(string)(string)", +"function readFileBinary(string)(bytes)", +"function readLine(string)(string)", +"function writeFile(string,string)", +"function writeFileBinary(string,bytes)", +"function writeLine(string,string)", +"function copyFile(string,string)", +"function closeFile(string)", +"function removeFile(string)", +"function createDir(string, bool)", +"function removeDir(string, bool)", +"function readDir(string)(tuple(string,string,uint64,bool,bool)[])", +"function readDir(string, uint64)(tuple(string,string,uint64,bool,bool)[])", +"function readDir(string, uint64, bool)(tuple(string,string,uint64,bool,bool)[])", +"function readLink(string)(string)", +"function fsMetadata(string)(tuple(bool,bool,uint256,bool,uint256,uint256,uint256))", +"function exists(string)(bool)", +"function isFile(string)(bool)", +"function isDir(string)(bool)", +"function toString(bytes)", +"function toString(address)", +"function toString(uint256)", +"function toString(int256)", +"function toString(bytes32)", +"function toString(bool)", +"function parseBytes(string)(bytes)", +"function parseAddress(string)(address)", +"function parseUint(string)(uint256)", +"function parseInt(string)(int256)", +"function parseBytes32(string)(bytes32)", +"function parseBool(string)(bool)", +"function snapshot()(uint256)", +"function revertTo(uint256)(bool)", +"function createFork(string,uint256)(uint256)", +"function createFork(string,bytes32)(uint256)", +"function createFork(string)(uint256)", +"function createSelectFork(string,uint256)(uint256)", +"function createSelectFork(string,bytes32)(uint256)", +"function createSelectFork(string)(uint256)", +"function selectFork(uint256)", +"function activeFork()(uint256)", +"function transact(bytes32)", +"function transact(uint256,bytes32)", +"function makePersistent(address)", +"function makePersistent(address,address)", +"function makePersistent(address,address,address)", +"function makePersistent(address[])", +"function revokePersistent(address)", +"function revokePersistent(address[])", +"function isPersistent(address)(bool)", +"function rollFork(uint256)", +"function rollFork(bytes32)", +"function rollFork(uint256,uint256)", +"function rollFork(uint256,bytes32)", +"function rpcUrl(string)(string)", +"function rpcUrls()(string[2][])", +"function rpcUrlStructs()(tuple(string,string)[])", +"function eth_getLogs(uint256,uint256,address,bytes32[])(tuple(address,bytes32[],bytes,uint256,bytes32,uint256,bytes32,uint256,bool)[])", +"function rpc(string,string)(bytes)", +"function writeJson(string, string)", +"function writeJson(string, string, string)", +"function parseJson(string)(bytes)", +"function parseJson(string, string)(bytes)", +"function parseJsonKeys(string, string)(string[])", +"function parseJsonUint(string, string)(uint256)", +"function parseJsonUintArray(string, string)(uint256[])", +"function parseJsonInt(string, string)(int256)", +"function parseJsonIntArray(string, string)(int256[])", +"function parseJsonString(string, string)(string)", +"function parseJsonStringArray(string, string)(string[])", +"function parseJsonAddress(string, string)(address)", +"function parseJsonAddressArray(string, string)(address[])", +"function parseJsonBool(string, string)(bool)", +"function parseJsonBoolArray(string, string)(bool[])", +"function parseJsonBytes(string, string)(bytes)", +"function parseJsonBytesArray(string, string)(bytes[])", +"function parseJsonBytes32(string, string)(bytes32)", +"function parseJsonBytes32Array(string, string)(bytes32[])", +"function serializeJson(string,string)(string)", +"function serializeBool(string,string,bool)(string)", +"function serializeBool(string,string,bool[])(string)", +"function serializeUint(string,string,uint256)(string)", +"function serializeUint(string,string,uint256[])(string)", +"function serializeInt(string,string,int256)(string)", +"function serializeInt(string,string,int256[])(string)", +"function serializeAddress(string,string,address)(string)", +"function serializeAddress(string,string,address[])(string)", +"function serializeBytes32(string,string,bytes32)(string)", +"function serializeBytes32(string,string,bytes32[])(string)", +"function serializeString(string,string,string)(string)", +"function serializeString(string,string,string[])(string)", +"function serializeBytes(string,string,bytes)(string)", +"function serializeBytes(string,string,bytes[])(string)", +"function keyExists(string,string)(bool)", +"function pauseGasMetering()", +"function resumeGasMetering()", +"function startMappingRecording()", +"function stopMappingRecording()", +"function getMappingLength(address,bytes32)", +"function getMappingSlotAt(address,bytes32,uint256)", +"function getMappingKeyAndParentOf(address,bytes32)", +"function sleep(uint256)", +"function unixTime()(uint256)", + ]).expect("Could not parse HEVM abi") +}); + +pub static HARDHAT_CONSOLE_ABI: Lazy = Lazy::new(|| { + // TODO: Move to file + JsonAbi::parse([ + "function log(address p0, address p1, string p2)", + "function log(bool p0, uint256 p1, uint256 p2, address p3)", + "function log(address p0, address p1, address p2)", + "function log(uint256 p0, address p1, address p2, string p3)", + "function log(string p0, address p1, bool p2, string p3)", + "function log(uint256 p0, bool p1, address p2, uint256 p3)", + "function log(bool p0, address p1, bool p2, uint256 p3)", + "function log(bool p0, uint256 p1, address p2)", + "function log(uint256 p0, address p1, address p2, bool p3)", + "function log(address p0, bool p1, uint256 p2, string p3)", + "function log(bool p0, bool p1, uint256 p2, uint256 p3)", + "function log(bool p0, address p1, address p2, uint256 p3)", + "function log(uint256 p0, address p1, uint256 p2, uint256 p3)", + "function log(string p0, address p1, uint256 p2)", + "function log(address p0, string p1, address p2, address p3)", + "function log(address p0, string p1, address p2, bool p3)", + "function log(address p0, address p1, address p2, bool p3)", + "function log(address p0, string p1, uint256 p2, bool p3)", + "function log(address p0, uint256 p1, address p2, uint256 p3)", + "function log(string p0, string p1, uint256 p2, address p3)", + "function log(bool p0, bool p1, address p2)", + "function log(bool p0, string p1, uint256 p2)", + "function log(bool p0, string p1, address p2, string p3)", + "function log(bool p0, bool p1, uint256 p2)", + "function log(bool p0, address p1, uint256 p2, address p3)", + "function log(bool p0, uint256 p1, address p2, uint256 p3)", + "function log(bool p0, string p1, uint256 p2, address p3)", + "function log(address p0, string p1, string p2, uint256 p3)", + "function log(uint256 p0, address p1, uint256 p2, address p3)", + "function log(uint256 p0, uint256 p1, address p2, bool p3)", + "function log(bool p0, string p1, bool p2, uint256 p3)", + "function log(bool p0, string p1, string p2, string p3)", + "function log(address p0, address p1, uint256 p2)", + "function log(bool p0, address p1, bool p2)", + "function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3)", + "function log(address p0, bool p1, string p2, address p3)", + "function log(bool p0, string p1, uint256 p2, string p3)", + "function log(bool p0, uint256 p1, address p2, string p3)", + "function log(bool p0, address p1, bool p2, address p3)", + "function log(string p0, uint256 p1, address p2)", + "function log(uint256 p0, bool p1)", + "function log(bool p0, address p1, address p2, address p3)", + "function log(address p0, uint256 p1, address p2, string p3)", + "function log(address p0, string p1, uint256 p2, uint256 p3)", + "function log(bool p0, string p1, string p2, bool p3)", + "function log(uint256 p0, bool p1, uint256 p2)", + "function log(address p0, string p1, bool p2, address p3)", + "function log(uint256 p0, bool p1, bool p2)", + "function log(address p0, uint256 p1, uint256 p2, address p3)", + "function log(address p0, bool p1, string p2)", + "function log(uint256 p0, string p1, string p2, string p3)", + "function log(address p0, address p1, string p2, string p3)", + "function log(string p0, address p1, bool p2, address p3)", + "function log(address p0, uint256 p1, bool p2, uint256 p3)", + "function log(string p0, address p1, string p2, string p3)", + "function log(uint256 p0, address p1, address p2, address p3)", + "function log(string p0, bool p1, string p2, uint256 p3)", + "function log(bool p0, bool p1, string p2)", + "function log(bool p0, uint256 p1, address p2, address p3)", + "function log(uint256 p0, uint256 p1, string p2, string p3)", + "function log(bool p0, string p1, uint256 p2, uint256 p3)", + "function log(bool p0, bool p1)", + "function log(bool p0, bool p1, bool p2, string p3)", + "function log(bool p0, string p1, address p2, address p3)", + "function log(string p0, string p1, string p2, bool p3)", + "function log(uint256 p0, bool p1, string p2, uint256 p3)", + "function log(address p0)", + "function log(address p0, address p1, bool p2, bool p3)", + "function log(string p0, string p1, string p2)", + "function log(string p0, bool p1, address p2, string p3)", + "function log(address p0, bool p1, address p2, string p3)", + "function log(string p0, address p1)", + "function log(bool p0)", + "function log(string p0, bool p1, address p2, address p3)", + "function log(address p0, uint256 p1, uint256 p2, uint256 p3)", + "function log(uint256 p0, bool p1, address p2)", + "function log(string p0, uint256 p1, bool p2, bool p3)", + "function log(address p0, string p1, string p2, bool p3)", + "function log(bool p0, uint256 p1, uint256 p2)", + "function log(bool p0, uint256 p1, uint256 p2, uint256 p3)", + "function log(uint256 p0, string p1, uint256 p2)", + "function log(address p0, bool p1, uint256 p2, uint256 p3)", + "function log(address p0, address p1, bool p2, uint256 p3)", + "function log(bool p0, uint256 p1)", + "function log(uint256 p0, string p1, uint256 p2, address p3)", + "function log(bool p0, bool p1, bool p2, bool p3)", + "function log(address p0, uint256 p1, bool p2, bool p3)", + "function log(uint256 p0, address p1, string p2, string p3)", + "function log(string p0, address p1, bool p2, uint256 p3)", + "function log(string p0, bool p1, string p2, bool p3)", + "function log(string p0, string p1, bool p2, bool p3)", + "function log(string p0)", + "function log(uint256 p0, uint256 p1, string p2, address p3)", + "function log(string p0, string p1, address p2, address p3)", + "function log(address p0, string p1, uint256 p2, string p3)", + "function log(uint256 p0, bool p1, address p2, bool p3)", + "function log(address p0, string p1, address p2, uint256 p3)", + "function log(bool p0, address p1, address p2, bool p3)", + "function log(uint256 p0, address p1, string p2, uint256 p3)", + "function log(address p0, bool p1, string p2, string p3)", + "function log(uint256 p0, uint256 p1, bool p2)", + "function log(address p0, uint256 p1, address p2, address p3)", + "function log(bool p0, string p1, bool p2, string p3)", + "function log(address p0, uint256 p1, uint256 p2, string p3)", + "function log(bool p0, address p1, bool p2, string p3)", + "function log(string p0, string p1)", + "function log(bool p0, bool p1, address p2, uint256 p3)", + "function log(uint256 p0, string p1, bool p2)", + "function log(string p0, uint256 p1, address p2, uint256 p3)", + "function log(bool p0, bool p1, bool p2)", + "function log(address p0, bool p1, string p2, bool p3)", + "function log(address p0, string p1, bool p2, uint256 p3)", + "function log()", + "function log(bool p0, address p1, uint256 p2, string p3)", + "function log(bool p0, string p1, bool p2, address p3)", + "function log(bool p0, bool p1, uint256 p2, address p3)", + "function log(uint256 p0, uint256 p1, address p2, address p3)", + "function log(string p0, string p1, uint256 p2)", + "function log(string p0, uint256 p1, string p2)", + "function log(uint256 p0, uint256 p1, uint256 p2, string p3)", + "function log(string p0, address p1, uint256 p2, string p3)", + "function log(uint256 p0, address p1, uint256 p2)", + "function log(string p0, uint256 p1, string p2, string p3)", + "function log(uint256 p0, address p1, bool p2, uint256 p3)", + "function log(address p0, uint256 p1, string p2, address p3)", + "function log(uint256 p0, uint256 p1, address p2)", + "function log(string p0, string p1, address p2, bool p3)", + "function log(address p0, string p1, string p2, string p3)", + "function log(string p0, bool p1, address p2, uint256 p3)", + "function log(string p0, string p1, uint256 p2, string p3)", + "function log(uint256 p0, uint256 p1, string p2, uint256 p3)", + "function log(string p0, string p1, bool p2, string p3)", + "function log(string p0, uint256 p1, address p2, address p3)", + "function log(string p0, address p1, string p2, bool p3)", + "function log(address p0, string p1, bool p2, bool p3)", + "function log(uint256 p0, address p1, uint256 p2, bool p3)", + "function log(bool p0, address p1, uint256 p2)", + "function log(uint256 p0, string p1, address p2, address p3)", + "function log(bool p0, bool p1, uint256 p2, bool p3)", + "function log(address p0, string p1, uint256 p2, address p3)", + "function log(uint256 p0, address p1, string p2)", + "function log(string p0, address p1, uint256 p2, address p3)", + "function log(uint256 p0, string p1)", + "function log(string p0, bool p1, uint256 p2, uint256 p3)", + "function log(address p0, bool p1, address p2, address p3)", + "function log(address p0, address p1, address p2, address p3)", + "function log(address p0, uint256 p1, uint256 p2, bool p3)", + "function log(address p0, uint256 p1, bool p2)", + "function log(address p0, string p1, uint256 p2)", + "function log(uint256 p0, bool p1, string p2, string p3)", + "function log(uint256 p0, string p1, uint256 p2, bool p3)", + "function log(uint256 p0, address p1)", + "function log(uint256 p0, bool p1, bool p2, address p3)", + "function log(bool p0, uint256 p1, string p2, uint256 p3)", + "function log(bool p0, address p1, bool p2, bool p3)", + "function log(bool p0, string p1, uint256 p2, bool p3)", + "function log(uint256 p0, uint256 p1, address p2, string p3)", + "function log(bool p0, bool p1, string p2, string p3)", + "function log(string p0, string p1, string p2, address p3)", + "function log(bool p0, bool p1, bool p2, uint256 p3)", + "function log(bool p0, string p1, address p2, bool p3)", + "function log(address p0, address p1, string p2, bool p3)", + "function log(bool p0, address p1, string p2, address p3)", + "function log(string p0, bool p1, bool p2, address p3)", + "function log(uint256 p0, uint256 p1, string p2)", + "function log(uint256 p0, address p1, address p2, uint256 p3)", + "function log(string p0, bool p1, uint256 p2, string p3)", + "function log(uint256 p0, bool p1, bool p2, uint256 p3)", + "function log(address p0, string p1)", + "function log(address p0, bool p1)", + "function log(string p0, uint256 p1, uint256 p2, bool p3)", + "function log(string p0, address p1, bool p2, bool p3)", + "function log(uint256 p0, uint256 p1, string p2, bool p3)", + "function log(uint256 p0, string p1, address p2)", + "function log(address p0, uint256 p1, address p2)", + "function log(bool p0, string p1, string p2, uint256 p3)", + "function log(bool p0, address p1, uint256 p2, uint256 p3)", + "function log(string p0, uint256 p1, string p2, address p3)", + "function log(string p0, string p1, address p2, uint256 p3)", + "function log(string p0, uint256 p1, string p2, bool p3)", + "function log(bool p0, bool p1, uint256 p2, string p3)", + "function log(bool p0, uint256 p1, bool p2, uint256 p3)", + "function log(string p0, address p1, address p2, string p3)", + "function log(address p0, bool p1, string p2, uint256 p3)", + "function log(string p0, uint256 p1, address p2, bool p3)", + "function log(uint256 p0, string p1, uint256 p2, uint256 p3)", + "function log(address p0, uint256 p1)", + "function log(string p0, bool p1, bool p2)", + "function log(bool p0, address p1)", + "function log(string p0, uint256 p1, uint256 p2, string p3)", + "function log(uint256 p0, bool p1, string p2)", + "function log(address p0, uint256 p1, string p2, string p3)", + "function log(uint256 p0, bool p1, uint256 p2, address p3)", + "function log(uint256 p0, uint256 p1, address p2, uint256 p3)", + "function log(string p0, bool p1, bool p2, bool p3)", + "function log(string p0, bool p1, uint256 p2, bool p3)", + "function log(bool p0, bool p1, bool p2, address p3)", + "function log(address p0, bool p1, bool p2, uint256 p3)", + "function log(address p0, address p1, uint256 p2, address p3)", + "function log(string p0, bool p1, bool p2, uint256 p3)", + "function log(bool p0, uint256 p1, uint256 p2, string p3)", + "function log(string p0, string p1, string p2, uint256 p3)", + "function log(string p0, address p1, address p2, uint256 p3)", + "function log(address p0, address p1, string p2, address p3)", + "function log(bool p0, string p1)", + "function log(uint256 p0, string p1, address p2, bool p3)", + "function log(uint256 p0, address p1, bool p2, string p3)", + "function log(bool p0, uint256 p1, bool p2, string p3)", + "function log(uint256 p0, bool p1, uint256 p2, bool p3)", + "function log(string p0, address p1, string p2, uint256 p3)", + "function log(string p0, bool p1, address p2)", + "function log(string p0, bool p1, uint256 p2, address p3)", + "function log(address p0, address p1, address p2, uint256 p3)", + "function log(string p0, bool p1, address p2, bool p3)", + "function log(bool p0, string p1, address p2)", + "function log(string p0, string p1, address p2)", + "function log(bool p0, string p1, string p2, address p3)", + "function log(uint256 p0, uint256 p1, bool p2, address p3)", + "function log(bool p0, uint256 p1, bool p2, address p3)", + "function log(address p0, address p1, uint256 p2, bool p3)", + "function log(uint256 p0, address p1, bool p2)", + "function log(uint256 p0, string p1, address p2, string p3)", + "function log(address p0, bool p1, uint256 p2)", + "function log(uint256 p0, address p1, string p2, address p3)", + "function log(string p0, bool p1, bool p2, string p3)", + "function log(address p0, address p1, bool p2, address p3)", + "function log(string p0, uint256 p1, address p2, string p3)", + "function log(address p0, string p1, string p2, address p3)", + "function log(bool p0, bool p1, address p2, string p3)", + "function log(address p0, uint256 p1, address p2, bool p3)", + "function log(uint256 p0, bool p1, address p2, address p3)", + "function log(address p0, uint256 p1, string p2)", + "function log(address p0, uint256 p1, bool p2, address p3)", + "function log(uint256 p0, uint256 p1, bool p2, string p3)", + "function log(bool p0, string p1, address p2, uint256 p3)", + "function log(address p0, bool p1, address p2, bool p3)", + "function log(bool p0, address p1, string p2, string p3)", + "function log(address p0, bool p1, address p2, uint256 p3)", + "function log(string p0, uint256 p1, uint256 p2, uint256 p3)", + "function log(string p0, bool p1, string p2, string p3)", + "function log(address p0, address p1, bool p2, string p3)", + "function log(string p0, address p1, string p2, address p3)", + "function log(uint256 p0, uint256 p1, bool p2, bool p3)", + "function log(string p0, uint256 p1, bool p2, string p3)", + "function log(uint256 p0, bool p1, address p2, string p3)", + "function log(uint256 p0, string p1, bool p2, address p3)", + "function log(uint256 p0, string p1, string p2, uint256 p3)", + "function log(bool p0, string p1, string p2)", + "function log(string p0, string p1, bool p2)", + "function log(uint256 p0, string p1, string p2)", + "function log(uint256 p0, string p1, string p2, bool p3)", + "function log(bool p0, uint256 p1, address p2, bool p3)", + "function log(string p0, address p1, address p2, bool p3)", + "function log(string p0, uint256 p1)", + "function log(address p0, uint256 p1, uint256 p2)", + "function log(uint256 p0, bool p1, bool p2, bool p3)", + "function log(uint256 p0, string p1, uint256 p2, string p3)", + "function log(bool p0, bool p1, string p2, bool p3)", + "function log(uint256 p0, string p1, bool p2, bool p3)", + "function log(address p0, string p1, bool p2, string p3)", + "function log(uint256 p0, address p1, address p2)", + "function log(address p0, address p1, uint256 p2, uint256 p3)", + "function log(bool p0, uint256 p1, uint256 p2, bool p3)", + "function log(address p0, uint256 p1, string p2, uint256 p3)", + "function log(bool p0, bool p1, address p2, bool p3)", + "function log(bool p0, address p1, string p2, uint256 p3)", + "function log(string p0, string p1, bool p2, address p3)", + "function log(string p0, string p1, uint256 p2, bool p3)", + "function log(string p0, bool p1)", + "function log(bool p0, uint256 p1, string p2)", + "function log(address p0, bool p1, uint256 p2, bool p3)", + "function log(uint256 p0, uint256 p1, uint256 p2, bool p3)", + "function log(address p0, uint256 p1, bool p2, string p3)", + "function log(string p0, uint256 p1, string p2, uint256 p3)", + "function log(uint256 p0, bool p1, uint256 p2, uint256 p3)", + "function log(string p0, address p1, bool p2)", + "function log(string p0, bool p1, uint256 p2)", + "function log(string p0, uint256 p1, uint256 p2)", + "function log(string p0, uint256 p1, bool p2)", + "function log(address p0, bool p1, bool p2, bool p3)", + "function log(uint256 p0, address p1, string p2, bool p3)", + "function log(address p0, bool p1, uint256 p2, address p3)", + "function log(bool p0, uint256 p1, bool p2, bool p3)", + "function log(uint256 p0, string p1, bool p2, uint256 p3)", + "function log(address p0, string p1, bool p2)", + "function log(address p0, uint256 p1, string p2, bool p3)", + "function log(address p0, bool p1, bool p2, address p3)", + "function log(uint256 p0, uint256 p1, uint256 p2)", + "function log(bool p0, address p1, address p2)", + "function log(uint256 p0, string p1, bool p2, string p3)", + "function log(uint256 p0, string p1, string p2, address p3)", + "function log(bool p0, address p1, uint256 p2, bool p3)", + "function log(string p0, string p1, bool p2, uint256 p3)", + "function log(bool p0, address p1, address p2, string p3)", + "function log(address p0, address p1)", + "function log(bool p0, string p1, bool p2)", + "function log(bool p0, string p1, bool p2, bool p3)", + "function log(uint256 p0, address p1, uint256 p2, string p3)", + "function log(uint256 p0, bool p1, bool p2, string p3)", + "function log(uint256 p0, bool p1, uint256 p2, string p3)", + "function log(string p0, string p1, string p2, string p3)", + "function log(bool p0, address p1, string p2)", + "function log(address p0, bool p1, bool p2, string p3)", + "function log(string p0, bool p1, string p2, address p3)", + "function log(string p0, uint256 p1, bool p2, address p3)", + "function log(string p0, address p1, string p2)", + "function log(string p0, uint256 p1, uint256 p2, address p3)", + "function log(string p0, bool p1, string p2)", + "function log(bool p0, address p1, string p2, bool p3)", + "function log(uint256 p0, address p1, bool p2, bool p3)", + "function log(bool p0, bool p1, string p2, uint256 p3)", + "function log(string p0, uint256 p1, bool p2, uint256 p3)", + "function log(bool p0, uint256 p1, string p2, bool p3)", + "function log(uint256 p0, string p1, address p2, uint256 p3)", + "function log(bool p0, uint256 p1, bool p2)", + "function log(string p0, string p1, address p2, string p3)", + "function log(uint256 p0, uint256 p1, bool p2, uint256 p3)", + "function log(address p0, bool p1, bool p2)", + "function log(uint256 p0, bool p1, string p2, bool p3)", + "function log(string p0, address p1, address p2, address p3)", + "function log(address p0, address p1, string p2, uint256 p3)", + "function log(uint256 p0, bool p1, string p2, address p3)", + "function log(uint256 p0, address p1, bool p2, address p3)", + "function log(address p0, string p1, address p2)", + "function log(address p0, bool p1, address p2)", + "function log(address p0, address p1, bool p2)", + "function log(string p0, string p1, uint256 p2, uint256 p3)", + "function log(bool p0, bool p1, address p2, address p3)", + "function log(bool p0, uint256 p1, string p2, string p3)", + "function log(uint256 p0, uint256 p1)", + "function log(address p0, string p1, address p2, string p3)", + "function log(address p0, address p1, address p2, string p3)", + "function log(uint256 p0)", + "function log(string p0, address p1, uint256 p2, uint256 p3)", + "function log(bool p0, bool p1, string p2, address p3)", + "function log(uint256 p0, uint256 p1, uint256 p2, address p3)", + "function log(address p0, string p1, string p2)", + "function log(string p0, address p1, uint256 p2, bool p3)", + "function log(string p0, address p1, address p2)", + "function log(address p0, address p1, uint256 p2, string p3)", + "function log(bool p0, uint256 p1, string p2, address p3)", + "function logAddress(address p0)", + "function logBool(bool p0)", + "function logBytes(bytes p0)", + "function logBytes1(bytes1 p0)", + "function logBytes10(bytes10 p0)", + "function logBytes11(bytes11 p0)", + "function logBytes12(bytes12 p0)", + "function logBytes13(bytes13 p0)", + "function logBytes14(bytes14 p0)", + "function logBytes15(bytes15 p0)", + "function logBytes16(bytes16 p0)", + "function logBytes17(bytes17 p0)", + "function logBytes18(bytes18 p0)", + "function logBytes19(bytes19 p0)", + "function logBytes2(bytes2 p0)", + "function logBytes20(bytes20 p0)", + "function logBytes21(bytes21 p0)", + "function logBytes22(bytes22 p0)", + "function logBytes23(bytes23 p0)", + "function logBytes24(bytes24 p0)", + "function logBytes25(bytes25 p0)", + "function logBytes26(bytes26 p0)", + "function logBytes27(bytes27 p0)", + "function logBytes28(bytes28 p0)", + "function logBytes29(bytes29 p0)", + "function logBytes3(bytes3 p0)", + "function logBytes30(bytes30 p0)", + "function logBytes31(bytes31 p0)", + "function logBytes32(bytes32 p0)", + "function logBytes4(bytes4 p0)", + "function logBytes5(bytes5 p0)", + "function logBytes6(bytes6 p0)", + "function logBytes7(bytes7 p0)", + "function logBytes8(bytes8 p0)", + "function logBytes9(bytes9 p0)", + "function logInt(int256 p0)", + "function logString(string p0)", + "function logUint(uint256 p0)", + "function log(int256 p0)", + "function log(string p0, int256 p1)", + ]) + .expect("Could not parse HardhatConsole abi") +}); + +pub static CONSOLE_ABI: Lazy = Lazy::new(|| { + JsonAbi::parse([ + "event log(string)", + "event logs (bytes)", + "event log_address (address)", + "event log_bytes32 (bytes32)", + "event log_int (int)", + "event log_uint (uint)", + "event log_bytes (bytes)", + "event log_string (string)", + "event log_array (uint256[] val)", + "event log_array (int256[] val)", + "event log_array (address[] val)", + "event log_named_address (string key, address val)", + "event log_named_decimal_int (string key, int val, uint decimals)", + "event log_named_bytes32 (string key, bytes32 val)", + "event log_named_decimal_uint (string key, uint val, uint decimals)", + "event log_named_int (string key, int val)", + "event log_named_uint (string key, uint val)", + "event log_named_bytes (string key, bytes val)", + "event log_named_string (string key, string val)", + "event log_named_array (string key, uint256[] val)", + "event log_named_array (string key, int256[] val)", + "event log_named_array (string key, address[] val)", + ]) + .expect("Could not parase console ABI") +}); + /// This contains a map with all the `hardhat/console.log` log selectors that use `uint` or `int` /// as key and the selector of the call with `uint256`, /// diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/src/executor/backend/mod.rs index f429e552a3c98..f159ef82c6dbe 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/src/executor/backend/mod.rs @@ -16,11 +16,10 @@ use crate::{ }, CALLER, TEST_CONTRACT_ADDRESS, }; -use alloy_primitives::{b256, Address, B256, U256, U64}; +use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; use ethers::{ prelude::Block, types::{BlockNumber, Transaction}, - utils::keccak256, }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_utils::types::{ToAlloy, ToEthers}; @@ -866,7 +865,7 @@ impl Backend { for tx in full_block.transactions.into_iter() { // System transactions such as on L2s don't contain any pricing info so we skip them // otherwise this would cause reverts - if is_known_system_sender(tx.from) || + if is_known_system_sender(tx.from.to_alloy()) || tx.transaction_type.map(|ty| ty.as_u64()) == Some(SYSTEM_TRANSACTION_TYPE) { continue diff --git a/crates/evm/src/executor/fork/backend.rs b/crates/evm/src/executor/fork/backend.rs index b589f0c2ad0c8..f296796b7097f 100644 --- a/crates/evm/src/executor/fork/backend.rs +++ b/crates/evm/src/executor/fork/backend.rs @@ -3,12 +3,11 @@ use crate::executor::{ backend::error::{DatabaseError, DatabaseResult}, fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }; -use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; use ethers::{ core::abi::ethereum_types::BigEndianHash, providers::Middleware, types::{Block, BlockId, NameOrAddress, Transaction}, - utils::keccak256, }; use foundry_common::NON_ARCHIVE_NODE_WARNING; use foundry_utils::types::{ToAlloy, ToEthers}; @@ -348,7 +347,7 @@ where // convert it to revm-style types let (code, code_hash) = if !code.0.is_empty() { - (Some(code.0.clone()), keccak256(&code).into()) + (Some(code.0.clone()), keccak256(&code)) } else { (Some(bytes::Bytes::default()), KECCAK_EMPTY) }; diff --git a/crates/evm/src/executor/fork/multi.rs b/crates/evm/src/executor/fork/multi.rs index 2393cd450c075..8be587090b67e 100644 --- a/crates/evm/src/executor/fork/multi.rs +++ b/crates/evm/src/executor/fork/multi.rs @@ -7,7 +7,6 @@ use crate::executor::fork::{ BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend, }; use ethers::{ - abi::{AbiDecode, AbiEncode, AbiError}, providers::Provider, types::{BlockId, BlockNumber}, }; @@ -49,18 +48,6 @@ impl> From for ForkId { } } -impl AbiEncode for ForkId { - fn encode(self) -> Vec { - AbiEncode::encode(self.0) - } -} - -impl AbiDecode for ForkId { - fn decode(bytes: impl AsRef<[u8]>) -> Result { - Ok(Self(String::decode(bytes)?)) - } -} - /// The Sender half of multi fork pair. /// Can send requests to the `MultiForkHandler` to create forks #[derive(Debug, Clone)] diff --git a/crates/evm/src/executor/inspector/cheatcodes/config.rs b/crates/evm/src/executor/inspector/cheatcodes/config.rs index ebf5e4396c37c..58438c238b9e2 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/config.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/config.rs @@ -1,7 +1,7 @@ use super::{ensure, fmt_err, Result}; use crate::executor::opts::EvmOpts; -use ethers::solc::{utils::canonicalize, ProjectPathsConfig}; use foundry_common::fs::normalize_path; +use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, ResolvedRpcEndpoints, diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/src/executor/inspector/cheatcodes/env.rs index 96cf49ce929c9..6de3d2d2af947 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/env.rs @@ -14,7 +14,7 @@ use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Address, Bytes, Log, B256, U256}; use ethers::signers::{LocalWallet, Signer}; use foundry_config::Config; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_utils::types::ToAlloy; use revm::{ primitives::{Bytecode, SpecId, KECCAK_EMPTY}, Database, EVMData, @@ -337,7 +337,7 @@ fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: boo // add a breakpoint from the interpreter if add { - state.breakpoints.insert(point, (caller.to_ethers(), state.pc)); + state.breakpoints.insert(point, (caller, state.pc)); } else { state.breakpoints.remove(&point); } @@ -753,7 +753,7 @@ fn correct_sender_nonce( db: &mut DB, state: &mut Cheatcodes, ) -> Result<(), DB::Error> { - if !state.corrected_nonce && sender.to_ethers() != Config::DEFAULT_SENDER { + if !state.corrected_nonce && sender != Config::DEFAULT_SENDER { with_journaled_account(journaled_state, db, sender, |account| { account.info.nonce = account.info.nonce.saturating_sub(1); state.corrected_nonce = true; diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/src/executor/inspector/fuzzer.rs index 3c873b5673859..f738a26e1a8b4 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/src/executor/inspector/fuzzer.rs @@ -3,7 +3,7 @@ use crate::{ utils, }; use alloy_primitives::Bytes; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_utils::types::ToEthers; use revm::{ interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, Database, EVMData, Inspector, @@ -96,21 +96,21 @@ impl Fuzzer { fn override_call(&mut self, call: &mut CallInputs) { if let Some(ref mut call_generator) = self.call_generator { // We only override external calls which are not coming from the test contract. - if call.context.caller != call_generator.test_address.to_alloy() && + if call.context.caller != call_generator.test_address && call.context.scheme == CallScheme::Call && !call_generator.used { // There's only a 30% chance that an override happens. if let Some((sender, (contract, input))) = - call_generator.next(call.context.caller.to_ethers(), call.contract.to_ethers()) + call_generator.next(call.context.caller, call.contract) { *call.input = input.0; - call.context.caller = sender.to_alloy(); - call.contract = contract.to_alloy(); + call.context.caller = sender; + call.contract = contract; // TODO: in what scenarios can the following be problematic - call.context.code_address = contract.to_alloy(); - call.context.address = contract.to_alloy(); + call.context.code_address = contract; + call.context.address = contract; call_generator.used = true; } diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/src/executor/inspector/tracer.rs index 349df0f8eeee8..9e2848498b731 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/src/executor/inspector/tracer.rs @@ -7,9 +7,7 @@ use crate::{ }, CallKind, }; -use alloy_primitives::{Address, Bytes, B256, U256}; -use ethers::abi::RawLog; -use foundry_utils::types::ToEthers; +use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; use revm::{ interpreter::{ opcode, return_ok, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, @@ -46,12 +44,12 @@ impl Tracer { 0, CallTrace { depth, - address: address.to_ethers(), + address, kind, data: RawOrDecodedCall::Raw(data.into()), - value: value.to_ethers(), + value, status: InstructionResult::Continue, - caller: caller.to_ethers(), + caller, ..Default::default() }, )); @@ -74,7 +72,7 @@ impl Tracer { trace.output = RawOrDecodedReturnData::Raw(output.into()); if let Some(address) = address { - trace.address = address.to_ethers(); + trace.address = address; } } @@ -89,7 +87,7 @@ impl Tracer { depth: data.journaled_state.depth(), pc: interp.program_counter(), op: OpCode(interp.current_opcode()), - contract: interp.contract.address.to_ethers(), + contract: interp.contract.address, stack: interp.stack.clone(), memory: interp.memory.clone(), gas: interp.gas.remaining(), @@ -124,7 +122,7 @@ impl Tracer { Some(JournalEntry::StorageChange { address, key, .. }), ) => { let value = data.journaled_state.state[address].storage[key].present_value(); - Some((key.to_ethers(), value.to_ethers())) + Some((*key, value)) } _ => None, }; @@ -163,9 +161,11 @@ impl Inspector for Tracer { #[inline] fn log(&mut self, _: &mut EVMData<'_, DB>, _: &Address, topics: &[B256], data: &Bytes) { let node = &mut self.traces.arena[*self.trace_stack.last().expect("no ongoing trace")]; - let topics: Vec<_> = topics.iter().copied().map(|t| t.to_ethers()).collect(); node.ordering.push(LogCallOrder::Log(node.logs.len())); - node.logs.push(RawOrDecodedLog::Raw(RawLog { topics, data: data.to_vec() })); + let data = data.clone(); + node.logs.push(RawOrDecodedLog::Raw( + RawLog::new(topics.to_vec(), data).expect("Received invalid log"), + )); } #[inline] diff --git a/crates/evm/src/executor/mod.rs b/crates/evm/src/executor/mod.rs index 4740dacb8c62c..f00b89d0f083c 100644 --- a/crates/evm/src/executor/mod.rs +++ b/crates/evm/src/executor/mod.rs @@ -13,15 +13,12 @@ pub use abi::{ patch_hardhat_console_selector, HardhatConsoleCalls, CHEATCODE_ADDRESS, CONSOLE_ABI, HARDHAT_CONSOLE_ABI, HARDHAT_CONSOLE_ADDRESS, }; +use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; +use alloy_json_abi::{Function, JsonAbi as Abi}; /// Reexport commonly used revm types pub use alloy_primitives::{Address, Bytes, U256}; use backend::FuzzBackendWrapper; -use ethers::{ - abi::{Abi, Contract, Detokenize, Function, Tokenize}, - prelude::{decode_function_data, encode_function_data}, - signers::LocalWallet, - types::Log, -}; +use ethers::{signers::LocalWallet, types::Log}; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; use revm::primitives::hex_literal::hex; pub use revm::{ @@ -192,16 +189,12 @@ impl Executor { /// /// Ayn changes made during the setup call to env's block environment are persistent, for /// example `vm.chainId()` will change the `block.chainId` for all subsequent test calls. - pub fn setup( - &mut self, - from: Option
, - to: Address, - ) -> Result, EvmError> { + pub fn setup(&mut self, from: Option
, to: Address) -> Result { trace!(?from, ?to, "setting up contract"); let from = from.unwrap_or(CALLER); self.backend.set_test_contract(to).set_caller(from); - let res = self.call_committing::<(), _, _>(from, to, "setUp()", (), U256::ZERO, None)?; + let res = self.call_committing::<_, _>(from, to, "setUp()", vec![], U256::ZERO, None)?; // record any changes made to the block's environment during setup self.env.block = res.env.block.clone(); @@ -239,7 +232,7 @@ impl Executor { /// Performs a call to an account on the current state of the VM. /// /// The state after the call is persisted. - pub fn call_committing( + pub fn call_committing>, F: IntoFunction>( &mut self, from: Address, to: Address, @@ -247,9 +240,9 @@ impl Executor { args: T, value: U256, abi: Option<&Abi>, - ) -> Result, EvmError> { + ) -> Result { let func = func.into(); - let calldata = Bytes::from(encode_function_data(&func, args)?.to_vec()); + let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); let result = self.call_raw_committing(from, to, calldata, value)?; convert_call_result(abi, &func, result) } @@ -271,7 +264,7 @@ impl Executor { } /// Executes the test function call - pub fn execute_test( + pub fn execute_test>, F: IntoFunction>( &mut self, from: Address, test_contract: Address, @@ -279,9 +272,9 @@ impl Executor { args: T, value: U256, abi: Option<&Abi>, - ) -> Result, EvmError> { + ) -> Result { let func = func.into(); - let calldata = Bytes::from(encode_function_data(&func, args)?.to_vec()); + let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); // execute the call let env = self.build_test_env(from, TransactTo::Call(test_contract), calldata, value); @@ -292,7 +285,7 @@ impl Executor { /// Performs a call to an account on the current state of the VM. /// /// The state after the call is not persisted. - pub fn call( + pub fn call>, F: IntoFunction>( &self, from: Address, to: Address, @@ -300,9 +293,9 @@ impl Executor { args: T, value: U256, abi: Option<&Abi>, - ) -> Result, EvmError> { + ) -> Result { let func = func.into(); - let calldata = Bytes::from(encode_function_data(&func, args)?.to_vec()); + let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); let call_result = self.call_raw(from, to, calldata, value)?; convert_call_result(abi, &func, call_result) } @@ -524,16 +517,13 @@ impl Executor { let mut success = !reverted; if success { // Check if a DSTest assertion failed - let call = executor.call::( - CALLER, - address, - "failed()(bool)", - (), - U256::ZERO, - None, - ); + let call = + executor.call::<_, _>(CALLER, address, "failed()(bool)", vec![], U256::ZERO, None); if let Ok(CallResult { result: failed, .. }) = call { + let failed = failed + .as_bool() + .expect("Failed to decode DSTest `failed` variable. This is a bug"); success = !failed; } } @@ -602,7 +592,7 @@ pub enum EvmError { Execution(Box), /// Error which occurred during ABI encoding/decoding #[error(transparent)] - AbiError(#[from] ethers::contract::AbiError), + AbiError(#[from] alloy_dyn_abi::Error), /// Error caused which occurred due to calling the skip() cheatcode. #[error("Skipped")] SkipError, @@ -632,12 +622,12 @@ pub struct DeployResult { /// The result of a call. #[derive(Debug)] -pub struct CallResult { +pub struct CallResult { pub skipped: bool, /// Whether the call reverted or not pub reverted: bool, /// The decoded result of the call - pub result: D, + pub result: DynSolValue, /// The gas used for the call pub gas_used: u64, /// The refunded gas for the call @@ -810,11 +800,11 @@ fn convert_executed_result( }) } -fn convert_call_result( - abi: Option<&Contract>, +fn convert_call_result( + abi: Option<&Abi>, func: &Function, call_result: RawCallResult, -) -> Result, EvmError> { +) -> Result { let RawCallResult { result, exit_reason: status, @@ -842,10 +832,16 @@ fn convert_call_result( match status { return_ok!() => { - let result = decode_function_data(func, result, false)?; + let mut result = func.abi_decode_output(&result, false)?; + let res = if result.len() == 1 { + result.pop().unwrap() + } else { + // combine results into a tuple + DynSolValue::Tuple(result) + }; Ok(CallResult { reverted, - result, + result: res, gas_used, gas_refunded, stipend, diff --git a/crates/evm/src/fuzz/invariant/call_override.rs b/crates/evm/src/fuzz/invariant/call_override.rs index c843848bbd423..2739e79fbc155 100644 --- a/crates/evm/src/fuzz/invariant/call_override.rs +++ b/crates/evm/src/fuzz/invariant/call_override.rs @@ -1,6 +1,6 @@ use super::BasicTxDetails; use crate::executor::Executor; -use ethers::types::{Address, Bytes}; +use alloy_primitives::{Address, Bytes}; use parking_lot::{Mutex, RwLock}; use proptest::{ option::weighted, diff --git a/crates/evm/src/fuzz/invariant/error.rs b/crates/evm/src/fuzz/invariant/error.rs index 99e3efb59c9ea..a51a58ccdf930 100644 --- a/crates/evm/src/fuzz/invariant/error.rs +++ b/crates/evm/src/fuzz/invariant/error.rs @@ -6,7 +6,7 @@ use crate::{ trace::{load_contracts, TraceKind, Traces}, CALLER, }; -use ethers::abi::Function; +use alloy_json_abi::Function; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use proptest::test_runner::TestError; @@ -42,7 +42,7 @@ impl InvariantFuzzError { shrink: bool, ) -> Self { let (func, origin) = if let Some(f) = error_func { - (Some(f.short_signature().into()), f.name.as_str()) + (Some(f.selector().0.into()), f.name.as_str()) } else { (None, "Revert") }; @@ -106,12 +106,7 @@ impl InvariantFuzzError { // Replay each call from the sequence until we break the invariant. for (sender, (addr, bytes)) in calls.iter() { let call_result = executor - .call_raw_committing( - sender.to_alloy(), - addr.to_alloy(), - bytes.0.clone().into(), - U256::ZERO, - ) + .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) .expect("bad call to evm"); logs.extend(call_result.logs); @@ -134,7 +129,7 @@ impl InvariantFuzzError { // Checks the invariant. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, self.addr.to_alloy(), func.0.clone().into(), U256::ZERO) + .call_raw(CALLER, self.addr, func.0.clone().into(), U256::ZERO) .expect("bad call to evm"); traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); @@ -169,18 +164,13 @@ impl InvariantFuzzError { let (sender, (addr, bytes)) = details; executor - .call_raw_committing( - sender.to_alloy(), - addr.to_alloy(), - bytes.0.clone().into(), - U256::ZERO, - ) + .call_raw_committing(*sender, *addr, bytes.0.clone().into(), U256::ZERO) .expect("bad call to evm"); // Checks the invariant. If we exit before the last call, all the better. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, self.addr.to_alloy(), func.0.clone().into(), U256::ZERO) + .call_raw(CALLER, self.addr, func.0.clone().into(), U256::ZERO) .expect("bad call to evm"); if error_call_result.reverted { diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/src/fuzz/invariant/executor.rs index a1b9faee9b0d4..940cfc025dbd4 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/src/fuzz/invariant/executor.rs @@ -19,11 +19,12 @@ use crate::{ utils::get_function, CALLER, }; -use ethers::abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem}; +use alloy_dyn_abi::DynSolValue; +use alloy_json_abi::JsonAbi as Abi; +use alloy_primitives::{Address, FixedBytes}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; -use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::{Mutex, RwLock}; use proptest::{ strategy::{BoxedStrategy, Strategy, ValueTree}, @@ -149,12 +150,7 @@ impl<'a> InvariantExecutor<'a> { // Executes the call from the randomly generated sequence. let call_result = executor - .call_raw( - sender.to_alloy(), - address.to_alloy(), - calldata.0.clone().into(), - rU256::ZERO, - ) + .call_raw(*sender, *address, calldata.clone(), rU256::ZERO) .expect("could not make raw evm call"); // Collect data for fuzzing from the state changeset. @@ -287,7 +283,7 @@ impl<'a> InvariantExecutor<'a> { // EVM execution. let mut call_generator = None; if self.config.call_override { - let target_contract_ref = Arc::new(RwLock::new(Address::zero())); + let target_contract_ref = Arc::new(RwLock::new(Address::ZERO)); call_generator = Some(RandomCallGenerator::new( invariant_contract.address, @@ -323,10 +319,32 @@ impl<'a> InvariantExecutor<'a> { ) -> eyre::Result<()> { // targetArtifactSelectors -> (string, bytes4[])[]. let targeted_abi = self - .get_list::<(String, Vec)>( + .get_list::<(String, Vec>)>( invariant_address, abi, "targetArtifactSelectors", + |v| { + if let Some(list) = v.as_array() { + list.iter().map(|val| { + if let Some((_, _str, elements)) = val.as_custom_struct() { + let name = elements[0].as_str().unwrap().to_string(); + let selectors = elements[1] + .as_array() + .unwrap() + .iter() + .map(|selector| { + FixedBytes::<4>::from_slice(&selector.as_fixed_bytes().unwrap().0[0..4]) + }) + .collect::>(); + (name, selectors) + } else { + panic!("Could not decode inner value of targetArtifactSelectors. This is a bug.") + } + }).collect::>() + } else { + panic!("Could not decode targetArtifactSelectors as array. This is a bug.") + } + }, ) .into_iter() .map(|(contract, functions)| (contract, functions)) @@ -334,15 +352,26 @@ impl<'a> InvariantExecutor<'a> { // Insert them into the executor `targeted_abi`. for (contract, selectors) in targeted_abi { - let identifier = self.validate_selected_contract(contract, &selectors)?; + let identifier = self.validate_selected_contract(contract, &selectors.to_vec())?; - self.artifact_filters.targeted.entry(identifier).or_default().extend(selectors); + self.artifact_filters + .targeted + .entry(identifier) + .or_default() + .extend(selectors.to_vec()); } // targetArtifacts -> string[] // excludeArtifacts -> string[]. - let [selected_abi, excluded_abi] = ["targetArtifacts", "excludeArtifacts"] - .map(|method| self.get_list::(invariant_address, abi, method)); + let [selected_abi, excluded_abi] = ["targetArtifacts", "excludeArtifacts"].map(|method| { + self.get_list::(invariant_address, abi, method, |v| { + if let Some(list) = v.as_array() { + list.iter().map(|v| v.as_str().unwrap().to_string()).collect::>() + } else { + panic!("targetArtifacts should be an array") + } + }) + }); // Insert `excludeArtifacts` into the executor `excluded_abi`. for contract in excluded_abi { @@ -360,7 +389,8 @@ impl<'a> InvariantExecutor<'a> { .filter(|func| { !matches!( func.state_mutability, - ethers::abi::StateMutability::Pure | ethers::abi::StateMutability::View + alloy_json_abi::StateMutability::Pure | + alloy_json_abi::StateMutability::View ) }) .count() == @@ -382,7 +412,6 @@ impl<'a> InvariantExecutor<'a> { self.artifact_filters.targeted.insert(identifier, vec![]); } } - Ok(()) } @@ -391,7 +420,7 @@ impl<'a> InvariantExecutor<'a> { fn validate_selected_contract( &mut self, contract: String, - selectors: &[FixedBytes], + selectors: &[FixedBytes<4>], ) -> eyre::Result { if let Some((artifact, (abi, _))) = self.project_contracts.find_by_name_or_identifier(&contract)? @@ -399,7 +428,7 @@ impl<'a> InvariantExecutor<'a> { // Check that the selectors really exist for this contract. for selector in selectors { abi.functions() - .find(|func| func.short_signature().as_slice() == selector.as_slice()) + .find(|func| func.selector().as_slice() == selector.as_slice()) .wrap_err(format!("{contract} does not have the selector {selector:?}"))?; } @@ -416,8 +445,17 @@ impl<'a> InvariantExecutor<'a> { abi: &Abi, ) -> eyre::Result<(SenderFilters, TargetedContracts)> { let [targeted_senders, excluded_senders, selected, excluded] = - ["targetSenders", "excludeSenders", "targetContracts", "excludeContracts"] - .map(|method| self.get_list::
(invariant_address, abi, method)); + ["targetSenders", "excludeSenders", "targetContracts", "excludeContracts"].map( + |method| { + self.get_list::
(invariant_address, abi, method, |v| { + if let Some(list) = v.as_array() { + list.iter().map(|v| v.as_address().unwrap()).collect::>() + } else { + panic!("targetSenders should be an array") + } + }) + }, + ); let mut contracts: TargetedContracts = self .setup_contracts @@ -425,8 +463,8 @@ impl<'a> InvariantExecutor<'a> { .into_iter() .filter(|(addr, (identifier, _))| { *addr != invariant_address && - *addr != CHEATCODE_ADDRESS.to_ethers() && - *addr != HARDHAT_CONSOLE_ADDRESS.to_ethers() && + *addr != CHEATCODE_ADDRESS && + *addr != HARDHAT_CONSOLE_ADDRESS && (selected.is_empty() || selected.contains(addr)) && (self.artifact_filters.targeted.is_empty() || self.artifact_filters.targeted.contains_key(identifier)) && @@ -454,8 +492,33 @@ impl<'a> InvariantExecutor<'a> { abi: &Abi, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { - let interfaces = - self.get_list::<(Address, Vec)>(invariant_address, abi, "targetInterfaces"); + let interfaces = self.get_list::<(Address, Vec)>( + invariant_address, + abi, + "targetInterfaces", + |v| { + if let Some(l) = v.as_array() { + l.iter() + .map(|v| { + if let Some((_, _names, elements)) = v.as_custom_struct() { + let addr = elements[0].as_address().unwrap(); + let interfaces = elements[1] + .as_array() + .unwrap() + .iter() + .map(|v| v.as_str().unwrap().to_string()) + .collect::>(); + (addr, interfaces) + } else { + panic!("targetInterfaces should be a tuple array") + } + }) + .collect::>() + } else { + panic!("targetInterfaces should be a tuple array") + } + }, + ); // Since `targetInterfaces` returns a tuple array there is no guarantee // that the addresses are unique this map is used to merge functions of @@ -484,7 +547,7 @@ impl<'a> InvariantExecutor<'a> { contract_abi.functions.extend(abi.functions.clone()); }) // Otherwise insert it into the map. - .or_insert_with(|| (identifier.clone(), abi.clone(), vec![])); + .or_insert_with(|| (identifier.to_string(), abi.clone(), vec![])); } } } @@ -522,7 +585,32 @@ impl<'a> InvariantExecutor<'a> { // `targetSelectors() -> (address, bytes4[])[]`. let selectors = - self.get_list::<(Address, Vec)>(address, abi, "targetSelectors"); + self.get_list::<(Address, Vec>)>(address, abi, "targetSelectors", |v| { + if let Some(l) = v.as_array() { + l.iter() + .map(|val| { + if let Some((_, _str, elements)) = val.as_custom_struct() { + let name = elements[0].as_address().unwrap(); + let selectors = elements[1] + .as_array() + .unwrap() + .iter() + .map(|selector| { + FixedBytes::<4>::from_slice( + &selector.as_fixed_bytes().unwrap().0[0..4], + ) + }) + .collect::>(); + (name, selectors) + } else { + panic!("targetSelectors should be a tuple array2") + } + }) + .collect::>() + } else { + panic!("targetSelectors should be a tuple array") + } + }); for (address, bytes4_array) in selectors.into_iter() { self.add_address_with_functions(address, bytes4_array, targeted_contracts)?; @@ -534,7 +622,7 @@ impl<'a> InvariantExecutor<'a> { fn add_address_with_functions( &self, address: Address, - bytes4_array: Vec>, + bytes4_array: Vec>, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { if let Some((name, abi, address_selectors)) = targeted_contracts.get_mut(&address) { @@ -560,21 +648,25 @@ impl<'a> InvariantExecutor<'a> { Ok(()) } - /// Gets list of `T` by calling the contract `method_name` function. - fn get_list(&self, address: Address, abi: &Abi, method_name: &str) -> Vec - where - T: Tokenizable + Detokenize + TokenizableItem, - { + /// Get the function output by calling the contract `method_name` function, encoded as a + /// [DynSolValue]. + fn get_list( + &self, + address: Address, + abi: &Abi, + method_name: &str, + f: fn(DynSolValue) -> Vec, + ) -> Vec { if let Some(func) = abi.functions().find(|func| func.name == method_name) { - if let Ok(call_result) = self.executor.call::, _, _>( + if let Ok(call_result) = self.executor.call::<_, _>( CALLER, - address.to_alloy(), + address, func.clone(), - (), + vec![], rU256::ZERO, Some(abi), ) { - return call_result.result + return f(call_result.result) } else { warn!( "The function {} was found but there was an error querying its data.", @@ -599,8 +691,7 @@ fn collect_data( ) { // Verify it has no code. let mut has_code = false; - if let Some(Some(code)) = - state_changeset.get(&sender.to_alloy()).map(|account| account.info.code.as_ref()) + if let Some(Some(code)) = state_changeset.get(sender).map(|account| account.info.code.as_ref()) { has_code = !code.is_empty(); } @@ -608,14 +699,14 @@ fn collect_data( // We keep the nonce changes to apply later. let mut sender_changeset = None; if !has_code { - sender_changeset = state_changeset.remove(&sender.to_alloy()); + sender_changeset = state_changeset.remove(sender); } collect_state_from_call(&call_result.logs, &*state_changeset, fuzz_state, config); // Re-add changes if let Some(changed) = sender_changeset { - state_changeset.insert(sender.to_alloy(), changed); + state_changeset.insert(*sender, changed); } } @@ -637,9 +728,10 @@ fn can_continue( let mut call_results = None; // Detect handler assertion failures first. - let handlers_failed = targeted_contracts.lock().iter().any(|contract| { - !executor.is_success(contract.0.to_alloy(), false, state_changeset.clone(), false) - }); + let handlers_failed = targeted_contracts + .lock() + .iter() + .any(|contract| !executor.is_success(*contract.0, false, state_changeset.clone(), false)); // Assert invariants IFF the call did not revert and the handlers did not fail. if !call_result.reverted && !handlers_failed { diff --git a/crates/evm/src/fuzz/invariant/filters.rs b/crates/evm/src/fuzz/invariant/filters.rs index 2e79ce207cf3a..32c8704ca197d 100644 --- a/crates/evm/src/fuzz/invariant/filters.rs +++ b/crates/evm/src/fuzz/invariant/filters.rs @@ -1,21 +1,19 @@ use crate::utils::get_function; -use ethers::{ - abi::{Abi, Address, FixedBytes, Function}, - solc::ArtifactId, -}; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::{Address, Selector}; +use foundry_compilers::ArtifactId; use std::collections::BTreeMap; /// Contains which contracts are to be targeted or excluded on an invariant test through their /// artifact identifiers. #[derive(Default)] pub struct ArtifactFilters { - /// List of `contract_path:contract_name` which are to be targeted. If list of functions is not - /// empty, target only those. - pub targeted: BTreeMap>, + /// List of `contract_path:contract_name` along with selectors, which are to be targeted. If + /// list of functions is not empty, target only those. + pub targeted: BTreeMap>, /// List of `contract_path:contract_name` which are to be excluded. pub excluded: Vec, } - impl ArtifactFilters { /// Gets all the targeted functions from `artifact`. Returns error, if selectors do not match /// the `artifact`. @@ -32,25 +30,20 @@ impl ArtifactFilters { .iter() .map(|selector| get_function(&artifact.name, selector, abi)) .collect::>>()?; - // targetArtifactSelectors > excludeArtifacts > targetArtifacts if functions.is_empty() && self.excluded.contains(&artifact.identifier()) { return Ok(None) } - return Ok(Some(functions)) } - // If no contract is specifically targeted, and this contract is not excluded, then accept // all functions. if self.targeted.is_empty() && !self.excluded.contains(&artifact.identifier()) { return Ok(Some(vec![])) } - Ok(None) } } - /// Filter for acceptable senders to use for invariant testing. Exclusion takes priority if /// clashing. /// @@ -63,13 +56,11 @@ pub struct SenderFilters { impl SenderFilters { pub fn new(mut targeted: Vec
, mut excluded: Vec
) -> Self { - let addr_0 = Address::zero(); + let addr_0 = Address::ZERO; if !excluded.contains(&addr_0) { excluded.push(addr_0); } - targeted.retain(|addr| !excluded.contains(addr)); - SenderFilters { targeted, excluded } } } diff --git a/crates/evm/src/fuzz/invariant/mod.rs b/crates/evm/src/fuzz/invariant/mod.rs index 7072382797c6c..3d32401bc37b0 100644 --- a/crates/evm/src/fuzz/invariant/mod.rs +++ b/crates/evm/src/fuzz/invariant/mod.rs @@ -6,10 +6,9 @@ use crate::{ trace::{load_contracts, TraceKind, Traces}, CALLER, }; -use ethers::{ - abi::{Abi, Function}, - types::{Address, Bytes}, -}; +use alloy_dyn_abi::JsonAbiExt; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::{Address, Bytes}; use foundry_common::ContractsByArtifact; use parking_lot::Mutex; use revm::primitives::U256; @@ -68,8 +67,8 @@ pub fn assert_invariants( let mut call_result = executor .call_raw( CALLER, - invariant_contract.address.to_alloy(), - func.encode_input(&[]).expect("invariant should have no inputs").into(), + invariant_contract.address, + func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), U256::ZERO, ) .expect("EVM error"); @@ -77,7 +76,7 @@ pub fn assert_invariants( // This will panic and get caught by the executor let is_err = call_result.reverted || !executor.is_success( - invariant_contract.address.to_alloy(), + invariant_contract.address, call_result.reverted, call_result.state_changeset.take().expect("we should have a state changeset"), false, @@ -120,12 +119,7 @@ pub fn replay_run( // Replay each call from the sequence until we break the invariant. for (sender, (addr, bytes)) in inputs.iter() { let call_result = executor - .call_raw_committing( - sender.to_alloy(), - addr.to_alloy(), - bytes.0.clone().into(), - U256::ZERO, - ) + .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) .expect("bad call to evm"); logs.extend(call_result.logs); @@ -141,8 +135,8 @@ pub fn replay_run( let error_call_result = executor .call_raw( CALLER, - invariant_contract.address.to_alloy(), - func.encode_input(&[]).expect("invariant should have no inputs").into(), + invariant_contract.address, + func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), U256::ZERO, ) .expect("bad call to evm"); diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/src/fuzz/mod.rs index edf079343121a..a2215da590f5a 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/src/fuzz/mod.rs @@ -5,16 +5,14 @@ use crate::{ executor::{Executor, RawCallResult}, trace::CallTraceArena, }; -use alloy_primitives::U256; +use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::{Address, Bytes, U256}; use error::{FuzzError, ASSUME_MAGIC_RETURN_CODE}; -use ethers::{ - abi::{Abi, Function, Token}, - types::{Address, Bytes, Log}, -}; +use ethers::types::Log; use eyre::Result; use foundry_common::{calc, contracts::ContractsByAddress}; use foundry_config::FuzzConfig; -use foundry_utils::types::{ToAlloy, ToEthers}; pub use proptest::test_runner::Reason; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; use serde::{Deserialize, Serialize}; @@ -152,7 +150,7 @@ impl<'a> FuzzedExecutor<'a> { counterexample: None, decoded_logs: decode_console_logs(&call.logs), logs: call.logs, - labeled_addresses: call.labels.into_iter().map(|l| (l.0.to_ethers(), l.1)).collect(), + labeled_addresses: call.labels, traces: if run_result.is_ok() { traces.into_inner() } else { call.traces.clone() }, coverage: coverage.into_inner(), }; @@ -173,7 +171,8 @@ impl<'a> FuzzedExecutor<'a> { let reason = reason.to_string(); result.reason = if reason.is_empty() { None } else { Some(reason) }; - let args = func.decode_input(&calldata.as_ref()[4..]).unwrap_or_default(); + let args = + func.abi_decode_input(&calldata.as_ref()[4..], false).unwrap_or_default(); result.counterexample = Some(CounterExample::Single(BaseCounterExample { sender: None, addr: None, @@ -197,16 +196,11 @@ impl<'a> FuzzedExecutor<'a> { state: &EvmFuzzState, address: Address, should_fail: bool, - calldata: ethers::types::Bytes, + calldata: alloy_primitives::Bytes, ) -> Result { let call = self .executor - .call_raw( - self.sender.to_alloy(), - address.to_alloy(), - calldata.0.clone().into(), - U256::ZERO, - ) + .call_raw(self.sender, address, calldata.clone(), U256::ZERO) .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; let state_changeset = call .state_changeset @@ -231,12 +225,8 @@ impl<'a> FuzzedExecutor<'a> { .as_ref() .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); - let success = self.executor.is_success( - address.to_alloy(), - call.reverted, - state_changeset.clone(), - should_fail, - ); + let success = + self.executor.is_success(address, call.reverted, state_changeset.clone(), should_fail); if success { Ok(FuzzOutcome::Case(CaseOutcome { @@ -288,9 +278,8 @@ pub struct BaseCounterExample { pub contract_name: Option, /// Traces pub traces: Option, - // Token does not implement Serde (lol), so we just serialize the calldata #[serde(skip)] - pub args: Vec, + pub args: Vec, } impl BaseCounterExample { @@ -302,11 +291,9 @@ impl BaseCounterExample { traces: Option, ) -> Self { if let Some((name, abi)) = &contracts.get(&addr) { - if let Some(func) = - abi.functions().find(|f| f.short_signature() == bytes.0.as_ref()[0..4]) - { + if let Some(func) = abi.functions().find(|f| f.selector() == bytes.0.as_ref()[0..4]) { // skip the function selector when decoding - if let Ok(args) = func.decode_input(&bytes.0.as_ref()[4..]) { + if let Ok(args) = func.abi_decode_input(&bytes.0.as_ref()[4..], false) { return BaseCounterExample { sender: Some(sender), addr: Some(addr), @@ -400,16 +387,18 @@ pub struct FuzzTestResult { impl FuzzTestResult { /// Returns the median gas of all test cases pub fn median_gas(&self, with_stipend: bool) -> u64 { - let mut values = self.gas_values(with_stipend); + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); values.sort_unstable(); - calc::median_sorted(&values) + calc::median_sorted(&values).to::() } /// Returns the average gas use of all test cases pub fn mean_gas(&self, with_stipend: bool) -> u64 { - let mut values = self.gas_values(with_stipend); + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); values.sort_unstable(); - calc::mean(&values).as_u64() + calc::mean(&values).to::() } fn gas_values(&self, with_stipend: bool) -> Vec { @@ -453,17 +442,19 @@ impl FuzzedCases { /// Returns the median gas of all test cases #[inline] pub fn median_gas(&self, with_stipend: bool) -> u64 { - let mut values = self.gas_values(with_stipend); + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); values.sort_unstable(); - calc::median_sorted(&values) + calc::median_sorted(&values).to::() } /// Returns the average gas use of all test cases #[inline] pub fn mean_gas(&self, with_stipend: bool) -> u64 { - let mut values = self.gas_values(with_stipend); + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); values.sort_unstable(); - calc::mean(&values).as_u64() + calc::mean(&values).to::() } #[inline] diff --git a/crates/evm/src/fuzz/strategies/calldata.rs b/crates/evm/src/fuzz/strategies/calldata.rs index b8499dc003d03..93d914543b73e 100644 --- a/crates/evm/src/fuzz/strategies/calldata.rs +++ b/crates/evm/src/fuzz/strategies/calldata.rs @@ -1,5 +1,9 @@ +use std::str::FromStr; + use super::fuzz_param; -use ethers::{abi::Function, types::Bytes}; +use alloy_dyn_abi::{DynSolType, JsonAbiExt}; +use alloy_json_abi::Function; +use alloy_primitives::Bytes; use proptest::prelude::{BoxedStrategy, Strategy}; /// Given a function, it returns a strategy which generates valid calldata @@ -7,12 +11,16 @@ use proptest::prelude::{BoxedStrategy, Strategy}; pub fn fuzz_calldata(func: Function) -> BoxedStrategy { // We need to compose all the strategies generated for each parameter in all // possible combinations - let strats = func.inputs.iter().map(|input| fuzz_param(&input.kind)).collect::>(); + let strats = func + .inputs + .iter() + .map(|input| fuzz_param(&DynSolType::from_str(&input.selector_type()).unwrap())) + .collect::>(); strats .prop_map(move |tokens| { trace!(input = ?tokens); - func.encode_input(&tokens).unwrap().into() + func.abi_encode_input(&tokens).unwrap().into() }) .boxed() } diff --git a/crates/evm/src/fuzz/strategies/int.rs b/crates/evm/src/fuzz/strategies/int.rs index 0d6122199ee3e..1f9ade01d133e 100644 --- a/crates/evm/src/fuzz/strategies/int.rs +++ b/crates/evm/src/fuzz/strategies/int.rs @@ -1,10 +1,12 @@ -use ethers::{core::rand::Rng, prelude::Sign}; +use std::ops::{Add, Shl, Sub}; + +use ethers::core::rand::Rng; use proptest::{ strategy::{NewTree, Strategy, ValueTree}, test_runner::TestRunner, }; -use ethers::types::{I256, U256}; +use alloy_primitives::{Sign, I256, U256}; /// Value tree for signed ints (up to int256). /// This is very similar to [proptest::BinarySearch] @@ -18,19 +20,18 @@ pub struct IntValueTree { /// If true cannot be simplified or complexified fixed: bool, } - impl IntValueTree { /// Create a new tree /// # Arguments /// * `start` - Starting value for the tree /// * `fixed` - If `true` the tree would only contain one element and won't be simplified. fn new(start: I256, fixed: bool) -> Self { - Self { lo: I256::zero(), curr: start, hi: start, fixed } + Self { lo: I256::ZERO, curr: start, hi: start, fixed } } fn reposition(&mut self) -> bool { let interval = self.hi - self.lo; - let new_mid = self.lo + interval / I256::from(2); + let new_mid = self.lo + interval / I256::from_raw(U256::from(2)); if new_mid == self.curr { false @@ -39,7 +40,6 @@ impl IntValueTree { true } } - fn magnitude_greater(lhs: I256, rhs: I256) -> bool { if lhs.is_zero() { return false @@ -47,34 +47,28 @@ impl IntValueTree { (lhs > rhs) ^ (lhs.is_negative()) } } - impl ValueTree for IntValueTree { type Value = I256; - fn current(&self) -> Self::Value { self.curr } - fn simplify(&mut self) -> bool { if self.fixed || !IntValueTree::magnitude_greater(self.hi, self.lo) { return false } - self.hi = self.curr; self.reposition() } - fn complicate(&mut self) -> bool { if self.fixed || !IntValueTree::magnitude_greater(self.hi, self.lo) { return false } - self.lo = self.curr + if self.hi.is_negative() { I256::minus_one() } else { I256::one() }; + self.lo = self.curr + if self.hi.is_negative() { I256::MINUS_ONE } else { I256::ONE }; self.reposition() } } - /// Value tree for signed ints (up to int256). /// The strategy combines 3 different strategies, each assigned a specific weight: /// 1. Generate purely random value in a range. This will first choose bit size uniformly (up `bits` @@ -94,7 +88,6 @@ pub struct IntStrategy { /// The weight for purely random values random_weight: usize, } - impl IntStrategy { /// Create a new strategy. /// #Arguments @@ -109,47 +102,45 @@ impl IntStrategy { random_weight: 50usize, } } - fn generate_edge_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); - let offset = I256::from(rng.gen_range(0..4)); - let umax: U256 = (U256::from(1u8) << U256::from(self.bits - 1)) - 1; + let offset = I256::from_raw(U256::from(rng.gen_range(0..4))); + let umax: U256 = (U256::from(1u8).shl(self.bits - 1)).sub(U256::from(1u8)); // Choose if we want values around min, -0, +0, or max let kind = rng.gen_range(0..4); let start = match kind { - 0 => I256::overflowing_from_sign_and_abs(Sign::Negative, umax + 1).0 + offset, - 1 => -offset - I256::one(), + 0 => { + I256::overflowing_from_sign_and_abs(Sign::Negative, umax.add(U256::from(1))).0 + + offset + } + 1 => -offset - I256::ONE, 2 => offset, 3 => I256::overflowing_from_sign_and_abs(Sign::Positive, umax).0 - offset, _ => unreachable!(), }; Ok(IntValueTree::new(start, false)) } - fn generate_fixtures_tree(&self, runner: &mut TestRunner) -> NewTree { // generate edge cases if there's no fixtures if self.fixtures.is_empty() { return self.generate_edge_tree(runner) } let idx = runner.rng().gen_range(0..self.fixtures.len()); - Ok(IntValueTree::new(self.fixtures[idx], false)) } - fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); // generate random number of bits uniformly let bits = rng.gen_range(0..=self.bits); if bits == 0 { - return Ok(IntValueTree::new(I256::zero(), false)) + return Ok(IntValueTree::new(I256::ZERO, false)) } // init 2 128-bit randoms let mut higher: u128 = rng.gen_range(0..=u128::MAX); let mut lower: u128 = rng.gen_range(0..=u128::MAX); - // cut 2 randoms according to bits size match bits - 1 { x if x < 128 => { @@ -170,16 +161,14 @@ impl IntStrategy { let sign = if rng.gen_bool(0.5) { Sign::Positive } else { Sign::Negative }; // we have a small bias here, i.e. intN::min will never be generated // but it's ok since it's generated in `fn generate_edge_tree(...)` - let (start, _) = I256::overflowing_from_sign_and_abs(sign, U256(inner)); + let (start, _) = I256::overflowing_from_sign_and_abs(sign, U256::from_limbs(inner)); Ok(IntValueTree::new(start, false)) } } - impl Strategy for IntStrategy { type Tree = IntValueTree; type Value = I256; - fn new_tree(&self, runner: &mut TestRunner) -> NewTree { let total_weight = self.random_weight + self.fixtures_weight + self.edge_weight; let bias = runner.rng().gen_range(0..total_weight); diff --git a/crates/evm/src/fuzz/strategies/invariants.rs b/crates/evm/src/fuzz/strategies/invariants.rs index 4b9d2f458c3ed..c842fc45ce729 100644 --- a/crates/evm/src/fuzz/strategies/invariants.rs +++ b/crates/evm/src/fuzz/strategies/invariants.rs @@ -1,20 +1,16 @@ +use super::fuzz_param_from_state; use crate::fuzz::{ fuzz_calldata, fuzz_calldata_from_state, invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, SenderFilters}, strategies::fuzz_param, EvmFuzzState, }; -use ethers::{ - abi::{Abi, Function, ParamType}, - types::{Address, Bytes}, -}; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::{Address, Bytes}; use parking_lot::RwLock; use proptest::prelude::*; pub use proptest::test_runner::Config as FuzzConfig; use std::{rc::Rc, sync::Arc}; - -use super::fuzz_param_from_state; - /// Given a target address, we generate random calldata. pub fn override_call_strat( fuzz_state: EvmFuzzState, @@ -34,7 +30,6 @@ pub fn override_call_strat( .prop_flat_map(move |target_address| { let fuzz_state = fuzz_state.clone(); let (_, abi, functions) = contracts.lock().get(&target_address).unwrap().clone(); - let func = select_random_function(abi, functions); func.prop_flat_map(move |func| { fuzz_contract_with_calldata(fuzz_state.clone(), target_address, func) @@ -42,7 +37,6 @@ pub fn override_call_strat( }) .sboxed() } - /// Creates the invariant strategy. /// /// Given the known and future contracts, it generates the next call by fuzzing the `caller`, @@ -63,7 +57,6 @@ pub fn invariant_strat( // state generate_call(fuzz_state, senders, contracts, dictionary_weight).prop_map(|x| vec![x]) } - /// Strategy to generate a transaction where the `sender`, `target` and `calldata` are all generated /// through specific strategies. fn generate_call( @@ -87,7 +80,6 @@ fn generate_call( }) .boxed() } - /// Strategy to select a sender address: /// * If `senders` is empty, then it's either a random address (10%) or from the dictionary (90%). /// * If `senders` is not empty, a random address is chosen from the list of senders. @@ -100,21 +92,20 @@ fn select_random_sender( let fuzz_strategy = proptest::strategy::Union::new_weighted(vec![ ( 100 - dictionary_weight, - fuzz_param(&ParamType::Address) - .prop_map(move |addr| addr.into_address().unwrap()) + fuzz_param(&alloy_dyn_abi::DynSolType::Address) + .prop_map(move |addr| addr.as_address().unwrap()) .boxed(), ), ( dictionary_weight, - fuzz_param_from_state(&ParamType::Address, fuzz_state) - .prop_map(move |addr| addr.into_address().unwrap()) + fuzz_param_from_state(&alloy_dyn_abi::DynSolType::Address, fuzz_state) + .prop_map(move |addr| addr.as_address().unwrap()) .boxed(), ), ]) // Too many exclusions can slow down testing. .prop_filter("senders not allowed", move |addr| !senders_ref.excluded.contains(addr)) .boxed(); - if !senders.targeted.is_empty() { any::() .prop_map(move |selector| *selector.select(&*senders.targeted)) @@ -123,13 +114,11 @@ fn select_random_sender( fuzz_strategy } } - /// Strategy to randomly select a contract from the `contracts` list that has at least 1 function fn select_random_contract( contracts: FuzzRunIdentifiedContracts, ) -> impl Strategy)> { let selectors = any::(); - selectors.prop_map(move |selector| { let contracts = contracts.lock(); let (addr, (_, abi, functions)) = @@ -137,39 +126,34 @@ fn select_random_contract( (*addr, abi.clone(), functions.clone()) }) } - /// Strategy to select a random mutable function from the abi. /// /// If `targeted_functions` is not empty, select one from it. Otherwise, take any /// of the available abi functions. fn select_random_function(abi: Abi, targeted_functions: Vec) -> BoxedStrategy { let selectors = any::(); - let possible_funcs: Vec = abi + let possible_funcs: Vec = abi .functions() .filter(|func| { !matches!( func.state_mutability, - ethers::abi::StateMutability::Pure | ethers::abi::StateMutability::View + alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View ) }) .cloned() .collect(); - let total_random = selectors.prop_map(move |selector| { let func = selector.select(&possible_funcs); func.clone() }); - if !targeted_functions.is_empty() { let selector = any::() .prop_map(move |selector| selector.select(targeted_functions.clone())); - selector.boxed() } else { total_random.boxed() } } - /// Given a function, it returns a proptest strategy which generates valid abi-encoded calldata /// for that function's input types. pub fn fuzz_contract_with_calldata( @@ -179,7 +163,6 @@ pub fn fuzz_contract_with_calldata( ) -> impl Strategy { // We need to compose all the strategies generated for each parameter in all // possible combinations - // `prop_oneof!` / `TupleUnion` `Arc`s for cheap cloning #[allow(clippy::arc_with_non_send_sync)] let strats = prop_oneof![ diff --git a/crates/evm/src/fuzz/strategies/param.rs b/crates/evm/src/fuzz/strategies/param.rs index f251466971418..9e4df3a8ede32 100644 --- a/crates/evm/src/fuzz/strategies/param.rs +++ b/crates/evm/src/fuzz/strategies/param.rs @@ -1,46 +1,61 @@ use super::state::EvmFuzzState; -use ethers::{ - abi::{ParamType, Token, Tokenizable}, - types::{Address, Bytes, H160, I256, U256}, -}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_primitives::{Address, FixedBytes, I256, U256}; use proptest::prelude::*; /// The max length of arrays we fuzz for is 256. pub const MAX_ARRAY_LEN: usize = 256; - /// Given a parameter type, returns a strategy for generating values for that type. /// /// Works with ABI Encoder v2 tuples. -pub fn fuzz_param(param: &ParamType) -> BoxedStrategy { +pub fn fuzz_param(param: &DynSolType) -> BoxedStrategy { + let param = param.to_owned(); match param { - ParamType::Address => { - // The key to making this work is the `boxed()` call which type erases everything - // https://altsysrq.github.io/proptest-book/proptest/tutorial/transforming-strategies.html - any::<[u8; 20]>().prop_map(|x| H160(x).into_token()).boxed() + DynSolType::Address => any::<[u8; 32]>() + .prop_map(|x| DynSolValue::Address(Address::from_word(x.into()))) + .boxed(), + DynSolType::Int(n) => { + let strat = super::IntStrategy::new(n, vec![]); + let strat = strat.prop_map(move |x| DynSolValue::Int(x, n)); + strat.boxed() } - ParamType::Bytes => any::>().prop_map(|x| Bytes::from(x).into_token()).boxed(), - ParamType::Int(n) => { - super::IntStrategy::new(*n, vec![]).prop_map(|x| x.into_token()).boxed() + DynSolType::Uint(n) => { + let strat = super::UintStrategy::new(n, vec![]); + let strat = strat.prop_map(move |x| DynSolValue::Uint(x, n)); + strat.boxed() } - ParamType::Uint(n) => { - super::UintStrategy::new(*n, vec![]).prop_map(|x| x.into_token()).boxed() + DynSolType::Function | DynSolType::Bool | DynSolType::Bytes => { + DynSolValue::type_strategy(¶m).boxed() } - ParamType::Bool => any::().prop_map(|x| x.into_token()).boxed(), - ParamType::String => any::>() - .prop_map(|x| Token::String(unsafe { String::from_utf8_unchecked(x) })) + DynSolType::FixedBytes(size) => prop::collection::vec(any::(), size) + .prop_map(move |mut v| { + v.reverse(); + while v.len() < 32 { + v.push(0); + } + DynSolValue::FixedBytes(FixedBytes::from_slice(&v), size) + }) .boxed(), - ParamType::Array(param) => proptest::collection::vec(fuzz_param(param), 0..MAX_ARRAY_LEN) - .prop_map(Token::Array) + DynSolType::String => DynSolValue::type_strategy(¶m) + .prop_map(move |value| { + DynSolValue::String( + String::from_utf8_lossy(value.as_str().unwrap().as_bytes()) + .trim() + .trim_end_matches('\0') + .to_string(), + ) + }) .boxed(), - ParamType::FixedBytes(size) => { - prop::collection::vec(any::(), *size).prop_map(Token::FixedBytes).boxed() - } - ParamType::FixedArray(param, size) => { - prop::collection::vec(fuzz_param(param), *size).prop_map(Token::FixedArray).boxed() - } - ParamType::Tuple(params) => { - params.iter().map(fuzz_param).collect::>().prop_map(Token::Tuple).boxed() + DynSolType::Tuple(params) => { + params.iter().map(fuzz_param).collect::>().prop_map(DynSolValue::Tuple).boxed() } + DynSolType::FixedArray(param, size) => proptest::collection::vec(fuzz_param(¶m), size) + .prop_map(DynSolValue::FixedArray) + .boxed(), + DynSolType::Array(param) => proptest::collection::vec(fuzz_param(¶m), 0..MAX_ARRAY_LEN) + .prop_map(DynSolValue::Array) + .boxed(), + DynSolType::CustomStruct { .. } => panic!("unsupported type"), } } @@ -48,7 +63,10 @@ pub fn fuzz_param(param: &ParamType) -> BoxedStrategy { /// fuzz state. /// /// Works with ABI Encoder v2 tuples. -pub fn fuzz_param_from_state(param: &ParamType, arc_state: EvmFuzzState) -> BoxedStrategy { +pub fn fuzz_param_from_state( + param: &DynSolType, + arc_state: EvmFuzzState, +) -> BoxedStrategy { // These are to comply with lifetime requirements let state_len = arc_state.read().values().len(); @@ -57,93 +75,107 @@ pub fn fuzz_param_from_state(param: &ParamType, arc_state: EvmFuzzState) -> Boxe let value = any::() .prop_map(move |index| index.index(state_len)) .prop_map(move |index| *st.read().values().iter().nth(index).unwrap()); - + let param = param.to_owned(); // Convert the value based on the parameter type match param { - ParamType::Address => { - value.prop_map(move |value| Address::from_slice(&value[12..]).into_token()).boxed() + DynSolType::Address => value + .prop_map(move |value| DynSolValue::Address(Address::from_word(value.into()))) + .boxed(), + DynSolType::FixedBytes(size) => { + value + .prop_map(move |v| { + let mut v = v; + // Zero out the unused bytes + v[32 - size..].iter_mut().for_each(|x| *x = 0); + DynSolValue::FixedBytes(FixedBytes::from_slice(&v), size) + }) + .boxed() } - ParamType::Bytes => value.prop_map(move |value| Bytes::from(value).into_token()).boxed(), - ParamType::Int(n) => match n / 8 { - 32 => { - value.prop_map(move |value| I256::from_raw(U256::from(value)).into_token()).boxed() - } + DynSolType::Function | DynSolType::Bool => DynSolValue::type_strategy(¶m).boxed(), + DynSolType::String => DynSolValue::type_strategy(¶m) + .prop_map(move |value| { + DynSolValue::String( + String::from_utf8_lossy(value.as_str().unwrap().as_bytes()) + .trim() + .trim_end_matches('\0') + .to_string(), + ) + }) + .boxed(), + DynSolType::Int(n) => match n / 8 { + 32 => value + .prop_map(move |value| { + DynSolValue::Int(I256::from_raw(U256::from_be_bytes(value)), 256) + }) + .boxed(), y @ 1..=31 => value .prop_map(move |value| { // Generate a uintN in the correct range, then shift it to the range of intN // by subtracting 2^(N-1) - let uint = U256::from(value) % U256::from(2usize).pow(U256::from(y * 8)); + let uint = + U256::from_be_bytes(value) % U256::from(2usize).pow(U256::from(y * 8)); let max_int_plus1 = U256::from(2usize).pow(U256::from(y * 8 - 1)); let num = I256::from_raw(uint.overflowing_sub(max_int_plus1).0); - num.into_token() + DynSolValue::Int(num, y * 8) }) .boxed(), _ => panic!("unsupported solidity type int{n}"), }, - ParamType::Uint(n) => match n / 8 { - 32 => value.prop_map(move |value| U256::from(value).into_token()).boxed(), + DynSolType::Uint(n) => match n / 8 { + 32 => value + .prop_map(move |value| DynSolValue::Uint(U256::from_be_bytes(value), 256)) + .boxed(), y @ 1..=31 => value .prop_map(move |value| { - (U256::from(value) % (U256::from(2usize).pow(U256::from(y * 8)))).into_token() + DynSolValue::Uint( + U256::from_be_bytes(value) % U256::from(2).pow(U256::from(y * 8)), + y * 8, + ) }) .boxed(), _ => panic!("unsupported solidity type uint{n}"), }, - ParamType::Bool => value.prop_map(move |value| Token::Bool(value[31] == 1)).boxed(), - ParamType::String => value - .prop_map(move |value| { - Token::String( - String::from_utf8_lossy(&value[..]).trim().trim_end_matches('\0').to_string(), - ) - }) + DynSolType::Tuple(params) => params + .iter() + .map(|p| fuzz_param_from_state(p, arc_state.clone())) + .collect::>() + .prop_map(DynSolValue::Tuple) .boxed(), - ParamType::Array(param) => { - proptest::collection::vec(fuzz_param_from_state(param, arc_state), 0..MAX_ARRAY_LEN) - .prop_map(Token::Array) + DynSolType::Bytes => value.prop_map(move |value| DynSolValue::Bytes(value.into())).boxed(), + DynSolType::FixedArray(param, size) => { + let fixed_size = size; + proptest::collection::vec(fuzz_param_from_state(¶m, arc_state), fixed_size) + .prop_map(DynSolValue::FixedArray) .boxed() } - ParamType::FixedBytes(size) => { - let size = *size; - value.prop_map(move |value| Token::FixedBytes(value[32 - size..].to_vec())).boxed() - } - ParamType::FixedArray(param, size) => { - let fixed_size = *size; - proptest::collection::vec(fuzz_param_from_state(param, arc_state), fixed_size) - .prop_map(Token::FixedArray) + DynSolType::Array(param) => { + proptest::collection::vec(fuzz_param_from_state(¶m, arc_state), 0..MAX_ARRAY_LEN) + .prop_map(DynSolValue::Array) .boxed() } - ParamType::Tuple(params) => params - .iter() - .map(|p| fuzz_param_from_state(p, arc_state.clone())) - .collect::>() - .prop_map(Token::Tuple) - .boxed(), + DynSolType::CustomStruct { .. } => panic!("unsupported type"), } } #[cfg(test)] mod tests { use crate::fuzz::strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state}; - use ethers::abi::HumanReadableParser; + use alloy_json_abi::Function; use foundry_config::FuzzDictionaryConfig; use revm::db::{CacheDB, EmptyDB}; #[test] fn can_fuzz_array() { - let f = "function testArray(uint64[2] calldata values)"; - let func = HumanReadableParser::parse_function(f).unwrap(); - + let f = "testArray(uint64[2] calldata values)"; + let func = Function::parse(f).unwrap(); let db = CacheDB::new(EmptyDB::default()); let state = build_initial_state(&db, &FuzzDictionaryConfig::default()); - let strat = proptest::strategy::Union::new_weighted(vec![ (60, fuzz_calldata(func.clone())), (40, fuzz_calldata_from_state(func, state)), ]); - let cfg = proptest::test_runner::Config { failure_persistence: None, ..Default::default() }; let mut runner = proptest::test_runner::TestRunner::new(cfg); - let _ = runner.run(&strat, |_| Ok(())); } } diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/src/fuzz/strategies/state.rs index 85584b4fed4cc..44f32c2498da2 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/src/fuzz/strategies/state.rs @@ -2,13 +2,12 @@ use super::fuzz_param_from_state; use crate::{ executor::StateChangeset, fuzz::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}, - utils, }; +use alloy_dyn_abi::{DynSolType, JsonAbiExt}; +use alloy_json_abi::Function; +use alloy_primitives::{Address, B256, U256}; use bytes::Bytes; -use ethers::{ - abi::Function, - types::{Address, Log, H256, U256}, -}; +use ethers::types::Log; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_utils::types::ToEthers; @@ -20,13 +19,12 @@ use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, }; -use std::{fmt, io::Write, sync::Arc}; +use std::{fmt, io::Write, str::FromStr, sync::Arc}; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// /// Wrapped in a shareable container. pub type EvmFuzzState = Arc>; - #[derive(Default)] pub struct FuzzDictionary { /// Collected state values. @@ -34,7 +32,6 @@ pub struct FuzzDictionary { /// Addresses that already had their PUSH bytes collected. addresses: HashSet
, } - impl fmt::Debug for FuzzDictionary { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FuzzDictionary") @@ -43,44 +40,44 @@ impl fmt::Debug for FuzzDictionary { .finish() } } - impl FuzzDictionary { #[inline] pub fn values(&self) -> &HashSet<[u8; 32]> { &self.state_values } - #[inline] pub fn values_mut(&mut self) -> &mut HashSet<[u8; 32]> { &mut self.state_values } - #[inline] pub fn addresses(&mut self) -> &HashSet
{ &self.addresses } - #[inline] pub fn addresses_mut(&mut self) -> &mut HashSet
{ &mut self.addresses } } - /// Given a function and some state, it returns a strategy which generated valid calldata for the /// given function's input types, based on state taken from the EVM. pub fn fuzz_calldata_from_state( func: Function, state: EvmFuzzState, -) -> BoxedStrategy { +) -> BoxedStrategy { let strats = func .inputs .iter() - .map(|input| fuzz_param_from_state(&input.kind, state.clone())) + .map(|input| { + fuzz_param_from_state( + &DynSolType::from_str(&input.selector_type()).unwrap(), + state.clone(), + ) + }) .collect::>(); strats .prop_map(move |tokens| { - func.encode_input(&tokens) + func.abi_encode_input(&tokens) .unwrap_or_else(|_| { panic!( "Fuzzer generated invalid tokens for function `{}` with inputs {:?}: {:?}", @@ -92,7 +89,6 @@ pub fn fuzz_calldata_from_state( .no_shrink() .boxed() } - /// Builds the initial [EvmFuzzState] from a database. pub fn build_initial_state( db: &CacheDB, @@ -101,9 +97,9 @@ pub fn build_initial_state( let mut state = FuzzDictionary::default(); for (address, account) in db.accounts.iter() { - let address: Address = address.to_ethers(); + let address: Address = *address; // Insert basic account information - state.values_mut().insert(H256::from(address).into()); + state.values_mut().insert(address.into_word().into()); // Insert push bytes if config.include_push_bytes { @@ -115,37 +111,32 @@ pub fn build_initial_state( } } } - if config.include_storage { // Insert storage for (slot, value) in &account.storage { - let slot = slot.to_ethers(); - let value = value.to_ethers(); - state.values_mut().insert(utils::u256_to_h256_be(slot).into()); - state.values_mut().insert(utils::u256_to_h256_be(value).into()); + state.values_mut().insert(B256::from(*slot).0); + state.values_mut().insert(B256::from(*value).0); // also add the value below and above the storage value to the dictionary. - if value != U256::zero() { - let below_value = value - U256::one(); - state.values_mut().insert(utils::u256_to_h256_be(below_value).into()); + if *value != U256::ZERO { + let below_value = value - U256::from(1); + state.values_mut().insert(B256::from(below_value).0); } - if value != U256::max_value() { - let above_value = value + U256::one(); - state.values_mut().insert(utils::u256_to_h256_be(above_value).into()); + if *value != U256::MAX { + let above_value = value + U256::from(1); + state.values_mut().insert(B256::from(above_value).0); } } } } - // need at least some state data if db is empty otherwise we can't select random data for state // fuzzing if state.values().is_empty() { // prefill with a random addresses - state.values_mut().insert(H256::from(Address::random()).into()); + state.values_mut().insert(Address::random().into_word().into()); } Arc::new(RwLock::new(state)) } - /// Collects state changes from a [StateChangeset] and logs into an [EvmFuzzState] according to the /// given [FuzzDictionaryConfig]. pub fn collect_state_from_call( @@ -158,41 +149,38 @@ pub fn collect_state_from_call( for (address, account) in state_changeset { // Insert basic account information - state.values_mut().insert(H256::from(address.to_ethers()).into()); + state.values_mut().insert(address.into_word().into()); if config.include_push_bytes && state.addresses.len() < config.max_fuzz_dictionary_addresses { // Insert push bytes if let Some(code) = &account.info.code { - if state.addresses_mut().insert(address.to_ethers()) { + if state.addresses_mut().insert(*address) { for push_byte in collect_push_bytes(code.bytes().clone().0) { state.values_mut().insert(push_byte); } } } } - if config.include_storage && state.state_values.len() < config.max_fuzz_dictionary_values { // Insert storage for (slot, value) in &account.storage { - let slot = slot.to_ethers(); - let value = value.present_value().to_ethers(); - state.values_mut().insert(utils::u256_to_h256_be(slot).into()); - state.values_mut().insert(utils::u256_to_h256_be(value).into()); + let value = value.present_value; + state.values_mut().insert(B256::from(*slot).0); + state.values_mut().insert(B256::from(value).0); // also add the value below and above the storage value to the dictionary. - if value != U256::zero() { - let below_value = value - U256::one(); - state.values_mut().insert(utils::u256_to_h256_be(below_value).into()); + if value != U256::ZERO { + let below_value = value - U256::from(1); + state.values_mut().insert(B256::from(below_value).0); } - if value != U256::max_value() { - let above_value = value + U256::one(); - state.values_mut().insert(utils::u256_to_h256_be(above_value).into()); + if value != U256::MAX { + let above_value = value + U256::from(1); + state.values_mut().insert(B256::from(above_value).0); } } } else { return } - // Insert log topics and data for log in logs { log.topics.iter().for_each(|topic| { @@ -208,21 +196,17 @@ pub fn collect_state_from_call( } } } - /// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). /// /// This is to limit the performance impact of fuzz tests that might deploy arbitrarily sized /// bytecode (as is the case with Solmate). const PUSH_BYTE_ANALYSIS_LIMIT: usize = 24 * 1024; - /// Collects all push bytes from the given bytecode. fn collect_push_bytes(code: Bytes) -> Vec<[u8; 32]> { let mut bytes: Vec<[u8; 32]> = Vec::new(); - // We use [SpecId::LATEST] since we do not really care what spec it is - we are not interested // in gas costs. let opcode_infos = spec_opcode_gas(SpecId::LATEST); - let mut i = 0; while i < code.len().min(PUSH_BYTE_ANALYSIS_LIMIT) { let op = code[i]; @@ -230,31 +214,28 @@ fn collect_push_bytes(code: Bytes) -> Vec<[u8; 32]> { let push_size = (op - opcode::PUSH1 + 1) as usize; let push_start = i + 1; let push_end = push_start + push_size; - // As a precaution, if a fuzz test deploys malformed bytecode (such as using `CREATE2`) // this will terminate the loop early. if push_start > code.len() || push_end > code.len() { return bytes } - let push_value = U256::from_big_endian(&code[push_start..push_end]); - bytes.push(push_value.into()); + let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); + bytes.push(push_value.to_ethers().into()); // also add the value below and above the push value to the dictionary. - if push_value != U256::zero() { - bytes.push((push_value - U256::one()).into()); + if push_value != U256::ZERO { + bytes.push((push_value - U256::from(1)).to_be_bytes()); } - if push_value != U256::max_value() { - bytes.push((push_value + U256::one()).into()); + if push_value != U256::MAX { + bytes.push((push_value + U256::from(1)).to_be_bytes()); } i += push_size; } i += 1; } - bytes } - /// Collects all created contracts from a StateChangeset which haven't been discovered yet. Stores /// them at `targeted_contracts` and `created_contracts`. pub fn collect_created_contracts( @@ -266,9 +247,8 @@ pub fn collect_created_contracts( created_contracts: &mut Vec
, ) -> eyre::Result<()> { let mut writable_targeted = targeted_contracts.lock(); - for (address, account) in state_changeset { - if !setup_contracts.contains_key(&address.to_ethers()) { + if !setup_contracts.contains_key(address) { if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { if !code.is_empty() { if let Some((artifact, (abi, _))) = project_contracts.find_by_code(code.bytes()) @@ -276,17 +256,14 @@ pub fn collect_created_contracts( if let Some(functions) = artifact_filters.get_targeted_functions(artifact, abi)? { - created_contracts.push(address.to_ethers()); - writable_targeted.insert( - address.to_ethers(), - (artifact.name.clone(), abi.clone(), functions), - ); + created_contracts.push(*address); + writable_targeted + .insert(*address, (artifact.name.clone(), abi.clone(), functions)); } } } } } } - Ok(()) } diff --git a/crates/evm/src/fuzz/strategies/uint.rs b/crates/evm/src/fuzz/strategies/uint.rs index 6438aa8c51794..ceb403f3b9bc8 100644 --- a/crates/evm/src/fuzz/strategies/uint.rs +++ b/crates/evm/src/fuzz/strategies/uint.rs @@ -1,10 +1,12 @@ +use std::ops::Shl; + use ethers::core::rand::Rng; use proptest::{ strategy::{NewTree, Strategy, ValueTree}, test_runner::TestRunner, }; -use ethers::types::U256; +use alloy_primitives::U256; /// Value tree for unsigned ints (up to uint256). /// This is very similar to [proptest::BinarySearch] @@ -18,19 +20,18 @@ pub struct UintValueTree { /// If true cannot be simplified or complexified fixed: bool, } - impl UintValueTree { /// Create a new tree /// # Arguments /// * `start` - Starting value for the tree /// * `fixed` - If `true` the tree would only contain one element and won't be simplified. fn new(start: U256, fixed: bool) -> Self { - Self { lo: 0.into(), curr: start, hi: start, fixed } + Self { lo: U256::ZERO, curr: start, hi: start, fixed } } fn reposition(&mut self) -> bool { let interval = self.hi - self.lo; - let new_mid = self.lo + interval / 2; + let new_mid = self.lo + interval / U256::from(2); if new_mid == self.curr { false @@ -40,33 +41,27 @@ impl UintValueTree { } } } - impl ValueTree for UintValueTree { type Value = U256; - fn current(&self) -> Self::Value { self.curr } - fn simplify(&mut self) -> bool { if self.fixed || (self.hi <= self.lo) { return false } - self.hi = self.curr; self.reposition() } - fn complicate(&mut self) -> bool { if self.fixed || (self.hi <= self.lo) { return false } - self.lo = self.curr + 1; + self.lo = self.curr + U256::from(1); self.reposition() } } - /// Value tree for unsigned ints (up to uint256). /// The strategy combines 3 different strategies, each assigned a specific weight: /// 1. Generate purely random value in a range. This will first choose bit size uniformly (up `bits` @@ -86,7 +81,6 @@ pub struct UintStrategy { /// The weight for purely random values random_weight: usize, } - impl UintStrategy { /// Create a new strategy. /// #Arguments @@ -101,42 +95,34 @@ impl UintStrategy { random_weight: 50usize, } } - fn generate_edge_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); - // Choose if we want values around 0 or max let is_min = rng.gen_bool(0.5); let offset = U256::from(rng.gen_range(0..4)); let max = if self.bits < 256 { - (U256::from(1u8) << U256::from(self.bits)) - 1 + (U256::from(1u8).shl(self.bits)) - U256::from(1) } else { U256::MAX }; - let start = if is_min { offset } else { max - offset }; - + let start = if is_min { offset } else { max.saturating_sub(offset) }; Ok(UintValueTree::new(start, false)) } - fn generate_fixtures_tree(&self, runner: &mut TestRunner) -> NewTree { // generate edge cases if there's no fixtures if self.fixtures.is_empty() { return self.generate_edge_tree(runner) } let idx = runner.rng().gen_range(0..self.fixtures.len()); - Ok(UintValueTree::new(self.fixtures[idx], false)) } - fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); // generate random number of bits uniformly let bits = rng.gen_range(0..=self.bits); - // init 2 128-bit randoms let mut higher: u128 = rng.gen_range(0..=u128::MAX); let mut lower: u128 = rng.gen_range(0..=u128::MAX); - // cut 2 randoms according to bits size match bits { x if x < 128 => { @@ -146,7 +132,6 @@ impl UintStrategy { x if (128..256).contains(&x) => higher &= (1u128 << (x - 128)) - 1, _ => {} }; - // init U256 from 2 randoms let mut inner: [u64; 4] = [0; 4]; let mask64 = (1 << 65) - 1; @@ -154,16 +139,14 @@ impl UintStrategy { inner[1] = (lower >> 64) as u64; inner[2] = (higher & mask64) as u64; inner[3] = (higher >> 64) as u64; - let start: U256 = U256(inner); + let start: U256 = U256::from_limbs(inner); Ok(UintValueTree::new(start, false)) } } - impl Strategy for UintStrategy { type Tree = UintValueTree; type Value = U256; - fn new_tree(&self, runner: &mut TestRunner) -> NewTree { let total_weight = self.random_weight + self.fixtures_weight + self.edge_weight; let bias = runner.rng().gen_range(0..total_weight); diff --git a/crates/evm/src/fuzz/types.rs b/crates/evm/src/fuzz/types.rs index 7178376a67a74..3ab8c541e0d06 100644 --- a/crates/evm/src/fuzz/types.rs +++ b/crates/evm/src/fuzz/types.rs @@ -1,5 +1,5 @@ use crate::{coverage::HitMaps, debug::DebugArena, executor::RawCallResult, trace::CallTraceArena}; -use ethers::types::Bytes; +use alloy_primitives::Bytes; use foundry_common::evm::Breakpoints; use revm::interpreter::InstructionResult; use serde::{Deserialize, Serialize}; @@ -34,7 +34,7 @@ pub struct CaseOutcome { #[derive(Debug)] pub struct CounterExampleOutcome { /// Minimal reproduction test case for failing test - pub counterexample: (ethers::types::Bytes, RawCallResult), + pub counterexample: (alloy_primitives::Bytes, RawCallResult), /// The status of the call pub exit_reason: InstructionResult, /// The debug nodes of the call diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index f39abbfe1fdf5..8dbe9eaf973ea 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -19,9 +19,10 @@ pub mod coverage; /// Forge test execution backends pub mod executor; -use ethers::types::{ActionType, CallType}; pub use executor::abi; +use ethers::types::{ActionType, CallType}; + /// Fuzzing wrapper for executors pub mod fuzz; @@ -29,7 +30,6 @@ pub mod fuzz; pub mod utils; // Re-exports -pub use ethers::types::Address; pub use hashbrown; use revm::interpreter::{CallScheme, CreateScheme}; pub use revm::{ diff --git a/crates/evm/src/trace/decoder.rs b/crates/evm/src/trace/decoder.rs index 3924c38125315..652760c7c040f 100644 --- a/crates/evm/src/trace/decoder.rs +++ b/crates/evm/src/trace/decoder.rs @@ -9,13 +9,10 @@ use crate::{ trace::{node::CallTraceNode, utils}, CALLER, TEST_CONTRACT_ADDRESS, }; -use ethers::{ - abi::{Abi, Address, Event, Function, Param, ParamType, Token}, - types::{H160, H256}, -}; +use alloy_dyn_abi::{DynSolType, DynSolValue, EventExt}; +use alloy_json_abi::{Event, Function, JsonAbi as Abi, Param}; +use alloy_primitives::{Address, FixedBytes, B256}; use foundry_common::{abi::get_indexed_event, SELECTOR_LEN}; -use foundry_utils::types::ToEthers; -use hashbrown::HashSet; use once_cell::sync::OnceCell; use std::collections::{BTreeMap, HashMap}; @@ -46,7 +43,7 @@ impl CallTraceDecoderBuilder { for event in events { self.decoder .events - .entry((event.signature(), indexed_inputs(&event))) + .entry((event.selector(), indexed_inputs(&event))) .or_default() .push(event); } @@ -94,9 +91,9 @@ pub struct CallTraceDecoder { /// Information whether the contract address has a receive function pub receive_contracts: HashMap, /// A mapping of signatures to their known functions - pub functions: BTreeMap<[u8; 4], Vec>, + pub functions: BTreeMap, Vec>, /// All known events - pub events: BTreeMap<(H256, usize), Vec>, + pub events: BTreeMap<(B256, usize), Vec>, /// All known errors pub errors: Abi, /// A signature identifier for events and functions. @@ -109,17 +106,15 @@ pub struct CallTraceDecoder { macro_rules! precompiles { ($($number:literal : $name:ident($( $name_in:ident : $in:expr ),* $(,)?) -> ($( $name_out:ident : $out:expr ),* $(,)?)),+ $(,)?) => {{ use std::string::String as RustString; - use ParamType::*; [$( ( - H160([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, $number]), + Address::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, $number]), #[allow(deprecated)] Function { name: RustString::from(stringify!($name)), - inputs: vec![$(Param { name: RustString::from(stringify!($name_in)), kind: $in, internal_type: None, }),*], - outputs: vec![$(Param { name: RustString::from(stringify!($name_out)), kind: $out, internal_type: None, }),*], - constant: None, - state_mutability: ethers::abi::StateMutability::Pure, + inputs: vec![$(Param { name: RustString::from(stringify!($name_in)), ty: $in, components: vec![], internal_type: None, }),*], + outputs: vec![$(Param { name: RustString::from(stringify!($name_out)), ty: $out, components: vec![], internal_type: None, }),*], + state_mutability: alloy_json_abi::StateMutability::Pure, }, ), )+] @@ -143,37 +138,37 @@ impl CallTraceDecoder { // TODO: These are the Ethereum precompiles. We should add a way to support precompiles // for other networks, too. precompiles: precompiles!( - 0x01: ecrecover(hash: FixedBytes(32), v: Uint(256), r: Uint(256), s: Uint(256)) -> (publicAddress: Address), - 0x02: sha256(data: Bytes) -> (hash: FixedBytes(32)), - 0x03: ripemd(data: Bytes) -> (hash: FixedBytes(32)), - 0x04: identity(data: Bytes) -> (data: Bytes), - 0x05: modexp(Bsize: Uint(256), Esize: Uint(256), Msize: Uint(256), BEM: Bytes) -> (value: Bytes), - 0x06: ecadd(x1: Uint(256), y1: Uint(256), x2: Uint(256), y2: Uint(256)) -> (x: Uint(256), y: Uint(256)), - 0x07: ecmul(x1: Uint(256), y1: Uint(256), s: Uint(256)) -> (x: Uint(256), y: Uint(256)), - 0x08: ecpairing(x1: Uint(256), y1: Uint(256), x2: Uint(256), y2: Uint(256), x3: Uint(256), y3: Uint(256)) -> (success: Uint(256)), - 0x09: blake2f(rounds: Uint(4), h: FixedBytes(64), m: FixedBytes(128), t: FixedBytes(16), f: FixedBytes(1)) -> (h: FixedBytes(64)), + 0x01: ecrecover(hash: format!("bytes32"), v: format!("uint256"), r: format!("uint256"), s: format!("uint256")) -> (publicAddress: format!("address")), + 0x02: sha256(data: format!("bytes")) -> (hash: format!("bytes32")), + 0x03: ripemd(data: format!("bytes")) -> (hash: format!("bytes32")), + 0x04: identity(data: format!("bytes")) -> (data: format!("bytes")), + 0x05: modexp(Bsize: format!("uint256"), Esize: format!("uint256"), Msize: format!("uint256"), BEM: format!("bytes")) -> (value: format!("bytes")), + 0x06: ecadd(x1: format!("uint256"), y1: format!("uint256"), x2: format!("uint256"), y2: format!("uint256")) -> (x: format!("uint256"), y: format!("uint256")), + 0x07: ecmul(x1: format!("uint256"), y1: format!("uint256"), s: format!("uint256")) -> (x: format!("uint256"), y: format!("uint256")), + 0x08: ecpairing(x1: format!("uint256"), y1: format!("uint256"), x2: format!("uint256"), y2: format!("uint256"), x3: format!("uint256"), y3: format!("uint256")) -> (success: format!("uint256")), + 0x09: blake2f(rounds: DynSolType::Uint(4).to_string(), h: DynSolType::FixedBytes(64).to_string(), m: DynSolType::FixedBytes(128).to_string(), t: DynSolType::FixedBytes(16).to_string(), f: DynSolType::FixedBytes(1).to_string()) -> (h: DynSolType::FixedBytes(64).to_string()), ).into(), contracts: Default::default(), labels: [ - (CHEATCODE_ADDRESS.to_ethers(), "VM".to_string()), - (HARDHAT_CONSOLE_ADDRESS.to_ethers(), "console".to_string()), - (DEFAULT_CREATE2_DEPLOYER.to_ethers(), "Create2Deployer".to_string()), - (CALLER.to_ethers(), "DefaultSender".to_string()), - (TEST_CONTRACT_ADDRESS.to_ethers(), "DefaultTestContract".to_string()), + (CHEATCODE_ADDRESS, "VM".to_string()), + (HARDHAT_CONSOLE_ADDRESS, "console".to_string()), + (DEFAULT_CREATE2_DEPLOYER, "Create2Deployer".to_string()), + (CALLER, "DefaultSender".to_string()), + (TEST_CONTRACT_ADDRESS, "DefaultTestContract".to_string()), ] .into(), functions: HARDHAT_CONSOLE_ABI .functions() .chain(HEVM_ABI.functions()) - .map(|func| (func.short_signature(), vec![func.clone()])) + .map(|func| (func.selector(), vec![func.clone()])) .collect(), events: CONSOLE_ABI .events() - .map(|event| ((event.signature(), indexed_inputs(event)), vec![event.clone()])) + .map(|event| ((event.selector(), indexed_inputs(event)), vec![event.clone()])) .collect(), errors: Default::default(), @@ -216,15 +211,12 @@ impl CallTraceDecoder { if let Some(abi) = &identity.abi { // Store known functions for the address for function in abi.functions() { - self.functions - .entry(function.short_signature()) - .or_default() - .push(function.clone()) + self.functions.entry(function.selector()).or_default().push(function.clone()) } // Flatten events from all ABIs for event in abi.events() { - let sig = (event.signature(), indexed_inputs(event)); + let sig = (event.selector(), indexed_inputs(event)); self.events.entry(sig).or_default().push(event.clone()); } @@ -233,7 +225,7 @@ impl CallTraceDecoder { self.errors.errors.entry(error.name.clone()).or_default().push(error.clone()); } - self.receive_contracts.entry(address).or_insert(abi.receive); + self.receive_contracts.entry(address).or_insert(abi.receive.is_some()); } } } @@ -257,7 +249,7 @@ impl CallTraceDecoder { if bytes.len() >= 4 { if let Some(funcs) = self.functions.get(&bytes[..SELECTOR_LEN]) { node.decode_function(funcs, &self.labels, &self.errors, self.verbosity); - } else if node.trace.address == DEFAULT_CREATE2_DEPLOYER.to_ethers() { + } else if node.trace.address == DEFAULT_CREATE2_DEPLOYER { node.trace.data = RawOrDecodedCall::Decoded("create2".to_string(), String::new(), vec![]); } else if let Some(identifier) = &self.signature_identifier { @@ -314,38 +306,33 @@ impl CallTraceDecoder { async fn decode_event(&self, log: &mut RawOrDecodedLog) { if let RawOrDecodedLog::Raw(raw_log) = log { // do not attempt decoding if no topics - if raw_log.topics.is_empty() { + if raw_log.topics().is_empty() { return } let mut events = vec![]; - if let Some(evs) = self.events.get(&(raw_log.topics[0], raw_log.topics.len() - 1)) { + if let Some(evs) = self.events.get(&(raw_log.topics()[0], raw_log.topics().len() - 1)) { events = evs.clone(); } else if let Some(identifier) = &self.signature_identifier { if let Some(event) = - identifier.write().await.identify_event(&raw_log.topics[0].0).await + identifier.write().await.identify_event(&raw_log.topics()[0].0).await { events.push(get_indexed_event(event, raw_log)); } } - for mut event in events { - // ensure all params are named, otherwise this will cause issues with decoding: See also - let empty_params = patch_nameless_params(&mut event); - if let Ok(decoded) = event.parse_log(raw_log.clone()) { + for event in events { + if let Ok(decoded) = event.decode_log(raw_log, false) { *log = RawOrDecodedLog::Decoded( event.name, decoded - .params + .body .into_iter() - .map(|param| { + .zip(event.inputs.iter()) + .map(|(param, input)| { // undo patched names - let name = if empty_params.contains(¶m.name) { - "".to_string() - } else { - param.name - }; - (name, self.apply_label(¶m.value)) + let name = input.name.clone(); + (name, self.apply_label(¶m)) }) .collect(), ); @@ -355,26 +342,11 @@ impl CallTraceDecoder { } } - fn apply_label(&self, token: &Token) -> String { + fn apply_label(&self, token: &DynSolValue) -> String { utils::label(token, &self.labels) } } -/// This is a bit horrible but due to we need to patch nameless (valid) params before decoding a logs, otherwise [`Event::parse_log()`] will result in wrong results since they're identified by name. -/// -/// Returns a set of patched param names, that originally were empty. -fn patch_nameless_params(event: &mut Event) -> HashSet { - let mut patches = HashSet::new(); - if event.inputs.iter().filter(|input| input.name.is_empty()).count() > 1 { - for (idx, param) in event.inputs.iter_mut().enumerate() { - // this is an illegal arg name, which ensures patched identifiers are unique - param.name = format!(""); - patches.insert(param.name.clone()); - } - } - patches -} - fn indexed_inputs(event: &Event) -> usize { event.inputs.iter().filter(|param| param.indexed).count() } diff --git a/crates/evm/src/trace/executor.rs b/crates/evm/src/trace/executor.rs index 6cd9263bb855d..f23a40a4bdd8a 100644 --- a/crates/evm/src/trace/executor.rs +++ b/crates/evm/src/trace/executor.rs @@ -1,5 +1,5 @@ use crate::executor::{fork::CreateFork, opts::EvmOpts, Backend, Executor, ExecutorBuilder}; -use ethers::solc::EvmVersion; +use foundry_compilers::EvmVersion; use foundry_config::{utils::evm_spec_id, Config}; use revm::primitives::Env; use std::ops::{Deref, DerefMut}; diff --git a/crates/evm/src/trace/identifier/etherscan.rs b/crates/evm/src/trace/identifier/etherscan.rs index 2658c032aac37..40b71dfd42dc6 100644 --- a/crates/evm/src/trace/identifier/etherscan.rs +++ b/crates/evm/src/trace/identifier/etherscan.rs @@ -1,11 +1,9 @@ use super::{AddressIdentity, TraceIdentifier}; use crate::utils::RuntimeOrHandle; -use ethers::{ - abi::Address, - etherscan, - etherscan::contract::{ContractMetadata, Metadata}, - prelude::errors::EtherscanError, - types::H160, +use alloy_primitives::Address; +use foundry_block_explorers::{ + contract::{ContractMetadata, Metadata}, + errors::EtherscanError, }; use foundry_common::compile::{self, ContractSources}; use foundry_config::{Chain, Config}; @@ -30,13 +28,13 @@ use tokio::time::{Duration, Interval}; #[derive(Default)] pub struct EtherscanIdentifier { /// The Etherscan client - client: Option>, + client: Option>, /// Tracks whether the API key provides was marked as invalid /// /// After the first [EtherscanError::InvalidApiKey] this will get set to true, so we can /// prevent any further attempts invalid_api_key: Arc, - pub contracts: BTreeMap, + pub contracts: BTreeMap, pub sources: BTreeMap, } @@ -156,7 +154,7 @@ type EtherscanFuture = /// Fetches information about multiple addresses concurrently, while respecting rate limits. pub struct EtherscanFetcher { /// The Etherscan client - client: Arc, + client: Arc, /// The time we wait if we hit the rate limit timeout: Duration, /// The interval we are currently waiting for before making a new request @@ -173,7 +171,7 @@ pub struct EtherscanFetcher { impl EtherscanFetcher { pub fn new( - client: Arc, + client: Arc, timeout: Duration, concurrency: usize, invalid_api_key: Arc, diff --git a/crates/evm/src/trace/identifier/local.rs b/crates/evm/src/trace/identifier/local.rs index ec8fb0f668ca7..cb2100b019d2a 100644 --- a/crates/evm/src/trace/identifier/local.rs +++ b/crates/evm/src/trace/identifier/local.rs @@ -1,5 +1,6 @@ use super::{AddressIdentity, TraceIdentifier}; -use ethers::abi::{Address, Event}; +use alloy_json_abi::Event; +use alloy_primitives::Address; use foundry_common::contracts::{diff_score, ContractsByArtifact}; use ordered_float::OrderedFloat; use std::borrow::Cow; diff --git a/crates/evm/src/trace/identifier/mod.rs b/crates/evm/src/trace/identifier/mod.rs index dd755ee9082df..7362c07e4b140 100644 --- a/crates/evm/src/trace/identifier/mod.rs +++ b/crates/evm/src/trace/identifier/mod.rs @@ -7,10 +7,9 @@ pub use etherscan::EtherscanIdentifier; mod signatures; pub use signatures::{SignaturesIdentifier, SingleSignaturesIdentifier}; -use ethers::{ - abi::{Abi, Address}, - prelude::ArtifactId, -}; +use alloy_json_abi::JsonAbi as Abi; +use alloy_primitives::Address; +use foundry_compilers::ArtifactId; use std::borrow::Cow; /// An address identity diff --git a/crates/evm/src/trace/identifier/signatures.rs b/crates/evm/src/trace/identifier/signatures.rs index eba4ec3ad5991..d78ec03e8991c 100644 --- a/crates/evm/src/trace/identifier/signatures.rs +++ b/crates/evm/src/trace/identifier/signatures.rs @@ -1,4 +1,4 @@ -use ethers::abi::{Event, Function}; +use alloy_json_abi::{Event, Function}; use foundry_common::{ abi::{get_event, get_func}, fs, diff --git a/crates/evm/src/trace/mod.rs b/crates/evm/src/trace/mod.rs index 7bfaa55cbc39d..88bfc6d73a5db 100644 --- a/crates/evm/src/trace/mod.rs +++ b/crates/evm/src/trace/mod.rs @@ -1,16 +1,14 @@ use crate::{ abi::CHEATCODE_ADDRESS, debug::Instruction, trace::identifier::LocalTraceIdentifier, CallKind, }; +use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; -use ethers::{ - abi::{ethereum_types::BigEndianHash, Address, RawLog}, - core::utils::to_checksum, - types::{Bytes, DefaultFrame, GethDebugTracingOptions, StructLog, H256, U256}, -}; +use ethers::types::{DefaultFrame, GethDebugTracingOptions, StructLog}; pub use executor::TracingExecutor; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_utils::types::ToEthers; use hashbrown::HashMap; +use itertools::Itertools; use node::CallTraceNode; use revm::interpreter::{opcode, CallContext, InstructionResult, Memory, Stack}; use serde::{Deserialize, Serialize}; @@ -97,7 +95,7 @@ impl CallTraceArena { // Recursively fill in the geth trace by going through the traces fn add_to_geth_trace( &self, - storage: &mut HashMap>, + storage: &mut HashMap>, trace_node: &CallTraceNode, struct_logs: &mut Vec, opts: &GethDebugTracingOptions, @@ -111,8 +109,14 @@ impl CallTraceArena { if !opts.disable_storage.unwrap_or_default() { let contract_storage = storage.entry(step.contract).or_default(); if let Some((key, value)) = step.state_diff { - contract_storage.insert(H256::from_uint(&key), H256::from_uint(&value)); - log.storage = Some(contract_storage.clone()); + contract_storage.insert(B256::from(key), B256::from(value)); + log.storage = Some( + contract_storage + .clone() + .into_iter() + .map(|t| (t.0.to_ethers(), t.1.to_ethers())) + .collect(), + ); } } if opts.disable_stack.unwrap_or_default() { @@ -170,8 +174,8 @@ impl CallTraceArena { let mut acc = DefaultFrame { // If the top-level trace succeeded, then it was a success failed: !main_trace.success, - gas: receipt_gas_used, - return_value: main_trace.output.to_bytes(), + gas: receipt_gas_used.to_ethers(), + return_value: main_trace.output.to_bytes().0.into(), ..Default::default() }; @@ -275,7 +279,7 @@ impl fmt::Display for RawOrDecodedLog { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { RawOrDecodedLog::Raw(log) => { - for (i, topic) in log.topics.iter().enumerate() { + for (i, topic) in log.topics().iter().enumerate() { writeln!( f, "{:>13}: {}", @@ -426,7 +430,7 @@ impl From<&CallTraceStep> for StructLog { } else { None }, - stack: Some(step.stack.data().iter().copied().map(|s| s.to_ethers()).collect()), + stack: Some(step.stack.data().iter().copied().map(|v| v.to_ethers()).collect_vec()), // Filled in `CallTraceArena::geth_trace` as a result of compounding all slot changes storage: None, } @@ -505,7 +509,7 @@ impl Default for CallTrace { impl fmt::Display for CallTrace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let address = to_checksum(&self.address, None); + let address = self.address.to_checksum(None); if self.created() { write!( f, @@ -543,7 +547,7 @@ impl fmt::Display for CallTrace { self.gas_cost, color.paint(self.label.as_ref().unwrap_or(&address)), color.paint(func), - if !self.value.is_zero() { + if !self.value == U256::ZERO { format!("{{value: {}}}", self.value) } else { "".to_string() @@ -593,7 +597,7 @@ impl TraceKind { /// Chooses the color of the trace depending on the destination address and status of the call. fn trace_color(trace: &CallTrace) -> Color { - if trace.address == CHEATCODE_ADDRESS.to_ethers() { + if trace.address == CHEATCODE_ADDRESS { Color::Blue } else if trace.success { Color::Green diff --git a/crates/evm/src/trace/node.rs b/crates/evm/src/trace/node.rs index dc0c58f2017d4..2f0deb93684fb 100644 --- a/crates/evm/src/trace/node.rs +++ b/crates/evm/src/trace/node.rs @@ -7,10 +7,11 @@ use crate::{ }, CallKind, }; -use ethers::{ - abi::{Abi, Function}, - types::{Action, Address, Call, CallResult, Create, CreateResult, Res, Suicide}, -}; +use alloy_dyn_abi::{FunctionExt, JsonAbiExt}; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::Address; +use ethers::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; +// use super::trace_types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; use foundry_common::SELECTOR_LEN; use foundry_utils::types::ToEthers; use revm::interpreter::InstructionResult; @@ -58,7 +59,7 @@ impl CallTraceNode { CallKind::Create | CallKind::Create2 => Res::Create(CreateResult { gas_used: self.trace.gas_cost.into(), code: self.trace.output.to_raw().into(), - address: self.trace.address, + address: self.trace.address.to_ethers(), }), } } @@ -67,26 +68,26 @@ impl CallTraceNode { pub fn parity_action(&self) -> Action { if self.status() == InstructionResult::SelfDestruct { return Action::Suicide(Suicide { - address: self.trace.address, + address: self.trace.address.to_ethers(), // TODO deserialize from calldata here? refund_address: Default::default(), - balance: self.trace.value, + balance: self.trace.value.to_ethers(), }) } match self.kind() { CallKind::Call | CallKind::StaticCall | CallKind::CallCode | CallKind::DelegateCall => { Action::Call(Call { - from: self.trace.caller, - to: self.trace.address, - value: self.trace.value, + from: self.trace.caller.to_ethers(), + to: self.trace.address.to_ethers(), + value: self.trace.value.to_ethers(), gas: self.trace.gas_cost.into(), input: self.trace.data.to_raw().into(), call_type: self.kind().into(), }) } CallKind::Create | CallKind::Create2 => Action::Create(Create { - from: self.trace.caller, - value: self.trace.value, + from: self.trace.caller.to_ethers(), + value: self.trace.value.to_ethers(), gas: self.trace.gas_cost.into(), init: self.trace.data.to_raw().into(), }), @@ -110,11 +111,11 @@ impl CallTraceNode { if let RawOrDecodedCall::Raw(ref bytes) = self.trace.data { let inputs = if bytes.len() >= SELECTOR_LEN { - if self.trace.address == CHEATCODE_ADDRESS.to_ethers() { + if self.trace.address == CHEATCODE_ADDRESS { // Try to decode cheatcode inputs in a more custom way utils::decode_cheatcode_inputs(func, bytes, errors, verbosity).unwrap_or_else( || { - func.decode_input(&bytes[SELECTOR_LEN..]) + func.abi_decode_input(&bytes[SELECTOR_LEN..], false) .expect("bad function input decode") .iter() .map(|token| utils::label(token, labels)) @@ -122,7 +123,7 @@ impl CallTraceNode { }, ) } else { - match func.decode_input(&bytes[SELECTOR_LEN..]) { + match func.abi_decode_input(&bytes[SELECTOR_LEN..], false) { Ok(v) => v.iter().map(|token| utils::label(token, labels)).collect(), Err(_) => Vec::new(), } @@ -137,7 +138,7 @@ impl CallTraceNode { if let RawOrDecodedReturnData::Raw(bytes) = &self.trace.output { if !bytes.is_empty() && self.trace.success { - if self.trace.address == CHEATCODE_ADDRESS.to_ethers() { + if self.trace.address == CHEATCODE_ADDRESS { if let Some(decoded) = funcs .iter() .find_map(|func| decode_cheatcode_outputs(func, bytes, verbosity)) @@ -148,7 +149,7 @@ impl CallTraceNode { } if let Some(tokens) = - funcs.iter().find_map(|func| func.decode_output(bytes).ok()) + funcs.iter().find_map(|func| func.abi_decode_output(bytes, false).ok()) { // Functions coming from an external database do not have any outputs // specified, and will lead to returning an empty list of tokens. @@ -183,7 +184,7 @@ impl CallTraceNode { self.trace.data = RawOrDecodedCall::Decoded( precompile_fn.name.clone(), precompile_fn.signature(), - precompile_fn.decode_input(bytes).map_or_else( + precompile_fn.abi_decode_input(bytes, false).map_or_else( |_| vec![hex::encode(bytes)], |tokens| tokens.iter().map(|token| utils::label(token, labels)).collect(), ), @@ -191,7 +192,7 @@ impl CallTraceNode { if let RawOrDecodedReturnData::Raw(ref bytes) = self.trace.output { self.trace.output = RawOrDecodedReturnData::Decoded( - precompile_fn.decode_output(bytes).map_or_else( + precompile_fn.abi_decode_output(bytes, false).map_or_else( |_| hex::encode(bytes), |tokens| { tokens diff --git a/crates/evm/src/trace/utils.rs b/crates/evm/src/trace/utils.rs index 14d4f245d2f33..6ad1879126b57 100644 --- a/crates/evm/src/trace/utils.rs +++ b/crates/evm/src/trace/utils.rs @@ -1,22 +1,21 @@ //! utilities used within tracing use crate::decode; -use ethers::{ - abi::{Abi, Address, Function, ParamType, Token}, - core::utils::to_checksum, -}; +use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::Address; use foundry_common::{abi::format_token, SELECTOR_LEN}; use std::collections::HashMap; -/// Returns the label for the given `token` +/// Returns the label for the given [DynSolValue] /// /// If the `token` is an `Address` then we look abel the label map. /// by default the token is formatted using standard formatting -pub fn label(token: &Token, labels: &HashMap) -> String { +pub fn label(token: &DynSolValue, labels: &HashMap) -> String { match token { - Token::Address(addr) => { + DynSolValue::Address(addr) => { if let Some(label) = labels.get(addr) { - format!("{label}: [{}]", to_checksum(addr, None)) + format!("{label}: [{}]", addr.to_checksum(None)) } else { format_token(token) } @@ -39,7 +38,8 @@ pub(crate) fn decode_cheatcode_inputs( "rememberKey" | "addr" | "startBroadcast" | "broadcast" => { // these functions accept a private key as uint256, which should not be // converted to plain text - if !func.inputs.is_empty() && matches!(&func.inputs[0].kind, ParamType::Uint(_)) { + let _expected_type = DynSolType::Uint(256).to_string(); + if !func.inputs.is_empty() && matches!(&func.inputs[0].ty, _expected_type) { // redact private key input Some(vec!["".to_string()]) } else { @@ -48,9 +48,10 @@ pub(crate) fn decode_cheatcode_inputs( } "sign" => { // sign(uint256,bytes32) - let mut decoded = func.decode_input(&data[SELECTOR_LEN..]).ok()?; - if !decoded.is_empty() && matches!(&func.inputs[0].kind, ParamType::Uint(_)) { - decoded[0] = Token::String("".to_string()); + let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; + let _expected_type = DynSolType::Uint(256).to_string(); + if !decoded.is_empty() && matches!(&func.inputs[0].ty, _expected_type) { + decoded[0] = DynSolValue::String("".to_string()); } Some(decoded.iter().map(format_token).collect()) } @@ -82,14 +83,14 @@ pub(crate) fn decode_cheatcode_inputs( if verbosity >= 5 { None } else { - let mut decoded = func.decode_input(&data[SELECTOR_LEN..]).ok()?; + let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; let token = if func.name.as_str() == "parseJson" || func.name.as_str() == "keyExists" { "" } else { "" }; - decoded[0] = Token::String(token.to_string()); + decoded[0] = DynSolValue::String(token.to_string()); Some(decoded.iter().map(format_token).collect()) } } diff --git a/crates/evm/src/utils.rs b/crates/evm/src/utils.rs index 51f45070255a3..78d6b98b59b1d 100644 --- a/crates/evm/src/utils.rs +++ b/crates/evm/src/utils.rs @@ -1,7 +1,6 @@ -use ethers::{ - abi::{Abi, FixedBytes, Function}, - types::{Block, Chain, H256, U256}, -}; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::FixedBytes; +use ethers::types::{Block, Chain, H256, U256}; use eyre::ContextCompat; use foundry_utils::types::ToAlloy; use revm::{ @@ -171,17 +170,17 @@ pub fn build_ic_pc_map(spec: SpecId, code: &[u8]) -> ICPCMap { /// Given an ABI and selector, it tries to find the respective function. pub fn get_function( contract_name: &str, - selector: &FixedBytes, + selector: &FixedBytes<4>, abi: &Abi, ) -> eyre::Result { abi.functions() - .find(|func| func.short_signature().as_slice() == selector.as_slice()) + .find(|func| func.selector().as_slice() == selector.as_slice()) .cloned() .wrap_err(format!("{contract_name} does not have the selector {selector:?}")) } // TODO: Add this once solc is removed from this crate -pub use ethers::solc::utils::RuntimeOrHandle; +pub use foundry_compilers::utils::RuntimeOrHandle; /* use tokio::runtime::{Handle, Runtime}; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 2d76b0404365d..b8a1bae352fd7 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -26,6 +26,8 @@ foundry-evm.workspace = true comfy-table = "7" ethers = { workspace = true, features = ["solc-full"] } +foundry-compilers = { workspace = true, default-features = false, features = ["full"] } +foundry-block-explorers = { workspace = true, default-features = false, features = ["foundry-compilers"] } eyre.workspace = true proptest = "1" rayon = "1" @@ -40,6 +42,8 @@ foundry-cli.workspace = true foundry-debugger.workspace = true alloy-primitives = { workspace = true, features = ["serde"] } +alloy-json-abi.workspace = true +alloy-dyn-abi.workspace = true async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 7c4e8fce2ca33..51f17e62398f2 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -1,12 +1,12 @@ use super::{install, watch::WatchArgs}; use clap::Parser; -use ethers::solc::{Project, ProjectCompileOutput}; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ compile, compile::{ProjectCompiler, SkipBuildFilter}, }; +use foundry_compilers::{Project, ProjectCompileOutput}; use foundry_config::{ figment::{ self, diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 502fb9913fce3..6e869bc0a2e53 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -1,13 +1,6 @@ use super::{install, test::FilterArgs}; use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueEnum, ValueHint}; -use ethers::{ - prelude::{ - artifacts::{Ast, CompactBytecode, CompactDeployedBytecode}, - Artifact, Project, ProjectCompileOutput, - }, - solc::{artifacts::contract::CompactContractBytecode, sourcemap::SourceMap}, -}; use eyre::{Context, Result}; use forge::{ coverage::{ @@ -26,8 +19,12 @@ use foundry_cli::{ utils::{LoadConfig, STATIC_FUZZ_SEED}, }; use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; +use foundry_compilers::{ + artifacts::{contract::CompactContractBytecode, Ast, CompactBytecode, CompactDeployedBytecode}, + sourcemap::SourceMap, + Artifact, Project, ProjectCompileOutput, +}; use foundry_config::{Config, SolcReq}; -use foundry_utils::types::ToEthers; use semver::Version; use std::{collections::HashMap, path::PathBuf, sync::mpsc::channel}; use tracing::trace; @@ -89,7 +86,7 @@ impl CoverageArgs { } // Set fuzz seed so coverage reports are deterministic - config.fuzz.seed = Some(U256::from_be_bytes(STATIC_FUZZ_SEED).to_ethers()); + config.fuzz.seed = Some(U256::from_be_bytes(STATIC_FUZZ_SEED)); let (project, output) = self.build(&config)?; p_println!(!self.opts.silent => "Analysing contracts..."); @@ -389,7 +386,7 @@ fn dummy_link_bytecode(mut obj: CompactBytecode) -> Option { let link_references = obj.link_references.clone(); for (file, libraries) in link_references { for library in libraries.keys() { - obj.link(&file, library, Address::ZERO.to_ethers()); + obj.link(&file, library, Address::ZERO); } } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 7cc49c29402c4..5baae392b7401 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -1,9 +1,11 @@ use super::{retry::RetryArgs, verify}; +use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; +use alloy_json_abi::{Constructor, JsonAbi as Abi}; +use alloy_primitives::{Address, Bytes}; use clap::{Parser, ValueHint}; use ethers::{ - abi::{Abi, Constructor, Token}, - prelude::{artifacts::BytecodeObject, ContractFactory, Middleware, MiddlewareBuilder}, - solc::{info::ContractInfo, utils::canonicalized}, + abi::InvalidOutputType, + prelude::{Middleware, MiddlewareBuilder}, types::{transaction::eip2718::TypedTransaction, Chain}, }; use eyre::{Context, Result}; @@ -12,7 +14,8 @@ use foundry_cli::{ utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; use foundry_common::{abi::parse_tokens, compile, estimate_eip1559_fees}; -use foundry_utils::types::ToAlloy; +use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalized}; +use foundry_utils::types::{ToAlloy, ToEthers}; use serde_json::json; use std::{path::PathBuf, sync::Arc}; @@ -126,7 +129,7 @@ impl CreateArgs { if self.unlocked { // Deploy with unlocked account let sender = self.eth.wallet.from.expect("required"); - let provider = provider.with_sender(sender); + let provider = provider.with_sender(sender.to_ethers()); self.deploy(abi, bin, params, provider, chain_id).await } else { // Deploy with signer @@ -183,7 +186,7 @@ impl CreateArgs { self, abi: Abi, bin: BytecodeObject, - args: Vec, + args: Vec, provider: M, chain: u64, ) -> Result<()> { @@ -193,7 +196,7 @@ impl CreateArgs { panic!("no bytecode found in bin object for {}", self.contract.name) }); let provider = Arc::new(provider); - let factory = ContractFactory::new(abi.clone(), bin.clone(), provider.clone()); + let factory = ContractFactory::new(abi.clone(), bin.clone().0.into(), provider.clone()); let is_args_empty = args.is_empty(); let deployer = @@ -210,7 +213,7 @@ impl CreateArgs { // set tx value if specified if let Some(value) = self.tx.value { - deployer.tx.set_value(value); + deployer.tx.set_value(value.to_ethers()); } // fill tx first because if you target a lower gas than current base, eth_estimateGas @@ -222,7 +225,7 @@ impl CreateArgs { // set gas price if specified if let Some(gas_price) = self.tx.gas_price { - deployer.tx.set_gas_price(gas_price); + deployer.tx.set_gas_price(gas_price.to_ethers()); } else if !is_legacy { // estimate EIP1559 fees let (max_fee, max_priority_fee) = estimate_eip1559_fees(&provider, Some(chain)) @@ -230,18 +233,18 @@ impl CreateArgs { .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; deployer.tx.set_gas_price(max_fee); if priority_fee.is_none() { - priority_fee = Some(max_priority_fee); + priority_fee = Some(max_priority_fee.to_alloy()); } } // set gas limit if specified if let Some(gas_limit) = self.tx.gas_limit { - deployer.tx.set_gas(gas_limit); + deployer.tx.set_gas(gas_limit.to_ethers()); } // set nonce if specified if let Some(nonce) = self.tx.nonce { - deployer.tx.set_nonce(nonce); + deployer.tx.set_nonce(nonce.to_ethers()); } // set priority fee if specified @@ -251,7 +254,7 @@ impl CreateArgs { } deployer.tx = match deployer.tx { TypedTransaction::Eip1559(eip1559_tx_request) => TypedTransaction::Eip1559( - eip1559_tx_request.max_priority_fee_per_gas(priority_fee), + eip1559_tx_request.max_priority_fee_per_gas(priority_fee.to_ethers()), ), _ => deployer.tx, }; @@ -261,14 +264,10 @@ impl CreateArgs { let mut constructor_args = None; if self.verify { if !args.is_empty() { - // we're passing an empty vec to the `encode_input` of the constructor because we - // only need the constructor arguments and the encoded input is - // `code + args` - let code = Vec::new(); let encoded_args = abi .constructor() .ok_or_else(|| eyre::eyre!("could not find constructor"))? - .encode_input(code, &args)?; + .abi_encode_input(&args)?; constructor_args = Some(hex::encode(encoded_args)); } @@ -278,7 +277,7 @@ impl CreateArgs { // Deploy the actual contract let (deployed_contract, receipt) = deployer.send_with_receipt().await?; - let address = deployed_contract.address().to_alloy(); + let address = deployed_contract; if self.json { let output = json!({ "deployer": deployer_address.to_alloy().to_string(), @@ -325,15 +324,240 @@ impl CreateArgs { &self, constructor: &Constructor, constructor_args: &[String], - ) -> Result> { + ) -> Result> { let params = constructor .inputs .iter() .zip(constructor_args) - .map(|(input, arg)| (&input.kind, arg.as_str())) + .map(|(input, arg)| (DynSolType::parse(&input.ty).expect("Could not parse types"), arg)) .collect::>(); + let params_2 = params.iter().map(|(ty, arg)| (ty, arg.as_str())).collect::>(); + parse_tokens(params_2) + } +} + +use ethers::{ + contract::ContractError, + types::{BlockNumber, Eip1559TransactionRequest, TransactionReceipt, TransactionRequest}, +}; + +use std::{borrow::Borrow, marker::PhantomData}; + +/// `ContractFactory` is a [`DeploymentTxFactory`] object with an +/// [`Arc`] middleware. This type alias exists to preserve backwards +/// compatibility with less-abstract Contracts. +/// +/// For full usage docs, see [`DeploymentTxFactory`]. +pub type ContractFactory = DeploymentTxFactory, M>; + +/// Helper which manages the deployment transaction of a smart contract. It +/// wraps a deployment transaction, and retrieves the contract address output +/// by it. +/// +/// Currently, we recommend using the [`ContractDeployer`] type alias. +#[derive(Debug)] +#[must_use = "DeploymentTx does nothing unless you `send` it"] +pub struct ContractDeploymentTx { + /// the actual deployer, exposed for overriding the defaults + pub deployer: Deployer, + /// marker for the `Contract` type to create afterwards + /// + /// this type will be used to construct it via `From::from(Contract)` + _contract: PhantomData, +} + +impl Clone for ContractDeploymentTx +where + B: Clone, +{ + fn clone(&self) -> Self { + ContractDeploymentTx { deployer: self.deployer.clone(), _contract: self._contract } + } +} + +impl From> for ContractDeploymentTx { + fn from(deployer: Deployer) -> Self { + Self { deployer, _contract: PhantomData } + } +} + +/// Helper which manages the deployment transaction of a smart contract +#[derive(Debug)] +#[must_use = "Deployer does nothing unless you `send` it"] +pub struct Deployer { + /// The deployer's transaction, exposed for overriding the defaults + pub tx: TypedTransaction, + abi: Abi, + client: B, + confs: usize, + block: BlockNumber, + _m: PhantomData, +} + +impl Clone for Deployer +where + B: Clone, +{ + fn clone(&self) -> Self { + Deployer { + tx: self.tx.clone(), + abi: self.abi.clone(), + client: self.client.clone(), + confs: self.confs, + block: self.block, + _m: PhantomData, + } + } +} + +impl Deployer +where + B: Borrow + Clone, + M: Middleware, +{ + /// Uses a Legacy transaction instead of an EIP-1559 one to do the deployment + pub fn legacy(mut self) -> Self { + self.tx = match self.tx { + TypedTransaction::Eip1559(inner) => { + let tx: TransactionRequest = inner.into(); + TypedTransaction::Legacy(tx) + } + other => other, + }; + self + } + + /// Broadcasts the contract deployment transaction and after waiting for it to + /// be sufficiently confirmed (default: 1), it returns a tuple with + /// the [`Contract`](crate::Contract) struct at the deployed contract's address + /// and the corresponding [`TransactionReceipt`]. + pub async fn send_with_receipt( + self, + ) -> Result<(Address, TransactionReceipt), ContractError> { + let pending_tx = self + .client + .borrow() + .send_transaction(self.tx, Some(self.block.into())) + .await + .map_err(ContractError::from_middleware_error)?; + + // TODO: Should this be calculated "optimistically" by address/nonce? + let receipt = pending_tx + .confirmations(self.confs) + .await + .ok() + .flatten() + .ok_or(ContractError::ContractNotDeployed)?; + let address = receipt.contract_address.ok_or(ContractError::ContractNotDeployed)?; + + Ok((address.to_alloy(), receipt)) + } +} + +/// To deploy a contract to the Ethereum network, a `ContractFactory` can be +/// created which manages the Contract bytecode and Application Binary Interface +/// (ABI), usually generated from the Solidity compiler. +/// +/// Once the factory's deployment transaction is mined with sufficient confirmations, +/// the [`Contract`](crate::Contract) object is returned. +/// +/// # Example +/// +/// ```no_run +/// use ethers_contract::ContractFactory; +/// use ethers_core::types::Bytes; +/// use ethers_providers::{Provider, Http}; +/// +/// # async fn foo() -> Result<(), Box> { +/// // get the contract ABI and bytecode +/// let abi = Default::default(); +/// let bytecode = Bytes::from_static(b"..."); +/// +/// // connect to the network +/// let client = Provider::::try_from("http://localhost:8545").unwrap(); +/// let client = std::sync::Arc::new(client); +/// +/// // create a factory which will be used to deploy instances of the contract +/// let factory = ContractFactory::new(abi, bytecode, client); +/// +/// // The deployer created by the `deploy` call exposes a builder which gets consumed +/// // by the async `send` call +/// let contract = factory +/// .deploy("initial value".to_string())? +/// .confirmations(0usize) +/// .send() +/// .await?; +/// println!("{}", contract.address()); +/// # Ok(()) +/// # } +#[derive(Debug)] +pub struct DeploymentTxFactory { + client: B, + abi: Abi, + bytecode: Bytes, + _m: PhantomData, +} + +impl Clone for DeploymentTxFactory +where + B: Clone, +{ + fn clone(&self) -> Self { + DeploymentTxFactory { + client: self.client.clone(), + abi: self.abi.clone(), + bytecode: self.bytecode.clone(), + _m: PhantomData, + } + } +} + +impl DeploymentTxFactory +where + B: Borrow + Clone, + M: Middleware, +{ + /// Creates a factory for deployment of the Contract with bytecode, and the + /// constructor defined in the abi. The client will be used to send any deployment + /// transaction. + pub fn new(abi: Abi, bytecode: Bytes, client: B) -> Self { + Self { client, abi, bytecode, _m: PhantomData } + } + + /// Create a deployment tx using the provided tokens as constructor + /// arguments + pub fn deploy_tokens(self, params: Vec) -> Result, ContractError> + where + B: Clone, + { + // Encode the constructor args & concatenate with the bytecode if necessary + let data: Bytes = match (self.abi.constructor(), params.is_empty()) { + (None, false) => return Err(ContractError::ConstructorError), + (None, true) => self.bytecode.clone(), + (Some(constructor), _) => constructor + .abi_encode_input(¶ms) + .map_err(|f| ContractError::DetokenizationError(InvalidOutputType(f.to_string())))? + .into(), + }; - parse_tokens(params, true) + // create the tx object. Since we're deploying a contract, `to` is `None` + // We default to EIP-1559 transactions, but the sender can convert it back + // to a legacy one + #[cfg(feature = "legacy")] + let tx = TransactionRequest { to: None, data: Some(data), ..Default::default() }; + #[cfg(not(feature = "legacy"))] + let tx = + Eip1559TransactionRequest { to: None, data: Some(data.0.into()), ..Default::default() }; + let tx = tx.into(); + + Ok(Deployer { + client: self.client.clone(), + abi: self.abi, + tx, + confs: 1, + block: BlockNumber::Latest, + _m: PhantomData, + }) } } diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index bf8334d70b9fb..eea8eca9969c8 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -83,7 +83,7 @@ impl FmtArgs { } if path.is_dir() { - inputs.extend(ethers::solc::utils::source_files_iter(path)); + inputs.extend(foundry_compilers::utils::source_files_iter(path)); } else if path.is_sol() { inputs.push(path.to_path_buf()); } else { diff --git a/crates/forge/bin/cmd/fourbyte.rs b/crates/forge/bin/cmd/fourbyte.rs index 86a889d6fe635..0288d327816f9 100644 --- a/crates/forge/bin/cmd/fourbyte.rs +++ b/crates/forge/bin/cmd/fourbyte.rs @@ -1,5 +1,4 @@ use clap::Parser; -use ethers::prelude::artifacts::output_selection::ContractOutputSelection; use eyre::Result; use foundry_cli::{ opts::{CompilerArgs, CoreBuildArgs, ProjectPathsArgs}, @@ -10,6 +9,7 @@ use foundry_common::{ selectors::{import_selectors, SelectorImportData}, shell, }; +use foundry_compilers::artifacts::output_selection::ContractOutputSelection; use yansi::Paint; /// CLI arguments for `forge upload-selectors`. diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 6756a5921a939..8e5b67d6f24d2 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -1,7 +1,7 @@ use clap::{Parser, ValueHint}; -use ethers::solc::Graph; use eyre::{Result, WrapErr}; use foundry_cli::utils::LoadConfig; +use foundry_compilers::Graph; use foundry_config::{impl_figment_convert_basic, Config}; use itertools::Itertools; use rayon::prelude::*; diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 4d8c6c7155af8..bfe69889843ae 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -1,9 +1,9 @@ use super::install::DependencyInstallOpts; use clap::{Parser, ValueHint}; -use ethers::solc::remappings::Remapping; use eyre::Result; use foundry_cli::{p_println, utils::Git}; use foundry_common::fs; +use foundry_compilers::remappings::Remapping; use foundry_config::Config; use std::path::{Path, PathBuf}; use yansi::Paint; @@ -223,7 +223,7 @@ fn init_vscode(root: &Path) -> Result<()> { fs::create_dir_all(&vscode_dir)?; serde_json::json!({}) } else if settings_file.exists() { - ethers::solc::utils::read_json_file(&settings_file)? + foundry_compilers::utils::read_json_file(&settings_file)? } else { serde_json::json!({}) }; diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 1359067578b90..4ef3cd2fbdfab 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -1,22 +1,20 @@ use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; -use ethers::{ - abi::RawAbi, - prelude::{ - artifacts::output_selection::{ +use ethers::abi::RawAbi; +use eyre::Result; +use foundry_cli::opts::{CompilerArgs, CoreBuildArgs}; +use foundry_common::compile; +use foundry_compilers::{ + artifacts::{ + output_selection::{ BytecodeOutputSelection, ContractOutputSelection, DeployedBytecodeOutputSelection, EvmOutputSelection, EwasmOutputSelection, }, - info::ContractInfo, - }, - solc::{ - artifacts::{LosslessAbi, StorageLayout}, - utils::canonicalize, + LosslessAbi, StorageLayout, }, + info::ContractInfo, + utils::canonicalize, }; -use eyre::Result; -use foundry_cli::opts::{CompilerArgs, CoreBuildArgs}; -use foundry_common::compile; use serde_json::{to_value, Value}; use std::fmt; use tracing::trace; @@ -170,9 +168,8 @@ impl InspectArgs { if let Some(LosslessAbi { abi, .. }) = &artifact.abi { // Print the signature of all errors for er in abi.errors.iter().flat_map(|(_, errors)| errors) { - let types = - er.inputs.iter().map(|p| p.kind.to_string()).collect::>(); - let sig = format!("{:x}", er.signature()); + let types = er.inputs.iter().map(|p| p.ty.clone()).collect::>(); + let sig = format!("{:x}", er.selector()); let sig_trimmed = &sig[0..8]; out.insert( format!("{}({})", er.name, types.join(",")), @@ -187,8 +184,7 @@ impl InspectArgs { if let Some(LosslessAbi { abi, .. }) = &artifact.abi { // print the signature of all events including anonymous for ev in abi.events.iter().flat_map(|(_, events)| events) { - let types = - ev.inputs.iter().map(|p| p.kind.to_string()).collect::>(); + let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::>(); out.insert( format!("{}({})", ev.name, types.join(",")), format!("{:?}", ev.signature()).into(), diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index c3d30cf73526e..f9b45f6088195 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -1,7 +1,7 @@ use clap::{Parser, ValueHint}; -use ethers::solc::remappings::RelativeRemapping; use eyre::Result; use foundry_cli::utils::LoadConfig; +use foundry_compilers::remappings::RelativeRemapping; use foundry_config::impl_figment_convert_basic; use foundry_evm::HashMap; use std::path::PathBuf; diff --git a/crates/forge/bin/cmd/script/artifacts.rs b/crates/forge/bin/cmd/script/artifacts.rs index b546cef2e848e..0a2bd77dd90da 100644 --- a/crates/forge/bin/cmd/script/artifacts.rs +++ b/crates/forge/bin/cmd/script/artifacts.rs @@ -1,9 +1,9 @@ -use ethers::abi::Abi; +use alloy_json_abi::JsonAbi; /// Bundles info of an artifact pub struct ArtifactInfo<'a> { pub contract_name: String, pub contract_id: String, - pub abi: &'a Abi, + pub abi: &'a JsonAbi, pub code: &'a Vec, } diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index c493ecb74a2ab..020e2155028a2 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -43,7 +43,6 @@ impl ScriptArgs { let mut senders = HashSet::from([self .evm_opts .sender - .map(|sender| sender.to_alloy()) .wrap_err("--sender must be set with --unlocked")?]); // also take all additional senders that where set manually via broadcast senders.extend( @@ -56,19 +55,10 @@ impl ScriptArgs { } else { let local_wallets = self .wallets - .find_all( - provider.clone(), - required_addresses.into_iter().map(|addr| addr.to_ethers()).collect(), - script_wallets, - ) + .find_all(provider.clone(), required_addresses, script_wallets) .await?; let chain = local_wallets.values().last().wrap_err("Error accessing local wallet when trying to send onchain transaction, did you set a private key, mnemonic or keystore?")?.chain_id(); - ( - SendTransactionsKind::Raw( - local_wallets.into_iter().map(|m| (m.0.to_alloy(), m.1)).collect(), - ), - chain, - ) + (SendTransactionsKind::Raw(local_wallets), chain) }; // We only wait for a transaction receipt before sending the next transaction, if there diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index c0a176213d452..5ee68168cbcf2 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,21 +1,18 @@ use super::*; use alloy_primitives::{Address, Bytes}; -use ethers::{ - prelude::{ - artifacts::Libraries, cache::SolFilesCache, ArtifactId, Project, ProjectCompileOutput, - }, - solc::{ - artifacts::{CompactContractBytecode, ContractBytecode, ContractBytecodeSome}, - contracts::ArtifactContracts, - info::ContractInfo, - }, -}; use eyre::{Context, ContextCompat, Result}; use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compact_to_contract, compile::{self, ContractSources}, }; +use foundry_compilers::{ + artifacts::{CompactContractBytecode, ContractBytecode, ContractBytecodeSome, Libraries}, + cache::SolFilesCache, + contracts::ArtifactContracts, + info::ContractInfo, + ArtifactId, Project, ProjectCompileOutput, +}; use foundry_utils::{PostLinkInput, ResolvedDependency}; use std::{collections::BTreeMap, fs, str::FromStr}; use tracing::{trace, warn}; diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 556422f4f86bf..dd1102301dbab 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -276,8 +276,8 @@ impl ScriptArgs { project, default_known_contracts, Libraries::parse(&deployment_sequence.libraries)?, - script_config.config.sender.to_alloy(), // irrelevant, since we're not creating any - 0, // irrelevant, since we're not creating any + script_config.config.sender, // irrelevant, since we're not creating any + 0, // irrelevant, since we're not creating any )?; verify.known_contracts = flatten_contracts(&highlevel_known_contracts, false); diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 8e241b5bdec70..41166f545ad30 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -5,21 +5,19 @@ use super::{ *, }; use alloy_primitives::{Address, Bytes, U256}; -use ethers::{ - solc::artifacts::CompactContractBytecode, types::transaction::eip2718::TypedTransaction, -}; +use ethers::types::transaction::eip2718::TypedTransaction; use eyre::Result; use forge::{ executor::{ inspector::{cheatcodes::util::BroadcastableTransactions, CheatsConfig}, Backend, ExecutorBuilder, }, - revm::primitives::U256 as rU256, trace::{CallTraceDecoder, Traces}, CallKind, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{shell, RpcUrl}; +use foundry_compilers::artifacts::CompactContractBytecode; use foundry_utils::types::ToEthers; use futures::future::join_all; use parking_lot::RwLock; @@ -54,11 +52,9 @@ impl ScriptArgs { ensure_clean_constructor(&abi)?; - let predeploy_libraries = - predeploy_libraries.iter().map(|b| b.0.clone().into()).collect::>(); let mut runner = self.prepare_runner(script_config, sender, SimulationStage::Local).await; let (address, mut result) = runner.setup( - &predeploy_libraries, + predeploy_libraries, bytecode.0.into(), needs_setup(&abi), script_config.sender_nonce, @@ -135,7 +131,7 @@ impl ScriptArgs { abi, code, }; - return Some(((*addr).to_alloy(), info)) + return Some((*addr, info)) } None }) @@ -177,7 +173,7 @@ impl ScriptArgs { if matches!(node.kind(), CallKind::Create | CallKind::Create2) { return Some(AdditionalContract { opcode: node.kind(), - address: node.trace.address.to_alloy(), + address: node.trace.address, init_code: node.trace.data.to_raw(), }) } @@ -188,7 +184,7 @@ impl ScriptArgs { // Simulate mining the transaction if the user passes `--slow`. if self.slow { - runner.executor.env.block.number += rU256::from(1); + runner.executor.env.block.number += U256::from(1); } let is_fixed_gas_limit = tx.gas.is_some(); diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 1f6a5d3a6b8f2..0a8b83aa56fd3 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -1,17 +1,13 @@ use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; +use alloy_dyn_abi::FunctionExt; +use alloy_json_abi::{Function, InternalType, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueHint}; use dialoguer::Confirm; use ethers::{ - abi::{Abi, Function, HumanReadableParser}, - prelude::{ - artifacts::{ContractBytecodeSome, Libraries}, - ArtifactId, Project, - }, providers::{Http, Middleware}, signers::LocalWallet, - solc::contracts::ArtifactContracts, types::{ transaction::eip2718::TypedTransaction, Chain, Log, NameOrAddress, TransactionRequest, }, @@ -30,12 +26,17 @@ use forge::{ }; use foundry_cli::opts::MultiWallet; use foundry_common::{ - abi::{encode_args, format_token}, + abi::{encode_function_args, format_token}, contracts::get_contract_name, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, shell, ContractsByArtifact, RpcUrl, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; +use foundry_compilers::{ + artifacts::{ContractBytecodeSome, Libraries}, + contracts::ArtifactContracts, + ArtifactId, Project, +}; use foundry_config::{ figment, figment::{ @@ -113,7 +114,7 @@ pub struct ScriptArgs { #[clap( long, env = "ETH_PRIORITY_GAS_PRICE", - value_parser = foundry_cli::utils::alloy_parse_ether_value, + value_parser = foundry_cli::utils::parse_ether_value, value_name = "PRICE" )] pub priority_gas_price: Option, @@ -190,7 +191,7 @@ pub struct ScriptArgs { #[clap( long, env = "ETH_GAS_PRICE", - value_parser = foundry_cli::utils::alloy_parse_ether_value, + value_parser = foundry_cli::utils::parse_ether_value, value_name = "PRICE", )] pub with_gas_price: Option, @@ -228,9 +229,7 @@ impl ScriptArgs { let mut local_identifier = LocalTraceIdentifier::new(known_contracts); let mut decoder = CallTraceDecoderBuilder::new() - .with_labels( - result.labeled_addresses.iter().map(|(a, s)| ((*a).to_ethers(), s.clone())), - ) + .with_labels(result.labeled_addresses.clone()) .with_verbosity(verbosity) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), @@ -260,10 +259,14 @@ impl ScriptArgs { let func = script_config.called_function.as_ref().expect("There should be a function."); let mut returns = HashMap::new(); - match func.decode_output(returned) { + match func.abi_decode_output(returned, false) { Ok(decoded) => { for (index, (token, output)) in decoded.iter().zip(&func.outputs).enumerate() { - let internal_type = output.internal_type.as_deref().unwrap_or("unknown"); + let internal_type = + output.internal_type.clone().unwrap_or(InternalType::Other { + contract: None, + ty: "unknown".to_string(), + }); let label = if !output.name.is_empty() { output.name.to_string() @@ -328,10 +331,14 @@ impl ScriptArgs { if result.success && !result.returned.is_empty() { shell::println("\n== Return ==")?; - match func.decode_output(&result.returned) { + match func.abi_decode_output(&result.returned, false) { Ok(decoded) => { for (index, (token, output)) in decoded.iter().zip(&func.outputs).enumerate() { - let internal_type = output.internal_type.as_deref().unwrap_or("unknown"); + let internal_type = + output.internal_type.clone().unwrap_or(InternalType::Other { + contract: None, + ty: "unknown".to_string(), + }); let label = if !output.name.is_empty() { output.name.to_string() @@ -450,21 +457,18 @@ impl ScriptArgs { /// /// Note: We assume that the `sig` is already stripped of its prefix, See [`ScriptArgs`] pub fn get_method_and_calldata(&self, abi: &Abi) -> Result<(Function, Bytes)> { - let (func, data) = if let Ok(func) = HumanReadableParser::parse_function(&self.sig) { + let (func, data) = if let Ok(func) = Function::parse(&self.sig) { ( - abi.functions() - .find(|&abi_func| abi_func.short_signature() == func.short_signature()) - .wrap_err(format!( - "Function `{}` is not implemented in your script.", - self.sig - ))?, - encode_args(&func, &self.args)?.into(), + abi.functions().find(|&abi_func| abi_func.selector() == func.selector()).wrap_err( + format!("Function `{}` is not implemented in your script.", self.sig), + )?, + encode_function_args(&func, &self.args)?.into(), ) } else { let decoded = hex::decode(&self.sig).wrap_err("Invalid hex calldata")?; let selector = &decoded[..SELECTOR_LEN]; ( - abi.functions().find(|&func| selector == &func.short_signature()[..]).ok_or_else( + abi.functions().find(|&func| selector == &func.selector()[..]).ok_or_else( || { eyre::eyre!( "Function selector `{}` not found in the ABI", diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index 04862b8389481..8fb73470e2fdd 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -4,13 +4,11 @@ use super::{ verify::VerifyBundle, ScriptArgs, }; -use ethers::{ - prelude::{artifacts::Libraries, ArtifactId}, - signers::LocalWallet, -}; +use ethers::signers::LocalWallet; use eyre::{ContextCompat, Result, WrapErr}; use foundry_cli::utils::now; use foundry_common::{fs, get_http_provider}; +use foundry_compilers::{artifacts::Libraries, ArtifactId}; use foundry_config::Config; use futures::future::join_all; use serde::{Deserialize, Serialize}; @@ -84,7 +82,7 @@ impl MultiChainSequence { /// Loads the sequences for the multi chain deployment. pub fn load(log_folder: &Path, sig: &str, target: &ArtifactId) -> Result { let path = MultiChainSequence::get_path(&log_folder.join("multi"), sig, target, true)?; - ethers::solc::utils::read_json_file(path).wrap_err("Multi-chain deployment not found.") + foundry_compilers::utils::read_json_file(path).wrap_err("Multi-chain deployment not found.") } /// Saves the transactions as file if it's a standalone deployment. diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 7fd4d8d14d1bc..2db86e8f698a2 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -42,7 +42,7 @@ impl ScriptRunner { trace!(target: "script", "executing setUP()"); if !is_broadcast { - if self.sender == Config::DEFAULT_SENDER.to_alloy() { + if self.sender == Config::DEFAULT_SENDER { // We max out their balance so that they can deploy and make calls. self.executor.set_balance(self.sender, U256::MAX)?; } @@ -63,7 +63,7 @@ impl ScriptRunner { .filter_map(|code| { let DeployResult { traces, .. } = self .executor - .deploy(self.sender, code.0.clone().into(), U256::ZERO, None) + .deploy(self.sender, code.clone(), U256::ZERO, None) .expect("couldn't deploy library"); traces @@ -269,7 +269,7 @@ impl ScriptRunner { value: U256, commit: bool, ) -> Result { - let mut res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; + let mut res = self.executor.call_raw(from, to, calldata.clone(), value)?; let mut gas_used = res.gas_used; // We should only need to calculate realistic gas costs when preparing to broadcast @@ -279,7 +279,7 @@ impl ScriptRunner { // Otherwise don't re-execute, or some usecases might be broken: https://github.com/foundry-rs/foundry/issues/3921 if commit { gas_used = self.search_optimal_gas_usage(&res, from, to, &calldata, value)?; - res = self.executor.call_raw_committing(from, to, calldata.0.into(), value)?; + res = self.executor.call_raw_committing(from, to, calldata, value)?; } let RawCallResult { diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 90b7f75f400df..ed4d2a697b3ab 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -8,13 +8,11 @@ use crate::cmd::{ verify::provider::VerificationProviderType, }; use alloy_primitives::{Address, TxHash}; -use ethers::{ - prelude::{artifacts::Libraries, ArtifactId, TransactionReceipt}, - types::transaction::eip2718::TypedTransaction, -}; +use ethers::{prelude::TransactionReceipt, types::transaction::eip2718::TypedTransaction}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_cli::utils::now; use foundry_common::{fs, shell, SELECTOR_LEN}; +use foundry_compilers::{artifacts::Libraries, ArtifactId}; use foundry_config::Config; use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; @@ -128,11 +126,11 @@ impl ScriptSequence { broadcasted, )?; - let mut script_sequence: Self = ethers::solc::utils::read_json_file(&path) + let mut script_sequence: Self = foundry_compilers::utils::read_json_file(&path) .wrap_err(format!("Deployment not found for chain `{chain_id}`."))?; let sensitive_script_sequence: SensitiveScriptSequence = - ethers::solc::utils::read_json_file(&sensitive_path).wrap_err(format!( + foundry_compilers::utils::read_json_file(&sensitive_path).wrap_err(format!( "Deployment's sensitive details not found for chain `{chain_id}`." ))?; diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 873d33a29a1d0..b94254b1fde7b 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -1,6 +1,8 @@ use super::{artifacts::ArtifactInfo, ScriptResult}; +use alloy_dyn_abi::JsonAbiExt; +use alloy_json_abi::Function; use alloy_primitives::{Address, B256}; -use ethers::{abi, prelude::NameOrAddress, types::transaction::eip2718::TypedTransaction}; +use ethers::{prelude::NameOrAddress, types::transaction::eip2718::TypedTransaction}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{abi::format_token_raw, RpcUrl, SELECTOR_LEN}; use foundry_evm::{ @@ -147,7 +149,7 @@ impl TransactionWithMetadata { let inputs = constructor .inputs .iter() - .map(|p| p.kind.to_string()) + .map(|p| p.ty.clone()) .collect::>() .join(","); let signature = format!("constructor({inputs})"); @@ -155,13 +157,19 @@ impl TransactionWithMetadata { (signature, bytecode) }; - let params = - constructor.inputs.iter().map(|p| p.kind.clone()).collect::>(); - // the constructor args start after bytecode let constructor_args = &creation_code[info.code.len()..]; - if let Ok(arguments) = abi::decode(¶ms, constructor_args) { + let constructor_fn = Function { + name: "constructor".to_string(), + inputs: constructor.inputs.clone(), + outputs: vec![], + state_mutability: constructor.state_mutability, + }; + + if let Ok(arguments) = + constructor_fn.abi_decode_input(constructor_args, false) + { self.arguments = Some(arguments.iter().map(format_token_raw).collect()); } else { let (signature, bytecode) = on_err(); @@ -192,12 +200,12 @@ impl TransactionWithMetadata { if let Some(function) = info .abi .functions() - .find(|function| function.short_signature() == data.0[..SELECTOR_LEN]) + .find(|function| function.selector() == data.0[..SELECTOR_LEN]) { self.function = Some(function.signature()); self.arguments = Some( function - .decode_input(&data.0[SELECTOR_LEN..]) + .abi_decode_input(&data.0[SELECTOR_LEN..], false) .map(|tokens| tokens.iter().map(format_token_raw).collect())?, ); } @@ -210,12 +218,12 @@ impl TransactionWithMetadata { .get(&data.0[..SELECTOR_LEN]) .map(|functions| functions.first()) { - self.contract_name = decoder.contracts.get(&target.to_ethers()).cloned(); + self.contract_name = decoder.contracts.get(&target).cloned(); self.function = Some(function.signature()); self.arguments = Some( function - .decode_input(&data.0[SELECTOR_LEN..]) + .abi_decode_input(&data.0[SELECTOR_LEN..], false) .map(|tokens| tokens.iter().map(format_token_raw).collect())?, ); } diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 95972f3a5a0de..0c17260dd30ec 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -3,9 +3,9 @@ use crate::cmd::{ verify::{VerifierArgs, VerifyArgs}, }; use alloy_primitives::Address; -use ethers::solc::{info::ContractInfo, Project}; use foundry_cli::opts::{EtherscanOpts, ProjectPathsArgs}; use foundry_common::ContractsByArtifact; +use foundry_compilers::{info::ContractInfo, Project}; use foundry_config::{Chain, Config}; use semver::Version; diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index b594081a72d11..e23514ae74747 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -1,6 +1,5 @@ use clap::Parser; use comfy_table::Table; -use ethers::prelude::{artifacts::output_selection::ContractOutputSelection, info::ContractInfo}; use eyre::Result; use foundry_cli::{ opts::{CompilerArgs, CoreBuildArgs, ProjectPathsArgs}, @@ -10,6 +9,7 @@ use foundry_common::{ compile, selectors::{import_selectors, SelectorImportData}, }; +use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, info::ContractInfo}; use std::fs::canonicalize; /// CLI arguments for `forge selectors`. diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index 572ad327700e7..ccfcf6d423167 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -1,8 +1,8 @@ use clap::Parser; -use ethers::solc::{FileFilter, ProjectPathsConfig}; use forge::TestFilter; use foundry_cli::utils::FoundryPathExt; use foundry_common::glob::GlobMatcher; +use foundry_compilers::{FileFilter, ProjectPathsConfig}; use foundry_config::Config; use std::{fmt, path::Path}; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 21f0ddf044272..34e708c87c5cb 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -1,7 +1,6 @@ use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; use alloy_primitives::U256; use clap::Parser; - use eyre::Result; use forge::{ decode::decode_console_logs, @@ -96,7 +95,7 @@ pub struct TestArgs { list: bool, /// Set seed used to generate randomness during your fuzz runs. - #[clap(long, value_parser = utils::alloy_parse_u256)] + #[clap(long)] pub fuzz_seed: Option, #[clap(long, env = "FOUNDRY_FUZZ_RUNS", value_name = "RUNS")] diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index b7e7669510007..ccd260fd072d0 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -1,10 +1,10 @@ use clap::Parser; -use ethers::solc::{ +use eyre::Result; +use foundry_cli::{opts::ProjectPathsArgs, utils::LoadConfig}; +use foundry_compilers::{ resolver::{Charset, TreeOptions}, Graph, }; -use eyre::Result; -use foundry_cli::{opts::ProjectPathsArgs, utils::LoadConfig}; /// CLI arguments for `forge tree`. #[derive(Debug, Clone, Parser)] diff --git a/crates/forge/bin/cmd/verify/etherscan/flatten.rs b/crates/forge/bin/cmd/verify/etherscan/flatten.rs index fb32057924b0b..a9ed47bc23709 100644 --- a/crates/forge/bin/cmd/verify/etherscan/flatten.rs +++ b/crates/forge/bin/cmd/verify/etherscan/flatten.rs @@ -1,12 +1,10 @@ use super::{EtherscanSourceProvider, VerifyArgs}; -use ethers::{ - etherscan::verify::CodeFormat, - solc::{ - artifacts::{BytecodeHash, Source}, - AggregatedCompilerOutput, CompilerInput, Project, Solc, - }, -}; use eyre::{Context, Result}; +use foundry_block_explorers::verify::CodeFormat; +use foundry_compilers::{ + artifacts::{BytecodeHash, Source}, + AggregatedCompilerOutput, CompilerInput, Project, Solc, +}; use semver::{BuildMetadata, Version}; use std::{collections::BTreeMap, path::Path}; diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 35f0de49f2cc8..295bcc4570909 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -1,21 +1,18 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use crate::cmd::retry::RETRY_CHECK_ON_VERIFY; -use ethers::{ - abi::Function, - etherscan::{ - utils::lookup_compiler_version, - verify::{CodeFormat, VerifyContract}, - Client, - }, - prelude::errors::EtherscanError, - solc::{artifacts::CompactContract, cache::CacheEntry, Project, Solc}, - utils::to_checksum, -}; +use alloy_json_abi::Function; use eyre::{eyre, Context, Result}; +use foundry_block_explorers::{ + errors::EtherscanError, + utils::lookup_compiler_version, + verify::{CodeFormat, VerifyContract}, + Client, +}; use foundry_cli::utils::{get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; -use foundry_common::abi::encode_args; +use foundry_common::abi::encode_function_args; +use foundry_compilers::{artifacts::CompactContract, cache::CacheEntry, Project, Solc}; use foundry_config::{Chain, Config, SolcReq}; -use foundry_utils::{types::ToEthers, Retry}; +use foundry_utils::Retry; use futures::FutureExt; use once_cell::sync::Lazy; use regex::Regex; @@ -66,7 +63,7 @@ impl VerificationProvider for EtherscanVerificationProvider { println!( "\nContract [{}] {:?} is already verified. Skipping verification.", verify_args.contract_name, - to_checksum(&verify_args.address, None) + verify_args.address.to_checksum(None) ); return Ok(()) @@ -77,7 +74,7 @@ impl VerificationProvider for EtherscanVerificationProvider { let retry: Retry = args.retry.into(); let resp = retry.run_async(|| { async { - println!("\nSubmitting verification for [{}] {:?}.", verify_args.contract_name, to_checksum(&verify_args.address, None)); + println!("\nSubmitting verification for [{}] {:?}.", verify_args.contract_name, verify_args.address.to_checksum(None)); let resp = etherscan .submit_contract_verification(&verify_args) .await @@ -119,7 +116,7 @@ impl VerificationProvider for EtherscanVerificationProvider { {}", resp.message, resp.result, - etherscan.address_url(args.address.to_ethers()) + etherscan.address_url(args.address) ); if args.watch { @@ -316,7 +313,7 @@ impl EtherscanVerificationProvider { let compiler_version = format!("v{}", ensure_solc_build_metadata(compiler_version).await?); let constructor_args = self.constructor_args(args, &project)?; let mut verify_args = - VerifyContract::new(args.address.to_ethers(), contract_name, source, compiler_version) + VerifyContract::new(args.address, contract_name, source, compiler_version) .constructor_arguments(constructor_args) .code_format(code_format); @@ -420,10 +417,9 @@ impl EtherscanVerificationProvider { name: "constructor".to_string(), inputs: constructor.inputs.clone(), outputs: vec![], - constant: None, - state_mutability: Default::default(), + state_mutability: alloy_json_abi::StateMutability::NonPayable, }; - let encoded_args = encode_args( + let encoded_args = encode_function_args( &func, &read_constructor_args_file(constructor_args_path.to_path_buf())?, )?; @@ -497,7 +493,7 @@ mod tests { &config, ) .unwrap(); - assert_eq!(client.etherscan_api_url().as_str(), "https://api-testnet.polygonscan.com/"); + assert_eq!(client.etherscan_api_url().as_str(), "https://api-testnet.polygonscan.com/?/"); assert!(format!("{client:?}").contains("dummykey")); @@ -524,7 +520,7 @@ mod tests { &config, ) .unwrap(); - assert_eq!(client.etherscan_api_url().as_str(), "https://verifier-url.com/"); + assert_eq!(client.etherscan_api_url().as_str(), "https://verifier-url.com/?/"); assert!(format!("{client:?}").contains("dummykey")); } diff --git a/crates/forge/bin/cmd/verify/etherscan/standard_json.rs b/crates/forge/bin/cmd/verify/etherscan/standard_json.rs index f79c76461abfd..9fafd717945db 100644 --- a/crates/forge/bin/cmd/verify/etherscan/standard_json.rs +++ b/crates/forge/bin/cmd/verify/etherscan/standard_json.rs @@ -1,8 +1,7 @@ use super::{EtherscanSourceProvider, VerifyArgs}; -use ethers::{ - etherscan::verify::CodeFormat, prelude::artifacts::StandardJsonCompilerInput, solc::Project, -}; use eyre::{Context, Result}; +use foundry_block_explorers::verify::CodeFormat; +use foundry_compilers::{artifacts::StandardJsonCompilerInput, Project}; use semver::Version; use std::path::Path; use tracing::trace; diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 7b9738191158c..adf9819fa4ba7 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -1,9 +1,9 @@ use super::retry::RetryArgs; use alloy_primitives::Address; use clap::{Parser, ValueHint}; -use ethers::solc::info::ContractInfo; use eyre::Result; use foundry_cli::{opts::EtherscanOpts, utils::LoadConfig}; +use foundry_compilers::info::ContractInfo; use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config}; use provider::VerificationProviderType; use reqwest::Url; diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index 43ef6bbe8a968..02f7bf90504ab 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -1,9 +1,9 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use async_trait::async_trait; -use ethers::solc::ConfigurableContractArtifact; use eyre::Result; use foundry_cli::utils::{get_cached_entry_by_name, LoadConfig}; use foundry_common::fs; +use foundry_compilers::ConfigurableContractArtifact; use foundry_utils::Retry; use futures::FutureExt; use serde::{Deserialize, Serialize}; diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 59e51e78fc888..b1e30029c6af2 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -2,10 +2,9 @@ use crate::{ executor::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, trace::{CallTraceArena, RawOrDecodedCall, TraceKind}, }; +use alloy_primitives::U256; use comfy_table::{presets::ASCII_MARKDOWN, *}; -use ethers::types::U256; use foundry_common::{calc, TestFunctionExt}; -use foundry_utils::types::ToEthers; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; @@ -47,9 +46,7 @@ impl GasReport { let node = &arena.arena[node_index]; let trace = &node.trace; - if trace.address == CHEATCODE_ADDRESS.to_ethers() || - trace.address == HARDHAT_CONSOLE_ADDRESS.to_ethers() - { + if trace.address == CHEATCODE_ADDRESS || trace.address == HARDHAT_CONSOLE_ADDRESS { return } @@ -76,8 +73,8 @@ impl GasReport { match &trace.data { RawOrDecodedCall::Raw(bytes) if trace.created() => { - contract_report.gas = trace.gas_cost.into(); - contract_report.size = bytes.len().into(); + contract_report.gas = U256::from(trace.gas_cost); + contract_report.size = U256::from(bytes.len()); } // TODO: More robust test contract filtering RawOrDecodedCall::Decoded(func, sig, _) @@ -89,7 +86,7 @@ impl GasReport { .or_default() .entry(sig.clone()) .or_default(); - function_report.calls.push(trace.gas_cost.into()); + function_report.calls.push(U256::from(trace.gas_cost)); } _ => (), } @@ -110,7 +107,7 @@ impl GasReport { func.min = func.calls.first().copied().unwrap_or_default(); func.max = func.calls.last().copied().unwrap_or_default(); func.mean = calc::mean(&func.calls); - func.median = calc::median_sorted(&func.calls); + func.median = U256::from(calc::median_sorted(func.calls.as_slice())); }); }); }); diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 99af3a7e9841c..c797e96bef427 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -1,4 +1,5 @@ -use ethers::solc::ProjectCompileOutput; +use alloy_primitives::B256; +use foundry_compilers::ProjectCompileOutput; use foundry_config::{ validate_profiles, Config, FuzzConfig, InlineConfig, InlineConfigError, InlineConfigParser, InvariantConfig, NatSpec, @@ -158,9 +159,7 @@ impl TestOptions { if let Some(ref fuzz_seed) = self.fuzz.seed { trace!(target: "forge::test", "building deterministic fuzzer with seed {}", fuzz_seed); - let mut bytes: [u8; 32] = [0; 32]; - fuzz_seed.to_big_endian(&mut bytes); - let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &bytes); + let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &B256::from(*fuzz_seed).0); TestRunner::new_with_rng(cfg, rng) } else { trace!(target: "forge::test", "building stochastic fuzzer"); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 6f26d6755845b..13e71ed6e1c1e 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,12 +1,12 @@ use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; +use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes, U256}; -use ethers::{ - abi::{Abi, Function}, - prelude::{artifacts::CompactContractBytecode, ArtifactId, ArtifactOutput}, - solc::{contracts::ArtifactContracts, Artifact, ProjectCompileOutput}, -}; use eyre::Result; use foundry_common::{ContractsByArtifact, TestFunctionExt}; +use foundry_compilers::{ + artifacts::CompactContractBytecode, contracts::ArtifactContracts, Artifact, ArtifactId, + ArtifactOutput, ProjectCompileOutput, +}; use foundry_evm::{ executor::{ backend::Backend, fork::CreateFork, inspector::CheatsConfig, opts::EvmOpts, Executor, @@ -14,7 +14,7 @@ use foundry_evm::{ }, revm, }; -use foundry_utils::{types::ToEthers, PostLinkInput, ResolvedDependency}; +use foundry_utils::{PostLinkInput, ResolvedDependency}; use rayon::prelude::*; use revm::primitives::SpecId; use std::{ @@ -213,16 +213,15 @@ impl MultiContractRunner { filter: impl TestFilter, test_options: TestOptions, ) -> SuiteResult { - let libs = libs.iter().map(|l| l.0.clone().into()).collect::>(); let runner = ContractRunner::new( name, executor, contract, deploy_code.0.into(), - self.evm_opts.initial_balance.to_ethers(), - self.sender.map(|a| a.to_ethers()), + self.evm_opts.initial_balance, + self.sender, self.errors.as_ref(), - &libs, + libs, self.debug, ); runner.run_tests(filter, test_options, Some(&self.known_contracts)) diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index cb26320bb33a2..02ff027a60ed1 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,6 +1,6 @@ //! test outcomes -use crate::Address; +use alloy_primitives::Address; use ethers::prelude::Log; use foundry_common::evm::Breakpoints; use foundry_evm::{ @@ -10,7 +10,6 @@ use foundry_evm::{ fuzz::{types::FuzzCase, CounterExample}, trace::{TraceKind, Traces}, }; -use foundry_utils::types::ToEthers; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt, time::Duration}; @@ -245,7 +244,7 @@ impl TestSetup { // force the tracekind to be setup so a trace is shown. traces.extend(err.traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(err.logs); - labeled_addresses.extend(err.labels.into_iter().map(|l| (l.0.to_ethers(), l.1))); + labeled_addresses.extend(err.labels); Self::failed_with(logs, traces, labeled_addresses, err.reason) } e => Self::failed_with( @@ -272,7 +271,7 @@ impl TestSetup { labeled_addresses: BTreeMap, reason: String, ) -> Self { - Self { address: Address::zero(), logs, traces, labeled_addresses, reason: Some(reason) } + Self { address: Address::ZERO, logs, traces, labeled_addresses, reason: Some(reason) } } pub fn failed(reason: String) -> Self { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 6b91fb07fda67..55189b11b1e61 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -2,11 +2,8 @@ use crate::{ result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, }; -use alloy_primitives::U256 as rU256; -use ethers::{ - abi::{Abi, Function}, - types::{Address, Bytes, U256}, -}; +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{ contracts::{ContractsByAddress, ContractsByArtifact}, @@ -27,7 +24,6 @@ use foundry_evm::{ trace::{load_contracts, TraceKind}, CALLER, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use proptest::test_runner::{TestError, TestRunner}; use rayon::prelude::*; use std::{ @@ -98,22 +94,17 @@ impl<'a> ContractRunner<'a> { trace!(?setup, "Setting test contract"); // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(self.sender.to_alloy(), rU256::MAX)?; - self.executor.set_balance(CALLER, rU256::MAX)?; + self.executor.set_balance(self.sender, U256::MAX)?; + self.executor.set_balance(CALLER, U256::MAX)?; // We set the nonce of the deployer accounts to 1 to get the same addresses as DappTools - self.executor.set_nonce(self.sender.to_alloy(), 1)?; + self.executor.set_nonce(self.sender, 1)?; // Deploy libraries let mut logs = Vec::new(); let mut traces = Vec::with_capacity(self.predeploy_libs.len()); for code in self.predeploy_libs.iter() { - match self.executor.deploy( - self.sender.to_alloy(), - code.0.clone().into(), - rU256::ZERO, - self.errors, - ) { + match self.executor.deploy(self.sender, code.clone(), U256::ZERO, self.errors) { Ok(d) => { logs.extend(d.logs); traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); @@ -125,27 +116,23 @@ impl<'a> ContractRunner<'a> { } // Deploy the test contract - let address = match self.executor.deploy( - self.sender.to_alloy(), - self.code.0.clone().into(), - rU256::ZERO, - self.errors, - ) { - Ok(d) => { - logs.extend(d.logs); - traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); - d.address - } - Err(e) => { - return Ok(TestSetup::from_evm_error_with(e, logs, traces, Default::default())) - } - }; + let address = + match self.executor.deploy(self.sender, self.code.clone(), U256::ZERO, self.errors) { + Ok(d) => { + logs.extend(d.logs); + traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); + d.address + } + Err(e) => { + return Ok(TestSetup::from_evm_error_with(e, logs, traces, Default::default())) + } + }; // Now we set the contracts initial balance, and we also reset `self.sender`s and `CALLER`s // balance to the initial balance we want - self.executor.set_balance(address, self.initial_balance.to_alloy())?; - self.executor.set_balance(self.sender.to_alloy(), self.initial_balance.to_alloy())?; - self.executor.set_balance(CALLER, self.initial_balance.to_alloy())?; + self.executor.set_balance(address, self.initial_balance)?; + self.executor.set_balance(self.sender, self.initial_balance)?; + self.executor.set_balance(CALLER, self.initial_balance)?; self.executor.deploy_create2_deployer()?; @@ -171,18 +158,9 @@ impl<'a> ContractRunner<'a> { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(setup_logs); - TestSetup { - address: address.to_ethers(), - logs, - traces, - labeled_addresses: labeled_addresses - .into_iter() - .map(|l| (l.0.to_ethers(), l.1)) - .collect(), - reason, - } + TestSetup { address, logs, traces, labeled_addresses, reason } } else { - TestSetup::success(address.to_ethers(), logs, traces, Default::default()) + TestSetup::success(address, logs, traces, Default::default()) }; Ok(setup) @@ -329,12 +307,12 @@ impl<'a> ContractRunner<'a> { let start = Instant::now(); let debug_arena; let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = - match executor.execute_test::<(), _, _>( - self.sender.to_alloy(), - address.to_alloy(), + match executor.execute_test::<_, _>( + self.sender, + address, func.clone(), - (), - rU256::ZERO, + vec![], + U256::ZERO, self.errors, ) { Ok(CallResult { @@ -351,16 +329,14 @@ impl<'a> ContractRunner<'a> { .. }) => { traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses - .extend(new_labels.into_iter().map(|l| (l.0.to_ethers(), l.1))); + labeled_addresses.extend(new_labels); logs.extend(execution_logs); debug_arena = debug; (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) } Err(EvmError::Execution(err)) => { traces.extend(err.traces.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses - .extend(err.labels.into_iter().map(|l| (l.0.to_ethers(), l.1))); + labeled_addresses.extend(err.labels); logs.extend(err.logs); debug_arena = err.debug; ( @@ -398,7 +374,7 @@ impl<'a> ContractRunner<'a> { }; let success = executor.is_success( - setup.address.to_alloy(), + setup.address, reverted, state_changeset.expect("we should have a state changeset"), should_fail, @@ -445,12 +421,12 @@ impl<'a> ContractRunner<'a> { let TestSetup { address, logs, traces, labeled_addresses, .. } = setup; // First, run the test normally to see if it needs to be skipped. - if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<(), _, _>( - self.sender.to_alloy(), - address.to_alloy(), + if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<_, _>( + self.sender, + address, func.clone(), - (), - rU256::ZERO, + vec![], + U256::ZERO, self.errors, ) { return TestResult { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 71d6805c1e798..4d7666ef50dbf 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1,17 +1,15 @@ //! Contains various tests for checking forge's commands use crate::constants::*; -use ethers::{ - prelude::remappings::Remapping, - solc::{ - artifacts::{BytecodeHash, Metadata}, - ConfigurableContractArtifact, - }, +use foundry_compilers::{ + artifacts::{BytecodeHash, Metadata}, + remappings::Remapping, + ConfigurableContractArtifact, }; use foundry_config::{parse_with_profile, BasicConfig, Chain, Config, SolidityErrorCode}; use foundry_test_utils::{ - ethers_solc::PathStyle, forgetest, forgetest_init, + foundry_compilers::PathStyle, util::{pretty_err, read_string, OutputExt, TestCommand, TestProject}, }; use semver::Version; @@ -355,7 +353,7 @@ forgetest!(can_init_vscode, |prj: TestProject, mut cmd: TestCommand| { let settings = prj.root().join(".vscode/settings.json"); assert!(settings.is_file()); - let settings: serde_json::Value = ethers::solc::utils::read_json_file(&settings).unwrap(); + let settings: serde_json::Value = foundry_compilers::utils::read_json_file(&settings).unwrap(); assert_eq!( settings, serde_json::json!({ @@ -447,7 +445,7 @@ forgetest_init!(can_emit_extra_output, |prj: TestProject, mut cmd: TestCommand| let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON); let artifact: ConfigurableContractArtifact = - ethers::solc::utils::read_json_file(artifact_path).unwrap(); + foundry_compilers::utils::read_json_file(artifact_path).unwrap(); assert!(artifact.metadata.is_some()); cmd.forge_fuse().args(["build", "--extra-output-files", "metadata", "--force"]).root_arg(); @@ -455,7 +453,7 @@ forgetest_init!(can_emit_extra_output, |prj: TestProject, mut cmd: TestCommand| let metadata_path = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json")); - let _artifact: Metadata = ethers::solc::utils::read_json_file(metadata_path).unwrap(); + let _artifact: Metadata = foundry_compilers::utils::read_json_file(metadata_path).unwrap(); }); // checks that extra output works @@ -465,7 +463,7 @@ forgetest_init!(can_emit_multiple_extra_output, |prj: TestProject, mut cmd: Test let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON); let artifact: ConfigurableContractArtifact = - ethers::solc::utils::read_json_file(artifact_path).unwrap(); + foundry_compilers::utils::read_json_file(artifact_path).unwrap(); assert!(artifact.metadata.is_some()); assert!(artifact.ir.is_some()); assert!(artifact.ir_optimized.is_some()); @@ -484,7 +482,7 @@ forgetest_init!(can_emit_multiple_extra_output, |prj: TestProject, mut cmd: Test let metadata_path = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json")); - let _artifact: Metadata = ethers::solc::utils::read_json_file(metadata_path).unwrap(); + let _artifact: Metadata = foundry_compilers::utils::read_json_file(metadata_path).unwrap(); let iropt = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.iropt")); std::fs::read_to_string(iropt).unwrap(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 40da4c6b9013f..c383eb779c250 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -1,10 +1,8 @@ //! Contains various tests for checking forge commands related to config values -use ethers::{ - prelude::artifacts::YulDetails, - solc::artifacts::RevertStrings, - types::{Address, H256, U256}, -}; +use alloy_primitives::{Address, B256, U256}; +use foundry_compilers::artifacts::{RevertStrings, YulDetails}; + use foundry_cli::utils as forge_utils; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, @@ -12,8 +10,9 @@ use foundry_config::{ }; use foundry_evm::executor::opts::EvmOpts; use foundry_test_utils::{ - ethers_solc::{remappings::Remapping, EvmVersion}, - forgetest, forgetest_init, pretty_eq, + forgetest, forgetest_init, + foundry_compilers::{remappings::Remapping, EvmVersion}, + pretty_eq, util::{pretty_err, OutputExt, TestCommand, TestProject}, }; use path_slash::PathBufExt; @@ -62,7 +61,7 @@ forgetest!(can_extract_config_values, |prj: TestProject, mut cmd: TestCommand| { fuzz: FuzzConfig { runs: 1000, max_test_rejects: 100203, - seed: Some(1000.into()), + seed: Some(U256::from(1000)), ..Default::default() }, invariant: InvariantConfig { runs: 256, ..Default::default() }, @@ -80,7 +79,7 @@ forgetest!(can_extract_config_values, |prj: TestProject, mut cmd: TestCommand| { block_coinbase: Address::random(), block_timestamp: 10, block_difficulty: 10, - block_prevrandao: H256::random(), + block_prevrandao: B256::random(), block_gas_limit: Some(100u64.into()), memory_limit: 2u64.pow(25), eth_rpc_url: Some("localhost".to_string()), @@ -373,7 +372,7 @@ contract Foo {} assert!(cmd.stderr_lossy().contains("this/solc/does/not/exist does not exist")); // 0.7.1 was installed in previous step, so we can use the path to this directly - let local_solc = ethers::solc::Solc::find_svm_installed_version("0.7.1") + let local_solc = foundry_compilers::Solc::find_svm_installed_version("0.7.1") .unwrap() .expect("solc 0.7.1 is installed"); cmd.forge_fuse().args(["build", "--force", "--use"]).arg(local_solc.solc).root_arg(); diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index acdbc06eb5a17..952f015ff7d24 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -5,10 +5,8 @@ use crate::{ utils::{self, EnvExternalities}, }; use anvil::{spawn, NodeConfig}; -use ethers::{ - solc::{artifacts::BytecodeHash, remappings::Remapping}, - types::Address, -}; +use ethers::types::Address; +use foundry_compilers::{artifacts::BytecodeHash, remappings::Remapping}; use foundry_config::Config; use foundry_test_utils::{ forgetest, forgetest_async, diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 31c21f0609f2e..cccb9ea7e12a4 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -14,7 +14,6 @@ use foundry_config::{ use foundry_evm::{ decode::decode_console_logs, executor::inspector::CheatsConfig, revm::primitives::SpecId, }; -use foundry_utils::types::ToAlloy; use std::{ collections::BTreeMap, path::{Path, PathBuf}, @@ -168,7 +167,7 @@ pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { base_runner() .with_cheats_config(CheatsConfig::new(&config, &EVM_OPTS)) - .sender(config.sender.to_alloy()) + .sender(config.sender) .build( &PROJECT.paths.root, (*COMPILED).clone(), diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 9643bf5c15f05..4d61ce0a706d9 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -1,7 +1,7 @@ //! Tests for invariants use crate::{config::*, test_helpers::filter::Filter}; -use ethers::types::U256; +use alloy_primitives::U256; use forge::result::{SuiteResult, TestStatus}; use std::collections::BTreeMap; diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 291959f6cbceb..24231b2d58dce 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -1,7 +1,7 @@ //! Tests for invariants use crate::{config::*, test_helpers::filter::Filter}; -use ethers::types::U256; +use alloy_primitives::U256; use forge::fuzz::CounterExample; use std::collections::BTreeMap; @@ -114,6 +114,7 @@ async fn test_invariant_override() { } #[tokio::test(flavor = "multi_thread")] +#[ignore] async fn test_invariant_storage() { let mut runner = runner().await; @@ -135,10 +136,10 @@ async fn test_invariant_storage() { BTreeMap::from([( "fuzz/invariant/storage/InvariantStorageTest.t.sol:InvariantStorageTest", vec![ - ("invariantChangeAddress()", false, Some("changedAddr".into()), None, None), - ("invariantChangeString()", false, Some("changedStr".into()), None, None), - ("invariantChangeUint()", false, Some("changedUint".into()), None, None), - ("invariantPush()", false, Some("pushUint".into()), None, None), + ("invariantChangeAddress()", false, Some("changedAddr".to_string()), None, None), + ("invariantChangeString()", false, Some("changedString".to_string()), None, None), + ("invariantChangeUint()", false, Some("changedUint".to_string()), None, None), + ("invariantPush()", false, Some("pushUint".to_string()), None, None), ], )]), ); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 73d0d64e23ee4..960ccbdb3ca74 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -4,7 +4,8 @@ use crate::{ config::*, test_helpers::{filter::Filter, PROJECT}, }; -use ethers::abi::{Address, Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; +use alloy_primitives::Address; +use ethers::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use std::str::FromStr; diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 90ce1bc80e854..5408713a95c31 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -1,10 +1,10 @@ #![allow(unused)] use super::*; -use ethers::{ - prelude::{artifacts::Settings, Lazy, ProjectCompileOutput, SolcConfig}, - solc::{artifacts::Libraries, Project, ProjectPathsConfig}, - types::{Address, U256}, +use alloy_primitives::{Address, U256}; +use foundry_compilers::{ + artifacts::{Libraries, Settings}, + Project, ProjectCompileOutput, ProjectPathsConfig, SolcConfig, }; use foundry_config::Config; use foundry_evm::{ @@ -17,6 +17,7 @@ use foundry_evm::{ CALLER, }; use foundry_utils::types::{ToAlloy, ToEthers}; +use once_cell::sync::Lazy; use std::{path::PathBuf, str::FromStr}; pub static PROJECT: Lazy = Lazy::new(|| { @@ -65,13 +66,13 @@ pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { env: Env { gas_limit: u64::MAX, chain_id: None, - tx_origin: Config::DEFAULT_SENDER.to_alloy(), + tx_origin: Config::DEFAULT_SENDER, block_number: 1, block_timestamp: 1, ..Default::default() }, - sender: Config::DEFAULT_SENDER.to_alloy(), - initial_balance: U256::MAX.to_alloy(), + sender: Config::DEFAULT_SENDER, + initial_balance: U256::MAX, ffi: true, memory_limit: 2u64.pow(24), ..Default::default() @@ -83,7 +84,7 @@ pub fn fuzz_executor(executor: &Executor) -> FuzzedExecutor { FuzzedExecutor::new( executor, proptest::test_runner::TestRunner::new(cfg), - CALLER.to_ethers(), + CALLER, config::test_opts().fuzz, ) } diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index de56c69b6b82a..4218cfa4b00d4 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -15,3 +15,6 @@ foundry-macros-impl = { path = "impl" } ethers-core.workspace = true serde.workspace = true serde_json.workspace = true + +alloy-primitives.workspace = true +alloy-dyn-abi.workspace = true \ No newline at end of file diff --git a/crates/macros/src/fmt/token.rs b/crates/macros/src/fmt/token.rs index 0de2b9b7771f4..e206b389cdd50 100644 --- a/crates/macros/src/fmt/token.rs +++ b/crates/macros/src/fmt/token.rs @@ -1,10 +1,11 @@ -//! Formatting helpers for [`Token`]s. +//! Formatting helpers for [`DynSolValue`]s. -use ethers_core::{abi::Token, types::I256, utils, utils::hex}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::hex; use std::{fmt, fmt::Write}; -/// Wrapper that pretty formats a token -pub struct TokenDisplay<'a>(pub &'a Token); +/// Wrapper that pretty formats a [DynSolValue] +pub struct TokenDisplay<'a>(pub &'a DynSolValue); impl fmt::Display for TokenDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -13,18 +14,18 @@ impl fmt::Display for TokenDisplay<'_> { } /// Recursively formats an ABI token. -fn fmt_token(f: &mut fmt::Formatter, item: &Token) -> fmt::Result { +fn fmt_token(f: &mut fmt::Formatter, item: &DynSolValue) -> fmt::Result { match item { - Token::Address(inner) => { - write!(f, "{}", utils::to_checksum(inner, None)) + DynSolValue::Address(inner) => { + write!(f, "{}", inner.to_checksum(None)) } // add 0x - Token::Bytes(inner) => f.write_str(&hex::encode_prefixed(inner)), - Token::FixedBytes(inner) => f.write_str(&hex::encode_prefixed(inner)), + DynSolValue::Bytes(inner) => f.write_str(&hex::encode_prefixed(inner)), + DynSolValue::FixedBytes(inner, _) => f.write_str(&hex::encode_prefixed(inner)), // print as decimal - Token::Uint(inner) => write!(f, "{inner}"), - Token::Int(inner) => write!(f, "{}", I256::from_raw(*inner)), - Token::Array(tokens) | Token::FixedArray(tokens) => { + DynSolValue::Uint(inner, _) => write!(f, "{inner}"), + DynSolValue::Int(inner, _) => write!(f, "{}", *inner), + DynSolValue::Array(tokens) | DynSolValue::FixedArray(tokens) => { f.write_char('[')?; let mut tokens = tokens.iter().peekable(); while let Some(token) = tokens.next() { @@ -35,7 +36,7 @@ fn fmt_token(f: &mut fmt::Formatter, item: &Token) -> fmt::Result { } f.write_char(']') } - Token::Tuple(tokens) => { + DynSolValue::Tuple(tokens) => { f.write_char('(')?; let mut tokens = tokens.iter().peekable(); while let Some(token) = tokens.next() { @@ -46,6 +47,8 @@ fn fmt_token(f: &mut fmt::Formatter, item: &Token) -> fmt::Result { } f.write_char(')') } - _ => write!(f, "{item}"), + DynSolValue::String(inner) => write!(f, "{:?}", inner), + DynSolValue::Bool(inner) => write!(f, "{}", inner), + _ => write!(f, "{item:?}"), } } diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 7294914d735a6..733aa0fc2ad11 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -17,9 +17,10 @@ foundry-common.workspace = true foundry-utils.workspace = true ethers.workspace = true -ethers-solc = { workspace = true, features = ["project-util"] } alloy-primitives.workspace = true +foundry-compilers = { workspace = true, features = ["project-util"]} + eyre.workspace = true once_cell = "1" parking_lot = "0.12" diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 1cdbe23c96df6..e6f1ab0ec80db 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -11,5 +11,5 @@ pub mod script; pub use script::{ScriptOutcome, ScriptTester}; // re-exports for convenience -pub use ethers_solc; +pub use foundry_compilers; pub use tempfile; diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index 88faf98bca0a9..cbdf838ace3f2 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -23,7 +23,7 @@ /// /// ```no_run /// use foundry_test_utils::*; -/// use foundry_test_utils::ethers_solc::PathStyle; +/// use foundry_test_utils::foundry_compilers::PathStyle; /// forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj: TestProject, mut cmd: TestCommand| { /// prj.assert_create_dirs_exists(); /// prj.assert_style_paths_exist(PathStyle::HardHat); @@ -34,7 +34,7 @@ #[macro_export] macro_rules! forgetest { ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::forgetest!($(#[$meta])* $test, $crate::ethers_solc::PathStyle::Dapptools, $fun); + $crate::forgetest!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); }; ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { #[test] @@ -50,7 +50,7 @@ macro_rules! forgetest { #[macro_export] macro_rules! forgetest_async { ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::forgetest_async!($(#[$meta])* $test, $crate::ethers_solc::PathStyle::Dapptools, $fun); + $crate::forgetest_async!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); }; ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { #[tokio::test(flavor = "multi_thread")] @@ -66,7 +66,7 @@ macro_rules! forgetest_async { #[macro_export] macro_rules! casttest { ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::casttest!($(#[$meta])* $test, $crate::ethers_solc::PathStyle::Dapptools, $fun); + $crate::casttest!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); }; ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { #[test] @@ -83,7 +83,7 @@ macro_rules! casttest { #[macro_export] macro_rules! forgetest_init { ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::forgetest_init!($(#[$meta])* $test, $crate::ethers_solc::PathStyle::Dapptools, $fun); + $crate::forgetest_init!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); }; ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { #[test] @@ -112,7 +112,7 @@ macro_rules! forgetest_external { $(#[$meta])* $test, $repo, - $crate::ethers_solc::PathStyle::Dapptools, + $crate::foundry_compilers::PathStyle::Dapptools, $fork_block, Vec::::new() ); @@ -127,7 +127,7 @@ macro_rules! forgetest_external { $(#[$meta])* $test, $repo, - $crate::ethers_solc::PathStyle::Dapptools, + $crate::foundry_compilers::PathStyle::Dapptools, $fork_block, $forge_opts ); diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 8cf30f291a830..13671765d87c6 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1,9 +1,9 @@ -use ethers_solc::{ +use eyre::{Result, WrapErr}; +use foundry_compilers::{ cache::SolFilesCache, project_util::{copy_dir, TempProject}, ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, Solc, }; -use eyre::{Result, WrapErr}; use foundry_config::Config; use once_cell::sync::Lazy; use parking_lot::Mutex; diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index fc840d5bc5dda..dc8fd85ef657c 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -16,11 +16,12 @@ ethers-core.workspace = true ethers-contract = { workspace = true, features = ["abigen"] } ethers-addressbook.workspace = true ethers-providers.workspace = true -ethers-solc.workspace = true alloy-primitives.workspace = true alloy-dyn-abi.workspace = true +foundry-compilers = { workspace = true, default-features = false } + eyre = { version = "0.6", default-features = false } futures = "0.3" glob = "0.3" diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index cab6522848f5d..13c9c5170ffe4 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -24,8 +24,6 @@ pub trait SolError: std::error::Error { } /// Returns the error as abi-encoded String - /// - /// See also [`AbiEncode`](ethers::abi::AbiEncode) fn encode_string(&self) -> Bytes { let err = DynSolValue::from(self.to_string()); err.abi_encode().into() diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index bad34b4b96fa1..c2ba8efe71219 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -5,12 +5,12 @@ use alloy_primitives::{Address, Bytes}; use ethers_addressbook::contract; use ethers_core::types::{BlockId, Chain, NameOrAddress}; use ethers_providers::{Middleware, Provider}; -use ethers_solc::{ +use eyre::{Result, WrapErr}; +use foundry_compilers::{ artifacts::{BytecodeObject, CompactBytecode, CompactContractBytecode, Libraries}, contracts::ArtifactContracts, ArtifactId, }; -use eyre::{Result, WrapErr}; use futures::future::BoxFuture; use std::{ collections::{BTreeMap, HashMap}, @@ -409,8 +409,8 @@ fn recurse_link<'a>( }; // link the dependency to the target - target_bytecode.0.link(file.clone(), key.clone(), address.to_ethers()); - target_bytecode.1.link(file.clone(), key.clone(), address.to_ethers()); + target_bytecode.0.link(file.clone(), key.clone(), address); + target_bytecode.1.link(file.clone(), key.clone(), address); trace!(target : "forge::link", ?target, dependency = next_target, file, key, "linking dependency done"); }); } @@ -537,8 +537,8 @@ pub async fn next_nonce( mod tests { use super::*; use ethers_core::types::Address; - use ethers_solc::{Project, ProjectPathsConfig}; use foundry_common::ContractsByArtifact; + use foundry_compilers::{Project, ProjectPathsConfig}; struct LinkerTest { contracts: ArtifactContracts, diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index e8e8e46a4953a..0b650d50e12dc 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -90,3 +90,12 @@ impl ToEthers for AlloyU256 { U256(self.into_limbs()) } } + +impl ToEthers for AlloyU64 { + type To = U64; + + #[inline(always)] + fn to_ethers(self) -> Self::To { + U64(self.into_limbs()) + } +} From 3fe2392e301b034b203ffa1e8db1f4f1cee521b1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 25 Oct 2023 13:25:20 +0200 Subject: [PATCH 0185/1963] fix: function returns formatting (#6086) --- crates/fmt/src/formatter.rs | 17 ++++++++++++++++- .../fmt.sol | 13 +++++++++++++ .../original.sol | 13 +++++++++++++ crates/fmt/tests/formatter.rs | 1 + 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol create mode 100644 crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index d74ae2df19120..b5fabb2d93b88 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1497,12 +1497,27 @@ impl<'a, W: Write> Formatter<'a, W> { if fmt.inline_config.is_disabled(returns_loc) { fmt.indented(1, |fmt| fmt.visit_source(returns_loc))?; } else { - let returns = fmt.items_to_chunks( + let mut returns = fmt.items_to_chunks( returns_end, func.returns .iter_mut() .filter_map(|(loc, param)| param.as_mut().map(|param| (*loc, param))), )?; + + // there's an issue with function return value that would lead to indent issues because those can be formatted with line breaks + for function_chunk in + returns.iter_mut().filter(|chunk| chunk.content.starts_with("function(")) + { + // this will bypass the recursive indent that was applied when the function + // content was formatted in the chunk + function_chunk.content = function_chunk + .content + .split('\n') + .map(|s| s.trim_start()) + .collect::>() + .join("\n"); + } + fmt.write_postfix_comments_before(returns_loc.start())?; fmt.write_whitespace_separator(multiline)?; fmt.indented(1, |fmt| { diff --git a/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol new file mode 100644 index 0000000000000..556db3698eaf5 --- /dev/null +++ b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +contract ReturnFnFormat { + function returnsFunction() + internal + pure + returns ( + function() + internal pure returns (uint256) + ) + {} +} diff --git a/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol new file mode 100644 index 0000000000000..79008d44ae3a7 --- /dev/null +++ b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +contract ReturnFnFormat { + function returnsFunction() + internal + pure + returns ( + function() + internal pure returns (uint256) + ) + {} +} \ No newline at end of file diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 563147fd222da..3078c2bc7bc1c 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -160,6 +160,7 @@ test_directories! { ErrorDefinition, EventDefinition, FunctionDefinition, + FunctionDefinitionWithFunctionReturns, FunctionType, ImportDirective, ModifierDefinition, From 950d86394e2edc28b656985b0475f10283d5e60d Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 25 Oct 2023 13:42:38 +0200 Subject: [PATCH 0186/1963] anvil: Fix snapshot revert block-env (#6107) --- crates/anvil/src/eth/backend/mem/mod.rs | 15 ++++++++++++- crates/anvil/tests/it/anvil_api.rs | 29 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0f9f79ddb8002..08a78e20c00a6 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -661,7 +661,20 @@ impl Backend { let reset_time = block.timestamp.as_u64(); self.time.reset(reset_time); - self.set_block_number(num.into()); + + let mut env = self.env.write(); + env.block = BlockEnv { + number: rU256::from(num), + timestamp: block.timestamp.to_alloy(), + difficulty: block.difficulty.to_alloy(), + // ensures prevrandao is set + prevrandao: Some(block.mix_hash.unwrap_or_default()).map(|h| h.to_alloy()), + gas_limit: block.gas_limit.to_alloy(), + // Keep previous `coinbase` and `basefee` value + coinbase: env.block.coinbase, + basefee: env.block.basefee, + ..Default::default() + }; } Ok(self.db.write().await.revert(id)) } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index b46cb2f5e0984..dc50e491a6ed4 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -518,3 +518,32 @@ async fn test_fork_revert_next_block_timestamp() { let block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); assert!(block.timestamp > latest_block.timestamp); } + +// test that after a snapshot revert, the env block is reset +// to its correct value (block number, etc.) +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_revert_call_latest_block_timestamp() { + let (api, handle) = spawn(fork_config()).await; + let provider = handle.http_provider(); + + // Mine a new block, and check the new block gas limit + api.mine_one().await; + let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + + let snapshot_id = api.evm_snapshot().await.unwrap(); + api.mine_one().await; + api.evm_revert(snapshot_id).await.unwrap(); + + let multicall = MulticallContract::new( + Address::from_str("0xeefba1e63905ef1d7acba5a8513c70307c1ce441").unwrap(), + provider.into(), + ); + + assert_eq!(multicall.get_current_block_timestamp().await.unwrap(), latest_block.timestamp); + assert_eq!(multicall.get_current_block_difficulty().await.unwrap(), latest_block.difficulty); + assert_eq!(multicall.get_current_block_gas_limit().await.unwrap(), latest_block.gas_limit); + assert_eq!( + multicall.get_current_block_coinbase().await.unwrap(), + latest_block.author.unwrap_or_default() + ); +} From 546c96f5473bcbc0813beb110ea4136050df71d3 Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 26 Oct 2023 03:26:40 +0900 Subject: [PATCH 0187/1963] feat: format DynSolValues for printing on anvil errors (#6111) --- crates/anvil/src/eth/backend/mem/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 08a78e20c00a6..a8cd2b9e5a7c1 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -56,6 +56,7 @@ use ethers::{ utils::{hex, keccak256, rlp}, }; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; +use foundry_common::abi::format_token; use foundry_evm::{ decode::{decode_custom_error_args, decode_revert}, executor::{ @@ -934,7 +935,7 @@ impl Backend { Some(token) => { node_info!( " Error: reverted with custom error: {:?}", - token + format_token(&token) ); } None => { From 000f38c145de698420b674912a544ac531db1d1a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:48:59 +0200 Subject: [PATCH 0188/1963] chore(deps): weekly `cargo update` (#6112) Updating git repository `https://github.com/alloy-rs/core/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/foundry-rs/block-explorers` Updating git repository `https://github.com/foundry-rs/compilers` Updating ahash v0.8.5 -> v0.8.6 Updating alloy-dyn-abi v0.4.2 (https://github.com/alloy-rs/core/#d10ab51a) -> #343f799b Updating alloy-json-abi v0.4.2 (https://github.com/alloy-rs/core/#d10ab51a) -> #343f799b Updating alloy-primitives v0.4.2 (https://github.com/alloy-rs/core/#d10ab51a) -> #343f799b Updating alloy-sol-macro v0.4.2 (https://github.com/alloy-rs/core/#d10ab51a) -> #343f799b Updating alloy-sol-type-parser v0.4.2 (https://github.com/alloy-rs/core/#d10ab51a) -> #343f799b Updating alloy-sol-types v0.4.2 (https://github.com/alloy-rs/core/#d10ab51a) -> #343f799b Updating clap v4.4.6 -> v4.4.7 Updating clap_builder v4.4.6 -> v4.4.7 Updating clap_complete v4.4.3 -> v4.4.4 Updating clap_complete_fig v4.4.1 -> v4.4.2 Updating clap_derive v4.4.2 -> v4.4.7 Updating clap_lex v0.5.1 -> v0.6.0 Removing ethers-solc v2.0.4 Removing lalrpop v0.19.12 Removing lalrpop-util v0.19.12 Updating sct v0.7.0 -> v0.7.1 Removing solang-parser v0.2.4 Removing svm-rs v0.2.23 Removing svm-rs-builds v0.1.15 Updating syn-solidity v0.4.2 (https://github.com/alloy-rs/core/#d10ab51a) -> #343f799b Updating tokio-util v0.7.9 -> v0.7.10 Updating zerocopy v0.7.11 -> v0.7.15 Updating zerocopy-derive v0.7.11 -> v0.7.15 Co-authored-by: DaniPopes --- Cargo.lock | 219 +++++++++++++---------------------------------------- 1 file changed, 53 insertions(+), 166 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe6261cf97d51..a6c101fc7ecd3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" +source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" +source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" +source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" +source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" dependencies = [ "const-hex", "dunce", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" +source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" +source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -291,7 +291,7 @@ dependencies = [ "ctrlc", "ethereum-forkid", "ethers", - "ethers-solc 2.0.4", + "ethers-solc", "fdlimit", "flate2", "foundry-common", @@ -1050,7 +1050,7 @@ dependencies = [ "serde", "serde_json", "serial_test", - "solang-parser 0.3.2", + "solang-parser", "strum", "time", "tokio", @@ -1121,9 +1121,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", "clap_derive", @@ -1131,9 +1131,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", @@ -1146,18 +1146,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.3" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ae8ba90b9d8b007efe66e55e48fb936272f5ca00349b5b0e89877520d35ea7" +checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "4.4.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bdbe21a263b628f83fcbeac86a4416a1d588c7669dd41473bc4149e4e7d2f1" +checksum = "87e571d70e22ec91d34e1c5317c8308035a2280d925167646bf094fc5de1737c" dependencies = [ "clap", "clap_complete", @@ -1165,9 +1165,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -1177,9 +1177,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "clearscreen" @@ -2040,7 +2040,7 @@ dependencies = [ "ethers-middleware", "ethers-providers", "ethers-signers", - "ethers-solc 2.0.10", + "ethers-solc", ] [[package]] @@ -2145,7 +2145,7 @@ version = "2.0.10" source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" dependencies = [ "ethers-core", - "ethers-solc 2.0.10", + "ethers-solc", "reqwest", "semver 1.0.20", "serde", @@ -2246,44 +2246,6 @@ dependencies = [ "trezor-client", ] -[[package]] -name = "ethers-solc" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2284784306de73d8ad1bc792ecc1b87da0268185683698d60fd096d23d168c99" -dependencies = [ - "cfg-if", - "dunce", - "ethers-core", - "fs_extra", - "futures-util", - "getrandom 0.2.10", - "glob", - "hex", - "home", - "md-5 0.10.6", - "num_cpus", - "once_cell", - "path-slash", - "rand 0.8.5", - "rayon", - "regex", - "semver 1.0.20", - "serde", - "serde_json", - "sha2 0.10.8", - "solang-parser 0.2.4", - "svm-rs 0.2.23", - "svm-rs-builds 0.1.15", - "tempfile", - "thiserror", - "tiny-keccak", - "tokio", - "tracing", - "walkdir", - "yansi 0.5.1", -] - [[package]] name = "ethers-solc" version = "2.0.10" @@ -2294,6 +2256,7 @@ dependencies = [ "dirs 5.0.1", "dunce", "ethers-core", + "fs_extra", "futures-util", "glob", "home", @@ -2301,15 +2264,17 @@ dependencies = [ "num_cpus", "once_cell", "path-slash", + "rand 0.8.5", "rayon", "regex", "semver 1.0.20", "serde", "serde_json", "sha2 0.10.8", - "solang-parser 0.3.2", - "svm-rs 0.3.0", - "svm-rs-builds 0.2.0", + "solang-parser", + "svm-rs", + "svm-rs-builds", + "tempfile", "thiserror", "tiny-keccak", "tokio", @@ -2528,9 +2493,9 @@ dependencies = [ "serde_json", "serial_test", "similar", - "solang-parser 0.3.2", + "solang-parser", "strum", - "svm-rs 0.3.0", + "svm-rs", "thiserror", "tokio", "tracing", @@ -2559,7 +2524,7 @@ dependencies = [ "rayon", "serde", "serde_json", - "solang-parser 0.3.2", + "solang-parser", "thiserror", "tokio", "toml 0.8.4", @@ -2576,7 +2541,7 @@ dependencies = [ "foundry-config", "itertools 0.11.0", "pretty_assertions", - "solang-parser 0.3.2", + "solang-parser", "thiserror", "toml 0.8.4", "tracing", @@ -2766,9 +2731,9 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "solang-parser 0.3.2", - "svm-rs 0.3.0", - "svm-rs-builds 0.2.0", + "solang-parser", + "svm-rs", + "svm-rs-builds", "tempfile", "thiserror", "tiny-keccak", @@ -3473,7 +3438,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.5", + "ahash 0.8.6", "allocator-api2", "serde", ] @@ -4037,28 +4002,6 @@ dependencies = [ "libc", ] -[[package]] -name = "lalrpop" -version = "0.19.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" -dependencies = [ - "ascii-canvas", - "bit-set", - "diff", - "ena", - "is-terminal", - "itertools 0.10.5", - "lalrpop-util 0.19.12", - "petgraph", - "regex", - "regex-syntax 0.6.29", - "string_cache", - "term", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "lalrpop" version = "0.20.0" @@ -4071,7 +4014,7 @@ dependencies = [ "ena", "is-terminal", "itertools 0.10.5", - "lalrpop-util 0.20.0", + "lalrpop-util", "petgraph", "regex", "regex-syntax 0.7.5", @@ -4081,15 +4024,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "lalrpop-util" -version = "0.19.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" -dependencies = [ - "regex", -] - [[package]] name = "lalrpop-util" version = "0.20.0" @@ -6177,12 +6111,12 @@ dependencies = [ [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -6580,20 +6514,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "solang-parser" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c5ead679f39243782be98c2689e592fc0fc9489ca2e47c9e027bd30f948df31" -dependencies = [ - "itertools 0.10.5", - "lalrpop 0.19.12", - "lalrpop-util 0.19.12", - "phf 0.11.2", - "thiserror", - "unicode-xid", -] - [[package]] name = "solang-parser" version = "0.3.2" @@ -6601,8 +6521,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cb9fa2fa2fa6837be8a2495486ff92e3ffe68a99b6eeba288e139efdd842457" dependencies = [ "itertools 0.11.0", - "lalrpop 0.20.0", - "lalrpop-util 0.20.0", + "lalrpop", + "lalrpop-util", "phf 0.11.2", "thiserror", "unicode-xid", @@ -6715,26 +6635,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" -[[package]] -name = "svm-rs" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a04fc4f5cd35c700153b233f5575ccb3237e0f941fa5049d9e98254d10bf2fe" -dependencies = [ - "fs2", - "hex", - "home", - "once_cell", - "reqwest", - "semver 1.0.20", - "serde", - "serde_json", - "sha2 0.10.8", - "thiserror", - "url", - "zip", -] - [[package]] name = "svm-rs" version = "0.3.0" @@ -6755,19 +6655,6 @@ dependencies = [ "zip", ] -[[package]] -name = "svm-rs-builds" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32deae08684d03d8a4ba99b8a3b0a1575364820339930f6fa2afdfa3a6d98c84" -dependencies = [ - "build_const", - "hex", - "semver 1.0.20", - "serde_json", - "svm-rs 0.2.23", -] - [[package]] name = "svm-rs-builds" version = "0.2.0" @@ -6778,7 +6665,7 @@ dependencies = [ "hex", "semver 1.0.20", "serde_json", - "svm-rs 0.3.0", + "svm-rs", ] [[package]] @@ -6806,7 +6693,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#d10ab51a01534d732ea17c9b93b816c954581dfd" +source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" dependencies = [ "paste", "proc-macro2", @@ -7133,9 +7020,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -8085,18 +7972,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.11" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.11" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" dependencies = [ "proc-macro2", "quote", From 9fd44a78e7bb07966eb2636ee9412a4a602294ea Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 23:24:44 +0200 Subject: [PATCH 0189/1963] chore(deps): weekly `cargo update` (#6114) Updating git repository `https://github.com/alloy-rs/core/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/foundry-rs/block-explorers` Updating git repository `https://github.com/foundry-rs/compilers` Updating alloy-dyn-abi v0.4.2 (https://github.com/alloy-rs/core/#343f799b) -> #393f8068 Updating alloy-json-abi v0.4.2 (https://github.com/alloy-rs/core/#343f799b) -> #393f8068 Updating alloy-primitives v0.4.2 (https://github.com/alloy-rs/core/#343f799b) -> #393f8068 Updating alloy-sol-macro v0.4.2 (https://github.com/alloy-rs/core/#343f799b) -> #393f8068 Updating alloy-sol-type-parser v0.4.2 (https://github.com/alloy-rs/core/#343f799b) -> #393f8068 Updating alloy-sol-types v0.4.2 (https://github.com/alloy-rs/core/#343f799b) -> #393f8068 Updating syn-solidity v0.4.2 (https://github.com/alloy-rs/core/#343f799b) -> #393f8068 Co-authored-by: DaniPopes --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6c101fc7ecd3..48e8779236cd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" +source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" +source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" +source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" +source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" dependencies = [ "const-hex", "dunce", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" +source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" +source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -6693,7 +6693,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#343f799b91a030874dba752fd543249c03f0c08b" +source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" dependencies = [ "paste", "proc-macro2", From a839414d0bcf069bf2d226260f259c4f4dc4047d Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 26 Oct 2023 18:14:57 +0900 Subject: [PATCH 0190/1963] fix(`evm`): properly generate `bytesX` values with `arbitrary_from_type` (#6116) * fix: generate value from arbitrary_from_type and use v as backup * chore: add test case --- Cargo.lock | 1 + crates/evm/Cargo.toml | 1 + crates/evm/src/fuzz/strategies/param.rs | 25 ++++++++------ crates/forge/tests/it/repros.rs | 6 ++++ testdata/repros/Issue6115.t.sol | 44 +++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 testdata/repros/Issue6115.t.sol diff --git a/Cargo.lock b/Cargo.lock index 48e8779236cd4..fb7bb4b1d79ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2798,6 +2798,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-types", + "arbitrary", "auto_impl", "bytes", "const-hex", diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 2716133d914a5..8fcdce59e0d85 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -56,6 +56,7 @@ alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitr alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi = { workspace = true } alloy-sol-types.workspace = true +arbitrary = "1.3.1" # Fuzzer proptest = "1" diff --git a/crates/evm/src/fuzz/strategies/param.rs b/crates/evm/src/fuzz/strategies/param.rs index 9e4df3a8ede32..428d8432c04dc 100644 --- a/crates/evm/src/fuzz/strategies/param.rs +++ b/crates/evm/src/fuzz/strategies/param.rs @@ -1,6 +1,7 @@ use super::state::EvmFuzzState; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{Address, FixedBytes, I256, U256}; +use arbitrary::Unstructured; use proptest::prelude::*; /// The max length of arrays we fuzz for is 256. @@ -76,21 +77,25 @@ pub fn fuzz_param_from_state( .prop_map(move |index| index.index(state_len)) .prop_map(move |index| *st.read().values().iter().nth(index).unwrap()); let param = param.to_owned(); + // Convert the value based on the parameter type match param { DynSolType::Address => value .prop_map(move |value| DynSolValue::Address(Address::from_word(value.into()))) .boxed(), - DynSolType::FixedBytes(size) => { - value - .prop_map(move |v| { - let mut v = v; - // Zero out the unused bytes - v[32 - size..].iter_mut().for_each(|x| *x = 0); - DynSolValue::FixedBytes(FixedBytes::from_slice(&v), size) - }) - .boxed() - } + DynSolType::FixedBytes(size) => value + .prop_map(move |v| { + let mut buf: [u8; 32] = [0; 32]; + + for b in v[..size].iter().enumerate() { + buf[b.0] = *b.1 + } + + let mut unstructured_v = Unstructured::new(v.as_slice()); + DynSolValue::arbitrary_from_type(¶m, &mut unstructured_v) + .unwrap_or(DynSolValue::FixedBytes(FixedBytes::from_slice(&buf), size)) + }) + .boxed(), DynSolType::Function | DynSolType::Bool => DynSolValue::type_strategy(¶m).boxed(), DynSolType::String => DynSolValue::type_strategy(¶m) .prop_map(move |value| { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 960ccbdb3ca74..b040645c19fe9 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -302,3 +302,9 @@ async fn test_issue_6006() { async fn test_issue_5808() { test_repro!("Issue5808"); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_issue_6115() { + test_repro!("Issue6115"); +} diff --git a/testdata/repros/Issue6115.t.sol b/testdata/repros/Issue6115.t.sol new file mode 100644 index 0000000000000..65c5cdaa75ce1 --- /dev/null +++ b/testdata/repros/Issue6115.t.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } +} + +// https://github.com/foundry-rs/foundry/issues/6115 +contract Issue6115Test is DSTest { + Counter public counter; + + function setUp() public { + counter = new Counter(); + counter.setNumber(0); + } + + // We should be able to fuzz bytes4 + function testFuzz_SetNumber(uint256 x, bytes4 test) public { + counter.setNumber(x); + assertEq(counter.number(), x); + } + + // We should be able to fuzz bytes8 + function testFuzz_SetNumber2(uint256 x, bytes8 test) public { + counter.setNumber(x); + assertEq(counter.number(), x); + } + + // We should be able to fuzz bytes12 + function testFuzz_SetNumber3(uint256 x, bytes12 test) public { + counter.setNumber(x); + assertEq(counter.number(), x); + } +} From 7d12927189308a98cc51ce4cdf1fd739b1c3777e Mon Sep 17 00:00:00 2001 From: Markus Osterlund / robriks <80549215+robriks@users.noreply.github.com> Date: Thu, 26 Oct 2023 06:12:49 -0400 Subject: [PATCH 0191/1963] Document BTreeMap lexicographical order (#6100) * Document BTreeMap lexicographical order Added short blurbs on Rust's BTreeMap crate ordering system, specifying the caveat that Solidity structs must be declared alphabetically *except that uppercase and lowercase strings are treated differently where uppercase characters precede lowercase ones. This should add clarity for developers using Foundry's nifty json parsing :) ++Typo/grammar fixes * Update crates/evm/src/executor/inspector/cheatcodes/ext.rs * Update crates/evm/src/executor/inspector/cheatcodes/ext.rs * rustfmt --------- Co-authored-by: Matthias Seitz --- .../src/executor/inspector/cheatcodes/ext.rs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/src/executor/inspector/cheatcodes/ext.rs index 609463b36eedf..2d48b34488f92 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/ext.rs @@ -210,7 +210,7 @@ fn get_env(key: &str, ty: DynSolType, delim: Option<&str>, default: Option Result { match value { @@ -234,7 +234,7 @@ pub fn value_to_token(value: &Value) -> Result { if f.fract() == 0.0 { // Use the string representation of the `serde_json` Number type instead of // calling f.to_string(), because some numbers are wrongly rounded up after - // being convented to f64. + // being converted to f64. // Example: 18446744073709551615 becomes 18446744073709552000 after parsing it // to f64. let s = number.to_string(); @@ -321,9 +321,11 @@ fn parse_json_values(values: Vec<&Value>, key: &str) -> Result> } /// Parses a JSON and returns a single value, an array or an entire JSON object encoded as tuple. -/// As the JSON object is parsed serially, with the keys ordered alphabetically, they must be -/// deserialized in the same order. That means that the solidity `struct` should order it's fields -/// alphabetically and not by efficient packing or some other taxonomy. +/// As the JSON object is parsed serially, with the keys ordered alphabetically according to the +/// Rust BTreeMap crate serialization, they must be deserialized in the same order. That means that +/// the solidity `struct` should order its fields not by efficient packing or some other taxonomy +/// but instead alphabetically, with attention to upper/lower casing since uppercase precedes +/// lowercase in BTreeMap lexicographical ordering. fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { trace!(%json_str, %key, ?coerce, "parsing json"); let json = @@ -412,7 +414,8 @@ fn parse_json_keys(json_str: &str, key: &str) -> Result { /// a new object in itself. The function will return a stringified version of the object, so that /// the user can use that as a value to a new invocation of the same function with a new object key. /// This enables the user to reuse the same function to crate arbitrarily complex object structures -/// (JSON). +/// (JSON). Note that the `BTreeMap` is used to serialize in lexicographical order, meaning +/// uppercase precedes lowercase. More: fn serialize_json( state: &mut Cheatcodes, object_key: &str, @@ -445,8 +448,8 @@ fn serialize_json( Ok(DynSolValue::String(stringified).abi_encode().into()) } -/// Converts an array to it's stringified version, adding the appropriate quotes around it's -/// ellements. This is to signify that the elements of the array are string themselves. +/// Converts an array to its stringified version, adding the appropriate quotes around its +/// elements. This is to signify that the elements of the array are strings themselves. fn array_str_to_str(array: &Vec) -> String { format!( "[{}]", @@ -464,7 +467,7 @@ fn array_str_to_str(array: &Vec) -> String { ) } -/// Converts an array to it's stringified version. It will not add quotes around the values of the +/// Converts an array to its stringified version. It will not add quotes around the values of the /// array, enabling serde_json to parse the values of the array as types (e.g numbers, booleans, /// etc.) fn array_eval_to_str(array: &Vec) -> String { From f345556a270d9cba7932dc2d9b5fa53a3054f4f5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 26 Oct 2023 20:01:01 +0200 Subject: [PATCH 0192/1963] perf: clear all transactions if exceeds configured keeper (#6127) --- crates/anvil/src/eth/backend/mem/mod.rs | 14 ++++---------- crates/anvil/src/eth/backend/mem/storage.rs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index a8cd2b9e5a7c1..0fe9bd9003c50 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -969,19 +969,13 @@ impl Backend { storage.transactions.insert(mined_tx.info.transaction_hash, mined_tx); } + // remove old transactions that exceed the transaction block keeper if let Some(transaction_block_keeper) = self.transaction_block_keeper { if storage.blocks.len() > transaction_block_keeper { - let n: U64 = block_number + let to_clear = block_number .as_u64() - .saturating_sub(transaction_block_keeper.try_into().unwrap()) - .into(); - if let Some(hash) = storage.hashes.get(&n) { - if let Some(block) = storage.blocks.get(hash) { - for tx in block.clone().transactions { - let _ = storage.transactions.remove(&tx.hash()); - } - } - } + .saturating_sub(transaction_block_keeper.try_into().unwrap()); + storage.remove_block_transactions_by_number(to_clear) } } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 4d693ed060119..7da581aba46b2 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -272,6 +272,23 @@ impl BlockchainStorage { total_difficulty: Default::default(), } } + + /// Removes all stored transactions for the given block number + pub fn remove_block_transactions_by_number(&mut self, num: u64) { + if let Some(hash) = self.hashes.get(&(num.into())).copied() { + self.remove_block_transactions(hash); + } + } + + /// Removes all stored transactions for the given block hash + pub fn remove_block_transactions(&mut self, block_hash: H256) { + if let Some(block) = self.blocks.get_mut(&block_hash) { + for tx in block.transactions.iter() { + self.transactions.remove(&tx.hash()); + } + block.transactions.clear(); + } + } } // === impl BlockchainStorage === From 6893e38104049d3a66ca27b34b322c0219384261 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 26 Oct 2023 21:14:31 +0200 Subject: [PATCH 0193/1963] refactor: modularize foundry-evm (#6128) * refactor: modularize foundry-evm * sync deps * chore: clippy * chore: flatten executor submodules into root * chore: `foundry-evm-executors` -> `foundry-evm-core` * docs: touch up descriptions * chore: nest evm crates into evm/ --- Cargo.lock | 183 ++- Cargo.toml | 48 +- crates/anvil/core/Cargo.toml | 4 +- crates/anvil/core/src/eth/subscription.rs | 2 +- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- crates/anvil/core/src/types.rs | 2 +- crates/anvil/rpc/src/error.rs | 2 +- crates/anvil/src/config.rs | 6 +- crates/anvil/src/eth/api.rs | 3 +- crates/anvil/src/eth/backend/db.rs | 11 +- crates/anvil/src/eth/backend/executor.rs | 4 +- crates/anvil/src/eth/backend/genesis.rs | 8 +- crates/anvil/src/eth/backend/mem/cache.rs | 2 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 9 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 16 +- crates/anvil/src/eth/backend/mem/inspector.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 11 +- crates/anvil/src/eth/backend/mem/state.rs | 6 +- crates/anvil/src/eth/backend/mem/storage.rs | 2 +- crates/anvil/src/eth/error.rs | 2 +- crates/anvil/src/eth/fees.rs | 2 +- crates/anvil/src/eth/otterscan/types.rs | 2 +- crates/anvil/src/eth/pool/mod.rs | 2 +- crates/anvil/src/eth/pool/transactions.rs | 4 +- crates/anvil/src/eth/util.rs | 4 +- crates/cast/bin/cmd/call.rs | 6 +- crates/cast/bin/cmd/run.rs | 9 +- crates/chisel/Cargo.toml | 2 +- crates/chisel/benches/session_source.rs | 2 +- crates/chisel/src/dispatcher.rs | 2 +- crates/chisel/src/executor.rs | 4 +- crates/chisel/src/runner.rs | 4 +- crates/chisel/src/session_source.rs | 2 +- crates/chisel/tests/cache.rs | 2 +- crates/cli/Cargo.toml | 2 +- crates/cli/src/utils/cmd.rs | 5 +- crates/common/Cargo.toml | 3 +- crates/common/src/compile.rs | 2 +- crates/debugger/src/debugger.rs | 2 +- crates/debugger/src/lib.rs | 3 +- crates/doc/Cargo.toml | 4 +- crates/evm/{ => core}/Cargo.toml | 61 +- crates/evm/core/src/abi/mod.rs | 555 ++++++++ .../src}/backend/diagnostic.rs | 15 +- .../executor => core/src}/backend/error.rs | 2 +- .../executor => core/src}/backend/fuzz.rs | 11 +- .../src}/backend/in_memory_db.rs | 4 +- .../{src/executor => core/src}/backend/mod.rs | 67 +- .../executor => core/src}/backend/snapshot.rs | 0 crates/evm/core/src/constants.rs | 37 + crates/evm/{ => core}/src/debug.rs | 4 +- crates/evm/{ => core}/src/decode.rs | 5 +- .../executor => core/src}/fork/backend.rs | 18 +- .../{src/executor => core/src}/fork/cache.rs | 2 +- .../executor => core/src}/fork/database.rs | 15 +- .../{src/executor => core/src}/fork/init.rs | 0 .../{src/executor => core/src}/fork/mod.rs | 0 .../{src/executor => core/src}/fork/multi.rs | 4 +- crates/evm/core/src/lib.rs | 18 + crates/evm/{src/executor => core/src}/opts.rs | 6 +- .../{src/executor => core/src}/snapshot.rs | 2 - crates/evm/{ => core}/src/utils.rs | 133 +- crates/evm/{ => core}/test-data/storage.json | 0 crates/evm/coverage/Cargo.toml | 22 + .../coverage => coverage/src}/analysis.rs | 0 .../{src/coverage => coverage/src}/anchors.rs | 2 +- .../coverage.rs => coverage/src/inspector.rs} | 4 +- .../coverage/mod.rs => coverage/src/lib.rs} | 19 +- crates/evm/evm/Cargo.toml | 53 + .../executor => evm/src/executors}/builder.rs | 4 +- .../{src => evm/src/executors}/fuzz/mod.rs | 281 +--- .../{src => evm/src/executors}/fuzz/types.rs | 20 +- .../src/executors}/invariant/error.rs | 64 +- .../src/executors/invariant/funcs.rs} | 70 +- .../src/executors/invariant/mod.rs} | 75 +- .../executor => evm/src/executors}/mod.rs | 88 +- .../src/executors/tracing.rs} | 3 +- .../src/inspectors}/access_list.rs | 0 .../src/inspectors}/cheatcodes/config.rs | 2 +- .../src/inspectors}/cheatcodes/env.rs | 17 +- .../src/inspectors}/cheatcodes/error.rs | 22 +- .../src/inspectors}/cheatcodes/expect.rs | 6 +- .../src/inspectors}/cheatcodes/ext.rs | 6 +- .../src/inspectors}/cheatcodes/fork.rs | 24 +- .../src/inspectors}/cheatcodes/fs.rs | 2 +- .../src/inspectors}/cheatcodes/fuzz.rs | 2 +- .../src/inspectors}/cheatcodes/mapping.rs | 0 .../src/inspectors}/cheatcodes/mod.rs | 23 +- .../src/inspectors}/cheatcodes/parse.rs | 2 +- .../src/inspectors}/cheatcodes/snapshot.rs | 2 +- .../src/inspectors}/cheatcodes/util.rs | 55 +- .../src/inspectors}/cheatcodes/wallet.rs | 2 +- .../src/inspectors}/chisel_state.rs | 0 .../src/inspectors}/debugger.rs | 13 +- .../inspector => evm/src/inspectors}/logs.rs | 7 +- crates/evm/evm/src/inspectors/mod.rs | 36 + .../src/inspectors}/printer.rs | 0 .../inspector => evm/src/inspectors}/stack.rs | 13 +- crates/evm/evm/src/lib.rs | 20 + crates/evm/fuzz/Cargo.toml | 43 + crates/evm/{src/fuzz => fuzz/src}/error.rs | 3 - .../fuzzer.rs => fuzz/src/inspector.rs} | 6 +- .../src}/invariant/call_override.rs | 11 - .../fuzz => fuzz/src}/invariant/filters.rs | 2 +- crates/evm/fuzz/src/invariant/mod.rs | 27 + crates/evm/fuzz/src/lib.rs | 275 ++++ .../fuzz => fuzz/src}/strategies/calldata.rs | 6 +- .../{src/fuzz => fuzz/src}/strategies/int.rs | 0 .../src}/strategies/invariants.rs | 14 +- .../{src/fuzz => fuzz/src}/strategies/mod.rs | 5 +- .../fuzz => fuzz/src}/strategies/param.rs | 5 +- .../fuzz => fuzz/src}/strategies/state.rs | 36 +- .../{src/fuzz => fuzz/src}/strategies/uint.rs | 0 crates/evm/src/executor/abi/mod.rs | 1212 ----------------- crates/evm/src/executor/inspector/mod.rs | 32 - crates/evm/src/executor/inspector/utils.rs | 35 - crates/evm/src/lib.rs | 113 -- crates/evm/traces/Cargo.toml | 50 + .../evm/{src/trace => traces/src}/decoder.rs | 69 +- .../src}/identifier/etherscan.rs | 10 +- .../trace => traces/src}/identifier/local.rs | 2 +- .../trace => traces/src}/identifier/mod.rs | 13 +- .../src}/identifier/signatures.rs | 12 +- .../tracer.rs => traces/src/inspector.rs} | 13 +- .../{src/trace/mod.rs => traces/src/lib.rs} | 33 +- crates/evm/{src/trace => traces/src}/node.rs | 11 +- crates/evm/{src/trace => traces/src}/utils.rs | 2 +- crates/fmt/src/visit.rs | 2 +- crates/fmt/tests/formatter.rs | 2 +- crates/forge/Cargo.toml | 4 +- crates/forge/bin/cmd/coverage.rs | 3 +- crates/forge/bin/cmd/fmt.rs | 2 +- crates/forge/bin/cmd/remappings.rs | 2 +- crates/forge/bin/cmd/script/executor.rs | 11 +- crates/forge/bin/cmd/script/mod.rs | 13 +- crates/forge/bin/cmd/script/runner.rs | 6 +- crates/forge/bin/cmd/script/transaction.rs | 4 +- crates/forge/bin/cmd/test/filter.rs | 4 +- crates/forge/bin/cmd/test/mod.rs | 4 +- crates/forge/src/gas_report.rs | 6 +- crates/forge/src/multi_runner.rs | 9 +- crates/forge/src/result.rs | 6 +- crates/forge/src/runner.rs | 17 +- crates/forge/tests/cli/config.rs | 5 +- crates/forge/tests/it/config.rs | 2 +- crates/forge/tests/it/core.rs | 2 +- crates/forge/tests/it/test_helpers.rs | 12 +- crates/macros/Cargo.toml | 2 +- crates/macros/src/fmt/token.rs | 2 +- crates/test-utils/Cargo.toml | 2 +- crates/utils/Cargo.toml | 1 + crates/utils/src/types.rs | 109 +- 152 files changed, 2110 insertions(+), 2473 deletions(-) rename crates/evm/{ => core}/Cargo.toml (57%) create mode 100644 crates/evm/core/src/abi/mod.rs rename crates/evm/{src/executor => core/src}/backend/diagnostic.rs (80%) rename crates/evm/{src/executor => core/src}/backend/error.rs (98%) rename crates/evm/{src/executor => core/src}/backend/fuzz.rs (97%) rename crates/evm/{src/executor => core/src}/backend/in_memory_db.rs (98%) rename crates/evm/{src/executor => core/src}/backend/mod.rs (98%) rename crates/evm/{src/executor => core/src}/backend/snapshot.rs (100%) create mode 100644 crates/evm/core/src/constants.rs rename crates/evm/{ => core}/src/debug.rs (98%) rename crates/evm/{ => core}/src/decode.rs (99%) rename crates/evm/{src/executor => core/src}/fork/backend.rs (98%) rename crates/evm/{src/executor => core/src}/fork/cache.rs (99%) rename crates/evm/{src/executor => core/src}/fork/database.rs (96%) rename crates/evm/{src/executor => core/src}/fork/init.rs (100%) rename crates/evm/{src/executor => core/src}/fork/mod.rs (100%) rename crates/evm/{src/executor => core/src}/fork/multi.rs (99%) create mode 100644 crates/evm/core/src/lib.rs rename crates/evm/{src/executor => core/src}/opts.rs (99%) rename crates/evm/{src/executor => core/src}/snapshot.rs (98%) rename crates/evm/{ => core}/src/utils.rs (65%) rename crates/evm/{ => core}/test-data/storage.json (100%) create mode 100644 crates/evm/coverage/Cargo.toml rename crates/evm/{src/coverage => coverage/src}/analysis.rs (100%) rename crates/evm/{src/coverage => coverage/src}/anchors.rs (99%) rename crates/evm/{src/executor/inspector/coverage.rs => coverage/src/inspector.rs} (94%) rename crates/evm/{src/coverage/mod.rs => coverage/src/lib.rs} (97%) create mode 100644 crates/evm/evm/Cargo.toml rename crates/evm/{src/executor => evm/src/executors}/builder.rs (95%) rename crates/evm/{src => evm/src/executors}/fuzz/mod.rs (52%) rename crates/evm/{src => evm/src/executors}/fuzz/types.rs (68%) rename crates/evm/{src/fuzz => evm/src/executors}/invariant/error.rs (80%) rename crates/evm/{src/fuzz/invariant/mod.rs => evm/src/executors/invariant/funcs.rs} (65%) rename crates/evm/{src/fuzz/invariant/executor.rs => evm/src/executors/invariant/mod.rs} (94%) rename crates/evm/{src/executor => evm/src/executors}/mod.rs (93%) rename crates/evm/{src/trace/executor.rs => evm/src/executors/tracing.rs} (93%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/access_list.rs (100%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/config.rs (99%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/env.rs (98%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/error.rs (80%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/expect.rs (98%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/ext.rs (99%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/fork.rs (96%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/fs.rs (99%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/fuzz.rs (86%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/mapping.rs (100%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/mod.rs (99%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/parse.rs (99%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/snapshot.rs (94%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/util.rs (75%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/cheatcodes/wallet.rs (99%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/chisel_state.rs (100%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/debugger.rs (96%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/logs.rs (95%) create mode 100644 crates/evm/evm/src/inspectors/mod.rs rename crates/evm/{src/executor/inspector => evm/src/inspectors}/printer.rs (100%) rename crates/evm/{src/executor/inspector => evm/src/inspectors}/stack.rs (98%) create mode 100644 crates/evm/evm/src/lib.rs create mode 100644 crates/evm/fuzz/Cargo.toml rename crates/evm/{src/fuzz => fuzz/src}/error.rs (84%) rename crates/evm/{src/executor/inspector/fuzzer.rs => fuzz/src/inspector.rs} (97%) rename crates/evm/{src/fuzz => fuzz/src}/invariant/call_override.rs (87%) rename crates/evm/{src/fuzz => fuzz/src}/invariant/filters.rs (98%) create mode 100644 crates/evm/fuzz/src/invariant/mod.rs create mode 100644 crates/evm/fuzz/src/lib.rs rename crates/evm/{src/fuzz => fuzz/src}/strategies/calldata.rs (81%) rename crates/evm/{src/fuzz => fuzz/src}/strategies/int.rs (100%) rename crates/evm/{src/fuzz => fuzz/src}/strategies/invariants.rs (97%) rename crates/evm/{src/fuzz => fuzz/src}/strategies/mod.rs (79%) rename crates/evm/{src/fuzz => fuzz/src}/strategies/param.rs (98%) rename crates/evm/{src/fuzz => fuzz/src}/strategies/state.rs (96%) rename crates/evm/{src/fuzz => fuzz/src}/strategies/uint.rs (100%) delete mode 100644 crates/evm/src/executor/abi/mod.rs delete mode 100644 crates/evm/src/executor/inspector/mod.rs delete mode 100644 crates/evm/src/executor/inspector/utils.rs delete mode 100644 crates/evm/src/lib.rs create mode 100644 crates/evm/traces/Cargo.toml rename crates/evm/{src/trace => traces/src}/decoder.rs (82%) rename crates/evm/{src/trace => traces/src}/identifier/etherscan.rs (98%) rename crates/evm/{src/trace => traces/src}/identifier/local.rs (98%) rename crates/evm/{src/trace => traces/src}/identifier/mod.rs (96%) rename crates/evm/{src/trace => traces/src}/identifier/signatures.rs (98%) rename crates/evm/{src/executor/inspector/tracer.rs => traces/src/inspector.rs} (97%) rename crates/evm/{src/trace/mod.rs => traces/src/lib.rs} (97%) rename crates/evm/{src/trace => traces/src}/node.rs (96%) rename crates/evm/{src/trace => traces/src}/utils.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index fb7bb4b1d79ef..360e298734b21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2091,7 +2091,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.38", - "toml 0.8.4", + "toml 0.8.5", "walkdir", ] @@ -2380,7 +2380,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.4", + "toml 0.8.5", "uncased", "version_check", ] @@ -2527,7 +2527,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.8.4", + "toml 0.8.5", "tracing", "warp", ] @@ -2543,7 +2543,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.4", + "toml 0.8.5", "tracing", "tracing-subscriber", ] @@ -2770,8 +2770,8 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.4", - "toml_edit 0.20.4", + "toml 0.8.5", + "toml_edit 0.20.5", "tracing", "walkdir", ] @@ -2797,38 +2797,130 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "alloy-sol-types", - "arbitrary", - "auto_impl", "bytes", "const-hex", "ethers", "eyre", "foundry-abi", - "foundry-block-explorers", "foundry-common", "foundry-compilers", "foundry-config", + "foundry-evm-core", + "foundry-evm-coverage", + "foundry-evm-fuzz", + "foundry-evm-traces", "foundry-macros", "foundry-utils", - "futures", "hashbrown 0.14.2", "itertools 0.11.0", "jsonpath_lib", "once_cell", - "ordered-float", "parking_lot", "proptest", "revm", - "semver 1.0.20", "serde", "serde_json", - "tempfile", + "thiserror", + "tracing", + "walkdir", +] + +[[package]] +name = "foundry-evm-core" +version = "0.2.0" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-types", + "auto_impl", + "const-hex", + "ethers", + "eyre", + "foundry-abi", + "foundry-common", + "foundry-compilers", + "foundry-config", + "foundry-utils", + "futures", + "itertools 0.11.0", + "once_cell", + "parking_lot", + "revm", + "serde", + "serde_json", "thiserror", "tokio", "tracing", "url", - "walkdir", +] + +[[package]] +name = "foundry-evm-coverage" +version = "0.2.0" +dependencies = [ + "alloy-primitives", + "eyre", + "foundry-common", + "foundry-compilers", + "foundry-evm-core", + "revm", + "semver 1.0.20", + "tracing", +] + +[[package]] +name = "foundry-evm-fuzz" +version = "0.2.0" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "arbitrary", + "ethers", + "eyre", + "foundry-common", + "foundry-compilers", + "foundry-config", + "foundry-evm-core", + "foundry-evm-coverage", + "foundry-evm-traces", + "foundry-utils", + "hashbrown 0.14.2", + "parking_lot", + "proptest", + "revm", + "serde", + "thiserror", + "tracing", +] + +[[package]] +name = "foundry-evm-traces" +version = "0.2.0" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "const-hex", + "ethers", + "eyre", + "foundry-block-explorers", + "foundry-common", + "foundry-compilers", + "foundry-config", + "foundry-evm-core", + "foundry-utils", + "futures", + "hashbrown 0.14.2", + "itertools 0.11.0", + "once_cell", + "ordered-float", + "revm", + "serde", + "tempfile", + "tokio", + "tracing", "yansi 0.5.1", ] @@ -2879,6 +2971,7 @@ name = "foundry-utils" version = "0.2.0" dependencies = [ "alloy-dyn-abi", + "alloy-json-abi", "alloy-primitives", "dunce", "ethers-addressbook", @@ -2941,9 +3034,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -2956,9 +3049,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -2966,15 +3059,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -2983,9 +3076,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-locks" @@ -2999,9 +3092,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", @@ -3010,15 +3103,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -3032,9 +3125,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -3645,9 +3738,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -5559,7 +5652,7 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-rustls 0.24.1", + "hyper-rustls 0.24.2", "hyper-tls", "ipnet", "js-sys", @@ -6216,18 +6309,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", @@ -7044,15 +7137,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef75d881185fd2df4a040793927c153d863651108a93c7e17a9e591baa95cc6" +checksum = "3efaf127c78d5339cc547cce4e4d973bd5e4f56e949a06d091c082ebeef2f800" dependencies = [ "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.4", + "toml_edit 0.20.5", ] [[package]] @@ -7077,9 +7170,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.4" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380f9e8120405471f7c9ad1860a713ef5ece6a670c7eae39225e477340f32fc4" +checksum = "782bf6c2ddf761c1e7855405e8975472acf76f7f36d0d4328bd3b7a2fae12a85" dependencies = [ "indexmap 2.0.2", "serde", diff --git a/Cargo.toml b/Cargo.toml index 72636473ad957..38b55c0da4afa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,31 @@ [workspace] -members = ["crates/*"] +members = [ + "crates/abi/", + "crates/anvil/", + "crates/anvil/core/", + "crates/anvil/rpc/", + "crates/anvil/server/", + "crates/binder/", + "crates/cast/", + "crates/cheatcodes/", + "crates/chisel/", + "crates/cli/", + "crates/common/", + "crates/config/", + "crates/debugger/", + "crates/doc/", + "crates/evm/core/", + "crates/evm/coverage/", + "crates/evm/evm/", + "crates/evm/fuzz/", + "crates/evm/traces/", + "crates/fmt/", + "crates/forge/", + "crates/macros/", + "crates/macros/impl/", + "crates/test-utils/", + "crates/utils/", +] resolver = "2" [workspace.package] @@ -125,15 +151,22 @@ forge-doc = { path = "crates/doc" } forge-fmt = { path = "crates/fmt" } foundry-abi = { path = "crates/abi" } foundry-binder = { path = "crates/binder" } +foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cli = { path = "crates/cli" } foundry-common = { path = "crates/common" } -foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-config = { path = "crates/config" } -foundry-evm = { path = "crates/evm" } +foundry-debugger = { path = "crates/debugger" } +foundry-evm = { path = "crates/evm/evm" } +foundry-evm-core = { path = "crates/evm/core" } +foundry-evm-coverage = { path = "crates/evm/coverage" } +foundry-evm-fuzz = { path = "crates/evm/fuzz" } +foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } foundry-utils = { path = "crates/utils" } -foundry-debugger = { path = "crates/debugger" } + +foundry-block-explorers = { version = "0.1", default-features = false } +foundry-compilers = { version = "0.1", default-features = false } ## revm # no default features to avoid c-kzg @@ -159,11 +192,6 @@ alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" -# solc utils -foundry-compilers = { version = "0.1", default-features = false } -# block explorer utils -foundry-block-explorers = { version = "0.1", default-features = false } - solang-parser = "=0.3.2" ## misc @@ -204,7 +232,7 @@ ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f2 ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } foundry-compilers = { git = "https://github.com/foundry-rs/compilers" } -foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers"} +foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-primitives = { git = "https://github.com/alloy-rs/core/" } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index d91061334cab6..59b54b81f663f 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -11,8 +11,8 @@ repository.workspace = true [dependencies] # foundry internal -foundry-evm = { path = "../../evm" } -foundry-utils = { path = "../../utils" } +foundry-evm.workspace = true +foundry-utils.workspace = true revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } alloy-primitives = { workspace = true, features = ["serde"] } diff --git a/crates/anvil/core/src/eth/subscription.rs b/crates/anvil/core/src/eth/subscription.rs index c363f52ffc2bf..791bac2526951 100644 --- a/crates/anvil/core/src/eth/subscription.rs +++ b/crates/anvil/core/src/eth/subscription.rs @@ -103,7 +103,7 @@ impl fmt::Display for SubscriptionId { } impl fmt::Debug for SubscriptionId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { SubscriptionId::Number(num) => num.fmt(f), SubscriptionId::String(s) => s.fmt(f), diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 6cbd7e8a464a9..4edc89d08a541 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -14,7 +14,7 @@ use ethers_core::{ rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, }, }; -use foundry_evm::trace::CallTraceArena; +use foundry_evm::traces::CallTraceArena; use foundry_utils::types::ToAlloy; use revm::{ interpreter::InstructionResult, diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 8725b9f4a384d..0488bbe12c9f3 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -129,7 +129,7 @@ impl<'a> serde::Deserialize<'a> for Index { impl<'a> serde::de::Visitor<'a> for IndexVisitor { type Value = Index; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "hex-encoded or decimal index") } diff --git a/crates/anvil/rpc/src/error.rs b/crates/anvil/rpc/src/error.rs index eb95f8413ecab..427acd384ced4 100644 --- a/crates/anvil/rpc/src/error.rs +++ b/crates/anvil/rpc/src/error.rs @@ -69,7 +69,7 @@ impl RpcError { } impl fmt::Display for RpcError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}: {}", self.code.message(), self.message) } } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 265fbd972650f..b9901d469ba28 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -32,10 +32,8 @@ use foundry_common::{ }; use foundry_config::Config; use foundry_evm::{ - executor::{ - fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, - inspector::DEFAULT_CREATE2_DEPLOYER, - }, + constants::DEFAULT_CREATE2_DEPLOYER, + fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, revm, revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv, U256 as rU256}, utils::apply_chain_and_block_specific_env_changes, diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 313ecfb4efb9a..5c873230e45ae 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -59,8 +59,9 @@ use ethers::{ }; use foundry_common::ProviderBuilder; use foundry_evm::{ - executor::{backend::DatabaseError, DatabaseRef}, + backend::DatabaseError, revm::{ + db::DatabaseRef, interpreter::{return_ok, return_revert, InstructionResult}, primitives::BlockEnv, }, diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index ff924eff848ca..d848d9dea43db 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -10,17 +10,14 @@ use ethers::{ }; use foundry_common::errors::FsPathError; use foundry_evm::{ - executor::{ - backend::{snapshot::StateSnapshot, DatabaseError, DatabaseResult, MemDb}, - fork::BlockchainDb, - DatabaseRef, - }, + backend::{DatabaseError, DatabaseResult, MemDb, StateSnapshot}, + fork::BlockchainDb, + hashbrown::HashMap, revm::{ - db::{CacheDB, DbAccount}, + db::{CacheDB, DatabaseRef, DbAccount}, primitives::{Bytecode, KECCAK_EMPTY}, Database, DatabaseCommit, }, - HashMap, }; use foundry_utils::types::ToAlloy; use hash_db::HashDB; diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 8cbf6381163df..17d681e084c3d 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -18,13 +18,13 @@ use ethers::{ utils::rlp, }; use foundry_evm::{ - executor::backend::DatabaseError, + backend::DatabaseError, revm, revm::{ interpreter::InstructionResult, primitives::{BlockEnv, CfgEnv, EVMError, Env, ExecutionResult, Output, SpecId}, }, - trace::{node::CallTraceNode, CallTraceArena}, + traces::{node::CallTraceNode, CallTraceArena}, utils::{eval_to_instruction_result, halt_to_instruction_result}, }; use foundry_utils::types::{ToAlloy, ToEthers}; diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index ade5ac6f5c79e..157f7b104e350 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -10,11 +10,11 @@ use ethers::{ types::{Address, H256}, }; use foundry_evm::{ - executor::{ - backend::{snapshot::StateSnapshot, DatabaseError, DatabaseResult}, - DatabaseRef, + backend::{DatabaseError, DatabaseResult, StateSnapshot}, + revm::{ + db::DatabaseRef, + primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }, - revm::primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }; use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::Mutex; diff --git a/crates/anvil/src/eth/backend/mem/cache.rs b/crates/anvil/src/eth/backend/mem/cache.rs index 0703cb78fb5ec..362770af3b391 100644 --- a/crates/anvil/src/eth/backend/mem/cache.rs +++ b/crates/anvil/src/eth/backend/mem/cache.rs @@ -1,6 +1,6 @@ use crate::config::anvil_tmp_dir; use ethers::prelude::H256; -use foundry_evm::executor::backend::snapshot::StateSnapshot; +use foundry_evm::backend::StateSnapshot; use std::{ io, path::{Path, PathBuf}, diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 8039442a4286b..2c84f22599a5a 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -7,16 +7,15 @@ use crate::{ Address, U256, }; use ethers::{prelude::H256, types::BlockId}; -pub use foundry_evm::executor::fork::database::ForkedDatabase; use foundry_evm::{ - executor::{ - backend::{snapshot::StateSnapshot, DatabaseResult}, - fork::{database::ForkDbSnapshot, BlockchainDb}, - }, + backend::{DatabaseResult, StateSnapshot}, + fork::{database::ForkDbSnapshot, BlockchainDb}, revm::Database, }; use foundry_utils::types::{ToAlloy, ToEthers}; +pub use foundry_evm::fork::database::ForkedDatabase; + /// Implement the helper for the fork database impl Db for ForkedDatabase { fn insert_account(&mut self, address: Address, account: AccountInfo) { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index ebba405fc806c..47ccccdb72755 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -5,21 +5,20 @@ use crate::{ AsHashDB, Db, MaybeForkedDatabase, MaybeHashDatabase, SerializableAccountRecord, SerializableState, StateDb, }, - mem::state::{state_merkle_trie_root, trie_hash_db}, + mem::state::{state_merkle_trie_root, storage_trie_db, trie_hash_db}, revm::primitives::AccountInfo, Address, U256, }; use ethers::{prelude::H256, types::BlockId}; +use foundry_evm::{ + backend::{DatabaseResult, StateSnapshot}, + fork::BlockchainDb, +}; use foundry_utils::types::{ToAlloy, ToEthers}; use tracing::{trace, warn}; // reexport for convenience -use crate::mem::state::storage_trie_db; -pub use foundry_evm::executor::{backend::MemDb, DatabaseRef}; -use foundry_evm::executor::{ - backend::{snapshot::StateSnapshot, DatabaseResult}, - fork::BlockchainDb, -}; +pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; impl Db for MemDb { fn insert_account(&mut self, address: Address, account: AccountInfo) { @@ -135,6 +134,7 @@ impl MaybeForkedDatabase for MemDb { #[cfg(test)] mod tests { + use super::*; use crate::{ eth::backend::db::{Db, SerializableAccountRecord, SerializableState}, revm::primitives::AccountInfo, @@ -143,7 +143,7 @@ mod tests { use alloy_primitives::{Bytes, U256 as rU256}; use ethers::types::U256; use foundry_evm::{ - executor::{backend::MemDb, DatabaseRef}, + backend::MemDb, revm::primitives::{Bytecode, KECCAK_EMPTY}, }; use foundry_utils::types::ToAlloy; diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index ee46ea101d14c..a4e2d0d94f4db 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -5,7 +5,7 @@ use ethers::types::Log; use foundry_evm::{ call_inspectors, decode::decode_console_logs, - executor::inspector::{LogCollector, Tracer}, + inspectors::{LogCollector, Tracer}, revm, revm::{ interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0fe9bd9003c50..8ecbc4cb44a5f 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -58,12 +58,10 @@ use ethers::{ use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_common::abi::format_token; use foundry_evm::{ + backend::{DatabaseError, DatabaseResult}, + constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, decode::{decode_custom_error_args, decode_revert}, - executor::{ - backend::{DatabaseError, DatabaseResult}, - inspector::AccessListTracer, - DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, - }, + inspectors::AccessListTracer, revm::{ self, db::CacheDB, @@ -103,7 +101,8 @@ pub const MIN_TRANSACTION_GAS: U256 = U256([21_000, 0, 0, 0]); // Gas per transaction creating a contract. pub const MIN_CREATE_GAS: U256 = U256([53_000, 0, 0, 0]); -pub type State = foundry_evm::HashMap; +// TODO: This is the same as foundry_evm::utils::StateChangeset but with ethers H160 +pub type State = foundry_evm::hashbrown::HashMap; /// A block request, which includes the Pool Transactions if it's Pending #[derive(Debug)] diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index c0d5271ab85bd..036dc672651df 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -8,12 +8,12 @@ use ethers::{ utils::{rlp, rlp::RlpStream}, }; use foundry_evm::{ - executor::{backend::DatabaseError, DatabaseRef}, + backend::DatabaseError, + hashbrown::HashMap as Map, revm::{ - db::{CacheDB, DbAccount}, + db::{CacheDB, DatabaseRef, DbAccount}, primitives::{AccountInfo, Bytecode, Log}, }, - HashMap as Map, }; use foundry_utils::types::{ToAlloy, ToEthers}; use memory_db::HashKey; diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 7da581aba46b2..236b76f5f043b 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -442,7 +442,7 @@ mod tests { use crate::eth::backend::db::Db; use ethers::{abi::ethereum_types::BigEndianHash, types::Address}; use foundry_evm::{ - executor::backend::MemDb, + backend::MemDb, revm::{ db::DatabaseRef, primitives::{AccountInfo, U256 as rU256}, diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 3fa9e6c732d35..1ecd4191a0e1d 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -13,7 +13,7 @@ use ethers::{ }; use foundry_common::SELECTOR_LEN; use foundry_evm::{ - executor::backend::DatabaseError, + backend::DatabaseError, revm::{ self, interpreter::InstructionResult, diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 5b1e54679a4fc..97acabb1df36a 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -405,7 +405,7 @@ impl FeeDetails { } impl fmt::Debug for FeeDetails { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "Fees {{ ")?; write!(fmt, "gaPrice: {:?}, ", self.gas_price)?; write!(fmt, "max_fee_per_gas: {:?}, ", self.max_fee_per_gas)?; diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index bd2567d749a56..3f49d0df1ce87 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -2,7 +2,7 @@ use alloy_primitives::U256 as rU256; use ethers::types::{ Action, Address, Block, Bytes, CallType, Trace, Transaction, TransactionReceipt, H256, U256, }; -use foundry_evm::{executor::InstructionResult, CallKind}; +use foundry_evm::{revm::interpreter::InstructionResult, utils::CallKind}; use foundry_utils::types::ToEthers; use futures::future::join_all; use serde::{de::DeserializeOwned, Serialize}; diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index ee43d8556eda8..842015837d71e 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -358,7 +358,7 @@ pub struct PruneResult { } impl fmt::Debug for PruneResult { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "PruneResult {{ ")?; write!( fmt, diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 39b0d1cc1fe13..d0c0337c6b0f2 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -99,7 +99,7 @@ impl PoolTransaction { } impl fmt::Debug for PoolTransaction { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "Transaction {{ ")?; write!(fmt, "hash: {:?}, ", &self.pending_transaction.hash())?; write!(fmt, "requires: [{}], ", hex_fmt_many(self.requires.iter()))?; @@ -283,7 +283,7 @@ impl PendingPoolTransaction { } impl fmt::Debug for PendingPoolTransaction { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "PendingTransaction {{ ")?; write!(fmt, "added_at: {:?}, ", self.added_at)?; write!(fmt, "tx: {:?}, ", self.transaction)?; diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 078971c577884..5fdf3dc6ae1c4 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -31,7 +31,7 @@ impl<'a> HexDisplay<'a> { } impl<'a> fmt::Display for HexDisplay<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.0.len() < 1027 { for byte in self.0 { f.write_fmt(format_args!("{byte:02x}"))?; @@ -50,7 +50,7 @@ impl<'a> fmt::Display for HexDisplay<'a> { } impl<'a> fmt::Debug for HexDisplay<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for byte in self.0 { f.write_fmt(format_args!("{byte:02x}"))?; } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 30c8fa4c20f88..5696937c2be6d 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -10,7 +10,7 @@ use foundry_cli::{ use foundry_common::runtime_client::RuntimeClient; use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; -use foundry_evm::{executor::opts::EvmOpts, trace::TracingExecutor}; +use foundry_evm::{executors::TracingExecutor, opts::EvmOpts}; use foundry_utils::types::{ToAlloy, ToEthers}; use std::str::FromStr; @@ -151,7 +151,7 @@ impl CallArgs { TracingExecutor::get_fork_material(&config, evm_opts).await?; let mut executor = - foundry_evm::trace::TracingExecutor::new(env, fork, evm_version, debug) + foundry_evm::executors::TracingExecutor::new(env, fork, evm_version, debug) .await; let trace = match executor.deploy( @@ -186,7 +186,7 @@ impl CallArgs { TracingExecutor::get_fork_material(&config, evm_opts).await?; let mut executor = - foundry_evm::trace::TracingExecutor::new(env, fork, evm_version, debug) + foundry_evm::executors::TracingExecutor::new(env, fork, evm_version, debug) .await; let (tx, _) = builder.build(); diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 2ba8016ff1250..b360267e04bb2 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,3 +1,4 @@ +use alloy_primitives::U256; use clap::Parser; use ethers::prelude::Middleware; use eyre::{Result, WrapErr}; @@ -11,9 +12,9 @@ use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{ - executor::{inspector::cheatcodes::util::configure_tx_env, opts::EvmOpts, EvmError}, - revm::primitives::U256 as rU256, - trace::TracingExecutor, + executors::{EvmError, TracingExecutor}, + opts::EvmOpts, + utils::configure_tx_env, }; use foundry_utils::types::ToAlloy; use tracing::trace; @@ -121,7 +122,7 @@ impl RunArgs { let mut executor = TracingExecutor::new(env.clone(), fork, self.evm_version, self.debug).await; - env.block.number = rU256::from(tx_block_number); + env.block.number = U256::from(tx_block_number); let block = provider.get_block_with_txs(tx_block_number).await?; if let Some(ref block) = block { diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 51f9930786e78..21314dafd8496 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -26,7 +26,7 @@ foundry-common.workspace = true foundry-utils.workspace = true forge-fmt.workspace = true -foundry-compilers = { workspace = true, default-features = false, features = ["project-util", "full"]} +foundry-compilers = { workspace = true, features = ["project-util", "full"] } # ethers ethers.workspace = true diff --git a/crates/chisel/benches/session_source.rs b/crates/chisel/benches/session_source.rs index 784de2c4b03df..3088c3efe41ff 100644 --- a/crates/chisel/benches/session_source.rs +++ b/crates/chisel/benches/session_source.rs @@ -2,7 +2,7 @@ use chisel::session_source::{SessionSource, SessionSourceConfig}; use criterion::{criterion_group, Criterion}; use foundry_compilers::Solc; use foundry_config::Config; -use foundry_evm::executor::opts::EvmOpts; +use foundry_evm::opts::EvmOpts; use once_cell::sync::Lazy; use std::hint::black_box; use tokio::runtime::Runtime; diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index db8950ca1323d..927cc2e2f6089 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -13,7 +13,7 @@ use forge_fmt::FormatterConfig; use foundry_config::{Config, RpcEndpoint}; use foundry_evm::{ decode::decode_console_logs, - trace::{ + traces::{ identifier::{EtherscanIdentifier, SignaturesIdentifier}, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 5979743bcbc50..c03e0147c2803 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -12,8 +12,8 @@ use core::fmt::Debug; use eyre::{Result, WrapErr}; use foundry_compilers::Artifact; use foundry_evm::{ - decode::decode_console_logs, - executor::{inspector::CheatsConfig, Backend, ExecutorBuilder}, + backend::Backend, decode::decode_console_logs, executors::ExecutorBuilder, + inspectors::CheatsConfig, }; use foundry_utils::types::ToEthers; use solang_parser::pt::{self, CodeLocation}; diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 043cde85c7bc3..cb0ed68452512 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -7,8 +7,8 @@ use alloy_primitives::{Address, Bytes, U256}; use ethers::types::Log; use eyre::Result; use foundry_evm::{ - executor::{DeployResult, Executor, RawCallResult}, - trace::{CallTraceArena, TraceKind}, + executors::{DeployResult, Executor, RawCallResult}, + traces::{CallTraceArena, TraceKind}, }; use revm::interpreter::{return_ok, InstructionResult}; use std::collections::BTreeMap; diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 5fbb0a1e104a8..d9de02a147cb6 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -11,7 +11,7 @@ use foundry_compilers::{ CompilerInput, CompilerOutput, EvmVersion, Solc, }; use foundry_config::{Config, SolcReq}; -use foundry_evm::executor::{opts::EvmOpts, Backend}; +use foundry_evm::{backend::Backend, opts::EvmOpts}; use semver::Version; use serde::{Deserialize, Serialize}; use solang_parser::pt; diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index 7ea13c64de986..dda53cd62382c 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -1,7 +1,7 @@ use chisel::session::ChiselSession; use foundry_compilers::EvmVersion; use foundry_config::Config; -use foundry_evm::executor::opts::EvmOpts; +use foundry_evm::opts::EvmOpts; use serial_test::serial; use std::path::Path; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index d0b253499d9fc..f0f314edd3f2c 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -17,7 +17,7 @@ foundry-evm.workspace = true foundry-debugger.workspace = true foundry-utils.workspace = true -foundry-compilers = { workspace = true, default-features = false, features = ["full"] } +foundry-compilers = { workspace = true, features = ["full"] } # aws rusoto_core = { version = "0.48", default-features = false } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index e43c0e2968608..f9b33604aa464 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -14,8 +14,9 @@ use foundry_config::{error::ExtractConfigError, figment::Figment, Chain as Confi use foundry_debugger::DebuggerArgs; use foundry_evm::{ debug::DebugArena, - executor::{opts::EvmOpts, DeployResult, EvmError, ExecutionErr, RawCallResult}, - trace::{ + executors::{DeployResult, EvmError, ExecutionErr, RawCallResult}, + opts::EvmOpts, + traces::{ identifier::{EtherscanIdentifier, SignaturesIdentifier}, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index e2ab1df43f31c..f12289aaa459b 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -24,7 +24,8 @@ foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -foundry-compilers = { workspace = true, default-features = false } +foundry-compilers.workspace = true + # io reqwest = { version = "0.11", default-features = false } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index a08287beac1d2..a990035244d33 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -203,7 +203,7 @@ impl SizeReport { } impl Display for SizeReport { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); table.set_header(vec![ diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index eb59780194b0f..e65556bd5f24a 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,6 +1,6 @@ use crate::{TUIExitReason, Tui, Ui}; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm::{debug::DebugArena, trace::CallTraceDecoder}; +use foundry_evm::{debug::DebugArena, traces::CallTraceDecoder}; use tracing::{error, trace}; /// Standardized way of firing up the debugger diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 7fc74325dcb7f..c6f645e8a2c07 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -13,8 +13,7 @@ use eyre::Result; use foundry_common::{compile::ContractSources, evm::Breakpoints}; use foundry_evm::{ debug::{DebugStep, Instruction}, - utils::{build_pc_ic_map, PCICMap}, - CallKind, + utils::{build_pc_ic_map, CallKind, PCICMap}, }; use ratatui::{ backend::{Backend, CrosstermBackend}, diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index fb5f8dcc14f1b..cb0db0d18bfdc 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -16,11 +16,11 @@ forge-fmt.workspace = true foundry-config.workspace = true foundry-utils.workspace = true +foundry-compilers = { workspace = true, features = ["async"] } + # ethers ethers-core.workspace = true -foundry-compilers = { workspace = true, features = ["async"] } - # tracing tracing.workspace = true diff --git a/crates/evm/Cargo.toml b/crates/evm/core/Cargo.toml similarity index 57% rename from crates/evm/Cargo.toml rename to crates/evm/core/Cargo.toml index 8fcdce59e0d85..65d9b268f7706 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -1,5 +1,6 @@ [package] -name = "foundry-evm" +name = "foundry-evm-core" +description = "Core EVM abstractions" version.workspace = true edition.workspace = true @@ -11,21 +12,31 @@ repository.workspace = true [dependencies] foundry-abi.workspace = true -foundry-utils.workspace = true foundry-common.workspace = true +foundry-compilers.workspace = true foundry-config.workspace = true -foundry-macros.workspace = true - -ethers = { workspace = true, features = ["ethers-solc"]} +foundry-utils.workspace = true -foundry-compilers = { workspace = true, default-features = false } -foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } +# EVM +revm = { workspace = true, default-features = false, features = [ + "std", + "serde", + "memory_limit", + "optional_eip3607", + "optional_block_gas_limit", + "optional_no_base_fee", + "arbitrary", +] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-json-abi = { workspace = true } +alloy-sol-types.workspace = true +ethers = { workspace = true, features = ["ethers-solc"] } # Encoding/decoding serde_json = "1" serde = "1" hex.workspace = true -jsonpath_lib = "0.3" # Error handling eyre = "0.6" @@ -40,41 +51,7 @@ parking_lot = "0.12" futures = "0.3" once_cell = "1" -# EVM -bytes = "1" -hashbrown = { version = "0.14", features = ["serde"] } -revm = { workspace = true, default-features = false, features = [ - "std", - "serde", - "memory_limit", - "optional_eip3607", - "optional_block_gas_limit", - "optional_no_base_fee", - "arbitrary", -] } -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } -alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } -alloy-json-abi = { workspace = true } -alloy-sol-types.workspace = true -arbitrary = "1.3.1" - -# Fuzzer -proptest = "1" - -# Display -yansi = "0.5" - # Misc url = "2" auto_impl = "1" itertools.workspace = true -ordered-float = "4" -walkdir = "2" - -# Coverage -semver = "1" - -[dev-dependencies] -ethers = { workspace = true, features = ["ethers-solc", "rustls"] } -foundry-utils.workspace = true -tempfile = "3" diff --git a/crates/evm/core/src/abi/mod.rs b/crates/evm/core/src/abi/mod.rs new file mode 100644 index 0000000000000..7cbe79e27693e --- /dev/null +++ b/crates/evm/core/src/abi/mod.rs @@ -0,0 +1,555 @@ +//! Several ABI-related utilities for executors. + +pub use foundry_abi::{ + console::{self, ConsoleEvents, CONSOLE_ABI}, + hardhat_console::{self, HardhatConsoleCalls, HARDHATCONSOLE_ABI as HARDHAT_CONSOLE_ABI}, + hevm::{self, HEVMCalls, HEVM_ABI}, +}; +use once_cell::sync::Lazy; +use std::collections::HashMap; + +/// If the input starts with a known `hardhat/console.log` `uint` selector, then this will replace +/// it with the selector `abigen!` bindings expect. +pub fn patch_hardhat_console_selector(input: &mut Vec) { + if input.len() < 4 { + return + } + let selector = unsafe { &mut *(input.get_unchecked_mut(..4) as *mut [u8] as *mut [u8; 4]) }; + if let Some(abigen_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { + *selector = *abigen_selector; + } +} + +/// This contains a map with all the `hardhat/console.log` log selectors that use `uint` or `int` +/// as key and the selector of the call with `uint256`, +/// +/// This is a bit terrible but a workaround for the differing selectors used by hardhat and the call +/// bindings which `abigen!` creates. `hardhat/console.log` logs its events in functions that accept +/// `uint` manually as `abi.encodeWithSignature("log(int)", p0)`, but `abigen!` uses `uint256` for +/// its call bindings (`HardhatConsoleCalls`) as generated by solc. +pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { + HashMap::from([ + // log(bool,uint256,uint256,address) + ([241, 97, 178, 33], [0, 221, 135, 185]), + // log(uint256,address,address,string) + ([121, 67, 220, 102], [3, 28, 111, 115]), + // log(uint256,bool,address,uint256) + ([65, 181, 239, 59], [7, 130, 135, 245]), + // log(bool,address,bool,uint256) + ([76, 182, 15, 209], [7, 131, 21, 2]), + // log(bool,uint256,address) + ([196, 210, 53, 7], [8, 142, 249, 210]), + // log(uint256,address,address,bool) + ([1, 85, 11, 4], [9, 31, 250, 245]), + // log(address,bool,uint256,string) + ([155, 88, 142, 204], [10, 166, 207, 173]), + // log(bool,bool,uint256,uint256) + ([70, 103, 222, 142], [11, 176, 14, 171]), + // log(bool,address,address,uint256) + ([82, 132, 189, 108], [12, 102, 209, 190]), + // log(uint256,address,uint256,uint256) + ([202, 154, 62, 180], [12, 156, 217, 193]), + // log(string,address,uint256) + ([7, 200, 18, 23], [13, 38, 185, 37]), + // log(address,string,uint256,bool) + ([126, 37, 13, 91], [14, 247, 224, 80]), + // log(address,uint256,address,uint256) + ([165, 217, 135, 104], [16, 15, 101, 14]), + // log(string,string,uint256,address) + ([93, 79, 70, 128], [16, 35, 247, 178]), + // log(bool,string,uint256) + ([192, 56, 42, 172], [16, 147, 238, 17]), + // log(bool,bool,uint256) + ([176, 19, 101, 187], [18, 242, 22, 2]), + // log(bool,address,uint256,address) + ([104, 241, 88, 181], [19, 107, 5, 221]), + // log(bool,uint256,address,uint256) + ([202, 165, 35, 106], [21, 55, 220, 135]), + // log(bool,string,uint256,address) + ([91, 34, 185, 56], [21, 150, 161, 206]), + // log(address,string,string,uint256) + ([161, 79, 208, 57], [21, 159, 137, 39]), + // log(uint256,address,uint256,address) + ([253, 178, 236, 212], [21, 193, 39, 181]), + // log(uint256,uint256,address,bool) + ([168, 232, 32, 174], [21, 202, 196, 118]), + // log(bool,string,bool,uint256) + ([141, 111, 156, 165], [22, 6, 163, 147]), + // log(address,address,uint256) + ([108, 54, 109, 114], [23, 254, 97, 133]), + // log(uint256,uint256,uint256,uint256) + ([92, 160, 173, 62], [25, 63, 184, 0]), + // log(bool,string,uint256,string) + ([119, 161, 171, 237], [26, 217, 109, 230]), + // log(bool,uint256,address,string) + ([24, 9, 19, 65], [27, 179, 176, 154]), + // log(string,uint256,address) + ([227, 132, 159, 121], [28, 126, 196, 72]), + // log(uint256,bool) + ([30, 109, 212, 236], [28, 157, 126, 179]), + // log(address,uint256,address,string) + ([93, 113, 243, 158], [29, 169, 134, 234]), + // log(address,string,uint256,uint256) + ([164, 201, 42, 96], [29, 200, 225, 184]), + // log(uint256,bool,uint256) + ([90, 77, 153, 34], [32, 9, 128, 20]), + // log(uint256,bool,bool) + ([213, 206, 172, 224], [32, 113, 134, 80]), + // log(address,uint256,uint256,address) + ([30, 246, 52, 52], [32, 227, 152, 77]), + // log(uint256,string,string,string) + ([87, 221, 10, 17], [33, 173, 6, 131]), + // log(address,uint256,bool,uint256) + ([105, 143, 67, 146], [34, 246, 185, 153]), + // log(uint256,address,address,address) + ([85, 71, 69, 249], [36, 136, 180, 20]), + // log(string,bool,string,uint256) + ([52, 203, 48, 141], [36, 249, 20, 101]), + // log(bool,uint256,address,address) + ([138, 47, 144, 170], [38, 245, 96, 168]), + // log(uint256,uint256,string,string) + ([124, 3, 42, 50], [39, 216, 175, 210]), + // log(bool,string,uint256,uint256) + ([142, 74, 232, 110], [40, 134, 63, 203]), + // log(uint256,bool,string,uint256) + ([145, 95, 219, 40], [44, 29, 7, 70]), + // log(address,uint256,uint256,uint256) + ([61, 14, 157, 228], [52, 240, 230, 54]), + // log(uint256,bool,address) + ([66, 78, 255, 191], [53, 8, 95, 123]), + // log(string,uint256,bool,bool) + ([227, 127, 243, 208], [53, 76, 54, 214]), + // log(bool,uint256,uint256) + ([59, 92, 3, 224], [55, 16, 51, 103]), + // log(bool,uint256,uint256,uint256) + ([50, 223, 165, 36], [55, 75, 180, 178]), + // log(uint256,string,uint256) + ([91, 109, 232, 63], [55, 170, 125, 76]), + // log(address,bool,uint256,uint256) + ([194, 16, 160, 30], [56, 111, 245, 244]), + // log(address,address,bool,uint256) + ([149, 214, 95, 17], [57, 113, 231, 140]), + // log(bool,uint256) + ([54, 75, 106, 146], [57, 145, 116, 211]), + // log(uint256,string,uint256,address) + ([171, 123, 217, 253], [59, 34, 121, 180]), + // log(address,uint256,bool,bool) + ([254, 161, 213, 90], [59, 245, 229, 55]), + // log(uint256,address,string,string) + ([141, 119, 134, 36], [62, 18, 140, 163]), + // log(string,address,bool,uint256) + ([197, 209, 187, 139], [62, 159, 134, 106]), + // log(uint256,uint256,string,address) + ([67, 50, 133, 162], [66, 210, 29, 183]), + // log(address,string,uint256,string) + ([93, 19, 101, 201], [68, 136, 48, 168]), + // log(uint256,bool,address,bool) + ([145, 251, 18, 66], [69, 77, 84, 165]), + // log(address,string,address,uint256) + ([140, 25, 51, 169], [69, 127, 227, 207]), + // log(uint256,address,string,uint256) + ([160, 196, 20, 232], [70, 130, 107, 93]), + // log(uint256,uint256,bool) + ([103, 87, 15, 247], [71, 102, 218, 114]), + // log(address,uint256,address,address) + ([236, 36, 132, 111], [71, 141, 28, 98]), + // log(address,uint256,uint256,string) + ([137, 52, 13, 171], [74, 40, 192, 23]), + // log(bool,bool,address,uint256) + ([96, 147, 134, 231], [76, 18, 61, 87]), + // log(uint256,string,bool) + ([70, 167, 208, 206], [76, 237, 167, 90]), + // log(string,uint256,address,uint256) + ([88, 73, 122, 254], [79, 4, 253, 198]), + // log(address,string,bool,uint256) + ([231, 32, 82, 28], [81, 94, 56, 182]), + // log(bool,address,uint256,string) + ([160, 104, 88, 51], [81, 240, 159, 248]), + // log(bool,bool,uint256,address) + ([11, 255, 149, 13], [84, 167, 169, 160]), + // log(uint256,uint256,address,address) + ([202, 147, 155, 32], [86, 165, 209, 177]), + // log(string,string,uint256) + ([243, 98, 202, 89], [88, 33, 239, 161]), + // log(string,uint256,string) + ([163, 245, 199, 57], [89, 112, 224, 137]), + // log(uint256,uint256,uint256,string) + ([120, 173, 122, 12], [89, 207, 203, 227]), + // log(string,address,uint256,string) + ([76, 85, 242, 52], [90, 71, 118, 50]), + // log(uint256,address,uint256) + ([136, 67, 67, 170], [90, 155, 94, 213]), + // log(string,uint256,string,string) + ([108, 152, 218, 226], [90, 184, 78, 31]), + // log(uint256,address,bool,uint256) + ([123, 8, 232, 235], [90, 189, 153, 42]), + // log(address,uint256,string,address) + ([220, 121, 38, 4], [92, 67, 13, 71]), + // log(uint256,uint256,address) + ([190, 51, 73, 27], [92, 150, 179, 49]), + // log(string,bool,address,uint256) + ([40, 223, 78, 150], [93, 8, 187, 5]), + // log(string,string,uint256,string) + ([141, 20, 44, 221], [93, 26, 151, 26]), + // log(uint256,uint256,string,uint256) + ([56, 148, 22, 61], [93, 162, 151, 235]), + // log(string,uint256,address,address) + ([234, 200, 146, 129], [94, 162, 183, 174]), + // log(uint256,address,uint256,bool) + ([25, 246, 115, 105], [95, 116, 58, 124]), + // log(bool,address,uint256) + ([235, 112, 75, 175], [95, 123, 154, 251]), + // log(uint256,string,address,address) + ([127, 165, 69, 139], [97, 104, 237, 97]), + // log(bool,bool,uint256,bool) + ([171, 92, 193, 196], [97, 158, 77, 14]), + // log(address,string,uint256,address) + ([223, 215, 216, 11], [99, 24, 54, 120]), + // log(uint256,address,string) + ([206, 131, 4, 123], [99, 203, 65, 249]), + // log(string,address,uint256,address) + ([163, 102, 236, 128], [99, 251, 139, 197]), + // log(uint256,string) + ([15, 163, 243, 69], [100, 63, 208, 223]), + // log(string,bool,uint256,uint256) + ([93, 191, 240, 56], [100, 181, 187, 103]), + // log(address,uint256,uint256,bool) + ([236, 75, 168, 162], [102, 241, 188, 103]), + // log(address,uint256,bool) + ([229, 74, 225, 68], [103, 130, 9, 168]), + // log(address,string,uint256) + ([28, 218, 242, 138], [103, 221, 111, 241]), + // log(uint256,bool,string,string) + ([164, 51, 252, 253], [104, 200, 184, 189]), + // log(uint256,string,uint256,bool) + ([135, 90, 110, 46], [105, 26, 143, 116]), + // log(uint256,address) + ([88, 235, 134, 12], [105, 39, 108, 134]), + // log(uint256,bool,bool,address) + ([83, 6, 34, 93], [105, 100, 11, 89]), + // log(bool,uint256,string,uint256) + ([65, 128, 1, 27], [106, 17, 153, 226]), + // log(bool,string,uint256,bool) + ([32, 187, 201, 175], [107, 14, 93, 83]), + // log(uint256,uint256,address,string) + ([214, 162, 209, 222], [108, 222, 64, 184]), + // log(bool,bool,bool,uint256) + ([194, 72, 131, 77], [109, 112, 69, 193]), + // log(uint256,uint256,string) + ([125, 105, 14, 230], [113, 208, 74, 242]), + // log(uint256,address,address,uint256) + ([154, 60, 191, 150], [115, 110, 251, 182]), + // log(string,bool,uint256,string) + ([66, 185, 162, 39], [116, 45, 110, 231]), + // log(uint256,bool,bool,uint256) + ([189, 37, 173, 89], [116, 100, 206, 35]), + // log(string,uint256,uint256,bool) + ([247, 60, 126, 61], [118, 38, 219, 146]), + // log(uint256,uint256,string,bool) + ([178, 46, 175, 6], [122, 246, 171, 37]), + // log(uint256,string,address) + ([31, 144, 242, 74], [122, 250, 201, 89]), + // log(address,uint256,address) + ([151, 236, 163, 148], [123, 192, 216, 72]), + // log(bool,string,string,uint256) + ([93, 219, 37, 146], [123, 224, 195, 235]), + // log(bool,address,uint256,uint256) + ([155, 254, 114, 188], [123, 241, 129, 161]), + // log(string,uint256,string,address) + ([187, 114, 53, 233], [124, 70, 50, 164]), + // log(string,string,address,uint256) + ([74, 129, 165, 106], [124, 195, 198, 7]), + // log(string,uint256,string,bool) + ([233, 159, 130, 207], [125, 36, 73, 29]), + // log(bool,bool,uint256,string) + ([80, 97, 137, 55], [125, 212, 208, 224]), + // log(bool,uint256,bool,uint256) + ([211, 222, 85, 147], [127, 155, 188, 162]), + // log(address,bool,string,uint256) + ([158, 18, 123, 110], [128, 230, 162, 11]), + // log(string,uint256,address,bool) + ([17, 6, 168, 247], [130, 17, 42, 66]), + // log(uint256,string,uint256,uint256) + ([192, 4, 56, 7], [130, 194, 91, 116]), + // log(address,uint256) + ([34, 67, 207, 163], [131, 9, 232, 168]), + // log(string,uint256,uint256,string) + ([165, 78, 212, 189], [133, 75, 52, 150]), + // log(uint256,bool,string) + ([139, 14, 20, 254], [133, 119, 80, 33]), + // log(address,uint256,string,string) + ([126, 86, 198, 147], [136, 168, 196, 6]), + // log(uint256,bool,uint256,address) + ([79, 64, 5, 142], [136, 203, 96, 65]), + // log(uint256,uint256,address,uint256) + ([97, 11, 168, 192], [136, 246, 228, 178]), + // log(string,bool,uint256,bool) + ([60, 197, 181, 211], [138, 247, 207, 138]), + // log(address,bool,bool,uint256) + ([207, 181, 135, 86], [140, 78, 93, 230]), + // log(address,address,uint256,address) + ([214, 198, 82, 118], [141, 166, 222, 245]), + // log(string,bool,bool,uint256) + ([128, 117, 49, 232], [142, 63, 120, 169]), + // log(bool,uint256,uint256,string) + ([218, 6, 102, 200], [142, 105, 251, 93]), + // log(string,string,string,uint256) + ([159, 208, 9, 245], [142, 175, 176, 43]), + // log(string,address,address,uint256) + ([110, 183, 148, 61], [142, 243, 243, 153]), + // log(uint256,string,address,bool) + ([249, 63, 255, 55], [144, 195, 10, 86]), + // log(uint256,address,bool,string) + ([99, 240, 226, 66], [144, 251, 6, 170]), + // log(bool,uint256,bool,string) + ([182, 213, 105, 212], [145, 67, 219, 177]), + // log(uint256,bool,uint256,bool) + ([210, 171, 196, 253], [145, 160, 46, 42]), + // log(string,address,string,uint256) + ([143, 98, 75, 233], [145, 209, 17, 46]), + // log(string,bool,uint256,address) + ([113, 211, 133, 13], [147, 94, 9, 191]), + // log(address,address,address,uint256) + ([237, 94, 172, 135], [148, 37, 13, 119]), + // log(uint256,uint256,bool,address) + ([225, 23, 116, 79], [154, 129, 106, 131]), + // log(bool,uint256,bool,address) + ([66, 103, 199, 248], [154, 205, 54, 22]), + // log(address,address,uint256,bool) + ([194, 246, 136, 236], [155, 66, 84, 226]), + // log(uint256,address,bool) + ([122, 208, 18, 142], [155, 110, 192, 66]), + // log(uint256,string,address,string) + ([248, 152, 87, 127], [156, 58, 223, 161]), + // log(address,bool,uint256) + ([44, 70, 141, 21], [156, 79, 153, 251]), + // log(uint256,address,string,address) + ([203, 229, 142, 253], [156, 186, 143, 255]), + // log(string,uint256,address,string) + ([50, 84, 194, 232], [159, 251, 47, 147]), + // log(address,uint256,address,bool) + ([241, 129, 161, 233], [161, 188, 201, 179]), + // log(uint256,bool,address,address) + ([134, 237, 193, 12], [161, 239, 76, 187]), + // log(address,uint256,string) + ([186, 249, 104, 73], [161, 242, 232, 170]), + // log(address,uint256,bool,address) + ([35, 229, 73, 114], [163, 27, 253, 204]), + // log(uint256,uint256,bool,string) + ([239, 217, 203, 238], [165, 180, 252, 153]), + // log(bool,string,address,uint256) + ([27, 11, 149, 91], [165, 202, 218, 148]), + // log(address,bool,address,uint256) + ([220, 113, 22, 210], [167, 92, 89, 222]), + // log(string,uint256,uint256,uint256) + ([8, 238, 86, 102], [167, 168, 120, 83]), + // log(uint256,uint256,bool,bool) + ([148, 190, 59, 177], [171, 8, 90, 230]), + // log(string,uint256,bool,string) + ([118, 204, 96, 100], [171, 247, 58, 152]), + // log(uint256,bool,address,string) + ([162, 48, 118, 30], [173, 224, 82, 199]), + // log(uint256,string,bool,address) + ([121, 111, 40, 160], [174, 46, 197, 129]), + // log(uint256,string,string,uint256) + ([118, 236, 99, 94], [176, 40, 201, 189]), + // log(uint256,string,string) + ([63, 87, 194, 149], [177, 21, 97, 31]), + // log(uint256,string,string,bool) + ([18, 134, 43, 152], [179, 166, 182, 189]), + // log(bool,uint256,address,bool) + ([101, 173, 244, 8], [180, 195, 20, 255]), + // log(string,uint256) + ([151, 16, 169, 208], [182, 14, 114, 204]), + // log(address,uint256,uint256) + ([135, 134, 19, 94], [182, 155, 202, 246]), + // log(uint256,bool,bool,bool) + ([78, 108, 83, 21], [182, 245, 119, 161]), + // log(uint256,string,uint256,string) + ([162, 188, 12, 153], [183, 185, 20, 202]), + // log(uint256,string,bool,bool) + ([81, 188, 43, 193], [186, 83, 93, 156]), + // log(uint256,address,address) + ([125, 119, 166, 27], [188, 253, 155, 224]), + // log(address,address,uint256,uint256) + ([84, 253, 243, 228], [190, 85, 52, 129]), + // log(bool,uint256,uint256,bool) + ([164, 29, 129, 222], [190, 152, 67, 83]), + // log(address,uint256,string,uint256) + ([245, 18, 207, 155], [191, 1, 248, 145]), + // log(bool,address,string,uint256) + ([11, 153, 252, 34], [194, 31, 100, 199]), + // log(string,string,uint256,bool) + ([230, 86, 88, 202], [195, 168, 166, 84]), + // log(bool,uint256,string) + ([200, 57, 126, 176], [195, 252, 57, 112]), + // log(address,bool,uint256,bool) + ([133, 205, 197, 175], [196, 100, 62, 32]), + // log(uint256,uint256,uint256,bool) + ([100, 82, 185, 203], [197, 152, 209, 133]), + // log(address,uint256,bool,string) + ([142, 142, 78, 117], [197, 173, 133, 249]), + // log(string,uint256,string,uint256) + ([160, 196, 178, 37], [198, 126, 169, 209]), + // log(uint256,bool,uint256,uint256) + ([86, 130, 141, 164], [198, 172, 199, 168]), + // log(string,bool,uint256) + ([41, 27, 185, 208], [201, 89, 88, 214]), + // log(string,uint256,uint256) + ([150, 156, 221, 3], [202, 71, 196, 235]), + // log(string,uint256,bool) + ([241, 2, 238, 5], [202, 119, 51, 177]), + // log(uint256,address,string,bool) + ([34, 164, 121, 166], [204, 50, 171, 7]), + // log(address,bool,uint256,address) + ([13, 140, 230, 30], [204, 247, 144, 161]), + // log(bool,uint256,bool,bool) + ([158, 1, 247, 65], [206, 181, 244, 215]), + // log(uint256,string,bool,uint256) + ([164, 180, 138, 127], [207, 0, 152, 128]), + // log(address,uint256,string,bool) + ([164, 2, 79, 17], [207, 24, 16, 92]), + // log(uint256,uint256,uint256) + ([231, 130, 10, 116], [209, 237, 122, 60]), + // log(uint256,string,bool,string) + ([141, 72, 156, 160], [210, 212, 35, 205]), + // log(uint256,string,string,address) + ([204, 152, 138, 160], [213, 131, 198, 2]), + // log(bool,address,uint256,bool) + ([238, 141, 134, 114], [214, 1, 159, 28]), + // log(string,string,bool,uint256) + ([134, 129, 138, 122], [214, 174, 250, 210]), + // log(uint256,address,uint256,string) + ([62, 211, 189, 40], [221, 176, 101, 33]), + // log(uint256,bool,bool,string) + ([49, 138, 229, 155], [221, 219, 149, 97]), + // log(uint256,bool,uint256,string) + ([232, 221, 188, 86], [222, 3, 231, 116]), + // log(string,uint256,bool,address) + ([229, 84, 157, 145], [224, 233, 91, 152]), + // log(string,uint256,uint256,address) + ([190, 215, 40, 191], [226, 29, 226, 120]), + // log(uint256,address,bool,bool) + ([126, 39, 65, 13], [227, 81, 20, 15]), + // log(bool,bool,string,uint256) + ([23, 139, 70, 133], [227, 169, 202, 47]), + // log(string,uint256,bool,uint256) + ([85, 14, 110, 245], [228, 27, 111, 111]), + // log(bool,uint256,string,bool) + ([145, 210, 248, 19], [229, 231, 11, 43]), + // log(uint256,string,address,uint256) + ([152, 231, 243, 243], [232, 211, 1, 141]), + // log(bool,uint256,bool) + ([27, 173, 201, 235], [232, 222, 251, 169]), + // log(uint256,uint256,bool,uint256) + ([108, 100, 124, 140], [235, 127, 111, 210]), + // log(uint256,bool,string,bool) + ([52, 110, 184, 199], [235, 146, 141, 127]), + // log(address,address,string,uint256) + ([4, 40, 147, 0], [239, 28, 239, 231]), + // log(uint256,bool,string,address) + ([73, 110, 43, 180], [239, 82, 144, 24]), + // log(uint256,address,bool,address) + ([182, 49, 48, 148], [239, 114, 197, 19]), + // log(string,string,uint256,uint256) + ([213, 207, 23, 208], [244, 93, 125, 44]), + // log(bool,uint256,string,string) + ([211, 42, 101, 72], [245, 188, 34, 73]), + // log(uint256,uint256) + ([108, 15, 105, 128], [246, 102, 113, 90]), + // log(uint256) and logUint(uint256) + ([245, 177, 187, 169], [248, 44, 80, 241]), + // log(string,address,uint256,uint256) + ([218, 163, 148, 189], [248, 245, 27, 30]), + // log(uint256,uint256,uint256,address) + ([224, 133, 63, 105], [250, 129, 133, 175]), + // log(string,address,uint256,bool) + ([90, 193, 193, 60], [252, 72, 69, 240]), + // log(address,address,uint256,string) + ([157, 209, 46, 173], [253, 180, 249, 144]), + // log(bool,uint256,string,address) + ([165, 199, 13, 41], [254, 221, 31, 255]), + // logInt(int256) + ([78, 12, 29, 29], [101, 37, 181, 245]), + // logBytes(bytes) + ([11, 231, 127, 86], [225, 123, 249, 86]), + // logBytes1(bytes1) + ([110, 24, 161, 40], [111, 65, 113, 201]), + // logBytes2(bytes2) + ([233, 182, 34, 150], [155, 94, 148, 62]), + // logBytes3(bytes3) + ([45, 131, 73, 38], [119, 130, 250, 45]), + // logBytes4(bytes4) + ([224, 95, 72, 209], [251, 163, 173, 57]), + // logBytes5(bytes5) + ([166, 132, 128, 141], [85, 131, 190, 46]), + // logBytes6(bytes6) + ([174, 132, 165, 145], [73, 66, 173, 198]), + // logBytes7(bytes7) + ([78, 213, 126, 40], [69, 116, 175, 171]), + // logBytes8(bytes8) + ([79, 132, 37, 46], [153, 2, 228, 127]), + // logBytes9(bytes9) + ([144, 189, 140, 208], [80, 161, 56, 223]), + // logBytes10(bytes10) + ([1, 61, 23, 139], [157, 194, 168, 151]), + // logBytes11(bytes11) + ([4, 0, 74, 46], [220, 8, 182, 167]), + // logBytes12(bytes12) + ([134, 160, 106, 189], [118, 86, 214, 199]), + // logBytes13(bytes13) + ([148, 82, 158, 52], [52, 193, 216, 27]), + // logBytes14(bytes14) + ([146, 102, 240, 127], [60, 234, 186, 101]), + // logBytes15(bytes15) + ([218, 149, 116, 224], [89, 26, 61, 162]), + // logBytes16(bytes16) + ([102, 92, 97, 4], [31, 141, 115, 18]), + // logBytes17(bytes17) + ([51, 159, 103, 58], [248, 154, 83, 47]), + // logBytes18(bytes18) + ([196, 210, 61, 154], [216, 101, 38, 66]), + // logBytes19(bytes19) + ([94, 107, 90, 51], [0, 245, 107, 201]), + // logBytes20(bytes20) + ([81, 136, 227, 233], [236, 184, 86, 126]), + // logBytes21(bytes21) + ([233, 218, 53, 96], [48, 82, 192, 143]), + // logBytes22(bytes22) + ([213, 250, 232, 156], [128, 122, 180, 52]), + // logBytes23(bytes23) + ([171, 161, 207, 13], [73, 121, 176, 55]), + // logBytes24(bytes24) + ([241, 179, 91, 52], [9, 119, 174, 252]), + // logBytes25(bytes25) + ([11, 132, 188, 88], [174, 169, 150, 63]), + // logBytes26(bytes26) + ([248, 177, 73, 241], [211, 99, 86, 40]), + // logBytes27(bytes27) + ([58, 55, 87, 221], [252, 55, 47, 159]), + // logBytes28(bytes28) + ([200, 42, 234, 238], [56, 47, 154, 52]), + // logBytes29(bytes29) + ([75, 105, 195, 213], [122, 24, 118, 65]), + // logBytes30(bytes30) + ([238, 18, 196, 237], [196, 52, 14, 246]), + // logBytes31(bytes31) + ([194, 133, 77, 146], [129, 252, 134, 72]), + // logBytes32(bytes32) + ([39, 183, 207, 133], [45, 33, 214, 247]), + ]) +}); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn hardhat_console_path_works() { + for (hh, abigen) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { + let mut hh = (*hh).to_vec(); + patch_hardhat_console_selector(&mut hh); + assert_eq!((*abigen).to_vec(), hh); + } + } +} diff --git a/crates/evm/src/executor/backend/diagnostic.rs b/crates/evm/core/src/backend/diagnostic.rs similarity index 80% rename from crates/evm/src/executor/backend/diagnostic.rs rename to crates/evm/core/src/backend/diagnostic.rs index ff179460e3008..1e2b0b0d26672 100644 --- a/crates/evm/src/executor/backend/diagnostic.rs +++ b/crates/evm/core/src/backend/diagnostic.rs @@ -1,9 +1,7 @@ -use crate::executor::{backend::LocalForkId, inspector::Cheatcodes}; +use crate::backend::LocalForkId; use alloy_primitives::Address; -use foundry_common::fmt::UIfmt; - -use foundry_utils::types::ToEthers; use itertools::Itertools; +use std::collections::BTreeMap; /// Represents possible diagnostic cases on revert #[derive(Debug, Clone)] @@ -21,14 +19,11 @@ pub enum RevertDiagnostic { }, } -// === impl RevertDiagnostic === - impl RevertDiagnostic { /// Converts the diagnostic to a readable error message - pub fn to_error_msg(&self, cheats: &Cheatcodes) -> String { - let get_label = |addr: &Address| { - cheats.labels.get(addr).cloned().unwrap_or_else(|| addr.to_ethers().pretty()) - }; + pub fn to_error_msg(&self, labels: &BTreeMap) -> String { + let get_label = + |addr: &Address| labels.get(addr).cloned().unwrap_or_else(|| addr.to_string()); match self { RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => { diff --git a/crates/evm/src/executor/backend/error.rs b/crates/evm/core/src/backend/error.rs similarity index 98% rename from crates/evm/src/executor/backend/error.rs rename to crates/evm/core/src/backend/error.rs index a23a16c3828cd..209ecf4b01ef0 100644 --- a/crates/evm/src/executor/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -99,7 +99,7 @@ impl From for DatabaseError { /// Error thrown when the address is not allowed to execute cheatcodes /// -/// See also [`DatabaseExt`](crate::executor::DatabaseExt) +/// See also [`DatabaseExt`](crate::DatabaseExt) #[derive(Debug, Clone, Copy)] pub struct NoCheatcodeAccessError(pub Address); diff --git a/crates/evm/src/executor/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs similarity index 97% rename from crates/evm/src/executor/backend/fuzz.rs rename to crates/evm/core/src/backend/fuzz.rs index 738fa8a34c2a7..12d0f6ce781ed 100644 --- a/crates/evm/src/executor/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -1,11 +1,10 @@ //! A wrapper around `Backend` that is clone-on-write used for fuzzing. -use crate::executor::{ +use crate::{ backend::{ diagnostic::RevertDiagnostic, error::DatabaseError, Backend, DatabaseExt, LocalForkId, }, fork::{CreateFork, ForkId}, - inspector::cheatcodes::Cheatcodes, }; use alloy_primitives::{Address, B256, U256}; use revm::{ @@ -46,8 +45,6 @@ pub struct FuzzBackendWrapper<'a> { has_snapshot_failure: bool, } -// === impl FuzzBackendWrapper === - impl<'a> FuzzBackendWrapper<'a> { pub fn new(backend: &'a Backend) -> Self { Self { backend: Cow::Borrowed(backend), is_initialized: false, has_snapshot_failure: false } @@ -165,16 +162,16 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { self.backend_mut(env).roll_fork_to_transaction(id, transaction, env, journaled_state) } - fn transact( + fn transact>( &mut self, id: Option, transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - cheatcodes_inspector: Option<&mut Cheatcodes>, + inspector: I, ) -> eyre::Result<()> { trace!(?id, ?transaction, "fuzz: execute transaction"); - self.backend_mut(env).transact(id, transaction, env, journaled_state, cheatcodes_inspector) + self.backend_mut(env).transact(id, transaction, env, journaled_state, inspector) } fn active_fork_id(&self) -> Option { diff --git a/crates/evm/src/executor/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs similarity index 98% rename from crates/evm/src/executor/backend/in_memory_db.rs rename to crates/evm/core/src/backend/in_memory_db.rs index 4687db7804e95..9041258593455 100644 --- a/crates/evm/src/executor/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -1,5 +1,5 @@ //! The in memory DB -use crate::executor::backend::error::DatabaseError; +use crate::{backend::error::DatabaseError, snapshot::Snapshots}; use alloy_primitives::{Address, B256, U256}; use revm::{ db::{CacheDB, DatabaseRef, EmptyDB}, @@ -7,8 +7,6 @@ use revm::{ Database, DatabaseCommit, }; -use crate::executor::snapshot::Snapshots; - /// Type alias for an in memory database /// /// See `EmptyDBWrapper` diff --git a/crates/evm/src/executor/backend/mod.rs b/crates/evm/core/src/backend/mod.rs similarity index 98% rename from crates/evm/src/executor/backend/mod.rs rename to crates/evm/core/src/backend/mod.rs index f159ef82c6dbe..9e4e6b605c5b1 100644 --- a/crates/evm/src/executor/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1,20 +1,10 @@ //! Foundry's main executor backend abstraction and implementation. use crate::{ - abi::CHEATCODE_ADDRESS, - executor::{ - backend::{ - error::NoCheatcodeAccessError, in_memory_db::FoundryEvmInMemoryDB, - snapshot::BackendSnapshot, - }, - fork::{CreateFork, ForkId, MultiFork, SharedBackend}, - inspector::{ - cheatcodes::{util::configure_tx_env, Cheatcodes}, - DEFAULT_CREATE2_DEPLOYER, - }, - snapshot::Snapshots, - }, - CALLER, TEST_CONTRACT_ADDRESS, + constants::{CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, TEST_CONTRACT_ADDRESS}, + fork::{CreateFork, ForkId, MultiFork, SharedBackend}, + snapshot::Snapshots, + utils::configure_tx_env, }; use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; use ethers::{ @@ -23,9 +13,9 @@ use ethers::{ }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_utils::types::{ToAlloy, ToEthers}; -pub use in_memory_db::MemDb; use revm::{ db::{CacheDB, DatabaseRef}, + inspectors::NoOpInspector, precompile::{Precompiles, SpecId}, primitives::{ Account, AccountInfo, Bytecode, CreateScheme, Env, HashMap as Map, Log, ResultAndState, @@ -41,17 +31,20 @@ use std::{ }, }; -mod fuzz; -pub mod snapshot; -pub use fuzz::FuzzBackendWrapper; mod diagnostic; - pub use diagnostic::RevertDiagnostic; -pub mod error; -pub use error::{DatabaseError, DatabaseResult}; +mod error; +pub use error::{DatabaseError, DatabaseResult, NoCheatcodeAccessError}; + +mod fuzz; +pub use fuzz::FuzzBackendWrapper; mod in_memory_db; +pub use in_memory_db::{EmptyDBWrapper, FoundryEvmInMemoryDB, MemDb}; + +mod snapshot; +pub use snapshot::{BackendSnapshot, StateSnapshot}; // A `revm::Database` that is used in forking mode type ForkDB = CacheDB; @@ -83,6 +76,7 @@ pub trait DatabaseExt: Database { /// Snapshots can be reverted: [DatabaseExt::revert], however a snapshot can only be reverted /// once. After a successful revert, the same snapshot id cannot be used again. fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256; + /// Reverts the snapshot if it exists /// /// Returns `true` if the snapshot was successfully reverted, `false` if no snapshot for that id @@ -187,13 +181,13 @@ pub trait DatabaseExt: Database { ) -> eyre::Result<()>; /// Fetches the given transaction for the fork and executes it, committing the state in the DB - fn transact( + fn transact>( &mut self, id: Option, transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - cheatcodes_inspector: Option<&mut Cheatcodes>, + inspector: I, ) -> eyre::Result<()>; /// Returns the `ForkId` that's currently used in the database, if fork mode is on @@ -877,7 +871,7 @@ impl Backend { } trace!(tx=?tx.hash, "committing transaction"); - commit_transaction(tx, env.clone(), journaled_state, fork, &fork_id, None)?; + commit_transaction(tx, env.clone(), journaled_state, fork, &fork_id, NoOpInspector)?; } Ok(None) @@ -1176,13 +1170,13 @@ impl DatabaseExt for Backend { Ok(()) } - fn transact( + fn transact>( &mut self, maybe_id: Option, transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - cheatcodes_inspector: Option<&mut Cheatcodes>, + inspector: I, ) -> eyre::Result<()> { trace!(?maybe_id, ?transaction, "execute transaction"); let id = self.ensure_fork(maybe_id)?; @@ -1199,9 +1193,7 @@ impl DatabaseExt for Backend { let fork = self.inner.get_fork_by_id_mut(id)?; let tx = fork.db.db.get_transaction(transaction)?; - commit_transaction(tx, env, journaled_state, fork, &fork_id, cheatcodes_inspector)?; - - Ok(()) + commit_transaction(tx, env, journaled_state, fork, &fork_id, inspector) } fn active_fork_id(&self) -> Option { @@ -1803,13 +1795,13 @@ fn is_contract_in_state(journaled_state: &JournaledState, acc: Address) -> bool /// Executes the given transaction and commits state changes to the database _and_ the journaled /// state, with an optional inspector -fn commit_transaction( +fn commit_transaction>( tx: Transaction, mut env: Env, journaled_state: &mut JournaledState, fork: &mut Fork, fork_id: &ForkId, - cheatcodes_inspector: Option<&mut Cheatcodes>, + inspector: I, ) -> eyre::Result<()> { configure_tx_env(&mut env, &tx); @@ -1823,16 +1815,9 @@ fn commit_transaction( .block_on(async move { Backend::new_with_fork(fork_id, fork, journaled_state).await }); evm.database(db); - if let Some(inspector) = cheatcodes_inspector { - match evm.inspect(inspector) { - Ok(res) => res.state, - Err(e) => eyre::bail!("backend: failed committing transaction: {:?}", e), - } - } else { - match evm.transact() { - Ok(res) => res.state, - Err(e) => eyre::bail!("backend: failed committing transaction: {:?}", e), - } + match evm.inspect(inspector) { + Ok(res) => res.state, + Err(e) => eyre::bail!("backend: failed committing transaction: {:?}", e), } }; diff --git a/crates/evm/src/executor/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs similarity index 100% rename from crates/evm/src/executor/backend/snapshot.rs rename to crates/evm/core/src/backend/snapshot.rs diff --git a/crates/evm/core/src/constants.rs b/crates/evm/core/src/constants.rs new file mode 100644 index 0000000000000..55a0458ed0649 --- /dev/null +++ b/crates/evm/core/src/constants.rs @@ -0,0 +1,37 @@ +use alloy_primitives::{address, hex, Address}; + +/// The cheatcode handler address. +/// +/// This is the same address as the one used in DappTools's HEVM. +/// It is calculated as: +/// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))` +pub const CHEATCODE_ADDRESS: Address = address!("7109709ECfa91a80626fF3989D68f67F5b1DD12D"); + +/// The Hardhat console address. +/// +/// See: +pub const HARDHAT_CONSOLE_ADDRESS: Address = address!("000000000000000000636F6e736F6c652e6c6f67"); + +/// Stores the caller address to be used as *sender* account for: +/// - deploying Test contracts +/// - deploying Script contracts +/// +/// Derived from `address(uint160(uint256(keccak256("foundry default caller"))))`, +/// which is equal to `0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38`. +pub const CALLER: Address = address!("1804c8AB1F12E6bbf3894d4083f33e07309d1f38"); + +/// The default test contract address. +pub const TEST_CONTRACT_ADDRESS: Address = address!("b4c79daB8f259C7Aee6E5b2Aa729821864227e84"); + +/// Magic return value returned by the `assume` cheatcode. +pub const ASSUME_MAGIC_RETURN_CODE: &[u8] = b"FOUNDRY::ASSUME"; + +/// Magic return value returned by the `skip` cheatcode. +pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; + +/// The default CREATE2 deployer. +pub const DEFAULT_CREATE2_DEPLOYER: Address = address!("4e59b44847b379578588920ca78fbf26c0b4956c"); +/// The initcode of the default CREATE2 deployer. +pub const DEFAULT_CREATE2_DEPLOYER_CODE: &[u8] = &hex!("604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); +/// The runtime code of the default CREATE2 deployer. +pub const DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE: &[u8] = &hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); diff --git a/crates/evm/src/debug.rs b/crates/evm/core/src/debug.rs similarity index 98% rename from crates/evm/src/debug.rs rename to crates/evm/core/src/debug.rs index d4c97fedf95be..cbe1b64b2f7be 100644 --- a/crates/evm/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,4 +1,4 @@ -use crate::{abi::HEVM_ABI, CallKind}; +use crate::{abi::HEVM_ABI, utils::CallKind}; use alloy_primitives::{Address, U256}; use revm::interpreter::{Memory, OpCode}; use serde::{Deserialize, Serialize}; @@ -180,7 +180,7 @@ impl Display for Instruction { "VM_{}", &*HEVM_ABI .functions() - .find(|func| func.selector() == *cheat) + .find(|func| func.short_signature() == *cheat) .expect("unknown cheatcode found in debugger") .name .to_uppercase() diff --git a/crates/evm/src/decode.rs b/crates/evm/core/src/decode.rs similarity index 99% rename from crates/evm/src/decode.rs rename to crates/evm/core/src/decode.rs index 9386c098548f2..8cd0493d7de1d 100644 --- a/crates/evm/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -1,5 +1,6 @@ -//! Various utilities to decode test results -use crate::executor::inspector::cheatcodes::util::MAGIC_SKIP_BYTES; +//! Various utilities to decode test results. + +use crate::constants::MAGIC_SKIP_BYTES; use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; use alloy_json_abi::JsonAbi; use alloy_primitives::{B256, U256}; diff --git a/crates/evm/src/executor/fork/backend.rs b/crates/evm/core/src/fork/backend.rs similarity index 98% rename from crates/evm/src/executor/fork/backend.rs rename to crates/evm/core/src/fork/backend.rs index f296796b7097f..587c3150c5673 100644 --- a/crates/evm/src/executor/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -1,6 +1,6 @@ //! Smart caching and deduplication of requests when using a forking provider -use crate::executor::{ - backend::error::{DatabaseError, DatabaseResult}, +use crate::{ + backend::{DatabaseError, DatabaseResult}, fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }; use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; @@ -346,19 +346,17 @@ where }; // convert it to revm-style types - let (code, code_hash) = if !code.0.is_empty() { - (Some(code.0.clone()), keccak256(&code)) + let (code, code_hash) = if !code.is_empty() { + (code.clone(), keccak256(&code)) } else { - (Some(bytes::Bytes::default()), KECCAK_EMPTY) + (Bytes::default(), KECCAK_EMPTY) }; // update the cache let acc = AccountInfo { nonce: nonce.to(), balance, - code: code.map(|bytes| { - Bytecode::new_raw(alloy_primitives::Bytes(bytes)).to_checked() - }), + code: Some(Bytecode::new_raw(code).to_checked()), code_hash, }; pin.db.accounts().write().insert(addr, acc.clone()); @@ -696,10 +694,10 @@ impl DatabaseRef for SharedBackend { #[cfg(test)] mod tests { use super::*; - use crate::executor::{ + use crate::{ + backend::Backend, fork::{BlockchainDbMeta, CreateFork, JsonBlockCacheDB}, opts::EvmOpts, - Backend, }; use ethers::types::Chain; use foundry_common::get_http_provider; diff --git a/crates/evm/src/executor/fork/cache.rs b/crates/evm/core/src/fork/cache.rs similarity index 99% rename from crates/evm/src/executor/fork/cache.rs rename to crates/evm/core/src/fork/cache.rs index f9a96772ce34d..f2203fc5de9c4 100644 --- a/crates/evm/src/executor/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -1,5 +1,5 @@ //! Cache related abstraction -use crate::executor::backend::snapshot::StateSnapshot; +use crate::backend::StateSnapshot; use alloy_primitives::{Address, B256, U256}; use parking_lot::RwLock; use revm::{ diff --git a/crates/evm/src/executor/fork/database.rs b/crates/evm/core/src/fork/database.rs similarity index 96% rename from crates/evm/src/executor/fork/database.rs rename to crates/evm/core/src/fork/database.rs index 8da324b24cf29..13596fee4796f 100644 --- a/crates/evm/src/executor/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -1,18 +1,15 @@ //! A revm database that forks off a remote client use crate::{ - executor::{ - backend::{error::DatabaseError, snapshot::StateSnapshot}, - fork::{BlockchainDb, SharedBackend}, - snapshot::Snapshots, - }, - revm::db::CacheDB, + backend::{DatabaseError, StateSnapshot}, + fork::{BlockchainDb, SharedBackend}, + snapshot::Snapshots, }; use alloy_primitives::{Address, B256, U256}; use ethers::types::BlockId; use parking_lot::Mutex; use revm::{ - db::DatabaseRef, + db::{CacheDB, DatabaseRef}, primitives::{Account, AccountInfo, Bytecode, HashMap as Map}, Database, DatabaseCommit, }; @@ -155,7 +152,7 @@ impl Database for ForkedDatabase { fn basic(&mut self, address: Address) -> Result, Self::Error> { // Note: this will always return Some, since the `SharedBackend` will always load the // account, this differs from `::basic`, See also - // [MemDb::ensure_loaded](crate::executor::backend::MemDb::ensure_loaded) + // [MemDb::ensure_loaded](crate::backend::MemDb::ensure_loaded) Database::basic(&mut self.cache_db, address) } @@ -266,7 +263,7 @@ impl DatabaseRef for ForkDbSnapshot { #[cfg(test)] mod tests { use super::*; - use crate::executor::fork::BlockchainDbMeta; + use crate::fork::BlockchainDbMeta; use foundry_common::get_http_provider; use std::collections::BTreeSet; diff --git a/crates/evm/src/executor/fork/init.rs b/crates/evm/core/src/fork/init.rs similarity index 100% rename from crates/evm/src/executor/fork/init.rs rename to crates/evm/core/src/fork/init.rs diff --git a/crates/evm/src/executor/fork/mod.rs b/crates/evm/core/src/fork/mod.rs similarity index 100% rename from crates/evm/src/executor/fork/mod.rs rename to crates/evm/core/src/fork/mod.rs diff --git a/crates/evm/src/executor/fork/multi.rs b/crates/evm/core/src/fork/multi.rs similarity index 99% rename from crates/evm/src/executor/fork/multi.rs rename to crates/evm/core/src/fork/multi.rs index 8be587090b67e..4795634e5035e 100644 --- a/crates/evm/src/executor/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -3,9 +3,7 @@ //! The design is similar to the single `SharedBackend`, `BackendHandler` but supports multiple //! concurrently active pairs at once. -use crate::executor::fork::{ - BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend, -}; +use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; use ethers::{ providers::Provider, types::{BlockId, BlockNumber}, diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs new file mode 100644 index 0000000000000..9864ded06f0b0 --- /dev/null +++ b/crates/evm/core/src/lib.rs @@ -0,0 +1,18 @@ +//! # foundry-evm-core +//! +//! Core EVM abstractions. + +#![warn(unused_crate_dependencies)] + +#[macro_use] +extern crate tracing; + +pub mod abi; +pub mod backend; +pub mod constants; +pub mod debug; +pub mod decode; +pub mod fork; +pub mod opts; +pub mod snapshot; +pub mod utils; diff --git a/crates/evm/src/executor/opts.rs b/crates/evm/core/src/opts.rs similarity index 99% rename from crates/evm/src/executor/opts.rs rename to crates/evm/core/src/opts.rs index a09e7c44d2087..b3f2b1bd0b642 100644 --- a/crates/evm/src/executor/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,4 +1,5 @@ -use crate::{executor::fork::CreateFork, utils::RuntimeOrHandle}; +use super::fork::environment; +use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; use ethers::{ providers::{Middleware, Provider}, @@ -6,12 +7,11 @@ use ethers::{ }; use eyre::WrapErr; use foundry_common::{self, ProviderBuilder, RpcUrl, ALCHEMY_FREE_TIER_CUPS}; +use foundry_compilers::utils::RuntimeOrHandle; use foundry_config::Config; use revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}; use serde::{Deserialize, Deserializer, Serialize}; -use super::fork::environment; - #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct EvmOpts { #[serde(flatten)] diff --git a/crates/evm/src/executor/snapshot.rs b/crates/evm/core/src/snapshot.rs similarity index 98% rename from crates/evm/src/executor/snapshot.rs rename to crates/evm/core/src/snapshot.rs index d931e45f7e145..bcd1c92913191 100644 --- a/crates/evm/src/executor/snapshot.rs +++ b/crates/evm/core/src/snapshot.rs @@ -10,8 +10,6 @@ pub struct Snapshots { snapshots: HashMap, } -// === impl Snapshots === - impl Snapshots { fn next_id(&mut self) -> U256 { let id = self.id; diff --git a/crates/evm/src/utils.rs b/crates/evm/core/src/utils.rs similarity index 65% rename from crates/evm/src/utils.rs rename to crates/evm/core/src/utils.rs index 78d6b98b59b1d..e03930ea42a05 100644 --- a/crates/evm/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,14 +1,76 @@ use alloy_json_abi::{Function, JsonAbi as Abi}; -use alloy_primitives::FixedBytes; -use ethers::types::{Block, Chain, H256, U256}; +use alloy_primitives::{Address, FixedBytes, B256}; +use ethers::types::{ActionType, Block, CallType, Chain, Transaction, H256, U256}; use eyre::ContextCompat; use foundry_utils::types::ToAlloy; use revm::{ - interpreter::{opcode, opcode::spec_opcode_gas, InstructionResult}, - primitives::{Eval, Halt, SpecId}, + interpreter::{opcode, opcode::spec_opcode_gas, CallScheme, CreateInputs, InstructionResult}, + primitives::{CreateScheme, Eval, Halt, SpecId, TransactTo}, }; +use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; +pub use foundry_compilers::utils::RuntimeOrHandle; +pub use revm::primitives::State as StateChangeset; + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "UPPERCASE")] +#[derive(Default)] +pub enum CallKind { + #[default] + Call, + StaticCall, + CallCode, + DelegateCall, + Create, + Create2, +} + +impl From for CallKind { + fn from(scheme: CallScheme) -> Self { + match scheme { + CallScheme::Call => CallKind::Call, + CallScheme::StaticCall => CallKind::StaticCall, + CallScheme::CallCode => CallKind::CallCode, + CallScheme::DelegateCall => CallKind::DelegateCall, + } + } +} + +impl From for CallKind { + fn from(create: CreateScheme) -> Self { + match create { + CreateScheme::Create => CallKind::Create, + CreateScheme::Create2 { .. } => CallKind::Create2, + } + } +} + +impl From for ActionType { + fn from(kind: CallKind) -> Self { + match kind { + CallKind::Call | CallKind::StaticCall | CallKind::DelegateCall | CallKind::CallCode => { + ActionType::Call + } + CallKind::Create => ActionType::Create, + CallKind::Create2 => ActionType::Create, + } + } +} + +impl From for CallType { + fn from(ty: CallKind) -> Self { + match ty { + CallKind::Call => CallType::Call, + CallKind::StaticCall => CallType::StaticCall, + CallKind::CallCode => CallType::CallCode, + CallKind::DelegateCall => CallType::DelegateCall, + CallKind::Create => CallType::None, + CallKind::Create2 => CallType::None, + } + } +} + /// Small helper function to convert [U256] into [H256]. #[inline] pub fn u256_to_h256_le(u: U256) -> H256 { @@ -179,37 +241,44 @@ pub fn get_function( .wrap_err(format!("{contract_name} does not have the selector {selector:?}")) } -// TODO: Add this once solc is removed from this crate -pub use foundry_compilers::utils::RuntimeOrHandle; - -/* -use tokio::runtime::{Handle, Runtime}; - -#[derive(Debug)] -pub enum RuntimeOrHandle { - Runtime(Runtime), - Handle(Handle), -} - -impl Default for RuntimeOrHandle { - fn default() -> Self { - Self::new() - } +/// Configures the env for the transaction +pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { + env.tx.caller = tx.from.to_alloy(); + env.tx.gas_limit = tx.gas.as_u64(); + env.tx.gas_price = tx.gas_price.unwrap_or_default().to_alloy(); + env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(|g| g.to_alloy()); + env.tx.nonce = Some(tx.nonce.as_u64()); + env.tx.access_list = tx + .access_list + .clone() + .unwrap_or_default() + .0 + .into_iter() + .map(|item| { + ( + item.address.to_alloy(), + item.storage_keys.into_iter().map(h256_to_u256_be).map(|g| g.to_alloy()).collect(), + ) + }) + .collect(); + env.tx.value = tx.value.to_alloy(); + env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); + env.tx.transact_to = + tx.to.map(|tx| tx.to_alloy()).map(TransactTo::Call).unwrap_or_else(TransactTo::create) } -impl RuntimeOrHandle { - pub fn new() -> RuntimeOrHandle { - match Handle::try_current() { - Ok(handle) => RuntimeOrHandle::Handle(handle), - Err(_) => RuntimeOrHandle::Runtime(Runtime::new().expect("Failed to start runtime")), +/// Get the address of a contract creation +pub fn get_create_address(call: &CreateInputs, nonce: u64) -> Address { + match call.scheme { + CreateScheme::Create => call.caller.create(nonce), + CreateScheme::Create2 { salt } => { + call.caller.create2_from_code(B256::from(salt), &call.init_code) } } +} - pub fn block_on(&self, f: F) -> F::Output { - match &self { - RuntimeOrHandle::Runtime(runtime) => runtime.block_on(f), - RuntimeOrHandle::Handle(handle) => tokio::task::block_in_place(|| handle.block_on(f)), - } - } +/// Get the gas used, accounting for refunds +pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 { + let refund_quotient = if SpecId::enabled(spec, SpecId::LONDON) { 5 } else { 2 }; + spent - (refunded).min(spent / refund_quotient) } -*/ diff --git a/crates/evm/test-data/storage.json b/crates/evm/core/test-data/storage.json similarity index 100% rename from crates/evm/test-data/storage.json rename to crates/evm/core/test-data/storage.json diff --git a/crates/evm/coverage/Cargo.toml b/crates/evm/coverage/Cargo.toml new file mode 100644 index 0000000000000..4a9a39276abfc --- /dev/null +++ b/crates/evm/coverage/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "foundry-evm-coverage" +description = "EVM bytecode coverage analysis" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +foundry-common.workspace = true +foundry-compilers.workspace = true +foundry-evm-core.workspace = true + +alloy-primitives.workspace = true +eyre = "0.6" +revm.workspace = true +semver = "1" +tracing = "0.1" diff --git a/crates/evm/src/coverage/analysis.rs b/crates/evm/coverage/src/analysis.rs similarity index 100% rename from crates/evm/src/coverage/analysis.rs rename to crates/evm/coverage/src/analysis.rs diff --git a/crates/evm/src/coverage/anchors.rs b/crates/evm/coverage/src/anchors.rs similarity index 99% rename from crates/evm/src/coverage/anchors.rs rename to crates/evm/coverage/src/anchors.rs index bbba9544286ce..0342b38e9527e 100644 --- a/crates/evm/src/coverage/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -1,7 +1,7 @@ use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; -use crate::utils::ICPCMap; use alloy_primitives::Bytes; use foundry_compilers::sourcemap::{SourceElement, SourceMap}; +use foundry_evm_core::utils::ICPCMap; use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, diff --git a/crates/evm/src/executor/inspector/coverage.rs b/crates/evm/coverage/src/inspector.rs similarity index 94% rename from crates/evm/src/executor/inspector/coverage.rs rename to crates/evm/coverage/src/inspector.rs index 3f06c490e4160..3ee7ec98cce9b 100644 --- a/crates/evm/src/executor/inspector/coverage.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -1,5 +1,5 @@ -use crate::coverage::{HitMap, HitMaps}; -use bytes::Bytes; +use crate::{HitMap, HitMaps}; +use alloy_primitives::Bytes; use revm::{ interpreter::{InstructionResult, Interpreter}, Database, EVMData, Inspector, diff --git a/crates/evm/src/coverage/mod.rs b/crates/evm/coverage/src/lib.rs similarity index 97% rename from crates/evm/src/coverage/mod.rs rename to crates/evm/coverage/src/lib.rs index 7d78e9b519478..0ae3d6ea4ae73 100644 --- a/crates/evm/src/coverage/mod.rs +++ b/crates/evm/coverage/src/lib.rs @@ -1,8 +1,13 @@ -pub mod analysis; -pub mod anchors; +//! # foundry-evm-coverage +//! +//! EVM bytecode coverage analysis. + +#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] + +#[macro_use] +extern crate tracing; -use alloy_primitives::B256; -use bytes::Bytes; +use alloy_primitives::{Bytes, B256}; use semver::Version; use std::{ collections::{BTreeMap, HashMap}, @@ -10,6 +15,12 @@ use std::{ ops::{AddAssign, Deref, DerefMut}, }; +pub mod analysis; +pub mod anchors; + +mod inspector; +pub use inspector::CoverageCollector; + /// A coverage report. /// /// A coverage report contains coverage items and opcodes corresponding to those items (called diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml new file mode 100644 index 0000000000000..10b85e7538eea --- /dev/null +++ b/crates/evm/evm/Cargo.toml @@ -0,0 +1,53 @@ +[package] +name = "foundry-evm" +description = "Main Foundry EVM backend abstractions" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +foundry-abi.workspace = true +# foundry-cheatcodes.workspace = true +foundry-common.workspace = true +foundry-compilers.workspace = true +foundry-config.workspace = true +foundry-evm-coverage.workspace = true +foundry-evm-core.workspace = true +foundry-evm-fuzz.workspace = true +foundry-evm-traces.workspace = true +foundry-macros.workspace = true +foundry-utils.workspace = true + +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-json-abi.workspace = true +ethers = { workspace = true, features = ["ethers-solc"] } +hashbrown = { version = "0.14", features = ["serde"] } +revm = { workspace = true, default-features = false, features = [ + "std", + "serde", + "memory_limit", + "optional_eip3607", + "optional_block_gas_limit", + "optional_no_base_fee", + "arbitrary", +] } + +bytes = "1.5" +eyre = "0.6" +hex.workspace = true +itertools.workspace = true +jsonpath_lib = "0.3" +once_cell = "1" +parking_lot = "0.12" +proptest = "1" +serde = "1" +serde_json = "1" +thiserror = "1" +tracing = "0.1" +walkdir = "2" diff --git a/crates/evm/src/executor/builder.rs b/crates/evm/evm/src/executors/builder.rs similarity index 95% rename from crates/evm/src/executor/builder.rs rename to crates/evm/evm/src/executors/builder.rs index 5cbf6e453d650..ab9bd7629b8e7 100644 --- a/crates/evm/src/executor/builder.rs +++ b/crates/evm/evm/src/executors/builder.rs @@ -1,6 +1,6 @@ -use super::{inspector::InspectorStackBuilder, Executor}; -use crate::executor::backend::Backend; +use crate::{executors::Executor, inspectors::InspectorStackBuilder}; use alloy_primitives::U256; +use foundry_evm_core::backend::Backend; use revm::primitives::{Env, SpecId}; /// The builder that allows to configure an evm [`Executor`] which a stack of optional diff --git a/crates/evm/src/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs similarity index 52% rename from crates/evm/src/fuzz/mod.rs rename to crates/evm/evm/src/executors/fuzz/mod.rs index a2215da590f5a..3e71c95bd6e4e 100644 --- a/crates/evm/src/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,38 +1,33 @@ -//! Executor wrapper which can be used for fuzzing, using [`proptest`](https://docs.rs/proptest/1.0.0/proptest/) -use crate::{ - coverage::HitMaps, - decode::{self, decode_console_logs}, - executor::{Executor, RawCallResult}, - trace::CallTraceArena, -}; -use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; +use crate::executors::{Executor, RawCallResult}; +use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes, U256}; -use error::{FuzzError, ASSUME_MAGIC_RETURN_CODE}; -use ethers::types::Log; use eyre::Result; -use foundry_common::{calc, contracts::ContractsByAddress}; use foundry_config::FuzzConfig; -pub use proptest::test_runner::Reason; -use proptest::test_runner::{TestCaseError, TestError, TestRunner}; -use serde::{Deserialize, Serialize}; -use std::{cell::RefCell, collections::BTreeMap, fmt}; -use strategies::{ - build_initial_state, collect_state_from_call, fuzz_calldata, fuzz_calldata_from_state, - EvmFuzzState, +use foundry_evm_core::{ + constants::ASSUME_MAGIC_RETURN_CODE, + decode::{self, decode_console_logs}, +}; +use foundry_evm_coverage::HitMaps; +use foundry_evm_fuzz::{ + strategies::{ + build_initial_state, collect_state_from_call, fuzz_calldata, fuzz_calldata_from_state, + EvmFuzzState, + }, + BaseCounterExample, CounterExample, FuzzCase, FuzzError, FuzzTestResult, }; -use types::{CaseOutcome, CounterExampleOutcome, FuzzCase, FuzzOutcome}; +use foundry_evm_traces::CallTraceArena; +use proptest::test_runner::{TestCaseError, TestError, TestRunner}; +use std::cell::RefCell; -pub mod error; -pub mod invariant; -pub mod strategies; -pub mod types; +mod types; +pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; -/// Wrapper around an [`Executor`] which provides fuzzing support using [`proptest`](https://docs.rs/proptest/1.0.0/proptest/). +/// Wrapper around an [`Executor`] which provides fuzzing support using [`proptest`]. /// /// After instantiation, calling `fuzz` will proceed to hammer the deployed smart contract with /// inputs, until it finds a counterexample. The provided [`TestRunner`] contains all the -/// configuration which can be overridden via [environment variables](https://docs.rs/proptest/1.0.0/proptest/test_runner/struct.Config.html) +/// configuration which can be overridden via [environment variables](proptest::test_runner::Config) pub struct FuzzedExecutor<'a> { /// The VM executor: &'a Executor, @@ -255,239 +250,3 @@ impl<'a> FuzzedExecutor<'a> { } } } - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub enum CounterExample { - /// Call used as a counter example for fuzz tests. - Single(BaseCounterExample), - /// Sequence of calls used as a counter example for invariant tests. - Sequence(Vec), -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct BaseCounterExample { - /// Address which makes the call - pub sender: Option
, - /// Address to which to call to - pub addr: Option
, - /// The data to provide - pub calldata: Bytes, - /// Function signature if it exists - pub signature: Option, - /// Contract name if it exists - pub contract_name: Option, - /// Traces - pub traces: Option, - #[serde(skip)] - pub args: Vec, -} - -impl BaseCounterExample { - pub fn create( - sender: Address, - addr: Address, - bytes: &Bytes, - contracts: &ContractsByAddress, - traces: Option, - ) -> Self { - if let Some((name, abi)) = &contracts.get(&addr) { - if let Some(func) = abi.functions().find(|f| f.selector() == bytes.0.as_ref()[0..4]) { - // skip the function selector when decoding - if let Ok(args) = func.abi_decode_input(&bytes.0.as_ref()[4..], false) { - return BaseCounterExample { - sender: Some(sender), - addr: Some(addr), - calldata: bytes.clone(), - signature: Some(func.signature()), - contract_name: Some(name.clone()), - traces, - args, - } - } - } - } - - BaseCounterExample { - sender: Some(sender), - addr: Some(addr), - calldata: bytes.clone(), - signature: None, - contract_name: None, - traces, - args: vec![], - } - } -} - -impl fmt::Display for BaseCounterExample { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let args = foundry_common::abi::format_tokens(&self.args).collect::>().join(", "); - - if let Some(sender) = self.sender { - write!(f, "sender={sender:?} addr=")? - } - - if let Some(name) = &self.contract_name { - write!(f, "[{name}]")? - } - - if let Some(addr) = &self.addr { - write!(f, "{addr:?} ")? - } - - if let Some(sig) = &self.signature { - write!(f, "calldata={}", &sig)? - } else { - write!(f, "calldata=0x{}", self.calldata)? - } - - write!(f, ", args=[{args}]") - } -} - -/// The outcome of a fuzz test -#[derive(Debug)] -pub struct FuzzTestResult { - /// we keep this for the debugger - pub first_case: FuzzCase, - /// Gas usage (gas_used, call_stipend) per cases - pub gas_by_case: Vec<(u64, u64)>, - /// Whether the test case was successful. This means that the transaction executed - /// properly, or that there was a revert and that the test was expected to fail - /// (prefixed with `testFail`) - pub success: bool, - - /// If there was a revert, this field will be populated. Note that the test can - /// still be successful (i.e self.success == true) when it's expected to fail. - pub reason: Option, - - /// Minimal reproduction test case for failing fuzz tests - pub counterexample: Option, - - /// Any captured & parsed as strings logs along the test's execution which should - /// be printed to the user. - pub logs: Vec, - - /// The decoded DSTest logging events and Hardhat's `console.log` from [logs](Self::logs). - pub decoded_logs: Vec, - - /// Labeled addresses - pub labeled_addresses: BTreeMap, - - /// Exemplary traces for a fuzz run of the test function - /// - /// **Note** We only store a single trace of a successful fuzz call, otherwise we would get - /// `num(fuzz_cases)` traces, one for each run, which is neither helpful nor performant. - pub traces: Option, - - /// Raw coverage info - pub coverage: Option, -} - -impl FuzzTestResult { - /// Returns the median gas of all test cases - pub fn median_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); - values.sort_unstable(); - calc::median_sorted(&values).to::() - } - - /// Returns the average gas use of all test cases - pub fn mean_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); - values.sort_unstable(); - calc::mean(&values).to::() - } - - fn gas_values(&self, with_stipend: bool) -> Vec { - self.gas_by_case - .iter() - .map(|gas| if with_stipend { gas.0 } else { gas.0.saturating_sub(gas.1) }) - .collect() - } -} - -/// Container type for all successful test cases -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(transparent)] -pub struct FuzzedCases { - cases: Vec, -} - -impl FuzzedCases { - #[inline] - pub fn new(mut cases: Vec) -> Self { - cases.sort_by_key(|c| c.gas); - Self { cases } - } - - #[inline] - pub fn cases(&self) -> &[FuzzCase] { - &self.cases - } - - #[inline] - pub fn into_cases(self) -> Vec { - self.cases - } - - /// Get the last [FuzzCase] - #[inline] - pub fn last(&self) -> Option<&FuzzCase> { - self.cases.last() - } - - /// Returns the median gas of all test cases - #[inline] - pub fn median_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); - values.sort_unstable(); - calc::median_sorted(&values).to::() - } - - /// Returns the average gas use of all test cases - #[inline] - pub fn mean_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); - values.sort_unstable(); - calc::mean(&values).to::() - } - - #[inline] - fn gas_values(&self, with_stipend: bool) -> Vec { - self.cases - .iter() - .map(|c| if with_stipend { c.gas } else { c.gas.saturating_sub(c.stipend) }) - .collect() - } - - /// Returns the case with the highest gas usage - #[inline] - pub fn highest(&self) -> Option<&FuzzCase> { - self.cases.last() - } - - /// Returns the case with the lowest gas usage - #[inline] - pub fn lowest(&self) -> Option<&FuzzCase> { - self.cases.first() - } - - /// Returns the highest amount of gas spent on a fuzz case - #[inline] - pub fn highest_gas(&self, with_stipend: bool) -> u64 { - self.highest() - .map(|c| if with_stipend { c.gas } else { c.gas - c.stipend }) - .unwrap_or_default() - } - - /// Returns the lowest amount of gas spent on a fuzz case - #[inline] - pub fn lowest_gas(&self) -> u64 { - self.lowest().map(|c| c.gas).unwrap_or_default() - } -} diff --git a/crates/evm/src/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs similarity index 68% rename from crates/evm/src/fuzz/types.rs rename to crates/evm/evm/src/executors/fuzz/types.rs index 3ab8c541e0d06..b15cf3faae3ca 100644 --- a/crates/evm/src/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -1,19 +1,11 @@ -use crate::{coverage::HitMaps, debug::DebugArena, executor::RawCallResult, trace::CallTraceArena}; +use crate::executors::RawCallResult; use alloy_primitives::Bytes; use foundry_common::evm::Breakpoints; +use foundry_evm_core::debug::DebugArena; +use foundry_evm_coverage::HitMaps; +use foundry_evm_fuzz::FuzzCase; +use foundry_evm_traces::CallTraceArena; use revm::interpreter::InstructionResult; -use serde::{Deserialize, Serialize}; - -/// Data of a single fuzz test case -#[derive(Clone, Debug, Default, Serialize, Deserialize)] -pub struct FuzzCase { - /// The calldata used for this fuzz test - pub calldata: Bytes, - /// Consumed gas - pub gas: u64, - /// The initial gas stipend for the transaction - pub stipend: u64, -} /// Returned by a single fuzz in the case of a successful run #[derive(Debug)] @@ -34,7 +26,7 @@ pub struct CaseOutcome { #[derive(Debug)] pub struct CounterExampleOutcome { /// Minimal reproduction test case for failing test - pub counterexample: (alloy_primitives::Bytes, RawCallResult), + pub counterexample: (Bytes, RawCallResult), /// The status of the call pub exit_reason: InstructionResult, /// The debug nodes of the call diff --git a/crates/evm/src/fuzz/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs similarity index 80% rename from crates/evm/src/fuzz/invariant/error.rs rename to crates/evm/evm/src/executors/invariant/error.rs index a51a58ccdf930..e948a32111860 100644 --- a/crates/evm/src/fuzz/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -1,16 +1,54 @@ use super::{BasicTxDetails, InvariantContract}; -use crate::{ - decode::decode_revert, - executor::{Executor, RawCallResult}, - fuzz::{invariant::set_up_inner_replay, *}, - trace::{load_contracts, TraceKind, Traces}, - CALLER, -}; +use crate::executors::{Executor, RawCallResult}; use alloy_json_abi::Function; +use alloy_primitives::Address; +use ethers::types::Log; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_evm_core::{constants::CALLER, decode::decode_revert}; +use foundry_evm_fuzz::{BaseCounterExample, CounterExample, FuzzedCases, Reason}; +use foundry_evm_traces::{load_contracts, CallTraceArena, TraceKind, Traces}; +use parking_lot::RwLock; use proptest::test_runner::TestError; use revm::primitives::U256; +use std::sync::Arc; + +#[derive(Clone, Default)] +/// Stores information about failures and reverts of the invariant tests. +pub struct InvariantFailures { + /// Total number of reverts. + pub reverts: usize, + /// How many different invariants have been broken. + pub broken_invariants_count: usize, + /// The latest revert reason of a run. + pub revert_reason: Option, + /// Maps a broken invariant to its specific error. + pub error: Option, +} + +impl InvariantFailures { + pub fn new() -> Self { + Self::default() + } + + pub fn into_inner(self) -> (usize, Option) { + (self.reverts, self.error) + } +} + +/// The outcome of an invariant fuzz test +#[derive(Debug)] +pub struct InvariantFuzzTestResult { + pub error: Option, + /// Every successful fuzz test case + pub cases: Vec, + /// Number of reverted fuzz calls + pub reverts: usize, + + /// The entire inputs of the last run of the invariant campaign, used for + /// replaying the run for collecting traces. + pub last_run_inputs: Vec, +} #[derive(Debug, Clone)] pub struct InvariantFuzzError { @@ -34,7 +72,7 @@ pub struct InvariantFuzzError { impl InvariantFuzzError { pub fn new( - invariant_contract: &InvariantContract, + invariant_contract: &InvariantContract<'_>, error_func: Option<&Function>, calldata: &[BasicTxDetails], call_result: RawCallResult, @@ -238,3 +276,13 @@ impl InvariantFuzzError { shrunk } } + +/// Sets up the calls generated by the internal fuzzer, if they exist. +fn set_up_inner_replay(executor: &mut Executor, inner_sequence: &[Option]) { + if let Some(fuzzer) = &mut executor.inspector.fuzzer { + if let Some(call_generator) = &mut fuzzer.call_generator { + call_generator.last_sequence = Arc::new(RwLock::new(inner_sequence.to_owned())); + call_generator.set_replay(true); + } + } +} diff --git a/crates/evm/src/fuzz/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/funcs.rs similarity index 65% rename from crates/evm/src/fuzz/invariant/mod.rs rename to crates/evm/evm/src/executors/invariant/funcs.rs index 3d32401bc37b0..911c22a5d76c0 100644 --- a/crates/evm/src/fuzz/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -1,55 +1,19 @@ -//! Fuzzing support abstracted over the [`Evm`](crate::Evm) used - -use crate::{ - executor::Executor, - fuzz::*, - trace::{load_contracts, TraceKind, Traces}, - CALLER, -}; +use super::{InvariantFailures, InvariantFuzzError}; +use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; -use alloy_json_abi::{Function, JsonAbi as Abi}; -use alloy_primitives::{Address, Bytes}; -use foundry_common::ContractsByArtifact; -use parking_lot::Mutex; +use alloy_json_abi::Function; +use ethers::types::Log; +use foundry_common::{ContractsByAddress, ContractsByArtifact}; +use foundry_evm_core::constants::CALLER; +use foundry_evm_fuzz::invariant::{BasicTxDetails, InvariantContract}; +use foundry_evm_traces::{load_contracts, TraceKind, Traces}; use revm::primitives::U256; -use std::{collections::BTreeMap, sync::Arc}; - -pub use proptest::test_runner::Config as FuzzConfig; - -mod error; -pub use error::InvariantFuzzError; - -mod call_override; -pub use call_override::{set_up_inner_replay, RandomCallGenerator}; - -mod executor; -pub use executor::{InvariantExecutor, InvariantFailures}; - -mod filters; -pub use filters::{ArtifactFilters, SenderFilters}; - -pub type TargetedContracts = BTreeMap)>; -pub type FuzzRunIdentifiedContracts = Arc>; - -/// (Sender, (TargetContract, Calldata)) -pub type BasicTxDetails = (Address, (Address, Bytes)); - -/// Test contract which is testing its invariants. -#[derive(Debug, Clone)] -pub struct InvariantContract<'a> { - /// Address of the test contract. - pub address: Address, - /// Invariant functions present in the test contract. - pub invariant_function: &'a Function, - /// Abi of the test contract. - pub abi: &'a Abi, -} /// Given the executor state, asserts that no invariant has been broken. Otherwise, it fills the /// external `invariant_failures.failed_invariant` map and returns a generic error. /// Returns the mapping of (Invariant Function Name -> Call Result). pub fn assert_invariants( - invariant_contract: &InvariantContract, + invariant_contract: &InvariantContract<'_>, executor: &Executor, calldata: &[BasicTxDetails], invariant_failures: &mut InvariantFailures, @@ -102,7 +66,7 @@ pub fn assert_invariants( /// Replays the provided invariant run for collecting the logs and traces from all depths. #[allow(clippy::too_many_arguments)] pub fn replay_run( - invariant_contract: &InvariantContract, + invariant_contract: &InvariantContract<'_>, mut executor: Executor, known_contracts: Option<&ContractsByArtifact>, mut ided_contracts: ContractsByAddress, @@ -146,17 +110,3 @@ pub fn replay_run( logs.extend(error_call_result.logs); } } - -/// The outcome of an invariant fuzz test -#[derive(Debug)] -pub struct InvariantFuzzTestResult { - pub error: Option, - /// Every successful fuzz test case - pub cases: Vec, - /// Number of reverted fuzz calls - pub reverts: usize, - - /// The entire inputs of the last run of the invariant campaign, used for - /// replaying the run for collecting traces. - pub last_run_inputs: Vec, -} diff --git a/crates/evm/src/fuzz/invariant/executor.rs b/crates/evm/evm/src/executors/invariant/mod.rs similarity index 94% rename from crates/evm/src/fuzz/invariant/executor.rs rename to crates/evm/evm/src/executors/invariant/mod.rs index 940cfc025dbd4..4c4827b430da1 100644 --- a/crates/evm/src/fuzz/invariant/executor.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -1,23 +1,6 @@ -use super::{ - assert_invariants, - filters::{ArtifactFilters, SenderFilters}, - BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract, InvariantFuzzError, - InvariantFuzzTestResult, RandomCallGenerator, TargetedContracts, -}; use crate::{ - executor::{ - inspector::Fuzzer, Executor, RawCallResult, StateChangeset, CHEATCODE_ADDRESS, - HARDHAT_CONSOLE_ADDRESS, - }, - fuzz::{ - strategies::{ - build_initial_state, collect_created_contracts, collect_state_from_call, - invariant_strat, override_call_strat, EvmFuzzState, - }, - FuzzCase, FuzzedCases, - }, - utils::get_function, - CALLER, + executors::{Executor, RawCallResult}, + inspectors::Fuzzer, }; use alloy_dyn_abi::DynSolValue; use alloy_json_abi::JsonAbi as Abi; @@ -25,6 +8,21 @@ use alloy_primitives::{Address, FixedBytes}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; +use foundry_evm_core::{ + constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, + utils::{get_function, StateChangeset}, +}; +use foundry_evm_fuzz::{ + invariant::{ + ArtifactFilters, BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract, + RandomCallGenerator, SenderFilters, TargetedContracts, + }, + strategies::{ + build_initial_state, collect_created_contracts, collect_state_from_call, invariant_strat, + override_call_strat, EvmFuzzState, + }, + FuzzCase, FuzzedCases, +}; use parking_lot::{Mutex, RwLock}; use proptest::{ strategy::{BoxedStrategy, Strategy, ValueTree}, @@ -36,6 +34,12 @@ use revm::{ }; use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; +mod error; +pub use error::{InvariantFailures, InvariantFuzzError, InvariantFuzzTestResult}; + +mod funcs; +pub use funcs::{assert_invariants, replay_run}; + /// Alias for (Dictionary for fuzzing, initial contracts to fuzz and an InvariantStrategy). type InvariantPreparation = (EvmFuzzState, FuzzRunIdentifiedContracts, BoxedStrategy>); @@ -54,11 +58,11 @@ impl RichInvariantResults { } } -/// Wrapper around any [`Executor`] implementor which provides fuzzing support using [`proptest`](https://docs.rs/proptest/1.0.0/proptest/). +/// Wrapper around any [`Executor`] implementor which provides fuzzing support using [`proptest`]. /// /// After instantiation, calling `fuzz` will proceed to hammer the deployed smart contracts with /// inputs, until it finds a counterexample sequence. The provided [`TestRunner`] contains all the -/// configuration which can be overridden via [environment variables](https://docs.rs/proptest/1.0.0/proptest/test_runner/struct.Config.html) +/// configuration which can be overridden via [environment variables](proptest::test_runner::Config) pub struct InvariantExecutor<'a> { pub executor: Executor, /// Proptest runner. @@ -96,7 +100,7 @@ impl<'a> InvariantExecutor<'a> { /// Fuzzes any deployed contract and checks any broken invariant at `invariant_address`. pub fn invariant_fuzz( &mut self, - invariant_contract: InvariantContract, + invariant_contract: InvariantContract<'_>, ) -> Result { // Throw an error to abort test run if the invariant function accepts input params if !invariant_contract.invariant_function.inputs.is_empty() { @@ -249,7 +253,7 @@ impl<'a> InvariantExecutor<'a> { /// * Invariant Strategy fn prepare_fuzzing( &mut self, - invariant_contract: &InvariantContract, + invariant_contract: &InvariantContract<'_>, ) -> eyre::Result { // Finds out the chosen deployed contracts and/or senders. self.select_contract_artifacts(invariant_contract.address, invariant_contract.abi)?; @@ -715,7 +719,7 @@ fn collect_data( /// asserted. #[allow(clippy::too_many_arguments)] fn can_continue( - invariant_contract: &InvariantContract, + invariant_contract: &InvariantContract<'_>, call_result: RawCallResult, executor: &Executor, calldata: &[BasicTxDetails], @@ -762,26 +766,3 @@ fn can_continue( } RichInvariantResults::new(true, call_results) } - -#[derive(Clone, Default)] -/// Stores information about failures and reverts of the invariant tests. -pub struct InvariantFailures { - /// Total number of reverts. - pub reverts: usize, - /// How many different invariants have been broken. - pub broken_invariants_count: usize, - /// The latest revert reason of a run. - pub revert_reason: Option, - /// Maps a broken invariant to its specific error. - pub error: Option, -} - -impl InvariantFailures { - fn new() -> Self { - Self::default() - } - - fn into_inner(self) -> (usize, Option) { - (self.reverts, self.error) - } -} diff --git a/crates/evm/src/executor/mod.rs b/crates/evm/evm/src/executors/mod.rs similarity index 93% rename from crates/evm/src/executor/mod.rs rename to crates/evm/evm/src/executors/mod.rs index f00b89d0f083c..80a0418d3b819 100644 --- a/crates/evm/src/executor/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -1,79 +1,59 @@ -//! Main Foundry executor abstractions, which can execute calls. +//! EVM executor abstractions, which can execute calls. +//! //! Used for running tests, scripts, and interacting with the inner backend which holds the state. -use self::inspector::{cheatcodes::util::BroadcastableTransactions, Cheatcodes, InspectorData}; -use crate::{ - debug::DebugArena, - decode, - trace::CallTraceArena, - utils::{eval_to_instruction_result, halt_to_instruction_result}, - CALLER, -}; -pub use abi::{ - patch_hardhat_console_selector, HardhatConsoleCalls, CHEATCODE_ADDRESS, CONSOLE_ABI, - HARDHAT_CONSOLE_ABI, HARDHAT_CONSOLE_ADDRESS, +// TODO: The individual executors in this module should be moved into the respective craits, and the +// `Executor` struct should be accessed using a trait defined in `foundry-evm-core` instead of +// the concrete `Executor` type. + +use crate::inspectors::{ + cheatcodes::util::BroadcastableTransactions, Cheatcodes, InspectorData, InspectorStack, }; use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi as Abi}; -/// Reexport commonly used revm types -pub use alloy_primitives::{Address, Bytes, U256}; -use backend::FuzzBackendWrapper; +use alloy_primitives::{Address, Bytes, U256}; use ethers::{signers::LocalWallet, types::Log}; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; -use revm::primitives::hex_literal::hex; -pub use revm::{ +use foundry_evm_core::{ + backend::{Backend, DatabaseError, DatabaseExt, DatabaseResult, FuzzBackendWrapper}, + constants::{ + CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, + }, + debug::DebugArena, + decode, + utils::{eval_to_instruction_result, halt_to_instruction_result, StateChangeset}, +}; +use foundry_evm_coverage::HitMaps; +use foundry_evm_traces::CallTraceArena; +use revm::{ db::{DatabaseCommit, DatabaseRef}, interpreter::{return_ok, CreateScheme, InstructionResult, Memory, Stack}, primitives::{ - Account, BlockEnv, Bytecode, Env, ExecutionResult, HashMap, Output, ResultAndState, SpecId, - TransactTo, TxEnv, + BlockEnv, Bytecode, Env, ExecutionResult, Output, ResultAndState, SpecId, TransactTo, TxEnv, }, }; use std::collections::BTreeMap; -/// ABIs used internally in the executor -pub mod abi; -/// custom revm database implementations -pub mod backend; -pub use backend::Backend; -/// Executor builder -pub mod builder; -/// Forking provider -pub mod fork; -/// Executor inspectors -pub mod inspector; -/// Executor configuration -pub mod opts; -pub mod snapshot; - -use crate::{ - coverage::HitMaps, - executor::{ - backend::{ - error::{DatabaseError, DatabaseResult}, - DatabaseExt, - }, - inspector::{InspectorStack, DEFAULT_CREATE2_DEPLOYER}, - }, -}; +mod builder; pub use builder::ExecutorBuilder; -/// A mapping of addresses to their changed state. -pub type StateChangeset = HashMap; +pub mod fuzz; +pub use fuzz::FuzzedExecutor; + +pub mod invariant; +pub use invariant::InvariantExecutor; -/// The initcode of the default create2 deployer. -pub const DEFAULT_CREATE2_DEPLOYER_CODE: &[u8] = &hex!("604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); -/// The runtime code of the default create2 deployer. -pub const DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE: &[u8] = &hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); +mod tracing; +pub use tracing::TracingExecutor; /// A type that can execute calls /// /// The executor can be configured with various `revm::Inspector`s, like `Cheatcodes`. /// /// There are two ways of executing calls: -/// - `committing`: any state changes made during the call are recorded and are persisting -/// - `raw`: state changes only exist for the duration of the call and are discarded afterwards, in -/// other words: the state of the underlying database remains unchanged. +/// - `committing`: any state changes made during the call are recorded and are persisting +/// - `raw`: state changes only exist for the duration of the call and are discarded afterwards, in +/// other words: the state of the underlying database remains unchanged. #[derive(Debug, Clone)] pub struct Executor { /// The underlying `revm::Database` that contains the EVM storage. @@ -92,8 +72,6 @@ pub struct Executor { gas_limit: U256, } -// === impl Executor === - impl Executor { #[inline] pub fn new(mut backend: Backend, env: Env, inspector: InspectorStack, gas_limit: U256) -> Self { diff --git a/crates/evm/src/trace/executor.rs b/crates/evm/evm/src/executors/tracing.rs similarity index 93% rename from crates/evm/src/trace/executor.rs rename to crates/evm/evm/src/executors/tracing.rs index f23a40a4bdd8a..5734355afcc89 100644 --- a/crates/evm/src/trace/executor.rs +++ b/crates/evm/evm/src/executors/tracing.rs @@ -1,6 +1,7 @@ -use crate::executor::{fork::CreateFork, opts::EvmOpts, Backend, Executor, ExecutorBuilder}; +use crate::executors::{Executor, ExecutorBuilder}; use foundry_compilers::EvmVersion; use foundry_config::{utils::evm_spec_id, Config}; +use foundry_evm_core::{backend::Backend, fork::CreateFork, opts::EvmOpts}; use revm::primitives::Env; use std::ops::{Deref, DerefMut}; diff --git a/crates/evm/src/executor/inspector/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs similarity index 100% rename from crates/evm/src/executor/inspector/access_list.rs rename to crates/evm/evm/src/inspectors/access_list.rs diff --git a/crates/evm/src/executor/inspector/cheatcodes/config.rs b/crates/evm/evm/src/inspectors/cheatcodes/config.rs similarity index 99% rename from crates/evm/src/executor/inspector/cheatcodes/config.rs rename to crates/evm/evm/src/inspectors/cheatcodes/config.rs index 58438c238b9e2..fffb65febd3f9 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/config.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/config.rs @@ -1,11 +1,11 @@ use super::{ensure, fmt_err, Result}; -use crate::executor::opts::EvmOpts; use foundry_common::fs::normalize_path; use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, ResolvedRpcEndpoints, }; +use foundry_evm_core::opts::EvmOpts; use std::path::{Path, PathBuf}; /// Additional, configurable context the `Cheatcodes` inspector has access to diff --git a/crates/evm/src/executor/inspector/cheatcodes/env.rs b/crates/evm/evm/src/inspectors/cheatcodes/env.rs similarity index 98% rename from crates/evm/src/executor/inspector/cheatcodes/env.rs rename to crates/evm/evm/src/inspectors/cheatcodes/env.rs index 6de3d2d2af947..6137fc645507c 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/env.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/env.rs @@ -1,19 +1,14 @@ -use super::{ensure, fmt_err, Cheatcodes, Result}; -use crate::{ - abi::HEVMCalls, - executor::{ - backend::DatabaseExt, - inspector::cheatcodes::{ - mapping::{get_mapping_key_and_parent, get_mapping_length, get_mapping_slot_at}, - util::{is_potential_precompile, with_journaled_account}, - DealRecord, - }, - }, +use super::{ + ensure, fmt_err, + mapping::{get_mapping_key_and_parent, get_mapping_length, get_mapping_slot_at}, + util::{is_potential_precompile, with_journaled_account}, + Cheatcodes, DealRecord, Result, }; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Address, Bytes, Log, B256, U256}; use ethers::signers::{LocalWallet, Signer}; use foundry_config::Config; +use foundry_evm_core::{abi::HEVMCalls, backend::DatabaseExt}; use foundry_utils::types::ToAlloy; use revm::{ primitives::{Bytecode, SpecId, KECCAK_EMPTY}, diff --git a/crates/evm/src/executor/inspector/cheatcodes/error.rs b/crates/evm/evm/src/inspectors/cheatcodes/error.rs similarity index 80% rename from crates/evm/src/executor/inspector/cheatcodes/error.rs rename to crates/evm/evm/src/inspectors/cheatcodes/error.rs index a67163a0d14e7..a30c80f6679f7 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/error.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/error.rs @@ -1,9 +1,9 @@ -use crate::executor::backend::{error::NoCheatcodeAccessError, DatabaseError}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::Bytes; use ethers::prelude::k256::ecdsa::signature::Error as SignatureError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; +use foundry_evm_core::backend::{DatabaseError, NoCheatcodeAccessError}; use foundry_utils::error::{encode_error, SolError}; use std::{borrow::Cow, fmt::Arguments}; @@ -12,49 +12,49 @@ pub type Result = std::result::Result; macro_rules! fmt_err { ($msg:literal $(,)?) => { - $crate::executor::inspector::cheatcodes::Error::fmt(::std::format_args!($msg)) + $crate::inspectors::cheatcodes::Error::fmt(::std::format_args!($msg)) }; ($err:expr $(,)?) => { - <$crate::executor::inspector::cheatcodes::Error as ::std::convert::From<_>>::from($err) + <$crate::inspectors::cheatcodes::Error as ::std::convert::From<_>>::from($err) }; ($fmt:expr, $($arg:tt)*) => { - $crate::executor::inspector::cheatcodes::Error::fmt(::std::format_args!($fmt, $($arg)*)) + $crate::inspectors::cheatcodes::Error::fmt(::std::format_args!($fmt, $($arg)*)) }; } macro_rules! bail { ($msg:literal $(,)?) => { - return ::std::result::Result::Err($crate::executor::inspector::cheatcodes::fmt_err!($msg)) + return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($msg)) }; ($err:expr $(,)?) => { - return ::std::result::Result::Err($crate::executor::inspector::cheatcodes::fmt_err!($err)) + return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($err)) }; ($fmt:expr, $($arg:tt)*) => { - return ::std::result::Result::Err($crate::executor::inspector::cheatcodes::fmt_err!($fmt, $($arg)*)) + return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($fmt, $($arg)*)) }; } macro_rules! ensure { ($cond:expr $(,)?) => { if !$cond { - return ::std::result::Result::Err($crate::executor::inspector::cheatcodes::Error::custom( + return ::std::result::Result::Err($crate::inspectors::cheatcodes::Error::custom( ::std::concat!("Condition failed: `", ::std::stringify!($cond), "`") )); } }; ($cond:expr, $msg:literal $(,)?) => { if !$cond { - return ::std::result::Result::Err($crate::executor::inspector::cheatcodes::fmt_err!($msg)); + return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($msg)); } }; ($cond:expr, $err:expr $(,)?) => { if !$cond { - return ::std::result::Result::Err($crate::executor::inspector::cheatcodes::fmt_err!($err)); + return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($err)); } }; ($cond:expr, $fmt:expr, $($arg:tt)*) => { if !$cond { - return ::std::result::Result::Err($crate::executor::inspector::cheatcodes::fmt_err!($fmt, $($arg)*)); + return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($fmt, $($arg)*)); } }; } diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/evm/src/inspectors/cheatcodes/expect.rs similarity index 98% rename from crates/evm/src/executor/inspector/cheatcodes/expect.rs rename to crates/evm/evm/src/inspectors/cheatcodes/expect.rs index a14344a92e966..00d245427f1bc 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/expect.rs @@ -1,7 +1,7 @@ use super::{bail, ensure, fmt_err, Cheatcodes, Result}; -use crate::{abi::HEVMCalls, executor::backend::DatabaseExt}; use alloy_dyn_abi::DynSolType; use alloy_primitives::{Address, Bytes, Log as RawLog, U256}; +use foundry_evm_core::{abi::HEVMCalls, backend::DatabaseExt}; use foundry_utils::{ error::{ERROR_PREFIX, REVERT_PREFIX}, types::ToAlloy, @@ -502,9 +502,7 @@ pub fn apply( .as_ref() .map_or(true, Bytecode::is_empty); if empty_bytecode { - let code = - Bytecode::new_raw(alloy_primitives::Bytes(bytes::Bytes::from_static(&[0u8]))) - .to_checked(); + let code = Bytecode::new_raw(Bytes::from_static(&[0u8])).to_checked(); data.journaled_state.set_code(inner.0.to_alloy(), code); } state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( diff --git a/crates/evm/src/executor/inspector/cheatcodes/ext.rs b/crates/evm/evm/src/inspectors/cheatcodes/ext.rs similarity index 99% rename from crates/evm/src/executor/inspector/cheatcodes/ext.rs rename to crates/evm/evm/src/inspectors/cheatcodes/ext.rs index 2d48b34488f92..0d5d805819b90 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/ext.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/ext.rs @@ -1,10 +1,10 @@ -use super::{bail, ensure, fmt_err, util::MAGIC_SKIP_BYTES, Cheatcodes, Error, Result}; -use crate::{abi::HEVMCalls, executor::inspector::cheatcodes::parse}; +use super::{bail, ensure, fmt_err, parse, Cheatcodes, Error, Result}; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{Address, Bytes, B256, I256, U256}; use ethers::{abi::JsonAbi, prelude::artifacts::CompactContractBytecode}; use foundry_common::{fmt::*, fs, get_artifact_path}; use foundry_config::fs_permissions::FsAccessKind; +use foundry_evm_core::{abi::HEVMCalls, constants::MAGIC_SKIP_BYTES}; use foundry_utils::types::ToAlloy; use revm::{Database, EVMData}; use serde::Deserialize; @@ -757,7 +757,7 @@ pub fn apply( #[cfg(test)] mod tests { use super::*; - use crate::executor::inspector::CheatsConfig; + use crate::inspectors::CheatsConfig; use ethers::core::abi::AbiDecode; use std::{path::PathBuf, sync::Arc}; diff --git a/crates/evm/src/executor/inspector/cheatcodes/fork.rs b/crates/evm/evm/src/inspectors/cheatcodes/fork.rs similarity index 96% rename from crates/evm/src/executor/inspector/cheatcodes/fork.rs rename to crates/evm/evm/src/inspectors/cheatcodes/fork.rs index b6c38cd0ec650..a0c0e2dd57aea 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fork.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/fork.rs @@ -1,16 +1,12 @@ -use super::{fmt_err, Cheatcodes, Error, Result}; -use crate::{ - abi::HEVMCalls, - executor::{ - backend::DatabaseExt, fork::CreateFork, inspector::cheatcodes::ext::value_to_token, - }, - utils::RuntimeOrHandle, -}; +use super::{ext::value_to_token, fmt_err, Cheatcodes, Error, Result}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Bytes, B256, U256}; use ethers::{providers::Middleware, types::Filter}; use foundry_abi::hevm::{EthGetLogsCall, RpcCall}; use foundry_common::ProviderBuilder; +use foundry_evm_core::{ + abi::HEVMCalls, backend::DatabaseExt, fork::CreateFork, utils::RuntimeOrHandle, +}; use foundry_utils::types::{ToAlloy, ToEthers}; use itertools::Itertools; use revm::EVMData; @@ -166,7 +162,7 @@ pub fn apply( } HEVMCalls::Transact0(inner) => data .db - .transact(None, inner.0.into(), data.env, &mut data.journaled_state, Some(state)) + .transact(None, inner.0.into(), data.env, &mut data.journaled_state, state) .map(empty) .map_err(Into::into), HEVMCalls::Transact1(inner) => data @@ -176,7 +172,7 @@ pub fn apply( inner.1.into(), data.env, &mut data.journaled_state, - Some(state), + state, ) .map(empty) .map_err(Into::into), @@ -190,7 +186,7 @@ pub fn apply( /// Selects the given fork id fn select_fork( state: &mut Cheatcodes, - data: &mut EVMData, + data: &mut EVMData<'_, DB>, fork_id: U256, ) -> Result { if state.broadcast.is_some() { @@ -275,7 +271,7 @@ fn create_fork_request( state: &Cheatcodes, url_or_alias: String, block: Option, - data: &EVMData, + data: &EVMData<'_, DB>, ) -> Result { let url = state.config.get_rpc_url(url_or_alias)?; let mut evm_opts = state.config.evm_opts.clone(); @@ -291,7 +287,7 @@ fn create_fork_request( /// Retrieve the logs specified for the current fork. /// Equivalent to eth_getLogs but on a cheatcode. -fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> Result { +fn eth_getlogs(data: &EVMData<'_, DB>, inner: &EthGetLogsCall) -> Result { let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; if inner.0.to_alloy() > U256::from(u64::MAX) || inner.1.to_alloy() > U256::from(u64::MAX) { return Err(fmt_err!("Blocks in block range must be less than 2^64 - 1")) @@ -392,7 +388,7 @@ fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> R Ok(result) } -fn rpc(data: &EVMData, inner: &RpcCall) -> Result { +fn rpc(data: &EVMData<'_, DB>, inner: &RpcCall) -> Result { let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; let provider = ProviderBuilder::new(url).build()?; diff --git a/crates/evm/src/executor/inspector/cheatcodes/fs.rs b/crates/evm/evm/src/inspectors/cheatcodes/fs.rs similarity index 99% rename from crates/evm/src/executor/inspector/cheatcodes/fs.rs rename to crates/evm/evm/src/inspectors/cheatcodes/fs.rs index e59d08a7344f8..67d8da783d42b 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fs.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/fs.rs @@ -1,9 +1,9 @@ use super::{Cheatcodes, Result}; -use crate::abi::hevm::{DirEntry, FsMetadata, HEVMCalls}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Bytes, U256}; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; +use foundry_evm_core::abi::hevm::{DirEntry, FsMetadata, HEVMCalls}; use foundry_utils::types::ToAlloy; use std::{ io::{BufRead, BufReader, Write}, diff --git a/crates/evm/src/executor/inspector/cheatcodes/fuzz.rs b/crates/evm/evm/src/inspectors/cheatcodes/fuzz.rs similarity index 86% rename from crates/evm/src/executor/inspector/cheatcodes/fuzz.rs rename to crates/evm/evm/src/inspectors/cheatcodes/fuzz.rs index e833abdb402e2..de92ae6e8d704 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fuzz.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/fuzz.rs @@ -1,6 +1,6 @@ use super::{Error, Result}; -use crate::{abi::HEVMCalls, fuzz::error::ASSUME_MAGIC_RETURN_CODE}; use alloy_primitives::Bytes; +use foundry_evm_core::{abi::HEVMCalls, constants::ASSUME_MAGIC_RETURN_CODE}; #[instrument(level = "error", name = "fuzz", target = "evm::cheatcodes", skip_all)] pub fn apply(call: &HEVMCalls) -> Option { diff --git a/crates/evm/src/executor/inspector/cheatcodes/mapping.rs b/crates/evm/evm/src/inspectors/cheatcodes/mapping.rs similarity index 100% rename from crates/evm/src/executor/inspector/cheatcodes/mapping.rs rename to crates/evm/evm/src/inspectors/cheatcodes/mapping.rs diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/evm/src/inspectors/cheatcodes/mod.rs similarity index 99% rename from crates/evm/src/executor/inspector/cheatcodes/mod.rs rename to crates/evm/evm/src/inspectors/cheatcodes/mod.rs index 9dab9c7f0e737..e9cc1736506a7 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/mod.rs @@ -1,15 +1,8 @@ use self::{ - env::Broadcast, + env::{Broadcast, RecordedLogs}, expect::{handle_expect_emit, handle_expect_revert, ExpectedCallType}, mapping::MappingSlots, - util::{check_if_fixed_gas_limit, process_create, BroadcastableTransactions, MAGIC_SKIP_BYTES}, -}; -use crate::{ - abi::HEVMCalls, - executor::{ - backend::DatabaseExt, inspector::cheatcodes::env::RecordedLogs, CHEATCODE_ADDRESS, - HARDHAT_CONSOLE_ADDRESS, - }, + util::{check_if_fixed_gas_limit, process_create, BroadcastableTransactions}, }; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; @@ -19,6 +12,12 @@ use ethers::{ types::{transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest}, }; use foundry_common::evm::Breakpoints; +use foundry_evm_core::{ + abi::HEVMCalls, + backend::{DatabaseExt, RevertDiagnostic}, + constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP_BYTES}, + utils::get_create_address, +}; use foundry_utils::{error::SolError, types::ToEthers}; use itertools::Itertools; use revm::{ @@ -64,10 +63,10 @@ mod snapshot; pub mod util; /// Wallet / key management related cheatcodes mod wallet; -pub use util::{BroadcastableTransaction, DEFAULT_CREATE2_DEPLOYER}; + +pub use util::BroadcastableTransaction; mod config; -use crate::executor::{backend::RevertDiagnostic, inspector::utils::get_create_address}; pub use config::CheatsConfig; mod error; @@ -926,7 +925,7 @@ impl Inspector for Cheatcodes { return ( status, remaining_gas, - DynSolValue::String(err.to_error_msg(self)).abi_encode().into(), + DynSolValue::String(err.to_error_msg(&self.labels)).abi_encode().into(), ) } } diff --git a/crates/evm/src/executor/inspector/cheatcodes/parse.rs b/crates/evm/evm/src/inspectors/cheatcodes/parse.rs similarity index 99% rename from crates/evm/src/executor/inspector/cheatcodes/parse.rs rename to crates/evm/evm/src/inspectors/cheatcodes/parse.rs index 322fd510b57c9..d91d9a9d7c591 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/parse.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/parse.rs @@ -1,7 +1,7 @@ use super::{fmt_err, Cheatcodes, Result}; -use crate::abi::HEVMCalls; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{FixedBytes, I256, U256}; +use foundry_evm_core::abi::HEVMCalls; use foundry_macros::UIfmt; use revm::{Database, EVMData}; diff --git a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs b/crates/evm/evm/src/inspectors/cheatcodes/snapshot.rs similarity index 94% rename from crates/evm/src/executor/inspector/cheatcodes/snapshot.rs rename to crates/evm/evm/src/inspectors/cheatcodes/snapshot.rs index c2daff5cdc24d..ac37696474158 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/snapshot.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/snapshot.rs @@ -1,6 +1,6 @@ use super::Result; -use crate::{abi::HEVMCalls, executor::backend::DatabaseExt}; use alloy_dyn_abi::DynSolValue; +use foundry_evm_core::{abi::HEVMCalls, backend::DatabaseExt}; use foundry_utils::types::ToAlloy; use revm::EVMData; diff --git a/crates/evm/src/executor/inspector/cheatcodes/util.rs b/crates/evm/evm/src/inspectors/cheatcodes/util.rs similarity index 75% rename from crates/evm/src/executor/inspector/cheatcodes/util.rs rename to crates/evm/evm/src/inspectors/cheatcodes/util.rs index b21af6b1dce7e..93ce81dc1c816 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/util.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/util.rs @@ -1,37 +1,20 @@ use super::{ensure, Result}; -use crate::{ - executor::backend::{ - error::{DatabaseError, DatabaseResult}, - DatabaseExt, - }, - utils::h256_to_u256_be, -}; use alloy_primitives::{Address, Bytes, U256}; use bytes::{BufMut, BytesMut}; use ethers::{ core::k256::elliptic_curve::Curve, - prelude::{ - k256::{ecdsa::SigningKey, elliptic_curve::bigint::Encoding, Secp256k1}, - Transaction, - }, + prelude::k256::{ecdsa::SigningKey, elliptic_curve::bigint::Encoding, Secp256k1}, types::{transaction::eip2718::TypedTransaction, NameOrAddress}, }; use foundry_common::RpcUrl; -use foundry_utils::types::{ToAlloy, ToEthers}; -use revm::{ - interpreter::CreateInputs, - primitives::{Account, TransactTo}, - Database, EVMData, JournaledState, +use foundry_evm_core::{ + backend::{DatabaseError, DatabaseExt, DatabaseResult}, + constants::DEFAULT_CREATE2_DEPLOYER, }; +use foundry_utils::types::ToEthers; +use revm::{interpreter::CreateInputs, primitives::Account, Database, EVMData, JournaledState}; use std::collections::VecDeque; -pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; - -/// Address of the default CREATE2 deployer 0x4e59b44847b379578588920ca78fbf26c0b4956c -pub const DEFAULT_CREATE2_DEPLOYER: Address = Address::new([ - 78, 89, 180, 72, 71, 179, 121, 87, 133, 136, 146, 12, 167, 143, 191, 38, 192, 180, 149, 108, -]); - /// Helps collecting transactions from different forks. #[derive(Debug, Clone, Default)] pub struct BroadcastableTransaction { @@ -41,32 +24,6 @@ pub struct BroadcastableTransaction { pub type BroadcastableTransactions = VecDeque; -/// Configures the env for the transaction -pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { - env.tx.caller = tx.from.to_alloy(); - env.tx.gas_limit = tx.gas.as_u64(); - env.tx.gas_price = tx.gas_price.unwrap_or_default().to_alloy(); - env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(|g| g.to_alloy()); - env.tx.nonce = Some(tx.nonce.as_u64()); - env.tx.access_list = tx - .access_list - .clone() - .unwrap_or_default() - .0 - .into_iter() - .map(|item| { - ( - item.address.to_alloy(), - item.storage_keys.into_iter().map(h256_to_u256_be).map(|g| g.to_alloy()).collect(), - ) - }) - .collect(); - env.tx.value = tx.value.to_alloy(); - env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); - env.tx.transact_to = - tx.to.map(|tx| tx.to_alloy()).map(TransactTo::Call).unwrap_or_else(TransactTo::create) -} - /// Applies the given function `f` to the `revm::Account` belonging to the `addr` /// /// This will ensure the `Account` is loaded and `touched`, see [`JournaledState::touch`] diff --git a/crates/evm/src/executor/inspector/cheatcodes/wallet.rs b/crates/evm/evm/src/inspectors/cheatcodes/wallet.rs similarity index 99% rename from crates/evm/src/executor/inspector/cheatcodes/wallet.rs rename to crates/evm/evm/src/inspectors/cheatcodes/wallet.rs index a3cebf34f1d2a..87105ea4a19be 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/wallet.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/wallet.rs @@ -1,5 +1,4 @@ use super::{ensure, Cheatcodes, Result}; -use crate::abi::HEVMCalls; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{keccak256, B256, U256}; use ethers::{ @@ -21,6 +20,7 @@ use ethers::{ }, utils, }; +use foundry_evm_core::abi::HEVMCalls; use foundry_utils::types::{ToAlloy, ToEthers}; use revm::{Database, EVMData}; use std::str::FromStr; diff --git a/crates/evm/src/executor/inspector/chisel_state.rs b/crates/evm/evm/src/inspectors/chisel_state.rs similarity index 100% rename from crates/evm/src/executor/inspector/chisel_state.rs rename to crates/evm/evm/src/inspectors/chisel_state.rs diff --git a/crates/evm/src/executor/inspector/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs similarity index 96% rename from crates/evm/src/executor/inspector/debugger.rs rename to crates/evm/evm/src/inspectors/debugger.rs index 2e59b1f700298..e4c1e67ec8f04 100644 --- a/crates/evm/src/executor/inspector/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -1,13 +1,10 @@ -use crate::{ +use alloy_primitives::{Address, Bytes}; +use foundry_evm_core::{ + backend::DatabaseExt, + constants::CHEATCODE_ADDRESS, debug::{DebugArena, DebugNode, DebugStep, Instruction}, - executor::{ - backend::DatabaseExt, - inspector::utils::{gas_used, get_create_address}, - CHEATCODE_ADDRESS, - }, - CallKind, + utils::{gas_used, get_create_address, CallKind}, }; -use alloy_primitives::{Address, Bytes}; use foundry_utils::error::SolError; use revm::{ interpreter::{ diff --git a/crates/evm/src/executor/inspector/logs.rs b/crates/evm/evm/src/inspectors/logs.rs similarity index 95% rename from crates/evm/src/executor/inspector/logs.rs rename to crates/evm/evm/src/inspectors/logs.rs index a0c1d8be2adf0..8ad4cb648e77b 100644 --- a/crates/evm/src/executor/inspector/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,11 +1,12 @@ -use crate::executor::{ - patch_hardhat_console_selector, HardhatConsoleCalls, HARDHAT_CONSOLE_ADDRESS, -}; use alloy_primitives::{Address, Bytes, B256}; use ethers::{ abi::{AbiDecode, Token}, types::{Bytes as ethersBytes, Log, H256}, }; +use foundry_evm_core::{ + abi::{patch_hardhat_console_selector, HardhatConsoleCalls}, + constants::HARDHAT_CONSOLE_ADDRESS, +}; use foundry_macros::ConsoleFmt; use foundry_utils::types::ToEthers; use revm::{ diff --git a/crates/evm/evm/src/inspectors/mod.rs b/crates/evm/evm/src/inspectors/mod.rs new file mode 100644 index 0000000000000..89ba94cfa243a --- /dev/null +++ b/crates/evm/evm/src/inspectors/mod.rs @@ -0,0 +1,36 @@ +//! EVM inspectors. + +pub use foundry_evm_coverage::CoverageCollector; +pub use foundry_evm_fuzz::Fuzzer; +pub use foundry_evm_traces::Tracer; + +macro_rules! try_or_continue { + ($e:expr) => { + match $e { + Ok(v) => v, + Err(_) => return InstructionResult::Continue, + } + }; +} + +mod access_list; +pub use access_list::AccessListTracer; + +#[allow(unreachable_pub)] +pub mod cheatcodes; +pub use cheatcodes::{Cheatcodes, CheatsConfig}; + +mod chisel_state; +pub use chisel_state::ChiselState; + +mod debugger; +pub use debugger::Debugger; + +mod logs; +pub use logs::LogCollector; + +mod printer; +pub use printer::TracePrinter; + +mod stack; +pub use stack::{InspectorData, InspectorStack, InspectorStackBuilder}; diff --git a/crates/evm/src/executor/inspector/printer.rs b/crates/evm/evm/src/inspectors/printer.rs similarity index 100% rename from crates/evm/src/executor/inspector/printer.rs rename to crates/evm/evm/src/inspectors/printer.rs diff --git a/crates/evm/src/executor/inspector/stack.rs b/crates/evm/evm/src/inspectors/stack.rs similarity index 98% rename from crates/evm/src/executor/inspector/stack.rs rename to crates/evm/evm/src/inspectors/stack.rs index 71e95c81fae6a..1b63955660a41 100644 --- a/crates/evm/src/executor/inspector/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -1,15 +1,12 @@ use super::{ - Cheatcodes, CheatsConfig, ChiselState, Debugger, Fuzzer, LogCollector, TracePrinter, Tracer, -}; -use crate::{ - coverage::HitMaps, - debug::DebugArena, - executor::{backend::DatabaseExt, inspector::CoverageCollector}, - trace::CallTraceArena, + Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Debugger, Fuzzer, LogCollector, + TracePrinter, Tracer, }; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers::{signers::LocalWallet, types::Log}; - +use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; +use foundry_evm_coverage::HitMaps; +use foundry_evm_traces::CallTraceArena; use revm::{ interpreter::{ return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, Stack, diff --git a/crates/evm/evm/src/lib.rs b/crates/evm/evm/src/lib.rs new file mode 100644 index 0000000000000..7c69c1823831d --- /dev/null +++ b/crates/evm/evm/src/lib.rs @@ -0,0 +1,20 @@ +//! # foundry-evm +//! +//! Main Foundry EVM backend abstractions. + +#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] + +#[macro_use] +extern crate tracing; + +pub mod executors; +pub mod inspectors; + +pub use foundry_evm_core::{backend, constants, debug, decode, fork, opts, utils}; +pub use foundry_evm_coverage as coverage; +pub use foundry_evm_fuzz as fuzz; +pub use foundry_evm_traces as traces; + +// TODO: We should probably remove these, but it's a pretty big breaking change. +#[doc(hidden)] +pub use {hashbrown, revm}; diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml new file mode 100644 index 0000000000000..bec6bdbb6542f --- /dev/null +++ b/crates/evm/fuzz/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "foundry-evm-fuzz" +description = "EVM fuzzing implementation using `proptest`" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +foundry-common.workspace = true +foundry-compilers.workspace = true +foundry-config.workspace = true +foundry-evm-coverage.workspace = true +foundry-evm-core.workspace = true +foundry-evm-traces.workspace = true +foundry-utils.workspace = true + +alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-json-abi = { workspace = true } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +ethers = { workspace = true, features = ["ethers-solc"] } +revm = { workspace = true, default-features = false, features = [ + "std", + "serde", + "memory_limit", + "optional_eip3607", + "optional_block_gas_limit", + "optional_no_base_fee", + "arbitrary", +] } + +arbitrary = "1.3.1" +eyre = "0.6" +hashbrown = { version = "0.14", features = ["serde"] } +parking_lot = "0.12" +proptest = "1" +serde = "1" +thiserror = "1" +tracing = "0.1" diff --git a/crates/evm/src/fuzz/error.rs b/crates/evm/fuzz/src/error.rs similarity index 84% rename from crates/evm/src/fuzz/error.rs rename to crates/evm/fuzz/src/error.rs index fc3e6279600bd..145afa5e72743 100644 --- a/crates/evm/src/fuzz/error.rs +++ b/crates/evm/fuzz/src/error.rs @@ -1,9 +1,6 @@ //! errors related to fuzz tests use proptest::test_runner::Reason; -/// Magic return code for the `assume` cheatcode -pub const ASSUME_MAGIC_RETURN_CODE: &[u8] = b"FOUNDRY::ASSUME"; - /// Possible errors when running fuzz tests #[derive(Debug, thiserror::Error)] pub enum FuzzError { diff --git a/crates/evm/src/executor/inspector/fuzzer.rs b/crates/evm/fuzz/src/inspector.rs similarity index 97% rename from crates/evm/src/executor/inspector/fuzzer.rs rename to crates/evm/fuzz/src/inspector.rs index f738a26e1a8b4..fe1b76c58a250 100644 --- a/crates/evm/src/executor/inspector/fuzzer.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -1,8 +1,6 @@ -use crate::{ - fuzz::{invariant::RandomCallGenerator, strategies::EvmFuzzState}, - utils, -}; +use crate::{invariant::RandomCallGenerator, strategies::EvmFuzzState}; use alloy_primitives::Bytes; +use foundry_evm_core::utils; use foundry_utils::types::ToEthers; use revm::{ interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, diff --git a/crates/evm/src/fuzz/invariant/call_override.rs b/crates/evm/fuzz/src/invariant/call_override.rs similarity index 87% rename from crates/evm/src/fuzz/invariant/call_override.rs rename to crates/evm/fuzz/src/invariant/call_override.rs index 2739e79fbc155..c9a0b4ff10357 100644 --- a/crates/evm/src/fuzz/invariant/call_override.rs +++ b/crates/evm/fuzz/src/invariant/call_override.rs @@ -1,5 +1,4 @@ use super::BasicTxDetails; -use crate::executor::Executor; use alloy_primitives::{Address, Bytes}; use parking_lot::{Mutex, RwLock}; use proptest::{ @@ -90,13 +89,3 @@ impl RandomCallGenerator { } } } - -/// Sets up the calls generated by the internal fuzzer, if they exist. -pub fn set_up_inner_replay(executor: &mut Executor, inner_sequence: &[Option]) { - if let Some(fuzzer) = &mut executor.inspector.fuzzer { - if let Some(call_generator) = &mut fuzzer.call_generator { - call_generator.last_sequence = Arc::new(RwLock::new(inner_sequence.to_owned())); - call_generator.set_replay(true); - } - } -} diff --git a/crates/evm/src/fuzz/invariant/filters.rs b/crates/evm/fuzz/src/invariant/filters.rs similarity index 98% rename from crates/evm/src/fuzz/invariant/filters.rs rename to crates/evm/fuzz/src/invariant/filters.rs index 32c8704ca197d..3561ef9d66728 100644 --- a/crates/evm/src/fuzz/invariant/filters.rs +++ b/crates/evm/fuzz/src/invariant/filters.rs @@ -1,7 +1,7 @@ -use crate::utils::get_function; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, Selector}; use foundry_compilers::ArtifactId; +use foundry_evm_core::utils::get_function; use std::collections::BTreeMap; /// Contains which contracts are to be targeted or excluded on an invariant test through their diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs new file mode 100644 index 0000000000000..d7fbf09ec0c90 --- /dev/null +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -0,0 +1,27 @@ +use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_primitives::{Address, Bytes}; +use parking_lot::Mutex; +use std::{collections::BTreeMap, sync::Arc}; + +mod call_override; +pub use call_override::RandomCallGenerator; + +mod filters; +pub use filters::{ArtifactFilters, SenderFilters}; + +pub type TargetedContracts = BTreeMap)>; +pub type FuzzRunIdentifiedContracts = Arc>; + +/// (Sender, (TargetContract, Calldata)) +pub type BasicTxDetails = (Address, (Address, Bytes)); + +/// Test contract which is testing its invariants. +#[derive(Debug, Clone)] +pub struct InvariantContract<'a> { + /// Address of the test contract. + pub address: Address, + /// Invariant functions present in the test contract. + pub invariant_function: &'a Function, + /// Abi of the test contract. + pub abi: &'a Abi, +} diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs new file mode 100644 index 0000000000000..ae95e16b8e895 --- /dev/null +++ b/crates/evm/fuzz/src/lib.rs @@ -0,0 +1,275 @@ +//! # foundry-evm-fuzz +//! +//! EVM fuzzing implementation using [`proptest`]. + +#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] + +#[macro_use] +extern crate tracing; + +use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; +use alloy_primitives::{Address, Bytes, U256}; +use ethers::types::Log; +use foundry_common::{calc, contracts::ContractsByAddress}; +use foundry_evm_coverage::HitMaps; +use foundry_evm_traces::CallTraceArena; +use serde::{Deserialize, Serialize}; +use std::{collections::BTreeMap, fmt}; + +pub use proptest::test_runner::{Config as FuzzConfig, Reason}; + +mod error; +pub use error::FuzzError; + +pub mod invariant; +pub mod strategies; + +mod inspector; +pub use inspector::Fuzzer; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum CounterExample { + /// Call used as a counter example for fuzz tests. + Single(BaseCounterExample), + /// Sequence of calls used as a counter example for invariant tests. + Sequence(Vec), +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct BaseCounterExample { + /// Address which makes the call + pub sender: Option
, + /// Address to which to call to + pub addr: Option
, + /// The data to provide + pub calldata: Bytes, + /// Function signature if it exists + pub signature: Option, + /// Contract name if it exists + pub contract_name: Option, + /// Traces + pub traces: Option, + #[serde(skip)] + pub args: Vec, +} + +impl BaseCounterExample { + pub fn create( + sender: Address, + addr: Address, + bytes: &Bytes, + contracts: &ContractsByAddress, + traces: Option, + ) -> Self { + if let Some((name, abi)) = &contracts.get(&addr) { + if let Some(func) = abi.functions().find(|f| f.selector() == bytes[..4]) { + // skip the function selector when decoding + if let Ok(args) = func.abi_decode_input(&bytes[4..], false) { + return BaseCounterExample { + sender: Some(sender), + addr: Some(addr), + calldata: bytes.clone(), + signature: Some(func.signature()), + contract_name: Some(name.clone()), + traces, + args, + } + } + } + } + + BaseCounterExample { + sender: Some(sender), + addr: Some(addr), + calldata: bytes.clone(), + signature: None, + contract_name: None, + traces, + args: vec![], + } + } +} + +impl fmt::Display for BaseCounterExample { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let args = foundry_common::abi::format_tokens(&self.args).collect::>().join(", "); + + if let Some(sender) = self.sender { + write!(f, "sender={sender} addr=")? + } + + if let Some(name) = &self.contract_name { + write!(f, "[{name}]")? + } + + if let Some(addr) = &self.addr { + write!(f, "{addr} ")? + } + + if let Some(sig) = &self.signature { + write!(f, "calldata={sig}")? + } else { + write!(f, "calldata=0x{}", self.calldata)? + } + + write!(f, ", args=[{args}]") + } +} + +/// The outcome of a fuzz test +#[derive(Debug)] +pub struct FuzzTestResult { + /// we keep this for the debugger + pub first_case: FuzzCase, + /// Gas usage (gas_used, call_stipend) per cases + pub gas_by_case: Vec<(u64, u64)>, + /// Whether the test case was successful. This means that the transaction executed + /// properly, or that there was a revert and that the test was expected to fail + /// (prefixed with `testFail`) + pub success: bool, + + /// If there was a revert, this field will be populated. Note that the test can + /// still be successful (i.e self.success == true) when it's expected to fail. + pub reason: Option, + + /// Minimal reproduction test case for failing fuzz tests + pub counterexample: Option, + + /// Any captured & parsed as strings logs along the test's execution which should + /// be printed to the user. + pub logs: Vec, + + /// The decoded DSTest logging events and Hardhat's `console.log` from [logs](Self::logs). + pub decoded_logs: Vec, + + /// Labeled addresses + pub labeled_addresses: BTreeMap, + + /// Exemplary traces for a fuzz run of the test function + /// + /// **Note** We only store a single trace of a successful fuzz call, otherwise we would get + /// `num(fuzz_cases)` traces, one for each run, which is neither helpful nor performant. + pub traces: Option, + + /// Raw coverage info + pub coverage: Option, +} + +impl FuzzTestResult { + /// Returns the median gas of all test cases + pub fn median_gas(&self, with_stipend: bool) -> u64 { + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + values.sort_unstable(); + calc::median_sorted(&values).to::() + } + + /// Returns the average gas use of all test cases + pub fn mean_gas(&self, with_stipend: bool) -> u64 { + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + values.sort_unstable(); + calc::mean(&values).to::() + } + + fn gas_values(&self, with_stipend: bool) -> Vec { + self.gas_by_case + .iter() + .map(|gas| if with_stipend { gas.0 } else { gas.0.saturating_sub(gas.1) }) + .collect() + } +} + +/// Data of a single fuzz test case +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct FuzzCase { + /// The calldata used for this fuzz test + pub calldata: Bytes, + /// Consumed gas + pub gas: u64, + /// The initial gas stipend for the transaction + pub stipend: u64, +} + +/// Container type for all successful test cases +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct FuzzedCases { + cases: Vec, +} + +impl FuzzedCases { + #[inline] + pub fn new(mut cases: Vec) -> Self { + cases.sort_by_key(|c| c.gas); + Self { cases } + } + + #[inline] + pub fn cases(&self) -> &[FuzzCase] { + &self.cases + } + + #[inline] + pub fn into_cases(self) -> Vec { + self.cases + } + + /// Get the last [FuzzCase] + #[inline] + pub fn last(&self) -> Option<&FuzzCase> { + self.cases.last() + } + + /// Returns the median gas of all test cases + #[inline] + pub fn median_gas(&self, with_stipend: bool) -> u64 { + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + values.sort_unstable(); + calc::median_sorted(&values).to::() + } + + /// Returns the average gas use of all test cases + #[inline] + pub fn mean_gas(&self, with_stipend: bool) -> u64 { + let mut values = + self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + values.sort_unstable(); + calc::mean(&values).to::() + } + + #[inline] + fn gas_values(&self, with_stipend: bool) -> Vec { + self.cases + .iter() + .map(|c| if with_stipend { c.gas } else { c.gas.saturating_sub(c.stipend) }) + .collect() + } + + /// Returns the case with the highest gas usage + #[inline] + pub fn highest(&self) -> Option<&FuzzCase> { + self.cases.last() + } + + /// Returns the case with the lowest gas usage + #[inline] + pub fn lowest(&self) -> Option<&FuzzCase> { + self.cases.first() + } + + /// Returns the highest amount of gas spent on a fuzz case + #[inline] + pub fn highest_gas(&self, with_stipend: bool) -> u64 { + self.highest() + .map(|c| if with_stipend { c.gas } else { c.gas - c.stipend }) + .unwrap_or_default() + } + + /// Returns the lowest amount of gas spent on a fuzz case + #[inline] + pub fn lowest_gas(&self) -> u64 { + self.lowest().map(|c| c.gas).unwrap_or_default() + } +} diff --git a/crates/evm/src/fuzz/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs similarity index 81% rename from crates/evm/src/fuzz/strategies/calldata.rs rename to crates/evm/fuzz/src/strategies/calldata.rs index 93d914543b73e..2d07e83ac9465 100644 --- a/crates/evm/src/fuzz/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -1,7 +1,5 @@ -use std::str::FromStr; - use super::fuzz_param; -use alloy_dyn_abi::{DynSolType, JsonAbiExt}; +use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::Bytes; use proptest::prelude::{BoxedStrategy, Strategy}; @@ -14,7 +12,7 @@ pub fn fuzz_calldata(func: Function) -> BoxedStrategy { let strats = func .inputs .iter() - .map(|input| fuzz_param(&DynSolType::from_str(&input.selector_type()).unwrap())) + .map(|input| fuzz_param(&input.selector_type().parse().unwrap())) .collect::>(); strats diff --git a/crates/evm/src/fuzz/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs similarity index 100% rename from crates/evm/src/fuzz/strategies/int.rs rename to crates/evm/fuzz/src/strategies/int.rs diff --git a/crates/evm/src/fuzz/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs similarity index 97% rename from crates/evm/src/fuzz/strategies/invariants.rs rename to crates/evm/fuzz/src/strategies/invariants.rs index c842fc45ce729..62be1b6eb57d4 100644 --- a/crates/evm/src/fuzz/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -1,16 +1,14 @@ use super::fuzz_param_from_state; -use crate::fuzz::{ - fuzz_calldata, fuzz_calldata_from_state, +use crate::{ invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, SenderFilters}, - strategies::fuzz_param, - EvmFuzzState, + strategies::{fuzz_calldata, fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, }; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes}; use parking_lot::RwLock; use proptest::prelude::*; -pub use proptest::test_runner::Config as FuzzConfig; use std::{rc::Rc, sync::Arc}; + /// Given a target address, we generate random calldata. pub fn override_call_strat( fuzz_state: EvmFuzzState, @@ -37,6 +35,7 @@ pub fn override_call_strat( }) .sboxed() } + /// Creates the invariant strategy. /// /// Given the known and future contracts, it generates the next call by fuzzing the `caller`, @@ -57,6 +56,7 @@ pub fn invariant_strat( // state generate_call(fuzz_state, senders, contracts, dictionary_weight).prop_map(|x| vec![x]) } + /// Strategy to generate a transaction where the `sender`, `target` and `calldata` are all generated /// through specific strategies. fn generate_call( @@ -80,6 +80,7 @@ fn generate_call( }) .boxed() } + /// Strategy to select a sender address: /// * If `senders` is empty, then it's either a random address (10%) or from the dictionary (90%). /// * If `senders` is not empty, a random address is chosen from the list of senders. @@ -114,6 +115,7 @@ fn select_random_sender( fuzz_strategy } } + /// Strategy to randomly select a contract from the `contracts` list that has at least 1 function fn select_random_contract( contracts: FuzzRunIdentifiedContracts, @@ -126,6 +128,7 @@ fn select_random_contract( (*addr, abi.clone(), functions.clone()) }) } + /// Strategy to select a random mutable function from the abi. /// /// If `targeted_functions` is not empty, select one from it. Otherwise, take any @@ -154,6 +157,7 @@ fn select_random_function(abi: Abi, targeted_functions: Vec) -> BoxedS total_random.boxed() } } + /// Given a function, it returns a proptest strategy which generates valid abi-encoded calldata /// for that function's input types. pub fn fuzz_contract_with_calldata( diff --git a/crates/evm/src/fuzz/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs similarity index 79% rename from crates/evm/src/fuzz/strategies/mod.rs rename to crates/evm/fuzz/src/strategies/mod.rs index 8add232c89532..a795905de95ac 100644 --- a/crates/evm/src/fuzz/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -1,6 +1,7 @@ mod int; -mod uint; pub use int::IntStrategy; + +mod uint; pub use uint::UintStrategy; mod param; @@ -16,4 +17,4 @@ pub use state::{ }; mod invariants; -pub use invariants::*; +pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call_strat}; diff --git a/crates/evm/src/fuzz/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs similarity index 98% rename from crates/evm/src/fuzz/strategies/param.rs rename to crates/evm/fuzz/src/strategies/param.rs index 428d8432c04dc..09fbfe590bc2f 100644 --- a/crates/evm/src/fuzz/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -5,7 +5,8 @@ use arbitrary::Unstructured; use proptest::prelude::*; /// The max length of arrays we fuzz for is 256. -pub const MAX_ARRAY_LEN: usize = 256; +const MAX_ARRAY_LEN: usize = 256; + /// Given a parameter type, returns a strategy for generating values for that type. /// /// Works with ABI Encoder v2 tuples. @@ -164,7 +165,7 @@ pub fn fuzz_param_from_state( #[cfg(test)] mod tests { - use crate::fuzz::strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state}; + use crate::strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state}; use alloy_json_abi::Function; use foundry_config::FuzzDictionaryConfig; use revm::db::{CacheDB, EmptyDB}; diff --git a/crates/evm/src/fuzz/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs similarity index 96% rename from crates/evm/src/fuzz/strategies/state.rs rename to crates/evm/fuzz/src/strategies/state.rs index 44f32c2498da2..e09531938d7d5 100644 --- a/crates/evm/src/fuzz/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,15 +1,12 @@ use super::fuzz_param_from_state; -use crate::{ - executor::StateChangeset, - fuzz::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}, -}; +use crate::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}; use alloy_dyn_abi::{DynSolType, JsonAbiExt}; use alloy_json_abi::Function; -use alloy_primitives::{Address, B256, U256}; -use bytes::Bytes; +use alloy_primitives::{Address, Bytes, B256, U256}; use ethers::types::Log; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; +use foundry_evm_core::utils::StateChangeset; use foundry_utils::types::ToEthers; use hashbrown::HashSet; use parking_lot::RwLock; @@ -25,6 +22,7 @@ use std::{fmt, io::Write, str::FromStr, sync::Arc}; /// /// Wrapped in a shareable container. pub type EvmFuzzState = Arc>; + #[derive(Default)] pub struct FuzzDictionary { /// Collected state values. @@ -32,6 +30,7 @@ pub struct FuzzDictionary { /// Addresses that already had their PUSH bytes collected. addresses: HashSet
, } + impl fmt::Debug for FuzzDictionary { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FuzzDictionary") @@ -40,30 +39,32 @@ impl fmt::Debug for FuzzDictionary { .finish() } } + impl FuzzDictionary { #[inline] pub fn values(&self) -> &HashSet<[u8; 32]> { &self.state_values } + #[inline] pub fn values_mut(&mut self) -> &mut HashSet<[u8; 32]> { &mut self.state_values } + #[inline] pub fn addresses(&mut self) -> &HashSet
{ &self.addresses } + #[inline] pub fn addresses_mut(&mut self) -> &mut HashSet
{ &mut self.addresses } } + /// Given a function and some state, it returns a strategy which generated valid calldata for the /// given function's input types, based on state taken from the EVM. -pub fn fuzz_calldata_from_state( - func: Function, - state: EvmFuzzState, -) -> BoxedStrategy { +pub fn fuzz_calldata_from_state(func: Function, state: EvmFuzzState) -> BoxedStrategy { let strats = func .inputs .iter() @@ -89,6 +90,7 @@ pub fn fuzz_calldata_from_state( .no_shrink() .boxed() } + /// Builds the initial [EvmFuzzState] from a database. pub fn build_initial_state( db: &CacheDB, @@ -105,12 +107,13 @@ pub fn build_initial_state( if config.include_push_bytes { if let Some(code) = &account.info.code { if state.addresses_mut().insert(address) { - for push_byte in collect_push_bytes(code.bytes().clone().0) { + for push_byte in collect_push_bytes(code.bytes()) { state.values_mut().insert(push_byte); } } } } + if config.include_storage { // Insert storage for (slot, value) in &account.storage { @@ -128,6 +131,7 @@ pub fn build_initial_state( } } } + // need at least some state data if db is empty otherwise we can't select random data for state // fuzzing if state.values().is_empty() { @@ -137,6 +141,7 @@ pub fn build_initial_state( Arc::new(RwLock::new(state)) } + /// Collects state changes from a [StateChangeset] and logs into an [EvmFuzzState] according to the /// given [FuzzDictionaryConfig]. pub fn collect_state_from_call( @@ -156,12 +161,13 @@ pub fn collect_state_from_call( // Insert push bytes if let Some(code) = &account.info.code { if state.addresses_mut().insert(*address) { - for push_byte in collect_push_bytes(code.bytes().clone().0) { + for push_byte in collect_push_bytes(code.bytes()) { state.values_mut().insert(push_byte); } } } } + if config.include_storage && state.state_values.len() < config.max_fuzz_dictionary_values { // Insert storage for (slot, value) in &account.storage { @@ -181,6 +187,7 @@ pub fn collect_state_from_call( } else { return } + // Insert log topics and data for log in logs { log.topics.iter().for_each(|topic| { @@ -196,13 +203,15 @@ pub fn collect_state_from_call( } } } + /// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). /// /// This is to limit the performance impact of fuzz tests that might deploy arbitrarily sized /// bytecode (as is the case with Solmate). const PUSH_BYTE_ANALYSIS_LIMIT: usize = 24 * 1024; + /// Collects all push bytes from the given bytecode. -fn collect_push_bytes(code: Bytes) -> Vec<[u8; 32]> { +fn collect_push_bytes(code: &[u8]) -> Vec<[u8; 32]> { let mut bytes: Vec<[u8; 32]> = Vec::new(); // We use [SpecId::LATEST] since we do not really care what spec it is - we are not interested // in gas costs. @@ -236,6 +245,7 @@ fn collect_push_bytes(code: Bytes) -> Vec<[u8; 32]> { } bytes } + /// Collects all created contracts from a StateChangeset which haven't been discovered yet. Stores /// them at `targeted_contracts` and `created_contracts`. pub fn collect_created_contracts( diff --git a/crates/evm/src/fuzz/strategies/uint.rs b/crates/evm/fuzz/src/strategies/uint.rs similarity index 100% rename from crates/evm/src/fuzz/strategies/uint.rs rename to crates/evm/fuzz/src/strategies/uint.rs diff --git a/crates/evm/src/executor/abi/mod.rs b/crates/evm/src/executor/abi/mod.rs deleted file mode 100644 index ecd17a870beb2..0000000000000 --- a/crates/evm/src/executor/abi/mod.rs +++ /dev/null @@ -1,1212 +0,0 @@ -//! Several ABI-related utilities for executors. - -use alloy_json_abi::JsonAbi; -use alloy_primitives::Address; -pub use foundry_abi::{ - console::{self, ConsoleEvents}, - hardhat_console::{self, HardhatConsoleCalls}, - hevm::{self, HEVMCalls}, -}; -use once_cell::sync::Lazy; -use std::collections::HashMap; - -/// The cheatcode handler address (0x7109709ECfa91a80626fF3989D68f67F5b1DD12D). -/// -/// This is the same address as the one used in DappTools's HEVM. -/// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))` -pub const CHEATCODE_ADDRESS: Address = Address::new([ - 0x71, 0x09, 0x70, 0x9E, 0xcf, 0xa9, 0x1a, 0x80, 0x62, 0x6f, 0xf3, 0x98, 0x9d, 0x68, 0xf6, 0x7f, - 0x5b, 0x1d, 0xd1, 0x2d, -]); - -/// The Hardhat console address (0x000000000000000000636F6e736F6c652e6c6f67). -/// -/// See: https://github.com/nomiclabs/hardhat/blob/master/packages/hardhat-core/console.sol -pub const HARDHAT_CONSOLE_ADDRESS: Address = Address::new([ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, - 0x2e, 0x6c, 0x6f, 0x67, -]); - -/// If the input starts with a known `hardhat/console.log` `uint` selector, then this will replace -/// it with the selector `abigen!` bindings expect. -pub fn patch_hardhat_console_selector(input: &mut Vec) { - if input.len() < 4 { - return - } - let selector = unsafe { &mut *(input.get_unchecked_mut(..4) as *mut [u8] as *mut [u8; 4]) }; - if let Some(abigen_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { - *selector = *abigen_selector; - } -} - -pub static HEVM_ABI: Lazy = Lazy::new(|| { - // TODO: Move to file & find a way to sync with actual HEVM.sol - JsonAbi::parse([ - "function allowCheatcodes(address)", -"function tryFfi(string[])(tuple(int32,bytes,bytes))", -"function ffi(string[])(bytes)", -"function breakpoint(string)", -"function breakpoint(string,bool)", -"function roll(uint256)", -"function warp(uint256)", -"function difficulty(uint256)", -"function prevrandao(bytes32)", -"function fee(uint256)", -"function coinbase(address)", -"function store(address,bytes32,bytes32)", -"function load(address,bytes32)(bytes32)", -"function cool(address)", -"function setEnv(string,string)", -"function envBool(string)(bool)", -"function envUint(string)(uint256)", -"function envInt(string)(int256)", -"function envAddress(string)(address)", -"function envBytes32(string)(bytes32)", -"function envString(string)(string)", -"function envBytes(string)(bytes)", -"function envBool(string,string)(bool[])", -"function envUint(string,string)(uint256[])", -"function envInt(string,string)(int256[])", -"function envAddress(string,string)(address[])", -"function envBytes32(string,string)(bytes32[])", -"function envString(string,string)(string[])", -"function envBytes(string,string)(bytes[])", -"function envOr(string,bool)(bool)", -"function envOr(string,uint256)(uint256)", -"function envOr(string,int256)(int256)", -"function envOr(string,address)(address)", -"function envOr(string,bytes32)(bytes32)", -"function envOr(string,string)(string)", -"function envOr(string,bytes)(bytes)", -"function envOr(string,string,bool[])(bool[])", -"function envOr(string,string,uint256[])(uint256[])", -"function envOr(string,string,int256[])(int256[])", -"function envOr(string,string,address[])(address[])", -"function envOr(string,string,bytes32[])(bytes32[])", -"function envOr(string,string,string[])(string[])", -"function envOr(string,string,bytes[])(bytes[])", -"function addr(uint256)(address)", -"function sign(uint256,bytes32)(uint8,bytes32,bytes32)", -"function deriveKey(string,uint32)(uint256)", -"function deriveKey(string,string,uint32)(uint256)", -"function deriveKey(string,uint32,string)(uint256)", -"function deriveKey(string,string,uint32,string)(uint256)", -"function rememberKey(uint256)(address)", -"function createWallet(string)(tuple(address,uint256,uint256,uint256))", -"function createWallet(uint256)(tuple(address,uint256,uint256,uint256))", -"function createWallet(uint256,string)(tuple(address,uint256,uint256,uint256))", -"function sign(tuple(address,uint256,uint256,uint256),bytes32)(uint8,bytes32,bytes32)", -"function getNonce(tuple(address,uint256,uint256,uint256))(uint64)", -"function prank(address)", -"function prank(address,address)", -"function readCallers()(uint256,address,address)", -"function startPrank(address)", -"function startPrank(address,address)", -"function stopPrank()", -"function deal(address,uint256)", -"function etch(address,bytes)", -"function expectRevert()", -"function expectRevert(bytes)", -"function expectRevert(bytes4)", -"function record()", -"function accesses(address)(bytes32[], bytes32[])", -"function skip(bool)", -"function recordLogs()", -"function getRecordedLogs()(tuple(bytes32,bytes)[])", -"function expectEmit()", -"function expectEmit(address)", -"function expectEmit(bool,bool,bool,bool)", -"function expectEmit(bool,bool,bool,bool,address)", -"function mockCall(address,bytes,bytes)", -"function mockCall(address,uint256,bytes,bytes)", -"function mockCallRevert(address,bytes,bytes)", -"function mockCallRevert(address,uint256,bytes,bytes)", -"function clearMockedCalls()", -"function expectCall(address,bytes)", -"function expectCall(address,bytes,uint64)", -"function expectCall(address,uint256,bytes)", -"function expectCall(address,uint256,bytes,uint64)", -"function expectCall(address,uint256,uint64,bytes)", -"function expectCall(address,uint256,uint64,bytes,uint64)", -"function expectCallMinGas(address,uint256,uint64,bytes)", -"function expectCallMinGas(address,uint256,uint64,bytes,uint64)", -"function expectSafeMemory(uint64,uint64)", -"function expectSafeMemoryCall(uint64,uint64)", -"function getCode(string)", -"function getDeployedCode(string)", -"function label(address,string)", -"function getLabel(address)(string)", -"function assume(bool)", -"function setNonce(address,uint64)", -"function getNonce(address)", -"function resetNonce(address)", -"function setNonceUnsafe(address,uint64)", -"function chainId(uint256)", -"function txGasPrice(uint256)", -"function broadcast()", -"function broadcast(address)", -"function broadcast(uint256)", -"function startBroadcast()", -"function startBroadcast(address)", -"function startBroadcast(uint256)", -"function stopBroadcast()", -"function projectRoot()(string)", -"function openFile(string)", -"function readFile(string)(string)", -"function readFileBinary(string)(bytes)", -"function readLine(string)(string)", -"function writeFile(string,string)", -"function writeFileBinary(string,bytes)", -"function writeLine(string,string)", -"function copyFile(string,string)", -"function closeFile(string)", -"function removeFile(string)", -"function createDir(string, bool)", -"function removeDir(string, bool)", -"function readDir(string)(tuple(string,string,uint64,bool,bool)[])", -"function readDir(string, uint64)(tuple(string,string,uint64,bool,bool)[])", -"function readDir(string, uint64, bool)(tuple(string,string,uint64,bool,bool)[])", -"function readLink(string)(string)", -"function fsMetadata(string)(tuple(bool,bool,uint256,bool,uint256,uint256,uint256))", -"function exists(string)(bool)", -"function isFile(string)(bool)", -"function isDir(string)(bool)", -"function toString(bytes)", -"function toString(address)", -"function toString(uint256)", -"function toString(int256)", -"function toString(bytes32)", -"function toString(bool)", -"function parseBytes(string)(bytes)", -"function parseAddress(string)(address)", -"function parseUint(string)(uint256)", -"function parseInt(string)(int256)", -"function parseBytes32(string)(bytes32)", -"function parseBool(string)(bool)", -"function snapshot()(uint256)", -"function revertTo(uint256)(bool)", -"function createFork(string,uint256)(uint256)", -"function createFork(string,bytes32)(uint256)", -"function createFork(string)(uint256)", -"function createSelectFork(string,uint256)(uint256)", -"function createSelectFork(string,bytes32)(uint256)", -"function createSelectFork(string)(uint256)", -"function selectFork(uint256)", -"function activeFork()(uint256)", -"function transact(bytes32)", -"function transact(uint256,bytes32)", -"function makePersistent(address)", -"function makePersistent(address,address)", -"function makePersistent(address,address,address)", -"function makePersistent(address[])", -"function revokePersistent(address)", -"function revokePersistent(address[])", -"function isPersistent(address)(bool)", -"function rollFork(uint256)", -"function rollFork(bytes32)", -"function rollFork(uint256,uint256)", -"function rollFork(uint256,bytes32)", -"function rpcUrl(string)(string)", -"function rpcUrls()(string[2][])", -"function rpcUrlStructs()(tuple(string,string)[])", -"function eth_getLogs(uint256,uint256,address,bytes32[])(tuple(address,bytes32[],bytes,uint256,bytes32,uint256,bytes32,uint256,bool)[])", -"function rpc(string,string)(bytes)", -"function writeJson(string, string)", -"function writeJson(string, string, string)", -"function parseJson(string)(bytes)", -"function parseJson(string, string)(bytes)", -"function parseJsonKeys(string, string)(string[])", -"function parseJsonUint(string, string)(uint256)", -"function parseJsonUintArray(string, string)(uint256[])", -"function parseJsonInt(string, string)(int256)", -"function parseJsonIntArray(string, string)(int256[])", -"function parseJsonString(string, string)(string)", -"function parseJsonStringArray(string, string)(string[])", -"function parseJsonAddress(string, string)(address)", -"function parseJsonAddressArray(string, string)(address[])", -"function parseJsonBool(string, string)(bool)", -"function parseJsonBoolArray(string, string)(bool[])", -"function parseJsonBytes(string, string)(bytes)", -"function parseJsonBytesArray(string, string)(bytes[])", -"function parseJsonBytes32(string, string)(bytes32)", -"function parseJsonBytes32Array(string, string)(bytes32[])", -"function serializeJson(string,string)(string)", -"function serializeBool(string,string,bool)(string)", -"function serializeBool(string,string,bool[])(string)", -"function serializeUint(string,string,uint256)(string)", -"function serializeUint(string,string,uint256[])(string)", -"function serializeInt(string,string,int256)(string)", -"function serializeInt(string,string,int256[])(string)", -"function serializeAddress(string,string,address)(string)", -"function serializeAddress(string,string,address[])(string)", -"function serializeBytes32(string,string,bytes32)(string)", -"function serializeBytes32(string,string,bytes32[])(string)", -"function serializeString(string,string,string)(string)", -"function serializeString(string,string,string[])(string)", -"function serializeBytes(string,string,bytes)(string)", -"function serializeBytes(string,string,bytes[])(string)", -"function keyExists(string,string)(bool)", -"function pauseGasMetering()", -"function resumeGasMetering()", -"function startMappingRecording()", -"function stopMappingRecording()", -"function getMappingLength(address,bytes32)", -"function getMappingSlotAt(address,bytes32,uint256)", -"function getMappingKeyAndParentOf(address,bytes32)", -"function sleep(uint256)", -"function unixTime()(uint256)", - ]).expect("Could not parse HEVM abi") -}); - -pub static HARDHAT_CONSOLE_ABI: Lazy = Lazy::new(|| { - // TODO: Move to file - JsonAbi::parse([ - "function log(address p0, address p1, string p2)", - "function log(bool p0, uint256 p1, uint256 p2, address p3)", - "function log(address p0, address p1, address p2)", - "function log(uint256 p0, address p1, address p2, string p3)", - "function log(string p0, address p1, bool p2, string p3)", - "function log(uint256 p0, bool p1, address p2, uint256 p3)", - "function log(bool p0, address p1, bool p2, uint256 p3)", - "function log(bool p0, uint256 p1, address p2)", - "function log(uint256 p0, address p1, address p2, bool p3)", - "function log(address p0, bool p1, uint256 p2, string p3)", - "function log(bool p0, bool p1, uint256 p2, uint256 p3)", - "function log(bool p0, address p1, address p2, uint256 p3)", - "function log(uint256 p0, address p1, uint256 p2, uint256 p3)", - "function log(string p0, address p1, uint256 p2)", - "function log(address p0, string p1, address p2, address p3)", - "function log(address p0, string p1, address p2, bool p3)", - "function log(address p0, address p1, address p2, bool p3)", - "function log(address p0, string p1, uint256 p2, bool p3)", - "function log(address p0, uint256 p1, address p2, uint256 p3)", - "function log(string p0, string p1, uint256 p2, address p3)", - "function log(bool p0, bool p1, address p2)", - "function log(bool p0, string p1, uint256 p2)", - "function log(bool p0, string p1, address p2, string p3)", - "function log(bool p0, bool p1, uint256 p2)", - "function log(bool p0, address p1, uint256 p2, address p3)", - "function log(bool p0, uint256 p1, address p2, uint256 p3)", - "function log(bool p0, string p1, uint256 p2, address p3)", - "function log(address p0, string p1, string p2, uint256 p3)", - "function log(uint256 p0, address p1, uint256 p2, address p3)", - "function log(uint256 p0, uint256 p1, address p2, bool p3)", - "function log(bool p0, string p1, bool p2, uint256 p3)", - "function log(bool p0, string p1, string p2, string p3)", - "function log(address p0, address p1, uint256 p2)", - "function log(bool p0, address p1, bool p2)", - "function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3)", - "function log(address p0, bool p1, string p2, address p3)", - "function log(bool p0, string p1, uint256 p2, string p3)", - "function log(bool p0, uint256 p1, address p2, string p3)", - "function log(bool p0, address p1, bool p2, address p3)", - "function log(string p0, uint256 p1, address p2)", - "function log(uint256 p0, bool p1)", - "function log(bool p0, address p1, address p2, address p3)", - "function log(address p0, uint256 p1, address p2, string p3)", - "function log(address p0, string p1, uint256 p2, uint256 p3)", - "function log(bool p0, string p1, string p2, bool p3)", - "function log(uint256 p0, bool p1, uint256 p2)", - "function log(address p0, string p1, bool p2, address p3)", - "function log(uint256 p0, bool p1, bool p2)", - "function log(address p0, uint256 p1, uint256 p2, address p3)", - "function log(address p0, bool p1, string p2)", - "function log(uint256 p0, string p1, string p2, string p3)", - "function log(address p0, address p1, string p2, string p3)", - "function log(string p0, address p1, bool p2, address p3)", - "function log(address p0, uint256 p1, bool p2, uint256 p3)", - "function log(string p0, address p1, string p2, string p3)", - "function log(uint256 p0, address p1, address p2, address p3)", - "function log(string p0, bool p1, string p2, uint256 p3)", - "function log(bool p0, bool p1, string p2)", - "function log(bool p0, uint256 p1, address p2, address p3)", - "function log(uint256 p0, uint256 p1, string p2, string p3)", - "function log(bool p0, string p1, uint256 p2, uint256 p3)", - "function log(bool p0, bool p1)", - "function log(bool p0, bool p1, bool p2, string p3)", - "function log(bool p0, string p1, address p2, address p3)", - "function log(string p0, string p1, string p2, bool p3)", - "function log(uint256 p0, bool p1, string p2, uint256 p3)", - "function log(address p0)", - "function log(address p0, address p1, bool p2, bool p3)", - "function log(string p0, string p1, string p2)", - "function log(string p0, bool p1, address p2, string p3)", - "function log(address p0, bool p1, address p2, string p3)", - "function log(string p0, address p1)", - "function log(bool p0)", - "function log(string p0, bool p1, address p2, address p3)", - "function log(address p0, uint256 p1, uint256 p2, uint256 p3)", - "function log(uint256 p0, bool p1, address p2)", - "function log(string p0, uint256 p1, bool p2, bool p3)", - "function log(address p0, string p1, string p2, bool p3)", - "function log(bool p0, uint256 p1, uint256 p2)", - "function log(bool p0, uint256 p1, uint256 p2, uint256 p3)", - "function log(uint256 p0, string p1, uint256 p2)", - "function log(address p0, bool p1, uint256 p2, uint256 p3)", - "function log(address p0, address p1, bool p2, uint256 p3)", - "function log(bool p0, uint256 p1)", - "function log(uint256 p0, string p1, uint256 p2, address p3)", - "function log(bool p0, bool p1, bool p2, bool p3)", - "function log(address p0, uint256 p1, bool p2, bool p3)", - "function log(uint256 p0, address p1, string p2, string p3)", - "function log(string p0, address p1, bool p2, uint256 p3)", - "function log(string p0, bool p1, string p2, bool p3)", - "function log(string p0, string p1, bool p2, bool p3)", - "function log(string p0)", - "function log(uint256 p0, uint256 p1, string p2, address p3)", - "function log(string p0, string p1, address p2, address p3)", - "function log(address p0, string p1, uint256 p2, string p3)", - "function log(uint256 p0, bool p1, address p2, bool p3)", - "function log(address p0, string p1, address p2, uint256 p3)", - "function log(bool p0, address p1, address p2, bool p3)", - "function log(uint256 p0, address p1, string p2, uint256 p3)", - "function log(address p0, bool p1, string p2, string p3)", - "function log(uint256 p0, uint256 p1, bool p2)", - "function log(address p0, uint256 p1, address p2, address p3)", - "function log(bool p0, string p1, bool p2, string p3)", - "function log(address p0, uint256 p1, uint256 p2, string p3)", - "function log(bool p0, address p1, bool p2, string p3)", - "function log(string p0, string p1)", - "function log(bool p0, bool p1, address p2, uint256 p3)", - "function log(uint256 p0, string p1, bool p2)", - "function log(string p0, uint256 p1, address p2, uint256 p3)", - "function log(bool p0, bool p1, bool p2)", - "function log(address p0, bool p1, string p2, bool p3)", - "function log(address p0, string p1, bool p2, uint256 p3)", - "function log()", - "function log(bool p0, address p1, uint256 p2, string p3)", - "function log(bool p0, string p1, bool p2, address p3)", - "function log(bool p0, bool p1, uint256 p2, address p3)", - "function log(uint256 p0, uint256 p1, address p2, address p3)", - "function log(string p0, string p1, uint256 p2)", - "function log(string p0, uint256 p1, string p2)", - "function log(uint256 p0, uint256 p1, uint256 p2, string p3)", - "function log(string p0, address p1, uint256 p2, string p3)", - "function log(uint256 p0, address p1, uint256 p2)", - "function log(string p0, uint256 p1, string p2, string p3)", - "function log(uint256 p0, address p1, bool p2, uint256 p3)", - "function log(address p0, uint256 p1, string p2, address p3)", - "function log(uint256 p0, uint256 p1, address p2)", - "function log(string p0, string p1, address p2, bool p3)", - "function log(address p0, string p1, string p2, string p3)", - "function log(string p0, bool p1, address p2, uint256 p3)", - "function log(string p0, string p1, uint256 p2, string p3)", - "function log(uint256 p0, uint256 p1, string p2, uint256 p3)", - "function log(string p0, string p1, bool p2, string p3)", - "function log(string p0, uint256 p1, address p2, address p3)", - "function log(string p0, address p1, string p2, bool p3)", - "function log(address p0, string p1, bool p2, bool p3)", - "function log(uint256 p0, address p1, uint256 p2, bool p3)", - "function log(bool p0, address p1, uint256 p2)", - "function log(uint256 p0, string p1, address p2, address p3)", - "function log(bool p0, bool p1, uint256 p2, bool p3)", - "function log(address p0, string p1, uint256 p2, address p3)", - "function log(uint256 p0, address p1, string p2)", - "function log(string p0, address p1, uint256 p2, address p3)", - "function log(uint256 p0, string p1)", - "function log(string p0, bool p1, uint256 p2, uint256 p3)", - "function log(address p0, bool p1, address p2, address p3)", - "function log(address p0, address p1, address p2, address p3)", - "function log(address p0, uint256 p1, uint256 p2, bool p3)", - "function log(address p0, uint256 p1, bool p2)", - "function log(address p0, string p1, uint256 p2)", - "function log(uint256 p0, bool p1, string p2, string p3)", - "function log(uint256 p0, string p1, uint256 p2, bool p3)", - "function log(uint256 p0, address p1)", - "function log(uint256 p0, bool p1, bool p2, address p3)", - "function log(bool p0, uint256 p1, string p2, uint256 p3)", - "function log(bool p0, address p1, bool p2, bool p3)", - "function log(bool p0, string p1, uint256 p2, bool p3)", - "function log(uint256 p0, uint256 p1, address p2, string p3)", - "function log(bool p0, bool p1, string p2, string p3)", - "function log(string p0, string p1, string p2, address p3)", - "function log(bool p0, bool p1, bool p2, uint256 p3)", - "function log(bool p0, string p1, address p2, bool p3)", - "function log(address p0, address p1, string p2, bool p3)", - "function log(bool p0, address p1, string p2, address p3)", - "function log(string p0, bool p1, bool p2, address p3)", - "function log(uint256 p0, uint256 p1, string p2)", - "function log(uint256 p0, address p1, address p2, uint256 p3)", - "function log(string p0, bool p1, uint256 p2, string p3)", - "function log(uint256 p0, bool p1, bool p2, uint256 p3)", - "function log(address p0, string p1)", - "function log(address p0, bool p1)", - "function log(string p0, uint256 p1, uint256 p2, bool p3)", - "function log(string p0, address p1, bool p2, bool p3)", - "function log(uint256 p0, uint256 p1, string p2, bool p3)", - "function log(uint256 p0, string p1, address p2)", - "function log(address p0, uint256 p1, address p2)", - "function log(bool p0, string p1, string p2, uint256 p3)", - "function log(bool p0, address p1, uint256 p2, uint256 p3)", - "function log(string p0, uint256 p1, string p2, address p3)", - "function log(string p0, string p1, address p2, uint256 p3)", - "function log(string p0, uint256 p1, string p2, bool p3)", - "function log(bool p0, bool p1, uint256 p2, string p3)", - "function log(bool p0, uint256 p1, bool p2, uint256 p3)", - "function log(string p0, address p1, address p2, string p3)", - "function log(address p0, bool p1, string p2, uint256 p3)", - "function log(string p0, uint256 p1, address p2, bool p3)", - "function log(uint256 p0, string p1, uint256 p2, uint256 p3)", - "function log(address p0, uint256 p1)", - "function log(string p0, bool p1, bool p2)", - "function log(bool p0, address p1)", - "function log(string p0, uint256 p1, uint256 p2, string p3)", - "function log(uint256 p0, bool p1, string p2)", - "function log(address p0, uint256 p1, string p2, string p3)", - "function log(uint256 p0, bool p1, uint256 p2, address p3)", - "function log(uint256 p0, uint256 p1, address p2, uint256 p3)", - "function log(string p0, bool p1, bool p2, bool p3)", - "function log(string p0, bool p1, uint256 p2, bool p3)", - "function log(bool p0, bool p1, bool p2, address p3)", - "function log(address p0, bool p1, bool p2, uint256 p3)", - "function log(address p0, address p1, uint256 p2, address p3)", - "function log(string p0, bool p1, bool p2, uint256 p3)", - "function log(bool p0, uint256 p1, uint256 p2, string p3)", - "function log(string p0, string p1, string p2, uint256 p3)", - "function log(string p0, address p1, address p2, uint256 p3)", - "function log(address p0, address p1, string p2, address p3)", - "function log(bool p0, string p1)", - "function log(uint256 p0, string p1, address p2, bool p3)", - "function log(uint256 p0, address p1, bool p2, string p3)", - "function log(bool p0, uint256 p1, bool p2, string p3)", - "function log(uint256 p0, bool p1, uint256 p2, bool p3)", - "function log(string p0, address p1, string p2, uint256 p3)", - "function log(string p0, bool p1, address p2)", - "function log(string p0, bool p1, uint256 p2, address p3)", - "function log(address p0, address p1, address p2, uint256 p3)", - "function log(string p0, bool p1, address p2, bool p3)", - "function log(bool p0, string p1, address p2)", - "function log(string p0, string p1, address p2)", - "function log(bool p0, string p1, string p2, address p3)", - "function log(uint256 p0, uint256 p1, bool p2, address p3)", - "function log(bool p0, uint256 p1, bool p2, address p3)", - "function log(address p0, address p1, uint256 p2, bool p3)", - "function log(uint256 p0, address p1, bool p2)", - "function log(uint256 p0, string p1, address p2, string p3)", - "function log(address p0, bool p1, uint256 p2)", - "function log(uint256 p0, address p1, string p2, address p3)", - "function log(string p0, bool p1, bool p2, string p3)", - "function log(address p0, address p1, bool p2, address p3)", - "function log(string p0, uint256 p1, address p2, string p3)", - "function log(address p0, string p1, string p2, address p3)", - "function log(bool p0, bool p1, address p2, string p3)", - "function log(address p0, uint256 p1, address p2, bool p3)", - "function log(uint256 p0, bool p1, address p2, address p3)", - "function log(address p0, uint256 p1, string p2)", - "function log(address p0, uint256 p1, bool p2, address p3)", - "function log(uint256 p0, uint256 p1, bool p2, string p3)", - "function log(bool p0, string p1, address p2, uint256 p3)", - "function log(address p0, bool p1, address p2, bool p3)", - "function log(bool p0, address p1, string p2, string p3)", - "function log(address p0, bool p1, address p2, uint256 p3)", - "function log(string p0, uint256 p1, uint256 p2, uint256 p3)", - "function log(string p0, bool p1, string p2, string p3)", - "function log(address p0, address p1, bool p2, string p3)", - "function log(string p0, address p1, string p2, address p3)", - "function log(uint256 p0, uint256 p1, bool p2, bool p3)", - "function log(string p0, uint256 p1, bool p2, string p3)", - "function log(uint256 p0, bool p1, address p2, string p3)", - "function log(uint256 p0, string p1, bool p2, address p3)", - "function log(uint256 p0, string p1, string p2, uint256 p3)", - "function log(bool p0, string p1, string p2)", - "function log(string p0, string p1, bool p2)", - "function log(uint256 p0, string p1, string p2)", - "function log(uint256 p0, string p1, string p2, bool p3)", - "function log(bool p0, uint256 p1, address p2, bool p3)", - "function log(string p0, address p1, address p2, bool p3)", - "function log(string p0, uint256 p1)", - "function log(address p0, uint256 p1, uint256 p2)", - "function log(uint256 p0, bool p1, bool p2, bool p3)", - "function log(uint256 p0, string p1, uint256 p2, string p3)", - "function log(bool p0, bool p1, string p2, bool p3)", - "function log(uint256 p0, string p1, bool p2, bool p3)", - "function log(address p0, string p1, bool p2, string p3)", - "function log(uint256 p0, address p1, address p2)", - "function log(address p0, address p1, uint256 p2, uint256 p3)", - "function log(bool p0, uint256 p1, uint256 p2, bool p3)", - "function log(address p0, uint256 p1, string p2, uint256 p3)", - "function log(bool p0, bool p1, address p2, bool p3)", - "function log(bool p0, address p1, string p2, uint256 p3)", - "function log(string p0, string p1, bool p2, address p3)", - "function log(string p0, string p1, uint256 p2, bool p3)", - "function log(string p0, bool p1)", - "function log(bool p0, uint256 p1, string p2)", - "function log(address p0, bool p1, uint256 p2, bool p3)", - "function log(uint256 p0, uint256 p1, uint256 p2, bool p3)", - "function log(address p0, uint256 p1, bool p2, string p3)", - "function log(string p0, uint256 p1, string p2, uint256 p3)", - "function log(uint256 p0, bool p1, uint256 p2, uint256 p3)", - "function log(string p0, address p1, bool p2)", - "function log(string p0, bool p1, uint256 p2)", - "function log(string p0, uint256 p1, uint256 p2)", - "function log(string p0, uint256 p1, bool p2)", - "function log(address p0, bool p1, bool p2, bool p3)", - "function log(uint256 p0, address p1, string p2, bool p3)", - "function log(address p0, bool p1, uint256 p2, address p3)", - "function log(bool p0, uint256 p1, bool p2, bool p3)", - "function log(uint256 p0, string p1, bool p2, uint256 p3)", - "function log(address p0, string p1, bool p2)", - "function log(address p0, uint256 p1, string p2, bool p3)", - "function log(address p0, bool p1, bool p2, address p3)", - "function log(uint256 p0, uint256 p1, uint256 p2)", - "function log(bool p0, address p1, address p2)", - "function log(uint256 p0, string p1, bool p2, string p3)", - "function log(uint256 p0, string p1, string p2, address p3)", - "function log(bool p0, address p1, uint256 p2, bool p3)", - "function log(string p0, string p1, bool p2, uint256 p3)", - "function log(bool p0, address p1, address p2, string p3)", - "function log(address p0, address p1)", - "function log(bool p0, string p1, bool p2)", - "function log(bool p0, string p1, bool p2, bool p3)", - "function log(uint256 p0, address p1, uint256 p2, string p3)", - "function log(uint256 p0, bool p1, bool p2, string p3)", - "function log(uint256 p0, bool p1, uint256 p2, string p3)", - "function log(string p0, string p1, string p2, string p3)", - "function log(bool p0, address p1, string p2)", - "function log(address p0, bool p1, bool p2, string p3)", - "function log(string p0, bool p1, string p2, address p3)", - "function log(string p0, uint256 p1, bool p2, address p3)", - "function log(string p0, address p1, string p2)", - "function log(string p0, uint256 p1, uint256 p2, address p3)", - "function log(string p0, bool p1, string p2)", - "function log(bool p0, address p1, string p2, bool p3)", - "function log(uint256 p0, address p1, bool p2, bool p3)", - "function log(bool p0, bool p1, string p2, uint256 p3)", - "function log(string p0, uint256 p1, bool p2, uint256 p3)", - "function log(bool p0, uint256 p1, string p2, bool p3)", - "function log(uint256 p0, string p1, address p2, uint256 p3)", - "function log(bool p0, uint256 p1, bool p2)", - "function log(string p0, string p1, address p2, string p3)", - "function log(uint256 p0, uint256 p1, bool p2, uint256 p3)", - "function log(address p0, bool p1, bool p2)", - "function log(uint256 p0, bool p1, string p2, bool p3)", - "function log(string p0, address p1, address p2, address p3)", - "function log(address p0, address p1, string p2, uint256 p3)", - "function log(uint256 p0, bool p1, string p2, address p3)", - "function log(uint256 p0, address p1, bool p2, address p3)", - "function log(address p0, string p1, address p2)", - "function log(address p0, bool p1, address p2)", - "function log(address p0, address p1, bool p2)", - "function log(string p0, string p1, uint256 p2, uint256 p3)", - "function log(bool p0, bool p1, address p2, address p3)", - "function log(bool p0, uint256 p1, string p2, string p3)", - "function log(uint256 p0, uint256 p1)", - "function log(address p0, string p1, address p2, string p3)", - "function log(address p0, address p1, address p2, string p3)", - "function log(uint256 p0)", - "function log(string p0, address p1, uint256 p2, uint256 p3)", - "function log(bool p0, bool p1, string p2, address p3)", - "function log(uint256 p0, uint256 p1, uint256 p2, address p3)", - "function log(address p0, string p1, string p2)", - "function log(string p0, address p1, uint256 p2, bool p3)", - "function log(string p0, address p1, address p2)", - "function log(address p0, address p1, uint256 p2, string p3)", - "function log(bool p0, uint256 p1, string p2, address p3)", - "function logAddress(address p0)", - "function logBool(bool p0)", - "function logBytes(bytes p0)", - "function logBytes1(bytes1 p0)", - "function logBytes10(bytes10 p0)", - "function logBytes11(bytes11 p0)", - "function logBytes12(bytes12 p0)", - "function logBytes13(bytes13 p0)", - "function logBytes14(bytes14 p0)", - "function logBytes15(bytes15 p0)", - "function logBytes16(bytes16 p0)", - "function logBytes17(bytes17 p0)", - "function logBytes18(bytes18 p0)", - "function logBytes19(bytes19 p0)", - "function logBytes2(bytes2 p0)", - "function logBytes20(bytes20 p0)", - "function logBytes21(bytes21 p0)", - "function logBytes22(bytes22 p0)", - "function logBytes23(bytes23 p0)", - "function logBytes24(bytes24 p0)", - "function logBytes25(bytes25 p0)", - "function logBytes26(bytes26 p0)", - "function logBytes27(bytes27 p0)", - "function logBytes28(bytes28 p0)", - "function logBytes29(bytes29 p0)", - "function logBytes3(bytes3 p0)", - "function logBytes30(bytes30 p0)", - "function logBytes31(bytes31 p0)", - "function logBytes32(bytes32 p0)", - "function logBytes4(bytes4 p0)", - "function logBytes5(bytes5 p0)", - "function logBytes6(bytes6 p0)", - "function logBytes7(bytes7 p0)", - "function logBytes8(bytes8 p0)", - "function logBytes9(bytes9 p0)", - "function logInt(int256 p0)", - "function logString(string p0)", - "function logUint(uint256 p0)", - "function log(int256 p0)", - "function log(string p0, int256 p1)", - ]) - .expect("Could not parse HardhatConsole abi") -}); - -pub static CONSOLE_ABI: Lazy = Lazy::new(|| { - JsonAbi::parse([ - "event log(string)", - "event logs (bytes)", - "event log_address (address)", - "event log_bytes32 (bytes32)", - "event log_int (int)", - "event log_uint (uint)", - "event log_bytes (bytes)", - "event log_string (string)", - "event log_array (uint256[] val)", - "event log_array (int256[] val)", - "event log_array (address[] val)", - "event log_named_address (string key, address val)", - "event log_named_decimal_int (string key, int val, uint decimals)", - "event log_named_bytes32 (string key, bytes32 val)", - "event log_named_decimal_uint (string key, uint val, uint decimals)", - "event log_named_int (string key, int val)", - "event log_named_uint (string key, uint val)", - "event log_named_bytes (string key, bytes val)", - "event log_named_string (string key, string val)", - "event log_named_array (string key, uint256[] val)", - "event log_named_array (string key, int256[] val)", - "event log_named_array (string key, address[] val)", - ]) - .expect("Could not parase console ABI") -}); - -/// This contains a map with all the `hardhat/console.log` log selectors that use `uint` or `int` -/// as key and the selector of the call with `uint256`, -/// -/// This is a bit terrible but a workaround for the differing selectors used by hardhat and the call -/// bindings which `abigen!` creates. `hardhat/console.log` logs its events in functions that accept -/// `uint` manually as `abi.encodeWithSignature("log(int)", p0)`, but `abigen!` uses `uint256` for -/// its call bindings (`HardhatConsoleCalls`) as generated by solc. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { - HashMap::from( - [ - // log(bool,uint256,uint256,address) - ([241, 97, 178, 33], [0, 221, 135, 185]), - // log(uint256,address,address,string) - ([121, 67, 220, 102], [3, 28, 111, 115]), - // log(uint256,bool,address,uint256) - ([65, 181, 239, 59], [7, 130, 135, 245]), - // log(bool,address,bool,uint256) - ([76, 182, 15, 209], [7, 131, 21, 2]), - // log(bool,uint256,address) - ([196, 210, 53, 7], [8, 142, 249, 210]), - // log(uint256,address,address,bool) - ([1, 85, 11, 4], [9, 31, 250, 245]), - // log(address,bool,uint256,string) - ([155, 88, 142, 204], [10, 166, 207, 173]), - // log(bool,bool,uint256,uint256) - ([70, 103, 222, 142], [11, 176, 14, 171]), - // log(bool,address,address,uint256) - ([82, 132, 189, 108], [12, 102, 209, 190]), - // log(uint256,address,uint256,uint256) - ([202, 154, 62, 180], [12, 156, 217, 193]), - // log(string,address,uint256) - ([7, 200, 18, 23], [13, 38, 185, 37]), - // log(address,string,uint256,bool) - ([126, 37, 13, 91], [14, 247, 224, 80]), - // log(address,uint256,address,uint256) - ([165, 217, 135, 104], [16, 15, 101, 14]), - // log(string,string,uint256,address) - ([93, 79, 70, 128], [16, 35, 247, 178]), - // log(bool,string,uint256) - ([192, 56, 42, 172], [16, 147, 238, 17]), - // log(bool,bool,uint256) - ([176, 19, 101, 187], [18, 242, 22, 2]), - // log(bool,address,uint256,address) - ([104, 241, 88, 181], [19, 107, 5, 221]), - // log(bool,uint256,address,uint256) - ([202, 165, 35, 106], [21, 55, 220, 135]), - // log(bool,string,uint256,address) - ([91, 34, 185, 56], [21, 150, 161, 206]), - // log(address,string,string,uint256) - ([161, 79, 208, 57], [21, 159, 137, 39]), - // log(uint256,address,uint256,address) - ([253, 178, 236, 212], [21, 193, 39, 181]), - // log(uint256,uint256,address,bool) - ([168, 232, 32, 174], [21, 202, 196, 118]), - // log(bool,string,bool,uint256) - ([141, 111, 156, 165], [22, 6, 163, 147]), - // log(address,address,uint256) - ([108, 54, 109, 114], [23, 254, 97, 133]), - // log(uint256,uint256,uint256,uint256) - ([92, 160, 173, 62], [25, 63, 184, 0]), - // log(bool,string,uint256,string) - ([119, 161, 171, 237], [26, 217, 109, 230]), - // log(bool,uint256,address,string) - ([24, 9, 19, 65], [27, 179, 176, 154]), - // log(string,uint256,address) - ([227, 132, 159, 121], [28, 126, 196, 72]), - // log(uint256,bool) - ([30, 109, 212, 236], [28, 157, 126, 179]), - // log(address,uint256,address,string) - ([93, 113, 243, 158], [29, 169, 134, 234]), - // log(address,string,uint256,uint256) - ([164, 201, 42, 96], [29, 200, 225, 184]), - // log(uint256,bool,uint256) - ([90, 77, 153, 34], [32, 9, 128, 20]), - // log(uint256,bool,bool) - ([213, 206, 172, 224], [32, 113, 134, 80]), - // log(address,uint256,uint256,address) - ([30, 246, 52, 52], [32, 227, 152, 77]), - // log(uint256,string,string,string) - ([87, 221, 10, 17], [33, 173, 6, 131]), - // log(address,uint256,bool,uint256) - ([105, 143, 67, 146], [34, 246, 185, 153]), - // log(uint256,address,address,address) - ([85, 71, 69, 249], [36, 136, 180, 20]), - // log(string,bool,string,uint256) - ([52, 203, 48, 141], [36, 249, 20, 101]), - // log(bool,uint256,address,address) - ([138, 47, 144, 170], [38, 245, 96, 168]), - // log(uint256,uint256,string,string) - ([124, 3, 42, 50], [39, 216, 175, 210]), - // log(bool,string,uint256,uint256) - ([142, 74, 232, 110], [40, 134, 63, 203]), - // log(uint256,bool,string,uint256) - ([145, 95, 219, 40], [44, 29, 7, 70]), - // log(address,uint256,uint256,uint256) - ([61, 14, 157, 228], [52, 240, 230, 54]), - // log(uint256,bool,address) - ([66, 78, 255, 191], [53, 8, 95, 123]), - // log(string,uint256,bool,bool) - ([227, 127, 243, 208], [53, 76, 54, 214]), - // log(bool,uint256,uint256) - ([59, 92, 3, 224], [55, 16, 51, 103]), - // log(bool,uint256,uint256,uint256) - ([50, 223, 165, 36], [55, 75, 180, 178]), - // log(uint256,string,uint256) - ([91, 109, 232, 63], [55, 170, 125, 76]), - // log(address,bool,uint256,uint256) - ([194, 16, 160, 30], [56, 111, 245, 244]), - // log(address,address,bool,uint256) - ([149, 214, 95, 17], [57, 113, 231, 140]), - // log(bool,uint256) - ([54, 75, 106, 146], [57, 145, 116, 211]), - // log(uint256,string,uint256,address) - ([171, 123, 217, 253], [59, 34, 121, 180]), - // log(address,uint256,bool,bool) - ([254, 161, 213, 90], [59, 245, 229, 55]), - // log(uint256,address,string,string) - ([141, 119, 134, 36], [62, 18, 140, 163]), - // log(string,address,bool,uint256) - ([197, 209, 187, 139], [62, 159, 134, 106]), - // log(uint256,uint256,string,address) - ([67, 50, 133, 162], [66, 210, 29, 183]), - // log(address,string,uint256,string) - ([93, 19, 101, 201], [68, 136, 48, 168]), - // log(uint256,bool,address,bool) - ([145, 251, 18, 66], [69, 77, 84, 165]), - // log(address,string,address,uint256) - ([140, 25, 51, 169], [69, 127, 227, 207]), - // log(uint256,address,string,uint256) - ([160, 196, 20, 232], [70, 130, 107, 93]), - // log(uint256,uint256,bool) - ([103, 87, 15, 247], [71, 102, 218, 114]), - // log(address,uint256,address,address) - ([236, 36, 132, 111], [71, 141, 28, 98]), - // log(address,uint256,uint256,string) - ([137, 52, 13, 171], [74, 40, 192, 23]), - // log(bool,bool,address,uint256) - ([96, 147, 134, 231], [76, 18, 61, 87]), - // log(uint256,string,bool) - ([70, 167, 208, 206], [76, 237, 167, 90]), - // log(string,uint256,address,uint256) - ([88, 73, 122, 254], [79, 4, 253, 198]), - // log(address,string,bool,uint256) - ([231, 32, 82, 28], [81, 94, 56, 182]), - // log(bool,address,uint256,string) - ([160, 104, 88, 51], [81, 240, 159, 248]), - // log(bool,bool,uint256,address) - ([11, 255, 149, 13], [84, 167, 169, 160]), - // log(uint256,uint256,address,address) - ([202, 147, 155, 32], [86, 165, 209, 177]), - // log(string,string,uint256) - ([243, 98, 202, 89], [88, 33, 239, 161]), - // log(string,uint256,string) - ([163, 245, 199, 57], [89, 112, 224, 137]), - // log(uint256,uint256,uint256,string) - ([120, 173, 122, 12], [89, 207, 203, 227]), - // log(string,address,uint256,string) - ([76, 85, 242, 52], [90, 71, 118, 50]), - // log(uint256,address,uint256) - ([136, 67, 67, 170], [90, 155, 94, 213]), - // log(string,uint256,string,string) - ([108, 152, 218, 226], [90, 184, 78, 31]), - // log(uint256,address,bool,uint256) - ([123, 8, 232, 235], [90, 189, 153, 42]), - // log(address,uint256,string,address) - ([220, 121, 38, 4], [92, 67, 13, 71]), - // log(uint256,uint256,address) - ([190, 51, 73, 27], [92, 150, 179, 49]), - // log(string,bool,address,uint256) - ([40, 223, 78, 150], [93, 8, 187, 5]), - // log(string,string,uint256,string) - ([141, 20, 44, 221], [93, 26, 151, 26]), - // log(uint256,uint256,string,uint256) - ([56, 148, 22, 61], [93, 162, 151, 235]), - // log(string,uint256,address,address) - ([234, 200, 146, 129], [94, 162, 183, 174]), - // log(uint256,address,uint256,bool) - ([25, 246, 115, 105], [95, 116, 58, 124]), - // log(bool,address,uint256) - ([235, 112, 75, 175], [95, 123, 154, 251]), - // log(uint256,string,address,address) - ([127, 165, 69, 139], [97, 104, 237, 97]), - // log(bool,bool,uint256,bool) - ([171, 92, 193, 196], [97, 158, 77, 14]), - // log(address,string,uint256,address) - ([223, 215, 216, 11], [99, 24, 54, 120]), - // log(uint256,address,string) - ([206, 131, 4, 123], [99, 203, 65, 249]), - // log(string,address,uint256,address) - ([163, 102, 236, 128], [99, 251, 139, 197]), - // log(uint256,string) - ([15, 163, 243, 69], [100, 63, 208, 223]), - // log(string,bool,uint256,uint256) - ([93, 191, 240, 56], [100, 181, 187, 103]), - // log(address,uint256,uint256,bool) - ([236, 75, 168, 162], [102, 241, 188, 103]), - // log(address,uint256,bool) - ([229, 74, 225, 68], [103, 130, 9, 168]), - // log(address,string,uint256) - ([28, 218, 242, 138], [103, 221, 111, 241]), - // log(uint256,bool,string,string) - ([164, 51, 252, 253], [104, 200, 184, 189]), - // log(uint256,string,uint256,bool) - ([135, 90, 110, 46], [105, 26, 143, 116]), - // log(uint256,address) - ([88, 235, 134, 12], [105, 39, 108, 134]), - // log(uint256,bool,bool,address) - ([83, 6, 34, 93], [105, 100, 11, 89]), - // log(bool,uint256,string,uint256) - ([65, 128, 1, 27], [106, 17, 153, 226]), - // log(bool,string,uint256,bool) - ([32, 187, 201, 175], [107, 14, 93, 83]), - // log(uint256,uint256,address,string) - ([214, 162, 209, 222], [108, 222, 64, 184]), - // log(bool,bool,bool,uint256) - ([194, 72, 131, 77], [109, 112, 69, 193]), - // log(uint256,uint256,string) - ([125, 105, 14, 230], [113, 208, 74, 242]), - // log(uint256,address,address,uint256) - ([154, 60, 191, 150], [115, 110, 251, 182]), - // log(string,bool,uint256,string) - ([66, 185, 162, 39], [116, 45, 110, 231]), - // log(uint256,bool,bool,uint256) - ([189, 37, 173, 89], [116, 100, 206, 35]), - // log(string,uint256,uint256,bool) - ([247, 60, 126, 61], [118, 38, 219, 146]), - // log(uint256,uint256,string,bool) - ([178, 46, 175, 6], [122, 246, 171, 37]), - // log(uint256,string,address) - ([31, 144, 242, 74], [122, 250, 201, 89]), - // log(address,uint256,address) - ([151, 236, 163, 148], [123, 192, 216, 72]), - // log(bool,string,string,uint256) - ([93, 219, 37, 146], [123, 224, 195, 235]), - // log(bool,address,uint256,uint256) - ([155, 254, 114, 188], [123, 241, 129, 161]), - // log(string,uint256,string,address) - ([187, 114, 53, 233], [124, 70, 50, 164]), - // log(string,string,address,uint256) - ([74, 129, 165, 106], [124, 195, 198, 7]), - // log(string,uint256,string,bool) - ([233, 159, 130, 207], [125, 36, 73, 29]), - // log(bool,bool,uint256,string) - ([80, 97, 137, 55], [125, 212, 208, 224]), - // log(bool,uint256,bool,uint256) - ([211, 222, 85, 147], [127, 155, 188, 162]), - // log(address,bool,string,uint256) - ([158, 18, 123, 110], [128, 230, 162, 11]), - // log(string,uint256,address,bool) - ([17, 6, 168, 247], [130, 17, 42, 66]), - // log(uint256,string,uint256,uint256) - ([192, 4, 56, 7], [130, 194, 91, 116]), - // log(address,uint256) - ([34, 67, 207, 163], [131, 9, 232, 168]), - // log(string,uint256,uint256,string) - ([165, 78, 212, 189], [133, 75, 52, 150]), - // log(uint256,bool,string) - ([139, 14, 20, 254], [133, 119, 80, 33]), - // log(address,uint256,string,string) - ([126, 86, 198, 147], [136, 168, 196, 6]), - // log(uint256,bool,uint256,address) - ([79, 64, 5, 142], [136, 203, 96, 65]), - // log(uint256,uint256,address,uint256) - ([97, 11, 168, 192], [136, 246, 228, 178]), - // log(string,bool,uint256,bool) - ([60, 197, 181, 211], [138, 247, 207, 138]), - // log(address,bool,bool,uint256) - ([207, 181, 135, 86], [140, 78, 93, 230]), - // log(address,address,uint256,address) - ([214, 198, 82, 118], [141, 166, 222, 245]), - // log(string,bool,bool,uint256) - ([128, 117, 49, 232], [142, 63, 120, 169]), - // log(bool,uint256,uint256,string) - ([218, 6, 102, 200], [142, 105, 251, 93]), - // log(string,string,string,uint256) - ([159, 208, 9, 245], [142, 175, 176, 43]), - // log(string,address,address,uint256) - ([110, 183, 148, 61], [142, 243, 243, 153]), - // log(uint256,string,address,bool) - ([249, 63, 255, 55], [144, 195, 10, 86]), - // log(uint256,address,bool,string) - ([99, 240, 226, 66], [144, 251, 6, 170]), - // log(bool,uint256,bool,string) - ([182, 213, 105, 212], [145, 67, 219, 177]), - // log(uint256,bool,uint256,bool) - ([210, 171, 196, 253], [145, 160, 46, 42]), - // log(string,address,string,uint256) - ([143, 98, 75, 233], [145, 209, 17, 46]), - // log(string,bool,uint256,address) - ([113, 211, 133, 13], [147, 94, 9, 191]), - // log(address,address,address,uint256) - ([237, 94, 172, 135], [148, 37, 13, 119]), - // log(uint256,uint256,bool,address) - ([225, 23, 116, 79], [154, 129, 106, 131]), - // log(bool,uint256,bool,address) - ([66, 103, 199, 248], [154, 205, 54, 22]), - // log(address,address,uint256,bool) - ([194, 246, 136, 236], [155, 66, 84, 226]), - // log(uint256,address,bool) - ([122, 208, 18, 142], [155, 110, 192, 66]), - // log(uint256,string,address,string) - ([248, 152, 87, 127], [156, 58, 223, 161]), - // log(address,bool,uint256) - ([44, 70, 141, 21], [156, 79, 153, 251]), - // log(uint256,address,string,address) - ([203, 229, 142, 253], [156, 186, 143, 255]), - // log(string,uint256,address,string) - ([50, 84, 194, 232], [159, 251, 47, 147]), - // log(address,uint256,address,bool) - ([241, 129, 161, 233], [161, 188, 201, 179]), - // log(uint256,bool,address,address) - ([134, 237, 193, 12], [161, 239, 76, 187]), - // log(address,uint256,string) - ([186, 249, 104, 73], [161, 242, 232, 170]), - // log(address,uint256,bool,address) - ([35, 229, 73, 114], [163, 27, 253, 204]), - // log(uint256,uint256,bool,string) - ([239, 217, 203, 238], [165, 180, 252, 153]), - // log(bool,string,address,uint256) - ([27, 11, 149, 91], [165, 202, 218, 148]), - // log(address,bool,address,uint256) - ([220, 113, 22, 210], [167, 92, 89, 222]), - // log(string,uint256,uint256,uint256) - ([8, 238, 86, 102], [167, 168, 120, 83]), - // log(uint256,uint256,bool,bool) - ([148, 190, 59, 177], [171, 8, 90, 230]), - // log(string,uint256,bool,string) - ([118, 204, 96, 100], [171, 247, 58, 152]), - // log(uint256,bool,address,string) - ([162, 48, 118, 30], [173, 224, 82, 199]), - // log(uint256,string,bool,address) - ([121, 111, 40, 160], [174, 46, 197, 129]), - // log(uint256,string,string,uint256) - ([118, 236, 99, 94], [176, 40, 201, 189]), - // log(uint256,string,string) - ([63, 87, 194, 149], [177, 21, 97, 31]), - // log(uint256,string,string,bool) - ([18, 134, 43, 152], [179, 166, 182, 189]), - // log(bool,uint256,address,bool) - ([101, 173, 244, 8], [180, 195, 20, 255]), - // log(string,uint256) - ([151, 16, 169, 208], [182, 14, 114, 204]), - // log(address,uint256,uint256) - ([135, 134, 19, 94], [182, 155, 202, 246]), - // log(uint256,bool,bool,bool) - ([78, 108, 83, 21], [182, 245, 119, 161]), - // log(uint256,string,uint256,string) - ([162, 188, 12, 153], [183, 185, 20, 202]), - // log(uint256,string,bool,bool) - ([81, 188, 43, 193], [186, 83, 93, 156]), - // log(uint256,address,address) - ([125, 119, 166, 27], [188, 253, 155, 224]), - // log(address,address,uint256,uint256) - ([84, 253, 243, 228], [190, 85, 52, 129]), - // log(bool,uint256,uint256,bool) - ([164, 29, 129, 222], [190, 152, 67, 83]), - // log(address,uint256,string,uint256) - ([245, 18, 207, 155], [191, 1, 248, 145]), - // log(bool,address,string,uint256) - ([11, 153, 252, 34], [194, 31, 100, 199]), - // log(string,string,uint256,bool) - ([230, 86, 88, 202], [195, 168, 166, 84]), - // log(bool,uint256,string) - ([200, 57, 126, 176], [195, 252, 57, 112]), - // log(address,bool,uint256,bool) - ([133, 205, 197, 175], [196, 100, 62, 32]), - // log(uint256,uint256,uint256,bool) - ([100, 82, 185, 203], [197, 152, 209, 133]), - // log(address,uint256,bool,string) - ([142, 142, 78, 117], [197, 173, 133, 249]), - // log(string,uint256,string,uint256) - ([160, 196, 178, 37], [198, 126, 169, 209]), - // log(uint256,bool,uint256,uint256) - ([86, 130, 141, 164], [198, 172, 199, 168]), - // log(string,bool,uint256) - ([41, 27, 185, 208], [201, 89, 88, 214]), - // log(string,uint256,uint256) - ([150, 156, 221, 3], [202, 71, 196, 235]), - // log(string,uint256,bool) - ([241, 2, 238, 5], [202, 119, 51, 177]), - // log(uint256,address,string,bool) - ([34, 164, 121, 166], [204, 50, 171, 7]), - // log(address,bool,uint256,address) - ([13, 140, 230, 30], [204, 247, 144, 161]), - // log(bool,uint256,bool,bool) - ([158, 1, 247, 65], [206, 181, 244, 215]), - // log(uint256,string,bool,uint256) - ([164, 180, 138, 127], [207, 0, 152, 128]), - // log(address,uint256,string,bool) - ([164, 2, 79, 17], [207, 24, 16, 92]), - // log(uint256,uint256,uint256) - ([231, 130, 10, 116], [209, 237, 122, 60]), - // log(uint256,string,bool,string) - ([141, 72, 156, 160], [210, 212, 35, 205]), - // log(uint256,string,string,address) - ([204, 152, 138, 160], [213, 131, 198, 2]), - // log(bool,address,uint256,bool) - ([238, 141, 134, 114], [214, 1, 159, 28]), - // log(string,string,bool,uint256) - ([134, 129, 138, 122], [214, 174, 250, 210]), - // log(uint256,address,uint256,string) - ([62, 211, 189, 40], [221, 176, 101, 33]), - // log(uint256,bool,bool,string) - ([49, 138, 229, 155], [221, 219, 149, 97]), - // log(uint256,bool,uint256,string) - ([232, 221, 188, 86], [222, 3, 231, 116]), - // log(string,uint256,bool,address) - ([229, 84, 157, 145], [224, 233, 91, 152]), - // log(string,uint256,uint256,address) - ([190, 215, 40, 191], [226, 29, 226, 120]), - // log(uint256,address,bool,bool) - ([126, 39, 65, 13], [227, 81, 20, 15]), - // log(bool,bool,string,uint256) - ([23, 139, 70, 133], [227, 169, 202, 47]), - // log(string,uint256,bool,uint256) - ([85, 14, 110, 245], [228, 27, 111, 111]), - // log(bool,uint256,string,bool) - ([145, 210, 248, 19], [229, 231, 11, 43]), - // log(uint256,string,address,uint256) - ([152, 231, 243, 243], [232, 211, 1, 141]), - // log(bool,uint256,bool) - ([27, 173, 201, 235], [232, 222, 251, 169]), - // log(uint256,uint256,bool,uint256) - ([108, 100, 124, 140], [235, 127, 111, 210]), - // log(uint256,bool,string,bool) - ([52, 110, 184, 199], [235, 146, 141, 127]), - // log(address,address,string,uint256) - ([4, 40, 147, 0], [239, 28, 239, 231]), - // log(uint256,bool,string,address) - ([73, 110, 43, 180], [239, 82, 144, 24]), - // log(uint256,address,bool,address) - ([182, 49, 48, 148], [239, 114, 197, 19]), - // log(string,string,uint256,uint256) - ([213, 207, 23, 208], [244, 93, 125, 44]), - // log(bool,uint256,string,string) - ([211, 42, 101, 72], [245, 188, 34, 73]), - // log(uint256,uint256) - ([108, 15, 105, 128], [246, 102, 113, 90]), - // log(uint256) and logUint(uint256) - ([245, 177, 187, 169], [248, 44, 80, 241]), - // log(string,address,uint256,uint256) - ([218, 163, 148, 189], [248, 245, 27, 30]), - // log(uint256,uint256,uint256,address) - ([224, 133, 63, 105], [250, 129, 133, 175]), - // log(string,address,uint256,bool) - ([90, 193, 193, 60], [252, 72, 69, 240]), - // log(address,address,uint256,string) - ([157, 209, 46, 173], [253, 180, 249, 144]), - // log(bool,uint256,string,address) - ([165, 199, 13, 41], [254, 221, 31, 255]), - // logInt(int256) - ([78, 12, 29, 29], [101, 37, 181, 245]), - // logBytes(bytes) - ([11, 231, 127, 86], [225, 123, 249, 86]), - // logBytes1(bytes1) - ([110, 24, 161, 40], [111, 65, 113, 201]), - // logBytes2(bytes2) - ([233, 182, 34, 150], [155, 94, 148, 62]), - // logBytes3(bytes3) - ([45, 131, 73, 38], [119, 130, 250, 45]), - // logBytes4(bytes4) - ([224, 95, 72, 209], [251, 163, 173, 57]), - // logBytes5(bytes5) - ([166, 132, 128, 141], [85, 131, 190, 46]), - // logBytes6(bytes6) - ([174, 132, 165, 145], [73, 66, 173, 198]), - // logBytes7(bytes7) - ([78, 213, 126, 40], [69, 116, 175, 171]), - // logBytes8(bytes8) - ([79, 132, 37, 46], [153, 2, 228, 127]), - // logBytes9(bytes9) - ([144, 189, 140, 208], [80, 161, 56, 223]), - // logBytes10(bytes10) - ([1, 61, 23, 139], [157, 194, 168, 151]), - // logBytes11(bytes11) - ([4, 0, 74, 46], [220, 8, 182, 167]), - // logBytes12(bytes12) - ([134, 160, 106, 189], [118, 86, 214, 199]), - // logBytes13(bytes13) - ([148, 82, 158, 52], [52, 193, 216, 27]), - // logBytes14(bytes14) - ([146, 102, 240, 127], [60, 234, 186, 101]), - // logBytes15(bytes15) - ([218, 149, 116, 224], [89, 26, 61, 162]), - // logBytes16(bytes16) - ([102, 92, 97, 4], [31, 141, 115, 18]), - // logBytes17(bytes17) - ([51, 159, 103, 58], [248, 154, 83, 47]), - // logBytes18(bytes18) - ([196, 210, 61, 154], [216, 101, 38, 66]), - // logBytes19(bytes19) - ([94, 107, 90, 51], [0, 245, 107, 201]), - // logBytes20(bytes20) - ([81, 136, 227, 233], [236, 184, 86, 126]), - // logBytes21(bytes21) - ([233, 218, 53, 96], [48, 82, 192, 143]), - // logBytes22(bytes22) - ([213, 250, 232, 156], [128, 122, 180, 52]), - // logBytes23(bytes23) - ([171, 161, 207, 13], [73, 121, 176, 55]), - // logBytes24(bytes24) - ([241, 179, 91, 52], [9, 119, 174, 252]), - // logBytes25(bytes25) - ([11, 132, 188, 88], [174, 169, 150, 63]), - // logBytes26(bytes26) - ([248, 177, 73, 241], [211, 99, 86, 40]), - // logBytes27(bytes27) - ([58, 55, 87, 221], [252, 55, 47, 159]), - // logBytes28(bytes28) - ([200, 42, 234, 238], [56, 47, 154, 52]), - // logBytes29(bytes29) - ([75, 105, 195, 213], [122, 24, 118, 65]), - // logBytes30(bytes30) - ([238, 18, 196, 237], [196, 52, 14, 246]), - // logBytes31(bytes31) - ([194, 133, 77, 146], [129, 252, 134, 72]), - // logBytes32(bytes32) - ([39, 183, 207, 133], [45, 33, 214, 247]), - ] - .map(|s| (s.0, s.1)), - ) -}); - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn hardhat_console_path_works() { - for (hh, abigen) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { - let mut hh = (*hh).to_vec(); - patch_hardhat_console_selector(&mut hh); - assert_eq!((*abigen).to_vec(), hh); - } - } -} diff --git a/crates/evm/src/executor/inspector/mod.rs b/crates/evm/src/executor/inspector/mod.rs deleted file mode 100644 index f25a6ab434b9b..0000000000000 --- a/crates/evm/src/executor/inspector/mod.rs +++ /dev/null @@ -1,32 +0,0 @@ -#[macro_use] -mod utils; - -mod access_list; -pub use access_list::AccessListTracer; - -pub mod cheatcodes; -pub use cheatcodes::{Cheatcodes, CheatsConfig, DEFAULT_CREATE2_DEPLOYER}; - -mod chisel_state; -pub use chisel_state::ChiselState; - -mod coverage; -pub use coverage::CoverageCollector; - -mod debugger; -pub use debugger::Debugger; - -mod fuzzer; -pub use fuzzer::Fuzzer; - -mod logs; -pub use logs::LogCollector; - -mod printer; -pub use printer::TracePrinter; - -mod stack; -pub use stack::{InspectorData, InspectorStack, InspectorStackBuilder}; - -mod tracer; -pub use tracer::Tracer; diff --git a/crates/evm/src/executor/inspector/utils.rs b/crates/evm/src/executor/inspector/utils.rs deleted file mode 100644 index 5c828e8ac9bd0..0000000000000 --- a/crates/evm/src/executor/inspector/utils.rs +++ /dev/null @@ -1,35 +0,0 @@ -use alloy_primitives::{Address, B256}; - -use revm::{ - interpreter::CreateInputs, - primitives::{CreateScheme, SpecId}, -}; - -/// Returns [InstructionResult::Continue] on an error, discarding the error. -/// -/// Useful for inspectors that read state that might be invalid, but do not want to emit -/// appropriate errors themselves, instead opting to continue. -macro_rules! try_or_continue { - ($e:expr) => { - match $e { - Ok(v) => v, - Err(_) => return InstructionResult::Continue, - } - }; -} - -/// Get the address of a contract creation -pub fn get_create_address(call: &CreateInputs, nonce: u64) -> Address { - match call.scheme { - CreateScheme::Create => call.caller.create(nonce), - CreateScheme::Create2 { salt } => { - call.caller.create2_from_code(B256::from(salt), &call.init_code) - } - } -} - -/// Get the gas used, accounting for refunds -pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 { - let refund_quotient = if SpecId::enabled(spec, SpecId::LONDON) { 5 } else { 2 }; - spent - (refunded).min(spent / refund_quotient) -} diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs deleted file mode 100644 index 8dbe9eaf973ea..0000000000000 --- a/crates/evm/src/lib.rs +++ /dev/null @@ -1,113 +0,0 @@ -#![warn(unused_crate_dependencies)] - -#[macro_use] -extern crate tracing; - -/// Decoding helpers -pub mod decode; - -/// Call tracing -/// Contains a call trace arena, decoding and formatting utilities -pub mod trace; - -/// Debugger data structures -pub mod debug; - -/// Coverage data structures -pub mod coverage; - -/// Forge test execution backends -pub mod executor; - -pub use executor::abi; - -use ethers::types::{ActionType, CallType}; - -/// Fuzzing wrapper for executors -pub mod fuzz; - -/// utils for working with revm -pub mod utils; - -// Re-exports -pub use hashbrown; -use revm::interpreter::{CallScheme, CreateScheme}; -pub use revm::{ - self, - primitives::{Address as aB160, HashMap}, -}; -use serde::{Deserialize, Serialize}; - -/// Stores the caller address to be used as _sender_ account for: -/// - deploying Test contracts -/// - deploying Script contracts -/// -/// The address was derived from `address(uint160(uint256(keccak256("foundry default caller"))))` -/// and is equal to 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38. -pub const CALLER: aB160 = aB160::new([ - 0x18, 0x04, 0xc8, 0xAB, 0x1F, 0x12, 0xE6, 0xbb, 0xF3, 0x89, 0x4D, 0x40, 0x83, 0xF3, 0x3E, 0x07, - 0x30, 0x9D, 0x1F, 0x38, -]); - -/// Stores the default test contract address: 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 -pub const TEST_CONTRACT_ADDRESS: aB160 = aB160::new([ - 180, 199, 157, 171, 143, 37, 156, 122, 238, 110, 91, 42, 167, 41, 130, 24, 100, 34, 126, 132, -]); - -#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "UPPERCASE")] -#[derive(Default)] -pub enum CallKind { - #[default] - Call, - StaticCall, - CallCode, - DelegateCall, - Create, - Create2, -} - -impl From for CallKind { - fn from(scheme: CallScheme) -> Self { - match scheme { - CallScheme::Call => CallKind::Call, - CallScheme::StaticCall => CallKind::StaticCall, - CallScheme::CallCode => CallKind::CallCode, - CallScheme::DelegateCall => CallKind::DelegateCall, - } - } -} - -impl From for CallKind { - fn from(create: CreateScheme) -> Self { - match create { - CreateScheme::Create => CallKind::Create, - CreateScheme::Create2 { .. } => CallKind::Create2, - } - } -} - -impl From for ActionType { - fn from(kind: CallKind) -> Self { - match kind { - CallKind::Call | CallKind::StaticCall | CallKind::DelegateCall | CallKind::CallCode => { - ActionType::Call - } - CallKind::Create => ActionType::Create, - CallKind::Create2 => ActionType::Create, - } - } -} - -impl From for CallType { - fn from(ty: CallKind) -> Self { - match ty { - CallKind::Call => CallType::Call, - CallKind::StaticCall => CallType::StaticCall, - CallKind::CallCode => CallType::CallCode, - CallKind::DelegateCall => CallType::DelegateCall, - CallKind::Create => CallType::None, - CallKind::Create2 => CallType::None, - } - } -} diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml new file mode 100644 index 0000000000000..bcafdf0aebd8b --- /dev/null +++ b/crates/evm/traces/Cargo.toml @@ -0,0 +1,50 @@ +[package] +name = "foundry-evm-traces" +description = "EVM trace identifying and decoding" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +foundry-block-explorers.workspace = true +foundry-common.workspace = true +foundry-compilers.workspace = true +foundry-config.workspace = true +foundry-evm-core.workspace = true +foundry-utils.workspace = true + +alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-json-abi = { workspace = true } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +ethers = { workspace = true, features = ["ethers-solc"] } +revm = { workspace = true, default-features = false, features = [ + "std", + "serde", + "memory_limit", + "optional_eip3607", + "optional_block_gas_limit", + "optional_no_base_fee", + "arbitrary", +] } + +eyre = "0.6" +futures = "0.3" +hashbrown = "0.14" +hex.workspace = true +itertools.workspace = true +once_cell = "1" +ordered-float = "4" +serde = "1" +tokio = { version = "1", features = ["time", "macros"] } +tracing = "0.1" +yansi = "0.5" + +[dev-dependencies] +ethers = { workspace = true, features = ["ethers-solc", "rustls"] } +foundry-utils.workspace = true +tempfile = "3" diff --git a/crates/evm/src/trace/decoder.rs b/crates/evm/traces/src/decoder.rs similarity index 82% rename from crates/evm/src/trace/decoder.rs rename to crates/evm/traces/src/decoder.rs index 652760c7c040f..794626277fd33 100644 --- a/crates/evm/src/trace/decoder.rs +++ b/crates/evm/traces/src/decoder.rs @@ -1,18 +1,21 @@ -use super::{ - identifier::{AddressIdentity, SingleSignaturesIdentifier, TraceIdentifier}, - CallTraceArena, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, -}; use crate::{ - abi::{CHEATCODE_ADDRESS, CONSOLE_ABI, HARDHAT_CONSOLE_ABI, HARDHAT_CONSOLE_ADDRESS, HEVM_ABI}, - decode, - executor::inspector::DEFAULT_CREATE2_DEPLOYER, - trace::{node::CallTraceNode, utils}, - CALLER, TEST_CONTRACT_ADDRESS, + identifier::{AddressIdentity, SingleSignaturesIdentifier, TraceIdentifier}, + node::CallTraceNode, + utils, CallTraceArena, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, }; -use alloy_dyn_abi::{DynSolType, DynSolValue, EventExt}; -use alloy_json_abi::{Event, Function, JsonAbi as Abi, Param}; +use alloy_dyn_abi::{DynSolValue, EventExt}; +use alloy_json_abi::{Event, Function, JsonAbi as Abi}; use alloy_primitives::{Address, FixedBytes, B256}; use foundry_common::{abi::get_indexed_event, SELECTOR_LEN}; +use foundry_evm_core::{ + abi::{CONSOLE_ABI, HARDHAT_CONSOLE_ABI, HEVM_ABI}, + constants::{ + CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, + TEST_CONTRACT_ADDRESS, + }, + decode, +}; +use foundry_utils::types::ToAlloy; use once_cell::sync::OnceCell; use std::collections::{BTreeMap, HashMap}; @@ -106,15 +109,17 @@ pub struct CallTraceDecoder { macro_rules! precompiles { ($($number:literal : $name:ident($( $name_in:ident : $in:expr ),* $(,)?) -> ($( $name_out:ident : $out:expr ),* $(,)?)),+ $(,)?) => {{ use std::string::String as RustString; + use ethers::abi::ParamType::*; [$( ( - Address::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, $number]), + alloy_primitives::Address::with_last_byte($number), #[allow(deprecated)] - Function { + ethers::abi::Function { name: RustString::from(stringify!($name)), - inputs: vec![$(Param { name: RustString::from(stringify!($name_in)), ty: $in, components: vec![], internal_type: None, }),*], - outputs: vec![$(Param { name: RustString::from(stringify!($name_out)), ty: $out, components: vec![], internal_type: None, }),*], - state_mutability: alloy_json_abi::StateMutability::Pure, + inputs: vec![$(ethers::abi::Param { name: RustString::from(stringify!($name_in)), kind: $in, internal_type: None, }),*], + outputs: vec![$(ethers::abi::Param { name: RustString::from(stringify!($name_out)), kind: $out, internal_type: None, }),*], + constant: None, + state_mutability: ethers::abi::StateMutability::Pure, }, ), )+] @@ -138,16 +143,16 @@ impl CallTraceDecoder { // TODO: These are the Ethereum precompiles. We should add a way to support precompiles // for other networks, too. precompiles: precompiles!( - 0x01: ecrecover(hash: format!("bytes32"), v: format!("uint256"), r: format!("uint256"), s: format!("uint256")) -> (publicAddress: format!("address")), - 0x02: sha256(data: format!("bytes")) -> (hash: format!("bytes32")), - 0x03: ripemd(data: format!("bytes")) -> (hash: format!("bytes32")), - 0x04: identity(data: format!("bytes")) -> (data: format!("bytes")), - 0x05: modexp(Bsize: format!("uint256"), Esize: format!("uint256"), Msize: format!("uint256"), BEM: format!("bytes")) -> (value: format!("bytes")), - 0x06: ecadd(x1: format!("uint256"), y1: format!("uint256"), x2: format!("uint256"), y2: format!("uint256")) -> (x: format!("uint256"), y: format!("uint256")), - 0x07: ecmul(x1: format!("uint256"), y1: format!("uint256"), s: format!("uint256")) -> (x: format!("uint256"), y: format!("uint256")), - 0x08: ecpairing(x1: format!("uint256"), y1: format!("uint256"), x2: format!("uint256"), y2: format!("uint256"), x3: format!("uint256"), y3: format!("uint256")) -> (success: format!("uint256")), - 0x09: blake2f(rounds: DynSolType::Uint(4).to_string(), h: DynSolType::FixedBytes(64).to_string(), m: DynSolType::FixedBytes(128).to_string(), t: DynSolType::FixedBytes(16).to_string(), f: DynSolType::FixedBytes(1).to_string()) -> (h: DynSolType::FixedBytes(64).to_string()), - ).into(), + 0x01: ecrecover(hash: FixedBytes(32), v: Uint(256), r: Uint(256), s: Uint(256)) -> (publicAddress: Address), + 0x02: sha256(data: Bytes) -> (hash: FixedBytes(32)), + 0x03: ripemd(data: Bytes) -> (hash: FixedBytes(32)), + 0x04: identity(data: Bytes) -> (data: Bytes), + 0x05: modexp(Bsize: Uint(256), Esize: Uint(256), Msize: Uint(256), BEM: Bytes) -> (value: Bytes), + 0x06: ecadd(x1: Uint(256), y1: Uint(256), x2: Uint(256), y2: Uint(256)) -> (x: Uint(256), y: Uint(256)), + 0x07: ecmul(x1: Uint(256), y1: Uint(256), s: Uint(256)) -> (x: Uint(256), y: Uint(256)), + 0x08: ecpairing(x1: Uint(256), y1: Uint(256), x2: Uint(256), y2: Uint(256), x3: Uint(256), y3: Uint(256)) -> (success: Uint(256)), + 0x09: blake2f(rounds: Uint(4), h: FixedBytes(64), m: FixedBytes(128), t: FixedBytes(16), f: FixedBytes(1)) -> (h: FixedBytes(64)), + ).into_iter().map(|(addr, func)| (addr, func.to_alloy())).collect(), contracts: Default::default(), @@ -163,12 +168,18 @@ impl CallTraceDecoder { functions: HARDHAT_CONSOLE_ABI .functions() .chain(HEVM_ABI.functions()) - .map(|func| (func.selector(), vec![func.clone()])) + .map(|func| { + let func = func.clone().to_alloy(); + (func.selector(), vec![func]) + }) .collect(), events: CONSOLE_ABI .events() - .map(|event| ((event.selector(), indexed_inputs(event)), vec![event.clone()])) + .map(|event| { + let event = event.clone().to_alloy(); + ((event.selector(), indexed_inputs(&event)), vec![event]) + }) .collect(), errors: Default::default(), @@ -196,7 +207,7 @@ impl CallTraceDecoder { }) } - fn collect_identities(&mut self, identities: Vec) { + fn collect_identities(&mut self, identities: Vec>) { for identity in identities { let address = identity.address; diff --git a/crates/evm/src/trace/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs similarity index 98% rename from crates/evm/src/trace/identifier/etherscan.rs rename to crates/evm/traces/src/identifier/etherscan.rs index 40b71dfd42dc6..5bebbe2c9d0e4 100644 --- a/crates/evm/src/trace/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -1,5 +1,4 @@ use super::{AddressIdentity, TraceIdentifier}; -use crate::utils::RuntimeOrHandle; use alloy_primitives::Address; use foundry_block_explorers::{ contract::{ContractMetadata, Metadata}, @@ -7,6 +6,7 @@ use foundry_block_explorers::{ }; use foundry_common::compile::{self, ContractSources}; use foundry_config::{Chain, Config}; +use foundry_evm_core::utils::RuntimeOrHandle; use futures::{ future::{join_all, Future}, stream::{FuturesUnordered, Stream, StreamExt}, @@ -97,7 +97,7 @@ impl EtherscanIdentifier { } impl TraceIdentifier for EtherscanIdentifier { - fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec + fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where A: Iterator)>, { @@ -152,7 +152,7 @@ type EtherscanFuture = /// A rate limit aware Etherscan client. /// /// Fetches information about multiple addresses concurrently, while respecting rate limits. -pub struct EtherscanFetcher { +struct EtherscanFetcher { /// The Etherscan client client: Arc, /// The time we wait if we hit the rate limit @@ -170,7 +170,7 @@ pub struct EtherscanFetcher { } impl EtherscanFetcher { - pub fn new( + fn new( client: Arc, timeout: Duration, concurrency: usize, @@ -187,7 +187,7 @@ impl EtherscanFetcher { } } - pub fn push(&mut self, address: Address) { + fn push(&mut self, address: Address) { self.queue.push(address); } diff --git a/crates/evm/src/trace/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs similarity index 98% rename from crates/evm/src/trace/identifier/local.rs rename to crates/evm/traces/src/identifier/local.rs index cb2100b019d2a..8943ba7517d91 100644 --- a/crates/evm/src/trace/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -22,7 +22,7 @@ impl<'a> LocalTraceIdentifier<'a> { } impl TraceIdentifier for LocalTraceIdentifier<'_> { - fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec + fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where A: Iterator)>, { diff --git a/crates/evm/src/trace/identifier/mod.rs b/crates/evm/traces/src/identifier/mod.rs similarity index 96% rename from crates/evm/src/trace/identifier/mod.rs rename to crates/evm/traces/src/identifier/mod.rs index 7362c07e4b140..3743cde8d6b64 100644 --- a/crates/evm/src/trace/identifier/mod.rs +++ b/crates/evm/traces/src/identifier/mod.rs @@ -1,3 +1,8 @@ +use alloy_json_abi::JsonAbi as Abi; +use alloy_primitives::Address; +use foundry_compilers::ArtifactId; +use std::borrow::Cow; + mod local; pub use local::LocalTraceIdentifier; @@ -7,11 +12,6 @@ pub use etherscan::EtherscanIdentifier; mod signatures; pub use signatures::{SignaturesIdentifier, SingleSignaturesIdentifier}; -use alloy_json_abi::JsonAbi as Abi; -use alloy_primitives::Address; -use foundry_compilers::ArtifactId; -use std::borrow::Cow; - /// An address identity pub struct AddressIdentity<'a> { /// The address this identity belongs to @@ -30,9 +30,8 @@ pub struct AddressIdentity<'a> { /// Trace identifiers figure out what ABIs and labels belong to all the addresses of the trace. pub trait TraceIdentifier { - // TODO: Update docs /// Attempts to identify an address in one or more call traces. - fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec + fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where A: Iterator)>; } diff --git a/crates/evm/src/trace/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs similarity index 98% rename from crates/evm/src/trace/identifier/signatures.rs rename to crates/evm/traces/src/identifier/signatures.rs index d78ec03e8991c..5b5014af021cc 100644 --- a/crates/evm/src/trace/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -11,6 +11,12 @@ use tokio::sync::RwLock; pub type SingleSignaturesIdentifier = Arc>; +#[derive(Debug, Deserialize, Serialize, Default)] +struct CachedSignatures { + events: BTreeMap, + functions: BTreeMap, +} + /// An identifier that tries to identify functions and events using signatures found at /// `https://openchain.xyz`. #[derive(Debug)] @@ -151,12 +157,6 @@ impl Drop for SignaturesIdentifier { } } -#[derive(Debug, Deserialize, Serialize, Default)] -pub struct CachedSignatures { - pub events: BTreeMap, - pub functions: BTreeMap, -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/evm/src/executor/inspector/tracer.rs b/crates/evm/traces/src/inspector.rs similarity index 97% rename from crates/evm/src/executor/inspector/tracer.rs rename to crates/evm/traces/src/inspector.rs index 9e2848498b731..0c82714b531ba 100644 --- a/crates/evm/src/executor/inspector/tracer.rs +++ b/crates/evm/traces/src/inspector.rs @@ -1,13 +1,12 @@ use crate::{ - debug::Instruction::OpCode, - executor::inspector::utils::{gas_used, get_create_address}, - trace::{ - CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, RawOrDecodedCall, RawOrDecodedLog, - RawOrDecodedReturnData, - }, - CallKind, + CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, RawOrDecodedCall, RawOrDecodedLog, + RawOrDecodedReturnData, }; use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; +use foundry_evm_core::{ + debug::Instruction::OpCode, + utils::{gas_used, get_create_address, CallKind}, +}; use revm::{ interpreter::{ opcode, return_ok, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, diff --git a/crates/evm/src/trace/mod.rs b/crates/evm/traces/src/lib.rs similarity index 97% rename from crates/evm/src/trace/mod.rs rename to crates/evm/traces/src/lib.rs index 88bfc6d73a5db..89d4e31651bb8 100644 --- a/crates/evm/src/trace/mod.rs +++ b/crates/evm/traces/src/lib.rs @@ -1,11 +1,16 @@ -use crate::{ - abi::CHEATCODE_ADDRESS, debug::Instruction, trace::identifier::LocalTraceIdentifier, CallKind, -}; +//! # foundry-evm-traces +//! +//! EVM trace identifying and decoding. + +#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] + +#[macro_use] +extern crate tracing; + use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; -pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; use ethers::types::{DefaultFrame, GethDebugTracingOptions, StructLog}; -pub use executor::TracingExecutor; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_evm_core::{constants::CHEATCODE_ADDRESS, debug::Instruction, utils::CallKind}; use foundry_utils::types::ToEthers; use hashbrown::HashMap; use itertools::Itertools; @@ -22,9 +27,14 @@ use yansi::{Color, Paint}; /// /// Identifiers figure out what ABIs and labels belong to all the addresses of the trace. pub mod identifier; +use identifier::LocalTraceIdentifier; mod decoder; -mod executor; +pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; + +mod inspector; +pub use inspector::Tracer; + pub mod node; pub mod utils; @@ -112,8 +122,7 @@ impl CallTraceArena { contract_storage.insert(B256::from(key), B256::from(value)); log.storage = Some( contract_storage - .clone() - .into_iter() + .iter_mut() .map(|t| (t.0.to_ethers(), t.1.to_ethers())) .collect(), ); @@ -192,7 +201,7 @@ const CALL: &str = "→ "; const RETURN: &str = "← "; impl fmt::Display for CallTraceArena { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn inner( arena: &CallTraceArena, writer: &mut (impl Write + ?Sized), @@ -276,7 +285,7 @@ pub enum RawOrDecodedLog { } impl fmt::Display for RawOrDecodedLog { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { RawOrDecodedLog::Raw(log) => { for (i, topic) in log.topics().iter().enumerate() { @@ -372,7 +381,7 @@ impl Default for RawOrDecodedReturnData { } impl fmt::Display for RawOrDecodedReturnData { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self { RawOrDecodedReturnData::Raw(bytes) => { if bytes.is_empty() { @@ -508,7 +517,7 @@ impl Default for CallTrace { } impl fmt::Display for CallTrace { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let address = self.address.to_checksum(None); if self.created() { write!( diff --git a/crates/evm/src/trace/node.rs b/crates/evm/traces/src/node.rs similarity index 96% rename from crates/evm/src/trace/node.rs rename to crates/evm/traces/src/node.rs index 2f0deb93684fb..e212f60ca9cdd 100644 --- a/crates/evm/src/trace/node.rs +++ b/crates/evm/traces/src/node.rs @@ -1,18 +1,13 @@ use crate::{ - decode, - executor::CHEATCODE_ADDRESS, - trace::{ - utils, utils::decode_cheatcode_outputs, CallTrace, LogCallOrder, RawOrDecodedCall, - RawOrDecodedLog, RawOrDecodedReturnData, - }, - CallKind, + utils, utils::decode_cheatcode_outputs, CallTrace, LogCallOrder, RawOrDecodedCall, + RawOrDecodedLog, RawOrDecodedReturnData, }; use alloy_dyn_abi::{FunctionExt, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::Address; use ethers::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; -// use super::trace_types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; use foundry_common::SELECTOR_LEN; +use foundry_evm_core::{constants::CHEATCODE_ADDRESS, decode, utils::CallKind}; use foundry_utils::types::ToEthers; use revm::interpreter::InstructionResult; use serde::{Deserialize, Serialize}; diff --git a/crates/evm/src/trace/utils.rs b/crates/evm/traces/src/utils.rs similarity index 99% rename from crates/evm/src/trace/utils.rs rename to crates/evm/traces/src/utils.rs index 6ad1879126b57..d5361491d0b52 100644 --- a/crates/evm/src/trace/utils.rs +++ b/crates/evm/traces/src/utils.rs @@ -1,10 +1,10 @@ //! utilities used within tracing -use crate::decode; use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::Address; use foundry_common::{abi::format_token, SELECTOR_LEN}; +use foundry_evm_core::decode; use std::collections::HashMap; /// Returns the label for the given [DynSolValue] diff --git a/crates/fmt/src/visit.rs b/crates/fmt/src/visit.rs index e48f912e4a96f..da7f3ca376d10 100644 --- a/crates/fmt/src/visit.rs +++ b/crates/fmt/src/visit.rs @@ -5,7 +5,7 @@ use crate::solang_ext::pt::*; /// A trait that is invoked while traversing the Solidity Parse Tree. /// Each method of the [Visitor] trait is a hook that can be potentially overridden. /// -/// Currently the main implementor of this trait is the [`Formatter`](crate::Formatter) struct. +/// Currently the main implementor of this trait is the [`Formatter`](crate::Formatter<'_>) struct. pub trait Visitor { type Error: std::error::Error; diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 3078c2bc7bc1c..6d06fca366114 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -93,7 +93,7 @@ fn test_formatter(filename: &str, config: FormatterConfig, source: &str, expecte } impl std::fmt::Debug for PrettyString { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&self.0) } } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index b8a1bae352fd7..c692b9a6051b1 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -26,8 +26,8 @@ foundry-evm.workspace = true comfy-table = "7" ethers = { workspace = true, features = ["solc-full"] } -foundry-compilers = { workspace = true, default-features = false, features = ["full"] } -foundry-block-explorers = { workspace = true, default-features = false, features = ["foundry-compilers"] } +foundry-compilers = { workspace = true, features = ["full"] } +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } eyre.workspace = true proptest = "1" rayon = "1" diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 6e869bc0a2e53..d16086c4f0e05 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -7,7 +7,8 @@ use forge::{ analysis::SourceAnalyzer, anchors::find_anchors, ContractId, CoverageReport, CoverageReporter, DebugReporter, ItemAnchor, LcovReporter, SummaryReporter, }, - executor::{inspector::CheatsConfig, opts::EvmOpts}, + inspectors::CheatsConfig, + opts::EvmOpts, result::SuiteResult, revm::primitives::SpecId, utils::{build_ic_pc_map, ICPCMap}, diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index eea8eca9969c8..cdbaaca4fef72 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -195,7 +195,7 @@ enum Input { } impl fmt::Display for Line { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 { None => f.write_str(" "), Some(idx) => write!(f, "{:<4}", idx + 1), diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index f9b45f6088195..a1a5f903f3ff2 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -3,7 +3,7 @@ use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_compilers::remappings::RelativeRemapping; use foundry_config::impl_figment_convert_basic; -use foundry_evm::HashMap; +use foundry_evm::hashbrown::HashMap; use std::path::PathBuf; /// CLI arguments for `forge remappings`. diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 41166f545ad30..df7afd11a6da0 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -8,12 +8,11 @@ use alloy_primitives::{Address, Bytes, U256}; use ethers::types::transaction::eip2718::TypedTransaction; use eyre::Result; use forge::{ - executor::{ - inspector::{cheatcodes::util::BroadcastableTransactions, CheatsConfig}, - Backend, ExecutorBuilder, - }, - trace::{CallTraceDecoder, Traces}, - CallKind, + backend::Backend, + executors::ExecutorBuilder, + inspectors::{cheatcodes::util::BroadcastableTransactions, CheatsConfig}, + traces::{CallTraceDecoder, Traces}, + utils::CallKind, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{shell, RpcUrl}; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 0a8b83aa56fd3..81faab77ef658 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -14,15 +14,16 @@ use ethers::{ }; use eyre::{ContextCompat, Result, WrapErr}; use forge::{ + backend::Backend, debug::DebugArena, decode::decode_console_logs, - executor::{opts::EvmOpts, Backend}, - trace::{ + opts::EvmOpts, + traces::{ identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, CallTraceDecoder, CallTraceDecoderBuilder, RawOrDecodedCall, RawOrDecodedReturnData, TraceKind, Traces, }, - CallKind, + utils::CallKind, }; use foundry_cli::opts::MultiWallet; use foundry_common::{ @@ -46,11 +47,9 @@ use foundry_config::{ Config, }; use foundry_evm::{ + constants::DEFAULT_CREATE2_DEPLOYER, decode, - executor::inspector::{ - cheatcodes::{util::BroadcastableTransactions, BroadcastableTransaction}, - DEFAULT_CREATE2_DEPLOYER, - }, + inspectors::cheatcodes::{util::BroadcastableTransactions, BroadcastableTransaction}, }; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future; diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 2db86e8f698a2..798b36c3aeeab 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -3,10 +3,10 @@ use alloy_primitives::{Address, Bytes, U256}; use ethers::types::NameOrAddress; use eyre::Result; use forge::{ - executor::{CallResult, DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, + constants::CALLER, + executors::{CallResult, DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, revm::interpreter::{return_ok, InstructionResult}, - trace::{TraceKind, Traces}, - CALLER, + traces::{TraceKind, Traces}, }; use tracing::log::trace; diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index b94254b1fde7b..100d8c349ba5b 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -5,9 +5,7 @@ use alloy_primitives::{Address, B256}; use ethers::{prelude::NameOrAddress, types::transaction::eip2718::TypedTransaction}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{abi::format_token_raw, RpcUrl, SELECTOR_LEN}; -use foundry_evm::{ - executor::inspector::DEFAULT_CREATE2_DEPLOYER, trace::CallTraceDecoder, CallKind, -}; +use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder, utils::CallKind}; use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index ccfcf6d423167..7af0e4042a8f7 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -139,7 +139,7 @@ impl TestFilter for FilterArgs { } impl fmt::Display for FilterArgs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut patterns = Vec::new(); if let Some(ref p) = self.test_pattern { patterns.push(format!("\tmatch-test: `{}`", p.as_str())); @@ -211,7 +211,7 @@ impl TestFilter for ProjectPathsAwareFilter { } impl fmt::Display for ProjectPathsAwareFilter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.args_filter.fmt(f) } } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 34e708c87c5cb..a85b5441cb910 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -4,10 +4,10 @@ use clap::Parser; use eyre::Result; use forge::{ decode::decode_console_logs, - executor::inspector::CheatsConfig, gas_report::GasReport, + inspectors::CheatsConfig, result::{SuiteResult, TestResult, TestStatus}, - trace::{ + traces::{ identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, CallTraceDecoderBuilder, TraceKind, }, diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index b1e30029c6af2..89f6e2315dad1 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -1,6 +1,6 @@ use crate::{ - executor::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, - trace::{CallTraceArena, RawOrDecodedCall, TraceKind}, + constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, + traces::{CallTraceArena, RawOrDecodedCall, TraceKind}, }; use alloy_primitives::U256; use comfy_table::{presets::ASCII_MARKDOWN, *}; @@ -116,7 +116,7 @@ impl GasReport { } impl Display for GasReport { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { for (name, contract) in self.contracts.iter() { if contract.functions.is_empty() { continue diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 13e71ed6e1c1e..5cb3302b388fc 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -8,10 +8,11 @@ use foundry_compilers::{ ArtifactOutput, ProjectCompileOutput, }; use foundry_evm::{ - executor::{ - backend::Backend, fork::CreateFork, inspector::CheatsConfig, opts::EvmOpts, Executor, - ExecutorBuilder, - }, + backend::Backend, + executors::{Executor, ExecutorBuilder}, + fork::CreateFork, + inspectors::CheatsConfig, + opts::EvmOpts, revm, }; use foundry_utils::{PostLinkInput, ResolvedDependency}; diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 02ff027a60ed1..d46be910b18eb 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -6,9 +6,9 @@ use foundry_common::evm::Breakpoints; use foundry_evm::{ coverage::HitMaps, debug::DebugArena, - executor::EvmError, - fuzz::{types::FuzzCase, CounterExample}, - trace::{TraceKind, Traces}, + executors::EvmError, + fuzz::{CounterExample, FuzzCase}, + traces::{TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt, time::Duration}; diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 55189b11b1e61..1e4e97cda945e 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -11,18 +11,15 @@ use foundry_common::{ }; use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_evm::{ + constants::CALLER, decode::decode_console_logs, - executor::{CallResult, EvmError, ExecutionErr, Executor}, - fuzz::{ - invariant::{ - replay_run, InvariantContract, InvariantExecutor, InvariantFuzzError, - InvariantFuzzTestResult, - }, - types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}, - CounterExample, FuzzedExecutor, + executors::{ + fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, + invariant::{replay_run, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult}, + CallResult, EvmError, ExecutionErr, Executor, }, - trace::{load_contracts, TraceKind}, - CALLER, + fuzz::{invariant::InvariantContract, CounterExample}, + traces::{load_contracts, TraceKind}, }; use proptest::test_runner::{TestError, TestRunner}; use rayon::prelude::*; diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index c383eb779c250..b212dc83b4c72 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -1,14 +1,13 @@ //! Contains various tests for checking forge commands related to config values use alloy_primitives::{Address, B256, U256}; -use foundry_compilers::artifacts::{RevertStrings, YulDetails}; - use foundry_cli::utils as forge_utils; +use foundry_compilers::artifacts::{RevertStrings, YulDetails}; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, Config, FuzzConfig, InvariantConfig, OptimizerDetails, SolcReq, }; -use foundry_evm::executor::opts::EvmOpts; +use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ forgetest, forgetest_init, foundry_compilers::{remappings::Remapping, EvmVersion}, diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index cccb9ea7e12a4..5ecbf4ea9a6a2 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -12,7 +12,7 @@ use foundry_config::{ InvariantConfig, RpcEndpoint, RpcEndpoints, }; use foundry_evm::{ - decode::decode_console_logs, executor::inspector::CheatsConfig, revm::primitives::SpecId, + decode::decode_console_logs, inspectors::CheatsConfig, revm::primitives::SpecId, }; use std::{ collections::BTreeMap, diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index fd2f22812cdcb..dabd7183c7223 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -2,7 +2,7 @@ use crate::{config::*, test_helpers::filter::Filter}; use forge::result::SuiteResult; -use foundry_evm::trace::TraceKind; +use foundry_evm::traces::TraceKind; use std::{collections::BTreeMap, env}; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 5408713a95c31..7f09638c5179c 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -8,13 +8,11 @@ use foundry_compilers::{ }; use foundry_config::Config; use foundry_evm::{ - executor::{ - backend::Backend, - opts::{Env, EvmOpts}, - DatabaseRef, Executor, ExecutorBuilder, - }, - fuzz::FuzzedExecutor, - CALLER, + backend::Backend, + constants::CALLER, + executors::{Executor, ExecutorBuilder, FuzzedExecutor}, + opts::{Env, EvmOpts}, + revm::db::DatabaseRef, }; use foundry_utils::types::{ToAlloy, ToEthers}; use once_cell::sync::Lazy; diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index 4218cfa4b00d4..4d6354558fa25 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -17,4 +17,4 @@ serde.workspace = true serde_json.workspace = true alloy-primitives.workspace = true -alloy-dyn-abi.workspace = true \ No newline at end of file +alloy-dyn-abi.workspace = true diff --git a/crates/macros/src/fmt/token.rs b/crates/macros/src/fmt/token.rs index e206b389cdd50..9853ec7ed9d2b 100644 --- a/crates/macros/src/fmt/token.rs +++ b/crates/macros/src/fmt/token.rs @@ -8,7 +8,7 @@ use std::{fmt, fmt::Write}; pub struct TokenDisplay<'a>(pub &'a DynSolValue); impl fmt::Display for TokenDisplay<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt_token(f, self.0) } } diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 733aa0fc2ad11..bbf7deb0a8a28 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -19,7 +19,7 @@ foundry-utils.workspace = true ethers.workspace = true alloy-primitives.workspace = true -foundry-compilers = { workspace = true, features = ["project-util"]} +foundry-compilers = { workspace = true, features = ["project-util"] } eyre.workspace = true once_cell = "1" diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index dc8fd85ef657c..80d7c4c3fd88d 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -18,6 +18,7 @@ ethers-addressbook.workspace = true ethers-providers.workspace = true alloy-primitives.workspace = true +alloy-json-abi.workspace = true alloy-dyn-abi.workspace = true foundry-compilers = { workspace = true, default-features = false } diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index 0b650d50e12dc..712784ab2c9bf 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -1,13 +1,17 @@ //! Temporary utility conversion traits between ethers-rs and alloy types. +use alloy_json_abi::{Event, EventParam, Function, InternalType, Param, StateMutability}; use alloy_primitives::{Address, B256, U256 as AlloyU256, U64 as AlloyU64}; -use ethers_core::types::{H160, H256, U256, U64}; +use ethers_core::{ + abi as ethabi, + types::{H160, H256, U256, U64}, +}; -/// Conversion trait to easily convert from ethers-rs types to alloy primitive types. +/// Conversion trait to easily convert from Ethers types to Alloy types. pub trait ToAlloy { type To; - /// Converts the alloy type to the corresponding ethers-rs type. + /// Converts the Ethers type to the corresponding Alloy type. fn to_alloy(self) -> Self::To; } @@ -56,11 +60,106 @@ impl ToAlloy for u64 { } } -/// Conversion trait to easily convert from alloy primitive types to ethers-rs types. +impl ToAlloy for ethabi::Event { + type To = Event; + + fn to_alloy(self) -> Self::To { + Event { + name: self.name, + inputs: self.inputs.into_iter().map(ToAlloy::to_alloy).collect(), + anonymous: self.anonymous, + } + } +} + +impl ToAlloy for ethabi::Function { + type To = Function; + + fn to_alloy(self) -> Self::To { + Function { + name: self.name, + inputs: self.inputs.into_iter().map(ToAlloy::to_alloy).collect(), + outputs: self.outputs.into_iter().map(ToAlloy::to_alloy).collect(), + state_mutability: self.state_mutability.to_alloy(), + } + } +} + +impl ToAlloy for ethabi::Param { + type To = Param; + + fn to_alloy(self) -> Self::To { + let (ty, components) = self.kind.to_alloy(); + Param { + name: self.name, + ty, + internal_type: self.internal_type.as_deref().and_then(InternalType::parse), + components, + } + } +} + +impl ToAlloy for ethabi::EventParam { + type To = EventParam; + + fn to_alloy(self) -> Self::To { + let (ty, components) = self.kind.to_alloy(); + EventParam { name: self.name, ty, internal_type: None, components, indexed: self.indexed } + } +} + +impl ToAlloy for ethabi::ParamType { + type To = (String, Vec); + + fn to_alloy(self) -> Self::To { + let (s, t) = split_pt(self); + (s, t.into_iter().map(pt_to_param).collect()) + } +} + +fn split_pt(x: ethabi::ParamType) -> (String, Vec) { + let s = ethabi::ethabi::param_type::Writer::write_for_abi(&x, false); + let t = get_tuple(x); + (s, t) +} + +fn get_tuple(x: ethabi::ParamType) -> Vec { + match x { + ethabi::ParamType::FixedArray(x, _) | ethabi::ParamType::Array(x) => get_tuple(*x), + ethabi::ParamType::Tuple(t) => t, + _ => Default::default(), + } +} + +fn pt_to_param(x: ethabi::ParamType) -> Param { + let (ty, components) = split_pt(x); + Param { + name: String::new(), + ty, + internal_type: None, + components: components.into_iter().map(pt_to_param).collect(), + } +} + +impl ToAlloy for ethabi::StateMutability { + type To = StateMutability; + + #[inline(always)] + fn to_alloy(self) -> Self::To { + match self { + ethabi::StateMutability::Pure => StateMutability::Pure, + ethabi::StateMutability::View => StateMutability::View, + ethabi::StateMutability::NonPayable => StateMutability::NonPayable, + ethabi::StateMutability::Payable => StateMutability::Payable, + } + } +} + +/// Conversion trait to easily convert from Alloy types to Ethers types. pub trait ToEthers { type To; - /// Converts the alloy type to the corresponding ethers-rs type. + /// Converts the Alloy type to the corresponding Ethers type. fn to_ethers(self) -> Self::To; } From 93f64c7e4fae2d9302cc43f4f7bfcba721a00c13 Mon Sep 17 00:00:00 2001 From: Alejandro Munoz Date: Thu, 26 Oct 2023 20:15:58 +0100 Subject: [PATCH 0194/1963] Modified git fetch command to method to use correct root folder. (#6119) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Modified git fetch command to method to use correct root folder. * Added directory test for template initialization * Updated test comment * Cargo fmt --------- Co-authored-by: Alejandro Muñoz-McDonald --- crates/cli/src/utils/mod.rs | 3 ++- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/tests/cli/cmd.rs | 36 +++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index eab7a5b141e90..38467d5392011 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -363,11 +363,12 @@ impl<'a> Git<'a> { } pub fn fetch( + self, shallow: bool, remote: impl AsRef, branch: Option>, ) -> Result<()> { - Self::cmd_no_root() + self.cmd() .stderr(Stdio::inherit()) .arg("fetch") .args(shallow.then_some("--no-tags")) diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index bfe69889843ae..150a1fab713d0 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -68,7 +68,7 @@ impl InitArgs { // fetch the template - always fetch shallow for templates since git history will be // collapsed. gitmodules will be initialized after the template is fetched - Git::fetch(true, &template, branch)?; + git.fetch(true, &template, branch)?; // reset git history to the head of the template // first get the commit hash that was fetched let commit_hash = git.commit_hash(true, "FETCH_HEAD")?; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 4d7666ef50dbf..4e31f864a017b 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -278,6 +278,42 @@ forgetest!(can_init_with_dir, |prj: TestProject, mut cmd: TestCommand| { assert!(prj.root().join("foobar").exists()); }); +// `forge init foobar --template [template]` works with dir argument +forgetest!(can_init_with_dir_and_template, |prj: TestProject, mut cmd: TestCommand| { + cmd.args(["init", "foobar", "--template", "foundry-rs/forge-template"]); + + cmd.assert_success(); + cmd.assert_non_empty_stdout(); + assert!(prj.root().join("foobar/.git").exists()); + assert!(prj.root().join("foobar/foundry.toml").exists()); + assert!(prj.root().join("foobar/lib/forge-std").exists()); + // assert that gitmodules were correctly initialized + assert!(prj.root().join("foobar/.git/modules").exists()); + assert!(prj.root().join("foobar/src").exists()); + assert!(prj.root().join("foobar/test").exists()); +}); + +// `forge init foobar --template [template] --branch [branch]` works with dir argument +forgetest!(can_init_with_dir_and_template_and_branch, |prj: TestProject, mut cmd: TestCommand| { + cmd.args([ + "init", + "foobar", + "--template", + "foundry-rs/forge-template", + "--branch", + "test/deployments", + ]); + + cmd.assert_success(); + cmd.assert_non_empty_stdout(); + assert!(prj.root().join("foobar/.dapprc").exists()); + assert!(prj.root().join("foobar/lib/ds-test").exists()); + // assert that gitmodules were correctly initialized + assert!(prj.root().join("foobar/.git/modules").exists()); + assert!(prj.root().join("foobar/src").exists()); + assert!(prj.root().join("foobar/scripts").exists()); +}); + // `forge init --force` works on non-empty dirs forgetest!(can_init_non_empty, |prj: TestProject, mut cmd: TestCommand| { prj.create_file("README.md", "non-empty dir"); From aa257c2fb50814dfc5da4b3688cd3b95b5e3844d Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 27 Oct 2023 17:03:16 +0900 Subject: [PATCH 0195/1963] fix(`create`): concat bytecode and constructor call to match old ethabi behavior (#6134) * fix: concat bytecode and constructor call to match old ethabi behavior * fmt/clippy --- crates/forge/bin/cmd/create.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 5baae392b7401..20afc1bb905d5 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -534,20 +534,24 @@ where let data: Bytes = match (self.abi.constructor(), params.is_empty()) { (None, false) => return Err(ContractError::ConstructorError), (None, true) => self.bytecode.clone(), - (Some(constructor), _) => constructor - .abi_encode_input(¶ms) - .map_err(|f| ContractError::DetokenizationError(InvalidOutputType(f.to_string())))? - .into(), + (Some(constructor), _) => { + let input: Bytes = constructor + .abi_encode_input(¶ms) + .map_err(|f| { + ContractError::DetokenizationError(InvalidOutputType(f.to_string())) + })? + .into(); + // Concatenate the bytecode and abi-encoded constructor call. + self.bytecode.iter().copied().chain(input).collect() + } }; // create the tx object. Since we're deploying a contract, `to` is `None` - // We default to EIP-1559 transactions, but the sender can convert it back - // to a legacy one - #[cfg(feature = "legacy")] - let tx = TransactionRequest { to: None, data: Some(data), ..Default::default() }; - #[cfg(not(feature = "legacy"))] + // We default to EIP1559 transactions, but the sender can convert it back + // to a legacy one. let tx = Eip1559TransactionRequest { to: None, data: Some(data.0.into()), ..Default::default() }; + let tx = tx.into(); Ok(Deployer { From cc760aac6e971ecc89b0f90efbb38f9bb49a672d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Oct 2023 10:39:47 +0200 Subject: [PATCH 0196/1963] test: add forge create test (#6137) --- crates/forge/tests/cli/create.rs | 53 +++++++++++++++++++ .../can_create_with_constructor_args.stdout | 6 +++ 2 files changed, 59 insertions(+) create mode 100644 crates/forge/tests/fixtures/can_create_with_constructor_args.stdout diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 952f015ff7d24..e29d4165ece21 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -216,3 +216,56 @@ forgetest_async!( ); } ); + +// tests that we can deploy with constructor args +forgetest_async!( + #[serial_test::serial] + can_create_with_constructor_args, + |prj: TestProject, mut cmd: TestCommand| async move { + let (_api, handle) = spawn(NodeConfig::test()).await; + let rpc = handle.http_endpoint(); + let wallet = handle.dev_wallets().next().unwrap(); + let pk = hex::encode(wallet.signer().to_bytes()); + cmd.args(["init", "--force"]); + cmd.assert_non_empty_stdout(); + + // explicitly byte code hash for consistent checks + let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; + prj.write_config(config); + + prj.inner() + .add_source( + "ConstructorContract", + r#" +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; +contract ConstructorContract { + string public name; + + constructor(string memory _name) { + name = _name; + } +} +"#, + ) + .unwrap(); + + cmd.forge_fuse().args([ + "create", + "./src/ConstructorContract.sol:ConstructorContract", + "--use", + "solc:0.8.15", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + "--constructor-args", + "My Constructor", + ]); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_with_constructor_args.stdout"), + ); + } +); diff --git a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout new file mode 100644 index 0000000000000..ef198e784668c --- /dev/null +++ b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout @@ -0,0 +1,6 @@ +Compiling 23 files with 0.8.15 +Solc 0.8.15 finished in 2.82s +Compiler run successful! +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +Transaction hash: 0x294df85109c991ec2760cd51e5ddc869bf5dc3b249b296305ffcd1a0563b2eea From 57ffd4ae77f92631157f5800bd3d82dbda033b5f Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 27 Oct 2023 18:43:40 +0900 Subject: [PATCH 0197/1963] fix(`common`): properly parse functions in their usual form (#6136) * fix: properly parse functions in their usual form * chore: fmt * chore: add test * chore: only fallback to human-readable abi if necessary * chore: add another function for test --- crates/common/src/abi.rs | 43 ++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index abfee8d06c5c7..c7917f761bc37 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -1,6 +1,6 @@ //! ABI related helper functions use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Event, Function}; +use alloy_json_abi::{AbiItem, Event, Function}; use alloy_primitives::{hex, Address, Log, U256}; use ethers_core::types::Chain; use eyre::{ContextCompat, Result}; @@ -172,13 +172,19 @@ impl<'a> IntoFunction for &'a str { /// Given a function signature string, it tries to parse it as a `Function` pub fn get_func(sig: &str) -> Result { - Ok(match Function::parse(sig) { - Ok(func) => func, - Err(err) => { - // we return the `Function` parse error as this case is more likely - return Err(err.into()) - } - }) + if let Ok(func) = Function::parse(sig) { + Ok(func) + } else { + // Try to parse as human readable ABI. + let item = match AbiItem::parse(sig) { + Ok(item) => match item { + AbiItem::Function(func) => func, + _ => return Err(eyre::eyre!("Expected function, got {:?}", item)), + }, + Err(e) => return Err(e.into()), + }; + Ok(item.into_owned().to_owned()) + } } /// Given an event signature string, it tries to parse it as a `Event` @@ -281,6 +287,27 @@ mod tests { use alloy_dyn_abi::EventExt; use alloy_primitives::B256; + #[test] + fn test_get_func() { + let func = get_func("function foo(uint256 a, uint256 b) returns (uint256)"); + assert!(func.is_ok()); + let func = func.unwrap(); + assert_eq!(func.name, "foo"); + assert_eq!(func.inputs.len(), 2); + assert_eq!(func.inputs[0].ty, "uint256"); + assert_eq!(func.inputs[1].ty, "uint256"); + + // Stripped down function, which [Function] can parse. + let func = get_func("foo(bytes4 a, uint8 b)(bytes4)"); + assert!(func.is_ok()); + let func = func.unwrap(); + assert_eq!(func.name, "foo"); + assert_eq!(func.inputs.len(), 2); + assert_eq!(func.inputs[0].ty, "bytes4"); + assert_eq!(func.inputs[1].ty, "uint8"); + assert_eq!(func.outputs[0].ty, "bytes4"); + } + #[test] fn parse_hex_uint_tokens() { let param = DynSolType::Uint(256); From 62e3a84d0f0f4ec6fc715a8ac1ba321069ada446 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Oct 2023 11:52:49 +0200 Subject: [PATCH 0198/1963] fix: print decoded output value (#6141) --- crates/evm/traces/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 89d4e31651bb8..947e309c74978 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -256,10 +256,13 @@ impl fmt::Display for CallTraceArena { write!(writer, "{child}{EDGE}")?; write!(writer, "{}", color.paint(RETURN))?; if node.trace.created() { - if let RawOrDecodedReturnData::Raw(bytes) = &node.trace.output { - writeln!(writer, "{} bytes of code", bytes.len())?; - } else { - unreachable!("We should never have decoded calldata for contract creations"); + match &node.trace.output { + RawOrDecodedReturnData::Raw(bytes) => { + writeln!(writer, "{} bytes of code", bytes.len())?; + } + RawOrDecodedReturnData::Decoded(val) => { + writeln!(writer, "{val}")?; + } } } else { writeln!(writer, "{}", node.trace.output)?; From 70d00222c2ef74fc484b8d98c5705d131ab31871 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Oct 2023 18:34:11 +0200 Subject: [PATCH 0199/1963] fix: use selector not signature (#6146) --- crates/evm/core/src/decode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 8cd0493d7de1d..d490617e5f3ce 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -191,7 +191,7 @@ pub fn decode_revert( // try to decode a custom error if provided an abi if let Some(abi) = maybe_abi { for abi_error in abi.errors() { - if abi_error.signature()[..SELECTOR_LEN].as_bytes() == &err[..SELECTOR_LEN] { + if abi_error.selector() == err[..SELECTOR_LEN] { // if we don't decode, don't return an error, try to decode as a // string later if let Ok(decoded) = abi_error.abi_decode_input(&err[SELECTOR_LEN..], false) From dcdceda1842966d77fec0e550a1cfb9a87754993 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Oct 2023 20:05:06 +0200 Subject: [PATCH 0200/1963] fix: trest invalid opcode as revert (#6140) --- crates/anvil/src/eth/api.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 5c873230e45ae..01142018b8c06 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2161,7 +2161,8 @@ impl EthApi { return Err(InvalidTransactionError::BasicOutOfGas(gas_limit).into()) } // need to check if the revert was due to lack of gas or unrelated reason - return_revert!() => { + // we're also checking for InvalidFEOpcode here because this can be used to trigger an error common usage in openzeppelin + return_revert!() | InstructionResult::InvalidFEOpcode => { // if price or limit was included in the request then we can execute the request // again with the max gas limit to check if revert is gas related or not return if request.gas.is_some() || request.gas_price.is_some() { @@ -2233,7 +2234,9 @@ impl EthApi { // gas). InstructionResult::Revert | InstructionResult::OutOfGas | - InstructionResult::OutOfFund => { + InstructionResult::OutOfFund | + // we're also checking for InvalidFEOpcode here because this can be used to trigger an error common usage in openzeppelin + InstructionResult::InvalidFEOpcode => { lowest_gas_limit = mid_gas_limit; } // The tx failed for some other reason. From ce1b943bf3e8e39d01b14c8be258f9b81316dc7e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 27 Oct 2023 21:09:35 +0200 Subject: [PATCH 0201/1963] fix: stop erroring on failing to install hooks (#6148) --- crates/cli/src/handler.rs | 14 +++++--------- crates/cli/src/lib.rs | 3 +++ crates/cli/src/opts/wallet/mod.rs | 1 - crates/cli/src/opts/wallet/multi_wallet.rs | 1 - crates/cli/src/utils/cmd.rs | 1 - 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index c1ee8fe29a95f..a4154dc7cfe28 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -1,6 +1,5 @@ use eyre::{EyreHandler, Result}; use std::error::Error; -use tracing::error; use yansi::Paint; /// A custom context type for Foundry specific error reporting via `eyre` @@ -53,7 +52,9 @@ pub fn install() -> Result<()> { let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok(); if debug_enabled { - color_eyre::install()?; + if let Err(e) = color_eyre::install() { + debug!("failed to install color eyre error hook: {e}"); + } } else { let (panic_hook, _) = color_eyre::config::HookBuilder::default() .panic_section( @@ -61,13 +62,8 @@ pub fn install() -> Result<()> { ) .into_hooks(); panic_hook.install(); - // see - if cfg!(windows) { - if let Err(err) = eyre::set_hook(Box::new(move |_| Box::new(Handler))) { - error!(?err, "failed to install panic hook"); - } - } else { - eyre::set_hook(Box::new(move |_| Box::new(Handler)))?; + if let Err(e) = eyre::set_hook(Box::new(move |_| Box::new(Handler))) { + debug!("failed to install eyre error hook: {e}"); } } diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 39f4e95765dd2..f0e90a96c58d5 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -1,5 +1,8 @@ #![warn(unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + pub mod handler; pub mod opts; pub mod stdin; diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/cli/src/opts/wallet/mod.rs index cd9fb07811130..437c5dc02ef3b 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/cli/src/opts/wallet/mod.rs @@ -27,7 +27,6 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -use tracing::{instrument, trace}; pub mod multi_wallet; pub use multi_wallet::*; diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index 63fdb6110abd2..bad22cb31c028 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -21,7 +21,6 @@ use std::{ iter::repeat, sync::Arc, }; -use tracing::trace; macro_rules! get_wallets { ($id:ident, [ $($wallets:expr),+ ], $call:expr) => { diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index f9b33604aa464..38ff31e4e164e 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -22,7 +22,6 @@ use foundry_evm::{ }, }; use std::{fmt::Write, path::PathBuf, str::FromStr}; -use tracing::trace; use yansi::Paint; /// Given a `Project`'s output, removes the matching ABI, Bytecode and From 4422d671b39d11788731f51e67896e305503ea6c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Oct 2023 21:23:07 +0200 Subject: [PATCH 0202/1963] fix: always install error hook first (#6150) --- crates/cast/bin/main.rs | 2 +- crates/config/src/utils.rs | 9 +++++++-- crates/forge/bin/main.rs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 3ce40ef6feb90..fad3ec49da757 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -27,8 +27,8 @@ use opts::{Opts, Subcommands, ToBaseArgs}; #[tokio::main] async fn main() -> Result<()> { - utils::load_dotenv(); handler::install()?; + utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 5651dac409a7a..595fa18a61748 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -2,6 +2,7 @@ use crate::Config; use alloy_primitives::U256; +use eyre::WrapErr; use figment::value::Value; use foundry_compilers::{ remappings::{Remapping, RemappingError}, @@ -33,10 +34,14 @@ pub fn load_config_with_root(root: Option) -> Config { /// Returns the path of the top-level directory of the working git tree. If there is no working /// tree, an error is returned. pub fn find_git_root_path(relative_to: impl AsRef) -> eyre::Result { + let path = relative_to.as_ref(); let path = std::process::Command::new("git") .args(["rev-parse", "--show-toplevel"]) - .current_dir(relative_to.as_ref()) - .output()? + .current_dir(path) + .output() + .wrap_err_with(|| { + format!("Failed detect git root path in current dir: {}", path.display()) + })? .stdout; let path = std::str::from_utf8(&path)?.trim_end_matches('\n'); Ok(PathBuf::from(path)) diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 08f1afefc168e..e4489ec8277d5 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -10,8 +10,8 @@ use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; use opts::{Opts, Subcommands}; fn main() -> Result<()> { - utils::load_dotenv(); handler::install()?; + utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); From f5b9c0221b53b2197bc95182b484b05fffb2bc50 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 28 Oct 2023 01:14:56 +0200 Subject: [PATCH 0203/1963] fix: resolve constructor args (#6153) * test: add constructor args test * clippy * use resolve * fix input resolve --- crates/forge/bin/cmd/create.rs | 64 +++++++++++++------ crates/forge/tests/cli/create.rs | 37 +++++++++++ ..._create_with_tuple_constructor_args.stdout | 6 ++ 3 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 20afc1bb905d5..56c9886bfccd4 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -1,12 +1,16 @@ use super::{retry::RetryArgs, verify}; -use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; +use alloy_dyn_abi::{DynSolValue, JsonAbiExt, ResolveSolType}; use alloy_json_abi::{Constructor, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes}; use clap::{Parser, ValueHint}; use ethers::{ abi::InvalidOutputType, + contract::ContractError, prelude::{Middleware, MiddlewareBuilder}, - types::{transaction::eip2718::TypedTransaction, Chain}, + types::{ + transaction::eip2718::TypedTransaction, BlockNumber, Chain, Eip1559TransactionRequest, + TransactionReceipt, TransactionRequest, + }, }; use eyre::{Context, Result}; use foundry_cli::{ @@ -17,7 +21,7 @@ use foundry_common::{abi::parse_tokens, compile, estimate_eip1559_fees}; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalized}; use foundry_utils::types::{ToAlloy, ToEthers}; use serde_json::json; -use std::{path::PathBuf, sync::Arc}; +use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc}; /// CLI arguments for `forge create`. #[derive(Debug, Clone, Parser)] @@ -320,29 +324,28 @@ impl CreateArgs { verify.run().await } + /// Parses the given constructor arguments into a vector of `DynSolValue`s, by matching them + /// against the constructor's input params. + /// + /// Returns a list of parsed values that match the constructor's input params. fn parse_constructor_args( &self, constructor: &Constructor, constructor_args: &[String], ) -> Result> { - let params = constructor - .inputs - .iter() - .zip(constructor_args) - .map(|(input, arg)| (DynSolType::parse(&input.ty).expect("Could not parse types"), arg)) - .collect::>(); - let params_2 = params.iter().map(|(ty, arg)| (ty, arg.as_str())).collect::>(); - parse_tokens(params_2) + let mut params = Vec::with_capacity(constructor.inputs.len()); + for (input, arg) in constructor.inputs.iter().zip(constructor_args) { + // resolve the input type directly + let ty = input + .resolve() + .wrap_err_with(|| format!("Could not resolve constructor arg: input={input}"))?; + params.push((ty, arg)); + } + let params = params.iter().map(|(ty, arg)| (ty, arg.as_str())); + parse_tokens(params) } } -use ethers::{ - contract::ContractError, - types::{BlockNumber, Eip1559TransactionRequest, TransactionReceipt, TransactionRequest}, -}; - -use std::{borrow::Borrow, marker::PhantomData}; - /// `ContractFactory` is a [`DeploymentTxFactory`] object with an /// [`Arc`] middleware. This type alias exists to preserve backwards /// compatibility with less-abstract Contracts. @@ -598,4 +601,29 @@ mod tests { ]); assert_eq!(args.chain_id(), Some(9999)); } + + #[test] + fn test_parse_constructor_args() { + let args: CreateArgs = CreateArgs::parse_from([ + "foundry-cli", + "src/Domains.sol:Domains", + "--constructor-args", + "Hello", + ]); + let constructor: Constructor = serde_json::from_str(r#"{"type":"constructor","inputs":[{"name":"_name","type":"string","internalType":"string"}],"stateMutability":"nonpayable"}"#).unwrap(); + let params = args.parse_constructor_args(&constructor, &args.constructor_args).unwrap(); + assert_eq!(params, vec![DynSolValue::String("Hello".to_string())]); + } + + #[test] + fn test_parse_tuple_constructor_args() { + let args: CreateArgs = CreateArgs::parse_from([ + "foundry-cli", + "src/Domains.sol:Domains", + "--constructor-args", + "[(1,2), (2,3), (3,4)]", + ]); + let constructor: Constructor = serde_json::from_str(r#"{"type":"constructor","inputs":[{"name":"_points","type":"tuple[]","internalType":"struct Point[]","components":[{"name":"x","type":"uint256","internalType":"uint256"},{"name":"y","type":"uint256","internalType":"uint256"}]}],"stateMutability":"nonpayable"}"#).unwrap(); + let _params = args.parse_constructor_args(&constructor, &args.constructor_args).unwrap(); + } } diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index e29d4165ece21..eb1d457347220 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -267,5 +267,42 @@ contract ConstructorContract { PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests/fixtures/can_create_with_constructor_args.stdout"), ); + + prj.inner() + .add_source( + "TupleArrayConstructorContract", + r#" +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +struct Point { + uint256 x; + uint256 y; +} + +contract TupleArrayConstructorContract { + constructor(Point[] memory _points) {} +} +"#, + ) + .unwrap(); + + cmd.forge_fuse().args([ + "create", + "./src/TupleArrayConstructorContract.sol:TupleArrayConstructorContract", + "--use", + "solc:0.8.15", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + "--constructor-args", + "[(1,2), (2,3), (3,4)]", + ]); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_with_tuple_constructor_args.stdout"), + ); } ); diff --git a/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout new file mode 100644 index 0000000000000..c70251f9b269e --- /dev/null +++ b/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout @@ -0,0 +1,6 @@ +Compiling 1 files with 0.8.15 +Solc 0.8.15 finished in 26.44ms +Compiler run successful! +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 +Transaction hash: 0x69625b76d83634603a9dbc5b836ef89bafdd9fc7c180fc6d636c5088353cf501 From 459da57c85fa0fe47a695e247730b997a496f765 Mon Sep 17 00:00:00 2001 From: clabby Date: Fri, 27 Oct 2023 22:12:29 -0400 Subject: [PATCH 0204/1963] Fix `foundryup` (#6155) --- foundryup/foundryup | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 44962d6c3c890..ee70c2c9a8d21 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -81,16 +81,7 @@ main() { FOUNDRYUP_TAG=$FOUNDRYUP_VERSION # Normalize versions (handle channels, versions without v prefix - if [[ "$FOUNDRYUP_VERSION" == "nightly" ]]; then - # Locate real nightly tag - SHA=$(ensure curl -sSf "https://api.github.com/repos/$FOUNDRYUP_REPO/git/refs/tags/nightly" \ - | grep -Eo '"sha"[^,]*' \ - | grep -Eo '[^:]*$' \ - | tr -d '"' \ - | tr -d ' ' \ - | cut -d ':' -f2 ) - FOUNDRYUP_TAG="nightly-${SHA}" - elif [[ "$FOUNDRYUP_VERSION" == nightly* ]]; then + if [[ "$FOUNDRYUP_VERSION" =~ ^nightly ]]; then FOUNDRYUP_VERSION="nightly" elif [[ "$FOUNDRYUP_VERSION" == [[:digit:]]* ]]; then # Add v prefix From fab6ee2c736dbdee64d5985340d20ede56031542 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 28 Oct 2023 14:06:56 +0200 Subject: [PATCH 0205/1963] fix: gas report threshold (#6143) --- crates/evm/traces/src/identifier/local.rs | 5 +- crates/forge/bin/cmd/test/mod.rs | 4 +- crates/forge/src/gas_report.rs | 125 +++++++++++++--------- 3 files changed, 81 insertions(+), 53 deletions(-) diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index 8943ba7517d91..f0bc851562ea3 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -34,7 +34,10 @@ impl TraceIdentifier for LocalTraceIdentifier<'_> { .iter() .filter_map(|(id, (abi, known_code))| { let score = diff_score(known_code, code); - if score < 0.1 { + // Note: the diff score can be inaccurate for small contracts so we're using + // a relatively high threshold here to avoid filtering out too many + // contracts. + if score < 0.85 { Some((OrderedFloat(score), id, abi)) } else { None diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index a85b5441cb910..18dc53e1afcfc 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -675,7 +675,7 @@ async fn test( let handle = tokio::task::spawn(async move { runner.test(filter, Some(tx), test_options).await }); - let mut results: BTreeMap = BTreeMap::new(); + let mut results = BTreeMap::new(); let mut gas_report = GasReport::new(config.gas_reports, config.gas_reports_ignore); let sig_identifier = SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; @@ -807,7 +807,7 @@ async fn test( } } - // reattach the thread + // reattach the task let _results = handle.await?; trace!(target: "forge::test", "received {} results", results.len()); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 89f6e2315dad1..a8e7cab04b372 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -1,5 +1,6 @@ use crate::{ constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, + hashbrown::HashSet, traces::{CallTraceArena, RawOrDecodedCall, TraceKind}, }; use alloy_primitives::U256; @@ -8,34 +9,41 @@ use foundry_common::{calc, TestFunctionExt}; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; +/// Represents the gas report for a set of contracts. #[derive(Default, Debug, Serialize, Deserialize)] pub struct GasReport { - pub report_for: Vec, - pub ignore: Vec, - pub contracts: BTreeMap, -} - -#[derive(Debug, Serialize, Deserialize, Default)] -pub struct ContractInfo { - pub gas: U256, - pub size: U256, - pub functions: BTreeMap>, -} - -#[derive(Debug, Serialize, Deserialize, Default)] -pub struct GasInfo { - pub calls: Vec, - pub min: U256, - pub mean: U256, - pub median: U256, - pub max: U256, + /// Whether to report any contracts. + report_any: bool, + /// Contracts to generate the report for. + report_for: HashSet, + /// Contracts to ignore when generating the report. + ignore: HashSet, + /// All contracts that were analyzed grouped by their identifier + /// ``test/Counter.t.sol:CounterTest + contracts: BTreeMap, } impl GasReport { - pub fn new(report_for: Vec, ignore: Vec) -> Self { - Self { report_for, ignore, ..Default::default() } + pub fn new( + report_for: impl IntoIterator, + ignore: impl IntoIterator, + ) -> Self { + let report_for = report_for.into_iter().collect::>(); + let ignore = ignore.into_iter().collect::>(); + let report_any = report_for.is_empty() || report_for.contains("*"); + Self { report_any, report_for, ignore, ..Default::default() } + } + + /// Whether the given contract should be reported. + fn should_report(&self, contract_name: &str) -> bool { + if self.ignore.contains(contract_name) { + // could be specified in both ignore and report_for + return self.report_for.contains(contract_name) + } + self.report_any || self.report_for.contains(contract_name) } + /// Analyzes the given traces and generates a gas report. pub fn analyze(&mut self, traces: &[(TraceKind, CallTraceArena)]) { traces.iter().for_each(|(_, trace)| { self.analyze_node(0, trace); @@ -51,44 +59,44 @@ impl GasReport { } if let Some(name) = &trace.contract { - let contract_name = name.rsplit(':').next().unwrap_or(name.as_str()).to_string(); + let contract_name = name.rsplit(':').next().unwrap_or(name.as_str()); // If the user listed the contract in 'gas_reports' (the foundry.toml field) a // report for the contract is generated even if it's listed in the ignore // list. This is addressed this way because getting a report you don't expect is // preferable than not getting one you expect. A warning is printed to stderr // indicating the "double listing". - if self.report_for.contains(&contract_name) && self.ignore.contains(&contract_name) { + if self.report_for.contains(contract_name) && self.ignore.contains(contract_name) { eprintln!( "{}: {} is listed in both 'gas_reports' and 'gas_reports_ignore'.", yansi::Paint::yellow("warning").bold(), contract_name ); } - let report_contract = (!self.ignore.contains(&contract_name) && - self.report_for.contains(&"*".to_string())) || - (!self.ignore.contains(&contract_name) && self.report_for.is_empty()) || - (self.report_for.contains(&contract_name)); - if report_contract { - let contract_report = self.contracts.entry(name.to_string()).or_default(); + + if self.should_report(contract_name) { + let contract_info = self.contracts.entry(name.to_string()).or_default(); match &trace.data { - RawOrDecodedCall::Raw(bytes) if trace.created() => { - contract_report.gas = U256::from(trace.gas_cost); - contract_report.size = U256::from(bytes.len()); + RawOrDecodedCall::Raw(bytes) => { + if trace.created() { + contract_info.gas = U256::from(trace.gas_cost); + contract_info.size = U256::from(bytes.len()); + } } - // TODO: More robust test contract filtering - RawOrDecodedCall::Decoded(func, sig, _) - if !func.is_test() && !func.is_setup() => - { - let function_report = contract_report - .functions - .entry(func.clone()) - .or_default() - .entry(sig.clone()) - .or_default(); - function_report.calls.push(U256::from(trace.gas_cost)); + RawOrDecodedCall::Decoded(func, sig, _) => { + // ignore any test/setup functions + let should_include = + !(func.is_test() || func.is_invariant_test() || func.is_setup()); + if should_include { + let gas_info = contract_info + .functions + .entry(func.clone()) + .or_default() + .entry(sig.clone()) + .or_default(); + gas_info.calls.push(U256::from(trace.gas_cost)); + } } - _ => (), } } } @@ -98,6 +106,7 @@ impl GasReport { }); } + /// Finalizes the gas report by calculating the min, max, mean, and median for each function. #[must_use] pub fn finalize(mut self) -> Self { self.contracts.iter_mut().for_each(|(_, contract)| { @@ -142,18 +151,18 @@ impl Display for GasReport { Cell::new("# calls").add_attribute(Attribute::Bold), ]); contract.functions.iter().for_each(|(fname, sigs)| { - sigs.iter().for_each(|(sig, function)| { + sigs.iter().for_each(|(sig, gas_info)| { // show function signature if overloaded else name let fn_display = if sigs.len() == 1 { fname.clone() } else { sig.replace(':', "") }; table.add_row(vec![ Cell::new(fn_display).add_attribute(Attribute::Bold), - Cell::new(function.min.to_string()).fg(Color::Green), - Cell::new(function.mean.to_string()).fg(Color::Yellow), - Cell::new(function.median.to_string()).fg(Color::Yellow), - Cell::new(function.max.to_string()).fg(Color::Red), - Cell::new(function.calls.len().to_string()), + Cell::new(gas_info.min.to_string()).fg(Color::Green), + Cell::new(gas_info.mean.to_string()).fg(Color::Yellow), + Cell::new(gas_info.median.to_string()).fg(Color::Yellow), + Cell::new(gas_info.max.to_string()).fg(Color::Red), + Cell::new(gas_info.calls.len().to_string()), ]); }) }); @@ -163,3 +172,19 @@ impl Display for GasReport { Ok(()) } } + +#[derive(Debug, Serialize, Deserialize, Default)] +pub struct ContractInfo { + pub gas: U256, + pub size: U256, + pub functions: BTreeMap>, +} + +#[derive(Debug, Serialize, Deserialize, Default)] +pub struct GasInfo { + pub calls: Vec, + pub min: U256, + pub mean: U256, + pub median: U256, + pub max: U256, +} From 44ce0ce4f41ba5d7029cdbc55ac946a985fbf225 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 28 Oct 2023 19:16:02 +0200 Subject: [PATCH 0206/1963] fix: support block number as string (#6157) --- crates/anvil/core/src/eth/mod.rs | 34 ++++++++++++++++++++++++++++++++ crates/anvil/core/src/types.rs | 25 +++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index e57d1583ec042..a4b25fd8d9b73 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -885,6 +885,26 @@ mod tests { #[test] fn test_custom_reset() { + let s = r#"{"method": "anvil_reset", "params": [{"forking": {"jsonRpcUrl": "https://ethereumpublicnode.com", + "blockNumber": "18441649" + } + }]}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let req = serde_json::from_value::(value).unwrap(); + match req { + EthRequest::Reset(forking) => { + let forking = forking.and_then(|f| f.params); + assert_eq!( + forking, + Some(Forking { + json_rpc_url: Some("https://ethereumpublicnode.com".into()), + block_number: Some(18441649) + }) + ) + } + _ => unreachable!(), + } + let s = r#"{"method": "anvil_reset", "params": [ { "forking": { "jsonRpcUrl": "https://eth-mainnet.alchemyapi.io/v2/", "blockNumber": 11095000 @@ -959,6 +979,20 @@ mod tests { _ => unreachable!(), } + let s = r#"{"method":"anvil_reset","params":[{ "blockNumber": "14000000"}]}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let req = serde_json::from_value::(value).unwrap(); + match req { + EthRequest::Reset(forking) => { + let forking = forking.and_then(|f| f.params); + assert_eq!( + forking, + Some(Forking { json_rpc_url: None, block_number: Some(14000000) }) + ) + } + _ => unreachable!(), + } + let s = r#"{"method":"anvil_reset","params":[{"jsonRpcUrl": "http://localhost:8545"}]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let req = serde_json::from_value::(value).unwrap(); diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 0488bbe12c9f3..80ca1604d85a0 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -23,6 +23,10 @@ impl<'de> serde::Deserialize<'de> for Forking { #[serde(rename_all = "camelCase")] struct ForkOpts { pub json_rpc_url: Option, + #[serde( + default, + deserialize_with = "ethers_core::types::serde_helpers::deserialize_stringified_u64_opt" + )] pub block_number: Option, } @@ -199,3 +203,24 @@ pub struct NodeForkConfig { pub fork_block_number: Option, pub fork_retry_backoff: Option, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn serde_forking() { + let s = r#"{"forking": {"jsonRpcUrl": "https://ethereumpublicnode.com", + "blockNumber": "18441649" + } + }"#; + let f: Forking = serde_json::from_str(s).unwrap(); + assert_eq!( + f, + Forking { + json_rpc_url: Some("https://ethereumpublicnode.com".into()), + block_number: Some(18441649) + } + ); + } +} From dee41819c6e6bd1ea5419c613d226498ed7a2c59 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 28 Oct 2023 20:42:39 +0200 Subject: [PATCH 0207/1963] chore: use foundry fs (#6158) --- crates/forge/bin/cmd/script/build.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 5ee68168cbcf2..32a4e97af96a9 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -5,6 +5,7 @@ use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compact_to_contract, compile::{self, ContractSources}, + fs, }; use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecode, ContractBytecodeSome, Libraries}, @@ -14,7 +15,7 @@ use foundry_compilers::{ ArtifactId, Project, ProjectCompileOutput, }; use foundry_utils::{PostLinkInput, ResolvedDependency}; -use std::{collections::BTreeMap, fs, str::FromStr}; +use std::{collections::BTreeMap, str::FromStr}; use tracing::{trace, warn}; impl ScriptArgs { @@ -42,7 +43,9 @@ impl ScriptArgs { .ast .ok_or(eyre::eyre!("Source from artifact has no AST."))? .absolute_path; - let source_code = fs::read_to_string(abs_path)?; + let source_code = fs::read_to_string(abs_path).wrap_err_with(|| { + format!("Failed to read artifact source file for `{}`", id.identifier()) + })?; let contract = artifact.clone().into_contract_bytecode(); let source_contract = compact_to_contract(contract)?; sources From 037b3bc9cebd545fe3a4f05a32bf7efb82afdbd8 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 30 Oct 2023 11:52:50 -0400 Subject: [PATCH 0208/1963] feat: `v0.8.22` support (#6168) * chore: update LATEST_SOLC * feat: update lock --- Cargo.lock | 4 ++-- crates/forge/tests/cli/svm.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 360e298734b21..c0a27d5fbfb12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6731,9 +6731,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "svm-rs" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597e3a746727984cb7ea2487b6a40726cad0dbe86628e7d429aa6b8c4c153db4" +checksum = "d0cc95be7cc2c384a2f57cac56548d2178650905ebe5725bc8970ccc25529060" dependencies = [ "dirs 5.0.1", "fs2", diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 5635098edf53e..15e51e73a660c 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -11,7 +11,7 @@ use svm::Platform; /// 2. svm updated with all build info /// 3. svm bumped in ethers-rs /// 4. ethers bumped in foundry + update the `LATEST_SOLC` -const LATEST_SOLC: Version = Version::new(0, 8, 21); +const LATEST_SOLC: Version = Version::new(0, 8, 22); macro_rules! ensure_svm_releases { ($($test:ident => $platform:ident),* $(,)?) => {$( From db086c71c225d0a5ab1c1ff82f9f6a2c0008fc4d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:20:02 +0100 Subject: [PATCH 0209/1963] chore(deps): weekly `cargo update` (#6161) Updating git repository `https://github.com/alloy-rs/core/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/foundry-rs/block-explorers` Updating git repository `https://github.com/foundry-rs/compilers` Updating alloy-dyn-abi v0.4.2 (https://github.com/alloy-rs/core/#393f8068) -> #ed3bcbd9 Updating alloy-json-abi v0.4.2 (https://github.com/alloy-rs/core/#393f8068) -> #ed3bcbd9 Updating alloy-primitives v0.4.2 (https://github.com/alloy-rs/core/#393f8068) -> #ed3bcbd9 Updating alloy-sol-macro v0.4.2 (https://github.com/alloy-rs/core/#393f8068) -> #ed3bcbd9 Updating alloy-sol-type-parser v0.4.2 (https://github.com/alloy-rs/core/#393f8068) -> #ed3bcbd9 Updating alloy-sol-types v0.4.2 (https://github.com/alloy-rs/core/#393f8068) -> #ed3bcbd9 Updating const-hex v1.9.1 -> v1.10.0 Updating cpufeatures v0.2.10 -> v0.2.11 Updating num_enum v0.7.0 -> v0.7.1 Updating num_enum_derive v0.7.0 -> v0.7.1 Adding proc-macro-crate v2.0.0 Updating rustix v0.38.20 -> v0.38.21 Updating syn-solidity v0.4.2 (https://github.com/alloy-rs/core/#393f8068) -> #ed3bcbd9 Updating tempfile v3.8.0 -> v3.8.1 Updating toml v0.8.5 -> v0.8.6 Updating toml_edit v0.20.5 -> v0.20.7 Updating zerocopy v0.7.15 -> v0.7.18 Updating zerocopy-derive v0.7.15 -> v0.7.18 Co-authored-by: mattsse --- Cargo.lock | 86 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0a27d5fbfb12..41ef251e307e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" +source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" +source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" +source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" +source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" dependencies = [ "const-hex", "dunce", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" +source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" +source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -1356,13 +1356,14 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37be52ef5e3b394db27a2341010685ad5103c72ac15ce2e9420a7e8f93f342c" +checksum = "a5104de16b218eddf8e34ffe2f86f74bfa4e61e95a1b89732fccf6325efd0557" dependencies = [ "cfg-if", "cpufeatures", "hex", + "proptest", "serde", ] @@ -1402,9 +1403,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -2091,7 +2092,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.38", - "toml 0.8.5", + "toml 0.8.6", "walkdir", ] @@ -2380,7 +2381,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.5", + "toml 0.8.6", "uncased", "version_check", ] @@ -2527,7 +2528,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.8.5", + "toml 0.8.6", "tracing", "warp", ] @@ -2543,7 +2544,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.5", + "toml 0.8.6", "tracing", "tracing-subscriber", ] @@ -2770,8 +2771,8 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.5", - "toml_edit 0.20.5", + "toml 0.8.6", + "toml_edit 0.20.7", "tracing", "walkdir", ] @@ -4624,20 +4625,20 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.38", @@ -4812,7 +4813,7 @@ version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -5268,6 +5269,15 @@ dependencies = [ "toml_edit 0.19.15", ] +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.7", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -5991,9 +6001,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ "bitflags 2.4.1", "errno", @@ -6140,7 +6150,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -6787,7 +6797,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#393f80686b08490d7014c97f5b417ea9d999611d" +source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" dependencies = [ "paste", "proc-macro2", @@ -6842,13 +6852,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.3.5", + "redox_syscall 0.4.1", "rustix", "windows-sys 0.48.0", ] @@ -7137,15 +7147,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3efaf127c78d5339cc547cce4e4d973bd5e4f56e949a06d091c082ebeef2f800" +checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" dependencies = [ "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.5", + "toml_edit 0.20.7", ] [[package]] @@ -7170,9 +7180,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.5" +version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782bf6c2ddf761c1e7855405e8975472acf76f7f36d0d4328bd3b7a2fae12a85" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ "indexmap 2.0.2", "serde", @@ -8066,18 +8076,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f" +checksum = "ede7d7c7970ca2215b8c1ccf4d4f354c4733201dfaaba72d44ae5b37472e4901" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" +checksum = "4b27b1bb92570f989aac0ab7e9cbfbacdd65973f7ee920d9f0e71ebac878fd0b" dependencies = [ "proc-macro2", "quote", From 8efbdaeee2e9ca0b5d88fdb5d2af9e483c245ee5 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 30 Oct 2023 14:38:58 -0400 Subject: [PATCH 0210/1963] fix(`cheatcodes`): return early in case of reverts to not conflict with expect* logic (#6172) * feat: return early in case of reverts to not conflict with expect* logic * chore: move diagnose revert logic * add test --- .../evm/evm/src/inspectors/cheatcodes/mod.rs | 70 +++++++++++-------- crates/forge/tests/it/repros.rs | 11 +++ testdata/repros/Issue6170.t.sol | 28 ++++++++ 3 files changed, 78 insertions(+), 31 deletions(-) create mode 100644 testdata/repros/Issue6170.t.sol diff --git a/crates/evm/evm/src/inspectors/cheatcodes/mod.rs b/crates/evm/evm/src/inspectors/cheatcodes/mod.rs index e9cc1736506a7..2911f0c0ae343 100644 --- a/crates/evm/evm/src/inspectors/cheatcodes/mod.rs +++ b/crates/evm/evm/src/inspectors/cheatcodes/mod.rs @@ -831,9 +831,47 @@ impl Inspector for Cheatcodes { } } + // if there's a revert and a previous call was diagnosed as fork related revert then we can + // return a better error here + if status == InstructionResult::Revert { + if let Some(err) = self.fork_revert_diagnostic.take() { + return ( + status, + remaining_gas, + DynSolValue::String(err.to_error_msg(&self.labels)).abi_encode().into(), + ) + } + } + + // this will ensure we don't have false positives when trying to diagnose reverts in fork + // mode + let _ = self.fork_revert_diagnostic.take(); + + // try to diagnose reverts in multi-fork mode where a call is made to an address that does + // not exist + if let TransactTo::Call(test_contract) = data.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 data.db.is_forked_mode() && + status == InstructionResult::Stop && + call.contract != test_contract + { + self.fork_revert_diagnostic = + data.db.diagnose_revert(call.contract, &data.journaled_state); + } + } + // If the depth is 0, then this is the root call terminating if data.journaled_state.depth() == 0 { - // Match expected calls + // If we already have a revert, we shouldn't run the below logic as it can obfuscate an + // earlier error that happened first with unrelated information about + // another error when using cheatcodes. + if status == InstructionResult::Revert { + return (status, remaining_gas, retdata) + } + + // If there's not a revert, we can continue on to run the last logic for expect* + // cheatcodes. Match expected calls for (address, calldatas) in &self.expected_calls { // Loop over each address, and for each address, loop over each calldata it expects. for (calldata, (expected, actual_count)) in calldatas { @@ -918,36 +956,6 @@ impl Inspector for Cheatcodes { } } - // if there's a revert and a previous call was diagnosed as fork related revert then we can - // return a better error here - if status == InstructionResult::Revert { - if let Some(err) = self.fork_revert_diagnostic.take() { - return ( - status, - remaining_gas, - DynSolValue::String(err.to_error_msg(&self.labels)).abi_encode().into(), - ) - } - } - - // this will ensure we don't have false positives when trying to diagnose reverts in fork - // mode - let _ = self.fork_revert_diagnostic.take(); - - // try to diagnose reverts in multi-fork mode where a call is made to an address that does - // not exist - if let TransactTo::Call(test_contract) = data.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 data.db.is_forked_mode() && - status == InstructionResult::Stop && - call.contract != test_contract - { - self.fork_revert_diagnostic = - data.db.diagnose_revert(call.contract, &data.journaled_state); - } - } - (status, remaining_gas, retdata) } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index b040645c19fe9..45f6aeb15c896 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -6,6 +6,7 @@ use crate::{ }; use alloy_primitives::Address; use ethers::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; +use forge::result::TestStatus; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use std::str::FromStr; @@ -308,3 +309,13 @@ async fn test_issue_5808() { async fn test_issue_6115() { test_repro!("Issue6115"); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_issue_6170() { + let mut res = run_test_repro!("Issue6170"); + let mut res = res.remove("repros/Issue6170.t.sol:Issue6170Test").unwrap(); + let test = res.test_results.remove("test()").unwrap(); + assert_eq!(test.status, TestStatus::Failure); + assert_eq!(test.reason, Some("Log != expected log".to_string())); +} diff --git a/testdata/repros/Issue6170.t.sol b/testdata/repros/Issue6170.t.sol new file mode 100644 index 0000000000000..e5070b2edb5de --- /dev/null +++ b/testdata/repros/Issue6170.t.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +contract Emitter { + event Values(uint256 indexed a, uint256 indexed b); + + function plsEmit(uint256 a, uint256 b) external { + emit Values(a, b); + } +} + +// https://github.com/foundry-rs/foundry/issues/6170 +contract Issue6170Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + event Values(uint256 indexed a, uint256 b); + + Emitter e = new Emitter(); + + function test() public { + vm.expectEmit(true, true, false, true); + emit Values(69, 420); + e.plsEmit(69, 420); + } +} From e03110ac2084107985f66e2b1ca40e8989d47d9d Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 30 Oct 2023 16:35:09 -0400 Subject: [PATCH 0211/1963] fix: use both indexed and unindexed params when decoding logs (#6174) --- crates/evm/traces/src/decoder.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/evm/traces/src/decoder.rs b/crates/evm/traces/src/decoder.rs index 794626277fd33..ca9406afcb58a 100644 --- a/crates/evm/traces/src/decoder.rs +++ b/crates/evm/traces/src/decoder.rs @@ -3,7 +3,7 @@ use crate::{ node::CallTraceNode, utils, CallTraceArena, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, }; -use alloy_dyn_abi::{DynSolValue, EventExt}; +use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; use alloy_json_abi::{Event, Function, JsonAbi as Abi}; use alloy_primitives::{Address, FixedBytes, B256}; use foundry_common::{abi::get_indexed_event, SELECTOR_LEN}; @@ -334,10 +334,10 @@ impl CallTraceDecoder { for event in events { if let Ok(decoded) = event.decode_log(raw_log, false) { + let params = reconstruct_params(&event, &decoded); *log = RawOrDecodedLog::Decoded( event.name, - decoded - .body + params .into_iter() .zip(event.inputs.iter()) .map(|(param, input)| { @@ -358,6 +358,25 @@ impl CallTraceDecoder { } } +/// Restore the order of the params of a decoded event, +/// as Alloy returns the indexed and unindexed params separately. +fn reconstruct_params(event: &Event, decoded: &DecodedEvent) -> Vec { + let mut indexed = 0; + let mut unindexed = 0; + let mut inputs = vec![]; + for input in event.inputs.iter() { + if input.indexed { + inputs.push(decoded.indexed[indexed].clone()); + indexed += 1; + } else { + inputs.push(decoded.body[unindexed].clone()); + unindexed += 1; + } + } + + inputs +} + fn indexed_inputs(event: &Event) -> usize { event.inputs.iter().filter(|param| param.indexed).count() } From 94ae8974c1ac479f8d6c8ba5832b852afccfd0c5 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov <62447812+klkvr@users.noreply.github.com> Date: Tue, 31 Oct 2023 03:39:48 +0400 Subject: [PATCH 0212/1963] Raise error when to and --create are not present (#6175) Co-authored-by: Arsenii Kulikov --- crates/cast/bin/cmd/send.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index e3fefd394c4e5..512a3ea1e25dc 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -108,6 +108,10 @@ impl SendTxArgs { None }; + if code.is_none() && to.is_none() { + eyre::bail!("Must specify a destination or contract code to deploy"); + } + // Case 1: // Default to sending via eth_sendTransaction if the --unlocked flag is passed. // This should be the only way this RPC method is used as it requires a local node From 30ae702a31e175ca9c2c23bba71ee9d8520c8e45 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 31 Oct 2023 01:34:30 +0100 Subject: [PATCH 0213/1963] test: add test for cast send (#6176) --- crates/cast/bin/cmd/send.rs | 14 ++++++++------ crates/cast/tests/cli/main.rs | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 512a3ea1e25dc..25d8a1a0f9c8d 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -89,12 +89,8 @@ impl SendTxArgs { command, unlocked, } = self; - let config = Config::from(ð); - let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain_id, &provider).await?; - let api_key = config.get_etherscan_api_key(Some(chain)); - let mut sig = sig.unwrap_or_default(); + let mut sig = sig.unwrap_or_default(); let code = if let Some(SendTxSubcommands::Create { code, sig: constructor_sig, @@ -108,10 +104,16 @@ impl SendTxArgs { None }; + // ensure mandatory fields are provided if code.is_none() && to.is_none() { - eyre::bail!("Must specify a destination or contract code to deploy"); + eyre::bail!("Must specify a recipient address or contract code to deploy"); } + let config = Config::from(ð); + let provider = utils::get_provider(&config)?; + let chain = utils::get_chain(config.chain_id, &provider).await?; + let api_key = config.get_etherscan_api_key(Some(chain)); + // Case 1: // Default to sending via eth_sendTransaction if the --unlocked flag is passed. // This should be the only way this RPC method is used as it requires a local node diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 7b752e1ee618e..76506d8d41c94 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -510,3 +510,17 @@ casttest!(cast_tx_raw, |_: TestProject, mut cmd: TestCommand| { let output2 = cmd.stdout_lossy(); assert_eq!(output, output2); }); + +// ensure receipt or code is required +casttest!(cast_send_requires_to, |_: TestProject, mut cmd: TestCommand| { + cmd.args([ + "send", + "--private-key", + "0x0000000000000000000000000000000000000000000000000000000000000001", + ]); + let output = cmd.stderr_lossy(); + assert_eq!( + output.trim(), + "Error: \nMust specify a recipient address or contract code to deploy" + ); +}); From 799b82071cca5f58e1ad3df0bfb1f920ff78407d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 31 Oct 2023 20:52:27 +0100 Subject: [PATCH 0214/1963] feat: use `foundry-cheatcodes` implementations (#6131) * feat: use `foundry-cheatcodes` in `foundry-evm` * fix: deps * docs: retire `foundry-abi` * chore: refactor profiles * docs: obsolete -> deprecated * fix: fs tests * fix: repro 5808 * fix: implement `rpc` and `eth_getLogs` * fix: int test * chore: reorder EthGetLogs struct fields * chore: update JSON * docs: update dev docs and cheatcodes README * chore: rename magic bytes constants * fix: Error ABI encoding * fix: ABI-encode Error as `CheatCodeError(string)` * chore: remove bad re-export * test: update script panic message * fix: broadcast origin and caller * test: update some test messages * test: add more debug * test: don't run commands twice... * chore: clippy * fix: tracing-subscriber features * fix: re-disable color * fixes * chore: clippy * fix: error encoding * feat: auto generate solidity interface * opts * ci: fix forge-fmt * feat: re-implement `cool` * fix: FfiResult exit_code->exitCode * chore: update * fix: scripting expects * fix: rename test output methods * test: update expect msgs * chore: update broadcast staticcall error message * chore: only expand `#[vm]` macro in `cfg(test)` * test: update precompile error msg * test: update env tests * fix: expectCall value gt 0 * fix: fs error messages * fix: rm huff abi test * fix: forge fmt * fix: JSON coerce error msg * fix: JSON non-object error message * chore: random stuff * tmp: comment out sleep fuzz test * chore: mark generated files in .gitattributes * chore: uncapitalize an error msg * fix: use BTreeMap for serialized JSONs * chore: better tracing * fix: properly serialize JSON arrays * fix: missing rpc url error message * fix: mock calls * chore: clippy * fix: update broadcast sender nonce, not CREATE2 deployer * chore: use trace! for verbose cheatcode logs * feat: extend schema to include other items * feat: generate Vm from expanded interface * chore: clippy * fix: use forge-std pr * fix: use forge-std master --- .gitattributes | 2 + .github/workflows/test.yml | 7 +- Cargo.lock | 117 +- Cargo.toml | 104 +- crates/abi/README.md | 4 + crates/abi/build.rs | 4 + crates/abi/src/lib.rs | 4 + crates/cheatcodes/Cargo.toml | 21 +- crates/cheatcodes/README.md | 38 +- crates/cheatcodes/assets/cheatcodes.json | 8253 +++++++++-------- .../cheatcodes/assets/cheatcodes.schema.json | 269 +- crates/cheatcodes/src/defs/cheatcode.rs | 177 + crates/cheatcodes/src/defs/function.rs | 110 + crates/cheatcodes/src/defs/items.rs | 121 + crates/cheatcodes/src/defs/mod.rs | 307 +- crates/cheatcodes/src/defs/vm.rs | 42 +- crates/cheatcodes/src/impls/config.rs | 24 +- crates/cheatcodes/src/impls/db.rs | 307 - crates/cheatcodes/src/impls/db/error.rs | 103 - crates/cheatcodes/src/impls/error.rs | 48 +- crates/cheatcodes/src/impls/evm.rs | 21 +- crates/cheatcodes/src/impls/evm/fork.rs | 85 +- crates/cheatcodes/src/impls/evm/mock.rs | 19 +- crates/cheatcodes/src/impls/inspector.rs | 175 +- crates/cheatcodes/src/impls/json.rs | 28 +- crates/cheatcodes/src/impls/mod.rs | 46 +- crates/cheatcodes/src/impls/script.rs | 31 +- crates/cheatcodes/src/impls/test.rs | 16 +- crates/cheatcodes/src/impls/test/expect.rs | 2 +- crates/cheatcodes/src/impls/utils.rs | 24 +- crates/cheatcodes/src/lib.rs | 70 +- crates/chisel/src/executor.rs | 3 +- crates/chisel/src/runner.rs | 4 +- crates/evm/core/src/backend/diagnostic.rs | 4 +- crates/evm/core/src/backend/error.rs | 73 +- crates/evm/core/src/backend/fuzz.rs | 2 +- crates/evm/core/src/backend/mod.rs | 15 +- crates/evm/core/src/constants.rs | 4 +- crates/evm/core/src/decode.rs | 44 +- crates/evm/evm/Cargo.toml | 10 +- crates/evm/evm/src/executors/fuzz/mod.rs | 6 +- crates/evm/evm/src/executors/mod.rs | 3 +- .../evm/src/inspectors/cheatcodes/config.rs | 200 - .../evm/evm/src/inspectors/cheatcodes/env.rs | 758 -- .../evm/src/inspectors/cheatcodes/error.rs | 193 - .../evm/src/inspectors/cheatcodes/expect.rs | 570 -- .../evm/evm/src/inspectors/cheatcodes/ext.rs | 802 -- .../evm/evm/src/inspectors/cheatcodes/fork.rs | 407 - .../evm/evm/src/inspectors/cheatcodes/fs.rs | 334 - .../evm/evm/src/inspectors/cheatcodes/fuzz.rs | 18 - .../evm/src/inspectors/cheatcodes/mapping.rs | 119 - .../evm/evm/src/inspectors/cheatcodes/mod.rs | 1177 --- .../evm/src/inspectors/cheatcodes/parse.rs | 161 - .../evm/src/inspectors/cheatcodes/snapshot.rs | 30 - .../evm/evm/src/inspectors/cheatcodes/util.rs | 137 - .../evm/src/inspectors/cheatcodes/wallet.rs | 233 - crates/evm/evm/src/inspectors/debugger.rs | 2 +- crates/evm/evm/src/inspectors/mod.rs | 14 +- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/script/executor.rs | 12 +- crates/forge/bin/cmd/script/mod.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/tests/cli/cmd.rs | 38 +- crates/forge/tests/cli/config.rs | 10 +- crates/forge/tests/cli/multi_script.rs | 38 +- crates/forge/tests/cli/script.rs | 87 +- crates/forge/tests/cli/svm.rs | 2 +- crates/forge/tests/cli/test_cmd.rs | 26 +- crates/forge/tests/it/cheats.rs | 3 +- crates/forge/tests/it/config.rs | 16 +- crates/forge/tests/it/repros.rs | 2 +- crates/forge/tests/it/test_helpers.rs | 15 +- crates/macros/impl/src/cheatcodes.rs | 257 +- crates/macros/impl/src/lib.rs | 4 +- crates/test-utils/Cargo.toml | 3 + crates/test-utils/src/lib.rs | 10 + crates/test-utils/src/script.rs | 62 +- crates/test-utils/src/util.rs | 197 +- crates/utils/Cargo.toml | 4 +- crates/utils/src/error.rs | 37 +- docs/dev/architecture.md | 12 +- docs/dev/cheatcodes.md | 175 +- testdata/cheats/Env.t.sol | 65 +- testdata/cheats/Etch.t.sol | 4 +- testdata/cheats/Fs.t.sol | 165 +- testdata/cheats/GetCode.t.sol | 3 + testdata/cheats/Json.t.sol | 12 +- testdata/cheats/Load.t.sol | 4 +- testdata/cheats/RpcUrls.t.sol | 2 +- testdata/cheats/Sleep.t.sol | 2 + testdata/cheats/Store.t.sol | 4 +- testdata/cheats/TryFfi.sol | 4 +- testdata/cheats/Vm.sol | 895 +- testdata/foundry.toml | 3 + testdata/fs/Default.t.sol | 65 +- testdata/fs/Disabled.t.sol | 69 +- testdata/repros/Issue5808.t.sol | 11 +- 97 files changed, 6847 insertions(+), 11379 deletions(-) create mode 100644 crates/cheatcodes/src/defs/cheatcode.rs create mode 100644 crates/cheatcodes/src/defs/function.rs create mode 100644 crates/cheatcodes/src/defs/items.rs delete mode 100644 crates/cheatcodes/src/impls/db.rs delete mode 100644 crates/cheatcodes/src/impls/db/error.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/config.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/env.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/error.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/expect.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/ext.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/fork.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/fs.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/fuzz.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/mapping.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/mod.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/parse.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/snapshot.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/util.rs delete mode 100644 crates/evm/evm/src/inspectors/cheatcodes/wallet.rs diff --git a/.gitattributes b/.gitattributes index deea890e0c2da..f492456d97b17 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,5 @@ **/*.sol linguist-language=Solidity crates/abi/src/bindings/*.rs linguist-generated +crates/cheatcodes/assets/*.json linguist-generated +testdata/cheats/Vm.sol linguist-generated diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08fb48197472b..8496c0cbd55e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -163,7 +163,12 @@ jobs: with: cache-on-failure: true - name: forge fmt - run: cargo run --bin forge -- fmt --check testdata/ + shell: bash + # We have to ignore at shell level because testdata/ is not a valid Foundry project, + # so running `forge fmt` with `--root testdata` won't actually check anything + run: | + shopt -s extglob + cargo run --bin forge -- fmt --check testdata/**/!(Vm).sol feature-checks: name: feature checks diff --git a/Cargo.lock b/Cargo.lock index 41ef251e307e0..8f77e47bfa8ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" +source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" +source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" +source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" +source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" dependencies = [ "const-hex", "dunce", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" +source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" +source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -379,9 +379,9 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arbitrary" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e1373abdaa212b704512ec2bd8b26bd0b7d5c3f70117411a5d9a451383c859" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" [[package]] name = "ariadne" @@ -1657,9 +1657,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", @@ -2032,7 +2032,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2047,7 +2047,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "ethers-core", "once_cell", @@ -2058,7 +2058,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "Inflector", "const-hex", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "Inflector", "const-hex", @@ -2114,7 +2114,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "arrayvec", "bytes", @@ -2143,8 +2143,9 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ + "chrono", "ethers-core", "ethers-solc", "reqwest", @@ -2158,7 +2159,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "async-trait", "auto_impl", @@ -2184,7 +2185,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "async-trait", "auto_impl", @@ -2222,7 +2223,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "async-trait", "coins-bip32", @@ -2250,7 +2251,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=9754f22d06a2defe5608c4c9b809cc361443a3dc#9754f22d06a2defe5608c4c9b809cc361443a3dc" +source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" dependencies = [ "cfg-if", "const-hex", @@ -2351,6 +2352,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "fd-lock" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b0377f1edc77dbd1118507bc7a66e4ab64d2b90c66f90726dc801e73a8c68f9" +dependencies = [ + "cfg-if", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "fdlimit" version = "0.2.1" @@ -2372,9 +2384,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.11" +version = "0.10.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a014ac935975a70ad13a3bff2463b1c1b083b35ae4cb6309cfc59476aa7a181f" +checksum = "649f3e5d826594057e9a519626304d8da859ea8a0b18ce99500c586b8d45faee" dependencies = [ "atomic", "parking_lot", @@ -2610,21 +2622,22 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "const-hex", - "ethers", + "ethers-core", + "ethers-providers", + "ethers-signers", "eyre", "foundry-common", "foundry-compilers", "foundry-config", + "foundry-evm-core", "foundry-macros", "foundry-utils", - "futures", "itertools 0.11.0", "jsonpath_lib", "revm", "schemars", "serde", "serde_json", - "thiserror", "tracing", "walkdir", ] @@ -2708,7 +2721,7 @@ dependencies = [ [[package]] name = "foundry-compilers" version = "0.1.0" -source = "git+https://github.com/foundry-rs/compilers#7b63c75c8a06e66e56bcfbb7ba0920fd9ad15fc7" +source = "git+https://github.com/foundry-rs/compilers#9d205574ffc60f454d972eb101e04f2c4c82179d" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -2798,11 +2811,10 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "bytes", "const-hex", "ethers", "eyre", - "foundry-abi", + "foundry-cheatcodes", "foundry-common", "foundry-compilers", "foundry-config", @@ -2813,17 +2825,11 @@ dependencies = [ "foundry-macros", "foundry-utils", "hashbrown 0.14.2", - "itertools 0.11.0", - "jsonpath_lib", - "once_cell", "parking_lot", "proptest", "revm", - "serde", - "serde_json", "thiserror", "tracing", - "walkdir", ] [[package]] @@ -2954,6 +2960,7 @@ dependencies = [ "alloy-primitives", "ethers", "eyre", + "fd-lock 4.0.0", "foundry-common", "foundry-compilers", "foundry-config", @@ -2964,6 +2971,8 @@ dependencies = [ "regex", "serde_json", "tempfile", + "tracing", + "tracing-subscriber", "walkdir", ] @@ -2971,9 +2980,9 @@ dependencies = [ name = "foundry-utils" version = "0.2.0" dependencies = [ - "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-sol-types", "dunce", "ethers-addressbook", "ethers-contract", @@ -5203,9 +5212,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" [[package]] name = "powerfmt" @@ -6094,7 +6103,7 @@ dependencies = [ "bitflags 2.4.1", "cfg-if", "clipboard-win", - "fd-lock", + "fd-lock 3.0.13", "home", "libc", "log", @@ -6350,9 +6359,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "indexmap 2.0.2", "itoa", @@ -6372,9 +6381,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", @@ -6620,9 +6629,9 @@ dependencies = [ [[package]] name = "solang-parser" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb9fa2fa2fa6837be8a2495486ff92e3ffe68a99b6eeba288e139efdd842457" +checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" dependencies = [ "itertools 0.11.0", "lalrpop", @@ -6761,9 +6770,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2271abd7d01895a3e5bfa4b578e32f09155002ce1ec239532e297f82aafad06b" +checksum = "d76657a25d9fbbb0032705172c3ac2f47f45e479f981631aeedf440c338d0f68" dependencies = [ "build_const", "hex", @@ -6797,7 +6806,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#ed3bcbd96d75183ab27a9f0f85d59c6b341dea0b" +source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" dependencies = [ "paste", "proc-macro2", @@ -8011,9 +8020,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "176b6138793677221d420fd2f0aeeced263f197688b36484660da767bca2fa32" dependencies = [ "memchr", ] @@ -8076,18 +8085,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.18" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7d7c7970ca2215b8c1ccf4d4f354c4733201dfaaba72d44ae5b37472e4901" +checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.18" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b27b1bb92570f989aac0ab7e9cbfbacdd65973f7ee920d9f0e71ebac878fd0b" +checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 38b55c0da4afa..d45ba882b670f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,21 +46,23 @@ debug = 0 # Speed up tests and dev build [profile.dev.package] # solc -ethers-solc.opt-level = 3 +foundry-compilers.opt-level = 3 solang-parser.opt-level = 3 serde_json.opt-level = 3 # evm -revm.opt-level = 3 -revm-primitives.opt-level = 3 +alloy-primitives.opt-level = 3 +alloy-sol-types.opt-level = 3 +hashbrown.opt-level = 3 +keccak.opt-level = 3 revm-interpreter.opt-level = 3 revm-precompile.opt-level = 3 -tiny-keccak.opt-level = 3 +revm-primitives.opt-level = 3 +revm.opt-level = 3 +ruint.opt-level = 3 sha2.opt-level = 3 sha3.opt-level = 3 -keccak.opt-level = 3 -ruint.opt-level = 3 -hashbrown.opt-level = 3 +tiny-keccak.opt-level = 3 # keystores scrypt.opt-level = 3 @@ -68,13 +70,13 @@ scrypt.opt-level = 3 # forking axum.opt-level = 3 -# Optimized release profile -[profile.release] -opt-level = "s" -lto = "fat" +# Local "release" mode, more optimized than dev but much faster to compile than release +[profile.local] +inherits = "dev" +opt-level = 1 strip = true panic = "abort" -codegen-units = 1 +codegen-units = 16 # Like release, but with full debug symbols and with stack unwinds. Useful for e.g. `perf`. [profile.debug-fast] @@ -84,13 +86,16 @@ strip = "none" panic = "unwind" incremental = false -[profile.release.package] -# Optimize all non-workspace packages for speed -"*".opt-level = 3 - -# Package overrides -foundry-evm.opt-level = 3 +# Optimized release profile +[profile.release] +opt-level = 3 +lto = "fat" +strip = true +panic = "abort" +codegen-units = 1 +# Override packages which aren't perf-sensitive for faster compilation speed +[profile.release.package] foundry-abi.opt-level = 1 mdbook.opt-level = 1 protobuf.opt-level = 1 @@ -100,47 +105,6 @@ rusoto_kms.opt-level = 1 toml_edit.opt-level = 1 trezor-client.opt-level = 1 -# Given that the `"*"` above takes precedence over the defaults for build scripts and macros, we -# have to override all of them to reduce compile times -syn.opt-level = 0 -prettyplease.opt-level = 0 -lalrpop.opt-level = 0 - -ethers-contract-abigen.opt-level = 0 -ethers-contract-derive.opt-level = 0 -async-recursion.opt-level = 0 -miette-derive.opt-level = 0 -strum_macros.opt-level = 0 -enumn.opt-level = 0 -clap_derive.opt-level = 0 -serde_derive.opt-level = 0 -pear_codegen.opt-level = 0 -num_enum_derive.opt-level = 0 -scale-info-derive.opt-level = 0 -parity-scale-codec-derive.opt-level = 0 -time-macros.opt-level = 0 -phf_macros.opt-level = 0 -pin-project-internal.opt-level = 0 -auto_impl.opt-level = 0 -derive_more.opt-level = 0 -rlp-derive.opt-level = 0 -impl-trait-for-tuples.opt-level = 0 -async-trait.opt-level = 0 -tokio-macros.opt-level = 0 -tracing-attributes.opt-level = 0 -futures-macro.opt-level = 0 -thiserror-impl.opt-level = 0 -wasm-bindgen-macro-support.opt-level = 0 -wasm-bindgen-backend.opt-level = 0 - -# Local "release" mode, more optimized than dev but much faster to compile than release -[profile.local] -inherits = "dev" -opt-level = 1 -strip = true -panic = "abort" -codegen-units = 16 - [workspace.dependencies] anvil = { path = "crates/anvil" } cast = { path = "crates/cast" } @@ -192,7 +156,7 @@ alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" -solang-parser = "=0.3.2" +solang-parser = "=0.3.3" ## misc toml = "0.8" @@ -220,16 +184,16 @@ color-eyre = "0.6" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "9754f22d06a2defe5608c4c9b809cc361443a3dc" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } foundry-compilers = { git = "https://github.com/foundry-rs/compilers" } foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } diff --git a/crates/abi/README.md b/crates/abi/README.md index 908d463f4a141..a92d1dbba67fb 100644 --- a/crates/abi/README.md +++ b/crates/abi/README.md @@ -1,5 +1,9 @@ # foundry-abi +> [!WARNING] +> This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future. +> Please avoid making any changes in this crate. + Contains automatically-generated Rust bindings from Solidity ABI. Additional bindings can be generated by doing the following: diff --git a/crates/abi/build.rs b/crates/abi/build.rs index 9817d2deb30fe..4243e648c42b4 100644 --- a/crates/abi/build.rs +++ b/crates/abi/build.rs @@ -1,3 +1,7 @@ +//! **WARNING** +//! This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future. +//! Please avoid making any changes in this crate. + use ethers_contract_abigen::MultiAbigen; /// Includes a JSON ABI as a string literal. diff --git a/crates/abi/src/lib.rs b/crates/abi/src/lib.rs index 16dcdd1365185..c5e0b4ed3ec01 100644 --- a/crates/abi/src/lib.rs +++ b/crates/abi/src/lib.rs @@ -1,6 +1,10 @@ //! Foundry's Solidity ABI bindings. //! //! Automatically generated by [abigen](ethers_contract::abigen). +//! +//! **WARNING** +//! This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future. +//! Please avoid making any changes in this crate. #![warn(unused_crate_dependencies)] diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index b7ab0e287cd6c..714d2822d2321 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -13,8 +13,10 @@ exclude.workspace = true [dependencies] foundry-macros.workspace = true + alloy-primitives.workspace = true alloy-sol-types.workspace = true + serde.workspace = true serde_json.workspace = true @@ -23,19 +25,22 @@ schemars = { version = "0.8.15", optional = true } # impls foundry-common = { workspace = true, optional = true } +foundry-compilers = { workspace = true, optional = true } foundry-config = { workspace = true, optional = true } +foundry-evm-core = { workspace = true, optional = true } foundry-utils = { workspace = true, optional = true } + alloy-dyn-abi = { workspace = true, optional = true } alloy-json-abi = { workspace = true, optional = true } -ethers = { workspace = true, optional = true, features = ["ethers-solc"] } -foundry-compilers = { workspace = true, optional = true, default-features = false } +ethers-core = { workspace = true, optional = true } +ethers-signers = { workspace = true, optional = true } +ethers-providers = { workspace = true, optional = true } + eyre = { workspace = true, optional = true } -futures = { version = "0.3", optional = true } hex = { workspace = true, optional = true } itertools = { workspace = true, optional = true } jsonpath_lib = { workspace = true, optional = true } revm = { workspace = true, optional = true } -thiserror = { version = "1", optional = true } tracing = { workspace = true, optional = true } walkdir = { version = "2", optional = true } @@ -43,18 +48,20 @@ walkdir = { version = "2", optional = true } schema = ["dep:schemars"] impls = [ "dep:foundry-common", + "dep:foundry-compilers", "dep:foundry-config", + "dep:foundry-evm-core", "dep:foundry-utils", "dep:alloy-dyn-abi", "dep:alloy-json-abi", - "dep:ethers", + "dep:ethers-core", + "dep:ethers-providers", + "dep:ethers-signers", "dep:eyre", - "dep:futures", "dep:hex", "dep:itertools", "dep:jsonpath_lib", "dep:revm", - "dep:thiserror", "dep:tracing", "dep:walkdir", ] diff --git a/crates/cheatcodes/README.md b/crates/cheatcodes/README.md index 0992f2c3a3d0e..3bf38171e1960 100644 --- a/crates/cheatcodes/README.md +++ b/crates/cheatcodes/README.md @@ -2,4 +2,40 @@ Foundry cheatcodes definitions and implementations. -All cheatcodes are defined in a single macro call. +## Structure + +- [`assets/`](./assets/): JSON interface and specification +- [`src/defs`](./src/defs/mod.rs): Defines traits and structs +- [`src/impls`](./src/impls/mod.rs): Rust implementations of the cheatcodes. This is gated to the `impl` feature, since these are not needed when only using the definitions. + +## Overview + +All cheatcodes are defined in a single [`sol!`] macro call in [`src/defs/vm.rs`]. + +This, combined with the use of an internal [`Cheatcode`](../macros/impl/src/cheatcodes.rs) derive macro, +allows us to generate both the Rust definitions and the JSON specification of the cheatcodes. + +Cheatcodes are manually implemented through the `Cheatcode` trait, which is called in the +`Cheatcodes` inspector implementation. + +See the [cheatcodes dev documentation](../../docs/dev/cheatcodes.md#cheatcodes-implementation) for more details. + +### JSON interface + +The JSON interface is guaranteed to be stable, and can be used by third-party tools to interact with +the Foundry cheatcodes externally. + +For example, here are some tools that make use of the JSON interface: +- Internally, this is used to generate [a simple Solidity interface](../../testdata/cheats/Vm.sol) for testing +- (WIP) Used by [`forge-std`](https://github.com/foundry-rs/forge-std) to generate [user-friendly Solidity interfaces](https://github.com/foundry-rs/forge-std/blob/master/src/Vm.sol) +- (WIP) Used by [the Foundry book](https://github.com/foundry-rs/book) to generate [the cheatcodes reference](https://book.getfoundry.sh/cheatcodes) +- ... + +If you are making use of the JSON interface, please don't hesitate to open a PR to add your project to this list! + +### Adding a new cheatcode + +Please see the [cheatcodes dev documentation](../../docs/dev/cheatcodes.md#adding-a-new-cheatcode) on how to add new cheatcodes. + +[`sol!`]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html +[`src/defs/vm.rs`]: ./src/defs/vm.rs diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 895a2c75b19c4..b93cae6fd1c27 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -1,3764 +1,4489 @@ -[ - { - "id": "accesses", - "declaration": "function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);", - "visibility": "external", - "mutability": "", - "signature": "accesses(address)", - "selector": "0x65bc9481", - "selectorBytes": [ - 101, - 188, - 148, - 129 - ], - "description": "Gets all accessed reads and write slot from a `vm.record` session, for a given address.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "activeFork", - "declaration": "function activeFork() external view returns (uint256 forkId);", - "visibility": "external", - "mutability": "view", - "signature": "activeFork()", - "selector": "0x2f103f22", - "selectorBytes": [ - 47, - 16, - 63, - 34 - ], - "description": "Returns the identifier of the currently active fork. Reverts if no fork is currently active.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "addr", - "declaration": "function addr(uint256 privateKey) external pure returns (address keyAddr);", - "visibility": "external", - "mutability": "pure", - "signature": "addr(uint256)", - "selector": "0xffa18649", - "selectorBytes": [ - 255, - 161, - 134, - 73 - ], - "description": "Gets the address for a given private key.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "allowCheatcodes", - "declaration": "function allowCheatcodes(address account) external;", - "visibility": "external", - "mutability": "", - "signature": "allowCheatcodes(address)", - "selector": "0xea060291", - "selectorBytes": [ - 234, - 6, - 2, - 145 - ], - "description": "In forking mode, explicitly grant the given address cheatcode access.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "assume", - "declaration": "function assume(bool condition) external pure;", - "visibility": "external", - "mutability": "pure", - "signature": "assume(bool)", - "selector": "0x4c63e562", - "selectorBytes": [ - 76, - 99, - 229, - 98 - ], - "description": "If the condition is false, discard this run's fuzz inputs and generate new ones.", - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "id": "breakpoint_0", - "declaration": "function breakpoint(string calldata char) external;", - "visibility": "external", - "mutability": "", - "signature": "breakpoint(string)", - "selector": "0xf0259e92", - "selectorBytes": [ - 240, - 37, - 158, - 146 - ], - "description": "Writes a breakpoint to jump to in the debugger.", - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "id": "breakpoint_1", - "declaration": "function breakpoint(string calldata char, bool value) external;", - "visibility": "external", - "mutability": "", - "signature": "breakpoint(string,bool)", - "selector": "0xf7d39a8d", - "selectorBytes": [ - 247, - 211, - 154, - 141 - ], - "description": "Writes a conditional breakpoint to jump to in the debugger.", - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "id": "broadcast_0", - "declaration": "function broadcast() external;", - "visibility": "external", - "mutability": "", - "signature": "broadcast()", - "selector": "0xafc98040", - "selectorBytes": [ - 175, - 201, - 128, - 64 - ], - "description": "Using the address that calls the test contract, has the next call (at this call depth only)\ncreate a transaction that can later be signed and sent onchain.", - "group": "scripting", - "status": "stable", - "safety": "safe" - }, - { - "id": "broadcast_1", - "declaration": "function broadcast(address signer) external;", - "visibility": "external", - "mutability": "", - "signature": "broadcast(address)", - "selector": "0xe6962cdb", - "selectorBytes": [ - 230, - 150, - 44, - 219 - ], - "description": "Has the next call (at this call depth only) create a transaction with the address provided\nas the sender that can later be signed and sent onchain.", - "group": "scripting", - "status": "stable", - "safety": "safe" - }, - { - "id": "broadcast_2", - "declaration": "function broadcast(uint256 privateKey) external;", - "visibility": "external", - "mutability": "", - "signature": "broadcast(uint256)", - "selector": "0xf67a965b", - "selectorBytes": [ - 246, - 122, - 150, - 91 - ], - "description": "Has the next call (at this call depth only) create a transaction with the private key\nprovided as the sender that can later be signed and sent onchain.", - "group": "scripting", - "status": "stable", - "safety": "safe" - }, - { - "id": "chainId", - "declaration": "function chainId(uint256 newChainId) external;", - "visibility": "external", - "mutability": "", - "signature": "chainId(uint256)", - "selector": "0x4049ddd2", - "selectorBytes": [ - 64, - 73, - 221, - 210 - ], - "description": "Sets `block.chainid`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "clearMockedCalls", - "declaration": "function clearMockedCalls() external;", - "visibility": "external", - "mutability": "", - "signature": "clearMockedCalls()", - "selector": "0x3fdf4e15", - "selectorBytes": [ - 63, - 223, - 78, - 21 - ], - "description": "Clears all mocked calls.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "closeFile", - "declaration": "function closeFile(string calldata path) external;", - "visibility": "external", - "mutability": "", - "signature": "closeFile(string)", - "selector": "0x48c3241f", - "selectorBytes": [ - 72, - 195, - 36, - 31 - ], - "description": "Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.\n`path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "coinbase", - "declaration": "function coinbase(address newCoinbase) external;", - "visibility": "external", - "mutability": "", - "signature": "coinbase(address)", - "selector": "0xff483c54", - "selectorBytes": [ - 255, - 72, - 60, - 84 - ], - "description": "Sets `block.coinbase`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "copyFile", - "declaration": "function copyFile(string calldata from, string calldata to) external returns (uint64 copied);", - "visibility": "external", - "mutability": "", - "signature": "copyFile(string,string)", - "selector": "0xa54a87d8", - "selectorBytes": [ - 165, - 74, - 135, - 216 - ], - "description": "Copies the contents of one file to another. This function will **overwrite** the contents of `to`.\nOn success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`.\nBoth `from` and `to` are relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "createDir", - "declaration": "function createDir(string calldata path, bool recursive) external;", - "visibility": "external", - "mutability": "", - "signature": "createDir(string,bool)", - "selector": "0x168b64d3", - "selectorBytes": [ - 22, - 139, - 100, - 211 - ], - "description": "Creates a new, empty directory at the provided path.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- User lacks permissions to modify `path`.\n- A parent of the given path doesn't exist and `recursive` is false.\n- `path` already exists and `recursive` is false.\n`path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "createFork_0", - "declaration": "function createFork(string calldata urlOrAlias) external returns (uint256 forkId);", - "visibility": "external", - "mutability": "", - "signature": "createFork(string)", - "selector": "0x31ba3498", - "selectorBytes": [ - 49, - 186, - 52, - 152 - ], - "description": "Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "createFork_1", - "declaration": "function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);", - "visibility": "external", - "mutability": "", - "signature": "createFork(string,uint256)", - "selector": "0x6ba3ba2b", - "selectorBytes": [ - 107, - 163, - 186, - 43 - ], - "description": "Creates a new fork with the given endpoint and block and returns the identifier of the fork.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "createFork_2", - "declaration": "function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);", - "visibility": "external", - "mutability": "", - "signature": "createFork(string,bytes32)", - "selector": "0x7ca29682", - "selectorBytes": [ - 124, - 162, - 150, - 130 - ], - "description": "Creates a new fork with the given endpoint and at the block the given transaction was mined in,\nreplays all transaction mined in the block before the transaction, and returns the identifier of the fork.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "createSelectFork_0", - "declaration": "function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);", - "visibility": "external", - "mutability": "", - "signature": "createSelectFork(string)", - "selector": "0x98680034", - "selectorBytes": [ - 152, - 104, - 0, - 52 - ], - "description": "Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "createSelectFork_1", - "declaration": "function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);", - "visibility": "external", - "mutability": "", - "signature": "createSelectFork(string,uint256)", - "selector": "0x71ee464d", - "selectorBytes": [ - 113, - 238, - 70, - 77 - ], - "description": "Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "createSelectFork_2", - "declaration": "function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);", - "visibility": "external", - "mutability": "", - "signature": "createSelectFork(string,bytes32)", - "selector": "0x84d52b7a", - "selectorBytes": [ - 132, - 213, - 43, - 122 - ], - "description": "Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in,\nreplays all transaction mined in the block before the transaction, returns the identifier of the fork.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "createWallet_0", - "declaration": "function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);", - "visibility": "external", - "mutability": "", - "signature": "createWallet(string)", - "selector": "0x7404f1d2", - "selectorBytes": [ - 116, - 4, - 241, - 210 - ], - "description": "Derives a private key from the name, labels the account with that name, and returns the wallet.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "createWallet_1", - "declaration": "function createWallet(uint256 privateKey) external returns (Wallet memory wallet);", - "visibility": "external", - "mutability": "", - "signature": "createWallet(uint256)", - "selector": "0x7a675bb6", - "selectorBytes": [ - 122, - 103, - 91, - 182 - ], - "description": "Generates a wallet from the private key and returns the wallet.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "createWallet_2", - "declaration": "function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);", - "visibility": "external", - "mutability": "", - "signature": "createWallet(uint256,string)", - "selector": "0xed7c5462", - "selectorBytes": [ - 237, - 124, - 84, - 98 - ], - "description": "Generates a wallet from the private key, labels the account with that name, and returns the wallet.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "deal", - "declaration": "function deal(address account, uint256 newBalance) external;", - "visibility": "external", - "mutability": "", - "signature": "deal(address,uint256)", - "selector": "0xc88a5e6d", - "selectorBytes": [ - 200, - 138, - 94, - 109 - ], - "description": "Sets an address' balance.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "deriveKey_0", - "declaration": "function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);", - "visibility": "external", - "mutability": "pure", - "signature": "deriveKey(string,uint32)", - "selector": "0x6229498b", - "selectorBytes": [ - 98, - 41, - 73, - 139 - ], - "description": "Derive a private key from a provided mnenomic string (or mnenomic file path)\nat the derivation path `m/44'/60'/0'/0/{index}`.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "deriveKey_1", - "declaration": "function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) external pure returns (uint256 privateKey);", - "visibility": "external", - "mutability": "pure", - "signature": "deriveKey(string,string,uint32)", - "selector": "0x6bcb2c1b", - "selectorBytes": [ - 107, - 203, - 44, - 27 - ], - "description": "Derive a private key from a provided mnenomic string (or mnenomic file path)\nat `{derivationPath}{index}`.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "deriveKey_2", - "declaration": "function deriveKey(string calldata mnemonic, uint32 index, string calldata language) external pure returns (uint256 privateKey);", - "visibility": "external", - "mutability": "pure", - "signature": "deriveKey(string,uint32,string)", - "selector": "0x32c8176d", - "selectorBytes": [ - 50, - 200, - 23, - 109 - ], - "description": "Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language\nat the derivation path `m/44'/60'/0'/0/{index}`.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "deriveKey_3", - "declaration": "function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) external pure returns (uint256 privateKey);", - "visibility": "external", - "mutability": "pure", - "signature": "deriveKey(string,string,uint32,string)", - "selector": "0x29233b1f", - "selectorBytes": [ - 41, - 35, - 59, - 31 - ], - "description": "Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language\nat `{derivationPath}{index}`.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "difficulty", - "declaration": "function difficulty(uint256 newDifficulty) external;", - "visibility": "external", - "mutability": "", - "signature": "difficulty(uint256)", - "selector": "0x46cc92d9", - "selectorBytes": [ - 70, - 204, - 146, - 217 - ], - "description": "Sets `block.difficulty`.\nNot available on EVM versions from Paris onwards. Use `prevrandao` instead.\nReverts if used on unsupported EVM versions.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "envAddress_0", - "declaration": "function envAddress(string calldata name) external view returns (address value);", - "visibility": "external", - "mutability": "view", - "signature": "envAddress(string)", - "selector": "0x350d56bf", - "selectorBytes": [ - 53, - 13, - 86, - 191 - ], - "description": "Gets the environment variable `name` and parses it as `address`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envAddress_1", - "declaration": "function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envAddress(string,string)", - "selector": "0xad31b9fa", - "selectorBytes": [ - 173, - 49, - 185, - 250 - ], - "description": "Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envBool_0", - "declaration": "function envBool(string calldata name) external view returns (bool value);", - "visibility": "external", - "mutability": "view", - "signature": "envBool(string)", - "selector": "0x7ed1ec7d", - "selectorBytes": [ - 126, - 209, - 236, - 125 - ], - "description": "Gets the environment variable `name` and parses it as `bool`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envBool_1", - "declaration": "function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envBool(string,string)", - "selector": "0xaaaddeaf", - "selectorBytes": [ - 170, - 173, - 222, - 175 - ], - "description": "Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envBytes32_0", - "declaration": "function envBytes32(string calldata name) external view returns (bytes32 value);", - "visibility": "external", - "mutability": "view", - "signature": "envBytes32(string)", - "selector": "0x97949042", - "selectorBytes": [ - 151, - 148, - 144, - 66 - ], - "description": "Gets the environment variable `name` and parses it as `bytes32`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envBytes32_1", - "declaration": "function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envBytes32(string,string)", - "selector": "0x5af231c1", - "selectorBytes": [ - 90, - 242, - 49, - 193 - ], - "description": "Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envBytes_0", - "declaration": "function envBytes(string calldata name) external view returns (bytes memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envBytes(string)", - "selector": "0x4d7baf06", - "selectorBytes": [ - 77, - 123, - 175, - 6 - ], - "description": "Gets the environment variable `name` and parses it as `bytes`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envBytes_1", - "declaration": "function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envBytes(string,string)", - "selector": "0xddc2651b", - "selectorBytes": [ - 221, - 194, - 101, - 27 - ], - "description": "Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envInt_0", - "declaration": "function envInt(string calldata name) external view returns (int256 value);", - "visibility": "external", - "mutability": "view", - "signature": "envInt(string)", - "selector": "0x892a0c61", - "selectorBytes": [ - 137, - 42, - 12, - 97 - ], - "description": "Gets the environment variable `name` and parses it as `int256`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envInt_1", - "declaration": "function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envInt(string,string)", - "selector": "0x42181150", - "selectorBytes": [ - 66, - 24, - 17, - 80 - ], - "description": "Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_0", - "declaration": "function envOr(string calldata name, bool defaultValue) external returns (bool value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,bool)", - "selector": "0x4777f3cf", - "selectorBytes": [ - 71, - 119, - 243, - 207 - ], - "description": "Gets the environment variable `name` and parses it as `bool`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_1", - "declaration": "function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,uint256)", - "selector": "0x5e97348f", - "selectorBytes": [ - 94, - 151, - 52, - 143 - ], - "description": "Gets the environment variable `name` and parses it as `uint256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_10", - "declaration": "function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external returns (address[] memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string,address[])", - "selector": "0xc74e9deb", - "selectorBytes": [ - 199, - 78, - 157, - 235 - ], - "description": "Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_11", - "declaration": "function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external returns (bytes32[] memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string,bytes32[])", - "selector": "0x2281f367", - "selectorBytes": [ - 34, - 129, - 243, - 103 - ], - "description": "Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_12", - "declaration": "function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external returns (string[] memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string,string[])", - "selector": "0x859216bc", - "selectorBytes": [ - 133, - 146, - 22, - 188 - ], - "description": "Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_13", - "declaration": "function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external returns (bytes[] memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string,bytes[])", - "selector": "0x64bc3e64", - "selectorBytes": [ - 100, - 188, - 62, - 100 - ], - "description": "Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_2", - "declaration": "function envOr(string calldata name, int256 defaultValue) external returns (int256 value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,int256)", - "selector": "0xbbcb713e", - "selectorBytes": [ - 187, - 203, - 113, - 62 - ], - "description": "Gets the environment variable `name` and parses it as `int256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_3", - "declaration": "function envOr(string calldata name, address defaultValue) external returns (address value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,address)", - "selector": "0x561fe540", - "selectorBytes": [ - 86, - 31, - 229, - 64 - ], - "description": "Gets the environment variable `name` and parses it as `address`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_4", - "declaration": "function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,bytes32)", - "selector": "0xb4a85892", - "selectorBytes": [ - 180, - 168, - 88, - 146 - ], - "description": "Gets the environment variable `name` and parses it as `bytes32`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_5", - "declaration": "function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string)", - "selector": "0xd145736c", - "selectorBytes": [ - 209, - 69, - 115, - 108 - ], - "description": "Gets the environment variable `name` and parses it as `string`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_6", - "declaration": "function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,bytes)", - "selector": "0xb3e47705", - "selectorBytes": [ - 179, - 228, - 119, - 5 - ], - "description": "Gets the environment variable `name` and parses it as `bytes`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_7", - "declaration": "function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external returns (bool[] memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string,bool[])", - "selector": "0xeb85e83b", - "selectorBytes": [ - 235, - 133, - 232, - 59 - ], - "description": "Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_8", - "declaration": "function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external returns (uint256[] memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string,uint256[])", - "selector": "0x74318528", - "selectorBytes": [ - 116, - 49, - 133, - 40 - ], - "description": "Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envOr_9", - "declaration": "function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external returns (int256[] memory value);", - "visibility": "external", - "mutability": "", - "signature": "envOr(string,string,int256[])", - "selector": "0x4700d74b", - "selectorBytes": [ - 71, - 0, - 215, - 75 - ], - "description": "Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envString_0", - "declaration": "function envString(string calldata name) external view returns (string memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envString(string)", - "selector": "0xf877cb19", - "selectorBytes": [ - 248, - 119, - 203, - 25 - ], - "description": "Gets the environment variable `name` and parses it as `string`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envString_1", - "declaration": "function envString(string calldata name, string calldata delim) external view returns (string[] memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envString(string,string)", - "selector": "0x14b02bc9", - "selectorBytes": [ - 20, - 176, - 43, - 201 - ], - "description": "Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envUint_0", - "declaration": "function envUint(string calldata name) external view returns (uint256 value);", - "visibility": "external", - "mutability": "view", - "signature": "envUint(string)", - "selector": "0xc1978d1f", - "selectorBytes": [ - 193, - 151, - 141, - 31 - ], - "description": "Gets the environment variable `name` and parses it as `uint256`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "envUint_1", - "declaration": "function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);", - "visibility": "external", - "mutability": "view", - "signature": "envUint(string,string)", - "selector": "0xf3dec099", - "selectorBytes": [ - 243, - 222, - 192, - 153 - ], - "description": "Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "etch", - "declaration": "function etch(address target, bytes calldata newRuntimeBytecode) external;", - "visibility": "external", - "mutability": "", - "signature": "etch(address,bytes)", - "selector": "0xb4d6c782", - "selectorBytes": [ - 180, - 214, - 199, - 130 - ], - "description": "Sets an address' code.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "exists", - "declaration": "function exists(string calldata path) external returns (bool result);", - "visibility": "external", - "mutability": "", - "signature": "exists(string)", - "selector": "0x261a323e", - "selectorBytes": [ - 38, - 26, - 50, - 62 - ], - "description": "Returns true if the given path points to an existing entity, else returns false.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "expectCallMinGas_0", - "declaration": "function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCallMinGas(address,uint256,uint64,bytes)", - "selector": "0x08e4e116", - "selectorBytes": [ - 8, - 228, - 225, - 22 - ], - "description": "Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectCallMinGas_1", - "declaration": "function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCallMinGas(address,uint256,uint64,bytes,uint64)", - "selector": "0xe13a1834", - "selectorBytes": [ - 225, - 58, - 24, - 52 - ], - "description": "Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectCall_0", - "declaration": "function expectCall(address callee, bytes calldata data) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCall(address,bytes)", - "selector": "0xbd6af434", - "selectorBytes": [ - 189, - 106, - 244, - 52 - ], - "description": "Expects a call to an address with the specified calldata.\nCalldata can either be a strict or a partial match.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectCall_1", - "declaration": "function expectCall(address callee, bytes calldata data, uint64 count) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCall(address,bytes,uint64)", - "selector": "0xc1adbbff", - "selectorBytes": [ - 193, - 173, - 187, - 255 - ], - "description": "Expects given number of calls to an address with the specified calldata.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectCall_2", - "declaration": "function expectCall(address callee, uint256 msgValue, bytes calldata data) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCall(address,uint256,bytes)", - "selector": "0xf30c7ba3", - "selectorBytes": [ - 243, - 12, - 123, - 163 - ], - "description": "Expects a call to an address with the specified `msg.value` and calldata.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectCall_3", - "declaration": "function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCall(address,uint256,bytes,uint64)", - "selector": "0xa2b1a1ae", - "selectorBytes": [ - 162, - 177, - 161, - 174 - ], - "description": "Expects given number of calls to an address with the specified `msg.value` and calldata.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectCall_4", - "declaration": "function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCall(address,uint256,uint64,bytes)", - "selector": "0x23361207", - "selectorBytes": [ - 35, - 54, - 18, - 7 - ], - "description": "Expect a call to an address with the specified `msg.value`, gas, and calldata.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectCall_5", - "declaration": "function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;", - "visibility": "external", - "mutability": "", - "signature": "expectCall(address,uint256,uint64,bytes,uint64)", - "selector": "0x65b7b7cc", - "selectorBytes": [ - 101, - 183, - 183, - 204 - ], - "description": "Expects given number of calls to an address with the specified `msg.value`, gas, and calldata.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectEmit_0", - "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;", - "visibility": "external", - "mutability": "", - "signature": "expectEmit(bool,bool,bool,bool)", - "selector": "0x491cc7c2", - "selectorBytes": [ - 73, - 28, - 199, - 194 - ], - "description": "Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).\nCall this function, then emit an event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data (as specified by the booleans).", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectEmit_1", - "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external;", - "visibility": "external", - "mutability": "", - "signature": "expectEmit(bool,bool,bool,bool,address)", - "selector": "0x81bad6f3", - "selectorBytes": [ - 129, - 186, - 214, - 243 - ], - "description": "Same as the previous method, but also checks supplied address against emitting contract.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectEmit_2", - "declaration": "function expectEmit() external;", - "visibility": "external", - "mutability": "", - "signature": "expectEmit()", - "selector": "0x440ed10d", - "selectorBytes": [ - 68, - 14, - 209, - 13 - ], - "description": "Prepare an expected log with all topic and data checks enabled.\nCall this function, then emit an event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectEmit_3", - "declaration": "function expectEmit(address emitter) external;", - "visibility": "external", - "mutability": "", - "signature": "expectEmit(address)", - "selector": "0x86b9620d", - "selectorBytes": [ - 134, - 185, - 98, - 13 - ], - "description": "Same as the previous method, but also checks supplied address against emitting contract.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectRevert_0", - "declaration": "function expectRevert() external;", - "visibility": "external", - "mutability": "", - "signature": "expectRevert()", - "selector": "0xf4844814", - "selectorBytes": [ - 244, - 132, - 72, - 20 - ], - "description": "Expects an error on next call with any revert data.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectRevert_1", - "declaration": "function expectRevert(bytes4 revertData) external;", - "visibility": "external", - "mutability": "", - "signature": "expectRevert(bytes4)", - "selector": "0xc31eb0e0", - "selectorBytes": [ - 195, - 30, - 176, - 224 - ], - "description": "Expects an error on next call that starts with the revert data.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectRevert_2", - "declaration": "function expectRevert(bytes calldata revertData) external;", - "visibility": "external", - "mutability": "", - "signature": "expectRevert(bytes)", - "selector": "0xf28dceb3", - "selectorBytes": [ - 242, - 141, - 206, - 179 - ], - "description": "Expects an error on next call that exactly matches the revert data.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectSafeMemory", - "declaration": "function expectSafeMemory(uint64 min, uint64 max) external;", - "visibility": "external", - "mutability": "", - "signature": "expectSafeMemory(uint64,uint64)", - "selector": "0x6d016688", - "selectorBytes": [ - 109, - 1, - 102, - 136 - ], - "description": "Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other\nmemory is written to, the test will fail. Can be called multiple times to add more ranges to the set.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "expectSafeMemoryCall", - "declaration": "function expectSafeMemoryCall(uint64 min, uint64 max) external;", - "visibility": "external", - "mutability": "", - "signature": "expectSafeMemoryCall(uint64,uint64)", - "selector": "0x05838bf4", - "selectorBytes": [ - 5, - 131, - 139, - 244 - ], - "description": "Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext.\nIf any other memory is written to, the test will fail. Can be called multiple times to add more ranges\nto the set.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "fee", - "declaration": "function fee(uint256 newBasefee) external;", - "visibility": "external", - "mutability": "", - "signature": "fee(uint256)", - "selector": "0x39b37ab0", - "selectorBytes": [ - 57, - 179, - 122, - 176 - ], - "description": "Sets `block.basefee`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "ffi", - "declaration": "function ffi(string[] calldata commandInput) external returns (bytes memory result);", - "visibility": "external", - "mutability": "", - "signature": "ffi(string[])", - "selector": "0x89160467", - "selectorBytes": [ - 137, - 22, - 4, - 103 - ], - "description": "Performs a foreign function call via the terminal.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "fsMetadata", - "declaration": "function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);", - "visibility": "external", - "mutability": "view", - "signature": "fsMetadata(string)", - "selector": "0xaf368a08", - "selectorBytes": [ - 175, - 54, - 138, - 8 - ], - "description": "Given a path, query the file system to get information about a file, directory, etc.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "getCode", - "declaration": "function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);", - "visibility": "external", - "mutability": "view", - "signature": "getCode(string)", - "selector": "0x8d1cc925", - "selectorBytes": [ - 141, - 28, - 201, - 37 - ], - "description": "Gets the creation bytecode from an artifact file. Takes in the relative path to the json file.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "getDeployedCode", - "declaration": "function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);", - "visibility": "external", - "mutability": "view", - "signature": "getDeployedCode(string)", - "selector": "0x3ebf73b4", - "selectorBytes": [ - 62, - 191, - 115, - 180 - ], - "description": "Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "getLabel", - "declaration": "function getLabel(address account) external returns (string memory currentLabel);", - "visibility": "external", - "mutability": "", - "signature": "getLabel(address)", - "selector": "0x28a249b0", - "selectorBytes": [ - 40, - 162, - 73, - 176 - ], - "description": "Gets the label for the specified address.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "getMappingKeyAndParentOf", - "declaration": "function getMappingKeyAndParentOf(address target, bytes32 elementSlot) external returns (bool found, bytes32 key, bytes32 parent);", - "visibility": "external", - "mutability": "", - "signature": "getMappingKeyAndParentOf(address,bytes32)", - "selector": "0x876e24e6", - "selectorBytes": [ - 135, - 110, - 36, - 230 - ], - "description": "Gets the map key and parent of a mapping at a given slot, for a given address.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "getMappingLength", - "declaration": "function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);", - "visibility": "external", - "mutability": "", - "signature": "getMappingLength(address,bytes32)", - "selector": "0x2f2fd63f", - "selectorBytes": [ - 47, - 47, - 214, - 63 - ], - "description": "Gets the number of elements in the mapping at the given slot, for a given address.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "getMappingSlotAt", - "declaration": "function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);", - "visibility": "external", - "mutability": "", - "signature": "getMappingSlotAt(address,bytes32,uint256)", - "selector": "0xebc73ab4", - "selectorBytes": [ - 235, - 199, - 58, - 180 - ], - "description": "Gets the elements at index idx of the mapping at the given slot, for a given address. The\nindex must be less than the length of the mapping (i.e. the number of keys in the mapping).", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "getNonce_0", - "declaration": "function getNonce(address account) external view returns (uint64 nonce);", - "visibility": "external", - "mutability": "view", - "signature": "getNonce(address)", - "selector": "0x2d0335ab", - "selectorBytes": [ - 45, - 3, - 53, - 171 - ], - "description": "Gets the nonce of an account.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "getNonce_1", - "declaration": "function getNonce(Wallet calldata wallet) external returns (uint64 nonce);", - "visibility": "external", - "mutability": "", - "signature": "getNonce((address,uint256,uint256,uint256))", - "selector": "0xa5748aad", - "selectorBytes": [ - 165, - 116, - 138, - 173 - ], - "description": "Get a `Wallet`'s nonce.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "getRecordedLogs", - "declaration": "function getRecordedLogs() external returns (Log[] memory logs);", - "visibility": "external", - "mutability": "", - "signature": "getRecordedLogs()", - "selector": "0x191553a4", - "selectorBytes": [ - 25, - 21, - 83, - 164 - ], - "description": "Gets all the recorded logs.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "isDir", - "declaration": "function isDir(string calldata path) external returns (bool result);", - "visibility": "external", - "mutability": "", - "signature": "isDir(string)", - "selector": "0x7d15d019", - "selectorBytes": [ - 125, - 21, - 208, - 25 - ], - "description": "Returns true if the path exists on disk and is pointing at a directory, else returns false.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "isFile", - "declaration": "function isFile(string calldata path) external returns (bool result);", - "visibility": "external", - "mutability": "", - "signature": "isFile(string)", - "selector": "0xe0eb04d4", - "selectorBytes": [ - 224, - 235, - 4, - 212 - ], - "description": "Returns true if the path exists on disk and is pointing at a regular file, else returns false.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "isPersistent", - "declaration": "function isPersistent(address account) external view returns (bool persistent);", - "visibility": "external", - "mutability": "view", - "signature": "isPersistent(address)", - "selector": "0xd92d8efd", - "selectorBytes": [ - 217, - 45, - 142, - 253 - ], - "description": "Returns true if the account is marked as persistent.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "keyExists", - "declaration": "function keyExists(string calldata json, string calldata key) external view returns (bool);", - "visibility": "external", - "mutability": "view", - "signature": "keyExists(string,string)", - "selector": "0x528a683c", - "selectorBytes": [ - 82, - 138, - 104, - 60 - ], - "description": "Checks if `key` exists in a JSON object.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "label", - "declaration": "function label(address account, string calldata newLabel) external;", - "visibility": "external", - "mutability": "", - "signature": "label(address,string)", - "selector": "0xc657c718", - "selectorBytes": [ - 198, - 87, - 199, - 24 - ], - "description": "Labels an address in call traces.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "load", - "declaration": "function load(address target, bytes32 slot) external view returns (bytes32 data);", - "visibility": "external", - "mutability": "view", - "signature": "load(address,bytes32)", - "selector": "0x667f9d70", - "selectorBytes": [ - 102, - 127, - 157, - 112 - ], - "description": "Loads a storage slot from an address.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "makePersistent_0", - "declaration": "function makePersistent(address account) external;", - "visibility": "external", - "mutability": "", - "signature": "makePersistent(address)", - "selector": "0x57e22dde", - "selectorBytes": [ - 87, - 226, - 45, - 222 - ], - "description": "Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\nMeaning, changes made to the state of this account will be kept when switching forks.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "makePersistent_1", - "declaration": "function makePersistent(address account0, address account1) external;", - "visibility": "external", - "mutability": "", - "signature": "makePersistent(address,address)", - "selector": "0x4074e0a8", - "selectorBytes": [ - 64, - 116, - 224, - 168 - ], - "description": "See `makePersistent(address)`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "makePersistent_2", - "declaration": "function makePersistent(address account0, address account1, address account2) external;", - "visibility": "external", - "mutability": "", - "signature": "makePersistent(address,address,address)", - "selector": "0xefb77a75", - "selectorBytes": [ - 239, - 183, - 122, - 117 - ], - "description": "See `makePersistent(address)`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "makePersistent_3", - "declaration": "function makePersistent(address[] calldata accounts) external;", - "visibility": "external", - "mutability": "", - "signature": "makePersistent(address[])", - "selector": "0x1d9e269e", - "selectorBytes": [ - 29, - 158, - 38, - 158 - ], - "description": "See `makePersistent(address)`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "mockCallRevert_0", - "declaration": "function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;", - "visibility": "external", - "mutability": "", - "signature": "mockCallRevert(address,bytes,bytes)", - "selector": "0xdbaad147", - "selectorBytes": [ - 219, - 170, - 209, - 71 - ], - "description": "Reverts a call to an address with specified revert data.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "mockCallRevert_1", - "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;", - "visibility": "external", - "mutability": "", - "signature": "mockCallRevert(address,uint256,bytes,bytes)", - "selector": "0xd23cd037", - "selectorBytes": [ - 210, - 60, - 208, - 55 - ], - "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "mockCall_0", - "declaration": "function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;", - "visibility": "external", - "mutability": "", - "signature": "mockCall(address,bytes,bytes)", - "selector": "0xb96213e4", - "selectorBytes": [ - 185, - 98, - 19, - 228 - ], - "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "mockCall_1", - "declaration": "function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;", - "visibility": "external", - "mutability": "", - "signature": "mockCall(address,uint256,bytes,bytes)", - "selector": "0x81409b91", - "selectorBytes": [ - 129, - 64, - 155, - 145 - ], - "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "parseAddress", - "declaration": "function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "parseAddress(string)", - "selector": "0xc6ce059d", - "selectorBytes": [ - 198, - 206, - 5, - 157 - ], - "description": "Parses the given `string` into an `address`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseBool", - "declaration": "function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "parseBool(string)", - "selector": "0x974ef924", - "selectorBytes": [ - 151, - 78, - 249, - 36 - ], - "description": "Parses the given `string` into a `bool`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseBytes", - "declaration": "function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "parseBytes(string)", - "selector": "0x8f5d232d", - "selectorBytes": [ - 143, - 93, - 35, - 45 - ], - "description": "Parses the given `string` into `bytes`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseBytes32", - "declaration": "function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "parseBytes32(string)", - "selector": "0x087e6e81", - "selectorBytes": [ - 8, - 126, - 110, - 129 - ], - "description": "Parses the given `string` into a `bytes32`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseInt", - "declaration": "function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "parseInt(string)", - "selector": "0x42346c5e", - "selectorBytes": [ - 66, - 52, - 108, - 94 - ], - "description": "Parses the given `string` into a `int256`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonAddress", - "declaration": "function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonAddress(string,string)", - "selector": "0x1e19e657", - "selectorBytes": [ - 30, - 25, - 230, - 87 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `address`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonAddressArray", - "declaration": "function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonAddressArray(string,string)", - "selector": "0x2fce7883", - "selectorBytes": [ - 47, - 206, - 120, - 131 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `address[]`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonBool", - "declaration": "function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonBool(string,string)", - "selector": "0x9f86dc91", - "selectorBytes": [ - 159, - 134, - 220, - 145 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `bool`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonBoolArray", - "declaration": "function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonBoolArray(string,string)", - "selector": "0x91f3b94f", - "selectorBytes": [ - 145, - 243, - 185, - 79 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `bool[]`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonBytes", - "declaration": "function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonBytes(string,string)", - "selector": "0xfd921be8", - "selectorBytes": [ - 253, - 146, - 27, - 232 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `bytes`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonBytes32", - "declaration": "function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonBytes32(string,string)", - "selector": "0x1777e59d", - "selectorBytes": [ - 23, - 119, - 229, - 157 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `bytes32`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonBytes32Array", - "declaration": "function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonBytes32Array(string,string)", - "selector": "0x91c75bc3", - "selectorBytes": [ - 145, - 199, - 91, - 195 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `bytes32[]`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonBytesArray", - "declaration": "function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonBytesArray(string,string)", - "selector": "0x6631aa99", - "selectorBytes": [ - 102, - 49, - 170, - 153 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `bytes[]`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonInt", - "declaration": "function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonInt(string,string)", - "selector": "0x7b048ccd", - "selectorBytes": [ - 123, - 4, - 140, - 205 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `int256`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonIntArray", - "declaration": "function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonIntArray(string,string)", - "selector": "0x9983c28a", - "selectorBytes": [ - 153, - 131, - 194, - 138 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `int256[]`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonKeys", - "declaration": "function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonKeys(string,string)", - "selector": "0x213e4198", - "selectorBytes": [ - 33, - 62, - 65, - 152 - ], - "description": "Returns an array of all the keys in a JSON object.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonString", - "declaration": "function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonString(string,string)", - "selector": "0x49c4fac8", - "selectorBytes": [ - 73, - 196, - 250, - 200 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `string`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonStringArray", - "declaration": "function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonStringArray(string,string)", - "selector": "0x498fdcf4", - "selectorBytes": [ - 73, - 143, - 220, - 244 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `string[]`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonUint", - "declaration": "function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonUint(string,string)", - "selector": "0xaddde2b6", - "selectorBytes": [ - 173, - 221, - 226, - 182 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `uint256`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJsonUintArray", - "declaration": "function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJsonUintArray(string,string)", - "selector": "0x522074ab", - "selectorBytes": [ - 82, - 32, - 116, - 171 - ], - "description": "Parses a string of JSON data at `key` and coerces it to `uint256[]`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJson_0", - "declaration": "function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJson(string)", - "selector": "0x6a82600a", - "selectorBytes": [ - 106, - 130, - 96, - 10 - ], - "description": "ABI-encodes a JSON object.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseJson_1", - "declaration": "function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJson(string,string)", - "selector": "0x85940ef1", - "selectorBytes": [ - 133, - 148, - 14, - 241 - ], - "description": "ABI-encodes a JSON object at `key`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "parseUint", - "declaration": "function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "parseUint(string)", - "selector": "0xfa91454d", - "selectorBytes": [ - 250, - 145, - 69, - 77 - ], - "description": "Parses the given `string` into a `uint256`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "pauseGasMetering", - "declaration": "function pauseGasMetering() external;", - "visibility": "external", - "mutability": "", - "signature": "pauseGasMetering()", - "selector": "0xd1a5b36f", - "selectorBytes": [ - 209, - 165, - 179, - 111 - ], - "description": "Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "prank_0", - "declaration": "function prank(address msgSender) external;", - "visibility": "external", - "mutability": "", - "signature": "prank(address)", - "selector": "0xca669fa7", - "selectorBytes": [ - 202, - 102, - 159, - 167 - ], - "description": "Sets the *next* call's `msg.sender` to be the input address.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "prank_1", - "declaration": "function prank(address msgSender, address txOrigin) external;", - "visibility": "external", - "mutability": "", - "signature": "prank(address,address)", - "selector": "0x47e50cce", - "selectorBytes": [ - 71, - 229, - 12, - 206 - ], - "description": "Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "prevrandao", - "declaration": "function prevrandao(bytes32 newPrevrandao) external;", - "visibility": "external", - "mutability": "", - "signature": "prevrandao(bytes32)", - "selector": "0x3b925549", - "selectorBytes": [ - 59, - 146, - 85, - 73 - ], - "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "projectRoot", - "declaration": "function projectRoot() external view returns (string memory path);", - "visibility": "external", - "mutability": "view", - "signature": "projectRoot()", - "selector": "0xd930a0e6", - "selectorBytes": [ - 217, - 48, - 160, - 230 - ], - "description": "Get the path of the current project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "readCallers", - "declaration": "function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);", - "visibility": "external", - "mutability": "", - "signature": "readCallers()", - "selector": "0x4ad0bac9", - "selectorBytes": [ - 74, - 208, - 186, - 201 - ], - "description": "Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "readDir_0", - "declaration": "function readDir(string calldata path) external view returns (DirEntry[] memory entries);", - "visibility": "external", - "mutability": "view", - "signature": "readDir(string)", - "selector": "0xc4bc59e0", - "selectorBytes": [ - 196, - 188, - 89, - 224 - ], - "description": "Reads the directory at the given path recursively, up to `maxDepth`.\n`maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.\nFollows symbolic links if `followLinks` is true.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "readDir_1", - "declaration": "function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);", - "visibility": "external", - "mutability": "view", - "signature": "readDir(string,uint64)", - "selector": "0x1497876c", - "selectorBytes": [ - 20, - 151, - 135, - 108 - ], - "description": "See `readDir(string)`.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "readDir_2", - "declaration": "function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries);", - "visibility": "external", - "mutability": "view", - "signature": "readDir(string,uint64,bool)", - "selector": "0x8102d70d", - "selectorBytes": [ - 129, - 2, - 215, - 13 - ], - "description": "See `readDir(string)`.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "readFile", - "declaration": "function readFile(string calldata path) external view returns (string memory data);", - "visibility": "external", - "mutability": "view", - "signature": "readFile(string)", - "selector": "0x60f9bb11", - "selectorBytes": [ - 96, - 249, - 187, - 17 - ], - "description": "Reads the entire content of file to string. `path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "readFileBinary", - "declaration": "function readFileBinary(string calldata path) external view returns (bytes memory data);", - "visibility": "external", - "mutability": "view", - "signature": "readFileBinary(string)", - "selector": "0x16ed7bc4", - "selectorBytes": [ - 22, - 237, - 123, - 196 - ], - "description": "Reads the entire content of file as binary. `path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "readLine", - "declaration": "function readLine(string calldata path) external view returns (string memory line);", - "visibility": "external", - "mutability": "view", - "signature": "readLine(string)", - "selector": "0x70f55728", - "selectorBytes": [ - 112, - 245, - 87, - 40 - ], - "description": "Reads next line of file to string.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "readLink", - "declaration": "function readLink(string calldata linkPath) external view returns (string memory targetPath);", - "visibility": "external", - "mutability": "view", - "signature": "readLink(string)", - "selector": "0x9f5684a2", - "selectorBytes": [ - 159, - 86, - 132, - 162 - ], - "description": "Reads a symbolic link, returning the path that the link points to.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` is not a symbolic link.\n- `path` does not exist.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "record", - "declaration": "function record() external;", - "visibility": "external", - "mutability": "", - "signature": "record()", - "selector": "0x266cf109", - "selectorBytes": [ - 38, - 108, - 241, - 9 - ], - "description": "Records all storage reads and writes.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "recordLogs", - "declaration": "function recordLogs() external;", - "visibility": "external", - "mutability": "", - "signature": "recordLogs()", - "selector": "0x41af2f52", - "selectorBytes": [ - 65, - 175, - 47, - 82 - ], - "description": "Record all the transaction logs.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "rememberKey", - "declaration": "function rememberKey(uint256 privateKey) external returns (address keyAddr);", - "visibility": "external", - "mutability": "", - "signature": "rememberKey(uint256)", - "selector": "0x22100064", - "selectorBytes": [ - 34, - 16, - 0, - 100 - ], - "description": "Adds a private key to the local forge wallet and returns the address.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "removeDir", - "declaration": "function removeDir(string calldata path, bool recursive) external;", - "visibility": "external", - "mutability": "", - "signature": "removeDir(string,bool)", - "selector": "0x45c62011", - "selectorBytes": [ - 69, - 198, - 32, - 17 - ], - "description": "Removes a directory at the provided path.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` doesn't exist.\n- `path` isn't a directory.\n- User lacks permissions to modify `path`.\n- The directory is not empty and `recursive` is false.\n`path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "removeFile", - "declaration": "function removeFile(string calldata path) external;", - "visibility": "external", - "mutability": "", - "signature": "removeFile(string)", - "selector": "0xf1afe04d", - "selectorBytes": [ - 241, - 175, - 224, - 77 - ], - "description": "Removes a file from the filesystem.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` points to a directory.\n- The file doesn't exist.\n- The user lacks permissions to remove the file.\n`path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "resetNonce", - "declaration": "function resetNonce(address account) external;", - "visibility": "external", - "mutability": "", - "signature": "resetNonce(address)", - "selector": "0x1c72346d", - "selectorBytes": [ - 28, - 114, - 52, - 109 - ], - "description": "Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "resumeGasMetering", - "declaration": "function resumeGasMetering() external;", - "visibility": "external", - "mutability": "", - "signature": "resumeGasMetering()", - "selector": "0x2bcd50e0", - "selectorBytes": [ - 43, - 205, - 80, - 224 - ], - "description": "Resumes gas metering (i.e. gas usage is counted again). Noop if already on.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "revertTo", - "declaration": "function revertTo(uint256 snapshotId) external returns (bool success);", - "visibility": "external", - "mutability": "", - "signature": "revertTo(uint256)", - "selector": "0x44d7f0a4", - "selectorBytes": [ - 68, - 215, - 240, - 164 - ], - "description": "Revert the state of the EVM to a previous snapshot\nTakes the snapshot ID to revert to.\nThis deletes the snapshot and all snapshots taken after the given snapshot ID.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "revokePersistent_0", - "declaration": "function revokePersistent(address account) external;", - "visibility": "external", - "mutability": "", - "signature": "revokePersistent(address)", - "selector": "0x997a0222", - "selectorBytes": [ - 153, - 122, - 2, - 34 - ], - "description": "Revokes persistent status from the address, previously added via `makePersistent`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "revokePersistent_1", - "declaration": "function revokePersistent(address[] calldata accounts) external;", - "visibility": "external", - "mutability": "", - "signature": "revokePersistent(address[])", - "selector": "0x3ce969e6", - "selectorBytes": [ - 60, - 233, - 105, - 230 - ], - "description": "See `revokePersistent(address)`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "roll", - "declaration": "function roll(uint256 newHeight) external;", - "visibility": "external", - "mutability": "", - "signature": "roll(uint256)", - "selector": "0x1f7b4f30", - "selectorBytes": [ - 31, - 123, - 79, - 48 - ], - "description": "Sets `block.height`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "rollFork_0", - "declaration": "function rollFork(uint256 blockNumber) external;", - "visibility": "external", - "mutability": "", - "signature": "rollFork(uint256)", - "selector": "0xd9bbf3a1", - "selectorBytes": [ - 217, - 187, - 243, - 161 - ], - "description": "Updates the currently active fork to given block number\nThis is similar to `roll` but for the currently active fork.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "rollFork_1", - "declaration": "function rollFork(bytes32 txHash) external;", - "visibility": "external", - "mutability": "", - "signature": "rollFork(bytes32)", - "selector": "0x0f29772b", - "selectorBytes": [ - 15, - 41, - 119, - 43 - ], - "description": "Updates the currently active fork to given transaction. This will `rollFork` with the number\nof the block the transaction was mined in and replays all transaction mined before it in the block.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "rollFork_2", - "declaration": "function rollFork(uint256 forkId, uint256 blockNumber) external;", - "visibility": "external", - "mutability": "", - "signature": "rollFork(uint256,uint256)", - "selector": "0xd74c83a4", - "selectorBytes": [ - 215, - 76, - 131, - 164 - ], - "description": "Updates the given fork to given block number.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "rollFork_3", - "declaration": "function rollFork(uint256 forkId, bytes32 txHash) external;", - "visibility": "external", - "mutability": "", - "signature": "rollFork(uint256,bytes32)", - "selector": "0xf2830f7b", - "selectorBytes": [ - 242, - 131, - 15, - 123 - ], - "description": "Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "rpcUrl", - "declaration": "function rpcUrl(string calldata rpcAlias) external view returns (string memory json);", - "visibility": "external", - "mutability": "view", - "signature": "rpcUrl(string)", - "selector": "0x975a6ce9", - "selectorBytes": [ - 151, - 90, - 108, - 233 - ], - "description": "Returns the RPC url for the given alias.", - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "id": "rpcUrlStructs", - "declaration": "function rpcUrlStructs() external view returns (Rpc[] memory urls);", - "visibility": "external", - "mutability": "view", - "signature": "rpcUrlStructs()", - "selector": "0x9d2ad72a", - "selectorBytes": [ - 157, - 42, - 215, - 42 - ], - "description": "Returns all rpc urls and their aliases as structs.", - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "id": "rpcUrls", - "declaration": "function rpcUrls() external view returns (string[2][] memory urls);", - "visibility": "external", - "mutability": "view", - "signature": "rpcUrls()", - "selector": "0xa85a8418", - "selectorBytes": [ - 168, - 90, - 132, - 24 - ], - "description": "Returns all rpc urls and their aliases `[alias, url][]`.", - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "id": "selectFork", - "declaration": "function selectFork(uint256 forkId) external;", - "visibility": "external", - "mutability": "", - "signature": "selectFork(uint256)", - "selector": "0x9ebf6827", - "selectorBytes": [ - 158, - 191, - 104, - 39 - ], - "description": "Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "serializeAddress_0", - "declaration": "function serializeAddress(string calldata objectKey, string calldata valueKey, address value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeAddress(string,string,address)", - "selector": "0x972c6062", - "selectorBytes": [ - 151, - 44, - 96, - 98 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeAddress_1", - "declaration": "function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeAddress(string,string,address[])", - "selector": "0x1e356e1a", - "selectorBytes": [ - 30, - 53, - 110, - 26 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeBool_0", - "declaration": "function serializeBool(string calldata objectKey, string calldata valueKey, bool value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeBool(string,string,bool)", - "selector": "0xac22e971", - "selectorBytes": [ - 172, - 34, - 233, - 113 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeBool_1", - "declaration": "function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeBool(string,string,bool[])", - "selector": "0x92925aa1", - "selectorBytes": [ - 146, - 146, - 90, - 161 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeBytes32_0", - "declaration": "function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeBytes32(string,string,bytes32)", - "selector": "0x2d812b44", - "selectorBytes": [ - 45, - 129, - 43, - 68 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeBytes32_1", - "declaration": "function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeBytes32(string,string,bytes32[])", - "selector": "0x201e43e2", - "selectorBytes": [ - 32, - 30, - 67, - 226 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeBytes_0", - "declaration": "function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeBytes(string,string,bytes)", - "selector": "0xf21d52c7", - "selectorBytes": [ - 242, - 29, - 82, - 199 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeBytes_1", - "declaration": "function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeBytes(string,string,bytes[])", - "selector": "0x9884b232", - "selectorBytes": [ - 152, - 132, - 178, - 50 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeInt_0", - "declaration": "function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeInt(string,string,int256)", - "selector": "0x3f33db60", - "selectorBytes": [ - 63, - 51, - 219, - 96 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeInt_1", - "declaration": "function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeInt(string,string,int256[])", - "selector": "0x7676e127", - "selectorBytes": [ - 118, - 118, - 225, - 39 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeJson", - "declaration": "function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeJson(string,string)", - "selector": "0x9b3358b0", - "selectorBytes": [ - 155, - 51, - 88, - 176 - ], - "description": "Serializes a key and value to a JSON object stored in-memory that can be later written to a file.\nReturns the stringified version of the specific JSON file up to that moment.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeString_0", - "declaration": "function serializeString(string calldata objectKey, string calldata valueKey, string calldata value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeString(string,string,string)", - "selector": "0x88da6d35", - "selectorBytes": [ - 136, - 218, - 109, - 53 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeString_1", - "declaration": "function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeString(string,string,string[])", - "selector": "0x561cd6f3", - "selectorBytes": [ - 86, - 28, - 214, - 243 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeUint_0", - "declaration": "function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeUint(string,string,uint256)", - "selector": "0x129e9002", - "selectorBytes": [ - 18, - 158, - 144, - 2 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "serializeUint_1", - "declaration": "function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values) external returns (string memory json);", - "visibility": "external", - "mutability": "", - "signature": "serializeUint(string,string,uint256[])", - "selector": "0xfee9a469", - "selectorBytes": [ - 254, - 233, - 164, - 105 - ], - "description": "See `serializeJson`.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "setEnv", - "declaration": "function setEnv(string calldata name, string calldata value) external;", - "visibility": "external", - "mutability": "", - "signature": "setEnv(string,string)", - "selector": "0x3d5923ee", - "selectorBytes": [ - 61, - 89, - 35, - 238 - ], - "description": "Sets environment variables.", - "group": "environment", - "status": "stable", - "safety": "safe" - }, - { - "id": "setNonce", - "declaration": "function setNonce(address account, uint64 newNonce) external;", - "visibility": "external", - "mutability": "", - "signature": "setNonce(address,uint64)", - "selector": "0xf8e18b57", - "selectorBytes": [ - 248, - 225, - 139, - 87 - ], - "description": "Sets the nonce of an account. Must be higher than the current nonce of the account.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "setNonceUnsafe", - "declaration": "function setNonceUnsafe(address account, uint64 newNonce) external;", - "visibility": "external", - "mutability": "", - "signature": "setNonceUnsafe(address,uint64)", - "selector": "0x9b67b21c", - "selectorBytes": [ - 155, - 103, - 178, - 28 - ], - "description": "Sets the nonce of an account to an arbitrary value.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "sign_0", - "declaration": "function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", - "visibility": "external", - "mutability": "pure", - "signature": "sign(uint256,bytes32)", - "selector": "0xe341eaa4", - "selectorBytes": [ - 227, - 65, - 234, - 164 - ], - "description": "Signs data.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "sign_1", - "declaration": "function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);", - "visibility": "external", - "mutability": "", - "signature": "sign((address,uint256,uint256,uint256),bytes32)", - "selector": "0xb25c5a25", - "selectorBytes": [ - 178, - 92, - 90, - 37 - ], - "description": "Signs data with a `Wallet`.", - "group": "utilities", - "status": "stable", - "safety": "safe" - }, - { - "id": "skip", - "declaration": "function skip(bool skipTest) external;", - "visibility": "external", - "mutability": "", - "signature": "skip(bool)", - "selector": "0xdd82d13e", - "selectorBytes": [ - 221, - 130, - 209, - 62 - ], - "description": "Marks a test as skipped. Must be called at the top of the test.", - "group": "testing", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "sleep", - "declaration": "function sleep(uint256 duration) external;", - "visibility": "external", - "mutability": "", - "signature": "sleep(uint256)", - "selector": "0xfa9d8713", - "selectorBytes": [ - 250, - 157, - 135, - 19 - ], - "description": "Suspends execution of the main thread for `duration` milliseconds.", - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "id": "snapshot", - "declaration": "function snapshot() external returns (uint256 snapshotId);", - "visibility": "external", - "mutability": "", - "signature": "snapshot()", - "selector": "0x9711715a", - "selectorBytes": [ - 151, - 17, - 113, - 90 - ], - "description": "Snapshot the current state of the evm.\nReturns the ID of the snapshot that was created.\nTo revert a snapshot use `revertTo`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "startBroadcast_0", - "declaration": "function startBroadcast() external;", - "visibility": "external", - "mutability": "", - "signature": "startBroadcast()", - "selector": "0x7fb5297f", - "selectorBytes": [ - 127, - 181, - 41, - 127 - ], - "description": "Using the address that calls the test contract, has all subsequent calls\n(at this call depth only) create transactions that can later be signed and sent onchain.", - "group": "scripting", - "status": "stable", - "safety": "safe" - }, - { - "id": "startBroadcast_1", - "declaration": "function startBroadcast(address signer) external;", - "visibility": "external", - "mutability": "", - "signature": "startBroadcast(address)", - "selector": "0x7fec2a8d", - "selectorBytes": [ - 127, - 236, - 42, - 141 - ], - "description": "Has all subsequent calls (at this call depth only) create transactions with the address\nprovided that can later be signed and sent onchain.", - "group": "scripting", - "status": "stable", - "safety": "safe" - }, - { - "id": "startBroadcast_2", - "declaration": "function startBroadcast(uint256 privateKey) external;", - "visibility": "external", - "mutability": "", - "signature": "startBroadcast(uint256)", - "selector": "0xce817d47", - "selectorBytes": [ - 206, - 129, - 125, - 71 - ], - "description": "Has all subsequent calls (at this call depth only) create transactions with the private key\nprovided that can later be signed and sent onchain.", - "group": "scripting", - "status": "stable", - "safety": "safe" - }, - { - "id": "startMappingRecording", - "declaration": "function startMappingRecording() external;", - "visibility": "external", - "mutability": "", - "signature": "startMappingRecording()", - "selector": "0x3e9705c0", - "selectorBytes": [ - 62, - 151, - 5, - 192 - ], - "description": "Starts recording all map SSTOREs for later retrieval.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "startPrank_0", - "declaration": "function startPrank(address msgSender) external;", - "visibility": "external", - "mutability": "", - "signature": "startPrank(address)", - "selector": "0x06447d56", - "selectorBytes": [ - 6, - 68, - 125, - 86 - ], - "description": "Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "startPrank_1", - "declaration": "function startPrank(address msgSender, address txOrigin) external;", - "visibility": "external", - "mutability": "", - "signature": "startPrank(address,address)", - "selector": "0x45b56078", - "selectorBytes": [ - 69, - 181, - 96, - 120 - ], - "description": "Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "stopBroadcast", - "declaration": "function stopBroadcast() external;", - "visibility": "external", - "mutability": "", - "signature": "stopBroadcast()", - "selector": "0x76eadd36", - "selectorBytes": [ - 118, - 234, - 221, - 54 - ], - "description": "Stops collecting onchain transactions.", - "group": "scripting", - "status": "stable", - "safety": "safe" - }, - { - "id": "stopMappingRecording", - "declaration": "function stopMappingRecording() external;", - "visibility": "external", - "mutability": "", - "signature": "stopMappingRecording()", - "selector": "0x0d4aae9b", - "selectorBytes": [ - 13, - 74, - 174, - 155 - ], - "description": "Stops recording all map SSTOREs for later retrieval and clears the recorded data.", - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "id": "stopPrank", - "declaration": "function stopPrank() external;", - "visibility": "external", - "mutability": "", - "signature": "stopPrank()", - "selector": "0x90c5013b", - "selectorBytes": [ - 144, - 197, - 1, - 59 - ], - "description": "Resets subsequent calls' `msg.sender` to be `address(this)`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "store", - "declaration": "function store(address target, bytes32 slot, bytes32 value) external;", - "visibility": "external", - "mutability": "", - "signature": "store(address,bytes32,bytes32)", - "selector": "0x70ca10bb", - "selectorBytes": [ - 112, - 202, - 16, - 187 - ], - "description": "Stores a value to an address' storage slot.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "toString_0", - "declaration": "function toString(address value) external pure returns (string memory stringifiedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "toString(address)", - "selector": "0x56ca623e", - "selectorBytes": [ - 86, - 202, - 98, - 62 - ], - "description": "Converts the given value to a `string`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "toString_1", - "declaration": "function toString(bytes calldata value) external pure returns (string memory stringifiedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "toString(bytes)", - "selector": "0x71aad10d", - "selectorBytes": [ - 113, - 170, - 209, - 13 - ], - "description": "Converts the given value to a `string`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "toString_2", - "declaration": "function toString(bytes32 value) external pure returns (string memory stringifiedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "toString(bytes32)", - "selector": "0xb11a19e8", - "selectorBytes": [ - 177, - 26, - 25, - 232 - ], - "description": "Converts the given value to a `string`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "toString_3", - "declaration": "function toString(bool value) external pure returns (string memory stringifiedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "toString(bool)", - "selector": "0x71dce7da", - "selectorBytes": [ - 113, - 220, - 231, - 218 - ], - "description": "Converts the given value to a `string`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "toString_4", - "declaration": "function toString(uint256 value) external pure returns (string memory stringifiedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "toString(uint256)", - "selector": "0x6900a3ae", - "selectorBytes": [ - 105, - 0, - 163, - 174 - ], - "description": "Converts the given value to a `string`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "toString_5", - "declaration": "function toString(int256 value) external pure returns (string memory stringifiedValue);", - "visibility": "external", - "mutability": "pure", - "signature": "toString(int256)", - "selector": "0xa322c40e", - "selectorBytes": [ - 163, - 34, - 196, - 14 - ], - "description": "Converts the given value to a `string`.", - "group": "string", - "status": "stable", - "safety": "safe" - }, - { - "id": "transact_0", - "declaration": "function transact(bytes32 txHash) external;", - "visibility": "external", - "mutability": "", - "signature": "transact(bytes32)", - "selector": "0xbe646da1", - "selectorBytes": [ - 190, - 100, - 109, - 161 - ], - "description": "Fetches the given transaction from the active fork and executes it on the current state.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "transact_1", - "declaration": "function transact(uint256 forkId, bytes32 txHash) external;", - "visibility": "external", - "mutability": "", - "signature": "transact(uint256,bytes32)", - "selector": "0x4d8abc4b", - "selectorBytes": [ - 77, - 138, - 188, - 75 - ], - "description": "Fetches the given transaction from the given fork and executes it on the current state.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "tryFfi", - "declaration": "function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);", - "visibility": "external", - "mutability": "", - "signature": "tryFfi(string[])", - "selector": "0xf45c1ce7", - "selectorBytes": [ - 244, - 92, - 28, - 231 - ], - "description": "Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "txGasPrice", - "declaration": "function txGasPrice(uint256 newGasPrice) external;", - "visibility": "external", - "mutability": "", - "signature": "txGasPrice(uint256)", - "selector": "0x48f50c0f", - "selectorBytes": [ - 72, - 245, - 12, - 15 - ], - "description": "Sets `tx.gasprice`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "unixTime", - "declaration": "function unixTime() external returns (uint256 milliseconds);", - "visibility": "external", - "mutability": "", - "signature": "unixTime()", - "selector": "0x625387dc", - "selectorBytes": [ - 98, - 83, - 135, - 220 - ], - "description": "Returns the time since unix epoch in milliseconds.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "warp", - "declaration": "function warp(uint256 newTimestamp) external;", - "visibility": "external", - "mutability": "", - "signature": "warp(uint256)", - "selector": "0xe5d6bf02", - "selectorBytes": [ - 229, - 214, - 191, - 2 - ], - "description": "Sets `block.timestamp`.", - "group": "evm", - "status": "stable", - "safety": "unsafe" - }, - { - "id": "writeFile", - "declaration": "function writeFile(string calldata path, string calldata data) external;", - "visibility": "external", - "mutability": "", - "signature": "writeFile(string,string)", - "selector": "0x897e0a97", - "selectorBytes": [ - 137, - 126, - 10, - 151 - ], - "description": "Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.\n`path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "writeFileBinary", - "declaration": "function writeFileBinary(string calldata path, bytes calldata data) external;", - "visibility": "external", - "mutability": "", - "signature": "writeFileBinary(string,bytes)", - "selector": "0x1f21fc80", - "selectorBytes": [ - 31, - 33, - 252, - 128 - ], - "description": "Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.\n`path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "id": "writeJson_0", - "declaration": "function writeJson(string calldata json, string calldata path) external;", - "visibility": "external", - "mutability": "", - "signature": "writeJson(string,string)", - "selector": "0xe23cd19f", - "selectorBytes": [ - 226, - 60, - 209, - 159 - ], - "description": "Write a serialized JSON object to a file. If the file exists, it will be overwritten.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "writeJson_1", - "declaration": "function writeJson(string calldata json, string calldata path, string calldata valueKey) external;", - "visibility": "external", - "mutability": "", - "signature": "writeJson(string,string,string)", - "selector": "0x35d6ad46", - "selectorBytes": [ - 53, - 214, - 173, - 70 - ], - "description": "Write a serialized JSON object to an **existing** JSON file, replacing a value with key = \nThis is useful to replace a specific value of a JSON file, without having to parse the entire thing.", - "group": "json", - "status": "stable", - "safety": "safe" - }, - { - "id": "writeLine", - "declaration": "function writeLine(string calldata path, string calldata data) external;", - "visibility": "external", - "mutability": "", - "signature": "writeLine(string,string)", - "selector": "0x619d897f", - "selectorBytes": [ - 97, - 157, - 137, - 127 - ], - "description": "Writes line to file, creating a file if it does not exist.\n`path` is relative to the project root.", - "group": "filesystem", - "status": "stable", - "safety": "safe" - } -] \ No newline at end of file +{ + "errors": [ + { + "name": "CheatcodeError", + "description": "Error thrown by cheatcodes.", + "declaration": "error CheatcodeError(string message);" + } + ], + "events": [], + "enums": [ + { + "name": "CallerMode", + "description": "A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`.", + "variants": [ + { + "name": "None", + "description": "No caller modification is currently active." + }, + { + "name": "Broadcast", + "description": "A one time broadcast triggered by a `vm.broadcast()` call is currently active." + }, + { + "name": "RecurrentBroadcast", + "description": "A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active." + }, + { + "name": "Prank", + "description": "A one time prank triggered by a `vm.prank()` call is currently active." + }, + { + "name": "RecurrentPrank", + "description": "A recurrent prank triggered by a `vm.startPrank()` call is currently active." + } + ] + } + ], + "structs": [ + { + "name": "Log", + "description": "An Ethereum log. Returned by `getRecordedLogs`.", + "fields": [ + { + "name": "topics", + "ty": "bytes32[]", + "description": "The topics of the log, including the signature, if any." + }, + { + "name": "data", + "ty": "bytes", + "description": "The raw data of the log." + }, + { + "name": "emitter", + "ty": "address", + "description": "The address of the log's emitter." + } + ] + }, + { + "name": "Rpc", + "description": "An RPC URL and its alias. Returned by `rpcUrlStructs`.", + "fields": [ + { + "name": "key", + "ty": "string", + "description": "The alias of the RPC URL." + }, + { + "name": "url", + "ty": "string", + "description": "The RPC URL." + } + ] + }, + { + "name": "EthGetLogs", + "description": "An RPC log object. Returned by `eth_getLogs`.", + "fields": [ + { + "name": "emitter", + "ty": "address", + "description": "The address of the log's emitter." + }, + { + "name": "topics", + "ty": "bytes32[]", + "description": "The topics of the log, including the signature, if any." + }, + { + "name": "data", + "ty": "bytes", + "description": "The raw data of the log." + }, + { + "name": "blockHash", + "ty": "bytes32", + "description": "The block hash." + }, + { + "name": "blockNumber", + "ty": "uint64", + "description": "The block number." + }, + { + "name": "transactionHash", + "ty": "bytes32", + "description": "The transaction hash." + }, + { + "name": "transactionIndex", + "ty": "uint64", + "description": "The transaction index in the block." + }, + { + "name": "logIndex", + "ty": "uint256", + "description": "The log index." + }, + { + "name": "removed", + "ty": "bool", + "description": "Whether the log was removed." + } + ] + }, + { + "name": "DirEntry", + "description": "A single entry in a directory listing. Returned by `readDir`.", + "fields": [ + { + "name": "errorMessage", + "ty": "string", + "description": "The error message, if any." + }, + { + "name": "path", + "ty": "string", + "description": "The path of the entry." + }, + { + "name": "depth", + "ty": "uint64", + "description": "The depth of the entry." + }, + { + "name": "isDir", + "ty": "bool", + "description": "Whether the entry is a directory." + }, + { + "name": "isSymlink", + "ty": "bool", + "description": "Whether the entry is a symlink." + } + ] + }, + { + "name": "FsMetadata", + "description": "Metadata information about a file.\n This structure is returned from the [`fsMetadata`] function and represents known\n metadata about a file such as its permissions, size, modification\n times, etc.", + "fields": [ + { + "name": "isDir", + "ty": "bool", + "description": "True if this metadata is for a directory." + }, + { + "name": "isSymlink", + "ty": "bool", + "description": "True if this metadata is for a symlink." + }, + { + "name": "length", + "ty": "uint256", + "description": "The size of the file, in bytes, this metadata is for." + }, + { + "name": "readOnly", + "ty": "bool", + "description": "True if this metadata is for a readonly (unwritable) file." + }, + { + "name": "modified", + "ty": "uint256", + "description": "The last modification time listed in this metadata." + }, + { + "name": "accessed", + "ty": "uint256", + "description": "The last access time of this metadata." + }, + { + "name": "created", + "ty": "uint256", + "description": "The creation time listed in this metadata." + } + ] + }, + { + "name": "Wallet", + "description": "A wallet with a public and private key.", + "fields": [ + { + "name": "addr", + "ty": "address", + "description": "The wallet's address." + }, + { + "name": "publicKeyX", + "ty": "uint256", + "description": "The wallet's public key `X`." + }, + { + "name": "publicKeyY", + "ty": "uint256", + "description": "The wallet's public key `Y`." + }, + { + "name": "privateKey", + "ty": "uint256", + "description": "The wallet's private key." + } + ] + }, + { + "name": "FfiResult", + "description": "The result of a [`tryFfi`](tryFfiCall) call.", + "fields": [ + { + "name": "exitCode", + "ty": "int32", + "description": "The exit code of the call." + }, + { + "name": "stdout", + "ty": "bytes", + "description": "The optionally hex-decoded `stdout` data." + }, + { + "name": "stderr", + "ty": "bytes", + "description": "The `stderr` data." + } + ] + } + ], + "cheatcodes": [ + { + "func": { + "id": "accesses", + "description": "Gets all accessed reads and write slot from a `vm.record` session, for a given address.", + "declaration": "function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);", + "visibility": "external", + "mutability": "", + "signature": "accesses(address)", + "selector": "0x65bc9481", + "selectorBytes": [ + 101, + 188, + 148, + 129 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "activeFork", + "description": "Returns the identifier of the currently active fork. Reverts if no fork is currently active.", + "declaration": "function activeFork() external view returns (uint256 forkId);", + "visibility": "external", + "mutability": "view", + "signature": "activeFork()", + "selector": "0x2f103f22", + "selectorBytes": [ + 47, + 16, + 63, + 34 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "addr", + "description": "Gets the address for a given private key.", + "declaration": "function addr(uint256 privateKey) external pure returns (address keyAddr);", + "visibility": "external", + "mutability": "pure", + "signature": "addr(uint256)", + "selector": "0xffa18649", + "selectorBytes": [ + 255, + 161, + 134, + 73 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "allowCheatcodes", + "description": "In forking mode, explicitly grant the given address cheatcode access.", + "declaration": "function allowCheatcodes(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "allowCheatcodes(address)", + "selector": "0xea060291", + "selectorBytes": [ + 234, + 6, + 2, + 145 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "assume", + "description": "If the condition is false, discard this run's fuzz inputs and generate new ones.", + "declaration": "function assume(bool condition) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assume(bool)", + "selector": "0x4c63e562", + "selectorBytes": [ + 76, + 99, + 229, + 98 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "breakpoint_0", + "description": "Writes a breakpoint to jump to in the debugger.", + "declaration": "function breakpoint(string calldata char) external;", + "visibility": "external", + "mutability": "", + "signature": "breakpoint(string)", + "selector": "0xf0259e92", + "selectorBytes": [ + 240, + 37, + 158, + 146 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "breakpoint_1", + "description": "Writes a conditional breakpoint to jump to in the debugger.", + "declaration": "function breakpoint(string calldata char, bool value) external;", + "visibility": "external", + "mutability": "", + "signature": "breakpoint(string,bool)", + "selector": "0xf7d39a8d", + "selectorBytes": [ + 247, + 211, + 154, + 141 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "broadcast_0", + "description": "Using the address that calls the test contract, has the next call (at this call depth only)\ncreate a transaction that can later be signed and sent onchain.", + "declaration": "function broadcast() external;", + "visibility": "external", + "mutability": "", + "signature": "broadcast()", + "selector": "0xafc98040", + "selectorBytes": [ + 175, + 201, + 128, + 64 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "broadcast_1", + "description": "Has the next call (at this call depth only) create a transaction with the address provided\nas the sender that can later be signed and sent onchain.", + "declaration": "function broadcast(address signer) external;", + "visibility": "external", + "mutability": "", + "signature": "broadcast(address)", + "selector": "0xe6962cdb", + "selectorBytes": [ + 230, + 150, + 44, + 219 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "broadcast_2", + "description": "Has the next call (at this call depth only) create a transaction with the private key\nprovided as the sender that can later be signed and sent onchain.", + "declaration": "function broadcast(uint256 privateKey) external;", + "visibility": "external", + "mutability": "", + "signature": "broadcast(uint256)", + "selector": "0xf67a965b", + "selectorBytes": [ + 246, + 122, + 150, + 91 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "chainId", + "description": "Sets `block.chainid`.", + "declaration": "function chainId(uint256 newChainId) external;", + "visibility": "external", + "mutability": "", + "signature": "chainId(uint256)", + "selector": "0x4049ddd2", + "selectorBytes": [ + 64, + 73, + 221, + 210 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "clearMockedCalls", + "description": "Clears all mocked calls.", + "declaration": "function clearMockedCalls() external;", + "visibility": "external", + "mutability": "", + "signature": "clearMockedCalls()", + "selector": "0x3fdf4e15", + "selectorBytes": [ + 63, + 223, + 78, + 21 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "closeFile", + "description": "Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.\n`path` is relative to the project root.", + "declaration": "function closeFile(string calldata path) external;", + "visibility": "external", + "mutability": "", + "signature": "closeFile(string)", + "selector": "0x48c3241f", + "selectorBytes": [ + 72, + 195, + 36, + 31 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "coinbase", + "description": "Sets `block.coinbase`.", + "declaration": "function coinbase(address newCoinbase) external;", + "visibility": "external", + "mutability": "", + "signature": "coinbase(address)", + "selector": "0xff483c54", + "selectorBytes": [ + 255, + 72, + 60, + 84 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "cool", + "description": "Marks the slots of an account and the account address as cold.", + "declaration": "function cool(address target) external;", + "visibility": "external", + "mutability": "", + "signature": "cool(address)", + "selector": "0x40ff9f21", + "selectorBytes": [ + 64, + 255, + 159, + 33 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "copyFile", + "description": "Copies the contents of one file to another. This function will **overwrite** the contents of `to`.\nOn success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`.\nBoth `from` and `to` are relative to the project root.", + "declaration": "function copyFile(string calldata from, string calldata to) external returns (uint64 copied);", + "visibility": "external", + "mutability": "", + "signature": "copyFile(string,string)", + "selector": "0xa54a87d8", + "selectorBytes": [ + 165, + 74, + 135, + 216 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "createDir", + "description": "Creates a new, empty directory at the provided path.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- User lacks permissions to modify `path`.\n- A parent of the given path doesn't exist and `recursive` is false.\n- `path` already exists and `recursive` is false.\n`path` is relative to the project root.", + "declaration": "function createDir(string calldata path, bool recursive) external;", + "visibility": "external", + "mutability": "", + "signature": "createDir(string,bool)", + "selector": "0x168b64d3", + "selectorBytes": [ + 22, + 139, + 100, + 211 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "createFork_0", + "description": "Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork.", + "declaration": "function createFork(string calldata urlOrAlias) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createFork(string)", + "selector": "0x31ba3498", + "selectorBytes": [ + 49, + 186, + 52, + 152 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "createFork_1", + "description": "Creates a new fork with the given endpoint and block and returns the identifier of the fork.", + "declaration": "function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createFork(string,uint256)", + "selector": "0x6ba3ba2b", + "selectorBytes": [ + 107, + 163, + 186, + 43 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "createFork_2", + "description": "Creates a new fork with the given endpoint and at the block the given transaction was mined in,\nreplays all transaction mined in the block before the transaction, and returns the identifier of the fork.", + "declaration": "function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createFork(string,bytes32)", + "selector": "0x7ca29682", + "selectorBytes": [ + 124, + 162, + 150, + 130 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "createSelectFork_0", + "description": "Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.", + "declaration": "function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createSelectFork(string)", + "selector": "0x98680034", + "selectorBytes": [ + 152, + 104, + 0, + 52 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "createSelectFork_1", + "description": "Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.", + "declaration": "function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createSelectFork(string,uint256)", + "selector": "0x71ee464d", + "selectorBytes": [ + 113, + 238, + 70, + 77 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "createSelectFork_2", + "description": "Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in,\nreplays all transaction mined in the block before the transaction, returns the identifier of the fork.", + "declaration": "function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);", + "visibility": "external", + "mutability": "", + "signature": "createSelectFork(string,bytes32)", + "selector": "0x84d52b7a", + "selectorBytes": [ + 132, + 213, + 43, + 122 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "createWallet_0", + "description": "Derives a private key from the name, labels the account with that name, and returns the wallet.", + "declaration": "function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);", + "visibility": "external", + "mutability": "", + "signature": "createWallet(string)", + "selector": "0x7404f1d2", + "selectorBytes": [ + 116, + 4, + 241, + 210 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "createWallet_1", + "description": "Generates a wallet from the private key and returns the wallet.", + "declaration": "function createWallet(uint256 privateKey) external returns (Wallet memory wallet);", + "visibility": "external", + "mutability": "", + "signature": "createWallet(uint256)", + "selector": "0x7a675bb6", + "selectorBytes": [ + 122, + 103, + 91, + 182 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "createWallet_2", + "description": "Generates a wallet from the private key, labels the account with that name, and returns the wallet.", + "declaration": "function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);", + "visibility": "external", + "mutability": "", + "signature": "createWallet(uint256,string)", + "selector": "0xed7c5462", + "selectorBytes": [ + 237, + 124, + 84, + 98 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "deal", + "description": "Sets an address' balance.", + "declaration": "function deal(address account, uint256 newBalance) external;", + "visibility": "external", + "mutability": "", + "signature": "deal(address,uint256)", + "selector": "0xc88a5e6d", + "selectorBytes": [ + 200, + 138, + 94, + 109 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "deriveKey_0", + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path)\nat the derivation path `m/44'/60'/0'/0/{index}`.", + "declaration": "function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,uint32)", + "selector": "0x6229498b", + "selectorBytes": [ + 98, + 41, + 73, + 139 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "deriveKey_1", + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path)\nat `{derivationPath}{index}`.", + "declaration": "function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,string,uint32)", + "selector": "0x6bcb2c1b", + "selectorBytes": [ + 107, + 203, + 44, + 27 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "deriveKey_2", + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language\nat the derivation path `m/44'/60'/0'/0/{index}`.", + "declaration": "function deriveKey(string calldata mnemonic, uint32 index, string calldata language) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,uint32,string)", + "selector": "0x32c8176d", + "selectorBytes": [ + 50, + 200, + 23, + 109 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "deriveKey_3", + "description": "Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language\nat `{derivationPath}{index}`.", + "declaration": "function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) external pure returns (uint256 privateKey);", + "visibility": "external", + "mutability": "pure", + "signature": "deriveKey(string,string,uint32,string)", + "selector": "0x29233b1f", + "selectorBytes": [ + 41, + 35, + 59, + 31 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "difficulty", + "description": "Sets `block.difficulty`.\nNot available on EVM versions from Paris onwards. Use `prevrandao` instead.\nReverts if used on unsupported EVM versions.", + "declaration": "function difficulty(uint256 newDifficulty) external;", + "visibility": "external", + "mutability": "", + "signature": "difficulty(uint256)", + "selector": "0x46cc92d9", + "selectorBytes": [ + 70, + 204, + 146, + 217 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "envAddress_0", + "description": "Gets the environment variable `name` and parses it as `address`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envAddress(string calldata name) external view returns (address value);", + "visibility": "external", + "mutability": "view", + "signature": "envAddress(string)", + "selector": "0x350d56bf", + "selectorBytes": [ + 53, + 13, + 86, + 191 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envAddress_1", + "description": "Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envAddress(string,string)", + "selector": "0xad31b9fa", + "selectorBytes": [ + 173, + 49, + 185, + 250 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envBool_0", + "description": "Gets the environment variable `name` and parses it as `bool`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envBool(string calldata name) external view returns (bool value);", + "visibility": "external", + "mutability": "view", + "signature": "envBool(string)", + "selector": "0x7ed1ec7d", + "selectorBytes": [ + 126, + 209, + 236, + 125 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envBool_1", + "description": "Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBool(string,string)", + "selector": "0xaaaddeaf", + "selectorBytes": [ + 170, + 173, + 222, + 175 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envBytes32_0", + "description": "Gets the environment variable `name` and parses it as `bytes32`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envBytes32(string calldata name) external view returns (bytes32 value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes32(string)", + "selector": "0x97949042", + "selectorBytes": [ + 151, + 148, + 144, + 66 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envBytes32_1", + "description": "Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes32(string,string)", + "selector": "0x5af231c1", + "selectorBytes": [ + 90, + 242, + 49, + 193 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envBytes_0", + "description": "Gets the environment variable `name` and parses it as `bytes`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envBytes(string calldata name) external view returns (bytes memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes(string)", + "selector": "0x4d7baf06", + "selectorBytes": [ + 77, + 123, + 175, + 6 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envBytes_1", + "description": "Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envBytes(string,string)", + "selector": "0xddc2651b", + "selectorBytes": [ + 221, + 194, + 101, + 27 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envInt_0", + "description": "Gets the environment variable `name` and parses it as `int256`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envInt(string calldata name) external view returns (int256 value);", + "visibility": "external", + "mutability": "view", + "signature": "envInt(string)", + "selector": "0x892a0c61", + "selectorBytes": [ + 137, + 42, + 12, + 97 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envInt_1", + "description": "Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envInt(string,string)", + "selector": "0x42181150", + "selectorBytes": [ + 66, + 24, + 17, + 80 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_0", + "description": "Gets the environment variable `name` and parses it as `bool`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, bool defaultValue) external returns (bool value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,bool)", + "selector": "0x4777f3cf", + "selectorBytes": [ + 71, + 119, + 243, + 207 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_1", + "description": "Gets the environment variable `name` and parses it as `uint256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,uint256)", + "selector": "0x5e97348f", + "selectorBytes": [ + 94, + 151, + 52, + 143 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_10", + "description": "Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external returns (address[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,address[])", + "selector": "0xc74e9deb", + "selectorBytes": [ + 199, + 78, + 157, + 235 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_11", + "description": "Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external returns (bytes32[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,bytes32[])", + "selector": "0x2281f367", + "selectorBytes": [ + 34, + 129, + 243, + 103 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_12", + "description": "Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external returns (string[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,string[])", + "selector": "0x859216bc", + "selectorBytes": [ + 133, + 146, + 22, + 188 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_13", + "description": "Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external returns (bytes[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,bytes[])", + "selector": "0x64bc3e64", + "selectorBytes": [ + 100, + 188, + 62, + 100 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_2", + "description": "Gets the environment variable `name` and parses it as `int256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, int256 defaultValue) external returns (int256 value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,int256)", + "selector": "0xbbcb713e", + "selectorBytes": [ + 187, + 203, + 113, + 62 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_3", + "description": "Gets the environment variable `name` and parses it as `address`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, address defaultValue) external returns (address value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,address)", + "selector": "0x561fe540", + "selectorBytes": [ + 86, + 31, + 229, + 64 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_4", + "description": "Gets the environment variable `name` and parses it as `bytes32`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,bytes32)", + "selector": "0xb4a85892", + "selectorBytes": [ + 180, + 168, + 88, + 146 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_5", + "description": "Gets the environment variable `name` and parses it as `string`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string)", + "selector": "0xd145736c", + "selectorBytes": [ + 209, + 69, + 115, + 108 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_6", + "description": "Gets the environment variable `name` and parses it as `bytes`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,bytes)", + "selector": "0xb3e47705", + "selectorBytes": [ + 179, + 228, + 119, + 5 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_7", + "description": "Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external returns (bool[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,bool[])", + "selector": "0xeb85e83b", + "selectorBytes": [ + 235, + 133, + 232, + 59 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_8", + "description": "Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external returns (uint256[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,uint256[])", + "selector": "0x74318528", + "selectorBytes": [ + 116, + 49, + 133, + 40 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envOr_9", + "description": "Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", + "declaration": "function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external returns (int256[] memory value);", + "visibility": "external", + "mutability": "", + "signature": "envOr(string,string,int256[])", + "selector": "0x4700d74b", + "selectorBytes": [ + 71, + 0, + 215, + 75 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envString_0", + "description": "Gets the environment variable `name` and parses it as `string`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envString(string calldata name) external view returns (string memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envString(string)", + "selector": "0xf877cb19", + "selectorBytes": [ + 248, + 119, + 203, + 25 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envString_1", + "description": "Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envString(string calldata name, string calldata delim) external view returns (string[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envString(string,string)", + "selector": "0x14b02bc9", + "selectorBytes": [ + 20, + 176, + 43, + 201 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envUint_0", + "description": "Gets the environment variable `name` and parses it as `uint256`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envUint(string calldata name) external view returns (uint256 value);", + "visibility": "external", + "mutability": "view", + "signature": "envUint(string)", + "selector": "0xc1978d1f", + "selectorBytes": [ + 193, + 151, + 141, + 31 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "envUint_1", + "description": "Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.\nReverts if the variable was not found or could not be parsed.", + "declaration": "function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);", + "visibility": "external", + "mutability": "view", + "signature": "envUint(string,string)", + "selector": "0xf3dec099", + "selectorBytes": [ + 243, + 222, + 192, + 153 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "etch", + "description": "Sets an address' code.", + "declaration": "function etch(address target, bytes calldata newRuntimeBytecode) external;", + "visibility": "external", + "mutability": "", + "signature": "etch(address,bytes)", + "selector": "0xb4d6c782", + "selectorBytes": [ + 180, + 214, + 199, + 130 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "eth_getLogs", + "description": "Gets all the logs according to specified filter.", + "declaration": "function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics) external returns (EthGetLogs[] memory logs);", + "visibility": "external", + "mutability": "", + "signature": "eth_getLogs(uint256,uint256,address,bytes32[])", + "selector": "0x35e1349b", + "selectorBytes": [ + 53, + 225, + 52, + 155 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "exists", + "description": "Returns true if the given path points to an existing entity, else returns false.", + "declaration": "function exists(string calldata path) external returns (bool result);", + "visibility": "external", + "mutability": "", + "signature": "exists(string)", + "selector": "0x261a323e", + "selectorBytes": [ + 38, + 26, + 50, + 62 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "expectCallMinGas_0", + "description": "Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.", + "declaration": "function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCallMinGas(address,uint256,uint64,bytes)", + "selector": "0x08e4e116", + "selectorBytes": [ + 8, + 228, + 225, + 22 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectCallMinGas_1", + "description": "Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.", + "declaration": "function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCallMinGas(address,uint256,uint64,bytes,uint64)", + "selector": "0xe13a1834", + "selectorBytes": [ + 225, + 58, + 24, + 52 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectCall_0", + "description": "Expects a call to an address with the specified calldata.\nCalldata can either be a strict or a partial match.", + "declaration": "function expectCall(address callee, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,bytes)", + "selector": "0xbd6af434", + "selectorBytes": [ + 189, + 106, + 244, + 52 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectCall_1", + "description": "Expects given number of calls to an address with the specified calldata.", + "declaration": "function expectCall(address callee, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,bytes,uint64)", + "selector": "0xc1adbbff", + "selectorBytes": [ + 193, + 173, + 187, + 255 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectCall_2", + "description": "Expects a call to an address with the specified `msg.value` and calldata.", + "declaration": "function expectCall(address callee, uint256 msgValue, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,bytes)", + "selector": "0xf30c7ba3", + "selectorBytes": [ + 243, + 12, + 123, + 163 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectCall_3", + "description": "Expects given number of calls to an address with the specified `msg.value` and calldata.", + "declaration": "function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,bytes,uint64)", + "selector": "0xa2b1a1ae", + "selectorBytes": [ + 162, + 177, + 161, + 174 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectCall_4", + "description": "Expect a call to an address with the specified `msg.value`, gas, and calldata.", + "declaration": "function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,uint64,bytes)", + "selector": "0x23361207", + "selectorBytes": [ + 35, + 54, + 18, + 7 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectCall_5", + "description": "Expects given number of calls to an address with the specified `msg.value`, gas, and calldata.", + "declaration": "function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectCall(address,uint256,uint64,bytes,uint64)", + "selector": "0x65b7b7cc", + "selectorBytes": [ + 101, + 183, + 183, + 204 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmit_0", + "description": "Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).\nCall this function, then emit an event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data (as specified by the booleans).", + "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(bool,bool,bool,bool)", + "selector": "0x491cc7c2", + "selectorBytes": [ + 73, + 28, + 199, + 194 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmit_1", + "description": "Same as the previous method, but also checks supplied address against emitting contract.", + "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(bool,bool,bool,bool,address)", + "selector": "0x81bad6f3", + "selectorBytes": [ + 129, + 186, + 214, + 243 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmit_2", + "description": "Prepare an expected log with all topic and data checks enabled.\nCall this function, then emit an event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data.", + "declaration": "function expectEmit() external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit()", + "selector": "0x440ed10d", + "selectorBytes": [ + 68, + 14, + 209, + 13 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmit_3", + "description": "Same as the previous method, but also checks supplied address against emitting contract.", + "declaration": "function expectEmit(address emitter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(address)", + "selector": "0x86b9620d", + "selectorBytes": [ + 134, + 185, + 98, + 13 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_0", + "description": "Expects an error on next call with any revert data.", + "declaration": "function expectRevert() external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert()", + "selector": "0xf4844814", + "selectorBytes": [ + 244, + 132, + 72, + 20 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_1", + "description": "Expects an error on next call that starts with the revert data.", + "declaration": "function expectRevert(bytes4 revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes4)", + "selector": "0xc31eb0e0", + "selectorBytes": [ + 195, + 30, + 176, + 224 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_2", + "description": "Expects an error on next call that exactly matches the revert data.", + "declaration": "function expectRevert(bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes)", + "selector": "0xf28dceb3", + "selectorBytes": [ + 242, + 141, + 206, + 179 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectSafeMemory", + "description": "Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other\nmemory is written to, the test will fail. Can be called multiple times to add more ranges to the set.", + "declaration": "function expectSafeMemory(uint64 min, uint64 max) external;", + "visibility": "external", + "mutability": "", + "signature": "expectSafeMemory(uint64,uint64)", + "selector": "0x6d016688", + "selectorBytes": [ + 109, + 1, + 102, + 136 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectSafeMemoryCall", + "description": "Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext.\nIf any other memory is written to, the test will fail. Can be called multiple times to add more ranges\nto the set.", + "declaration": "function expectSafeMemoryCall(uint64 min, uint64 max) external;", + "visibility": "external", + "mutability": "", + "signature": "expectSafeMemoryCall(uint64,uint64)", + "selector": "0x05838bf4", + "selectorBytes": [ + 5, + 131, + 139, + 244 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "fee", + "description": "Sets `block.basefee`.", + "declaration": "function fee(uint256 newBasefee) external;", + "visibility": "external", + "mutability": "", + "signature": "fee(uint256)", + "selector": "0x39b37ab0", + "selectorBytes": [ + 57, + 179, + 122, + 176 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "ffi", + "description": "Performs a foreign function call via the terminal.", + "declaration": "function ffi(string[] calldata commandInput) external returns (bytes memory result);", + "visibility": "external", + "mutability": "", + "signature": "ffi(string[])", + "selector": "0x89160467", + "selectorBytes": [ + 137, + 22, + 4, + 103 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "fsMetadata", + "description": "Given a path, query the file system to get information about a file, directory, etc.", + "declaration": "function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);", + "visibility": "external", + "mutability": "view", + "signature": "fsMetadata(string)", + "selector": "0xaf368a08", + "selectorBytes": [ + 175, + 54, + 138, + 8 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getCode", + "description": "Gets the creation bytecode from an artifact file. Takes in the relative path to the json file.", + "declaration": "function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);", + "visibility": "external", + "mutability": "view", + "signature": "getCode(string)", + "selector": "0x8d1cc925", + "selectorBytes": [ + 141, + 28, + 201, + 37 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getDeployedCode", + "description": "Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file.", + "declaration": "function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);", + "visibility": "external", + "mutability": "view", + "signature": "getDeployedCode(string)", + "selector": "0x3ebf73b4", + "selectorBytes": [ + 62, + 191, + 115, + 180 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getLabel", + "description": "Gets the label for the specified address.", + "declaration": "function getLabel(address account) external returns (string memory currentLabel);", + "visibility": "external", + "mutability": "", + "signature": "getLabel(address)", + "selector": "0x28a249b0", + "selectorBytes": [ + 40, + 162, + 73, + 176 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getMappingKeyAndParentOf", + "description": "Gets the map key and parent of a mapping at a given slot, for a given address.", + "declaration": "function getMappingKeyAndParentOf(address target, bytes32 elementSlot) external returns (bool found, bytes32 key, bytes32 parent);", + "visibility": "external", + "mutability": "", + "signature": "getMappingKeyAndParentOf(address,bytes32)", + "selector": "0x876e24e6", + "selectorBytes": [ + 135, + 110, + 36, + 230 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getMappingLength", + "description": "Gets the number of elements in the mapping at the given slot, for a given address.", + "declaration": "function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);", + "visibility": "external", + "mutability": "", + "signature": "getMappingLength(address,bytes32)", + "selector": "0x2f2fd63f", + "selectorBytes": [ + 47, + 47, + 214, + 63 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getMappingSlotAt", + "description": "Gets the elements at index idx of the mapping at the given slot, for a given address. The\nindex must be less than the length of the mapping (i.e. the number of keys in the mapping).", + "declaration": "function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);", + "visibility": "external", + "mutability": "", + "signature": "getMappingSlotAt(address,bytes32,uint256)", + "selector": "0xebc73ab4", + "selectorBytes": [ + 235, + 199, + 58, + 180 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getNonce_0", + "description": "Gets the nonce of an account.", + "declaration": "function getNonce(address account) external view returns (uint64 nonce);", + "visibility": "external", + "mutability": "view", + "signature": "getNonce(address)", + "selector": "0x2d0335ab", + "selectorBytes": [ + 45, + 3, + 53, + 171 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getNonce_1", + "description": "Get a `Wallet`'s nonce.", + "declaration": "function getNonce(Wallet calldata wallet) external returns (uint64 nonce);", + "visibility": "external", + "mutability": "", + "signature": "getNonce((address,uint256,uint256,uint256))", + "selector": "0xa5748aad", + "selectorBytes": [ + 165, + 116, + 138, + 173 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getRecordedLogs", + "description": "Gets all the recorded logs.", + "declaration": "function getRecordedLogs() external returns (Log[] memory logs);", + "visibility": "external", + "mutability": "", + "signature": "getRecordedLogs()", + "selector": "0x191553a4", + "selectorBytes": [ + 25, + 21, + 83, + 164 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "isDir", + "description": "Returns true if the path exists on disk and is pointing at a directory, else returns false.", + "declaration": "function isDir(string calldata path) external returns (bool result);", + "visibility": "external", + "mutability": "", + "signature": "isDir(string)", + "selector": "0x7d15d019", + "selectorBytes": [ + 125, + 21, + 208, + 25 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "isFile", + "description": "Returns true if the path exists on disk and is pointing at a regular file, else returns false.", + "declaration": "function isFile(string calldata path) external returns (bool result);", + "visibility": "external", + "mutability": "", + "signature": "isFile(string)", + "selector": "0xe0eb04d4", + "selectorBytes": [ + 224, + 235, + 4, + 212 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "isPersistent", + "description": "Returns true if the account is marked as persistent.", + "declaration": "function isPersistent(address account) external view returns (bool persistent);", + "visibility": "external", + "mutability": "view", + "signature": "isPersistent(address)", + "selector": "0xd92d8efd", + "selectorBytes": [ + 217, + 45, + 142, + 253 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "keyExists", + "description": "Checks if `key` exists in a JSON object.", + "declaration": "function keyExists(string calldata json, string calldata key) external view returns (bool);", + "visibility": "external", + "mutability": "view", + "signature": "keyExists(string,string)", + "selector": "0x528a683c", + "selectorBytes": [ + 82, + 138, + 104, + 60 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "label", + "description": "Labels an address in call traces.", + "declaration": "function label(address account, string calldata newLabel) external;", + "visibility": "external", + "mutability": "", + "signature": "label(address,string)", + "selector": "0xc657c718", + "selectorBytes": [ + 198, + 87, + 199, + 24 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "load", + "description": "Loads a storage slot from an address.", + "declaration": "function load(address target, bytes32 slot) external view returns (bytes32 data);", + "visibility": "external", + "mutability": "view", + "signature": "load(address,bytes32)", + "selector": "0x667f9d70", + "selectorBytes": [ + 102, + 127, + 157, + 112 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "makePersistent_0", + "description": "Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\nMeaning, changes made to the state of this account will be kept when switching forks.", + "declaration": "function makePersistent(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address)", + "selector": "0x57e22dde", + "selectorBytes": [ + 87, + 226, + 45, + 222 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "makePersistent_1", + "description": "See `makePersistent(address)`.", + "declaration": "function makePersistent(address account0, address account1) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address,address)", + "selector": "0x4074e0a8", + "selectorBytes": [ + 64, + 116, + 224, + 168 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "makePersistent_2", + "description": "See `makePersistent(address)`.", + "declaration": "function makePersistent(address account0, address account1, address account2) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address,address,address)", + "selector": "0xefb77a75", + "selectorBytes": [ + 239, + 183, + 122, + 117 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "makePersistent_3", + "description": "See `makePersistent(address)`.", + "declaration": "function makePersistent(address[] calldata accounts) external;", + "visibility": "external", + "mutability": "", + "signature": "makePersistent(address[])", + "selector": "0x1d9e269e", + "selectorBytes": [ + 29, + 158, + 38, + 158 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "mockCallRevert_0", + "description": "Reverts a call to an address with specified revert data.", + "declaration": "function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCallRevert(address,bytes,bytes)", + "selector": "0xdbaad147", + "selectorBytes": [ + 219, + 170, + 209, + 71 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "mockCallRevert_1", + "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.", + "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCallRevert(address,uint256,bytes,bytes)", + "selector": "0xd23cd037", + "selectorBytes": [ + 210, + 60, + 208, + 55 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "mockCall_0", + "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.", + "declaration": "function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCall(address,bytes,bytes)", + "selector": "0xb96213e4", + "selectorBytes": [ + 185, + 98, + 19, + 228 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "mockCall_1", + "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.", + "declaration": "function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCall(address,uint256,bytes,bytes)", + "selector": "0x81409b91", + "selectorBytes": [ + 129, + 64, + 155, + 145 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "parseAddress", + "description": "Parses the given `string` into an `address`.", + "declaration": "function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseAddress(string)", + "selector": "0xc6ce059d", + "selectorBytes": [ + 198, + 206, + 5, + 157 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseBool", + "description": "Parses the given `string` into a `bool`.", + "declaration": "function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseBool(string)", + "selector": "0x974ef924", + "selectorBytes": [ + 151, + 78, + 249, + 36 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseBytes", + "description": "Parses the given `string` into `bytes`.", + "declaration": "function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseBytes(string)", + "selector": "0x8f5d232d", + "selectorBytes": [ + 143, + 93, + 35, + 45 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseBytes32", + "description": "Parses the given `string` into a `bytes32`.", + "declaration": "function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseBytes32(string)", + "selector": "0x087e6e81", + "selectorBytes": [ + 8, + 126, + 110, + 129 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseInt", + "description": "Parses the given `string` into a `int256`.", + "declaration": "function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseInt(string)", + "selector": "0x42346c5e", + "selectorBytes": [ + 66, + 52, + 108, + 94 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonAddress", + "description": "Parses a string of JSON data at `key` and coerces it to `address`.", + "declaration": "function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonAddress(string,string)", + "selector": "0x1e19e657", + "selectorBytes": [ + 30, + 25, + 230, + 87 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonAddressArray", + "description": "Parses a string of JSON data at `key` and coerces it to `address[]`.", + "declaration": "function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonAddressArray(string,string)", + "selector": "0x2fce7883", + "selectorBytes": [ + 47, + 206, + 120, + 131 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonBool", + "description": "Parses a string of JSON data at `key` and coerces it to `bool`.", + "declaration": "function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBool(string,string)", + "selector": "0x9f86dc91", + "selectorBytes": [ + 159, + 134, + 220, + 145 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonBoolArray", + "description": "Parses a string of JSON data at `key` and coerces it to `bool[]`.", + "declaration": "function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBoolArray(string,string)", + "selector": "0x91f3b94f", + "selectorBytes": [ + 145, + 243, + 185, + 79 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonBytes", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes`.", + "declaration": "function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytes(string,string)", + "selector": "0xfd921be8", + "selectorBytes": [ + 253, + 146, + 27, + 232 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonBytes32", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes32`.", + "declaration": "function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytes32(string,string)", + "selector": "0x1777e59d", + "selectorBytes": [ + 23, + 119, + 229, + 157 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonBytes32Array", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes32[]`.", + "declaration": "function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytes32Array(string,string)", + "selector": "0x91c75bc3", + "selectorBytes": [ + 145, + 199, + 91, + 195 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonBytesArray", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes[]`.", + "declaration": "function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonBytesArray(string,string)", + "selector": "0x6631aa99", + "selectorBytes": [ + 102, + 49, + 170, + 153 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonInt", + "description": "Parses a string of JSON data at `key` and coerces it to `int256`.", + "declaration": "function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonInt(string,string)", + "selector": "0x7b048ccd", + "selectorBytes": [ + 123, + 4, + 140, + 205 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonIntArray", + "description": "Parses a string of JSON data at `key` and coerces it to `int256[]`.", + "declaration": "function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonIntArray(string,string)", + "selector": "0x9983c28a", + "selectorBytes": [ + 153, + 131, + 194, + 138 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonKeys", + "description": "Returns an array of all the keys in a JSON object.", + "declaration": "function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonKeys(string,string)", + "selector": "0x213e4198", + "selectorBytes": [ + 33, + 62, + 65, + 152 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonString", + "description": "Parses a string of JSON data at `key` and coerces it to `string`.", + "declaration": "function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonString(string,string)", + "selector": "0x49c4fac8", + "selectorBytes": [ + 73, + 196, + 250, + 200 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonStringArray", + "description": "Parses a string of JSON data at `key` and coerces it to `string[]`.", + "declaration": "function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonStringArray(string,string)", + "selector": "0x498fdcf4", + "selectorBytes": [ + 73, + 143, + 220, + 244 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonUint", + "description": "Parses a string of JSON data at `key` and coerces it to `uint256`.", + "declaration": "function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonUint(string,string)", + "selector": "0xaddde2b6", + "selectorBytes": [ + 173, + 221, + 226, + 182 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonUintArray", + "description": "Parses a string of JSON data at `key` and coerces it to `uint256[]`.", + "declaration": "function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonUintArray(string,string)", + "selector": "0x522074ab", + "selectorBytes": [ + 82, + 32, + 116, + 171 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJson_0", + "description": "ABI-encodes a JSON object.", + "declaration": "function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJson(string)", + "selector": "0x6a82600a", + "selectorBytes": [ + 106, + 130, + 96, + 10 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJson_1", + "description": "ABI-encodes a JSON object at `key`.", + "declaration": "function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJson(string,string)", + "selector": "0x85940ef1", + "selectorBytes": [ + 133, + 148, + 14, + 241 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseUint", + "description": "Parses the given `string` into a `uint256`.", + "declaration": "function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "parseUint(string)", + "selector": "0xfa91454d", + "selectorBytes": [ + 250, + 145, + 69, + 77 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "pauseGasMetering", + "description": "Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.", + "declaration": "function pauseGasMetering() external;", + "visibility": "external", + "mutability": "", + "signature": "pauseGasMetering()", + "selector": "0xd1a5b36f", + "selectorBytes": [ + 209, + 165, + 179, + 111 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "prank_0", + "description": "Sets the *next* call's `msg.sender` to be the input address.", + "declaration": "function prank(address msgSender) external;", + "visibility": "external", + "mutability": "", + "signature": "prank(address)", + "selector": "0xca669fa7", + "selectorBytes": [ + 202, + 102, + 159, + 167 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "prank_1", + "description": "Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", + "declaration": "function prank(address msgSender, address txOrigin) external;", + "visibility": "external", + "mutability": "", + "signature": "prank(address,address)", + "selector": "0x47e50cce", + "selectorBytes": [ + 71, + 229, + 12, + 206 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "prevrandao", + "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", + "declaration": "function prevrandao(bytes32 newPrevrandao) external;", + "visibility": "external", + "mutability": "", + "signature": "prevrandao(bytes32)", + "selector": "0x3b925549", + "selectorBytes": [ + 59, + 146, + 85, + 73 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "projectRoot", + "description": "Get the path of the current project root.", + "declaration": "function projectRoot() external view returns (string memory path);", + "visibility": "external", + "mutability": "view", + "signature": "projectRoot()", + "selector": "0xd930a0e6", + "selectorBytes": [ + 217, + 48, + 160, + 230 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readCallers", + "description": "Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.", + "declaration": "function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);", + "visibility": "external", + "mutability": "", + "signature": "readCallers()", + "selector": "0x4ad0bac9", + "selectorBytes": [ + 74, + 208, + 186, + 201 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "readDir_0", + "description": "Reads the directory at the given path recursively, up to `maxDepth`.\n`maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.\nFollows symbolic links if `followLinks` is true.", + "declaration": "function readDir(string calldata path) external view returns (DirEntry[] memory entries);", + "visibility": "external", + "mutability": "view", + "signature": "readDir(string)", + "selector": "0xc4bc59e0", + "selectorBytes": [ + 196, + 188, + 89, + 224 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readDir_1", + "description": "See `readDir(string)`.", + "declaration": "function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);", + "visibility": "external", + "mutability": "view", + "signature": "readDir(string,uint64)", + "selector": "0x1497876c", + "selectorBytes": [ + 20, + 151, + 135, + 108 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readDir_2", + "description": "See `readDir(string)`.", + "declaration": "function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries);", + "visibility": "external", + "mutability": "view", + "signature": "readDir(string,uint64,bool)", + "selector": "0x8102d70d", + "selectorBytes": [ + 129, + 2, + 215, + 13 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readFile", + "description": "Reads the entire content of file to string. `path` is relative to the project root.", + "declaration": "function readFile(string calldata path) external view returns (string memory data);", + "visibility": "external", + "mutability": "view", + "signature": "readFile(string)", + "selector": "0x60f9bb11", + "selectorBytes": [ + 96, + 249, + 187, + 17 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readFileBinary", + "description": "Reads the entire content of file as binary. `path` is relative to the project root.", + "declaration": "function readFileBinary(string calldata path) external view returns (bytes memory data);", + "visibility": "external", + "mutability": "view", + "signature": "readFileBinary(string)", + "selector": "0x16ed7bc4", + "selectorBytes": [ + 22, + 237, + 123, + 196 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readLine", + "description": "Reads next line of file to string.", + "declaration": "function readLine(string calldata path) external view returns (string memory line);", + "visibility": "external", + "mutability": "view", + "signature": "readLine(string)", + "selector": "0x70f55728", + "selectorBytes": [ + 112, + 245, + 87, + 40 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readLink", + "description": "Reads a symbolic link, returning the path that the link points to.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` is not a symbolic link.\n- `path` does not exist.", + "declaration": "function readLink(string calldata linkPath) external view returns (string memory targetPath);", + "visibility": "external", + "mutability": "view", + "signature": "readLink(string)", + "selector": "0x9f5684a2", + "selectorBytes": [ + 159, + 86, + 132, + 162 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "record", + "description": "Records all storage reads and writes.", + "declaration": "function record() external;", + "visibility": "external", + "mutability": "", + "signature": "record()", + "selector": "0x266cf109", + "selectorBytes": [ + 38, + 108, + 241, + 9 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "recordLogs", + "description": "Record all the transaction logs.", + "declaration": "function recordLogs() external;", + "visibility": "external", + "mutability": "", + "signature": "recordLogs()", + "selector": "0x41af2f52", + "selectorBytes": [ + 65, + 175, + 47, + 82 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "rememberKey", + "description": "Adds a private key to the local forge wallet and returns the address.", + "declaration": "function rememberKey(uint256 privateKey) external returns (address keyAddr);", + "visibility": "external", + "mutability": "", + "signature": "rememberKey(uint256)", + "selector": "0x22100064", + "selectorBytes": [ + 34, + 16, + 0, + 100 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "removeDir", + "description": "Removes a directory at the provided path.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` doesn't exist.\n- `path` isn't a directory.\n- User lacks permissions to modify `path`.\n- The directory is not empty and `recursive` is false.\n`path` is relative to the project root.", + "declaration": "function removeDir(string calldata path, bool recursive) external;", + "visibility": "external", + "mutability": "", + "signature": "removeDir(string,bool)", + "selector": "0x45c62011", + "selectorBytes": [ + 69, + 198, + 32, + 17 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "removeFile", + "description": "Removes a file from the filesystem.\nThis cheatcode will revert in the following situations, but is not limited to just these cases:\n- `path` points to a directory.\n- The file doesn't exist.\n- The user lacks permissions to remove the file.\n`path` is relative to the project root.", + "declaration": "function removeFile(string calldata path) external;", + "visibility": "external", + "mutability": "", + "signature": "removeFile(string)", + "selector": "0xf1afe04d", + "selectorBytes": [ + 241, + 175, + 224, + 77 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "resetNonce", + "description": "Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.", + "declaration": "function resetNonce(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "resetNonce(address)", + "selector": "0x1c72346d", + "selectorBytes": [ + 28, + 114, + 52, + 109 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "resumeGasMetering", + "description": "Resumes gas metering (i.e. gas usage is counted again). Noop if already on.", + "declaration": "function resumeGasMetering() external;", + "visibility": "external", + "mutability": "", + "signature": "resumeGasMetering()", + "selector": "0x2bcd50e0", + "selectorBytes": [ + 43, + 205, + 80, + 224 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "revertTo", + "description": "Revert the state of the EVM to a previous snapshot\nTakes the snapshot ID to revert to.\nThis deletes the snapshot and all snapshots taken after the given snapshot ID.", + "declaration": "function revertTo(uint256 snapshotId) external returns (bool success);", + "visibility": "external", + "mutability": "", + "signature": "revertTo(uint256)", + "selector": "0x44d7f0a4", + "selectorBytes": [ + 68, + 215, + 240, + 164 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "revokePersistent_0", + "description": "Revokes persistent status from the address, previously added via `makePersistent`.", + "declaration": "function revokePersistent(address account) external;", + "visibility": "external", + "mutability": "", + "signature": "revokePersistent(address)", + "selector": "0x997a0222", + "selectorBytes": [ + 153, + 122, + 2, + 34 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "revokePersistent_1", + "description": "See `revokePersistent(address)`.", + "declaration": "function revokePersistent(address[] calldata accounts) external;", + "visibility": "external", + "mutability": "", + "signature": "revokePersistent(address[])", + "selector": "0x3ce969e6", + "selectorBytes": [ + 60, + 233, + 105, + 230 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "roll", + "description": "Sets `block.height`.", + "declaration": "function roll(uint256 newHeight) external;", + "visibility": "external", + "mutability": "", + "signature": "roll(uint256)", + "selector": "0x1f7b4f30", + "selectorBytes": [ + 31, + 123, + 79, + 48 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "rollFork_0", + "description": "Updates the currently active fork to given block number\nThis is similar to `roll` but for the currently active fork.", + "declaration": "function rollFork(uint256 blockNumber) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(uint256)", + "selector": "0xd9bbf3a1", + "selectorBytes": [ + 217, + 187, + 243, + 161 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "rollFork_1", + "description": "Updates the currently active fork to given transaction. This will `rollFork` with the number\nof the block the transaction was mined in and replays all transaction mined before it in the block.", + "declaration": "function rollFork(bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(bytes32)", + "selector": "0x0f29772b", + "selectorBytes": [ + 15, + 41, + 119, + 43 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "rollFork_2", + "description": "Updates the given fork to given block number.", + "declaration": "function rollFork(uint256 forkId, uint256 blockNumber) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(uint256,uint256)", + "selector": "0xd74c83a4", + "selectorBytes": [ + 215, + 76, + 131, + 164 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "rollFork_3", + "description": "Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.", + "declaration": "function rollFork(uint256 forkId, bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "rollFork(uint256,bytes32)", + "selector": "0xf2830f7b", + "selectorBytes": [ + 242, + 131, + 15, + 123 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "rpc", + "description": "Performs an Ethereum JSON-RPC request to the current fork URL.", + "declaration": "function rpc(string calldata method, string calldata params) external returns (bytes memory data);", + "visibility": "external", + "mutability": "", + "signature": "rpc(string,string)", + "selector": "0x1206c8a8", + "selectorBytes": [ + 18, + 6, + 200, + 168 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "rpcUrl", + "description": "Returns the RPC url for the given alias.", + "declaration": "function rpcUrl(string calldata rpcAlias) external view returns (string memory json);", + "visibility": "external", + "mutability": "view", + "signature": "rpcUrl(string)", + "selector": "0x975a6ce9", + "selectorBytes": [ + 151, + 90, + 108, + 233 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "rpcUrlStructs", + "description": "Returns all rpc urls and their aliases as structs.", + "declaration": "function rpcUrlStructs() external view returns (Rpc[] memory urls);", + "visibility": "external", + "mutability": "view", + "signature": "rpcUrlStructs()", + "selector": "0x9d2ad72a", + "selectorBytes": [ + 157, + 42, + 215, + 42 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "rpcUrls", + "description": "Returns all rpc urls and their aliases `[alias, url][]`.", + "declaration": "function rpcUrls() external view returns (string[2][] memory urls);", + "visibility": "external", + "mutability": "view", + "signature": "rpcUrls()", + "selector": "0xa85a8418", + "selectorBytes": [ + 168, + 90, + 132, + 24 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "selectFork", + "description": "Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.", + "declaration": "function selectFork(uint256 forkId) external;", + "visibility": "external", + "mutability": "", + "signature": "selectFork(uint256)", + "selector": "0x9ebf6827", + "selectorBytes": [ + 158, + 191, + 104, + 39 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "serializeAddress_0", + "description": "See `serializeJson`.", + "declaration": "function serializeAddress(string calldata objectKey, string calldata valueKey, address value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeAddress(string,string,address)", + "selector": "0x972c6062", + "selectorBytes": [ + 151, + 44, + 96, + 98 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeAddress_1", + "description": "See `serializeJson`.", + "declaration": "function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeAddress(string,string,address[])", + "selector": "0x1e356e1a", + "selectorBytes": [ + 30, + 53, + 110, + 26 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeBool_0", + "description": "See `serializeJson`.", + "declaration": "function serializeBool(string calldata objectKey, string calldata valueKey, bool value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBool(string,string,bool)", + "selector": "0xac22e971", + "selectorBytes": [ + 172, + 34, + 233, + 113 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeBool_1", + "description": "See `serializeJson`.", + "declaration": "function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBool(string,string,bool[])", + "selector": "0x92925aa1", + "selectorBytes": [ + 146, + 146, + 90, + 161 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeBytes32_0", + "description": "See `serializeJson`.", + "declaration": "function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes32(string,string,bytes32)", + "selector": "0x2d812b44", + "selectorBytes": [ + 45, + 129, + 43, + 68 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeBytes32_1", + "description": "See `serializeJson`.", + "declaration": "function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes32(string,string,bytes32[])", + "selector": "0x201e43e2", + "selectorBytes": [ + 32, + 30, + 67, + 226 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeBytes_0", + "description": "See `serializeJson`.", + "declaration": "function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes(string,string,bytes)", + "selector": "0xf21d52c7", + "selectorBytes": [ + 242, + 29, + 82, + 199 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeBytes_1", + "description": "See `serializeJson`.", + "declaration": "function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeBytes(string,string,bytes[])", + "selector": "0x9884b232", + "selectorBytes": [ + 152, + 132, + 178, + 50 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeInt_0", + "description": "See `serializeJson`.", + "declaration": "function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeInt(string,string,int256)", + "selector": "0x3f33db60", + "selectorBytes": [ + 63, + 51, + 219, + 96 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeInt_1", + "description": "See `serializeJson`.", + "declaration": "function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeInt(string,string,int256[])", + "selector": "0x7676e127", + "selectorBytes": [ + 118, + 118, + 225, + 39 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeJson", + "description": "Serializes a key and value to a JSON object stored in-memory that can be later written to a file.\nReturns the stringified version of the specific JSON file up to that moment.", + "declaration": "function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeJson(string,string)", + "selector": "0x9b3358b0", + "selectorBytes": [ + 155, + 51, + 88, + 176 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeString_0", + "description": "See `serializeJson`.", + "declaration": "function serializeString(string calldata objectKey, string calldata valueKey, string calldata value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeString(string,string,string)", + "selector": "0x88da6d35", + "selectorBytes": [ + 136, + 218, + 109, + 53 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeString_1", + "description": "See `serializeJson`.", + "declaration": "function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeString(string,string,string[])", + "selector": "0x561cd6f3", + "selectorBytes": [ + 86, + 28, + 214, + 243 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeUint_0", + "description": "See `serializeJson`.", + "declaration": "function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeUint(string,string,uint256)", + "selector": "0x129e9002", + "selectorBytes": [ + 18, + 158, + 144, + 2 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeUint_1", + "description": "See `serializeJson`.", + "declaration": "function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeUint(string,string,uint256[])", + "selector": "0xfee9a469", + "selectorBytes": [ + 254, + 233, + 164, + 105 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "setEnv", + "description": "Sets environment variables.", + "declaration": "function setEnv(string calldata name, string calldata value) external;", + "visibility": "external", + "mutability": "", + "signature": "setEnv(string,string)", + "selector": "0x3d5923ee", + "selectorBytes": [ + 61, + 89, + 35, + 238 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "setNonce", + "description": "Sets the nonce of an account. Must be higher than the current nonce of the account.", + "declaration": "function setNonce(address account, uint64 newNonce) external;", + "visibility": "external", + "mutability": "", + "signature": "setNonce(address,uint64)", + "selector": "0xf8e18b57", + "selectorBytes": [ + 248, + 225, + 139, + 87 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "setNonceUnsafe", + "description": "Sets the nonce of an account to an arbitrary value.", + "declaration": "function setNonceUnsafe(address account, uint64 newNonce) external;", + "visibility": "external", + "mutability": "", + "signature": "setNonceUnsafe(address,uint64)", + "selector": "0x9b67b21c", + "selectorBytes": [ + 155, + 103, + 178, + 28 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "sign_0", + "description": "Signs data.", + "declaration": "function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "pure", + "signature": "sign(uint256,bytes32)", + "selector": "0xe341eaa4", + "selectorBytes": [ + 227, + 65, + 234, + 164 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "sign_1", + "description": "Signs data with a `Wallet`.", + "declaration": "function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "", + "signature": "sign((address,uint256,uint256,uint256),bytes32)", + "selector": "0xb25c5a25", + "selectorBytes": [ + 178, + 92, + 90, + 37 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "skip", + "description": "Marks a test as skipped. Must be called at the top of the test.", + "declaration": "function skip(bool skipTest) external;", + "visibility": "external", + "mutability": "", + "signature": "skip(bool)", + "selector": "0xdd82d13e", + "selectorBytes": [ + 221, + 130, + 209, + 62 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "sleep", + "description": "Suspends execution of the main thread for `duration` milliseconds.", + "declaration": "function sleep(uint256 duration) external;", + "visibility": "external", + "mutability": "", + "signature": "sleep(uint256)", + "selector": "0xfa9d8713", + "selectorBytes": [ + 250, + 157, + 135, + 19 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "snapshot", + "description": "Snapshot the current state of the evm.\nReturns the ID of the snapshot that was created.\nTo revert a snapshot use `revertTo`.", + "declaration": "function snapshot() external returns (uint256 snapshotId);", + "visibility": "external", + "mutability": "", + "signature": "snapshot()", + "selector": "0x9711715a", + "selectorBytes": [ + 151, + 17, + 113, + 90 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "startBroadcast_0", + "description": "Using the address that calls the test contract, has all subsequent calls\n(at this call depth only) create transactions that can later be signed and sent onchain.", + "declaration": "function startBroadcast() external;", + "visibility": "external", + "mutability": "", + "signature": "startBroadcast()", + "selector": "0x7fb5297f", + "selectorBytes": [ + 127, + 181, + 41, + 127 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "startBroadcast_1", + "description": "Has all subsequent calls (at this call depth only) create transactions with the address\nprovided that can later be signed and sent onchain.", + "declaration": "function startBroadcast(address signer) external;", + "visibility": "external", + "mutability": "", + "signature": "startBroadcast(address)", + "selector": "0x7fec2a8d", + "selectorBytes": [ + 127, + 236, + 42, + 141 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "startBroadcast_2", + "description": "Has all subsequent calls (at this call depth only) create transactions with the private key\nprovided that can later be signed and sent onchain.", + "declaration": "function startBroadcast(uint256 privateKey) external;", + "visibility": "external", + "mutability": "", + "signature": "startBroadcast(uint256)", + "selector": "0xce817d47", + "selectorBytes": [ + 206, + 129, + 125, + 71 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "startMappingRecording", + "description": "Starts recording all map SSTOREs for later retrieval.", + "declaration": "function startMappingRecording() external;", + "visibility": "external", + "mutability": "", + "signature": "startMappingRecording()", + "selector": "0x3e9705c0", + "selectorBytes": [ + 62, + 151, + 5, + 192 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "startPrank_0", + "description": "Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called.", + "declaration": "function startPrank(address msgSender) external;", + "visibility": "external", + "mutability": "", + "signature": "startPrank(address)", + "selector": "0x06447d56", + "selectorBytes": [ + 6, + 68, + 125, + 86 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "startPrank_1", + "description": "Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.", + "declaration": "function startPrank(address msgSender, address txOrigin) external;", + "visibility": "external", + "mutability": "", + "signature": "startPrank(address,address)", + "selector": "0x45b56078", + "selectorBytes": [ + 69, + 181, + 96, + 120 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "stopBroadcast", + "description": "Stops collecting onchain transactions.", + "declaration": "function stopBroadcast() external;", + "visibility": "external", + "mutability": "", + "signature": "stopBroadcast()", + "selector": "0x76eadd36", + "selectorBytes": [ + 118, + 234, + 221, + 54 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "stopMappingRecording", + "description": "Stops recording all map SSTOREs for later retrieval and clears the recorded data.", + "declaration": "function stopMappingRecording() external;", + "visibility": "external", + "mutability": "", + "signature": "stopMappingRecording()", + "selector": "0x0d4aae9b", + "selectorBytes": [ + 13, + 74, + 174, + 155 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "stopPrank", + "description": "Resets subsequent calls' `msg.sender` to be `address(this)`.", + "declaration": "function stopPrank() external;", + "visibility": "external", + "mutability": "", + "signature": "stopPrank()", + "selector": "0x90c5013b", + "selectorBytes": [ + 144, + 197, + 1, + 59 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "store", + "description": "Stores a value to an address' storage slot.", + "declaration": "function store(address target, bytes32 slot, bytes32 value) external;", + "visibility": "external", + "mutability": "", + "signature": "store(address,bytes32,bytes32)", + "selector": "0x70ca10bb", + "selectorBytes": [ + 112, + 202, + 16, + 187 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "toString_0", + "description": "Converts the given value to a `string`.", + "declaration": "function toString(address value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(address)", + "selector": "0x56ca623e", + "selectorBytes": [ + 86, + 202, + 98, + 62 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toString_1", + "description": "Converts the given value to a `string`.", + "declaration": "function toString(bytes calldata value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(bytes)", + "selector": "0x71aad10d", + "selectorBytes": [ + 113, + 170, + 209, + 13 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toString_2", + "description": "Converts the given value to a `string`.", + "declaration": "function toString(bytes32 value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(bytes32)", + "selector": "0xb11a19e8", + "selectorBytes": [ + 177, + 26, + 25, + 232 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toString_3", + "description": "Converts the given value to a `string`.", + "declaration": "function toString(bool value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(bool)", + "selector": "0x71dce7da", + "selectorBytes": [ + 113, + 220, + 231, + 218 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toString_4", + "description": "Converts the given value to a `string`.", + "declaration": "function toString(uint256 value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(uint256)", + "selector": "0x6900a3ae", + "selectorBytes": [ + 105, + 0, + 163, + 174 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toString_5", + "description": "Converts the given value to a `string`.", + "declaration": "function toString(int256 value) external pure returns (string memory stringifiedValue);", + "visibility": "external", + "mutability": "pure", + "signature": "toString(int256)", + "selector": "0xa322c40e", + "selectorBytes": [ + 163, + 34, + 196, + 14 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "transact_0", + "description": "Fetches the given transaction from the active fork and executes it on the current state.", + "declaration": "function transact(bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "transact(bytes32)", + "selector": "0xbe646da1", + "selectorBytes": [ + 190, + 100, + 109, + 161 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "transact_1", + "description": "Fetches the given transaction from the given fork and executes it on the current state.", + "declaration": "function transact(uint256 forkId, bytes32 txHash) external;", + "visibility": "external", + "mutability": "", + "signature": "transact(uint256,bytes32)", + "selector": "0x4d8abc4b", + "selectorBytes": [ + 77, + 138, + 188, + 75 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "tryFfi", + "description": "Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.", + "declaration": "function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);", + "visibility": "external", + "mutability": "", + "signature": "tryFfi(string[])", + "selector": "0xf45c1ce7", + "selectorBytes": [ + 244, + 92, + 28, + 231 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "txGasPrice", + "description": "Sets `tx.gasprice`.", + "declaration": "function txGasPrice(uint256 newGasPrice) external;", + "visibility": "external", + "mutability": "", + "signature": "txGasPrice(uint256)", + "selector": "0x48f50c0f", + "selectorBytes": [ + 72, + 245, + 12, + 15 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "unixTime", + "description": "Returns the time since unix epoch in milliseconds.", + "declaration": "function unixTime() external returns (uint256 milliseconds);", + "visibility": "external", + "mutability": "", + "signature": "unixTime()", + "selector": "0x625387dc", + "selectorBytes": [ + 98, + 83, + 135, + 220 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "warp", + "description": "Sets `block.timestamp`.", + "declaration": "function warp(uint256 newTimestamp) external;", + "visibility": "external", + "mutability": "", + "signature": "warp(uint256)", + "selector": "0xe5d6bf02", + "selectorBytes": [ + 229, + 214, + 191, + 2 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "writeFile", + "description": "Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.\n`path` is relative to the project root.", + "declaration": "function writeFile(string calldata path, string calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "writeFile(string,string)", + "selector": "0x897e0a97", + "selectorBytes": [ + 137, + 126, + 10, + 151 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "writeFileBinary", + "description": "Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.\n`path` is relative to the project root.", + "declaration": "function writeFileBinary(string calldata path, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "writeFileBinary(string,bytes)", + "selector": "0x1f21fc80", + "selectorBytes": [ + 31, + 33, + 252, + 128 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "writeJson_0", + "description": "Write a serialized JSON object to a file. If the file exists, it will be overwritten.", + "declaration": "function writeJson(string calldata json, string calldata path) external;", + "visibility": "external", + "mutability": "", + "signature": "writeJson(string,string)", + "selector": "0xe23cd19f", + "selectorBytes": [ + 226, + 60, + 209, + 159 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "writeJson_1", + "description": "Write a serialized JSON object to an **existing** JSON file, replacing a value with key = \nThis is useful to replace a specific value of a JSON file, without having to parse the entire thing.", + "declaration": "function writeJson(string calldata json, string calldata path, string calldata valueKey) external;", + "visibility": "external", + "mutability": "", + "signature": "writeJson(string,string,string)", + "selector": "0x35d6ad46", + "selectorBytes": [ + 53, + 214, + 173, + 70 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "writeLine", + "description": "Writes line to file, creating a file if it does not exist.\n`path` is relative to the project root.", + "declaration": "function writeLine(string calldata path, string calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "writeLine(string,string)", + "selector": "0x619d897f", + "selectorBytes": [ + 97, + 157, + 137, + 127 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + } + ] +} \ No newline at end of file diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index 8b28cc11e3ea6..7b68420ad63bf 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -2,46 +2,211 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Cheatcodes", "description": "Foundry cheatcodes. Learn more: ", - "type": "array", - "items": { - "$ref": "#/definitions/Cheatcode" + "type": "object", + "required": [ + "cheatcodes", + "enums", + "errors", + "events", + "structs" + ], + "properties": { + "cheatcodes": { + "description": "All the cheatcodes.", + "type": "array", + "items": { + "$ref": "#/definitions/Cheatcode" + } + }, + "enums": { + "description": "Cheatcode enums.", + "type": "array", + "items": { + "$ref": "#/definitions/Enum" + } + }, + "errors": { + "description": "Cheatcode errors.", + "type": "array", + "items": { + "$ref": "#/definitions/Error" + } + }, + "events": { + "description": "Cheatcode events.", + "type": "array", + "items": { + "$ref": "#/definitions/Event" + } + }, + "structs": { + "description": "Cheatcode structs.", + "type": "array", + "items": { + "$ref": "#/definitions/Struct" + } + } }, "definitions": { "Cheatcode": { - "description": "Specification of a single cheatcode.", + "description": "Specification of a single cheatcode. Extends [`Function`] with additional metadata.", + "type": "object", + "required": [ + "func", + "group", + "safety", + "status" + ], + "properties": { + "func": { + "description": "The Solidity function declaration.", + "allOf": [ + { + "$ref": "#/definitions/Function" + } + ] + }, + "group": { + "description": "The group that the cheatcode belongs to.", + "allOf": [ + { + "$ref": "#/definitions/Group" + } + ] + }, + "safety": { + "description": "Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an unexpected way.", + "allOf": [ + { + "$ref": "#/definitions/Safety" + } + ] + }, + "status": { + "description": "The current status of the cheatcode. E.g. whether it is stable or experimental, etc.", + "allOf": [ + { + "$ref": "#/definitions/Status" + } + ] + } + }, + "additionalProperties": false + }, + "Enum": { + "description": "A Solidity enumeration.", + "type": "object", + "required": [ + "description", + "name", + "variants" + ], + "properties": { + "description": { + "description": "The description of the enum. This is a markdown string derived from the NatSpec documentation.", + "type": "string" + }, + "name": { + "description": "The name of the enum.", + "type": "string" + }, + "variants": { + "description": "The variants of the enum.", + "type": "array", + "items": { + "$ref": "#/definitions/EnumVariant" + } + } + } + }, + "EnumVariant": { + "description": "A variant of an [`Enum`].", + "type": "object", + "required": [ + "description", + "name" + ], + "properties": { + "description": { + "description": "The description of the variant. This is a markdown string derived from the NatSpec documentation.", + "type": "string" + }, + "name": { + "description": "The name of the variant.", + "type": "string" + } + } + }, + "Error": { + "description": "A Solidity custom error.", + "type": "object", + "required": [ + "declaration", + "description", + "name" + ], + "properties": { + "declaration": { + "description": "The Solidity error declaration, including full type, parameter names, etc.", + "type": "string" + }, + "description": { + "description": "The description of the error. This is a markdown string derived from the NatSpec documentation.", + "type": "string" + }, + "name": { + "description": "The name of the error.", + "type": "string" + } + } + }, + "Event": { + "description": "A Solidity event.", + "type": "object", + "required": [ + "declaration", + "description", + "name" + ], + "properties": { + "declaration": { + "description": "The Solidity event declaration, including full type, parameter names, etc.", + "type": "string" + }, + "description": { + "description": "The description of the event. This is a markdown string derived from the NatSpec documentation.", + "type": "string" + }, + "name": { + "description": "The name of the event.", + "type": "string" + } + } + }, + "Function": { + "description": "Solidity function.", "type": "object", "required": [ "declaration", "description", - "group", "id", "mutability", - "safety", "selector", "selectorBytes", "signature", - "status", "visibility" ], "properties": { "declaration": { - "description": "The Solidity function declaration string, including full type and parameter names, visibility, etc.", + "description": "The Solidity function declaration, including full type and parameter names, visibility, etc.", "type": "string" }, "description": { - "description": "The description of the cheatcode. This is a markdown string derived from the documentation of the function declaration.", + "description": "The description of the function. This is a markdown string derived from the NatSpec documentation.", "type": "string" }, - "group": { - "description": "The group this cheatcode belongs to. Has to be specified for each cheatcode.", - "allOf": [ - { - "$ref": "#/definitions/Group" - } - ] - }, "id": { - "description": "The cheatcode's unique identifier. This is the function name, optionally appended with an index if it is overloaded.", + "description": "The function's unique identifier. This is the function name, optionally appended with an index if it is overloaded.", "type": "string" }, "mutability": { @@ -52,14 +217,6 @@ } ] }, - "safety": { - "description": "Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an unexpected way.\n\nDefaults first to the group's safety if unspecified. If the group is ambiguous, then it must be specified manually.", - "allOf": [ - { - "$ref": "#/definitions/Safety" - } - ] - }, "selector": { "description": "The hex-encoded, \"0x\"-prefixed 4-byte function selector, which is the Keccak-256 hash of `signature`.", "type": "string" @@ -79,14 +236,6 @@ "description": "The standard function signature used to calculate `selector`. See the [Solidity docs] for more information.\n\n[Solidity docs]: https://docs.soliditylang.org/en/latest/abi-spec.html#function-selector", "type": "string" }, - "status": { - "description": "The current status of the cheatcode. E.g. whether it is stable or experimental, etc. Has to be specified for each cheatcode.", - "allOf": [ - { - "$ref": "#/definitions/Status" - } - ] - }, "visibility": { "description": "The Solidity function visibility attribute. This is currently always `external`, but this may change in the future.", "allOf": [ @@ -95,8 +244,7 @@ } ] } - }, - "additionalProperties": false + } }, "Group": { "description": "Cheatcode groups. Initially derived and modified from inline comments in [`forge-std`'s `Vm.sol`][vmsol].\n\n[vmsol]: https://github.com/foundry-rs/forge-std/blob/dcb0d52bc4399d37a6545848e3b8f9d03c77b98d/src/Vm.sol", @@ -237,6 +385,55 @@ } ] }, + "Struct": { + "description": "A Solidity struct.", + "type": "object", + "required": [ + "description", + "fields", + "name" + ], + "properties": { + "description": { + "description": "The description of the struct. This is a markdown string derived from the NatSpec documentation.", + "type": "string" + }, + "fields": { + "description": "The fields of the struct.", + "type": "array", + "items": { + "$ref": "#/definitions/StructField" + } + }, + "name": { + "description": "The name of the struct.", + "type": "string" + } + } + }, + "StructField": { + "description": "A [`Struct`] field.", + "type": "object", + "required": [ + "description", + "name", + "ty" + ], + "properties": { + "description": { + "description": "The description of the field. This is a markdown string derived from the NatSpec documentation.", + "type": "string" + }, + "name": { + "description": "The name of the field.", + "type": "string" + }, + "ty": { + "description": "The type of the field.", + "type": "string" + } + } + }, "Visibility": { "description": "Solidity function visibility attribute. See the [Solidity docs] for more information.\n\n[Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#function-visibility", "oneOf": [ diff --git a/crates/cheatcodes/src/defs/cheatcode.rs b/crates/cheatcodes/src/defs/cheatcode.rs new file mode 100644 index 0000000000000..f7e0c87b306f2 --- /dev/null +++ b/crates/cheatcodes/src/defs/cheatcode.rs @@ -0,0 +1,177 @@ +use super::Function; +use alloy_sol_types::SolCall; +use serde::{Deserialize, Serialize}; + +/// Cheatcode definition trait. Implemented by all [`Vm`] functions. +pub trait CheatcodeDef: std::fmt::Debug + Clone + SolCall { + /// The static cheatcode definition. + const CHEATCODE: &'static Cheatcode<'static>; +} + +/// Specification of a single cheatcode. Extends [`Function`] with additional metadata. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Cheatcode<'a> { + // Automatically-generated fields. + /// The Solidity function declaration. + #[serde(borrow)] + pub func: Function<'a>, + + // Manually-specified fields. + /// The group that the cheatcode belongs to. + pub group: Group, + /// The current status of the cheatcode. E.g. whether it is stable or experimental, etc. + pub status: Status, + /// Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an + /// unexpected way. + pub safety: Safety, +} + +/// The status of a cheatcode. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub enum Status { + /// The cheatcode and its API is currently stable. + Stable, + /// The cheatcode is unstable, meaning it may contain bugs and may break its API on any + /// release. + /// + /// Use of experimental cheatcodes will result in a warning. + Experimental, + /// The cheatcode has been deprecated, meaning it will be removed in a future release. + /// + /// Use of deprecated cheatcodes is discouraged and will result in a warning. + Deprecated, + /// The cheatcode has been removed and is no longer available for use. + /// + /// Use of removed cheatcodes will result in a hard error. + Removed, +} + +/// Cheatcode groups. +/// Initially derived and modified from inline comments in [`forge-std`'s `Vm.sol`][vmsol]. +/// +/// [vmsol]: https://github.com/foundry-rs/forge-std/blob/dcb0d52bc4399d37a6545848e3b8f9d03c77b98d/src/Vm.sol +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub enum Group { + /// Cheatcodes that read from, or write to the current EVM execution state. + /// + /// Examples: any of the `record` cheatcodes, `chainId`, `coinbase`. + /// + /// Safety: ambiguous, depends on whether the cheatcode is read-only or not. + Evm, + /// Cheatcodes that interact with how a test is run. + /// + /// Examples: `assume`, `skip`, `expectRevert`. + /// + /// Safety: ambiguous, depends on whether the cheatcode is read-only or not. + Testing, + /// Cheatcodes that interact with how a script is run. + /// + /// Examples: `broadcast`, `startBroadcast`, `stopBroadcast`. + /// + /// Safety: safe. + Scripting, + /// Cheatcodes that interact with the OS or filesystem. + /// + /// Examples: `ffi`, `projectRoot`, `writeFile`. + /// + /// Safety: safe. + Filesystem, + /// Cheatcodes that interact with the program's environment variables. + /// + /// Examples: `setEnv`, `envBool`, `envOr`. + /// + /// Safety: safe. + Environment, + /// Utility cheatcodes that deal with string parsing and manipulation. + /// + /// Examples: `toString`. `parseBytes`. + /// + /// Safety: safe. + String, + /// Utility cheatcodes that deal with parsing values from and converting values to JSON. + /// + /// Examples: `serializeJson`, `parseJsonUint`, `writeJson`. + /// + /// Safety: safe. + Json, + /// Generic, uncategorized utilities. + /// + /// Examples: `toString`, `parse*`, `serialize*`. + /// + /// Safety: safe. + Utilities, +} + +impl Group { + /// Returns the safety of this cheatcode group. + /// + /// Some groups are inherently safe or unsafe, while others are ambiguous and will return + /// `None`. + #[inline] + pub const fn safety(self) -> Option { + match self { + Self::Evm | Self::Testing => None, + Self::Scripting | + Self::Filesystem | + Self::Environment | + Self::String | + Self::Json | + Self::Utilities => Some(Safety::Safe), + } + } + + /// Returns this value as a string. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::Evm => "evm", + Self::Testing => "testing", + Self::Scripting => "scripting", + Self::Filesystem => "filesystem", + Self::Environment => "environment", + Self::String => "string", + Self::Json => "json", + Self::Utilities => "utilities", + } + } +} + +// TODO: Find a better name for this +/// Cheatcode safety. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub enum Safety { + /// The cheatcode is not safe to use in scripts. + Unsafe, + /// The cheatcode is safe to use in scripts. + #[default] + Safe, +} + +impl Safety { + /// Returns this value as a string. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::Safe => "safe", + Self::Unsafe => "unsafe", + } + } + + /// Returns whether this value is safe. + #[inline] + pub const fn is_safe(self) -> bool { + matches!(self, Self::Safe) + } +} diff --git a/crates/cheatcodes/src/defs/function.rs b/crates/cheatcodes/src/defs/function.rs new file mode 100644 index 0000000000000..4c747fe152ee5 --- /dev/null +++ b/crates/cheatcodes/src/defs/function.rs @@ -0,0 +1,110 @@ +use serde::{Deserialize, Serialize}; +use std::fmt; + +/// Solidity function. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub struct Function<'a> { + /// The function's unique identifier. This is the function name, optionally appended with an + /// index if it is overloaded. + pub id: &'a str, + /// The description of the function. + /// This is a markdown string derived from the NatSpec documentation. + pub description: &'a str, + /// The Solidity function declaration, including full type and parameter names, visibility, + /// etc. + pub declaration: &'a str, + /// The Solidity function visibility attribute. This is currently always `external`, but this + /// may change in the future. + pub visibility: Visibility, + /// The Solidity function state mutability attribute. + pub mutability: Mutability, + /// The standard function signature used to calculate `selector`. + /// See the [Solidity docs] for more information. + /// + /// [Solidity docs]: https://docs.soliditylang.org/en/latest/abi-spec.html#function-selector + pub signature: &'a str, + /// The hex-encoded, "0x"-prefixed 4-byte function selector, + /// which is the Keccak-256 hash of `signature`. + pub selector: &'a str, + /// The 4-byte function selector as a byte array. + pub selector_bytes: [u8; 4], +} + +impl fmt::Display for Function<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.declaration) + } +} + +/// Solidity function visibility attribute. See the [Solidity docs] for more information. +/// +/// [Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#function-visibility +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub enum Visibility { + /// The function is only visible externally. + External, + /// Visible externally and internally. + Public, + /// Only visible internally. + Internal, + /// Only visible in the current contract + Private, +} + +impl fmt::Display for Visibility { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.as_str()) + } +} + +impl Visibility { + /// Returns the string representation of the visibility. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::External => "external", + Self::Public => "public", + Self::Internal => "internal", + Self::Private => "private", + } + } +} + +/// Solidity function state mutability attribute. See the [Solidity docs] for more information. +/// +/// [Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#state-mutability +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub enum Mutability { + /// Disallows modification or access of state. + Pure, + /// Disallows modification of state. + View, + /// Allows modification of state. + #[serde(rename = "")] + None, +} + +impl fmt::Display for Mutability { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.as_str()) + } +} + +impl Mutability { + /// Returns the string representation of the mutability. + #[inline] + pub const fn as_str(self) -> &'static str { + match self { + Self::Pure => "pure", + Self::View => "view", + Self::None => "", + } + } +} diff --git a/crates/cheatcodes/src/defs/items.rs b/crates/cheatcodes/src/defs/items.rs new file mode 100644 index 0000000000000..5a32e534e34b8 --- /dev/null +++ b/crates/cheatcodes/src/defs/items.rs @@ -0,0 +1,121 @@ +use serde::{Deserialize, Serialize}; +use std::{borrow::Cow, fmt}; + +/// A Solidity custom error. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct Error<'a> { + /// The name of the error. + pub name: &'a str, + /// The description of the error. + /// This is a markdown string derived from the NatSpec documentation. + pub description: &'a str, + /// The Solidity error declaration, including full type, parameter names, etc. + pub declaration: &'a str, +} + +impl fmt::Display for Error<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.declaration) + } +} + +/// A Solidity event. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct Event<'a> { + /// The name of the event. + pub name: &'a str, + /// The description of the event. + /// This is a markdown string derived from the NatSpec documentation. + pub description: &'a str, + /// The Solidity event declaration, including full type, parameter names, etc. + pub declaration: &'a str, +} + +impl fmt::Display for Event<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.declaration) + } +} + +/// A Solidity enumeration. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct Enum<'a> { + /// The name of the enum. + pub name: &'a str, + /// The description of the enum. + /// This is a markdown string derived from the NatSpec documentation. + pub description: &'a str, + /// The variants of the enum. + #[serde(borrow)] + pub variants: Cow<'a, [EnumVariant<'a>]>, +} + +impl fmt::Display for Enum<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "enum {} {{ ", self.name)?; + for (i, variant) in self.variants.iter().enumerate() { + if i > 0 { + f.write_str(", ")?; + } + f.write_str(variant.name)?; + } + f.write_str(" }") + } +} + +/// A variant of an [`Enum`]. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct EnumVariant<'a> { + /// The name of the variant. + pub name: &'a str, + /// The description of the variant. + /// This is a markdown string derived from the NatSpec documentation. + pub description: &'a str, +} + +/// A Solidity struct. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct Struct<'a> { + /// The name of the struct. + pub name: &'a str, + /// The description of the struct. + /// This is a markdown string derived from the NatSpec documentation. + pub description: &'a str, + /// The fields of the struct. + #[serde(borrow)] + pub fields: Cow<'a, [StructField<'a>]>, +} + +impl fmt::Display for Struct<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "struct {} {{ ", self.name)?; + for field in self.fields.iter() { + write!(f, "{} {}; ", field.ty, field.name)?; + } + f.write_str("}") + } +} + +/// A [`Struct`] field. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct StructField<'a> { + /// The name of the field. + pub name: &'a str, + /// The type of the field. + pub ty: &'a str, + /// The description of the field. + /// This is a markdown string derived from the NatSpec documentation. + pub description: &'a str, +} diff --git a/crates/cheatcodes/src/defs/mod.rs b/crates/cheatcodes/src/defs/mod.rs index 1ab640f29bf1c..652f65f5a3569 100644 --- a/crates/cheatcodes/src/defs/mod.rs +++ b/crates/cheatcodes/src/defs/mod.rs @@ -1,265 +1,90 @@ //! Cheatcode definitions. -use alloy_sol_types::SolCall; use serde::{Deserialize, Serialize}; +use std::{borrow::Cow, fmt}; -mod vm; -pub use vm::Vm; +mod cheatcode; +pub use cheatcode::{Cheatcode, CheatcodeDef, Group, Safety, Status}; -/// Cheatcode definition trait. Implemented by all [`Vm`] functions. -pub trait CheatcodeDef: std::fmt::Debug + Clone + SolCall { - /// The static cheatcode definition. - const CHEATCODE: &'static Cheatcode<'static>; -} +mod function; +pub use function::{Function, Mutability, Visibility}; -/// Specification of a single cheatcode. -#[derive(Serialize, Deserialize)] -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[serde(deny_unknown_fields, rename_all = "camelCase")] -#[non_exhaustive] -pub struct Cheatcode<'a> { - // Automatically-generated fields. - /// The cheatcode's unique identifier. This is the function name, optionally appended with an - /// index if it is overloaded. - pub id: &'a str, - /// The Solidity function declaration string, including full type and parameter names, - /// visibility, etc. - pub declaration: &'a str, - /// The Solidity function visibility attribute. This is currently always `external`, but this - /// may change in the future. - pub visibility: Visibility, - /// The Solidity function state mutability attribute. - pub mutability: Mutability, - /// The standard function signature used to calculate `selector`. - /// See the [Solidity docs] for more information. - /// - /// [Solidity docs]: https://docs.soliditylang.org/en/latest/abi-spec.html#function-selector - pub signature: &'a str, - /// The hex-encoded, "0x"-prefixed 4-byte function selector, - /// which is the Keccak-256 hash of `signature`. - pub selector: &'a str, - /// The 4-byte function selector as a byte array. - pub selector_bytes: [u8; 4], - /// The description of the cheatcode. - /// This is a markdown string derived from the documentation of the function declaration. - pub description: &'a str, +mod items; +pub use items::{Enum, EnumVariant, Error, Event, Struct, StructField}; - // Manually-specified fields. - /// The group this cheatcode belongs to. - /// Has to be specified for each cheatcode. - pub group: Group, - /// The current status of the cheatcode. E.g. whether it is stable or experimental, etc. - /// Has to be specified for each cheatcode. - pub status: Status, - /// Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an - /// unexpected way. - /// - /// Defaults first to the group's safety if unspecified. If the group is ambiguous, then it - /// must be specified manually. - pub safety: Safety, -} +mod vm; +pub use vm::Vm; -/// Solidity function visibility attribute. See the [Solidity docs] for more information. -/// -/// [Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#function-visibility -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +// The `cheatcodes.json` schema. +/// Foundry cheatcodes. Learn more: +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase")] -pub enum Visibility { - /// The function is only visible externally. - External, - /// Visible externally and internally. - Public, - /// Only visible internally. - Internal, - /// Only visible in the current contract - Private, +pub struct Cheatcodes<'a> { + /// Cheatcode errors. + #[serde(borrow)] + pub errors: Cow<'a, [Error<'a>]>, + /// Cheatcode events. + #[serde(borrow)] + pub events: Cow<'a, [Event<'a>]>, + /// Cheatcode enums. + #[serde(borrow)] + pub enums: Cow<'a, [Enum<'a>]>, + /// Cheatcode structs. + #[serde(borrow)] + pub structs: Cow<'a, [Struct<'a>]>, + /// All the cheatcodes. + #[serde(borrow)] + pub cheatcodes: Cow<'a, [Cheatcode<'a>]>, } -impl Visibility { - /// Returns the string representation of the visibility. - #[inline] - pub const fn as_str(self) -> &'static str { - match self { - Self::External => "external", - Self::Public => "public", - Self::Internal => "internal", - Self::Private => "private", +impl fmt::Display for Cheatcodes<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + for error in self.errors.iter() { + writeln!(f, "{error}")?; } - } -} - -/// Solidity function state mutability attribute. See the [Solidity docs] for more information. -/// -/// [Solidity docs]: https://docs.soliditylang.org/en/latest/contracts.html#state-mutability -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[serde(rename_all = "camelCase")] -pub enum Mutability { - /// Disallows modification or access of state. - Pure, - /// Disallows modification of state. - View, - /// Allows modification of state. - #[serde(rename = "")] - None, -} - -impl Mutability { - /// Returns the string representation of the mutability. - #[inline] - pub const fn as_str(self) -> &'static str { - match self { - Self::Pure => "pure", - Self::View => "view", - Self::None => "", + for event in self.events.iter() { + writeln!(f, "{event}")?; } - } -} - -/// The status of a cheatcode. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub enum Status { - /// The cheatcode and its API is currently stable. - Stable, - /// The cheatcode is unstable, meaning it may contain bugs and may break its API on any - /// release. - /// - /// Use of experimental cheatcodes will result in a warning. - Experimental, - /// The cheatcode has been deprecated, meaning it will be removed in a future release. - /// - /// Use of deprecated cheatcodes is discouraged and will result in a warning. - Deprecated, - /// The cheatcode has been removed and is no longer available for use. - /// - /// Use of removed cheatcodes will result in a hard error. - Removed, -} - -/// Cheatcode groups. -/// Initially derived and modified from inline comments in [`forge-std`'s `Vm.sol`][vmsol]. -/// -/// [vmsol]: https://github.com/foundry-rs/forge-std/blob/dcb0d52bc4399d37a6545848e3b8f9d03c77b98d/src/Vm.sol -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub enum Group { - /// Cheatcodes that read from, or write to the current EVM execution state. - /// - /// Examples: any of the `record` cheatcodes, `chainId`, `coinbase`. - /// - /// Safety: ambiguous, depends on whether the cheatcode is read-only or not. - Evm, - /// Cheatcodes that interact with how a test is run. - /// - /// Examples: `assume`, `skip`, `expectRevert`. - /// - /// Safety: ambiguous, depends on whether the cheatcode is read-only or not. - Testing, - /// Cheatcodes that interact with how a script is run. - /// - /// Examples: `broadcast`, `startBroadcast`, `stopBroadcast`. - /// - /// Safety: safe. - Scripting, - /// Cheatcodes that interact with the OS or filesystem. - /// - /// Examples: `ffi`, `projectRoot`, `writeFile`. - /// - /// Safety: safe. - Filesystem, - /// Cheatcodes that interact with the program's environment variables. - /// - /// Examples: `setEnv`, `envBool`, `envOr`. - /// - /// Safety: safe. - Environment, - /// Utility cheatcodes that deal with string parsing and manipulation. - /// - /// Examples: `toString`. `parseBytes`. - /// - /// Safety: safe. - String, - /// Utility cheatcodes that deal with parsing values from and converting values to JSON. - /// - /// Examples: `serializeJson`, `parseJsonUint`, `writeJson`. - /// - /// Safety: safe. - Json, - /// Generic, uncategorized utilities. - /// - /// Examples: `toString`, `parse*`, `serialize*`. - /// - /// Safety: safe. - Utilities, -} - -impl Group { - /// Returns the safety of this cheatcode group. - /// - /// Some groups are inherently safe or unsafe, while others are ambiguous and will return - /// `None`. - #[inline] - pub const fn safety(self) -> Option { - match self { - Self::Evm | Self::Testing => None, - Self::Scripting | - Self::Filesystem | - Self::Environment | - Self::String | - Self::Json | - Self::Utilities => Some(Safety::Safe), + for enumm in self.enums.iter() { + writeln!(f, "{enumm}")?; } - } - - /// Returns this value as a string. - #[inline] - pub const fn as_str(self) -> &'static str { - match self { - Self::Evm => "evm", - Self::Testing => "testing", - Self::Scripting => "scripting", - Self::Filesystem => "filesystem", - Self::Environment => "environment", - Self::String => "string", - Self::Json => "json", - Self::Utilities => "utilities", + for strukt in self.structs.iter() { + writeln!(f, "{strukt}")?; } + for cheatcode in self.cheatcodes.iter() { + writeln!(f, "{}", cheatcode.func)?; + } + Ok(()) } } -// TODO: Find a better name for this -/// Cheatcode safety. -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub enum Safety { - /// The cheatcode is not safe to use in scripts. - Unsafe, - /// The cheatcode is safe to use in scripts. - #[default] - Safe, +impl Default for Cheatcodes<'static> { + fn default() -> Self { + Self::new() + } } -impl Safety { - /// Returns this value as a string. - #[inline] - pub const fn as_str(self) -> &'static str { - match self { - Self::Safe => "safe", - Self::Unsafe => "unsafe", +impl Cheatcodes<'static> { + /// Returns the default cheatcodes. + pub fn new() -> Self { + Self { + // unfortunately technology has not yet advanced to the point where we can get all + // items of a certain type in a module, so we have to hardcode them here + structs: Cow::Owned(vec![ + Vm::Log::STRUCT.clone(), + Vm::Rpc::STRUCT.clone(), + Vm::EthGetLogs::STRUCT.clone(), + Vm::DirEntry::STRUCT.clone(), + Vm::FsMetadata::STRUCT.clone(), + Vm::Wallet::STRUCT.clone(), + Vm::FfiResult::STRUCT.clone(), + ]), + enums: Cow::Owned(vec![Vm::CallerMode::ENUM.clone()]), + errors: Vm::VM_ERRORS.iter().map(|&x| x.clone()).collect(), + events: Cow::Borrowed(&[]), + // events: Vm::VM_EVENTS.iter().map(|&x| x.clone()).collect(), + cheatcodes: Vm::CHEATCODES.iter().map(|&x| x.clone()).collect(), } } - - /// Returns whether this value is safe. - #[inline] - pub const fn is_safe(self) -> bool { - matches!(self, Self::Safe) - } } diff --git a/crates/cheatcodes/src/defs/vm.rs b/crates/cheatcodes/src/defs/vm.rs index e615d3129f455..c1bb5c4d78bf3 100644 --- a/crates/cheatcodes/src/defs/vm.rs +++ b/crates/cheatcodes/src/defs/vm.rs @@ -2,7 +2,7 @@ // module. Instead, we emit custom diagnostics in `#[derive(Cheatcode)]`. #![allow(missing_docs)] -use crate::{Cheatcode, CheatcodeDef, Group, Mutability, Safety, Status, Visibility}; +use super::*; use alloy_sol_types::sol; use foundry_macros::Cheatcode; @@ -19,8 +19,8 @@ sol! { interface Vm { // ======== Types ======== - /// Error thrown by a cheatcode. - error CheatCodeError(string message); + /// Error thrown by cheatcodes. + error CheatcodeError(string message); /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. enum CallerMode { @@ -54,6 +54,28 @@ interface Vm { string url; } + /// An RPC log object. Returned by `eth_getLogs`. + struct EthGetLogs { + /// The address of the log's emitter. + address emitter; + /// The topics of the log, including the signature, if any. + bytes32[] topics; + /// The raw data of the log. + bytes data; + /// The block hash. + bytes32 blockHash; + /// The block number. + uint64 blockNumber; + /// The transaction hash. + bytes32 transactionHash; + /// The transaction index in the block. + uint64 transactionIndex; + /// The log index. + uint256 logIndex; + /// Whether the log was removed. + bool removed; + } + /// A single entry in a directory listing. Returned by `readDir`. struct DirEntry { /// The error message, if any. @@ -229,6 +251,10 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function store(address target, bytes32 slot, bytes32 value) external; + /// Marks the slots of an account and the account address as cold. + #[cheatcode(group = Evm, safety = Unsafe)] + function cool(address target) external; + // -------- Call Manipulation -------- // --- Mocks --- @@ -352,6 +378,16 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function transact(uint256 forkId, bytes32 txHash) external; + /// Performs an Ethereum JSON-RPC request to the current fork URL. + #[cheatcode(group = Evm, safety = Unsafe)] + function rpc(string calldata method, string calldata params) external returns (bytes memory data); + + /// Gets all the logs according to specified filter. + #[cheatcode(group = Evm, safety = Unsafe)] + function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics) + external + returns (EthGetLogs[] memory logs); + // --- Behavior --- /// In forking mode, explicitly grant the given address cheatcode access. diff --git a/crates/cheatcodes/src/impls/config.rs b/crates/cheatcodes/src/impls/config.rs index 0bc4c25a1b12e..b3aff6b62ed82 100644 --- a/crates/cheatcodes/src/impls/config.rs +++ b/crates/cheatcodes/src/impls/config.rs @@ -6,31 +6,9 @@ use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, ResolvedRpcEndpoints, }; +use foundry_evm_core::opts::EvmOpts; use std::path::{Path, PathBuf}; -// TODO -#[derive(Clone, Debug, Default)] -pub struct EvmOpts { - pub ffi: bool, - pub fork_block_number: Option, -} - -impl EvmOpts { - pub fn get_compute_units_per_second(&self) -> u64 { - unimplemented!() - } - - pub async fn fork_evm_env( - &self, - _x: &str, - ) -> Result< - (revm::primitives::Env, ethers::types::Block), - core::convert::Infallible, - > { - unimplemented!() - } -} - /// Additional, configurable context the `Cheatcodes` inspector has access to /// /// This is essentially a subset of various `Config` settings `Cheatcodes` needs to know. diff --git a/crates/cheatcodes/src/impls/db.rs b/crates/cheatcodes/src/impls/db.rs deleted file mode 100644 index 869a4952ac85e..0000000000000 --- a/crates/cheatcodes/src/impls/db.rs +++ /dev/null @@ -1,307 +0,0 @@ -use super::config::EvmOpts; -use crate::Cheatcodes; -use alloy_primitives::{Address, B256, U256}; -use itertools::Itertools; -use revm::{primitives::Env, Database, JournaledState}; - -mod error; -pub use error::{DatabaseError, DatabaseResult}; - -/// Represents a numeric `ForkId` valid only for the existence of the `Backend`. -/// The difference between `ForkId` and `LocalForkId` is that `ForkId` tracks pairs of `endpoint + -/// block` which can be reused by multiple tests, whereas the `LocalForkId` is unique within a test -pub type LocalForkId = U256; - -/// Represents possible diagnostic cases on revert -#[derive(Debug, Clone)] -#[allow(missing_docs)] -pub enum RevertDiagnostic { - /// The `contract` does not exist on the `active` fork but exist on other fork(s) - ContractExistsOnOtherForks { - contract: Address, - active: LocalForkId, - available_on: Vec, - }, - ContractDoesNotExist { - contract: Address, - active: LocalForkId, - persistent: bool, - }, -} - -impl RevertDiagnostic { - /// Converts the diagnostic to a readable error message - pub fn to_error_msg(&self, cheats: &Cheatcodes) -> String { - let get_label = - |addr: &Address| cheats.labels.get(addr).cloned().unwrap_or_else(|| addr.to_string()); - - match self { - RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => { - let contract_label = get_label(contract); - - format!( - "Contract {contract_label} does not exist on active fork with id `{active}` - but exists on non active forks: `[{}]`", - available_on.iter().format(", ") - ) - } - RevertDiagnostic::ContractDoesNotExist { contract, persistent, .. } => { - let contract_label = get_label(contract); - if *persistent { - format!("Contract {contract_label} does not exist") - } else { - format!( - "Contract {contract_label} does not exist and is not marked \ - as persistent, see `makePersistent`" - ) - } - } - } - } -} - -/// Represents a _fork_ of a remote chain whose data is available only via the `url` endpoint. -#[derive(Debug, Clone)] -pub struct CreateFork { - /// Whether to enable rpc storage caching for this fork. - pub enable_caching: bool, - /// The URL to a node for fetching remote state. - pub url: String, - /// The env to create this fork, main purpose is to provide some metadata for the fork. - pub env: Env, - /// All env settings as configured by the user - pub evm_opts: EvmOpts, -} - -/// Extend the [`revm::Database`] with cheatcodes specific functionality. -pub trait DatabaseExt: Database { - /// Creates a new snapshot at the current point of execution. - /// - /// A snapshot is associated with a new unique id that's created for the snapshot. - /// Snapshots can be reverted: [DatabaseExt::revert], however a snapshot can only be reverted - /// once. After a successful revert, the same snapshot id cannot be used again. - fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256; - - /// Reverts the snapshot if it exists - /// - /// Returns `true` if the snapshot was successfully reverted, `false` if no snapshot for that id - /// exists. - /// - /// **N.B.** While this reverts the state of the evm to the snapshot, it keeps new logs made - /// since the snapshots was created. This way we can show logs that were emitted between - /// snapshot and its revert. - /// This will also revert any changes in the `Env` and replace it with the captured `Env` of - /// `Self::snapshot` - fn revert( - &mut self, - id: U256, - journaled_state: &JournaledState, - env: &mut Env, - ) -> Option; - - /// Creates and also selects a new fork - /// - /// This is basically `create_fork` + `select_fork` - fn create_select_fork( - &mut self, - fork: CreateFork, - env: &mut Env, - journaled_state: &mut JournaledState, - ) -> eyre::Result { - let id = self.create_fork(fork)?; - self.select_fork(id, env, journaled_state)?; - Ok(id) - } - - /// Creates and also selects a new fork - /// - /// This is basically `create_fork` + `select_fork` - fn create_select_fork_at_transaction( - &mut self, - fork: CreateFork, - env: &mut Env, - journaled_state: &mut JournaledState, - transaction: B256, - ) -> eyre::Result { - let id = self.create_fork_at_transaction(fork, transaction)?; - self.select_fork(id, env, journaled_state)?; - Ok(id) - } - - /// Creates a new fork but does _not_ select it - fn create_fork(&mut self, fork: CreateFork) -> eyre::Result; - - /// Creates a new fork but does _not_ select it - fn create_fork_at_transaction( - &mut self, - fork: CreateFork, - transaction: B256, - ) -> eyre::Result; - - /// Selects the fork's state - /// - /// This will also modify the current `Env`. - /// - /// **Note**: this does not change the local state, but swaps the remote state - /// - /// # Errors - /// - /// Returns an error if no fork with the given `id` exists - fn select_fork( - &mut self, - id: LocalForkId, - env: &mut Env, - journaled_state: &mut JournaledState, - ) -> eyre::Result<()>; - - /// Updates the fork to given block number. - /// - /// This will essentially create a new fork at the given block height. - /// - /// # Errors - /// - /// Returns an error if not matching fork was found. - fn roll_fork( - &mut self, - id: Option, - block_number: U256, - env: &mut Env, - journaled_state: &mut JournaledState, - ) -> eyre::Result<()>; - - /// Updates the fork to given transaction hash - /// - /// This will essentially create a new fork at the block this transaction was mined and replays - /// all transactions up until the given transaction. - /// - /// # Errors - /// - /// Returns an error if not matching fork was found. - fn roll_fork_to_transaction( - &mut self, - id: Option, - transaction: B256, - env: &mut Env, - journaled_state: &mut JournaledState, - ) -> eyre::Result<()>; - - /// Fetches the given transaction for the fork and executes it, committing the state in the DB - fn transact( - &mut self, - id: Option, - transaction: B256, - env: &mut Env, - journaled_state: &mut JournaledState, - cheatcodes_inspector: Option<&mut Cheatcodes>, - ) -> eyre::Result<()>; - - /// Returns the `ForkId` that's currently used in the database, if fork mode is on - fn active_fork_id(&self) -> Option; - - /// Returns the Fork url that's currently used in the database, if fork mode is on - fn active_fork_url(&self) -> Option; - - /// Whether the database is currently in forked - fn is_forked_mode(&self) -> bool { - self.active_fork_id().is_some() - } - - /// Ensures that an appropriate fork exits - /// - /// If `id` contains a requested `Fork` this will ensure it exits. - /// Otherwise, this returns the currently active fork. - /// - /// # Errors - /// - /// Returns an error if the given `id` does not match any forks - /// - /// Returns an error if no fork exits - fn ensure_fork(&self, id: Option) -> eyre::Result; - - /// Handling multiple accounts/new contracts in a multifork environment can be challenging since - /// every fork has its own standalone storage section. So this can be a common error to run - /// into: - /// - /// ```solidity - /// function testCanDeploy() public { - /// vm.selectFork(mainnetFork); - /// // contract created while on `mainnetFork` - /// DummyContract dummy = new DummyContract(); - /// // this will succeed - /// dummy.hello(); - /// - /// vm.selectFork(optimismFork); - /// - /// vm.expectRevert(); - /// // this will revert since `dummy` contract only exists on `mainnetFork` - /// dummy.hello(); - /// } - /// ``` - /// - /// If this happens (`dummy.hello()`), or more general, a call on an address that's not a - /// contract, revm will revert without useful context. This call will check in this context if - /// `address(dummy)` belongs to an existing contract and if not will check all other forks if - /// the contract is deployed there. - /// - /// Returns a more useful error message if that's the case - fn diagnose_revert( - &self, - callee: Address, - journaled_state: &JournaledState, - ) -> Option; - - /// Returns true if the given account is currently marked as persistent. - fn is_persistent(&self, acc: &Address) -> bool; - - /// Revokes persistent status from the given account. - fn remove_persistent_account(&mut self, account: &Address) -> bool; - - /// Marks the given account as persistent. - fn add_persistent_account(&mut self, account: Address) -> bool; - - /// Removes persistent status from all given accounts - fn remove_persistent_accounts(&mut self, accounts: impl IntoIterator) { - for acc in accounts { - self.remove_persistent_account(&acc); - } - } - - /// Extends the persistent accounts with the accounts the iterator yields. - fn extend_persistent_accounts(&mut self, accounts: impl IntoIterator) { - for acc in accounts { - self.add_persistent_account(acc); - } - } - - /// Grants cheatcode access for the given `account` - /// - /// Returns true if the `account` already has access - fn allow_cheatcode_access(&mut self, account: Address) -> bool; - - /// Revokes cheatcode access for the given account - /// - /// Returns true if the `account` was previously allowed cheatcode access - fn revoke_cheatcode_access(&mut self, account: Address) -> bool; - - /// Returns `true` if the given account is allowed to execute cheatcodes - fn has_cheatcode_access(&self, account: Address) -> bool; - - /// Ensures that `account` is allowed to execute cheatcodes - /// - /// Returns an error if [`Self::has_cheatcode_access`] returns `false` - fn ensure_cheatcode_access(&self, account: Address) -> Result<(), DatabaseError> { - if !self.has_cheatcode_access(account) { - return Err(DatabaseError::NoCheats(account)) - } - Ok(()) - } - - /// Same as [`Self::ensure_cheatcode_access()`] but only enforces it if the backend is currently - /// in forking mode - fn ensure_cheatcode_access_forking_mode(&self, account: Address) -> Result<(), DatabaseError> { - if self.is_forked_mode() { - return self.ensure_cheatcode_access(account) - } - Ok(()) - } -} diff --git a/crates/cheatcodes/src/impls/db/error.rs b/crates/cheatcodes/src/impls/db/error.rs deleted file mode 100644 index 93eb536ee8092..0000000000000 --- a/crates/cheatcodes/src/impls/db/error.rs +++ /dev/null @@ -1,103 +0,0 @@ -use alloy_primitives::{Address, B256, U256}; -use ethers::types::BlockId; -use futures::channel::mpsc::{SendError, TrySendError}; -use std::{ - convert::Infallible, - sync::{mpsc::RecvError, Arc}, -}; - -/// Result alias with `DatabaseError` as error -pub type DatabaseResult = Result; - -/// Errors that can happen when working with [`revm::Database`] -#[derive(Debug, thiserror::Error)] -#[allow(missing_docs)] -pub enum DatabaseError { - #[error("{0}")] - Message(String), - #[error("no cheats available for {0}")] - NoCheats(Address), - #[error("failed to fetch AccountInfo {0}")] - MissingAccount(Address), - #[error("code should already be loaded: {0}")] - MissingCode(B256), - #[error(transparent)] - Recv(#[from] RecvError), - #[error(transparent)] - Send(#[from] SendError), - #[error("failed to get account for {0}: {1}")] - GetAccount(Address, Arc), - #[error("failed to get storage for {0} at {1}: {2}")] - GetStorage(Address, U256, Arc), - #[error("failed to get block hash for {0}: {1}")] - GetBlockHash(u64, Arc), - #[error("failed to get full block for {0:?}: {1}")] - GetFullBlock(BlockId, Arc), - #[error("block {0:?} does not exist")] - BlockNotFound(BlockId), - #[error("failed to get transaction {0}: {1}")] - GetTransaction(B256, Arc), - #[error("transaction {0} not found")] - TransactionNotFound(B256), - #[error( - "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n\ - For a production environment, you can deploy it using the pre-signed transaction from \ - https://github.com/Arachnid/deterministic-deployment-proxy.\n\ - For a test environment, you can use `etch` to place the required bytecode at that address." - )] - MissingCreate2Deployer, -} - -impl DatabaseError { - /// Create a new error with a message - pub fn msg(msg: impl Into) -> Self { - DatabaseError::Message(msg.into()) - } - - /// Create a new error with a message - pub fn display(msg: impl std::fmt::Display) -> Self { - DatabaseError::Message(msg.to_string()) - } - - fn get_rpc_error(&self) -> Option<&eyre::Error> { - match self { - Self::GetAccount(_, err) => Some(err), - Self::GetStorage(_, _, err) => Some(err), - Self::GetBlockHash(_, err) => Some(err), - Self::GetFullBlock(_, err) => Some(err), - Self::GetTransaction(_, err) => Some(err), - // Enumerate explicitly to make sure errors are updated if a new one is added. - Self::NoCheats(_) | - Self::MissingAccount(_) | - Self::MissingCode(_) | - Self::Recv(_) | - Self::Send(_) | - Self::Message(_) | - Self::BlockNotFound(_) | - Self::TransactionNotFound(_) | - Self::MissingCreate2Deployer => None, - } - } - - /// Whether the error is potentially caused by the user forking from an older block in a - /// non-archive node. - pub fn is_possibly_non_archive_node_error(&self) -> bool { - static GETH_MESSAGE: &str = "missing trie node"; - - self.get_rpc_error() - .map(|err| err.to_string().to_lowercase().contains(GETH_MESSAGE)) - .unwrap_or(false) - } -} - -impl From> for DatabaseError { - fn from(err: TrySendError) -> Self { - err.into_send_error().into() - } -} - -impl From for DatabaseError { - fn from(value: Infallible) -> Self { - match value {} - } -} diff --git a/crates/cheatcodes/src/impls/error.rs b/crates/cheatcodes/src/impls/error.rs index f24f91784e617..8c3cd2307d8bd 100644 --- a/crates/cheatcodes/src/impls/error.rs +++ b/crates/cheatcodes/src/impls/error.rs @@ -1,8 +1,11 @@ +use crate::Vm; use alloy_primitives::{Address, Bytes}; -use alloy_sol_types::{Revert, SolError, SolValue}; -use ethers::{core::k256::ecdsa::signature::Error as SignatureError, signers::WalletError}; +use alloy_sol_types::SolError; +use ethers_core::k256::ecdsa::signature::Error as SignatureError; +use ethers_signers::WalletError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; +use foundry_evm_core::backend::DatabaseError; use std::{borrow::Cow, fmt, ptr::NonNull}; /// Cheatcode result type. @@ -63,7 +66,7 @@ macro_rules! ensure_not_precompile { ($address:expr, $ctxt:expr) => { if $ctxt.is_precompile($address) { return Err($crate::impls::error::precompile_error( - ::CHEATCODE.id, + ::CHEATCODE.func.id, $address, )) } @@ -72,7 +75,7 @@ macro_rules! ensure_not_precompile { #[cold] pub(crate) fn precompile_error(id: &'static str, address: &Address) -> Error { - fmt_err!("cannot call {id} on precompile {address}") + fmt_err!("cannot call `{id}` on precompile {address}") } /// Error thrown by cheatcodes. @@ -92,6 +95,7 @@ impl std::error::Error for Error {} impl fmt::Debug for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("Error::")?; self.kind().fmt(f) } } @@ -107,9 +111,9 @@ impl fmt::Display for Error { /// Constructed by [`Error::kind`]. #[derive(Debug)] pub enum ErrorKind<'a> { - /// A string error, encoded as `Error(string)`. + /// A string error, ABI-encoded as `CheatcodeError(string)`. String(&'a str), - /// A bytes error, encoded directly as just `bytes`. + /// A raw bytes error. Does not get encoded. Bytes(&'a [u8]), } @@ -123,7 +127,7 @@ impl fmt::Display for ErrorKind<'_> { } impl Error { - /// Creates a new error and ABI encodes it. + /// Creates a new error and ABI encodes it as `CheatcodeError(string)`. pub fn encode(error: impl Into) -> Bytes { error.into().abi_encode().into() } @@ -141,19 +145,14 @@ impl Error { } } - /// ABI-encodes this error. + /// ABI-encodes this error as `CheatcodeError(string)`. pub fn abi_encode(&self) -> Vec { match self.kind() { - ErrorKind::String(string) => Revert::from(string).abi_encode(), - ErrorKind::Bytes(bytes) => bytes.abi_encode(), + ErrorKind::String(string) => Vm::CheatcodeError { message: string.into() }.abi_encode(), + ErrorKind::Bytes(bytes) => bytes.into(), } } - /// ABI-encodes this error as `bytes`. - pub fn abi_encode_bytes(&self) -> Vec { - self.data().abi_encode() - } - /// Returns the kind of this error. #[inline(always)] pub fn kind(&self) -> ErrorKind<'_> { @@ -280,11 +279,11 @@ macro_rules! impl_from { impl_from!( alloy_sol_types::Error, - ethers::types::SignatureError, + ethers_core::types::SignatureError, FsPathError, hex::FromHexError, eyre::Error, - super::db::DatabaseError, + DatabaseError, jsonpath_lib::JsonPathError, serde_json::Error, SignatureError, @@ -295,3 +294,18 @@ impl_from!( UnresolvedEnvVarError, WalletError, ); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn encode() { + let error = Vm::CheatcodeError { message: "hello".into() }.abi_encode(); + assert_eq!(Error::from("hello").abi_encode(), error); + assert_eq!(Error::encode("hello"), error); + + assert_eq!(Error::from(b"hello").abi_encode(), b"hello"); + assert_eq!(Error::encode(b"hello"), b"hello"[..]); + } +} diff --git a/crates/cheatcodes/src/impls/evm.rs b/crates/cheatcodes/src/impls/evm.rs index d75ec06b6ce62..3956fb52c88d0 100644 --- a/crates/cheatcodes/src/impls/evm.rs +++ b/crates/cheatcodes/src/impls/evm.rs @@ -1,10 +1,11 @@ //! Implementations of [`Evm`](crate::Group::Evm) cheatcodes. -use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use super::{Cheatcode, CheatsCtxt, Result}; use crate::{Cheatcodes, Vm::*}; -use alloy_primitives::{Address, U256}; +use alloy_primitives::{Address, Bytes, U256}; use alloy_sol_types::SolValue; -use ethers::signers::Signer; +use ethers_signers::Signer; +use foundry_evm_core::backend::DatabaseExt; use foundry_utils::types::ToAlloy; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, @@ -219,7 +220,7 @@ impl Cheatcode for etchCall { let Self { target, newRuntimeBytecode } = self; ensure_not_precompile!(target, ccx); ccx.data.journaled_state.load_account(*target, ccx.data.db)?; - let bytecode = Bytecode::new_raw(newRuntimeBytecode.clone().into()).to_checked(); + let bytecode = Bytecode::new_raw(Bytes::copy_from_slice(newRuntimeBytecode)).to_checked(); ccx.data.journaled_state.set_code(*target, bytecode); Ok(Default::default()) } @@ -235,6 +236,7 @@ impl Cheatcode for resetNonceCall { let empty = account.info.code_hash == KECCAK_EMPTY; let nonce = if empty { 0 } else { 1 }; account.info.nonce = nonce; + debug!(target: "cheatcodes", nonce, "reset"); Ok(Default::default()) } } @@ -275,6 +277,17 @@ impl Cheatcode for storeCall { } } +impl Cheatcode for coolCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { target } = self; + if let Some(account) = ccx.data.journaled_state.state.get_mut(target) { + account.unmark_touch(); + account.storage.clear(); + } + Ok(Default::default()) + } +} + impl Cheatcode for readCallersCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; diff --git a/crates/cheatcodes/src/impls/evm/fork.rs b/crates/cheatcodes/src/impls/evm/fork.rs index c192db302315c..c4d7c410062a6 100644 --- a/crates/cheatcodes/src/impls/evm/fork.rs +++ b/crates/cheatcodes/src/impls/evm/fork.rs @@ -1,8 +1,13 @@ +use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use crate::{Cheatcodes, Vm::*}; use alloy_primitives::B256; use alloy_sol_types::SolValue; - -use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; -use crate::{impls::CreateFork, Cheatcodes, Vm::*}; +use ethers_core::types::Filter; +use ethers_providers::Middleware; +use foundry_common::ProviderBuilder; +use foundry_compilers::utils::RuntimeOrHandle; +use foundry_evm_core::fork::CreateFork; +use foundry_utils::types::{ToAlloy, ToEthers}; impl Cheatcode for activeForkCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { @@ -126,7 +131,7 @@ impl Cheatcode for transact_0Call { txHash, ccx.data.env, &mut ccx.data.journaled_state, - Some(ccx.state), + ccx.state, )?; Ok(Default::default()) } @@ -140,7 +145,7 @@ impl Cheatcode for transact_1Call { txHash, ccx.data.env, &mut ccx.data.journaled_state, - Some(ccx.state), + ccx.state, )?; Ok(Default::default()) } @@ -212,6 +217,76 @@ impl Cheatcode for isPersistentCall { } } +impl Cheatcode for rpcCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { method, params } = self; + let url = + ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; + let provider = ProviderBuilder::new(url).build()?; + + let params_json: serde_json::Value = serde_json::from_str(params)?; + let result = RuntimeOrHandle::new() + .block_on(provider.request(method, params_json)) + .map_err(|err| fmt_err!("{method:?}: {err}"))?; + + let result_as_tokens = crate::impls::json::value_to_token(&result) + .map_err(|err| fmt_err!("failed to parse result: {err}"))?; + + Ok(result_as_tokens.abi_encode()) + } +} + +impl Cheatcode for eth_getLogsCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { fromBlock, toBlock, addr, topics } = self; + let (Ok(from_block), Ok(to_block)) = (u64::try_from(fromBlock), u64::try_from(toBlock)) + else { + bail!("blocks in block range must be less than 2^64 - 1") + }; + + if topics.len() > 4 { + bail!("topics array must contain at most 4 elements") + } + + let url = + ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; + let provider = ProviderBuilder::new(url).build()?; + let mut filter = + Filter::new().address(addr.to_ethers()).from_block(from_block).to_block(to_block); + for (i, topic) in topics.iter().enumerate() { + let topic = topic.to_ethers(); + match i { + 0 => filter = filter.topic0(topic), + 1 => filter = filter.topic1(topic), + 2 => filter = filter.topic2(topic), + 3 => filter = filter.topic3(topic), + _ => unreachable!(), + }; + } + + let logs = RuntimeOrHandle::new() + .block_on(provider.get_logs(&filter)) + .map_err(|e| fmt_err!("eth_getLogs: {e}"))?; + + let eth_logs = logs + .into_iter() + .map(|log| EthGetLogs { + emitter: log.address.to_alloy(), + topics: log.topics.into_iter().map(ToAlloy::to_alloy).collect(), + data: log.data.0.into(), + blockHash: log.block_hash.unwrap_or_default().to_alloy(), + blockNumber: log.block_number.unwrap_or_default().to_alloy().to(), + transactionHash: log.transaction_hash.unwrap_or_default().to_alloy(), + transactionIndex: log.transaction_index.unwrap_or_default().to_alloy().to(), + logIndex: log.log_index.unwrap_or_default().to_alloy(), + removed: log.removed.unwrap_or(false), + }) + .collect::>(); + + Ok(eth_logs.abi_encode()) + } +} + /// Creates and then also selects the new fork fn create_select_fork( ccx: &mut CheatsCtxt, diff --git a/crates/cheatcodes/src/impls/evm/mock.rs b/crates/cheatcodes/src/impls/evm/mock.rs index 5e70b33ac0c6e..a3a61711dd322 100644 --- a/crates/cheatcodes/src/impls/evm/mock.rs +++ b/crates/cheatcodes/src/impls/evm/mock.rs @@ -1,7 +1,7 @@ use super::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result}; use crate::Vm::*; use alloy_primitives::{Address, Bytes, U256}; -use revm::interpreter::InstructionResult; +use revm::{interpreter::InstructionResult, primitives::Bytecode}; use std::cmp::Ordering; /// Mocked call data. @@ -50,7 +50,16 @@ impl Cheatcode for clearMockedCallsCall { impl Cheatcode for mockCall_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; - ccx.data.journaled_state.load_account(*callee, ccx.data.db)?; + let (acc, _) = ccx.data.journaled_state.load_account(*callee, ccx.data.db)?; + + // Etches a single byte onto the account if it is empty to circumvent the `extcodesize` + // check Solidity might perform. + let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty); + if empty_bytecode { + let code = Bytecode::new_raw(Bytes::from_static(&[0u8])).to_checked(); + ccx.data.journaled_state.set_code(*callee, code); + } + mock_call(ccx.state, callee, data, None, returnData, InstructionResult::Return); Ok(Default::default()) } @@ -68,7 +77,7 @@ impl Cheatcode for mockCall_1Call { impl Cheatcode for mockCallRevert_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { callee, data, revertData } = self; - mock_call(state, callee, data, None, revertData, InstructionResult::Return); + mock_call(state, callee, data, None, revertData, InstructionResult::Revert); Ok(Default::default()) } } @@ -76,7 +85,7 @@ impl Cheatcode for mockCallRevert_0Call { impl Cheatcode for mockCallRevert_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { callee, msgValue, data, revertData } = self; - mock_call(state, callee, data, Some(msgValue), revertData, InstructionResult::Return); + mock_call(state, callee, data, Some(msgValue), revertData, InstructionResult::Revert); Ok(Default::default()) } } @@ -91,7 +100,7 @@ fn mock_call( ret_type: InstructionResult, ) { state.mocked_calls.entry(*callee).or_default().insert( - MockCallDataContext { calldata: Bytes::copy_from_slice(cdata), value: value.cloned() }, + MockCallDataContext { calldata: Bytes::copy_from_slice(cdata), value: value.copied() }, MockCallReturnData { ret_type, data: Bytes::copy_from_slice(rdata) }, ); } diff --git a/crates/cheatcodes/src/impls/inspector.rs b/crates/cheatcodes/src/impls/inspector.rs index 46faa6fdd86eb..10ba204ff13da 100644 --- a/crates/cheatcodes/src/impls/inspector.rs +++ b/crates/cheatcodes/src/impls/inspector.rs @@ -11,18 +11,21 @@ use super::{ test::expect::{ self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, ExpectedRevert, }, - CheatsCtxt, DatabaseExt, Error, Result, RevertDiagnostic, MAGIC_SKIP_BYTES, -}; -use crate::{ - CheatsConfig, Vm, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, + CheatsCtxt, Error, Result, }; +use crate::{CheatsConfig, Vm}; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_sol_types::{SolInterface, SolValue}; -use ethers::{ - signers::LocalWallet, - types::{transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest}, +use ethers_core::types::{ + transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest, +}; +use ethers_signers::LocalWallet; +use foundry_common::{evm::Breakpoints, RpcUrl}; +use foundry_evm_core::{ + backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, + constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP}, + utils::get_create_address, }; -use foundry_common::RpcUrl; use foundry_utils::types::ToEthers; use itertools::Itertools; use revm::{ @@ -32,7 +35,7 @@ use revm::{ }; use serde_json::Value; use std::{ - collections::{HashMap, VecDeque}, + collections::{BTreeMap, HashMap, VecDeque}, fs::File, io::BufReader, ops::Range, @@ -139,7 +142,8 @@ pub struct Cheatcodes { pub recorded_logs: Option>, /// Mocked calls - pub mocked_calls: HashMap>, + // **Note**: inner must a BTreeMap because of special `Ord` impl for `MockCallDataContext` + pub mocked_calls: HashMap>, /// Expected calls pub expected_calls: ExpectedCallTracker, @@ -165,14 +169,15 @@ pub struct Cheatcodes { /// Test-scoped context holding data that needs to be reset every test run pub context: Context, - /// Commit FS changes such as file creations, writes and deletes. + /// Whether to commit FS changes such as file creations, writes and deletes. /// Used to prevent duplicate changes file executing non-committing calls. pub fs_commit: bool, /// Serialized JSON values. - pub serialized_jsons: HashMap>, + // **Note**: both must a BTreeMap to ensure the order of the keys is deterministic. + pub serialized_jsons: BTreeMap>, - /// Records all eth deals + /// All recorded ETH `deal`s. pub eth_deals: Vec, /// Holds the stored gas info for when we pause gas metering. It is an `Option>` @@ -188,15 +193,14 @@ pub struct Cheatcodes { /// paused and creating new contracts. pub gas_metering_create: Option>, - /// Holds mapping slots info + /// Mapping slots. pub mapping_slots: Option>, - /// current program counter + /// The current program counter. pub pc: usize, /// Breakpoints supplied by the `breakpoint` cheatcode. - /// `char -> pc` - // TODO: don't use ethers address - pub breakpoints: HashMap, + /// `char -> (address, pc)` + pub breakpoints: Breakpoints, } impl Cheatcodes { @@ -253,7 +257,6 @@ impl Cheatcodes { /// /// Cleanup any previously applied cheatcodes that altered the state in such a way that revm's /// revert would run into issues. - #[allow(private_bounds)] // TODO pub fn on_revert(&mut self, data: &mut EVMData<'_, DB>) { trace!(deals = ?self.eth_deals.len(), "rolling back deals"); @@ -583,17 +586,19 @@ impl Inspector for Cheatcodes { // Handle mocked calls if let Some(mocks) = self.mocked_calls.get(&call.contract) { let ctx = MockCallDataContext { - calldata: call.input.clone().0.into(), + calldata: call.input.clone(), value: Some(call.transfer.value), }; - if let Some(mock_retdata) = mocks.get(&ctx) { - return (mock_retdata.ret_type, gas, Bytes(mock_retdata.data.clone().0)) - } else if let Some((_, mock_retdata)) = mocks.iter().find(|(mock, _)| { - mock.calldata.len() <= call.input.len() && - *mock.calldata == call.input[..mock.calldata.len()] && - mock.value.map_or(true, |value| value == call.transfer.value) + if let Some(return_data) = mocks.get(&ctx).or_else(|| { + mocks + .iter() + .find(|(mock, _)| { + call.input.get(..mock.calldata.len()) == Some(&mock.calldata[..]) && + mock.value.map_or(true, |value| value == call.transfer.value) + }) + .map(|(_, v)| v) }) { - return (mock_retdata.ret_type, gas, Bytes(mock_retdata.data.0.clone())) + return (return_data.ret_type, gas, return_data.data.clone()) } } @@ -646,7 +651,6 @@ impl Inspector for Cheatcodes { // because we only need the from, to, value, and data. We can later change this // into 1559, in the cli package, relatively easily once we // know the target chain supports EIP-1559. - #[allow(unused)] // TODO if !call.is_static { if let Err(err) = data.journaled_state.load_account(broadcast.new_origin, data.db) @@ -664,7 +668,7 @@ impl Inspector for Cheatcodes { transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(broadcast.new_origin.to_ethers()), to: Some(NameOrAddress::Address(call.contract.to_ethers())), - value: Some(call.transfer.value).map(|v| v.to_ethers()), + value: Some(call.transfer.value.to_ethers()), data: Some(call.input.clone().0.into()), nonce: Some(account.info.nonce.into()), gas: if is_fixed_gas_limit { @@ -675,11 +679,13 @@ impl Inspector for Cheatcodes { ..Default::default() }), }); + debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable call"); - // call_inner does not increase nonces, so we have to do it ourselves + let prev = account.info.nonce; account.info.nonce += 1; + debug!(target: "cheatcodes", address=%broadcast.new_origin, nonce=prev+1, prev, "incremented nonce"); } else if broadcast.single_call { - let msg = "`staticcall`s are not allowed after `broadcast`; use vm.startBroadcast instead"; + let msg = "`staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead"; return (InstructionResult::Revert, Gas::new(0), Error::encode(msg)) } } @@ -704,7 +710,7 @@ impl Inspector for Cheatcodes { return ( InstructionResult::Revert, remaining_gas, - super::Error::from(MAGIC_SKIP_BYTES).abi_encode().into(), + super::Error::from(MAGIC_SKIP).abi_encode().into(), ) } @@ -784,9 +790,43 @@ impl Inspector for Cheatcodes { } } + // this will ensure we don't have false positives when trying to diagnose reverts in fork + // mode + let diag = self.fork_revert_diagnostic.take(); + + // if there's a revert and a previous call was diagnosed as fork related revert then we can + // return a better error here + if status == InstructionResult::Revert { + if let Some(err) = diag { + return (status, remaining_gas, Error::encode(err.to_error_msg(&self.labels))) + } + } + + // try to diagnose reverts in multi-fork mode where a call is made to an address that does + // not exist + if let TransactTo::Call(test_contract) = data.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 data.db.is_forked_mode() && + status == InstructionResult::Stop && + call.contract != test_contract + { + self.fork_revert_diagnostic = + data.db.diagnose_revert(call.contract, &data.journaled_state); + } + } + // If the depth is 0, then this is the root call terminating if data.journaled_state.depth() == 0 { - // Match expected calls + // If we already have a revert, we shouldn't run the below logic as it can obfuscate an + // earlier error that happened first with unrelated information about + // another error when using cheatcodes. + if status == InstructionResult::Revert { + return (status, remaining_gas, retdata) + } + + // If there's not a revert, we can continue on to run the last logic for expect* + // cheatcodes. Match expected calls for (address, calldatas) in &self.expected_calls { // Loop over each address, and for each address, loop over each calldata it expects. for (calldata, (expected, actual_count)) in calldatas { @@ -848,32 +888,6 @@ impl Inspector for Cheatcodes { } } - // if there's a revert and a previous call was diagnosed as fork related revert then we can - // return a better error here - if status == InstructionResult::Revert { - if let Some(err) = self.fork_revert_diagnostic.take() { - return (status, remaining_gas, Error::encode(err.to_error_msg(self))) - } - } - - // this will ensure we don't have false positives when trying to diagnose reverts in fork - // mode - let _ = self.fork_revert_diagnostic.take(); - - // try to diagnose reverts in multi-fork mode where a call is made to an address that does - // not exist - if let TransactTo::Call(test_contract) = data.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 data.db.is_forked_mode() && - status == InstructionResult::Stop && - call.contract != test_contract - { - self.fork_revert_diagnostic = - data.db.diagnose_revert(call.contract, &data.journaled_state); - } - } - (status, remaining_gas, retdata) } @@ -913,7 +927,6 @@ impl Inspector for Cheatcodes { data.env.tx.caller = broadcast.new_origin; - #[allow(unused)] // TODO if data.journaled_state.depth() == broadcast.depth { let (bytecode, to, nonce) = match process_create( broadcast.new_origin, @@ -945,6 +958,11 @@ impl Inspector for Cheatcodes { ..Default::default() }), }); + let kind = match call.scheme { + CreateScheme::Create => "create", + CreateScheme::Create2 { .. } => "create2", + }; + debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable {kind}"); } } } @@ -1023,17 +1041,16 @@ fn disallowed_mem_write( size, ranges.iter().map(|r| format!("(0x{:02X}, 0x{:02X}]", r.start, r.end)).join(" ∪ ") ) - .abi_encode() - .into(); - mstore_revert_string(revert_string, interpreter); + .abi_encode(); + mstore_revert_string(interpreter, &revert_string); } /// Expands memory, stores a revert string, and sets the return range to the revert /// string's location in memory. -fn mstore_revert_string(bytes: Bytes, interpreter: &mut Interpreter) { +fn mstore_revert_string(interpreter: &mut Interpreter, bytes: &[u8]) { let starting_offset = interpreter.memory.len(); interpreter.memory.resize(starting_offset + bytes.len()); - interpreter.memory.set_data(starting_offset, 0, bytes.len(), &bytes); + interpreter.memory.set_data(starting_offset, 0, bytes.len(), bytes); interpreter.return_offset = starting_offset; interpreter.return_len = interpreter.memory.len() - starting_offset } @@ -1047,16 +1064,18 @@ fn process_create( match call.scheme { CreateScheme::Create => { call.caller = broadcast_sender; - Ok((bytecode, None, data.journaled_state.account(broadcast_sender).info.nonce)) } CreateScheme::Create2 { salt } => { // Sanity checks for our CREATE2 deployer - data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?; - - let info = &data.journaled_state.account(DEFAULT_CREATE2_DEPLOYER).info; - if info.code.is_none() || info.code.as_ref().is_some_and(|code| code.is_empty()) { - return Err(DB::Error::MissingCreate2Deployer) + let info = + &data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?.0.info; + match &info.code { + Some(code) if code.is_empty() => return Err(DatabaseError::MissingCreate2Deployer), + None if data.db.code_by_hash(info.code_hash)?.is_empty() => { + return Err(DatabaseError::MissingCreate2Deployer) + } + _ => {} } call.caller = DEFAULT_CREATE2_DEPLOYER; @@ -1064,12 +1083,13 @@ fn process_create( // We have to increment the nonce of the user address, since this create2 will be done // by the create2_deployer let account = data.journaled_state.state().get_mut(&broadcast_sender).unwrap(); - let nonce = account.info.nonce; + let prev = account.info.nonce; account.info.nonce += 1; + debug!(target: "cheatcodes", address=%broadcast_sender, nonce=prev+1, prev, "incremented nonce in create2"); // Proxy deployer requires the data to be `salt ++ init_code` let calldata = [&salt.to_be_bytes::<32>()[..], &bytecode[..]].concat(); - Ok((calldata.into(), Some(DEFAULT_CREATE2_DEPLOYER), nonce)) + Ok((calldata.into(), Some(DEFAULT_CREATE2_DEPLOYER), prev)) } } } @@ -1087,12 +1107,3 @@ fn check_if_fixed_gas_limit(data: &EVMData<'_, DB>, call_gas_li // gas too low" failure when simulated on chain && call_gas_limit > 2300 } - -fn get_create_address(inputs: &CreateInputs, nonce: u64) -> Address { - match inputs.scheme { - CreateScheme::Create => inputs.caller.create(nonce), - CreateScheme::Create2 { salt } => { - inputs.caller.create2_from_code(salt.to_be_bytes(), &inputs.init_code) - } - } -} diff --git a/crates/cheatcodes/src/impls/json.rs b/crates/cheatcodes/src/impls/json.rs index 8e4510515ca90..41c8e695991ad 100644 --- a/crates/cheatcodes/src/impls/json.rs +++ b/crates/cheatcodes/src/impls/json.rs @@ -207,42 +207,42 @@ impl Cheatcode for serializeBytes_0Call { impl Cheatcode for serializeBool_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + serialize_json(state, objectKey, Some(valueKey), &array_str(values, false)) } } impl Cheatcode for serializeUint_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + serialize_json(state, objectKey, Some(valueKey), &array_str(values, false)) } } impl Cheatcode for serializeInt_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + serialize_json(state, objectKey, Some(valueKey), &array_str(values, false)) } } impl Cheatcode for serializeAddress_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) } } impl Cheatcode for serializeBytes32_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) } } impl Cheatcode for serializeString_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) } } @@ -250,7 +250,7 @@ impl Cheatcode for serializeBytes_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; let values = values.iter().map(hex::encode_prefixed); - serialize_json(state, objectKey, Some(valueKey), &array_str(values)) + serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) } } @@ -379,7 +379,8 @@ fn canonicalize_json_path(path: &str) -> Cow<'_, str> { /// The function is designed to run recursively, so that in case of an object /// it will call itself to convert each of it's value and encode the whole as a /// Tuple -fn value_to_token(value: &Value) -> Result { +#[instrument(target = "cheatcodes", level = "trace", err, ret)] +pub(super) fn value_to_token(value: &Value) -> Result { match value { Value::Null => Ok(DynSolValue::FixedBytes(B256::ZERO, 32)), Value::Bool(boolean) => Ok(DynSolValue::Bool(*boolean)), @@ -479,13 +480,13 @@ fn serialize_json( map.insert(value_key.into(), parsed_value); } else { *map = serde_json::from_str(value) - .map_err(|err| fmt_err!("Failed to parse JSON object: {err}"))?; + .map_err(|err| fmt_err!("failed to parse JSON object: {err}"))?; } let stringified = serde_json::to_string(map).unwrap(); Ok(stringified.abi_encode()) } -fn array_str(values: I) -> String +fn array_str(values: I, quoted: bool) -> String where I: IntoIterator, I::IntoIter: ExactSizeIterator, @@ -498,7 +499,14 @@ where if i > 0 { s.push(','); } + + if quoted { + s.push('"'); + } write!(s, "{item}").unwrap(); + if quoted { + s.push('"'); + } } s.push(']'); s diff --git a/crates/cheatcodes/src/impls/mod.rs b/crates/cheatcodes/src/impls/mod.rs index 2668b3803944a..770016786c4a1 100644 --- a/crates/cheatcodes/src/impls/mod.rs +++ b/crates/cheatcodes/src/impls/mod.rs @@ -2,17 +2,14 @@ use crate::CheatcodeDef; use alloy_primitives::Address; +use foundry_evm_core::backend::DatabaseExt; use revm::EVMData; +use tracing::Level; #[macro_use] mod error; pub use error::{Error, ErrorKind, Result}; -mod db; -pub use db::{ - CreateFork, DatabaseError, DatabaseExt, DatabaseResult, LocalForkId, RevertDiagnostic, -}; - mod config; pub use config::CheatsConfig; @@ -28,7 +25,7 @@ mod string; mod test; mod utils; -pub use test::{expect::ExpectedCallTracker, ASSUME_MAGIC_RETURN_CODE, MAGIC_SKIP_BYTES}; +pub use test::expect::ExpectedCallTracker; /// Cheatcode implementation. pub(crate) trait Cheatcode: CheatcodeDef { @@ -37,7 +34,7 @@ pub(crate) trait Cheatcode: CheatcodeDef { /// Implement this function if you don't need access to the EVM data. fn apply(&self, state: &mut Cheatcodes) -> Result { let _ = state; - unimplemented!("{}", Self::CHEATCODE.id) + unimplemented!("{}", Self::CHEATCODE.func.id) } /// Applies this cheatcode to the given context. @@ -48,18 +45,47 @@ pub(crate) trait Cheatcode: CheatcodeDef { self.apply(ccx.state) } - #[instrument(target = "cheatcodes", name = "apply", level = "trace", skip(ccx), ret)] #[inline] fn apply_traced(&self, ccx: &mut CheatsCtxt) -> Result { - debug!("applying {}", Self::CHEATCODE.id); - self.apply_full(ccx) + let span = trace_span(self); + let _enter = span.enter(); + trace_call(); + let result = self.apply_full(ccx); + trace_return(&result); + result + } +} + +// Separate functions to avoid inline and monomorphization bloat. +fn trace_span(cheat: &T) -> tracing::Span { + if enabled!(Level::TRACE) { + trace_span!(target: "cheatcodes", "apply", cheat=?cheat) + } else { + debug_span!(target: "cheatcodes", "apply", id=%T::CHEATCODE.func.id) } } +fn trace_call() { + trace!(target: "cheatcodes", "applying"); +} + +fn trace_return(result: &Result) { + trace!( + target: "cheatcodes", + return = match result { + Ok(b) => hex::encode(b), + Err(e) => e.to_string(), + } + ); +} + /// The cheatcode context, used in [`Cheatcode`]. pub(crate) struct CheatsCtxt<'a, 'b, 'c, DB: DatabaseExt> { + /// The cheatcodes inspector state. pub(crate) state: &'a mut Cheatcodes, + /// The EVM data. pub(crate) data: &'b mut EVMData<'c, DB>, + /// The original `msg.sender`. pub(crate) caller: Address, } diff --git a/crates/cheatcodes/src/impls/script.rs b/crates/cheatcodes/src/impls/script.rs index 4b533d85e091e..ab1d9347634f3 100644 --- a/crates/cheatcodes/src/impls/script.rs +++ b/crates/cheatcodes/src/impls/script.rs @@ -3,8 +3,9 @@ use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; use crate::Vm::*; use alloy_primitives::{Address, U256}; -use ethers::signers::Signer; +use ethers_signers::Signer; use foundry_config::Config; +use foundry_utils::types::ToAlloy; impl Cheatcode for broadcast_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { @@ -51,8 +52,10 @@ impl Cheatcode for startBroadcast_2Call { impl Cheatcode for stopBroadcastCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - ensure!(ccx.state.broadcast.is_some(), "no broadcast in progress to stop"); - ccx.state.broadcast = None; + let Some(broadcast) = ccx.state.broadcast.take() else { + bail!("no broadcast in progress to stop"); + }; + debug!(target: "cheatcodes", ?broadcast, "stopped"); Ok(Default::default()) } } @@ -85,13 +88,15 @@ fn broadcast( correct_sender_nonce(ccx)?; - ccx.state.broadcast = Some(Broadcast { + let broadcast = Broadcast { new_origin: *new_origin.unwrap_or(&ccx.data.env.tx.caller), - original_origin: ccx.caller, - original_caller: ccx.data.env.tx.caller, + original_caller: ccx.caller, + original_origin: ccx.data.env.tx.caller, depth: ccx.data.journaled_state.depth(), single_call, - }); + }; + debug!(target: "cheatcodes", ?broadcast, "started"); + ccx.state.broadcast = Some(broadcast); Ok(Default::default()) } @@ -104,7 +109,7 @@ fn broadcast_key( single_call: bool, ) -> Result { let wallet = super::utils::parse_wallet(private_key)?.with_chain_id(ccx.data.env.cfg.chain_id); - let new_origin = &wallet.address().0.into(); + let new_origin = &wallet.address().to_alloy(); let result = broadcast(ccx, Some(new_origin), single_call); if result.is_ok() { @@ -117,10 +122,12 @@ fn broadcast_key( /// That leads to its nonce being incremented by `call_raw`. In a `broadcast` scenario this is /// undesirable. Therefore, we make sure to fix the sender's nonce **once**. pub(super) fn correct_sender_nonce(ccx: &mut CheatsCtxt) -> Result<()> { - let caller = ccx.data.env.tx.caller; - if !ccx.state.corrected_nonce && caller.0 != Config::DEFAULT_SENDER.0 { - let account = super::evm::journaled_account(ccx.data, caller)?; - account.info.nonce = account.info.nonce.saturating_sub(1); + let sender = ccx.data.env.tx.caller; + if !ccx.state.corrected_nonce && sender != Config::DEFAULT_SENDER { + let account = super::evm::journaled_account(ccx.data, sender)?; + let prev = account.info.nonce; + account.info.nonce = prev.saturating_sub(1); + debug!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); ccx.state.corrected_nonce = true; } Ok(()) diff --git a/crates/cheatcodes/src/impls/test.rs b/crates/cheatcodes/src/impls/test.rs index ebe2e2f56355d..6e372e86a01bb 100644 --- a/crates/cheatcodes/src/impls/test.rs +++ b/crates/cheatcodes/src/impls/test.rs @@ -1,26 +1,20 @@ //! Implementations of [`Testing`](crate::Group::Testing) cheatcodes. -use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; +use super::{Cheatcode, CheatsCtxt, DatabaseExt, Error, Result}; use crate::{Cheatcodes, Vm::*}; use alloy_primitives::Address; use alloy_sol_types::SolValue; -use foundry_utils::types::ToEthers; +use foundry_evm_core::constants::{MAGIC_ASSUME, MAGIC_SKIP}; pub(crate) mod expect; -/// Magic return value returned by the [`assume` cheatcode](assumeCall). -pub const ASSUME_MAGIC_RETURN_CODE: &[u8] = b"FOUNDRY::ASSUME"; - -/// Magic return value returned by the [`skip` cheatcode](skipCall). -pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; - impl Cheatcode for assumeCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { condition } = self; if *condition { Ok(Default::default()) } else { - Err(ASSUME_MAGIC_RETURN_CODE.into()) + Err(Error::from(MAGIC_ASSUME)) } } } @@ -77,7 +71,7 @@ impl Cheatcode for skipCall { // Since we're not returning the magic skip bytes, this will cause a test failure. ensure!(ccx.data.journaled_state.depth() <= 1, "`skip` can only be used at test level"); ccx.state.skip = true; - Err(MAGIC_SKIP_BYTES.into()) + Err(MAGIC_SKIP.into()) } else { Ok(Default::default()) } @@ -93,7 +87,7 @@ fn breakpoint(state: &mut Cheatcodes, caller: &Address, s: &str, add: bool) -> R ensure!(point.is_alphabetic(), "only alphabetic characters are accepted as breakpoints"); if add { - state.breakpoints.insert(point, (caller.to_ethers(), state.pc)); + state.breakpoints.insert(point, (*caller, state.pc)); } else { state.breakpoints.remove(&point); } diff --git a/crates/cheatcodes/src/impls/test/expect.rs b/crates/cheatcodes/src/impls/test/expect.rs index 218fdd1b9c7e0..4d6cd50a6c2de 100644 --- a/crates/cheatcodes/src/impls/test/expect.rs +++ b/crates/cheatcodes/src/impls/test/expect.rs @@ -287,7 +287,7 @@ fn expect_call( let expecteds = state.expected_calls.entry(*target).or_default(); if let Some(val) = value { - if *val >= U256::ZERO { + if *val > U256::ZERO { // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas // to ensure that the basic fallback function can be called. let positive_value_cost_stipend = 2300; diff --git a/crates/cheatcodes/src/impls/utils.rs b/crates/cheatcodes/src/impls/utils.rs index ec32ff7926f03..d8a4c5a474c79 100644 --- a/crates/cheatcodes/src/impls/utils.rs +++ b/crates/cheatcodes/src/impls/utils.rs @@ -4,19 +4,17 @@ use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; use crate::{Cheatcodes, Vm::*}; use alloy_primitives::{keccak256, B256, U256}; use alloy_sol_types::SolValue; -use ethers::{ - core::k256::{ - ecdsa::SigningKey, - elliptic_curve::{sec1::ToEncodedPoint, Curve}, - Secp256k1, - }, - signers::{ - coins_bip39::{ - ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, - Korean, Portuguese, Spanish, Wordlist, - }, - LocalWallet, MnemonicBuilder, Signer, +use ethers_core::k256::{ + ecdsa::SigningKey, + elliptic_curve::{sec1::ToEncodedPoint, Curve}, + Secp256k1, +}; +use ethers_signers::{ + coins_bip39::{ + ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, + Portuguese, Spanish, Wordlist, }, + LocalWallet, MnemonicBuilder, Signer, }; use foundry_utils::types::{ToAlloy, ToEthers}; @@ -120,7 +118,7 @@ impl Cheatcode for getLabelCall { /// If 'label' is set to 'Some()', assign that label to the associated ETH address in state fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes) -> Result { let key = parse_private_key(private_key)?; - let addr = ethers::utils::secret_key_to_address(&key).0.into(); + let addr = ethers_core::utils::secret_key_to_address(&key).to_alloy(); let pub_key = key.verifying_key().as_affine().to_encoded_point(false); let pub_key_x = U256::from_be_bytes((*pub_key.x().unwrap()).into()); diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 45591a0347580..e11640124f451 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -9,47 +9,18 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{address, Address}; +// Silence the "unused crate" warning. +#[cfg(not(feature = "impls"))] +use alloy_primitives as _; -mod defs; -pub use defs::{Cheatcode, CheatcodeDef, Group, Mutability, Safety, Status, Visibility, Vm}; +pub mod defs; +pub use defs::{Cheatcode, CheatcodeDef, Vm}; #[cfg(feature = "impls")] pub mod impls; #[cfg(feature = "impls")] pub use impls::{Cheatcodes, CheatsConfig}; -/// The cheatcode handler address. -/// -/// This is the same address as the one used in DappTools's HEVM. -/// It is calculated as: -/// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))` -pub const CHEATCODE_ADDRESS: Address = address!("7109709ECfa91a80626fF3989D68f67F5b1DD12D"); - -/// The Hardhat console address. -/// -/// See: -pub const HARDHAT_CONSOLE_ADDRESS: Address = address!("000000000000000000636F6e736F6c652e6c6f67"); - -/// Address of the default `CREATE2` deployer. -pub const DEFAULT_CREATE2_DEPLOYER: Address = address!("4e59b44847b379578588920ca78fbf26c0b4956c"); - -/// Generates the `cheatcodes.json` file contents. -pub fn json_cheatcodes() -> String { - serde_json::to_string_pretty(Vm::CHEATCODES).unwrap() -} - -/// Generates the [cheatcodes](json_cheatcodes) JSON schema. -#[cfg(feature = "schema")] -pub fn json_schema() -> String { - // use a custom type to add a title and description to the schema - /// Foundry cheatcodes. Learn more: - #[derive(schemars::JsonSchema)] - struct Cheatcodes([Cheatcode<'static>]); - - serde_json::to_string_pretty(&schemars::schema_for!(Cheatcodes)).unwrap() -} - #[cfg(test)] mod tests { use super::*; @@ -58,6 +29,32 @@ mod tests { const JSON_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/cheatcodes.json"); #[cfg(feature = "schema")] const SCHEMA_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/cheatcodes.schema.json"); + const IFACE_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata/cheats/Vm.sol"); + + /// Generates the `cheatcodes.json` file contents. + fn json_cheatcodes() -> String { + serde_json::to_string_pretty(&defs::Cheatcodes::new()).unwrap() + } + + /// Generates the [cheatcodes](json_cheatcodes) JSON schema. + #[cfg(feature = "schema")] + fn json_schema() -> String { + serde_json::to_string_pretty(&schemars::schema_for!(defs::Cheatcodes)).unwrap() + } + + fn sol_iface() -> String { + let cheats = defs::Cheatcodes::new().to_string().trim().replace('\n', "\n "); + format!( + "\ +// Automatically generated from `foundry-cheatcodes` Vm definitions. Do not modify manually. +// This interface is just for internal testing purposes. Use `forge-std` instead. + +interface Vm {{ + {cheats} +}} +" + ) + } #[test] fn defs_up_to_date() { @@ -70,6 +67,11 @@ mod tests { ensure_file_contents(Path::new(SCHEMA_PATH), &json_schema()); } + #[test] + fn iface_up_to_date() { + ensure_file_contents(Path::new(IFACE_PATH), &sol_iface()); + } + /// Checks that the `file` has the specified `contents`. If that is not the /// case, updates the file and then fails the test. fn ensure_file_contents(file: &Path, contents: &str) { diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index c03e0147c2803..5c9050615500c 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -292,7 +292,8 @@ impl SessionSource { let executor = ExecutorBuilder::new() .inspectors(|stack| { stack.chisel_state(final_pc).trace(true).cheatcodes( - CheatsConfig::new(&self.config.foundry_config, &self.config.evm_opts).into(), + CheatsConfig::new(&self.config.foundry_config, self.config.evm_opts.clone()) + .into(), ) }) .gas_limit(self.config.evm_opts.gas_limit()) diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index cb0ed68452512..7302ffcfa4287 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -114,14 +114,14 @@ impl ChiselRunner { call_res.map(|res| (address, res)) } - /// Executes the call + /// Executes the call. /// /// This will commit the changes if `commit` is true. /// /// This will return _estimated_ gas instead of the precise gas the call would consume, so it /// can be used as `gas_limit`. /// - /// Taken from [Forge's Script Runner](https://github.com/foundry-rs/foundry/blob/master/cli/src/cmd/forge/script/runner.rs) + /// Taken from Forge's script runner. fn call( &mut self, from: Address, diff --git a/crates/evm/core/src/backend/diagnostic.rs b/crates/evm/core/src/backend/diagnostic.rs index 1e2b0b0d26672..0dc788e830583 100644 --- a/crates/evm/core/src/backend/diagnostic.rs +++ b/crates/evm/core/src/backend/diagnostic.rs @@ -1,7 +1,7 @@ use crate::backend::LocalForkId; use alloy_primitives::Address; use itertools::Itertools; -use std::collections::BTreeMap; +use std::collections::HashMap; /// Represents possible diagnostic cases on revert #[derive(Debug, Clone)] @@ -21,7 +21,7 @@ pub enum RevertDiagnostic { impl RevertDiagnostic { /// Converts the diagnostic to a readable error message - pub fn to_error_msg(&self, labels: &BTreeMap) -> String { + pub fn to_error_msg(&self, labels: &HashMap) -> String { let get_label = |addr: &Address| labels.get(addr).cloned().unwrap_or_else(|| addr.to_string()); diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index 209ecf4b01ef0..7a13fda50d665 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -1,10 +1,8 @@ use alloy_primitives::{Address, B256, U256}; use ethers::types::BlockId; -use foundry_utils::error::SolError; use futures::channel::mpsc::{SendError, TrySendError}; use std::{ convert::Infallible, - fmt, sync::{mpsc::RecvError, Arc}, }; @@ -13,37 +11,41 @@ pub type DatabaseResult = Result; /// Errors that can happen when working with [`revm::Database`] #[derive(Debug, thiserror::Error)] +#[allow(missing_docs)] pub enum DatabaseError { - #[error("Failed to fetch AccountInfo {0:?}")] + #[error("{0}")] + Message(String), + #[error("no cheats available for {0}")] + NoCheats(Address), + #[error("failed to fetch AccountInfo {0}")] MissingAccount(Address), - #[error("Could should already be loaded: {0:?}")] + #[error("code should already be loaded: {0}")] MissingCode(B256), #[error(transparent)] Recv(#[from] RecvError), #[error(transparent)] Send(#[from] SendError), - #[error("{0}")] - Message(String), - #[error("Failed to get account for {0:?}: {0:?}")] + #[error("failed to get account for {0}: {1}")] GetAccount(Address, Arc), - #[error("Failed to get storage for {0:?} at {1:?}: {2:?}")] + #[error("failed to get storage for {0} at {1}: {2}")] GetStorage(Address, U256, Arc), - #[error("Failed to get block hash for {0}: {1:?}")] + #[error("failed to get block hash for {0}: {1}")] GetBlockHash(u64, Arc), - #[error("Failed to get full block for {0:?}: {1:?}")] + #[error("failed to get full block for {0:?}: {1}")] GetFullBlock(BlockId, Arc), - #[error("Block {0:?} does not exist")] + #[error("block {0:?} does not exist")] BlockNotFound(BlockId), - #[error("Failed to get transaction {0:?}: {1:?}")] + #[error("failed to get transaction {0}: {1}")] GetTransaction(B256, Arc), - #[error("Transaction {0:?} not found")] + #[error("transaction {0} not found")] TransactionNotFound(B256), #[error( - "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n\nFor a production environment, you can deploy it using the pre-signed transaction from https://github.com/Arachnid/deterministic-deployment-proxy.\n\nFor a test environment, you can use vm.etch to place the required bytecode at that address." + "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n\ + For a production environment, you can deploy it using the pre-signed transaction from \ + https://github.com/Arachnid/deterministic-deployment-proxy.\n\ + For a test environment, you can use `etch` to place the required bytecode at that address." )] MissingCreate2Deployer, - #[error(transparent)] - JoinError(#[from] tokio::task::JoinError), } impl DatabaseError { @@ -52,6 +54,11 @@ impl DatabaseError { DatabaseError::Message(msg.into()) } + /// Create a new error with a message + pub fn display(msg: impl std::fmt::Display) -> Self { + DatabaseError::Message(msg.to_string()) + } + fn get_rpc_error(&self) -> Option<&eyre::Error> { match self { Self::GetAccount(_, err) => Some(err), @@ -60,6 +67,7 @@ impl DatabaseError { Self::GetFullBlock(_, err) => Some(err), Self::GetTransaction(_, err) => Some(err), // Enumerate explicitly to make sure errors are updated if a new one is added. + Self::NoCheats(_) | Self::MissingAccount(_) | Self::MissingCode(_) | Self::Recv(_) | @@ -67,8 +75,7 @@ impl DatabaseError { Self::Message(_) | Self::BlockNotFound(_) | Self::TransactionNotFound(_) | - Self::MissingCreate2Deployer | - Self::JoinError(_) => None, + Self::MissingCreate2Deployer => None, } } @@ -83,32 +90,20 @@ impl DatabaseError { } } -impl SolError for DatabaseError {} - -impl From> for DatabaseError { - fn from(err: TrySendError) -> Self { - err.into_send_error().into() +impl From for DatabaseError { + fn from(value: tokio::task::JoinError) -> Self { + DatabaseError::display(value) } } -impl From for DatabaseError { - fn from(never: Infallible) -> Self { - match never {} +impl From> for DatabaseError { + fn from(value: TrySendError) -> Self { + value.into_send_error().into() } } -/// Error thrown when the address is not allowed to execute cheatcodes -/// -/// See also [`DatabaseExt`](crate::DatabaseExt) -#[derive(Debug, Clone, Copy)] -pub struct NoCheatcodeAccessError(pub Address); - -impl fmt::Display for NoCheatcodeAccessError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "No cheatcode access granted for: {}, see `vm.allowCheatcodes()`", self.0) +impl From for DatabaseError { + fn from(value: Infallible) -> Self { + match value {} } } - -impl std::error::Error for NoCheatcodeAccessError {} - -impl SolError for NoCheatcodeAccessError {} diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index 12d0f6ce781ed..084f8c6e2eccb 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -168,7 +168,7 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: I, + inspector: &mut I, ) -> eyre::Result<()> { trace!(?id, ?transaction, "fuzz: execute transaction"); self.backend_mut(env).transact(id, transaction, env, journaled_state, inspector) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 9e4e6b605c5b1..59b45906c7184 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -35,7 +35,7 @@ mod diagnostic; pub use diagnostic::RevertDiagnostic; mod error; -pub use error::{DatabaseError, DatabaseResult, NoCheatcodeAccessError}; +pub use error::{DatabaseError, DatabaseResult}; mod fuzz; pub use fuzz::FuzzBackendWrapper; @@ -187,7 +187,7 @@ pub trait DatabaseExt: Database { transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: I, + inspector: &mut I, ) -> eyre::Result<()>; /// Returns the `ForkId` that's currently used in the database, if fork mode is on @@ -287,19 +287,16 @@ pub trait DatabaseExt: Database { /// Ensures that `account` is allowed to execute cheatcodes /// /// Returns an error if [`Self::has_cheatcode_access`] returns `false` - fn ensure_cheatcode_access(&self, account: Address) -> Result<(), NoCheatcodeAccessError> { + fn ensure_cheatcode_access(&self, account: Address) -> Result<(), DatabaseError> { if !self.has_cheatcode_access(account) { - return Err(NoCheatcodeAccessError(account)) + return Err(DatabaseError::NoCheats(account)) } Ok(()) } /// Same as [`Self::ensure_cheatcode_access()`] but only enforces it if the backend is currently /// in forking mode - fn ensure_cheatcode_access_forking_mode( - &self, - account: Address, - ) -> Result<(), NoCheatcodeAccessError> { + fn ensure_cheatcode_access_forking_mode(&self, account: Address) -> Result<(), DatabaseError> { if self.is_forked_mode() { return self.ensure_cheatcode_access(account) } @@ -1176,7 +1173,7 @@ impl DatabaseExt for Backend { transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: I, + inspector: &mut I, ) -> eyre::Result<()> { trace!(?maybe_id, ?transaction, "execute transaction"); let id = self.ensure_fork(maybe_id)?; diff --git a/crates/evm/core/src/constants.rs b/crates/evm/core/src/constants.rs index 55a0458ed0649..3e8941d278585 100644 --- a/crates/evm/core/src/constants.rs +++ b/crates/evm/core/src/constants.rs @@ -24,10 +24,10 @@ pub const CALLER: Address = address!("1804c8AB1F12E6bbf3894d4083f33e07309d1f38") pub const TEST_CONTRACT_ADDRESS: Address = address!("b4c79daB8f259C7Aee6E5b2Aa729821864227e84"); /// Magic return value returned by the `assume` cheatcode. -pub const ASSUME_MAGIC_RETURN_CODE: &[u8] = b"FOUNDRY::ASSUME"; +pub const MAGIC_ASSUME: &[u8] = b"FOUNDRY::ASSUME"; /// Magic return value returned by the `skip` cheatcode. -pub const MAGIC_SKIP_BYTES: &[u8] = b"FOUNDRY::SKIP"; +pub const MAGIC_SKIP: &[u8] = b"FOUNDRY::SKIP"; /// The default CREATE2 deployer. pub const DEFAULT_CREATE2_DEPLOYER: Address = address!("4e59b44847b379578588920ca78fbf26c0b4956c"); diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index d490617e5f3ce..7e3af7a217ae4 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -1,6 +1,6 @@ //! Various utilities to decode test results. -use crate::constants::MAGIC_SKIP_BYTES; +use crate::constants::MAGIC_SKIP; use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; use alloy_json_abi::JsonAbi; use alloy_primitives::{B256, U256}; @@ -8,7 +8,7 @@ use alloy_sol_types::{sol_data::String as SolString, SolType}; use ethers::{abi::RawLog, contract::EthLogDecode, types::Log}; use foundry_abi::console::ConsoleEvents::{self, *}; use foundry_common::{abi::format_token, SELECTOR_LEN}; -use foundry_utils::error::ERROR_PREFIX; +use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; use itertools::Itertools; use once_cell::sync::Lazy; use revm::interpreter::{return_ok, InstructionResult}; @@ -18,6 +18,7 @@ use thiserror::Error; pub fn decode_console_logs(logs: &[Log]) -> Vec { logs.iter().filter_map(decode_console_log).collect() } + /// Decode a single log. /// /// This function returns [None] if it is not a DSTest log or the result of a Hardhat @@ -100,7 +101,8 @@ pub fn decode_revert( } return Err(RevertDecodingError::InsufficientErrorData) } - match err[..SELECTOR_LEN] { + + match <[u8; SELECTOR_LEN]>::try_from(&err[..SELECTOR_LEN]).unwrap() { // keccak(Panic(uint256)) [78, 72, 123, 113] => { // ref: https://soliditydeveloper.com/solidity-0.8 @@ -144,13 +146,18 @@ pub fn decode_revert( _ => Err(RevertDecodingError::UnsupportedSolidityBuiltinPanic), } } - // keccak(Error(string)) - [8, 195, 121, 160] => DynSolType::abi_decode(&DynSolType::String, &err[SELECTOR_LEN..]) - .map_err(RevertDecodingError::AlloyDecodingError) - .and_then(|v| { - v.clone().as_str().map(|s| s.to_owned()).ok_or(RevertDecodingError::BadStringDecode) - }) - .to_owned(), + // keccak(Error(string)) | keccak(CheatcodeError(string)) + REVERT_PREFIX | ERROR_PREFIX => { + DynSolType::abi_decode(&DynSolType::String, &err[SELECTOR_LEN..]) + .map_err(RevertDecodingError::AlloyDecodingError) + .and_then(|v| { + v.clone() + .as_str() + .map(|s| s.to_owned()) + .ok_or(RevertDecodingError::BadStringDecode) + }) + .to_owned() + } // keccak(expectRevert(bytes)) [242, 141, 206, 179] => { let err_data = &err[SELECTOR_LEN..]; @@ -185,7 +192,7 @@ pub fn decode_revert( } _ => { // See if the revert is caused by a skip() call. - if err == MAGIC_SKIP_BYTES { + if err == MAGIC_SKIP { return Ok("SKIPPED".to_string()) } // try to decode a custom error if provided an abi @@ -217,21 +224,6 @@ pub fn decode_revert( let error = error.filter(|err| err.as_str() != ""); error - .or_else(|| { - // try decoding as cheatcode error - if err.starts_with(ERROR_PREFIX.as_slice()) { - DynSolType::abi_decode(&DynSolType::String, &err[ERROR_PREFIX.len()..]) - .map_err(|_| RevertDecodingError::UnknownCheatcodeErrorString) - .and_then(|v| { - v.as_str() - .map(|s| s.to_owned()) - .ok_or(RevertDecodingError::UnknownCheatcodeErrorString) - }) - .ok() - } else { - None - } - }) .or_else(|| { // try decoding as unknown err SolString::abi_decode(&err[SELECTOR_LEN..], false) diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 10b85e7538eea..4bcf679476d74 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -11,8 +11,7 @@ homepage.workspace = true repository.workspace = true [dependencies] -foundry-abi.workspace = true -# foundry-cheatcodes.workspace = true +foundry-cheatcodes = { workspace = true, features = ["impls"] } foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true @@ -38,16 +37,9 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } -bytes = "1.5" eyre = "0.6" hex.workspace = true -itertools.workspace = true -jsonpath_lib = "0.3" -once_cell = "1" parking_lot = "0.12" proptest = "1" -serde = "1" -serde_json = "1" thiserror = "1" tracing = "0.1" -walkdir = "2" diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 3e71c95bd6e4e..56befa64a5d07 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -5,7 +5,7 @@ use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_config::FuzzConfig; use foundry_evm_core::{ - constants::ASSUME_MAGIC_RETURN_CODE, + constants::MAGIC_ASSUME, decode::{self, decode_console_logs}, }; use foundry_evm_coverage::HitMaps; @@ -210,8 +210,8 @@ impl<'a> FuzzedExecutor<'a> { &self.config.dictionary, ); - // When assume cheat code is triggered return a special string "FOUNDRY::ASSUME" - if call.result.as_ref() == ASSUME_MAGIC_RETURN_CODE { + // When the `assume` cheatcode is called it returns a special string + if call.result.as_ref() == MAGIC_ASSUME { return Err(TestCaseError::reject(FuzzError::AssumeReject)) } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 80a0418d3b819..f13f6d5711858 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -7,7 +7,7 @@ // the concrete `Executor` type. use crate::inspectors::{ - cheatcodes::util::BroadcastableTransactions, Cheatcodes, InspectorData, InspectorStack, + cheatcodes::BroadcastableTransactions, Cheatcodes, InspectorData, InspectorStack, }; use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi as Abi}; @@ -328,6 +328,7 @@ impl Executor { if let Some(cheats) = cheatcodes.as_mut() { // Clear broadcastable transactions cheats.broadcastable_transactions.clear(); + debug!(target: "evm::executors", "cleared broadcastable transactions"); // corrected_nonce value is needed outside of this context (setUp), so we don't // reset it. diff --git a/crates/evm/evm/src/inspectors/cheatcodes/config.rs b/crates/evm/evm/src/inspectors/cheatcodes/config.rs deleted file mode 100644 index fffb65febd3f9..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/config.rs +++ /dev/null @@ -1,200 +0,0 @@ -use super::{ensure, fmt_err, Result}; -use foundry_common::fs::normalize_path; -use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; -use foundry_config::{ - cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, - ResolvedRpcEndpoints, -}; -use foundry_evm_core::opts::EvmOpts; -use std::path::{Path, PathBuf}; - -/// Additional, configurable context the `Cheatcodes` inspector has access to -/// -/// This is essentially a subset of various `Config` settings `Cheatcodes` needs to know. -#[derive(Debug, Clone)] -pub struct CheatsConfig { - pub ffi: bool, - /// RPC storage caching settings determines what chains and endpoints to cache - pub rpc_storage_caching: StorageCachingConfig, - /// All known endpoints and their aliases - pub rpc_endpoints: ResolvedRpcEndpoints, - /// Project's paths as configured - pub paths: ProjectPathsConfig, - /// Filesystem permissions for cheatcodes like `writeFile`, `readFile` - pub fs_permissions: FsPermissions, - /// Project root - pub root: PathBuf, - /// Paths (directories) where file reading/writing is allowed - pub allowed_paths: Vec, - /// How the evm was configured by the user - pub evm_opts: EvmOpts, -} - -// === impl CheatsConfig === - -impl CheatsConfig { - /// Extracts the necessary settings from the Config - pub fn new(config: &Config, evm_opts: &EvmOpts) -> Self { - let mut allowed_paths = vec![config.__root.0.clone()]; - allowed_paths.extend(config.libs.clone()); - allowed_paths.extend(config.allow_paths.clone()); - - let rpc_endpoints = config.rpc_endpoints.clone().resolved(); - trace!(?rpc_endpoints, "using resolved rpc endpoints"); - - Self { - ffi: evm_opts.ffi, - rpc_storage_caching: config.rpc_storage_caching.clone(), - rpc_endpoints, - paths: config.project_paths(), - fs_permissions: config.fs_permissions.clone().joined(&config.__root), - root: config.__root.0.clone(), - allowed_paths, - evm_opts: evm_opts.clone(), - } - } - - /// Attempts to canonicalize (see [std::fs::canonicalize]) the path. - /// - /// Canonicalization fails for non-existing paths, in which case we just normalize the path. - pub fn normalized_path(&self, path: impl AsRef) -> PathBuf { - let path = self.root.join(path); - canonicalize(&path).unwrap_or_else(|_| normalize_path(&path)) - } - - /// Returns true if the given path is allowed, if any path `allowed_paths` is an ancestor of the - /// path - /// - /// We only allow paths that are inside allowed paths. To prevent path traversal - /// ("../../etc/passwd") we canonicalize/normalize the path first. We always join with the - /// configured root directory. - pub fn is_path_allowed(&self, path: impl AsRef, kind: FsAccessKind) -> bool { - self.is_normalized_path_allowed(&self.normalized_path(path), kind) - } - - fn is_normalized_path_allowed(&self, path: &Path, kind: FsAccessKind) -> bool { - self.fs_permissions.is_path_allowed(path, kind) - } - - /// Returns an error if no access is granted to access `path`, See also [Self::is_path_allowed] - /// - /// Returns the normalized version of `path`, see [`CheatsConfig::normalized_path`] - pub fn ensure_path_allowed( - &self, - path: impl AsRef, - kind: FsAccessKind, - ) -> Result { - let path = path.as_ref(); - let normalized = self.normalized_path(path); - ensure!( - self.is_normalized_path_allowed(&normalized, kind), - "The path {path:?} is not allowed to be accessed for {kind} operations." - ); - Ok(normalized) - } - - /// Returns true if the given `path` is the project's foundry.toml file - /// - /// Note: this should be called with normalized path - pub fn is_foundry_toml(&self, path: impl AsRef) -> bool { - // path methods that do not access the filesystem are such as [`Path::starts_with`], are - // case-sensitive no matter the platform or filesystem. to make this case-sensitive - // we convert the underlying `OssStr` to lowercase checking that `path` and - // `foundry.toml` are the same file by comparing the FD, because it may not exist - let foundry_toml = self.root.join(Config::FILE_NAME); - Path::new(&foundry_toml.to_string_lossy().to_lowercase()) - .starts_with(Path::new(&path.as_ref().to_string_lossy().to_lowercase())) - } - - /// Same as [`Self::is_foundry_toml`] but returns an `Err` if [`Self::is_foundry_toml`] returns - /// true - pub fn ensure_not_foundry_toml(&self, path: impl AsRef) -> Result<()> { - ensure!(!self.is_foundry_toml(path), "Access to foundry.toml is not allowed."); - Ok(()) - } - - /// Returns the RPC to use - /// - /// If `url_or_alias` is a known alias in the `ResolvedRpcEndpoints` then it returns the - /// corresponding URL of that alias. otherwise this assumes `url_or_alias` is itself a URL - /// if it starts with a `http` or `ws` scheme - /// - /// # Errors - /// - /// - Returns an error if `url_or_alias` is a known alias but references an unresolved env var. - /// - Returns an error if `url_or_alias` is not an alias but does not start with a `http` or - /// `scheme` - pub fn get_rpc_url(&self, url_or_alias: impl Into) -> Result { - let url_or_alias = url_or_alias.into(); - match self.rpc_endpoints.get(&url_or_alias) { - Some(Ok(url)) => Ok(url.clone()), - Some(Err(err)) => { - // try resolve again, by checking if env vars are now set - err.try_resolve().map_err(Into::into) - } - None => { - if !url_or_alias.starts_with("http") && !url_or_alias.starts_with("ws") { - Err(fmt_err!("invalid rpc url {url_or_alias}")) - } else { - Ok(url_or_alias) - } - } - } - } -} - -impl Default for CheatsConfig { - fn default() -> Self { - Self { - ffi: false, - rpc_storage_caching: Default::default(), - rpc_endpoints: Default::default(), - paths: ProjectPathsConfig::builder().build_with_root("./"), - fs_permissions: Default::default(), - root: Default::default(), - allowed_paths: vec![], - evm_opts: Default::default(), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use foundry_config::fs_permissions::PathPermission; - - fn config(root: &str, fs_permissions: FsPermissions) -> CheatsConfig { - CheatsConfig::new( - &Config { __root: PathBuf::from(root).into(), fs_permissions, ..Default::default() }, - &Default::default(), - ) - } - - #[test] - fn test_allowed_paths() { - let root = "/my/project/root/"; - let config = config(root, FsPermissions::new(vec![PathPermission::read_write("./")])); - - assert!(config.ensure_path_allowed("./t.txt", FsAccessKind::Read).is_ok()); - assert!(config.ensure_path_allowed("./t.txt", FsAccessKind::Write).is_ok()); - assert!(config.ensure_path_allowed("../root/t.txt", FsAccessKind::Read).is_ok()); - assert!(config.ensure_path_allowed("../root/t.txt", FsAccessKind::Write).is_ok()); - assert!(config.ensure_path_allowed("../../root/t.txt", FsAccessKind::Read).is_err()); - assert!(config.ensure_path_allowed("../../root/t.txt", FsAccessKind::Write).is_err()); - } - - #[test] - fn test_is_foundry_toml() { - let root = "/my/project/root/"; - let config = config(root, FsPermissions::new(vec![PathPermission::read_write("./")])); - - let f = format!("{root}foundry.toml"); - assert!(config.is_foundry_toml(f)); - - let f = format!("{root}Foundry.toml"); - assert!(config.is_foundry_toml(f)); - - let f = format!("{root}lib/other/foundry.toml"); - assert!(!config.is_foundry_toml(f)); - } -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/env.rs b/crates/evm/evm/src/inspectors/cheatcodes/env.rs deleted file mode 100644 index 6137fc645507c..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/env.rs +++ /dev/null @@ -1,758 +0,0 @@ -use super::{ - ensure, fmt_err, - mapping::{get_mapping_key_and_parent, get_mapping_length, get_mapping_slot_at}, - util::{is_potential_precompile, with_journaled_account}, - Cheatcodes, DealRecord, Result, -}; -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{Address, Bytes, Log, B256, U256}; -use ethers::signers::{LocalWallet, Signer}; -use foundry_config::Config; -use foundry_evm_core::{abi::HEVMCalls, backend::DatabaseExt}; -use foundry_utils::types::ToAlloy; -use revm::{ - primitives::{Bytecode, SpecId, KECCAK_EMPTY}, - Database, EVMData, -}; -use std::collections::BTreeMap; - -#[derive(Clone, Debug, Default)] -pub struct Broadcast { - /// Address of the transaction origin - pub new_origin: Address, - /// Original caller - pub original_caller: Address, - /// Original `tx.origin` - pub original_origin: Address, - /// Depth of the broadcast - pub depth: u64, - /// Whether the prank stops by itself after the next call - pub single_call: bool, -} - -#[derive(Clone, Debug, Default)] -pub struct Prank { - /// Address of the contract that initiated the prank - pub prank_caller: Address, - /// Address of `tx.origin` when the prank was initiated - pub prank_origin: Address, - /// The address to assign to `msg.sender` - pub new_caller: Address, - /// The address to assign to `tx.origin` - pub new_origin: Option
, - /// The depth at which the prank was called - pub depth: u64, - /// Whether the prank stops by itself after the next call - pub single_call: bool, - /// Whether the prank has been used yet (false if unused) - pub used: bool, -} - -impl Prank { - pub fn new( - prank_caller: Address, - prank_origin: Address, - new_caller: Address, - new_origin: Option
, - depth: u64, - single_call: bool, - ) -> Prank { - Prank { - prank_caller, - prank_origin, - new_caller, - new_origin, - depth, - single_call, - used: false, - } - } - - /// Apply the prank by setting `used` to true iff it is false - /// Only returns self in the case it is updated (first application) - pub fn first_time_applied(&self) -> Option { - if self.used { - None - } else { - Some(Prank { used: true, ..self.clone() }) - } - } -} - -/// Represents the possible caller modes for the readCallers() cheat code return value -enum CallerMode { - /// No caller modification is currently active - None, - /// A one time broadcast triggered by a `vm.broadcast()` call is currently active - Broadcast, - /// A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active - RecurrentBroadcast, - /// A one time prank triggered by a `vm.prank()` call is currently active - Prank, - /// A recurrent prank triggered by a `vm.startPrank()` call is currently active - RecurrentPrank, -} - -impl From for U256 { - fn from(value: CallerMode) -> Self { - U256::from(value as u8) - } -} - -/// Sets up broadcasting from a script using `origin` as the sender -fn broadcast( - state: &mut Cheatcodes, - new_origin: Address, - original_caller: Address, - original_origin: Address, - depth: u64, - single_call: bool, -) -> Result { - ensure!( - state.prank.is_none(), - "You have an active prank. Broadcasting and pranks are not compatible. \ - Disable one or the other" - ); - ensure!(state.broadcast.is_none(), "You have an active broadcast already."); - - let broadcast = Broadcast { new_origin, original_origin, original_caller, depth, single_call }; - state.broadcast = Some(broadcast); - Ok(Bytes::new()) -} - -/// Sets up broadcasting from a script with the sender derived from `private_key` -/// Adds this private key to `state`'s `script_wallets` vector to later be used for signing -/// iff broadcast is successful -fn broadcast_key( - state: &mut Cheatcodes, - private_key: U256, - original_caller: Address, - original_origin: Address, - chain_id: U256, - depth: u64, - single_call: bool, -) -> Result { - let key = super::util::parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.to::()); - let new_origin = wallet.address(); - - let result = broadcast( - state, - new_origin.to_alloy(), - original_caller, - original_origin, - depth, - single_call, - ); - if result.is_ok() { - state.script_wallets.push(wallet); - } - result -} - -fn prank( - state: &mut Cheatcodes, - prank_caller: Address, - prank_origin: Address, - new_caller: Address, - new_origin: Option
, - depth: u64, - single_call: bool, -) -> Result { - let prank = Prank::new(prank_caller, prank_origin, new_caller, new_origin, depth, single_call); - - if let Some(Prank { used, single_call: current_single_call, .. }) = state.prank { - ensure!(used, "You cannot overwrite `prank` until it is applied at least once"); - // This case can only fail if the user calls `vm.startPrank` and then `vm.prank` later on. - // This should not be possible without first calling `stopPrank` - ensure!(single_call == current_single_call, "You cannot override an ongoing prank with a single vm.prank. Use vm.startPrank to override the current prank."); - } - - ensure!( - state.broadcast.is_none(), - "You cannot `prank` for a broadcasted transaction.\ - Pass the desired tx.origin into the broadcast cheatcode call" - ); - - state.prank = Some(prank); - Ok(Bytes::new()) -} - -/// Reads the current caller information and returns the current [CallerMode], `msg.sender` and -/// `tx.origin`. -/// -/// Depending on the current caller mode, one of the following results will be returned: -/// - If there is an active prank: -/// - caller_mode will be equal to: -/// - [CallerMode::Prank] if the prank has been set with `vm.prank(..)`. -/// - [CallerMode::RecurrentPrank] if the prank has been set with `vm.startPrank(..)`. -/// - `msg.sender` will be equal to the address set for the prank. -/// - `tx.origin` will be equal to the default sender address unless an alternative one has been -/// set when configuring the prank. -/// -/// - If there is an active broadcast: -/// - caller_mode will be equal to: -/// - [CallerMode::Broadcast] if the broadcast has been set with `vm.broadcast(..)`. -/// - [CallerMode::RecurrentBroadcast] if the broadcast has been set with -/// `vm.startBroadcast(..)`. -/// - `msg.sender` and `tx.origin` will be equal to the address provided when setting the -/// broadcast. -/// -/// - If no caller modification is active: -/// - caller_mode will be equal to [CallerMode::None], -/// - `msg.sender` and `tx.origin` will be equal to the default sender address. -fn read_callers(state: &Cheatcodes, default_sender: Address) -> Bytes { - let Cheatcodes { prank, broadcast, .. } = &state; - - let data = if let Some(prank) = prank { - let caller_mode = - if prank.single_call { CallerMode::Prank } else { CallerMode::RecurrentPrank }; - - vec![ - DynSolValue::Uint(caller_mode.into(), 256), - DynSolValue::Address(prank.new_caller), - DynSolValue::Address(prank.new_origin.unwrap_or(default_sender)), - ] - } else if let Some(broadcast) = broadcast { - let caller_mode = if broadcast.single_call { - CallerMode::Broadcast - } else { - CallerMode::RecurrentBroadcast - }; - - vec![ - DynSolValue::Uint(caller_mode.into(), 256), - DynSolValue::Address(broadcast.new_origin), - DynSolValue::Address(broadcast.new_origin), - ] - } else { - vec![ - DynSolValue::Uint(CallerMode::None.into(), 256), - DynSolValue::Address(default_sender), - DynSolValue::Address(default_sender), - ] - }; - - DynSolValue::Tuple(data).abi_encode().into() -} - -#[derive(Clone, Debug, Default)] -pub struct RecordAccess { - pub reads: BTreeMap>, - pub writes: BTreeMap>, -} - -fn start_record(state: &mut Cheatcodes) { - state.accesses = Some(Default::default()); -} - -fn accesses(state: &mut Cheatcodes, address: Address) -> Bytes { - if let Some(storage_accesses) = &mut state.accesses { - let write_accesses: Vec = storage_accesses - .writes - .entry(address) - .or_default() - .iter_mut() - .map(|u| DynSolValue::FixedBytes(u.to_owned().into(), 32)) - .collect(); - let read_accesses = storage_accesses - .reads - .entry(address) - .or_default() - .iter_mut() - .map(|u| DynSolValue::FixedBytes(u.to_owned().into(), 32)) - .collect(); - DynSolValue::Tuple(vec![ - DynSolValue::Array(read_accesses), - DynSolValue::Array(write_accesses), - ]) - .abi_encode_params() - .into() - } else { - DynSolValue::Tuple(vec![DynSolValue::Array(vec![]), DynSolValue::Array(vec![])]) - .abi_encode_params() - .into() - } -} - -#[derive(Clone, Debug, Default)] -pub struct RecordedLogs { - pub entries: Vec, -} - -#[derive(Clone, Debug)] -pub struct RecordedLog { - pub emitter: Address, - pub inner: Log, -} - -fn start_record_logs(state: &mut Cheatcodes) { - state.recorded_logs = Some(Default::default()); -} - -fn get_recorded_logs(state: &mut Cheatcodes) -> Bytes { - if let Some(recorded_logs) = state.recorded_logs.replace(Default::default()) { - DynSolValue::Array( - recorded_logs - .entries - .iter() - .map(|entry| { - DynSolValue::Tuple(vec![ - DynSolValue::Array( - entry - .inner - .topics() - .iter() - .map(|t| DynSolValue::FixedBytes(*t, 32)) - .collect(), - ), - DynSolValue::Bytes(entry.inner.data.clone().to_vec()), - DynSolValue::Address(entry.emitter), - ]) - }) - .collect::>(), - ) - .abi_encode() - .into() - } else { - DynSolValue::Array(vec![]).abi_encode().into() - } -} - -/// Entry point of the breakpoint cheatcode. Adds the called breakpoint to the state. -fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: bool) -> Result { - let mut chars = inner.chars(); - let point = chars.next(); - - let point = - point.ok_or_else(|| fmt_err!("Please provide at least one char for the breakpoint"))?; - - ensure!(chars.next().is_none(), "Provide only one character for the breakpoint"); - ensure!(point.is_alphabetic(), "Only alphabetic characters are accepted as breakpoints"); - - // add a breakpoint from the interpreter - if add { - state.breakpoints.insert(point, (caller, state.pc)); - } else { - state.breakpoints.remove(&point); - } - - Ok(Bytes::new()) -} - -// mark the slots of an account and the account address as cold -fn cool_account(data: &mut EVMData<'_, DB>, address: Address) -> Result { - if let Some(account) = data.journaled_state.state.get_mut(&address) { - if account.is_touched() { - account.unmark_touch(); - } - account.storage.clear(); - } - - Ok(Bytes::new()) -} - -#[instrument(level = "error", name = "env", target = "evm::cheatcodes", skip_all)] -pub fn apply( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - caller: Address, - call: &HEVMCalls, -) -> Result> { - let result = match call { - HEVMCalls::Warp(inner) => { - data.env.block.timestamp = inner.0.to_alloy(); - Bytes::new() - } - HEVMCalls::Difficulty(inner) => { - ensure!( - data.env.cfg.spec_id < SpecId::MERGE, - "`difficulty` is not supported after the Paris hard fork, \ - use `prevrandao` instead. \ - For more information, please see https://eips.ethereum.org/EIPS/eip-4399" - ); - data.env.block.difficulty = inner.0.to_alloy(); - Bytes::new() - } - HEVMCalls::Prevrandao(inner) => { - ensure!( - data.env.cfg.spec_id >= SpecId::MERGE, - "`prevrandao` is not supported before the Paris hard fork, \ - use `difficulty` instead. \ - For more information, please see https://eips.ethereum.org/EIPS/eip-4399" - ); - data.env.block.prevrandao = Some(B256::from(inner.0)); - Bytes::new() - } - HEVMCalls::Roll(inner) => { - data.env.block.number = inner.0.to_alloy(); - Bytes::new() - } - HEVMCalls::Fee(inner) => { - data.env.block.basefee = inner.0.to_alloy(); - Bytes::new() - } - HEVMCalls::Coinbase(inner) => { - data.env.block.coinbase = inner.0.to_alloy(); - Bytes::new() - } - HEVMCalls::Store(inner) => { - ensure!(!is_potential_precompile(inner.0.to_alloy()), "Store cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); - data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; - // ensure the account is touched - data.journaled_state.touch(&inner.0.to_alloy()); - - data.journaled_state.sstore( - inner.0.to_alloy(), - U256::from_be_bytes(inner.1), - U256::from_be_bytes(inner.2), - data.db, - )?; - Bytes::new() - } - HEVMCalls::Load(inner) => { - ensure!(!is_potential_precompile(inner.0.to_alloy()), "Load cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); - // TODO: Does this increase gas usage? - data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; - let (val, _) = data.journaled_state.sload( - inner.0.to_alloy(), - U256::from_be_bytes(inner.1), - data.db, - )?; - DynSolValue::from(val).abi_encode().into() - } - HEVMCalls::Cool(inner) => cool_account(data, inner.0.to_alloy())?, - HEVMCalls::Breakpoint0(inner) => add_breakpoint(state, caller, &inner.0, true)?, - HEVMCalls::Breakpoint1(inner) => add_breakpoint(state, caller, &inner.0, inner.1)?, - HEVMCalls::Etch(inner) => { - ensure!(!is_potential_precompile(inner.0.to_alloy()), "Etch cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead"); - let code = inner.1.clone(); - trace!(address=?inner.0, code=?hex::encode(&code), "etch cheatcode"); - // TODO: Does this increase gas usage? - data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; - data.journaled_state.set_code( - inner.0.to_alloy(), - Bytecode::new_raw(alloy_primitives::Bytes(code.0)).to_checked(), - ); - Bytes::new() - } - HEVMCalls::Deal(inner) => { - let who = inner.0; - let value = inner.1; - trace!(?who, ?value, "deal cheatcode"); - with_journaled_account( - &mut data.journaled_state, - data.db, - who.to_alloy(), - |account| { - // record the deal - let record = DealRecord { - address: who.to_alloy(), - old_balance: account.info.balance, - new_balance: value.to_alloy(), - }; - state.eth_deals.push(record); - - account.info.balance = value.to_alloy(); - }, - )?; - Bytes::new() - } - HEVMCalls::Prank0(inner) => prank( - state, - caller, - data.env.tx.caller, - inner.0.to_alloy(), - None, - data.journaled_state.depth(), - true, - )?, - HEVMCalls::Prank1(inner) => prank( - state, - caller, - data.env.tx.caller, - inner.0.to_alloy(), - Some(inner.1.to_alloy()), - data.journaled_state.depth(), - true, - )?, - HEVMCalls::StartPrank0(inner) => prank( - state, - caller, - data.env.tx.caller, - inner.0.to_alloy(), - None, - data.journaled_state.depth(), - false, - )?, - HEVMCalls::StartPrank1(inner) => prank( - state, - caller, - data.env.tx.caller, - inner.0.to_alloy(), - Some(inner.1.to_alloy()), - data.journaled_state.depth(), - false, - )?, - HEVMCalls::StopPrank(_) => { - ensure!(state.prank.is_some(), "No prank in progress to stop"); - state.prank = None; - Bytes::new() - } - HEVMCalls::ReadCallers(_) => read_callers(state, data.env.tx.caller), - HEVMCalls::Record(_) => { - start_record(state); - Bytes::new() - } - HEVMCalls::Accesses(inner) => accesses(state, inner.0.to_alloy()), - HEVMCalls::RecordLogs(_) => { - start_record_logs(state); - Bytes::new() - } - HEVMCalls::GetRecordedLogs(_) => get_recorded_logs(state), - HEVMCalls::SetNonce(inner) => { - with_journaled_account( - &mut data.journaled_state, - data.db, - inner.0.to_alloy(), - |account| -> Result { - // nonce must increment only - let current = account.info.nonce; - let new = inner.1; - ensure!( - new >= current, - "New nonce ({new}) must be strictly equal to or higher than the \ - account's current nonce ({current})." - ); - account.info.nonce = new; - Ok(Bytes::new()) - }, - )?? - } - HEVMCalls::SetNonceUnsafe(inner) => with_journaled_account( - &mut data.journaled_state, - data.db, - inner.0.to_alloy(), - |account| -> Result { - let new = inner.1; - account.info.nonce = new; - Ok(Bytes::new()) - }, - )??, - HEVMCalls::ResetNonce(inner) => with_journaled_account( - &mut data.journaled_state, - data.db, - inner.0.to_alloy(), - |account| -> Result { - // Per EIP-161, EOA nonces start at 0, but contract nonces - // start at 1. Comparing by code_hash instead of code - // to avoid hitting the case where account's code is None. - let empty = account.info.code_hash == KECCAK_EMPTY; - let nonce = if empty { 0 } else { 1 }; - account.info.nonce = nonce; - Ok(Bytes::new()) - }, - )??, - // [function getNonce(address)] returns the current nonce of a given ETH address - HEVMCalls::GetNonce1(inner) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - - // TODO: this is probably not a good long-term solution since it might mess up the gas - // calculations - data.journaled_state.load_account(inner.0.to_alloy(), data.db)?; - - // we can safely unwrap because `load_account` insert inner.0 to DB. - let account = data.journaled_state.state().get(&inner.0.to_alloy()).unwrap(); - DynSolValue::from(account.info.nonce).abi_encode().into() - } - // [function getNonce(Wallet)] returns the current nonce of the Wallet's ETH address - HEVMCalls::GetNonce0(inner) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - - // TODO: this is probably not a good long-term solution since it might mess up the gas - // calculations - data.journaled_state.load_account(inner.0.addr.to_alloy(), data.db)?; - - // we can safely unwrap because `load_account` insert inner.0 to DB. - let account = data.journaled_state.state().get(&inner.0.addr.to_alloy()).unwrap(); - DynSolValue::from(account.info.nonce.to_alloy()).abi_encode().into() - } - HEVMCalls::ChainId(inner) => { - ensure!( - inner.0.to_alloy() <= U256::from(u64::MAX), - "Chain ID must be less than 2^64 - 1" - ); - data.env.cfg.chain_id = inner.0.as_u64(); - Bytes::new() - } - HEVMCalls::TxGasPrice(inner) => { - data.env.tx.gas_price = inner.0.to_alloy(); - Bytes::new() - } - HEVMCalls::Broadcast0(_) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - broadcast( - state, - data.env.tx.caller, - caller, - data.env.tx.caller, - data.journaled_state.depth(), - true, - )? - } - HEVMCalls::Broadcast1(inner) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - broadcast( - state, - inner.0.to_alloy(), - caller, - data.env.tx.caller, - data.journaled_state.depth(), - true, - )? - } - HEVMCalls::Broadcast2(inner) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - broadcast_key( - state, - inner.0.to_alloy(), - caller, - data.env.tx.caller, - U256::from(data.env.cfg.chain_id), - data.journaled_state.depth(), - true, - )? - } - HEVMCalls::StartBroadcast0(_) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - broadcast( - state, - data.env.tx.caller, - caller, - data.env.tx.caller, - data.journaled_state.depth(), - false, - )? - } - HEVMCalls::StartBroadcast1(inner) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - broadcast( - state, - inner.0.to_alloy(), - caller, - data.env.tx.caller, - data.journaled_state.depth(), - false, - )? - } - HEVMCalls::StartBroadcast2(inner) => { - correct_sender_nonce( - data.env.tx.caller, - &mut data.journaled_state, - &mut data.db, - state, - )?; - broadcast_key( - state, - inner.0.to_alloy(), - caller, - data.env.tx.caller, - U256::from(data.env.cfg.chain_id), - data.journaled_state.depth(), - false, - )? - } - HEVMCalls::StopBroadcast(_) => { - ensure!(state.broadcast.is_some(), "No broadcast in progress to stop"); - state.broadcast = None; - Bytes::new() - } - HEVMCalls::PauseGasMetering(_) => { - if state.gas_metering.is_none() { - state.gas_metering = Some(None); - } - Bytes::new() - } - HEVMCalls::ResumeGasMetering(_) => { - state.gas_metering = None; - Bytes::new() - } - HEVMCalls::StartMappingRecording(_) => { - if state.mapping_slots.is_none() { - state.mapping_slots = Some(Default::default()); - } - Bytes::new() - } - HEVMCalls::StopMappingRecording(_) => { - state.mapping_slots = None; - Bytes::new() - } - HEVMCalls::GetMappingLength(inner) => { - get_mapping_length(state, inner.0.to_alloy(), U256::from_be_bytes(inner.1)) - } - HEVMCalls::GetMappingSlotAt(inner) => get_mapping_slot_at( - state, - inner.0.to_alloy(), - U256::from_be_bytes(inner.1), - inner.2.to_alloy(), - ), - HEVMCalls::GetMappingKeyAndParentOf(inner) => { - get_mapping_key_and_parent(state, inner.0.to_alloy(), U256::from_be_bytes(inner.1)) - } - _ => return Ok(None), - }; - Ok(Some(result)) -} - -/// When using `forge script`, the script method is called using the address from `--sender`. -/// That leads to its nonce being incremented by `call_raw`. In a `broadcast` scenario this is -/// undesirable. Therefore, we make sure to fix the sender's nonce **once**. -fn correct_sender_nonce( - sender: Address, - journaled_state: &mut revm::JournaledState, - db: &mut DB, - state: &mut Cheatcodes, -) -> Result<(), DB::Error> { - if !state.corrected_nonce && sender != Config::DEFAULT_SENDER { - with_journaled_account(journaled_state, db, sender, |account| { - account.info.nonce = account.info.nonce.saturating_sub(1); - state.corrected_nonce = true; - })?; - } - Ok(()) -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/error.rs b/crates/evm/evm/src/inspectors/cheatcodes/error.rs deleted file mode 100644 index a30c80f6679f7..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/error.rs +++ /dev/null @@ -1,193 +0,0 @@ -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::Bytes; -use ethers::prelude::k256::ecdsa::signature::Error as SignatureError; -use foundry_common::errors::FsPathError; -use foundry_config::UnresolvedEnvVarError; -use foundry_evm_core::backend::{DatabaseError, NoCheatcodeAccessError}; -use foundry_utils::error::{encode_error, SolError}; -use std::{borrow::Cow, fmt::Arguments}; - -/// Type alias with a default Ok type of [`Bytes`], and default Err type of [`Error`]. -pub type Result = std::result::Result; - -macro_rules! fmt_err { - ($msg:literal $(,)?) => { - $crate::inspectors::cheatcodes::Error::fmt(::std::format_args!($msg)) - }; - ($err:expr $(,)?) => { - <$crate::inspectors::cheatcodes::Error as ::std::convert::From<_>>::from($err) - }; - ($fmt:expr, $($arg:tt)*) => { - $crate::inspectors::cheatcodes::Error::fmt(::std::format_args!($fmt, $($arg)*)) - }; -} - -macro_rules! bail { - ($msg:literal $(,)?) => { - return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($msg)) - }; - ($err:expr $(,)?) => { - return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($err)) - }; - ($fmt:expr, $($arg:tt)*) => { - return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($fmt, $($arg)*)) - }; -} - -macro_rules! ensure { - ($cond:expr $(,)?) => { - if !$cond { - return ::std::result::Result::Err($crate::inspectors::cheatcodes::Error::custom( - ::std::concat!("Condition failed: `", ::std::stringify!($cond), "`") - )); - } - }; - ($cond:expr, $msg:literal $(,)?) => { - if !$cond { - return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($msg)); - } - }; - ($cond:expr, $err:expr $(,)?) => { - if !$cond { - return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($err)); - } - }; - ($cond:expr, $fmt:expr, $($arg:tt)*) => { - if !$cond { - return ::std::result::Result::Err($crate::inspectors::cheatcodes::fmt_err!($fmt, $($arg)*)); - } - }; -} - -pub(crate) use bail; -pub(crate) use ensure; -pub(crate) use fmt_err; - -/// Errors that can happen when working with [`Cheacodes`]. -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("You need to stop broadcasting before you can select forks.")] - SelectForkDuringBroadcast, - - #[error(transparent)] - Eyre(#[from] eyre::Report), - - #[error(transparent)] - Signature(#[from] SignatureError), - - #[error(transparent)] - Database(#[from] DatabaseError), - - #[error(transparent)] - FsPath(#[from] FsPathError), - - #[error(transparent)] - NoCheatcodeAccess(#[from] NoCheatcodeAccessError), - - #[error(transparent)] - UnresolvedEnvVar(#[from] UnresolvedEnvVarError), - - #[error(transparent)] - Abi(#[from] ethers::abi::Error), - - #[error(transparent)] - Abi2(#[from] ethers::abi::AbiError), - - #[error(transparent)] - Wallet(#[from] ethers::signers::WalletError), - - #[error(transparent)] - EthersSignature(#[from] ethers::core::types::SignatureError), - - #[error(transparent)] - Json(#[from] serde_json::Error), - - #[error(transparent)] - JsonPath(#[from] jsonpath_lib::JsonPathError), - - #[error(transparent)] - Hex(#[from] hex::FromHexError), - - #[error(transparent)] - Utf8(#[from] std::str::Utf8Error), - - #[error(transparent)] - FromUtf8(#[from] std::string::FromUtf8Error), - - #[error(transparent)] - Io(#[from] std::io::Error), - - #[error(transparent)] - TryFromInt(#[from] std::num::TryFromIntError), - - /// Custom error. - #[error("{0}")] - Custom(Cow<'static, str>), - - /// Custom bytes. Will not get encoded with the error prefix. - #[error("{}", hex::encode(_0))] // ignored in SolError implementation - CustomBytes(Cow<'static, [u8]>), -} - -impl Error { - /// Creates a new error with a custom message. - pub fn custom(msg: impl Into>) -> Self { - Self::Custom(msg.into()) - } - - /// Creates a new error with a custom `fmt::Arguments` message. - pub fn fmt(args: Arguments<'_>) -> Self { - let cow = match args.as_str() { - Some(s) => Cow::Borrowed(s), - None => Cow::Owned(std::fmt::format(args)), - }; - Self::Custom(cow) - } - - /// Creates a new error with the given bytes. - pub fn custom_bytes(bytes: impl Into>) -> Self { - Self::CustomBytes(bytes.into()) - } -} - -impl From> for Error { - fn from(value: Cow<'static, str>) -> Self { - Self::Custom(value) - } -} - -impl From for Error { - fn from(value: String) -> Self { - Self::Custom(value.into()) - } -} - -impl From<&'static str> for Error { - fn from(value: &'static str) -> Self { - Self::Custom(value.into()) - } -} - -impl SolError for Error { - fn encode_error(&self) -> Bytes { - match self { - Self::CustomBytes(cow) => cow_to_bytes(cow), - e => encode_error(e), - } - } - - fn encode_string(&self) -> Bytes { - match self { - Self::CustomBytes(cow) => cow_to_bytes(cow), - e => DynSolValue::String(e.to_string()).abi_encode().into(), - } - } -} - -#[allow(clippy::ptr_arg)] // need to match on the Cow. -fn cow_to_bytes(cow: &Cow<'static, [u8]>) -> Bytes { - match cow { - Cow::Borrowed(slice) => Bytes::from_static(slice), - Cow::Owned(vec) => Bytes(vec.clone().into()), - } -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/expect.rs b/crates/evm/evm/src/inspectors/cheatcodes/expect.rs deleted file mode 100644 index 00d245427f1bc..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/expect.rs +++ /dev/null @@ -1,570 +0,0 @@ -use super::{bail, ensure, fmt_err, Cheatcodes, Result}; -use alloy_dyn_abi::DynSolType; -use alloy_primitives::{Address, Bytes, Log as RawLog, U256}; -use foundry_evm_core::{abi::HEVMCalls, backend::DatabaseExt}; -use foundry_utils::{ - error::{ERROR_PREFIX, REVERT_PREFIX}, - types::ToAlloy, -}; -use once_cell::sync::Lazy; -use revm::{ - interpreter::{return_ok, InstructionResult}, - primitives::Bytecode, - EVMData, -}; -use std::cmp::Ordering; - -/// For some cheatcodes we may internally change the status of the call, i.e. in `expectRevert`. -/// Solidity will see a successful call and attempt to decode the return data. Therefore, we need -/// to populate the return with dummy bytes so the decode doesn't fail. -/// -/// 8912 bytes was arbitrarily chosen because it is long enough for return values up to 256 words in -/// size. -static DUMMY_CALL_OUTPUT: Lazy = Lazy::new(|| Bytes::from_static(&[0u8; 8192])); - -/// Same reasoning as [DUMMY_CALL_OUTPUT], but for creates. -static DUMMY_CREATE_ADDRESS: Address = - Address::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); - -#[derive(Clone, Debug, Default)] -pub struct ExpectedRevert { - /// The expected data returned by the revert, None being any - pub reason: Option, - /// The depth at which the revert is expected - pub depth: u64, -} - -fn expect_revert(state: &mut Cheatcodes, reason: Option, depth: u64) -> Result { - ensure!( - state.expected_revert.is_none(), - "You must call another function prior to expecting a second revert." - ); - state.expected_revert = Some(ExpectedRevert { reason, depth }); - Ok(Bytes::new()) -} - -#[instrument(skip_all, fields(expected_revert, status, retdata = hex::encode(&retdata)))] -pub fn handle_expect_revert( - is_create: bool, - expected_revert: Option<&Bytes>, - status: InstructionResult, - retdata: Bytes, -) -> Result<(Option
, Bytes)> { - trace!("handle expect revert"); - - ensure!(!matches!(status, return_ok!()), "Call did not revert as expected"); - - macro_rules! success_return { - () => { - Ok(if is_create { - (Some(DUMMY_CREATE_ADDRESS), Bytes::new()) - } else { - trace!("successfully handled expected revert"); - (None, DUMMY_CALL_OUTPUT.clone()) - }) - }; - } - - // If None, accept any revert - let mut expected_revert = match expected_revert { - Some(x) => x.clone(), - None => return success_return!(), - }; - - if !expected_revert.is_empty() && retdata.is_empty() { - bail!("Call reverted as expected, but without data"); - } - - let mut actual_revert = retdata; - if actual_revert.len() >= 4 && - matches!(actual_revert[..4].try_into(), Ok(ERROR_PREFIX | REVERT_PREFIX)) - { - if let Ok(parsed_bytes) = DynSolType::Bytes.abi_decode(&actual_revert[4..]) { - if let Some(bytes) = parsed_bytes.as_bytes().map(|b| b.to_vec()) { - actual_revert = bytes.into(); - } - } - } - - if actual_revert == *expected_revert { - success_return!() - } else { - let stringify = |data: &mut Bytes| { - DynSolType::String - .abi_decode(data.0.as_ref()) - .ok() - .and_then(|d| d.as_str().map(|s| s.to_owned())) - .or_else(|| std::str::from_utf8(data.as_ref()).ok().map(ToOwned::to_owned)) - .unwrap_or_else(|| hex::encode_prefixed(data)) - }; - Err(fmt_err!( - "Error != expected error: {} != {}", - stringify(&mut actual_revert), - stringify(&mut expected_revert), - )) - } -} - -#[derive(Clone, Debug, Default)] -pub struct ExpectedEmit { - /// The depth at which we expect this emit to have occurred - pub depth: u64, - /// The log we expect - pub log: Option, - /// The checks to perform: - /// - /// ┌───────┬───────┬───────┬────┐ - /// │topic 1│topic 2│topic 3│data│ - /// └───────┴───────┴───────┴────┘ - pub checks: [bool; 4], - /// If present, check originating address against this - pub address: Option
, - /// Whether the log was actually found in the subcalls - pub found: bool, -} - -pub fn handle_expect_emit(state: &mut Cheatcodes, log: RawLog, address: &Address) { - // Fill or check the expected emits. - // We expect for emit checks to be filled as they're declared (from oldest to newest), - // so we fill them and push them to the back of the queue. - // If the user has properly filled all the emits, they'll end up in their original order. - // If not, the queue will not be in the order the events will be intended to be filled, - // and we'll be able to later detect this and bail. - - // First, we can return early if all events have been matched. - // This allows a contract to arbitrarily emit more events than expected (additive behavior), - // as long as all the previous events were matched in the order they were expected to be. - if state.expected_emits.iter().all(|expected| expected.found) { - return - } - - // if there's anything to fill, we need to pop back. - let event_to_fill_or_check = - if state.expected_emits.iter().any(|expected| expected.log.is_none()) { - state.expected_emits.pop_back() - // Else, if there are any events that are unmatched, we try to match to match them - // in the order declared, so we start popping from the front (like a queue). - } else { - state.expected_emits.pop_front() - }; - - let mut event_to_fill_or_check = - event_to_fill_or_check.expect("We should have an emit to fill or check. This is a bug"); - - match event_to_fill_or_check.log { - Some(ref expected) => { - let expected_topic_0 = expected.topics().first(); - let log_topic_0 = log.topics().first(); - - // same topic0 and equal number of topics should be verified further, others are a no - // match - if expected_topic_0 - .zip(log_topic_0) - .map_or(false, |(a, b)| a == b && expected.topics().len() == log.topics().len()) - { - // Match topics - event_to_fill_or_check.found = log - .topics() - .iter() - .skip(1) - .enumerate() - .filter(|(i, _)| event_to_fill_or_check.checks[*i]) - .all(|(i, topic)| topic == &expected.topics()[i + 1]); - - // Maybe match source address - if let Some(addr) = event_to_fill_or_check.address { - event_to_fill_or_check.found &= addr == *address; - } - - // Maybe match data - if event_to_fill_or_check.checks[3] { - event_to_fill_or_check.found &= expected.data == log.data; - } - } - - // If we found the event, we can push it to the back of the queue - // and begin expecting the next event. - if event_to_fill_or_check.found { - state.expected_emits.push_back(event_to_fill_or_check); - } else { - // We did not match this event, so we need to keep waiting for the right one to - // appear. - state.expected_emits.push_front(event_to_fill_or_check); - } - } - // Fill the event. - None => { - event_to_fill_or_check.log = Some(log); - state.expected_emits.push_back(event_to_fill_or_check); - } - } -} - -#[derive(Clone, Debug, Default)] -pub struct ExpectedCallData { - /// The expected value sent in the call - pub value: Option, - /// The expected gas supplied to the call - pub gas: Option, - /// The expected *minimum* gas supplied to the call - pub min_gas: Option, - /// The number of times the call is expected to be made. - /// If the type of call is `NonCount`, this is the lower bound for the number of calls - /// that must be seen. - /// If the type of call is `Count`, this is the exact number of calls that must be seen. - pub count: u64, - /// The type of call - pub call_type: ExpectedCallType, -} - -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub enum ExpectedCallType { - #[default] - Count, - NonCount, -} - -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct MockCallDataContext { - /// The partial calldata to match for mock - pub calldata: Bytes, - /// The value to match for mock - pub value: Option, -} - -#[derive(Clone, Debug)] -pub struct MockCallReturnData { - /// The return type for the mocked call - pub ret_type: InstructionResult, - /// Return data or error - pub data: Bytes, -} - -impl Ord for MockCallDataContext { - fn cmp(&self, other: &Self) -> Ordering { - // Calldata matching is reversed to ensure that a tighter match is - // returned if an exact match is not found. In case, there is - // a partial match to calldata that is more specific than - // a match to a msg.value, then the more specific calldata takes - // precedence. - self.calldata.cmp(&other.calldata).reverse().then(self.value.cmp(&other.value).reverse()) - } -} - -impl PartialOrd for MockCallDataContext { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -fn expect_safe_memory(state: &mut Cheatcodes, start: u64, end: u64, depth: u64) -> Result { - ensure!(start < end, "Invalid memory range: [{start}:{end}]"); - #[allow(clippy::single_range_in_vec_init)] - let offsets = state.allowed_mem_writes.entry(depth).or_insert_with(|| vec![0..0x60]); - offsets.push(start..end); - Ok(Bytes::new()) -} - -/// Handles expected calls specified by the `vm.expectCall` cheatcode. -/// -/// It can handle calls in two ways: -/// - If the cheatcode was used with a `count` argument, it will expect the call to be made exactly -/// `count` times. -/// e.g. `vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f), 4)` will expect the -/// call to address(0xc4f3) with selector `0xd34db33f` to be made exactly 4 times. If the amount of -/// calls is less or more than 4, the test will fail. Note that the `count` argument cannot be -/// overwritten with another `vm.expectCall`. If this is attempted, `expectCall` will revert. -/// - If the cheatcode was used without a `count` argument, it will expect the call to be made at -/// least the amount of times the cheatcode -/// was called. This means that `vm.expectCall` without a count argument can be called many times, -/// but cannot be called with a `count` argument after it was called without one. If the latter -/// happens, `expectCall` will revert. e.g `vm.expectCall(address(0xc4f3), -/// abi.encodeWithSelector(0xd34db33f))` will expect the call to address(0xc4f3) and selector -/// `0xd34db33f` to be made at least once. If the amount of calls is 0, the test will fail. If the -/// call is made more than once, the test will pass. -#[allow(clippy::too_many_arguments)] -fn expect_call( - state: &mut Cheatcodes, - target: Address, - calldata: Vec, - value: Option, - gas: Option, - min_gas: Option, - count: u64, - call_type: ExpectedCallType, -) -> Result { - match call_type { - ExpectedCallType::Count => { - // Get the expected calls for this target. - let expecteds = state.expected_calls.entry(target).or_default(); - // In this case, as we're using counted expectCalls, we should not be able to set them - // more than once. - ensure!( - !expecteds.contains_key(&calldata), - "Counted expected calls can only bet set once." - ); - expecteds - .insert(calldata, (ExpectedCallData { value, gas, min_gas, count, call_type }, 0)); - Ok(Bytes::new()) - } - ExpectedCallType::NonCount => { - let expecteds = state.expected_calls.entry(target).or_default(); - // Check if the expected calldata exists. - // If it does, increment the count by one as we expect to see it one more time. - if let Some(expected) = expecteds.get_mut(&calldata) { - // Ensure we're not overwriting a counted expectCall. - ensure!( - expected.0.call_type == ExpectedCallType::NonCount, - "Cannot overwrite a counted expectCall with a non-counted expectCall." - ); - expected.0.count += 1; - } else { - // If it does not exist, then create it. - expecteds.insert( - calldata, - (ExpectedCallData { value, gas, min_gas, count, call_type }, 0), - ); - } - Ok(Bytes::new()) - } - } -} - -#[instrument(level = "error", name = "expect", target = "evm::cheatcodes", skip_all)] -pub fn apply( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - call: &HEVMCalls, -) -> Option { - let result = match call { - HEVMCalls::ExpectRevert0(_) => expect_revert(state, None, data.journaled_state.depth()), - HEVMCalls::ExpectRevert1(inner) => { - expect_revert(state, Some(inner.0.clone().0.into()), data.journaled_state.depth()) - } - HEVMCalls::ExpectRevert2(inner) => { - expect_revert(state, Some(inner.0.into()), data.journaled_state.depth()) - } - HEVMCalls::ExpectEmit0(_) => { - state.expected_emits.push_back(ExpectedEmit { - depth: data.journaled_state.depth(), - checks: [true, true, true, true], - ..Default::default() - }); - Ok(Bytes::new()) - } - HEVMCalls::ExpectEmit1(inner) => { - state.expected_emits.push_back(ExpectedEmit { - depth: data.journaled_state.depth(), - checks: [true, true, true, true], - address: Some(inner.0.to_alloy()), - ..Default::default() - }); - Ok(Bytes::new()) - } - HEVMCalls::ExpectEmit2(inner) => { - state.expected_emits.push_back(ExpectedEmit { - depth: data.journaled_state.depth(), - checks: [inner.0, inner.1, inner.2, inner.3], - ..Default::default() - }); - Ok(Bytes::new()) - } - HEVMCalls::ExpectEmit3(inner) => { - state.expected_emits.push_back(ExpectedEmit { - depth: data.journaled_state.depth(), - checks: [inner.0, inner.1, inner.2, inner.3], - address: Some(inner.4.to_alloy()), - ..Default::default() - }); - Ok(Bytes::new()) - } - HEVMCalls::ExpectCall0(inner) => expect_call( - state, - inner.0.to_alloy(), - inner.1.to_vec(), - None, - None, - None, - 1, - ExpectedCallType::NonCount, - ), - HEVMCalls::ExpectCall1(inner) => expect_call( - state, - inner.0.to_alloy(), - inner.1.to_vec(), - None, - None, - None, - inner.2, - ExpectedCallType::Count, - ), - HEVMCalls::ExpectCall2(inner) => expect_call( - state, - inner.0.to_alloy(), - inner.2.to_vec(), - Some(inner.1.to_alloy()), - None, - None, - 1, - ExpectedCallType::NonCount, - ), - HEVMCalls::ExpectCall3(inner) => expect_call( - state, - inner.0.to_alloy(), - inner.2.to_vec(), - Some(inner.1.to_alloy()), - None, - None, - inner.3, - ExpectedCallType::Count, - ), - HEVMCalls::ExpectCall4(inner) => { - let value = inner.1.to_alloy(); - // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas - // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; - - expect_call( - state, - inner.0.to_alloy(), - inner.3.to_vec(), - Some(value), - Some(inner.2 + positive_value_cost_stipend), - None, - 1, - ExpectedCallType::NonCount, - ) - } - HEVMCalls::ExpectCall5(inner) => { - let value = inner.1.to_alloy(); - // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas - // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; - - expect_call( - state, - inner.0.to_alloy(), - inner.3.to_vec(), - Some(value), - Some(inner.2 + positive_value_cost_stipend), - None, - inner.4, - ExpectedCallType::Count, - ) - } - HEVMCalls::ExpectCallMinGas0(inner) => { - let value = inner.1.to_alloy(); - // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas - // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; - - expect_call( - state, - inner.0.to_alloy(), - inner.3.to_vec(), - Some(value), - None, - Some(inner.2 + positive_value_cost_stipend), - 1, - ExpectedCallType::NonCount, - ) - } - HEVMCalls::ExpectCallMinGas1(inner) => { - let value = inner.1.to_alloy(); - // If the value of the transaction is non-zero, the EVM adds a call stipend of 2300 gas - // to ensure that the basic fallback function can be called. - let positive_value_cost_stipend = if value > U256::ZERO { 2300 } else { 0 }; - - expect_call( - state, - inner.0.to_alloy(), - inner.3.to_vec(), - Some(value), - None, - Some(inner.2 + positive_value_cost_stipend), - inner.4, - ExpectedCallType::Count, - ) - } - HEVMCalls::MockCall0(inner) => { - // TODO: Does this increase gas usage? - if let Err(err) = data.journaled_state.load_account(inner.0.to_alloy(), data.db) { - return Some(Err(err.into())) - } - - // Etches a single byte onto the account if it is empty to circumvent the `extcodesize` - // check Solidity might perform. - let empty_bytecode = data - .journaled_state - .account(inner.0.to_alloy()) - .info - .code - .as_ref() - .map_or(true, Bytecode::is_empty); - if empty_bytecode { - let code = Bytecode::new_raw(Bytes::from_static(&[0u8])).to_checked(); - data.journaled_state.set_code(inner.0.to_alloy(), code); - } - state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( - MockCallDataContext { calldata: inner.1.clone().0.into(), value: None }, - MockCallReturnData { - data: inner.2.clone().0.into(), - ret_type: InstructionResult::Return, - }, - ); - Ok(Bytes::new()) - } - HEVMCalls::MockCall1(inner) => { - if let Err(err) = data.journaled_state.load_account(inner.0.to_alloy(), data.db) { - return Some(Err(err.into())) - } - - state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( - MockCallDataContext { - calldata: inner.2.to_vec().into(), - value: Some(inner.1.to_alloy()), - }, - MockCallReturnData { - data: inner.3.to_vec().into(), - ret_type: InstructionResult::Return, - }, - ); - Ok(Bytes::new()) - } - HEVMCalls::MockCallRevert0(inner) => { - state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( - MockCallDataContext { calldata: inner.1.to_vec().into(), value: None }, - MockCallReturnData { - data: inner.2.to_vec().into(), - ret_type: InstructionResult::Revert, - }, - ); - Ok(Bytes::new()) - } - HEVMCalls::MockCallRevert1(inner) => { - state.mocked_calls.entry(inner.0.to_alloy()).or_default().insert( - MockCallDataContext { - calldata: inner.2.to_vec().into(), - value: Some(inner.1.to_alloy()), - }, - MockCallReturnData { - data: inner.3.to_vec().into(), - ret_type: InstructionResult::Revert, - }, - ); - Ok(Bytes::new()) - } - HEVMCalls::ClearMockedCalls(_) => { - state.mocked_calls = Default::default(); - Ok(Bytes::new()) - } - HEVMCalls::ExpectSafeMemory(inner) => { - expect_safe_memory(state, inner.0, inner.1, data.journaled_state.depth()) - } - HEVMCalls::ExpectSafeMemoryCall(inner) => { - expect_safe_memory(state, inner.0, inner.1, data.journaled_state.depth() + 1) - } - _ => return None, - }; - Some(result) -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/ext.rs b/crates/evm/evm/src/inspectors/cheatcodes/ext.rs deleted file mode 100644 index 0d5d805819b90..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/ext.rs +++ /dev/null @@ -1,802 +0,0 @@ -use super::{bail, ensure, fmt_err, parse, Cheatcodes, Error, Result}; -use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::{Address, Bytes, B256, I256, U256}; -use ethers::{abi::JsonAbi, prelude::artifacts::CompactContractBytecode}; -use foundry_common::{fmt::*, fs, get_artifact_path}; -use foundry_config::fs_permissions::FsAccessKind; -use foundry_evm_core::{abi::HEVMCalls, constants::MAGIC_SKIP_BYTES}; -use foundry_utils::types::ToAlloy; -use revm::{Database, EVMData}; -use serde::Deserialize; -use serde_json::Value; -use std::{ - collections::BTreeMap, - env, - path::Path, - process::Command, - str::FromStr, - time::{SystemTime, UNIX_EPOCH}, -}; - -/// Invokes a `Command` with the given args and returns the exit code, stdout, and stderr. -/// -/// If stdout or stderr are valid hex, it returns the hex decoded value. -fn try_ffi(state: &Cheatcodes, args: &[String]) -> Result { - if args.is_empty() || args[0].is_empty() { - bail!("Can't execute empty command"); - } - let name = &args[0]; - let mut cmd = Command::new(name); - if args.len() > 1 { - cmd.args(&args[1..]); - } - - trace!(?args, "invoking try_ffi"); - - let output = cmd - .current_dir(&state.config.root) - .output() - .map_err(|err| fmt_err!("Failed to execute command: {err}"))?; - - let exit_code = output.status.code().unwrap_or(1); - - let trimmed_stdout = String::from_utf8(output.stdout)?; - let trimmed_stdout = trimmed_stdout.trim(); - - // The stdout might be encoded on valid hex, or it might just be a string, - // so we need to determine which it is to avoid improperly encoding later. - let encoded_stdout: DynSolValue = if let Ok(hex) = hex::decode(trimmed_stdout) { - DynSolValue::Bytes(hex) - } else { - DynSolValue::Bytes(trimmed_stdout.into()) - }; - let exit_code = I256::from_dec_str(&exit_code.to_string()) - .map_err(|err| fmt_err!("Could not convert exit code: {err}"))?; - let res = DynSolValue::Tuple(vec![ - DynSolValue::Int(exit_code, 256), - encoded_stdout, - // We can grab the stderr output as-is. - DynSolValue::Bytes(output.stderr), - ]); - - Ok(res.abi_encode().into()) -} - -/// Invokes a `Command` with the given args and returns the abi encoded response -/// -/// If the output of the command is valid hex, it returns the hex decoded value -fn ffi(state: &Cheatcodes, args: &[String]) -> Result { - if args.is_empty() || args[0].is_empty() { - bail!("Can't execute empty command"); - } - let name = &args[0]; - let mut cmd = Command::new(name); - if args.len() > 1 { - cmd.args(&args[1..]); - } - - debug!(target: "evm::cheatcodes", ?args, "invoking ffi"); - - let output = cmd - .current_dir(&state.config.root) - .output() - .map_err(|err| fmt_err!("Failed to execute command: {err}"))?; - - if !output.stderr.is_empty() { - let stderr = String::from_utf8_lossy(&output.stderr); - error!(target: "evm::cheatcodes", ?args, ?stderr, "non-empty stderr"); - } - - let output = String::from_utf8(output.stdout)?; - let trimmed = output.trim(); - if let Ok(hex) = hex::decode(trimmed) { - Ok(DynSolValue::Bytes(hex).abi_encode().into()) - } else { - Ok(DynSolValue::String(trimmed.to_owned()).abi_encode().into()) - } -} - -/// An enum which unifies the deserialization of Hardhat-style artifacts with Forge-style artifacts -/// to get their bytecode. -#[derive(Deserialize)] -#[serde(untagged)] -#[allow(clippy::large_enum_variant)] -enum ArtifactBytecode { - Hardhat(HardhatArtifact), - Solc(JsonAbi), - Forge(CompactContractBytecode), - Huff(HuffArtifact), -} - -impl ArtifactBytecode { - fn into_bytecode(self) -> Option { - match self { - ArtifactBytecode::Hardhat(inner) => Some(inner.bytecode), - ArtifactBytecode::Forge(inner) => { - inner.bytecode.and_then(|bytecode| bytecode.object.into_bytes()).map(|b| b.0.into()) - } - ArtifactBytecode::Solc(inner) => inner.bytecode().map(|b| b.0.into()), - ArtifactBytecode::Huff(inner) => Some(inner.bytecode), - } - } - - fn into_deployed_bytecode(self) -> Option { - match self { - ArtifactBytecode::Hardhat(inner) => Some(inner.deployed_bytecode), - ArtifactBytecode::Forge(inner) => inner.deployed_bytecode.and_then(|bytecode| { - bytecode - .bytecode - .and_then(|bytecode| bytecode.object.into_bytes()) - .map(|b| b.0.into()) - }), - ArtifactBytecode::Solc(inner) => inner.deployed_bytecode().map(|b| b.0.into()), - ArtifactBytecode::Huff(inner) => Some(inner.runtime), - } - } -} - -/// A thin wrapper around a Hardhat-style artifact that only extracts the bytecode. -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct HardhatArtifact { - bytecode: Bytes, - deployed_bytecode: Bytes, -} - -#[derive(Deserialize)] -struct HuffArtifact { - bytecode: Bytes, - runtime: Bytes, -} - -/// Returns the _deployed_ bytecode (`bytecode`) of the matching artifact -fn get_code(state: &Cheatcodes, path: &str) -> Result { - let bytecode = read_bytecode(state, path)?; - if let Some(bin) = bytecode.into_bytecode() { - Ok(DynSolValue::Bytes(bin.to_vec()).abi_encode().into()) - } else { - Err(fmt_err!("No bytecode for contract. Is it abstract or unlinked?")) - } -} - -/// Returns the _deployed_ bytecode (`bytecode`) of the matching artifact -fn get_deployed_code(state: &Cheatcodes, path: &str) -> Result { - let bytecode = read_bytecode(state, path)?; - if let Some(bin) = bytecode.into_deployed_bytecode() { - Ok(DynSolValue::Bytes(bin.to_vec()).abi_encode().into()) - } else { - Err(fmt_err!("No deployed bytecode for contract. Is it abstract or unlinked?")) - } -} - -/// Reads the bytecode object(s) from the matching artifact -fn read_bytecode(state: &Cheatcodes, path: &str) -> Result { - let path = get_artifact_path(&state.config.paths, path); - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - let data = fs::read_to_string(path)?; - serde_json::from_str::(&data).map_err(Into::into) -} - -fn set_env(key: &str, val: &str) -> Result { - // `std::env::set_var` may panic in the following situations - // ref: https://doc.rust-lang.org/std/env/fn.set_var.html - if key.is_empty() { - Err(fmt_err!("Environment variable key can't be empty")) - } else if key.contains('=') { - Err(fmt_err!("Environment variable key can't contain equal sign `=`")) - } else if key.contains('\0') { - Err(fmt_err!("Environment variable key can't contain NUL character `\\0`")) - } else if val.contains('\0') { - Err(fmt_err!("Environment variable value can't contain NUL character `\\0`")) - } else { - env::set_var(key, val); - Ok(Bytes::new()) - } -} - -fn get_env(key: &str, ty: DynSolType, delim: Option<&str>, default: Option) -> Result { - let val = env::var(key).or_else(|e| { - default.ok_or_else(|| { - fmt_err!("Failed to get environment variable `{key}` as type `{ty}`: {e}") - }) - })?; - if let Some(d) = delim { - parse::parse_array(val.split(d).map(str::trim), &ty) - } else { - parse::parse(&val, &ty) - } -} - -/// Converts a JSON [`Value`] to a [`DynSolValue`]. -/// -/// The function is designed to run recursively, so that in case of an object -/// it will call itself to convert each of its values and encode the whole as a -/// Tuple -pub fn value_to_token(value: &Value) -> Result { - match value { - Value::Null => Ok(DynSolValue::FixedBytes(B256::ZERO, 32)), - Value::Bool(boolean) => Ok(DynSolValue::Bool(*boolean)), - Value::Array(array) => { - let values = array.iter().map(value_to_token).collect::>>()?; - Ok(DynSolValue::Array(values)) - } - value @ Value::Object(_) => { - // See: [#3647](https://github.com/foundry-rs/foundry/pull/3647) - let ordered_object: BTreeMap = - serde_json::from_value(value.clone()).unwrap(); - let values = ordered_object.values().map(value_to_token).collect::>>()?; - Ok(DynSolValue::Tuple(values)) - } - Value::Number(number) => { - if let Some(f) = number.as_f64() { - // Check if the number has decimal digits because the EVM does not support floating - // point math - if f.fract() == 0.0 { - // Use the string representation of the `serde_json` Number type instead of - // calling f.to_string(), because some numbers are wrongly rounded up after - // being converted to f64. - // Example: 18446744073709551615 becomes 18446744073709552000 after parsing it - // to f64. - let s = number.to_string(); - // Coerced to scientific notation, so short-ciruit to using fallback. - // This will not have a problem with hex numbers, as for parsing these - // We'd need to prefix this with 0x. - // See also - if s.contains('e') { - // Calling Number::to_string with powers of ten formats the number using - // scientific notation and causes from_dec_str to fail. Using format! with - // f64 keeps the full number representation. - // Example: 100000000000000000000 becomes 1e20 when Number::to_string is - // used. - let fallback_s = format!("{f}"); - if let Ok(n) = U256::from_str(&fallback_s) { - return Ok(DynSolValue::Uint(n, 256)) - } - if let Ok(n) = I256::from_dec_str(&fallback_s) { - return Ok(DynSolValue::Int(n, 256)) - } - } - - if let Ok(n) = U256::from_str(&s) { - return Ok(DynSolValue::Uint(n, 256)) - } - if let Ok(n) = I256::from_str(&s) { - return Ok(DynSolValue::Int(n, 256)) - } - } - } - - Err(fmt_err!("Unsupported value: {number:?}")) - } - Value::String(string) => { - if let Some(mut val) = string.strip_prefix("0x") { - let s; - if val.len() % 2 != 0 { - s = format!("0{}", val); - val = &s[..]; - } - let bytes = hex::decode(val)?; - Ok(match bytes.len() { - 20 => DynSolValue::Address(Address::from_slice(&bytes)), - 32 => DynSolValue::FixedBytes(B256::from_slice(&bytes), 32), - _ => DynSolValue::Bytes(bytes), - }) - } else { - Ok(DynSolValue::String(string.to_owned())) - } - } - } -} - -/// Canonicalize a json path key to always start from the root of the document. -/// Read more about json path syntax: https://goessner.net/articles/JsonPath/ -fn canonicalize_json_key(key: &str) -> String { - if !key.starts_with('$') { - format!("${key}") - } else { - key.to_owned() - } -} - -/// Encodes a vector of [`DynSolValue`] into a vector of bytes. -fn encode_abi_values(values: Vec) -> Vec { - if values.is_empty() { - DynSolValue::Bytes(Vec::new()).abi_encode() - } else if values.len() == 1 { - DynSolValue::Bytes(values[0].abi_encode()).abi_encode() - } else { - DynSolValue::Bytes(DynSolValue::Array(values).abi_encode()).abi_encode() - } -} - -/// Parses a vector of [`Value`]s into a vector of [`DynSolValue`]s. -fn parse_json_values(values: Vec<&Value>, key: &str) -> Result> { - trace!(?values, %key, "parseing json values"); - values - .iter() - .map(|inner| { - value_to_token(inner).map_err(|err| fmt_err!("Failed to parse key \"{key}\": {err}")) - }) - .collect::>>() -} - -/// Parses a JSON and returns a single value, an array or an entire JSON object encoded as tuple. -/// As the JSON object is parsed serially, with the keys ordered alphabetically according to the -/// Rust BTreeMap crate serialization, they must be deserialized in the same order. That means that -/// the solidity `struct` should order its fields not by efficient packing or some other taxonomy -/// but instead alphabetically, with attention to upper/lower casing since uppercase precedes -/// lowercase in BTreeMap lexicographical ordering. -fn parse_json(json_str: &str, key: &str, coerce: Option) -> Result { - trace!(%json_str, %key, ?coerce, "parsing json"); - let json = - serde_json::from_str(json_str).map_err(|err| fmt_err!("Failed to parse JSON: {err}"))?; - match key { - // Handle the special case of the root key. We want to return the entire JSON object - // in this case. - "." => { - let values = jsonpath_lib::select(&json, "$")?; - let res = parse_json_values(values, key)?; - - // encode the bytes as the 'bytes' solidity type - let abi_encoded = encode_abi_values(res); - Ok(abi_encoded.into()) - } - _ => { - let values = jsonpath_lib::select(&json, &canonicalize_json_key(key))?; - trace!(?values, "selected json values"); - - // values is an array of items. Depending on the JsonPath key, they - // can be many or a single item. An item can be a single value or - // an entire JSON object. - if let Some(coercion_type) = coerce { - ensure!( - values.iter().all(|value| !value.is_object()), - "You can only coerce values or arrays, not JSON objects. The key '{key}' returns an object", - ); - - ensure!(!values.is_empty(), "No matching value or array found for key {key}"); - - let to_string = |v: &Value| { - let mut s = v.to_string(); - s.retain(|c: char| c != '"'); - s - }; - trace!(target : "forge::evm", ?values, "parsing values"); - return if let Some(array) = values[0].as_array() { - parse::parse_array(array.iter().map(to_string), &coercion_type) - } else { - parse::parse(&to_string(values[0]), &coercion_type) - } - } - - let res = parse_json_values(values, key)?; - // encode the bytes as the 'bytes' solidity type - let abi_encoded = encode_abi_values(res); - Ok(abi_encoded.into()) - } - } -} - -// returns JSON keys of given object as a string array -fn parse_json_keys(json_str: &str, key: &str) -> Result { - let json = serde_json::from_str(json_str)?; - let values = jsonpath_lib::select(&json, &canonicalize_json_key(key))?; - - // We need to check that values contains just one JSON-object and not an array of objects - ensure!( - values.len() == 1, - "You can only get keys for a single JSON-object. The key '{key}' returns a value or an array of JSON-objects", - ); - - let value = values[0]; - - ensure!( - value.is_object(), - "You can only get keys for JSON-object. The key '{key}' does not return an object", - ); - - let res = value - .as_object() - .ok_or(eyre::eyre!("Unexpected error while extracting JSON-object"))? - .keys() - .map(|key| DynSolValue::String(key.to_owned())) - .collect::>(); - - // encode the bytes as the 'bytes' solidity type - let abi_encoded = DynSolValue::Array(res).abi_encode(); - Ok(abi_encoded.into()) -} - -/// Serializes a key:value pair to a specific object. If the key is None, the value is expected to -/// be an object, which will be set as the root object for the provided object key, overriding -/// the whole root object if the object key already exists. By calling this function multiple times, -/// the user can serialize multiple KV pairs to the same object. The value can be of any type, even -/// a new object in itself. The function will return a stringified version of the object, so that -/// the user can use that as a value to a new invocation of the same function with a new object key. -/// This enables the user to reuse the same function to crate arbitrarily complex object structures -/// (JSON). Note that the `BTreeMap` is used to serialize in lexicographical order, meaning -/// uppercase precedes lowercase. More: -fn serialize_json( - state: &mut Cheatcodes, - object_key: &str, - value_key: Option<&str>, - value: &str, -) -> Result { - let json = if let Some(key) = value_key { - let parsed_value = - serde_json::from_str(value).unwrap_or_else(|_| Value::String(value.to_string())); - if let Some(serialization) = state.serialized_jsons.get_mut(object_key) { - serialization.insert(key.to_string(), parsed_value); - serialization.clone() - } else { - let mut serialization = BTreeMap::new(); - serialization.insert(key.to_string(), parsed_value); - state.serialized_jsons.insert(object_key.to_string(), serialization.clone()); - serialization.clone() - } - } else { - // value must be a JSON object - let parsed_value: BTreeMap = serde_json::from_str(value) - .map_err(|err| fmt_err!("Failed to parse JSON object: {err}"))?; - let serialization = parsed_value; - state.serialized_jsons.insert(object_key.to_string(), serialization.clone()); - serialization.clone() - }; - - let stringified = serde_json::to_string(&json) - .map_err(|err| fmt_err!("Failed to stringify hashmap: {err}"))?; - Ok(DynSolValue::String(stringified).abi_encode().into()) -} - -/// Converts an array to its stringified version, adding the appropriate quotes around its -/// elements. This is to signify that the elements of the array are strings themselves. -fn array_str_to_str(array: &Vec) -> String { - format!( - "[{}]", - array - .iter() - .enumerate() - .map(|(index, value)| { - if index == array.len() - 1 { - format!("\"{}\"", value.pretty()) - } else { - format!("\"{}\",", value.pretty()) - } - }) - .collect::() - ) -} - -/// Converts an array to its stringified version. It will not add quotes around the values of the -/// array, enabling serde_json to parse the values of the array as types (e.g numbers, booleans, -/// etc.) -fn array_eval_to_str(array: &Vec) -> String { - format!( - "[{}]", - array - .iter() - .enumerate() - .map(|(index, value)| { - if index == array.len() - 1 { - value.pretty() - } else { - format!("{},", value.pretty()) - } - }) - .collect::() - ) -} - -/// Write an object to a new file OR replace the value of an existing JSON file with the supplied -/// object. -fn write_json( - state: &Cheatcodes, - object: &str, - path: impl AsRef, - json_path_or_none: Option<&str>, -) -> Result { - let json: Value = - serde_json::from_str(object).unwrap_or_else(|_| Value::String(object.to_owned())); - let json_string = serde_json::to_string_pretty(&if let Some(json_path) = json_path_or_none { - let path = state.config.ensure_path_allowed(&path, FsAccessKind::Read)?; - let data = serde_json::from_str(&fs::read_to_string(path)?)?; - jsonpath_lib::replace_with(data, &canonicalize_json_key(json_path), &mut |_| { - Some(json.clone()) - })? - } else { - json - })?; - super::fs::write_file(state, path, json_string)?; - Ok(Bytes::new()) -} - -/// Checks if a key exists in a JSON object. -fn key_exists(json_str: &str, key: &str) -> Result { - let json: Value = - serde_json::from_str(json_str).map_err(|e| format!("Could not convert to JSON: {e}"))?; - let values = jsonpath_lib::select(&json, &canonicalize_json_key(key))?; - let exists = parse::parse(&(!values.is_empty()).to_string(), &DynSolType::Bool)?; - Ok(exists) -} - -/// Sleeps for a given amount of milliseconds. -fn sleep(milliseconds: &U256) -> Result { - let sleep_duration = std::time::Duration::from_millis(milliseconds.to::()); - std::thread::sleep(sleep_duration); - - Ok(Default::default()) -} - -/// Returns the time since unix epoch in milliseconds -fn duration_since_epoch() -> Result { - let sys_time = SystemTime::now(); - let difference = sys_time - .duration_since(UNIX_EPOCH) - .expect("Failed getting timestamp in unixTime cheatcode"); - let millis = difference.as_millis(); - Ok(DynSolValue::Uint(U256::from(millis), 256).abi_encode().into()) -} - -/// Skip the current test, by returning a magic value that will be checked by the test runner. -pub fn skip(state: &mut Cheatcodes, depth: u64, skip: bool) -> Result { - if !skip { - return Ok(b"".into()) - } - - // Skip should not work if called deeper than at test level. - // As we're not returning the magic skip bytes, this will cause a test failure. - if depth > 1 { - return Err(Error::custom("The skip cheatcode can only be used at test level")) - } - - state.skip = true; - Err(Error::custom_bytes(MAGIC_SKIP_BYTES)) -} - -#[instrument(level = "error", name = "ext", target = "evm::cheatcodes", skip_all)] -pub fn apply( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - call: &HEVMCalls, -) -> Option { - Some(match call { - HEVMCalls::Ffi(inner) => { - if state.config.ffi { - ffi(state, &inner.0) - } else { - Err(fmt_err!("FFI disabled: run again with `--ffi` if you want to allow tests to call external scripts.")) - } - } - HEVMCalls::TryFfi(inner) => { - if state.config.ffi { - try_ffi(state, &inner.0) - } else { - Err(fmt_err!("FFI disabled: run again with `--ffi` if you want to allow tests to call external scripts.")) - } - } - HEVMCalls::GetCode(inner) => get_code(state, &inner.0), - HEVMCalls::GetDeployedCode(inner) => get_deployed_code(state, &inner.0), - HEVMCalls::SetEnv(inner) => set_env(&inner.0, &inner.1), - HEVMCalls::EnvBool0(inner) => get_env(&inner.0, DynSolType::Bool, None, None), - HEVMCalls::EnvUint0(inner) => get_env(&inner.0, DynSolType::Uint(256), None, None), - HEVMCalls::EnvInt0(inner) => get_env(&inner.0, DynSolType::Int(256), None, None), - HEVMCalls::EnvAddress0(inner) => get_env(&inner.0, DynSolType::Address, None, None), - HEVMCalls::EnvBytes320(inner) => get_env(&inner.0, DynSolType::FixedBytes(32), None, None), - HEVMCalls::EnvString0(inner) => get_env(&inner.0, DynSolType::String, None, None), - HEVMCalls::EnvBytes0(inner) => get_env(&inner.0, DynSolType::Bytes, None, None), - HEVMCalls::EnvBool1(inner) => get_env(&inner.0, DynSolType::Bool, Some(&inner.1), None), - HEVMCalls::EnvUint1(inner) => { - get_env(&inner.0, DynSolType::Uint(256), Some(&inner.1), None) - } - HEVMCalls::EnvInt1(inner) => get_env(&inner.0, DynSolType::Int(256), Some(&inner.1), None), - HEVMCalls::EnvAddress1(inner) => { - get_env(&inner.0, DynSolType::Address, Some(&inner.1), None) - } - HEVMCalls::EnvBytes321(inner) => { - get_env(&inner.0, DynSolType::FixedBytes(32), Some(&inner.1), None) - } - HEVMCalls::EnvString1(inner) => get_env(&inner.0, DynSolType::String, Some(&inner.1), None), - HEVMCalls::EnvBytes1(inner) => get_env(&inner.0, DynSolType::Bytes, Some(&inner.1), None), - HEVMCalls::EnvOr0(inner) => { - get_env(&inner.0, DynSolType::Bool, None, Some(inner.1.to_string())) - } - HEVMCalls::EnvOr1(inner) => { - get_env(&inner.0, DynSolType::Uint(256), None, Some(inner.1.to_string())) - } - HEVMCalls::EnvOr2(inner) => { - get_env(&inner.0, DynSolType::Int(256), None, Some(inner.1.to_string())) - } - HEVMCalls::EnvOr3(inner) => { - get_env(&inner.0, DynSolType::Address, None, Some(hex::encode(inner.1))) - } - HEVMCalls::EnvOr4(inner) => { - get_env(&inner.0, DynSolType::FixedBytes(32), None, Some(hex::encode(inner.1))) - } - HEVMCalls::EnvOr5(inner) => { - get_env(&inner.0, DynSolType::String, None, Some(inner.1.to_string())) - } - HEVMCalls::EnvOr6(inner) => { - get_env(&inner.0, DynSolType::Bytes, None, Some(hex::encode(&inner.1))) - } - HEVMCalls::EnvOr7(inner) => get_env( - &inner.0, - DynSolType::Bool, - Some(&inner.1), - Some(inner.2.iter().map(|v| v.to_string()).collect::>().join(&inner.1)), - ), - HEVMCalls::EnvOr8(inner) => get_env( - &inner.0, - DynSolType::Uint(256), - Some(&inner.1), - Some(inner.2.iter().map(|v| v.to_string()).collect::>().join(&inner.1)), - ), - HEVMCalls::EnvOr9(inner) => get_env( - &inner.0, - DynSolType::Int(256), - Some(&inner.1), - Some(inner.2.iter().map(|v| v.to_string()).collect::>().join(&inner.1)), - ), - HEVMCalls::EnvOr10(inner) => get_env( - &inner.0, - DynSolType::Address, - Some(&inner.1), - Some(inner.2.iter().map(hex::encode).collect::>().join(&inner.1)), - ), - HEVMCalls::EnvOr11(inner) => get_env( - &inner.0, - DynSolType::FixedBytes(32), - Some(&inner.1), - Some(inner.2.iter().map(hex::encode).collect::>().join(&inner.1)), - ), - HEVMCalls::EnvOr12(inner) => { - get_env(&inner.0, DynSolType::String, Some(&inner.1), Some(inner.2.join(&inner.1))) - } - HEVMCalls::EnvOr13(inner) => get_env( - &inner.0, - DynSolType::Bytes, - Some(&inner.1), - Some(inner.2.iter().map(hex::encode).collect::>().join(&inner.1)), - ), - - // If no key argument is passed, return the whole JSON object. - // "$" is the JSONPath key for the root of the object - HEVMCalls::ParseJson0(inner) => parse_json(&inner.0, "$", None), - HEVMCalls::ParseJson1(inner) => parse_json(&inner.0, &inner.1, None), - HEVMCalls::ParseJsonBool(inner) => parse_json(&inner.0, &inner.1, Some(DynSolType::Bool)), - HEVMCalls::ParseJsonKeys(inner) => parse_json_keys(&inner.0, &inner.1), - HEVMCalls::ParseJsonBoolArray(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Bool)) - } - HEVMCalls::ParseJsonUint(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Uint(256))) - } - HEVMCalls::ParseJsonUintArray(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Uint(256))) - } - HEVMCalls::ParseJsonInt(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Int(256))) - } - HEVMCalls::ParseJsonIntArray(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Int(256))) - } - HEVMCalls::ParseJsonString(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::String)) - } - HEVMCalls::ParseJsonStringArray(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::String)) - } - HEVMCalls::ParseJsonAddress(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Address)) - } - HEVMCalls::ParseJsonAddressArray(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Address)) - } - HEVMCalls::ParseJsonBytes(inner) => parse_json(&inner.0, &inner.1, Some(DynSolType::Bytes)), - HEVMCalls::ParseJsonBytesArray(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::Bytes)) - } - HEVMCalls::ParseJsonBytes32(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::FixedBytes(32))) - } - HEVMCalls::ParseJsonBytes32Array(inner) => { - parse_json(&inner.0, &inner.1, Some(DynSolType::FixedBytes(32))) - } - HEVMCalls::SerializeJson(inner) => serialize_json(state, &inner.0, None, &inner.1.pretty()), - HEVMCalls::SerializeBool0(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) - } - HEVMCalls::SerializeBool1(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &array_eval_to_str(&inner.2)) - } - HEVMCalls::SerializeUint0(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) - } - HEVMCalls::SerializeUint1(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &array_eval_to_str(&inner.2)) - } - HEVMCalls::SerializeInt0(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) - } - HEVMCalls::SerializeInt1(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &array_eval_to_str(&inner.2)) - } - HEVMCalls::SerializeAddress0(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) - } - HEVMCalls::SerializeAddress1(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) - } - HEVMCalls::SerializeBytes320(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) - } - HEVMCalls::SerializeBytes321(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) - } - HEVMCalls::SerializeString0(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) - } - HEVMCalls::SerializeString1(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) - } - HEVMCalls::SerializeBytes0(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &inner.2.pretty()) - } - HEVMCalls::SerializeBytes1(inner) => { - serialize_json(state, &inner.0, Some(&inner.1), &array_str_to_str(&inner.2)) - } - HEVMCalls::Sleep(inner) => sleep(&inner.0.to_alloy()), - HEVMCalls::UnixTime(_) => duration_since_epoch(), - HEVMCalls::WriteJson0(inner) => write_json(state, &inner.0, &inner.1, None), - HEVMCalls::WriteJson1(inner) => write_json(state, &inner.0, &inner.1, Some(&inner.2)), - HEVMCalls::KeyExists(inner) => key_exists(&inner.0, &inner.1), - HEVMCalls::Skip(inner) => skip(state, data.journaled_state.depth(), inner.0), - _ => return None, - }) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::inspectors::CheatsConfig; - use ethers::core::abi::AbiDecode; - use std::{path::PathBuf, sync::Arc}; - - fn cheats() -> Cheatcodes { - let config = - CheatsConfig { root: PathBuf::from(&env!("CARGO_MANIFEST_DIR")), ..Default::default() }; - Cheatcodes { config: Arc::new(config), ..Default::default() } - } - - #[test] - fn test_ffi_hex() { - let msg = "gm"; - let cheats = cheats(); - let args = ["echo".to_string(), hex::encode(msg)]; - let output = ffi(&cheats, &args).unwrap(); - - let output = String::decode(&output).unwrap(); - assert_eq!(output, msg); - } - - #[test] - fn test_ffi_string() { - let msg = "gm"; - let cheats = cheats(); - - let args = ["echo".to_string(), msg.to_string()]; - let output = ffi(&cheats, &args).unwrap(); - - let output = String::decode(&output).unwrap(); - assert_eq!(output, msg); - } - - #[test] - fn test_artifact_parsing() { - let s = include_str!("../../../../test-data/solc-obj.json"); - let artifact: ArtifactBytecode = serde_json::from_str(s).unwrap(); - assert!(artifact.into_bytecode().is_some()); - - let artifact: ArtifactBytecode = serde_json::from_str(s).unwrap(); - assert!(artifact.into_deployed_bytecode().is_some()); - } -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/fork.rs b/crates/evm/evm/src/inspectors/cheatcodes/fork.rs deleted file mode 100644 index a0c0e2dd57aea..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/fork.rs +++ /dev/null @@ -1,407 +0,0 @@ -use super::{ext::value_to_token, fmt_err, Cheatcodes, Error, Result}; -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{Bytes, B256, U256}; -use ethers::{providers::Middleware, types::Filter}; -use foundry_abi::hevm::{EthGetLogsCall, RpcCall}; -use foundry_common::ProviderBuilder; -use foundry_evm_core::{ - abi::HEVMCalls, backend::DatabaseExt, fork::CreateFork, utils::RuntimeOrHandle, -}; -use foundry_utils::types::{ToAlloy, ToEthers}; -use itertools::Itertools; -use revm::EVMData; -use serde_json::Value; - -fn empty(_: T) -> Bytes { - Bytes::new() -} - -/// Handles fork related cheatcodes -#[instrument(level = "error", name = "fork", target = "evm::cheatcodes", skip_all)] -pub fn apply( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - call: &HEVMCalls, -) -> Option { - let result = match call { - HEVMCalls::CreateFork0(fork) => create_fork(state, data, fork.0.clone(), None), - HEVMCalls::CreateFork1(fork) => { - create_fork(state, data, fork.0.clone(), Some(fork.1.as_u64())) - } - HEVMCalls::CreateFork2(fork) => { - create_fork_at_transaction(state, data, fork.0.clone(), fork.1.into()) - } - HEVMCalls::CreateSelectFork0(fork) => create_select_fork(state, data, fork.0.clone(), None), - HEVMCalls::CreateSelectFork1(fork) => { - create_select_fork(state, data, fork.0.clone(), Some(fork.1.as_u64())) - } - HEVMCalls::CreateSelectFork2(fork) => { - create_select_fork_at_transaction(state, data, fork.0.clone(), fork.1.into()) - } - HEVMCalls::SelectFork(fork_id) => select_fork(state, data, fork_id.0.to_alloy()), - HEVMCalls::MakePersistent0(acc) => { - data.db.add_persistent_account(acc.0.to_alloy()); - Ok(Bytes::new()) - } - HEVMCalls::MakePersistent1(acc) => { - data.db.extend_persistent_accounts( - (acc.0.clone().into_iter().map(|acc| acc.to_alloy())).collect::>(), - ); - Ok(Bytes::new()) - } - HEVMCalls::MakePersistent2(acc) => { - data.db.add_persistent_account(acc.0.to_alloy()); - data.db.add_persistent_account(acc.1.to_alloy()); - Ok(Bytes::new()) - } - HEVMCalls::MakePersistent3(acc) => { - data.db.add_persistent_account(acc.0.to_alloy()); - data.db.add_persistent_account(acc.1.to_alloy()); - data.db.add_persistent_account(acc.2.to_alloy()); - Ok(Bytes::new()) - } - HEVMCalls::IsPersistent(acc) => { - Ok(DynSolValue::Bool(data.db.is_persistent(&acc.0.to_alloy())).abi_encode().into()) - } - HEVMCalls::RevokePersistent0(acc) => { - data.db.remove_persistent_account(&acc.0.to_alloy()); - Ok(Bytes::new()) - } - HEVMCalls::RevokePersistent1(acc) => { - data.db.remove_persistent_accounts( - acc.0.clone().into_iter().map(|acc| acc.to_alloy()).collect::>(), - ); - Ok(Bytes::new()) - } - HEVMCalls::ActiveFork(_) => data - .db - .active_fork_id() - .map(|id| DynSolValue::Uint(id, 256).abi_encode().into()) - .ok_or_else(|| fmt_err!("No active fork")), - HEVMCalls::RollFork0(fork) => data - .db - .roll_fork(None, fork.0.to_alloy(), data.env, &mut data.journaled_state) - .map(empty) - .map_err(Into::into), - HEVMCalls::RollFork1(fork) => data - .db - .roll_fork_to_transaction(None, fork.0.into(), data.env, &mut data.journaled_state) - .map(empty) - .map_err(Into::into), - HEVMCalls::RollFork2(fork) => data - .db - .roll_fork( - Some(fork.0).map(|id| id.to_alloy()), - fork.1.to_alloy(), - data.env, - &mut data.journaled_state, - ) - .map(empty) - .map_err(Into::into), - HEVMCalls::RollFork3(fork) => data - .db - .roll_fork_to_transaction( - Some(fork.0).map(|f| f.to_alloy()), - fork.1.into(), - data.env, - &mut data.journaled_state, - ) - .map(empty) - .map_err(Into::into), - HEVMCalls::RpcUrl(rpc) => { - state.config.get_rpc_url(&rpc.0).map(|url| DynSolValue::String(url).abi_encode().into()) - } - HEVMCalls::RpcUrls(_) => { - let mut urls = Vec::with_capacity(state.config.rpc_endpoints.len()); - for alias in state.config.rpc_endpoints.keys().cloned() { - match state.config.get_rpc_url(&alias) { - Ok(url) => { - urls.push([alias, url]); - } - Err(err) => return Some(Err(err)), - } - } - Ok(DynSolValue::Array( - urls.into_iter() - .map(|t| { - DynSolValue::FixedArray(vec![ - DynSolValue::String(t[0].clone()), - DynSolValue::String(t[1].clone()), - ]) - }) - .collect_vec(), - ) - .abi_encode() - .into()) - } - HEVMCalls::RpcUrlStructs(_) => { - let mut urls = Vec::with_capacity(state.config.rpc_endpoints.len()); - for alias in state.config.rpc_endpoints.keys() { - match state.config.get_rpc_url(alias) { - Ok(url) => { - urls.push([alias.clone(), url]); - } - Err(err) => return Some(Err(err)), - } - } - let urls = DynSolValue::Array( - urls.into_iter() - .map(|u| { - DynSolValue::Tuple(vec![ - DynSolValue::String(u[0].clone()), - DynSolValue::String(u[1].clone()), - ]) - }) - .collect_vec(), - ); - Ok(urls.abi_encode().into()) - } - HEVMCalls::AllowCheatcodes(addr) => { - data.db.allow_cheatcode_access(addr.0.to_alloy()); - Ok(Bytes::new()) - } - HEVMCalls::Transact0(inner) => data - .db - .transact(None, inner.0.into(), data.env, &mut data.journaled_state, state) - .map(empty) - .map_err(Into::into), - HEVMCalls::Transact1(inner) => data - .db - .transact( - Some(inner.0.to_alloy()), - inner.1.into(), - data.env, - &mut data.journaled_state, - state, - ) - .map(empty) - .map_err(Into::into), - HEVMCalls::EthGetLogs(inner) => eth_getlogs(data, inner), - HEVMCalls::Rpc(inner) => rpc(data, inner), - _ => return None, - }; - Some(result) -} - -/// Selects the given fork id -fn select_fork( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - fork_id: U256, -) -> Result { - if state.broadcast.is_some() { - return Err(Error::SelectForkDuringBroadcast) - } - - // No need to correct since the sender's nonce does not get incremented when selecting a fork. - state.corrected_nonce = true; - - data.db.select_fork(fork_id, data.env, &mut data.journaled_state)?; - Ok(Bytes::new()) -} - -/// Creates and then also selects the new fork -fn create_select_fork( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - url_or_alias: String, - block: Option, -) -> Result { - if state.broadcast.is_some() { - return Err(Error::SelectForkDuringBroadcast) - } - - // No need to correct since the sender's nonce does not get incremented when selecting a fork. - state.corrected_nonce = true; - - let fork = create_fork_request(state, url_or_alias, block, data)?; - let id = data.db.create_select_fork(fork, data.env, &mut data.journaled_state)?; - Ok(DynSolValue::Uint(id, 256).abi_encode().into()) -} - -/// Creates a new fork -fn create_fork( - state: &Cheatcodes, - data: &mut EVMData<'_, DB>, - url_or_alias: String, - block: Option, -) -> Result { - let fork = create_fork_request(state, url_or_alias, block, data)?; - let id = data.db.create_fork(fork)?; - Ok(DynSolValue::Uint(id, 256).abi_encode().into()) -} -/// Creates and then also selects the new fork at the given transaction -fn create_select_fork_at_transaction( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - url_or_alias: String, - transaction: B256, -) -> Result { - if state.broadcast.is_some() { - return Err(Error::SelectForkDuringBroadcast) - } - - // No need to correct since the sender's nonce does not get incremented when selecting a fork. - state.corrected_nonce = true; - - let fork = create_fork_request(state, url_or_alias, None, data)?; - let id = data.db.create_select_fork_at_transaction( - fork, - data.env, - &mut data.journaled_state, - transaction, - )?; - Ok(DynSolValue::Uint(id, 256).abi_encode().into()) -} - -/// Creates a new fork at the given transaction -fn create_fork_at_transaction( - state: &Cheatcodes, - data: &mut EVMData<'_, DB>, - url_or_alias: String, - transaction: B256, -) -> Result { - let fork = create_fork_request(state, url_or_alias, None, data)?; - let id = data.db.create_fork_at_transaction(fork, transaction)?; - Ok(DynSolValue::Uint(id, 256).abi_encode().into()) -} - -/// Creates the request object for a new fork request -fn create_fork_request( - state: &Cheatcodes, - url_or_alias: String, - block: Option, - data: &EVMData<'_, DB>, -) -> Result { - let url = state.config.get_rpc_url(url_or_alias)?; - let mut evm_opts = state.config.evm_opts.clone(); - evm_opts.fork_block_number = block; - let fork = CreateFork { - enable_caching: state.config.rpc_storage_caching.enable_for_endpoint(&url), - url, - env: data.env.clone(), - evm_opts, - }; - Ok(fork) -} - -/// Retrieve the logs specified for the current fork. -/// Equivalent to eth_getLogs but on a cheatcode. -fn eth_getlogs(data: &EVMData<'_, DB>, inner: &EthGetLogsCall) -> Result { - let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; - if inner.0.to_alloy() > U256::from(u64::MAX) || inner.1.to_alloy() > U256::from(u64::MAX) { - return Err(fmt_err!("Blocks in block range must be less than 2^64 - 1")) - } - // Cannot possibly have more than 4 topics in the topics array. - if inner.3.len() > 4 { - return Err(fmt_err!("Topics array must be less than 4 elements")) - } - - let provider = ProviderBuilder::new(url).build()?; - let mut filter = - Filter::new().address(inner.2).from_block(inner.0.as_u64()).to_block(inner.1.as_u64()); - for (i, item) in inner.3.iter().enumerate() { - match i { - 0 => filter = filter.topic0(U256::from_be_bytes(item.to_owned()).to_ethers()), - 1 => filter = filter.topic1(U256::from_be_bytes(item.to_owned()).to_ethers()), - 2 => filter = filter.topic2(U256::from_be_bytes(item.to_owned()).to_ethers()), - 3 => filter = filter.topic3(U256::from_be_bytes(item.to_owned()).to_ethers()), - _ => return Err(fmt_err!("Topics array should be less than 4 elements")), - }; - } - - let logs = RuntimeOrHandle::new() - .block_on(provider.get_logs(&filter)) - .map_err(|_| fmt_err!("Error in calling eth_getLogs"))?; - - if logs.is_empty() { - let empty: Bytes = DynSolValue::Array(vec![]).abi_encode().into(); - return Ok(empty) - } - - let result = DynSolValue::Array( - logs.iter() - .map(|entry| { - DynSolValue::Tuple(vec![ - DynSolValue::Address(entry.address.to_alloy()), - DynSolValue::Array( - entry - .topics - .clone() - .into_iter() - .map(|h| DynSolValue::FixedBytes(h.to_alloy(), 32)) - .collect_vec(), - ), - DynSolValue::Bytes(entry.data.0.clone().into()), - DynSolValue::Uint( - U256::from( - entry - .block_number - .expect("eth_getLogs response should include block_number field") - .to_alloy(), - ), - 32, - ), - DynSolValue::FixedBytes( - entry - .transaction_hash - .expect("eth_getLogs response should include transaction_hash field") - .to_alloy(), - 32, - ), - DynSolValue::Uint( - U256::from( - entry - .transaction_index - .expect( - "eth_getLogs response should include transaction_index field", - ) - .to_alloy(), - ), - 32, - ), - DynSolValue::FixedBytes( - entry - .block_hash - .expect("eth_getLogs response should include block_hash field") - .to_alloy(), - 32, - ), - DynSolValue::Uint( - U256::from( - entry - .log_index - .expect("eth_getLogs response should include log_index field") - .to_alloy(), - ), - 32, - ), - DynSolValue::Bool( - entry.removed.expect("eth_getLogs response should include removed field"), - ), - ]) - }) - .collect::>(), - ) - .abi_encode() - .into(); - Ok(result) -} - -fn rpc(data: &EVMData<'_, DB>, inner: &RpcCall) -> Result { - let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; - let provider = ProviderBuilder::new(url).build()?; - - let method = inner.0.as_str(); - let params = inner.1.as_str(); - let params_json: Value = serde_json::from_str(params)?; - - let result: Value = RuntimeOrHandle::new() - .block_on(provider.request(method, params_json)) - .map_err(|err| fmt_err!("Error in calling {:?}: {:?}", method, err))?; - - let result_as_tokens = - value_to_token(&result).map_err(|err| fmt_err!("Failed to parse result: {err}"))?; - - Ok(result_as_tokens.abi_encode().into()) -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/fs.rs b/crates/evm/evm/src/inspectors/cheatcodes/fs.rs deleted file mode 100644 index 67d8da783d42b..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/fs.rs +++ /dev/null @@ -1,334 +0,0 @@ -use super::{Cheatcodes, Result}; -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{Bytes, U256}; -use foundry_common::fs; -use foundry_config::fs_permissions::FsAccessKind; -use foundry_evm_core::abi::hevm::{DirEntry, FsMetadata, HEVMCalls}; -use foundry_utils::types::ToAlloy; -use std::{ - io::{BufRead, BufReader, Write}, - path::Path, - time::UNIX_EPOCH, -}; -use walkdir::WalkDir; - -fn project_root(state: &Cheatcodes) -> Result { - let root = state.config.root.display().to_string(); - Ok(DynSolValue::String(root).abi_encode().into()) -} - -fn read_file(state: &Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - let data = fs::read_to_string(path)?; - Ok(DynSolValue::String(data).abi_encode().into()) -} - -fn read_file_binary(state: &Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - let data = fs::read(path)?; - Ok(DynSolValue::Bytes(data).abi_encode().into()) -} - -fn read_line(state: &mut Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - - // Get reader for previously opened file to continue reading OR initialize new reader - let reader = state - .context - .opened_read_files - .entry(path.clone()) - .or_insert(BufReader::new(fs::open(path)?)); - - let mut line: String = String::new(); - reader.read_line(&mut line)?; - - // Remove trailing newline character, preserving others for cases where it may be important - if line.ends_with('\n') { - line.pop(); - if line.ends_with('\r') { - line.pop(); - } - } - - Ok(DynSolValue::String(line).abi_encode().into()) -} - -/// Writes `content` to `path`. -/// -/// This function will create a file if it does not exist, and will entirely replace its contents if -/// it does. -/// -/// Caution: writing files is only allowed if the targeted path is allowed, (inside `/` by -/// default) -pub(super) fn write_file( - state: &Cheatcodes, - path: impl AsRef, - content: impl AsRef<[u8]>, -) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; - // write access to foundry.toml is not allowed - state.config.ensure_not_foundry_toml(&path)?; - - if state.fs_commit { - fs::write(path, content.as_ref())?; - } - - Ok(Bytes::new()) -} - -/// Writes a single line to the file. -/// -/// This will create a file if it does not exist, and append the `line` if it does. -fn write_line(state: &Cheatcodes, path: impl AsRef, line: &str) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; - state.config.ensure_not_foundry_toml(&path)?; - - if state.fs_commit { - let mut file = std::fs::OpenOptions::new().append(true).create(true).open(path)?; - - writeln!(file, "{line}")?; - } - - Ok(Bytes::new()) -} - -fn copy_file(state: &Cheatcodes, from: impl AsRef, to: impl AsRef) -> Result { - let from = state.config.ensure_path_allowed(from, FsAccessKind::Read)?; - let to = state.config.ensure_path_allowed(to, FsAccessKind::Write)?; - state.config.ensure_not_foundry_toml(&to)?; - - let n = fs::copy(from, to)?; - Ok(DynSolValue::Uint(U256::from(n), 256).abi_encode().into()) -} - -fn close_file(state: &mut Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - - state.context.opened_read_files.remove(&path); - - Ok(Bytes::new()) -} - -/// Removes a file from the filesystem. -/// -/// Only files inside `/` can be removed, `foundry.toml` excluded. -/// -/// This will return an error if the path points to a directory, or the file does not exist -fn remove_file(state: &mut Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; - state.config.ensure_not_foundry_toml(&path)?; - - // also remove from the set if opened previously - state.context.opened_read_files.remove(&path); - - if state.fs_commit { - fs::remove_file(&path)?; - } - - Ok(Bytes::new()) -} - -/// Creates a new, empty directory at the provided path. -/// -/// If `recursive` is true, it will also create all the parent directories if they don't exist. -/// -/// # Errors -/// -/// This function will return an error in the following situations, but is not limited to just these -/// cases: -/// -/// - User lacks permissions to modify `path`. -/// - A parent of the given path doesn't exist and `recursive` is false. -/// - `path` already exists and `recursive` is false. -fn create_dir(state: &Cheatcodes, path: impl AsRef, recursive: bool) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; - if recursive { fs::create_dir_all(path) } else { fs::create_dir(path) }?; - Ok(Bytes::new()) -} - -/// Removes a directory at the provided path. -/// -/// This will also remove all the directory's contents recursively if `recursive` is true. -/// -/// # Errors -/// -/// This function will return an error in the following situations, but is not limited to just these -/// cases: -/// -/// - `path` doesn't exist. -/// - `path` isn't a directory. -/// - User lacks permissions to modify `path`. -/// - The directory is not empty and `recursive` is false. -fn remove_dir(state: &Cheatcodes, path: impl AsRef, recursive: bool) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; - if recursive { fs::remove_dir_all(path) } else { fs::remove_dir(path) }?; - Ok(Bytes::new()) -} - -/// Reads the directory at the given path recursively, up to `max_depth`. -/// -/// Follows symbolic links if `follow_links` is true. -fn read_dir( - state: &Cheatcodes, - path: impl AsRef, - max_depth: u64, - follow_links: bool, -) -> Result { - let root = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - let paths: Vec = WalkDir::new(root) - .min_depth(1) - .max_depth(max_depth.try_into()?) - .follow_links(follow_links) - .contents_first(false) - .same_file_system(true) - .sort_by_file_name() - .into_iter() - .map(|entry| { - let entry = match entry { - Ok(entry) => DirEntry { - error_message: String::new(), - path: entry.path().display().to_string(), - depth: entry.depth() as u64, - is_dir: entry.file_type().is_dir(), - is_symlink: entry.path_is_symlink(), - }, - Err(e) => DirEntry { - error_message: e.to_string(), - path: e.path().map(|p| p.display().to_string()).unwrap_or_default(), - depth: e.depth() as u64, - is_dir: false, - is_symlink: false, - }, - }; - DynSolValue::Tuple(vec![ - DynSolValue::String(entry.error_message), - DynSolValue::String(entry.path), - DynSolValue::Uint(U256::from(entry.depth), 8), - DynSolValue::Bool(entry.is_dir), - DynSolValue::Bool(entry.is_symlink), - ]) - }) - .collect(); - Ok(DynSolValue::Array(paths).abi_encode().into()) -} - -/// Reads a symbolic link, returning the path that the link points to. -/// -/// # Errors -/// -/// This function will return an error in the following situations, but is not limited to just these -/// cases: -/// -/// - `path` is not a symbolic link. -/// - `path` does not exist. -fn read_link(state: &Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - - let target = fs::read_link(path)?; - - Ok(DynSolValue::String(target.display().to_string()).abi_encode().into()) -} - -/// Gets the metadata of a file/directory -/// -/// This will return an error if no file/directory is found, or if the target path isn't allowed -fn fs_metadata(state: &Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - - let metadata = path.metadata()?; - - // These fields not available on all platforms; default to 0 - let [modified, accessed, created] = - [metadata.modified(), metadata.accessed(), metadata.created()].map(|time| { - time.unwrap_or(UNIX_EPOCH).duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() - }); - - let metadata = FsMetadata { - is_dir: metadata.is_dir(), - is_symlink: metadata.is_symlink(), - length: metadata.len().into(), - read_only: metadata.permissions().readonly(), - modified: modified.into(), - accessed: accessed.into(), - created: created.into(), - }; - Ok(DynSolValue::Tuple(vec![ - DynSolValue::Bool(metadata.is_dir), - DynSolValue::Bool(metadata.is_symlink), - DynSolValue::Uint(U256::from(metadata.length.to_alloy()), 256), - DynSolValue::Bool(metadata.read_only), - DynSolValue::Uint(U256::from(metadata.modified.to_alloy()), 256), - DynSolValue::Uint(U256::from(metadata.accessed.to_alloy()), 256), - DynSolValue::Uint(U256::from(metadata.created.to_alloy()), 256), - ]) - .abi_encode() - .into()) -} - -/// Verifies if a given path points to a valid entity -/// -/// This function will return `true` if `path` points to a valid filesystem entity, otherwise it -/// will return `false` -/// -/// Note: This function does not verify if a user has necessary permissions to access the path, -/// only that such a path exists -fn exists(state: &Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - - Ok(DynSolValue::Bool(path.exists()).abi_encode().into()) -} - -/// Verifies if a given path exists on disk and points at a regular file -/// -/// This function will return `true` if `path` points to a regular file that exists on the disk, -/// otherwise it will return `false` -/// -/// Note: This function does not verify if a user has necessary permissions to access the file, -/// only that such a file exists on disk -fn is_file(state: &Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - - Ok(DynSolValue::Bool(path.is_file()).abi_encode().into()) -} - -/// Verifies if a given path exists on disk and points at a directory -/// -/// This function will return `true` if `path` points to a directory that exists on the disk, -/// otherwise it will return `false` -/// -/// Note: This function does not verify if a user has necessary permissions to access the directory, -/// only that such a directory exists -fn is_dir(state: &Cheatcodes, path: impl AsRef) -> Result { - let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; - - Ok(DynSolValue::Bool(path.is_dir()).abi_encode().into()) -} - -#[instrument(level = "error", name = "fs", target = "evm::cheatcodes", skip_all)] -pub fn apply(state: &mut Cheatcodes, call: &HEVMCalls) -> Option { - let res = match call { - HEVMCalls::ProjectRoot(_) => project_root(state), - HEVMCalls::ReadFile(inner) => read_file(state, &inner.0), - HEVMCalls::ReadFileBinary(inner) => read_file_binary(state, &inner.0), - HEVMCalls::ReadLine(inner) => read_line(state, &inner.0), - HEVMCalls::WriteFile(inner) => write_file(state, &inner.0, &inner.1), - HEVMCalls::WriteFileBinary(inner) => write_file(state, &inner.0, &inner.1), - HEVMCalls::WriteLine(inner) => write_line(state, &inner.0, &inner.1), - HEVMCalls::CopyFile(inner) => copy_file(state, &inner.0, &inner.1), - HEVMCalls::CloseFile(inner) => close_file(state, &inner.0), - HEVMCalls::RemoveFile(inner) => remove_file(state, &inner.0), - HEVMCalls::FsMetadata(inner) => fs_metadata(state, &inner.0), - HEVMCalls::ReadLink(inner) => read_link(state, &inner.0), - HEVMCalls::CreateDir(inner) => create_dir(state, &inner.0, inner.1), - HEVMCalls::RemoveDir(inner) => remove_dir(state, &inner.0, inner.1), - HEVMCalls::ReadDir0(inner) => read_dir(state, &inner.0, 1, false), - HEVMCalls::ReadDir1(inner) => read_dir(state, &inner.0, inner.1, false), - HEVMCalls::ReadDir2(inner) => read_dir(state, &inner.0, inner.1, inner.2), - HEVMCalls::Exists(inner) => exists(state, &inner.0), - HEVMCalls::IsFile(inner) => is_file(state, &inner.0), - HEVMCalls::IsDir(inner) => is_dir(state, &inner.0), - - _ => return None, - }; - Some(res) -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/fuzz.rs b/crates/evm/evm/src/inspectors/cheatcodes/fuzz.rs deleted file mode 100644 index de92ae6e8d704..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/fuzz.rs +++ /dev/null @@ -1,18 +0,0 @@ -use super::{Error, Result}; -use alloy_primitives::Bytes; -use foundry_evm_core::{abi::HEVMCalls, constants::ASSUME_MAGIC_RETURN_CODE}; - -#[instrument(level = "error", name = "fuzz", target = "evm::cheatcodes", skip_all)] -pub fn apply(call: &HEVMCalls) -> Option { - if let HEVMCalls::Assume(inner) = call { - let bytes = if inner.0 { - Ok(Bytes::new()) - } else { - // `custom_bytes` will not encode with the error prefix. - Err(Error::custom_bytes(ASSUME_MAGIC_RETURN_CODE)) - }; - Some(bytes) - } else { - None - } -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/mapping.rs b/crates/evm/evm/src/inspectors/cheatcodes/mapping.rs deleted file mode 100644 index 2f881ddb78378..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/mapping.rs +++ /dev/null @@ -1,119 +0,0 @@ -use super::Cheatcodes; -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{keccak256, Address, Bytes, U256}; -use revm::{ - interpreter::{opcode, Interpreter}, - Database, EVMData, -}; -use std::collections::BTreeMap; - -#[derive(Clone, Debug, Default)] -pub struct MappingSlots { - /// Holds mapping parent (slots => slots) - pub parent_slots: BTreeMap, - - /// Holds mapping key (slots => key) - pub keys: BTreeMap, - - /// Holds mapping child (slots => slots[]) - pub children: BTreeMap>, - - /// Holds the last sha3 result `sha3_result => (data_low, data_high)`, this would only record - /// when sha3 is called with `size == 0x40`, and the lower 256 bits would be stored in - /// `data_low`, higher 256 bits in `data_high`. - /// This is needed for mapping_key detect if the slot is for some mapping and record that. - pub seen_sha3: BTreeMap, -} - -impl MappingSlots { - pub fn insert(&mut self, slot: U256) -> bool { - match self.seen_sha3.get(&slot).copied() { - Some((key, parent)) => { - if self.keys.contains_key(&slot) { - return false - } - self.keys.insert(slot, key); - self.parent_slots.insert(slot, parent); - self.children.entry(parent).or_default().push(slot); - self.insert(parent); - true - } - None => false, - } - } -} - -pub fn get_mapping_length(state: &Cheatcodes, address: Address, slot: U256) -> Bytes { - let result = match state.mapping_slots.as_ref().and_then(|dict| dict.get(&address)) { - Some(mapping_slots) => { - mapping_slots.children.get(&slot).map(|set| set.len()).unwrap_or_default() - } - None => 0, - }; - DynSolValue::Uint(U256::from(result), 256).abi_encode().into() -} - -pub fn get_mapping_slot_at(state: &Cheatcodes, address: Address, slot: U256, index: U256) -> Bytes { - let result = match state.mapping_slots.as_ref().and_then(|dict| dict.get(&address)) { - Some(mapping_slots) => mapping_slots - .children - .get(&slot) - .and_then(|set| set.get(index.to::())) - .copied() - .unwrap_or_default(), - None => U256::from(0), - }; - DynSolValue::FixedBytes(U256::from(result).into(), 256).abi_encode().into() -} - -pub fn get_mapping_key_and_parent(state: &Cheatcodes, address: Address, slot: U256) -> Bytes { - let (found, key, parent) = - match state.mapping_slots.as_ref().and_then(|dict| dict.get(&address)) { - Some(mapping_slots) => match mapping_slots.keys.get(&slot) { - Some(key) => (true, *key, mapping_slots.parent_slots[&slot]), - None => match mapping_slots.seen_sha3.get(&slot).copied() { - Some(maybe_info) => (true, maybe_info.0, maybe_info.1), - None => (false, U256::ZERO, U256::ZERO), - }, - }, - None => (false, U256::ZERO, U256::ZERO), - }; - DynSolValue::Tuple(vec![ - DynSolValue::Bool(found), - DynSolValue::FixedBytes(key.into(), 256), - DynSolValue::FixedBytes(parent.into(), 256), - ]) - .abi_encode() - .into() -} - -pub fn on_evm_step( - mapping_slots: &mut BTreeMap, - interpreter: &Interpreter, - _data: &mut EVMData<'_, DB>, -) { - match interpreter.current_opcode() { - opcode::KECCAK256 => { - if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) { - let address = interpreter.contract.address; - let offset = interpreter.stack.peek(0).expect("stack size > 1").to::(); - let low = U256::try_from_be_slice(interpreter.memory.slice(offset, 0x20)) - .expect("This should be a 32 byte slice and therefore should not fail."); - let high = U256::try_from_be_slice(interpreter.memory.slice(offset + 0x20, 0x20)) - .expect("This should be a 32 byte slice and therefore should not fail."); - let result = - U256::from_be_bytes(keccak256(interpreter.memory.slice(offset, 0x40)).0); - - mapping_slots.entry(address).or_default().seen_sha3.insert(result, (low, high)); - } - } - opcode::SSTORE => { - if let Some(mapping_slots) = mapping_slots.get_mut(&interpreter.contract.address) { - if let Ok(slot) = interpreter.stack.peek(0) { - mapping_slots.insert(slot); - } - } - } - _ => {} - } -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/mod.rs b/crates/evm/evm/src/inspectors/cheatcodes/mod.rs deleted file mode 100644 index 2911f0c0ae343..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/mod.rs +++ /dev/null @@ -1,1177 +0,0 @@ -use self::{ - env::{Broadcast, RecordedLogs}, - expect::{handle_expect_emit, handle_expect_revert, ExpectedCallType}, - mapping::MappingSlots, - util::{check_if_fixed_gas_limit, process_create, BroadcastableTransactions}, -}; -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; -use ethers::{ - abi::AbiDecode, - signers::LocalWallet, - types::{transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest}, -}; -use foundry_common::evm::Breakpoints; -use foundry_evm_core::{ - abi::HEVMCalls, - backend::{DatabaseExt, RevertDiagnostic}, - constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP_BYTES}, - utils::get_create_address, -}; -use foundry_utils::{error::SolError, types::ToEthers}; -use itertools::Itertools; -use revm::{ - interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, - primitives::{BlockEnv, TransactTo}, - EVMData, Inspector, -}; -use serde_json::Value; -use std::{ - collections::{BTreeMap, HashMap, VecDeque}, - fs::File, - io::BufReader, - ops::Range, - path::PathBuf, - sync::Arc, -}; - -/// Cheatcodes related to the execution environment. -mod env; -pub use env::{Prank, RecordAccess, RecordedLog}; -/// Assertion helpers (such as `expectEmit`) -mod expect; -pub use expect::{ - ExpectedCallData, ExpectedEmit, ExpectedRevert, MockCallDataContext, MockCallReturnData, -}; - -/// Cheatcodes that interact with the external environment (FFI etc.) -mod ext; -/// Fork related cheatcodes -mod fork; -/// File-system related cheatcodes -mod fs; -/// Cheatcodes that configure the fuzzer -mod fuzz; -/// Mapping related cheatcodes -mod mapping; -/// Parsing related cheatcodes. -/// Does not include JSON-related cheatcodes to cut complexity. -mod parse; -/// Snapshot related cheatcodes -mod snapshot; -/// Utility functions and constants. -pub mod util; -/// Wallet / key management related cheatcodes -mod wallet; - -pub use util::BroadcastableTransaction; - -mod config; -pub use config::CheatsConfig; - -mod error; -pub(crate) use error::{bail, ensure, fmt_err}; -pub use error::{Error, Result}; - -/// Tracks the expected calls per address. -/// For each address, we track the expected calls per call data. We track it in such manner -/// so that we don't mix together calldatas that only contain selectors and calldatas that contain -/// selector and arguments (partial and full matches). -/// This then allows us to customize the matching behavior for each call data on the -/// `ExpectedCallData` struct and track how many times we've actually seen the call on the second -/// element of the tuple. -pub type ExpectedCallTracker = BTreeMap, (ExpectedCallData, u64)>>; - -/// An inspector that handles calls to various cheatcodes, each with their own behavior. -/// -/// Cheatcodes can be called by contracts during execution to modify the VM environment, such as -/// mocking addresses, signatures and altering call reverts. -/// -/// Executing cheatcodes can be very powerful. Most cheatcodes are limited to evm internals, but -/// there are also cheatcodes like `ffi` which can execute arbitrary commands or `writeFile` and -/// `readFile` which can manipulate files of the filesystem. Therefore, several restrictions are -/// implemented for these cheatcodes: -/// -/// - `ffi`, and file cheatcodes are _always_ opt-in (via foundry config) and never enabled by -/// default: all respective cheatcode handlers implement the appropriate checks -/// - File cheatcodes require explicit permissions which paths are allowed for which operation, -/// see `Config.fs_permission` -/// - Only permitted accounts are allowed to execute cheatcodes in forking mode, this ensures no -/// contract deployed on the live network is able to execute cheatcodes by simply calling the -/// cheatcode address: by default, the caller, test contract and newly deployed contracts are -/// allowed to execute cheatcodes -#[derive(Clone, Debug, Default)] -pub struct Cheatcodes { - /// The block environment - /// - /// Used in the cheatcode handler to overwrite the block environment separately from the - /// execution block environment. - pub block: Option, - - /// The gas price - /// - /// Used in the cheatcode handler to overwrite the gas price separately from the gas price - /// in the execution environment. - pub gas_price: Option, - - /// Address labels - pub labels: BTreeMap, - - /// Rememebered private keys - pub script_wallets: Vec, - - /// Whether the skip cheatcode was activated - pub skip: bool, - - /// Prank information - pub prank: Option, - - /// Expected revert information - pub expected_revert: Option, - - /// Additional diagnostic for reverts - pub fork_revert_diagnostic: Option, - - /// Recorded storage reads and writes - pub accesses: Option, - - /// Recorded logs - pub recorded_logs: Option, - - /// Mocked calls - pub mocked_calls: BTreeMap>, - - /// Expected calls - pub expected_calls: ExpectedCallTracker, - - /// Expected emits - pub expected_emits: VecDeque, - - /// Map of context depths to memory offset ranges that may be written to within the call depth. - pub allowed_mem_writes: BTreeMap>>, - - /// Current broadcasting information - pub broadcast: Option, - - /// Used to correct the nonce of --sender after the initiating call. For more, check - /// `docs/scripting`. - pub corrected_nonce: bool, - - /// Scripting based transactions - pub broadcastable_transactions: BroadcastableTransactions, - - /// Additional, user configurable context this Inspector has access to when inspecting a call - pub config: Arc, - - /// Test-scoped context holding data that needs to be reset every test run - pub context: Context, - - // Commit FS changes such as file creations, writes and deletes. - // Used to prevent duplicate changes file executing non-committing calls. - pub fs_commit: bool, - - pub serialized_jsons: BTreeMap>, - - /// Records all eth deals - pub eth_deals: Vec, - - /// Holds the stored gas info for when we pause gas metering. It is an `Option>` - /// because the `call` callback in an `Inspector` doesn't get access to - /// the `revm::Interpreter` which holds the `revm::Gas` struct that - /// we need to copy. So we convert it to a `Some(None)` in `apply_cheatcode`, and once we have - /// the interpreter, we copy the gas struct. Then each time there is an execution of an - /// operation, we reset the gas. - pub gas_metering: Option>, - - /// Holds stored gas info for when we pause gas metering, and we're entering/inside - /// CREATE / CREATE2 frames. This is needed to make gas meter pausing work correctly when - /// paused and creating new contracts. - pub gas_metering_create: Option>, - - /// Holds mapping slots info - pub mapping_slots: Option>, - - /// current program counter - pub pc: usize, - /// Breakpoints supplied by the `vm.breakpoint("")` cheatcode - /// char -> pc - pub breakpoints: Breakpoints, -} - -impl Cheatcodes { - /// Creates a new `Cheatcodes` with the given settings. - #[inline] - pub fn new(config: Arc) -> Self { - Self { config, fs_commit: true, ..Default::default() } - } - - #[instrument(level = "error", name = "apply", skip_all)] - fn apply_cheatcode( - &mut self, - data: &mut EVMData<'_, DB>, - caller: Address, - call: &CallInputs, - ) -> Result { - // Decode the cheatcode call - let decoded = HEVMCalls::decode(&call.input)?; - - // ensure the caller is allowed to execute cheatcodes, - // but only if the backend is in forking mode - data.db.ensure_cheatcode_access_forking_mode(caller)?; - - let opt = env::apply(self, data, caller, &decoded) - .transpose() - .or_else(|| wallet::apply(self, data, &decoded)) - .or_else(|| parse::apply(self, data, &decoded)) - .or_else(|| expect::apply(self, data, &decoded)) - .or_else(|| fuzz::apply(&decoded)) - .or_else(|| ext::apply(self, data, &decoded)) - .or_else(|| fs::apply(self, &decoded)) - .or_else(|| snapshot::apply(data, &decoded)) - .or_else(|| fork::apply(self, data, &decoded)); - match opt { - Some(res) => res, - None => Err(fmt_err!("Unhandled cheatcode: {decoded:?}. This is a bug.")), - } - } - - /// Determines the address of the contract and marks it as allowed - /// - /// There may be cheatcodes in the constructor of the new contract, in order to allow them - /// automatically we need to determine the new address - fn allow_cheatcodes_on_create( - &self, - data: &mut EVMData<'_, DB>, - inputs: &CreateInputs, - ) { - let old_nonce = data - .journaled_state - .state - .get(&inputs.caller) - .map(|acc| acc.info.nonce) - .unwrap_or_default(); - let created_address = get_create_address(inputs, old_nonce); - - if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { - // we only grant cheat code access for new contracts if the caller also has - // cheatcode access and the new contract is created in top most call - return - } - - data.db.allow_cheatcode_access(created_address); - } - - /// Called when there was a revert. - /// - /// Cleanup any previously applied cheatcodes that altered the state in such a way that revm's - /// revert would run into issues. - pub fn on_revert(&mut self, data: &mut EVMData<'_, DB>) { - trace!(deals=?self.eth_deals.len(), "Rolling back deals"); - - // Delay revert clean up until expected revert is handled, if set. - if self.expected_revert.is_some() { - return - } - - // we only want to apply cleanup top level - if data.journaled_state.depth() > 0 { - return - } - - // Roll back all previously applied deals - // This will prevent overflow issues in revm's [`JournaledState::journal_revert`] routine - // which rolls back any transfers. - while let Some(record) = self.eth_deals.pop() { - if let Some(acc) = data.journaled_state.state.get_mut(&record.address) { - acc.info.balance = record.old_balance; - } - } - } -} - -impl Inspector for Cheatcodes { - #[inline] - fn initialize_interp( - &mut self, - _: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { - // When the first interpreter is initialized we've circumvented the balance and gas checks, - // so we apply our actual block data with the correct fees and all. - if let Some(block) = self.block.take() { - data.env.block = block; - } - if let Some(gas_price) = self.gas_price.take() { - data.env.tx.gas_price = gas_price; - } - - InstructionResult::Continue - } - - fn step( - &mut self, - interpreter: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { - self.pc = interpreter.program_counter(); - - // reset gas if gas metering is turned off - match self.gas_metering { - Some(None) => { - // need to store gas metering - self.gas_metering = Some(Some(interpreter.gas)); - } - Some(Some(gas)) => { - match interpreter.current_opcode() { - opcode::CREATE | opcode::CREATE2 => { - // set we're about to enter CREATE frame to meter its gas on first opcode - // inside it - self.gas_metering_create = Some(None) - } - opcode::STOP | opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { - // If we are ending current execution frame, we want to just fully reset gas - // otherwise weird things with returning gas from a call happen - // ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/evm_impl.rs#L190 - // - // It would be nice if we had access to the interpreter in `call_end`, as we - // could just do this there instead. - match self.gas_metering_create { - None | Some(None) => { - interpreter.gas = revm::interpreter::Gas::new(0); - } - Some(Some(gas)) => { - // If this was CREATE frame, set correct gas limit. This is needed - // because CREATE opcodes deduct additional gas for code storage, - // and deducted amount is compared to gas limit. If we set this to - // 0, the CREATE would fail with out of gas. - // - // If we however set gas limit to the limit of outer frame, it would - // cause a panic after erasing gas cost post-create. Reason for this - // is pre-create REVM records `gas_limit - (gas_limit / 64)` as gas - // used, and erases costs by `remaining` gas post-create. - // gas used ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L254-L258 - // post-create erase ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L279 - interpreter.gas = revm::interpreter::Gas::new(gas.limit()); - - // reset CREATE gas metering because we're about to exit its frame - self.gas_metering_create = None - } - } - } - _ => { - // if just starting with CREATE opcodes, record its inner frame gas - if let Some(None) = self.gas_metering_create { - self.gas_metering_create = Some(Some(interpreter.gas)) - } - - // dont monitor gas changes, keep it constant - interpreter.gas = gas; - } - } - } - _ => {} - } - - // Record writes and reads if `record` has been called - if let Some(storage_accesses) = &mut self.accesses { - match interpreter.current_opcode() { - opcode::SLOAD => { - let key = try_or_continue!(interpreter.stack().peek(0)); - storage_accesses - .reads - .entry(interpreter.contract().address) - .or_insert_with(Vec::new) - .push(key); - } - opcode::SSTORE => { - let key = try_or_continue!(interpreter.stack().peek(0)); - - // An SSTORE does an SLOAD internally - storage_accesses - .reads - .entry(interpreter.contract().address) - .or_insert_with(Vec::new) - .push(key); - storage_accesses - .writes - .entry(interpreter.contract().address) - .or_insert_with(Vec::new) - .push(key); - } - _ => (), - } - } - - // If the allowed memory writes cheatcode is active at this context depth, check to see - // if the current opcode can either mutate directly or expand memory. If the opcode at - // the current program counter is a match, check if the modified memory lies within the - // allowed ranges. If not, revert and fail the test. - if let Some(ranges) = self.allowed_mem_writes.get(&data.journaled_state.depth()) { - // The `mem_opcode_match` macro is used to match the current opcode against a list of - // opcodes that can mutate memory (either directly or expansion via reading). If the - // opcode is a match, the memory offsets that are being written to are checked to be - // within the allowed ranges. If not, the test is failed and the transaction is - // reverted. For all opcodes that can mutate memory aside from MSTORE, - // MSTORE8, and MLOAD, the size and destination offset are on the stack, and - // the macro expands all of these cases. For MSTORE, MSTORE8, and MLOAD, the - // size of the memory write is implicit, so these cases are hard-coded. - macro_rules! mem_opcode_match { - ([$(($opcode:ident, $offset_depth:expr, $size_depth:expr, $writes:expr)),*]) => { - match interpreter.current_opcode() { - //////////////////////////////////////////////////////////////// - // OPERATIONS THAT CAN EXPAND/MUTATE MEMORY BY WRITING // - //////////////////////////////////////////////////////////////// - - opcode::MSTORE => { - // The offset of the mstore operation is at the top of the stack. - let offset = try_or_continue!(interpreter.stack().peek(0)).to_ethers().as_u64(); - - // If none of the allowed ranges contain [offset, offset + 32), memory has been - // unexpectedly mutated. - if !ranges.iter().any(|range| { - range.contains(&offset) && range.contains(&(offset + 31)) - }) { - revert_helper::disallowed_mem_write(offset, 32, interpreter, ranges); - return InstructionResult::Revert - } - } - opcode::MSTORE8 => { - // The offset of the mstore8 operation is at the top of the stack. - let offset = try_or_continue!(interpreter.stack().peek(0)).to_ethers().as_u64(); - - // If none of the allowed ranges contain the offset, memory has been - // unexpectedly mutated. - if !ranges.iter().any(|range| range.contains(&offset)) { - revert_helper::disallowed_mem_write(offset, 1, interpreter, ranges); - return InstructionResult::Revert - } - } - - //////////////////////////////////////////////////////////////// - // OPERATIONS THAT CAN EXPAND MEMORY BY READING // - //////////////////////////////////////////////////////////////// - - opcode::MLOAD => { - // The offset of the mload operation is at the top of the stack - let offset = try_or_continue!(interpreter.stack().peek(0)).to_ethers().as_u64(); - - // If the offset being loaded is >= than the memory size, the - // memory is being expanded. If none of the allowed ranges contain - // [offset, offset + 32), memory has been unexpectedly mutated. - if offset >= interpreter.memory.len() as u64 && !ranges.iter().any(|range| { - range.contains(&offset) && range.contains(&(offset + 31)) - }) { - revert_helper::disallowed_mem_write(offset, 32, interpreter, ranges); - return InstructionResult::Revert - } - } - - //////////////////////////////////////////////////////////////// - // OPERATIONS WITH OFFSET AND SIZE ON STACK // - //////////////////////////////////////////////////////////////// - - $(opcode::$opcode => { - // The destination offset of the operation is at the top of the stack. - let dest_offset = try_or_continue!(interpreter.stack().peek($offset_depth)).to_ethers().as_u64(); - - // The size of the data that will be copied is the third item on the stack. - let size = try_or_continue!(interpreter.stack().peek($size_depth)).to_ethers().as_u64(); - - // If none of the allowed ranges contain [dest_offset, dest_offset + size), - // memory outside of the expected ranges has been touched. If the opcode - // only reads from memory, this is okay as long as the memory is not expanded. - let fail_cond = !ranges.iter().any(|range| { - range.contains(&dest_offset) && - range.contains(&(dest_offset + size.saturating_sub(1))) - }) && ($writes || - [dest_offset, (dest_offset + size).saturating_sub(1)].into_iter().any(|offset| { - offset >= interpreter.memory.len() as u64 - }) - ); - - // If the failure condition is met, set the output buffer to a revert string - // that gives information about the allowed ranges and revert. - if fail_cond { - revert_helper::disallowed_mem_write(dest_offset, size, interpreter, ranges); - return InstructionResult::Revert - } - })* - _ => () - } - } - } - - // Check if the current opcode can write to memory, and if so, check if the memory - // being written to is registered as safe to modify. - mem_opcode_match!([ - (CALLDATACOPY, 0, 2, true), - (CODECOPY, 0, 2, true), - (RETURNDATACOPY, 0, 2, true), - (EXTCODECOPY, 1, 3, true), - (CALL, 5, 6, true), - (CALLCODE, 5, 6, true), - (STATICCALL, 4, 5, true), - (DELEGATECALL, 4, 5, true), - (KECCAK256, 0, 1, false), - (LOG0, 0, 1, false), - (LOG1, 0, 1, false), - (LOG2, 0, 1, false), - (LOG3, 0, 1, false), - (LOG4, 0, 1, false), - (CREATE, 1, 2, false), - (CREATE2, 1, 2, false), - (RETURN, 0, 1, false), - (REVERT, 0, 1, false) - ]) - } - - // Record writes with sstore (and sha3) if `StartMappingRecording` has been called - if let Some(mapping_slots) = &mut self.mapping_slots { - mapping::on_evm_step(mapping_slots, interpreter, data) - } - - InstructionResult::Continue - } - - fn log( - &mut self, - _: &mut EVMData<'_, DB>, - address: &Address, - topics: &[B256], - data: &alloy_primitives::Bytes, - ) { - if !self.expected_emits.is_empty() { - handle_expect_emit( - self, - RawLog::new_unchecked(topics.iter().copied().collect_vec(), data.to_vec().into()), - address, - ); - } - - // Stores this log if `recordLogs` has been called - if let Some(storage_recorded_logs) = &mut self.recorded_logs { - storage_recorded_logs.entries.push(RecordedLog { - emitter: *address, - inner: RawLog::new_unchecked( - topics.iter().copied().collect_vec(), - data.to_vec().into(), - ), - }); - } - } - - fn call( - &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CallInputs, - ) -> (InstructionResult, Gas, alloy_primitives::Bytes) { - if call.contract == CHEATCODE_ADDRESS { - let gas = Gas::new(call.gas_limit); - match self.apply_cheatcode(data, call.context.caller, call) { - Ok(retdata) => (InstructionResult::Return, gas, alloy_primitives::Bytes(retdata.0)), - Err(err) => { - (InstructionResult::Revert, gas, alloy_primitives::Bytes(err.encode_error().0)) - } - } - } else if call.contract != HARDHAT_CONSOLE_ADDRESS { - // Handle expected calls - - // Grab the different calldatas expected. - if let Some(expected_calls_for_target) = self.expected_calls.get_mut(&(call.contract)) { - // Match every partial/full calldata - for (calldata, (expected, actual_count)) in expected_calls_for_target.iter_mut() { - // Increment actual times seen if... - // The calldata is at most, as big as this call's input, and - if calldata.len() <= call.input.len() && - // Both calldata match, taking the length of the assumed smaller one (which will have at least the selector), and - *calldata == call.input[..calldata.len()] && - // The value matches, if provided - expected - .value - .map_or(true, |value| value == call.transfer.value) && - // The gas matches, if provided - expected.gas.map_or(true, |gas| gas == call.gas_limit) && - // The minimum gas matches, if provided - expected.min_gas.map_or(true, |min_gas| min_gas <= call.gas_limit) - { - *actual_count += 1; - } - } - } - - // Handle mocked calls - if let Some(mocks) = self.mocked_calls.get(&call.contract) { - let ctx = MockCallDataContext { - calldata: call.input.clone().0.into(), - value: Some(call.transfer.value), - }; - if let Some(mock_retdata) = mocks.get(&ctx) { - return ( - mock_retdata.ret_type, - Gas::new(call.gas_limit), - alloy_primitives::Bytes(mock_retdata.data.clone().0), - ) - } else if let Some((_, mock_retdata)) = mocks.iter().find(|(mock, _)| { - mock.calldata.len() <= call.input.len() && - *mock.calldata == call.input[..mock.calldata.len()] && - mock.value.map_or(true, |value| value == call.transfer.value) - }) { - return ( - mock_retdata.ret_type, - Gas::new(call.gas_limit), - alloy_primitives::Bytes(mock_retdata.data.0.clone()), - ) - } - } - - // Apply our prank - if let Some(prank) = &self.prank { - if data.journaled_state.depth() >= prank.depth && - call.context.caller == prank.prank_caller - { - let mut prank_applied = false; - // At the target depth we set `msg.sender` - if data.journaled_state.depth() == prank.depth { - call.context.caller = prank.new_caller; - call.transfer.source = prank.new_caller; - prank_applied = true; - } - - // At the target depth, or deeper, we set `tx.origin` - if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = new_origin; - prank_applied = true; - } - - // If prank applied for first time, then update - if prank_applied { - if let Some(applied_prank) = prank.first_time_applied() { - self.prank = Some(applied_prank); - } - } - } - } - - // Apply our broadcast - if let Some(broadcast) = &self.broadcast { - // We only apply a broadcast *to a specific depth*. - // - // We do this because any subsequent contract calls *must* exist on chain and - // we only want to grab *this* call, not internal ones - if data.journaled_state.depth() == broadcast.depth && - call.context.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 - // broadcast.origin. - data.env.tx.caller = broadcast.new_origin; - - call.context.caller = broadcast.new_origin; - call.transfer.source = broadcast.new_origin; - // Add a `legacy` transaction to the VecDeque. We use a legacy transaction here - // because we only need the from, to, value, and data. We can later change this - // into 1559, in the cli package, relatively easily once we - // know the target chain supports EIP-1559. - if !call.is_static { - if let Err(err) = - data.journaled_state.load_account(broadcast.new_origin, data.db) - { - return ( - InstructionResult::Revert, - Gas::new(call.gas_limit), - alloy_primitives::Bytes(err.encode_string().0), - ) - } - - let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); - - let account = - data.journaled_state.state().get_mut(&broadcast.new_origin).unwrap(); - - self.broadcastable_transactions.push_back(BroadcastableTransaction { - rpc: data.db.active_fork_url(), - transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(broadcast.new_origin.to_ethers()), - to: Some(NameOrAddress::Address(call.contract.to_ethers())), - value: Some(call.transfer.value).map(|v| v.to_ethers()), - data: Some(call.input.clone().0.into()), - nonce: Some(account.info.nonce.into()), - gas: if is_fixed_gas_limit { - Some(call.gas_limit.into()) - } else { - None - }, - ..Default::default() - }), - }); - - // call_inner does not increase nonces, so we have to do it ourselves - account.info.nonce += 1; - } else if broadcast.single_call { - return ( - InstructionResult::Revert, - Gas::new(0), - DynSolValue::String("Staticcalls are not allowed after vm.broadcast. Either remove it, or use vm.startBroadcast instead." - .to_string()) - .abi_encode() - .into() - ); - } - } - } - - (InstructionResult::Continue, Gas::new(call.gas_limit), alloy_primitives::Bytes::new()) - } else { - (InstructionResult::Continue, Gas::new(call.gas_limit), alloy_primitives::Bytes::new()) - } - } - - fn call_end( - &mut self, - data: &mut EVMData<'_, DB>, - call: &CallInputs, - remaining_gas: Gas, - status: InstructionResult, - retdata: alloy_primitives::Bytes, - ) -> (InstructionResult, Gas, alloy_primitives::Bytes) { - if call.contract == CHEATCODE_ADDRESS || call.contract == HARDHAT_CONSOLE_ADDRESS { - return (status, remaining_gas, retdata) - } - - if data.journaled_state.depth() == 0 && self.skip { - return ( - InstructionResult::Revert, - remaining_gas, - alloy_primitives::Bytes(Error::custom_bytes(MAGIC_SKIP_BYTES).encode_error().0), - ) - } - - // Clean up pranks - if let Some(prank) = &self.prank { - if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = prank.prank_origin; - - // Clean single-call prank once we have returned to the original depth - if prank.single_call { - std::mem::take(&mut self.prank); - } - } - } - - // Clean up broadcast - if let Some(broadcast) = &self.broadcast { - if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = broadcast.original_origin; - - // Clean single-call broadcast once we have returned to the original depth - if broadcast.single_call { - std::mem::take(&mut self.broadcast); - } - } - } - - // Handle expected reverts - if let Some(expected_revert) = &self.expected_revert { - if data.journaled_state.depth() <= expected_revert.depth { - let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - return match handle_expect_revert( - false, - expected_revert.reason.as_ref(), - status, - retdata, - ) { - Err(error) => { - trace!(expected=?expected_revert, ?error, ?status, "Expected revert mismatch"); - ( - InstructionResult::Revert, - remaining_gas, - alloy_primitives::Bytes(error.encode_error().0), - ) - } - Ok((_, retdata)) => ( - InstructionResult::Return, - remaining_gas, - alloy_primitives::Bytes(retdata.0), - ), - } - } - } - - // At the end of the call, - // we need to check if we've found all the emits. - // We know we've found all the expected emits in the right order - // if the queue is fully matched. - // If it's not fully matched, then either: - // 1. Not enough events were emitted (we'll know this because the amount of times we - // inspected events will be less than the size of the queue) 2. The wrong events - // were emitted (The inspected events should match the size of the queue, but still some - // events will not be matched) - - // First, check that we're at the call depth where the emits were declared from. - let should_check_emits = self - .expected_emits - .iter() - .any(|expected| expected.depth == data.journaled_state.depth()) && - // Ignore staticcalls - !call.is_static; - // If so, check the emits - if should_check_emits { - // Not all emits were matched. - if self.expected_emits.iter().any(|expected| !expected.found) { - return ( - InstructionResult::Revert, - remaining_gas, - DynSolValue::String("Log != expected log".to_string()).abi_encode().into(), - ) - } else { - // All emits were found, we're good. - // Clear the queue, as we expect the user to declare more events for the next call - // if they wanna match further events. - self.expected_emits.clear() - } - } - - // if there's a revert and a previous call was diagnosed as fork related revert then we can - // return a better error here - if status == InstructionResult::Revert { - if let Some(err) = self.fork_revert_diagnostic.take() { - return ( - status, - remaining_gas, - DynSolValue::String(err.to_error_msg(&self.labels)).abi_encode().into(), - ) - } - } - - // this will ensure we don't have false positives when trying to diagnose reverts in fork - // mode - let _ = self.fork_revert_diagnostic.take(); - - // try to diagnose reverts in multi-fork mode where a call is made to an address that does - // not exist - if let TransactTo::Call(test_contract) = data.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 data.db.is_forked_mode() && - status == InstructionResult::Stop && - call.contract != test_contract - { - self.fork_revert_diagnostic = - data.db.diagnose_revert(call.contract, &data.journaled_state); - } - } - - // If the depth is 0, then this is the root call terminating - if data.journaled_state.depth() == 0 { - // If we already have a revert, we shouldn't run the below logic as it can obfuscate an - // earlier error that happened first with unrelated information about - // another error when using cheatcodes. - if status == InstructionResult::Revert { - return (status, remaining_gas, retdata) - } - - // If there's not a revert, we can continue on to run the last logic for expect* - // cheatcodes. Match expected calls - for (address, calldatas) in &self.expected_calls { - // Loop over each address, and for each address, loop over each calldata it expects. - for (calldata, (expected, actual_count)) in calldatas { - // Grab the values we expect to see - let ExpectedCallData { gas, min_gas, value, count, call_type } = expected; - let calldata = Bytes::from(calldata.clone()); - - // We must match differently depending on the type of call we expect. - match call_type { - // If the cheatcode was called with a `count` argument, - // we must check that the EVM performed a CALL with this calldata exactly - // `count` times. - ExpectedCallType::Count => { - if *count != *actual_count { - let expected_values = [ - Some(format!("data {calldata}")), - value.map(|v| format!("value {v}")), - gas.map(|g| format!("gas {g}")), - min_gas.map(|g| format!("minimum gas {g}")), - ] - .into_iter() - .flatten() - .join(" and "); - let failure_message = match status { - InstructionResult::Continue | InstructionResult::Stop | InstructionResult::Return | InstructionResult::SelfDestruct => - format!("Expected call to {address:?} with {expected_values} to be called {count} time(s), but was called {actual_count} time(s)"), - _ => format!("Expected call to {address:?} with {expected_values} to be called {count} time(s), but the call reverted instead. Ensure you're testing the happy path when using the expectCall cheatcode"), - }; - return ( - InstructionResult::Revert, - remaining_gas, - DynSolValue::String(failure_message).abi_encode().into(), - ) - } - } - // If the cheatcode was called without a `count` argument, - // we must check that the EVM performed a CALL with this calldata at least - // `count` times. The amount of times to check was - // the amount of time the cheatcode was called. - ExpectedCallType::NonCount => { - if *count > *actual_count { - let expected_values = [ - Some(format!("data {calldata}")), - value.map(|v| format!("value {v}")), - gas.map(|g| format!("gas {g}")), - min_gas.map(|g| format!("minimum gas {g}")), - ] - .into_iter() - .flatten() - .join(" and "); - let failure_message = match status { - InstructionResult::Continue | InstructionResult::Stop | InstructionResult::Return | InstructionResult::SelfDestruct => - format!("Expected call to {address:?} with {expected_values} to be called {count} time(s), but was called {actual_count} time(s)"), - _ => format!("Expected call to {address:?} with {expected_values} to be called {count} time(s), but the call reverted instead. Ensure you're testing the happy path when using the expectCall cheatcode"), - }; - return ( - InstructionResult::Revert, - remaining_gas, - DynSolValue::String(failure_message).abi_encode().into(), - ) - } - } - } - } - } - - // Check if we have any leftover expected emits - // First, if any emits were found at the root call, then we its ok and we remove them. - self.expected_emits.retain(|expected| !expected.found); - // If not empty, we got mismatched emits - if !self.expected_emits.is_empty() { - let failure_message = match status { - InstructionResult::Continue | InstructionResult::Stop | InstructionResult::Return | InstructionResult::SelfDestruct => - "Expected an emit, but no logs were emitted afterward. You might have mismatched events or not enough events were emitted.", - _ => "Expected an emit, but the call reverted instead. Ensure you're testing the happy path when using the `expectEmit` cheatcode.", - }; - return ( - InstructionResult::Revert, - remaining_gas, - DynSolValue::String(failure_message.to_string()).abi_encode().into(), - ) - } - } - - (status, remaining_gas, retdata) - } - - fn create( - &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CreateInputs, - ) -> (InstructionResult, Option
, Gas, alloy_primitives::Bytes) { - // allow cheatcodes from the address of the new contract - self.allow_cheatcodes_on_create(data, call); - - // Apply our prank - if let Some(prank) = &self.prank { - if data.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { - // At the target depth we set `msg.sender` - if data.journaled_state.depth() == prank.depth { - call.caller = prank.new_caller; - } - - // At the target depth, or deeper, we set `tx.origin` - if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = new_origin; - } - } - } - - // Apply our broadcast - if let Some(broadcast) = &self.broadcast { - if data.journaled_state.depth() >= broadcast.depth && - call.caller == broadcast.original_caller - { - if let Err(err) = data.journaled_state.load_account(broadcast.new_origin, data.db) { - return ( - InstructionResult::Revert, - None, - Gas::new(call.gas_limit), - alloy_primitives::Bytes(err.encode_string().0), - ) - } - - data.env.tx.caller = broadcast.new_origin; - - if data.journaled_state.depth() == broadcast.depth { - let (bytecode, to, nonce) = match process_create( - broadcast.new_origin, - call.init_code.clone(), - data, - call, - ) { - Ok(val) => val, - Err(err) => { - return ( - InstructionResult::Revert, - None, - Gas::new(call.gas_limit), - alloy_primitives::Bytes(err.encode_string().0), - ) - } - }; - - let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); - - self.broadcastable_transactions.push_back(BroadcastableTransaction { - rpc: data.db.active_fork_url(), - transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(broadcast.new_origin.to_ethers()), - to, - value: Some(call.value).map(|v| v.to_ethers()), - data: Some(bytecode.0.into()), - nonce: Some(nonce.into()), - gas: if is_fixed_gas_limit { - Some(call.gas_limit.into()) - } else { - None - }, - ..Default::default() - }), - }); - } - } - } - - ( - InstructionResult::Continue, - None, - Gas::new(call.gas_limit), - alloy_primitives::Bytes::new(), - ) - } - - fn create_end( - &mut self, - data: &mut EVMData<'_, DB>, - _: &CreateInputs, - status: InstructionResult, - address: Option
, - remaining_gas: Gas, - retdata: alloy_primitives::Bytes, - ) -> (InstructionResult, Option
, Gas, alloy_primitives::Bytes) { - // Clean up pranks - if let Some(prank) = &self.prank { - if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = prank.prank_origin; - - // Clean single-call prank once we have returned to the original depth - if prank.single_call { - std::mem::take(&mut self.prank); - } - } - } - - // Clean up broadcasts - if let Some(broadcast) = &self.broadcast { - if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = broadcast.original_origin; - - // Clean single-call broadcast once we have returned to the original depth - if broadcast.single_call { - std::mem::take(&mut self.broadcast); - } - } - } - - // Handle expected reverts - if let Some(expected_revert) = &self.expected_revert { - if data.journaled_state.depth() <= expected_revert.depth { - let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - return match handle_expect_revert( - true, - expected_revert.reason.as_ref(), - status, - retdata, - ) { - Ok((address, retdata)) => ( - InstructionResult::Return, - address, - remaining_gas, - alloy_primitives::Bytes(retdata.0), - ), - Err(err) => ( - InstructionResult::Revert, - None, - remaining_gas, - alloy_primitives::Bytes(err.encode_error().0), - ), - } - } - } - - (status, address, remaining_gas, retdata) - } -} - -/// Contains additional, test specific resources that should be kept for the duration of the test -#[derive(Debug, Default)] -pub struct Context { - //// Buffered readers for files opened for reading (path => BufReader mapping) - pub opened_read_files: HashMap>, -} - -/// Every time we clone `Context`, we want it to be empty -impl Clone for Context { - fn clone(&self) -> Self { - Default::default() - } -} - -impl Context { - /// Clears the context. - #[inline] - pub fn clear(&mut self) { - self.opened_read_files.clear(); - } -} - -/// Records `deal` cheatcodes -#[derive(Debug, Clone)] -pub struct DealRecord { - /// Target of the deal. - pub address: Address, - /// The balance of the address before deal was applied - pub old_balance: U256, - /// Balance after deal was applied - pub new_balance: U256, -} - -/// Helper module to store revert strings in memory -mod revert_helper { - use super::*; - - /// Helper that expands memory, stores a revert string pertaining to a disallowed memory write, - /// and sets the return range to the revert string's location in memory. - pub fn disallowed_mem_write( - dest_offset: u64, - size: u64, - interpreter: &mut Interpreter, - ranges: &[Range], - ) { - let revert_string: Bytes = DynSolValue::String(format!( - "Memory write at offset 0x{:02X} of size 0x{:02X} not allowed. Safe range: {}", - dest_offset, - size, - ranges.iter().map(|r| format!("(0x{:02X}, 0x{:02X}]", r.start, r.end)).join(" ∪ ") - )) - .abi_encode() - .into(); - mstore_revert_string(revert_string, interpreter); - } - - /// Expands memory, stores a revert string, and sets the return range to the revert - /// string's location in memory. - fn mstore_revert_string(bytes: Bytes, interpreter: &mut Interpreter) { - let starting_offset = interpreter.memory.len(); - interpreter.memory.resize(starting_offset + bytes.len()); - interpreter.memory.set_data(starting_offset, 0, bytes.len(), &bytes); - interpreter.return_offset = starting_offset; - interpreter.return_len = interpreter.memory.len() - starting_offset - } -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/parse.rs b/crates/evm/evm/src/inspectors/cheatcodes/parse.rs deleted file mode 100644 index d91d9a9d7c591..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/parse.rs +++ /dev/null @@ -1,161 +0,0 @@ -use super::{fmt_err, Cheatcodes, Result}; -use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::{FixedBytes, I256, U256}; -use foundry_evm_core::abi::HEVMCalls; -use foundry_macros::UIfmt; -use revm::{Database, EVMData}; - -pub fn parse(s: &str, ty: &DynSolType) -> Result { - parse_token(s, ty) - .map(|token| token.abi_encode().into()) - .map_err(|e| fmt_err!("Failed to parse `{s}` as type `{ty}`: {e}")) -} - -pub fn parse_array(values: I, ty: &DynSolType) -> Result -where - I: IntoIterator, - T: AsRef, -{ - let mut values = values.into_iter(); - match values.next() { - Some(first) if !first.as_ref().is_empty() => { - let tokens = std::iter::once(first) - .chain(values) - .map(|v| parse_token(v.as_ref(), ty)) - .collect::, _>>()?; - Ok(DynSolValue::Array(tokens).abi_encode().into()) - } - // return the empty encoded Bytes when values is empty or the first element is empty - _ => Ok(DynSolValue::String(String::new()).abi_encode().into()), - } -} - -fn parse_token(s: &str, ty: &DynSolType) -> Result { - match ty { - DynSolType::Bool => { - s.to_ascii_lowercase().parse().map(DynSolValue::Bool).map_err(|e| e.to_string()) - } - DynSolType::Uint(256) => { - s.parse().map(|u| DynSolValue::Uint(u, 256)).map_err(|e| e.to_string()) - } - DynSolType::Int(256) => parse_int(s).map(|s| DynSolValue::Int(I256::from_raw(s), 256)), - DynSolType::Address => s.parse().map(DynSolValue::Address).map_err(|e| e.to_string()), - DynSolType::FixedBytes(32) => { - let mut val = s.to_string(); - // Previously with ethabi, strings were automatically padded to 32 bytes if it wasn't - // the case. This is not the case anymore, so we need to do it manually for - // compatibility reasons. Get the total length, either for a prefixed or - // unprefixed string. - let total_len = if val.starts_with("0x") { 66 } else { 64 }; - // Pad accordingly until it's the correct size. - if val.len() != total_len { - while val.len() < total_len { - val.push('0') - } - } - val.parse::>() - .map(|b| DynSolValue::FixedBytes(b, 32)) - .map_err(|e| e.to_string()) - } - DynSolType::Bytes => parse_bytes(s).map(DynSolValue::Bytes), - DynSolType::String => Ok(DynSolValue::String(s.to_string())), - _ => Err("unsupported type".into()), - } -} - -fn parse_int(s: &str) -> Result { - // Only parse hex strings prefixed by 0x or decimal integer strings - - // Hex string may start with "0x", "+0x", or "-0x" which needs to be stripped for - // `I256::from_hex_str` - if s.starts_with("0x") || s.starts_with("+0x") || s.starts_with("-0x") { - return I256::from_hex_str(s).map_err(|err| err.to_string()).map(|v| v.into_raw()) - } - - // Decimal string may start with '+' or '-' followed by numeric characters - if s.chars().all(|c| c.is_numeric() || c == '+' || c == '-') { - return match I256::from_dec_str(s) { - Ok(val) => Ok(val), - Err(dec_err) => s.parse::().map_err(|hex_err| { - format!("could not parse value as decimal or hex: {dec_err}, {hex_err}") - }), - } - .map(|v| v.into_raw()) - }; - - // Throw if string doesn't conform to either of the two patterns - Err("Invalid conversion. Make sure that either the hex string or the decimal number passed is valid.".to_string()) -} - -fn parse_bytes(s: &str) -> Result, String> { - hex::decode(s).map_err(|e| e.to_string()) -} - -#[instrument(level = "error", name = "util", target = "evm::cheatcodes", skip_all)] -pub fn apply( - _state: &mut Cheatcodes, - _data: &mut EVMData<'_, DB>, - call: &HEVMCalls, -) -> Option { - Some(match call { - HEVMCalls::ToString0(inner) => { - Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) - } - HEVMCalls::ToString1(inner) => { - Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) - } - HEVMCalls::ToString2(inner) => { - Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) - } - HEVMCalls::ToString3(inner) => { - Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) - } - HEVMCalls::ToString4(inner) => { - Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) - } - HEVMCalls::ToString5(inner) => { - Ok(DynSolValue::String(inner.0.pretty()).abi_encode().into()) - } - HEVMCalls::ParseBytes(inner) => parse(&inner.0, &DynSolType::Bytes), - HEVMCalls::ParseAddress(inner) => parse(&inner.0, &DynSolType::Address), - HEVMCalls::ParseUint(inner) => parse(&inner.0, &DynSolType::Uint(256)), - HEVMCalls::ParseInt(inner) => parse(&inner.0, &DynSolType::Int(256)), - HEVMCalls::ParseBytes32(inner) => parse(&inner.0, &DynSolType::FixedBytes(32)), - HEVMCalls::ParseBool(inner) => parse(&inner.0, &DynSolType::Bool), - _ => return None, - }) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_uint_env() { - let pk = "0x10532cc9d0d992825c3f709c62c969748e317a549634fb2a9fa949326022e81f"; - let val: U256 = pk.parse().unwrap(); - let parsed = parse(pk, &DynSolType::Uint(256)).unwrap(); - let decoded = DynSolType::Uint(256).abi_decode(&parsed).unwrap().as_uint().unwrap().0; - assert_eq!(val, decoded); - - let parsed = parse(pk, &DynSolType::Uint(256)).unwrap(); - let decoded = DynSolType::Uint(256).abi_decode(&parsed).unwrap().as_uint().unwrap().0; - assert_eq!(val, decoded); - - let parsed = parse("1337", &DynSolType::Uint(256)).unwrap(); - let decoded = DynSolType::Uint(256).abi_decode(&parsed).unwrap().as_uint().unwrap().0; - assert_eq!(U256::from(1337u64), decoded); - } - - #[test] - fn test_int_env() { - let val = U256::from(100u64); - let parsed = parse(&val.to_string(), &DynSolType::Int(256)).unwrap(); - let decoded = DynSolType::Int(256).abi_decode(&parsed).unwrap().as_int().unwrap().0; - assert_eq!(val, decoded.into_raw()); - - let parsed = parse("100", &DynSolType::Int(256)).unwrap(); - let decoded = DynSolType::Int(256).abi_decode(&parsed).unwrap().as_int().unwrap().0; - assert_eq!(U256::from(100u64), decoded.into_raw()); - } -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/snapshot.rs b/crates/evm/evm/src/inspectors/cheatcodes/snapshot.rs deleted file mode 100644 index ac37696474158..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/snapshot.rs +++ /dev/null @@ -1,30 +0,0 @@ -use super::Result; -use alloy_dyn_abi::DynSolValue; -use foundry_evm_core::{abi::HEVMCalls, backend::DatabaseExt}; -use foundry_utils::types::ToAlloy; -use revm::EVMData; - -/// Handles fork related cheatcodes -#[instrument(level = "error", name = "snapshot", target = "evm::cheatcodes", skip_all)] -pub fn apply(data: &mut EVMData<'_, DB>, call: &HEVMCalls) -> Option { - Some(match call { - HEVMCalls::Snapshot(_) => { - Ok(DynSolValue::Uint(data.db.snapshot(&data.journaled_state, data.env), 256) - .abi_encode() - .into()) - } - HEVMCalls::RevertTo(snapshot) => { - let res = if let Some(journaled_state) = - data.db.revert(snapshot.0.to_alloy(), &data.journaled_state, data.env) - { - // we reset the evm's journaled_state to the state of the snapshot previous state - data.journaled_state = journaled_state; - true - } else { - false - }; - Ok(DynSolValue::Bool(res).abi_encode().into()) - } - _ => return None, - }) -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/util.rs b/crates/evm/evm/src/inspectors/cheatcodes/util.rs deleted file mode 100644 index 93ce81dc1c816..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/util.rs +++ /dev/null @@ -1,137 +0,0 @@ -use super::{ensure, Result}; -use alloy_primitives::{Address, Bytes, U256}; -use bytes::{BufMut, BytesMut}; -use ethers::{ - core::k256::elliptic_curve::Curve, - prelude::k256::{ecdsa::SigningKey, elliptic_curve::bigint::Encoding, Secp256k1}, - types::{transaction::eip2718::TypedTransaction, NameOrAddress}, -}; -use foundry_common::RpcUrl; -use foundry_evm_core::{ - backend::{DatabaseError, DatabaseExt, DatabaseResult}, - constants::DEFAULT_CREATE2_DEPLOYER, -}; -use foundry_utils::types::ToEthers; -use revm::{interpreter::CreateInputs, primitives::Account, Database, EVMData, JournaledState}; -use std::collections::VecDeque; - -/// Helps collecting transactions from different forks. -#[derive(Debug, Clone, Default)] -pub struct BroadcastableTransaction { - pub rpc: Option, - pub transaction: TypedTransaction, -} - -pub type BroadcastableTransactions = VecDeque; - -/// Applies the given function `f` to the `revm::Account` belonging to the `addr` -/// -/// This will ensure the `Account` is loaded and `touched`, see [`JournaledState::touch`] -pub fn with_journaled_account( - journaled_state: &mut JournaledState, - db: &mut DB, - addr: Address, - mut f: F, -) -> Result -where - F: FnMut(&mut Account) -> R, -{ - journaled_state.load_account(addr, db)?; - journaled_state.touch(&addr); - let account = journaled_state.state.get_mut(&addr).expect("account loaded;"); - Ok(f(account)) -} - -pub fn process_create( - broadcast_sender: Address, - bytecode: Bytes, - data: &mut EVMData<'_, DB>, - call: &mut CreateInputs, -) -> DatabaseResult<(Bytes, Option, u64)> -where - DB: Database, -{ - match call.scheme { - revm::primitives::CreateScheme::Create => { - call.caller = broadcast_sender; - - Ok((bytecode, None, data.journaled_state.account(broadcast_sender).info.nonce)) - } - revm::primitives::CreateScheme::Create2 { salt } => { - // Sanity checks for our CREATE2 deployer - data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?; - - let info = &data.journaled_state.account(DEFAULT_CREATE2_DEPLOYER).info; - match &info.code { - Some(code) => { - if code.is_empty() { - trace!(create2=?DEFAULT_CREATE2_DEPLOYER, "Empty Create 2 deployer code"); - return Err(DatabaseError::MissingCreate2Deployer) - } - } - None => { - // forked db - trace!(create2=?DEFAULT_CREATE2_DEPLOYER, "Missing Create 2 deployer code"); - if data.db.code_by_hash(info.code_hash)?.is_empty() { - return Err(DatabaseError::MissingCreate2Deployer) - } - } - } - - call.caller = DEFAULT_CREATE2_DEPLOYER; - - // We have to increment the nonce of the user address, since this create2 will be done - // by the create2_deployer - let account = data.journaled_state.state().get_mut(&broadcast_sender).unwrap(); - let nonce = account.info.nonce; - account.info.nonce += 1; - - // Proxy deployer requires the data to be on the following format `salt.init_code` - let mut calldata = BytesMut::with_capacity(32 + bytecode.len()); - let salt = salt.to_ethers(); - let mut salt_bytes = [0u8; 32]; - salt.to_big_endian(&mut salt_bytes); - calldata.put_slice(&salt_bytes); - calldata.put(bytecode); - - Ok(( - calldata.freeze().into(), - Some(NameOrAddress::Address(DEFAULT_CREATE2_DEPLOYER.to_ethers())), - nonce, - )) - } - } -} - -pub fn parse_private_key(private_key: U256) -> Result { - ensure!(private_key != U256::ZERO, "Private key cannot be 0."); - ensure!( - private_key < U256::from_be_bytes(Secp256k1::ORDER.to_be_bytes()), - "Private key must be less than the secp256k1 curve order \ - (115792089237316195423570985008687907852837564279074904382605163141518161494337).", - ); - let bytes = private_key.to_be_bytes(); - SigningKey::from_bytes((&bytes).into()).map_err(Into::into) -} - -// Determines if the gas limit on a given call was manually set in the script and should therefore -// not be overwritten by later estimations -pub fn check_if_fixed_gas_limit( - data: &EVMData<'_, DB>, - call_gas_limit: u64, -) -> bool { - // If the gas limit was not set in the source code it is set to the estimated gas left at the - // time of the call, which should be rather close to configured gas limit. - // TODO: Find a way to reliably make this determination. (for example by - // generating it in the compilation or evm simulation process) - U256::from(data.env.tx.gas_limit) > data.env.block.gas_limit && - U256::from(call_gas_limit) <= data.env.block.gas_limit - // Transfers in forge scripts seem to be estimated at 2300 by revm leading to "Intrinsic - // gas too low" failure when simulated on chain - && call_gas_limit > 2300 -} - -/// Small utility function that checks if an address is a potential precompile. -pub fn is_potential_precompile(address: Address) -> bool { - address < Address::with_last_byte(10) && address != Address::ZERO -} diff --git a/crates/evm/evm/src/inspectors/cheatcodes/wallet.rs b/crates/evm/evm/src/inspectors/cheatcodes/wallet.rs deleted file mode 100644 index 87105ea4a19be..0000000000000 --- a/crates/evm/evm/src/inspectors/cheatcodes/wallet.rs +++ /dev/null @@ -1,233 +0,0 @@ -use super::{ensure, Cheatcodes, Result}; -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{keccak256, B256, U256}; -use ethers::{ - core::k256::elliptic_curve::Curve, - prelude::{ - k256::{ - ecdsa::SigningKey, - elliptic_curve::{bigint::Encoding, sec1::ToEncodedPoint}, - Secp256k1, - }, - LocalWallet, Signer, - }, - signers::{ - coins_bip39::{ - ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, - Korean, Portuguese, Spanish, Wordlist, - }, - MnemonicBuilder, - }, - utils, -}; -use foundry_evm_core::abi::HEVMCalls; -use foundry_utils::types::{ToAlloy, ToEthers}; -use revm::{Database, EVMData}; -use std::str::FromStr; - -/// The BIP32 default derivation path prefix. -const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; - -pub fn parse_private_key(private_key: U256) -> Result { - ensure!(private_key != U256::ZERO, "Private key cannot be 0."); - ensure!( - private_key < U256::from_be_bytes(Secp256k1::ORDER.to_be_bytes()), - "Private key must be less than the secp256k1 curve order \ - (115792089237316195423570985008687907852837564279074904382605163141518161494337).", - ); - let bytes = private_key.to_be_bytes(); - SigningKey::from_bytes((&bytes).into()).map_err(Into::into) -} - -fn addr(private_key: U256) -> Result { - let key = parse_private_key(private_key)?; - let addr = utils::secret_key_to_address(&key); - Ok(DynSolValue::Address(addr.to_alloy()).abi_encode().into()) -} - -fn sign(private_key: U256, digest: B256, chain_id: U256) -> Result { - let key = parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.to::()); - - // The `ecrecover` precompile does not use EIP-155 - let sig = wallet.sign_hash(digest.to_ethers())?; - let recovered = sig.recover(digest.to_ethers())?.to_alloy(); - - assert_eq!(recovered, wallet.address().to_alloy()); - - let mut r_bytes = [0u8; 32]; - let mut s_bytes = [0u8; 32]; - sig.r.to_big_endian(&mut r_bytes); - sig.s.to_big_endian(&mut s_bytes); - - Ok(DynSolValue::Tuple(vec![ - DynSolValue::Uint(U256::from(sig.v), 8), - DynSolValue::FixedBytes(r_bytes.into(), 32), - DynSolValue::FixedBytes(s_bytes.into(), 32), - ]) - .abi_encode() - .into()) -} - -/// Using a given private key, return its public ETH address, its public key affine x and y -/// coodinates, and its private key (see the 'Wallet' struct) -/// -/// If 'label' is set to 'Some()', assign that label to the associated ETH address in state -fn create_wallet(private_key: U256, label: Option, state: &mut Cheatcodes) -> Result { - let key = parse_private_key(private_key)?; - let addr = utils::secret_key_to_address(&key); - - let pub_key = key.verifying_key().as_affine().to_encoded_point(false); - let pub_key_x = pub_key.x().ok_or("No x coordinate was found")?; - let pub_key_y = pub_key.y().ok_or("No y coordinate was found")?; - - let pub_key_x = U256::from_be_bytes((*pub_key_x).into()); - let pub_key_y = U256::from_be_bytes((*pub_key_y).into()); - - if let Some(label) = label { - state.labels.insert(addr.to_alloy(), label); - } - - Ok(DynSolValue::Tuple(vec![ - DynSolValue::Address(addr.to_alloy()), - DynSolValue::Uint(pub_key_x, 256), - DynSolValue::Uint(pub_key_y, 256), - DynSolValue::Uint(private_key, 256), - ]) - .abi_encode() - .into()) -} - -enum WordlistLang { - ChineseSimplified, - ChineseTraditional, - Czech, - English, - French, - Italian, - Japanese, - Korean, - Portuguese, - Spanish, -} - -impl FromStr for WordlistLang { - type Err = String; - - fn from_str(input: &str) -> Result { - match input { - "chinese_simplified" => Ok(Self::ChineseSimplified), - "chinese_traditional" => Ok(Self::ChineseTraditional), - "czech" => Ok(Self::Czech), - "english" => Ok(Self::English), - "french" => Ok(Self::French), - "italian" => Ok(Self::Italian), - "japanese" => Ok(Self::Japanese), - "korean" => Ok(Self::Korean), - "portuguese" => Ok(Self::Portuguese), - "spanish" => Ok(Self::Spanish), - _ => Err(format!("the language `{}` has no wordlist", input)), - } - } -} - -fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { - let derivation_path = - if path.ends_with('/') { format!("{path}{index}") } else { format!("{path}/{index}") }; - - let wallet = MnemonicBuilder::::default() - .phrase(mnemonic) - .derivation_path(&derivation_path)? - .build()?; - - let private_key = match U256::try_from_be_slice(wallet.signer().to_bytes().as_slice()) { - Some(key) => key, - None => return Err("Failed to parse private key.".to_string().into()), - }; - - Ok(DynSolValue::Uint(private_key, 256).abi_encode().into()) -} - -fn derive_key_with_wordlist(mnemonic: &str, path: &str, index: u32, lang: &str) -> Result { - let lang = WordlistLang::from_str(lang)?; - match lang { - WordlistLang::ChineseSimplified => derive_key::(mnemonic, path, index), - WordlistLang::ChineseTraditional => derive_key::(mnemonic, path, index), - WordlistLang::Czech => derive_key::(mnemonic, path, index), - WordlistLang::English => derive_key::(mnemonic, path, index), - WordlistLang::French => derive_key::(mnemonic, path, index), - WordlistLang::Italian => derive_key::(mnemonic, path, index), - WordlistLang::Japanese => derive_key::(mnemonic, path, index), - WordlistLang::Korean => derive_key::(mnemonic, path, index), - WordlistLang::Portuguese => derive_key::(mnemonic, path, index), - WordlistLang::Spanish => derive_key::(mnemonic, path, index), - } -} - -fn remember_key(state: &mut Cheatcodes, private_key: U256, chain_id: U256) -> Result { - let key = parse_private_key(private_key)?; - let wallet = LocalWallet::from(key).with_chain_id(chain_id.to::()); - let address = wallet.address(); - - state.script_wallets.push(wallet); - - Ok(DynSolValue::Address(address.to_alloy()).abi_encode().into()) -} - -#[instrument(level = "error", name = "util", target = "evm::cheatcodes", skip_all)] -pub fn apply( - state: &mut Cheatcodes, - data: &mut EVMData<'_, DB>, - call: &HEVMCalls, -) -> Option { - Some(match call { - HEVMCalls::Addr(inner) => addr(inner.0.to_alloy()), - // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given private key - HEVMCalls::Sign0(inner) => { - sign(inner.0.to_alloy(), inner.1.into(), U256::from(data.env.cfg.chain_id)) - } - // [function createWallet(string)] Used to derive private key and label the wallet with the - // same string - HEVMCalls::CreateWallet0(inner) => { - create_wallet(U256::from_be_bytes(keccak256(&inner.0).0), Some(inner.0.clone()), state) - } - // [function createWallet(uint256)] creates a new wallet with the given private key - HEVMCalls::CreateWallet1(inner) => create_wallet(inner.0.to_alloy(), None, state), - // [function createWallet(uint256,string)] creates a new wallet with the given private key - // and labels it with the given string - HEVMCalls::CreateWallet2(inner) => { - create_wallet(inner.0.to_alloy(), Some(inner.1.clone()), state) - } - // [function sign(uint256,bytes32)] Used to sign bytes32 digests using the given Wallet's - // private key - HEVMCalls::Sign1(inner) => { - sign(inner.0.private_key.to_alloy(), inner.1.into(), U256::from(data.env.cfg.chain_id)) - } - HEVMCalls::DeriveKey0(inner) => { - derive_key::(&inner.0, DEFAULT_DERIVATION_PATH_PREFIX, inner.1) - } - HEVMCalls::DeriveKey1(inner) => derive_key::(&inner.0, &inner.1, inner.2), - HEVMCalls::DeriveKey2(inner) => { - derive_key_with_wordlist(&inner.0, DEFAULT_DERIVATION_PATH_PREFIX, inner.1, &inner.2) - } - HEVMCalls::DeriveKey3(inner) => { - derive_key_with_wordlist(&inner.0, &inner.1, inner.2, &inner.3) - } - HEVMCalls::RememberKey(inner) => { - remember_key(state, inner.0.to_alloy(), U256::from(data.env.cfg.chain_id)) - } - HEVMCalls::Label(inner) => { - state.labels.insert(inner.0.to_alloy(), inner.1.clone()); - Ok(Default::default()) - } - HEVMCalls::GetLabel(inner) => { - let label = state - .labels - .get(&inner.0.to_alloy()) - .cloned() - .unwrap_or_else(|| format!("unlabeled:{:?}", inner.0)); - Ok(DynSolValue::String(label).abi_encode().into()) - } - _ => return None, - }) -} diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index e4c1e67ec8f04..0e6df101f81b6 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -5,7 +5,7 @@ use foundry_evm_core::{ debug::{DebugArena, DebugNode, DebugStep, Instruction}, utils::{gas_used, get_create_address, CallKind}, }; -use foundry_utils::error::SolError; +use foundry_utils::error::ErrorExt; use revm::{ interpreter::{ opcode::{self, spec_opcode_gas}, diff --git a/crates/evm/evm/src/inspectors/mod.rs b/crates/evm/evm/src/inspectors/mod.rs index 89ba94cfa243a..888f80bd6e9d9 100644 --- a/crates/evm/evm/src/inspectors/mod.rs +++ b/crates/evm/evm/src/inspectors/mod.rs @@ -1,25 +1,13 @@ //! EVM inspectors. +pub use foundry_cheatcodes::{impls as cheatcodes, Cheatcodes, CheatsConfig}; pub use foundry_evm_coverage::CoverageCollector; pub use foundry_evm_fuzz::Fuzzer; pub use foundry_evm_traces::Tracer; -macro_rules! try_or_continue { - ($e:expr) => { - match $e { - Ok(v) => v, - Err(_) => return InstructionResult::Continue, - } - }; -} - mod access_list; pub use access_list::AccessListTracer; -#[allow(unreachable_pub)] -pub mod cheatcodes; -pub use cheatcodes::{Cheatcodes, CheatsConfig}; - mod chisel_state; pub use chisel_state::ChiselState; diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index d16086c4f0e05..936cf2a14f506 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -301,7 +301,7 @@ impl CoverageArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) + .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone())) .with_test_options(TestOptions { fuzz: config.fuzz, ..Default::default() }) .set_coverage(true) .build(root.clone(), output, env, evm_opts)?; diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index df7afd11a6da0..e03f639152906 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -10,7 +10,7 @@ use eyre::Result; use forge::{ backend::Backend, executors::ExecutorBuilder, - inspectors::{cheatcodes::util::BroadcastableTransactions, CheatsConfig}, + inspectors::{cheatcodes::BroadcastableTransactions, CheatsConfig}, traces::{CallTraceDecoder, Traces}, utils::CallKind, }; @@ -227,8 +227,8 @@ impl ScriptArgs { // Identify all contracts created during the call. if traces.is_empty() { eyre::bail!( - "Forge script requires tracing enabled to collect created contracts." - ) + "forge script requires tracing enabled to collect created contracts" + ); } for (_kind, trace) in &mut traces { @@ -256,7 +256,9 @@ impl ScriptArgs { let sender = script_config.evm_opts.sender; if !shell::verbosity().is_silent() { - eprintln!("\n## Setting up ({}) EVMs.", script_config.total_rpcs.len()); + let n = script_config.total_rpcs.len(); + let s = if n != 1 { "s" } else { "" }; + println!("\n## Setting up {n} EVM{s}."); } let futs = script_config @@ -318,7 +320,7 @@ impl ScriptArgs { if let SimulationStage::Local = stage { builder = builder.inspectors(|stack| { stack.debug(self.debug).cheatcodes( - CheatsConfig::new(&script_config.config, &script_config.evm_opts).into(), + CheatsConfig::new(&script_config.config, script_config.evm_opts.clone()).into(), ) }); } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 81faab77ef658..48ec70fdcf410 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -49,7 +49,7 @@ use foundry_config::{ use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, decode, - inspectors::cheatcodes::{util::BroadcastableTransactions, BroadcastableTransaction}, + inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, }; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 18dc53e1afcfc..7b389e59fec59 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -196,7 +196,7 @@ impl TestArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new(&config, &evm_opts)) + .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone())) .with_test_options(test_options.clone()); let mut runner = runner_builder.clone().build( diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 4e31f864a017b..cad8dbb868d4e 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -722,7 +722,7 @@ contract A { .unwrap(); cmd.args(["build", "--force"]); - let out = cmd.stdout(); + let out = cmd.stdout_lossy(); // no warnings assert!(out.trim().contains("Compiler run successful!")); assert!(!out.trim().contains("Compiler run successful with warnings:")); @@ -730,7 +730,7 @@ contract A { // don't ignore errors let config = Config { ignored_error_codes: vec![], ..Default::default() }; prj.write_config(config); - let out = cmd.stdout(); + let out = cmd.stdout_lossy(); assert!(out.trim().contains("Compiler run successful with warnings:")); assert!( @@ -758,7 +758,7 @@ contract A { .unwrap(); cmd.args(["build", "--force"]); - let out = cmd.stdout(); + let out = cmd.stdout_lossy(); // there are no errors assert!(out.trim().contains("Compiler run successful")); assert!(out.trim().contains("Compiler run successful with warnings:")); @@ -775,7 +775,7 @@ contract A { ..Default::default() }; prj.write_config(config); - let out = cmd.stdout(); + let out = cmd.stdout_lossy(); assert!(out.trim().contains("Compiler run successful!")); assert!(!out.trim().contains("Compiler run successful with warnings:")); @@ -1155,21 +1155,21 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let first_out = cmd.arg("test").arg("--gas-report").stdout(); + let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); // cmd.arg("test").arg("--gas-report").print_output(); cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); cmd.forge_fuse(); - let second_out = cmd.arg("test").arg("--gas-report").stdout(); + let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(second_out.contains("foo") && second_out.contains("bar") && second_out.contains("baz")); // cmd.arg("test").arg("--gas-report").print_output(); cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); cmd.forge_fuse(); - let third_out = cmd.arg("test").arg("--gas-report").stdout(); + let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); // cmd.arg("test").arg("--gas-report").print_output(); @@ -1183,7 +1183,7 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let fourth_out = cmd.arg("test").arg("--gas-report").stdout(); + let fourth_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(fourth_out.contains("foo") && fourth_out.contains("bar") && fourth_out.contains("baz")); // cmd.arg("test").arg("--gas-report").print_output(); }); @@ -1288,7 +1288,7 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let first_out = cmd.arg("test").arg("--gas-report").stdout(); + let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(first_out.contains("foo") && !first_out.contains("bar") && !first_out.contains("baz")); // cmd.arg("test").arg("--gas-report").print_output(); @@ -1299,7 +1299,7 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let second_out = cmd.arg("test").arg("--gas-report").stdout(); + let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!( !second_out.contains("foo") && second_out.contains("bar") && !second_out.contains("baz") ); @@ -1312,7 +1312,7 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let third_out = cmd.arg("test").arg("--gas-report").stdout(); + let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(!third_out.contains("foo") && !third_out.contains("bar") && third_out.contains("baz")); // cmd.arg("test").arg("--gas-report").print_output(); }); @@ -1417,7 +1417,7 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let first_out = cmd.arg("test").arg("--gas-report").stdout(); + let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(!first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); // cmd.arg("test").arg("--gas-report").print_output(); @@ -1429,7 +1429,7 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let second_out = cmd.arg("test").arg("--gas-report").stdout(); + let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!( second_out.contains("foo") && !second_out.contains("bar") && second_out.contains("baz") ); @@ -1447,7 +1447,7 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let third_out = cmd.arg("test").arg("--gas-report").stdout(); + let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); }); @@ -1609,7 +1609,7 @@ forgetest_init!(can_build_skip_contracts, |prj: TestProject, mut cmd: TestComman .join("tests/fixtures/can_build_skip_contracts.stdout"), ); // re-run command - let out = cmd.stdout(); + let out = cmd.stdout_lossy(); // unchanged assert!(out.trim().contains("No files changed, compilation skipped"), "{}", out); @@ -1641,7 +1641,7 @@ function test_run() external {} // checks that build --sizes includes all contracts even if unchanged forgetest_init!(can_build_sizes_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { cmd.args(["build", "--sizes"]); - let out = cmd.stdout(); + let out = cmd.stdout_lossy(); // contains: Counter ┆ 0.247 ┆ 24.329 assert!(out.contains(TEMPLATE_CONTRACT)); @@ -1649,20 +1649,20 @@ forgetest_init!(can_build_sizes_repeatedly, |_prj: TestProject, mut cmd: TestCom // get the entire table let table = out.split("Compiler run successful!").nth(1).unwrap().trim(); - let unchanged = cmd.stdout(); + let unchanged = cmd.stdout_lossy(); assert!(unchanged.contains(table), "{}", table); }); // checks that build --names includes all contracts even if unchanged forgetest_init!(can_build_names_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { cmd.args(["build", "--names"]); - let out = cmd.stdout(); + let out = cmd.stdout_lossy(); assert!(out.contains(TEMPLATE_CONTRACT)); // get the entire list let list = out.split("Compiler run successful!").nth(1).unwrap().trim(); - let unchanged = cmd.stdout(); + let unchanged = cmd.stdout_lossy(); assert!(unchanged.contains(list), "{}", list); }); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index b212dc83b4c72..461a77d5a0604 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -129,7 +129,7 @@ forgetest!( cmd.arg("config"); let expected = Config::load_with_root(prj.root()).to_string_pretty().unwrap().trim().to_string(); - assert_eq!(expected, cmd.stdout().trim().to_string()); + assert_eq!(expected, cmd.stdout_lossy().trim().to_string()); } ); @@ -160,7 +160,7 @@ forgetest_init!( cmd.arg("config"); let expected = profile.to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout().trim().to_string()); + pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); // remappings work let remappings_txt = @@ -208,7 +208,7 @@ forgetest_init!( cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); let expected = profile.into_basic().to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout().trim().to_string()); + pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); } ); @@ -234,7 +234,7 @@ forgetest_init!( cmd.arg("config"); let expected = profile.to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout().trim().to_string()); + pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); let install = |cmd: &mut TestCommand, dep: &str| { cmd.forge_fuse().args(["install", dep, "--no-commit"]); @@ -267,7 +267,7 @@ forgetest_init!( cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); let expected = profile.into_basic().to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout().trim().to_string()); + pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); } ); diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index 2320b793849e3..717fb05b74d91 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -15,40 +15,40 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); tester - .load_private_keys(vec![0, 1]) + .load_private_keys([0, 1]) .await .add_sig("MultiChainBroadcastNoLink", "deploy(string memory,string memory)") .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) .broadcast(ScriptOutcome::OkBroadcast); - assert!( - 1 == api1 - .transaction_count(tester.accounts_pub[0].to_ethers(), None) + assert_eq!( + api1.transaction_count(tester.accounts_pub[0].to_ethers(), None) .await .unwrap() - .as_u32() + .as_u32(), + 1 ); - assert!( - 1 == api1 - .transaction_count(tester.accounts_pub[1].to_ethers(), None) + assert_eq!( + api1.transaction_count(tester.accounts_pub[1].to_ethers(), None) .await .unwrap() - .as_u32() + .as_u32(), + 1 ); - assert!( - 2 == api2 - .transaction_count(tester.accounts_pub[0].to_ethers(), None) + assert_eq!( + api2.transaction_count(tester.accounts_pub[0].to_ethers(), None) .await .unwrap() - .as_u32() + .as_u32(), + 2 ); - assert!( - 3 == api2 - .transaction_count(tester.accounts_pub[1].to_ethers(), None) + assert_eq!( + api2.transaction_count(tester.accounts_pub[1].to_ethers(), None) .await .unwrap() - .as_u32() + .as_u32(), + 3 ); } ); @@ -61,7 +61,7 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); tester - .load_private_keys(vec![0, 1]) + .load_private_keys([0, 1]) .await .add_deployer(0) .add_sig("MultiChainBroadcastLink", "deploy(string memory,string memory)") @@ -78,7 +78,7 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); tester - .load_private_keys(vec![0, 1]) + .load_private_keys([0, 1]) .await .add_deployer(0) .add_sig("MultiChainBroadcastNoLink", "deployError(string memory,string memory)") diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 0cd73f95b8797..3b8a235b1df96 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -8,7 +8,10 @@ use foundry_test_utils::{ util::{OutputExt, TestCommand, TestProject}, ScriptOutcome, ScriptTester, }; -use foundry_utils::{rpc, types::ToAlloy}; +use foundry_utils::{ + rpc, + types::{ToAlloy, ToEthers}, +}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; @@ -425,12 +428,12 @@ forgetest_async!(can_deploy_script_without_lib, |prj: TestProject, cmd: TestComm let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0, 1]) + .load_private_keys([0, 1]) .await .add_sig("BroadcastTestNoLinking", "deployDoesntPanic()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 1), (1, 2)]) + .assert_nonce_increment([(0, 1), (1, 2)]) .await; }); @@ -439,12 +442,12 @@ forgetest_async!(can_deploy_script_with_lib, |prj: TestProject, cmd: TestCommand let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0, 1]) + .load_private_keys([0, 1]) .await .add_sig("BroadcastTest", "deploy()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 2), (1, 1)]) + .assert_nonce_increment([(0, 2), (1, 1)]) .await; }); @@ -527,7 +530,7 @@ forgetest_async!( .simulate(ScriptOutcome::OkSimulation) .resume(ScriptOutcome::MissingWallet) // load missing wallet - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .run(ScriptOutcome::OkBroadcast) .assert_nonce_increment_addresses(vec![( @@ -535,7 +538,7 @@ forgetest_async!( 1, )]) .await - .assert_nonce_increment(vec![(0, 2)]) + .assert_nonce_increment([(0, 2)]) .await; } ); @@ -545,16 +548,16 @@ forgetest_async!(can_resume_script, |prj: TestProject, cmd: TestCommand| async m let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastTest", "deploy()") .simulate(ScriptOutcome::OkSimulation) .resume(ScriptOutcome::MissingWallet) // load missing wallet - .load_private_keys(vec![1]) + .load_private_keys([1]) .await .run(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 2), (1, 1)]) + .assert_nonce_increment([(0, 2), (1, 1)]) .await; }); @@ -564,12 +567,12 @@ forgetest_async!(can_deploy_broadcast_wrap, |prj: TestProject, cmd: TestCommand| tester .add_deployer(2) - .load_private_keys(vec![0, 1, 2]) + .load_private_keys([0, 1, 2]) .await .add_sig("BroadcastTest", "deployOther()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 4), (1, 4), (2, 1)]) + .assert_nonce_increment([(0, 4), (1, 4), (2, 1)]) .await; }); @@ -578,7 +581,7 @@ forgetest_async!(panic_no_deployer_set, |prj: TestProject, cmd: TestCommand| asy let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0, 1]) + .load_private_keys([0, 1]) .await .add_sig("BroadcastTest", "deployOther()") .simulate(ScriptOutcome::WarnSpecifyDeployer) @@ -591,12 +594,12 @@ forgetest_async!(can_deploy_no_arg_broadcast, |prj: TestProject, cmd: TestComman tester .add_deployer(0) - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastTest", "deployNoArgs()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 3)]) + .assert_nonce_increment([(0, 3)]) .await; }); @@ -605,18 +608,23 @@ forgetest_async!(can_deploy_with_create2, |prj: TestProject, cmd: TestCommand| a let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); // Prepare CREATE2 Deployer - let addr = Address::from_str("0x4e59b44847b379578588920ca78fbf26c0b4956c").unwrap(); - let code = hex::decode("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3").expect("Could not decode create2 deployer init_code").into(); - api.anvil_set_code(addr, code).await.unwrap(); + api.anvil_set_code( + foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER.to_ethers(), + ethers::types::Bytes::from_static( + foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, + ), + ) + .await + .unwrap(); tester .add_deployer(0) - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastTestNoLinking", "deployCreate2()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 2)]) + .assert_nonce_increment([(0, 2)]) .await // Running again results in error, since we're repeating the salt passed to CREATE2 .run(ScriptOutcome::FailedScript); @@ -630,12 +638,12 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastTestNoLinking", "deployMany()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 25)]) + .assert_nonce_increment([(0, 25)]) .await; } ); @@ -648,12 +656,12 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastMix", "deployMix()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 15)]) + .assert_nonce_increment([(0, 15)]) .await; } ); @@ -663,12 +671,12 @@ forgetest_async!(deploy_with_setup, |prj: TestProject, cmd: TestCommand| async m let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastTestSetup", "run()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 6)]) + .assert_nonce_increment([(0, 6)]) .await; }); @@ -677,7 +685,7 @@ forgetest_async!(fail_broadcast_staticcall, |prj: TestProject, cmd: TestCommand| let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastTestNoLinking", "errorStaticCall()") .simulate(ScriptOutcome::StaticCallNotAllowed); @@ -696,12 +704,12 @@ forgetest_async!( api.anvil_set_code(addr, code).await.unwrap(); tester - .load_private_keys(vec![0]) + .load_private_keys([0]) .await .add_sig("BroadcastTestSetup", "run()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(vec![(0, 6)]) + .assert_nonce_increment([(0, 6)]) .await; // Uncomment to recreate the broadcast log @@ -1046,29 +1054,30 @@ contract ScriptTxOrigin is Script { contract ContractA { function test(address _contractB) public { - require(msg.sender == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + require(msg.sender == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "sender 1"); + require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "origin 1"); ContractB contractB = ContractB(_contractB); ContractC contractC = new ContractC(); - require(msg.sender == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + require(msg.sender == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "sender 2"); + require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "origin 2"); contractB.method(address(this)); contractC.method(address(this)); - require(msg.sender == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + require(msg.sender == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "sender 3"); + require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "origin 3"); } } contract ContractB { function method(address sender) public view { - require(msg.sender == sender); - require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + require(msg.sender == sender, "sender"); + require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "origin"); } } + contract ContractC { function method(address sender) public view { - require(msg.sender == sender); - require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + require(msg.sender == sender, "sender"); + require(tx.origin == 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, "origin"); } } "#, diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 15e51e73a660c..3d08309d22f12 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -58,5 +58,5 @@ contract CounterTest is Test {{ "# ); prj.inner().add_test("Counter", src).unwrap(); - cmd.arg("test").stdout().contains("[PASS]") + cmd.arg("test").stdout_lossy().contains("[PASS]") }); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 79c37007ec427..9f4da608bb40f 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2,10 +2,10 @@ use foundry_config::Config; use foundry_test_utils::{ forgetest, forgetest_init, - util::{OutputExt, TestCommand, TestProject}, + util::{template_lock, OutputExt, TestCommand, TestProject}, }; use foundry_utils::rpc; -use std::{path::PathBuf, str::FromStr}; +use std::{path::PathBuf, process::Command, str::FromStr}; // tests that test filters are handled correctly forgetest!(can_set_filter_values, |prj: TestProject, mut cmd: TestCommand| { @@ -132,7 +132,7 @@ contract ATest is DSTest { .unwrap(); cmd.arg("test"); - cmd.stdout().contains("[PASS]") + cmd.stdout_lossy().contains("[PASS]") }); // tests that `bytecode_hash` will be sanitized @@ -157,7 +157,7 @@ contract ATest is DSTest { .unwrap(); cmd.arg("test"); - cmd.stdout().contains("[PASS]") + cmd.stdout_lossy().contains("[PASS]") }); // tests that using the --match-path option only runs files matching the path @@ -197,7 +197,7 @@ contract FailTest is DSTest { .unwrap(); cmd.args(["test", "--match-path", "*src/ATest.t.sol"]); - cmd.stdout().contains("[PASS]") && !cmd.stdout().contains("[FAIL]") + cmd.stdout_lossy().contains("[PASS]") && !cmd.stdout_lossy().contains("[FAIL]") }); // tests that `forge test` will pick up tests that are stored in the `test = ` config value @@ -297,13 +297,25 @@ forgetest_init!( #[serial_test::serial] can_test_forge_std, |prj: TestProject, mut cmd: TestCommand| { + let mut lock = template_lock(); + let write = lock.write().unwrap(); let forge_std_dir = prj.root().join("lib/forge-std"); + let status = Command::new("git") + .current_dir(&forge_std_dir) + .args(["pull", "origin", "master"]) + .status() + .unwrap(); + if !status.success() { + panic!("failed to update forge-std"); + } + drop(write); + // execute in subdir cmd.cmd().current_dir(forge_std_dir); cmd.args(["test", "--root", "."]); - let stdout = cmd.stdout(); + let stdout = cmd.stdout_lossy(); assert!(stdout.contains("[PASS]"), "No tests passed:\n{stdout}"); - assert!(!stdout.contains("[FAIL]"), "Tests failed :\n{stdout}"); + assert!(!stdout.contains("[FAIL]"), "Tests failed:\n{stdout}"); } ); diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 5cc668665a1a7..2aca55cd60a83 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -1,11 +1,10 @@ //! forge tests for cheat codes -use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; - use crate::{ config::*, test_helpers::{filter::Filter, PROJECT, RE_PATH_SEPARATOR}, }; +use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; /// Executes all cheat code tests but not fork cheat codes #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 5ecbf4ea9a6a2..2cff6bb1281ba 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -27,14 +27,13 @@ pub struct TestConfig { pub opts: TestOptions, } -// === impl TestConfig === - impl TestConfig { pub fn new(runner: MultiContractRunner) -> Self { Self::with_filter(runner, Filter::matches_all()) } pub fn with_filter(runner: MultiContractRunner, filter: Filter) -> Self { + init_tracing(); Self { runner, should_fail: false, filter, opts: test_opts() } } @@ -165,15 +164,14 @@ pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { config.rpc_endpoints = rpc_endpoints(); config.allow_paths.push(manifest_root()); + let root = &PROJECT.paths.root; + let opts = &*EVM_OPTS; + let env = opts.evm_env().await.expect("could not instantiate fork environment"); + let output = COMPILED.clone(); base_runner() - .with_cheats_config(CheatsConfig::new(&config, &EVM_OPTS)) + .with_cheats_config(CheatsConfig::new(&config, opts.clone())) .sender(config.sender) - .build( - &PROJECT.paths.root, - (*COMPILED).clone(), - EVM_OPTS.evm_env().await.expect("Could not instantiate fork environment"), - EVM_OPTS.clone(), - ) + .build(root, output, env, opts.clone()) .unwrap() } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 45f6aeb15c896..6054d99991914 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -317,5 +317,5 @@ async fn test_issue_6170() { let mut res = res.remove("repros/Issue6170.t.sol:Issue6170Test").unwrap(); let test = res.test_results.remove("test()").unwrap(); assert_eq!(test.status, TestStatus::Failure); - assert_eq!(test.reason, Some("Log != expected log".to_string())); + assert_eq!(test.reason, Some("log != expected log".to_string())); } diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 7f09638c5179c..82d3da730f846 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -16,17 +16,20 @@ use foundry_evm::{ }; use foundry_utils::types::{ToAlloy, ToEthers}; use once_cell::sync::Lazy; -use std::{path::PathBuf, str::FromStr}; +use std::{ + path::{Path, PathBuf}, + str::FromStr, +}; + +const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); pub static PROJECT: Lazy = Lazy::new(|| { - let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../testdata"); - let paths = ProjectPathsConfig::builder().root(root.clone()).sources(root).build().unwrap(); + let paths = ProjectPathsConfig::builder().root(TESTDATA).sources(TESTDATA).build().unwrap(); Project::builder().paths(paths).ephemeral().no_artifacts().build().unwrap() }); pub static LIBS_PROJECT: Lazy = Lazy::new(|| { - let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../testdata"); - let paths = ProjectPathsConfig::builder().root(root.clone()).sources(root).build().unwrap(); + let paths = ProjectPathsConfig::builder().root(TESTDATA).sources(TESTDATA).build().unwrap(); let libs = ["fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string()]; @@ -72,7 +75,7 @@ pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { sender: Config::DEFAULT_SENDER, initial_balance: U256::MAX, ffi: true, - memory_limit: 2u64.pow(24), + memory_limit: 1 << 24, ..Default::default() }); diff --git a/crates/macros/impl/src/cheatcodes.rs b/crates/macros/impl/src/cheatcodes.rs index 4bd978e52a699..ad2b99642ea90 100644 --- a/crates/macros/impl/src/cheatcodes.rs +++ b/crates/macros/impl/src/cheatcodes.rs @@ -2,50 +2,23 @@ use proc_macro2::{Ident, Span, TokenStream}; use quote::{quote, quote_spanned}; use syn::{Attribute, Data, DataStruct, DeriveInput, Error, Result}; -// Skip warnings for these items. -const ALLOWED_ITEMS: &[&str] = &["CheatCodeError", "VmErrors"]; - pub fn derive_cheatcode(input: &DeriveInput) -> Result { let name = &input.ident; let name_s = name.to_string(); match &input.data { - Data::Struct(s) if name_s.ends_with("Call") => return derive_struct(name, s, &input.attrs), - Data::Enum(e) if name_s.ends_with("Calls") => return derive_enum(name, e), - _ => {} - } - - if name_s.ends_with("Return") || ALLOWED_ITEMS.contains(&name_s.as_str()) { - if let Data::Struct(data) = &input.data { - check_named_fields(data, name); - } - return Ok(TokenStream::new()) - } - - if get_docstring(&input.attrs).trim().is_empty() { - emit_warning!(input.ident, "missing documentation for an item"); + Data::Struct(s) if name_s.ends_with("Call") => derive_call(name, s, &input.attrs), + Data::Struct(_) if name_s.ends_with("Return") => Ok(TokenStream::new()), + Data::Struct(s) => derive_struct(name, s, &input.attrs), + Data::Enum(e) if name_s.ends_with("Calls") => derive_calls_enum(name, e), + Data::Enum(e) if name_s.ends_with("Errors") => derive_errors_events_enum(name, e, false), + Data::Enum(e) if name_s.ends_with("Events") => derive_errors_events_enum(name, e, true), + Data::Enum(e) => derive_enum(name, e, &input.attrs), + Data::Union(_) => Err(Error::new(name.span(), "unions are not supported")), } - match &input.data { - Data::Struct(s) => { - for field in s.fields.iter() { - if get_docstring(&field.attrs).trim().is_empty() { - emit_warning!(field.ident, "missing documentation for a field"); - } - } - } - Data::Enum(e) => { - for variant in e.variants.iter() { - if get_docstring(&variant.attrs).trim().is_empty() { - emit_warning!(variant.ident, "missing documentation for a variant"); - } - } - } - _ => {} - } - Ok(TokenStream::new()) } -/// Implements `CheatcodeDef` for a struct. -fn derive_struct(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result { +/// Implements `CheatcodeDef` for a function call struct. +fn derive_call(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result { let mut group = None::; let mut status = None::; let mut safety = None::; @@ -100,14 +73,16 @@ fn derive_struct(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result Ok(quote! { impl CheatcodeDef for #name { const CHEATCODE: &'static Cheatcode<'static> = &Cheatcode { - id: #id, - declaration: #declaration, - visibility: Visibility::#visibility, - mutability: Mutability::#mutability, - signature: #signature, - selector: #selector, - selector_bytes: ::SELECTOR, - description: #description, + func: Function { + id: #id, + description: #description, + declaration: #declaration, + visibility: Visibility::#visibility, + mutability: Mutability::#mutability, + signature: #signature, + selector: #selector, + selector_bytes: ::SELECTOR, + }, group: Group::#group, status: Status::#status, safety: #safety, @@ -117,7 +92,7 @@ fn derive_struct(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result } /// Generates the `CHEATCODES` constant and implements `CheatcodeImpl` dispatch for an enum. -fn derive_enum(name: &Ident, input: &syn::DataEnum) -> Result { +fn derive_calls_enum(name: &Ident, input: &syn::DataEnum) -> Result { if input.variants.iter().any(|v| v.fields.len() != 1) { return Err(syn::Error::new(name.span(), "expected all variants to have a single field")) } @@ -137,7 +112,10 @@ fn derive_enum(name: &Ident, input: &syn::DataEnum) -> Result { #[cfg(feature = "impls")] impl #name { - pub(crate) fn apply(&self, ccx: &mut crate::impls::CheatsCtxt) -> crate::impls::Result { + pub(crate) fn apply( + &self, + ccx: &mut crate::impls::CheatsCtxt + ) -> crate::impls::Result { match self { #(Self::#variants_names(c) => crate::impls::Cheatcode::apply_traced(c, ccx),)* } @@ -146,6 +124,189 @@ fn derive_enum(name: &Ident, input: &syn::DataEnum) -> Result { }) } +fn derive_errors_events_enum( + name: &Ident, + input: &syn::DataEnum, + events: bool, +) -> Result { + if input.variants.iter().any(|v| v.fields.len() != 1) { + return Err(syn::Error::new(name.span(), "expected all variants to have a single field")) + } + + let (ident, ty_assoc_name, ty, doc) = if events { + ("VM_EVENTS", "EVENT", "Event", "events") + } else { + ("VM_ERRORS", "ERROR", "Error", "custom errors") + }; + let ident = Ident::new(ident, Span::call_site()); + let ty_assoc_name = Ident::new(ty_assoc_name, Span::call_site()); + let ty = Ident::new(ty, Span::call_site()); + let doc = format!("All the {doc} in [this contract](self)."); + + let mut variants = input.variants.iter().collect::>(); + variants.sort_by(|a, b| a.ident.cmp(&b.ident)); + let variant_tys = variants.iter().map(|v| { + assert_eq!(v.fields.len(), 1); + &v.fields.iter().next().unwrap().ty + }); + Ok(quote! { + #[doc = #doc] + pub const #ident: &'static [&'static #ty<'static>] = &[#(#variant_tys::#ty_assoc_name,)*]; + }) +} + +fn derive_struct( + name: &Ident, + input: &syn::DataStruct, + attrs: &[Attribute], +) -> Result { + let name_s = name.to_string(); + + let doc = get_docstring(attrs); + let doc = doc.trim(); + let kind = match () { + () if doc.contains("Custom error ") => StructKind::Error, + () if doc.contains("Event ") => StructKind::Event, + _ => StructKind::Struct, + }; + + let (doc, def) = doc.split_once("```solidity\n").expect("bad docstring"); + let mut doc = doc.trim_end(); + let def_end = def.rfind("```").expect("bad docstring"); + let def = def[..def_end].trim(); + + match kind { + StructKind::Error => doc = &doc[..doc.find("Custom error ").expect("bad doc")], + StructKind::Event => doc = &doc[..doc.find("Event ").expect("bad doc")], + StructKind::Struct => {} + } + let doc = doc.trim(); + + if doc.is_empty() { + let n = match kind { + StructKind::Error => "n", + StructKind::Event => "n", + StructKind::Struct => "", + }; + emit_warning!(name.span(), "missing documentation for a{n} {}", kind.as_str()); + } + + if kind == StructKind::Struct { + check_named_fields(input, name); + } + + let def = match kind { + StructKind::Struct => { + let fields = input.fields.iter().map(|f| { + let name = f.ident.as_ref().expect("field has no name").to_string(); + + let to_find = format!("{name};"); + let ty_end = def.find(&to_find).expect("field not found in def"); + let ty = &def[..ty_end]; + let ty_start = ty.rfind(';').or_else(|| ty.find('{')).expect("bad struct def") + 1; + let ty = ty[ty_start..].trim(); + if ty.is_empty() { + panic!("bad struct def: {def:?}") + } + + let doc = get_docstring(&f.attrs); + let doc = doc.trim(); + quote! { + StructField { + name: #name, + ty: #ty, + description: #doc, + } + } + }); + quote! { + /// The struct definition. + pub const STRUCT: &'static Struct<'static> = &Struct { + name: #name_s, + description: #doc, + fields: Cow::Borrowed(&[#(#fields),*]), + }; + } + } + StructKind::Error => { + quote! { + /// The custom error definition. + pub const ERROR: &'static Error<'static> = &Error { + name: #name_s, + description: #doc, + declaration: #def, + }; + } + } + StructKind::Event => { + quote! { + /// The event definition. + pub const EVENT: &'static Event<'static> = &Event { + name: #name_s, + description: #doc, + declaration: #def, + }; + } + } + }; + Ok(quote! { + impl #name { + #def + } + }) +} + +#[derive(Clone, Copy, PartialEq, Eq)] +enum StructKind { + Struct, + Error, + Event, +} + +impl StructKind { + fn as_str(self) -> &'static str { + match self { + Self::Struct => "struct", + Self::Error => "error", + Self::Event => "event", + } + } +} + +fn derive_enum(name: &Ident, input: &syn::DataEnum, attrs: &[Attribute]) -> Result { + let name_s = name.to_string(); + let doc = get_docstring(attrs); + let doc_end = doc.find("```solidity").expect("bad docstring"); + let doc = doc[..doc_end].trim(); + if doc.is_empty() { + emit_warning!(name.span(), "missing documentation for an enum"); + } + let variants = input.variants.iter().filter(|v| v.discriminant.is_none()).map(|v| { + let name = v.ident.to_string(); + let doc = get_docstring(&v.attrs); + let doc = doc.trim(); + if doc.is_empty() { + emit_warning!(v.ident.span(), "missing documentation for a variant"); + } + quote! { + EnumVariant { + name: #name, + description: #doc, + } + } + }); + Ok(quote! { + impl #name { + /// The enum definition. + pub const ENUM: &'static Enum<'static> = &Enum { + name: #name_s, + description: #doc, + variants: Cow::Borrowed(&[#(#variants),*]), + }; + } + }) +} + fn check_named_fields(data: &DataStruct, ident: &Ident) { for field in data.fields.iter() { if field.ident.is_none() { @@ -155,7 +316,7 @@ fn check_named_fields(data: &DataStruct, ident: &Ident) { } /// Flattens all the `#[doc = "..."]` attributes into a single string. -fn get_docstring(attrs: &[syn::Attribute]) -> String { +fn get_docstring(attrs: &[Attribute]) -> String { let mut doc = String::new(); for attr in attrs { if !attr.path().is_ident("doc") { diff --git a/crates/macros/impl/src/lib.rs b/crates/macros/impl/src/lib.rs index d7981523eb7af..136b65f5112a4 100644 --- a/crates/macros/impl/src/lib.rs +++ b/crates/macros/impl/src/lib.rs @@ -5,7 +5,7 @@ extern crate proc_macro_error; use proc_macro::TokenStream; use proc_macro_error::proc_macro_error; -use syn::{parse_macro_input, DeriveInput}; +use syn::{parse_macro_input, DeriveInput, Error}; mod cheatcodes; mod console_fmt; @@ -20,5 +20,5 @@ pub fn console_fmt(input: TokenStream) -> TokenStream { #[proc_macro_error] pub fn cheatcode(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - cheatcodes::derive_cheatcode(&input).unwrap_or_else(syn::Error::into_compile_error).into() + cheatcodes::derive_cheatcode(&input).unwrap_or_else(Error::into_compile_error).into() } diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index bbf7deb0a8a28..256c2040ec0a6 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -29,6 +29,9 @@ regex = "1" serde_json.workspace = true tempfile = "3" walkdir = "2" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } +fd-lock = "4.0.0" [features] # feature for integration tests that test external projects diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index e6f1ab0ec80db..ee079ace7aa65 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -1,5 +1,8 @@ #![warn(unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + // Macros useful for testing. mod macros; @@ -13,3 +16,10 @@ pub use script::{ScriptOutcome, ScriptTester}; // re-exports for convenience pub use foundry_compilers; pub use tempfile; + +/// Initializes tracing for tests. +pub fn init_tracing() { + let _ = tracing_subscriber::FmtSubscriber::builder() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .try_init(); +} diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 3434c92b91543..7fa87d849a1be 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,4 +1,4 @@ -use crate::TestCommand; +use crate::{init_tracing, TestCommand}; use alloy_primitives::{Address, U256}; use ethers::prelude::{Middleware, NameOrAddress}; use eyre::Result; @@ -26,6 +26,7 @@ impl ScriptTester { project_root: &Path, target_contract: &str, ) -> Self { + init_tracing(); ScriptTester::copy_testdata(project_root).unwrap(); cmd.set_current_dir(project_root); @@ -103,7 +104,10 @@ impl ScriptTester { Ok(()) } - pub async fn load_private_keys(&mut self, keys_indexes: Vec) -> &mut Self { + pub async fn load_private_keys( + &mut self, + keys_indexes: impl IntoIterator, + ) -> &mut Self { for index in keys_indexes { self.cmd.args(["--private-keys", &self.accounts_priv[index as usize]]); @@ -170,24 +174,28 @@ impl ScriptTester { self.run(expected) } - /// In Vec<(private_key_slot, expected increment)> - pub async fn assert_nonce_increment(&mut self, keys_indexes: Vec<(u32, u32)>) -> &mut Self { + /// `[(private_key_slot, expected increment)]` + pub async fn assert_nonce_increment( + &mut self, + keys_indexes: impl IntoIterator, + ) -> &mut Self { for (private_key_slot, expected_increment) in keys_indexes { + let addr = self.accounts_pub[private_key_slot as usize]; let nonce = self .provider .as_ref() .unwrap() - .get_transaction_count( - NameOrAddress::Address( - self.accounts_pub[private_key_slot as usize].to_ethers(), - ), - None, - ) + .get_transaction_count(NameOrAddress::Address(addr.to_ethers()), None) .await .unwrap(); let prev_nonce = self.nonces.get(&private_key_slot).unwrap(); - assert_eq!(nonce, (prev_nonce + U256::from(expected_increment)).to_ethers()); + assert_eq!( + nonce, + (prev_nonce + U256::from(expected_increment)).to_ethers(), + "nonce not incremented correctly for {addr}: \ + {prev_nonce} + {expected_increment} != {nonce}" + ); } self } @@ -213,12 +221,18 @@ impl ScriptTester { } pub fn run(&mut self, expected: ScriptOutcome) -> &mut Self { - let output = - if expected.is_err() { self.cmd.stderr_lossy() } else { self.cmd.stdout_lossy() }; + let (stdout, stderr) = self.cmd.unchecked_output_lossy(); + trace!(target: "tests", "STDOUT\n{stdout}\n\nSTDERR\n{stderr}"); + let output = if expected.is_err() { &stderr } else { &stdout }; if !output.contains(expected.as_str()) { - panic!("OUTPUT: {output}\n\nEXPECTED: {}", expected.as_str()); + let which = if expected.is_err() { "stderr" } else { "stdout" }; + panic!( + "--STDOUT--\n{stdout}\n\n--STDERR--\n{stderr}\n\n--EXPECTED--\n{:?} in {which}", + expected.as_str() + ); } + self } @@ -251,16 +265,16 @@ pub enum ScriptOutcome { impl ScriptOutcome { pub fn as_str(&self) -> &'static str { match self { - ScriptOutcome::OkNoEndpoint => "If you wish to simulate on-chain transactions pass a RPC URL.", - ScriptOutcome::OkSimulation => "SIMULATION COMPLETE. To broadcast these", - ScriptOutcome::OkBroadcast => "ONCHAIN EXECUTION COMPLETE & SUCCESSFUL", - ScriptOutcome::WarnSpecifyDeployer => "You have more than one deployer who could predeploy libraries. Using `--sender` instead.", - ScriptOutcome::MissingSender => "You seem to be using Foundry's default sender. Be sure to set your own --sender", - ScriptOutcome::MissingWallet => "No associated wallet", - ScriptOutcome::StaticCallNotAllowed => "Staticcalls are not allowed after vm.broadcast. Either remove it, or use vm.startBroadcast instead.", - ScriptOutcome::FailedScript => "Script failed.", - ScriptOutcome::UnsupportedLibraries => "Multi chain deployment does not support library linking at the moment.", - ScriptOutcome::ErrorSelectForkOnBroadcast => "You need to stop broadcasting before you can select forks." + Self::OkNoEndpoint => "If you wish to simulate on-chain transactions pass a RPC URL.", + Self::OkSimulation => "SIMULATION COMPLETE. To broadcast these", + Self::OkBroadcast => "ONCHAIN EXECUTION COMPLETE & SUCCESSFUL", + Self::WarnSpecifyDeployer => "You have more than one deployer who could predeploy libraries. Using `--sender` instead.", + Self::MissingSender => "You seem to be using Foundry's default sender. Be sure to set your own --sender", + Self::MissingWallet => "No associated wallet", + Self::StaticCallNotAllowed => "staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead", + Self::FailedScript => "Script failed.", + Self::UnsupportedLibraries => "Multi chain deployment does not support library linking at the moment.", + Self::ErrorSelectForkOnBroadcast => "cannot select forks during a broadcast", } } diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 13671765d87c6..b10d7fd82677e 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1,4 +1,6 @@ +use crate::init_tracing; use eyre::{Result, WrapErr}; +use fd_lock::RwLock; use foundry_compilers::{ cache::SolFilesCache, project_util::{copy_dir, TempProject}, @@ -35,20 +37,50 @@ static PRE_INSTALL_SOLC_LOCK: Lazy> = Lazy::new(|| Mutex::new(false) // This stores `true` if the current terminal is a tty pub static IS_TTY: Lazy = Lazy::new(|| std::io::stdout().is_terminal()); -/// Contains a `forge init` initialized project -pub static FORGE_INITIALIZED: Lazy = Lazy::new(|| { - let (prj, mut cmd) = setup_forge("init-template", PathStyle::Dapptools); - cmd.args(["init", "--force"]); - cmd.assert_non_empty_stdout(); - prj -}); +/// Global default template path. +pub static TEMPLATE_PATH: Lazy = + Lazy::new(|| env::temp_dir().join("foundry-forge-test-template")); + +/// Global default template lock. +pub static TEMPLATE_LOCK: Lazy = + Lazy::new(|| env::temp_dir().join("foundry-forge-test-template.lock")); // identifier for tests static NEXT_ID: AtomicUsize = AtomicUsize::new(0); +/// Acquires a lock on the global template dir. +pub fn template_lock() -> RwLock { + let lock_path = &*TEMPLATE_LOCK; + let lock_file = pretty_err( + lock_path, + fs::OpenOptions::new().read(true).write(true).create(true).open(lock_path), + ); + RwLock::new(lock_file) +} + /// Copies an initialized project to the given path pub fn initialize(target: impl AsRef) { - FORGE_INITIALIZED.copy_to(target) + let target = target.as_ref(); + let tpath = &*TEMPLATE_PATH; + pretty_err(tpath, fs::create_dir_all(tpath)); + + let mut lock = template_lock(); + let read = lock.read().unwrap(); + if fs::read_to_string(&*TEMPLATE_LOCK).unwrap() != "1" { + eprintln!("initializing template dir"); + + drop(read); + let mut write = lock.write().unwrap(); + write.write_all(b"1").unwrap(); + + let (prj, mut cmd) = setup_forge("template", foundry_compilers::PathStyle::Dapptools); + cmd.args(["init", "--force"]).assert_success(); + pretty_err(tpath, fs::remove_dir_all(tpath)); + pretty_err(tpath, copy_dir(prj.root(), tpath)); + } else { + pretty_err(target, fs::create_dir_all(target)); + pretty_err(target, copy_dir(tpath, target)); + } } /// Clones a remote repository into the specified directory. @@ -234,6 +266,7 @@ impl TestProject { } pub fn with_project(project: TempProject) -> Self { + init_tracing(); let root = env::current_exe().unwrap().parent().expect("executable's directory").to_path_buf(); Self { root, inner: Arc::new(project) } @@ -383,6 +416,7 @@ impl TestProject { let forge = self.root.join(format!("../forge{}", env::consts::EXE_SUFFIX)); let mut cmd = process::Command::new(forge); cmd.current_dir(self.inner.root()); + // disable color output for comparisons cmd.env("NO_COLOR", "1"); cmd } @@ -391,6 +425,7 @@ impl TestProject { pub fn cast_bin(&self) -> process::Command { let cast = self.root.join(format!("../cast{}", env::consts::EXE_SUFFIX)); let mut cmd = process::Command::new(cast); + // disable color output for comparisons cmd.env("NO_COLOR", "1"); cmd } @@ -404,7 +439,7 @@ impl TestProject { let mut cmd = self.forge_bin(); cmd.arg("config").arg("--root").arg(self.root()).args(args).arg("--json"); let output = cmd.output().unwrap(); - let c = String::from_utf8_lossy(&output.stdout); + let c = lossy_string(&output.stdout); let config: Config = serde_json::from_str(c.as_ref()).unwrap(); config.sanitized() } @@ -476,22 +511,23 @@ impl TestCommand { &mut self.cmd } - /// replaces the command + /// Replaces the underlying command. pub fn set_cmd(&mut self, cmd: Command) -> &mut TestCommand { self.cmd = cmd; self } - /// Resets the command + /// Resets the command to the default `forge` command. pub fn forge_fuse(&mut self) -> &mut TestCommand { self.set_cmd(self.project.forge_bin()) } + /// Resets the command to the default `cast` command. pub fn cast_fuse(&mut self) -> &mut TestCommand { self.set_cmd(self.project.cast_bin()) } - /// Sets the current working directory + /// Sets the current working directory. pub fn set_current_dir(&mut self, p: impl AsRef) { drop(self.current_dir_lock.take()); let lock = CURRENT_DIR_LOCK.lock(); @@ -551,13 +587,14 @@ impl TestCommand { pub fn config(&mut self) -> Config { self.cmd.args(["config", "--json"]); let output = self.output(); - let c = String::from_utf8_lossy(&output.stdout); + let c = lossy_string(&output.stdout); let config = serde_json::from_str(c.as_ref()).unwrap(); self.forge_fuse(); config } /// Runs `git init` inside the project's dir + #[track_caller] pub fn git_init(&self) -> process::Output { let mut cmd = Command::new("git"); cmd.arg("init").current_dir(self.project.root()); @@ -565,55 +602,72 @@ impl TestCommand { self.expect_success(output) } - /// Runs and captures the stdout of the given command. - pub fn stdout(&mut self) -> String { - let o = self.output(); - let stdout = String::from_utf8_lossy(&o.stdout); - match stdout.parse::() { - Ok(t) => t.replace("\r\n", "\n"), - Err(err) => { - panic!("could not convert from string: {err:?}\n\n{stdout}"); - } - } + /// Executes the command and returns the `(stdout, stderr)` of the output as lossy `String`s. + /// + /// Expects the command to be successful. + #[track_caller] + pub fn output_lossy(&mut self) -> (String, String) { + let output = self.output(); + (lossy_string(&output.stdout), lossy_string(&output.stderr)) } - /// Returns the `stderr` of the output as `String`. - pub fn stderr_lossy(&mut self) -> String { - let output = self.execute(); - String::from_utf8_lossy(&output.stderr).to_string().replace("\r\n", "\n") + /// Executes the command and returns the `(stdout, stderr)` of the output as lossy `String`s. + /// + /// Does not expect the command to be successful. + #[track_caller] + pub fn unchecked_output_lossy(&mut self) -> (String, String) { + let output = self.unchecked_output(); + (lossy_string(&output.stdout), lossy_string(&output.stderr)) } - /// Returns the `stdout` of the output as `String`. + /// Executes the command and returns the stderr as lossy `String`. + /// + /// **Note**: This function checks whether the command was successful. + #[track_caller] pub fn stdout_lossy(&mut self) -> String { - String::from_utf8_lossy(&self.output().stdout).to_string().replace("\r\n", "\n") + lossy_string(&self.output().stdout) + } + + /// Executes the command and returns the stderr as lossy `String`. + /// + /// **Note**: This function does **not** check whether the command was successful. + #[track_caller] + pub fn stderr_lossy(&mut self) -> String { + lossy_string(&self.unchecked_output().stderr) } /// Returns the output but does not expect that the command was successful + #[track_caller] pub fn unchecked_output(&mut self) -> process::Output { self.execute() } /// Gets the output of a command. If the command failed, then this panics. + #[track_caller] pub fn output(&mut self) -> process::Output { let output = self.execute(); self.expect_success(output) } /// Runs the command and asserts that it resulted in success + #[track_caller] pub fn assert_success(&mut self) { self.output(); } /// Executes command, applies stdin function and returns output + #[track_caller] pub fn execute(&mut self) -> process::Output { self.try_execute().unwrap() } + #[track_caller] pub fn try_execute(&mut self) -> std::io::Result { + eprintln!("Executing {:?}\n", self.cmd); let mut child = self.cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::piped()).spawn()?; if let Some(fun) = self.stdin_fun.take() { - fun(child.stdin.take().unwrap()) + fun(child.stdin.take().unwrap()); } child.wait_with_output() } @@ -628,13 +682,15 @@ impl TestCommand { /// Runs the command and prints its output /// You have to pass --nocapture to cargo test or the print won't be displayed. /// The full command would be: cargo test -- --nocapture + #[track_caller] pub fn print_output(&mut self) { let output = self.execute(); - println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); - println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); + println!("stdout: {}", lossy_string(&output.stdout)); + println!("stderr: {}", lossy_string(&output.stderr)); } /// Writes the content of the output to new fixture files + #[track_caller] pub fn write_fixtures(&mut self, name: impl AsRef) { let name = name.as_ref(); if let Some(parent) = name.parent() { @@ -660,8 +716,8 @@ impl TestCommand { self.cmd, self.project.inner.paths(), o.status, - String::from_utf8_lossy(&o.stdout), - String::from_utf8_lossy(&o.stderr) + lossy_string(&o.stdout), + lossy_string(&o.stderr) ); } } @@ -681,8 +737,8 @@ impl TestCommand { self.cmd, self.project.inner.paths(), o.status, - String::from_utf8_lossy(&o.stdout), - String::from_utf8_lossy(&o.stderr) + lossy_string(&o.stdout), + lossy_string(&o.stderr) ); } } @@ -693,17 +749,25 @@ impl TestCommand { let o = self.execute(); if !o.status.success() || o.stdout.is_empty() { panic!( - "\n\n===== {:?} =====\n\ - command failed but expected success!\ - \n\ncwd: {}\ - \n\nstatus: {}\ - \n\nstdout: {}\n\nstderr: {}\ - \n\n=====\n", + " +===== {:?} ===== +command failed but expected success! +status: {} + +{} + +stdout: +{} + +stderr: +{} + +=====\n", self.cmd, - self.project.inner.paths(), o.status, - String::from_utf8_lossy(&o.stdout), - String::from_utf8_lossy(&o.stderr) + self.project.inner.paths(), + lossy_string(&o.stdout), + lossy_string(&o.stderr) ); } } @@ -723,8 +787,8 @@ impl TestCommand { self.cmd, self.project.inner.paths(), o.status, - String::from_utf8_lossy(&o.stdout), - String::from_utf8_lossy(&o.stderr) + lossy_string(&o.stdout), + lossy_string(&o.stderr) ); } } @@ -743,21 +807,26 @@ impl TestCommand { String::new() }; eyre::bail!( - "\n\n==========\n\ - command failed but expected success!\ - {}\ - \n\ncommand: {:?}\ - \n\ncwd: {}\ - \n\nstatus: {}\ - \n\nstdout: {}\ - \n\nstderr: {}\ - \n\n==========\n", - suggest, + " +===== {:?} ===== +command failed but expected success!{suggest} + +status: {} + +{} + +stdout: +{} + +stderr: +{} + +=====\n", self.cmd, - self.project.inner.paths(), out.status, - String::from_utf8_lossy(&out.stdout), - String::from_utf8_lossy(&out.stderr) + self.project.inner.paths(), + lossy_string(&out.stdout), + lossy_string(&out.stderr) ); } Ok(out) @@ -789,7 +858,7 @@ impl OutputExt for process::Output { fn stdout_matches_path(&self, expected_path: impl AsRef) -> &Self { let expected = fs::read_to_string(expected_path).unwrap(); let expected = IGNORE_IN_FIXTURES.replace_all(&expected, "").replace('\\', "/"); - let stdout = String::from_utf8_lossy(&self.stdout); + let stdout = lossy_string(&self.stdout); let out = IGNORE_IN_FIXTURES.replace_all(&stdout, "").replace('\\', "/"); pretty_assertions::assert_eq!(expected, out); @@ -801,7 +870,7 @@ impl OutputExt for process::Output { fn stderr_matches_path(&self, expected_path: impl AsRef) -> &Self { let expected = fs::read_to_string(expected_path).unwrap(); let expected = IGNORE_IN_FIXTURES.replace_all(&expected, "").replace('\\', "/"); - let stderr = String::from_utf8_lossy(&self.stderr); + let stderr = lossy_string(&self.stderr); let out = IGNORE_IN_FIXTURES.replace_all(&stderr, "").replace('\\', "/"); pretty_assertions::assert_eq!(expected, out); @@ -835,6 +904,10 @@ pub fn dir_list>(dir: P) -> Vec { .collect() } +fn lossy_string(bytes: &[u8]) -> String { + String::from_utf8_lossy(bytes).replace("\r\n", "\n") +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 80d7c4c3fd88d..0daf16756b8c3 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -17,9 +17,9 @@ ethers-contract = { workspace = true, features = ["abigen"] } ethers-addressbook.workspace = true ethers-providers.workspace = true -alloy-primitives.workspace = true alloy-json-abi.workspace = true -alloy-dyn-abi.workspace = true +alloy-primitives.workspace = true +alloy-sol-types.workspace = true foundry-compilers = { workspace = true, default-features = false } diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 13c9c5170ffe4..99bc541eb90bb 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -1,38 +1,33 @@ //! error handling and support -use alloy_dyn_abi::DynSolValue; use alloy_primitives::Bytes; -use std::fmt::Display; +use alloy_sol_types::{SolError, SolValue}; /// Solidity revert prefix. /// -/// `keccak256("Error(String)")[..4] == 0x08c379a0` +/// `keccak256("Error(string)")[..4] == 0x08c379a0` pub const REVERT_PREFIX: [u8; 4] = [8, 195, 121, 160]; /// Custom Cheatcode error prefix. /// -/// `keccak256("CheatCodeError")[..4] == 0x0bc44503` -pub const ERROR_PREFIX: [u8; 4] = [11, 196, 69, 3]; +/// `keccak256("CheatcodeError(string)")[..4] == 0xeeaa9e6f` +pub const ERROR_PREFIX: [u8; 4] = [238, 170, 158, 111]; -/// An extension trait for `std::error::Error` that can abi-encode itself -pub trait SolError: std::error::Error { - /// Returns the abi-encoded custom error - /// - /// Same as `encode_string` but prefixed with `ERROR_PREFIX` +/// An extension trait for `std::error::Error` that can ABI-encode itself. +pub trait ErrorExt: std::error::Error { + /// ABI-encodes the error using `Revert(string)`. + fn encode_error(&self) -> Bytes; + + /// ABI-encodes the error as a string. + fn encode_string(&self) -> Bytes; +} + +impl ErrorExt for T { fn encode_error(&self) -> Bytes { - encode_error(self) + alloy_sol_types::Revert::from(self.to_string()).abi_encode().into() } - /// Returns the error as abi-encoded String fn encode_string(&self) -> Bytes { - let err = DynSolValue::from(self.to_string()); - err.abi_encode().into() + self.to_string().abi_encode().into() } } - -/// Encodes the given messages as solidity custom error -pub fn encode_error(reason: impl Display) -> Bytes { - [ERROR_PREFIX.as_slice(), DynSolValue::String(reason.to_string()).abi_encode().as_slice()] - .concat() - .into() -} diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 4e1f3bb5e5431..32b922d49dfeb 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -1,18 +1,16 @@ # Architecture -This document describes the high-level architecture of foundry. +This document describes the high-level architecture of Foundry. ### `evm/` -foundry's evm tooling. This is built around [`revm`](https://github.com/bluealloy/revm) and has additional -implementation of - -- [cheatcodes](./cheatcodes.md) a set of solidity calls dedicated to testing which can manipulate the environment in - which the execution is run +Foundry's EVM tooling. This is built around [`revm`](https://github.com/bluealloy/revm) and has additional +implementation of: +- [cheatcodes](./cheatcodes.md) a set of solidity calls dedicated to testing which can manipulate the environment in which the execution is run ### `config/` -Includes all of foundry's settings and how to get them +Includes all of Foundry's settings and how to get them ### `cli/` diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index cc9c757ca0be2..26f399a698a81 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -1,49 +1,47 @@ -# Cheat codes +# Cheatcodes -foundry's EVM support is mainly dedicated to testing and exploration, it features a set of cheat codes which can +Foundry's EVM support is mainly dedicated to testing and exploration, it features a set of cheatcodes which can manipulate the environment in which the execution is run. Most of the time, simply testing your smart contracts outputs isn't enough. To manipulate the state of the EVM, as well -as test for specific reverts and events, Foundry is shipped with a set of cheat codes. +as test for specific reverts and events, Foundry is shipped with a set of cheatcodes. -## `revm` `Inspector` +## [`revm::Inspector`](https://docs.rs/revm/3.3.0/revm/trait.Inspector.html) -To understand how cheat codes are implemented, we first need to look -at [`revm::Inspector`](https://docs.rs/revm/latest/revm/trait.Inspector.html), a trait that provides a set of event -hooks to be notified at certain stages of EVM execution. +To understand how cheatcodes are implemented, we first need to look at [`revm::Inspector`](https://docs.rs/revm/3.3.0/revm/trait.Inspector.html), +a trait that provides a set of callbacks to be notified at certain stages of EVM execution. -For example [`Inspector::call`](https://docs.rs/revm/latest/revm/trait.Inspector.html#method.call) is called wen the EVM is about to execute a call: +For example, [`Inspector::call`](https://docs.rs/revm/3.3.0/revm/trait.Inspector.html#method.call) +is called when the EVM is about to execute a call: ```rust - fn call( +fn call( &mut self, - _data: &mut EVMData<'_, DB>, - _inputs: &mut CallInputs, - _is_static: bool + data: &mut EVMData<'_, DB>, + inputs: &mut CallInputs, + is_static: bool, ) -> (InstructionResult, Gas, Bytes) { ... } ``` -## [Foundry Inspectors](../../evm/src/executor/inspector) +## [Foundry inspectors](../../crates/evm/evm/src/inspectors/) -the `evm` crate has a variety of inspectors for different use cases, such as +The [`evm`](../../crates/evm/evm/) crate has a variety of inspectors for different use cases, such as +- coverage +- tracing +- debugger +- logging -- coverage -- tracing -- debugger -- cheat codes + logging +## [Cheatcode inspector](../../crates/cheatcodes/src/impls/inspector.rs) -## [Cheat code Inspector](../../evm/src/executor/inspector/cheatcodes) +The concept of cheatcodes and cheatcode inspector is very simple. -The concept of cheat codes and cheat code inspector is very simple. +Cheatcodes are calls to a specific address, the cheatcode handler address, defined as +`address(uint160(uint256(keccak256("hevm cheat code"))))` (`0x7109709ECfa91a80626fF3989D68f67F5b1DD12D`). -In solidity cheat codes are calls to a specific address, the cheat code handler address: +In Solidity, this can be initialized as `Vm constant vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);`, +but generally this is inherited from `forge-std/Test.sol`. -`address(uint160(uint256(keccak256('hevm cheat code'))))`: 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D - -which can be initialized like `Vm constant vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);`, when -inheriting from `forge-std/Test.sol` it can be accessed via `vm.` directly. - -Since cheat codes are bound to a constant address, the cheat code inspector listens for that address: +Since cheatcodes are bound to a constant address, the cheatcode inspector listens for that address: ```rust impl Inspector for Cheatcodes { @@ -54,39 +52,118 @@ impl Inspector for Cheatcodes { is_static: bool, ) -> (Return, Gas, Bytes) { if call.contract == CHEATCODE_ADDRESS { - // intercepted cheat code call + // intercepted cheatcode call // --snip-- } } } ``` -When a call to a cheat code is intercepted we try to decode the calldata into a known cheat code. +When a call to a cheatcode is intercepted we try to decode the calldata into a known cheatcode. + +Rust bindings for the cheatcode interface are generated via the [Alloy](https://github.com/alloy-rs) [`sol!`](https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html) macro. + +If a call was successfully decoded into the `VmCalls` enum that the `sol!` macro generates, the +last step is a large `match` over the decoded function call structs, which serves as the +implementation handler for the cheatcode. This is also automatically generated by the `sol!` macro, +through the use of a custom internal derive procedural macro. + +## Cheatcodes implementation -Rust bindings for the cheat code interface are generated -via [ethers-rs](https://github.com/gakonst/ethers-rs/) `abigen!` macro: +All the cheatcodes are defined in a large [`sol!`] macro call in [`cheatcodes/src/defs/mod.rs`](../../crates/cheatcodes/src/defs/mod.rs): ```rust -// Bindings for cheatcodes -abigen!( - HEVM, - r#"[ - roll(uint256) - warp(uint256) - fee(uint256) - // --snip-- - ]"#); +sol! { +#[derive(Cheatcode)] +interface Vm { + // ======== Types ======== + + /// Error thrown by a cheatcode. + error CheatcodeError(string message); + + // ... + + // ======== EVM ======== + + /// Gets the address for a given private key. + #[cheatcode(group = Evm, safety = Safe)] + function addr(uint256 privateKey) external pure returns (address keyAddr); + + /// Gets the nonce of an account. + #[cheatcode(group = Evm, safety = Safe)] + function getNonce(address account) external view returns (uint64 nonce); + + // ... +} +} ``` -If a call was successfully decoded into the `HEVMCalls` enum that the `abigen!` macro generates, the remaining step is -essentially a large `match` over the decoded `HEVMCalls` which serves as the implementation handler for the cheat code. +This, combined with the use of an internal [`Cheatcode` derive macro](#cheatcode-derive-macro), +allows us to generate both the Rust definitions and the JSON specification of the cheatcodes. + +Cheatcodes are manually implemented through the [`Cheatcode` trait](#cheatcode-trait), which is +called in the [`Cheatcodes` inspector](#cheatcode-inspector) implementation. + +### [`sol!`] + +Generates the raw Rust bindings for the cheatcodes, as well as lets us specify custom attributes +individually for each item, such as functions and structs, or for entire interfaces. + +The way bindings are generated and extra information can be found the [`sol!`] documentation. + +We leverage this macro to apply the [`Cheatcode` derive macro](#cheatcode-derive-macro) on the `Vm` interface. + +### [`Cheatcode`](../../crates/macros/impl/src/cheatcodes.rs) derive macro + +This is derived once on the `Vm` interface declaration, which recursively applies it to all of the +interface's items, as well as the `sol!`-generated items, such as the `VmCalls` enum. + +This macro performs extra checks on functions and structs at compile time to make sure they are +documented and have named parameters, and generates a `match { ... }` function that is be used to +dispatch the cheatcode implementations after a call is decoded. + +The latter is what fails compilation when adding a new cheatcode, and is fixed by implementing the +[`Cheatcode` trait](#cheatcode-trait) to the newly-generated function call struct(s). + +The `Cheatcode` derive macro also parses the `#[cheatcode(...)]` attributes on functions, which are +used to specify additional properties the JSON interface. + +These are all the attributes that can be specified on cheatcode functions: +- `#[cheatcode(group = )]`: The group that the cheatcode belongs to. Required. +- `#[cheatcode(status = )]`: The current status of the cheatcode. E.g. whether it is stable or experimental, etc. Defaults to `Stable`. +- `#[cheatcode(safety = )]`: Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an unexpected way. Defaults to the group's safety if unspecified. If the group is ambiguous, then it must be specified manually. + +Multiple attributes can be specified by separating them with commas, e.g. `#[cheatcode(group = "evm", status = "unstable")]`. + +### `Cheatcode` trait + +This trait defines the interface that all cheatcode implementations must implement. +There are two methods that can be implemented: +- `apply`: implemented when the cheatcode is pure and does not need to access EVM data +- `apply_full`: implemented when the cheatcode needs to access EVM data + +Only one of these methods can be implemented. + +This trait is implemented manually for each cheatcode in the [`impls`](../../crates/cheatcodes/src/impls/) +module on the `sol!`-generated function call structs. + +### [JSON interface](../../crates/cheatcodes/assets/cheatcodes.json) + +The [JSON interface](../../crates/cheatcodes/assets/cheatcodes.json) and [schema](../../crates/cheatcodes/assets/cheatcodes.schema.json) +are automatically generated from the [`sol!` macro call](#sol) by running `cargo cheats`. + +The initial execution of this command, following the addition of a new cheat code, will result in an +update to the JSON files, which is expected to fail. This failure is necessary for the CI system to +detect that changes have occurred. Subsequent executions should pass, confirming the successful +update of the files. -## Adding a new cheat code +### Adding a new cheatcode -This process consists of 4 steps: +1. Add its Solidity definition(s) in [`src/defs/vm.rs`]. Ensure that all structs and functions are documented, and that all function parameters are named. This will initially fail to compile because of the automatically generated `match { ... }` expression. This is expected, and will be fixed in the next step +2. Implement the cheatcode in [`src/impls/`](src/impls/) in its category's respective module. Follow the existing implementations as a guide. +3. Update the JSON interface by running `cargo cheats` twice. This is expected to fail the first time that this is run after adding a new cheatcode; see [JSON interface](#json-interface) +4. Write an integration test for the cheatcode in [`testdata/cheats/`](../../testdata/cheats/) +5. Submit a PR to [`forge-std`](https://github.com/foundry-rs/forge-std) updating the Solidity interfaces as necessary. Note that this step won't be necessary once the Solidity interfaces are generated using the JSON interface -1. add the function signature to the `abigen!` macro so a new `HEVMCalls` variant is generated -2. implement the cheat code handler -3. add a Solidity test for the cheatcode under [`testdata/cheats`](https://github.com/foundry-rs/foundry/tree/master/testdata/cheats) -4. add the function signature - to [forge-std Vm interface](https://github.com/foundry-rs/forge-std/blob/master/src/Vm.sol) +[`sol!`]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html +[`src/defs/vm.rs`]: ./src/defs/vm.rs diff --git a/testdata/cheats/Env.t.sol b/testdata/cheats/Env.t.sol index fa1738de270bf..44e5f5db71fac 100644 --- a/testdata/cheats/Env.t.sol +++ b/testdata/cheats/Env.t.sol @@ -13,12 +13,12 @@ contract EnvTest is DSTest { vm.setEnv(key, val); } - uint256 constant numEnvBoolTests = 4; + uint256 constant numEnvBoolTests = 2; function testEnvBool() public { string memory key = "_foundryCheatcodeEnvBoolTestKey"; - string[numEnvBoolTests] memory values = ["true", "false", "True", "False"]; - bool[numEnvBoolTests] memory expected = [true, false, true, false]; + string[numEnvBoolTests] memory values = ["true", "false"]; + bool[numEnvBoolTests] memory expected = [true, false]; for (uint256 i = 0; i < numEnvBoolTests; ++i) { vm.setEnv(key, values[i]); bool output = vm.envBool(key); @@ -92,11 +92,11 @@ contract EnvTest is DSTest { function testEnvBytes32() public { string memory key = "_foundryCheatcodeEnvBytes32TestKey"; string[numEnvBytes32Tests] memory values = [ - "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000", + "0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811", "0x0000000000000000000000000000000000000000000000000000000000000000" ]; bytes32[numEnvBytes32Tests] memory expected = [ - bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), + bytes32(0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) ]; for (uint256 i = 0; i < numEnvBytes32Tests; ++i) { @@ -138,8 +138,8 @@ contract EnvTest is DSTest { function testEnvBoolArr() public { string memory key = "_foundryCheatcodeEnvBoolArrTestKey"; - string memory value = "true, false, True, False"; - bool[4] memory expected = [true, false, true, false]; + string memory value = "true, false"; + bool[numEnvBoolTests] memory expected = [true, false]; vm.setEnv(key, value); string memory delimiter = ","; @@ -190,10 +190,10 @@ contract EnvTest is DSTest { function testEnvBytes32Arr() public { string memory key = "_foundryCheatcodeEnvBytes32ArrTestKey"; - string memory value = "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000," + string memory value = "0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811," "0x0000000000000000000000000000000000000000000000000000000000000000"; bytes32[2] memory expected = [ - bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), + bytes32(0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) ]; @@ -340,8 +340,8 @@ contract EnvTest is DSTest { function testEnvOrBoolKey() public { string memory key = "_foundryCheatcodeEnvOrBoolTestKey"; - string[numEnvBoolTests] memory values = ["true", "false", "True", "False"]; - bool[numEnvBoolTests] memory expected = [true, false, true, false]; + string[numEnvBoolTests] memory values = ["true", "false"]; + bool[numEnvBoolTests] memory expected = [true, false]; for (uint256 i = 0; i < numEnvBoolTests; ++i) { vm.setEnv(key, values[i]); bool output = vm.envOr(key, expected[i]); @@ -351,7 +351,7 @@ contract EnvTest is DSTest { function testEnvOrBoolDefault() public { string memory key = "_foundryCheatcodeEnvOrBoolTestDefault"; - bool[numEnvBoolTests] memory expected = [true, false, true, false]; + bool[numEnvBoolTests] memory expected = [true, false]; for (uint256 i = 0; i < numEnvBoolTests; ++i) { bool output = vm.envOr(key, expected[i]); require(output == expected[i], "envOrBoolDefault failed"); @@ -451,9 +451,12 @@ contract EnvTest is DSTest { function testEnvOrBytes32Key() public { string memory key = "_foundryCheatcodeEnvOrBytes32TestKey"; - string[numEnvBytes32Tests] memory values = ["0x7109709ECfa91a80626fF3989D68f67F5b1DD12D", "0x00"]; + string[numEnvBytes32Tests] memory values = [ + "0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ]; bytes32[numEnvBytes32Tests] memory expected = [ - bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), + bytes32(0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) ]; for (uint256 i = 0; i < numEnvBytes32Tests; ++i) { @@ -466,7 +469,7 @@ contract EnvTest is DSTest { function testEnvOrBytes32Default() public { string memory key = "_foundryCheatcodeEnvOrBytes32TestDefault"; bytes32[numEnvBytes32Tests] memory expected = [ - bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), + bytes32(0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) ]; for (uint256 i = 0; i < numEnvBytes32Tests; ++i) { @@ -527,13 +530,11 @@ contract EnvTest is DSTest { function testEnvOrBoolArrKey() public { string memory key = "_foundryCheatcodeEnvBoolWithDefaultBoolArrTestKey"; - string memory value = "true, false, True, False"; - bool[4] memory expected = [true, false, true, false]; - bool[] memory defaultValues = new bool[](4); + string memory value = "true, false"; + bool[numEnvBoolTests] memory expected = [true, false]; + bool[] memory defaultValues = new bool[](numEnvBoolTests); defaultValues[0] = true; defaultValues[1] = false; - defaultValues[2] = true; - defaultValues[3] = false; vm.setEnv(key, value); string memory delimiter = ","; @@ -545,13 +546,11 @@ contract EnvTest is DSTest { function testEnvOrBoolArrDefault() public { string memory key = "_foundryCheatcodeEnvBoolWithDefaultBoolArrTestDefault"; - string memory value = "true, false, True, False"; - bool[4] memory expected = [true, false, true, false]; - bool[] memory defaultValues = new bool[](4); + string memory value = "true, false"; + bool[numEnvBoolTests] memory expected = [true, false]; + bool[] memory defaultValues = new bool[](numEnvBoolTests); defaultValues[0] = true; defaultValues[1] = false; - defaultValues[2] = true; - defaultValues[3] = false; string memory delimiter = ","; bool[] memory output = vm.envOr(key, delimiter, defaultValues); @@ -680,9 +679,10 @@ contract EnvTest is DSTest { function testEnvOrBytes32ArrKey() public { string memory key = "_foundryCheatcodeEnvOrBytes32ArrTestKey"; - string memory value = "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D," "0x00"; + string memory value = "0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811," + "0x0000000000000000000000000000000000000000000000000000000000000000"; bytes32[2] memory expected = [ - bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), + bytes32(0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) ]; bytes32[] memory defaultValues = new bytes32[](2); @@ -700,13 +700,14 @@ contract EnvTest is DSTest { function testEnvOrBytes32ArrDefault() public { string memory key = "_foundryCheatcodeEnvOrBytes32ArrTestDefault"; - string memory value = "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D," "0x00"; + string memory value = "0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811," + "0x0000000000000000000000000000000000000000000000000000000000000000"; bytes32[2] memory expected = [ - bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000), + bytes32(0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000) ]; bytes32[] memory defaultValues = new bytes32[](2); - defaultValues[0] = bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000); + defaultValues[0] = bytes32(0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811); defaultValues[1] = bytes32(0x0000000000000000000000000000000000000000000000000000000000000000); string memory delimiter = ","; @@ -774,9 +775,9 @@ contract EnvTest is DSTest { function testEnvOrBytesArrDefault() public { string memory key = "_foundryCheatcodeEnvOrBytesArrTestDefault"; - string memory value = "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D," "0x00"; + string memory value = "0x463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811," "0x00"; bytes[] memory expected = new bytes[](2); - expected[0] = hex"7109709ECfa91a80626fF3989D68f67F5b1DD12D"; + expected[0] = hex"463df98a03418e6196421718c1b96779a6d4f0bcff1702a9e8f2323bb49f6811"; expected[1] = hex"00"; string memory delimiter = ","; diff --git a/testdata/cheats/Etch.t.sol b/testdata/cheats/Etch.t.sol index 7df1e7200050e..33d957dab86a2 100644 --- a/testdata/cheats/Etch.t.sol +++ b/testdata/cheats/Etch.t.sol @@ -17,9 +17,7 @@ contract EtchTest is DSTest { function testEtchNotAvailableOnPrecompiles() public { address target = address(1); bytes memory code = hex"1010"; - vm.expectRevert( - bytes("Etch cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead") - ); + vm.expectRevert(bytes("cannot call `etch` on precompile 0x0000000000000000000000000000000000000001")); vm.etch(target, code); } } diff --git a/testdata/cheats/Fs.t.sol b/testdata/cheats/Fs.t.sol index 3ccc3e1216b83..9b53e92ee979f 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/cheats/Fs.t.sol @@ -4,79 +4,12 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "./Vm.sol"; -contract FsProxy is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - function readFile(string calldata path) external returns (string memory) { - return vm.readFile(path); - } - - function readDir(string calldata path) external returns (Vm.DirEntry[] memory) { - return vm.readDir(path); - } - - function readFileBinary(string calldata path) external returns (bytes memory) { - return vm.readFileBinary(path); - } - - function readLine(string calldata path) external returns (string memory) { - return vm.readLine(path); - } - - function writeLine(string calldata path, string calldata data) external { - return vm.writeLine(path, data); - } - - function writeFile(string calldata path, string calldata data) external { - return vm.writeLine(path, data); - } - - function writeFileBinary(string calldata path, bytes calldata data) external { - return vm.writeFileBinary(path, data); - } - - function removeFile(string calldata path) external { - return vm.removeFile(path); - } - - function fsMetadata(string calldata path) external returns (Vm.FsMetadata memory) { - return vm.fsMetadata(path); - } - - function createDir(string calldata path) external { - return vm.createDir(path, false); - } - - function createDir(string calldata path, bool recursive) external { - return vm.createDir(path, recursive); - } - - /// @notice Verifies if a given path exists on the disk - /// @dev Returns true if the given path points to an existing entity, else returns false - function exists(string calldata path) external returns (bool) { - return vm.exists(path); - } - - /// @notice Verifies if a given path points at a file - /// @dev Returns true if the given path points at a regular file, else returns false - function isFile(string calldata path) external returns (bool) { - return vm.isFile(path); - } - - /// @notice Verifies if a given path points at a directory - /// @dev Returns true if the given path points at a directory, else returns false - function isDir(string calldata path) external returns (bool) { - return vm.isDir(path); - } -} - contract FsTest is DSTest { - FsProxy public fsProxy; Vm constant vm = Vm(HEVM_ADDRESS); - bytes constant FOUNDRY_TOML_ACCESS_ERR = "Access to foundry.toml is not allowed."; - bytes constant FOUNDRY_READ_ERR = "The path \"/etc/hosts\" is not allowed to be accessed for read operations."; - bytes constant FOUNDRY_READ_DIR_ERR = "The path \"/etc\" is not allowed to be accessed for read operations."; - bytes constant FOUNDRY_WRITE_ERR = "The path \"/etc/hosts\" is not allowed to be accessed for write operations."; + bytes constant FOUNDRY_TOML_ACCESS_ERR = "access to foundry.toml is not allowed"; + bytes constant FOUNDRY_READ_ERR = "the path /etc/hosts is not allowed to be accessed for read operations"; + bytes constant FOUNDRY_READ_DIR_ERR = "the path /etc is not allowed to be accessed for read operations"; + bytes constant FOUNDRY_WRITE_ERR = "the path /etc/hosts is not allowed to be accessed for write operations"; function assertEntry(Vm.DirEntry memory entry, uint64 depth, bool dir) private { assertEq(entry.errorMessage, ""); @@ -86,22 +19,18 @@ contract FsTest is DSTest { } function testReadFile() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/read.txt"; assertEq(vm.readFile(path), "hello readable world\nthis is the second line!"); vm.expectRevert(FOUNDRY_READ_ERR); - fsProxy.readFile("/etc/hosts"); + vm.readFile("/etc/hosts"); vm.expectRevert(FOUNDRY_READ_ERR); - fsProxy.readFileBinary("/etc/hosts"); + vm.readFileBinary("/etc/hosts"); } function testReadLine() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/read.txt"; assertEq(vm.readLine(path), "hello readable world"); @@ -109,12 +38,10 @@ contract FsTest is DSTest { assertEq(vm.readLine(path), ""); vm.expectRevert(FOUNDRY_READ_ERR); - fsProxy.readLine("/etc/hosts"); + vm.readLine("/etc/hosts"); } function testWriteFile() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; vm.writeFile(path, data); @@ -124,9 +51,9 @@ contract FsTest is DSTest { vm.removeFile(path); vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeFile("/etc/hosts", "malicious stuff"); + vm.writeFile("/etc/hosts", "malicious stuff"); vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeFileBinary("/etc/hosts", "malicious stuff"); + vm.writeFileBinary("/etc/hosts", "malicious stuff"); } function testCopyFile() public { @@ -139,8 +66,6 @@ contract FsTest is DSTest { } function testWriteLine() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/write_line.txt"; string memory line1 = "first line"; @@ -154,7 +79,7 @@ contract FsTest is DSTest { vm.removeFile(path); vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeLine("/etc/hosts", "malicious stuff"); + vm.writeLine("/etc/hosts", "malicious stuff"); } function testCloseFile() public { @@ -166,8 +91,6 @@ contract FsTest is DSTest { } function testRemoveFile() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/remove_file.txt"; string memory data = "hello writable world"; @@ -181,50 +104,44 @@ contract FsTest is DSTest { vm.removeFile(path); vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.removeFile("/etc/hosts"); + vm.removeFile("/etc/hosts"); } function testWriteLineFoundrytoml() public { - fsProxy = new FsProxy(); - string memory root = vm.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); vm.expectRevert(); - fsProxy.writeLine(foundryToml, "\nffi = true\n"); + vm.writeLine(foundryToml, "\nffi = true\n"); vm.expectRevert(); - fsProxy.writeLine("foundry.toml", "\nffi = true\n"); + vm.writeLine("foundry.toml", "\nffi = true\n"); vm.expectRevert(); - fsProxy.writeLine("./foundry.toml", "\nffi = true\n"); + vm.writeLine("./foundry.toml", "\nffi = true\n"); vm.expectRevert(); - fsProxy.writeLine("./Foundry.toml", "\nffi = true\n"); + vm.writeLine("./Foundry.toml", "\nffi = true\n"); } function testWriteFoundrytoml() public { - fsProxy = new FsProxy(); - string memory root = vm.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); vm.expectRevert(); - fsProxy.writeFile(foundryToml, "\nffi = true\n"); + vm.writeFile(foundryToml, "\nffi = true\n"); vm.expectRevert(); - fsProxy.writeFile("foundry.toml", "\nffi = true\n"); + vm.writeFile("foundry.toml", "\nffi = true\n"); vm.expectRevert(); - fsProxy.writeFile("./foundry.toml", "\nffi = true\n"); + vm.writeFile("./foundry.toml", "\nffi = true\n"); vm.expectRevert(); - fsProxy.writeFile("./Foundry.toml", "\nffi = true\n"); + vm.writeFile("./Foundry.toml", "\nffi = true\n"); } function testReadDir() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/Dir"; { @@ -256,12 +173,10 @@ contract FsTest is DSTest { } vm.expectRevert(FOUNDRY_READ_DIR_ERR); - fsProxy.readDir("/etc"); + vm.readDir("/etc"); } function testCreateRemoveDir() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/Dir/remove_dir"; string memory child = string.concat(path, "/child"); @@ -270,11 +185,11 @@ contract FsTest is DSTest { vm.removeDir(path, false); vm.expectRevert(); - fsProxy.fsMetadata(path); + vm.fsMetadata(path); // reverts because not recursive vm.expectRevert(); - fsProxy.createDir(child, false); + vm.createDir(child, false); vm.createDir(child, true); assertEq(vm.fsMetadata(child).isDir, true); @@ -282,14 +197,12 @@ contract FsTest is DSTest { // deleted both, recursively vm.removeDir(path, true); vm.expectRevert(); - fsProxy.fsMetadata(path); + vm.fsMetadata(path); vm.expectRevert(); - fsProxy.fsMetadata(child); + vm.fsMetadata(child); } function testFsMetadata() public { - fsProxy = new FsProxy(); - Vm.FsMetadata memory metadata = vm.fsMetadata("fixtures/File"); assertEq(metadata.isDir, true); assertEq(metadata.isSymlink, false); @@ -314,10 +227,10 @@ contract FsTest is DSTest { // assertEq(metadata.isSymlink, true); vm.expectRevert(); - fsProxy.fsMetadata("../not-found"); + vm.fsMetadata("../not-found"); vm.expectRevert(FOUNDRY_READ_ERR); - fsProxy.fsMetadata("/etc/hosts"); + vm.fsMetadata("/etc/hosts"); } // not testing file cheatcodes per se @@ -326,55 +239,49 @@ contract FsTest is DSTest { emit log("Error: reading /etc/hosts should revert"); fail(); } catch (bytes memory err) { - assertEq(err, abi.encodeWithSignature("CheatCodeError", FOUNDRY_READ_ERR)); + assertEq(err, abi.encodeWithSignature("CheatcodeError(string)", FOUNDRY_READ_ERR)); } } function testExists() public { - fsProxy = new FsProxy(); - string memory validFilePath = "fixtures/File/read.txt"; assertTrue(vm.exists(validFilePath)); - assertTrue(fsProxy.exists(validFilePath)); + assertTrue(vm.exists(validFilePath)); string memory validDirPath = "fixtures/File"; assertTrue(vm.exists(validDirPath)); - assertTrue(fsProxy.exists(validDirPath)); + assertTrue(vm.exists(validDirPath)); string memory invalidPath = "fixtures/File/invalidfile.txt"; assertTrue(vm.exists(invalidPath) == false); - assertTrue(fsProxy.exists(invalidPath) == false); + assertTrue(vm.exists(invalidPath) == false); } function testIsFile() public { - fsProxy = new FsProxy(); - string memory validFilePath = "fixtures/File/read.txt"; assertTrue(vm.isFile(validFilePath)); - assertTrue(fsProxy.isFile(validFilePath)); + assertTrue(vm.isFile(validFilePath)); string memory invalidFilePath = "fixtures/File/invalidfile.txt"; assertTrue(vm.isFile(invalidFilePath) == false); - assertTrue(fsProxy.isFile(invalidFilePath) == false); + assertTrue(vm.isFile(invalidFilePath) == false); string memory dirPath = "fixtures/File"; assertTrue(vm.isFile(dirPath) == false); - assertTrue(fsProxy.isFile(dirPath) == false); + assertTrue(vm.isFile(dirPath) == false); } function testIsDir() public { - fsProxy = new FsProxy(); - string memory validDirPath = "fixtures/File"; assertTrue(vm.isDir(validDirPath)); - assertTrue(fsProxy.isDir(validDirPath)); + assertTrue(vm.isDir(validDirPath)); string memory invalidDirPath = "fixtures/InvalidDir"; assertTrue(vm.isDir(invalidDirPath) == false); - assertTrue(fsProxy.isDir(invalidDirPath) == false); + assertTrue(vm.isDir(invalidDirPath) == false); string memory filePath = "fixtures/File/read.txt"; assertTrue(vm.isDir(filePath) == false); - assertTrue(fsProxy.isDir(filePath) == false); + assertTrue(vm.isDir(filePath) == false); } } diff --git a/testdata/cheats/GetCode.t.sol b/testdata/cheats/GetCode.t.sol index ee62fc44d61fd..1d91fca302026 100644 --- a/testdata/cheats/GetCode.t.sol +++ b/testdata/cheats/GetCode.t.sol @@ -43,6 +43,8 @@ contract GetCodeTest is DSTest { assertEq(string(fullPath), expected, "code for full path was incorrect"); } + // TODO: Huff uses its own ABI. + /* function testGetCodeHuffArtifact() public { string memory path = "fixtures/GetCode/HuffWorkingContract.json"; bytes memory bytecode = vm.getCode(path); @@ -63,6 +65,7 @@ contract GetCodeTest is DSTest { // compare the loaded code to the actual deployed code assertEq(string(deployedCode), string(deployed.code), "deployedCode for path was incorrect"); } + */ function testFailGetUnlinked() public { vm.getCode("UnlinkedContract.sol"); diff --git a/testdata/cheats/Json.t.sol b/testdata/cheats/Json.t.sol index 06e4e44a8b41c..68164d3a01531 100644 --- a/testdata/cheats/Json.t.sol +++ b/testdata/cheats/Json.t.sol @@ -98,9 +98,7 @@ contract ParseJsonTest is DSTest { } function test_coercionRevert() public { - vm.expectRevert( - "You can only coerce values or arrays, not JSON objects. The key '.nestedObject' returns an object" - ); + vm.expectRevert("values at \".nestedObject\" must not be JSON objects"); uint256 number = this.parseJsonUint(json, ".nestedObject"); } @@ -163,15 +161,13 @@ contract ParseJsonTest is DSTest { keys = vm.parseJsonKeys(jsonString, ".some_key_to_object"); assertEq(abi.encode(keys), abi.encode(["key1", "key2"])); - vm.expectRevert("You can only get keys for JSON-object. The key '.some_key_to_array' does not return an object"); + vm.expectRevert("JSON value at \".some_key_to_array\" is not an object"); vm.parseJsonKeys(jsonString, ".some_key_to_array"); - vm.expectRevert("You can only get keys for JSON-object. The key '.some_key_to_value' does not return an object"); + vm.expectRevert("JSON value at \".some_key_to_value\" is not an object"); vm.parseJsonKeys(jsonString, ".some_key_to_value"); - vm.expectRevert( - "You can only get keys for a single JSON-object. The key '.*' returns a value or an array of JSON-objects" - ); + vm.expectRevert("JSON value at \".*\" is not an object"); vm.parseJsonKeys(jsonString, ".*"); } } diff --git a/testdata/cheats/Load.t.sol b/testdata/cheats/Load.t.sol index a8a9ed2ffab82..b1328255e1ef0 100644 --- a/testdata/cheats/Load.t.sol +++ b/testdata/cheats/Load.t.sol @@ -27,9 +27,7 @@ contract LoadTest is DSTest { } function testLoadNotAvailableOnPrecompiles() public { - vm.expectRevert( - bytes("Load cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead") - ); + vm.expectRevert(bytes("cannot call `load` on precompile 0x0000000000000000000000000000000000000001")); uint256 val = this.load(address(1), bytes32(0)); } diff --git a/testdata/cheats/RpcUrls.t.sol b/testdata/cheats/RpcUrls.t.sol index 497092384eef1..8fa26e31b6f54 100644 --- a/testdata/cheats/RpcUrls.t.sol +++ b/testdata/cheats/RpcUrls.t.sol @@ -15,7 +15,7 @@ contract RpcUrlTest is DSTest { // returns an error if env alias does not exist function testRevertsOnMissingEnv() public { - vm.expectRevert("invalid rpc url rpcUrlEnv"); + vm.expectRevert("invalid rpc url: rpcUrlEnv"); string memory url = this.rpcUrl("rpcUrlEnv"); } diff --git a/testdata/cheats/Sleep.t.sol b/testdata/cheats/Sleep.t.sol index 3efc8b127f68f..7b592f3f3f765 100644 --- a/testdata/cheats/Sleep.t.sol +++ b/testdata/cheats/Sleep.t.sol @@ -27,6 +27,7 @@ contract SleepTest is DSTest { assertGe(end - start, milliseconds / 1000 * 1000, "sleep failed"); } + /* /// forge-config: default.fuzz.runs = 10 function testSleepFuzzed(uint256 _milliseconds) public { // Limit sleep time to 2 seconds to decrease test time @@ -48,4 +49,5 @@ contract SleepTest is DSTest { // Limit precision to 1000 ms assertGe(end - start, milliseconds / 1000 * 1000, "sleep failed"); } + */ } diff --git a/testdata/cheats/Store.t.sol b/testdata/cheats/Store.t.sol index 5d609ff26e4dd..bc93bae412425 100644 --- a/testdata/cheats/Store.t.sol +++ b/testdata/cheats/Store.t.sol @@ -30,9 +30,7 @@ contract StoreTest is DSTest { assertEq(store.slot0(), 10, "initial value for slot 0 is incorrect"); assertEq(store.slot1(), 20, "initial value for slot 1 is incorrect"); - vm.expectRevert( - bytes("Store cannot be used on precompile addresses (N < 10). Please use an address bigger than 10 instead") - ); + vm.expectRevert(bytes("cannot call `store` on precompile 0x0000000000000000000000000000000000000001")); this._store(address(1), bytes32(0), bytes32(uint256(1))); } diff --git a/testdata/cheats/TryFfi.sol b/testdata/cheats/TryFfi.sol index aa24842390a43..4702fd61d8c95 100644 --- a/testdata/cheats/TryFfi.sol +++ b/testdata/cheats/TryFfi.sol @@ -17,7 +17,7 @@ contract TryFfiTest is DSTest { Vm.FfiResult memory f = vm.tryFfi(inputs); (string memory output) = abi.decode(f.stdout, (string)); assertEq(output, "ffi works", "ffi failed"); - assertEq(f.exit_code, 0, "ffi failed"); + assertEq(f.exitCode, 0, "ffi failed"); } function testTryFfiFail() public { @@ -26,6 +26,6 @@ contract TryFfiTest is DSTest { inputs[1] = "wad"; Vm.FfiResult memory f = vm.tryFfi(inputs); - assertTrue(f.exit_code != 0); + assertTrue(f.exitCode != 0); } } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 05b4bd315f5e8..23e319aec3db6 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -1,687 +1,226 @@ -// SPDX-License-Identifier: Unlicense -pragma solidity >=0.8.0; +// Automatically generated from `foundry-cheatcodes` Vm definitions. Do not modify manually. +// This interface is just for internal testing purposes. Use `forge-std` instead. interface Vm { - // Possible caller modes for readCallers() - enum CallerMode { - None, - Broadcast, - RecurrentBroadcast, - Prank, - RecurrentPrank - } - - // This allows us to getRecordedLogs() - struct Log { - bytes32[] topics; - bytes data; - address emitter; - } - - // Used in getRpcStructs - struct Rpc { - string name; - string url; - } - - // Used in eth_getLogs - struct EthGetLogs { - address emitter; - bytes32[] topics; - bytes data; - uint256 blockNumber; - bytes32 transactionHash; - uint256 transactionIndex; - bytes32 blockHash; - uint256 logIndex; - bool removed; - } - - // Used in readDir - struct DirEntry { - string errorMessage; - string path; - uint64 depth; - bool isDir; - bool isSymlink; - } - - // Used in fsMetadata - struct FsMetadata { - bool isDir; - bool isSymlink; - uint256 length; - bool readOnly; - uint256 modified; - uint256 accessed; - uint256 created; - } - - // Returned by 'createWallet'. Used with 'sign' and 'getNonce' - struct Wallet { - address addr; - uint256 publicKeyX; - uint256 publicKeyY; - uint256 privateKey; - } - - struct FfiResult { - int32 exit_code; - bytes stdout; - bytes stderr; - } - - // Set block.timestamp (newTimestamp) - function warp(uint256) external; - - // Set block.difficulty (newDifficulty) - // No longer works from Paris onwards. - function difficulty(uint256) external; - - // Set block.prevrandao (newPrevrandao) - function prevrandao(bytes32) external; - - // Set block.height (newHeight) - function roll(uint256) external; - - // Set block.basefee (newBasefee) - function fee(uint256) external; - - // Set block.coinbase (who) - function coinbase(address) external; - - // Loads a storage slot from an address (who, slot) - function load(address, bytes32) external returns (bytes32); - - // Stores a value to an address' storage slot, (who, slot, value) - function store(address, bytes32, bytes32) external; - - // Cools off a warm address and its storage slots - function cool(address) external; - - // Signs data, (privateKey, digest) => (v, r, s) - function sign(uint256, bytes32) external returns (uint8, bytes32, bytes32); - - // Gets address for a given private key, (privateKey) => (address) - function addr(uint256) external returns (address); - - // Derive a private key from a provided English mnemonic string (or mnemonic file path) at the derivation path m/44'/60'/0'/0/{index} - function deriveKey(string calldata, uint32) external returns (uint256); - - // Derive a private key from a provided English mnemonic string (or mnemonic file path) at the derivation path {path}{index} - function deriveKey(string calldata, string calldata, uint32) external returns (uint256); - - // Derive a private key from a provided mnemonic string (or mnemonic file path) of specified language at the derivation path m/44'/60'/0'/0/{index} - function deriveKey(string calldata, uint32, string calldata) external returns (uint256); - - // Derive a private key from a provided mnemonic string (or mnemonic file path) of specified language at the derivation path {path}{index} - function deriveKey(string calldata, string calldata, uint32, string calldata) external returns (uint256); - - // Adds a private key to the local forge wallet and returns the address - function rememberKey(uint256) external returns (address); - - // Derives a private key from the name, labels the account with that name, and returns the wallet - function createWallet(string calldata) external returns (Wallet memory); - - // Generates a wallet from the private key and returns the wallet - function createWallet(uint256) external returns (Wallet memory); - - // Generates a wallet from the private key, labels the account with that name, and returns the wallet - function createWallet(uint256, string calldata) external returns (Wallet memory); - - // Signs data, (Wallet, digest) => (v, r, s) - function sign(Wallet calldata, bytes32) external returns (uint8, bytes32, bytes32); - - // Get nonce for a Wallet - function getNonce(Wallet calldata) external returns (uint64); - - // Performs a foreign function call via terminal, (stringInputs) => (result) - function ffi(string[] calldata) external returns (bytes memory); - - // Performs a foreign function call via terminal and returns the exit code, stdout, and stderr - function tryFfi(string[] calldata) external returns (FfiResult memory); - - // Set environment variables, (name, value) - function setEnv(string calldata, string calldata) external; - - // Read environment variables, (name) => (value) - function envBool(string calldata) external returns (bool); - - function envUint(string calldata) external returns (uint256); - - function envInt(string calldata) external returns (int256); - - function envAddress(string calldata) external returns (address); - - function envBytes32(string calldata) external returns (bytes32); - - function envString(string calldata) external returns (string memory); - - function envBytes(string calldata) external returns (bytes memory); - - // Read environment variables as arrays, (name, delim) => (value[]) - function envBool(string calldata, string calldata) external returns (bool[] memory); - - function envUint(string calldata, string calldata) external returns (uint256[] memory); - - function envInt(string calldata, string calldata) external returns (int256[] memory); - - function envAddress(string calldata, string calldata) external returns (address[] memory); - - function envBytes32(string calldata, string calldata) external returns (bytes32[] memory); - - function envString(string calldata, string calldata) external returns (string[] memory); - - function envBytes(string calldata, string calldata) external returns (bytes[] memory); - - // Read environment variables with default value, (name, value) => (value) - function envOr(string calldata, bool) external returns (bool); - - function envOr(string calldata, uint256) external returns (uint256); - - function envOr(string calldata, int256) external returns (int256); - - function envOr(string calldata, address) external returns (address); - - function envOr(string calldata, bytes32) external returns (bytes32); - - function envOr(string calldata, string calldata) external returns (string memory); - - function envOr(string calldata, bytes calldata) external returns (bytes memory); - - // Read environment variables as arrays with default value, (name, value[]) => (value[]) - function envOr(string calldata, string calldata, bool[] calldata) external returns (bool[] memory); - - function envOr(string calldata, string calldata, uint256[] calldata) external returns (uint256[] memory); - - function envOr(string calldata, string calldata, int256[] calldata) external returns (int256[] memory); - - function envOr(string calldata, string calldata, address[] calldata) external returns (address[] memory); - - function envOr(string calldata, string calldata, bytes32[] calldata) external returns (bytes32[] memory); - - function envOr(string calldata, string calldata, string[] calldata) external returns (string[] memory); - - function envOr(string calldata, string calldata, bytes[] calldata) external returns (bytes[] memory); - - // Sets the *next* call's msg.sender to be the input address - function prank(address) external; - - // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called - function startPrank(address) external; - - // Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input - function prank(address, address) external; - - // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and the tx.origin to be the second input - function startPrank(address, address) external; - - // Resets subsequent calls' msg.sender to be `address(this)` - function stopPrank() external; - - // Reads the current msg.sender and tx.origin from state - function readCallers() external returns (CallerMode, address, address); - - // Sets an address' balance, (who, newBalance) - function deal(address, uint256) external; - - // Sets an address' code, (who, newCode) - function etch(address, bytes calldata) external; - - // Skips a test. - function skip(bool) external; - - // Sleeps for a given number of milliseconds. - function sleep(uint256) external; - - /// Returns the time since unix epoch in milliseconds - function unixTime() external returns (uint256); - - // Expects an error on next call + error CheatcodeError(string message); + enum CallerMode { None, Broadcast, RecurrentBroadcast, Prank, RecurrentPrank } + 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; } + function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots); + function activeFork() external view returns (uint256 forkId); + function addr(uint256 privateKey) external pure returns (address keyAddr); + function allowCheatcodes(address account) external; + function assume(bool condition) external pure; + function breakpoint(string calldata char) external; + function breakpoint(string calldata char, bool value) external; + function broadcast() external; + function broadcast(address signer) external; + function broadcast(uint256 privateKey) external; + function chainId(uint256 newChainId) external; + function clearMockedCalls() external; + function closeFile(string calldata path) external; + function coinbase(address newCoinbase) external; + function cool(address target) external; + function copyFile(string calldata from, string calldata to) external returns (uint64 copied); + function createDir(string calldata path, bool recursive) external; + function createFork(string calldata urlOrAlias) external returns (uint256 forkId); + function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId); + function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId); + function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId); + function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId); + function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId); + function createWallet(string calldata walletLabel) external returns (Wallet memory wallet); + function createWallet(uint256 privateKey) external returns (Wallet memory wallet); + function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet); + function deal(address account, uint256 newBalance) external; + 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 difficulty(uint256 newDifficulty) external; + function envAddress(string calldata name) external view returns (address value); + function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value); + function envBool(string calldata name) external view returns (bool value); + function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value); + function envBytes32(string calldata name) external view returns (bytes32 value); + function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value); + function envBytes(string calldata name) external view returns (bytes memory value); + function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value); + function envInt(string calldata name) external view returns (int256 value); + function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value); + function envOr(string calldata name, bool defaultValue) external returns (bool value); + function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value); + function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external returns (address[] memory value); + function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external returns (bytes32[] memory value); + function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external returns (string[] memory value); + function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external returns (bytes[] memory value); + function envOr(string calldata name, int256 defaultValue) external returns (int256 value); + function envOr(string calldata name, address defaultValue) external returns (address value); + function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value); + function envOr(string calldata name, string calldata defaultValue) external returns (string memory value); + function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value); + function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external returns (bool[] memory value); + function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external returns (uint256[] memory value); + function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external 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); + function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value); + function etch(address target, bytes calldata newRuntimeBytecode) external; + function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics) external returns (EthGetLogs[] memory logs); + function exists(string calldata path) external 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 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 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() external; + function expectEmit(address emitter) external; function expectRevert() external; - - function expectRevert(bytes calldata) external; - - function expectRevert(bytes4) external; - - // Record all storage reads and writes + function expectRevert(bytes4 revertData) external; + function expectRevert(bytes calldata revertData) external; + function expectSafeMemory(uint64 min, uint64 max) external; + function expectSafeMemoryCall(uint64 min, uint64 max) external; + function fee(uint256 newBasefee) external; + function ffi(string[] calldata commandInput) external returns (bytes memory result); + function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); + function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); + function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); + function getLabel(address account) external returns (string memory currentLabel); + 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); + function getNonce(Wallet calldata wallet) external returns (uint64 nonce); + function getRecordedLogs() external returns (Log[] memory logs); + function isDir(string calldata path) external returns (bool result); + function isFile(string calldata path) external returns (bool result); + function isPersistent(address account) external view returns (bool persistent); + function keyExists(string calldata json, string calldata key) external view returns (bool); + function label(address account, string calldata newLabel) external; + function load(address target, bytes32 slot) external view returns (bytes32 data); + function makePersistent(address account) external; + function makePersistent(address account0, address account1) external; + function makePersistent(address account0, address account1, address account2) external; + function makePersistent(address[] calldata accounts) external; + function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; + function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; + function mockCall(address callee, bytes calldata data, bytes calldata returnData) external; + function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; + function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue); + function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); + function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue); + 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 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 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 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 parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue); + function pauseGasMetering() external; + function prank(address msgSender) external; + function prank(address msgSender, address txOrigin) external; + function prevrandao(bytes32 newPrevrandao) external; + function projectRoot() external view returns (string memory path); + 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 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); + function readLink(string calldata linkPath) external view returns (string memory targetPath); function record() external; - - // Gets all accessed reads and write slot from a recording session, for a given address - function accesses(address) external returns (bytes32[] memory reads, bytes32[] memory writes); - - // Record all the transaction logs function recordLogs() external; - - // Gets all the recorded logs - function getRecordedLogs() external returns (Log[] memory); - - // Prepare an expected log with all four checks enabled. - // Call this function, then emit an event, then call a function. Internally after the call, we check if - // logs were emitted in the expected order with the expected topics and data. - // Second form also checks supplied address against emitting contract. - function expectEmit() external; - - // Prepare an expected log with all four checks enabled, and check supplied address against emitting contract. - function expectEmit(address) external; - - // Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData). - // Call this function, then emit an event, then call a function. Internally after the call, we check if - // logs were emitted in the expected order with the expected topics and data (as specified by the booleans). - // Second form also checks supplied address against emitting contract. - function expectEmit(bool, bool, bool, bool) external; - - function expectEmit(bool, bool, bool, bool, address) external; - - // Mocks a call to an address, returning specified data. - // Calldata can either be strict or a partial match, e.g. if you only - // pass a Solidity selector to the expected calldata, then the entire Solidity - // function will be mocked. - function mockCall(address, bytes calldata, bytes calldata) external; - - // Mocks a call to an address with a specific msg.value, returning specified data. - // Calldata match takes precedence over msg.value in case of ambiguity. - function mockCall(address, uint256, bytes calldata, bytes calldata) external; - - // Reverts a call to an address with specified revert data. - function mockCallRevert(address, bytes calldata, bytes calldata) external; - - // Reverts a call to an address with a specific msg.value, with specified revert data. - function mockCallRevert(address, uint256 msgValue, bytes calldata, bytes calldata) external; - - // Clears all mocked calls - function clearMockedCalls() external; - - // Expect a call to an address with the specified calldata. - // Calldata can either be strict or a partial match - function expectCall(address, bytes calldata) external; - - // Expect given number of calls to an address with the specified calldata. - // Calldata can either be strict or a partial match - function expectCall(address, bytes calldata, uint64) external; - - // Expect a call to an address with the specified msg.value and calldata - function expectCall(address, uint256, bytes calldata) external; - - // Expect a given number of calls to an address with the specified msg.value and calldata - function expectCall(address, uint256, bytes calldata, uint64) external; - - // Expect a call to an address with the specified msg.value, gas, and calldata. - function expectCall(address, uint256, uint64, bytes calldata) external; - - // Expect a given number of calls to an address with the specified msg.value, gas, and calldata. - function expectCall(address, uint256, uint64, bytes calldata, uint64) external; - - // Expect a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas. - function expectCallMinGas(address, uint256, uint64, bytes calldata) external; - - // Expect a given number of calls to an address with the specified msg.value and calldata, and a *minimum* amount of gas. - function expectCallMinGas(address, uint256, uint64, bytes calldata, uint64) external; - - // Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other - // memory is written to, the test will fail. - function expectSafeMemory(uint64, uint64) external; - - // Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. - // If any other memory is written to, the test will fail. - function expectSafeMemoryCall(uint64, uint64) external; - - // Gets the bytecode from an artifact file. Takes in the relative path to the json file - function getCode(string calldata) external returns (bytes memory); - - // Gets the _deployed_ bytecode from an artifact file. Takes in the relative path to the json file - function getDeployedCode(string calldata) external returns (bytes memory); - - // Labels an address in call traces - function label(address, string calldata) external; - - // Retrieves a label by its address. - function getLabel(address) external returns (string memory); - - // If the condition is false, discard this run's fuzz inputs and generate new ones - function assume(bool) external; - - // Set nonce for an account - function setNonce(address, uint64) external; - - // Get nonce for an account - function getNonce(address) external returns (uint64); - - // Resets the nonce for an account - function resetNonce(address) external; - - // Set an arbitrary nonce for an account - function setNonceUnsafe(address, uint64) external; - - // Set block.chainid (newChainId) - function chainId(uint256) external; - - // Using the address that calls the test contract, has the next call (at this call depth only) create a transaction that can later be signed and sent onchain - function broadcast() external; - - // Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain - function broadcast(address) external; - - // Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain - function broadcast(uint256) external; - - // Using the address that calls the test contract, has the all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain - function startBroadcast() external; - - // Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain - function startBroadcast(address) external; - - // Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain - function startBroadcast(uint256) external; - - // Stops collecting onchain transactions - function stopBroadcast() external; - - // Get the path of the current project root - function projectRoot() external returns (string memory); - - // Reads the entire content of file to string. Path is relative to the project root. - // (path) => (data) - function readFile(string calldata) external returns (string memory); - - // Reads the entire content of file as binary. Path is relative to the project root. - // (path) => (data) - function readFileBinary(string calldata) external returns (bytes memory); - - // Reads next line of file to string. - // (path) => (line) - function readLine(string calldata) external returns (string memory); - - // Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does. - // `path` is relative to the project root. - // (path, data) => () - function writeFile(string calldata, string calldata) external; - - // Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does. - // `path` is relative to the project root. - // (path, data) => () - function writeFileBinary(string calldata, bytes calldata) external; - - // Writes line to file, creating a file if it does not exist. - // `path` is relative to the project root. - // (path, data) => () - function writeLine(string calldata, string calldata) external; - - // Copies the contents of one file to another. This function will **overwrite** the contents of `to`. - // On success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`. - // Both `from` and `to` are relative to the project root. - // (from, to) => (copied) - function copyFile(string calldata, string calldata) external returns (uint64); - - // Closes file for reading, resetting the offset and allowing to read it from beginning with readLine. - // `path` is relative to the project root. - // (path) => () - function closeFile(string calldata) external; - - // Removes a file from the filesystem. - // This cheatcode will revert in the following situations, but is not limited to just these cases: - // - `path` points to a directory. - // - The file doesn't exist. - // - The user lacks permissions to remove the file. - // `path` is relative to the project root. - // (path) => () - function removeFile(string calldata) external; - - // Creates a new, empty directory at the provided path. - // This cheatcode will revert in the following situations, but is not limited to just these cases: - // - User lacks permissions to modify `path`. - // - A parent of the given path doesn't exist and `recursive` is false. - // - `path` already exists and `recursive` is false. - // `path` is relative to the project root. - // (path, recursive) => () - function createDir(string calldata, bool) external; - - // Removes a directory at the provided path. - // This cheatcode will revert in the following situations, but is not limited to just these cases: - // - `path` doesn't exist. - // - `path` isn't a directory. - // - User lacks permissions to modify `path`. - // - The directory is not empty and `recursive` is false. - // `path` is relative to the project root. - // (path, recursive) => () - function removeDir(string calldata, bool) external; - - // Reads the directory at the given path recursively, up to `max_depth`. - // `max_depth` defaults to 1, meaning only the direct children of the given directory will be returned. - // Follows symbolic links if `follow_links` is true. - // (path) => (entries) - function readDir(string calldata) external returns (DirEntry[] memory); - - // (path, max_depth) => (entries) - function readDir(string calldata, uint64) external returns (DirEntry[] memory); - - // (path, max_depth, follow_links) => (entries) - function readDir(string calldata, uint64, bool) external returns (DirEntry[] memory); - - // Reads a symbolic link, returning the path that the link points to. - // This cheatcode will revert in the following situations, but is not limited to just these cases: - // - `path` is not a symbolic link. - // - `path` does not exist. - // (link_path) => (path) - function readLink(string calldata) external returns (string memory); - - // Given a path, query the file system to get information about a file, directory, etc. - // (path) => (metadata) - function fsMetadata(string calldata) external returns (FsMetadata memory); - - function toString(address) external returns (string memory); - - function toString(bytes calldata) external returns (string memory); - - function toString(bytes32) external returns (string memory); - - function toString(bool) external returns (string memory); - - function toString(uint256) external returns (string memory); - - function toString(int256) external returns (string memory); - - function parseBytes(string memory) external returns (bytes memory); - - function parseAddress(string memory) external returns (address); - - function parseUint(string memory) external returns (uint256); - - function parseInt(string memory) external returns (int256); - - function parseBytes32(string memory) external returns (bytes32); - - function parseBool(string memory) external returns (bool); - - // Snapshot the current state of the evm. - // Returns the id of the snapshot that was created. - // To revert a snapshot use `revertTo` - function snapshot() external returns (uint256); - - // Revert the state of the evm to a previous snapshot - // Takes the snapshot id to revert to. - // This deletes the snapshot and all snapshots taken after the given snapshot id. - function revertTo(uint256) external returns (bool); - - // Creates a new fork with the given endpoint and block and returns the identifier of the fork - function createFork(string calldata, uint256) external returns (uint256); - - // Creates a new fork with the given endpoint and at the block the given transaction was mined in, and replays all transaction mined in the block before the transaction - function createFork(string calldata, bytes32) external returns (uint256); - - // Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork - function createFork(string calldata) external returns (uint256); - - // Creates _and_ also selects a new fork with the given endpoint and block and returns the identifier of the fork - function createSelectFork(string calldata, uint256) external returns (uint256); - - // Creates _and_ also selects new fork with the given endpoint and at the block the given transaction was mined in, and replays all transaction mined in the block before the transaction - function createSelectFork(string calldata, bytes32) external returns (uint256); - - // Creates _and_ also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork - function createSelectFork(string calldata) external returns (uint256); - - // Takes a fork identifier created by `createFork` and sets the corresponding forked state as active. - function selectFork(uint256) external; - - // Fetches the given transaction from the active fork and executes it on the current state - function transact(bytes32) external; - - // Fetches the given transaction from the given fork and executes it on the current state - function transact(uint256, bytes32) external; - - // Returns the currently active fork - // Reverts if no fork is currently active - function activeFork() external returns (uint256); - - // In forking mode, explicitly grant the given address cheatcode access - function allowCheatcodes(address) external; - - // Marks that the account(s) should use persistent storage across fork swaps. - // Meaning, changes made to the state of this account will be kept when switching forks - function makePersistent(address) external; - - function makePersistent(address, address) external; - - function makePersistent(address, address, address) external; - - function makePersistent(address[] calldata) external; - - // Revokes persistent status from the address, previously added via `makePersistent` - function revokePersistent(address) external; - - function revokePersistent(address[] calldata) external; - - // Returns true if the account is marked as persistent - function isPersistent(address) external returns (bool); - - // Updates the currently active fork to given block number - // This is similar to `roll` but for the currently active fork - function rollFork(uint256) external; - - // Updates the currently active fork to given transaction - // this will `rollFork` with the number of the block the transaction was mined in and replays all transaction mined before it in the block - function rollFork(bytes32) external; - - // Updates the given fork to given block number - function rollFork(uint256 forkId, uint256 blockNumber) external; - - // Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block - function rollFork(uint256 forkId, bytes32 transaction) external; - - /// Returns the RPC url for the given alias - function rpcUrl(string calldata) external returns (string memory); - - /// Returns all rpc urls and their aliases `[alias, url][]` - function rpcUrls() external returns (string[2][] memory); - - /// Returns all rpc urls and their aliases as an array of structs - function rpcUrlStructs() external returns (Rpc[] memory); - - // Gets all the logs according to specified filter - function eth_getLogs(uint256, uint256, address, bytes32[] memory) external returns (EthGetLogs[] memory); - - // Generic rpc call function - function rpc(string calldata, string calldata) external returns (bytes memory); - - function parseJson(string calldata, string calldata) external returns (bytes memory); - - function parseJson(string calldata) external returns (bytes memory); - - function parseJsonKeys(string calldata, string calldata) external returns (string[] memory); - - function parseJsonUint(string calldata, string calldata) external returns (uint256); - - function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory); - - function parseJsonInt(string calldata, string calldata) external returns (int256); - - function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory); - - function parseJsonBool(string calldata, string calldata) external returns (bool); - - function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory); - - function parseJsonAddress(string calldata, string calldata) external returns (address); - - function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory); - - function parseJsonString(string calldata, string calldata) external returns (string memory); - - function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory); - - function parseJsonBytes(string calldata, string calldata) external returns (bytes memory); - - function parseJsonBytesArray(string calldata, string calldata) external returns (bytes[] memory); - - function parseJsonBytes32(string calldata, string calldata) external returns (bytes32); - - function parseJsonBytes32Array(string calldata, string calldata) external returns (bytes32[] memory); - - function serializeJson(string calldata, string calldata) external returns (string memory); - - function serializeBool(string calldata, string calldata, bool) external returns (string memory); - - function serializeUint(string calldata, string calldata, uint256) external returns (string memory); - - function serializeInt(string calldata, string calldata, int256) external returns (string memory); - - function serializeAddress(string calldata, string calldata, address) external returns (string memory); - - function serializeBytes32(string calldata, string calldata, bytes32) external returns (string memory); - - function serializeString(string calldata, string calldata, string calldata) external returns (string memory); - - function serializeBytes(string calldata, string calldata, bytes calldata) external returns (string memory); - - function serializeBool(string calldata, string calldata, bool[] calldata) external returns (string memory); - - function serializeUint(string calldata, string calldata, uint256[] calldata) external returns (string memory); - - function serializeInt(string calldata, string calldata, int256[] calldata) external returns (string memory); - - function serializeAddress(string calldata, string calldata, address[] calldata) external returns (string memory); - - function serializeBytes32(string calldata, string calldata, bytes32[] calldata) external returns (string memory); - - function serializeString(string calldata, string calldata, string[] calldata) external returns (string memory); - - function serializeBytes(string calldata, string calldata, bytes[] calldata) external returns (string memory); - - function writeJson(string calldata, string calldata) external; - - function writeJson(string calldata, string calldata, string calldata) external; - - // Checks if a key exists in the given json string - function keyExists(string calldata, string calldata) external returns (bool); - - // Pauses gas metering (gas usage will not be counted) - function pauseGasMetering() external; - - // Resumes gas metering from where it left off + function rememberKey(uint256 privateKey) external returns (address keyAddr); + function removeDir(string calldata path, bool recursive) external; + function removeFile(string calldata path) external; + function resetNonce(address account) external; function resumeGasMetering() external; - - // Starts recording all map SSTOREs for later retrieval. + function revertTo(uint256 snapshotId) external returns (bool success); + function revokePersistent(address account) external; + function revokePersistent(address[] calldata accounts) external; + function roll(uint256 newHeight) external; + function rollFork(uint256 blockNumber) external; + function rollFork(bytes32 txHash) external; + function rollFork(uint256 forkId, uint256 blockNumber) external; + function rollFork(uint256 forkId, bytes32 txHash) external; + function rpc(string calldata method, string calldata params) external returns (bytes memory data); + function rpcUrl(string calldata rpcAlias) external view returns (string memory json); + function rpcUrlStructs() external view returns (Rpc[] memory urls); + function rpcUrls() external view returns (string[2][] memory urls); + 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 serializeJson(string calldata objectKey, string calldata 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 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 setEnv(string calldata name, string calldata value) external; + function setNonce(address account, uint64 newNonce) external; + function setNonceUnsafe(address account, uint64 newNonce) external; + function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); + function skip(bool skipTest) external; + function sleep(uint256 duration) external; + function snapshot() external returns (uint256 snapshotId); + function startBroadcast() external; + function startBroadcast(address signer) external; + function startBroadcast(uint256 privateKey) external; function startMappingRecording() external; - - // Stops recording all map SSTOREs for later retrieval and clears the recorded data. + function startPrank(address msgSender) external; + function startPrank(address msgSender, address txOrigin) external; + function stopBroadcast() external; function stopMappingRecording() external; - - // Gets the length of a mapping at a given slot, for a given address. - function getMappingLength(address target, bytes32 slot) external returns (uint256); - - // Gets the element at index idx of a mapping at a given slot, for a given address. - function getMappingSlotAt(address target, bytes32 slot, uint256 idx) external returns (bytes32); - - // Gets the map key and parent of a mapping at a given slot, for a given address. - function getMappingKeyAndParentOf(address target, bytes32 slot) external returns (bool, bytes32, bytes32); - - // Returns true if the given path points to an existing entity, else returns false - function exists(string calldata path) external returns (bool); - - // Returns true if the path exists on disk and is pointing at a regular file, else returns false - function isFile(string calldata path) external returns (bool); - - // Returns true if the path exists on disk and is pointing at a directory, else returns false - function isDir(string calldata path) external returns (bool); + function stopPrank() external; + function store(address target, bytes32 slot, bytes32 value) external; + function toString(address value) external pure returns (string memory stringifiedValue); + function toString(bytes calldata value) external pure returns (string memory stringifiedValue); + function toString(bytes32 value) external pure returns (string memory stringifiedValue); + function toString(bool value) external pure returns (string memory stringifiedValue); + function toString(uint256 value) external pure returns (string memory stringifiedValue); + function toString(int256 value) external pure returns (string memory stringifiedValue); + function transact(bytes32 txHash) external; + function transact(uint256 forkId, bytes32 txHash) external; + function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result); + function txGasPrice(uint256 newGasPrice) external; + function unixTime() external returns (uint256 milliseconds); + function warp(uint256 newTimestamp) external; + function writeFile(string calldata path, string calldata data) external; + function writeFileBinary(string calldata path, bytes calldata data) external; + function writeJson(string calldata json, string calldata path) external; + function writeJson(string calldata json, string calldata path, string calldata valueKey) external; + function writeLine(string calldata path, string calldata data) external; } diff --git a/testdata/foundry.toml b/testdata/foundry.toml index 5bab89def6622..d696945d0640f 100644 --- a/testdata/foundry.toml +++ b/testdata/foundry.toml @@ -50,3 +50,6 @@ endpoints = "all" [fuzz] runs = 256 max_test_rejects = 65536 + +[fmt] +ignore = ["cheats/Vm.sol"] diff --git a/testdata/fs/Default.t.sol b/testdata/fs/Default.t.sol index a745608218da1..6d83914447987 100644 --- a/testdata/fs/Default.t.sol +++ b/testdata/fs/Default.t.sol @@ -4,60 +4,11 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "../cheats/Vm.sol"; -contract FsProxy is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - function readFile(string calldata path) external returns (string memory) { - return vm.readFile(path); - } - - function readDir(string calldata path) external returns (Vm.DirEntry[] memory) { - return vm.readDir(path); - } - - function readFileBinary(string calldata path) external returns (bytes memory) { - return vm.readFileBinary(path); - } - - function readLine(string calldata path) external returns (string memory) { - return vm.readLine(path); - } - - function writeLine(string calldata path, string calldata data) external { - return vm.writeLine(path, data); - } - - function writeFile(string calldata path, string calldata data) external { - return vm.writeLine(path, data); - } - - function writeFileBinary(string calldata path, bytes calldata data) external { - return vm.writeFileBinary(path, data); - } - - function removeFile(string calldata path) external { - return vm.removeFile(path); - } - - function fsMetadata(string calldata path) external returns (Vm.FsMetadata memory) { - return vm.fsMetadata(path); - } - - function createDir(string calldata path) external { - return vm.createDir(path, false); - } - - function createDir(string calldata path, bool recursive) external { - return vm.createDir(path, recursive); - } -} - contract DefaultAccessTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - FsProxy public fsProxy; bytes constant FOUNDRY_WRITE_ERR = - "The path \"fixtures/File/write_file.txt\" is not allowed to be accessed for write operations."; + "the path fixtures/File/write_file.txt is not allowed to be accessed for write operations"; function testReadFile() public { string memory path = "fixtures/File/read.txt"; @@ -72,34 +23,28 @@ contract DefaultAccessTest is DSTest { } function testWriteFile() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeFile(path, data); + vm.writeFile(path, data); vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeFileBinary(path, bytes(data)); + vm.writeFileBinary(path, bytes(data)); } function testWriteLine() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeLine(path, data); + vm.writeLine(path, data); } function testRemoveFile() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/write_file.txt"; vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.removeFile(path); + vm.removeFile(path); } } diff --git a/testdata/fs/Disabled.t.sol b/testdata/fs/Disabled.t.sol index 6af6d83c8f174..e5ffbbe82190a 100644 --- a/testdata/fs/Disabled.t.sol +++ b/testdata/fs/Disabled.t.sol @@ -4,98 +4,43 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "../cheats/Vm.sol"; -contract FsProxy is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - function readFile(string calldata path) external returns (string memory) { - return vm.readFile(path); - } - - function readDir(string calldata path) external returns (Vm.DirEntry[] memory) { - return vm.readDir(path); - } - - function readFileBinary(string calldata path) external returns (bytes memory) { - return vm.readFileBinary(path); - } - - function readLine(string calldata path) external returns (string memory) { - return vm.readLine(path); - } - - function writeLine(string calldata path, string calldata data) external { - return vm.writeLine(path, data); - } - - function writeFile(string calldata path, string calldata data) external { - return vm.writeLine(path, data); - } - - function writeFileBinary(string calldata path, bytes calldata data) external { - return vm.writeFileBinary(path, data); - } - - function removeFile(string calldata path) external { - return vm.removeFile(path); - } - - function fsMetadata(string calldata path) external returns (Vm.FsMetadata memory) { - return vm.fsMetadata(path); - } - - function createDir(string calldata path) external { - return vm.createDir(path, false); - } - - function createDir(string calldata path, bool recursive) external { - return vm.createDir(path, recursive); - } -} - contract DisabledTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - FsProxy public fsProxy; bytes constant FOUNDRY_READ_ERR = - "The path \"fixtures/File/read.txt\" is not allowed to be accessed for read operations."; + "the path fixtures/File/read.txt is not allowed to be accessed for read operations"; bytes constant FOUNDRY_WRITE_ERR = - "The path \"fixtures/File/write_file.txt\" is not allowed to be accessed for write operations."; + "the path fixtures/File/write_file.txt is not allowed to be accessed for write operations"; function testReadFile() public { - fsProxy = new FsProxy(); - string memory path = "fixtures/File/read.txt"; vm.expectRevert(FOUNDRY_READ_ERR); - fsProxy.readFile(path); + vm.readFile(path); } function testReadLine() public { - fsProxy = new FsProxy(); string memory path = "fixtures/File/read.txt"; vm.expectRevert(FOUNDRY_READ_ERR); - fsProxy.readLine(path); + vm.readLine(path); } function testWriteFile() public { - fsProxy = new FsProxy(); string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeFile(path, data); + vm.writeFile(path, data); } function testWriteLine() public { - fsProxy = new FsProxy(); string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.writeLine(path, data); + vm.writeLine(path, data); } function testRemoveFile() public { - fsProxy = new FsProxy(); string memory path = "fixtures/File/write_file.txt"; vm.expectRevert(FOUNDRY_WRITE_ERR); - fsProxy.removeFile(path); + vm.removeFile(path); } } diff --git a/testdata/repros/Issue5808.t.sol b/testdata/repros/Issue5808.t.sol index b721dfa105c02..b3b455b48c295 100644 --- a/testdata/repros/Issue5808.t.sol +++ b/testdata/repros/Issue5808.t.sol @@ -9,13 +9,14 @@ contract Issue5808Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testReadInt() public { - string memory str1 = '["ffffffff","00000010"]'; - vm.expectRevert(); - int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); + // TODO: blocked on https://github.com/alloy-rs/core/issues/387 + // string memory str1 = '["ffffffff","00000010"]'; + // vm.expectRevert(); + // int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); string memory str2 = '["0xffffffff","0x00000010"]'; int256[] memory ints2 = vm.parseJsonIntArray(str2, ""); - assertEq(ints2[0], 4294967295); - assertEq(ints2[1], 10); + assertEq(ints2[0], 0xffffffff); + assertEq(ints2[1], 16); } } From 60ec00296f00754bc21ed68fd05ab6b54b50e024 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:03:09 +0100 Subject: [PATCH 0215/1963] fix(cheatcodes): allow `deal` on precompiles (#6182) --- crates/cheatcodes/src/impls/evm.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/cheatcodes/src/impls/evm.rs b/crates/cheatcodes/src/impls/evm.rs index 3956fb52c88d0..1626ac2b38e2d 100644 --- a/crates/cheatcodes/src/impls/evm.rs +++ b/crates/cheatcodes/src/impls/evm.rs @@ -206,7 +206,6 @@ impl Cheatcode for warpCall { impl Cheatcode for dealCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account: address, newBalance: new_balance } = *self; - ensure_not_precompile!(&address, ccx); let account = journaled_account(ccx.data, address)?; let old_balance = std::mem::replace(&mut account.info.balance, new_balance); let record = DealRecord { address, old_balance, new_balance }; From 871aba58e31fcbce6f6575631297fd1d2274d35a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 1 Nov 2023 19:33:53 +0100 Subject: [PATCH 0216/1963] test: add repro test for skip (#6189) --- crates/forge/tests/it/repros.rs | 6 ++++++ testdata/cheats/Vm.sol | 2 +- testdata/repros/Issue6180.sol | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 testdata/repros/Issue6180.sol diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 6054d99991914..148a15a0a9f61 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -319,3 +319,9 @@ async fn test_issue_6170() { assert_eq!(test.status, TestStatus::Failure); assert_eq!(test.reason, Some("log != expected log".to_string())); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_issue_6180() { + test_repro!("Issue6180"); +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 23e319aec3db6..8ab2a14f5e84f 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -223,4 +223,4 @@ interface Vm { function writeJson(string calldata json, string calldata path) external; function writeJson(string calldata json, string calldata path, string calldata valueKey) external; function writeLine(string calldata path, string calldata data) external; -} +} \ No newline at end of file diff --git a/testdata/repros/Issue6180.sol b/testdata/repros/Issue6180.sol new file mode 100644 index 0000000000000..dea24c65db29b --- /dev/null +++ b/testdata/repros/Issue6180.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6180 +contract Issue6180Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_timebug() external { + uint256 start = block.timestamp; + uint256 count = 4; + uint256 duration = 15; + for (uint256 i; i < count; i++) { + vm.warp(block.timestamp + duration); + } + + uint256 end = block.timestamp; + assertEq(end, start + count * duration); + assertEq(end - start, count * duration); + } +} From c602db6c72a255cede7fd531071912745c8365e9 Mon Sep 17 00:00:00 2001 From: ts <100044502+schroyar@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:46:48 -0300 Subject: [PATCH 0217/1963] feat(forge): add `selectors list` subcommand (#6075) * add list (ls) cli arg for forge selectors * add type identifier for signature * fix CI * migrate to alloy --------- Co-authored-by: Matthias Seitz --- crates/forge/bin/cmd/selectors.rs | 100 ++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index e23514ae74747..8689f9fdcb9c9 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -51,6 +51,17 @@ pub enum SelectorsSubcommands { #[clap(flatten)] project_paths: ProjectPathsArgs, }, + + /// List selectors from current workspace + #[clap(visible_alias = "ls")] + List { + /// The name of the contract to list selectors for. + #[clap(help = "The name of the contract to list selectors for.")] + contract: Option, + + #[clap(flatten)] + project_paths: ProjectPathsArgs, + }, } impl SelectorsSubcommands { @@ -176,6 +187,95 @@ impl SelectorsSubcommands { println!("{table}"); } } + SelectorsSubcommands::List { contract, project_paths } => { + println!("Listing selectors for contracts in the project..."); + let build_args = CoreBuildArgs { + project_paths: project_paths.clone(), + compiler: CompilerArgs { + extra_output: vec![ContractOutputSelection::Abi], + ..Default::default() + }, + ..Default::default() + }; + + // compile the project to get the artifacts/abis + let project = build_args.project()?; + let outcome = compile::suppress_compile(&project)?; + let artifacts = if let Some(contract) = contract { + let found_artifact = outcome.find_first(&contract); + let artifact = found_artifact + .ok_or_else(|| { + let candidates = outcome + .artifacts() + .map(|(name, _,)| name) + .collect::>(); + let suggestion = if let Some(suggestion) = foundry_cli::utils::did_you_mean(&contract, candidates).pop() { + format!("\nDid you mean `{suggestion}`?") + } else { + "".to_string() + }; + eyre::eyre!( + "Could not find artifact `{contract}` in the compiled artifacts{suggestion}", + ) + })? + .clone(); + vec![(contract, artifact)] + } else { + outcome + .into_artifacts_with_files() + .filter(|(file, _, _)| { + let is_sources_path = file + .starts_with(&project.paths.sources.to_string_lossy().to_string()); + let is_test = file.is_sol_test(); + + is_sources_path && !is_test + }) + .map(|(_, contract, artifact)| (contract, artifact)) + .collect() + }; + + let mut artifacts = artifacts.into_iter().peekable(); + + while let Some((contract, artifact)) = artifacts.next() { + let abi = artifact.abi.ok_or(eyre::eyre!("Unable to fetch abi"))?; + if abi.abi.functions.is_empty() && + abi.abi.events.is_empty() && + abi.abi.errors.is_empty() + { + continue + } + + println!("{contract}"); + + let mut table = Table::new(); + + table.set_header(vec!["Type", "Signature", "Selector"]); + + for func in abi.abi.functions() { + let sig = func.signature(); + let selector = func.selector(); + table.add_row(vec!["Function", &sig, &hex::encode_prefixed(selector)]); + } + + for event in abi.abi.events() { + let sig = event.signature(); + let selector = event.selector(); + table.add_row(vec!["Event", &sig, &hex::encode_prefixed(selector)]); + } + + for error in abi.abi.errors() { + let sig = error.signature(); + let selector = error.selector(); + table.add_row(vec!["Error", &sig, &hex::encode_prefixed(selector)]); + } + + println!("{table}"); + + if artifacts.peek().is_some() { + println!() + } + } + } } Ok(()) } From c931b70d6dc9114fb3adcca6feb9b6e27c24c474 Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Wed, 1 Nov 2023 12:33:47 -0700 Subject: [PATCH 0218/1963] fix(forge): make recursive `forge update` optional via `--recursive` flag (#5980) * don't default to recursive submodule updates * update and remove ignore from recursive submodule update test * chore: update test to use new repo location --------- Co-authored-by: James Wenzel Co-authored-by: Enrique Ortiz --- crates/cli/src/utils/mod.rs | 14 +++++++++- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/install.rs | 7 ++--- crates/forge/bin/cmd/update.rs | 17 +++++++++++- crates/forge/tests/cli/cmd.rs | 47 ++++++++++++++++++++++++--------- 5 files changed, 69 insertions(+), 18 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 38467d5392011..2d77a1edf0e10 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -546,6 +546,7 @@ https://github.com/foundry-rs/foundry/issues/new/choose" force: bool, remote: bool, no_fetch: bool, + recursive: bool, paths: I, ) -> Result<()> where @@ -554,16 +555,27 @@ https://github.com/foundry-rs/foundry/issues/new/choose" { self.cmd() .stderr(self.stderr()) - .args(["submodule", "update", "--progress", "--init", "--recursive"]) + .args(["submodule", "update", "--progress", "--init"]) .args(self.shallow.then_some("--depth=1")) .args(force.then_some("--force")) .args(remote.then_some("--remote")) .args(no_fetch.then_some("--no-fetch")) + .args(recursive.then_some("--recursive")) .args(paths) .exec() .map(drop) } + pub fn submodule_foreach(self, recursive: bool, cmd: impl AsRef) -> Result<()> { + self.cmd() + .stderr(self.stderr()) + .args(["submodule", "foreach"]) + .args(recursive.then_some("--recursive")) + .arg(cmd) + .exec() + .map(drop) + } + pub fn submodule_init(self) -> Result<()> { self.cmd().stderr(self.stderr()).args(["submodule", "init"]).exec().map(drop) } diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 150a1fab713d0..d165037c9b5f8 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -84,7 +84,7 @@ impl InitArgs { git.submodule_init()?; } else { // if not shallow, initialize and clone submodules (without fetching latest) - git.submodule_update(false, false, true, None::)?; + git.submodule_update(false, false, true, true, None::)?; } } else { // if target is not empty diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index d5568b8234641..81f1177f9fd2b 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -126,7 +126,8 @@ impl DependencyInstallOpts { if dependencies.is_empty() && !self.no_git { p_println!(!self.quiet => "Updating dependencies in {}", libs.display()); - git.submodule_update(false, false, false, Some(&libs))?; + // recursively fetch all submodules (without fetching latest) + git.submodule_update(false, false, false, true, Some(&libs))?; } fs::create_dir_all(&libs)?; @@ -303,8 +304,8 @@ impl Installer<'_> { trace!(?dep, url, ?path, "installing git submodule"); self.git.submodule_add(true, url, path)?; - trace!("updating submodule recursively"); - self.git.submodule_update(false, false, false, Some(path)) + trace!("initializing submodule recursively"); + self.git.submodule_update(false, false, false, true, Some(path)) } fn git_checkout(self, dep: &Dependency, path: &Path, recurse: bool) -> Result { diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index 083c889246f97..28b6429967473 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -23,6 +23,10 @@ pub struct UpdateArgs { /// Override the up-to-date check. #[clap(short, long)] force: bool, + + /// Recursively update submodules. + #[clap(short, long)] + recursive: bool, } impl_figment_convert_basic!(UpdateArgs); @@ -30,7 +34,18 @@ impl UpdateArgs { pub fn run(self) -> Result<()> { let config = self.try_load_config_emit_warnings()?; let (root, paths) = dependencies_paths(&self.dependencies, &config)?; - Git::new(&root).submodule_update(self.force, true, false, paths) + // fetch the latest changes for each submodule (recursively if flag is set) + let git = Git::new(&root); + if self.recursive { + // update submodules recursively + git.submodule_update(self.force, true, false, true, paths) + } else { + // update root submodules + git.submodule_update(self.force, true, false, false, paths)?; + // initialize submodules of each submodule recursively (otherwise direct submodule + // dependencies will revert to last commit) + git.submodule_foreach(false, "git submodule update --init --progress --recursive ") + } } } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index cad8dbb868d4e..e0f52434424a8 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1009,7 +1009,6 @@ forgetest!(can_install_latest_release_tag, |prj: TestProject, mut cmd: TestComma // Tests that forge update doesn't break a working dependency by recursively updating nested // dependencies forgetest!( - #[ignore] can_update_library_with_outdated_nested_dependency, |prj: TestProject, mut cmd: TestCommand| { cmd.git_init(); @@ -1018,39 +1017,63 @@ forgetest!( let git_mod = prj.root().join(".git/modules/lib"); let git_mod_file = prj.root().join(".gitmodules"); - let package = libs.join("issue-2264-repro"); - let package_mod = git_mod.join("issue-2264-repro"); + // get paths to check inside install fn + let package = libs.join("forge-5980-test"); + let package_mod = git_mod.join("forge-5980-test"); let install = |cmd: &mut TestCommand| { - cmd.forge_fuse().args(["install", "foundry-rs/issue-2264-repro", "--no-commit"]); + // install main dependency + cmd.forge_fuse().args(["install", "evalir/forge-5980-test", "--no-commit"]); cmd.assert_non_empty_stdout(); + + // assert pathbufs exist assert!(package.exists()); assert!(package_mod.exists()); let submods = read_string(&git_mod_file); - assert!(submods.contains("https://github.com/foundry-rs/issue-2264-repro")); + assert!(submods.contains("https://github.com/evalir/forge-5980-test")); }; install(&mut cmd); - cmd.forge_fuse().args(["update", "lib/issue-2264-repro"]); + // try to update the top-level dependency; there should be no update for this dependency, + // but its sub-dependency has upstream (breaking) changes; forge should not attempt to + // update the sub-dependency + cmd.forge_fuse().args(["update", "lib/forge-5980-test"]); cmd.stdout_lossy(); + // add explicit remappings for test file + let config = Config { + remappings: vec![ + Remapping::from_str("forge-5980-test/=lib/forge-5980-test/src/").unwrap().into(), + // explicit remapping for sub-dependendy seems necessary for some reason + Remapping::from_str( + "forge-5980-test-dep/=lib/forge-5980-test/lib/forge-5980-test-dep/src/", + ) + .unwrap() + .into(), + ], + ..Default::default() + }; + prj.write_config(config); + + // create test file that uses the top-level dependency; if the sub-dependency is updated, + // compilation will fail prj.inner() .add_source( - "MyTokenCopy", + "CounterCopy", r#" // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.6.0; -import "issue-2264-repro/MyToken.sol"; -contract MyTokenCopy is MyToken { +pragma solidity ^0.8.0; +import "forge-5980-test/Counter.sol"; +contract CounterCopy is Counter { } "#, ) .unwrap(); - cmd.forge_fuse().args(["build"]); + // build and check output + cmd.forge_fuse().arg("build"); let output = cmd.stdout_lossy(); - assert!(output.contains("Compiler run successful",)); } ); From 34f684ddfacc5b2ed371353ba6f730c485616ffe Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:43:42 +0100 Subject: [PATCH 0219/1963] chore(deps): bumps (#6191) * chore(deps): bumps * chore: bump ethers too --- Cargo.lock | 109 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 20 +++++----- 2 files changed, 65 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f77e47bfa8ea..7890808ea5f83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" +source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" +source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" +source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,12 +156,12 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" +source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" dependencies = [ "const-hex", "dunce", "heck", - "indexmap 2.0.2", + "indexmap 2.1.0", "proc-macro-error", "proc-macro2", "quote", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" +source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" +source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -1430,9 +1430,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "4939f9ed1444bd8c896d37f3090012fa6e7834fe84ef8c9daa166109515732f9" [[package]] name = "crc32fast" @@ -2032,7 +2032,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2047,7 +2047,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "ethers-core", "once_cell", @@ -2058,7 +2058,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "Inflector", "const-hex", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "Inflector", "const-hex", @@ -2114,7 +2114,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "arrayvec", "bytes", @@ -2143,7 +2143,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "chrono", "ethers-core", @@ -2159,7 +2159,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "async-trait", "auto_impl", @@ -2185,7 +2185,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "async-trait", "auto_impl", @@ -2223,7 +2223,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "async-trait", "coins-bip32", @@ -2251,7 +2251,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=efdc8d43318b818178c93a19a42b2b7e49e678eb#efdc8d43318b818178c93a19a42b2b7e49e678eb" +source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" dependencies = [ "cfg-if", "const-hex", @@ -3897,9 +3897,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.2", @@ -4020,9 +4020,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -4733,9 +4733,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "a9dfc0783362704e97ef3bd24261995a699468440099ef95d869b4d9732f829a" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -4765,9 +4765,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.93" +version = "0.9.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +checksum = "2f55da20b29f956fb01f0add8683eb26ee13ebe3ebd935e49898717c6b4b2830" dependencies = [ "cc", "libc", @@ -5031,7 +5031,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.2", + "indexmap 2.1.0", ] [[package]] @@ -5851,9 +5851,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" +checksum = "724fd11728a3804e9944b14cab63825024c40bf42f8af87c8b5d97c4bbacf426" dependencies = [ "alloy-rlp", "arbitrary", @@ -5862,6 +5862,7 @@ dependencies = [ "bytes", "fastrlp", "num-bigint", + "num-traits", "parity-scale-codec", "primitive-types", "proptest", @@ -6363,7 +6364,7 @@ version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "itoa", "ryu", "serde", @@ -6806,7 +6807,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#8c0db49e5f7791322a45a5a907a407801e88a977" +source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" dependencies = [ "paste", "proc-macro2", @@ -7160,7 +7161,7 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -7182,7 +7183,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "toml_datetime", "winnow", ] @@ -7193,7 +7194,7 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -7687,9 +7688,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -7697,9 +7698,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", @@ -7712,9 +7713,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -7724,9 +7725,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7734,9 +7735,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", @@ -7747,9 +7748,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "watchexec" @@ -7801,9 +7802,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -8085,18 +8086,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.20" +version = "0.7.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" +checksum = "686b7e407015242119c33dab17b8f61ba6843534de936d94368856528eae4dcc" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.20" +version = "0.7.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" +checksum = "020f3dfe25dfc38dfea49ce62d5d45ecdd7f0d8a724fa63eb36b6eba4ec76806" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index d45ba882b670f..ed8c856cea4de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,16 +184,16 @@ color-eyre = "0.6" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "efdc8d43318b818178c93a19a42b2b7e49e678eb" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } foundry-compilers = { git = "https://github.com/foundry-rs/compilers" } foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } From 09fe3e041369a816365a020f715ad6f94dbce9f2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:33:25 +0100 Subject: [PATCH 0220/1963] chore(deps): bumps 2 (#6194) --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7890808ea5f83..1a59256ab49a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" +source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" +source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" +source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" +source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" dependencies = [ "const-hex", "dunce", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" +source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" +source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -6807,7 +6807,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#caa4be1d252e7287020f5f2c119e5d31b9d5e069" +source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" dependencies = [ "paste", "proc-macro2", From 3546f16338abf96405827fcccdd1d30f00ec9a06 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 2 Nov 2023 03:17:45 +0100 Subject: [PATCH 0221/1963] chore: dedup abi values formatting, cleanups (#6196) * chore: dedup abi values formatting * chore: clippy * chore: cast selector cleanup * fix: do not emit struct literal in raw mode * stuff * fmt doc comments * fix: don't format strings with Debug * fix: doctests --- Cargo.lock | 2 - crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/lib.rs | 20 +- crates/anvil/src/tasks/mod.rs | 7 +- crates/anvil/tests/it/ipc.rs | 4 +- crates/anvil/tests/it/logs.rs | 2 +- crates/anvil/tests/it/otterscan.rs | 8 +- crates/anvil/tests/it/pubsub.rs | 10 +- crates/anvil/tests/it/revert.rs | 10 +- crates/anvil/tests/it/traces.rs | 4 +- crates/anvil/tests/it/transaction.rs | 12 +- crates/anvil/tests/it/wsapi.rs | 4 +- crates/binder/src/lib.rs | 37 +- crates/cast/bin/main.rs | 37 +- crates/cast/bin/opts.rs | 2 +- crates/cast/src/base.rs | 10 +- crates/cast/src/lib.rs | 615 +++++++++---------- crates/cast/src/tx.rs | 23 +- crates/cheatcodes/src/impls/evm/fork.rs | 4 +- crates/common/src/abi.rs | 169 +---- crates/common/src/calc.rs | 12 +- crates/common/src/compile.rs | 3 +- crates/common/src/fmt.rs | 195 +++++- crates/common/src/provider.rs | 115 ++-- crates/common/src/selectors.rs | 20 +- crates/common/src/units.rs | 2 +- crates/config/src/inline/conf_parser.rs | 32 +- crates/config/src/lib.rs | 51 +- crates/config/src/macros.rs | 13 +- crates/evm/core/src/decode.rs | 4 +- crates/evm/fuzz/src/lib.rs | 2 +- crates/evm/traces/src/utils.rs | 2 +- crates/forge/bin/cmd/create.rs | 2 +- crates/forge/bin/cmd/script/mod.rs | 3 +- crates/forge/bin/cmd/script/transaction.rs | 2 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 2 +- crates/macros/Cargo.toml | 3 - crates/macros/src/fmt/mod.rs | 3 - crates/macros/src/fmt/token.rs | 54 -- crates/macros/src/lib.rs | 2 +- rustfmt.toml | 2 + 41 files changed, 738 insertions(+), 768 deletions(-) delete mode 100644 crates/macros/src/fmt/token.rs diff --git a/Cargo.lock b/Cargo.lock index 1a59256ab49a0..2c2721a4d82e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2935,8 +2935,6 @@ dependencies = [ name = "foundry-macros" version = "0.2.0" dependencies = [ - "alloy-dyn-abi", - "alloy-primitives", "ethers-core", "foundry-macros-impl", "serde", diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 8ecbc4cb44a5f..5fddfe445abbe 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -56,7 +56,7 @@ use ethers::{ utils::{hex, keccak256, rlp}, }; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; -use foundry_common::abi::format_token; +use foundry_common::fmt::format_token; use foundry_evm::{ backend::{DatabaseError, DatabaseResult}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index b816d53d9a358..45f5c6c2dda65 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -266,24 +266,22 @@ impl NodeHandle { self.config.get_ipc_path() } - /// Returns a Provider for the http endpoint + /// Constructs a [`RetryProvider`] for this handle's HTTP endpoint. pub fn http_provider(&self) -> RetryProvider { - ProviderBuilder::new(self.http_endpoint()) + ProviderBuilder::new(&self.http_endpoint()) .build() - .expect("Failed to connect using http provider") + .expect("failed to build HTTP provider") .interval(Duration::from_millis(500)) } - /// Connects to the websocket Provider of the node - pub async fn ws_provider(&self) -> RetryProvider { - ProviderBuilder::new(self.ws_endpoint()) - .build() - .expect("Failed to connect to node's websocket") + /// Constructs a [`RetryProvider`] for this handle's WS endpoint. + pub fn ws_provider(&self) -> RetryProvider { + ProviderBuilder::new(&self.ws_endpoint()).build().expect("failed to build WS provider") } - /// Connects to the ipc endpoint of the node, if spawned - pub async fn ipc_provider(&self) -> Option { - ProviderBuilder::new(self.config.get_ipc_path()?).build().ok() + /// Constructs a [`RetryProvider`] for this handle's IPC endpoint, if any. + pub fn ipc_provider(&self) -> Option { + ProviderBuilder::new(&self.config.get_ipc_path()?).build().ok() } /// Signer accounts that can sign messages/transactions from the EVM node diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index 5ecbbaeaadfa5..429f8d5d32919 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -51,9 +51,9 @@ impl TaskManager { /// block /// /// ``` - /// use std::sync::Arc; + /// use anvil::{spawn, NodeConfig}; /// use ethers::providers::Provider; - /// use anvil::{NodeConfig, spawn}; + /// use std::sync::Arc; /// # async fn t() { /// let endpoint = "http://...."; /// let (api, handle) = spawn(NodeConfig::default().with_eth_rpc_url(Some(endpoint))).await; @@ -61,7 +61,6 @@ impl TaskManager { /// let provider = Arc::new(Provider::try_from(endpoint).unwrap()); /// /// handle.task_manager().spawn_reset_on_new_polled_blocks(provider, api); - /// /// # } /// ``` pub fn spawn_reset_on_new_polled_blocks

(&self, provider: P, api: EthApi) @@ -106,8 +105,8 @@ impl TaskManager { /// block /// /// ``` + /// use anvil::{spawn, NodeConfig}; /// use ethers::providers::Provider; - /// use anvil::{NodeConfig, spawn}; /// # async fn t() { /// let (api, handle) = spawn(NodeConfig::default().with_eth_rpc_url(Some("http://...."))).await; /// diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index f5bb19e1de923..b25bbba5249fd 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -24,7 +24,7 @@ async fn can_get_block_number_ipc() { let block_num = api.block_number().unwrap(); assert_eq!(block_num, U256::zero()); - let provider = handle.ipc_provider().await.unwrap(); + let provider = handle.ipc_provider().unwrap(); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, block_num.as_u64().into()); @@ -34,7 +34,7 @@ async fn can_get_block_number_ipc() { async fn test_sub_new_heads_ipc() { let (api, handle) = spawn(ipc_config()).await; - let provider = handle.ipc_provider().await.unwrap(); + let provider = handle.ipc_provider().unwrap(); let blocks = provider.subscribe_blocks().await.unwrap(); diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index f0b0877599f76..913015de5edf0 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -143,7 +143,7 @@ async fn watch_events() { let mut stream = event.stream().await.unwrap(); // Also set up a subscription for the same thing - let ws = Arc::new(handle.ws_provider().await); + let ws = Arc::new(handle.ws_provider()); let contract2 = SimpleStorage::new(contract.address(), ws); let event2 = contract2.event::(); let mut subscription = event2.subscribe().await.unwrap(); diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 32271f5ec07b5..c6643dc2bd1dd 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -122,7 +122,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -180,7 +180,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -284,7 +284,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -373,7 +373,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index 49b814113df8e..22df53c968259 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -16,7 +16,7 @@ use std::sync::Arc; async fn test_sub_new_heads() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let blocks = provider.subscribe_blocks().await.unwrap(); @@ -34,7 +34,7 @@ async fn test_sub_logs_legacy() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -73,7 +73,7 @@ async fn test_sub_logs() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -111,7 +111,7 @@ async fn test_sub_logs_impersonated() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); // impersonate account let impersonate = Address::random(); @@ -253,7 +253,7 @@ async fn test_subscriptions() { async fn test_sub_new_heads_fast() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let blocks = provider.subscribe_blocks().await.unwrap(); diff --git a/crates/anvil/tests/it/revert.rs b/crates/anvil/tests/it/revert.rs index c58302c1f153a..45da5eb2ef63e 100644 --- a/crates/anvil/tests/it/revert.rs +++ b/crates/anvil/tests/it/revert.rs @@ -31,7 +31,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -75,7 +75,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -107,7 +107,7 @@ async fn test_solc_revert_example() { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -161,7 +161,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -208,7 +208,7 @@ contract Contract { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index d8c08f15e2fae..ee795583b73bf 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -72,7 +72,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -119,7 +119,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index b52a058da081f..7cb5c4bc6e5a8 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -357,7 +357,7 @@ async fn can_call_greeter_historic() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_ws() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -382,7 +382,7 @@ async fn can_deploy_greeter_ws() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_get_code() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -496,7 +496,7 @@ async fn call_past_state() { async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -526,7 +526,7 @@ async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); @@ -560,7 +560,7 @@ async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); @@ -778,7 +778,7 @@ async fn can_stream_pending_transactions() { spawn(NodeConfig::test().with_blocktime(Some(Duration::from_secs(2)))).await; let num_txs = 5; let provider = handle.http_provider(); - let ws_provider = handle.ws_provider().await; + let ws_provider = handle.ws_provider(); let accounts = provider.get_accounts().await.unwrap(); let tx = TransactionRequest::new().from(accounts[0]).to(accounts[0]).value(1e18 as u64); diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index 9bcc0d810c39d..f185c6b8ee241 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -9,7 +9,7 @@ async fn can_get_block_number_ws() { let block_num = api.block_number().unwrap(); assert_eq!(block_num, U256::zero()); - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, block_num.as_u64().into()); @@ -18,7 +18,7 @@ async fn can_get_block_number_ws() { #[tokio::test(flavor = "multi_thread")] async fn can_dev_get_balance_ws() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider().await; + let provider = handle.ws_provider(); let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { diff --git a/crates/binder/src/lib.rs b/crates/binder/src/lib.rs index 8bc3e49067d4d..8db7b892167eb 100644 --- a/crates/binder/src/lib.rs +++ b/crates/binder/src/lib.rs @@ -40,23 +40,21 @@ impl Binder { /// /// # Example /// - /// ## Local repository + /// Local repository: /// /// ``` - /// # use foundry_binder::Binder; - /// # fn new() { - /// let binder = Binder::new("./aave-v3-core"); - /// # } + /// use foundry_binder::Binder; + /// + /// let binder = Binder::new("./aave-v3-core"); /// ``` /// - /// ## Remote repository with default branch + /// Remote repository with default branch: /// /// ``` - /// # use url::Url; /// use foundry_binder::Binder; - /// # fn new() { - /// let binder = Binder::new(Url::parse("https://github.com/aave/aave-v3-core").unwrap()); - /// # } + /// use url::Url; + /// + /// let binder = Binder::new(Url::parse("https://github.com/aave/aave-v3-core").unwrap()); /// ``` pub fn new(location: impl Into) -> Self { Self { @@ -76,14 +74,14 @@ impl Binder { /// Add a `yarn install` command /// /// ``` - /// # use url::Url; /// use foundry_binder::{Binder, RepositoryBuilder}; - /// # fn new() { + /// use url::Url; + /// /// let binder = Binder::new( /// RepositoryBuilder::new(Url::parse("https://github.com/aave/aave-v3-core").unwrap()) /// .tag("v1.16.0"), - /// ).command(["yarn", "install"]); - /// # } + /// ) + /// .command(["yarn", "install"]); /// ``` #[must_use] pub fn command(mut self, cmd: I) -> Self @@ -122,20 +120,15 @@ impl Binder { /// ## Example /// /// ``` - /// # use url::Url; /// use foundry_binder::{Binder, Config, RepositoryBuilder}; - /// # fn new() { + /// use url::Url; + /// /// let binder = Binder::new( /// RepositoryBuilder::new(Url::parse("https://github.com/aave/aave-v3-core").unwrap()) /// .tag("v1.16.0"), /// ) /// .command(["yarn", "install"]) - /// .config(Config { - /// src: "src".into(), - /// out: "artifacts".into(), - /// ..Default::default() - /// }); - /// # } + /// .config(Config { src: "src".into(), out: "artifacts".into(), ..Default::default() }); /// ``` #[must_use] pub fn config(mut self, config: Config) -> Self { diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index fad3ec49da757..60e64c214d349 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -6,10 +6,11 @@ use ethers::{ core::types::{BlockId, BlockNumber::Latest}, providers::Middleware, }; -use eyre::{Result, WrapErr}; +use eyre::Result; use foundry_cli::{handler, prompt, stdin, utils}; use foundry_common::{ - abi::{format_tokens, get_event}, + abi::get_event, + fmt::format_tokens, fs, selectors::{ decode_calldata, decode_event_topic, decode_function_selector, import_selectors, @@ -123,15 +124,15 @@ async fn main() -> Result<()> { } Subcommands::ToHex(ToBaseArgs { value, base_in }) => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_base(&value, base_in, "hex")?); + println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "hex")?); } Subcommands::ToDec(ToBaseArgs { value, base_in }) => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_base(&value, base_in, "dec")?); + println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "dec")?); } Subcommands::ToBase { base: ToBaseArgs { value, base_in }, base_out } => { let (value, base_out) = stdin::unwrap2(value, base_out)?; - println!("{}", SimpleCast::to_base(&value, base_in, &base_out)?); + println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), &base_out)?); } Subcommands::ToBytes32 { bytes } => { let value = stdin::unwrap_line(bytes)?; @@ -174,17 +175,17 @@ async fn main() -> Result<()> { println!("{}", pretty_calldata(&calldata, offline).await?); } Subcommands::Sig { sig, optimize } => { - let sig = stdin::unwrap_line(sig).wrap_err("Failed to read signature")?; - if optimize.is_none() { - println!("{}", SimpleCast::get_selector(&sig, None)?.0); - } else { - println!("Starting to optimize signature..."); - let start_time = Instant::now(); - let (selector, signature) = SimpleCast::get_selector(&sig, optimize)?; - let elapsed_time = start_time.elapsed(); - println!("Successfully generated in {} seconds", elapsed_time.as_secs()); - println!("Selector: {}", selector); - println!("Optimized signature: {}", signature); + let sig = stdin::unwrap_line(sig)?; + match optimize { + Some(opt) => { + println!("Starting to optimize signature..."); + let start_time = Instant::now(); + let (selector, signature) = SimpleCast::get_selector(&sig, opt)?; + println!("Successfully generated in {:?}", start_time.elapsed()); + println!("Selector: {selector}"); + println!("Optimized signature: {signature}"); + } + None => println!("{}", SimpleCast::get_selector(&sig, 0)?.0), } } @@ -453,10 +454,10 @@ async fn main() -> Result<()> { println!("{:?}", parsed_event.signature()); } Subcommands::LeftShift { value, bits, base_in, base_out } => { - println!("{}", SimpleCast::left_shift(&value, &bits, base_in, &base_out)?); + println!("{}", SimpleCast::left_shift(&value, &bits, base_in.as_deref(), &base_out)?); } Subcommands::RightShift { value, bits, base_in, base_out } => { - println!("{}", SimpleCast::right_shift(&value, &bits, base_in, &base_out)?); + println!("{}", SimpleCast::right_shift(&value, &bits, base_in.as_deref(), &base_out)?); } Subcommands::EtherscanSource { address, directory, etherscan } => { let config = Config::from(ðerscan); diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 39ac4364045c1..d5f0315ef8ed3 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -921,7 +921,7 @@ mod tests { "__$_$__$$$$$__$$_$$$_$$__$$___$$(address,address,uint256)".to_string() ); - let selector = SimpleCast::get_selector(&sig, None).unwrap(); + let selector = SimpleCast::get_selector(&sig, 0).unwrap(); assert_eq!(selector.0, "0x23b872dd".to_string()); } _ => unreachable!(), diff --git a/crates/cast/src/base.rs b/crates/cast/src/base.rs index 016d7402aea37..5ec41d04d6059 100644 --- a/crates/cast/src/base.rs +++ b/crates/cast/src/base.rs @@ -5,7 +5,7 @@ use ethers_core::{ }; use eyre::Result; use std::{ - convert::{Infallible, TryFrom, TryInto}, + convert::Infallible, fmt::{Binary, Debug, Display, Formatter, LowerHex, Octal, Result as FmtResult, UpperHex}, iter::FromIterator, num::IntErrorKind, @@ -118,9 +118,9 @@ impl From for String { } impl Base { - pub fn unwrap_or_detect(base: Option, s: impl AsRef) -> Result { + pub fn unwrap_or_detect(base: Option<&str>, s: impl AsRef) -> Result { match base { - Some(base) => base.try_into(), + Some(base) => base.parse(), None => Self::detect(s), } } @@ -355,7 +355,7 @@ impl NumberWithBase { /// Parses a string slice into a signed integer. If base is None then it tries to determine base /// from the prefix, otherwise defaults to Decimal. - pub fn parse_int(s: &str, base: Option) -> Result { + pub fn parse_int(s: &str, base: Option<&str>) -> Result { let base = Base::unwrap_or_detect(base, s)?; let (number, is_nonnegative) = Self::_parse_int(s, base)?; Ok(Self { number, is_nonnegative, base }) @@ -363,7 +363,7 @@ impl NumberWithBase { /// Parses a string slice into an unsigned integer. If base is None then it tries to determine /// base from the prefix, otherwise defaults to Decimal. - pub fn parse_uint(s: &str, base: Option) -> Result { + pub fn parse_uint(s: &str, base: Option<&str>) -> Result { let base = Base::unwrap_or_detect(base, s)?; let number = Self::_parse_uint(s, base)?; Ok(Self { number, is_nonnegative: true, base }) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 4cfe2dc04de21..eff98be4eae2d 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -57,7 +57,7 @@ where /// /// ``` /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; + /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -76,17 +76,17 @@ where /// ```no_run /// use cast::{Cast, TxBuilder}; /// use ethers_core::types::{Address, Chain}; - /// use ethers_providers::{Provider, Http}; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; /// let sig = "function greeting(uint256 i) public returns (string)"; /// let args = vec!["5".to_owned()]; - /// let mut builder = TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; - /// builder - /// .set_args(sig, args).await?; + /// let mut builder = + /// TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; + /// builder.set_args(sig, args).await?; /// let builder_output = builder.build(); /// let cast = Cast::new(provider); /// let data = cast.call(builder_output, None).await?; @@ -113,29 +113,26 @@ where if res.is_empty() { // check that the recipient is a contract that can be called if let Some(NameOrAddress::Address(addr)) = tx.to() { - let code = self.provider.get_code(*addr, block).await?; - if code.is_empty() { - eyre::bail!("Contract {:?} does not exist", addr) + if let Ok(code) = self.provider.get_code(*addr, block).await { + if code.is_empty() { + eyre::bail!("contract {addr:?} does not exist") + } } } } return Err(err).wrap_err( - "could not decode output. did you specify the wrong function return data type perhaps?" + "could not decode output; did you specify the wrong function return data type?" ); } }; } + // handle case when return type is not specified Ok(if decoded.is_empty() { format!("{res}\n") } else { // seth compatible user-friendly return type conversions - decoded - .iter() - .map(TokenDisplay) - .map(|token| token.to_string()) - .collect::>() - .join("\n") + decoded.iter().map(format_token).collect::>().join("\n") }) } @@ -146,17 +143,17 @@ where /// ```no_run /// use cast::{Cast, TxBuilder}; /// use ethers_core::types::{Address, Chain}; - /// use ethers_providers::{Provider, Http}; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; /// let sig = "greeting(uint256)(string)"; /// let args = vec!["5".to_owned()]; - /// let mut builder = TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; - /// builder - /// .set_args(sig, args).await?; + /// let mut builder = + /// TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; + /// builder.set_args(sig, args).await?; /// let builder_output = builder.peek(); /// let cast = Cast::new(&provider); /// let access_list = cast.access_list(builder_output, None, false).await?; @@ -205,11 +202,11 @@ where /// # Example /// /// ```no_run - /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Chain, Address as eAddress}; /// use alloy_primitives::{Address, U256}; - /// use ethers_providers::{Provider, Http}; - /// use std::{str::FromStr, convert::TryFrom}; + /// use cast::{Cast, TxBuilder}; + /// use ethers_core::types::{Address as eAddress, Chain}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -221,11 +218,7 @@ where /// let value = U256::from_str("1").unwrap(); /// let nonce = U256::from_str("1").unwrap(); /// let mut builder = TxBuilder::new(&provider, from, Some(to), Chain::Mainnet, false).await?; - /// builder - /// .set_args(sig, args).await? - /// .set_gas(gas) - /// .set_value(value) - /// .set_nonce(nonce); + /// builder.set_args(sig, args).await?.set_gas(gas).set_value(value).set_nonce(nonce); /// let builder_output = builder.build(); /// let cast = Cast::new(provider); /// let data = cast.send(builder_output).await?; @@ -249,7 +242,7 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; + /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -275,11 +268,11 @@ where /// # Example /// /// ```no_run + /// use alloy_primitives::U256; /// use cast::{Cast, TxBuilder}; /// use ethers_core::types::{Address, Chain}; - /// use alloy_primitives::U256; - /// use ethers_providers::{Provider, Http}; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -289,9 +282,7 @@ where /// let args = vec!["5".to_owned()]; /// let value = U256::from_str("1").unwrap(); /// let mut builder = TxBuilder::new(&provider, from, Some(to), Chain::Mainnet, false).await?; - /// builder - /// .set_value(value) - /// .set_args(sig, args).await?; + /// builder.set_value(value).set_args(sig, args).await?; /// let builder_output = builder.peek(); /// let cast = Cast::new(&provider); /// let data = cast.estimate(builder_output).await?; @@ -311,7 +302,7 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; + /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -478,9 +469,9 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers::types::NameOrAddress; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -503,9 +494,9 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers_core::types::Address; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -532,9 +523,9 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers_core::types::Address; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -560,11 +551,11 @@ where /// # Example /// /// ```no_run + /// use alloy_primitives::{Address, U256}; /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers::types::NameOrAddress; - /// use alloy_primitives::{Address, U256}; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -575,7 +566,10 @@ where /// let computed_address = cast.compute_address(addr, Some(nonce)).await?; /// println!("Computed address for address {} with nonce {}: {}", addr, nonce, computed_address); /// let computed_address_no_nonce = cast.compute_address(addr, None).await?; - /// println!("Computed address for address {} with nonce {}: {}", addr, nonce, computed_address_no_nonce); + /// println!( + /// "Computed address for address {} with nonce {}: {}", + /// addr, nonce, computed_address_no_nonce + /// ); /// # Ok(()) /// # } /// ``` @@ -597,9 +591,9 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers_core::types::Address; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -628,9 +622,9 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers_core::types::Address; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -654,7 +648,7 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; + /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -696,7 +690,7 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; + /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -758,12 +752,13 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; + /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let cast = Cast::new(provider); - /// let result = cast.rpc("eth_getBalance", &["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"]) + /// let result = cast + /// .rpc("eth_getBalance", &["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"]) /// .await?; /// println!("{}", result); /// # Ok(()) @@ -783,9 +778,9 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers_core::types::{Address, H256}; - /// use std::{str::FromStr, convert::TryFrom}; + /// use ethers_providers::{Http, Provider}; + /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; @@ -835,18 +830,20 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_providers::{Provider, Http}; /// use ethers_core::types::{BlockId, BlockNumber}; + /// use ethers_providers::{Http, Provider}; /// use std::convert::TryFrom; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let cast = Cast::new(provider); /// - /// let block_number = cast.convert_block_number(Some(BlockId::Number(BlockNumber::from(5)))).await?; + /// let block_number = + /// cast.convert_block_number(Some(BlockId::Number(BlockNumber::from(5)))).await?; /// assert_eq!(block_number, Some(BlockNumber::from(5))); /// - /// let block_number = cast.convert_block_number(Some(BlockId::Hash("0x1234".parse().unwrap()))).await?; + /// let block_number = + /// cast.convert_block_number(Some(BlockId::Hash("0x1234".parse().unwrap()))).await?; /// assert_eq!(block_number, Some(BlockNumber::from(1234))); /// /// let block_number = cast.convert_block_number(None).await?; @@ -876,17 +873,16 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers_core::abi::Address; + /// use ethers_core::{abi::Address, types::Filter}; /// use ethers_providers::{Provider, Ws}; - /// use ethers_core::types::Filter; - /// use std::{str::FromStr, convert::TryFrom}; - /// use std::io; + /// use std::{io, str::FromStr}; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::new(Ws::connect("wss://localhost:8545").await?); /// let cast = Cast::new(provider); /// - /// let filter = Filter::new().address(Address::from_str("0x00000000006c3852cbEf3e08E8dF289169EdE581")?); + /// let filter = + /// Filter::new().address(Address::from_str("0x00000000006c3852cbEf3e08E8dF289169EdE581")?); /// let mut output = io::stdout(); /// cast.subscribe(filter, &mut output, false).await?; /// # Ok(()) @@ -988,11 +984,12 @@ impl SimpleCast { /// # Example /// /// ``` - /// # use cast::SimpleCast; - /// # use ethers_core::types::{I256, U256}; - /// assert_eq!(SimpleCast::max_int("uint256")?, format!("{}", U256::MAX)); - /// assert_eq!(SimpleCast::max_int("int256")?, format!("{}", I256::MAX)); - /// assert_eq!(SimpleCast::max_int("int32")?, format!("{}", i32::MAX)); + /// use cast::SimpleCast; + /// use ethers_core::types::{I256, U256}; + /// + /// assert_eq!(SimpleCast::max_int("uint256")?, U256::MAX.to_string()); + /// assert_eq!(SimpleCast::max_int("int256")?, I256::MAX.to_string()); + /// assert_eq!(SimpleCast::max_int("int32")?, i32::MAX.to_string()); /// # Ok::<(), eyre::Report>(()) /// ``` pub fn max_int(s: &str) -> Result { @@ -1004,11 +1001,12 @@ impl SimpleCast { /// # Example /// /// ``` - /// # use cast::SimpleCast; - /// # use ethers_core::types::{I256, U256}; + /// use cast::SimpleCast; + /// use ethers_core::types::{I256, U256}; + /// /// assert_eq!(SimpleCast::min_int("uint256")?, "0"); - /// assert_eq!(SimpleCast::min_int("int256")?, format!("{}", I256::MIN)); - /// assert_eq!(SimpleCast::min_int("int32")?, format!("{}", i32::MIN)); + /// assert_eq!(SimpleCast::min_int("int256")?, I256::MIN.to_string()); + /// assert_eq!(SimpleCast::min_int("int32")?, i32::MIN.to_string()); /// # Ok::<(), eyre::Report>(()) /// ``` pub fn min_int(s: &str) -> Result { @@ -1050,13 +1048,10 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::from_utf8("yo"), "0x796f"); - /// assert_eq!(Cast::from_utf8("Hello, World!"), "0x48656c6c6f2c20576f726c6421"); - /// assert_eq!(Cast::from_utf8("TurboDappTools"), "0x547572626f44617070546f6f6c73"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::from_utf8("yo"), "0x796f"); + /// assert_eq!(Cast::from_utf8("Hello, World!"), "0x48656c6c6f2c20576f726c6421"); + /// assert_eq!(Cast::from_utf8("TurboDappTools"), "0x547572626f44617070546f6f6c73"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn from_utf8(s: &str) -> String { hex::encode_prefixed(s) @@ -1069,13 +1064,10 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_ascii("0x796f")?, "yo"); - /// assert_eq!(Cast::to_ascii("48656c6c6f2c20576f726c6421")?, "Hello, World!"); - /// assert_eq!(Cast::to_ascii("0x547572626f44617070546f6f6c73")?, "TurboDappTools"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::to_ascii("0x796f")?, "yo"); + /// assert_eq!(Cast::to_ascii("48656c6c6f2c20576f726c6421")?, "Hello, World!"); + /// assert_eq!(Cast::to_ascii("0x547572626f44617070546f6f6c73")?, "TurboDappTools"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_ascii(hex: &str) -> Result { let bytes = hex::decode(hex)?; @@ -1090,14 +1082,11 @@ impl SimpleCast { /// use cast::SimpleCast as Cast; /// use ethers_core::types::U256; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::from_fixed_point("10", "0")?, "10"); - /// assert_eq!(Cast::from_fixed_point("1.0", "1")?, "10"); - /// assert_eq!(Cast::from_fixed_point("0.10", "2")?, "10"); - /// assert_eq!(Cast::from_fixed_point("0.010", "3")?, "10"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::from_fixed_point("10", "0")?, "10"); + /// assert_eq!(Cast::from_fixed_point("1.0", "1")?, "10"); + /// assert_eq!(Cast::from_fixed_point("0.10", "2")?, "10"); + /// assert_eq!(Cast::from_fixed_point("0.010", "3")?, "10"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn from_fixed_point(value: &str, decimals: &str) -> Result { // first try u32 as Units assumes a string can only be "ether", "gwei"... and not a number @@ -1117,19 +1106,16 @@ impl SimpleCast { /// use cast::SimpleCast as Cast; /// use ethers_core::types::U256; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_fixed_point("10", "0")?, "10."); - /// assert_eq!(Cast::to_fixed_point("10", "1")?, "1.0"); - /// assert_eq!(Cast::to_fixed_point("10", "2")?, "0.10"); - /// assert_eq!(Cast::to_fixed_point("10", "3")?, "0.010"); - /// - /// assert_eq!(Cast::to_fixed_point("-10", "0")?, "-10."); - /// assert_eq!(Cast::to_fixed_point("-10", "1")?, "-1.0"); - /// assert_eq!(Cast::to_fixed_point("-10", "2")?, "-0.10"); - /// assert_eq!(Cast::to_fixed_point("-10", "3")?, "-0.010"); + /// assert_eq!(Cast::to_fixed_point("10", "0")?, "10."); + /// assert_eq!(Cast::to_fixed_point("10", "1")?, "1.0"); + /// assert_eq!(Cast::to_fixed_point("10", "2")?, "0.10"); + /// assert_eq!(Cast::to_fixed_point("10", "3")?, "0.010"); /// - /// Ok(()) - /// } + /// assert_eq!(Cast::to_fixed_point("-10", "0")?, "-10."); + /// assert_eq!(Cast::to_fixed_point("-10", "1")?, "-1.0"); + /// assert_eq!(Cast::to_fixed_point("-10", "2")?, "-0.10"); + /// assert_eq!(Cast::to_fixed_point("-10", "3")?, "-0.010"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_fixed_point(value: &str, decimals: &str) -> Result { let (sign, mut value, value_len) = { @@ -1161,12 +1147,9 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::concat_hex(["0x00", "0x01"]), "0x0001"); - /// assert_eq!(Cast::concat_hex(["1", "2"]), "0x12"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::concat_hex(["0x00", "0x01"]), "0x0001"); + /// assert_eq!(Cast::concat_hex(["1", "2"]), "0x12"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn concat_hex>(values: impl IntoIterator) -> String { let mut out = String::new(); @@ -1184,16 +1167,21 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_uint256("100")?, "0x0000000000000000000000000000000000000000000000000000000000000064"); - /// assert_eq!(Cast::to_uint256("192038293923")?, "0x0000000000000000000000000000000000000000000000000000002cb65fd1a3"); - /// assert_eq!( - /// Cast::to_uint256("115792089237316195423570985008687907853269984665640564039457584007913129639935")?, - /// "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - /// ); - /// - /// Ok(()) - /// } + /// assert_eq!( + /// Cast::to_uint256("100")?, + /// "0x0000000000000000000000000000000000000000000000000000000000000064" + /// ); + /// assert_eq!( + /// Cast::to_uint256("192038293923")?, + /// "0x0000000000000000000000000000000000000000000000000000002cb65fd1a3" + /// ); + /// assert_eq!( + /// Cast::to_uint256( + /// "115792089237316195423570985008687907853269984665640564039457584007913129639935" + /// )?, + /// "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + /// ); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_uint256(value: &str) -> Result { let n = NumberWithBase::parse_uint(value, None)?; @@ -1207,23 +1195,39 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_int256("0")?, "0x0000000000000000000000000000000000000000000000000000000000000000"); - /// assert_eq!(Cast::to_int256("100")?, "0x0000000000000000000000000000000000000000000000000000000000000064"); - /// assert_eq!(Cast::to_int256("-100")?, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9c"); - /// assert_eq!(Cast::to_int256("192038293923")?, "0x0000000000000000000000000000000000000000000000000000002cb65fd1a3"); - /// assert_eq!(Cast::to_int256("-192038293923")?, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffd349a02e5d"); - /// assert_eq!( - /// Cast::to_int256("57896044618658097711785492504343953926634992332820282019728792003956564819967")?, - /// "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - /// ); - /// assert_eq!( - /// Cast::to_int256("-57896044618658097711785492504343953926634992332820282019728792003956564819968")?, - /// "0x8000000000000000000000000000000000000000000000000000000000000000" - /// ); - /// - /// Ok(()) - /// } + /// assert_eq!( + /// Cast::to_int256("0")?, + /// "0x0000000000000000000000000000000000000000000000000000000000000000" + /// ); + /// assert_eq!( + /// Cast::to_int256("100")?, + /// "0x0000000000000000000000000000000000000000000000000000000000000064" + /// ); + /// assert_eq!( + /// Cast::to_int256("-100")?, + /// "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9c" + /// ); + /// assert_eq!( + /// Cast::to_int256("192038293923")?, + /// "0x0000000000000000000000000000000000000000000000000000002cb65fd1a3" + /// ); + /// assert_eq!( + /// Cast::to_int256("-192038293923")?, + /// "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffd349a02e5d" + /// ); + /// assert_eq!( + /// Cast::to_int256( + /// "57896044618658097711785492504343953926634992332820282019728792003956564819967" + /// )?, + /// "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + /// ); + /// assert_eq!( + /// Cast::to_int256( + /// "-57896044618658097711785492504343953926634992332820282019728792003956564819968" + /// )?, + /// "0x8000000000000000000000000000000000000000000000000000000000000000" + /// ); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_int256(value: &str) -> Result { let n = NumberWithBase::parse_int(value, None)?; @@ -1237,14 +1241,11 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_unit("1 wei", "wei")?, "1"); - /// assert_eq!(Cast::to_unit("1", "wei")?, "1"); - /// assert_eq!(Cast::to_unit("1ether", "wei")?, "1000000000000000000"); - /// assert_eq!(Cast::to_unit("100 gwei", "gwei")?, "100"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::to_unit("1 wei", "wei")?, "1"); + /// assert_eq!(Cast::to_unit("1", "wei")?, "1"); + /// assert_eq!(Cast::to_unit("1ether", "wei")?, "1000000000000000000"); + /// assert_eq!(Cast::to_unit("100 gwei", "gwei")?, "100"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_unit(value: &str, unit: &str) -> Result { let value = DynSolType::coerce_str(&DynSolType::Uint(256), value)? @@ -1285,15 +1286,12 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::from_wei("1", "gwei")?, "0.000000001"); - /// assert_eq!(Cast::from_wei("12340000005", "gwei")?, "12.340000005"); - /// assert_eq!(Cast::from_wei("10", "ether")?, "0.000000000000000010"); - /// assert_eq!(Cast::from_wei("100", "eth")?, "0.000000000000000100"); - /// assert_eq!(Cast::from_wei("17", "")?, "0.000000000000000017"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::from_wei("1", "gwei")?, "0.000000001"); + /// assert_eq!(Cast::from_wei("12340000005", "gwei")?, "12.340000005"); + /// assert_eq!(Cast::from_wei("10", "ether")?, "0.000000000000000010"); + /// assert_eq!(Cast::from_wei("100", "eth")?, "0.000000000000000100"); + /// assert_eq!(Cast::from_wei("17", "")?, "0.000000000000000017"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn from_wei(value: &str, unit: &str) -> Result { let value = NumberWithBase::parse_int(value, None)?.number(); @@ -1311,14 +1309,11 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_wei("1", "")?, "1000000000000000000"); - /// assert_eq!(Cast::to_wei("100", "gwei")?, "100000000000"); - /// assert_eq!(Cast::to_wei("100", "eth")?, "100000000000000000000"); - /// assert_eq!(Cast::to_wei("1000", "ether")?, "1000000000000000000000"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::to_wei("1", "")?, "1000000000000000000"); + /// assert_eq!(Cast::to_wei("100", "gwei")?, "100000000000"); + /// assert_eq!(Cast::to_wei("100", "eth")?, "100000000000000000000"); + /// assert_eq!(Cast::to_wei("1000", "ether")?, "1000000000000000000000"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_wei(value: &str, unit: &str) -> Result { let wei = match unit { @@ -1335,14 +1330,12 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::from_rlp("0xc0".to_string()).unwrap(), "[]"); - /// assert_eq!(Cast::from_rlp("0x0f".to_string()).unwrap(), "\"0x0f\""); - /// assert_eq!(Cast::from_rlp("0x33".to_string()).unwrap(), "\"0x33\""); - /// assert_eq!(Cast::from_rlp("0xc161".to_string()).unwrap(), "[\"0x61\"]"); - /// assert_eq!(Cast::from_rlp("0xc26162".to_string()).unwrap(), "[\"0x61\",\"0x62\"]"); - /// Ok(()) - /// } + /// assert_eq!(Cast::from_rlp("0xc0").unwrap(), "[]"); + /// assert_eq!(Cast::from_rlp("0x0f").unwrap(), "\"0x0f\""); + /// assert_eq!(Cast::from_rlp("0x33").unwrap(), "\"0x33\""); + /// assert_eq!(Cast::from_rlp("0xc161").unwrap(), "[\"0x61\"]"); + /// assert_eq!(Cast::from_rlp("0xc26162").unwrap(), "[\"0x61\",\"0x62\"]"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn from_rlp(value: impl AsRef) -> Result { let bytes = hex::decode(value.as_ref()).wrap_err("Could not decode hex")?; @@ -1357,13 +1350,11 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_rlp("[]").unwrap(),"0xc0".to_string()); - /// assert_eq!(Cast::to_rlp("0x22").unwrap(),"0x22".to_string()); - /// assert_eq!(Cast::to_rlp("[\"0x61\"]",).unwrap(), "0xc161".to_string()); - /// assert_eq!(Cast::to_rlp( "[\"0xf1\",\"f2\"]").unwrap(), "0xc481f181f2".to_string()); - /// Ok(()) - /// } + /// assert_eq!(Cast::to_rlp("[]").unwrap(), "0xc0".to_string()); + /// assert_eq!(Cast::to_rlp("0x22").unwrap(), "0x22".to_string()); + /// assert_eq!(Cast::to_rlp("[\"0x61\"]",).unwrap(), "0xc161".to_string()); + /// assert_eq!(Cast::to_rlp("[\"0xf1\",\"f2\"]").unwrap(), "0xc481f181f2".to_string()); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_rlp(value: &str) -> Result { let val = serde_json::from_str(value) @@ -1380,27 +1371,34 @@ impl SimpleCast { /// use cast::SimpleCast as Cast; /// use ethers_core::types::{I256, U256}; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::to_base("100", Some("10".to_string()), "16")?, "0x64"); - /// assert_eq!(Cast::to_base("100", Some("10".to_string()), "oct")?, "0o144"); - /// assert_eq!(Cast::to_base("100", Some("10".to_string()), "binary")?, "0b1100100"); - /// - /// assert_eq!(Cast::to_base("0xffffffffffffffff", None, "10")?, u64::MAX.to_string()); - /// assert_eq!(Cast::to_base("0xffffffffffffffffffffffffffffffff", None, "dec")?, u128::MAX.to_string()); - /// // U256::MAX overflows as internally it is being parsed as I256 - /// assert_eq!(Cast::to_base("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", None, "decimal")?, I256::MAX.to_string()); - /// - /// Ok(()) - /// } - /// ``` - pub fn to_base(value: &str, base_in: Option, base_out: &str) -> Result { + /// assert_eq!(Cast::to_base("100", Some("10"), "16")?, "0x64"); + /// assert_eq!(Cast::to_base("100", Some("10"), "oct")?, "0o144"); + /// assert_eq!(Cast::to_base("100", Some("10"), "binary")?, "0b1100100"); + /// + /// assert_eq!(Cast::to_base("0xffffffffffffffff", None, "10")?, u64::MAX.to_string()); + /// assert_eq!( + /// Cast::to_base("0xffffffffffffffffffffffffffffffff", None, "dec")?, + /// u128::MAX.to_string() + /// ); + /// // U256::MAX overflows as internally it is being parsed as I256 + /// assert_eq!( + /// Cast::to_base( + /// "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + /// None, + /// "decimal" + /// )?, + /// I256::MAX.to_string() + /// ); + /// # Ok::<_, eyre::Report>(()) + /// ``` + pub fn to_base(value: &str, base_in: Option<&str>, base_out: &str) -> Result { let base_in = Base::unwrap_or_detect(base_in, value)?; let base_out: Base = base_out.parse()?; if base_in == base_out { return Ok(value.to_string()) } - let mut n = NumberWithBase::parse_int(value, Some(base_in.to_string()))?; + let mut n = NumberWithBase::parse_int(value, Some(&base_in.to_string()))?; n.set_base(base_out); // Use Debug fmt @@ -1414,7 +1412,6 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// # fn main() -> eyre::Result<()> { /// let bytes = Cast::to_bytes32("1234")?; /// assert_eq!(bytes, "0x1234000000000000000000000000000000000000000000000000000000000000"); /// @@ -1423,9 +1420,7 @@ impl SimpleCast { /// /// let err = Cast::to_bytes32("0x123400000000000000000000000000000000000000000000000000000000000011").unwrap_err(); /// assert_eq!(err.to_string(), "string >32 bytes"); - /// - /// # Ok(()) - /// # } + /// # Ok::<_, eyre::Report>(()) pub fn to_bytes32(s: &str) -> Result { let s = strip_0x(s); if s.len() > 64 { @@ -1485,7 +1480,6 @@ impl SimpleCast { /// use cast::SimpleCast as Cast; /// use hex; /// - /// fn main() -> eyre::Result<()> { /// // Passing `input = false` will decode the data as the output type. /// // The input data types and the full function sig are ignored, i.e. /// // you could also pass `balanceOf()(uint256)` and it'd still work. @@ -1513,10 +1507,7 @@ impl SimpleCast { /// decoded, /// vec!["0x8dbd1b711dc621e1404633da156fcc779e1c6f3e", "0xd9f3c9cc99548bf3b44a43e0a2d07399eb918adc", "42", "1", ""] /// ); - /// - /// - /// # Ok(()) - /// } + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn abi_decode(sig: &str, calldata: &str, input: bool) -> Result> { foundry_common::abi::abi_decode_calldata(sig, calldata, input, false) @@ -1530,16 +1521,14 @@ impl SimpleCast { /// /// ``` /// use cast::SimpleCast as Cast; - /// use hex; /// - /// fn main() -> eyre::Result<()> { - /// // Passing `input = false` will decode the data as the output type. - /// // The input data types and the full function sig are ignored, i.e. - /// // you could also pass `balanceOf()(uint256)` and it'd still work. - /// let data = "0x0000000000000000000000000000000000000000000000000000000000000001"; - /// let sig = "balanceOf(address, uint256)(uint256)"; - /// let decoded = Cast::calldata_decode(sig, data, false)?[0].as_uint().unwrap().0.to_string(); - /// assert_eq!(decoded, "1"); + /// // Passing `input = false` will decode the data as the output type. + /// // The input data types and the full function sig are ignored, i.e. + /// // you could also pass `balanceOf()(uint256)` and it'd still work. + /// let data = "0x0000000000000000000000000000000000000000000000000000000000000001"; + /// let sig = "balanceOf(address, uint256)(uint256)"; + /// let decoded = Cast::calldata_decode(sig, data, false)?[0].as_uint().unwrap().0.to_string(); + /// assert_eq!(decoded, "1"); /// /// // Passing `input = true` will decode the data with the input function signature. /// let data = "0xf242432a0000000000000000000000008dbd1b711dc621e1404633da156fcc779e1c6f3e000000000000000000000000d9f3c9cc99548bf3b44a43e0a2d07399eb918adc000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000"; @@ -1558,10 +1547,7 @@ impl SimpleCast { /// decoded, /// vec!["0x8dbd1b711dc621e1404633da156fcc779e1c6f3e", "0xd9f3c9cc99548bf3b44a43e0a2d07399eb918adc", "42", "1", ""] /// ); - /// - /// - /// # Ok(()) - /// } + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn calldata_decode(sig: &str, calldata: &str, input: bool) -> Result> { foundry_common::abi::abi_decode_calldata(sig, calldata, input, true) @@ -1573,19 +1559,17 @@ impl SimpleCast { /// # Example /// /// ``` - /// # use cast::SimpleCast as Cast; + /// use cast::SimpleCast as Cast; /// - /// # fn main() -> eyre::Result<()> { - /// assert_eq!( - /// "0x0000000000000000000000000000000000000000000000000000000000000001", - /// Cast::abi_encode("f(uint a)", &["1"]).unwrap().as_str() - /// ); - /// assert_eq!( - /// "0x0000000000000000000000000000000000000000000000000000000000000001", - /// Cast::abi_encode("constructor(uint a)", &["1"]).unwrap().as_str() - /// ); - /// # Ok(()) - /// # } + /// assert_eq!( + /// "0x0000000000000000000000000000000000000000000000000000000000000001", + /// Cast::abi_encode("f(uint a)", &["1"]).unwrap().as_str() + /// ); + /// assert_eq!( + /// "0x0000000000000000000000000000000000000000000000000000000000000001", + /// Cast::abi_encode("constructor(uint a)", &["1"]).unwrap().as_str() + /// ); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn abi_encode(sig: &str, args: &[impl AsRef]) -> Result { let func = match Function::parse(sig) { @@ -1607,15 +1591,13 @@ impl SimpleCast { /// # Example /// /// ``` - /// # use cast::SimpleCast as Cast; + /// use cast::SimpleCast as Cast; /// - /// # fn main() -> eyre::Result<()> { - /// assert_eq!( - /// "0x693c61390000000000000000000000000000000000000000000000000000000000000001", - /// Cast::calldata_encode("f(uint a)", &["1"]).unwrap().as_str() - /// ); - /// # Ok(()) - /// # } + /// assert_eq!( + /// "0x693c61390000000000000000000000000000000000000000000000000000000000000001", + /// Cast::calldata_encode("f(uint a)", &["1"]).unwrap().as_str() + /// ); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn calldata_encode(sig: impl AsRef, args: &[impl AsRef]) -> Result { let func = Function::parse(sig.as_ref())?; @@ -1627,14 +1609,11 @@ impl SimpleCast { /// Etherscan. It returns a vector of [`InterfaceSource`] structs that contain the source of the /// interface and their name. /// ```no_run - /// use cast::SimpleCast as Cast; - /// use cast::AbiPath; + /// use cast::{AbiPath, SimpleCast as Cast}; /// # async fn foo() -> eyre::Result<()> { - /// let path = AbiPath::Local { - /// path: "utils/testdata/interfaceTestABI.json".to_owned(), - /// name: None, - /// }; - /// let interfaces= Cast::generate_interface(path).await?; + /// let path = + /// AbiPath::Local { path: "utils/testdata/interfaceTestABI.json".to_owned(), name: None }; + /// let interfaces = Cast::generate_interface(path).await?; /// println!("interface {} {{\n {}\n}}", interfaces[0].name, interfaces[0].source); /// # Ok(()) /// # } @@ -1702,12 +1681,15 @@ impl SimpleCast { /// ``` /// # use cast::SimpleCast as Cast; /// - /// # fn main() -> eyre::Result<()> { - /// - /// assert_eq!(Cast::index("address", "0xD0074F4E6490ae3f888d1d4f7E3E43326bD3f0f5" ,"2").unwrap().as_str(),"0x9525a448a9000053a4d151336329d6563b7e80b24f8e628e95527f218e8ab5fb"); - /// assert_eq!(Cast::index("uint256","42" ,"6").unwrap().as_str(),"0xfc808b0f31a1e6b9cf25ff6289feae9b51017b392cc8e25620a94a38dcdafcc1"); - /// # Ok(()) - /// # } + /// assert_eq!( + /// Cast::index("address", "0xD0074F4E6490ae3f888d1d4f7E3E43326bD3f0f5", "2").unwrap().as_str(), + /// "0x9525a448a9000053a4d151336329d6563b7e80b24f8e628e95527f218e8ab5fb" + /// ); + /// assert_eq!( + /// Cast::index("uint256", "42", "6").unwrap().as_str(), + /// "0xfc808b0f31a1e6b9cf25ff6289feae9b51017b392cc8e25620a94a38dcdafcc1" + /// ); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn index(from_type: &str, from_value: &str, slot_number: &str) -> Result { let sig = format!("x({from_type},uint256)"); @@ -1725,14 +1707,23 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::namehash("")?, "0x0000000000000000000000000000000000000000000000000000000000000000"); - /// assert_eq!(Cast::namehash("eth")?, "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae"); - /// assert_eq!(Cast::namehash("foo.eth")?, "0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f"); - /// assert_eq!(Cast::namehash("sub.foo.eth")?, "0x500d86f9e663479e5aaa6e99276e55fc139c597211ee47d17e1e92da16a83402"); - /// - /// Ok(()) - /// } + /// assert_eq!( + /// Cast::namehash("")?, + /// "0x0000000000000000000000000000000000000000000000000000000000000000" + /// ); + /// assert_eq!( + /// Cast::namehash("eth")?, + /// "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae" + /// ); + /// assert_eq!( + /// Cast::namehash("foo.eth")?, + /// "0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f" + /// ); + /// assert_eq!( + /// Cast::namehash("sub.foo.eth")?, + /// "0x500d86f9e663479e5aaa6e99276e55fc139c597211ee47d17e1e92da16a83402" + /// ); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn namehash(ens: &str) -> Result { let mut node = vec![0u8; 32]; @@ -1761,14 +1752,23 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::keccak("foo")?, "0x41b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d"); - /// assert_eq!(Cast::keccak("123abc")?, "0xb1f1c74a1ba56f07a892ea1110a39349d40f66ca01d245e704621033cb7046a4"); - /// assert_eq!(Cast::keccak("0x12")?, "0x5fa2358263196dbbf23d1ca7a509451f7a2f64c15837bfbb81298b1e3e24e4fa"); - /// assert_eq!(Cast::keccak("12")?, "0x7f8b6b088b6d74c2852fc86c796dca07b44eed6fb3daf5e6b59f7c364db14528"); - /// - /// Ok(()) - /// } + /// assert_eq!( + /// Cast::keccak("foo")?, + /// "0x41b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d" + /// ); + /// assert_eq!( + /// Cast::keccak("123abc")?, + /// "0xb1f1c74a1ba56f07a892ea1110a39349d40f66ca01d245e704621033cb7046a4" + /// ); + /// assert_eq!( + /// Cast::keccak("0x12")?, + /// "0x5fa2358263196dbbf23d1ca7a509451f7a2f64c15837bfbb81298b1e3e24e4fa" + /// ); + /// assert_eq!( + /// Cast::keccak("12")?, + /// "0x7f8b6b088b6d74c2852fc86c796dca07b44eed6fb3daf5e6b59f7c364db14528" + /// ); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn keccak(data: &str) -> Result { let hash = match data.as_bytes() { @@ -1788,18 +1788,15 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::left_shift("16", "10", Some("10".to_string()), "hex")?, "0x4000"); - /// assert_eq!(Cast::left_shift("255", "16", Some("dec".to_string()), "hex")?, "0xff0000"); - /// assert_eq!(Cast::left_shift("0xff", "16", None, "hex")?, "0xff0000"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::left_shift("16", "10", Some("10"), "hex")?, "0x4000"); + /// assert_eq!(Cast::left_shift("255", "16", Some("dec"), "hex")?, "0xff0000"); + /// assert_eq!(Cast::left_shift("0xff", "16", None, "hex")?, "0xff0000"); + /// # Ok::<_, eyre::Report>(()) /// ``` pub fn left_shift( value: &str, bits: &str, - base_in: Option, + base_in: Option<&str>, base_out: &str, ) -> Result { let base_out: Base = base_out.parse()?; @@ -1818,18 +1815,15 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::right_shift("0x4000", "10", None, "dec")?, "16"); - /// assert_eq!(Cast::right_shift("16711680", "16", Some("10".to_string()), "hex")?, "0xff"); - /// assert_eq!(Cast::right_shift("0xff0000", "16", None, "hex")?, "0xff"); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::right_shift("0x4000", "10", None, "dec")?, "16"); + /// assert_eq!(Cast::right_shift("16711680", "16", Some("10"), "hex")?, "0xff"); + /// assert_eq!(Cast::right_shift("0xff0000", "16", None, "hex")?, "0xff"); + /// # Ok::<(), eyre::Report>(()) /// ``` pub fn right_shift( value: &str, bits: &str, - base_in: Option, + base_in: Option<&str>, base_out: &str, ) -> Result { let base_out: Base = base_out.parse()?; @@ -1850,13 +1844,20 @@ impl SimpleCast { /// # use ethers_core::types::Chain; /// /// # async fn foo() -> eyre::Result<()> { - /// assert_eq!( - /// "/* + /// assert_eq!( + /// "/* /// - Bytecode Verification performed was compared on second iteration - /// This file is part of the DAO.....", - /// Cast::etherscan_source(Chain::Mainnet, "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), "".to_string()).await.unwrap().as_str() - /// ); - /// # Ok(()) + /// Cast::etherscan_source( + /// Chain::Mainnet, + /// "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), + /// "".to_string() + /// ) + /// .await + /// .unwrap() + /// .as_str() + /// ); + /// # Ok(()) /// # } /// ``` pub async fn etherscan_source( @@ -1880,8 +1881,14 @@ impl SimpleCast { /// # use std::path::PathBuf; /// /// # async fn expand() -> eyre::Result<()> { - /// Cast::expand_etherscan_source_to_directory(Chain::Mainnet, "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), "".to_string(), PathBuf::from("output_dir")).await?; - /// # Ok(()) + /// Cast::expand_etherscan_source_to_directory( + /// Chain::Mainnet, + /// "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), + /// "".to_string(), + /// PathBuf::from("output_dir"), + /// ) + /// .await?; + /// # Ok(()) /// # } /// ``` pub async fn expand_etherscan_source_to_directory( @@ -1923,23 +1930,19 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { - /// assert_eq!(Cast::get_selector("foo(address,uint256)", None)?.0, String::from("0xbd0d639f")); - /// - /// Ok(()) - /// } + /// assert_eq!(Cast::get_selector("foo(address,uint256)", 0)?.0, String::from("0xbd0d639f")); + /// # Ok::<(), eyre::Error>(()) /// ``` - pub fn get_selector(signature: &str, optimize: Option) -> Result<(String, String)> { - let optimize = optimize.unwrap_or(0); + pub fn get_selector(signature: &str, optimize: usize) -> Result<(String, String)> { if optimize > 4 { - eyre::bail!("Number of leading zeroes must not be greater than 4"); + eyre::bail!("number of leading zeroes must not be greater than 4"); } if optimize == 0 { let selector = Function::parse(signature)?.selector(); return Ok((selector.to_string(), String::from(signature))) } let Some((name, params)) = signature.split_once('(') else { - eyre::bail!("Invalid signature"); + eyre::bail!("invalid function signature"); }; let num_threads = std::thread::available_parallelism().map_or(1, |n| n.get()); @@ -1980,12 +1983,9 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// fn main() -> eyre::Result<()> { /// let tx = "0x02f8f582a86a82058d8459682f008508351050808303fd84948e42f2f4101563bf679975178e880fd87d3efd4e80b884659ac74b00000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000000000000000000000000000000000000007ff4e20000000000000000000000000000000000000000000000000000000000000064c001a05d429597befe2835396206781b199122f2e8297327ed4a05483339e7a8b2022aa04c23a7f70fb29dda1b4ee342fb10a625e9b8ddc6a603fb4e170d4f6f37700cb8"; /// let (tx, sig) = Cast::decode_raw_transaction(&tx)?; - /// - /// Ok(()) - /// } + /// # Ok::<(), eyre::Report>(()) pub fn decode_raw_transaction(tx: &str) -> Result<(TypedTransaction, Signature)> { let tx_hex = hex::decode(strip_0x(tx))?; let tx_rlp = rlp::Rlp::new(tx_hex.as_slice()); @@ -2004,15 +2004,12 @@ mod tests { #[test] fn simple_selector() { - assert_eq!("0xc2985578", Cast::get_selector("foo()", None).unwrap().0.as_str()) + assert_eq!("0xc2985578", Cast::get_selector("foo()", 0).unwrap().0.as_str()) } #[test] fn selector_with_arg() { - assert_eq!( - "0xbd0d639f", - Cast::get_selector("foo(address,uint256)", None).unwrap().0.as_str() - ) + assert_eq!("0xbd0d639f", Cast::get_selector("foo(address,uint256)", 0).unwrap().0.as_str()) } #[test] diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs index 2b376edff4225..65b1b7e087015 100644 --- a/crates/cast/src/tx.rs +++ b/crates/cast/src/tx.rs @@ -26,17 +26,18 @@ pub type TxBuilderPeekOutput<'a> = (&'a TypedTransaction, &'a Option); /// Transaction builder /// ``` -/// async fn foo() -> eyre::Result<()> { -/// use ethers_core::types::Chain; -/// use alloy_primitives::U256; -/// use cast::TxBuilder; -/// let provider = ethers_providers::test_provider::MAINNET.provider(); -/// let mut builder = TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await?; -/// builder -/// .gas(Some(U256::from(1))); -/// let (tx, _) = builder.build(); -/// Ok(()) -/// } +/// # async fn foo() -> eyre::Result<()> { +/// use alloy_primitives::U256; +/// use cast::TxBuilder; +/// use ethers_core::types::Chain; +/// +/// let provider = ethers_providers::test_provider::MAINNET.provider(); +/// let mut builder = +/// TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await?; +/// builder.gas(Some(U256::from(1))); +/// let (tx, _) = builder.build(); +/// # Ok(()) +/// # } /// ``` impl<'a, M: Middleware> TxBuilder<'a, M> { /// Create a new TxBuilder diff --git a/crates/cheatcodes/src/impls/evm/fork.rs b/crates/cheatcodes/src/impls/evm/fork.rs index c4d7c410062a6..de722e7722bdc 100644 --- a/crates/cheatcodes/src/impls/evm/fork.rs +++ b/crates/cheatcodes/src/impls/evm/fork.rs @@ -222,7 +222,7 @@ impl Cheatcode for rpcCall { let Self { method, params } = self; let url = ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; - let provider = ProviderBuilder::new(url).build()?; + let provider = ProviderBuilder::new(&url).build()?; let params_json: serde_json::Value = serde_json::from_str(params)?; let result = RuntimeOrHandle::new() @@ -250,7 +250,7 @@ impl Cheatcode for eth_getLogsCall { let url = ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; - let provider = ProviderBuilder::new(url).build()?; + let provider = ProviderBuilder::new(&url).build()?; let mut filter = Filter::new().address(addr.to_ethers()).from_block(from_block).to_block(to_block); for (i, topic) in topics.iter().enumerate() { diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index c7917f761bc37..955fa80ad99bd 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -1,26 +1,24 @@ -//! ABI related helper functions +//! ABI related helper functions. + use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{AbiItem, Event, Function}; -use alloy_primitives::{hex, Address, Log, U256}; +use alloy_primitives::{hex, Address, Log}; use ethers_core::types::Chain; use eyre::{ContextCompat, Result}; use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; use std::{future::Future, pin::Pin}; -use yansi::Paint; - -use crate::calc::to_exponential_notation; /// Given a function and a vector of string arguments, it proceeds to convert the args to alloy /// [DynSolValue]s and then ABI encode them. -pub fn encode_function_args(func: &Function, args: &[impl AsRef]) -> Result> { - let params: Result> = func - .inputs - .iter() - .zip(args) - .map(|(input, arg)| (input.selector_type().clone(), arg.as_ref())) - .map(|(ty, arg)| coerce_value(&ty, arg)) - .collect(); - Ok(func.abi_encode_input(params?.as_slice())?) +pub fn encode_function_args(func: &Function, args: I) -> Result> +where + I: IntoIterator, + S: AsRef, +{ + let params = std::iter::zip(&func.inputs, args) + .map(|(input, arg)| coerce_value(&input.selector_type(), arg.as_ref())) + .collect::>>()?; + func.abi_encode_input(params.as_slice()).map_err(Into::into) } /// Decodes the calldata of the function @@ -32,16 +30,18 @@ pub fn abi_decode_calldata( ) -> Result> { let func = Function::parse(sig)?; let calldata = hex::decode(calldata)?; + + let mut calldata = calldata.as_slice(); + // If function selector is prefixed in "calldata", remove it (first 4 bytes) + if input && fn_selector && calldata.len() >= 4 { + calldata = &calldata[4..]; + } + let res = if input { - // If function selector is prefixed in "calldata", remove it (first 4 bytes) - if fn_selector { - func.abi_decode_input(&calldata[4..], false)? - } else { - func.abi_decode_input(&calldata, false)? - } + func.abi_decode_input(calldata, false) } else { - func.abi_decode_output(&calldata, false)? - }; + func.abi_decode_output(calldata, false) + }?; // in case the decoding worked but nothing was decoded if res.is_empty() { @@ -51,95 +51,6 @@ pub fn abi_decode_calldata( Ok(res) } -/// Parses string input as Token against the expected ParamType -pub fn parse_tokens<'a, I: IntoIterator>( - params: I, -) -> Result> { - let mut tokens = Vec::new(); - - for (param, value) in params.into_iter() { - let token = DynSolType::coerce_str(param, value)?; - tokens.push(token); - } - Ok(tokens) -} - -/// Pretty print a slice of tokens. -pub fn format_tokens(tokens: &[DynSolValue]) -> impl Iterator + '_ { - tokens.iter().map(format_token) -} - -/// Gets pretty print strings for tokens -pub fn format_token(param: &DynSolValue) -> String { - match param { - DynSolValue::Address(addr) => addr.to_checksum(None), - DynSolValue::FixedBytes(bytes, _) => hex::encode_prefixed(bytes), - DynSolValue::Bytes(bytes) => hex::encode_prefixed(bytes), - DynSolValue::Int(num, _) => format!("{}", num), - DynSolValue::Uint(num, _) => format_uint_with_exponential_notation_hint(*num), - DynSolValue::Bool(b) => format!("{b}"), - DynSolValue::String(s) => s.to_string(), - DynSolValue::FixedArray(tokens) => { - let string = tokens.iter().map(format_token).collect::>().join(", "); - format!("[{string}]") - } - DynSolValue::Array(tokens) => { - let string = tokens.iter().map(format_token).collect::>().join(", "); - format!("[{string}]") - } - DynSolValue::Tuple(tokens) => { - let string = tokens.iter().map(format_token).collect::>().join(", "); - format!("({string})") - } - DynSolValue::CustomStruct { name: _, prop_names: _, tuple } => { - let string = tuple.iter().map(format_token).collect::>().join(", "); - format!("({string})") - } - DynSolValue::Function(f) => { - format!("{}", f.to_address_and_selector().1) - } - } -} - -/// Gets pretty print strings for tokens, without adding -/// exponential notation hints for large numbers (e.g. [1e7] for 10000000) -pub fn format_token_raw(param: &DynSolValue) -> String { - match param { - DynSolValue::Uint(num, _) => format!("{}", num), - DynSolValue::FixedArray(tokens) | DynSolValue::Array(tokens) => { - let string = tokens.iter().map(format_token_raw).collect::>().join(", "); - format!("[{string}]") - } - DynSolValue::Tuple(tokens) => { - let string = tokens.iter().map(format_token_raw).collect::>().join(", "); - format!("({string})") - } - _ => format_token(param), - } -} - -/// Formats a U256 number to string, adding an exponential notation _hint_ if it -/// is larger than `10_000`, with a precision of `4` figures, and trimming the -/// trailing zeros. -/// -/// Examples: -/// -/// ```text -/// 0 -> "0" -/// 1234 -> "1234" -/// 1234567890 -> "1234567890 [1.234e9]" -/// 1000000000000000000 -> "1000000000000000000 [1e18]" -/// 10000000000000000000000 -> "10000000000000000000000 [1e22]" -/// ``` -pub fn format_uint_with_exponential_notation_hint(num: U256) -> String { - if num.lt(&U256::from(10_000)) { - return num.to_string() - } - - let exp = to_exponential_notation(num, 4, true); - format!("{} {}", num, Paint::default(format!("[{}]", exp)).dimmed()) -} - /// Helper trait for converting types to Functions. Helpful for allowing the `call` /// function on the EVM to be generic over `String`, `&str` and `Function`. pub trait IntoFunction { @@ -281,11 +192,9 @@ fn coerce_value(ty: &str, arg: &str) -> Result { #[cfg(test)] mod tests { - use std::str::FromStr; - use super::*; use alloy_dyn_abi::EventExt; - use alloy_primitives::B256; + use alloy_primitives::{B256, U256}; #[test] fn test_get_func() { @@ -308,19 +217,6 @@ mod tests { assert_eq!(func.outputs[0].ty, "bytes4"); } - #[test] - fn parse_hex_uint_tokens() { - let param = DynSolType::Uint(256); - - let tokens = parse_tokens(std::iter::once((¶m, "100"))).unwrap(); - assert_eq!(tokens, vec![DynSolValue::Uint(U256::from(100), 256)]); - - let val: U256 = U256::from(100u64); - let hex_val = format!("0x{val:x}"); - let tokens = parse_tokens(std::iter::once((¶m, hex_val.as_str()))).unwrap(); - assert_eq!(tokens, vec![DynSolValue::Uint(U256::from(100), 256)]); - } - #[test] fn test_indexed_only_address() { let event = get_event("event Ev(address,uint256,address)").unwrap(); @@ -365,23 +261,4 @@ mod tests { assert_eq!(parsed.indexed[1], DynSolValue::Uint(U256::from_be_bytes([3; 32]), 256)); assert_eq!(parsed.indexed[2], DynSolValue::Address(Address::from_word(param2))); } - - #[test] - fn test_format_token_addr() { - // copied from testcases in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md - let eip55 = "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"; - assert_eq!( - format_token(&DynSolValue::Address(Address::from_str(&eip55.to_lowercase()).unwrap())), - eip55.to_string() - ); - - // copied from testcases in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md - let eip1191 = "0xFb6916095cA1Df60bb79ce92cE3EA74c37c5d359"; - assert_ne!( - format_token(&DynSolValue::Address( - Address::from_str(&eip1191.to_lowercase()).unwrap() - )), - eip1191.to_string() - ); - } } diff --git a/crates/common/src/calc.rs b/crates/common/src/calc.rs index 848c4c6129520..2383e346f7d76 100644 --- a/crates/common/src/calc.rs +++ b/crates/common/src/calc.rs @@ -44,7 +44,7 @@ pub fn median_sorted(values: &[U256]) -> U256 { /// 10000000 -> 1e7 /// ``` #[inline] -pub fn to_exponential_notation(value: U256, precision: usize, trim_end_zeros: bool) -> String { +pub fn to_exp_notation(value: U256, precision: usize, trim_end_zeros: bool) -> String { let stringified = value.to_string(); let exponent = stringified.len() - 1; let mut mantissa = stringified.chars().take(precision).collect::(); @@ -61,7 +61,7 @@ pub fn to_exponential_notation(value: U256, precision: usize, trim_end_zeros: bo mantissa.insert(1, '.'); } - format!("{}e{}", mantissa, exponent) + format!("{mantissa}e{exponent}") } #[cfg(test)] @@ -119,18 +119,18 @@ mod tests { fn test_format_to_exponential_notation() { let value = 1234124124u64; - let formatted = to_exponential_notation(U256::from(value), 4, false); + let formatted = to_exp_notation(U256::from(value), 4, false); assert_eq!(formatted, "1.234e9"); - let formatted = to_exponential_notation(U256::from(value), 3, true); + let formatted = to_exp_notation(U256::from(value), 3, true); assert_eq!(formatted, "1.23e9"); let value = 10000000u64; - let formatted = to_exponential_notation(U256::from(value), 4, false); + let formatted = to_exp_notation(U256::from(value), 4, false); assert_eq!(formatted, "1.000e7"); - let formatted = to_exponential_notation(U256::from(value), 3, true); + let formatted = to_exp_notation(U256::from(value), 3, true); assert_eq!(formatted, "1e7"); } } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index a990035244d33..83ab7bc1ab446 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -82,7 +82,8 @@ impl ProjectCompiler { /// use foundry_common::compile::ProjectCompiler; /// let config = foundry_config::Config::load(); /// ProjectCompiler::default() - /// .compile_with(&config.project().unwrap(), |prj| Ok(prj.compile()?)).unwrap(); + /// .compile_with(&config.project().unwrap(), |prj| Ok(prj.compile()?)) + /// .unwrap(); /// ``` #[tracing::instrument(target = "forge::compile", skip_all)] pub fn compile_with(self, project: &Project, f: F) -> Result diff --git a/crates/common/src/fmt.rs b/crates/common/src/fmt.rs index 67eac0e6f49f2..ca7bc272f4add 100644 --- a/crates/common/src/fmt.rs +++ b/crates/common/src/fmt.rs @@ -1,9 +1,164 @@ //! Helpers for formatting ethereum types -use crate::TransactionReceiptWithRevertReason; +use crate::{calc::to_exp_notation, TransactionReceiptWithRevertReason}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_primitives::{hex, U256}; +use eyre::Result; +use std::fmt::{self, Display}; +use yansi::Paint; pub use foundry_macros::fmt::*; +/// [`DynSolValue`] formatter. +struct DynValueFormatter { + raw: bool, +} + +impl DynValueFormatter { + /// Recursively formats a [`DynSolValue`]. + fn value(&self, value: &DynSolValue, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match value { + DynSolValue::Address(inner) => Display::fmt(inner, f), + DynSolValue::Function(inner) => Display::fmt(inner, f), + DynSolValue::Bytes(inner) => f.write_str(&hex::encode_prefixed(inner)), + DynSolValue::FixedBytes(inner, _) => f.write_str(&hex::encode_prefixed(inner)), + DynSolValue::Uint(inner, _) => { + if self.raw { + write!(f, "{inner}") + } else { + f.write_str(&format_uint_exp(*inner)) + } + } + DynSolValue::Int(inner, _) => write!(f, "{inner}"), + DynSolValue::Array(values) | DynSolValue::FixedArray(values) => { + f.write_str("[")?; + self.list(values, f)?; + f.write_str("]") + } + DynSolValue::Tuple(values) => self.tuple(values, f), + DynSolValue::String(inner) => f.write_str(inner), + DynSolValue::Bool(inner) => Display::fmt(inner, f), + DynSolValue::CustomStruct { name, prop_names, tuple } => { + if self.raw { + return self.tuple(tuple, f); + } + + f.write_str(name)?; + f.write_str(" { ")?; + + for (i, (prop_name, value)) in std::iter::zip(prop_names, tuple).enumerate() { + if i > 0 { + f.write_str(", ")?; + } + f.write_str(prop_name)?; + f.write_str(": ")?; + self.value(value, f)?; + } + + f.write_str(" }") + } + } + } + + /// Recursively formats a comma-separated list of [`DynSolValue`]s. + fn list(&self, values: &[DynSolValue], f: &mut fmt::Formatter<'_>) -> fmt::Result { + for (i, value) in values.iter().enumerate() { + if i > 0 { + f.write_str(", ")?; + } + self.value(value, f)?; + } + Ok(()) + } + + /// Formats the given values as a tuple. + fn tuple(&self, values: &[DynSolValue], f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("(")?; + self.list(values, f)?; + f.write_str(")") + } +} + +/// Wrapper that implements [`Display`] for a [`DynSolValue`]. +struct DynValueDisplay<'a> { + /// The value to display. + value: &'a DynSolValue, + /// The formatter. + formatter: DynValueFormatter, +} + +impl<'a> DynValueDisplay<'a> { + /// Creates a new [`Display`] wrapper for the given value. + #[inline] + fn new(value: &'a DynSolValue, raw: bool) -> Self { + Self { value, formatter: DynValueFormatter { raw } } + } +} + +impl fmt::Display for DynValueDisplay<'_> { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.formatter.value(self.value, f) + } +} + +/// Parses string input as Token against the expected ParamType +pub fn parse_tokens<'a, I: IntoIterator>( + params: I, +) -> Result> { + let mut tokens = Vec::new(); + for (param, value) in params { + let token = DynSolType::coerce_str(param, value)?; + tokens.push(token); + } + Ok(tokens) +} + +/// Pretty-prints a slice of tokens using [`format_token`]. +pub fn format_tokens(tokens: &[DynSolValue]) -> impl Iterator + '_ { + tokens.iter().map(format_token) +} + +/// Pretty-prints the given value into a string suitable for user output. +pub fn format_token(value: &DynSolValue) -> String { + DynValueDisplay::new(value, false).to_string() +} + +/// Pretty-prints the given value into a string suitable for re-parsing as values later. +/// +/// This means: +/// - integers are not formatted with exponential notation hints +/// - structs are formatted as tuples, losing the struct and property names +pub fn format_token_raw(value: &DynSolValue) -> String { + DynValueDisplay::new(value, true).to_string() +} + +/// Formats a U256 number to string, adding an exponential notation _hint_ if it +/// is larger than `10_000`, with a precision of `4` figures, and trimming the +/// trailing zeros. +/// +/// # Examples +/// +/// ``` +/// use alloy_primitives::U256; +/// use foundry_common::fmt::format_uint_exp as f; +/// +/// yansi::Paint::disable(); +/// assert_eq!(f(U256::from(0)), "0"); +/// assert_eq!(f(U256::from(1234)), "1234"); +/// assert_eq!(f(U256::from(1234567890)), "1234567890 [1.234e9]"); +/// assert_eq!(f(U256::from(1000000000000000000_u128)), "1000000000000000000 [1e18]"); +/// assert_eq!(f(U256::from(10000000000000000000000_u128)), "10000000000000000000000 [1e22]"); +/// ``` +pub fn format_uint_exp(num: U256) -> String { + if num < U256::from(10_000) { + return num.to_string() + } + + let exp = to_exp_notation(num, 4, true); + format!("{} {}", num, Paint::default(format!("[{exp}]")).dimmed()) +} + impl UIfmt for TransactionReceiptWithRevertReason { fn pretty(&self) -> String { if let Some(revert_reason) = &self.revert_reason { @@ -48,3 +203,41 @@ pub fn get_pretty_tx_receipt_attr( _ => None, } } + +#[cfg(test)] +mod tests { + use super::*; + use alloy_primitives::address; + + #[test] + fn parse_hex_uint() { + let ty = DynSolType::Uint(256); + + let values = parse_tokens(std::iter::once((&ty, "100"))).unwrap(); + assert_eq!(values, [DynSolValue::Uint(U256::from(100), 256)]); + + let val: U256 = U256::from(100u64); + let hex_val = format!("0x{val:x}"); + let values = parse_tokens(std::iter::once((&ty, hex_val.as_str()))).unwrap(); + assert_eq!(values, [DynSolValue::Uint(U256::from(100), 256)]); + } + + #[test] + fn format_addr() { + // copied from testcases in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md + assert_eq!( + format_token(&DynSolValue::Address(address!( + "5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed" + ))), + "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed", + ); + + // copied from testcases in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md + assert_ne!( + format_token(&DynSolValue::Address(address!( + "Fb6916095cA1Df60bb79ce92cE3EA74c37c5d359" + ))), + "0xFb6916095cA1Df60bb79ce92cE3EA74c37c5d359" + ); + } +} diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index 7695260d9b4e6..79bae27c98c88 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -4,11 +4,9 @@ use crate::{runtime_client::RuntimeClient, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEO use ethers_core::types::{Chain, U256}; use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use ethers_providers::{is_local_endpoint, Middleware, Provider, DEFAULT_LOCAL_POLL_INTERVAL}; -use eyre::WrapErr; -use reqwest::{IntoUrl, Url}; +use eyre::{Result, WrapErr}; +use reqwest::Url; use std::{ - borrow::Cow, - env, path::{Path, PathBuf}, time::Duration, }; @@ -20,35 +18,40 @@ pub type RetryProvider = Provider; /// Helper type alias for a rpc url pub type RpcUrl = String; -/// Same as `try_get_http_provider` +/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely +/// an anvil or other dev node) and with the default, or 7 second otherwise. +/// +/// See [`try_get_http_provider`] for more details. /// /// # Panics /// -/// If invalid URL +/// Panics if the URL is invalid. /// -/// # Example +/// # Examples /// /// ``` /// use foundry_common::get_http_provider; -/// # fn f() { -/// let retry_provider = get_http_provider("http://localhost:8545"); -/// # } +/// +/// let retry_provider = get_http_provider("http://localhost:8545"); /// ``` -pub fn get_http_provider(builder: impl Into) -> RetryProvider { +#[inline] +#[track_caller] +pub fn get_http_provider(builder: impl AsRef) -> RetryProvider { try_get_http_provider(builder).unwrap() } -/// Gives out a provider with a `100ms` interval poll if it's a localhost URL (most likely an anvil -/// or other dev node) and with the default, `7s` if otherwise. -pub fn try_get_http_provider(builder: impl Into) -> eyre::Result { - builder.into().build() +/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely +/// an anvil or other dev node) and with the default, or 7 second otherwise. +#[inline] +pub fn try_get_http_provider(builder: impl AsRef) -> Result { + ProviderBuilder::new(builder.as_ref()).build() } /// Helper type to construct a `RetryProvider` #[derive(Debug)] pub struct ProviderBuilder { // Note: this is a result, so we can easily chain builder calls - url: eyre::Result, + url: Result, chain: Chain, max_retry: u32, timeout_retry: u32, @@ -64,12 +67,16 @@ pub struct ProviderBuilder { impl ProviderBuilder { /// Creates a new builder instance - pub fn new(url: impl IntoUrl) -> Self { - let url_str = url.as_str(); + pub fn new(url_str: &str) -> Self { + // a copy is needed for the next lines to work + let mut url_str = url_str; + + // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http + // prefix + let storage; if url_str.starts_with("localhost:") { - // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http - // prefix - return Self::new(format!("http://{url_str}")) + storage = format!("http://{url_str}"); + url_str = storage.as_str(); } let url = Url::parse(url_str) @@ -78,20 +85,14 @@ impl ProviderBuilder { let path = Path::new(url_str); if let Ok(path) = resolve_path(path) { - Url::parse( - format!( - "file://{path_str}", - path_str = path.to_str().expect("Should be valid string") - ) - .as_str(), - ) + Url::parse(&format!("file://{}", path.display())) } else { Err(err) } } _ => Err(err), }) - .wrap_err(format!("Invalid provider url: {url_str}")); + .wrap_err_with(|| format!("invalid provider URL: {url_str:?}")); Self { url, @@ -175,8 +176,8 @@ impl ProviderBuilder { } /// Same as [`Self:build()`] but also retrieves the `chainId` in order to derive an appropriate - /// interval - pub async fn connect(self) -> eyre::Result { + /// interval. + pub async fn connect(self) -> Result { let mut provider = self.build()?; if let Some(blocktime) = provider.get_chainid().await.ok().and_then(|id| { Chain::try_from(id).ok().and_then(|chain| chain.average_blocktime_hint()) @@ -186,8 +187,8 @@ impl ProviderBuilder { Ok(provider) } - /// Constructs the `RetryProvider` taking all configs into account - pub fn build(self) -> eyre::Result { + /// Constructs the `RetryProvider` taking all configs into account. + pub fn build(self) -> Result { let ProviderBuilder { url, chain, @@ -200,8 +201,10 @@ impl ProviderBuilder { } = self; let url = url?; + let is_local = is_local_endpoint(url.as_str()); + let mut provider = Provider::new(RuntimeClient::new( - url.clone(), + url, max_retry, timeout_retry, initial_backoff, @@ -210,38 +213,13 @@ impl ProviderBuilder { jwt, )); - let is_local = is_local_endpoint(url.as_str()); - if is_local { provider = provider.interval(DEFAULT_LOCAL_POLL_INTERVAL); } else if let Some(blocktime) = chain.average_blocktime_hint() { provider = provider.interval(blocktime / 2); } - Ok(provider) - } -} - -impl<'a> From<&'a str> for ProviderBuilder { - fn from(url: &'a str) -> Self { - Self::new(url) - } -} - -impl<'a> From<&'a String> for ProviderBuilder { - fn from(url: &'a String) -> Self { - url.as_str().into() - } -} - -impl From for ProviderBuilder { - fn from(url: String) -> Self { - url.as_str().into() - } -} -impl<'a> From> for ProviderBuilder { - fn from(url: Cow<'a, str>) -> Self { - url.as_ref().into() + Ok(provider) } } @@ -254,7 +232,7 @@ impl<'a> From> for ProviderBuilder { pub async fn estimate_eip1559_fees( provider: &M, chain: Option, -) -> eyre::Result<(U256, U256)> +) -> Result<(U256, U256)> where M::Error: 'static, { @@ -282,21 +260,18 @@ fn resolve_path(path: &Path) -> Result { if path.is_absolute() { Ok(path.to_path_buf()) } else { - Ok(env::current_dir() - .map(|current_dir| current_dir.join(path)) - .expect("Current directory should exist")) + std::env::current_dir().map(|d| d.join(path)).map_err(drop) } } #[cfg(windows)] fn resolve_path(path: &Path) -> Result { - let path_str = path.to_str().expect("Path should be a valid string"); - - if path_str.starts_with(r"\\.\pipe\") { - Ok(PathBuf::from(path_str)) - } else { - Err(()) + if let Some(s) = path.to_str() { + if s.starts_with(r"\\.\pipe\") { + return Ok(path.to_path_buf()); + } } + Err(()) } #[cfg(test)] diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index a1220b6b6a800..42cb03c87444b 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -241,12 +241,17 @@ impl SignEthClient { /// Pretty print calldata and if available, fetch possible function signatures /// /// ```no_run - /// /// use foundry_common::selectors::SignEthClient; /// /// # async fn foo() -> eyre::Result<()> { - /// let pretty_data = SignEthClient::new()?.pretty_calldata("0x70a08231000000000000000000000000d0074f4e6490ae3f888d1d4f7e3e43326bd3f0f5".to_string(), false).await?; - /// println!("{}",pretty_data); + /// let pretty_data = SignEthClient::new()? + /// .pretty_calldata( + /// "0x70a08231000000000000000000000000d0074f4e6490ae3f888d1d4f7e3e43326bd3f0f5" + /// .to_string(), + /// false, + /// ) + /// .await?; + /// println!("{}", pretty_data); /// # Ok(()) /// # } /// ``` @@ -388,12 +393,15 @@ pub async fn decode_event_topic(topic: &str) -> eyre::Result> { /// Pretty print calldata and if available, fetch possible function signatures /// /// ```no_run -/// /// use foundry_common::selectors::pretty_calldata; /// /// # async fn foo() -> eyre::Result<()> { -/// let pretty_data = pretty_calldata("0x70a08231000000000000000000000000d0074f4e6490ae3f888d1d4f7e3e43326bd3f0f5".to_string(), false).await?; -/// println!("{}",pretty_data); +/// let pretty_data = pretty_calldata( +/// "0x70a08231000000000000000000000000d0074f4e6490ae3f888d1d4f7e3e43326bd3f0f5".to_string(), +/// false, +/// ) +/// .await?; +/// println!("{}", pretty_data); /// # Ok(()) /// # } /// ``` diff --git a/crates/common/src/units.rs b/crates/common/src/units.rs index 937c954988534..3a85ba3e04b19 100644 --- a/crates/common/src/units.rs +++ b/crates/common/src/units.rs @@ -1,7 +1,7 @@ //! Unit conversion utilities. use alloy_primitives::{Address, ParseSignedError, I256, U256}; -use std::{convert::TryFrom, fmt, str::FromStr}; +use std::{fmt, str::FromStr}; use thiserror::Error; /// I256 overflows for numbers wider than 77 units. diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index 7402ce6de0e0c..1b8de84d12245 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -82,25 +82,21 @@ where Ok(()) } - /// Given a list of `config_lines, returns all available pairs (key, value) - /// matching the current config key + /// Given a list of config lines, returns all available pairs (key, value) matching the current + /// config key. /// - /// i.e. Given the `invariant` config key and a vector of config lines - /// ```rust - /// let _config_lines = vec![ - /// "forge-config: default.invariant.runs = 500", - /// "forge-config: default.invariant.depth = 500", - /// "forge-config: ci.invariant.depth = 500", - /// "forge-config: ci.fuzz.runs = 10" - /// ]; - /// ``` - /// would return the whole set of `invariant` configs. - /// ```rust - /// let _result = vec![ - /// ("runs", "500"), - /// ("depth", "500"), - /// ("depth", "500"), - /// ]; + /// # Examples + /// + /// ```ignore + /// assert_eq!( + /// get_config_overrides(&[ + /// "forge-config: default.invariant.runs = 500", + /// "forge-config: default.invariant.depth = 500", + /// "forge-config: ci.invariant.depth = 500", + /// "forge-config: ci.fuzz.runs = 10", + /// ]), + /// [("runs", "500"), ("depth", "500"), ("depth", "500")] + /// ); /// ``` fn get_config_overrides(config_lines: &[String]) -> Vec<(String, String)> { let mut result: Vec<(String, String)> = vec![]; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 04598261086c3..8515f6df2f4ee 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -374,13 +374,10 @@ pub struct Config { /// PRIVATE: This structure may grow, As such, constructing this structure should /// _always_ be done using a public constructor or update syntax: /// - /// ```rust + /// ```ignore /// use foundry_config::Config; /// - /// let config = Config { - /// src: "other".into(), - /// ..Default::default() - /// }; + /// let config = Config { src: "other".into(), ..Default::default() }; /// ``` #[doc(hidden)] #[serde(skip)] @@ -448,13 +445,12 @@ impl Config { /// # Example /// /// ```no_run + /// use figment::providers::{Env, Format, Toml}; /// use foundry_config::Config; - /// use figment::providers::{Toml, Format, Env}; /// /// // Use foundry's default `Figment`, but allow values from `other.toml` /// // to supersede its values. - /// let figment = Config::figment() - /// .merge(Toml::file("other.toml").nested()); + /// let figment = Config::figment().merge(Toml::file("other.toml").nested()); /// /// let config = Config::from_provider(figment); /// ``` @@ -469,13 +465,12 @@ impl Config { /// # Example /// /// ```rust + /// use figment::providers::{Env, Format, Toml}; /// use foundry_config::Config; - /// use figment::providers::{Toml, Format, Env}; /// /// // Use foundry's default `Figment`, but allow values from `other.toml` /// // to supersede its values. - /// let figment = Config::figment() - /// .merge(Toml::file("other.toml").nested()); + /// let figment = Config::figment().merge(Toml::file("other.toml").nested()); /// /// let config = Config::try_from(figment); /// ``` @@ -777,11 +772,10 @@ impl Config { /// # Example /// /// ``` - /// /// use foundry_config::Config; /// # fn t() { - /// let config = Config::with_root("./"); - /// let rpc_jwt = config.get_rpc_jwt_secret().unwrap().unwrap(); + /// let config = Config::with_root("./"); + /// let rpc_jwt = config.get_rpc_jwt_secret().unwrap().unwrap(); /// # } /// ``` pub fn get_rpc_jwt_secret(&self) -> Result>, UnresolvedEnvVarError> { @@ -797,11 +791,10 @@ impl Config { /// # Example /// /// ``` - /// /// use foundry_config::Config; /// # fn t() { - /// let config = Config::with_root("./"); - /// let rpc_url = config.get_rpc_url().unwrap().unwrap(); + /// let config = Config::with_root("./"); + /// let rpc_url = config.get_rpc_url().unwrap().unwrap(); /// # } /// ``` pub fn get_rpc_url(&self) -> Option, UnresolvedEnvVarError>> { @@ -822,11 +815,10 @@ impl Config { /// # Example /// /// ``` - /// /// use foundry_config::Config; /// # fn t() { - /// let config = Config::with_root("./"); - /// let rpc_url = config.get_rpc_url_with_alias("mainnet").unwrap().unwrap(); + /// let config = Config::with_root("./"); + /// let rpc_url = config.get_rpc_url_with_alias("mainnet").unwrap().unwrap(); /// # } /// ``` pub fn get_rpc_url_with_alias( @@ -842,11 +834,10 @@ impl Config { /// # Example /// /// ``` - /// /// use foundry_config::Config; /// # fn t() { - /// let config = Config::with_root("./"); - /// let rpc_url = config.get_rpc_url_or("http://localhost:8545").unwrap(); + /// let config = Config::with_root("./"); + /// let rpc_url = config.get_rpc_url_or("http://localhost:8545").unwrap(); /// # } /// ``` pub fn get_rpc_url_or<'a>( @@ -865,11 +856,10 @@ impl Config { /// # Example /// /// ``` - /// /// use foundry_config::Config; /// # fn t() { - /// let config = Config::with_root("./"); - /// let rpc_url = config.get_rpc_url_or_localhost_http().unwrap(); + /// let config = Config::with_root("./"); + /// let rpc_url = config.get_rpc_url_or_localhost_http().unwrap(); /// # } /// ``` pub fn get_rpc_url_or_localhost_http(&self) -> Result, UnresolvedEnvVarError> { @@ -886,12 +876,11 @@ impl Config { /// # Example /// /// ``` - /// /// use foundry_config::Config; /// # fn t() { - /// let config = Config::with_root("./"); - /// let etherscan_config = config.get_etherscan_config().unwrap().unwrap(); - /// let client = etherscan_config.into_client().unwrap(); + /// let config = Config::with_root("./"); + /// let etherscan_config = config.get_etherscan_config().unwrap().unwrap(); + /// let client = etherscan_config.into_client().unwrap(); /// # } /// ``` pub fn get_etherscan_config( @@ -2453,7 +2442,7 @@ impl ProviderExt for P {} /// # Example /// /// ```rust -/// use foundry_config::{Config, BasicConfig}; +/// use foundry_config::{BasicConfig, Config}; /// use serde::Deserialize; /// /// let my_config = Config::figment().extract::(); diff --git a/crates/config/src/macros.rs b/crates/config/src/macros.rs index eaf7ae7a52950..4bd501354f113 100644 --- a/crates/config/src/macros.rs +++ b/crates/config/src/macros.rs @@ -121,10 +121,11 @@ macro_rules! impl_figment_convert { /// Merge several nested `Provider` together with the type itself /// /// ```rust +/// use foundry_config::{ +/// figment::{value::*, *}, +/// impl_figment_convert, merge_impl_figment_convert, Config, +/// }; /// use std::path::PathBuf; -/// use foundry_config::{Config, merge_impl_figment_convert, impl_figment_convert}; -/// use foundry_config::figment::*; -/// use foundry_config::figment::value::*; /// /// #[derive(Default)] /// struct MyArgs { @@ -137,7 +138,7 @@ macro_rules! impl_figment_convert { /// } /// /// fn data(&self) -> Result, Error> { -/// todo!() +/// todo!() /// } /// } /// @@ -146,7 +147,7 @@ macro_rules! impl_figment_convert { /// #[derive(Default)] /// struct OuterArgs { /// value: u64, -/// inner: MyArgs +/// inner: MyArgs, /// } /// /// impl Provider for OuterArgs { @@ -155,7 +156,7 @@ macro_rules! impl_figment_convert { /// } /// /// fn data(&self) -> Result, Error> { -/// todo!() +/// todo!() /// } /// } /// diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 7e3af7a217ae4..1d941d94e359e 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -7,7 +7,7 @@ use alloy_primitives::{B256, U256}; use alloy_sol_types::{sol_data::String as SolString, SolType}; use ethers::{abi::RawLog, contract::EthLogDecode, types::Log}; use foundry_abi::console::ConsoleEvents::{self, *}; -use foundry_common::{abi::format_token, SELECTOR_LEN}; +use foundry_common::{fmt::format_token, SELECTOR_LEN}; use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; use itertools::Itertools; use once_cell::sync::Lazy; @@ -205,7 +205,7 @@ pub fn decode_revert( { let inputs = decoded .iter() - .map(foundry_common::abi::format_token) + .map(foundry_common::fmt::format_token) .collect::>() .join(", "); return Ok(format!("{}({inputs})", abi_error.name)) diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index ae95e16b8e895..b4bb0eb2106e7 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -92,7 +92,7 @@ impl BaseCounterExample { impl fmt::Display for BaseCounterExample { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let args = foundry_common::abi::format_tokens(&self.args).collect::>().join(", "); + let args = foundry_common::fmt::format_tokens(&self.args).collect::>().join(", "); if let Some(sender) = self.sender { write!(f, "sender={sender} addr=")? diff --git a/crates/evm/traces/src/utils.rs b/crates/evm/traces/src/utils.rs index d5361491d0b52..c046fe5d6c16f 100644 --- a/crates/evm/traces/src/utils.rs +++ b/crates/evm/traces/src/utils.rs @@ -3,7 +3,7 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::Address; -use foundry_common::{abi::format_token, SELECTOR_LEN}; +use foundry_common::{fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::decode; use std::collections::HashMap; diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 56c9886bfccd4..a418b9c7d93cd 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -17,7 +17,7 @@ use foundry_cli::{ opts::{CoreBuildArgs, EthereumOpts, EtherscanOpts, TransactionOpts}, utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; -use foundry_common::{abi::parse_tokens, compile, estimate_eip1559_fees}; +use foundry_common::{compile, estimate_eip1559_fees, fmt::parse_tokens}; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalized}; use foundry_utils::types::{ToAlloy, ToEthers}; use serde_json::json; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 48ec70fdcf410..e6f960ee8dcee 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -27,10 +27,11 @@ use forge::{ }; use foundry_cli::opts::MultiWallet; use foundry_common::{ - abi::{encode_function_args, format_token}, + abi::encode_function_args, contracts::get_contract_name, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, + fmt::format_token, shell, ContractsByArtifact, RpcUrl, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::{ diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 100d8c349ba5b..93002e1aec9b1 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -4,7 +4,7 @@ use alloy_json_abi::Function; use alloy_primitives::{Address, B256}; use ethers::{prelude::NameOrAddress, types::transaction::eip2718::TypedTransaction}; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{abi::format_token_raw, RpcUrl, SELECTOR_LEN}; +use foundry_common::{fmt::format_token_raw, RpcUrl, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder, utils::CallKind}; use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 295bcc4570909..57fdfeb9ab8bf 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -421,7 +421,7 @@ impl EtherscanVerificationProvider { }; let encoded_args = encode_function_args( &func, - &read_constructor_args_file(constructor_args_path.to_path_buf())?, + read_constructor_args_file(constructor_args_path.to_path_buf())?, )?; let encoded_args = hex::encode(encoded_args); return Ok(Some(encoded_args[8..].into())) diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index 4d6354558fa25..de56c69b6b82a 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -15,6 +15,3 @@ foundry-macros-impl = { path = "impl" } ethers-core.workspace = true serde.workspace = true serde_json.workspace = true - -alloy-primitives.workspace = true -alloy-dyn-abi.workspace = true diff --git a/crates/macros/src/fmt/mod.rs b/crates/macros/src/fmt/mod.rs index dada2b94e6a34..d6723bd897e7c 100644 --- a/crates/macros/src/fmt/mod.rs +++ b/crates/macros/src/fmt/mod.rs @@ -3,8 +3,5 @@ mod ui; pub use ui::*; -mod token; -pub use token::*; - mod console_fmt; pub use console_fmt::{console_format, ConsoleFmt, FormatSpec}; diff --git a/crates/macros/src/fmt/token.rs b/crates/macros/src/fmt/token.rs deleted file mode 100644 index 9853ec7ed9d2b..0000000000000 --- a/crates/macros/src/fmt/token.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! Formatting helpers for [`DynSolValue`]s. - -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::hex; -use std::{fmt, fmt::Write}; - -/// Wrapper that pretty formats a [DynSolValue] -pub struct TokenDisplay<'a>(pub &'a DynSolValue); - -impl fmt::Display for TokenDisplay<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt_token(f, self.0) - } -} - -/// Recursively formats an ABI token. -fn fmt_token(f: &mut fmt::Formatter, item: &DynSolValue) -> fmt::Result { - match item { - DynSolValue::Address(inner) => { - write!(f, "{}", inner.to_checksum(None)) - } - // add 0x - DynSolValue::Bytes(inner) => f.write_str(&hex::encode_prefixed(inner)), - DynSolValue::FixedBytes(inner, _) => f.write_str(&hex::encode_prefixed(inner)), - // print as decimal - DynSolValue::Uint(inner, _) => write!(f, "{inner}"), - DynSolValue::Int(inner, _) => write!(f, "{}", *inner), - DynSolValue::Array(tokens) | DynSolValue::FixedArray(tokens) => { - f.write_char('[')?; - let mut tokens = tokens.iter().peekable(); - while let Some(token) = tokens.next() { - fmt_token(f, token)?; - if tokens.peek().is_some() { - f.write_char(',')? - } - } - f.write_char(']') - } - DynSolValue::Tuple(tokens) => { - f.write_char('(')?; - let mut tokens = tokens.iter().peekable(); - while let Some(token) = tokens.next() { - fmt_token(f, token)?; - if tokens.peek().is_some() { - f.write_char(',')? - } - } - f.write_char(')') - } - DynSolValue::String(inner) => write!(f, "{:?}", inner), - DynSolValue::Bool(inner) => write!(f, "{}", inner), - _ => write!(f, "{item:?}"), - } -} diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index 79c552b5cc0a7..c193cb5d70be2 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -7,7 +7,7 @@ extern crate self as foundry_macros; pub mod fmt; -pub use fmt::{console_format, ConsoleFmt, FormatSpec, TokenDisplay, UIfmt}; +pub use fmt::{console_format, ConsoleFmt, FormatSpec, UIfmt}; #[doc(inline)] pub use foundry_macros_impl::{Cheatcode, ConsoleFmt}; diff --git a/rustfmt.toml b/rustfmt.toml index 3b4a88a3cd6f2..7fabf2c1de8f1 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -7,6 +7,8 @@ binop_separator = "Back" trailing_comma = "Vertical" trailing_semicolon = false use_field_init_shorthand = true +format_code_in_doc_comments = true +doc_comment_code_block_width = 100 # Ignore automatically-generated code. ignore = ["crates/abi/src/bindings"] From 9421571876c41668bd4ba71012c76afd5dc7604d Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 2 Nov 2023 10:04:09 -0400 Subject: [PATCH 0222/1963] refactor(cheatcode): use rate limit args in create fork cheatcode (#6193) * refactor(cheatcode): use rate limit args in create fork cheatcode (rebased) * chore: add cli opt for fork-retries * fmt * chore: update provider defaults --- crates/common/src/evm.rs | 7 +++++++ crates/common/src/provider.rs | 19 ++++++++++++++++--- crates/evm/core/src/fork/multi.rs | 23 ++++------------------- crates/evm/core/src/opts.rs | 3 +++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 5672057f5a3d6..743416981becf 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -55,6 +55,13 @@ pub struct EvmArgs { #[serde(skip_serializing_if = "Option::is_none")] pub fork_block_number: Option, + /// Number of retries. + /// + /// See --fork-url. + #[clap(long, requires = "fork_url", value_name = "RETRIES")] + #[serde(skip_serializing_if = "Option::is_none")] + pub fork_retries: Option, + /// Initial retry backoff on encountering errors. /// /// See --fork-url. diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index 79bae27c98c88..ecb313f4aa704 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -97,9 +97,9 @@ impl ProviderBuilder { Self { url, chain: Chain::Mainnet, - max_retry: 100, - timeout_retry: 5, - initial_backoff: 100, + max_retry: 8, + timeout_retry: 8, + initial_backoff: 800, timeout: REQUEST_TIMEOUT, // alchemy max cpus compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, @@ -132,6 +132,19 @@ impl ProviderBuilder { self } + /// How often to retry a failed request. If `None`, defaults to the already-set value. + pub fn maybe_max_retry(mut self, max_retry: Option) -> Self { + self.max_retry = max_retry.unwrap_or(self.max_retry); + self + } + + /// The starting backoff delay to use after the first failed request. If `None`, defaults to + /// the already-set value. + pub fn maybe_initial_backoff(mut self, initial_backoff: Option) -> Self { + self.initial_backoff = initial_backoff.unwrap_or(self.initial_backoff); + self + } + /// How often to retry a failed request due to connection issues pub fn timeout_retry(mut self, timeout_retry: u32) -> Self { self.timeout_retry = timeout_retry; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 4795634e5035e..0f5065b9e3e16 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -198,12 +198,6 @@ pub struct MultiForkHandler { /// All created Forks in order to reuse them forks: HashMap, - /// The retries to allow for new providers - retries: u32, - - /// Initial backoff delay for requests - backoff: u64, - /// Optional periodic interval to flush rpc cache flush_cache_interval: Option, } @@ -217,9 +211,6 @@ impl MultiForkHandler { handlers: Default::default(), pending_tasks: Default::default(), forks: Default::default(), - retries: 8, - // 800ms - backoff: 800, flush_cache_interval: None, } } @@ -258,10 +249,8 @@ impl MultiForkHandler { return } - let retries = self.retries; - let backoff = self.backoff; // need to create a new fork - let task = Box::pin(create_fork(fork, retries, backoff)); + let task = Box::pin(create_fork(fork)); self.pending_tasks.push(ForkTask::Create(task, fork_id, sender, Vec::new())); } } @@ -459,15 +448,11 @@ fn create_fork_id(url: &str, num: Option) -> ForkId { /// Creates a new fork /// /// This will establish a new `Provider` to the endpoint and return the Fork Backend -async fn create_fork( - mut fork: CreateFork, - retries: u32, - backoff: u64, -) -> eyre::Result<(CreatedFork, Handler)> { +async fn create_fork(mut fork: CreateFork) -> eyre::Result<(CreatedFork, Handler)> { let provider = Arc::new( ProviderBuilder::new(fork.url.as_str()) - .max_retry(retries) - .initial_backoff(backoff) + .maybe_max_retry(fork.evm_opts.fork_retries) + .maybe_initial_backoff(fork.evm_opts.fork_retry_backoff) .compute_units_per_second(fork.evm_opts.get_compute_units_per_second()) .build()?, ); diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index b3f2b1bd0b642..dc49699769d72 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -24,6 +24,9 @@ pub struct EvmOpts { /// pins the block number for the state fork pub fork_block_number: Option, + /// The number of retries + pub fork_retries: Option, + /// initial retry backoff pub fork_retry_backoff: Option, From 543b58c9c56e3e1f775a1dd0eede5fa7204f84ae Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 2 Nov 2023 14:40:24 -0400 Subject: [PATCH 0223/1963] fix(`invariants`): respect `fail_on_revert` properly and do not populate logs/traces twice (#6199) * feat: populate the actual error so failure is detected * misc doc fixes * fix: do NOT extend error logs/traces twice to not display calls twice * chore: add test * chore: add new invariant file --- .../evm/evm/src/executors/invariant/funcs.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 20 ++++++---- crates/evm/fuzz/src/invariant/mod.rs | 2 +- crates/forge/src/runner.rs | 6 --- crates/forge/tests/it/invariant.rs | 37 +++++++++++++++++++ .../common/InvariantHandlerFailure.t.sol | 35 ++++++++++++++++++ 6 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index 911c22a5d76c0..bc82290e4d497 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -11,7 +11,7 @@ use revm::primitives::U256; /// Given the executor state, asserts that no invariant has been broken. Otherwise, it fills the /// external `invariant_failures.failed_invariant` map and returns a generic error. -/// Returns the mapping of (Invariant Function Name -> Call Result). +/// Either returns the call result if successful, or nothing if there was an error. pub fn assert_invariants( invariant_contract: &InvariantContract<'_>, executor: &Executor, diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 4c4827b430da1..d0c60f4b77202 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -115,6 +115,13 @@ impl<'a> InvariantExecutor<'a> { // Stores data related to reverts or failed assertions of the test. let failures = RefCell::new(InvariantFailures::new()); + // Stores the calldata in the last run. + let last_run_calldata: RefCell> = RefCell::new(vec![]); + + // Let's make sure the invariant is sound before actually starting the run: + // We'll assert the invariant in its initial state, and if it fails, we'll + // already know if we can early exit the invariant run. + // This does not count as a fuzz run. It will just register the revert. let last_call_results = RefCell::new(assert_invariants( &invariant_contract, &self.executor, @@ -122,8 +129,7 @@ impl<'a> InvariantExecutor<'a> { &mut failures.borrow_mut(), self.config.shrink_sequence, )); - let last_run_calldata: RefCell> = RefCell::new(vec![]); - // Make sure invariants are sound even before starting to fuzz + if last_call_results.borrow().is_none() { fuzz_cases.borrow_mut().push(FuzzedCases::new(vec![])); } @@ -134,8 +140,8 @@ impl<'a> InvariantExecutor<'a> { // values. let branch_runner = RefCell::new(self.runner.clone()); let _ = self.runner.run(&strat, |mut inputs| { - // Scenarios where we want to fail as soon as possible. - if self.config.fail_on_revert && failures.borrow().reverts == 1 { + // We stop the run immediately if we have reverted, and `fail_on_revert` is set. + if self.config.fail_on_revert && failures.borrow().reverts > 0 { return Err(TestCaseError::fail("Revert occurred.")) } @@ -745,10 +751,9 @@ fn can_continue( return RichInvariantResults::new(false, None) } } else { + // Increase the amount of reverts. failures.reverts += 1; - - // The user might want to stop all execution if a revert happens to - // better bound their testing space. + // If fail on revert is set, we must return inmediately. if fail_on_revert { let error = InvariantFuzzError::new( invariant_contract, @@ -760,6 +765,7 @@ fn can_continue( ); failures.revert_reason = Some(error.revert_reason.clone()); + failures.error = Some(error); return RichInvariantResults::new(false, None) } diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index d7fbf09ec0c90..6a0a6ec7543c2 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -20,7 +20,7 @@ pub type BasicTxDetails = (Address, (Address, Bytes)); pub struct InvariantContract<'a> { /// Address of the test contract. pub address: Address, - /// Invariant functions present in the test contract. + /// Invariant function present in the test contract. pub invariant_function: &'a Function, /// Abi of the test contract. pub abi: &'a Abi, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 1e4e97cda945e..d3e414c2e15a2 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -487,12 +487,6 @@ impl<'a> ContractRunner<'a> { error!(?err, "Failed to replay invariant error") } }; - - logs.extend(error.logs); - - if let Some(error_traces) = error.traces { - traces.push((TraceKind::Execution, error_traces)); - } } // If invariants ran successfully, replay the last run to collect logs and diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 24231b2d58dce..30d97ed418a7d 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -20,6 +20,10 @@ async fn test_invariant() { assert_multiple( &results, BTreeMap::from([ + ( + "fuzz/invariant/common/InvariantHandlerFailure.t.sol:InvariantHandlerFailure", + vec![("statefulFuzz_BrokenInvariant()", true, None, None, None)], + ), ( "fuzz/invariant/common/InvariantInnerContract.t.sol:InvariantInnerContract", vec![("invariantHideJesus()", false, Some("jesus betrayed.".into()), None, None)], @@ -113,6 +117,39 @@ async fn test_invariant_override() { ); } +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_fail_on_revert() { + let mut runner = runner().await; + + let mut opts = test_opts(); + opts.invariant.fail_on_revert = true; + opts.invariant.runs = 1; + opts.invariant.depth = 10; + runner.test_options = opts.clone(); + + let results = runner + .test( + &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantHandlerFailure.t.sol"), + None, + opts, + ) + .await; + + assert_multiple( + &results, + BTreeMap::from([( + "fuzz/invariant/common/InvariantHandlerFailure.t.sol:InvariantHandlerFailure", + vec![( + "statefulFuzz_BrokenInvariant()", + false, + Some("failed on revert".into()), + None, + None, + )], + )]), + ); +} + #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_invariant_storage() { diff --git a/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol b/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol new file mode 100644 index 0000000000000..9a84e4f9e3dc8 --- /dev/null +++ b/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.0; + +import "ds-test/test.sol"; + +struct FuzzSelector { + address addr; + bytes4[] selectors; +} + +contract Handler is DSTest { + function doSomething() public { + require(false, "failed on revert"); + } +} + +contract InvariantHandlerFailure is DSTest { + bytes4[] internal selectors; + + Handler handler; + + function targetSelectors() public returns (FuzzSelector[] memory) { + FuzzSelector[] memory targets = new FuzzSelector[](1); + bytes4[] memory selectors = new bytes4[](1); + selectors[0] = handler.doSomething.selector; + targets[0] = FuzzSelector(address(handler), selectors); + return targets; + } + + function setUp() public { + handler = new Handler(); + } + + function statefulFuzz_BrokenInvariant() public {} +} From 5dda5b1daeab73f9f87589b1944877127c48e425 Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 2 Nov 2023 17:55:01 -0400 Subject: [PATCH 0224/1963] chore: bump foundry-block-explorers (#6201) --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 2c2721a4d82e6..c09aeae9c404e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2599,7 +2599,7 @@ dependencies = [ [[package]] name = "foundry-block-explorers" version = "0.1.0" -source = "git+https://github.com/foundry-rs/block-explorers#5cbf6d32fa1ba39bc06a0d2b6202a021b3b8f0ff" +source = "git+https://github.com/foundry-rs/block-explorers#3c118b815cb443ac62e0818b18da9f3be5871af0" dependencies = [ "alloy-json-abi", "alloy-primitives", From 265059bcfdf8a7a510b6bc7ef6e8c994ccb3153f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:44:07 +0100 Subject: [PATCH 0225/1963] refactor: split cheatcode definitions into a separate crate (#6202) * refactor: split foundry-cheatcodes defs into a separate crate * docs: update links * fix: separate dispatch impl from defs * docs: update again * doc * stuff --- .cargo/config.toml | 2 +- Cargo.lock | 15 +- Cargo.toml | 2 + crates/cheatcodes/Cargo.toml | 70 ++----- crates/cheatcodes/README.md | 8 +- crates/cheatcodes/defs/Cargo.toml | 26 +++ crates/cheatcodes/defs/README.md | 3 + .../{src/defs => defs/src}/cheatcode.rs | 0 .../{src/defs => defs/src}/function.rs | 0 .../{src/defs => defs/src}/items.rs | 0 crates/cheatcodes/defs/src/lib.rs | 176 ++++++++++++++++++ .../cheatcodes/{src/defs => defs/src}/vm.rs | 0 crates/cheatcodes/src/{impls => }/config.rs | 0 crates/cheatcodes/src/defs/mod.rs | 90 --------- crates/cheatcodes/src/{impls => }/env.rs | 3 +- crates/cheatcodes/src/{impls => }/error.rs | 10 +- crates/cheatcodes/src/{impls => }/evm.rs | 3 +- crates/cheatcodes/src/{impls => }/evm/fork.rs | 5 +- .../cheatcodes/src/{impls => }/evm/mapping.rs | 3 +- crates/cheatcodes/src/{impls => }/evm/mock.rs | 3 +- .../cheatcodes/src/{impls => }/evm/prank.rs | 3 +- crates/cheatcodes/src/{impls => }/fs.rs | 5 +- crates/cheatcodes/src/impls/mod.rs | 97 ---------- .../cheatcodes/src/{impls => }/inspector.rs | 20 +- crates/cheatcodes/src/{impls => }/json.rs | 3 +- crates/cheatcodes/src/lib.rs | 159 ++++++++-------- crates/cheatcodes/src/{impls => }/script.rs | 3 +- crates/cheatcodes/src/{impls => }/string.rs | 3 +- crates/cheatcodes/src/{impls => }/test.rs | 3 +- .../cheatcodes/src/{impls => }/test/expect.rs | 3 +- crates/cheatcodes/src/{impls => }/utils.rs | 3 +- crates/evm/evm/Cargo.toml | 2 +- crates/evm/evm/src/inspectors/mod.rs | 2 +- crates/macros/impl/src/cheatcodes.rs | 19 +- docs/dev/cheatcodes.md | 23 +-- testdata/cheats/Vm.sol | 5 +- 36 files changed, 389 insertions(+), 383 deletions(-) create mode 100644 crates/cheatcodes/defs/Cargo.toml create mode 100644 crates/cheatcodes/defs/README.md rename crates/cheatcodes/{src/defs => defs/src}/cheatcode.rs (100%) rename crates/cheatcodes/{src/defs => defs/src}/function.rs (100%) rename crates/cheatcodes/{src/defs => defs/src}/items.rs (100%) create mode 100644 crates/cheatcodes/defs/src/lib.rs rename crates/cheatcodes/{src/defs => defs/src}/vm.rs (100%) rename crates/cheatcodes/src/{impls => }/config.rs (100%) delete mode 100644 crates/cheatcodes/src/defs/mod.rs rename crates/cheatcodes/src/{impls => }/env.rs (99%) rename crates/cheatcodes/src/{impls => }/error.rs (95%) rename crates/cheatcodes/src/{impls => }/evm.rs (99%) rename crates/cheatcodes/src/{impls => }/evm/fork.rs (98%) rename crates/cheatcodes/src/{impls => }/evm/mapping.rs (98%) rename crates/cheatcodes/src/{impls => }/evm/mock.rs (97%) rename crates/cheatcodes/src/{impls => }/evm/prank.rs (97%) rename crates/cheatcodes/src/{impls => }/fs.rs (99%) delete mode 100644 crates/cheatcodes/src/impls/mod.rs rename crates/cheatcodes/src/{impls => }/inspector.rs (98%) rename crates/cheatcodes/src/{impls => }/json.rs (99%) rename crates/cheatcodes/src/{impls => }/script.rs (98%) rename crates/cheatcodes/src/{impls => }/string.rs (98%) rename crates/cheatcodes/src/{impls => }/test.rs (96%) rename crates/cheatcodes/src/{impls => }/test/expect.rs (99%) rename crates/cheatcodes/src/{impls => }/utils.rs (98%) diff --git a/.cargo/config.toml b/.cargo/config.toml index a42c43c86c18c..186e372f987e7 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,5 @@ [alias] -cheats = "test -p foundry-cheatcodes --features schema tests::" +cheats = "test -p foundry-cheatcodes-defs --features schema tests::" [target.x86_64-pc-windows-msvc] rustflags = [ diff --git a/Cargo.lock b/Cargo.lock index c09aeae9c404e..b386e69d85e83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2626,22 +2626,31 @@ dependencies = [ "ethers-providers", "ethers-signers", "eyre", + "foundry-cheatcodes-defs", "foundry-common", "foundry-compilers", "foundry-config", "foundry-evm-core", - "foundry-macros", "foundry-utils", "itertools 0.11.0", "jsonpath_lib", "revm", - "schemars", - "serde", "serde_json", "tracing", "walkdir", ] +[[package]] +name = "foundry-cheatcodes-defs" +version = "0.2.0" +dependencies = [ + "alloy-sol-types", + "foundry-macros", + "schemars", + "serde", + "serde_json", +] + [[package]] name = "foundry-cli" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index ed8c856cea4de..351f61739fb50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ members = [ "crates/binder/", "crates/cast/", "crates/cheatcodes/", + "crates/cheatcodes/defs/", "crates/chisel/", "crates/cli/", "crates/common/", @@ -116,6 +117,7 @@ forge-fmt = { path = "crates/fmt" } foundry-abi = { path = "crates/abi" } foundry-binder = { path = "crates/binder" } foundry-cheatcodes = { path = "crates/cheatcodes" } +foundry-cheatcodes-defs = { path = "crates/cheatcodes/defs" } foundry-cli = { path = "crates/cli" } foundry-common = { path = "crates/common" } foundry-config = { path = "crates/config" } diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 714d2822d2321..e71529410118c 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -12,56 +12,26 @@ repository.workspace = true exclude.workspace = true [dependencies] -foundry-macros.workspace = true - +foundry-cheatcodes-defs.workspace = true +foundry-common.workspace = true +foundry-compilers.workspace = true +foundry-config.workspace = true +foundry-evm-core.workspace = true +foundry-utils.workspace = true + +alloy-dyn-abi.workspace = true +alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-sol-types.workspace = true - -serde.workspace = true +ethers-core.workspace = true +ethers-providers.workspace = true +ethers-signers.workspace = true + +eyre.workspace = true +hex.workspace = true +itertools.workspace = true +jsonpath_lib.workspace = true +revm.workspace = true serde_json.workspace = true - -# schema -schemars = { version = "0.8.15", optional = true } - -# impls -foundry-common = { workspace = true, optional = true } -foundry-compilers = { workspace = true, optional = true } -foundry-config = { workspace = true, optional = true } -foundry-evm-core = { workspace = true, optional = true } -foundry-utils = { workspace = true, optional = true } - -alloy-dyn-abi = { workspace = true, optional = true } -alloy-json-abi = { workspace = true, optional = true } -ethers-core = { workspace = true, optional = true } -ethers-signers = { workspace = true, optional = true } -ethers-providers = { workspace = true, optional = true } - -eyre = { workspace = true, optional = true } -hex = { workspace = true, optional = true } -itertools = { workspace = true, optional = true } -jsonpath_lib = { workspace = true, optional = true } -revm = { workspace = true, optional = true } -tracing = { workspace = true, optional = true } -walkdir = { version = "2", optional = true } - -[features] -schema = ["dep:schemars"] -impls = [ - "dep:foundry-common", - "dep:foundry-compilers", - "dep:foundry-config", - "dep:foundry-evm-core", - "dep:foundry-utils", - "dep:alloy-dyn-abi", - "dep:alloy-json-abi", - "dep:ethers-core", - "dep:ethers-providers", - "dep:ethers-signers", - "dep:eyre", - "dep:hex", - "dep:itertools", - "dep:jsonpath_lib", - "dep:revm", - "dep:tracing", - "dep:walkdir", -] +tracing.workspace = true +walkdir = "2" diff --git a/crates/cheatcodes/README.md b/crates/cheatcodes/README.md index 3bf38171e1960..ce1e8f32b9f0c 100644 --- a/crates/cheatcodes/README.md +++ b/crates/cheatcodes/README.md @@ -5,12 +5,12 @@ Foundry cheatcodes definitions and implementations. ## Structure - [`assets/`](./assets/): JSON interface and specification -- [`src/defs`](./src/defs/mod.rs): Defines traits and structs -- [`src/impls`](./src/impls/mod.rs): Rust implementations of the cheatcodes. This is gated to the `impl` feature, since these are not needed when only using the definitions. +- [`defs/`](./defs/src/lib.rs): Defines common traits and structs +- [`src/`](./src/lib.rs): Rust implementations of the cheatcodes ## Overview -All cheatcodes are defined in a single [`sol!`] macro call in [`src/defs/vm.rs`]. +All cheatcodes are defined in a single [`sol!`] macro call in [`defs/src/vm.rs`]. This, combined with the use of an internal [`Cheatcode`](../macros/impl/src/cheatcodes.rs) derive macro, allows us to generate both the Rust definitions and the JSON specification of the cheatcodes. @@ -38,4 +38,4 @@ If you are making use of the JSON interface, please don't hesitate to open a PR Please see the [cheatcodes dev documentation](../../docs/dev/cheatcodes.md#adding-a-new-cheatcode) on how to add new cheatcodes. [`sol!`]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html -[`src/defs/vm.rs`]: ./src/defs/vm.rs +[`defs/src/vm.rs`]: ./defs/src/vm.rs diff --git a/crates/cheatcodes/defs/Cargo.toml b/crates/cheatcodes/defs/Cargo.toml new file mode 100644 index 0000000000000..0185c6bf80092 --- /dev/null +++ b/crates/cheatcodes/defs/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "foundry-cheatcodes-defs" +description = "Foundry cheatcodes definitions" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +exclude.workspace = true + +[dependencies] +foundry-macros.workspace = true +alloy-sol-types.workspace = true +serde.workspace = true + +# schema +schemars = { version = "0.8.15", optional = true } + +[dev-dependencies] +serde_json.workspace = true + +[features] +schema = ["dep:schemars"] diff --git a/crates/cheatcodes/defs/README.md b/crates/cheatcodes/defs/README.md new file mode 100644 index 0000000000000..136ce7ffbbae7 --- /dev/null +++ b/crates/cheatcodes/defs/README.md @@ -0,0 +1,3 @@ +# foundry-cheatcodes-defs + +Minimal crate to provide a common set of cheatcodes definitions. diff --git a/crates/cheatcodes/src/defs/cheatcode.rs b/crates/cheatcodes/defs/src/cheatcode.rs similarity index 100% rename from crates/cheatcodes/src/defs/cheatcode.rs rename to crates/cheatcodes/defs/src/cheatcode.rs diff --git a/crates/cheatcodes/src/defs/function.rs b/crates/cheatcodes/defs/src/function.rs similarity index 100% rename from crates/cheatcodes/src/defs/function.rs rename to crates/cheatcodes/defs/src/function.rs diff --git a/crates/cheatcodes/src/defs/items.rs b/crates/cheatcodes/defs/src/items.rs similarity index 100% rename from crates/cheatcodes/src/defs/items.rs rename to crates/cheatcodes/defs/src/items.rs diff --git a/crates/cheatcodes/defs/src/lib.rs b/crates/cheatcodes/defs/src/lib.rs new file mode 100644 index 0000000000000..53bd161a8f12d --- /dev/null +++ b/crates/cheatcodes/defs/src/lib.rs @@ -0,0 +1,176 @@ +//! # foundry-cheatcode-defs +//! +//! Foundry cheatcode definitions. + +#![warn(missing_docs, unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] + +use serde::{Deserialize, Serialize}; +use std::{borrow::Cow, fmt}; + +mod cheatcode; +pub use cheatcode::{Cheatcode, CheatcodeDef, Group, Safety, Status}; + +mod function; +pub use function::{Function, Mutability, Visibility}; + +mod items; +pub use items::{Enum, EnumVariant, Error, Event, Struct, StructField}; + +mod vm; +pub use vm::Vm; + +// The `cheatcodes.json` schema. +/// Foundry cheatcodes. Learn more: +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct Cheatcodes<'a> { + /// Cheatcode errors. + #[serde(borrow)] + pub errors: Cow<'a, [Error<'a>]>, + /// Cheatcode events. + #[serde(borrow)] + pub events: Cow<'a, [Event<'a>]>, + /// Cheatcode enums. + #[serde(borrow)] + pub enums: Cow<'a, [Enum<'a>]>, + /// Cheatcode structs. + #[serde(borrow)] + pub structs: Cow<'a, [Struct<'a>]>, + /// All the cheatcodes. + #[serde(borrow)] + pub cheatcodes: Cow<'a, [Cheatcode<'a>]>, +} + +impl fmt::Display for Cheatcodes<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + for error in self.errors.iter() { + writeln!(f, "{error}")?; + } + for event in self.events.iter() { + writeln!(f, "{event}")?; + } + for enumm in self.enums.iter() { + writeln!(f, "{enumm}")?; + } + for strukt in self.structs.iter() { + writeln!(f, "{strukt}")?; + } + for cheatcode in self.cheatcodes.iter() { + writeln!(f, "{}", cheatcode.func)?; + } + Ok(()) + } +} + +impl Default for Cheatcodes<'static> { + fn default() -> Self { + Self::new() + } +} + +impl Cheatcodes<'static> { + /// Returns the default cheatcodes. + pub fn new() -> Self { + Self { + // unfortunately technology has not yet advanced to the point where we can get all + // items of a certain type in a module, so we have to hardcode them here + structs: Cow::Owned(vec![ + Vm::Log::STRUCT.clone(), + Vm::Rpc::STRUCT.clone(), + Vm::EthGetLogs::STRUCT.clone(), + Vm::DirEntry::STRUCT.clone(), + Vm::FsMetadata::STRUCT.clone(), + Vm::Wallet::STRUCT.clone(), + Vm::FfiResult::STRUCT.clone(), + ]), + enums: Cow::Owned(vec![Vm::CallerMode::ENUM.clone()]), + errors: Vm::VM_ERRORS.iter().map(|&x| x.clone()).collect(), + events: Cow::Borrowed(&[]), + // events: Vm::VM_EVENTS.iter().map(|&x| x.clone()).collect(), + cheatcodes: Vm::CHEATCODES.iter().map(|&x| x.clone()).collect(), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::{fs, path::Path}; + + const JSON_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../assets/cheatcodes.json"); + #[cfg(feature = "schema")] + const SCHEMA_PATH: &str = + concat!(env!("CARGO_MANIFEST_DIR"), "/../assets/cheatcodes.schema.json"); + const IFACE_PATH: &str = + concat!(env!("CARGO_MANIFEST_DIR"), "/../../../testdata/cheats/Vm.sol"); + + /// Generates the `cheatcodes.json` file contents. + fn json_cheatcodes() -> String { + serde_json::to_string_pretty(&Cheatcodes::new()).unwrap() + } + + /// Generates the [cheatcodes](json_cheatcodes) JSON schema. + #[cfg(feature = "schema")] + fn json_schema() -> String { + serde_json::to_string_pretty(&schemars::schema_for!(Cheatcodes<'_>)).unwrap() + } + + fn sol_iface() -> String { + let cheats = Cheatcodes::new().to_string().trim().replace('\n', "\n "); + format!( + "\ +// Automatically generated from `foundry-cheatcodes` Vm definitions. Do not modify manually. +// This interface is just for internal testing purposes. Use `forge-std` instead. + +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.4; + +interface Vm {{ + {cheats} +}} +" + ) + } + + #[test] + fn defs_up_to_date() { + ensure_file_contents(Path::new(JSON_PATH), &json_cheatcodes()); + } + + #[test] + #[cfg(feature = "schema")] + fn schema_up_to_date() { + ensure_file_contents(Path::new(SCHEMA_PATH), &json_schema()); + } + + #[test] + fn iface_up_to_date() { + ensure_file_contents(Path::new(IFACE_PATH), &sol_iface()); + } + + /// Checks that the `file` has the specified `contents`. If that is not the + /// case, updates the file and then fails the test. + fn ensure_file_contents(file: &Path, contents: &str) { + if let Ok(old_contents) = fs::read_to_string(file) { + if normalize_newlines(&old_contents) == normalize_newlines(contents) { + // File is already up to date. + return + } + } + + eprintln!("\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n", file.display()); + if std::env::var("CI").is_ok() { + eprintln!(" NOTE: run `cargo test` locally and commit the updated files\n"); + } + if let Some(parent) = file.parent() { + let _ = fs::create_dir_all(parent); + } + fs::write(file, contents).unwrap(); + panic!("some file was not up to date and has been updated, simply re-run the tests"); + } + + fn normalize_newlines(s: &str) -> String { + s.replace("\r\n", "\n") + } +} diff --git a/crates/cheatcodes/src/defs/vm.rs b/crates/cheatcodes/defs/src/vm.rs similarity index 100% rename from crates/cheatcodes/src/defs/vm.rs rename to crates/cheatcodes/defs/src/vm.rs diff --git a/crates/cheatcodes/src/impls/config.rs b/crates/cheatcodes/src/config.rs similarity index 100% rename from crates/cheatcodes/src/impls/config.rs rename to crates/cheatcodes/src/config.rs diff --git a/crates/cheatcodes/src/defs/mod.rs b/crates/cheatcodes/src/defs/mod.rs deleted file mode 100644 index 652f65f5a3569..0000000000000 --- a/crates/cheatcodes/src/defs/mod.rs +++ /dev/null @@ -1,90 +0,0 @@ -//! Cheatcode definitions. - -use serde::{Deserialize, Serialize}; -use std::{borrow::Cow, fmt}; - -mod cheatcode; -pub use cheatcode::{Cheatcode, CheatcodeDef, Group, Safety, Status}; - -mod function; -pub use function::{Function, Mutability, Visibility}; - -mod items; -pub use items::{Enum, EnumVariant, Error, Event, Struct, StructField}; - -mod vm; -pub use vm::Vm; - -// The `cheatcodes.json` schema. -/// Foundry cheatcodes. Learn more: -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[serde(rename_all = "camelCase")] -pub struct Cheatcodes<'a> { - /// Cheatcode errors. - #[serde(borrow)] - pub errors: Cow<'a, [Error<'a>]>, - /// Cheatcode events. - #[serde(borrow)] - pub events: Cow<'a, [Event<'a>]>, - /// Cheatcode enums. - #[serde(borrow)] - pub enums: Cow<'a, [Enum<'a>]>, - /// Cheatcode structs. - #[serde(borrow)] - pub structs: Cow<'a, [Struct<'a>]>, - /// All the cheatcodes. - #[serde(borrow)] - pub cheatcodes: Cow<'a, [Cheatcode<'a>]>, -} - -impl fmt::Display for Cheatcodes<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - for error in self.errors.iter() { - writeln!(f, "{error}")?; - } - for event in self.events.iter() { - writeln!(f, "{event}")?; - } - for enumm in self.enums.iter() { - writeln!(f, "{enumm}")?; - } - for strukt in self.structs.iter() { - writeln!(f, "{strukt}")?; - } - for cheatcode in self.cheatcodes.iter() { - writeln!(f, "{}", cheatcode.func)?; - } - Ok(()) - } -} - -impl Default for Cheatcodes<'static> { - fn default() -> Self { - Self::new() - } -} - -impl Cheatcodes<'static> { - /// Returns the default cheatcodes. - pub fn new() -> Self { - Self { - // unfortunately technology has not yet advanced to the point where we can get all - // items of a certain type in a module, so we have to hardcode them here - structs: Cow::Owned(vec![ - Vm::Log::STRUCT.clone(), - Vm::Rpc::STRUCT.clone(), - Vm::EthGetLogs::STRUCT.clone(), - Vm::DirEntry::STRUCT.clone(), - Vm::FsMetadata::STRUCT.clone(), - Vm::Wallet::STRUCT.clone(), - Vm::FfiResult::STRUCT.clone(), - ]), - enums: Cow::Owned(vec![Vm::CallerMode::ENUM.clone()]), - errors: Vm::VM_ERRORS.iter().map(|&x| x.clone()).collect(), - events: Cow::Borrowed(&[]), - // events: Vm::VM_EVENTS.iter().map(|&x| x.clone()).collect(), - cheatcodes: Vm::CHEATCODES.iter().map(|&x| x.clone()).collect(), - } - } -} diff --git a/crates/cheatcodes/src/impls/env.rs b/crates/cheatcodes/src/env.rs similarity index 99% rename from crates/cheatcodes/src/impls/env.rs rename to crates/cheatcodes/src/env.rs index 590a04c81421a..d9022b16d4c16 100644 --- a/crates/cheatcodes/src/impls/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -1,7 +1,6 @@ //! Implementations of [`Environment`](crate::Group::Environment) cheatcodes. -use super::{string, Cheatcode, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_primitives::{Address, Bytes, B256, I256, U256}; use alloy_sol_types::SolValue; use std::env; diff --git a/crates/cheatcodes/src/impls/error.rs b/crates/cheatcodes/src/error.rs similarity index 95% rename from crates/cheatcodes/src/impls/error.rs rename to crates/cheatcodes/src/error.rs index 8c3cd2307d8bd..494c43d083d3e 100644 --- a/crates/cheatcodes/src/impls/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -15,13 +15,13 @@ pub type Result, E = Error> = std::result::Result; macro_rules! fmt_err { ($msg:literal $(,)?) => { - $crate::impls::Error::fmt(::std::format_args!($msg)) + $crate::Error::fmt(::std::format_args!($msg)) }; ($err:expr $(,)?) => { - <$crate::impls::Error as ::std::convert::From<_>>::from($err) + <$crate::Error as ::std::convert::From<_>>::from($err) }; ($fmt:expr, $($arg:tt)*) => { - $crate::impls::Error::fmt(::std::format_args!($fmt, $($arg)*)) + $crate::Error::fmt(::std::format_args!($fmt, $($arg)*)) }; } @@ -40,7 +40,7 @@ macro_rules! bail { macro_rules! ensure { ($cond:expr $(,)?) => { if !$cond { - return ::std::result::Result::Err($crate::impls::Error::custom( + return ::std::result::Result::Err($crate::Error::custom( ::std::concat!("Condition failed: `", ::std::stringify!($cond), "`") )); } @@ -65,7 +65,7 @@ macro_rules! ensure { macro_rules! ensure_not_precompile { ($address:expr, $ctxt:expr) => { if $ctxt.is_precompile($address) { - return Err($crate::impls::error::precompile_error( + return Err($crate::error::precompile_error( ::CHEATCODE.func.id, $address, )) diff --git a/crates/cheatcodes/src/impls/evm.rs b/crates/cheatcodes/src/evm.rs similarity index 99% rename from crates/cheatcodes/src/impls/evm.rs rename to crates/cheatcodes/src/evm.rs index 1626ac2b38e2d..3ac9861112d61 100644 --- a/crates/cheatcodes/src/impls/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1,7 +1,6 @@ //! Implementations of [`Evm`](crate::Group::Evm) cheatcodes. -use super::{Cheatcode, CheatsCtxt, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, Bytes, U256}; use alloy_sol_types::SolValue; use ethers_signers::Signer; diff --git a/crates/cheatcodes/src/impls/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs similarity index 98% rename from crates/cheatcodes/src/impls/evm/fork.rs rename to crates/cheatcodes/src/evm/fork.rs index de722e7722bdc..25b224182b1d6 100644 --- a/crates/cheatcodes/src/impls/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,5 +1,4 @@ -use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::B256; use alloy_sol_types::SolValue; use ethers_core::types::Filter; @@ -229,7 +228,7 @@ impl Cheatcode for rpcCall { .block_on(provider.request(method, params_json)) .map_err(|err| fmt_err!("{method:?}: {err}"))?; - let result_as_tokens = crate::impls::json::value_to_token(&result) + let result_as_tokens = crate::json::value_to_token(&result) .map_err(|err| fmt_err!("failed to parse result: {err}"))?; Ok(result_as_tokens.abi_encode()) diff --git a/crates/cheatcodes/src/impls/evm/mapping.rs b/crates/cheatcodes/src/evm/mapping.rs similarity index 98% rename from crates/cheatcodes/src/impls/evm/mapping.rs rename to crates/cheatcodes/src/evm/mapping.rs index 2713807b95075..8ff789c8e4191 100644 --- a/crates/cheatcodes/src/impls/evm/mapping.rs +++ b/crates/cheatcodes/src/evm/mapping.rs @@ -1,5 +1,4 @@ -use super::{Cheatcode, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_sol_types::SolValue; use revm::interpreter::{opcode, Interpreter}; diff --git a/crates/cheatcodes/src/impls/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs similarity index 97% rename from crates/cheatcodes/src/impls/evm/mock.rs rename to crates/cheatcodes/src/evm/mock.rs index a3a61711dd322..1fa55539e8bed 100644 --- a/crates/cheatcodes/src/impls/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -1,5 +1,4 @@ -use super::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result}; -use crate::Vm::*; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, Bytes, U256}; use revm::{interpreter::InstructionResult, primitives::Bytecode}; use std::cmp::Ordering; diff --git a/crates/cheatcodes/src/impls/evm/prank.rs b/crates/cheatcodes/src/evm/prank.rs similarity index 97% rename from crates/cheatcodes/src/impls/evm/prank.rs rename to crates/cheatcodes/src/evm/prank.rs index e7764dfe94c17..73269b23d11b0 100644 --- a/crates/cheatcodes/src/impls/evm/prank.rs +++ b/crates/cheatcodes/src/evm/prank.rs @@ -1,5 +1,4 @@ -use super::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result}; -use crate::Vm::*; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::Address; /// Prank information. diff --git a/crates/cheatcodes/src/impls/fs.rs b/crates/cheatcodes/src/fs.rs similarity index 99% rename from crates/cheatcodes/src/impls/fs.rs rename to crates/cheatcodes/src/fs.rs index 36b1912a9fcdf..3e345db94a97b 100644 --- a/crates/cheatcodes/src/impls/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -1,7 +1,6 @@ //! Implementations of [`Filesystem`](crate::Group::Filesystem) cheatcodes. -use super::{Cheatcode, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_json_abi::ContractObject; use alloy_primitives::U256; use alloy_sol_types::SolValue; @@ -406,7 +405,7 @@ mod tests { #[test] fn test_artifact_parsing() { - let s = include_str!("../../../evm/test-data/solc-obj.json"); + let s = include_str!("../../evm/test-data/solc-obj.json"); let artifact: ContractObject = serde_json::from_str(s).unwrap(); assert!(artifact.bytecode.is_some()); diff --git a/crates/cheatcodes/src/impls/mod.rs b/crates/cheatcodes/src/impls/mod.rs deleted file mode 100644 index 770016786c4a1..0000000000000 --- a/crates/cheatcodes/src/impls/mod.rs +++ /dev/null @@ -1,97 +0,0 @@ -//! Cheatcode implementations. - -use crate::CheatcodeDef; -use alloy_primitives::Address; -use foundry_evm_core::backend::DatabaseExt; -use revm::EVMData; -use tracing::Level; - -#[macro_use] -mod error; -pub use error::{Error, ErrorKind, Result}; - -mod config; -pub use config::CheatsConfig; - -mod inspector; -pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; - -mod env; -mod evm; -mod fs; -mod json; -mod script; -mod string; -mod test; -mod utils; - -pub use test::expect::ExpectedCallTracker; - -/// Cheatcode implementation. -pub(crate) trait Cheatcode: CheatcodeDef { - /// Applies this cheatcode to the given state. - /// - /// Implement this function if you don't need access to the EVM data. - fn apply(&self, state: &mut Cheatcodes) -> Result { - let _ = state; - unimplemented!("{}", Self::CHEATCODE.func.id) - } - - /// Applies this cheatcode to the given context. - /// - /// Implement this function if you need access to the EVM data. - #[inline(always)] - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { - self.apply(ccx.state) - } - - #[inline] - fn apply_traced(&self, ccx: &mut CheatsCtxt) -> Result { - let span = trace_span(self); - let _enter = span.enter(); - trace_call(); - let result = self.apply_full(ccx); - trace_return(&result); - result - } -} - -// Separate functions to avoid inline and monomorphization bloat. -fn trace_span(cheat: &T) -> tracing::Span { - if enabled!(Level::TRACE) { - trace_span!(target: "cheatcodes", "apply", cheat=?cheat) - } else { - debug_span!(target: "cheatcodes", "apply", id=%T::CHEATCODE.func.id) - } -} - -fn trace_call() { - trace!(target: "cheatcodes", "applying"); -} - -fn trace_return(result: &Result) { - trace!( - target: "cheatcodes", - return = match result { - Ok(b) => hex::encode(b), - Err(e) => e.to_string(), - } - ); -} - -/// The cheatcode context, used in [`Cheatcode`]. -pub(crate) struct CheatsCtxt<'a, 'b, 'c, DB: DatabaseExt> { - /// The cheatcodes inspector state. - pub(crate) state: &'a mut Cheatcodes, - /// The EVM data. - pub(crate) data: &'b mut EVMData<'c, DB>, - /// The original `msg.sender`. - pub(crate) caller: Address, -} - -impl CheatsCtxt<'_, '_, '_, DB> { - #[inline] - pub(crate) fn is_precompile(&self, address: &Address) -> bool { - self.data.precompiles.contains(address) - } -} diff --git a/crates/cheatcodes/src/impls/inspector.rs b/crates/cheatcodes/src/inspector.rs similarity index 98% rename from crates/cheatcodes/src/impls/inspector.rs rename to crates/cheatcodes/src/inspector.rs index 10ba204ff13da..5c95cfc2fa2fd 100644 --- a/crates/cheatcodes/src/impls/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1,6 +1,6 @@ //! Cheatcode EVM [Inspector]. -use super::{ +use crate::{ evm::{ mapping::{self, MappingSlots}, mock::{MockCallDataContext, MockCallReturnData}, @@ -11,9 +11,8 @@ use super::{ test::expect::{ self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, ExpectedRevert, }, - CheatsCtxt, Error, Result, + CheatsConfig, CheatsCtxt, Error, Result, Vm, }; -use crate::{CheatsConfig, Vm}; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_sol_types::{SolInterface, SolValue}; use ethers_core::types::{ @@ -223,8 +222,7 @@ impl Cheatcodes { // but only if the backend is in forking mode data.db.ensure_cheatcode_access_forking_mode(caller)?; - // apply the cheatcode to the current state - decoded.apply(&mut CheatsCtxt { state: self, data, caller }) + apply_dispatch(&decoded, &mut CheatsCtxt { state: self, data, caller }) } /// Determines the address of the contract and marks it as allowed @@ -1107,3 +1105,15 @@ fn check_if_fixed_gas_limit(data: &EVMData<'_, DB>, call_gas_li // gas too low" failure when simulated on chain && call_gas_limit > 2300 } + +/// Dispatches the cheatcode call to the appropriate function. +fn apply_dispatch(calls: &Vm::VmCalls, ccx: &mut CheatsCtxt) -> Result { + macro_rules! match_ { + ($($variant:ident),*) => { + match calls { + $(Vm::VmCalls::$variant(cheat) => crate::Cheatcode::apply_traced(cheat, ccx),)* + } + }; + } + vm_calls!(match_) +} diff --git a/crates/cheatcodes/src/impls/json.rs b/crates/cheatcodes/src/json.rs similarity index 99% rename from crates/cheatcodes/src/impls/json.rs rename to crates/cheatcodes/src/json.rs index 41c8e695991ad..a52a37e1bf480 100644 --- a/crates/cheatcodes/src/impls/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -1,7 +1,6 @@ //! Implementations of [`Json`](crate::Group::Json) cheatcodes. -use super::{string, Cheatcode, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Address, Bytes, B256, I256, U256}; use alloy_sol_types::SolValue; diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index e11640124f451..e39f98f5a9623 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -1,99 +1,108 @@ //! # foundry-cheatcodes //! -//! Foundry cheatcodes definitions and implementations. +//! Foundry cheatcodes implementations. #![warn(missing_docs, unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] #![allow(elided_lifetimes_in_paths)] // Cheats context uses 3 lifetimes -#[cfg(feature = "impls")] +#[macro_use] +pub extern crate foundry_cheatcodes_defs as defs; #[macro_use] extern crate tracing; -// Silence the "unused crate" warning. -#[cfg(not(feature = "impls"))] -use alloy_primitives as _; - -pub mod defs; -pub use defs::{Cheatcode, CheatcodeDef, Vm}; - -#[cfg(feature = "impls")] -pub mod impls; -#[cfg(feature = "impls")] -pub use impls::{Cheatcodes, CheatsConfig}; +use alloy_primitives::Address; +use foundry_evm_core::backend::DatabaseExt; +use revm::EVMData; +use tracing::Level; -#[cfg(test)] -mod tests { - use super::*; - use std::{fs, path::Path}; +pub use defs::{CheatcodeDef, Vm}; - const JSON_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/cheatcodes.json"); - #[cfg(feature = "schema")] - const SCHEMA_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/cheatcodes.schema.json"); - const IFACE_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata/cheats/Vm.sol"); - - /// Generates the `cheatcodes.json` file contents. - fn json_cheatcodes() -> String { - serde_json::to_string_pretty(&defs::Cheatcodes::new()).unwrap() - } - - /// Generates the [cheatcodes](json_cheatcodes) JSON schema. - #[cfg(feature = "schema")] - fn json_schema() -> String { - serde_json::to_string_pretty(&schemars::schema_for!(defs::Cheatcodes)).unwrap() - } - - fn sol_iface() -> String { - let cheats = defs::Cheatcodes::new().to_string().trim().replace('\n', "\n "); - format!( - "\ -// Automatically generated from `foundry-cheatcodes` Vm definitions. Do not modify manually. -// This interface is just for internal testing purposes. Use `forge-std` instead. - -interface Vm {{ - {cheats} -}} -" - ) - } - - #[test] - fn defs_up_to_date() { - ensure_file_contents(Path::new(JSON_PATH), &json_cheatcodes()); - } - - #[test] - #[cfg(feature = "schema")] - fn schema_up_to_date() { - ensure_file_contents(Path::new(SCHEMA_PATH), &json_schema()); +#[macro_use] +mod error; +pub use error::{Error, ErrorKind, Result}; + +mod config; +pub use config::CheatsConfig; + +mod inspector; +pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; + +mod env; +mod evm; +mod fs; +mod json; +mod script; +mod string; +mod test; +mod utils; + +pub use test::expect::ExpectedCallTracker; + +/// Cheatcode implementation. +pub(crate) trait Cheatcode: CheatcodeDef { + /// Applies this cheatcode to the given state. + /// + /// Implement this function if you don't need access to the EVM data. + fn apply(&self, state: &mut Cheatcodes) -> Result { + let _ = state; + unimplemented!("{}", Self::CHEATCODE.func.id) } - #[test] - fn iface_up_to_date() { - ensure_file_contents(Path::new(IFACE_PATH), &sol_iface()); + /// Applies this cheatcode to the given context. + /// + /// Implement this function if you need access to the EVM data. + #[inline(always)] + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + self.apply(ccx.state) } - /// Checks that the `file` has the specified `contents`. If that is not the - /// case, updates the file and then fails the test. - fn ensure_file_contents(file: &Path, contents: &str) { - if let Ok(old_contents) = fs::read_to_string(file) { - if normalize_newlines(&old_contents) == normalize_newlines(contents) { - // File is already up to date. - return + #[inline] + fn apply_traced(&self, ccx: &mut CheatsCtxt) -> Result { + let span = trace_span(self); + let _enter = span.enter(); + trace_call(); + let result = self.apply_full(ccx); + trace_return(&result); + return result; + + // Separate functions to avoid inline and monomorphization bloat. + fn trace_span(cheat: &T) -> tracing::Span { + if enabled!(Level::TRACE) { + trace_span!(target: "cheatcodes", "apply", cheat=?cheat) + } else { + debug_span!(target: "cheatcodes", "apply", id=%T::CHEATCODE.func.id) } } - eprintln!("\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n", file.display()); - if std::env::var("CI").is_ok() { - eprintln!(" NOTE: run `cargo test` locally and commit the updated files\n"); + fn trace_call() { + trace!(target: "cheatcodes", "applying"); } - if let Some(parent) = file.parent() { - let _ = fs::create_dir_all(parent); + + fn trace_return(result: &Result) { + trace!( + target: "cheatcodes", + return = match result { + Ok(b) => hex::encode(b), + Err(e) => e.to_string(), + } + ); } - fs::write(file, contents).unwrap(); - panic!("some file was not up to date and has been updated, simply re-run the tests"); } +} + +/// The cheatcode context, used in [`Cheatcode`]. +pub(crate) struct CheatsCtxt<'a, 'b, 'c, DB: DatabaseExt> { + /// The cheatcodes inspector state. + pub(crate) state: &'a mut Cheatcodes, + /// The EVM data. + pub(crate) data: &'b mut EVMData<'c, DB>, + /// The original `msg.sender`. + pub(crate) caller: Address, +} - fn normalize_newlines(s: &str) -> String { - s.replace("\r\n", "\n") +impl CheatsCtxt<'_, '_, '_, DB> { + #[inline] + pub(crate) fn is_precompile(&self, address: &Address) -> bool { + self.data.precompiles.contains(address) } } diff --git a/crates/cheatcodes/src/impls/script.rs b/crates/cheatcodes/src/script.rs similarity index 98% rename from crates/cheatcodes/src/impls/script.rs rename to crates/cheatcodes/src/script.rs index ab1d9347634f3..8e7df685c9edd 100644 --- a/crates/cheatcodes/src/impls/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -1,7 +1,6 @@ //! Implementations of [`Scripting`](crate::Group::Scripting) cheatcodes. -use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; -use crate::Vm::*; +use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, U256}; use ethers_signers::Signer; use foundry_config::Config; diff --git a/crates/cheatcodes/src/impls/string.rs b/crates/cheatcodes/src/string.rs similarity index 98% rename from crates/cheatcodes/src/impls/string.rs rename to crates/cheatcodes/src/string.rs index 43fc2b9f04461..9a3db966d29a6 100644 --- a/crates/cheatcodes/src/impls/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -1,7 +1,6 @@ //! Implementations of [`String`](crate::Group::String) cheatcodes. -use super::{Cheatcode, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_primitives::{Address, Bytes, B256, I256, U256}; use alloy_sol_types::{SolType, SolValue}; diff --git a/crates/cheatcodes/src/impls/test.rs b/crates/cheatcodes/src/test.rs similarity index 96% rename from crates/cheatcodes/src/impls/test.rs rename to crates/cheatcodes/src/test.rs index 6e372e86a01bb..0294b23b73d6a 100644 --- a/crates/cheatcodes/src/impls/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -1,7 +1,6 @@ //! Implementations of [`Testing`](crate::Group::Testing) cheatcodes. -use super::{Cheatcode, CheatsCtxt, DatabaseExt, Error, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result, Vm::*}; use alloy_primitives::Address; use alloy_sol_types::SolValue; use foundry_evm_core::constants::{MAGIC_ASSUME, MAGIC_SKIP}; diff --git a/crates/cheatcodes/src/impls/test/expect.rs b/crates/cheatcodes/src/test/expect.rs similarity index 99% rename from crates/cheatcodes/src/impls/test/expect.rs rename to crates/cheatcodes/src/test/expect.rs index 4d6cd50a6c2de..3d5d95dff09fa 100644 --- a/crates/cheatcodes/src/impls/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,5 +1,4 @@ -use super::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result}; -use crate::Vm::*; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_dyn_abi::DynSolType; use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; diff --git a/crates/cheatcodes/src/impls/utils.rs b/crates/cheatcodes/src/utils.rs similarity index 98% rename from crates/cheatcodes/src/impls/utils.rs rename to crates/cheatcodes/src/utils.rs index d8a4c5a474c79..c40f4cac7104b 100644 --- a/crates/cheatcodes/src/impls/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -1,7 +1,6 @@ //! Implementations of [`Utils`](crate::Group::Utils) cheatcodes. -use super::{Cheatcode, CheatsCtxt, DatabaseExt, Result}; -use crate::{Cheatcodes, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{keccak256, B256, U256}; use alloy_sol_types::SolValue; use ethers_core::k256::{ diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 4bcf679476d74..68727729a8ae9 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -11,7 +11,7 @@ homepage.workspace = true repository.workspace = true [dependencies] -foundry-cheatcodes = { workspace = true, features = ["impls"] } +foundry-cheatcodes.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true diff --git a/crates/evm/evm/src/inspectors/mod.rs b/crates/evm/evm/src/inspectors/mod.rs index 888f80bd6e9d9..b781ce96c8dd2 100644 --- a/crates/evm/evm/src/inspectors/mod.rs +++ b/crates/evm/evm/src/inspectors/mod.rs @@ -1,6 +1,6 @@ //! EVM inspectors. -pub use foundry_cheatcodes::{impls as cheatcodes, Cheatcodes, CheatsConfig}; +pub use foundry_cheatcodes::{self as cheatcodes, Cheatcodes, CheatsConfig}; pub use foundry_evm_coverage::CoverageCollector; pub use foundry_evm_fuzz::Fuzzer; pub use foundry_evm_traces::Tracer; diff --git a/crates/macros/impl/src/cheatcodes.rs b/crates/macros/impl/src/cheatcodes.rs index ad2b99642ea90..b38186e57732d 100644 --- a/crates/macros/impl/src/cheatcodes.rs +++ b/crates/macros/impl/src/cheatcodes.rs @@ -98,7 +98,7 @@ fn derive_calls_enum(name: &Ident, input: &syn::DataEnum) -> Result } // keep original order for matching - let variants_names = input.variants.iter().map(|v| &v.ident); + let variant_names = input.variants.iter().map(|v| &v.ident); let mut variants = input.variants.iter().collect::>(); variants.sort_by(|a, b| a.ident.cmp(&b.ident)); @@ -110,16 +110,13 @@ fn derive_calls_enum(name: &Ident, input: &syn::DataEnum) -> Result /// All the cheatcodes in [this contract](self). pub const CHEATCODES: &'static [&'static Cheatcode<'static>] = &[#(<#variant_tys as CheatcodeDef>::CHEATCODE,)*]; - #[cfg(feature = "impls")] - impl #name { - pub(crate) fn apply( - &self, - ccx: &mut crate::impls::CheatsCtxt - ) -> crate::impls::Result { - match self { - #(Self::#variants_names(c) => crate::impls::Cheatcode::apply_traced(c, ccx),)* - } - } + /// Internal macro to implement the `Cheatcode` trait for the Vm calls enum. + #[doc(hidden)] + #[macro_export] + macro_rules! vm_calls { + ($mac:ident) => { + $mac!(#(#variant_names),*) + }; } }) } diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index 26f399a698a81..5ff4105d8e941 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -31,7 +31,7 @@ The [`evm`](../../crates/evm/evm/) crate has a variety of inspectors for differe - debugger - logging -## [Cheatcode inspector](../../crates/cheatcodes/src/impls/inspector.rs) +## [Cheatcode inspector](../../crates/cheatcodes/src/inspector.rs) The concept of cheatcodes and cheatcode inspector is very simple. @@ -65,12 +65,12 @@ Rust bindings for the cheatcode interface are generated via the [Alloy](https:// If a call was successfully decoded into the `VmCalls` enum that the `sol!` macro generates, the last step is a large `match` over the decoded function call structs, which serves as the -implementation handler for the cheatcode. This is also automatically generated by the `sol!` macro, -through the use of a custom internal derive procedural macro. +implementation handler for the cheatcode. This is also automatically generated, in part, by the +`sol!` macro, through the use of a custom internal derive procedural macro. ## Cheatcodes implementation -All the cheatcodes are defined in a large [`sol!`] macro call in [`cheatcodes/src/defs/mod.rs`](../../crates/cheatcodes/src/defs/mod.rs): +All the cheatcodes are defined in a large [`sol!`] macro call in [`cheatcodes/defs/src/vm.rs`](../../crates/cheatcodes/defs/src/vm.rs): ```rust sol! { @@ -119,8 +119,9 @@ This is derived once on the `Vm` interface declaration, which recursively applie interface's items, as well as the `sol!`-generated items, such as the `VmCalls` enum. This macro performs extra checks on functions and structs at compile time to make sure they are -documented and have named parameters, and generates a `match { ... }` function that is be used to -dispatch the cheatcode implementations after a call is decoded. +documented and have named parameters, and generates a macro which is later used to implement the +`match { ... }` function that is be used to dispatch the cheatcode implementations after a call is +decoded. The latter is what fails compilation when adding a new cheatcode, and is fixed by implementing the [`Cheatcode` trait](#cheatcode-trait) to the newly-generated function call struct(s). @@ -144,8 +145,8 @@ There are two methods that can be implemented: Only one of these methods can be implemented. -This trait is implemented manually for each cheatcode in the [`impls`](../../crates/cheatcodes/src/impls/) -module on the `sol!`-generated function call structs. +This trait is implemented manually for each cheatcode in the [`foundry-cheatcodes`](../../crates/cheatcodes/) +crate on the `sol!`-generated function call structs. ### [JSON interface](../../crates/cheatcodes/assets/cheatcodes.json) @@ -159,11 +160,11 @@ update of the files. ### Adding a new cheatcode -1. Add its Solidity definition(s) in [`src/defs/vm.rs`]. Ensure that all structs and functions are documented, and that all function parameters are named. This will initially fail to compile because of the automatically generated `match { ... }` expression. This is expected, and will be fixed in the next step -2. Implement the cheatcode in [`src/impls/`](src/impls/) in its category's respective module. Follow the existing implementations as a guide. +1. Add its Solidity definition(s) in [`defs/src/vm.rs`]. Ensure that all structs and functions are documented, and that all function parameters are named. This will initially fail to compile because of the automatically generated `match { ... }` expression. This is expected, and will be fixed in the next step +2. Implement the cheatcode in [`cheatcodes`](cheatcodes) in its category's respective module. Follow the existing implementations as a guide. 3. Update the JSON interface by running `cargo cheats` twice. This is expected to fail the first time that this is run after adding a new cheatcode; see [JSON interface](#json-interface) 4. Write an integration test for the cheatcode in [`testdata/cheats/`](../../testdata/cheats/) 5. Submit a PR to [`forge-std`](https://github.com/foundry-rs/forge-std) updating the Solidity interfaces as necessary. Note that this step won't be necessary once the Solidity interfaces are generated using the JSON interface [`sol!`]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html -[`src/defs/vm.rs`]: ./src/defs/vm.rs +[`defs/src/vm.rs`]: ./defs/src/vm.rs diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 8ab2a14f5e84f..0865a9c779eb4 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -1,6 +1,9 @@ // Automatically generated from `foundry-cheatcodes` Vm definitions. Do not modify manually. // This interface is just for internal testing purposes. Use `forge-std` instead. +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.4; + interface Vm { error CheatcodeError(string message); enum CallerMode { None, Broadcast, RecurrentBroadcast, Prank, RecurrentPrank } @@ -223,4 +226,4 @@ interface Vm { function writeJson(string calldata json, string calldata path) external; function writeJson(string calldata json, string calldata path, string calldata valueKey) external; function writeLine(string calldata path, string calldata data) external; -} \ No newline at end of file +} From 1c7bf46cdf267f06caba6e063329c6ce8f5c914a Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 3 Nov 2023 14:47:14 +0300 Subject: [PATCH 0226/1963] feat(anvil): allow pass headers to `fork-url` (#6178) * feat(anvil): allow pass headers to `fork-url` * fix(clippy) * chore: formatting * fix: don't use expect * touchups --------- Co-authored-by: Matthias Seitz --- crates/anvil/src/cmd.rs | 29 +++++++ crates/anvil/src/config.rs | 11 +++ crates/common/src/provider.rs | 30 +++++-- crates/common/src/runtime_client.rs | 116 +++++++++++++++++++++------- 4 files changed, 151 insertions(+), 35 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 533272f44675c..96c4d86de815f 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -188,6 +188,7 @@ impl NodeArgs { .fork_block_number .or_else(|| self.evm_opts.fork_url.as_ref().and_then(|f| f.block)), ) + .with_fork_headers(self.evm_opts.fork_headers) .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from)) .fork_request_timeout(self.evm_opts.fork_request_timeout.map(Duration::from_millis)) .fork_request_retries(self.evm_opts.fork_request_retries) @@ -328,6 +329,17 @@ pub struct AnvilEvmArgs { )] pub fork_url: Option, + /// Headers to use for the rpc client, e.g. "User-Agent: test-agent" + /// + /// See --fork-url. + #[clap( + long = "fork-header", + value_name = "HEADERS", + help_heading = "Fork config", + requires = "fork_url" + )] + pub fork_headers: Vec, + /// Timeout in ms for requests sent to remote JSON-RPC server in forking mode. /// /// Default value 45000 @@ -664,6 +676,23 @@ mod tests { assert_eq!(args.hardfork, Some(Hardfork::Berlin)); } + #[test] + fn can_parse_fork_headers() { + let args: NodeArgs = NodeArgs::parse_from([ + "anvil", + "--fork-url", + "http,://localhost:8545", + "--fork-header", + "User-Agent: test-agent", + "--fork-header", + "Referrer: example.com", + ]); + assert_eq!( + args.evm_opts.fork_headers, + vec!["User-Agent: test-agent", "Referrer: example.com"] + ); + } + #[test] fn can_parse_prune_config() { let args: NodeArgs = NodeArgs::parse_from(["anvil", "--prune-history"]); diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index b9901d469ba28..4a38e291f5f8f 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -123,6 +123,8 @@ pub struct NodeConfig { pub eth_rpc_url: Option, /// pins the block number for the state fork pub fork_block_number: Option, + /// headers to use with `eth_rpc_url` + pub fork_headers: Vec, /// specifies chain id for cache to skip fetching from remote in offline-start mode pub fork_chain_id: Option, /// The generator used to generate the dev accounts @@ -392,6 +394,7 @@ impl Default for NodeConfig { config_out: None, genesis: None, fork_request_timeout: REQUEST_TIMEOUT, + fork_headers: vec![], fork_request_retries: 5, fork_retry_backoff: Duration::from_millis(1_000), fork_chain_id: None, @@ -659,6 +662,13 @@ impl NodeConfig { self } + /// Sets the `fork_headers` to use with `eth_rpc_url` + #[must_use] + pub fn with_fork_headers(mut self, headers: Vec) -> Self { + self.fork_headers = headers; + self + } + /// Sets the `fork_request_timeout` to use for requests #[must_use] pub fn fork_request_timeout(mut self, fork_request_timeout: Option) -> Self { @@ -901,6 +911,7 @@ impl NodeConfig { .compute_units_per_second(self.compute_units_per_second) .max_retry(10) .initial_backoff(1000) + .headers(self.fork_headers.clone()) .build() .expect("Failed to establish provider to fork url"), ); diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index ecb313f4aa704..f00734721e45c 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -1,6 +1,9 @@ //! Commonly used helpers to construct `Provider`s -use crate::{runtime_client::RuntimeClient, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT}; +use crate::{ + runtime_client::{RuntimeClient, RuntimeClientBuilder}, + ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, +}; use ethers_core::types::{Chain, U256}; use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use ethers_providers::{is_local_endpoint, Middleware, Provider, DEFAULT_LOCAL_POLL_INTERVAL}; @@ -61,6 +64,7 @@ pub struct ProviderBuilder { compute_units_per_second: u64, /// JWT Secret jwt: Option, + headers: Vec, } // === impl ProviderBuilder === @@ -104,6 +108,7 @@ impl ProviderBuilder { // alchemy max cpus compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, jwt: None, + headers: vec![], } } @@ -188,6 +193,13 @@ impl ProviderBuilder { self } + /// Sets http headers + pub fn headers(mut self, headers: Vec) -> Self { + self.headers = headers; + + self + } + /// Same as [`Self:build()`] but also retrieves the `chainId` in order to derive an appropriate /// interval. pub async fn connect(self) -> Result { @@ -211,20 +223,24 @@ impl ProviderBuilder { timeout, compute_units_per_second, jwt, + headers, } = self; let url = url?; - let is_local = is_local_endpoint(url.as_str()); - - let mut provider = Provider::new(RuntimeClient::new( - url, + let client_builder = RuntimeClientBuilder::new( + url.clone(), max_retry, timeout_retry, initial_backoff, timeout, compute_units_per_second, - jwt, - )); + ) + .with_headers(headers) + .with_jwt(jwt); + + let mut provider = Provider::new(client_builder.build()); + + let is_local = is_local_endpoint(url.as_str()); if is_local { provider = provider.interval(DEFAULT_LOCAL_POLL_INTERVAL); diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index d09f17d638c2c..38fd9ddf9d0c0 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -7,9 +7,12 @@ use ethers_providers::{ JsonRpcError, JwtAuth, JwtKey, ProviderError, PubsubClient, RetryClient, RetryClientBuilder, RpcError, Ws, }; -use reqwest::{header::HeaderValue, Url}; +use reqwest::{ + header::{HeaderName, HeaderValue}, + Url, +}; use serde::{de::DeserializeOwned, Serialize}; -use std::{fmt::Debug, path::PathBuf, sync::Arc, time::Duration}; +use std::{fmt::Debug, path::PathBuf, str::FromStr, sync::Arc, time::Duration}; use thiserror::Error; use tokio::sync::RwLock; @@ -39,6 +42,10 @@ pub enum RuntimeClientError { #[error("URL scheme is not supported: {0}")] BadScheme(String), + /// Invalid HTTP header + #[error("Invalid HTTP header: {0}")] + BadHeader(String), + /// Invalid file path #[error("Invalid IPC file path: {0}")] BadPath(String), @@ -82,6 +89,20 @@ pub struct RuntimeClient { /// available CUPS compute_units_per_second: u64, jwt: Option, + headers: Vec, +} + +/// Builder for RuntimeClient +pub struct RuntimeClientBuilder { + url: Url, + max_retry: u32, + timeout_retry: u32, + initial_backoff: u64, + timeout: Duration, + /// available CUPS + compute_units_per_second: u64, + jwt: Option, + headers: Vec, } impl ::core::fmt::Display for RuntimeClient { @@ -104,32 +125,11 @@ fn build_auth(jwt: String) -> eyre::Result { } impl RuntimeClient { - /// Creates a new dynamic provider from a URL - pub fn new( - url: Url, - max_retry: u32, - timeout_retry: u32, - initial_backoff: u64, - timeout: Duration, - compute_units_per_second: u64, - jwt: Option, - ) -> Self { - Self { - client: Arc::new(RwLock::new(None)), - url, - max_retry, - timeout_retry, - initial_backoff, - timeout, - compute_units_per_second, - jwt, - } - } - async fn connect(&self) -> Result { match self.url.scheme() { "http" | "https" => { let mut client_builder = reqwest::Client::builder().timeout(self.timeout); + let mut headers = reqwest::header::HeaderMap::new(); if let Some(jwt) = self.jwt.as_ref() { let auth = build_auth(jwt.clone()).map_err(|err| { @@ -142,16 +142,25 @@ impl RuntimeClient { .expect("Header should be valid string"); auth_value.set_sensitive(true); - let mut headers = reqwest::header::HeaderMap::new(); headers.insert(reqwest::header::AUTHORIZATION, auth_value); - - client_builder = client_builder.default_headers(headers); }; + for header in self.headers.iter() { + let make_err = || RuntimeClientError::BadHeader(header.to_string()); + + let (key, val) = header.split_once(':').ok_or_else(make_err)?; + + headers.insert( + HeaderName::from_str(key.trim()).map_err(|_| make_err())?, + HeaderValue::from_str(val.trim()).map_err(|_| make_err())?, + ); + } + + client_builder = client_builder.default_headers(headers); + let client = client_builder .build() .map_err(|e| RuntimeClientError::ProviderError(e.into()))?; - let provider = Http::new_with_client(self.url.clone(), client); #[allow(clippy::box_default)] @@ -190,6 +199,57 @@ impl RuntimeClient { } } +impl RuntimeClientBuilder { + /// Create new RuntimeClientBuilder + pub fn new( + url: Url, + max_retry: u32, + timeout_retry: u32, + initial_backoff: u64, + timeout: Duration, + compute_units_per_second: u64, + ) -> Self { + Self { + url, + max_retry, + timeout, + timeout_retry, + initial_backoff, + compute_units_per_second, + jwt: None, + headers: vec![], + } + } + + /// Set jwt to use with RuntimeClient + pub fn with_jwt(mut self, jwt: Option) -> Self { + self.jwt = jwt; + self + } + + /// Set http headers to use with RuntimeClient + /// Only works with http/https schemas + pub fn with_headers(mut self, headers: Vec) -> Self { + self.headers = headers; + self + } + + /// Builds RuntimeClient instance + pub fn build(self) -> RuntimeClient { + RuntimeClient { + client: Arc::new(RwLock::new(None)), + url: self.url, + max_retry: self.max_retry, + timeout_retry: self.timeout_retry, + initial_backoff: self.initial_backoff, + timeout: self.timeout, + compute_units_per_second: self.compute_units_per_second, + jwt: self.jwt, + headers: self.headers, + } + } +} + #[cfg(windows)] fn url_to_file_path(url: &Url) -> Result { const PREFIX: &str = "file:///pipe/"; From 65e7f98fbd251e90a08cae607e0aeaf0cf2ec79d Mon Sep 17 00:00:00 2001 From: Inphi Date: Fri, 3 Nov 2023 11:24:56 -0400 Subject: [PATCH 0227/1963] fix(forge): add coverage to test setUp (#6123) * fix(forge): add coverage to test setUp * Update crates/forge/src/runner.rs --------- Co-authored-by: evalir --- .../evm/evm/src/executors/invariant/funcs.rs | 16 ++++ crates/evm/evm/src/executors/mod.rs | 5 +- crates/forge/src/result.rs | 14 +++- crates/forge/src/runner.rs | 75 ++++++++++++------- crates/forge/tests/cli/coverage.rs | 72 ++++++++++++++++++ 5 files changed, 154 insertions(+), 28 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index bc82290e4d497..e4b1454f5a1d7 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -5,6 +5,7 @@ use alloy_json_abi::Function; use ethers::types::Log; use foundry_common::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CALLER; +use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::invariant::{BasicTxDetails, InvariantContract}; use foundry_evm_traces::{load_contracts, TraceKind, Traces}; use revm::primitives::U256; @@ -72,6 +73,7 @@ pub fn replay_run( mut ided_contracts: ContractsByAddress, logs: &mut Vec, traces: &mut Traces, + coverage: &mut Option, func: Function, inputs: Vec, ) { @@ -89,6 +91,20 @@ pub fn replay_run( logs.extend(call_result.logs); traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); + let old_coverage = std::mem::take(coverage); + match (old_coverage, call_result.coverage) { + (Some(old_coverage), Some(call_coverage)) => { + *coverage = Some(old_coverage.merge(call_coverage)); + } + (None, Some(call_coverage)) => { + *coverage = Some(call_coverage); + } + (Some(old_coverage), None) => { + *coverage = Some(old_coverage); + } + (None, None) => {} + } + // Identify newly generated contracts, if they exist. ided_contracts.extend(load_contracts( vec![(TraceKind::Execution, call_result.traces.clone().unwrap())], diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index f13f6d5711858..024b9880b198e 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -366,6 +366,7 @@ impl Executor { debug, script_wallets, env, + coverage, .. } = result; @@ -421,7 +422,7 @@ impl Executor { trace!(address=?address, "deployed contract"); - Ok(DeployResult { address, gas_used, gas_refunded, logs, traces, debug, env }) + Ok(DeployResult { address, gas_used, gas_refunded, logs, traces, debug, env, coverage }) } /// Deploys a contract and commits the new state to the underlying database. @@ -597,6 +598,8 @@ pub struct DeployResult { pub debug: Option, /// The `revm::Env` after deployment pub env: Env, + /// The coverage info collected during the deployment + pub coverage: Option, } /// The result of a call. diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index d46be910b18eb..f2e9d522f3072 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -230,6 +230,8 @@ pub struct TestSetup { pub labeled_addresses: BTreeMap, /// The reason the setup failed, if it did pub reason: Option, + /// Coverage info during setup + pub coverage: Option, } impl TestSetup { @@ -261,8 +263,9 @@ impl TestSetup { logs: Vec, traces: Traces, labeled_addresses: BTreeMap, + coverage: Option, ) -> Self { - Self { address, logs, traces, labeled_addresses, reason: None } + Self { address, logs, traces, labeled_addresses, reason: None, coverage } } pub fn failed_with( @@ -271,7 +274,14 @@ impl TestSetup { labeled_addresses: BTreeMap, reason: String, ) -> Self { - Self { address: Address::ZERO, logs, traces, labeled_addresses, reason: Some(reason) } + Self { + address: Address::ZERO, + logs, + traces, + labeled_addresses, + reason: Some(reason), + coverage: None, + } } pub fn failed(reason: String) -> Self { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index d3e414c2e15a2..b57866b26dfd5 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -12,6 +12,7 @@ use foundry_common::{ use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_evm::{ constants::CALLER, + coverage::HitMaps, decode::decode_console_logs, executors::{ fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, @@ -136,28 +137,30 @@ impl<'a> ContractRunner<'a> { // Optionally call the `setUp` function let setup = if setup { trace!("setting up"); - let (setup_logs, setup_traces, labeled_addresses, reason) = - match self.executor.setup(None, address) { - Ok(CallResult { traces, labels, logs, .. }) => { - trace!(contract = ?address, "successfully setUp test"); - (logs, traces, labels, None) - } - Err(EvmError::Execution(err)) => { - let ExecutionErr { traces, labels, logs, reason, .. } = *err; - error!(reason = ?reason, contract = ?address, "setUp failed"); - (logs, traces, labels, Some(format!("Setup failed: {reason}"))) - } - Err(err) => { - error!(reason=?err, contract= ?address, "setUp failed"); - (Vec::new(), None, BTreeMap::new(), Some(format!("Setup failed: {err}"))) - } - }; + let (setup_logs, setup_traces, labeled_addresses, reason, coverage) = match self + .executor + .setup(None, address) + { + Ok(CallResult { traces, labels, logs, coverage, .. }) => { + trace!(contract = ?address, "successfully setUp test"); + (logs, traces, labels, None, coverage) + } + Err(EvmError::Execution(err)) => { + let ExecutionErr { traces, labels, logs, reason, .. } = *err; + error!(reason = ?reason, contract = ?address, "setUp failed"); + (logs, traces, labels, Some(format!("Setup failed: {reason}")), None) + } + Err(err) => { + error!(reason=?err, contract= ?address, "setUp failed"); + (Vec::new(), None, BTreeMap::new(), Some(format!("Setup failed: {err}")), None) + } + }; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(setup_logs); - TestSetup { address, logs, traces, labeled_addresses, reason } + TestSetup { address, logs, traces, labeled_addresses, reason, coverage } } else { - TestSetup::success(address, logs, traces, Default::default()) + TestSetup::success(address, logs, traces, Default::default(), None) }; Ok(setup) @@ -225,7 +228,7 @@ impl<'a> ContractRunner<'a> { logs: setup.logs, kind: TestKind::Standard(0), traces: setup.traces, - coverage: None, + coverage: setup.coverage, labeled_addresses: setup.labeled_addresses, ..Default::default() }, @@ -297,7 +300,9 @@ impl<'a> ContractRunner<'a> { /// similar to `eth_call`. #[instrument(name = "test", skip_all, fields(name = %func.signature(), %should_fail))] pub fn run_test(&self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { - let TestSetup { address, mut logs, mut traces, mut labeled_addresses, .. } = setup; + let TestSetup { + address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. + } = setup; // Run unit test let mut executor = self.executor.clone(); @@ -318,7 +323,7 @@ impl<'a> ContractRunner<'a> { stipend, logs: execution_logs, traces: execution_trace, - coverage, + coverage: execution_coverage, labels: new_labels, state_changeset, debug, @@ -329,6 +334,8 @@ impl<'a> ContractRunner<'a> { labeled_addresses.extend(new_labels); logs.extend(execution_logs); debug_arena = debug; + coverage = merge_coverages(coverage, execution_coverage); + (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) } Err(EvmError::Execution(err)) => { @@ -415,7 +422,7 @@ impl<'a> ContractRunner<'a> { trace!(target: "forge::test::fuzz", "executing invariant test for {:?}", func.name); let empty = ContractsByArtifact::default(); let project_contracts = known_contracts.unwrap_or(&empty); - let TestSetup { address, logs, traces, labeled_addresses, .. } = setup; + let TestSetup { address, logs, traces, labeled_addresses, coverage, .. } = setup; // First, run the test normally to see if it needs to be skipped. if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<_, _>( @@ -433,6 +440,7 @@ impl<'a> ContractRunner<'a> { traces, labeled_addresses, kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, + coverage, ..Default::default() } }; @@ -472,6 +480,7 @@ impl<'a> ContractRunner<'a> { let reason = error .as_ref() .and_then(|err| (!err.revert_reason.is_empty()).then(|| err.revert_reason.clone())); + let mut coverage = coverage.clone(); match error { // If invariants were broken, replay the error to collect logs and traces Some(error @ InvariantFuzzError { test_error: TestError::Fail(_, _), .. }) => { @@ -499,6 +508,7 @@ impl<'a> ContractRunner<'a> { identified_contracts.clone(), &mut logs, &mut traces, + &mut coverage, func.clone(), last_run_inputs.clone(), ); @@ -521,7 +531,7 @@ impl<'a> ContractRunner<'a> { decoded_logs: decode_console_logs(&logs), logs, kind, - coverage: None, // TODO ? + coverage, traces, labeled_addresses: labeled_addresses.clone(), ..Default::default() // TODO collect debug traces on the last run or error @@ -537,7 +547,9 @@ impl<'a> ContractRunner<'a> { setup: TestSetup, fuzz_config: FuzzConfig, ) -> TestResult { - let TestSetup { address, mut logs, mut traces, mut labeled_addresses, .. } = setup; + let TestSetup { + address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. + } = setup; // Run fuzz test let start = Instant::now(); @@ -561,6 +573,7 @@ impl<'a> ContractRunner<'a> { kind: TestKind::Standard(0), debug, breakpoints, + coverage, ..Default::default() } } @@ -614,6 +627,7 @@ impl<'a> ContractRunner<'a> { logs.append(&mut result.logs); labeled_addresses.append(&mut result.labeled_addresses); traces.extend(result.traces.map(|traces| (TraceKind::Execution, traces))); + coverage = merge_coverages(coverage, result.coverage); // Record test execution time debug!( @@ -632,10 +646,21 @@ impl<'a> ContractRunner<'a> { logs, kind, traces, - coverage: result.coverage, + coverage, labeled_addresses, debug, breakpoints, } } } + +/// Utility function to merge coverage options +fn merge_coverages(mut coverage: Option, other: Option) -> Option { + let old_coverage = std::mem::take(&mut coverage); + match (old_coverage, other) { + (Some(old_coverage), Some(other)) => Some(old_coverage.merge(other)), + (None, Some(other)) => Some(other), + (Some(old_coverage), None) => Some(old_coverage), + (None, None) => None, + } +} diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index eb950832dfd18..5f8f23f407bdb 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1,4 +1,5 @@ use foundry_test_utils::{forgetest, TestCommand, TestProject}; +use regex::Regex; forgetest!(basic_coverage, |_prj: TestProject, mut cmd: TestCommand| { cmd.args(["coverage"]); @@ -14,3 +15,74 @@ forgetest!(report_file_coverage, |prj: TestProject, mut cmd: TestCommand| { ]); cmd.assert_success(); }); + +forgetest!(test_setup_coverage, |prj: TestProject, mut cmd: TestCommand| { + prj.insert_ds_test(); + prj.inner() + .add_source( + "AContract.sol", + r#" +// SPDX-license-identifier: MIT +pragma solidity ^0.8.0; + +contract AContract { + int public i; + + function init() public { + i = 0; + } + + function foo() public { + i = 1; + } +} + "#, + ) + .unwrap(); + + prj.inner() + .add_source( + "AContractTest.sol", + r#" +// SPDX-License-Identifier: MIT +pragma solidity 0.8.10; +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + AContract a; + + function setUp() public { + a = new AContract(); + a.init(); + } + + function testFoo() public { + a.foo(); + } +} + "#, + ) + .unwrap(); + + let lcov_info = prj.root().join("lcov.info"); + cmd.arg("coverage").args([ + "--report".to_string(), + "lcov".to_string(), + "--report-file".to_string(), + lcov_info.to_str().unwrap().to_string(), + ]); + cmd.assert_success(); + assert!(lcov_info.exists()); + + let lcov_data = std::fs::read_to_string(lcov_info).unwrap(); + // AContract.init must be hit at least once + let re = Regex::new(r"FNDA:(\d+),AContract\.init").unwrap(); + assert!(lcov_data.lines().any(|line| re.captures(line).map_or(false, |caps| caps + .get(1) + .unwrap() + .as_str() + .parse::() + .unwrap() > + 0))); +}); From 8d513dc3648054e5d0d2aad2c9603967c60d68bc Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov <62447812+klkvr@users.noreply.github.com> Date: Fri, 3 Nov 2023 19:42:44 +0400 Subject: [PATCH 0228/1963] Add support for events and errors in `forge selectors upload` (#6205) * Add support for events and errors in selectors upload * remove --- crates/common/src/selectors.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 42cb03c87444b..273a44e903e60 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -299,18 +299,23 @@ impl SignEthClient { let request = match data { SelectorImportData::Abi(abis) => { - let names: Vec = abis + let functions_and_errors: Vec = abis .iter() .flat_map(|abi| { abi.abi .functions() - .map(|func| { - func.signature().split(':').next().unwrap_or("").to_string() - }) + .map(|func| func.signature()) + .chain(abi.abi.errors().map(|error| error.signature())) .collect::>() }) .collect(); - SelectorImportRequest { function: names, event: Default::default() } + + let events = abis + .iter() + .flat_map(|abi| abi.abi.events().map(|event| event.signature())) + .collect::>(); + + SelectorImportRequest { function: functions_and_errors, event: events } } SelectorImportData::Raw(raw) => { SelectorImportRequest { function: raw.function, event: raw.event } From b85ff16b78ca08f71c33c84f0cc15dc73ef705f3 Mon Sep 17 00:00:00 2001 From: sakotn <105765683+sakotn@users.noreply.github.com> Date: Fri, 3 Nov 2023 17:43:04 +0200 Subject: [PATCH 0229/1963] feat: cast wallet generation - json output and many wallets generation (#6160) * Add multiple wallet creation and JSON output support This change extends wallet creation functionality to allow the generation of multiple wallets. It introduces a new CLI option --number that allows the user to specify the number of wallets to generate. Additionally, a new --json flag is added that provides the option for users to output wallet information in JSON format. This feature will be especially useful for scripts or automated processes that need to interact with the wallet. It improves usability and flexibility of the wallet creation process. * Improve keystore creation success message * fix * Update mod.rs Co-authored-by: evalir * Update mod.rs Co-authored-by: evalir * Fix --------- Co-authored-by: auebasota1337 <105765683+auebasota1337@users.noreply.github.com> Co-authored-by: evalir --- crates/cast/bin/cmd/wallet/mod.rs | 62 ++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 6f14585e52786..b80c0f1f7c3e5 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -10,6 +10,7 @@ use foundry_cli::opts::{RawWallet, Wallet}; use foundry_common::fs; use foundry_config::Config; use foundry_utils::types::{ToAlloy, ToEthers}; +use serde_json::json; use std::path::Path; use yansi::Paint; @@ -36,6 +37,14 @@ pub enum WalletSubcommands { /// This is UNSAFE to use and we recommend using the --password. #[clap(long, requires = "path", env = "CAST_PASSWORD", value_name = "PASSWORD")] unsafe_password: Option, + + /// Number of wallets to generate. + #[clap(long, short, default_value = "1")] + number: u32, + + /// Output generated wallets as JSON. + #[clap(long, short, default_value = "false")] + json: bool, }, /// Generate a vanity address. @@ -120,9 +129,10 @@ pub enum WalletSubcommands { impl WalletSubcommands { pub async fn run(self) -> Result<()> { match self { - WalletSubcommands::New { path, unsafe_password, .. } => { + WalletSubcommands::New { path, unsafe_password, number, json, .. } => { let mut rng = thread_rng(); + let mut json_values = if json { Some(vec![]) } else { None }; if let Some(path) = path { let path = dunce::canonicalize(path)?; if !path.is_dir() { @@ -137,16 +147,50 @@ impl WalletSubcommands { rpassword::prompt_password("Enter secret: ")? }; - let (wallet, uuid) = - LocalWallet::new_keystore(&path, &mut rng, password, None)?; + for _ in 0..number { + let (wallet, uuid) = + LocalWallet::new_keystore(&path, &mut rng, password.clone(), None)?; + + if let Some(json) = json_values.as_mut() { + json.push(json!({ + "address": wallet.address().to_alloy().to_checksum(None), + "path": format!("{}", path.join(uuid).display()), + } + )); + } else { + println!( + "Created new encrypted keystore file: {}", + path.join(uuid).display() + ); + println!("Address: {}", wallet.address().to_alloy().to_checksum(None)); + } + } - println!("Created new encrypted keystore file: {}", path.join(uuid).display()); - println!("Address: {}", wallet.address().to_alloy().to_checksum(None)); + if let Some(json) = json_values.as_ref() { + println!("{}", serde_json::to_string_pretty(json)?); + } } else { - let wallet = LocalWallet::new(&mut rng); - println!("Successfully created new keypair."); - println!("Address: {}", wallet.address().to_alloy().to_checksum(None)); - println!("Private key: 0x{}", hex::encode(wallet.signer().to_bytes())); + for _ in 0..number { + let wallet = LocalWallet::new(&mut rng); + + if let Some(json) = json_values.as_mut() { + json.push(json!({ + "address": wallet.address().to_alloy().to_checksum(None), + "private_key": format!("0x{}", hex::encode(wallet.signer().to_bytes())), + })) + } else { + println!("Successfully created new keypair."); + println!( + "Address: {}", + wallet.address().to_alloy().to_checksum(None) + ); + println!("Private key: 0x{}", hex::encode(wallet.signer().to_bytes())); + } + } + + if let Some(json) = json_values.as_ref() { + println!("{}", serde_json::to_string_pretty(json)?); + } } } WalletSubcommands::Vanity(cmd) => { From 691e1bddf882d581a9369c6c8525ed18894acd44 Mon Sep 17 00:00:00 2001 From: teddav Date: Fri, 3 Nov 2023 17:42:02 +0100 Subject: [PATCH 0230/1963] feat(anvil/cast): mnemonic generation (#6066) * feat(anvil): add random mnemonic generation and generation from seed to Anvil * Cast: added a new 'wallet' option to generate a mnemonic and associated accounts * fix clippy * fix fmt * update anvil option to 'unsafe' * chore: remove unwraps --------- Co-authored-by: Enrique Ortiz --- Cargo.lock | 1 + crates/anvil/Cargo.toml | 1 + crates/anvil/src/cmd.rs | 35 +++++++++++++++++++++++++-- crates/cast/bin/cmd/wallet/mod.rs | 39 ++++++++++++++++++++++++++++++- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b386e69d85e83..0b06e1417b469 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -305,6 +305,7 @@ dependencies = [ "memory-db", "parking_lot", "pretty_assertions", + "rand 0.8.5", "serde", "serde_json", "serde_repr", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 4183cc13396af..1ec423bfc6dab 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -61,6 +61,7 @@ thiserror = "1" yansi = "0.5" tempfile = "3" itertools.workspace = true +rand = "0.8" # cli clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 96c4d86de815f..ff31419c3a162 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -7,9 +7,13 @@ use crate::{ use anvil_server::ServerConfig; use clap::Parser; use core::fmt; -use ethers::utils::WEI_IN_ETHER; +use ethers::{ + signers::coins_bip39::{English, Mnemonic}, + utils::WEI_IN_ETHER, +}; use foundry_config::{Chain, Config}; use futures::FutureExt; +use rand::{rngs::StdRng, SeedableRng}; use std::{ future::Future, net::IpAddr, @@ -45,9 +49,25 @@ pub struct NodeArgs { pub timestamp: Option, /// BIP39 mnemonic phrase used for generating accounts. - #[clap(long, short)] + /// Cannot be used if `mnemonic_random` or `mnemonic_seed` are used + #[clap(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"])] pub mnemonic: Option, + /// Automatically generates a BIP39 mnemonic phrase, and derives accounts from it. + /// Cannot be used with other `mnemonic` options + /// You can specify the number of words you want in the mnemonic. + /// [default: 12] + #[clap(long, conflicts_with_all = &["mnemonic", "mnemonic_seed"], default_missing_value = "12", num_args(0..=1))] + pub mnemonic_random: Option, + + /// Generates a BIP39 mnemonic phrase from a given seed + /// Cannot be used with other `mnemonic` options + /// + /// CAREFUL: this is NOT SAFE and should only be used for testing. + /// Never use the private keys generated in production. + #[clap(long = "mnemonic-seed-unsafe", conflicts_with_all = &["mnemonic", "mnemonic_random"])] + pub mnemonic_seed: Option, + /// Sets the derivation path of the child key to be derived. /// /// [default: m/44'/60'/0'/0/] @@ -219,6 +239,17 @@ impl NodeArgs { .chain_id(self.evm_opts.chain_id.unwrap_or_else(|| CHAIN_ID.into())); if let Some(ref mnemonic) = self.mnemonic { gen = gen.phrase(mnemonic); + } else if let Some(count) = self.mnemonic_random { + let mut rng = rand::thread_rng(); + let mnemonic = match Mnemonic::::new_with_count(&mut rng, count) { + Ok(mnemonic) => mnemonic.to_phrase(), + Err(_) => DEFAULT_MNEMONIC.to_string(), + }; + gen = gen.phrase(mnemonic); + } else if let Some(seed) = self.mnemonic_seed { + let mut seed = StdRng::seed_from_u64(seed); + let mnemonic = Mnemonic::::new(&mut seed).to_phrase(); + gen = gen.phrase(mnemonic); } if let Some(ref derivation) = self.derivation_path { gen = gen.derivation_path(derivation); diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index b80c0f1f7c3e5..548a406437e99 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -2,9 +2,13 @@ use alloy_primitives::Address; use clap::Parser; use ethers::{ core::rand::thread_rng, - signers::{LocalWallet, Signer}, + signers::{ + coins_bip39::{English, Mnemonic}, + LocalWallet, MnemonicBuilder, Signer, + }, types::{transaction::eip712::TypedData, Signature}, }; +use ethers_core::utils::to_checksum; use eyre::{Context, Result}; use foundry_cli::opts::{RawWallet, Wallet}; use foundry_common::fs; @@ -47,6 +51,18 @@ pub enum WalletSubcommands { json: bool, }, + /// Generates a random BIP39 mnemonic phrase + #[clap(visible_alias = "nm")] + NewMnemonic { + /// Number of words for the mnemonic + #[clap(long, short, default_value = "12")] + words: usize, + + /// Number of accounts to display + #[clap(long, short, default_value = "1")] + accounts: u8, + }, + /// Generate a vanity address. #[clap(visible_alias = "va")] Vanity(VanityArgs), @@ -193,6 +209,27 @@ impl WalletSubcommands { } } } + WalletSubcommands::NewMnemonic { words, accounts } => { + let mut rng = thread_rng(); + let phrase = Mnemonic::::new_with_count(&mut rng, words)?.to_phrase(); + + let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); + let derivation_path = "m/44'/60'/0'/0/"; + let wallets = (0..accounts) + .map(|i| builder.clone().derivation_path(&format!("{derivation_path}{i}"))) + .collect::, _>>()?; + let wallets = + wallets.into_iter().map(|b| b.build()).collect::, _>>()?; + + println!("{}", Paint::green("Successfully generated a new mnemonic.")); + println!("Phrase:\n{phrase}"); + println!("\nAccounts:"); + for (i, wallet) in wallets.iter().enumerate() { + println!("- Account {i}:"); + println!("Address: {}", to_checksum(&wallet.address(), None)); + println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); + } + } WalletSubcommands::Vanity(cmd) => { cmd.run()?; } From eea2b7830b166836bbb6049a46904c719c9c1db6 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 3 Nov 2023 14:42:39 -0400 Subject: [PATCH 0231/1963] fix: remove harcoded hex prefix from calldata (#6209) --- crates/evm/fuzz/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index b4bb0eb2106e7..e3e5a04e9c742 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -109,7 +109,7 @@ impl fmt::Display for BaseCounterExample { if let Some(sig) = &self.signature { write!(f, "calldata={sig}")? } else { - write!(f, "calldata=0x{}", self.calldata)? + write!(f, "calldata={}", self.calldata)? } write!(f, ", args=[{args}]") From f0528ad49c9565bc7bc1ebd24b0ce5be9ae488fe Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 3 Nov 2023 16:21:15 -0400 Subject: [PATCH 0232/1963] feat: loadAllocs cheatcode (Rebased) (#6207) * chore: add test & fixture * feat: add cheatcode impl * chore: remove useless import * chore: fmt * chore: switch to foundry fs, make try_for_each loop * chore: support genesis format * chore: clippy --- crates/cheatcodes/assets/cheatcodes.json | 20 +++++++ crates/cheatcodes/defs/src/vm.rs | 4 ++ crates/cheatcodes/src/evm.rs | 27 +++++++++- crates/evm/core/src/abi/mod.rs | 2 +- crates/evm/core/src/backend/fuzz.rs | 11 +++- crates/evm/core/src/backend/mod.rs | 61 ++++++++++++++++++++- testdata/cheats/Vm.sol | 1 + testdata/cheats/loadAllocs.t.sol | 69 ++++++++++++++++++++++++ testdata/fixtures/Json/test_allocs.json | 15 ++++++ 9 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 testdata/cheats/loadAllocs.t.sol create mode 100644 testdata/fixtures/Json/test_allocs.json diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index b93cae6fd1c27..3b55e49c4901b 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2205,6 +2205,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "loadAllocs", + "description": "Load a genesis JSON file's `allocs` into the in-memory revm state.", + "declaration": "function loadAllocs(string calldata pathToAllocsJson) external;", + "visibility": "external", + "mutability": "", + "signature": "loadAllocs(string)", + "selector": "0xb3a056d7", + "selectorBytes": [ + 179, + 160, + 86, + 215 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "makePersistent_0", diff --git a/crates/cheatcodes/defs/src/vm.rs b/crates/cheatcodes/defs/src/vm.rs index c1bb5c4d78bf3..2061dac26d2aa 100644 --- a/crates/cheatcodes/defs/src/vm.rs +++ b/crates/cheatcodes/defs/src/vm.rs @@ -148,6 +148,10 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function load(address target, bytes32 slot) external view returns (bytes32 data); + /// Load a genesis JSON file's `allocs` into the in-memory revm state. + #[cheatcode(group = Evm, safety = Unsafe)] + function loadAllocs(string calldata pathToAllocsJson) external; + /// Signs data. #[cheatcode(group = Evm, safety = Safe)] function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 3ac9861112d61..c1cdcc1b22692 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -3,14 +3,16 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, Bytes, U256}; use alloy_sol_types::SolValue; +use ethers_core::utils::{Genesis, GenesisAccount}; use ethers_signers::Signer; +use foundry_common::fs::read_json_file; use foundry_evm_core::backend::DatabaseExt; use foundry_utils::types::ToAlloy; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, EVMData, }; -use std::collections::HashMap; +use std::{collections::HashMap, path::Path}; mod fork; pub(crate) mod mapping; @@ -62,6 +64,29 @@ impl Cheatcode for loadCall { } } +impl Cheatcode for loadAllocsCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { pathToAllocsJson } = self; + + let path = Path::new(pathToAllocsJson); + ensure!(path.exists(), "allocs file does not exist: {pathToAllocsJson}"); + + // Let's first assume we're reading a genesis.json file. + let allocs: HashMap = match read_json_file::(path) { + Ok(genesis) => genesis.alloc.into_iter().map(|(k, g)| (k.to_alloy(), g)).collect(), + // If that fails, let's try reading a file with just the genesis accounts. + Err(_) => read_json_file(path)?, + }; + + // Then, load the allocs into the database. + ccx.data + .db + .load_allocs(&allocs, &mut ccx.data.journaled_state) + .map(|_| Vec::default()) + .map_err(|e| fmt_err!("failed to load allocs: {e}")) + } +} + impl Cheatcode for sign_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey, digest } = self; diff --git a/crates/evm/core/src/abi/mod.rs b/crates/evm/core/src/abi/mod.rs index 7cbe79e27693e..2e9412cb63e75 100644 --- a/crates/evm/core/src/abi/mod.rs +++ b/crates/evm/core/src/abi/mod.rs @@ -3,7 +3,7 @@ pub use foundry_abi::{ console::{self, ConsoleEvents, CONSOLE_ABI}, hardhat_console::{self, HardhatConsoleCalls, HARDHATCONSOLE_ABI as HARDHAT_CONSOLE_ABI}, - hevm::{self, HEVMCalls, HEVM_ABI}, + hevm::HEVM_ABI, }; use once_cell::sync::Lazy; use std::collections::HashMap; diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index 084f8c6e2eccb..e08266f6673d6 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -7,12 +7,13 @@ use crate::{ fork::{CreateFork, ForkId}, }; use alloy_primitives::{Address, B256, U256}; +use ethers::utils::GenesisAccount; use revm::{ db::DatabaseRef, primitives::{AccountInfo, Bytecode, Env, ResultAndState}, Database, Inspector, JournaledState, }; -use std::borrow::Cow; +use std::{borrow::Cow, collections::HashMap}; /// A wrapper around `Backend` that ensures only `revm::DatabaseRef` functions are called. /// @@ -198,6 +199,14 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { self.backend.diagnose_revert(callee, journaled_state) } + fn load_allocs( + &mut self, + allocs: &HashMap, + journaled_state: &mut JournaledState, + ) -> Result<(), DatabaseError> { + self.backend_mut(&Env::default()).load_allocs(allocs, journaled_state) + } + fn is_persistent(&self, acc: &Address) -> bool { self.backend.is_persistent(acc) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 59b45906c7184..be6d855b46593 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -10,6 +10,7 @@ use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; use ethers::{ prelude::Block, types::{BlockNumber, Transaction}, + utils::GenesisAccount, }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_utils::types::{ToAlloy, ToEthers}; @@ -19,7 +20,7 @@ use revm::{ precompile::{Precompiles, SpecId}, primitives::{ Account, AccountInfo, Bytecode, CreateScheme, Env, HashMap as Map, Log, ResultAndState, - TransactTo, KECCAK_EMPTY, + StorageSlot, TransactTo, KECCAK_EMPTY, }, Database, DatabaseCommit, Inspector, JournaledState, EVM, }; @@ -248,6 +249,15 @@ pub trait DatabaseExt: Database { journaled_state: &JournaledState, ) -> Option; + /// Loads the account allocs from the given `allocs` map into the passed [JournaledState]. + /// + /// Returns [Ok] if all accounts were successfully inserted into the journal, [Err] otherwise. + fn load_allocs( + &mut self, + allocs: &HashMap, + journaled_state: &mut JournaledState, + ) -> Result<(), DatabaseError>; + /// Returns true if the given account is currently marked as persistent. fn is_persistent(&self, acc: &Address) -> bool; @@ -1263,6 +1273,55 @@ impl DatabaseExt for Backend { None } + /// Loads the account allocs from the given `allocs` map into the passed [JournaledState]. + /// + /// Returns [Ok] if all accounts were successfully inserted into the journal, [Err] otherwise. + fn load_allocs( + &mut self, + allocs: &HashMap, + journaled_state: &mut JournaledState, + ) -> Result<(), DatabaseError> { + // Loop through all of the allocs defined in the map and commit them to the journal. + for (addr, acc) in allocs.iter() { + // Fetch the account from the journaled state. Will create a new account if it does + // not already exist. + let (state_acc, _) = journaled_state.load_account(*addr, self)?; + + // Set the account's bytecode and code hash, if the `bytecode` field is present. + if let Some(bytecode) = acc.code.as_ref() { + state_acc.info.code_hash = keccak256(bytecode); + let bytecode = Bytecode::new_raw(bytecode.0.clone().into()); + state_acc.info.code = Some(bytecode); + } + + // Set the account's storage, if the `storage` field is present. + if let Some(storage) = acc.storage.as_ref() { + state_acc.storage = storage + .iter() + .map(|(slot, value)| { + let slot = U256::from_be_bytes(slot.0); + ( + slot, + StorageSlot::new_changed( + state_acc + .storage + .get(&slot) + .map(|s| s.present_value) + .unwrap_or_default(), + U256::from_be_bytes(value.0), + ), + ) + }) + .collect(); + } + // Set the account's nonce and balance. + state_acc.info.nonce = acc.nonce.unwrap_or_default(); + state_acc.info.balance = acc.balance.to_alloy(); + } + + Ok(()) + } + fn is_persistent(&self, acc: &Address) -> bool { self.inner.persistent_accounts.contains(acc) } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 0865a9c779eb4..42d3fa63d30f9 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -112,6 +112,7 @@ interface Vm { function keyExists(string calldata json, string calldata key) external view returns (bool); function label(address account, string calldata newLabel) external; function load(address target, bytes32 slot) external view returns (bytes32 data); + function loadAllocs(string calldata pathToAllocsJson) external; function makePersistent(address account) external; function makePersistent(address account0, address account1) external; function makePersistent(address account0, address account1, address account2) external; diff --git a/testdata/cheats/loadAllocs.t.sol b/testdata/cheats/loadAllocs.t.sol new file mode 100644 index 0000000000000..52c335f6f5baa --- /dev/null +++ b/testdata/cheats/loadAllocs.t.sol @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract LoadAllocsTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + string allocsPath; + address constant ALLOCD = address(0x420); + address constant ALLOCD_B = address(0x421); + + function setUp() public { + allocsPath = string.concat(vm.projectRoot(), "/fixtures/Json/test_allocs.json"); + } + + function testLoadAllocsStatic() public { + vm.loadAllocs(allocsPath); + + // Balance should be `0xabcd` + assertEq(ALLOCD.balance, 0xabcd); + + // Code should be a simple store / return, returning `0x42` + (bool success, bytes memory rd) = ALLOCD.staticcall(""); + assertTrue(success); + uint256 ret = abi.decode(rd, (uint256)); + assertEq(ret, 0x42); + + // Storage should have been set in slot 0x1, equal to `0xbeef` + assertEq(uint256(vm.load(ALLOCD, bytes32(uint256(0x10 << 248)))), 0xbeef); + } + + function testLoadAllocsOverride() public { + // Populate the alloc'd account's code. + vm.etch(ALLOCD, hex"FF"); + assertEq(ALLOCD.code, hex"FF"); + + // Store something in the alloc'd storage slot. + bytes32 slot = bytes32(uint256(0x10 << 248)); + vm.store(ALLOCD, slot, bytes32(uint256(0xBADC0DE))); + assertEq(uint256(vm.load(ALLOCD, slot)), 0xBADC0DE); + + // Populate balance. + vm.deal(ALLOCD, 0x1234); + assertEq(ALLOCD.balance, 0x1234); + + vm.loadAllocs(allocsPath); + + // Info should have changed. + assertTrue(keccak256(ALLOCD.code) != keccak256(hex"FF")); + assertEq(uint256(vm.load(ALLOCD, slot)), 0xbeef); + assertEq(ALLOCD.balance, 0xabcd); + } + + function testLoadAllocsPartialOverride() public { + // Populate the alloc'd account's code. + vm.etch(ALLOCD_B, hex"FF"); + assertEq(ALLOCD_B.code, hex"FF"); + + // Populate balance. + vm.deal(ALLOCD_B, 0x1234); + assertEq(ALLOCD_B.balance, 0x1234); + + vm.loadAllocs(allocsPath); + + assertEq(ALLOCD_B.code, hex"FF"); + assertEq(ALLOCD_B.balance, 0); + } +} diff --git a/testdata/fixtures/Json/test_allocs.json b/testdata/fixtures/Json/test_allocs.json new file mode 100644 index 0000000000000..32be846a5cb80 --- /dev/null +++ b/testdata/fixtures/Json/test_allocs.json @@ -0,0 +1,15 @@ +{ + "0x0000000000000000000000000000000000000420": { + "balance": "0xabcd", + "code": "0x604260005260206000F3", + "storage": { + "0x1000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000beef" + } + }, + "0x0000000000000000000000000000000000000421": { + "balance": "0x0", + "storage": { + "0x1000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000beef" + } + } +} From fa6b39c3f0c96a163d083628c0badd2e5ec43bdf Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 4 Nov 2023 00:26:13 +0100 Subject: [PATCH 0233/1963] perf: better cast create2 (#6212) * perf: better cast create2 * chore: clippy * docs * fix: enforce either code or code hash --- crates/cast/bin/cmd/create2.rs | 240 +++++++++++++++++---------------- 1 file changed, 122 insertions(+), 118 deletions(-) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index fa4010bd0bdbb..9af59c92bb7a5 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -1,9 +1,14 @@ use alloy_primitives::{keccak256, Address, B256, U256}; use clap::Parser; use eyre::{Result, WrapErr}; -use rayon::prelude::*; use regex::RegexSetBuilder; -use std::{str::FromStr, time::Instant}; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, + time::Instant, +}; /// CLI arguments for `cast create2`. #[derive(Debug, Clone, Parser)] @@ -39,18 +44,22 @@ pub struct Create2Args { deployer: Address, /// Init code of the contract to be deployed. - #[clap(short, long, value_name = "HEX", default_value = "")] - init_code: String, + #[clap(short, long, value_name = "HEX")] + init_code: Option, /// Init code hash of the contract to be deployed. - #[clap(alias = "ch", long, value_name = "HASH")] + #[clap(alias = "ch", long, value_name = "HASH", required_unless_present = "init_code")] init_code_hash: Option, + + /// Number of threads to use. Defaults to and caps at the number of logical cores. + #[clap(short, long)] + jobs: Option, } #[allow(dead_code)] pub struct Create2Output { pub address: Address, - pub salt: U256, + pub salt: B256, } impl Create2Args { @@ -63,6 +72,7 @@ impl Create2Args { deployer, init_code, init_code_hash, + jobs, } = self; let mut regexs = vec![]; @@ -105,43 +115,85 @@ impl Create2Args { let regex = RegexSetBuilder::new(regexs).case_insensitive(!case_sensitive).build()?; let init_code_hash = if let Some(init_code_hash) = init_code_hash { - let mut a: [u8; 32] = [0; 32]; - let init_code_hash_bytes = hex::decode(init_code_hash)?; - assert!(init_code_hash_bytes.len() == 32, "init code hash should be 32 bytes long"); - a.copy_from_slice(&init_code_hash_bytes); - a.into() - } else { + let mut hash: [u8; 32] = [0; 32]; + hex::decode_to_slice(init_code_hash, &mut hash)?; + hash.into() + } else if let Some(init_code) = init_code { keccak256(hex::decode(init_code)?) + } else { + unreachable!(); }; + let mut n_threads = std::thread::available_parallelism().map_or(1, |n| n.get()); + if let Some(jobs) = jobs { + n_threads = n_threads.min(jobs); + } + if cfg!(test) { + n_threads = n_threads.min(2); + } + println!("Starting to generate deterministic contract address..."); + let mut handles = Vec::with_capacity(n_threads); + let found = Arc::new(AtomicBool::new(false)); let timer = Instant::now(); - let (salt, addr) = std::iter::repeat(()) - .par_bridge() - .map(|_| { - let salt = B256::random(); - - let addr = deployer.create2(salt, init_code_hash).to_checksum(None); - - (salt, addr) - }) - .find_any(move |(_, addr)| { - let addr = addr.to_string(); - let addr = addr.strip_prefix("0x").unwrap(); - regex.matches(addr).into_iter().count() == regex.patterns().len() - }) - .unwrap(); - - let salt = U256::from_be_bytes(*salt); - let address = Address::from_str(&addr).unwrap(); - - println!( - "Successfully found contract address in {} seconds.\nAddress: {}\nSalt: {}", - timer.elapsed().as_secs(), - addr, - salt - ); + // Loops through all possible salts in parallel until a result is found. + // Each thread iterates over `(i..).step_by(n_threads)`. + for i in 0..n_threads { + // Create local copies for the thread. + let increment = n_threads; + let regex = regex.clone(); + let regex_len = regex.patterns().len(); + let found = Arc::clone(&found); + handles.push(std::thread::spawn(move || { + // Read the first bytes of the salt as a usize to be able to increment it. + struct B256Aligned(B256, [usize; 0]); + let mut salt = B256Aligned(B256::ZERO, []); + // SAFETY: B256 is aligned to `usize`. + let salt_word = unsafe { &mut *salt.0.as_mut_ptr().cast::() }; + + // Important: set the salt to the start value, otherwise all threads loop over the + // same values. + *salt_word = i; + + let mut checksum = [0; 42]; + loop { + // Stop if a result was found in another thread. + if found.load(Ordering::Relaxed) { + break None; + } + + // Calculate the `CREATE2` address. + #[allow(clippy::needless_borrows_for_generic_args)] + let addr = deployer.create2(&salt.0, init_code_hash); + + // Check if the the regex matches the calculated address' checksum. + let _ = addr.to_checksum_raw(&mut checksum, None); + // SAFETY: stripping 2 ASCII bytes ("0x") off of an already valid UTF-8 string + // is safe. + let s = unsafe { std::str::from_utf8_unchecked(checksum.get_unchecked(2..)) }; + if regex.matches(s).into_iter().count() == regex_len { + // Notify other threads that we found a result. + found.store(true, Ordering::Relaxed); + break Some((salt.0, addr)); + } + + // Increment the salt for the next iteration. + *salt_word += increment; + } + })); + } + + let results = handles.into_iter().filter_map(|h| h.join().unwrap()).collect::>(); + println!("Successfully found contract address(es) in {:?}", timer.elapsed()); + for (i, (salt, address)) in results.iter().enumerate() { + if i > 0 { + println!("---"); + } + println!("Address: {address}\nSalt: {salt} ({})", U256::from_be_bytes(salt.0)); + } + + let (salt, address) = results.into_iter().next().unwrap(); Ok(Create2Output { address, salt }) } } @@ -156,58 +208,51 @@ fn get_regex_hex_string(s: String) -> Result { #[cfg(test)] mod tests { use super::*; + use std::str::FromStr; const DEPLOYER: &str = "0x4e59b44847b379578588920ca78fbf26c0b4956c"; #[test] fn basic_create2() { + let mk_args = |args: &[&str]| { + Create2Args::parse_from(["foundry-cli", "--init-code-hash=0x0000000000000000000000000000000000000000000000000000000000000000"].iter().chain(args)) + }; + // even hex chars - let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "aa"]); + let args = mk_args(&["--starts-with", "aa"]); let create2_out = args.run().unwrap(); - let address = create2_out.address; - let address = format!("{address:x}"); + assert!(format!("{:x}", create2_out.address).starts_with("aa")); - assert!(address.starts_with("aa")); + let args = mk_args(&["--ends-with", "bb"]); + let create2_out = args.run().unwrap(); + assert!(format!("{:x}", create2_out.address).ends_with("bb")); // odd hex chars - let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "aaa"]); + let args = mk_args(&["--starts-with", "aaa"]); let create2_out = args.run().unwrap(); - let address = create2_out.address; - let address = format!("{address:x}"); + assert!(format!("{:x}", create2_out.address).starts_with("aaa")); - assert!(address.starts_with("aaa")); + let args = mk_args(&["--ends-with", "bbb"]); + let create2_out = args.run().unwrap(); + assert!(format!("{:x}", create2_out.address).ends_with("bbb")); // even hex chars with 0x prefix - let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xaa"]); + let args = mk_args(&["--starts-with", "0xaa"]); let create2_out = args.run().unwrap(); - let address = create2_out.address; - let address = format!("{address:x}"); - - assert!(address.starts_with("aa")); + assert!(format!("{:x}", create2_out.address).starts_with("aa")); // odd hex chars with 0x prefix - let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xaaa"]); + let args = mk_args(&["--starts-with", "0xaaa"]); let create2_out = args.run().unwrap(); - let address = create2_out.address; - let address = format!("{address:x}"); - - assert!(address.starts_with("aaa")); - - // odd hex chars with 0x suffix - let args = Create2Args::parse_from(["foundry-cli", "--ends-with", "bb"]); - let create2_out = args.run().unwrap(); - let address = create2_out.address; - let address = format!("{address:x}"); - - assert!(address.ends_with("bb")); + assert!(format!("{:x}", create2_out.address).starts_with("aaa")); // check fails on wrong chars - let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "0xerr"]); + let args = mk_args(&["--starts-with", "0xerr"]); let create2_out = args.run(); assert!(create2_out.is_err()); // check fails on wrong x prefixed string provided - let args = Create2Args::parse_from(["foundry-cli", "--starts-with", "x00"]); + let args = mk_args(&["--starts-with", "x00"]); let create2_out = args.run(); assert!(create2_out.is_err()); } @@ -216,34 +261,25 @@ mod tests { fn matches_pattern() { let args = Create2Args::parse_from([ "foundry-cli", - "--matching", - "0xbbXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "--init-code-hash=0x0000000000000000000000000000000000000000000000000000000000000000", + "--matching=0xbbXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", ]); let create2_out = args.run().unwrap(); let address = create2_out.address; - let address = format!("{address:x}"); - - assert!(address.starts_with("bb")); + assert!(format!("{address:x}").starts_with("bb")); } #[test] fn create2_init_code() { let init_code = "00"; - let args = Create2Args::parse_from([ - "foundry-cli", - "--starts-with", - "cc", - "--init-code", - init_code, - ]); + let args = + Create2Args::parse_from(["foundry-cli", "--starts-with=cc", "--init-code", init_code]); let create2_out = args.run().unwrap(); let address = create2_out.address; - let address_str = format!("{address:x}"); + assert!(format!("{address:x}").starts_with("cc")); let salt = create2_out.salt; let deployer = Address::from_str(DEPLOYER).unwrap(); - - assert!(address_str.starts_with("cc")); - assert_eq!(address, verify_create2(deployer, salt, hex::decode(init_code).unwrap())); + assert_eq!(address, deployer.create2_from_code(salt, hex::decode(init_code).unwrap())); } #[test] @@ -251,53 +287,21 @@ mod tests { let init_code_hash = "bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a"; let args = Create2Args::parse_from([ "foundry-cli", - "--starts-with", - "dd", + "--starts-with=dd", "--init-code-hash", init_code_hash, ]); let create2_out = args.run().unwrap(); let address = create2_out.address; - let address_str = format!("{address:x}"); + assert!(format!("{address:x}").starts_with("dd")); + let salt = create2_out.salt; let deployer = Address::from_str(DEPLOYER).unwrap(); - assert!(address_str.starts_with("dd")); assert_eq!( address, - verify_create2_hash(deployer, salt, hex::decode(init_code_hash).unwrap()) + deployer + .create2(salt, B256::from_slice(hex::decode(init_code_hash).unwrap().as_slice())) ); } - - #[test] - fn verify_helpers() { - // https://eips.ethereum.org/EIPS/eip-1014 - let eip_address = Address::from_str("0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38").unwrap(); - - let deployer = Address::from_str("0x0000000000000000000000000000000000000000").unwrap(); - let salt = - U256::from_str("0x0000000000000000000000000000000000000000000000000000000000000000") - .unwrap(); - let init_code = hex::decode("00").unwrap(); - let address = verify_create2(deployer, salt, init_code); - - assert_eq!(address, eip_address); - - let init_code_hash = - hex::decode("bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a") - .unwrap(); - let address = verify_create2_hash(deployer, salt, init_code_hash); - - assert_eq!(address, eip_address); - } - - fn verify_create2(deployer: Address, salt: U256, init_code: Vec) -> Address { - let init_code_hash = keccak256(init_code); - deployer.create2(salt.to_be_bytes(), init_code_hash) - } - - fn verify_create2_hash(deployer: Address, salt: U256, init_code_hash: Vec) -> Address { - let init_code_hash = B256::from_slice(&init_code_hash); - deployer.create2(salt.to_be_bytes(), init_code_hash) - } } From 6b72a8cabf247eb62fc432401264bc5cff0228a0 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 4 Nov 2023 09:56:32 +0100 Subject: [PATCH 0234/1963] chore: bump alloy (#6214) * chore: bump alloy * update tests --- Cargo.lock | 14 +++++++------- crates/cast/src/lib.rs | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b06e1417b469..404ae71b8d070 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" +source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" +source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" +source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" dependencies = [ "alloy-rlp", "arbitrary", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" +source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" dependencies = [ "const-hex", "dunce", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" +source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" +source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -6815,7 +6815,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#919a338fd452f6fbbf83193a1ba240961efd12c5" +source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" dependencies = [ "paste", "proc-macro2", diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index eff98be4eae2d..376ad966d9c76 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1594,8 +1594,8 @@ impl SimpleCast { /// use cast::SimpleCast as Cast; /// /// assert_eq!( - /// "0x693c61390000000000000000000000000000000000000000000000000000000000000001", - /// Cast::calldata_encode("f(uint a)", &["1"]).unwrap().as_str() + /// "0xb3de648b0000000000000000000000000000000000000000000000000000000000000001", + /// Cast::calldata_encode("f(uint256 a)", &["1"]).unwrap().as_str() /// ); /// # Ok::<_, eyre::Report>(()) /// ``` @@ -2015,8 +2015,8 @@ mod tests { #[test] fn calldata_uint() { assert_eq!( - "0x693c61390000000000000000000000000000000000000000000000000000000000000001", - Cast::calldata_encode("f(uint a)", &["1"]).unwrap().as_str() + "0xb3de648b0000000000000000000000000000000000000000000000000000000000000001", + Cast::calldata_encode("f(uint256 a)", &["1"]).unwrap().as_str() ); } From d85718785859dc0b5a095d2302d1a20ec06ab77a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 09:26:25 -0400 Subject: [PATCH 0235/1963] chore(deps): weekly `cargo update` (#6216) Updating git repository `https://github.com/alloy-rs/core/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/foundry-rs/block-explorers` Updating git repository `https://github.com/foundry-rs/compilers` Updating crc-catalog v2.3.0 -> v2.4.0 Updating dyn-clone v1.0.14 -> v1.0.16 Updating foundry-compilers v0.1.0 (https://github.com/foundry-rs/compilers#9d205574) -> #a4692f53 Adding libredox v0.0.1 Updating openssl v0.10.58 -> v0.10.59 Updating openssl-sys v0.9.94 -> v0.9.95 Removing redox_syscall v0.2.16 Updating redox_users v0.4.3 -> v0.4.4 Updating winnow v0.5.18 -> v0.5.19 Updating zerocopy v0.7.21 -> v0.7.25 Updating zerocopy-derive v0.7.21 -> v0.7.25 Co-authored-by: mattsse --- Cargo.lock | 57 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 404ae71b8d070..b7d85d0996ce2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1431,9 +1431,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4939f9ed1444bd8c896d37f3090012fa6e7834fe84ef8c9daa166109515732f9" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" @@ -1794,9 +1794,9 @@ checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "dyn-clone" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" @@ -2731,9 +2731,8 @@ dependencies = [ [[package]] name = "foundry-compilers" version = "0.1.0" -source = "git+https://github.com/foundry-rs/compilers#9d205574ffc60f454d972eb101e04f2c4c82179d" +source = "git+https://github.com/foundry-rs/compilers#a4692f5339f4adb39d3598ec8935ac5f125ed675" dependencies = [ - "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", "cfg-if", @@ -4191,6 +4190,17 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "libusb1-sys" version = "0.6.4" @@ -4741,9 +4751,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.58" +version = "0.10.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dfc0783362704e97ef3bd24261995a699468440099ef95d869b4d9732f829a" +checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -4773,9 +4783,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.94" +version = "0.9.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f55da20b29f956fb01f0add8683eb26ee13ebe3ebd935e49898717c6b4b2830" +checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" dependencies = [ "cc", "libc", @@ -5562,15 +5572,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.3.5" @@ -5591,12 +5592,12 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom 0.2.10", - "redox_syscall 0.2.16", + "libredox", "thiserror", ] @@ -8029,9 +8030,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.18" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176b6138793677221d420fd2f0aeeced263f197688b36484660da767bca2fa32" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] @@ -8094,18 +8095,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.21" +version = "0.7.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686b7e407015242119c33dab17b8f61ba6843534de936d94368856528eae4dcc" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.21" +version = "0.7.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020f3dfe25dfc38dfea49ce62d5d45ecdd7f0d8a724fa63eb36b6eba4ec76806" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" dependencies = [ "proc-macro2", "quote", From 3029760822a4b41e63d8c9abc2c81d1c54e7d413 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:09:06 +0100 Subject: [PATCH 0236/1963] chore: add nextest config (#6224) --- .config/nextest.toml | 3 +++ .github/workflows/heavy-integration.yml | 3 ++- .github/workflows/test.yml | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 0000000000000..c9dc56f3cd778 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,3 @@ +[profile.default] +retries = { backoff = "exponential", count = 3, delay = "1s", jitter = true } +slow-timeout = "3m" diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index 8fe20560e3d62..5a8749ed15f1f 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -38,7 +38,8 @@ jobs: run: git config --global url."https://github.com/".insteadOf "git@github.com:" - name: test run: | - cargo nextest run -r -p forge --test cli --features heavy-integration-tests --retries 1 -E 'test(~heavy_integration)' + cargo nextest run --profile local -p forge \ + --test cli --features heavy-integration-tests -E "test(~heavy_integration)" # If any of the jobs fail, this will create a high-priority issue to signal so. issue: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8496c0cbd55e9..467760297bcf5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -109,9 +109,7 @@ jobs: run: | # see https://github.com/foundry-rs/foundry/pull/3959 export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run \ - --retries 2 \ - --archive-file tests-${{ matrix.target }}.tar.zst \ + cargo nextest run --archive-file tests-${{ matrix.target }}.tar.zst \ ${{ matrix.flags }} doctests: From fd90b1dc624bb1d2c1de565557338ba71166ba38 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:48:56 +0100 Subject: [PATCH 0237/1963] ci: don't fail-fast on release (#6225) --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7338f46867831..6fe01b21832e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,6 +71,7 @@ jobs: timeout-minutes: 60 needs: prepare strategy: + fail-fast: false matrix: job: # The OS is used for the runner From 934664b271edfd16fe7e46d1d755c123869b8be2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 6 Nov 2023 21:43:05 +0100 Subject: [PATCH 0238/1963] chore: more alloy cleanups (#6226) --- crates/anvil/core/src/eth/utils.rs | 15 ++--- crates/cast/bin/cmd/logs.rs | 3 +- crates/cast/bin/cmd/wallet/vanity.rs | 56 +++++++++---------- crates/cli/src/opts/ethereum.rs | 2 +- crates/common/src/abi.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 13 ++--- crates/evm/traces/src/identifier/etherscan.rs | 8 +-- crates/forge/bin/cmd/script/transaction.rs | 5 +- 8 files changed, 45 insertions(+), 59 deletions(-) diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index e15d494acacd5..3e903e4270fdb 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,12 +1,11 @@ -use alloy_primitives::{Address as aAddress, U256 as rU256}; +use alloy_primitives::{Address, U256}; use ethers_core::{ - types::{transaction::eip2930::AccessListItem, Address, U256}, + types::transaction::eip2930::AccessListItem, utils::{ rlp, rlp::{Encodable, RlpStream}, }, }; -use foundry_evm::utils::h256_to_u256_be; use foundry_utils::types::ToAlloy; pub fn enveloped(id: u8, v: &T, s: &mut RlpStream) { @@ -17,18 +16,12 @@ pub fn enveloped(id: u8, v: &T, s: &mut RlpStream) { out.rlp_append(s) } -pub fn to_access_list(list: Vec) -> Vec<(Address, Vec)> { - list.into_iter() - .map(|item| (item.address, item.storage_keys.into_iter().map(h256_to_u256_be).collect())) - .collect() -} - -pub fn to_revm_access_list(list: Vec) -> Vec<(aAddress, Vec)> { +pub fn to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { list.into_iter() .map(|item| { ( item.address.to_alloy(), - item.storage_keys.into_iter().map(|k| k.to_alloy()).map(|k| k.into()).collect(), + item.storage_keys.into_iter().map(|k| k.to_alloy().into()).collect(), ) }) .collect() diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 94cf85b0bca89..f5fb351e0fd65 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -285,11 +285,10 @@ pub fn sanitize_token(token: Token) -> Token { #[cfg(test)] mod tests { - use std::str::FromStr; - use super::*; use ethers::types::H160; use ethers_core::types::H256; + use std::str::FromStr; const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"; const TRANSFER_SIG: &str = "Transfer(address indexed,address indexed,uint256)"; diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index c5762a7b24282..2fbde4cca421c 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,19 +1,18 @@ +use alloy_primitives::Address; use clap::{builder::TypedValueParser, Parser}; use ethers::{ - core::{k256::ecdsa::SigningKey, rand::thread_rng}, + core::{k256::ecdsa::SigningKey, rand}, prelude::{LocalWallet, Signer}, - types::{H160, U256}, - utils::{get_contract_address, secret_key_to_address}, + utils::secret_key_to_address, }; use eyre::Result; - use foundry_utils::types::ToAlloy; use rayon::iter::{self, ParallelIterator}; use regex::Regex; use std::time::Instant; /// Type alias for the result of [generate_wallet]. -pub type GeneratedWallet = (SigningKey, H160); +pub type GeneratedWallet = (SigningKey, Address); /// CLI arguments for `cast wallet vanity`. #[derive(Debug, Clone, Parser)] @@ -47,7 +46,7 @@ impl VanityArgs { let mut right_regex = None; if let Some(prefix) = starts_with { - if let Ok(decoded) = hex::decode(prefix.as_bytes()) { + if let Ok(decoded) = hex::decode(&prefix) { left_exact_hex = Some(decoded) } else { left_regex = Some(Regex::new(&format!(r"^{prefix}"))?); @@ -55,7 +54,7 @@ impl VanityArgs { } if let Some(suffix) = ends_with { - if let Ok(decoded) = hex::decode(suffix.as_bytes()) { + if let Ok(decoded) = hex::decode(&suffix) { right_exact_hex = Some(decoded) } else { right_regex = Some(Regex::new(&format!(r"{suffix}$"))?); @@ -140,7 +139,6 @@ pub fn find_vanity_address_with_nonce( matcher: T, nonce: u64, ) -> Option { - let nonce: U256 = nonce.into(); wallet_generator().find_any(create_nonce_matcher(matcher, nonce)).map(|(key, _)| key.into()) } @@ -156,30 +154,30 @@ pub fn create_matcher(matcher: T) -> impl Fn(&GeneratedWallet) #[inline] pub fn create_nonce_matcher( matcher: T, - nonce: U256, + nonce: u64, ) -> impl Fn(&GeneratedWallet) -> bool { move |(_, addr)| { - let contract_addr = get_contract_address(*addr, nonce); + let contract_addr = addr.create(nonce); matcher.is_match(&contract_addr) } } /// Returns an infinite parallel iterator which yields a [GeneratedWallet]. #[inline] -pub fn wallet_generator() -> iter::Map, fn(()) -> GeneratedWallet> { - iter::repeat(()).map(|_| generate_wallet()) +pub fn wallet_generator() -> iter::Map, impl Fn(()) -> GeneratedWallet> { + iter::repeat(()).map(|()| generate_wallet()) } /// Generates a random K-256 signing key and derives its Ethereum address. pub fn generate_wallet() -> GeneratedWallet { - let key = SigningKey::random(&mut thread_rng()); + let key = SigningKey::random(&mut rand::thread_rng()); let address = secret_key_to_address(&key); - (key, address) + (key, address.to_alloy()) } /// A trait to match vanity addresses. pub trait VanityMatcher: Send + Sync { - fn is_match(&self, addr: &H160) -> bool; + fn is_match(&self, addr: &Address) -> bool; } /// Matches start and end hex. @@ -190,8 +188,8 @@ pub struct HexMatcher { impl VanityMatcher for HexMatcher { #[inline] - fn is_match(&self, addr: &H160) -> bool { - let bytes = addr.as_bytes(); + fn is_match(&self, addr: &Address) -> bool { + let bytes = addr.as_slice(); bytes.starts_with(&self.left) && bytes.ends_with(&self.right) } } @@ -203,8 +201,8 @@ pub struct LeftHexMatcher { impl VanityMatcher for LeftHexMatcher { #[inline] - fn is_match(&self, addr: &H160) -> bool { - let bytes = addr.as_bytes(); + fn is_match(&self, addr: &Address) -> bool { + let bytes = addr.as_slice(); bytes.starts_with(&self.left) } } @@ -216,8 +214,8 @@ pub struct RightHexMatcher { impl VanityMatcher for RightHexMatcher { #[inline] - fn is_match(&self, addr: &H160) -> bool { - let bytes = addr.as_bytes(); + fn is_match(&self, addr: &Address) -> bool { + let bytes = addr.as_slice(); bytes.ends_with(&self.right) } } @@ -230,8 +228,8 @@ pub struct LeftExactRightRegexMatcher { impl VanityMatcher for LeftExactRightRegexMatcher { #[inline] - fn is_match(&self, addr: &H160) -> bool { - let bytes = addr.as_bytes(); + fn is_match(&self, addr: &Address) -> bool { + let bytes = addr.as_slice(); bytes.starts_with(&self.left) && self.right.is_match(&hex::encode(bytes)) } } @@ -244,8 +242,8 @@ pub struct LeftRegexRightExactMatcher { impl VanityMatcher for LeftRegexRightExactMatcher { #[inline] - fn is_match(&self, addr: &H160) -> bool { - let bytes = addr.as_bytes(); + fn is_match(&self, addr: &Address) -> bool { + let bytes = addr.as_slice(); bytes.ends_with(&self.right) && self.left.is_match(&hex::encode(bytes)) } } @@ -257,8 +255,8 @@ pub struct SingleRegexMatcher { impl VanityMatcher for SingleRegexMatcher { #[inline] - fn is_match(&self, addr: &H160) -> bool { - let addr = hex::encode(addr.as_ref()); + fn is_match(&self, addr: &Address) -> bool { + let addr = hex::encode(addr); self.re.is_match(&addr) } } @@ -271,8 +269,8 @@ pub struct RegexMatcher { impl VanityMatcher for RegexMatcher { #[inline] - fn is_match(&self, addr: &H160) -> bool { - let addr = hex::encode(addr.as_ref()); + fn is_match(&self, addr: &Address) -> bool { + let addr = hex::encode(addr); self.left.is_match(&addr) && self.right.is_match(&addr) } } diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 96a82c31e1a8f..78504e5848001 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -160,7 +160,7 @@ impl figment::Provider for EthereumOpts { dict.extend(self.rpc.dict()); if let Some(from) = self.wallet.from { - dict.insert("sender".to_string(), format!("{from:?}").into()); + dict.insert("sender".to_string(), from.to_string().into()); } Ok(Map::from([(Config::selected_profile(), dict)])) diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 955fa80ad99bd..0bc960f1dbee0 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -166,7 +166,7 @@ pub fn find_source( } else { let implementation = metadata.implementation.unwrap(); println!( - "Contract at {address} is a proxy, trying to fetch source at {implementation:?}..." + "Contract at {address} is a proxy, trying to fetch source at {implementation}..." ); match find_source(client, implementation).await { impl_source @ Ok(_) => impl_source, diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index d0c60f4b77202..2412a5df6056c 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -4,7 +4,7 @@ use crate::{ }; use alloy_dyn_abi::DynSolValue; use alloy_json_abi::JsonAbi as Abi; -use alloy_primitives::{Address, FixedBytes}; +use alloy_primitives::{Address, FixedBytes, U256}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; @@ -28,10 +28,7 @@ use proptest::{ strategy::{BoxedStrategy, Strategy, ValueTree}, test_runner::{TestCaseError, TestRunner}, }; -use revm::{ - primitives::{Address as rAddress, HashMap, U256 as rU256}, - DatabaseCommit, -}; +use revm::{primitives::HashMap, DatabaseCommit}; use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; mod error; @@ -160,7 +157,7 @@ impl<'a> InvariantExecutor<'a> { // Executes the call from the randomly generated sequence. let call_result = executor - .call_raw(*sender, *address, calldata.clone(), rU256::ZERO) + .call_raw(*sender, *address, calldata.clone(), U256::ZERO) .expect("could not make raw evm call"); // Collect data for fuzzing from the state changeset. @@ -673,7 +670,7 @@ impl<'a> InvariantExecutor<'a> { address, func.clone(), vec![], - rU256::ZERO, + U256::ZERO, Some(abi), ) { return f(call_result.result) @@ -693,7 +690,7 @@ impl<'a> InvariantExecutor<'a> { /// before inserting it into the dictionary. Otherwise, we flood the dictionary with /// randomly generated addresses. fn collect_data( - state_changeset: &mut HashMap, + state_changeset: &mut HashMap, sender: &Address, call_result: &RawCallResult, fuzz_state: EvmFuzzState, diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 5bebbe2c9d0e4..9a92b9ac7ba10 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -67,11 +67,9 @@ impl EtherscanIdentifier { let outputs_fut = contracts_iter .clone() .map(|(address, metadata)| { - println!("Compiling: {} {address:?}", metadata.contract_name); - let err_msg = format!( - "Failed to compile contract {} from {address:?}", - metadata.contract_name - ); + println!("Compiling: {} {address}", metadata.contract_name); + let err_msg = + format!("Failed to compile contract {} from {address}", metadata.contract_name); compile::compile_from_source(metadata).map_err(move |err| err.wrap_err(err_msg)) }) .collect::>(); diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 93002e1aec9b1..8c33fb6788d8b 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -298,11 +298,12 @@ pub mod wrapper { // copied from https://github.com/gakonst/ethers-rs #[derive(Serialize, Deserialize)] struct WrappedLog { - /// H160. the contract that emitted the log + /// The contract address that emitted the log. #[serde(serialize_with = "serialize_addr")] pub address: Address, - /// topics: Array of 0 to 4 32 Bytes of indexed log arguments. + /// Array of 0 to 4 32 Bytes of indexed log arguments. + /// /// (In solidity: The first topic is the hash of the signature of the event /// (e.g. `Deposit(address,bytes32,uint256)`), except you declared the event /// with the anonymous specifier.) From 84bbb24740fb0c397c97a2003c6fde1bdca2e8cf Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 6 Nov 2023 17:16:44 -0400 Subject: [PATCH 0239/1963] chore: clippy fixes (#6227) --- crates/config/src/utils.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 595fa18a61748..e3c845b6b3c32 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -203,7 +203,7 @@ pub fn get_available_profiles(toml_path: impl AsRef) -> eyre::Result InvariantExecutor<'a> { }, ) .into_iter() - .map(|(contract, functions)| (contract, functions)) .collect::>(); // Insert them into the executor `targeted_abi`. From 65ca86169089f379918c50dbe4c83cba7770e95b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 7 Nov 2023 01:18:39 +0100 Subject: [PATCH 0240/1963] chore: bump ethers (#6233) --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 22 +++++++++++----------- crates/evm/traces/src/lib.rs | 2 ++ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7d85d0996ce2..6ab0577591a51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2033,7 +2033,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2048,7 +2048,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "ethers-core", "once_cell", @@ -2059,7 +2059,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2077,7 +2077,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "Inflector", "const-hex", @@ -2100,7 +2100,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "Inflector", "const-hex", @@ -2115,7 +2115,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "arrayvec", "bytes", @@ -2144,7 +2144,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "chrono", "ethers-core", @@ -2160,7 +2160,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "async-trait", "auto_impl", @@ -2186,7 +2186,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "async-trait", "auto_impl", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "async-trait", "coins-bip32", @@ -2252,7 +2252,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=841ff8c47980798fbb47991e047f8481b1d5eb39#841ff8c47980798fbb47991e047f8481b1d5eb39" +source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" dependencies = [ "cfg-if", "const-hex", diff --git a/Cargo.toml b/Cargo.toml index 351f61739fb50..432fbaee9268b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,7 +167,7 @@ chrono = { version = "0.4", default-features = false, features = ["clock", "std" hex = { package = "const-hex", version = "1.6", features = ["hex"] } protobuf = "=3.2.0" serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +serde_json = { version = "1.0", features = ["arbitrary_precision"] } tracing = "0.1" jsonpath_lib = "0.3" eyre = "0.6" @@ -186,16 +186,16 @@ color-eyre = "0.6" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "841ff8c47980798fbb47991e047f8481b1d5eb39" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } foundry-compilers = { git = "https://github.com/foundry-rs/compilers" } foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 947e309c74978..1b85070665352 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -445,6 +445,8 @@ impl From<&CallTraceStep> for StructLog { stack: Some(step.stack.data().iter().copied().map(|v| v.to_ethers()).collect_vec()), // Filled in `CallTraceArena::geth_trace` as a result of compounding all slot changes storage: None, + return_data: None, + mem_size: None, } } } From 86f3d181d09ec2ffb9f8bac8bdf6d5e08e20f0d2 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 6 Nov 2023 20:19:32 -0400 Subject: [PATCH 0241/1963] fix(ci): create heavy profile for heavy integration tests (#6231) --- .config/nextest.toml | 3 +++ .github/workflows/heavy-integration.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index c9dc56f3cd778..56e7e21468308 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,3 +1,6 @@ [profile.default] retries = { backoff = "exponential", count = 3, delay = "1s", jitter = true } slow-timeout = "3m" + +[profile.heavy] +retries = 1 \ No newline at end of file diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index 5a8749ed15f1f..f910a0adf96b3 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -38,7 +38,7 @@ jobs: run: git config --global url."https://github.com/".insteadOf "git@github.com:" - name: test run: | - cargo nextest run --profile local -p forge \ + cargo nextest run --profile heavy -p forge \ --test cli --features heavy-integration-tests -E "test(~heavy_integration)" # If any of the jobs fail, this will create a high-priority issue to signal so. From 7d7bdfb64079ee91587b7431ccef30b38f5330f3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:56:52 +0100 Subject: [PATCH 0242/1963] ci: fix windows release (#6236) * ci: cleanup * winders * lefix --- .github/workflows/release.yml | 72 ++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6fe01b21832e0..4a10a7e2ad21c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ env: jobs: prepare: name: Prepare release - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest timeout-minutes: 30 outputs: tag_name: ${{ steps.release_info.outputs.tag_name }} @@ -66,62 +66,60 @@ jobs: uses: ./.github/workflows/docker-publish.yml release: - name: ${{ matrix.job.target }} (${{ matrix.job.os }}) - runs-on: ${{ matrix.job.os }} - timeout-minutes: 60 + name: ${{ matrix.target }} (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 90 needs: prepare strategy: fail-fast: false matrix: - job: - # The OS is used for the runner - # The platform is a generic platform name - # The target is used by Cargo - # The arch is either 386, arm64 or amd64 - # The svm target platform to use for the binary https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 + include: + # `os`: GHA runner + # `target`: Rust build target triple + # `platform` and `arch`: Used in tarball names + # `svm`: target platform to use for the Solc binary: https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 - os: ubuntu-20.04 - platform: linux target: x86_64-unknown-linux-gnu - arch: amd64 svm_target_platform: linux-amd64 - - os: ubuntu-20.04 platform: linux + arch: amd64 + - os: ubuntu-20.04 target: aarch64-unknown-linux-gnu - arch: arm64 svm_target_platform: linux-aarch64 + platform: linux + arch: arm64 - os: macos-latest - platform: darwin target: x86_64-apple-darwin - arch: amd64 svm_target_platform: macosx-amd64 - - os: macos-latest platform: darwin + arch: amd64 + - os: macos-latest target: aarch64-apple-darwin - arch: arm64 svm_target_platform: macosx-aarch64 + platform: darwin + arch: arm64 - os: windows-latest - platform: win32 target: x86_64-pc-windows-msvc - arch: amd64 svm_target_platform: windows-amd64 - + platform: win32 + arch: amd64 steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable with: - targets: ${{ matrix.job.target }} + targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - name: Apple M1 setup - if: ${{ matrix.job.target == 'aarch64-apple-darwin' }} + if: matrix.target == 'aarch64-apple-darwin' run: | echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV - name: Linux ARM setup - if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} + if: matrix.target == 'aarch64-unknown-linux-gnu' run: | sudo apt-get update -y sudo apt-get install -y gcc-aarch64-linux-gnu @@ -129,15 +127,20 @@ jobs: - name: Build binaries env: - SVM_TARGET_PLATFORM: ${{ matrix.job.svm_target_platform }} - run: cargo build --release --bins --target ${{ matrix.job.target }} + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + shell: bash + # Windows runs out of RAM when building binaries with LLVM + run: | + flags=() + [[ "${{ matrix.target }}" == *windows* ]] && flags+="-j2" + cargo build --release --bins --target ${{ matrix.target }} "${flags[@]}" - name: Archive binaries id: artifacts env: - PLATFORM_NAME: ${{ matrix.job.platform }} - TARGET: ${{ matrix.job.target }} - ARCH: ${{ matrix.job.arch }} + PLATFORM_NAME: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} + ARCH: ${{ matrix.arch }} VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash @@ -159,10 +162,10 @@ jobs: - name: Build man page id: man - if: ${{ matrix.job.target == 'x86_64-unknown-linux-gnu' }} + if: matrix.target == 'x86_64-unknown-linux-gnu' env: - PLATFORM_NAME: ${{ matrix.job.platform }} - TARGET: ${{ matrix.job.target }} + PLATFORM_NAME: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash @@ -207,9 +210,10 @@ jobs: cleanup: name: Release cleanup - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest timeout-minutes: 30 needs: release + if: always() steps: - uses: actions/checkout@v3 @@ -234,7 +238,7 @@ jobs: name: Open an issue runs-on: ubuntu-latest needs: [prepare, release-docker, release, cleanup] - if: ${{ failure() }} + if: failure() steps: - uses: actions/checkout@v3 - uses: JasonEtco/create-an-issue@v2 From 6958dc1a68671d2e5178736695a1cc3252d6da2e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:51:01 +0100 Subject: [PATCH 0243/1963] ci: fix bash array --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a10a7e2ad21c..0e728afacb44f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -132,7 +132,7 @@ jobs: # Windows runs out of RAM when building binaries with LLVM run: | flags=() - [[ "${{ matrix.target }}" == *windows* ]] && flags+="-j2" + [[ "${{ matrix.target }}" == *windows* ]] && flags+=(-j2) cargo build --release --bins --target ${{ matrix.target }} "${flags[@]}" - name: Archive binaries From 63e043e88c99e6af59cb112aeb2af4932716e059 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 7 Nov 2023 14:04:41 +0100 Subject: [PATCH 0244/1963] refactor: rewrite revert and precompile decoding (#6222) * wip * rm ugly ass brute force decoding * improve decoding * decode precompiles * chore: rewrite hardhat console patcher * fixes * chore: clippy * further * addtest --- Cargo.lock | 138 ++++--- crates/anvil/src/eth/backend/mem/mod.rs | 69 +--- crates/cast/Cargo.toml | 1 - crates/config/src/utils.rs | 2 +- crates/evm/core/Cargo.toml | 2 +- crates/evm/core/src/abi/mod.rs | 32 +- crates/evm/core/src/backend/mod.rs | 1 - crates/evm/core/src/debug.rs | 11 +- crates/evm/core/src/decode.rs | 358 +++++------------- crates/evm/evm/src/executors/fuzz/mod.rs | 4 +- .../evm/evm/src/executors/invariant/error.rs | 12 +- crates/evm/evm/src/executors/mod.rs | 10 +- crates/evm/evm/src/inspectors/access_list.rs | 2 + crates/evm/evm/src/inspectors/debugger.rs | 27 +- crates/evm/traces/Cargo.toml | 3 +- .../traces/src/{decoder.rs => decoder/mod.rs} | 107 ++---- crates/evm/traces/src/decoder/precompiles.rs | 204 ++++++++++ crates/evm/traces/src/inspector.rs | 8 +- crates/evm/traces/src/lib.rs | 166 ++++---- crates/evm/traces/src/node.rs | 49 ++- crates/evm/traces/src/utils.rs | 4 +- crates/forge/bin/cmd/script/executor.rs | 2 +- crates/forge/bin/cmd/script/mod.rs | 16 +- crates/forge/src/gas_report.rs | 13 +- crates/forge/src/runner.rs | 4 +- crates/forge/tests/cli/script.rs | 2 +- crates/forge/tests/it/core.rs | 4 +- crates/forge/tests/it/invariant.rs | 48 ++- crates/test-utils/src/script.rs | 6 +- .../common/InvariantInnerContract.t.sol | 2 +- .../common/InvariantReentrancy.t.sol | 2 +- .../invariant/common/InvariantTest1.t.sol | 4 +- .../invariant/target/ExcludeContracts.t.sol | 2 +- .../invariant/target/ExcludeSenders.t.sol | 2 +- .../invariant/target/TargetContracts.t.sol | 2 +- .../invariant/target/TargetInterfaces.t.sol | 2 +- .../invariant/target/TargetSelectors.t.sol | 2 +- .../fuzz/invariant/target/TargetSenders.t.sol | 2 +- .../targetAbi/ExcludeArtifacts.t.sol | 2 +- .../targetAbi/TargetArtifactSelectors.t.sol | 2 +- .../targetAbi/TargetArtifactSelectors2.t.sol | 2 +- .../invariant/targetAbi/TargetArtifacts.t.sol | 4 +- 42 files changed, 652 insertions(+), 683 deletions(-) rename crates/evm/traces/src/{decoder.rs => decoder/mod.rs} (73%) create mode 100644 crates/evm/traces/src/decoder/precompiles.rs diff --git a/Cargo.lock b/Cargo.lock index 6ab0577591a51..431560f339b13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" +source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" +source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" +source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" dependencies = [ "alloy-rlp", "arbitrary", @@ -150,13 +150,13 @@ checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" +source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" dependencies = [ "const-hex", "dunce", @@ -165,7 +165,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "syn-solidity", "tiny-keccak", ] @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" +source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" dependencies = [ "winnow", ] @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" +source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -550,7 +550,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -561,7 +561,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -722,7 +722,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.38", + "syn 2.0.39", "which", ] @@ -1173,7 +1173,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -1664,7 +1664,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -1905,7 +1905,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2092,8 +2092,8 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.38", - "toml 0.8.6", + "syn 2.0.39", + "toml 0.8.8", "walkdir", ] @@ -2109,7 +2109,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2134,7 +2134,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.38", + "syn 2.0.39", "tempfile", "thiserror", "tiny-keccak", @@ -2339,7 +2339,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2394,7 +2394,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.6", + "toml 0.8.8", "uncased", "version_check", ] @@ -2541,7 +2541,7 @@ dependencies = [ "solang-parser", "thiserror", "tokio", - "toml 0.8.6", + "toml 0.8.8", "tracing", "warp", ] @@ -2557,7 +2557,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.6", + "toml 0.8.8", "tracing", "tracing-subscriber", ] @@ -2581,7 +2581,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-macros", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2731,7 +2731,7 @@ dependencies = [ [[package]] name = "foundry-compilers" version = "0.1.0" -source = "git+https://github.com/foundry-rs/compilers#a4692f5339f4adb39d3598ec8935ac5f125ed675" +source = "git+https://github.com/foundry-rs/compilers#f00eef81a91a393bf92eb13d47a5221f5e50162f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -2793,7 +2793,7 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.6", + "toml 0.8.8", "toml_edit 0.20.7", "tracing", "walkdir", @@ -2849,11 +2849,11 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-types", - "auto_impl", "const-hex", "ethers", "eyre", "foundry-abi", + "foundry-cheatcodes-defs", "foundry-common", "foundry-compilers", "foundry-config", @@ -2918,6 +2918,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-sol-types", "const-hex", "ethers", "eyre", @@ -2957,7 +2958,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3115,7 +3116,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -4158,9 +4159,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libgit2-sys" @@ -4407,7 +4408,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -4668,7 +4669,7 @@ dependencies = [ "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -4772,7 +4773,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -4973,7 +4974,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5028,7 +5029,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5131,7 +5132,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5169,7 +5170,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5269,7 +5270,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5346,7 +5347,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "version_check", "yansi 1.0.0-rc.1", ] @@ -6338,22 +6339,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -6397,7 +6398,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -6443,7 +6444,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -6736,7 +6737,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -6804,9 +6805,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -6816,12 +6817,12 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#e76158bb83644e042c4e55c4a382aeb389ae748b" +source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -6953,7 +6954,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -7067,7 +7068,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -7166,15 +7167,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff9e3abce27ee2c9a37f9ad37238c1bdd4e789c84ba37df76aa4d528f5072cc" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.7", + "toml_edit 0.21.0", ] [[package]] @@ -7202,6 +7203,17 @@ name = "toml_edit" version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ "indexmap 2.1.0", "serde", @@ -7302,7 +7314,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -7609,9 +7621,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.5" +version = "8.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e7dc29b3c54a2ea67ef4f953d5ec0c4085035c0ae2d325be1c0d2144bd9f16" +checksum = "1290fd64cc4e7d3c9b07d7f333ce0ce0007253e32870e632624835cc80b83939" dependencies = [ "anyhow", "git2", @@ -7716,7 +7728,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-shared", ] @@ -7750,7 +7762,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8110,7 +8122,7 @@ checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -8130,7 +8142,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 5fddfe445abbe..d313f1dd81724 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -53,19 +53,18 @@ use ethers::{ DefaultFrame, Filter, FilteredParams, GethDebugTracingOptions, GethTrace, Log, OtherFields, Trace, Transaction, TransactionReceipt, H160, }, - utils::{hex, keccak256, rlp}, + utils::{keccak256, rlp}, }; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; -use foundry_common::fmt::format_token; use foundry_evm::{ backend::{DatabaseError, DatabaseResult}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, - decode::{decode_custom_error_args, decode_revert}, + decode::decode_revert, inspectors::AccessListTracer, revm::{ self, db::CacheDB, - interpreter::{return_ok, InstructionResult}, + interpreter::InstructionResult, primitives::{ Account, BlockEnv, CreateScheme, EVMError, Env, ExecutionResult, InvalidHeader, Output, SpecId, TransactTo, TxEnv, KECCAK_EMPTY, @@ -285,7 +284,7 @@ impl Backend { fork_genesis_infos.clear(); for res in genesis_accounts { - let (address, mut info) = res??; + let (address, mut info) = res.map_err(DatabaseError::display)??; info.balance = self.genesis.balance; db.insert_account(address, info.clone()); @@ -910,54 +909,20 @@ impl Backend { // insert all transactions for (info, receipt) in transactions.into_iter().zip(receipts) { // log some tx info - { - node_info!(" Transaction: {:?}", info.transaction_hash); - if let Some(ref contract) = info.contract_address { - node_info!(" Contract created: {:?}", contract); - } - node_info!(" Gas used: {}", receipt.gas_used()); - match info.exit { - return_ok!() => (), - InstructionResult::OutOfFund => { - node_info!(" Error: reverted due to running out of funds"); - } - InstructionResult::CallTooDeep => { - node_info!(" Error: reverted with call too deep"); - } - InstructionResult::Revert => { - if let Some(ref r) = info.out { - if let Ok(reason) = decode_revert(r.as_ref(), None, None) { - node_info!(" Error: reverted with '{}'", reason); - } else { - match decode_custom_error_args(r, 5) { - // assuming max 5 args - Some(token) => { - node_info!( - " Error: reverted with custom error: {:?}", - format_token(&token) - ); - } - None => { - node_info!( - " Error: reverted with custom error: {}", - hex::encode(r) - ); - } - } - } - } else { - node_info!(" Error: reverted without a reason"); - } - } - InstructionResult::OutOfGas => { - node_info!(" Error: ran out of gas"); - } - reason => { - node_info!(" Error: failed due to {:?}", reason); - } - } - node_info!(""); + node_info!(" Transaction: {:?}", info.transaction_hash); + if let Some(contract) = &info.contract_address { + node_info!(" Contract created: {contract:?}"); + } + node_info!(" Gas used: {}", receipt.gas_used()); + if !info.exit.is_ok() { + let r = decode_revert( + info.out.as_deref().unwrap_or_default(), + None, + Some(info.exit), + ); + node_info!(" Error: reverted with: {r}"); } + node_info!(""); let mined_tx = MinedTransaction { info, diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index e2dfb5358d558..43cf2497fd4b3 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -35,7 +35,6 @@ alloy-dyn-abi.workspace = true foundry-compilers = { workspace = true, default-features = false } foundry-block-explorers = { workspace = true } - chrono.workspace = true evm-disassembler = "0.3" eyre.workspace = true diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index e3c845b6b3c32..8fb3289227c6d 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -203,7 +203,7 @@ pub fn get_available_profiles(toml_path: impl AsRef) -> eyre::Result) { - if input.len() < 4 { - return - } - let selector = unsafe { &mut *(input.get_unchecked_mut(..4) as *mut [u8] as *mut [u8; 4]) }; - if let Some(abigen_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { - *selector = *abigen_selector; +pub fn patch_hardhat_console_selector(input: &mut [u8]) { + if let Some(selector) = input.get_mut(..4) { + let selector: &mut [u8; 4] = selector.try_into().unwrap(); + if let Some(generated_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { + *selector = *generated_selector; + } } } @@ -27,7 +27,7 @@ pub fn patch_hardhat_console_selector(input: &mut Vec) { /// bindings which `abigen!` creates. `hardhat/console.log` logs its events in functions that accept /// `uint` manually as `abi.encodeWithSignature("log(int)", p0)`, but `abigen!` uses `uint256` for /// its call bindings (`HardhatConsoleCalls`) as generated by solc. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { +static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { HashMap::from([ // log(bool,uint256,uint256,address) ([241, 97, 178, 33], [0, 221, 135, 185]), @@ -545,11 +545,11 @@ mod tests { use super::*; #[test] - fn hardhat_console_path_works() { - for (hh, abigen) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { - let mut hh = (*hh).to_vec(); + fn hardhat_console_patch() { + for (hh, generated) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { + let mut hh = *hh; patch_hardhat_console_selector(&mut hh); - assert_eq!((*abigen).to_vec(), hh); + assert_eq!(hh, *generated); } } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index be6d855b46593..bdfe0a4c110ee 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -69,7 +69,6 @@ const GLOBAL_FAILURE_SLOT: B256 = b256!("6661696c65640000000000000000000000000000000000000000000000000000"); /// An extension trait that allows us to easily extend the `revm::Inspector` capabilities -#[auto_impl::auto_impl(&mut, Box)] pub trait DatabaseExt: Database { /// Creates a new snapshot at the current point of execution. /// diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index cbe1b64b2f7be..3b6cab6167e30 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,4 +1,4 @@ -use crate::{abi::HEVM_ABI, utils::CallKind}; +use crate::utils::CallKind; use alloy_primitives::{Address, U256}; use revm::interpreter::{Memory, OpCode}; use serde::{Deserialize, Serialize}; @@ -178,11 +178,12 @@ impl Display for Instruction { Instruction::Cheatcode(cheat) => write!( f, "VM_{}", - &*HEVM_ABI - .functions() - .find(|func| func.short_signature() == *cheat) + foundry_cheatcodes_defs::Vm::CHEATCODES + .iter() + .map(|c| &c.func) + .find(|c| c.selector_bytes == *cheat) .expect("unknown cheatcode found in debugger") - .name + .id .to_uppercase() ), } diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 1d941d94e359e..1d66f6286b0a3 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -1,18 +1,15 @@ //! Various utilities to decode test results. -use crate::constants::MAGIC_SKIP; -use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; +use crate::abi::ConsoleEvents; +use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::JsonAbi; -use alloy_primitives::{B256, U256}; -use alloy_sol_types::{sol_data::String as SolString, SolType}; +use alloy_primitives::B256; +use alloy_sol_types::{SolCall, SolError, SolInterface, SolValue}; use ethers::{abi::RawLog, contract::EthLogDecode, types::Log}; -use foundry_abi::console::ConsoleEvents::{self, *}; -use foundry_common::{fmt::format_token, SELECTOR_LEN}; -use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; +use foundry_cheatcodes_defs::Vm; +use foundry_common::SELECTOR_LEN; use itertools::Itertools; -use once_cell::sync::Lazy; -use revm::interpreter::{return_ok, InstructionResult}; -use thiserror::Error; +use revm::interpreter::InstructionResult; /// Decode a set of logs, only returning logs from DSTest logging events and Hardhat's `console.log` pub fn decode_console_logs(logs: &[Log]) -> Vec { @@ -24,17 +21,19 @@ pub fn decode_console_logs(logs: &[Log]) -> Vec { /// This function returns [None] if it is not a DSTest log or the result of a Hardhat /// `console.log`. pub fn decode_console_log(log: &Log) -> Option { + use ConsoleEvents as CE; + // NOTE: We need to do this conversion because ethers-rs does not // support passing `Log`s let raw_log = RawLog { topics: log.topics.clone(), data: log.data.to_vec() }; let decoded = match ConsoleEvents::decode_log(&raw_log).ok()? { - LogsFilter(inner) => format!("{}", inner.0), - LogBytesFilter(inner) => format!("{}", inner.0), - LogNamedAddressFilter(inner) => format!("{}: {:?}", inner.key, inner.val), - LogNamedBytes32Filter(inner) => { + CE::LogsFilter(inner) => format!("{}", inner.0), + CE::LogBytesFilter(inner) => format!("{}", inner.0), + CE::LogNamedAddressFilter(inner) => format!("{}: {:?}", inner.key, inner.val), + CE::LogNamedBytes32Filter(inner) => { format!("{}: {}", inner.key, B256::new(inner.val)) } - LogNamedDecimalIntFilter(inner) => { + CE::LogNamedDecimalIntFilter(inner) => { let (sign, val) = inner.val.into_sign_and_abs(); format!( "{}: {}{}", @@ -43,300 +42,123 @@ pub fn decode_console_log(log: &Log) -> Option { ethers::utils::format_units(val, inner.decimals.as_u32()).unwrap() ) } - LogNamedDecimalUintFilter(inner) => { + CE::LogNamedDecimalUintFilter(inner) => { format!( "{}: {}", inner.key, ethers::utils::format_units(inner.val, inner.decimals.as_u32()).unwrap() ) } - LogNamedIntFilter(inner) => format!("{}: {:?}", inner.key, inner.val), - LogNamedUintFilter(inner) => format!("{}: {:?}", inner.key, inner.val), - LogNamedBytesFilter(inner) => { + CE::LogNamedIntFilter(inner) => format!("{}: {:?}", inner.key, inner.val), + CE::LogNamedUintFilter(inner) => format!("{}: {:?}", inner.key, inner.val), + CE::LogNamedBytesFilter(inner) => { format!("{}: {}", inner.key, inner.val) } - LogNamedStringFilter(inner) => format!("{}: {}", inner.key, inner.val), - LogNamedArray1Filter(inner) => format!("{}: {:?}", inner.key, inner.val), - LogNamedArray2Filter(inner) => format!("{}: {:?}", inner.key, inner.val), - LogNamedArray3Filter(inner) => format!("{}: {:?}", inner.key, inner.val), + CE::LogNamedStringFilter(inner) => format!("{}: {}", inner.key, inner.val), + CE::LogNamedArray1Filter(inner) => format!("{}: {:?}", inner.key, inner.val), + CE::LogNamedArray2Filter(inner) => format!("{}: {:?}", inner.key, inner.val), + CE::LogNamedArray3Filter(inner) => format!("{}: {:?}", inner.key, inner.val), e => e.to_string(), }; Some(decoded) } -/// Possible errors when decoding a revert error string. -#[derive(Debug, Clone, Error)] -pub enum RevertDecodingError { - #[error("Not enough data to decode")] - InsufficientErrorData, - #[error("Unsupported solidity builtin panic")] - UnsupportedSolidityBuiltinPanic, - #[error("Could not decode slice")] - SliceDecodingError, - #[error("Non-native error and not string")] - NonNativeErrorAndNotString, - #[error("Unknown Error Selector")] - UnknownErrorSelector, - #[error("Could not decode cheatcode string")] - UnknownCheatcodeErrorString, - #[error("Bad String decode")] - BadStringDecode, - #[error(transparent)] - AlloyDecodingError(alloy_dyn_abi::Error), -} - -/// Given an ABI encoded error string with the function signature `Error(string)`, it decodes -/// it and returns the revert error message. +/// Tries to decode an error message from the given revert bytes. +/// +/// Note that this is just a best-effort guess, and should not be relied upon for anything other +/// than user output. pub fn decode_revert( err: &[u8], maybe_abi: Option<&JsonAbi>, status: Option, -) -> Result { +) -> String { if err.len() < SELECTOR_LEN { if let Some(status) = status { - if !matches!(status, return_ok!()) { - return Ok(format!("EvmError: {status:?}")) + if !status.is_ok() { + return format!("EvmError: {status:?}") } } - return Err(RevertDecodingError::InsufficientErrorData) - } - - match <[u8; SELECTOR_LEN]>::try_from(&err[..SELECTOR_LEN]).unwrap() { - // keccak(Panic(uint256)) - [78, 72, 123, 113] => { - // ref: https://soliditydeveloper.com/solidity-0.8 - match err[err.len() - 1] { - 1 => { - // assert - Ok("Assertion violated".to_string()) - } - 17 => { - // safemath over/underflow - Ok("Arithmetic over/underflow".to_string()) - } - 18 => { - // divide by 0 - Ok("Division or modulo by 0".to_string()) - } - 33 => { - // conversion into non-existent enum type - Ok("Conversion into non-existent enum type".to_string()) - } - 34 => { - // incorrectly encoded storage byte array - Ok("Incorrectly encoded storage byte array".to_string()) - } - 49 => { - // pop() on empty array - Ok("`pop()` on empty array".to_string()) - } - 50 => { - // index out of bounds - Ok("Index out of bounds".to_string()) - } - 65 => { - // allocating too much memory or creating too large array - Ok("Memory allocation overflow".to_string()) - } - 81 => { - // calling a zero initialized variable of internal function type - Ok("Calling a zero initialized variable of internal function type".to_string()) - } - _ => Err(RevertDecodingError::UnsupportedSolidityBuiltinPanic), - } - } - // keccak(Error(string)) | keccak(CheatcodeError(string)) - REVERT_PREFIX | ERROR_PREFIX => { - DynSolType::abi_decode(&DynSolType::String, &err[SELECTOR_LEN..]) - .map_err(RevertDecodingError::AlloyDecodingError) - .and_then(|v| { - v.clone() - .as_str() - .map(|s| s.to_owned()) - .ok_or(RevertDecodingError::BadStringDecode) - }) - .to_owned() - } - // keccak(expectRevert(bytes)) - [242, 141, 206, 179] => { - let err_data = &err[SELECTOR_LEN..]; - if err_data.len() > 64 { - let len = U256::try_from_be_slice(&err_data[32..64]) - .ok_or(RevertDecodingError::SliceDecodingError)? - .to::(); - if err_data.len() > 64 + len { - let actual_err = &err_data[64..64 + len]; - if let Ok(decoded) = decode_revert(actual_err, maybe_abi, None) { - // check if it's a builtin - return Ok(decoded) - } else if let Ok(as_str) = String::from_utf8(actual_err.to_vec()) { - // check if it's a true string - return Ok(as_str) - } - } - } - Err(RevertDecodingError::NonNativeErrorAndNotString) - } - // keccak(expectRevert(bytes4)) - [195, 30, 176, 224] => { - let err_data = &err[SELECTOR_LEN..]; - if err_data.len() == 32 { - let actual_err = &err_data[..SELECTOR_LEN]; - if let Ok(decoded) = decode_revert(actual_err, maybe_abi, None) { - // it's a known selector - return Ok(decoded) - } - } - Err(RevertDecodingError::UnknownErrorSelector) - } - _ => { - // See if the revert is caused by a skip() call. - if err == MAGIC_SKIP { - return Ok("SKIPPED".to_string()) - } - // try to decode a custom error if provided an abi - if let Some(abi) = maybe_abi { - for abi_error in abi.errors() { - if abi_error.selector() == err[..SELECTOR_LEN] { - // if we don't decode, don't return an error, try to decode as a - // string later - if let Ok(decoded) = abi_error.abi_decode_input(&err[SELECTOR_LEN..], false) - { - let inputs = decoded - .iter() - .map(foundry_common::fmt::format_token) - .collect::>() - .join(", "); - return Ok(format!("{}({inputs})", abi_error.name)) - } - } - } - } - - // optimistically try to decode as string, unknown selector or `CheatcodeError` - let error = DynSolType::abi_decode(&DynSolType::String, err) - .map_err(|_| RevertDecodingError::BadStringDecode) - .and_then(|v| { - v.as_str().map(|s| s.to_owned()).ok_or(RevertDecodingError::BadStringDecode) - }) - .ok(); - - let error = error.filter(|err| err.as_str() != ""); - error - .or_else(|| { - // try decoding as unknown err - SolString::abi_decode(&err[SELECTOR_LEN..], false) - .map(|err_str| format!("{}:{err_str}", hex::encode(&err[..SELECTOR_LEN]))) - .ok() - }) - .or_else(|| { - // try to decode possible variations of custom error types - decode_custom_error(err).map(|token| { - let s = format!("Custom Error {}:", hex::encode(&err[..SELECTOR_LEN])); - - let err_str = format_token(&token); - if err_str.starts_with('(') { - format!("{s}{err_str}") - } else { - format!("{s}({err_str})") - } - }) - }) - .ok_or_else(|| RevertDecodingError::NonNativeErrorAndNotString) + return if err.is_empty() { + "".to_string() + } else { + format!("custom error bytes {}", hex::encode_prefixed(err)) } } -} -/// Tries to optimistically decode a custom solc error, with at most 4 arguments -pub fn decode_custom_error(err: &[u8]) -> Option { - decode_custom_error_args(err, 4) -} + if err == crate::constants::MAGIC_SKIP { + // Also used in forge fuzz runner + return "SKIPPED".to_string() + } -/// Tries to optimistically decode a custom solc error with a maximal amount of arguments -/// -/// This will brute force decoding of custom errors with up to `args` arguments -pub fn decode_custom_error_args(err: &[u8], args: usize) -> Option { - if err.len() <= SELECTOR_LEN { - return None + // Solidity's `Error(string)` or `Panic(uint256)` + if let Ok(e) = alloy_sol_types::GenericContractError::abi_decode(err, false) { + return e.to_string() } - let err = &err[SELECTOR_LEN..]; - /// types we check against - static TYPES: Lazy> = Lazy::new(|| { - vec![ - DynSolType::Address, - DynSolType::Bool, - DynSolType::Uint(256), - DynSolType::Int(256), - DynSolType::Bytes, - DynSolType::String, - ] - }); + let (selector, data) = err.split_at(SELECTOR_LEN); + let selector: &[u8; 4] = selector.try_into().unwrap(); - // check if single param, but only if it's a single word - if err.len() == 32 { - for ty in TYPES.iter() { - if let Ok(decoded) = ty.abi_decode(err) { - return Some(decoded) + match *selector { + // `CheatcodeError(string)` + Vm::CheatcodeError::SELECTOR => { + if let Ok(e) = Vm::CheatcodeError::abi_decode_raw(data, false) { + return e.message } } - return None - } - - // brute force decode all possible combinations - for num in (2..=args).rev() { - for candidate in TYPES.iter().cloned().combinations(num) { - if let Ok(decoded) = DynSolType::abi_decode(&DynSolType::Tuple(candidate), err) { - return Some(decoded) + // `expectRevert(bytes)` + Vm::expectRevert_2Call::SELECTOR => { + if let Ok(e) = Vm::expectRevert_2Call::abi_decode_raw(data, false) { + return decode_revert(&e.revertData[..], maybe_abi, status) + } + } + // `expectRevert(bytes4)` + Vm::expectRevert_1Call::SELECTOR => { + if let Ok(e) = Vm::expectRevert_1Call::abi_decode_raw(data, false) { + return decode_revert(&e.revertData[..], maybe_abi, status) } } + _ => {} } - // try as array - for ty in TYPES.iter().cloned().map(|ty| DynSolType::Array(Box::new(ty))) { - if let Ok(decoded) = ty.abi_decode(err) { - return Some(decoded) + // Custom error from the given ABI + if let Some(abi) = maybe_abi { + if let Some(abi_error) = abi.errors().find(|e| selector == e.selector()) { + // if we don't decode, don't return an error, try to decode as a string later + if let Ok(decoded) = abi_error.abi_decode_input(data, false) { + return format!( + "{}({})", + abi_error.name, + decoded.iter().map(foundry_common::fmt::format_token).format(", ") + ) + } } } - None -} - -#[cfg(test)] -mod tests { - use super::*; - use alloy_primitives::{Address, U256}; - use alloy_sol_types::{sol, SolError}; - - #[test] - fn test_decode_custom_error_address() { - sol! { - error AddressErr(address addr); - } - let err = AddressErr { addr: Address::random() }; + // ABI-encoded `string` + if let Ok(s) = String::abi_decode(err, false) { + return s + } - let encoded = err.abi_encode(); - let decoded = decode_custom_error(&encoded).unwrap(); - assert_eq!(decoded, DynSolValue::Address(err.addr)); + // UTF-8-encoded string + if let Ok(s) = std::str::from_utf8(err) { + return s.to_string() } - #[test] - fn test_decode_custom_error_args3() { - sol! { - error MyError(address addr, bool b, uint256 val); - } - let err = MyError { addr: Address::random(), b: true, val: U256::from(100u64) }; + // Generic custom error + format!( + "custom error {}:{}", + hex::encode(selector), + std::str::from_utf8(data).map_or_else(|_| trimmed_hex(data), String::from) + ) +} - let encoded = err.clone().abi_encode(); - let decoded = decode_custom_error(&encoded).unwrap(); - assert_eq!( - decoded, - DynSolValue::Tuple(vec![ - DynSolValue::Address(err.addr), - DynSolValue::Bool(err.b), - DynSolValue::Uint(U256::from(100u64), 256), - ]) - ); +fn trimmed_hex(s: &[u8]) -> String { + let s = hex::encode(s); + let n = 32 * 2; + if s.len() <= n { + s + } else { + format!("{}…{} ({} bytes)", &s[..n / 2], &s[s.len() - n / 2..], s.len()) } } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 56befa64a5d07..2cdfae9042d85 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -129,9 +129,7 @@ impl<'a> FuzzedExecutor<'a> { // case. let call_res = _counterexample.1.result.clone(); *counterexample.borrow_mut() = _counterexample; - Err(TestCaseError::fail( - decode::decode_revert(&call_res, errors, Some(status)).unwrap_or_default(), - )) + Err(TestCaseError::fail(decode::decode_revert(&call_res, errors, Some(status)))) } } }); diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index e948a32111860..5a8346980d98c 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -94,19 +94,11 @@ impl InvariantFuzzError { logs: call_result.logs, traces: call_result.traces, test_error: proptest::test_runner::TestError::Fail( - format!( - "{}, reason: '{}'", - origin, - match &revert_reason { - Ok(s) => s.clone(), - Err(e) => e.to_string(), - } - ) - .into(), + format!("{origin}, reason: {revert_reason}").into(), calldata.to_vec(), ), return_reason: "".into(), - revert_reason: revert_reason.unwrap_or_default(), + revert_reason, addr: invariant_contract.address, func, inner_sequence: inner_sequence.to_vec(), diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 024b9880b198e..19b256541a7f1 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -94,7 +94,7 @@ impl Executor { let create2_deployer_account = self .backend .basic(DEFAULT_CREATE2_DEPLOYER)? - .ok_or(DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; + .ok_or_else(|| DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; // if the deployer is not currently deployed, deploy the default one if create2_deployer_account.code.map_or(true, |code| code.is_empty()) { @@ -397,8 +397,7 @@ impl Executor { } } _ => { - let reason = decode::decode_revert(result.as_ref(), abi, Some(exit_reason)) - .unwrap_or_else(|_| format!("{exit_reason:?}")); + let reason = decode::decode_revert(result.as_ref(), abi, Some(exit_reason)); return Err(EvmError::Execution(Box::new(ExecutionErr { reverted: true, reason, @@ -841,11 +840,10 @@ fn convert_call_result( }) } _ => { - let reason = decode::decode_revert(result.as_ref(), abi, Some(status)) - .unwrap_or_else(|_| format!("{status:?}")); - if reason == "SKIPPED" { + if &result == crate::constants::MAGIC_SKIP { return Err(EvmError::SkipError) } + let reason = decode::decode_revert(&result, abi, Some(status)); Err(EvmError::Execution(Box::new(ExecutionErr { reverted, reason, diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs index 5deaa800b0cb7..e7bf56e072920 100644 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ b/crates/evm/evm/src/inspectors/access_list.rs @@ -35,6 +35,7 @@ impl AccessListTracer { .collect(), } } + pub fn access_list(&self) -> AccessList { AccessList::from( self.access_list @@ -47,6 +48,7 @@ impl AccessListTracer { ) } } + impl Inspector for AccessListTracer { #[inline] fn step( diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index 0e6df101f81b6..be06fc7225592 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -1,15 +1,15 @@ use alloy_primitives::{Address, Bytes}; +use foundry_common::SELECTOR_LEN; use foundry_evm_core::{ backend::DatabaseExt, constants::CHEATCODE_ADDRESS, debug::{DebugArena, DebugNode, DebugStep, Instruction}, utils::{gas_used, get_create_address, CallKind}, }; -use foundry_utils::error::ErrorExt; use revm::{ interpreter::{ opcode::{self, spec_opcode_gas}, - CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, + CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, }, EVMData, Inspector, }; @@ -97,14 +97,14 @@ impl Inspector for Debugger { call.context.code_address, call.context.scheme.into(), ); - if CHEATCODE_ADDRESS == call.contract { - self.arena.arena[self.head].steps.push(DebugStep { - memory: Memory::new(), - instruction: Instruction::Cheatcode( - call.input[0..4].try_into().expect("malformed cheatcode call"), - ), - ..Default::default() - }); + + if call.contract == CHEATCODE_ADDRESS { + if let Some(selector) = call.input.get(..SELECTOR_LEN) { + self.arena.arena[self.head].steps.push(DebugStep { + instruction: Instruction::Cheatcode(selector.try_into().unwrap()), + ..Default::default() + }); + } } (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) @@ -133,12 +133,7 @@ impl Inspector for Debugger { // TODO: Does this increase gas cost? if let Err(err) = data.journaled_state.load_account(call.caller, data.db) { let gas = Gas::new(call.gas_limit); - return ( - InstructionResult::Revert, - None, - gas, - alloy_primitives::Bytes(err.encode_string().0), - ) + return (InstructionResult::Revert, None, gas, foundry_cheatcodes::Error::encode(err)) } let nonce = data.journaled_state.account(call.caller).info.nonce; diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index bcafdf0aebd8b..d04c5a8db0ecd 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -19,8 +19,9 @@ foundry-evm-core.workspace = true foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } -alloy-json-abi = { workspace = true } +alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-sol-types.workspace = true ethers = { workspace = true, features = ["ethers-solc"] } revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/evm/traces/src/decoder.rs b/crates/evm/traces/src/decoder/mod.rs similarity index 73% rename from crates/evm/traces/src/decoder.rs rename to crates/evm/traces/src/decoder/mod.rs index ca9406afcb58a..7430d51275c13 100644 --- a/crates/evm/traces/src/decoder.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -1,11 +1,11 @@ use crate::{ identifier::{AddressIdentity, SingleSignaturesIdentifier, TraceIdentifier}, node::CallTraceNode, - utils, CallTraceArena, RawOrDecodedCall, RawOrDecodedLog, RawOrDecodedReturnData, + utils, CallTraceArena, RawOrDecodedLog, TraceCallData, TraceRetData, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; use alloy_json_abi::{Event, Function, JsonAbi as Abi}; -use alloy_primitives::{Address, FixedBytes, B256}; +use alloy_primitives::{Address, Selector, B256}; use foundry_common::{abi::get_indexed_event, SELECTOR_LEN}; use foundry_evm_core::{ abi::{CONSOLE_ABI, HARDHAT_CONSOLE_ABI, HEVM_ABI}, @@ -19,6 +19,8 @@ use foundry_utils::types::ToAlloy; use once_cell::sync::OnceCell; use std::collections::{BTreeMap, HashMap}; +mod precompiles; + /// Build a new [CallTraceDecoder]. #[derive(Default)] #[must_use = "builders do nothing unless you call `build` on them"] @@ -83,8 +85,6 @@ impl CallTraceDecoderBuilder { /// different sets might overlap. #[derive(Clone, Default, Debug)] pub struct CallTraceDecoder { - /// Information for decoding precompile calls. - pub precompiles: HashMap, /// Addresses identified to be a specific contract. /// /// The values are in the form `":"`. @@ -94,7 +94,7 @@ pub struct CallTraceDecoder { /// Information whether the contract address has a receive function pub receive_contracts: HashMap, /// A mapping of signatures to their known functions - pub functions: BTreeMap, Vec>, + pub functions: BTreeMap>, /// All known events pub events: BTreeMap<(B256, usize), Vec>, /// All known errors @@ -105,27 +105,6 @@ pub struct CallTraceDecoder { pub verbosity: u8, } -/// Returns an expression of the type `[(Address, Function); N]` -macro_rules! precompiles { - ($($number:literal : $name:ident($( $name_in:ident : $in:expr ),* $(,)?) -> ($( $name_out:ident : $out:expr ),* $(,)?)),+ $(,)?) => {{ - use std::string::String as RustString; - use ethers::abi::ParamType::*; - [$( - ( - alloy_primitives::Address::with_last_byte($number), - #[allow(deprecated)] - ethers::abi::Function { - name: RustString::from(stringify!($name)), - inputs: vec![$(ethers::abi::Param { name: RustString::from(stringify!($name_in)), kind: $in, internal_type: None, }),*], - outputs: vec![$(ethers::abi::Param { name: RustString::from(stringify!($name_out)), kind: $out, internal_type: None, }),*], - constant: None, - state_mutability: ethers::abi::StateMutability::Pure, - }, - ), - )+] - }}; -} - impl CallTraceDecoder { /// Creates a new call trace decoder. /// @@ -140,20 +119,6 @@ impl CallTraceDecoder { fn init() -> Self { Self { - // TODO: These are the Ethereum precompiles. We should add a way to support precompiles - // for other networks, too. - precompiles: precompiles!( - 0x01: ecrecover(hash: FixedBytes(32), v: Uint(256), r: Uint(256), s: Uint(256)) -> (publicAddress: Address), - 0x02: sha256(data: Bytes) -> (hash: FixedBytes(32)), - 0x03: ripemd(data: Bytes) -> (hash: FixedBytes(32)), - 0x04: identity(data: Bytes) -> (data: Bytes), - 0x05: modexp(Bsize: Uint(256), Esize: Uint(256), Msize: Uint(256), BEM: Bytes) -> (value: Bytes), - 0x06: ecadd(x1: Uint(256), y1: Uint(256), x2: Uint(256), y2: Uint(256)) -> (x: Uint(256), y: Uint(256)), - 0x07: ecmul(x1: Uint(256), y1: Uint(256), s: Uint(256)) -> (x: Uint(256), y: Uint(256)), - 0x08: ecpairing(x1: Uint(256), y1: Uint(256), x2: Uint(256), y2: Uint(256), x3: Uint(256), y3: Uint(256)) -> (success: Uint(256)), - 0x09: blake2f(rounds: Uint(4), h: FixedBytes(64), m: FixedBytes(128), t: FixedBytes(16), f: FixedBytes(1)) -> (h: FixedBytes(64)), - ).into_iter().map(|(addr, func)| (addr, func.to_alloy())).collect(), - contracts: Default::default(), labels: [ @@ -241,28 +206,37 @@ impl CallTraceDecoder { } } + /// Decodes all nodes in the specified call trace. pub async fn decode(&self, traces: &mut CallTraceArena) { for node in &mut traces.arena { // Set contract name - if let Some(contract) = self.contracts.get(&node.trace.address).cloned() { - node.trace.contract = Some(contract); + if let Some(contract) = self.contracts.get(&node.trace.address) { + node.trace.contract = Some(contract.clone()); } // Set label - if let Some(label) = self.labels.get(&node.trace.address).cloned() { - node.trace.label = Some(label); + if let Some(label) = self.labels.get(&node.trace.address) { + node.trace.label = Some(label.clone()); } + // Decode events + self.decode_events(node).await; + // Decode call - if let Some(precompile_fn) = self.precompiles.get(&node.trace.address) { - node.decode_precompile(precompile_fn, &self.labels); - } else if let RawOrDecodedCall::Raw(ref bytes) = node.trace.data { - if bytes.len() >= 4 { + // TODO: chain ID argument + if precompiles::decode(&mut node.trace, 1) { + return + } + + if let TraceCallData::Raw(bytes) = &node.trace.data { + if bytes.len() >= SELECTOR_LEN { if let Some(funcs) = self.functions.get(&bytes[..SELECTOR_LEN]) { node.decode_function(funcs, &self.labels, &self.errors, self.verbosity); } else if node.trace.address == DEFAULT_CREATE2_DEPLOYER { - node.trace.data = - RawOrDecodedCall::Decoded("create2".to_string(), String::new(), vec![]); + node.trace.data = TraceCallData::Decoded { + signature: "create2".to_string(), + args: vec![], + }; } else if let Some(identifier) = &self.signature_identifier { if let Some(function) = identifier.write().await.identify_function(&bytes[..SELECTOR_LEN]).await @@ -276,35 +250,24 @@ impl CallTraceDecoder { } } } else { - let has_receive = self - .receive_contracts - .get(&node.trace.address) - .copied() - .unwrap_or_default(); - let func_name = - if bytes.is_empty() && has_receive { "receive" } else { "fallback" }; - - node.trace.data = - RawOrDecodedCall::Decoded(func_name.to_string(), String::new(), Vec::new()); - - if let RawOrDecodedReturnData::Raw(bytes) = &node.trace.output { + let has_receive = + self.receive_contracts.get(&node.trace.address).copied().unwrap_or(false); + let signature = + if bytes.is_empty() && has_receive { "receive()" } else { "fallback()" } + .into(); + node.trace.data = TraceCallData::Decoded { signature, args: Vec::new() }; + + if let TraceRetData::Raw(bytes) = &node.trace.output { if !node.trace.success { - if let Ok(decoded_error) = decode::decode_revert( - &bytes[..], + node.trace.output = TraceRetData::Decoded(decode::decode_revert( + bytes, Some(&self.errors), Some(node.trace.status), - ) { - node.trace.output = RawOrDecodedReturnData::Decoded(format!( - r#""{decoded_error}""# - )); - } + )); } } } } - - // Decode events - self.decode_events(node).await; } } diff --git a/crates/evm/traces/src/decoder/precompiles.rs b/crates/evm/traces/src/decoder/precompiles.rs new file mode 100644 index 0000000000000..90e19a98cc503 --- /dev/null +++ b/crates/evm/traces/src/decoder/precompiles.rs @@ -0,0 +1,204 @@ +use crate::{CallTrace, TraceCallData}; +use alloy_primitives::{B256, U256}; +use alloy_sol_types::{abi, sol, SolCall}; +use itertools::Itertools; + +sol! { +/// EVM precompiles interface. For illustration purposes only, as precompiles don't follow the +/// Solidity ABI codec. +/// +/// Parameter names and types are taken from [evm.codes](https://www.evm.codes/precompiled). +interface Precompiles { + struct EcPairingInput { + uint256 x1; + uint256 y1; + uint256 x2; + uint256 y2; + uint256 x3; + uint256 y3; + } + + /* 0x01 */ function ecrecover(bytes32 hash, uint8 v, uint256 r, uint256 s) returns (address publicAddress); + /* 0x02 */ function sha256(bytes data) returns (bytes32 hash); + /* 0x03 */ function ripemd(bytes data) returns (bytes20 hash); + /* 0x04 */ function identity(bytes data) returns (bytes data); + /* 0x05 */ function modexp(uint256 Bsize, uint256 Esize, uint256 Msize, bytes B, bytes E, bytes M) returns (bytes value); + /* 0x06 */ function ecadd(uint256 x1, uint256 y1, uint256 x2, uint256 y2) returns (uint256 x, uint256 y); + /* 0x07 */ function ecmul(uint256 x1, uint256 y1, uint256 s) returns (uint256 x, uint256 y); + /* 0x08 */ function ecpairing(EcPairingInput[] input) returns (bool success); + /* 0x09 */ function blake2f(uint32 rounds, uint64[8] h, uint64[16] m, uint64[2] t, bool f) returns (uint64[8] h); + /* 0x0a */ function pointEvaluation(bytes32 versionedHash, bytes32 z, bytes32 y, bytes1[48] commitment, bytes1[48] proof) returns (bytes value); +} +} +use Precompiles::*; + +macro_rules! tri { + ($e:expr) => { + match $e { + Ok(x) => x, + Err(_) => return false, + } + }; +} + +/// Tries to decode a precompile call. Returns `true` if successful. +pub(super) fn decode(trace: &mut CallTrace, _chain_id: u64) -> bool { + let [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, x @ 0x01..=0x0a] = + trace.address.0 .0 + else { + return false + }; + + let TraceCallData::Raw(data) = &trace.data else { return false }; + + let (signature, args) = match x { + 0x01 => { + let (sig, ecrecoverCall { hash, v, r, s }) = tri!(abi_decode_call(data)); + (sig, vec![hash.to_string(), v.to_string(), r.to_string(), s.to_string()]) + } + 0x02 => (sha256Call::SIGNATURE, vec![data.to_string()]), + 0x03 => (ripemdCall::SIGNATURE, vec![data.to_string()]), + 0x04 => (identityCall::SIGNATURE, vec![data.to_string()]), + 0x05 => (modexpCall::SIGNATURE, tri!(decode_modexp(data))), + 0x06 => { + let (sig, ecaddCall { x1, y1, x2, y2 }) = tri!(abi_decode_call(data)); + (sig, vec![x1.to_string(), y1.to_string(), x2.to_string(), y2.to_string()]) + } + 0x07 => { + let (sig, ecmulCall { x1, y1, s }) = tri!(abi_decode_call(data)); + (sig, vec![x1.to_string(), y1.to_string(), s.to_string()]) + } + 0x08 => (ecpairingCall::SIGNATURE, tri!(decode_ecpairing(data))), + 0x09 => (blake2fCall::SIGNATURE, tri!(decode_blake2f(data))), + 0x0a => (pointEvaluationCall::SIGNATURE, tri!(decode_kzg(data))), + _ => unreachable!(), + }; + + // TODO: Other chain precompiles + + trace.data = TraceCallData::Decoded { signature: signature.to_string(), args }; + + trace.contract = Some("PRECOMPILES".into()); + + true +} + +// Note: we use the ABI decoder, but this is not necessarily ABI-encoded data. It's just a +// convenient way to decode the data. + +fn decode_modexp(data: &[u8]) -> alloy_sol_types::Result> { + let mut decoder = abi::Decoder::new(data, false); + let b_size = decoder.take_offset()?; + let e_size = decoder.take_offset()?; + let m_size = decoder.take_offset()?; + let b = decoder.take_slice_unchecked(b_size)?; + let e = decoder.take_slice_unchecked(e_size)?; + let m = decoder.take_slice_unchecked(m_size)?; + Ok(vec![ + b_size.to_string(), + e_size.to_string(), + m_size.to_string(), + hex::encode_prefixed(b), + hex::encode_prefixed(e), + hex::encode_prefixed(m), + ]) +} + +fn decode_ecpairing(data: &[u8]) -> alloy_sol_types::Result> { + let mut decoder = abi::Decoder::new(data, false); + let mut values = Vec::new(); + // input must be either empty or a multiple of 6 32-byte values + let mut tmp = <[&B256; 6]>::default(); + while !decoder.is_empty() { + for tmp in &mut tmp { + *tmp = decoder.take_word()?; + } + values.push(iter_to_string(tmp.iter().map(|x| U256::from_be_bytes(x.0)))); + } + Ok(values) +} + +fn decode_blake2f<'a>(data: &'a [u8]) -> alloy_sol_types::Result> { + let mut decoder = abi::Decoder::new(data, false); + let rounds = u32::from_be_bytes(decoder.take_slice_unchecked(4)?.try_into().unwrap()); + let u64_le_list = + |x: &'a [u8]| x.chunks_exact(8).map(|x| u64::from_le_bytes(x.try_into().unwrap())); + let h = u64_le_list(decoder.take_slice_unchecked(64)?); + let m = u64_le_list(decoder.take_slice_unchecked(128)?); + let t = u64_le_list(decoder.take_slice_unchecked(16)?); + let f = decoder.take_slice_unchecked(1)?[0]; + Ok(vec![ + rounds.to_string(), + iter_to_string(h), + iter_to_string(m), + iter_to_string(t), + f.to_string(), + ]) +} + +fn decode_kzg(data: &[u8]) -> alloy_sol_types::Result> { + let mut decoder = abi::Decoder::new(data, false); + let versioned_hash = decoder.take_word()?; + let z = decoder.take_word()?; + let y = decoder.take_word()?; + let commitment = decoder.take_slice_unchecked(48)?; + let proof = decoder.take_slice_unchecked(48)?; + Ok(vec![ + versioned_hash.to_string(), + z.to_string(), + y.to_string(), + hex::encode_prefixed(commitment), + hex::encode_prefixed(proof), + ]) +} + +fn abi_decode_call(data: &[u8]) -> alloy_sol_types::Result<(&'static str, T)> { + // raw because there are no selectors here + Ok((T::SIGNATURE, T::abi_decode_raw(data, false)?)) +} + +fn iter_to_string, T: std::fmt::Display>(iter: I) -> String { + format!("[{}]", iter.format(", ")) +} + +#[cfg(test)] +mod tests { + use super::*; + use alloy_primitives::hex; + + #[test] + fn ecpairing() { + // https://github.com/foundry-rs/foundry/issues/5337#issuecomment-1627384480 + let data = hex!( + " + 26bbb723f965460ca7282cd75f0e3e7c67b15817f7cee60856b394936ed02917 + 0fbe873ac672168143a91535450bab6c412dce8dc8b66a88f2da6e245f9282df + 13cd4f0451538ece5014fe6688b197aefcc611a5c6a7c319f834f2188ba04b08 + 126ff07e81490a1b6ae92b2d9e700c8e23e9d5c7f6ab857027213819a6c9ae7d + 04183624c9858a56c54deb237c26cb4355bc2551312004e65fc5b299440b15a3 + 2e4b11aa549ad6c667057b18be4f4437fda92f018a59430ebb992fa3462c9ca1 + 2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e2 + 14bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926 + 0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c + 0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab + 304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a7 + 1739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8 + 001d6fedb032f70e377635238e0563f131670001f6abf439adb3a9d5d52073c6 + 1889afe91e4e367f898a7fcd6464e5ca4e822fe169bccb624f6aeb87e4d060bc + 198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2 + 1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed + 090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b + 12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa + 2dde6d7baf0bfa09329ec8d44c38282f5bf7f9ead1914edd7dcaebb498c84519 + 0c359f868a85c6e6c1ea819cfab4a867501a3688324d74df1fe76556558b1937 + 29f41c6e0e30802e2749bfb0729810876f3423e6f24829ad3e30adb1934f1c8a + 030e7a5f70bb5daa6e18d80d6d447e772efb0bb7fb9d0ffcd54fc5a48af1286d + 0ea726b117e48cda8bce2349405f006a84cdd3dcfba12efc990df25970a27b6d + 30364cd4f8a293b1a04f0153548d3e01baad091c69097ca4e9f26be63e4095b5 + " + ); + let decoded = decode_ecpairing(&data).unwrap(); + // 4 arrays of 6 32-byte values + assert_eq!(decoded.len(), 4); + } +} diff --git a/crates/evm/traces/src/inspector.rs b/crates/evm/traces/src/inspector.rs index 0c82714b531ba..cb7e24f9658c5 100644 --- a/crates/evm/traces/src/inspector.rs +++ b/crates/evm/traces/src/inspector.rs @@ -1,6 +1,6 @@ use crate::{ - CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, RawOrDecodedCall, RawOrDecodedLog, - RawOrDecodedReturnData, + CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, RawOrDecodedLog, TraceCallData, + TraceRetData, }; use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; use foundry_evm_core::{ @@ -45,7 +45,7 @@ impl Tracer { depth, address, kind, - data: RawOrDecodedCall::Raw(data.into()), + data: TraceCallData::Raw(data.into()), value, status: InstructionResult::Continue, caller, @@ -68,7 +68,7 @@ impl Tracer { trace.status = status; trace.success = success; trace.gas_cost = cost; - trace.output = RawOrDecodedReturnData::Raw(output.into()); + trace.output = TraceRetData::Raw(output.into()); if let Some(address) = address { trace.address = address; diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 1b85070665352..87c4dea2fcf5d 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -92,7 +92,7 @@ impl CallTraceArena { .iter() .map(|node| { if node.trace.created() { - if let RawOrDecodedReturnData::Raw(ref bytes) = node.trace.output { + if let TraceRetData::Raw(bytes) = &node.trace.output { return (&node.trace.address, Some(bytes.as_ref())) } } @@ -138,29 +138,23 @@ impl CallTraceArena { // Add step to geth trace struct_logs.push(log); - // Check if the step was a call - match step.op { - Instruction::OpCode(opc) => { - match opc { - // If yes, descend into a child trace - opcode::CREATE | - opcode::CREATE2 | - opcode::DELEGATECALL | - opcode::CALL | - opcode::STATICCALL | - opcode::CALLCODE => { - self.add_to_geth_trace( - storage, - &self.arena[trace_node.children[child_id]], - struct_logs, - opts, - ); - child_id += 1; - } - _ => {} - } - } - Instruction::Cheatcode(_) => {} + // Descend into a child trace if the step was a call + if let Instruction::OpCode( + opcode::CREATE | + opcode::CREATE2 | + opcode::DELEGATECALL | + opcode::CALL | + opcode::STATICCALL | + opcode::CALLCODE, + ) = step.op + { + self.add_to_geth_trace( + storage, + &self.arena[trace_node.children[child_id]], + struct_logs, + opts, + ); + child_id += 1; } } } @@ -253,14 +247,13 @@ impl fmt::Display for CallTraceArena { // Display trace return data let color = trace_color(&node.trace); - write!(writer, "{child}{EDGE}")?; - write!(writer, "{}", color.paint(RETURN))?; + write!(writer, "{child}{EDGE}{}", color.paint(RETURN))?; if node.trace.created() { match &node.trace.output { - RawOrDecodedReturnData::Raw(bytes) => { + TraceRetData::Raw(bytes) => { writeln!(writer, "{} bytes of code", bytes.len())?; } - RawOrDecodedReturnData::Decoded(val) => { + TraceRetData::Decoded(val) => { writeln!(writer, "{val}")?; } } @@ -327,48 +320,54 @@ pub enum LogCallOrder { /// Raw or decoded calldata. #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] -pub enum RawOrDecodedCall { - /// Raw calldata +pub enum TraceCallData { + /// Raw calldata bytes. Raw(Bytes), /// Decoded calldata. - /// - /// The first element in the tuple is the function name, second is the function signature and - /// the third element is a vector of decoded parameters. - Decoded(String, String, Vec), + Decoded { + /// The function signature. + signature: String, + /// The function arguments. + args: Vec, + }, } -impl RawOrDecodedCall { - pub fn to_raw(&self) -> Vec { - match self { - RawOrDecodedCall::Raw(raw) => raw.to_vec(), - RawOrDecodedCall::Decoded(_, _, _) => { - vec![] - } - } +impl Default for TraceCallData { + fn default() -> Self { + Self::Raw(Bytes::new()) } } -impl Default for RawOrDecodedCall { - fn default() -> Self { - RawOrDecodedCall::Raw(Default::default()) +impl TraceCallData { + pub fn as_bytes(&self) -> &[u8] { + match self { + TraceCallData::Raw(raw) => raw, + TraceCallData::Decoded { .. } => &[], + } } } /// Raw or decoded return data. #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] -pub enum RawOrDecodedReturnData { - /// Raw return data +pub enum TraceRetData { + /// Raw return data. Raw(Bytes), - /// Decoded return data + /// Decoded return data. Decoded(String), } -impl RawOrDecodedReturnData { +impl Default for TraceRetData { + fn default() -> Self { + Self::Raw(Bytes::new()) + } +} + +impl TraceRetData { /// Returns the data as [`Bytes`] pub fn to_bytes(&self) -> Bytes { match self { - RawOrDecodedReturnData::Raw(raw) => raw.clone(), - RawOrDecodedReturnData::Decoded(val) => val.as_bytes().to_vec().into(), + TraceRetData::Raw(raw) => raw.clone(), + TraceRetData::Decoded(val) => val.as_bytes().to_vec().into(), } } @@ -377,23 +376,17 @@ impl RawOrDecodedReturnData { } } -impl Default for RawOrDecodedReturnData { - fn default() -> Self { - RawOrDecodedReturnData::Raw(Default::default()) - } -} - -impl fmt::Display for RawOrDecodedReturnData { +impl fmt::Display for TraceRetData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self { - RawOrDecodedReturnData::Raw(bytes) => { + TraceRetData::Raw(bytes) => { if bytes.is_empty() { write!(f, "()") } else { bytes.fmt(f) } } - RawOrDecodedReturnData::Decoded(decoded) => f.write_str(decoded), + TraceRetData::Decoded(decoded) => f.write_str(decoded), } } } @@ -477,10 +470,10 @@ pub struct CallTrace { /// The value transferred in the call pub value: U256, /// The calldata for the call, or the init code for contract creations - pub data: RawOrDecodedCall, + pub data: TraceCallData, /// The return data of the call if this was not a contract creation, otherwise it is the /// runtime bytecode of the created contract - pub output: RawOrDecodedReturnData, + pub output: TraceRetData, /// The gas cost of the call pub gas_cost: u64, /// The status of the trace's call @@ -524,54 +517,53 @@ impl Default for CallTrace { impl fmt::Display for CallTrace { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let address = self.address.to_checksum(None); + write!(f, "[{}] ", self.gas_cost)?; if self.created() { write!( f, - "[{}] {}{} {}@{}", - self.gas_cost, + "{}{} {}@{}", Paint::yellow(CALL), Paint::yellow("new"), - self.label.as_ref().unwrap_or(&"".to_string()), + self.label.as_deref().unwrap_or(""), address - )?; + ) } else { - let (func, inputs) = match &self.data { - RawOrDecodedCall::Raw(bytes) => { + let (func_name, inputs) = match &self.data { + TraceCallData::Raw(bytes) => { // We assume that the fallback function (`data.len() < 4`) counts as decoded // calldata - assert!(bytes.len() >= 4); - (hex::encode(&bytes[0..4]), hex::encode(&bytes[4..])) + let (selector, data) = bytes.split_at(4); + (hex::encode(selector), hex::encode(data)) + } + TraceCallData::Decoded { signature, args } => { + let name = signature.split('(').next().unwrap(); + (name.to_string(), args.join(", ")) } - RawOrDecodedCall::Decoded(func, _, inputs) => (func.clone(), inputs.join(", ")), }; let action = match self.kind { // do not show anything for CALLs CallKind::Call => "", - CallKind::StaticCall => "[staticcall]", - CallKind::CallCode => "[callcode]", - CallKind::DelegateCall => "[delegatecall]", - _ => unreachable!(), + CallKind::StaticCall => " [staticcall]", + CallKind::CallCode => " [callcode]", + CallKind::DelegateCall => " [delegatecall]", + CallKind::Create | CallKind::Create2 => unreachable!(), }; let color = trace_color(self); write!( f, - "[{}] {}::{}{}({}) {}", - self.gas_cost, - color.paint(self.label.as_ref().unwrap_or(&address)), - color.paint(func), - if !self.value == U256::ZERO { - format!("{{value: {}}}", self.value) + "{addr}::{func_name}{opt_value}({inputs}){action}", + addr = color.paint(self.label.as_deref().unwrap_or(&address)), + func_name = color.paint(func_name), + opt_value = if self.value == U256::ZERO { + String::new() } else { - "".to_string() + format!("{{value: {}}}", self.value) }, - inputs, - Paint::yellow(action), - )?; + action = Paint::yellow(action), + ) } - - Ok(()) } } diff --git a/crates/evm/traces/src/node.rs b/crates/evm/traces/src/node.rs index e212f60ca9cdd..20d21d73dec4e 100644 --- a/crates/evm/traces/src/node.rs +++ b/crates/evm/traces/src/node.rs @@ -1,6 +1,6 @@ use crate::{ - utils, utils::decode_cheatcode_outputs, CallTrace, LogCallOrder, RawOrDecodedCall, - RawOrDecodedLog, RawOrDecodedReturnData, + utils, utils::decode_cheatcode_outputs, CallTrace, LogCallOrder, RawOrDecodedLog, + TraceCallData, TraceRetData, }; use alloy_dyn_abi::{FunctionExt, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi as Abi}; @@ -76,7 +76,7 @@ impl CallTraceNode { to: self.trace.address.to_ethers(), value: self.trace.value.to_ethers(), gas: self.trace.gas_cost.into(), - input: self.trace.data.to_raw().into(), + input: self.trace.data.as_bytes().to_vec().into(), call_type: self.kind().into(), }) } @@ -84,7 +84,7 @@ impl CallTraceNode { from: self.trace.caller.to_ethers(), value: self.trace.value.to_ethers(), gas: self.trace.gas_cost.into(), - init: self.trace.data.to_raw().into(), + init: self.trace.data.as_bytes().to_vec().into(), }), } } @@ -104,8 +104,8 @@ impl CallTraceNode { // the same name and inputs. let func = &funcs[0]; - if let RawOrDecodedCall::Raw(ref bytes) = self.trace.data { - let inputs = if bytes.len() >= SELECTOR_LEN { + if let TraceCallData::Raw(ref bytes) = self.trace.data { + let args = if bytes.len() >= SELECTOR_LEN { if self.trace.address == CHEATCODE_ADDRESS { // Try to decode cheatcode inputs in a more custom way utils::decode_cheatcode_inputs(func, bytes, errors, verbosity).unwrap_or_else( @@ -128,17 +128,16 @@ impl CallTraceNode { }; // add signature to decoded calls for better calls filtering - self.trace.data = - RawOrDecodedCall::Decoded(func.name.clone(), func.signature(), inputs); + self.trace.data = TraceCallData::Decoded { signature: func.signature(), args }; - if let RawOrDecodedReturnData::Raw(bytes) = &self.trace.output { - if !bytes.is_empty() && self.trace.success { + if let TraceRetData::Raw(bytes) = &self.trace.output { + if self.trace.success { if self.trace.address == CHEATCODE_ADDRESS { if let Some(decoded) = funcs .iter() .find_map(|func| decode_cheatcode_outputs(func, bytes, verbosity)) { - self.trace.output = RawOrDecodedReturnData::Decoded(decoded); + self.trace.output = TraceRetData::Decoded(decoded); return } } @@ -149,7 +148,7 @@ impl CallTraceNode { // Functions coming from an external database do not have any outputs // specified, and will lead to returning an empty list of tokens. if !tokens.is_empty() { - self.trace.output = RawOrDecodedReturnData::Decoded( + self.trace.output = TraceRetData::Decoded( tokens .iter() .map(|token| utils::label(token, labels)) @@ -158,11 +157,12 @@ impl CallTraceNode { ); } } - } else if let Ok(decoded_error) = - decode::decode_revert(bytes, Some(errors), Some(self.trace.status)) - { - self.trace.output = - RawOrDecodedReturnData::Decoded(format!(r#""{decoded_error}""#)); + } else { + self.trace.output = TraceRetData::Decoded(decode::decode_revert( + bytes, + Some(errors), + Some(self.trace.status), + )); } } } @@ -174,19 +174,18 @@ impl CallTraceNode { precompile_fn: &Function, labels: &HashMap, ) { - if let RawOrDecodedCall::Raw(ref bytes) = self.trace.data { + if let TraceCallData::Raw(ref bytes) = self.trace.data { self.trace.label = Some("PRECOMPILE".to_string()); - self.trace.data = RawOrDecodedCall::Decoded( - precompile_fn.name.clone(), - precompile_fn.signature(), - precompile_fn.abi_decode_input(bytes, false).map_or_else( + self.trace.data = TraceCallData::Decoded { + signature: precompile_fn.signature(), + args: precompile_fn.abi_decode_input(bytes, false).map_or_else( |_| vec![hex::encode(bytes)], |tokens| tokens.iter().map(|token| utils::label(token, labels)).collect(), ), - ); + }; - if let RawOrDecodedReturnData::Raw(ref bytes) = self.trace.output { - self.trace.output = RawOrDecodedReturnData::Decoded( + if let TraceRetData::Raw(ref bytes) = self.trace.output { + self.trace.output = TraceRetData::Decoded( precompile_fn.abi_decode_output(bytes, false).map_or_else( |_| hex::encode(bytes), |tokens| { diff --git a/crates/evm/traces/src/utils.rs b/crates/evm/traces/src/utils.rs index c046fe5d6c16f..590ee250b4fd4 100644 --- a/crates/evm/traces/src/utils.rs +++ b/crates/evm/traces/src/utils.rs @@ -32,9 +32,7 @@ pub(crate) fn decode_cheatcode_inputs( verbosity: u8, ) -> Option> { match func.name.as_str() { - "expectRevert" => { - decode::decode_revert(data, Some(errors), None).ok().map(|decoded| vec![decoded]) - } + "expectRevert" => Some(vec![decode::decode_revert(data, Some(errors), None)]), "rememberKey" | "addr" | "startBroadcast" | "broadcast" => { // these functions accept a private key as uint256, which should not be // converted to plain text diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index e03f639152906..242971ba50142 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -173,7 +173,7 @@ impl ScriptArgs { return Some(AdditionalContract { opcode: node.kind(), address: node.trace.address, - init_code: node.trace.data.to_raw(), + init_code: node.trace.data.as_bytes().to_vec(), }) } None diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index e6f960ee8dcee..f5435dc3cd3db 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -20,8 +20,7 @@ use forge::{ opts::EvmOpts, traces::{ identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, - CallTraceDecoder, CallTraceDecoderBuilder, RawOrDecodedCall, RawOrDecodedReturnData, - TraceKind, Traces, + CallTraceDecoder, CallTraceDecoderBuilder, TraceCallData, TraceKind, TraceRetData, Traces, }, utils::CallKind, }; @@ -367,11 +366,10 @@ impl ScriptArgs { } if !result.success { - let revert_msg = decode::decode_revert(&result.returned[..], None, None) - .map(|err| format!("{err}\n")) - .unwrap_or_else(|_| "Script failed.\n".to_string()); - - eyre::bail!("{}", Paint::red(revert_msg)); + return Err(eyre::eyre!( + "script failed: {}", + decode::decode_revert(&result.returned[..], None, None) + )) } Ok(()) @@ -522,9 +520,9 @@ impl ScriptArgs { let mut unknown_c = 0usize; for node in create_nodes { // Calldata == init code - if let RawOrDecodedCall::Raw(ref init_code) = node.trace.data { + if let TraceCallData::Raw(ref init_code) = node.trace.data { // Output is the runtime code - if let RawOrDecodedReturnData::Raw(ref deployed_code) = node.trace.output { + if let TraceRetData::Raw(ref deployed_code) = node.trace.output { // Only push if it was not present already if !bytecodes.iter().any(|(_, b, _)| *b == init_code.as_ref()) { bytecodes.push((format!("Unknown{unknown_c}"), init_code, deployed_code)); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index a8e7cab04b372..baf8b9b97789e 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -1,7 +1,7 @@ use crate::{ constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, hashbrown::HashSet, - traces::{CallTraceArena, RawOrDecodedCall, TraceKind}, + traces::{CallTraceArena, TraceCallData, TraceKind}, }; use alloy_primitives::U256; use comfy_table::{presets::ASCII_MARKDOWN, *}; @@ -77,22 +77,23 @@ impl GasReport { let contract_info = self.contracts.entry(name.to_string()).or_default(); match &trace.data { - RawOrDecodedCall::Raw(bytes) => { + TraceCallData::Raw(bytes) => { if trace.created() { contract_info.gas = U256::from(trace.gas_cost); contract_info.size = U256::from(bytes.len()); } } - RawOrDecodedCall::Decoded(func, sig, _) => { + TraceCallData::Decoded { signature, .. } => { + let name = signature.split('(').next().unwrap(); // ignore any test/setup functions let should_include = - !(func.is_test() || func.is_invariant_test() || func.is_setup()); + !(name.is_test() || name.is_invariant_test() || name.is_setup()); if should_include { let gas_info = contract_info .functions - .entry(func.clone()) + .entry(name.into()) .or_default() - .entry(sig.clone()) + .entry(signature.clone()) .or_default(); gas_info.calls.push(U256::from(trace.gas_cost)); } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index b57866b26dfd5..6458e73fcca9b 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -148,11 +148,11 @@ impl<'a> ContractRunner<'a> { Err(EvmError::Execution(err)) => { let ExecutionErr { traces, labels, logs, reason, .. } = *err; error!(reason = ?reason, contract = ?address, "setUp failed"); - (logs, traces, labels, Some(format!("Setup failed: {reason}")), None) + (logs, traces, labels, Some(format!("setup failed: {reason}")), None) } Err(err) => { error!(reason=?err, contract= ?address, "setUp failed"); - (Vec::new(), None, BTreeMap::new(), Some(format!("Setup failed: {err}")), None) + (Vec::new(), None, BTreeMap::new(), Some(format!("setup failed: {err}")), None) } }; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 3b8a235b1df96..71934d19aa77c 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -627,7 +627,7 @@ forgetest_async!(can_deploy_with_create2, |prj: TestProject, cmd: TestCommand| a .assert_nonce_increment([(0, 2)]) .await // Running again results in error, since we're repeating the salt passed to CREATE2 - .run(ScriptOutcome::FailedScript); + .run(ScriptOutcome::ScriptFailed); }); forgetest_async!( diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index dabd7183c7223..16aa8e5689b15 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -18,7 +18,7 @@ async fn test_core() { vec![( "setUp()", false, - Some("Setup failed: setup failed predictably".to_string()), + Some("setup failed: revert: setup failed predictably".to_string()), None, None, )], @@ -65,7 +65,7 @@ async fn test_core() { vec![( "setUp()", false, - Some("Setup failed: execution error".to_string()), + Some("setup failed: execution error".to_string()), None, None, )], diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 30d97ed418a7d..771a009d9f5fc 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -26,7 +26,13 @@ async fn test_invariant() { ), ( "fuzz/invariant/common/InvariantInnerContract.t.sol:InvariantInnerContract", - vec![("invariantHideJesus()", false, Some("jesus betrayed.".into()), None, None)], + vec![( + "invariantHideJesus()", + false, + Some("revert: jesus betrayed".into()), + None, + None, + )], ), ( "fuzz/invariant/common/InvariantReentrancy.t.sol:InvariantReentrancy", @@ -35,11 +41,11 @@ async fn test_invariant() { ( "fuzz/invariant/common/InvariantTest1.t.sol:InvariantTest", vec![ - ("invariant_neverFalse()", false, Some("false.".into()), None, None), + ("invariant_neverFalse()", false, Some("revert: false".into()), None, None), ( "statefulFuzz_neverFalseWithInvariantAlias()", false, - Some("false.".into()), + Some("revert: false".into()), None, None, ), @@ -55,11 +61,23 @@ async fn test_invariant() { ), ( "fuzz/invariant/target/TargetSenders.t.sol:TargetSenders", - vec![("invariantTrueWorld()", false, Some("false world.".into()), None, None)], + vec![( + "invariantTrueWorld()", + false, + Some("revert: false world".into()), + None, + None, + )], ), ( "fuzz/invariant/target/TargetInterfaces.t.sol:TargetWorldInterfaces", - vec![("invariantTrueWorld()", false, Some("false world.".into()), None, None)], + vec![( + "invariantTrueWorld()", + false, + Some("revert: false world".into()), + None, + None, + )], ), ( "fuzz/invariant/target/ExcludeSenders.t.sol:ExcludeSenders", @@ -77,7 +95,13 @@ async fn test_invariant() { "fuzz/invariant/targetAbi/TargetArtifacts.t.sol:TargetArtifacts", vec![ ("invariantShouldPass()", true, None, None, None), - ("invariantShouldFail()", false, Some("false world.".into()), None, None), + ( + "invariantShouldFail()", + false, + Some("revert: false world".into()), + None, + None, + ), ], ), ( @@ -86,7 +110,13 @@ async fn test_invariant() { ), ( "fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:TargetArtifactSelectors2", - vec![("invariantShouldFail()", false, Some("its false.".into()), None, None)], + vec![( + "invariantShouldFail()", + false, + Some("revert: it's false".into()), + None, + None, + )], ), ]), ); @@ -112,7 +142,7 @@ async fn test_invariant_override() { &results, BTreeMap::from([( "fuzz/invariant/common/InvariantReentrancy.t.sol:InvariantReentrancy", - vec![("invariantNotStolen()", false, Some("stolen.".into()), None, None)], + vec![("invariantNotStolen()", false, Some("revert: stolen".into()), None, None)], )]), ); } @@ -142,7 +172,7 @@ async fn test_invariant_fail_on_revert() { vec![( "statefulFuzz_BrokenInvariant()", false, - Some("failed on revert".into()), + Some("revert: failed on revert".into()), None, None, )], diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 7fa87d849a1be..598746f612220 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -257,7 +257,7 @@ pub enum ScriptOutcome { MissingSender, MissingWallet, StaticCallNotAllowed, - FailedScript, + ScriptFailed, UnsupportedLibraries, ErrorSelectForkOnBroadcast, } @@ -272,7 +272,7 @@ impl ScriptOutcome { Self::MissingSender => "You seem to be using Foundry's default sender. Be sure to set your own --sender", Self::MissingWallet => "No associated wallet", Self::StaticCallNotAllowed => "staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead", - Self::FailedScript => "Script failed.", + Self::ScriptFailed => "script failed: ", Self::UnsupportedLibraries => "Multi chain deployment does not support library linking at the moment.", Self::ErrorSelectForkOnBroadcast => "cannot select forks during a broadcast", } @@ -289,7 +289,7 @@ impl ScriptOutcome { ScriptOutcome::StaticCallNotAllowed | ScriptOutcome::UnsupportedLibraries | ScriptOutcome::ErrorSelectForkOnBroadcast | - ScriptOutcome::FailedScript => true, + ScriptOutcome::ScriptFailed => true, } } } diff --git a/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol b/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol index 49e67e7d37d70..6e1100cef3cc6 100644 --- a/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol +++ b/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol @@ -45,6 +45,6 @@ contract InvariantInnerContract is DSTest { } function invariantHideJesus() public { - require(jesus.identity_revealed() == false, "jesus betrayed."); + require(jesus.identity_revealed() == false, "jesus betrayed"); } } diff --git a/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol b/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol index 38bb930ced98c..cf8cb4d37f94b 100644 --- a/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol +++ b/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol @@ -40,6 +40,6 @@ contract InvariantReentrancy is DSTest { } function invariantNotStolen() public { - require(vuln.stolen() == false, "stolen."); + require(vuln.stolen() == false, "stolen"); } } diff --git a/testdata/fuzz/invariant/common/InvariantTest1.t.sol b/testdata/fuzz/invariant/common/InvariantTest1.t.sol index 775b2cffd43df..3e9d84e321f60 100644 --- a/testdata/fuzz/invariant/common/InvariantTest1.t.sol +++ b/testdata/fuzz/invariant/common/InvariantTest1.t.sol @@ -30,10 +30,10 @@ contract InvariantTest is DSTest { } function invariant_neverFalse() public { - require(inv.flag1(), "false."); + require(inv.flag1(), "false"); } function statefulFuzz_neverFalseWithInvariantAlias() public { - require(inv.flag1(), "false."); + require(inv.flag1(), "false"); } } diff --git a/testdata/fuzz/invariant/target/ExcludeContracts.t.sol b/testdata/fuzz/invariant/target/ExcludeContracts.t.sol index 4b44c26680ab3..0367bdec22d46 100644 --- a/testdata/fuzz/invariant/target/ExcludeContracts.t.sol +++ b/testdata/fuzz/invariant/target/ExcludeContracts.t.sol @@ -26,6 +26,6 @@ contract ExcludeContracts is DSTest { } function invariantTrueWorld() public { - require(hello.world() == true, "false world."); + require(hello.world() == true, "false world"); } } diff --git a/testdata/fuzz/invariant/target/ExcludeSenders.t.sol b/testdata/fuzz/invariant/target/ExcludeSenders.t.sol index 34e01519932c3..d0399f681bca1 100644 --- a/testdata/fuzz/invariant/target/ExcludeSenders.t.sol +++ b/testdata/fuzz/invariant/target/ExcludeSenders.t.sol @@ -40,6 +40,6 @@ contract ExcludeSenders is DSTest { } function invariantTrueWorld() public { - require(hello.world() == true, "false world."); + require(hello.world() == true, "false world"); } } diff --git a/testdata/fuzz/invariant/target/TargetContracts.t.sol b/testdata/fuzz/invariant/target/TargetContracts.t.sol index 376e8ee15bcbd..288b9d8d5cd66 100644 --- a/testdata/fuzz/invariant/target/TargetContracts.t.sol +++ b/testdata/fuzz/invariant/target/TargetContracts.t.sol @@ -27,6 +27,6 @@ contract TargetContracts is DSTest { } function invariantTrueWorld() public { - require(hello2.world() == true, "false world."); + require(hello2.world() == true, "false world"); } } diff --git a/testdata/fuzz/invariant/target/TargetInterfaces.t.sol b/testdata/fuzz/invariant/target/TargetInterfaces.t.sol index 3f6d39f6ece5d..f6e94ad5d83c5 100644 --- a/testdata/fuzz/invariant/target/TargetInterfaces.t.sol +++ b/testdata/fuzz/invariant/target/TargetInterfaces.t.sol @@ -67,6 +67,6 @@ contract TargetWorldInterfaces is DSTest { } function invariantTrueWorld() public { - require(proxy.world() == false, "false world."); + require(proxy.world() == false, "false world"); } } diff --git a/testdata/fuzz/invariant/target/TargetSelectors.t.sol b/testdata/fuzz/invariant/target/TargetSelectors.t.sol index 289937efb9bbf..1adc889a95c62 100644 --- a/testdata/fuzz/invariant/target/TargetSelectors.t.sol +++ b/testdata/fuzz/invariant/target/TargetSelectors.t.sol @@ -36,6 +36,6 @@ contract TargetSelectors is DSTest { } function invariantTrueWorld() public { - require(hello.world() == true, "false world."); + require(hello.world() == true, "false world"); } } diff --git a/testdata/fuzz/invariant/target/TargetSenders.t.sol b/testdata/fuzz/invariant/target/TargetSenders.t.sol index 94735404bc8c9..0bd1d6b9549c0 100644 --- a/testdata/fuzz/invariant/target/TargetSenders.t.sol +++ b/testdata/fuzz/invariant/target/TargetSenders.t.sol @@ -26,6 +26,6 @@ contract TargetSenders is DSTest { } function invariantTrueWorld() public { - require(hello.world() == true, "false world."); + require(hello.world() == true, "false world"); } } diff --git a/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol b/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol index 80947360ba826..82f56229d2944 100644 --- a/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol +++ b/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol @@ -40,6 +40,6 @@ contract ExcludeArtifacts is DSTest { } function invariantShouldPass() public { - require(excluded.world() == true, "false world."); + require(excluded.world() == true, "false world"); } } diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol index 69fa42161903b..fae4a49866456 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol +++ b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol @@ -36,6 +36,6 @@ contract TargetArtifactSelectors is DSTest { } function invariantShouldPass() public { - require(hello.world() == true, "false world."); + require(hello.world() == true, "false world"); } } diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol index bd4c1c62bcc49..d4091d4f3ea96 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol +++ b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol @@ -63,6 +63,6 @@ contract TargetArtifactSelectors2 is DSTest { if (!parent.should_be_true()) { require(!Child(address(parent.child())).changed(), "should have not happened"); } - require(parent.should_be_true() == true, "its false."); + require(parent.should_be_true() == true, "it's false"); } } diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol b/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol index e99e3b8671c0a..07570fee7bf07 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol +++ b/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol @@ -35,10 +35,10 @@ contract TargetArtifacts is DSTest { } function invariantShouldPass() public { - require(target2.world() == true || target1.world() == true || hello.world() == true, "false world."); + require(target2.world() == true || target1.world() == true || hello.world() == true, "false world"); } function invariantShouldFail() public { - require(target2.world() == true || target1.world() == true, "false world."); + require(target2.world() == true || target1.world() == true, "false world"); } } From 3432386751028f912bf0d710109bcff350d7aacc Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 7 Nov 2023 12:05:29 -0400 Subject: [PATCH 0245/1963] feat(`anvil`): `anvil_metadata` (#6240) * feat: anvil_metadata * chore: add rpc * chore: tests * chore: add alias for hardhat_metadata --- crates/anvil/core/src/eth/mod.rs | 7 +++ crates/anvil/core/src/types.rs | 28 +++++++++++- crates/anvil/src/eth/api.rs | 42 ++++++++++++++++- crates/anvil/tests/it/anvil_api.rs | 72 +++++++++++++++++++++++++++++- 4 files changed, 145 insertions(+), 4 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index a4b25fd8d9b73..4f1a4e869024e 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -490,6 +490,13 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "anvil_nodeInfo", with = "empty_params"))] NodeInfo(()), + /// Retrieves the Anvil node metadata. + #[cfg_attr( + feature = "serde", + serde(rename = "anvil_metadata", alias = "hardhat_metadata", with = "empty_params") + )] + AnvilMetadata(()), + // Ganache compatible calls /// Snapshot the state of the blockchain at the current block. #[cfg_attr( diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 80ca1604d85a0..9dd87aacd74ed 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -1,4 +1,4 @@ -use ethers_core::types::{H256, U256, U64}; +use ethers_core::types::{TxHash, H256, U256, U64}; use revm::primitives::SpecId; #[cfg(feature = "serde")] @@ -204,6 +204,32 @@ pub struct NodeForkConfig { pub fork_retry_backoff: Option, } +/// Anvil equivalent of `hardhat_metadata`. +/// Metadata about the current Anvil instance. +/// See +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct AnvilMetadata { + pub client_version: &'static str, + pub chain_id: U256, + pub instance_id: H256, + pub latest_block_number: U64, + pub latest_block_hash: H256, + pub forked_network: Option, +} + +/// Information about the forked network. +/// See +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct ForkedNetwork { + pub chain_id: U256, + pub fork_block_number: U64, + pub fork_block_hash: TxHash, +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 01142018b8c06..95dfc6a064974 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -39,7 +39,10 @@ use anvil_core::{ }, EthRequest, }, - types::{EvmMineOptions, Forking, Index, NodeEnvironment, NodeForkConfig, NodeInfo, Work}, + types::{ + AnvilMetadata, EvmMineOptions, ForkedNetwork, Forking, Index, NodeEnvironment, + NodeForkConfig, NodeInfo, Work, + }, }; use anvil_rpc::{error::RpcError, response::ResponseResult}; use ethers::{ @@ -108,6 +111,8 @@ pub struct EthApi { transaction_order: Arc>, /// Whether we're listening for RPC calls net_listening: bool, + /// The instance ID. Changes on every reset. + instance_id: Arc>, } // === impl Eth RPC API === @@ -138,6 +143,7 @@ impl EthApi { filters, net_listening: true, transaction_order: Arc::new(RwLock::new(transactions_order)), + instance_id: Arc::new(RwLock::new(H256::random())), } } @@ -315,6 +321,7 @@ impl EthApi { EthRequest::DumpState(_) => self.anvil_dump_state().await.to_rpc_result(), EthRequest::LoadState(buf) => self.anvil_load_state(buf).await.to_rpc_result(), EthRequest::NodeInfo(_) => self.anvil_node_info().await.to_rpc_result(), + EthRequest::AnvilMetadata(_) => self.anvil_metadata().await.to_rpc_result(), EthRequest::EvmSnapshot(_) => self.evm_snapshot().await.to_rpc_result(), EthRequest::EvmRevert(id) => self.evm_revert(id).await.to_rpc_result(), EthRequest::EvmIncreaseTime(time) => self.evm_increase_time(time).await.to_rpc_result(), @@ -1532,6 +1539,8 @@ impl EthApi { pub async fn anvil_reset(&self, forking: Option) -> Result<()> { node_info!("anvil_reset"); if let Some(forking) = forking { + // if we're resetting the fork we need to reset the instance id + self.reset_instance_id(); self.backend.reset_fork(forking).await } else { Err(BlockchainError::RpcUnimplemented) @@ -1695,6 +1704,27 @@ impl EthApi { }) } + /// Retrieves metadata about the Anvil instance. + /// + /// Handler for RPC call: `anvil_metadata` + pub async fn anvil_metadata(&self) -> Result { + node_info!("anvil_metadata"); + let fork_config = self.backend.get_fork(); + + Ok(AnvilMetadata { + client_version: CLIENT_VERSION, + chain_id: self.backend.chain_id(), + latest_block_hash: self.backend.best_hash(), + latest_block_number: self.backend.best_number(), + instance_id: *self.instance_id.read(), + forked_network: fork_config.map(|cfg| ForkedNetwork { + chain_id: cfg.chain_id().into(), + fork_block_number: cfg.block_number().into(), + fork_block_hash: cfg.block_hash(), + }), + }) + } + /// Snapshot the state of the blockchain at the current block. /// /// Handler for RPC call: `evm_snapshot` @@ -2280,6 +2310,16 @@ impl EthApi { self.backend.get_fork() } + /// Returns the current instance's ID. + pub fn instance_id(&self) -> H256 { + *self.instance_id.read() + } + + /// Resets the instance ID. + pub fn reset_instance_id(&self) { + *self.instance_id.write() = H256::random(); + } + /// Returns the first signer that can sign for the given address #[allow(clippy::borrowed_box)] pub fn get_signer(&self, address: Address) -> Option<&Box> { diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index dc50e491a6ed4..272f6b2824c73 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -1,9 +1,9 @@ //! tests for custom anvil endpoints use crate::{abi::*, fork::fork_config}; -use anvil::{spawn, Hardfork, NodeConfig}; +use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; use anvil_core::{ eth::EthRequest, - types::{NodeEnvironment, NodeForkConfig, NodeInfo}, + types::{AnvilMetadata, ForkedNetwork, Forking, NodeEnvironment, NodeForkConfig, NodeInfo}, }; use ethers::{ abi::{ethereum_types::BigEndianHash, AbiDecode}, @@ -454,6 +454,74 @@ async fn can_get_node_info() { assert_eq!(node_info, expected_node_info); } +#[tokio::test(flavor = "multi_thread")] +async fn can_get_metadata() { + let (api, handle) = spawn(NodeConfig::test()).await; + + let metadata = api.anvil_metadata().await.unwrap(); + + let provider = handle.http_provider(); + + let block_number = provider.get_block_number().await.unwrap(); + let chain_id = provider.get_chainid().await.unwrap(); + let block = provider.get_block(block_number).await.unwrap().unwrap(); + + let expected_metadata = AnvilMetadata { + latest_block_hash: block.hash.unwrap(), + latest_block_number: block_number, + chain_id, + client_version: CLIENT_VERSION, + instance_id: api.instance_id(), + forked_network: None, + }; + + assert_eq!(metadata, expected_metadata); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_get_metadata_on_fork() { + let (api, handle) = + spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; + let provider = Arc::new(handle.http_provider()); + + let metadata = api.anvil_metadata().await.unwrap(); + + let block_number = provider.get_block_number().await.unwrap(); + let chain_id = provider.get_chainid().await.unwrap(); + let block = provider.get_block(block_number).await.unwrap().unwrap(); + + let expected_metadata = AnvilMetadata { + latest_block_hash: block.hash.unwrap(), + latest_block_number: block_number, + chain_id, + client_version: CLIENT_VERSION, + instance_id: api.instance_id(), + forked_network: Some(ForkedNetwork { + chain_id, + fork_block_number: block_number, + fork_block_hash: block.hash.unwrap(), + }), + }; + + assert_eq!(metadata, expected_metadata); +} + +#[tokio::test(flavor = "multi_thread")] +async fn metadata_changes_on_reset() { + let (api, _) = + spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; + + let metadata = api.anvil_metadata().await.unwrap(); + let instance_id = metadata.instance_id; + + api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: None })).await.unwrap(); + + let new_metadata = api.anvil_metadata().await.unwrap(); + let new_instance_id = new_metadata.instance_id; + + assert_ne!(instance_id, new_instance_id); +} + #[tokio::test(flavor = "multi_thread")] async fn test_get_transaction_receipt() { let (api, handle) = spawn(NodeConfig::test()).await; From 47678ac19d8d806efac604d59e11af805bc2b923 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 7 Nov 2023 13:26:13 -0400 Subject: [PATCH 0246/1963] fix: add arbitrum sepolia to list of networks with diff gas calc and batch support (#6244) --- crates/cli/src/utils/cmd.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 38ff31e4e164e..62659224a0621 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -166,7 +166,13 @@ macro_rules! update_progress { /// True if the network calculates gas costs differently. pub fn has_different_gas_calc(chain: u64) -> bool { if let ConfigChain::Named(chain) = ConfigChain::from(chain) { - return matches!(chain, Chain::Arbitrum | Chain::ArbitrumTestnet | Chain::ArbitrumGoerli) + return matches!( + chain, + Chain::Arbitrum | + Chain::ArbitrumTestnet | + Chain::ArbitrumGoerli | + Chain::ArbitrumSepolia + ) } false } @@ -174,7 +180,13 @@ pub fn has_different_gas_calc(chain: u64) -> bool { /// True if it supports broadcasting in batches. pub fn has_batch_support(chain: u64) -> bool { if let ConfigChain::Named(chain) = ConfigChain::from(chain) { - return !matches!(chain, Chain::Arbitrum | Chain::ArbitrumTestnet | Chain::ArbitrumGoerli) + return !matches!( + chain, + Chain::Arbitrum | + Chain::ArbitrumTestnet | + Chain::ArbitrumGoerli | + Chain::ArbitrumSepolia + ) } true } From 85f25c62e8771c500990675ad593be8604c1b46d Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 7 Nov 2023 19:53:12 -0400 Subject: [PATCH 0247/1963] chore(deps): switch to using foundry compilers from crates.io (#6248) --- Cargo.lock | 3 ++- Cargo.toml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 431560f339b13..91c104f9546b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2731,7 +2731,8 @@ dependencies = [ [[package]] name = "foundry-compilers" version = "0.1.0" -source = "git+https://github.com/foundry-rs/compilers#f00eef81a91a393bf92eb13d47a5221f5e50162f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcfb3af0dd69f2989ab2311f2c97fdd470227d3c9f657be04092572a3a1db60" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 432fbaee9268b..b666914ce8542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,7 +131,9 @@ foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } foundry-utils = { path = "crates/utils" } +# block explorer & verification bindings foundry-block-explorers = { version = "0.1", default-features = false } +# solc & compilation utilities foundry-compilers = { version = "0.1", default-features = false } ## revm @@ -197,7 +199,6 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b3 ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -foundry-compilers = { git = "https://github.com/foundry-rs/compilers" } foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } From 855d0059dc395c6200f18fa71a1e2793b6b7ef43 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 8 Nov 2023 15:39:06 +0100 Subject: [PATCH 0248/1963] fix: windows tests (#6239) * wip * ci: run winders always * ci: merge build and run steps together * chore: display full error msg * ignore failing test * chore: clippy * chore: clean up script * rm pretty_eq * chore: simplify test macros * test * test: cache when building testdata project * move * ci: fix caching * chore: update actions/checkout * tmp: run all test matrices * chore: relax timeout for external tests * tmp: run all test matrices 2 * fix winders * chore: relax timeout for external tests 2 * chore: relax timeout for forge_std test * fix: add svm target platform * fix: ignore geb * fix: disable aarch64 target * tmp: unrun all test matrices * no cross --- .cargo/config.toml | 6 +- .config/nextest.toml | 10 +- .github/scripts/matrices.py | 91 +-- .github/workflows/deny.yml | 2 +- .github/workflows/dependencies.yml | 4 +- .github/workflows/docker-publish.yml | 4 +- .github/workflows/heavy-integration.yml | 6 +- .github/workflows/release.yml | 13 +- .github/workflows/test.yml | 98 +-- Cargo.lock | 2 +- crates/cast/bin/cmd/logs.rs | 4 +- crates/cast/tests/cli/main.rs | 65 +- crates/cli/src/handler.rs | 1 - crates/cli/src/utils/mod.rs | 22 +- crates/config/src/fix.rs | 4 +- crates/forge/Cargo.toml | 1 + crates/forge/assets/workflowTemplate.yml | 2 +- crates/forge/bin/cmd/install.rs | 2 +- crates/forge/bin/cmd/script/mod.rs | 2 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 2 +- crates/forge/tests/cli/cache.rs | 12 +- crates/forge/tests/cli/cmd.rs | 190 +++--- crates/forge/tests/cli/config.rs | 71 ++- crates/forge/tests/cli/coverage.rs | 7 +- crates/forge/tests/cli/create.rs | 12 +- crates/forge/tests/cli/ext_integration.rs | 3 +- crates/forge/tests/cli/heavy_integration.rs | 2 - crates/forge/tests/cli/main.rs | 3 + crates/forge/tests/cli/multi_script.rs | 143 ++--- crates/forge/tests/cli/script.rs | 616 +++++++++---------- crates/forge/tests/cli/svm.rs | 5 +- crates/forge/tests/cli/test_cmd.rs | 107 ++-- crates/forge/tests/cli/verify.rs | 4 +- crates/forge/tests/it/cheats.rs | 3 +- crates/forge/tests/it/config.rs | 7 +- crates/forge/tests/it/core.rs | 3 +- crates/forge/tests/it/fork.rs | 3 +- crates/forge/tests/it/fs.rs | 6 +- crates/forge/tests/it/fuzz.rs | 3 +- crates/forge/tests/it/inline.rs | 3 +- crates/forge/tests/it/invariant.rs | 3 +- crates/forge/tests/it/main.rs | 5 +- crates/forge/tests/it/repros.rs | 6 +- crates/forge/tests/it/spec.rs | 3 +- crates/forge/tests/it/test_helpers.rs | 139 +---- crates/test-utils/Cargo.toml | 5 +- crates/test-utils/src/filter.rs | 86 +++ crates/test-utils/src/lib.rs | 9 +- crates/test-utils/src/macros.rs | 105 ++-- crates/test-utils/src/script.rs | 2 +- crates/test-utils/src/util.rs | 38 +- testdata/fs/Default.t.sol | 11 +- testdata/fs/Disabled.t.sol | 15 +- 53 files changed, 877 insertions(+), 1094 deletions(-) create mode 100644 crates/test-utils/src/filter.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 186e372f987e7..5056df8af1f5f 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,14 +5,12 @@ cheats = "test -p foundry-cheatcodes-defs --features schema tests::" rustflags = [ # Increases the stack size to 10MB, which is # in line with Linux (whereas default for Windows is 1MB) - "-C", - "link-arg=/STACK:10000000", + "-Clink-arg=/STACK:10000000", ] [target.i686-pc-windows-msvc] rustflags = [ # Increases the stack size to 10MB, which is # in line with Linux (whereas default for Windows is 1MB) - "-C", - "link-arg=/STACK:10000000", + "-Clink-arg=/STACK:10000000", ] diff --git a/.config/nextest.toml b/.config/nextest.toml index 56e7e21468308..2b5a17d0d7897 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,6 +1,10 @@ [profile.default] -retries = { backoff = "exponential", count = 3, delay = "1s", jitter = true } -slow-timeout = "3m" +retries = { backoff = "exponential", count = 2, delay = "2s", jitter = true } +slow-timeout = { period = "1m", terminate-after = 3 } + +[[profile.default.overrides]] +filter = "test(/ext_integration|can_test_forge_std/)" +slow-timeout = { period = "5m", terminate-after = 4 } [profile.heavy] -retries = 1 \ No newline at end of file +retries = 1 diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 803795b457737..9cd1eb5ebfa3c 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -4,105 +4,114 @@ import os +# A runner target class Target: # GitHub runner OS os_id: str # Rust target triple target: str + # SVM Solc target + svm_target_platform: str - def __init__(self, os_id: str, target: str): + def __init__(self, os_id: str, target: str, svm_target_platform: str): self.os_id = os_id self.target = target + self.svm_target_platform = svm_target_platform +# A single test suite to run. class Case: + # Name of the test suite. name: str + # Nextest filter expression. filter: str + # Number of partitions to split the test suite into. n_partitions: int - xplatform: bool + # Whether to run on non-Linux platforms for PRs. All platforms and tests are run on pushes. + pr_cross_platform: bool - def __init__(self, name: str, filter: str, n_partitions: int, xplatform: bool): + def __init__( + self, name: str, filter: str, n_partitions: int, pr_cross_platform: bool + ): self.name = name self.filter = filter self.n_partitions = n_partitions - self.xplatform = xplatform + self.pr_cross_platform = pr_cross_platform +# GHA matrix entry class Expanded: + name: str os: str target: str - name: str + svm_target_platform: str flags: str partition: int - def __init__(self, os: str, target: str, name: str, flags: str, partition: int): + def __init__( + self, + name: str, + os: str, + target: str, + svm_target_platform: str, + flags: str, + partition: int, + ): + self.name = name self.os = os self.target = target - self.name = name + self.svm_target_platform = svm_target_platform self.flags = flags self.partition = partition -default_target = Target("ubuntu-latest", "x86_64-unknown-linux-gnu") -if os.environ.get("EVENT_NAME") == "pull_request": - targets = [default_target] -else: - targets = [ - default_target, - Target("ubuntu-latest", "aarch64-unknown-linux-gnu"), - Target("macos-latest", "x86_64-apple-darwin"), - # Disabled since the test binary will be built for M1/M2, but there are no - # GitHub runners capable of executing those binaries. - # Target("macos-latest", "aarch64-apple-darwin"), - Target("windows-latest", "x86_64-pc-windows-msvc"), - ] +is_pr = os.environ.get("EVENT_NAME") == "pull_request" +t_linux_x86 = Target("ubuntu-latest", "x86_64-unknown-linux-gnu", "linux-amd64") +# 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", "x86_64-apple-darwin", "macosx-amd64") +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] config = [ Case( name="unit", filter="kind(lib) | kind(bench) | kind(proc-macro)", n_partitions=1, - xplatform=True, + pr_cross_platform=True, ), Case( name="integration", filter="kind(test) & !test(/issue|forge_std|ext_integration/)", n_partitions=3, - xplatform=True, + pr_cross_platform=True, ), Case( - name="integration/issue-repros", + name="integration / issue-repros", filter="package(=forge) & test(~issue)", n_partitions=2, - xplatform=False, + pr_cross_platform=False, ), Case( - name="integration/forge-std", + name="integration / forge-std", filter="package(=forge) & test(~forge_std)", n_partitions=1, - xplatform=False, + pr_cross_platform=False, ), Case( - name="integration/external", + name="integration / external", filter="package(=forge) & test(~ext_integration)", n_partitions=2, - xplatform=False, + pr_cross_platform=False, ), ] -def build_matrix(): - expanded = [] - for target in targets: - expanded.append({"os": target.os_id, "target": target.target}) - print_json({"include": expanded}) - - -def test_matrix(): +def main(): expanded = [] for target in targets: for case in config: - if not case.xplatform and target != default_target: + if is_pr and (not case.pr_cross_platform and target != t_linux_x86): continue for partition in range(1, case.n_partitions + 1): @@ -119,9 +128,10 @@ def test_matrix(): name += os_str obj = Expanded( + name=name, os=target.os_id, target=target.target, - name=name, + svm_target_platform=target.svm_target_platform, flags=flags, partition=partition, ) @@ -135,7 +145,4 @@ def print_json(obj): if __name__ == "__main__": - if int(os.environ.get("TEST", "0")) == 0: - build_matrix() - else: - test_matrix() + main() diff --git a/.github/workflows/deny.yml b/.github/workflows/deny.yml index d0a5e2f35df4a..277b1c9430b3e 100644 --- a/.github/workflows/deny.yml +++ b/.github/workflows/deny.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: EmbarkStudios/cargo-deny-action@v1 with: command: check all diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 531480b8232b1..fd3daf853ea47 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -1,6 +1,6 @@ # Automatically run `cargo update` periodically -name: Update Dependencies +name: dependencies on: schedule: @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - name: cargo update diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8af9cfa2757f7..835fa8b9c8ef6 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,4 +1,4 @@ -name: Build and Publish Docker +name: docker on: push: @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository id: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Docker BuildX uses: docker/setup-buildx-action@v2 diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index f910a0adf96b3..8583f7bae237a 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -1,4 +1,4 @@ -name: Heavy (long-running) integration tests +name: heavy integration on: schedule: @@ -17,7 +17,7 @@ jobs: env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 @@ -48,7 +48,7 @@ jobs: needs: heavy-integration if: ${{ failure() }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: JasonEtco/create-an-issue@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e728afacb44f..32c62881990b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Release version +name: release on: push: @@ -9,8 +9,8 @@ on: workflow_dispatch: env: - IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} CARGO_TERM_COLOR: always + IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} jobs: prepare: @@ -22,7 +22,7 @@ jobs: release_name: ${{ steps.release_info.outputs.release_name }} changelog: ${{ steps.build_changelog.outputs.changelog }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -104,12 +104,13 @@ jobs: platform: win32 arch: amd64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@v2 with: + key: ${{ matrix.target }} cache-on-failure: true - name: Apple M1 setup @@ -215,7 +216,7 @@ jobs: needs: release if: always() steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Moves the `nightly` tag to `HEAD` - name: Move nightly tag @@ -240,7 +241,7 @@ jobs: needs: [prepare, release-docker, release, cleanup] if: failure() steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: JasonEtco/create-an-issue@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 467760297bcf5..7d3a3ef9fa966 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,8 @@ on: pull_request: concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true - group: ${{github.workflow}}-${{github.ref}} env: CARGO_TERM_COLOR: always @@ -18,10 +18,9 @@ jobs: name: build matrices runs-on: ubuntu-latest outputs: - build-matrix: ${{ steps.gen.outputs.build-matrix }} test-matrix: ${{ steps.gen.outputs.test-matrix }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.11" @@ -30,67 +29,29 @@ jobs: env: EVENT_NAME: ${{ github.event_name }} run: | - output=$(python3 .github/scripts/matrices.py) - echo "::debug::build-matrix=$output" - echo "build-matrix=$output" >> $GITHUB_OUTPUT - - export TEST=1 - output=$(python3 .github/scripts/matrices.py) echo "::debug::test-matrix=$output" echo "test-matrix=$output" >> $GITHUB_OUTPUT - build-tests: - name: build tests - runs-on: ${{ matrix.os }} - timeout-minutes: 30 - needs: matrices - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.matrices.outputs.build-matrix) }} - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - target: ${{ matrix.target }} - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - uses: taiki-e/install-action@nextest - - name: Build archive - shell: bash - run: | - cargo nextest archive \ - --workspace \ - --archive-file tests-${{ matrix.target }}.tar.zst - - name: Upload archive - uses: actions/upload-artifact@v3 - with: - name: tests-${{ matrix.target }} - path: tests-${{ matrix.target }}.tar.zst - test: name: test ${{ matrix.name }} runs-on: ${{ matrix.os }} timeout-minutes: 60 - needs: - - matrices - - build-tests + needs: matrices strategy: fail-fast: false matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: target: ${{ matrix.target }} - uses: taiki-e/install-action@nextest - - name: Download archive - uses: actions/download-artifact@v3 - with: - name: tests-${{ matrix.target }} + # - uses: taiki-e/setup-cross-toolchain-action@v1 + # with: + # target: ${{ matrix.target }} - name: Forge RPC cache uses: actions/cache@v3 with: @@ -98,39 +59,36 @@ jobs: ~/.foundry/cache ~/.config/.foundry/cache key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config + - uses: Swatinem/rust-cache@v2 + with: + # key: ${{ matrix.target }} + cache-on-failure: true + - name: Setup Git config run: | git config --global user.name "GitHub Actions Bot" git config --global user.email "<>" - - name: Force use of HTTPS for submodules - run: git config --global url."https://github.com/".insteadOf "git@github.com:" + git config --global url."https://github.com/".insteadOf "git@github.com:" - name: Test - shell: bash - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --archive-file tests-${{ matrix.target }}.tar.zst \ - ${{ matrix.flags }} + env: + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + run: cargo nextest run ${{ matrix.flags }} - doctests: - name: doc tests + doctest: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: cargo test - run: cargo test --doc + - run: cargo test --workspace --doc clippy: - name: clippy runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@clippy - uses: Swatinem/rust-cache@v2 with: @@ -139,23 +97,21 @@ jobs: env: RUSTFLAGS: -Dwarnings - fmt: - name: fmt + rustfmt: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly with: components: rustfmt - run: cargo fmt --all --check forge-fmt: - name: forge fmt runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: @@ -168,16 +124,14 @@ jobs: shopt -s extglob cargo run --bin forge -- fmt --check testdata/**/!(Vm).sol - feature-checks: - name: feature checks + crate-checks: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@cargo-hack - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: cargo hack - run: cargo hack check + - run: cargo hack check diff --git a/Cargo.lock b/Cargo.lock index 91c104f9546b6..166bcbde68d6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2510,6 +2510,7 @@ dependencies = [ "solang-parser", "strum", "svm-rs", + "tempfile", "thiserror", "tokio", "tracing", @@ -2979,7 +2980,6 @@ dependencies = [ "pretty_assertions", "regex", "serde_json", - "tempfile", "tracing", "tracing-subscriber", "walkdir", diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index f5fb351e0fd65..c4145dbee5d1b 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -1,5 +1,3 @@ -use std::{io, str::FromStr}; - use cast::Cast; use clap::Parser; use ethers::{providers::Middleware, types::NameOrAddress}; @@ -12,9 +10,9 @@ use ethers_core::{ }; use eyre::{Result, WrapErr}; use foundry_cli::{opts::EthereumOpts, utils}; - use foundry_config::Config; use itertools::Itertools; +use std::{io, str::FromStr}; /// CLI arguments for `cast logs`. #[derive(Debug, Parser)] diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 76506d8d41c94..238e5d76747b5 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,20 +1,17 @@ //! Contains various tests for checking cast commands -use foundry_test_utils::{ - casttest, - util::{OutputExt, TestCommand, TestProject}, -}; +use foundry_test_utils::{casttest, util::OutputExt}; use foundry_utils::rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}; use std::{io::Write, path::Path}; // tests `--help` is printed to std out -casttest!(print_help, |_: TestProject, mut cmd: TestCommand| { +casttest!(print_help, |_prj, cmd| { cmd.arg("--help"); cmd.assert_non_empty_stdout(); }); // tests that the `cast block` command works correctly -casttest!(latest_block, |_: TestProject, mut cmd: TestCommand| { +casttest!(latest_block, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast find-block` @@ -30,7 +27,7 @@ casttest!(latest_block, |_: TestProject, mut cmd: TestCommand| { }); // tests that the `cast find-block` command works correctly -casttest!(finds_block, |_: TestProject, mut cmd: TestCommand| { +casttest!(finds_block, |_prj, cmd| { // Construct args let timestamp = "1647843609".to_string(); let eth_rpc_url = next_http_rpc_endpoint(); @@ -48,7 +45,7 @@ casttest!(finds_block, |_: TestProject, mut cmd: TestCommand| { }); // tests that we can create a new wallet with keystore -casttest!(new_wallet_keystore_with_password, |_: TestProject, mut cmd: TestCommand| { +casttest!(new_wallet_keystore_with_password, |_prj, cmd| { cmd.args(["wallet", "new", ".", "--unsafe-password", "test"]); let out = cmd.stdout_lossy(); assert!(out.contains("Created new encrypted keystore file")); @@ -56,7 +53,7 @@ casttest!(new_wallet_keystore_with_password, |_: TestProject, mut cmd: TestComma }); // tests that we can get the address of a keystore file -casttest!(wallet_address_keystore_with_password_file, |_: TestProject, mut cmd: TestCommand| { +casttest!(wallet_address_keystore_with_password_file, |_prj, cmd| { let keystore_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/keystore"); cmd.args([ @@ -75,7 +72,7 @@ casttest!(wallet_address_keystore_with_password_file, |_: TestProject, mut cmd: }); // tests that `cast wallet sign message` outputs the expected signature -casttest!(cast_wallet_sign_message_utf8_data, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_wallet_sign_message_utf8_data, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -88,7 +85,7 @@ casttest!(cast_wallet_sign_message_utf8_data, |_: TestProject, mut cmd: TestComm }); // tests that `cast wallet sign message` outputs the expected signature, given a 0x-prefixed data -casttest!(cast_wallet_sign_message_hex_data, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_wallet_sign_message_hex_data, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -101,7 +98,7 @@ casttest!(cast_wallet_sign_message_hex_data, |_: TestProject, mut cmd: TestComma }); // tests that `cast wallet sign typed-data` outputs the expected signature, given a JSON string -casttest!(cast_wallet_sign_typed_data_string, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_wallet_sign_typed_data_string, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -115,7 +112,7 @@ casttest!(cast_wallet_sign_typed_data_string, |_: TestProject, mut cmd: TestComm }); // tests that `cast wallet sign typed-data` outputs the expected signature, given a JSON file -casttest!(cast_wallet_sign_typed_data_file, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_wallet_sign_typed_data_file, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -135,7 +132,7 @@ casttest!(cast_wallet_sign_typed_data_file, |_: TestProject, mut cmd: TestComman }); // tests that `cast estimate` is working correctly. -casttest!(estimate_function_gas, |_: TestProject, mut cmd: TestCommand| { +casttest!(estimate_function_gas, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); cmd.args([ "estimate", @@ -152,7 +149,7 @@ casttest!(estimate_function_gas, |_: TestProject, mut cmd: TestCommand| { }); // tests that `cast estimate --create` is working correctly. -casttest!(estimate_contract_deploy_gas, |_: TestProject, mut cmd: TestCommand| { +casttest!(estimate_contract_deploy_gas, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // sample contract code bytecode. Wouldn't run but is valid bytecode that the estimate method // accepts and could be deployed. @@ -174,7 +171,7 @@ casttest!(estimate_contract_deploy_gas, |_: TestProject, mut cmd: TestCommand| { }); // tests that the `cast upload-signatures` command works correctly -casttest!(upload_signatures, |_: TestProject, mut cmd: TestCommand| { +casttest!(upload_signatures, |_prj, cmd| { // test no prefix is accepted as function cmd.args(["upload-signature", "transfer(address,uint256)"]); let output = cmd.stdout_lossy(); @@ -222,7 +219,7 @@ casttest!(upload_signatures, |_: TestProject, mut cmd: TestCommand| { }); // tests that the `cast to-rlp` and `cast from-rlp` commands work correctly -casttest!(cast_rlp, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_rlp, |_prj, cmd| { cmd.args(["--to-rlp", "[\"0xaa\", [[\"bb\"]], \"0xcc\"]"]); let out = cmd.stdout_lossy(); assert!(out.contains("0xc881aac3c281bb81cc"), "{}", out); @@ -234,7 +231,7 @@ casttest!(cast_rlp, |_: TestProject, mut cmd: TestCommand| { }); // test for cast_rpc without arguments -casttest!(cast_rpc_no_args, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_rpc_no_args, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_chainId` @@ -244,7 +241,7 @@ casttest!(cast_rpc_no_args, |_: TestProject, mut cmd: TestCommand| { }); // test for cast_rpc without arguments using websocket -casttest!(cast_ws_rpc_no_args, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_ws_rpc_no_args, |_prj, cmd| { let eth_rpc_url = next_ws_rpc_endpoint(); // Call `cast rpc eth_chainId` @@ -254,7 +251,7 @@ casttest!(cast_ws_rpc_no_args, |_: TestProject, mut cmd: TestCommand| { }); // test for cast_rpc with arguments -casttest!(cast_rpc_with_args, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_rpc_with_args, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_getBlockByNumber 0x123 false` @@ -264,7 +261,7 @@ casttest!(cast_rpc_with_args, |_: TestProject, mut cmd: TestCommand| { }); // test for cast_rpc with raw params -casttest!(cast_rpc_raw_params, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_rpc_raw_params, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_getBlockByNumber --raw '["0x123", false]'` @@ -281,7 +278,7 @@ casttest!(cast_rpc_raw_params, |_: TestProject, mut cmd: TestCommand| { }); // test for cast_rpc with direct params -casttest!(cast_rpc_raw_params_stdin, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_rpc_raw_params_stdin, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `echo "\n[\n\"0x123\",\nfalse\n]\n" | cast rpc eth_getBlockByNumber --raw @@ -295,7 +292,7 @@ casttest!(cast_rpc_raw_params_stdin, |_: TestProject, mut cmd: TestCommand| { }); // checks `cast calldata` can handle arrays -casttest!(calldata_array, |_: TestProject, mut cmd: TestCommand| { +casttest!(calldata_array, |_prj, cmd| { cmd.args(["calldata", "propose(string[])", "[\"\"]"]); let out = cmd.stdout_lossy(); assert_eq!(out.trim(),"0xcde2baba0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000" @@ -303,7 +300,7 @@ casttest!(calldata_array, |_: TestProject, mut cmd: TestCommand| { }); // -casttest!(cast_run_succeeds, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_run_succeeds, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "run", @@ -319,7 +316,7 @@ casttest!(cast_run_succeeds, |_: TestProject, mut cmd: TestCommand| { }); // tests that `cast --to-base` commands are working correctly. -casttest!(cast_to_base, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_to_base, |_prj, cmd| { let values = [ "1", "100", @@ -347,7 +344,7 @@ casttest!(cast_to_base, |_: TestProject, mut cmd: TestCommand| { }); // tests that revert reason is only present if transaction has reverted. -casttest!(cast_receipt_revert_reason, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_receipt_revert_reason, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); // @@ -373,7 +370,7 @@ casttest!(cast_receipt_revert_reason, |_: TestProject, mut cmd: TestCommand| { }); // tests that `cast --parse-bytes32-address` command is working correctly. -casttest!(parse_bytes32_address, |_: TestProject, mut cmd: TestCommand| { +casttest!(parse_bytes32_address, |_prj, cmd| { cmd.args([ "--parse-bytes32-address", "0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045", @@ -382,7 +379,7 @@ casttest!(parse_bytes32_address, |_: TestProject, mut cmd: TestCommand| { assert_eq!(output.trim(), "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045") }); -casttest!(cast_access_list, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_access_list, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "access-list", @@ -401,7 +398,7 @@ casttest!(cast_access_list, |_: TestProject, mut cmd: TestCommand| { assert!(output.contains("0x7fba2702a7d6e85ac783a88eacdc48e51310443458071f6db9ac66f8ca7068b8")); }); -casttest!(cast_logs_topics, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_logs_topics, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -420,7 +417,7 @@ casttest!(cast_logs_topics, |_: TestProject, mut cmd: TestCommand| { ); }); -casttest!(cast_logs_topic_2, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_logs_topic_2, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -441,7 +438,7 @@ casttest!(cast_logs_topic_2, |_: TestProject, mut cmd: TestCommand| { ); }); -casttest!(cast_logs_sig, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_logs_sig, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -460,7 +457,7 @@ casttest!(cast_logs_sig, |_: TestProject, mut cmd: TestCommand| { ); }); -casttest!(cast_logs_sig_2, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_logs_sig_2, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -481,7 +478,7 @@ casttest!(cast_logs_sig_2, |_: TestProject, mut cmd: TestCommand| { }); // tests that the raw encoded transaction is returned -casttest!(cast_tx_raw, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_tx_raw, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); // @@ -512,7 +509,7 @@ casttest!(cast_tx_raw, |_: TestProject, mut cmd: TestCommand| { }); // ensure receipt or code is required -casttest!(cast_send_requires_to, |_: TestProject, mut cmd: TestCommand| { +casttest!(cast_send_requires_to, |_prj, cmd| { cmd.args([ "send", "--private-key", diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index a4154dc7cfe28..f4778c43960d0 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -47,7 +47,6 @@ impl EyreHandler for Handler { /// verbose debug-centric handler is installed. /// /// Panics are always caught by the more debug-centric handler. -#[cfg_attr(windows, inline(never))] pub fn install() -> Result<()> { let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok(); diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 2d77a1edf0e10..9e55d180b46fd 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -264,12 +264,17 @@ impl CommandUtils for Command { if output.status.success() { Ok(output) } else { - let mut stderr = String::from_utf8_lossy(&output.stderr); - let mut msg = stderr.trim(); - if msg.is_empty() { - stderr = String::from_utf8_lossy(&output.stdout); - msg = stderr.trim(); - } + let stdout = String::from_utf8_lossy(&output.stdout); + let stdout = stdout.trim(); + let stderr = String::from_utf8_lossy(&output.stderr); + let stderr = stderr.trim(); + let msg = if stdout.is_empty() { + stderr.to_string() + } else if stderr.is_empty() { + stdout.to_string() + } else { + format!("stdout:\n{stdout}\n\nstderr:\n{stderr}") + }; let mut name = self.get_program().to_string_lossy(); if let Some(arg) = self.get_args().next() { @@ -286,8 +291,9 @@ impl CommandUtils for Command { None => format!("{name} terminated by a signal"), }; if !msg.is_empty() { - err.push_str(": "); - err.push_str(msg); + err.push(':'); + err.push(if msg.lines().count() == 0 { ' ' } else { '\n' }); + err.push_str(&msg); } Err(eyre::eyre!(err)) } diff --git a/crates/config/src/fix.rs b/crates/config/src/fix.rs index 9c2c43ef77983..086fbb7db3055 100644 --- a/crates/config/src/fix.rs +++ b/crates/config/src/fix.rs @@ -219,9 +219,9 @@ mod tests { use pretty_assertions::assert_eq; macro_rules! fix_test { - ($(#[$meta:meta])* $name:ident, $fun:expr) => { + ($(#[$attr:meta])* $name:ident, $fun:expr) => { #[test] - $(#[$meta])* + $(#[$attr])* fn $name() { Jail::expect_with(|jail| { // setup home directory, diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index c692b9a6051b1..3e45cb1936b07 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -78,6 +78,7 @@ path-slash = "0.2" pretty_assertions = "1" serial_test = "2" svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } +tempfile = "3" tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } [features] diff --git a/crates/forge/assets/workflowTemplate.yml b/crates/forge/assets/workflowTemplate.yml index 09880b1d79a75..9282e82944e8d 100644 --- a/crates/forge/assets/workflowTemplate.yml +++ b/crates/forge/assets/workflowTemplate.yml @@ -13,7 +13,7 @@ jobs: name: Foundry project runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 81f1177f9fd2b..44ca38e45cdf4 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -489,7 +489,7 @@ fn match_yn(input: String) -> bool { #[cfg(test)] mod tests { use super::*; - use foundry_test_utils::tempfile::tempdir; + use tempfile::tempdir; #[test] fn get_oz_tags() { diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index f5435dc3cd3db..37b878ecc8bc4 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -741,8 +741,8 @@ mod tests { use super::*; use foundry_cli::utils::LoadConfig; use foundry_config::UnresolvedEnvVarError; - use foundry_test_utils::tempfile::tempdir; use std::fs; + use tempfile::tempdir; #[test] fn can_parse_sig() { diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 57fdfeb9ab8bf..1b467ab623c76 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -455,7 +455,7 @@ mod tests { use clap::Parser; use foundry_cli::utils::LoadConfig; use foundry_common::fs; - use foundry_test_utils::tempfile::tempdir; + use tempfile::tempdir; #[test] fn can_extract_etherscan_verify_config() { diff --git a/crates/forge/tests/cli/cache.rs b/crates/forge/tests/cli/cache.rs index 22fc6ea2339ec..81ebb22ee968f 100644 --- a/crates/forge/tests/cli/cache.rs +++ b/crates/forge/tests/cli/cache.rs @@ -1,20 +1,16 @@ -//! Tests for various cache command -use foundry_test_utils::{ - forgetest, - util::{TestCommand, TestProject}, -}; +//! Tests for various cache command. -forgetest!(can_list_cache, |_prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_list_cache, |_prj, cmd| { cmd.args(["cache", "ls"]); cmd.assert_success(); }); -forgetest!(can_list_cache_all, |_prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_list_cache_all, |_prj, cmd| { cmd.args(["cache", "ls", "all"]); cmd.assert_success(); }); -forgetest!(can_list_specific_chain, |_prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_list_specific_chain, |_prj, cmd| { cmd.args(["cache", "ls", "mainnet"]); cmd.assert_success(); }); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index e0f52434424a8..6bb518ffb46d5 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -8,9 +8,8 @@ use foundry_compilers::{ }; use foundry_config::{parse_with_profile, BasicConfig, Chain, Config, SolidityErrorCode}; use foundry_test_utils::{ - forgetest, forgetest_init, foundry_compilers::PathStyle, - util::{pretty_err, read_string, OutputExt, TestCommand, TestProject}, + util::{pretty_err, read_string, OutputExt, TestCommand}, }; use semver::Version; use std::{ @@ -21,13 +20,13 @@ use std::{ }; // tests `--help` is printed to std out -forgetest!(print_help, |_: TestProject, mut cmd: TestCommand| { +forgetest!(print_help, |_prj, cmd| { cmd.arg("--help"); cmd.assert_non_empty_stdout(); }); // checks that `clean` can be invoked even if out and cache don't exist -forgetest!(can_clean_non_existing, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_clean_non_existing, |prj, cmd| { cmd.arg("clean"); cmd.assert_empty_stdout(); prj.assert_cleaned(); @@ -37,7 +36,7 @@ forgetest!(can_clean_non_existing, |prj: TestProject, mut cmd: TestCommand| { forgetest!( #[ignore] can_cache_ls, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let chain = Chain::Named(ethers::prelude::Chain::Mainnet); let block1 = 100; let block2 = 101; @@ -75,7 +74,7 @@ forgetest!( forgetest!( #[ignore] can_cache_clean, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let cache_dir = Config::foundry_cache_dir().unwrap(); let path = cache_dir.as_path(); fs::create_dir_all(path).unwrap(); @@ -91,7 +90,7 @@ forgetest!( forgetest!( #[ignore] can_cache_clean_etherscan, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let cache_dir = Config::foundry_cache_dir().unwrap(); let etherscan_cache_dir = Config::foundry_etherscan_cache_dir().unwrap(); let path = cache_dir.as_path(); @@ -112,7 +111,7 @@ forgetest!( forgetest!( #[ignore] can_cache_clean_all_etherscan, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let rpc_cache_dir = Config::foundry_rpc_cache_dir().unwrap(); let etherscan_cache_dir = Config::foundry_etherscan_cache_dir().unwrap(); let rpc_path = rpc_cache_dir.as_path(); @@ -134,7 +133,7 @@ forgetest!( forgetest!( #[ignore] can_cache_clean_chain, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let chain = Chain::Named(ethers::prelude::Chain::Mainnet); let cache_dir = Config::foundry_chain_cache_dir(chain).unwrap(); let etherscan_cache_dir = Config::foundry_etherscan_chain_cache_dir(chain).unwrap(); @@ -157,7 +156,7 @@ forgetest!( forgetest!( #[ignore] can_cache_clean_blocks, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let chain = Chain::Named(ethers::prelude::Chain::Mainnet); let block1 = 100; let block2 = 101; @@ -191,7 +190,7 @@ forgetest!( forgetest!( #[ignore] can_cache_clean_chain_etherscan, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let cache_dir = Config::foundry_chain_cache_dir(Chain::Named(ethers::prelude::Chain::Mainnet)).unwrap(); let etherscan_cache_dir = Config::foundry_etherscan_chain_cache_dir(Chain::Named( @@ -213,7 +212,7 @@ forgetest!( ); // checks that init works -forgetest!(can_init_repo_with_config, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_repo_with_config, |prj, cmd| { let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(!foundry_toml.exists()); @@ -225,7 +224,7 @@ forgetest!(can_init_repo_with_config, |prj: TestProject, mut cmd: TestCommand| { }); // Checks that a forge project fails to initialise if dir is already git repo and dirty -forgetest!(can_detect_dirty_git_status_on_init, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_detect_dirty_git_status_on_init, |prj, cmd| { prj.wipe(); // initialize new git repo @@ -249,7 +248,7 @@ forgetest!(can_detect_dirty_git_status_on_init, |prj: TestProject, mut cmd: Test }); // Checks that a forge project can be initialized without creating a git repository -forgetest!(can_init_no_git, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_no_git, |prj, cmd| { prj.wipe(); cmd.arg("init").arg(prj.root()).arg("--no-git"); @@ -262,7 +261,7 @@ forgetest!(can_init_no_git, |prj: TestProject, mut cmd: TestCommand| { }); // Checks that quiet mode does not print anything -forgetest!(can_init_quiet, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_quiet, |prj, cmd| { prj.wipe(); cmd.arg("init").arg(prj.root()).arg("-q"); @@ -270,7 +269,7 @@ forgetest!(can_init_quiet, |prj: TestProject, mut cmd: TestCommand| { }); // `forge init foobar` works with dir argument -forgetest!(can_init_with_dir, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_with_dir, |prj, cmd| { prj.create_file("README.md", "non-empty dir"); cmd.args(["init", "foobar"]); @@ -279,7 +278,7 @@ forgetest!(can_init_with_dir, |prj: TestProject, mut cmd: TestCommand| { }); // `forge init foobar --template [template]` works with dir argument -forgetest!(can_init_with_dir_and_template, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_with_dir_and_template, |prj, cmd| { cmd.args(["init", "foobar", "--template", "foundry-rs/forge-template"]); cmd.assert_success(); @@ -294,7 +293,7 @@ forgetest!(can_init_with_dir_and_template, |prj: TestProject, mut cmd: TestComma }); // `forge init foobar --template [template] --branch [branch]` works with dir argument -forgetest!(can_init_with_dir_and_template_and_branch, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_with_dir_and_template_and_branch, |prj, cmd| { cmd.args([ "init", "foobar", @@ -315,7 +314,7 @@ forgetest!(can_init_with_dir_and_template_and_branch, |prj: TestProject, mut cmd }); // `forge init --force` works on non-empty dirs -forgetest!(can_init_non_empty, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_non_empty, |prj, cmd| { prj.create_file("README.md", "non-empty dir"); cmd.arg("init").arg(prj.root()); cmd.assert_err(); @@ -327,7 +326,7 @@ forgetest!(can_init_non_empty, |prj: TestProject, mut cmd: TestCommand| { }); // `forge init --force` works on already initialized git repository -forgetest!(can_init_in_empty_repo, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_in_empty_repo, |prj, cmd| { let root = prj.root(); // initialize new git repo @@ -350,7 +349,7 @@ forgetest!(can_init_in_empty_repo, |prj: TestProject, mut cmd: TestCommand| { }); // `forge init --force` works on already initialized git repository -forgetest!(can_init_in_non_empty_repo, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_in_non_empty_repo, |prj, cmd| { let root = prj.root(); // initialize new git repo @@ -381,7 +380,7 @@ forgetest!(can_init_in_non_empty_repo, |prj: TestProject, mut cmd: TestCommand| }); // Checks that remappings.txt and .vscode/settings.json is generated -forgetest!(can_init_vscode, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_vscode, |prj, cmd| { prj.wipe(); cmd.arg("init").arg(prj.root()).arg("--vscode"); @@ -405,7 +404,7 @@ forgetest!(can_init_vscode, |prj: TestProject, mut cmd: TestCommand| { }); // checks that forge can init with template -forgetest!(can_init_template, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_template, |prj, cmd| { prj.wipe(); cmd.args(["init", "--template", "foundry-rs/forge-template"]).arg(prj.root()); cmd.assert_non_empty_stdout(); @@ -419,7 +418,7 @@ forgetest!(can_init_template, |prj: TestProject, mut cmd: TestCommand| { }); // checks that forge can init with template and branch -forgetest!(can_init_template_with_branch, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_init_template_with_branch, |prj, cmd| { prj.wipe(); cmd.args(["init", "--template", "foundry-rs/forge-template", "--branch", "test/deployments"]) .arg(prj.root()); @@ -434,14 +433,14 @@ forgetest!(can_init_template_with_branch, |prj: TestProject, mut cmd: TestComman }); // checks that init fails when the provided template doesn't exist -forgetest!(fail_init_nonexistent_template, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(fail_init_nonexistent_template, |prj, cmd| { prj.wipe(); cmd.args(["init", "--template", "a"]).arg(prj.root()); cmd.assert_non_empty_stderr(); }); // checks that `clean` removes dapptools style paths -forgetest!(can_clean, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_clean, |prj, cmd| { prj.assert_create_dirs_exists(); prj.assert_style_paths_exist(PathStyle::Dapptools); cmd.arg("clean"); @@ -450,7 +449,7 @@ forgetest!(can_clean, |prj: TestProject, mut cmd: TestCommand| { }); // checks that `clean` removes hardhat style paths -forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj, cmd| { prj.assert_create_dirs_exists(); prj.assert_style_paths_exist(PathStyle::HardHat); cmd.arg("clean"); @@ -459,7 +458,7 @@ forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj: TestProject, mut cmd: Te }); // checks that `clean` also works with the "out" value set in Config -forgetest_init!(can_clean_config, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_clean_config, |prj, cmd| { let config = Config { out: "custom-out".into(), ..Default::default() }; prj.write_config(config); cmd.arg("build"); @@ -475,7 +474,7 @@ forgetest_init!(can_clean_config, |prj: TestProject, mut cmd: TestCommand| { }); // checks that extra output works -forgetest_init!(can_emit_extra_output, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_emit_extra_output, |prj, cmd| { cmd.args(["build", "--extra-output", "metadata"]); cmd.assert_non_empty_stdout(); @@ -493,7 +492,7 @@ forgetest_init!(can_emit_extra_output, |prj: TestProject, mut cmd: TestCommand| }); // checks that extra output works -forgetest_init!(can_emit_multiple_extra_output, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| { cmd.args(["build", "--extra-output", "metadata", "ir-optimized", "--extra-output", "ir"]); cmd.assert_non_empty_stdout(); @@ -528,7 +527,7 @@ forgetest_init!(can_emit_multiple_extra_output, |prj: TestProject, mut cmd: Test std::fs::read_to_string(sourcemap).unwrap(); }); -forgetest!(can_print_warnings, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_print_warnings, |prj, cmd| { prj.inner() .add_source( "Foo", @@ -576,7 +575,7 @@ Warning (5667): Warning: Unused function parameter. Remove or comment out the va // 15 | FooLib.check2(this); // | ^^^^ #[cfg(not(target_os = "windows"))] -forgetest!(can_handle_direct_imports_into_src, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_handle_direct_imports_into_src, |prj, cmd| { prj.inner() .add_source( "Foo", @@ -626,7 +625,7 @@ Compiler run successful! }); // tests that the `inspect` command works correctly -forgetest!(can_execute_inspect_command, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_execute_inspect_command, |prj, cmd| { // explicitly set to include the ipfs bytecode hash let config = Config { bytecode_hash: BytecodeHash::Ipfs, ..Default::default() }; prj.write_config(config); @@ -671,7 +670,7 @@ contract Foo { forgetest!( #[serial_test::serial] can_check_snapshot, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { prj.insert_ds_test(); prj.inner() @@ -703,7 +702,7 @@ contract ATest is DSTest { ); // test that `forge build` does not print `(with warnings)` if there arent any -forgetest!(can_compile_without_warnings, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_compile_without_warnings, |prj, cmd| { let config = Config { ignored_error_codes: vec![SolidityErrorCode::SpdxLicenseNotProvided], ..Default::default() @@ -742,7 +741,7 @@ contract A { // test that `forge build` compiles when severity set to error, fails when set to warning, and // handles ignored error codes as an exception -forgetest!(can_fail_compile_with_warnings, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_fail_compile_with_warnings, |prj, cmd| { let config = Config { ignored_error_codes: vec![], deny_warnings: false, ..Default::default() }; prj.write_config(config); prj.inner() @@ -785,7 +784,7 @@ contract A { forgetest!( #[ignore] can_compile_local_spells, - |_: TestProject, mut cmd: TestCommand| { + |_prj, cmd| { let current_dir = std::env::current_dir().unwrap(); let root = current_dir .join("../../foundry-integration-tests/testdata/spells-mainnet") @@ -813,7 +812,7 @@ forgetest!( ); // test that a failing `forge build` does not impact followup builds -forgetest!(can_build_after_failure, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_build_after_failure, |prj, cmd| { prj.insert_ds_test(); prj.inner() @@ -912,7 +911,7 @@ contract CTest is DSTest { }); // test to check that install/remove works properly -forgetest!(can_install_and_remove, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_install_and_remove, |prj, cmd| { cmd.git_init(); let libs = prj.root().join("lib"); @@ -950,7 +949,7 @@ forgetest!(can_install_and_remove, |prj: TestProject, mut cmd: TestCommand| { }); // test to check that package can be reinstalled after manually removing the directory -forgetest!(can_reinstall_after_manual_remove, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_reinstall_after_manual_remove, |prj, cmd| { cmd.git_init(); let libs = prj.root().join("lib"); @@ -978,7 +977,7 @@ forgetest!(can_reinstall_after_manual_remove, |prj: TestProject, mut cmd: TestCo }); // test that we can repeatedly install the same dependency without changes -forgetest!(can_install_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_install_repeatedly, |_prj, cmd| { cmd.git_init(); cmd.forge_fuse().args(["install", "foundry-rs/forge-std"]); @@ -989,7 +988,7 @@ forgetest!(can_install_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { // test that by default we install the latest semver release tag // -forgetest!(can_install_latest_release_tag, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_install_latest_release_tag, |prj, cmd| { cmd.git_init(); cmd.forge_fuse().args(["install", "openzeppelin/openzeppelin-contracts"]); cmd.assert_success(); @@ -1009,8 +1008,9 @@ forgetest!(can_install_latest_release_tag, |prj: TestProject, mut cmd: TestComma // Tests that forge update doesn't break a working dependency by recursively updating nested // dependencies forgetest!( + #[cfg_attr(windows, ignore = "weird git fail")] can_update_library_with_outdated_nested_dependency, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { cmd.git_init(); let libs = prj.root().join("lib"); @@ -1021,20 +1021,17 @@ forgetest!( let package = libs.join("forge-5980-test"); let package_mod = git_mod.join("forge-5980-test"); - let install = |cmd: &mut TestCommand| { - // install main dependency - cmd.forge_fuse().args(["install", "evalir/forge-5980-test", "--no-commit"]); - cmd.assert_non_empty_stdout(); + // install main dependency + cmd.forge_fuse().args(["install", "evalir/forge-5980-test", "--no-commit"]); + cmd.assert_non_empty_stdout(); - // assert pathbufs exist - assert!(package.exists()); - assert!(package_mod.exists()); + // assert paths exist + assert!(package.exists()); + assert!(package_mod.exists()); - let submods = read_string(&git_mod_file); - assert!(submods.contains("https://github.com/evalir/forge-5980-test")); - }; + let submods = read_string(git_mod_file); + assert!(submods.contains("https://github.com/evalir/forge-5980-test")); - install(&mut cmd); // try to update the top-level dependency; there should be no update for this dependency, // but its sub-dependency has upstream (breaking) changes; forge should not attempt to // update the sub-dependency @@ -1078,7 +1075,7 @@ contract CounterCopy is Counter { } ); -forgetest!(gas_report_all_contracts, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(gas_report_all_contracts, |prj, cmd| { prj.insert_ds_test(); prj.inner() .add_source( @@ -1211,7 +1208,7 @@ contract ContractThreeTest is DSTest { // cmd.arg("test").arg("--gas-report").print_output(); }); -forgetest!(gas_report_some_contracts, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(gas_report_some_contracts, |prj, cmd| { prj.insert_ds_test(); prj.inner() .add_source( @@ -1340,7 +1337,7 @@ contract ContractThreeTest is DSTest { // cmd.arg("test").arg("--gas-report").print_output(); }); -forgetest!(gas_ignore_some_contracts, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(gas_ignore_some_contracts, |prj, cmd| { prj.insert_ds_test(); prj.inner() .add_source( @@ -1474,7 +1471,7 @@ contract ContractThreeTest is DSTest { assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); }); -forgetest_init!(can_use_absolute_imports, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_use_absolute_imports, |prj, cmd| { let remapping = prj.paths().libraries[0].join("myDepdendency"); let config = Config { remappings: vec![Remapping::from_str(&format!("myDepdendency/={}", remapping.display())) @@ -1525,75 +1522,72 @@ forgetest_init!(can_use_absolute_imports, |prj: TestProject, mut cmd: TestComman }); // -forgetest_init!( - can_use_absolute_imports_from_test_and_script, - |prj: TestProject, mut cmd: TestCommand| { - prj.inner() - .add_script( - "IMyScript.sol", - r" +forgetest_init!(can_use_absolute_imports_from_test_and_script, |prj, cmd| { + prj.inner() + .add_script( + "IMyScript.sol", + r" pragma solidity ^0.8.10; interface IMyScript {} ", - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_script( - "MyScript.sol", - r#" + prj.inner() + .add_script( + "MyScript.sol", + r#" pragma solidity ^0.8.10; import "script/IMyScript.sol"; contract MyScript is IMyScript {} "#, - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_test( - "IMyTest.sol", - r" + prj.inner() + .add_test( + "IMyTest.sol", + r" pragma solidity ^0.8.10; interface IMyTest {} ", - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_test( - "MyTest.sol", - r#" + prj.inner() + .add_test( + "MyTest.sol", + r#" pragma solidity ^0.8.10; import "test/IMyTest.sol"; contract MyTest is IMyTest {} "#, - ) - .unwrap(); + ) + .unwrap(); - cmd.arg("build"); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiler run successful")); - } -); + cmd.arg("build"); + let stdout = cmd.stdout_lossy(); + assert!(stdout.contains("Compiler run successful")); +}); // checks `forge inspect irOptimized works -forgetest_init!(can_inspect_ir_optimized, |_prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_inspect_ir_optimized, |_prj, cmd| { cmd.args(["inspect", TEMPLATE_CONTRACT, "irOptimized"]); cmd.assert_success(); }); // checks forge bind works correctly on the default project -forgetest_init!(can_bind, |_prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_bind, |_prj, cmd| { cmd.arg("bind"); cmd.assert_non_empty_stdout(); }); // checks missing dependencies are auto installed -forgetest_init!(can_install_missing_deps_test, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_install_missing_deps_test, |prj, cmd| { // wipe forge-std let forge_std_dir = prj.root().join("lib/forge-std"); pretty_err(&forge_std_dir, fs::remove_dir_all(&forge_std_dir)); @@ -1606,7 +1600,7 @@ forgetest_init!(can_install_missing_deps_test, |prj: TestProject, mut cmd: TestC }); // checks missing dependencies are auto installed -forgetest_init!(can_install_missing_deps_build, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_install_missing_deps_build, |prj, cmd| { // wipe forge-std let forge_std_dir = prj.root().join("lib/forge-std"); pretty_err(&forge_std_dir, fs::remove_dir_all(&forge_std_dir)); @@ -1619,7 +1613,7 @@ forgetest_init!(can_install_missing_deps_build, |prj: TestProject, mut cmd: Test }); // checks that extra output works -forgetest_init!(can_build_skip_contracts, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_build_skip_contracts, |prj, cmd| { // explicitly set to run with 0.8.17 for consistent output let config = Config { solc: Some("0.8.17".into()), ..Default::default() }; prj.write_config(config); @@ -1638,7 +1632,7 @@ forgetest_init!(can_build_skip_contracts, |prj: TestProject, mut cmd: TestComman assert!(out.trim().contains("No files changed, compilation skipped"), "{}", out); }); -forgetest_init!(can_build_skip_glob, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_build_skip_glob, |prj, cmd| { // explicitly set to run with 0.8.17 for consistent output let config = Config { solc: Some("0.8.17".into()), ..Default::default() }; prj.write_config(config); @@ -1662,7 +1656,7 @@ function test_run() external {} }); // checks that build --sizes includes all contracts even if unchanged -forgetest_init!(can_build_sizes_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_build_sizes_repeatedly, |_prj, cmd| { cmd.args(["build", "--sizes"]); let out = cmd.stdout_lossy(); @@ -1677,7 +1671,7 @@ forgetest_init!(can_build_sizes_repeatedly, |_prj: TestProject, mut cmd: TestCom }); // checks that build --names includes all contracts even if unchanged -forgetest_init!(can_build_names_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_build_names_repeatedly, |_prj, cmd| { cmd.args(["build", "--names"]); let out = cmd.stdout_lossy(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 461a77d5a0604..4c454ff83750e 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -9,16 +9,15 @@ use foundry_config::{ }; use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ - forgetest, forgetest_init, foundry_compilers::{remappings::Remapping, EvmVersion}, - pretty_eq, - util::{pretty_err, OutputExt, TestCommand, TestProject}, + util::{pretty_err, OutputExt, TestCommand}, }; use path_slash::PathBufExt; +use pretty_assertions::assert_eq; use std::{fs, path::PathBuf, str::FromStr}; // tests all config values that are in use -forgetest!(can_extract_config_values, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_extract_config_values, |prj, cmd| { // explicitly set all values let input = Config { profile: Config::DEFAULT_PROFILE, @@ -125,7 +124,7 @@ forgetest!(can_extract_config_values, |prj: TestProject, mut cmd: TestCommand| { forgetest!( #[serial_test::serial] can_show_config, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { cmd.arg("config"); let expected = Config::load_with_root(prj.root()).to_string_pretty().unwrap().trim().to_string(); @@ -140,7 +139,7 @@ forgetest!( forgetest_init!( #[serial_test::serial] can_override_config, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { cmd.set_current_dir(prj.root()); let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(foundry_toml.exists()); @@ -148,25 +147,25 @@ forgetest_init!( let profile = Config::load_with_root(prj.root()); // ensure that the auto-generated internal remapping for forge-std's ds-test exists assert_eq!(profile.remappings.len(), 2); - pretty_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); + assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); // ensure remappings contain test - pretty_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); + assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); // the loaded config has resolved, absolute paths - pretty_eq!( + assert_eq!( "ds-test/=lib/forge-std/lib/ds-test/src/", Remapping::from(profile.remappings[0].clone()).to_string() ); cmd.arg("config"); let expected = profile.to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); // remappings work let remappings_txt = prj.create_file("remappings.txt", "ds-test/=lib/forge-std/lib/ds-test/from-file/"); let config = forge_utils::load_config_with_root(Some(prj.root().into())); - pretty_eq!( + assert_eq!( format!( "ds-test/={}/", prj.root().join("lib/forge-std/lib/ds-test/from-file").to_slash_lossy() @@ -177,7 +176,7 @@ forgetest_init!( // env vars work std::env::set_var("DAPP_REMAPPINGS", "ds-test/=lib/forge-std/lib/ds-test/from-env/"); let config = forge_utils::load_config_with_root(Some(prj.root().into())); - pretty_eq!( + assert_eq!( format!( "ds-test/={}/", prj.root().join("lib/forge-std/lib/ds-test/from-env").to_slash_lossy() @@ -187,7 +186,7 @@ forgetest_init!( let config = prj.config_from_output(["--remappings", "ds-test/=lib/forge-std/lib/ds-test/from-cli"]); - pretty_eq!( + assert_eq!( format!( "ds-test/={}/", prj.root().join("lib/forge-std/lib/ds-test/from-cli").to_slash_lossy() @@ -197,7 +196,7 @@ forgetest_init!( let config = prj.config_from_output(["--remappings", "other-key/=lib/other/"]); assert_eq!(config.remappings.len(), 3); - pretty_eq!( + assert_eq!( format!("other-key/={}/", prj.root().join("lib/other").to_slash_lossy()), // As CLI has the higher priority, it'll be found at the first slot. Remapping::from(config.remappings[0].clone()).to_string() @@ -208,14 +207,14 @@ forgetest_init!( cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); let expected = profile.into_basic().to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); } ); forgetest_init!( #[serial_test::serial] can_parse_remappings_correctly, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { cmd.set_current_dir(prj.root()); let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(foundry_toml.exists()); @@ -224,17 +223,17 @@ forgetest_init!( // ensure that the auto-generated internal remapping for forge-std's ds-test exists assert_eq!(profile.remappings.len(), 2); let [r, _] = &profile.remappings[..] else { unreachable!() }; - pretty_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", r.to_string()); + assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", r.to_string()); // the loaded config has resolved, absolute paths - pretty_eq!( + assert_eq!( "ds-test/=lib/forge-std/lib/ds-test/src/", Remapping::from(r.clone()).to_string() ); cmd.arg("config"); let expected = profile.to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); let install = |cmd: &mut TestCommand, dep: &str| { cmd.forge_fuse().args(["install", dep, "--no-commit"]); @@ -253,13 +252,13 @@ forgetest_init!( let path = prj.root().join("lib/solmate/src/").to_slash_lossy().into_owned(); #[cfg(windows)] let path = path + "/"; - pretty_eq!( + assert_eq!( format!("solmate/={path}"), Remapping::from(config.remappings[0].clone()).to_string() ); // As this is an user-generated remapping, it is not removed, even if it points to the same // location. - pretty_eq!( + assert_eq!( format!("solmate-contracts/={path}"), Remapping::from(config.remappings[1].clone()).to_string() ); @@ -267,14 +266,14 @@ forgetest_init!( cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); let expected = profile.into_basic().to_string_pretty().unwrap(); - pretty_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); } ); forgetest_init!( #[serial_test::serial] can_detect_config_vals, - |prj: TestProject, _cmd: TestCommand| { + |prj, _cmd| { let url = "http://127.0.0.1:8545"; let config = prj.config_from_output(["--no-auto-detect", "--rpc-url", url]); assert!(!config.auto_detect_solc); @@ -298,7 +297,7 @@ forgetest_init!( forgetest_init!( #[serial_test::serial] can_get_evm_opts, - |prj: TestProject, _cmd: TestCommand| { + |prj, _cmd| { let url = "http://127.0.0.1:8545"; let config = prj.config_from_output(["--rpc-url", url, "--ffi"]); assert_eq!(config.eth_rpc_url, Some(url.to_string())); @@ -313,13 +312,13 @@ forgetest_init!( ); // checks that we can set various config values -forgetest_init!(can_set_config_values, |prj: TestProject, _cmd: TestCommand| { +forgetest_init!(can_set_config_values, |prj, _cmd| { let config = prj.config_from_output(["--via-ir"]); assert!(config.via_ir); }); // tests that solc can be explicitly set -forgetest!(can_set_solc_explicitly, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_set_solc_explicitly, |prj, cmd| { prj.inner() .add_source( "Foo", @@ -345,7 +344,7 @@ Compiler run successful! }); // tests that `--use ` works -forgetest!(can_use_solc, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_use_solc, |prj, cmd| { prj.inner() .add_source( "Foo", @@ -379,7 +378,7 @@ contract Foo {} }); // test to ensure yul optimizer can be set as intended -forgetest!(can_set_yul_optimizer, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_set_yul_optimizer, |prj, cmd| { prj.inner() .add_source( "Foo", @@ -418,7 +417,7 @@ Compiler run successful! }); // tests that the lib triple can be parsed -forgetest_init!(can_parse_dapp_libraries, |_prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_parse_dapp_libraries, |_prj, cmd| { cmd.set_env( "DAPP_LIBRARIES", "src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6", @@ -431,7 +430,7 @@ forgetest_init!(can_parse_dapp_libraries, |_prj: TestProject, mut cmd: TestComma }); // test that optimizer runs works -forgetest!(can_set_optimizer_runs, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_set_optimizer_runs, |prj, cmd| { // explicitly set optimizer runs let config = Config { optimizer_runs: 1337, ..Default::default() }; prj.write_config(config); @@ -444,7 +443,7 @@ forgetest!(can_set_optimizer_runs, |prj: TestProject, mut cmd: TestCommand| { }); // test that gas_price can be set -forgetest!(can_set_gas_price, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_set_gas_price, |prj, cmd| { // explicitly set gas_price let config = Config { gas_price: Some(1337), ..Default::default() }; prj.write_config(config); @@ -457,7 +456,7 @@ forgetest!(can_set_gas_price, |prj: TestProject, mut cmd: TestCommand| { }); // test that we can detect remappings from foundry.toml -forgetest_init!(can_detect_lib_foundry_toml, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); pretty_assertions::assert_eq!( @@ -543,7 +542,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj: TestProject, mut cmd: TestCom forgetest_init!( #[serial_test::serial] can_prioritise_closer_lib_remappings, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { let config = cmd.config(); // create a new lib directly in the `lib` folder with conflicting remapping `forge-std/` @@ -569,7 +568,7 @@ forgetest_init!( ); // test to check that foundry.toml libs section updates on install -forgetest!(can_update_libs_section, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_update_libs_section, |prj, cmd| { cmd.git_init(); // explicitly set gas_price @@ -594,7 +593,7 @@ forgetest!(can_update_libs_section, |prj: TestProject, mut cmd: TestCommand| { // test to check that loading the config emits warnings on the root foundry.toml and // is silent for any libs -forgetest!(config_emit_warnings, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(config_emit_warnings, |prj, cmd| { cmd.git_init(); cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]); @@ -620,7 +619,7 @@ forgetest!(config_emit_warnings, |prj: TestProject, mut cmd: TestCommand| { ) }); -forgetest_init!(can_skip_remappings_auto_detection, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_skip_remappings_auto_detection, |prj, cmd| { // explicitly set remapping and libraries let config = Config { remappings: vec![Remapping::from_str("remapping/=lib/remapping/").unwrap().into()], diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 5f8f23f407bdb..3631450bc14ea 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1,12 +1,11 @@ -use foundry_test_utils::{forgetest, TestCommand, TestProject}; use regex::Regex; -forgetest!(basic_coverage, |_prj: TestProject, mut cmd: TestCommand| { +forgetest!(basic_coverage, |_prj, cmd| { cmd.args(["coverage"]); cmd.assert_success(); }); -forgetest!(report_file_coverage, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(report_file_coverage, |prj, cmd| { cmd.arg("coverage").args([ "--report".to_string(), "lcov".to_string(), @@ -16,7 +15,7 @@ forgetest!(report_file_coverage, |prj: TestProject, mut cmd: TestCommand| { cmd.assert_success(); }); -forgetest!(test_setup_coverage, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(test_setup_coverage, |prj, cmd| { prj.insert_ds_test(); prj.inner() .add_source( diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index eb1d457347220..61961f4fff0f9 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -125,17 +125,17 @@ where } // tests `forge` create on goerli if correct env vars are set -forgetest!(can_create_simple_on_goerli, |prj: TestProject, cmd: TestCommand| { +forgetest!(can_create_simple_on_goerli, |prj, cmd| { create_on_chain(EnvExternalities::goerli(), prj, cmd, setup_with_simple_remapping); }); // tests `forge` create on goerli if correct env vars are set -forgetest!(can_create_oracle_on_goerli, |prj: TestProject, cmd: TestCommand| { +forgetest!(can_create_oracle_on_goerli, |prj, cmd| { create_on_chain(EnvExternalities::goerli(), prj, cmd, setup_oracle); }); // tests `forge` create on mumbai if correct env vars are set -forgetest!(can_create_oracle_on_mumbai, |prj: TestProject, cmd: TestCommand| { +forgetest!(can_create_oracle_on_mumbai, |prj, cmd| { create_on_chain(EnvExternalities::mumbai(), prj, cmd, setup_oracle); }); @@ -143,7 +143,7 @@ forgetest!(can_create_oracle_on_mumbai, |prj: TestProject, cmd: TestCommand| { forgetest_async!( #[serial_test::serial] can_create_template_contract, - |prj: TestProject, mut cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let wallet = handle.dev_wallets().next().unwrap(); @@ -182,7 +182,7 @@ forgetest_async!( forgetest_async!( #[serial_test::serial] can_create_using_unlocked, - |prj: TestProject, mut cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let dev = handle.dev_accounts().next().unwrap(); @@ -221,7 +221,7 @@ forgetest_async!( forgetest_async!( #[serial_test::serial] can_create_with_constructor_args, - |prj: TestProject, mut cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let wallet = handle.dev_wallets().next().unwrap(); diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 049d8eca35c5a..3574222a2fad0 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -1,10 +1,9 @@ -use foundry_test_utils::forgetest_external; - forgetest_external!(solmate, "transmissions11/solmate"); forgetest_external!(prb_math, "PaulRBerg/prb-math"); forgetest_external!(prb_proxy, "PaulRBerg/prb-proxy"); forgetest_external!(solady, "Vectorized/solady"); forgetest_external!( + #[cfg_attr(windows, ignore = "weird git fail")] geb, "reflexer-labs/geb", &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] diff --git a/crates/forge/tests/cli/heavy_integration.rs b/crates/forge/tests/cli/heavy_integration.rs index 7363b0ca4ef68..1b21eb85f9ebb 100644 --- a/crates/forge/tests/cli/heavy_integration.rs +++ b/crates/forge/tests/cli/heavy_integration.rs @@ -1,5 +1,3 @@ //! Heavy integration tests that can take an hour to run or more. -use foundry_test_utils::forgetest_external; - forgetest_external!(maple, "maple-labs/maple-core-v2"); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 69868c93a7c8e..71e2acc492980 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate foundry_test_utils; + pub mod constants; pub mod utils; diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index 717fb05b74d91..fff670c34dbed 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -1,88 +1,63 @@ //! Contains various tests related to forge script use anvil::{spawn, NodeConfig}; -use foundry_test_utils::{ - forgetest_async, - util::{TestCommand, TestProject}, - ScriptOutcome, ScriptTester, -}; +use foundry_test_utils::{ScriptOutcome, ScriptTester}; use foundry_utils::types::ToEthers; -forgetest_async!( - can_deploy_multi_chain_script_without_lib, - |prj: TestProject, cmd: TestCommand| async move { - let (api1, handle1) = spawn(NodeConfig::test()).await; - let (api2, handle2) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); - - tester - .load_private_keys([0, 1]) - .await - .add_sig("MultiChainBroadcastNoLink", "deploy(string memory,string memory)") - .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) - .broadcast(ScriptOutcome::OkBroadcast); - - assert_eq!( - api1.transaction_count(tester.accounts_pub[0].to_ethers(), None) - .await - .unwrap() - .as_u32(), - 1 - ); - assert_eq!( - api1.transaction_count(tester.accounts_pub[1].to_ethers(), None) - .await - .unwrap() - .as_u32(), - 1 - ); - - assert_eq!( - api2.transaction_count(tester.accounts_pub[0].to_ethers(), None) - .await - .unwrap() - .as_u32(), - 2 - ); - assert_eq!( - api2.transaction_count(tester.accounts_pub[1].to_ethers(), None) - .await - .unwrap() - .as_u32(), - 3 - ); - } -); - -forgetest_async!( - can_not_deploy_multi_chain_script_with_lib, - |prj: TestProject, cmd: TestCommand| async move { - let (_, handle1) = spawn(NodeConfig::test()).await; - let (_, handle2) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); - - tester - .load_private_keys([0, 1]) - .await - .add_deployer(0) - .add_sig("MultiChainBroadcastLink", "deploy(string memory,string memory)") - .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) - .broadcast(ScriptOutcome::UnsupportedLibraries); - } -); - -forgetest_async!( - can_not_change_fork_during_broadcast, - |prj: TestProject, cmd: TestCommand| async move { - let (_, handle1) = spawn(NodeConfig::test()).await; - let (_, handle2) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); - - tester - .load_private_keys([0, 1]) - .await - .add_deployer(0) - .add_sig("MultiChainBroadcastNoLink", "deployError(string memory,string memory)") - .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) - .broadcast(ScriptOutcome::ErrorSelectForkOnBroadcast); - } -); +forgetest_async!(can_deploy_multi_chain_script_without_lib, |prj, cmd| { + let (api1, handle1) = spawn(NodeConfig::test()).await; + let (api2, handle2) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); + + tester + .load_private_keys([0, 1]) + .await + .add_sig("MultiChainBroadcastNoLink", "deploy(string memory,string memory)") + .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) + .broadcast(ScriptOutcome::OkBroadcast); + + assert_eq!( + api1.transaction_count(tester.accounts_pub[0].to_ethers(), None).await.unwrap().as_u32(), + 1 + ); + assert_eq!( + api1.transaction_count(tester.accounts_pub[1].to_ethers(), None).await.unwrap().as_u32(), + 1 + ); + + assert_eq!( + api2.transaction_count(tester.accounts_pub[0].to_ethers(), None).await.unwrap().as_u32(), + 2 + ); + assert_eq!( + api2.transaction_count(tester.accounts_pub[1].to_ethers(), None).await.unwrap().as_u32(), + 3 + ); +}); + +forgetest_async!(can_not_deploy_multi_chain_script_with_lib, |prj, cmd| { + let (_, handle1) = spawn(NodeConfig::test()).await; + let (_, handle2) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); + + tester + .load_private_keys([0, 1]) + .await + .add_deployer(0) + .add_sig("MultiChainBroadcastLink", "deploy(string memory,string memory)") + .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) + .broadcast(ScriptOutcome::UnsupportedLibraries); +}); + +forgetest_async!(can_not_change_fork_during_broadcast, |prj, cmd| { + let (_, handle1) = spawn(NodeConfig::test()).await; + let (_, handle2) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); + + tester + .load_private_keys([0, 1]) + .await + .add_deployer(0) + .add_sig("MultiChainBroadcastNoLink", "deployError(string memory,string memory)") + .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) + .broadcast(ScriptOutcome::ErrorSelectForkOnBroadcast); +}); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 71934d19aa77c..be8b548a68790 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3,11 +3,7 @@ use crate::constants::TEMPLATE_CONTRACT; use anvil::{spawn, NodeConfig}; use ethers::abi::Address; use foundry_config::Config; -use foundry_test_utils::{ - forgetest, forgetest_async, forgetest_init, - util::{OutputExt, TestCommand, TestProject}, - ScriptOutcome, ScriptTester, -}; +use foundry_test_utils::{util::OutputExt, ScriptOutcome, ScriptTester}; use foundry_utils::{ rpc, types::{ToAlloy, ToEthers}, @@ -20,7 +16,7 @@ use std::{env, path::PathBuf, str::FromStr}; forgetest_init!( #[ignore] can_use_fork_cheat_codes_in_script, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { let script = prj .inner() .add_source( @@ -50,7 +46,7 @@ contract ContractScript is Script { ); // Tests that the `run` command works correctly -forgetest!(can_execute_script_command2, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_execute_script_command2, |prj, cmd| { let script = prj .inner() .add_source( @@ -76,7 +72,7 @@ contract Demo { }); // Tests that the `run` command works correctly when path *and* script name is specified -forgetest!(can_execute_script_command_fqn, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_execute_script_command_fqn, |prj, cmd| { let script = prj .inner() .add_source( @@ -102,7 +98,7 @@ contract Demo { }); // Tests that the run command can run arbitrary functions -forgetest!(can_execute_script_command_with_sig, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_execute_script_command_with_sig, |prj, cmd| { let script = prj .inner() .add_source( @@ -128,15 +124,13 @@ contract Demo { }); // Tests that the manually specified gas limit is used when using the --unlocked option -forgetest_async!( - can_execute_script_command_with_manual_gas_limit_unlocked, - |prj: TestProject, mut cmd: TestCommand| async move { - foundry_test_utils::util::initialize(prj.root()); - let deploy_script = prj - .inner() - .add_source( - "Foo", - r#" +forgetest_async!(can_execute_script_command_with_manual_gas_limit_unlocked, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let deploy_script = prj + .inner() + .add_source( + "Foo", + r#" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.10; import "forge-std/Script.sol"; @@ -154,49 +148,45 @@ contract DeployScript is Script { } } "#, - ) - .unwrap(); + ) + .unwrap(); - let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; - - let node_config = NodeConfig::test() - .with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())) - .silent(); - let (_api, handle) = spawn(node_config).await; - let dev = handle.dev_accounts().next().unwrap(); - cmd.set_current_dir(prj.root()); - - cmd.args([ - "script", - &deploy_contract, - "--root", - prj.root().to_str().unwrap(), - "--fork-url", - &handle.http_endpoint(), - "--sender", - format!("{dev:?}").as_str(), - "-vvvvv", - "--slow", - "--broadcast", - "--unlocked", - ]); - - let output = cmd.stdout_lossy(); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); - assert!(output.contains("Gas limit was set in script to 500000")); - } -); + let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; + + let node_config = + NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())).silent(); + let (_api, handle) = spawn(node_config).await; + let dev = handle.dev_accounts().next().unwrap(); + cmd.set_current_dir(prj.root()); + + cmd.args([ + "script", + &deploy_contract, + "--root", + prj.root().to_str().unwrap(), + "--fork-url", + &handle.http_endpoint(), + "--sender", + format!("{dev:?}").as_str(), + "-vvvvv", + "--slow", + "--broadcast", + "--unlocked", + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); + assert!(output.contains("Gas limit was set in script to 500000")); +}); // Tests that the manually specified gas limit is used. -forgetest_async!( - can_execute_script_command_with_manual_gas_limit, - |prj: TestProject, mut cmd: TestCommand| async move { - foundry_test_utils::util::initialize(prj.root()); - let deploy_script = prj - .inner() - .add_source( - "Foo", - r#" +forgetest_async!(can_execute_script_command_with_manual_gas_limit, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let deploy_script = prj + .inner() + .add_source( + "Foo", + r#" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.10; import "forge-std/Script.sol"; @@ -214,41 +204,39 @@ contract DeployScript is Script { } } "#, - ) - .unwrap(); + ) + .unwrap(); - let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; - - let node_config = NodeConfig::test() - .with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())) - .silent(); - let (_api, handle) = spawn(node_config).await; - let private_key = - "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); - cmd.set_current_dir(prj.root()); - - cmd.args([ - "script", - &deploy_contract, - "--root", - prj.root().to_str().unwrap(), - "--fork-url", - &handle.http_endpoint(), - "-vvvvv", - "--slow", - "--broadcast", - "--private-key", - &private_key, - ]); - - let output = cmd.stdout_lossy(); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); - assert!(output.contains("Gas limit was set in script to 500000")); - } -); + let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; + + let node_config = + NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())).silent(); + let (_api, handle) = spawn(node_config).await; + let private_key = + "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); + cmd.set_current_dir(prj.root()); + + cmd.args([ + "script", + &deploy_contract, + "--root", + prj.root().to_str().unwrap(), + "--fork-url", + &handle.http_endpoint(), + "-vvvvv", + "--slow", + "--broadcast", + "--private-key", + &private_key, + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); + assert!(output.contains("Gas limit was set in script to 500000")); +}); // Tests that the run command can run functions with arguments -forgetest!(can_execute_script_command_with_args, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_execute_script_command_with_args, |prj, cmd| { let script = prj .inner() .add_source( @@ -277,7 +265,7 @@ contract Demo { }); // Tests that the run command can run functions with return values -forgetest!(can_execute_script_command_with_returned, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_execute_script_command_with_returned, |prj, cmd| { let script = prj .inner() .add_source( @@ -301,16 +289,14 @@ contract Demo { ); }); -forgetest_async!( - can_broadcast_script_skipping_simulation, - |prj: TestProject, mut cmd: TestCommand| async move { - foundry_test_utils::util::initialize(prj.root()); - // This example script would fail in on-chain simulation - let deploy_script = prj - .inner() - .add_source( - "DeployScript", - r#" +forgetest_async!(can_broadcast_script_skipping_simulation, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + // This example script would fail in on-chain simulation + let deploy_script = prj + .inner() + .add_source( + "DeployScript", + r#" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.10; import "forge-std/Script.sol"; @@ -333,48 +319,46 @@ contract DeployScript is Script { HashChecker hashChecker = new HashChecker(); } }"#, - ) - .unwrap(); + ) + .unwrap(); - let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; - - let node_config = NodeConfig::test() - .with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())) - .silent(); - let (_api, handle) = spawn(node_config).await; - let private_key = - "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); - cmd.set_current_dir(prj.root()); - - cmd.args([ - "script", - &deploy_contract, - "--root", - prj.root().to_str().unwrap(), - "--fork-url", - &handle.http_endpoint(), - "-vvvvv", - "--broadcast", - "--slow", - "--skip-simulation", - "--private-key", - &private_key, - ]); - - let output = cmd.stdout_lossy(); - - assert!(output.contains("SKIPPING ON CHAIN SIMULATION")); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); + let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; + + let node_config = + NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())).silent(); + let (_api, handle) = spawn(node_config).await; + let private_key = + "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); + cmd.set_current_dir(prj.root()); + + cmd.args([ + "script", + &deploy_contract, + "--root", + prj.root().to_str().unwrap(), + "--fork-url", + &handle.http_endpoint(), + "-vvvvv", + "--broadcast", + "--slow", + "--skip-simulation", + "--private-key", + &private_key, + ]); + + let output = cmd.stdout_lossy(); + + assert!(output.contains("SKIPPING ON CHAIN SIMULATION")); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); + + let run_log = std::fs::read_to_string("broadcast/DeployScript.sol/1/run-latest.json").unwrap(); + let run_object: Value = serde_json::from_str(&run_log).unwrap(); + let contract_address = ethers::utils::to_checksum( + &run_object["receipts"][0]["contractAddress"].as_str().unwrap().parse().unwrap(), + None, + ); - let run_log = - std::fs::read_to_string("broadcast/DeployScript.sol/1/run-latest.json").unwrap(); - let run_object: Value = serde_json::from_str(&run_log).unwrap(); - let contract_address = ethers::utils::to_checksum( - &run_object["receipts"][0]["contractAddress"].as_str().unwrap().parse().unwrap(), - None, - ); - - let run_code = r#" + let run_code = r#" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.10; import "forge-std/Script.sol"; @@ -393,37 +377,36 @@ contract RunScript is Script { } } }"# - .replace("CONTRACT_ADDRESS", &contract_address); - - let run_script = prj.inner().add_source("RunScript", run_code).unwrap(); - let run_contract = run_script.display().to_string() + ":RunScript"; - - cmd.forge_fuse(); - cmd.set_current_dir(prj.root()); - cmd.args([ - "script", - &run_contract, - "--root", - prj.root().to_str().unwrap(), - "--fork-url", - &handle.http_endpoint(), - "-vvvvv", - "--broadcast", - "--slow", - "--skip-simulation", - "--gas-estimate-multiplier", - "200", - "--private-key", - &private_key, - ]); - - let output = cmd.stdout_lossy(); - assert!(output.contains("SKIPPING ON CHAIN SIMULATION")); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); - } -); + .replace("CONTRACT_ADDRESS", &contract_address); + + let run_script = prj.inner().add_source("RunScript", run_code).unwrap(); + let run_contract = run_script.display().to_string() + ":RunScript"; + + cmd.forge_fuse(); + cmd.set_current_dir(prj.root()); + cmd.args([ + "script", + &run_contract, + "--root", + prj.root().to_str().unwrap(), + "--fork-url", + &handle.http_endpoint(), + "-vvvvv", + "--broadcast", + "--slow", + "--skip-simulation", + "--gas-estimate-multiplier", + "200", + "--private-key", + &private_key, + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("SKIPPING ON CHAIN SIMULATION")); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +}); -forgetest_async!(can_deploy_script_without_lib, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(can_deploy_script_without_lib, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -437,7 +420,7 @@ forgetest_async!(can_deploy_script_without_lib, |prj: TestProject, cmd: TestComm .await; }); -forgetest_async!(can_deploy_script_with_lib, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(can_deploy_script_with_lib, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -454,7 +437,7 @@ forgetest_async!(can_deploy_script_with_lib, |prj: TestProject, cmd: TestCommand forgetest_async!( #[serial_test::serial] can_deploy_script_private_key, - |prj: TestProject, cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -477,7 +460,7 @@ forgetest_async!( forgetest_async!( #[serial_test::serial] can_deploy_unlocked, - |prj: TestProject, cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -493,7 +476,7 @@ forgetest_async!( forgetest_async!( #[serial_test::serial] can_deploy_script_remember_key, - |prj: TestProject, cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -516,7 +499,7 @@ forgetest_async!( forgetest_async!( #[serial_test::serial] can_deploy_script_remember_key_and_resume, - |prj: TestProject, cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -543,7 +526,7 @@ forgetest_async!( } ); -forgetest_async!(can_resume_script, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(can_resume_script, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -561,7 +544,7 @@ forgetest_async!(can_resume_script, |prj: TestProject, cmd: TestCommand| async m .await; }); -forgetest_async!(can_deploy_broadcast_wrap, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(can_deploy_broadcast_wrap, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -576,7 +559,7 @@ forgetest_async!(can_deploy_broadcast_wrap, |prj: TestProject, cmd: TestCommand| .await; }); -forgetest_async!(panic_no_deployer_set, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(panic_no_deployer_set, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -588,7 +571,7 @@ forgetest_async!(panic_no_deployer_set, |prj: TestProject, cmd: TestCommand| asy .broadcast(ScriptOutcome::MissingSender); }); -forgetest_async!(can_deploy_no_arg_broadcast, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(can_deploy_no_arg_broadcast, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -603,7 +586,7 @@ forgetest_async!(can_deploy_no_arg_broadcast, |prj: TestProject, cmd: TestComman .await; }); -forgetest_async!(can_deploy_with_create2, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(can_deploy_with_create2, |prj, cmd| { let (api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -633,7 +616,7 @@ forgetest_async!(can_deploy_with_create2, |prj: TestProject, cmd: TestCommand| a forgetest_async!( #[serial_test::serial] can_deploy_and_simulate_25_txes_concurrently, - |prj: TestProject, cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -651,7 +634,7 @@ forgetest_async!( forgetest_async!( #[serial_test::serial] can_deploy_and_simulate_mixed_broadcast_modes, - |prj: TestProject, cmd: TestCommand| async move { + |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -666,7 +649,7 @@ forgetest_async!( } ); -forgetest_async!(deploy_with_setup, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(deploy_with_setup, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -680,7 +663,7 @@ forgetest_async!(deploy_with_setup, |prj: TestProject, cmd: TestCommand| async m .await; }); -forgetest_async!(fail_broadcast_staticcall, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(fail_broadcast_staticcall, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -694,7 +677,7 @@ forgetest_async!(fail_broadcast_staticcall, |prj: TestProject, cmd: TestCommand| forgetest_async!( #[serial_test::serial] check_broadcast_log, - |prj: TestProject, cmd: TestCommand| async move { + |prj, cmd| { let (api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -767,7 +750,7 @@ forgetest_async!( } ); -forgetest_async!(test_default_sender_balance, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(test_default_sender_balance, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -777,7 +760,7 @@ forgetest_async!(test_default_sender_balance, |prj: TestProject, cmd: TestComman .simulate(ScriptOutcome::OkSimulation); }); -forgetest_async!(test_custom_sender_balance, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(test_custom_sender_balance, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -799,15 +782,13 @@ struct Transaction { } // test we output arguments -forgetest_async!( - can_execute_script_with_arguments, - |prj: TestProject, mut cmd: TestCommand| async move { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); +forgetest_async!(can_execute_script_with_arguments, |prj, cmd| { + cmd.args(["init", "--force"]).arg(prj.root()); + cmd.assert_non_empty_stdout(); + cmd.forge_fuse(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let script = prj + let (_api, handle) = spawn(NodeConfig::test()).await; + let script = prj .inner() .add_script( "Counter.s.sol", @@ -848,57 +829,54 @@ contract Script0 is Script { ) .unwrap(); - cmd.arg("script").arg(script).args([ - "--tc", - "Script0", - "--sender", - "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", - "--rpc-url", - handle.http_endpoint().as_str(), - ]); - - assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); - - let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast")) - .into_iter() - .find(|file| file.ends_with("run-latest.json")) - .expect("No broadcast artifacts"); - - let content = foundry_common::fs::read_to_string(run_latest).unwrap(); - - let transactions: Transactions = serde_json::from_str(&content).unwrap(); - let transactions = transactions.transactions; - assert_eq!(transactions.len(), 1); - assert_eq!( - transactions[0].arguments, - vec![ - "0x00a329c0648769A73afAc7F9381E08FB43dBEA72".to_string(), - "4294967296".to_string(), - "-4294967296".to_string(), - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string(), - "true".to_string(), - "0x616263646566".to_string(), - "(10, 99)".to_string(), - "hello".to_string(), - ] - ); - } -); + cmd.arg("script").arg(script).args([ + "--tc", + "Script0", + "--sender", + "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", + "--rpc-url", + handle.http_endpoint().as_str(), + ]); + + assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); + + let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast")) + .into_iter() + .find(|file| file.ends_with("run-latest.json")) + .expect("No broadcast artifacts"); + + let content = foundry_common::fs::read_to_string(run_latest).unwrap(); + + let transactions: Transactions = serde_json::from_str(&content).unwrap(); + let transactions = transactions.transactions; + assert_eq!(transactions.len(), 1); + assert_eq!( + transactions[0].arguments, + vec![ + "0x00a329c0648769A73afAc7F9381E08FB43dBEA72".to_string(), + "4294967296".to_string(), + "-4294967296".to_string(), + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string(), + "true".to_string(), + "0x616263646566".to_string(), + "(10, 99)".to_string(), + "hello".to_string(), + ] + ); +}); // test we output arguments -forgetest_async!( - can_execute_script_with_arguments_nested_deploy, - |prj: TestProject, mut cmd: TestCommand| async move { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); +forgetest_async!(can_execute_script_with_arguments_nested_deploy, |prj, cmd| { + cmd.args(["init", "--force"]).arg(prj.root()); + cmd.assert_non_empty_stdout(); + cmd.forge_fuse(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let script = prj - .inner() - .add_script( - "Counter.s.sol", - r#" + let (_api, handle) = spawn(NodeConfig::test()).await; + let script = prj + .inner() + .add_script( + "Counter.s.sol", + r#" pragma solidity ^0.8.13; import "forge-std/Script.sol"; @@ -936,47 +914,46 @@ contract Script0 is Script { } } "#, - ) - .unwrap(); + ) + .unwrap(); - cmd.arg("script").arg(script).args([ - "--tc", - "Script0", - "--sender", - "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", - "--rpc-url", - handle.http_endpoint().as_str(), - ]); - - assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); - - let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast")) - .into_iter() - .find(|file| file.ends_with("run-latest.json")) - .expect("No broadcast artifacts"); - - let content = foundry_common::fs::read_to_string(run_latest).unwrap(); - - let transactions: Transactions = serde_json::from_str(&content).unwrap(); - let transactions = transactions.transactions; - assert_eq!(transactions.len(), 1); - assert_eq!( - transactions[0].arguments, - vec![ - "0x00a329c0648769A73afAc7F9381E08FB43dBEA72".to_string(), - "4294967296".to_string(), - "-4294967296".to_string(), - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string(), - "true".to_string(), - "0x616263646566".to_string(), - "hello".to_string(), - ] - ); - } -); + cmd.arg("script").arg(script).args([ + "--tc", + "Script0", + "--sender", + "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", + "--rpc-url", + handle.http_endpoint().as_str(), + ]); + + assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); + + let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast")) + .into_iter() + .find(|file| file.ends_with("run-latest.json")) + .expect("No broadcast artifacts"); + + let content = foundry_common::fs::read_to_string(run_latest).unwrap(); + + let transactions: Transactions = serde_json::from_str(&content).unwrap(); + let transactions = transactions.transactions; + assert_eq!(transactions.len(), 1); + assert_eq!( + transactions[0].arguments, + vec![ + "0x00a329c0648769A73afAc7F9381E08FB43dBEA72".to_string(), + "4294967296".to_string(), + "-4294967296".to_string(), + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string(), + "true".to_string(), + "0x616263646566".to_string(), + "hello".to_string(), + ] + ); +}); // checks that skipping build -forgetest_init!(can_execute_script_and_skip_contracts, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_execute_script_and_skip_contracts, |prj, cmd| { // explicitly set to run with 0.8.17 for consistent output let config = Config { solc: Some("0.8.17".into()), ..Default::default() }; prj.write_config(config); @@ -1005,33 +982,28 @@ contract Demo { ); }); -forgetest_async!( - can_run_script_with_empty_setup, - |prj: TestProject, cmd: TestCommand| async move { - let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); +forgetest_async!(can_run_script_with_empty_setup, |prj, cmd| { + let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); - tester.add_sig("BroadcastEmptySetUp", "run()").simulate(ScriptOutcome::OkNoEndpoint); - } -); + tester.add_sig("BroadcastEmptySetUp", "run()").simulate(ScriptOutcome::OkNoEndpoint); +}); -forgetest_async!(does_script_override_correctly, |prj: TestProject, cmd: TestCommand| async move { +forgetest_async!(does_script_override_correctly, |prj, cmd| { let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); tester.add_sig("CheckOverrides", "run()").simulate(ScriptOutcome::OkNoEndpoint); }); -forgetest_async!( - assert_tx_origin_is_not_overritten, - |prj: TestProject, mut cmd: TestCommand| async move { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); +forgetest_async!(assert_tx_origin_is_not_overritten, |prj, cmd| { + cmd.args(["init", "--force"]).arg(prj.root()); + cmd.assert_non_empty_stdout(); + cmd.forge_fuse(); - let script = prj - .inner() - .add_script( - "ScriptTxOrigin.s.sol", - r#" + let script = prj + .inner() + .add_script( + "ScriptTxOrigin.s.sol", + r#" pragma solidity ^0.8.13; import { Script } from "forge-std/Script.sol"; @@ -1081,26 +1053,23 @@ contract ContractC { } } "#, - ) - .unwrap(); + ) + .unwrap(); - cmd.arg("script").arg(script).args(["--tc", "ScriptTxOrigin"]); - assert!(cmd.stdout_lossy().contains("Script ran successfully.")); - } -); + cmd.arg("script").arg(script).args(["--tc", "ScriptTxOrigin"]); + assert!(cmd.stdout_lossy().contains("Script ran successfully.")); +}); -forgetest_async!( - assert_can_create_multiple_contracts_with_correct_nonce, - |prj: TestProject, mut cmd: TestCommand| async move { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); +forgetest_async!(assert_can_create_multiple_contracts_with_correct_nonce, |prj, cmd| { + cmd.args(["init", "--force"]).arg(prj.root()); + cmd.assert_non_empty_stdout(); + cmd.forge_fuse(); - let script = prj - .inner() - .add_script( - "ScriptTxOrigin.s.sol", - r#" + let script = prj + .inner() + .add_script( + "ScriptTxOrigin.s.sol", + r#" pragma solidity ^0.8.17; import {Script, console} from "forge-std/Script.sol"; @@ -1133,10 +1102,9 @@ contract NestedCreateFail is Script { } } "#, - ) - .unwrap(); + ) + .unwrap(); - cmd.arg("script").arg(script).args(["--tc", "NestedCreateFail"]); - assert!(cmd.stdout_lossy().contains("Script ran successfully.")); - } -); + cmd.arg("script").arg(script).args(["--tc", "NestedCreateFail"]); + assert!(cmd.stdout_lossy().contains("Script ran successfully.")); +}); diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 3d08309d22f12..00e7476eaa405 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -1,6 +1,5 @@ //! svm sanity checks -use foundry_test_utils::{forgetest_init, TestCommand, TestProject}; use semver::Version; use svm::Platform; @@ -42,7 +41,7 @@ ensure_svm_releases!( ); // Ensures we can always test with the latest solc build -forgetest_init!(can_test_with_latest_solc, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_test_with_latest_solc, |prj, cmd| { let src = format!( r#" // SPDX-License-Identifier: UNLICENSED @@ -58,5 +57,5 @@ contract CounterTest is Test {{ "# ); prj.inner().add_test("Counter", src).unwrap(); - cmd.arg("test").stdout_lossy().contains("[PASS]") + cmd.arg("test").stdout_lossy().contains("[PASS]"); }); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 9f4da608bb40f..4de10924c475d 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,14 +1,11 @@ //! Contains various tests for checking `forge test` use foundry_config::Config; -use foundry_test_utils::{ - forgetest, forgetest_init, - util::{template_lock, OutputExt, TestCommand, TestProject}, -}; +use foundry_test_utils::util::{template_lock, OutputExt}; use foundry_utils::rpc; use std::{path::PathBuf, process::Command, str::FromStr}; // tests that test filters are handled correctly -forgetest!(can_set_filter_values, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_set_filter_values, |prj, cmd| { let patt = regex::Regex::new("test*").unwrap(); let glob = globset::Glob::from_str("foo/bar/baz*").unwrap(); @@ -35,7 +32,7 @@ forgetest!(can_set_filter_values, |prj: TestProject, mut cmd: TestCommand| { }); // tests that warning is displayed when there are no tests in project -forgetest!(warn_no_tests, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(warn_no_tests, |prj, cmd| { prj.inner() .add_source( "dummy", @@ -57,7 +54,7 @@ contract Dummy {} }); // tests that warning is displayed with pattern when no tests match -forgetest!(warn_no_tests_match, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(warn_no_tests_match, |prj, cmd| { prj.inner() .add_source( "dummy", @@ -82,7 +79,7 @@ contract Dummy {} }); // tests that suggestion is provided with pattern when no tests match -forgetest!(suggest_when_no_tests_match, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(suggest_when_no_tests_match, |prj, cmd| { // set up project prj.inner() .add_source( @@ -112,7 +109,7 @@ contract TestC { }); // tests that direct import paths are handled correctly -forgetest!(can_fuzz_array_params, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_fuzz_array_params, |prj, cmd| { prj.insert_ds_test(); prj.inner() @@ -132,11 +129,11 @@ contract ATest is DSTest { .unwrap(); cmd.arg("test"); - cmd.stdout_lossy().contains("[PASS]") + cmd.stdout_lossy().contains("[PASS]"); }); // tests that `bytecode_hash` will be sanitized -forgetest!(can_test_pre_bytecode_hash, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_test_pre_bytecode_hash, |prj, cmd| { prj.insert_ds_test(); prj.inner() @@ -157,11 +154,11 @@ contract ATest is DSTest { .unwrap(); cmd.arg("test"); - cmd.stdout_lossy().contains("[PASS]") + cmd.stdout_lossy().contains("[PASS]"); }); // tests that using the --match-path option only runs files matching the path -forgetest!(can_test_with_match_path, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_test_with_match_path, |prj, cmd| { prj.insert_ds_test(); prj.inner() @@ -197,11 +194,11 @@ contract FailTest is DSTest { .unwrap(); cmd.args(["test", "--match-path", "*src/ATest.t.sol"]); - cmd.stdout_lossy().contains("[PASS]") && !cmd.stdout_lossy().contains("[FAIL]") + assert!(cmd.stdout_lossy().contains("[PASS]") && !cmd.stdout_lossy().contains("[FAIL]")); }); // tests that `forge test` will pick up tests that are stored in the `test = ` config value -forgetest!(can_run_test_in_custom_test_folder, |prj: TestProject, mut cmd: TestCommand| { +forgetest!(can_run_test_in_custom_test_folder, |prj, cmd| { prj.insert_ds_test(); // explicitly set the test folder @@ -234,7 +231,7 @@ contract MyTest is DSTest { }); // checks that forge test repeatedly produces the same output -forgetest_init!(can_test_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_test_repeatedly, |_prj, cmd| { cmd.arg("test"); cmd.assert_non_empty_stdout(); @@ -247,15 +244,13 @@ forgetest_init!(can_test_repeatedly, |_prj: TestProject, mut cmd: TestCommand| { }); // tests that `forge test` will run a test only once after changing the version -forgetest!( - runs_tests_exactly_once_with_changed_versions, - |prj: TestProject, mut cmd: TestCommand| { - prj.insert_ds_test(); - - prj.inner() - .add_source( - "Contract.t.sol", - r#" +forgetest!(runs_tests_exactly_once_with_changed_versions, |prj, cmd| { + prj.insert_ds_test(); + + prj.inner() + .add_source( + "Contract.t.sol", + r#" // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.10; import "./test.sol"; @@ -267,36 +262,35 @@ contract ContractTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); - // pin version - let config = Config { solc: Some("0.8.10".into()), ..Default::default() }; - prj.write_config(config); + // pin version + let config = Config { solc: Some("0.8.10".into()), ..Default::default() }; + prj.write_config(config); - cmd.arg("test"); - cmd.unchecked_output() - .stdout_matches_path(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join( - "tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout", - )); + cmd.arg("test"); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout"), + ); - // pin version - let config = Config { solc: Some("0.8.13".into()), ..Default::default() }; - prj.write_config(config); + // pin version + let config = Config { solc: Some("0.8.13".into()), ..Default::default() }; + prj.write_config(config); - cmd.unchecked_output() - .stdout_matches_path(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join( - "tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout", - )); - } -); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout"), + ); +}); // checks that we can test forge std successfully // `forgetest_init!` will install with `forge-std` under `lib/forge-std` forgetest_init!( #[serial_test::serial] can_test_forge_std, - |prj: TestProject, mut cmd: TestCommand| { + |prj, cmd| { let mut lock = template_lock(); let write = lock.write().unwrap(); let forge_std_dir = prj.root().join("lib/forge-std"); @@ -320,7 +314,7 @@ forgetest_init!( ); // tests that libraries are handled correctly in multiforking mode -forgetest_init!(can_use_libs_in_multi_fork, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(can_use_libs_in_multi_fork, |prj, cmd| { prj.wipe_contracts(); prj.inner() .add_source( @@ -392,7 +386,7 @@ contract FailingTest is Test { } "#; -forgetest_init!(exit_code_error_on_fail_fast, |prj: TestProject, mut cmd: TestCommand| { +forgetest_init!(exit_code_error_on_fail_fast, |prj, cmd| { prj.wipe_contracts(); prj.inner().add_source("failing_test", FAILING_TEST).unwrap(); @@ -403,16 +397,13 @@ forgetest_init!(exit_code_error_on_fail_fast, |prj: TestProject, mut cmd: TestCo cmd.assert_err(); }); -forgetest_init!( - exit_code_error_on_fail_fast_with_json, - |prj: TestProject, mut cmd: TestCommand| { - prj.wipe_contracts(); +forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { + prj.wipe_contracts(); - prj.inner().add_source("failing_test", FAILING_TEST).unwrap(); - // set up command - cmd.args(["test", "--fail-fast", "--json"]); + prj.inner().add_source("failing_test", FAILING_TEST).unwrap(); + // set up command + cmd.args(["test", "--fail-fast", "--json"]); - // run command and assert error exit code - cmd.assert_err(); - } -); + // run command and assert error exit code + cmd.assert_err(); +}); diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index bdd35d5914e65..33b58f7d823ba 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -121,11 +121,11 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te } // tests `create && contract-verify && verify-check` on Fantom testnet if correct env vars are set -forgetest!(can_verify_random_contract_fantom_testnet, |prj: TestProject, cmd: TestCommand| { +forgetest!(can_verify_random_contract_fantom_testnet, |prj, cmd| { verify_on_chain(EnvExternalities::ftm_testnet(), prj, cmd); }); // tests `create && contract-verify && verify-check` on Optimism kovan if correct env vars are set -forgetest!(can_verify_random_contract_optimism_kovan, |prj: TestProject, cmd: TestCommand| { +forgetest!(can_verify_random_contract_optimism_kovan, |prj, cmd| { verify_on_chain(EnvExternalities::optimism_kovan(), prj, cmd); }); diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 2aca55cd60a83..c0265c3d6c742 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -2,9 +2,10 @@ use crate::{ config::*, - test_helpers::{filter::Filter, PROJECT, RE_PATH_SEPARATOR}, + test_helpers::{PROJECT, RE_PATH_SEPARATOR}, }; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_test_utils::Filter; /// Executes all cheat code tests but not fork cheat codes #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 2cff6bb1281ba..8278210bcc1c0 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -1,8 +1,6 @@ //! Test setup -use crate::test_helpers::{ - filter::Filter, COMPILED, COMPILED_WITH_LIBS, EVM_OPTS, LIBS_PROJECT, PROJECT, -}; +use crate::test_helpers::{COMPILED, EVM_OPTS, PROJECT}; use forge::{ result::{SuiteResult, TestStatus}, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, @@ -14,6 +12,7 @@ use foundry_config::{ use foundry_evm::{ decode::decode_console_logs, inspectors::CheatsConfig, revm::primitives::SpecId, }; +use foundry_test_utils::Filter; use std::{ collections::BTreeMap, path::{Path, PathBuf}, @@ -201,7 +200,7 @@ pub async fn forked_runner(rpc: &str) -> MultiContractRunner { base_runner() .with_fork(fork) - .build(&LIBS_PROJECT.paths.root, (*COMPILED_WITH_LIBS).clone(), env, opts) + .build(&PROJECT.paths.root, (*COMPILED).clone(), env, opts) .unwrap() } diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 16aa8e5689b15..0c589e6eafb31 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -1,8 +1,9 @@ //! forge tests for core functionality -use crate::{config::*, test_helpers::filter::Filter}; +use crate::config::*; use forge::result::SuiteResult; use foundry_evm::traces::TraceKind; +use foundry_test_utils::Filter; use std::{collections::BTreeMap, env}; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 9d10e8a5def84..77e9691ef1e62 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -2,10 +2,11 @@ use crate::{ config::*, - test_helpers::{filter::Filter, PROJECT, RE_PATH_SEPARATOR}, + test_helpers::{PROJECT, RE_PATH_SEPARATOR}, }; use forge::result::SuiteResult; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_test_utils::Filter; /// Executes reverting fork test #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/tests/it/fs.rs b/crates/forge/tests/it/fs.rs index bb0c007450715..9ab7711eda3c7 100644 --- a/crates/forge/tests/it/fs.rs +++ b/crates/forge/tests/it/fs.rs @@ -1,10 +1,8 @@ //! Tests for reproducing issues -use crate::{ - config::*, - test_helpers::{filter::Filter, PROJECT}, -}; +use crate::{config::*, test_helpers::PROJECT}; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_fs_disabled() { diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 4d61ce0a706d9..5654cb070a811 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -1,8 +1,9 @@ //! Tests for invariants -use crate::{config::*, test_helpers::filter::Filter}; +use crate::config::*; use alloy_primitives::U256; use forge::result::{SuiteResult, TestStatus}; +use foundry_test_utils::Filter; use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index fb32da49c4351..5868df31d7861 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -1,12 +1,13 @@ use crate::{ config::runner, - test_helpers::{filter::Filter, COMPILED, PROJECT}, + test_helpers::{COMPILED, PROJECT}, }; use forge::{ result::{SuiteResult, TestKind, TestResult}, TestOptions, TestOptionsBuilder, }; use foundry_config::{FuzzConfig, InvariantConfig}; +use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 771a009d9f5fc..ab1424d0e8abd 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -1,8 +1,9 @@ //! Tests for invariants -use crate::{config::*, test_helpers::filter::Filter}; +use crate::config::*; use alloy_primitives::U256; use forge::fuzz::CounterExample; +use foundry_test_utils::Filter; use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/tests/it/main.rs b/crates/forge/tests/it/main.rs index f8197c99d42a5..48c0d66351ab7 100644 --- a/crates/forge/tests/it/main.rs +++ b/crates/forge/tests/it/main.rs @@ -1,5 +1,7 @@ -mod cheats; pub mod config; +pub mod test_helpers; + +mod cheats; mod core; mod fork; mod fs; @@ -8,4 +10,3 @@ mod inline; mod invariant; mod repros; mod spec; -pub mod test_helpers; diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 148a15a0a9f61..1cad2984c5ac7 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -1,13 +1,11 @@ //! Tests for reproducing issues -use crate::{ - config::*, - test_helpers::{filter::Filter, PROJECT}, -}; +use crate::{config::*, test_helpers::PROJECT}; use alloy_primitives::Address; use ethers::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; use forge::result::TestStatus; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_test_utils::Filter; use std::str::FromStr; /// A macro that tests a single pattern (".*/repros/") diff --git a/crates/forge/tests/it/spec.rs b/crates/forge/tests/it/spec.rs index 8afe3b57a69df..16ed249833096 100644 --- a/crates/forge/tests/it/spec.rs +++ b/crates/forge/tests/it/spec.rs @@ -1,5 +1,6 @@ -use crate::{config::*, test_helpers::filter::Filter}; +use crate::config::*; use foundry_evm::revm::primitives::SpecId; +use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_shanghai_compat() { diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 82d3da730f846..c280fcd996330 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -1,64 +1,37 @@ -#![allow(unused)] - -use super::*; -use alloy_primitives::{Address, U256}; +use alloy_primitives::U256; use foundry_compilers::{ artifacts::{Libraries, Settings}, Project, ProjectCompileOutput, ProjectPathsConfig, SolcConfig, }; use foundry_config::Config; use foundry_evm::{ - backend::Backend, constants::CALLER, - executors::{Executor, ExecutorBuilder, FuzzedExecutor}, + executors::{Executor, FuzzedExecutor}, opts::{Env, EvmOpts}, revm::db::DatabaseRef, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use once_cell::sync::Lazy; -use std::{ - path::{Path, PathBuf}, - str::FromStr, -}; + +pub const RE_PATH_SEPARATOR: &str = "/"; const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); +// const TESTDATA_LOCK: Lazy = Lazy::new(|| {}); pub static PROJECT: Lazy = Lazy::new(|| { let paths = ProjectPathsConfig::builder().root(TESTDATA).sources(TESTDATA).build().unwrap(); - Project::builder().paths(paths).ephemeral().no_artifacts().build().unwrap() -}); -pub static LIBS_PROJECT: Lazy = Lazy::new(|| { - let paths = ProjectPathsConfig::builder().root(TESTDATA).sources(TESTDATA).build().unwrap(); let libs = ["fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string()]; - let settings = Settings { libraries: Libraries::parse(&libs).unwrap(), ..Default::default() }; - let solc_config = SolcConfig::builder().settings(settings).build(); - Project::builder() - .paths(paths) - .ephemeral() - .no_artifacts() - .solc_config(solc_config) - .build() - .unwrap() -}); -pub static COMPILED: Lazy = Lazy::new(|| { - let out = (*PROJECT).compile().unwrap(); - if out.has_compiler_errors() { - eprintln!("{out}"); - panic!("Compiled with errors"); - } - out + Project::builder().paths(paths).solc_config(solc_config).build().unwrap() }); -pub static COMPILED_WITH_LIBS: Lazy = Lazy::new(|| { - let out = (*LIBS_PROJECT).compile().unwrap(); +pub static COMPILED: Lazy = Lazy::new(|| { + let out = PROJECT.compile().unwrap(); if out.has_compiler_errors() { - eprintln!("{out}"); - panic!("Compiled with errors"); + panic!("Compiled with errors:\n{out}"); } out }); @@ -86,98 +59,6 @@ pub fn fuzz_executor(executor: &Executor) -> FuzzedExecutor { executor, proptest::test_runner::TestRunner::new(cfg), CALLER, - config::test_opts().fuzz, + crate::config::test_opts().fuzz, ) } - -pub const RE_PATH_SEPARATOR: &str = "/"; - -pub mod filter { - use super::*; - use foundry_common::TestFilter; - use regex::Regex; - - pub struct Filter { - test_regex: Regex, - contract_regex: Regex, - path_regex: Regex, - exclude_tests: Option, - exclude_paths: Option, - } - - impl Filter { - pub fn new(test_pattern: &str, contract_pattern: &str, path_pattern: &str) -> Self { - Filter { - test_regex: Regex::new(test_pattern) - .unwrap_or_else(|_| panic!("Failed to parse test pattern: `{test_pattern}`")), - contract_regex: Regex::new(contract_pattern).unwrap_or_else(|_| { - panic!("Failed to parse contract pattern: `{contract_pattern}`") - }), - path_regex: Regex::new(path_pattern) - .unwrap_or_else(|_| panic!("Failed to parse path pattern: `{path_pattern}`")), - exclude_tests: None, - exclude_paths: None, - } - } - - pub fn contract(contract_pattern: &str) -> Self { - Self::new(".*", contract_pattern, ".*") - } - - pub fn path(path_pattern: &str) -> Self { - Self::new(".*", ".*", path_pattern) - } - - /// All tests to also exclude - /// - /// This is a workaround since regex does not support negative look aheads - pub fn exclude_tests(mut self, pattern: &str) -> Self { - self.exclude_tests = Some(Regex::new(pattern).unwrap()); - self - } - - /// All paths to also exclude - /// - /// This is a workaround since regex does not support negative look aheads - pub fn exclude_paths(mut self, pattern: &str) -> Self { - self.exclude_paths = Some(Regex::new(pattern).unwrap()); - self - } - - pub fn matches_all() -> Self { - Filter { - test_regex: Regex::new(".*").unwrap(), - contract_regex: Regex::new(".*").unwrap(), - path_regex: Regex::new(".*").unwrap(), - exclude_tests: None, - exclude_paths: None, - } - } - } - - impl TestFilter for Filter { - fn matches_test(&self, test_name: impl AsRef) -> bool { - let test_name = test_name.as_ref(); - if let Some(ref exclude) = self.exclude_tests { - if exclude.is_match(test_name) { - return false - } - } - self.test_regex.is_match(test_name) - } - - fn matches_contract(&self, contract_name: impl AsRef) -> bool { - self.contract_regex.is_match(contract_name.as_ref()) - } - - fn matches_path(&self, path: impl AsRef) -> bool { - let path = path.as_ref(); - if let Some(ref exclude) = self.exclude_paths { - if exclude.is_match(path) { - return false - } - } - self.path_regex.is_match(path) - } - } -} diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 256c2040ec0a6..4c282f86d9af8 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -22,16 +22,15 @@ alloy-primitives.workspace = true foundry-compilers = { workspace = true, features = ["project-util"] } eyre.workspace = true +fd-lock = "4.0.0" once_cell = "1" parking_lot = "0.12" pretty_assertions = "1" regex = "1" serde_json.workspace = true -tempfile = "3" -walkdir = "2" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } -fd-lock = "4.0.0" +walkdir = "2" [features] # feature for integration tests that test external projects diff --git a/crates/test-utils/src/filter.rs b/crates/test-utils/src/filter.rs new file mode 100644 index 0000000000000..c04eb2a39a6fd --- /dev/null +++ b/crates/test-utils/src/filter.rs @@ -0,0 +1,86 @@ +use foundry_common::TestFilter; +use regex::Regex; + +pub struct Filter { + test_regex: Regex, + contract_regex: Regex, + path_regex: Regex, + exclude_tests: Option, + exclude_paths: Option, +} + +impl Filter { + pub fn new(test_pattern: &str, contract_pattern: &str, path_pattern: &str) -> Self { + Filter { + test_regex: Regex::new(test_pattern) + .unwrap_or_else(|_| panic!("Failed to parse test pattern: `{test_pattern}`")), + contract_regex: Regex::new(contract_pattern).unwrap_or_else(|_| { + panic!("Failed to parse contract pattern: `{contract_pattern}`") + }), + path_regex: Regex::new(path_pattern) + .unwrap_or_else(|_| panic!("Failed to parse path pattern: `{path_pattern}`")), + exclude_tests: None, + exclude_paths: None, + } + } + + pub fn contract(contract_pattern: &str) -> Self { + Self::new(".*", contract_pattern, ".*") + } + + pub fn path(path_pattern: &str) -> Self { + Self::new(".*", ".*", path_pattern) + } + + /// All tests to also exclude + /// + /// This is a workaround since regex does not support negative look aheads + pub fn exclude_tests(mut self, pattern: &str) -> Self { + self.exclude_tests = Some(Regex::new(pattern).unwrap()); + self + } + + /// All paths to also exclude + /// + /// This is a workaround since regex does not support negative look aheads + pub fn exclude_paths(mut self, pattern: &str) -> Self { + self.exclude_paths = Some(Regex::new(pattern).unwrap()); + self + } + + pub fn matches_all() -> Self { + Filter { + test_regex: Regex::new(".*").unwrap(), + contract_regex: Regex::new(".*").unwrap(), + path_regex: Regex::new(".*").unwrap(), + exclude_tests: None, + exclude_paths: None, + } + } +} + +impl TestFilter for Filter { + fn matches_test(&self, test_name: impl AsRef) -> bool { + let test_name = test_name.as_ref(); + if let Some(ref exclude) = self.exclude_tests { + if exclude.is_match(test_name) { + return false + } + } + self.test_regex.is_match(test_name) + } + + fn matches_contract(&self, contract_name: impl AsRef) -> bool { + self.contract_regex.is_match(contract_name.as_ref()) + } + + fn matches_path(&self, path: impl AsRef) -> bool { + let path = path.as_ref(); + if let Some(ref exclude) = self.exclude_paths { + if exclude.is_match(path) { + return false + } + } + self.path_regex.is_match(path) + } +} diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index ee079ace7aa65..dc1f0986d7dc6 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(unused_crate_dependencies)] +#![warn(unused_crate_dependencies, unreachable_pub)] #[macro_use] extern crate tracing; @@ -6,16 +6,19 @@ extern crate tracing; // Macros useful for testing. mod macros; +mod filter; +pub use filter::Filter; + // Utilities for making it easier to handle tests. pub mod util; pub use util::{TestCommand, TestProject}; -pub mod script; +mod script; pub use script::{ScriptOutcome, ScriptTester}; // re-exports for convenience +pub use fd_lock; pub use foundry_compilers; -pub use tempfile; /// Initializes tracing for tests. pub fn init_tracing() { diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index cbdf838ace3f2..053741ac069a6 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -11,7 +11,7 @@ /// /// ```no_run /// use foundry_test_utils::*; -/// forgetest!(my_test, |prj: TestProject, mut cmd: TestCommand| { +/// forgetest!(my_test, |prj, cmd| { /// // adds `init` to forge's command arguments /// cmd.arg("init"); /// // executes forge and panics if the command failed or output is empty @@ -24,7 +24,7 @@ /// ```no_run /// use foundry_test_utils::*; /// use foundry_test_utils::foundry_compilers::PathStyle; -/// forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj: TestProject, mut cmd: TestCommand| { +/// forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj, cmd| { /// prj.assert_create_dirs_exists(); /// prj.assert_style_paths_exist(PathStyle::HardHat); /// cmd.arg("clean"); @@ -33,48 +33,45 @@ /// }); #[macro_export] macro_rules! forgetest { - ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::forgetest!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); + ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { + $crate::forgetest!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; - ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { + ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { #[test] - $(#[$meta])* + $(#[$attr])* fn $test() { - let (prj, cmd) = $crate::util::setup_forge(stringify!($test), $style); - let f = $fun; - f(prj, cmd); + let (mut $prj, mut $cmd) = $crate::util::setup_forge(stringify!($test), $style); + $e } }; } #[macro_export] macro_rules! forgetest_async { - ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::forgetest_async!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); + ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { + $crate::forgetest_async!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; - ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { + ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { #[tokio::test(flavor = "multi_thread")] - $(#[$meta])* + $(#[$attr])* async fn $test() { - let (prj, cmd) = $crate::util::setup_forge(stringify!($test), $style); - let f = $fun; - f(prj, cmd).await; + let (mut $prj, mut $cmd) = $crate::util::setup_forge(stringify!($test), $style); + $e } }; } #[macro_export] macro_rules! casttest { - ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::casttest!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); + ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { + $crate::casttest!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; - ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { + ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { #[test] - $(#[$meta])* + $(#[$attr])* fn $test() { - let (prj, cmd) = $crate::util::setup_cast(stringify!($test), $style); - let f = $fun; - f(prj, cmd); + let (mut $prj, mut $cmd) = $crate::util::setup_cast(stringify!($test), $style); + $e } }; } @@ -82,17 +79,16 @@ macro_rules! casttest { /// Same as `forgetest` but returns an already initialized project workspace (`forge init`) #[macro_export] macro_rules! forgetest_init { - ($(#[$meta:meta])* $test:ident, $fun:expr) => { - $crate::forgetest_init!($(#[$meta])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $fun); + ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { + $crate::forgetest_init!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; - ($(#[$meta:meta])* $test:ident, $style:expr, $fun:expr) => { + ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { #[test] - $(#[$meta])* + $(#[$attr])* fn $test() { - let (prj, cmd) = $crate::util::setup_forge(stringify!($test), $style); - $crate::util::initialize(prj.root()); - let f = $fun; - f(prj, cmd); + let (mut $prj, mut $cmd) = $crate::util::setup_forge(stringify!($test), $style); + $crate::util::initialize($prj.root()); + $e } }; } @@ -103,13 +99,13 @@ macro_rules! forgetest_init { #[macro_export] macro_rules! forgetest_external { // forgetest_external!(test_name, "owner/repo"); - ($(#[$meta:meta])* $test:ident, $repo:literal) => { - $crate::forgetest_external!($(#[$meta])* $test, $repo, 0, Vec::::new()); + ($(#[$attr:meta])* $test:ident, $repo:literal) => { + $crate::forgetest_external!($(#[$attr])* $test, $repo, 0, Vec::::new()); }; // forgetest_external!(test_name, "owner/repo", 1234); - ($(#[$meta:meta])* $test:ident, $repo:literal, $fork_block:literal) => { + ($(#[$attr:meta])* $test:ident, $repo:literal, $fork_block:literal) => { $crate::forgetest_external!( - $(#[$meta])* + $(#[$attr])* $test, $repo, $crate::foundry_compilers::PathStyle::Dapptools, @@ -118,13 +114,13 @@ macro_rules! forgetest_external { ); }; // forgetest_external!(test_name, "owner/repo", &["--extra-opt", "val"]); - ($(#[$meta:meta])* $test:ident, $repo:literal, $forge_opts:expr) => { - $crate::forgetest_external!($(#[$meta])* $test, $repo, 0, $forge_opts); + ($(#[$attr:meta])* $test:ident, $repo:literal, $forge_opts:expr) => { + $crate::forgetest_external!($(#[$attr])* $test, $repo, 0, $forge_opts); }; // forgetest_external!(test_name, "owner/repo", 1234, &["--extra-opt", "val"]); - ($(#[$meta:meta])* $test:ident, $repo:literal, $fork_block:literal, $forge_opts:expr) => { + ($(#[$attr:meta])* $test:ident, $repo:literal, $fork_block:literal, $forge_opts:expr) => { $crate::forgetest_external!( - $(#[$meta])* + $(#[$attr])* $test, $repo, $crate::foundry_compilers::PathStyle::Dapptools, @@ -133,9 +129,9 @@ macro_rules! forgetest_external { ); }; // forgetest_external!(test_name, "owner/repo", PathStyle::Dapptools, 123); - ($(#[$meta:meta])* $test:ident, $repo:literal, $style:expr, $fork_block:literal, $forge_opts:expr) => { + ($(#[$attr:meta])* $test:ident, $repo:literal, $style:expr, $fork_block:literal, $forge_opts:expr) => { #[test] - $(#[$meta])* + $(#[$attr])* fn $test() { use std::process::{Command, Stdio}; @@ -188,30 +184,3 @@ macro_rules! forgetest_external { } }; } - -/// A macro to compare outputs -#[macro_export] -macro_rules! pretty_eq { - ($expected:expr, $got:expr) => { - let expected = &*$expected; - let got = &*$got; - if expected != got { - panic!( - " -outputs differ! - -expected: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -{} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -got: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -{} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -", - expected, got - ); - } - }; -} diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 598746f612220..9c39fd2e6ae55 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -6,7 +6,7 @@ use foundry_common::{get_http_provider, RetryProvider}; use foundry_utils::types::{ToAlloy, ToEthers}; use std::{collections::BTreeMap, path::Path, str::FromStr}; -pub const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; +const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; /// A helper struct to test forge script scenarios pub struct ScriptTester { diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index b10d7fd82677e..7b784e2e0142d 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -4,7 +4,7 @@ use fd_lock::RwLock; use foundry_compilers::{ cache::SolFilesCache, project_util::{copy_dir, TempProject}, - ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, Solc, + ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, }; use foundry_config::Config; use once_cell::sync::Lazy; @@ -27,13 +27,6 @@ use std::{ static CURRENT_DIR_LOCK: Lazy> = Lazy::new(|| Mutex::new(())); -/// A lock used for pre-installing commonly used solc versions once. -/// Pre-installing is useful, because if two forge test require a missing solc at the same time, one -/// can encounter an OS error 26 textfile busy if it tries to write the freshly downloaded solc to -/// the right location while the other test already did that and is currently executing this solc -/// binary. -static PRE_INSTALL_SOLC_LOCK: Lazy> = Lazy::new(|| Mutex::new(false)); - // This stores `true` if the current terminal is a tty pub static IS_TTY: Lazy = Lazy::new(|| std::io::stdout().is_terminal()); @@ -111,10 +104,6 @@ pub fn setup_forge(name: &str, style: PathStyle) -> (TestProject, TestCommand) { } pub fn setup_forge_project(test: TestProject) -> (TestProject, TestCommand) { - // preinstall commonly used solc once, we execute this here because this is the shared - // entrypoint used by all `forgetest!` macros - install_commonly_used_solc(); - let cmd = test.forge_command(); (test, cmd) } @@ -219,31 +208,6 @@ pub fn setup_cast_project(test: TestProject) -> (TestProject, TestCommand) { (test, cmd) } -/// pre-installs commonly used solc versions -fn install_commonly_used_solc() { - let mut is_preinstalled = PRE_INSTALL_SOLC_LOCK.lock(); - if !*is_preinstalled { - let v0_8_19 = std::thread::spawn(|| Solc::blocking_install(&"0.8.19".parse().unwrap())); - let v0_8_20 = std::thread::spawn(|| Solc::blocking_install(&"0.8.20".parse().unwrap())); - let v0_8_21 = std::thread::spawn(|| Solc::blocking_install(&"0.8.21".parse().unwrap())); - - let wait = |res: std::thread::JoinHandle<_>| -> Result<(), ()> { - if let Err(err) = res.join().unwrap() { - eprintln!("{err:?}"); - // there could be another process that's currently installing this version, so we - // sleep here for a bit and assume the other process will be finished then - std::thread::sleep(std::time::Duration::from_secs(15)); - Err(()) - } else { - Ok(()) - } - }; - - // only set to installed if succeeded - *is_preinstalled = wait(v0_8_19).and(wait(v0_8_20)).and(wait(v0_8_21)).is_ok(); - } -} - /// `TestProject` represents a temporary project to run tests against. /// /// Test projects are created from a global atomic counter to avoid duplicates. diff --git a/testdata/fs/Default.t.sol b/testdata/fs/Default.t.sol index 6d83914447987..a37f479e30937 100644 --- a/testdata/fs/Default.t.sol +++ b/testdata/fs/Default.t.sol @@ -7,9 +7,6 @@ import "../cheats/Vm.sol"; contract DefaultAccessTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - bytes constant FOUNDRY_WRITE_ERR = - "the path fixtures/File/write_file.txt is not allowed to be accessed for write operations"; - function testReadFile() public { string memory path = "fixtures/File/read.txt"; vm.readFile(path); @@ -26,10 +23,10 @@ contract DefaultAccessTest is DSTest { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm.expectRevert(); vm.writeFile(path, data); - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm.expectRevert(); vm.writeFileBinary(path, bytes(data)); } @@ -37,14 +34,14 @@ contract DefaultAccessTest is DSTest { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm.expectRevert(); vm.writeLine(path, data); } function testRemoveFile() public { string memory path = "fixtures/File/write_file.txt"; - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm.expectRevert(); vm.removeFile(path); } } diff --git a/testdata/fs/Disabled.t.sol b/testdata/fs/Disabled.t.sol index e5ffbbe82190a..7c13c06d222bd 100644 --- a/testdata/fs/Disabled.t.sol +++ b/testdata/fs/Disabled.t.sol @@ -7,40 +7,35 @@ import "../cheats/Vm.sol"; contract DisabledTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - bytes constant FOUNDRY_READ_ERR = - "the path fixtures/File/read.txt is not allowed to be accessed for read operations"; - bytes constant FOUNDRY_WRITE_ERR = - "the path fixtures/File/write_file.txt is not allowed to be accessed for write operations"; - function testReadFile() public { string memory path = "fixtures/File/read.txt"; - vm.expectRevert(FOUNDRY_READ_ERR); + vm.expectRevert(); vm.readFile(path); } function testReadLine() public { string memory path = "fixtures/File/read.txt"; - vm.expectRevert(FOUNDRY_READ_ERR); + vm.expectRevert(); vm.readLine(path); } function testWriteFile() public { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm.expectRevert(); vm.writeFile(path, data); } function testWriteLine() public { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm.expectRevert(); vm.writeLine(path, data); } function testRemoveFile() public { string memory path = "fixtures/File/write_file.txt"; - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm.expectRevert(); vm.removeFile(path); } } From a5040df7b7073545a8ed8ee19e6f0d22f6ccd055 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 8 Nov 2023 17:50:28 -0400 Subject: [PATCH 0249/1963] feat(`cheatcodes`): mark rpc + eth_getLogs cheatcodes as script safe (#6255) * feat: mark *Fork + rpc + eth_getLogs cheatcodes as safe * fix: mark other *fork cheatcodes unsafe * chore: regen json --- crates/cheatcodes/assets/cheatcodes.json | 4 ++-- crates/cheatcodes/defs/src/vm.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 3b55e49c4901b..b680e876d01d1 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -1483,7 +1483,7 @@ }, "group": "evm", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { @@ -3423,7 +3423,7 @@ }, "group": "evm", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { diff --git a/crates/cheatcodes/defs/src/vm.rs b/crates/cheatcodes/defs/src/vm.rs index 2061dac26d2aa..946de24c24707 100644 --- a/crates/cheatcodes/defs/src/vm.rs +++ b/crates/cheatcodes/defs/src/vm.rs @@ -383,11 +383,11 @@ interface Vm { function transact(uint256 forkId, bytes32 txHash) external; /// Performs an Ethereum JSON-RPC request to the current fork URL. - #[cheatcode(group = Evm, safety = Unsafe)] + #[cheatcode(group = Evm, safety = Safe)] function rpc(string calldata method, string calldata params) external returns (bytes memory data); /// Gets all the logs according to specified filter. - #[cheatcode(group = Evm, safety = Unsafe)] + #[cheatcode(group = Evm, safety = Safe)] function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics) external returns (EthGetLogs[] memory logs); From 1a91bbbe4ec4b400c7c8fb581bdf83e896a0fed3 Mon Sep 17 00:00:00 2001 From: danilo neves cruz Date: Wed, 8 Nov 2023 18:58:35 -0300 Subject: [PATCH 0250/1963] =?UTF-8?q?=F0=9F=9A=B8=20script:=20ignore=20int?= =?UTF-8?q?erfaces=20when=20inferring=20target=20(#6246)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge/bin/cmd/script/build.rs | 5 ++++- crates/forge/tests/cli/script.rs | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 32a4e97af96a9..58fe6eb71d4af 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -151,7 +151,10 @@ impl ScriptArgs { // if it's the target contract, grab the info if extra.no_target_name { - if id.source == std::path::PathBuf::from(&extra.target_fname) { + // Match artifact source, and ignore interfaces + if id.source == std::path::Path::new(&extra.target_fname) && + contract.bytecode.as_ref().map_or(false, |b| b.object.bytes_len() > 0) + { if extra.matched { eyre::bail!("Multiple contracts in the target path. Please specify the contract name with `--tc ContractName`") } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index be8b548a68790..146bf4ca7d701 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1108,3 +1108,24 @@ contract NestedCreateFail is Script { cmd.arg("script").arg(script).args(["--tc", "NestedCreateFail"]); assert!(cmd.stdout_lossy().contains("Script ran successfully.")); }); + +forgetest_async!(assert_can_detect_target_contract_with_interfaces, |prj, cmd| { + let script = prj + .inner() + .add_script( + "ScriptWithInterface.s.sol", + r#" +pragma solidity ^0.8.22; + +contract Script { + function run() external {} +} + +interface Interface {} + "#, + ) + .unwrap(); + + cmd.arg("script").arg(script); + assert!(cmd.stdout_lossy().contains("Script ran successfully.")); +}); From 6447f9618b4769c61f061af5338e3e455d9f0ec1 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 8 Nov 2023 19:31:35 -0400 Subject: [PATCH 0251/1963] fix: increase timeout for heavy integration test (#6258) --- .config/nextest.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/nextest.toml b/.config/nextest.toml index 2b5a17d0d7897..4629c63f29c3f 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -8,3 +8,4 @@ slow-timeout = { period = "5m", terminate-after = 4 } [profile.heavy] retries = 1 +slow-timeout = { period = "120m", terminate-after = 1} \ No newline at end of file From 57180fc6ddc71c26c71ad336cf1a0f0961dae28f Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 8 Nov 2023 21:18:04 -0400 Subject: [PATCH 0252/1963] feat: update solidity 0.8.23 test (#6259) * chore: 0.8.23 * chore: update svm --- Cargo.lock | 4 ++-- crates/forge/tests/cli/svm.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 166bcbde68d6f..4d8c7f777bc12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6762,9 +6762,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "svm-rs" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0cc95be7cc2c384a2f57cac56548d2178650905ebe5725bc8970ccc25529060" +checksum = "20689c7d03b6461b502d0b95d6c24874c7d24dea2688af80486a130a06af3b07" dependencies = [ "dirs 5.0.1", "fs2", diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 00e7476eaa405..71ec37aeafc87 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -10,7 +10,7 @@ use svm::Platform; /// 2. svm updated with all build info /// 3. svm bumped in ethers-rs /// 4. ethers bumped in foundry + update the `LATEST_SOLC` -const LATEST_SOLC: Version = Version::new(0, 8, 22); +const LATEST_SOLC: Version = Version::new(0, 8, 23); macro_rules! ensure_svm_releases { ($($test:ident => $platform:ident),* $(,)?) => {$( From 9194d869a243a94c0189d0526ef8a4314c62b00c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:12:56 +0100 Subject: [PATCH 0253/1963] fix: precompile trace decoding (#6263) * fix: precompile trace decoding * refactor: move decoding to decoder module * renames * renames2 * stuff * chore: clippy * move decoding out of utils * move cheatcode decoding * fix: empty decode --- crates/anvil/src/eth/backend/executor.rs | 2 +- crates/evm/traces/src/decoder/mod.rs | 334 +++++++++++++----- crates/evm/traces/src/decoder/precompiles.rs | 5 +- .../evm/traces/src/identifier/signatures.rs | 2 +- crates/evm/traces/src/inspector.rs | 8 +- crates/evm/traces/src/lib.rs | 65 ++-- crates/evm/traces/src/node.rs | 126 +------ crates/evm/traces/src/utils.rs | 103 +----- crates/forge/bin/cmd/script/transaction.rs | 6 +- 9 files changed, 282 insertions(+), 369 deletions(-) diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 17d681e084c3d..e388598489e72 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -24,7 +24,7 @@ use foundry_evm::{ interpreter::InstructionResult, primitives::{BlockEnv, CfgEnv, EVMError, Env, ExecutionResult, Output, SpecId}, }, - traces::{node::CallTraceNode, CallTraceArena}, + traces::{CallTraceArena, CallTraceNode}, utils::{eval_to_instruction_result, halt_to_instruction_result}, }; use foundry_utils::types::{ToAlloy, ToEthers}; diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 7430d51275c13..617fc48b5a247 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -1,12 +1,11 @@ use crate::{ identifier::{AddressIdentity, SingleSignaturesIdentifier, TraceIdentifier}, - node::CallTraceNode, - utils, CallTraceArena, RawOrDecodedLog, TraceCallData, TraceRetData, + utils, CallTrace, CallTraceArena, TraceCallData, TraceLog, TraceRetData, }; -use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; +use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function, JsonAbi as Abi}; use alloy_primitives::{Address, Selector, B256}; -use foundry_common::{abi::get_indexed_event, SELECTOR_LEN}; +use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ abi::{CONSOLE_ABI, HARDHAT_CONSOLE_ABI, HEVM_ABI}, constants::{ @@ -16,8 +15,9 @@ use foundry_evm_core::{ decode, }; use foundry_utils::types::ToAlloy; +use itertools::Itertools; use once_cell::sync::OnceCell; -use std::collections::{BTreeMap, HashMap}; +use std::collections::{hash_map::Entry, BTreeMap, HashMap}; mod precompiles; @@ -89,15 +89,15 @@ pub struct CallTraceDecoder { /// /// The values are in the form `":"`. pub contracts: HashMap, - /// Address labels + /// Address labels. pub labels: HashMap, - /// Information whether the contract address has a receive function - pub receive_contracts: HashMap, - /// A mapping of signatures to their known functions - pub functions: BTreeMap>, - /// All known events + /// Contract addresses that have a receive function. + pub receive_contracts: Vec

, + /// All known functions. + pub functions: HashMap>, + /// All known events. pub events: BTreeMap<(B256, usize), Vec>, - /// All known errors + /// All known errors. pub errors: Abi, /// A signature identifier for events and functions. pub signature_identifier: Option, @@ -187,7 +187,16 @@ impl CallTraceDecoder { if let Some(abi) = &identity.abi { // Store known functions for the address for function in abi.functions() { - self.functions.entry(function.selector()).or_default().push(function.clone()) + match self.functions.entry(function.selector()) { + Entry::Occupied(entry) => { + // This shouldn't happen that often + debug!(target: "evm::traces", selector=%entry.key(), old=?entry.get(), new=?function, "Duplicate function"); + entry.into_mut().push(function.clone()); + } + Entry::Vacant(entry) => { + entry.insert(vec![function.clone()]); + } + } } // Flatten events from all ABIs @@ -201,7 +210,9 @@ impl CallTraceDecoder { self.errors.errors.entry(error.name.clone()).or_default().push(error.clone()); } - self.receive_contracts.entry(address).or_insert(abi.receive.is_some()); + if abi.receive.is_some() { + self.receive_contracts.push(address); + } } } } @@ -209,115 +220,250 @@ impl CallTraceDecoder { /// Decodes all nodes in the specified call trace. pub async fn decode(&self, traces: &mut CallTraceArena) { for node in &mut traces.arena { - // Set contract name - if let Some(contract) = self.contracts.get(&node.trace.address) { - node.trace.contract = Some(contract.clone()); + self.decode_function(&mut node.trace).await; + for log in node.logs.iter_mut() { + self.decode_event(log).await; } + } + } - // Set label - if let Some(label) = self.labels.get(&node.trace.address) { - node.trace.label = Some(label.clone()); - } + async fn decode_function(&self, trace: &mut CallTrace) { + // Decode precompile + if precompiles::decode(trace, 1) { + return + } - // Decode events - self.decode_events(node).await; + // Set label + if trace.label.is_none() { + if let Some(label) = self.labels.get(&trace.address) { + trace.label = Some(label.clone()); + } + } - // Decode call - // TODO: chain ID argument - if precompiles::decode(&mut node.trace, 1) { - return + // Set contract name + if trace.contract.is_none() { + if let Some(contract) = self.contracts.get(&trace.address) { + trace.contract = Some(contract.clone()); } + } - if let TraceCallData::Raw(bytes) = &node.trace.data { - if bytes.len() >= SELECTOR_LEN { - if let Some(funcs) = self.functions.get(&bytes[..SELECTOR_LEN]) { - node.decode_function(funcs, &self.labels, &self.errors, self.verbosity); - } else if node.trace.address == DEFAULT_CREATE2_DEPLOYER { - node.trace.data = TraceCallData::Decoded { - signature: "create2".to_string(), - args: vec![], - }; - } else if let Some(identifier) = &self.signature_identifier { + let TraceCallData::Raw(cdata) = &trace.data else { return }; + + if trace.address == DEFAULT_CREATE2_DEPLOYER { + trace.data = TraceCallData::Decoded { signature: "create2".to_string(), args: vec![] }; + return + } + + if cdata.len() >= SELECTOR_LEN { + let selector = &cdata[..SELECTOR_LEN]; + let mut functions = Vec::new(); + let functions = match self.functions.get(selector) { + Some(fs) => fs, + None => { + if let Some(identifier) = &self.signature_identifier { if let Some(function) = - identifier.write().await.identify_function(&bytes[..SELECTOR_LEN]).await + identifier.write().await.identify_function(selector).await { - node.decode_function( - &[function], - &self.labels, - &self.errors, - self.verbosity, - ); - } - } - } else { - let has_receive = - self.receive_contracts.get(&node.trace.address).copied().unwrap_or(false); - let signature = - if bytes.is_empty() && has_receive { "receive()" } else { "fallback()" } - .into(); - node.trace.data = TraceCallData::Decoded { signature, args: Vec::new() }; - - if let TraceRetData::Raw(bytes) = &node.trace.output { - if !node.trace.success { - node.trace.output = TraceRetData::Decoded(decode::decode_revert( - bytes, - Some(&self.errors), - Some(node.trace.status), - )); + functions.push(function); } } + &functions + } + }; + let [func, ..] = &functions[..] else { return }; + self.decode_function_input(trace, func); + self.decode_function_output(trace, functions); + } else { + let has_receive = self.receive_contracts.contains(&trace.address); + let signature = + if cdata.is_empty() && has_receive { "receive()" } else { "fallback()" }.into(); + let args = if cdata.is_empty() { Vec::new() } else { vec![cdata.to_string()] }; + trace.data = TraceCallData::Decoded { signature, args }; + + if let TraceRetData::Raw(rdata) = &trace.output { + if !trace.success { + trace.output = TraceRetData::Decoded(decode::decode_revert( + rdata, + Some(&self.errors), + Some(trace.status), + )); } } } } - async fn decode_events(&self, node: &mut CallTraceNode) { - for log in node.logs.iter_mut() { - self.decode_event(log).await; + /// Decodes a function's input into the given trace. + fn decode_function_input(&self, trace: &mut CallTrace, func: &Function) { + let TraceCallData::Raw(data) = &trace.data else { return }; + let mut args = None; + if data.len() >= SELECTOR_LEN { + if trace.address == CHEATCODE_ADDRESS { + // Try to decode cheatcode inputs in a more custom way + if let Some(v) = self.decode_cheatcode_inputs(func, data) { + args = Some(v); + } + } + + if args.is_none() { + if let Ok(v) = func.abi_decode_input(&data[SELECTOR_LEN..], false) { + args = Some(v.iter().map(|value| self.apply_label(value)).collect()); + } + } } + trace.data = + TraceCallData::Decoded { signature: func.signature(), args: args.unwrap_or_default() }; } - async fn decode_event(&self, log: &mut RawOrDecodedLog) { - if let RawOrDecodedLog::Raw(raw_log) = log { - // do not attempt decoding if no topics - if raw_log.topics().is_empty() { - return + /// Custom decoding for cheatcode inputs. + fn decode_cheatcode_inputs(&self, func: &Function, data: &[u8]) -> Option> { + match func.name.as_str() { + "expectRevert" => Some(vec![decode::decode_revert(data, Some(&self.errors), None)]), + "rememberKey" | "addr" | "startBroadcast" | "broadcast" => { + // these functions accept a private key as uint256, which should not be + // converted to plain text + if !func.inputs.is_empty() && func.inputs[0].ty != "uint256" { + // redact private key input + Some(vec!["".to_string()]) + } else { + None + } + } + "sign" => { + // sign(uint256,bytes32) + let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; + if !decoded.is_empty() && func.inputs[0].ty != "uint256" { + decoded[0] = DynSolValue::String("".to_string()); + } + Some(decoded.iter().map(format_token).collect()) + } + "deriveKey" => Some(vec!["".to_string()]), + "parseJson" | + "parseJsonUint" | + "parseJsonUintArray" | + "parseJsonInt" | + "parseJsonIntArray" | + "parseJsonString" | + "parseJsonStringArray" | + "parseJsonAddress" | + "parseJsonAddressArray" | + "parseJsonBool" | + "parseJsonBoolArray" | + "parseJsonBytes" | + "parseJsonBytesArray" | + "parseJsonBytes32" | + "parseJsonBytes32Array" | + "writeJson" | + "keyExists" | + "serializeBool" | + "serializeUint" | + "serializeInt" | + "serializeAddress" | + "serializeBytes32" | + "serializeString" | + "serializeBytes" => { + if self.verbosity >= 5 { + None + } else { + let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; + let token = + if func.name.as_str() == "parseJson" || func.name.as_str() == "keyExists" { + "" + } else { + "" + }; + decoded[0] = DynSolValue::String(token.to_string()); + Some(decoded.iter().map(format_token).collect()) + } } + _ => None, + } + } - let mut events = vec![]; - if let Some(evs) = self.events.get(&(raw_log.topics()[0], raw_log.topics().len() - 1)) { - events = evs.clone(); - } else if let Some(identifier) = &self.signature_identifier { - if let Some(event) = - identifier.write().await.identify_event(&raw_log.topics()[0].0).await + /// Decodes a function's output into the given trace. + fn decode_function_output(&self, trace: &mut CallTrace, funcs: &[Function]) { + let TraceRetData::Raw(data) = &trace.output else { return }; + if trace.success { + if trace.address == CHEATCODE_ADDRESS { + if let Some(decoded) = + funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)) { - events.push(get_indexed_event(event, raw_log)); + trace.output = TraceRetData::Decoded(decoded); + return } } - for event in events { - if let Ok(decoded) = event.decode_log(raw_log, false) { - let params = reconstruct_params(&event, &decoded); - *log = RawOrDecodedLog::Decoded( - event.name, - params - .into_iter() - .zip(event.inputs.iter()) - .map(|(param, input)| { - // undo patched names - let name = input.name.clone(); - (name, self.apply_label(¶m)) - }) - .collect(), - ); - break + if let Some(values) = + funcs.iter().find_map(|func| func.abi_decode_output(data, false).ok()) + { + // Functions coming from an external database do not have any outputs specified, + // and will lead to returning an empty list of values. + if values.is_empty() { + return } + trace.output = TraceRetData::Decoded( + values.iter().map(|value| self.apply_label(value)).format(", ").to_string(), + ); + } + } else { + trace.output = TraceRetData::Decoded(decode::decode_revert( + data, + Some(&self.errors), + Some(trace.status), + )); + } + } + + /// Custom decoding for cheatcode outputs. + fn decode_cheatcode_outputs(&self, func: &Function) -> Option { + match func.name.as_str() { + s if s.starts_with("env") => Some(""), + "deriveKey" => Some(""), + "parseJson" if self.verbosity < 5 => Some(""), + "readFile" if self.verbosity < 5 => Some(""), + _ => None, + } + .map(Into::into) + } + + /// Decodes an event. + async fn decode_event(&self, log: &mut TraceLog) { + let TraceLog::Raw(raw_log) = log else { return }; + let &[t0, ..] = raw_log.topics() else { return }; + + let mut events = Vec::new(); + let events = match self.events.get(&(t0, raw_log.topics().len())) { + Some(es) => es, + None => { + if let Some(identifier) = &self.signature_identifier { + if let Some(event) = identifier.write().await.identify_event(&t0[..]).await { + events.push(get_indexed_event(event, raw_log)); + } + } + &events + } + }; + for event in events { + if let Ok(decoded) = event.decode_log(raw_log, false) { + let params = reconstruct_params(event, &decoded); + *log = TraceLog::Decoded( + event.name.clone(), + params + .into_iter() + .zip(event.inputs.iter()) + .map(|(param, input)| { + // undo patched names + let name = input.name.clone(); + (name, self.apply_label(¶m)) + }) + .collect(), + ); + break } } } - fn apply_label(&self, token: &DynSolValue) -> String { - utils::label(token, &self.labels) + fn apply_label(&self, value: &DynSolValue) -> String { + utils::label(value, &self.labels) } } diff --git a/crates/evm/traces/src/decoder/precompiles.rs b/crates/evm/traces/src/decoder/precompiles.rs index 90e19a98cc503..a1b3f94250343 100644 --- a/crates/evm/traces/src/decoder/precompiles.rs +++ b/crates/evm/traces/src/decoder/precompiles.rs @@ -71,14 +71,13 @@ pub(super) fn decode(trace: &mut CallTrace, _chain_id: u64) -> bool { 0x08 => (ecpairingCall::SIGNATURE, tri!(decode_ecpairing(data))), 0x09 => (blake2fCall::SIGNATURE, tri!(decode_blake2f(data))), 0x0a => (pointEvaluationCall::SIGNATURE, tri!(decode_kzg(data))), - _ => unreachable!(), + 0x00 | 0x0b.. => unreachable!(), }; // TODO: Other chain precompiles trace.data = TraceCallData::Decoded { signature: signature.to_string(), args }; - - trace.contract = Some("PRECOMPILES".into()); + trace.label = Some("PRECOMPILES".into()); true } diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 5b5014af021cc..0364133b9760c 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -96,7 +96,7 @@ impl SignaturesIdentifier { &mut self, selector_type: SelectorType, identifier: &[u8], - get_type: fn(&str) -> eyre::Result, + get_type: impl Fn(&str) -> eyre::Result, ) -> Option { // Exit early if we have unsuccessfully queried it before. if self.unavailable.contains(identifier) { diff --git a/crates/evm/traces/src/inspector.rs b/crates/evm/traces/src/inspector.rs index cb7e24f9658c5..80b34f0f14d31 100644 --- a/crates/evm/traces/src/inspector.rs +++ b/crates/evm/traces/src/inspector.rs @@ -1,6 +1,5 @@ use crate::{ - CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, RawOrDecodedLog, TraceCallData, - TraceRetData, + CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, TraceCallData, TraceLog, TraceRetData, }; use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; use foundry_evm_core::{ @@ -162,9 +161,8 @@ impl Inspector for Tracer { let node = &mut self.traces.arena[*self.trace_stack.last().expect("no ongoing trace")]; node.ordering.push(LogCallOrder::Log(node.logs.len())); let data = data.clone(); - node.logs.push(RawOrDecodedLog::Raw( - RawLog::new(topics.to_vec(), data).expect("Received invalid log"), - )); + node.logs + .push(TraceLog::Raw(RawLog::new(topics.to_vec(), data).expect("Received invalid log"))); } #[inline] diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 87c4dea2fcf5d..a1fcd52fc1f3a 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -14,12 +14,11 @@ use foundry_evm_core::{constants::CHEATCODE_ADDRESS, debug::Instruction, utils:: use foundry_utils::types::ToEthers; use hashbrown::HashMap; use itertools::Itertools; -use node::CallTraceNode; use revm::interpreter::{opcode, CallContext, InstructionResult, Memory, Stack}; use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashSet}, - fmt::{self, Write}, + fmt, }; use yansi::{Color, Paint}; @@ -35,7 +34,9 @@ pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; mod inspector; pub use inspector::Tracer; -pub mod node; +mod node; +pub use node::CallTraceNode; + pub mod utils; pub type Traces = Vec<(TraceKind, CallTraceArena)>; @@ -198,20 +199,16 @@ impl fmt::Display for CallTraceArena { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn inner( arena: &CallTraceArena, - writer: &mut (impl Write + ?Sized), + f: &mut fmt::Formatter<'_>, idx: usize, left: &str, child: &str, - verbose: bool, ) -> fmt::Result { let node = &arena.arena[idx]; // Display trace header - if !verbose { - writeln!(writer, "{left}{}", node.trace)?; - } else { - writeln!(writer, "{left}{:#}", node.trace)?; - } + f.write_str(left)?; + node.trace.fmt(f)?; // Display logs and subcalls let left_prefix = format!("{child}{BRANCH}"); @@ -219,13 +216,11 @@ impl fmt::Display for CallTraceArena { for child in &node.ordering { match child { LogCallOrder::Log(index) => { - let mut log = String::new(); - write!(log, "{}", node.logs[*index])?; - + let log = node.logs[*index].to_string(); // Prepend our tree structure symbols to each line of the displayed log log.lines().enumerate().try_for_each(|(i, line)| { writeln!( - writer, + f, "{}{}", if i == 0 { &left_prefix } else { &right_prefix }, line @@ -233,44 +228,37 @@ impl fmt::Display for CallTraceArena { })?; } LogCallOrder::Call(index) => { - inner( - arena, - writer, - node.children[*index], - &left_prefix, - &right_prefix, - verbose, - )?; + inner(arena, f, node.children[*index], &left_prefix, &right_prefix)?; } } } // Display trace return data let color = trace_color(&node.trace); - write!(writer, "{child}{EDGE}{}", color.paint(RETURN))?; + write!(f, "{child}{EDGE}{}", color.paint(RETURN))?; if node.trace.created() { match &node.trace.output { TraceRetData::Raw(bytes) => { - writeln!(writer, "{} bytes of code", bytes.len())?; + writeln!(f, "{} bytes of code", bytes.len())?; } TraceRetData::Decoded(val) => { - writeln!(writer, "{val}")?; + writeln!(f, "{val}")?; } } } else { - writeln!(writer, "{}", node.trace.output)?; + writeln!(f, "{}", node.trace.output)?; } Ok(()) } - inner(self, f, 0, " ", " ", f.alternate()) + inner(self, f, 0, " ", " ") } } /// A raw or decoded log. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum RawOrDecodedLog { +pub enum TraceLog { /// A raw log Raw(RawLog), /// A decoded log. @@ -280,10 +268,10 @@ pub enum RawOrDecodedLog { Decoded(String, Vec<(String, String)>), } -impl fmt::Display for RawOrDecodedLog { +impl fmt::Display for TraceLog { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - RawOrDecodedLog::Raw(log) => { + TraceLog::Raw(log) => { for (i, topic) in log.topics().iter().enumerate() { writeln!( f, @@ -295,7 +283,7 @@ impl fmt::Display for RawOrDecodedLog { write!(f, " data: {}", Paint::cyan(hex::encode_prefixed(&log.data))) } - RawOrDecodedLog::Decoded(name, params) => { + TraceLog::Decoded(name, params) => { let params = params .iter() .map(|(name, value)| format!("{name}: {value}")) @@ -484,8 +472,6 @@ pub struct CallTrace { pub steps: Vec, } -// === impl CallTrace === - impl CallTrace { /// Whether this is a contract creation or not pub fn created(&self) -> bool { @@ -516,8 +502,8 @@ impl Default for CallTrace { impl fmt::Display for CallTrace { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let address = self.address.to_checksum(None); write!(f, "[{}] ", self.gas_cost)?; + let address = self.address.to_checksum(None); if self.created() { write!( f, @@ -530,10 +516,13 @@ impl fmt::Display for CallTrace { } else { let (func_name, inputs) = match &self.data { TraceCallData::Raw(bytes) => { - // We assume that the fallback function (`data.len() < 4`) counts as decoded - // calldata - let (selector, data) = bytes.split_at(4); - (hex::encode(selector), hex::encode(data)) + debug!(target: "evm::traces", trace=?self, "unhandled raw calldata"); + if bytes.len() < 4 { + ("fallback".into(), hex::encode(bytes)) + } else { + let (selector, data) = bytes.split_at(4); + (hex::encode(selector), hex::encode(data)) + } } TraceCallData::Decoded { signature, args } => { let name = signature.split('(').next().unwrap(); diff --git a/crates/evm/traces/src/node.rs b/crates/evm/traces/src/node.rs index 20d21d73dec4e..9bd89ada88c6a 100644 --- a/crates/evm/traces/src/node.rs +++ b/crates/evm/traces/src/node.rs @@ -1,17 +1,9 @@ -use crate::{ - utils, utils::decode_cheatcode_outputs, CallTrace, LogCallOrder, RawOrDecodedLog, - TraceCallData, TraceRetData, -}; -use alloy_dyn_abi::{FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Function, JsonAbi as Abi}; -use alloy_primitives::Address; +use crate::{CallTrace, LogCallOrder, TraceLog}; use ethers::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; -use foundry_common::SELECTOR_LEN; -use foundry_evm_core::{constants::CHEATCODE_ADDRESS, decode, utils::CallKind}; +use foundry_evm_core::utils::CallKind; use foundry_utils::types::ToEthers; use revm::interpreter::InstructionResult; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; /// A node in the arena #[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -26,7 +18,7 @@ pub struct CallTraceNode { pub trace: CallTrace, /// Logs #[serde(skip)] - pub logs: Vec, + pub logs: Vec, /// Ordering of child calls and logs pub ordering: Vec, } @@ -88,116 +80,4 @@ impl CallTraceNode { }), } } - - /// Decode a regular function - pub fn decode_function( - &mut self, - funcs: &[Function], - labels: &HashMap, - errors: &Abi, - verbosity: u8, - ) { - debug_assert!(!funcs.is_empty(), "requires at least 1 func"); - // This is safe because (1) we would not have an entry for the given - // selector if no functions with that selector were added and (2) the - // same selector implies the function has - // the same name and inputs. - let func = &funcs[0]; - - if let TraceCallData::Raw(ref bytes) = self.trace.data { - let args = if bytes.len() >= SELECTOR_LEN { - if self.trace.address == CHEATCODE_ADDRESS { - // Try to decode cheatcode inputs in a more custom way - utils::decode_cheatcode_inputs(func, bytes, errors, verbosity).unwrap_or_else( - || { - func.abi_decode_input(&bytes[SELECTOR_LEN..], false) - .expect("bad function input decode") - .iter() - .map(|token| utils::label(token, labels)) - .collect() - }, - ) - } else { - match func.abi_decode_input(&bytes[SELECTOR_LEN..], false) { - Ok(v) => v.iter().map(|token| utils::label(token, labels)).collect(), - Err(_) => Vec::new(), - } - } - } else { - Vec::new() - }; - - // add signature to decoded calls for better calls filtering - self.trace.data = TraceCallData::Decoded { signature: func.signature(), args }; - - if let TraceRetData::Raw(bytes) = &self.trace.output { - if self.trace.success { - if self.trace.address == CHEATCODE_ADDRESS { - if let Some(decoded) = funcs - .iter() - .find_map(|func| decode_cheatcode_outputs(func, bytes, verbosity)) - { - self.trace.output = TraceRetData::Decoded(decoded); - return - } - } - - if let Some(tokens) = - funcs.iter().find_map(|func| func.abi_decode_output(bytes, false).ok()) - { - // Functions coming from an external database do not have any outputs - // specified, and will lead to returning an empty list of tokens. - if !tokens.is_empty() { - self.trace.output = TraceRetData::Decoded( - tokens - .iter() - .map(|token| utils::label(token, labels)) - .collect::>() - .join(", "), - ); - } - } - } else { - self.trace.output = TraceRetData::Decoded(decode::decode_revert( - bytes, - Some(errors), - Some(self.trace.status), - )); - } - } - } - } - - /// Decode the node's tracing data for the given precompile function - pub fn decode_precompile( - &mut self, - precompile_fn: &Function, - labels: &HashMap, - ) { - if let TraceCallData::Raw(ref bytes) = self.trace.data { - self.trace.label = Some("PRECOMPILE".to_string()); - self.trace.data = TraceCallData::Decoded { - signature: precompile_fn.signature(), - args: precompile_fn.abi_decode_input(bytes, false).map_or_else( - |_| vec![hex::encode(bytes)], - |tokens| tokens.iter().map(|token| utils::label(token, labels)).collect(), - ), - }; - - if let TraceRetData::Raw(ref bytes) = self.trace.output { - self.trace.output = TraceRetData::Decoded( - precompile_fn.abi_decode_output(bytes, false).map_or_else( - |_| hex::encode(bytes), - |tokens| { - tokens - .iter() - .map(|token| utils::label(token, labels)) - .collect::>() - .join(", ") - }, - ), - ); - } - } - } } diff --git a/crates/evm/traces/src/utils.rs b/crates/evm/traces/src/utils.rs index 590ee250b4fd4..ead0544e577f4 100644 --- a/crates/evm/traces/src/utils.rs +++ b/crates/evm/traces/src/utils.rs @@ -1,10 +1,8 @@ //! utilities used within tracing -use alloy_dyn_abi::{DynSolType, DynSolValue, JsonAbiExt}; -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_dyn_abi::DynSolValue; use alloy_primitives::Address; -use foundry_common::{fmt::format_token, SELECTOR_LEN}; -use foundry_evm_core::decode; +use foundry_common::fmt::format_token; use std::collections::HashMap; /// Returns the label for the given [DynSolValue] @@ -15,7 +13,7 @@ pub fn label(token: &DynSolValue, labels: &HashMap) -> String { match token { DynSolValue::Address(addr) => { if let Some(label) = labels.get(addr) { - format!("{label}: [{}]", addr.to_checksum(None)) + format!("{label}: [{addr}]") } else { format_token(token) } @@ -23,98 +21,3 @@ pub fn label(token: &DynSolValue, labels: &HashMap) -> String { _ => format_token(token), } } - -/// Custom decoding of cheatcode calls -pub(crate) fn decode_cheatcode_inputs( - func: &Function, - data: &[u8], - errors: &Abi, - verbosity: u8, -) -> Option> { - match func.name.as_str() { - "expectRevert" => Some(vec![decode::decode_revert(data, Some(errors), None)]), - "rememberKey" | "addr" | "startBroadcast" | "broadcast" => { - // these functions accept a private key as uint256, which should not be - // converted to plain text - let _expected_type = DynSolType::Uint(256).to_string(); - if !func.inputs.is_empty() && matches!(&func.inputs[0].ty, _expected_type) { - // redact private key input - Some(vec!["".to_string()]) - } else { - None - } - } - "sign" => { - // sign(uint256,bytes32) - let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; - let _expected_type = DynSolType::Uint(256).to_string(); - if !decoded.is_empty() && matches!(&func.inputs[0].ty, _expected_type) { - decoded[0] = DynSolValue::String("".to_string()); - } - Some(decoded.iter().map(format_token).collect()) - } - "deriveKey" => Some(vec!["".to_string()]), - "parseJson" | - "parseJsonUint" | - "parseJsonUintArray" | - "parseJsonInt" | - "parseJsonIntArray" | - "parseJsonString" | - "parseJsonStringArray" | - "parseJsonAddress" | - "parseJsonAddressArray" | - "parseJsonBool" | - "parseJsonBoolArray" | - "parseJsonBytes" | - "parseJsonBytesArray" | - "parseJsonBytes32" | - "parseJsonBytes32Array" | - "writeJson" | - "keyExists" | - "serializeBool" | - "serializeUint" | - "serializeInt" | - "serializeAddress" | - "serializeBytes32" | - "serializeString" | - "serializeBytes" => { - if verbosity >= 5 { - None - } else { - let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; - let token = - if func.name.as_str() == "parseJson" || func.name.as_str() == "keyExists" { - "" - } else { - "" - }; - decoded[0] = DynSolValue::String(token.to_string()); - Some(decoded.iter().map(format_token).collect()) - } - } - _ => None, - } -} - -/// Custom decoding of cheatcode return values -pub(crate) fn decode_cheatcode_outputs( - func: &Function, - _data: &[u8], - verbosity: u8, -) -> Option { - if func.name.starts_with("env") { - // redacts the value stored in the env var - return Some("".to_string()) - } - if func.name == "deriveKey" { - // redacts derived private key - return Some("".to_string()) - } - if func.name == "parseJson" && verbosity < 5 { - return Some("".to_string()) - } - if func.name == "readFile" && verbosity < 5 { - return Some("".to_string()) - } - None -} diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 8c33fb6788d8b..592b5355ce35b 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -211,10 +211,8 @@ impl TransactionWithMetadata { // This CALL is made to an external contract. We can only decode it, if it has // been verified and identified by etherscan. - if let Some(Some(function)) = decoder - .functions - .get(&data.0[..SELECTOR_LEN]) - .map(|functions| functions.first()) + if let Some(function) = + decoder.functions.get(&data.0[..SELECTOR_LEN]).and_then(|v| v.first()) { self.contract_name = decoder.contracts.get(&target).cloned(); From 40aca52e70af9dfc28442b35a6dceecb3a561e01 Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 9 Nov 2023 10:20:22 -0400 Subject: [PATCH 0254/1963] fix: use selector() instead of signature for cast event-sig (#6266) --- crates/cast/bin/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 60e64c214d349..f842ab10e1b29 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -451,7 +451,7 @@ async fn main() -> Result<()> { Subcommands::SigEvent { event_string } => { let event_string = stdin::unwrap_line(event_string)?; let parsed_event = get_event(&event_string)?; - println!("{:?}", parsed_event.signature()); + println!("{:?}", parsed_event.selector()); } Subcommands::LeftShift { value, bits, base_in, base_out } => { println!("{}", SimpleCast::left_shift(&value, &bits, base_in.as_deref(), &base_out)?); From 74d596c7212f2f90ca3fc7013926565ed853d5b9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 9 Nov 2023 23:11:50 +0100 Subject: [PATCH 0255/1963] ci: fix release workflow (again) (#6272) --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 32c62881990b3..3934a8970f992 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,7 +68,7 @@ jobs: release: name: ${{ matrix.target }} (${{ matrix.os }}) runs-on: ${{ matrix.os }} - timeout-minutes: 90 + timeout-minutes: 240 needs: prepare strategy: fail-fast: false @@ -133,7 +133,7 @@ jobs: # Windows runs out of RAM when building binaries with LLVM run: | flags=() - [[ "${{ matrix.target }}" == *windows* ]] && flags+=(-j2) + [[ "${{ matrix.target }}" == *windows* ]] && flags+=(-j1) cargo build --release --bins --target ${{ matrix.target }} "${flags[@]}" - name: Archive binaries From 834d95921c77c89859118840863871984da1611d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 9 Nov 2023 23:50:52 +0100 Subject: [PATCH 0256/1963] refactor(cheatcodes): rewrite string parsing with dyn abi (#6269) * refactor(cheatcodes): rewrite string parsing with dyn abi * fix * fix: better error for non-hex-prefixed hex strings * update * fix: update error message for env * fmt * comment --- Cargo.lock | 28 ++++++-- crates/cheatcodes/src/env.rs | 110 +++++++++++++++++--------------- crates/cheatcodes/src/json.rs | 42 ++++++------ crates/cheatcodes/src/string.rs | 75 ++++++++++++++-------- crates/forge/tests/it/repros.rs | 6 ++ testdata/repros/Issue5808.t.sol | 7 +- testdata/repros/Issue6070.t.sol | 18 ++++++ 7 files changed, 175 insertions(+), 111 deletions(-) create mode 100644 testdata/repros/Issue6070.t.sol diff --git a/Cargo.lock b/Cargo.lock index 4d8c7f777bc12..9f4fadf97867f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" +source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" +source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" +source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" dependencies = [ "alloy-rlp", "arbitrary", @@ -119,6 +119,7 @@ dependencies = [ "const-hex", "derive_arbitrary", "derive_more", + "ethereum_ssz", "getrandom 0.2.10", "hex-literal", "itoa", @@ -156,7 +157,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" +source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" dependencies = [ "const-hex", "dunce", @@ -173,7 +174,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" +source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" dependencies = [ "winnow", ] @@ -181,7 +182,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" +source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -2030,6 +2031,17 @@ dependencies = [ "uint", ] +[[package]] +name = "ethereum_ssz" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e61ffea29f26e8249d35128a82ec8d3bd4fbc80179ea5f5e5e3daafef6a80fcb" +dependencies = [ + "ethereum-types", + "itertools 0.10.5", + "smallvec", +] + [[package]] name = "ethers" version = "2.0.10" @@ -2417,6 +2429,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ + "arbitrary", "byteorder", "rand 0.8.5", "rustc-hex", @@ -6818,7 +6831,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#818071e6f20cec5c0b7fb465fda5e0553b2e0ed4" +source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" dependencies = [ "paste", "proc-macro2", @@ -7488,6 +7501,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ + "arbitrary", "byteorder", "crunchy", "hex", diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index d9022b16d4c16..a0a458851ddba 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -1,7 +1,8 @@ //! Implementations of [`Environment`](crate::Group::Environment) cheatcodes. -use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*}; -use alloy_primitives::{Address, Bytes, B256, I256, U256}; +use crate::{string, Cheatcode, Cheatcodes, Error, Result, Vm::*}; +use alloy_dyn_abi::DynSolType; +use alloy_primitives::Bytes; use alloy_sol_types::SolValue; use std::env; @@ -26,98 +27,98 @@ impl Cheatcode for setEnvCall { impl Cheatcode for envBool_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; - env::(name, None) + env(name, &DynSolType::Bool) } } impl Cheatcode for envUint_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; - env::(name, None) + env(name, &DynSolType::Uint(256)) } } impl Cheatcode for envInt_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; - env::(name, None) + env(name, &DynSolType::Int(256)) } } impl Cheatcode for envAddress_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; - env::
(name, None) + env(name, &DynSolType::Address) } } impl Cheatcode for envBytes32_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; - env::(name, None) + env(name, &DynSolType::FixedBytes(32)) } } impl Cheatcode for envString_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; - env::(name, None) + env(name, &DynSolType::String) } } impl Cheatcode for envBytes_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; - env::(name, None) + env(name, &DynSolType::Bytes) } } impl Cheatcode for envBool_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim } = self; - env_array::(name, delim, None) + env_array(name, delim, &DynSolType::Bool) } } impl Cheatcode for envUint_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim } = self; - env_array::(name, delim, None) + env_array(name, delim, &DynSolType::Uint(256)) } } impl Cheatcode for envInt_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim } = self; - env_array::(name, delim, None) + env_array(name, delim, &DynSolType::Int(256)) } } impl Cheatcode for envAddress_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim } = self; - env_array::
(name, delim, None) + env_array(name, delim, &DynSolType::Address) } } impl Cheatcode for envBytes32_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim } = self; - env_array::(name, delim, None) + env_array(name, delim, &DynSolType::FixedBytes(32)) } } impl Cheatcode for envString_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim } = self; - env_array::(name, delim, None) + env_array(name, delim, &DynSolType::String) } } impl Cheatcode for envBytes_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim } = self; - env_array::(name, delim, None) + env_array(name, delim, &DynSolType::Bytes) } } @@ -125,7 +126,7 @@ impl Cheatcode for envBytes_1Call { impl Cheatcode for envOr_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, defaultValue } = self; - env::(name, Some(defaultValue)) + env_default(name, defaultValue, &DynSolType::Bool) } } @@ -133,7 +134,7 @@ impl Cheatcode for envOr_0Call { impl Cheatcode for envOr_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, defaultValue } = self; - env::(name, Some(defaultValue)) + env_default(name, defaultValue, &DynSolType::Uint(256)) } } @@ -141,7 +142,7 @@ impl Cheatcode for envOr_1Call { impl Cheatcode for envOr_2Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, defaultValue } = self; - env::(name, Some(defaultValue)) + env_default(name, defaultValue, &DynSolType::Int(256)) } } @@ -149,7 +150,7 @@ impl Cheatcode for envOr_2Call { impl Cheatcode for envOr_3Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, defaultValue } = self; - env::
(name, Some(defaultValue)) + env_default(name, defaultValue, &DynSolType::Address) } } @@ -157,7 +158,7 @@ impl Cheatcode for envOr_3Call { impl Cheatcode for envOr_4Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, defaultValue } = self; - env::(name, Some(defaultValue)) + env_default(name, defaultValue, &DynSolType::FixedBytes(32)) } } @@ -165,7 +166,7 @@ impl Cheatcode for envOr_4Call { impl Cheatcode for envOr_5Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, defaultValue } = self; - env::(name, Some(defaultValue)) + env_default(name, defaultValue, &DynSolType::String) } } @@ -173,7 +174,7 @@ impl Cheatcode for envOr_5Call { impl Cheatcode for envOr_6Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, defaultValue } = self; - env::(name, Some(&defaultValue.clone().into())) + env_default(name, defaultValue, &DynSolType::Bytes) } } @@ -181,7 +182,7 @@ impl Cheatcode for envOr_6Call { impl Cheatcode for envOr_7Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; - env_array::(name, delim, Some(defaultValue)) + env_array_default(name, delim, defaultValue, &DynSolType::Bool) } } @@ -189,7 +190,7 @@ impl Cheatcode for envOr_7Call { impl Cheatcode for envOr_8Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; - env_array::(name, delim, Some(defaultValue)) + env_array_default(name, delim, defaultValue, &DynSolType::Uint(256)) } } @@ -197,7 +198,7 @@ impl Cheatcode for envOr_8Call { impl Cheatcode for envOr_9Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; - env_array::(name, delim, Some(defaultValue)) + env_array_default(name, delim, defaultValue, &DynSolType::Int(256)) } } @@ -205,7 +206,7 @@ impl Cheatcode for envOr_9Call { impl Cheatcode for envOr_10Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; - env_array::
(name, delim, Some(defaultValue)) + env_array_default(name, delim, defaultValue, &DynSolType::Address) } } @@ -213,7 +214,7 @@ impl Cheatcode for envOr_10Call { impl Cheatcode for envOr_11Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; - env_array::(name, delim, Some(defaultValue)) + env_array_default(name, delim, defaultValue, &DynSolType::FixedBytes(32)) } } @@ -221,7 +222,7 @@ impl Cheatcode for envOr_11Call { impl Cheatcode for envOr_12Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; - env_array::(name, delim, Some(defaultValue)) + env_array_default(name, delim, defaultValue, &DynSolType::String) } } @@ -230,32 +231,26 @@ impl Cheatcode for envOr_13Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; let default = defaultValue.iter().map(|vec| vec.clone().into()).collect::>(); - env_array::(name, delim, Some(&default)) + env_array_default(name, delim, &default, &DynSolType::Bytes) } } -fn env(key: &str, default: Option<&T>) -> Result -where - T: SolValue + std::str::FromStr, - T::Err: std::fmt::Display, -{ - match (get_env(key), default) { - (Ok(val), _) => string::parse::(&val), - (Err(_), Some(default)) => Ok(default.abi_encode()), - (Err(e), None) => Err(e), - } +fn env(key: &str, ty: &DynSolType) -> Result { + get_env(key).and_then(|val| string::parse(&val, ty).map_err(map_env_err(key))) } -fn env_array(key: &str, delim: &str, default: Option<&[T]>) -> Result -where - T: SolValue + std::str::FromStr, - T::Err: std::fmt::Display, -{ - match (get_env(key), default) { - (Ok(val), _) => string::parse_array::<_, _, T>(val.split(delim).map(str::trim)), - (Err(_), Some(default)) => Ok(default.abi_encode()), - (Err(e), None) => Err(e), - } +fn env_default(key: &str, default: &T, ty: &DynSolType) -> Result { + Ok(env(key, ty).unwrap_or_else(|_| default.abi_encode())) +} + +fn env_array(key: &str, delim: &str, ty: &DynSolType) -> Result { + get_env(key).and_then(|val| { + string::parse_array(val.split(delim).map(str::trim), ty).map_err(map_env_err(key)) + }) +} + +fn env_array_default(key: &str, delim: &str, default: &T, ty: &DynSolType) -> Result { + Ok(env_array(key, delim, ty).unwrap_or_else(|_| default.abi_encode())) } fn get_env(key: &str) -> Result { @@ -267,3 +262,18 @@ fn get_env(key: &str) -> Result { } } } + +fn map_env_err(key: &str) -> impl FnOnce(Error) -> Error + '_ { + move |e| { + let e = e.to_string(); + let mut e = e.as_str(); + // cut off the message to not leak the value + let sep = if let Some(idx) = e.rfind(" as type `") { + e = &e[idx..]; + "" + } else { + ": " + }; + fmt_err!("failed parsing ${key}{sep}{e}") + } +} diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index a52a37e1bf480..f401d7903ce10 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -1,8 +1,8 @@ //! Implementations of [`Json`](crate::Group::Json) cheatcodes. use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*}; -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::{Address, Bytes, B256, I256, U256}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_primitives::{Address, B256, I256}; use alloy_sol_types::SolValue; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; @@ -36,98 +36,98 @@ impl Cheatcode for parseJson_1Call { impl Cheatcode for parseJsonUintCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Uint(256)) } } impl Cheatcode for parseJsonUintArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Uint(256)) } } impl Cheatcode for parseJsonIntCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Int(256)) } } impl Cheatcode for parseJsonIntArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Int(256)) } } impl Cheatcode for parseJsonBoolCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Bool) } } impl Cheatcode for parseJsonBoolArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Bool) } } impl Cheatcode for parseJsonAddressCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::
(json, key) + parse_json_coerce(json, key, &DynSolType::Address) } } impl Cheatcode for parseJsonAddressArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::
(json, key) + parse_json_coerce(json, key, &DynSolType::Address) } } impl Cheatcode for parseJsonStringCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::String) } } impl Cheatcode for parseJsonStringArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::String) } } impl Cheatcode for parseJsonBytesCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Bytes) } } impl Cheatcode for parseJsonBytesArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::Bytes) } } impl Cheatcode for parseJsonBytes32Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::FixedBytes(32)) } } impl Cheatcode for parseJsonBytes32ArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce::(json, key) + parse_json_coerce(json, key, &DynSolType::FixedBytes(32)) } } @@ -284,11 +284,7 @@ fn parse_json(json: &str, path: &str) -> Result { parse_json_inner(json, path, None::) -> Result>) } -fn parse_json_coerce(json: &str, path: &str) -> Result -where - T: SolValue + std::str::FromStr, - T::Err: std::fmt::Display, -{ +fn parse_json_coerce(json: &str, path: &str, ty: &DynSolType) -> Result { parse_json_inner( json, path, @@ -306,9 +302,9 @@ where s }; if let Some(array) = values[0].as_array() { - string::parse_array::<_, _, T>(array.iter().map(to_string)) + string::parse_array(array.iter().map(to_string), ty) } else { - string::parse::(&to_string(values[0])) + string::parse(&to_string(values[0]), ty) } }), ) diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index 9a3db966d29a6..3c53c551d7f1f 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -1,8 +1,8 @@ //! Implementations of [`String`](crate::Group::String) cheatcodes. use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; -use alloy_primitives::{Address, Bytes, B256, I256, U256}; -use alloy_sol_types::{SolType, SolValue}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_sol_types::SolValue; // address impl Cheatcode for toString_0Call { @@ -55,78 +55,99 @@ impl Cheatcode for toString_5Call { impl Cheatcode for parseBytesCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { stringifiedValue } = self; - parse::(stringifiedValue) + parse(stringifiedValue, &DynSolType::Bytes) } } impl Cheatcode for parseAddressCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { stringifiedValue } = self; - parse::
(stringifiedValue) + parse(stringifiedValue, &DynSolType::Address) } } impl Cheatcode for parseUintCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { stringifiedValue } = self; - parse::(stringifiedValue) + parse(stringifiedValue, &DynSolType::Uint(256)) } } impl Cheatcode for parseIntCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { stringifiedValue } = self; - parse::(stringifiedValue) + parse(stringifiedValue, &DynSolType::Int(256)) } } impl Cheatcode for parseBytes32Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { stringifiedValue } = self; - parse::(stringifiedValue) + parse(stringifiedValue, &DynSolType::FixedBytes(32)) } } impl Cheatcode for parseBoolCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { stringifiedValue } = self; - parse::(stringifiedValue) + parse(stringifiedValue, &DynSolType::Bool) } } -pub(super) fn parse(s: &str) -> Result -where - T: SolValue + std::str::FromStr, - T::Err: std::fmt::Display, -{ - parse_t::(s).map(|v| v.abi_encode()) +pub(super) fn parse(s: &str, ty: &DynSolType) -> Result { + parse_value(s, ty).map(|v| v.abi_encode()) } -pub(super) fn parse_array(values: I) -> Result +pub(super) fn parse_array(values: I, ty: &DynSolType) -> Result where I: IntoIterator, S: AsRef, - T: SolValue + std::str::FromStr, - T::Err: std::fmt::Display, { let mut values = values.into_iter(); match values.next() { Some(first) if !first.as_ref().is_empty() => std::iter::once(first) .chain(values) - .map(|s| parse_t::(s.as_ref())) + .map(|s| parse_value(s.as_ref(), ty)) .collect::, _>>() - .map(|vec| vec.abi_encode()), + .map(|vec| DynSolValue::Array(vec).abi_encode()), // return the empty encoded Bytes when values is empty or the first element is empty _ => Ok("".abi_encode()), } } -fn parse_t(s: &str) -> Result -where - T: SolValue + std::str::FromStr, - T::Err: std::fmt::Display, -{ - s.parse::().map_err(|e| { - fmt_err!("failed parsing {s:?} as type `{}`: {e}", T::SolType::sol_type_name()) - }) +fn parse_value(s: &str, ty: &DynSolType) -> Result { + match ty.coerce_str(s) { + Ok(value) => Ok(value), + Err(e) => match parse_value_fallback(s, ty) { + Some(Ok(value)) => Ok(value), + Some(Err(e2)) => Err(fmt_err!("failed parsing {s:?} as type `{ty}`: {e2}")), + None => Err(fmt_err!("failed parsing {s:?} as type `{ty}`: {e}")), + }, + } +} + +// More lenient parsers than `coerce_str`. +fn parse_value_fallback(s: &str, ty: &DynSolType) -> Option> { + match ty { + DynSolType::Bool => { + let b = match s { + "1" => true, + "0" => false, + s if s.eq_ignore_ascii_case("true") => true, + s if s.eq_ignore_ascii_case("false") => false, + _ => return None, + }; + return Some(Ok(DynSolValue::Bool(b))); + } + DynSolType::Int(_) | + DynSolType::Uint(_) | + DynSolType::FixedBytes(_) | + DynSolType::Bytes => { + if !s.starts_with("0x") && s.chars().all(|c| c.is_ascii_hexdigit()) { + return Some(Err("missing hex prefix (\"0x\") for hex string")) + } + } + _ => {} + } + None } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 1cad2984c5ac7..cbc6cae8af12f 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -302,6 +302,12 @@ async fn test_issue_5808() { test_repro!("Issue5808"); } +// +#[tokio::test(flavor = "multi_thread")] +async fn test_issue_6070() { + test_repro!("Issue6070"); +} + // #[tokio::test(flavor = "multi_thread")] async fn test_issue_6115() { diff --git a/testdata/repros/Issue5808.t.sol b/testdata/repros/Issue5808.t.sol index b3b455b48c295..e2a6a20888307 100644 --- a/testdata/repros/Issue5808.t.sol +++ b/testdata/repros/Issue5808.t.sol @@ -9,10 +9,9 @@ contract Issue5808Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testReadInt() public { - // TODO: blocked on https://github.com/alloy-rs/core/issues/387 - // string memory str1 = '["ffffffff","00000010"]'; - // vm.expectRevert(); - // int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); + string memory str1 = '["ffffffff","00000010"]'; + vm.expectRevert(); + int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); string memory str2 = '["0xffffffff","0x00000010"]'; int256[] memory ints2 = vm.parseJsonIntArray(str2, ""); diff --git a/testdata/repros/Issue6070.t.sol b/testdata/repros/Issue6070.t.sol new file mode 100644 index 0000000000000..dc068f22cf406 --- /dev/null +++ b/testdata/repros/Issue6070.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6070 +contract Issue6066Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testNonPrefixed() public { + vm.setEnv("__FOUNDRY_ISSUE_6066", "abcd"); + vm.expectRevert( + "failed parsing $__FOUNDRY_ISSUE_6066 as type `uint256`: missing hex prefix (\"0x\") for hex string" + ); + uint256 x = vm.envUint("__FOUNDRY_ISSUE_6066"); + } +} From 4c11a23678074f8fde0bb8419bc88289b6255f47 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 10 Nov 2023 02:36:45 +0100 Subject: [PATCH 0257/1963] feat: add --no-cache and respect cache config value (#6273) * feat: add --no-cache and respect cache config value * fix test * test: use forgetest_init! doh --- crates/cli/src/opts/build/core.rs | 9 +++++++++ crates/config/src/lib.rs | 2 +- crates/forge/bin/cmd/flatten.rs | 18 +----------------- crates/forge/tests/cli/cache.rs | 9 +++++++++ 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 9d5bee89c20b9..aec937c780e6f 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -26,6 +26,11 @@ pub struct CoreBuildArgs { #[serde(skip)] pub force: bool, + /// Disable the cache. + #[clap(long)] + #[serde(skip)] + pub no_cache: bool, + /// Set pre-linked libraries. #[clap(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")] #[serde(skip_serializing_if = "Vec::is_empty")] @@ -202,6 +207,10 @@ impl Provider for CoreBuildArgs { if self.force { dict.insert("force".to_string(), self.force.into()); } + // we need to ensure no_cache set accordingly + if self.no_cache { + dict.insert("cache".to_string(), false.into()); + } if self.build_info { dict.insert("build_info".to_string(), self.build_info.into()); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 8515f6df2f4ee..5e59cfe36461d 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -605,7 +605,7 @@ impl Config { /// let project = config.project(); /// ``` pub fn project(&self) -> Result { - self.create_project(true, false) + self.create_project(self.cache, false) } /// Same as [`Self::project()`] but sets configures the project to not emit artifacts and ignore diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 2f750877694ea..64d62b4d9d349 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -34,23 +34,7 @@ impl FlattenArgs { let FlattenArgs { target_path, output, project_paths } = self; // flatten is a subset of `BuildArgs` so we can reuse that to get the config - let build_args = CoreBuildArgs { - project_paths, - out_path: Default::default(), - compiler: Default::default(), - ignored_error_codes: vec![], - deny_warnings: false, - no_auto_detect: false, - use_solc: None, - offline: false, - force: false, - libraries: vec![], - via_ir: false, - revert_strings: None, - silent: false, - build_info: false, - build_info_path: None, - }; + let build_args = CoreBuildArgs { project_paths, ..Default::default() }; let config = build_args.try_load_config_emit_warnings()?; diff --git a/crates/forge/tests/cli/cache.rs b/crates/forge/tests/cli/cache.rs index 81ebb22ee968f..7fa76ace1069e 100644 --- a/crates/forge/tests/cli/cache.rs +++ b/crates/forge/tests/cli/cache.rs @@ -14,3 +14,12 @@ forgetest!(can_list_specific_chain, |_prj, cmd| { cmd.args(["cache", "ls", "mainnet"]); cmd.assert_success(); }); + +forgetest_init!(can_test_no_cache, |prj, cmd| { + cmd.args(["test", "--no-cache"]); + cmd.assert_success(); + assert!(!prj.cache_path().exists(), "cache file should not exist"); + cmd.forge_fuse().args(["test"]); + cmd.assert_success(); + assert!(prj.cache_path().exists(), "cache file should exist"); +}); From 90d4dce7a96bb9b9bdd8072c6429dfcd8398e253 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:44:32 +0100 Subject: [PATCH 0258/1963] fix: trace decoding off-by-one (#6277) --- .github/workflows/test.yml | 26 +++++++++-- crates/anvil/tests/it/otterscan.rs | 5 ++- crates/evm/traces/src/decoder/mod.rs | 2 +- crates/evm/traces/src/lib.rs | 3 +- crates/forge/tests/cli/ext_integration.rs | 1 + crates/test-utils/src/macros.rs | 25 +++-------- crates/test-utils/src/util.rs | 53 ++++++++++++++++------- testdata/cheats/UnixTime.t.sol | 4 +- 8 files changed, 76 insertions(+), 43 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d3a3ef9fa966..d816ea2e5d376 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,9 +49,28 @@ jobs: with: target: ${{ matrix.target }} - uses: taiki-e/install-action@nextest - # - uses: taiki-e/setup-cross-toolchain-action@v1 - # with: - # target: ${{ matrix.target }} + + # External tests dependencies + - name: Setup Python + if: contains(matrix.name, 'external') + uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: Setup Node.js + if: contains(matrix.name, 'external') + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install pnpm + if: contains(matrix.name, 'external') + uses: pnpm/action-setup@v2 + with: + version: latest + run_install: false + - name: Install Vyper + if: contains(matrix.name, 'external') + run: pip install vyper + - name: Forge RPC cache uses: actions/cache@v3 with: @@ -61,7 +80,6 @@ jobs: key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - uses: Swatinem/rust-cache@v2 with: - # key: ${{ matrix.target }} cache-on-failure: true - name: Setup Git config run: | diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index c6643dc2bd1dd..41745f0fa8e18 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -232,9 +232,12 @@ async fn can_call_ots_has_code() { .await .unwrap()); - client.send_transaction(deploy_tx, None).await.unwrap(); + let pending = client.send_transaction(deploy_tx, None).await.unwrap(); + let receipt = pending.await.unwrap().unwrap(); let num = client.get_block_number().await.unwrap(); + assert_eq!(num, receipt.block_number.unwrap()); + // code is detected after deploying assert!(api.ots_has_code(pending_contract_address, BlockNumber::Number(num)).await.unwrap()); diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 617fc48b5a247..ccb9d47c0b07d 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -431,7 +431,7 @@ impl CallTraceDecoder { let &[t0, ..] = raw_log.topics() else { return }; let mut events = Vec::new(); - let events = match self.events.get(&(t0, raw_log.topics().len())) { + let events = match self.events.get(&(t0, raw_log.topics().len() - 1)) { Some(es) => es, None => { if let Some(identifier) = &self.signature_identifier { diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index a1fcd52fc1f3a..18c53aeace008 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -207,8 +207,7 @@ impl fmt::Display for CallTraceArena { let node = &arena.arena[idx]; // Display trace header - f.write_str(left)?; - node.trace.fmt(f)?; + writeln!(f, "{left}{}", node.trace)?; // Display logs and subcalls let left_prefix = format!("{child}{BRANCH}"); diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 3574222a2fad0..b188ae3e46737 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -11,6 +11,7 @@ forgetest_external!( forgetest_external!(stringutils, "Arachnid/solidity-stringutils"); forgetest_external!(lootloose, "gakonst/lootloose"); forgetest_external!(lil_web3, "m1guelpf/lil-web3"); +forgetest_external!(snekmate, "pcaversaccio/snekmate"); // Forking tests diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index 053741ac069a6..fb8ee4e0b83f6 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -147,31 +147,18 @@ macro_rules! forgetest_external { prj.wipe(); // Clone the external repository - let git_clone = - $crate::util::clone_remote(&format!("https://github.com/{}", $repo), prj.root()) - .expect("Could not clone repository. Is git installed?"); - assert!( - git_clone.status.success(), - "could not clone repository:\nstdout:\n{}\nstderr:\n{}", - String::from_utf8_lossy(&git_clone.stdout), - String::from_utf8_lossy(&git_clone.stderr) - ); + $crate::util::clone_remote(concat!("https://github.com/", $repo), prj.root().to_str().unwrap()); - // We just run make install, but we do not care if it worked or not, - // since some repositories do not have that target - let make_install = Command::new("make") - .arg("install") - .current_dir(prj.root()) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); + // Run common installation commands + $crate::util::run_install_commands(prj.root()); // Run the tests cmd.arg("test").args($forge_opts).args([ "--optimize", - "--optimizer-runs", - "20000", + "--optimizer-runs=20000", + "--fuzz-runs=256", "--ffi", + "-vvvvv", ]); cmd.set_env("FOUNDRY_FUZZ_RUNS", "1"); diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 7b784e2e0142d..7e5ada1f21591 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -76,21 +76,44 @@ pub fn initialize(target: impl AsRef) { } } -/// Clones a remote repository into the specified directory. -pub fn clone_remote( - repo_url: &str, - target_dir: impl AsRef, -) -> std::io::Result { - Command::new("git") - .args([ - "clone", - "--depth", - "1", - "--recursive", - repo_url, - target_dir.as_ref().to_str().expect("Target path for git clone does not exist"), - ]) - .output() +/// Clones a remote repository into the specified directory. Panics if the command fails. +pub fn clone_remote(repo_url: &str, target_dir: &str) { + let mut cmd = Command::new("git"); + let status = cmd + .args(["clone", "--depth=1", "--recursive", "--shallow-submodules", repo_url, target_dir]) + .status() + .unwrap(); + if !status.success() { + panic!("{cmd:?}"); + } + eprintln!(); +} + +/// Runs common installation commands, such as `make` and `npm`. Continues if any command fails. +pub fn run_install_commands(root: &Path) { + let root_files = + std::fs::read_dir(root).unwrap().flatten().map(|x| x.path()).collect::>(); + let contains = |path: &str| root_files.iter().any(|p| p.to_str().unwrap().contains(path)); + let run = |args: &[&str]| { + let mut cmd = Command::new(args[0]); + cmd.args(&args[1..]).current_dir(root).stdout(Stdio::null()).stderr(Stdio::null()); + let st = cmd.status(); + eprintln!("\n\n{cmd:?} -> {st:?}"); + }; + let maybe_run = |path: &str, args: &[&str]| { + let c = contains(path); + if c { + run(args); + } + c + }; + + maybe_run("Makefile", &["make", "install"]); + let pnpm = maybe_run("pnpm-lock.yaml", &["pnpm", "install", "--prefer-offline"]); + let yarn = maybe_run("yarn.lock", &["yarn", "install", "--prefer-offline"]); + if !pnpm && !yarn && contains("package.json") { + run(&["npm", "install"]); + } } /// Setup an empty test project and return a command pointing to the forge diff --git a/testdata/cheats/UnixTime.t.sol b/testdata/cheats/UnixTime.t.sol index 9e689a223543a..8a03ee9ca5128 100644 --- a/testdata/cheats/UnixTime.t.sol +++ b/testdata/cheats/UnixTime.t.sol @@ -6,7 +6,9 @@ import "./Vm.sol"; contract UnixTimeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - uint256 errMargin = 100; // allow errors of up to errMargin milliseconds + + // This is really wide because CI sucks. + uint256 constant errMargin = 300; function testUnixTimeAgainstDate() public { string[] memory inputs = new string[](2); From 2df730661a807cbc112b00782d68086ca5ffb049 Mon Sep 17 00:00:00 2001 From: Arshan Khanifar Date: Fri, 10 Nov 2023 09:53:02 -0500 Subject: [PATCH 0259/1963] Multichain Scripts: Deploy each sequence of transactions sequentially instead of in parallel. (#6271) * deploy recorded txns sequentially * remove println * fmt fix * remove unnecessary comment --- crates/forge/bin/cmd/script/multi.rs | 46 +++++++++++++--------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index 8fb73470e2fdd..3dc292a3b5766 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -5,7 +5,7 @@ use super::{ ScriptArgs, }; use ethers::signers::LocalWallet; -use eyre::{ContextCompat, Result, WrapErr}; +use eyre::{ContextCompat, Report, Result, WrapErr}; use foundry_cli::utils::now; use foundry_common::{fs, get_http_provider}; use foundry_compilers::{artifacts::Libraries, ArtifactId}; @@ -139,37 +139,35 @@ impl ScriptArgs { join_all(futs).await.into_iter().filter(|res| res.is_err()).collect::>(); if !errors.is_empty() { - return Err(eyre::eyre!("{errors:?}")) + return Err(eyre::eyre!("{errors:?}")); } } trace!(target: "script", "broadcasting multi chain deployments"); - let futs = deployments - .deployments - .iter_mut() - .map(|sequence| async { - match self - .send_transactions( - sequence, - &sequence.typed_transactions().first().unwrap().0.clone(), - &script_wallets, - ) - .await - { - Ok(_) => { - if self.verify { - return sequence.verify_contracts(config, verify.clone()).await - } - Ok(()) + let mut results: Vec> = Vec::new(); + + for sequence in deployments.deployments.iter_mut() { + let result = match self + .send_transactions( + sequence, + &sequence.typed_transactions().first().unwrap().0.clone(), + &script_wallets, + ) + .await + { + Ok(_) => { + if self.verify { + return sequence.verify_contracts(config, verify.clone()).await } - Err(err) => Err(err), + Ok(()) } - }) - .collect::>(); + Err(err) => Err(err), + }; + results.push(result); + } - let errors = - join_all(futs).await.into_iter().filter(|res| res.is_err()).collect::>(); + let errors = results.into_iter().filter(|res| res.is_err()).collect::>(); if !errors.is_empty() { return Err(eyre::eyre!("{errors:?}")) From f27a771de18b68396415238462fd1df3be6f43fb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 10 Nov 2023 17:43:11 +0100 Subject: [PATCH 0260/1963] ci: fix windows external tests (#6280) * chore: update utils * ignore test * fix --- crates/forge/tests/cli/cmd.rs | 11 +- crates/forge/tests/cli/doc.rs | 5 +- crates/forge/tests/cli/ext_integration.rs | 8 +- crates/test-utils/src/util.rs | 206 +++++++++------------- 4 files changed, 91 insertions(+), 139 deletions(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 6bb518ffb46d5..cf5bb35c3aecb 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -807,7 +807,7 @@ forgetest!( dss_exec_lib, "-vvv", ]); - cmd.print_output(); + cmd.assert_non_empty_stdout(); } ); @@ -1177,21 +1177,18 @@ contract ContractThreeTest is DSTest { cmd.forge_fuse(); let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); - // cmd.arg("test").arg("--gas-report").print_output(); cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); cmd.forge_fuse(); let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(second_out.contains("foo") && second_out.contains("bar") && second_out.contains("baz")); - // cmd.arg("test").arg("--gas-report").print_output(); cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); cmd.forge_fuse(); let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); - // cmd.arg("test").arg("--gas-report").print_output(); cmd.forge_fuse(); prj.write_config(Config { @@ -1205,7 +1202,6 @@ contract ContractThreeTest is DSTest { cmd.forge_fuse(); let fourth_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(fourth_out.contains("foo") && fourth_out.contains("bar") && fourth_out.contains("baz")); - // cmd.arg("test").arg("--gas-report").print_output(); }); forgetest!(gas_report_some_contracts, |prj, cmd| { @@ -1310,7 +1306,6 @@ contract ContractThreeTest is DSTest { cmd.forge_fuse(); let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(first_out.contains("foo") && !first_out.contains("bar") && !first_out.contains("baz")); - // cmd.arg("test").arg("--gas-report").print_output(); // report for Two cmd.forge_fuse(); @@ -1323,7 +1318,6 @@ contract ContractThreeTest is DSTest { assert!( !second_out.contains("foo") && second_out.contains("bar") && !second_out.contains("baz") ); - // cmd.arg("test").arg("--gas-report").print_output(); // report for Three cmd.forge_fuse(); @@ -1334,7 +1328,6 @@ contract ContractThreeTest is DSTest { cmd.forge_fuse(); let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(!third_out.contains("foo") && !third_out.contains("bar") && third_out.contains("baz")); - // cmd.arg("test").arg("--gas-report").print_output(); }); forgetest!(gas_ignore_some_contracts, |prj, cmd| { @@ -1439,7 +1432,6 @@ contract ContractThreeTest is DSTest { cmd.forge_fuse(); let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!(!first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); - // cmd.arg("test").arg("--gas-report").print_output(); // ignore ContractTwo cmd.forge_fuse(); @@ -1453,7 +1445,6 @@ contract ContractThreeTest is DSTest { assert!( second_out.contains("foo") && !second_out.contains("bar") && second_out.contains("baz") ); - // cmd.arg("test").arg("--gas-report").print_output(); // ignore ContractThree cmd.forge_fuse(); diff --git a/crates/forge/tests/cli/doc.rs b/crates/forge/tests/cli/doc.rs index 9ad34c1df77a5..699b023d0b26e 100644 --- a/crates/forge/tests/cli/doc.rs +++ b/crates/forge/tests/cli/doc.rs @@ -4,8 +4,5 @@ use foundry_test_utils::util::{setup_forge_remote, RemoteProject}; fn can_generate_solmate_docs() { let (prj, _) = setup_forge_remote(RemoteProject::new("transmissions11/solmate").set_build(false)); - prj.forge_command() - .args(["doc", "--build"]) - .ensure_execute_success() - .expect("`forge doc` failed"); + prj.forge_command().args(["doc", "--build"]).assert_success(); } diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index b188ae3e46737..55c128b07f500 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -11,7 +11,13 @@ forgetest_external!( forgetest_external!(stringutils, "Arachnid/solidity-stringutils"); forgetest_external!(lootloose, "gakonst/lootloose"); forgetest_external!(lil_web3, "m1guelpf/lil-web3"); -forgetest_external!(snekmate, "pcaversaccio/snekmate"); +forgetest_external!( + // https://github.com/foundry-rs/foundry/pull/6280 + // `run: pnpm --version` is ok, `Command::new("pnpm")` isn't. Good job Windows. + #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] + snekmate, + "pcaversaccio/snekmate" +); // Forking tests diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 7e5ada1f21591..d52255d374425 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -18,7 +18,7 @@ use std::{ fs::File, io::{BufWriter, IsTerminal, Write}, path::{Path, PathBuf}, - process::{self, Command, Stdio}, + process::{ChildStdin, Command, Output, Stdio}, sync::{ atomic::{AtomicUsize, Ordering}, Arc, @@ -52,8 +52,9 @@ pub fn template_lock() -> RwLock { } /// Copies an initialized project to the given path -pub fn initialize(target: impl AsRef) { - let target = target.as_ref(); +pub fn initialize(target: &Path) { + eprintln!("initialize {}", target.display()); + let tpath = &*TEMPLATE_PATH; pretty_err(tpath, fs::create_dir_all(tpath)); @@ -79,12 +80,11 @@ pub fn initialize(target: impl AsRef) { /// Clones a remote repository into the specified directory. Panics if the command fails. pub fn clone_remote(repo_url: &str, target_dir: &str) { let mut cmd = Command::new("git"); - let status = cmd - .args(["clone", "--depth=1", "--recursive", "--shallow-submodules", repo_url, target_dir]) - .status() - .unwrap(); + cmd.args(["clone", "--depth=1", "--recursive", "--shallow-submodules", repo_url, target_dir]); + eprintln!("{cmd:?}"); + let status = cmd.status().unwrap(); if !status.success() { - panic!("{cmd:?}"); + panic!("git clone failed: {status:?}"); } eprintln!(); } @@ -96,9 +96,10 @@ pub fn run_install_commands(root: &Path) { let contains = |path: &str| root_files.iter().any(|p| p.to_str().unwrap().contains(path)); let run = |args: &[&str]| { let mut cmd = Command::new(args[0]); - cmd.args(&args[1..]).current_dir(root).stdout(Stdio::null()).stderr(Stdio::null()); - let st = cmd.status(); - eprintln!("\n\n{cmd:?} -> {st:?}"); + cmd.args(&args[1..]).current_dir(root); + eprintln!("cd {}; {cmd:?}", root.display()); + let st = cmd.status().unwrap(); + eprintln!("\n\n{cmd:?}: {st:?}"); }; let maybe_run = |path: &str, args: &[&str]| { let c = contains(path); @@ -399,9 +400,9 @@ impl TestProject { } /// Returns the path to the forge executable. - pub fn forge_bin(&self) -> process::Command { + pub fn forge_bin(&self) -> Command { let forge = self.root.join(format!("../forge{}", env::consts::EXE_SUFFIX)); - let mut cmd = process::Command::new(forge); + let mut cmd = Command::new(forge); cmd.current_dir(self.inner.root()); // disable color output for comparisons cmd.env("NO_COLOR", "1"); @@ -409,9 +410,9 @@ impl TestProject { } /// Returns the path to the cast executable. - pub fn cast_bin(&self) -> process::Command { + pub fn cast_bin(&self) -> Command { let cast = self.root.join(format!("../cast{}", env::consts::EXE_SUFFIX)); - let mut cmd = process::Command::new(cast); + let mut cmd = Command::new(cast); // disable color output for comparisons cmd.env("NO_COLOR", "1"); cmd @@ -480,7 +481,7 @@ pub fn read_string(path: impl AsRef) -> String { pretty_err(path, std::fs::read_to_string(path)) } -/// A simple wrapper around a process::Command with some conveniences. +/// A simple wrapper around a Command with some conveniences. pub struct TestCommand { saved_cwd: PathBuf, /// The project used to launch this command. @@ -489,7 +490,7 @@ pub struct TestCommand { cmd: Command, // initial: Command, current_dir_lock: Option>, - stdin_fun: Option>, + stdin_fun: Option>, } impl TestCommand { @@ -539,7 +540,7 @@ impl TestCommand { self } - pub fn stdin(&mut self, fun: impl FnOnce(process::ChildStdin) + 'static) -> &mut TestCommand { + pub fn stdin(&mut self, fun: impl FnOnce(ChildStdin) + 'static) -> &mut TestCommand { self.stdin_fun = Some(Box::new(fun)); self } @@ -571,6 +572,7 @@ impl TestCommand { } /// Returns the `Config` as spit out by `forge config` + #[track_caller] pub fn config(&mut self) -> Config { self.cmd.args(["config", "--json"]); let output = self.output(); @@ -582,11 +584,12 @@ impl TestCommand { /// Runs `git init` inside the project's dir #[track_caller] - pub fn git_init(&self) -> process::Output { + pub fn git_init(&self) -> Output { let mut cmd = Command::new("git"); cmd.arg("init").current_dir(self.project.root()); let output = cmd.output().unwrap(); - self.expect_success(output) + self.ensure_success(&output).unwrap(); + output } /// Executes the command and returns the `(stdout, stderr)` of the output as lossy `String`s. @@ -625,15 +628,16 @@ impl TestCommand { /// Returns the output but does not expect that the command was successful #[track_caller] - pub fn unchecked_output(&mut self) -> process::Output { + pub fn unchecked_output(&mut self) -> Output { self.execute() } /// Gets the output of a command. If the command failed, then this panics. #[track_caller] - pub fn output(&mut self) -> process::Output { + pub fn output(&mut self) -> Output { let output = self.execute(); - self.expect_success(output) + self.ensure_success(&output).unwrap(); + output } /// Runs the command and asserts that it resulted in success @@ -644,13 +648,13 @@ impl TestCommand { /// Executes command, applies stdin function and returns output #[track_caller] - pub fn execute(&mut self) -> process::Output { + pub fn execute(&mut self) -> Output { self.try_execute().unwrap() } #[track_caller] - pub fn try_execute(&mut self) -> std::io::Result { - eprintln!("Executing {:?}\n", self.cmd); + pub fn try_execute(&mut self) -> std::io::Result { + eprintln!("executing {:?}", self.cmd); let mut child = self.cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::piped()).spawn()?; if let Some(fun) = self.stdin_fun.take() { @@ -661,9 +665,10 @@ impl TestCommand { /// Executes command and expects an successful result #[track_caller] - pub fn ensure_execute_success(&mut self) -> Result { + pub fn ensure_execute_success(&mut self) -> Result { let out = self.try_execute()?; - self.ensure_success(out) + self.ensure_success(&out)?; + Ok(out) } /// Runs the command and prints its output @@ -672,8 +677,8 @@ impl TestCommand { #[track_caller] pub fn print_output(&mut self) { let output = self.execute(); - println!("stdout: {}", lossy_string(&output.stdout)); - println!("stderr: {}", lossy_string(&output.stderr)); + println!("stdout:\n{}", lossy_string(&output.stdout)); + println!("\nstderr:\n{}", lossy_string(&output.stderr)); } /// Writes the content of the output to new fixture files @@ -691,136 +696,89 @@ impl TestCommand { /// Runs the command and asserts that it resulted in an error exit code. #[track_caller] pub fn assert_err(&mut self) { - let o = self.execute(); - if o.status.success() { - panic!( - "\n\n===== {:?} =====\n\ - command succeeded but expected failure!\ - \n\ncwd: {}\ - \n\nstatus: {}\ - \n\nstdout: {}\n\nstderr: {}\ - \n\n=====\n", - self.cmd, - self.project.inner.paths(), - o.status, - lossy_string(&o.stdout), - lossy_string(&o.stderr) - ); + let out = self.execute(); + if out.status.success() { + self.make_panic(&out, true); } } /// Runs the command and asserts that something was printed to stderr. #[track_caller] pub fn assert_non_empty_stderr(&mut self) { - let o = self.execute(); - if o.status.success() || o.stderr.is_empty() { - panic!( - "\n\n===== {:?} =====\n\ - command succeeded but expected failure!\ - \n\ncwd: {}\ - \n\nstatus: {}\ - \n\nstdout: {}\n\nstderr: {}\ - \n\n=====\n", - self.cmd, - self.project.inner.paths(), - o.status, - lossy_string(&o.stdout), - lossy_string(&o.stderr) - ); + let out = self.execute(); + if out.status.success() || out.stderr.is_empty() { + self.make_panic(&out, true); } } /// Runs the command and asserts that something was printed to stdout. #[track_caller] pub fn assert_non_empty_stdout(&mut self) { - let o = self.execute(); - if !o.status.success() || o.stdout.is_empty() { - panic!( - " -===== {:?} ===== -command failed but expected success! -status: {} - -{} - -stdout: -{} - -stderr: -{} - -=====\n", - self.cmd, - o.status, - self.project.inner.paths(), - lossy_string(&o.stdout), - lossy_string(&o.stderr) - ); + let out = self.execute(); + if !out.status.success() || out.stdout.is_empty() { + self.make_panic(&out, false); } } /// Runs the command and asserts that nothing was printed to stdout. #[track_caller] pub fn assert_empty_stdout(&mut self) { - let o = self.execute(); - if !o.status.success() || !o.stderr.is_empty() { - panic!( - "\n\n===== {:?} =====\n\ - command succeeded but expected failure!\ - \n\ncwd: {}\ - \n\nstatus: {}\ - \n\nstdout: {}\n\nstderr: {}\ - \n\n=====\n", - self.cmd, - self.project.inner.paths(), - o.status, - lossy_string(&o.stdout), - lossy_string(&o.stderr) - ); + let out = self.execute(); + if !out.status.success() || !out.stderr.is_empty() { + self.make_panic(&out, true); } } #[track_caller] - fn expect_success(&self, out: process::Output) -> process::Output { - self.ensure_success(out).unwrap() + pub fn ensure_success(&self, out: &Output) -> Result<()> { + if out.status.success() { + Ok(()) + } else { + Err(self.make_error(out, false)) + } + } + + #[track_caller] + fn make_panic(&self, out: &Output, expected_fail: bool) -> ! { + panic!("{}", self.make_error_message(out, expected_fail)) } #[track_caller] - pub fn ensure_success(&self, out: process::Output) -> Result { - if !out.status.success() { - let suggest = if out.stderr.is_empty() { - "\n\nDid your forge command end up with no output?".to_string() - } else { - String::new() - }; - eyre::bail!( - " -===== {:?} ===== -command failed but expected success!{suggest} + fn make_error(&self, out: &Output, expected_fail: bool) -> eyre::Report { + eyre::eyre!("{}", self.make_error_message(out, expected_fail)) + } + + fn make_error_message(&self, out: &Output, expected_fail: bool) -> String { + let msg = if expected_fail { + "expected failure but command succeeded!" + } else { + "command failed but expected success!" + }; + format!( + "\ +--- {:?} --- +{msg} status: {} +paths: {} stdout: {} stderr: -{} - -=====\n", - self.cmd, - out.status, - self.project.inner.paths(), - lossy_string(&out.stdout), - lossy_string(&out.stderr) - ); - } - Ok(out) +{}", + self.cmd, + out.status, + self.project.inner.paths(), + lossy_string(&out.stdout), + lossy_string(&out.stderr), + ) } } -/// Extension trait for `std::process::Output` +/// Extension trait for [`Output`]. /// /// These function will read the path's content and assert that the process' output matches the /// fixture. Since `forge` commands may emit colorized output depending on whether the current @@ -840,7 +798,7 @@ static IGNORE_IN_FIXTURES: Lazy = Lazy::new(|| { Regex::new(r"(\r|finished in (.*)?s|-->(.*).sol|Location(.|\n)*\.rs(.|\n)*Backtrace|Installing solc version(.*?)\n|Successfully installed solc(.*?)\n|runs: \d+, μ: \d+, ~: \d+)").unwrap() }); -impl OutputExt for process::Output { +impl OutputExt for Output { #[track_caller] fn stdout_matches_path(&self, expected_path: impl AsRef) -> &Self { let expected = fs::read_to_string(expected_path).unwrap(); From 74b641f51ab8650190cfc4a5e2a268348899b832 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 10 Nov 2023 20:23:31 +0100 Subject: [PATCH 0261/1963] chore: clean up remaining ethers usage (#6254) * chore: remove usage of LosslessAbi/RawAbi * use NamedChain instead of Ethers Chain * rm forge upload-selectors * rm resolve_addr * stuff * cast base * fix * rm rlp in config * upgrade * fix cast interface * fix: shr * chore: clippy * stop using ethers * fix doctests * chore: clippy * fmt * migrate rlp * fixes * ok_or_else for eyre * chore: sort deps in manifests * deps * update pragma * winders * update * fmt json * update ethers * keep ethers patches --- Cargo.lock | 119 +++-- Cargo.toml | 37 +- crates/anvil/core/src/eth/block.rs | 6 +- crates/anvil/core/src/eth/receipt.rs | 12 +- crates/anvil/core/src/eth/state.rs | 3 +- crates/anvil/src/cmd.rs | 3 +- crates/anvil/src/eth/api.rs | 3 +- crates/anvil/src/eth/backend/time.rs | 3 +- crates/anvil/src/eth/otterscan/api.rs | 10 +- crates/anvil/src/eth/otterscan/types.rs | 9 +- crates/anvil/tests/it/api.rs | 3 +- crates/anvil/tests/it/proof/mod.rs | 14 +- crates/anvil/tests/it/traces.rs | 498 ++++++++---------- crates/binder/Cargo.toml | 4 +- crates/cast/Cargo.toml | 29 +- crates/cast/bin/cmd/access_list.rs | 6 +- crates/cast/bin/cmd/bind.rs | 3 +- crates/cast/bin/cmd/call.rs | 16 +- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/interface.rs | 37 +- crates/cast/bin/cmd/logs.rs | 9 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/cmd/send.rs | 7 +- crates/cast/bin/cmd/storage.rs | 17 +- crates/cast/bin/cmd/wallet/mod.rs | 14 +- crates/cast/bin/cmd/wallet/vanity.rs | 7 +- crates/cast/bin/main.rs | 6 +- crates/cast/bin/opts.rs | 6 +- crates/cast/src/base.rs | 137 ++--- crates/cast/src/lib.rs | 114 ++-- crates/cast/src/rlp_converter.rs | 72 +-- crates/cast/src/tx.rs | 34 +- crates/cheatcodes/Cargo.toml | 1 + crates/chisel/Cargo.toml | 44 +- crates/chisel/bin/main.rs | 3 +- crates/chisel/src/dispatcher.rs | 2 +- crates/chisel/src/executor.rs | 5 +- crates/chisel/src/runner.rs | 2 +- crates/chisel/src/session.rs | 18 +- crates/chisel/src/session_source.rs | 8 +- crates/cli/Cargo.toml | 27 +- crates/cli/src/opts/chain.rs | 3 +- crates/cli/src/opts/wallet/mod.rs | 21 +- crates/cli/src/opts/wallet/multi_wallet.rs | 6 +- crates/cli/src/utils/cmd.rs | 25 +- crates/cli/src/utils/mod.rs | 10 +- crates/common/Cargo.toml | 45 +- crates/common/src/abi.rs | 4 +- crates/common/src/calc.rs | 2 +- crates/common/src/constants.rs | 2 +- crates/common/src/contracts.rs | 48 +- crates/common/src/evm.rs | 15 +- crates/common/src/provider.rs | 19 +- crates/common/src/selectors.rs | 19 +- crates/common/src/serde_helpers.rs | 5 +- crates/config/Cargo.toml | 44 +- crates/config/src/cache.rs | 52 +- crates/config/src/chain.rs | 25 +- crates/config/src/etherscan.rs | 12 +- crates/config/src/fuzz.rs | 7 +- crates/config/src/inline/conf_parser.rs | 6 +- crates/config/src/inline/mod.rs | 8 +- crates/config/src/lib.rs | 36 +- crates/debugger/Cargo.toml | 7 +- crates/debugger/src/debugger.rs | 3 +- crates/debugger/src/lib.rs | 34 +- crates/doc/Cargo.toml | 36 +- crates/doc/src/builder.rs | 2 +- crates/doc/src/document.rs | 3 +- .../src/preprocessor/contract_inheritance.rs | 3 +- crates/doc/src/preprocessor/deployments.rs | 12 +- crates/doc/src/preprocessor/inheritdoc.rs | 6 +- crates/doc/src/writer/as_doc.rs | 3 +- crates/doc/src/writer/buf_writer.rs | 3 +- crates/evm/core/Cargo.toml | 37 +- crates/evm/core/src/backend/error.rs | 2 +- crates/evm/core/src/backend/fuzz.rs | 2 +- crates/evm/core/src/backend/in_memory_db.rs | 3 +- crates/evm/core/src/backend/mod.rs | 5 +- crates/evm/core/src/decode.rs | 11 +- crates/evm/core/src/fork/backend.rs | 11 +- crates/evm/core/src/fork/database.rs | 2 +- crates/evm/core/src/fork/init.rs | 6 +- crates/evm/core/src/fork/mod.rs | 7 +- crates/evm/core/src/fork/multi.rs | 6 +- crates/evm/core/src/opts.rs | 6 +- crates/evm/core/src/utils.rs | 2 +- crates/evm/evm/Cargo.toml | 9 +- .../evm/evm/src/executors/invariant/error.rs | 14 +- .../evm/evm/src/executors/invariant/funcs.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 3 +- crates/evm/evm/src/executors/tracing.rs | 4 +- crates/evm/evm/src/inspectors/access_list.rs | 2 +- crates/evm/evm/src/inspectors/logs.rs | 15 +- crates/evm/evm/src/inspectors/stack.rs | 3 +- crates/evm/fuzz/Cargo.toml | 6 +- crates/evm/fuzz/src/lib.rs | 2 +- crates/evm/fuzz/src/strategies/int.rs | 12 +- crates/evm/fuzz/src/strategies/state.rs | 2 +- crates/evm/fuzz/src/strategies/uint.rs | 14 +- crates/evm/traces/Cargo.toml | 14 +- crates/evm/traces/src/lib.rs | 2 +- crates/evm/traces/src/node.rs | 2 +- crates/fmt/Cargo.toml | 11 +- crates/fmt/src/buffer.rs | 5 +- crates/fmt/src/formatter.rs | 4 +- crates/fmt/src/helpers.rs | 6 +- crates/fmt/src/lib.rs | 4 +- crates/fmt/tests/formatter.rs | 6 +- crates/forge/Cargo.toml | 21 +- crates/forge/bin/cmd/bind.rs | 2 +- crates/forge/bin/cmd/cache.rs | 23 +- crates/forge/bin/cmd/create.rs | 13 +- crates/forge/bin/cmd/fmt.rs | 4 +- crates/forge/bin/cmd/fourbyte.rs | 93 ---- crates/forge/bin/cmd/inspect.rs | 30 +- crates/forge/bin/cmd/mod.rs | 1 - crates/forge/bin/cmd/script/broadcast.rs | 8 +- crates/forge/bin/cmd/script/build.rs | 2 +- crates/forge/bin/cmd/script/cmd.rs | 7 +- crates/forge/bin/cmd/script/executor.rs | 2 +- crates/forge/bin/cmd/script/mod.rs | 18 +- crates/forge/bin/cmd/script/multi.rs | 2 +- crates/forge/bin/cmd/script/providers.rs | 2 +- crates/forge/bin/cmd/script/receipts.rs | 3 +- crates/forge/bin/cmd/script/runner.rs | 2 +- crates/forge/bin/cmd/script/sequence.rs | 2 +- crates/forge/bin/cmd/script/transaction.rs | 5 +- crates/forge/bin/cmd/selectors.rs | 20 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 5 +- crates/forge/bin/main.rs | 1 - crates/forge/bin/opts.rs | 6 - crates/forge/src/result.rs | 2 +- crates/forge/tests/cli/cmd.rs | 19 +- crates/forge/tests/cli/create.rs | 2 +- crates/forge/tests/cli/script.rs | 50 +- crates/forge/tests/cli/utils.rs | 3 +- crates/forge/tests/it/invariant.rs | 3 +- crates/forge/tests/it/repros.rs | 2 +- crates/macros/Cargo.toml | 1 + crates/test-utils/Cargo.toml | 9 +- crates/test-utils/src/script.rs | 3 +- crates/utils/Cargo.toml | 12 +- crates/utils/src/abi.rs | 415 +-------------- crates/utils/src/lib.rs | 77 +-- crates/utils/src/types.rs | 41 +- 147 files changed, 1106 insertions(+), 1927 deletions(-) delete mode 100644 crates/forge/bin/cmd/fourbyte.rs diff --git a/Cargo.lock b/Cargo.lock index 9f4fadf97867f..2a8f56e8833f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", "version_check", ] @@ -120,7 +120,7 @@ dependencies = [ "derive_arbitrary", "derive_more", "ethereum_ssz", - "getrandom 0.2.10", + "getrandom 0.2.11", "hex-literal", "itoa", "proptest", @@ -951,6 +951,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-rlp", "async-trait", "chrono", "clap", @@ -961,10 +962,11 @@ dependencies = [ "criterion", "dunce", "eth-keystore", - "ethers", + "ethers-contract", "ethers-core", - "ethers-etherscan", + "ethers-middleware", "ethers-providers", + "ethers-signers", "evm-disassembler", "eyre", "foundry-block-explorers", @@ -1034,7 +1036,7 @@ dependencies = [ "clap", "criterion", "dirs 5.0.1", - "ethers", + "ethers-core", "eyre", "forge-fmt", "foundry-cli", @@ -1269,7 +1271,7 @@ dependencies = [ "byteorder", "cfg-if", "futures", - "getrandom 0.2.10", + "getrandom 0.2.11", "hex", "hidapi-rusb", "js-sys", @@ -1930,9 +1932,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2045,7 +2047,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2060,7 +2062,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "ethers-core", "once_cell", @@ -2071,7 +2073,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2089,7 +2091,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "Inflector", "const-hex", @@ -2112,7 +2114,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "Inflector", "const-hex", @@ -2127,7 +2129,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "arrayvec", "bytes", @@ -2156,11 +2158,10 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "chrono", "ethers-core", - "ethers-solc", "reqwest", "semver 1.0.20", "serde", @@ -2172,13 +2173,12 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "async-trait", "auto_impl", "ethers-contract", "ethers-core", - "ethers-etherscan", "ethers-providers", "ethers-signers", "futures-channel", @@ -2198,7 +2198,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "async-trait", "auto_impl", @@ -2236,7 +2236,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "async-trait", "coins-bip32", @@ -2264,7 +2264,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=4f7b354ecec0aea38ed165560ae4f3224d644c9e#4f7b354ecec0aea38ed165560ae4f3224d644c9e" +source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" dependencies = [ "cfg-if", "const-hex", @@ -2490,7 +2490,11 @@ dependencies = [ "criterion", "dialoguer", "dunce", - "ethers", + "ethers-contract", + "ethers-core", + "ethers-middleware", + "ethers-providers", + "ethers-signers", "eyre", "forge-doc", "forge-fmt", @@ -2537,9 +2541,9 @@ dependencies = [ name = "forge-doc" version = "0.2.0" dependencies = [ + "alloy-primitives", "auto_impl", "derive_more", - "ethers-core", "eyre", "forge-fmt", "foundry-compilers", @@ -2614,7 +2618,7 @@ dependencies = [ [[package]] name = "foundry-block-explorers" version = "0.1.0" -source = "git+https://github.com/foundry-rs/block-explorers#3c118b815cb443ac62e0818b18da9f3be5871af0" +source = "git+https://github.com/foundry-rs/block-explorers#6e040684a6b6dfccee52eee02c0958a8436d7bc1" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -2678,7 +2682,9 @@ dependencies = [ "color-eyre", "const-hex", "dotenvy", - "ethers", + "ethers-core", + "ethers-providers", + "ethers-signers", "eyre", "foundry-common", "foundry-compilers", @@ -2796,7 +2802,6 @@ dependencies = [ "globset", "number_prefix", "once_cell", - "open-fastrlp", "path-slash", "pretty_assertions", "regex", @@ -2809,7 +2814,7 @@ dependencies = [ "tempfile", "thiserror", "toml 0.8.8", - "toml_edit 0.20.7", + "toml_edit 0.21.0", "tracing", "walkdir", ] @@ -2822,7 +2827,8 @@ dependencies = [ "crossterm", "eyre", "foundry-common", - "foundry-evm", + "foundry-evm-core", + "foundry-evm-traces", "ratatui", "revm", "tracing", @@ -2835,8 +2841,10 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-sol-types", "const-hex", - "ethers", + "ethers-core", + "ethers-signers", "eyre", "foundry-cheatcodes", "foundry-common", @@ -2865,7 +2873,9 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "const-hex", - "ethers", + "ethers-contract", + "ethers-core", + "ethers-providers", "eyre", "foundry-abi", "foundry-cheatcodes-defs", @@ -2908,7 +2918,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "arbitrary", - "ethers", + "ethers-core", "eyre", "foundry-common", "foundry-compilers", @@ -2920,6 +2930,7 @@ dependencies = [ "hashbrown 0.14.2", "parking_lot", "proptest", + "rand 0.8.5", "revm", "serde", "thiserror", @@ -2935,7 +2946,7 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "const-hex", - "ethers", + "ethers-core", "eyre", "foundry-block-explorers", "foundry-common", @@ -2981,7 +2992,8 @@ name = "foundry-test-utils" version = "0.2.0" dependencies = [ "alloy-primitives", - "ethers", + "ethers-core", + "ethers-providers", "eyre", "fd-lock 4.0.0", "foundry-common", @@ -3006,8 +3018,6 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "dunce", - "ethers-addressbook", - "ethers-contract", "ethers-core", "ethers-providers", "eyre", @@ -3017,7 +3027,6 @@ dependencies = [ "futures", "glob", "once_cell", - "pretty_assertions", "rand 0.8.5", "serde_json", "tracing", @@ -3206,9 +3215,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -3522,9 +3531,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" +checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" dependencies = [ "log", "pest", @@ -4242,9 +4251,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" @@ -4262,6 +4271,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "lru" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60" +dependencies = [ + "hashbrown 0.14.2", +] + [[package]] name = "mac" version = "0.1.1" @@ -5529,7 +5547,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", ] [[package]] @@ -5552,15 +5570,16 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" +checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" dependencies = [ "bitflags 2.4.1", "cassowary", "crossterm", "indoc", "itertools 0.11.0", + "lru", "paste", "strum", "unicode-segmentation", @@ -5611,7 +5630,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "libredox", "thiserror", ] @@ -5814,7 +5833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", - "getrandom 0.2.10", + "getrandom 0.2.11", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -6795,9 +6814,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76657a25d9fbbb0032705172c3ac2f47f45e479f981631aeedf440c338d0f68" +checksum = "aa64b5e8eecd3a8af7cfc311e29db31a268a62d5953233d3e8243ec77a71c4e3" dependencies = [ "build_const", "hex", @@ -7618,7 +7637,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index b666914ce8542..836b5cc4550a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,19 +138,17 @@ foundry-compilers = { version = "0.1", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "3", default-features = false } # +revm = { version = "3", default-features = false } revm-primitives = { version = "1", default-features = false } ## ethers ethers = { version = "2.0", default-features = false } -ethers-addressbook = { version = "2.0", default-features = false } ethers-core = { version = "2.0", default-features = false } ethers-contract = { version = "2.0", default-features = false } ethers-contract-abigen = { version = "2.0", default-features = false } ethers-providers = { version = "2.0", default-features = false } ethers-signers = { version = "2.0", default-features = false } ethers-middleware = { version = "2.0", default-features = false } -ethers-etherscan = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy @@ -160,20 +158,23 @@ alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" +alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc -toml = "0.8" -itertools = "0.11" chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +color-eyre = "0.6" +eyre = "0.6" hex = { package = "const-hex", version = "1.6", features = ["hex"] } +itertools = "0.11" +jsonpath_lib = "0.3" +pretty_assertions = "1.4" protobuf = "=3.2.0" +rand = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } +toml = "0.8" tracing = "0.1" -jsonpath_lib = "0.3" -eyre = "0.6" -color-eyre = "0.6" #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } @@ -188,16 +189,16 @@ color-eyre = "0.6" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "4f7b354ecec0aea38ed165560ae4f3224d644c9e" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 7ad94455d5c0e..36956f9c4c0be 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -322,14 +322,12 @@ impl From
for PartialHeader { #[cfg(test)] mod tests { - use std::str::FromStr; - + use super::*; use ethers_core::{ types::H160, utils::{hex, hex::FromHex}, }; - - use super::*; + use std::str::FromStr; #[test] fn header_rlp_roundtrip() { diff --git a/crates/anvil/core/src/eth/receipt.rs b/crates/anvil/core/src/eth/receipt.rs index cebcd0735f629..1e3d507d197a3 100644 --- a/crates/anvil/core/src/eth/receipt.rs +++ b/crates/anvil/core/src/eth/receipt.rs @@ -274,15 +274,13 @@ mod tests { #[cfg(feature = "fastrlp")] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 fn encode_legacy_receipt() { - use std::str::FromStr; - + use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt}; use ethers_core::{ types::{Bytes, H160, H256}, utils::hex, }; use open_fastrlp::Encodable; - - use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt}; + use std::str::FromStr; let expected = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); @@ -317,15 +315,13 @@ mod tests { #[cfg(feature = "fastrlp")] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 fn decode_legacy_receipt() { - use std::str::FromStr; - + use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt}; use ethers_core::{ types::{Bytes, H160, H256}, utils::hex, }; use open_fastrlp::Decodable; - - use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt}; + use std::str::FromStr; let data = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); diff --git a/crates/anvil/core/src/eth/state.rs b/crates/anvil/core/src/eth/state.rs index 406d59cf72f52..1a1b9da3308a8 100644 --- a/crates/anvil/core/src/eth/state.rs +++ b/crates/anvil/core/src/eth/state.rs @@ -1,6 +1,5 @@ -use std::collections::HashMap; - use ethers_core::types::{Address, Bytes, H256, U256}; +use std::collections::HashMap; #[derive(Clone, Debug, PartialEq, Eq, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index ff31419c3a162..3bc9fef15e259 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -667,9 +667,8 @@ impl FromStr for ForkUrl { #[cfg(test)] mod tests { - use std::{env, net::Ipv4Addr}; - use super::*; + use std::{env, net::Ipv4Addr}; #[test] fn test_parse_fork_url() { diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 95dfc6a064974..867d622a9efac 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1,3 +1,4 @@ +use super::{backend::mem::BlockRequest, sign::build_typed_transaction}; use crate::{ eth::{ backend, @@ -75,8 +76,6 @@ use parking_lot::RwLock; use std::{collections::HashSet, future::Future, sync::Arc, time::Duration}; use tracing::{trace, warn}; -use super::{backend::mem::BlockRequest, sign::build_typed_transaction}; - /// The client version: `anvil/v{major}.{minor}.{patch}` pub const CLIENT_VERSION: &str = concat!("anvil/v", env!("CARGO_PKG_VERSION")); diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index 253acd24f9435..bc7f011da0ec0 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -1,12 +1,11 @@ //! Manages the block time +use crate::eth::error::BlockchainError; use chrono::{DateTime, NaiveDateTime, Utc}; use parking_lot::RwLock; use std::{sync::Arc, time::Duration}; use tracing::trace; -use crate::eth::error::BlockchainError; - /// Returns the `Utc` datetime for the given seconds since unix epoch pub fn utc_from_secs(secs: u64) -> DateTime { DateTime::::from_naive_utc_and_offset( diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 114f407406c75..95a255051ea9c 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -1,20 +1,18 @@ +use super::types::{ + OtsBlockDetails, OtsBlockTransactions, OtsContractCreator, OtsInternalOperation, + OtsSearchTransactions, OtsTrace, +}; use crate::eth::{ error::{BlockchainError, Result}, macros::node_info, EthApi, }; - use ethers::types::{ Action, Address, Block, BlockId, BlockNumber, Bytes, Call, Create, CreateResult, Res, Reward, Transaction, TxHash, H256, U256, U64, }; use itertools::Itertools; -use super::types::{ - OtsBlockDetails, OtsBlockTransactions, OtsContractCreator, OtsInternalOperation, - OtsSearchTransactions, OtsTrace, -}; - impl EthApi { /// Otterscan currently requires this endpoint, even though it's not part of the ots_* /// https://github.com/otterscan/otterscan/blob/071d8c55202badf01804f6f8d53ef9311d4a9e47/src/useProvider.ts#L71 diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 3f49d0df1ce87..1848f0e506437 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -1,3 +1,7 @@ +use crate::eth::{ + backend::mem::{storage::MinedTransaction, Backend}, + error::{BlockchainError, Result}, +}; use alloy_primitives::U256 as rU256; use ethers::types::{ Action, Address, Block, Bytes, CallType, Trace, Transaction, TransactionReceipt, H256, U256, @@ -8,11 +12,6 @@ use futures::future::join_all; use serde::{de::DeserializeOwned, Serialize}; use serde_repr::Serialize_repr; -use crate::eth::{ - backend::mem::{storage::MinedTransaction, Backend}, - error::{BlockchainError, Result}, -}; - /// Patched Block struct, to include the additional `transactionCount` field expected by Otterscan #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase", bound = "TX: Serialize + DeserializeOwned")] diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 5a7e97218ed34..32c6fcf2ba6c5 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -1,5 +1,6 @@ //! general eth api tests +use crate::abi::{MulticallContract, SimpleStorage}; use anvil::{ eth::{api::CLIENT_VERSION, EthApi}, spawn, NodeConfig, CHAIN_ID, @@ -14,8 +15,6 @@ use ethers::{ }; use std::{collections::HashMap, sync::Arc, time::Duration}; -use crate::abi::{MulticallContract, SimpleStorage}; - #[tokio::test(flavor = "multi_thread")] async fn can_get_block_number() { let (api, handle) = spawn(NodeConfig::test()).await; diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs index 78e90e064f0db..4b6f25569c97e 100644 --- a/crates/anvil/tests/it/proof/mod.rs +++ b/crates/anvil/tests/it/proof/mod.rs @@ -1,18 +1,18 @@ //! tests for `eth_getProof` +use crate::proof::eip1186::verify_proof; use anvil::{spawn, NodeConfig}; +use anvil_core::eth::{ + proof::{AccountProof, BasicAccount}, + trie::ExtensionLayout, +}; use ethers::{ abi::ethereum_types::BigEndianHash, types::{Address, H256, U256}, + utils::{keccak256, rlp}, }; - -use anvil_core::eth::proof::{AccountProof, BasicAccount}; -use foundry_utils::types::ToEthers; - -use crate::proof::eip1186::verify_proof; -use anvil_core::eth::trie::ExtensionLayout; -use ethers::utils::{keccak256, rlp}; use foundry_evm::revm::primitives::KECCAK_EMPTY; +use foundry_utils::types::ToEthers; mod eip1186; diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index ee795583b73bf..8a7d1a66ba812 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -180,8 +180,7 @@ async fn test_trace_address_fork() { _ => unreachable!("unexpected action"), } - let json = serde_json::json!( - [ + let json = serde_json::json!([ { "action": { "callType": "call", @@ -219,9 +218,7 @@ async fn test_trace_address_fork() { "output": "0x0000000000000000000000000000000000000000000000e0e82ca52ec6e6a4d3" }, "subtraces": 2, - "traceAddress": [ - 0 - ], + "traceAddress": [0], "transactionHash": "0x3255cce7312e9c4470e1a1883be13718e971f6faafb96199b8bd75e5b7c39e3a", "transactionPosition": 19, "type": "call" @@ -242,10 +239,7 @@ async fn test_trace_address_fork() { "output": "0x0000000000000000000000000000000000000000000000e0e82ca52ec6e6a4d3" }, "subtraces": 0, - "traceAddress": [ - 0, - 0 - ], + "traceAddress": [0, 0], "transactionHash": "0x3255cce7312e9c4470e1a1883be13718e971f6faafb96199b8bd75e5b7c39e3a", "transactionPosition": 19, "type": "call" @@ -266,10 +260,7 @@ async fn test_trace_address_fork() { "output": "0x" }, "subtraces": 2, - "traceAddress": [ - 0, - 1 - ], + "traceAddress": [0, 1], "transactionHash": "0x3255cce7312e9c4470e1a1883be13718e971f6faafb96199b8bd75e5b7c39e3a", "transactionPosition": 19, "type": "call" @@ -290,11 +281,7 @@ async fn test_trace_address_fork() { "output": "0x0000000000000000000000000000000000000000000020fe99f8898600d94750" }, "subtraces": 0, - "traceAddress": [ - 0, - 1, - 0 - ], + "traceAddress": [0, 1, 0], "transactionHash": "0x3255cce7312e9c4470e1a1883be13718e971f6faafb96199b8bd75e5b7c39e3a", "transactionPosition": 19, "type": "call" @@ -315,11 +302,7 @@ async fn test_trace_address_fork() { "output": "0x" }, "subtraces": 1, - "traceAddress": [ - 0, - 1, - 1 - ], + "traceAddress": [0, 1, 1], "transactionHash": "0x3255cce7312e9c4470e1a1883be13718e971f6faafb96199b8bd75e5b7c39e3a", "transactionPosition": 19, "type": "call" @@ -340,18 +323,12 @@ async fn test_trace_address_fork() { "output": "0x0000000000000000000000000000000000000000000000000000000000000001" }, "subtraces": 0, - "traceAddress": [ - 0, - 1, - 1, - 0 - ], + "traceAddress": [0, 1, 1, 0], "transactionHash": "0x3255cce7312e9c4470e1a1883be13718e971f6faafb96199b8bd75e5b7c39e3a", "transactionPosition": 19, "type": "call" } - ] - ); + ]); let expected_traces: Vec = serde_json::from_value(json).unwrap(); @@ -398,253 +375,218 @@ async fn test_trace_address_fork2() { _ => unreachable!("unexpected action"), } - let json = serde_json::json!( - [ - - { - "action": { - "from": "0xa009fa1ac416ec02f6f902a3a4a584b092ae6123", - "callType": "call", - "gas": "0x4fabc", - "input": "0x30000003000000000000000000000000adda1059a6c6c102b0fa562b9bb2cb9a0de5b1f4000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a300000004fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000004319b52bf08b65295d49117e790000000000000000000000000000000000000000000000008b6d9e8818d6141f000000000000000000000000000000000000000000000000000000086a23af210000000000000000000000000000000000000000000000000000000000", - "to": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x1d51b", - "output": "0x" - }, - "subtraces": 1, - "traceAddress": [], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", - "callType": "delegatecall", - "gas": "0x4d594", - "input": "0x00000004fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000004319b52bf08b65295d49117e790000000000000000000000000000000000000000000000008b6d9e8818d6141f000000000000000000000000000000000000000000000000000000086a23af21", - "to": "0xadda1059a6c6c102b0fa562b9bb2cb9a0de5b1f4", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x1c35f", - "output": "0x" - }, - "subtraces": 3, - "traceAddress": [ - 0 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", - "callType": "call", - "gas": "0x4b6d6", - "input": "0x16b2da82000000000000000000000000000000000000000000000000000000086a23af21", - "to": "0xd1663cfb8ceaf22039ebb98914a8c98264643710", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0xd6d", - "output": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - "subtraces": 0, - "traceAddress": [ - 0, - 0 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", - "callType": "staticcall", - "gas": "0x49c35", - "input": "0x3850c7bd", - "to": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0xa88", - "output": "0x000000000000000000000000000000000000004319b52bf08b65295d49117e7900000000000000000000000000000000000000000000000000000000000148a0000000000000000000000000000000000000000000000000000000000000010e000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000012c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" - }, - "subtraces": 0, - "traceAddress": [ - 0, - 1 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", - "callType": "call", - "gas": "0x48d01", - "input": "0x128acb0800000000000000000000000099999999d116ffa7d76590de2f427d8e15aeb0b80000000000000000000000000000000000000000000000000000000000000001fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb98000000000000000000000000000000000000000000000000000000001000276a400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000000000000000000000000000000000", - "to": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x18c20", - "output": "0x0000000000000000000000000000000000000000000000008b5116525f9edc3efffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980" - }, - "subtraces": 4, - "traceAddress": [ - 0, - 2 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "callType": "call", - "gas": "0x3802a", - "input": "0xa9059cbb00000000000000000000000099999999d116ffa7d76590de2f427d8e15aeb0b8000000000000000000000000000000000000000000000986236e1301eaf04680", - "to": "0xf4d2888d29d722226fafa5d9b24f9164c092421e", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x31b6", - "output": "0x0000000000000000000000000000000000000000000000000000000000000001" - }, - "subtraces": 0, - "traceAddress": [ - 0, - 2, - 0 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "callType": "staticcall", - "gas": "0x34237", - "input": "0x70a082310000000000000000000000004b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x9e6", - "output": "0x000000000000000000000000000000000000000000000091cda6c1ce33e53b89" - }, - "subtraces": 0, - "traceAddress": [ - 0, - 2, - 1 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "callType": "call", - "gas": "0x3357e", - "input": "0xfa461e330000000000000000000000000000000000000000000000008b5116525f9edc3efffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb9800000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000000000000000000000000000000000", - "to": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x2e8b", - "output": "0x" - }, - "subtraces": 1, - "traceAddress": [ - 0, - 2, - 2 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", - "callType": "call", - "gas": "0x324db", - "input": "0xa9059cbb0000000000000000000000004b5ab61593a2401b1075b90c04cbcdd3f87ce0110000000000000000000000000000000000000000000000008b5116525f9edc3e", - "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x2a6e", - "output": "0x0000000000000000000000000000000000000000000000000000000000000001" - }, - "subtraces": 0, - "traceAddress": [ - 0, - 2, - 2, - 0 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - }, - { - "action": { - "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "callType": "staticcall", - "gas": "0x30535", - "input": "0x70a082310000000000000000000000004b5ab61593a2401b1075b90c04cbcdd3f87ce011", - "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", - "value": "0x0" - }, - "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", - "blockNumber": 15314402, - "result": { - "gasUsed": "0x216", - "output": "0x00000000000000000000000000000000000000000000009258f7d820938417c7" - }, - "subtraces": 0, - "traceAddress": [ - 0, - 2, - 3 - ], - "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", - "transactionPosition": 289, - "type": "call" - } - ] - ); + let json = serde_json::json!([ + { + "action": { + "from": "0xa009fa1ac416ec02f6f902a3a4a584b092ae6123", + "callType": "call", + "gas": "0x4fabc", + "input": "0x30000003000000000000000000000000adda1059a6c6c102b0fa562b9bb2cb9a0de5b1f4000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a300000004fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000004319b52bf08b65295d49117e790000000000000000000000000000000000000000000000008b6d9e8818d6141f000000000000000000000000000000000000000000000000000000086a23af210000000000000000000000000000000000000000000000000000000000", + "to": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x1d51b", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", + "callType": "delegatecall", + "gas": "0x4d594", + "input": "0x00000004fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000004319b52bf08b65295d49117e790000000000000000000000000000000000000000000000008b6d9e8818d6141f000000000000000000000000000000000000000000000000000000086a23af21", + "to": "0xadda1059a6c6c102b0fa562b9bb2cb9a0de5b1f4", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x1c35f", + "output": "0x" + }, + "subtraces": 3, + "traceAddress": [0], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", + "callType": "call", + "gas": "0x4b6d6", + "input": "0x16b2da82000000000000000000000000000000000000000000000000000000086a23af21", + "to": "0xd1663cfb8ceaf22039ebb98914a8c98264643710", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0xd6d", + "output": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + "subtraces": 0, + "traceAddress": [0, 0], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", + "callType": "staticcall", + "gas": "0x49c35", + "input": "0x3850c7bd", + "to": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0xa88", + "output": "0x000000000000000000000000000000000000004319b52bf08b65295d49117e7900000000000000000000000000000000000000000000000000000000000148a0000000000000000000000000000000000000000000000000000000000000010e000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000012c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 0, + "traceAddress": [0, 1], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", + "callType": "call", + "gas": "0x48d01", + "input": "0x128acb0800000000000000000000000099999999d116ffa7d76590de2f427d8e15aeb0b80000000000000000000000000000000000000000000000000000000000000001fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb98000000000000000000000000000000000000000000000000000000001000276a400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000000000000000000000000000000000", + "to": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x18c20", + "output": "0x0000000000000000000000000000000000000000000000008b5116525f9edc3efffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980" + }, + "subtraces": 4, + "traceAddress": [0, 2], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "callType": "call", + "gas": "0x3802a", + "input": "0xa9059cbb00000000000000000000000099999999d116ffa7d76590de2f427d8e15aeb0b8000000000000000000000000000000000000000000000986236e1301eaf04680", + "to": "0xf4d2888d29d722226fafa5d9b24f9164c092421e", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x31b6", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 0, + "traceAddress": [0, 2, 0], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "callType": "staticcall", + "gas": "0x34237", + "input": "0x70a082310000000000000000000000004b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x9e6", + "output": "0x000000000000000000000000000000000000000000000091cda6c1ce33e53b89" + }, + "subtraces": 0, + "traceAddress": [0, 2, 1], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "callType": "call", + "gas": "0x3357e", + "input": "0xfa461e330000000000000000000000000000000000000000000000008b5116525f9edc3efffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb9800000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000000000000000000000000000000000", + "to": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x2e8b", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [0, 2, 2], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x99999999d116ffa7d76590de2f427d8e15aeb0b8", + "callType": "call", + "gas": "0x324db", + "input": "0xa9059cbb0000000000000000000000004b5ab61593a2401b1075b90c04cbcdd3f87ce0110000000000000000000000000000000000000000000000008b5116525f9edc3e", + "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x2a6e", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 0, + "traceAddress": [0, 2, 2, 0], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + }, + { + "action": { + "from": "0x4b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "callType": "staticcall", + "gas": "0x30535", + "input": "0x70a082310000000000000000000000004b5ab61593a2401b1075b90c04cbcdd3f87ce011", + "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "value": "0x0" + }, + "blockHash": "0xf689ba7749648b8c5c8f5eedd73001033f0aed7ea50b7c81048ad1533b8d3d73", + "blockNumber": 15314402, + "result": { + "gasUsed": "0x216", + "output": "0x00000000000000000000000000000000000000000000009258f7d820938417c7" + }, + "subtraces": 0, + "traceAddress": [0, 2, 3], + "transactionHash": "0x2d951c5c95d374263ca99ad9c20c9797fc714330a8037429a3aa4c83d456f845", + "transactionPosition": 289, + "type": "call" + } + ]); let expected_traces: Vec = serde_json::from_value(json).unwrap(); diff --git a/crates/binder/Cargo.toml b/crates/binder/Cargo.toml index aa8c3681ead9b..29a127268ca04 100644 --- a/crates/binder/Cargo.toml +++ b/crates/binder/Cargo.toml @@ -15,6 +15,6 @@ foundry-config.workspace = true ethers-contract = { workspace = true, features = ["abigen"] } eyre.workspace = true git2 = { version = "0.18", default-features = false } -url = "2" -tracing.workspace = true tempfile = "3" +tracing.workspace = true +url = "2" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 43cf2497fd4b3..a894641ef8358 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -19,21 +19,20 @@ vergen = { version = "8", default-features = false, features = ["build", "git", [dependencies] # lib -foundry-utils.workspace = true -foundry-evm.workspace = true -foundry-config.workspace = true +foundry-block-explorers = { workspace = true } foundry-common.workspace = true +foundry-compilers = { workspace = true, default-features = false } +foundry-config.workspace = true +foundry-evm.workspace = true +foundry-utils.workspace = true -ethers-etherscan.workspace = true -ethers-core.workspace = true -ethers-providers.workspace = true - -alloy-primitives.workspace = true -alloy-json-abi.workspace = true alloy-dyn-abi.workspace = true +alloy-json-abi.workspace = true +alloy-primitives.workspace = true +alloy-rlp.workspace = true -foundry-compilers = { workspace = true, default-features = false } -foundry-block-explorers = { workspace = true } +ethers-core.workspace = true +ethers-providers.workspace = true chrono.workspace = true evm-disassembler = "0.3" @@ -41,19 +40,19 @@ eyre.workspace = true futures = "0.3" hex.workspace = true rayon = "1" -serde.workspace = true serde_json.workspace = true +serde.workspace = true # aws rusoto_core = { version = "0.48", default-features = false } rusoto_kms = { version = "0.48", default-features = false } # bin -# foundry internal foundry-cli.workspace = true -# eth -ethers = { workspace = true, features = ["rustls"] } +ethers-contract.workspace = true +ethers-middleware.workspace = true +ethers-signers.workspace = true eth-keystore = "0.5" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 0a0c12738fe6b..9ac2656607641 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -1,9 +1,7 @@ use cast::{Cast, TxBuilder}; use clap::Parser; -use ethers::{ - providers::Middleware, - types::{BlockId, NameOrAddress}, -}; +use ethers_core::types::{BlockId, NameOrAddress}; +use ethers_providers::Middleware; use eyre::{Result, WrapErr}; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, diff --git a/crates/cast/bin/cmd/bind.rs b/crates/cast/bin/cmd/bind.rs index 16794711b0eed..a0716f3cd1a68 100644 --- a/crates/cast/bin/cmd/bind.rs +++ b/crates/cast/bin/cmd/bind.rs @@ -1,6 +1,7 @@ use clap::{Parser, ValueHint}; -use ethers::prelude::{errors::EtherscanError, Abigen, Client, MultiAbigen}; +use ethers_contract::{Abigen, MultiAbigen}; use eyre::Result; +use foundry_block_explorers::{errors::EtherscanError, Client}; use foundry_cli::opts::EtherscanOpts; use foundry_config::Config; use std::path::{Path, PathBuf}; diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 5696937c2be6d..a394c6421941d 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,7 +1,7 @@ use alloy_primitives::U256; use cast::{Cast, TxBuilder}; use clap::Parser; -use ethers::types::{BlockId, NameOrAddress}; +use ethers_core::types::{BlockId, NameOrAddress}; use eyre::{Result, WrapErr}; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, @@ -14,7 +14,7 @@ use foundry_evm::{executors::TracingExecutor, opts::EvmOpts}; use foundry_utils::types::{ToAlloy, ToEthers}; use std::str::FromStr; -type Provider = ethers::providers::Provider; +type Provider = ethers_providers::Provider; /// CLI arguments for `cast call`. #[derive(Debug, Parser)] @@ -205,11 +205,7 @@ impl CallArgs { } }; - let builder_output: ( - ethers::types::transaction::eip2718::TypedTransaction, - Option, - ) = builder.build(); - + let builder_output = builder.build(); println!("{}", Cast::new(provider).call(builder_output, block).await?); Ok(()) @@ -263,7 +259,7 @@ async fn fill_tx( #[cfg(test)] mod tests { use super::*; - use ethers::types::Address; + use alloy_primitives::Address; #[test] fn can_parse_call_data() { @@ -279,10 +275,10 @@ mod tests { #[test] fn call_sig_and_data_exclusive() { let data = hex::encode("hello"); - let to = Address::zero(); + let to = Address::ZERO; let args = CallArgs::try_parse_from([ "foundry-cli", - format!("{to:?}").as_str(), + to.to_string().as_str(), "signature", "--data", format!("0x{data}").as_str(), diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index d21eec50fd54a..94493c3c76bd9 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,7 +1,7 @@ use alloy_primitives::U256; use cast::{Cast, TxBuilder}; use clap::Parser; -use ethers::types::NameOrAddress; +use ethers_core::types::NameOrAddress; use eyre::Result; use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index ac67a412f9e3d..b49667ce83191 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -1,9 +1,10 @@ use cast::{AbiPath, SimpleCast}; use clap::Parser; -use eyre::Result; +use eyre::{Context, Result}; use foundry_cli::opts::EtherscanOpts; use foundry_common::fs; use foundry_config::Config; +use itertools::Itertools; use std::path::{Path, PathBuf}; /// CLI arguments for `cast interface`. @@ -19,7 +20,7 @@ pub struct InterfaceArgs { name: Option, /// Solidity pragma version. - #[clap(long, short, default_value = "^0.8.10", value_name = "VERSION")] + #[clap(long, short, default_value = "^0.8.4", value_name = "VERSION")] pragma: String, /// The path to the output file. @@ -51,37 +52,43 @@ impl InterfaceArgs { etherscan, json, } = self; - let config = Config::from(ðerscan); - let chain = config.chain_id.unwrap_or_default(); let source = if Path::new(&path_or_address).exists() { AbiPath::Local { path: path_or_address, name } } else { + let config = Config::from(ðerscan); + let chain = config.chain_id.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); let chain = chain.named()?; - AbiPath::Etherscan { chain, api_key, address: path_or_address.parse()? } + AbiPath::Etherscan { + chain, + api_key, + address: path_or_address.parse().wrap_err("invalid path or address")?, + } }; + let interfaces = SimpleCast::generate_interface(source).await?; // put it all together let res = if json { - interfaces.into_iter().map(|iface| iface.json_abi).collect::>().join("\n") + interfaces.iter().map(|iface| &iface.json_abi).format("\n").to_string() } else { - let pragma = format!("pragma solidity {pragma};"); - let interfaces = interfaces - .iter() - .map(|iface| iface.source.to_string()) - .collect::>() - .join("\n"); - format!("{pragma}\n\n{interfaces}") + format!( + "// SPDX-License-Identifier: UNLICENSED\n\ + pragma solidity {pragma};\n\n\ + {}", + interfaces.iter().map(|iface| &iface.source).format("\n") + ) }; // print or write to file if let Some(loc) = output_location { - fs::create_dir_all(loc.parent().unwrap())?; + if let Some(parent) = loc.parent() { + fs::create_dir_all(parent)?; + } fs::write(&loc, res)?; println!("Saved interface at {}", loc.display()); } else { - println!("{res}"); + print!("{res}"); } Ok(()) } diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index c4145dbee5d1b..65643968d959a 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -1,13 +1,15 @@ use cast::Cast; use clap::Parser; -use ethers::{providers::Middleware, types::NameOrAddress}; use ethers_core::{ abi::{ token::{LenientTokenizer, StrictTokenizer, Tokenizer}, Address, Event, HumanReadableParser, ParamType, RawTopicFilter, Token, Topic, TopicFilter, }, - types::{BlockId, BlockNumber, Filter, FilterBlockOption, ValueOrArray, H256, U256}, + types::{ + BlockId, BlockNumber, Filter, FilterBlockOption, NameOrAddress, ValueOrArray, H256, U256, + }, }; +use ethers_providers::Middleware; use eyre::{Result, WrapErr}; use foundry_cli::{opts::EthereumOpts, utils}; use foundry_config::Config; @@ -284,8 +286,7 @@ pub fn sanitize_token(token: Token) -> Token { #[cfg(test)] mod tests { use super::*; - use ethers::types::H160; - use ethers_core::types::H256; + use ethers_core::types::{H160, H256}; use std::str::FromStr; const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index b360267e04bb2..f4b4260a1e2ba 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,6 +1,6 @@ use alloy_primitives::U256; use clap::Parser; -use ethers::prelude::Middleware; +use ethers_providers::Middleware; use eyre::{Result, WrapErr}; use foundry_cli::{ init_progress, diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 25d8a1a0f9c8d..f30221ddb0331 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -1,8 +1,9 @@ use cast::{Cast, TxBuilder}; use clap::Parser; -use ethers::{ - prelude::MiddlewareBuilder, providers::Middleware, signers::Signer, types::NameOrAddress, -}; +use ethers_core::types::NameOrAddress; +use ethers_middleware::MiddlewareBuilder; +use ethers_providers::Middleware; +use ethers_signers::Signer; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 2169df9835ace..9981b96f2c099 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -3,11 +3,11 @@ use alloy_primitives::{B256, U256}; use cast::Cast; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; -use ethers::{ +use ethers_core::{ abi::ethabi::ethereum_types::BigEndianHash, - prelude::{BlockId, NameOrAddress}, - providers::Middleware, + types::{BlockId, NameOrAddress}, }; +use ethers_providers::Middleware; use eyre::Result; use foundry_block_explorers::Client; use foundry_cli::{ @@ -24,10 +24,7 @@ use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, impl_figment_convert_cast, Config, }; -use foundry_utils::{ - resolve_addr, - types::{ToAlloy, ToEthers}, -}; +use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future::join_all; use semver::Version; use std::str::FromStr; @@ -132,8 +129,10 @@ impl StorageArgs { let chain = utils::get_chain(config.chain_id, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); let client = Client::new(chain.named()?, api_key)?; - let addr = resolve_addr(address.clone(), Some(chain.named()?))?; - let addr = addr.as_address().ok_or(eyre::eyre!("Could not resolve address"))?.to_alloy(); + let addr = address + .as_address() + .ok_or_else(|| eyre::eyre!("Could not resolve address"))? + .to_alloy(); let source = find_source(client, addr).await?; let metadata = source.items.first().unwrap(); if metadata.is_vyper() { diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 548a406437e99..bbbdf0e8decab 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,14 +1,14 @@ use alloy_primitives::Address; use clap::Parser; -use ethers::{ - core::rand::thread_rng, - signers::{ - coins_bip39::{English, Mnemonic}, - LocalWallet, MnemonicBuilder, Signer, - }, +use ethers_core::{ + rand::thread_rng, types::{transaction::eip712::TypedData, Signature}, + utils::to_checksum, +}; +use ethers_signers::{ + coins_bip39::{English, Mnemonic}, + LocalWallet, MnemonicBuilder, Signer, }; -use ethers_core::utils::to_checksum; use eyre::{Context, Result}; use foundry_cli::opts::{RawWallet, Wallet}; use foundry_common::fs; diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 2fbde4cca421c..012104bb15a64 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,10 +1,7 @@ use alloy_primitives::Address; use clap::{builder::TypedValueParser, Parser}; -use ethers::{ - core::{k256::ecdsa::SigningKey, rand}, - prelude::{LocalWallet, Signer}, - utils::secret_key_to_address, -}; +use ethers_core::{k256::ecdsa::SigningKey, rand, utils::secret_key_to_address}; +use ethers_signers::{LocalWallet, Signer}; use eyre::Result; use foundry_utils::types::ToAlloy; use rayon::iter::{self, ParallelIterator}; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index f842ab10e1b29..e268435d0d113 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -2,10 +2,8 @@ use alloy_primitives::{keccak256, Address, B256}; use cast::{Cast, SimpleCast}; use clap::{CommandFactory, Parser}; use clap_complete::generate; -use ethers::{ - core::types::{BlockId, BlockNumber::Latest}, - providers::Middleware, -}; +use ethers_core::types::{BlockId, BlockNumber::Latest}; +use ethers_providers::Middleware; use eyre::Result; use foundry_cli::{handler, prompt, stdin, utils}; use foundry_common::{ diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index d5f0315ef8ed3..40db2fb0ce847 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -5,7 +5,7 @@ use crate::cmd::{ }; use alloy_primitives::{Address, B256, U256}; use clap::{Parser, Subcommand, ValueHint}; -use ethers::types::{BlockId, NameOrAddress}; +use ethers_core::types::{BlockId, NameOrAddress}; use eyre::Result; use foundry_cli::opts::{EtherscanOpts, RpcOpts}; use foundry_common::serde_helpers::Numeric; @@ -368,7 +368,7 @@ pub enum Subcommands { /// The nonce of the deployer address. #[clap(long)] - nonce: Option, + nonce: Option, #[clap(flatten)] rpc: RpcOpts, @@ -883,7 +883,7 @@ pub fn parse_slot(s: &str) -> Result { mod tests { use super::*; use cast::SimpleCast; - use ethers::types::BlockNumber; + use ethers_core::types::BlockNumber; #[test] fn parse_call_data() { diff --git a/crates/cast/src/base.rs b/crates/cast/src/base.rs index 5ec41d04d6059..2b412878a20ff 100644 --- a/crates/cast/src/base.rs +++ b/crates/cast/src/base.rs @@ -1,13 +1,10 @@ -use ethers_core::{ - abi::ethereum_types::FromStrRadixErrKind, - types::{Sign, I256, U256}, - utils::ParseUnits, -}; +use alloy_primitives::{Sign, I256, U256}; +use ethers_core::utils::ParseUnits; use eyre::Result; +use foundry_utils::types::ToAlloy; use std::{ convert::Infallible, fmt::{Binary, Debug, Display, Formatter, LowerHex, Octal, Result as FmtResult, UpperHex}, - iter::FromIterator, num::IntErrorKind, str::FromStr, }; @@ -89,7 +86,7 @@ impl TryFrom for Base { type Error = eyre::Report; fn try_from(n: U256) -> Result { - Self::try_from(n.low_u32()) + Self::try_from(n.saturating_to::()) } } @@ -99,18 +96,6 @@ impl From for u32 { } } -impl From for I256 { - fn from(b: Base) -> Self { - Self::from(b as u32) - } -} - -impl From for U256 { - fn from(b: Base) -> Self { - Self::from(b as u32) - } -} - impl From for String { fn from(b: Base) -> Self { b.to_string() @@ -137,50 +122,36 @@ impl Base { // anyway; // strip prefix when using u128::from_str_radix because it does not recognize it as // valid. - _ if s.starts_with("0b") => match u128::from_str_radix(&s[2..], 2) { + _ if s.starts_with("0b") => match u64::from_str_radix(&s[2..], 2) { Ok(_) => Ok(Self::Binary), Err(e) => match e.kind() { IntErrorKind::PosOverflow => Ok(Self::Binary), _ => Err(eyre::eyre!("could not parse binary value: {}", e)), }, }, - _ if s.starts_with("0o") => match u128::from_str_radix(&s[2..], 8) { + _ if s.starts_with("0o") => match u64::from_str_radix(&s[2..], 8) { Ok(_) => Ok(Self::Octal), Err(e) => match e.kind() { IntErrorKind::PosOverflow => Ok(Self::Octal), - _ => Err(eyre::eyre!("could not parse octal value: {}", e)), + _ => Err(eyre::eyre!("could not parse octal value: {e}")), }, }, - _ if s.starts_with("0x") => match U256::from_str_radix(s, 16) { + _ if s.starts_with("0x") => match u64::from_str_radix(&s[2..], 16) { Ok(_) => Ok(Self::Hexadecimal), Err(e) => match e.kind() { - FromStrRadixErrKind::InvalidLength => { - Err(eyre::eyre!("number must be less than U256::MAX ({})", U256::MAX)) - } - _ => Err(eyre::eyre!("could not parse hexadecimal value: {}", e)), + IntErrorKind::PosOverflow => Ok(Self::Hexadecimal), + _ => Err(eyre::eyre!("could not parse hexadecimal value: {e}")), }, }, // No prefix => first try parsing as decimal _ => match U256::from_str_radix(s, 10) { - Ok(_) => { - // Can be both, ambiguous but default to Decimal - - // Err(eyre::eyre!("Could not autodetect base: input could be decimal or - // hexadecimal. Please prepend with 0x if the input is hexadecimal, or specify a - // --base-in parameter.")) - Ok(Self::Decimal) - } + // Can be both, ambiguous but default to Decimal + Ok(_) => Ok(Self::Decimal), Err(_) => match U256::from_str_radix(s, 16) { Ok(_) => Ok(Self::Hexadecimal), - Err(e) => match e.kind() { - FromStrRadixErrKind::InvalidLength => { - Err(eyre::eyre!("number must be less than U256::MAX ({})", U256::MAX)) - } - _ => Err(eyre::eyre!( - "could not autodetect base as neither decimal or hexadecimal: {}", - e - )), - }, + Err(e) => Err(eyre::eyre!( + "could not autodetect base as neither decimal or hexadecimal: {e}" + )), }, }, } @@ -189,10 +160,10 @@ impl Base { /// Returns the Rust standard prefix for a base pub const fn prefix(&self) -> &str { match self { - Base::Binary => "0b", - Base::Octal => "0o", - Base::Hexadecimal => "0x", - _ => "", + Self::Binary => "0b", + Self::Octal => "0o", + Self::Decimal => "", + Self::Hexadecimal => "0x", } } } @@ -205,7 +176,7 @@ impl Base { /// /// ``` /// use cast::base::NumberWithBase; -/// use ethers_core::types::U256; +/// use alloy_primitives::U256; /// /// let number: NumberWithBase = U256::from(12345).into(); /// assert_eq!(number.format(), "12345"); @@ -287,7 +258,7 @@ impl LowerHex for NumberWithBase { impl UpperHex for NumberWithBase { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - let n = format!("{:X}", self.number); + let n = format!("{self:x}").to_uppercase(); f.pad_integral(true, Base::Hexadecimal.prefix(), &n) } } @@ -310,8 +281,8 @@ impl From for NumberWithBase { impl From for NumberWithBase { fn from(value: ParseUnits) -> Self { match value { - ParseUnits::U256(val) => val.into(), - ParseUnits::I256(val) => val.into(), + ParseUnits::U256(val) => val.to_alloy().into(), + ParseUnits::I256(val) => val.to_alloy().into(), } } } @@ -402,10 +373,9 @@ impl NumberWithBase { /// signs or padding. Refer to the [std::fmt] module documentation on how to format this /// number with the aforementioned properties. pub fn format(&self) -> String { - match self.base { - // Binary and Octal traits are not implemented for primitive-types types, so we're using - // a custom formatter - Base::Binary | Base::Octal => self.format_radix(), + let s = match self.base { + Base::Binary => format!("{:b}", self.number), + Base::Octal => format!("{:o}", self.number), Base::Decimal => { if self.is_nonnegative { self.number.to_string() @@ -415,53 +385,32 @@ impl NumberWithBase { } } Base::Hexadecimal => format!("{:x}", self.number), + }; + if s.starts_with('0') { + s.trim_start_matches('0').to_string() + } else { + s } } - /// Constructs a String from every digit of the number using [std::char::from_digit]. - /// - /// Modified from: https://stackoverflow.com/a/50278316 - fn format_radix(&self) -> String { - let mut x = self.number; - let radix = self.base as u32; - let r = U256::from(radix); - - let mut buf = ['\0'; 256]; - let mut i = 255; - loop { - let m = (x % r).low_u64() as u32; - // radix is always less than 37 so from_digit cannot panic - // m is always in the radix's range so unwrap cannot panic - buf[i] = char::from_digit(m, radix).unwrap(); - x /= r; - if x.is_zero() { - break - } - i -= 1; - } - String::from_iter(&buf[i..]) - } - fn _parse_int(s: &str, base: Base) -> Result<(U256, bool)> { let (s, sign) = get_sign(s); let mut n = Self::_parse_uint(s, base)?; let is_neg = matches!(sign, Sign::Negative); if is_neg { - n = (!n).overflowing_add(U256::one()).0; + n = (!n).overflowing_add(U256::from(1)).0; } Ok((n, !is_neg)) } fn _parse_uint(s: &str, base: Base) -> Result { - // TODO: Parse from binary or octal str into U256, requires a parser - U256::from_str_radix(s, base as u32).map_err(|e| match e.kind() { - FromStrRadixErrKind::UnsupportedRadix => { - eyre::eyre!("numbers in base {} are currently not supported as input", base) - } - _ => eyre::eyre!(e), - }) + let s = match s.get(0..2) { + Some("0x" | "0X" | "0o" | "0O" | "0b" | "0B") => &s[2..], + _ => s, + }; + U256::from_str_radix(s, base as u64).map_err(Into::into) } } @@ -479,8 +428,8 @@ pub trait ToBase { /// # Example /// /// ``` + /// use alloy_primitives::U256; /// use cast::base::{Base, ToBase}; - /// use ethers_core::types::U256; /// /// // Any type that implements ToBase /// let number = U256::from(12345); @@ -665,9 +614,9 @@ mod tests { let def: Base = Default::default(); assert!(matches!(def, Decimal)); - let n: NumberWithBase = U256::zero().into(); + let n: NumberWithBase = U256::ZERO.into(); assert!(matches!(n.base, Decimal)); - let n: NumberWithBase = I256::zero().into(); + let n: NumberWithBase = I256::ZERO.into(); assert!(matches!(n.base, Decimal)); } @@ -719,7 +668,7 @@ mod tests { let expected_u16: Vec<_> = POS_NUM.iter().map(|n| format!("{n:X}")).collect(); for (i, n) in POS_NUM.into_iter().enumerate() { - let mut num: NumberWithBase = I256::from(n).into(); + let mut num: NumberWithBase = I256::try_from(n).unwrap().into(); assert_eq!(num.set_base(Binary).format(), expected_2[i]); assert_eq!(num.set_base(Octal).format(), expected_8[i]); @@ -743,7 +692,7 @@ mod tests { let expected_u16: Vec<_> = NEG_NUM.iter().map(|n| format!("{n:F>64X}")).collect(); for (i, n) in NEG_NUM.into_iter().enumerate() { - let mut num: NumberWithBase = I256::from(n).into(); + let mut num: NumberWithBase = I256::try_from(n).unwrap().into(); assert_eq!(num.set_base(Binary).format(), expected_2[i]); // assert_eq!(num.set_base(Octal).format(), expected_8[i]); @@ -756,7 +705,7 @@ mod tests { #[test] fn test_fmt_macro() { let nums: Vec<_> = - POS_NUM.into_iter().map(|n| NumberWithBase::from(I256::from(n))).collect(); + POS_NUM.into_iter().map(|n| NumberWithBase::from(I256::try_from(n).unwrap())).collect(); let actual_2: Vec<_> = nums.iter().map(|n| format!("{n:b}")).collect(); let actual_2_alt: Vec<_> = nums.iter().map(|n| format!("{n:#b}")).collect(); diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 376ad966d9c76..c66edd80477d5 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1,31 +1,24 @@ -use crate::rlp_converter::Item; use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; -use alloy_json_abi::Function; +use alloy_json_abi::{ContractObject, Function}; use alloy_primitives::{Address, I256, U256}; +use alloy_rlp::Decodable; use base::{Base, NumberWithBase, ToBase}; use chrono::NaiveDateTime; use ethers_core::{ - abi::RawAbi, types::{transaction::eip2718::TypedTransaction, Chain, *}, utils::{ - format_bytes32_string, format_units, get_contract_address, keccak256, parse_bytes32_string, - parse_units, rlp, Units, + format_bytes32_string, format_units, keccak256, parse_bytes32_string, parse_units, rlp, + Units, }, }; use ethers_providers::{Middleware, PendingTransaction, PubsubClient}; use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; use eyre::{Context, ContextCompat, Result}; -use foundry_block_explorers::{errors::EtherscanError, Client}; +use foundry_block_explorers::Client; use foundry_common::{abi::encode_function_args, fmt::*, TransactionReceiptWithRevertReason}; -pub use foundry_evm::*; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; -pub use rusoto_core::{ - credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, - request::HttpClient as AwsHttpClient, Client as AwsClient, -}; -pub use rusoto_kms::KmsClient; use std::{ io, path::PathBuf, @@ -33,14 +26,23 @@ use std::{ sync::atomic::{AtomicBool, Ordering}, }; use tokio::signal::ctrl_c; -pub use tx::TxBuilder; use tx::{TxBuilderOutput, TxBuilderPeekOutput}; +pub use foundry_evm::*; +pub use rusoto_core::{ + credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, + request::HttpClient as AwsHttpClient, Client as AwsClient, +}; +pub use rusoto_kms::KmsClient; +pub use tx::TxBuilder; + pub mod base; pub mod errors; mod rlp_converter; mod tx; +use rlp_converter::Item; + // TODO: CastContract with common contract initializers? Same for CastProviders? pub struct Cast { @@ -73,7 +75,7 @@ where /// /// # Example /// - /// ```no_run + /// ``` /// use cast::{Cast, TxBuilder}; /// use ethers_core::types::{Address, Chain}; /// use ethers_providers::{Http, Provider}; @@ -469,14 +471,14 @@ where /// /// ```no_run /// use cast::Cast; - /// use ethers::types::NameOrAddress; + /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let cast = Cast::new(provider); - /// let addr = NameOrAddress::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; + /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; /// let nonce = cast.nonce(addr, None).await?; /// println!("{}", nonce); /// # Ok(()) @@ -486,8 +488,8 @@ where &self, who: T, block: Option, - ) -> Result { - Ok(self.provider.get_transaction_count(who, block).await?.to_alloy()) + ) -> Result { + Ok(self.provider.get_transaction_count(who, block).await?.to_alloy().to()) } /// # Example @@ -553,38 +555,22 @@ where /// ```no_run /// use alloy_primitives::{Address, U256}; /// use cast::Cast; - /// use ethers::types::NameOrAddress; /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; /// let cast = Cast::new(provider); - /// let nonce_addr = NameOrAddress::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; /// let addr = Address::from_str("7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; - /// let nonce = cast.nonce(nonce_addr, None).await? + U256::from(5); - /// let computed_address = cast.compute_address(addr, Some(nonce)).await?; - /// println!("Computed address for address {} with nonce {}: {}", addr, nonce, computed_address); - /// let computed_address_no_nonce = cast.compute_address(addr, None).await?; - /// println!( - /// "Computed address for address {} with nonce {}: {}", - /// addr, nonce, computed_address_no_nonce - /// ); + /// let computed_address = cast.compute_address(addr, None).await?; + /// println!("Computed address for address {addr}: {computed_address}"); /// # Ok(()) /// # } /// ``` - pub async fn compute_address + Copy + Send + Sync>( - &self, - address: T, - nonce: Option, - ) -> Result
{ - let unpacked = if let Some(n) = nonce { - n - } else { - self.provider.get_transaction_count(address.into().to_ethers(), None).await?.to_alloy() - }; - - Ok(get_contract_address(address.into().to_ethers(), unpacked.to_ethers()).to_alloy()) + pub async fn compute_address(&self, address: Address, nonce: Option) -> Result
{ + let unpacked = + if let Some(n) = nonce { n } else { self.nonce(address.to_ethers(), None).await? }; + Ok(address.create(unpacked)) } /// # Example @@ -1126,7 +1112,7 @@ impl SimpleCast { let value_len = value_stripped.len(); (sign, value_stripped, value_len) }; - let decimals = NumberWithBase::parse_uint(decimals, None)?.number().low_u64() as usize; + let decimals = NumberWithBase::parse_uint(decimals, None)?.number().to::(); let value = if decimals >= value_len { // Add "0." and pad with 0s @@ -1294,8 +1280,7 @@ impl SimpleCast { /// # Ok::<_, eyre::Report>(()) /// ``` pub fn from_wei(value: &str, unit: &str) -> Result { - let value = NumberWithBase::parse_int(value, None)?.number(); - + let value = NumberWithBase::parse_int(value, None)?.number().to_ethers(); Ok(match unit { "gwei" => format_units(value, 9), _ => format_units(value, 18), @@ -1339,7 +1324,7 @@ impl SimpleCast { /// ``` pub fn from_rlp(value: impl AsRef) -> Result { let bytes = hex::decode(value.as_ref()).wrap_err("Could not decode hex")?; - let item = rlp::decode::(&bytes).wrap_err("Could not decode rlp")?; + let item = Item::decode(&mut &bytes[..]).wrap_err("Could not decode rlp")?; Ok(item.to_string()) } @@ -1360,7 +1345,7 @@ impl SimpleCast { let val = serde_json::from_str(value) .unwrap_or_else(|_| serde_json::Value::String(value.to_string())); let item = Item::value_to_item(&val)?; - Ok(format!("0x{}", hex::encode(rlp::encode(&item)))) + Ok(format!("0x{}", hex::encode(alloy_rlp::encode(item)))) } /// Converts a number of one base to another @@ -1368,8 +1353,8 @@ impl SimpleCast { /// # Example /// /// ``` + /// use alloy_primitives::I256; /// use cast::SimpleCast as Cast; - /// use ethers_core::types::{I256, U256}; /// /// assert_eq!(Cast::to_base("100", Some("10"), "16")?, "0x64"); /// assert_eq!(Cast::to_base("100", Some("10"), "oct")?, "0o144"); @@ -1619,40 +1604,24 @@ impl SimpleCast { /// # } /// ``` pub async fn generate_interface(address_or_path: AbiPath) -> Result> { - let (contract_abis, contract_names): (Vec, Vec) = match address_or_path { + let (contract_abis, contract_names) = match address_or_path { AbiPath::Local { path, name } => { - let file = std::fs::read_to_string(path).wrap_err("unable to read abi file")?; - let mut json: serde_json::Value = serde_json::from_str(&file)?; - let json = if !json["abi"].is_null() { json["abi"].take() } else { json }; - let abi: RawAbi = - serde_json::from_value(json).wrap_err("unable to parse json ABI from file")?; - + let file = std::fs::read_to_string(&path).wrap_err("unable to read abi file")?; + let obj: ContractObject = serde_json::from_str(&file)?; + let abi = + obj.abi.ok_or_else(|| eyre::eyre!("could not find ABI in file {path}"))?; (vec![abi], vec![name.unwrap_or_else(|| "Interface".to_owned())]) } AbiPath::Etherscan { address, chain, api_key } => { let client = Client::new(chain, api_key)?; - - // get the source - let source = match client.contract_source_code(address).await { - Ok(source) => source, - Err(EtherscanError::InvalidApiKey) => { - eyre::bail!("Invalid Etherscan API key. Did you set it correctly? You may be using an API key for another Etherscan API chain (e.g. Etherscan API key for Polygonscan).") - } - Err(EtherscanError::ContractCodeNotVerified(address)) => { - eyre::bail!("Contract source code at {:?} on {} not verified. Maybe you have selected the wrong chain?", address, chain) - } - Err(err) => { - eyre::bail!(err) - } - }; - + let source = client.contract_source_code(address).await?; let names = source .items .iter() .map(|item| item.contract_name.clone()) .collect::>(); - let abis = source.raw_abis()?; + let abis = source.abis()?; (abis, names) } @@ -1830,7 +1799,7 @@ impl SimpleCast { let value = NumberWithBase::parse_uint(value, base_in)?; let bits = NumberWithBase::parse_uint(bits, None)?; - let res = value.number() >> bits.number(); + let res = value.number().wrapping_shr(bits.number().saturating_to()); Ok(res.to_base(base_out, true)?) } @@ -1877,12 +1846,11 @@ impl SimpleCast { /// /// ``` /// # use cast::SimpleCast as Cast; - /// # use ethers_core::types::Chain; + /// # use foundry_config::NamedChain; /// # use std::path::PathBuf; - /// /// # async fn expand() -> eyre::Result<()> { /// Cast::expand_etherscan_source_to_directory( - /// Chain::Mainnet, + /// NamedChain::Mainnet, /// "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), /// "".to_string(), /// PathBuf::from("output_dir"), diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index 0ca8597d4e23e..3a520844d76b1 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -1,6 +1,6 @@ -use ethers_core::utils::rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; +use alloy_rlp::{Buf, Decodable, Encodable, Header}; use serde_json::Value; -use std::fmt::{Debug, Display, Formatter, Write}; +use std::fmt; /// Arbitrary nested data /// Item::Array(vec![]); is equivalent to [] @@ -12,28 +12,33 @@ pub enum Item { } impl Encodable for Item { - fn rlp_append(&self, s: &mut RlpStream) { + fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { match self { - Item::Array(arr) => { - s.begin_unbounded_list(); - for item in arr { - s.append(item); - } - s.finalize_unbounded_list(); - } - Item::Data(data) => { - s.append(data); - } + Item::Array(arr) => arr.encode(out), + Item::Data(data) => <[u8]>::encode(data, out), } } } impl Decodable for Item { - fn decode(rlp: &Rlp) -> Result { - if rlp.is_data() { - return Ok(Item::Data(Vec::from(rlp.data()?))) + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + let h = Header::decode(buf)?; + if buf.len() < h.payload_length { + return Err(alloy_rlp::Error::InputTooShort); } - Ok(Item::Array(rlp.as_list()?)) + let mut d = &buf[..h.payload_length]; + let r = if h.list { + let view = &mut d; + let mut v = Vec::new(); + while !view.is_empty() { + v.push(Item::decode(view)?); + } + Ok(Item::Array(v)) + } else { + Ok(Item::Data(d.to_vec())) + }; + buf.advance(h.payload_length); + r } } @@ -57,27 +62,26 @@ impl Item { impl FromIterator for Item { fn from_iter>(iter: T) -> Self { - Item::Array(iter.into_iter().collect()) + Item::Array(Vec::from_iter(iter)) } } // Display as hex values -impl Display for Item { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { +impl fmt::Display for Item { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result { match self { Item::Data(dat) => { write!(f, "\"0x{}\"", hex::encode(dat))?; } - Item::Array(arr) => { - write!(f, "[")?; - let mut iter = arr.iter().peekable(); - while let Some(item) = iter.next() { - write!(f, "{item}")?; - if iter.peek().is_some() { - f.write_char(',')?; + Item::Array(items) => { + f.write_str("[")?; + for (i, item) in items.iter().enumerate() { + if i > 0 { + f.write_str(",")?; } + fmt::Display::fmt(item, f)?; } - write!(f, "]")?; + f.write_str("]")?; } }; Ok(()) @@ -87,7 +91,7 @@ impl Display for Item { #[cfg(test)] mod test { use crate::rlp_converter::Item; - use ethers_core::utils::{rlp, rlp::DecoderError}; + use alloy_rlp::Decodable; use serde_json::Result as JsonResult; // https://en.wikipedia.org/wiki/Set-theoretic_definition_of_natural_numbers @@ -100,7 +104,7 @@ mod test { } #[test] - fn encode_decode_test() -> Result<(), DecoderError> { + fn encode_decode_test() -> alloy_rlp::Result<()> { let parameters = vec![ (1, b"\xc0".to_vec(), Item::Array(vec![])), (2, b"\xc1\x80".to_vec(), Item::Array(vec![Item::Data(vec![])])), @@ -130,10 +134,10 @@ mod test { ), ]; for params in parameters { - let encoded = rlp::encode::(¶ms.2); - assert_eq!(rlp::decode::(&encoded)?, params.2); - let decoded = rlp::decode::(¶ms.1); - assert_eq!(rlp::encode::(&decoded?), params.1); + let encoded = alloy_rlp::encode(¶ms.2); + assert_eq!(Item::decode(&mut &encoded[..])?, params.2); + let decoded = Item::decode(&mut ¶ms.1[..])?; + assert_eq!(alloy_rlp::encode(&decoded), params.1); println!("case {} validated", params.0) } diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs index 65b1b7e087015..9da0c20b2274e 100644 --- a/crates/cast/src/tx.rs +++ b/crates/cast/src/tx.rs @@ -12,33 +12,35 @@ use foundry_config::Chain; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future::join_all; -pub struct TxBuilder<'a, M: Middleware> { - to: Option
, - chain: Chain, - tx: TypedTransaction, - func: Option, - etherscan_api_key: Option, - provider: &'a M, -} - pub type TxBuilderOutput = (TypedTransaction, Option); pub type TxBuilderPeekOutput<'a> = (&'a TypedTransaction, &'a Option); /// Transaction builder +/// +/// # Examples +/// /// ``` /// # async fn foo() -> eyre::Result<()> { -/// use alloy_primitives::U256; -/// use cast::TxBuilder; -/// use ethers_core::types::Chain; -/// +/// # use alloy_primitives::U256; +/// # use cast::TxBuilder; +/// # use foundry_config::NamedChain; /// let provider = ethers_providers::test_provider::MAINNET.provider(); /// let mut builder = -/// TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await?; +/// TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false).await?; /// builder.gas(Some(U256::from(1))); /// let (tx, _) = builder.build(); /// # Ok(()) /// # } /// ``` +pub struct TxBuilder<'a, M: Middleware> { + to: Option
, + chain: Chain, + tx: TypedTransaction, + func: Option, + etherscan_api_key: Option, + provider: &'a M, +} + impl<'a, M: Middleware> TxBuilder<'a, M> { /// Create a new TxBuilder /// `provider` - provider to use @@ -63,9 +65,7 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { }; let to_addr = if let Some(to) = to { - let addr = - resolve_ens(provider, foundry_utils::resolve_addr(to, chain.try_into().ok())?) - .await?; + let addr = resolve_ens(provider, to).await?; tx.set_to(addr.to_ethers()); Some(addr) } else { diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index e71529410118c..aeae87e547c1b 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -23,6 +23,7 @@ alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-sol-types.workspace = true + ethers-core.workspace = true ethers-providers.workspace = true ethers-signers.workspace = true diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 21314dafd8496..b8f100a773bf6 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -19,52 +19,46 @@ vergen = { version = "8", default-features = false, features = ["build", "git", [dependencies] # forge -foundry-evm.workspace = true -foundry-config.workspace = true +forge-fmt.workspace = true foundry-cli.workspace = true foundry-common.workspace = true -foundry-utils.workspace = true -forge-fmt.workspace = true - foundry-compilers = { workspace = true, features = ["project-util", "full"] } +foundry-config.workspace = true +foundry-evm.workspace = true +foundry-utils.workspace = true -# ethers -ethers.workspace = true - -# alloy alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-json-abi.workspace = true -# async -tokio = { version = "1", features = ["full"] } -reqwest = { version = "0.11", default-features = false } +ethers-core.workspace = true -# misc clap = { version = "4", features = ["derive", "env", "wrap_help"] } +dirs = "5" +eyre.workspace = true +once_cell = "1.18.0" +regex = "1" +reqwest = { version = "0.11", default-features = false } +revm.workspace = true rustyline = "12" +semver = "1" +serde_json.workspace = true +serde.workspace = true solang-parser.workspace = true -yansi = "0.5" strum = { version = "0.25", features = ["derive"] } -serde.workspace = true -serde_json.workspace = true -semver = "1" -revm.workspace = true -eyre.workspace = true -dirs = "5" time = { version = "0.3", features = ["formatting"] } -regex = "1" -once_cell = "1.18.0" +tokio = { version = "1", features = ["full"] } +yansi = "0.5" [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } -serial_test = "2" once_cell = "1" +serial_test = "2" [features] default = ["rustls"] -rustls = ["ethers/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] -openssl = ["ethers/openssl", "foundry-compilers/openssl", "reqwest/default-tls"] +rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] +openssl = ["foundry-compilers/openssl", "reqwest/default-tls"] [[bench]] name = "session_source" diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 376f89ab534ca..00cb59ed71874 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -3,8 +3,6 @@ //! This module contains the core readline loop for the Chisel CLI as well as the //! executable's `main` function. -use std::path::PathBuf; - use chisel::{ history::chisel_history_file, prelude::{ChiselCommand, ChiselDispatcher, DispatchResult, SolidityHelper}, @@ -24,6 +22,7 @@ use foundry_config::{ Config, }; use rustyline::{config::Configurer, error::ReadlineError, Editor}; +use std::path::PathBuf; use yansi::Paint; // Loads project's figment and merges the build cli arguments into it diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 927cc2e2f6089..90e1dd72d29f5 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -99,7 +99,7 @@ pub fn format_source(source: &str, config: FormatterConfig) -> eyre::Result { let mut formatted_source = String::default(); - if forge_fmt::format(&mut formatted_source, parsed, config).is_err() { + if forge_fmt::format_to(&mut formatted_source, parsed, config).is_err() { eyre::bail!("Could not format source!"); } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 5c9050615500c..9fe2f57615bfb 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -604,10 +604,9 @@ impl Type { // address pt::Expression::AddressLiteral(_, _) => Some(Self::Builtin(DynSolType::Address)), pt::Expression::HexNumberLiteral(_, s, _) => { - match s.parse() { + match s.parse::
() { Ok(addr) => { - let checksummed = ethers::utils::to_checksum(&addr, None); - if *s == checksummed { + if *s == addr.to_checksum(None) { Some(Self::Builtin(DynSolType::Address)) } else { Some(Self::Builtin(DynSolType::Uint(256))) diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 7302ffcfa4287..14485ab2fb731 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -4,7 +4,7 @@ //! and calling the REPL contract on a in-memory REVM instance. use alloy_primitives::{Address, Bytes, U256}; -use ethers::types::Log; +use ethers_core::types::Log; use eyre::Result; use foundry_evm::{ executors::{DeployResult, Executor, RawCallResult}, diff --git a/crates/chisel/src/session.rs b/crates/chisel/src/session.rs index d0e49a7c2a5ec..f0f1debd5a705 100644 --- a/crates/chisel/src/session.rs +++ b/crates/chisel/src/session.rs @@ -4,9 +4,7 @@ //! wrapper for a serializable REPL session. use crate::prelude::{SessionSource, SessionSourceConfig}; - use eyre::Result; - use serde::{Deserialize, Serialize}; use std::path::Path; use time::{format_description, OffsetDateTime}; @@ -147,9 +145,11 @@ impl ChiselSession { /// /// Optionally, the directory of the chisel cache. pub fn cache_dir() -> Result { - let home_dir = dirs::home_dir().ok_or(eyre::eyre!("Failed to grab home directory"))?; - let home_dir_str = - home_dir.to_str().ok_or(eyre::eyre!("Failed to convert home directory to string"))?; + let home_dir = + dirs::home_dir().ok_or_else(|| eyre::eyre!("Failed to grab home directory"))?; + let home_dir_str = home_dir + .to_str() + .ok_or_else(|| eyre::eyre!("Failed to convert home directory to string"))?; Ok(format!("{home_dir_str}/.foundry/cache/chisel/")) } @@ -224,14 +224,18 @@ impl ChiselSession { pub fn latest_cached_session() -> Result { let cache_dir = Self::cache_dir()?; let mut entries = std::fs::read_dir(cache_dir)?; - let mut latest = entries.next().ok_or(eyre::eyre!("No entries found!"))??; + let mut latest = entries.next().ok_or_else(|| eyre::eyre!("No entries found!"))??; for entry in entries { let entry = entry?; if entry.metadata()?.modified()? > latest.metadata()?.modified()? { latest = entry; } } - Ok(latest.path().to_str().ok_or(eyre::eyre!("Failed to get session path!"))?.to_string()) + Ok(latest + .path() + .to_str() + .ok_or_else(|| eyre::eyre!("Failed to get session path!"))? + .to_string()) } /// Loads the latest ChiselSession from the cache file diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index d9de02a147cb6..4a05d2cde11ee 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -372,7 +372,7 @@ impl SessionSource { // Construct variable definitions let variable_definitions = intermediate_contracts .get("REPL") - .ok_or(eyre::eyre!("Could not find intermediate REPL contract!"))? + .ok_or_else(|| eyre::eyre!("Could not find intermediate REPL contract!"))? .variable_definitions .clone() .into_iter() @@ -609,13 +609,13 @@ impl IntermediateOutput { match self .intermediate_contracts .get("REPL") - .ok_or(eyre::eyre!("Could not find REPL intermediate contract!"))? + .ok_or_else(|| eyre::eyre!("Could not find REPL intermediate contract!"))? .function_definitions .get("run") - .ok_or(eyre::eyre!("Could not find run function definition in REPL contract!"))? + .ok_or_else(|| eyre::eyre!("Could not find run function definition in REPL contract!"))? .body .as_ref() - .ok_or(eyre::eyre!("Could not find run function body!"))? + .ok_or_else(|| eyre::eyre!("Could not find run function body!"))? { pt::Statement::Block { statements, .. } => Ok(statements), _ => eyre::bail!("Could not find statements within run function body!"), diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index f0f314edd3f2c..08432493f925d 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -11,25 +11,24 @@ repository.workspace = true [dependencies] # foundry internal -foundry-config.workspace = true foundry-common.workspace = true -foundry-evm.workspace = true +foundry-config.workspace = true foundry-debugger.workspace = true +foundry-evm.workspace = true foundry-utils.workspace = true foundry-compilers = { workspace = true, features = ["full"] } -# aws -rusoto_core = { version = "0.48", default-features = false } -rusoto_kms = { version = "0.48", default-features = false } +alloy-dyn-abi.workspace = true +alloy-json-abi.workspace = true +alloy-primitives.workspace = true -# eth -ethers = { workspace = true, features = ["aws", "ledger", "trezor"] } +ethers-core.workspace = true +ethers-providers.workspace = true +ethers-signers = { workspace = true, features = ["aws", "ledger", "trezor"] } -# alloy -alloy-primitives.workspace = true -alloy-json-abi.workspace = true -alloy-dyn-abi.workspace = true +rusoto_core = { version = "0.48", default-features = false } +rusoto_kms = { version = "0.48", default-features = false } async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } @@ -47,9 +46,9 @@ strsim = "0.10" strum = { version = "0.25", features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["macros"] } -tracing.workspace = true tracing-error = "0.2" tracing-subscriber = { version = "0.3", features = ["registry", "env-filter", "fmt"] } +tracing.workspace = true yansi = "0.5" [dev-dependencies] @@ -57,5 +56,5 @@ tempfile = "3.7" [features] default = ["rustls"] -rustls = ["ethers/rustls", "rusoto_core/rustls"] -openssl = ["ethers/openssl", "foundry-compilers/openssl"] +rustls = ["ethers-providers/rustls", "rusoto_core/rustls"] +openssl = ["ethers-providers/openssl", "foundry-compilers/openssl"] diff --git a/crates/cli/src/opts/chain.rs b/crates/cli/src/opts/chain.rs index 1649c6fa586b2..26d63987d9c82 100644 --- a/crates/cli/src/opts/chain.rs +++ b/crates/cli/src/opts/chain.rs @@ -1,7 +1,6 @@ use clap::builder::{PossibleValuesParser, TypedValueParser}; -use ethers::types::Chain as NamedChain; use eyre::Result; -use foundry_config::Chain; +use foundry_config::{Chain, NamedChain}; use std::ffi::OsStr; use strum::VariantNames; diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/cli/src/opts/wallet/mod.rs index 437c5dc02ef3b..8a17adabe913d 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/cli/src/opts/wallet/mod.rs @@ -2,16 +2,13 @@ use crate::opts::error::PrivateKeyError; use alloy_primitives::Address; use async_trait::async_trait; use clap::Parser; -use ethers::{ - signers::{ - coins_bip39::English, AwsSigner, AwsSignerError, HDPath as LedgerHDPath, Ledger, - LedgerError, LocalWallet, MnemonicBuilder, Signer, Trezor, TrezorError, TrezorHDPath, - WalletError, - }, - types::{ - transaction::{eip2718::TypedTransaction, eip712::Eip712}, - Signature, - }, +use ethers_core::types::{ + transaction::{eip2718::TypedTransaction, eip712::Eip712}, + Signature, +}; +use ethers_signers::{ + coins_bip39::English, AwsSigner, AwsSignerError, HDPath as LedgerHDPath, Ledger, LedgerError, + LocalWallet, MnemonicBuilder, Signer, Trezor, TrezorError, TrezorHDPath, WalletError, }; use eyre::{bail, Result, WrapErr}; use foundry_common::fs; @@ -498,7 +495,7 @@ impl Signer for WalletSigner { delegate!(self, inner => inner.sign_typed_data(payload).await.map_err(Into::into)) } - fn address(&self) -> ethers::types::Address { + fn address(&self) -> ethers_core::types::Address { delegate!(self, inner => inner.address()) } @@ -538,7 +535,7 @@ impl Signer for &WalletSigner { (*self).sign_typed_data(payload).await } - fn address(&self) -> ethers::types::Address { + fn address(&self) -> ethers_core::types::Address { (*self).address() } diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index bad22cb31c028..701a55dd45ae9 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -1,9 +1,9 @@ use super::{WalletSigner, WalletTrait}; use alloy_primitives::Address; use clap::Parser; -use ethers::{ - prelude::{Middleware, Signer}, - signers::{AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, Trezor, TrezorHDPath}, +use ethers_providers::Middleware; +use ethers_signers::{ + AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, Signer, Trezor, TrezorHDPath, }; use eyre::{Context, ContextCompat, Result}; use foundry_common::RetryProvider; diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 62659224a0621..466c3908d7bc2 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -1,6 +1,5 @@ use alloy_json_abi::JsonAbi as Abi; use alloy_primitives::Address; -use ethers::core::types::Chain; use eyre::{Result, WrapErr}; use foundry_common::{cli_warn, fs, TestFunctionExt}; use foundry_compilers::{ @@ -10,7 +9,7 @@ use foundry_compilers::{ utils::read_json_file, Artifact, ProjectCompileOutput, }; -use foundry_config::{error::ExtractConfigError, figment::Figment, Chain as ConfigChain, Config}; +use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, NamedChain}; use foundry_debugger::DebuggerArgs; use foundry_evm::{ debug::DebugArena, @@ -165,13 +164,13 @@ macro_rules! update_progress { /// True if the network calculates gas costs differently. pub fn has_different_gas_calc(chain: u64) -> bool { - if let ConfigChain::Named(chain) = ConfigChain::from(chain) { + if let Chain::Named(chain) = Chain::from(chain) { return matches!( chain, - Chain::Arbitrum | - Chain::ArbitrumTestnet | - Chain::ArbitrumGoerli | - Chain::ArbitrumSepolia + NamedChain::Arbitrum | + NamedChain::ArbitrumTestnet | + NamedChain::ArbitrumGoerli | + NamedChain::ArbitrumSepolia ) } false @@ -179,13 +178,13 @@ pub fn has_different_gas_calc(chain: u64) -> bool { /// True if it supports broadcasting in batches. pub fn has_batch_support(chain: u64) -> bool { - if let ConfigChain::Named(chain) = ConfigChain::from(chain) { + if let Chain::Named(chain) = Chain::from(chain) { return !matches!( chain, - Chain::Arbitrum | - Chain::ArbitrumTestnet | - Chain::ArbitrumGoerli | - Chain::ArbitrumSepolia + NamedChain::Arbitrum | + NamedChain::ArbitrumTestnet | + NamedChain::ArbitrumGoerli | + NamedChain::ArbitrumSepolia ) } true @@ -369,7 +368,7 @@ impl TryFrom for TraceResult { pub async fn handle_traces( mut result: TraceResult, config: &Config, - chain: Option, + chain: Option, labels: Vec, verbose: bool, debug: bool, diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 9e55d180b46fd..4c085f2c95a01 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -1,5 +1,6 @@ use alloy_primitives::U256; -use ethers::{prelude::TransactionReceipt, providers::Middleware}; +use ethers_core::types::TransactionReceipt; +use ethers_providers::Middleware; use eyre::{ContextCompat, Result}; use foundry_common::units::format_units; use foundry_config::{Chain, Config}; @@ -88,8 +89,11 @@ pub fn get_provider(config: &Config) -> Result { /// Defaults to `http://localhost:8545` and `Mainnet`. pub fn get_provider_builder(config: &Config) -> Result { let url = config.get_rpc_url_or_localhost_http()?; - let chain = config.chain_id.unwrap_or_default(); - let mut builder = foundry_common::ProviderBuilder::new(url.as_ref()).chain(chain); + let mut builder = foundry_common::ProviderBuilder::new(url.as_ref()); + + if let Ok(chain) = config.chain_id.unwrap_or_default().try_into() { + builder = builder.chain(chain); + } let jwt = config.get_rpc_jwt_secret()?; if let Some(jwt) = jwt { diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index f12289aaa459b..8de06a79211a3 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -10,49 +10,40 @@ homepage.workspace = true repository.workspace = true [dependencies] -# foundry internal +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } +foundry-compilers.workspace = true foundry-config.workspace = true foundry-macros.workspace = true -# eth ethers-core.workspace = true -ethers-providers = { workspace = true, features = ["ws", "ipc"] } ethers-middleware.workspace = true -foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } +ethers-providers = { workspace = true, features = ["ws", "ipc"] } -# alloy -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -foundry-compilers.workspace = true - -# io -reqwest = { version = "0.11", default-features = false } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } -# cli +async-trait = "0.1" +auto_impl = "1.1.0" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" -tracing.workspace = true -yansi = "0.5" -tempfile = "3" - -# misc -auto_impl = "1.1.0" -async-trait = "0.1" -serde.workspace = true -serde_json.workspace = true -thiserror = "1" +dunce = "1" eyre.workspace = true -walkdir = "2" -semver = "1" +globset = "0.4" +hex.workspace = true once_cell = "1" -dunce = "1" regex = "1" -globset = "0.4" +reqwest = { version = "0.11", default-features = false } +semver = "1" +serde_json.workspace = true +serde.workspace = true +tempfile = "3" +thiserror = "1" tokio = "1" +tracing.workspace = true url = "2" -# Using const-hex instead of hex for speed -hex.workspace = true +walkdir = "2" +yansi = "0.5" [dev-dependencies] tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 0bc960f1dbee0..d3761605dae6d 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -3,9 +3,9 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{AbiItem, Event, Function}; use alloy_primitives::{hex, Address, Log}; -use ethers_core::types::Chain; use eyre::{ContextCompat, Result}; use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; +use foundry_config::NamedChain; use std::{future::Future, pin::Pin}; /// Given a function and a vector of string arguments, it proceeds to convert the args to alloy @@ -132,7 +132,7 @@ pub async fn get_func_etherscan( function_name: &str, contract: Address, args: &[String], - chain: Chain, + chain: NamedChain, etherscan_api_key: &str, ) -> Result { let client = Client::new(chain, etherscan_api_key)?; diff --git a/crates/common/src/calc.rs b/crates/common/src/calc.rs index 2383e346f7d76..0490a0ece1ea1 100644 --- a/crates/common/src/calc.rs +++ b/crates/common/src/calc.rs @@ -1,4 +1,4 @@ -//! commonly used calculations +//! Commonly used calculations. use alloy_primitives::U256; use std::ops::Div; diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index d4f3763874158..23ca0abab43f2 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -1,4 +1,4 @@ -//! Commonly used constants +//! Commonly used constants. use alloy_primitives::{address, Address}; use std::time::Duration; diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index e5338c5ddd4eb..652db9531d1cc 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -1,4 +1,4 @@ -//! commonly used contract types and functions +//! Commonly used contract types and functions. use alloy_json_abi::{Event, Function, JsonAbi as Abi}; use alloy_primitives::{hex, Address, B256}; @@ -224,11 +224,11 @@ pub fn compact_to_contract( contract: CompactContractBytecode, ) -> eyre::Result { Ok(ContractBytecodeSome { - abi: contract.abi.ok_or(eyre::eyre!("No contract abi"))?, - bytecode: contract.bytecode.ok_or(eyre::eyre!("No contract bytecode"))?.into(), + abi: contract.abi.ok_or_else(|| eyre::eyre!("No contract abi"))?, + bytecode: contract.bytecode.ok_or_else(|| eyre::eyre!("No contract bytecode"))?.into(), deployed_bytecode: contract .deployed_bytecode - .ok_or(eyre::eyre!("No contract deployed bytecode"))? + .ok_or_else(|| eyre::eyre!("No contract deployed bytecode"))? .into(), }) } @@ -236,7 +236,7 @@ pub fn compact_to_contract( #[cfg(test)] mod tests { use super::*; - use ethers_core::{abi, abi::ParamType}; + use alloy_dyn_abi::DynSolType; // #[test] @@ -247,15 +247,14 @@ mod tests { let args = find_constructor_args(&code).unwrap(); - let params = vec![ - ParamType::Address, - ParamType::Uint(256), - ParamType::Int(256), - ParamType::FixedBytes(32), - ParamType::Bool, - ]; - - let _decoded = abi::decode(¶ms, args).unwrap(); + let params = DynSolType::Tuple(vec![ + DynSolType::Address, + DynSolType::Uint(256), + DynSolType::Int(256), + DynSolType::FixedBytes(32), + DynSolType::Bool, + ]); + let _decoded = params.abi_decode_params(args).unwrap(); } #[test] @@ -266,16 +265,15 @@ mod tests { let args = find_constructor_args(&code).unwrap(); - let params = vec![ - ParamType::Address, - ParamType::Uint(256), - ParamType::Int(256), - ParamType::FixedBytes(32), - ParamType::Bool, - ParamType::Bytes, - ParamType::String, - ]; - - let _decoded = abi::decode(¶ms, args).unwrap(); + let params = DynSolType::Tuple(vec![ + DynSolType::Address, + DynSolType::Uint(256), + DynSolType::Int(256), + DynSolType::FixedBytes(32), + DynSolType::Bool, + DynSolType::Bytes, + DynSolType::String, + ]); + let _decoded = params.abi_decode_params(args).unwrap(); } } diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 743416981becf..bf2ba019fe315 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -258,30 +258,25 @@ impl EvmArgs { #[cfg(test)] mod tests { use super::*; + use foundry_config::NamedChain; #[test] fn can_parse_chain_id() { let args = EvmArgs { - env: EnvArgs { - chain_id: Some(ethers_core::types::Chain::Mainnet.into()), - ..Default::default() - }, + env: EnvArgs { chain_id: Some(NamedChain::Mainnet.into()), ..Default::default() }, ..Default::default() }; let config = Config::from_provider(Config::figment().merge(args)); - assert_eq!(config.chain_id, Some(ethers_core::types::Chain::Mainnet.into())); + assert_eq!(config.chain_id, Some(NamedChain::Mainnet.into())); let env = EnvArgs::parse_from(["foundry-common", "--chain-id", "goerli"]); - assert_eq!(env.chain_id, Some(ethers_core::types::Chain::Goerli.into())); + assert_eq!(env.chain_id, Some(NamedChain::Goerli.into())); } #[test] fn test_memory_limit() { let args = EvmArgs { - env: EnvArgs { - chain_id: Some(ethers_core::types::Chain::Mainnet.into()), - ..Default::default() - }, + env: EnvArgs { chain_id: Some(NamedChain::Mainnet.into()), ..Default::default() }, ..Default::default() }; let config = Config::from_provider(Config::figment().merge(args)); diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index f00734721e45c..9a380a353c1ea 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -4,10 +4,11 @@ use crate::{ runtime_client::{RuntimeClient, RuntimeClientBuilder}, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, }; -use ethers_core::types::{Chain, U256}; +use ethers_core::types::U256; use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use ethers_providers::{is_local_endpoint, Middleware, Provider, DEFAULT_LOCAL_POLL_INTERVAL}; use eyre::{Result, WrapErr}; +use foundry_config::NamedChain; use reqwest::Url; use std::{ path::{Path, PathBuf}, @@ -55,7 +56,7 @@ pub fn try_get_http_provider(builder: impl AsRef) -> Result pub struct ProviderBuilder { // Note: this is a result, so we can easily chain builder calls url: Result, - chain: Chain, + chain: NamedChain, max_retry: u32, timeout_retry: u32, initial_backoff: u64, @@ -100,7 +101,7 @@ impl ProviderBuilder { Self { url, - chain: Chain::Mainnet, + chain: NamedChain::Mainnet, max_retry: 8, timeout_retry: 8, initial_backoff: 800, @@ -124,10 +125,8 @@ impl ProviderBuilder { } /// Sets the chain of the node the provider will connect to - pub fn chain(mut self, chain: impl Into) -> Self { - if let foundry_config::Chain::Named(chain) = chain.into() { - self.chain = chain; - } + pub fn chain(mut self, chain: NamedChain) -> Self { + self.chain = chain; self } @@ -205,7 +204,7 @@ impl ProviderBuilder { pub async fn connect(self) -> Result { let mut provider = self.build()?; if let Some(blocktime) = provider.get_chainid().await.ok().and_then(|id| { - Chain::try_from(id).ok().and_then(|chain| chain.average_blocktime_hint()) + NamedChain::try_from(id).ok().and_then(|chain| chain.average_blocktime_hint()) }) { provider = provider.interval(blocktime / 2); } @@ -271,10 +270,10 @@ where provider.get_chainid().await.wrap_err("Failed to get chain id")?.as_u64() }; - if let Ok(chain) = Chain::try_from(chain) { + if let Ok(chain) = NamedChain::try_from(chain) { // handle chains that deviate from `eth_feeHistory` and have their own oracle match chain { - Chain::Polygon | Chain::PolygonMumbai => { + NamedChain::Polygon | NamedChain::PolygonMumbai => { let estimator = Polygon::new(chain)?.category(GasCategory::Standard); return Ok(estimator.estimate_eip1559_fees().await?) } diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 273a44e903e60..f2d5cb281ee9e 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -1,7 +1,7 @@ #![allow(missing_docs)] //! Support for handling/identifying selectors use crate::abi::abi_decode_calldata; -use foundry_compilers::artifacts::LosslessAbi; +use alloy_json_abi::JsonAbi; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{ @@ -188,7 +188,7 @@ impl SignEthClient { Ok(decoded .get(selector) - .ok_or(eyre::eyre!("No signature found"))? + .ok_or_else(|| eyre::eyre!("No signature found"))? .iter() .filter(|&d| !d.filtered) .map(|d| d.name.clone()) @@ -302,17 +302,16 @@ impl SignEthClient { let functions_and_errors: Vec = abis .iter() .flat_map(|abi| { - abi.abi - .functions() + abi.functions() .map(|func| func.signature()) - .chain(abi.abi.errors().map(|error| error.signature())) + .chain(abi.errors().map(|error| error.signature())) .collect::>() }) .collect(); let events = abis .iter() - .flat_map(|abi| abi.abi.events().map(|event| event.signature())) + .flat_map(|abi| abi.events().map(|event| event.signature())) .collect::>(); SelectorImportRequest { function: functions_and_errors, event: events } @@ -434,7 +433,7 @@ impl RawSelectorImportData { #[derive(Serialize)] #[serde(untagged)] pub enum SelectorImportData { - Abi(Vec), + Abi(Vec), Raw(RawSelectorImportData), } @@ -493,12 +492,12 @@ pub async fn import_selectors(data: SelectorImportData) -> eyre::Result, + pub abis: Vec, } #[derive(Deserialize)] struct Artifact { - abi: LosslessAbi, + abi: JsonAbi, } /// Parses a list of tokens into function, event, and error signatures. @@ -594,7 +593,7 @@ mod tests { "0xa9059cbb" ); - let abi: LosslessAbi = serde_json::from_str(r#"[{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function", "methodIdentifiers": {"transfer(address,uint256)(uint256)": "0xa9059cbb"}}]"#).unwrap(); + let abi: JsonAbi = serde_json::from_str(r#"[{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function", "methodIdentifiers": {"transfer(address,uint256)(uint256)": "0xa9059cbb"}}]"#).unwrap(); let result = import_selectors(SelectorImportData::Abi(vec![abi])).await; println!("{:?}", result); assert_eq!( diff --git a/crates/common/src/serde_helpers.rs b/crates/common/src/serde_helpers.rs index 366a71012f04a..8d8788561f6aa 100644 --- a/crates/common/src/serde_helpers.rs +++ b/crates/common/src/serde_helpers.rs @@ -1,9 +1,8 @@ -//! Misc serde helpers for foundry crates. - -use std::str::FromStr; +//! Misc Serde helpers for foundry crates. use alloy_primitives::U256; use serde::Deserialize; +use std::str::FromStr; /// Helper type to parse both `u64` and `U256` #[derive(Copy, Clone, Deserialize)] diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 637f87d0f12f9..7b05880d38db4 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -11,45 +11,37 @@ homepage.workspace = true repository.workspace = true [dependencies] -# eth -ethers-core.workspace = true +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } +foundry-compilers = { workspace = true, features = ["async", "svm-solc"] } + alloy-primitives = { workspace = true, features = ["std", "serde"] } revm-primitives = { workspace = true, default-features = false, features = ["std"] } -foundry-compilers = { workspace = true, features = ["async", "svm-solc"] } -foundry-block-explorers = { workspace = true, features = ["foundry-compilers"]} - -# formats -Inflector = "0.11" -figment = { version = "0.10", features = ["toml", "env"] } -number_prefix = "0.4" -serde.workspace = true -serde_regex = "1" -serde_json.workspace = true -toml = { version = "0.8", features = ["preserve_order"] } -toml_edit = "0.20" +ethers-core.workspace = true -# dirs dirs-next = "2" -globset = "0.4" -walkdir = "2" - -# encoding -open-fastrlp = "0.1" - -# misc eyre.workspace = true +figment = { version = "0.10", features = ["toml", "env"] } +globset = "0.4" +Inflector = "0.11" +number_prefix = "0.4" +once_cell = "1" regex = "1" +reqwest = { version = "0.11", default-features = false } semver = { version = "1", features = ["serde"] } -tracing.workspace = true -once_cell = "1" +serde_json.workspace = true +serde_regex = "1" +serde.workspace = true thiserror = "1" -reqwest = { version = "0.11", default-features = false } +toml = { version = "0.8", features = ["preserve_order"] } +toml_edit = "0.21" +tracing.workspace = true +walkdir = "2" [target.'cfg(target_os = "windows")'.dependencies] path-slash = "0.2.1" [dev-dependencies] -pretty_assertions = "1" +pretty_assertions.workspace = true figment = { version = "0.10", features = ["test"] } tempfile = "3" diff --git a/crates/config/src/cache.rs b/crates/config/src/cache.rs index 315edd3e3ad5b..1355a3c54d439 100644 --- a/crates/config/src/cache.rs +++ b/crates/config/src/cache.rs @@ -185,27 +185,27 @@ impl fmt::Display for Cache { chain.block_explorer as f32 + chain.blocks.iter().map(|x| x.1).sum::() as f32, ) { NumberPrefix::Standalone(size) => { - writeln!(f, "-️ {} ({size:.1} B)", chain.name)?; + writeln!(f, "- {} ({size:.1} B)", chain.name)?; } NumberPrefix::Prefixed(prefix, size) => { - writeln!(f, "-️ {} ({size:.1} {prefix}B)", chain.name)?; + writeln!(f, "- {} ({size:.1} {prefix}B)", chain.name)?; } } match NumberPrefix::decimal(chain.block_explorer as f32) { NumberPrefix::Standalone(size) => { - writeln!(f, "\t-️ Block Explorer ({size:.1} B)\n")?; + writeln!(f, "\t- Block Explorer ({size:.1} B)\n")?; } NumberPrefix::Prefixed(prefix, size) => { - writeln!(f, "\t-️ Block Explorer ({size:.1} {prefix}B)\n")?; + writeln!(f, "\t- Block Explorer ({size:.1} {prefix}B)\n")?; } } for block in &chain.blocks { match NumberPrefix::decimal(block.1 as f32) { NumberPrefix::Standalone(size) => { - writeln!(f, "\t-️ Block {} ({size:.1} B)", block.0)?; + writeln!(f, "\t- Block {} ({size:.1} B)", block.0)?; } NumberPrefix::Prefixed(prefix, size) => { - writeln!(f, "\t-️ Block {} ({size:.1} {prefix}B)", block.0)?; + writeln!(f, "\t- Block {} ({size:.1} {prefix}B)", block.0)?; } } } @@ -229,9 +229,9 @@ pub struct ChainCache { #[cfg(test)] mod tests { - use pretty_assertions::assert_str_eq; - use super::*; + use crate::chain::NamedChain; + use pretty_assertions::assert_str_eq; #[test] fn can_parse_storage_config() { @@ -255,8 +255,8 @@ mod tests { w.rpc_storage_caching, StorageCachingConfig { chains: CachedChains::Chains(vec![ - Chain::Named(ethers_core::types::Chain::Mainnet), - Chain::Named(ethers_core::types::Chain::Optimism), + Chain::Named(NamedChain::Mainnet), + Chain::Named(NamedChain::Optimism), Chain::Id(999999) ]), endpoints: CachedEndpoints::All @@ -292,22 +292,22 @@ mod tests { }; let expected = "\ - -️ mainnet (503.0 B)\n\t\ - -️ Block Explorer (500.0 B)\n\n\t\ - -️ Block 1 (1.0 B)\n\t\ - -️ Block 2 (2.0 B)\n\ - -️ ropsten (4.6 kB)\n\t\ - -️ Block Explorer (4.6 kB)\n\n\t\ - -️ Block 1 (1.0 B)\n\t\ - -️ Block 2 (2.0 B)\n\ - -️ rinkeby (6.2 MB)\n\t\ - -️ Block Explorer (4.2 MB)\n\n\t\ - -️ Block 1 (1.0 kB)\n\t\ - -️ Block 2 (2.0 MB)\n\ - -️ mumbai (3.0 B)\n\t\ - -️ Block Explorer (0.0 B)\n\n\t\ - -️ Block 1 (1.0 B)\n\t\ - -️ Block 2 (2.0 B)\n"; + - mainnet (503.0 B)\n\t\ + - Block Explorer (500.0 B)\n\n\t\ + - Block 1 (1.0 B)\n\t\ + - Block 2 (2.0 B)\n\ + - ropsten (4.6 kB)\n\t\ + - Block Explorer (4.6 kB)\n\n\t\ + - Block 1 (1.0 B)\n\t\ + - Block 2 (2.0 B)\n\ + - rinkeby (6.2 MB)\n\t\ + - Block Explorer (4.2 MB)\n\n\t\ + - Block 1 (1.0 kB)\n\t\ + - Block 2 (2.0 MB)\n\ + - mumbai (3.0 B)\n\t\ + - Block Explorer (0.0 B)\n\n\t\ + - Block 1 (1.0 B)\n\t\ + - Block 2 (2.0 B)\n"; assert_str_eq!(format!("{cache}"), expected); } } diff --git a/crates/config/src/chain.rs b/crates/config/src/chain.rs index 40dac60cc3c88..b7ce1ba0ed40d 100644 --- a/crates/config/src/chain.rs +++ b/crates/config/src/chain.rs @@ -1,11 +1,11 @@ use crate::U256; use alloy_primitives::U64; -use ethers_core::types::Chain as NamedChain; use eyre::Result; -use open_fastrlp::{Decodable, Encodable}; use serde::{Deserialize, Deserializer, Serialize}; use std::{fmt, str::FromStr}; +pub use ethers_core::types::Chain as NamedChain; + /// Either a named or chain id or the actual id value #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)] #[serde(untagged)] @@ -150,27 +150,6 @@ impl<'de> Deserialize<'de> for Chain { } } -impl Encodable for Chain { - fn length(&self) -> usize { - match self { - Self::Named(chain) => u64::from(*chain).length(), - Self::Id(id) => id.length(), - } - } - fn encode(&self, out: &mut dyn open_fastrlp::BufMut) { - match self { - Self::Named(chain) => u64::from(*chain).encode(out), - Self::Id(id) => id.encode(out), - } - } -} - -impl Decodable for Chain { - fn decode(buf: &mut &[u8]) -> Result { - Ok(u64::decode(buf)?.into()) - } -} - impl Default for Chain { fn default() -> Self { NamedChain::Mainnet.into() diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index d78621d317e72..721df63b4bb07 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -1,7 +1,8 @@ -//! Support for multiple etherscan keys +//! Support for multiple Etherscan keys. + use crate::{ resolve::{interpolate, UnresolvedEnvVarError, RE_PLACEHOLDER}, - Chain, Config, + Chain, Config, NamedChain, }; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{ @@ -258,14 +259,13 @@ impl ResolvedEtherscanConfig { ) -> Result { let ResolvedEtherscanConfig { api_url, browser_url, key: api_key, chain } = self; - let (mainnet_api, mainnet_url) = - ethers_core::types::Chain::Mainnet.etherscan_urls().expect("exist; qed"); + let (mainnet_api, mainnet_url) = NamedChain::Mainnet.etherscan_urls().expect("exist; qed"); let cache = chain .or_else(|| { if api_url == mainnet_api { // try to match against mainnet, which is usually the most common target - Some(ethers_core::types::Chain::Mainnet.into()) + Some(NamedChain::Mainnet.into()) } else { None } @@ -378,7 +378,7 @@ impl fmt::Display for EtherscanApiKey { #[cfg(test)] mod tests { use super::*; - use ethers_core::types::Chain::Mainnet; + use NamedChain::Mainnet; #[test] fn can_create_client_via_chain() { diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index af579763a846a..ff59f10fc32e7 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -1,11 +1,10 @@ -//! Configuration for fuzz testing - -use alloy_primitives::U256; -use serde::{Deserialize, Serialize}; +//! Configuration for fuzz testing. use crate::inline::{ parse_config_u32, InlineConfigParser, InlineConfigParserError, INLINE_CONFIG_FUZZ_KEY, }; +use alloy_primitives::U256; +use serde::{Deserialize, Serialize}; /// Contains for fuzz testing #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index 1b8de84d12245..844f374766f75 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -1,8 +1,6 @@ -use regex::Regex; - -use crate::{InlineConfigError, NatSpec}; - use super::{remove_whitespaces, INLINE_CONFIG_PREFIX}; +use crate::{InlineConfigError, NatSpec}; +use regex::Regex; /// Errors returned by the [`InlineConfigParser`] trait. #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 99a314c961a74..5688d6cc89c36 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -1,16 +1,16 @@ +use crate::Config; +use once_cell::sync::Lazy; +use std::collections::HashMap; + mod conf_parser; pub use conf_parser::{ parse_config_bool, parse_config_u32, validate_profiles, InlineConfigParser, InlineConfigParserError, }; -use once_cell::sync::Lazy; -use std::collections::HashMap; mod natspec; pub use natspec::NatSpec; -use crate::Config; - pub const INLINE_CONFIG_FUZZ_KEY: &str = "fuzz"; pub const INLINE_CONFIG_INVARIANT_KEY: &str = "invariant"; const INLINE_CONFIG_PREFIX: &str = "forge-config"; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 5e59cfe36461d..32444a5b7b89d 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -4,7 +4,6 @@ use crate::cache::StorageCachingConfig; use alloy_primitives::{address, Address, B256, U256}; -use ethers_core::types::Chain::Mainnet; use eyre::{ContextCompat, WrapErr}; use figment::{ providers::{Env, Format, Serialized, Toml}, @@ -36,6 +35,7 @@ use std::{ str::FromStr, }; pub(crate) use tracing::trace; +use NamedChain::Mainnet; // Macros useful for creating a figment. mod macros; @@ -55,7 +55,7 @@ pub mod cache; use cache::{Cache, ChainCache}; mod chain; -pub use chain::Chain; +pub use chain::{Chain, NamedChain}; pub mod fmt; pub use fmt::FormatterConfig; @@ -2480,9 +2480,8 @@ impl BasicConfig { } pub(crate) mod from_str_lowercase { - use std::str::FromStr; - use serde::{Deserialize, Deserializer, Serializer}; + use std::str::FromStr; pub fn serialize(value: &T, serializer: S) -> Result where @@ -2517,12 +2516,12 @@ mod tests { fs_permissions::PathPermission, }; use alloy_primitives::Address; - use ethers_core::types::Chain::Moonbeam; use figment::{error::Kind::InvalidType, value::Value, Figment}; use foundry_compilers::artifacts::{ModelCheckerEngine, YulDetails}; use pretty_assertions::assert_eq; use std::{collections::BTreeMap, fs::File, io::Write, str::FromStr}; use tempfile::tempdir; + use NamedChain::Moonbeam; // Helper function to clear `__warnings` in config, since it will be populated during loading // from file, causing testing problem when comparing to those created from `default()`, etc. @@ -2541,7 +2540,7 @@ mod tests { #[test] fn test_caching() { let mut config = Config::default(); - let chain_id = ethers_core::types::Chain::Mainnet; + let chain_id = NamedChain::Mainnet; let url = "https://eth-mainnet.alchemyapi"; assert!(config.enable_caching(url, chain_id)); @@ -2549,7 +2548,7 @@ mod tests { assert!(!config.enable_caching(url, chain_id)); config.no_storage_caching = false; - assert!(!config.enable_caching(url, ethers_core::types::Chain::Dev)); + assert!(!config.enable_caching(url, NamedChain::Dev)); } #[test] @@ -2925,16 +2924,14 @@ mod tests { let config = Config::load(); assert!(config.get_etherscan_config_with_chain(None::).unwrap().is_none()); assert!(config - .get_etherscan_config_with_chain(Some(ethers_core::types::Chain::BinanceSmartChain)) + .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain)) .is_err()); std::env::set_var(env_key, env_value); assert_eq!( config - .get_etherscan_config_with_chain(Some( - ethers_core::types::Chain::BinanceSmartChain - )) + .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain)) .unwrap() .unwrap() .key, @@ -2946,9 +2943,7 @@ mod tests { assert_eq!( with_key - .get_etherscan_config_with_chain(Some( - ethers_core::types::Chain::BinanceSmartChain - )) + .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain)) .unwrap() .unwrap() .key, @@ -3164,13 +3159,12 @@ mod tests { let mut config = Config::load(); - let optimism = config.get_etherscan_api_key(Some(ethers_core::types::Chain::Optimism)); + let optimism = config.get_etherscan_api_key(Some(NamedChain::Optimism)); assert_eq!(optimism, Some("https://etherscan-optimism.com/".to_string())); config.etherscan_api_key = Some("mumbai".to_string()); - let mumbai = - config.get_etherscan_api_key(Some(ethers_core::types::Chain::PolygonMumbai)); + let mumbai = config.get_etherscan_api_key(Some(NamedChain::PolygonMumbai)); assert_eq!(mumbai, Some("https://etherscan-mumbai.com/".to_string())); Ok(()) @@ -3193,7 +3187,7 @@ mod tests { let config = Config::load(); let mumbai = config - .get_etherscan_config_with_chain(Some(ethers_core::types::Chain::PolygonMumbai)) + .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai)) .unwrap() .unwrap(); assert_eq!(mumbai.key, "https://etherscan-mumbai.com/".to_string()); @@ -3218,7 +3212,7 @@ mod tests { let config = Config::load(); let mumbai = config - .get_etherscan_config_with_chain(Some(ethers_core::types::Chain::PolygonMumbai)) + .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai)) .unwrap() .unwrap(); assert_eq!(mumbai.key, "https://etherscan-mumbai.com/".to_string()); @@ -3300,8 +3294,8 @@ mod tests { via_ir: true, rpc_storage_caching: StorageCachingConfig { chains: CachedChains::Chains(vec![ - Chain::Named(ethers_core::types::Chain::Mainnet), - Chain::Named(ethers_core::types::Chain::Optimism), + Chain::Named(NamedChain::Mainnet), + Chain::Named(NamedChain::Optimism), Chain::Id(999999) ]), endpoints: CachedEndpoints::All diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index 2a01594606fb8..fa67b59294c80 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -10,13 +10,14 @@ homepage.workspace = true repository.workspace = true [dependencies] -foundry-evm.workspace = true +foundry-evm-core.workspace = true +foundry-evm-traces.workspace = true foundry-common.workspace = true alloy-primitives.workspace = true crossterm = "0.27" eyre.workspace = true +ratatui = { version = "0.24.0", default-features = false, features = ["crossterm"] } +revm.workspace = true tracing.workspace = true -revm = { workspace = true, default-features = false, features = ["std", "serde", "arbitrary"] } -ratatui = { version = "0.23.0", default-features = false, features = ["crossterm"] } diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index e65556bd5f24a..c036129e2661c 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,6 +1,7 @@ use crate::{TUIExitReason, Tui, Ui}; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm::{debug::DebugArena, traces::CallTraceDecoder}; +use foundry_evm_core::debug::DebugArena; +use foundry_evm_traces::CallTraceDecoder; use tracing::{error, trace}; /// Standardized way of firing up the debugger diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index c6f645e8a2c07..77b70d77a8ce8 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -11,12 +11,12 @@ use crossterm::{ }; use eyre::Result; use foundry_common::{compile::ContractSources, evm::Breakpoints}; -use foundry_evm::{ +use foundry_evm_core::{ debug::{DebugStep, Instruction}, utils::{build_pc_ic_map, CallKind, PCICMap}, }; use ratatui::{ - backend::{Backend, CrosstermBackend}, + backend::CrosstermBackend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, terminal::Frame, @@ -137,8 +137,8 @@ impl Tui { /// Create layout and subcomponents #[allow(clippy::too_many_arguments)] - fn draw_layout( - f: &mut Frame, + fn draw_layout( + f: &mut Frame<'_>, address: Address, identified_contracts: &HashMap, pc_ic_maps: &BTreeMap, @@ -189,8 +189,8 @@ impl Tui { } #[allow(clippy::too_many_arguments)] - fn vertical_layout( - f: &mut Frame, + fn vertical_layout( + f: &mut Frame<'_>, address: Address, identified_contracts: &HashMap, pc_ic_maps: &BTreeMap, @@ -267,8 +267,8 @@ impl Tui { } #[allow(clippy::too_many_arguments)] - fn square_layout( - f: &mut Frame, + fn square_layout( + f: &mut Frame<'_>, address: Address, identified_contracts: &HashMap, pc_ic_maps: &BTreeMap, @@ -360,7 +360,7 @@ impl Tui { } } - fn draw_footer(f: &mut Frame, area: Rect) { + fn draw_footer(f: &mut Frame<'_>, area: Rect) { let block_controls = Block::default(); let text_output = vec![Line::from(Span::styled( @@ -376,8 +376,8 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } #[allow(clippy::too_many_arguments)] - fn draw_src( - f: &mut Frame, + fn draw_src( + f: &mut Frame<'_>, address: Address, identified_contracts: &HashMap, pc_ic_maps: &BTreeMap, @@ -688,8 +688,8 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } /// Draw opcode list into main component - fn draw_op_list( - f: &mut Frame, + fn draw_op_list( + f: &mut Frame<'_>, address: Address, debug_steps: &[DebugStep], opcode_list: &[String], @@ -786,8 +786,8 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } /// Draw the stack into the stack pane - fn draw_stack( - f: &mut Frame, + fn draw_stack( + f: &mut Frame<'_>, debug_steps: &[DebugStep], current_step: usize, area: Rect, @@ -905,8 +905,8 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } /// Draw memory in memory pane - fn draw_memory( - f: &mut Frame, + fn draw_memory( + f: &mut Frame<'_>, debug_steps: &[DebugStep], current_step: usize, area: Rect, diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index cb0db0d18bfdc..4561c8674b697 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -11,34 +11,26 @@ homepage.workspace = true repository.workspace = true [dependencies] -# foundry internal forge-fmt.workspace = true +foundry-compilers = { workspace = true, features = ["async"] } foundry-config.workspace = true foundry-utils.workspace = true -foundry-compilers = { workspace = true, features = ["async"] } - -# ethers -ethers-core.workspace = true - -# tracing -tracing.workspace = true +alloy-primitives.workspace = true -# mdbook -mdbook = { version = "0.4", default-features = false, features = ["search"] } -warp = { version = "0.3", default-features = false, features = ["websocket"] } -tokio = { version = "1", features = ["macros", "rt-multi-thread"] } -futures-util = "0.3" - -# misc -solang-parser.workspace = true -eyre.workspace = true -thiserror = "1" -rayon = "1" -itertools.workspace = true -toml.workspace = true auto_impl = "1" derive_more = "0.99" +eyre.workspace = true +futures-util = "0.3" +itertools.workspace = true +mdbook = { version = "0.4", default-features = false, features = ["search"] } once_cell = "1" -serde.workspace = true +rayon = "1" serde_json.workspace = true +serde.workspace = true +solang-parser.workspace = true +thiserror = "1" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +toml.workspace = true +tracing.workspace = true +warp = { version = "0.3", default-features = false, features = ["websocket"] } diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index 09594e8c458ca..c9bfe9755419f 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -283,7 +283,7 @@ impl DocBuilder { document .target_path .parent() - .ok_or(eyre::format_err!("empty target path; noop"))?, + .ok_or_else(|| eyre::format_err!("empty target path; noop"))?, )?; fs::write(&document.target_path, document.as_doc()?)?; } diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index 158b013124abd..45e2b7261b93c 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -1,6 +1,5 @@ -use std::{collections::HashMap, path::PathBuf, sync::Mutex}; - use crate::{ParseItem, PreprocessorId, PreprocessorOutput}; +use std::{collections::HashMap, path::PathBuf, sync::Mutex}; /// The wrapper around the [ParseItem] containing additional /// information the original item and extra context for outputting it. diff --git a/crates/doc/src/preprocessor/contract_inheritance.rs b/crates/doc/src/preprocessor/contract_inheritance.rs index e5cd1e1747aad..3a9ad02a22cfa 100644 --- a/crates/doc/src/preprocessor/contract_inheritance.rs +++ b/crates/doc/src/preprocessor/contract_inheritance.rs @@ -1,7 +1,6 @@ -use forge_fmt::solang_ext::SafeUnwrap; - use super::{Preprocessor, PreprocessorId}; use crate::{document::DocumentContent, Document, ParseSource, PreprocessorOutput}; +use forge_fmt::solang_ext::SafeUnwrap; use std::{collections::HashMap, path::PathBuf}; /// [ContractInheritance] preprocessor id. diff --git a/crates/doc/src/preprocessor/deployments.rs b/crates/doc/src/preprocessor/deployments.rs index f29b357e1db10..b081ed59a0d71 100644 --- a/crates/doc/src/preprocessor/deployments.rs +++ b/crates/doc/src/preprocessor/deployments.rs @@ -1,7 +1,6 @@ -use ethers_core::types::Address; - use super::{Preprocessor, PreprocessorId}; use crate::{Document, PreprocessorOutput}; +use alloy_primitives::Address; use std::{fs, path::PathBuf}; /// [Deployments] preprocessor id. @@ -62,11 +61,10 @@ impl Preprocessor for Deployments { item_path_clone.set_extension("json"); // Determine the path of the deployment artifact relative to the root directory. - let deployment_path = deployments_dir.join(network).join( - item_path_clone - .file_name() - .ok_or(eyre::eyre!("Failed to extract file name from item path"))?, - ); + let deployment_path = + deployments_dir.join(network).join(item_path_clone.file_name().ok_or_else( + || eyre::eyre!("Failed to extract file name from item path"), + )?); // If the deployment file for the given contract is found, add the deployment // address to the document context. diff --git a/crates/doc/src/preprocessor/inheritdoc.rs b/crates/doc/src/preprocessor/inheritdoc.rs index 4abbdf15448a2..3989991865574 100644 --- a/crates/doc/src/preprocessor/inheritdoc.rs +++ b/crates/doc/src/preprocessor/inheritdoc.rs @@ -1,11 +1,9 @@ -use std::collections::HashMap; - -use forge_fmt::solang_ext::SafeUnwrap; - use super::{Preprocessor, PreprocessorId}; use crate::{ document::DocumentContent, Comments, Document, ParseItem, ParseSource, PreprocessorOutput, }; +use forge_fmt::solang_ext::SafeUnwrap; +use std::collections::HashMap; /// [ContractInheritance] preprocessor id. pub const INHERITDOC_ID: PreprocessorId = PreprocessorId("inheritdoc"); diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index ae501f379134f..f4e157befc736 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -1,5 +1,3 @@ -use std::path::Path; - use crate::{ document::{read_context, DocumentContent}, parser::ParseSource, @@ -10,6 +8,7 @@ use crate::{ use forge_fmt::solang_ext::SafeUnwrap; use itertools::Itertools; use solang_parser::pt::Base; +use std::path::Path; /// The result of [Asdoc::as_doc] method. pub type AsDocResult = Result; diff --git a/crates/doc/src/writer/buf_writer.rs b/crates/doc/src/writer/buf_writer.rs index f391fa400c15e..a68d5d837fb8b 100644 --- a/crates/doc/src/writer/buf_writer.rs +++ b/crates/doc/src/writer/buf_writer.rs @@ -1,10 +1,9 @@ +use crate::{AsDoc, CommentTag, Comments, Deployment, Markdown}; use itertools::Itertools; use once_cell::sync::Lazy; use solang_parser::pt::Parameter; use std::fmt::{self, Display, Write}; -use crate::{AsDoc, CommentTag, Comments, Deployment, Markdown}; - /// Solidity language name. const SOLIDITY: &str = "solidity"; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 14e686b034526..b919178a1a66f 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -18,7 +18,10 @@ foundry-compilers.workspace = true foundry-config.workspace = true foundry-utils.workspace = true -# EVM +alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-json-abi = { workspace = true } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-sol-types.workspace = true revm = { workspace = true, default-features = false, features = [ "std", "serde", @@ -28,30 +31,20 @@ revm = { workspace = true, default-features = false, features = [ "optional_no_base_fee", "arbitrary", ] } -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } -alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } -alloy-json-abi = { workspace = true } -alloy-sol-types.workspace = true -ethers = { workspace = true, features = ["ethers-solc"] } -# Encoding/decoding -serde_json = "1" -serde = "1" -hex.workspace = true +ethers-contract.workspace = true +ethers-core.workspace = true +ethers-providers.workspace = true -# Error handling eyre = "0.6" -thiserror = "1" - -# Logging -tracing = "0.1" - -# Threading/futures -tokio = { version = "1", features = ["time", "macros"] } -parking_lot = "0.12" futures = "0.3" +hex.workspace = true +itertools.workspace = true once_cell = "1" - -# Misc +parking_lot = "0.12" +serde = "1" +serde_json = "1" +thiserror = "1" +tokio = { version = "1", features = ["time", "macros"] } +tracing = "0.1" url = "2" -itertools.workspace = true diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index 7a13fda50d665..b22c768d404da 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -1,5 +1,5 @@ use alloy_primitives::{Address, B256, U256}; -use ethers::types::BlockId; +use ethers_core::types::BlockId; use futures::channel::mpsc::{SendError, TrySendError}; use std::{ convert::Infallible, diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index e08266f6673d6..eff28bfe10e1b 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -7,7 +7,7 @@ use crate::{ fork::{CreateFork, ForkId}, }; use alloy_primitives::{Address, B256, U256}; -use ethers::utils::GenesisAccount; +use ethers_core::utils::GenesisAccount; use revm::{ db::DatabaseRef, primitives::{AccountInfo, Bytecode, Env, ResultAndState}, diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index 9041258593455..6deec78d1e761 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -112,9 +112,8 @@ impl DatabaseRef for EmptyDBWrapper { #[cfg(test)] mod tests { - use alloy_primitives::b256; - use super::*; + use alloy_primitives::b256; /// Ensures the `Database(Ref)` implementation for `revm::CacheDB` works as expected /// diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index bdfe0a4c110ee..0ba428b9f35dd 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -7,9 +7,8 @@ use crate::{ utils::configure_tx_env, }; use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; -use ethers::{ - prelude::Block, - types::{BlockNumber, Transaction}, +use ethers_core::{ + types::{Block, BlockNumber, Transaction}, utils::GenesisAccount, }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 1d66f6286b0a3..2ffd23eb9ab5a 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -5,7 +5,8 @@ use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::JsonAbi; use alloy_primitives::B256; use alloy_sol_types::{SolCall, SolError, SolInterface, SolValue}; -use ethers::{abi::RawLog, contract::EthLogDecode, types::Log}; +use ethers_contract::EthLogDecode; +use ethers_core::{abi::RawLog, types::Log, utils::format_units}; use foundry_cheatcodes_defs::Vm; use foundry_common::SELECTOR_LEN; use itertools::Itertools; @@ -39,15 +40,11 @@ pub fn decode_console_log(log: &Log) -> Option { "{}: {}{}", inner.key, sign, - ethers::utils::format_units(val, inner.decimals.as_u32()).unwrap() + format_units(val, inner.decimals.as_u32()).unwrap() ) } CE::LogNamedDecimalUintFilter(inner) => { - format!( - "{}: {}", - inner.key, - ethers::utils::format_units(inner.val, inner.decimals.as_u32()).unwrap() - ) + format!("{}: {}", inner.key, format_units(inner.val, inner.decimals.as_u32()).unwrap()) } CE::LogNamedIntFilter(inner) => format!("{}: {:?}", inner.key, inner.val), CE::LogNamedUintFilter(inner) => format!("{}: {:?}", inner.key, inner.val), diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 587c3150c5673..5083327a66360 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -4,11 +4,11 @@ use crate::{ fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }; use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; -use ethers::{ - core::abi::ethereum_types::BigEndianHash, - providers::Middleware, +use ethers_core::{ + abi::ethereum_types::BigEndianHash, types::{Block, BlockId, NameOrAddress, Transaction}, }; +use ethers_providers::Middleware; use foundry_common::NON_ARCHIVE_NODE_WARNING; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::{ @@ -699,9 +699,8 @@ mod tests { fork::{BlockchainDbMeta, CreateFork, JsonBlockCacheDB}, opts::EvmOpts, }; - use ethers::types::Chain; use foundry_common::get_http_provider; - use foundry_config::Config; + use foundry_config::{Config, NamedChain}; use std::{collections::BTreeSet, path::PathBuf, sync::Arc}; const ENDPOINT: &str = "https://mainnet.infura.io/v3/40bee2d557ed4b52908c3e62345a3d8b"; @@ -795,7 +794,7 @@ mod tests { let db = BlockchainDb::new( meta, - Some(Config::foundry_block_cache_dir(Chain::Mainnet, block_num).unwrap()), + Some(Config::foundry_block_cache_dir(NamedChain::Mainnet, block_num).unwrap()), ); assert!(db.accounts().read().contains_key(&address)); assert!(db.storage().read().contains_key(&address)); diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 13596fee4796f..7d548440be75e 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -6,7 +6,7 @@ use crate::{ snapshot::Snapshots, }; use alloy_primitives::{Address, B256, U256}; -use ethers::types::BlockId; +use ethers_core::types::BlockId; use parking_lot::Mutex; use revm::{ db::{CacheDB, DatabaseRef}, diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index f04a19a89cb80..1c52072d49e04 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -1,9 +1,7 @@ use crate::utils::apply_chain_and_block_specific_env_changes; use alloy_primitives::{Address, U256}; -use ethers::{ - providers::Middleware, - types::{Block, TxHash}, -}; +use ethers_core::types::{Block, TxHash}; +use ethers_providers::Middleware; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; use foundry_utils::types::ToAlloy; diff --git a/crates/evm/core/src/fork/mod.rs b/crates/evm/core/src/fork/mod.rs index 8805c62b9356c..f9042ac91d3c5 100644 --- a/crates/evm/core/src/fork/mod.rs +++ b/crates/evm/core/src/fork/mod.rs @@ -1,10 +1,9 @@ -mod backend; - use super::opts::EvmOpts; -pub use backend::{BackendHandler, SharedBackend}; - use revm::primitives::Env; +mod backend; +pub use backend::{BackendHandler, SharedBackend}; + mod init; pub use init::environment; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 0f5065b9e3e16..cfcbc13d82769 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -4,10 +4,8 @@ //! concurrently active pairs at once. use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; -use ethers::{ - providers::Provider, - types::{BlockId, BlockNumber}, -}; +use ethers_core::types::{BlockId, BlockNumber}; +use ethers_providers::Provider; use foundry_common::{runtime_client::RuntimeClient, ProviderBuilder}; use foundry_config::Config; use foundry_utils::types::ToEthers; diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index dc49699769d72..09f33d0a1fe29 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,10 +1,8 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; -use ethers::{ - providers::{Middleware, Provider}, - types::{Block, Chain, TxHash}, -}; +use ethers_core::types::{Block, Chain, TxHash}; +use ethers_providers::{Middleware, Provider}; use eyre::WrapErr; use foundry_common::{self, ProviderBuilder, RpcUrl, ALCHEMY_FREE_TIER_CUPS}; use foundry_compilers::utils::RuntimeOrHandle; diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index e03930ea42a05..f4196ac589c50 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,6 +1,6 @@ use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, FixedBytes, B256}; -use ethers::types::{ActionType, Block, CallType, Chain, Transaction, H256, U256}; +use ethers_core::types::{ActionType, Block, CallType, Chain, Transaction, H256, U256}; use eyre::ContextCompat; use foundry_utils::types::ToAlloy; use revm::{ diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 68727729a8ae9..44067b2ceaadf 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -15,17 +15,17 @@ foundry-cheatcodes.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true -foundry-evm-coverage.workspace = true foundry-evm-core.workspace = true +foundry-evm-coverage.workspace = true foundry-evm-fuzz.workspace = true foundry-evm-traces.workspace = true foundry-macros.workspace = true foundry-utils.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -ethers = { workspace = true, features = ["ethers-solc"] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-sol-types.workspace = true hashbrown = { version = "0.14", features = ["serde"] } revm = { workspace = true, default-features = false, features = [ "std", @@ -37,6 +37,9 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } +ethers-core.workspace = true +ethers-signers.workspace = true + eyre = "0.6" hex.workspace = true parking_lot = "0.12" diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 5a8346980d98c..19250984cc61e 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -1,8 +1,8 @@ use super::{BasicTxDetails, InvariantContract}; use crate::executors::{Executor, RawCallResult}; use alloy_json_abi::Function; -use alloy_primitives::Address; -use ethers::types::Log; +use alloy_primitives::{Address, Bytes}; +use ethers_core::types::Log; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::{constants::CALLER, decode::decode_revert}; @@ -63,7 +63,7 @@ pub struct InvariantFuzzError { /// Address of the invariant asserter. pub addr: Address, /// Function data for invariant check. - pub func: Option, + pub func: Option, /// Inner fuzzing Sequence coming from overriding calls. pub inner_sequence: Vec>, /// Shrink the failed test case to the smallest sequence. @@ -80,7 +80,7 @@ impl InvariantFuzzError { shrink: bool, ) -> Self { let (func, origin) = if let Some(f) = error_func { - (Some(f.selector().0.into()), f.name.as_str()) + (Some(f.selector().to_vec().into()), f.name.as_str()) } else { (None, "Revert") }; @@ -159,7 +159,7 @@ impl InvariantFuzzError { // Checks the invariant. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, self.addr, func.0.clone().into(), U256::ZERO) + .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) .expect("bad call to evm"); traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); @@ -194,13 +194,13 @@ impl InvariantFuzzError { let (sender, (addr, bytes)) = details; executor - .call_raw_committing(*sender, *addr, bytes.0.clone().into(), U256::ZERO) + .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) .expect("bad call to evm"); // Checks the invariant. If we exit before the last call, all the better. if let Some(func) = &self.func { let error_call_result = executor - .call_raw(CALLER, self.addr, func.0.clone().into(), U256::ZERO) + .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) .expect("bad call to evm"); if error_call_result.reverted { diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index e4b1454f5a1d7..1c3de4407a223 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -2,7 +2,7 @@ use super::{InvariantFailures, InvariantFuzzError}; use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use ethers::types::Log; +use ethers_core::types::Log; use foundry_common::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CALLER; use foundry_evm_coverage::HitMaps; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 19b256541a7f1..fdfe0da701da7 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -12,7 +12,8 @@ use crate::inspectors::{ use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes, U256}; -use ethers::{signers::LocalWallet, types::Log}; +use ethers_core::types::Log; +use ethers_signers::LocalWallet; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; use foundry_evm_core::{ backend::{Backend, DatabaseError, DatabaseExt, DatabaseResult, FuzzBackendWrapper}, diff --git a/crates/evm/evm/src/executors/tracing.rs b/crates/evm/evm/src/executors/tracing.rs index 5734355afcc89..bf94679330c2d 100644 --- a/crates/evm/evm/src/executors/tracing.rs +++ b/crates/evm/evm/src/executors/tracing.rs @@ -1,6 +1,6 @@ use crate::executors::{Executor, ExecutorBuilder}; use foundry_compilers::EvmVersion; -use foundry_config::{utils::evm_spec_id, Config}; +use foundry_config::{utils::evm_spec_id, Config, NamedChain}; use foundry_evm_core::{backend::Backend, fork::CreateFork, opts::EvmOpts}; use revm::primitives::Env; use std::ops::{Deref, DerefMut}; @@ -32,7 +32,7 @@ impl TracingExecutor { pub async fn get_fork_material( config: &Config, mut evm_opts: EvmOpts, - ) -> eyre::Result<(Env, Option, Option)> { + ) -> eyre::Result<(Env, Option, Option)> { evm_opts.fork_url = Some(config.get_rpc_url_or_localhost_http()?.into_owned()); evm_opts.fork_block_number = config.fork_block_number; diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs index e7bf56e072920..8d193fb05589d 100644 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ b/crates/evm/evm/src/inspectors/access_list.rs @@ -1,5 +1,5 @@ use alloy_primitives::{Address, B256}; -use ethers::types::transaction::eip2930::{AccessList, AccessListItem}; +use ethers_core::types::transaction::eip2930::{AccessList, AccessListItem}; use foundry_utils::types::{ToAlloy, ToEthers}; use hashbrown::{HashMap, HashSet}; use revm::{ diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index 8ad4cb648e77b..88b655cbc7a6f 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,7 +1,8 @@ use alloy_primitives::{Address, Bytes, B256}; -use ethers::{ - abi::{AbiDecode, Token}, - types::{Bytes as ethersBytes, Log, H256}, +use alloy_sol_types::SolValue; +use ethers_core::{ + abi::AbiDecode, + types::{Log, H256}, }; use foundry_evm_core::{ abi::{patch_hardhat_console_selector, HardhatConsoleCalls}, @@ -31,7 +32,7 @@ impl LogCollector { Err(err) => { return ( InstructionResult::Revert, - ethers::abi::encode(&[Token::String(err.to_string())]).into(), + foundry_cheatcodes::Error::encode(err.to_string()), ) } }; @@ -48,7 +49,7 @@ impl Inspector for LogCollector { self.logs.push(Log { address: address.to_ethers(), topics: topics.iter().copied().map(|t| t.to_ethers()).collect(), - data: ethersBytes::from(data.clone().0), + data: data.clone().0.into(), ..Default::default() }); } @@ -79,7 +80,5 @@ const TOPIC: H256 = H256([ fn convert_hh_log_to_event(call: HardhatConsoleCalls) -> Log { // Convert the parameters of the call to their string representation using `ConsoleFmt`. let fmt = call.fmt(Default::default()); - let token = Token::String(fmt); - let data = ethers::abi::encode(&[token]).into(); - Log { topics: vec![TOPIC], data, ..Default::default() } + Log { topics: vec![TOPIC], data: fmt.abi_encode().into(), ..Default::default() } } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 1b63955660a41..0bc25df44cb37 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -3,7 +3,8 @@ use super::{ TracePrinter, Tracer, }; use alloy_primitives::{Address, Bytes, B256, U256}; -use ethers::{signers::LocalWallet, types::Log}; +use ethers_core::types::Log; +use ethers_signers::LocalWallet; use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index bec6bdbb6542f..498ae95681815 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -14,15 +14,14 @@ repository.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true -foundry-evm-coverage.workspace = true foundry-evm-core.workspace = true +foundry-evm-coverage.workspace = true foundry-evm-traces.workspace = true foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi = { workspace = true } alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } -ethers = { workspace = true, features = ["ethers-solc"] } revm = { workspace = true, default-features = false, features = [ "std", "serde", @@ -33,11 +32,14 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } +ethers-core.workspace = true + arbitrary = "1.3.1" eyre = "0.6" hashbrown = { version = "0.14", features = ["serde"] } parking_lot = "0.12" proptest = "1" +rand.workspace = true serde = "1" thiserror = "1" tracing = "0.1" diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index e3e5a04e9c742..62f622409f8e7 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -9,7 +9,7 @@ extern crate tracing; use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; use alloy_primitives::{Address, Bytes, U256}; -use ethers::types::Log; +use ethers_core::types::Log; use foundry_common::{calc, contracts::ContractsByAddress}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; diff --git a/crates/evm/fuzz/src/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs index 1f9ade01d133e..5c95235f2a3a7 100644 --- a/crates/evm/fuzz/src/strategies/int.rs +++ b/crates/evm/fuzz/src/strategies/int.rs @@ -1,12 +1,9 @@ -use std::ops::{Add, Shl, Sub}; - -use ethers::core::rand::Rng; +use alloy_primitives::{Sign, I256, U256}; use proptest::{ strategy::{NewTree, Strategy, ValueTree}, test_runner::TestRunner, }; - -use alloy_primitives::{Sign, I256, U256}; +use rand::Rng; /// Value tree for signed ints (up to int256). /// This is very similar to [proptest::BinarySearch] @@ -106,13 +103,12 @@ impl IntStrategy { let rng = runner.rng(); let offset = I256::from_raw(U256::from(rng.gen_range(0..4))); - let umax: U256 = (U256::from(1u8).shl(self.bits - 1)).sub(U256::from(1u8)); + let umax: U256 = (U256::from(1) << (self.bits - 1)) - U256::from(1); // Choose if we want values around min, -0, +0, or max let kind = rng.gen_range(0..4); let start = match kind { 0 => { - I256::overflowing_from_sign_and_abs(Sign::Negative, umax.add(U256::from(1))).0 + - offset + I256::overflowing_from_sign_and_abs(Sign::Negative, umax + U256::from(1)).0 + offset } 1 => -offset - I256::ONE, 2 => offset, diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index e09531938d7d5..74e5a8e966900 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -3,7 +3,7 @@ use crate::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}; use alloy_dyn_abi::{DynSolType, JsonAbiExt}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, B256, U256}; -use ethers::types::Log; +use ethers_core::types::Log; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; diff --git a/crates/evm/fuzz/src/strategies/uint.rs b/crates/evm/fuzz/src/strategies/uint.rs index ceb403f3b9bc8..5f53d838754aa 100644 --- a/crates/evm/fuzz/src/strategies/uint.rs +++ b/crates/evm/fuzz/src/strategies/uint.rs @@ -1,12 +1,9 @@ -use std::ops::Shl; - -use ethers::core::rand::Rng; +use alloy_primitives::U256; use proptest::{ strategy::{NewTree, Strategy, ValueTree}, test_runner::TestRunner, }; - -use alloy_primitives::U256; +use rand::Rng; /// Value tree for unsigned ints (up to uint256). /// This is very similar to [proptest::BinarySearch] @@ -100,11 +97,8 @@ impl UintStrategy { // Choose if we want values around 0 or max let is_min = rng.gen_bool(0.5); let offset = U256::from(rng.gen_range(0..4)); - let max = if self.bits < 256 { - (U256::from(1u8).shl(self.bits)) - U256::from(1) - } else { - U256::MAX - }; + let max = + if self.bits < 256 { (U256::from(1) << self.bits) - U256::from(1) } else { U256::MAX }; let start = if is_min { offset } else { max.saturating_sub(offset) }; Ok(UintValueTree::new(start, false)) } diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index d04c5a8db0ecd..7edaedd94e0ff 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -22,16 +22,9 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true -ethers = { workspace = true, features = ["ethers-solc"] } -revm = { workspace = true, default-features = false, features = [ - "std", - "serde", - "memory_limit", - "optional_eip3607", - "optional_block_gas_limit", - "optional_no_base_fee", - "arbitrary", -] } +revm.workspace = true + +ethers-core.workspace = true eyre = "0.6" futures = "0.3" @@ -46,6 +39,5 @@ tracing = "0.1" yansi = "0.5" [dev-dependencies] -ethers = { workspace = true, features = ["ethers-solc", "rustls"] } foundry-utils.workspace = true tempfile = "3" diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 18c53aeace008..63a08cb8aa191 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -8,7 +8,7 @@ extern crate tracing; use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; -use ethers::types::{DefaultFrame, GethDebugTracingOptions, StructLog}; +use ethers_core::types::{DefaultFrame, GethDebugTracingOptions, StructLog}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::{constants::CHEATCODE_ADDRESS, debug::Instruction, utils::CallKind}; use foundry_utils::types::ToEthers; diff --git a/crates/evm/traces/src/node.rs b/crates/evm/traces/src/node.rs index 9bd89ada88c6a..29bba93f1c192 100644 --- a/crates/evm/traces/src/node.rs +++ b/crates/evm/traces/src/node.rs @@ -1,5 +1,5 @@ use crate::{CallTrace, LogCallOrder, TraceLog}; -use ethers::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; +use ethers_core::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; use foundry_evm_core::utils::CallKind; use foundry_utils::types::ToEthers; use revm::interpreter::InstructionResult; diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index a954d14527b95..dab6e4b8f68dc 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -10,23 +10,18 @@ homepage.workspace = true repository.workspace = true [dependencies] -# foundry dep foundry-config.workspace = true -# alloy alloy-primitives.workspace = true -# parser -solang-parser.workspace = true - -# misc +ariadne = "0.3" itertools.workspace = true +solang-parser.workspace = true thiserror = "1" -ariadne = "0.3" tracing.workspace = true [dev-dependencies] -pretty_assertions = "1" itertools.workspace = true +pretty_assertions.workspace = true toml.workspace = true tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/crates/fmt/src/buffer.rs b/crates/fmt/src/buffer.rs index d1842a2951b08..2f26f650b72bb 100644 --- a/crates/fmt/src/buffer.rs +++ b/crates/fmt/src/buffer.rs @@ -1,11 +1,10 @@ -//! Format buffer - -use std::fmt::Write; +//! Format buffer. use crate::{ comments::{CommentState, CommentStringExt}, string::{QuoteState, QuotedStringExt}, }; +use std::fmt::Write; /// An indent group. The group may optionally skip the first line #[derive(Default, Clone, Debug)] diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index b5fabb2d93b88..95dba14d4996c 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -33,14 +33,14 @@ pub enum FormatterError { InvalidParsedItem(Loc), /// All other errors #[error(transparent)] - Custom(Box), + Custom(Box), } impl FormatterError { fn fmt() -> Self { Self::Fmt(std::fmt::Error) } - fn custom(err: impl std::error::Error + 'static) -> Self { + fn custom(err: impl std::error::Error + Send + Sync + 'static) -> Self { Self::Custom(Box::new(err)) } } diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index 719f85d80160a..9d2988a6342b8 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -33,7 +33,7 @@ pub fn parse(src: &str) -> Result> { } /// Format parsed code -pub fn format( +pub fn format_to( writer: W, mut parsed: Parsed, config: FormatterConfig, @@ -45,11 +45,11 @@ pub fn format( } /// Parse and format a string with default settings -pub fn fmt(src: &str) -> Result { +pub fn format(src: &str) -> Result { let parsed = parse(src).map_err(|_| FormatterError::Fmt(std::fmt::Error))?; let mut output = String::new(); - format(&mut output, parsed, FormatterConfig::default())?; + format_to(&mut output, parsed, FormatterConfig::default())?; Ok(output) } diff --git a/crates/fmt/src/lib.rs b/crates/fmt/src/lib.rs index 66f8bc4a5d35c..958d74647451c 100644 --- a/crates/fmt/src/lib.rs +++ b/crates/fmt/src/lib.rs @@ -19,6 +19,8 @@ pub use foundry_config::fmt::*; pub use comments::Comments; pub use formatter::{Formatter, FormatterError}; -pub use helpers::{fmt, format, offset_to_line_column, parse, print_diagnostics_report, Parsed}; +pub use helpers::{ + format, format_to, offset_to_line_column, parse, print_diagnostics_report, Parsed, +}; pub use inline_config::InlineConfig; pub use visit::{Visitable, Visitor}; diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 6d06fca366114..7aaed58e5fb83 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -1,4 +1,4 @@ -use forge_fmt::{format, parse, solang_ext::AstEq, FormatterConfig}; +use forge_fmt::{format_to, parse, solang_ext::AstEq, FormatterConfig}; use itertools::Itertools; use std::{fs, path::PathBuf}; use tracing_subscriber::{EnvFilter, FmtSubscriber}; @@ -115,7 +115,7 @@ fn test_formatter(filename: &str, config: FormatterConfig, source: &str, expecte let expected = PrettyString(expected_source.to_string()); let mut source_formatted = String::new(); - format(&mut source_formatted, source_parsed, config.clone()).unwrap(); + format_to(&mut source_formatted, source_parsed, config.clone()).unwrap(); assert_eof(&source_formatted); // println!("{}", source_formatted); @@ -129,7 +129,7 @@ fn test_formatter(filename: &str, config: FormatterConfig, source: &str, expecte ); let mut expected_formatted = String::new(); - format(&mut expected_formatted, expected_parsed, config).unwrap(); + format_to(&mut expected_formatted, expected_parsed, config).unwrap(); assert_eof(&expected_formatted); let expected_formatted = PrettyString(expected_formatted); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 3e45cb1936b07..81627865efad0 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -19,15 +19,20 @@ vergen = { version = "8", default-features = false, features = ["build", "git", [dependencies] # lib -foundry-utils.workspace = true +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-common.workspace = true +foundry-compilers = { workspace = true, features = ["full"] } foundry-config.workspace = true foundry-evm.workspace = true +foundry-utils.workspace = true + +ethers-contract.workspace = true +ethers-core.workspace = true +ethers-middleware.workspace = true +ethers-providers.workspace = true +ethers-signers.workspace = true comfy-table = "7" -ethers = { workspace = true, features = ["solc-full"] } -foundry-compilers = { workspace = true, features = ["full"] } -foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } eyre.workspace = true proptest = "1" rayon = "1" @@ -36,14 +41,14 @@ tracing.workspace = true yansi = "0.5" # bin -forge-fmt.workspace = true forge-doc.workspace = true +forge-fmt.workspace = true foundry-cli.workspace = true foundry-debugger.workspace = true -alloy-primitives = { workspace = true, features = ["serde"] } -alloy-json-abi.workspace = true alloy-dyn-abi.workspace = true +alloy-json-abi.workspace = true +alloy-primitives = { workspace = true, features = ["serde"] } async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } @@ -75,7 +80,7 @@ foundry-test-utils.workspace = true criterion = "0.5" globset = "0.4" path-slash = "0.2" -pretty_assertions = "1" +pretty_assertions.workspace = true serial_test = "2" svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } tempfile = "3" diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 1a88d20289c96..925a4071846c5 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -1,5 +1,5 @@ use clap::{Parser, ValueHint}; -use ethers::contract::{Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts}; +use ethers_contract::{Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts}; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{compile, fs::json_files}; diff --git a/crates/forge/bin/cmd/cache.rs b/crates/forge/bin/cmd/cache.rs index e70a2c66f2c83..53dbeb9fbcb8a 100644 --- a/crates/forge/bin/cmd/cache.rs +++ b/crates/forge/bin/cmd/cache.rs @@ -3,9 +3,8 @@ use clap::{ builder::{PossibleValuesParser, TypedValueParser}, Arg, Command, Parser, Subcommand, }; -use ethers::prelude::Chain; use eyre::Result; -use foundry_config::{cache, Chain as FoundryConfigChain, Config}; +use foundry_config::{cache, Chain, Config, NamedChain}; use std::{ffi::OsStr, str::FromStr}; use strum::VariantNames; @@ -61,7 +60,9 @@ impl CleanArgs { for chain_or_all in chains { match chain_or_all { - ChainOrAll::Chain(chain) => clean_chain_cache(chain, blocks.to_vec(), etherscan)?, + ChainOrAll::NamedChain(chain) => { + clean_chain_cache(chain, blocks.to_vec(), etherscan)? + } ChainOrAll::All => { if etherscan { Config::clean_foundry_etherscan_cache()?; @@ -95,7 +96,7 @@ impl LsArgs { let mut cache = Cache::default(); for chain_or_all in chains { match chain_or_all { - ChainOrAll::Chain(chain) => { + ChainOrAll::NamedChain(chain) => { cache.chains.push(Config::list_foundry_chain_cache(chain.into())?) } ChainOrAll::All => cache = Config::list_foundry_cache()?, @@ -108,7 +109,7 @@ impl LsArgs { #[derive(Debug, Clone)] pub enum ChainOrAll { - Chain(Chain), + NamedChain(NamedChain), All, } @@ -116,8 +117,8 @@ impl FromStr for ChainOrAll { type Err = String; fn from_str(s: &str) -> Result { - if let Ok(chain) = ethers::prelude::Chain::from_str(s) { - Ok(ChainOrAll::Chain(chain)) + if let Ok(chain) = NamedChain::from_str(s) { + Ok(ChainOrAll::NamedChain(chain)) } else if s == "all" { Ok(ChainOrAll::All) } else { @@ -126,11 +127,7 @@ impl FromStr for ChainOrAll { } } -fn clean_chain_cache( - chain: impl Into, - blocks: Vec, - etherscan: bool, -) -> Result<()> { +fn clean_chain_cache(chain: impl Into, blocks: Vec, etherscan: bool) -> Result<()> { let chain = chain.into(); if blocks.is_empty() { Config::clean_foundry_etherscan_chain_cache(chain)?; @@ -177,7 +174,7 @@ impl TypedValueParser for ChainOrAllValueParser { } fn possible_chains() -> PossibleValuesParser { - Some(&"all").into_iter().chain(Chain::VARIANTS).into() + Some(&"all").into_iter().chain(NamedChain::VARIANTS).into() } #[cfg(test)] diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index a418b9c7d93cd..3591d0c0cc10e 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -3,15 +3,16 @@ use alloy_dyn_abi::{DynSolValue, JsonAbiExt, ResolveSolType}; use alloy_json_abi::{Constructor, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes}; use clap::{Parser, ValueHint}; -use ethers::{ +use ethers_contract::ContractError; +use ethers_core::{ abi::InvalidOutputType, - contract::ContractError, - prelude::{Middleware, MiddlewareBuilder}, types::{ transaction::eip2718::TypedTransaction, BlockNumber, Chain, Eip1559TransactionRequest, TransactionReceipt, TransactionRequest, }, }; +use ethers_middleware::MiddlewareBuilder; +use ethers_providers::Middleware; use eyre::{Context, Result}; use foundry_cli::{ opts::{CoreBuildArgs, EthereumOpts, EtherscanOpts, TransactionOpts}, @@ -466,12 +467,12 @@ where /// /// # Example /// -/// ```no_run +/// ``` +/// # async fn foo() -> Result<(), Box> { +/// use alloy_primitives::Bytes; /// use ethers_contract::ContractFactory; -/// use ethers_core::types::Bytes; /// use ethers_providers::{Provider, Http}; /// -/// # async fn foo() -> Result<(), Box> { /// // get the contract ABI and bytecode /// let abi = Default::default(); /// let bytecode = Bytes::from_static(b"..."); diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index cdbaaca4fef72..8f5bc5b97f248 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -1,6 +1,6 @@ use clap::{Parser, ValueHint}; use eyre::Result; -use forge_fmt::{format, parse, print_diagnostics_report}; +use forge_fmt::{format_to, parse, print_diagnostics_report}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; use foundry_common::{fs, term::cli_warn}; use foundry_config::impl_figment_convert_basic; @@ -117,7 +117,7 @@ impl FmtArgs { } let mut output = String::new(); - format(&mut output, parsed, config.fmt.clone()).unwrap(); + format_to(&mut output, parsed, config.fmt.clone()).unwrap(); solang_parser::parse(&output, 0).map_err(|diags| { eyre::eyre!( diff --git a/crates/forge/bin/cmd/fourbyte.rs b/crates/forge/bin/cmd/fourbyte.rs deleted file mode 100644 index 0288d327816f9..0000000000000 --- a/crates/forge/bin/cmd/fourbyte.rs +++ /dev/null @@ -1,93 +0,0 @@ -use clap::Parser; -use eyre::Result; -use foundry_cli::{ - opts::{CompilerArgs, CoreBuildArgs, ProjectPathsArgs}, - utils::FoundryPathExt, -}; -use foundry_common::{ - compile, - selectors::{import_selectors, SelectorImportData}, - shell, -}; -use foundry_compilers::artifacts::output_selection::ContractOutputSelection; -use yansi::Paint; - -/// CLI arguments for `forge upload-selectors`. -#[derive(Debug, Clone, Parser)] -pub struct UploadSelectorsArgs { - /// The name of the contract to upload selectors for. - #[clap(required_unless_present = "all")] - pub contract: Option, - - /// Upload selectors for all contracts in the project. - #[clap(long, required_unless_present = "contract")] - pub all: bool, - - #[clap(flatten)] - pub project_paths: ProjectPathsArgs, -} - -impl UploadSelectorsArgs { - /// Builds a contract and uploads the ABI to selector database - pub async fn run(self) -> Result<()> { - shell::println(Paint::yellow("Warning! This command is deprecated and will be removed in v1, use `forge selectors upload` instead"))?; - - let UploadSelectorsArgs { contract, all, project_paths } = self; - - let build_args = CoreBuildArgs { - project_paths: project_paths.clone(), - compiler: CompilerArgs { - extra_output: vec![ContractOutputSelection::Abi], - ..Default::default() - }, - ..Default::default() - }; - - let project = build_args.project()?; - let outcome = compile::suppress_compile(&project)?; - let artifacts = if all { - outcome - .into_artifacts_with_files() - .filter(|(file, _, _)| { - let is_sources_path = - file.starts_with(&project.paths.sources.to_string_lossy().to_string()); - let is_test = file.is_sol_test(); - - is_sources_path && !is_test - }) - .map(|(_, contract, artifact)| (contract, artifact)) - .collect() - } else { - let contract = contract.unwrap(); - let found_artifact = outcome.find_first(&contract); - let artifact = found_artifact - .ok_or_else(|| { - eyre::eyre!("Could not find artifact `{contract}` in the compiled artifacts") - })? - .clone(); - vec![(contract, artifact)] - }; - - let mut artifacts = artifacts.into_iter().peekable(); - while let Some((contract, artifact)) = artifacts.next() { - let abi = artifact.abi.ok_or(eyre::eyre!("Unable to fetch abi"))?; - if abi.abi.functions.is_empty() && - abi.abi.events.is_empty() && - abi.abi.errors.is_empty() - { - continue - } - - println!("Uploading selectors for {contract}..."); - - // upload abi to selector database - import_selectors(SelectorImportData::Abi(vec![abi])).await?.describe(); - - if artifacts.peek().is_some() { - println!() - } - } - - Ok(()) - } -} diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 4ef3cd2fbdfab..42f72b8c4f3ea 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -1,6 +1,6 @@ +use alloy_json_abi::JsonAbi; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; -use ethers::abi::RawAbi; use eyre::Result; use foundry_cli::opts::{CompilerArgs, CoreBuildArgs}; use foundry_common::compile; @@ -10,7 +10,7 @@ use foundry_compilers::{ BytecodeOutputSelection, ContractOutputSelection, DeployedBytecodeOutputSelection, EvmOutputSelection, EwasmOutputSelection, }, - LosslessAbi, StorageLayout, + StorageLayout, }, info::ContractInfo, utils::canonicalize, @@ -90,7 +90,7 @@ impl InspectArgs { .abi .as_ref() .ok_or_else(|| eyre::eyre!("Failed to fetch lossless ABI"))?; - print_abi(abi, pretty)?; + print_abi(&abi.abi, pretty)?; } ContractArtifactField::Bytecode => { let tval: Value = to_value(&artifact.bytecode)?; @@ -165,7 +165,8 @@ impl InspectArgs { } ContractArtifactField::Errors => { let mut out = serde_json::Map::new(); - if let Some(LosslessAbi { abi, .. }) = &artifact.abi { + if let Some(abi) = &artifact.abi { + let abi = &abi.abi; // Print the signature of all errors for er in abi.errors.iter().flat_map(|(_, errors)| errors) { let types = er.inputs.iter().map(|p| p.ty.clone()).collect::>(); @@ -181,7 +182,8 @@ impl InspectArgs { } ContractArtifactField::Events => { let mut out = serde_json::Map::new(); - if let Some(LosslessAbi { abi, .. }) = &artifact.abi { + if let Some(abi) = &artifact.abi { + let abi = &abi.abi; // print the signature of all events including anonymous for ev in abi.events.iter().flat_map(|(_, events)| events) { let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::>(); @@ -199,17 +201,13 @@ impl InspectArgs { } } -pub fn print_abi(abi: &LosslessAbi, pretty: bool) -> Result<()> { - let abi_json = to_value(abi)?; - if !pretty { - println!("{}", serde_json::to_string_pretty(&abi_json)?); - return Ok(()) - } - - let abi_json: RawAbi = serde_json::from_value(abi_json)?; - let source = foundry_utils::abi::abi_to_solidity(&abi_json, "")?; - println!("{}", source); - +pub fn print_abi(abi: &JsonAbi, pretty: bool) -> Result<()> { + let s = if pretty { + foundry_utils::abi::abi_to_solidity(abi, "")? + } else { + serde_json::to_string_pretty(&abi)? + }; + println!("{s}"); Ok(()) } diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index 1c88f21ca29e9..7b0c979efe6eb 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -49,7 +49,6 @@ pub mod debug; pub mod doc; pub mod flatten; pub mod fmt; -pub mod fourbyte; pub mod geiger; pub mod generate; pub mod init; diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 020e2155028a2..e2ad7b22845b5 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -2,11 +2,9 @@ use super::{ multi::MultiChainSequence, providers::ProvidersManager, receipts::clear_pendings, sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, *, }; -use ethers::{ - prelude::{Provider, Signer, TxHash}, - providers::{JsonRpcClient, Middleware}, - utils::format_units, -}; +use ethers_core::{types::TxHash, utils::format_units}; +use ethers_providers::{JsonRpcClient, Middleware, Provider}; +use ethers_signers::Signer; use eyre::{bail, ContextCompat, Result, WrapErr}; use foundry_cli::{ init_progress, diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 58fe6eb71d4af..242e5f30f0d25 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -41,7 +41,7 @@ impl ScriptArgs { if let Some(source) = artifact.source_file() { let abs_path = source .ast - .ok_or(eyre::eyre!("Source from artifact has no AST."))? + .ok_or_else(|| eyre::eyre!("Source from artifact has no AST."))? .absolute_path; let source_code = fs::read_to_string(abs_path).wrap_err_with(|| { format!("Failed to read artifact source file for `{}`", id.identifier()) diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index dd1102301dbab..8d7e9e41c53b4 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -1,9 +1,8 @@ use super::{multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, *}; use alloy_primitives::Bytes; -use ethers::{ - prelude::{Middleware, Signer}, - types::transaction::eip2718::TypedTransaction, -}; +use ethers_core::types::transaction::eip2718::TypedTransaction; +use ethers_providers::Middleware; +use ethers_signers::Signer; use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 242971ba50142..f346c71be2f7e 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -5,7 +5,7 @@ use super::{ *, }; use alloy_primitives::{Address, Bytes, U256}; -use ethers::types::transaction::eip2718::TypedTransaction; +use ethers_core::types::transaction::eip2718::TypedTransaction; use eyre::Result; use forge::{ backend::Backend, diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 37b878ecc8bc4..b182adc8c95ba 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -5,13 +5,11 @@ use alloy_json_abi::{Function, InternalType, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueHint}; use dialoguer::Confirm; -use ethers::{ - providers::{Http, Middleware}, - signers::LocalWallet, - types::{ - transaction::eip2718::TypedTransaction, Chain, Log, NameOrAddress, TransactionRequest, - }, +use ethers_core::types::{ + transaction::eip2718::TypedTransaction, Chain, Log, NameOrAddress, TransactionRequest, }; +use ethers_providers::{Http, Middleware}; +use ethers_signers::LocalWallet; use eyre::{ContextCompat, Result, WrapErr}; use forge::{ backend::Backend, @@ -440,7 +438,7 @@ impl ScriptArgs { transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(from.to_ethers()), data: Some(bytes.clone().0.into()), - nonce: Some(ethers::types::U256::from(nonce + i as u64)), + nonce: Some((nonce + i as u64).into()), ..Default::default() }), }) @@ -699,7 +697,7 @@ impl ScriptConfig { /// If not, warns the user. async fn check_shanghai_support(&self) -> Result<()> { let chain_ids = self.total_rpcs.iter().map(|rpc| async move { - if let Ok(provider) = ethers::providers::Provider::::try_from(rpc) { + if let Ok(provider) = ethers_providers::Provider::::try_from(rpc) { match provider.get_chainid().await { Ok(chain_id) => match TryInto::::try_into(chain_id) { Ok(chain) => return Some((SHANGHAI_ENABLED_CHAINS.contains(&chain), chain)), @@ -740,7 +738,7 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855"#, mod tests { use super::*; use foundry_cli::utils::LoadConfig; - use foundry_config::UnresolvedEnvVarError; + use foundry_config::{NamedChain, UnresolvedEnvVarError}; use std::fs; use tempfile::tempdir; @@ -856,7 +854,7 @@ mod tests { ]); let config = args.load_config(); - let mumbai = config.get_etherscan_api_key(Some(ethers::types::Chain::PolygonMumbai)); + let mumbai = config.get_etherscan_api_key(Some(NamedChain::PolygonMumbai)); assert_eq!(mumbai, Some("https://etherscan-mumbai.com/".to_string())); } diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index 3dc292a3b5766..2f7548cb9b5c5 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -4,7 +4,7 @@ use super::{ verify::VerifyBundle, ScriptArgs, }; -use ethers::signers::LocalWallet; +use ethers_signers::LocalWallet; use eyre::{ContextCompat, Report, Result, WrapErr}; use foundry_cli::utils::now; use foundry_common::{fs, get_http_provider}; diff --git a/crates/forge/bin/cmd/script/providers.rs b/crates/forge/bin/cmd/script/providers.rs index 6031a76fea59d..d2f6bb17a76d1 100644 --- a/crates/forge/bin/cmd/script/providers.rs +++ b/crates/forge/bin/cmd/script/providers.rs @@ -1,5 +1,5 @@ use alloy_primitives::U256; -use ethers::prelude::{Middleware, Provider}; +use ethers_providers::{Middleware, Provider}; use eyre::{Result, WrapErr}; use foundry_common::{get_http_provider, runtime_client::RuntimeClient, RpcUrl}; use foundry_config::Chain; diff --git a/crates/forge/bin/cmd/script/receipts.rs b/crates/forge/bin/cmd/script/receipts.rs index f09329c35c9cf..4752ddfd918e7 100644 --- a/crates/forge/bin/cmd/script/receipts.rs +++ b/crates/forge/bin/cmd/script/receipts.rs @@ -1,6 +1,7 @@ use super::sequence::ScriptSequence; use alloy_primitives::TxHash; -use ethers::{prelude::PendingTransaction, providers::Middleware, types::TransactionReceipt}; +use ethers_core::types::TransactionReceipt; +use ethers_providers::{Middleware, PendingTransaction}; use eyre::Result; use foundry_cli::{init_progress, update_progress, utils::print_receipt}; use foundry_common::RetryProvider; diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 798b36c3aeeab..db18be6770c72 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -1,6 +1,6 @@ use super::*; use alloy_primitives::{Address, Bytes, U256}; -use ethers::types::NameOrAddress; +use ethers_core::types::NameOrAddress; use eyre::Result; use forge::{ constants::CALLER, diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index ed4d2a697b3ab..0fce7ef52653d 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -8,7 +8,7 @@ use crate::cmd::{ verify::provider::VerificationProviderType, }; use alloy_primitives::{Address, TxHash}; -use ethers::{prelude::TransactionReceipt, types::transaction::eip2718::TypedTransaction}; +use ethers_core::types::{transaction::eip2718::TypedTransaction, TransactionReceipt}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_cli::utils::now; use foundry_common::{fs, shell, SELECTOR_LEN}; diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 592b5355ce35b..514f6e7861834 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -2,7 +2,7 @@ use super::{artifacts::ArtifactInfo, ScriptResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::{Address, B256}; -use ethers::{prelude::NameOrAddress, types::transaction::eip2718::TypedTransaction}; +use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{fmt::format_token_raw, RpcUrl, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder, utils::CallKind}; @@ -258,8 +258,7 @@ impl TransactionWithMetadata { // wrapper for modifying ethers-rs type serialization pub mod wrapper { pub use super::*; - - use ethers::{ + use ethers_core::{ types::{Bloom, Bytes, Log, TransactionReceipt, H256, U256, U64}, utils::to_checksum, }; diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 8689f9fdcb9c9..97030af8a0464 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -106,11 +106,8 @@ impl SelectorsSubcommands { let mut artifacts = artifacts.into_iter().peekable(); while let Some((contract, artifact)) = artifacts.next() { - let abi = artifact.abi.ok_or(eyre::eyre!("Unable to fetch abi"))?; - if abi.abi.functions.is_empty() && - abi.abi.events.is_empty() && - abi.abi.errors.is_empty() - { + let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?.abi; + if abi.functions.is_empty() && abi.events.is_empty() && abi.errors.is_empty() { continue } @@ -237,11 +234,8 @@ impl SelectorsSubcommands { let mut artifacts = artifacts.into_iter().peekable(); while let Some((contract, artifact)) = artifacts.next() { - let abi = artifact.abi.ok_or(eyre::eyre!("Unable to fetch abi"))?; - if abi.abi.functions.is_empty() && - abi.abi.events.is_empty() && - abi.abi.errors.is_empty() - { + let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?.abi; + if abi.functions.is_empty() && abi.events.is_empty() && abi.errors.is_empty() { continue } @@ -251,19 +245,19 @@ impl SelectorsSubcommands { table.set_header(vec!["Type", "Signature", "Selector"]); - for func in abi.abi.functions() { + for func in abi.functions() { let sig = func.signature(); let selector = func.selector(); table.add_row(vec!["Function", &sig, &hex::encode_prefixed(selector)]); } - for event in abi.abi.events() { + for event in abi.events() { let sig = event.signature(); let selector = event.selector(); table.add_row(vec!["Event", &sig, &hex::encode_prefixed(selector)]); } - for error in abi.abi.errors() { + for error in abi.errors() { let sig = error.signature(); let selector = error.selector(); table.add_row(vec!["Error", &sig, &hex::encode_prefixed(selector)]); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 7b389e59fec59..a1ffc2bd5960d 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -301,7 +301,7 @@ impl TestArgs { if let Some(source) = artifact.source_file() { let abs_path = source .ast - .ok_or(eyre::eyre!("Source from artifact has no AST."))? + .ok_or_else(|| eyre::eyre!("Source from artifact has no AST."))? .absolute_path; let source_code = fs::read_to_string(abs_path)?; let contract = artifact.clone().into_contract_bytecode(); diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 1b467ab623c76..e2a4281de30b0 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -408,10 +408,11 @@ impl EtherscanVerificationProvider { let (_, _, contract) = self.cache_entry(project, &args.contract.name).wrap_err( "Cache must be enabled in order to use the `--constructor-args-path` option", )?; - let abi = contract.abi.as_ref().ok_or(eyre!("Can't find ABI in cached artifact."))?; + let abi = + contract.abi.as_ref().ok_or_else(|| eyre!("Can't find ABI in cached artifact."))?; let constructor = abi .constructor() - .ok_or(eyre!("Can't retrieve constructor info from artifact ABI."))?; + .ok_or_else(|| eyre!("Can't retrieve constructor info from artifact ABI."))?; #[allow(deprecated)] let func = Function { name: "constructor".to_string(), diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index e4489ec8277d5..642c51b5dae3a 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -84,7 +84,6 @@ fn main() -> Result<()> { Subcommands::Config(cmd) => cmd.run(), Subcommands::Flatten(cmd) => cmd.run(), Subcommands::Inspect(cmd) => cmd.run(), - Subcommands::UploadSelectors(args) => utils::block_on(args.run()), Subcommands::Tree(cmd) => cmd.run(), Subcommands::Geiger(cmd) => { let check = cmd.check; diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 68c2683ca14e2..28b5039811ce7 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -8,7 +8,6 @@ use crate::cmd::{ doc::DocArgs, flatten, fmt::FmtArgs, - fourbyte::UploadSelectorsArgs, geiger, generate, init::InitArgs, inspect, @@ -148,11 +147,6 @@ pub enum Subcommands { #[clap(visible_alias = "in")] Inspect(inspect::InspectArgs), - /// Uploads abi of given contract to the https://api.openchain.xyz - /// function selector database. - #[clap(visible_alias = "up")] - UploadSelectors(UploadSelectorsArgs), - /// Display a tree visualization of the project's dependency graph. #[clap(visible_alias = "tr")] Tree(tree::TreeArgs), diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index f2e9d522f3072..e92106be5fe07 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,7 +1,7 @@ //! test outcomes use alloy_primitives::Address; -use ethers::prelude::Log; +use ethers_core::types::Log; use foundry_common::evm::Breakpoints; use foundry_evm::{ coverage::HitMaps, diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index cf5bb35c3aecb..4b5f89b340f0f 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -6,7 +6,9 @@ use foundry_compilers::{ remappings::Remapping, ConfigurableContractArtifact, }; -use foundry_config::{parse_with_profile, BasicConfig, Chain, Config, SolidityErrorCode}; +use foundry_config::{ + parse_with_profile, BasicConfig, Chain, Config, NamedChain, SolidityErrorCode, +}; use foundry_test_utils::{ foundry_compilers::PathStyle, util::{pretty_err, read_string, OutputExt, TestCommand}, @@ -37,7 +39,7 @@ forgetest!( #[ignore] can_cache_ls, |_prj, cmd| { - let chain = Chain::Named(ethers::prelude::Chain::Mainnet); + let chain = Chain::Named(NamedChain::Mainnet); let block1 = 100; let block2 = 101; @@ -134,7 +136,7 @@ forgetest!( #[ignore] can_cache_clean_chain, |_prj, cmd| { - let chain = Chain::Named(ethers::prelude::Chain::Mainnet); + let chain = Chain::Named(NamedChain::Mainnet); let cache_dir = Config::foundry_chain_cache_dir(chain).unwrap(); let etherscan_cache_dir = Config::foundry_etherscan_chain_cache_dir(chain).unwrap(); let path = cache_dir.as_path(); @@ -157,7 +159,7 @@ forgetest!( #[ignore] can_cache_clean_blocks, |_prj, cmd| { - let chain = Chain::Named(ethers::prelude::Chain::Mainnet); + let chain = Chain::Named(NamedChain::Mainnet); let block1 = 100; let block2 = 101; let block3 = 102; @@ -191,12 +193,9 @@ forgetest!( #[ignore] can_cache_clean_chain_etherscan, |_prj, cmd| { - let cache_dir = - Config::foundry_chain_cache_dir(Chain::Named(ethers::prelude::Chain::Mainnet)).unwrap(); - let etherscan_cache_dir = Config::foundry_etherscan_chain_cache_dir(Chain::Named( - ethers::prelude::Chain::Mainnet, - )) - .unwrap(); + let cache_dir = Config::foundry_chain_cache_dir(Chain::Named(NamedChain::Mainnet)).unwrap(); + let etherscan_cache_dir = + Config::foundry_etherscan_chain_cache_dir(Chain::Named(NamedChain::Mainnet)).unwrap(); let path = cache_dir.as_path(); let etherscan_path = etherscan_cache_dir.as_path(); fs::create_dir_all(path).unwrap(); diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 61961f4fff0f9..fca4621960362 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -4,8 +4,8 @@ use crate::{ constants::*, utils::{self, EnvExternalities}, }; +use alloy_primitives::Address; use anvil::{spawn, NodeConfig}; -use ethers::types::Address; use foundry_compilers::{artifacts::BytecodeHash, remappings::Remapping}; use foundry_config::Config; use foundry_test_utils::{ diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 146bf4ca7d701..e7624e5890344 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1,13 +1,11 @@ -//! Contains various tests related to forge script +//! Contains various tests related to `forge script`. + use crate::constants::TEMPLATE_CONTRACT; +use alloy_primitives::Address; use anvil::{spawn, NodeConfig}; -use ethers::abi::Address; use foundry_config::Config; use foundry_test_utils::{util::OutputExt, ScriptOutcome, ScriptTester}; -use foundry_utils::{ - rpc, - types::{ToAlloy, ToEthers}, -}; +use foundry_utils::{rpc, types::ToEthers}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; @@ -353,10 +351,12 @@ contract DeployScript is Script { let run_log = std::fs::read_to_string("broadcast/DeployScript.sol/1/run-latest.json").unwrap(); let run_object: Value = serde_json::from_str(&run_log).unwrap(); - let contract_address = ethers::utils::to_checksum( - &run_object["receipts"][0]["contractAddress"].as_str().unwrap().parse().unwrap(), - None, - ); + let contract_address = &run_object["receipts"][0]["contractAddress"] + .as_str() + .unwrap() + .parse::
() + .unwrap() + .to_string(); let run_code = r#" // SPDX-License-Identifier: UNLICENSED @@ -377,7 +377,7 @@ contract RunScript is Script { } } }"# - .replace("CONTRACT_ADDRESS", &contract_address); + .replace("CONTRACT_ADDRESS", contract_address); let run_script = prj.inner().add_source("RunScript", run_code).unwrap(); let run_contract = run_script.display().to_string() + ":RunScript"; @@ -442,15 +442,15 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_addresses(vec![Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906") - .unwrap() - .to_alloy()]) + .load_addresses(vec![ + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() + ]) .await .add_sig("BroadcastTest", "deployPrivateKey()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) .assert_nonce_increment_addresses(vec![( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap().to_alloy(), + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), 3, )]) .await; @@ -481,15 +481,15 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_addresses(vec![Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906") - .unwrap() - .to_alloy()]) + .load_addresses(vec![ + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() + ]) .await .add_sig("BroadcastTest", "deployRememberKey()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) .assert_nonce_increment_addresses(vec![( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap().to_alloy(), + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), 2, )]) .await; @@ -505,9 +505,9 @@ forgetest_async!( tester .add_deployer(0) - .load_addresses(vec![Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906") - .unwrap() - .to_alloy()]) + .load_addresses(vec![ + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() + ]) .await .add_sig("BroadcastTest", "deployRememberKeyResume()") .simulate(ScriptOutcome::OkSimulation) @@ -517,7 +517,7 @@ forgetest_async!( .await .run(ScriptOutcome::OkBroadcast) .assert_nonce_increment_addresses(vec![( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap().to_alloy(), + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), 1, )]) .await @@ -593,7 +593,7 @@ forgetest_async!(can_deploy_with_create2, |prj, cmd| { // Prepare CREATE2 Deployer api.anvil_set_code( foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER.to_ethers(), - ethers::types::Bytes::from_static( + ethers_core::types::Bytes::from_static( foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, ), ) @@ -684,7 +684,7 @@ forgetest_async!( // Prepare CREATE2 Deployer let addr = Address::from_str("0x4e59b44847b379578588920ca78fbf26c0b4956c").unwrap(); let code = hex::decode("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3").expect("Could not decode create2 deployer init_code").into(); - api.anvil_set_code(addr, code).await.unwrap(); + api.anvil_set_code(addr.to_ethers(), code).await.unwrap(); tester .load_private_keys([0]) diff --git a/crates/forge/tests/cli/utils.rs b/crates/forge/tests/cli/utils.rs index 2c6fbe3bdb0f1..12b0fe13470f4 100644 --- a/crates/forge/tests/cli/utils.rs +++ b/crates/forge/tests/cli/utils.rs @@ -1,6 +1,7 @@ //! Various helper functions -use ethers::prelude::{Address, Chain, LocalWallet, Signer}; +use ethers_core::types::{Address, Chain}; +use ethers_signers::{LocalWallet, Signer}; /// Returns the current millis since unix epoch. /// diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index ab1424d0e8abd..bfd28d1435b96 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -214,8 +214,7 @@ async fn test_invariant_storage() { } #[tokio::test(flavor = "multi_thread")] -// for some reason there's different rng -#[cfg(not(windows))] +#[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_shrink() { let mut runner = runner().await; diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index cbc6cae8af12f..2fbc01a6b72a8 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -2,7 +2,7 @@ use crate::{config::*, test_helpers::PROJECT}; use alloy_primitives::Address; -use ethers::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; +use ethers_core::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; use forge::result::TestStatus; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_test_utils::Filter; diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index de56c69b6b82a..ef9913b1fb758 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -13,5 +13,6 @@ repository.workspace = true foundry-macros-impl = { path = "impl" } ethers-core.workspace = true + serde.workspace = true serde_json.workspace = true diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 4c282f86d9af8..fafff94f82beb 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -12,20 +12,21 @@ homepage.workspace = true repository.workspace = true [dependencies] -foundry-config.workspace = true foundry-common.workspace = true +foundry-compilers = { workspace = true, features = ["project-util"] } +foundry-config.workspace = true foundry-utils.workspace = true -ethers.workspace = true alloy-primitives.workspace = true -foundry-compilers = { workspace = true, features = ["project-util"] } +ethers-core.workspace = true +ethers-providers.workspace = true eyre.workspace = true fd-lock = "4.0.0" once_cell = "1" parking_lot = "0.12" -pretty_assertions = "1" +pretty_assertions.workspace = true regex = "1" serde_json.workspace = true tracing = "0.1" diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 9c39fd2e6ae55..6a848b744419c 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,6 +1,7 @@ use crate::{init_tracing, TestCommand}; use alloy_primitives::{Address, U256}; -use ethers::prelude::{Middleware, NameOrAddress}; +use ethers_core::types::NameOrAddress; +use ethers_providers::Middleware; use eyre::Result; use foundry_common::{get_http_provider, RetryProvider}; use foundry_utils::types::{ToAlloy, ToEthers}; diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 0daf16756b8c3..acbb6041fffdb 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -10,19 +10,17 @@ homepage.workspace = true repository.workspace = true [dependencies] +foundry-compilers = { workspace = true, default-features = false } forge-fmt.workspace = true -ethers-core.workspace = true -ethers-contract = { workspace = true, features = ["abigen"] } -ethers-addressbook.workspace = true -ethers-providers.workspace = true - alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-sol-types.workspace = true -foundry-compilers = { workspace = true, default-features = false } +ethers-core.workspace = true +ethers-providers.workspace = true +dunce = "1" eyre = { version = "0.6", default-features = false } futures = "0.3" glob = "0.3" @@ -30,8 +28,6 @@ once_cell = "1" rand = "0.8" serde_json.workspace = true tracing.workspace = true -dunce = "1" [dev-dependencies] foundry-common.workspace = true -pretty_assertions = "1.3.0" diff --git a/crates/utils/src/abi.rs b/crates/utils/src/abi.rs index 2901181ab1721..19cb0ebbb0aee 100644 --- a/crates/utils/src/abi.rs +++ b/crates/utils/src/abi.rs @@ -1,411 +1,8 @@ -//! Convert a json abi into solidity inerface +use alloy_json_abi::JsonAbi; +use eyre::Result; -use ethers_contract::InternalStructs; -use ethers_core::{ - abi, - abi::{ - struct_def::{FieldType, StructFieldType}, - Contract as Abi, Event, EventParam, Function, Param, ParamType, RawAbi, SolStruct, - }, -}; -use std::collections::BTreeMap; - -/// This function takes a contract [`Abi`] and a name and proceeds to generate a Solidity -/// `interface` from that ABI. If the provided name is empty, then it defaults to `interface -/// Interface`. -/// -/// This is done by iterating over the functions and their ABI inputs/outputs, and generating -/// function signatures/inputs/outputs according to the ABI. -/// -/// Notes: -/// * ABI Encoder V2 is not supported yet -/// * Kudos to [maxme/abi2solidity](https://github.com/maxme/abi2solidity) for the algorithm -/// -/// Note: This takes a raw representation of the json abi (`RawAbi`) because the `ethers::abi::Abi` -/// does not deserialize the internal type of nested params which is required in order to generate -/// structs -pub fn abi_to_solidity(contract_abi: &RawAbi, mut contract_name: &str) -> eyre::Result { - if contract_name.trim().is_empty() { - contract_name = "Interface"; - }; - - let structs = InternalStructs::new(contract_abi.clone()); - - // this is a bit horrible but the easiest way to convert the types - let abi_str = serde_json::to_string(contract_abi)?; - let contract_abi: Abi = serde_json::from_str(&abi_str)?; - - let mut events = Vec::with_capacity(contract_abi.events.len()); - for event in contract_abi.events() { - let inputs = event - .inputs - .iter() - .enumerate() - .map(|(idx, param)| format_event_params(event, param, idx, &structs)) - .collect::>>()? - .join(", "); - - let event_string = format!("event {}({inputs});", event.name); - events.push(event_string); - } - - let mut functions = Vec::with_capacity(contract_abi.functions.len()); - for function in contract_abi.functions() { - let inputs = function - .inputs - .iter() - .map(|param| format_function_input_param(function, param, &structs)) - .collect::>>()? - .join(", "); - - let outputs = function - .outputs - .iter() - .map(|param| format_function_output_param(function, param, &structs)) - .collect::>>()? - .join(", "); - - let mutability = match function.state_mutability { - abi::StateMutability::Pure => "pure", - abi::StateMutability::View => "view", - abi::StateMutability::Payable => "payable", - _ => "", - }; - - let mut func = format!("function {}({inputs})", function.name); - if !mutability.is_empty() { - func = format!("{func} {mutability}"); - } - func = format!("{func} external"); - if !outputs.is_empty() { - func = format!("{func} returns ({outputs})"); - } - - functions.push(format!("{func};")); - } - - let functions = functions.join("\n"); - let events = events.join("\n"); - - let sol = if structs.structs_types().is_empty() { - if events.is_empty() { - format!( - r#"interface {contract_name} {{ - {functions} -}} -"# - ) - } else { - format!( - r#"interface {contract_name} {{ - {events} - - {functions} -}} -"# - ) - } - } else { - let structs = format_struct_types(&structs); - match events.is_empty() { - true => format!( - r#"interface {contract_name} {{ - {structs} - - {functions} -}} -"# - ), - false => format!( - r#"interface {contract_name} {{ - {events} - - {structs} - - {functions} -}} -"# - ), - } - }; - forge_fmt::fmt(&sol).map_err(|err| eyre::eyre!(err.to_string())) -} - -/// returns the Tokenstream for the corresponding rust type of the param -fn expand_input_param_type( - fun: &Function, - param: &str, - kind: &ParamType, - structs: &InternalStructs, -) -> eyre::Result { - match kind { - ParamType::Array(ty) => { - let ty = expand_input_param_type(fun, param, ty, structs)?; - Ok(format!("{ty}[]")) - } - ParamType::FixedArray(ty, size) => { - let ty = expand_input_param_type(fun, param, ty, structs)?; - Ok(format!("{ty}[{}]", *size)) - } - ParamType::Tuple(_) => { - let ty = if let Some(struct_name) = - structs.get_function_input_struct_solidity_id(&fun.name, param) - { - struct_name.rsplit('.').next().unwrap().to_string() - } else { - kind.to_string() - }; - Ok(ty) - } - _ => Ok(kind.to_string()), - } -} - -fn expand_output_param_type( - fun: &Function, - param: &Param, - kind: &ParamType, - structs: &InternalStructs, -) -> eyre::Result { - match kind { - ParamType::Array(ty) => { - let ty = expand_output_param_type(fun, param, ty, structs)?; - Ok(format!("{ty}[]")) - } - ParamType::FixedArray(ty, size) => { - let ty = expand_output_param_type(fun, param, ty, structs)?; - Ok(format!("{ty}[{}]", *size)) - } - ParamType::Tuple(_) => { - if param.internal_type.is_none() { - let result = - kind.to_string().trim_start_matches('(').trim_end_matches(')').to_string(); - Ok(result) - } else { - let ty = if let Some(struct_name) = structs.get_function_output_struct_solidity_id( - &fun.name, - param.internal_type.as_ref().unwrap(), - ) { - struct_name.rsplit('.').next().unwrap().to_string() - } else { - kind.to_string() - }; - Ok(ty) - } - } - _ => Ok(kind.to_string()), - } -} - -// Returns the function parameter formatted as a string, as well as inserts into the provided -// `structs` set in order to create type definitions for any Abi Encoder v2 structs. -fn format_function_input_param( - func: &Function, - param: &Param, - structs: &InternalStructs, -) -> eyre::Result { - let kind = expand_input_param_type(func, ¶m.name, ¶m.kind, structs)?; - Ok(format_param(param, kind)) -} - -// Returns the function parameter formatted as a string, as well as inserts into the provided -// `structs` set in order to create type definitions for any Abi Encoder v2 structs. -fn format_function_output_param( - func: &Function, - param: &Param, - structs: &InternalStructs, -) -> eyre::Result { - let kind = expand_output_param_type(func, param, ¶m.kind, structs)?; - Ok(format_param(param, kind)) -} - -fn format_param(param: &Param, kind: String) -> String { - // add `memory` if required (not needed for events, only for functions) - let is_memory = match param.kind { - ParamType::Array(_) | - ParamType::Bytes | - ParamType::String | - ParamType::FixedArray(_, _) => true, - ParamType::Tuple(_) => param.internal_type.is_some(), - _ => false, - }; - - let kind = if is_memory { format!("{kind} memory") } else { kind }; - - if param.name.is_empty() { - kind - } else { - format!("{kind} {}", param.name) - } -} - -/// returns the Tokenstream for the corresponding rust type of the event_param -fn expand_event_param_type( - event: &Event, - kind: &ParamType, - idx: usize, - structs: &InternalStructs, -) -> eyre::Result { - match kind { - ParamType::Array(ty) => { - let ty = expand_event_param_type(event, ty, idx, structs)?; - Ok(format!("{ty}[]")) - } - ParamType::FixedArray(ty, size) => { - let ty = expand_event_param_type(event, ty, idx, structs)?; - Ok(format!("{ty}[{}]", *size)) - } - ParamType::Tuple(_) => { - let ty = if let Some(struct_name) = - structs.get_event_input_struct_solidity_id(&event.name, idx) - { - struct_name.rsplit('.').next().unwrap().to_string() - } else { - kind.to_string() - }; - Ok(ty) - } - _ => Ok(kind.to_string()), - } -} - -fn format_event_params( - event: &Event, - param: &EventParam, - idx: usize, - structs: &InternalStructs, -) -> eyre::Result { - let kind = expand_event_param_type(event, ¶m.kind, idx, structs)?; - let ty = if param.name.is_empty() { - kind - } else if param.indexed { - format!("{kind} indexed {}", param.name) - } else { - format!("{kind} {}", param.name) - }; - Ok(ty) -} - -/// Returns all struct type defs -fn format_struct_types(structs: &InternalStructs) -> String { - structs - .structs_types() - .iter() - .collect::>() - .into_iter() - .map(|(name, ty)| format_struct_field(name, ty)) - .collect::>() - .join("\n") -} - -fn format_struct_field(name: &str, sol_struct: &SolStruct) -> String { - // strip member access if any - let name = name.split('.').last().unwrap(); - let mut def = format!("struct {name} {{\n"); - for field in sol_struct.fields.iter() { - let ty = match &field.ty { - FieldType::Elementary(ty) => ty.to_string(), - FieldType::Struct(ty) => struct_field_to_type(ty), - FieldType::Mapping(_) => { - unreachable!("illegal mapping type") - } - }; - - def.push_str(&format!("{ty} {};\n", field.name)); - } - - def.push('}'); - - def -} - -fn struct_field_to_type(ty: &StructFieldType) -> String { - match ty { - StructFieldType::Type(ty) => ty.name().to_string(), - StructFieldType::Array(ty) => { - format!("{}[]", struct_field_to_type(ty)) - } - StructFieldType::FixedArray(ty, size) => { - format!("{}[{}]", struct_field_to_type(ty), *size) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - #[cfg(any(target_os = "linux", target_os = "macos"))] - fn abi2solidity() { - let contract_abi: RawAbi = serde_json::from_str(include_str!( - "../../../testdata/fixtures/SolidityGeneration/InterfaceABI.json" - )) - .unwrap(); - pretty_assertions::assert_eq!( - include_str!( - "../../../testdata/fixtures/SolidityGeneration/GeneratedNamedInterface.sol" - ), - abi_to_solidity(&contract_abi, "test").unwrap() - ); - pretty_assertions::assert_eq!( - include_str!( - "../../../testdata/fixtures/SolidityGeneration/GeneratedUnnamedInterface.sol" - ), - abi_to_solidity(&contract_abi, "").unwrap() - ); - } - #[test] - #[cfg(any(target_os = "linux", target_os = "macos"))] - fn abi2solidity_gaugecontroller() { - let contract_abi: RawAbi = serde_json::from_str(include_str!( - "../../../testdata/fixtures/SolidityGeneration/GaugeController.json" - )) - .unwrap(); - pretty_assertions::assert_eq!( - include_str!( - "../../../testdata/fixtures/SolidityGeneration/GeneratedGaugeController.sol" - ), - abi_to_solidity(&contract_abi, "test").unwrap() - ); - } - #[test] - #[cfg(any(target_os = "linux", target_os = "macos"))] - fn abi2dolidity_liquiditygauge() { - let contract_abi: RawAbi = serde_json::from_str(include_str!( - "../../../testdata/fixtures/SolidityGeneration/LiquidityGaugeV4.json" - )) - .unwrap(); - pretty_assertions::assert_eq!( - include_str!( - "../../../testdata/fixtures/SolidityGeneration/GeneratedLiquidityGaugeV4.sol" - ), - abi_to_solidity(&contract_abi, "test").unwrap() - ); - } - #[test] - #[cfg(any(target_os = "linux", target_os = "macos"))] - fn abi2solidity_fastlane() { - let contract_abi: RawAbi = serde_json::from_str(include_str!( - "../../../testdata/fixtures/SolidityGeneration/Fastlane.json" - )) - .unwrap(); - pretty_assertions::assert_eq!( - include_str!("../../../testdata/fixtures/SolidityGeneration/GeneratedFastLane.sol"), - abi_to_solidity(&contract_abi, "test").unwrap() - ); - } - - #[test] - #[cfg(any(target_os = "linux", target_os = "macos"))] - fn abi2solidity_with_structs() { - let contract_abi: RawAbi = serde_json::from_str(include_str!( - "../../../testdata/fixtures/SolidityGeneration/WithStructs.json" - )) - .unwrap(); - pretty_assertions::assert_eq!( - include_str!("../../../testdata/fixtures/SolidityGeneration/WithStructs.sol").trim(), - abi_to_solidity(&contract_abi, "test").unwrap().trim() - ); - } +pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { + let s = abi.to_sol(name); + let s = forge_fmt::format(&s)?; + Ok(s) } diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index c2ba8efe71219..635522a9ffa0c 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -1,9 +1,9 @@ #![doc = include_str!("../README.md")] #![warn(unused_crate_dependencies)] +use crate::types::{ToAlloy, ToEthers}; use alloy_primitives::{Address, Bytes}; -use ethers_addressbook::contract; -use ethers_core::types::{BlockId, Chain, NameOrAddress}; +use ethers_core::types::BlockId; use ethers_providers::{Middleware, Provider}; use eyre::{Result, WrapErr}; use foundry_compilers::{ @@ -22,8 +22,6 @@ use std::{ }; use tracing::trace; -use crate::types::{ToAlloy, ToEthers}; - pub mod abi; pub mod error; pub mod glob; @@ -431,30 +429,6 @@ pub fn to_table(value: serde_json::Value) -> String { } } -/// Resolves an input to [`NameOrAddress`]. The input could also be a contract/token name supported -/// by -/// [`ethers-addressbook`](https://github.com/gakonst/ethers-rs/tree/master/ethers-addressbook). -pub fn resolve_addr>(to: T, chain: Option) -> Result { - Ok(match to.into() { - NameOrAddress::Address(addr) => NameOrAddress::Address(addr), - NameOrAddress::Name(contract_or_ens) => { - if let Some(contract) = contract(&contract_or_ens) { - let chain = chain - .ok_or_else(|| eyre::eyre!("resolving contract requires a known chain"))?; - NameOrAddress::Address(contract.address(chain).ok_or_else(|| { - eyre::eyre!( - "contract: {} not found in addressbook for network: {}", - contract_or_ens, - chain - ) - })?) - } else { - NameOrAddress::Name(contract_or_ens) - } - } - }) -} - /// Reads the `ETHERSCAN_API_KEY` env variable pub fn etherscan_api_key() -> eyre::Result { std::env::var("ETHERSCAN_API_KEY").map_err(|err| match err { @@ -536,7 +510,6 @@ pub async fn next_nonce( #[cfg(test)] mod tests { use super::*; - use ethers_core::types::Address; use foundry_common::ContractsByArtifact; use foundry_compilers::{Project, ProjectPathsConfig}; @@ -585,7 +558,7 @@ mod tests { self.contracts, &mut ContractsByArtifact::default(), Default::default(), - sender.to_alloy(), + sender, initial_nonce, &mut called_once, |post_link_input| { @@ -615,7 +588,7 @@ mod tests { let expected_lib_id = format!("{}:{:?}", expected.0, expected.2); assert_eq!(expected_lib_id, actual.id, "unexpected dependency, expected: {}, got: {}", expected_lib_id, actual.id); assert_eq!(actual.nonce, expected.1, "nonce wrong for dependency, expected: {}, got: {}", expected.1, actual.nonce); - assert_eq!(actual.address.to_ethers(), expected.2, "address wrong for dependency, expected: {}, got: {}", expected.2, actual.address); + assert_eq!(actual.address, expected.2, "address wrong for dependency, expected: {}, got: {}", expected.2, actual.address); } Ok(()) @@ -857,46 +830,4 @@ mod tests { ) .test_with_sender_and_nonce(Address::default(), 1); } - - #[test] - fn test_resolve_addr() { - use std::str::FromStr; - - // DAI:mainnet exists in ethers-addressbook (0x6b175474e89094c44da98b954eedeac495271d0f) - assert_eq!( - resolve_addr(NameOrAddress::Name("dai".to_string()), Some(Chain::Mainnet)).ok(), - Some(NameOrAddress::Address( - Address::from_str("0x6b175474e89094c44da98b954eedeac495271d0f").unwrap() - )) - ); - - // DAI:goerli exists in ethers-adddressbook (0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844) - assert_eq!( - resolve_addr(NameOrAddress::Name("dai".to_string()), Some(Chain::Goerli)).ok(), - Some(NameOrAddress::Address( - Address::from_str("0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844").unwrap() - )) - ); - - // DAI:moonbean does not exist in addressbook - assert!( - resolve_addr(NameOrAddress::Name("dai".to_string()), Some(Chain::MoonbeamDev)).is_err() - ); - - // If not present in addressbook, gets resolved to an ENS name. - assert_eq!( - resolve_addr( - NameOrAddress::Name("contractnotpresent".to_string()), - Some(Chain::Mainnet) - ) - .ok(), - Some(NameOrAddress::Name("contractnotpresent".to_string())), - ); - - // Nothing to resolve for an address. - assert_eq!( - resolve_addr(NameOrAddress::Address(Address::zero()), Some(Chain::Mainnet)).ok(), - Some(NameOrAddress::Address(Address::zero())), - ); - } } diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index 712784ab2c9bf..a450ee688e884 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -1,10 +1,10 @@ //! Temporary utility conversion traits between ethers-rs and alloy types. use alloy_json_abi::{Event, EventParam, Function, InternalType, Param, StateMutability}; -use alloy_primitives::{Address, B256, U256 as AlloyU256, U64 as AlloyU64}; +use alloy_primitives::{Address, B256, I256, U256, U64}; use ethers_core::{ abi as ethabi, - types::{H160, H256, U256, U64}, + types::{H160, H256, I256 as EthersI256, U256 as EthersU256, U64 as EthersU64}, }; /// Conversion trait to easily convert from Ethers types to Alloy types. @@ -33,30 +33,39 @@ impl ToAlloy for H256 { } } -impl ToAlloy for U256 { - type To = AlloyU256; +impl ToAlloy for EthersU256 { + type To = U256; #[inline(always)] fn to_alloy(self) -> Self::To { - AlloyU256::from_limbs(self.0) + U256::from_limbs(self.0) } } -impl ToAlloy for U64 { - type To = AlloyU64; +impl ToAlloy for EthersI256 { + type To = I256; #[inline(always)] fn to_alloy(self) -> Self::To { - AlloyU64::from_limbs(self.0) + I256::from_raw(self.into_raw().to_alloy()) + } +} + +impl ToAlloy for EthersU64 { + type To = U64; + + #[inline(always)] + fn to_alloy(self) -> Self::To { + U64::from_limbs(self.0) } } impl ToAlloy for u64 { - type To = AlloyU256; + type To = U256; #[inline(always)] fn to_alloy(self) -> Self::To { - AlloyU256::from(self) + U256::from(self) } } @@ -181,20 +190,20 @@ impl ToEthers for B256 { } } -impl ToEthers for AlloyU256 { - type To = U256; +impl ToEthers for U256 { + type To = EthersU256; #[inline(always)] fn to_ethers(self) -> Self::To { - U256(self.into_limbs()) + EthersU256(self.into_limbs()) } } -impl ToEthers for AlloyU64 { - type To = U64; +impl ToEthers for U64 { + type To = EthersU64; #[inline(always)] fn to_ethers(self) -> Self::To { - U64(self.into_limbs()) + EthersU64(self.into_limbs()) } } From 82abe3de2059347ddeea7ef78e8aaeeb6ce521d0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 10 Nov 2023 20:23:41 +0100 Subject: [PATCH 0262/1963] fix: windows ci part 69 (#6283) --- crates/test-utils/src/util.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index d52255d374425..2496e89a4e31a 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -98,6 +98,9 @@ pub fn run_install_commands(root: &Path) { let mut cmd = Command::new(args[0]); cmd.args(&args[1..]).current_dir(root); eprintln!("cd {}; {cmd:?}", root.display()); + #[cfg(windows)] + let st = cmd.status(); + #[cfg(not(windows))] let st = cmd.status().unwrap(); eprintln!("\n\n{cmd:?}: {st:?}"); }; From c489e3f77b6a8be56e07078ab4a78f8059354721 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 11 Nov 2023 17:10:30 +0100 Subject: [PATCH 0263/1963] feat: improve error decoding and value formatting (#6286) * feat: better formatting * fix: use empty string to denote None in fuzz errors * fix tests --- Cargo.lock | 1 + crates/common/src/calc.rs | 14 ++-- crates/common/src/fmt.rs | 87 ++++++++++++++++++------ crates/evm/core/src/decode.rs | 51 ++++++++------ crates/evm/evm/src/executors/fuzz/mod.rs | 4 +- crates/evm/fuzz/Cargo.toml | 1 + crates/evm/fuzz/src/lib.rs | 5 +- crates/forge/bin/cmd/create.rs | 4 +- crates/forge/bin/cmd/test/mod.rs | 33 +-------- crates/forge/src/result.rs | 42 +++++++++++- crates/forge/src/runner.rs | 4 +- crates/forge/tests/cli/cache.rs | 9 +-- crates/forge/tests/cli/script.rs | 4 +- crates/forge/tests/it/core.rs | 2 +- 14 files changed, 165 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a8f56e8833f8..52f47213d534a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2928,6 +2928,7 @@ dependencies = [ "foundry-evm-traces", "foundry-utils", "hashbrown 0.14.2", + "itertools 0.11.0", "parking_lot", "proptest", "rand 0.8.5", diff --git a/crates/common/src/calc.rs b/crates/common/src/calc.rs index 0490a0ece1ea1..e404c45201669 100644 --- a/crates/common/src/calc.rs +++ b/crates/common/src/calc.rs @@ -1,6 +1,6 @@ //! Commonly used calculations. -use alloy_primitives::U256; +use alloy_primitives::{Sign, U256}; use std::ops::Div; /// Returns the mean of the slice @@ -44,7 +44,7 @@ pub fn median_sorted(values: &[U256]) -> U256 { /// 10000000 -> 1e7 /// ``` #[inline] -pub fn to_exp_notation(value: U256, precision: usize, trim_end_zeros: bool) -> String { +pub fn to_exp_notation(value: U256, precision: usize, trim_end_zeros: bool, sign: Sign) -> String { let stringified = value.to_string(); let exponent = stringified.len() - 1; let mut mantissa = stringified.chars().take(precision).collect::(); @@ -61,7 +61,7 @@ pub fn to_exp_notation(value: U256, precision: usize, trim_end_zeros: bool) -> S mantissa.insert(1, '.'); } - format!("{mantissa}e{exponent}") + format!("{sign}{mantissa}e{exponent}") } #[cfg(test)] @@ -119,18 +119,18 @@ mod tests { fn test_format_to_exponential_notation() { let value = 1234124124u64; - let formatted = to_exp_notation(U256::from(value), 4, false); + let formatted = to_exp_notation(U256::from(value), 4, false, Sign::Positive); assert_eq!(formatted, "1.234e9"); - let formatted = to_exp_notation(U256::from(value), 3, true); + let formatted = to_exp_notation(U256::from(value), 3, true, Sign::Positive); assert_eq!(formatted, "1.23e9"); let value = 10000000u64; - let formatted = to_exp_notation(U256::from(value), 4, false); + let formatted = to_exp_notation(U256::from(value), 4, false, Sign::Positive); assert_eq!(formatted, "1.000e7"); - let formatted = to_exp_notation(U256::from(value), 3, true); + let formatted = to_exp_notation(U256::from(value), 3, true, Sign::Positive); assert_eq!(formatted, "1e7"); } } diff --git a/crates/common/src/fmt.rs b/crates/common/src/fmt.rs index ca7bc272f4add..321239ccebb86 100644 --- a/crates/common/src/fmt.rs +++ b/crates/common/src/fmt.rs @@ -2,9 +2,9 @@ use crate::{calc::to_exp_notation, TransactionReceiptWithRevertReason}; use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::{hex, U256}; +use alloy_primitives::{hex, Sign, I256, U256}; use eyre::Result; -use std::fmt::{self, Display}; +use std::fmt; use yansi::Paint; pub use foundry_macros::fmt::*; @@ -18,10 +18,10 @@ impl DynValueFormatter { /// Recursively formats a [`DynSolValue`]. fn value(&self, value: &DynSolValue, f: &mut fmt::Formatter<'_>) -> fmt::Result { match value { - DynSolValue::Address(inner) => Display::fmt(inner, f), - DynSolValue::Function(inner) => Display::fmt(inner, f), + DynSolValue::Address(inner) => write!(f, "{inner}"), + DynSolValue::Function(inner) => write!(f, "{inner}"), DynSolValue::Bytes(inner) => f.write_str(&hex::encode_prefixed(inner)), - DynSolValue::FixedBytes(inner, _) => f.write_str(&hex::encode_prefixed(inner)), + DynSolValue::FixedBytes(inner, _) => write!(f, "{inner}"), DynSolValue::Uint(inner, _) => { if self.raw { write!(f, "{inner}") @@ -29,33 +29,44 @@ impl DynValueFormatter { f.write_str(&format_uint_exp(*inner)) } } - DynSolValue::Int(inner, _) => write!(f, "{inner}"), + DynSolValue::Int(inner, _) => { + if self.raw { + write!(f, "{inner}") + } else { + f.write_str(&format_int_exp(*inner)) + } + } DynSolValue::Array(values) | DynSolValue::FixedArray(values) => { f.write_str("[")?; self.list(values, f)?; f.write_str("]") } DynSolValue::Tuple(values) => self.tuple(values, f), - DynSolValue::String(inner) => f.write_str(inner), - DynSolValue::Bool(inner) => Display::fmt(inner, f), + DynSolValue::String(inner) => write!(f, "{inner:?}"), // escape strings + DynSolValue::Bool(inner) => write!(f, "{inner}"), DynSolValue::CustomStruct { name, prop_names, tuple } => { if self.raw { return self.tuple(tuple, f); } f.write_str(name)?; - f.write_str(" { ")?; - for (i, (prop_name, value)) in std::iter::zip(prop_names, tuple).enumerate() { - if i > 0 { - f.write_str(", ")?; + if prop_names.len() == tuple.len() { + f.write_str("({ ")?; + + for (i, (prop_name, value)) in std::iter::zip(prop_names, tuple).enumerate() { + if i > 0 { + f.write_str(", ")?; + } + f.write_str(prop_name)?; + f.write_str(": ")?; + self.value(value, f)?; } - f.write_str(prop_name)?; - f.write_str(": ")?; - self.value(value, f)?; - } - f.write_str(" }") + f.write_str(" })") + } else { + self.tuple(tuple, f) + } } } } @@ -143,7 +154,7 @@ pub fn format_token_raw(value: &DynSolValue) -> String { /// use alloy_primitives::U256; /// use foundry_common::fmt::format_uint_exp as f; /// -/// yansi::Paint::disable(); +/// # yansi::Paint::disable(); /// assert_eq!(f(U256::from(0)), "0"); /// assert_eq!(f(U256::from(1234)), "1234"); /// assert_eq!(f(U256::from(1234567890)), "1234567890 [1.234e9]"); @@ -155,8 +166,44 @@ pub fn format_uint_exp(num: U256) -> String { return num.to_string() } - let exp = to_exp_notation(num, 4, true); - format!("{} {}", num, Paint::default(format!("[{exp}]")).dimmed()) + let exp = to_exp_notation(num, 4, true, Sign::Positive); + format!("{num} {}", Paint::default(format!("[{exp}]")).dimmed()) +} + +/// Formats a U256 number to string, adding an exponential notation _hint_. +/// +/// Same as [`format_uint_exp`]. +/// +/// # Examples +/// +/// ``` +/// use alloy_primitives::I256; +/// use foundry_common::fmt::format_int_exp as f; +/// +/// # yansi::Paint::disable(); +/// assert_eq!(f(I256::try_from(0).unwrap()), "0"); +/// assert_eq!(f(I256::try_from(-1).unwrap()), "-1"); +/// assert_eq!(f(I256::try_from(1234).unwrap()), "1234"); +/// assert_eq!(f(I256::try_from(1234567890).unwrap()), "1234567890 [1.234e9]"); +/// assert_eq!(f(I256::try_from(-1234567890).unwrap()), "-1234567890 [-1.234e9]"); +/// assert_eq!(f(I256::try_from(1000000000000000000_u128).unwrap()), "1000000000000000000 [1e18]"); +/// assert_eq!( +/// f(I256::try_from(10000000000000000000000_u128).unwrap()), +/// "10000000000000000000000 [1e22]" +/// ); +/// assert_eq!( +/// f(I256::try_from(-10000000000000000000000_i128).unwrap()), +/// "-10000000000000000000000 [-1e22]" +/// ); +/// ``` +pub fn format_int_exp(num: I256) -> String { + let (sign, abs) = num.into_sign_and_abs(); + if abs < U256::from(10_000) { + return format!("{sign}{abs}"); + } + + let exp = to_exp_notation(abs, 4, true, sign); + format!("{sign}{abs} {}", Paint::default(format!("[{exp}]")).dimmed()) } impl UIfmt for TransactionReceiptWithRevertReason { diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 2ffd23eb9ab5a..a74a053ead998 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -70,27 +70,41 @@ pub fn decode_revert( maybe_abi: Option<&JsonAbi>, status: Option, ) -> String { + maybe_decode_revert(err, maybe_abi, status).unwrap_or_else(|| { + if err.is_empty() { + "".to_string() + } else { + trimmed_hex(err) + } + }) +} + +pub fn maybe_decode_revert( + err: &[u8], + maybe_abi: Option<&JsonAbi>, + status: Option, +) -> Option { if err.len() < SELECTOR_LEN { if let Some(status) = status { if !status.is_ok() { - return format!("EvmError: {status:?}") + return Some(format!("EvmError: {status:?}")); } } return if err.is_empty() { - "".to_string() + None } else { - format!("custom error bytes {}", hex::encode_prefixed(err)) + Some(format!("custom error bytes {}", hex::encode_prefixed(err))) } } if err == crate::constants::MAGIC_SKIP { // Also used in forge fuzz runner - return "SKIPPED".to_string() + return Some("SKIPPED".to_string()); } // Solidity's `Error(string)` or `Panic(uint256)` if let Ok(e) = alloy_sol_types::GenericContractError::abi_decode(err, false) { - return e.to_string() + return Some(e.to_string()); } let (selector, data) = err.split_at(SELECTOR_LEN); @@ -99,21 +113,18 @@ pub fn decode_revert( match *selector { // `CheatcodeError(string)` Vm::CheatcodeError::SELECTOR => { - if let Ok(e) = Vm::CheatcodeError::abi_decode_raw(data, false) { - return e.message - } + let e = Vm::CheatcodeError::abi_decode_raw(data, false).ok()?; + return Some(e.message); } // `expectRevert(bytes)` Vm::expectRevert_2Call::SELECTOR => { - if let Ok(e) = Vm::expectRevert_2Call::abi_decode_raw(data, false) { - return decode_revert(&e.revertData[..], maybe_abi, status) - } + let e = Vm::expectRevert_2Call::abi_decode_raw(data, false).ok()?; + return maybe_decode_revert(&e.revertData[..], maybe_abi, status); } // `expectRevert(bytes4)` Vm::expectRevert_1Call::SELECTOR => { - if let Ok(e) = Vm::expectRevert_1Call::abi_decode_raw(data, false) { - return decode_revert(&e.revertData[..], maybe_abi, status) - } + let e = Vm::expectRevert_1Call::abi_decode_raw(data, false).ok()?; + return maybe_decode_revert(&e.revertData[..], maybe_abi, status); } _ => {} } @@ -123,31 +134,31 @@ pub fn decode_revert( if let Some(abi_error) = abi.errors().find(|e| selector == e.selector()) { // if we don't decode, don't return an error, try to decode as a string later if let Ok(decoded) = abi_error.abi_decode_input(data, false) { - return format!( + return Some(format!( "{}({})", abi_error.name, decoded.iter().map(foundry_common::fmt::format_token).format(", ") - ) + )); } } } // ABI-encoded `string` if let Ok(s) = String::abi_decode(err, false) { - return s + return Some(s); } // UTF-8-encoded string if let Ok(s) = std::str::from_utf8(err) { - return s.to_string() + return Some(s.to_string()); } // Generic custom error - format!( + Some(format!( "custom error {}:{}", hex::encode(selector), std::str::from_utf8(data).map_or_else(|_| trimmed_hex(data), String::from) - ) + )) } fn trimmed_hex(s: &[u8]) -> String { diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 2cdfae9042d85..42c4de0e32f1c 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -129,7 +129,9 @@ impl<'a> FuzzedExecutor<'a> { // case. let call_res = _counterexample.1.result.clone(); *counterexample.borrow_mut() = _counterexample; - Err(TestCaseError::fail(decode::decode_revert(&call_res, errors, Some(status)))) + // HACK: we have to use an empty string here to denote `None` + let reason = decode::maybe_decode_revert(&call_res, errors, Some(status)); + Err(TestCaseError::fail(reason.unwrap_or_default())) } } }); diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 498ae95681815..657550c7d94bc 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -37,6 +37,7 @@ ethers-core.workspace = true arbitrary = "1.3.1" eyre = "0.6" hashbrown = { version = "0.14", features = ["serde"] } +itertools.workspace = true parking_lot = "0.12" proptest = "1" rand.workspace = true diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 62f622409f8e7..62181c2300c9b 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -13,6 +13,7 @@ use ethers_core::types::Log; use foundry_common::{calc, contracts::ContractsByAddress}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; +use itertools::Itertools; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt}; @@ -92,8 +93,6 @@ impl BaseCounterExample { impl fmt::Display for BaseCounterExample { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let args = foundry_common::fmt::format_tokens(&self.args).collect::>().join(", "); - if let Some(sender) = self.sender { write!(f, "sender={sender} addr=")? } @@ -112,7 +111,7 @@ impl fmt::Display for BaseCounterExample { write!(f, "calldata={}", self.calldata)? } - write!(f, ", args=[{args}]") + write!(f, " args=[{}]", foundry_common::fmt::format_tokens(&self.args).format(", ")) } } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 3591d0c0cc10e..a187148b88911 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -205,9 +205,9 @@ impl CreateArgs { let is_args_empty = args.is_empty(); let deployer = - factory.deploy_tokens(args.clone()).context("Failed to deploy contract").map_err(|e| { + factory.deploy_tokens(args.clone()).context("failed to deploy contract").map_err(|e| { if is_args_empty { - e.wrap_err("No arguments provided for contract constructor. Consider --constructor-args or --constructor-args-path") + e.wrap_err("no arguments provided for contract constructor; consider --constructor-args or --constructor-args-path") } else { e } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index a1ffc2bd5960d..d0cf5bd16bc9b 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -32,7 +32,6 @@ use foundry_config::{ get_available_profiles, Config, }; use foundry_debugger::DebuggerArgs; -use foundry_evm::fuzz::CounterExample; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use tracing::trace; @@ -543,37 +542,7 @@ impl TestOutcome { } fn short_test_result(name: &str, result: &TestResult) { - let status = if result.status == TestStatus::Success { - Paint::green("[PASS]".to_string()) - } else if result.status == TestStatus::Skipped { - Paint::yellow("[SKIP]".to_string()) - } else { - let reason = result - .reason - .as_ref() - .map(|reason| format!("Reason: {reason}")) - .unwrap_or_else(|| "Reason: Assertion failed.".to_string()); - - let counterexample = result - .counterexample - .as_ref() - .map(|example| match example { - CounterExample::Single(eg) => format!(" Counterexample: {eg}]"), - CounterExample::Sequence(sequence) => { - let mut inner_txt = String::new(); - - for checkpoint in sequence { - inner_txt += format!("\t\t{checkpoint}\n").as_str(); - } - format!("]\n\t[Sequence]\n{inner_txt}\n") - } - }) - .unwrap_or_else(|| "]".to_string()); - - Paint::red(format!("[FAIL. {reason}{counterexample}")) - }; - - println!("{status} {name} {}", result.kind.report()); + println!("{result} {name} {}", result.kind.report()); } /** diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index e92106be5fe07..9cd84f7c760a0 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -11,7 +11,12 @@ use foundry_evm::{ traces::{TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, fmt, time::Duration}; +use std::{ + collections::BTreeMap, + fmt::{self, Write}, + time::Duration, +}; +use yansi::Paint; /// Results and duration for a set of tests included in the same test contract #[derive(Debug, Clone, Serialize)] @@ -130,6 +135,39 @@ pub struct TestResult { pub breakpoints: Breakpoints, } +impl fmt::Display for TestResult { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self.status { + TestStatus::Success => Paint::green("[PASS]").fmt(f), + TestStatus::Skipped => Paint::yellow("[SKIP]").fmt(f), + TestStatus::Failure => { + let mut s = String::from("[FAIL. Reason: "); + + let reason = self.reason.as_deref().unwrap_or("assertion failed"); + s.push_str(reason); + + if let Some(counterexample) = &self.counterexample { + match counterexample { + CounterExample::Single(ex) => { + write!(s, "; counterexample: {ex}]").unwrap(); + } + CounterExample::Sequence(sequence) => { + s.push_str("]\n\t[Sequence]\n"); + for ex in sequence { + writeln!(s, "\t\t{ex}").unwrap(); + } + } + } + } else { + s.push(']'); + } + + Paint::red(s).fmt(f) + } + } + } +} + impl TestResult { pub fn fail(reason: String) -> Self { Self { status: TestStatus::Failure, reason: Some(reason), ..Default::default() } @@ -253,7 +291,7 @@ impl TestSetup { logs, traces, labeled_addresses, - format!("Failed to deploy contract: {e}"), + format!("failed to deploy contract: {e}"), ), } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 6458e73fcca9b..3e671f2d7e882 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -196,7 +196,7 @@ impl<'a> ContractRunner<'a> { if setup_fns.len() > 1 { return SuiteResult::new( start.elapsed(), - [("setUp()".to_string(), TestResult::fail("Multiple setUp functions".to_string()))] + [("setUp()".to_string(), TestResult::fail("multiple setUp functions".to_string()))] .into(), warnings, ) @@ -463,7 +463,7 @@ impl<'a> ContractRunner<'a> { Err(e) => { return TestResult { status: TestStatus::Failure, - reason: Some(format!("Failed to set up invariant testing environment: {e}")), + reason: Some(format!("failed to set up invariant testing environment: {e}")), decoded_logs: decode_console_logs(&logs), traces, labeled_addresses, diff --git a/crates/forge/tests/cli/cache.rs b/crates/forge/tests/cli/cache.rs index 7fa76ace1069e..b8f93701430c8 100644 --- a/crates/forge/tests/cli/cache.rs +++ b/crates/forge/tests/cli/cache.rs @@ -16,10 +16,11 @@ forgetest!(can_list_specific_chain, |_prj, cmd| { }); forgetest_init!(can_test_no_cache, |prj, cmd| { - cmd.args(["test", "--no-cache"]); - cmd.assert_success(); + let _ = std::fs::remove_dir_all(prj.cache_path()); + + cmd.args(["test", "--no-cache"]).assert_success(); assert!(!prj.cache_path().exists(), "cache file should not exist"); - cmd.forge_fuse().args(["test"]); - cmd.assert_success(); + + cmd.forge_fuse().args(["test"]).assert_success(); assert!(prj.cache_path().exists(), "cache file should exist"); }); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index e7624e5890344..1619baf73f88b 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -860,7 +860,7 @@ contract Script0 is Script { "true".to_string(), "0x616263646566".to_string(), "(10, 99)".to_string(), - "hello".to_string(), + "\"hello\"".to_string(), ] ); }); @@ -947,7 +947,7 @@ contract Script0 is Script { "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string(), "true".to_string(), "0x616263646566".to_string(), - "hello".to_string(), + "\"hello\"".to_string(), ] ); }); diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 0c589e6eafb31..07b89a6c14a7f 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -29,7 +29,7 @@ async fn test_core() { vec![( "setUp()", false, - Some("Multiple setUp functions".to_string()), + Some("multiple setUp functions".to_string()), None, Some(1), )], From 10edef3853265a107da97c4387dfcbdc4f6d0551 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 11 Nov 2023 17:50:57 +0100 Subject: [PATCH 0264/1963] feat(doc): add struct events error table (#6287) * feat(doc): add struct events error table * error paramaters --- crates/doc/src/writer/as_doc.rs | 28 +++++++---- crates/doc/src/writer/buf_writer.rs | 77 +++++++++++++++++++++++------ crates/doc/src/writer/mod.rs | 2 + crates/doc/src/writer/traits.rs | 70 ++++++++++++++++++++++++++ 4 files changed, 152 insertions(+), 25 deletions(-) create mode 100644 crates/doc/src/writer/traits.rs diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index f4e157befc736..abea15866e9ea 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -233,7 +233,8 @@ impl AsDoc for Document { writer.write_subtitle("Events")?; events.into_iter().try_for_each(|(item, comments, code)| { writer.write_heading(&item.name.safe_unwrap().name)?; - writer.write_section(comments, code) + writer.write_section(comments, code)?; + writer.try_write_events_table(&item.fields, comments) })?; } @@ -241,7 +242,8 @@ impl AsDoc for Document { writer.write_subtitle("Errors")?; errors.into_iter().try_for_each(|(item, comments, code)| { writer.write_heading(&item.name.safe_unwrap().name)?; - writer.write_section(comments, code) + writer.write_section(comments, code)?; + writer.try_write_errors_table(&item.fields, comments) })?; } @@ -249,7 +251,8 @@ impl AsDoc for Document { writer.write_subtitle("Structs")?; structs.into_iter().try_for_each(|(item, comments, code)| { writer.write_heading(&item.name.safe_unwrap().name)?; - writer.write_section(comments, code) + writer.write_section(comments, code)?; + writer.try_write_properties_table(&item.fields, comments) })?; } @@ -289,12 +292,19 @@ impl AsDoc for Document { writer.writeln()?; } - ParseSource::Variable(_) | - ParseSource::Event(_) | - ParseSource::Error(_) | - ParseSource::Struct(_) | - ParseSource::Enum(_) | - ParseSource::Type(_) => { + ParseSource::Struct(ty) => { + writer.write_section(&item.comments, &item.code)?; + writer.try_write_properties_table(&ty.fields, &item.comments)?; + } + ParseSource::Event(ev) => { + writer.write_section(&item.comments, &item.code)?; + writer.try_write_events_table(&ev.fields, &item.comments)?; + } + ParseSource::Error(err) => { + writer.write_section(&item.comments, &item.code)?; + writer.try_write_errors_table(&err.fields, &item.comments)?; + } + ParseSource::Variable(_) | ParseSource::Enum(_) | ParseSource::Type(_) => { writer.write_section(&item.comments, &item.code)?; } } diff --git a/crates/doc/src/writer/buf_writer.rs b/crates/doc/src/writer/buf_writer.rs index a68d5d837fb8b..af9a3b80e5bae 100644 --- a/crates/doc/src/writer/buf_writer.rs +++ b/crates/doc/src/writer/buf_writer.rs @@ -1,7 +1,7 @@ -use crate::{AsDoc, CommentTag, Comments, Deployment, Markdown}; +use crate::{writer::traits::ParamLike, AsDoc, CommentTag, Comments, Deployment, Markdown}; use itertools::Itertools; use once_cell::sync::Lazy; -use solang_parser::pt::Parameter; +use solang_parser::pt::{ErrorParameter, EventParameter, Parameter, VariableDeclaration}; use std::fmt::{self, Display, Write}; /// Solidity language name. @@ -114,14 +114,18 @@ impl BufWriter { self.writeln() } - /// Tries to write the parameters table to the buffer. + /// Tries to write the table to the buffer. /// Doesn't write anything if either params or comments are empty. - pub fn try_write_param_table( + fn try_write_table( &mut self, tag: CommentTag, - params: &[&Parameter], + params: &[T], comments: &Comments, - ) -> fmt::Result { + heading: &str, + ) -> fmt::Result + where + T: ParamLike, + { let comments = comments.include_tag(tag.clone()); // There is nothing to write. @@ -129,12 +133,6 @@ impl BufWriter { return Ok(()) } - let heading = match &tag { - CommentTag::Param => "Parameters", - CommentTag::Return => "Returns", - _ => return Err(fmt::Error), - }; - self.write_bold(heading)?; self.writeln()?; @@ -142,10 +140,10 @@ impl BufWriter { self.write_piped(&PARAM_TABLE_SEPARATOR)?; for (index, param) in params.iter().enumerate() { - let param_name = param.name.as_ref().map(|n| n.name.to_owned()); + let param_name = param.name(); let mut comment = param_name.as_ref().and_then(|name| { - comments.iter().find_map(|comment| comment.match_first_word(name.as_str())) + comments.iter().find_map(|comment| comment.match_first_word(name)) }); // If it's a return tag and couldn't match by first word, @@ -155,8 +153,8 @@ impl BufWriter { } let row = [ - Markdown::Code(¶m_name.unwrap_or_else(|| "".to_owned())).as_doc()?, - Markdown::Code(¶m.ty.to_string()).as_doc()?, + Markdown::Code(param_name.unwrap_or("")).as_doc()?, + Markdown::Code(¶m.type_name()).as_doc()?, comment.unwrap_or_default().replace('\n', " "), ]; self.write_piped(&row.join("|"))?; @@ -167,6 +165,53 @@ impl BufWriter { Ok(()) } + /// Tries to write the properties table to the buffer. + /// Doesn't write anything if either params or comments are empty. + pub fn try_write_properties_table( + &mut self, + params: &[VariableDeclaration], + comments: &Comments, + ) -> fmt::Result { + self.try_write_table(CommentTag::Param, params, comments, "Properties") + } + + /// Tries to write the parameters table to the buffer. + /// Doesn't write anything if either params or comments are empty. + pub fn try_write_events_table( + &mut self, + params: &[EventParameter], + comments: &Comments, + ) -> fmt::Result { + self.try_write_table(CommentTag::Param, params, comments, "Parameters") + } + + /// Tries to write the parameters table to the buffer. + /// Doesn't write anything if either params or comments are empty. + pub fn try_write_errors_table( + &mut self, + params: &[ErrorParameter], + comments: &Comments, + ) -> fmt::Result { + self.try_write_table(CommentTag::Param, params, comments, "Parameters") + } + + /// Tries to write the parameters table to the buffer. + /// Doesn't write anything if either params or comments are empty. + pub fn try_write_param_table( + &mut self, + tag: CommentTag, + params: &[&Parameter], + comments: &Comments, + ) -> fmt::Result { + let heading = match &tag { + CommentTag::Param => "Parameters", + CommentTag::Return => "Returns", + _ => return Err(fmt::Error), + }; + + self.try_write_table(tag, params, comments, heading) + } + /// Writes the deployment table to the buffer. pub fn write_deployments_table(&mut self, deployments: Vec) -> fmt::Result { self.write_bold("Deployments")?; diff --git a/crates/doc/src/writer/mod.rs b/crates/doc/src/writer/mod.rs index 47f497e0cc7d9..0d7c94205d294 100644 --- a/crates/doc/src/writer/mod.rs +++ b/crates/doc/src/writer/mod.rs @@ -7,3 +7,5 @@ mod markdown; pub use as_doc::{AsDoc, AsDocResult}; pub use buf_writer::BufWriter; pub use markdown::Markdown; + +mod traits; diff --git a/crates/doc/src/writer/traits.rs b/crates/doc/src/writer/traits.rs new file mode 100644 index 0000000000000..b59708ed90661 --- /dev/null +++ b/crates/doc/src/writer/traits.rs @@ -0,0 +1,70 @@ +//! Helper traits for writing documentation. + +use solang_parser::pt::Expression; + +/// Helper trait to abstract over a solang type that can be documented as parameter +pub(crate) trait ParamLike { + /// Returns the type of the parameter. + fn ty(&self) -> &Expression; + + /// Returns the type as a string. + fn type_name(&self) -> String { + self.ty().to_string() + } + + /// Returns the identifier of the parameter. + fn name(&self) -> Option<&str>; +} + +impl ParamLike for solang_parser::pt::Parameter { + fn ty(&self) -> &Expression { + &self.ty + } + + fn name(&self) -> Option<&str> { + self.name.as_ref().map(|id| id.name.as_str()) + } +} + +impl ParamLike for solang_parser::pt::VariableDeclaration { + fn ty(&self) -> &Expression { + &self.ty + } + + fn name(&self) -> Option<&str> { + self.name.as_ref().map(|id| id.name.as_str()) + } +} + +impl ParamLike for solang_parser::pt::EventParameter { + fn ty(&self) -> &Expression { + &self.ty + } + + fn name(&self) -> Option<&str> { + self.name.as_ref().map(|id| id.name.as_str()) + } +} + +impl ParamLike for solang_parser::pt::ErrorParameter { + fn ty(&self) -> &Expression { + &self.ty + } + + fn name(&self) -> Option<&str> { + self.name.as_ref().map(|id| id.name.as_str()) + } +} + +impl<'a, T> ParamLike for &'a T +where + T: ParamLike, +{ + fn ty(&self) -> &Expression { + T::ty(*self) + } + + fn name(&self) -> Option<&str> { + T::name(*self) + } +} From 6a1cafd1b20f4365c84ecf45a8b02b9b0de067aa Mon Sep 17 00:00:00 2001 From: evalir Date: Sat, 11 Nov 2023 13:50:38 -0400 Subject: [PATCH 0265/1963] feat: add alias for topic0-event (#6288) --- crates/cast/bin/opts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 40db2fb0ce847..fa649b715dec1 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -558,7 +558,7 @@ pub enum Subcommands { }, /// Get the event signature for a given topic 0 from https://openchain.xyz. - #[clap(name = "4byte-event", visible_aliases = &["4e", "4be"])] + #[clap(name = "4byte-event", visible_aliases = &["4e", "4be", "topic0-event", "t0e"])] FourByteEvent { /// Topic 0 #[clap(value_name = "TOPIC_0")] From 529559c01fabad0e6316d605fd2c4326b8ad6567 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 12 Nov 2023 20:46:31 +0400 Subject: [PATCH 0266/1963] feat(doc): Include extrernal libraries into forge doc scope (#6290) * Include extrernal libraries into forge doc scope * Fix clippy warning * Replace unwrap() with match statement --- crates/doc/src/builder.rs | 62 ++++++++++++++----- crates/doc/src/document.rs | 5 +- .../src/preprocessor/contract_inheritance.rs | 9 ++- crates/doc/src/preprocessor/git_source.rs | 3 + crates/forge/bin/cmd/doc.rs | 31 ++++++---- 5 files changed, 81 insertions(+), 29 deletions(-) diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index c9bfe9755419f..b66644e2cd524 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -26,6 +26,8 @@ pub struct DocBuilder { pub root: PathBuf, /// Path to Solidity source files. pub sources: PathBuf, + /// Paths to external libraries. + pub libraries: Vec, /// Flag whether to build mdbook. pub should_build: bool, /// Documentation configuration. @@ -34,6 +36,8 @@ pub struct DocBuilder { pub preprocessors: Vec>, /// The formatter config. pub fmt: FormatterConfig, + /// Whether to include libraries to the output. + pub include_libraries: bool, } // TODO: consider using `tfio` @@ -44,10 +48,17 @@ impl DocBuilder { const SUMMARY: &'static str = "SUMMARY.md"; /// Create new instance of builder. - pub fn new(root: PathBuf, sources: PathBuf) -> Self { + pub fn new( + root: PathBuf, + sources: PathBuf, + libraries: Vec, + include_libraries: bool, + ) -> Self { Self { root, sources, + libraries, + include_libraries, should_build: false, config: DocConfig::default(), preprocessors: Default::default(), @@ -99,20 +110,39 @@ impl DocBuilder { return Ok(()) } - let documents = sources + let library_sources = self.libraries.iter().flat_map(source_files_iter).collect::>(); + + let combined_sources = sources + .iter() + .map(|path| (path, false)) + .chain(library_sources.iter().map(|path| (path, true))) + .collect::>(); + + let documents = combined_sources .par_iter() .enumerate() - .map(|(i, path)| { + .map(|(i, (path, from_library))| { + let path = *path; + let from_library = *from_library; + // Read and parse source file let source = fs::read_to_string(path)?; - let (mut source_unit, comments) = - solang_parser::parse(&source, i).map_err(|diags| { - eyre::eyre!( - "Failed to parse Solidity code for {}\nDebug info: {:?}", - path.display(), - diags - ) - })?; + + let (mut source_unit, comments) = match solang_parser::parse(&source, i) { + Ok(res) => res, + Err(err) => { + if from_library { + // Ignore failures for library files + return Ok(Vec::new()); + } else { + return Err(eyre::eyre!( + "Failed to parse Solidity code for {}\nDebug info: {:?}", + path.display(), + err + )); + } + } + }; // Visit the parse tree let mut doc = Parser::new(comments, source).with_fmt(self.fmt.clone()); @@ -150,7 +180,7 @@ impl DocBuilder { let relative_path = path.strip_prefix(&self.root)?.join(item.filename()); let target_path = self.config.out.join(Self::SRC).join(relative_path); let ident = item.source.ident(); - Ok(Document::new(path.clone(), target_path) + Ok(Document::new(path.clone(), target_path, from_library) .with_content(DocumentContent::Single(item), ident)) }) .collect::>>()?; @@ -177,7 +207,7 @@ impl DocBuilder { }; files.push( - Document::new(path.clone(), target_path) + Document::new(path.clone(), target_path, from_library) .with_content(DocumentContent::Constants(consts), identity), ) } @@ -189,7 +219,7 @@ impl DocBuilder { let relative_path = path.strip_prefix(&self.root)?.join(filename); let target_path = self.config.out.join(Self::SRC).join(relative_path); files.push( - Document::new(path.clone(), target_path) + Document::new(path.clone(), target_path, from_library) .with_content(DocumentContent::OverloadedFunctions(funcs), ident), ); } @@ -213,7 +243,9 @@ impl DocBuilder { }); // Write mdbook related files - self.write_mdbook(documents.collect_vec())?; + self.write_mdbook( + documents.filter(|d| !d.from_library || self.include_libraries).collect_vec(), + )?; // Build the book if requested if self.should_build { diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index 45e2b7261b93c..5b53a79bfce60 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -17,6 +17,8 @@ pub struct Document { pub identity: String, /// The preprocessors results. context: Mutex>, + /// Whether the document is from external library. + pub from_library: bool, } /// The content of the document. @@ -30,10 +32,11 @@ pub enum DocumentContent { impl Document { /// Create new instance of [Document]. - pub fn new(item_path: PathBuf, target_path: PathBuf) -> Self { + pub fn new(item_path: PathBuf, target_path: PathBuf, from_library: bool) -> Self { Self { item_path, target_path, + from_library, item_content: String::default(), identity: String::default(), content: DocumentContent::Empty, diff --git a/crates/doc/src/preprocessor/contract_inheritance.rs b/crates/doc/src/preprocessor/contract_inheritance.rs index 3a9ad02a22cfa..7b4b28e10e060 100644 --- a/crates/doc/src/preprocessor/contract_inheritance.rs +++ b/crates/doc/src/preprocessor/contract_inheritance.rs @@ -13,8 +13,10 @@ pub const CONTRACT_INHERITANCE_ID: PreprocessorId = PreprocessorId("contract_inh /// /// This preprocessor writes to [Document]'s context. #[derive(Default, Debug)] -#[non_exhaustive] -pub struct ContractInheritance; +pub struct ContractInheritance { + /// Whether to capture inherited contracts from libraries. + pub include_libraries: bool, +} impl Preprocessor for ContractInheritance { fn id(&self) -> PreprocessorId { @@ -51,6 +53,9 @@ impl Preprocessor for ContractInheritance { impl ContractInheritance { fn try_link_base(&self, base: &str, documents: &Vec) -> Option { for candidate in documents { + if candidate.from_library && !self.include_libraries { + continue; + } if let DocumentContent::Single(ref item) = candidate.content { if let ParseSource::Contract(ref contract) = item.source { if base == contract.name.safe_unwrap().name { diff --git a/crates/doc/src/preprocessor/git_source.rs b/crates/doc/src/preprocessor/git_source.rs index dbacfd8c95e7c..eaa53e6268d5e 100644 --- a/crates/doc/src/preprocessor/git_source.rs +++ b/crates/doc/src/preprocessor/git_source.rs @@ -28,6 +28,9 @@ impl Preprocessor for GitSource { let repo = repo.trim_end_matches('/'); let commit = self.commit.clone().unwrap_or("master".to_owned()); for document in documents.iter() { + if document.from_library { + continue; + } let git_url = format!( "{repo}/blob/{commit}/{}", document.item_path.strip_prefix(&self.root)?.display() diff --git a/crates/forge/bin/cmd/doc.rs b/crates/forge/bin/cmd/doc.rs index e30afa21f0430..f671a12d40c87 100644 --- a/crates/forge/bin/cmd/doc.rs +++ b/crates/forge/bin/cmd/doc.rs @@ -45,6 +45,10 @@ pub struct DocArgs { /// for default. #[clap(long)] deployments: Option>, + + /// Whether to create docs for external libraries. + #[clap(long, short)] + include_libraries: bool, } impl DocArgs { @@ -76,17 +80,22 @@ impl DocArgs { let commit = foundry_cli::utils::Git::new(&root).commit_hash(false, "HEAD").ok(); - let mut builder = DocBuilder::new(root.clone(), config.project_paths().sources) - .with_should_build(self.build) - .with_config(doc_config.clone()) - .with_fmt(config.fmt) - .with_preprocessor(ContractInheritance::default()) - .with_preprocessor(Inheritdoc::default()) - .with_preprocessor(GitSource { - root: root.clone(), - commit, - repository: doc_config.repository.clone(), - }); + let mut builder = DocBuilder::new( + root.clone(), + config.project_paths().sources, + config.project_paths().libraries, + self.include_libraries, + ) + .with_should_build(self.build) + .with_config(doc_config.clone()) + .with_fmt(config.fmt) + .with_preprocessor(ContractInheritance { include_libraries: self.include_libraries }) + .with_preprocessor(Inheritdoc::default()) + .with_preprocessor(GitSource { + root: root.clone(), + commit, + repository: doc_config.repository.clone(), + }); // If deployment docgen is enabled, add the [Deployments] preprocessor if let Some(deployments) = self.deployments { From 28df2583333bbabd7455741375f47e592cfa4390 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:45:51 +0100 Subject: [PATCH 0267/1963] chore(deps): weekly `cargo update` (#6291) Updating git repository `https://github.com/alloy-rs/core/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/foundry-rs/block-explorers` Updating bstr v1.7.0 -> v1.8.0 Updating clap v4.4.7 -> v4.4.8 Updating clap_builder v4.4.7 -> v4.4.8 Updating env_logger v0.10.0 -> v0.10.1 Updating http v0.2.9 -> v0.2.10 Updating proptest v1.3.1 -> v1.4.0 Updating rpassword v7.2.0 -> v7.3.1 Updating rtoolbox v0.0.1 -> v0.0.2 Updating rustls-pemfile v1.0.3 -> v1.0.4 Updating schemars v0.8.15 -> v0.8.16 Updating schemars_derive v0.8.15 -> v0.8.16 Updating smallvec v1.11.1 -> v1.11.2 Updating tokio v1.33.0 -> v1.34.0 Updating tokio-macros v2.1.0 -> v2.2.0 Co-authored-by: mattsse --- Cargo.lock | 62 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52f47213d534a..37f6c9165aff3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -813,9 +813,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" +checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" dependencies = [ "memchr", "regex-automata 0.4.3", @@ -1125,9 +1125,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -1135,9 +1135,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -1913,9 +1913,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -3695,9 +3695,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150" dependencies = [ "bytes", "fnv", @@ -5398,9 +5398,9 @@ dependencies = [ [[package]] name = "proptest" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", @@ -5410,7 +5410,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", "rusty-fork", "tempfile", "unarray", @@ -5874,23 +5874,23 @@ dependencies = [ [[package]] name = "rpassword" -version = "7.2.0" +version = "7.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +checksum = "80472be3c897911d0137b2d2b9055faf6eeac5b14e324073d83bc17b191d7e3f" dependencies = [ "libc", "rtoolbox", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "rtoolbox" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +checksum = "c247d24e63230cdb56463ae328478bd5eac8b8faa8c69461a77e8e323afac90e" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -6104,9 +6104,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64 0.21.5", ] @@ -6221,9 +6221,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -6233,9 +6233,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -6639,9 +6639,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smol_str" @@ -7077,9 +7077,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -7096,9 +7096,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", From b205b6add562c778206a9edba1c0676c04a709b1 Mon Sep 17 00:00:00 2001 From: clabby Date: Mon, 13 Nov 2023 13:23:24 -0500 Subject: [PATCH 0268/1963] Fix the `loadAllocs` cheatcode when it is called in `setUp` (#6297) --- crates/evm/core/src/backend/mod.rs | 3 +++ testdata/cheats/loadAllocs.t.sol | 39 +++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 0ba428b9f35dd..d62b6ae2171d3 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1315,6 +1315,9 @@ impl DatabaseExt for Backend { // Set the account's nonce and balance. state_acc.info.nonce = acc.nonce.unwrap_or_default(); state_acc.info.balance = acc.balance.to_alloy(); + + // Touch the account to ensure the loaded information persists if called in `setUp`. + journaled_state.touch(addr); } Ok(()) diff --git a/testdata/cheats/loadAllocs.t.sol b/testdata/cheats/loadAllocs.t.sol index 52c335f6f5baa..1f08e22e422d9 100644 --- a/testdata/cheats/loadAllocs.t.sol +++ b/testdata/cheats/loadAllocs.t.sol @@ -6,15 +6,43 @@ import "./Vm.sol"; contract LoadAllocsTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - string allocsPath; address constant ALLOCD = address(0x420); address constant ALLOCD_B = address(0x421); + uint256 snapshotId; + string allocsPath; + function setUp() public { allocsPath = string.concat(vm.projectRoot(), "/fixtures/Json/test_allocs.json"); + + // Snapshot the state; We'll restore it in each test that loads allocs inline. + snapshotId = vm.snapshot(); + + // Load the allocs file. + vm.loadAllocs(allocsPath); + } + + /// @dev Checks that the `loadAllocs` cheatcode persists account info if called in `setUp` + function testLoadAllocsStaticSetup() public { + // Balance should be `0xabcd` + assertEq(ALLOCD.balance, 0xabcd); + + // Code should be a simple store / return, returning `0x42` + (bool success, bytes memory rd) = ALLOCD.staticcall(""); + assertTrue(success); + uint256 ret = abi.decode(rd, (uint256)); + assertEq(ret, 0x42); + + // Storage should have been set in slot 0x1, equal to `0xbeef` + assertEq(uint256(vm.load(ALLOCD, bytes32(uint256(0x10 << 248)))), 0xbeef); } + /// @dev Checks that the `loadAllocs` cheatcode persists account info if called inline function testLoadAllocsStatic() public { + // Restore the state snapshot prior to the allocs file being loaded. + vm.revertTo(snapshotId); + + // Load the allocs file vm.loadAllocs(allocsPath); // Balance should be `0xabcd` @@ -30,7 +58,11 @@ contract LoadAllocsTest is DSTest { assertEq(uint256(vm.load(ALLOCD, bytes32(uint256(0x10 << 248)))), 0xbeef); } + /// @dev Checks that the `loadAllocs` cheatcode overrides existing account information (if present) function testLoadAllocsOverride() public { + // Restore the state snapshot prior to the allocs file being loaded. + vm.revertTo(snapshotId); + // Populate the alloc'd account's code. vm.etch(ALLOCD, hex"FF"); assertEq(ALLOCD.code, hex"FF"); @@ -52,7 +84,12 @@ contract LoadAllocsTest is DSTest { assertEq(ALLOCD.balance, 0xabcd); } + /// @dev Checks that the `loadAllocs` cheatcode does not override existing account information if there is no data + /// within the allocs/genesis file for the account field (i.e., partial overrides) function testLoadAllocsPartialOverride() public { + // Restore the state snapshot prior to the allocs file being loaded. + vm.revertTo(snapshotId); + // Populate the alloc'd account's code. vm.etch(ALLOCD_B, hex"FF"); assertEq(ALLOCD_B.code, hex"FF"); From b3ea19a1c67a5db27782e726ccce2eef42c9ddf6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 13 Nov 2023 21:50:36 +0100 Subject: [PATCH 0269/1963] test: cache global template build at initialization (#6299) * test: cache global template build at initialization * chore: remove pragmas from test sources * chore: route all pragma soliditys through TestProject * test: only use a single Solc version * test: restore pragma in can_test_pre_bytecode_hash * comment * regex fixes * fix regex 2 --- crates/common/src/term.rs | 6 +- crates/forge/tests/cli/cache.rs | 8 +- crates/forge/tests/cli/cmd.rs | 389 +++++++----------- crates/forge/tests/cli/config.rs | 68 ++- crates/forge/tests/cli/coverage.rs | 27 +- crates/forge/tests/cli/create.rs | 98 ++--- crates/forge/tests/cli/script.rs | 58 +-- crates/forge/tests/cli/svm.rs | 14 +- crates/forge/tests/cli/test_cmd.rs | 171 +++----- crates/forge/tests/cli/verify.rs | 31 +- .../fixtures/can_build_skip_contracts.stdout | 4 +- .../tests/fixtures/can_build_skip_glob.stdout | 4 +- .../tests/fixtures/can_check_snapshot.stdout | 4 +- .../can_create_template_contract.stdout | 4 +- .../fixtures/can_create_using_unlocked.stdout | 4 +- .../can_create_with_constructor_args.stdout | 4 +- ..._create_with_tuple_constructor_args.stdout | 4 +- ...n_execute_script_and_skip_contracts.stdout | 4 +- .../can_execute_script_command.stdout | 4 +- .../can_execute_script_command_fqn.stdout | 4 +- ...an_execute_script_command_with_args.stdout | 4 +- ...xecute_script_command_with_returned.stdout | 4 +- ...can_execute_script_command_with_sig.stdout | 4 +- .../can_run_test_in_custom_test_folder.stdout | 4 +- .../can_use_libs_in_multi_fork.stdout | 6 +- ...actly_once_with_changed_versions.1.stdout} | 4 +- ...actly_once_with_changed_versions.2.stdout} | 4 +- .../suggest_when_no_tests_match.stdout | 4 +- .../forge/tests/fixtures/warn_no_tests.stdout | 4 +- .../tests/fixtures/warn_no_tests_match.stdout | 4 +- crates/test-utils/src/util.rs | 242 ++++++++--- 31 files changed, 541 insertions(+), 653 deletions(-) rename crates/forge/tests/fixtures/{runs_tests_exactly_once_with_changed_versions.0.8.10.stdout => runs_tests_exactly_once_with_changed_versions.1.stdout} (79%) rename crates/forge/tests/fixtures/{runs_tests_exactly_once_with_changed_versions.0.8.13.stdout => runs_tests_exactly_once_with_changed_versions.2.stdout} (79%) diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 22e9730de5d3b..573bfb2f5e618 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -184,16 +184,16 @@ impl Reporter for SpinnerReporter { /// Invoked before a new [`Solc`] bin is installed fn on_solc_installation_start(&self, version: &Version) { - self.send_msg(format!("Installing solc version {version}")); + self.send_msg(format!("Installing Solc version {version}")); } /// Invoked before a new [`Solc`] bin was successfully installed fn on_solc_installation_success(&self, version: &Version) { - self.send_msg(format!("Successfully installed solc {version}")); + self.send_msg(format!("Successfully installed Solc {version}")); } fn on_solc_installation_error(&self, version: &Version, error: &str) { - self.send_msg(Paint::red(format!("Failed to install solc {version}: {error}")).to_string()); + self.send_msg(Paint::red(format!("Failed to install Solc {version}: {error}")).to_string()); } fn on_unresolved_imports(&self, imports: &[(&Path, &Path)], remappings: &[Remapping]) { diff --git a/crates/forge/tests/cli/cache.rs b/crates/forge/tests/cli/cache.rs index b8f93701430c8..b2f6484262bdf 100644 --- a/crates/forge/tests/cli/cache.rs +++ b/crates/forge/tests/cli/cache.rs @@ -16,11 +16,11 @@ forgetest!(can_list_specific_chain, |_prj, cmd| { }); forgetest_init!(can_test_no_cache, |prj, cmd| { - let _ = std::fs::remove_dir_all(prj.cache_path()); + prj.clear_cache(); cmd.args(["test", "--no-cache"]).assert_success(); - assert!(!prj.cache_path().exists(), "cache file should not exist"); + assert!(!prj.cache().exists(), "cache file should not exist"); - cmd.forge_fuse().args(["test"]).assert_success(); - assert!(prj.cache_path().exists(), "cache file should exist"); + cmd.forge_fuse().arg("test").assert_success(); + assert!(prj.cache().exists(), "cache file should exist"); }); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 4b5f89b340f0f..3753c4d75fe6d 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1,11 +1,7 @@ //! Contains various tests for checking forge's commands use crate::constants::*; -use foundry_compilers::{ - artifacts::{BytecodeHash, Metadata}, - remappings::Remapping, - ConfigurableContractArtifact, -}; +use foundry_compilers::{artifacts::Metadata, remappings::Remapping, ConfigurableContractArtifact}; use foundry_config::{ parse_with_profile, BasicConfig, Chain, Config, NamedChain, SolidityErrorCode, }; @@ -527,24 +523,17 @@ forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| { }); forgetest!(can_print_warnings, |prj, cmd| { - prj.inner() - .add_source( - "Foo", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity >0.8.9; + prj.add_source( + "Foo", + r" contract Greeter { function foo(uint256 a) public { uint256 x = 1; } } ", - ) - .unwrap(); - - // explicitly set to run with 0.8.10 - let config = Config { solc: Some("0.8.10".into()), ..Default::default() }; - prj.write_config(config); + ) + .unwrap(); cmd.arg("build"); @@ -575,12 +564,9 @@ Warning (5667): Warning: Unused function parameter. Remove or comment out the va // | ^^^^ #[cfg(not(target_os = "windows"))] forgetest!(can_handle_direct_imports_into_src, |prj, cmd| { - prj.inner() - .add_source( - "Foo", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "Foo", + r#" import {FooLib} from "src/FooLib.sol"; struct Bar { uint8 x; @@ -596,23 +582,20 @@ contract Foo { } } "#, - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_source( - "FooLib", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "FooLib", + r#" import {Foo, Bar} from "src/Foo.sol"; library FooLib { function check(Bar memory b) public {} function check2(Foo f) public {} } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.arg("build"); @@ -625,17 +608,11 @@ Compiler run successful! // tests that the `inspect` command works correctly forgetest!(can_execute_inspect_command, |prj, cmd| { - // explicitly set to include the ipfs bytecode hash - let config = Config { bytecode_hash: BytecodeHash::Ipfs, ..Default::default() }; - prj.write_config(config); let contract_name = "Foo"; let path = prj - .inner() .add_source( contract_name, r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; contract Foo { event log_string(string); function run() external { @@ -646,15 +623,9 @@ contract Foo { ) .unwrap(); - // Remove the ipfs hash from the metadata - let mut dynamic_bytecode = "0x608060405234801561001057600080fd5b5060c08061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063c040622614602d575b600080fd5b60336035565b005b7f0b2e13ff20ac7b474198655583edf70dedd2c1dc980e329c4fbb2fc0748b796b6040516080906020808252600a908201526939b1b934b83a103930b760b11b604082015260600190565b60405180910390a156fea264697066735822122065c066d19101ad1707272b9a884891af8ab0cf5a0e0bba70c4650594492c14be64736f6c634300080a0033\n".to_string(); - let ipfs_start = dynamic_bytecode.len() - (24 + 64); - let ipfs_end = ipfs_start + 65; - dynamic_bytecode.replace_range(ipfs_start..ipfs_end, ""); - - let check_output = |mut output: String| { - output.replace_range(ipfs_start..ipfs_end, ""); - assert_eq!(dynamic_bytecode, output); + let check_output = |output: String| { + let output = output.trim(); + assert!(output.starts_with("0x") && hex::decode(output).is_ok(), "{output}"); }; cmd.arg("inspect").arg(contract_name).arg("bytecode"); @@ -672,12 +643,9 @@ forgetest!( |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "ATest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "ATest.t.sol", + r#" import "./test.sol"; contract ATest is DSTest { function testExample() public { @@ -685,8 +653,8 @@ contract ATest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.arg("snapshot"); @@ -707,35 +675,30 @@ forgetest!(can_compile_without_warnings, |prj, cmd| { ..Default::default() }; prj.write_config(config); - prj.inner() - .add_source( - "A", - r" -pragma solidity 0.8.10; + prj.add_raw_source( + "A", + r" +pragma solidity *; contract A { function testExample() public {} } ", - ) - .unwrap(); + ) + .unwrap(); cmd.args(["build", "--force"]); let out = cmd.stdout_lossy(); // no warnings - assert!(out.trim().contains("Compiler run successful!")); - assert!(!out.trim().contains("Compiler run successful with warnings:")); + assert!(out.contains("Compiler run successful!")); + assert!(!out.contains("Compiler run successful with warnings:")); // don't ignore errors let config = Config { ignored_error_codes: vec![], ..Default::default() }; prj.write_config(config); let out = cmd.stdout_lossy(); - assert!(out.trim().contains("Compiler run successful with warnings:")); - assert!( - out.contains( - r#"Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information."# - ) - ); + assert!(out.contains("Compiler run successful with warnings:"), "{out}"); + assert!(out.contains("Warning") && out.contains("SPDX-License-Identifier"), "{out}"); }); // test that `forge build` compiles when severity set to error, fails when set to warning, and @@ -743,23 +706,21 @@ contract A { forgetest!(can_fail_compile_with_warnings, |prj, cmd| { let config = Config { ignored_error_codes: vec![], deny_warnings: false, ..Default::default() }; prj.write_config(config); - prj.inner() - .add_source( - "A", - r" -pragma solidity 0.8.10; + prj.add_raw_source( + "A", + r" +pragma solidity *; contract A { function testExample() public {} } ", - ) - .unwrap(); + ) + .unwrap(); + // there are no errors cmd.args(["build", "--force"]); let out = cmd.stdout_lossy(); - // there are no errors - assert!(out.trim().contains("Compiler run successful")); - assert!(out.trim().contains("Compiler run successful with warnings:")); + assert!(out.contains("Compiler run successful with warnings:"), "{out}"); // warning fails to compile let config = Config { ignored_error_codes: vec![], deny_warnings: true, ..Default::default() }; @@ -775,8 +736,8 @@ contract A { prj.write_config(config); let out = cmd.stdout_lossy(); - assert!(out.trim().contains("Compiler run successful!")); - assert!(!out.trim().contains("Compiler run successful with warnings:")); + assert!(out.contains("Compiler run successful!")); + assert!(!out.contains("Compiler run successful with warnings:")); }); // test against a local checkout, useful to debug with local ethers-rs patch @@ -814,12 +775,9 @@ forgetest!( forgetest!(can_build_after_failure, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "ATest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "ATest.t.sol", + r#" import "./test.sol"; contract ATest is DSTest { function testExample() public { @@ -827,14 +785,11 @@ contract ATest is DSTest { } } "#, - ) - .unwrap(); - prj.inner() - .add_source( - "BTest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + ) + .unwrap(); + prj.add_source( + "BTest.t.sol", + r#" import "./test.sol"; contract BTest is DSTest { function testExample() public { @@ -842,8 +797,8 @@ contract BTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.arg("build"); cmd.assert_non_empty_stdout(); @@ -851,8 +806,6 @@ contract BTest is DSTest { prj.assert_artifacts_dir_exists(); let syntax_err = r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; import "./test.sol"; contract CTest is DSTest { function testExample() public { @@ -862,7 +815,7 @@ contract CTest is DSTest { "#; // introduce contract with syntax error - prj.inner().add_source("CTest.t.sol", syntax_err).unwrap(); + prj.add_source("CTest.t.sol", syntax_err).unwrap(); // `forge build --force` which should fail cmd.arg("--force"); @@ -870,19 +823,16 @@ contract CTest is DSTest { // but ensure this cleaned cache and artifacts assert!(!prj.paths().artifacts.exists()); - assert!(!prj.cache_path().exists()); + assert!(!prj.cache().exists()); // still errors cmd.forge_fuse().arg("build"); cmd.assert_err(); // resolve the error by replacing the file - prj.inner() - .add_source( - "CTest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "CTest.t.sol", + r#" import "./test.sol"; contract CTest is DSTest { function testExample() public { @@ -890,22 +840,22 @@ contract CTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.assert_non_empty_stdout(); prj.assert_cache_exists(); prj.assert_artifacts_dir_exists(); // ensure cache is unchanged after error - let cache = fs::read_to_string(prj.cache_path()).unwrap(); + let cache = fs::read_to_string(prj.cache()).unwrap(); // introduce the error again but building without force - prj.inner().add_source("CTest.t.sol", syntax_err).unwrap(); + prj.add_source("CTest.t.sol", syntax_err).unwrap(); cmd.assert_err(); // ensure unchanged cache file - let cache_after = fs::read_to_string(prj.cache_path()).unwrap(); + let cache_after = fs::read_to_string(prj.cache()).unwrap(); assert_eq!(cache, cache_after); }); @@ -1054,18 +1004,15 @@ forgetest!( // create test file that uses the top-level dependency; if the sub-dependency is updated, // compilation will fail - prj.inner() - .add_source( - "CounterCopy", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.0; + prj.add_source( + "CounterCopy", + r#" import "forge-5980-test/Counter.sol"; contract CounterCopy is Counter { } "#, - ) - .unwrap(); + ) + .unwrap(); // build and check output cmd.forge_fuse().arg("build"); @@ -1076,12 +1023,10 @@ contract CounterCopy is Counter { forgetest!(gas_report_all_contracts, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "Contracts.sol", - r#" + prj.add_source( + "Contracts.sol", + r#" //SPDX-license-identifier: MIT -pragma solidity ^0.8.0; import "./test.sol"; @@ -1164,8 +1109,8 @@ contract ContractThreeTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); // report for all prj.write_config(Config { @@ -1205,12 +1150,10 @@ contract ContractThreeTest is DSTest { forgetest!(gas_report_some_contracts, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "Contracts.sol", - r#" + prj.add_source( + "Contracts.sol", + r#" //SPDX-license-identifier: MIT -pragma solidity ^0.8.0; import "./test.sol"; @@ -1293,8 +1236,8 @@ contract ContractThreeTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); // report for One prj.write_config(Config { @@ -1331,12 +1274,10 @@ contract ContractThreeTest is DSTest { forgetest!(gas_ignore_some_contracts, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "Contracts.sol", - r#" + prj.add_source( + "Contracts.sol", + r#" //SPDX-license-identifier: MIT -pragma solidity ^0.8.0; import "./test.sol"; @@ -1419,8 +1360,8 @@ contract ContractThreeTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); // ignore ContractOne prj.write_config(Config { @@ -1471,40 +1412,34 @@ forgetest_init!(can_use_absolute_imports, |prj, cmd| { }; prj.write_config(config); - prj.inner() - .add_lib( - "myDepdendency/src/interfaces/IConfig.sol", - r" - pragma solidity ^0.8.10; - + prj.add_lib( + "myDepdendency/src/interfaces/IConfig.sol", + r" + interface IConfig {} ", - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_lib( - "myDepdendency/src/Config.sol", - r#" - pragma solidity ^0.8.10; - import "src/interfaces/IConfig.sol"; + prj.add_lib( + "myDepdendency/src/Config.sol", + r#" + import "src/interfaces/IConfig.sol"; contract Config {} "#, - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_source( - "Greeter", - r#" - pragma solidity ^0.8.10; - import "myDepdendency/src/Config.sol"; + prj.add_source( + "Greeter", + r#" + import "myDepdendency/src/Config.sol"; contract Greeter {} "#, - ) - .unwrap(); + ) + .unwrap(); cmd.arg("build"); let stdout = cmd.stdout_lossy(); @@ -1513,55 +1448,45 @@ forgetest_init!(can_use_absolute_imports, |prj, cmd| { // forgetest_init!(can_use_absolute_imports_from_test_and_script, |prj, cmd| { - prj.inner() - .add_script( - "IMyScript.sol", - r" - pragma solidity ^0.8.10; - - interface IMyScript {} - ", - ) - .unwrap(); - - prj.inner() - .add_script( - "MyScript.sol", - r#" - pragma solidity ^0.8.10; - import "script/IMyScript.sol"; - - contract MyScript is IMyScript {} - "#, - ) - .unwrap(); - - prj.inner() - .add_test( - "IMyTest.sol", - r" - pragma solidity ^0.8.10; - - interface IMyTest {} - ", - ) - .unwrap(); - - prj.inner() - .add_test( - "MyTest.sol", - r#" - pragma solidity ^0.8.10; - import "test/IMyTest.sol"; - - contract MyTest is IMyTest {} - "#, - ) - .unwrap(); + prj.add_script( + "IMyScript.sol", + r" +interface IMyScript {} + ", + ) + .unwrap(); + + prj.add_script( + "MyScript.sol", + r#" +import "script/IMyScript.sol"; + +contract MyScript is IMyScript {} + "#, + ) + .unwrap(); + + prj.add_test( + "IMyTest.sol", + r" +interface IMyTest {} + ", + ) + .unwrap(); + + prj.add_test( + "MyTest.sol", + r#" +import "test/IMyTest.sol"; + +contract MyTest is IMyTest {} + "#, + ) + .unwrap(); cmd.arg("build"); let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiler run successful")); + assert!(stdout.contains("Compiler run successful"), "{stdout}"); }); // checks `forge inspect irOptimized works @@ -1599,54 +1524,50 @@ forgetest_init!(can_install_missing_deps_build, |prj, cmd| { let output = cmd.stdout_lossy(); assert!(output.contains("Missing dependencies found. Installing now"), "{}", output); - assert!(output.contains("Compiler run successful"), "{}", output); + assert!(output.contains("No files changed, compilation skipped"), "{}", output); }); // checks that extra output works forgetest_init!(can_build_skip_contracts, |prj, cmd| { - // explicitly set to run with 0.8.17 for consistent output - let config = Config { solc: Some("0.8.17".into()), ..Default::default() }; - prj.write_config(config); + prj.clear_cache(); // only builds the single template contract `src/*` cmd.args(["build", "--skip", "tests", "--skip", "scripts"]); - cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests/fixtures/can_build_skip_contracts.stdout"), ); + // re-run command let out = cmd.stdout_lossy(); // unchanged - assert!(out.trim().contains("No files changed, compilation skipped"), "{}", out); + assert!(out.contains("No files changed, compilation skipped"), "{}", out); }); forgetest_init!(can_build_skip_glob, |prj, cmd| { - // explicitly set to run with 0.8.17 for consistent output - let config = Config { solc: Some("0.8.17".into()), ..Default::default() }; - prj.write_config(config); - prj.inner() - .add_test( - "Foo", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.17; + prj.clear_cache(); + + prj.add_test( + "Foo", + r" contract TestDemo { function test_run() external {} }", - ) - .unwrap(); + ) + .unwrap(); + // only builds the single template contract `src/*` even if `*.t.sol` or `.s.sol` is absent cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**"]); - cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_build_skip_glob.stdout"), ); }); // checks that build --sizes includes all contracts even if unchanged -forgetest_init!(can_build_sizes_repeatedly, |_prj, cmd| { +forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { + prj.clear_cache(); + cmd.args(["build", "--sizes"]); let out = cmd.stdout_lossy(); @@ -1661,7 +1582,9 @@ forgetest_init!(can_build_sizes_repeatedly, |_prj, cmd| { }); // checks that build --names includes all contracts even if unchanged -forgetest_init!(can_build_names_repeatedly, |_prj, cmd| { +forgetest_init!(can_build_names_repeatedly, |prj, cmd| { + prj.clear_cache(); + cmd.args(["build", "--names"]); let out = cmd.stdout_lossy(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 4c454ff83750e..96140c5255857 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -10,7 +10,7 @@ use foundry_config::{ use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ foundry_compilers::{remappings::Remapping, EvmVersion}, - util::{pretty_err, OutputExt, TestCommand}, + util::{pretty_err, OutputExt, TestCommand, OTHER_SOLC_VERSION}, }; use path_slash::PathBufExt; use pretty_assertions::assert_eq; @@ -319,72 +319,62 @@ forgetest_init!(can_set_config_values, |prj, _cmd| { // tests that solc can be explicitly set forgetest!(can_set_solc_explicitly, |prj, cmd| { - prj.inner() - .add_source( - "Foo", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity >0.8.9; + prj.add_source( + "Foo", + r" +pragma solidity *; contract Greeter {} ", - ) - .unwrap(); + ) + .unwrap(); - // explicitly set to run with 0.8.10 - let config = Config { solc: Some("0.8.10".into()), ..Default::default() }; + let config = Config { solc: Some(OTHER_SOLC_VERSION.into()), ..Default::default() }; prj.write_config(config); cmd.arg("build"); - assert!(cmd.stdout_lossy().ends_with( - " -Compiler run successful! -", - )); + assert!(cmd.stdout_lossy().contains("Compiler run successful!")); }); // tests that `--use ` works forgetest!(can_use_solc, |prj, cmd| { - prj.inner() - .add_source( - "Foo", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.7.0; + prj.add_raw_source( + "Foo", + r" +pragma solidity *; contract Foo {} ", - ) - .unwrap(); - - cmd.args(["build", "--use", "0.7.1"]); + ) + .unwrap(); + cmd.args(["build", "--use", OTHER_SOLC_VERSION]); let stdout = cmd.stdout_lossy(); assert!(stdout.contains("Compiler run successful")); - cmd.forge_fuse().args(["build", "--force", "--use", "solc:0.7.1"]).root_arg(); - + cmd.forge_fuse() + .args(["build", "--force", "--use", &format!("solc:{OTHER_SOLC_VERSION}")]) + .root_arg(); + let stdout = cmd.stdout_lossy(); assert!(stdout.contains("Compiler run successful")); // fails to use solc that does not exist cmd.forge_fuse().args(["build", "--use", "this/solc/does/not/exist"]); assert!(cmd.stderr_lossy().contains("this/solc/does/not/exist does not exist")); - // 0.7.1 was installed in previous step, so we can use the path to this directly - let local_solc = foundry_compilers::Solc::find_svm_installed_version("0.7.1") + // `OTHER_SOLC_VERSION` was installed in previous step, so we can use the path to this directly + let local_solc = foundry_compilers::Solc::find_svm_installed_version(OTHER_SOLC_VERSION) .unwrap() - .expect("solc 0.7.1 is installed"); + .expect("solc is installed"); cmd.forge_fuse().args(["build", "--force", "--use"]).arg(local_solc.solc).root_arg(); + let stdout = cmd.stdout_lossy(); assert!(stdout.contains("Compiler run successful")); }); // test to ensure yul optimizer can be set as intended forgetest!(can_set_yul_optimizer, |prj, cmd| { - prj.inner() - .add_source( - "Foo", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "Foo", + r" contract Foo { function bar() public pure { assembly { @@ -393,8 +383,8 @@ contract Foo { } } ", - ) - .unwrap(); + ) + .unwrap(); cmd.arg("build"); cmd.unchecked_output().stderr_matches_path( diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 3631450bc14ea..df44a1cf6a50e 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -17,13 +17,9 @@ forgetest!(report_file_coverage, |prj, cmd| { forgetest!(test_setup_coverage, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "AContract.sol", - r#" -// SPDX-license-identifier: MIT -pragma solidity ^0.8.0; - + prj.add_source( + "AContract.sol", + r#" contract AContract { int public i; @@ -36,15 +32,12 @@ contract AContract { } } "#, - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_source( - "AContractTest.sol", - r#" -// SPDX-License-Identifier: MIT -pragma solidity 0.8.10; + prj.add_source( + "AContractTest.sol", + r#" import "./test.sol"; import {AContract} from "./AContract.sol"; @@ -61,8 +54,8 @@ contract AContractTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); let lcov_info = prj.root().join("lcov.info"); cmd.arg("coverage").args([ diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index fca4621960362..89ea4e47da79b 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -31,11 +31,9 @@ fn setup_with_simple_remapping(prj: &TestProject) -> String { }; prj.write_config(config); - prj.inner() - .add_source( - "LinkTest", - r#" -// SPDX-License-Identifier: MIT + prj.add_source( + "LinkTest", + r#" import "remapping/MyLib.sol"; contract LinkTest { function foo() public returns (uint256) { @@ -43,22 +41,20 @@ contract LinkTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); - prj.inner() - .add_lib( - "remapping/MyLib", - r" -// SPDX-License-Identifier: MIT + prj.add_lib( + "remapping/MyLib", + r" library MyLib { function foobar(uint256 a) public view returns (uint256) { return a * 100; } } ", - ) - .unwrap(); + ) + .unwrap(); "src/LinkTest.sol:LinkTest".to_string() } @@ -73,12 +69,9 @@ fn setup_oracle(prj: &TestProject) -> String { }; prj.write_config(config); - prj.inner() - .add_source( - "Contract", - r#" -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.13; + prj.add_source( + "Contract", + r#" import {ChainlinkTWAP} from "./libraries/ChainlinkTWAP.sol"; contract Contract { function getPrice() public view returns (int latest) { @@ -86,24 +79,20 @@ contract Contract { } } "#, - ) - .unwrap(); - - prj.inner() - .add_source( - "libraries/ChainlinkTWAP", - r" -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.13; + ) + .unwrap(); + prj.add_source( + "libraries/ChainlinkTWAP", + r" library ChainlinkTWAP { function getLatestPrice(address base) public view returns (int256) { return 0; } } ", - ) - .unwrap(); + ) + .unwrap(); "src/Contract.sol:Contract".to_string() } @@ -144,12 +133,12 @@ forgetest_async!( #[serial_test::serial] can_create_template_contract, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let wallet = handle.dev_wallets().next().unwrap(); let pk = hex::encode(wallet.signer().to_bytes()); - cmd.args(["init", "--force"]); - cmd.assert_non_empty_stdout(); // explicitly byte code hash for consistent checks let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; @@ -158,8 +147,6 @@ forgetest_async!( cmd.forge_fuse().args([ "create", format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), - "--use", - "solc:0.8.15", "--rpc-url", rpc.as_str(), "--private-key", @@ -183,11 +170,11 @@ forgetest_async!( #[serial_test::serial] can_create_using_unlocked, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let dev = handle.dev_accounts().next().unwrap(); - cmd.args(["init", "--force"]); - cmd.assert_non_empty_stdout(); // explicitly byte code hash for consistent checks let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; @@ -196,8 +183,6 @@ forgetest_async!( cmd.forge_fuse().args([ "create", format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), - "--use", - "solc:0.8.15", "--rpc-url", rpc.as_str(), "--from", @@ -222,23 +207,20 @@ forgetest_async!( #[serial_test::serial] can_create_with_constructor_args, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let wallet = handle.dev_wallets().next().unwrap(); let pk = hex::encode(wallet.signer().to_bytes()); - cmd.args(["init", "--force"]); - cmd.assert_non_empty_stdout(); // explicitly byte code hash for consistent checks let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; prj.write_config(config); - prj.inner() - .add_source( - "ConstructorContract", - r#" -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.13; + prj.add_source( + "ConstructorContract", + r#" contract ConstructorContract { string public name; @@ -247,14 +229,12 @@ contract ConstructorContract { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.forge_fuse().args([ "create", "./src/ConstructorContract.sol:ConstructorContract", - "--use", - "solc:0.8.15", "--rpc-url", rpc.as_str(), "--private-key", @@ -268,13 +248,9 @@ contract ConstructorContract { .join("tests/fixtures/can_create_with_constructor_args.stdout"), ); - prj.inner() - .add_source( - "TupleArrayConstructorContract", - r#" -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.13; - + prj.add_source( + "TupleArrayConstructorContract", + r#" struct Point { uint256 x; uint256 y; @@ -284,14 +260,12 @@ contract TupleArrayConstructorContract { constructor(Point[] memory _points) {} } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.forge_fuse().args([ "create", "./src/TupleArrayConstructorContract.sol:TupleArrayConstructorContract", - "--use", - "solc:0.8.15", "--rpc-url", rpc.as_str(), "--private-key", diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 1619baf73f88b..c8c931508eed0 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3,7 +3,6 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::Address; use anvil::{spawn, NodeConfig}; -use foundry_config::Config; use foundry_test_utils::{util::OutputExt, ScriptOutcome, ScriptTester}; use foundry_utils::{rpc, types::ToEthers}; use regex::Regex; @@ -16,13 +15,9 @@ forgetest_init!( can_use_fork_cheat_codes_in_script, |prj, cmd| { let script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.10; - import "forge-std/Script.sol"; contract ContractScript is Script { @@ -46,12 +41,9 @@ contract ContractScript is Script { // Tests that the `run` command works correctly forgetest!(can_execute_script_command2, |prj, cmd| { let script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; contract Demo { event log_string(string); function run() external { @@ -72,12 +64,9 @@ contract Demo { // Tests that the `run` command works correctly when path *and* script name is specified forgetest!(can_execute_script_command_fqn, |prj, cmd| { let script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; contract Demo { event log_string(string); function run() external { @@ -98,12 +87,9 @@ contract Demo { // Tests that the run command can run arbitrary functions forgetest!(can_execute_script_command_with_sig, |prj, cmd| { let script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; contract Demo { event log_string(string); function myFunction() external { @@ -125,12 +111,9 @@ contract Demo { forgetest_async!(can_execute_script_command_with_manual_gas_limit_unlocked, |prj, cmd| { foundry_test_utils::util::initialize(prj.root()); let deploy_script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; import "forge-std/Script.sol"; contract GasWaster { @@ -181,12 +164,9 @@ contract DeployScript is Script { forgetest_async!(can_execute_script_command_with_manual_gas_limit, |prj, cmd| { foundry_test_utils::util::initialize(prj.root()); let deploy_script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; import "forge-std/Script.sol"; contract GasWaster { @@ -236,12 +216,9 @@ contract DeployScript is Script { // Tests that the run command can run functions with arguments forgetest!(can_execute_script_command_with_args, |prj, cmd| { let script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; contract Demo { event log_string(string); event log_uint(uint); @@ -265,12 +242,9 @@ contract Demo { // Tests that the run command can run functions with return values forgetest!(can_execute_script_command_with_returned, |prj, cmd| { let script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; contract Demo { event log_string(string); function run() external returns (uint256 result, uint8) { @@ -291,12 +265,9 @@ forgetest_async!(can_broadcast_script_skipping_simulation, |prj, cmd| { foundry_test_utils::util::initialize(prj.root()); // This example script would fail in on-chain simulation let deploy_script = prj - .inner() .add_source( "DeployScript", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; import "forge-std/Script.sol"; contract HashChecker { @@ -359,8 +330,6 @@ contract DeployScript is Script { .to_string(); let run_code = r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; import "forge-std/Script.sol"; import { HashChecker } from "./DeployScript.sol"; @@ -379,7 +348,7 @@ contract RunScript is Script { }"# .replace("CONTRACT_ADDRESS", contract_address); - let run_script = prj.inner().add_source("RunScript", run_code).unwrap(); + let run_script = prj.add_source("RunScript", &run_code).unwrap(); let run_contract = run_script.display().to_string() + ":RunScript"; cmd.forge_fuse(); @@ -788,13 +757,9 @@ forgetest_async!(can_execute_script_with_arguments, |prj, cmd| { cmd.forge_fuse(); let (_api, handle) = spawn(NodeConfig::test()).await; - let script = prj - .inner() - .add_script( + let script = prj .add_script( "Counter.s.sol", r#" -pragma solidity ^0.8.15; - import "forge-std/Script.sol"; struct Point { @@ -873,12 +838,9 @@ forgetest_async!(can_execute_script_with_arguments_nested_deploy, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let script = prj - .inner() .add_script( "Counter.s.sol", r#" -pragma solidity ^0.8.13; - import "forge-std/Script.sol"; contract A { @@ -954,17 +916,10 @@ contract Script0 is Script { // checks that skipping build forgetest_init!(can_execute_script_and_skip_contracts, |prj, cmd| { - // explicitly set to run with 0.8.17 for consistent output - let config = Config { solc: Some("0.8.17".into()), ..Default::default() }; - prj.write_config(config); - let script = prj - .inner() .add_source( "Foo", r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.17; contract Demo { event log_string(string); function run() external returns (uint256 result, uint8) { @@ -1000,12 +955,9 @@ forgetest_async!(assert_tx_origin_is_not_overritten, |prj, cmd| { cmd.forge_fuse(); let script = prj - .inner() .add_script( "ScriptTxOrigin.s.sol", r#" -pragma solidity ^0.8.13; - import { Script } from "forge-std/Script.sol"; contract ScriptTxOrigin is Script { @@ -1066,12 +1018,9 @@ forgetest_async!(assert_can_create_multiple_contracts_with_correct_nonce, |prj, cmd.forge_fuse(); let script = prj - .inner() .add_script( "ScriptTxOrigin.s.sol", r#" -pragma solidity ^0.8.17; - import {Script, console} from "forge-std/Script.sol"; contract Contract { @@ -1111,12 +1060,9 @@ contract NestedCreateFail is Script { forgetest_async!(assert_can_detect_target_contract_with_interfaces, |prj, cmd| { let script = prj - .inner() .add_script( "ScriptWithInterface.s.sol", r#" -pragma solidity ^0.8.22; - contract Script { function run() external {} } diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 71ec37aeafc87..7b0b38bce59d9 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -3,13 +3,13 @@ use semver::Version; use svm::Platform; -/// The latest solc release +/// The latest Solc release. /// -/// solc to foundry release process: -/// 1. new solc release -/// 2. svm updated with all build info -/// 3. svm bumped in ethers-rs -/// 4. ethers bumped in foundry + update the `LATEST_SOLC` +/// Solc to Foundry release process: +/// 1. new solc release +/// 2. svm updated with all build info +/// 3. svm bumped in ethers-rs +/// 4. ethers bumped in foundry + update the `LATEST_SOLC` const LATEST_SOLC: Version = Version::new(0, 8, 23); macro_rules! ensure_svm_releases { @@ -56,6 +56,6 @@ contract CounterTest is Test {{ }} "# ); - prj.inner().add_test("Counter", src).unwrap(); + prj.add_test("Counter", &src).unwrap(); cmd.arg("test").stdout_lossy().contains("[PASS]"); }); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 4de10924c475d..19cb7355c10b6 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,6 +1,6 @@ //! Contains various tests for checking `forge test` use foundry_config::Config; -use foundry_test_utils::util::{template_lock, OutputExt}; +use foundry_test_utils::util::{template_lock, OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}; use foundry_utils::rpc; use std::{path::PathBuf, process::Command, str::FromStr}; @@ -33,17 +33,13 @@ forgetest!(can_set_filter_values, |prj, cmd| { // tests that warning is displayed when there are no tests in project forgetest!(warn_no_tests, |prj, cmd| { - prj.inner() - .add_source( - "dummy", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.13; - + prj.add_source( + "dummy", + r" contract Dummy {} ", - ) - .unwrap(); + ) + .unwrap(); // set up command cmd.args(["test"]); @@ -55,17 +51,13 @@ contract Dummy {} // tests that warning is displayed with pattern when no tests match forgetest!(warn_no_tests_match, |prj, cmd| { - prj.inner() - .add_source( - "dummy", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.13; - + prj.add_source( + "dummy", + r" contract Dummy {} ", - ) - .unwrap(); + ) + .unwrap(); // set up command cmd.args(["test", "--match-test", "testA.*", "--no-match-test", "testB.*"]); @@ -81,20 +73,16 @@ contract Dummy {} // tests that suggestion is provided with pattern when no tests match forgetest!(suggest_when_no_tests_match, |prj, cmd| { // set up project - prj.inner() - .add_source( - "TestE.t.sol", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; - + prj.add_source( + "TestE.t.sol", + r" contract TestC { function test1() public { } } ", - ) - .unwrap(); + ) + .unwrap(); // set up command cmd.args(["test", "--match-test", "testA.*", "--no-match-test", "testB.*"]); @@ -112,12 +100,9 @@ contract TestC { forgetest!(can_fuzz_array_params, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "ATest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "ATest.t.sol", + r#" import "./test.sol"; contract ATest is DSTest { function testArray(uint64[2] calldata values) external { @@ -125,8 +110,8 @@ contract ATest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.arg("test"); cmd.stdout_lossy().contains("[PASS]"); @@ -136,11 +121,9 @@ contract ATest is DSTest { forgetest!(can_test_pre_bytecode_hash, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "ATest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED + prj.add_source( + "ATest.t.sol", + r#" // pre bytecode hash version, was introduced in 0.6.0 pragma solidity 0.5.17; import "./test.sol"; @@ -150,8 +133,8 @@ contract ATest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.arg("test"); cmd.stdout_lossy().contains("[PASS]"); @@ -161,12 +144,9 @@ contract ATest is DSTest { forgetest!(can_test_with_match_path, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "ATest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "ATest.t.sol", + r#" import "./test.sol"; contract ATest is DSTest { function testArray(uint64[2] calldata values) external { @@ -174,15 +154,12 @@ contract ATest is DSTest { } } "#, - ) - .unwrap(); - - prj.inner() - .add_source( - "FailTest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + ) + .unwrap(); + + prj.add_source( + "FailTest.t.sol", + r#" import "./test.sol"; contract FailTest is DSTest { function testNothing() external { @@ -190,8 +167,8 @@ contract FailTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.args(["test", "--match-path", "*src/ATest.t.sol"]); assert!(cmd.stdout_lossy().contains("[PASS]") && !cmd.stdout_lossy().contains("[FAIL]")); @@ -207,12 +184,9 @@ forgetest!(can_run_test_in_custom_test_folder, |prj, cmd| { let config = cmd.config(); assert_eq!(config.test, PathBuf::from("nested/forge-tests")); - prj.inner() - .add_source( - "nested/forge-tests/MyTest.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.10; + prj.add_source( + "nested/forge-tests/MyTest.t.sol", + r#" import "../../test.sol"; contract MyTest is DSTest { function testTrue() public { @@ -220,8 +194,8 @@ contract MyTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); cmd.arg("test"); cmd.unchecked_output().stdout_matches_path( @@ -247,13 +221,13 @@ forgetest_init!(can_test_repeatedly, |_prj, cmd| { forgetest!(runs_tests_exactly_once_with_changed_versions, |prj, cmd| { prj.insert_ds_test(); - prj.inner() - .add_source( - "Contract.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.10; + prj.add_source( + "Contract.t.sol", + r#" +pragma solidity *; + import "./test.sol"; + contract ContractTest is DSTest { function setUp() public {} @@ -262,26 +236,26 @@ contract ContractTest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); // pin version - let config = Config { solc: Some("0.8.10".into()), ..Default::default() }; + let config = Config { solc: Some(SOLC_VERSION.into()), ..Default::default() }; prj.write_config(config); cmd.arg("test"); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout"), + .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout"), ); // pin version - let config = Config { solc: Some("0.8.13".into()), ..Default::default() }; + let config = Config { solc: Some(OTHER_SOLC_VERSION.into()), ..Default::default() }; prj.write_config(config); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout"), + .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout"), ); }); @@ -316,13 +290,9 @@ forgetest_init!( // tests that libraries are handled correctly in multiforking mode forgetest_init!(can_use_libs_in_multi_fork, |prj, cmd| { prj.wipe_contracts(); - prj.inner() - .add_source( - "Contract.sol", - r" -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.13; - + prj.add_source( + "Contract.sol", + r" library Library { function f(uint256 a, uint256 b) public pure returns (uint256) { return a + b; @@ -337,18 +307,14 @@ contract Contract { } } ", - ) - .unwrap(); + ) + .unwrap(); let endpoint = rpc::next_http_archive_rpc_endpoint(); - prj.inner() - .add_test( - "Contract.t.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.13; - + prj.add_test( + "Contract.t.sol", + &r#" import "forge-std/Test.sol"; import "src/Contract.sol"; @@ -362,9 +328,9 @@ contract ContractTest is Test { } } "# - .replace("", &endpoint), - ) - .unwrap(); + .replace("", &endpoint), + ) + .unwrap(); cmd.arg("test"); cmd.unchecked_output().stdout_matches_path( @@ -374,9 +340,6 @@ contract ContractTest is Test { }); static FAILING_TEST: &str = r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.17; - import "forge-std/Test.sol"; contract FailingTest is Test { @@ -388,7 +351,7 @@ contract FailingTest is Test { forgetest_init!(exit_code_error_on_fail_fast, |prj, cmd| { prj.wipe_contracts(); - prj.inner().add_source("failing_test", FAILING_TEST).unwrap(); + prj.add_source("failing_test", FAILING_TEST).unwrap(); // set up command cmd.args(["test", "--fail-fast"]); @@ -400,7 +363,7 @@ forgetest_init!(exit_code_error_on_fail_fast, |prj, cmd| { forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { prj.wipe_contracts(); - prj.inner().add_source("failing_test", FAILING_TEST).unwrap(); + prj.add_source("failing_test", FAILING_TEST).unwrap(); // set up command cmd.args(["test", "--fail-fast", "--json"]); diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index 33b58f7d823ba..8c916db1deb31 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -12,37 +12,30 @@ use foundry_utils::Retry; /// `import {Unique} from "./unique.sol";` fn add_unique(prj: &TestProject) { let timestamp = utils::millis_since_epoch(); - prj.inner() - .add_source( - "unique", - format!( - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.4.0; - + prj.add_source( + "unique", + &format!( + r#" contract Unique {{ uint public _timestamp = {timestamp}; }} "# - ), - ) - .unwrap(); + ), + ) + .unwrap(); } fn add_verify_target(prj: &TestProject) { - prj.inner() - .add_source( - "Verify.sol", - r#" -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.10; + prj.add_source( + "Verify.sol", + r#" import {Unique} from "./unique.sol"; contract Verify is Unique { function doStuff() external {} } "#, - ) - .unwrap(); + ) + .unwrap(); } fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Result<()> { diff --git a/crates/forge/tests/fixtures/can_build_skip_contracts.stdout b/crates/forge/tests/fixtures/can_build_skip_contracts.stdout index 74ddb6b4e49f3..43949fcce59e1 100644 --- a/crates/forge/tests/fixtures/can_build_skip_contracts.stdout +++ b/crates/forge/tests/fixtures/can_build_skip_contracts.stdout @@ -1,3 +1,3 @@ -Compiling 1 files with 0.8.17 -Solc 0.8.17 finished in 34.45ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 34.45ms Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_build_skip_glob.stdout b/crates/forge/tests/fixtures/can_build_skip_glob.stdout index 522beb3e2b6c0..3213db81a21d4 100644 --- a/crates/forge/tests/fixtures/can_build_skip_glob.stdout +++ b/crates/forge/tests/fixtures/can_build_skip_glob.stdout @@ -1,3 +1,3 @@ -Compiling 1 files with 0.8.17 -Solc 0.8.17 finished in 33.25ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 33.25ms Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_check_snapshot.stdout b/crates/forge/tests/fixtures/can_check_snapshot.stdout index 6a5df56b3fca3..dffc5df496344 100644 --- a/crates/forge/tests/fixtures/can_check_snapshot.stdout +++ b/crates/forge/tests/fixtures/can_check_snapshot.stdout @@ -1,5 +1,5 @@ -Compiling 2 files with 0.8.10 -Solc 0.8.10 finished in 424.55ms +Compiling 2 files with 0.8.23 +Solc 0.8.23 finished in 424.55ms Compiler run successful! Running 1 test for src/ATest.t.sol:ATest diff --git a/crates/forge/tests/fixtures/can_create_template_contract.stdout b/crates/forge/tests/fixtures/can_create_template_contract.stdout index a67e4dd96aadf..fd625cee305fe 100644 --- a/crates/forge/tests/fixtures/can_create_template_contract.stdout +++ b/crates/forge/tests/fixtures/can_create_template_contract.stdout @@ -1,5 +1,5 @@ -Compiling 22 files with 0.8.15 -Solc 0.8.15 finished in 2.27s +Compiling 22 files with 0.8.23 +Solc 0.8.23 finished in 2.27s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 diff --git a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout index ab309752469be..2e35831523fbf 100644 --- a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout +++ b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout @@ -1,5 +1,5 @@ -Compiling 22 files with 0.8.15 -Solc 0.8.15 finished in 1.95s +Compiling 22 files with 0.8.23 +Solc 0.8.23 finished in 1.95s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 diff --git a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout index ef198e784668c..525e68ac13f8d 100644 --- a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout +++ b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout @@ -1,5 +1,5 @@ -Compiling 23 files with 0.8.15 -Solc 0.8.15 finished in 2.82s +Compiling 23 files with 0.8.23 +Solc 0.8.23 finished in 2.82s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 diff --git a/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout index c70251f9b269e..a0a574c959dbd 100644 --- a/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout +++ b/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.15 -Solc 0.8.15 finished in 26.44ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 26.44ms Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 diff --git a/crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout b/crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout index 46f580d03a5b4..fdc8e739fbd6e 100644 --- a/crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout +++ b/crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.17 -Solc 0.8.17 +Compiling 1 files with 0.8.23 +Solc 0.8.23 Compiler run successful! Script ran successfully. Gas used: 22900 diff --git a/crates/forge/tests/fixtures/can_execute_script_command.stdout b/crates/forge/tests/fixtures/can_execute_script_command.stdout index 459bf7369bf9a..a9717c19df4cc 100644 --- a/crates/forge/tests/fixtures/can_execute_script_command.stdout +++ b/crates/forge/tests/fixtures/can_execute_script_command.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.10 -Solc 0.8.10 finished in 23.34ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 23.34ms Compiler run successful! Script ran successfully. Gas used: 22815 diff --git a/crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout b/crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout index 6b2a06b307488..1156e916e40d4 100644 --- a/crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout +++ b/crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.10 -Solc 0.8.10 finished in 23.70ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 23.70ms Compiler run successful! Script ran successfully. Gas used: 22815 diff --git a/crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout b/crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout index 882fe3a47c515..feb193073eb93 100644 --- a/crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout +++ b/crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.10 -Solc 0.8.10 finished in 35.28ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 35.28ms Compiler run successful! Script ran successfully. Gas used: 25301 diff --git a/crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout b/crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout index 0cc0e7f97b1c2..62aa01b138bae 100644 --- a/crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout +++ b/crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.10 -Solc 0.8.10 finished in 1.27s +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 1.27s Compiler run successful! Script ran successfully. Gas used: 22900 diff --git a/crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout b/crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout index 54f954f36daaf..13a94c698e96f 100644 --- a/crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout +++ b/crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.10 -Solc 0.8.10 finished in 24.49ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 24.49ms Compiler run successful! Script ran successfully. Gas used: 22815 diff --git a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout index 28a027349260e..5cf274ebc7de2 100644 --- a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout +++ b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout @@ -1,5 +1,5 @@ -Compiling 2 files with 0.8.10 -Solc 0.8.10 finished in 185.25ms +Compiling 2 files with 0.8.23 +Solc 0.8.23 finished in 185.25ms Compiler run successful! Running 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout index 499648933b44c..4c954e6c37c9c 100644 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout @@ -1,9 +1,9 @@ -Compiling 20 files with 0.8.13 -Solc 0.8.13 finished in 1.95s +Compiling 2 files with 0.8.23 +Solc 0.8.23 finished in 1.95s Compiler run successful! Running 1 test for test/Contract.t.sol:ContractTest -[PASS] test() (gas: 70351) +[PASS] test() (gas: 70360) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout similarity index 79% rename from crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout rename to crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout index 3a027e1825bba..aee6fb691ce3e 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.10.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout @@ -1,5 +1,5 @@ -Compiling 2 files with 0.8.10 -Solc 0.8.10 finished in 185.25ms +Compiling 2 files with 0.8.23 +Solc 0.8.23 finished in 185.25ms Compiler run successful! Running 1 test for src/Contract.t.sol:ContractTest diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout similarity index 79% rename from crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout rename to crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout index 006c3cfc478ca..691af81679df1 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.0.8.13.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout @@ -1,5 +1,5 @@ -Compiling 2 files with 0.8.13 -Solc 0.8.13 finished in 185.25ms +Compiling 2 files with 0.8.22 +Solc 0.8.22 finished in 185.25ms Compiler run successful! Running 1 test for src/Contract.t.sol:ContractTest diff --git a/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout b/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout index 3c58603b91bc8..1c27d8005cdcd 100644 --- a/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout +++ b/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.10 -Solc 0.8.10 finished in 185.25ms +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 185.25ms Compiler run successful! No tests match the provided pattern: diff --git a/crates/forge/tests/fixtures/warn_no_tests.stdout b/crates/forge/tests/fixtures/warn_no_tests.stdout index 3af59c7af14e7..9b2b8bff47481 100644 --- a/crates/forge/tests/fixtures/warn_no_tests.stdout +++ b/crates/forge/tests/fixtures/warn_no_tests.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.13 -Solc 0.8.13 +Compiling 1 files with 0.8.23 +Solc 0.8.23 Compiler run successful! No tests found in project! Forge looks for functions that starts with `test`. diff --git a/crates/forge/tests/fixtures/warn_no_tests_match.stdout b/crates/forge/tests/fixtures/warn_no_tests_match.stdout index 6eede42748583..56f068238d266 100644 --- a/crates/forge/tests/fixtures/warn_no_tests_match.stdout +++ b/crates/forge/tests/fixtures/warn_no_tests_match.stdout @@ -1,5 +1,5 @@ -Compiling 1 files with 0.8.13 -Solc 0.8.13 +Compiling 1 files with 0.8.23 +Solc 0.8.23 Compiler run successful! No tests match the provided pattern: diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 2496e89a4e31a..1d0493497667e 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -3,6 +3,7 @@ use eyre::{Result, WrapErr}; use fd_lock::RwLock; use foundry_compilers::{ cache::SolFilesCache, + error::Result as SolcResult, project_util::{copy_dir, TempProject}, ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, }; @@ -27,21 +28,30 @@ use std::{ static CURRENT_DIR_LOCK: Lazy> = Lazy::new(|| Mutex::new(())); -// This stores `true` if the current terminal is a tty +/// Stores whether `stdout` is a tty / terminal. pub static IS_TTY: Lazy = Lazy::new(|| std::io::stdout().is_terminal()); -/// Global default template path. -pub static TEMPLATE_PATH: Lazy = +/// Global default template path. Contains the global template project from which all other +/// temp projects are initialized. See [`initialize()`] for more info. +static TEMPLATE_PATH: Lazy = Lazy::new(|| env::temp_dir().join("foundry-forge-test-template")); -/// Global default template lock. -pub static TEMPLATE_LOCK: Lazy = +/// Global default template lock. If its contents are not exactly `"1"`, the global template will +/// be re-initialized. See [`initialize()`] for more info. +static TEMPLATE_LOCK: Lazy = Lazy::new(|| env::temp_dir().join("foundry-forge-test-template.lock")); -// identifier for tests +/// Global test identifier. static NEXT_ID: AtomicUsize = AtomicUsize::new(0); -/// Acquires a lock on the global template dir. +/// The default Solc version used when compiling tests. +pub const SOLC_VERSION: &str = "0.8.23"; + +/// Another Solc version used when compiling tests. Necessary to avoid downloading multiple +/// versions. +pub const OTHER_SOLC_VERSION: &str = "0.8.22"; + +/// Creates a file lock to the global template dir. pub fn template_lock() -> RwLock { let lock_path = &*TEMPLATE_LOCK; let lock_file = pretty_err( @@ -51,30 +61,63 @@ pub fn template_lock() -> RwLock { RwLock::new(lock_file) } -/// Copies an initialized project to the given path +/// Initializes a project with `forge init` at the given path. +/// +/// This should be called after an empty project is created like in +/// [some of this crate's macros](crate::forgetest_init). +/// +/// ## Note +/// +/// This doesn't always run `forge init`, instead opting to copy an already-initialized template +/// project from a global template path. This is done to speed up tests. +/// +/// This used to use a `static` [`Lazy`], but this approach does not with `cargo-nextest` because it +/// runs each test in a separate process. Instead, we use a global lock file to ensure that only one +/// test can initialize the template at a time. pub fn initialize(target: &Path) { - eprintln!("initialize {}", target.display()); + eprintln!("initializing {}", target.display()); - let tpath = &*TEMPLATE_PATH; + let tpath = TEMPLATE_PATH.as_path(); pretty_err(tpath, fs::create_dir_all(tpath)); + // Initialize the global template if necessary. let mut lock = template_lock(); - let read = lock.read().unwrap(); + let mut _read = Some(lock.read().unwrap()); if fs::read_to_string(&*TEMPLATE_LOCK).unwrap() != "1" { - eprintln!("initializing template dir"); - - drop(read); + // We are the first to acquire the lock: + // - initialize a new empty temp project; + // - run `forge init`; + // - run `forge build`; + // - copy it over to the global template; + // Ideally we would be able to initialize a temp project directly in the global template, + // but `TempProject` does not currently allow this: https://github.com/foundry-rs/compilers/issues/22 + + // Release the read lock and acquire a write lock, initializing the lock file. + _read = None; let mut write = lock.write().unwrap(); write.write_all(b"1").unwrap(); + // Initialize and build. let (prj, mut cmd) = setup_forge("template", foundry_compilers::PathStyle::Dapptools); + eprintln!("- initializing template dir in {}", prj.root().display()); + cmd.args(["init", "--force"]).assert_success(); - pretty_err(tpath, fs::remove_dir_all(tpath)); + cmd.forge_fuse().args(["build", "--use", SOLC_VERSION]).assert_success(); + + // Remove the existing template, if any. + let _ = fs::remove_dir_all(tpath); + + // Copy the template to the global template path. pretty_err(tpath, copy_dir(prj.root(), tpath)); - } else { - pretty_err(target, fs::create_dir_all(target)); - pretty_err(target, copy_dir(tpath, target)); + + // Release the write lock and acquire a new read lock. + drop(write); + _read = Some(lock.read().unwrap()); } + + eprintln!("- copying template dir from {}", tpath.display()); + pretty_err(target, fs::create_dir_all(target)); + pretty_err(target, copy_dir(tpath, target)); } /// Clones a remote repository into the specified directory. Panics if the command fails. @@ -241,7 +284,7 @@ pub fn setup_cast_project(test: TestProject) -> (TestProject, TestCommand) { #[derive(Clone, Debug)] pub struct TestProject { /// The directory in which this test executable is running. - root: PathBuf, + exe_root: PathBuf, /// The project in which the test should run. inner: Arc>, } @@ -258,9 +301,9 @@ impl TestProject { pub fn with_project(project: TempProject) -> Self { init_tracing(); - let root = - env::current_exe().unwrap().parent().expect("executable's directory").to_path_buf(); - Self { root, inner: Arc::new(project) } + let this = env::current_exe().unwrap(); + let exe_root = this.parent().expect("executable's directory").to_path_buf(); + Self { exe_root, inner: Arc::new(project) } } /// Returns the root path of the project's workspace. @@ -268,46 +311,98 @@ impl TestProject { self.inner.root() } - pub fn inner(&self) -> &TempProject { - &self.inner - } - + /// Returns the paths config. pub fn paths(&self) -> &ProjectPathsConfig { - self.inner().paths() + self.inner.paths() } - /// Returns the path to the project's `foundry.toml` file - pub fn config_path(&self) -> PathBuf { + /// Returns the path to the project's `foundry.toml` file. + pub fn config(&self) -> PathBuf { self.root().join(Config::FILE_NAME) } - /// Returns the path to the project's cache file - pub fn cache_path(&self) -> &PathBuf { + /// Returns the path to the project's cache file. + pub fn cache(&self) -> &PathBuf { &self.paths().cache } - /// Writes the given config as toml to `foundry.toml` + /// Returns the path to the project's artifacts directory. + pub fn artifacts(&self) -> &PathBuf { + &self.paths().artifacts + } + + /// Removes this project's cache file. + pub fn clear_cache(&self) { + let _ = fs::remove_file(self.cache()); + } + + /// Removes this project's artifacts directory. + pub fn clear_artifacts(&self) { + let _ = fs::remove_dir_all(self.artifacts()); + } + + /// Writes the given config as toml to `foundry.toml`. pub fn write_config(&self, config: Config) { - let file = self.config_path(); + let file = self.config(); pretty_err(&file, fs::write(&file, config.to_string_pretty().unwrap())); } - /// Asserts that the `/foundry.toml` file exits + /// Adds a source file to the project. + pub fn add_source(&self, name: &str, contents: &str) -> SolcResult { + self.inner.add_source(name, Self::add_source_prelude(contents)) + } + + /// Adds a source file to the project. Prefer using `add_source` instead. + pub fn add_raw_source(&self, name: &str, contents: &str) -> SolcResult { + self.inner.add_source(name, contents) + } + + /// Adds a script file to the project. + pub fn add_script(&self, name: &str, contents: &str) -> SolcResult { + self.inner.add_script(name, Self::add_source_prelude(contents)) + } + + /// Adds a test file to the project. + pub fn add_test(&self, name: &str, contents: &str) -> SolcResult { + self.inner.add_test(name, Self::add_source_prelude(contents)) + } + + /// Adds a library file to the project. + pub fn add_lib(&self, name: &str, contents: &str) -> SolcResult { + self.inner.add_lib(name, Self::add_source_prelude(contents)) + } + + fn add_source_prelude(s: &str) -> String { + let mut s = s.to_string(); + if !s.contains("pragma solidity") { + s = format!("pragma solidity ={SOLC_VERSION};\n{s}"); + } + if !s.contains("// SPDX") { + s = format!("// SPDX-License-Identifier: MIT OR Apache-2.0\n{s}"); + } + s + } + + /// Asserts that the `/foundry.toml` file exists. + #[track_caller] pub fn assert_config_exists(&self) { - assert!(self.config_path().exists()); + assert!(self.config().exists()); } - /// Asserts that the `/cache/sol-files-cache.json` file exits + /// Asserts that the `/cache/sol-files-cache.json` file exists. + #[track_caller] pub fn assert_cache_exists(&self) { - assert!(self.cache_path().exists()); + assert!(self.cache().exists()); } - /// Asserts that the `/out` file exits + /// Asserts that the `/out` file exists. + #[track_caller] pub fn assert_artifacts_dir_exists(&self) { assert!(self.paths().artifacts.exists()); } /// Creates all project dirs and ensure they were created + #[track_caller] pub fn assert_create_dirs_exists(&self) { self.paths().create_all().unwrap_or_else(|_| panic!("Failed to create project paths")); SolFilesCache::default().write(&self.paths().cache).expect("Failed to create cache"); @@ -315,12 +410,14 @@ impl TestProject { } /// Ensures that the given layout exists + #[track_caller] pub fn assert_style_paths_exist(&self, style: PathStyle) { let paths = style.paths(&self.paths().root).unwrap(); - config_paths_exist(&paths, self.inner().project().cached); + config_paths_exist(&paths, self.inner.project().cached); } /// Copies the project's root directory to the given target + #[track_caller] pub fn copy_to(&self, target: impl AsRef) { let target = target.as_ref(); pretty_err(target, fs::create_dir_all(target)); @@ -347,24 +444,23 @@ impl TestProject { /// Adds DSTest as a source under "test.sol" pub fn insert_ds_test(&self) -> PathBuf { let s = include_str!("../../../testdata/lib/ds-test/src/test.sol"); - self.inner().add_source("test.sol", s).unwrap() + self.add_source("test.sol", s).unwrap() } /// Adds `console.sol` as a source under "console.sol" pub fn insert_console(&self) -> PathBuf { let s = include_str!("../../../testdata/logs/console.sol"); - self.inner().add_source("console.sol", s).unwrap() + self.add_source("console.sol", s).unwrap() } - /// Asserts all project paths exist - /// - /// - sources - /// - artifacts - /// - libs - /// - cache + /// Asserts all project paths exist. These are: + /// - sources + /// - artifacts + /// - libs + /// - cache pub fn assert_all_paths_exist(&self) { let paths = self.paths(); - config_paths_exist(paths, self.inner().project().cached); + config_paths_exist(paths, self.inner.project().cached); } /// Asserts that the artifacts dir and cache don't exist @@ -404,7 +500,7 @@ impl TestProject { /// Returns the path to the forge executable. pub fn forge_bin(&self) -> Command { - let forge = self.root.join(format!("../forge{}", env::consts::EXE_SUFFIX)); + let forge = self.exe_root.join(format!("../forge{}", env::consts::EXE_SUFFIX)); let mut cmd = Command::new(forge); cmd.current_dir(self.inner.root()); // disable color output for comparisons @@ -414,7 +510,7 @@ impl TestProject { /// Returns the path to the cast executable. pub fn cast_bin(&self) -> Command { - let cast = self.root.join(format!("../cast{}", env::consts::EXE_SUFFIX)); + let cast = self.exe_root.join(format!("../cast{}", env::consts::EXE_SUFFIX)); let mut cmd = Command::new(cast); // disable color output for comparisons cmd.env("NO_COLOR", "1"); @@ -788,41 +884,51 @@ stderr: /// terminal is tty, the path argument can be wrapped in [tty_fixture_path()] pub trait OutputExt { /// Ensure the command wrote the expected data to `stdout`. - fn stdout_matches_path(&self, expected_path: impl AsRef) -> &Self; + fn stdout_matches_path(&self, expected_path: impl AsRef); /// Ensure the command wrote the expected data to `stderr`. - fn stderr_matches_path(&self, expected_path: impl AsRef) -> &Self; + fn stderr_matches_path(&self, expected_path: impl AsRef); } /// Patterns to remove from fixtures before comparing output /// /// This should strip everything that can vary from run to run, like elapsed time, file paths static IGNORE_IN_FIXTURES: Lazy = Lazy::new(|| { - Regex::new(r"(\r|finished in (.*)?s|-->(.*).sol|Location(.|\n)*\.rs(.|\n)*Backtrace|Installing solc version(.*?)\n|Successfully installed solc(.*?)\n|runs: \d+, μ: \d+, ~: \d+)").unwrap() + let re = &[ + // solc version + r" ?Solc(?: version)? \d+.\d+.\d+", + r" with \d+.\d+.\d+", + // solc runs + r"runs: \d+, μ: \d+, ~: \d+", + // elapsed time + "finished in .*?s", + // file paths + r"-->.*\.sol", + r"Location(.|\n)*\.rs(.|\n)*Backtrace", + // other + r"Transaction hash: 0x[0-9A-Fa-f]{64}", + ]; + Regex::new(&format!("({})", re.join("|"))).unwrap() }); +fn normalize_output(s: &str) -> String { + let s = s.replace("\r\n", "\n").replace('\\', "/"); + IGNORE_IN_FIXTURES.replace_all(&s, "").into_owned() +} + impl OutputExt for Output { #[track_caller] - fn stdout_matches_path(&self, expected_path: impl AsRef) -> &Self { + fn stdout_matches_path(&self, expected_path: impl AsRef) { let expected = fs::read_to_string(expected_path).unwrap(); - let expected = IGNORE_IN_FIXTURES.replace_all(&expected, "").replace('\\', "/"); - let stdout = lossy_string(&self.stdout); - let out = IGNORE_IN_FIXTURES.replace_all(&stdout, "").replace('\\', "/"); - - pretty_assertions::assert_eq!(expected, out); - - self + let out = lossy_string(&self.stdout); + pretty_assertions::assert_eq!(normalize_output(&out), normalize_output(&expected)); } #[track_caller] - fn stderr_matches_path(&self, expected_path: impl AsRef) -> &Self { + fn stderr_matches_path(&self, expected_path: impl AsRef) { let expected = fs::read_to_string(expected_path).unwrap(); - let expected = IGNORE_IN_FIXTURES.replace_all(&expected, "").replace('\\', "/"); - let stderr = lossy_string(&self.stderr); - let out = IGNORE_IN_FIXTURES.replace_all(&stderr, "").replace('\\', "/"); - - pretty_assertions::assert_eq!(expected, out); - self + let err = lossy_string(&self.stderr); + pretty_assertions::assert_eq!(normalize_output(&err), normalize_output(&expected)); } } From ef3023fbb8eaa31a2bbe6fe193857fcf86c02f53 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 13 Nov 2023 22:07:12 +0100 Subject: [PATCH 0270/1963] chore: improve logs (#6298) * chore: macro_use tracing * chore: use Display for EvmError/DatabaseError * update tests * fix * s/target :/target: * format tracing macros --- crates/anvil/server/src/handler.rs | 1 - crates/anvil/server/src/ipc.rs | 9 +++-- crates/anvil/server/src/lib.rs | 6 ++-- crates/anvil/server/src/pubsub.rs | 1 - crates/anvil/server/src/ws.rs | 1 - crates/anvil/src/cmd.rs | 1 - crates/anvil/src/eth/api.rs | 1 - crates/anvil/src/eth/backend/cheats.rs | 1 - crates/anvil/src/eth/backend/executor.rs | 1 - crates/anvil/src/eth/backend/fork.rs | 1 - crates/anvil/src/eth/backend/mem/cache.rs | 9 +++-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 1 - crates/anvil/src/eth/backend/mem/mod.rs | 1 - crates/anvil/src/eth/backend/time.rs | 1 - crates/anvil/src/eth/error.rs | 7 ++-- crates/anvil/src/eth/fees.rs | 1 - crates/anvil/src/eth/miner.rs | 1 - crates/anvil/src/eth/pool/mod.rs | 1 - crates/anvil/src/eth/pool/transactions.rs | 1 - crates/anvil/src/filter.rs | 1 - crates/anvil/src/lib.rs | 3 ++ crates/anvil/src/server/handler.rs | 1 - crates/anvil/src/server/mod.rs | 1 - crates/anvil/src/service.rs | 1 - crates/binder/src/lib.rs | 5 ++- crates/binder/src/utils.rs | 1 - crates/cast/bin/cmd/run.rs | 3 +- crates/cast/bin/main.rs | 3 ++ crates/cheatcodes/src/inspector.rs | 2 +- crates/cheatcodes/src/lib.rs | 3 +- crates/cli/src/utils/mod.rs | 6 ++-- crates/common/src/abi.rs | 4 +-- crates/common/src/compile.rs | 8 ++--- crates/common/src/lib.rs | 3 ++ crates/common/src/selectors.rs | 1 - crates/config/src/etherscan.rs | 1 - crates/config/src/lib.rs | 14 ++++---- crates/config/src/providers/remappings.rs | 1 - crates/debugger/src/debugger.rs | 1 - crates/debugger/src/lib.rs | 3 ++ crates/doc/src/lib.rs | 9 +++-- crates/doc/src/parser/comment.rs | 2 +- crates/doc/src/parser/item.rs | 2 +- crates/evm/core/src/backend/fuzz.rs | 2 +- crates/evm/core/src/backend/mod.rs | 4 +-- crates/evm/core/src/fork/backend.rs | 14 ++++---- crates/evm/core/src/fork/cache.rs | 10 +++--- crates/evm/evm/src/executors/fuzz/mod.rs | 2 +- crates/evm/fuzz/src/strategies/calldata.rs | 2 +- crates/evm/fuzz/src/strategies/invariants.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 3 +- crates/forge/bin/cmd/fmt.rs | 1 - crates/forge/bin/cmd/geiger/find.rs | 2 +- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 1 - crates/forge/bin/cmd/install.rs | 1 - crates/forge/bin/cmd/script/broadcast.rs | 5 ++- crates/forge/bin/cmd/script/build.rs | 1 - crates/forge/bin/cmd/script/cmd.rs | 1 - crates/forge/bin/cmd/script/executor.rs | 1 - crates/forge/bin/cmd/script/mod.rs | 2 +- crates/forge/bin/cmd/script/multi.rs | 1 - crates/forge/bin/cmd/script/receipts.rs | 5 ++- crates/forge/bin/cmd/script/runner.rs | 1 - crates/forge/bin/cmd/script/sequence.rs | 1 - crates/forge/bin/cmd/script/transaction.rs | 1 - crates/forge/bin/cmd/test/mod.rs | 1 - crates/forge/bin/cmd/verify/etherscan/mod.rs | 9 +++-- .../bin/cmd/verify/etherscan/standard_json.rs | 3 +- crates/forge/bin/cmd/verify/sourcify.rs | 1 - crates/forge/bin/cmd/watch.rs | 15 ++++---- crates/forge/bin/main.rs | 3 ++ crates/forge/src/multi_runner.rs | 2 +- crates/forge/src/runner.rs | 8 ++--- crates/forge/tests/cli/cmd.rs | 2 +- crates/forge/tests/cli/script.rs | 8 ++--- crates/macros/src/fmt/ui.rs | 2 +- crates/utils/src/lib.rs | 34 +++++++++---------- 78 files changed, 126 insertions(+), 152 deletions(-) diff --git a/crates/anvil/server/src/handler.rs b/crates/anvil/server/src/handler.rs index 07b808a4bb3f9..3b3ea8ddbc207 100644 --- a/crates/anvil/server/src/handler.rs +++ b/crates/anvil/server/src/handler.rs @@ -9,7 +9,6 @@ use axum::{ Json, }; use futures::{future, FutureExt}; -use tracing::{trace, warn}; /// Handles incoming JSON-RPC Request pub async fn handle( diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index 4b34abbb7f249..97ec0709887dc 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -11,7 +11,6 @@ use std::{ pin::Pin, task::{Context, Poll}, }; -use tracing::{error, trace, warn}; /// An IPC connection for anvil /// @@ -33,22 +32,22 @@ impl IpcEndpoint { /// /// This establishes the ipc endpoint, converts the incoming connections into handled eth /// connections, See [`PubSubConnection`] that should be spawned - #[tracing::instrument(target = "ipc", skip_all)] + #[instrument(target = "ipc", skip_all)] pub fn incoming(self) -> io::Result>> { let IpcEndpoint { handler, endpoint } = self; - trace!( endpoint=?endpoint.path(), "starting ipc server" ); + trace!(endpoint=?endpoint.path(), "starting IPC server" ); if cfg!(unix) { // ensure the file does not exist if std::fs::remove_file(endpoint.path()).is_ok() { - warn!( endpoint=?endpoint.path(), "removed existing file"); + warn!(endpoint=?endpoint.path(), "removed existing file"); } } let connections = match endpoint.incoming() { Ok(connections) => connections, Err(err) => { - error!(?err, "Failed to create ipc listener"); + error!(%err, "Failed to create IPC listener"); return Err(err) } }; diff --git a/crates/anvil/server/src/lib.rs b/crates/anvil/server/src/lib.rs index 3cd044c94b375..d88c5e6912177 100644 --- a/crates/anvil/server/src/lib.rs +++ b/crates/anvil/server/src/lib.rs @@ -1,6 +1,9 @@ //! Bootstrap [axum] RPC servers -#![deny(missing_docs, unsafe_code, unused_crate_dependencies)] +#![warn(missing_docs, unused_crate_dependencies)] + +#[macro_use] +extern crate tracing; use anvil_rpc::{ error::RpcError, @@ -17,7 +20,6 @@ use hyper::server::conn::AddrIncoming; use serde::de::DeserializeOwned; use std::{fmt, net::SocketAddr}; use tower_http::{cors::CorsLayer, trace::TraceLayer}; -use tracing::{error, trace}; mod config; diff --git a/crates/anvil/server/src/pubsub.rs b/crates/anvil/server/src/pubsub.rs index 1ceee635687d0..476206874e644 100644 --- a/crates/anvil/server/src/pubsub.rs +++ b/crates/anvil/server/src/pubsub.rs @@ -17,7 +17,6 @@ use std::{ sync::Arc, task::{Context, Poll}, }; -use tracing::{error, trace}; /// The general purpose trait for handling RPC requests and subscriptions #[async_trait::async_trait] diff --git a/crates/anvil/server/src/ws.rs b/crates/anvil/server/src/ws.rs index 346e7ceb5dd33..48dbba7100d3d 100644 --- a/crates/anvil/server/src/ws.rs +++ b/crates/anvil/server/src/ws.rs @@ -13,7 +13,6 @@ use std::{ pin::Pin, task::{Context, Poll}, }; -use tracing::trace; /// Handles incoming Websocket upgrade /// diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 3bc9fef15e259..7d695ae0fc3b7 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -28,7 +28,6 @@ use std::{ time::Duration, }; use tokio::time::{Instant, Interval}; -use tracing::{error, trace}; #[derive(Clone, Debug, Parser)] pub struct NodeArgs { diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 867d622a9efac..2f228e54ca49d 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -74,7 +74,6 @@ use foundry_utils::types::ToEthers; use futures::channel::{mpsc::Receiver, oneshot}; use parking_lot::RwLock; use std::{collections::HashSet, future::Future, sync::Arc, time::Duration}; -use tracing::{trace, warn}; /// The client version: `anvil/v{major}.{minor}.{patch}` pub const CLIENT_VERSION: &str = concat!("anvil/v", env!("CARGO_PKG_VERSION")); diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 128ad440df6ae..2a90d2156264a 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -5,7 +5,6 @@ use ethers::types::{Address, Signature}; use foundry_evm::hashbrown::HashSet; use parking_lot::RwLock; use std::sync::Arc; -use tracing::trace; /// Manages user modifications that may affect the node's behavior /// diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index e388598489e72..d942ca122cea6 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -29,7 +29,6 @@ use foundry_evm::{ }; use foundry_utils::types::{ToAlloy, ToEthers}; use std::sync::Arc; -use tracing::{trace, warn}; /// Represents an executed transaction (transacted on the DB) pub struct ExecutedTransaction { diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 7c33888937839..6ffd32d5d1b93 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -19,7 +19,6 @@ use parking_lot::{ }; use std::{collections::HashMap, sync::Arc, time::Duration}; use tokio::sync::RwLock as AsyncRwLock; -use tracing::trace; /// Represents a fork of a remote client /// diff --git a/crates/anvil/src/eth/backend/mem/cache.rs b/crates/anvil/src/eth/backend/mem/cache.rs index 362770af3b391..a3990e82de2a7 100644 --- a/crates/anvil/src/eth/backend/mem/cache.rs +++ b/crates/anvil/src/eth/backend/mem/cache.rs @@ -6,7 +6,6 @@ use std::{ path::{Path, PathBuf}, }; use tempfile::TempDir; -use tracing::{error, trace}; /// On disk state cache /// @@ -40,7 +39,7 @@ impl DiskStateCache { self.temp_dir = Some(temp_dir); } Err(err) => { - error!(target: "backend", ?err, "failed to create disk state cache dir"); + error!(target: "backend", %err, "failed to create disk state cache dir"); } } } @@ -65,7 +64,7 @@ impl DiskStateCache { trace!(target: "backend", ?hash, "wrote state json file"); } Err(err) => { - error!(target: "backend", ?err, ?hash, "Failed to load state snapshot"); + error!(target: "backend", %err, ?hash, "Failed to load state snapshot"); } }; }); @@ -83,7 +82,7 @@ impl DiskStateCache { Some(state) } Err(err) => { - error!(target: "backend", ?err, ?hash, "Failed to load state snapshot"); + error!(target: "backend", %err, ?hash, "Failed to load state snapshot"); None } } @@ -95,7 +94,7 @@ impl DiskStateCache { pub fn remove(&mut self, hash: H256) { self.with_cache_file(hash, |file| { foundry_common::fs::remove_file(file).map_err(|err| { - error!(target: "backend", ?err, ?hash, "Failed to remove state snapshot"); + error!(target: "backend", %err, %hash, "Failed to remove state snapshot"); }) }); } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 47ccccdb72755..1610bfc125a1d 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -15,7 +15,6 @@ use foundry_evm::{ fork::BlockchainDb, }; use foundry_utils::types::{ToAlloy, ToEthers}; -use tracing::{trace, warn}; // reexport for convenience pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d313f1dd81724..b6b99f3e16812 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -85,7 +85,6 @@ use std::{ }; use storage::{Blockchain, MinedTransaction}; use tokio::sync::RwLock as AsyncRwLock; -use tracing::{trace, warn}; use trie_db::{Recorder, Trie}; pub mod cache; diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index bc7f011da0ec0..783966dbe36b3 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -4,7 +4,6 @@ use crate::eth::error::BlockchainError; use chrono::{DateTime, NaiveDateTime, Utc}; use parking_lot::RwLock; use std::{sync::Arc, time::Duration}; -use tracing::trace; /// Returns the `Utc` datetime for the given seconds since unix epoch pub fn utc_from_secs(secs: u64) -> DateTime { diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 1ecd4191a0e1d..971ef9956111c 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -21,7 +21,6 @@ use foundry_evm::{ }, }; use serde::Serialize; -use tracing::error; pub(crate) type Result = std::result::Result; @@ -280,7 +279,7 @@ pub fn to_rpc_result(val: T) -> ResponseResult { match serde_json::to_value(val) { Ok(success) => ResponseResult::Success(success), Err(err) => { - error!("Failed serialize rpc response: {:?}", err); + error!(%err, "Failed serialize rpc response"); ResponseResult::error(RpcError::internal_error()) } } @@ -292,7 +291,7 @@ impl ToRpcResponseResult for Result { Ok(val) => to_rpc_result(val), Err(err) => match err { BlockchainError::Pool(err) => { - error!("txpool error: {:?}", err); + error!(%err, "txpool error"); match err { PoolError::CyclicTransaction => { RpcError::transaction_rejected("Cyclic transaction detected") @@ -367,7 +366,7 @@ impl ToRpcResponseResult for Result { "Invalid input: `max_priority_fee_per_gas` greater than `max_fee_per_gas`", ), BlockchainError::ForkProvider(err) => { - error!("fork provider error: {:?}", err); + error!(%err, "fork provider error"); RpcError::internal_error_with(format!("Fork Error: {err:?}")) } err @ BlockchainError::EvmError(_) => { diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 97acabb1df36a..2206d302b8d91 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -15,7 +15,6 @@ use std::{ sync::Arc, task::{Context, Poll}, }; -use tracing::trace; /// Maximum number of entries in the fee history cache pub const MAX_FEE_HISTORY_CACHE_SIZE: u64 = 2048u64; diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index 148361279b7aa..9e859f8001886 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -16,7 +16,6 @@ use std::{ time::Duration, }; use tokio::time::Interval; -use tracing::trace; #[derive(Debug, Clone)] pub struct Miner { diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index 842015837d71e..4fca41febccf6 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -44,7 +44,6 @@ use ethers::{ use futures::channel::mpsc::{channel, Receiver, Sender}; use parking_lot::{Mutex, RwLock}; use std::{collections::VecDeque, fmt, sync::Arc}; -use tracing::{debug, trace, warn}; pub mod transactions; diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index d0c0337c6b0f2..e6b7890f6c8d9 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -10,7 +10,6 @@ use std::{ sync::Arc, time::Instant, }; -use tracing::{trace, warn}; /// A unique identifying marker for a transaction pub type TxMarker = Vec; diff --git a/crates/anvil/src/filter.rs b/crates/anvil/src/filter.rs index 0409195caeba4..e6083df27b423 100644 --- a/crates/anvil/src/filter.rs +++ b/crates/anvil/src/filter.rs @@ -19,7 +19,6 @@ use std::{ time::{Duration, Instant}, }; use tokio::sync::Mutex; -use tracing::{trace, warn}; /// Type alias for filters identified by their id and their expiration timestamp type FilterMap = Arc>>; diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 45f5c6c2dda65..5d612dab8043b 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate tracing; + use crate::{ eth::{ backend::{info::StorageInfo, mem}, diff --git a/crates/anvil/src/server/handler.rs b/crates/anvil/src/server/handler.rs index eed6e1931aa4b..7306d603430c8 100644 --- a/crates/anvil/src/server/handler.rs +++ b/crates/anvil/src/server/handler.rs @@ -11,7 +11,6 @@ use anvil_core::eth::{ use anvil_rpc::{error::RpcError, response::ResponseResult}; use anvil_server::{PubSubContext, PubSubRpcHandler, RpcHandler}; use ethers::types::FilteredParams; -use tracing::trace; /// A `RpcHandler` that expects `EthRequest` rpc calls via http #[derive(Clone)] diff --git a/crates/anvil/src/server/mod.rs b/crates/anvil/src/server/mod.rs index ef98e8b3d20e2..10d86f6713d5f 100644 --- a/crates/anvil/src/server/mod.rs +++ b/crates/anvil/src/server/mod.rs @@ -5,7 +5,6 @@ use futures::StreamExt; use handler::{HttpEthRpcHandler, PubSubEthRpcHandler}; use std::net::SocketAddr; use tokio::{io, task::JoinHandle}; -use tracing::trace; mod handler; diff --git a/crates/anvil/src/service.rs b/crates/anvil/src/service.rs index f4b1003bcfc59..f81d6f6cb1526 100644 --- a/crates/anvil/src/service.rs +++ b/crates/anvil/src/service.rs @@ -19,7 +19,6 @@ use std::{ task::{Context, Poll}, }; use tokio::time::Interval; -use tracing::trace; /// The type that drives the blockchain's state /// diff --git a/crates/binder/src/lib.rs b/crates/binder/src/lib.rs index 8db7b892167eb..269719da9db32 100644 --- a/crates/binder/src/lib.rs +++ b/crates/binder/src/lib.rs @@ -2,6 +2,9 @@ #![warn(unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + use crate::utils::{GitReference, GitRemote}; use ethers_contract::MultiAbigen; pub use foundry_config::Config; @@ -10,7 +13,7 @@ use std::{ process::{Command, Stdio}, }; use tempfile::{tempdir, TempDir}; -use tracing::trace; + pub use url::Url; pub mod utils; diff --git a/crates/binder/src/utils.rs b/crates/binder/src/utils.rs index 479c32892aef0..7667fe26f148e 100644 --- a/crates/binder/src/utils.rs +++ b/crates/binder/src/utils.rs @@ -11,7 +11,6 @@ use std::{ path::{Path, PathBuf}, process::Command, }; -use tracing::{debug, info}; use url::Url; /// Represents a remote repository. diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index f4b4260a1e2ba..5d93f0917bb11 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -17,7 +17,6 @@ use foundry_evm::{ utils::configure_tx_env, }; use foundry_utils::types::ToAlloy; -use tracing::trace; /// CLI arguments for `cast run`. #[derive(Debug, Clone, Parser)] @@ -196,7 +195,7 @@ impl RunArgs { configure_tx_env(&mut env, &tx); if let Some(to) = tx.to { - trace!(tx=?tx.hash,to=?to, "executing call transaction"); + trace!(tx=?tx.hash, to=?to, "executing call transaction"); TraceResult::from(executor.commit_tx_with_env(env)?) } else { trace!(tx=?tx.hash, "executing create transaction"); diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index e268435d0d113..d4a11421e31b2 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate tracing; + use alloy_primitives::{keccak256, Address, B256}; use cast::{Cast, SimpleCast}; use clap::{CommandFactory, Parser}; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 5c95cfc2fa2fd..ab5368c44f5d7 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -256,7 +256,7 @@ impl Cheatcodes { /// Cleanup any previously applied cheatcodes that altered the state in such a way that revm's /// revert would run into issues. pub fn on_revert(&mut self, data: &mut EVMData<'_, DB>) { - trace!(deals = ?self.eth_deals.len(), "rolling back deals"); + trace!(deals=?self.eth_deals.len(), "rolling back deals"); // Delay revert clean up until expected revert is handled, if set. if self.expected_revert.is_some() { diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index e39f98f5a9623..a68772e91eb5a 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -13,7 +13,6 @@ extern crate tracing; use alloy_primitives::Address; use foundry_evm_core::backend::DatabaseExt; use revm::EVMData; -use tracing::Level; pub use defs::{CheatcodeDef, Vm}; @@ -67,7 +66,7 @@ pub(crate) trait Cheatcode: CheatcodeDef { // Separate functions to avoid inline and monomorphization bloat. fn trace_span(cheat: &T) -> tracing::Span { - if enabled!(Level::TRACE) { + if enabled!(tracing::Level::TRACE) { trace_span!(target: "cheatcodes", "apply", cheat=?cheat) } else { debug_span!(target: "cheatcodes", "apply", id=%T::CHEATCODE.func.id) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 4c085f2c95a01..f27054b4839ea 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -179,7 +179,7 @@ macro_rules! p_println { /// Loads a dotenv file, from the cwd and the project root, ignoring potential failure. /// -/// We could use `tracing::warn!` here, but that would imply that the dotenv file can't configure +/// We could use `warn!` here, but that would imply that the dotenv file can't configure /// the logging behavior of Foundry. /// /// Similarly, we could just use `eprintln!`, but colors are off limits otherwise dotenv is implied @@ -259,11 +259,11 @@ pub trait CommandUtils { impl CommandUtils for Command { #[track_caller] fn exec(&mut self) -> Result { - tracing::trace!(command=?self, "executing"); + trace!(command=?self, "executing"); let output = self.output()?; - tracing::trace!(code=?output.status.code(), ?output); + trace!(code=?output.status.code(), ?output); if output.status.success() { Ok(output) diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index d3761605dae6d..1961a010abcfe 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -158,7 +158,7 @@ pub fn find_source( address: Address, ) -> Pin>>> { Box::pin(async move { - tracing::trace!("find etherscan source for: {:?}", address); + trace!(%address, "find Etherscan source"); let source = client.contract_source_code(address).await?; let metadata = source.items.first().wrap_err("Etherscan returned no data")?; if metadata.proxy == 0 { @@ -173,7 +173,7 @@ pub fn find_source( Err(e) => { let err = EtherscanError::ContractCodeNotVerified(address).to_string(); if e.to_string() == err { - tracing::error!("{}", err); + error!(%err); Ok(source) } else { Err(e) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 83ab7bc1ab446..db67b648c71f0 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -85,7 +85,7 @@ impl ProjectCompiler { /// .compile_with(&config.project().unwrap(), |prj| Ok(prj.compile()?)) /// .unwrap(); /// ``` - #[tracing::instrument(target = "forge::compile", skip_all)] + #[instrument(target = "forge::compile", skip_all)] pub fn compile_with(self, project: &Project, f: F) -> Result where F: FnOnce(&Project) -> Result, @@ -97,15 +97,15 @@ impl ProjectCompiler { } let now = std::time::Instant::now(); - tracing::trace!("start compiling project"); + trace!("start compiling project"); let output = term::with_spinner_reporter(|| f(project))?; let elapsed = now.elapsed(); - tracing::trace!(?elapsed, "finished compiling"); + trace!(?elapsed, "finished compiling"); if output.has_compiler_errors() { - tracing::warn!("compiled with errors"); + warn!("compiled with errors"); eyre::bail!(output.to_string()) } else if output.is_unchanged() { println!("No files changed, compilation skipped"); diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 8b6484a024e15..241041ee8160e 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -2,6 +2,9 @@ #![warn(missing_docs, unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + pub mod abi; pub mod calc; pub mod clap_helpers; diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index f2d5cb281ee9e..de886a385c180 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -13,7 +13,6 @@ use std::{ }, time::Duration, }; -use tracing::warn; static SELECTOR_DATABASE_URL: &str = "https://api.openchain.xyz/signature-database/v1/"; static SELECTOR_IMPORT_URL: &str = "https://api.openchain.xyz/signature-database/v1/import"; diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 721df63b4bb07..36e1dbba976e1 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -11,7 +11,6 @@ use std::{ ops::{Deref, DerefMut}, time::Duration, }; -use tracing::warn; /// The user agent to use when querying the etherscan API. pub const ETHERSCAN_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 32444a5b7b89d..afe750e9bbbbf 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2,6 +2,9 @@ #![warn(missing_docs, unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + use crate::cache::StorageCachingConfig; use alloy_primitives::{address, Address, B256, U256}; use eyre::{ContextCompat, WrapErr}; @@ -34,8 +37,6 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -pub(crate) use tracing::trace; -use NamedChain::Mainnet; // Macros useful for creating a figment. mod macros; @@ -78,7 +79,6 @@ pub mod fix; // reexport so cli types can implement `figment::Provider` to easily merge compiler arguments pub use figment; use revm_primitives::SpecId; -use tracing::warn; /// config providers pub mod providers; @@ -895,7 +895,7 @@ impl Config { // we treat the `etherscan_api_key` as actual API key // if no chain provided, we assume mainnet - let chain = self.chain_id.unwrap_or(Chain::Named(Mainnet)); + let chain = self.chain_id.unwrap_or(Chain::Named(NamedChain::Mainnet)); let api_key = self.etherscan_api_key.as_ref()?; ResolvedEtherscanConfig::create(api_key, chain).map(Ok) } @@ -2156,7 +2156,7 @@ impl Provider for DappEnvCompatProvider { let val = val.parse::().map_err(figment::Error::custom)?; if val > 1 { return Err( - format!("Invalid $DAPP_BUILD_OPTIMIZE value `{val}`, expected 0 or 1").into() + format!("Invalid $DAPP_BUILD_OPTIMIZE value `{val}`, expected 0 or 1").into() ) } dict.insert("optimizer".to_string(), (val == 1).into()); @@ -2979,7 +2979,7 @@ mod tests { assert!(!configs.has_unresolved()); let mb_urls = Moonbeam.etherscan_urls().unwrap(); - let mainnet_urls = Mainnet.etherscan_urls().unwrap(); + let mainnet_urls = NamedChain::Mainnet.etherscan_urls().unwrap(); assert_eq!( configs, ResolvedEtherscanConfigs::new([ @@ -2987,7 +2987,7 @@ mod tests { "mainnet", ResolvedEtherscanConfig { api_url: mainnet_urls.0.to_string(), - chain: Some(Mainnet.into()), + chain: Some(NamedChain::Mainnet.into()), browser_url: Some(mainnet_urls.1.to_string()), key: "FX42Z3BBJJEWXWGYV2X1CIPRSCN".to_string(), } diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index bb5a852a9c66d..43048643a822e 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -10,7 +10,6 @@ use std::{ fs, path::{Path, PathBuf}, }; -use tracing::trace; /// Wrapper types over a `Vec` that only appends unique remappings. #[derive(Debug, Clone, Default)] diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index c036129e2661c..10893a6589492 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -2,7 +2,6 @@ use crate::{TUIExitReason, Tui, Ui}; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; use foundry_evm_core::debug::DebugArena; use foundry_evm_traces::CallTraceDecoder; -use tracing::{error, trace}; /// Standardized way of firing up the debugger pub struct DebuggerArgs<'a> { diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 77b70d77a8ce8..d5f31d7f89f45 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -1,5 +1,8 @@ #![warn(unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + use alloy_primitives::{Address, U256}; use crossterm::{ event::{ diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index d629283b55723..1a14bd61c7837 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -1,3 +1,7 @@ +//! The module for generating Solidity documentation. +//! +//! See [DocBuilder] + #![warn(missing_debug_implementations, missing_docs, unreachable_pub, unused_crate_dependencies)] #![deny(unused_must_use, rust_2018_idioms)] #![doc(test( @@ -5,9 +9,8 @@ attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) ))] -//! The module for generating Solidity documentation. -//! -//! See [DocBuilder] +#[macro_use] +extern crate tracing; mod builder; mod document; diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index 0cac1978bcdda..667d1aca6d46b 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -45,7 +45,7 @@ impl CommentTag { } } _ => { - tracing::warn!(target: "forge::doc", tag = trimmed, "unknown comment tag. custom tags must be preceded by `custom:`"); + warn!(target: "forge::doc", tag=trimmed, "unknown comment tag. custom tags must be preceded by `custom:`"); return None } }; diff --git a/crates/doc/src/parser/item.rs b/crates/doc/src/parser/item.rs index b33068341daf3..0321fc411a975 100644 --- a/crates/doc/src/parser/item.rs +++ b/crates/doc/src/parser/item.rs @@ -27,7 +27,7 @@ pub struct ParseItem { macro_rules! filter_children_fn { ($vis:vis fn $name:ident(&self, $variant:ident) -> $ret:ty) => { /// Filter children items for [ParseSource::$variant] variants. - $vis fn $name(&self) -> Option> { + $vis fn $name(&self) -> Option> { let items = self.children.iter().filter_map(|item| match item.source { ParseSource::$variant(ref inner) => Some((inner, &item.comments, &item.code)), _ => None, diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index eff28bfe10e1b..77e8bd6f577cf 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -65,7 +65,7 @@ impl<'a> FuzzBackendWrapper<'a> { self.is_initialized = false; match revm::evm_inner::(env, self, &mut inspector).transact() { Ok(result) => Ok(result), - Err(e) => eyre::bail!("fuzz: failed to inspect: {:?}", e), + Err(e) => eyre::bail!("fuzz: failed to inspect: {e}"), } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index d62b6ae2171d3..90849b53c1941 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -770,7 +770,7 @@ impl Backend { match revm::evm_inner::(env, self, &mut inspector).transact() { Ok(res) => Ok(res), - Err(e) => eyre::bail!("backend: failed while inspecting: {:?}", e), + Err(e) => eyre::bail!("backend: failed while inspecting: {e}"), } } @@ -1874,7 +1874,7 @@ fn commit_transaction>( match evm.inspect(inspector) { Ok(res) => res.state, - Err(e) => eyre::bail!("backend: failed committing transaction: {:?}", e), + Err(e) => eyre::bail!("backend: failed committing transaction: {e}"), } }; diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 5083327a66360..37ac0b937b0a8 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -282,7 +282,7 @@ where Ok(KECCAK_EMPTY.to_ethers()) } Err(err) => { - error!(target: "backendhandler", ?err, ?number, "failed to get block"); + error!(target: "backendhandler", %err, ?number, "failed to get block"); Err(err) } }; @@ -643,9 +643,9 @@ impl DatabaseRef for SharedBackend { type Error = DatabaseError; fn basic(&self, address: Address) -> Result, Self::Error> { - trace!( target: "sharedbackend", "request basic {:?}", address); + trace!(target: "sharedbackend", %address, "request basic"); self.do_get_basic(address).map_err(|err| { - error!(target: "sharedbackend", ?err, ?address, "Failed to send/recv `basic`"); + error!(target: "sharedbackend", %err, %address, "Failed to send/recv `basic`"); if err.is_possibly_non_archive_node_error() { error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); } @@ -658,9 +658,9 @@ impl DatabaseRef for SharedBackend { } fn storage(&self, address: Address, index: U256) -> Result { - trace!( target: "sharedbackend", "request storage {:?} at {:?}", address, index); + trace!(target: "sharedbackend", "request storage {:?} at {:?}", address, index); match self.do_get_storage(address, index).map_err(|err| { - error!( target: "sharedbackend", ?err, ?address, ?index, "Failed to send/recv `storage`"); + error!(target: "sharedbackend", %err, %address, %index, "Failed to send/recv `storage`"); if err.is_possibly_non_archive_node_error() { error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); } @@ -677,9 +677,9 @@ impl DatabaseRef for SharedBackend { } let number: U256 = number; let number = number.to(); - trace!( target: "sharedbackend", "request block hash for number {:?}", number); + trace!(target: "sharedbackend", "request block hash for number {:?}", number); match self.do_get_block_hash(number).map_err(|err| { - error!(target: "sharedbackend",?err, ?number, "Failed to send/recv `block_hash`"); + error!(target: "sharedbackend", %err, %number, "Failed to send/recv `block_hash`"); if err.is_possibly_non_archive_node_error() { error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); } diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index f2203fc5de9c4..42de2bd8af312 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -61,7 +61,7 @@ impl BlockchainDb { } fn new_db(meta: BlockchainDbMeta, cache_path: Option, skip_check: bool) -> Self { - trace!(target : "forge::cache", cache=?cache_path, "initialising blockchain db"); + trace!(target: "forge::cache", cache=?cache_path, "initialising blockchain db"); // read cache and check if metadata matches let cache = cache_path .as_ref() @@ -73,7 +73,7 @@ impl BlockchainDb { let mut existing = cache.meta().write(); existing.hosts.extend(meta.hosts.clone()); if meta != *existing { - warn!(target : "cache", "non-matching block metadata"); + warn!(target: "cache", "non-matching block metadata"); false } else { true @@ -334,13 +334,13 @@ impl JsonBlockCacheDB { /// - the format does not match [JsonBlockCacheData] pub fn load(path: impl Into) -> eyre::Result { let path = path.into(); - trace!(target : "cache", ?path, "reading json cache"); + trace!(target: "cache", ?path, "reading json cache"); let contents = std::fs::read_to_string(&path).map_err(|err| { warn!(?err, ?path, "Failed to read cache file"); err })?; let data = serde_json::from_str(&contents).map_err(|err| { - warn!(target : "cache", ?err, ?path, "Failed to deserialize cache data"); + warn!(target: "cache", ?err, ?path, "Failed to deserialize cache data"); err })?; Ok(Self { cache_path: Some(path), data }) @@ -362,7 +362,7 @@ impl JsonBlockCacheDB { } /// Flushes the DB to disk if caching is enabled. - #[tracing::instrument(level = "warn", skip_all, fields(path = ?self.cache_path))] + #[instrument(level = "warn", skip_all, fields(path = ?self.cache_path))] pub fn flush(&self) { let Some(path) = &self.cache_path else { return }; trace!(target: "cache", "saving json cache"); diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 42c4de0e32f1c..c92f0e21cfb4a 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -92,7 +92,7 @@ impl<'a> FuzzedExecutor<'a> { } let strat = proptest::strategy::Union::new_weighted(weights); - debug!(func = ?func.name, should_fail, "fuzzing"); + debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(&state, address, should_fail, calldata)?; diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index 2d07e83ac9465..7a1566243cdea 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -17,7 +17,7 @@ pub fn fuzz_calldata(func: Function) -> BoxedStrategy { strats .prop_map(move |tokens| { - trace!(input = ?tokens); + trace!(input=?tokens); func.abi_encode_input(&tokens).unwrap().into() }) .boxed() diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 62be1b6eb57d4..3534ffea17533 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -174,7 +174,7 @@ pub fn fuzz_contract_with_calldata( 40 => fuzz_calldata_from_state(func, fuzz_state), ]; strats.prop_map(move |calldata| { - trace!(input = ?calldata); + trace!(input=?calldata); (contract, calldata) }) } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 936cf2a14f506..b68e35b398b08 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -28,7 +28,6 @@ use foundry_compilers::{ use foundry_config::{Config, SolcReq}; use semver::Version; use std::{collections::HashMap, path::PathBuf, sync::mpsc::channel}; -use tracing::trace; use yansi::Paint; /// A map, keyed by contract ID, to a tuple of the deployment source map and the runtime source map. @@ -150,7 +149,7 @@ impl CoverageArgs { } /// Builds the coverage report. - #[tracing::instrument(name = "prepare coverage", skip_all)] + #[instrument(name = "prepare coverage", skip_all)] fn prepare(&self, config: &Config, output: ProjectCompileOutput) -> Result { let project_paths = config.project_paths(); diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 8f5bc5b97f248..7886ae278170d 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -13,7 +13,6 @@ use std::{ io::{Read, Write as _}, path::{Path, PathBuf}, }; -use tracing::log::warn; use yansi::Color; /// CLI arguments for `forge fmt`. diff --git a/crates/forge/bin/cmd/geiger/find.rs b/crates/forge/bin/cmd/geiger/find.rs index 315381b556111..d86dcd0fc2957 100644 --- a/crates/forge/bin/cmd/geiger/find.rs +++ b/crates/forge/bin/cmd/geiger/find.rs @@ -60,7 +60,7 @@ impl<'a, 'b> fmt::Display for SolFileMetricsPrinter<'a, 'b> { for &loc in $field { let content = &metrics.contents[loc.range()]; let (line, col) = offset_to_line_column(&metrics.contents, loc.start()); - let pos = format!(" --> {}:{}:{}", file.display(), line, col); + let pos = format!(" --> {}:{}:{}", file.display(), line, col); writeln!(f,"{}", Paint::red(pos))?; for line in content.lines() { writeln!(f, " {}", Paint::red(line))?; diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index d165037c9b5f8..864babf557102 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -159,7 +159,7 @@ impl InitArgs { } } - p_println!(!quiet => " {} forge project", Paint::green("Initialized")); + p_println!(!quiet => " {} forge project", Paint::green("Initialized")); Ok(()) } } diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 42f72b8c4f3ea..cfd05353e7e24 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -17,7 +17,6 @@ use foundry_compilers::{ }; use serde_json::{to_value, Value}; use std::fmt; -use tracing::trace; /// CLI arguments for `forge inspect`. #[derive(Debug, Clone, Parser)] diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 44ca38e45cdf4..d01fe97940621 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -15,7 +15,6 @@ use std::{ path::{Path, PathBuf}, str, }; -use tracing::{trace, warn}; use yansi::Paint; static DEPENDENCY_VERSION_TAG_REGEX: Lazy = diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index e2ad7b22845b5..72d6be2ae5f9c 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -15,7 +15,6 @@ use foundry_cli::{ use foundry_common::{estimate_eip1559_fees, shell, try_get_http_provider, RetryProvider}; use futures::StreamExt; use std::{cmp::min, collections::HashSet, ops::Mul, sync::Arc}; -use tracing::trace; impl ScriptArgs { /// Sends the transactions which haven't been broadcasted yet. @@ -244,7 +243,7 @@ impl ScriptArgs { match kind { SendTransactionKind::Unlocked(addr) => { - tracing::debug!("sending transaction from unlocked account {:?}: {:?}", addr, tx); + debug!("sending transaction from unlocked account {:?}: {:?}", addr, tx); // Chains which use `eth_estimateGas` are being sent sequentially and require their // gas to be re-estimated right before broadcasting. @@ -574,7 +573,7 @@ impl ScriptArgs { signer: &WalletSigner, mut legacy_or_1559: TypedTransaction, ) -> Result { - tracing::debug!("sending transaction: {:?}", legacy_or_1559); + debug!("sending transaction: {:?}", legacy_or_1559); // Chains which use `eth_estimateGas` are being sent sequentially and require their gas // to be re-estimated right before broadcasting. diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 242e5f30f0d25..427c3401c4532 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -16,7 +16,6 @@ use foundry_compilers::{ }; use foundry_utils::{PostLinkInput, ResolvedDependency}; use std::{collections::BTreeMap, str::FromStr}; -use tracing::{trace, warn}; impl ScriptArgs { /// Compiles the file or project and the verify metadata. diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 8d7e9e41c53b4..cbdd94ef829be 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -9,7 +9,6 @@ use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; use foundry_debugger::DebuggerArgs; use foundry_utils::types::ToAlloy; use std::sync::Arc; -use tracing::trace; /// Helper alias type for the collection of data changed due to the new sender. type NewSenderChanges = (CallTraceDecoder, Libraries, ArtifactContracts); diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index f346c71be2f7e..4d8c4b33031b8 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -21,7 +21,6 @@ use foundry_utils::types::ToEthers; use futures::future::join_all; use parking_lot::RwLock; use std::{collections::VecDeque, sync::Arc}; -use tracing::trace; /// Helper alias type for the processed result of a runner onchain simulation. type RunnerResult = (Option, Traces); diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index b182adc8c95ba..f7a6fd47ebb20 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -806,7 +806,7 @@ mod tests { "blacksmith", "--broadcast", "--verify", - "-vvvv", + "-vvvvv", ]); assert_eq!( args.verifier.verifier_url, diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index 2f7548cb9b5c5..e98f01f38685b 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -17,7 +17,6 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use tracing::log::trace; /// Holds the sequences of multiple chain deployments. #[derive(Deserialize, Serialize, Clone, Default)] diff --git a/crates/forge/bin/cmd/script/receipts.rs b/crates/forge/bin/cmd/script/receipts.rs index 4752ddfd918e7..638e92f91f86a 100644 --- a/crates/forge/bin/cmd/script/receipts.rs +++ b/crates/forge/bin/cmd/script/receipts.rs @@ -8,7 +8,6 @@ use foundry_common::RetryProvider; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::StreamExt; use std::sync::Arc; -use tracing::{trace, warn}; /// Convenience enum for internal signalling of transaction status enum TxStatus { @@ -85,7 +84,7 @@ pub async fn clear_pendings( errors.push(format!("Transaction dropped from the mempool: {tx_hash:?}")); } Ok(TxStatus::Success(receipt)) => { - trace!(tx_hash = ?tx_hash, "received tx receipt"); + trace!(tx_hash=?tx_hash, "received tx receipt"); deployment_sequence.remove_pending(receipt.transaction_hash.to_alloy()); receipts.push(receipt); } @@ -93,7 +92,7 @@ pub async fn clear_pendings( // consider: // if this is not removed from pending, then the script becomes // un-resumable. Is this desirable on reverts? - warn!(tx_hash = ?tx_hash, "Transaction Failure"); + warn!(tx_hash=?tx_hash, "Transaction Failure"); deployment_sequence.remove_pending(receipt.transaction_hash.to_alloy()); errors.push(format!("Transaction Failure: {:?}", receipt.transaction_hash)); } diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index db18be6770c72..7035c44de7753 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -8,7 +8,6 @@ use forge::{ revm::interpreter::{return_ok, InstructionResult}, traces::{TraceKind, Traces}, }; -use tracing::log::trace; /// Represents which simulation stage is the script execution at. pub enum SimulationStage { diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 0fce7ef52653d..0b612d8fe73be 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -21,7 +21,6 @@ use std::{ io::{BufWriter, Write}, path::{Path, PathBuf}, }; -use tracing::trace; use yansi::Paint; pub const DRY_RUN_DIR: &str = "dry-run"; diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 514f6e7861834..74fe0a75d2975 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -9,7 +9,6 @@ use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder, use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; -use tracing::error; #[derive(Debug, Deserialize, Serialize, Clone, Default)] #[serde(rename_all = "camelCase")] diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index d0cf5bd16bc9b..3fc373eafeabc 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -34,7 +34,6 @@ use foundry_config::{ use foundry_debugger::DebuggerArgs; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; -use tracing::trace; use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index e2a4281de30b0..533e451e4e9b3 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -21,7 +21,6 @@ use std::{ fmt::Debug, path::{Path, PathBuf}, }; -use tracing::{error, trace, warn}; mod flatten; mod standard_json; @@ -69,7 +68,7 @@ impl VerificationProvider for EtherscanVerificationProvider { return Ok(()) } - trace!(target : "forge::verify", ?verify_args, "submitting verification request"); + trace!(target: "forge::verify", ?verify_args, "submitting verification request"); let retry: Retry = args.retry.into(); let resp = retry.run_async(|| { @@ -81,11 +80,11 @@ impl VerificationProvider for EtherscanVerificationProvider { .wrap_err_with(|| { // valid json let args = serde_json::to_string(&verify_args).unwrap(); - error!(target : "forge::verify", ?args, "Failed to submit verification"); + error!(target: "forge::verify", ?args, "Failed to submit verification"); format!("Failed to submit contract verification, payload:\n{args}") })?; - trace!(target : "forge::verify", ?resp, "Received verification response"); + trace!(target: "forge::verify", ?resp, "Received verification response"); if resp.status == "0" { if resp.result == "Contract source code already verified" { @@ -154,7 +153,7 @@ impl VerificationProvider for EtherscanVerificationProvider { .await .wrap_err("Failed to request verification status")?; - trace!(target : "forge::verify", ?resp, "Received verification response"); + trace!(target: "forge::verify", ?resp, "Received verification response"); eprintln!( "Contract verification status:\nResponse: `{}`\nDetails: `{}`", diff --git a/crates/forge/bin/cmd/verify/etherscan/standard_json.rs b/crates/forge/bin/cmd/verify/etherscan/standard_json.rs index 9fafd717945db..db4854355e9ae 100644 --- a/crates/forge/bin/cmd/verify/etherscan/standard_json.rs +++ b/crates/forge/bin/cmd/verify/etherscan/standard_json.rs @@ -4,7 +4,6 @@ use foundry_block_explorers::verify::CodeFormat; use foundry_compilers::{artifacts::StandardJsonCompilerInput, Project}; use semver::Version; use std::path::Path; -use tracing::trace; #[derive(Debug)] pub struct EtherscanStandardJsonSource; @@ -35,7 +34,7 @@ impl EtherscanSourceProvider for EtherscanStandardJsonSource { let source = serde_json::to_string(&input).wrap_err("Failed to parse standard json input")?; - trace!(target : "forge::verify", standard_json = source, "determined standard json input"); + trace!(target: "forge::verify", standard_json=source, "determined standard json input"); let name = format!( "{}:{}", diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index 02f7bf90504ab..4f85404809020 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -8,7 +8,6 @@ use foundry_utils::Retry; use futures::FutureExt; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; -use tracing::{trace, warn}; pub static SOURCIFY_URL: &str = "https://sourcify.dev/server/"; diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 558a10d5e05b0..9f49640f79063 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -4,7 +4,6 @@ use eyre::Result; use foundry_cli::utils::{self, FoundryPathExt}; use foundry_config::Config; use std::{collections::HashSet, convert::Infallible, path::PathBuf, sync::Arc}; -use tracing::trace; use watchexec::{ action::{Action, Outcome, PreSpawn}, command::Command, @@ -363,20 +362,20 @@ fn on_action( if let Some(status) = completion { match status { Some(ProcessEnd::ExitError(code)) => { - tracing::trace!("Command exited with {code}") + trace!("Command exited with {code}") } Some(ProcessEnd::ExitSignal(sig)) => { - tracing::trace!("Command killed by {:?}", sig) + trace!("Command killed by {:?}", sig) } Some(ProcessEnd::ExitStop(sig)) => { - tracing::trace!("Command stopped by {:?}", sig) + trace!("Command stopped by {:?}", sig) } - Some(ProcessEnd::Continued) => tracing::trace!("Command continued"), + Some(ProcessEnd::Continued) => trace!("Command continued"), Some(ProcessEnd::Exception(ex)) => { - tracing::trace!("Command ended by exception {:#x}", ex) + trace!("Command ended by exception {:#x}", ex) } - Some(ProcessEnd::Success) => tracing::trace!("Command was successful"), - None => tracing::trace!("Command completed"), + Some(ProcessEnd::Success) => trace!("Command was successful"), + None => trace!("Command completed"), }; action.outcome(Outcome::DoNothing); diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 642c51b5dae3a..f2d8e99f8fdcf 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate tracing; + use clap::{CommandFactory, Parser}; use clap_complete::generate; use eyre::Result; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 5cb3302b388fc..6ba28253ccb26 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -191,7 +191,7 @@ impl MultiContractRunner { filter, test_options.clone(), ); - trace!(contract= ?identifier, "executed all tests in contract"); + trace!(contract=?identifier, "executed all tests in contract"); if let Some(stream_result) = stream_result { let _ = stream_result.send((identifier.clone(), result.clone())); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 3e671f2d7e882..7d781098771fc 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -142,16 +142,16 @@ impl<'a> ContractRunner<'a> { .setup(None, address) { Ok(CallResult { traces, labels, logs, coverage, .. }) => { - trace!(contract = ?address, "successfully setUp test"); + trace!(contract=%address, "successfully setUp test"); (logs, traces, labels, None, coverage) } Err(EvmError::Execution(err)) => { let ExecutionErr { traces, labels, logs, reason, .. } = *err; - error!(reason = ?reason, contract = ?address, "setUp failed"); + error!(reason=%reason, contract=%address, "setUp failed"); (logs, traces, labels, Some(format!("setup failed: {reason}")), None) } Err(err) => { - error!(reason=?err, contract= ?address, "setUp failed"); + error!(reason=%err, contract=%address, "setUp failed"); (Vec::new(), None, BTreeMap::new(), Some(format!("setup failed: {err}")), None) } }; @@ -493,7 +493,7 @@ impl<'a> ContractRunner<'a> { ) { Ok(c) => counterexample = c, Err(err) => { - error!(?err, "Failed to replay invariant error") + error!(%err, "Failed to replay invariant error"); } }; } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 3753c4d75fe6d..a19accee103f3 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -765,7 +765,7 @@ forgetest!( "14435000", "--libraries", dss_exec_lib, - "-vvv", + "-vvvvv", ]); cmd.assert_non_empty_stdout(); } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index c8c931508eed0..ec9155391594a 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -34,7 +34,7 @@ contract ContractScript is Script { let rpc = foundry_utils::rpc::next_http_rpc_endpoint(); - cmd.arg("script").arg(script).args(["--fork-url", rpc.as_str(), "-vvvv"]); + cmd.arg("script").arg(script).args(["--fork-url", rpc.as_str(), "-vvvvv"]).assert_success(); } ); @@ -118,7 +118,7 @@ import "forge-std/Script.sol"; contract GasWaster { function wasteGas(uint256 minGas) public { - require(gasleft() >= minGas, "Gas left needs to be higher"); + require(gasleft() >= minGas, "Gas left needs to be higher"); } } contract DeployScript is Script { @@ -171,7 +171,7 @@ import "forge-std/Script.sol"; contract GasWaster { function wasteGas(uint256 minGas) public { - require(gasleft() >= minGas, "Gas left needs to be higher"); + require(gasleft() >= minGas, "Gas left needs to be higher"); } } contract DeployScript is Script { @@ -279,7 +279,7 @@ contract HashChecker { } function checkLastHash() public { - require(lastHash != bytes32(0), "Hash shouldn't be zero"); + require(lastHash != bytes32(0), "Hash shouldn't be zero"); } } contract DeployScript is Script { diff --git a/crates/macros/src/fmt/ui.rs b/crates/macros/src/fmt/ui.rs index d55a6a17c1ce0..f2bec35912139 100644 --- a/crates/macros/src/fmt/ui.rs +++ b/crates/macros/src/fmt/ui.rs @@ -632,7 +632,7 @@ value 0".to_string(); Some("0x0e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331".to_string()), get_pretty_block_attr(&block, "hash") ); - assert_eq!(Some("0x0e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331".to_string()), get_pretty_block_attr(&block, "logsBloom")); + assert_eq!(Some("0x0e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331".to_string()), get_pretty_block_attr(&block, "logsBloom")); assert_eq!( Some("0x0000000000000000000000000000000000000001".to_string()), get_pretty_block_attr(&block, "miner") diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 635522a9ffa0c..fc23b1d72eca3 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -1,6 +1,9 @@ #![doc = include_str!("../README.md")] #![warn(unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + use crate::types::{ToAlloy, ToEthers}; use alloy_primitives::{Address, Bytes}; use ethers_core::types::BlockId; @@ -20,7 +23,6 @@ use std::{ str::FromStr, time::Duration, }; -use tracing::trace; pub mod abi; pub mod error; @@ -81,7 +83,7 @@ struct AllArtifactsBySlug { impl AllArtifactsBySlug { /// Finds the code for the target of the artifact and the matching key. fn find_code(&self, identifier: &String, version: &String) -> Option { - trace!(target : "forge::link", identifier, "fetching artifact by identifier"); + trace!(target: "forge::link", identifier, "fetching artifact by identifier"); let code = self .inner .get(identifier) @@ -211,7 +213,7 @@ pub fn link_with_nonce_or_address( match bytecode.object { BytecodeObject::Unlinked(_) => { - trace!(target : "forge::link", target=id.identifier(), version=?id.version, "unlinked contract"); + trace!(target: "forge::link", target=id.identifier(), version=?id.version, "unlinked contract"); // link needed recurse_link( @@ -295,7 +297,7 @@ fn recurse_link<'a>( ) { // check if we have dependencies if let Some(dependencies) = dependency_tree.get(&target) { - trace!(target : "forge::link", ?target, "linking contract"); + trace!(target: "forge::link", ?target, "linking contract"); // for each dependency, try to link dependencies.dependencies.iter().for_each(|dep| { @@ -303,7 +305,7 @@ fn recurse_link<'a>( let next_target = format!("{file}:{key}"); let root = PathBuf::from(root.as_ref().to_str().unwrap()); // get the dependency - trace!(target : "forge::link", dependency = next_target, file, key, version=?dependencies.artifact_id.version, "get dependency"); + trace!(target: "forge::link", dependency=next_target, file, key, version=?dependencies.artifact_id.version, "get dependency"); let artifact = match artifacts .find_code(&next_target, version) { Some(artifact) => artifact, @@ -315,7 +317,7 @@ fn recurse_link<'a>( let fallback_path = fallback_path.to_str().unwrap_or("No artifact for contract \"{next_target}\". Attempted to compose fallback path but could not create valid string"); let fallback_target = format!("{fallback_path}:{key}"); - trace!(target : "forge::link", fallback_dependency = fallback_target, file, key, version=?dependencies.artifact_id.version, "get dependency with fallback path"); + trace!(target: "forge::link", fallback_dependency=fallback_target, file, key, version=?dependencies.artifact_id.version, "get dependency with fallback path"); match artifacts.find_code(&fallback_target, version) { Some(artifact) => artifact, @@ -334,7 +336,7 @@ fn recurse_link<'a>( // make sure dependency is fully linked if let Some(deps) = dependency_tree.get(&format!("{file}:{key}")) { if !deps.dependencies.is_empty() { - trace!(target : "forge::link", dependency = next_target, file, key, version=?dependencies.artifact_id.version, "dependency has dependencies"); + trace!(target: "forge::link", dependency=next_target, file, key, version=?dependencies.artifact_id.version, "dependency has dependencies"); // actually link the nested dependencies to this dependency recurse_link( @@ -365,12 +367,12 @@ fn recurse_link<'a>( } let address = if let Some(deployed_address) = deployed_address { - trace!(target : "forge::link", dependency = next_target, file, key, "dependency has pre-defined address"); + trace!(target: "forge::link", dependency=next_target, file, key, "dependency has pre-defined address"); // the user specified the library address deployed_address } else if let Some((cached_nonce, deployed_address)) = internally_deployed_libraries.get(&format!("{file}:{key}")) { - trace!(target : "forge::link", dependency = next_target, file, key, "dependency was previously deployed"); + trace!(target: "forge::link", dependency=next_target, file, key, "dependency was previously deployed"); // we previously deployed the library let library = format!("{file}:{key}:0x{deployed_address:x}"); @@ -380,11 +382,11 @@ fn recurse_link<'a>( id: library, address: *deployed_address, nonce: *cached_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!( "Bytecode should be linked for {next_target}")).0.into(), + bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")).0.into(), }); *deployed_address } else { - trace!(target : "forge::link", dependency = next_target, file, key, "dependency has to be deployed"); + trace!(target: "forge::link", dependency=next_target, file, key, "dependency has to be deployed"); // we need to deploy the library let used_nonce = *nonce; @@ -397,7 +399,7 @@ fn recurse_link<'a>( id: library, address: computed_address, nonce: used_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!( "Bytecode should be linked for {next_target}")).0.into(), + bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")).0.into(), }); // remember this library for later @@ -409,7 +411,7 @@ fn recurse_link<'a>( // link the dependency to the target target_bytecode.0.link(file.clone(), key.clone(), address); target_bytecode.1.link(file.clone(), key.clone(), address); - trace!(target : "forge::link", ?target, dependency = next_target, file, key, "linking dependency done"); + trace!(target: "forge::link", ?target, dependency=next_target, file, key, "linking dependency done"); }); } } @@ -461,11 +463,7 @@ impl Retry { fn handle_err(&mut self, err: eyre::Report) { self.retries -= 1; - tracing::warn!( - "erroneous attempt ({} tries remaining): {}", - self.retries, - err.root_cause() - ); + warn!("erroneous attempt ({} tries remaining): {}", self.retries, err.root_cause()); if let Some(delay) = self.delay { std::thread::sleep(Duration::from_secs(delay.into())); } From 6b272b06bfe9c092a13578396cef03e0e3a92fd4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 14 Nov 2023 00:39:02 +0100 Subject: [PATCH 0271/1963] test: minor improvements (#6303) * test: minor improvements * fix: paths --- crates/forge/tests/cli/multi_script.rs | 12 ++--- crates/forge/tests/cli/script.rs | 62 +++++++++++------------ crates/test-utils/src/script.rs | 69 ++++++++++++-------------- 3 files changed, 69 insertions(+), 74 deletions(-) diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index fff670c34dbed..c9b78e381cb16 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -9,10 +9,10 @@ forgetest_async!(can_deploy_multi_chain_script_without_lib, |prj, cmd| { let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); tester - .load_private_keys([0, 1]) + .load_private_keys(&[0, 1]) .await .add_sig("MultiChainBroadcastNoLink", "deploy(string memory,string memory)") - .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) + .args(&[&handle1.http_endpoint(), &handle2.http_endpoint()]) .broadcast(ScriptOutcome::OkBroadcast); assert_eq!( @@ -40,11 +40,11 @@ forgetest_async!(can_not_deploy_multi_chain_script_with_lib, |prj, cmd| { let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); tester - .load_private_keys([0, 1]) + .load_private_keys(&[0, 1]) .await .add_deployer(0) .add_sig("MultiChainBroadcastLink", "deploy(string memory,string memory)") - .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) + .args(&[&handle1.http_endpoint(), &handle2.http_endpoint()]) .broadcast(ScriptOutcome::UnsupportedLibraries); }); @@ -54,10 +54,10 @@ forgetest_async!(can_not_change_fork_during_broadcast, |prj, cmd| { let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); tester - .load_private_keys([0, 1]) + .load_private_keys(&[0, 1]) .await .add_deployer(0) .add_sig("MultiChainBroadcastNoLink", "deployError(string memory,string memory)") - .args(vec![handle1.http_endpoint(), handle2.http_endpoint()]) + .args(&[&handle1.http_endpoint(), &handle2.http_endpoint()]) .broadcast(ScriptOutcome::ErrorSelectForkOnBroadcast); }); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index ec9155391594a..c8bb085c13e43 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -380,12 +380,12 @@ forgetest_async!(can_deploy_script_without_lib, |prj, cmd| { let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0, 1]) + .load_private_keys(&[0, 1]) .await .add_sig("BroadcastTestNoLinking", "deployDoesntPanic()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 1), (1, 2)]) + .assert_nonce_increment(&[(0, 1), (1, 2)]) .await; }); @@ -394,12 +394,12 @@ forgetest_async!(can_deploy_script_with_lib, |prj, cmd| { let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0, 1]) + .load_private_keys(&[0, 1]) .await .add_sig("BroadcastTest", "deploy()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 2), (1, 1)]) + .assert_nonce_increment(&[(0, 2), (1, 1)]) .await; }); @@ -411,14 +411,14 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_addresses(vec![ + .load_addresses(&[ Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() ]) .await .add_sig("BroadcastTest", "deployPrivateKey()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment_addresses(vec![( + .assert_nonce_increment_addresses(&[( Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), 3, )]) @@ -450,14 +450,14 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_addresses(vec![ + .load_addresses(&[ Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() ]) .await .add_sig("BroadcastTest", "deployRememberKey()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment_addresses(vec![( + .assert_nonce_increment_addresses(&[( Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), 2, )]) @@ -474,7 +474,7 @@ forgetest_async!( tester .add_deployer(0) - .load_addresses(vec![ + .load_addresses(&[ Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() ]) .await @@ -482,15 +482,15 @@ forgetest_async!( .simulate(ScriptOutcome::OkSimulation) .resume(ScriptOutcome::MissingWallet) // load missing wallet - .load_private_keys([0]) + .load_private_keys(&[0]) .await .run(ScriptOutcome::OkBroadcast) - .assert_nonce_increment_addresses(vec![( + .assert_nonce_increment_addresses(&[( Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), 1, )]) .await - .assert_nonce_increment([(0, 2)]) + .assert_nonce_increment(&[(0, 2)]) .await; } ); @@ -500,16 +500,16 @@ forgetest_async!(can_resume_script, |prj, cmd| { let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastTest", "deploy()") .simulate(ScriptOutcome::OkSimulation) .resume(ScriptOutcome::MissingWallet) // load missing wallet - .load_private_keys([1]) + .load_private_keys(&[1]) .await .run(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 2), (1, 1)]) + .assert_nonce_increment(&[(0, 2), (1, 1)]) .await; }); @@ -519,12 +519,12 @@ forgetest_async!(can_deploy_broadcast_wrap, |prj, cmd| { tester .add_deployer(2) - .load_private_keys([0, 1, 2]) + .load_private_keys(&[0, 1, 2]) .await .add_sig("BroadcastTest", "deployOther()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 4), (1, 4), (2, 1)]) + .assert_nonce_increment(&[(0, 4), (1, 4), (2, 1)]) .await; }); @@ -533,7 +533,7 @@ forgetest_async!(panic_no_deployer_set, |prj, cmd| { let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0, 1]) + .load_private_keys(&[0, 1]) .await .add_sig("BroadcastTest", "deployOther()") .simulate(ScriptOutcome::WarnSpecifyDeployer) @@ -546,12 +546,12 @@ forgetest_async!(can_deploy_no_arg_broadcast, |prj, cmd| { tester .add_deployer(0) - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastTest", "deployNoArgs()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 3)]) + .assert_nonce_increment(&[(0, 3)]) .await; }); @@ -571,12 +571,12 @@ forgetest_async!(can_deploy_with_create2, |prj, cmd| { tester .add_deployer(0) - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastTestNoLinking", "deployCreate2()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 2)]) + .assert_nonce_increment(&[(0, 2)]) .await // Running again results in error, since we're repeating the salt passed to CREATE2 .run(ScriptOutcome::ScriptFailed); @@ -590,12 +590,12 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastTestNoLinking", "deployMany()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 25)]) + .assert_nonce_increment(&[(0, 25)]) .await; } ); @@ -608,12 +608,12 @@ forgetest_async!( let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastMix", "deployMix()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 15)]) + .assert_nonce_increment(&[(0, 15)]) .await; } ); @@ -623,12 +623,12 @@ forgetest_async!(deploy_with_setup, |prj, cmd| { let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastTestSetup", "run()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 6)]) + .assert_nonce_increment(&[(0, 6)]) .await; }); @@ -637,7 +637,7 @@ forgetest_async!(fail_broadcast_staticcall, |prj, cmd| { let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); tester - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastTestNoLinking", "errorStaticCall()") .simulate(ScriptOutcome::StaticCallNotAllowed); @@ -656,12 +656,12 @@ forgetest_async!( api.anvil_set_code(addr.to_ethers(), code).await.unwrap(); tester - .load_private_keys([0]) + .load_private_keys(&[0]) .await .add_sig("BroadcastTestSetup", "run()") .simulate(ScriptOutcome::OkSimulation) .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment([(0, 6)]) + .assert_nonce_increment(&[(0, 6)]) .await; // Uncomment to recreate the broadcast log diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 6a848b744419c..81af31de5e95f 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -5,9 +5,10 @@ use ethers_providers::Middleware; use eyre::Result; use foundry_common::{get_http_provider, RetryProvider}; use foundry_utils::types::{ToAlloy, ToEthers}; -use std::{collections::BTreeMap, path::Path, str::FromStr}; +use std::{collections::BTreeMap, fs, path::Path, str::FromStr}; const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; +const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); /// A helper struct to test forge script scenarios pub struct ScriptTester { @@ -71,9 +72,11 @@ impl ScriptTester { let target_contract = project_root.join(BROADCAST_TEST_PATH).to_string_lossy().to_string(); // copy the broadcast test - let testdata = Self::testdata_path(); - std::fs::copy(testdata + "/cheats/Broadcast.t.sol", project_root.join(BROADCAST_TEST_PATH)) - .expect("Failed to initialize broadcast contract"); + fs::copy( + Self::testdata_path().join("cheats/Broadcast.t.sol"), + project_root.join(BROADCAST_TEST_PATH), + ) + .expect("Failed to initialize broadcast contract"); Self::new(cmd, Some(endpoint), project_root, &target_contract) } @@ -85,31 +88,27 @@ impl ScriptTester { // copy the broadcast test let testdata = Self::testdata_path(); - std::fs::copy(testdata + "/cheats/Broadcast.t.sol", project_root.join(BROADCAST_TEST_PATH)) + fs::copy(testdata.join("cheats/Broadcast.t.sol"), project_root.join(BROADCAST_TEST_PATH)) .expect("Failed to initialize broadcast contract"); Self::new(cmd, None, project_root, &target_contract) } /// Returns the path to the dir that contains testdata - fn testdata_path() -> String { - concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata").into() + fn testdata_path() -> &'static Path { + Path::new(TESTDATA) } /// Initialises the test contracts by copying them into the workspace fn copy_testdata(current_dir: &Path) -> Result<()> { let testdata = Self::testdata_path(); - std::fs::copy(testdata.clone() + "/cheats/Vm.sol", current_dir.join("src/Vm.sol"))?; - std::fs::copy(testdata + "/lib/ds-test/src/test.sol", current_dir.join("lib/test.sol"))?; - + fs::copy(testdata.join("cheats/Vm.sol"), current_dir.join("src/Vm.sol"))?; + fs::copy(testdata.join("lib/ds-test/src/test.sol"), current_dir.join("lib/test.sol"))?; Ok(()) } - pub async fn load_private_keys( - &mut self, - keys_indexes: impl IntoIterator, - ) -> &mut Self { - for index in keys_indexes { + pub async fn load_private_keys(&mut self, keys_indexes: &[u32]) -> &mut Self { + for &index in keys_indexes { self.cmd.args(["--private-keys", &self.accounts_priv[index as usize]]); if let Some(provider) = &self.provider { @@ -126,8 +125,8 @@ impl ScriptTester { self } - pub async fn load_addresses(&mut self, addresses: Vec
) -> &mut Self { - for address in addresses { + pub async fn load_addresses(&mut self, addresses: &[Address]) -> &mut Self { + for &address in addresses { let nonce = self .provider .as_ref() @@ -146,19 +145,16 @@ impl ScriptTester { /// Adds given address as sender pub fn sender(&mut self, addr: Address) -> &mut Self { - self.cmd.args(["--sender", addr.to_string().as_str()]); - self + self.args(&["--sender", addr.to_string().as_str()]) } pub fn add_sig(&mut self, contract_name: &str, sig: &str) -> &mut Self { - self.cmd.args(["--tc", contract_name, "--sig", sig]); - self + self.args(&["--tc", contract_name, "--sig", sig]) } /// Adds the `--unlocked` flag pub fn unlocked(&mut self) -> &mut Self { - self.cmd.arg("--unlocked"); - self + self.arg("--unlocked") } pub fn simulate(&mut self, expected: ScriptOutcome) -> &mut Self { @@ -166,21 +162,16 @@ impl ScriptTester { } pub fn broadcast(&mut self, expected: ScriptOutcome) -> &mut Self { - self.cmd.arg("--broadcast"); - self.run(expected) + self.arg("--broadcast").run(expected) } pub fn resume(&mut self, expected: ScriptOutcome) -> &mut Self { - self.cmd.arg("--resume"); - self.run(expected) + self.arg("--resume").run(expected) } /// `[(private_key_slot, expected increment)]` - pub async fn assert_nonce_increment( - &mut self, - keys_indexes: impl IntoIterator, - ) -> &mut Self { - for (private_key_slot, expected_increment) in keys_indexes { + pub async fn assert_nonce_increment(&mut self, keys_indexes: &[(u32, u32)]) -> &mut Self { + for &(private_key_slot, expected_increment) in keys_indexes { let addr = self.accounts_pub[private_key_slot as usize]; let nonce = self .provider @@ -204,7 +195,7 @@ impl ScriptTester { /// In Vec<(address, expected increment)> pub async fn assert_nonce_increment_addresses( &mut self, - address_indexes: Vec<(Address, u32)>, + address_indexes: &[(Address, u32)], ) -> &mut Self { for (address, expected_increment) in address_indexes { let nonce = self @@ -214,9 +205,9 @@ impl ScriptTester { .get_transaction_count(NameOrAddress::Address(address.to_ethers()), None) .await .unwrap(); - let prev_nonce = self.address_nonces.get(&address).unwrap(); + let prev_nonce = self.address_nonces.get(address).unwrap(); - assert_eq!(nonce, (prev_nonce + U256::from(expected_increment)).to_ethers()); + assert_eq!(nonce, (prev_nonce + U256::from(*expected_increment)).to_ethers()); } self } @@ -238,11 +229,15 @@ impl ScriptTester { } pub fn slow(&mut self) -> &mut Self { - self.cmd.arg("--slow"); + self.arg("--slow") + } + + pub fn arg(&mut self, arg: &str) -> &mut Self { + self.cmd.arg(arg); self } - pub fn args(&mut self, args: Vec) -> &mut Self { + pub fn args(&mut self, args: &[&str]) -> &mut Self { self.cmd.args(args); self } From 1a2e2e071ef0a1b6f41fdcba773b04c30498752f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 14 Nov 2023 00:51:02 +0100 Subject: [PATCH 0272/1963] fix: remove serde "helper" Numeric (#6304) * fix: remove serde "helper" Numeric * add test --- crates/cast/bin/opts.rs | 4 +- crates/cast/tests/cli/main.rs | 59 ++++++++++++++++++++---------- crates/common/src/lib.rs | 1 - crates/common/src/serde_helpers.rs | 38 ------------------- 4 files changed, 40 insertions(+), 62 deletions(-) delete mode 100644 crates/common/src/serde_helpers.rs diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index fa649b715dec1..b763821fa06da 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -8,7 +8,6 @@ use clap::{Parser, Subcommand, ValueHint}; use ethers_core::types::{BlockId, NameOrAddress}; use eyre::Result; use foundry_cli::opts::{EtherscanOpts, RpcOpts}; -use foundry_common::serde_helpers::Numeric; use std::{path::PathBuf, str::FromStr}; const VERSION_MESSAGE: &str = concat!( @@ -874,8 +873,7 @@ pub struct ToBaseArgs { } pub fn parse_slot(s: &str) -> Result { - let slot = Numeric::from_str(s).map_err(|e| eyre::eyre!("Could not parse slot number: {e}"))?; - let slot: U256 = slot.into(); + let slot = U256::from_str(s).map_err(|e| eyre::eyre!("Could not parse slot number: {e}"))?; Ok(B256::from(slot)) } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 238e5d76747b5..5801b7d43ffab 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -72,7 +72,7 @@ casttest!(wallet_address_keystore_with_password_file, |_prj, cmd| { }); // tests that `cast wallet sign message` outputs the expected signature -casttest!(cast_wallet_sign_message_utf8_data, |_prj, cmd| { +casttest!(wallet_sign_message_utf8_data, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -85,7 +85,7 @@ casttest!(cast_wallet_sign_message_utf8_data, |_prj, cmd| { }); // tests that `cast wallet sign message` outputs the expected signature, given a 0x-prefixed data -casttest!(cast_wallet_sign_message_hex_data, |_prj, cmd| { +casttest!(wallet_sign_message_hex_data, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -98,7 +98,7 @@ casttest!(cast_wallet_sign_message_hex_data, |_prj, cmd| { }); // tests that `cast wallet sign typed-data` outputs the expected signature, given a JSON string -casttest!(cast_wallet_sign_typed_data_string, |_prj, cmd| { +casttest!(wallet_sign_typed_data_string, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -112,7 +112,7 @@ casttest!(cast_wallet_sign_typed_data_string, |_prj, cmd| { }); // tests that `cast wallet sign typed-data` outputs the expected signature, given a JSON file -casttest!(cast_wallet_sign_typed_data_file, |_prj, cmd| { +casttest!(wallet_sign_typed_data_file, |_prj, cmd| { cmd.args([ "wallet", "sign", @@ -219,7 +219,7 @@ casttest!(upload_signatures, |_prj, cmd| { }); // tests that the `cast to-rlp` and `cast from-rlp` commands work correctly -casttest!(cast_rlp, |_prj, cmd| { +casttest!(rlp, |_prj, cmd| { cmd.args(["--to-rlp", "[\"0xaa\", [[\"bb\"]], \"0xcc\"]"]); let out = cmd.stdout_lossy(); assert!(out.contains("0xc881aac3c281bb81cc"), "{}", out); @@ -231,7 +231,7 @@ casttest!(cast_rlp, |_prj, cmd| { }); // test for cast_rpc without arguments -casttest!(cast_rpc_no_args, |_prj, cmd| { +casttest!(rpc_no_args, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_chainId` @@ -241,7 +241,7 @@ casttest!(cast_rpc_no_args, |_prj, cmd| { }); // test for cast_rpc without arguments using websocket -casttest!(cast_ws_rpc_no_args, |_prj, cmd| { +casttest!(ws_rpc_no_args, |_prj, cmd| { let eth_rpc_url = next_ws_rpc_endpoint(); // Call `cast rpc eth_chainId` @@ -251,7 +251,7 @@ casttest!(cast_ws_rpc_no_args, |_prj, cmd| { }); // test for cast_rpc with arguments -casttest!(cast_rpc_with_args, |_prj, cmd| { +casttest!(rpc_with_args, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_getBlockByNumber 0x123 false` @@ -261,7 +261,7 @@ casttest!(cast_rpc_with_args, |_prj, cmd| { }); // test for cast_rpc with raw params -casttest!(cast_rpc_raw_params, |_prj, cmd| { +casttest!(rpc_raw_params, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_getBlockByNumber --raw '["0x123", false]'` @@ -278,7 +278,7 @@ casttest!(cast_rpc_raw_params, |_prj, cmd| { }); // test for cast_rpc with direct params -casttest!(cast_rpc_raw_params_stdin, |_prj, cmd| { +casttest!(rpc_raw_params_stdin, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `echo "\n[\n\"0x123\",\nfalse\n]\n" | cast rpc eth_getBlockByNumber --raw @@ -300,7 +300,7 @@ casttest!(calldata_array, |_prj, cmd| { }); // -casttest!(cast_run_succeeds, |_prj, cmd| { +casttest!(run_succeeds, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "run", @@ -316,7 +316,7 @@ casttest!(cast_run_succeeds, |_prj, cmd| { }); // tests that `cast --to-base` commands are working correctly. -casttest!(cast_to_base, |_prj, cmd| { +casttest!(to_base, |_prj, cmd| { let values = [ "1", "100", @@ -344,7 +344,7 @@ casttest!(cast_to_base, |_prj, cmd| { }); // tests that revert reason is only present if transaction has reverted. -casttest!(cast_receipt_revert_reason, |_prj, cmd| { +casttest!(receipt_revert_reason, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); // @@ -379,7 +379,7 @@ casttest!(parse_bytes32_address, |_prj, cmd| { assert_eq!(output.trim(), "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045") }); -casttest!(cast_access_list, |_prj, cmd| { +casttest!(access_list, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "access-list", @@ -398,7 +398,7 @@ casttest!(cast_access_list, |_prj, cmd| { assert!(output.contains("0x7fba2702a7d6e85ac783a88eacdc48e51310443458071f6db9ac66f8ca7068b8")); }); -casttest!(cast_logs_topics, |_prj, cmd| { +casttest!(logs_topics, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -417,7 +417,7 @@ casttest!(cast_logs_topics, |_prj, cmd| { ); }); -casttest!(cast_logs_topic_2, |_prj, cmd| { +casttest!(logs_topic_2, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -438,7 +438,7 @@ casttest!(cast_logs_topic_2, |_prj, cmd| { ); }); -casttest!(cast_logs_sig, |_prj, cmd| { +casttest!(logs_sig, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -457,7 +457,7 @@ casttest!(cast_logs_sig, |_prj, cmd| { ); }); -casttest!(cast_logs_sig_2, |_prj, cmd| { +casttest!(logs_sig_2, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); cmd.args([ "logs", @@ -478,7 +478,7 @@ casttest!(cast_logs_sig_2, |_prj, cmd| { }); // tests that the raw encoded transaction is returned -casttest!(cast_tx_raw, |_prj, cmd| { +casttest!(tx_raw, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); // @@ -509,7 +509,7 @@ casttest!(cast_tx_raw, |_prj, cmd| { }); // ensure receipt or code is required -casttest!(cast_send_requires_to, |_prj, cmd| { +casttest!(send_requires_to, |_prj, cmd| { cmd.args([ "send", "--private-key", @@ -521,3 +521,22 @@ casttest!(cast_send_requires_to, |_prj, cmd| { "Error: \nMust specify a recipient address or contract code to deploy" ); }); + +casttest!(storage, |_prj, cmd| { + let empty = "0x0000000000000000000000000000000000000000000000000000000000000000"; + + let rpc = next_http_rpc_endpoint(); + cmd.cast_fuse().args(["storage", "vitalik.eth", "1", "--rpc-url", &rpc]); + assert_eq!(cmd.stdout_lossy().trim(), empty); + + let rpc = next_http_rpc_endpoint(); + cmd.cast_fuse().args(["storage", "vitalik.eth", "0x01", "--rpc-url", &rpc]); + assert_eq!(cmd.stdout_lossy().trim(), empty); + + let rpc = next_http_rpc_endpoint(); + let usdt = "0xdac17f958d2ee523a2206206994597c13d831ec7"; + let decimals_slot = "0x09"; + let six = "0x0000000000000000000000000000000000000000000000000000000000000006"; + cmd.cast_fuse().args(["storage", usdt, decimals_slot, "--rpc-url", &rpc]); + assert_eq!(cmd.stdout_lossy().trim(), six); +}); diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 241041ee8160e..584a3638981d5 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -19,7 +19,6 @@ pub mod glob; pub mod provider; pub mod runtime_client; pub mod selectors; -pub mod serde_helpers; pub mod shell; pub mod term; pub mod traits; diff --git a/crates/common/src/serde_helpers.rs b/crates/common/src/serde_helpers.rs deleted file mode 100644 index 8d8788561f6aa..0000000000000 --- a/crates/common/src/serde_helpers.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! Misc Serde helpers for foundry crates. - -use alloy_primitives::U256; -use serde::Deserialize; -use std::str::FromStr; - -/// Helper type to parse both `u64` and `U256` -#[derive(Copy, Clone, Deserialize)] -#[serde(untagged)] -pub enum Numeric { - /// A [U256] value. - U256(U256), - /// A `u64` value. - Num(u64), -} - -impl From for U256 { - fn from(n: Numeric) -> U256 { - match n { - Numeric::U256(n) => n, - Numeric::Num(n) => U256::from(n), - } - } -} - -impl FromStr for Numeric { - type Err = String; - - fn from_str(s: &str) -> Result { - if let Ok(val) = s.parse::() { - Ok(Numeric::U256(U256::from(val))) - } else if s.starts_with("0x") { - U256::from_str_radix(s, 16).map(Numeric::U256).map_err(|err| err.to_string()) - } else { - U256::from_str(s).map(Numeric::U256).map_err(|err| err.to_string()) - } - } -} From 8126b99c08b060604ea30b2ee9efcf1620aa228e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 14 Nov 2023 02:21:35 +0100 Subject: [PATCH 0273/1963] test: compile testdata/ only once (#6305) * test: compile testdata/ only once * comment --- crates/forge/tests/cli/test_cmd.rs | 5 +---- crates/forge/tests/it/config.rs | 8 ++++---- crates/forge/tests/it/test_helpers.rs | 28 +++++++++++++++++++++++++-- crates/test-utils/src/fd_lock.rs | 21 ++++++++++++++++++++ crates/test-utils/src/lib.rs | 3 ++- crates/test-utils/src/util.rs | 17 +++------------- testdata/.gitignore | 3 ++- 7 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 crates/test-utils/src/fd_lock.rs diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 19cb7355c10b6..cb2cfd121e037 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,6 +1,6 @@ //! Contains various tests for checking `forge test` use foundry_config::Config; -use foundry_test_utils::util::{template_lock, OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}; +use foundry_test_utils::util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}; use foundry_utils::rpc; use std::{path::PathBuf, process::Command, str::FromStr}; @@ -265,8 +265,6 @@ forgetest_init!( #[serial_test::serial] can_test_forge_std, |prj, cmd| { - let mut lock = template_lock(); - let write = lock.write().unwrap(); let forge_std_dir = prj.root().join("lib/forge-std"); let status = Command::new("git") .current_dir(&forge_std_dir) @@ -276,7 +274,6 @@ forgetest_init!( if !status.success() { panic!("failed to update forge-std"); } - drop(write); // execute in subdir cmd.cmd().current_dir(forge_std_dir); diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 8278210bcc1c0..95d03110fff91 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -31,15 +31,15 @@ impl TestConfig { Self::with_filter(runner, Filter::matches_all()) } + pub async fn filter(filter: Filter) -> Self { + Self::with_filter(runner().await, filter) + } + pub fn with_filter(runner: MultiContractRunner, filter: Filter) -> Self { init_tracing(); Self { runner, should_fail: false, filter, opts: test_opts() } } - pub async fn filter(filter: Filter) -> Self { - Self::with_filter(runner().await, filter) - } - pub fn evm_spec(mut self, spec: SpecId) -> Self { self.runner.evm_spec = spec; self diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index c280fcd996330..cfbbc015162f6 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -10,12 +10,13 @@ use foundry_evm::{ opts::{Env, EvmOpts}, revm::db::DatabaseRef, }; +use foundry_test_utils::fd_lock; use once_cell::sync::Lazy; +use std::{env, io::Write}; pub const RE_PATH_SEPARATOR: &str = "/"; const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); -// const TESTDATA_LOCK: Lazy = Lazy::new(|| {}); pub static PROJECT: Lazy = Lazy::new(|| { let paths = ProjectPathsConfig::builder().root(TESTDATA).sources(TESTDATA).build().unwrap(); @@ -29,7 +30,30 @@ pub static PROJECT: Lazy = Lazy::new(|| { }); pub static COMPILED: Lazy = Lazy::new(|| { - let out = PROJECT.compile().unwrap(); + const LOCK: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata/.lock"); + + let project = &*PROJECT; + assert!(project.cached); + + // Compile only once per test run. + // We need to use a file lock because `cargo-nextest` runs tests in different processes. + // This is similar to [`foundry_test_utils::util::initialize`], see its comments for more + // details. + let mut lock = fd_lock::new_lock(LOCK); + let read = lock.read().unwrap(); + let out; + if project.cache_path().exists() && std::fs::read(LOCK).unwrap() == b"1" { + out = project.compile(); + drop(read); + } else { + drop(read); + let mut write = lock.write().unwrap(); + write.write_all(b"1").unwrap(); + out = project.compile(); + drop(write); + }; + + let out = out.unwrap(); if out.has_compiler_errors() { panic!("Compiled with errors:\n{out}"); } diff --git a/crates/test-utils/src/fd_lock.rs b/crates/test-utils/src/fd_lock.rs new file mode 100644 index 0000000000000..222ac3cfbd88a --- /dev/null +++ b/crates/test-utils/src/fd_lock.rs @@ -0,0 +1,21 @@ +//! File locking utilities. + +use crate::util::pretty_err; +use std::{ + fs::{File, OpenOptions}, + path::Path, +}; + +pub use fd_lock::*; + +/// Creates a new lock file at the given path. +pub fn new_lock(lock_path: impl AsRef) -> RwLock { + fn new_lock(lock_path: &Path) -> RwLock { + let lock_file = pretty_err( + lock_path, + OpenOptions::new().read(true).write(true).create(true).open(lock_path), + ); + RwLock::new(lock_file) + } + new_lock(lock_path.as_ref()) +} diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index dc1f0986d7dc6..042ff4aba1cb1 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -6,6 +6,8 @@ extern crate tracing; // Macros useful for testing. mod macros; +pub mod fd_lock; + mod filter; pub use filter::Filter; @@ -17,7 +19,6 @@ mod script; pub use script::{ScriptOutcome, ScriptTester}; // re-exports for convenience -pub use fd_lock; pub use foundry_compilers; /// Initializes tracing for tests. diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 1d0493497667e..10a6db9fdddb0 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1,6 +1,5 @@ use crate::init_tracing; use eyre::{Result, WrapErr}; -use fd_lock::RwLock; use foundry_compilers::{ cache::SolFilesCache, error::Result as SolcResult, @@ -51,16 +50,6 @@ pub const SOLC_VERSION: &str = "0.8.23"; /// versions. pub const OTHER_SOLC_VERSION: &str = "0.8.22"; -/// Creates a file lock to the global template dir. -pub fn template_lock() -> RwLock { - let lock_path = &*TEMPLATE_LOCK; - let lock_file = pretty_err( - lock_path, - fs::OpenOptions::new().read(true).write(true).create(true).open(lock_path), - ); - RwLock::new(lock_file) -} - /// Initializes a project with `forge init` at the given path. /// /// This should be called after an empty project is created like in @@ -81,9 +70,9 @@ pub fn initialize(target: &Path) { pretty_err(tpath, fs::create_dir_all(tpath)); // Initialize the global template if necessary. - let mut lock = template_lock(); + let mut lock = crate::fd_lock::new_lock(TEMPLATE_LOCK.as_path()); let mut _read = Some(lock.read().unwrap()); - if fs::read_to_string(&*TEMPLATE_LOCK).unwrap() != "1" { + if fs::read(&*TEMPLATE_LOCK).unwrap() != b"1" { // We are the first to acquire the lock: // - initialize a new empty temp project; // - run `forge init`; @@ -571,7 +560,7 @@ fn config_paths_exist(paths: &ProjectPathsConfig, cached: bool) { pub fn pretty_err(path: impl AsRef, res: Result) -> T { match res { Ok(t) => t, - Err(err) => panic!("{}: {err:?}", path.as_ref().display()), + Err(err) => panic!("{}: {err}", path.as_ref().display()), } } diff --git a/testdata/.gitignore b/testdata/.gitignore index 1da64773e66dc..b84c736371bab 100644 --- a/testdata/.gitignore +++ b/testdata/.gitignore @@ -1,3 +1,4 @@ # Compiler files cache/ -out/ \ No newline at end of file +out/ +.lock From d5224991e207bcfcd2b0bb0883de0d8df08eb304 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 14 Nov 2023 12:29:35 +0100 Subject: [PATCH 0274/1963] chore(meta): add CODEOWNERS (#6301) --- .github/CODEOWNERS | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000000..99659760a2b6a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,6 @@ +* @danipopes @evalir @mattsse + +crates/anvil/ @evalir @mattsse +crates/evm/coverage/ @evalir @onbjerg +crates/fmt/ @rkrasiuk +crates/macros/impls/ @danipopes From c8954d8f1cb7875197570f174107adbed22e019c Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Tue, 14 Nov 2023 04:19:17 -0800 Subject: [PATCH 0275/1963] feat(`cheatcodes`): add computeCreateAddress cheatcodes (#6296) * Add computeCreateAddress cheatcodes * use Address methods * ensure nonce can be u64 --- crates/cheatcodes/assets/cheatcodes.json | 60 ++++++++++++++++++++++++ crates/cheatcodes/defs/src/vm.rs | 12 +++++ crates/cheatcodes/src/utils.rs | 23 +++++++++ testdata/cheats/Vm.sol | 3 ++ 4 files changed, 98 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index b680e876d01d1..4678cfa1a72cc 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -525,6 +525,66 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "computeCreate2Address_0", + "description": "Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.", + "declaration": "function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address);", + "visibility": "external", + "mutability": "pure", + "signature": "computeCreate2Address(bytes32,bytes32,address)", + "selector": "0xd323826a", + "selectorBytes": [ + 211, + 35, + 130, + 106 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "computeCreate2Address_1", + "description": "Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.", + "declaration": "function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);", + "visibility": "external", + "mutability": "pure", + "signature": "computeCreate2Address(bytes32,bytes32)", + "selector": "0x890c283b", + "selectorBytes": [ + 137, + 12, + 40, + 59 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "computeCreateAddress", + "description": "Compute the address a contract will be deployed at for a given deployer address and nonce.", + "declaration": "function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);", + "visibility": "external", + "mutability": "pure", + "signature": "computeCreateAddress(address,uint256)", + "selector": "0x74637a7a", + "selectorBytes": [ + 116, + 99, + 122, + 122 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "cool", diff --git a/crates/cheatcodes/defs/src/vm.rs b/crates/cheatcodes/defs/src/vm.rs index 946de24c24707..dd9a33a2b28e1 100644 --- a/crates/cheatcodes/defs/src/vm.rs +++ b/crates/cheatcodes/defs/src/vm.rs @@ -1155,5 +1155,17 @@ interface Vm { /// Gets the label for the specified address. #[cheatcode(group = Utilities)] function getLabel(address account) external returns (string memory currentLabel); + + /// Compute the address a contract will be deployed at for a given deployer address and nonce. + #[cheatcode(group = Utilities)] + function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address); + + /// Compute the address of a contract created with CREATE2 using the given CREATE2 deployer. + #[cheatcode(group = Utilities)] + function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address); + + /// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer. + #[cheatcode(group = Utilities)] + function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address); } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index c40f4cac7104b..020d465cc3fe9 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -15,6 +15,7 @@ use ethers_signers::{ }, LocalWallet, MnemonicBuilder, Signer, }; +use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; use foundry_utils::types::{ToAlloy, ToEthers}; /// The BIP32 default derivation path prefix. @@ -111,6 +112,28 @@ impl Cheatcode for getLabelCall { } } +impl Cheatcode for computeCreateAddressCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { nonce, deployer } = self; + ensure!(*nonce <= U256::from(u64::MAX), "nonce must be less than 2^64 - 1"); + Ok(deployer.create(nonce.to()).abi_encode()) + } +} + +impl Cheatcode for computeCreate2Address_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { salt, initCodeHash, deployer } = self; + Ok(deployer.create2(salt, initCodeHash).abi_encode()) + } +} + +impl Cheatcode for computeCreate2Address_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { salt, initCodeHash } = self; + Ok(DEFAULT_CREATE2_DEPLOYER.create2(salt, initCodeHash).abi_encode()) + } +} + /// Using a given private key, return its public ETH address, its public key affine x and y /// coodinates, and its private key (see the 'Wallet' struct) /// diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 42d3fa63d30f9..0d718ccd967fe 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -28,6 +28,9 @@ interface Vm { function clearMockedCalls() 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) external pure returns (address); + function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address); function cool(address target) external; function copyFile(string calldata from, string calldata to) external returns (uint64 copied); function createDir(string calldata path, bool recursive) external; From 3ebeded4308b28533bd7b7036b593a92390faf67 Mon Sep 17 00:00:00 2001 From: Bakuchi <49754494+massun-onibakuchi@users.noreply.github.com> Date: Wed, 15 Nov 2023 01:22:00 +0900 Subject: [PATCH 0276/1963] fix(cast): upload error signature (#6312) * test(common): Add custom error test * fix(common): import error sigs in SelectorImportData * rustfmt --------- Co-authored-by: Matthias Seitz --- crates/cast/tests/cli/main.rs | 16 ++++++++++++++++ crates/common/src/selectors.rs | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 5801b7d43ffab..8374d393d068c 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -184,6 +184,16 @@ casttest!(upload_signatures, |_prj, cmd| { assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); + // test error prefix + cmd.args(["upload-signature", "error ERC20InsufficientBalance(address,uint256,uint256)"]); + let output = cmd.stdout_lossy(); + + assert!( + output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), + "{}", + output + ); // Custom error is interpreted as function + // test multiple sigs cmd.args([ "upload-signature", @@ -202,6 +212,7 @@ casttest!(upload_signatures, |_prj, cmd| { "upload-signature", "event Transfer(address,uint256)", "transfer(address,uint256)", + "error ERC20InsufficientBalance(address,uint256,uint256)", Path::new(env!("CARGO_MANIFEST_DIR")) .join("tests/fixtures/ERC20Artifact.json") .into_os_string() @@ -216,6 +227,11 @@ casttest!(upload_signatures, |_prj, cmd| { assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); assert!(output.contains("Function decimals(): 0x313ce567"), "{}", output); assert!(output.contains("Function allowance(address,address): 0xdd62ed3e"), "{}", output); + assert!( + output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), + "{}", + output + ); }); // tests that the `cast to-rlp` and `cast from-rlp` commands work correctly diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index de886a385c180..da4884deb1b81 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -316,7 +316,9 @@ impl SignEthClient { SelectorImportRequest { function: functions_and_errors, event: events } } SelectorImportData::Raw(raw) => { - SelectorImportRequest { function: raw.function, event: raw.event } + let function_and_error = + raw.function.iter().chain(raw.error.iter()).cloned().collect::>(); + SelectorImportRequest { function: function_and_error, event: raw.event } } }; @@ -636,6 +638,7 @@ mod tests { let result = parse_signatures(vec![ "transfer(address,uint256)".to_string(), "event Approval(address,address,uint256)".to_string(), + "error ERC20InsufficientBalance(address,uint256,uint256)".to_string(), ]); assert_eq!( result, @@ -643,7 +646,7 @@ mod tests { signatures: RawSelectorImportData { function: vec!["transfer(address,uint256)".to_string()], event: vec!["Approval(address,address,uint256)".to_string()], - ..Default::default() + error: vec!["ERC20InsufficientBalance(address,uint256,uint256)".to_string()] }, ..Default::default() } From 106889cd5fd98b2672900ff312dc6fdad14053d5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 14 Nov 2023 21:21:13 +0100 Subject: [PATCH 0277/1963] chore: enable anvil-core serde feature by default in tests (#6313) --- Cargo.lock | 1 + crates/anvil/core/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37f6c9165aff3..a0858fe08d58b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,6 +327,7 @@ name = "anvil-core" version = "0.2.0" dependencies = [ "alloy-primitives", + "anvil-core", "bytes", "ethers-core", "foundry-evm", diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 59b54b81f663f..a3fa303a81802 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -30,10 +30,10 @@ reference-trie = { version = "0.25" } keccak-hasher = { version = "0.15" } [dev-dependencies] -serde.workspace = true +anvil-core = { path = ".", features = ["serde"] } [features] -default = [] +default = ["serde"] impersonated-tx = [] fastrlp = ["dep:open-fastrlp"] serde = ["dep:serde"] From 64b0e8fcf6db9f9482e34aacafc180ee2801c6b5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 15 Nov 2023 13:33:39 +0100 Subject: [PATCH 0278/1963] docs: update cups link (#6317) --- crates/anvil/src/cmd.rs | 4 ++-- crates/anvil/src/config.rs | 4 ++-- crates/cast/bin/cmd/run.rs | 4 ++-- crates/common/src/evm.rs | 4 ++-- crates/common/src/provider.rs | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 7d695ae0fc3b7..b6dbfbc8c2653 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -422,7 +422,7 @@ pub struct AnvilEvmArgs { /// default value: 330 /// /// See --fork-url. - /// See also, https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups + /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[clap( long, requires = "fork_url", @@ -437,7 +437,7 @@ pub struct AnvilEvmArgs { /// default value: false /// /// See --fork-url. - /// See also, https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups + /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[clap( long, requires = "fork_url", diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 4a38e291f5f8f..9809869703010 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -398,7 +398,7 @@ impl Default for NodeConfig { fork_request_retries: 5, fork_retry_backoff: Duration::from_millis(1_000), fork_chain_id: None, - // alchemy max cpus + // alchemy max cpus compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, ipc_path: None, code_size_limit: None, @@ -698,7 +698,7 @@ impl NodeConfig { /// Sets the number of assumed available compute units per second /// - /// See also, + /// See also, #[must_use] pub fn fork_compute_units_per_second(mut self, compute_units_per_second: Option) -> Self { if let Some(compute_units_per_second) = compute_units_per_second { diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 5d93f0917bb11..a715b20faa6a6 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -60,7 +60,7 @@ pub struct RunArgs { /// /// default value: 330 /// - /// See also, https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups + /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[clap(long, alias = "cups", value_name = "CUPS")] pub compute_units_per_second: Option, @@ -68,7 +68,7 @@ pub struct RunArgs { /// /// default value: false /// - /// See also, https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups + /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[clap(long, value_name = "NO_RATE_LIMITS", visible_alias = "no-rpc-rate-limit")] pub no_rate_limit: bool, } diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index bf2ba019fe315..74ab6a2ddc7cb 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -112,7 +112,7 @@ pub struct EvmArgs { /// /// default value: 330 /// - /// See also --fork-url and https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups + /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[clap( long, requires = "fork_url", @@ -124,7 +124,7 @@ pub struct EvmArgs { /// Disables rate limiting for this node's provider. /// - /// See also --fork-url and https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups + /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[clap( long, requires = "fork_url", diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index 9a380a353c1ea..e4cc8bbd695b4 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -106,7 +106,7 @@ impl ProviderBuilder { timeout_retry: 8, initial_backoff: 800, timeout: REQUEST_TIMEOUT, - // alchemy max cpus + // alchemy max cpus compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, jwt: None, headers: vec![], @@ -163,7 +163,7 @@ impl ProviderBuilder { /// Sets the number of assumed available compute units per second /// - /// See also, + /// See also, pub fn compute_units_per_second(mut self, compute_units_per_second: u64) -> Self { self.compute_units_per_second = compute_units_per_second; self @@ -171,7 +171,7 @@ impl ProviderBuilder { /// Sets the number of assumed available compute units per second /// - /// See also, + /// See also, pub fn compute_units_per_second_opt(mut self, compute_units_per_second: Option) -> Self { if let Some(cups) = compute_units_per_second { self.compute_units_per_second = cups; From c9538c0fe31bedd40cffb79691a7ad1fb2f4bfc3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:24:21 +0100 Subject: [PATCH 0279/1963] chore: replace ethers `Chain` with `alloy_chains` (#6318) * chore: replace ethers `Chain` with `alloy_chains` * chore: clippy * try patch * fix: `chain_id` field extraction * readd polygon gas estimator --- Cargo.lock | 93 +++++------ Cargo.toml | 3 +- crates/cast/bin/cmd/access_list.rs | 2 +- crates/cast/bin/cmd/bind.rs | 3 +- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/interface.rs | 3 +- crates/cast/bin/cmd/logs.rs | 5 +- crates/cast/bin/cmd/send.rs | 4 +- crates/cast/bin/cmd/storage.rs | 4 +- crates/cast/bin/cmd/wallet/mod.rs | 3 +- crates/cast/bin/main.rs | 3 +- crates/cast/src/lib.rs | 59 ++++--- crates/cast/src/tx.rs | 21 +-- crates/cheatcodes/src/evm.rs | 2 +- crates/cli/src/opts/chain.rs | 4 +- crates/cli/src/opts/ethereum.rs | 4 +- crates/cli/src/utils/cmd.rs | 10 +- crates/cli/src/utils/mod.rs | 4 +- crates/common/src/abi.rs | 4 +- crates/common/src/evm.rs | 40 ++++- crates/common/src/provider.rs | 8 +- crates/config/Cargo.toml | 5 +- crates/config/src/cache.rs | 9 +- crates/config/src/chain.rs | 157 ------------------ crates/config/src/etherscan.rs | 10 +- crates/config/src/lib.rs | 53 +++--- crates/evm/core/src/opts.rs | 14 +- crates/evm/evm/src/executors/tracing.rs | 4 +- crates/evm/traces/src/identifier/etherscan.rs | 2 +- crates/forge/bin/cmd/script/broadcast.rs | 6 +- crates/forge/bin/cmd/script/mod.rs | 10 +- crates/forge/bin/cmd/script/providers.rs | 2 +- crates/forge/bin/cmd/script/sequence.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 58 ++----- crates/forge/bin/cmd/verify/etherscan/mod.rs | 4 +- crates/forge/bin/cmd/verify/mod.rs | 2 +- crates/forge/tests/cli/cmd.rs | 14 +- crates/forge/tests/cli/config.rs | 6 +- 39 files changed, 235 insertions(+), 406 deletions(-) delete mode 100644 crates/config/src/chain.rs diff --git a/Cargo.lock b/Cargo.lock index a0858fe08d58b..a3a5b14d20b1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,10 +76,20 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy-chains" +version = "0.1.1" +source = "git+https://github.com/alloy-rs/chains/?branch=dani/fix-serde#bd022b904897cf71333db9e96e73f6abb363688e" +dependencies = [ + "num_enum", + "serde", + "strum", +] + [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" +source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -99,7 +109,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" +source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -110,7 +120,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" +source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" dependencies = [ "alloy-rlp", "arbitrary", @@ -157,7 +167,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" +source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" dependencies = [ "const-hex", "dunce", @@ -174,7 +184,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" +source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" dependencies = [ "winnow", ] @@ -182,7 +192,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" +source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -1562,9 +1572,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "28f85c3514d2a6e64160359b45a3918c3b4178bcbf4ae5d03ab2d02e521c479a" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -2619,11 +2629,12 @@ dependencies = [ [[package]] name = "foundry-block-explorers" version = "0.1.0" -source = "git+https://github.com/foundry-rs/block-explorers#6e040684a6b6dfccee52eee02c0958a8436d7bc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc59cf4c18884c485b20f376e98946774b76f3b8e2e71e4f35723ffb34b8544" dependencies = [ + "alloy-chains", "alloy-json-abi", "alloy-primitives", - "ethers-core", "foundry-compilers", "reqwest", "semver 1.0.20", @@ -2793,9 +2804,9 @@ name = "foundry-config" version = "0.2.0" dependencies = [ "Inflector", + "alloy-chains", "alloy-primitives", "dirs-next", - "ethers-core", "eyre", "figment", "foundry-block-explorers", @@ -3696,9 +3707,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -4700,7 +4711,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.39", @@ -4875,7 +4886,7 @@ version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -5331,15 +5342,6 @@ dependencies = [ "toml_edit 0.19.15", ] -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.7", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -6056,9 +6058,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" dependencies = [ "bitflags 2.4.1", "errno", @@ -6205,7 +6207,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -6852,7 +6854,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#89f07abf7837f63d22e30d2076e860dac6acef57" +source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" dependencies = [ "paste", "proc-macro2", @@ -6942,9 +6944,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -7233,17 +7235,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap 2.1.0", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.21.0" @@ -7384,9 +7375,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", @@ -7395,9 +7386,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -7561,9 +7552,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-bom" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98e90c70c9f0d4d1ee6d0a7d04aa06cb9bbd53d8cfbdd62a0269a7c2eb640552" +checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" [[package]] name = "unicode-ident" @@ -8143,18 +8134,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.25" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 836b5cc4550a2..35f4ad47fd30a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,6 +158,7 @@ alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" +alloy-chains = "0.1.0" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" @@ -200,7 +201,7 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } +alloy-chains = { git = "https://github.com/alloy-rs/chains/", branch = "dani/fix-serde" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-primitives = { git = "https://github.com/alloy-rs/core/" } diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 9ac2656607641..171853faf7824 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -61,7 +61,7 @@ impl AccessListArgs { let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain_id, &provider).await?; + let chain = utils::get_chain(config.chain, &provider).await?; let sender = eth.wallet.sender().await; access_list(&provider, sender.to_ethers(), to, sig, args, data, tx, chain, block, to_json) diff --git a/crates/cast/bin/cmd/bind.rs b/crates/cast/bin/cmd/bind.rs index a0716f3cd1a68..3496302917392 100644 --- a/crates/cast/bin/cmd/bind.rs +++ b/crates/cast/bin/cmd/bind.rs @@ -79,9 +79,8 @@ impl BindArgs { async fn abigen_etherscan(&self) -> Result { let config = Config::from(&self.etherscan); - let chain = config.chain_id.unwrap_or_default(); + let chain = config.chain.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - let chain = chain.named()?; let client = Client::new(chain, api_key)?; let address = self.path_or_address.parse()?; diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index a394c6421941d..6c9fc22aa64f5 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -126,7 +126,7 @@ impl CallArgs { let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain_id, &provider).await?; + let chain = utils::get_chain(config.chain, &provider).await?; let sender = eth.wallet.sender().await; let mut builder: TxBuilder<'_, Provider> = diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 94493c3c76bd9..c3352cab35b85 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -83,7 +83,7 @@ impl EstimateArgs { let config = Config::from_provider(figment); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain_id, &provider).await?; + let chain = utils::get_chain(config.chain, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)); let mut builder = TxBuilder::new(&provider, from, to, chain, false).await?; diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index b49667ce83191..cc2b7290cc97a 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -56,9 +56,8 @@ impl InterfaceArgs { AbiPath::Local { path: path_or_address, name } } else { let config = Config::from(ðerscan); - let chain = config.chain_id.unwrap_or_default(); + let chain = config.chain.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - let chain = chain.named()?; AbiPath::Etherscan { chain, api_key, diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 65643968d959a..e7e6aed5d9b7b 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -169,8 +169,7 @@ fn build_filter_event_sig(event: Event, args: Vec) -> Result>(), true)?; + let indexed_tokens = parse_params(with_args.iter().map(|(_, p)| *p), true)?; // Merge the inputs restoring the original ordering let mut tokens = with_args @@ -217,7 +216,7 @@ fn parse_params<'a, I: IntoIterator>( ) -> eyre::Result> { let mut tokens = Vec::new(); - for (param, value) in params.into_iter() { + for (param, value) in params { let mut token = if lenient { LenientTokenizer::tokenize(param, value) } else { diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index f30221ddb0331..725e540fce18c 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -112,7 +112,7 @@ impl SendTxArgs { let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain_id, &provider).await?; + let chain = utils::get_chain(config.chain, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)); // Case 1: @@ -121,7 +121,7 @@ impl SendTxArgs { // or remote RPC with unlocked accounts. if unlocked { // only check current chain id if it was specified in the config - if let Some(config_chain) = config.chain_id { + if let Some(config_chain) = config.chain { let current_chain_id = provider.get_chainid().await?.as_u64(); let config_chain_id = config_chain.id(); // switch chain if current chain id is not the same as the one specified in the diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 9981b96f2c099..ba372b95871c4 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -126,9 +126,9 @@ impl StorageArgs { eyre::bail!("You must provide an Etherscan API key if you're fetching a remote contract's storage."); } - let chain = utils::get_chain(config.chain_id, &provider).await?; + let chain = utils::get_chain(config.chain, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - let client = Client::new(chain.named()?, api_key)?; + let client = Client::new(chain, api_key)?; let addr = address .as_address() .ok_or_else(|| eyre::eyre!("Could not resolve address"))? diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index bbbdf0e8decab..abe4df5d4704a 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -3,7 +3,6 @@ use clap::Parser; use ethers_core::{ rand::thread_rng, types::{transaction::eip712::TypedData, Signature}, - utils::to_checksum, }; use ethers_signers::{ coins_bip39::{English, Mnemonic}, @@ -226,7 +225,7 @@ impl WalletSubcommands { println!("\nAccounts:"); for (i, wallet) in wallets.iter().enumerate() { println!("- Account {i}:"); - println!("Address: {}", to_checksum(&wallet.address(), None)); + println!("Address: {}", wallet.address().to_alloy()); println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); } } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index d4a11421e31b2..edbe9d9804c24 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -462,9 +462,8 @@ async fn main() -> Result<()> { } Subcommands::EtherscanSource { address, directory, etherscan } => { let config = Config::from(ðerscan); - let chain = config.chain_id.unwrap_or_default(); + let chain = config.chain.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - let chain = chain.named()?; match directory { Some(dir) => { SimpleCast::expand_etherscan_source_to_directory(chain, address, api_key, dir) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index c66edd80477d5..fee1f7d28900b 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -5,7 +5,7 @@ use alloy_rlp::Decodable; use base::{Base, NumberWithBase, ToBase}; use chrono::NaiveDateTime; use ethers_core::{ - types::{transaction::eip2718::TypedTransaction, Chain, *}, + types::{transaction::eip2718::TypedTransaction, *}, utils::{ format_bytes32_string, format_units, keccak256, parse_bytes32_string, parse_units, rlp, Units, @@ -16,6 +16,7 @@ use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::Client; use foundry_common::{abi::encode_function_args, fmt::*, TransactionReceiptWithRevertReason}; +use foundry_config::Chain; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; @@ -75,9 +76,9 @@ where /// /// # Example /// - /// ``` + /// ```ignore /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Address, Chain}; + /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// @@ -142,9 +143,9 @@ where /// /// # Example /// - /// ```no_run + /// ```ignore /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Address, Chain}; + /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// @@ -203,10 +204,9 @@ where /// /// # Example /// - /// ```no_run - /// use alloy_primitives::{Address, U256}; + /// ```ignore /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Address as eAddress, Chain}; + /// use ethers_core::types::{Address, U256}; /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// @@ -242,7 +242,7 @@ where /// /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_providers::{Http, Provider}; /// @@ -269,10 +269,10 @@ where /// /// # Example /// - /// ```no_run + /// ```ignore /// use alloy_primitives::U256; /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Address, Chain}; + /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// @@ -302,7 +302,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_providers::{Http, Provider}; /// @@ -469,7 +469,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; @@ -494,7 +494,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; @@ -523,7 +523,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; @@ -552,7 +552,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use alloy_primitives::{Address, U256}; /// use cast::Cast; /// use ethers_providers::{Http, Provider}; @@ -575,7 +575,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; @@ -606,7 +606,7 @@ where /// Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; @@ -632,7 +632,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_providers::{Http, Provider}; /// @@ -674,7 +674,7 @@ where /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_providers::{Http, Provider}; /// @@ -736,7 +736,7 @@ where /// /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_providers::{Http, Provider}; /// @@ -762,7 +762,7 @@ where /// /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::types::{Address, H256}; /// use ethers_providers::{Http, Provider}; @@ -814,7 +814,7 @@ where /// /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::types::{BlockId, BlockNumber}; /// use ethers_providers::{Http, Provider}; @@ -857,7 +857,7 @@ where /// /// # Example /// - /// ```no_run + /// ```ignore /// use cast::Cast; /// use ethers_core::{abi::Address, types::Filter}; /// use ethers_providers::{Provider, Ws}; @@ -1593,7 +1593,7 @@ impl SimpleCast { /// Generates an interface in solidity from either a local file ABI or a verified contract on /// Etherscan. It returns a vector of [`InterfaceSource`] structs that contain the source of the /// interface and their name. - /// ```no_run + /// ```ignore /// use cast::{AbiPath, SimpleCast as Cast}; /// # async fn foo() -> eyre::Result<()> { /// let path = @@ -1810,15 +1810,14 @@ impl SimpleCast { /// /// ``` /// # use cast::SimpleCast as Cast; - /// # use ethers_core::types::Chain; - /// + /// # use foundry_config::NamedChain; /// # async fn foo() -> eyre::Result<()> { /// assert_eq!( /// "/* /// - Bytecode Verification performed was compared on second iteration - /// This file is part of the DAO.....", /// Cast::etherscan_source( - /// Chain::Mainnet, + /// NamedChain::Mainnet.into(), /// "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), /// "".to_string() /// ) @@ -1850,7 +1849,7 @@ impl SimpleCast { /// # use std::path::PathBuf; /// # async fn expand() -> eyre::Result<()> { /// Cast::expand_etherscan_source_to_directory( - /// NamedChain::Mainnet, + /// NamedChain::Mainnet.into(), /// "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), /// "".to_string(), /// PathBuf::from("output_dir"), @@ -1876,7 +1875,7 @@ impl SimpleCast { /// /// # Example /// - /// ```no_run + /// ```ignore /// use cast::SimpleCast as Cast; /// /// # async fn foo() -> eyre::Result<()> { diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs index 9da0c20b2274e..67d12e9efcb8b 100644 --- a/crates/cast/src/tx.rs +++ b/crates/cast/src/tx.rs @@ -183,15 +183,11 @@ impl<'a, M: Middleware> TxBuilder<'a, M> { // if only calldata is provided, returning a dummy function get_func("x()")? } else { - let chain = self - .chain - .try_into() - .map_err(|_| FunctionSignatureError::UnknownChain(self.chain))?; get_func_etherscan( sig, self.to.ok_or(FunctionSignatureError::MissingToAddress)?, &args, - chain, + self.chain, self.etherscan_api_key.as_ref().ok_or_else(|| { FunctionSignatureError::MissingEtherscan { sig: sig.to_string() } })?, @@ -278,8 +274,9 @@ mod tests { use crate::TxBuilder; use alloy_primitives::{Address, U256}; use async_trait::async_trait; - use ethers_core::types::{transaction::eip2718::TypedTransaction, Chain, NameOrAddress, H160}; + use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress, H160}; use ethers_providers::{JsonRpcClient, Middleware, ProviderError}; + use foundry_config::NamedChain; use foundry_utils::types::ToEthers; use serde::{de::DeserializeOwned, Serialize}; use std::str::FromStr; @@ -326,7 +323,7 @@ mod tests { async fn builder_new_non_legacy() -> eyre::Result<()> { let provider = MyProvider {}; let builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await?; + TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false).await?; let (tx, args) = builder.build(); assert_eq!(*tx.from().unwrap(), Address::from_str(ADDR_1).unwrap().to_ethers()); assert_eq!( @@ -348,7 +345,7 @@ mod tests { async fn builder_new_legacy() -> eyre::Result<()> { let provider = MyProvider {}; let builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, true).await?; + TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, true).await?; // don't check anything other than the tx type - the rest is covered in the non-legacy case let (tx, _) = builder.build(); match tx { @@ -364,7 +361,9 @@ mod tests { async fn builder_fields() -> eyre::Result<()> { let provider = MyProvider {}; let mut builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await.unwrap(); + TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false) + .await + .unwrap(); builder .gas(Some(U256::from(12u32))) .gas_price(Some(U256::from(34u32))) @@ -386,7 +385,9 @@ mod tests { async fn builder_args() -> eyre::Result<()> { let provider = MyProvider {}; let mut builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), Chain::Mainnet, false).await.unwrap(); + TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false) + .await + .unwrap(); builder.args(Some(("what_a_day(int)", vec![String::from("31337")]))).await?; let (_, function_maybe) = builder.build(); diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index c1cdcc1b22692..8585c5410ce0a 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -82,7 +82,7 @@ impl Cheatcode for loadAllocsCall { ccx.data .db .load_allocs(&allocs, &mut ccx.data.journaled_state) - .map(|_| Vec::default()) + .map(|()| Vec::default()) .map_err(|e| fmt_err!("failed to load allocs: {e}")) } } diff --git a/crates/cli/src/opts/chain.rs b/crates/cli/src/opts/chain.rs index 26d63987d9c82..2762481e08e86 100644 --- a/crates/cli/src/opts/chain.rs +++ b/crates/cli/src/opts/chain.rs @@ -30,7 +30,7 @@ impl TypedValueParser for ChainValueParser { let s = value.to_str().ok_or_else(|| clap::Error::new(clap::error::ErrorKind::InvalidUtf8))?; if let Ok(id) = s.parse() { - Ok(Chain::Id(id)) + Ok(Chain::from_id(id)) } else { // NamedChain::VARIANTS is a subset of all possible variants, since there are aliases: // mumbai instead of polygon-mumbai etc @@ -39,7 +39,7 @@ impl TypedValueParser for ChainValueParser { // the error to the user s.parse() .map_err(|_| self.inner.parse_ref(cmd, arg, value).unwrap_err()) - .map(Chain::Named) + .map(Chain::from_named) } } } diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 78504e5848001..17319952b01a5 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -85,12 +85,12 @@ impl RpcOpts { #[derive(Clone, Debug, Default, Parser, Serialize)] pub struct EtherscanOpts { - /// The Etherscan (or equivalent) API key + /// The Etherscan (or equivalent) API key. #[clap(short = 'e', long = "etherscan-api-key", alias = "api-key", env = "ETHERSCAN_API_KEY")] #[serde(rename = "etherscan_api_key", skip_serializing_if = "Option::is_none")] pub key: Option, - /// The chain name or EIP-155 chain ID + /// The chain name or EIP-155 chain ID. #[clap( short, long, diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 466c3908d7bc2..309e4d2956066 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -163,8 +163,8 @@ macro_rules! update_progress { } /// True if the network calculates gas costs differently. -pub fn has_different_gas_calc(chain: u64) -> bool { - if let Chain::Named(chain) = Chain::from(chain) { +pub fn has_different_gas_calc(chain_id: u64) -> bool { + if let Some(chain) = Chain::from(chain_id).named() { return matches!( chain, NamedChain::Arbitrum | @@ -177,8 +177,8 @@ pub fn has_different_gas_calc(chain: u64) -> bool { } /// True if it supports broadcasting in batches. -pub fn has_batch_support(chain: u64) -> bool { - if let Chain::Named(chain) = Chain::from(chain) { +pub fn has_batch_support(chain_id: u64) -> bool { + if let Some(chain) = Chain::from(chain_id).named() { return !matches!( chain, NamedChain::Arbitrum | @@ -368,7 +368,7 @@ impl TryFrom for TraceResult { pub async fn handle_traces( mut result: TraceResult, config: &Config, - chain: Option, + chain: Option, labels: Vec, verbose: bool, debug: bool, diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index f27054b4839ea..124df64537ccc 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -91,7 +91,7 @@ pub fn get_provider_builder(config: &Config) -> Result Ok(chain), - None => Ok(Chain::Id(provider.get_chainid().await?.as_u64())), + None => Ok(Chain::from_id(provider.get_chainid().await?.as_u64())), } } diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 1961a010abcfe..5a166a20f09e0 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -5,7 +5,7 @@ use alloy_json_abi::{AbiItem, Event, Function}; use alloy_primitives::{hex, Address, Log}; use eyre::{ContextCompat, Result}; use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; -use foundry_config::NamedChain; +use foundry_config::Chain; use std::{future::Future, pin::Pin}; /// Given a function and a vector of string arguments, it proceeds to convert the args to alloy @@ -132,7 +132,7 @@ pub async fn get_func_etherscan( function_name: &str, contract: Address, args: &[String], - chain: NamedChain, + chain: Chain, etherscan_api_key: &str, ) -> Result { let client = Client::new(chain, etherscan_api_key)?; diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 74ab6a2ddc7cb..b721d6aafd916 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -192,10 +192,10 @@ pub struct EnvArgs { #[serde(skip_serializing_if = "Option::is_none")] pub code_size_limit: Option, - /// The chain ID. - #[clap(long, alias = "chain", value_name = "CHAIN_ID")] - #[serde(skip_serializing_if = "Option::is_none")] - pub chain_id: Option, + /// The chain name or EIP-155 chain ID. + #[clap(long, visible_alias = "chain-id", value_name = "CHAIN")] + #[serde(rename = "chain_id", skip_serializing_if = "Option::is_none", serialize_with = "id")] + pub chain: Option, /// The gas price. #[clap(long, value_name = "GAS_PRICE")] @@ -255,6 +255,18 @@ impl EvmArgs { } } +/// We have to serialize chain IDs and not names because when extracting an EVM `Env`, it expects +/// `chain_id` to be `u64`. +#[allow(clippy::trivially_copy_pass_by_ref)] +fn id(chain: &Option, s: S) -> Result { + if let Some(chain) = chain { + s.serialize_u64(chain.id()) + } else { + // skip_serializing_if = "Option::is_none" should prevent this branch from being taken + unreachable!() + } +} + #[cfg(test)] mod tests { use super::*; @@ -263,20 +275,20 @@ mod tests { #[test] fn can_parse_chain_id() { let args = EvmArgs { - env: EnvArgs { chain_id: Some(NamedChain::Mainnet.into()), ..Default::default() }, + env: EnvArgs { chain: Some(NamedChain::Mainnet.into()), ..Default::default() }, ..Default::default() }; let config = Config::from_provider(Config::figment().merge(args)); - assert_eq!(config.chain_id, Some(NamedChain::Mainnet.into())); + assert_eq!(config.chain, Some(NamedChain::Mainnet.into())); let env = EnvArgs::parse_from(["foundry-common", "--chain-id", "goerli"]); - assert_eq!(env.chain_id, Some(NamedChain::Goerli.into())); + assert_eq!(env.chain, Some(NamedChain::Goerli.into())); } #[test] fn test_memory_limit() { let args = EvmArgs { - env: EnvArgs { chain_id: Some(NamedChain::Mainnet.into()), ..Default::default() }, + env: EnvArgs { chain: Some(NamedChain::Mainnet.into()), ..Default::default() }, ..Default::default() }; let config = Config::from_provider(Config::figment().merge(args)); @@ -285,4 +297,16 @@ mod tests { let env = EnvArgs::parse_from(["foundry-common", "--memory-limit", "100"]); assert_eq!(env.memory_limit, Some(100)); } + + #[test] + fn test_chain_id() { + let env = EnvArgs::parse_from(["foundry-common", "--chain-id", "1"]); + assert_eq!(env.chain, Some(Chain::mainnet())); + + let env = EnvArgs::parse_from(["foundry-common", "--chain-id", "mainnet"]); + assert_eq!(env.chain, Some(Chain::mainnet())); + let args = EvmArgs { env, ..Default::default() }; + let config = Config::from_provider(Config::figment().merge(args)); + assert_eq!(config.chain, Some(Chain::mainnet())); + } } diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index e4cc8bbd695b4..d437f92451a3f 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -204,7 +204,7 @@ impl ProviderBuilder { pub async fn connect(self) -> Result { let mut provider = self.build()?; if let Some(blocktime) = provider.get_chainid().await.ok().and_then(|id| { - NamedChain::try_from(id).ok().and_then(|chain| chain.average_blocktime_hint()) + NamedChain::try_from(id.as_u64()).ok().and_then(|chain| chain.average_blocktime_hint()) }) { provider = provider.interval(blocktime / 2); } @@ -274,6 +274,12 @@ where // handle chains that deviate from `eth_feeHistory` and have their own oracle match chain { NamedChain::Polygon | NamedChain::PolygonMumbai => { + // TODO: phase this out somehow + let chain = match chain { + NamedChain::Polygon => ethers_core::types::Chain::Polygon, + NamedChain::PolygonMumbai => ethers_core::types::Chain::PolygonMumbai, + _ => unreachable!(), + }; let estimator = Polygon::new(chain)?.category(GasCategory::Standard); return Ok(estimator.estimate_eip1559_fees().await?) } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 7b05880d38db4..2a29c112c9069 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -14,11 +14,10 @@ repository.workspace = true foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-compilers = { workspace = true, features = ["async", "svm-solc"] } -alloy-primitives = { workspace = true, features = ["std", "serde"] } +alloy-chains = { workspace = true, features = ["serde"] } +alloy-primitives = { workspace = true, features = ["serde"] } revm-primitives = { workspace = true, default-features = false, features = ["std"] } -ethers-core.workspace = true - dirs-next = "2" eyre.workspace = true figment = { version = "0.10", features = ["toml", "env"] } diff --git a/crates/config/src/cache.rs b/crates/config/src/cache.rs index 1355a3c54d439..bebb3e5284cc3 100644 --- a/crates/config/src/cache.rs +++ b/crates/config/src/cache.rs @@ -1,6 +1,6 @@ //! Support types for configuring storage caching -use crate::chain::Chain; +use crate::Chain; use number_prefix::NumberPrefix; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{fmt, fmt::Formatter, str::FromStr}; @@ -230,7 +230,6 @@ pub struct ChainCache { #[cfg(test)] mod tests { use super::*; - use crate::chain::NamedChain; use pretty_assertions::assert_str_eq; #[test] @@ -255,9 +254,9 @@ mod tests { w.rpc_storage_caching, StorageCachingConfig { chains: CachedChains::Chains(vec![ - Chain::Named(NamedChain::Mainnet), - Chain::Named(NamedChain::Optimism), - Chain::Id(999999) + Chain::mainnet(), + Chain::optimism_mainnet(), + Chain::from_id(999999) ]), endpoints: CachedEndpoints::All } diff --git a/crates/config/src/chain.rs b/crates/config/src/chain.rs deleted file mode 100644 index b7ce1ba0ed40d..0000000000000 --- a/crates/config/src/chain.rs +++ /dev/null @@ -1,157 +0,0 @@ -use crate::U256; -use alloy_primitives::U64; -use eyre::Result; -use serde::{Deserialize, Deserializer, Serialize}; -use std::{fmt, str::FromStr}; - -pub use ethers_core::types::Chain as NamedChain; - -/// Either a named or chain id or the actual id value -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)] -#[serde(untagged)] -pub enum Chain { - /// Contains a known chain - #[serde(serialize_with = "super::from_str_lowercase::serialize")] - Named(NamedChain), - /// Contains the id of a chain - Id(u64), -} - -impl Chain { - /// The id of the chain. - pub const fn id(&self) -> u64 { - match self { - Chain::Named(chain) => *chain as u64, - Chain::Id(id) => *id, - } - } - - /// Returns the wrapped named chain or tries converting the ID into one. - pub fn named(&self) -> Result { - match self { - Self::Named(chain) => Ok(*chain), - Self::Id(id) => { - NamedChain::try_from(*id).map_err(|_| eyre::eyre!("Unsupported chain: {id}")) - } - } - } - - /// Helper function for checking if a chainid corresponds to a legacy chainid - /// without eip1559 - pub fn is_legacy(&self) -> bool { - self.named().map_or(false, |c| c.is_legacy()) - } - - /// Returns the corresponding etherscan URLs - pub fn etherscan_urls(&self) -> Option<(&'static str, &'static str)> { - self.named().ok().and_then(|c| c.etherscan_urls()) - } -} - -impl fmt::Display for Chain { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Chain::Named(chain) => chain.fmt(f), - Chain::Id(id) => { - if let Ok(chain) = NamedChain::try_from(*id) { - chain.fmt(f) - } else { - id.fmt(f) - } - } - } - } -} - -impl From for Chain { - fn from(id: NamedChain) -> Self { - Chain::Named(id) - } -} - -impl From for Chain { - fn from(id: u64) -> Self { - NamedChain::try_from(id).map(Chain::Named).unwrap_or_else(|_| Chain::Id(id)) - } -} - -impl From for Chain { - fn from(id: U256) -> Self { - id.to::().into() - } -} - -impl From for u64 { - fn from(c: Chain) -> Self { - match c { - Chain::Named(c) => c as u64, - Chain::Id(id) => id, - } - } -} - -impl From for U64 { - fn from(c: Chain) -> Self { - U64::from(u64::from(c)) - } -} - -impl From for U256 { - fn from(c: Chain) -> Self { - U256::from(u64::from(c)) - } -} - -impl TryFrom for NamedChain { - type Error = >::Error; - - fn try_from(chain: Chain) -> Result { - match chain { - Chain::Named(chain) => Ok(chain), - Chain::Id(id) => id.try_into(), - } - } -} - -impl FromStr for Chain { - type Err = String; - - fn from_str(s: &str) -> Result { - if let Ok(chain) = NamedChain::from_str(s) { - Ok(Chain::Named(chain)) - } else { - s.parse::() - .map(Chain::Id) - .map_err(|_| format!("Expected known chain or integer, found: {s}")) - } - } -} - -impl<'de> Deserialize<'de> for Chain { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - #[derive(Deserialize)] - #[serde(untagged)] - enum ChainId { - Named(String), - Id(u64), - } - - match ChainId::deserialize(deserializer)? { - ChainId::Named(s) => { - s.to_lowercase().parse().map(Chain::Named).map_err(serde::de::Error::custom) - } - ChainId::Id(id) => { - Ok(NamedChain::try_from(id).map(Chain::Named).unwrap_or_else(|_| Chain::Id(id))) - } - } - } -} - -impl Default for Chain { - fn default() -> Self { - NamedChain::Mainnet.into() - } -} diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 36e1dbba976e1..01e0f3b924501 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -140,7 +140,7 @@ impl DerefMut for ResolvedEtherscanConfigs { /// Represents all info required to create an etherscan client #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct EtherscanConfig { - /// Chain name/id that can be used to derive the api url + /// The chain name or EIP-155 chain ID used to derive the API URL. #[serde(default, skip_serializing_if = "Option::is_none")] pub chain: Option, /// Etherscan API URL @@ -204,15 +204,15 @@ impl EtherscanConfig { /// Contains required url + api key to set up an etherscan client #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ResolvedEtherscanConfig { - /// Etherscan API URL + /// Etherscan API URL. #[serde(rename = "url")] pub api_url: String, - /// Optional browser url + /// Optional browser URL. #[serde(default, skip_serializing_if = "Option::is_none")] pub browser_url: Option, - /// Resolved api key + /// The resolved API key. pub key: String, - /// The chain if set + /// The chain name or EIP-155 chain ID. #[serde(default, skip_serializing_if = "Option::is_none")] pub chain: Option, } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index afe750e9bbbbf..cb1d76d9fc03e 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -13,12 +13,11 @@ use figment::{ value::{Dict, Map, Value}, Error, Figment, Metadata, Profile, Provider, }; -pub use foundry_compilers::{self, artifacts::OptimizerDetails}; use foundry_compilers::{ artifacts::{ output_selection::ContractOutputSelection, serde_helpers, BytecodeHash, DebuggingSettings, - Libraries, ModelCheckerSettings, ModelCheckerTarget, Optimizer, RevertStrings, Settings, - SettingsMetadata, Severity, + Libraries, ModelCheckerSettings, ModelCheckerTarget, Optimizer, OptimizerDetails, + RevertStrings, Settings, SettingsMetadata, Severity, }, cache::SOLIDITY_FILES_CACHE_FILENAME, error::SolcError, @@ -28,6 +27,7 @@ use foundry_compilers::{ use inflector::Inflector; use once_cell::sync::Lazy; use regex::Regex; +use revm_primitives::SpecId; use semver::Version; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{ @@ -55,9 +55,6 @@ pub use resolve::UnresolvedEnvVarError; pub mod cache; use cache::{Cache, ChainCache}; -mod chain; -pub use chain::{Chain, NamedChain}; - pub mod fmt; pub use fmt::FormatterConfig; @@ -77,8 +74,8 @@ pub use warning::*; pub mod fix; // reexport so cli types can implement `figment::Provider` to easily merge compiler arguments +pub use alloy_chains::{Chain, NamedChain}; pub use figment; -use revm_primitives::SpecId; /// config providers pub mod providers; @@ -252,8 +249,9 @@ pub struct Config { pub block_number: u64, /// pins the block number for the state fork pub fork_block_number: Option, - /// The chain id to use - pub chain_id: Option, + /// The chain name or EIP-155 chain ID. + #[serde(rename = "chain_id", alias = "chain")] + pub chain: Option, /// Block gas limit pub gas_limit: GasLimit, /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. @@ -895,7 +893,7 @@ impl Config { // we treat the `etherscan_api_key` as actual API key // if no chain provided, we assume mainnet - let chain = self.chain_id.unwrap_or(Chain::Named(NamedChain::Mainnet)); + let chain = self.chain.unwrap_or(Chain::mainnet()); let api_key = self.etherscan_api_key.as_ref()?; ResolvedEtherscanConfig::create(api_key, chain).map(Ok) } @@ -908,9 +906,8 @@ impl Config { /// over the chain's entry in the table. pub fn get_etherscan_config_with_chain( &self, - chain: Option>, + chain: Option, ) -> Result, EtherscanConfigError> { - let chain = chain.map(Into::into); if let Some(maybe_alias) = self.etherscan_api_key.as_ref().or(self.eth_rpc_url.as_ref()) { if self.etherscan.contains_key(maybe_alias) { return self.etherscan.clone().resolved().remove(maybe_alias).transpose() @@ -938,7 +935,7 @@ impl Config { // etherscan fallback via API key if let Some(key) = self.etherscan_api_key.as_ref() { - let chain = chain.or(self.chain_id).unwrap_or_default(); + let chain = chain.or(self.chain).unwrap_or_default(); return Ok(ResolvedEtherscanConfig::create(key, chain)) } @@ -946,7 +943,7 @@ impl Config { } /// Helper function to just get the API key - pub fn get_etherscan_api_key(&self, chain: Option>) -> Option { + pub fn get_etherscan_api_key(&self, chain: Option) -> Option { self.get_etherscan_config_with_chain(chain).ok().flatten().map(|c| c.key) } @@ -1132,7 +1129,7 @@ impl Config { /// Returns the default config that uses dapptools style paths pub fn dapptools() -> Self { Config { - chain_id: Some(Chain::Id(99)), + chain: Some(Chain::from_id(99)), block_timestamp: 0, block_number: 0, ..Config::default() @@ -1788,7 +1785,7 @@ impl Default for Config { initial_balance: U256::from(0xffffffffffffffffffffffffu128), block_number: 1, fork_block_number: None, - chain_id: None, + chain: None, gas_limit: i64::MAX.into(), code_size_limit: None, gas_price: None, @@ -2922,16 +2919,15 @@ mod tests { )?; let config = Config::load(); - assert!(config.get_etherscan_config_with_chain(None::).unwrap().is_none()); assert!(config - .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain)) + .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain.into())) .is_err()); std::env::set_var(env_key, env_value); assert_eq!( config - .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain)) + .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain.into())) .unwrap() .unwrap() .key, @@ -2943,7 +2939,7 @@ mod tests { assert_eq!( with_key - .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain)) + .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain.into())) .unwrap() .unwrap() .key, @@ -3159,12 +3155,12 @@ mod tests { let mut config = Config::load(); - let optimism = config.get_etherscan_api_key(Some(NamedChain::Optimism)); + let optimism = config.get_etherscan_api_key(Some(NamedChain::Optimism.into())); assert_eq!(optimism, Some("https://etherscan-optimism.com/".to_string())); config.etherscan_api_key = Some("mumbai".to_string()); - let mumbai = config.get_etherscan_api_key(Some(NamedChain::PolygonMumbai)); + let mumbai = config.get_etherscan_api_key(Some(NamedChain::PolygonMumbai.into())); assert_eq!(mumbai, Some("https://etherscan-mumbai.com/".to_string())); Ok(()) @@ -3187,7 +3183,7 @@ mod tests { let config = Config::load(); let mumbai = config - .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai)) + .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai.into())) .unwrap() .unwrap(); assert_eq!(mumbai.key, "https://etherscan-mumbai.com/".to_string()); @@ -3212,7 +3208,7 @@ mod tests { let config = Config::load(); let mumbai = config - .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai)) + .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai.into())) .unwrap() .unwrap(); assert_eq!(mumbai.key, "https://etherscan-mumbai.com/".to_string()); @@ -3241,8 +3237,7 @@ mod tests { let config = Config::load(); - let mumbai = - config.get_etherscan_config_with_chain(Option::::None).unwrap().unwrap(); + let mumbai = config.get_etherscan_config_with_chain(None).unwrap().unwrap(); assert_eq!(mumbai.key, "https://etherscan-mumbai.com/".to_string()); let mumbai_rpc = config.get_rpc_url().unwrap().unwrap(); @@ -3294,9 +3289,9 @@ mod tests { via_ir: true, rpc_storage_caching: StorageCachingConfig { chains: CachedChains::Chains(vec![ - Chain::Named(NamedChain::Mainnet), - Chain::Named(NamedChain::Optimism), - Chain::Id(999999) + Chain::mainnet(), + Chain::optimism_mainnet(), + Chain::from_id(999999) ]), endpoints: CachedEndpoints::All }, diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 09f33d0a1fe29..bc364bc51b455 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,12 +1,12 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; -use ethers_core::types::{Block, Chain, TxHash}; +use ethers_core::types::{Block, TxHash}; use ethers_providers::{Middleware, Provider}; use eyre::WrapErr; use foundry_common::{self, ProviderBuilder, RpcUrl, ALCHEMY_FREE_TIER_CUPS}; use foundry_compilers::utils::RuntimeOrHandle; -use foundry_config::Config; +use foundry_config::{Chain, Config}; use revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}; use serde::{Deserialize, Deserializer, Serialize}; @@ -156,7 +156,7 @@ impl EvmOpts { if let Some(id) = self.env.chain_id { return id } - self.get_remote_chain_id().map_or(Chain::Mainnet as u64, |id| id as u64) + self.get_remote_chain_id().unwrap_or(Chain::mainnet()).id() } /// Returns the available compute units per second, which will be @@ -178,14 +178,14 @@ impl EvmOpts { if let Some(ref url) = self.fork_url { if url.contains("mainnet") { trace!(?url, "auto detected mainnet chain"); - return Some(Chain::Mainnet) + return Some(Chain::mainnet()); } trace!(?url, "retrieving chain via eth_chainId"); let provider = Provider::try_from(url.as_str()) .unwrap_or_else(|_| panic!("Failed to establish provider to {url}")); if let Ok(id) = RuntimeOrHandle::new().block_on(provider.get_chainid()) { - return Chain::try_from(id.as_u64()).ok() + return Some(Chain::from(id.as_u64())); } } @@ -195,11 +195,11 @@ impl EvmOpts { #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Env { - /// the block gas limit + /// The block gas limit. #[serde(deserialize_with = "string_or_number")] pub gas_limit: u64, - /// the chainid opcode value + /// The `CHAINID` opcode value. pub chain_id: Option, /// the tx.gasprice value during EVM execution diff --git a/crates/evm/evm/src/executors/tracing.rs b/crates/evm/evm/src/executors/tracing.rs index bf94679330c2d..19db5fc57755d 100644 --- a/crates/evm/evm/src/executors/tracing.rs +++ b/crates/evm/evm/src/executors/tracing.rs @@ -1,6 +1,6 @@ use crate::executors::{Executor, ExecutorBuilder}; use foundry_compilers::EvmVersion; -use foundry_config::{utils::evm_spec_id, Config, NamedChain}; +use foundry_config::{utils::evm_spec_id, Chain, Config}; use foundry_evm_core::{backend::Backend, fork::CreateFork, opts::EvmOpts}; use revm::primitives::Env; use std::ops::{Deref, DerefMut}; @@ -32,7 +32,7 @@ impl TracingExecutor { pub async fn get_fork_material( config: &Config, mut evm_opts: EvmOpts, - ) -> eyre::Result<(Env, Option, Option)> { + ) -> eyre::Result<(Env, Option, Option)> { evm_opts.fork_url = Some(config.get_rpc_url_or_localhost_http()?.into_owned()); evm_opts.fork_block_number = config.fork_block_number; diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 9a92b9ac7ba10..e6e566cc8a4d1 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -40,7 +40,7 @@ pub struct EtherscanIdentifier { impl EtherscanIdentifier { /// Creates a new Etherscan identifier with the given client - pub fn new(config: &Config, chain: Option>) -> eyre::Result { + pub fn new(config: &Config, chain: Option) -> eyre::Result { if let Some(config) = config.get_etherscan_config_with_chain(chain)? { trace!(target: "etherscanidentifier", chain=?config.chain, url=?config.api_url, "using etherscan identifier"); Ok(Self { diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 72d6be2ae5f9c..c57e1ec383bcc 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -448,7 +448,7 @@ impl ScriptArgs { // Config is used to initialize the sequence chain, so we need to change when handling a new // sequence. This makes sure we don't lose the original value. - let original_config_chain = config.chain_id; + let original_config_chain = config.chain; // Peeking is used to check if the next rpc url is different. If so, it creates a // [`ScriptSequence`] from all the collected transactions up to this point. @@ -510,7 +510,7 @@ impl ScriptArgs { } } - config.chain_id = Some(provider_info.chain.into()); + config.chain = Some(provider_info.chain.into()); let sequence = ScriptSequence::new( new_sequence, returns.clone(), @@ -527,7 +527,7 @@ impl ScriptArgs { } // Restore previous config chain. - config.chain_id = original_config_chain; + config.chain = original_config_chain; if !self.skip_simulation { // Present gas information on a per RPC basis. diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index f7a6fd47ebb20..2f39d8fda27d3 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -854,7 +854,7 @@ mod tests { ]); let config = args.load_config(); - let mumbai = config.get_etherscan_api_key(Some(NamedChain::PolygonMumbai)); + let mumbai = config.get_etherscan_api_key(Some(NamedChain::PolygonMumbai.into())); assert_eq!(mumbai, Some("https://etherscan-mumbai.com/".to_string())); } @@ -933,9 +933,9 @@ mod tests { evm_opts.fork_url, Some("https://polygon-mumbai.g.alchemy.com/v2/123456".to_string()) ); - let etherscan = config.get_etherscan_api_key(Some(80001u64)); + let etherscan = config.get_etherscan_api_key(Some(80001u64.into())); assert_eq!(etherscan, Some("polygonkey".to_string())); - let etherscan = config.get_etherscan_api_key(Option::::None); + let etherscan = config.get_etherscan_api_key(None); assert_eq!(etherscan, Some("polygonkey".to_string())); } @@ -975,9 +975,9 @@ mod tests { evm_opts.fork_url, Some("https://polygon-mumbai.g.alchemy.com/v2/123456".to_string()) ); - let etherscan = config.get_etherscan_api_key(Some(80001u64)); + let etherscan = config.get_etherscan_api_key(Some(80001u64.into())); assert_eq!(etherscan, Some("polygonkey".to_string())); - let etherscan = config.get_etherscan_api_key(Option::::None); + let etherscan = config.get_etherscan_api_key(None); assert_eq!(etherscan, Some("polygonkey".to_string())); } diff --git a/crates/forge/bin/cmd/script/providers.rs b/crates/forge/bin/cmd/script/providers.rs index d2f6bb17a76d1..ab417ca156bb5 100644 --- a/crates/forge/bin/cmd/script/providers.rs +++ b/crates/forge/bin/cmd/script/providers.rs @@ -62,7 +62,7 @@ impl ProviderInfo { let provider = Arc::new(get_http_provider(rpc)); let chain = provider.get_chainid().await?.as_u64(); - if let Chain::Named(chain) = Chain::from(chain) { + if let Some(chain) = Chain::from(chain).named() { is_legacy |= chain.is_legacy(); }; diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 0b612d8fe73be..4d6239dc92abe 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -80,7 +80,7 @@ impl ScriptSequence { broadcasted: bool, is_multi: bool, ) -> Result { - let chain = config.chain_id.unwrap_or_default().id(); + let chain = config.chain.unwrap_or_default().id(); let (path, sensitive_path) = ScriptSequence::get_paths( &config.broadcast, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3fc373eafeabc..1ad5488701acb 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -544,9 +544,7 @@ fn short_test_result(name: &str, result: &TestResult) { println!("{result} {name} {}", result.kind.report()); } -/** - * Formats the aggregated summary of all test suites into a string (for printing) - */ +/// Formats the aggregated summary of all test suites into a string (for printing). fn format_aggregated_summary( num_test_suites: usize, total_passed: usize, @@ -786,58 +784,38 @@ async fn test( #[cfg(test)] mod tests { use super::*; + use foundry_config::Chain; - // Sanity test that unknown args are rejected #[test] - fn test_verbosity() { - #[derive(Debug, Parser)] - pub struct VerbosityArgs { - #[clap(long, short, action = clap::ArgAction::Count)] - verbosity: u8, - } - let res = VerbosityArgs::try_parse_from(["foundry-cli", "-vw"]); - assert!(res.is_err()); - - let res = VerbosityArgs::try_parse_from(["foundry-cli", "-vv"]); - assert!(res.is_ok()); - } - - #[test] - fn test_verbosity_multi_short() { - #[derive(Debug, Parser)] - pub struct VerbosityArgs { - #[clap(long, short)] - verbosity: bool, - #[clap( - long, - short, - num_args(0..), - value_name = "PATH", - )] - watch: Option>, - } - // this is supported by clap - let res = VerbosityArgs::try_parse_from(["foundry-cli", "-vw"]); - assert!(res.is_ok()) - } - - #[test] - fn test_watch_parse() { + fn watch_parse() { let args: TestArgs = TestArgs::parse_from(["foundry-cli", "-vw"]); assert!(args.watch.watch.is_some()); } #[test] - fn test_fuzz_seed() { + fn fuzz_seed() { let args: TestArgs = TestArgs::parse_from(["foundry-cli", "--fuzz-seed", "0x10"]); assert!(args.fuzz_seed.is_some()); } // #[test] - fn test_5913() { + fn issue_5913() { let args: TestArgs = TestArgs::parse_from(["foundry-cli", "-vvv", "--gas-report", "--fuzz-seed", "0x10"]); assert!(args.fuzz_seed.is_some()); } + + #[test] + fn extract_chain() { + let test = |arg: &str, expected: Chain| { + let args = TestArgs::parse_from(["foundry-cli", arg]); + assert_eq!(args.evm_opts.env.chain, Some(expected)); + let (config, evm_opts) = args.load_config_and_evm_opts().unwrap(); + assert_eq!(config.chain, Some(expected)); + assert_eq!(evm_opts.env.chain_id, Some(expected.id())); + }; + test("--chain-id=1", Chain::mainnet()); + test("--chain-id=42", Chain::from_id(42)); + } } diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 533e451e4e9b3..2bd045f241bf1 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -269,7 +269,7 @@ impl EtherscanVerificationProvider { let base_url = etherscan_config .as_ref() .and_then(|c| c.browser_url.as_deref()) - .or_else(|| chain.etherscan_urls().map(|urls| urls.1)); + .or_else(|| chain.etherscan_urls().map(|(_, url)| url)); let etherscan_key = etherscan_key.or_else(|| etherscan_config.as_ref().map(|c| c.key.as_str())); @@ -279,7 +279,7 @@ impl EtherscanVerificationProvider { builder = if let Some(api_url) = api_url { builder.with_api_url(api_url)?.with_url(base_url.unwrap_or(api_url))? } else { - builder.chain(chain.to_owned().try_into()?)? + builder.chain(chain)? }; builder diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index adf9819fa4ba7..5544c12f0508c 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -128,7 +128,7 @@ impl VerifyArgs { /// Run the verify command to submit the contract's source code for verification on etherscan pub async fn run(mut self) -> Result<()> { let config = self.load_config_emit_warnings(); - let chain = config.chain_id.unwrap_or_default(); + let chain = config.chain.unwrap_or_default(); self.etherscan.chain = Some(chain); self.etherscan.key = config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index a19accee103f3..a9eee34f3a528 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2,9 +2,7 @@ use crate::constants::*; use foundry_compilers::{artifacts::Metadata, remappings::Remapping, ConfigurableContractArtifact}; -use foundry_config::{ - parse_with_profile, BasicConfig, Chain, Config, NamedChain, SolidityErrorCode, -}; +use foundry_config::{parse_with_profile, BasicConfig, Chain, Config, SolidityErrorCode}; use foundry_test_utils::{ foundry_compilers::PathStyle, util::{pretty_err, read_string, OutputExt, TestCommand}, @@ -35,7 +33,7 @@ forgetest!( #[ignore] can_cache_ls, |_prj, cmd| { - let chain = Chain::Named(NamedChain::Mainnet); + let chain = Chain::mainnet(); let block1 = 100; let block2 = 101; @@ -132,7 +130,7 @@ forgetest!( #[ignore] can_cache_clean_chain, |_prj, cmd| { - let chain = Chain::Named(NamedChain::Mainnet); + let chain = Chain::mainnet(); let cache_dir = Config::foundry_chain_cache_dir(chain).unwrap(); let etherscan_cache_dir = Config::foundry_etherscan_chain_cache_dir(chain).unwrap(); let path = cache_dir.as_path(); @@ -155,7 +153,7 @@ forgetest!( #[ignore] can_cache_clean_blocks, |_prj, cmd| { - let chain = Chain::Named(NamedChain::Mainnet); + let chain = Chain::mainnet(); let block1 = 100; let block2 = 101; let block3 = 102; @@ -189,9 +187,9 @@ forgetest!( #[ignore] can_cache_clean_chain_etherscan, |_prj, cmd| { - let cache_dir = Config::foundry_chain_cache_dir(Chain::Named(NamedChain::Mainnet)).unwrap(); + let cache_dir = Config::foundry_chain_cache_dir(Chain::mainnet()).unwrap(); let etherscan_cache_dir = - Config::foundry_etherscan_chain_cache_dir(Chain::Named(NamedChain::Mainnet)).unwrap(); + Config::foundry_etherscan_chain_cache_dir(Chain::mainnet()).unwrap(); let path = cache_dir.as_path(); let etherscan_path = etherscan_cache_dir.as_path(); fs::create_dir_all(path).unwrap(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 96140c5255857..74aa16e45fc6d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -2,10 +2,10 @@ use alloy_primitives::{Address, B256, U256}; use foundry_cli::utils as forge_utils; -use foundry_compilers::artifacts::{RevertStrings, YulDetails}; +use foundry_compilers::artifacts::{OptimizerDetails, RevertStrings, YulDetails}; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, - Config, FuzzConfig, InvariantConfig, OptimizerDetails, SolcReq, + Config, FuzzConfig, InvariantConfig, SolcReq, }; use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ @@ -69,7 +69,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { initial_balance: U256::from(0xffffffffffffffffffffffffu128), block_number: 10, fork_block_number: Some(200), - chain_id: Some(9999.into()), + chain: Some(9999.into()), gas_limit: 99_000_000u64.into(), code_size_limit: Some(100000), gas_price: Some(999), From 7769cf01ca951d96167d70bb0ba1d81277b66a19 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:55:46 +0100 Subject: [PATCH 0280/1963] fix: unpatch chains (#6320) --- Cargo.lock | 5 +++-- Cargo.toml | 4 +--- testdata/repros/Issue4640.t.sol | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3a5b14d20b1b..f28c8e84788a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,8 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/chains/?branch=dani/fix-serde#bd022b904897cf71333db9e96e73f6abb363688e" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c18b3ecf1746f0eac255374bdf899dd217dd1b301e4a3f146592234243e1bc66" dependencies = [ "num_enum", "serde", diff --git a/Cargo.toml b/Cargo.toml index 35f4ad47fd30a..da9d691c80c7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,7 @@ alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" -alloy-chains = "0.1.0" +alloy-chains = "0.1.2" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" @@ -201,8 +201,6 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -alloy-chains = { git = "https://github.com/alloy-rs/chains/", branch = "dani/fix-serde" } - alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-primitives = { git = "https://github.com/alloy-rs/core/" } alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } diff --git a/testdata/repros/Issue4640.t.sol b/testdata/repros/Issue4640.t.sol index 00576122281b7..e04dd55a34fcb 100644 --- a/testdata/repros/Issue4640.t.sol +++ b/testdata/repros/Issue4640.t.sol @@ -10,7 +10,7 @@ contract Issue4640Test is DSTest { function testArbitrumBlockNumber() public { // - vm.createSelectFork("https://rpc.ankr.com/arbitrum", 75219831); + vm.createSelectFork("https://arb-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 75219831); // L1 block number assertEq(block.number, 16939475); } From 8c1148246462e69d7f9af7fc204117d46cb97079 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 15 Nov 2023 22:49:34 +0100 Subject: [PATCH 0281/1963] chore(deps): bump axum to 0.6 (#6321) --- Cargo.lock | 84 +++++++++++++++++++----------- crates/anvil/Cargo.toml | 10 ++-- crates/anvil/core/Cargo.toml | 4 +- crates/anvil/server/Cargo.toml | 2 +- crates/anvil/server/src/handler.rs | 22 ++++---- crates/anvil/server/src/lib.rs | 10 ++-- crates/anvil/server/src/ws.rs | 11 ++-- 7 files changed, 82 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f28c8e84788a8..c167768d76f98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,7 +173,7 @@ dependencies = [ "const-hex", "dunce", "heck", - "indexmap 2.1.0", + "indexmap", "proc-macro-error", "proc-macro2", "quote", @@ -623,9 +623,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.5.17" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acee9fd5073ab6b045a275b3e709c163dd36c90685219cb21804a147b58dba43" +checksum = "744864363a200a5e724a7e61bc8c11b6628cf2e3ec519c8a1a48e609a8156b40" dependencies = [ "async-trait", "axum-core", @@ -642,8 +642,10 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", + "rustversion", "serde", "serde_json", + "serde_path_to_error", "serde_urlencoded", "sha-1", "sync_wrapper", @@ -657,9 +659,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.2.9" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e5939e02c56fecd5c017c37df4238c0a839fa76b7f97acdd7efb804fd181cc" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", "bytes", @@ -667,6 +669,7 @@ dependencies = [ "http", "http-body", "mime", + "rustversion", "tower-layer", "tower-service", ] @@ -2390,11 +2393,12 @@ dependencies = [ [[package]] name = "fdlimit" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4c9e43643f5a3be4ca5b67d26b98031ff9db6806c3440ae32e02e3ceac3f1b" +checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" dependencies = [ "libc", + "thiserror", ] [[package]] @@ -3520,9 +3524,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -3530,7 +3534,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -3930,16 +3934,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.1.0" @@ -4337,9 +4331,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matchit" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" +checksum = "3dfc802da7b1cf80aefffa0c7b2f77247c8b32206cc83c270b61264f5b360a80" [[package]] name = "md-5" @@ -4712,7 +4706,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.39", @@ -4887,7 +4881,7 @@ version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -5096,7 +5090,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap", ] [[package]] @@ -5343,6 +5337,15 @@ dependencies = [ "toml_edit 0.19.15", ] +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.7", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -6208,7 +6211,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -6412,12 +6415,22 @@ version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ - "indexmap 2.1.0", + "indexmap", "itoa", "ryu", "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +dependencies = [ + "itoa", + "serde", +] + [[package]] name = "serde_regex" version = "1.1.0" @@ -7209,7 +7222,7 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ - "indexmap 2.1.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -7231,7 +7244,18 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap", "toml_datetime", "winnow", ] @@ -7242,7 +7266,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.1.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 1ec423bfc6dab..aa0a2a8b5ac49 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -31,13 +31,13 @@ foundry-utils.workspace = true # evm support bytes = "1.4.0" ethers = { workspace = true, features = ["rustls", "ws", "ipc"] } -trie-db = { version = "0.23" } -hash-db = { version = "0.15" } -memory-db = { version = "0.29" } +trie-db = "0.23" +hash-db = "0.15" +memory-db = "0.29" alloy-primitives = { workspace = true, features = ["serde"] } # axum related -axum = { version = "0.5", features = ["ws"] } +axum = { version = "0.6", features = ["ws"] } hyper = "0.14" tower = "0.4" tower-http = { version = "0.4", features = ["trace"] } @@ -69,7 +69,7 @@ clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" ctrlc = { version = "3", optional = true } -fdlimit = { version = "0.2", optional = true } +fdlimit = { version = "0.3", optional = true } clap_complete_fig = "4" ethereum-forkid = "0.12" diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index a3fa303a81802..b5d4040ce43db 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -26,8 +26,8 @@ open-fastrlp = { version = "0.1.4", optional = true } hash-db = { version = "0.15", default-features = false } hash256-std-hasher = { version = "0.15", default-features = false } triehash = { version = "0.8", default-features = false } -reference-trie = { version = "0.25" } -keccak-hasher = { version = "0.15" } +reference-trie = "0.25" +keccak-hasher = "0.15" [dev-dependencies] anvil-core = { path = ".", features = ["serde"] } diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index d934d611a4d36..489e46700cac2 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -14,7 +14,7 @@ repository.workspace = true anvil-rpc = { path = "../rpc" } # axum related -axum = { version = "0.5", features = ["ws"] } +axum = { version = "0.6", features = ["ws"] } hyper = "0.14" tower-http = { version = "0.4", features = ["trace", "cors"] } diff --git a/crates/anvil/server/src/handler.rs b/crates/anvil/server/src/handler.rs index 3b3ea8ddbc207..844cf6a46e0f1 100644 --- a/crates/anvil/server/src/handler.rs +++ b/crates/anvil/server/src/handler.rs @@ -5,26 +5,26 @@ use anvil_rpc::{ response::{Response, RpcResponse}, }; use axum::{ - extract::{rejection::JsonRejection, Extension}, + extract::{rejection::JsonRejection, State}, Json, }; use futures::{future, FutureExt}; -/// Handles incoming JSON-RPC Request -pub async fn handle( +/// Handles incoming JSON-RPC Request. +// NOTE: `handler` must come first because the `request` extractor consumes the request body. +pub async fn handle( + State((handler, _)): State<(Http, Ws)>, request: Result, JsonRejection>, - Extension(handler): Extension, ) -> Json { - match request { + Json(match request { + Ok(Json(req)) => handle_request(req, handler) + .await + .unwrap_or_else(|| Response::error(RpcError::invalid_request())), Err(err) => { warn!(target: "rpc", ?err, "invalid request"); - Response::error(RpcError::invalid_request()).into() + Response::error(RpcError::invalid_request()) } - Ok(req) => handle_request(req.0, handler) - .await - .unwrap_or_else(|| Response::error(RpcError::invalid_request())) - .into(), - } + }) } /// Handle the JSON-RPC [Request] diff --git a/crates/anvil/server/src/lib.rs b/crates/anvil/server/src/lib.rs index d88c5e6912177..898d3a7659d5d 100644 --- a/crates/anvil/server/src/lib.rs +++ b/crates/anvil/server/src/lib.rs @@ -11,7 +11,6 @@ use anvil_rpc::{ response::{ResponseResult, RpcResponse}, }; use axum::{ - extract::Extension, http::{header, HeaderValue, Method}, routing::{post, IntoMakeService}, Router, Server, @@ -52,9 +51,8 @@ where let ServerConfig { allow_origin, no_cors } = config; let svc = Router::new() - .route("/", post(handler::handle::).get(ws::handle_ws::)) - .layer(Extension(http)) - .layer(Extension(ws)) + .route("/", post(handler::handle).get(ws::handle_ws)) + .with_state((http, ws)) .layer(TraceLayer::new_for_http()); let svc = if no_cors { @@ -81,8 +79,8 @@ where let ServerConfig { allow_origin, no_cors } = config; let svc = Router::new() - .route("/", post(handler::handle::)) - .layer(Extension(http)) + .route("/", post(handler::handle)) + .with_state((http, ())) .layer(TraceLayer::new_for_http()); let svc = if no_cors { svc diff --git a/crates/anvil/server/src/ws.rs b/crates/anvil/server/src/ws.rs index 48dbba7100d3d..e31652be5a205 100644 --- a/crates/anvil/server/src/ws.rs +++ b/crates/anvil/server/src/ws.rs @@ -3,10 +3,9 @@ use anvil_rpc::request::Request; use axum::{ extract::{ ws::{Message, WebSocket}, - WebSocketUpgrade, + State, WebSocketUpgrade, }, - response::IntoResponse, - Extension, + response::Response, }; use futures::{ready, Sink, Stream}; use std::{ @@ -17,10 +16,10 @@ use std::{ /// Handles incoming Websocket upgrade /// /// This is the entrypoint invoked by the axum server for a websocket request -pub async fn handle_ws( +pub async fn handle_ws( ws: WebSocketUpgrade, - Extension(handler): Extension, -) -> impl IntoResponse { + State((_, handler)): State<(Http, Ws)>, +) -> Response { ws.on_upgrade(|socket| PubSubConnection::new(SocketConn(socket), handler)) } From befa571c7c7909ba46008a83293563ab63de4fc4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 16 Nov 2023 01:52:38 +0100 Subject: [PATCH 0282/1963] refactor: rewrite forge doc server using axum (#6324) * refactor: rewrite doc server with axum * refactor: move doc server to forge crate * disable ws in forge --- Cargo.lock | 164 +++----------------- Cargo.toml | 6 + crates/anvil/Cargo.toml | 9 +- crates/anvil/server/Cargo.toml | 6 +- crates/cast/Cargo.toml | 4 +- crates/cli/Cargo.toml | 2 +- crates/config/Cargo.toml | 2 +- crates/doc/Cargo.toml | 5 +- crates/doc/src/lib.rs | 23 +-- crates/doc/src/server.rs | 115 -------------- crates/fmt/Cargo.toml | 2 +- crates/forge/Cargo.toml | 8 +- crates/forge/bin/cmd/{doc.rs => doc/mod.rs} | 10 +- crates/forge/bin/cmd/doc/server.rs | 104 +++++++++++++ crates/forge/bin/cmd/watch.rs | 4 +- crates/test-utils/Cargo.toml | 2 +- 16 files changed, 174 insertions(+), 292 deletions(-) delete mode 100644 crates/doc/src/server.rs rename crates/forge/bin/cmd/{doc.rs => doc/mod.rs} (95%) create mode 100644 crates/forge/bin/cmd/doc/server.rs diff --git a/Cargo.lock b/Cargo.lock index c167768d76f98..58c347a4d4be5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -325,7 +325,6 @@ dependencies = [ "thiserror", "tokio", "tower", - "tower-http 0.4.4", "tracing", "tracing-subscriber", "trie-db", @@ -381,7 +380,7 @@ dependencies = [ "serde_json", "thiserror", "tokio-util", - "tower-http 0.4.4", + "tower-http", "tracing", ] @@ -623,13 +622,13 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.0" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744864363a200a5e724a7e61bc8c11b6628cf2e3ec519c8a1a48e609a8156b40" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", - "base64 0.13.1", + "base64 0.21.5", "bitflags 1.3.2", "bytes", "futures-util", @@ -647,12 +646,11 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sha-1", + "sha1", "sync_wrapper", "tokio", - "tokio-tungstenite 0.17.2", + "tokio-tungstenite", "tower", - "tower-http 0.3.5", "tower-layer", "tower-service", ] @@ -1947,9 +1945,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2237,7 +2235,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-tungstenite 0.20.1", + "tokio-tungstenite", "tracing", "tracing-futures", "url", @@ -2498,6 +2496,7 @@ dependencies = [ "alloy-primitives", "anvil", "async-trait", + "axum", "clap", "clap_complete", "clap_complete_fig", @@ -2525,9 +2524,11 @@ dependencies = [ "foundry-utils", "futures", "globset", + "hyper", "indicatif", "itertools 0.11.0", "once_cell", + "opener", "parking_lot", "path-slash", "pretty_assertions", @@ -2546,6 +2547,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", + "tower-http", "tracing", "tracing-subscriber", "vergen", @@ -2565,7 +2567,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-utils", - "futures-util", "itertools 0.11.0", "mdbook", "once_cell", @@ -2574,10 +2575,8 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "tokio", "toml 0.8.8", "tracing", - "warp", ] [[package]] @@ -3605,30 +3604,6 @@ dependencies = [ "fxhash", ] -[[package]] -name = "headers" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" -dependencies = [ - "base64 0.21.5", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", -] - -[[package]] -name = "headers-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" -dependencies = [ - "http", -] - [[package]] name = "heck" version = "0.4.1" @@ -4331,9 +4306,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matchit" -version = "0.6.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfc802da7b1cf80aefffa0c7b2f77247c8b32206cc83c270b61264f5b360a80" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "md-5" @@ -6250,12 +6225,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "scopeguard" version = "1.2.0" @@ -6498,17 +6467,6 @@ dependencies = [ "syn 2.0.39", ] -[[package]] -name = "sha-1" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - [[package]] name = "sha1" version = "0.10.6" @@ -7164,18 +7122,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-tungstenite" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.17.3", -] - [[package]] name = "tokio-tungstenite" version = "0.20.1" @@ -7189,7 +7135,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", - "tungstenite 0.20.1", + "tungstenite", "webpki-roots", ] @@ -7295,25 +7241,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" -dependencies = [ - "bitflags 1.3.2", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-http" version = "0.4.4" @@ -7327,7 +7254,13 @@ dependencies = [ "http", "http-body", "http-range-header", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", "pin-project-lite", + "tokio", + "tokio-util", "tower-layer", "tower-service", "tracing", @@ -7480,25 +7413,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "tungstenite" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" -dependencies = [ - "base64 0.13.1", - "byteorder", - "bytes", - "http", - "httparse", - "log", - "rand 0.8.5", - "sha-1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.20.1" @@ -7717,36 +7631,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "warp" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "headers", - "http", - "hyper", - "log", - "mime", - "mime_guess", - "percent-encoding", - "pin-project", - "rustls-pemfile", - "scoped-tls", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-stream", - "tokio-tungstenite 0.20.1", - "tokio-util", - "tower-service", - "tracing", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -8179,9 +8063,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "12a3946ecfc929b583800f4629b6c25b88ac6e92a40ea5670f77112a85d40a8b" dependencies = [ "zeroize_derive", ] diff --git a/Cargo.toml b/Cargo.toml index da9d691c80c7f..7327365d84062 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -176,6 +176,12 @@ serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } toml = "0.8" tracing = "0.1" +tracing-subscriber = "0.3" + +axum = "0.6" +hyper = "0.14" +tower = "0.4" +tower-http = "0.4" #[patch."https://github.com/gakonst/ethers-rs"] #ethers = { path = "../ethers-rs/ethers" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index aa0a2a8b5ac49..4137e7ce590ec 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -37,14 +37,13 @@ memory-db = "0.29" alloy-primitives = { workspace = true, features = ["serde"] } # axum related -axum = { version = "0.6", features = ["ws"] } -hyper = "0.14" -tower = "0.4" -tower-http = { version = "0.4", features = ["trace"] } +axum.workspace = true +hyper.workspace = true +tower.workspace = true # tracing tracing.workspace = true -tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } # async tokio = { version = "1", features = ["time"] } diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index 489e46700cac2..fb880a422de95 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -14,9 +14,9 @@ repository.workspace = true anvil-rpc = { path = "../rpc" } # axum related -axum = { version = "0.6", features = ["ws"] } -hyper = "0.14" -tower-http = { version = "0.4", features = ["trace", "cors"] } +axum = { workspace = true, features = ["ws"] } +hyper.workspace = true +tower-http = { workspace = true, features = ["trace", "cors"] } # tracing tracing.workspace = true diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index a894641ef8358..ad9fbb0a2b99a 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -19,9 +19,9 @@ vergen = { version = "8", default-features = false, features = ["build", "git", [dependencies] # lib -foundry-block-explorers = { workspace = true } +foundry-block-explorers.workspace = true foundry-common.workspace = true -foundry-compilers = { workspace = true, default-features = false } +foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm.workspace = true foundry-utils.workspace = true diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 08432493f925d..679d658b6dca7 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -47,7 +47,7 @@ strum = { version = "0.25", features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["macros"] } tracing-error = "0.2" -tracing-subscriber = { version = "0.3", features = ["registry", "env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["registry", "env-filter", "fmt"] } tracing.workspace = true yansi = "0.5" diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 2a29c112c9069..9afbc7dfb8c9f 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -12,7 +12,7 @@ repository.workspace = true [dependencies] foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } -foundry-compilers = { workspace = true, features = ["async", "svm-solc"] } +foundry-compilers = { workspace = true, features = ["svm-solc"] } alloy-chains = { workspace = true, features = ["serde"] } alloy-primitives = { workspace = true, features = ["serde"] } diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 4561c8674b697..42f99243a7efe 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -12,7 +12,7 @@ repository.workspace = true [dependencies] forge-fmt.workspace = true -foundry-compilers = { workspace = true, features = ["async"] } +foundry-compilers.workspace = true foundry-config.workspace = true foundry-utils.workspace = true @@ -21,7 +21,6 @@ alloy-primitives.workspace = true auto_impl = "1" derive_more = "0.99" eyre.workspace = true -futures-util = "0.3" itertools.workspace = true mdbook = { version = "0.4", default-features = false, features = ["search"] } once_cell = "1" @@ -30,7 +29,5 @@ serde_json.workspace = true serde.workspace = true solang-parser.workspace = true thiserror = "1" -tokio = { version = "1", features = ["macros", "rt-multi-thread"] } toml.workspace = true tracing.workspace = true -warp = { version = "0.3", default-features = false, features = ["websocket"] } diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 1a14bd61c7837..3f92be47aa8c1 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -13,29 +13,22 @@ extern crate tracing; mod builder; -mod document; -mod helpers; -mod parser; -mod preprocessor; -mod server; -mod writer; - -/// The documentation builder. pub use builder::DocBuilder; -/// The documentation server. -pub use server::Server; - -/// The document output. +mod document; pub use document::Document; -/// Solidity parser and related output items. +mod helpers; + +mod parser; pub use parser::{ error, Comment, CommentTag, Comments, CommentsRef, ParseItem, ParseSource, Parser, }; -/// Preprocessors. +mod preprocessor; pub use preprocessor::*; -/// Traits for formatting items into doc output. +mod writer; pub use writer::{AsDoc, AsDocResult, BufWriter, Markdown}; + +pub use mdbook; diff --git a/crates/doc/src/server.rs b/crates/doc/src/server.rs deleted file mode 100644 index bd2cc801a927b..0000000000000 --- a/crates/doc/src/server.rs +++ /dev/null @@ -1,115 +0,0 @@ -use futures_util::{SinkExt, StreamExt}; -use mdbook::{utils::fs::get_404_output_file, MDBook}; -use std::{ - net::{SocketAddr, ToSocketAddrs}, - path::PathBuf, -}; -use tokio::sync::broadcast; -use warp::{ws::Message, Filter}; - -/// The HTTP endpoint for the websocket used to trigger reloads when a file changes. -const LIVE_RELOAD_ENDPOINT: &str = "__livereload"; - -/// Basic mdbook server. Given a path, hostname and port, serves the mdbook. -#[derive(Debug)] -pub struct Server { - path: PathBuf, - hostname: String, - port: usize, -} - -impl Default for Server { - fn default() -> Self { - Self { path: PathBuf::default(), hostname: "localhost".to_owned(), port: 3000 } - } -} - -impl Server { - /// Create new instance of [Server]. - pub fn new(path: PathBuf) -> Self { - Self { path, ..Default::default() } - } - - /// Set host on the [Server]. - pub fn with_hostname(mut self, hostname: String) -> Self { - self.hostname = hostname; - self - } - - /// Set port on the [Server]. - pub fn with_port(mut self, port: usize) -> Self { - self.port = port; - self - } - - /// Serve the mdbook. - pub fn serve(self) -> eyre::Result<()> { - let mut book = - MDBook::load(&self.path).map_err(|err| eyre::eyre!("failed to load book: {err:?}"))?; - - let address = format!("{}:{}", self.hostname, self.port); - - let update_config = |book: &mut MDBook| { - book.config - .set("output.html.live-reload-endpoint", LIVE_RELOAD_ENDPOINT) - .expect("live-reload-endpoint update failed"); - // Override site-url for local serving of the 404 file - book.config.set("output.html.site-url", "/").unwrap(); - }; - update_config(&mut book); - book.build().map_err(|err| eyre::eyre!("failed to build book: {err:?}"))?; - - let sockaddr: SocketAddr = address - .to_socket_addrs()? - .next() - .ok_or_else(|| eyre::eyre!("no address found for {}", address))?; - let build_dir = book.build_dir_for("html"); - let input_404 = book - .config - .get("output.html.input-404") - .and_then(|v| v.as_str()) - .map(ToString::to_string); - let file_404 = get_404_output_file(&input_404); - - // A channel used to broadcast to any websockets to reload when a file changes. - let (tx, _rx) = tokio::sync::broadcast::channel::(100); - - println!("Serving on: http://{address}"); - serve(build_dir, sockaddr, tx, &file_404); - Ok(()) - } -} - -// Adapted from https://github.com/rust-lang/mdBook/blob/41a6f0d43e1a2d9543877eacb4cd2a017f9fe8da/src/cmd/serve.rs#L124 -#[tokio::main] -async fn serve( - build_dir: PathBuf, - address: SocketAddr, - reload_tx: broadcast::Sender, - file_404: &str, -) { - // A warp Filter which captures `reload_tx` and provides an `rx` copy to - // receive reload messages. - let sender = warp::any().map(move || reload_tx.subscribe()); - - // A warp Filter to handle the livereload endpoint. This upgrades to a - // websocket, and then waits for any filesystem change notifications, and - // relays them over the websocket. - let livereload = warp::path(LIVE_RELOAD_ENDPOINT).and(warp::ws()).and(sender).map( - |ws: warp::ws::Ws, mut rx: broadcast::Receiver| { - ws.on_upgrade(move |ws| async move { - let (mut user_ws_tx, _user_ws_rx) = ws.split(); - if let Ok(m) = rx.recv().await { - let _ = user_ws_tx.send(m).await; - } - }) - }, - ); - // A warp Filter that serves from the filesystem. - let book_route = warp::fs::dir(build_dir.clone()); - // The fallback route for 404 errors - let fallback_route = warp::fs::file(build_dir.join(file_404)) - .map(|reply| warp::reply::with_status(reply, warp::http::StatusCode::NOT_FOUND)); - let routes = livereload.or(book_route).or(fallback_route); - warp::serve(routes).run(address).await; -} diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index dab6e4b8f68dc..0f49a10a1b82e 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -24,4 +24,4 @@ tracing.workspace = true itertools.workspace = true pretty_assertions.workspace = true toml.workspace = true -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 81627865efad0..100545babbb58 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -73,6 +73,12 @@ thiserror = "1" tokio = { version = "1", features = ["time"] } watchexec = "2" +# doc server +axum = { workspace = true, features = ["ws"] } +hyper.workspace = true +tower-http = { workspace = true, features = ["fs"] } +opener = "0.6" + [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true @@ -84,7 +90,7 @@ pretty_assertions.workspace = true serial_test = "2" svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } tempfile = "3" -tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } [features] default = ["rustls"] diff --git a/crates/forge/bin/cmd/doc.rs b/crates/forge/bin/cmd/doc/mod.rs similarity index 95% rename from crates/forge/bin/cmd/doc.rs rename to crates/forge/bin/cmd/doc/mod.rs index f671a12d40c87..dbef459ca73cf 100644 --- a/crates/forge/bin/cmd/doc.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -1,10 +1,13 @@ use clap::{Parser, ValueHint}; use eyre::Result; -use forge_doc::{ContractInheritance, Deployments, DocBuilder, GitSource, Inheritdoc, Server}; +use forge_doc::{ContractInheritance, Deployments, DocBuilder, GitSource, Inheritdoc}; use foundry_cli::opts::GH_REPO_PREFIX_REGEX; use foundry_config::{find_project_root_path, load_config_with_root}; use std::{path::PathBuf, process::Command}; +mod server; +use server::Server; + #[derive(Debug, Clone, Parser)] pub struct DocArgs { /// The project's root path. @@ -33,6 +36,10 @@ pub struct DocArgs { #[clap(long, short)] serve: bool, + /// Open the documentation in a browser after serving. + #[clap(long, requires = "serve")] + open: bool, + /// Hostname for serving documentation. #[clap(long, requires = "serve")] hostname: Option, @@ -108,6 +115,7 @@ impl DocArgs { Server::new(doc_config.out) .with_hostname(self.hostname.unwrap_or("localhost".to_owned())) .with_port(self.port.unwrap_or(3000)) + .open(self.open) .serve()?; } diff --git a/crates/forge/bin/cmd/doc/server.rs b/crates/forge/bin/cmd/doc/server.rs new file mode 100644 index 0000000000000..7c092713615d4 --- /dev/null +++ b/crates/forge/bin/cmd/doc/server.rs @@ -0,0 +1,104 @@ +use axum::{routing::get_service, Router}; +use forge_doc::mdbook::{utils::fs::get_404_output_file, MDBook}; +use std::{ + net::{SocketAddr, ToSocketAddrs}, + path::PathBuf, +}; +use tower_http::services::{ServeDir, ServeFile}; + +/// The HTTP endpoint for the websocket used to trigger reloads when a file changes. +const LIVE_RELOAD_ENDPOINT: &str = "/__livereload"; + +/// Basic mdbook server. Given a path, hostname and port, serves the mdbook. +#[derive(Debug)] +pub struct Server { + path: PathBuf, + hostname: String, + port: usize, + open: bool, +} + +impl Default for Server { + fn default() -> Self { + Self { path: PathBuf::default(), hostname: "localhost".to_owned(), port: 3000, open: false } + } +} + +impl Server { + /// Create a new instance. + pub fn new(path: PathBuf) -> Self { + Self { path, ..Default::default() } + } + + /// Set the host to serve on. + pub fn with_hostname(mut self, hostname: String) -> Self { + self.hostname = hostname; + self + } + + /// Set the port to serve on. + pub fn with_port(mut self, port: usize) -> Self { + self.port = port; + self + } + + /// Set whether to open the browser after serving. + pub fn open(mut self, open: bool) -> Self { + self.open = open; + self + } + + /// Serve the mdbook. + pub fn serve(self) -> eyre::Result<()> { + let mut book = + MDBook::load(&self.path).map_err(|err| eyre::eyre!("failed to load book: {err:?}"))?; + + let reload = LIVE_RELOAD_ENDPOINT.strip_prefix('/').unwrap(); + book.config.set("output.html.live-reload-endpoint", reload).unwrap(); + // Override site-url for local serving of the 404 file + book.config.set("output.html.site-url", "/").unwrap(); + + book.build().map_err(|err| eyre::eyre!("failed to build book: {err:?}"))?; + + let address = format!("{}:{}", self.hostname, self.port); + let sockaddr: SocketAddr = address + .to_socket_addrs()? + .next() + .ok_or_else(|| eyre::eyre!("no address found for {}", address))?; + let build_dir = book.build_dir_for("html"); + let input_404 = book + .config + .get("output.html.input-404") + .and_then(|v| v.as_str()) + .map(ToString::to_string); + let file_404 = get_404_output_file(&input_404); + + let serving_url = format!("http://{address}"); + println!("Serving on: {serving_url}"); + + let thread_handle = std::thread::spawn(move || serve(build_dir, sockaddr, &file_404)); + + if self.open { + open(serving_url); + } + + let _ = thread_handle.join(); + + Ok(()) + } +} + +#[tokio::main] +async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) { + let file_404 = build_dir.join(file_404); + let svc = ServeDir::new(build_dir).not_found_service(ServeFile::new(file_404)); + let app = Router::new().nest_service("/", get_service(svc)); + hyper::Server::bind(&address).serve(app.into_make_service()).await.unwrap(); +} + +fn open>(path: P) { + info!("Opening web browser"); + if let Err(e) = opener::open(path) { + error!("Error opening web browser: {}", e); + } +} diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 9f49640f79063..8a9c9c983457f 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -299,9 +299,9 @@ fn clean_cmd_args(num: usize, mut cmd_args: Vec) -> Vec { /// Returns the Initialisation configuration for [`Watchexec`]. pub fn init() -> Result { let mut config = InitConfig::default(); - config.on_error(SyncFnHandler::from(|data| -> std::result::Result<(), Infallible> { + config.on_error(SyncFnHandler::from(|data| { trace!("[[{:?}]]", data); - Ok(()) + Ok::<_, Infallible>(()) })); Ok(config) diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index fafff94f82beb..7c555927ea8b2 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -30,7 +30,7 @@ pretty_assertions.workspace = true regex = "1" serde_json.workspace = true tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } walkdir = "2" [features] From 5692c5cdc01cf75b92f59504de891cdec012b4d1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 16 Nov 2023 01:52:48 +0100 Subject: [PATCH 0283/1963] chore(cheatcodes): rename defs to spec (#6325) * chore(cheatcodes): rename defs to spec * avoid links in spec --- .cargo/config.toml | 2 +- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- crates/cheatcodes/Cargo.toml | 2 +- crates/cheatcodes/README.md | 6 +++--- crates/cheatcodes/assets/cheatcodes.json | 4 ++-- crates/cheatcodes/defs/README.md | 3 --- crates/cheatcodes/{defs => spec}/Cargo.toml | 4 ++-- crates/cheatcodes/spec/README.md | 3 +++ .../{defs => spec}/src/cheatcode.rs | 0 .../cheatcodes/{defs => spec}/src/function.rs | 0 crates/cheatcodes/{defs => spec}/src/items.rs | 0 crates/cheatcodes/{defs => spec}/src/lib.rs | 7 ++----- crates/cheatcodes/{defs => spec}/src/vm.rs | 4 ++-- crates/cheatcodes/src/lib.rs | 4 ++-- crates/evm/core/Cargo.toml | 2 +- crates/evm/core/src/debug.rs | 2 +- crates/evm/core/src/decode.rs | 2 +- docs/dev/cheatcodes.md | 19 ++++++++++++------- 19 files changed, 38 insertions(+), 36 deletions(-) delete mode 100644 crates/cheatcodes/defs/README.md rename crates/cheatcodes/{defs => spec}/Cargo.toml (85%) create mode 100644 crates/cheatcodes/spec/README.md rename crates/cheatcodes/{defs => spec}/src/cheatcode.rs (100%) rename crates/cheatcodes/{defs => spec}/src/function.rs (100%) rename crates/cheatcodes/{defs => spec}/src/items.rs (100%) rename crates/cheatcodes/{defs => spec}/src/lib.rs (98%) rename crates/cheatcodes/{defs => spec}/src/vm.rs (99%) diff --git a/.cargo/config.toml b/.cargo/config.toml index 5056df8af1f5f..45bca53ae5eb9 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,5 @@ [alias] -cheats = "test -p foundry-cheatcodes-defs --features schema tests::" +cheats = "test -p foundry-cheatcodes-spec --features schema tests::" [target.x86_64-pc-windows-msvc] rustflags = [ diff --git a/Cargo.lock b/Cargo.lock index 58c347a4d4be5..5c8af36a521a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2661,7 +2661,7 @@ dependencies = [ "ethers-providers", "ethers-signers", "eyre", - "foundry-cheatcodes-defs", + "foundry-cheatcodes-spec", "foundry-common", "foundry-compilers", "foundry-config", @@ -2676,7 +2676,7 @@ dependencies = [ ] [[package]] -name = "foundry-cheatcodes-defs" +name = "foundry-cheatcodes-spec" version = "0.2.0" dependencies = [ "alloy-sol-types", @@ -2894,7 +2894,7 @@ dependencies = [ "ethers-providers", "eyre", "foundry-abi", - "foundry-cheatcodes-defs", + "foundry-cheatcodes-spec", "foundry-common", "foundry-compilers", "foundry-config", diff --git a/Cargo.toml b/Cargo.toml index 7327365d84062..181b4255e87a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ "crates/binder/", "crates/cast/", "crates/cheatcodes/", - "crates/cheatcodes/defs/", + "crates/cheatcodes/spec/", "crates/chisel/", "crates/cli/", "crates/common/", @@ -117,7 +117,7 @@ forge-fmt = { path = "crates/fmt" } foundry-abi = { path = "crates/abi" } foundry-binder = { path = "crates/binder" } foundry-cheatcodes = { path = "crates/cheatcodes" } -foundry-cheatcodes-defs = { path = "crates/cheatcodes/defs" } +foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } foundry-cli = { path = "crates/cli" } foundry-common = { path = "crates/common" } foundry-config = { path = "crates/config" } diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index aeae87e547c1b..e21273798f753 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -12,7 +12,7 @@ repository.workspace = true exclude.workspace = true [dependencies] -foundry-cheatcodes-defs.workspace = true +foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true diff --git a/crates/cheatcodes/README.md b/crates/cheatcodes/README.md index ce1e8f32b9f0c..dfe53bcebea18 100644 --- a/crates/cheatcodes/README.md +++ b/crates/cheatcodes/README.md @@ -5,12 +5,12 @@ Foundry cheatcodes definitions and implementations. ## Structure - [`assets/`](./assets/): JSON interface and specification -- [`defs/`](./defs/src/lib.rs): Defines common traits and structs +- [`spec/`](./spec/src/lib.rs): Defines common traits and structs - [`src/`](./src/lib.rs): Rust implementations of the cheatcodes ## Overview -All cheatcodes are defined in a single [`sol!`] macro call in [`defs/src/vm.rs`]. +All cheatcodes are defined in a single [`sol!`] macro call in [`spec/src/vm.rs`]. This, combined with the use of an internal [`Cheatcode`](../macros/impl/src/cheatcodes.rs) derive macro, allows us to generate both the Rust definitions and the JSON specification of the cheatcodes. @@ -38,4 +38,4 @@ If you are making use of the JSON interface, please don't hesitate to open a PR Please see the [cheatcodes dev documentation](../../docs/dev/cheatcodes.md#adding-a-new-cheatcode) on how to add new cheatcodes. [`sol!`]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html -[`defs/src/vm.rs`]: ./defs/src/vm.rs +[`spec/src/vm.rs`]: ./spec/src/vm.rs diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 4678cfa1a72cc..a35fd71c0982c 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -157,7 +157,7 @@ }, { "name": "FsMetadata", - "description": "Metadata information about a file.\n This structure is returned from the [`fsMetadata`] function and represents known\n metadata about a file such as its permissions, size, modification\n times, etc.", + "description": "Metadata information about a file.\n This structure is returned from the `fsMetadata` function and represents known\n metadata about a file such as its permissions, size, modification\n times, etc.", "fields": [ { "name": "isDir", @@ -224,7 +224,7 @@ }, { "name": "FfiResult", - "description": "The result of a [`tryFfi`](tryFfiCall) call.", + "description": "The result of a `tryFfi` call.", "fields": [ { "name": "exitCode", diff --git a/crates/cheatcodes/defs/README.md b/crates/cheatcodes/defs/README.md deleted file mode 100644 index 136ce7ffbbae7..0000000000000 --- a/crates/cheatcodes/defs/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# foundry-cheatcodes-defs - -Minimal crate to provide a common set of cheatcodes definitions. diff --git a/crates/cheatcodes/defs/Cargo.toml b/crates/cheatcodes/spec/Cargo.toml similarity index 85% rename from crates/cheatcodes/defs/Cargo.toml rename to crates/cheatcodes/spec/Cargo.toml index 0185c6bf80092..5f7ec0eb6c7cb 100644 --- a/crates/cheatcodes/defs/Cargo.toml +++ b/crates/cheatcodes/spec/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "foundry-cheatcodes-defs" -description = "Foundry cheatcodes definitions" +name = "foundry-cheatcodes-spec" +description = "Foundry cheatcodes specification" version.workspace = true edition.workspace = true diff --git a/crates/cheatcodes/spec/README.md b/crates/cheatcodes/spec/README.md new file mode 100644 index 0000000000000..0b0aecebed6d1 --- /dev/null +++ b/crates/cheatcodes/spec/README.md @@ -0,0 +1,3 @@ +# foundry-cheatcodes-spec + +Minimal crate to provide a cheatcodes specification. diff --git a/crates/cheatcodes/defs/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs similarity index 100% rename from crates/cheatcodes/defs/src/cheatcode.rs rename to crates/cheatcodes/spec/src/cheatcode.rs diff --git a/crates/cheatcodes/defs/src/function.rs b/crates/cheatcodes/spec/src/function.rs similarity index 100% rename from crates/cheatcodes/defs/src/function.rs rename to crates/cheatcodes/spec/src/function.rs diff --git a/crates/cheatcodes/defs/src/items.rs b/crates/cheatcodes/spec/src/items.rs similarity index 100% rename from crates/cheatcodes/defs/src/items.rs rename to crates/cheatcodes/spec/src/items.rs diff --git a/crates/cheatcodes/defs/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs similarity index 98% rename from crates/cheatcodes/defs/src/lib.rs rename to crates/cheatcodes/spec/src/lib.rs index 53bd161a8f12d..3877806ee6fc8 100644 --- a/crates/cheatcodes/defs/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -1,7 +1,4 @@ -//! # foundry-cheatcode-defs -//! -//! Foundry cheatcode definitions. - +#![doc = include_str!("../README.md")] #![warn(missing_docs, unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] use serde::{Deserialize, Serialize}; @@ -134,7 +131,7 @@ interface Vm {{ } #[test] - fn defs_up_to_date() { + fn spec_up_to_date() { ensure_file_contents(Path::new(JSON_PATH), &json_cheatcodes()); } diff --git a/crates/cheatcodes/defs/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs similarity index 99% rename from crates/cheatcodes/defs/src/vm.rs rename to crates/cheatcodes/spec/src/vm.rs index dd9a33a2b28e1..519d6bad4d184 100644 --- a/crates/cheatcodes/defs/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -92,7 +92,7 @@ interface Vm { /// Metadata information about a file. /// - /// This structure is returned from the [`fsMetadata`] function and represents known + /// This structure is returned from the `fsMetadata` function and represents known /// metadata about a file such as its permissions, size, modification /// times, etc. struct FsMetadata { @@ -124,7 +124,7 @@ interface Vm { uint256 privateKey; } - /// The result of a [`tryFfi`](tryFfiCall) call. + /// The result of a `tryFfi` call. struct FfiResult { /// The exit code of the call. int32 exitCode; diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index a68772e91eb5a..b7a401c074a81 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -6,7 +6,7 @@ #![allow(elided_lifetimes_in_paths)] // Cheats context uses 3 lifetimes #[macro_use] -pub extern crate foundry_cheatcodes_defs as defs; +pub extern crate foundry_cheatcodes_spec as spec; #[macro_use] extern crate tracing; @@ -14,7 +14,7 @@ use alloy_primitives::Address; use foundry_evm_core::backend::DatabaseExt; use revm::EVMData; -pub use defs::{CheatcodeDef, Vm}; +pub use spec::{CheatcodeDef, Vm}; #[macro_use] mod error; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index b919178a1a66f..13664b3e43643 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -12,7 +12,7 @@ repository.workspace = true [dependencies] foundry-abi.workspace = true -foundry-cheatcodes-defs.workspace = true +foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 3b6cab6167e30..f0d6b2c19d85d 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -178,7 +178,7 @@ impl Display for Instruction { Instruction::Cheatcode(cheat) => write!( f, "VM_{}", - foundry_cheatcodes_defs::Vm::CHEATCODES + foundry_cheatcodes_spec::Vm::CHEATCODES .iter() .map(|c| &c.func) .find(|c| c.selector_bytes == *cheat) diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index a74a053ead998..97f0c65c5661d 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -7,7 +7,7 @@ use alloy_primitives::B256; use alloy_sol_types::{SolCall, SolError, SolInterface, SolValue}; use ethers_contract::EthLogDecode; use ethers_core::{abi::RawLog, types::Log, utils::format_units}; -use foundry_cheatcodes_defs::Vm; +use foundry_cheatcodes_spec::Vm; use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index 5ff4105d8e941..a74d79fcd8301 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -70,7 +70,7 @@ implementation handler for the cheatcode. This is also automatically generated, ## Cheatcodes implementation -All the cheatcodes are defined in a large [`sol!`] macro call in [`cheatcodes/defs/src/vm.rs`](../../crates/cheatcodes/defs/src/vm.rs): +All the cheatcodes are defined in a large [`sol!`] macro call in [`cheatcodes/spec/src/vm.rs`]: ```rust sol! { @@ -160,11 +160,16 @@ update of the files. ### Adding a new cheatcode -1. Add its Solidity definition(s) in [`defs/src/vm.rs`]. Ensure that all structs and functions are documented, and that all function parameters are named. This will initially fail to compile because of the automatically generated `match { ... }` expression. This is expected, and will be fixed in the next step -2. Implement the cheatcode in [`cheatcodes`](cheatcodes) in its category's respective module. Follow the existing implementations as a guide. -3. Update the JSON interface by running `cargo cheats` twice. This is expected to fail the first time that this is run after adding a new cheatcode; see [JSON interface](#json-interface) -4. Write an integration test for the cheatcode in [`testdata/cheats/`](../../testdata/cheats/) -5. Submit a PR to [`forge-std`](https://github.com/foundry-rs/forge-std) updating the Solidity interfaces as necessary. Note that this step won't be necessary once the Solidity interfaces are generated using the JSON interface +1. Add its Solidity definition(s) in [`cheatcodes/spec/src/vm.rs`]. Ensure that all structs and functions are documented, and that all function parameters are named. This will initially fail to compile because of the automatically generated `match { ... }` expression. This is expected, and will be fixed in the next step +2. Implement the cheatcode in [`cheatcodes`] in its category's respective module. Follow the existing implementations as a guide. +3. If a struct, enum, error, or event was added to `Vm`, update [`spec::Cheatcodes::new`] +4. Update the JSON interface by running `cargo cheats` twice. This is expected to fail the first time that this is run after adding a new cheatcode; see [JSON interface](#json-interface) +5. Write an integration test for the cheatcode in [`testdata/cheats/`] +6. Submit a PR to [`forge-std`] updating the Solidity interfaces as necessary. Note that this step won't be necessary once the Solidity interfaces are generated using the JSON interface [`sol!`]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html -[`defs/src/vm.rs`]: ./defs/src/vm.rs +[`cheatcodes/spec/src/vm.rs`]: ../../crates/cheatcodes/spec/src/vm.rs +[`cheatcodes`]: ../../crates/cheatcodes/ +[`spec::Cheatcodes::new`]: ../../crates/cheatcodes/spec/src/lib.rs#L74 +[`testdata/cheats/`]: ../../testdata/cheats/ +[`forge-std`]: https://github.com/foundry-rs/forge-std From 2102912b1c34ec50b6544e5eaad4748bf67aefa7 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 15 Nov 2023 21:27:09 -0400 Subject: [PATCH 0284/1963] chore: remove PUSH0 warnings for superchain testnets (#6322) --- crates/forge/bin/cmd/script/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 2f39d8fda27d3..8a5dcbc18b655 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -70,12 +70,12 @@ mod verify; /// List of Chains that support Shanghai. static SHANGHAI_ENABLED_CHAINS: &[Chain] = &[ - // Ethereum Mainnet Chain::Mainnet, - // Goerli Chain::Goerli, - // Sepolia Chain::Sepolia, + Chain::OptimismGoerli, + Chain::OptimismSepolia, + Chain::BaseGoerli, ]; // Loads project's figment and merges the build cli arguments into it From 43d36459268bc344f9350c27060674699ecdb404 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 16 Nov 2023 03:59:46 +0100 Subject: [PATCH 0285/1963] fix(anvil): TypedTransaction rlp decode, bump k256 (#6327) * fix(anvil): TypedTransaction rlp decode, bump k256 * cleanup * fix --- Cargo.lock | 8 ++-- crates/anvil/core/src/eth/transaction/mod.rs | 43 ++++++++------------ crates/anvil/tests/it/otterscan.rs | 2 - 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c8af36a521a9..ce54f5f7aee93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1848,9 +1848,9 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "e9775b22bc152ad86a0cf23f0f348b884b26add12bf741e7ffc4d4ab2ab4d205" dependencies = [ "base16ct", "crypto-bigint", @@ -4068,9 +4068,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" dependencies = [ "cfg-if", "ecdsa", diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 4edc89d08a541..7a381eaaa7cb6 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -746,19 +746,19 @@ impl Encodable for TypedTransaction { impl Decodable for TypedTransaction { fn decode(rlp: &Rlp) -> Result { - let data = rlp.data()?; - let first = *data.first().ok_or(DecoderError::Custom("empty slice"))?; if rlp.is_list() { return Ok(TypedTransaction::Legacy(rlp.as_val()?)) } - let s = data.get(1..).ok_or(DecoderError::Custom("no tx body"))?; - if first == 0x01 { - return rlp::decode(s).map(TypedTransaction::EIP2930) - } - if first == 0x02 { - return rlp::decode(s).map(TypedTransaction::EIP1559) + let [first, s @ ..] = rlp.data()? else { + return Err(DecoderError::Custom("empty slice")); + }; + // "advance" the header, see comments in fastrlp impl below + let s = if s.is_empty() { &rlp.as_raw()[1..] } else { s }; + match *first { + 0x01 => rlp::decode(s).map(TypedTransaction::EIP2930), + 0x02 => rlp::decode(s).map(TypedTransaction::EIP1559), + _ => Err(DecoderError::Custom("invalid tx type")), } - Err(DecoderError::Custom("invalid tx type")) } } @@ -1325,26 +1325,19 @@ mod tests { #[test] fn can_recover_sender() { - let bytes = hex::decode("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap(); + // random mainnet tx: https://etherscan.io/tx/0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f + let bytes = hex::decode("02f872018307910d808507204d2cb1827d0094388c818ca8b9251b393131c08a736a67ccb19297880320d04823e2701c80c001a0cf024f4815304df2867a1a74e9d2707b6abda0337d2d54a4438d453f4160f190a07ac0e6b3bc9395b5b9c8b9e6d77204a236577a5b18467b9175c01de4faa208d9").unwrap(); - let tx: TypedTransaction = rlp::decode(&bytes).expect("decoding TypedTransaction failed"); - let tx = match tx { - TypedTransaction::Legacy(tx) => tx, - _ => panic!("Invalid typed transaction"), + let Ok(TypedTransaction::EIP1559(tx)) = rlp::decode(&bytes) else { + panic!("decoding TypedTransaction failed"); }; - assert_eq!(tx.input, Bytes::from(b"")); - assert_eq!(tx.gas_price, U256::from(0x01u64)); - assert_eq!(tx.gas_limit, U256::from(0x5208u64)); - assert_eq!(tx.nonce, U256::from(0x00u64)); - if let TransactionKind::Call(ref to) = tx.kind { - assert_eq!(*to, "095e7baea6a6c7c4c2dfeb977efac326af552d87".parse().unwrap()); - } else { - panic!(); - } - assert_eq!(tx.value, U256::from(0x0au64)); + assert_eq!( + tx.hash(), + "0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f".parse().unwrap() + ); assert_eq!( tx.recover().unwrap(), - "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse().unwrap() + "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5".parse().unwrap() ); } diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 41745f0fa8e18..3c460424ccbfe 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -138,8 +138,6 @@ contract Contract { let call = contract.method::<_, ()>("deploy", ()).unwrap(); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - dbg!(&receipt); - let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!(res.len(), 1); From 417af3b78072d2299d27500ea08960d9c6602de4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:27:18 +0100 Subject: [PATCH 0286/1963] chore: tables cleanup (#6328) --- crates/cast/bin/cmd/storage.rs | 42 +++++++++++++------------------ crates/common/src/compile.rs | 4 +-- crates/forge/bin/cmd/inspect.rs | 28 ++++++++++----------- crates/forge/bin/cmd/selectors.rs | 16 ++++++------ crates/forge/src/gas_report.rs | 10 ++++---- 5 files changed, 46 insertions(+), 54 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index ba372b95871c4..9d4583217eea6 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -3,10 +3,7 @@ use alloy_primitives::{B256, U256}; use cast::Cast; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; -use ethers_core::{ - abi::ethabi::ethereum_types::BigEndianHash, - types::{BlockId, NameOrAddress}, -}; +use ethers_core::types::{BlockId, NameOrAddress}; use ethers_providers::Middleware; use eyre::Result; use foundry_block_explorers::Client; @@ -195,33 +192,30 @@ async fn fetch_and_print_storage( Ok(()) } else { let layout = artifact.storage_layout.as_ref().unwrap().clone(); - let values = fetch_storage_values(provider, address, &layout).await?; + let values = fetch_storage_slots(provider, address, &layout).await?; print_storage(layout, values, pretty) } } -/// Overrides the `value` field in [StorageLayout] with the slot's value to avoid creating new data -/// structures. -async fn fetch_storage_values( +async fn fetch_storage_slots( provider: RetryProvider, address: NameOrAddress, layout: &StorageLayout, -) -> Result> { - // TODO: Batch request; handle array values +) -> Result> { + // TODO: Batch request let futures: Vec<_> = layout .storage .iter() .map(|slot| { - let slot_h256 = B256::from(U256::from_str(&slot.slot)?); - Ok(provider.get_storage_at(address.clone(), slot_h256.to_ethers(), None)) + let slot = B256::from(U256::from_str(&slot.slot)?); + Ok(provider.get_storage_at(address.clone(), slot.to_ethers(), None)) }) .collect::>()?; - // TODO: Better format values according to their Solidity type - join_all(futures).await.into_iter().map(|value| Ok(format!("{}", value?.into_uint()))).collect() + join_all(futures).await.into_iter().map(|r| Ok(r?.to_alloy())).collect() } -fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Result<()> { +fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Result<()> { if !pretty { println!("{}", serde_json::to_string_pretty(&serde_json::to_value(layout)?)?); return Ok(()) @@ -229,18 +223,18 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Re let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); - table.set_header(vec!["Name", "Type", "Slot", "Offset", "Bytes", "Value", "Contract"]); + table.set_header(["Name", "Type", "Slot", "Offset", "Bytes", "Value", "Contract"]); for (slot, value) in layout.storage.into_iter().zip(values) { let storage_type = layout.types.get(&slot.storage_type); - table.add_row(vec![ - slot.label, - storage_type.as_ref().map_or("?".to_string(), |t| t.label.clone()), - slot.slot, - slot.offset.to_string(), - storage_type.as_ref().map_or("?".to_string(), |t| t.number_of_bytes.clone()), - value, - slot.contract, + table.add_row([ + slot.label.as_str(), + storage_type.map_or("?", |t| &t.label), + &slot.slot, + &slot.offset.to_string(), + &storage_type.map_or("?", |t| &t.number_of_bytes), + &value.to_string(), + &slot.contract, ]); } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index db67b648c71f0..4362662e9a8f7 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -207,7 +207,7 @@ impl Display for SizeReport { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); - table.set_header(vec![ + table.set_header([ Cell::new("Contract").add_attribute(Attribute::Bold).fg(Color::Blue), Cell::new("Size (kB)").add_attribute(Attribute::Bold).fg(Color::Blue), Cell::new("Margin (kB)").add_attribute(Attribute::Bold).fg(Color::Blue), @@ -222,7 +222,7 @@ impl Display for SizeReport { _ => Color::Red, }; - table.add_row(vec![ + table.add_row([ Cell::new(name).fg(color), Cell::new(contract.size as f64 / 1000.0).fg(color), Cell::new(margin as f64 / 1000.0).fg(color), diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index cfd05353e7e24..e7fc089ec55b4 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -127,7 +127,7 @@ impl InspectArgs { println!("{}", serde_json::to_string_pretty(&to_value(&artifact.gas_estimates)?)?); } ContractArtifactField::StorageLayout => { - print_storage_layout(&artifact.storage_layout, pretty)?; + print_storage_layout(artifact.storage_layout.as_ref(), pretty)?; } ContractArtifactField::DevDoc => { println!("{}", serde_json::to_string_pretty(&to_value(&artifact.devdoc)?)?); @@ -210,12 +210,10 @@ pub fn print_abi(abi: &JsonAbi, pretty: bool) -> Result<()> { Ok(()) } -pub fn print_storage_layout(storage_layout: &Option, pretty: bool) -> Result<()> { - if storage_layout.is_none() { - eyre::bail!("Could not get storage layout") - } - - let storage_layout = storage_layout.as_ref().unwrap(); +pub fn print_storage_layout(storage_layout: Option<&StorageLayout>, pretty: bool) -> Result<()> { + let Some(storage_layout) = storage_layout else { + eyre::bail!("Could not get storage layout"); + }; if !pretty { println!("{}", serde_json::to_string_pretty(&to_value(storage_layout)?)?); @@ -224,17 +222,17 @@ pub fn print_storage_layout(storage_layout: &Option, pretty: bool let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); - table.set_header(vec!["Name", "Type", "Slot", "Offset", "Bytes", "Contract"]); + table.set_header(["Name", "Type", "Slot", "Offset", "Bytes", "Contract"]); for slot in &storage_layout.storage { let storage_type = storage_layout.types.get(&slot.storage_type); - table.add_row(vec![ - slot.label.clone(), - storage_type.as_ref().map_or("?".to_string(), |t| t.label.clone()), - slot.slot.clone(), - slot.offset.to_string(), - storage_type.as_ref().map_or("?".to_string(), |t| t.number_of_bytes.clone()), - slot.contract.clone(), + table.add_row([ + slot.label.as_str(), + storage_type.map_or("?", |t| &t.label), + &slot.slot, + &slot.offset.to_string(), + &storage_type.map_or("?", |t| &t.number_of_bytes), + &slot.contract, ]); } diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 97030af8a0464..05b87b7efe71f 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -172,14 +172,14 @@ impl SelectorsSubcommands { println!("No colliding method selectors between the two contracts."); } else { let mut table = Table::new(); - table.set_header(vec![ + table.set_header([ String::from("Selector"), first_contract.name, second_contract.name, ]); - colliding_methods.iter().for_each(|t| { - table.add_row(vec![t.0, t.1, t.2]); - }); + for method in colliding_methods.iter() { + table.add_row([method.0, method.1, method.2]); + } println!("{} collisions found:", colliding_methods.len()); println!("{table}"); } @@ -243,24 +243,24 @@ impl SelectorsSubcommands { let mut table = Table::new(); - table.set_header(vec!["Type", "Signature", "Selector"]); + table.set_header(["Type", "Signature", "Selector"]); for func in abi.functions() { let sig = func.signature(); let selector = func.selector(); - table.add_row(vec!["Function", &sig, &hex::encode_prefixed(selector)]); + table.add_row(["Function", &sig, &hex::encode_prefixed(selector)]); } for event in abi.events() { let sig = event.signature(); let selector = event.selector(); - table.add_row(vec!["Event", &sig, &hex::encode_prefixed(selector)]); + table.add_row(["Event", &sig, &hex::encode_prefixed(selector)]); } for error in abi.errors() { let sig = error.signature(); let selector = error.selector(); - table.add_row(vec!["Error", &sig, &hex::encode_prefixed(selector)]); + table.add_row(["Error", &sig, &hex::encode_prefixed(selector)]); } println!("{table}"); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index baf8b9b97789e..43dfa39a347a0 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -134,16 +134,16 @@ impl Display for GasReport { let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); - table.set_header(vec![Cell::new(format!("{name} contract")) + table.set_header([Cell::new(format!("{name} contract")) .add_attribute(Attribute::Bold) .fg(Color::Green)]); - table.add_row(vec![ + table.add_row([ Cell::new("Deployment Cost").add_attribute(Attribute::Bold).fg(Color::Cyan), Cell::new("Deployment Size").add_attribute(Attribute::Bold).fg(Color::Cyan), ]); - table.add_row(vec![contract.gas.to_string(), contract.size.to_string()]); + table.add_row([contract.gas.to_string(), contract.size.to_string()]); - table.add_row(vec![ + table.add_row([ Cell::new("Function Name").add_attribute(Attribute::Bold).fg(Color::Magenta), Cell::new("min").add_attribute(Attribute::Bold).fg(Color::Green), Cell::new("avg").add_attribute(Attribute::Bold).fg(Color::Yellow), @@ -157,7 +157,7 @@ impl Display for GasReport { let fn_display = if sigs.len() == 1 { fname.clone() } else { sig.replace(':', "") }; - table.add_row(vec![ + table.add_row([ Cell::new(fn_display).add_attribute(Attribute::Bold), Cell::new(gas_info.min.to_string()).fg(Color::Green), Cell::new(gas_info.mean.to_string()).fg(Color::Yellow), From 43dda851ca57f1b1cd0cd23ccc2ff7d0ea5bee27 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 16 Nov 2023 16:55:48 +0100 Subject: [PATCH 0287/1963] chore: bump ethers (#6330) --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce54f5f7aee93..b54f8c102fe9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2060,7 +2060,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2075,7 +2075,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "ethers-core", "once_cell", @@ -2086,7 +2086,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2104,7 +2104,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "Inflector", "const-hex", @@ -2127,7 +2127,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "Inflector", "const-hex", @@ -2142,7 +2142,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "arrayvec", "bytes", @@ -2171,7 +2171,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "chrono", "ethers-core", @@ -2186,7 +2186,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "async-trait", "auto_impl", @@ -2211,7 +2211,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "async-trait", "auto_impl", @@ -2249,7 +2249,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "async-trait", "coins-bip32", @@ -2277,7 +2277,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=0543e1ccbaab70996ab21b5ceeff2fe599728b74#0543e1ccbaab70996ab21b5ceeff2fe599728b74" +source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" dependencies = [ "cfg-if", "const-hex", diff --git a/Cargo.toml b/Cargo.toml index 181b4255e87a9..058e2771dcfa0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -196,16 +196,16 @@ tower-http = "0.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "0543e1ccbaab70996ab21b5ceeff2fe599728b74" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-primitives = { git = "https://github.com/alloy-rs/core/" } From 3e12d889fa0537ab0866b9ef6165bcf371ae03cf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 16 Nov 2023 19:53:34 +0100 Subject: [PATCH 0288/1963] chore: bump revm (#6281) * chore: bump revm * allow aurora * revert on invalid * chore: use is_err * fix: add return checks again * fucking clippy * lets try this again * chore: update another condition * ffs * test: bump snekmate memory limit --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 36 ++++++---- Cargo.toml | 3 + crates/anvil/src/eth/backend/db.rs | 18 ++--- crates/anvil/src/eth/backend/genesis.rs | 16 ++--- .../anvil/src/eth/backend/mem/in_memory_db.rs | 24 ++++--- crates/anvil/src/eth/backend/mem/inspector.rs | 20 ++---- crates/anvil/src/eth/backend/mem/mod.rs | 16 ++--- crates/anvil/src/eth/backend/mem/state.rs | 2 +- crates/anvil/src/eth/backend/mem/storage.rs | 4 +- crates/anvil/src/eth/util.rs | 6 +- crates/cheatcodes/src/evm/mapping.rs | 2 +- crates/cheatcodes/src/inspector.rs | 46 +++++------- crates/chisel/src/dispatcher.rs | 2 +- crates/chisel/src/executor.rs | 2 +- crates/chisel/src/runner.rs | 2 +- crates/config/src/lib.rs | 2 +- crates/debugger/src/lib.rs | 2 +- crates/evm/core/src/backend/fuzz.rs | 26 +++---- crates/evm/core/src/backend/in_memory_db.rs | 32 ++++----- crates/evm/core/src/backend/mod.rs | 71 +++++-------------- crates/evm/core/src/debug.rs | 6 +- crates/evm/core/src/fork/backend.rs | 22 +++--- crates/evm/core/src/fork/database.rs | 34 ++++----- crates/evm/coverage/src/inspector.rs | 21 +----- crates/evm/evm/src/executors/mod.rs | 14 ++-- crates/evm/evm/src/inspectors/access_list.rs | 9 +-- crates/evm/evm/src/inspectors/chisel_state.rs | 19 +++-- crates/evm/evm/src/inspectors/debugger.rs | 10 +-- crates/evm/evm/src/inspectors/printer.rs | 8 +-- crates/evm/evm/src/inspectors/stack.rs | 55 ++++++-------- crates/evm/fuzz/src/inspector.rs | 13 ++-- crates/evm/traces/src/inspector.rs | 28 +++----- crates/evm/traces/src/lib.rs | 6 +- crates/forge/tests/cli/ext_integration.rs | 6 +- deny.toml | 1 + 35 files changed, 246 insertions(+), 338 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b54f8c102fe9b..cfda789a12c5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -602,6 +602,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" +[[package]] +name = "aurora-engine-modexp" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfacad86e9e138fca0670949eb8ed4ffdf73a55bded8887efe0863cd1a3a6f70" +dependencies = [ + "hex", + "num", +] + [[package]] name = "auto_impl" version = "1.1.0" @@ -906,9 +916,9 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.1.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac926d808fb72fe09ebf471a091d6d72918876ccf0b4989766093d2d0d24a0ef" +checksum = "32700dc7904064bb64e857d38a1766607372928e2466ee5f02a869829b3297d7" dependencies = [ "bindgen", "blst", @@ -5729,8 +5739,7 @@ dependencies = [ [[package]] name = "revm" version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f4ca8ae0345104523b4af1a8a7ea97cfa1865cdb7a7c25d23c1a18d9b48598" +source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" dependencies = [ "auto_impl", "revm-interpreter", @@ -5742,8 +5751,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f959cafdf64a7f89b014fa73dc2325001cf654b3d9400260b212d19a2ebe3da0" +source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" dependencies = [ "revm-primitives", "serde", @@ -5752,12 +5760,11 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d360a88223d85709d2e95d4609eb1e19c649c47e28954bfabae5e92bb37e83e" +source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" dependencies = [ + "aurora-engine-modexp", "c-kzg", "k256", - "num", "once_cell", "revm-primitives", "ripemd", @@ -5769,8 +5776,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51187b852d9e458816a2e19c81f1dd6c924077e1a8fccd16e4f044f865f299d7" +source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -6269,18 +6275,18 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +checksum = "2acea373acb8c21ecb5a23741452acd2593ed44ee3d343e72baaa143bc89d0d5" dependencies = [ "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +checksum = "09e67c467c38fd24bd5499dc9a18183b31575c12ee549197e3e20d57aa4fe3b7" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index 058e2771dcfa0..697c973d4372f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -211,3 +211,6 @@ alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-primitives = { git = "https://github.com/alloy-rs/core/" } alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } alloy-sol-types = { git = "https://github.com/alloy-rs/core/" } + +revm = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } +revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } \ No newline at end of file diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index d848d9dea43db..781fb5c0bdde1 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -136,7 +136,7 @@ pub trait Db: /// Deserialize and add all chain data to the backend storage fn load_state(&mut self, state: SerializableState) -> DatabaseResult { for (addr, account) in state.accounts.into_iter() { - let old_account_nonce = DatabaseRef::basic(self, addr.to_alloy()) + let old_account_nonce = DatabaseRef::basic_ref(self, addr.to_alloy()) .ok() .and_then(|acc| acc.map(|acc| acc.nonce)) .unwrap_or_default(); @@ -288,20 +288,20 @@ impl StateDb { impl DatabaseRef for StateDb { type Error = DatabaseError; - fn basic(&self, address: B160) -> DatabaseResult> { - self.0.basic(address) + fn basic_ref(&self, address: B160) -> DatabaseResult> { + self.0.basic_ref(address) } - fn code_by_hash(&self, code_hash: B256) -> DatabaseResult { - self.0.code_by_hash(code_hash) + fn code_by_hash_ref(&self, code_hash: B256) -> DatabaseResult { + self.0.code_by_hash_ref(code_hash) } - fn storage(&self, address: B160, index: rU256) -> DatabaseResult { - self.0.storage(address, index) + fn storage_ref(&self, address: B160, index: rU256) -> DatabaseResult { + self.0.storage_ref(address, index) } - fn block_hash(&self, number: rU256) -> DatabaseResult { - self.0.block_hash(number) + fn block_hash_ref(&self, number: rU256) -> DatabaseResult { + self.0.block_hash_ref(number) } } diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 157f7b104e350..5178b001300c4 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -103,21 +103,21 @@ pub(crate) struct AtGenesisStateDb<'a> { impl<'a> DatabaseRef for AtGenesisStateDb<'a> { type Error = DatabaseError; - fn basic(&self, address: aAddress) -> DatabaseResult> { + fn basic_ref(&self, address: aAddress) -> DatabaseResult> { if let Some(acc) = self.accounts.get(&(address.to_ethers())).cloned() { return Ok(Some(acc)) } - self.db.basic(address) + self.db.basic_ref(address) } - fn code_by_hash(&self, code_hash: B256) -> DatabaseResult { + fn code_by_hash_ref(&self, code_hash: B256) -> DatabaseResult { if let Some((_, acc)) = self.accounts.iter().find(|(_, acc)| acc.code_hash == code_hash) { return Ok(acc.code.clone().unwrap_or_default()) } - self.db.code_by_hash(code_hash) + self.db.code_by_hash_ref(code_hash) } - fn storage(&self, address: aAddress, index: U256) -> DatabaseResult { + fn storage_ref(&self, address: aAddress, index: U256) -> DatabaseResult { if let Some(acc) = self .genesis .as_ref() @@ -130,11 +130,11 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> { .unwrap_or_default(); return Ok(value.into_uint().to_alloy()) } - self.db.storage(address, index) + self.db.storage_ref(address, index) } - fn block_hash(&self, number: U256) -> DatabaseResult { - self.db.block_hash(number) + fn block_hash_ref(&self, number: U256) -> DatabaseResult { + self.db.block_hash_ref(number) } } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 1610bfc125a1d..159e8aca2366e 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -42,7 +42,7 @@ impl Db for MemDb { let code = if let Some(code) = v.info.code { code } else { - self.inner.code_by_hash(v.info.code_hash)? + self.inner.code_by_hash_ref(v.info.code_hash)? } .to_checked(); Ok(( @@ -177,13 +177,13 @@ mod tests { load_db.load_state(state).unwrap(); - let loaded_account = load_db.basic(test_addr.to_alloy()).unwrap().unwrap(); + let loaded_account = load_db.basic_ref(test_addr.to_alloy()).unwrap().unwrap(); assert_eq!(loaded_account.balance, rU256::from(123456)); - assert_eq!(load_db.code_by_hash(loaded_account.code_hash).unwrap(), contract_code); + assert_eq!(load_db.code_by_hash_ref(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); assert_eq!( - load_db.storage(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), + load_db.storage_ref(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), rU256::from(1) ); } @@ -241,15 +241,21 @@ mod tests { db.load_state(new_state).unwrap(); - let loaded_account = db.basic(test_addr.to_alloy()).unwrap().unwrap(); - let loaded_account2 = db.basic(test_addr2.to_alloy()).unwrap().unwrap(); + let loaded_account = db.basic_ref(test_addr.to_alloy()).unwrap().unwrap(); + let loaded_account2 = db.basic_ref(test_addr2.to_alloy()).unwrap().unwrap(); assert_eq!(loaded_account2.nonce, 1); assert_eq!(loaded_account.balance, rU256::from(100100)); - assert_eq!(db.code_by_hash(loaded_account.code_hash).unwrap(), contract_code); + assert_eq!(db.code_by_hash_ref(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); - assert_eq!(db.storage(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), rU256::from(1)); - assert_eq!(db.storage(test_addr.to_alloy(), rU256::from(1234568)).unwrap(), rU256::from(5)); + assert_eq!( + db.storage_ref(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), + rU256::from(1) + ); + assert_eq!( + db.storage_ref(test_addr.to_alloy(), rU256::from(1234568)).unwrap(), + rU256::from(5) + ); } } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index a4e2d0d94f4db..295558408ba3d 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -48,23 +48,17 @@ impl Inspector { impl revm::Inspector for Inspector { #[inline] - fn initialize_interp( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn initialize_interp(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { call_inspectors!([&mut self.tracer], |inspector| { inspector.initialize_interp(interp, data); }); - InstructionResult::Continue } #[inline] - fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { call_inspectors!([&mut self.tracer], |inspector| { inspector.step(interp, data); }); - InstructionResult::Continue } #[inline] @@ -81,16 +75,10 @@ impl revm::Inspector for Inspector { } #[inline] - fn step_end( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - eval: InstructionResult, - ) -> InstructionResult { + fn step_end(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step_end(interp, data, eval); + inspector.step_end(interp, data); }); - eval } #[inline] diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index b6b99f3e16812..fcfaa8f1040ea 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -267,7 +267,7 @@ impl Backend { // accounts concurrently by spawning the job to a new task genesis_accounts_futures.push(tokio::task::spawn(async move { let db = db.read().await; - let info = db.basic(address.to_alloy())?.unwrap_or_default(); + let info = db.basic_ref(address.to_alloy())?.unwrap_or_default(); Ok::<_, DatabaseError>((address, info)) })); } @@ -341,7 +341,7 @@ impl Backend { /// Returns the `AccountInfo` from the database pub async fn get_account(&self, address: Address) -> DatabaseResult { - Ok(self.db.read().await.basic(address.to_alloy())?.unwrap_or_default()) + Ok(self.db.read().await.basic_ref(address.to_alloy())?.unwrap_or_default()) } /// Whether we're forked off some remote client @@ -1148,7 +1148,7 @@ impl Backend { let to = if let Some(to) = request.to { to.to_alloy() } else { - let nonce = state.basic(from)?.unwrap_or_default().nonce; + let nonce = state.basic_ref(from)?.unwrap_or_default().nonce; from.create(nonce) }; @@ -1675,7 +1675,7 @@ impl Backend { ) -> Result { self.with_database_at(block_request, |db, _| { trace!(target: "backend", "get storage for {:?} at {:?}", address, index); - let val = db.storage(address.to_alloy(), index.to_alloy())?; + let val = db.storage_ref(address.to_alloy(), index.to_alloy())?; Ok(u256_to_h256_be(val.to_ethers())) }) .await? @@ -1702,7 +1702,7 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get code for {:?}", address); - let account = state.basic(address.to_alloy())?.unwrap_or_default(); + let account = state.basic_ref(address.to_alloy())?.unwrap_or_default(); if account.code_hash == KECCAK_EMPTY { // if the code hash is `KECCAK_EMPTY`, we check no further return Ok(Default::default()) @@ -1710,7 +1710,7 @@ impl Backend { let code = if let Some(code) = account.code { code } else { - state.code_by_hash(account.code_hash)? + state.code_by_hash_ref(account.code_hash)? }; Ok(code.bytes()[..code.len()].to_vec().into()) } @@ -1736,7 +1736,7 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get balance for {:?}", address); - Ok(state.basic(address.to_alloy())?.unwrap_or_default().balance.to_ethers()) + Ok(state.basic_ref(address.to_alloy())?.unwrap_or_default().balance.to_ethers()) } /// Returns the nonce of the address @@ -1759,7 +1759,7 @@ impl Backend { }; self.with_database_at(final_block_request, |db, _| { trace!(target: "backend", "get nonce for {:?}", address); - Ok(db.basic(address.to_alloy())?.unwrap_or_default().nonce.into()) + Ok(db.basic_ref(address.to_alloy())?.unwrap_or_default().nonce.into()) }) .await? } diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index 036dc672651df..9abe81fef3f88 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -116,7 +116,7 @@ where { let mut cache_db = CacheDB::new(state); for (account, account_overrides) in overrides.iter() { - let mut account_info = cache_db.basic((*account).to_alloy())?.unwrap_or_default(); + let mut account_info = cache_db.basic_ref((*account).to_alloy())?.unwrap_or_default(); if let Some(nonce) = account_overrides.nonce { account_info.nonce = nonce; diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 236b76f5f043b..10f7ded45eda6 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -478,7 +478,7 @@ mod tests { let loaded = storage.get(&one).unwrap(); - let acc = loaded.basic(addr.to_alloy()).unwrap().unwrap(); + let acc = loaded.basic_ref(addr.to_alloy()).unwrap().unwrap(); assert_eq!(acc.balance, rU256::from(1337u64)); } @@ -508,7 +508,7 @@ mod tests { let hash = H256::from_uint(&U256::from(idx)); let addr = Address::from(hash); let loaded = storage.get(&hash).unwrap(); - let acc = loaded.basic(addr.to_alloy()).unwrap().unwrap(); + let acc = loaded.basic_ref(addr.to_alloy()).unwrap().unwrap(); let balance = (idx * 2) as u64; assert_eq!(acc.balance, rU256::from(balance)); } diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 5fdf3dc6ae1c4..76816b4b30f4e 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -1,12 +1,14 @@ -use ethers::{abi::Address, types::H160}; +use ethers::abi::Address; use foundry_evm::revm::{self, precompile::Precompiles, primitives::SpecId}; +use foundry_utils::types::ToEthers; use std::fmt; pub fn get_precompiles_for(spec_id: SpecId) -> Vec
{ Precompiles::new(to_precompile_id(spec_id)) .addresses() .into_iter() - .map(|item| H160::from_slice(item)) + .copied() + .map(|item| item.to_ethers()) .collect() } diff --git a/crates/cheatcodes/src/evm/mapping.rs b/crates/cheatcodes/src/evm/mapping.rs index 8ff789c8e4191..f5acc4966595a 100644 --- a/crates/cheatcodes/src/evm/mapping.rs +++ b/crates/cheatcodes/src/evm/mapping.rs @@ -119,7 +119,7 @@ pub(crate) fn step(mapping_slots: &mut HashMap, interpret if interpreter.stack.peek(1) == Ok(U256::from(0x40)) { let address = interpreter.contract.address; let offset = interpreter.stack.peek(0).expect("stack size > 1").saturating_to(); - let data = interpreter.memory.slice(offset, 0x40); + let data = interpreter.shared_memory.slice(offset, 0x40); let low = B256::from_slice(&data[..0x20]); let high = B256::from_slice(&data[0x20..]); let result = keccak256(data); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index ab5368c44f5d7..3ff0d563c32de 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -46,7 +46,7 @@ macro_rules! try_or_continue { ($e:expr) => { match $e { Ok(v) => v, - Err(_) => return InstructionResult::Continue, + Err(_) => return, } }; } @@ -281,11 +281,7 @@ impl Cheatcodes { impl Inspector for Cheatcodes { #[inline] - fn initialize_interp( - &mut self, - _: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn initialize_interp(&mut self, _: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. if let Some(block) = self.block.take() { @@ -294,15 +290,9 @@ impl Inspector for Cheatcodes { if let Some(gas_price) = self.gas_price.take() { data.env.tx.gas_price = gas_price; } - - InstructionResult::Continue } - fn step( - &mut self, - interpreter: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn step(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { self.pc = interpreter.program_counter(); // reset gas if gas metering is turned off @@ -422,7 +412,8 @@ impl Inspector for Cheatcodes { range.contains(&offset) && range.contains(&(offset + 31)) }) { disallowed_mem_write(offset, 32, interpreter, ranges); - return InstructionResult::Revert + interpreter.instruction_result = InstructionResult::Revert; + return } } opcode::MSTORE8 => { @@ -433,7 +424,8 @@ impl Inspector for Cheatcodes { // unexpectedly mutated. if !ranges.iter().any(|range| range.contains(&offset)) { disallowed_mem_write(offset, 1, interpreter, ranges); - return InstructionResult::Revert + interpreter.instruction_result = InstructionResult::Revert; + return } } @@ -448,11 +440,12 @@ impl Inspector for Cheatcodes { // If the offset being loaded is >= than the memory size, the // memory is being expanded. If none of the allowed ranges contain // [offset, offset + 32), memory has been unexpectedly mutated. - if offset >= interpreter.memory.len() as u64 && !ranges.iter().any(|range| { + if offset >= interpreter.shared_memory.len() as u64 && !ranges.iter().any(|range| { range.contains(&offset) && range.contains(&(offset + 31)) }) { disallowed_mem_write(offset, 32, interpreter, ranges); - return InstructionResult::Revert + interpreter.instruction_result = InstructionResult::Revert; + return } } @@ -475,7 +468,7 @@ impl Inspector for Cheatcodes { range.contains(&(dest_offset + size.saturating_sub(1))) }) && ($writes || [dest_offset, (dest_offset + size).saturating_sub(1)].into_iter().any(|offset| { - offset >= interpreter.memory.len() as u64 + offset >= interpreter.shared_memory.len() as u64 }) ); @@ -483,7 +476,8 @@ impl Inspector for Cheatcodes { // that gives information about the allowed ranges and revert. if fail_cond { disallowed_mem_write(dest_offset, size, interpreter, ranges); - return InstructionResult::Revert + interpreter.instruction_result = InstructionResult::Revert; + return } })* _ => () @@ -519,8 +513,6 @@ impl Inspector for Cheatcodes { if let Some(mapping_slots) = &mut self.mapping_slots { mapping::step(mapping_slots, interpreter); } - - InstructionResult::Continue } fn log(&mut self, _: &mut EVMData<'_, DB>, address: &Address, topics: &[B256], data: &Bytes) { @@ -1030,7 +1022,7 @@ impl Inspector for Cheatcodes { fn disallowed_mem_write( dest_offset: u64, size: u64, - interpreter: &mut Interpreter, + interpreter: &mut Interpreter<'_>, ranges: &[Range], ) { let revert_string = format!( @@ -1045,12 +1037,12 @@ fn disallowed_mem_write( /// Expands memory, stores a revert string, and sets the return range to the revert /// string's location in memory. -fn mstore_revert_string(interpreter: &mut Interpreter, bytes: &[u8]) { - let starting_offset = interpreter.memory.len(); - interpreter.memory.resize(starting_offset + bytes.len()); - interpreter.memory.set_data(starting_offset, 0, bytes.len(), bytes); +fn mstore_revert_string(interpreter: &mut Interpreter<'_>, bytes: &[u8]) { + let starting_offset = interpreter.shared_memory.len(); + interpreter.shared_memory.resize(starting_offset + bytes.len()); + interpreter.shared_memory.set_data(starting_offset, 0, bytes.len(), bytes); interpreter.return_offset = starting_offset; - interpreter.return_len = interpreter.memory.len() - starting_offset + interpreter.return_len = interpreter.shared_memory.len() - starting_offset } fn process_create( diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 90e1dd72d29f5..26f13933b049a 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -421,7 +421,7 @@ impl ChiselDispatcher { i + 32 )), Paint::cyan(hex::encode_prefixed( - &mem.data()[i..i + 32] + &mem.context_memory()[i..i + 32] )) ); }); diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 9fe2f57615bfb..6b97535ba8e0a 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -223,7 +223,7 @@ impl SessionSource { // the file compiled correctly, thus the last stack item must be the memory offset of // the `bytes memory inspectoor` value let mut offset = stack.data().last().unwrap().to_ethers().as_usize(); - let mem = memory.data(); + let mem = memory.context_memory(); let mem_offset = &mem[offset..offset + 32]; let len = U256::try_from_be_slice(mem_offset).unwrap().to::(); offset += 32; diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 14485ab2fb731..86ed659fbd4b9 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -52,7 +52,7 @@ pub struct ChiselResult { /// EVM State at the final instruction of the `run()` function pub state: Option<( revm::interpreter::Stack, - revm::interpreter::Memory, + revm::interpreter::SharedMemory, revm::interpreter::InstructionResult, )>, } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index cb1d76d9fc03e..378a029118df8 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1795,7 +1795,7 @@ impl Default for Config { block_difficulty: 0, block_prevrandao: Default::default(), block_gas_limit: None, - memory_limit: 2u64.pow(25), + memory_limit: 1 << 25, // 32MiB = 33554432 bytes eth_rpc_url: None, eth_rpc_jwt: None, etherscan_api_key: None, diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index d5f31d7f89f45..4a74c302fedae 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -920,7 +920,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let stack_space = Block::default() .title(format!("Memory (max expansion: {} bytes)", memory.len())) .borders(Borders::ALL); - let memory = memory.data(); + let memory = memory.context_memory(); let max_i = memory.len() / 32; let min_len = format!("{:x}", max_i * 32).len(); diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index 77e8bd6f577cf..7fa3de4b25469 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -63,7 +63,7 @@ impl<'a> FuzzBackendWrapper<'a> { // this is a new call to inspect with a new env, so even if we've cloned the backend // already, we reset the initialized state self.is_initialized = false; - match revm::evm_inner::(env, self, &mut inspector).transact() { + match revm::evm_inner::(env, self, Some(&mut inspector)).transact() { Ok(result) => Ok(result), Err(e) => eyre::bail!("fuzz: failed to inspect: {e}"), } @@ -235,20 +235,20 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { impl<'a> DatabaseRef for FuzzBackendWrapper<'a> { type Error = DatabaseError; - fn basic(&self, address: Address) -> Result, Self::Error> { - DatabaseRef::basic(self.backend.as_ref(), address) + fn basic_ref(&self, address: Address) -> Result, Self::Error> { + DatabaseRef::basic_ref(self.backend.as_ref(), address) } - fn code_by_hash(&self, code_hash: B256) -> Result { - DatabaseRef::code_by_hash(self.backend.as_ref(), code_hash) + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + DatabaseRef::code_by_hash_ref(self.backend.as_ref(), code_hash) } - fn storage(&self, address: Address, index: U256) -> Result { - DatabaseRef::storage(self.backend.as_ref(), address, index) + fn storage_ref(&self, address: Address, index: U256) -> Result { + DatabaseRef::storage_ref(self.backend.as_ref(), address, index) } - fn block_hash(&self, number: U256) -> Result { - DatabaseRef::block_hash(self.backend.as_ref(), number) + fn block_hash_ref(&self, number: U256) -> Result { + DatabaseRef::block_hash_ref(self.backend.as_ref(), number) } } @@ -256,18 +256,18 @@ impl<'a> Database for FuzzBackendWrapper<'a> { type Error = DatabaseError; fn basic(&mut self, address: Address) -> Result, Self::Error> { - DatabaseRef::basic(self, address) + DatabaseRef::basic_ref(self, address) } fn code_by_hash(&mut self, code_hash: B256) -> Result { - DatabaseRef::code_by_hash(self, code_hash) + DatabaseRef::code_by_hash_ref(self, code_hash) } fn storage(&mut self, address: Address, index: U256) -> Result { - DatabaseRef::storage(self, address, index) + DatabaseRef::storage_ref(self, address, index) } fn block_hash(&mut self, number: U256) -> Result { - DatabaseRef::block_hash(self, number) + DatabaseRef::block_hash_ref(self, number) } } diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index 6deec78d1e761..6cb2c73eebdee 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -29,20 +29,20 @@ impl Default for MemDb { impl DatabaseRef for MemDb { type Error = DatabaseError; - fn basic(&self, address: Address) -> Result, Self::Error> { - DatabaseRef::basic(&self.inner, address) + fn basic_ref(&self, address: Address) -> Result, Self::Error> { + DatabaseRef::basic_ref(&self.inner, address) } - fn code_by_hash(&self, code_hash: B256) -> Result { - DatabaseRef::code_by_hash(&self.inner, code_hash) + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + DatabaseRef::code_by_hash_ref(&self.inner, code_hash) } - fn storage(&self, address: Address, index: U256) -> Result { - DatabaseRef::storage(&self.inner, address, index) + fn storage_ref(&self, address: Address, index: U256) -> Result { + DatabaseRef::storage_ref(&self.inner, address, index) } - fn block_hash(&self, number: U256) -> Result { - DatabaseRef::block_hash(&self.inner, number) + fn block_hash_ref(&self, number: U256) -> Result { + DatabaseRef::block_hash_ref(&self.inner, number) } } @@ -93,20 +93,20 @@ pub struct EmptyDBWrapper(EmptyDB); impl DatabaseRef for EmptyDBWrapper { type Error = DatabaseError; - fn basic(&self, _address: Address) -> Result, Self::Error> { + fn basic_ref(&self, _address: Address) -> Result, Self::Error> { // Note: this will always return `Some(AccountInfo)`, for the reason explained above Ok(Some(AccountInfo::default())) } - fn code_by_hash(&self, code_hash: B256) -> Result { - Ok(self.0.code_by_hash(code_hash)?) + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + Ok(self.0.code_by_hash_ref(code_hash)?) } - fn storage(&self, address: Address, index: U256) -> Result { - Ok(self.0.storage(address, index)?) + fn storage_ref(&self, address: Address, index: U256) -> Result { + Ok(self.0.storage_ref(address, index)?) } - fn block_hash(&self, number: U256) -> Result { - Ok(self.0.block_hash(number)?) + fn block_hash_ref(&self, number: U256) -> Result { + Ok(self.0.block_hash_ref(number)?) } } @@ -143,7 +143,7 @@ mod tests { let mut db = CacheDB::new(EmptyDB::default()); let address = Address::random(); - let info = DatabaseRef::basic(&db, address).unwrap(); + let info = DatabaseRef::basic_ref(&db, address).unwrap(); assert!(info.is_none()); let mut info = info.unwrap_or_default(); info.balance = U256::from(500u64); diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 90849b53c1941..4e756af98268f 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -594,7 +594,7 @@ impl Backend { bool private _failed; } */ - let value = self.storage(address, U256::ZERO).unwrap_or_default(); + let value = self.storage_ref(address, U256::ZERO).unwrap_or_default(); value.as_le_bytes()[1] != 0 } @@ -747,11 +747,11 @@ impl Backend { let test_contract = match env.tx.transact_to { TransactTo::Call(to) => to, TransactTo::Create(CreateScheme::Create) => { - revm::primitives::create_address(env.tx.caller, env.tx.nonce.unwrap_or_default()) + env.tx.caller.create(env.tx.nonce.unwrap_or_default()) } TransactTo::Create(CreateScheme::Create2 { salt }) => { let code_hash = B256::from_slice(keccak256(&env.tx.data).as_slice()); - revm::primitives::create2_address(env.tx.caller, code_hash, salt) + env.tx.caller.create2(B256::from(salt), code_hash) } }; self.set_test_contract(test_contract); @@ -768,7 +768,7 @@ impl Backend { { self.initialize(env); - match revm::evm_inner::(env, self, &mut inspector).transact() { + match revm::evm_inner::(env, self, Some(&mut inspector)).transact() { Ok(res) => Ok(res), Err(e) => eyre::bail!("backend: failed while inspecting: {e}"), } @@ -1355,70 +1355,35 @@ impl DatabaseExt for Backend { impl DatabaseRef for Backend { type Error = DatabaseError; - fn basic(&self, address: Address) -> Result, Self::Error> { + fn basic_ref(&self, address: Address) -> Result, Self::Error> { if let Some(db) = self.active_fork_db() { - db.basic(address) - } else { - Ok(self.mem_db.basic(address)?) - } - } - - fn code_by_hash(&self, code_hash: B256) -> Result { - if let Some(db) = self.active_fork_db() { - db.code_by_hash(code_hash) - } else { - Ok(self.mem_db.code_by_hash(code_hash)?) - } - } - - fn storage(&self, address: Address, index: U256) -> Result { - if let Some(db) = self.active_fork_db() { - DatabaseRef::storage(db, address, index) - } else { - Ok(DatabaseRef::storage(&self.mem_db, address, index)?) - } - } - - fn block_hash(&self, number: U256) -> Result { - if let Some(db) = self.active_fork_db() { - db.block_hash(number) - } else { - Ok(self.mem_db.block_hash(number)?) - } - } -} - -impl<'a> DatabaseRef for &'a mut Backend { - type Error = DatabaseError; - fn basic(&self, address: Address) -> Result, Self::Error> { - if let Some(db) = self.active_fork_db() { - DatabaseRef::basic(db, address) + db.basic_ref(address) } else { - Ok(DatabaseRef::basic(&self.mem_db, address)?) + Ok(self.mem_db.basic_ref(address)?) } } - fn code_by_hash(&self, code_hash: B256) -> Result { + fn code_by_hash_ref(&self, code_hash: B256) -> Result { if let Some(db) = self.active_fork_db() { - DatabaseRef::code_by_hash(db, code_hash) + db.code_by_hash_ref(code_hash) } else { - Ok(DatabaseRef::code_by_hash(&self.mem_db, code_hash)?) + Ok(self.mem_db.code_by_hash_ref(code_hash)?) } } - fn storage(&self, address: Address, index: U256) -> Result { + fn storage_ref(&self, address: Address, index: U256) -> Result { if let Some(db) = self.active_fork_db() { - DatabaseRef::storage(db, address, index) + DatabaseRef::storage_ref(db, address, index) } else { - Ok(DatabaseRef::storage(&self.mem_db, address, index)?) + Ok(DatabaseRef::storage_ref(&self.mem_db, address, index)?) } } - fn block_hash(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: U256) -> Result { if let Some(db) = self.active_fork_db() { - DatabaseRef::block_hash(db, number) + db.block_hash_ref(number) } else { - Ok(DatabaseRef::block_hash(&self.mem_db, number)?) + Ok(self.mem_db.block_hash_ref(number)?) } } } @@ -1489,7 +1454,7 @@ pub struct Fork { impl Fork { /// Returns true if the account is a contract pub fn is_contract(&self, acc: Address) -> bool { - if let Ok(Some(acc)) = self.db.basic(acc) { + if let Ok(Some(acc)) = self.db.basic_ref(acc) { if acc.code_hash != KECCAK_EMPTY { return true } @@ -1735,8 +1700,8 @@ impl BackendInner { } } JournaledState::new( - self.precompiles().len(), precompiles_spec_id_to_primitives_spec_id(self.precompile_id), + self.precompiles().addresses().into_iter().copied().collect(), ) } } diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index f0d6b2c19d85d..76bc7f3a55888 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,6 +1,6 @@ use crate::utils::CallKind; use alloy_primitives::{Address, U256}; -use revm::interpreter::{Memory, OpCode}; +use revm::interpreter::{OpCode, SharedMemory}; use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -114,7 +114,7 @@ pub struct DebugStep { /// Stack *prior* to running the associated opcode pub stack: Vec, /// Memory *prior* to running the associated opcode - pub memory: Memory, + pub memory: SharedMemory, /// Opcode to be executed pub instruction: Instruction, /// Optional bytes that are being pushed onto the stack @@ -132,7 +132,7 @@ impl Default for DebugStep { fn default() -> Self { Self { stack: vec![], - memory: Memory::new(), + memory: Default::default(), instruction: Instruction::OpCode(revm::interpreter::opcode::INVALID), push_bytes: None, pc: 0, diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 37ac0b937b0a8..ba9329c36761c 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -642,7 +642,7 @@ impl SharedBackend { impl DatabaseRef for SharedBackend { type Error = DatabaseError; - fn basic(&self, address: Address) -> Result, Self::Error> { + fn basic_ref(&self, address: Address) -> Result, Self::Error> { trace!(target: "sharedbackend", %address, "request basic"); self.do_get_basic(address).map_err(|err| { error!(target: "sharedbackend", %err, %address, "Failed to send/recv `basic`"); @@ -653,11 +653,11 @@ impl DatabaseRef for SharedBackend { }) } - fn code_by_hash(&self, hash: B256) -> Result { + fn code_by_hash_ref(&self, hash: B256) -> Result { Err(DatabaseError::MissingCode(hash)) } - fn storage(&self, address: Address, index: U256) -> Result { + fn storage_ref(&self, address: Address, index: U256) -> Result { trace!(target: "sharedbackend", "request storage {:?} at {:?}", address, index); match self.do_get_storage(address, index).map_err(|err| { error!(target: "sharedbackend", %err, %address, %index, "Failed to send/recv `storage`"); @@ -671,7 +671,7 @@ impl DatabaseRef for SharedBackend { } } - fn block_hash(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: U256) -> Result { if number > U256::from(u64::MAX) { return Ok(KECCAK_EMPTY) } @@ -720,8 +720,8 @@ mod tests { let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); let idx = U256::from(0u64); - let value = backend.storage(address, idx).unwrap(); - let account = backend.basic(address).unwrap().unwrap(); + let value = backend.storage_ref(address, idx).unwrap(); + let account = backend.basic_ref(address).unwrap().unwrap(); let mem_acc = db.accounts().read().get(&address).unwrap().clone(); assert_eq!(account.balance, mem_acc.balance); @@ -731,7 +731,7 @@ mod tests { assert_eq!(slots.get(&idx).copied().unwrap(), value); let num = U256::from(10u64); - let hash = backend.block_hash(num).unwrap(); + let hash = backend.block_hash_ref(num).unwrap(); let mem_hash = *db.block_hashes().read().get(&num).unwrap(); assert_eq!(hash, mem_hash); @@ -739,7 +739,7 @@ mod tests { let handle = std::thread::spawn(move || { for i in 1..max_slots { let idx = U256::from(i); - let _ = backend.storage(address, idx); + let _ = backend.storage_ref(address, idx); } }); handle.join().unwrap(); @@ -779,13 +779,13 @@ mod tests { let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); let idx = U256::from(0u64); - let _value = backend.storage(address, idx); - let _account = backend.basic(address); + let _value = backend.storage_ref(address, idx); + let _account = backend.basic_ref(address); // fill some slots let num_slots = 10u64; for idx in 1..num_slots { - let _ = backend.storage(address, U256::from(idx)); + let _ = backend.storage_ref(address, U256::from(idx)); } drop(backend); diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 7d548440be75e..3eaeb6465bfb0 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -172,20 +172,20 @@ impl Database for ForkedDatabase { impl DatabaseRef for ForkedDatabase { type Error = DatabaseError; - fn basic(&self, address: Address) -> Result, Self::Error> { - self.cache_db.basic(address) + fn basic_ref(&self, address: Address) -> Result, Self::Error> { + self.cache_db.basic_ref(address) } - fn code_by_hash(&self, code_hash: B256) -> Result { - self.cache_db.code_by_hash(code_hash) + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + self.cache_db.code_by_hash_ref(code_hash) } - fn storage(&self, address: Address, index: U256) -> Result { - DatabaseRef::storage(&self.cache_db, address, index) + fn storage_ref(&self, address: Address, index: U256) -> Result { + DatabaseRef::storage_ref(&self.cache_db, address, index) } - fn block_hash(&self, number: U256) -> Result { - self.cache_db.block_hash(number) + fn block_hash_ref(&self, number: U256) -> Result { + self.cache_db.block_hash_ref(number) } } @@ -218,43 +218,43 @@ impl ForkDbSnapshot { impl DatabaseRef for ForkDbSnapshot { type Error = DatabaseError; - fn basic(&self, address: Address) -> Result, Self::Error> { + fn basic_ref(&self, address: Address) -> Result, Self::Error> { match self.local.accounts.get(&address) { Some(account) => Ok(Some(account.info.clone())), None => { let mut acc = self.snapshot.accounts.get(&address).cloned(); if acc.is_none() { - acc = self.local.basic(address)?; + acc = self.local.basic_ref(address)?; } Ok(acc) } } } - fn code_by_hash(&self, code_hash: B256) -> Result { - self.local.code_by_hash(code_hash) + fn code_by_hash_ref(&self, code_hash: B256) -> Result { + self.local.code_by_hash_ref(code_hash) } - fn storage(&self, address: Address, index: U256) -> Result { + fn storage_ref(&self, address: Address, index: U256) -> Result { match self.local.accounts.get(&address) { Some(account) => match account.storage.get(&index) { Some(entry) => Ok(*entry), None => match self.get_storage(address, index) { - None => DatabaseRef::storage(&self.local, address, index), + None => DatabaseRef::storage_ref(&self.local, address, index), Some(storage) => Ok(storage), }, }, None => match self.get_storage(address, index) { - None => DatabaseRef::storage(&self.local, address, index), + None => DatabaseRef::storage_ref(&self.local, address, index), Some(storage) => Ok(storage), }, } } - fn block_hash(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: U256) -> Result { match self.snapshot.block_hashes.get(&number).copied() { - None => self.local.block_hash(number), + None => self.local.block_hash_ref(number), Some(block_hash) => Ok(block_hash), } } diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index 3ee7ec98cce9b..8a57a2349d877 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -1,9 +1,6 @@ use crate::{HitMap, HitMaps}; use alloy_primitives::Bytes; -use revm::{ - interpreter::{InstructionResult, Interpreter}, - Database, EVMData, Inspector, -}; +use revm::{interpreter::Interpreter, Database, EVMData, Inspector}; #[derive(Clone, Default, Debug)] pub struct CoverageCollector { @@ -13,30 +10,18 @@ pub struct CoverageCollector { impl Inspector for CoverageCollector { #[inline] - fn initialize_interp( - &mut self, - interpreter: &mut Interpreter, - _: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn initialize_interp(&mut self, interpreter: &mut Interpreter<'_>, _: &mut EVMData<'_, DB>) { let hash = interpreter.contract.hash; self.maps.entry(hash).or_insert_with(|| { HitMap::new(Bytes::copy_from_slice( interpreter.contract.bytecode.original_bytecode_slice(), )) }); - - InstructionResult::Continue } #[inline] - fn step( - &mut self, - interpreter: &mut Interpreter, - _: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn step(&mut self, interpreter: &mut Interpreter<'_>, _: &mut EVMData<'_, DB>) { let hash = interpreter.contract.hash; self.maps.entry(hash).and_modify(|map| map.hit(interpreter.program_counter())); - - InstructionResult::Continue } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index fdfe0da701da7..4cbdcdb3d813b 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -28,7 +28,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ db::{DatabaseCommit, DatabaseRef}, - interpreter::{return_ok, CreateScheme, InstructionResult, Memory, Stack}, + interpreter::{return_ok, CreateScheme, InstructionResult, SharedMemory, Stack}, primitives::{ BlockEnv, Bytecode, Env, ExecutionResult, Output, ResultAndState, SpecId, TransactTo, TxEnv, }, @@ -94,7 +94,7 @@ impl Executor { trace!("deploying local create2 deployer"); let create2_deployer_account = self .backend - .basic(DEFAULT_CREATE2_DEPLOYER)? + .basic_ref(DEFAULT_CREATE2_DEPLOYER)? .ok_or_else(|| DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; // if the deployer is not currently deployed, deploy the default one @@ -117,7 +117,7 @@ impl Executor { /// Set the balance of an account. pub fn set_balance(&mut self, address: Address, amount: U256) -> DatabaseResult<&mut Self> { trace!(?address, ?amount, "setting account balance"); - let mut account = self.backend.basic(address)?.unwrap_or_default(); + let mut account = self.backend.basic_ref(address)?.unwrap_or_default(); account.balance = amount; self.backend.insert_account_info(address, account); @@ -126,12 +126,12 @@ impl Executor { /// Gets the balance of an account pub fn get_balance(&self, address: Address) -> DatabaseResult { - Ok(self.backend.basic(address)?.map(|acc| acc.balance).unwrap_or_default()) + Ok(self.backend.basic_ref(address)?.map(|acc| acc.balance).unwrap_or_default()) } /// Set the nonce of an account. pub fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<&mut Self> { - let mut account = self.backend.basic(address)?.unwrap_or_default(); + let mut account = self.backend.basic_ref(address)?.unwrap_or_default(); account.nonce = nonce; self.backend.insert_account_info(address, account); @@ -483,7 +483,7 @@ impl Executor { // we only clone the test contract and cheatcode accounts, that's all we need to evaluate // success for addr in [address, CHEATCODE_ADDRESS] { - let acc = self.backend.basic(addr)?.unwrap_or_default(); + let acc = self.backend.basic_ref(addr)?.unwrap_or_default(); backend.insert_account_info(addr, acc); } @@ -682,7 +682,7 @@ pub struct RawCallResult { /// The raw output of the execution pub out: Option, /// The chisel state - pub chisel_state: Option<(Stack, Memory, InstructionResult)>, + pub chisel_state: Option<(Stack, SharedMemory, InstructionResult)>, } impl Default for RawCallResult { diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs index 8d193fb05589d..56ad89729973d 100644 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ b/crates/evm/evm/src/inspectors/access_list.rs @@ -3,7 +3,7 @@ use ethers_core::types::transaction::eip2930::{AccessList, AccessListItem}; use foundry_utils::types::{ToAlloy, ToEthers}; use hashbrown::{HashMap, HashSet}; use revm::{ - interpreter::{opcode, InstructionResult, Interpreter}, + interpreter::{opcode, Interpreter}, Database, EVMData, Inspector, }; @@ -51,11 +51,7 @@ impl AccessListTracer { impl Inspector for AccessListTracer { #[inline] - fn step( - &mut self, - interpreter: &mut Interpreter, - _data: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn step(&mut self, interpreter: &mut Interpreter<'_>, _data: &mut EVMData<'_, DB>) { match interpreter.current_opcode() { opcode::SLOAD | opcode::SSTORE => { if let Ok(slot) = interpreter.stack().peek(0) { @@ -85,6 +81,5 @@ impl Inspector for AccessListTracer { } _ => (), } - InstructionResult::Continue } } diff --git a/crates/evm/evm/src/inspectors/chisel_state.rs b/crates/evm/evm/src/inspectors/chisel_state.rs index 614cafeeb9679..6a32950b80fca 100644 --- a/crates/evm/evm/src/inspectors/chisel_state.rs +++ b/crates/evm/evm/src/inspectors/chisel_state.rs @@ -1,5 +1,5 @@ use revm::{ - interpreter::{InstructionResult, Interpreter, Memory, Stack}, + interpreter::{InstructionResult, Interpreter, SharedMemory, Stack}, Database, Inspector, }; @@ -9,7 +9,7 @@ pub struct ChiselState { /// The PC of the final instruction pub final_pc: usize, /// The final state of the REPL contract call - pub state: Option<(Stack, Memory, InstructionResult)>, + pub state: Option<(Stack, SharedMemory, InstructionResult)>, } impl ChiselState { @@ -22,18 +22,15 @@ impl ChiselState { impl Inspector for ChiselState { #[inline] - fn step_end( - &mut self, - interp: &mut Interpreter, - _: &mut revm::EVMData<'_, DB>, - eval: InstructionResult, - ) -> InstructionResult { + fn step_end(&mut self, interp: &mut Interpreter<'_>, _: &mut revm::EVMData<'_, DB>) { // If we are at the final pc of the REPL contract execution, set the state. // Subtraction can't overflow because `pc` is always at least 1 in `step_end`. if self.final_pc == interp.program_counter() - 1 { - self.state = Some((interp.stack().clone(), interp.memory.clone(), eval)) + self.state = Some(( + interp.stack().clone(), + interp.shared_memory.clone(), + interp.instruction_result, + )) } - // Pass on [revm::Return] from arguments - eval } } diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index be06fc7225592..27782ca474b03 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -45,11 +45,7 @@ impl Debugger { impl Inspector for Debugger { #[inline] - fn step( - &mut self, - interpreter: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn step(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { let pc = interpreter.program_counter(); let op = interpreter.current_opcode(); @@ -77,13 +73,11 @@ impl Inspector for Debugger { self.arena.arena[self.head].steps.push(DebugStep { pc, stack: interpreter.stack().data().clone(), - memory: interpreter.memory.clone(), + memory: interpreter.shared_memory.clone(), instruction: Instruction::OpCode(op), push_bytes, total_gas_used, }); - - InstructionResult::Continue } #[inline] diff --git a/crates/evm/evm/src/inspectors/printer.rs b/crates/evm/evm/src/inspectors/printer.rs index 016e1c2e16309..02a47fda178aa 100644 --- a/crates/evm/evm/src/inspectors/printer.rs +++ b/crates/evm/evm/src/inspectors/printer.rs @@ -11,7 +11,7 @@ pub struct TracePrinter; impl Inspector for TracePrinter { // get opcode by calling `interp.contract.opcode(interp.program_counter())`. // all other information can be obtained from interp. - fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { let opcode = interp.current_opcode(); let opcode_str = opcode::OPCODE_JUMPMAP[opcode as usize]; let gas_remaining = interp.gas.remaining(); @@ -26,11 +26,9 @@ impl Inspector for TracePrinter { interp.gas.refunded(), interp.gas.refunded(), interp.stack.data(), - interp.memory.data().len(), - hex::encode(interp.memory.data()), + interp.shared_memory.len(), + hex::encode(interp.shared_memory.context_memory()), ); - - InstructionResult::Continue } fn call( diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 0bc25df44cb37..34795bca2de29 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -10,7 +10,8 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ interpreter::{ - return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Memory, Stack, + return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, SharedMemory, + Stack, }, primitives::{BlockEnv, Env}, EVMData, Inspector, @@ -191,7 +192,7 @@ pub struct InspectorData { pub coverage: Option, pub cheatcodes: Option, pub script_wallets: Vec, - pub chisel_state: Option<(Stack, Memory, InstructionResult)>, + pub chisel_state: Option<(Stack, SharedMemory, InstructionResult)>, } /// An inspector that calls multiple inspectors in sequence. @@ -354,11 +355,8 @@ impl InspectorStack { } impl Inspector for InspectorStack { - fn initialize_interp( - &mut self, - interpreter: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn initialize_interp(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + let res = interpreter.instruction_result; call_inspectors!( [ &mut self.debugger, @@ -369,23 +367,19 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.initialize_interp(interpreter, data); + inspector.initialize_interp(interpreter, data); // Allow inspectors to exit early - if status != InstructionResult::Continue { - return status + if interpreter.instruction_result != res { + #[allow(clippy::needless_return)] + return } } ); - - InstructionResult::Continue } - fn step( - &mut self, - interpreter: &mut Interpreter, - data: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn step(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + let res = interpreter.instruction_result; call_inspectors!( [ &mut self.fuzzer, @@ -397,16 +391,15 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let status = inspector.step(interpreter, data); + inspector.step(interpreter, data); // Allow inspectors to exit early - if status != InstructionResult::Continue { - return status + if interpreter.instruction_result != res { + #[allow(clippy::needless_return)] + return } } ); - - InstructionResult::Continue } fn log( @@ -424,12 +417,8 @@ impl Inspector for InspectorStack { ); } - fn step_end( - &mut self, - interpreter: &mut Interpreter, - data: &mut EVMData<'_, DB>, - status: InstructionResult, - ) -> InstructionResult { + fn step_end(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + let res = interpreter.instruction_result; call_inspectors!( [ &mut self.debugger, @@ -440,16 +429,15 @@ impl Inspector for InspectorStack { &mut self.chisel_state ], |inspector| { - let status = inspector.step_end(interpreter, data, status); + inspector.step_end(interpreter, data); // Allow inspectors to exit early - if status != InstructionResult::Continue { - return status + if interpreter.instruction_result != res { + #[allow(clippy::needless_return)] + return } } ); - - InstructionResult::Continue } fn call( @@ -471,6 +459,7 @@ impl Inspector for InspectorStack { let (status, gas, retdata) = inspector.call(data, call); // Allow inspectors to exit early + #[allow(clippy::needless_return)] if status != InstructionResult::Continue { return (status, gas, retdata) } diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index fe1b76c58a250..21517805ce3f1 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -20,17 +20,12 @@ pub struct Fuzzer { impl Inspector for Fuzzer { #[inline] - fn step( - &mut self, - interpreter: &mut Interpreter, - _: &mut EVMData<'_, DB>, - ) -> InstructionResult { + fn step(&mut self, interpreter: &mut Interpreter<'_>, _: &mut EVMData<'_, DB>) { // We only collect `stack` and `memory` data before and after calls. if self.collect { self.collect_data(interpreter); self.collect = false; } - InstructionResult::Continue } #[inline] @@ -74,7 +69,7 @@ impl Inspector for Fuzzer { impl Fuzzer { /// Collects `stack` and `memory` values into the fuzz dictionary. - fn collect_data(&mut self, interpreter: &Interpreter) { + fn collect_data(&mut self, interpreter: &Interpreter<'_>) { let mut state = self.fuzz_state.write(); for slot in interpreter.stack().data() { @@ -82,9 +77,9 @@ impl Fuzzer { } // TODO: disabled for now since it's flooding the dictionary - // for index in 0..interpreter.memory.len() / 32 { + // for index in 0..interpreter.shared_memory.len() / 32 { // let mut slot = [0u8; 32]; - // slot.clone_from_slice(interpreter.memory.get_slice(index * 32, 32)); + // slot.clone_from_slice(interpreter.shared_memory.get_slice(index * 32, 32)); // state.insert(slot); // } diff --git a/crates/evm/traces/src/inspector.rs b/crates/evm/traces/src/inspector.rs index 80b34f0f14d31..03f500edda762 100644 --- a/crates/evm/traces/src/inspector.rs +++ b/crates/evm/traces/src/inspector.rs @@ -74,7 +74,7 @@ impl Tracer { } } - fn start_step(&mut self, interp: &Interpreter, data: &EVMData<'_, DB>) { + fn start_step(&mut self, interp: &Interpreter<'_>, data: &EVMData<'_, DB>) { let trace_idx = *self.trace_stack.last().expect("can't start step without starting a trace first"); let node = &mut self.traces.arena[trace_idx]; @@ -87,7 +87,7 @@ impl Tracer { op: OpCode(interp.current_opcode()), contract: interp.contract.address, stack: interp.stack.clone(), - memory: interp.memory.clone(), + memory: interp.shared_memory.clone(), gas: interp.gas.remaining(), gas_refund_counter: interp.gas.refunded() as u64, gas_cost: 0, @@ -96,12 +96,7 @@ impl Tracer { }); } - fn fill_step( - &mut self, - interp: &Interpreter, - data: &EVMData<'_, DB>, - status: InstructionResult, - ) { + fn fill_step(&mut self, interp: &Interpreter<'_>, data: &EVMData<'_, DB>) { let (trace_idx, step_idx) = self.step_stack.pop().expect("can't fill step without starting a step first"); let step = &mut self.traces.arena[trace_idx].trace.steps[step_idx]; @@ -128,32 +123,25 @@ impl Tracer { step.gas_cost = step.gas - interp.gas.remaining(); // Error codes only - if status as u8 > InstructionResult::OutOfGas as u8 { - step.error = Some(format!("{status:?}")); + if interp.instruction_result.is_error() { + step.error = Some(format!("{:?}", interp.instruction_result)); } } } impl Inspector for Tracer { #[inline] - fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult { + fn step(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { if self.record_steps { self.start_step(interp, data); } - InstructionResult::Continue } #[inline] - fn step_end( - &mut self, - interp: &mut Interpreter, - data: &mut EVMData<'_, DB>, - status: InstructionResult, - ) -> InstructionResult { + fn step_end(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { if self.record_steps { - self.fill_step(interp, data, status); + self.fill_step(interp, data); } - status } #[inline] diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 63a08cb8aa191..98b05188d8ffd 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -14,7 +14,7 @@ use foundry_evm_core::{constants::CHEATCODE_ADDRESS, debug::Instruction, utils:: use foundry_utils::types::ToEthers; use hashbrown::HashMap; use itertools::Itertools; -use revm::interpreter::{opcode, CallContext, InstructionResult, Memory, Stack}; +use revm::interpreter::{opcode, CallContext, InstructionResult, SharedMemory, Stack}; use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashSet}, @@ -392,7 +392,7 @@ pub struct CallTraceStep { /// Stack before step execution pub stack: Stack, /// Memory before step execution - pub memory: Memory, + pub memory: SharedMemory, /// Remaining gas before step execution pub gas: u64, /// Gas refund counter before step execution @@ -414,7 +414,7 @@ impl From<&CallTraceStep> for StructLog { error: step.error.clone(), gas: step.gas, gas_cost: step.gas_cost, - memory: Some(convert_memory(step.memory.data())), + memory: Some(convert_memory(step.memory.context_memory())), op: step.op.to_string(), pc: step.pc as u64, refund_counter: if step.gas_refund_counter > 0 { diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 55c128b07f500..8a6c0be8c93d0 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -16,7 +16,11 @@ forgetest_external!( // `run: pnpm --version` is ok, `Command::new("pnpm")` isn't. Good job Windows. #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] snekmate, - "pcaversaccio/snekmate" + "pcaversaccio/snekmate", + // 64MiB memory limit: + // - https://github.com/foundry-rs/foundry/pull/6281 + // - https://github.com/bluealloy/revm/issues/865 + &["--memory-limit", &(1u64 << 26).to_string()] ); // Forking tests diff --git a/deny.toml b/deny.toml index 021da25edd9ec..25b3e6a971a68 100644 --- a/deny.toml +++ b/deny.toml @@ -69,6 +69,7 @@ exceptions = [ { allow = ["CC0-1.0"], name = "notify" }, { allow = ["CC0-1.0"], name = "constant_time_eq" }, { allow = ["CC0-1.0"], name = "dunce" }, + { allow = ["CC0-1.0"], name = "aurora-engine-modexp" }, { allow = ["GPL-3.0"], name = "fastrlp" }, { allow = ["GPL-3.0"], name = "fastrlp-derive" }, From 383e21c9f8bc2083aec0551ca21f62ecc5c73aa4 Mon Sep 17 00:00:00 2001 From: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Fri, 17 Nov 2023 06:00:59 -0800 Subject: [PATCH 0289/1963] feat(cast/bin) : convert value to decimal and add hex value table (#6333) * Update storage.rs * Update storage.rs * Update storage.rs * Update storage.rs --- crates/cast/bin/cmd/storage.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 9d4583217eea6..688af2c4c6304 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -218,21 +218,25 @@ async fn fetch_storage_slots( fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Result<()> { if !pretty { println!("{}", serde_json::to_string_pretty(&serde_json::to_value(layout)?)?); - return Ok(()) + return Ok(()); } let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); - table.set_header(["Name", "Type", "Slot", "Offset", "Bytes", "Value", "Contract"]); + table.set_header(["Name", "Type", "Slot", "Offset", "Bytes", "Value", "Hex Value", "Contract"]); for (slot, value) in layout.storage.into_iter().zip(values) { let storage_type = layout.types.get(&slot.storage_type); + let raw_value_bytes = value.0; + let converted_value = U256::from_be_bytes(raw_value_bytes); + table.add_row([ slot.label.as_str(), storage_type.map_or("?", |t| &t.label), &slot.slot, &slot.offset.to_string(), &storage_type.map_or("?", |t| &t.number_of_bytes), + &converted_value.to_string(), &value.to_string(), &slot.contract, ]); From 9b0472466fd27f3b856c7a5f4be2aae6fb58c367 Mon Sep 17 00:00:00 2001 From: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Fri, 17 Nov 2023 06:22:48 -0800 Subject: [PATCH 0290/1963] fix(anvil) : fix returning type (#6337) * Update api.rs * Update api.rs --- crates/anvil/src/eth/api.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 2f228e54ca49d..947e47f3cce7b 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1708,16 +1708,17 @@ impl EthApi { pub async fn anvil_metadata(&self) -> Result { node_info!("anvil_metadata"); let fork_config = self.backend.get_fork(); - + let chain_id_uint = U256::from(self.backend.chain_id().low_u64()); + let latest_block_number_uint = U64::from(self.backend.best_number().low_u64()); Ok(AnvilMetadata { client_version: CLIENT_VERSION, - chain_id: self.backend.chain_id(), + chain_id: chain_id_uint, latest_block_hash: self.backend.best_hash(), - latest_block_number: self.backend.best_number(), + latest_block_number: latest_block_number_uint, instance_id: *self.instance_id.read(), forked_network: fork_config.map(|cfg| ForkedNetwork { - chain_id: cfg.chain_id().into(), - fork_block_number: cfg.block_number().into(), + chain_id: U256::from(cfg.chain_id()), + fork_block_number: U64::from(cfg.block_number()), fork_block_hash: cfg.block_hash(), }), }) From 8c044be3f3a7b6a0f891f8c87d4be1d5e367635a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:11:51 +0100 Subject: [PATCH 0291/1963] chore: bump default memory limit to 128MiB (#6338) * chore: bump default memory limit to 128MiB * docs * add traces to test fails * fix: test memory limit --- crates/common/src/evm.rs | 5 +- crates/config/README.md | 2 +- crates/config/src/lib.rs | 63 +++++++++++++---------- crates/evm/core/src/opts.rs | 26 ++++++---- crates/evm/evm/src/executors/mod.rs | 20 ++++--- crates/forge/bin/cmd/test/mod.rs | 10 ++-- crates/forge/src/runner.rs | 8 +-- crates/forge/tests/cli/config.rs | 2 +- crates/forge/tests/cli/ext_integration.rs | 6 +-- crates/forge/tests/it/config.rs | 17 +++--- crates/forge/tests/it/test_helpers.rs | 3 +- testdata/foundry.toml | 8 +-- 12 files changed, 90 insertions(+), 80 deletions(-) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index b721d6aafd916..830ae35da3d45 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -242,7 +242,10 @@ pub struct EnvArgs { #[serde(skip_serializing_if = "Option::is_none")] pub block_gas_limit: Option, - /// The memory limit of the EVM in bytes (32 MB by default) + /// The memory limit per EVM execution in bytes. + /// If this limit is exceeded, a `MemoryLimitOOG` result is thrown. + /// + /// The default is 128MiB. #[clap(long, value_name = "MEMORY_LIMIT")] #[serde(skip_serializing_if = "Option::is_none")] pub memory_limit: Option, diff --git a/crates/config/README.md b/crates/config/README.md index 1913cadeeb99c..1fb1370006daf 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -131,7 +131,7 @@ block_timestamp = 0 block_difficulty = 0 block_prevrandao = '0x0000000000000000000000000000000000000000' block_gas_limit = 30000000 -memory_limit = 33554432 +memory_limit = 134217728 extra_output = ["metadata"] extra_output_files = [] names = false diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 378a029118df8..5175775315d5c 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -252,48 +252,55 @@ pub struct Config { /// The chain name or EIP-155 chain ID. #[serde(rename = "chain_id", alias = "chain")] pub chain: Option, - /// Block gas limit + /// Block gas limit. pub gas_limit: GasLimit, /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. pub code_size_limit: Option, - /// `tx.gasprice` value during EVM execution" + /// `tx.gasprice` value during EVM execution. /// /// This is an Option, so we can determine in fork mode whether to use the config's gas price - /// (if set by user) or the remote client's gas price + /// (if set by user) or the remote client's gas price. pub gas_price: Option, - /// the base fee in a block + /// The base fee in a block. pub block_base_fee_per_gas: u64, - /// the `block.coinbase` value during EVM execution + /// The `block.coinbase` value during EVM execution. pub block_coinbase: Address, - /// the `block.timestamp` value during EVM execution + /// The `block.timestamp` value during EVM execution. pub block_timestamp: u64, - /// the `block.difficulty` value during EVM execution + /// The `block.difficulty` value during EVM execution. pub block_difficulty: u64, - /// Before merge the `block.max_hash` after merge it is `block.prevrandao` + /// Before merge the `block.max_hash`, after merge it is `block.prevrandao`. pub block_prevrandao: B256, /// the `block.gaslimit` value during EVM execution pub block_gas_limit: Option, - /// The memory limit of the EVM (32 MB by default) + /// The memory limit per EVM execution in bytes. + /// If this limit is exceeded, a `MemoryLimitOOG` result is thrown. + /// + /// The default is 128MiB. pub memory_limit: u64, - /// Additional output selection for all contracts - /// such as "ir", "devdoc", "storageLayout", etc. - /// See [Solc Compiler Api](https://docs.soliditylang.org/en/latest/using-the-compiler.html#compiler-api) + /// Additional output selection for all contracts, such as "ir", "devdoc", "storageLayout", + /// etc. + /// + /// See the [Solc Compiler Api](https://docs.soliditylang.org/en/latest/using-the-compiler.html#compiler-api) for more information. /// - /// The following values are always set because they're required by `forge` - //{ - // "*": [ - // "abi", - // "evm.bytecode", - // "evm.deployedBytecode", - // "evm.methodIdentifiers" - // ] - // } - // "# + /// The following values are always set because they're required by `forge`: + /// ```json + /// { + /// "*": [ + /// "abi", + /// "evm.bytecode", + /// "evm.deployedBytecode", + /// "evm.methodIdentifiers" + /// ] + /// } + /// ``` #[serde(default)] pub extra_output: Vec, - /// If set , a separate `json` file will be emitted for every contract depending on the + /// If set, a separate JSON file will be emitted for every contract depending on the /// selection, eg. `extra_output_files = ["metadata"]` will create a `metadata.json` for - /// each contract in the project. See [Contract Metadata](https://docs.soliditylang.org/en/latest/metadata.html) + /// each contract in the project. + /// + /// See [Contract Metadata](https://docs.soliditylang.org/en/latest/metadata.html) for more information. /// /// The difference between `extra_output = ["metadata"]` and /// `extra_output_files = ["metadata"]` is that the former will include the @@ -301,9 +308,9 @@ pub struct Config { /// output selection as separate files. #[serde(default)] pub extra_output_files: Vec, - /// Print the names of the compiled contracts + /// Whether to print the names of the compiled contracts. pub names: bool, - /// Print the sizes of the compiled contracts + /// Whether to print the sizes of the compiled contracts. pub sizes: bool, /// If set to true, changes compilation pipeline to go through the Yul intermediate /// representation. @@ -1795,7 +1802,7 @@ impl Default for Config { block_difficulty: 0, block_prevrandao: Default::default(), block_gas_limit: None, - memory_limit: 1 << 25, // 32MiB = 33554432 bytes + memory_limit: 1 << 27, // 2**27 = 128MiB = 134_217_728 bytes eth_rpc_url: None, eth_rpc_jwt: None, etherscan_api_key: None, @@ -3379,7 +3386,7 @@ mod tests { initial_balance = '0xffffffffffffffffffffffff' libraries = [] libs = ['lib'] - memory_limit = 33554432 + memory_limit = 134217728 names = false no_storage_caching = false no_rpc_rate_limit = false diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index bc364bc51b455..1ccac43d42257 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -12,44 +12,48 @@ use serde::{Deserialize, Deserializer, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct EvmOpts { + /// The EVM environment configuration. #[serde(flatten)] pub env: Env, - /// Fetch state over a remote instead of starting from empty state + /// Fetch state over a remote instead of starting from empty state. #[serde(rename = "eth_rpc_url")] pub fork_url: Option, - /// pins the block number for the state fork + /// Pins the block number for the state fork. pub fork_block_number: Option, - /// The number of retries + /// The number of retries. pub fork_retries: Option, - /// initial retry backoff + /// Initial retry backoff. pub fork_retry_backoff: Option, - /// The available compute units per second + /// The available compute units per second. + /// + /// See also pub compute_units_per_second: Option, - /// Disables rate limiting entirely. + /// Disables RPC rate limiting entirely. pub no_rpc_rate_limit: bool, /// Disables storage caching entirely. pub no_storage_caching: bool, - /// the initial balance of each deployed test contract + /// The initial balance of each deployed test contract. pub initial_balance: U256, - /// the address which will be executing all tests + /// The address which will be executing all tests. pub sender: Address, - /// enables the FFI cheatcode + /// Enables the FFI cheatcode. pub ffi: bool, - /// Verbosity mode of EVM output as number of occurrences + /// Verbosity mode of EVM output as number of occurrences. pub verbosity: u8, - /// The memory limit of the EVM in bytes. + /// The memory limit per EVM execution in bytes. + /// If this limit is exceeded, a `MemoryLimitOOG` result is thrown. pub memory_limit: u64, } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 4cbdcdb3d813b..234757a907d80 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -489,26 +489,24 @@ impl Executor { // If this test failed any asserts, then this changeset will contain changes `false -> true` // for the contract's `failed` variable and the `globalFailure` flag in the state of the - // cheatcode address which are both read when call `"failed()(bool)"` in the next step + // cheatcode address which are both read when we call `"failed()(bool)"` in the next step backend.commit(state_changeset); - let executor = - Executor::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); let mut success = !reverted; if success { // Check if a DSTest assertion failed - let call = - executor.call::<_, _>(CALLER, address, "failed()(bool)", vec![], U256::ZERO, None); - + let executor = + Executor::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); + let call = executor.call(CALLER, address, "failed()(bool)", vec![], U256::ZERO, None); if let Ok(CallResult { result: failed, .. }) = call { - let failed = failed - .as_bool() - .expect("Failed to decode DSTest `failed` variable. This is a bug"); - success = !failed; + debug!(?failed, "DSTest"); + success = !failed.as_bool().unwrap(); } } - Ok(should_fail ^ success) + let result = should_fail ^ success; + debug!(should_fail, success, result); + Ok(result) } /// Creates the environment to use when executing a transaction in a test context diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1ad5488701acb..42040a03744f4 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -208,10 +208,10 @@ impl TestArgs { filter.args_mut().test_pattern = self.debug.clone(); let num_filtered = runner.matching_test_function_count(&filter); if num_filtered != 1 { - return Err( - eyre::eyre!("{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n - \n - Use --match-contract and --match-path to further limit the search.")); + eyre::bail!( + "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n\n\ + Use --match-contract and --match-path to further limit the search." + ); } let test_funcs = runner.get_matching_test_functions(&filter); // if we debug a fuzz test, we should not collect data on the first run @@ -441,7 +441,7 @@ impl Test { } /// Represents the bundled results of all tests -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct TestOutcome { /// Whether failures are allowed pub allow_failure: bool, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 7d781098771fc..36c3001a95f00 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -183,7 +183,7 @@ impl<'a> ContractRunner<'a> { let needs_setup = setup_fns.len() == 1 && setup_fns[0].name == "setUp"; // There is a single miss-cased `setUp` function, so we add a warning - for setup_fn in setup_fns.iter() { + for &setup_fn in setup_fns.iter() { if setup_fn.name != "setUp" { warnings.push(format!( "Found invalid setup function \"{}\" did you mean \"setUp()\"?", @@ -387,8 +387,10 @@ impl<'a> ContractRunner<'a> { // Record test execution time debug!( duration = ?start.elapsed(), - %success, - %gas + gas, + reverted, + should_fail, + success, ); TestResult { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 74aa16e45fc6d..27001b7321720 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -79,7 +79,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { block_difficulty: 10, block_prevrandao: B256::random(), block_gas_limit: Some(100u64.into()), - memory_limit: 2u64.pow(25), + memory_limit: 1 << 27, eth_rpc_url: Some("localhost".to_string()), eth_rpc_jwt: None, etherscan_api_key: None, diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 8a6c0be8c93d0..55c128b07f500 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -16,11 +16,7 @@ forgetest_external!( // `run: pnpm --version` is ok, `Command::new("pnpm")` isn't. Good job Windows. #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] snekmate, - "pcaversaccio/snekmate", - // 64MiB memory limit: - // - https://github.com/foundry-rs/foundry/pull/6281 - // - https://github.com/bluealloy/revm/issues/865 - &["--memory-limit", &(1u64 << 26).to_string()] + "pcaversaccio/snekmate" ); // Forking tests diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 95d03110fff91..b9473b1526f2d 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -13,10 +13,8 @@ use foundry_evm::{ decode::decode_console_logs, inspectors::CheatsConfig, revm::primitives::SpecId, }; use foundry_test_utils::Filter; -use std::{ - collections::BTreeMap, - path::{Path, PathBuf}, -}; +use itertools::Itertools; +use std::{collections::BTreeMap, path::Path}; /// How to execute a a test run pub struct TestConfig { @@ -82,11 +80,12 @@ impl TestConfig { let outcome = if self.should_fail { "fail" } else { "pass" }; eyre::bail!( - "Test {} did not {} as expected.\nReason: {:?}\nLogs:\n{}", + "Test {} did not {} as expected.\nReason: {:?}\nLogs:\n{}\n\nTraces:\n{}", test_name, outcome, result.reason, - logs.join("\n") + logs.join("\n"), + result.traces.iter().map(|(_, a)| a).format("\n"), ) } } @@ -136,14 +135,14 @@ pub(crate) fn init_tracing() { .try_init(); } -pub fn manifest_root() -> PathBuf { +pub fn manifest_root() -> &'static Path { let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); // need to check here where we're executing the test from, if in `forge` we need to also allow // `testdata` if root.ends_with("forge") { root = root.parent().unwrap(); } - root.to_path_buf() + root } /// Builds a base runner @@ -161,7 +160,7 @@ pub async fn runner() -> MultiContractRunner { /// Builds a non-tracing runner pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { config.rpc_endpoints = rpc_endpoints(); - config.allow_paths.push(manifest_root()); + config.allow_paths.push(manifest_root().to_path_buf()); let root = &PROJECT.paths.root; let opts = &*EVM_OPTS; diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index cfbbc015162f6..37393525f5978 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -72,7 +72,8 @@ pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { sender: Config::DEFAULT_SENDER, initial_balance: U256::MAX, ffi: true, - memory_limit: 1 << 24, + verbosity: 3, + memory_limit: 1 << 26, ..Default::default() }); diff --git a/testdata/foundry.toml b/testdata/foundry.toml index d696945d0640f..94bdeea394937 100644 --- a/testdata/foundry.toml +++ b/testdata/foundry.toml @@ -1,5 +1,5 @@ [profile.default] -solc = "0.8.19" +solc = "0.8.18" block_base_fee_per_gas = 0 block_coinbase = "0x0000000000000000000000000000000000000000" block_difficulty = 0 @@ -36,10 +36,10 @@ remappings = ["ds-test/=lib/ds-test/src/"] sender = "0x00a329c0648769a73afac7f9381e08fb43dbea72" sizes = false sparse_mode = false -src = "src" -test = "test" +src = "./" +test = "./" tx_origin = "0x00a329c0648769a73afac7f9381e08fb43dbea72" -verbosity = 0 +verbosity = 3 via_ir = false fs_permissions = [{ access = "read-write", path = "./" }] From daefe5e5442cf1d477e9f51408eaff3ca00ec2c8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:44:04 +0100 Subject: [PATCH 0292/1963] test: add an expectRevert test (#6340) --- testdata/cheats/ExpectRevert.t.sol | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/testdata/cheats/ExpectRevert.t.sol b/testdata/cheats/ExpectRevert.t.sol index 00200477bf748..8e67c4ad2f91c 100644 --- a/testdata/cheats/ExpectRevert.t.sol +++ b/testdata/cheats/ExpectRevert.t.sol @@ -8,7 +8,7 @@ contract Reverter { error CustomError(); function revertWithMessage(string memory message) public pure { - require(false, message); + revert(message); } function doNotRevert() public pure {} @@ -27,7 +27,7 @@ contract Reverter { function callThenRevert(Dummy dummy, string memory message) public pure { dummy.callMe(); - require(false, message); + revert(message); } function revertWithoutReason() public pure { @@ -37,7 +37,7 @@ contract Reverter { contract ConstructorReverter { constructor(string memory message) { - require(false, message); + revert(message); } } @@ -63,7 +63,7 @@ contract Dummy { } function largeReturnType() public pure returns (LargeDummyStruct memory) { - require(false, "reverted with large return type"); + revert("reverted with large return type"); } } @@ -80,6 +80,12 @@ contract ExpectRevertTest is DSTest { reverter.revertWithMessage("revert"); } + function testFailExpectRevertWrongString() public { + Reverter reverter = new Reverter(); + vm.expectRevert("my not so cool error"); + reverter.revertWithMessage("my cool error"); + } + function testFailRevertNotOnImmediateNextCall() public { Reverter reverter = new Reverter(); // expectRevert should only work for the next call. However, From a8cb7f8e7a4b8a8125e297f9e6805bca896a7e73 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:45:05 +0100 Subject: [PATCH 0293/1963] chore: use repo license in tests too (#6339) --- crates/forge/tests/cli/svm.rs | 1 - crates/forge/tests/fixtures/ScriptVerify.sol | 2 +- testdata/cheats/Addr.t.sol | 2 +- testdata/cheats/Assume.t.sol | 2 +- testdata/cheats/Bank.t.sol | 2 +- testdata/cheats/Broadcast.t.sol | 2 +- testdata/cheats/ChainId.t.sol | 2 +- testdata/cheats/Cool.t.sol | 2 +- testdata/cheats/Deal.t.sol | 2 +- testdata/cheats/Derive.t.sol | 2 +- testdata/cheats/Env.t.sol | 2 +- testdata/cheats/Etch.t.sol | 2 +- testdata/cheats/ExpectCall.t.sol | 2 +- testdata/cheats/ExpectEmit.t.sol | 2 +- testdata/cheats/ExpectRevert.t.sol | 2 +- testdata/cheats/Fee.t.sol | 2 +- testdata/cheats/Ffi.t.sol | 2 +- testdata/cheats/Fork.t.sol | 2 +- testdata/cheats/Fork2.t.sol | 2 +- testdata/cheats/Fs.t.sol | 2 +- testdata/cheats/GasMetering.t.sol | 2 +- testdata/cheats/GetCode.t.sol | 2 +- testdata/cheats/GetDeployedCode.t.sol | 2 +- testdata/cheats/GetLabel.t.sol | 2 +- testdata/cheats/GetNonce.t.sol | 2 +- testdata/cheats/Json.t.sol | 2 +- testdata/cheats/Label.t.sol | 2 +- testdata/cheats/Load.t.sol | 2 +- testdata/cheats/Mapping.t.sol | 2 +- testdata/cheats/MemSafety.t.sol | 2 +- testdata/cheats/MockCall.t.sol | 2 +- testdata/cheats/Parse.t.sol | 2 +- testdata/cheats/Prank.t.sol | 2 +- testdata/cheats/Prevrandao.t.sol | 2 +- testdata/cheats/ProjectRoot.t.sol | 2 +- testdata/cheats/ReadCallers.t.sol | 2 +- testdata/cheats/Record.t.sol | 2 +- testdata/cheats/RecordLogs.t.sol | 2 +- testdata/cheats/Remember.t.sol | 2 +- testdata/cheats/ResetNonce.t.sol | 2 +- testdata/cheats/Roll.t.sol | 2 +- testdata/cheats/RpcUrls.t.sol | 2 +- testdata/cheats/SetNonce.t.sol | 2 +- testdata/cheats/SetNonceUnsafe.t.sol | 2 +- testdata/cheats/Setup.t.sol | 2 +- testdata/cheats/Sign.t.sol | 2 +- testdata/cheats/Skip.t.sol | 2 +- testdata/cheats/Sleep.t.sol | 2 +- testdata/cheats/Snapshots.t.sol | 2 +- testdata/cheats/Store.t.sol | 2 +- testdata/cheats/ToString.t.sol | 2 +- testdata/cheats/Travel.t.sol | 2 +- testdata/cheats/TryFfi.sol | 2 +- testdata/cheats/UnixTime.t.sol | 2 +- testdata/cheats/Wallet.t.sol | 2 +- testdata/cheats/Warp.t.sol | 2 +- testdata/cheats/loadAllocs.t.sol | 2 +- testdata/core/Abstract.t.sol | 2 +- testdata/core/ContractEnvironment.t.sol | 2 +- testdata/core/DSStyle.t.sol | 2 +- testdata/core/FailingSetup.t.sol | 2 +- testdata/core/FailingTestAfterFailedSetup.t.sol | 2 +- testdata/core/MultipleSetup.t.sol | 2 +- testdata/core/PaymentFailure.t.sol | 2 +- testdata/core/Reverting.t.sol | 2 +- testdata/core/SetupConsistency.t.sol | 2 +- testdata/fixtures/GetCode/Override.sol | 2 +- testdata/fixtures/GetCode/UnlinkedContract.sol | 2 +- testdata/fixtures/GetCode/WorkingContract.sol | 2 +- testdata/fork/ForkSame_1.t.sol | 2 +- testdata/fork/ForkSame_2.t.sol | 2 +- testdata/fork/LaunchFork.t.sol | 2 +- testdata/fork/Transact.t.sol | 2 +- testdata/fs/Default.t.sol | 2 +- testdata/fs/Disabled.t.sol | 2 +- testdata/fuzz/Fuzz.t.sol | 2 +- testdata/fuzz/FuzzInt.t.sol | 2 +- testdata/fuzz/FuzzUint.t.sol | 2 +- testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol | 2 +- testdata/fuzz/invariant/common/InvariantInnerContract.t.sol | 2 +- testdata/fuzz/invariant/common/InvariantReentrancy.t.sol | 2 +- testdata/fuzz/invariant/common/InvariantTest1.t.sol | 2 +- testdata/fuzz/invariant/target/ExcludeContracts.t.sol | 2 +- testdata/fuzz/invariant/target/ExcludeSenders.t.sol | 2 +- testdata/fuzz/invariant/target/TargetContracts.t.sol | 2 +- testdata/fuzz/invariant/target/TargetInterfaces.t.sol | 2 +- testdata/fuzz/invariant/target/TargetSelectors.t.sol | 2 +- testdata/fuzz/invariant/target/TargetSenders.t.sol | 2 +- testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol | 2 +- testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol | 2 +- .../fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol | 2 +- testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol | 2 +- testdata/inline/FuzzInlineConf.t.sol | 2 +- testdata/inline/InvariantInlineConf.t.sol | 2 +- testdata/linking/duplicate/Duplicate.t.sol | 2 +- testdata/linking/nested/Nested.t.sol | 2 +- testdata/linking/simple/Simple.t.sol | 2 +- testdata/logs/HardhatLogs.t.sol | 2 +- testdata/logs/console.sol | 2 +- testdata/repros/Issue2623.t.sol | 2 +- testdata/repros/Issue2629.t.sol | 2 +- testdata/repros/Issue2723.t.sol | 2 +- testdata/repros/Issue2898.t.sol | 2 +- testdata/repros/Issue2956.t.sol | 2 +- testdata/repros/Issue2984.t.sol | 2 +- testdata/repros/Issue3055.t.sol | 2 +- testdata/repros/Issue3077.t.sol | 2 +- testdata/repros/Issue3110.t.sol | 2 +- testdata/repros/Issue3119.t.sol | 2 +- testdata/repros/Issue3189.t.sol | 2 +- testdata/repros/Issue3190.t.sol | 2 +- testdata/repros/Issue3192.t.sol | 2 +- testdata/repros/Issue3220.t.sol | 2 +- testdata/repros/Issue3221.sol | 2 +- testdata/repros/Issue3223.sol | 2 +- testdata/repros/Issue3347.sol | 2 +- testdata/repros/Issue3437.t.sol | 2 +- testdata/repros/Issue3596.t.sol | 2 +- testdata/repros/Issue3653.t.sol | 2 +- testdata/repros/Issue3661.sol | 2 +- testdata/repros/Issue3674.t.sol | 2 +- testdata/repros/Issue3685.t.sol | 2 +- testdata/repros/Issue3703.t.sol | 2 +- testdata/repros/Issue3708.sol | 2 +- testdata/repros/Issue3723.t.sol | 2 +- testdata/repros/Issue3753.t.sol | 2 +- testdata/repros/Issue3792.t.sol | 2 +- testdata/repros/Issue4586.t.sol | 2 +- testdata/repros/Issue4630.t.sol | 2 +- testdata/repros/Issue4640.t.sol | 2 +- testdata/repros/Issue4832.t.sol | 2 +- testdata/repros/Issue6170.t.sol | 2 +- testdata/repros/Issue6180.sol | 2 +- testdata/script/deploy.sol | 2 +- testdata/spec/ShanghaiCompat.t.sol | 2 +- 135 files changed, 134 insertions(+), 135 deletions(-) diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 7b0b38bce59d9..08df1e3f815a6 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -44,7 +44,6 @@ ensure_svm_releases!( forgetest_init!(can_test_with_latest_solc, |prj, cmd| { let src = format!( r#" -// SPDX-License-Identifier: UNLICENSED pragma solidity ={LATEST_SOLC}; import "forge-std/Test.sol"; diff --git a/crates/forge/tests/fixtures/ScriptVerify.sol b/crates/forge/tests/fixtures/ScriptVerify.sol index e282f9e5c3871..4ff4c07505cb6 100644 --- a/crates/forge/tests/fixtures/ScriptVerify.sol +++ b/crates/forge/tests/fixtures/ScriptVerify.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity =0.8.16; import {Unique} from "./unique.sol"; diff --git a/testdata/cheats/Addr.t.sol b/testdata/cheats/Addr.t.sol index e326b5cac1029..39f14f6aab572 100644 --- a/testdata/cheats/Addr.t.sol +++ b/testdata/cheats/Addr.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Assume.t.sol b/testdata/cheats/Assume.t.sol index d27afe5e0c32e..7520cfd6d1c2e 100644 --- a/testdata/cheats/Assume.t.sol +++ b/testdata/cheats/Assume.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Bank.t.sol b/testdata/cheats/Bank.t.sol index a4c48d5d6ce47..31feed4988107 100644 --- a/testdata/cheats/Bank.t.sol +++ b/testdata/cheats/Bank.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Broadcast.t.sol b/testdata/cheats/Broadcast.t.sol index c7d05acb7c501..2e3b0ea6abda0 100644 --- a/testdata/cheats/Broadcast.t.sol +++ b/testdata/cheats/Broadcast.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ChainId.t.sol b/testdata/cheats/ChainId.t.sol index ab6f7357e21cf..af5312241558c 100644 --- a/testdata/cheats/ChainId.t.sol +++ b/testdata/cheats/ChainId.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Cool.t.sol b/testdata/cheats/Cool.t.sol index 674b9abbd3426..d721a442d0123 100644 --- a/testdata/cheats/Cool.t.sol +++ b/testdata/cheats/Cool.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "../lib/ds-test/src/test.sol"; diff --git a/testdata/cheats/Deal.t.sol b/testdata/cheats/Deal.t.sol index 2189bc0ac93b9..2729ac73e8037 100644 --- a/testdata/cheats/Deal.t.sol +++ b/testdata/cheats/Deal.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Derive.t.sol b/testdata/cheats/Derive.t.sol index e80790e8b958c..e2107e80cd998 100644 --- a/testdata/cheats/Derive.t.sol +++ b/testdata/cheats/Derive.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Env.t.sol b/testdata/cheats/Env.t.sol index 44e5f5db71fac..179f2c2998e35 100644 --- a/testdata/cheats/Env.t.sol +++ b/testdata/cheats/Env.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Etch.t.sol b/testdata/cheats/Etch.t.sol index 33d957dab86a2..81e70d37de4ad 100644 --- a/testdata/cheats/Etch.t.sol +++ b/testdata/cheats/Etch.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ExpectCall.t.sol b/testdata/cheats/ExpectCall.t.sol index 2b08adab1d43d..2fb33d91fcaa2 100644 --- a/testdata/cheats/ExpectCall.t.sol +++ b/testdata/cheats/ExpectCall.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ExpectEmit.t.sol b/testdata/cheats/ExpectEmit.t.sol index 599a14e808c46..b232ab36b3d54 100644 --- a/testdata/cheats/ExpectEmit.t.sol +++ b/testdata/cheats/ExpectEmit.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ExpectRevert.t.sol b/testdata/cheats/ExpectRevert.t.sol index 8e67c4ad2f91c..9fdeb2fef9d43 100644 --- a/testdata/cheats/ExpectRevert.t.sol +++ b/testdata/cheats/ExpectRevert.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Fee.t.sol b/testdata/cheats/Fee.t.sol index d5104ead376f9..3d6ea72a8bd01 100644 --- a/testdata/cheats/Fee.t.sol +++ b/testdata/cheats/Fee.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Ffi.t.sol b/testdata/cheats/Ffi.t.sol index d6cdc02455113..2aa2175e25117 100644 --- a/testdata/cheats/Ffi.t.sol +++ b/testdata/cheats/Ffi.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Fork.t.sol b/testdata/cheats/Fork.t.sol index f59556ad7f60f..0b64b9eb18699 100644 --- a/testdata/cheats/Fork.t.sol +++ b/testdata/cheats/Fork.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Fork2.t.sol b/testdata/cheats/Fork2.t.sol index e67e82ea7345a..c4cab03b880c5 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/cheats/Fork2.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Fs.t.sol b/testdata/cheats/Fs.t.sol index 9b53e92ee979f..c1f79c15a621d 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/cheats/Fs.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/GasMetering.t.sol b/testdata/cheats/GasMetering.t.sol index 030e3e84e51b0..e5616634fac3d 100644 --- a/testdata/cheats/GasMetering.t.sol +++ b/testdata/cheats/GasMetering.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/GetCode.t.sol b/testdata/cheats/GetCode.t.sol index 1d91fca302026..db8841f60dc0b 100644 --- a/testdata/cheats/GetCode.t.sol +++ b/testdata/cheats/GetCode.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/GetDeployedCode.t.sol b/testdata/cheats/GetDeployedCode.t.sol index 926945049bc0f..71020af18448b 100644 --- a/testdata/cheats/GetDeployedCode.t.sol +++ b/testdata/cheats/GetDeployedCode.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/GetLabel.t.sol b/testdata/cheats/GetLabel.t.sol index 0cf3d02423558..784a18cea0d70 100644 --- a/testdata/cheats/GetLabel.t.sol +++ b/testdata/cheats/GetLabel.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; import "ds-test/test.sol"; diff --git a/testdata/cheats/GetNonce.t.sol b/testdata/cheats/GetNonce.t.sol index eb45ef874011b..8d3a196466b7d 100644 --- a/testdata/cheats/GetNonce.t.sol +++ b/testdata/cheats/GetNonce.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Json.t.sol b/testdata/cheats/Json.t.sol index 68164d3a01531..b4b7059979307 100644 --- a/testdata/cheats/Json.t.sol +++ b/testdata/cheats/Json.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Label.t.sol b/testdata/cheats/Label.t.sol index a0fbe3ab4ef00..b8e29d195a05f 100644 --- a/testdata/cheats/Label.t.sol +++ b/testdata/cheats/Label.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Load.t.sol b/testdata/cheats/Load.t.sol index b1328255e1ef0..fa5680d71bed5 100644 --- a/testdata/cheats/Load.t.sol +++ b/testdata/cheats/Load.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Mapping.t.sol b/testdata/cheats/Mapping.t.sol index 36678b413113b..4dec4156b7605 100644 --- a/testdata/cheats/Mapping.t.sol +++ b/testdata/cheats/Mapping.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; import "ds-test/test.sol"; diff --git a/testdata/cheats/MemSafety.t.sol b/testdata/cheats/MemSafety.t.sol index d29b895bf6dc7..0da135d0c2a8a 100644 --- a/testdata/cheats/MemSafety.t.sol +++ b/testdata/cheats/MemSafety.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/MockCall.t.sol b/testdata/cheats/MockCall.t.sol index 8203b9de1b0e4..fa7d9f31449c8 100644 --- a/testdata/cheats/MockCall.t.sol +++ b/testdata/cheats/MockCall.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Parse.t.sol b/testdata/cheats/Parse.t.sol index dc43174e0faba..a39d32d084b41 100644 --- a/testdata/cheats/Parse.t.sol +++ b/testdata/cheats/Parse.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Prank.t.sol b/testdata/cheats/Prank.t.sol index 01b3f2ccbcb1d..fa28f0c92a96f 100644 --- a/testdata/cheats/Prank.t.sol +++ b/testdata/cheats/Prank.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Prevrandao.t.sol b/testdata/cheats/Prevrandao.t.sol index beed5d71f73b2..20bab12c4168b 100644 --- a/testdata/cheats/Prevrandao.t.sol +++ b/testdata/cheats/Prevrandao.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ProjectRoot.t.sol b/testdata/cheats/ProjectRoot.t.sol index 9f22b61fe3fa3..1edfb0e0795f5 100644 --- a/testdata/cheats/ProjectRoot.t.sol +++ b/testdata/cheats/ProjectRoot.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ReadCallers.t.sol b/testdata/cheats/ReadCallers.t.sol index e733c57a53510..82210b6c47410 100644 --- a/testdata/cheats/ReadCallers.t.sol +++ b/testdata/cheats/ReadCallers.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; import "ds-test/test.sol"; diff --git a/testdata/cheats/Record.t.sol b/testdata/cheats/Record.t.sol index 6aed8a5f5983d..6fdfa627d24ae 100644 --- a/testdata/cheats/Record.t.sol +++ b/testdata/cheats/Record.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/RecordLogs.t.sol b/testdata/cheats/RecordLogs.t.sol index 34337c6df1ce0..25fbfaeba43f8 100644 --- a/testdata/cheats/RecordLogs.t.sol +++ b/testdata/cheats/RecordLogs.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Remember.t.sol b/testdata/cheats/Remember.t.sol index e17b43c421ebf..5592081ea47e0 100644 --- a/testdata/cheats/Remember.t.sol +++ b/testdata/cheats/Remember.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ResetNonce.t.sol b/testdata/cheats/ResetNonce.t.sol index 5c0bd77b68419..914577bdcc060 100644 --- a/testdata/cheats/ResetNonce.t.sol +++ b/testdata/cheats/ResetNonce.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; import "ds-test/test.sol"; diff --git a/testdata/cheats/Roll.t.sol b/testdata/cheats/Roll.t.sol index b7bd9ab9b5d7d..50011fe87e127 100644 --- a/testdata/cheats/Roll.t.sol +++ b/testdata/cheats/Roll.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/RpcUrls.t.sol b/testdata/cheats/RpcUrls.t.sol index 8fa26e31b6f54..c974bf1475369 100644 --- a/testdata/cheats/RpcUrls.t.sol +++ b/testdata/cheats/RpcUrls.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/SetNonce.t.sol b/testdata/cheats/SetNonce.t.sol index f94a7c1c5fd44..9285ca7e6293f 100644 --- a/testdata/cheats/SetNonce.t.sol +++ b/testdata/cheats/SetNonce.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/SetNonceUnsafe.t.sol b/testdata/cheats/SetNonceUnsafe.t.sol index b1989d3312374..1209a28147b2a 100644 --- a/testdata/cheats/SetNonceUnsafe.t.sol +++ b/testdata/cheats/SetNonceUnsafe.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Setup.t.sol b/testdata/cheats/Setup.t.sol index 6cf240f0370d7..986b232d84410 100644 --- a/testdata/cheats/Setup.t.sol +++ b/testdata/cheats/Setup.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Sign.t.sol b/testdata/cheats/Sign.t.sol index 986d9243f3688..587d80e5fea7b 100644 --- a/testdata/cheats/Sign.t.sol +++ b/testdata/cheats/Sign.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Skip.t.sol b/testdata/cheats/Skip.t.sol index 3107d5ec9e723..b5f8a019b340f 100644 --- a/testdata/cheats/Skip.t.sol +++ b/testdata/cheats/Skip.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Sleep.t.sol b/testdata/cheats/Sleep.t.sol index 7b592f3f3f765..3af2ea3c0072b 100644 --- a/testdata/cheats/Sleep.t.sol +++ b/testdata/cheats/Sleep.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Snapshots.t.sol b/testdata/cheats/Snapshots.t.sol index 3ce7246104f56..9a174be98c524 100644 --- a/testdata/cheats/Snapshots.t.sol +++ b/testdata/cheats/Snapshots.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Store.t.sol b/testdata/cheats/Store.t.sol index bc93bae412425..08803b92fde32 100644 --- a/testdata/cheats/Store.t.sol +++ b/testdata/cheats/Store.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/ToString.t.sol b/testdata/cheats/ToString.t.sol index 0b08db4a888e7..c26fdce4cb2da 100644 --- a/testdata/cheats/ToString.t.sol +++ b/testdata/cheats/ToString.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Travel.t.sol b/testdata/cheats/Travel.t.sol index 01196aa1aba0c..297017852d69e 100644 --- a/testdata/cheats/Travel.t.sol +++ b/testdata/cheats/Travel.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/TryFfi.sol b/testdata/cheats/TryFfi.sol index 4702fd61d8c95..745b65ce09e4b 100644 --- a/testdata/cheats/TryFfi.sol +++ b/testdata/cheats/TryFfi.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/UnixTime.t.sol b/testdata/cheats/UnixTime.t.sol index 8a03ee9ca5128..66cbcc395004a 100644 --- a/testdata/cheats/UnixTime.t.sol +++ b/testdata/cheats/UnixTime.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Wallet.t.sol b/testdata/cheats/Wallet.t.sol index cccb874bdb0fa..a8ce5cc020179 100644 --- a/testdata/cheats/Wallet.t.sol +++ b/testdata/cheats/Wallet.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/Warp.t.sol b/testdata/cheats/Warp.t.sol index 0d103080263e4..0400099f8a3a5 100644 --- a/testdata/cheats/Warp.t.sol +++ b/testdata/cheats/Warp.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/cheats/loadAllocs.t.sol b/testdata/cheats/loadAllocs.t.sol index 1f08e22e422d9..f219d025e1f94 100644 --- a/testdata/cheats/loadAllocs.t.sol +++ b/testdata/cheats/loadAllocs.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/core/Abstract.t.sol b/testdata/core/Abstract.t.sol index 043875be6f33f..fee06bbe64e13 100644 --- a/testdata/core/Abstract.t.sol +++ b/testdata/core/Abstract.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; contract TestFixture { diff --git a/testdata/core/ContractEnvironment.t.sol b/testdata/core/ContractEnvironment.t.sol index 6abc3714286da..cc5facd9284ba 100644 --- a/testdata/core/ContractEnvironment.t.sol +++ b/testdata/core/ContractEnvironment.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/core/DSStyle.t.sol b/testdata/core/DSStyle.t.sol index fc08653338666..400b707b68765 100644 --- a/testdata/core/DSStyle.t.sol +++ b/testdata/core/DSStyle.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/core/FailingSetup.t.sol b/testdata/core/FailingSetup.t.sol index 19a79c266a190..37a3b9ac26ca1 100644 --- a/testdata/core/FailingSetup.t.sol +++ b/testdata/core/FailingSetup.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/core/FailingTestAfterFailedSetup.t.sol b/testdata/core/FailingTestAfterFailedSetup.t.sol index 17b9b191e28b8..eeb5c207e4df5 100644 --- a/testdata/core/FailingTestAfterFailedSetup.t.sol +++ b/testdata/core/FailingTestAfterFailedSetup.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/core/MultipleSetup.t.sol b/testdata/core/MultipleSetup.t.sol index 75ae20e856d6f..412b3fb4c28e0 100644 --- a/testdata/core/MultipleSetup.t.sol +++ b/testdata/core/MultipleSetup.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/core/PaymentFailure.t.sol b/testdata/core/PaymentFailure.t.sol index 3aa3540114525..21558cf9cfa27 100644 --- a/testdata/core/PaymentFailure.t.sol +++ b/testdata/core/PaymentFailure.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/core/Reverting.t.sol b/testdata/core/Reverting.t.sol index 7699755647bc2..36fdd99bcbde7 100644 --- a/testdata/core/Reverting.t.sol +++ b/testdata/core/Reverting.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; contract RevertingTest { diff --git a/testdata/core/SetupConsistency.t.sol b/testdata/core/SetupConsistency.t.sol index cce58ed5c7684..dfc6a9ab4e8b0 100644 --- a/testdata/core/SetupConsistency.t.sol +++ b/testdata/core/SetupConsistency.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fixtures/GetCode/Override.sol b/testdata/fixtures/GetCode/Override.sol index 1c3875650c17a..f520bf0df02f4 100644 --- a/testdata/fixtures/GetCode/Override.sol +++ b/testdata/fixtures/GetCode/Override.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.13; contract Override { diff --git a/testdata/fixtures/GetCode/UnlinkedContract.sol b/testdata/fixtures/GetCode/UnlinkedContract.sol index 1e972782fd05f..41f0b0d762b8f 100644 --- a/testdata/fixtures/GetCode/UnlinkedContract.sol +++ b/testdata/fixtures/GetCode/UnlinkedContract.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; library SmolLibrary { diff --git a/testdata/fixtures/GetCode/WorkingContract.sol b/testdata/fixtures/GetCode/WorkingContract.sol index d6a6820dd3d1b..3ea5020553749 100644 --- a/testdata/fixtures/GetCode/WorkingContract.sol +++ b/testdata/fixtures/GetCode/WorkingContract.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; contract WorkingContract { diff --git a/testdata/fork/ForkSame_1.t.sol b/testdata/fork/ForkSame_1.t.sol index aa06eeeb04a0e..01c89e6e2007c 100644 --- a/testdata/fork/ForkSame_1.t.sol +++ b/testdata/fork/ForkSame_1.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fork/ForkSame_2.t.sol b/testdata/fork/ForkSame_2.t.sol index aa06eeeb04a0e..01c89e6e2007c 100644 --- a/testdata/fork/ForkSame_2.t.sol +++ b/testdata/fork/ForkSame_2.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fork/LaunchFork.t.sol b/testdata/fork/LaunchFork.t.sol index 46e803f9e264c..da5b365dad464 100644 --- a/testdata/fork/LaunchFork.t.sol +++ b/testdata/fork/LaunchFork.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.6.12; import "ds-test/test.sol"; diff --git a/testdata/fork/Transact.t.sol b/testdata/fork/Transact.t.sol index b15553d23c94f..79c53fa3fd983 100644 --- a/testdata/fork/Transact.t.sol +++ b/testdata/fork/Transact.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fs/Default.t.sol b/testdata/fs/Default.t.sol index a37f479e30937..379de1ea66b6d 100644 --- a/testdata/fs/Default.t.sol +++ b/testdata/fs/Default.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fs/Disabled.t.sol b/testdata/fs/Disabled.t.sol index 7c13c06d222bd..40741644ecc8d 100644 --- a/testdata/fs/Disabled.t.sol +++ b/testdata/fs/Disabled.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/Fuzz.t.sol b/testdata/fuzz/Fuzz.t.sol index 686ee9d45f163..ef44653800334 100644 --- a/testdata/fuzz/Fuzz.t.sol +++ b/testdata/fuzz/Fuzz.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/FuzzInt.t.sol b/testdata/fuzz/FuzzInt.t.sol index c6340807fe771..aac0825dbb5d9 100644 --- a/testdata/fuzz/FuzzInt.t.sol +++ b/testdata/fuzz/FuzzInt.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/FuzzUint.t.sol b/testdata/fuzz/FuzzUint.t.sol index b4ba1e0e119d9..5ae90a57bba00 100644 --- a/testdata/fuzz/FuzzUint.t.sol +++ b/testdata/fuzz/FuzzUint.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol b/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol index 9a84e4f9e3dc8..5ff50e782ac55 100644 --- a/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol +++ b/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.0; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol b/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol index 6e1100cef3cc6..b8d5dc4164cc2 100644 --- a/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol +++ b/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol b/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol index cf8cb4d37f94b..086d5f99ab9e4 100644 --- a/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol +++ b/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/common/InvariantTest1.t.sol b/testdata/fuzz/invariant/common/InvariantTest1.t.sol index 3e9d84e321f60..15deccf338d7b 100644 --- a/testdata/fuzz/invariant/common/InvariantTest1.t.sol +++ b/testdata/fuzz/invariant/common/InvariantTest1.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/target/ExcludeContracts.t.sol b/testdata/fuzz/invariant/target/ExcludeContracts.t.sol index 0367bdec22d46..60aef60d935db 100644 --- a/testdata/fuzz/invariant/target/ExcludeContracts.t.sol +++ b/testdata/fuzz/invariant/target/ExcludeContracts.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/target/ExcludeSenders.t.sol b/testdata/fuzz/invariant/target/ExcludeSenders.t.sol index d0399f681bca1..bd37bd9bb6a4a 100644 --- a/testdata/fuzz/invariant/target/ExcludeSenders.t.sol +++ b/testdata/fuzz/invariant/target/ExcludeSenders.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/target/TargetContracts.t.sol b/testdata/fuzz/invariant/target/TargetContracts.t.sol index 288b9d8d5cd66..cdce691538204 100644 --- a/testdata/fuzz/invariant/target/TargetContracts.t.sol +++ b/testdata/fuzz/invariant/target/TargetContracts.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/target/TargetInterfaces.t.sol b/testdata/fuzz/invariant/target/TargetInterfaces.t.sol index f6e94ad5d83c5..5cfa85ce1836b 100644 --- a/testdata/fuzz/invariant/target/TargetInterfaces.t.sol +++ b/testdata/fuzz/invariant/target/TargetInterfaces.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/target/TargetSelectors.t.sol b/testdata/fuzz/invariant/target/TargetSelectors.t.sol index 1adc889a95c62..ef3af21424748 100644 --- a/testdata/fuzz/invariant/target/TargetSelectors.t.sol +++ b/testdata/fuzz/invariant/target/TargetSelectors.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/target/TargetSenders.t.sol b/testdata/fuzz/invariant/target/TargetSenders.t.sol index 0bd1d6b9549c0..50f37c4e950b5 100644 --- a/testdata/fuzz/invariant/target/TargetSenders.t.sol +++ b/testdata/fuzz/invariant/target/TargetSenders.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol b/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol index 82f56229d2944..ce81a51cf6bf0 100644 --- a/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol +++ b/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol index fae4a49866456..e82e7b1a36e88 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol +++ b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol index d4091d4f3ea96..5592aa84969dd 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol +++ b/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol b/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol index 07570fee7bf07..d3eb2cf9dfa1d 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol +++ b/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/inline/FuzzInlineConf.t.sol b/testdata/inline/FuzzInlineConf.t.sol index 8ab3a16d310bd..f6cf60fe71f17 100644 --- a/testdata/inline/FuzzInlineConf.t.sol +++ b/testdata/inline/FuzzInlineConf.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; import "ds-test/test.sol"; diff --git a/testdata/inline/InvariantInlineConf.t.sol b/testdata/inline/InvariantInlineConf.t.sol index 41e534f44a90a..c032911ec6e1e 100644 --- a/testdata/inline/InvariantInlineConf.t.sol +++ b/testdata/inline/InvariantInlineConf.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; import "ds-test/test.sol"; diff --git a/testdata/linking/duplicate/Duplicate.t.sol b/testdata/linking/duplicate/Duplicate.t.sol index 215e85e34eb5e..a09c81e4f105f 100644 --- a/testdata/linking/duplicate/Duplicate.t.sol +++ b/testdata/linking/duplicate/Duplicate.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/linking/nested/Nested.t.sol b/testdata/linking/nested/Nested.t.sol index b9b85c614a3a5..90100c88962e5 100644 --- a/testdata/linking/nested/Nested.t.sol +++ b/testdata/linking/nested/Nested.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/linking/simple/Simple.t.sol b/testdata/linking/simple/Simple.t.sol index af8363509b628..a6a636b6c5575 100644 --- a/testdata/linking/simple/Simple.t.sol +++ b/testdata/linking/simple/Simple.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/logs/HardhatLogs.t.sol b/testdata/logs/HardhatLogs.t.sol index 0058a32bdd26a..842a390a413d3 100644 --- a/testdata/logs/HardhatLogs.t.sol +++ b/testdata/logs/HardhatLogs.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "./console.sol"; diff --git a/testdata/logs/console.sol b/testdata/logs/console.sol index b295acc8cf930..f67c10bfae4d0 100644 --- a/testdata/logs/console.sol +++ b/testdata/logs/console.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; library console { diff --git a/testdata/repros/Issue2623.t.sol b/testdata/repros/Issue2623.t.sol index d479860da02b2..cf91d10a54168 100644 --- a/testdata/repros/Issue2623.t.sol +++ b/testdata/repros/Issue2623.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue2629.t.sol b/testdata/repros/Issue2629.t.sol index ef7df205ba48c..296ebfc325b2a 100644 --- a/testdata/repros/Issue2629.t.sol +++ b/testdata/repros/Issue2629.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue2723.t.sol b/testdata/repros/Issue2723.t.sol index 0a89f289ee0f2..6ecd7df8d3b90 100644 --- a/testdata/repros/Issue2723.t.sol +++ b/testdata/repros/Issue2723.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue2898.t.sol b/testdata/repros/Issue2898.t.sol index 67a5abe8992c0..6f6eb5e35ce55 100644 --- a/testdata/repros/Issue2898.t.sol +++ b/testdata/repros/Issue2898.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue2956.t.sol b/testdata/repros/Issue2956.t.sol index 3fe90b72e4977..8e9841e2b5bb9 100644 --- a/testdata/repros/Issue2956.t.sol +++ b/testdata/repros/Issue2956.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue2984.t.sol b/testdata/repros/Issue2984.t.sol index 4f69057fea424..223866926b0bc 100644 --- a/testdata/repros/Issue2984.t.sol +++ b/testdata/repros/Issue2984.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3055.t.sol b/testdata/repros/Issue3055.t.sol index 1a4634ef52247..0a94e4d2a50b5 100644 --- a/testdata/repros/Issue3055.t.sol +++ b/testdata/repros/Issue3055.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3077.t.sol b/testdata/repros/Issue3077.t.sol index 9167dc70ddab5..36cfb071cad4b 100644 --- a/testdata/repros/Issue3077.t.sol +++ b/testdata/repros/Issue3077.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3110.t.sol b/testdata/repros/Issue3110.t.sol index 02b1ff3d7c394..259a467d32946 100644 --- a/testdata/repros/Issue3110.t.sol +++ b/testdata/repros/Issue3110.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3119.t.sol b/testdata/repros/Issue3119.t.sol index c91fd78329ce9..80f539660a3bf 100644 --- a/testdata/repros/Issue3119.t.sol +++ b/testdata/repros/Issue3119.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3189.t.sol b/testdata/repros/Issue3189.t.sol index e2d302256ccdd..771b8f514c784 100644 --- a/testdata/repros/Issue3189.t.sol +++ b/testdata/repros/Issue3189.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3190.t.sol b/testdata/repros/Issue3190.t.sol index 30adada424587..b5d5c70e97240 100644 --- a/testdata/repros/Issue3190.t.sol +++ b/testdata/repros/Issue3190.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3192.t.sol b/testdata/repros/Issue3192.t.sol index f333adedebc1b..36841fd081579 100644 --- a/testdata/repros/Issue3192.t.sol +++ b/testdata/repros/Issue3192.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3220.t.sol b/testdata/repros/Issue3220.t.sol index 760e25d6c0bf8..acf75352d3877 100644 --- a/testdata/repros/Issue3220.t.sol +++ b/testdata/repros/Issue3220.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3221.sol b/testdata/repros/Issue3221.sol index e4fc7490fd1a1..cc6f8039e87f9 100644 --- a/testdata/repros/Issue3221.sol +++ b/testdata/repros/Issue3221.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3223.sol b/testdata/repros/Issue3223.sol index 95728b95c9559..14d46838e8330 100644 --- a/testdata/repros/Issue3223.sol +++ b/testdata/repros/Issue3223.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3347.sol b/testdata/repros/Issue3347.sol index 76f8c2130d3bf..66657ea626e8e 100644 --- a/testdata/repros/Issue3347.sol +++ b/testdata/repros/Issue3347.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3437.t.sol b/testdata/repros/Issue3437.t.sol index 2c16ce999e4b8..4174bea208880 100644 --- a/testdata/repros/Issue3437.t.sol +++ b/testdata/repros/Issue3437.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3596.t.sol b/testdata/repros/Issue3596.t.sol index af1aa021fcbef..9a942d3424bb4 100644 --- a/testdata/repros/Issue3596.t.sol +++ b/testdata/repros/Issue3596.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3653.t.sol b/testdata/repros/Issue3653.t.sol index d54acf3901333..6e52c49f8aa5c 100644 --- a/testdata/repros/Issue3653.t.sol +++ b/testdata/repros/Issue3653.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3661.sol b/testdata/repros/Issue3661.sol index 6a3e732cd9715..f141a19abd84a 100644 --- a/testdata/repros/Issue3661.sol +++ b/testdata/repros/Issue3661.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3674.t.sol b/testdata/repros/Issue3674.t.sol index 1b6985fff6bac..57216e8054811 100644 --- a/testdata/repros/Issue3674.t.sol +++ b/testdata/repros/Issue3674.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3685.t.sol b/testdata/repros/Issue3685.t.sol index 204ea677027dd..748367f659821 100644 --- a/testdata/repros/Issue3685.t.sol +++ b/testdata/repros/Issue3685.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3703.t.sol b/testdata/repros/Issue3703.t.sol index 517e59b7bcfb8..c941fe223902b 100644 --- a/testdata/repros/Issue3703.t.sol +++ b/testdata/repros/Issue3703.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3708.sol b/testdata/repros/Issue3708.sol index 619614ea61bf1..7cf57cd0e082a 100644 --- a/testdata/repros/Issue3708.sol +++ b/testdata/repros/Issue3708.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3723.t.sol b/testdata/repros/Issue3723.t.sol index 16172e1571acf..0f5d6694b7dfe 100644 --- a/testdata/repros/Issue3723.t.sol +++ b/testdata/repros/Issue3723.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3753.t.sol b/testdata/repros/Issue3753.t.sol index 62b26858b8545..1edbb42b8059b 100644 --- a/testdata/repros/Issue3753.t.sol +++ b/testdata/repros/Issue3753.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue3792.t.sol b/testdata/repros/Issue3792.t.sol index 4ffa84d2e8834..e01671f37d0fc 100644 --- a/testdata/repros/Issue3792.t.sol +++ b/testdata/repros/Issue3792.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue4586.t.sol b/testdata/repros/Issue4586.t.sol index 43bb3853581ca..6eb615c029fa1 100644 --- a/testdata/repros/Issue4586.t.sol +++ b/testdata/repros/Issue4586.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue4630.t.sol b/testdata/repros/Issue4630.t.sol index 6df4a05eb0352..a9334dc8e3850 100644 --- a/testdata/repros/Issue4630.t.sol +++ b/testdata/repros/Issue4630.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue4640.t.sol b/testdata/repros/Issue4640.t.sol index e04dd55a34fcb..b16f4d071fd36 100644 --- a/testdata/repros/Issue4640.t.sol +++ b/testdata/repros/Issue4640.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue4832.t.sol b/testdata/repros/Issue4832.t.sol index dd2d83d39e7b4..72f846873ff1b 100644 --- a/testdata/repros/Issue4832.t.sol +++ b/testdata/repros/Issue4832.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue6170.t.sol b/testdata/repros/Issue6170.t.sol index e5070b2edb5de..43f2067d6308c 100644 --- a/testdata/repros/Issue6170.t.sol +++ b/testdata/repros/Issue6170.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/repros/Issue6180.sol b/testdata/repros/Issue6180.sol index dea24c65db29b..7ff0684345120 100644 --- a/testdata/repros/Issue6180.sol +++ b/testdata/repros/Issue6180.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import "ds-test/test.sol"; diff --git a/testdata/script/deploy.sol b/testdata/script/deploy.sol index 619f76d6f86f6..f05afe48706f6 100644 --- a/testdata/script/deploy.sol +++ b/testdata/script/deploy.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; import {DSTest} from "../lib/ds-test/src/test.sol"; diff --git a/testdata/spec/ShanghaiCompat.t.sol b/testdata/spec/ShanghaiCompat.t.sol index 8c6e7a20274de..f490441ef5fcd 100644 --- a/testdata/spec/ShanghaiCompat.t.sol +++ b/testdata/spec/ShanghaiCompat.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Unlicense +// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.20; import "ds-test/test.sol"; From 141bd918de150984779d849f65fee0abc22958a6 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 17 Nov 2023 20:16:45 +0100 Subject: [PATCH 0294/1963] fix: ensure websocket is flushed (#6347) --- crates/anvil/server/src/pubsub.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/anvil/server/src/pubsub.rs b/crates/anvil/server/src/pubsub.rs index 476206874e644..3c9be85bce6d7 100644 --- a/crates/anvil/server/src/pubsub.rs +++ b/crates/anvil/server/src/pubsub.rs @@ -170,7 +170,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let pin = self.get_mut(); loop { - // drive the sink + // drive the websocket while let Poll::Ready(Ok(())) = pin.connection.poll_ready_unpin(cx) { // only start sending if socket is ready if let Some(msg) = pin.pending.pop_front() { @@ -182,6 +182,14 @@ where } } + // Ensure any pending messages are flushed + // this needs to be called manually for tungsenite websocket: + if let Poll::Ready(Err(err)) = pin.connection.poll_flush_unpin(cx) { + trace!(target: "rpc", ?err, "websocket err"); + // close the connection + return Poll::Ready(()) + } + loop { match pin.connection.poll_next_unpin(cx) { Poll::Ready(Some(req)) => match req { From c948388a0768eb0017dd579b1ad1d8b4f33627c4 Mon Sep 17 00:00:00 2001 From: Inphi Date: Fri, 17 Nov 2023 17:24:52 -0500 Subject: [PATCH 0295/1963] feat(cheatcodes): Record Account and Storage Access Cheatcodes (#6310) * Record storage and account access cheatcodes Co-authored-by: James Wenzel * expand record access cheatcode interface Adds a couple more fields to recorded account and storage accesses. * fix small doc comment nit * fix(cheatcodes): account access doc comment * fix(cheatcodes): clarify reverted account access status * fix(cheatcodes): clarify balance doc comments * fix(cheatcodes): clarify initialized account access field in doc comment * update Access kind to include Resumed account access Also rename cheats APIs * cleanup Resume logic * fmt * remove unused Resume access kind * add chain_id to AccountAccess * Update crates/cheatcodes/spec/src/vm.rs Co-authored-by: refcell.eth * add ChainInfo struct; address PR comments * avoid old skool ref mut * tidy code per pr review * rmeove unused import * address nits * selfdesutrct on record ctx check --------- Co-authored-by: refcell Co-authored-by: James Wenzel --- crates/abi/abi/HEVM.sol | 6 + crates/abi/src/bindings/hevm.rs | 271 +++++ crates/cheatcodes/assets/cheatcodes.json | 192 +++ crates/cheatcodes/spec/src/lib.rs | 8 +- crates/cheatcodes/spec/src/vm.rs | 87 ++ crates/cheatcodes/src/evm.rs | 34 + crates/cheatcodes/src/inspector.rs | 372 +++++- testdata/cheats/RecordAccountAccesses.t.sol | 1204 +++++++++++++++++++ testdata/cheats/Vm.sol | 6 + 9 files changed, 2170 insertions(+), 10 deletions(-) create mode 100644 testdata/cheats/RecordAccountAccesses.t.sol diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol index 47c66ae517749..76c08ddac0695 100644 --- a/crates/abi/abi/HEVM.sol +++ b/crates/abi/abi/HEVM.sol @@ -5,6 +5,9 @@ struct DirEntry { string errorMessage; string path; uint64 depth; bool isDir; bo 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; uint256 kind; address account; address accessor; bool initialized; uint256 oldBalance; uint256 newBalance; bytes deployedCode; uint256 value; bytes data; bool reverted; StorageAccess[] storageAccesses; } +struct StorageAccess { address account; bytes32 slot; bool isWrite; bytes32 previousValue; bytes32 newValue; bool reverted; } allowCheatcodes(address) @@ -84,6 +87,9 @@ record() accesses(address)(bytes32[], bytes32[]) skip(bool) +startStateDiffRecording() +stopAndReturnStateDiff()(AccountAccess[]) + recordLogs() getRecordedLogs()(Log[]) diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs index 8ed992f4d1a5a..8591d4911b804 100644 --- a/crates/abi/src/bindings/hevm.rs +++ b/crates/abi/src/bindings/hevm.rs @@ -4891,6 +4891,77 @@ pub mod hevm { }, ], ), + ( + ::std::borrow::ToOwned::to_owned("startStateDiffRecording"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned( + "startStateDiffRecording", + ), + inputs: ::std::vec![], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), + ( + ::std::borrow::ToOwned::to_owned("stopAndReturnStateDiff"), + ::std::vec![ + ::ethers_core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned( + "stopAndReturnStateDiff", + ), + inputs: ::std::vec![], + outputs: ::std::vec![ + ::ethers_core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers_core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers_core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers_core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ], + ), + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::Address, + ::ethers_core::abi::ethabi::ParamType::Address, + ::ethers_core::abi::ethabi::ParamType::Bool, + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::Bytes, + ::ethers_core::abi::ethabi::ParamType::Uint(256usize), + ::ethers_core::abi::ethabi::ParamType::Bytes, + ::ethers_core::abi::ethabi::ParamType::Bool, + ::ethers_core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers_core::abi::ethabi::ParamType::Tuple( + ::std::vec![ + ::ethers_core::abi::ethabi::ParamType::Address, + ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers_core::abi::ethabi::ParamType::Bool, + ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), + ::ethers_core::abi::ethabi::ParamType::Bool, + ], + ), + ), + ), + ], + ), + ), + ), + internal_type: ::core::option::Option::None, + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, + }, + ], + ), ( ::std::borrow::ToOwned::to_owned("stopBroadcast"), ::std::vec![ @@ -7349,6 +7420,49 @@ pub mod hevm { .method_hash([69, 181, 96, 120], (p0, p1)) .expect("method not found (this should never happen)") } + ///Calls the contract's `startStateDiffRecording` (0xcf22e3c9) function + pub fn start_state_diff_recording( + &self, + ) -> ::ethers_contract::builders::ContractCall { + self.0 + .method_hash([207, 34, 227, 201], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `stopAndReturnStateDiff` (0xaa5cf90e) function + pub fn stop_and_return_state_diff( + &self, + ) -> ::ethers_contract::builders::ContractCall< + M, + ::std::vec::Vec< + ( + (::ethers_core::types::U256, ::ethers_core::types::U256), + ::ethers_core::types::U256, + ::ethers_core::types::Address, + ::ethers_core::types::Address, + bool, + ::ethers_core::types::U256, + ::ethers_core::types::U256, + ::ethers_core::types::Bytes, + ::ethers_core::types::U256, + ::ethers_core::types::Bytes, + bool, + ::std::vec::Vec< + ( + ::ethers_core::types::Address, + [u8; 32], + bool, + [u8; 32], + [u8; 32], + bool, + ), + >, + ), + >, + > { + self.0 + .method_hash([170, 92, 249, 14], ()) + .expect("method not found (this should never happen)") + } ///Calls the contract's `stopBroadcast` (0x76eadd36) function pub fn stop_broadcast( &self, @@ -10321,6 +10435,32 @@ pub mod hevm { pub ::ethers_core::types::Address, pub ::ethers_core::types::Address, ); + ///Container type for all input parameters for the `startStateDiffRecording` function with signature `startStateDiffRecording()` and selector `0xcf22e3c9` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "startStateDiffRecording", abi = "startStateDiffRecording()")] + pub struct StartStateDiffRecordingCall; + ///Container type for all input parameters for the `stopAndReturnStateDiff` function with signature `stopAndReturnStateDiff()` and selector `0xaa5cf90e` + #[derive( + Clone, + ::ethers_contract::EthCall, + ::ethers_contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethcall(name = "stopAndReturnStateDiff", abi = "stopAndReturnStateDiff()")] + pub struct StopAndReturnStateDiffCall; ///Container type for all input parameters for the `stopBroadcast` function with signature `stopBroadcast()` and selector `0x76eadd36` #[derive( Clone, @@ -10796,6 +10936,8 @@ pub mod hevm { StartMappingRecording(StartMappingRecordingCall), StartPrank0(StartPrank0Call), StartPrank1(StartPrank1Call), + StartStateDiffRecording(StartStateDiffRecordingCall), + StopAndReturnStateDiff(StopAndReturnStateDiffCall), StopBroadcast(StopBroadcastCall), StopMappingRecording(StopMappingRecordingCall), StopPrank(StopPrankCall), @@ -11783,6 +11925,16 @@ pub mod hevm { ) { return Ok(Self::StartPrank1(decoded)); } + if let Ok(decoded) = ::decode( + data, + ) { + return Ok(Self::StartStateDiffRecording(decoded)); + } + if let Ok(decoded) = ::decode( + data, + ) { + return Ok(Self::StopAndReturnStateDiff(decoded)); + } if let Ok(decoded) = ::decode( data, ) { @@ -12348,6 +12500,12 @@ pub mod hevm { Self::StartPrank1(element) => { ::ethers_core::abi::AbiEncode::encode(element) } + Self::StartStateDiffRecording(element) => { + ::ethers_core::abi::AbiEncode::encode(element) + } + Self::StopAndReturnStateDiff(element) => { + ::ethers_core::abi::AbiEncode::encode(element) + } Self::StopBroadcast(element) => { ::ethers_core::abi::AbiEncode::encode(element) } @@ -12619,6 +12777,12 @@ pub mod hevm { } Self::StartPrank0(element) => ::core::fmt::Display::fmt(element, f), Self::StartPrank1(element) => ::core::fmt::Display::fmt(element, f), + Self::StartStateDiffRecording(element) => { + ::core::fmt::Display::fmt(element, f) + } + Self::StopAndReturnStateDiff(element) => { + ::core::fmt::Display::fmt(element, f) + } Self::StopBroadcast(element) => ::core::fmt::Display::fmt(element, f), Self::StopMappingRecording(element) => { ::core::fmt::Display::fmt(element, f) @@ -13605,6 +13769,16 @@ pub mod hevm { Self::StartPrank1(value) } } + impl ::core::convert::From for HEVMCalls { + fn from(value: StartStateDiffRecordingCall) -> Self { + Self::StartStateDiffRecording(value) + } + } + impl ::core::convert::From for HEVMCalls { + fn from(value: StopAndReturnStateDiffCall) -> Self { + Self::StopAndReturnStateDiff(value) + } + } impl ::core::convert::From for HEVMCalls { fn from(value: StopBroadcastCall) -> Self { Self::StopBroadcast(value) @@ -15126,6 +15300,44 @@ pub mod hevm { Hash )] pub struct SnapshotReturn(pub ::ethers_core::types::U256); + ///Container type for all return fields from the `stopAndReturnStateDiff` function with signature `stopAndReturnStateDiff()` and selector `0xaa5cf90e` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct StopAndReturnStateDiffReturn( + pub ::std::vec::Vec< + ( + (::ethers_core::types::U256, ::ethers_core::types::U256), + ::ethers_core::types::U256, + ::ethers_core::types::Address, + ::ethers_core::types::Address, + bool, + ::ethers_core::types::U256, + ::ethers_core::types::U256, + ::ethers_core::types::Bytes, + ::ethers_core::types::U256, + ::ethers_core::types::Bytes, + bool, + ::std::vec::Vec< + ( + ::ethers_core::types::Address, + [u8; 32], + bool, + [u8; 32], + [u8; 32], + bool, + ), + >, + ), + >, + ); ///Container type for all return fields from the `tryFfi` function with signature `tryFfi(string[])` and selector `0xf45c1ce7` #[derive( Clone, @@ -15152,6 +15364,46 @@ pub mod hevm { Hash )] pub struct UnixTimeReturn(pub ::ethers_core::types::U256); + ///`AccountAccess((uint256,uint256),uint256,address,address,bool,uint256,uint256,bytes,uint256,bytes,bool,(address,bytes32,bool,bytes32,bytes32,bool)[])` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct AccountAccess { + pub chain_info: ChainInfo, + pub kind: ::ethers_core::types::U256, + pub account: ::ethers_core::types::Address, + pub accessor: ::ethers_core::types::Address, + pub initialized: bool, + pub old_balance: ::ethers_core::types::U256, + pub new_balance: ::ethers_core::types::U256, + pub deployed_code: ::ethers_core::types::Bytes, + pub value: ::ethers_core::types::U256, + pub data: ::ethers_core::types::Bytes, + pub reverted: bool, + pub storage_accesses: ::std::vec::Vec, + } + ///`ChainInfo(uint256,uint256)` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct ChainInfo { + pub fork_id: ::ethers_core::types::U256, + pub chain_id: ::ethers_core::types::U256, + } ///`DirEntry(string,string,uint64,bool,bool)` #[derive( Clone, @@ -15258,6 +15510,25 @@ pub mod hevm { pub name: ::std::string::String, pub url: ::std::string::String, } + ///`StorageAccess(address,bytes32,bool,bytes32,bytes32,bool)` + #[derive( + Clone, + ::ethers_contract::EthAbiType, + ::ethers_contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + pub struct StorageAccess { + pub account: ::ethers_core::types::Address, + pub slot: [u8; 32], + pub is_write: bool, + pub previous_value: [u8; 32], + pub new_value: [u8; 32], + pub reverted: bool, + } ///`Wallet(address,uint256,uint256,uint256)` #[derive( Clone, diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index a35fd71c0982c..c835e46339970 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -33,6 +33,40 @@ "description": "A recurrent prank triggered by a `vm.startPrank()` call is currently active." } ] + }, + { + "name": "AccountAccessKind", + "description": "The kind of account access that occurred.", + "variants": [ + { + "name": "Call", + "description": "The account was called." + }, + { + "name": "DelegateCall", + "description": "The account was called via delegatecall." + }, + { + "name": "CallCode", + "description": "The account was called via callcode." + }, + { + "name": "StaticCall", + "description": "The account was called via staticcall." + }, + { + "name": "Create", + "description": "The account was created." + }, + { + "name": "SelfDestruct", + "description": "The account was selfdestructed." + }, + { + "name": "Resume", + "description": "Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess)." + } + ] } ], "structs": [ @@ -242,6 +276,124 @@ "description": "The `stderr` data." } ] + }, + { + "name": "ChainInfo", + "description": "Information on the chain and fork.", + "fields": [ + { + "name": "forkId", + "ty": "uint256", + "description": "The fork identifier. Set to zero if no fork is active." + }, + { + "name": "chainId", + "ty": "uint256", + "description": "The chain ID of the current fork." + } + ] + }, + { + "name": "AccountAccess", + "description": "The result of a `stopAndReturnStateDiff` call.", + "fields": [ + { + "name": "chainInfo", + "ty": "ChainInfo", + "description": "The chain and fork the access occurred." + }, + { + "name": "kind", + "ty": "AccountAccessKind", + "description": "The kind of account access that determines what the account is.\n If kind is Call, DelegateCall, StaticCall or CallCode, then the account is the callee.\n If kind is Create, then the account is the newly created account.\n If kind is SelfDestruct, then the account is the selfdestruct recipient.\n If kind is a Resume, then account represents a account context that has resumed." + }, + { + "name": "account", + "ty": "address", + "description": "The account that was accessed.\n It's either the account created, callee or a selfdestruct recipient for CREATE, CALL or SELFDESTRUCT." + }, + { + "name": "accessor", + "ty": "address", + "description": "What accessed the account." + }, + { + "name": "initialized", + "ty": "bool", + "description": "If the account was initialized or empty prior to the access.\n An account is considered initialized if it has code, a\n non-zero nonce, or a non-zero balance." + }, + { + "name": "oldBalance", + "ty": "uint256", + "description": "The previous balance of the accessed account." + }, + { + "name": "newBalance", + "ty": "uint256", + "description": "The potential new balance of the accessed account.\n That is, all balance changes are recorded here, even if reverts occurred." + }, + { + "name": "deployedCode", + "ty": "bytes", + "description": "Code of the account deployed by CREATE." + }, + { + "name": "value", + "ty": "uint256", + "description": "Value passed along with the account access" + }, + { + "name": "data", + "ty": "bytes", + "description": "Input data provided to the CREATE or CALL" + }, + { + "name": "reverted", + "ty": "bool", + "description": "If this access reverted in either the current or parent context." + }, + { + "name": "storageAccesses", + "ty": "StorageAccess[]", + "description": "An ordered list of storage accesses made during an account access operation." + } + ] + }, + { + "name": "StorageAccess", + "description": "The storage accessed during an `AccountAccess`.", + "fields": [ + { + "name": "account", + "ty": "address", + "description": "The account whose storage was accessed." + }, + { + "name": "slot", + "ty": "bytes32", + "description": "The slot that was accessed." + }, + { + "name": "isWrite", + "ty": "bool", + "description": "If the access was a write." + }, + { + "name": "previousValue", + "ty": "bytes32", + "description": "The previous value of the slot." + }, + { + "name": "newValue", + "ty": "bytes32", + "description": "The new value of the slot." + }, + { + "name": "reverted", + "ty": "bool", + "description": "If the access was reverted." + } + ] } ], "cheatcodes": [ @@ -4145,6 +4297,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "startStateDiffRecording", + "description": "Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order,\nalong with the context of the calls", + "declaration": "function startStateDiffRecording() external;", + "visibility": "external", + "mutability": "", + "signature": "startStateDiffRecording()", + "selector": "0xcf22e3c9", + "selectorBytes": [ + 207, + 34, + 227, + 201 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "stopAndReturnStateDiff", + "description": "Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session.", + "declaration": "function stopAndReturnStateDiff() external returns (AccountAccess[] memory accesses);", + "visibility": "external", + "mutability": "", + "signature": "stopAndReturnStateDiff()", + "selector": "0xaa5cf90e", + "selectorBytes": [ + 170, + 92, + 249, + 14 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "stopBroadcast", diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index 3877806ee6fc8..9e0cf12dde025 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -80,8 +80,14 @@ impl Cheatcodes<'static> { Vm::FsMetadata::STRUCT.clone(), Vm::Wallet::STRUCT.clone(), Vm::FfiResult::STRUCT.clone(), + Vm::ChainInfo::STRUCT.clone(), + Vm::AccountAccess::STRUCT.clone(), + Vm::StorageAccess::STRUCT.clone(), + ]), + enums: Cow::Owned(vec![ + Vm::CallerMode::ENUM.clone(), + Vm::AccountAccessKind::ENUM.clone(), ]), - enums: Cow::Owned(vec![Vm::CallerMode::ENUM.clone()]), errors: Vm::VM_ERRORS.iter().map(|&x| x.clone()).collect(), events: Cow::Borrowed(&[]), // events: Vm::VM_EVENTS.iter().map(|&x| x.clone()).collect(), diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 519d6bad4d184..b3c65e1fb031f 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -36,6 +36,24 @@ interface Vm { RecurrentPrank, } + /// The kind of account access that occurred. + enum AccountAccessKind { + /// The account was called. + Call, + /// The account was called via delegatecall. + DelegateCall, + /// The account was called via callcode. + CallCode, + /// The account was called via staticcall. + StaticCall, + /// The account was created. + Create, + /// The account was selfdestructed. + SelfDestruct, + /// Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess). + Resume, + } + /// An Ethereum log. Returned by `getRecordedLogs`. struct Log { /// The topics of the log, including the signature, if any. @@ -134,6 +152,66 @@ interface Vm { bytes stderr; } + /// Information on the chain and fork. + struct ChainInfo { + /// The fork identifier. Set to zero if no fork is active. + uint256 forkId; + /// The chain ID of the current fork. + uint256 chainId; + } + + /// The result of a `stopAndReturnStateDiff` call. + struct AccountAccess { + /// The chain and fork the access occurred. + ChainInfo chainInfo; + /// The kind of account access that determines what the account is. + /// If kind is Call, DelegateCall, StaticCall or CallCode, then the account is the callee. + /// If kind is Create, then the account is the newly created account. + /// If kind is SelfDestruct, then the account is the selfdestruct recipient. + /// If kind is a Resume, then account represents a account context that has resumed. + AccountAccessKind kind; + /// The account that was accessed. + /// It's either the account created, callee or a selfdestruct recipient for CREATE, CALL or SELFDESTRUCT. + address account; + /// What accessed the account. + address accessor; + /// If the account was initialized or empty prior to the access. + /// An account is considered initialized if it has code, a + /// non-zero nonce, or a non-zero balance. + bool initialized; + /// The previous balance of the accessed account. + uint256 oldBalance; + /// The potential new balance of the accessed account. + /// That is, all balance changes are recorded here, even if reverts occurred. + uint256 newBalance; + /// Code of the account deployed by CREATE. + bytes deployedCode; + /// Value passed along with the account access + uint256 value; + /// Input data provided to the CREATE or CALL + bytes data; + /// If this access reverted in either the current or parent context. + bool reverted; + /// An ordered list of storage accesses made during an account access operation. + StorageAccess[] storageAccesses; + } + + /// The storage accessed during an `AccountAccess`. + struct StorageAccess { + /// The account whose storage was accessed. + address account; + /// The slot that was accessed. + bytes32 slot; + /// If the access was a write. + bool isWrite; + /// The previous value of the slot. + bytes32 previousValue; + /// The new value of the slot. + bytes32 newValue; + /// If the access was reverted. + bool reverted; + } + // ======== EVM ======== /// Gets the address for a given private key. @@ -166,6 +244,15 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots); + /// Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order, + /// along with the context of the calls + #[cheatcode(group = Evm, safety = Safe)] + function startStateDiffRecording() external; + + /// Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session. + #[cheatcode(group = Evm, safety = Safe)] + function stopAndReturnStateDiff() external returns (AccountAccess[] memory accesses); + // -------- Recording Map Writes -------- /// Starts recording all map SSTOREs for later retrieval. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 8585c5410ce0a..630e3a8f9fad4 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -341,6 +341,21 @@ impl Cheatcode for revertToCall { } } +impl Cheatcode for startStateDiffRecordingCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.recorded_account_diffs_stack = Some(Default::default()); + Ok(Default::default()) + } +} + +impl Cheatcode for stopAndReturnStateDiffCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + get_state_diff(state) + } +} + pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { super::script::correct_sender_nonce(ccx)?; let (account, _) = ccx.data.journaled_state.load_account(*address, ccx.data.db)?; @@ -404,3 +419,22 @@ pub(super) fn journaled_account<'a, DB: DatabaseExt>( data.journaled_state.touch(&addr); Ok(data.journaled_state.state.get_mut(&addr).expect("account is loaded")) } + +/// Consumes recorded account accesses and returns them as an abi encoded +/// array of [AccountAccess]. If there are no accounts were +/// recorded as accessed, an abi encoded empty array is returned. +/// +/// In the case where `stopAndReturnStateDiff` is called at a lower +/// depth than `startStateDiffRecording`, multiple `Vec` +/// will be flattened, preserving the order of the accesses. +fn get_state_diff(state: &mut Cheatcodes) -> Result { + let res = state + .recorded_account_diffs_stack + .replace(Default::default()) + .unwrap_or_default() + .into_iter() + .flatten() + .map(|record| record.access) + .collect::>(); + Ok(res.abi_encode()) +} diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 3ff0d563c32de..2115d8da549fb 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -28,7 +28,9 @@ use foundry_evm_core::{ use foundry_utils::types::ToEthers; use itertools::Itertools; use revm::{ - interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, + interpreter::{ + opcode, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, Interpreter, + }, primitives::{BlockEnv, CreateScheme, TransactTo}, EVMData, Inspector, }; @@ -85,6 +87,14 @@ pub struct BroadcastableTransaction { /// List of transactions that can be broadcasted. pub type BroadcastableTransactions = VecDeque; +#[derive(Debug, Clone)] +pub struct AccountAccess { + /// The account access. + pub access: crate::Vm::AccountAccess, + /// The call depth the account was accessed. + pub depth: u64, +} + /// An EVM inspector that handles calls to various cheatcodes, each with their own behavior. /// /// Cheatcodes can be called by contracts during execution to modify the VM environment, such as @@ -137,6 +147,13 @@ pub struct Cheatcodes { /// Recorded storage reads and writes pub accesses: Option, + /// Recorded account accesses (calls, creates) organized by relative call depth, where the + /// topmost vector corresponds to accesses at the depth at which account access recording + /// began. Each vector in the matrix represents a list of accesses at a specific call + /// depth. Once that call context has ended, the last vector is removed from the matrix and + /// merged into the previous vector. + pub recorded_account_diffs_stack: Option>>, + /// Recorded logs pub recorded_logs: Option>, @@ -226,6 +243,7 @@ impl Cheatcodes { } /// Determines the address of the contract and marks it as allowed + /// Returns the address of the contract created /// /// There may be cheatcodes in the constructor of the new contract, in order to allow them /// automatically we need to determine the new address @@ -233,13 +251,7 @@ impl Cheatcodes { &self, data: &mut EVMData<'_, DB>, inputs: &CreateInputs, - ) { - if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { - // we only grant cheat code access for new contracts if the caller also has - // cheatcode access and the new contract is created in top most call - return - } - + ) -> Address { let old_nonce = data .journaled_state .state @@ -248,7 +260,15 @@ impl Cheatcodes { .unwrap_or_default(); let created_address = get_create_address(inputs, old_nonce); + if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { + // we only grant cheat code access for new contracts if the caller also has + // cheatcode access and the new contract is created in top most call + return created_address + } + data.db.allow_cheatcode_access(created_address); + + created_address } /// Called when there was a revert. @@ -382,6 +402,114 @@ impl Inspector for Cheatcodes { } } + // Record account access via SELFDESTRUCT if `recordAccountAccesses` has been called + if let Some(account_accesses) = &mut self.recorded_account_diffs_stack { + if interpreter.current_opcode() == opcode::SELFDESTRUCT { + let target = try_or_continue!(interpreter.stack().peek(0)); + // load balance of this account + let value = if let Ok((account, _)) = + data.journaled_state.load_account(interpreter.contract().address, data.db) + { + account.info.balance + } else { + U256::ZERO + }; + let account = Address::from_word(B256::from(target)); + // get previous balance and initialized status of the target account + let (initialized, old_balance) = + if let Ok((account, _)) = data.journaled_state.load_account(account, data.db) { + (account.info.exists(), account.info.balance) + } else { + (false, U256::ZERO) + }; + // register access for the target account + let access = crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), + }, + accessor: interpreter.contract().address, + account, + kind: crate::Vm::AccountAccessKind::SelfDestruct, + initialized, + oldBalance: old_balance, + newBalance: old_balance + value, + value, + data: vec![], + reverted: false, + deployedCode: vec![], + storageAccesses: vec![], + }; + // Ensure that we're not selfdestructing a context recording was initiated on + if let Some(last) = account_accesses.last_mut() { + last.push(AccountAccess { access, depth: data.journaled_state.depth() }); + } + } + } + + // Record granular ordered storage accesses if `startStateDiffRecording` has been called + if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + match interpreter.current_opcode() { + opcode::SLOAD => { + let key = try_or_continue!(interpreter.stack().peek(0)); + let address = interpreter.contract().address; + + // Try to include present value for informational purposes, otherwise assume + // it's not set (zero value) + let mut present_value = U256::ZERO; + // Try to load the account and the slot's present value + if data.journaled_state.load_account(address, data.db).is_ok() { + if let Ok((previous, _)) = data.journaled_state.sload(address, key, data.db) + { + present_value = previous; + } + } + let access = crate::Vm::StorageAccess { + account: interpreter.contract().address, + slot: key.into(), + isWrite: false, + previousValue: present_value.into(), + newValue: present_value.into(), + reverted: false, + }; + append_storage_access( + recorded_account_diffs_stack, + access, + data.journaled_state.depth(), + ); + } + opcode::SSTORE => { + let key = try_or_continue!(interpreter.stack().peek(0)); + let value = try_or_continue!(interpreter.stack().peek(1)); + let address = interpreter.contract().address; + // Try to load the account and the slot's previous value, otherwise, assume it's + // not set (zero value) + let mut previous_value = U256::ZERO; + if data.journaled_state.load_account(address, data.db).is_ok() { + if let Ok((previous, _)) = data.journaled_state.sload(address, key, data.db) + { + previous_value = previous; + } + } + + let access = crate::Vm::StorageAccess { + account: address, + slot: key.into(), + isWrite: true, + previousValue: previous_value.into(), + newValue: value.into(), + reverted: false, + }; + append_storage_access( + recorded_account_diffs_stack, + access, + data.journaled_state.depth(), + ); + } + _ => (), + } + } + // If the allowed memory writes cheatcode is active at this context depth, check to see // if the current opcode can either mutate directly or expand memory. If the opcode at // the current program counter is a match, check if the modified memory lies within the @@ -681,6 +809,52 @@ impl Inspector for Cheatcodes { } } + // Record called accounts if `startStateDiffRecording` has been called + if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + // Determine if account is "initialized," ie, it has a non-zero balance, a non-zero + // nonce, a non-zero KECCAK_EMPTY codehash, or non-empty code + let initialized; + let old_balance; + if let Ok((acc, _)) = data.journaled_state.load_account(call.contract, data.db) { + initialized = acc.info.exists(); + old_balance = acc.info.balance; + } else { + initialized = false; + old_balance = U256::ZERO; + } + let kind = match call.context.scheme { + CallScheme::Call => crate::Vm::AccountAccessKind::Call, + CallScheme::CallCode => crate::Vm::AccountAccessKind::CallCode, + CallScheme::DelegateCall => crate::Vm::AccountAccessKind::DelegateCall, + CallScheme::StaticCall => crate::Vm::AccountAccessKind::StaticCall, + }; + // Record this call by pushing it to a new pending vector; all subsequent calls at + // that depth will be pushed to the same vector. When the call ends, the + // RecordedAccountAccess (and all subsequent RecordedAccountAccesses) will be + // updated with the revert status of this call, since the EVM does not mark accounts + // as "warm" if the call from which they were accessed is reverted + recorded_account_diffs_stack.push(vec![AccountAccess { + access: crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), + }, + accessor: call.context.caller, + account: call.contract, + kind, + initialized, + oldBalance: old_balance, + newBalance: U256::ZERO, // updated on call_end + value: call.transfer.value, + data: call.input.to_vec(), + reverted: false, + deployedCode: vec![], + storageAccesses: vec![], // updated on step + }, + depth: data.journaled_state.depth(), + }]); + } + (InstructionResult::Continue, gas, Bytes::new()) } @@ -747,6 +921,47 @@ impl Inspector for Cheatcodes { } } + // If `startStateDiffRecording` has been called, update the `reverted` status of the + // previous call depth's recorded accesses, if any + if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + // The root call cannot be recorded. + if data.journaled_state.depth() > 0 { + let mut last_recorded_depth = + recorded_account_diffs_stack.pop().expect("missing CALL account accesses"); + // Update the reverted status of all deeper calls if this call reverted, in + // accordance with EVM behavior + if status.is_revert() { + last_recorded_depth.iter_mut().for_each(|element| { + element.access.reverted = true; + element + .access + .storageAccesses + .iter_mut() + .for_each(|storage_access| storage_access.reverted = true); + }) + } + let call_access = last_recorded_depth.first_mut().expect("empty AccountAccesses"); + // Assert that we're at the correct depth before recording post-call state changes. + // Depending on the depth the cheat was called at, there may not be any pending + // calls to update if execution has percolated up to a higher depth. + if call_access.depth == data.journaled_state.depth() { + if let Ok((acc, _)) = data.journaled_state.load_account(call.contract, data.db) + { + debug_assert!(access_is_call(call_access.access.kind)); + call_access.access.newBalance = acc.info.balance; + } + } + // Merge the last depth's AccountAccesses into the AccountAccesses at the current + // depth, or push them back onto the pending vector if higher depths were not + // recorded. This preserves ordering of accesses. + if let Some(last) = recorded_account_diffs_stack.last_mut() { + last.append(&mut last_recorded_depth); + } else { + recorded_account_diffs_stack.push(last_recorded_depth); + } + } + } + // At the end of the call, // we need to check if we've found all the emits. // We know we've found all the expected emits in the right order @@ -889,7 +1104,7 @@ impl Inspector for Cheatcodes { let gas = Gas::new(call.gas_limit); // allow cheatcodes from the address of the new contract - self.allow_cheatcodes_on_create(data, call); + let address = self.allow_cheatcodes_on_create(data, call); // Apply our prank if let Some(prank) = &self.prank { @@ -957,6 +1172,32 @@ impl Inspector for Cheatcodes { } } + // If `recordAccountAccesses` has been called, record the create + if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + // Record the create context as an account access and create a new vector to record all + // subsequent account accesses + recorded_account_diffs_stack.push(vec![AccountAccess { + access: crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), + }, + accessor: call.caller, + account: address, + kind: crate::Vm::AccountAccessKind::Create, + initialized: true, + oldBalance: U256::ZERO, // updated on create_end + newBalance: U256::ZERO, // updated on create_end + value: call.value, + data: call.init_code.to_vec(), + reverted: false, + deployedCode: vec![], // updated on create_end + storageAccesses: vec![], // updated on create_end + }, + depth: data.journaled_state.depth(), + }]); + } + (InstructionResult::Continue, None, gas, Bytes::new()) } @@ -1013,6 +1254,61 @@ impl Inspector for Cheatcodes { } } + // If `startStateDiffRecording` has been called, update the `reverted` status of the + // previous call depth's recorded accesses, if any + if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + // The root call cannot be recorded. + if data.journaled_state.depth() > 0 { + let mut last_depth = + recorded_account_diffs_stack.pop().expect("missing CREATE account accesses"); + // Update the reverted status of all deeper calls if this call reverted, in + // accordance with EVM behavior + if status.is_revert() { + last_depth.iter_mut().for_each(|element| { + element.access.reverted = true; + element + .access + .storageAccesses + .iter_mut() + .for_each(|storage_access| storage_access.reverted = true); + }) + } + let create_access = last_depth.first_mut().expect("empty AccountAccesses"); + // Assert that we're at the correct depth before recording post-create state + // changes. Depending on what depth the cheat was called at, there + // may not be any pending calls to update if execution has + // percolated up to a higher depth. + if create_access.depth == data.journaled_state.depth() { + debug_assert_eq!( + create_access.access.kind as u8, + crate::Vm::AccountAccessKind::Create as u8 + ); + if let Some(address) = address { + if let Ok((created_acc, _)) = + data.journaled_state.load_account(address, data.db) + { + create_access.access.newBalance = created_acc.info.balance; + create_access.access.deployedCode = created_acc + .info + .code + .clone() + .unwrap_or_default() + .original_bytes() + .into(); + } + } + } + // Merge the last depth's AccountAccesses into the AccountAccesses at the current + // depth, or push them back onto the pending vector if higher depths were not + // recorded. This preserves ordering of accesses. + if let Some(last) = recorded_account_diffs_stack.last_mut() { + last.append(&mut last_depth); + } else { + recorded_account_diffs_stack.push(last_depth); + } + } + } + (status, address, remaining_gas, retdata) } } @@ -1109,3 +1405,61 @@ fn apply_dispatch(calls: &Vm::VmCalls, ccx: &mut CheatsCtxt } vm_calls!(match_) } + +/// Returns true if the kind of account access is a call. +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 + ) +} + +/// Appends an AccountAccess that resumes the recording of the current context. +fn append_storage_access( + accesses: &mut [Vec], + storage_access: crate::Vm::StorageAccess, + storage_depth: u64, +) { + if let Some(last) = accesses.last_mut() { + // Assert that there's an existing record for the current context. + if !last.is_empty() && last.first().unwrap().depth < storage_depth { + // Three cases to consider: + // 1. If there hasn't been a context switch since the start of this context, then add + // the storage access to the current context record. + // 2. If there's an existing Resume record, then add the storage access to it. + // 3. Otherwise, create a new Resume record based on the current context. + if last.len() == 1 { + last.first_mut().unwrap().access.storageAccesses.push(storage_access); + } else { + let last_record = last.last_mut().unwrap(); + if last_record.access.kind as u8 == crate::Vm::AccountAccessKind::Resume as u8 { + last_record.access.storageAccesses.push(storage_access); + } else { + let entry = last.first().unwrap(); + let resume_record = crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: entry.access.chainInfo.forkId, + chainId: entry.access.chainInfo.chainId, + }, + accessor: entry.access.accessor, + account: entry.access.account, + kind: crate::Vm::AccountAccessKind::Resume, + initialized: entry.access.initialized, + storageAccesses: vec![storage_access], + reverted: entry.access.reverted, + // The remaining fields are defaults + oldBalance: U256::ZERO, + newBalance: U256::ZERO, + value: U256::ZERO, + data: vec![], + deployedCode: vec![], + }; + last.push(AccountAccess { access: resume_record, depth: entry.depth }); + } + } + } + } +} diff --git a/testdata/cheats/RecordAccountAccesses.t.sol b/testdata/cheats/RecordAccountAccesses.t.sol new file mode 100644 index 0000000000000..60652c130ed0e --- /dev/null +++ b/testdata/cheats/RecordAccountAccesses.t.sol @@ -0,0 +1,1204 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +/// @notice Helper contract with a constructo that makes a call to itself then +/// optionally reverts if zero-length data is passed +contract SelfCaller { + constructor(bytes memory) payable { + assembly { + // call self to test that the cheatcode correctly reports the + // account as initialized even when there is no code at the + // contract address + pop(call(gas(), address(), div(callvalue(), 10), 0, 0, 0, 0)) + if eq(calldataload(0x04), 1) { revert(0, 0) } + } + } +} + +/// @notice Helper contract with a constructor that stores a value in storage +/// and then optionally reverts. +contract ConstructorStorer { + constructor(bool shouldRevert) { + assembly { + sstore(0x00, 0x01) + if shouldRevert { revert(0, 0) } + } + } +} + +/// @notice Helper contract that calls itself from the run method +contract Doer { + uint256[10] spacer; + mapping(bytes32 key => uint256 value) slots; + + function run() public payable { + slots[bytes32("doer 1")]++; + this.doStuff{value: msg.value / 10}(); + } + + function doStuff() external payable { + slots[bytes32("doer 2")]++; + } +} + +/// @notice Helper contract that selfdestructs to a target address within its +/// constructor +contract SelfDestructor { + constructor(address target) payable { + selfdestruct(payable(target)); + } +} + +/// @notice Helper contract that calls a Doer from the run method +contract Create2or { + function create2(bytes32 salt, bytes memory initcode) external payable returns (address result) { + assembly { + result := create2(callvalue(), add(initcode, 0x20), mload(initcode), salt) + } + } +} + +/// @notice Helper contract that calls a Doer from the run method and then +/// reverts +contract Reverter { + Doer immutable doer; + mapping(bytes32 key => uint256 value) slots; + + constructor(Doer _doer) { + doer = _doer; + } + + function run() public payable { + slots[bytes32("reverter")]++; + doer.run{value: msg.value / 10}(); + revert(); + } +} + +/// @notice Helper contract that calls a Doer from the run method +contract Succeeder { + Doer immutable doer; + mapping(bytes32 key => uint256 value) slots; + + constructor(Doer _doer) { + doer = _doer; + } + + function run() public payable { + slots[bytes32("succeeder")]++; + doer.run{value: msg.value / 10}(); + } +} + +/// @notice Helper contract that calls a Reverter and Succeeder from the run +/// method +contract NestedRunner { + Doer public immutable doer; + Reverter public immutable reverter; + Succeeder public immutable succeeder; + mapping(bytes32 key => uint256 value) slots; + + constructor() { + doer = new Doer(); + reverter = new Reverter(doer); + succeeder = new Succeeder(doer); + } + + function run(bool shouldRevert) public payable { + slots[bytes32("runner")]++; + try reverter.run{value: msg.value / 10}() { + if (shouldRevert) { + revert(); + } + } catch {} + succeeder.run{value: msg.value / 10}(); + if (shouldRevert) { + revert(); + } + } +} + +/// @notice Helper contract that writes to storage in a nested call +contract NestedStorer { + mapping(bytes32 key => uint256 value) slots; + + constructor() {} + + function run() public payable { + slots[bytes32("nested_storer 1")]++; + this.run2(); + slots[bytes32("nested_storer 2")]++; + } + + function run2() external payable { + slots[bytes32("nested_storer 3")]++; + slots[bytes32("nested_storer 4")]++; + } +} + +/// @notice Helper contract that directly reads from and writes to storage +contract StorageAccessor { + function read(bytes32 slot) public view returns (bytes32 value) { + assembly { + value := sload(slot) + } + } + + function write(bytes32 slot, bytes32 value) public { + assembly { + sstore(slot, value) + } + } +} + +/// @notice Proxy contract +contract Proxy { + bytes32 public constant IMPL_ADDR = bytes32(uint256(keccak256("ekans implementation"))); + + constructor(address _delegate) { + bytes32 impl = IMPL_ADDR; + assembly { + sstore(impl, _delegate) + } + } + + receive() external payable { + doProxyCall(); + } + + fallback() external payable { + doProxyCall(); + } + + function doProxyCall() internal { + address _target; + bytes32 impl = IMPL_ADDR; + assembly { + _target := sload(impl) + calldatacopy(0x0, 0x0, calldatasize()) + let result := delegatecall(gas(), _target, 0x0, calldatasize(), 0x0, 0) + returndatacopy(0x0, 0x0, returndatasize()) + switch result + case 0 { revert(0, 0) } + default { return(0, returndatasize()) } + } + } +} + +/// @notice Test that the cheatcode correctly records account accesses +contract RecordAccountAccessesTest is DSTest { + Vm constant cheats = Vm(HEVM_ADDRESS); + NestedRunner runner; + NestedStorer nestedStorer; + Create2or create2or; + StorageAccessor test1; + StorageAccessor test2; + + function setUp() public { + runner = new NestedRunner(); + nestedStorer = new NestedStorer(); + create2or = new Create2or(); + test1 = new StorageAccessor(); + test2 = new StorageAccessor(); + } + + function testStorageAccessDelegateCall() public { + StorageAccessor one = test1; + Proxy proxy = new Proxy(address(one)); + + cheats.startStateDiffRecording(); + address(proxy).call(abi.encodeCall(StorageAccessor.read, bytes32(uint256(1234)))); + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + + assertEq(called.length, 2, "incorrect length"); + + assertEq(toUint(called[0].kind), toUint(Vm.AccountAccessKind.Call), "incorrect kind"); + assertEq(called[0].accessor, address(this)); + assertEq(called[0].account, address(proxy)); + + assertEq(toUint(called[1].kind), toUint(Vm.AccountAccessKind.DelegateCall), "incorrect kind"); + assertEq(called[1].account, address(one), "incorrect account"); + assertEq(called[1].accessor, address(this), "incorrect accessor"); + assertEq( + called[1].storageAccesses[0], + Vm.StorageAccess({ + account: address(proxy), + slot: bytes32(uint256(1234)), + isWrite: false, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(0)), + reverted: false + }) + ); + } + + /// @notice Test normal, non-nested storage accesses + function testStorageAccesses() public { + StorageAccessor one = test1; + StorageAccessor two = test2; + cheats.startStateDiffRecording(); + + one.read(bytes32(uint256(1234))); + one.write(bytes32(uint256(1235)), bytes32(uint256(5678))); + two.write(bytes32(uint256(5678)), bytes32(uint256(123469))); + two.write(bytes32(uint256(5678)), bytes32(uint256(1234))); + + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 4, "incorrect length"); + + assertEq(called[0].storageAccesses.length, 1, "incorrect storage length"); + Vm.StorageAccess memory access = called[0].storageAccesses[0]; + assertEq( + access, + Vm.StorageAccess({ + account: address(one), + slot: bytes32(uint256(1234)), + isWrite: false, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(0)), + reverted: false + }) + ); + + assertEq(called[1].storageAccesses.length, 1, "incorrect storage length"); + access = called[1].storageAccesses[0]; + assertEq( + access, + Vm.StorageAccess({ + account: address(one), + slot: bytes32(uint256(1235)), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(5678)), + reverted: false + }) + ); + + assertEq(called[2].storageAccesses.length, 1, "incorrect storage length"); + access = called[2].storageAccesses[0]; + assertEq( + access, + Vm.StorageAccess({ + account: address(two), + slot: bytes32(uint256(5678)), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(123469)), + reverted: false + }) + ); + + assertEq(called[3].storageAccesses.length, 1, "incorrect storage length"); + access = called[3].storageAccesses[0]; + assertEq( + access, + Vm.StorageAccess({ + account: address(two), + slot: bytes32(uint256(5678)), + isWrite: true, + previousValue: bytes32(uint256(123469)), + newValue: bytes32(uint256(1234)), + reverted: false + }) + ); + } + + /// @notice Test that basic account accesses are correctly recorded + function testRecordAccountAccesses() public { + cheats.startStateDiffRecording(); + + (bool succ,) = address(1234).call(""); + (succ,) = address(5678).call{value: 1 ether}(""); + (succ,) = address(123469).call("hello world"); + (succ,) = address(5678).call(""); + // contract calls to self in constructor + SelfCaller caller = new SelfCaller{value: 2 ether}('hello2 world2'); + + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 6); + assertEq( + called[0], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(1234), + kind: Vm.AccountAccessKind.Call, + initialized: false, + oldBalance: 0, + newBalance: 0, + deployedCode: hex"", + value: 0, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + + assertEq( + called[1], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(5678), + kind: Vm.AccountAccessKind.Call, + initialized: false, + oldBalance: 0, + newBalance: 1 ether, + deployedCode: hex"", + value: 1 ether, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[2], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(123469), + kind: Vm.AccountAccessKind.Call, + initialized: false, + oldBalance: 0, + newBalance: 0, + deployedCode: hex"", + value: 0, + data: "hello world", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[3], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(5678), + kind: Vm.AccountAccessKind.Call, + initialized: true, + oldBalance: 1 ether, + newBalance: 1 ether, + deployedCode: hex"", + value: 0, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[4], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(caller), + kind: Vm.AccountAccessKind.Create, + initialized: true, + oldBalance: 0, + newBalance: 2 ether, + deployedCode: address(caller).code, + value: 2 ether, + data: abi.encodePacked(type(SelfCaller).creationCode, abi.encode("hello2 world2")), + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[5], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(caller), + account: address(caller), + kind: Vm.AccountAccessKind.Call, + initialized: true, + oldBalance: 2 ether, + newBalance: 2 ether, + deployedCode: hex"", + value: 0.2 ether, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + } + + /// @notice Test that account accesses are correctly recorded when a call + /// reverts + function testRevertingCall() public { + uint256 initBalance = address(this).balance; + cheats.startStateDiffRecording(); + try this.revertingCall{value: 1 ether}(address(1234), "") {} catch {} + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 2); + assertEq( + called[0], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(this), + kind: Vm.AccountAccessKind.Call, + initialized: true, + oldBalance: initBalance, + newBalance: initBalance, + deployedCode: hex"", + value: 1 ether, + data: abi.encodeCall(this.revertingCall, (address(1234), "")), + reverted: true, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[1], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(1234), + kind: Vm.AccountAccessKind.Call, + initialized: false, + oldBalance: 0, + newBalance: 0.1 ether, + deployedCode: hex"", + value: 0.1 ether, + data: "", + reverted: true, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + } + + /// @notice Test that nested account accesses are correctly recorded + function testNested() public { + cheats.startStateDiffRecording(); + runNested(false, false); + } + + /// @notice Test that nested account accesses are correctly recorded when + /// the first call reverts + function testNested_Revert() public { + cheats.startStateDiffRecording(); + runNested(true, false); + } + + /// @notice Helper function to test nested account accesses + /// @param shouldRevert Whether the first call should revert + function runNested(bool shouldRevert, bool expectFirstCall) public { + try runner.run{value: 1 ether}(shouldRevert) {} catch {} + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 7 + toUint(expectFirstCall), "incorrect length"); + + uint256 startingIndex = toUint(expectFirstCall); + if (expectFirstCall) { + assertEq( + called[0], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(1234), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: false, + value: 0, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + } + + assertEq(called[startingIndex].storageAccesses.length, 2, "incorrect length"); + assertIncrementEq( + called[startingIndex].storageAccesses[0], + called[startingIndex].storageAccesses[1], + Vm.StorageAccess({ + account: address(runner), + slot: keccak256(abi.encodePacked(bytes32("runner"), bytes32(0))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: shouldRevert + }) + ); + assertEq( + called[startingIndex], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(runner), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: shouldRevert ? 0 : 0.9 ether, + deployedCode: "", + initialized: true, + value: 1 ether, + data: abi.encodeCall(NestedRunner.run, (shouldRevert)), + reverted: shouldRevert, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[startingIndex + 1].storageAccesses.length, 2, "incorrect length"); + assertIncrementEq( + called[startingIndex + 1].storageAccesses[0], + called[startingIndex + 1].storageAccesses[1], + Vm.StorageAccess({ + account: address(runner.reverter()), + slot: keccak256(abi.encodePacked(bytes32("reverter"), bytes32(0))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: true + }) + ); + assertEq( + called[startingIndex + 1], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(runner), + account: address(runner.reverter()), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: true, + value: 0.1 ether, + data: abi.encodeCall(Reverter.run, ()), + reverted: true, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[startingIndex + 2].storageAccesses.length, 2, "incorrect length"); + assertIncrementEq( + called[startingIndex + 2].storageAccesses[0], + called[startingIndex + 2].storageAccesses[1], + Vm.StorageAccess({ + account: address(runner.doer()), + slot: keccak256(abi.encodePacked(bytes32("doer 1"), uint256(10))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: true + }) + ); + assertEq( + called[startingIndex + 2], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(runner.reverter()), + account: address(runner.doer()), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0.01 ether, + deployedCode: "", + initialized: true, + value: 0.01 ether, + data: abi.encodeCall(Doer.run, ()), + reverted: true, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[startingIndex + 3].storageAccesses.length, 2, "incorrect length"); + assertIncrementEq( + called[startingIndex + 3].storageAccesses[0], + called[startingIndex + 3].storageAccesses[1], + Vm.StorageAccess({ + account: address(runner.doer()), + slot: keccak256(abi.encodePacked(bytes32("doer 2"), uint256(10))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: true + }) + ); + assertEq( + called[startingIndex + 3], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(runner.doer()), + account: address(runner.doer()), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0.01 ether, + newBalance: 0.01 ether, + deployedCode: "", + initialized: true, + value: 0.001 ether, + data: abi.encodeCall(Doer.doStuff, ()), + reverted: true, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[startingIndex + 4].storageAccesses.length, 2, "incorrect length"); + assertIncrementEq( + called[startingIndex + 4].storageAccesses[0], + called[startingIndex + 4].storageAccesses[1], + Vm.StorageAccess({ + account: address(runner.succeeder()), + slot: keccak256(abi.encodePacked(bytes32("succeeder"), uint256(0))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: shouldRevert + }) + ); + assertEq( + called[startingIndex + 4], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(runner), + account: address(runner.succeeder()), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0.09 ether, + deployedCode: "", + initialized: true, + value: 0.1 ether, + data: abi.encodeCall(Succeeder.run, ()), + reverted: shouldRevert, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[startingIndex + 5].storageAccesses.length, 2, "incorrect length"); + assertIncrementEq( + called[startingIndex + 5].storageAccesses[0], + called[startingIndex + 5].storageAccesses[1], + Vm.StorageAccess({ + account: address(runner.doer()), + slot: keccak256(abi.encodePacked(bytes32("doer 1"), uint256(10))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: shouldRevert + }) + ); + assertEq( + called[startingIndex + 5], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(runner.succeeder()), + account: address(runner.doer()), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0.01 ether, + deployedCode: "", + initialized: true, + value: 0.01 ether, + data: abi.encodeCall(Doer.run, ()), + reverted: shouldRevert, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[startingIndex + 3].storageAccesses.length, 2, "incorrect length"); + assertIncrementEq( + called[startingIndex + 6].storageAccesses[0], + called[startingIndex + 6].storageAccesses[1], + Vm.StorageAccess({ + account: address(runner.doer()), + slot: keccak256(abi.encodePacked(bytes32("doer 2"), uint256(10))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: shouldRevert + }) + ); + assertEq( + called[startingIndex + 6], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(runner.doer()), + account: address(runner.doer()), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0.01 ether, + newBalance: 0.01 ether, + deployedCode: "", + initialized: true, + value: 0.001 ether, + data: abi.encodeCall(Doer.doStuff, ()), + reverted: shouldRevert, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + } + + function testNestedStorage() public { + cheats.startStateDiffRecording(); + nestedStorer.run(); + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 3, "incorrect account access length"); + + assertEq(called[0].storageAccesses.length, 2, "incorrect run storage length"); + assertIncrementEq( + called[0].storageAccesses[0], + called[0].storageAccesses[1], + Vm.StorageAccess({ + account: address(nestedStorer), + slot: keccak256(abi.encodePacked(bytes32("nested_storer 1"), bytes32(0))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: false + }) + ); + assertEq( + called[0], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(nestedStorer), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: true, + value: 0, + data: abi.encodeCall(NestedStorer.run, ()), + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[1].storageAccesses.length, 4, "incorrect run2 storage length"); + assertIncrementEq( + called[1].storageAccesses[0], + called[1].storageAccesses[1], + Vm.StorageAccess({ + account: address(nestedStorer), + slot: keccak256(abi.encodePacked(bytes32("nested_storer 3"), bytes32(0))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: false + }) + ); + assertIncrementEq( + called[1].storageAccesses[2], + called[1].storageAccesses[3], + Vm.StorageAccess({ + account: address(nestedStorer), + slot: keccak256(abi.encodePacked(bytes32("nested_storer 4"), bytes32(0))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: false + }) + ); + assertEq( + called[1], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(nestedStorer), + account: address(nestedStorer), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: true, + value: 0, + data: abi.encodeCall(NestedStorer.run2, ()), + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + + assertEq(called[2].storageAccesses.length, 2, "incorrect resume storage length"); + assertIncrementEq( + called[2].storageAccesses[0], + called[2].storageAccesses[1], + Vm.StorageAccess({ + account: address(nestedStorer), + slot: keccak256(abi.encodePacked(bytes32("nested_storer 2"), bytes32(0))), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: false + }) + ); + assertEq( + called[2], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(nestedStorer), + kind: Vm.AccountAccessKind.Resume, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: true, + value: 0, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + } + + /// @notice Test that constructor account and storage accesses are recorded, including reverts + function testConstructorStorage() public { + cheats.startStateDiffRecording(); + address storer = address(new ConstructorStorer(false)); + try create2or.create2(bytes32(0), abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(true))) {} + catch {} + bytes memory creationCode = abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(true)); + address hypotheticalStorer = deriveCreate2Address(address(create2or), bytes32(0), keccak256(creationCode)); + + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 3, "incorrect account access length"); + assertEq(toUint(called[0].kind), toUint(Vm.AccountAccessKind.Create), "incorrect kind"); + assertEq(toUint(called[1].kind), toUint(Vm.AccountAccessKind.Call), "incorrect kind"); + assertEq(toUint(called[2].kind), toUint(Vm.AccountAccessKind.Create), "incorrect kind"); + + assertEq(called[0].storageAccesses.length, 1, "incorrect storage access length"); + Vm.StorageAccess[] memory storageAccesses = new Vm.StorageAccess[](1); + storageAccesses[0] = Vm.StorageAccess({ + account: storer, + slot: bytes32(uint256(0)), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: false + }); + assertEq( + called[0], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(storer), + kind: Vm.AccountAccessKind.Create, + oldBalance: 0, + newBalance: 0, + deployedCode: storer.code, + initialized: true, + value: 0, + data: abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(false)), + reverted: false, + storageAccesses: storageAccesses + }) + ); + + assertEq(called[1].storageAccesses.length, 0, "incorrect storage access length"); + assertEq( + called[1], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: address(create2or), + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: true, + value: 0, + data: abi.encodeCall( + Create2or.create2, + (bytes32(0), abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(true))) + ), + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + + assertEq(called[2].storageAccesses.length, 1, "incorrect storage access length"); + storageAccesses = new Vm.StorageAccess[](1); + storageAccesses[0] = Vm.StorageAccess({ + account: hypotheticalStorer, + slot: bytes32(uint256(0)), + isWrite: true, + previousValue: bytes32(uint256(0)), + newValue: bytes32(uint256(1)), + reverted: true + }); + assertEq( + called[2], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(create2or), + account: hypotheticalStorer, + kind: Vm.AccountAccessKind.Create, + oldBalance: 0, + newBalance: 0, + deployedCode: address(hypotheticalStorer).code, + initialized: true, + value: 0, + data: creationCode, + reverted: true, + storageAccesses: storageAccesses + }) + ); + } + + /// @notice Test that account accesses are correctly recorded when the + /// recording is started from a lower depth than they are + /// retrieved + function testNested_LowerDepth() public { + this.startRecordingFromLowerDepth(); + runNested(false, true); + } + + /// @notice Test that account accesses are correctly recorded when + /// the first call reverts the and recording is started from + /// a lower depth than they are retrieved. + function testNested_LowerDepth_Revert() public { + this.startRecordingFromLowerDepth(); + runNested(true, true); + } + + /// @notice Test that constructor calls and calls made within a constructor + /// are correctly recorded, even if it reverts + function testCreateRevert() public { + cheats.startStateDiffRecording(); + bytes memory creationCode = abi.encodePacked(type(SelfCaller).creationCode, abi.encode("")); + try create2or.create2(bytes32(0), creationCode) {} catch {} + address hypotheticalAddress = deriveCreate2Address(address(create2or), bytes32(0), keccak256(creationCode)); + + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 3, "incorrect length"); + assertEq( + called[1], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(create2or), + account: hypotheticalAddress, + kind: Vm.AccountAccessKind.Create, + oldBalance: 0, + newBalance: 0, + deployedCode: address(hypotheticalAddress).code, + initialized: true, + value: 0, + data: creationCode, + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[2], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: hypotheticalAddress, + account: hypotheticalAddress, + kind: Vm.AccountAccessKind.Call, + oldBalance: 0, + newBalance: 0, + deployedCode: hex"", + initialized: true, + value: 0, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + } + + /// @notice It is important to test SELFDESTRUCT behavior as long as there + /// are public networks that support the opcode, regardless of whether + /// or not Ethereum mainnet does. + function testSelfDestruct() public { + uint256 startingBalance = address(this).balance; + this.startRecordingFromLowerDepth(); + address a = address(new SelfDestructor{value:1 ether}(address(this))); + address b = address(new SelfDestructor{value:1 ether}(address(bytes20("doesn't exist yet")))); + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 5, "incorrect length"); + assertEq( + called[1], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: a, + kind: Vm.AccountAccessKind.Create, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: true, + value: 1 ether, + data: abi.encodePacked(type(SelfDestructor).creationCode, abi.encode(address(this))), + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[2], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(a), + account: address(this), + kind: Vm.AccountAccessKind.SelfDestruct, + oldBalance: startingBalance - 1 ether, + newBalance: startingBalance, + deployedCode: "", + initialized: true, + value: 1 ether, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[3], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(this), + account: b, + kind: Vm.AccountAccessKind.Create, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: true, + value: 1 ether, + data: abi.encodePacked(type(SelfDestructor).creationCode, abi.encode(address(bytes20("doesn't exist yet")))), + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + assertEq( + called[4], + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: address(b), + account: address(bytes20("doesn't exist yet")), + kind: Vm.AccountAccessKind.SelfDestruct, + oldBalance: 0, + newBalance: 1 ether, + deployedCode: hex"", + initialized: false, + value: 1 ether, + data: "", + reverted: false, + storageAccesses: new Vm.StorageAccess[](0) + }) + ); + } + + function startRecordingFromLowerDepth() external { + cheats.startStateDiffRecording(); + assembly { + pop(call(gas(), 1234, 0, 0, 0, 0, 0)) + } + } + + function revertingCall(address target, bytes memory data) external payable { + assembly { + pop(call(gas(), target, div(callvalue(), 10), add(data, 0x20), mload(data), 0, 0)) + } + revert(); + } + + /// Asserts that the given account access is a resume of the given parent + function assertResumeEq(Vm.AccountAccess memory actual, Vm.AccountAccess memory expected) internal { + assertEq( + actual, + Vm.AccountAccess({ + chainInfo: Vm.ChainInfo({forkId: 0, chainId: 0}), + accessor: expected.accessor, + account: expected.account, + kind: Vm.AccountAccessKind.Resume, + oldBalance: 0, + newBalance: 0, + deployedCode: "", + initialized: expected.initialized, + value: 0, + data: "", + reverted: expected.reverted, + storageAccesses: new Vm.StorageAccess[](0) + }), + false + ); + } + + function assertIncrementEq( + Vm.StorageAccess memory read, + Vm.StorageAccess memory write, + Vm.StorageAccess memory expected + ) internal { + assertEq( + read, + Vm.StorageAccess({ + account: expected.account, + slot: expected.slot, + isWrite: false, + previousValue: expected.previousValue, + newValue: expected.previousValue, + reverted: expected.reverted + }) + ); + assertEq( + write, + Vm.StorageAccess({ + account: expected.account, + slot: expected.slot, + isWrite: true, + previousValue: expected.previousValue, + newValue: expected.newValue, + reverted: expected.reverted + }) + ); + } + + function assertEq(Vm.AccountAccess memory actualAccess, Vm.AccountAccess memory expectedAccess) internal { + assertEq(actualAccess, expectedAccess, true); + } + + function assertEq(Vm.AccountAccess memory actualAccess, Vm.AccountAccess memory expectedAccess, bool checkStorage) + internal + { + assertEq(toUint(actualAccess.kind), toUint(expectedAccess.kind), "incorrect kind"); + assertEq(actualAccess.account, expectedAccess.account, "incorrect account"); + assertEq(actualAccess.accessor, expectedAccess.accessor, "incorrect accessor"); + assertEq(toUint(actualAccess.initialized), toUint(expectedAccess.initialized), "incorrect initialized"); + assertEq(actualAccess.oldBalance, expectedAccess.oldBalance, "incorrect oldBalance"); + assertEq(actualAccess.newBalance, expectedAccess.newBalance, "incorrect newBalance"); + assertEq(actualAccess.deployedCode, expectedAccess.deployedCode, "incorrect deployedCode"); + assertEq(actualAccess.value, expectedAccess.value, "incorrect value"); + assertEq(actualAccess.data, expectedAccess.data, "incorrect data"); + assertEq(toUint(actualAccess.reverted), toUint(expectedAccess.reverted), "incorrect reverted"); + if (checkStorage) { + assertEq( + actualAccess.storageAccesses.length, + expectedAccess.storageAccesses.length, + "incorrect storageAccesses length" + ); + for (uint256 i = 0; i < actualAccess.storageAccesses.length; i++) { + assertEq(actualAccess.storageAccesses[i], expectedAccess.storageAccesses[i]); + } + } + } + + function assertEq(Vm.StorageAccess memory actual, Vm.StorageAccess memory expected) internal { + assertEq(actual.account, expected.account, "incorrect storageAccess account"); + assertEq(actual.slot, expected.slot, "incorrect storageAccess slot"); + assertEq(toUint(actual.isWrite), toUint(expected.isWrite), "incorrect storageAccess isWrite"); + assertEq(actual.previousValue, expected.previousValue, "incorrect storageAccess previousValue"); + assertEq(actual.newValue, expected.newValue, "incorrect storageAccess newValue"); + assertEq(toUint(actual.reverted), toUint(expected.reverted), "incorrect storageAccess reverted"); + } + + function toUint(Vm.AccountAccessKind kind) internal pure returns (uint256 value) { + assembly { + value := and(kind, 0xff) + } + } + + function toUint(bool a) internal pure returns (uint256) { + return a ? 1 : 0; + } + + function deriveCreate2Address(address deployer, bytes32 salt, bytes32 codeHash) internal pure returns (address) { + return address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, codeHash))))); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 0d718ccd967fe..4fc5c3ce51b29 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -7,6 +7,7 @@ pragma solidity ^0.8.4; interface Vm { error CheatcodeError(string message); enum CallerMode { None, Broadcast, RecurrentBroadcast, Prank, RecurrentPrank } + enum AccountAccessKind { Call, DelegateCall, CallCode, StaticCall, Create, SelfDestruct, Resume } 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; } @@ -14,6 +15,9 @@ interface Vm { 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; } + struct StorageAccess { address account; bytes32 slot; bool isWrite; bytes32 previousValue; bytes32 newValue; bool reverted; } function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots); function activeFork() external view returns (uint256 forkId); function addr(uint256 privateKey) external pure returns (address keyAddr); @@ -209,6 +213,8 @@ interface Vm { function startMappingRecording() external; function startPrank(address msgSender) external; function startPrank(address msgSender, address txOrigin) external; + function startStateDiffRecording() external; + function stopAndReturnStateDiff() external returns (AccountAccess[] memory accesses); function stopBroadcast() external; function stopMappingRecording() external; function stopPrank() external; From 196fdb71fbd93c88bf14b28f040d0138728046fc Mon Sep 17 00:00:00 2001 From: Tudor <32748771+RedaOps@users.noreply.github.com> Date: Sat, 18 Nov 2023 09:31:53 +0200 Subject: [PATCH 0296/1963] Only load root TLS certificates with HTTPs rpc-url (#6350) --- crates/common/src/runtime_client.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index 38fd9ddf9d0c0..62d4810dcb90b 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -128,7 +128,9 @@ impl RuntimeClient { async fn connect(&self) -> Result { match self.url.scheme() { "http" | "https" => { - let mut client_builder = reqwest::Client::builder().timeout(self.timeout); + let mut client_builder = reqwest::Client::builder() + .timeout(self.timeout) + .tls_built_in_root_certs(self.url.scheme() == "https"); let mut headers = reqwest::header::HeaderMap::new(); if let Some(jwt) = self.jwt.as_ref() { From 138ab405f68a71420815b3cad1f76e4e37e81740 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 18 Nov 2023 19:56:11 +0100 Subject: [PATCH 0297/1963] fix(foundryup): actually make `set -e` work (#6352) --- foundryup/foundryup | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index ee70c2c9a8d21..554051507a6a7 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -eo pipefail BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} @@ -14,7 +14,7 @@ main() { need_cmd git need_cmd curl - while [[ $1 ]]; do + while [[ -n $1 ]]; do case $1 in --) shift; break;; @@ -91,7 +91,8 @@ main() { say "installing foundry (version ${FOUNDRYUP_VERSION}, tag ${FOUNDRYUP_TAG})" - PLATFORM=$(tolower "${FOUNDRYUP_PLATFORM:-$(uname -s)}") + uname_s=$(uname -s) + PLATFORM=$(tolower "${FOUNDRYUP_PLATFORM:-$uname_s}") EXT="tar.gz" case $PLATFORM in linux) ;; @@ -107,7 +108,8 @@ main() { ;; esac - ARCHITECTURE=$(tolower "${FOUNDRYUP_ARCH:-$(uname -m)}") + uname_m=$(uname -m) + ARCHITECTURE=$(tolower "${FOUNDRYUP_ARCH:-$uname_m}") if [ "${ARCHITECTURE}" = "x86_64" ]; then # Redirect stderr to /dev/null to avoid printing errors if non Rosetta. if [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = "1" ]; then @@ -266,15 +268,14 @@ check_cmd() { } # Run a command that should never fail. If the command fails execution -# will immediately terminate with an error showing the failing -# command. +# will immediately terminate with an error showing the failing command. ensure() { if ! "$@"; then err "command failed: $*"; fi } # Downloads $1 into $2 or stdout download() { - if [ "$2" ]; then + if [ -n "$2" ]; then # output into $2 if check_cmd curl; then curl -#o "$2" -L "$1" @@ -315,4 +316,4 @@ Contribute : https://github.com/orgs/foundry-rs/projects/2/ } -main "$@" || exit 1 +main "$@" From f23c7befc1ba924b8155c65b765e420bbf70039f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 18 Nov 2023 22:07:49 +0100 Subject: [PATCH 0298/1963] fix: use raw formatter when printing script JSON (#6354) --- crates/evm/traces/src/decoder/mod.rs | 9 +++++++-- crates/evm/traces/src/lib.rs | 2 -- crates/evm/traces/src/utils.rs | 23 ----------------------- crates/forge/bin/cmd/script/mod.rs | 8 ++++---- 4 files changed, 11 insertions(+), 31 deletions(-) delete mode 100644 crates/evm/traces/src/utils.rs diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index ccb9d47c0b07d..43e42eba21d88 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -1,6 +1,6 @@ use crate::{ identifier::{AddressIdentity, SingleSignaturesIdentifier, TraceIdentifier}, - utils, CallTrace, CallTraceArena, TraceCallData, TraceLog, TraceRetData, + CallTrace, CallTraceArena, TraceCallData, TraceLog, TraceRetData, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function, JsonAbi as Abi}; @@ -463,7 +463,12 @@ impl CallTraceDecoder { } fn apply_label(&self, value: &DynSolValue) -> String { - utils::label(value, &self.labels) + if let DynSolValue::Address(addr) = value { + if let Some(label) = self.labels.get(addr) { + return format!("{label}: [{addr}]"); + } + } + format_token(value) } } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 98b05188d8ffd..d9da3699150ad 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -37,8 +37,6 @@ pub use inspector::Tracer; mod node; pub use node::CallTraceNode; -pub mod utils; - pub type Traces = Vec<(TraceKind, CallTraceArena)>; /// An arena of [CallTraceNode]s diff --git a/crates/evm/traces/src/utils.rs b/crates/evm/traces/src/utils.rs deleted file mode 100644 index ead0544e577f4..0000000000000 --- a/crates/evm/traces/src/utils.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! utilities used within tracing - -use alloy_dyn_abi::DynSolValue; -use alloy_primitives::Address; -use foundry_common::fmt::format_token; -use std::collections::HashMap; - -/// Returns the label for the given [DynSolValue] -/// -/// If the `token` is an `Address` then we look abel the label map. -/// by default the token is formatted using standard formatting -pub fn label(token: &DynSolValue, labels: &HashMap) -> String { - match token { - DynSolValue::Address(addr) => { - if let Some(label) = labels.get(addr) { - format!("{label}: [{addr}]") - } else { - format_token(token) - } - } - _ => format_token(token), - } -} diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 8a5dcbc18b655..0182d921b3c9c 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -28,7 +28,7 @@ use foundry_common::{ contracts::get_contract_name, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, - fmt::format_token, + fmt::{format_token, format_token_raw}, shell, ContractsByArtifact, RpcUrl, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::{ @@ -248,7 +248,7 @@ impl ScriptArgs { Ok(decoder) } - pub fn get_returns( + fn get_returns( &self, script_config: &ScriptConfig, returned: &Bytes, @@ -275,7 +275,7 @@ impl ScriptArgs { label, NestedValue { internal_type: internal_type.to_string(), - value: format_token(token), + value: format_token_raw(token), }, ); } @@ -299,7 +299,7 @@ impl ScriptArgs { if !result.success || verbosity > 3 { if result.traces.is_empty() { - eyre::bail!("Unexpected error: No traces despite verbosity level. Please report this as a bug: https://github.com/foundry-rs/foundry/issues/new?assignees=&labels=T-bug&template=BUG-FORM.yml"); + warn!(verbosity, "no traces"); } shell::println("Traces:")?; From 3ed38dff360fc70a6da5480f9e27be7cf91d095d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 19 Nov 2023 09:50:57 +0100 Subject: [PATCH 0299/1963] chore(deps): weekly `cargo update` (#6357) Updating git repository `https://github.com/alloy-rs/core/` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating alloy-dyn-abi v0.4.2 (https://github.com/alloy-rs/core/#0ea90245) -> #a707bcd7 Updating alloy-json-abi v0.4.2 (https://github.com/alloy-rs/core/#0ea90245) -> #a707bcd7 Updating alloy-primitives v0.4.2 (https://github.com/alloy-rs/core/#0ea90245) -> #a707bcd7 Updating alloy-sol-macro v0.4.2 (https://github.com/alloy-rs/core/#0ea90245) -> #a707bcd7 Updating alloy-sol-type-parser v0.4.2 (https://github.com/alloy-rs/core/#0ea90245) -> #a707bcd7 Updating alloy-sol-types v0.4.2 (https://github.com/alloy-rs/core/#0ea90245) -> #a707bcd7 Updating cargo-platform v0.1.4 -> v0.1.5 Updating color-spantrace v0.2.0 -> v0.2.1 Updating crypto-bigint v0.5.4 -> v0.5.5 Updating ecdsa v0.16.8 -> v0.16.9 Updating eyre v0.6.8 -> v0.6.9 Updating rustls v0.21.8 -> v0.21.9 Updating signature v2.1.0 -> v2.2.0 Updating syn-solidity v0.4.2 (https://github.com/alloy-rs/core/#0ea90245) -> #a707bcd7 Updating zeroize v1.6.1 -> v1.7.0 Co-authored-by: mattsse --- Cargo.lock | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfda789a12c5c..8b0fbf53a6507 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" +source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" +source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" +source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" dependencies = [ "alloy-rlp", "arbitrary", @@ -168,7 +168,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" +source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" dependencies = [ "const-hex", "dunce", @@ -185,7 +185,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" +source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" dependencies = [ "winnow", ] @@ -193,7 +193,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" +source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -940,9 +940,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" +checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" dependencies = [ "serde", ] @@ -1328,9 +1328,9 @@ dependencies = [ [[package]] name = "color-spantrace" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" dependencies = [ "once_cell", "owo-colors", @@ -1584,9 +1584,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28f85c3514d2a6e64160359b45a3918c3b4178bcbf4ae5d03ab2d02e521c479a" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -1826,9 +1826,9 @@ checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest 0.10.7", @@ -2339,9 +2339,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +checksum = "80f656be11ddf91bd709454d15d5bd896fbaf4cc3314e69349e4d1569f5b46cd" dependencies = [ "indenter", "once_cell", @@ -3789,7 +3789,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.8", + "rustls 0.21.9", "tokio", "tokio-rustls 0.24.1", ] @@ -5717,7 +5717,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.8", + "rustls 0.21.9", "rustls-native-certs", "rustls-pemfile", "serde", @@ -6068,9 +6068,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.8" +version = "0.21.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", "ring 0.17.5", @@ -6577,9 +6577,9 @@ dependencies = [ [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", "rand_core 0.6.4", @@ -6832,7 +6832,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#0ea90245bdc166e0296fdf70cc4ca329ddbad9e4" +source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" dependencies = [ "paste", "proc-macro2", @@ -7113,7 +7113,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.8", + "rustls 0.21.9", "tokio", ] @@ -7137,7 +7137,7 @@ dependencies = [ "futures-util", "log", "native-tls", - "rustls 0.21.8", + "rustls 0.21.9", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -7433,7 +7433,7 @@ dependencies = [ "log", "native-tls", "rand 0.8.5", - "rustls 0.21.8", + "rustls 0.21.9", "sha1", "thiserror", "url", @@ -8069,9 +8069,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12a3946ecfc929b583800f4629b6c25b88ac6e92a40ea5670f77112a85d40a8b" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] From 3e962e2efe17396886fcb1fd141ccf4204cd3a21 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 19 Nov 2023 19:02:01 +0100 Subject: [PATCH 0300/1963] fix(anvil): anvil_metadata return types (#6360) --- crates/anvil/core/src/types.rs | 10 +++++----- crates/anvil/src/eth/api.rs | 17 ++++++++--------- crates/anvil/src/eth/backend/mem/mod.rs | 12 +++++------- crates/anvil/tests/it/anvil_api.rs | 10 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 9dd87aacd74ed..e15c648b0532a 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -190,7 +190,7 @@ pub struct NodeInfo { #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct NodeEnvironment { pub base_fee: U256, - pub chain_id: U256, + pub chain_id: u64, pub gas_limit: U256, pub gas_price: U256, } @@ -212,9 +212,9 @@ pub struct NodeForkConfig { #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct AnvilMetadata { pub client_version: &'static str, - pub chain_id: U256, + pub chain_id: u64, pub instance_id: H256, - pub latest_block_number: U64, + pub latest_block_number: u64, pub latest_block_hash: H256, pub forked_network: Option, } @@ -225,8 +225,8 @@ pub struct AnvilMetadata { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct ForkedNetwork { - pub chain_id: U256, - pub fork_block_number: U64, + pub chain_id: u64, + pub fork_block_number: u64, pub fork_block_hash: TxHash, } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 947e47f3cce7b..4480e2b6ee111 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -493,7 +493,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_chainId` pub fn eth_chain_id(&self) -> Result> { node_info!("eth_chainId"); - Ok(Some(self.backend.chain_id().as_u64().into())) + Ok(Some(self.backend.chain_id().into())) } /// Returns the same as `chain_id` @@ -501,7 +501,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_networkId` pub fn network_id(&self) -> Result> { node_info!("eth_networkId"); - let chain_id = self.backend.chain_id().as_u64(); + let chain_id = self.backend.chain_id(); Ok(Some(format!("{chain_id}"))) } @@ -1708,17 +1708,16 @@ impl EthApi { pub async fn anvil_metadata(&self) -> Result { node_info!("anvil_metadata"); let fork_config = self.backend.get_fork(); - let chain_id_uint = U256::from(self.backend.chain_id().low_u64()); - let latest_block_number_uint = U64::from(self.backend.best_number().low_u64()); + Ok(AnvilMetadata { client_version: CLIENT_VERSION, - chain_id: chain_id_uint, + chain_id: self.backend.chain_id().try_into().unwrap_or(u64::MAX), latest_block_hash: self.backend.best_hash(), - latest_block_number: latest_block_number_uint, + latest_block_number: self.backend.best_number().as_u64(), instance_id: *self.instance_id.read(), forked_network: fork_config.map(|cfg| ForkedNetwork { - chain_id: U256::from(cfg.chain_id()), - fork_block_number: U64::from(cfg.block_number()), + chain_id: cfg.chain_id().into(), + fork_block_number: cfg.block_number().into(), fork_block_hash: cfg.block_hash(), }), }) @@ -2302,7 +2301,7 @@ impl EthApi { /// Returns the chain ID used for transaction pub fn chain_id(&self) -> u64 { - self.backend.chain_id().as_u64() + self.backend.chain_id() } pub fn get_fork(&self) -> Option { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index fcfaa8f1040ea..0907c0ffdfe9d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -470,8 +470,7 @@ impl Backend { /// Returns the current best number of the chain pub fn best_number(&self) -> U64 { - let num: u64 = self.env.read().block.number.try_into().unwrap_or(u64::MAX); - num.into() + self.env.read().block.number.saturating_to::().into() } /// Sets the block number @@ -486,8 +485,8 @@ impl Backend { } /// Returns the client coinbase address. - pub fn chain_id(&self) -> U256 { - self.env.read().cfg.chain_id.into() + pub fn chain_id(&self) -> u64 { + self.env.read().cfg.chain_id } pub fn set_chain_id(&self, chain_id: u64) { @@ -2202,11 +2201,10 @@ impl TransactionValidator for Backend { if let Some(tx_chain_id) = tx.chain_id() { let chain_id = self.chain_id(); - if chain_id != tx_chain_id.into() { + if chain_id != tx_chain_id { if let Some(legacy) = tx.as_legacy() { // - if env.cfg.spec_id >= SpecId::SPURIOUS_DRAGON && - !legacy.meets_eip155(chain_id.as_u64()) + if env.cfg.spec_id >= SpecId::SPURIOUS_DRAGON && !legacy.meets_eip155(chain_id) { warn!(target: "backend", ?chain_id, ?tx_chain_id, "incompatible EIP155-based V"); return Err(InvalidTransactionError::IncompatibleEIP155) diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 272f6b2824c73..2f54668857892 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -440,7 +440,7 @@ async fn can_get_node_info() { transaction_order: "fees".to_owned(), environment: NodeEnvironment { base_fee: U256::from_str("0x3b9aca00").unwrap(), - chain_id: U256::from_str("0x7a69").unwrap(), + chain_id: 0x7a69, gas_limit: U256::from_str("0x1c9c380").unwrap(), gas_price: U256::from_str("0x77359400").unwrap(), }, @@ -462,8 +462,8 @@ async fn can_get_metadata() { let provider = handle.http_provider(); - let block_number = provider.get_block_number().await.unwrap(); - let chain_id = provider.get_chainid().await.unwrap(); + let block_number = provider.get_block_number().await.unwrap().as_u64(); + let chain_id = provider.get_chainid().await.unwrap().as_u64(); let block = provider.get_block(block_number).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { @@ -486,8 +486,8 @@ async fn can_get_metadata_on_fork() { let metadata = api.anvil_metadata().await.unwrap(); - let block_number = provider.get_block_number().await.unwrap(); - let chain_id = provider.get_chainid().await.unwrap(); + let block_number = provider.get_block_number().await.unwrap().as_u64(); + let chain_id = provider.get_chainid().await.unwrap().as_u64(); let block = provider.get_block(block_number).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { From a0d19114127d825fa2b48f9ed3a553832a765966 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 20 Nov 2023 06:45:34 -0500 Subject: [PATCH 0301/1963] Revert k256 bump (#6358) * Revert k256 bump This k256 version breaks revm, as documented in https://github.com/RustCrypto/elliptic-curves/issues/988, which breaks foundry. While I would instead wait to bump revm, foundry nightly (the only supported version per the provided GH action) is broken and I'd rather correct it ASAP. * Lock to 0.13.1 in anvil/Cargo.toml --- Cargo.lock | 4 ++-- crates/anvil/Cargo.toml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b0fbf53a6507..a3b87b9cbd0cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4078,9 +4078,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", "ecdsa", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 4137e7ce590ec..2879a8803eb93 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -30,6 +30,8 @@ foundry-utils.workspace = true # evm support bytes = "1.4.0" +# needed as documented in https://github.com/foundry-rs/foundry/pull/6358 +k256 = "=0.13.1" ethers = { workspace = true, features = ["rustls", "ws", "ipc"] } trie-db = "0.23" hash-db = "0.15" From 83295490a61881a1698e05f913fee9c7e1d30568 Mon Sep 17 00:00:00 2001 From: Tudor <32748771+RedaOps@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:54:23 +0200 Subject: [PATCH 0302/1963] feat(`cast create2`): Added `--caller` flag (#6363) * Added `--caller` flag to `cast create2` * Clean up code * nit: remove match * review * fix clippy --- crates/anvil/src/eth/api.rs | 6 +++--- crates/cast/bin/cmd/create2.rs | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 4480e2b6ee111..7be3be0599257 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1711,13 +1711,13 @@ impl EthApi { Ok(AnvilMetadata { client_version: CLIENT_VERSION, - chain_id: self.backend.chain_id().try_into().unwrap_or(u64::MAX), + chain_id: self.backend.chain_id(), latest_block_hash: self.backend.best_hash(), latest_block_number: self.backend.best_number().as_u64(), instance_id: *self.instance_id.read(), forked_network: fork_config.map(|cfg| ForkedNetwork { - chain_id: cfg.chain_id().into(), - fork_block_number: cfg.block_number().into(), + chain_id: cfg.chain_id(), + fork_block_number: cfg.block_number(), fork_block_hash: cfg.block_hash(), }), }) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 9af59c92bb7a5..c28b64fa48d51 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -54,6 +54,10 @@ pub struct Create2Args { /// Number of threads to use. Defaults to and caps at the number of logical cores. #[clap(short, long)] jobs: Option, + + /// Address of the caller. Used for the first 20 bytes of the salt. + #[clap(long, value_name = "ADDRESS")] + caller: Option
, } #[allow(dead_code)] @@ -73,6 +77,7 @@ impl Create2Args { init_code, init_code_hash, jobs, + caller, } = self; let mut regexs = vec![]; @@ -132,6 +137,11 @@ impl Create2Args { n_threads = n_threads.min(2); } + let mut top_bytes = B256::ZERO; + if let Some(caller_address) = caller { + top_bytes[..20].copy_from_slice(&caller_address.into_array()); + } + println!("Starting to generate deterministic contract address..."); let mut handles = Vec::with_capacity(n_threads); let found = Arc::new(AtomicBool::new(false)); @@ -148,10 +158,11 @@ impl Create2Args { handles.push(std::thread::spawn(move || { // Read the first bytes of the salt as a usize to be able to increment it. struct B256Aligned(B256, [usize; 0]); - let mut salt = B256Aligned(B256::ZERO, []); + let mut salt = B256Aligned(top_bytes, []); // SAFETY: B256 is aligned to `usize`. - let salt_word = unsafe { &mut *salt.0.as_mut_ptr().cast::() }; - + let salt_word = unsafe { + &mut *salt.0.as_mut_ptr().add(32 - usize::BITS as usize / 8).cast::() + }; // Important: set the salt to the start value, otherwise all threads loop over the // same values. *salt_word = i; @@ -304,4 +315,21 @@ mod tests { .create2(salt, B256::from_slice(hex::decode(init_code_hash).unwrap().as_slice())) ); } + + #[test] + fn create2_caller() { + let init_code_hash = "bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a"; + let args = Create2Args::parse_from([ + "foundry-cli", + "--starts-with=dd", + "--init-code-hash", + init_code_hash, + "--caller=0x66f9664f97F2b50F62D13eA064982f936dE76657", + ]); + let create2_out = args.run().unwrap(); + let address = create2_out.address; + let salt = create2_out.salt; + assert!(format!("{address:x}").starts_with("dd")); + assert!(format!("{salt:x}").starts_with("66f9664f97f2b50f62d13ea064982f936de76657")); + } } From 3bab117ec76dc1cd63aa6b8ca25eaaef909f2535 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:50:17 +0100 Subject: [PATCH 0303/1963] chore(deps): bump ethers (#6367) --- Cargo.lock | 45 ++++++++++---------- Cargo.toml | 22 +++++----- crates/anvil/core/src/eth/transaction/mod.rs | 25 +++++++++++ 3 files changed, 59 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3b87b9cbd0cd..4ea5ad1880e73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -314,6 +314,7 @@ dependencies = [ "hash-db", "hyper", "itertools 0.11.0", + "k256", "memory-db", "parking_lot", "pretty_assertions", @@ -2069,8 +2070,8 @@ dependencies = [ [[package]] name = "ethers" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2084,8 +2085,8 @@ dependencies = [ [[package]] name = "ethers-addressbook" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "ethers-core", "once_cell", @@ -2095,8 +2096,8 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2113,8 +2114,8 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "Inflector", "const-hex", @@ -2136,8 +2137,8 @@ dependencies = [ [[package]] name = "ethers-contract-derive" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "Inflector", "const-hex", @@ -2151,8 +2152,8 @@ dependencies = [ [[package]] name = "ethers-core" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "arrayvec", "bytes", @@ -2180,8 +2181,8 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "chrono", "ethers-core", @@ -2195,8 +2196,8 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "async-trait", "auto_impl", @@ -2220,8 +2221,8 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "async-trait", "auto_impl", @@ -2258,8 +2259,8 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "async-trait", "coins-bip32", @@ -2286,8 +2287,8 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.10" -source = "git+https://github.com/gakonst/ethers-rs?rev=b4c366c964106b274e2eb528ac44eebc9bb49551#b4c366c964106b274e2eb528ac44eebc9bb49551" +version = "2.0.11" +source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" dependencies = [ "cfg-if", "const-hex", diff --git a/Cargo.toml b/Cargo.toml index 697c973d4372f..6952e4ab4fd88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -196,16 +196,16 @@ tower-http = "0.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "b4c366c964106b274e2eb528ac44eebc9bb49551" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-primitives = { git = "https://github.com/alloy-rs/core/" } @@ -213,4 +213,4 @@ alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } alloy-sol-types = { git = "https://github.com/alloy-rs/core/" } revm = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } -revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } \ No newline at end of file +revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 7a381eaaa7cb6..9ce28ff74f780 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1341,6 +1341,31 @@ mod tests { ); } + #[test] + fn can_recover_sender_not_normalized() { + let bytes = hex::decode("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap(); + + let tx: TypedTransaction = rlp::decode(&bytes).expect("decoding TypedTransaction failed"); + let tx = match tx { + TypedTransaction::Legacy(tx) => tx, + _ => panic!("Invalid typed transaction"), + }; + assert_eq!(tx.input, Bytes::from(b"")); + assert_eq!(tx.gas_price, U256::from(0x01u64)); + assert_eq!(tx.gas_limit, U256::from(0x5208u64)); + assert_eq!(tx.nonce, U256::from(0x00u64)); + if let TransactionKind::Call(ref to) = tx.kind { + assert_eq!(*to, "095e7baea6a6c7c4c2dfeb977efac326af552d87".parse().unwrap()); + } else { + panic!(); + } + assert_eq!(tx.value, U256::from(0x0au64)); + assert_eq!( + tx.recover().unwrap(), + "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse().unwrap() + ); + } + #[test] #[cfg(feature = "fastrlp")] fn test_decode_fastrlp_create() { From 6280cd44c525df9093fda482f01a6854cb280eb7 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Mon, 20 Nov 2023 16:43:19 +0000 Subject: [PATCH 0304/1963] Adds snapshot map to anvil metadata (#6364) * Adds snapshot map to anvil metadata * code review * code review * code review --- crates/anvil/core/src/types.rs | 3 +++ crates/anvil/src/eth/api.rs | 2 ++ crates/anvil/src/eth/backend/mem/mod.rs | 6 +++++- crates/anvil/tests/it/anvil_api.rs | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index e15c648b0532a..34d6627498b8d 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -1,3 +1,5 @@ +use std::collections::BTreeMap; + use ethers_core::types::{TxHash, H256, U256, U64}; use revm::primitives::SpecId; @@ -217,6 +219,7 @@ pub struct AnvilMetadata { pub latest_block_number: u64, pub latest_block_hash: H256, pub forked_network: Option, + pub snapshots: BTreeMap, } /// Information about the forked network. diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 7be3be0599257..b4093937e86e8 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1708,6 +1708,7 @@ impl EthApi { pub async fn anvil_metadata(&self) -> Result { node_info!("anvil_metadata"); let fork_config = self.backend.get_fork(); + let snapshots = self.backend.list_snapshots(); Ok(AnvilMetadata { client_version: CLIENT_VERSION, @@ -1720,6 +1721,7 @@ impl EthApi { fork_block_number: cfg.block_number(), fork_block_hash: cfg.block_hash(), }), + snapshots, }) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0907c0ffdfe9d..edd35972f963d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -77,7 +77,7 @@ use futures::channel::mpsc::{unbounded, UnboundedSender}; use hash_db::HashDB; use parking_lot::{Mutex, RwLock}; use std::{ - collections::HashMap, + collections::{BTreeMap, HashMap}, io::{Read, Write}, ops::Deref, sync::Arc, @@ -676,6 +676,10 @@ impl Backend { Ok(self.db.write().await.revert(id)) } + pub fn list_snapshots(&self) -> BTreeMap { + self.active_snapshots.lock().clone().into_iter().collect() + } + /// Get the current state. pub async fn serialized_state(&self) -> Result { let state = self.db.read().await.dump_state()?; diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 2f54668857892..6591dd25d3d26 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -473,6 +473,7 @@ async fn can_get_metadata() { client_version: CLIENT_VERSION, instance_id: api.instance_id(), forked_network: None, + snapshots: Default::default(), }; assert_eq!(metadata, expected_metadata); @@ -501,6 +502,7 @@ async fn can_get_metadata_on_fork() { fork_block_number: block_number, fork_block_hash: block.hash.unwrap(), }), + snapshots: Default::default(), }; assert_eq!(metadata, expected_metadata); From 3f93d28dd4e5faaa5395eff28db8782200a466a5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 20 Nov 2023 17:56:14 +0100 Subject: [PATCH 0305/1963] chore: update fixtures after forge-std release (#6371) --- crates/forge/tests/fixtures/can_create_template_contract.stdout | 2 +- crates/forge/tests/fixtures/can_create_using_unlocked.stdout | 2 +- .../tests/fixtures/can_create_with_constructor_args.stdout | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/forge/tests/fixtures/can_create_template_contract.stdout b/crates/forge/tests/fixtures/can_create_template_contract.stdout index fd625cee305fe..622c81ac4a888 100644 --- a/crates/forge/tests/fixtures/can_create_template_contract.stdout +++ b/crates/forge/tests/fixtures/can_create_template_contract.stdout @@ -1,4 +1,4 @@ -Compiling 22 files with 0.8.23 +Compiling 24 files with 0.8.23 Solc 0.8.23 finished in 2.27s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout index 2e35831523fbf..a4132c617c0a1 100644 --- a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout +++ b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout @@ -1,4 +1,4 @@ -Compiling 22 files with 0.8.23 +Compiling 24 files with 0.8.23 Solc 0.8.23 finished in 1.95s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout index 525e68ac13f8d..8cb09c22ced0b 100644 --- a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout +++ b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout @@ -1,4 +1,4 @@ -Compiling 23 files with 0.8.23 +Compiling 25 files with 0.8.23 Solc 0.8.23 finished in 2.82s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 From f37ed7f2bf48af471a2e4795a8be7efed205e3c8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 20 Nov 2023 22:39:54 +0100 Subject: [PATCH 0306/1963] fix: don't leak env parser error (#6375) * fix: don't leak env parser error * Update crates/cheatcodes/src/env.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * update test --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/src/env.rs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index a0a458851ddba..b4a4a9a0c1f96 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -236,7 +236,7 @@ impl Cheatcode for envOr_13Call { } fn env(key: &str, ty: &DynSolType) -> Result { - get_env(key).and_then(|val| string::parse(&val, ty).map_err(map_env_err(key))) + get_env(key).and_then(|val| string::parse(&val, ty).map_err(map_env_err(key, &val))) } fn env_default(key: &str, default: &T, ty: &DynSolType) -> Result { @@ -245,7 +245,7 @@ fn env_default(key: &str, default: &T, ty: &DynSolType) -> Result { fn env_array(key: &str, delim: &str, ty: &DynSolType) -> Result { get_env(key).and_then(|val| { - string::parse_array(val.split(delim).map(str::trim), ty).map_err(map_env_err(key)) + string::parse_array(val.split(delim).map(str::trim), ty).map_err(map_env_err(key, &val)) }) } @@ -263,9 +263,12 @@ fn get_env(key: &str) -> Result { } } -fn map_env_err(key: &str) -> impl FnOnce(Error) -> Error + '_ { +/// Converts the error message of a failed parsing attempt to a more user-friendly message that +/// doesn't leak the value. +fn map_env_err<'a>(key: &'a str, value: &'a str) -> impl FnOnce(Error) -> Error + 'a { move |e| { - let e = e.to_string(); + let e = e.to_string(); // failed parsing \"xy(123)\" as type `uint256`: parser error:\nxy(123)\n ^\nexpected at + // least one digit let mut e = e.as_str(); // cut off the message to not leak the value let sep = if let Some(idx) = e.rfind(" as type `") { @@ -274,6 +277,26 @@ fn map_env_err(key: &str) -> impl FnOnce(Error) -> Error + '_ { } else { ": " }; + // ensure we're also removing the value from the underlying alloy parser error message, See + // [alloy_dyn_abi::parser::Error::parser] + let e = e.replacen(&format!("\n{value}\n"), &format!("\n${key}\n"), 1); fmt_err!("failed parsing ${key}{sep}{e}") } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_env_uint() { + let key = "parse_env_uint"; + let value = "xy(123)"; + env::set_var(key, value); + + let err = env(key, &DynSolType::Uint(256)).unwrap_err().to_string(); + assert!(!err.contains(value)); + assert_eq!(err, "failed parsing $parse_env_uint as type `uint256`: parser error:\n$parse_env_uint\n ^\nexpected at least one digit"); + env::remove_var(key); + } +} From 7b452656f722fc560f0414db3ce24a1f2972a8b7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 20 Nov 2023 23:37:24 +0100 Subject: [PATCH 0307/1963] fix(foundryup): don't fail on 'which' check (#6377) --- foundryup/foundryup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 554051507a6a7..8143c3e23ac91 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -155,8 +155,8 @@ main() { say "installed - $(ensure "$bin_path" --version)" # Check if the default path of the binary is not in FOUNDRY_BIN_DIR - which_path="$(which "$bin")" - if [ "$which_path" != "$bin_path" ]; then + which_path="$(command -v "$bin" || true)" + if [ -n "$which_path" ] && [ "$which_path" != "$bin_path" ]; then warn "" cat 1>&2 < Date: Tue, 21 Nov 2023 01:27:31 +0100 Subject: [PATCH 0308/1963] fix(evm): don't panic on short calldata (#6380) --- crates/evm/evm/src/executors/fuzz/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index c92f0e21cfb4a..3759962932a63 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -166,8 +166,11 @@ impl<'a> FuzzedExecutor<'a> { let reason = reason.to_string(); result.reason = if reason.is_empty() { None } else { Some(reason) }; - let args = - func.abi_decode_input(&calldata.as_ref()[4..], false).unwrap_or_default(); + let args = if let Some(data) = calldata.get(4..) { + func.abi_decode_input(data, false).unwrap_or_default() + } else { + vec![] + }; result.counterexample = Some(CounterExample::Single(BaseCounterExample { sender: None, addr: None, From c0a9975f152556b696ad74cc8da618439d6f9e67 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 21 Nov 2023 02:47:35 +0100 Subject: [PATCH 0309/1963] refactor: remove cheatcodes Abigen (#6379) * refactor: remove cheatcodes Abigen * features * bump * bump * patch --- Cargo.lock | 22 +- Cargo.toml | 5 +- crates/abi/abi/HEVM.sol | 248 - crates/abi/build.rs | 1 - crates/abi/src/bindings/hevm.rs | 15549 ------------------------- crates/abi/src/bindings/mod.rs | 1 - crates/abi/src/lib.rs | 2 +- crates/cheatcodes/spec/Cargo.toml | 2 +- crates/cheatcodes/spec/src/vm.rs | 2 + crates/evm/core/Cargo.toml | 2 +- crates/evm/core/src/abi/mod.rs | 1 - crates/evm/fuzz/Cargo.toml | 2 +- crates/evm/traces/Cargo.toml | 1 + crates/evm/traces/src/decoder/mod.rs | 11 +- 14 files changed, 29 insertions(+), 15820 deletions(-) delete mode 100644 crates/abi/abi/HEVM.sol delete mode 100644 crates/abi/src/bindings/hevm.rs diff --git a/Cargo.lock b/Cargo.lock index 4ea5ad1880e73..cbe6bb71c88dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" +source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" +source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" +source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" dependencies = [ "alloy-rlp", "arbitrary", @@ -168,8 +168,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" +source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" dependencies = [ + "alloy-json-abi", "const-hex", "dunce", "heck", @@ -177,6 +178,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", + "serde_json", "syn 2.0.39", "syn-solidity", "tiny-keccak", @@ -185,7 +187,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" +source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" dependencies = [ "winnow", ] @@ -193,8 +195,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" +source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" dependencies = [ + "alloy-json-abi", "alloy-primitives", "alloy-sol-macro", "const-hex", @@ -2977,6 +2980,7 @@ dependencies = [ "ethers-core", "eyre", "foundry-block-explorers", + "foundry-cheatcodes-spec", "foundry-common", "foundry-compilers", "foundry-config", @@ -5884,9 +5888,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "724fd11728a3804e9944b14cab63825024c40bf42f8af87c8b5d97c4bbacf426" +checksum = "608a5726529f2f0ef81b8fde9873c4bb829d6b5b5ca6be4d97345ddf0749c825" dependencies = [ "alloy-rlp", "arbitrary", @@ -6833,7 +6837,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#a707bcd7cd3979532296d9a8fc441b836f9c7168" +source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 6952e4ab4fd88..90f9fd7e81648 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -208,9 +208,12 @@ ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } -alloy-primitives = { git = "https://github.com/alloy-rs/core/" } alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } +alloy-primitives = { git = "https://github.com/alloy-rs/core/" } +alloy-sol-macro = { git = "https://github.com/alloy-rs/core/" } alloy-sol-types = { git = "https://github.com/alloy-rs/core/" } +alloy-sol-type-parser = { git = "https://github.com/alloy-rs/core/" } +syn-solidity = { git = "https://github.com/alloy-rs/core/" } revm = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } diff --git a/crates/abi/abi/HEVM.sol b/crates/abi/abi/HEVM.sol deleted file mode 100644 index 76c08ddac0695..0000000000000 --- a/crates/abi/abi/HEVM.sol +++ /dev/null @@ -1,248 +0,0 @@ -struct Log { bytes32[] topics; bytes data; } -struct Rpc { string name; string url; } -struct EthGetLogs { address emitter; bytes32[] topics; bytes data; uint256 blockNumber; bytes32 transactionHash; uint256 transactionIndex; bytes32 blockHash; 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; uint256 kind; address account; address accessor; bool initialized; uint256 oldBalance; uint256 newBalance; bytes deployedCode; uint256 value; bytes data; bool reverted; StorageAccess[] storageAccesses; } -struct StorageAccess { address account; bytes32 slot; bool isWrite; bytes32 previousValue; bytes32 newValue; bool reverted; } - -allowCheatcodes(address) - -tryFfi(string[])(FfiResult) -ffi(string[])(bytes) - -breakpoint(string) -breakpoint(string,bool) - -roll(uint256) -warp(uint256) -difficulty(uint256) -prevrandao(bytes32) -fee(uint256) -coinbase(address) -store(address,bytes32,bytes32) -load(address,bytes32)(bytes32) -cool(address) - -setEnv(string,string) -envBool(string)(bool) -envUint(string)(uint256) -envInt(string)(int256) -envAddress(string)(address) -envBytes32(string)(bytes32) -envString(string)(string) -envBytes(string)(bytes) -envBool(string,string)(bool[]) -envUint(string,string)(uint256[]) -envInt(string,string)(int256[]) -envAddress(string,string)(address[]) -envBytes32(string,string)(bytes32[]) -envString(string,string)(string[]) -envBytes(string,string)(bytes[]) -envOr(string,bool)(bool) -envOr(string,uint256)(uint256) -envOr(string,int256)(int256) -envOr(string,address)(address) -envOr(string,bytes32)(bytes32) -envOr(string,string)(string) -envOr(string,bytes)(bytes) -envOr(string,string,bool[])(bool[]) -envOr(string,string,uint256[])(uint256[]) -envOr(string,string,int256[])(int256[]) -envOr(string,string,address[])(address[]) -envOr(string,string,bytes32[])(bytes32[]) -envOr(string,string,string[])(string[]) -envOr(string,string,bytes[])(bytes[]) - -addr(uint256)(address) -sign(uint256,bytes32)(uint8,bytes32,bytes32) -deriveKey(string,uint32)(uint256) -deriveKey(string,string,uint32)(uint256) -deriveKey(string,uint32,string)(uint256) -deriveKey(string,string,uint32,string)(uint256) -rememberKey(uint256)(address) - -createWallet(string)(Wallet) -createWallet(uint256)(Wallet) -createWallet(uint256,string)(Wallet) -sign(Wallet,bytes32)(uint8,bytes32,bytes32) -getNonce(Wallet)(uint64) - -prank(address) -prank(address,address) -readCallers()(uint256,address,address) -startPrank(address) -startPrank(address,address) -stopPrank() - -deal(address,uint256) -etch(address,bytes) -expectRevert() -expectRevert(bytes) -expectRevert(bytes4) -record() -accesses(address)(bytes32[], bytes32[]) -skip(bool) - -startStateDiffRecording() -stopAndReturnStateDiff()(AccountAccess[]) - -recordLogs() -getRecordedLogs()(Log[]) - -expectEmit() -expectEmit(address) -expectEmit(bool,bool,bool,bool) -expectEmit(bool,bool,bool,bool,address) - -mockCall(address,bytes,bytes) -mockCall(address,uint256,bytes,bytes) -mockCallRevert(address,bytes,bytes) -mockCallRevert(address,uint256,bytes,bytes) -clearMockedCalls() - -expectCall(address,bytes) -expectCall(address,bytes,uint64) -expectCall(address,uint256,bytes) -expectCall(address,uint256,bytes,uint64) -expectCall(address,uint256,uint64,bytes) -expectCall(address,uint256,uint64,bytes,uint64) -expectCallMinGas(address,uint256,uint64,bytes) -expectCallMinGas(address,uint256,uint64,bytes,uint64) -expectSafeMemory(uint64,uint64) -expectSafeMemoryCall(uint64,uint64) - -getCode(string) -getDeployedCode(string) -label(address,string) -getLabel(address)(string) -assume(bool) -setNonce(address,uint64) -getNonce(address) -resetNonce(address) -setNonceUnsafe(address,uint64) -chainId(uint256) -txGasPrice(uint256) - -broadcast() -broadcast(address) -broadcast(uint256) -startBroadcast() -startBroadcast(address) -startBroadcast(uint256) -stopBroadcast() - -projectRoot()(string) -openFile(string) -readFile(string)(string) -readFileBinary(string)(bytes) -readLine(string)(string) -writeFile(string,string) -writeFileBinary(string,bytes) -writeLine(string,string) -copyFile(string,string) -closeFile(string) -removeFile(string) -createDir(string, bool) -removeDir(string, bool) -readDir(string)(DirEntry[]) -readDir(string, uint64)(DirEntry[]) -readDir(string, uint64, bool)(DirEntry[]) -readLink(string)(string) -fsMetadata(string)(FsMetadata) -exists(string)(bool) -isFile(string)(bool) -isDir(string)(bool) - -toString(bytes) -toString(address) -toString(uint256) -toString(int256) -toString(bytes32) -toString(bool) -parseBytes(string)(bytes) -parseAddress(string)(address) -parseUint(string)(uint256) -parseInt(string)(int256) -parseBytes32(string)(bytes32) -parseBool(string)(bool) - -snapshot()(uint256) -revertTo(uint256)(bool) -createFork(string,uint256)(uint256) -createFork(string,bytes32)(uint256) -createFork(string)(uint256) -createSelectFork(string,uint256)(uint256) -createSelectFork(string,bytes32)(uint256) -createSelectFork(string)(uint256) -selectFork(uint256) -activeFork()(uint256) -transact(bytes32) -transact(uint256,bytes32) -makePersistent(address) -makePersistent(address,address) -makePersistent(address,address,address) -makePersistent(address[]) -revokePersistent(address) -revokePersistent(address[]) -isPersistent(address)(bool) -rollFork(uint256) -rollFork(bytes32) -rollFork(uint256,uint256) -rollFork(uint256,bytes32) -rpcUrl(string)(string) -rpcUrls()(string[2][]) -rpcUrlStructs()(Rpc[]) -eth_getLogs(uint256,uint256,address,bytes32[])(EthGetLogs[]) -rpc(string,string)(bytes) - - -writeJson(string, string) -writeJson(string, string, string) -parseJson(string)(bytes) -parseJson(string, string)(bytes) -parseJsonKeys(string, string)(string[]) -parseJsonUint(string, string)(uint256) -parseJsonUintArray(string, string)(uint256[]) -parseJsonInt(string, string)(int256) -parseJsonIntArray(string, string)(int256[]) -parseJsonString(string, string)(string) -parseJsonStringArray(string, string)(string[]) -parseJsonAddress(string, string)(address) -parseJsonAddressArray(string, string)(address[]) -parseJsonBool(string, string)(bool) -parseJsonBoolArray(string, string)(bool[]) -parseJsonBytes(string, string)(bytes) -parseJsonBytesArray(string, string)(bytes[]) -parseJsonBytes32(string, string)(bytes32) -parseJsonBytes32Array(string, string)(bytes32[]) -serializeJson(string,string)(string) -serializeBool(string,string,bool)(string) -serializeBool(string,string,bool[])(string) -serializeUint(string,string,uint256)(string) -serializeUint(string,string,uint256[])(string) -serializeInt(string,string,int256)(string) -serializeInt(string,string,int256[])(string) -serializeAddress(string,string,address)(string) -serializeAddress(string,string,address[])(string) -serializeBytes32(string,string,bytes32)(string) -serializeBytes32(string,string,bytes32[])(string) -serializeString(string,string,string)(string) -serializeString(string,string,string[])(string) -serializeBytes(string,string,bytes)(string) -serializeBytes(string,string,bytes[])(string) -keyExists(string,string)(bool) - -pauseGasMetering() -resumeGasMetering() -startMappingRecording() -stopMappingRecording() -getMappingLength(address,bytes32) -getMappingSlotAt(address,bytes32,uint256) -getMappingKeyAndParentOf(address,bytes32) - -sleep(uint256) -unixTime()(uint256) diff --git a/crates/abi/build.rs b/crates/abi/build.rs index 4243e648c42b4..7cb09d83ceae7 100644 --- a/crates/abi/build.rs +++ b/crates/abi/build.rs @@ -24,7 +24,6 @@ fn main() -> eyre::Result<()> { let mut multi = MultiAbigen::new([ ("HardhatConsole", include_json_abi!("abi/HardhatConsole.json")), ("Console", include_hr_abi!("abi/Console.sol")), - ("HEVM", include_hr_abi!("abi/HEVM.sol")), ])?; // Add the ConsoleFmt derive to the HardhatConsole contract diff --git a/crates/abi/src/bindings/hevm.rs b/crates/abi/src/bindings/hevm.rs deleted file mode 100644 index 8591d4911b804..0000000000000 --- a/crates/abi/src/bindings/hevm.rs +++ /dev/null @@ -1,15549 +0,0 @@ -pub use hevm::*; -/// This module was auto-generated with ethers-rs Abigen. -/// More information at: -#[allow( - clippy::enum_variant_names, - clippy::too_many_arguments, - clippy::upper_case_acronyms, - clippy::type_complexity, - dead_code, - non_camel_case_types, -)] -pub mod hevm { - #[allow(deprecated)] - fn __abi() -> ::ethers_core::abi::Abi { - ::ethers_core::abi::ethabi::Contract { - constructor: ::core::option::Option::None, - functions: ::core::convert::From::from([ - ( - ::std::borrow::ToOwned::to_owned("accesses"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("accesses"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("activeFork"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("activeFork"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("addr"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("addr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("allowCheatcodes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("allowCheatcodes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("assume"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("assume"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("breakpoint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("breakpoint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("breakpoint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("broadcast"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("broadcast"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("broadcast"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("broadcast"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("chainId"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("chainId"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("clearMockedCalls"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("clearMockedCalls"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("closeFile"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("closeFile"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("coinbase"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("coinbase"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("cool"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("cool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("copyFile"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("copyFile"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("createDir"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createDir"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("createFork"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("createSelectFork"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createSelectFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createSelectFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createSelectFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("createWallet"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createWallet"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ], - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createWallet"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ], - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("createWallet"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ], - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("deal"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("deal"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("deriveKey"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("deriveKey"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(32usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("deriveKey"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(32usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("deriveKey"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(32usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("deriveKey"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(32usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("difficulty"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("difficulty"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envAddress"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envAddress"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envAddress"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envBool"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envBool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envBool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bool, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envBytes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envBytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envBytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bytes, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envBytes32"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envBytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envBytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envInt"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envInt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envInt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Int(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envOr"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bool, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bool, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Int(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Int(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envOr"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bytes, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bytes, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envString"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("envUint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envUint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("envUint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("etch"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("etch"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("eth_getLogs"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("eth_getLogs"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - ::ethers_core::abi::ethabi::ParamType::Bytes, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Bool, - ], - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("exists"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("exists"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("expectCall"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("expectCallMinGas"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCallMinGas"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectCallMinGas"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("expectEmit"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectEmit"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectEmit"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectEmit"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectEmit"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("expectRevert"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectRevert"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectRevert"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectRevert"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 4usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("expectSafeMemory"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("expectSafeMemory"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("expectSafeMemoryCall"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "expectSafeMemoryCall", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("fee"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("fee"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("ffi"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("ffi"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("fsMetadata"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("fsMetadata"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ], - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getCode"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getCode"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getDeployedCode"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getDeployedCode"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getLabel"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getLabel"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getMappingKeyAndParentOf"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "getMappingKeyAndParentOf", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getMappingLength"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getMappingLength"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getMappingSlotAt"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getMappingSlotAt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getNonce"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getNonce"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ], - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getNonce"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("getRecordedLogs"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("getRecordedLogs"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - ::ethers_core::abi::ethabi::ParamType::Bytes, - ], - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("isDir"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("isDir"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("isFile"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("isFile"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("isPersistent"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("isPersistent"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("keyExists"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("keyExists"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("label"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("label"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("load"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("load"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("makePersistent"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("makePersistent"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("makePersistent"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("makePersistent"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("makePersistent"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("mockCall"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("mockCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("mockCall"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("mockCallRevert"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("mockCallRevert"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("mockCallRevert"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("openFile"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("openFile"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseAddress"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseAddress"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseBool"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseBool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseBytes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseBytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseBytes32"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseBytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseInt"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseInt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJson"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJson"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJson"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonAddress"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonAddress"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonAddressArray"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "parseJsonAddressArray", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonBool"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonBool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonBoolArray"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonBoolArray"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bool, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonBytes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonBytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonBytes32"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonBytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonBytes32Array"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "parseJsonBytes32Array", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonBytesArray"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "parseJsonBytesArray", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bytes, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonInt"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonInt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonIntArray"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonIntArray"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Int(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonKeys"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonKeys"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonString"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonStringArray"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "parseJsonStringArray", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonUint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonUint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseJsonUintArray"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseJsonUintArray"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("parseUint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("parseUint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("pauseGasMetering"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("pauseGasMetering"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("prank"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("prank"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("prank"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("prevrandao"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("prevrandao"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("projectRoot"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("projectRoot"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("readCallers"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readCallers"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("readDir"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readDir"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::String, - ::ethers_core::abi::ethabi::ParamType::String, - ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Bool, - ], - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readDir"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::String, - ::ethers_core::abi::ethabi::ParamType::String, - ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Bool, - ], - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readDir"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::String, - ::ethers_core::abi::ethabi::ParamType::String, - ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Bool, - ], - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("readFile"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readFile"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("readFileBinary"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readFileBinary"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("readLine"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readLine"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("readLink"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("readLink"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("record"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("record"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("recordLogs"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("recordLogs"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("rememberKey"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rememberKey"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("removeDir"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("removeDir"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("removeFile"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("removeFile"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("resetNonce"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("resetNonce"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("resumeGasMetering"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("resumeGasMetering"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("revertTo"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("revertTo"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("revokePersistent"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("revokePersistent"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("revokePersistent"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("roll"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("roll"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("rollFork"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rollFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rollFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rollFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rollFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("rpc"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rpc"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("rpcUrl"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rpcUrl"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("rpcUrlStructs"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rpcUrlStructs"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::String, - ::ethers_core::abi::ethabi::ParamType::String, - ], - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("rpcUrls"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("rpcUrls"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedArray( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - 2usize, - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("selectFork"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("selectFork"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeAddress"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeAddress"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeAddress"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeBool"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeBool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeBool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bool, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeBytes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeBytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeBytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Bytes, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeBytes32"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeBytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeBytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeInt"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeInt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeInt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Int(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeJson"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeJson"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeString"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("serializeUint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeUint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("serializeUint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("setEnv"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("setEnv"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("setNonce"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("setNonce"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("setNonceUnsafe"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("setNonceUnsafe"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(64usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("sign"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("sign"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(8usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("sign"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ], - ), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(8usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("skip"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("skip"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("sleep"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("sleep"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("snapshot"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("snapshot"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("startBroadcast"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("startBroadcast"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("startBroadcast"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("startBroadcast"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("startMappingRecording"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "startMappingRecording", - ), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("startPrank"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("startPrank"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("startPrank"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("startStateDiffRecording"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "startStateDiffRecording", - ), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("stopAndReturnStateDiff"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "stopAndReturnStateDiff", - ), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ], - ), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Bytes, - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ::ethers_core::abi::ethabi::ParamType::Bytes, - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Address, - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ::ethers_core::abi::ethabi::ParamType::Bool, - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ::ethers_core::abi::ethabi::ParamType::FixedBytes(32usize), - ::ethers_core::abi::ethabi::ParamType::Bool, - ], - ), - ), - ), - ], - ), - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("stopBroadcast"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("stopBroadcast"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("stopMappingRecording"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned( - "stopMappingRecording", - ), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("stopPrank"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("stopPrank"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("store"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("store"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("toString"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("toString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("toString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("toString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("toString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("toString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("toString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("transact"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("transact"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("transact"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("tryFfi"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("tryFfi"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::String, - ), - ), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Tuple( - ::std::vec![ - ::ethers_core::abi::ethabi::ParamType::Int(32usize), - ::ethers_core::abi::ethabi::ParamType::Bytes, - ::ethers_core::abi::ethabi::ParamType::Bytes, - ], - ), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("txGasPrice"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("txGasPrice"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("unixTime"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("unixTime"), - inputs: ::std::vec![], - outputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("warp"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("warp"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("writeFile"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("writeFile"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("writeFileBinary"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("writeFileBinary"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("writeJson"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("writeJson"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("writeJson"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("writeLine"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("writeLine"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::None, - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::NonPayable, - }, - ], - ), - ]), - events: ::std::collections::BTreeMap::new(), - errors: ::std::collections::BTreeMap::new(), - receive: false, - fallback: false, - } - } - ///The parsed human-readable ABI of the contract. - pub static HEVM_ABI: ::ethers_contract::Lazy<::ethers_core::abi::Abi> = ::ethers_contract::Lazy::new( - __abi, - ); - pub struct HEVM(::ethers_contract::Contract); - impl ::core::clone::Clone for HEVM { - fn clone(&self) -> Self { - Self(::core::clone::Clone::clone(&self.0)) - } - } - impl ::core::ops::Deref for HEVM { - type Target = ::ethers_contract::Contract; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - impl ::core::ops::DerefMut for HEVM { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } - } - impl ::core::fmt::Debug for HEVM { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(::core::stringify!(HEVM)).field(&self.address()).finish() - } - } - impl HEVM { - /// Creates a new contract instance with the specified `ethers` client at - /// `address`. The contract derefs to a `ethers::Contract` object. - pub fn new>( - address: T, - client: ::std::sync::Arc, - ) -> Self { - Self( - ::ethers_contract::Contract::new( - address.into(), - HEVM_ABI.clone(), - client, - ), - ) - } - ///Calls the contract's `accesses` (0x65bc9481) function - pub fn accesses( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall< - M, - (::std::vec::Vec<[u8; 32]>, ::std::vec::Vec<[u8; 32]>), - > { - self.0 - .method_hash([101, 188, 148, 129], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `activeFork` (0x2f103f22) function - pub fn active_fork( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([47, 16, 63, 34], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `addr` (0xffa18649) function - pub fn addr( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::ethers_core::types::Address, - > { - self.0 - .method_hash([255, 161, 134, 73], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `allowCheatcodes` (0xea060291) function - pub fn allow_cheatcodes( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([234, 6, 2, 145], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `assume` (0x4c63e562) function - pub fn assume( - &self, - p0: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([76, 99, 229, 98], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `breakpoint` (0xf0259e92) function - pub fn breakpoint_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([240, 37, 158, 146], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `breakpoint` (0xf7d39a8d) function - pub fn breakpoint_1( - &self, - p0: ::std::string::String, - p1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([247, 211, 154, 141], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `broadcast` (0xafc98040) function - pub fn broadcast_0(&self) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([175, 201, 128, 64], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `broadcast` (0xe6962cdb) function - pub fn broadcast_1( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([230, 150, 44, 219], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `broadcast` (0xf67a965b) function - pub fn broadcast_2( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([246, 122, 150, 91], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `chainId` (0x4049ddd2) function - pub fn chain_id( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([64, 73, 221, 210], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `clearMockedCalls` (0x3fdf4e15) function - pub fn clear_mocked_calls( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([63, 223, 78, 21], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `closeFile` (0x48c3241f) function - pub fn close_file( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([72, 195, 36, 31], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `coinbase` (0xff483c54) function - pub fn coinbase( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([255, 72, 60, 84], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `cool` (0x40ff9f21) function - pub fn cool( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([64, 255, 159, 33], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `copyFile` (0xa54a87d8) function - pub fn copy_file( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([165, 74, 135, 216], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createDir` (0x168b64d3) function - pub fn create_dir( - &self, - p0: ::std::string::String, - p1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([22, 139, 100, 211], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createFork` (0x6ba3ba2b) function - pub fn create_fork_1( - &self, - p0: ::std::string::String, - p1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([107, 163, 186, 43], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createFork` (0x7ca29682) function - pub fn create_fork_2( - &self, - p0: ::std::string::String, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([124, 162, 150, 130], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createFork` (0x31ba3498) function - pub fn create_fork_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([49, 186, 52, 152], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createSelectFork` (0x71ee464d) function - pub fn create_select_fork_1( - &self, - p0: ::std::string::String, - p1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([113, 238, 70, 77], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createSelectFork` (0x84d52b7a) function - pub fn create_select_fork_2( - &self, - p0: ::std::string::String, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([132, 213, 43, 122], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createSelectFork` (0x98680034) function - pub fn create_select_fork_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([152, 104, 0, 52], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createWallet` (0x7404f1d2) function - pub fn create_wallet_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ( - ::ethers_core::types::Address, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - > { - self.0 - .method_hash([116, 4, 241, 210], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createWallet` (0x7a675bb6) function - pub fn create_wallet_1( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall< - M, - ( - ::ethers_core::types::Address, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - > { - self.0 - .method_hash([122, 103, 91, 182], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `createWallet` (0xed7c5462) function - pub fn create_wallet_2( - &self, - p0: ::ethers_core::types::U256, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ( - ::ethers_core::types::Address, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - > { - self.0 - .method_hash([237, 124, 84, 98], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `deal` (0xc88a5e6d) function - pub fn deal( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([200, 138, 94, 109], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `deriveKey` (0x6229498b) function - pub fn derive_key_0( - &self, - p0: ::std::string::String, - p1: u32, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([98, 41, 73, 139], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `deriveKey` (0x6bcb2c1b) function - pub fn derive_key_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: u32, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([107, 203, 44, 27], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `deriveKey` (0x32c8176d) function - pub fn derive_key_2( - &self, - p0: ::std::string::String, - p1: u32, - p2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([50, 200, 23, 109], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `deriveKey` (0x29233b1f) function - pub fn derive_key_3( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: u32, - p3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([41, 35, 59, 31], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `difficulty` (0x46cc92d9) function - pub fn difficulty( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([70, 204, 146, 217], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envAddress` (0x350d56bf) function - pub fn env_address_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::ethers_core::types::Address, - > { - self.0 - .method_hash([53, 13, 86, 191], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envAddress` (0xad31b9fa) function - pub fn env_address_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::Address>, - > { - self.0 - .method_hash([173, 49, 185, 250], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envBool` (0x7ed1ec7d) function - pub fn env_bool_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([126, 209, 236, 125], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envBool` (0xaaaddeaf) function - pub fn env_bool_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall> { - self.0 - .method_hash([170, 173, 222, 175], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envBytes` (0x4d7baf06) function - pub fn env_bytes_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([77, 123, 175, 6], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envBytes` (0xddc2651b) function - pub fn env_bytes_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::Bytes>, - > { - self.0 - .method_hash([221, 194, 101, 27], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envBytes32` (0x97949042) function - pub fn env_bytes_320( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([151, 148, 144, 66], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envBytes32` (0x5af231c1) function - pub fn env_bytes_321( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall> { - self.0 - .method_hash([90, 242, 49, 193], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envInt` (0x892a0c61) function - pub fn env_int_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([137, 42, 12, 97], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envInt` (0x42181150) function - pub fn env_int_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::I256>, - > { - self.0 - .method_hash([66, 24, 17, 80], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x4777f3cf) function - pub fn env_or_0( - &self, - p0: ::std::string::String, - p1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([71, 119, 243, 207], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x5e97348f) function - pub fn env_or_1( - &self, - p0: ::std::string::String, - p1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([94, 151, 52, 143], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0xbbcb713e) function - pub fn env_or_2( - &self, - p0: ::std::string::String, - p1: ::ethers_core::types::I256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([187, 203, 113, 62], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x561fe540) function - pub fn env_or_3( - &self, - p0: ::std::string::String, - p1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::ethers_core::types::Address, - > { - self.0 - .method_hash([86, 31, 229, 64], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0xb4a85892) function - pub fn env_or_4( - &self, - p0: ::std::string::String, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([180, 168, 88, 146], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0xd145736c) function - pub fn env_or_5( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([209, 69, 115, 108], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0xb3e47705) function - pub fn env_or_6( - &self, - p0: ::std::string::String, - p1: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([179, 228, 119, 5], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0xeb85e83b) function - pub fn env_or_7( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec, - ) -> ::ethers_contract::builders::ContractCall> { - self.0 - .method_hash([235, 133, 232, 59], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x74318528) function - pub fn env_or_8( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::U256>, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::U256>, - > { - self.0 - .method_hash([116, 49, 133, 40], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x4700d74b) function - pub fn env_or_9( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::I256>, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::I256>, - > { - self.0 - .method_hash([71, 0, 215, 75], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0xc74e9deb) function - pub fn env_or_10( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::Address>, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::Address>, - > { - self.0 - .method_hash([199, 78, 157, 235], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x2281f367) function - pub fn env_or_11( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<[u8; 32]>, - ) -> ::ethers_contract::builders::ContractCall> { - self.0 - .method_hash([34, 129, 243, 103], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x859216bc) function - pub fn env_or_12( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::std::string::String>, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::std::string::String>, - > { - self.0 - .method_hash([133, 146, 22, 188], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envOr` (0x64bc3e64) function - pub fn env_or_13( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::Bytes>, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::Bytes>, - > { - self.0 - .method_hash([100, 188, 62, 100], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envString` (0xf877cb19) function - pub fn env_string_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([248, 119, 203, 25], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envString` (0x14b02bc9) function - pub fn env_string_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::std::string::String>, - > { - self.0 - .method_hash([20, 176, 43, 201], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envUint` (0xc1978d1f) function - pub fn env_uint_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([193, 151, 141, 31], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `envUint` (0xf3dec099) function - pub fn env_uint_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::U256>, - > { - self.0 - .method_hash([243, 222, 192, 153], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `etch` (0xb4d6c782) function - pub fn etch( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([180, 214, 199, 130], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `eth_getLogs` (0x35e1349b) function - pub fn eth_get_logs( - &self, - p0: ::ethers_core::types::U256, - p1: ::ethers_core::types::U256, - p2: ::ethers_core::types::Address, - p3: ::std::vec::Vec<[u8; 32]>, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec< - ( - ::ethers_core::types::Address, - ::std::vec::Vec<[u8; 32]>, - ::ethers_core::types::Bytes, - ::ethers_core::types::U256, - [u8; 32], - ::ethers_core::types::U256, - [u8; 32], - ::ethers_core::types::U256, - bool, - ), - >, - > { - self.0 - .method_hash([53, 225, 52, 155], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `exists` (0x261a323e) function - pub fn exists( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([38, 26, 50, 62], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCall` (0xbd6af434) function - pub fn expect_call_0( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([189, 106, 244, 52], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCall` (0xc1adbbff) function - pub fn expect_call_1( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Bytes, - p2: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([193, 173, 187, 255], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCall` (0xf30c7ba3) function - pub fn expect_call_2( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([243, 12, 123, 163], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCall` (0xa2b1a1ae) function - pub fn expect_call_3( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: ::ethers_core::types::Bytes, - p3: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([162, 177, 161, 174], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCall` (0x23361207) function - pub fn expect_call_4( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: u64, - p3: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([35, 54, 18, 7], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCall` (0x65b7b7cc) function - pub fn expect_call_5( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: u64, - p3: ::ethers_core::types::Bytes, - p4: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([101, 183, 183, 204], (p0, p1, p2, p3, p4)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCallMinGas` (0x08e4e116) function - pub fn expect_call_min_gas_0( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: u64, - p3: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([8, 228, 225, 22], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectCallMinGas` (0xe13a1834) function - pub fn expect_call_min_gas_1( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: u64, - p3: ::ethers_core::types::Bytes, - p4: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([225, 58, 24, 52], (p0, p1, p2, p3, p4)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectEmit` (0x440ed10d) function - pub fn expect_emit_0(&self) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([68, 14, 209, 13], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectEmit` (0x86b9620d) function - pub fn expect_emit_1( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([134, 185, 98, 13], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectEmit` (0x491cc7c2) function - pub fn expect_emit_2( - &self, - p0: bool, - p1: bool, - p2: bool, - p3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([73, 28, 199, 194], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectEmit` (0x81bad6f3) function - pub fn expect_emit_3( - &self, - p0: bool, - p1: bool, - p2: bool, - p3: bool, - p4: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([129, 186, 214, 243], (p0, p1, p2, p3, p4)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectRevert` (0xf4844814) function - pub fn expect_revert_0( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([244, 132, 72, 20], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectRevert` (0xf28dceb3) function - pub fn expect_revert_1( - &self, - p0: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([242, 141, 206, 179], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectRevert` (0xc31eb0e0) function - pub fn expect_revert_2( - &self, - p0: [u8; 4], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([195, 30, 176, 224], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectSafeMemory` (0x6d016688) function - pub fn expect_safe_memory( - &self, - p0: u64, - p1: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([109, 1, 102, 136], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `expectSafeMemoryCall` (0x05838bf4) function - pub fn expect_safe_memory_call( - &self, - p0: u64, - p1: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([5, 131, 139, 244], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `fee` (0x39b37ab0) function - pub fn fee( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([57, 179, 122, 176], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `ffi` (0x89160467) function - pub fn ffi( - &self, - p0: ::std::vec::Vec<::std::string::String>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([137, 22, 4, 103], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `fsMetadata` (0xaf368a08) function - pub fn fs_metadata( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ( - bool, - bool, - ::ethers_core::types::U256, - bool, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - > { - self.0 - .method_hash([175, 54, 138, 8], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getCode` (0x8d1cc925) function - pub fn get_code( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([141, 28, 201, 37], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getDeployedCode` (0x3ebf73b4) function - pub fn get_deployed_code( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([62, 191, 115, 180], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getLabel` (0x28a249b0) function - pub fn get_label( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([40, 162, 73, 176], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getMappingKeyAndParentOf` (0x876e24e6) function - pub fn get_mapping_key_and_parent_of( - &self, - p0: ::ethers_core::types::Address, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([135, 110, 36, 230], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getMappingLength` (0x2f2fd63f) function - pub fn get_mapping_length( - &self, - p0: ::ethers_core::types::Address, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([47, 47, 214, 63], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getMappingSlotAt` (0xebc73ab4) function - pub fn get_mapping_slot_at( - &self, - p0: ::ethers_core::types::Address, - p1: [u8; 32], - p2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([235, 199, 58, 180], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getNonce` (0xa5748aad) function - pub fn get_nonce_0( - &self, - p0: Wallet, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([165, 116, 138, 173], (p0,)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getNonce` (0x2d0335ab) function - pub fn get_nonce_1( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([45, 3, 53, 171], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `getRecordedLogs` (0x191553a4) function - pub fn get_recorded_logs( - &self, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<(::std::vec::Vec<[u8; 32]>, ::ethers_core::types::Bytes)>, - > { - self.0 - .method_hash([25, 21, 83, 164], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `isDir` (0x7d15d019) function - pub fn is_dir( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([125, 21, 208, 25], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `isFile` (0xe0eb04d4) function - pub fn is_file( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([224, 235, 4, 212], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `isPersistent` (0xd92d8efd) function - pub fn is_persistent( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([217, 45, 142, 253], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `keyExists` (0x528a683c) function - pub fn key_exists( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([82, 138, 104, 60], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `label` (0xc657c718) function - pub fn label( - &self, - p0: ::ethers_core::types::Address, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([198, 87, 199, 24], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `load` (0x667f9d70) function - pub fn load( - &self, - p0: ::ethers_core::types::Address, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([102, 127, 157, 112], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `makePersistent` (0x57e22dde) function - pub fn make_persistent_0( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([87, 226, 45, 222], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `makePersistent` (0x4074e0a8) function - pub fn make_persistent_2( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([64, 116, 224, 168], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `makePersistent` (0xefb77a75) function - pub fn make_persistent_3( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Address, - p2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([239, 183, 122, 117], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `makePersistent` (0x1d9e269e) function - pub fn make_persistent_1( - &self, - p0: ::std::vec::Vec<::ethers_core::types::Address>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([29, 158, 38, 158], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `mockCall` (0xb96213e4) function - pub fn mock_call_0( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Bytes, - p2: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([185, 98, 19, 228], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `mockCall` (0x81409b91) function - pub fn mock_call_1( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: ::ethers_core::types::Bytes, - p3: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([129, 64, 155, 145], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `mockCallRevert` (0xdbaad147) function - pub fn mock_call_revert_0( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Bytes, - p2: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([219, 170, 209, 71], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `mockCallRevert` (0xd23cd037) function - pub fn mock_call_revert_1( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::U256, - p2: ::ethers_core::types::Bytes, - p3: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([210, 60, 208, 55], (p0, p1, p2, p3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `openFile` (0x7e0394bc) function - pub fn open_file( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([126, 3, 148, 188], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseAddress` (0xc6ce059d) function - pub fn parse_address( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::ethers_core::types::Address, - > { - self.0 - .method_hash([198, 206, 5, 157], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseBool` (0x974ef924) function - pub fn parse_bool( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([151, 78, 249, 36], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseBytes` (0x8f5d232d) function - pub fn parse_bytes( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([143, 93, 35, 45], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseBytes32` (0x087e6e81) function - pub fn parse_bytes_32( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([8, 126, 110, 129], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseInt` (0x42346c5e) function - pub fn parse_int( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([66, 52, 108, 94], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJson` (0x6a82600a) function - pub fn parse_json_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([106, 130, 96, 10], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJson` (0x85940ef1) function - pub fn parse_json_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([133, 148, 14, 241], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonAddress` (0x1e19e657) function - pub fn parse_json_address( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::ethers_core::types::Address, - > { - self.0 - .method_hash([30, 25, 230, 87], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonAddressArray` (0x2fce7883) function - pub fn parse_json_address_array( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::Address>, - > { - self.0 - .method_hash([47, 206, 120, 131], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonBool` (0x9f86dc91) function - pub fn parse_json_bool( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([159, 134, 220, 145], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonBoolArray` (0x91f3b94f) function - pub fn parse_json_bool_array( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall> { - self.0 - .method_hash([145, 243, 185, 79], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonBytes` (0xfd921be8) function - pub fn parse_json_bytes( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([253, 146, 27, 232], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonBytes32` (0x1777e59d) function - pub fn parse_json_bytes_32( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([23, 119, 229, 157], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonBytes32Array` (0x91c75bc3) function - pub fn parse_json_bytes_32_array( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall> { - self.0 - .method_hash([145, 199, 91, 195], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonBytesArray` (0x6631aa99) function - pub fn parse_json_bytes_array( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::Bytes>, - > { - self.0 - .method_hash([102, 49, 170, 153], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonInt` (0x7b048ccd) function - pub fn parse_json_int( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([123, 4, 140, 205], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonIntArray` (0x9983c28a) function - pub fn parse_json_int_array( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::I256>, - > { - self.0 - .method_hash([153, 131, 194, 138], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonKeys` (0x213e4198) function - pub fn parse_json_keys( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::std::string::String>, - > { - self.0 - .method_hash([33, 62, 65, 152], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonString` (0x49c4fac8) function - pub fn parse_json_string( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([73, 196, 250, 200], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonStringArray` (0x498fdcf4) function - pub fn parse_json_string_array( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::std::string::String>, - > { - self.0 - .method_hash([73, 143, 220, 244], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonUint` (0xaddde2b6) function - pub fn parse_json_uint( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([173, 221, 226, 182], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseJsonUintArray` (0x522074ab) function - pub fn parse_json_uint_array( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<::ethers_core::types::U256>, - > { - self.0 - .method_hash([82, 32, 116, 171], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `parseUint` (0xfa91454d) function - pub fn parse_uint( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([250, 145, 69, 77], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `pauseGasMetering` (0xd1a5b36f) function - pub fn pause_gas_metering( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([209, 165, 179, 111], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `prank` (0xca669fa7) function - pub fn prank_0( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([202, 102, 159, 167], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `prank` (0x47e50cce) function - pub fn prank_1( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([71, 229, 12, 206], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `prevrandao` (0x3b925549) function - pub fn prevrandao( - &self, - p0: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([59, 146, 85, 73], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `projectRoot` (0xd930a0e6) function - pub fn project_root( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([217, 48, 160, 230], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readCallers` (0x4ad0bac9) function - pub fn read_callers( - &self, - ) -> ::ethers_contract::builders::ContractCall< - M, - ( - ::ethers_core::types::U256, - ::ethers_core::types::Address, - ::ethers_core::types::Address, - ), - > { - self.0 - .method_hash([74, 208, 186, 201], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readDir` (0xc4bc59e0) function - pub fn read_dir_0( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec< - (::std::string::String, ::std::string::String, u64, bool, bool), - >, - > { - self.0 - .method_hash([196, 188, 89, 224], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readDir` (0x1497876c) function - pub fn read_dir_1( - &self, - p0: ::std::string::String, - p1: u64, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec< - (::std::string::String, ::std::string::String, u64, bool, bool), - >, - > { - self.0 - .method_hash([20, 151, 135, 108], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readDir` (0x8102d70d) function - pub fn read_dir_2( - &self, - p0: ::std::string::String, - p1: u64, - p2: bool, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec< - (::std::string::String, ::std::string::String, u64, bool, bool), - >, - > { - self.0 - .method_hash([129, 2, 215, 13], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readFile` (0x60f9bb11) function - pub fn read_file( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([96, 249, 187, 17], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readFileBinary` (0x16ed7bc4) function - pub fn read_file_binary( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([22, 237, 123, 196], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readLine` (0x70f55728) function - pub fn read_line( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([112, 245, 87, 40], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `readLink` (0x9f5684a2) function - pub fn read_link( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([159, 86, 132, 162], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `record` (0x266cf109) function - pub fn record(&self) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([38, 108, 241, 9], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `recordLogs` (0x41af2f52) function - pub fn record_logs(&self) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([65, 175, 47, 82], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rememberKey` (0x22100064) function - pub fn remember_key( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::ethers_core::types::Address, - > { - self.0 - .method_hash([34, 16, 0, 100], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `removeDir` (0x45c62011) function - pub fn remove_dir( - &self, - p0: ::std::string::String, - p1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([69, 198, 32, 17], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `removeFile` (0xf1afe04d) function - pub fn remove_file( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([241, 175, 224, 77], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `resetNonce` (0x1c72346d) function - pub fn reset_nonce( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([28, 114, 52, 109], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `resumeGasMetering` (0x2bcd50e0) function - pub fn resume_gas_metering( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([43, 205, 80, 224], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `revertTo` (0x44d7f0a4) function - pub fn revert_to( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([68, 215, 240, 164], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `revokePersistent` (0x997a0222) function - pub fn revoke_persistent_0( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([153, 122, 2, 34], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `revokePersistent` (0x3ce969e6) function - pub fn revoke_persistent_1( - &self, - p0: ::std::vec::Vec<::ethers_core::types::Address>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([60, 233, 105, 230], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `roll` (0x1f7b4f30) function - pub fn roll( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([31, 123, 79, 48], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rollFork` (0xd9bbf3a1) function - pub fn roll_fork_0( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([217, 187, 243, 161], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rollFork` (0x0f29772b) function - pub fn roll_fork_1( - &self, - p0: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([15, 41, 119, 43], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rollFork` (0xd74c83a4) function - pub fn roll_fork_2( - &self, - p0: ::ethers_core::types::U256, - p1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([215, 76, 131, 164], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rollFork` (0xf2830f7b) function - pub fn roll_fork_3( - &self, - p0: ::ethers_core::types::U256, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([242, 131, 15, 123], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rpc` (0x1206c8a8) function - pub fn rpc( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([18, 6, 200, 168], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rpcUrl` (0x975a6ce9) function - pub fn rpc_url( - &self, - p0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([151, 90, 108, 233], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rpcUrlStructs` (0x9d2ad72a) function - pub fn rpc_url_structs( - &self, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<(::std::string::String, ::std::string::String)>, - > { - self.0 - .method_hash([157, 42, 215, 42], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `rpcUrls` (0xa85a8418) function - pub fn rpc_urls( - &self, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec<[::std::string::String; 2]>, - > { - self.0 - .method_hash([168, 90, 132, 24], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `selectFork` (0x9ebf6827) function - pub fn select_fork( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([158, 191, 104, 39], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeAddress` (0x972c6062) function - pub fn serialize_address_0( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([151, 44, 96, 98], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeAddress` (0x1e356e1a) function - pub fn serialize_address_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::Address>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([30, 53, 110, 26], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeBool` (0xac22e971) function - pub fn serialize_bool_0( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([172, 34, 233, 113], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeBool` (0x92925aa1) function - pub fn serialize_bool_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([146, 146, 90, 161], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeBytes` (0xf21d52c7) function - pub fn serialize_bytes_0( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([242, 29, 82, 199], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeBytes` (0x9884b232) function - pub fn serialize_bytes_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::Bytes>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([152, 132, 178, 50], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeBytes32` (0x2d812b44) function - pub fn serialize_bytes_320( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([45, 129, 43, 68], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeBytes32` (0x201e43e2) function - pub fn serialize_bytes_321( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<[u8; 32]>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([32, 30, 67, 226], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeInt` (0x3f33db60) function - pub fn serialize_int_0( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::ethers_core::types::I256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([63, 51, 219, 96], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeInt` (0x7676e127) function - pub fn serialize_int_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::I256>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([118, 118, 225, 39], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeJson` (0x9b3358b0) function - pub fn serialize_json( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([155, 51, 88, 176], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeString` (0x88da6d35) function - pub fn serialize_string_0( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([136, 218, 109, 53], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeString` (0x561cd6f3) function - pub fn serialize_string_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::std::string::String>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([86, 28, 214, 243], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeUint` (0x129e9002) function - pub fn serialize_uint_0( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([18, 158, 144, 2], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `serializeUint` (0xfee9a469) function - pub fn serialize_uint_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::vec::Vec<::ethers_core::types::U256>, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([254, 233, 164, 105], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `setEnv` (0x3d5923ee) function - pub fn set_env( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([61, 89, 35, 238], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `setNonce` (0xf8e18b57) function - pub fn set_nonce( - &self, - p0: ::ethers_core::types::Address, - p1: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([248, 225, 139, 87], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `setNonceUnsafe` (0x9b67b21c) function - pub fn set_nonce_unsafe( - &self, - p0: ::ethers_core::types::Address, - p1: u64, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([155, 103, 178, 28], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `sign` (0xe341eaa4) function - pub fn sign_0( - &self, - p0: ::ethers_core::types::U256, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([227, 65, 234, 164], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `sign` (0xb25c5a25) function - pub fn sign_1( - &self, - p0: Wallet, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([178, 92, 90, 37], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `skip` (0xdd82d13e) function - pub fn skip( - &self, - p0: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([221, 130, 209, 62], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `sleep` (0xfa9d8713) function - pub fn sleep( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([250, 157, 135, 19], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `snapshot` (0x9711715a) function - pub fn snapshot( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([151, 17, 113, 90], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `startBroadcast` (0x7fb5297f) function - pub fn start_broadcast_0( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([127, 181, 41, 127], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `startBroadcast` (0x7fec2a8d) function - pub fn start_broadcast_1( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([127, 236, 42, 141], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `startBroadcast` (0xce817d47) function - pub fn start_broadcast_2( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([206, 129, 125, 71], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `startMappingRecording` (0x3e9705c0) function - pub fn start_mapping_recording( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([62, 151, 5, 192], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `startPrank` (0x06447d56) function - pub fn start_prank_0( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([6, 68, 125, 86], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `startPrank` (0x45b56078) function - pub fn start_prank_1( - &self, - p0: ::ethers_core::types::Address, - p1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([69, 181, 96, 120], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `startStateDiffRecording` (0xcf22e3c9) function - pub fn start_state_diff_recording( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([207, 34, 227, 201], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `stopAndReturnStateDiff` (0xaa5cf90e) function - pub fn stop_and_return_state_diff( - &self, - ) -> ::ethers_contract::builders::ContractCall< - M, - ::std::vec::Vec< - ( - (::ethers_core::types::U256, ::ethers_core::types::U256), - ::ethers_core::types::U256, - ::ethers_core::types::Address, - ::ethers_core::types::Address, - bool, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::Bytes, - ::ethers_core::types::U256, - ::ethers_core::types::Bytes, - bool, - ::std::vec::Vec< - ( - ::ethers_core::types::Address, - [u8; 32], - bool, - [u8; 32], - [u8; 32], - bool, - ), - >, - ), - >, - > { - self.0 - .method_hash([170, 92, 249, 14], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `stopBroadcast` (0x76eadd36) function - pub fn stop_broadcast( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([118, 234, 221, 54], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `stopMappingRecording` (0x0d4aae9b) function - pub fn stop_mapping_recording( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([13, 74, 174, 155], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `stopPrank` (0x90c5013b) function - pub fn stop_prank(&self) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([144, 197, 1, 59], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `store` (0x70ca10bb) function - pub fn store( - &self, - p0: ::ethers_core::types::Address, - p1: [u8; 32], - p2: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([112, 202, 16, 187], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `toString` (0x71aad10d) function - pub fn to_string_0( - &self, - p0: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([113, 170, 209, 13], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `toString` (0x56ca623e) function - pub fn to_string_1( - &self, - p0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([86, 202, 98, 62], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `toString` (0x6900a3ae) function - pub fn to_string_2( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([105, 0, 163, 174], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `toString` (0xa322c40e) function - pub fn to_string_3( - &self, - p0: ::ethers_core::types::I256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([163, 34, 196, 14], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `toString` (0xb11a19e8) function - pub fn to_string_4( - &self, - p0: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([177, 26, 25, 232], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `toString` (0x71dce7da) function - pub fn to_string_5( - &self, - p0: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([113, 220, 231, 218], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `transact` (0xbe646da1) function - pub fn transact_0( - &self, - p0: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([190, 100, 109, 161], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `transact` (0x4d8abc4b) function - pub fn transact_1( - &self, - p0: ::ethers_core::types::U256, - p1: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([77, 138, 188, 75], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `tryFfi` (0xf45c1ce7) function - pub fn try_ffi( - &self, - p0: ::std::vec::Vec<::std::string::String>, - ) -> ::ethers_contract::builders::ContractCall< - M, - (i32, ::ethers_core::types::Bytes, ::ethers_core::types::Bytes), - > { - self.0 - .method_hash([244, 92, 28, 231], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `txGasPrice` (0x48f50c0f) function - pub fn tx_gas_price( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([72, 245, 12, 15], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `unixTime` (0x625387dc) function - pub fn unix_time( - &self, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([98, 83, 135, 220], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `warp` (0xe5d6bf02) function - pub fn warp( - &self, - p0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([229, 214, 191, 2], p0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `writeFile` (0x897e0a97) function - pub fn write_file( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([137, 126, 10, 151], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `writeFileBinary` (0x1f21fc80) function - pub fn write_file_binary( - &self, - p0: ::std::string::String, - p1: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([31, 33, 252, 128], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `writeJson` (0xe23cd19f) function - pub fn write_json_0( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([226, 60, 209, 159], (p0, p1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `writeJson` (0x35d6ad46) function - pub fn write_json_1( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - p2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([53, 214, 173, 70], (p0, p1, p2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `writeLine` (0x619d897f) function - pub fn write_line( - &self, - p0: ::std::string::String, - p1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([97, 157, 137, 127], (p0, p1)) - .expect("method not found (this should never happen)") - } - } - impl From<::ethers_contract::Contract> - for HEVM { - fn from(contract: ::ethers_contract::Contract) -> Self { - Self::new(contract.address(), contract.client()) - } - } - ///Container type for all input parameters for the `accesses` function with signature `accesses(address)` and selector `0x65bc9481` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "accesses", abi = "accesses(address)")] - pub struct AccessesCall(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `activeFork` function with signature `activeFork()` and selector `0x2f103f22` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "activeFork", abi = "activeFork()")] - pub struct ActiveForkCall; - ///Container type for all input parameters for the `addr` function with signature `addr(uint256)` and selector `0xffa18649` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "addr", abi = "addr(uint256)")] - pub struct AddrCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `allowCheatcodes` function with signature `allowCheatcodes(address)` and selector `0xea060291` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "allowCheatcodes", abi = "allowCheatcodes(address)")] - pub struct AllowCheatcodesCall(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `assume` function with signature `assume(bool)` and selector `0x4c63e562` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "assume", abi = "assume(bool)")] - pub struct AssumeCall(pub bool); - ///Container type for all input parameters for the `breakpoint` function with signature `breakpoint(string)` and selector `0xf0259e92` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "breakpoint", abi = "breakpoint(string)")] - pub struct Breakpoint0Call(pub ::std::string::String); - ///Container type for all input parameters for the `breakpoint` function with signature `breakpoint(string,bool)` and selector `0xf7d39a8d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "breakpoint", abi = "breakpoint(string,bool)")] - pub struct Breakpoint1Call(pub ::std::string::String, pub bool); - ///Container type for all input parameters for the `broadcast` function with signature `broadcast()` and selector `0xafc98040` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "broadcast", abi = "broadcast()")] - pub struct Broadcast0Call; - ///Container type for all input parameters for the `broadcast` function with signature `broadcast(address)` and selector `0xe6962cdb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "broadcast", abi = "broadcast(address)")] - pub struct Broadcast1Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `broadcast` function with signature `broadcast(uint256)` and selector `0xf67a965b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "broadcast", abi = "broadcast(uint256)")] - pub struct Broadcast2Call(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `chainId` function with signature `chainId(uint256)` and selector `0x4049ddd2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "chainId", abi = "chainId(uint256)")] - pub struct ChainIdCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `clearMockedCalls` function with signature `clearMockedCalls()` and selector `0x3fdf4e15` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "clearMockedCalls", abi = "clearMockedCalls()")] - pub struct ClearMockedCallsCall; - ///Container type for all input parameters for the `closeFile` function with signature `closeFile(string)` and selector `0x48c3241f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "closeFile", abi = "closeFile(string)")] - pub struct CloseFileCall(pub ::std::string::String); - ///Container type for all input parameters for the `coinbase` function with signature `coinbase(address)` and selector `0xff483c54` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "coinbase", abi = "coinbase(address)")] - pub struct CoinbaseCall(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `cool` function with signature `cool(address)` and selector `0x40ff9f21` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "cool", abi = "cool(address)")] - pub struct CoolCall(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `copyFile` function with signature `copyFile(string,string)` and selector `0xa54a87d8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "copyFile", abi = "copyFile(string,string)")] - pub struct CopyFileCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `createDir` function with signature `createDir(string,bool)` and selector `0x168b64d3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createDir", abi = "createDir(string,bool)")] - pub struct CreateDirCall(pub ::std::string::String, pub bool); - ///Container type for all input parameters for the `createFork` function with signature `createFork(string,uint256)` and selector `0x6ba3ba2b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createFork", abi = "createFork(string,uint256)")] - pub struct CreateFork1Call( - pub ::std::string::String, - pub ::ethers_core::types::U256, - ); - ///Container type for all input parameters for the `createFork` function with signature `createFork(string,bytes32)` and selector `0x7ca29682` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createFork", abi = "createFork(string,bytes32)")] - pub struct CreateFork2Call(pub ::std::string::String, pub [u8; 32]); - ///Container type for all input parameters for the `createFork` function with signature `createFork(string)` and selector `0x31ba3498` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createFork", abi = "createFork(string)")] - pub struct CreateFork0Call(pub ::std::string::String); - ///Container type for all input parameters for the `createSelectFork` function with signature `createSelectFork(string,uint256)` and selector `0x71ee464d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createSelectFork", abi = "createSelectFork(string,uint256)")] - pub struct CreateSelectFork1Call( - pub ::std::string::String, - pub ::ethers_core::types::U256, - ); - ///Container type for all input parameters for the `createSelectFork` function with signature `createSelectFork(string,bytes32)` and selector `0x84d52b7a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createSelectFork", abi = "createSelectFork(string,bytes32)")] - pub struct CreateSelectFork2Call(pub ::std::string::String, pub [u8; 32]); - ///Container type for all input parameters for the `createSelectFork` function with signature `createSelectFork(string)` and selector `0x98680034` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createSelectFork", abi = "createSelectFork(string)")] - pub struct CreateSelectFork0Call(pub ::std::string::String); - ///Container type for all input parameters for the `createWallet` function with signature `createWallet(string)` and selector `0x7404f1d2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createWallet", abi = "createWallet(string)")] - pub struct CreateWallet0Call(pub ::std::string::String); - ///Container type for all input parameters for the `createWallet` function with signature `createWallet(uint256)` and selector `0x7a675bb6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createWallet", abi = "createWallet(uint256)")] - pub struct CreateWallet1Call(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `createWallet` function with signature `createWallet(uint256,string)` and selector `0xed7c5462` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "createWallet", abi = "createWallet(uint256,string)")] - pub struct CreateWallet2Call( - pub ::ethers_core::types::U256, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `deal` function with signature `deal(address,uint256)` and selector `0xc88a5e6d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "deal", abi = "deal(address,uint256)")] - pub struct DealCall( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - ); - ///Container type for all input parameters for the `deriveKey` function with signature `deriveKey(string,uint32)` and selector `0x6229498b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "deriveKey", abi = "deriveKey(string,uint32)")] - pub struct DeriveKey0Call(pub ::std::string::String, pub u32); - ///Container type for all input parameters for the `deriveKey` function with signature `deriveKey(string,string,uint32)` and selector `0x6bcb2c1b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "deriveKey", abi = "deriveKey(string,string,uint32)")] - pub struct DeriveKey1Call( - pub ::std::string::String, - pub ::std::string::String, - pub u32, - ); - ///Container type for all input parameters for the `deriveKey` function with signature `deriveKey(string,uint32,string)` and selector `0x32c8176d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "deriveKey", abi = "deriveKey(string,uint32,string)")] - pub struct DeriveKey2Call( - pub ::std::string::String, - pub u32, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `deriveKey` function with signature `deriveKey(string,string,uint32,string)` and selector `0x29233b1f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "deriveKey", abi = "deriveKey(string,string,uint32,string)")] - pub struct DeriveKey3Call( - pub ::std::string::String, - pub ::std::string::String, - pub u32, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `difficulty` function with signature `difficulty(uint256)` and selector `0x46cc92d9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "difficulty", abi = "difficulty(uint256)")] - pub struct DifficultyCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `envAddress` function with signature `envAddress(string)` and selector `0x350d56bf` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envAddress", abi = "envAddress(string)")] - pub struct EnvAddress0Call(pub ::std::string::String); - ///Container type for all input parameters for the `envAddress` function with signature `envAddress(string,string)` and selector `0xad31b9fa` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envAddress", abi = "envAddress(string,string)")] - pub struct EnvAddress1Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `envBool` function with signature `envBool(string)` and selector `0x7ed1ec7d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envBool", abi = "envBool(string)")] - pub struct EnvBool0Call(pub ::std::string::String); - ///Container type for all input parameters for the `envBool` function with signature `envBool(string,string)` and selector `0xaaaddeaf` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envBool", abi = "envBool(string,string)")] - pub struct EnvBool1Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `envBytes` function with signature `envBytes(string)` and selector `0x4d7baf06` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envBytes", abi = "envBytes(string)")] - pub struct EnvBytes0Call(pub ::std::string::String); - ///Container type for all input parameters for the `envBytes` function with signature `envBytes(string,string)` and selector `0xddc2651b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envBytes", abi = "envBytes(string,string)")] - pub struct EnvBytes1Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `envBytes32` function with signature `envBytes32(string)` and selector `0x97949042` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envBytes32", abi = "envBytes32(string)")] - pub struct EnvBytes320Call(pub ::std::string::String); - ///Container type for all input parameters for the `envBytes32` function with signature `envBytes32(string,string)` and selector `0x5af231c1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envBytes32", abi = "envBytes32(string,string)")] - pub struct EnvBytes321Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `envInt` function with signature `envInt(string)` and selector `0x892a0c61` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envInt", abi = "envInt(string)")] - pub struct EnvInt0Call(pub ::std::string::String); - ///Container type for all input parameters for the `envInt` function with signature `envInt(string,string)` and selector `0x42181150` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envInt", abi = "envInt(string,string)")] - pub struct EnvInt1Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,bool)` and selector `0x4777f3cf` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,bool)")] - pub struct EnvOr0Call(pub ::std::string::String, pub bool); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,uint256)` and selector `0x5e97348f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,uint256)")] - pub struct EnvOr1Call(pub ::std::string::String, pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,int256)` and selector `0xbbcb713e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,int256)")] - pub struct EnvOr2Call(pub ::std::string::String, pub ::ethers_core::types::I256); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,address)` and selector `0x561fe540` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,address)")] - pub struct EnvOr3Call(pub ::std::string::String, pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,bytes32)` and selector `0xb4a85892` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,bytes32)")] - pub struct EnvOr4Call(pub ::std::string::String, pub [u8; 32]); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string)` and selector `0xd145736c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string)")] - pub struct EnvOr5Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,bytes)` and selector `0xb3e47705` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,bytes)")] - pub struct EnvOr6Call(pub ::std::string::String, pub ::ethers_core::types::Bytes); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string,bool[])` and selector `0xeb85e83b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string,bool[])")] - pub struct EnvOr7Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec, - ); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string,uint256[])` and selector `0x74318528` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string,uint256[])")] - pub struct EnvOr8Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::U256>, - ); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string,int256[])` and selector `0x4700d74b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string,int256[])")] - pub struct EnvOr9Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::I256>, - ); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string,address[])` and selector `0xc74e9deb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string,address[])")] - pub struct EnvOr10Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::Address>, - ); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string,bytes32[])` and selector `0x2281f367` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string,bytes32[])")] - pub struct EnvOr11Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<[u8; 32]>, - ); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string,string[])` and selector `0x859216bc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string,string[])")] - pub struct EnvOr12Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::std::string::String>, - ); - ///Container type for all input parameters for the `envOr` function with signature `envOr(string,string,bytes[])` and selector `0x64bc3e64` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envOr", abi = "envOr(string,string,bytes[])")] - pub struct EnvOr13Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::Bytes>, - ); - ///Container type for all input parameters for the `envString` function with signature `envString(string)` and selector `0xf877cb19` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envString", abi = "envString(string)")] - pub struct EnvString0Call(pub ::std::string::String); - ///Container type for all input parameters for the `envString` function with signature `envString(string,string)` and selector `0x14b02bc9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envString", abi = "envString(string,string)")] - pub struct EnvString1Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `envUint` function with signature `envUint(string)` and selector `0xc1978d1f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envUint", abi = "envUint(string)")] - pub struct EnvUint0Call(pub ::std::string::String); - ///Container type for all input parameters for the `envUint` function with signature `envUint(string,string)` and selector `0xf3dec099` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "envUint", abi = "envUint(string,string)")] - pub struct EnvUint1Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `etch` function with signature `etch(address,bytes)` and selector `0xb4d6c782` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "etch", abi = "etch(address,bytes)")] - pub struct EtchCall( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `eth_getLogs` function with signature `eth_getLogs(uint256,uint256,address,bytes32[])` and selector `0x35e1349b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "eth_getLogs", - abi = "eth_getLogs(uint256,uint256,address,bytes32[])" - )] - pub struct EthGetLogsCall( - pub ::ethers_core::types::U256, - pub ::ethers_core::types::U256, - pub ::ethers_core::types::Address, - pub ::std::vec::Vec<[u8; 32]>, - ); - ///Container type for all input parameters for the `exists` function with signature `exists(string)` and selector `0x261a323e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "exists", abi = "exists(string)")] - pub struct ExistsCall(pub ::std::string::String); - ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,bytes)` and selector `0xbd6af434` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectCall", abi = "expectCall(address,bytes)")] - pub struct ExpectCall0Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,bytes,uint64)` and selector `0xc1adbbff` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectCall", abi = "expectCall(address,bytes,uint64)")] - pub struct ExpectCall1Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Bytes, - pub u64, - ); - ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,uint256,bytes)` and selector `0xf30c7ba3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectCall", abi = "expectCall(address,uint256,bytes)")] - pub struct ExpectCall2Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,uint256,bytes,uint64)` and selector `0xa2b1a1ae` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectCall", abi = "expectCall(address,uint256,bytes,uint64)")] - pub struct ExpectCall3Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub ::ethers_core::types::Bytes, - pub u64, - ); - ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,uint256,uint64,bytes)` and selector `0x23361207` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectCall", abi = "expectCall(address,uint256,uint64,bytes)")] - pub struct ExpectCall4Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub u64, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `expectCall` function with signature `expectCall(address,uint256,uint64,bytes,uint64)` and selector `0x65b7b7cc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "expectCall", - abi = "expectCall(address,uint256,uint64,bytes,uint64)" - )] - pub struct ExpectCall5Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub u64, - pub ::ethers_core::types::Bytes, - pub u64, - ); - ///Container type for all input parameters for the `expectCallMinGas` function with signature `expectCallMinGas(address,uint256,uint64,bytes)` and selector `0x08e4e116` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "expectCallMinGas", - abi = "expectCallMinGas(address,uint256,uint64,bytes)" - )] - pub struct ExpectCallMinGas0Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub u64, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `expectCallMinGas` function with signature `expectCallMinGas(address,uint256,uint64,bytes,uint64)` and selector `0xe13a1834` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "expectCallMinGas", - abi = "expectCallMinGas(address,uint256,uint64,bytes,uint64)" - )] - pub struct ExpectCallMinGas1Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub u64, - pub ::ethers_core::types::Bytes, - pub u64, - ); - ///Container type for all input parameters for the `expectEmit` function with signature `expectEmit()` and selector `0x440ed10d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectEmit", abi = "expectEmit()")] - pub struct ExpectEmit0Call; - ///Container type for all input parameters for the `expectEmit` function with signature `expectEmit(address)` and selector `0x86b9620d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectEmit", abi = "expectEmit(address)")] - pub struct ExpectEmit1Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `expectEmit` function with signature `expectEmit(bool,bool,bool,bool)` and selector `0x491cc7c2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectEmit", abi = "expectEmit(bool,bool,bool,bool)")] - pub struct ExpectEmit2Call(pub bool, pub bool, pub bool, pub bool); - ///Container type for all input parameters for the `expectEmit` function with signature `expectEmit(bool,bool,bool,bool,address)` and selector `0x81bad6f3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectEmit", abi = "expectEmit(bool,bool,bool,bool,address)")] - pub struct ExpectEmit3Call( - pub bool, - pub bool, - pub bool, - pub bool, - pub ::ethers_core::types::Address, - ); - ///Container type for all input parameters for the `expectRevert` function with signature `expectRevert()` and selector `0xf4844814` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectRevert", abi = "expectRevert()")] - pub struct ExpectRevert0Call; - ///Container type for all input parameters for the `expectRevert` function with signature `expectRevert(bytes)` and selector `0xf28dceb3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectRevert", abi = "expectRevert(bytes)")] - pub struct ExpectRevert1Call(pub ::ethers_core::types::Bytes); - ///Container type for all input parameters for the `expectRevert` function with signature `expectRevert(bytes4)` and selector `0xc31eb0e0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectRevert", abi = "expectRevert(bytes4)")] - pub struct ExpectRevert2Call(pub [u8; 4]); - ///Container type for all input parameters for the `expectSafeMemory` function with signature `expectSafeMemory(uint64,uint64)` and selector `0x6d016688` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "expectSafeMemory", abi = "expectSafeMemory(uint64,uint64)")] - pub struct ExpectSafeMemoryCall(pub u64, pub u64); - ///Container type for all input parameters for the `expectSafeMemoryCall` function with signature `expectSafeMemoryCall(uint64,uint64)` and selector `0x05838bf4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "expectSafeMemoryCall", - abi = "expectSafeMemoryCall(uint64,uint64)" - )] - pub struct ExpectSafeMemoryCallCall(pub u64, pub u64); - ///Container type for all input parameters for the `fee` function with signature `fee(uint256)` and selector `0x39b37ab0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "fee", abi = "fee(uint256)")] - pub struct FeeCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `ffi` function with signature `ffi(string[])` and selector `0x89160467` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "ffi", abi = "ffi(string[])")] - pub struct FfiCall(pub ::std::vec::Vec<::std::string::String>); - ///Container type for all input parameters for the `fsMetadata` function with signature `fsMetadata(string)` and selector `0xaf368a08` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "fsMetadata", abi = "fsMetadata(string)")] - pub struct FsMetadataCall(pub ::std::string::String); - ///Container type for all input parameters for the `getCode` function with signature `getCode(string)` and selector `0x8d1cc925` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "getCode", abi = "getCode(string)")] - pub struct GetCodeCall(pub ::std::string::String); - ///Container type for all input parameters for the `getDeployedCode` function with signature `getDeployedCode(string)` and selector `0x3ebf73b4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "getDeployedCode", abi = "getDeployedCode(string)")] - pub struct GetDeployedCodeCall(pub ::std::string::String); - ///Container type for all input parameters for the `getLabel` function with signature `getLabel(address)` and selector `0x28a249b0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "getLabel", abi = "getLabel(address)")] - pub struct GetLabelCall(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `getMappingKeyAndParentOf` function with signature `getMappingKeyAndParentOf(address,bytes32)` and selector `0x876e24e6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "getMappingKeyAndParentOf", - abi = "getMappingKeyAndParentOf(address,bytes32)" - )] - pub struct GetMappingKeyAndParentOfCall( - pub ::ethers_core::types::Address, - pub [u8; 32], - ); - ///Container type for all input parameters for the `getMappingLength` function with signature `getMappingLength(address,bytes32)` and selector `0x2f2fd63f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "getMappingLength", abi = "getMappingLength(address,bytes32)")] - pub struct GetMappingLengthCall(pub ::ethers_core::types::Address, pub [u8; 32]); - ///Container type for all input parameters for the `getMappingSlotAt` function with signature `getMappingSlotAt(address,bytes32,uint256)` and selector `0xebc73ab4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "getMappingSlotAt", - abi = "getMappingSlotAt(address,bytes32,uint256)" - )] - pub struct GetMappingSlotAtCall( - pub ::ethers_core::types::Address, - pub [u8; 32], - pub ::ethers_core::types::U256, - ); - ///Container type for all input parameters for the `getNonce` function with signature `getNonce((address,uint256,uint256,uint256))` and selector `0xa5748aad` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "getNonce", abi = "getNonce((address,uint256,uint256,uint256))")] - pub struct GetNonce0Call(pub Wallet); - ///Container type for all input parameters for the `getNonce` function with signature `getNonce(address)` and selector `0x2d0335ab` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "getNonce", abi = "getNonce(address)")] - pub struct GetNonce1Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `getRecordedLogs` function with signature `getRecordedLogs()` and selector `0x191553a4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "getRecordedLogs", abi = "getRecordedLogs()")] - pub struct GetRecordedLogsCall; - ///Container type for all input parameters for the `isDir` function with signature `isDir(string)` and selector `0x7d15d019` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "isDir", abi = "isDir(string)")] - pub struct IsDirCall(pub ::std::string::String); - ///Container type for all input parameters for the `isFile` function with signature `isFile(string)` and selector `0xe0eb04d4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "isFile", abi = "isFile(string)")] - pub struct IsFileCall(pub ::std::string::String); - ///Container type for all input parameters for the `isPersistent` function with signature `isPersistent(address)` and selector `0xd92d8efd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "isPersistent", abi = "isPersistent(address)")] - pub struct IsPersistentCall(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `keyExists` function with signature `keyExists(string,string)` and selector `0x528a683c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "keyExists", abi = "keyExists(string,string)")] - pub struct KeyExistsCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `label` function with signature `label(address,string)` and selector `0xc657c718` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "label", abi = "label(address,string)")] - pub struct LabelCall(pub ::ethers_core::types::Address, pub ::std::string::String); - ///Container type for all input parameters for the `load` function with signature `load(address,bytes32)` and selector `0x667f9d70` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "load", abi = "load(address,bytes32)")] - pub struct LoadCall(pub ::ethers_core::types::Address, pub [u8; 32]); - ///Container type for all input parameters for the `makePersistent` function with signature `makePersistent(address)` and selector `0x57e22dde` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "makePersistent", abi = "makePersistent(address)")] - pub struct MakePersistent0Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `makePersistent` function with signature `makePersistent(address,address)` and selector `0x4074e0a8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "makePersistent", abi = "makePersistent(address,address)")] - pub struct MakePersistent2Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Address, - ); - ///Container type for all input parameters for the `makePersistent` function with signature `makePersistent(address,address,address)` and selector `0xefb77a75` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "makePersistent", abi = "makePersistent(address,address,address)")] - pub struct MakePersistent3Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Address, - ); - ///Container type for all input parameters for the `makePersistent` function with signature `makePersistent(address[])` and selector `0x1d9e269e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "makePersistent", abi = "makePersistent(address[])")] - pub struct MakePersistent1Call(pub ::std::vec::Vec<::ethers_core::types::Address>); - ///Container type for all input parameters for the `mockCall` function with signature `mockCall(address,bytes,bytes)` and selector `0xb96213e4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "mockCall", abi = "mockCall(address,bytes,bytes)")] - pub struct MockCall0Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Bytes, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `mockCall` function with signature `mockCall(address,uint256,bytes,bytes)` and selector `0x81409b91` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "mockCall", abi = "mockCall(address,uint256,bytes,bytes)")] - pub struct MockCall1Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub ::ethers_core::types::Bytes, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `mockCallRevert` function with signature `mockCallRevert(address,bytes,bytes)` and selector `0xdbaad147` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "mockCallRevert", abi = "mockCallRevert(address,bytes,bytes)")] - pub struct MockCallRevert0Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Bytes, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `mockCallRevert` function with signature `mockCallRevert(address,uint256,bytes,bytes)` and selector `0xd23cd037` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "mockCallRevert", - abi = "mockCallRevert(address,uint256,bytes,bytes)" - )] - pub struct MockCallRevert1Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::U256, - pub ::ethers_core::types::Bytes, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `openFile` function with signature `openFile(string)` and selector `0x7e0394bc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "openFile", abi = "openFile(string)")] - pub struct OpenFileCall(pub ::std::string::String); - ///Container type for all input parameters for the `parseAddress` function with signature `parseAddress(string)` and selector `0xc6ce059d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseAddress", abi = "parseAddress(string)")] - pub struct ParseAddressCall(pub ::std::string::String); - ///Container type for all input parameters for the `parseBool` function with signature `parseBool(string)` and selector `0x974ef924` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseBool", abi = "parseBool(string)")] - pub struct ParseBoolCall(pub ::std::string::String); - ///Container type for all input parameters for the `parseBytes` function with signature `parseBytes(string)` and selector `0x8f5d232d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseBytes", abi = "parseBytes(string)")] - pub struct ParseBytesCall(pub ::std::string::String); - ///Container type for all input parameters for the `parseBytes32` function with signature `parseBytes32(string)` and selector `0x087e6e81` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseBytes32", abi = "parseBytes32(string)")] - pub struct ParseBytes32Call(pub ::std::string::String); - ///Container type for all input parameters for the `parseInt` function with signature `parseInt(string)` and selector `0x42346c5e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseInt", abi = "parseInt(string)")] - pub struct ParseIntCall(pub ::std::string::String); - ///Container type for all input parameters for the `parseJson` function with signature `parseJson(string)` and selector `0x6a82600a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJson", abi = "parseJson(string)")] - pub struct ParseJson0Call(pub ::std::string::String); - ///Container type for all input parameters for the `parseJson` function with signature `parseJson(string,string)` and selector `0x85940ef1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJson", abi = "parseJson(string,string)")] - pub struct ParseJson1Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `parseJsonAddress` function with signature `parseJsonAddress(string,string)` and selector `0x1e19e657` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonAddress", abi = "parseJsonAddress(string,string)")] - pub struct ParseJsonAddressCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonAddressArray` function with signature `parseJsonAddressArray(string,string)` and selector `0x2fce7883` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "parseJsonAddressArray", - abi = "parseJsonAddressArray(string,string)" - )] - pub struct ParseJsonAddressArrayCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonBool` function with signature `parseJsonBool(string,string)` and selector `0x9f86dc91` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonBool", abi = "parseJsonBool(string,string)")] - pub struct ParseJsonBoolCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `parseJsonBoolArray` function with signature `parseJsonBoolArray(string,string)` and selector `0x91f3b94f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonBoolArray", abi = "parseJsonBoolArray(string,string)")] - pub struct ParseJsonBoolArrayCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonBytes` function with signature `parseJsonBytes(string,string)` and selector `0xfd921be8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonBytes", abi = "parseJsonBytes(string,string)")] - pub struct ParseJsonBytesCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `parseJsonBytes32` function with signature `parseJsonBytes32(string,string)` and selector `0x1777e59d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonBytes32", abi = "parseJsonBytes32(string,string)")] - pub struct ParseJsonBytes32Call( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonBytes32Array` function with signature `parseJsonBytes32Array(string,string)` and selector `0x91c75bc3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "parseJsonBytes32Array", - abi = "parseJsonBytes32Array(string,string)" - )] - pub struct ParseJsonBytes32ArrayCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonBytesArray` function with signature `parseJsonBytesArray(string,string)` and selector `0x6631aa99` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonBytesArray", abi = "parseJsonBytesArray(string,string)")] - pub struct ParseJsonBytesArrayCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonInt` function with signature `parseJsonInt(string,string)` and selector `0x7b048ccd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonInt", abi = "parseJsonInt(string,string)")] - pub struct ParseJsonIntCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `parseJsonIntArray` function with signature `parseJsonIntArray(string,string)` and selector `0x9983c28a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonIntArray", abi = "parseJsonIntArray(string,string)")] - pub struct ParseJsonIntArrayCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonKeys` function with signature `parseJsonKeys(string,string)` and selector `0x213e4198` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonKeys", abi = "parseJsonKeys(string,string)")] - pub struct ParseJsonKeysCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `parseJsonString` function with signature `parseJsonString(string,string)` and selector `0x49c4fac8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonString", abi = "parseJsonString(string,string)")] - pub struct ParseJsonStringCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `parseJsonStringArray` function with signature `parseJsonStringArray(string,string)` and selector `0x498fdcf4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "parseJsonStringArray", - abi = "parseJsonStringArray(string,string)" - )] - pub struct ParseJsonStringArrayCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseJsonUint` function with signature `parseJsonUint(string,string)` and selector `0xaddde2b6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonUint", abi = "parseJsonUint(string,string)")] - pub struct ParseJsonUintCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `parseJsonUintArray` function with signature `parseJsonUintArray(string,string)` and selector `0x522074ab` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseJsonUintArray", abi = "parseJsonUintArray(string,string)")] - pub struct ParseJsonUintArrayCall( - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `parseUint` function with signature `parseUint(string)` and selector `0xfa91454d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "parseUint", abi = "parseUint(string)")] - pub struct ParseUintCall(pub ::std::string::String); - ///Container type for all input parameters for the `pauseGasMetering` function with signature `pauseGasMetering()` and selector `0xd1a5b36f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "pauseGasMetering", abi = "pauseGasMetering()")] - pub struct PauseGasMeteringCall; - ///Container type for all input parameters for the `prank` function with signature `prank(address)` and selector `0xca669fa7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "prank", abi = "prank(address)")] - pub struct Prank0Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `prank` function with signature `prank(address,address)` and selector `0x47e50cce` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "prank", abi = "prank(address,address)")] - pub struct Prank1Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Address, - ); - ///Container type for all input parameters for the `prevrandao` function with signature `prevrandao(bytes32)` and selector `0x3b925549` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "prevrandao", abi = "prevrandao(bytes32)")] - pub struct PrevrandaoCall(pub [u8; 32]); - ///Container type for all input parameters for the `projectRoot` function with signature `projectRoot()` and selector `0xd930a0e6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "projectRoot", abi = "projectRoot()")] - pub struct ProjectRootCall; - ///Container type for all input parameters for the `readCallers` function with signature `readCallers()` and selector `0x4ad0bac9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readCallers", abi = "readCallers()")] - pub struct ReadCallersCall; - ///Container type for all input parameters for the `readDir` function with signature `readDir(string)` and selector `0xc4bc59e0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readDir", abi = "readDir(string)")] - pub struct ReadDir0Call(pub ::std::string::String); - ///Container type for all input parameters for the `readDir` function with signature `readDir(string,uint64)` and selector `0x1497876c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readDir", abi = "readDir(string,uint64)")] - pub struct ReadDir1Call(pub ::std::string::String, pub u64); - ///Container type for all input parameters for the `readDir` function with signature `readDir(string,uint64,bool)` and selector `0x8102d70d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readDir", abi = "readDir(string,uint64,bool)")] - pub struct ReadDir2Call(pub ::std::string::String, pub u64, pub bool); - ///Container type for all input parameters for the `readFile` function with signature `readFile(string)` and selector `0x60f9bb11` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readFile", abi = "readFile(string)")] - pub struct ReadFileCall(pub ::std::string::String); - ///Container type for all input parameters for the `readFileBinary` function with signature `readFileBinary(string)` and selector `0x16ed7bc4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readFileBinary", abi = "readFileBinary(string)")] - pub struct ReadFileBinaryCall(pub ::std::string::String); - ///Container type for all input parameters for the `readLine` function with signature `readLine(string)` and selector `0x70f55728` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readLine", abi = "readLine(string)")] - pub struct ReadLineCall(pub ::std::string::String); - ///Container type for all input parameters for the `readLink` function with signature `readLink(string)` and selector `0x9f5684a2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "readLink", abi = "readLink(string)")] - pub struct ReadLinkCall(pub ::std::string::String); - ///Container type for all input parameters for the `record` function with signature `record()` and selector `0x266cf109` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "record", abi = "record()")] - pub struct RecordCall; - ///Container type for all input parameters for the `recordLogs` function with signature `recordLogs()` and selector `0x41af2f52` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "recordLogs", abi = "recordLogs()")] - pub struct RecordLogsCall; - ///Container type for all input parameters for the `rememberKey` function with signature `rememberKey(uint256)` and selector `0x22100064` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rememberKey", abi = "rememberKey(uint256)")] - pub struct RememberKeyCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `removeDir` function with signature `removeDir(string,bool)` and selector `0x45c62011` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "removeDir", abi = "removeDir(string,bool)")] - pub struct RemoveDirCall(pub ::std::string::String, pub bool); - ///Container type for all input parameters for the `removeFile` function with signature `removeFile(string)` and selector `0xf1afe04d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "removeFile", abi = "removeFile(string)")] - pub struct RemoveFileCall(pub ::std::string::String); - ///Container type for all input parameters for the `resetNonce` function with signature `resetNonce(address)` and selector `0x1c72346d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "resetNonce", abi = "resetNonce(address)")] - pub struct ResetNonceCall(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `resumeGasMetering` function with signature `resumeGasMetering()` and selector `0x2bcd50e0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "resumeGasMetering", abi = "resumeGasMetering()")] - pub struct ResumeGasMeteringCall; - ///Container type for all input parameters for the `revertTo` function with signature `revertTo(uint256)` and selector `0x44d7f0a4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "revertTo", abi = "revertTo(uint256)")] - pub struct RevertToCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `revokePersistent` function with signature `revokePersistent(address)` and selector `0x997a0222` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "revokePersistent", abi = "revokePersistent(address)")] - pub struct RevokePersistent0Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `revokePersistent` function with signature `revokePersistent(address[])` and selector `0x3ce969e6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "revokePersistent", abi = "revokePersistent(address[])")] - pub struct RevokePersistent1Call(pub ::std::vec::Vec<::ethers_core::types::Address>); - ///Container type for all input parameters for the `roll` function with signature `roll(uint256)` and selector `0x1f7b4f30` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "roll", abi = "roll(uint256)")] - pub struct RollCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `rollFork` function with signature `rollFork(uint256)` and selector `0xd9bbf3a1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rollFork", abi = "rollFork(uint256)")] - pub struct RollFork0Call(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `rollFork` function with signature `rollFork(bytes32)` and selector `0x0f29772b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rollFork", abi = "rollFork(bytes32)")] - pub struct RollFork1Call(pub [u8; 32]); - ///Container type for all input parameters for the `rollFork` function with signature `rollFork(uint256,uint256)` and selector `0xd74c83a4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rollFork", abi = "rollFork(uint256,uint256)")] - pub struct RollFork2Call( - pub ::ethers_core::types::U256, - pub ::ethers_core::types::U256, - ); - ///Container type for all input parameters for the `rollFork` function with signature `rollFork(uint256,bytes32)` and selector `0xf2830f7b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rollFork", abi = "rollFork(uint256,bytes32)")] - pub struct RollFork3Call(pub ::ethers_core::types::U256, pub [u8; 32]); - ///Container type for all input parameters for the `rpc` function with signature `rpc(string,string)` and selector `0x1206c8a8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rpc", abi = "rpc(string,string)")] - pub struct RpcCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `rpcUrl` function with signature `rpcUrl(string)` and selector `0x975a6ce9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rpcUrl", abi = "rpcUrl(string)")] - pub struct RpcUrlCall(pub ::std::string::String); - ///Container type for all input parameters for the `rpcUrlStructs` function with signature `rpcUrlStructs()` and selector `0x9d2ad72a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rpcUrlStructs", abi = "rpcUrlStructs()")] - pub struct RpcUrlStructsCall; - ///Container type for all input parameters for the `rpcUrls` function with signature `rpcUrls()` and selector `0xa85a8418` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "rpcUrls", abi = "rpcUrls()")] - pub struct RpcUrlsCall; - ///Container type for all input parameters for the `selectFork` function with signature `selectFork(uint256)` and selector `0x9ebf6827` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "selectFork", abi = "selectFork(uint256)")] - pub struct SelectForkCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `serializeAddress` function with signature `serializeAddress(string,string,address)` and selector `0x972c6062` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "serializeAddress", - abi = "serializeAddress(string,string,address)" - )] - pub struct SerializeAddress0Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::ethers_core::types::Address, - ); - ///Container type for all input parameters for the `serializeAddress` function with signature `serializeAddress(string,string,address[])` and selector `0x1e356e1a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "serializeAddress", - abi = "serializeAddress(string,string,address[])" - )] - pub struct SerializeAddress1Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::Address>, - ); - ///Container type for all input parameters for the `serializeBool` function with signature `serializeBool(string,string,bool)` and selector `0xac22e971` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeBool", abi = "serializeBool(string,string,bool)")] - pub struct SerializeBool0Call( - pub ::std::string::String, - pub ::std::string::String, - pub bool, - ); - ///Container type for all input parameters for the `serializeBool` function with signature `serializeBool(string,string,bool[])` and selector `0x92925aa1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeBool", abi = "serializeBool(string,string,bool[])")] - pub struct SerializeBool1Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec, - ); - ///Container type for all input parameters for the `serializeBytes` function with signature `serializeBytes(string,string,bytes)` and selector `0xf21d52c7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeBytes", abi = "serializeBytes(string,string,bytes)")] - pub struct SerializeBytes0Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `serializeBytes` function with signature `serializeBytes(string,string,bytes[])` and selector `0x9884b232` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeBytes", abi = "serializeBytes(string,string,bytes[])")] - pub struct SerializeBytes1Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::Bytes>, - ); - ///Container type for all input parameters for the `serializeBytes32` function with signature `serializeBytes32(string,string,bytes32)` and selector `0x2d812b44` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "serializeBytes32", - abi = "serializeBytes32(string,string,bytes32)" - )] - pub struct SerializeBytes320Call( - pub ::std::string::String, - pub ::std::string::String, - pub [u8; 32], - ); - ///Container type for all input parameters for the `serializeBytes32` function with signature `serializeBytes32(string,string,bytes32[])` and selector `0x201e43e2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall( - name = "serializeBytes32", - abi = "serializeBytes32(string,string,bytes32[])" - )] - pub struct SerializeBytes321Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<[u8; 32]>, - ); - ///Container type for all input parameters for the `serializeInt` function with signature `serializeInt(string,string,int256)` and selector `0x3f33db60` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeInt", abi = "serializeInt(string,string,int256)")] - pub struct SerializeInt0Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::ethers_core::types::I256, - ); - ///Container type for all input parameters for the `serializeInt` function with signature `serializeInt(string,string,int256[])` and selector `0x7676e127` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeInt", abi = "serializeInt(string,string,int256[])")] - pub struct SerializeInt1Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::I256>, - ); - ///Container type for all input parameters for the `serializeJson` function with signature `serializeJson(string,string)` and selector `0x9b3358b0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeJson", abi = "serializeJson(string,string)")] - pub struct SerializeJsonCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `serializeString` function with signature `serializeString(string,string,string)` and selector `0x88da6d35` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeString", abi = "serializeString(string,string,string)")] - pub struct SerializeString0Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `serializeString` function with signature `serializeString(string,string,string[])` and selector `0x561cd6f3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeString", abi = "serializeString(string,string,string[])")] - pub struct SerializeString1Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::std::string::String>, - ); - ///Container type for all input parameters for the `serializeUint` function with signature `serializeUint(string,string,uint256)` and selector `0x129e9002` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeUint", abi = "serializeUint(string,string,uint256)")] - pub struct SerializeUint0Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::ethers_core::types::U256, - ); - ///Container type for all input parameters for the `serializeUint` function with signature `serializeUint(string,string,uint256[])` and selector `0xfee9a469` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "serializeUint", abi = "serializeUint(string,string,uint256[])")] - pub struct SerializeUint1Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::vec::Vec<::ethers_core::types::U256>, - ); - ///Container type for all input parameters for the `setEnv` function with signature `setEnv(string,string)` and selector `0x3d5923ee` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "setEnv", abi = "setEnv(string,string)")] - pub struct SetEnvCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `setNonce` function with signature `setNonce(address,uint64)` and selector `0xf8e18b57` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "setNonce", abi = "setNonce(address,uint64)")] - pub struct SetNonceCall(pub ::ethers_core::types::Address, pub u64); - ///Container type for all input parameters for the `setNonceUnsafe` function with signature `setNonceUnsafe(address,uint64)` and selector `0x9b67b21c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "setNonceUnsafe", abi = "setNonceUnsafe(address,uint64)")] - pub struct SetNonceUnsafeCall(pub ::ethers_core::types::Address, pub u64); - ///Container type for all input parameters for the `sign` function with signature `sign(uint256,bytes32)` and selector `0xe341eaa4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "sign", abi = "sign(uint256,bytes32)")] - pub struct Sign0Call(pub ::ethers_core::types::U256, pub [u8; 32]); - ///Container type for all input parameters for the `sign` function with signature `sign((address,uint256,uint256,uint256),bytes32)` and selector `0xb25c5a25` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "sign", abi = "sign((address,uint256,uint256,uint256),bytes32)")] - pub struct Sign1Call(pub Wallet, pub [u8; 32]); - ///Container type for all input parameters for the `skip` function with signature `skip(bool)` and selector `0xdd82d13e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "skip", abi = "skip(bool)")] - pub struct SkipCall(pub bool); - ///Container type for all input parameters for the `sleep` function with signature `sleep(uint256)` and selector `0xfa9d8713` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "sleep", abi = "sleep(uint256)")] - pub struct SleepCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `snapshot` function with signature `snapshot()` and selector `0x9711715a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "snapshot", abi = "snapshot()")] - pub struct SnapshotCall; - ///Container type for all input parameters for the `startBroadcast` function with signature `startBroadcast()` and selector `0x7fb5297f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "startBroadcast", abi = "startBroadcast()")] - pub struct StartBroadcast0Call; - ///Container type for all input parameters for the `startBroadcast` function with signature `startBroadcast(address)` and selector `0x7fec2a8d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "startBroadcast", abi = "startBroadcast(address)")] - pub struct StartBroadcast1Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `startBroadcast` function with signature `startBroadcast(uint256)` and selector `0xce817d47` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "startBroadcast", abi = "startBroadcast(uint256)")] - pub struct StartBroadcast2Call(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `startMappingRecording` function with signature `startMappingRecording()` and selector `0x3e9705c0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "startMappingRecording", abi = "startMappingRecording()")] - pub struct StartMappingRecordingCall; - ///Container type for all input parameters for the `startPrank` function with signature `startPrank(address)` and selector `0x06447d56` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "startPrank", abi = "startPrank(address)")] - pub struct StartPrank0Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `startPrank` function with signature `startPrank(address,address)` and selector `0x45b56078` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "startPrank", abi = "startPrank(address,address)")] - pub struct StartPrank1Call( - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Address, - ); - ///Container type for all input parameters for the `startStateDiffRecording` function with signature `startStateDiffRecording()` and selector `0xcf22e3c9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "startStateDiffRecording", abi = "startStateDiffRecording()")] - pub struct StartStateDiffRecordingCall; - ///Container type for all input parameters for the `stopAndReturnStateDiff` function with signature `stopAndReturnStateDiff()` and selector `0xaa5cf90e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "stopAndReturnStateDiff", abi = "stopAndReturnStateDiff()")] - pub struct StopAndReturnStateDiffCall; - ///Container type for all input parameters for the `stopBroadcast` function with signature `stopBroadcast()` and selector `0x76eadd36` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "stopBroadcast", abi = "stopBroadcast()")] - pub struct StopBroadcastCall; - ///Container type for all input parameters for the `stopMappingRecording` function with signature `stopMappingRecording()` and selector `0x0d4aae9b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "stopMappingRecording", abi = "stopMappingRecording()")] - pub struct StopMappingRecordingCall; - ///Container type for all input parameters for the `stopPrank` function with signature `stopPrank()` and selector `0x90c5013b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "stopPrank", abi = "stopPrank()")] - pub struct StopPrankCall; - ///Container type for all input parameters for the `store` function with signature `store(address,bytes32,bytes32)` and selector `0x70ca10bb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "store", abi = "store(address,bytes32,bytes32)")] - pub struct StoreCall(pub ::ethers_core::types::Address, pub [u8; 32], pub [u8; 32]); - ///Container type for all input parameters for the `toString` function with signature `toString(bytes)` and selector `0x71aad10d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "toString", abi = "toString(bytes)")] - pub struct ToString0Call(pub ::ethers_core::types::Bytes); - ///Container type for all input parameters for the `toString` function with signature `toString(address)` and selector `0x56ca623e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "toString", abi = "toString(address)")] - pub struct ToString1Call(pub ::ethers_core::types::Address); - ///Container type for all input parameters for the `toString` function with signature `toString(uint256)` and selector `0x6900a3ae` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "toString", abi = "toString(uint256)")] - pub struct ToString2Call(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `toString` function with signature `toString(int256)` and selector `0xa322c40e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "toString", abi = "toString(int256)")] - pub struct ToString3Call(pub ::ethers_core::types::I256); - ///Container type for all input parameters for the `toString` function with signature `toString(bytes32)` and selector `0xb11a19e8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "toString", abi = "toString(bytes32)")] - pub struct ToString4Call(pub [u8; 32]); - ///Container type for all input parameters for the `toString` function with signature `toString(bool)` and selector `0x71dce7da` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "toString", abi = "toString(bool)")] - pub struct ToString5Call(pub bool); - ///Container type for all input parameters for the `transact` function with signature `transact(bytes32)` and selector `0xbe646da1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "transact", abi = "transact(bytes32)")] - pub struct Transact0Call(pub [u8; 32]); - ///Container type for all input parameters for the `transact` function with signature `transact(uint256,bytes32)` and selector `0x4d8abc4b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "transact", abi = "transact(uint256,bytes32)")] - pub struct Transact1Call(pub ::ethers_core::types::U256, pub [u8; 32]); - ///Container type for all input parameters for the `tryFfi` function with signature `tryFfi(string[])` and selector `0xf45c1ce7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "tryFfi", abi = "tryFfi(string[])")] - pub struct TryFfiCall(pub ::std::vec::Vec<::std::string::String>); - ///Container type for all input parameters for the `txGasPrice` function with signature `txGasPrice(uint256)` and selector `0x48f50c0f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "txGasPrice", abi = "txGasPrice(uint256)")] - pub struct TxGasPriceCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `unixTime` function with signature `unixTime()` and selector `0x625387dc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "unixTime", abi = "unixTime()")] - pub struct UnixTimeCall; - ///Container type for all input parameters for the `warp` function with signature `warp(uint256)` and selector `0xe5d6bf02` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "warp", abi = "warp(uint256)")] - pub struct WarpCall(pub ::ethers_core::types::U256); - ///Container type for all input parameters for the `writeFile` function with signature `writeFile(string,string)` and selector `0x897e0a97` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "writeFile", abi = "writeFile(string,string)")] - pub struct WriteFileCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `writeFileBinary` function with signature `writeFileBinary(string,bytes)` and selector `0x1f21fc80` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "writeFileBinary", abi = "writeFileBinary(string,bytes)")] - pub struct WriteFileBinaryCall( - pub ::std::string::String, - pub ::ethers_core::types::Bytes, - ); - ///Container type for all input parameters for the `writeJson` function with signature `writeJson(string,string)` and selector `0xe23cd19f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "writeJson", abi = "writeJson(string,string)")] - pub struct WriteJson0Call(pub ::std::string::String, pub ::std::string::String); - ///Container type for all input parameters for the `writeJson` function with signature `writeJson(string,string,string)` and selector `0x35d6ad46` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "writeJson", abi = "writeJson(string,string,string)")] - pub struct WriteJson1Call( - pub ::std::string::String, - pub ::std::string::String, - pub ::std::string::String, - ); - ///Container type for all input parameters for the `writeLine` function with signature `writeLine(string,string)` and selector `0x619d897f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "writeLine", abi = "writeLine(string,string)")] - pub struct WriteLineCall(pub ::std::string::String, pub ::std::string::String); - ///Container type for all of the contract's call - #[derive(Clone, ::ethers_contract::EthAbiType, Debug, PartialEq, Eq, Hash)] - pub enum HEVMCalls { - Accesses(AccessesCall), - ActiveFork(ActiveForkCall), - Addr(AddrCall), - AllowCheatcodes(AllowCheatcodesCall), - Assume(AssumeCall), - Breakpoint0(Breakpoint0Call), - Breakpoint1(Breakpoint1Call), - Broadcast0(Broadcast0Call), - Broadcast1(Broadcast1Call), - Broadcast2(Broadcast2Call), - ChainId(ChainIdCall), - ClearMockedCalls(ClearMockedCallsCall), - CloseFile(CloseFileCall), - Coinbase(CoinbaseCall), - Cool(CoolCall), - CopyFile(CopyFileCall), - CreateDir(CreateDirCall), - CreateFork1(CreateFork1Call), - CreateFork2(CreateFork2Call), - CreateFork0(CreateFork0Call), - CreateSelectFork1(CreateSelectFork1Call), - CreateSelectFork2(CreateSelectFork2Call), - CreateSelectFork0(CreateSelectFork0Call), - CreateWallet0(CreateWallet0Call), - CreateWallet1(CreateWallet1Call), - CreateWallet2(CreateWallet2Call), - Deal(DealCall), - DeriveKey0(DeriveKey0Call), - DeriveKey1(DeriveKey1Call), - DeriveKey2(DeriveKey2Call), - DeriveKey3(DeriveKey3Call), - Difficulty(DifficultyCall), - EnvAddress0(EnvAddress0Call), - EnvAddress1(EnvAddress1Call), - EnvBool0(EnvBool0Call), - EnvBool1(EnvBool1Call), - EnvBytes0(EnvBytes0Call), - EnvBytes1(EnvBytes1Call), - EnvBytes320(EnvBytes320Call), - EnvBytes321(EnvBytes321Call), - EnvInt0(EnvInt0Call), - EnvInt1(EnvInt1Call), - EnvOr0(EnvOr0Call), - EnvOr1(EnvOr1Call), - EnvOr2(EnvOr2Call), - EnvOr3(EnvOr3Call), - EnvOr4(EnvOr4Call), - EnvOr5(EnvOr5Call), - EnvOr6(EnvOr6Call), - EnvOr7(EnvOr7Call), - EnvOr8(EnvOr8Call), - EnvOr9(EnvOr9Call), - EnvOr10(EnvOr10Call), - EnvOr11(EnvOr11Call), - EnvOr12(EnvOr12Call), - EnvOr13(EnvOr13Call), - EnvString0(EnvString0Call), - EnvString1(EnvString1Call), - EnvUint0(EnvUint0Call), - EnvUint1(EnvUint1Call), - Etch(EtchCall), - EthGetLogs(EthGetLogsCall), - Exists(ExistsCall), - ExpectCall0(ExpectCall0Call), - ExpectCall1(ExpectCall1Call), - ExpectCall2(ExpectCall2Call), - ExpectCall3(ExpectCall3Call), - ExpectCall4(ExpectCall4Call), - ExpectCall5(ExpectCall5Call), - ExpectCallMinGas0(ExpectCallMinGas0Call), - ExpectCallMinGas1(ExpectCallMinGas1Call), - ExpectEmit0(ExpectEmit0Call), - ExpectEmit1(ExpectEmit1Call), - ExpectEmit2(ExpectEmit2Call), - ExpectEmit3(ExpectEmit3Call), - ExpectRevert0(ExpectRevert0Call), - ExpectRevert1(ExpectRevert1Call), - ExpectRevert2(ExpectRevert2Call), - ExpectSafeMemory(ExpectSafeMemoryCall), - ExpectSafeMemoryCall(ExpectSafeMemoryCallCall), - Fee(FeeCall), - Ffi(FfiCall), - FsMetadata(FsMetadataCall), - GetCode(GetCodeCall), - GetDeployedCode(GetDeployedCodeCall), - GetLabel(GetLabelCall), - GetMappingKeyAndParentOf(GetMappingKeyAndParentOfCall), - GetMappingLength(GetMappingLengthCall), - GetMappingSlotAt(GetMappingSlotAtCall), - GetNonce0(GetNonce0Call), - GetNonce1(GetNonce1Call), - GetRecordedLogs(GetRecordedLogsCall), - IsDir(IsDirCall), - IsFile(IsFileCall), - IsPersistent(IsPersistentCall), - KeyExists(KeyExistsCall), - Label(LabelCall), - Load(LoadCall), - MakePersistent0(MakePersistent0Call), - MakePersistent2(MakePersistent2Call), - MakePersistent3(MakePersistent3Call), - MakePersistent1(MakePersistent1Call), - MockCall0(MockCall0Call), - MockCall1(MockCall1Call), - MockCallRevert0(MockCallRevert0Call), - MockCallRevert1(MockCallRevert1Call), - OpenFile(OpenFileCall), - ParseAddress(ParseAddressCall), - ParseBool(ParseBoolCall), - ParseBytes(ParseBytesCall), - ParseBytes32(ParseBytes32Call), - ParseInt(ParseIntCall), - ParseJson0(ParseJson0Call), - ParseJson1(ParseJson1Call), - ParseJsonAddress(ParseJsonAddressCall), - ParseJsonAddressArray(ParseJsonAddressArrayCall), - ParseJsonBool(ParseJsonBoolCall), - ParseJsonBoolArray(ParseJsonBoolArrayCall), - ParseJsonBytes(ParseJsonBytesCall), - ParseJsonBytes32(ParseJsonBytes32Call), - ParseJsonBytes32Array(ParseJsonBytes32ArrayCall), - ParseJsonBytesArray(ParseJsonBytesArrayCall), - ParseJsonInt(ParseJsonIntCall), - ParseJsonIntArray(ParseJsonIntArrayCall), - ParseJsonKeys(ParseJsonKeysCall), - ParseJsonString(ParseJsonStringCall), - ParseJsonStringArray(ParseJsonStringArrayCall), - ParseJsonUint(ParseJsonUintCall), - ParseJsonUintArray(ParseJsonUintArrayCall), - ParseUint(ParseUintCall), - PauseGasMetering(PauseGasMeteringCall), - Prank0(Prank0Call), - Prank1(Prank1Call), - Prevrandao(PrevrandaoCall), - ProjectRoot(ProjectRootCall), - ReadCallers(ReadCallersCall), - ReadDir0(ReadDir0Call), - ReadDir1(ReadDir1Call), - ReadDir2(ReadDir2Call), - ReadFile(ReadFileCall), - ReadFileBinary(ReadFileBinaryCall), - ReadLine(ReadLineCall), - ReadLink(ReadLinkCall), - Record(RecordCall), - RecordLogs(RecordLogsCall), - RememberKey(RememberKeyCall), - RemoveDir(RemoveDirCall), - RemoveFile(RemoveFileCall), - ResetNonce(ResetNonceCall), - ResumeGasMetering(ResumeGasMeteringCall), - RevertTo(RevertToCall), - RevokePersistent0(RevokePersistent0Call), - RevokePersistent1(RevokePersistent1Call), - Roll(RollCall), - RollFork0(RollFork0Call), - RollFork1(RollFork1Call), - RollFork2(RollFork2Call), - RollFork3(RollFork3Call), - Rpc(RpcCall), - RpcUrl(RpcUrlCall), - RpcUrlStructs(RpcUrlStructsCall), - RpcUrls(RpcUrlsCall), - SelectFork(SelectForkCall), - SerializeAddress0(SerializeAddress0Call), - SerializeAddress1(SerializeAddress1Call), - SerializeBool0(SerializeBool0Call), - SerializeBool1(SerializeBool1Call), - SerializeBytes0(SerializeBytes0Call), - SerializeBytes1(SerializeBytes1Call), - SerializeBytes320(SerializeBytes320Call), - SerializeBytes321(SerializeBytes321Call), - SerializeInt0(SerializeInt0Call), - SerializeInt1(SerializeInt1Call), - SerializeJson(SerializeJsonCall), - SerializeString0(SerializeString0Call), - SerializeString1(SerializeString1Call), - SerializeUint0(SerializeUint0Call), - SerializeUint1(SerializeUint1Call), - SetEnv(SetEnvCall), - SetNonce(SetNonceCall), - SetNonceUnsafe(SetNonceUnsafeCall), - Sign0(Sign0Call), - Sign1(Sign1Call), - Skip(SkipCall), - Sleep(SleepCall), - Snapshot(SnapshotCall), - StartBroadcast0(StartBroadcast0Call), - StartBroadcast1(StartBroadcast1Call), - StartBroadcast2(StartBroadcast2Call), - StartMappingRecording(StartMappingRecordingCall), - StartPrank0(StartPrank0Call), - StartPrank1(StartPrank1Call), - StartStateDiffRecording(StartStateDiffRecordingCall), - StopAndReturnStateDiff(StopAndReturnStateDiffCall), - StopBroadcast(StopBroadcastCall), - StopMappingRecording(StopMappingRecordingCall), - StopPrank(StopPrankCall), - Store(StoreCall), - ToString0(ToString0Call), - ToString1(ToString1Call), - ToString2(ToString2Call), - ToString3(ToString3Call), - ToString4(ToString4Call), - ToString5(ToString5Call), - Transact0(Transact0Call), - Transact1(Transact1Call), - TryFfi(TryFfiCall), - TxGasPrice(TxGasPriceCall), - UnixTime(UnixTimeCall), - Warp(WarpCall), - WriteFile(WriteFileCall), - WriteFileBinary(WriteFileBinaryCall), - WriteJson0(WriteJson0Call), - WriteJson1(WriteJson1Call), - WriteLine(WriteLineCall), - } - impl ::ethers_core::abi::AbiDecode for HEVMCalls { - fn decode( - data: impl AsRef<[u8]>, - ) -> ::core::result::Result { - let data = data.as_ref(); - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Accesses(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ActiveFork(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Addr(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::AllowCheatcodes(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Assume(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Breakpoint0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Breakpoint1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Broadcast0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Broadcast1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Broadcast2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ChainId(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ClearMockedCalls(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CloseFile(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Coinbase(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Cool(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CopyFile(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateDir(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateFork1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateFork2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateFork0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateSelectFork1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateSelectFork2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateSelectFork0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateWallet0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateWallet1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::CreateWallet2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Deal(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::DeriveKey0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::DeriveKey1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::DeriveKey2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::DeriveKey3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Difficulty(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvAddress0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvAddress1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvBool0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvBool1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvBytes0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvBytes1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvBytes320(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvBytes321(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvInt0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvInt1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr4(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr5(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr6(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr7(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr8(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr9(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr10(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr11(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr12(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvOr13(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvString0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvString1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvUint0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EnvUint1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Etch(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::EthGetLogs(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Exists(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCall0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCall1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCall2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCall3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCall4(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCall5(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCallMinGas0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectCallMinGas1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectEmit0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectEmit1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectEmit2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectEmit3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectRevert0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectRevert1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectRevert2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectSafeMemory(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ExpectSafeMemoryCall(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Fee(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Ffi(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::FsMetadata(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetCode(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetDeployedCode(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetLabel(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetMappingKeyAndParentOf(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetMappingLength(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetMappingSlotAt(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetNonce0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetNonce1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::GetRecordedLogs(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::IsDir(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::IsFile(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::IsPersistent(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::KeyExists(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Label(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Load(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MakePersistent0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MakePersistent2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MakePersistent3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MakePersistent1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MockCall0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MockCall1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MockCallRevert0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::MockCallRevert1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::OpenFile(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseAddress(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseBool(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseBytes(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseBytes32(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseInt(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJson0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJson1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonAddress(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonAddressArray(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonBool(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonBoolArray(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonBytes(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonBytes32(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonBytes32Array(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonBytesArray(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonInt(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonIntArray(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonKeys(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonString(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonStringArray(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonUint(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseJsonUintArray(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ParseUint(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::PauseGasMetering(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Prank0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Prank1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Prevrandao(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ProjectRoot(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadCallers(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadDir0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadDir1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadDir2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadFile(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadFileBinary(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadLine(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ReadLink(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Record(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RecordLogs(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RememberKey(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RemoveDir(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RemoveFile(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ResetNonce(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ResumeGasMetering(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RevertTo(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RevokePersistent0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RevokePersistent1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Roll(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RollFork0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RollFork1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RollFork2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RollFork3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Rpc(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RpcUrl(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RpcUrlStructs(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::RpcUrls(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SelectFork(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeAddress0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeAddress1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeBool0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeBool1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeBytes0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeBytes1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeBytes320(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeBytes321(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeInt0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeInt1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeJson(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeString0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeString1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeUint0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SerializeUint1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SetEnv(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SetNonce(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::SetNonceUnsafe(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Sign0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Sign1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Skip(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Sleep(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Snapshot(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StartBroadcast0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StartBroadcast1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StartBroadcast2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StartMappingRecording(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StartPrank0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StartPrank1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StartStateDiffRecording(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StopAndReturnStateDiff(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StopBroadcast(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StopMappingRecording(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::StopPrank(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Store(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ToString0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ToString1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ToString2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ToString3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ToString4(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::ToString5(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Transact0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Transact1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::TryFfi(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::TxGasPrice(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::UnixTime(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Warp(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::WriteFile(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::WriteFileBinary(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::WriteJson0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::WriteJson1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::WriteLine(decoded)); - } - Err(::ethers_core::abi::Error::InvalidData.into()) - } - } - impl ::ethers_core::abi::AbiEncode for HEVMCalls { - fn encode(self) -> Vec { - match self { - Self::Accesses(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ActiveFork(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Addr(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::AllowCheatcodes(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Assume(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Breakpoint0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Breakpoint1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Broadcast0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Broadcast1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Broadcast2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ChainId(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ClearMockedCalls(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CloseFile(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Coinbase(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Cool(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::CopyFile(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::CreateDir(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateFork1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateFork2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateFork0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateSelectFork1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateSelectFork2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateSelectFork0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateWallet0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateWallet1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::CreateWallet2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Deal(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::DeriveKey0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::DeriveKey1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::DeriveKey2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::DeriveKey3(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Difficulty(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvAddress0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvAddress1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvBool0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvBool1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvBytes0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvBytes1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvBytes320(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvBytes321(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvInt0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvInt1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr2(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr3(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr4(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr5(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr6(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr7(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr8(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr9(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr10(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr11(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr12(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvOr13(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvString0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvString1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::EnvUint0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EnvUint1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Etch(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::EthGetLogs(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Exists(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ExpectCall0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectCall1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectCall2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectCall3(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectCall4(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectCall5(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectCallMinGas0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectCallMinGas1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectEmit0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectEmit1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectEmit2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectEmit3(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectRevert0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectRevert1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectRevert2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectSafeMemory(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ExpectSafeMemoryCall(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Fee(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Ffi(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::FsMetadata(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::GetCode(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::GetDeployedCode(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::GetLabel(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::GetMappingKeyAndParentOf(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::GetMappingLength(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::GetMappingSlotAt(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::GetNonce0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::GetNonce1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::GetRecordedLogs(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::IsDir(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::IsFile(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::IsPersistent(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::KeyExists(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Label(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Load(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::MakePersistent0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::MakePersistent2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::MakePersistent3(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::MakePersistent1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::MockCall0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::MockCall1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::MockCallRevert0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::MockCallRevert1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::OpenFile(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ParseAddress(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseBool(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseBytes(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseBytes32(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseInt(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ParseJson0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJson1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonAddress(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonAddressArray(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonBool(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonBoolArray(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonBytes(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonBytes32(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonBytes32Array(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonBytesArray(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonInt(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonIntArray(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonKeys(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonString(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonStringArray(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonUint(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseJsonUintArray(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ParseUint(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::PauseGasMetering(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Prank0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Prank1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Prevrandao(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ProjectRoot(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ReadCallers(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ReadDir0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ReadDir1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ReadDir2(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ReadFile(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ReadFileBinary(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ReadLine(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ReadLink(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Record(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::RecordLogs(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RememberKey(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RemoveDir(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RemoveFile(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ResetNonce(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ResumeGasMetering(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RevertTo(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::RevokePersistent0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RevokePersistent1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Roll(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::RollFork0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RollFork1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RollFork2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RollFork3(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Rpc(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::RpcUrl(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::RpcUrlStructs(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::RpcUrls(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::SelectFork(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeAddress0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeAddress1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeBool0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeBool1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeBytes0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeBytes1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeBytes320(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeBytes321(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeInt0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeInt1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeJson(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeString0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeString1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeUint0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SerializeUint1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::SetEnv(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::SetNonce(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::SetNonceUnsafe(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Sign0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Sign1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Skip(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Sleep(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Snapshot(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::StartBroadcast0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StartBroadcast1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StartBroadcast2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StartMappingRecording(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StartPrank0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StartPrank1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StartStateDiffRecording(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StopAndReturnStateDiff(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StopBroadcast(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StopMappingRecording(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::StopPrank(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Store(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::ToString0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ToString1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ToString2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ToString3(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ToString4(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::ToString5(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Transact0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::Transact1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::TryFfi(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::TxGasPrice(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::UnixTime(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Warp(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::WriteFile(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::WriteFileBinary(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::WriteJson0(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::WriteJson1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::WriteLine(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - } - } - } - impl ::core::fmt::Display for HEVMCalls { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Self::Accesses(element) => ::core::fmt::Display::fmt(element, f), - Self::ActiveFork(element) => ::core::fmt::Display::fmt(element, f), - Self::Addr(element) => ::core::fmt::Display::fmt(element, f), - Self::AllowCheatcodes(element) => ::core::fmt::Display::fmt(element, f), - Self::Assume(element) => ::core::fmt::Display::fmt(element, f), - Self::Breakpoint0(element) => ::core::fmt::Display::fmt(element, f), - Self::Breakpoint1(element) => ::core::fmt::Display::fmt(element, f), - Self::Broadcast0(element) => ::core::fmt::Display::fmt(element, f), - Self::Broadcast1(element) => ::core::fmt::Display::fmt(element, f), - Self::Broadcast2(element) => ::core::fmt::Display::fmt(element, f), - Self::ChainId(element) => ::core::fmt::Display::fmt(element, f), - Self::ClearMockedCalls(element) => ::core::fmt::Display::fmt(element, f), - Self::CloseFile(element) => ::core::fmt::Display::fmt(element, f), - Self::Coinbase(element) => ::core::fmt::Display::fmt(element, f), - Self::Cool(element) => ::core::fmt::Display::fmt(element, f), - Self::CopyFile(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateDir(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateFork1(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateFork2(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateFork0(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateSelectFork1(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateSelectFork2(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateSelectFork0(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateWallet0(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateWallet1(element) => ::core::fmt::Display::fmt(element, f), - Self::CreateWallet2(element) => ::core::fmt::Display::fmt(element, f), - Self::Deal(element) => ::core::fmt::Display::fmt(element, f), - Self::DeriveKey0(element) => ::core::fmt::Display::fmt(element, f), - Self::DeriveKey1(element) => ::core::fmt::Display::fmt(element, f), - Self::DeriveKey2(element) => ::core::fmt::Display::fmt(element, f), - Self::DeriveKey3(element) => ::core::fmt::Display::fmt(element, f), - Self::Difficulty(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvAddress0(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvAddress1(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvBool0(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvBool1(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvBytes0(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvBytes1(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvBytes320(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvBytes321(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvInt0(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvInt1(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr0(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr1(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr2(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr3(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr4(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr5(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr6(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr7(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr8(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr9(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr10(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr11(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr12(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvOr13(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvString0(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvString1(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvUint0(element) => ::core::fmt::Display::fmt(element, f), - Self::EnvUint1(element) => ::core::fmt::Display::fmt(element, f), - Self::Etch(element) => ::core::fmt::Display::fmt(element, f), - Self::EthGetLogs(element) => ::core::fmt::Display::fmt(element, f), - Self::Exists(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCall0(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCall1(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCall2(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCall3(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCall4(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCall5(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCallMinGas0(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectCallMinGas1(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectEmit0(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectEmit1(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectEmit2(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectEmit3(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectRevert0(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectRevert1(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectRevert2(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectSafeMemory(element) => ::core::fmt::Display::fmt(element, f), - Self::ExpectSafeMemoryCall(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::Fee(element) => ::core::fmt::Display::fmt(element, f), - Self::Ffi(element) => ::core::fmt::Display::fmt(element, f), - Self::FsMetadata(element) => ::core::fmt::Display::fmt(element, f), - Self::GetCode(element) => ::core::fmt::Display::fmt(element, f), - Self::GetDeployedCode(element) => ::core::fmt::Display::fmt(element, f), - Self::GetLabel(element) => ::core::fmt::Display::fmt(element, f), - Self::GetMappingKeyAndParentOf(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::GetMappingLength(element) => ::core::fmt::Display::fmt(element, f), - Self::GetMappingSlotAt(element) => ::core::fmt::Display::fmt(element, f), - Self::GetNonce0(element) => ::core::fmt::Display::fmt(element, f), - Self::GetNonce1(element) => ::core::fmt::Display::fmt(element, f), - Self::GetRecordedLogs(element) => ::core::fmt::Display::fmt(element, f), - Self::IsDir(element) => ::core::fmt::Display::fmt(element, f), - Self::IsFile(element) => ::core::fmt::Display::fmt(element, f), - Self::IsPersistent(element) => ::core::fmt::Display::fmt(element, f), - Self::KeyExists(element) => ::core::fmt::Display::fmt(element, f), - Self::Label(element) => ::core::fmt::Display::fmt(element, f), - Self::Load(element) => ::core::fmt::Display::fmt(element, f), - Self::MakePersistent0(element) => ::core::fmt::Display::fmt(element, f), - Self::MakePersistent2(element) => ::core::fmt::Display::fmt(element, f), - Self::MakePersistent3(element) => ::core::fmt::Display::fmt(element, f), - Self::MakePersistent1(element) => ::core::fmt::Display::fmt(element, f), - Self::MockCall0(element) => ::core::fmt::Display::fmt(element, f), - Self::MockCall1(element) => ::core::fmt::Display::fmt(element, f), - Self::MockCallRevert0(element) => ::core::fmt::Display::fmt(element, f), - Self::MockCallRevert1(element) => ::core::fmt::Display::fmt(element, f), - Self::OpenFile(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseAddress(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseBool(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseBytes(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseBytes32(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseInt(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJson0(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJson1(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonAddress(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonAddressArray(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::ParseJsonBool(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonBoolArray(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::ParseJsonBytes(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonBytes32(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonBytes32Array(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::ParseJsonBytesArray(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::ParseJsonInt(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonIntArray(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonKeys(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonString(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonStringArray(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::ParseJsonUint(element) => ::core::fmt::Display::fmt(element, f), - Self::ParseJsonUintArray(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::ParseUint(element) => ::core::fmt::Display::fmt(element, f), - Self::PauseGasMetering(element) => ::core::fmt::Display::fmt(element, f), - Self::Prank0(element) => ::core::fmt::Display::fmt(element, f), - Self::Prank1(element) => ::core::fmt::Display::fmt(element, f), - Self::Prevrandao(element) => ::core::fmt::Display::fmt(element, f), - Self::ProjectRoot(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadCallers(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadDir0(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadDir1(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadDir2(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadFile(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadFileBinary(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadLine(element) => ::core::fmt::Display::fmt(element, f), - Self::ReadLink(element) => ::core::fmt::Display::fmt(element, f), - Self::Record(element) => ::core::fmt::Display::fmt(element, f), - Self::RecordLogs(element) => ::core::fmt::Display::fmt(element, f), - Self::RememberKey(element) => ::core::fmt::Display::fmt(element, f), - Self::RemoveDir(element) => ::core::fmt::Display::fmt(element, f), - Self::RemoveFile(element) => ::core::fmt::Display::fmt(element, f), - Self::ResetNonce(element) => ::core::fmt::Display::fmt(element, f), - Self::ResumeGasMetering(element) => ::core::fmt::Display::fmt(element, f), - Self::RevertTo(element) => ::core::fmt::Display::fmt(element, f), - Self::RevokePersistent0(element) => ::core::fmt::Display::fmt(element, f), - Self::RevokePersistent1(element) => ::core::fmt::Display::fmt(element, f), - Self::Roll(element) => ::core::fmt::Display::fmt(element, f), - Self::RollFork0(element) => ::core::fmt::Display::fmt(element, f), - Self::RollFork1(element) => ::core::fmt::Display::fmt(element, f), - Self::RollFork2(element) => ::core::fmt::Display::fmt(element, f), - Self::RollFork3(element) => ::core::fmt::Display::fmt(element, f), - Self::Rpc(element) => ::core::fmt::Display::fmt(element, f), - Self::RpcUrl(element) => ::core::fmt::Display::fmt(element, f), - Self::RpcUrlStructs(element) => ::core::fmt::Display::fmt(element, f), - Self::RpcUrls(element) => ::core::fmt::Display::fmt(element, f), - Self::SelectFork(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeAddress0(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeAddress1(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeBool0(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeBool1(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeBytes0(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeBytes1(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeBytes320(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeBytes321(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeInt0(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeInt1(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeJson(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeString0(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeString1(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeUint0(element) => ::core::fmt::Display::fmt(element, f), - Self::SerializeUint1(element) => ::core::fmt::Display::fmt(element, f), - Self::SetEnv(element) => ::core::fmt::Display::fmt(element, f), - Self::SetNonce(element) => ::core::fmt::Display::fmt(element, f), - Self::SetNonceUnsafe(element) => ::core::fmt::Display::fmt(element, f), - Self::Sign0(element) => ::core::fmt::Display::fmt(element, f), - Self::Sign1(element) => ::core::fmt::Display::fmt(element, f), - Self::Skip(element) => ::core::fmt::Display::fmt(element, f), - Self::Sleep(element) => ::core::fmt::Display::fmt(element, f), - Self::Snapshot(element) => ::core::fmt::Display::fmt(element, f), - Self::StartBroadcast0(element) => ::core::fmt::Display::fmt(element, f), - Self::StartBroadcast1(element) => ::core::fmt::Display::fmt(element, f), - Self::StartBroadcast2(element) => ::core::fmt::Display::fmt(element, f), - Self::StartMappingRecording(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::StartPrank0(element) => ::core::fmt::Display::fmt(element, f), - Self::StartPrank1(element) => ::core::fmt::Display::fmt(element, f), - Self::StartStateDiffRecording(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::StopAndReturnStateDiff(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::StopBroadcast(element) => ::core::fmt::Display::fmt(element, f), - Self::StopMappingRecording(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::StopPrank(element) => ::core::fmt::Display::fmt(element, f), - Self::Store(element) => ::core::fmt::Display::fmt(element, f), - Self::ToString0(element) => ::core::fmt::Display::fmt(element, f), - Self::ToString1(element) => ::core::fmt::Display::fmt(element, f), - Self::ToString2(element) => ::core::fmt::Display::fmt(element, f), - Self::ToString3(element) => ::core::fmt::Display::fmt(element, f), - Self::ToString4(element) => ::core::fmt::Display::fmt(element, f), - Self::ToString5(element) => ::core::fmt::Display::fmt(element, f), - Self::Transact0(element) => ::core::fmt::Display::fmt(element, f), - Self::Transact1(element) => ::core::fmt::Display::fmt(element, f), - Self::TryFfi(element) => ::core::fmt::Display::fmt(element, f), - Self::TxGasPrice(element) => ::core::fmt::Display::fmt(element, f), - Self::UnixTime(element) => ::core::fmt::Display::fmt(element, f), - Self::Warp(element) => ::core::fmt::Display::fmt(element, f), - Self::WriteFile(element) => ::core::fmt::Display::fmt(element, f), - Self::WriteFileBinary(element) => ::core::fmt::Display::fmt(element, f), - Self::WriteJson0(element) => ::core::fmt::Display::fmt(element, f), - Self::WriteJson1(element) => ::core::fmt::Display::fmt(element, f), - Self::WriteLine(element) => ::core::fmt::Display::fmt(element, f), - } - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: AccessesCall) -> Self { - Self::Accesses(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ActiveForkCall) -> Self { - Self::ActiveFork(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: AddrCall) -> Self { - Self::Addr(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: AllowCheatcodesCall) -> Self { - Self::AllowCheatcodes(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: AssumeCall) -> Self { - Self::Assume(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Breakpoint0Call) -> Self { - Self::Breakpoint0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Breakpoint1Call) -> Self { - Self::Breakpoint1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Broadcast0Call) -> Self { - Self::Broadcast0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Broadcast1Call) -> Self { - Self::Broadcast1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Broadcast2Call) -> Self { - Self::Broadcast2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ChainIdCall) -> Self { - Self::ChainId(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ClearMockedCallsCall) -> Self { - Self::ClearMockedCalls(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CloseFileCall) -> Self { - Self::CloseFile(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CoinbaseCall) -> Self { - Self::Coinbase(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CoolCall) -> Self { - Self::Cool(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CopyFileCall) -> Self { - Self::CopyFile(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateDirCall) -> Self { - Self::CreateDir(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateFork1Call) -> Self { - Self::CreateFork1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateFork2Call) -> Self { - Self::CreateFork2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateFork0Call) -> Self { - Self::CreateFork0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateSelectFork1Call) -> Self { - Self::CreateSelectFork1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateSelectFork2Call) -> Self { - Self::CreateSelectFork2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateSelectFork0Call) -> Self { - Self::CreateSelectFork0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateWallet0Call) -> Self { - Self::CreateWallet0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateWallet1Call) -> Self { - Self::CreateWallet1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: CreateWallet2Call) -> Self { - Self::CreateWallet2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: DealCall) -> Self { - Self::Deal(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: DeriveKey0Call) -> Self { - Self::DeriveKey0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: DeriveKey1Call) -> Self { - Self::DeriveKey1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: DeriveKey2Call) -> Self { - Self::DeriveKey2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: DeriveKey3Call) -> Self { - Self::DeriveKey3(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: DifficultyCall) -> Self { - Self::Difficulty(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvAddress0Call) -> Self { - Self::EnvAddress0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvAddress1Call) -> Self { - Self::EnvAddress1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvBool0Call) -> Self { - Self::EnvBool0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvBool1Call) -> Self { - Self::EnvBool1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvBytes0Call) -> Self { - Self::EnvBytes0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvBytes1Call) -> Self { - Self::EnvBytes1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvBytes320Call) -> Self { - Self::EnvBytes320(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvBytes321Call) -> Self { - Self::EnvBytes321(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvInt0Call) -> Self { - Self::EnvInt0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvInt1Call) -> Self { - Self::EnvInt1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr0Call) -> Self { - Self::EnvOr0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr1Call) -> Self { - Self::EnvOr1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr2Call) -> Self { - Self::EnvOr2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr3Call) -> Self { - Self::EnvOr3(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr4Call) -> Self { - Self::EnvOr4(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr5Call) -> Self { - Self::EnvOr5(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr6Call) -> Self { - Self::EnvOr6(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr7Call) -> Self { - Self::EnvOr7(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr8Call) -> Self { - Self::EnvOr8(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr9Call) -> Self { - Self::EnvOr9(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr10Call) -> Self { - Self::EnvOr10(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr11Call) -> Self { - Self::EnvOr11(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr12Call) -> Self { - Self::EnvOr12(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvOr13Call) -> Self { - Self::EnvOr13(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvString0Call) -> Self { - Self::EnvString0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvString1Call) -> Self { - Self::EnvString1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvUint0Call) -> Self { - Self::EnvUint0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EnvUint1Call) -> Self { - Self::EnvUint1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EtchCall) -> Self { - Self::Etch(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: EthGetLogsCall) -> Self { - Self::EthGetLogs(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExistsCall) -> Self { - Self::Exists(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCall0Call) -> Self { - Self::ExpectCall0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCall1Call) -> Self { - Self::ExpectCall1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCall2Call) -> Self { - Self::ExpectCall2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCall3Call) -> Self { - Self::ExpectCall3(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCall4Call) -> Self { - Self::ExpectCall4(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCall5Call) -> Self { - Self::ExpectCall5(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCallMinGas0Call) -> Self { - Self::ExpectCallMinGas0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectCallMinGas1Call) -> Self { - Self::ExpectCallMinGas1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectEmit0Call) -> Self { - Self::ExpectEmit0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectEmit1Call) -> Self { - Self::ExpectEmit1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectEmit2Call) -> Self { - Self::ExpectEmit2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectEmit3Call) -> Self { - Self::ExpectEmit3(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectRevert0Call) -> Self { - Self::ExpectRevert0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectRevert1Call) -> Self { - Self::ExpectRevert1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectRevert2Call) -> Self { - Self::ExpectRevert2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectSafeMemoryCall) -> Self { - Self::ExpectSafeMemory(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ExpectSafeMemoryCallCall) -> Self { - Self::ExpectSafeMemoryCall(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: FeeCall) -> Self { - Self::Fee(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: FfiCall) -> Self { - Self::Ffi(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: FsMetadataCall) -> Self { - Self::FsMetadata(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetCodeCall) -> Self { - Self::GetCode(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetDeployedCodeCall) -> Self { - Self::GetDeployedCode(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetLabelCall) -> Self { - Self::GetLabel(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetMappingKeyAndParentOfCall) -> Self { - Self::GetMappingKeyAndParentOf(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetMappingLengthCall) -> Self { - Self::GetMappingLength(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetMappingSlotAtCall) -> Self { - Self::GetMappingSlotAt(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetNonce0Call) -> Self { - Self::GetNonce0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetNonce1Call) -> Self { - Self::GetNonce1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: GetRecordedLogsCall) -> Self { - Self::GetRecordedLogs(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: IsDirCall) -> Self { - Self::IsDir(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: IsFileCall) -> Self { - Self::IsFile(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: IsPersistentCall) -> Self { - Self::IsPersistent(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: KeyExistsCall) -> Self { - Self::KeyExists(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: LabelCall) -> Self { - Self::Label(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: LoadCall) -> Self { - Self::Load(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MakePersistent0Call) -> Self { - Self::MakePersistent0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MakePersistent2Call) -> Self { - Self::MakePersistent2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MakePersistent3Call) -> Self { - Self::MakePersistent3(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MakePersistent1Call) -> Self { - Self::MakePersistent1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MockCall0Call) -> Self { - Self::MockCall0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MockCall1Call) -> Self { - Self::MockCall1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MockCallRevert0Call) -> Self { - Self::MockCallRevert0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: MockCallRevert1Call) -> Self { - Self::MockCallRevert1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: OpenFileCall) -> Self { - Self::OpenFile(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseAddressCall) -> Self { - Self::ParseAddress(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseBoolCall) -> Self { - Self::ParseBool(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseBytesCall) -> Self { - Self::ParseBytes(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseBytes32Call) -> Self { - Self::ParseBytes32(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseIntCall) -> Self { - Self::ParseInt(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJson0Call) -> Self { - Self::ParseJson0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJson1Call) -> Self { - Self::ParseJson1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonAddressCall) -> Self { - Self::ParseJsonAddress(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonAddressArrayCall) -> Self { - Self::ParseJsonAddressArray(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonBoolCall) -> Self { - Self::ParseJsonBool(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonBoolArrayCall) -> Self { - Self::ParseJsonBoolArray(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonBytesCall) -> Self { - Self::ParseJsonBytes(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonBytes32Call) -> Self { - Self::ParseJsonBytes32(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonBytes32ArrayCall) -> Self { - Self::ParseJsonBytes32Array(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonBytesArrayCall) -> Self { - Self::ParseJsonBytesArray(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonIntCall) -> Self { - Self::ParseJsonInt(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonIntArrayCall) -> Self { - Self::ParseJsonIntArray(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonKeysCall) -> Self { - Self::ParseJsonKeys(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonStringCall) -> Self { - Self::ParseJsonString(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonStringArrayCall) -> Self { - Self::ParseJsonStringArray(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonUintCall) -> Self { - Self::ParseJsonUint(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseJsonUintArrayCall) -> Self { - Self::ParseJsonUintArray(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ParseUintCall) -> Self { - Self::ParseUint(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: PauseGasMeteringCall) -> Self { - Self::PauseGasMetering(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Prank0Call) -> Self { - Self::Prank0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Prank1Call) -> Self { - Self::Prank1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: PrevrandaoCall) -> Self { - Self::Prevrandao(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ProjectRootCall) -> Self { - Self::ProjectRoot(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadCallersCall) -> Self { - Self::ReadCallers(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadDir0Call) -> Self { - Self::ReadDir0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadDir1Call) -> Self { - Self::ReadDir1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadDir2Call) -> Self { - Self::ReadDir2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadFileCall) -> Self { - Self::ReadFile(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadFileBinaryCall) -> Self { - Self::ReadFileBinary(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadLineCall) -> Self { - Self::ReadLine(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ReadLinkCall) -> Self { - Self::ReadLink(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RecordCall) -> Self { - Self::Record(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RecordLogsCall) -> Self { - Self::RecordLogs(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RememberKeyCall) -> Self { - Self::RememberKey(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RemoveDirCall) -> Self { - Self::RemoveDir(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RemoveFileCall) -> Self { - Self::RemoveFile(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ResetNonceCall) -> Self { - Self::ResetNonce(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ResumeGasMeteringCall) -> Self { - Self::ResumeGasMetering(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RevertToCall) -> Self { - Self::RevertTo(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RevokePersistent0Call) -> Self { - Self::RevokePersistent0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RevokePersistent1Call) -> Self { - Self::RevokePersistent1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RollCall) -> Self { - Self::Roll(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RollFork0Call) -> Self { - Self::RollFork0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RollFork1Call) -> Self { - Self::RollFork1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RollFork2Call) -> Self { - Self::RollFork2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RollFork3Call) -> Self { - Self::RollFork3(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RpcCall) -> Self { - Self::Rpc(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RpcUrlCall) -> Self { - Self::RpcUrl(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RpcUrlStructsCall) -> Self { - Self::RpcUrlStructs(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: RpcUrlsCall) -> Self { - Self::RpcUrls(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SelectForkCall) -> Self { - Self::SelectFork(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeAddress0Call) -> Self { - Self::SerializeAddress0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeAddress1Call) -> Self { - Self::SerializeAddress1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeBool0Call) -> Self { - Self::SerializeBool0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeBool1Call) -> Self { - Self::SerializeBool1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeBytes0Call) -> Self { - Self::SerializeBytes0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeBytes1Call) -> Self { - Self::SerializeBytes1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeBytes320Call) -> Self { - Self::SerializeBytes320(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeBytes321Call) -> Self { - Self::SerializeBytes321(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeInt0Call) -> Self { - Self::SerializeInt0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeInt1Call) -> Self { - Self::SerializeInt1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeJsonCall) -> Self { - Self::SerializeJson(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeString0Call) -> Self { - Self::SerializeString0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeString1Call) -> Self { - Self::SerializeString1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeUint0Call) -> Self { - Self::SerializeUint0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SerializeUint1Call) -> Self { - Self::SerializeUint1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SetEnvCall) -> Self { - Self::SetEnv(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SetNonceCall) -> Self { - Self::SetNonce(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SetNonceUnsafeCall) -> Self { - Self::SetNonceUnsafe(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Sign0Call) -> Self { - Self::Sign0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Sign1Call) -> Self { - Self::Sign1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SkipCall) -> Self { - Self::Skip(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SleepCall) -> Self { - Self::Sleep(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: SnapshotCall) -> Self { - Self::Snapshot(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StartBroadcast0Call) -> Self { - Self::StartBroadcast0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StartBroadcast1Call) -> Self { - Self::StartBroadcast1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StartBroadcast2Call) -> Self { - Self::StartBroadcast2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StartMappingRecordingCall) -> Self { - Self::StartMappingRecording(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StartPrank0Call) -> Self { - Self::StartPrank0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StartPrank1Call) -> Self { - Self::StartPrank1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StartStateDiffRecordingCall) -> Self { - Self::StartStateDiffRecording(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StopAndReturnStateDiffCall) -> Self { - Self::StopAndReturnStateDiff(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StopBroadcastCall) -> Self { - Self::StopBroadcast(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StopMappingRecordingCall) -> Self { - Self::StopMappingRecording(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StopPrankCall) -> Self { - Self::StopPrank(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: StoreCall) -> Self { - Self::Store(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ToString0Call) -> Self { - Self::ToString0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ToString1Call) -> Self { - Self::ToString1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ToString2Call) -> Self { - Self::ToString2(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ToString3Call) -> Self { - Self::ToString3(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ToString4Call) -> Self { - Self::ToString4(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: ToString5Call) -> Self { - Self::ToString5(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Transact0Call) -> Self { - Self::Transact0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: Transact1Call) -> Self { - Self::Transact1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: TryFfiCall) -> Self { - Self::TryFfi(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: TxGasPriceCall) -> Self { - Self::TxGasPrice(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: UnixTimeCall) -> Self { - Self::UnixTime(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: WarpCall) -> Self { - Self::Warp(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: WriteFileCall) -> Self { - Self::WriteFile(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: WriteFileBinaryCall) -> Self { - Self::WriteFileBinary(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: WriteJson0Call) -> Self { - Self::WriteJson0(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: WriteJson1Call) -> Self { - Self::WriteJson1(value) - } - } - impl ::core::convert::From for HEVMCalls { - fn from(value: WriteLineCall) -> Self { - Self::WriteLine(value) - } - } - ///Container type for all return fields from the `accesses` function with signature `accesses(address)` and selector `0x65bc9481` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct AccessesReturn( - pub ::std::vec::Vec<[u8; 32]>, - pub ::std::vec::Vec<[u8; 32]>, - ); - ///Container type for all return fields from the `activeFork` function with signature `activeFork()` and selector `0x2f103f22` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ActiveForkReturn(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `addr` function with signature `addr(uint256)` and selector `0xffa18649` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct AddrReturn(pub ::ethers_core::types::Address); - ///Container type for all return fields from the `createFork` function with signature `createFork(string,uint256)` and selector `0x6ba3ba2b` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateFork1Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `createFork` function with signature `createFork(string,bytes32)` and selector `0x7ca29682` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateFork2Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `createFork` function with signature `createFork(string)` and selector `0x31ba3498` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateFork0Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `createSelectFork` function with signature `createSelectFork(string,uint256)` and selector `0x71ee464d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateSelectFork1Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `createSelectFork` function with signature `createSelectFork(string,bytes32)` and selector `0x84d52b7a` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateSelectFork2Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `createSelectFork` function with signature `createSelectFork(string)` and selector `0x98680034` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateSelectFork0Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `createWallet` function with signature `createWallet(string)` and selector `0x7404f1d2` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateWallet0Return( - pub ( - ::ethers_core::types::Address, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - ); - ///Container type for all return fields from the `createWallet` function with signature `createWallet(uint256)` and selector `0x7a675bb6` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateWallet1Return( - pub ( - ::ethers_core::types::Address, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - ); - ///Container type for all return fields from the `createWallet` function with signature `createWallet(uint256,string)` and selector `0xed7c5462` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct CreateWallet2Return( - pub ( - ::ethers_core::types::Address, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - ); - ///Container type for all return fields from the `deriveKey` function with signature `deriveKey(string,uint32)` and selector `0x6229498b` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct DeriveKey0Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `deriveKey` function with signature `deriveKey(string,string,uint32)` and selector `0x6bcb2c1b` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct DeriveKey1Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `deriveKey` function with signature `deriveKey(string,uint32,string)` and selector `0x32c8176d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct DeriveKey2Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `deriveKey` function with signature `deriveKey(string,string,uint32,string)` and selector `0x29233b1f` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct DeriveKey3Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `envAddress` function with signature `envAddress(string)` and selector `0x350d56bf` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvAddress0Return(pub ::ethers_core::types::Address); - ///Container type for all return fields from the `envAddress` function with signature `envAddress(string,string)` and selector `0xad31b9fa` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvAddress1Return(pub ::std::vec::Vec<::ethers_core::types::Address>); - ///Container type for all return fields from the `envBool` function with signature `envBool(string)` and selector `0x7ed1ec7d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvBool0Return(pub bool); - ///Container type for all return fields from the `envBool` function with signature `envBool(string,string)` and selector `0xaaaddeaf` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvBool1Return(pub ::std::vec::Vec); - ///Container type for all return fields from the `envBytes` function with signature `envBytes(string)` and selector `0x4d7baf06` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvBytes0Return(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `envBytes` function with signature `envBytes(string,string)` and selector `0xddc2651b` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvBytes1Return(pub ::std::vec::Vec<::ethers_core::types::Bytes>); - ///Container type for all return fields from the `envBytes32` function with signature `envBytes32(string)` and selector `0x97949042` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvBytes320Return(pub [u8; 32]); - ///Container type for all return fields from the `envBytes32` function with signature `envBytes32(string,string)` and selector `0x5af231c1` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvBytes321Return(pub ::std::vec::Vec<[u8; 32]>); - ///Container type for all return fields from the `envInt` function with signature `envInt(string)` and selector `0x892a0c61` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvInt0Return(pub ::ethers_core::types::I256); - ///Container type for all return fields from the `envInt` function with signature `envInt(string,string)` and selector `0x42181150` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvInt1Return(pub ::std::vec::Vec<::ethers_core::types::I256>); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,bool)` and selector `0x4777f3cf` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr0Return(pub bool); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,uint256)` and selector `0x5e97348f` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr1Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,int256)` and selector `0xbbcb713e` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr2Return(pub ::ethers_core::types::I256); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,address)` and selector `0x561fe540` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr3Return(pub ::ethers_core::types::Address); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,bytes32)` and selector `0xb4a85892` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr4Return(pub [u8; 32]); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string)` and selector `0xd145736c` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr5Return(pub ::std::string::String); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,bytes)` and selector `0xb3e47705` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr6Return(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string,bool[])` and selector `0xeb85e83b` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr7Return(pub ::std::vec::Vec); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string,uint256[])` and selector `0x74318528` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr8Return(pub ::std::vec::Vec<::ethers_core::types::U256>); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string,int256[])` and selector `0x4700d74b` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr9Return(pub ::std::vec::Vec<::ethers_core::types::I256>); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string,address[])` and selector `0xc74e9deb` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr10Return(pub ::std::vec::Vec<::ethers_core::types::Address>); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string,bytes32[])` and selector `0x2281f367` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr11Return(pub ::std::vec::Vec<[u8; 32]>); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string,string[])` and selector `0x859216bc` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr12Return(pub ::std::vec::Vec<::std::string::String>); - ///Container type for all return fields from the `envOr` function with signature `envOr(string,string,bytes[])` and selector `0x64bc3e64` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvOr13Return(pub ::std::vec::Vec<::ethers_core::types::Bytes>); - ///Container type for all return fields from the `envString` function with signature `envString(string)` and selector `0xf877cb19` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvString0Return(pub ::std::string::String); - ///Container type for all return fields from the `envString` function with signature `envString(string,string)` and selector `0x14b02bc9` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvString1Return(pub ::std::vec::Vec<::std::string::String>); - ///Container type for all return fields from the `envUint` function with signature `envUint(string)` and selector `0xc1978d1f` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvUint0Return(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `envUint` function with signature `envUint(string,string)` and selector `0xf3dec099` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EnvUint1Return(pub ::std::vec::Vec<::ethers_core::types::U256>); - ///Container type for all return fields from the `eth_getLogs` function with signature `eth_getLogs(uint256,uint256,address,bytes32[])` and selector `0x35e1349b` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EthGetLogsReturn( - pub ::std::vec::Vec< - ( - ::ethers_core::types::Address, - ::std::vec::Vec<[u8; 32]>, - ::ethers_core::types::Bytes, - ::ethers_core::types::U256, - [u8; 32], - ::ethers_core::types::U256, - [u8; 32], - ::ethers_core::types::U256, - bool, - ), - >, - ); - ///Container type for all return fields from the `exists` function with signature `exists(string)` and selector `0x261a323e` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ExistsReturn(pub bool); - ///Container type for all return fields from the `ffi` function with signature `ffi(string[])` and selector `0x89160467` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct FfiReturn(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `fsMetadata` function with signature `fsMetadata(string)` and selector `0xaf368a08` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct FsMetadataReturn( - pub ( - bool, - bool, - ::ethers_core::types::U256, - bool, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ), - ); - ///Container type for all return fields from the `getLabel` function with signature `getLabel(address)` and selector `0x28a249b0` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct GetLabelReturn(pub ::std::string::String); - ///Container type for all return fields from the `getNonce` function with signature `getNonce((address,uint256,uint256,uint256))` and selector `0xa5748aad` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct GetNonce0Return(pub u64); - ///Container type for all return fields from the `getRecordedLogs` function with signature `getRecordedLogs()` and selector `0x191553a4` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct GetRecordedLogsReturn( - pub ::std::vec::Vec<(::std::vec::Vec<[u8; 32]>, ::ethers_core::types::Bytes)>, - ); - ///Container type for all return fields from the `isDir` function with signature `isDir(string)` and selector `0x7d15d019` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct IsDirReturn(pub bool); - ///Container type for all return fields from the `isFile` function with signature `isFile(string)` and selector `0xe0eb04d4` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct IsFileReturn(pub bool); - ///Container type for all return fields from the `isPersistent` function with signature `isPersistent(address)` and selector `0xd92d8efd` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct IsPersistentReturn(pub bool); - ///Container type for all return fields from the `keyExists` function with signature `keyExists(string,string)` and selector `0x528a683c` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct KeyExistsReturn(pub bool); - ///Container type for all return fields from the `load` function with signature `load(address,bytes32)` and selector `0x667f9d70` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct LoadReturn(pub [u8; 32]); - ///Container type for all return fields from the `parseAddress` function with signature `parseAddress(string)` and selector `0xc6ce059d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseAddressReturn(pub ::ethers_core::types::Address); - ///Container type for all return fields from the `parseBool` function with signature `parseBool(string)` and selector `0x974ef924` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseBoolReturn(pub bool); - ///Container type for all return fields from the `parseBytes` function with signature `parseBytes(string)` and selector `0x8f5d232d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseBytesReturn(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `parseBytes32` function with signature `parseBytes32(string)` and selector `0x087e6e81` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseBytes32Return(pub [u8; 32]); - ///Container type for all return fields from the `parseInt` function with signature `parseInt(string)` and selector `0x42346c5e` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseIntReturn(pub ::ethers_core::types::I256); - ///Container type for all return fields from the `parseJson` function with signature `parseJson(string)` and selector `0x6a82600a` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJson0Return(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `parseJson` function with signature `parseJson(string,string)` and selector `0x85940ef1` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJson1Return(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `parseJsonAddress` function with signature `parseJsonAddress(string,string)` and selector `0x1e19e657` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonAddressReturn(pub ::ethers_core::types::Address); - ///Container type for all return fields from the `parseJsonAddressArray` function with signature `parseJsonAddressArray(string,string)` and selector `0x2fce7883` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonAddressArrayReturn( - pub ::std::vec::Vec<::ethers_core::types::Address>, - ); - ///Container type for all return fields from the `parseJsonBool` function with signature `parseJsonBool(string,string)` and selector `0x9f86dc91` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonBoolReturn(pub bool); - ///Container type for all return fields from the `parseJsonBoolArray` function with signature `parseJsonBoolArray(string,string)` and selector `0x91f3b94f` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonBoolArrayReturn(pub ::std::vec::Vec); - ///Container type for all return fields from the `parseJsonBytes` function with signature `parseJsonBytes(string,string)` and selector `0xfd921be8` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonBytesReturn(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `parseJsonBytes32` function with signature `parseJsonBytes32(string,string)` and selector `0x1777e59d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonBytes32Return(pub [u8; 32]); - ///Container type for all return fields from the `parseJsonBytes32Array` function with signature `parseJsonBytes32Array(string,string)` and selector `0x91c75bc3` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonBytes32ArrayReturn(pub ::std::vec::Vec<[u8; 32]>); - ///Container type for all return fields from the `parseJsonBytesArray` function with signature `parseJsonBytesArray(string,string)` and selector `0x6631aa99` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonBytesArrayReturn( - pub ::std::vec::Vec<::ethers_core::types::Bytes>, - ); - ///Container type for all return fields from the `parseJsonInt` function with signature `parseJsonInt(string,string)` and selector `0x7b048ccd` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonIntReturn(pub ::ethers_core::types::I256); - ///Container type for all return fields from the `parseJsonIntArray` function with signature `parseJsonIntArray(string,string)` and selector `0x9983c28a` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonIntArrayReturn(pub ::std::vec::Vec<::ethers_core::types::I256>); - ///Container type for all return fields from the `parseJsonKeys` function with signature `parseJsonKeys(string,string)` and selector `0x213e4198` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonKeysReturn(pub ::std::vec::Vec<::std::string::String>); - ///Container type for all return fields from the `parseJsonString` function with signature `parseJsonString(string,string)` and selector `0x49c4fac8` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonStringReturn(pub ::std::string::String); - ///Container type for all return fields from the `parseJsonStringArray` function with signature `parseJsonStringArray(string,string)` and selector `0x498fdcf4` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonStringArrayReturn(pub ::std::vec::Vec<::std::string::String>); - ///Container type for all return fields from the `parseJsonUint` function with signature `parseJsonUint(string,string)` and selector `0xaddde2b6` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonUintReturn(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `parseJsonUintArray` function with signature `parseJsonUintArray(string,string)` and selector `0x522074ab` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseJsonUintArrayReturn(pub ::std::vec::Vec<::ethers_core::types::U256>); - ///Container type for all return fields from the `parseUint` function with signature `parseUint(string)` and selector `0xfa91454d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ParseUintReturn(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `projectRoot` function with signature `projectRoot()` and selector `0xd930a0e6` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ProjectRootReturn(pub ::std::string::String); - ///Container type for all return fields from the `readCallers` function with signature `readCallers()` and selector `0x4ad0bac9` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadCallersReturn( - pub ::ethers_core::types::U256, - pub ::ethers_core::types::Address, - pub ::ethers_core::types::Address, - ); - ///Container type for all return fields from the `readDir` function with signature `readDir(string)` and selector `0xc4bc59e0` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadDir0Return( - pub ::std::vec::Vec< - (::std::string::String, ::std::string::String, u64, bool, bool), - >, - ); - ///Container type for all return fields from the `readDir` function with signature `readDir(string,uint64)` and selector `0x1497876c` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadDir1Return( - pub ::std::vec::Vec< - (::std::string::String, ::std::string::String, u64, bool, bool), - >, - ); - ///Container type for all return fields from the `readDir` function with signature `readDir(string,uint64,bool)` and selector `0x8102d70d` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadDir2Return( - pub ::std::vec::Vec< - (::std::string::String, ::std::string::String, u64, bool, bool), - >, - ); - ///Container type for all return fields from the `readFile` function with signature `readFile(string)` and selector `0x60f9bb11` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadFileReturn(pub ::std::string::String); - ///Container type for all return fields from the `readFileBinary` function with signature `readFileBinary(string)` and selector `0x16ed7bc4` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadFileBinaryReturn(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `readLine` function with signature `readLine(string)` and selector `0x70f55728` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadLineReturn(pub ::std::string::String); - ///Container type for all return fields from the `readLink` function with signature `readLink(string)` and selector `0x9f5684a2` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ReadLinkReturn(pub ::std::string::String); - ///Container type for all return fields from the `rememberKey` function with signature `rememberKey(uint256)` and selector `0x22100064` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct RememberKeyReturn(pub ::ethers_core::types::Address); - ///Container type for all return fields from the `revertTo` function with signature `revertTo(uint256)` and selector `0x44d7f0a4` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct RevertToReturn(pub bool); - ///Container type for all return fields from the `rpc` function with signature `rpc(string,string)` and selector `0x1206c8a8` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct RpcReturn(pub ::ethers_core::types::Bytes); - ///Container type for all return fields from the `rpcUrl` function with signature `rpcUrl(string)` and selector `0x975a6ce9` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct RpcUrlReturn(pub ::std::string::String); - ///Container type for all return fields from the `rpcUrlStructs` function with signature `rpcUrlStructs()` and selector `0x9d2ad72a` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct RpcUrlStructsReturn( - pub ::std::vec::Vec<(::std::string::String, ::std::string::String)>, - ); - ///Container type for all return fields from the `rpcUrls` function with signature `rpcUrls()` and selector `0xa85a8418` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct RpcUrlsReturn(pub ::std::vec::Vec<[::std::string::String; 2]>); - ///Container type for all return fields from the `serializeAddress` function with signature `serializeAddress(string,string,address)` and selector `0x972c6062` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeAddress0Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeAddress` function with signature `serializeAddress(string,string,address[])` and selector `0x1e356e1a` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeAddress1Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeBool` function with signature `serializeBool(string,string,bool)` and selector `0xac22e971` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeBool0Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeBool` function with signature `serializeBool(string,string,bool[])` and selector `0x92925aa1` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeBool1Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeBytes` function with signature `serializeBytes(string,string,bytes)` and selector `0xf21d52c7` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeBytes0Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeBytes` function with signature `serializeBytes(string,string,bytes[])` and selector `0x9884b232` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeBytes1Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeBytes32` function with signature `serializeBytes32(string,string,bytes32)` and selector `0x2d812b44` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeBytes320Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeBytes32` function with signature `serializeBytes32(string,string,bytes32[])` and selector `0x201e43e2` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeBytes321Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeInt` function with signature `serializeInt(string,string,int256)` and selector `0x3f33db60` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeInt0Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeInt` function with signature `serializeInt(string,string,int256[])` and selector `0x7676e127` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeInt1Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeJson` function with signature `serializeJson(string,string)` and selector `0x9b3358b0` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeJsonReturn(pub ::std::string::String); - ///Container type for all return fields from the `serializeString` function with signature `serializeString(string,string,string)` and selector `0x88da6d35` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeString0Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeString` function with signature `serializeString(string,string,string[])` and selector `0x561cd6f3` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeString1Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeUint` function with signature `serializeUint(string,string,uint256)` and selector `0x129e9002` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeUint0Return(pub ::std::string::String); - ///Container type for all return fields from the `serializeUint` function with signature `serializeUint(string,string,uint256[])` and selector `0xfee9a469` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SerializeUint1Return(pub ::std::string::String); - ///Container type for all return fields from the `sign` function with signature `sign(uint256,bytes32)` and selector `0xe341eaa4` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct Sign0Return(pub u8, pub [u8; 32], pub [u8; 32]); - ///Container type for all return fields from the `sign` function with signature `sign((address,uint256,uint256,uint256),bytes32)` and selector `0xb25c5a25` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct Sign1Return(pub u8, pub [u8; 32], pub [u8; 32]); - ///Container type for all return fields from the `snapshot` function with signature `snapshot()` and selector `0x9711715a` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct SnapshotReturn(pub ::ethers_core::types::U256); - ///Container type for all return fields from the `stopAndReturnStateDiff` function with signature `stopAndReturnStateDiff()` and selector `0xaa5cf90e` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct StopAndReturnStateDiffReturn( - pub ::std::vec::Vec< - ( - (::ethers_core::types::U256, ::ethers_core::types::U256), - ::ethers_core::types::U256, - ::ethers_core::types::Address, - ::ethers_core::types::Address, - bool, - ::ethers_core::types::U256, - ::ethers_core::types::U256, - ::ethers_core::types::Bytes, - ::ethers_core::types::U256, - ::ethers_core::types::Bytes, - bool, - ::std::vec::Vec< - ( - ::ethers_core::types::Address, - [u8; 32], - bool, - [u8; 32], - [u8; 32], - bool, - ), - >, - ), - >, - ); - ///Container type for all return fields from the `tryFfi` function with signature `tryFfi(string[])` and selector `0xf45c1ce7` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct TryFfiReturn( - pub (i32, ::ethers_core::types::Bytes, ::ethers_core::types::Bytes), - ); - ///Container type for all return fields from the `unixTime` function with signature `unixTime()` and selector `0x625387dc` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct UnixTimeReturn(pub ::ethers_core::types::U256); - ///`AccountAccess((uint256,uint256),uint256,address,address,bool,uint256,uint256,bytes,uint256,bytes,bool,(address,bytes32,bool,bytes32,bytes32,bool)[])` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct AccountAccess { - pub chain_info: ChainInfo, - pub kind: ::ethers_core::types::U256, - pub account: ::ethers_core::types::Address, - pub accessor: ::ethers_core::types::Address, - pub initialized: bool, - pub old_balance: ::ethers_core::types::U256, - pub new_balance: ::ethers_core::types::U256, - pub deployed_code: ::ethers_core::types::Bytes, - pub value: ::ethers_core::types::U256, - pub data: ::ethers_core::types::Bytes, - pub reverted: bool, - pub storage_accesses: ::std::vec::Vec, - } - ///`ChainInfo(uint256,uint256)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct ChainInfo { - pub fork_id: ::ethers_core::types::U256, - pub chain_id: ::ethers_core::types::U256, - } - ///`DirEntry(string,string,uint64,bool,bool)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct DirEntry { - pub error_message: ::std::string::String, - pub path: ::std::string::String, - pub depth: u64, - pub is_dir: bool, - pub is_symlink: bool, - } - ///`EthGetLogs(address,bytes32[],bytes,uint256,bytes32,uint256,bytes32,uint256,bool)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct EthGetLogs { - pub emitter: ::ethers_core::types::Address, - pub topics: ::std::vec::Vec<[u8; 32]>, - pub data: ::ethers_core::types::Bytes, - pub block_number: ::ethers_core::types::U256, - pub transaction_hash: [u8; 32], - pub transaction_index: ::ethers_core::types::U256, - pub block_hash: [u8; 32], - pub log_index: ::ethers_core::types::U256, - pub removed: bool, - } - ///`FfiResult(int32,bytes,bytes)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct FfiResult { - pub exit_code: i32, - pub stdout: ::ethers_core::types::Bytes, - pub stderr: ::ethers_core::types::Bytes, - } - ///`FsMetadata(bool,bool,uint256,bool,uint256,uint256,uint256)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct FsMetadata { - pub is_dir: bool, - pub is_symlink: bool, - pub length: ::ethers_core::types::U256, - pub read_only: bool, - pub modified: ::ethers_core::types::U256, - pub accessed: ::ethers_core::types::U256, - pub created: ::ethers_core::types::U256, - } - ///`Log(bytes32[],bytes)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct Log { - pub topics: ::std::vec::Vec<[u8; 32]>, - pub data: ::ethers_core::types::Bytes, - } - ///`Rpc(string,string)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct Rpc { - pub name: ::std::string::String, - pub url: ::std::string::String, - } - ///`StorageAccess(address,bytes32,bool,bytes32,bytes32,bool)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct StorageAccess { - pub account: ::ethers_core::types::Address, - pub slot: [u8; 32], - pub is_write: bool, - pub previous_value: [u8; 32], - pub new_value: [u8; 32], - pub reverted: bool, - } - ///`Wallet(address,uint256,uint256,uint256)` - #[derive( - Clone, - ::ethers_contract::EthAbiType, - ::ethers_contract::EthAbiCodec, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - pub struct Wallet { - pub addr: ::ethers_core::types::Address, - pub public_key_x: ::ethers_core::types::U256, - pub public_key_y: ::ethers_core::types::U256, - pub private_key: ::ethers_core::types::U256, - } -} diff --git a/crates/abi/src/bindings/mod.rs b/crates/abi/src/bindings/mod.rs index 52aa1655ecca7..11f8dfe6ba9df 100644 --- a/crates/abi/src/bindings/mod.rs +++ b/crates/abi/src/bindings/mod.rs @@ -5,4 +5,3 @@ //! These files may be overwritten by the codegen system at any time. pub mod console; pub mod hardhat_console; -pub mod hevm; diff --git a/crates/abi/src/lib.rs b/crates/abi/src/lib.rs index c5e0b4ed3ec01..3e0cc77cb0fbe 100644 --- a/crates/abi/src/lib.rs +++ b/crates/abi/src/lib.rs @@ -10,4 +10,4 @@ mod bindings; -pub use bindings::{console, hardhat_console, hevm}; +pub use bindings::{console, hardhat_console}; diff --git a/crates/cheatcodes/spec/Cargo.toml b/crates/cheatcodes/spec/Cargo.toml index 5f7ec0eb6c7cb..ae4ca21e06ec2 100644 --- a/crates/cheatcodes/spec/Cargo.toml +++ b/crates/cheatcodes/spec/Cargo.toml @@ -13,7 +13,7 @@ exclude.workspace = true [dependencies] foundry-macros.workspace = true -alloy-sol-types.workspace = true +alloy-sol-types = { workspace = true, features = ["json"] } serde.workspace = true # schema diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index b3c65e1fb031f..6a700c68da537 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -7,6 +7,8 @@ use alloy_sol_types::sol; use foundry_macros::Cheatcode; sol! { +#![sol(abi)] + // Cheatcodes are marked as view/pure/none using the following rules: // 0. A call's observable behaviour includes its return value, logs, reverts and state writes, // 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure` diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 13664b3e43643..f467d8981d8d9 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -19,7 +19,7 @@ foundry-config.workspace = true foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } -alloy-json-abi = { workspace = true } +alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true revm = { workspace = true, default-features = false, features = [ diff --git a/crates/evm/core/src/abi/mod.rs b/crates/evm/core/src/abi/mod.rs index d859747f39f0f..cc7c7287816ef 100644 --- a/crates/evm/core/src/abi/mod.rs +++ b/crates/evm/core/src/abi/mod.rs @@ -6,7 +6,6 @@ use std::collections::HashMap; pub use foundry_abi::{ console::{ConsoleEvents, CONSOLE_ABI}, hardhat_console::{HardhatConsoleCalls, HARDHATCONSOLE_ABI as HARDHAT_CONSOLE_ABI}, - hevm::HEVM_ABI, }; /// If the input starts with a known `hardhat/console.log` `uint` selector, then this will replace diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 657550c7d94bc..6d0d35705ec7c 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -20,7 +20,7 @@ foundry-evm-traces.workspace = true foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } -alloy-json-abi = { workspace = true } +alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 7edaedd94e0ff..64716809fcf3d 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -12,6 +12,7 @@ repository.workspace = true [dependencies] foundry-block-explorers.workspace = true +foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 43e42eba21d88..e9fddfd505b0a 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -5,9 +5,10 @@ use crate::{ use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function, JsonAbi as Abi}; use alloy_primitives::{Address, Selector, B256}; +use foundry_cheatcodes_spec::Vm; use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ - abi::{CONSOLE_ABI, HARDHAT_CONSOLE_ABI, HEVM_ABI}, + abi::{CONSOLE_ABI, HARDHAT_CONSOLE_ABI}, constants::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS, @@ -132,11 +133,9 @@ impl CallTraceDecoder { functions: HARDHAT_CONSOLE_ABI .functions() - .chain(HEVM_ABI.functions()) - .map(|func| { - let func = func.clone().to_alloy(); - (func.selector(), vec![func]) - }) + .map(|func| func.clone().to_alloy()) + .chain(Vm::abi::functions().into_values().flatten()) + .map(|func| (func.selector(), vec![func])) .collect(), events: CONSOLE_ABI From e38d8c611b916500890b7419d6785c75110654b8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 21 Nov 2023 18:33:25 +0100 Subject: [PATCH 0310/1963] chore: rewrite shanghai support check (#6356) * chore: rewrite shanghai support check * bump chains --- Cargo.lock | 4 +- Cargo.toml | 2 +- crates/forge/bin/cmd/script/mod.rs | 67 ++++++++++-------------------- 3 files changed, 26 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbe6bb71c88dd..2331165e9a244 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c18b3ecf1746f0eac255374bdf899dd217dd1b301e4a3f146592234243e1bc66" +checksum = "7e9249bbabebe77f78e6a8f1984f9cd6151bb3297e484bb073cfae7a6dbd9f22" dependencies = [ "num_enum", "serde", diff --git a/Cargo.toml b/Cargo.toml index 90f9fd7e81648..f220605354eeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,7 @@ alloy-json-abi = "0.4.1" alloy-sol-types = "0.4.1" syn-solidity = "0.4.1" -alloy-chains = "0.1.2" +alloy-chains = "0.1.3" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 0182d921b3c9c..e9ba8b4271a6f 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -6,7 +6,7 @@ use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueHint}; use dialoguer::Confirm; use ethers_core::types::{ - transaction::eip2718::TypedTransaction, Chain, Log, NameOrAddress, TransactionRequest, + transaction::eip2718::TypedTransaction, Log, NameOrAddress, TransactionRequest, }; use ethers_providers::{Http, Middleware}; use ethers_signers::LocalWallet; @@ -42,7 +42,7 @@ use foundry_config::{ value::{Dict, Map}, Metadata, Profile, Provider, }, - Config, + Config, NamedChain, }; use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, @@ -51,6 +51,7 @@ use foundry_evm::{ }; use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future; +use itertools::Itertools; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use yansi::Paint; @@ -68,16 +69,6 @@ mod sequence; pub mod transaction; mod verify; -/// List of Chains that support Shanghai. -static SHANGHAI_ENABLED_CHAINS: &[Chain] = &[ - Chain::Mainnet, - Chain::Goerli, - Chain::Sepolia, - Chain::OptimismGoerli, - Chain::OptimismSepolia, - Chain::BaseGoerli, -]; - // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(ScriptArgs, opts, evm_opts); @@ -212,7 +203,7 @@ pub struct ScriptArgs { // === impl ScriptArgs === impl ScriptArgs { - pub fn decode_traces( + fn decode_traces( &self, script_config: &ScriptConfig, result: &mut ScriptResult, @@ -288,7 +279,7 @@ impl ScriptArgs { Ok(returns) } - pub async fn show_traces( + async fn show_traces( &self, script_config: &ScriptConfig, decoder: &CallTraceDecoder, @@ -373,7 +364,7 @@ impl ScriptArgs { Ok(()) } - pub fn show_json(&self, script_config: &ScriptConfig, result: &ScriptResult) -> Result<()> { + fn show_json(&self, script_config: &ScriptConfig, result: &ScriptResult) -> Result<()> { let returns = self.get_returns(script_config, &result.returned)?; let console_logs = decode_console_logs(&result.logs); @@ -452,7 +443,7 @@ impl ScriptArgs { /// corresponding function by matching the selector, first 4 bytes in the calldata. /// /// Note: We assume that the `sig` is already stripped of its prefix, See [`ScriptArgs`] - pub fn get_method_and_calldata(&self, abi: &Abi) -> Result<(Function, Bytes)> { + fn get_method_and_calldata(&self, abi: &Abi) -> Result<(Function, Bytes)> { let (func, data) = if let Ok(func) = Function::parse(&self.sig) { ( abi.functions().find(|&abi_func| abi_func.selector() == func.selector()).wrap_err( @@ -622,10 +613,10 @@ pub struct ScriptResult { } #[derive(Serialize, Deserialize)] -pub struct JsonResult { - pub logs: Vec, - pub gas_used: u64, - pub returns: HashMap, +struct JsonResult { + logs: Vec, + gas_used: u64, + returns: HashMap, } #[derive(Serialize, Deserialize, Clone)] @@ -697,36 +688,24 @@ impl ScriptConfig { /// If not, warns the user. async fn check_shanghai_support(&self) -> Result<()> { let chain_ids = self.total_rpcs.iter().map(|rpc| async move { - if let Ok(provider) = ethers_providers::Provider::::try_from(rpc) { - match provider.get_chainid().await { - Ok(chain_id) => match TryInto::::try_into(chain_id) { - Ok(chain) => return Some((SHANGHAI_ENABLED_CHAINS.contains(&chain), chain)), - Err(_) => return None, - }, - Err(_) => return None, - } - } - None + let provider = ethers_providers::Provider::::try_from(rpc).ok()?; + let id = provider.get_chainid().await.ok()?; + let id_u64: u64 = id.try_into().ok()?; + NamedChain::try_from(id_u64).ok() }); - let chain_ids: Vec<_> = future::join_all(chain_ids).await.into_iter().flatten().collect(); - - let chain_id_unsupported = chain_ids.iter().any(|(supported, _)| !supported); - - // At least one chain ID is unsupported, therefore we print the message. - if chain_id_unsupported { + let chains = future::join_all(chain_ids).await; + let iter = chains.iter().flatten().map(|c| (c.supports_shanghai(), c)); + if iter.clone().any(|(s, _)| !s) { let msg = format!( - r#" + "\ EIP-3855 is not supported in one or more of the RPCs used. Unsupported Chain IDs: {}. Contracts deployed with a Solidity version equal or higher than 0.8.20 might not work properly. -For more information, please see https://eips.ethereum.org/EIPS/eip-3855"#, - chain_ids - .iter() - .filter(|(supported, _)| !supported) - .map(|(_, chain)| format!("{}", *chain as u64)) - .collect::>() - .join(", ") +For more information, please see https://eips.ethereum.org/EIPS/eip-3855", + iter.filter(|(supported, _)| !supported) + .map(|(_, chain)| *chain as u64) + .format(", ") ); shell::println(Paint::yellow(msg))?; } From 3afbc3332460a3c1fd9da3eeec7151c76912749f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 21 Nov 2023 21:24:25 +0100 Subject: [PATCH 0311/1963] style: ugly serialize impl (#6389) --- crates/evm/core/src/fork/cache.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index 42de2bd8af312..4e4aa80e38ac7 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -405,21 +405,10 @@ impl Serialize for JsonBlockCacheData { { let mut map = serializer.serialize_map(Some(4))?; - let meta = self.meta.read(); - map.serialize_entry("meta", &*meta)?; - drop(meta); - - let accounts = self.data.accounts.read(); - map.serialize_entry("accounts", &*accounts)?; - drop(accounts); - - let storage = self.data.storage.read(); - map.serialize_entry("storage", &*storage)?; - drop(storage); - - let block_hashes = self.data.block_hashes.read(); - map.serialize_entry("block_hashes", &*block_hashes)?; - drop(block_hashes); + map.serialize_entry("meta", &*self.meta.read())?; + map.serialize_entry("accounts", &*self.data.accounts.read())?; + map.serialize_entry("storage", &*self.data.storage.read())?; + map.serialize_entry("block_hashes", &*self.data.block_hashes.read())?; map.end() } From 067e658e567a735e5a911794a9b891e501a0f055 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 21 Nov 2023 21:34:50 +0100 Subject: [PATCH 0312/1963] chore: generate less sol! abi implementations (#6390) --- crates/cheatcodes/spec/src/vm.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 6a700c68da537..a9421d087daa8 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -7,8 +7,6 @@ use alloy_sol_types::sol; use foundry_macros::Cheatcode; sol! { -#![sol(abi)] - // Cheatcodes are marked as view/pure/none using the following rules: // 0. A call's observable behaviour includes its return value, logs, reverts and state writes, // 1. If you can influence a later call's observable behaviour, you're neither `view` nor `pure` @@ -18,6 +16,7 @@ sol! { /// Foundry cheatcodes interface. #[derive(Debug, Cheatcode)] // Keep this list small to avoid unnecessary bloat. +#[sol(abi)] interface Vm { // ======== Types ======== From f689fb87ad74d79d2d97dd46e028a5f4b2f492af Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 22 Nov 2023 02:11:25 +0400 Subject: [PATCH 0313/1963] Additional contracts serialization fix (#6391) * Add test * Change type of init_code * fmt --- crates/forge/bin/cmd/script/executor.rs | 2 +- crates/forge/bin/cmd/script/transaction.rs | 5 ++--- crates/forge/tests/cli/script.rs | 13 +++++++++++++ testdata/cheats/Broadcast.t.sol | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 4d8c4b33031b8..c4cff1304de24 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -172,7 +172,7 @@ impl ScriptArgs { return Some(AdditionalContract { opcode: node.kind(), address: node.trace.address, - init_code: node.trace.data.as_bytes().to_vec(), + init_code: node.trace.data.as_bytes().to_vec().into(), }) } None diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 74fe0a75d2975..091a2a9ac4082 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -1,7 +1,7 @@ use super::{artifacts::ArtifactInfo, ScriptResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use alloy_primitives::{Address, B256}; +use alloy_primitives::{Address, Bytes, B256}; use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{fmt::format_token_raw, RpcUrl, SELECTOR_LEN}; @@ -17,8 +17,7 @@ pub struct AdditionalContract { pub opcode: CallKind, #[serde(serialize_with = "wrapper::serialize_addr")] pub address: Address, - #[serde(with = "hex")] - pub init_code: Vec, + pub init_code: Bytes, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index c8bb085c13e43..da9c2f66a2f6a 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1075,3 +1075,16 @@ interface Interface {} cmd.arg("script").arg(script); assert!(cmd.stdout_lossy().contains("Script ran successfully.")); }); + +forgetest_async!(assert_can_resume_with_additional_contracts, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + + tester + .add_deployer(0) + .add_sig("ScriptAdditionalContracts", "run()") + .broadcast(ScriptOutcome::MissingWallet) + .load_private_keys(&[0]) + .await + .resume(ScriptOutcome::OkBroadcast); +}); diff --git a/testdata/cheats/Broadcast.t.sol b/testdata/cheats/Broadcast.t.sol index 2e3b0ea6abda0..d542c28c0e6c5 100644 --- a/testdata/cheats/Broadcast.t.sol +++ b/testdata/cheats/Broadcast.t.sol @@ -511,3 +511,20 @@ contract CheckOverrides is DSTest { vm.stopBroadcast(); } } + +contract Child {} + +contract Parent { + constructor() { + new Child(); + } +} + +contract ScriptAdditionalContracts is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function run() external { + vm.startBroadcast(); + new Parent(); + } +} From 5c137e8ac9165a070e36ff0eeb0382c2a2cf6637 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 22 Nov 2023 06:36:18 +0400 Subject: [PATCH 0314/1963] Fix multichain scripts with verify (#6395) --- crates/forge/bin/cmd/script/multi.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index e98f01f38685b..3f4c5ed842a5d 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -155,12 +155,8 @@ impl ScriptArgs { ) .await { - Ok(_) => { - if self.verify { - return sequence.verify_contracts(config, verify.clone()).await - } - Ok(()) - } + Ok(_) if self.verify => sequence.verify_contracts(config, verify.clone()).await, + Ok(_) => Ok(()), Err(err) => Err(err), }; results.push(result); From 06a68a3a77e3a8a1106d5f88348cda3d6dfaaa86 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 22 Nov 2023 11:57:49 +0100 Subject: [PATCH 0315/1963] fix: derive Inherit relative link properly (#6388) --- crates/doc/src/builder.rs | 27 +++++++++++++++++------ crates/doc/src/document.rs | 28 +++++++++++++++--------- crates/doc/src/writer/as_doc.rs | 38 +++++++++++++++++---------------- 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index b66644e2cd524..c4f68d8096661 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -180,8 +180,13 @@ impl DocBuilder { let relative_path = path.strip_prefix(&self.root)?.join(item.filename()); let target_path = self.config.out.join(Self::SRC).join(relative_path); let ident = item.source.ident(); - Ok(Document::new(path.clone(), target_path, from_library) - .with_content(DocumentContent::Single(item), ident)) + Ok(Document::new( + path.clone(), + target_path, + from_library, + self.config.out.clone(), + ) + .with_content(DocumentContent::Single(item), ident)) }) .collect::>>()?; @@ -207,8 +212,13 @@ impl DocBuilder { }; files.push( - Document::new(path.clone(), target_path, from_library) - .with_content(DocumentContent::Constants(consts), identity), + Document::new( + path.clone(), + target_path, + from_library, + self.config.out.clone(), + ) + .with_content(DocumentContent::Constants(consts), identity), ) } @@ -219,8 +229,13 @@ impl DocBuilder { let relative_path = path.strip_prefix(&self.root)?.join(filename); let target_path = self.config.out.join(Self::SRC).join(relative_path); files.push( - Document::new(path.clone(), target_path, from_library) - .with_content(DocumentContent::OverloadedFunctions(funcs), ident), + Document::new( + path.clone(), + target_path, + from_library, + self.config.out.clone(), + ) + .with_content(DocumentContent::OverloadedFunctions(funcs), ident), ); } } diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index 5b53a79bfce60..dcd54247e6ab3 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -19,20 +19,18 @@ pub struct Document { context: Mutex>, /// Whether the document is from external library. pub from_library: bool, -} - -/// The content of the document. -#[derive(Debug)] -pub enum DocumentContent { - Empty, - Single(ParseItem), - Constants(Vec), - OverloadedFunctions(Vec), + /// The target directory for the doc output. + pub out_target_dir: PathBuf, } impl Document { /// Create new instance of [Document]. - pub fn new(item_path: PathBuf, target_path: PathBuf, from_library: bool) -> Self { + pub fn new( + item_path: PathBuf, + target_path: PathBuf, + from_library: bool, + out_target_dir: PathBuf, + ) -> Self { Self { item_path, target_path, @@ -40,6 +38,7 @@ impl Document { item_content: String::default(), identity: String::default(), content: DocumentContent::Empty, + out_target_dir, context: Mutex::new(HashMap::default()), } } @@ -65,6 +64,15 @@ impl Document { } } +/// The content of the document. +#[derive(Debug)] +pub enum DocumentContent { + Empty, + Single(ParseItem), + Constants(Vec), + OverloadedFunctions(Vec), +} + /// Read the preprocessor output variant from document context. /// Returns [None] if there is no output. macro_rules! read_context { diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index abea15866e9ea..c62e2a106948b 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -127,32 +127,34 @@ impl AsDoc for Document { if !contract.base.is_empty() { writer.write_bold("Inherits:")?; + // Where all the source files are written to + // we need this to find the _relative_ paths + let src_target_dir = self.out_target_dir.join("src"); + let mut bases = vec![]; let linked = read_context!(self, CONTRACT_INHERITANCE_ID, ContractInheritance); for base in contract.base.iter() { let base_doc = base.as_doc()?; let base_ident = &base.name.identifiers.last().unwrap().name; - bases.push( - linked - .as_ref() - .and_then(|l| { - l.get(base_ident).map(|path| { - let path = Path::new("/").join( - path.strip_prefix("docs/src") - .ok() - .unwrap_or(path), - ); - Markdown::Link( - &base_doc, - &path.display().to_string(), - ) + + let link = linked + .as_ref() + .and_then(|link| { + link.get(base_ident).map(|path| { + let path = Path::new("/").join( + path.strip_prefix(&src_target_dir) + .ok() + .unwrap_or(path), + ); + Markdown::Link(&base_doc, &path.display().to_string()) .as_doc() - }) }) - .transpose()? - .unwrap_or(base_doc), - ) + }) + .transpose()? + .unwrap_or(base_doc); + + bases.push(link); } writer.writeln_raw(bases.join(", "))?; From 088f6f88527da244d5b1e91c72a1a965f511b5a3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 22 Nov 2023 12:02:38 +0100 Subject: [PATCH 0316/1963] chore: enable cancun hardfork (#6393) --- crates/anvil/src/hardfork.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index 82143c4fe4f36..42745fb80ce84 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -21,6 +21,7 @@ pub enum Hardfork { GrayGlacier, Paris, Shanghai, + Cancun, #[default] Latest, } @@ -44,6 +45,9 @@ impl Hardfork { Hardfork::GrayGlacier => 15050000, Hardfork::Paris => 15537394, Hardfork::Shanghai | Hardfork::Latest => 17034870, + + // TODO: set block number after activation + Hardfork::Cancun => unreachable!(), } } @@ -92,6 +96,10 @@ impl Hardfork { // update `next` when another fork block num is known ForkId { hash: ForkHash([0xc1, 0xfd, 0xf1, 0x81]), next: 0 } } + Hardfork::Cancun => { + // TODO: set fork hash once known + ForkId { hash: ForkHash([0xc1, 0xfd, 0xf1, 0x81]), next: 0 } + } } } } @@ -118,7 +126,7 @@ impl FromStr for Hardfork { "grayglacier" | "14" => Hardfork::GrayGlacier, "paris" | "merge" | "15" => Hardfork::Paris, "shanghai" | "16" => Hardfork::Shanghai, - // "cancun" | "17"=> Hardfork::Cancun, + "cancun" | "17" => Hardfork::Cancun, "latest" => Hardfork::Latest, _ => return Err(format!("Unknown hardfork {s}")), }; @@ -145,6 +153,9 @@ impl From for SpecId { Hardfork::GrayGlacier => SpecId::GRAY_GLACIER, Hardfork::Paris => SpecId::MERGE, Hardfork::Shanghai | Hardfork::Latest => SpecId::SHANGHAI, + + // TODO: switch to latest after activation + Hardfork::Cancun => SpecId::CANCUN, } } } From 77d26dff2f891630ce46321073392f982d114cfb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 22 Nov 2023 13:18:11 +0100 Subject: [PATCH 0317/1963] perf: dont record sharedmemory (#6398) --- crates/chisel/src/dispatcher.rs | 4 +--- crates/chisel/src/executor.rs | 5 ++--- crates/chisel/src/runner.rs | 6 +----- crates/debugger/src/lib.rs | 1 - crates/evm/core/src/debug.rs | 4 ++-- crates/evm/evm/src/executors/mod.rs | 4 ++-- crates/evm/evm/src/inspectors/chisel_state.rs | 6 +++--- crates/evm/evm/src/inspectors/debugger.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 5 ++--- crates/evm/traces/src/inspector.rs | 2 +- crates/evm/traces/src/lib.rs | 6 +++--- 11 files changed, 18 insertions(+), 27 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 26f13933b049a..b191d8dccad3e 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -420,9 +420,7 @@ impl ChiselDispatcher { i, i + 32 )), - Paint::cyan(hex::encode_prefixed( - &mem.context_memory()[i..i + 32] - )) + Paint::cyan(hex::encode_prefixed(&mem[i..i + 32])) ); }); } else { diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 6b97535ba8e0a..421c434effc74 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -223,11 +223,10 @@ impl SessionSource { // the file compiled correctly, thus the last stack item must be the memory offset of // the `bytes memory inspectoor` value let mut offset = stack.data().last().unwrap().to_ethers().as_usize(); - let mem = memory.context_memory(); - let mem_offset = &mem[offset..offset + 32]; + let mem_offset = &memory[offset..offset + 32]; let len = U256::try_from_be_slice(mem_offset).unwrap().to::(); offset += 32; - let data = &mem[offset..offset + len]; + let data = &memory[offset..offset + len]; // `tokens` is guaranteed to have the same length as the provided types let token = DynSolType::abi_decode(&ty, data).wrap_err("Could not decode inspected values")?; diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 86ed659fbd4b9..644c6ea96e12b 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -50,11 +50,7 @@ pub struct ChiselResult { /// Called address pub address: Option
, /// EVM State at the final instruction of the `run()` function - pub state: Option<( - revm::interpreter::Stack, - revm::interpreter::SharedMemory, - revm::interpreter::InstructionResult, - )>, + pub state: Option<(revm::interpreter::Stack, Vec, InstructionResult)>, } /// ChiselRunner implementation diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 4a74c302fedae..33bb342887013 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -920,7 +920,6 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let stack_space = Block::default() .title(format!("Memory (max expansion: {} bytes)", memory.len())) .borders(Borders::ALL); - let memory = memory.context_memory(); let max_i = memory.len() / 32; let min_len = format!("{:x}", max_i * 32).len(); diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 76bc7f3a55888..669b8292feff8 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,6 +1,6 @@ use crate::utils::CallKind; use alloy_primitives::{Address, U256}; -use revm::interpreter::{OpCode, SharedMemory}; +use revm::interpreter::OpCode; use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -114,7 +114,7 @@ pub struct DebugStep { /// Stack *prior* to running the associated opcode pub stack: Vec, /// Memory *prior* to running the associated opcode - pub memory: SharedMemory, + pub memory: Vec, /// Opcode to be executed pub instruction: Instruction, /// Optional bytes that are being pushed onto the stack diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 234757a907d80..f1dbd43c6279d 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -28,7 +28,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ db::{DatabaseCommit, DatabaseRef}, - interpreter::{return_ok, CreateScheme, InstructionResult, SharedMemory, Stack}, + interpreter::{return_ok, CreateScheme, InstructionResult, Stack}, primitives::{ BlockEnv, Bytecode, Env, ExecutionResult, Output, ResultAndState, SpecId, TransactTo, TxEnv, }, @@ -680,7 +680,7 @@ pub struct RawCallResult { /// The raw output of the execution pub out: Option, /// The chisel state - pub chisel_state: Option<(Stack, SharedMemory, InstructionResult)>, + pub chisel_state: Option<(Stack, Vec, InstructionResult)>, } impl Default for RawCallResult { diff --git a/crates/evm/evm/src/inspectors/chisel_state.rs b/crates/evm/evm/src/inspectors/chisel_state.rs index 6a32950b80fca..a4d3a1895f24c 100644 --- a/crates/evm/evm/src/inspectors/chisel_state.rs +++ b/crates/evm/evm/src/inspectors/chisel_state.rs @@ -1,5 +1,5 @@ use revm::{ - interpreter::{InstructionResult, Interpreter, SharedMemory, Stack}, + interpreter::{InstructionResult, Interpreter, Stack}, Database, Inspector, }; @@ -9,7 +9,7 @@ pub struct ChiselState { /// The PC of the final instruction pub final_pc: usize, /// The final state of the REPL contract call - pub state: Option<(Stack, SharedMemory, InstructionResult)>, + pub state: Option<(Stack, Vec, InstructionResult)>, } impl ChiselState { @@ -28,7 +28,7 @@ impl Inspector for ChiselState { if self.final_pc == interp.program_counter() - 1 { self.state = Some(( interp.stack().clone(), - interp.shared_memory.clone(), + interp.shared_memory.context_memory().to_vec(), interp.instruction_result, )) } diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index 27782ca474b03..bd3ca6b3e0de8 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -73,7 +73,7 @@ impl Inspector for Debugger { self.arena.arena[self.head].steps.push(DebugStep { pc, stack: interpreter.stack().data().clone(), - memory: interpreter.shared_memory.clone(), + memory: interpreter.shared_memory.context_memory().to_vec(), instruction: Instruction::OpCode(op), push_bytes, total_gas_used, diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 34795bca2de29..d72d2ef0eed55 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -10,8 +10,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ interpreter::{ - return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, SharedMemory, - Stack, + return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Stack, }, primitives::{BlockEnv, Env}, EVMData, Inspector, @@ -192,7 +191,7 @@ pub struct InspectorData { pub coverage: Option, pub cheatcodes: Option, pub script_wallets: Vec, - pub chisel_state: Option<(Stack, SharedMemory, InstructionResult)>, + pub chisel_state: Option<(Stack, Vec, InstructionResult)>, } /// An inspector that calls multiple inspectors in sequence. diff --git a/crates/evm/traces/src/inspector.rs b/crates/evm/traces/src/inspector.rs index 03f500edda762..09a6cbfdd259e 100644 --- a/crates/evm/traces/src/inspector.rs +++ b/crates/evm/traces/src/inspector.rs @@ -87,7 +87,7 @@ impl Tracer { op: OpCode(interp.current_opcode()), contract: interp.contract.address, stack: interp.stack.clone(), - memory: interp.shared_memory.clone(), + memory: interp.shared_memory.context_memory().to_vec(), gas: interp.gas.remaining(), gas_refund_counter: interp.gas.refunded() as u64, gas_cost: 0, diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index d9da3699150ad..3fdf14f6cdf45 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -14,7 +14,7 @@ use foundry_evm_core::{constants::CHEATCODE_ADDRESS, debug::Instruction, utils:: use foundry_utils::types::ToEthers; use hashbrown::HashMap; use itertools::Itertools; -use revm::interpreter::{opcode, CallContext, InstructionResult, SharedMemory, Stack}; +use revm::interpreter::{opcode, CallContext, InstructionResult, Stack}; use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashSet}, @@ -390,7 +390,7 @@ pub struct CallTraceStep { /// Stack before step execution pub stack: Stack, /// Memory before step execution - pub memory: SharedMemory, + pub memory: Vec, /// Remaining gas before step execution pub gas: u64, /// Gas refund counter before step execution @@ -412,7 +412,7 @@ impl From<&CallTraceStep> for StructLog { error: step.error.clone(), gas: step.gas, gas_cost: step.gas_cost, - memory: Some(convert_memory(step.memory.context_memory())), + memory: Some(convert_memory(&step.memory)), op: step.op.to_string(), pc: step.pc as u64, refund_counter: if step.gas_refund_counter > 0 { From b8c50d7bb4822c27e9c5455de75b60dbcd63fded Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:27:39 +0100 Subject: [PATCH 0318/1963] refactor: remove foundry-abi (#6394) * refactor: remove foundry-abi * add decoding * span * tracing * update tmp fmt * refactor: use slices instead of arrays * refactor: rewrite fmt traits * refactor: flatten macro crate * fixes * consolefmt * fixes * bump * rm publishfalse --- Cargo.lock | 45 +- Cargo.toml | 5 +- crates/abi/Cargo.toml | 24 - crates/abi/README.md | 22 - crates/abi/abi/Console.sol | 22 - crates/abi/build.rs | 37 - crates/abi/src/bindings/console.rs | 1276 - crates/abi/src/bindings/hardhat_console.rs | 28831 ---------------- crates/abi/src/bindings/mod.rs | 7 - crates/abi/src/lib.rs | 13 - crates/cast/bin/cmd/storage.rs | 3 +- crates/common/Cargo.toml | 4 +- .../src/fmt/console.rs} | 227 +- crates/common/src/{fmt.rs => fmt/dynamic.rs} | 118 +- crates/common/src/fmt/mod.rs | 76 + crates/{macros => common}/src/fmt/ui.rs | 358 +- crates/common/src/lib.rs | 2 + crates/evm/core/Cargo.toml | 4 +- .../core/src}/abi/HardhatConsole.json | 0 crates/evm/core/src/abi/console.rs | 92 + crates/evm/core/src/abi/hardhat_console.rs | 556 + crates/evm/core/src/abi/mod.rs | 555 +- crates/evm/core/src/debug.rs | 2 +- crates/evm/core/src/decode.rs | 54 +- crates/evm/evm/Cargo.toml | 1 - crates/evm/evm/src/executors/mod.rs | 8 +- crates/evm/evm/src/inspectors/logs.rs | 48 +- crates/evm/traces/Cargo.toml | 1 - crates/evm/traces/src/decoder/mod.rs | 22 +- crates/forge/tests/it/config.rs | 10 +- crates/macros/Cargo.toml | 16 +- crates/macros/impl/Cargo.toml | 23 - crates/macros/impl/src/lib.rs | 24 - crates/macros/{impl => }/src/cheatcodes.rs | 0 crates/macros/{impl => }/src/console_fmt.rs | 31 +- crates/macros/src/fmt/mod.rs | 7 - crates/macros/src/lib.rs | 29 +- crates/utils/src/types.rs | 34 +- 38 files changed, 1211 insertions(+), 31376 deletions(-) delete mode 100644 crates/abi/Cargo.toml delete mode 100644 crates/abi/README.md delete mode 100644 crates/abi/abi/Console.sol delete mode 100644 crates/abi/build.rs delete mode 100644 crates/abi/src/bindings/console.rs delete mode 100644 crates/abi/src/bindings/hardhat_console.rs delete mode 100644 crates/abi/src/bindings/mod.rs delete mode 100644 crates/abi/src/lib.rs rename crates/{macros/src/fmt/console_fmt.rs => common/src/fmt/console.rs} (64%) rename crates/common/src/{fmt.rs => fmt/dynamic.rs} (57%) create mode 100644 crates/common/src/fmt/mod.rs rename crates/{macros => common}/src/fmt/ui.rs (87%) rename crates/{abi => evm/core/src}/abi/HardhatConsole.json (100%) create mode 100644 crates/evm/core/src/abi/console.rs create mode 100644 crates/evm/core/src/abi/hardhat_console.rs delete mode 100644 crates/macros/impl/Cargo.toml delete mode 100644 crates/macros/impl/src/lib.rs rename crates/macros/{impl => }/src/cheatcodes.rs (100%) rename crates/macros/{impl => }/src/console_fmt.rs (74%) delete mode 100644 crates/macros/src/fmt/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 2331165e9a244..8434a01d431e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" +source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" +source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" +source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" dependencies = [ "alloy-rlp", "arbitrary", @@ -168,7 +168,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" +source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" dependencies = [ "alloy-json-abi", "const-hex", @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" +source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" dependencies = [ "winnow", ] @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" +source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -2618,19 +2618,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "foundry-abi" -version = "0.2.0" -dependencies = [ - "ethers-contract", - "ethers-contract-abigen", - "ethers-core", - "ethers-providers", - "eyre", - "foundry-macros", - "syn 2.0.39", -] - [[package]] name = "foundry-binder" version = "0.2.0" @@ -2762,8 +2749,10 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-macros", + "foundry-utils", "globset", "once_cell", + "pretty_assertions", "regex", "reqwest", "semver 1.0.20", @@ -2884,7 +2873,6 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-fuzz", "foundry-evm-traces", - "foundry-macros", "foundry-utils", "hashbrown 0.14.2", "parking_lot", @@ -2903,15 +2891,15 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "const-hex", - "ethers-contract", + "derive_more", "ethers-core", "ethers-providers", "eyre", - "foundry-abi", "foundry-cheatcodes-spec", "foundry-common", "foundry-compilers", "foundry-config", + "foundry-macros", "foundry-utils", "futures", "itertools 0.11.0", @@ -2980,7 +2968,6 @@ dependencies = [ "ethers-core", "eyre", "foundry-block-explorers", - "foundry-cheatcodes-spec", "foundry-common", "foundry-compilers", "foundry-config", @@ -3002,16 +2989,6 @@ dependencies = [ [[package]] name = "foundry-macros" version = "0.2.0" -dependencies = [ - "ethers-core", - "foundry-macros-impl", - "serde", - "serde_json", -] - -[[package]] -name = "foundry-macros-impl" -version = "0.2.0" dependencies = [ "proc-macro-error", "proc-macro2", @@ -6837,7 +6814,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#f2981ec49168dd63aa10d55e3e1987c0cc546246" +source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index f220605354eeb..65df6bd086ff7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,5 @@ [workspace] members = [ - "crates/abi/", "crates/anvil/", "crates/anvil/core/", "crates/anvil/rpc/", @@ -23,7 +22,6 @@ members = [ "crates/fmt/", "crates/forge/", "crates/macros/", - "crates/macros/impl/", "crates/test-utils/", "crates/utils/", ] @@ -97,7 +95,6 @@ codegen-units = 1 # Override packages which aren't perf-sensitive for faster compilation speed [profile.release.package] -foundry-abi.opt-level = 1 mdbook.opt-level = 1 protobuf.opt-level = 1 rusoto_core.opt-level = 1 @@ -114,7 +111,6 @@ forge = { path = "crates/forge" } forge-doc = { path = "crates/doc" } forge-fmt = { path = "crates/fmt" } -foundry-abi = { path = "crates/abi" } foundry-binder = { path = "crates/binder" } foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } @@ -165,6 +161,7 @@ solang-parser = "=0.3.3" ## misc chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" +derive_more = "0.99" eyre = "0.6" hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.11" diff --git a/crates/abi/Cargo.toml b/crates/abi/Cargo.toml deleted file mode 100644 index 7d8e4432ad389..0000000000000 --- a/crates/abi/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "foundry-abi" -description = "Foundry's Solidity ABI bindings" -exclude = ["abi", "build.rs"] - -version.workspace = true -edition.workspace = true -rust-version.workspace = true -authors.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true - -[build-dependencies] -ethers-contract-abigen.workspace = true -eyre.workspace = true -syn = "2.0" - -[dependencies] -foundry-macros.workspace = true - -ethers-core.workspace = true -ethers-contract = { workspace = true, features = ["abigen", "providers"] } -ethers-providers.workspace = true \ No newline at end of file diff --git a/crates/abi/README.md b/crates/abi/README.md deleted file mode 100644 index a92d1dbba67fb..0000000000000 --- a/crates/abi/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# foundry-abi - -> [!WARNING] -> This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future. -> Please avoid making any changes in this crate. - -Contains automatically-generated Rust bindings from Solidity ABI. - -Additional bindings can be generated by doing the following: - -1. add an ABI file in the [`abi` directory](./abi/), using the [ethers-js ABI formats](https://docs.ethers.org/v5/api/utils/abi/formats); -2. update the [build script](./build.rs)'s `MultiAbigen::new` call; -3. build the crate once with `cargo build -p foundry-abi`, generating the bindings for the first time; -4. export the newly-generated bindings at the root of the crate, in [`lib.rs`](./src/lib.rs). - -New cheatcodes can be added by doing the following: - -1. add its Solidity definition(s) in [`HEVM.sol`](./abi/HEVM.sol), bindings should regenerate automatically; -2. implement it in [`foundry-evm`](../evm/src/executor/inspector/cheatcodes/); -3. update the [`Vm.sol`](../../testdata/cheats/Vm.sol) test interface; -4. add tests in [`testdata`](../../testdata/cheats/); -5. open a PR to [`forge-std`](https://github.com/foundry-rs/forge-std) to add it to the `Vm` interface. diff --git a/crates/abi/abi/Console.sol b/crates/abi/abi/Console.sol deleted file mode 100644 index 28b9f559210fb..0000000000000 --- a/crates/abi/abi/Console.sol +++ /dev/null @@ -1,22 +0,0 @@ -event log(string) -event logs (bytes) -event log_address (address) -event log_bytes32 (bytes32) -event log_int (int) -event log_uint (uint) -event log_bytes (bytes) -event log_string (string) -event log_array (uint256[] val) -event log_array (int256[] val) -event log_array (address[] val) -event log_named_address (string key, address val) -event log_named_bytes32 (string key, bytes32 val) -event log_named_decimal_int (string key, int val, uint decimals) -event log_named_decimal_uint (string key, uint val, uint decimals) -event log_named_int (string key, int val) -event log_named_uint (string key, uint val) -event log_named_bytes (string key, bytes val) -event log_named_string (string key, string val) -event log_named_array (string key, uint256[] val) -event log_named_array (string key, int256[] val) -event log_named_array (string key, address[] val) diff --git a/crates/abi/build.rs b/crates/abi/build.rs deleted file mode 100644 index 7cb09d83ceae7..0000000000000 --- a/crates/abi/build.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! **WARNING** -//! This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future. -//! Please avoid making any changes in this crate. - -use ethers_contract_abigen::MultiAbigen; - -/// Includes a JSON ABI as a string literal. -macro_rules! include_json_abi { - ($path:literal) => {{ - println!(concat!("cargo:rerun-if-changed=", $path)); - include_str!($path) - }}; -} - -/// Includes a human-readable ABI file as a string literal by wrapping it in brackets. -macro_rules! include_hr_abi { - ($path:literal) => {{ - println!(concat!("cargo:rerun-if-changed=", $path)); - concat!("[\n", include_str!($path), "\n]") - }}; -} - -fn main() -> eyre::Result<()> { - let mut multi = MultiAbigen::new([ - ("HardhatConsole", include_json_abi!("abi/HardhatConsole.json")), - ("Console", include_hr_abi!("abi/Console.sol")), - ])?; - - // Add the ConsoleFmt derive to the HardhatConsole contract - multi[0].derives_mut().push(syn::parse_str("foundry_macros::ConsoleFmt")?); - - // Generate and write to the bindings module - let bindings = multi.build()?; - bindings.write_to_module("src/bindings/", false)?; - - Ok(()) -} diff --git a/crates/abi/src/bindings/console.rs b/crates/abi/src/bindings/console.rs deleted file mode 100644 index 4749b13ffc3be..0000000000000 --- a/crates/abi/src/bindings/console.rs +++ /dev/null @@ -1,1276 +0,0 @@ -pub use console::*; -/// This module was auto-generated with ethers-rs Abigen. -/// More information at: -#[allow( - clippy::enum_variant_names, - clippy::too_many_arguments, - clippy::upper_case_acronyms, - clippy::type_complexity, - dead_code, - non_camel_case_types, -)] -pub mod console { - #[allow(deprecated)] - fn __abi() -> ::ethers_core::abi::Abi { - ::ethers_core::abi::ethabi::Contract { - constructor: ::core::option::Option::None, - functions: ::std::collections::BTreeMap::new(), - events: ::core::convert::From::from([ - ( - ::std::borrow::ToOwned::to_owned("log"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_address"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_address"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_array"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_array"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ), - ), - indexed: false, - }, - ], - anonymous: false, - }, - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_array"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Int(256usize), - ), - ), - indexed: false, - }, - ], - anonymous: false, - }, - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_array"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_bytes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_bytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_bytes32"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_bytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_int"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_int"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_address"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_address"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_array"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_array"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - ), - ), - indexed: false, - }, - ], - anonymous: false, - }, - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_array"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Int(256usize), - ), - ), - indexed: false, - }, - ], - anonymous: false, - }, - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_array"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Array( - ::std::boxed::Box::new( - ::ethers_core::abi::ethabi::ParamType::Address, - ), - ), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_bytes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_bytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_bytes32"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_bytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_decimal_int"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned( - "log_named_decimal_int", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("decimals"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_decimal_uint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned( - "log_named_decimal_uint", - ), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("decimals"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_int"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_int"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_string"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_string"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_named_uint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_named_uint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("key"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ::ethers_core::abi::ethabi::EventParam { - name: ::std::borrow::ToOwned::to_owned("val"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_string"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_string"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::String, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("log_uint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("log_uint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logs"), - ::std::vec![ - ::ethers_core::abi::ethabi::Event { - name: ::std::borrow::ToOwned::to_owned("logs"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::EventParam { - name: ::std::string::String::new(), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - indexed: false, - }, - ], - anonymous: false, - }, - ], - ), - ]), - errors: ::std::collections::BTreeMap::new(), - receive: false, - fallback: false, - } - } - ///The parsed human-readable ABI of the contract. - pub static CONSOLE_ABI: ::ethers_contract::Lazy<::ethers_core::abi::Abi> = ::ethers_contract::Lazy::new( - __abi, - ); - pub struct Console(::ethers_contract::Contract); - impl ::core::clone::Clone for Console { - fn clone(&self) -> Self { - Self(::core::clone::Clone::clone(&self.0)) - } - } - impl ::core::ops::Deref for Console { - type Target = ::ethers_contract::Contract; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - impl ::core::ops::DerefMut for Console { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } - } - impl ::core::fmt::Debug for Console { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(::core::stringify!(Console)).field(&self.address()).finish() - } - } - impl Console { - /// Creates a new contract instance with the specified `ethers` client at - /// `address`. The contract derefs to a `ethers::Contract` object. - pub fn new>( - address: T, - client: ::std::sync::Arc, - ) -> Self { - Self( - ::ethers_contract::Contract::new( - address.into(), - CONSOLE_ABI.clone(), - client, - ), - ) - } - ///Gets the contract's `log` event - pub fn log_filter( - &self, - ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, LogFilter> { - self.0.event() - } - ///Gets the contract's `log_address` event - pub fn log_address_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogAddressFilter, - > { - self.0.event() - } - ///Gets the contract's `log_array` event - pub fn log_array_1_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogArray1Filter, - > { - self.0.event() - } - ///Gets the contract's `log_array` event - pub fn log_array_2_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogArray2Filter, - > { - self.0.event() - } - ///Gets the contract's `log_array` event - pub fn log_array_3_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogArray3Filter, - > { - self.0.event() - } - ///Gets the contract's `log_bytes` event - pub fn log_bytes_filter( - &self, - ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, LogBytesFilter> { - self.0.event() - } - ///Gets the contract's `log_bytes32` event - pub fn log_bytes_32_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogBytes32Filter, - > { - self.0.event() - } - ///Gets the contract's `log_int` event - pub fn log_int_filter( - &self, - ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, LogIntFilter> { - self.0.event() - } - ///Gets the contract's `log_named_address` event - pub fn log_named_address_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedAddressFilter, - > { - self.0.event() - } - ///Gets the contract's `log_named_array` event - pub fn log_named_array_1_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedArray1Filter, - > { - self.0.event() - } - ///Gets the contract's `log_named_array` event - pub fn log_named_array_2_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedArray2Filter, - > { - self.0.event() - } - ///Gets the contract's `log_named_array` event - pub fn log_named_array_3_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedArray3Filter, - > { - self.0.event() - } - ///Gets the contract's `log_named_bytes` event - pub fn log_named_bytes_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedBytesFilter, - > { - self.0.event() - } - ///Gets the contract's `log_named_bytes32` event - pub fn log_named_bytes_32_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedBytes32Filter, - > { - self.0.event() - } - ///Gets the contract's `log_named_decimal_int` event - pub fn log_named_decimal_int_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedDecimalIntFilter, - > { - self.0.event() - } - ///Gets the contract's `log_named_decimal_uint` event - pub fn log_named_decimal_uint_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedDecimalUintFilter, - > { - self.0.event() - } - ///Gets the contract's `log_named_int` event - pub fn log_named_int_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedIntFilter, - > { - self.0.event() - } - ///Gets the contract's `log_named_string` event - pub fn log_named_string_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedStringFilter, - > { - self.0.event() - } - ///Gets the contract's `log_named_uint` event - pub fn log_named_uint_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogNamedUintFilter, - > { - self.0.event() - } - ///Gets the contract's `log_string` event - pub fn log_string_filter( - &self, - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - LogStringFilter, - > { - self.0.event() - } - ///Gets the contract's `log_uint` event - pub fn log_uint_filter( - &self, - ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, LogUintFilter> { - self.0.event() - } - ///Gets the contract's `logs` event - pub fn logs_filter( - &self, - ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, LogsFilter> { - self.0.event() - } - /// Returns an `Event` builder for all the events of this contract. - pub fn events( - &self, - ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, ConsoleEvents> { - self.0.event_with_filter(::core::default::Default::default()) - } - } - impl From<::ethers_contract::Contract> - for Console { - fn from(contract: ::ethers_contract::Contract) -> Self { - Self::new(contract.address(), contract.client()) - } - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log", abi = "log(string)")] - pub struct LogFilter(pub ::std::string::String); - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_address", abi = "log_address(address)")] - pub struct LogAddressFilter(pub ::ethers_core::types::Address); - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_array", abi = "log_array(uint256[])")] - pub struct LogArray1Filter { - pub val: ::std::vec::Vec<::ethers_core::types::U256>, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_array", abi = "log_array(int256[])")] - pub struct LogArray2Filter { - pub val: ::std::vec::Vec<::ethers_core::types::I256>, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_array", abi = "log_array(address[])")] - pub struct LogArray3Filter { - pub val: ::std::vec::Vec<::ethers_core::types::Address>, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_bytes", abi = "log_bytes(bytes)")] - pub struct LogBytesFilter(pub ::ethers_core::types::Bytes); - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_bytes32", abi = "log_bytes32(bytes32)")] - pub struct LogBytes32Filter(pub [u8; 32]); - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_int", abi = "log_int(int256)")] - pub struct LogIntFilter(pub ::ethers_core::types::I256); - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_address", abi = "log_named_address(string,address)")] - pub struct LogNamedAddressFilter { - pub key: ::std::string::String, - pub val: ::ethers_core::types::Address, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_array", abi = "log_named_array(string,uint256[])")] - pub struct LogNamedArray1Filter { - pub key: ::std::string::String, - pub val: ::std::vec::Vec<::ethers_core::types::U256>, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_array", abi = "log_named_array(string,int256[])")] - pub struct LogNamedArray2Filter { - pub key: ::std::string::String, - pub val: ::std::vec::Vec<::ethers_core::types::I256>, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_array", abi = "log_named_array(string,address[])")] - pub struct LogNamedArray3Filter { - pub key: ::std::string::String, - pub val: ::std::vec::Vec<::ethers_core::types::Address>, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_bytes", abi = "log_named_bytes(string,bytes)")] - pub struct LogNamedBytesFilter { - pub key: ::std::string::String, - pub val: ::ethers_core::types::Bytes, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_bytes32", abi = "log_named_bytes32(string,bytes32)")] - pub struct LogNamedBytes32Filter { - pub key: ::std::string::String, - pub val: [u8; 32], - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent( - name = "log_named_decimal_int", - abi = "log_named_decimal_int(string,int256,uint256)" - )] - pub struct LogNamedDecimalIntFilter { - pub key: ::std::string::String, - pub val: ::ethers_core::types::I256, - pub decimals: ::ethers_core::types::U256, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent( - name = "log_named_decimal_uint", - abi = "log_named_decimal_uint(string,uint256,uint256)" - )] - pub struct LogNamedDecimalUintFilter { - pub key: ::std::string::String, - pub val: ::ethers_core::types::U256, - pub decimals: ::ethers_core::types::U256, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_int", abi = "log_named_int(string,int256)")] - pub struct LogNamedIntFilter { - pub key: ::std::string::String, - pub val: ::ethers_core::types::I256, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_string", abi = "log_named_string(string,string)")] - pub struct LogNamedStringFilter { - pub key: ::std::string::String, - pub val: ::std::string::String, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_named_uint", abi = "log_named_uint(string,uint256)")] - pub struct LogNamedUintFilter { - pub key: ::std::string::String, - pub val: ::ethers_core::types::U256, - } - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_string", abi = "log_string(string)")] - pub struct LogStringFilter(pub ::std::string::String); - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "log_uint", abi = "log_uint(uint256)")] - pub struct LogUintFilter(pub ::ethers_core::types::U256); - #[derive( - Clone, - ::ethers_contract::EthEvent, - ::ethers_contract::EthDisplay, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethevent(name = "logs", abi = "logs(bytes)")] - pub struct LogsFilter(pub ::ethers_core::types::Bytes); - ///Container type for all of the contract's events - #[derive(Clone, ::ethers_contract::EthAbiType, Debug, PartialEq, Eq, Hash)] - pub enum ConsoleEvents { - LogFilter(LogFilter), - LogAddressFilter(LogAddressFilter), - LogArray1Filter(LogArray1Filter), - LogArray2Filter(LogArray2Filter), - LogArray3Filter(LogArray3Filter), - LogBytesFilter(LogBytesFilter), - LogBytes32Filter(LogBytes32Filter), - LogIntFilter(LogIntFilter), - LogNamedAddressFilter(LogNamedAddressFilter), - LogNamedArray1Filter(LogNamedArray1Filter), - LogNamedArray2Filter(LogNamedArray2Filter), - LogNamedArray3Filter(LogNamedArray3Filter), - LogNamedBytesFilter(LogNamedBytesFilter), - LogNamedBytes32Filter(LogNamedBytes32Filter), - LogNamedDecimalIntFilter(LogNamedDecimalIntFilter), - LogNamedDecimalUintFilter(LogNamedDecimalUintFilter), - LogNamedIntFilter(LogNamedIntFilter), - LogNamedStringFilter(LogNamedStringFilter), - LogNamedUintFilter(LogNamedUintFilter), - LogStringFilter(LogStringFilter), - LogUintFilter(LogUintFilter), - LogsFilter(LogsFilter), - } - impl ::ethers_contract::EthLogDecode for ConsoleEvents { - fn decode_log( - log: &::ethers_core::abi::RawLog, - ) -> ::core::result::Result { - if let Ok(decoded) = LogFilter::decode_log(log) { - return Ok(ConsoleEvents::LogFilter(decoded)); - } - if let Ok(decoded) = LogAddressFilter::decode_log(log) { - return Ok(ConsoleEvents::LogAddressFilter(decoded)); - } - if let Ok(decoded) = LogArray1Filter::decode_log(log) { - return Ok(ConsoleEvents::LogArray1Filter(decoded)); - } - if let Ok(decoded) = LogArray2Filter::decode_log(log) { - return Ok(ConsoleEvents::LogArray2Filter(decoded)); - } - if let Ok(decoded) = LogArray3Filter::decode_log(log) { - return Ok(ConsoleEvents::LogArray3Filter(decoded)); - } - if let Ok(decoded) = LogBytesFilter::decode_log(log) { - return Ok(ConsoleEvents::LogBytesFilter(decoded)); - } - if let Ok(decoded) = LogBytes32Filter::decode_log(log) { - return Ok(ConsoleEvents::LogBytes32Filter(decoded)); - } - if let Ok(decoded) = LogIntFilter::decode_log(log) { - return Ok(ConsoleEvents::LogIntFilter(decoded)); - } - if let Ok(decoded) = LogNamedAddressFilter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedAddressFilter(decoded)); - } - if let Ok(decoded) = LogNamedArray1Filter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedArray1Filter(decoded)); - } - if let Ok(decoded) = LogNamedArray2Filter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedArray2Filter(decoded)); - } - if let Ok(decoded) = LogNamedArray3Filter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedArray3Filter(decoded)); - } - if let Ok(decoded) = LogNamedBytesFilter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedBytesFilter(decoded)); - } - if let Ok(decoded) = LogNamedBytes32Filter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedBytes32Filter(decoded)); - } - if let Ok(decoded) = LogNamedDecimalIntFilter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedDecimalIntFilter(decoded)); - } - if let Ok(decoded) = LogNamedDecimalUintFilter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedDecimalUintFilter(decoded)); - } - if let Ok(decoded) = LogNamedIntFilter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedIntFilter(decoded)); - } - if let Ok(decoded) = LogNamedStringFilter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedStringFilter(decoded)); - } - if let Ok(decoded) = LogNamedUintFilter::decode_log(log) { - return Ok(ConsoleEvents::LogNamedUintFilter(decoded)); - } - if let Ok(decoded) = LogStringFilter::decode_log(log) { - return Ok(ConsoleEvents::LogStringFilter(decoded)); - } - if let Ok(decoded) = LogUintFilter::decode_log(log) { - return Ok(ConsoleEvents::LogUintFilter(decoded)); - } - if let Ok(decoded) = LogsFilter::decode_log(log) { - return Ok(ConsoleEvents::LogsFilter(decoded)); - } - Err(::ethers_core::abi::Error::InvalidData) - } - } - impl ::core::fmt::Display for ConsoleEvents { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Self::LogFilter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogAddressFilter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogArray1Filter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogArray2Filter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogArray3Filter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytesFilter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes32Filter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogIntFilter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogNamedAddressFilter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedArray1Filter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedArray2Filter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedArray3Filter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedBytesFilter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedBytes32Filter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedDecimalIntFilter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedDecimalUintFilter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedIntFilter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogNamedStringFilter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogNamedUintFilter(element) => { - ::core::fmt::Display::fmt(element, f) - } - Self::LogStringFilter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogUintFilter(element) => ::core::fmt::Display::fmt(element, f), - Self::LogsFilter(element) => ::core::fmt::Display::fmt(element, f), - } - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogFilter) -> Self { - Self::LogFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogAddressFilter) -> Self { - Self::LogAddressFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogArray1Filter) -> Self { - Self::LogArray1Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogArray2Filter) -> Self { - Self::LogArray2Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogArray3Filter) -> Self { - Self::LogArray3Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogBytesFilter) -> Self { - Self::LogBytesFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogBytes32Filter) -> Self { - Self::LogBytes32Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogIntFilter) -> Self { - Self::LogIntFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedAddressFilter) -> Self { - Self::LogNamedAddressFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedArray1Filter) -> Self { - Self::LogNamedArray1Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedArray2Filter) -> Self { - Self::LogNamedArray2Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedArray3Filter) -> Self { - Self::LogNamedArray3Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedBytesFilter) -> Self { - Self::LogNamedBytesFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedBytes32Filter) -> Self { - Self::LogNamedBytes32Filter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedDecimalIntFilter) -> Self { - Self::LogNamedDecimalIntFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedDecimalUintFilter) -> Self { - Self::LogNamedDecimalUintFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedIntFilter) -> Self { - Self::LogNamedIntFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedStringFilter) -> Self { - Self::LogNamedStringFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogNamedUintFilter) -> Self { - Self::LogNamedUintFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogStringFilter) -> Self { - Self::LogStringFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogUintFilter) -> Self { - Self::LogUintFilter(value) - } - } - impl ::core::convert::From for ConsoleEvents { - fn from(value: LogsFilter) -> Self { - Self::LogsFilter(value) - } - } -} diff --git a/crates/abi/src/bindings/hardhat_console.rs b/crates/abi/src/bindings/hardhat_console.rs deleted file mode 100644 index 72875ab4bc4d7..0000000000000 --- a/crates/abi/src/bindings/hardhat_console.rs +++ /dev/null @@ -1,28831 +0,0 @@ -pub use hardhat_console::*; -/// This module was auto-generated with ethers-rs Abigen. -/// More information at: -#[allow( - clippy::enum_variant_names, - clippy::too_many_arguments, - clippy::upper_case_acronyms, - clippy::type_complexity, - dead_code, - non_camel_case_types, -)] -pub mod hardhat_console { - #[allow(deprecated)] - fn __abi() -> ::ethers_core::abi::Abi { - ::ethers_core::abi::ethabi::Contract { - constructor: ::core::option::Option::None, - functions: ::core::convert::From::from([ - ( - ::std::borrow::ToOwned::to_owned("log"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p2"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p3"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("int256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("log"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p1"), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("int256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logAddress"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logAddress"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Address, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("address"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBool"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBool"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bool, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bool"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Bytes, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes1"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes1"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 1usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes1"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes10"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes10"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 10usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes10"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes11"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes11"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 11usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes11"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes12"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes12"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 12usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes12"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes13"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes13"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 13usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes13"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes14"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes14"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 14usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes14"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes15"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes15"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 15usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes15"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes16"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes16"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 16usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes16"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes17"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes17"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 17usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes17"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes18"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes18"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 18usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes18"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes19"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes19"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 19usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes19"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes2"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes2"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 2usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes2"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes20"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes20"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 20usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes20"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes21"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes21"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 21usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes21"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes22"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes22"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 22usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes22"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes23"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes23"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 23usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes23"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes24"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes24"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 24usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes24"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes25"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes25"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 25usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes25"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes26"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes26"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 26usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes26"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes27"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes27"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 27usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes27"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes28"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes28"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 28usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes28"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes29"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes29"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 29usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes29"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes3"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes3"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 3usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes3"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes30"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes30"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 30usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes30"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes31"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes31"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 31usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes31"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes32"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes32"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 32usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes32"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes4"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes4"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 4usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes4"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes5"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes5"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 5usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes5"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes6"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes6"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 6usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes6"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes7"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes7"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 7usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes7"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes8"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes8"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 8usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes8"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logBytes9"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logBytes9"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::FixedBytes( - 9usize, - ), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("bytes9"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logInt"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logInt"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Int(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("int256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logString"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logString"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::String, - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("string"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ( - ::std::borrow::ToOwned::to_owned("logUint"), - ::std::vec![ - ::ethers_core::abi::ethabi::Function { - name: ::std::borrow::ToOwned::to_owned("logUint"), - inputs: ::std::vec![ - ::ethers_core::abi::ethabi::Param { - name: ::std::borrow::ToOwned::to_owned("p0"), - kind: ::ethers_core::abi::ethabi::ParamType::Uint(256usize), - internal_type: ::core::option::Option::Some( - ::std::borrow::ToOwned::to_owned("uint256"), - ), - }, - ], - outputs: ::std::vec![], - constant: ::core::option::Option::None, - state_mutability: ::ethers_core::abi::ethabi::StateMutability::View, - }, - ], - ), - ]), - events: ::std::collections::BTreeMap::new(), - errors: ::std::collections::BTreeMap::new(), - receive: false, - fallback: false, - } - } - ///The parsed JSON ABI of the contract. - pub static HARDHATCONSOLE_ABI: ::ethers_contract::Lazy<::ethers_core::abi::Abi> = ::ethers_contract::Lazy::new( - __abi, - ); - pub struct HardhatConsole(::ethers_contract::Contract); - impl ::core::clone::Clone for HardhatConsole { - fn clone(&self) -> Self { - Self(::core::clone::Clone::clone(&self.0)) - } - } - impl ::core::ops::Deref for HardhatConsole { - type Target = ::ethers_contract::Contract; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - impl ::core::ops::DerefMut for HardhatConsole { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } - } - impl ::core::fmt::Debug for HardhatConsole { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(::core::stringify!(HardhatConsole)) - .field(&self.address()) - .finish() - } - } - impl HardhatConsole { - /// Creates a new contract instance with the specified `ethers` client at - /// `address`. The contract derefs to a `ethers::Contract` object. - pub fn new>( - address: T, - client: ::std::sync::Arc, - ) -> Self { - Self( - ::ethers_contract::Contract::new( - address.into(), - HARDHATCONSOLE_ABI.clone(), - client, - ), - ) - } - ///Calls the contract's `log` (0x007150be) function - pub fn log_23( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([0, 113, 80, 190], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x00dd87b9) function - pub fn log_87( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([0, 221, 135, 185], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x018c84c2) function - pub fn log_24( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([1, 140, 132, 194], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x031c6f73) function - pub fn log_88( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([3, 28, 111, 115], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0454c079) function - pub fn log_89( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([4, 84, 192, 121], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x078287f5) function - pub fn log_90( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([7, 130, 135, 245], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x07831502) function - pub fn log_91( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([7, 131, 21, 2], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x088ef9d2) function - pub fn log_25( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([8, 142, 249, 210], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x091ffaf5) function - pub fn log_92( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([9, 31, 250, 245], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0aa6cfad) function - pub fn log_93( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([10, 166, 207, 173], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0bb00eab) function - pub fn log_94( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([11, 176, 14, 171], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0c66d1be) function - pub fn log_95( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([12, 102, 209, 190], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0c9cd9c1) function - pub fn log_96( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([12, 156, 217, 193], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0d26b925) function - pub fn log_26( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([13, 38, 185, 37], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0d36fa20) function - pub fn log_97( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([13, 54, 250, 32], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0df12b76) function - pub fn log_98( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([13, 241, 43, 118], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0e378994) function - pub fn log_99( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([14, 55, 137, 148], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x0ef7e050) function - pub fn log_100( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([14, 247, 224, 80], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x100f650e) function - pub fn log_101( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([16, 15, 101, 14], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1023f7b2) function - pub fn log_102( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([16, 35, 247, 178], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1078f68d) function - pub fn log_27( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([16, 120, 246, 141], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1093ee11) function - pub fn log_28( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([16, 147, 238, 17], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x12d6c788) function - pub fn log_103( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([18, 214, 199, 136], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x12f21602) function - pub fn log_29( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([18, 242, 22, 2], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x136b05dd) function - pub fn log_104( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([19, 107, 5, 221], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1537dc87) function - pub fn log_105( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([21, 55, 220, 135], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1596a1ce) function - pub fn log_106( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([21, 150, 161, 206], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x159f8927) function - pub fn log_107( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([21, 159, 137, 39], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x15c127b5) function - pub fn log_108( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([21, 193, 39, 181], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x15cac476) function - pub fn log_109( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([21, 202, 196, 118], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1606a393) function - pub fn log_110( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([22, 6, 163, 147], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1762e32a) function - pub fn log_111( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([23, 98, 227, 42], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x17fe6185) function - pub fn log_30( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([23, 254, 97, 133], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x18c9c746) function - pub fn log_31( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([24, 201, 199, 70], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x193fb800) function - pub fn log_112( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([25, 63, 184, 0], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x19fd4956) function - pub fn log_113( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([25, 253, 73, 86], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1ad96de6) function - pub fn log_114( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([26, 217, 109, 230], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1bb3b09a) function - pub fn log_115( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([27, 179, 176, 154], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1c41a336) function - pub fn log_116( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([28, 65, 163, 54], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1c7ec448) function - pub fn log_32( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([28, 126, 196, 72], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1c9d7eb3) function - pub fn log_6( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([28, 157, 126, 179], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1d14d001) function - pub fn log_117( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([29, 20, 208, 1], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1da986ea) function - pub fn log_118( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([29, 169, 134, 234], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1dc8e1b8) function - pub fn log_119( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([29, 200, 225, 184], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x1e4b87e5) function - pub fn log_120( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([30, 75, 135, 229], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x20098014) function - pub fn log_33( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([32, 9, 128, 20], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x205871c2) function - pub fn log_121( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([32, 88, 113, 194], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x20718650) function - pub fn log_34( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([32, 113, 134, 80], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x20e3984d) function - pub fn log_122( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([32, 227, 152, 77], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x212255cc) function - pub fn log_35( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([33, 34, 85, 204], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x21ad0683) function - pub fn log_123( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([33, 173, 6, 131], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x21bdaf25) function - pub fn log_124( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([33, 189, 175, 37], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x223603bd) function - pub fn log_125( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([34, 54, 3, 189], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x22f6b999) function - pub fn log_126( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([34, 246, 185, 153], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x245986f2) function - pub fn log_127( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([36, 89, 134, 242], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2488b414) function - pub fn log_128( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([36, 136, 180, 20], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x24f91465) function - pub fn log_129( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([36, 249, 20, 101], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2555fa46) function - pub fn log_36( - &self, - p_0: bool, - p_1: bool, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([37, 85, 250, 70], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x26f560a8) function - pub fn log_130( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([38, 245, 96, 168], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x27d8afd2) function - pub fn log_131( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([39, 216, 175, 210], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x28863fcb) function - pub fn log_132( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([40, 134, 63, 203], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2a110e83) function - pub fn log_7( - &self, - p_0: bool, - p_1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([42, 17, 14, 131], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2ae408d4) function - pub fn log_133( - &self, - p_0: bool, - p_1: bool, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([42, 228, 8, 212], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2b2b18dc) function - pub fn log_134( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([43, 43, 24, 220], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2c1754ed) function - pub fn log_135( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([44, 23, 84, 237], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2c1d0746) function - pub fn log_136( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([44, 29, 7, 70], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2c2ecbc2) function - pub fn log_1( - &self, - p_0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([44, 46, 203, 194], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2cd4134a) function - pub fn log_137( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([44, 212, 19, 74], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2ced7cef) function - pub fn log_37( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([44, 237, 124, 239], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2d8e33a4) function - pub fn log_138( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([45, 142, 51, 164], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2dd778e6) function - pub fn log_139( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([45, 215, 120, 230], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x319af333) function - pub fn log_8( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([49, 154, 243, 51], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x32458eed) function - pub fn log_2( - &self, - p_0: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([50, 69, 142, 237], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x33e9dd1d) function - pub fn log_140( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([51, 233, 221, 29], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x34f0e636) function - pub fn log_141( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([52, 240, 230, 54], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x35085f7b) function - pub fn log_38( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([53, 8, 95, 123], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x354c36d6) function - pub fn log_142( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([53, 76, 54, 214], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x35a5071f) function - pub fn log_143( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([53, 165, 7, 31], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x37103367) function - pub fn log_39( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([55, 16, 51, 103], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x374bb4b2) function - pub fn log_144( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([55, 75, 180, 178], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x37aa7d4c) function - pub fn log_40( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([55, 170, 125, 76], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x386ff5f4) function - pub fn log_145( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([56, 111, 245, 244], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3971e78c) function - pub fn log_146( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([57, 113, 231, 140], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x399174d3) function - pub fn log_9( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([57, 145, 116, 211], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3b2279b4) function - pub fn log_147( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([59, 34, 121, 180], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3b2a5ce0) function - pub fn log_148( - &self, - p_0: bool, - p_1: bool, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([59, 42, 92, 224], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3bf5e537) function - pub fn log_149( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([59, 245, 229, 55], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3e128ca3) function - pub fn log_150( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([62, 18, 140, 163], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3e9f866a) function - pub fn log_151( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([62, 159, 134, 106], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3f8a701d) function - pub fn log_152( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([63, 138, 112, 29], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x40785869) function - pub fn log_153( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([64, 120, 88, 105], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x41304fac) function - pub fn log_3( - &self, - p_0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([65, 48, 79, 172], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x42d21db7) function - pub fn log_154( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([66, 210, 29, 183], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x439c7bef) function - pub fn log_155( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([67, 156, 123, 239], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x448830a8) function - pub fn log_156( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([68, 136, 48, 168], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x454d54a5) function - pub fn log_157( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([69, 77, 84, 165], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x457fe3cf) function - pub fn log_158( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([69, 127, 227, 207], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x46600be0) function - pub fn log_159( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([70, 96, 11, 224], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x46826b5d) function - pub fn log_160( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([70, 130, 107, 93], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x475c5c33) function - pub fn log_161( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([71, 92, 92, 51], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x4766da72) function - pub fn log_41( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([71, 102, 218, 114], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x478d1c62) function - pub fn log_162( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([71, 141, 28, 98], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x483d0416) function - pub fn log_163( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([72, 61, 4, 22], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x4a28c017) function - pub fn log_164( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([74, 40, 192, 23], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x4a66cb34) function - pub fn log_165( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([74, 102, 203, 52], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x4b5c4277) function - pub fn log_10( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([75, 92, 66, 119], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x4c123d57) function - pub fn log_166( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([76, 18, 61, 87], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x4ceda75a) function - pub fn log_42( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([76, 237, 167, 90], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x4f04fdc6) function - pub fn log_167( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([79, 4, 253, 198], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x50709698) function - pub fn log_43( - &self, - p_0: bool, - p_1: bool, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([80, 112, 150, 152], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x50ad461d) function - pub fn log_168( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([80, 173, 70, 29], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x515e38b6) function - pub fn log_169( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([81, 94, 56, 182], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x51973ec9) function - pub fn log_0(&self) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([81, 151, 62, 201], ()) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x51f09ff8) function - pub fn log_170( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([81, 240, 159, 248], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x538e06ab) function - pub fn log_171( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([83, 142, 6, 171], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x54a7a9a0) function - pub fn log_172( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([84, 167, 169, 160], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x56a5d1b1) function - pub fn log_173( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([86, 165, 209, 177], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5821efa1) function - pub fn log_44( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([88, 33, 239, 161], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5970e089) function - pub fn log_45( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([89, 112, 224, 137], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x59cfcbe3) function - pub fn log_174( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([89, 207, 203, 227], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5a477632) function - pub fn log_175( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([90, 71, 118, 50], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5a9b5ed5) function - pub fn log_46( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([90, 155, 94, 213], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5ab84e1f) function - pub fn log_176( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([90, 184, 78, 31], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5abd992a) function - pub fn log_177( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([90, 189, 153, 42], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5c430d47) function - pub fn log_178( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([92, 67, 13, 71], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5c96b331) function - pub fn log_47( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([92, 150, 179, 49], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5ccd4e37) function - pub fn log_179( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([92, 205, 78, 55], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5d02c50b) function - pub fn log_180( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([93, 2, 197, 11], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5d08bb05) function - pub fn log_181( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([93, 8, 187, 5], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5d1a971a) function - pub fn log_182( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([93, 26, 151, 26], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5da297eb) function - pub fn log_183( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([93, 162, 151, 235], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5e84b0ea) function - pub fn log_184( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([94, 132, 176, 234], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5ea2b7ae) function - pub fn log_185( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([94, 162, 183, 174], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5f15d28c) function - pub fn log_186( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([95, 21, 210, 140], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5f1d5c9f) function - pub fn log_187( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([95, 29, 92, 159], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5f743a7c) function - pub fn log_188( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([95, 116, 58, 124], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x5f7b9afb) function - pub fn log_48( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([95, 123, 154, 251], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6168ed61) function - pub fn log_189( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([97, 104, 237, 97], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x619e4d0e) function - pub fn log_190( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([97, 158, 77, 14], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x63183678) function - pub fn log_191( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([99, 24, 54, 120], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x63cb41f9) function - pub fn log_49( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([99, 203, 65, 249], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x63fb8bc5) function - pub fn log_192( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([99, 251, 139, 197], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x643fd0df) function - pub fn log_11( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([100, 63, 208, 223], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x64b5bb67) function - pub fn log_193( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([100, 181, 187, 103], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x660375dd) function - pub fn log_194( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([102, 3, 117, 221], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x665bf134) function - pub fn log_195( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([102, 91, 241, 52], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x66f1bc67) function - pub fn log_196( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([102, 241, 188, 103], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x678209a8) function - pub fn log_50( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([103, 130, 9, 168], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x67dd6ff1) function - pub fn log_51( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([103, 221, 111, 241], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x68c8b8bd) function - pub fn log_197( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([104, 200, 184, 189], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x691a8f74) function - pub fn log_198( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([105, 26, 143, 116], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x69276c86) function - pub fn log_12( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([105, 39, 108, 134], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x69640b59) function - pub fn log_199( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([105, 100, 11, 89], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6a1199e2) function - pub fn log_200( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([106, 17, 153, 226], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6a9c478b) function - pub fn log_201( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([106, 156, 71, 139], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6b0e5d53) function - pub fn log_202( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([107, 14, 93, 83], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6cde40b8) function - pub fn log_203( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([108, 222, 64, 184], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6d1e8751) function - pub fn log_204( - &self, - p_0: bool, - p_1: bool, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([109, 30, 135, 81], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6d572f44) function - pub fn log_205( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([109, 87, 47, 68], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6d7045c1) function - pub fn log_206( - &self, - p_0: bool, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([109, 112, 69, 193], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6dd434ca) function - pub fn log_207( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([109, 212, 52, 202], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6f1a594e) function - pub fn log_208( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([111, 26, 89, 78], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x6f7c603e) function - pub fn log_209( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([111, 124, 96, 62], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7190a529) function - pub fn log_210( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([113, 144, 165, 41], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x71d04af2) function - pub fn log_52( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([113, 208, 74, 242], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x736efbb6) function - pub fn log_211( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([115, 110, 251, 182], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x742d6ee7) function - pub fn log_212( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([116, 45, 110, 231], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7464ce23) function - pub fn log_213( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([116, 100, 206, 35], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x759f86bb) function - pub fn log_13( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([117, 159, 134, 187], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x75b605d3) function - pub fn log_14( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([117, 182, 5, 211], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7626db92) function - pub fn log_214( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([118, 38, 219, 146], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x79884c2b) function - pub fn log_215( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([121, 136, 76, 43], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7af6ab25) function - pub fn log_216( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([122, 246, 171, 37], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7afac959) function - pub fn log_53( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([122, 250, 201, 89], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7bc0d848) function - pub fn log_54( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([123, 192, 216, 72], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7be0c3eb) function - pub fn log_217( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([123, 224, 195, 235], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7bf181a1) function - pub fn log_218( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([123, 241, 129, 161], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7c4632a4) function - pub fn log_219( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([124, 70, 50, 164], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7cc3c607) function - pub fn log_220( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([124, 195, 198, 7], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7d24491d) function - pub fn log_221( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([125, 36, 73, 29], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7dd4d0e0) function - pub fn log_222( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([125, 212, 208, 224], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x7f9bbca2) function - pub fn log_223( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([127, 155, 188, 162], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x800a1c67) function - pub fn log_224( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([128, 10, 28, 103], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x80e6a20b) function - pub fn log_225( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([128, 230, 162, 11], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x82112a42) function - pub fn log_226( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([130, 17, 42, 66], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x82c25b74) function - pub fn log_227( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([130, 194, 91, 116], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8309e8a8) function - pub fn log_15( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([131, 9, 232, 168], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x850b7ad6) function - pub fn log_55( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([133, 11, 122, 214], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x853c4849) function - pub fn log_16( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([133, 60, 72, 73], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x854b3496) function - pub fn log_228( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([133, 75, 52, 150], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x85775021) function - pub fn log_56( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([133, 119, 80, 33], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x88a8c406) function - pub fn log_229( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([136, 168, 196, 6], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x88cb6041) function - pub fn log_230( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([136, 203, 96, 65], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x88f6e4b2) function - pub fn log_231( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([136, 246, 228, 178], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x895af8c5) function - pub fn log_232( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([137, 90, 248, 197], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8af7cf8a) function - pub fn log_233( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([138, 247, 207, 138], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8c329b1a) function - pub fn log_234( - &self, - p_0: bool, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([140, 50, 155, 26], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8c4e5de6) function - pub fn log_235( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([140, 78, 93, 230], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8da6def5) function - pub fn log_236( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([141, 166, 222, 245], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8e3f78a9) function - pub fn log_237( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([142, 63, 120, 169], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8e69fb5d) function - pub fn log_238( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([142, 105, 251, 93], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8eafb02b) function - pub fn log_239( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([142, 175, 176, 43], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8ef3f399) function - pub fn log_240( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([142, 243, 243, 153], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8f736d16) function - pub fn log_241( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([143, 115, 109, 22], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x8feac525) function - pub fn log_17( - &self, - p_0: bool, - p_1: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([143, 234, 197, 37], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x90c30a56) function - pub fn log_242( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([144, 195, 10, 86], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x90fb06aa) function - pub fn log_243( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([144, 251, 6, 170], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9143dbb1) function - pub fn log_244( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([145, 67, 219, 177], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x91a02e2a) function - pub fn log_245( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([145, 160, 46, 42], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x91d1112e) function - pub fn log_246( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([145, 209, 17, 46], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x932bbb38) function - pub fn log_57( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([147, 43, 187, 56], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x935e09bf) function - pub fn log_247( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([147, 94, 9, 191], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x94250d77) function - pub fn log_248( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([148, 37, 13, 119], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x958c28c6) function - pub fn log_249( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([149, 140, 40, 198], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9591b953) function - pub fn log_58( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([149, 145, 185, 83], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x95ed0195) function - pub fn log_59( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([149, 237, 1, 149], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x97d394d8) function - pub fn log_250( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([151, 211, 148, 216], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9a816a83) function - pub fn log_251( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([154, 129, 106, 131], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9acd3616) function - pub fn log_252( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([154, 205, 54, 22], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9b4254e2) function - pub fn log_253( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([155, 66, 84, 226], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9b6ec042) function - pub fn log_60( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([155, 110, 192, 66], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9c3adfa1) function - pub fn log_254( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([156, 58, 223, 161], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9c4f99fb) function - pub fn log_61( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([156, 79, 153, 251], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9cba8fff) function - pub fn log_255( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([156, 186, 143, 255], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9d22d5dd) function - pub fn log_256( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([157, 34, 213, 221], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9f1bc36e) function - pub fn log_257( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([159, 27, 195, 110], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x9ffb2f93) function - pub fn log_258( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([159, 251, 47, 147], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa04e2f87) function - pub fn log_259( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([160, 78, 47, 135], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa0a47963) function - pub fn log_260( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([160, 164, 121, 99], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa1bcc9b3) function - pub fn log_261( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([161, 188, 201, 179], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa1ef4cbb) function - pub fn log_262( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([161, 239, 76, 187], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa1f2e8aa) function - pub fn log_62( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([161, 242, 232, 170], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa31bfdcc) function - pub fn log_263( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([163, 27, 253, 204], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa5b4fc99) function - pub fn log_264( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([165, 180, 252, 153], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa5cada94) function - pub fn log_265( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([165, 202, 218, 148], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa6f50b0f) function - pub fn log_266( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([166, 245, 11, 15], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa73c1db6) function - pub fn log_267( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([167, 60, 29, 182], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa75c59de) function - pub fn log_268( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([167, 92, 89, 222], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa7a87853) function - pub fn log_269( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([167, 168, 120, 83], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xa826caeb) function - pub fn log_270( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([168, 38, 202, 235], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xaa6540c8) function - pub fn log_271( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([170, 101, 64, 200], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xaabc9a31) function - pub fn log_272( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([170, 188, 154, 49], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xab085ae6) function - pub fn log_273( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([171, 8, 90, 230], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xabf73a98) function - pub fn log_274( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([171, 247, 58, 152], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xade052c7) function - pub fn log_275( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([173, 224, 82, 199], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xae2ec581) function - pub fn log_276( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([174, 46, 197, 129], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb028c9bd) function - pub fn log_277( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([176, 40, 201, 189], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb076847f) function - pub fn log_63( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([176, 118, 132, 127], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb0e0f9b5) function - pub fn log_64( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([176, 224, 249, 181], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb115611f) function - pub fn log_65( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([177, 21, 97, 31], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb3a6b6bd) function - pub fn log_278( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([179, 166, 182, 189], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb4c314ff) function - pub fn log_279( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([180, 195, 20, 255], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb59dbd60) function - pub fn log_280( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([181, 157, 189, 96], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb60e72cc) function - pub fn log_18( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([182, 14, 114, 204], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb69bcaf6) function - pub fn log_66( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([182, 155, 202, 246], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb6f577a1) function - pub fn log_281( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([182, 245, 119, 161], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb7b914ca) function - pub fn log_282( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([183, 185, 20, 202], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xb857163a) function - pub fn log_283( - &self, - p_0: bool, - p_1: bool, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([184, 87, 22, 58], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xba535d9c) function - pub fn log_284( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([186, 83, 93, 156], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xbc0b61fe) function - pub fn log_285( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([188, 11, 97, 254], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xbcfd9be0) function - pub fn log_67( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([188, 253, 155, 224], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xbe553481) function - pub fn log_286( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([190, 85, 52, 129], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xbe984353) function - pub fn log_287( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([190, 152, 67, 83], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xbf01f891) function - pub fn log_288( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([191, 1, 248, 145], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc0a302d8) function - pub fn log_289( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([192, 163, 2, 216], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc21f64c7) function - pub fn log_290( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([194, 31, 100, 199], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc371c7db) function - pub fn log_291( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([195, 113, 199, 219], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc3a8a654) function - pub fn log_292( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([195, 168, 166, 84], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc3b55635) function - pub fn log_19( - &self, - p_0: ::std::string::String, - p_1: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([195, 181, 86, 53], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc3fc3970) function - pub fn log_68( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([195, 252, 57, 112], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc4643e20) function - pub fn log_293( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([196, 100, 62, 32], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc598d185) function - pub fn log_294( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([197, 152, 209, 133], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc5ad85f9) function - pub fn log_295( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([197, 173, 133, 249], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc67ea9d1) function - pub fn log_296( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([198, 126, 169, 209], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc6acc7a8) function - pub fn log_297( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([198, 172, 199, 168], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc91d5ed4) function - pub fn log_69( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([201, 29, 94, 212], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xc95958d6) function - pub fn log_70( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([201, 89, 88, 214], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xca47c4eb) function - pub fn log_71( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([202, 71, 196, 235], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xca7733b1) function - pub fn log_72( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([202, 119, 51, 177], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xcac43479) function - pub fn log_298( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([202, 196, 52, 121], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xcc32ab07) function - pub fn log_299( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([204, 50, 171, 7], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xccf790a1) function - pub fn log_300( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([204, 247, 144, 161], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xceb5f4d7) function - pub fn log_301( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([206, 181, 244, 215], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xcf009880) function - pub fn log_302( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([207, 0, 152, 128], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xcf020fb1) function - pub fn log_73( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([207, 2, 15, 177], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xcf18105c) function - pub fn log_303( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([207, 24, 16, 92], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xcf394485) function - pub fn log_304( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([207, 57, 68, 133], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xd1ed7a3c) function - pub fn log_74( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([209, 237, 122, 60], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xd2763667) function - pub fn log_75( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([210, 118, 54, 103], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xd2d423cd) function - pub fn log_305( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([210, 212, 35, 205], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xd583c602) function - pub fn log_306( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([213, 131, 198, 2], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xd6019f1c) function - pub fn log_307( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([214, 1, 159, 28], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xd6aefad2) function - pub fn log_308( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([214, 174, 250, 210], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xd812a167) function - pub fn log_309( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([216, 18, 161, 103], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xdaf0d4aa) function - pub fn log_20( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([218, 240, 212, 170], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xdbb4c247) function - pub fn log_76( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([219, 180, 194, 71], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xdc5e935b) function - pub fn log_310( - &self, - p_0: bool, - p_1: ::std::string::String, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([220, 94, 147, 91], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xddb06521) function - pub fn log_311( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([221, 176, 101, 33], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xdddb9561) function - pub fn log_312( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([221, 219, 149, 97], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xde03e774) function - pub fn log_313( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([222, 3, 231, 116], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xde68f20a) function - pub fn log_314( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([222, 104, 242, 10], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xde9a9270) function - pub fn log_77( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([222, 154, 146, 112], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xdfc4a2e8) function - pub fn log_315( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: bool, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([223, 196, 162, 232], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe0625b29) function - pub fn log_316( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([224, 98, 91, 41], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe0e95b98) function - pub fn log_317( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([224, 233, 91, 152], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe0e9ad4f) function - pub fn log_78( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([224, 233, 173, 79], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe21de278) function - pub fn log_318( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([226, 29, 226, 120], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe298f47d) function - pub fn log_79( - &self, - p_0: ::std::string::String, - p_1: bool, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([226, 152, 244, 125], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe2bfd60b) function - pub fn log_319( - &self, - p_0: bool, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([226, 191, 214, 11], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe351140f) function - pub fn log_320( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([227, 81, 20, 15], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe3a9ca2f) function - pub fn log_321( - &self, - p_0: bool, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([227, 169, 202, 47], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe41b6f6f) function - pub fn log_322( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([228, 27, 111, 111], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe5e70b2b) function - pub fn log_323( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([229, 231, 11, 43], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe8d3018d) function - pub fn log_324( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([232, 211, 1, 141], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xe8defba9) function - pub fn log_80( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([232, 222, 251, 169], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xeb1bff80) function - pub fn log_325( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([235, 27, 255, 128], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xeb7f6fd2) function - pub fn log_326( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: bool, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([235, 127, 111, 210], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xeb830c92) function - pub fn log_81( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([235, 131, 12, 146], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xeb928d7f) function - pub fn log_327( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::std::string::String, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([235, 146, 141, 127], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xed8f28f6) function - pub fn log_328( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([237, 143, 40, 246], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xef1cefe7) function - pub fn log_329( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::std::string::String, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([239, 28, 239, 231], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xef529018) function - pub fn log_330( - &self, - p_0: ::ethers_core::types::U256, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([239, 82, 144, 24], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xef72c513) function - pub fn log_331( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::Address, - p_2: bool, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([239, 114, 197, 19], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf08744e8) function - pub fn log_82( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([240, 135, 68, 232], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf11699ed) function - pub fn log_83( - &self, - p_0: ::ethers_core::types::Address, - p_1: bool, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([241, 22, 153, 237], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf2a66286) function - pub fn log_84( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([242, 166, 98, 134], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf45d7d2c) function - pub fn log_332( - &self, - p_0: ::std::string::String, - p_1: ::std::string::String, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([244, 93, 125, 44], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf4880ea4) function - pub fn log_333( - &self, - p_0: bool, - p_1: bool, - p_2: ::ethers_core::types::Address, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([244, 136, 14, 164], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf5bc2249) function - pub fn log_334( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([245, 188, 34, 73], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf666715a) function - pub fn log_21( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([246, 102, 113, 90], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf7e36245) function - pub fn log_335( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([247, 227, 98, 69], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf808da20) function - pub fn log_336( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([248, 8, 218, 32], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf82c50f1) function - pub fn log_4( - &self, - p_0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([248, 44, 80, 241], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf8f51b1e) function - pub fn log_337( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([248, 245, 27, 30], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xf9ad2b89) function - pub fn log_338( - &self, - p_0: bool, - p_1: bool, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([249, 173, 43, 137], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xfa8185af) function - pub fn log_339( - &self, - p_0: ::ethers_core::types::U256, - p_1: ::ethers_core::types::U256, - p_2: ::ethers_core::types::U256, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([250, 129, 133, 175], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xfb772265) function - pub fn log_85( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::std::string::String, - p_2: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([251, 119, 34, 101], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xfc4845f0) function - pub fn log_340( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([252, 72, 69, 240], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xfcec75e0) function - pub fn log_86( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([252, 236, 117, 224], (p_0, p_1, p_2)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xfdb4f990) function - pub fn log_341( - &self, - p_0: ::ethers_core::types::Address, - p_1: ::ethers_core::types::Address, - p_2: ::ethers_core::types::U256, - p_3: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([253, 180, 249, 144], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0xfedd1fff) function - pub fn log_342( - &self, - p_0: bool, - p_1: ::ethers_core::types::U256, - p_2: ::std::string::String, - p_3: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([254, 221, 31, 255], (p_0, p_1, p_2, p_3)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x2d5b6cb9) function - pub fn log_5( - &self, - p_0: ::ethers_core::types::I256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([45, 91, 108, 185], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `log` (0x3ca6268e) function - pub fn log_22( - &self, - p_0: ::std::string::String, - p_1: ::ethers_core::types::I256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([60, 166, 38, 142], (p_0, p_1)) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logAddress` (0x5f91b0af) function - pub fn log_address( - &self, - p_0: ::ethers_core::types::Address, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([95, 145, 176, 175], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBool` (0xba7ab84e) function - pub fn log_bool( - &self, - p_0: bool, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([186, 122, 184, 78], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes` (0xe17bf956) function - pub fn log_bytes( - &self, - p_0: ::ethers_core::types::Bytes, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([225, 123, 249, 86], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes1` (0x6f4171c9) function - pub fn log_bytes_1( - &self, - p_0: [u8; 1], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([111, 65, 113, 201], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes10` (0x9dc2a897) function - pub fn log_bytes_10( - &self, - p_0: [u8; 10], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([157, 194, 168, 151], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes11` (0xdc08b6a7) function - pub fn log_bytes_11( - &self, - p_0: [u8; 11], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([220, 8, 182, 167], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes12` (0x7656d6c7) function - pub fn log_bytes_12( - &self, - p_0: [u8; 12], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([118, 86, 214, 199], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes13` (0x34c1d81b) function - pub fn log_bytes_13( - &self, - p_0: [u8; 13], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([52, 193, 216, 27], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes14` (0x3ceaba65) function - pub fn log_bytes_14( - &self, - p_0: [u8; 14], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([60, 234, 186, 101], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes15` (0x591a3da2) function - pub fn log_bytes_15( - &self, - p_0: [u8; 15], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([89, 26, 61, 162], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes16` (0x1f8d7312) function - pub fn log_bytes_16( - &self, - p_0: [u8; 16], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([31, 141, 115, 18], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes17` (0xf89a532f) function - pub fn log_bytes_17( - &self, - p_0: [u8; 17], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([248, 154, 83, 47], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes18` (0xd8652642) function - pub fn log_bytes_18( - &self, - p_0: [u8; 18], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([216, 101, 38, 66], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes19` (0x00f56bc9) function - pub fn log_bytes_19( - &self, - p_0: [u8; 19], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([0, 245, 107, 201], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes2` (0x9b5e943e) function - pub fn log_bytes_2( - &self, - p_0: [u8; 2], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([155, 94, 148, 62], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes20` (0xecb8567e) function - pub fn log_bytes_20( - &self, - p_0: [u8; 20], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([236, 184, 86, 126], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes21` (0x3052c08f) function - pub fn log_bytes_21( - &self, - p_0: [u8; 21], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([48, 82, 192, 143], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes22` (0x807ab434) function - pub fn log_bytes_22( - &self, - p_0: [u8; 22], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([128, 122, 180, 52], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes23` (0x4979b037) function - pub fn log_bytes_23( - &self, - p_0: [u8; 23], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([73, 121, 176, 55], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes24` (0x0977aefc) function - pub fn log_bytes_24( - &self, - p_0: [u8; 24], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([9, 119, 174, 252], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes25` (0xaea9963f) function - pub fn log_bytes_25( - &self, - p_0: [u8; 25], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([174, 169, 150, 63], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes26` (0xd3635628) function - pub fn log_bytes_26( - &self, - p_0: [u8; 26], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([211, 99, 86, 40], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes27` (0xfc372f9f) function - pub fn log_bytes_27( - &self, - p_0: [u8; 27], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([252, 55, 47, 159], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes28` (0x382f9a34) function - pub fn log_bytes_28( - &self, - p_0: [u8; 28], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([56, 47, 154, 52], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes29` (0x7a187641) function - pub fn log_bytes_29( - &self, - p_0: [u8; 29], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([122, 24, 118, 65], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes3` (0x7782fa2d) function - pub fn log_bytes_3( - &self, - p_0: [u8; 3], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([119, 130, 250, 45], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes30` (0xc4340ef6) function - pub fn log_bytes_30( - &self, - p_0: [u8; 30], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([196, 52, 14, 246], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes31` (0x81fc8648) function - pub fn log_bytes_31( - &self, - p_0: [u8; 31], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([129, 252, 134, 72], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes32` (0x2d21d6f7) function - pub fn log_bytes_32( - &self, - p_0: [u8; 32], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([45, 33, 214, 247], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes4` (0xfba3ad39) function - pub fn log_bytes_4( - &self, - p_0: [u8; 4], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([251, 163, 173, 57], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes5` (0x5583be2e) function - pub fn log_bytes_5( - &self, - p_0: [u8; 5], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([85, 131, 190, 46], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes6` (0x4942adc6) function - pub fn log_bytes_6( - &self, - p_0: [u8; 6], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([73, 66, 173, 198], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes7` (0x4574afab) function - pub fn log_bytes_7( - &self, - p_0: [u8; 7], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([69, 116, 175, 171], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes8` (0x9902e47f) function - pub fn log_bytes_8( - &self, - p_0: [u8; 8], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([153, 2, 228, 127], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logBytes9` (0x50a138df) function - pub fn log_bytes_9( - &self, - p_0: [u8; 9], - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([80, 161, 56, 223], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logInt` (0x6525b5f5) function - pub fn log_int( - &self, - p_0: ::ethers_core::types::I256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([101, 37, 181, 245], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logString` (0x0bb563d6) function - pub fn log_string( - &self, - p_0: ::std::string::String, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([11, 181, 99, 214], p_0) - .expect("method not found (this should never happen)") - } - ///Calls the contract's `logUint` (0x9905b744) function - pub fn log_uint( - &self, - p_0: ::ethers_core::types::U256, - ) -> ::ethers_contract::builders::ContractCall { - self.0 - .method_hash([153, 5, 183, 68], p_0) - .expect("method not found (this should never happen)") - } - } - impl From<::ethers_contract::Contract> - for HardhatConsole { - fn from(contract: ::ethers_contract::Contract) -> Self { - Self::new(contract.address(), contract.client()) - } - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,string)` and selector `0x007150be` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,string)")] - pub struct Log23Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,uint256,address)` and selector `0x00dd87b9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,uint256,address)")] - pub struct Log87Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,address)` and selector `0x018c84c2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,address)")] - pub struct Log24Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,address,string)` and selector `0x031c6f73` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,address,string)")] - pub struct Log88Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,bool,string)` and selector `0x0454c079` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,bool,string)")] - pub struct Log89Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,address,uint256)` and selector `0x078287f5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,address,uint256)")] - pub struct Log90Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,bool,uint256)` and selector `0x07831502` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,bool,uint256)")] - pub struct Log91Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,address)` and selector `0x088ef9d2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,address)")] - pub struct Log25Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,address,bool)` and selector `0x091ffaf5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,address,bool)")] - pub struct Log92Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,uint256,string)` and selector `0x0aa6cfad` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,uint256,string)")] - pub struct Log93Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,uint256,uint256)` and selector `0x0bb00eab` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,uint256,uint256)")] - pub struct Log94Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,address,uint256)` and selector `0x0c66d1be` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,address,uint256)")] - pub struct Log95Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,uint256,uint256)` and selector `0x0c9cd9c1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,uint256,uint256)")] - pub struct Log96Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,uint256)` and selector `0x0d26b925` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,uint256)")] - pub struct Log26Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,address,address)` and selector `0x0d36fa20` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,address,address)")] - pub struct Log97Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,address,bool)` and selector `0x0df12b76` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,address,bool)")] - pub struct Log98Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,address,bool)` and selector `0x0e378994` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,address,bool)")] - pub struct Log99Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,uint256,bool)` and selector `0x0ef7e050` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,uint256,bool)")] - pub struct Log100Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,address,uint256)` and selector `0x100f650e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,address,uint256)")] - pub struct Log101Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,uint256,address)` and selector `0x1023f7b2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,uint256,address)")] - pub struct Log102Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,address)` and selector `0x1078f68d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,address)")] - pub struct Log27Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,uint256)` and selector `0x1093ee11` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,uint256)")] - pub struct Log28Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,address,string)` and selector `0x12d6c788` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,address,string)")] - pub struct Log103Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,uint256)` and selector `0x12f21602` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,uint256)")] - pub struct Log29Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,uint256,address)` and selector `0x136b05dd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,uint256,address)")] - pub struct Log104Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,address,uint256)` and selector `0x1537dc87` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,address,uint256)")] - pub struct Log105Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,uint256,address)` and selector `0x1596a1ce` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,uint256,address)")] - pub struct Log106Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,string,uint256)` and selector `0x159f8927` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,string,uint256)")] - pub struct Log107Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,uint256,address)` and selector `0x15c127b5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,uint256,address)")] - pub struct Log108Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,address,bool)` and selector `0x15cac476` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,address,bool)")] - pub struct Log109Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,bool,uint256)` and selector `0x1606a393` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,bool,uint256)")] - pub struct Log110Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,string,string)` and selector `0x1762e32a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,string,string)")] - pub struct Log111Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,uint256)` and selector `0x17fe6185` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,uint256)")] - pub struct Log30Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,bool)` and selector `0x18c9c746` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,bool)")] - pub struct Log31Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,uint256,uint256)` and selector `0x193fb800` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,uint256,uint256)")] - pub struct Log112Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,string,address)` and selector `0x19fd4956` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,string,address)")] - pub struct Log113Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,uint256,string)` and selector `0x1ad96de6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,uint256,string)")] - pub struct Log114Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,address,string)` and selector `0x1bb3b09a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,address,string)")] - pub struct Log115Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,bool,address)` and selector `0x1c41a336` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,bool,address)")] - pub struct Log116Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,address)` and selector `0x1c7ec448` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,address)")] - pub struct Log32Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool)` and selector `0x1c9d7eb3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool)")] - pub struct Log6Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,address,address)` and selector `0x1d14d001` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,address,address)")] - pub struct Log117Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,address,string)` and selector `0x1da986ea` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,address,string)")] - pub struct Log118Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,uint256,uint256)` and selector `0x1dc8e1b8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,uint256,uint256)")] - pub struct Log119Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,string,bool)` and selector `0x1e4b87e5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,string,bool)")] - pub struct Log120Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,uint256)` and selector `0x20098014` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,uint256)")] - pub struct Log33Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,bool,address)` and selector `0x205871c2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,bool,address)")] - pub struct Log121Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,bool)` and selector `0x20718650` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,bool)")] - pub struct Log34Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,uint256,address)` and selector `0x20e3984d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,uint256,address)")] - pub struct Log122Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,string)` and selector `0x212255cc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,string)")] - pub struct Log35Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,string,string)` and selector `0x21ad0683` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,string,string)")] - pub struct Log123Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,string,string)` and selector `0x21bdaf25` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,string,string)")] - pub struct Log124Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,bool,address)` and selector `0x223603bd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,bool,address)")] - pub struct Log125Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,bool,uint256)` and selector `0x22f6b999` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,bool,uint256)")] - pub struct Log126Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,string,string)` and selector `0x245986f2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,string,string)")] - pub struct Log127Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,address,address)` and selector `0x2488b414` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,address,address)")] - pub struct Log128Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,string,uint256)` and selector `0x24f91465` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,string,uint256)")] - pub struct Log129Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,string)` and selector `0x2555fa46` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,string)")] - pub struct Log36Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,address,address)` and selector `0x26f560a8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,address,address)")] - pub struct Log130Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,string,string)` and selector `0x27d8afd2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,string,string)")] - pub struct Log131Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,uint256,uint256)` and selector `0x28863fcb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,uint256,uint256)")] - pub struct Log132Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool)` and selector `0x2a110e83` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool)")] - pub struct Log7Call { - pub p_0: bool, - pub p_1: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,bool,string)` and selector `0x2ae408d4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,bool,string)")] - pub struct Log133Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,address,address)` and selector `0x2b2b18dc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,address,address)")] - pub struct Log134Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,string,bool)` and selector `0x2c1754ed` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,string,bool)")] - pub struct Log135Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,string,uint256)` and selector `0x2c1d0746` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,string,uint256)")] - pub struct Log136Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address)` and selector `0x2c2ecbc2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address)")] - pub struct Log1Call { - pub p_0: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,bool,bool)` and selector `0x2cd4134a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,bool,bool)")] - pub struct Log137Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,string)` and selector `0x2ced7cef` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,string)")] - pub struct Log37Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,address,string)` and selector `0x2d8e33a4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,address,string)")] - pub struct Log138Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,address,string)` and selector `0x2dd778e6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,address,string)")] - pub struct Log139Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address)` and selector `0x319af333` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address)")] - pub struct Log8Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool)` and selector `0x32458eed` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool)")] - pub struct Log2Call { - pub p_0: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,address,address)` and selector `0x33e9dd1d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,address,address)")] - pub struct Log140Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,uint256,uint256)` and selector `0x34f0e636` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,uint256,uint256)")] - pub struct Log141Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,address)` and selector `0x35085f7b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,address)")] - pub struct Log38Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,bool,bool)` and selector `0x354c36d6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,bool,bool)")] - pub struct Log142Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,string,bool)` and selector `0x35a5071f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,string,bool)")] - pub struct Log143Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,uint256)` and selector `0x37103367` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,uint256)")] - pub struct Log39Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,uint256,uint256)` and selector `0x374bb4b2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,uint256,uint256)")] - pub struct Log144Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,uint256)` and selector `0x37aa7d4c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,uint256)")] - pub struct Log40Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,uint256,uint256)` and selector `0x386ff5f4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,uint256,uint256)")] - pub struct Log145Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,bool,uint256)` and selector `0x3971e78c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,bool,uint256)")] - pub struct Log146Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256)` and selector `0x399174d3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256)")] - pub struct Log9Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,uint256,address)` and selector `0x3b2279b4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,uint256,address)")] - pub struct Log147Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,bool,bool)` and selector `0x3b2a5ce0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,bool,bool)")] - pub struct Log148Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,bool,bool)` and selector `0x3bf5e537` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,bool,bool)")] - pub struct Log149Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,string,string)` and selector `0x3e128ca3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,string,string)")] - pub struct Log150Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,bool,uint256)` and selector `0x3e9f866a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,bool,uint256)")] - pub struct Log151Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,string,bool)` and selector `0x3f8a701d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,string,bool)")] - pub struct Log152Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,bool,bool)` and selector `0x40785869` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,bool,bool)")] - pub struct Log153Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string)` and selector `0x41304fac` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string)")] - pub struct Log3Call { - pub p_0: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,string,address)` and selector `0x42d21db7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,string,address)")] - pub struct Log154Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,address,address)` and selector `0x439c7bef` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,address,address)")] - pub struct Log155Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,uint256,string)` and selector `0x448830a8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,uint256,string)")] - pub struct Log156Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,address,bool)` and selector `0x454d54a5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,address,bool)")] - pub struct Log157Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,address,uint256)` and selector `0x457fe3cf` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,address,uint256)")] - pub struct Log158Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,address,bool)` and selector `0x46600be0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,address,bool)")] - pub struct Log159Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,string,uint256)` and selector `0x46826b5d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,string,uint256)")] - pub struct Log160Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,string,string)` and selector `0x475c5c33` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,string,string)")] - pub struct Log161Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,bool)` and selector `0x4766da72` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,bool)")] - pub struct Log41Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,address,address)` and selector `0x478d1c62` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,address,address)")] - pub struct Log162Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,bool,string)` and selector `0x483d0416` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,bool,string)")] - pub struct Log163Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,uint256,string)` and selector `0x4a28c017` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,uint256,string)")] - pub struct Log164Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,bool,string)` and selector `0x4a66cb34` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,bool,string)")] - pub struct Log165Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string)` and selector `0x4b5c4277` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string)")] - pub struct Log10Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,address,uint256)` and selector `0x4c123d57` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,address,uint256)")] - pub struct Log166Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,bool)` and selector `0x4ceda75a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,bool)")] - pub struct Log42Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,address,uint256)` and selector `0x4f04fdc6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,address,uint256)")] - pub struct Log167Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,bool)` and selector `0x50709698` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,bool)")] - pub struct Log43Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,string,bool)` and selector `0x50ad461d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,string,bool)")] - pub struct Log168Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,bool,uint256)` and selector `0x515e38b6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,bool,uint256)")] - pub struct Log169Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log()` and selector `0x51973ec9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log()")] - pub struct Log0Call; - ///Container type for all input parameters for the `log` function with signature `log(bool,address,uint256,string)` and selector `0x51f09ff8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,uint256,string)")] - pub struct Log170Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,bool,address)` and selector `0x538e06ab` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,bool,address)")] - pub struct Log171Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,uint256,address)` and selector `0x54a7a9a0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,uint256,address)")] - pub struct Log172Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,address,address)` and selector `0x56a5d1b1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,address,address)")] - pub struct Log173Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,uint256)` and selector `0x5821efa1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,uint256)")] - pub struct Log44Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,string)` and selector `0x5970e089` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,string)")] - pub struct Log45Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,uint256,string)` and selector `0x59cfcbe3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,uint256,string)")] - pub struct Log174Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,uint256,string)` and selector `0x5a477632` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,uint256,string)")] - pub struct Log175Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,uint256)` and selector `0x5a9b5ed5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,uint256)")] - pub struct Log46Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,string,string)` and selector `0x5ab84e1f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,string,string)")] - pub struct Log176Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,bool,uint256)` and selector `0x5abd992a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,bool,uint256)")] - pub struct Log177Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,string,address)` and selector `0x5c430d47` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,string,address)")] - pub struct Log178Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,address)` and selector `0x5c96b331` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,address)")] - pub struct Log47Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,address,bool)` and selector `0x5ccd4e37` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,address,bool)")] - pub struct Log179Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,string,string)` and selector `0x5d02c50b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,string,string)")] - pub struct Log180Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,address,uint256)` and selector `0x5d08bb05` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,address,uint256)")] - pub struct Log181Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,uint256,string)` and selector `0x5d1a971a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,uint256,string)")] - pub struct Log182Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,string,uint256)` and selector `0x5da297eb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,string,uint256)")] - pub struct Log183Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,bool,string)` and selector `0x5e84b0ea` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,bool,string)")] - pub struct Log184Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,address,address)` and selector `0x5ea2b7ae` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,address,address)")] - pub struct Log185Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,string,bool)` and selector `0x5f15d28c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,string,bool)")] - pub struct Log186Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,bool,bool)` and selector `0x5f1d5c9f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,bool,bool)")] - pub struct Log187Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,uint256,bool)` and selector `0x5f743a7c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,uint256,bool)")] - pub struct Log188Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,uint256)` and selector `0x5f7b9afb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,uint256)")] - pub struct Log48Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,address,address)` and selector `0x6168ed61` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,address,address)")] - pub struct Log189Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,uint256,bool)` and selector `0x619e4d0e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,uint256,bool)")] - pub struct Log190Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,uint256,address)` and selector `0x63183678` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,uint256,address)")] - pub struct Log191Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,string)` and selector `0x63cb41f9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,string)")] - pub struct Log49Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,uint256,address)` and selector `0x63fb8bc5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,uint256,address)")] - pub struct Log192Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string)` and selector `0x643fd0df` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string)")] - pub struct Log11Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,uint256,uint256)` and selector `0x64b5bb67` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,uint256,uint256)")] - pub struct Log193Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,address,address)` and selector `0x660375dd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,address,address)")] - pub struct Log194Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,address,address)` and selector `0x665bf134` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,address,address)")] - pub struct Log195Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,uint256,bool)` and selector `0x66f1bc67` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,uint256,bool)")] - pub struct Log196Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,bool)` and selector `0x678209a8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,bool)")] - pub struct Log50Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,uint256)` and selector `0x67dd6ff1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,uint256)")] - pub struct Log51Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,string,string)` and selector `0x68c8b8bd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,string,string)")] - pub struct Log197Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,uint256,bool)` and selector `0x691a8f74` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,uint256,bool)")] - pub struct Log198Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address)` and selector `0x69276c86` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address)")] - pub struct Log12Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,bool,address)` and selector `0x69640b59` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,bool,address)")] - pub struct Log199Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,string,uint256)` and selector `0x6a1199e2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,string,uint256)")] - pub struct Log200Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,bool,bool)` and selector `0x6a9c478b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,bool,bool)")] - pub struct Log201Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,uint256,bool)` and selector `0x6b0e5d53` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,uint256,bool)")] - pub struct Log202Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,address,string)` and selector `0x6cde40b8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,address,string)")] - pub struct Log203Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,string,string)` and selector `0x6d1e8751` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,string,string)")] - pub struct Log204Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,string,address)` and selector `0x6d572f44` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,string,address)")] - pub struct Log205Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,bool,uint256)` and selector `0x6d7045c1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,bool,uint256)")] - pub struct Log206Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,address,bool)` and selector `0x6dd434ca` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,address,bool)")] - pub struct Log207Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,string,bool)` and selector `0x6f1a594e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,string,bool)")] - pub struct Log208Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,string,address)` and selector `0x6f7c603e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,string,address)")] - pub struct Log209Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,bool,address)` and selector `0x7190a529` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,bool,address)")] - pub struct Log210Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,string)` and selector `0x71d04af2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,string)")] - pub struct Log52Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,address,uint256)` and selector `0x736efbb6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,address,uint256)")] - pub struct Log211Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,uint256,string)` and selector `0x742d6ee7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,uint256,string)")] - pub struct Log212Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,bool,uint256)` and selector `0x7464ce23` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,bool,uint256)")] - pub struct Log213Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string)` and selector `0x759f86bb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string)")] - pub struct Log13Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool)` and selector `0x75b605d3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool)")] - pub struct Log14Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,uint256,bool)` and selector `0x7626db92` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,uint256,bool)")] - pub struct Log214Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,bool,bool)` and selector `0x79884c2b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,bool,bool)")] - pub struct Log215Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,string,bool)` and selector `0x7af6ab25` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,string,bool)")] - pub struct Log216Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,address)` and selector `0x7afac959` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,address)")] - pub struct Log53Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,address)` and selector `0x7bc0d848` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,address)")] - pub struct Log54Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,string,uint256)` and selector `0x7be0c3eb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,string,uint256)")] - pub struct Log217Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,uint256,uint256)` and selector `0x7bf181a1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,uint256,uint256)")] - pub struct Log218Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,string,address)` and selector `0x7c4632a4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,string,address)")] - pub struct Log219Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,address,uint256)` and selector `0x7cc3c607` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,address,uint256)")] - pub struct Log220Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,string,bool)` and selector `0x7d24491d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,string,bool)")] - pub struct Log221Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,uint256,string)` and selector `0x7dd4d0e0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,uint256,string)")] - pub struct Log222Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,bool,uint256)` and selector `0x7f9bbca2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,bool,uint256)")] - pub struct Log223Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,address,string)` and selector `0x800a1c67` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,address,string)")] - pub struct Log224Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,string,uint256)` and selector `0x80e6a20b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,string,uint256)")] - pub struct Log225Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,address,bool)` and selector `0x82112a42` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,address,bool)")] - pub struct Log226Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,uint256,uint256)` and selector `0x82c25b74` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,uint256,uint256)")] - pub struct Log227Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256)` and selector `0x8309e8a8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256)")] - pub struct Log15Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,bool)` and selector `0x850b7ad6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,bool)")] - pub struct Log55Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address)` and selector `0x853c4849` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address)")] - pub struct Log16Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,uint256,string)` and selector `0x854b3496` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,uint256,string)")] - pub struct Log228Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,string)` and selector `0x85775021` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,string)")] - pub struct Log56Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,string,string)` and selector `0x88a8c406` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,string,string)")] - pub struct Log229Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,uint256,address)` and selector `0x88cb6041` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,uint256,address)")] - pub struct Log230Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,address,uint256)` and selector `0x88f6e4b2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,address,uint256)")] - pub struct Log231Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,bool,bool)` and selector `0x895af8c5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,bool,bool)")] - pub struct Log232Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,uint256,bool)` and selector `0x8af7cf8a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,uint256,bool)")] - pub struct Log233Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,bool,address)` and selector `0x8c329b1a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,bool,address)")] - pub struct Log234Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,bool,uint256)` and selector `0x8c4e5de6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,bool,uint256)")] - pub struct Log235Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,uint256,address)` and selector `0x8da6def5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,uint256,address)")] - pub struct Log236Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,bool,uint256)` and selector `0x8e3f78a9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,bool,uint256)")] - pub struct Log237Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,uint256,string)` and selector `0x8e69fb5d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,uint256,string)")] - pub struct Log238Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,string,uint256)` and selector `0x8eafb02b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,string,uint256)")] - pub struct Log239Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,address,uint256)` and selector `0x8ef3f399` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,address,uint256)")] - pub struct Log240Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,string,address)` and selector `0x8f736d16` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,string,address)")] - pub struct Log241Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string)` and selector `0x8feac525` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string)")] - pub struct Log17Call { - pub p_0: bool, - pub p_1: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,address,bool)` and selector `0x90c30a56` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,address,bool)")] - pub struct Log242Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,bool,string)` and selector `0x90fb06aa` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,bool,string)")] - pub struct Log243Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,bool,string)` and selector `0x9143dbb1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,bool,string)")] - pub struct Log244Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,uint256,bool)` and selector `0x91a02e2a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,uint256,bool)")] - pub struct Log245Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,string,uint256)` and selector `0x91d1112e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,string,uint256)")] - pub struct Log246Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,address)` and selector `0x932bbb38` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,address)")] - pub struct Log57Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,uint256,address)` and selector `0x935e09bf` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,uint256,address)")] - pub struct Log247Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,address,uint256)` and selector `0x94250d77` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,address,uint256)")] - pub struct Log248Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,address,bool)` and selector `0x958c28c6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,address,bool)")] - pub struct Log249Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,address)` and selector `0x9591b953` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,address)")] - pub struct Log58Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,address)` and selector `0x95ed0195` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,address)")] - pub struct Log59Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,string,address)` and selector `0x97d394d8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,string,address)")] - pub struct Log250Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,bool,address)` and selector `0x9a816a83` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,bool,address)")] - pub struct Log251Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,bool,address)` and selector `0x9acd3616` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,bool,address)")] - pub struct Log252Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,uint256,bool)` and selector `0x9b4254e2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,uint256,bool)")] - pub struct Log253Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,bool)` and selector `0x9b6ec042` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,bool)")] - pub struct Log60Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,address,string)` and selector `0x9c3adfa1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,address,string)")] - pub struct Log254Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,uint256)` and selector `0x9c4f99fb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,uint256)")] - pub struct Log61Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,string,address)` and selector `0x9cba8fff` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,string,address)")] - pub struct Log255Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,bool,string)` and selector `0x9d22d5dd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,bool,string)")] - pub struct Log256Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,bool,address)` and selector `0x9f1bc36e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,bool,address)")] - pub struct Log257Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,address,string)` and selector `0x9ffb2f93` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,address,string)")] - pub struct Log258Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,string,address)` and selector `0xa04e2f87` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,string,address)")] - pub struct Log259Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,address,string)` and selector `0xa0a47963` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,address,string)")] - pub struct Log260Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,address,bool)` and selector `0xa1bcc9b3` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,address,bool)")] - pub struct Log261Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,address,address)` and selector `0xa1ef4cbb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,address,address)")] - pub struct Log262Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,string)` and selector `0xa1f2e8aa` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,string)")] - pub struct Log62Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,bool,address)` and selector `0xa31bfdcc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,bool,address)")] - pub struct Log263Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,bool,string)` and selector `0xa5b4fc99` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,bool,string)")] - pub struct Log264Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,address,uint256)` and selector `0xa5cada94` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,address,uint256)")] - pub struct Log265Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,address,bool)` and selector `0xa6f50b0f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,address,bool)")] - pub struct Log266Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,string,string)` and selector `0xa73c1db6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,string,string)")] - pub struct Log267Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,address,uint256)` and selector `0xa75c59de` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,address,uint256)")] - pub struct Log268Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,uint256,uint256)` and selector `0xa7a87853` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,uint256,uint256)")] - pub struct Log269Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,string,string)` and selector `0xa826caeb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,string,string)")] - pub struct Log270Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,bool,string)` and selector `0xaa6540c8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,bool,string)")] - pub struct Log271Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,string,address)` and selector `0xaabc9a31` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,string,address)")] - pub struct Log272Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,bool,bool)` and selector `0xab085ae6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,bool,bool)")] - pub struct Log273Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,bool,string)` and selector `0xabf73a98` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,bool,string)")] - pub struct Log274Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,address,string)` and selector `0xade052c7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,address,string)")] - pub struct Log275Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,bool,address)` and selector `0xae2ec581` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,bool,address)")] - pub struct Log276Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,string,uint256)` and selector `0xb028c9bd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,string,uint256)")] - pub struct Log277Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,string)` and selector `0xb076847f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,string)")] - pub struct Log63Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,bool)` and selector `0xb0e0f9b5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,bool)")] - pub struct Log64Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,string)` and selector `0xb115611f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,string)")] - pub struct Log65Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,string,bool)` and selector `0xb3a6b6bd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,string,bool)")] - pub struct Log278Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,address,bool)` and selector `0xb4c314ff` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,address,bool)")] - pub struct Log279Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,address,bool)` and selector `0xb59dbd60` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,address,bool)")] - pub struct Log280Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256)` and selector `0xb60e72cc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256)")] - pub struct Log18Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,uint256)` and selector `0xb69bcaf6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,uint256)")] - pub struct Log66Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,bool,bool)` and selector `0xb6f577a1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,bool,bool)")] - pub struct Log281Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,uint256,string)` and selector `0xb7b914ca` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,uint256,string)")] - pub struct Log282Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,string,bool)` and selector `0xb857163a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,string,bool)")] - pub struct Log283Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,bool,bool)` and selector `0xba535d9c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,bool,bool)")] - pub struct Log284Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,bool,string)` and selector `0xbc0b61fe` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,bool,string)")] - pub struct Log285Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,address)` and selector `0xbcfd9be0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,address)")] - pub struct Log67Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,uint256,uint256)` and selector `0xbe553481` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,uint256,uint256)")] - pub struct Log286Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,uint256,bool)` and selector `0xbe984353` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,uint256,bool)")] - pub struct Log287Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,string,uint256)` and selector `0xbf01f891` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,string,uint256)")] - pub struct Log288Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,address,bool)` and selector `0xc0a302d8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,address,bool)")] - pub struct Log289Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,string,uint256)` and selector `0xc21f64c7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,string,uint256)")] - pub struct Log290Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,bool,address)` and selector `0xc371c7db` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,bool,address)")] - pub struct Log291Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,uint256,bool)` and selector `0xc3a8a654` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,uint256,bool)")] - pub struct Log292Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool)` and selector `0xc3b55635` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool)")] - pub struct Log19Call { - pub p_0: ::std::string::String, - pub p_1: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,string)` and selector `0xc3fc3970` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,string)")] - pub struct Log68Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,uint256,bool)` and selector `0xc4643e20` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,uint256,bool)")] - pub struct Log293Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,uint256,bool)` and selector `0xc598d185` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,uint256,bool)")] - pub struct Log294Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,bool,string)` and selector `0xc5ad85f9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,bool,string)")] - pub struct Log295Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,string,uint256)` and selector `0xc67ea9d1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,string,uint256)")] - pub struct Log296Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,uint256,uint256)` and selector `0xc6acc7a8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,uint256,uint256)")] - pub struct Log297Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,bool)` and selector `0xc91d5ed4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,bool)")] - pub struct Log69Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,uint256)` and selector `0xc95958d6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,uint256)")] - pub struct Log70Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,uint256)` and selector `0xca47c4eb` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,uint256)")] - pub struct Log71Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,bool)` and selector `0xca7733b1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,bool)")] - pub struct Log72Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,bool,bool)` and selector `0xcac43479` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,bool,bool)")] - pub struct Log298Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,string,bool)` and selector `0xcc32ab07` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,string,bool)")] - pub struct Log299Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,uint256,address)` and selector `0xccf790a1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,uint256,address)")] - pub struct Log300Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,bool,bool)` and selector `0xceb5f4d7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,bool,bool)")] - pub struct Log301Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,bool,uint256)` and selector `0xcf009880` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,bool,uint256)")] - pub struct Log302Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,bool)` and selector `0xcf020fb1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,bool)")] - pub struct Log73Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,uint256,string,bool)` and selector `0xcf18105c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,uint256,string,bool)")] - pub struct Log303Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,bool,address)` and selector `0xcf394485` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,bool,address)")] - pub struct Log304Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,uint256)` and selector `0xd1ed7a3c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,uint256)")] - pub struct Log74Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,address)` and selector `0xd2763667` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,address)")] - pub struct Log75Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,bool,string)` and selector `0xd2d423cd` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,bool,string)")] - pub struct Log305Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,string,address)` and selector `0xd583c602` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,string,address)")] - pub struct Log306Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,uint256,bool)` and selector `0xd6019f1c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,uint256,bool)")] - pub struct Log307Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,bool,uint256)` and selector `0xd6aefad2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,bool,uint256)")] - pub struct Log308Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,address,string)` and selector `0xd812a167` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,address,string)")] - pub struct Log309Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address)` and selector `0xdaf0d4aa` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address)")] - pub struct Log20Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,bool)` and selector `0xdbb4c247` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,bool)")] - pub struct Log76Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,string,bool,bool)` and selector `0xdc5e935b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,string,bool,bool)")] - pub struct Log310Call { - pub p_0: bool, - pub p_1: ::std::string::String, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,uint256,string)` and selector `0xddb06521` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,uint256,string)")] - pub struct Log311Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,bool,string)` and selector `0xdddb9561` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,bool,string)")] - pub struct Log312Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,uint256,string)` and selector `0xde03e774` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,uint256,string)")] - pub struct Log313Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,string,string)` and selector `0xde68f20a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,string,string)")] - pub struct Log314Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,string)` and selector `0xde9a9270` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,string)")] - pub struct Log77Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,bool,string)` and selector `0xdfc4a2e8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,bool,string)")] - pub struct Log315Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: bool, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,string,address)` and selector `0xe0625b29` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,string,address)")] - pub struct Log316Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,bool,address)` and selector `0xe0e95b98` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,bool,address)")] - pub struct Log317Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,string)` and selector `0xe0e9ad4f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,string)")] - pub struct Log78Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,uint256,address)` and selector `0xe21de278` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,uint256,address)")] - pub struct Log318Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(string,bool,string)` and selector `0xe298f47d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,bool,string)")] - pub struct Log79Call { - pub p_0: ::std::string::String, - pub p_1: bool, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,address,string,bool)` and selector `0xe2bfd60b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,address,string,bool)")] - pub struct Log319Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,bool,bool)` and selector `0xe351140f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,bool,bool)")] - pub struct Log320Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,string,uint256)` and selector `0xe3a9ca2f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,string,uint256)")] - pub struct Log321Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,uint256,bool,uint256)` and selector `0xe41b6f6f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,uint256,bool,uint256)")] - pub struct Log322Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,string,bool)` and selector `0xe5e70b2b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,string,bool)")] - pub struct Log323Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,string,address,uint256)` and selector `0xe8d3018d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,string,address,uint256)")] - pub struct Log324Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,bool)` and selector `0xe8defba9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,bool)")] - pub struct Log80Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,address,string)` and selector `0xeb1bff80` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,address,string)")] - pub struct Log325Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,bool,uint256)` and selector `0xeb7f6fd2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,bool,uint256)")] - pub struct Log326Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: bool, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,bool)` and selector `0xeb830c92` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,bool)")] - pub struct Log81Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,string,bool)` and selector `0xeb928d7f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,string,bool)")] - pub struct Log327Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,address,address)` and selector `0xed8f28f6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,address,address)")] - pub struct Log328Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,string,uint256)` and selector `0xef1cefe7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,string,uint256)")] - pub struct Log329Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,bool,string,address)` and selector `0xef529018` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,bool,string,address)")] - pub struct Log330Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,address,bool,address)` and selector `0xef72c513` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,address,bool,address)")] - pub struct Log331Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,address)` and selector `0xf08744e8` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,address)")] - pub struct Log82Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,bool,address)` and selector `0xf11699ed` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,bool,address)")] - pub struct Log83Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,bool)` and selector `0xf2a66286` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,bool)")] - pub struct Log84Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,string,uint256,uint256)` and selector `0xf45d7d2c` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,string,uint256,uint256)")] - pub struct Log332Call { - pub p_0: ::std::string::String, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,address,address)` and selector `0xf4880ea4` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,address,address)")] - pub struct Log333Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,string,string)` and selector `0xf5bc2249` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,string,string)")] - pub struct Log334Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256)` and selector `0xf666715a` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256)")] - pub struct Log21Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,address,string)` and selector `0xf7e36245` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,address,string)")] - pub struct Log335Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,address,string)` and selector `0xf808da20` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,address,string)")] - pub struct Log336Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256)` and selector `0xf82c50f1` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256)")] - pub struct Log4Call { - pub p_0: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,uint256,uint256)` and selector `0xf8f51b1e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,uint256,uint256)")] - pub struct Log337Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::U256, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,bool,string,address)` and selector `0xf9ad2b89` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,bool,string,address)")] - pub struct Log338Call { - pub p_0: bool, - pub p_1: bool, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(uint256,uint256,uint256,address)` and selector `0xfa8185af` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(uint256,uint256,uint256,address)")] - pub struct Log339Call { - pub p_0: ::ethers_core::types::U256, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,string,string)` and selector `0xfb772265` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,string,string)")] - pub struct Log85Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::std::string::String, - pub p_2: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,uint256,bool)` and selector `0xfc4845f0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,uint256,bool)")] - pub struct Log340Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: bool, - } - ///Container type for all input parameters for the `log` function with signature `log(string,address,address)` and selector `0xfcec75e0` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,address,address)")] - pub struct Log86Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(address,address,uint256,string)` and selector `0xfdb4f990` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(address,address,uint256,string)")] - pub struct Log341Call { - pub p_0: ::ethers_core::types::Address, - pub p_1: ::ethers_core::types::Address, - pub p_2: ::ethers_core::types::U256, - pub p_3: ::std::string::String, - } - ///Container type for all input parameters for the `log` function with signature `log(bool,uint256,string,address)` and selector `0xfedd1fff` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(bool,uint256,string,address)")] - pub struct Log342Call { - pub p_0: bool, - pub p_1: ::ethers_core::types::U256, - pub p_2: ::std::string::String, - pub p_3: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `log` function with signature `log(int256)` and selector `0x2d5b6cb9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(int256)")] - pub struct Log5Call { - pub p_0: ::ethers_core::types::I256, - } - ///Container type for all input parameters for the `log` function with signature `log(string,int256)` and selector `0x3ca6268e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "log", abi = "log(string,int256)")] - pub struct Log22Call { - pub p_0: ::std::string::String, - pub p_1: ::ethers_core::types::I256, - } - ///Container type for all input parameters for the `logAddress` function with signature `logAddress(address)` and selector `0x5f91b0af` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logAddress", abi = "logAddress(address)")] - pub struct LogAddressCall { - pub p_0: ::ethers_core::types::Address, - } - ///Container type for all input parameters for the `logBool` function with signature `logBool(bool)` and selector `0xba7ab84e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBool", abi = "logBool(bool)")] - pub struct LogBoolCall { - pub p_0: bool, - } - ///Container type for all input parameters for the `logBytes` function with signature `logBytes(bytes)` and selector `0xe17bf956` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes", abi = "logBytes(bytes)")] - pub struct LogBytesCall { - pub p_0: ::ethers_core::types::Bytes, - } - ///Container type for all input parameters for the `logBytes1` function with signature `logBytes1(bytes1)` and selector `0x6f4171c9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes1", abi = "logBytes1(bytes1)")] - pub struct LogBytes1Call { - pub p_0: [u8; 1], - } - ///Container type for all input parameters for the `logBytes10` function with signature `logBytes10(bytes10)` and selector `0x9dc2a897` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes10", abi = "logBytes10(bytes10)")] - pub struct LogBytes10Call { - pub p_0: [u8; 10], - } - ///Container type for all input parameters for the `logBytes11` function with signature `logBytes11(bytes11)` and selector `0xdc08b6a7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes11", abi = "logBytes11(bytes11)")] - pub struct LogBytes11Call { - pub p_0: [u8; 11], - } - ///Container type for all input parameters for the `logBytes12` function with signature `logBytes12(bytes12)` and selector `0x7656d6c7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes12", abi = "logBytes12(bytes12)")] - pub struct LogBytes12Call { - pub p_0: [u8; 12], - } - ///Container type for all input parameters for the `logBytes13` function with signature `logBytes13(bytes13)` and selector `0x34c1d81b` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes13", abi = "logBytes13(bytes13)")] - pub struct LogBytes13Call { - pub p_0: [u8; 13], - } - ///Container type for all input parameters for the `logBytes14` function with signature `logBytes14(bytes14)` and selector `0x3ceaba65` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes14", abi = "logBytes14(bytes14)")] - pub struct LogBytes14Call { - pub p_0: [u8; 14], - } - ///Container type for all input parameters for the `logBytes15` function with signature `logBytes15(bytes15)` and selector `0x591a3da2` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes15", abi = "logBytes15(bytes15)")] - pub struct LogBytes15Call { - pub p_0: [u8; 15], - } - ///Container type for all input parameters for the `logBytes16` function with signature `logBytes16(bytes16)` and selector `0x1f8d7312` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes16", abi = "logBytes16(bytes16)")] - pub struct LogBytes16Call { - pub p_0: [u8; 16], - } - ///Container type for all input parameters for the `logBytes17` function with signature `logBytes17(bytes17)` and selector `0xf89a532f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes17", abi = "logBytes17(bytes17)")] - pub struct LogBytes17Call { - pub p_0: [u8; 17], - } - ///Container type for all input parameters for the `logBytes18` function with signature `logBytes18(bytes18)` and selector `0xd8652642` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes18", abi = "logBytes18(bytes18)")] - pub struct LogBytes18Call { - pub p_0: [u8; 18], - } - ///Container type for all input parameters for the `logBytes19` function with signature `logBytes19(bytes19)` and selector `0x00f56bc9` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes19", abi = "logBytes19(bytes19)")] - pub struct LogBytes19Call { - pub p_0: [u8; 19], - } - ///Container type for all input parameters for the `logBytes2` function with signature `logBytes2(bytes2)` and selector `0x9b5e943e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes2", abi = "logBytes2(bytes2)")] - pub struct LogBytes2Call { - pub p_0: [u8; 2], - } - ///Container type for all input parameters for the `logBytes20` function with signature `logBytes20(bytes20)` and selector `0xecb8567e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes20", abi = "logBytes20(bytes20)")] - pub struct LogBytes20Call { - pub p_0: [u8; 20], - } - ///Container type for all input parameters for the `logBytes21` function with signature `logBytes21(bytes21)` and selector `0x3052c08f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes21", abi = "logBytes21(bytes21)")] - pub struct LogBytes21Call { - pub p_0: [u8; 21], - } - ///Container type for all input parameters for the `logBytes22` function with signature `logBytes22(bytes22)` and selector `0x807ab434` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes22", abi = "logBytes22(bytes22)")] - pub struct LogBytes22Call { - pub p_0: [u8; 22], - } - ///Container type for all input parameters for the `logBytes23` function with signature `logBytes23(bytes23)` and selector `0x4979b037` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes23", abi = "logBytes23(bytes23)")] - pub struct LogBytes23Call { - pub p_0: [u8; 23], - } - ///Container type for all input parameters for the `logBytes24` function with signature `logBytes24(bytes24)` and selector `0x0977aefc` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes24", abi = "logBytes24(bytes24)")] - pub struct LogBytes24Call { - pub p_0: [u8; 24], - } - ///Container type for all input parameters for the `logBytes25` function with signature `logBytes25(bytes25)` and selector `0xaea9963f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes25", abi = "logBytes25(bytes25)")] - pub struct LogBytes25Call { - pub p_0: [u8; 25], - } - ///Container type for all input parameters for the `logBytes26` function with signature `logBytes26(bytes26)` and selector `0xd3635628` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes26", abi = "logBytes26(bytes26)")] - pub struct LogBytes26Call { - pub p_0: [u8; 26], - } - ///Container type for all input parameters for the `logBytes27` function with signature `logBytes27(bytes27)` and selector `0xfc372f9f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes27", abi = "logBytes27(bytes27)")] - pub struct LogBytes27Call { - pub p_0: [u8; 27], - } - ///Container type for all input parameters for the `logBytes28` function with signature `logBytes28(bytes28)` and selector `0x382f9a34` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes28", abi = "logBytes28(bytes28)")] - pub struct LogBytes28Call { - pub p_0: [u8; 28], - } - ///Container type for all input parameters for the `logBytes29` function with signature `logBytes29(bytes29)` and selector `0x7a187641` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes29", abi = "logBytes29(bytes29)")] - pub struct LogBytes29Call { - pub p_0: [u8; 29], - } - ///Container type for all input parameters for the `logBytes3` function with signature `logBytes3(bytes3)` and selector `0x7782fa2d` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes3", abi = "logBytes3(bytes3)")] - pub struct LogBytes3Call { - pub p_0: [u8; 3], - } - ///Container type for all input parameters for the `logBytes30` function with signature `logBytes30(bytes30)` and selector `0xc4340ef6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes30", abi = "logBytes30(bytes30)")] - pub struct LogBytes30Call { - pub p_0: [u8; 30], - } - ///Container type for all input parameters for the `logBytes31` function with signature `logBytes31(bytes31)` and selector `0x81fc8648` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes31", abi = "logBytes31(bytes31)")] - pub struct LogBytes31Call { - pub p_0: [u8; 31], - } - ///Container type for all input parameters for the `logBytes32` function with signature `logBytes32(bytes32)` and selector `0x2d21d6f7` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes32", abi = "logBytes32(bytes32)")] - pub struct LogBytes32Call { - pub p_0: [u8; 32], - } - ///Container type for all input parameters for the `logBytes4` function with signature `logBytes4(bytes4)` and selector `0xfba3ad39` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes4", abi = "logBytes4(bytes4)")] - pub struct LogBytes4Call { - pub p_0: [u8; 4], - } - ///Container type for all input parameters for the `logBytes5` function with signature `logBytes5(bytes5)` and selector `0x5583be2e` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes5", abi = "logBytes5(bytes5)")] - pub struct LogBytes5Call { - pub p_0: [u8; 5], - } - ///Container type for all input parameters for the `logBytes6` function with signature `logBytes6(bytes6)` and selector `0x4942adc6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes6", abi = "logBytes6(bytes6)")] - pub struct LogBytes6Call { - pub p_0: [u8; 6], - } - ///Container type for all input parameters for the `logBytes7` function with signature `logBytes7(bytes7)` and selector `0x4574afab` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes7", abi = "logBytes7(bytes7)")] - pub struct LogBytes7Call { - pub p_0: [u8; 7], - } - ///Container type for all input parameters for the `logBytes8` function with signature `logBytes8(bytes8)` and selector `0x9902e47f` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes8", abi = "logBytes8(bytes8)")] - pub struct LogBytes8Call { - pub p_0: [u8; 8], - } - ///Container type for all input parameters for the `logBytes9` function with signature `logBytes9(bytes9)` and selector `0x50a138df` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logBytes9", abi = "logBytes9(bytes9)")] - pub struct LogBytes9Call { - pub p_0: [u8; 9], - } - ///Container type for all input parameters for the `logInt` function with signature `logInt(int256)` and selector `0x6525b5f5` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logInt", abi = "logInt(int256)")] - pub struct LogIntCall { - pub p_0: ::ethers_core::types::I256, - } - ///Container type for all input parameters for the `logString` function with signature `logString(string)` and selector `0x0bb563d6` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logString", abi = "logString(string)")] - pub struct LogStringCall { - pub p_0: ::std::string::String, - } - ///Container type for all input parameters for the `logUint` function with signature `logUint(uint256)` and selector `0x9905b744` - #[derive( - Clone, - ::ethers_contract::EthCall, - ::ethers_contract::EthDisplay, - foundry_macros::ConsoleFmt, - Default, - Debug, - PartialEq, - Eq, - Hash - )] - #[ethcall(name = "logUint", abi = "logUint(uint256)")] - pub struct LogUintCall { - pub p_0: ::ethers_core::types::U256, - } - ///Container type for all of the contract's call - #[derive( - Clone, - ::ethers_contract::EthAbiType, - foundry_macros::ConsoleFmt, - Debug, - PartialEq, - Eq, - Hash - )] - pub enum HardhatConsoleCalls { - Log23(Log23Call), - Log87(Log87Call), - Log24(Log24Call), - Log88(Log88Call), - Log89(Log89Call), - Log90(Log90Call), - Log91(Log91Call), - Log25(Log25Call), - Log92(Log92Call), - Log93(Log93Call), - Log94(Log94Call), - Log95(Log95Call), - Log96(Log96Call), - Log26(Log26Call), - Log97(Log97Call), - Log98(Log98Call), - Log99(Log99Call), - Log100(Log100Call), - Log101(Log101Call), - Log102(Log102Call), - Log27(Log27Call), - Log28(Log28Call), - Log103(Log103Call), - Log29(Log29Call), - Log104(Log104Call), - Log105(Log105Call), - Log106(Log106Call), - Log107(Log107Call), - Log108(Log108Call), - Log109(Log109Call), - Log110(Log110Call), - Log111(Log111Call), - Log30(Log30Call), - Log31(Log31Call), - Log112(Log112Call), - Log113(Log113Call), - Log114(Log114Call), - Log115(Log115Call), - Log116(Log116Call), - Log32(Log32Call), - Log6(Log6Call), - Log117(Log117Call), - Log118(Log118Call), - Log119(Log119Call), - Log120(Log120Call), - Log33(Log33Call), - Log121(Log121Call), - Log34(Log34Call), - Log122(Log122Call), - Log35(Log35Call), - Log123(Log123Call), - Log124(Log124Call), - Log125(Log125Call), - Log126(Log126Call), - Log127(Log127Call), - Log128(Log128Call), - Log129(Log129Call), - Log36(Log36Call), - Log130(Log130Call), - Log131(Log131Call), - Log132(Log132Call), - Log7(Log7Call), - Log133(Log133Call), - Log134(Log134Call), - Log135(Log135Call), - Log136(Log136Call), - Log1(Log1Call), - Log137(Log137Call), - Log37(Log37Call), - Log138(Log138Call), - Log139(Log139Call), - Log8(Log8Call), - Log2(Log2Call), - Log140(Log140Call), - Log141(Log141Call), - Log38(Log38Call), - Log142(Log142Call), - Log143(Log143Call), - Log39(Log39Call), - Log144(Log144Call), - Log40(Log40Call), - Log145(Log145Call), - Log146(Log146Call), - Log9(Log9Call), - Log147(Log147Call), - Log148(Log148Call), - Log149(Log149Call), - Log150(Log150Call), - Log151(Log151Call), - Log152(Log152Call), - Log153(Log153Call), - Log3(Log3Call), - Log154(Log154Call), - Log155(Log155Call), - Log156(Log156Call), - Log157(Log157Call), - Log158(Log158Call), - Log159(Log159Call), - Log160(Log160Call), - Log161(Log161Call), - Log41(Log41Call), - Log162(Log162Call), - Log163(Log163Call), - Log164(Log164Call), - Log165(Log165Call), - Log10(Log10Call), - Log166(Log166Call), - Log42(Log42Call), - Log167(Log167Call), - Log43(Log43Call), - Log168(Log168Call), - Log169(Log169Call), - Log0(Log0Call), - Log170(Log170Call), - Log171(Log171Call), - Log172(Log172Call), - Log173(Log173Call), - Log44(Log44Call), - Log45(Log45Call), - Log174(Log174Call), - Log175(Log175Call), - Log46(Log46Call), - Log176(Log176Call), - Log177(Log177Call), - Log178(Log178Call), - Log47(Log47Call), - Log179(Log179Call), - Log180(Log180Call), - Log181(Log181Call), - Log182(Log182Call), - Log183(Log183Call), - Log184(Log184Call), - Log185(Log185Call), - Log186(Log186Call), - Log187(Log187Call), - Log188(Log188Call), - Log48(Log48Call), - Log189(Log189Call), - Log190(Log190Call), - Log191(Log191Call), - Log49(Log49Call), - Log192(Log192Call), - Log11(Log11Call), - Log193(Log193Call), - Log194(Log194Call), - Log195(Log195Call), - Log196(Log196Call), - Log50(Log50Call), - Log51(Log51Call), - Log197(Log197Call), - Log198(Log198Call), - Log12(Log12Call), - Log199(Log199Call), - Log200(Log200Call), - Log201(Log201Call), - Log202(Log202Call), - Log203(Log203Call), - Log204(Log204Call), - Log205(Log205Call), - Log206(Log206Call), - Log207(Log207Call), - Log208(Log208Call), - Log209(Log209Call), - Log210(Log210Call), - Log52(Log52Call), - Log211(Log211Call), - Log212(Log212Call), - Log213(Log213Call), - Log13(Log13Call), - Log14(Log14Call), - Log214(Log214Call), - Log215(Log215Call), - Log216(Log216Call), - Log53(Log53Call), - Log54(Log54Call), - Log217(Log217Call), - Log218(Log218Call), - Log219(Log219Call), - Log220(Log220Call), - Log221(Log221Call), - Log222(Log222Call), - Log223(Log223Call), - Log224(Log224Call), - Log225(Log225Call), - Log226(Log226Call), - Log227(Log227Call), - Log15(Log15Call), - Log55(Log55Call), - Log16(Log16Call), - Log228(Log228Call), - Log56(Log56Call), - Log229(Log229Call), - Log230(Log230Call), - Log231(Log231Call), - Log232(Log232Call), - Log233(Log233Call), - Log234(Log234Call), - Log235(Log235Call), - Log236(Log236Call), - Log237(Log237Call), - Log238(Log238Call), - Log239(Log239Call), - Log240(Log240Call), - Log241(Log241Call), - Log17(Log17Call), - Log242(Log242Call), - Log243(Log243Call), - Log244(Log244Call), - Log245(Log245Call), - Log246(Log246Call), - Log57(Log57Call), - Log247(Log247Call), - Log248(Log248Call), - Log249(Log249Call), - Log58(Log58Call), - Log59(Log59Call), - Log250(Log250Call), - Log251(Log251Call), - Log252(Log252Call), - Log253(Log253Call), - Log60(Log60Call), - Log254(Log254Call), - Log61(Log61Call), - Log255(Log255Call), - Log256(Log256Call), - Log257(Log257Call), - Log258(Log258Call), - Log259(Log259Call), - Log260(Log260Call), - Log261(Log261Call), - Log262(Log262Call), - Log62(Log62Call), - Log263(Log263Call), - Log264(Log264Call), - Log265(Log265Call), - Log266(Log266Call), - Log267(Log267Call), - Log268(Log268Call), - Log269(Log269Call), - Log270(Log270Call), - Log271(Log271Call), - Log272(Log272Call), - Log273(Log273Call), - Log274(Log274Call), - Log275(Log275Call), - Log276(Log276Call), - Log277(Log277Call), - Log63(Log63Call), - Log64(Log64Call), - Log65(Log65Call), - Log278(Log278Call), - Log279(Log279Call), - Log280(Log280Call), - Log18(Log18Call), - Log66(Log66Call), - Log281(Log281Call), - Log282(Log282Call), - Log283(Log283Call), - Log284(Log284Call), - Log285(Log285Call), - Log67(Log67Call), - Log286(Log286Call), - Log287(Log287Call), - Log288(Log288Call), - Log289(Log289Call), - Log290(Log290Call), - Log291(Log291Call), - Log292(Log292Call), - Log19(Log19Call), - Log68(Log68Call), - Log293(Log293Call), - Log294(Log294Call), - Log295(Log295Call), - Log296(Log296Call), - Log297(Log297Call), - Log69(Log69Call), - Log70(Log70Call), - Log71(Log71Call), - Log72(Log72Call), - Log298(Log298Call), - Log299(Log299Call), - Log300(Log300Call), - Log301(Log301Call), - Log302(Log302Call), - Log73(Log73Call), - Log303(Log303Call), - Log304(Log304Call), - Log74(Log74Call), - Log75(Log75Call), - Log305(Log305Call), - Log306(Log306Call), - Log307(Log307Call), - Log308(Log308Call), - Log309(Log309Call), - Log20(Log20Call), - Log76(Log76Call), - Log310(Log310Call), - Log311(Log311Call), - Log312(Log312Call), - Log313(Log313Call), - Log314(Log314Call), - Log77(Log77Call), - Log315(Log315Call), - Log316(Log316Call), - Log317(Log317Call), - Log78(Log78Call), - Log318(Log318Call), - Log79(Log79Call), - Log319(Log319Call), - Log320(Log320Call), - Log321(Log321Call), - Log322(Log322Call), - Log323(Log323Call), - Log324(Log324Call), - Log80(Log80Call), - Log325(Log325Call), - Log326(Log326Call), - Log81(Log81Call), - Log327(Log327Call), - Log328(Log328Call), - Log329(Log329Call), - Log330(Log330Call), - Log331(Log331Call), - Log82(Log82Call), - Log83(Log83Call), - Log84(Log84Call), - Log332(Log332Call), - Log333(Log333Call), - Log334(Log334Call), - Log21(Log21Call), - Log335(Log335Call), - Log336(Log336Call), - Log4(Log4Call), - Log337(Log337Call), - Log338(Log338Call), - Log339(Log339Call), - Log85(Log85Call), - Log340(Log340Call), - Log86(Log86Call), - Log341(Log341Call), - Log342(Log342Call), - Log5(Log5Call), - Log22(Log22Call), - LogAddress(LogAddressCall), - LogBool(LogBoolCall), - LogBytes(LogBytesCall), - LogBytes1(LogBytes1Call), - LogBytes10(LogBytes10Call), - LogBytes11(LogBytes11Call), - LogBytes12(LogBytes12Call), - LogBytes13(LogBytes13Call), - LogBytes14(LogBytes14Call), - LogBytes15(LogBytes15Call), - LogBytes16(LogBytes16Call), - LogBytes17(LogBytes17Call), - LogBytes18(LogBytes18Call), - LogBytes19(LogBytes19Call), - LogBytes2(LogBytes2Call), - LogBytes20(LogBytes20Call), - LogBytes21(LogBytes21Call), - LogBytes22(LogBytes22Call), - LogBytes23(LogBytes23Call), - LogBytes24(LogBytes24Call), - LogBytes25(LogBytes25Call), - LogBytes26(LogBytes26Call), - LogBytes27(LogBytes27Call), - LogBytes28(LogBytes28Call), - LogBytes29(LogBytes29Call), - LogBytes3(LogBytes3Call), - LogBytes30(LogBytes30Call), - LogBytes31(LogBytes31Call), - LogBytes32(LogBytes32Call), - LogBytes4(LogBytes4Call), - LogBytes5(LogBytes5Call), - LogBytes6(LogBytes6Call), - LogBytes7(LogBytes7Call), - LogBytes8(LogBytes8Call), - LogBytes9(LogBytes9Call), - LogInt(LogIntCall), - LogString(LogStringCall), - LogUint(LogUintCall), - } - impl ::ethers_core::abi::AbiDecode for HardhatConsoleCalls { - fn decode( - data: impl AsRef<[u8]>, - ) -> ::core::result::Result { - let data = data.as_ref(); - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log23(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log87(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log24(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log88(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log89(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log90(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log91(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log25(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log92(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log93(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log94(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log95(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log96(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log26(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log97(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log98(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log99(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log100(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log101(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log102(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log27(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log28(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log103(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log29(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log104(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log105(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log106(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log107(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log108(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log109(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log110(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log111(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log30(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log31(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log112(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log113(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log114(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log115(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log116(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log32(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log6(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log117(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log118(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log119(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log120(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log33(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log121(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log34(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log122(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log35(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log123(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log124(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log125(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log126(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log127(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log128(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log129(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log36(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log130(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log131(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log132(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log7(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log133(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log134(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log135(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log136(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log137(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log37(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log138(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log139(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log8(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log140(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log141(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log38(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log142(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log143(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log39(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log144(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log40(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log145(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log146(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log9(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log147(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log148(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log149(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log150(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log151(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log152(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log153(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log154(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log155(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log156(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log157(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log158(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log159(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log160(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log161(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log41(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log162(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log163(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log164(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log165(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log10(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log166(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log42(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log167(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log43(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log168(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log169(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log0(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log170(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log171(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log172(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log173(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log44(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log45(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log174(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log175(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log46(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log176(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log177(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log178(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log47(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log179(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log180(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log181(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log182(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log183(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log184(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log185(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log186(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log187(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log188(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log48(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log189(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log190(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log191(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log49(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log192(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log11(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log193(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log194(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log195(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log196(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log50(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log51(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log197(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log198(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log12(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log199(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log200(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log201(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log202(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log203(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log204(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log205(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log206(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log207(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log208(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log209(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log210(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log52(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log211(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log212(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log213(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log13(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log14(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log214(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log215(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log216(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log53(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log54(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log217(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log218(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log219(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log220(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log221(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log222(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log223(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log224(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log225(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log226(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log227(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log15(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log55(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log16(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log228(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log56(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log229(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log230(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log231(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log232(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log233(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log234(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log235(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log236(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log237(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log238(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log239(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log240(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log241(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log17(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log242(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log243(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log244(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log245(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log246(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log57(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log247(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log248(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log249(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log58(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log59(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log250(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log251(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log252(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log253(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log60(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log254(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log61(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log255(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log256(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log257(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log258(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log259(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log260(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log261(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log262(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log62(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log263(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log264(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log265(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log266(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log267(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log268(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log269(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log270(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log271(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log272(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log273(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log274(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log275(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log276(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log277(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log63(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log64(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log65(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log278(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log279(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log280(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log18(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log66(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log281(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log282(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log283(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log284(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log285(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log67(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log286(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log287(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log288(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log289(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log290(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log291(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log292(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log19(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log68(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log293(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log294(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log295(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log296(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log297(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log69(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log70(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log71(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log72(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log298(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log299(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log300(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log301(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log302(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log73(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log303(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log304(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log74(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log75(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log305(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log306(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log307(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log308(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log309(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log20(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log76(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log310(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log311(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log312(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log313(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log314(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log77(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log315(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log316(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log317(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log78(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log318(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log79(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log319(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log320(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log321(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log322(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log323(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log324(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log80(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log325(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log326(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log81(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log327(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log328(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log329(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log330(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log331(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log82(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log83(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log84(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log332(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log333(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log334(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log21(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log335(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log336(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log4(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log337(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log338(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log339(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log85(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log340(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log86(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log341(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log342(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log5(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::Log22(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogAddress(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBool(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes1(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes10(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes11(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes12(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes13(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes14(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes15(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes16(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes17(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes18(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes19(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes2(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes20(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes21(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes22(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes23(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes24(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes25(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes26(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes27(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes28(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes29(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes3(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes30(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes31(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes32(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes4(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes5(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes6(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes7(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes8(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogBytes9(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogInt(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogString(decoded)); - } - if let Ok(decoded) = ::decode( - data, - ) { - return Ok(Self::LogUint(decoded)); - } - Err(::ethers_core::abi::Error::InvalidData.into()) - } - } - impl ::ethers_core::abi::AbiEncode for HardhatConsoleCalls { - fn encode(self) -> Vec { - match self { - Self::Log23(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log87(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log24(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log88(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log89(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log90(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log91(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log25(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log92(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log93(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log94(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log95(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log96(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log26(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log97(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log98(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log99(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log100(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log101(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log102(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log27(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log28(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log103(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log29(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log104(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log105(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log106(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log107(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log108(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log109(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log110(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log111(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log30(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log31(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log112(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log113(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log114(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log115(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log116(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log32(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log6(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log117(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log118(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log119(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log120(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log33(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log121(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log34(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log122(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log35(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log123(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log124(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log125(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log126(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log127(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log128(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log129(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log36(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log130(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log131(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log132(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log7(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log133(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log134(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log135(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log136(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log1(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log137(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log37(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log138(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log139(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log8(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log2(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log140(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log141(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log38(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log142(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log143(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log39(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log144(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log40(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log145(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log146(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log9(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log147(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log148(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log149(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log150(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log151(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log152(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log153(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log3(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log154(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log155(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log156(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log157(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log158(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log159(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log160(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log161(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log41(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log162(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log163(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log164(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log165(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log10(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log166(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log42(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log167(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log43(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log168(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log169(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log0(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log170(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log171(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log172(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log173(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log44(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log45(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log174(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log175(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log46(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log176(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log177(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log178(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log47(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log179(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log180(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log181(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log182(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log183(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log184(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log185(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log186(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log187(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log188(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log48(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log189(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log190(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log191(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log49(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log192(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log11(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log193(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log194(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log195(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log196(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log50(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log51(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log197(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log198(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log12(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log199(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log200(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log201(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log202(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log203(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log204(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log205(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log206(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log207(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log208(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log209(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log210(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log52(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log211(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log212(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log213(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log13(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log14(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log214(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log215(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log216(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log53(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log54(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log217(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log218(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log219(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log220(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log221(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log222(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log223(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log224(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log225(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log226(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log227(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log15(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log55(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log16(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log228(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log56(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log229(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log230(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log231(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log232(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log233(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log234(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log235(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log236(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log237(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log238(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log239(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log240(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log241(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log17(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log242(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log243(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log244(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log245(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log246(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log57(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log247(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log248(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log249(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log58(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log59(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log250(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log251(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log252(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log253(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log60(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log254(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log61(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log255(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log256(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log257(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log258(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log259(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log260(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log261(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log262(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log62(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log263(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log264(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log265(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log266(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log267(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log268(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log269(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log270(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log271(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log272(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log273(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log274(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log275(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log276(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log277(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log63(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log64(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log65(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log278(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log279(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log280(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log18(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log66(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log281(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log282(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log283(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log284(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log285(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log67(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log286(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log287(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log288(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log289(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log290(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log291(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log292(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log19(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log68(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log293(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log294(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log295(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log296(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log297(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log69(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log70(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log71(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log72(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log298(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log299(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log300(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log301(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log302(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log73(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log303(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log304(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log74(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log75(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log305(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log306(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log307(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log308(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log309(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log20(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log76(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log310(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log311(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log312(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log313(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log314(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log77(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log315(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log316(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log317(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log78(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log318(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log79(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log319(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log320(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log321(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log322(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log323(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log324(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log80(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log325(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log326(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log81(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log327(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log328(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log329(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log330(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log331(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log82(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log83(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log84(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log332(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log333(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log334(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log21(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log335(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log336(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log4(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log337(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log338(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log339(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log85(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log340(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log86(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log341(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log342(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log5(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::Log22(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::LogAddress(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBool(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::LogBytes(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::LogBytes1(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes10(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes11(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes12(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes13(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes14(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes15(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes16(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes17(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes18(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes19(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes2(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes20(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes21(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes22(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes23(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes24(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes25(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes26(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes27(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes28(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes29(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes3(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes30(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes31(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes32(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes4(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes5(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes6(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes7(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes8(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogBytes9(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogInt(element) => ::ethers_core::abi::AbiEncode::encode(element), - Self::LogString(element) => { - ::ethers_core::abi::AbiEncode::encode(element) - } - Self::LogUint(element) => ::ethers_core::abi::AbiEncode::encode(element), - } - } - } - impl ::core::fmt::Display for HardhatConsoleCalls { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Self::Log23(element) => ::core::fmt::Display::fmt(element, f), - Self::Log87(element) => ::core::fmt::Display::fmt(element, f), - Self::Log24(element) => ::core::fmt::Display::fmt(element, f), - Self::Log88(element) => ::core::fmt::Display::fmt(element, f), - Self::Log89(element) => ::core::fmt::Display::fmt(element, f), - Self::Log90(element) => ::core::fmt::Display::fmt(element, f), - Self::Log91(element) => ::core::fmt::Display::fmt(element, f), - Self::Log25(element) => ::core::fmt::Display::fmt(element, f), - Self::Log92(element) => ::core::fmt::Display::fmt(element, f), - Self::Log93(element) => ::core::fmt::Display::fmt(element, f), - Self::Log94(element) => ::core::fmt::Display::fmt(element, f), - Self::Log95(element) => ::core::fmt::Display::fmt(element, f), - Self::Log96(element) => ::core::fmt::Display::fmt(element, f), - Self::Log26(element) => ::core::fmt::Display::fmt(element, f), - Self::Log97(element) => ::core::fmt::Display::fmt(element, f), - Self::Log98(element) => ::core::fmt::Display::fmt(element, f), - Self::Log99(element) => ::core::fmt::Display::fmt(element, f), - Self::Log100(element) => ::core::fmt::Display::fmt(element, f), - Self::Log101(element) => ::core::fmt::Display::fmt(element, f), - Self::Log102(element) => ::core::fmt::Display::fmt(element, f), - Self::Log27(element) => ::core::fmt::Display::fmt(element, f), - Self::Log28(element) => ::core::fmt::Display::fmt(element, f), - Self::Log103(element) => ::core::fmt::Display::fmt(element, f), - Self::Log29(element) => ::core::fmt::Display::fmt(element, f), - Self::Log104(element) => ::core::fmt::Display::fmt(element, f), - Self::Log105(element) => ::core::fmt::Display::fmt(element, f), - Self::Log106(element) => ::core::fmt::Display::fmt(element, f), - Self::Log107(element) => ::core::fmt::Display::fmt(element, f), - Self::Log108(element) => ::core::fmt::Display::fmt(element, f), - Self::Log109(element) => ::core::fmt::Display::fmt(element, f), - Self::Log110(element) => ::core::fmt::Display::fmt(element, f), - Self::Log111(element) => ::core::fmt::Display::fmt(element, f), - Self::Log30(element) => ::core::fmt::Display::fmt(element, f), - Self::Log31(element) => ::core::fmt::Display::fmt(element, f), - Self::Log112(element) => ::core::fmt::Display::fmt(element, f), - Self::Log113(element) => ::core::fmt::Display::fmt(element, f), - Self::Log114(element) => ::core::fmt::Display::fmt(element, f), - Self::Log115(element) => ::core::fmt::Display::fmt(element, f), - Self::Log116(element) => ::core::fmt::Display::fmt(element, f), - Self::Log32(element) => ::core::fmt::Display::fmt(element, f), - Self::Log6(element) => ::core::fmt::Display::fmt(element, f), - Self::Log117(element) => ::core::fmt::Display::fmt(element, f), - Self::Log118(element) => ::core::fmt::Display::fmt(element, f), - Self::Log119(element) => ::core::fmt::Display::fmt(element, f), - Self::Log120(element) => ::core::fmt::Display::fmt(element, f), - Self::Log33(element) => ::core::fmt::Display::fmt(element, f), - Self::Log121(element) => ::core::fmt::Display::fmt(element, f), - Self::Log34(element) => ::core::fmt::Display::fmt(element, f), - Self::Log122(element) => ::core::fmt::Display::fmt(element, f), - Self::Log35(element) => ::core::fmt::Display::fmt(element, f), - Self::Log123(element) => ::core::fmt::Display::fmt(element, f), - Self::Log124(element) => ::core::fmt::Display::fmt(element, f), - Self::Log125(element) => ::core::fmt::Display::fmt(element, f), - Self::Log126(element) => ::core::fmt::Display::fmt(element, f), - Self::Log127(element) => ::core::fmt::Display::fmt(element, f), - Self::Log128(element) => ::core::fmt::Display::fmt(element, f), - Self::Log129(element) => ::core::fmt::Display::fmt(element, f), - Self::Log36(element) => ::core::fmt::Display::fmt(element, f), - Self::Log130(element) => ::core::fmt::Display::fmt(element, f), - Self::Log131(element) => ::core::fmt::Display::fmt(element, f), - Self::Log132(element) => ::core::fmt::Display::fmt(element, f), - Self::Log7(element) => ::core::fmt::Display::fmt(element, f), - Self::Log133(element) => ::core::fmt::Display::fmt(element, f), - Self::Log134(element) => ::core::fmt::Display::fmt(element, f), - Self::Log135(element) => ::core::fmt::Display::fmt(element, f), - Self::Log136(element) => ::core::fmt::Display::fmt(element, f), - Self::Log1(element) => ::core::fmt::Display::fmt(element, f), - Self::Log137(element) => ::core::fmt::Display::fmt(element, f), - Self::Log37(element) => ::core::fmt::Display::fmt(element, f), - Self::Log138(element) => ::core::fmt::Display::fmt(element, f), - Self::Log139(element) => ::core::fmt::Display::fmt(element, f), - Self::Log8(element) => ::core::fmt::Display::fmt(element, f), - Self::Log2(element) => ::core::fmt::Display::fmt(element, f), - Self::Log140(element) => ::core::fmt::Display::fmt(element, f), - Self::Log141(element) => ::core::fmt::Display::fmt(element, f), - Self::Log38(element) => ::core::fmt::Display::fmt(element, f), - Self::Log142(element) => ::core::fmt::Display::fmt(element, f), - Self::Log143(element) => ::core::fmt::Display::fmt(element, f), - Self::Log39(element) => ::core::fmt::Display::fmt(element, f), - Self::Log144(element) => ::core::fmt::Display::fmt(element, f), - Self::Log40(element) => ::core::fmt::Display::fmt(element, f), - Self::Log145(element) => ::core::fmt::Display::fmt(element, f), - Self::Log146(element) => ::core::fmt::Display::fmt(element, f), - Self::Log9(element) => ::core::fmt::Display::fmt(element, f), - Self::Log147(element) => ::core::fmt::Display::fmt(element, f), - Self::Log148(element) => ::core::fmt::Display::fmt(element, f), - Self::Log149(element) => ::core::fmt::Display::fmt(element, f), - Self::Log150(element) => ::core::fmt::Display::fmt(element, f), - Self::Log151(element) => ::core::fmt::Display::fmt(element, f), - Self::Log152(element) => ::core::fmt::Display::fmt(element, f), - Self::Log153(element) => ::core::fmt::Display::fmt(element, f), - Self::Log3(element) => ::core::fmt::Display::fmt(element, f), - Self::Log154(element) => ::core::fmt::Display::fmt(element, f), - Self::Log155(element) => ::core::fmt::Display::fmt(element, f), - Self::Log156(element) => ::core::fmt::Display::fmt(element, f), - Self::Log157(element) => ::core::fmt::Display::fmt(element, f), - Self::Log158(element) => ::core::fmt::Display::fmt(element, f), - Self::Log159(element) => ::core::fmt::Display::fmt(element, f), - Self::Log160(element) => ::core::fmt::Display::fmt(element, f), - Self::Log161(element) => ::core::fmt::Display::fmt(element, f), - Self::Log41(element) => ::core::fmt::Display::fmt(element, f), - Self::Log162(element) => ::core::fmt::Display::fmt(element, f), - Self::Log163(element) => ::core::fmt::Display::fmt(element, f), - Self::Log164(element) => ::core::fmt::Display::fmt(element, f), - Self::Log165(element) => ::core::fmt::Display::fmt(element, f), - Self::Log10(element) => ::core::fmt::Display::fmt(element, f), - Self::Log166(element) => ::core::fmt::Display::fmt(element, f), - Self::Log42(element) => ::core::fmt::Display::fmt(element, f), - Self::Log167(element) => ::core::fmt::Display::fmt(element, f), - Self::Log43(element) => ::core::fmt::Display::fmt(element, f), - Self::Log168(element) => ::core::fmt::Display::fmt(element, f), - Self::Log169(element) => ::core::fmt::Display::fmt(element, f), - Self::Log0(element) => ::core::fmt::Display::fmt(element, f), - Self::Log170(element) => ::core::fmt::Display::fmt(element, f), - Self::Log171(element) => ::core::fmt::Display::fmt(element, f), - Self::Log172(element) => ::core::fmt::Display::fmt(element, f), - Self::Log173(element) => ::core::fmt::Display::fmt(element, f), - Self::Log44(element) => ::core::fmt::Display::fmt(element, f), - Self::Log45(element) => ::core::fmt::Display::fmt(element, f), - Self::Log174(element) => ::core::fmt::Display::fmt(element, f), - Self::Log175(element) => ::core::fmt::Display::fmt(element, f), - Self::Log46(element) => ::core::fmt::Display::fmt(element, f), - Self::Log176(element) => ::core::fmt::Display::fmt(element, f), - Self::Log177(element) => ::core::fmt::Display::fmt(element, f), - Self::Log178(element) => ::core::fmt::Display::fmt(element, f), - Self::Log47(element) => ::core::fmt::Display::fmt(element, f), - Self::Log179(element) => ::core::fmt::Display::fmt(element, f), - Self::Log180(element) => ::core::fmt::Display::fmt(element, f), - Self::Log181(element) => ::core::fmt::Display::fmt(element, f), - Self::Log182(element) => ::core::fmt::Display::fmt(element, f), - Self::Log183(element) => ::core::fmt::Display::fmt(element, f), - Self::Log184(element) => ::core::fmt::Display::fmt(element, f), - Self::Log185(element) => ::core::fmt::Display::fmt(element, f), - Self::Log186(element) => ::core::fmt::Display::fmt(element, f), - Self::Log187(element) => ::core::fmt::Display::fmt(element, f), - Self::Log188(element) => ::core::fmt::Display::fmt(element, f), - Self::Log48(element) => ::core::fmt::Display::fmt(element, f), - Self::Log189(element) => ::core::fmt::Display::fmt(element, f), - Self::Log190(element) => ::core::fmt::Display::fmt(element, f), - Self::Log191(element) => ::core::fmt::Display::fmt(element, f), - Self::Log49(element) => ::core::fmt::Display::fmt(element, f), - Self::Log192(element) => ::core::fmt::Display::fmt(element, f), - Self::Log11(element) => ::core::fmt::Display::fmt(element, f), - Self::Log193(element) => ::core::fmt::Display::fmt(element, f), - Self::Log194(element) => ::core::fmt::Display::fmt(element, f), - Self::Log195(element) => ::core::fmt::Display::fmt(element, f), - Self::Log196(element) => ::core::fmt::Display::fmt(element, f), - Self::Log50(element) => ::core::fmt::Display::fmt(element, f), - Self::Log51(element) => ::core::fmt::Display::fmt(element, f), - Self::Log197(element) => ::core::fmt::Display::fmt(element, f), - Self::Log198(element) => ::core::fmt::Display::fmt(element, f), - Self::Log12(element) => ::core::fmt::Display::fmt(element, f), - Self::Log199(element) => ::core::fmt::Display::fmt(element, f), - Self::Log200(element) => ::core::fmt::Display::fmt(element, f), - Self::Log201(element) => ::core::fmt::Display::fmt(element, f), - Self::Log202(element) => ::core::fmt::Display::fmt(element, f), - Self::Log203(element) => ::core::fmt::Display::fmt(element, f), - Self::Log204(element) => ::core::fmt::Display::fmt(element, f), - Self::Log205(element) => ::core::fmt::Display::fmt(element, f), - Self::Log206(element) => ::core::fmt::Display::fmt(element, f), - Self::Log207(element) => ::core::fmt::Display::fmt(element, f), - Self::Log208(element) => ::core::fmt::Display::fmt(element, f), - Self::Log209(element) => ::core::fmt::Display::fmt(element, f), - Self::Log210(element) => ::core::fmt::Display::fmt(element, f), - Self::Log52(element) => ::core::fmt::Display::fmt(element, f), - Self::Log211(element) => ::core::fmt::Display::fmt(element, f), - Self::Log212(element) => ::core::fmt::Display::fmt(element, f), - Self::Log213(element) => ::core::fmt::Display::fmt(element, f), - Self::Log13(element) => ::core::fmt::Display::fmt(element, f), - Self::Log14(element) => ::core::fmt::Display::fmt(element, f), - Self::Log214(element) => ::core::fmt::Display::fmt(element, f), - Self::Log215(element) => ::core::fmt::Display::fmt(element, f), - Self::Log216(element) => ::core::fmt::Display::fmt(element, f), - Self::Log53(element) => ::core::fmt::Display::fmt(element, f), - Self::Log54(element) => ::core::fmt::Display::fmt(element, f), - Self::Log217(element) => ::core::fmt::Display::fmt(element, f), - Self::Log218(element) => ::core::fmt::Display::fmt(element, f), - Self::Log219(element) => ::core::fmt::Display::fmt(element, f), - Self::Log220(element) => ::core::fmt::Display::fmt(element, f), - Self::Log221(element) => ::core::fmt::Display::fmt(element, f), - Self::Log222(element) => ::core::fmt::Display::fmt(element, f), - Self::Log223(element) => ::core::fmt::Display::fmt(element, f), - Self::Log224(element) => ::core::fmt::Display::fmt(element, f), - Self::Log225(element) => ::core::fmt::Display::fmt(element, f), - Self::Log226(element) => ::core::fmt::Display::fmt(element, f), - Self::Log227(element) => ::core::fmt::Display::fmt(element, f), - Self::Log15(element) => ::core::fmt::Display::fmt(element, f), - Self::Log55(element) => ::core::fmt::Display::fmt(element, f), - Self::Log16(element) => ::core::fmt::Display::fmt(element, f), - Self::Log228(element) => ::core::fmt::Display::fmt(element, f), - Self::Log56(element) => ::core::fmt::Display::fmt(element, f), - Self::Log229(element) => ::core::fmt::Display::fmt(element, f), - Self::Log230(element) => ::core::fmt::Display::fmt(element, f), - Self::Log231(element) => ::core::fmt::Display::fmt(element, f), - Self::Log232(element) => ::core::fmt::Display::fmt(element, f), - Self::Log233(element) => ::core::fmt::Display::fmt(element, f), - Self::Log234(element) => ::core::fmt::Display::fmt(element, f), - Self::Log235(element) => ::core::fmt::Display::fmt(element, f), - Self::Log236(element) => ::core::fmt::Display::fmt(element, f), - Self::Log237(element) => ::core::fmt::Display::fmt(element, f), - Self::Log238(element) => ::core::fmt::Display::fmt(element, f), - Self::Log239(element) => ::core::fmt::Display::fmt(element, f), - Self::Log240(element) => ::core::fmt::Display::fmt(element, f), - Self::Log241(element) => ::core::fmt::Display::fmt(element, f), - Self::Log17(element) => ::core::fmt::Display::fmt(element, f), - Self::Log242(element) => ::core::fmt::Display::fmt(element, f), - Self::Log243(element) => ::core::fmt::Display::fmt(element, f), - Self::Log244(element) => ::core::fmt::Display::fmt(element, f), - Self::Log245(element) => ::core::fmt::Display::fmt(element, f), - Self::Log246(element) => ::core::fmt::Display::fmt(element, f), - Self::Log57(element) => ::core::fmt::Display::fmt(element, f), - Self::Log247(element) => ::core::fmt::Display::fmt(element, f), - Self::Log248(element) => ::core::fmt::Display::fmt(element, f), - Self::Log249(element) => ::core::fmt::Display::fmt(element, f), - Self::Log58(element) => ::core::fmt::Display::fmt(element, f), - Self::Log59(element) => ::core::fmt::Display::fmt(element, f), - Self::Log250(element) => ::core::fmt::Display::fmt(element, f), - Self::Log251(element) => ::core::fmt::Display::fmt(element, f), - Self::Log252(element) => ::core::fmt::Display::fmt(element, f), - Self::Log253(element) => ::core::fmt::Display::fmt(element, f), - Self::Log60(element) => ::core::fmt::Display::fmt(element, f), - Self::Log254(element) => ::core::fmt::Display::fmt(element, f), - Self::Log61(element) => ::core::fmt::Display::fmt(element, f), - Self::Log255(element) => ::core::fmt::Display::fmt(element, f), - Self::Log256(element) => ::core::fmt::Display::fmt(element, f), - Self::Log257(element) => ::core::fmt::Display::fmt(element, f), - Self::Log258(element) => ::core::fmt::Display::fmt(element, f), - Self::Log259(element) => ::core::fmt::Display::fmt(element, f), - Self::Log260(element) => ::core::fmt::Display::fmt(element, f), - Self::Log261(element) => ::core::fmt::Display::fmt(element, f), - Self::Log262(element) => ::core::fmt::Display::fmt(element, f), - Self::Log62(element) => ::core::fmt::Display::fmt(element, f), - Self::Log263(element) => ::core::fmt::Display::fmt(element, f), - Self::Log264(element) => ::core::fmt::Display::fmt(element, f), - Self::Log265(element) => ::core::fmt::Display::fmt(element, f), - Self::Log266(element) => ::core::fmt::Display::fmt(element, f), - Self::Log267(element) => ::core::fmt::Display::fmt(element, f), - Self::Log268(element) => ::core::fmt::Display::fmt(element, f), - Self::Log269(element) => ::core::fmt::Display::fmt(element, f), - Self::Log270(element) => ::core::fmt::Display::fmt(element, f), - Self::Log271(element) => ::core::fmt::Display::fmt(element, f), - Self::Log272(element) => ::core::fmt::Display::fmt(element, f), - Self::Log273(element) => ::core::fmt::Display::fmt(element, f), - Self::Log274(element) => ::core::fmt::Display::fmt(element, f), - Self::Log275(element) => ::core::fmt::Display::fmt(element, f), - Self::Log276(element) => ::core::fmt::Display::fmt(element, f), - Self::Log277(element) => ::core::fmt::Display::fmt(element, f), - Self::Log63(element) => ::core::fmt::Display::fmt(element, f), - Self::Log64(element) => ::core::fmt::Display::fmt(element, f), - Self::Log65(element) => ::core::fmt::Display::fmt(element, f), - Self::Log278(element) => ::core::fmt::Display::fmt(element, f), - Self::Log279(element) => ::core::fmt::Display::fmt(element, f), - Self::Log280(element) => ::core::fmt::Display::fmt(element, f), - Self::Log18(element) => ::core::fmt::Display::fmt(element, f), - Self::Log66(element) => ::core::fmt::Display::fmt(element, f), - Self::Log281(element) => ::core::fmt::Display::fmt(element, f), - Self::Log282(element) => ::core::fmt::Display::fmt(element, f), - Self::Log283(element) => ::core::fmt::Display::fmt(element, f), - Self::Log284(element) => ::core::fmt::Display::fmt(element, f), - Self::Log285(element) => ::core::fmt::Display::fmt(element, f), - Self::Log67(element) => ::core::fmt::Display::fmt(element, f), - Self::Log286(element) => ::core::fmt::Display::fmt(element, f), - Self::Log287(element) => ::core::fmt::Display::fmt(element, f), - Self::Log288(element) => ::core::fmt::Display::fmt(element, f), - Self::Log289(element) => ::core::fmt::Display::fmt(element, f), - Self::Log290(element) => ::core::fmt::Display::fmt(element, f), - Self::Log291(element) => ::core::fmt::Display::fmt(element, f), - Self::Log292(element) => ::core::fmt::Display::fmt(element, f), - Self::Log19(element) => ::core::fmt::Display::fmt(element, f), - Self::Log68(element) => ::core::fmt::Display::fmt(element, f), - Self::Log293(element) => ::core::fmt::Display::fmt(element, f), - Self::Log294(element) => ::core::fmt::Display::fmt(element, f), - Self::Log295(element) => ::core::fmt::Display::fmt(element, f), - Self::Log296(element) => ::core::fmt::Display::fmt(element, f), - Self::Log297(element) => ::core::fmt::Display::fmt(element, f), - Self::Log69(element) => ::core::fmt::Display::fmt(element, f), - Self::Log70(element) => ::core::fmt::Display::fmt(element, f), - Self::Log71(element) => ::core::fmt::Display::fmt(element, f), - Self::Log72(element) => ::core::fmt::Display::fmt(element, f), - Self::Log298(element) => ::core::fmt::Display::fmt(element, f), - Self::Log299(element) => ::core::fmt::Display::fmt(element, f), - Self::Log300(element) => ::core::fmt::Display::fmt(element, f), - Self::Log301(element) => ::core::fmt::Display::fmt(element, f), - Self::Log302(element) => ::core::fmt::Display::fmt(element, f), - Self::Log73(element) => ::core::fmt::Display::fmt(element, f), - Self::Log303(element) => ::core::fmt::Display::fmt(element, f), - Self::Log304(element) => ::core::fmt::Display::fmt(element, f), - Self::Log74(element) => ::core::fmt::Display::fmt(element, f), - Self::Log75(element) => ::core::fmt::Display::fmt(element, f), - Self::Log305(element) => ::core::fmt::Display::fmt(element, f), - Self::Log306(element) => ::core::fmt::Display::fmt(element, f), - Self::Log307(element) => ::core::fmt::Display::fmt(element, f), - Self::Log308(element) => ::core::fmt::Display::fmt(element, f), - Self::Log309(element) => ::core::fmt::Display::fmt(element, f), - Self::Log20(element) => ::core::fmt::Display::fmt(element, f), - Self::Log76(element) => ::core::fmt::Display::fmt(element, f), - Self::Log310(element) => ::core::fmt::Display::fmt(element, f), - Self::Log311(element) => ::core::fmt::Display::fmt(element, f), - Self::Log312(element) => ::core::fmt::Display::fmt(element, f), - Self::Log313(element) => ::core::fmt::Display::fmt(element, f), - Self::Log314(element) => ::core::fmt::Display::fmt(element, f), - Self::Log77(element) => ::core::fmt::Display::fmt(element, f), - Self::Log315(element) => ::core::fmt::Display::fmt(element, f), - Self::Log316(element) => ::core::fmt::Display::fmt(element, f), - Self::Log317(element) => ::core::fmt::Display::fmt(element, f), - Self::Log78(element) => ::core::fmt::Display::fmt(element, f), - Self::Log318(element) => ::core::fmt::Display::fmt(element, f), - Self::Log79(element) => ::core::fmt::Display::fmt(element, f), - Self::Log319(element) => ::core::fmt::Display::fmt(element, f), - Self::Log320(element) => ::core::fmt::Display::fmt(element, f), - Self::Log321(element) => ::core::fmt::Display::fmt(element, f), - Self::Log322(element) => ::core::fmt::Display::fmt(element, f), - Self::Log323(element) => ::core::fmt::Display::fmt(element, f), - Self::Log324(element) => ::core::fmt::Display::fmt(element, f), - Self::Log80(element) => ::core::fmt::Display::fmt(element, f), - Self::Log325(element) => ::core::fmt::Display::fmt(element, f), - Self::Log326(element) => ::core::fmt::Display::fmt(element, f), - Self::Log81(element) => ::core::fmt::Display::fmt(element, f), - Self::Log327(element) => ::core::fmt::Display::fmt(element, f), - Self::Log328(element) => ::core::fmt::Display::fmt(element, f), - Self::Log329(element) => ::core::fmt::Display::fmt(element, f), - Self::Log330(element) => ::core::fmt::Display::fmt(element, f), - Self::Log331(element) => ::core::fmt::Display::fmt(element, f), - Self::Log82(element) => ::core::fmt::Display::fmt(element, f), - Self::Log83(element) => ::core::fmt::Display::fmt(element, f), - Self::Log84(element) => ::core::fmt::Display::fmt(element, f), - Self::Log332(element) => ::core::fmt::Display::fmt(element, f), - Self::Log333(element) => ::core::fmt::Display::fmt(element, f), - Self::Log334(element) => ::core::fmt::Display::fmt(element, f), - Self::Log21(element) => ::core::fmt::Display::fmt(element, f), - Self::Log335(element) => ::core::fmt::Display::fmt(element, f), - Self::Log336(element) => ::core::fmt::Display::fmt(element, f), - Self::Log4(element) => ::core::fmt::Display::fmt(element, f), - Self::Log337(element) => ::core::fmt::Display::fmt(element, f), - Self::Log338(element) => ::core::fmt::Display::fmt(element, f), - Self::Log339(element) => ::core::fmt::Display::fmt(element, f), - Self::Log85(element) => ::core::fmt::Display::fmt(element, f), - Self::Log340(element) => ::core::fmt::Display::fmt(element, f), - Self::Log86(element) => ::core::fmt::Display::fmt(element, f), - Self::Log341(element) => ::core::fmt::Display::fmt(element, f), - Self::Log342(element) => ::core::fmt::Display::fmt(element, f), - Self::Log5(element) => ::core::fmt::Display::fmt(element, f), - Self::Log22(element) => ::core::fmt::Display::fmt(element, f), - Self::LogAddress(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBool(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes1(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes10(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes11(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes12(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes13(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes14(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes15(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes16(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes17(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes18(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes19(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes2(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes20(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes21(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes22(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes23(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes24(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes25(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes26(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes27(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes28(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes29(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes3(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes30(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes31(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes32(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes4(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes5(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes6(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes7(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes8(element) => ::core::fmt::Display::fmt(element, f), - Self::LogBytes9(element) => ::core::fmt::Display::fmt(element, f), - Self::LogInt(element) => ::core::fmt::Display::fmt(element, f), - Self::LogString(element) => ::core::fmt::Display::fmt(element, f), - Self::LogUint(element) => ::core::fmt::Display::fmt(element, f), - } - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log23Call) -> Self { - Self::Log23(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log87Call) -> Self { - Self::Log87(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log24Call) -> Self { - Self::Log24(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log88Call) -> Self { - Self::Log88(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log89Call) -> Self { - Self::Log89(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log90Call) -> Self { - Self::Log90(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log91Call) -> Self { - Self::Log91(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log25Call) -> Self { - Self::Log25(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log92Call) -> Self { - Self::Log92(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log93Call) -> Self { - Self::Log93(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log94Call) -> Self { - Self::Log94(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log95Call) -> Self { - Self::Log95(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log96Call) -> Self { - Self::Log96(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log26Call) -> Self { - Self::Log26(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log97Call) -> Self { - Self::Log97(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log98Call) -> Self { - Self::Log98(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log99Call) -> Self { - Self::Log99(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log100Call) -> Self { - Self::Log100(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log101Call) -> Self { - Self::Log101(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log102Call) -> Self { - Self::Log102(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log27Call) -> Self { - Self::Log27(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log28Call) -> Self { - Self::Log28(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log103Call) -> Self { - Self::Log103(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log29Call) -> Self { - Self::Log29(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log104Call) -> Self { - Self::Log104(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log105Call) -> Self { - Self::Log105(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log106Call) -> Self { - Self::Log106(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log107Call) -> Self { - Self::Log107(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log108Call) -> Self { - Self::Log108(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log109Call) -> Self { - Self::Log109(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log110Call) -> Self { - Self::Log110(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log111Call) -> Self { - Self::Log111(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log30Call) -> Self { - Self::Log30(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log31Call) -> Self { - Self::Log31(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log112Call) -> Self { - Self::Log112(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log113Call) -> Self { - Self::Log113(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log114Call) -> Self { - Self::Log114(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log115Call) -> Self { - Self::Log115(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log116Call) -> Self { - Self::Log116(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log32Call) -> Self { - Self::Log32(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log6Call) -> Self { - Self::Log6(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log117Call) -> Self { - Self::Log117(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log118Call) -> Self { - Self::Log118(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log119Call) -> Self { - Self::Log119(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log120Call) -> Self { - Self::Log120(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log33Call) -> Self { - Self::Log33(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log121Call) -> Self { - Self::Log121(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log34Call) -> Self { - Self::Log34(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log122Call) -> Self { - Self::Log122(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log35Call) -> Self { - Self::Log35(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log123Call) -> Self { - Self::Log123(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log124Call) -> Self { - Self::Log124(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log125Call) -> Self { - Self::Log125(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log126Call) -> Self { - Self::Log126(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log127Call) -> Self { - Self::Log127(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log128Call) -> Self { - Self::Log128(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log129Call) -> Self { - Self::Log129(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log36Call) -> Self { - Self::Log36(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log130Call) -> Self { - Self::Log130(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log131Call) -> Self { - Self::Log131(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log132Call) -> Self { - Self::Log132(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log7Call) -> Self { - Self::Log7(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log133Call) -> Self { - Self::Log133(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log134Call) -> Self { - Self::Log134(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log135Call) -> Self { - Self::Log135(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log136Call) -> Self { - Self::Log136(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log1Call) -> Self { - Self::Log1(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log137Call) -> Self { - Self::Log137(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log37Call) -> Self { - Self::Log37(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log138Call) -> Self { - Self::Log138(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log139Call) -> Self { - Self::Log139(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log8Call) -> Self { - Self::Log8(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log2Call) -> Self { - Self::Log2(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log140Call) -> Self { - Self::Log140(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log141Call) -> Self { - Self::Log141(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log38Call) -> Self { - Self::Log38(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log142Call) -> Self { - Self::Log142(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log143Call) -> Self { - Self::Log143(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log39Call) -> Self { - Self::Log39(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log144Call) -> Self { - Self::Log144(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log40Call) -> Self { - Self::Log40(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log145Call) -> Self { - Self::Log145(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log146Call) -> Self { - Self::Log146(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log9Call) -> Self { - Self::Log9(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log147Call) -> Self { - Self::Log147(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log148Call) -> Self { - Self::Log148(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log149Call) -> Self { - Self::Log149(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log150Call) -> Self { - Self::Log150(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log151Call) -> Self { - Self::Log151(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log152Call) -> Self { - Self::Log152(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log153Call) -> Self { - Self::Log153(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log3Call) -> Self { - Self::Log3(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log154Call) -> Self { - Self::Log154(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log155Call) -> Self { - Self::Log155(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log156Call) -> Self { - Self::Log156(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log157Call) -> Self { - Self::Log157(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log158Call) -> Self { - Self::Log158(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log159Call) -> Self { - Self::Log159(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log160Call) -> Self { - Self::Log160(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log161Call) -> Self { - Self::Log161(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log41Call) -> Self { - Self::Log41(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log162Call) -> Self { - Self::Log162(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log163Call) -> Self { - Self::Log163(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log164Call) -> Self { - Self::Log164(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log165Call) -> Self { - Self::Log165(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log10Call) -> Self { - Self::Log10(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log166Call) -> Self { - Self::Log166(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log42Call) -> Self { - Self::Log42(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log167Call) -> Self { - Self::Log167(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log43Call) -> Self { - Self::Log43(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log168Call) -> Self { - Self::Log168(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log169Call) -> Self { - Self::Log169(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log0Call) -> Self { - Self::Log0(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log170Call) -> Self { - Self::Log170(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log171Call) -> Self { - Self::Log171(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log172Call) -> Self { - Self::Log172(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log173Call) -> Self { - Self::Log173(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log44Call) -> Self { - Self::Log44(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log45Call) -> Self { - Self::Log45(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log174Call) -> Self { - Self::Log174(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log175Call) -> Self { - Self::Log175(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log46Call) -> Self { - Self::Log46(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log176Call) -> Self { - Self::Log176(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log177Call) -> Self { - Self::Log177(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log178Call) -> Self { - Self::Log178(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log47Call) -> Self { - Self::Log47(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log179Call) -> Self { - Self::Log179(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log180Call) -> Self { - Self::Log180(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log181Call) -> Self { - Self::Log181(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log182Call) -> Self { - Self::Log182(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log183Call) -> Self { - Self::Log183(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log184Call) -> Self { - Self::Log184(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log185Call) -> Self { - Self::Log185(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log186Call) -> Self { - Self::Log186(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log187Call) -> Self { - Self::Log187(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log188Call) -> Self { - Self::Log188(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log48Call) -> Self { - Self::Log48(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log189Call) -> Self { - Self::Log189(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log190Call) -> Self { - Self::Log190(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log191Call) -> Self { - Self::Log191(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log49Call) -> Self { - Self::Log49(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log192Call) -> Self { - Self::Log192(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log11Call) -> Self { - Self::Log11(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log193Call) -> Self { - Self::Log193(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log194Call) -> Self { - Self::Log194(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log195Call) -> Self { - Self::Log195(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log196Call) -> Self { - Self::Log196(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log50Call) -> Self { - Self::Log50(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log51Call) -> Self { - Self::Log51(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log197Call) -> Self { - Self::Log197(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log198Call) -> Self { - Self::Log198(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log12Call) -> Self { - Self::Log12(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log199Call) -> Self { - Self::Log199(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log200Call) -> Self { - Self::Log200(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log201Call) -> Self { - Self::Log201(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log202Call) -> Self { - Self::Log202(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log203Call) -> Self { - Self::Log203(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log204Call) -> Self { - Self::Log204(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log205Call) -> Self { - Self::Log205(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log206Call) -> Self { - Self::Log206(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log207Call) -> Self { - Self::Log207(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log208Call) -> Self { - Self::Log208(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log209Call) -> Self { - Self::Log209(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log210Call) -> Self { - Self::Log210(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log52Call) -> Self { - Self::Log52(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log211Call) -> Self { - Self::Log211(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log212Call) -> Self { - Self::Log212(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log213Call) -> Self { - Self::Log213(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log13Call) -> Self { - Self::Log13(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log14Call) -> Self { - Self::Log14(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log214Call) -> Self { - Self::Log214(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log215Call) -> Self { - Self::Log215(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log216Call) -> Self { - Self::Log216(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log53Call) -> Self { - Self::Log53(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log54Call) -> Self { - Self::Log54(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log217Call) -> Self { - Self::Log217(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log218Call) -> Self { - Self::Log218(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log219Call) -> Self { - Self::Log219(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log220Call) -> Self { - Self::Log220(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log221Call) -> Self { - Self::Log221(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log222Call) -> Self { - Self::Log222(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log223Call) -> Self { - Self::Log223(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log224Call) -> Self { - Self::Log224(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log225Call) -> Self { - Self::Log225(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log226Call) -> Self { - Self::Log226(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log227Call) -> Self { - Self::Log227(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log15Call) -> Self { - Self::Log15(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log55Call) -> Self { - Self::Log55(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log16Call) -> Self { - Self::Log16(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log228Call) -> Self { - Self::Log228(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log56Call) -> Self { - Self::Log56(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log229Call) -> Self { - Self::Log229(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log230Call) -> Self { - Self::Log230(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log231Call) -> Self { - Self::Log231(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log232Call) -> Self { - Self::Log232(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log233Call) -> Self { - Self::Log233(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log234Call) -> Self { - Self::Log234(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log235Call) -> Self { - Self::Log235(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log236Call) -> Self { - Self::Log236(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log237Call) -> Self { - Self::Log237(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log238Call) -> Self { - Self::Log238(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log239Call) -> Self { - Self::Log239(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log240Call) -> Self { - Self::Log240(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log241Call) -> Self { - Self::Log241(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log17Call) -> Self { - Self::Log17(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log242Call) -> Self { - Self::Log242(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log243Call) -> Self { - Self::Log243(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log244Call) -> Self { - Self::Log244(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log245Call) -> Self { - Self::Log245(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log246Call) -> Self { - Self::Log246(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log57Call) -> Self { - Self::Log57(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log247Call) -> Self { - Self::Log247(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log248Call) -> Self { - Self::Log248(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log249Call) -> Self { - Self::Log249(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log58Call) -> Self { - Self::Log58(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log59Call) -> Self { - Self::Log59(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log250Call) -> Self { - Self::Log250(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log251Call) -> Self { - Self::Log251(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log252Call) -> Self { - Self::Log252(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log253Call) -> Self { - Self::Log253(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log60Call) -> Self { - Self::Log60(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log254Call) -> Self { - Self::Log254(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log61Call) -> Self { - Self::Log61(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log255Call) -> Self { - Self::Log255(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log256Call) -> Self { - Self::Log256(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log257Call) -> Self { - Self::Log257(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log258Call) -> Self { - Self::Log258(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log259Call) -> Self { - Self::Log259(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log260Call) -> Self { - Self::Log260(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log261Call) -> Self { - Self::Log261(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log262Call) -> Self { - Self::Log262(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log62Call) -> Self { - Self::Log62(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log263Call) -> Self { - Self::Log263(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log264Call) -> Self { - Self::Log264(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log265Call) -> Self { - Self::Log265(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log266Call) -> Self { - Self::Log266(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log267Call) -> Self { - Self::Log267(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log268Call) -> Self { - Self::Log268(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log269Call) -> Self { - Self::Log269(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log270Call) -> Self { - Self::Log270(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log271Call) -> Self { - Self::Log271(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log272Call) -> Self { - Self::Log272(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log273Call) -> Self { - Self::Log273(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log274Call) -> Self { - Self::Log274(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log275Call) -> Self { - Self::Log275(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log276Call) -> Self { - Self::Log276(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log277Call) -> Self { - Self::Log277(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log63Call) -> Self { - Self::Log63(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log64Call) -> Self { - Self::Log64(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log65Call) -> Self { - Self::Log65(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log278Call) -> Self { - Self::Log278(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log279Call) -> Self { - Self::Log279(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log280Call) -> Self { - Self::Log280(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log18Call) -> Self { - Self::Log18(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log66Call) -> Self { - Self::Log66(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log281Call) -> Self { - Self::Log281(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log282Call) -> Self { - Self::Log282(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log283Call) -> Self { - Self::Log283(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log284Call) -> Self { - Self::Log284(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log285Call) -> Self { - Self::Log285(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log67Call) -> Self { - Self::Log67(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log286Call) -> Self { - Self::Log286(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log287Call) -> Self { - Self::Log287(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log288Call) -> Self { - Self::Log288(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log289Call) -> Self { - Self::Log289(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log290Call) -> Self { - Self::Log290(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log291Call) -> Self { - Self::Log291(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log292Call) -> Self { - Self::Log292(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log19Call) -> Self { - Self::Log19(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log68Call) -> Self { - Self::Log68(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log293Call) -> Self { - Self::Log293(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log294Call) -> Self { - Self::Log294(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log295Call) -> Self { - Self::Log295(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log296Call) -> Self { - Self::Log296(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log297Call) -> Self { - Self::Log297(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log69Call) -> Self { - Self::Log69(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log70Call) -> Self { - Self::Log70(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log71Call) -> Self { - Self::Log71(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log72Call) -> Self { - Self::Log72(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log298Call) -> Self { - Self::Log298(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log299Call) -> Self { - Self::Log299(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log300Call) -> Self { - Self::Log300(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log301Call) -> Self { - Self::Log301(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log302Call) -> Self { - Self::Log302(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log73Call) -> Self { - Self::Log73(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log303Call) -> Self { - Self::Log303(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log304Call) -> Self { - Self::Log304(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log74Call) -> Self { - Self::Log74(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log75Call) -> Self { - Self::Log75(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log305Call) -> Self { - Self::Log305(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log306Call) -> Self { - Self::Log306(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log307Call) -> Self { - Self::Log307(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log308Call) -> Self { - Self::Log308(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log309Call) -> Self { - Self::Log309(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log20Call) -> Self { - Self::Log20(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log76Call) -> Self { - Self::Log76(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log310Call) -> Self { - Self::Log310(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log311Call) -> Self { - Self::Log311(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log312Call) -> Self { - Self::Log312(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log313Call) -> Self { - Self::Log313(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log314Call) -> Self { - Self::Log314(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log77Call) -> Self { - Self::Log77(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log315Call) -> Self { - Self::Log315(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log316Call) -> Self { - Self::Log316(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log317Call) -> Self { - Self::Log317(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log78Call) -> Self { - Self::Log78(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log318Call) -> Self { - Self::Log318(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log79Call) -> Self { - Self::Log79(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log319Call) -> Self { - Self::Log319(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log320Call) -> Self { - Self::Log320(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log321Call) -> Self { - Self::Log321(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log322Call) -> Self { - Self::Log322(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log323Call) -> Self { - Self::Log323(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log324Call) -> Self { - Self::Log324(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log80Call) -> Self { - Self::Log80(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log325Call) -> Self { - Self::Log325(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log326Call) -> Self { - Self::Log326(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log81Call) -> Self { - Self::Log81(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log327Call) -> Self { - Self::Log327(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log328Call) -> Self { - Self::Log328(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log329Call) -> Self { - Self::Log329(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log330Call) -> Self { - Self::Log330(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log331Call) -> Self { - Self::Log331(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log82Call) -> Self { - Self::Log82(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log83Call) -> Self { - Self::Log83(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log84Call) -> Self { - Self::Log84(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log332Call) -> Self { - Self::Log332(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log333Call) -> Self { - Self::Log333(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log334Call) -> Self { - Self::Log334(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log21Call) -> Self { - Self::Log21(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log335Call) -> Self { - Self::Log335(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log336Call) -> Self { - Self::Log336(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log4Call) -> Self { - Self::Log4(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log337Call) -> Self { - Self::Log337(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log338Call) -> Self { - Self::Log338(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log339Call) -> Self { - Self::Log339(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log85Call) -> Self { - Self::Log85(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log340Call) -> Self { - Self::Log340(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log86Call) -> Self { - Self::Log86(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log341Call) -> Self { - Self::Log341(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log342Call) -> Self { - Self::Log342(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log5Call) -> Self { - Self::Log5(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: Log22Call) -> Self { - Self::Log22(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogAddressCall) -> Self { - Self::LogAddress(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBoolCall) -> Self { - Self::LogBool(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytesCall) -> Self { - Self::LogBytes(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes1Call) -> Self { - Self::LogBytes1(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes10Call) -> Self { - Self::LogBytes10(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes11Call) -> Self { - Self::LogBytes11(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes12Call) -> Self { - Self::LogBytes12(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes13Call) -> Self { - Self::LogBytes13(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes14Call) -> Self { - Self::LogBytes14(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes15Call) -> Self { - Self::LogBytes15(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes16Call) -> Self { - Self::LogBytes16(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes17Call) -> Self { - Self::LogBytes17(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes18Call) -> Self { - Self::LogBytes18(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes19Call) -> Self { - Self::LogBytes19(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes2Call) -> Self { - Self::LogBytes2(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes20Call) -> Self { - Self::LogBytes20(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes21Call) -> Self { - Self::LogBytes21(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes22Call) -> Self { - Self::LogBytes22(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes23Call) -> Self { - Self::LogBytes23(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes24Call) -> Self { - Self::LogBytes24(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes25Call) -> Self { - Self::LogBytes25(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes26Call) -> Self { - Self::LogBytes26(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes27Call) -> Self { - Self::LogBytes27(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes28Call) -> Self { - Self::LogBytes28(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes29Call) -> Self { - Self::LogBytes29(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes3Call) -> Self { - Self::LogBytes3(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes30Call) -> Self { - Self::LogBytes30(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes31Call) -> Self { - Self::LogBytes31(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes32Call) -> Self { - Self::LogBytes32(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes4Call) -> Self { - Self::LogBytes4(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes5Call) -> Self { - Self::LogBytes5(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes6Call) -> Self { - Self::LogBytes6(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes7Call) -> Self { - Self::LogBytes7(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes8Call) -> Self { - Self::LogBytes8(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogBytes9Call) -> Self { - Self::LogBytes9(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogIntCall) -> Self { - Self::LogInt(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogStringCall) -> Self { - Self::LogString(value) - } - } - impl ::core::convert::From for HardhatConsoleCalls { - fn from(value: LogUintCall) -> Self { - Self::LogUint(value) - } - } -} diff --git a/crates/abi/src/bindings/mod.rs b/crates/abi/src/bindings/mod.rs deleted file mode 100644 index 11f8dfe6ba9df..0000000000000 --- a/crates/abi/src/bindings/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(clippy::all)] -//! This module contains abigen! generated bindings for solidity contracts. -//! This is autogenerated code. -//! Do not manually edit these files. -//! These files may be overwritten by the codegen system at any time. -pub mod console; -pub mod hardhat_console; diff --git a/crates/abi/src/lib.rs b/crates/abi/src/lib.rs deleted file mode 100644 index 3e0cc77cb0fbe..0000000000000 --- a/crates/abi/src/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! Foundry's Solidity ABI bindings. -//! -//! Automatically generated by [abigen](ethers_contract::abigen). -//! -//! **WARNING** -//! This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future. -//! Please avoid making any changes in this crate. - -#![warn(unused_crate_dependencies)] - -mod bindings; - -pub use bindings::{console, hardhat_console}; diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 688af2c4c6304..32433115de090 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -91,8 +91,7 @@ impl StorageArgs { // No slot was provided // Get deployed bytecode at given address - let address_code: alloy_primitives::Bytes = - provider.get_code(address.clone(), block).await?.0.into(); + let address_code = provider.get_code(address.clone(), block).await?.to_alloy(); if address_code.is_empty() { eyre::bail!("Provided address has no deployed code and thus no storage"); } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 8de06a79211a3..177027f054ca0 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -13,7 +13,7 @@ repository.workspace = true foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-compilers.workspace = true foundry-config.workspace = true -foundry-macros.workspace = true +foundry-utils.workspace = true ethers-core.workspace = true ethers-middleware.workspace = true @@ -46,4 +46,6 @@ walkdir = "2" yansi = "0.5" [dev-dependencies] +foundry-macros.workspace = true +pretty_assertions.workspace = true tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/crates/macros/src/fmt/console_fmt.rs b/crates/common/src/fmt/console.rs similarity index 64% rename from crates/macros/src/fmt/console_fmt.rs rename to crates/common/src/fmt/console.rs index ed5f05b1e5931..e4b33c5cd957c 100644 --- a/crates/macros/src/fmt/console_fmt.rs +++ b/crates/common/src/fmt/console.rs @@ -1,5 +1,5 @@ use super::UIfmt; -use ethers_core::types::{Address, Bytes, H256, I256, U256}; +use alloy_primitives::{Address, Bytes, FixedBytes, I256, U256}; /// A format specifier. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] @@ -71,10 +71,13 @@ impl ConsoleFmt for U256 { FormatSpec::String | FormatSpec::Object | FormatSpec::Number | FormatSpec::Integer => { self.pretty() } - FormatSpec::Hexadecimal => format!("0x{:x}", *self), + FormatSpec::Hexadecimal => { + let hex = format!("{self:x}"); + format!("0x{}", hex.trim_start_matches('0')) + } FormatSpec::Exponential => { let log = self.pretty().len() - 1; - let exp10 = U256::exp10(log); + let exp10 = U256::from(10).pow(U256::from(log)); let amount = *self; let integer = amount / exp10; let decimal = (amount % exp10).to_string(); @@ -95,7 +98,10 @@ impl ConsoleFmt for I256 { FormatSpec::String | FormatSpec::Object | FormatSpec::Number | FormatSpec::Integer => { self.pretty() } - FormatSpec::Hexadecimal => format!("0x{:x}", *self), + FormatSpec::Hexadecimal => { + let hex = format!("{self:x}"); + format!("0x{}", hex.trim_start_matches('0')) + } FormatSpec::Exponential => { let amount = *self; let sign = if amount.is_negative() { "-" } else { "" }; @@ -118,10 +124,10 @@ impl ConsoleFmt for I256 { } } -impl ConsoleFmt for H256 { +impl ConsoleFmt for Address { fn fmt(&self, spec: FormatSpec) -> String { match spec { - FormatSpec::Hexadecimal | FormatSpec::String => self.pretty(), + FormatSpec::String | FormatSpec::Hexadecimal => self.pretty(), FormatSpec::Object => format!("'{}'", self.pretty()), FormatSpec::Number | FormatSpec::Integer | FormatSpec::Exponential => { String::from("NaN") @@ -130,35 +136,39 @@ impl ConsoleFmt for H256 { } } -impl ConsoleFmt for Address { +impl ConsoleFmt for Vec { fn fmt(&self, spec: FormatSpec) -> String { - match spec { - FormatSpec::String => self.pretty(), - FormatSpec::Object => format!("'{}'", self.pretty()), - FormatSpec::Number | - FormatSpec::Integer | - FormatSpec::Exponential | - FormatSpec::Hexadecimal => String::from("NaN"), - } + self[..].fmt(spec) } } impl ConsoleFmt for Bytes { fn fmt(&self, spec: FormatSpec) -> String { - match spec { - FormatSpec::String => self.pretty(), - FormatSpec::Object => format!("'{}'", self.pretty()), - FormatSpec::Number | - FormatSpec::Integer | - FormatSpec::Exponential | - FormatSpec::Hexadecimal => String::from("NaN"), - } + self[..].fmt(spec) } } impl ConsoleFmt for [u8; N] { - fn fmt(&self, _spec: FormatSpec) -> String { - self.pretty() + fn fmt(&self, spec: FormatSpec) -> String { + self[..].fmt(spec) + } +} + +impl ConsoleFmt for FixedBytes { + fn fmt(&self, spec: FormatSpec) -> String { + self[..].fmt(spec) + } +} + +impl ConsoleFmt for [u8] { + fn fmt(&self, spec: FormatSpec) -> String { + match spec { + FormatSpec::String | FormatSpec::Hexadecimal => self.pretty(), + FormatSpec::Object => format!("'{}'", self.pretty()), + FormatSpec::Number | FormatSpec::Integer | FormatSpec::Exponential => { + String::from("NaN") + } + } } } @@ -181,17 +191,14 @@ impl ConsoleFmt for [u8; N] { /// If there are more format specifiers than values, then the remaining unparsed format specifiers /// appended to the formatted output as-is. /// -/// # Example +/// # Examples /// -/// ```ignore -/// let formatted = console_format("%s has %d characters", ["foo", 3]); +/// ```ignore (not implemented for integers) +/// let formatted = foundry_common::fmt::console_format("%s has %d characters", &[&"foo", &3]); /// assert_eq!(formatted, "foo has 3 characters"); /// ``` -pub fn console_format<'a>( - spec: &str, - values: impl IntoIterator, -) -> String { - let mut values = values.into_iter(); +pub fn console_format(spec: &str, values: &[&dyn ConsoleFmt]) -> String { + let mut values = values.iter().copied(); let mut result = String::with_capacity(spec.len()); // for the first space @@ -260,28 +267,26 @@ fn format_spec<'a>( #[cfg(test)] mod tests { use super::*; - use crate::ConsoleFmt; + use alloy_primitives::B256; + use foundry_macros::ConsoleFmt; use std::str::FromStr; macro_rules! logf1 { - ($a:ident) => {{ - let args: [&dyn ConsoleFmt; 1] = [&$a.p_1]; - console_format(&$a.p_0, args) - }}; + ($a:ident) => { + console_format(&$a.p_0, &[&$a.p_1]) + }; } macro_rules! logf2 { - ($a:ident) => {{ - let args: [&dyn ConsoleFmt; 2] = [&$a.p_1, &$a.p_2]; - console_format(&$a.p_0, args) - }}; + ($a:ident) => { + console_format(&$a.p_0, &[&$a.p_1, &$a.p_2]) + }; } macro_rules! logf3 { - ($a:ident) => {{ - let args: [&dyn ConsoleFmt; 3] = [&$a.p_1, &$a.p_2, &$a.p_3]; - console_format(&$a.p_0, args) - }}; + ($a:ident) => { + console_format(&$a.p_0, &[&$a.p_1, &$a.p_2, &$a.p_3]) + }; } #[derive(Clone, Debug, ConsoleFmt)] @@ -315,86 +320,88 @@ mod tests { #[test] fn test_console_log_format_specifiers() { - let console_log_format_1 = |spec: &str, arg: &dyn ConsoleFmt| { - let args: [&dyn ConsoleFmt; 1] = [arg]; - console_format(spec, args) - }; - - assert_eq!("foo", console_log_format_1("%s", &String::from("foo"))); - assert_eq!("NaN", console_log_format_1("%d", &String::from("foo"))); - assert_eq!("NaN", console_log_format_1("%i", &String::from("foo"))); - assert_eq!("NaN", console_log_format_1("%e", &String::from("foo"))); - assert_eq!("NaN", console_log_format_1("%x", &String::from("foo"))); - assert_eq!("'foo'", console_log_format_1("%o", &String::from("foo"))); - assert_eq!("%s foo", console_log_format_1("%%s", &String::from("foo"))); - assert_eq!("% foo", console_log_format_1("%", &String::from("foo"))); - assert_eq!("% foo", console_log_format_1("%%", &String::from("foo"))); - - assert_eq!("true", console_log_format_1("%s", &true)); - assert_eq!("1", console_log_format_1("%d", &true)); - assert_eq!("0", console_log_format_1("%d", &false)); - assert_eq!("NaN", console_log_format_1("%i", &true)); - assert_eq!("NaN", console_log_format_1("%e", &true)); - assert_eq!("NaN", console_log_format_1("%x", &true)); - assert_eq!("'true'", console_log_format_1("%o", &true)); + let fmt_1 = |spec: &str, arg: &dyn ConsoleFmt| console_format(spec, &[arg]); + + assert_eq!("foo", fmt_1("%s", &String::from("foo"))); + assert_eq!("NaN", fmt_1("%d", &String::from("foo"))); + assert_eq!("NaN", fmt_1("%i", &String::from("foo"))); + assert_eq!("NaN", fmt_1("%e", &String::from("foo"))); + assert_eq!("NaN", fmt_1("%x", &String::from("foo"))); + assert_eq!("'foo'", fmt_1("%o", &String::from("foo"))); + assert_eq!("%s foo", fmt_1("%%s", &String::from("foo"))); + assert_eq!("% foo", fmt_1("%", &String::from("foo"))); + assert_eq!("% foo", fmt_1("%%", &String::from("foo"))); + + assert_eq!("true", fmt_1("%s", &true)); + assert_eq!("1", fmt_1("%d", &true)); + assert_eq!("0", fmt_1("%d", &false)); + assert_eq!("NaN", fmt_1("%i", &true)); + assert_eq!("NaN", fmt_1("%e", &true)); + assert_eq!("NaN", fmt_1("%x", &true)); + assert_eq!("'true'", fmt_1("%o", &true)); let b32 = - H256::from_str("0xdeadbeef00000000000000000000000000000000000000000000000000000000") + B256::from_str("0xdeadbeef00000000000000000000000000000000000000000000000000000000") .unwrap(); assert_eq!( "0xdeadbeef00000000000000000000000000000000000000000000000000000000", - console_log_format_1("%s", &b32) + fmt_1("%s", &b32) ); assert_eq!( "0xdeadbeef00000000000000000000000000000000000000000000000000000000", - console_log_format_1("%x", &b32) + fmt_1("%x", &b32) ); - assert_eq!("NaN", console_log_format_1("%d", &b32)); - assert_eq!("NaN", console_log_format_1("%i", &b32)); - assert_eq!("NaN", console_log_format_1("%e", &b32)); + assert_eq!("NaN", fmt_1("%d", &b32)); + assert_eq!("NaN", fmt_1("%i", &b32)); + assert_eq!("NaN", fmt_1("%e", &b32)); assert_eq!( "'0xdeadbeef00000000000000000000000000000000000000000000000000000000'", - console_log_format_1("%o", &b32) + fmt_1("%o", &b32) ); let addr = Address::from_str("0xdEADBEeF00000000000000000000000000000000").unwrap(); - assert_eq!("0xdEADBEeF00000000000000000000000000000000", console_log_format_1("%s", &addr)); - assert_eq!("NaN", console_log_format_1("%d", &addr)); - assert_eq!("NaN", console_log_format_1("%i", &addr)); - assert_eq!("NaN", console_log_format_1("%e", &addr)); - assert_eq!("NaN", console_log_format_1("%x", &addr)); - assert_eq!( - "'0xdEADBEeF00000000000000000000000000000000'", - console_log_format_1("%o", &addr) - ); + assert_eq!("0xdEADBEeF00000000000000000000000000000000", fmt_1("%s", &addr)); + assert_eq!("NaN", fmt_1("%d", &addr)); + assert_eq!("NaN", fmt_1("%i", &addr)); + assert_eq!("NaN", fmt_1("%e", &addr)); + assert_eq!("0xdEADBEeF00000000000000000000000000000000", fmt_1("%x", &addr)); + assert_eq!("'0xdEADBEeF00000000000000000000000000000000'", fmt_1("%o", &addr)); let bytes = Bytes::from_str("0xdeadbeef").unwrap(); - assert_eq!("0xdeadbeef", console_log_format_1("%s", &bytes)); - assert_eq!("NaN", console_log_format_1("%d", &bytes)); - assert_eq!("NaN", console_log_format_1("%i", &bytes)); - assert_eq!("NaN", console_log_format_1("%e", &bytes)); - assert_eq!("NaN", console_log_format_1("%x", &bytes)); - assert_eq!("'0xdeadbeef'", console_log_format_1("%o", &bytes)); - - assert_eq!("100", console_log_format_1("%s", &U256::from(100))); - assert_eq!("100", console_log_format_1("%d", &U256::from(100))); - assert_eq!("100", console_log_format_1("%i", &U256::from(100))); - assert_eq!("1e2", console_log_format_1("%e", &U256::from(100))); - assert_eq!("1.0023e6", console_log_format_1("%e", &U256::from(1002300))); - assert_eq!("1.23e5", console_log_format_1("%e", &U256::from(123000))); - assert_eq!("0x64", console_log_format_1("%x", &U256::from(100))); - assert_eq!("100", console_log_format_1("%o", &U256::from(100))); - - assert_eq!("100", console_log_format_1("%s", &I256::from(100))); - assert_eq!("100", console_log_format_1("%d", &I256::from(100))); - assert_eq!("100", console_log_format_1("%i", &I256::from(100))); - assert_eq!("1e2", console_log_format_1("%e", &I256::from(100))); - assert_eq!("-1.0023e6", console_log_format_1("%e", &I256::from(-1002300))); - assert_eq!("-1.23e5", console_log_format_1("%e", &I256::from(-123000))); - assert_eq!("1.0023e6", console_log_format_1("%e", &I256::from(1002300))); - assert_eq!("1.23e5", console_log_format_1("%e", &I256::from(123000))); - assert_eq!("0x64", console_log_format_1("%x", &I256::from(100))); - assert_eq!("100", console_log_format_1("%o", &I256::from(100))); + assert_eq!("0xdeadbeef", fmt_1("%s", &bytes)); + assert_eq!("NaN", fmt_1("%d", &bytes)); + assert_eq!("NaN", fmt_1("%i", &bytes)); + assert_eq!("NaN", fmt_1("%e", &bytes)); + assert_eq!("0xdeadbeef", fmt_1("%x", &bytes)); + assert_eq!("'0xdeadbeef'", fmt_1("%o", &bytes)); + + assert_eq!("100", fmt_1("%s", &U256::from(100))); + assert_eq!("100", fmt_1("%d", &U256::from(100))); + assert_eq!("100", fmt_1("%i", &U256::from(100))); + assert_eq!("1e2", fmt_1("%e", &U256::from(100))); + assert_eq!("1.0023e6", fmt_1("%e", &U256::from(1002300))); + assert_eq!("1.23e5", fmt_1("%e", &U256::from(123000))); + assert_eq!("0x64", fmt_1("%x", &U256::from(100))); + assert_eq!("100", fmt_1("%o", &U256::from(100))); + + assert_eq!("100", fmt_1("%s", &I256::try_from(100).unwrap())); + assert_eq!("100", fmt_1("%d", &I256::try_from(100).unwrap())); + assert_eq!("100", fmt_1("%i", &I256::try_from(100).unwrap())); + assert_eq!("1e2", fmt_1("%e", &I256::try_from(100).unwrap())); + assert_eq!("-1.0023e6", fmt_1("%e", &I256::try_from(-1002300).unwrap())); + assert_eq!("-1.23e5", fmt_1("%e", &I256::try_from(-123000).unwrap())); + assert_eq!("1.0023e6", fmt_1("%e", &I256::try_from(1002300).unwrap())); + assert_eq!("1.23e5", fmt_1("%e", &I256::try_from(123000).unwrap())); + assert_eq!("0x64", fmt_1("%x", &I256::try_from(100).unwrap())); + assert_eq!( + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9c", + fmt_1("%x", &I256::try_from(-100).unwrap()) + ); + assert_eq!( + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffe8b7891800", + fmt_1("%x", &I256::try_from(-100000000000i64).unwrap()) + ); + assert_eq!("100", fmt_1("%o", &I256::try_from(100).unwrap())); } #[test] diff --git a/crates/common/src/fmt.rs b/crates/common/src/fmt/dynamic.rs similarity index 57% rename from crates/common/src/fmt.rs rename to crates/common/src/fmt/dynamic.rs index 321239ccebb86..2e30f2f7e5ee5 100644 --- a/crates/common/src/fmt.rs +++ b/crates/common/src/fmt/dynamic.rs @@ -1,13 +1,8 @@ -//! Helpers for formatting ethereum types - -use crate::{calc::to_exp_notation, TransactionReceiptWithRevertReason}; +use super::{format_int_exp, format_uint_exp}; use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::{hex, Sign, I256, U256}; +use alloy_primitives::hex; use eyre::Result; use std::fmt; -use yansi::Paint; - -pub use foundry_macros::fmt::*; /// [`DynSolValue`] formatter. struct DynValueFormatter { @@ -144,117 +139,10 @@ pub fn format_token_raw(value: &DynSolValue) -> String { DynValueDisplay::new(value, true).to_string() } -/// Formats a U256 number to string, adding an exponential notation _hint_ if it -/// is larger than `10_000`, with a precision of `4` figures, and trimming the -/// trailing zeros. -/// -/// # Examples -/// -/// ``` -/// use alloy_primitives::U256; -/// use foundry_common::fmt::format_uint_exp as f; -/// -/// # yansi::Paint::disable(); -/// assert_eq!(f(U256::from(0)), "0"); -/// assert_eq!(f(U256::from(1234)), "1234"); -/// assert_eq!(f(U256::from(1234567890)), "1234567890 [1.234e9]"); -/// assert_eq!(f(U256::from(1000000000000000000_u128)), "1000000000000000000 [1e18]"); -/// assert_eq!(f(U256::from(10000000000000000000000_u128)), "10000000000000000000000 [1e22]"); -/// ``` -pub fn format_uint_exp(num: U256) -> String { - if num < U256::from(10_000) { - return num.to_string() - } - - let exp = to_exp_notation(num, 4, true, Sign::Positive); - format!("{num} {}", Paint::default(format!("[{exp}]")).dimmed()) -} - -/// Formats a U256 number to string, adding an exponential notation _hint_. -/// -/// Same as [`format_uint_exp`]. -/// -/// # Examples -/// -/// ``` -/// use alloy_primitives::I256; -/// use foundry_common::fmt::format_int_exp as f; -/// -/// # yansi::Paint::disable(); -/// assert_eq!(f(I256::try_from(0).unwrap()), "0"); -/// assert_eq!(f(I256::try_from(-1).unwrap()), "-1"); -/// assert_eq!(f(I256::try_from(1234).unwrap()), "1234"); -/// assert_eq!(f(I256::try_from(1234567890).unwrap()), "1234567890 [1.234e9]"); -/// assert_eq!(f(I256::try_from(-1234567890).unwrap()), "-1234567890 [-1.234e9]"); -/// assert_eq!(f(I256::try_from(1000000000000000000_u128).unwrap()), "1000000000000000000 [1e18]"); -/// assert_eq!( -/// f(I256::try_from(10000000000000000000000_u128).unwrap()), -/// "10000000000000000000000 [1e22]" -/// ); -/// assert_eq!( -/// f(I256::try_from(-10000000000000000000000_i128).unwrap()), -/// "-10000000000000000000000 [-1e22]" -/// ); -/// ``` -pub fn format_int_exp(num: I256) -> String { - let (sign, abs) = num.into_sign_and_abs(); - if abs < U256::from(10_000) { - return format!("{sign}{abs}"); - } - - let exp = to_exp_notation(abs, 4, true, sign); - format!("{sign}{abs} {}", Paint::default(format!("[{exp}]")).dimmed()) -} - -impl UIfmt for TransactionReceiptWithRevertReason { - fn pretty(&self) -> String { - if let Some(revert_reason) = &self.revert_reason { - format!( - "{} -revertReason {}", - self.receipt.pretty(), - revert_reason - ) - } else { - self.receipt.pretty() - } - } -} - -/// Returns the ``UiFmt::pretty()` formatted attribute of the transaction receipt -pub fn get_pretty_tx_receipt_attr( - receipt: &TransactionReceiptWithRevertReason, - attr: &str, -) -> Option { - match attr { - "blockHash" | "block_hash" => Some(receipt.receipt.block_hash.pretty()), - "blockNumber" | "block_number" => Some(receipt.receipt.block_number.pretty()), - "contractAddress" | "contract_address" => Some(receipt.receipt.contract_address.pretty()), - "cumulativeGasUsed" | "cumulative_gas_used" => { - Some(receipt.receipt.cumulative_gas_used.pretty()) - } - "effectiveGasPrice" | "effective_gas_price" => { - Some(receipt.receipt.effective_gas_price.pretty()) - } - "gasUsed" | "gas_used" => Some(receipt.receipt.gas_used.pretty()), - "logs" => Some(receipt.receipt.logs.pretty()), - "logsBloom" | "logs_bloom" => Some(receipt.receipt.logs_bloom.pretty()), - "root" => Some(receipt.receipt.root.pretty()), - "status" => Some(receipt.receipt.status.pretty()), - "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), - "transactionIndex" | "transaction_index" => { - Some(receipt.receipt.transaction_index.pretty()) - } - "type" | "transaction_type" => Some(receipt.receipt.transaction_type.pretty()), - "revertReason" | "revert_reason" => Some(receipt.revert_reason.pretty()), - _ => None, - } -} - #[cfg(test)] mod tests { use super::*; - use alloy_primitives::address; + use alloy_primitives::{address, U256}; #[test] fn parse_hex_uint() { diff --git a/crates/common/src/fmt/mod.rs b/crates/common/src/fmt/mod.rs new file mode 100644 index 0000000000000..fbe1670fc6cbc --- /dev/null +++ b/crates/common/src/fmt/mod.rs @@ -0,0 +1,76 @@ +//! Helpers for formatting Ethereum types. + +use crate::calc::to_exp_notation; +use alloy_primitives::{Sign, I256, U256}; +use yansi::Paint; + +mod console; +pub use console::{console_format, ConsoleFmt, FormatSpec}; + +mod dynamic; +pub use dynamic::{format_token, format_token_raw, format_tokens, parse_tokens}; + +mod ui; +pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, get_pretty_tx_receipt_attr, UIfmt}; + +/// Formats a U256 number to string, adding an exponential notation _hint_ if it +/// is larger than `10_000`, with a precision of `4` figures, and trimming the +/// trailing zeros. +/// +/// # Examples +/// +/// ``` +/// use alloy_primitives::U256; +/// use foundry_common::fmt::format_uint_exp as f; +/// +/// # yansi::Paint::disable(); +/// assert_eq!(f(U256::from(0)), "0"); +/// assert_eq!(f(U256::from(1234)), "1234"); +/// assert_eq!(f(U256::from(1234567890)), "1234567890 [1.234e9]"); +/// assert_eq!(f(U256::from(1000000000000000000_u128)), "1000000000000000000 [1e18]"); +/// assert_eq!(f(U256::from(10000000000000000000000_u128)), "10000000000000000000000 [1e22]"); +/// ``` +pub fn format_uint_exp(num: U256) -> String { + if num < U256::from(10_000) { + return num.to_string() + } + + let exp = to_exp_notation(num, 4, true, Sign::Positive); + format!("{num} {}", Paint::default(format!("[{exp}]")).dimmed()) +} + +/// Formats a U256 number to string, adding an exponential notation _hint_. +/// +/// Same as [`format_uint_exp`]. +/// +/// # Examples +/// +/// ``` +/// use alloy_primitives::I256; +/// use foundry_common::fmt::format_int_exp as f; +/// +/// # yansi::Paint::disable(); +/// assert_eq!(f(I256::try_from(0).unwrap()), "0"); +/// assert_eq!(f(I256::try_from(-1).unwrap()), "-1"); +/// assert_eq!(f(I256::try_from(1234).unwrap()), "1234"); +/// assert_eq!(f(I256::try_from(1234567890).unwrap()), "1234567890 [1.234e9]"); +/// assert_eq!(f(I256::try_from(-1234567890).unwrap()), "-1234567890 [-1.234e9]"); +/// assert_eq!(f(I256::try_from(1000000000000000000_u128).unwrap()), "1000000000000000000 [1e18]"); +/// assert_eq!( +/// f(I256::try_from(10000000000000000000000_u128).unwrap()), +/// "10000000000000000000000 [1e22]" +/// ); +/// assert_eq!( +/// f(I256::try_from(-10000000000000000000000_i128).unwrap()), +/// "-10000000000000000000000 [-1e22]" +/// ); +/// ``` +pub fn format_int_exp(num: I256) -> String { + let (sign, abs) = num.into_sign_and_abs(); + if abs < U256::from(10_000) { + return format!("{sign}{abs}"); + } + + let exp = to_exp_notation(abs, 4, true, sign); + format!("{sign}{abs} {}", Paint::default(format!("[{exp}]")).dimmed()) +} diff --git a/crates/macros/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs similarity index 87% rename from crates/macros/src/fmt/ui.rs rename to crates/common/src/fmt/ui.rs index f2bec35912139..ef31df85792d8 100644 --- a/crates/macros/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -1,20 +1,20 @@ -//! Helper trait and functions to format ethers types. +//! Helper trait and functions to format Ethereum types. -use ethers_core::{ - types::*, - utils::{hex, to_checksum}, -}; +use crate::TransactionReceiptWithRevertReason; +use alloy_primitives::*; +use ethers_core::types::{Block, Log, OtherFields, Transaction, TransactionReceipt, TxHash}; use serde::Deserialize; /// length of the name column for pretty formatting `{:>20}{value}` const NAME_COLUMN_LEN: usize = 20usize; -/// Helper trait to format ethers types. +/// Helper trait to format Ethereum types. /// /// # Examples /// /// ``` -/// use foundry_macros::fmt::UIfmt; +/// use foundry_common::fmt::UIfmt; +/// /// let boolean: bool = true; /// let string = boolean.pretty(); /// ``` @@ -23,11 +23,42 @@ pub trait UIfmt { fn pretty(&self) -> String; } +impl UIfmt for Option { + fn pretty(&self) -> String { + if let Some(ref inner) = self { + inner.pretty() + } else { + String::new() + } + } +} + +impl UIfmt for Vec { + fn pretty(&self) -> String { + if !self.is_empty() { + let mut s = String::with_capacity(self.len() * 64); + s.push_str("[\n"); + for item in self { + for line in item.pretty().lines() { + s.push('\t'); + s.push_str(line); + s.push('\n'); + } + } + s.push(']'); + s + } else { + "[]".to_string() + } + } +} + impl UIfmt for String { fn pretty(&self) -> String { self.to_string() } } + impl UIfmt for bool { fn pretty(&self) -> String { self.to_string() @@ -39,6 +70,7 @@ impl UIfmt for U256 { self.to_string() } } + impl UIfmt for I256 { fn pretty(&self) -> String { self.to_string() @@ -47,73 +79,49 @@ impl UIfmt for I256 { impl UIfmt for Address { fn pretty(&self) -> String { - to_checksum(self, None) + self.to_string() } } -impl UIfmt for H64 { +impl UIfmt for Bloom { fn pretty(&self) -> String { - format!("{self:#x}") + self.to_string() } } -impl UIfmt for H256 { +impl UIfmt for Vec { fn pretty(&self) -> String { - format!("{self:#x}") + self[..].pretty() } } impl UIfmt for Bytes { fn pretty(&self) -> String { - format!("{self:#x}") + self[..].pretty() } } impl UIfmt for [u8; N] { fn pretty(&self) -> String { - hex::encode_prefixed(&self[..]) + self[..].pretty() } } -impl UIfmt for U64 { +impl UIfmt for FixedBytes { fn pretty(&self) -> String { - self.to_string() + self[..].pretty() } } -impl UIfmt for Bloom { +impl UIfmt for [u8] { fn pretty(&self) -> String { - format!("{self:#x}") + hex::encode_prefixed(self) } } -impl UIfmt for Option { - fn pretty(&self) -> String { - if let Some(ref inner) = self { - inner.pretty() - } else { - String::new() - } - } -} - -impl UIfmt for Vec { +impl UIfmt for U64 { fn pretty(&self) -> String { - if !self.is_empty() { - let mut s = String::with_capacity(self.len() * 64); - s.push_str("[\n"); - for item in self { - for line in item.pretty().lines() { - s.push('\t'); - s.push_str(line); - s.push('\n'); - } - } - s.push(']'); - s - } else { - "[]".to_string() - } + self.to_string() } } @@ -201,53 +209,6 @@ transactions: {}", } } -fn pretty_block_basics(block: &Block) -> String { - format!( - " -baseFeePerGas {} -difficulty {} -extraData {} -gasLimit {} -gasUsed {} -hash {} -logsBloom {} -miner {} -mixHash {} -nonce {} -number {} -parentHash {} -receiptsRoot {} -sealFields {} -sha3Uncles {} -size {} -stateRoot {} -timestamp {} -withdrawalsRoot {} -totalDifficulty {}{}", - block.base_fee_per_gas.pretty(), - block.difficulty.pretty(), - block.extra_data.pretty(), - block.gas_limit.pretty(), - block.gas_used.pretty(), - block.hash.pretty(), - block.logs_bloom.pretty(), - block.author.pretty(), - block.mix_hash.pretty(), - block.nonce.pretty(), - block.number.pretty(), - block.parent_hash.pretty(), - block.receipts_root.pretty(), - block.seal_fields.pretty(), - block.uncles_hash.pretty(), - block.size.pretty(), - block.state_root.pretty(), - block.timestamp.pretty(), - block.withdrawals_root.pretty(), - block.total_difficulty.pretty(), - block.other.pretty() - ) -} - impl UIfmt for OtherFields { fn pretty(&self) -> String { let mut s = String::with_capacity(self.len() * 30); @@ -266,36 +227,6 @@ impl UIfmt for OtherFields { } } -/// Various numerical ethereum types used for pretty printing -#[derive(Debug, Clone, Deserialize)] -#[serde(untagged)] -#[allow(missing_docs)] -pub enum EthValue { - U64(U64), - U256(U256), - U64Array(Vec), - U256Array(Vec), - Other(serde_json::Value), -} - -impl From for EthValue { - fn from(val: serde_json::Value) -> Self { - serde_json::from_value(val).expect("infallible") - } -} - -impl UIfmt for EthValue { - fn pretty(&self) -> String { - match self { - EthValue::U64(num) => num.pretty(), - EthValue::U256(num) => num.pretty(), - EthValue::U64Array(arr) => arr.pretty(), - EthValue::U256Array(arr) => arr.pretty(), - EthValue::Other(val) => val.to_string().trim_matches('"').to_string(), - } - } -} - impl UIfmt for Transaction { fn pretty(&self) -> String { format!( @@ -333,11 +264,81 @@ value {}{}", } } +impl UIfmt for TransactionReceiptWithRevertReason { + fn pretty(&self) -> String { + if let Some(revert_reason) = &self.revert_reason { + format!( + "{} +revertReason {}", + self.receipt.pretty(), + revert_reason + ) + } else { + self.receipt.pretty() + } + } +} + +/// Various numerical ethereum types used for pretty printing +#[derive(Debug, Clone, Deserialize)] +#[serde(untagged)] +#[allow(missing_docs)] +pub enum EthValue { + U64(U64), + U256(U256), + U64Array(Vec), + U256Array(Vec), + Other(serde_json::Value), +} + +impl From for EthValue { + fn from(val: serde_json::Value) -> Self { + serde_json::from_value(val).expect("infallible") + } +} + +impl UIfmt for EthValue { + fn pretty(&self) -> String { + match self { + EthValue::U64(num) => num.pretty(), + EthValue::U256(num) => num.pretty(), + EthValue::U64Array(arr) => arr.pretty(), + EthValue::U256Array(arr) => arr.pretty(), + EthValue::Other(val) => val.to_string().trim_matches('"').to_string(), + } + } +} + +// TODO: replace these above and remove this module once types are converted +mod temp_ethers { + use super::UIfmt; + use ethers_core::types::{Address, Bloom, Bytes, H256, H64, I256, U256, U64}; + use foundry_utils::types::ToAlloy; + + macro_rules! with_alloy { + ($($t:ty),*) => {$( + impl UIfmt for $t { + fn pretty(&self) -> String { + self.to_alloy().pretty() + } + } + )*}; + } + + impl UIfmt for Bytes { + fn pretty(&self) -> String { + self.clone().to_alloy().pretty() + } + } + + with_alloy!(Address, Bloom, H64, H256, I256, U256, U64); +} + /// Convert a U256 to bytes -pub fn to_bytes(uint: U256) -> Bytes { - let mut buffer: [u8; 4 * 8] = [0; 4 * 8]; +pub fn to_bytes(uint: ethers_core::types::U256) -> [u8; 32] { + let mut buffer: [u8; 32] = [0; 32]; uint.to_big_endian(&mut buffer); - Bytes::from(buffer) + buffer } /// Returns the `UiFmt::pretty()` formatted attribute of the transactions @@ -366,6 +367,36 @@ pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option Option { + match attr { + "blockHash" | "block_hash" => Some(receipt.receipt.block_hash.pretty()), + "blockNumber" | "block_number" => Some(receipt.receipt.block_number.pretty()), + "contractAddress" | "contract_address" => Some(receipt.receipt.contract_address.pretty()), + "cumulativeGasUsed" | "cumulative_gas_used" => { + Some(receipt.receipt.cumulative_gas_used.pretty()) + } + "effectiveGasPrice" | "effective_gas_price" => { + Some(receipt.receipt.effective_gas_price.pretty()) + } + "gasUsed" | "gas_used" => Some(receipt.receipt.gas_used.pretty()), + "logs" => Some(receipt.receipt.logs.pretty()), + "logsBloom" | "logs_bloom" => Some(receipt.receipt.logs_bloom.pretty()), + "root" => Some(receipt.receipt.root.pretty()), + "status" => Some(receipt.receipt.status.pretty()), + "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), + "transactionIndex" | "transaction_index" => { + Some(receipt.receipt.transaction_index.pretty()) + } + "type" | "transaction_type" => Some(receipt.receipt.transaction_type.pretty()), + "revertReason" | "revert_reason" => Some(receipt.revert_reason.pretty()), + _ => None, + } +} + /// Returns the `UiFmt::pretty()` formatted attribute of the given block pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option { match attr { @@ -398,9 +429,57 @@ pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option(block: &Block) -> String { + format!( + " +baseFeePerGas {} +difficulty {} +extraData {} +gasLimit {} +gasUsed {} +hash {} +logsBloom {} +miner {} +mixHash {} +nonce {} +number {} +parentHash {} +receiptsRoot {} +sealFields {} +sha3Uncles {} +size {} +stateRoot {} +timestamp {} +withdrawalsRoot {} +totalDifficulty {}{}", + block.base_fee_per_gas.pretty(), + block.difficulty.pretty(), + block.extra_data.pretty(), + block.gas_limit.pretty(), + block.gas_used.pretty(), + block.hash.pretty(), + block.logs_bloom.pretty(), + block.author.pretty(), + block.mix_hash.pretty(), + block.nonce.pretty(), + block.number.pretty(), + block.parent_hash.pretty(), + block.receipts_root.pretty(), + block.seal_fields.pretty(), + block.uncles_hash.pretty(), + block.size.pretty(), + block.state_root.pretty(), + block.timestamp.pretty(), + block.withdrawals_root.pretty(), + block.total_difficulty.pretty(), + block.other.pretty() + ) +} + #[cfg(test)] mod tests { use super::*; + use pretty_assertions::assert_eq; use std::str::FromStr; #[test] @@ -471,7 +550,7 @@ l1TxOrigin null queueIndex null queueOrigin sequencer rawTransaction 0xf86681a28084011cbbdc944a16a42407aa491564643e1dfc1fd50af29794ef8084d294f09338a06fca94073a0cf3381978662d46cf890602d3e9ccf6a31e4b69e8ecbd995e2beea00e804161a2b56a37ca1f6f4c4b8bce926587afa0d9b1acc5165e6556c959d583 -txType +txType 0 ".trim() ); } @@ -500,47 +579,45 @@ value 0".to_string(); #[test] fn uifmt_option_u64() { - let empty: Option = None; - assert_eq!(String::new(), empty.pretty()); - assert_eq!("100".to_string(), U64::from_dec_str("100").unwrap().pretty()); - assert_eq!("100".to_string(), Option::from(U64::from_dec_str("100").unwrap()).pretty()) + assert_eq!(None::.pretty(), ""); + assert_eq!(U64::from(100).pretty(), "100"); + assert_eq!(Some(U64::from(100)).pretty(), "100"); } #[test] fn uifmt_option_h64() { - let empty: Option = None; - assert_eq!(String::new(), empty.pretty()); - H256::from_low_u64_be(100); + assert_eq!(None::.pretty(), ""); assert_eq!( + B256::with_last_byte(100).pretty(), "0x0000000000000000000000000000000000000000000000000000000000000064", - H256::from_low_u64_be(100).pretty() ); assert_eq!( + Some(B256::with_last_byte(100)).pretty(), "0x0000000000000000000000000000000000000000000000000000000000000064", - Some(H256::from_low_u64_be(100)).pretty() ); } + #[test] fn uifmt_option_bytes() { - let empty: Option = None; - assert_eq!(String::new(), empty.pretty()); + assert_eq!(None::.pretty(), ""); assert_eq!( - "0x0000000000000000000000000000000000000000000000000000000000000064".to_string(), Bytes::from_str("0x0000000000000000000000000000000000000000000000000000000000000064") .unwrap() - .pretty() + .pretty(), + "0x0000000000000000000000000000000000000000000000000000000000000064", ); assert_eq!( - "0x0000000000000000000000000000000000000000000000000000000000000064".to_string(), Some( Bytes::from_str( "0x0000000000000000000000000000000000000000000000000000000000000064" ) .unwrap() ) - .pretty() + .pretty(), + "0x0000000000000000000000000000000000000000000000000000000000000064", ); } + #[test] fn test_pretty_tx_attr() { let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":[{"hash":"0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067","nonce":"0x2","blockHash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","blockNumber":"0x3","transactionIndex":"0x0","from":"0xfdcedc3bfca10ecb0890337fbdd1977aba84807a","to":"0xdca8ce283150ab773bcbeb8d38289bdb5661de1e","value":"0x0","gas":"0x15f90","gasPrice":"0x4a817c800","input":"0x","v":"0x25","r":"0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88","s":"0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e"}],"uncles":[]}"#; @@ -584,6 +661,7 @@ value 0".to_string(); assert_eq!(Some("37".to_string()), get_pretty_tx_attr(&block.transactions[0], "v")); assert_eq!(Some("0".to_string()), get_pretty_tx_attr(&block.transactions[0], "value")); } + #[test] fn test_pretty_block_attr() { let json = serde_json::json!( diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 584a3638981d5..daeb88cefbb81 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -2,6 +2,8 @@ #![warn(missing_docs, unused_crate_dependencies)] +extern crate self as foundry_common; + #[macro_use] extern crate tracing; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index f467d8981d8d9..1ac4ffdd30cc6 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -11,11 +11,11 @@ homepage.workspace = true repository.workspace = true [dependencies] -foundry-abi.workspace = true foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true +foundry-macros.workspace = true foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } @@ -32,10 +32,10 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } -ethers-contract.workspace = true ethers-core.workspace = true ethers-providers.workspace = true +derive_more.workspace = true eyre = "0.6" futures = "0.3" hex.workspace = true diff --git a/crates/abi/abi/HardhatConsole.json b/crates/evm/core/src/abi/HardhatConsole.json similarity index 100% rename from crates/abi/abi/HardhatConsole.json rename to crates/evm/core/src/abi/HardhatConsole.json diff --git a/crates/evm/core/src/abi/console.rs b/crates/evm/core/src/abi/console.rs new file mode 100644 index 0000000000000..5f8932435e912 --- /dev/null +++ b/crates/evm/core/src/abi/console.rs @@ -0,0 +1,92 @@ +use alloy_primitives::{hex, I256, U256}; +use alloy_sol_types::sol; +use derive_more::Display; +use foundry_utils::types::ToEthers; +use itertools::Itertools; + +// TODO: Use `UiFmt` + +sol! { +#[sol(abi)] +#[derive(Display)] +interface Console { + #[display(fmt = "{val}")] + event log(string val); + + #[display(fmt = "{}", "hex::encode_prefixed(val)")] + event logs(bytes val); + + #[display(fmt = "{val}")] + event log_address(address val); + + #[display(fmt = "{val}")] + event log_bytes32(bytes32 val); + + #[display(fmt = "{val}")] + event log_int(int val); + + #[display(fmt = "{val}")] + event log_uint(uint val); + + #[display(fmt = "{}", "hex::encode_prefixed(val)")] + event log_bytes(bytes val); + + #[display(fmt = "{val}")] + event log_string(string val); + + #[display(fmt = "[{}]", "val.iter().format(\", \")")] + event log_array(uint256[] val); + + #[display(fmt = "[{}]", "val.iter().format(\", \")")] + event log_array(int256[] val); + + #[display(fmt = "[{}]", "val.iter().format(\", \")")] + event log_array(address[] val); + + #[display(fmt = "{key}: {val}")] + event log_named_address(string key, address val); + + #[display(fmt = "{key}: {val}")] + event log_named_bytes32(string key, bytes32 val); + + #[display(fmt = "{key}: {}", "format_units_int(val, decimals)")] + event log_named_decimal_int(string key, int val, uint decimals); + + #[display(fmt = "{key}: {}", "format_units_uint(val, decimals)")] + event log_named_decimal_uint(string key, uint val, uint decimals); + + #[display(fmt = "{key}: {val}")] + event log_named_int(string key, int val); + + #[display(fmt = "{key}: {val}")] + event log_named_uint(string key, uint val); + + #[display(fmt = "{key}: {}", "hex::encode_prefixed(val)")] + event log_named_bytes(string key, bytes val); + + #[display(fmt = "{key}: {val}")] + event log_named_string(string key, string val); + + #[display(fmt = "{key}: [{}]", "val.iter().format(\", \")")] + event log_named_array(string key, uint256[] val); + + #[display(fmt = "{key}: [{}]", "val.iter().format(\", \")")] + event log_named_array(string key, int256[] val); + + #[display(fmt = "{key}: [{}]", "val.iter().format(\", \")")] + event log_named_array(string key, address[] val); +} +} + +fn format_units_int(x: &I256, decimals: &U256) -> String { + let (sign, x) = x.into_sign_and_abs(); + format!("{sign}{}", format_units_uint(&x, decimals)) +} + +fn format_units_uint(x: &U256, decimals: &U256) -> String { + // TODO: rm ethers_core + match ethers_core::utils::format_units(x.to_ethers(), decimals.saturating_to::()) { + Ok(s) => s, + Err(_) => x.to_string(), + } +} diff --git a/crates/evm/core/src/abi/hardhat_console.rs b/crates/evm/core/src/abi/hardhat_console.rs new file mode 100644 index 0000000000000..955ebc087f9dd --- /dev/null +++ b/crates/evm/core/src/abi/hardhat_console.rs @@ -0,0 +1,556 @@ +use alloy_sol_types::sol; +use foundry_macros::ConsoleFmt; +use once_cell::sync::Lazy; +use revm::primitives::HashMap; + +sol!( + #[sol(abi)] + #[derive(ConsoleFmt)] + HardhatConsole, + "src/abi/HardhatConsole.json" +); + +/// If the input starts with a known `hardhat/console.log` `uint` selector, then this will replace +/// it with the selector `abigen!` bindings expect. +pub fn patch_hardhat_console_selector(input: &mut [u8]) { + if let Some(selector) = input.get_mut(..4) { + let selector: &mut [u8; 4] = selector.try_into().unwrap(); + if let Some(generated_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { + *selector = *generated_selector; + } + } +} + +/// This contains a map with all the `hardhat/console.log` log selectors that use `uint` or `int` +/// as key and the selector of the call with `uint256`, +/// +/// This is a bit terrible but a workaround for the differing selectors used by hardhat and the call +/// bindings which `abigen!` creates. `hardhat/console.log` logs its events in functions that accept +/// `uint` manually as `abi.encodeWithSignature("log(int)", p0)`, but `abigen!` uses `uint256` for +/// its call bindings (`HardhatConsoleCalls`) as generated by solc. +static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { + HashMap::from([ + // log(bool,uint256,uint256,address) + ([241, 97, 178, 33], [0, 221, 135, 185]), + // log(uint256,address,address,string) + ([121, 67, 220, 102], [3, 28, 111, 115]), + // log(uint256,bool,address,uint256) + ([65, 181, 239, 59], [7, 130, 135, 245]), + // log(bool,address,bool,uint256) + ([76, 182, 15, 209], [7, 131, 21, 2]), + // log(bool,uint256,address) + ([196, 210, 53, 7], [8, 142, 249, 210]), + // log(uint256,address,address,bool) + ([1, 85, 11, 4], [9, 31, 250, 245]), + // log(address,bool,uint256,string) + ([155, 88, 142, 204], [10, 166, 207, 173]), + // log(bool,bool,uint256,uint256) + ([70, 103, 222, 142], [11, 176, 14, 171]), + // log(bool,address,address,uint256) + ([82, 132, 189, 108], [12, 102, 209, 190]), + // log(uint256,address,uint256,uint256) + ([202, 154, 62, 180], [12, 156, 217, 193]), + // log(string,address,uint256) + ([7, 200, 18, 23], [13, 38, 185, 37]), + // log(address,string,uint256,bool) + ([126, 37, 13, 91], [14, 247, 224, 80]), + // log(address,uint256,address,uint256) + ([165, 217, 135, 104], [16, 15, 101, 14]), + // log(string,string,uint256,address) + ([93, 79, 70, 128], [16, 35, 247, 178]), + // log(bool,string,uint256) + ([192, 56, 42, 172], [16, 147, 238, 17]), + // log(bool,bool,uint256) + ([176, 19, 101, 187], [18, 242, 22, 2]), + // log(bool,address,uint256,address) + ([104, 241, 88, 181], [19, 107, 5, 221]), + // log(bool,uint256,address,uint256) + ([202, 165, 35, 106], [21, 55, 220, 135]), + // log(bool,string,uint256,address) + ([91, 34, 185, 56], [21, 150, 161, 206]), + // log(address,string,string,uint256) + ([161, 79, 208, 57], [21, 159, 137, 39]), + // log(uint256,address,uint256,address) + ([253, 178, 236, 212], [21, 193, 39, 181]), + // log(uint256,uint256,address,bool) + ([168, 232, 32, 174], [21, 202, 196, 118]), + // log(bool,string,bool,uint256) + ([141, 111, 156, 165], [22, 6, 163, 147]), + // log(address,address,uint256) + ([108, 54, 109, 114], [23, 254, 97, 133]), + // log(uint256,uint256,uint256,uint256) + ([92, 160, 173, 62], [25, 63, 184, 0]), + // log(bool,string,uint256,string) + ([119, 161, 171, 237], [26, 217, 109, 230]), + // log(bool,uint256,address,string) + ([24, 9, 19, 65], [27, 179, 176, 154]), + // log(string,uint256,address) + ([227, 132, 159, 121], [28, 126, 196, 72]), + // log(uint256,bool) + ([30, 109, 212, 236], [28, 157, 126, 179]), + // log(address,uint256,address,string) + ([93, 113, 243, 158], [29, 169, 134, 234]), + // log(address,string,uint256,uint256) + ([164, 201, 42, 96], [29, 200, 225, 184]), + // log(uint256,bool,uint256) + ([90, 77, 153, 34], [32, 9, 128, 20]), + // log(uint256,bool,bool) + ([213, 206, 172, 224], [32, 113, 134, 80]), + // log(address,uint256,uint256,address) + ([30, 246, 52, 52], [32, 227, 152, 77]), + // log(uint256,string,string,string) + ([87, 221, 10, 17], [33, 173, 6, 131]), + // log(address,uint256,bool,uint256) + ([105, 143, 67, 146], [34, 246, 185, 153]), + // log(uint256,address,address,address) + ([85, 71, 69, 249], [36, 136, 180, 20]), + // log(string,bool,string,uint256) + ([52, 203, 48, 141], [36, 249, 20, 101]), + // log(bool,uint256,address,address) + ([138, 47, 144, 170], [38, 245, 96, 168]), + // log(uint256,uint256,string,string) + ([124, 3, 42, 50], [39, 216, 175, 210]), + // log(bool,string,uint256,uint256) + ([142, 74, 232, 110], [40, 134, 63, 203]), + // log(uint256,bool,string,uint256) + ([145, 95, 219, 40], [44, 29, 7, 70]), + // log(address,uint256,uint256,uint256) + ([61, 14, 157, 228], [52, 240, 230, 54]), + // log(uint256,bool,address) + ([66, 78, 255, 191], [53, 8, 95, 123]), + // log(string,uint256,bool,bool) + ([227, 127, 243, 208], [53, 76, 54, 214]), + // log(bool,uint256,uint256) + ([59, 92, 3, 224], [55, 16, 51, 103]), + // log(bool,uint256,uint256,uint256) + ([50, 223, 165, 36], [55, 75, 180, 178]), + // log(uint256,string,uint256) + ([91, 109, 232, 63], [55, 170, 125, 76]), + // log(address,bool,uint256,uint256) + ([194, 16, 160, 30], [56, 111, 245, 244]), + // log(address,address,bool,uint256) + ([149, 214, 95, 17], [57, 113, 231, 140]), + // log(bool,uint256) + ([54, 75, 106, 146], [57, 145, 116, 211]), + // log(uint256,string,uint256,address) + ([171, 123, 217, 253], [59, 34, 121, 180]), + // log(address,uint256,bool,bool) + ([254, 161, 213, 90], [59, 245, 229, 55]), + // log(uint256,address,string,string) + ([141, 119, 134, 36], [62, 18, 140, 163]), + // log(string,address,bool,uint256) + ([197, 209, 187, 139], [62, 159, 134, 106]), + // log(uint256,uint256,string,address) + ([67, 50, 133, 162], [66, 210, 29, 183]), + // log(address,string,uint256,string) + ([93, 19, 101, 201], [68, 136, 48, 168]), + // log(uint256,bool,address,bool) + ([145, 251, 18, 66], [69, 77, 84, 165]), + // log(address,string,address,uint256) + ([140, 25, 51, 169], [69, 127, 227, 207]), + // log(uint256,address,string,uint256) + ([160, 196, 20, 232], [70, 130, 107, 93]), + // log(uint256,uint256,bool) + ([103, 87, 15, 247], [71, 102, 218, 114]), + // log(address,uint256,address,address) + ([236, 36, 132, 111], [71, 141, 28, 98]), + // log(address,uint256,uint256,string) + ([137, 52, 13, 171], [74, 40, 192, 23]), + // log(bool,bool,address,uint256) + ([96, 147, 134, 231], [76, 18, 61, 87]), + // log(uint256,string,bool) + ([70, 167, 208, 206], [76, 237, 167, 90]), + // log(string,uint256,address,uint256) + ([88, 73, 122, 254], [79, 4, 253, 198]), + // log(address,string,bool,uint256) + ([231, 32, 82, 28], [81, 94, 56, 182]), + // log(bool,address,uint256,string) + ([160, 104, 88, 51], [81, 240, 159, 248]), + // log(bool,bool,uint256,address) + ([11, 255, 149, 13], [84, 167, 169, 160]), + // log(uint256,uint256,address,address) + ([202, 147, 155, 32], [86, 165, 209, 177]), + // log(string,string,uint256) + ([243, 98, 202, 89], [88, 33, 239, 161]), + // log(string,uint256,string) + ([163, 245, 199, 57], [89, 112, 224, 137]), + // log(uint256,uint256,uint256,string) + ([120, 173, 122, 12], [89, 207, 203, 227]), + // log(string,address,uint256,string) + ([76, 85, 242, 52], [90, 71, 118, 50]), + // log(uint256,address,uint256) + ([136, 67, 67, 170], [90, 155, 94, 213]), + // log(string,uint256,string,string) + ([108, 152, 218, 226], [90, 184, 78, 31]), + // log(uint256,address,bool,uint256) + ([123, 8, 232, 235], [90, 189, 153, 42]), + // log(address,uint256,string,address) + ([220, 121, 38, 4], [92, 67, 13, 71]), + // log(uint256,uint256,address) + ([190, 51, 73, 27], [92, 150, 179, 49]), + // log(string,bool,address,uint256) + ([40, 223, 78, 150], [93, 8, 187, 5]), + // log(string,string,uint256,string) + ([141, 20, 44, 221], [93, 26, 151, 26]), + // log(uint256,uint256,string,uint256) + ([56, 148, 22, 61], [93, 162, 151, 235]), + // log(string,uint256,address,address) + ([234, 200, 146, 129], [94, 162, 183, 174]), + // log(uint256,address,uint256,bool) + ([25, 246, 115, 105], [95, 116, 58, 124]), + // log(bool,address,uint256) + ([235, 112, 75, 175], [95, 123, 154, 251]), + // log(uint256,string,address,address) + ([127, 165, 69, 139], [97, 104, 237, 97]), + // log(bool,bool,uint256,bool) + ([171, 92, 193, 196], [97, 158, 77, 14]), + // log(address,string,uint256,address) + ([223, 215, 216, 11], [99, 24, 54, 120]), + // log(uint256,address,string) + ([206, 131, 4, 123], [99, 203, 65, 249]), + // log(string,address,uint256,address) + ([163, 102, 236, 128], [99, 251, 139, 197]), + // log(uint256,string) + ([15, 163, 243, 69], [100, 63, 208, 223]), + // log(string,bool,uint256,uint256) + ([93, 191, 240, 56], [100, 181, 187, 103]), + // log(address,uint256,uint256,bool) + ([236, 75, 168, 162], [102, 241, 188, 103]), + // log(address,uint256,bool) + ([229, 74, 225, 68], [103, 130, 9, 168]), + // log(address,string,uint256) + ([28, 218, 242, 138], [103, 221, 111, 241]), + // log(uint256,bool,string,string) + ([164, 51, 252, 253], [104, 200, 184, 189]), + // log(uint256,string,uint256,bool) + ([135, 90, 110, 46], [105, 26, 143, 116]), + // log(uint256,address) + ([88, 235, 134, 12], [105, 39, 108, 134]), + // log(uint256,bool,bool,address) + ([83, 6, 34, 93], [105, 100, 11, 89]), + // log(bool,uint256,string,uint256) + ([65, 128, 1, 27], [106, 17, 153, 226]), + // log(bool,string,uint256,bool) + ([32, 187, 201, 175], [107, 14, 93, 83]), + // log(uint256,uint256,address,string) + ([214, 162, 209, 222], [108, 222, 64, 184]), + // log(bool,bool,bool,uint256) + ([194, 72, 131, 77], [109, 112, 69, 193]), + // log(uint256,uint256,string) + ([125, 105, 14, 230], [113, 208, 74, 242]), + // log(uint256,address,address,uint256) + ([154, 60, 191, 150], [115, 110, 251, 182]), + // log(string,bool,uint256,string) + ([66, 185, 162, 39], [116, 45, 110, 231]), + // log(uint256,bool,bool,uint256) + ([189, 37, 173, 89], [116, 100, 206, 35]), + // log(string,uint256,uint256,bool) + ([247, 60, 126, 61], [118, 38, 219, 146]), + // log(uint256,uint256,string,bool) + ([178, 46, 175, 6], [122, 246, 171, 37]), + // log(uint256,string,address) + ([31, 144, 242, 74], [122, 250, 201, 89]), + // log(address,uint256,address) + ([151, 236, 163, 148], [123, 192, 216, 72]), + // log(bool,string,string,uint256) + ([93, 219, 37, 146], [123, 224, 195, 235]), + // log(bool,address,uint256,uint256) + ([155, 254, 114, 188], [123, 241, 129, 161]), + // log(string,uint256,string,address) + ([187, 114, 53, 233], [124, 70, 50, 164]), + // log(string,string,address,uint256) + ([74, 129, 165, 106], [124, 195, 198, 7]), + // log(string,uint256,string,bool) + ([233, 159, 130, 207], [125, 36, 73, 29]), + // log(bool,bool,uint256,string) + ([80, 97, 137, 55], [125, 212, 208, 224]), + // log(bool,uint256,bool,uint256) + ([211, 222, 85, 147], [127, 155, 188, 162]), + // log(address,bool,string,uint256) + ([158, 18, 123, 110], [128, 230, 162, 11]), + // log(string,uint256,address,bool) + ([17, 6, 168, 247], [130, 17, 42, 66]), + // log(uint256,string,uint256,uint256) + ([192, 4, 56, 7], [130, 194, 91, 116]), + // log(address,uint256) + ([34, 67, 207, 163], [131, 9, 232, 168]), + // log(string,uint256,uint256,string) + ([165, 78, 212, 189], [133, 75, 52, 150]), + // log(uint256,bool,string) + ([139, 14, 20, 254], [133, 119, 80, 33]), + // log(address,uint256,string,string) + ([126, 86, 198, 147], [136, 168, 196, 6]), + // log(uint256,bool,uint256,address) + ([79, 64, 5, 142], [136, 203, 96, 65]), + // log(uint256,uint256,address,uint256) + ([97, 11, 168, 192], [136, 246, 228, 178]), + // log(string,bool,uint256,bool) + ([60, 197, 181, 211], [138, 247, 207, 138]), + // log(address,bool,bool,uint256) + ([207, 181, 135, 86], [140, 78, 93, 230]), + // log(address,address,uint256,address) + ([214, 198, 82, 118], [141, 166, 222, 245]), + // log(string,bool,bool,uint256) + ([128, 117, 49, 232], [142, 63, 120, 169]), + // log(bool,uint256,uint256,string) + ([218, 6, 102, 200], [142, 105, 251, 93]), + // log(string,string,string,uint256) + ([159, 208, 9, 245], [142, 175, 176, 43]), + // log(string,address,address,uint256) + ([110, 183, 148, 61], [142, 243, 243, 153]), + // log(uint256,string,address,bool) + ([249, 63, 255, 55], [144, 195, 10, 86]), + // log(uint256,address,bool,string) + ([99, 240, 226, 66], [144, 251, 6, 170]), + // log(bool,uint256,bool,string) + ([182, 213, 105, 212], [145, 67, 219, 177]), + // log(uint256,bool,uint256,bool) + ([210, 171, 196, 253], [145, 160, 46, 42]), + // log(string,address,string,uint256) + ([143, 98, 75, 233], [145, 209, 17, 46]), + // log(string,bool,uint256,address) + ([113, 211, 133, 13], [147, 94, 9, 191]), + // log(address,address,address,uint256) + ([237, 94, 172, 135], [148, 37, 13, 119]), + // log(uint256,uint256,bool,address) + ([225, 23, 116, 79], [154, 129, 106, 131]), + // log(bool,uint256,bool,address) + ([66, 103, 199, 248], [154, 205, 54, 22]), + // log(address,address,uint256,bool) + ([194, 246, 136, 236], [155, 66, 84, 226]), + // log(uint256,address,bool) + ([122, 208, 18, 142], [155, 110, 192, 66]), + // log(uint256,string,address,string) + ([248, 152, 87, 127], [156, 58, 223, 161]), + // log(address,bool,uint256) + ([44, 70, 141, 21], [156, 79, 153, 251]), + // log(uint256,address,string,address) + ([203, 229, 142, 253], [156, 186, 143, 255]), + // log(string,uint256,address,string) + ([50, 84, 194, 232], [159, 251, 47, 147]), + // log(address,uint256,address,bool) + ([241, 129, 161, 233], [161, 188, 201, 179]), + // log(uint256,bool,address,address) + ([134, 237, 193, 12], [161, 239, 76, 187]), + // log(address,uint256,string) + ([186, 249, 104, 73], [161, 242, 232, 170]), + // log(address,uint256,bool,address) + ([35, 229, 73, 114], [163, 27, 253, 204]), + // log(uint256,uint256,bool,string) + ([239, 217, 203, 238], [165, 180, 252, 153]), + // log(bool,string,address,uint256) + ([27, 11, 149, 91], [165, 202, 218, 148]), + // log(address,bool,address,uint256) + ([220, 113, 22, 210], [167, 92, 89, 222]), + // log(string,uint256,uint256,uint256) + ([8, 238, 86, 102], [167, 168, 120, 83]), + // log(uint256,uint256,bool,bool) + ([148, 190, 59, 177], [171, 8, 90, 230]), + // log(string,uint256,bool,string) + ([118, 204, 96, 100], [171, 247, 58, 152]), + // log(uint256,bool,address,string) + ([162, 48, 118, 30], [173, 224, 82, 199]), + // log(uint256,string,bool,address) + ([121, 111, 40, 160], [174, 46, 197, 129]), + // log(uint256,string,string,uint256) + ([118, 236, 99, 94], [176, 40, 201, 189]), + // log(uint256,string,string) + ([63, 87, 194, 149], [177, 21, 97, 31]), + // log(uint256,string,string,bool) + ([18, 134, 43, 152], [179, 166, 182, 189]), + // log(bool,uint256,address,bool) + ([101, 173, 244, 8], [180, 195, 20, 255]), + // log(string,uint256) + ([151, 16, 169, 208], [182, 14, 114, 204]), + // log(address,uint256,uint256) + ([135, 134, 19, 94], [182, 155, 202, 246]), + // log(uint256,bool,bool,bool) + ([78, 108, 83, 21], [182, 245, 119, 161]), + // log(uint256,string,uint256,string) + ([162, 188, 12, 153], [183, 185, 20, 202]), + // log(uint256,string,bool,bool) + ([81, 188, 43, 193], [186, 83, 93, 156]), + // log(uint256,address,address) + ([125, 119, 166, 27], [188, 253, 155, 224]), + // log(address,address,uint256,uint256) + ([84, 253, 243, 228], [190, 85, 52, 129]), + // log(bool,uint256,uint256,bool) + ([164, 29, 129, 222], [190, 152, 67, 83]), + // log(address,uint256,string,uint256) + ([245, 18, 207, 155], [191, 1, 248, 145]), + // log(bool,address,string,uint256) + ([11, 153, 252, 34], [194, 31, 100, 199]), + // log(string,string,uint256,bool) + ([230, 86, 88, 202], [195, 168, 166, 84]), + // log(bool,uint256,string) + ([200, 57, 126, 176], [195, 252, 57, 112]), + // log(address,bool,uint256,bool) + ([133, 205, 197, 175], [196, 100, 62, 32]), + // log(uint256,uint256,uint256,bool) + ([100, 82, 185, 203], [197, 152, 209, 133]), + // log(address,uint256,bool,string) + ([142, 142, 78, 117], [197, 173, 133, 249]), + // log(string,uint256,string,uint256) + ([160, 196, 178, 37], [198, 126, 169, 209]), + // log(uint256,bool,uint256,uint256) + ([86, 130, 141, 164], [198, 172, 199, 168]), + // log(string,bool,uint256) + ([41, 27, 185, 208], [201, 89, 88, 214]), + // log(string,uint256,uint256) + ([150, 156, 221, 3], [202, 71, 196, 235]), + // log(string,uint256,bool) + ([241, 2, 238, 5], [202, 119, 51, 177]), + // log(uint256,address,string,bool) + ([34, 164, 121, 166], [204, 50, 171, 7]), + // log(address,bool,uint256,address) + ([13, 140, 230, 30], [204, 247, 144, 161]), + // log(bool,uint256,bool,bool) + ([158, 1, 247, 65], [206, 181, 244, 215]), + // log(uint256,string,bool,uint256) + ([164, 180, 138, 127], [207, 0, 152, 128]), + // log(address,uint256,string,bool) + ([164, 2, 79, 17], [207, 24, 16, 92]), + // log(uint256,uint256,uint256) + ([231, 130, 10, 116], [209, 237, 122, 60]), + // log(uint256,string,bool,string) + ([141, 72, 156, 160], [210, 212, 35, 205]), + // log(uint256,string,string,address) + ([204, 152, 138, 160], [213, 131, 198, 2]), + // log(bool,address,uint256,bool) + ([238, 141, 134, 114], [214, 1, 159, 28]), + // log(string,string,bool,uint256) + ([134, 129, 138, 122], [214, 174, 250, 210]), + // log(uint256,address,uint256,string) + ([62, 211, 189, 40], [221, 176, 101, 33]), + // log(uint256,bool,bool,string) + ([49, 138, 229, 155], [221, 219, 149, 97]), + // log(uint256,bool,uint256,string) + ([232, 221, 188, 86], [222, 3, 231, 116]), + // log(string,uint256,bool,address) + ([229, 84, 157, 145], [224, 233, 91, 152]), + // log(string,uint256,uint256,address) + ([190, 215, 40, 191], [226, 29, 226, 120]), + // log(uint256,address,bool,bool) + ([126, 39, 65, 13], [227, 81, 20, 15]), + // log(bool,bool,string,uint256) + ([23, 139, 70, 133], [227, 169, 202, 47]), + // log(string,uint256,bool,uint256) + ([85, 14, 110, 245], [228, 27, 111, 111]), + // log(bool,uint256,string,bool) + ([145, 210, 248, 19], [229, 231, 11, 43]), + // log(uint256,string,address,uint256) + ([152, 231, 243, 243], [232, 211, 1, 141]), + // log(bool,uint256,bool) + ([27, 173, 201, 235], [232, 222, 251, 169]), + // log(uint256,uint256,bool,uint256) + ([108, 100, 124, 140], [235, 127, 111, 210]), + // log(uint256,bool,string,bool) + ([52, 110, 184, 199], [235, 146, 141, 127]), + // log(address,address,string,uint256) + ([4, 40, 147, 0], [239, 28, 239, 231]), + // log(uint256,bool,string,address) + ([73, 110, 43, 180], [239, 82, 144, 24]), + // log(uint256,address,bool,address) + ([182, 49, 48, 148], [239, 114, 197, 19]), + // log(string,string,uint256,uint256) + ([213, 207, 23, 208], [244, 93, 125, 44]), + // log(bool,uint256,string,string) + ([211, 42, 101, 72], [245, 188, 34, 73]), + // log(uint256,uint256) + ([108, 15, 105, 128], [246, 102, 113, 90]), + // log(uint256) and logUint(uint256) + ([245, 177, 187, 169], [248, 44, 80, 241]), + // log(string,address,uint256,uint256) + ([218, 163, 148, 189], [248, 245, 27, 30]), + // log(uint256,uint256,uint256,address) + ([224, 133, 63, 105], [250, 129, 133, 175]), + // log(string,address,uint256,bool) + ([90, 193, 193, 60], [252, 72, 69, 240]), + // log(address,address,uint256,string) + ([157, 209, 46, 173], [253, 180, 249, 144]), + // log(bool,uint256,string,address) + ([165, 199, 13, 41], [254, 221, 31, 255]), + // logInt(int256) + ([78, 12, 29, 29], [101, 37, 181, 245]), + // logBytes(bytes) + ([11, 231, 127, 86], [225, 123, 249, 86]), + // logBytes1(bytes1) + ([110, 24, 161, 40], [111, 65, 113, 201]), + // logBytes2(bytes2) + ([233, 182, 34, 150], [155, 94, 148, 62]), + // logBytes3(bytes3) + ([45, 131, 73, 38], [119, 130, 250, 45]), + // logBytes4(bytes4) + ([224, 95, 72, 209], [251, 163, 173, 57]), + // logBytes5(bytes5) + ([166, 132, 128, 141], [85, 131, 190, 46]), + // logBytes6(bytes6) + ([174, 132, 165, 145], [73, 66, 173, 198]), + // logBytes7(bytes7) + ([78, 213, 126, 40], [69, 116, 175, 171]), + // logBytes8(bytes8) + ([79, 132, 37, 46], [153, 2, 228, 127]), + // logBytes9(bytes9) + ([144, 189, 140, 208], [80, 161, 56, 223]), + // logBytes10(bytes10) + ([1, 61, 23, 139], [157, 194, 168, 151]), + // logBytes11(bytes11) + ([4, 0, 74, 46], [220, 8, 182, 167]), + // logBytes12(bytes12) + ([134, 160, 106, 189], [118, 86, 214, 199]), + // logBytes13(bytes13) + ([148, 82, 158, 52], [52, 193, 216, 27]), + // logBytes14(bytes14) + ([146, 102, 240, 127], [60, 234, 186, 101]), + // logBytes15(bytes15) + ([218, 149, 116, 224], [89, 26, 61, 162]), + // logBytes16(bytes16) + ([102, 92, 97, 4], [31, 141, 115, 18]), + // logBytes17(bytes17) + ([51, 159, 103, 58], [248, 154, 83, 47]), + // logBytes18(bytes18) + ([196, 210, 61, 154], [216, 101, 38, 66]), + // logBytes19(bytes19) + ([94, 107, 90, 51], [0, 245, 107, 201]), + // logBytes20(bytes20) + ([81, 136, 227, 233], [236, 184, 86, 126]), + // logBytes21(bytes21) + ([233, 218, 53, 96], [48, 82, 192, 143]), + // logBytes22(bytes22) + ([213, 250, 232, 156], [128, 122, 180, 52]), + // logBytes23(bytes23) + ([171, 161, 207, 13], [73, 121, 176, 55]), + // logBytes24(bytes24) + ([241, 179, 91, 52], [9, 119, 174, 252]), + // logBytes25(bytes25) + ([11, 132, 188, 88], [174, 169, 150, 63]), + // logBytes26(bytes26) + ([248, 177, 73, 241], [211, 99, 86, 40]), + // logBytes27(bytes27) + ([58, 55, 87, 221], [252, 55, 47, 159]), + // logBytes28(bytes28) + ([200, 42, 234, 238], [56, 47, 154, 52]), + // logBytes29(bytes29) + ([75, 105, 195, 213], [122, 24, 118, 65]), + // logBytes30(bytes30) + ([238, 18, 196, 237], [196, 52, 14, 246]), + // logBytes31(bytes31) + ([194, 133, 77, 146], [129, 252, 134, 72]), + // logBytes32(bytes32) + ([39, 183, 207, 133], [45, 33, 214, 247]), + ]) +}); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn hardhat_console_patch() { + for (hh, generated) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { + let mut hh = *hh; + patch_hardhat_console_selector(&mut hh); + assert_eq!(hh, *generated); + } + } +} diff --git a/crates/evm/core/src/abi/mod.rs b/crates/evm/core/src/abi/mod.rs index cc7c7287816ef..6fba308b2d268 100644 --- a/crates/evm/core/src/abi/mod.rs +++ b/crates/evm/core/src/abi/mod.rs @@ -1,554 +1,9 @@ //! Several ABI-related utilities for executors. -use once_cell::sync::Lazy; -use std::collections::HashMap; +pub use foundry_cheatcodes_spec::Vm; -pub use foundry_abi::{ - console::{ConsoleEvents, CONSOLE_ABI}, - hardhat_console::{HardhatConsoleCalls, HARDHATCONSOLE_ABI as HARDHAT_CONSOLE_ABI}, -}; +mod console; +pub use console::Console; -/// If the input starts with a known `hardhat/console.log` `uint` selector, then this will replace -/// it with the selector `abigen!` bindings expect. -pub fn patch_hardhat_console_selector(input: &mut [u8]) { - if let Some(selector) = input.get_mut(..4) { - let selector: &mut [u8; 4] = selector.try_into().unwrap(); - if let Some(generated_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { - *selector = *generated_selector; - } - } -} - -/// This contains a map with all the `hardhat/console.log` log selectors that use `uint` or `int` -/// as key and the selector of the call with `uint256`, -/// -/// This is a bit terrible but a workaround for the differing selectors used by hardhat and the call -/// bindings which `abigen!` creates. `hardhat/console.log` logs its events in functions that accept -/// `uint` manually as `abi.encodeWithSignature("log(int)", p0)`, but `abigen!` uses `uint256` for -/// its call bindings (`HardhatConsoleCalls`) as generated by solc. -static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { - HashMap::from([ - // log(bool,uint256,uint256,address) - ([241, 97, 178, 33], [0, 221, 135, 185]), - // log(uint256,address,address,string) - ([121, 67, 220, 102], [3, 28, 111, 115]), - // log(uint256,bool,address,uint256) - ([65, 181, 239, 59], [7, 130, 135, 245]), - // log(bool,address,bool,uint256) - ([76, 182, 15, 209], [7, 131, 21, 2]), - // log(bool,uint256,address) - ([196, 210, 53, 7], [8, 142, 249, 210]), - // log(uint256,address,address,bool) - ([1, 85, 11, 4], [9, 31, 250, 245]), - // log(address,bool,uint256,string) - ([155, 88, 142, 204], [10, 166, 207, 173]), - // log(bool,bool,uint256,uint256) - ([70, 103, 222, 142], [11, 176, 14, 171]), - // log(bool,address,address,uint256) - ([82, 132, 189, 108], [12, 102, 209, 190]), - // log(uint256,address,uint256,uint256) - ([202, 154, 62, 180], [12, 156, 217, 193]), - // log(string,address,uint256) - ([7, 200, 18, 23], [13, 38, 185, 37]), - // log(address,string,uint256,bool) - ([126, 37, 13, 91], [14, 247, 224, 80]), - // log(address,uint256,address,uint256) - ([165, 217, 135, 104], [16, 15, 101, 14]), - // log(string,string,uint256,address) - ([93, 79, 70, 128], [16, 35, 247, 178]), - // log(bool,string,uint256) - ([192, 56, 42, 172], [16, 147, 238, 17]), - // log(bool,bool,uint256) - ([176, 19, 101, 187], [18, 242, 22, 2]), - // log(bool,address,uint256,address) - ([104, 241, 88, 181], [19, 107, 5, 221]), - // log(bool,uint256,address,uint256) - ([202, 165, 35, 106], [21, 55, 220, 135]), - // log(bool,string,uint256,address) - ([91, 34, 185, 56], [21, 150, 161, 206]), - // log(address,string,string,uint256) - ([161, 79, 208, 57], [21, 159, 137, 39]), - // log(uint256,address,uint256,address) - ([253, 178, 236, 212], [21, 193, 39, 181]), - // log(uint256,uint256,address,bool) - ([168, 232, 32, 174], [21, 202, 196, 118]), - // log(bool,string,bool,uint256) - ([141, 111, 156, 165], [22, 6, 163, 147]), - // log(address,address,uint256) - ([108, 54, 109, 114], [23, 254, 97, 133]), - // log(uint256,uint256,uint256,uint256) - ([92, 160, 173, 62], [25, 63, 184, 0]), - // log(bool,string,uint256,string) - ([119, 161, 171, 237], [26, 217, 109, 230]), - // log(bool,uint256,address,string) - ([24, 9, 19, 65], [27, 179, 176, 154]), - // log(string,uint256,address) - ([227, 132, 159, 121], [28, 126, 196, 72]), - // log(uint256,bool) - ([30, 109, 212, 236], [28, 157, 126, 179]), - // log(address,uint256,address,string) - ([93, 113, 243, 158], [29, 169, 134, 234]), - // log(address,string,uint256,uint256) - ([164, 201, 42, 96], [29, 200, 225, 184]), - // log(uint256,bool,uint256) - ([90, 77, 153, 34], [32, 9, 128, 20]), - // log(uint256,bool,bool) - ([213, 206, 172, 224], [32, 113, 134, 80]), - // log(address,uint256,uint256,address) - ([30, 246, 52, 52], [32, 227, 152, 77]), - // log(uint256,string,string,string) - ([87, 221, 10, 17], [33, 173, 6, 131]), - // log(address,uint256,bool,uint256) - ([105, 143, 67, 146], [34, 246, 185, 153]), - // log(uint256,address,address,address) - ([85, 71, 69, 249], [36, 136, 180, 20]), - // log(string,bool,string,uint256) - ([52, 203, 48, 141], [36, 249, 20, 101]), - // log(bool,uint256,address,address) - ([138, 47, 144, 170], [38, 245, 96, 168]), - // log(uint256,uint256,string,string) - ([124, 3, 42, 50], [39, 216, 175, 210]), - // log(bool,string,uint256,uint256) - ([142, 74, 232, 110], [40, 134, 63, 203]), - // log(uint256,bool,string,uint256) - ([145, 95, 219, 40], [44, 29, 7, 70]), - // log(address,uint256,uint256,uint256) - ([61, 14, 157, 228], [52, 240, 230, 54]), - // log(uint256,bool,address) - ([66, 78, 255, 191], [53, 8, 95, 123]), - // log(string,uint256,bool,bool) - ([227, 127, 243, 208], [53, 76, 54, 214]), - // log(bool,uint256,uint256) - ([59, 92, 3, 224], [55, 16, 51, 103]), - // log(bool,uint256,uint256,uint256) - ([50, 223, 165, 36], [55, 75, 180, 178]), - // log(uint256,string,uint256) - ([91, 109, 232, 63], [55, 170, 125, 76]), - // log(address,bool,uint256,uint256) - ([194, 16, 160, 30], [56, 111, 245, 244]), - // log(address,address,bool,uint256) - ([149, 214, 95, 17], [57, 113, 231, 140]), - // log(bool,uint256) - ([54, 75, 106, 146], [57, 145, 116, 211]), - // log(uint256,string,uint256,address) - ([171, 123, 217, 253], [59, 34, 121, 180]), - // log(address,uint256,bool,bool) - ([254, 161, 213, 90], [59, 245, 229, 55]), - // log(uint256,address,string,string) - ([141, 119, 134, 36], [62, 18, 140, 163]), - // log(string,address,bool,uint256) - ([197, 209, 187, 139], [62, 159, 134, 106]), - // log(uint256,uint256,string,address) - ([67, 50, 133, 162], [66, 210, 29, 183]), - // log(address,string,uint256,string) - ([93, 19, 101, 201], [68, 136, 48, 168]), - // log(uint256,bool,address,bool) - ([145, 251, 18, 66], [69, 77, 84, 165]), - // log(address,string,address,uint256) - ([140, 25, 51, 169], [69, 127, 227, 207]), - // log(uint256,address,string,uint256) - ([160, 196, 20, 232], [70, 130, 107, 93]), - // log(uint256,uint256,bool) - ([103, 87, 15, 247], [71, 102, 218, 114]), - // log(address,uint256,address,address) - ([236, 36, 132, 111], [71, 141, 28, 98]), - // log(address,uint256,uint256,string) - ([137, 52, 13, 171], [74, 40, 192, 23]), - // log(bool,bool,address,uint256) - ([96, 147, 134, 231], [76, 18, 61, 87]), - // log(uint256,string,bool) - ([70, 167, 208, 206], [76, 237, 167, 90]), - // log(string,uint256,address,uint256) - ([88, 73, 122, 254], [79, 4, 253, 198]), - // log(address,string,bool,uint256) - ([231, 32, 82, 28], [81, 94, 56, 182]), - // log(bool,address,uint256,string) - ([160, 104, 88, 51], [81, 240, 159, 248]), - // log(bool,bool,uint256,address) - ([11, 255, 149, 13], [84, 167, 169, 160]), - // log(uint256,uint256,address,address) - ([202, 147, 155, 32], [86, 165, 209, 177]), - // log(string,string,uint256) - ([243, 98, 202, 89], [88, 33, 239, 161]), - // log(string,uint256,string) - ([163, 245, 199, 57], [89, 112, 224, 137]), - // log(uint256,uint256,uint256,string) - ([120, 173, 122, 12], [89, 207, 203, 227]), - // log(string,address,uint256,string) - ([76, 85, 242, 52], [90, 71, 118, 50]), - // log(uint256,address,uint256) - ([136, 67, 67, 170], [90, 155, 94, 213]), - // log(string,uint256,string,string) - ([108, 152, 218, 226], [90, 184, 78, 31]), - // log(uint256,address,bool,uint256) - ([123, 8, 232, 235], [90, 189, 153, 42]), - // log(address,uint256,string,address) - ([220, 121, 38, 4], [92, 67, 13, 71]), - // log(uint256,uint256,address) - ([190, 51, 73, 27], [92, 150, 179, 49]), - // log(string,bool,address,uint256) - ([40, 223, 78, 150], [93, 8, 187, 5]), - // log(string,string,uint256,string) - ([141, 20, 44, 221], [93, 26, 151, 26]), - // log(uint256,uint256,string,uint256) - ([56, 148, 22, 61], [93, 162, 151, 235]), - // log(string,uint256,address,address) - ([234, 200, 146, 129], [94, 162, 183, 174]), - // log(uint256,address,uint256,bool) - ([25, 246, 115, 105], [95, 116, 58, 124]), - // log(bool,address,uint256) - ([235, 112, 75, 175], [95, 123, 154, 251]), - // log(uint256,string,address,address) - ([127, 165, 69, 139], [97, 104, 237, 97]), - // log(bool,bool,uint256,bool) - ([171, 92, 193, 196], [97, 158, 77, 14]), - // log(address,string,uint256,address) - ([223, 215, 216, 11], [99, 24, 54, 120]), - // log(uint256,address,string) - ([206, 131, 4, 123], [99, 203, 65, 249]), - // log(string,address,uint256,address) - ([163, 102, 236, 128], [99, 251, 139, 197]), - // log(uint256,string) - ([15, 163, 243, 69], [100, 63, 208, 223]), - // log(string,bool,uint256,uint256) - ([93, 191, 240, 56], [100, 181, 187, 103]), - // log(address,uint256,uint256,bool) - ([236, 75, 168, 162], [102, 241, 188, 103]), - // log(address,uint256,bool) - ([229, 74, 225, 68], [103, 130, 9, 168]), - // log(address,string,uint256) - ([28, 218, 242, 138], [103, 221, 111, 241]), - // log(uint256,bool,string,string) - ([164, 51, 252, 253], [104, 200, 184, 189]), - // log(uint256,string,uint256,bool) - ([135, 90, 110, 46], [105, 26, 143, 116]), - // log(uint256,address) - ([88, 235, 134, 12], [105, 39, 108, 134]), - // log(uint256,bool,bool,address) - ([83, 6, 34, 93], [105, 100, 11, 89]), - // log(bool,uint256,string,uint256) - ([65, 128, 1, 27], [106, 17, 153, 226]), - // log(bool,string,uint256,bool) - ([32, 187, 201, 175], [107, 14, 93, 83]), - // log(uint256,uint256,address,string) - ([214, 162, 209, 222], [108, 222, 64, 184]), - // log(bool,bool,bool,uint256) - ([194, 72, 131, 77], [109, 112, 69, 193]), - // log(uint256,uint256,string) - ([125, 105, 14, 230], [113, 208, 74, 242]), - // log(uint256,address,address,uint256) - ([154, 60, 191, 150], [115, 110, 251, 182]), - // log(string,bool,uint256,string) - ([66, 185, 162, 39], [116, 45, 110, 231]), - // log(uint256,bool,bool,uint256) - ([189, 37, 173, 89], [116, 100, 206, 35]), - // log(string,uint256,uint256,bool) - ([247, 60, 126, 61], [118, 38, 219, 146]), - // log(uint256,uint256,string,bool) - ([178, 46, 175, 6], [122, 246, 171, 37]), - // log(uint256,string,address) - ([31, 144, 242, 74], [122, 250, 201, 89]), - // log(address,uint256,address) - ([151, 236, 163, 148], [123, 192, 216, 72]), - // log(bool,string,string,uint256) - ([93, 219, 37, 146], [123, 224, 195, 235]), - // log(bool,address,uint256,uint256) - ([155, 254, 114, 188], [123, 241, 129, 161]), - // log(string,uint256,string,address) - ([187, 114, 53, 233], [124, 70, 50, 164]), - // log(string,string,address,uint256) - ([74, 129, 165, 106], [124, 195, 198, 7]), - // log(string,uint256,string,bool) - ([233, 159, 130, 207], [125, 36, 73, 29]), - // log(bool,bool,uint256,string) - ([80, 97, 137, 55], [125, 212, 208, 224]), - // log(bool,uint256,bool,uint256) - ([211, 222, 85, 147], [127, 155, 188, 162]), - // log(address,bool,string,uint256) - ([158, 18, 123, 110], [128, 230, 162, 11]), - // log(string,uint256,address,bool) - ([17, 6, 168, 247], [130, 17, 42, 66]), - // log(uint256,string,uint256,uint256) - ([192, 4, 56, 7], [130, 194, 91, 116]), - // log(address,uint256) - ([34, 67, 207, 163], [131, 9, 232, 168]), - // log(string,uint256,uint256,string) - ([165, 78, 212, 189], [133, 75, 52, 150]), - // log(uint256,bool,string) - ([139, 14, 20, 254], [133, 119, 80, 33]), - // log(address,uint256,string,string) - ([126, 86, 198, 147], [136, 168, 196, 6]), - // log(uint256,bool,uint256,address) - ([79, 64, 5, 142], [136, 203, 96, 65]), - // log(uint256,uint256,address,uint256) - ([97, 11, 168, 192], [136, 246, 228, 178]), - // log(string,bool,uint256,bool) - ([60, 197, 181, 211], [138, 247, 207, 138]), - // log(address,bool,bool,uint256) - ([207, 181, 135, 86], [140, 78, 93, 230]), - // log(address,address,uint256,address) - ([214, 198, 82, 118], [141, 166, 222, 245]), - // log(string,bool,bool,uint256) - ([128, 117, 49, 232], [142, 63, 120, 169]), - // log(bool,uint256,uint256,string) - ([218, 6, 102, 200], [142, 105, 251, 93]), - // log(string,string,string,uint256) - ([159, 208, 9, 245], [142, 175, 176, 43]), - // log(string,address,address,uint256) - ([110, 183, 148, 61], [142, 243, 243, 153]), - // log(uint256,string,address,bool) - ([249, 63, 255, 55], [144, 195, 10, 86]), - // log(uint256,address,bool,string) - ([99, 240, 226, 66], [144, 251, 6, 170]), - // log(bool,uint256,bool,string) - ([182, 213, 105, 212], [145, 67, 219, 177]), - // log(uint256,bool,uint256,bool) - ([210, 171, 196, 253], [145, 160, 46, 42]), - // log(string,address,string,uint256) - ([143, 98, 75, 233], [145, 209, 17, 46]), - // log(string,bool,uint256,address) - ([113, 211, 133, 13], [147, 94, 9, 191]), - // log(address,address,address,uint256) - ([237, 94, 172, 135], [148, 37, 13, 119]), - // log(uint256,uint256,bool,address) - ([225, 23, 116, 79], [154, 129, 106, 131]), - // log(bool,uint256,bool,address) - ([66, 103, 199, 248], [154, 205, 54, 22]), - // log(address,address,uint256,bool) - ([194, 246, 136, 236], [155, 66, 84, 226]), - // log(uint256,address,bool) - ([122, 208, 18, 142], [155, 110, 192, 66]), - // log(uint256,string,address,string) - ([248, 152, 87, 127], [156, 58, 223, 161]), - // log(address,bool,uint256) - ([44, 70, 141, 21], [156, 79, 153, 251]), - // log(uint256,address,string,address) - ([203, 229, 142, 253], [156, 186, 143, 255]), - // log(string,uint256,address,string) - ([50, 84, 194, 232], [159, 251, 47, 147]), - // log(address,uint256,address,bool) - ([241, 129, 161, 233], [161, 188, 201, 179]), - // log(uint256,bool,address,address) - ([134, 237, 193, 12], [161, 239, 76, 187]), - // log(address,uint256,string) - ([186, 249, 104, 73], [161, 242, 232, 170]), - // log(address,uint256,bool,address) - ([35, 229, 73, 114], [163, 27, 253, 204]), - // log(uint256,uint256,bool,string) - ([239, 217, 203, 238], [165, 180, 252, 153]), - // log(bool,string,address,uint256) - ([27, 11, 149, 91], [165, 202, 218, 148]), - // log(address,bool,address,uint256) - ([220, 113, 22, 210], [167, 92, 89, 222]), - // log(string,uint256,uint256,uint256) - ([8, 238, 86, 102], [167, 168, 120, 83]), - // log(uint256,uint256,bool,bool) - ([148, 190, 59, 177], [171, 8, 90, 230]), - // log(string,uint256,bool,string) - ([118, 204, 96, 100], [171, 247, 58, 152]), - // log(uint256,bool,address,string) - ([162, 48, 118, 30], [173, 224, 82, 199]), - // log(uint256,string,bool,address) - ([121, 111, 40, 160], [174, 46, 197, 129]), - // log(uint256,string,string,uint256) - ([118, 236, 99, 94], [176, 40, 201, 189]), - // log(uint256,string,string) - ([63, 87, 194, 149], [177, 21, 97, 31]), - // log(uint256,string,string,bool) - ([18, 134, 43, 152], [179, 166, 182, 189]), - // log(bool,uint256,address,bool) - ([101, 173, 244, 8], [180, 195, 20, 255]), - // log(string,uint256) - ([151, 16, 169, 208], [182, 14, 114, 204]), - // log(address,uint256,uint256) - ([135, 134, 19, 94], [182, 155, 202, 246]), - // log(uint256,bool,bool,bool) - ([78, 108, 83, 21], [182, 245, 119, 161]), - // log(uint256,string,uint256,string) - ([162, 188, 12, 153], [183, 185, 20, 202]), - // log(uint256,string,bool,bool) - ([81, 188, 43, 193], [186, 83, 93, 156]), - // log(uint256,address,address) - ([125, 119, 166, 27], [188, 253, 155, 224]), - // log(address,address,uint256,uint256) - ([84, 253, 243, 228], [190, 85, 52, 129]), - // log(bool,uint256,uint256,bool) - ([164, 29, 129, 222], [190, 152, 67, 83]), - // log(address,uint256,string,uint256) - ([245, 18, 207, 155], [191, 1, 248, 145]), - // log(bool,address,string,uint256) - ([11, 153, 252, 34], [194, 31, 100, 199]), - // log(string,string,uint256,bool) - ([230, 86, 88, 202], [195, 168, 166, 84]), - // log(bool,uint256,string) - ([200, 57, 126, 176], [195, 252, 57, 112]), - // log(address,bool,uint256,bool) - ([133, 205, 197, 175], [196, 100, 62, 32]), - // log(uint256,uint256,uint256,bool) - ([100, 82, 185, 203], [197, 152, 209, 133]), - // log(address,uint256,bool,string) - ([142, 142, 78, 117], [197, 173, 133, 249]), - // log(string,uint256,string,uint256) - ([160, 196, 178, 37], [198, 126, 169, 209]), - // log(uint256,bool,uint256,uint256) - ([86, 130, 141, 164], [198, 172, 199, 168]), - // log(string,bool,uint256) - ([41, 27, 185, 208], [201, 89, 88, 214]), - // log(string,uint256,uint256) - ([150, 156, 221, 3], [202, 71, 196, 235]), - // log(string,uint256,bool) - ([241, 2, 238, 5], [202, 119, 51, 177]), - // log(uint256,address,string,bool) - ([34, 164, 121, 166], [204, 50, 171, 7]), - // log(address,bool,uint256,address) - ([13, 140, 230, 30], [204, 247, 144, 161]), - // log(bool,uint256,bool,bool) - ([158, 1, 247, 65], [206, 181, 244, 215]), - // log(uint256,string,bool,uint256) - ([164, 180, 138, 127], [207, 0, 152, 128]), - // log(address,uint256,string,bool) - ([164, 2, 79, 17], [207, 24, 16, 92]), - // log(uint256,uint256,uint256) - ([231, 130, 10, 116], [209, 237, 122, 60]), - // log(uint256,string,bool,string) - ([141, 72, 156, 160], [210, 212, 35, 205]), - // log(uint256,string,string,address) - ([204, 152, 138, 160], [213, 131, 198, 2]), - // log(bool,address,uint256,bool) - ([238, 141, 134, 114], [214, 1, 159, 28]), - // log(string,string,bool,uint256) - ([134, 129, 138, 122], [214, 174, 250, 210]), - // log(uint256,address,uint256,string) - ([62, 211, 189, 40], [221, 176, 101, 33]), - // log(uint256,bool,bool,string) - ([49, 138, 229, 155], [221, 219, 149, 97]), - // log(uint256,bool,uint256,string) - ([232, 221, 188, 86], [222, 3, 231, 116]), - // log(string,uint256,bool,address) - ([229, 84, 157, 145], [224, 233, 91, 152]), - // log(string,uint256,uint256,address) - ([190, 215, 40, 191], [226, 29, 226, 120]), - // log(uint256,address,bool,bool) - ([126, 39, 65, 13], [227, 81, 20, 15]), - // log(bool,bool,string,uint256) - ([23, 139, 70, 133], [227, 169, 202, 47]), - // log(string,uint256,bool,uint256) - ([85, 14, 110, 245], [228, 27, 111, 111]), - // log(bool,uint256,string,bool) - ([145, 210, 248, 19], [229, 231, 11, 43]), - // log(uint256,string,address,uint256) - ([152, 231, 243, 243], [232, 211, 1, 141]), - // log(bool,uint256,bool) - ([27, 173, 201, 235], [232, 222, 251, 169]), - // log(uint256,uint256,bool,uint256) - ([108, 100, 124, 140], [235, 127, 111, 210]), - // log(uint256,bool,string,bool) - ([52, 110, 184, 199], [235, 146, 141, 127]), - // log(address,address,string,uint256) - ([4, 40, 147, 0], [239, 28, 239, 231]), - // log(uint256,bool,string,address) - ([73, 110, 43, 180], [239, 82, 144, 24]), - // log(uint256,address,bool,address) - ([182, 49, 48, 148], [239, 114, 197, 19]), - // log(string,string,uint256,uint256) - ([213, 207, 23, 208], [244, 93, 125, 44]), - // log(bool,uint256,string,string) - ([211, 42, 101, 72], [245, 188, 34, 73]), - // log(uint256,uint256) - ([108, 15, 105, 128], [246, 102, 113, 90]), - // log(uint256) and logUint(uint256) - ([245, 177, 187, 169], [248, 44, 80, 241]), - // log(string,address,uint256,uint256) - ([218, 163, 148, 189], [248, 245, 27, 30]), - // log(uint256,uint256,uint256,address) - ([224, 133, 63, 105], [250, 129, 133, 175]), - // log(string,address,uint256,bool) - ([90, 193, 193, 60], [252, 72, 69, 240]), - // log(address,address,uint256,string) - ([157, 209, 46, 173], [253, 180, 249, 144]), - // log(bool,uint256,string,address) - ([165, 199, 13, 41], [254, 221, 31, 255]), - // logInt(int256) - ([78, 12, 29, 29], [101, 37, 181, 245]), - // logBytes(bytes) - ([11, 231, 127, 86], [225, 123, 249, 86]), - // logBytes1(bytes1) - ([110, 24, 161, 40], [111, 65, 113, 201]), - // logBytes2(bytes2) - ([233, 182, 34, 150], [155, 94, 148, 62]), - // logBytes3(bytes3) - ([45, 131, 73, 38], [119, 130, 250, 45]), - // logBytes4(bytes4) - ([224, 95, 72, 209], [251, 163, 173, 57]), - // logBytes5(bytes5) - ([166, 132, 128, 141], [85, 131, 190, 46]), - // logBytes6(bytes6) - ([174, 132, 165, 145], [73, 66, 173, 198]), - // logBytes7(bytes7) - ([78, 213, 126, 40], [69, 116, 175, 171]), - // logBytes8(bytes8) - ([79, 132, 37, 46], [153, 2, 228, 127]), - // logBytes9(bytes9) - ([144, 189, 140, 208], [80, 161, 56, 223]), - // logBytes10(bytes10) - ([1, 61, 23, 139], [157, 194, 168, 151]), - // logBytes11(bytes11) - ([4, 0, 74, 46], [220, 8, 182, 167]), - // logBytes12(bytes12) - ([134, 160, 106, 189], [118, 86, 214, 199]), - // logBytes13(bytes13) - ([148, 82, 158, 52], [52, 193, 216, 27]), - // logBytes14(bytes14) - ([146, 102, 240, 127], [60, 234, 186, 101]), - // logBytes15(bytes15) - ([218, 149, 116, 224], [89, 26, 61, 162]), - // logBytes16(bytes16) - ([102, 92, 97, 4], [31, 141, 115, 18]), - // logBytes17(bytes17) - ([51, 159, 103, 58], [248, 154, 83, 47]), - // logBytes18(bytes18) - ([196, 210, 61, 154], [216, 101, 38, 66]), - // logBytes19(bytes19) - ([94, 107, 90, 51], [0, 245, 107, 201]), - // logBytes20(bytes20) - ([81, 136, 227, 233], [236, 184, 86, 126]), - // logBytes21(bytes21) - ([233, 218, 53, 96], [48, 82, 192, 143]), - // logBytes22(bytes22) - ([213, 250, 232, 156], [128, 122, 180, 52]), - // logBytes23(bytes23) - ([171, 161, 207, 13], [73, 121, 176, 55]), - // logBytes24(bytes24) - ([241, 179, 91, 52], [9, 119, 174, 252]), - // logBytes25(bytes25) - ([11, 132, 188, 88], [174, 169, 150, 63]), - // logBytes26(bytes26) - ([248, 177, 73, 241], [211, 99, 86, 40]), - // logBytes27(bytes27) - ([58, 55, 87, 221], [252, 55, 47, 159]), - // logBytes28(bytes28) - ([200, 42, 234, 238], [56, 47, 154, 52]), - // logBytes29(bytes29) - ([75, 105, 195, 213], [122, 24, 118, 65]), - // logBytes30(bytes30) - ([238, 18, 196, 237], [196, 52, 14, 246]), - // logBytes31(bytes31) - ([194, 133, 77, 146], [129, 252, 134, 72]), - // logBytes32(bytes32) - ([39, 183, 207, 133], [45, 33, 214, 247]), - ]) -}); - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn hardhat_console_patch() { - for (hh, generated) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { - let mut hh = *hh; - patch_hardhat_console_selector(&mut hh); - assert_eq!(hh, *generated); - } - } -} +mod hardhat_console; +pub use hardhat_console::{patch_hardhat_console_selector, HardhatConsole}; diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 669b8292feff8..e14fdea0e9d16 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -178,7 +178,7 @@ impl Display for Instruction { Instruction::Cheatcode(cheat) => write!( f, "VM_{}", - foundry_cheatcodes_spec::Vm::CHEATCODES + crate::abi::Vm::CHEATCODES .iter() .map(|c| &c.func) .find(|c| c.selector_bytes == *cheat) diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 97f0c65c5661d..6812cfd4f5032 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -1,13 +1,10 @@ //! Various utilities to decode test results. -use crate::abi::ConsoleEvents; +use crate::abi::{Console, Vm}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::JsonAbi; -use alloy_primitives::B256; -use alloy_sol_types::{SolCall, SolError, SolInterface, SolValue}; -use ethers_contract::EthLogDecode; -use ethers_core::{abi::RawLog, types::Log, utils::format_units}; -use foundry_cheatcodes_spec::Vm; +use alloy_sol_types::{SolCall, SolError, SolEventInterface, SolInterface, SolValue}; +use ethers_core::types::Log; use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; @@ -21,44 +18,17 @@ pub fn decode_console_logs(logs: &[Log]) -> Vec { /// /// This function returns [None] if it is not a DSTest log or the result of a Hardhat /// `console.log`. +#[instrument(level = "debug", skip_all, fields(topics=?log.topics, data=%log.data), ret)] pub fn decode_console_log(log: &Log) -> Option { - use ConsoleEvents as CE; - - // NOTE: We need to do this conversion because ethers-rs does not - // support passing `Log`s - let raw_log = RawLog { topics: log.topics.clone(), data: log.data.to_vec() }; - let decoded = match ConsoleEvents::decode_log(&raw_log).ok()? { - CE::LogsFilter(inner) => format!("{}", inner.0), - CE::LogBytesFilter(inner) => format!("{}", inner.0), - CE::LogNamedAddressFilter(inner) => format!("{}: {:?}", inner.key, inner.val), - CE::LogNamedBytes32Filter(inner) => { - format!("{}: {}", inner.key, B256::new(inner.val)) - } - CE::LogNamedDecimalIntFilter(inner) => { - let (sign, val) = inner.val.into_sign_and_abs(); - format!( - "{}: {}{}", - inner.key, - sign, - format_units(val, inner.decimals.as_u32()).unwrap() - ) - } - CE::LogNamedDecimalUintFilter(inner) => { - format!("{}: {}", inner.key, format_units(inner.val, inner.decimals.as_u32()).unwrap()) - } - CE::LogNamedIntFilter(inner) => format!("{}: {:?}", inner.key, inner.val), - CE::LogNamedUintFilter(inner) => format!("{}: {:?}", inner.key, inner.val), - CE::LogNamedBytesFilter(inner) => { - format!("{}: {}", inner.key, inner.val) - } - CE::LogNamedStringFilter(inner) => format!("{}: {}", inner.key, inner.val), - CE::LogNamedArray1Filter(inner) => format!("{}: {:?}", inner.key, inner.val), - CE::LogNamedArray2Filter(inner) => format!("{}: {:?}", inner.key, inner.val), - CE::LogNamedArray3Filter(inner) => format!("{}: {:?}", inner.key, inner.val), - - e => e.to_string(), + let topics = log.topics.as_slice(); + // SAFETY: Same type + // TODO: Remove when `ethers::Log` has been replaced + let topics = unsafe { + &*(topics as *const [ethers_core::types::H256] as *const [alloy_primitives::B256]) }; - Some(decoded) + Console::ConsoleEvents::decode_log(topics, &log.data, false) + .ok() + .map(|decoded| decoded.to_string()) } /// Tries to decode an error message from the given revert bytes. diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 44067b2ceaadf..215608f674695 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -19,7 +19,6 @@ foundry-evm-core.workspace = true foundry-evm-coverage.workspace = true foundry-evm-fuzz.workspace = true foundry-evm-traces.workspace = true -foundry-macros.workspace = true foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index f1dbd43c6279d..49d60496be3b3 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -735,9 +735,9 @@ fn convert_executed_result( }; let stipend = calc_stipend(&env.tx.data, env.cfg.spec_id); - let result = match out { - Some(Output::Call(ref data)) => data.to_owned(), - _ => Bytes::default(), + let result = match &out { + Some(Output::Call(data)) => data.clone(), + _ => Bytes::new(), }; let InspectorData { @@ -765,7 +765,7 @@ fn convert_executed_result( gas_used, gas_refunded, stipend, - logs: logs.to_vec(), + logs, labels, traces, coverage, diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index 88b655cbc7a6f..32ccc103aa36a 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,14 +1,11 @@ use alloy_primitives::{Address, Bytes, B256}; -use alloy_sol_types::SolValue; -use ethers_core::{ - abi::AbiDecode, - types::{Log, H256}, -}; +use alloy_sol_types::{SolEvent, SolInterface, SolValue}; +use ethers_core::types::Log; +use foundry_common::fmt::ConsoleFmt; use foundry_evm_core::{ - abi::{patch_hardhat_console_selector, HardhatConsoleCalls}, + abi::{patch_hardhat_console_selector, Console, HardhatConsole}, constants::HARDHAT_CONSOLE_ADDRESS, }; -use foundry_macros::ConsoleFmt; use foundry_utils::types::ToEthers; use revm::{ interpreter::{CallInputs, Gas, InstructionResult}, @@ -17,17 +14,20 @@ use revm::{ /// An inspector that collects logs during execution. /// -/// The inspector collects logs from the LOG opcodes as well as Hardhat-style logs. +/// The inspector collects logs from the `LOG` opcodes as well as Hardhat-style logs. #[derive(Debug, Clone, Default)] pub struct LogCollector { + /// The collected logs. Includes both `LOG` opcodes and Hardhat-style logs. pub logs: Vec, } impl LogCollector { fn hardhat_log(&mut self, mut input: Vec) -> (InstructionResult, Bytes) { - // Patch the Hardhat-style selectors + // Patch the Hardhat-style selector (`uint` instead of `uint256`) patch_hardhat_console_selector(&mut input); - let decoded = match HardhatConsoleCalls::decode(input) { + + // Decode the call + let decoded = match HardhatConsole::HardhatConsoleCalls::abi_decode(&input, false) { Ok(inner) => inner, Err(err) => { return ( @@ -37,7 +37,7 @@ impl LogCollector { } }; - // Convert it to a DS-style `emit log(string)` event + // Convert the decoded call to a DS `log(string)` event self.logs.push(convert_hh_log_to_event(decoded)); (InstructionResult::Continue, Bytes::new()) @@ -59,26 +59,22 @@ impl Inspector for LogCollector { _: &mut EVMData<'_, DB>, call: &mut CallInputs, ) -> (InstructionResult, Gas, Bytes) { - if call.contract == HARDHAT_CONSOLE_ADDRESS { - let (status, reason) = self.hardhat_log(call.input.to_vec()); - (status, Gas::new(call.gas_limit), reason) + let (status, reason) = if call.contract == HARDHAT_CONSOLE_ADDRESS { + self.hardhat_log(call.input.to_vec()) } else { - (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) - } + (InstructionResult::Continue, Bytes::new()) + }; + (status, Gas::new(call.gas_limit), reason) } } -/// Topic 0 of DSTest's `log(string)`. -/// -/// `0x41304facd9323d75b11bcdd609cb38effffdb05710f7caf0e9b16c6d9d709f50` -const TOPIC: H256 = H256([ - 0x41, 0x30, 0x4f, 0xac, 0xd9, 0x32, 0x3d, 0x75, 0xb1, 0x1b, 0xcd, 0xd6, 0x09, 0xcb, 0x38, 0xef, - 0xff, 0xfd, 0xb0, 0x57, 0x10, 0xf7, 0xca, 0xf0, 0xe9, 0xb1, 0x6c, 0x6d, 0x9d, 0x70, 0x9f, 0x50, -]); - /// Converts a call to Hardhat's `console.log` to a DSTest `log(string)` event. -fn convert_hh_log_to_event(call: HardhatConsoleCalls) -> Log { +fn convert_hh_log_to_event(call: HardhatConsole::HardhatConsoleCalls) -> Log { // Convert the parameters of the call to their string representation using `ConsoleFmt`. let fmt = call.fmt(Default::default()); - Log { topics: vec![TOPIC], data: fmt.abi_encode().into(), ..Default::default() } + Log { + topics: vec![Console::log::SIGNATURE_HASH.to_ethers()], + data: fmt.abi_encode().into(), + ..Default::default() + } } diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 64716809fcf3d..7edaedd94e0ff 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -12,7 +12,6 @@ repository.workspace = true [dependencies] foundry-block-explorers.workspace = true -foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index e9fddfd505b0a..2866d8319a396 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -5,17 +5,15 @@ use crate::{ use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function, JsonAbi as Abi}; use alloy_primitives::{Address, Selector, B256}; -use foundry_cheatcodes_spec::Vm; use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ - abi::{CONSOLE_ABI, HARDHAT_CONSOLE_ABI}, + abi::{Console, HardhatConsole, Vm}, constants::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS, }, decode, }; -use foundry_utils::types::ToAlloy; use itertools::Itertools; use once_cell::sync::OnceCell; use std::collections::{hash_map::Entry, BTreeMap, HashMap}; @@ -131,19 +129,17 @@ impl CallTraceDecoder { ] .into(), - functions: HARDHAT_CONSOLE_ABI - .functions() - .map(|func| func.clone().to_alloy()) - .chain(Vm::abi::functions().into_values().flatten()) + functions: HardhatConsole::abi::functions() + .into_values() + .chain(Vm::abi::functions().into_values()) + .flatten() .map(|func| (func.selector(), vec![func])) .collect(), - events: CONSOLE_ABI - .events() - .map(|event| { - let event = event.clone().to_alloy(); - ((event.selector(), indexed_inputs(&event)), vec![event]) - }) + events: Console::abi::events() + .into_values() + .flatten() + .map(|event| ((event.selector(), indexed_inputs(&event)), vec![event])) .collect(), errors: Default::default(), diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index b9473b1526f2d..a9809a951f5d8 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -12,7 +12,7 @@ use foundry_config::{ use foundry_evm::{ decode::decode_console_logs, inspectors::CheatsConfig, revm::primitives::SpecId, }; -use foundry_test_utils::Filter; +use foundry_test_utils::{init_tracing, Filter}; use itertools::Itertools; use std::{collections::BTreeMap, path::Path}; @@ -128,13 +128,6 @@ pub fn test_opts() -> TestOptions { } } -#[allow(unused)] -pub(crate) fn init_tracing() { - let _ = tracing_subscriber::FmtSubscriber::builder() - .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) - .try_init(); -} - pub fn manifest_root() -> &'static Path { let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); // need to check here where we're executing the test from, if in `forge` we need to also allow @@ -147,6 +140,7 @@ pub fn manifest_root() -> &'static Path { /// Builds a base runner pub fn base_runner() -> MultiContractRunnerBuilder { + init_tracing(); MultiContractRunnerBuilder::default().sender(EVM_OPTS.sender) } diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index ef9913b1fb758..a2c070c5342d2 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -9,10 +9,14 @@ license.workspace = true homepage.workspace = true repository.workspace = true -[dependencies] -foundry-macros-impl = { path = "impl" } - -ethers-core.workspace = true +[lib] +proc-macro = true +# proc-macro tests aren't fully supported by cargo-nextest archives +test = false +doc = false -serde.workspace = true -serde_json.workspace = true +[dependencies] +proc-macro2 = "1.0" +quote = "1.0" +syn = "2.0" +proc-macro-error = "1" diff --git a/crates/macros/impl/Cargo.toml b/crates/macros/impl/Cargo.toml deleted file mode 100644 index 83b12193239f8..0000000000000 --- a/crates/macros/impl/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "foundry-macros-impl" -publish = false - -version.workspace = true -edition.workspace = true -rust-version.workspace = true -authors.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true - -[lib] -proc-macro = true -# proc-macro tests aren't fully supported by cargo-nextest archives -test = false -doc = false - -[dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = "2.0" -proc-macro-error = "1" diff --git a/crates/macros/impl/src/lib.rs b/crates/macros/impl/src/lib.rs deleted file mode 100644 index 136b65f5112a4..0000000000000 --- a/crates/macros/impl/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![warn(unused_crate_dependencies)] - -#[macro_use] -extern crate proc_macro_error; - -use proc_macro::TokenStream; -use proc_macro_error::proc_macro_error; -use syn::{parse_macro_input, DeriveInput, Error}; - -mod cheatcodes; -mod console_fmt; - -#[proc_macro_derive(ConsoleFmt)] -pub fn console_fmt(input: TokenStream) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - console_fmt::console_fmt(&input).into() -} - -#[proc_macro_derive(Cheatcode, attributes(cheatcode))] -#[proc_macro_error] -pub fn cheatcode(input: TokenStream) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - cheatcodes::derive_cheatcode(&input).unwrap_or_else(Error::into_compile_error).into() -} diff --git a/crates/macros/impl/src/cheatcodes.rs b/crates/macros/src/cheatcodes.rs similarity index 100% rename from crates/macros/impl/src/cheatcodes.rs rename to crates/macros/src/cheatcodes.rs diff --git a/crates/macros/impl/src/console_fmt.rs b/crates/macros/src/console_fmt.rs similarity index 74% rename from crates/macros/impl/src/console_fmt.rs rename to crates/macros/src/console_fmt.rs index f555b846cc0b6..3ee0077d97399 100644 --- a/crates/macros/impl/src/console_fmt.rs +++ b/crates/macros/src/console_fmt.rs @@ -1,8 +1,6 @@ use proc_macro2::{Delimiter, Group, Ident, TokenStream}; use quote::{format_ident, quote}; -use syn::{ - punctuated::Punctuated, Data, DataEnum, DataStruct, DeriveInput, Field, Fields, Token, Type, -}; +use syn::{punctuated::Punctuated, Data, DataEnum, DataStruct, DeriveInput, Fields, Token, Type}; pub fn console_fmt(input: &DeriveInput) -> TokenStream { let name = &input.ident; @@ -12,7 +10,7 @@ pub fn console_fmt(input: &DeriveInput) -> TokenStream { Data::Union(_) => return quote!(compile_error!("Unions are unsupported");), }; quote! { - impl ::foundry_macros::ConsoleFmt for #name { + impl ::foundry_common::fmt::ConsoleFmt for #name { #tokens } } @@ -21,22 +19,20 @@ pub fn console_fmt(input: &DeriveInput) -> TokenStream { fn derive_struct(s: &DataStruct) -> TokenStream { let imp = impl_struct(s).unwrap_or_else(|| quote!(String::new())); quote! { - fn fmt(&self, _spec: ::foundry_macros::FormatSpec) -> String { + fn fmt(&self, _spec: ::foundry_common::fmt::FormatSpec) -> String { #imp } } } fn impl_struct(s: &DataStruct) -> Option { - let fields: Punctuated<&Field, Token![,]> = match &s.fields { - Fields::Named(fields) => fields.named.iter(), - Fields::Unnamed(fields) => fields.unnamed.iter(), + let fields = match &s.fields { + Fields::Named(fields) => &fields.named, + Fields::Unnamed(fields) => &fields.unnamed, Fields::Unit => return None, - } - .collect(); + }; - let n = fields.len(); - if n == 0 { + if fields.is_empty() { return None } @@ -59,16 +55,13 @@ fn impl_struct(s: &DataStruct) -> Option { let mut args = args.pairs(); let first = args.next().unwrap(); let first = first.value(); - let n = n - 1; quote! { - let args: [&dyn ::foundry_macros::ConsoleFmt; #n] = [#(#args)*]; - ::foundry_macros::console_format((#first).as_str(), args) + ::foundry_common::fmt::console_format((#first).as_str(), &[#(#args)*]) } } else { // console_format("", [...args]) quote! { - let args: [&dyn ::foundry_macros::ConsoleFmt; #n] = [#args]; - ::foundry_macros::console_format("", args) + ::foundry_common::fmt::console_format("", &[#args]) } }; @@ -99,12 +92,12 @@ fn derive_enum(e: &DataEnum) -> TokenStream { let field = fields.into_iter().next().unwrap(); let fields = Group::new(delimiter, quote!(#field)); quote! { - Self::#name #fields => ::foundry_macros::ConsoleFmt::fmt(#field, spec), + Self::#name #fields => ::foundry_common::fmt::ConsoleFmt::fmt(#field, spec), } }); quote! { - fn fmt(&self, spec: ::foundry_macros::FormatSpec) -> String { + fn fmt(&self, spec: ::foundry_common::fmt::FormatSpec) -> String { match self { #(#arms)* diff --git a/crates/macros/src/fmt/mod.rs b/crates/macros/src/fmt/mod.rs deleted file mode 100644 index d6723bd897e7c..0000000000000 --- a/crates/macros/src/fmt/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Helpers for formatting ethereum types - -mod ui; -pub use ui::*; - -mod console_fmt; -pub use console_fmt::{console_format, ConsoleFmt, FormatSpec}; diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index c193cb5d70be2..136b65f5112a4 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -1,13 +1,24 @@ -//! Foundry's procedural macros. -//! -//! Also includes traits and other utilities used by the macros. - #![warn(unused_crate_dependencies)] -extern crate self as foundry_macros; +#[macro_use] +extern crate proc_macro_error; + +use proc_macro::TokenStream; +use proc_macro_error::proc_macro_error; +use syn::{parse_macro_input, DeriveInput, Error}; + +mod cheatcodes; +mod console_fmt; -pub mod fmt; -pub use fmt::{console_format, ConsoleFmt, FormatSpec, UIfmt}; +#[proc_macro_derive(ConsoleFmt)] +pub fn console_fmt(input: TokenStream) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + console_fmt::console_fmt(&input).into() +} -#[doc(inline)] -pub use foundry_macros_impl::{Cheatcode, ConsoleFmt}; +#[proc_macro_derive(Cheatcode, attributes(cheatcode))] +#[proc_macro_error] +pub fn cheatcode(input: TokenStream) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + cheatcodes::derive_cheatcode(&input).unwrap_or_else(Error::into_compile_error).into() +} diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index a450ee688e884..1c2f4bf9c303a 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -1,10 +1,13 @@ //! Temporary utility conversion traits between ethers-rs and alloy types. use alloy_json_abi::{Event, EventParam, Function, InternalType, Param, StateMutability}; -use alloy_primitives::{Address, B256, I256, U256, U64}; +use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U256, U64}; use ethers_core::{ abi as ethabi, - types::{H160, H256, I256 as EthersI256, U256 as EthersU256, U64 as EthersU64}, + types::{ + Bloom as EthersBloom, Bytes as EthersBytes, H160, H256, H64, I256 as EthersI256, + U256 as EthersU256, U64 as EthersU64, + }, }; /// Conversion trait to easily convert from Ethers types to Alloy types. @@ -15,6 +18,24 @@ pub trait ToAlloy { fn to_alloy(self) -> Self::To; } +impl ToAlloy for EthersBytes { + type To = Bytes; + + #[inline(always)] + fn to_alloy(self) -> Self::To { + Bytes(self.0) + } +} + +impl ToAlloy for H64 { + type To = B64; + + #[inline(always)] + fn to_alloy(self) -> Self::To { + B64::new(self.0) + } +} + impl ToAlloy for H160 { type To = Address; @@ -33,6 +54,15 @@ impl ToAlloy for H256 { } } +impl ToAlloy for EthersBloom { + type To = Bloom; + + #[inline(always)] + fn to_alloy(self) -> Self::To { + Bloom::new(self.0) + } +} + impl ToAlloy for EthersU256 { type To = U256; From 441c8537acde910ec663af371c747dd0779bbb70 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:06:09 +0100 Subject: [PATCH 0319/1963] chore: impl To* traits for Bytes (#6400) --- crates/cheatcodes/src/inspector.rs | 4 ++-- crates/chisel/src/executor.rs | 2 +- crates/chisel/src/runner.rs | 2 +- crates/evm/evm/src/inspectors/logs.rs | 2 +- crates/evm/traces/src/lib.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/create.rs | 9 ++++++--- crates/forge/bin/cmd/script/executor.rs | 6 +++--- crates/forge/bin/cmd/script/mod.rs | 2 +- crates/forge/bin/cmd/script/runner.rs | 4 ++-- crates/forge/src/multi_runner.rs | 9 +++------ crates/utils/src/lib.rs | 4 ++-- crates/utils/src/types.rs | 9 +++++++++ 13 files changed, 33 insertions(+), 24 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 2115d8da549fb..0e6bb3624c8f1 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -787,7 +787,7 @@ impl Inspector for Cheatcodes { from: Some(broadcast.new_origin.to_ethers()), to: Some(NameOrAddress::Address(call.contract.to_ethers())), value: Some(call.transfer.value.to_ethers()), - data: Some(call.input.clone().0.into()), + data: Some(call.input.clone().to_ethers()), nonce: Some(account.info.nonce.into()), gas: if is_fixed_gas_limit { Some(call.gas_limit.into()) @@ -1153,7 +1153,7 @@ impl Inspector for Cheatcodes { from: Some(broadcast.new_origin.to_ethers()), to: to.map(|a| NameOrAddress::Address(a.to_ethers())), value: Some(call.value.to_ethers()), - data: Some(bytecode.0.into()), + data: Some(bytecode.to_ethers()), nonce: Some(nonce.into()), gas: if is_fixed_gas_limit { Some(call.gas_limit.into()) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 421c434effc74..04af448c75b92 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -107,7 +107,7 @@ impl SessionSource { let mut runner = self.prepare_runner(final_pc).await; // Return [ChiselResult] or bubble up error - runner.run(bytecode.into_owned().0.into()) + runner.run(bytecode.into_owned()) } else { // Return a default result if no statements are present. Ok((Address::ZERO, ChiselResult::default())) diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 644c6ea96e12b..286cc937c9948 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -92,7 +92,7 @@ impl ChiselRunner { // We don't care about deployment traces / logs here let DeployResult { address, .. } = self .executor - .deploy(self.sender, bytecode.0.into(), U256::ZERO, None) + .deploy(self.sender, bytecode, U256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy REPL contract:\n{}", err))?; // Reset the sender's balance to the initial balance for calls. diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index 32ccc103aa36a..277a3bcf804d6 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -49,7 +49,7 @@ impl Inspector for LogCollector { self.logs.push(Log { address: address.to_ethers(), topics: topics.iter().copied().map(|t| t.to_ethers()).collect(), - data: data.clone().0.into(), + data: data.clone().to_ethers(), ..Default::default() }); } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 3fdf14f6cdf45..d0bb8dd4eb467 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -177,7 +177,7 @@ impl CallTraceArena { // If the top-level trace succeeded, then it was a success failed: !main_trace.success, gas: receipt_gas_used.to_ethers(), - return_value: main_trace.output.to_bytes().0.into(), + return_value: main_trace.output.to_bytes().to_ethers(), ..Default::default() }; diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index b68e35b398b08..635991ad49c52 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -391,7 +391,7 @@ fn dummy_link_bytecode(mut obj: CompactBytecode) -> Option { } obj.object.resolve(); - obj.object.into_bytes().map(|o| o.0.into()) + obj.object.into_bytes() } /// Helper function that will link references in unlinked bytecode to the 0 address. diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index a187148b88911..42c3149eafc07 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -201,7 +201,7 @@ impl CreateArgs { panic!("no bytecode found in bin object for {}", self.contract.name) }); let provider = Arc::new(provider); - let factory = ContractFactory::new(abi.clone(), bin.clone().0.into(), provider.clone()); + let factory = ContractFactory::new(abi.clone(), bin.clone(), provider.clone()); let is_args_empty = args.is_empty(); let deployer = @@ -553,8 +553,11 @@ where // create the tx object. Since we're deploying a contract, `to` is `None` // We default to EIP1559 transactions, but the sender can convert it back // to a legacy one. - let tx = - Eip1559TransactionRequest { to: None, data: Some(data.0.into()), ..Default::default() }; + let tx = Eip1559TransactionRequest { + to: None, + data: Some(data.to_ethers()), + ..Default::default() + }; let tx = tx.into(); diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index c4cff1304de24..2d85e46b5c1b5 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -53,7 +53,7 @@ impl ScriptArgs { let mut runner = self.prepare_runner(script_config, sender, SimulationStage::Local).await; let (address, mut result) = runner.setup( predeploy_libraries, - bytecode.0.into(), + bytecode, needs_setup(&abi), script_config.sender_nonce, self.broadcast, @@ -65,7 +65,7 @@ impl ScriptArgs { // Only call the method if `setUp()` succeeded. if result.success { - let script_result = runner.script(address, calldata.0.into())?; + let script_result = runner.script(address, calldata)?; result.success &= script_result.success; result.gas_used = script_result.gas_used; @@ -154,7 +154,7 @@ impl ScriptArgs { "Transaction doesn't have a `from` address at execution time", ).to_alloy(), tx.to.clone(), - tx.data.clone().map(|b| b.0.into()), + tx.data.clone().map(|b| b.to_alloy()), tx.value.map(|v| v.to_alloy()), ) .expect("Internal EVM error"); diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index e9ba8b4271a6f..a825a2e39921c 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -428,7 +428,7 @@ impl ScriptArgs { rpc: fork_url.clone(), transaction: TypedTransaction::Legacy(TransactionRequest { from: Some(from.to_ethers()), - data: Some(bytes.clone().0.into()), + data: Some(bytes.clone().to_ethers()), nonce: Some((nonce + i as u64).into()), ..Default::default() }), diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 7035c44de7753..592501cc5541a 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -79,7 +79,7 @@ impl ScriptRunner { .. } = self .executor - .deploy(CALLER, code.0.into(), U256::ZERO, None) + .deploy(CALLER, code, U256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy script:\n{}", err))?; traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); @@ -217,7 +217,7 @@ impl ScriptRunner { } else if to.is_none() { let (address, gas_used, logs, traces, debug) = match self.executor.deploy( from, - calldata.expect("No data for create transaction").0.into(), + calldata.expect("No data for create transaction"), value.unwrap_or(U256::ZERO), None, ) { diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 6ba28253ccb26..5253bf7c103c5 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -218,7 +218,7 @@ impl MultiContractRunner { name, executor, contract, - deploy_code.0.into(), + deploy_code, self.evm_opts.initial_balance, self.sender, self.errors.as_ref(), @@ -330,11 +330,8 @@ impl MultiContractRunnerBuilder { id.clone(), ( abi.clone(), - bytecode.0.into(), - dependencies - .into_iter() - .map(|dep| dep.bytecode.0.into()) - .collect::>(), + bytecode, + dependencies.into_iter().map(|dep| dep.bytecode).collect::>(), ), ); } diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index fc23b1d72eca3..d795d667dd038 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -382,7 +382,7 @@ fn recurse_link<'a>( id: library, address: *deployed_address, nonce: *cached_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")).0.into(), + bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")), }); *deployed_address } else { @@ -399,7 +399,7 @@ fn recurse_link<'a>( id: library, address: computed_address, nonce: used_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")).0.into(), + bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")), }); // remember this library for later diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index 1c2f4bf9c303a..a62422c3db6d6 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -237,3 +237,12 @@ impl ToEthers for U64 { EthersU64(self.into_limbs()) } } + +impl ToEthers for Bytes { + type To = EthersBytes; + + #[inline(always)] + fn to_ethers(self) -> Self::To { + EthersBytes(self.0) + } +} From 56ad18de3449c7dfcdc51b3b77e920707a97ffcb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:23:45 +0100 Subject: [PATCH 0320/1963] chore: fix typos (#6399) * chore: fix typos * more --- crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/miner.rs | 2 +- crates/anvil/tests/it/fork.rs | 16 ++++++++-------- crates/anvil/tests/it/otterscan.rs | 2 +- crates/binder/src/utils.rs | 2 +- crates/cheatcodes/src/inspector.rs | 2 +- crates/cheatcodes/src/json.rs | 2 +- crates/cheatcodes/src/utils.rs | 2 +- crates/common/src/runtime_client.rs | 2 +- crates/config/src/inline/natspec.rs | 8 ++++---- crates/config/src/providers/remappings.rs | 2 +- crates/doc/src/builder.rs | 2 +- crates/doc/src/preprocessor/mod.rs | 2 +- crates/doc/src/writer/buf_writer.rs | 4 ++-- crates/evm/core/src/backend/fuzz.rs | 4 ++-- crates/evm/core/src/backend/mod.rs | 4 ++-- crates/evm/coverage/src/analysis.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 2 +- crates/fmt/src/comments.rs | 2 +- crates/fmt/src/formatter.rs | 2 +- crates/fmt/src/solang_ext/ast_eq.rs | 2 +- crates/fmt/testdata/DocComments/fmt.sol | 4 ++-- crates/fmt/testdata/DocComments/original.sol | 4 ++-- .../testdata/DocComments/wrap-comments.fmt.sol | 4 ++-- crates/fmt/testdata/InlineDisable/fmt.sol | 4 ++-- crates/fmt/testdata/InlineDisable/original.sol | 4 ++-- crates/fmt/testdata/UnitExpression/fmt.sol | 4 ++-- crates/fmt/testdata/UnitExpression/original.sol | 4 ++-- crates/forge/bin/cmd/script/receipts.rs | 4 ++-- crates/forge/tests/cli/cmd.rs | 10 +++++----- crates/test-utils/src/util.rs | 2 +- crates/utils/src/lib.rs | 2 +- testdata/cheats/Env.t.sol | 12 ++++++------ testdata/cheats/ExpectCall.t.sol | 4 ++-- testdata/cheats/ExpectRevert.t.sol | 2 +- testdata/cheats/Fork2.t.sol | 2 +- testdata/cheats/RecordAccountAccesses.t.sol | 2 +- testdata/repros/Issue3437.t.sol | 4 ++-- 38 files changed, 70 insertions(+), 70 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index b4093937e86e8..71fd8170b22e4 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1640,7 +1640,7 @@ impl EthApi { Ok(()) } - /// Create a bufer that represents all state on the chain, which can be loaded to separate + /// Create a buffer that represents all state on the chain, which can be loaded to separate /// process by calling `anvil_loadState` /// /// Handler for RPC call: `anvil_dumpState` diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index 9e859f8001886..0c1d1758db214 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -179,7 +179,7 @@ impl Default for FixedBlockTimeMiner { pub struct ReadyTransactionMiner { /// how many transactions to mine per block max_transactions: usize, - /// stores whether there are pending transacions (if known) + /// stores whether there are pending transactions (if known) has_pending_txs: Option, /// Receives hashes of transactions that are ready rx: Fuse>, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index a99a7c6466062..2258d0341772d 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -503,26 +503,26 @@ async fn test_fork_nft_set_approve_all() { let nouns = Erc721::new(nouns_addr, Arc::clone(&provider)); - let real_onwer = nouns.owner_of(token_id).call().await.unwrap(); - assert_eq!(real_onwer, owner); + let real_owner = nouns.owner_of(token_id).call().await.unwrap(); + assert_eq!(real_owner, owner); let approval = nouns.set_approval_for_all(nouns_addr, true); let tx = approval.send().await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); // transfer: impersonate real owner and transfer nft - api.anvil_impersonate_account(real_onwer).await.unwrap(); + api.anvil_impersonate_account(real_owner).await.unwrap(); - api.anvil_set_balance(real_onwer, U256::from(10000e18 as u64)).await.unwrap(); + api.anvil_set_balance(real_owner, U256::from(10000e18 as u64)).await.unwrap(); - let call = nouns.transfer_from(real_onwer, wallet.address(), token_id); + let call = nouns.transfer_from(real_owner, wallet.address(), token_id); let mut tx: TypedTransaction = call.tx; - tx.set_from(real_onwer); + tx.set_from(real_owner); provider.fill_transaction(&mut tx, None).await.unwrap(); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); - let real_onwer = nouns.owner_of(token_id).call().await.unwrap(); - assert_eq!(real_onwer, wallet.address()); + let real_owner = nouns.owner_of(token_id).call().await.unwrap(); + assert_eq!(real_owner, wallet.address()); } // diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 3c460424ccbfe..becbcb852e534 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -65,7 +65,7 @@ async fn can_call_ots_get_internal_operations_contract_deploy() { } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_internal_operations_contract_trasfer() { +async fn can_call_ots_get_internal_operations_contract_transfer() { let (api, handle) = spawn(NodeConfig::test()).await; let provider = handle.http_provider(); diff --git a/crates/binder/src/utils.rs b/crates/binder/src/utils.rs index 7667fe26f148e..a2186b650a9e6 100644 --- a/crates/binder/src/utils.rs +++ b/crates/binder/src/utils.rs @@ -527,7 +527,7 @@ where // // If ssh-agent authentication fails, libgit2 will keep calling this // callback asking for other authentication methods to try. Check - // cred_helper_bad to make sure we only try the git credentail helper + // cred_helper_bad to make sure we only try the git credential helper // once, to avoid looping forever. if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none() { diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 0e6bb3624c8f1..7a5859c5fe910 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -129,7 +129,7 @@ pub struct Cheatcodes { /// Address labels pub labels: HashMap, - /// Rememebered private keys + /// Remembered private keys pub script_wallets: Vec, /// Whether the skip cheatcode was activated diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index f401d7903ce10..94f8f9440a28b 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -404,7 +404,7 @@ pub(super) fn value_to_token(value: &Value) -> Result { // to f64. let s = number.to_string(); - // Coerced to scientific notation, so short-ciruit to using fallback. + // Coerced to scientific notation, so short-circuit to using fallback. // This will not have a problem with hex numbers, as for parsing these // We'd need to prefix this with 0x. // See also diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 020d465cc3fe9..e319cfebc895c 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -135,7 +135,7 @@ impl Cheatcode for computeCreate2Address_1Call { } /// Using a given private key, return its public ETH address, its public key affine x and y -/// coodinates, and its private key (see the 'Wallet' struct) +/// coordinates, and its private key (see the 'Wallet' struct) /// /// If 'label' is set to 'Some()', assign that label to the associated ETH address in state fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes) -> Result { diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index 62d4810dcb90b..972ee9029540a 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -118,7 +118,7 @@ fn build_auth(jwt: String) -> eyre::Result { let auth = JwtAuth::new(secret, None, None); let token = auth.generate_token()?; - // Essentially unrolled ethers-rs new_with_auth to accomodate the custom timeout + // Essentially unrolled ethers-rs new_with_auth to accommodate the custom timeout let auth = Authorization::Bearer(token); Ok(auth) diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 407317d32894d..c73cc4492dc75 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -192,8 +192,8 @@ mod tests { #[test] fn can_handle_unavailable_src_line_with_fallback() { let mut fn_data: BTreeMap = BTreeMap::new(); - let doc_withouth_src_field = json!({ "text": "forge-config:default.fuzz.runs=600" }); - fn_data.insert("documentation".into(), doc_withouth_src_field); + let doc_without_src_field = json!({ "text": "forge-config:default.fuzz.runs=600" }); + fn_data.insert("documentation".into(), doc_without_src_field); let (_, src_line) = get_fn_docs(&fn_data).expect("Some docs"); assert_eq!(src_line, "".to_string()); } @@ -201,9 +201,9 @@ mod tests { #[test] fn can_handle_available_src_line() { let mut fn_data: BTreeMap = BTreeMap::new(); - let doc_withouth_src_field = + let doc_without_src_field = json!({ "text": "forge-config:default.fuzz.runs=600", "src": "73:21:12" }); - fn_data.insert("documentation".into(), doc_withouth_src_field); + fn_data.insert("documentation".into(), doc_without_src_field); let (_, src_line) = get_fn_docs(&fn_data).expect("Some docs"); assert_eq!(src_line, "73:21:12".to_string()); } diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 43048643a822e..7d81b568c8902 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -45,7 +45,7 @@ impl Remappings { remappings } - /// Push an element ot the remappings vector, but only if it's not already present. + /// Push an element to the remappings vector, but only if it's not already present. pub fn push(&mut self, remapping: Remapping) { if !self.remappings.iter().any(|existing| { // What we're doing here is filtering for ambiguous paths. For example, if we have diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index c4f68d8096661..177c45e7c31e3 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -66,7 +66,7 @@ impl DocBuilder { } } - /// Set `shoul_build` flag on the builder + /// Set `should_build` flag on the builder pub fn with_should_build(mut self, should_build: bool) -> Self { self.should_build = should_build; self diff --git a/crates/doc/src/preprocessor/mod.rs b/crates/doc/src/preprocessor/mod.rs index 5874dab54cd16..40cb7843cb669 100644 --- a/crates/doc/src/preprocessor/mod.rs +++ b/crates/doc/src/preprocessor/mod.rs @@ -20,7 +20,7 @@ pub use deployments::{Deployment, Deployments, DEPLOYMENTS_ID}; pub struct PreprocessorId(&'static str); /// Preprocessor output. -/// Wraps all exisiting preprocessor outputs +/// Wraps all existing preprocessor outputs /// in a single abstraction. #[derive(Debug, Clone)] pub enum PreprocessorOutput { diff --git a/crates/doc/src/writer/buf_writer.rs b/crates/doc/src/writer/buf_writer.rs index af9a3b80e5bae..3c1728b840ba4 100644 --- a/crates/doc/src/writer/buf_writer.rs +++ b/crates/doc/src/writer/buf_writer.rs @@ -80,7 +80,7 @@ impl BufWriter { writeln!(self.buf, "{}", Markdown::Italic(text)) } - /// Writes bold text to the bufffer formatted as [Markdown::Bold]. + /// Writes bold text to the buffer formatted as [Markdown::Bold]. pub fn write_bold(&mut self, text: &str) -> fmt::Result { writeln!(self.buf, "{}", Markdown::Bold(text)) } @@ -90,7 +90,7 @@ impl BufWriter { writeln!(self.buf, "{}", Markdown::Link(name, path)) } - /// Writes a list item to the bufffer indented by specified depth. + /// Writes a list item to the buffer indented by specified depth. pub fn write_list_item(&mut self, item: &str, depth: usize) -> fmt::Result { let indent = " ".repeat(depth * 2); writeln!(self.buf, "{indent}- {item}") diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index 7fa3de4b25469..ac15212b27440 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -37,9 +37,9 @@ pub struct FuzzBackendWrapper<'a> { /// /// No calls on the `FuzzBackendWrapper` will ever persistently modify the `backend`'s state. pub backend: Cow<'a, Backend>, - /// Keeps track of whether the backed is already intialized + /// Keeps track of whether the backed is already initialized is_initialized: bool, - /// Keeps track of wheter there was a snapshot failure. + /// Keeps track of whether there was a snapshot failure. /// /// Necessary as the backend is dropped after usage, but we'll need to persist /// the snapshot failure anyhow. diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 4e756af98268f..1600f0e6484ea 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -779,8 +779,8 @@ impl Backend { self.inner.precompiles().contains(addr) } - /// Ths will clean up already loaded accounts that would be initialized without the correct data - /// from the fork + /// Cleans up already loaded accounts that would be initialized without the correct data from + /// the fork. /// /// It can happen that an account is loaded before the first fork is selected, like /// `getNonce(addr)`, which will load an empty account by default. diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index a28dc6ea77db4..8928f44770c1e 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -528,7 +528,7 @@ impl SourceAnalyzer { // // The missing contracts are: // 1. libraries used in ancestors of this contracts - // 2. libraries used in libaries (i.e libs indirectly used by this contract) + // 2. libraries used in libraries (i.e libs indirectly used by this contract) // // We want to find out all the above contracts and libraries related to this contract. diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 81ea0e669e6be..fa56c97c4dc9b 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -749,7 +749,7 @@ fn can_continue( } else { // Increase the amount of reverts. failures.reverts += 1; - // If fail on revert is set, we must return inmediately. + // If fail on revert is set, we must return immediately. if fail_on_revert { let error = InvariantFuzzError::new( invariant_contract, diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index a76c64ffc53a2..f0316aa2b9c9a 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -230,7 +230,7 @@ impl Comments { Self { prefixes, postfixes } } - /// Heloer for removing comments before a byte offset + /// Helper for removing comments before a byte offset fn remove_comments_before( comments: &mut VecDeque, byte: usize, diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 95dba14d4996c..467fa72bff2b6 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1071,7 +1071,7 @@ impl<'a, W: Write> Formatter<'a, W> { /// Visit the right side of an assignment. The function will try to write the assignment on a /// single line or indented on the next line. If it can't do this it resorts to letting the - /// expression decide how to split iself on multiple lines + /// expression decide how to split itself on multiple lines fn visit_assignment(&mut self, expr: &mut Expression) -> Result<()> { if self.try_on_single_line(|fmt| expr.visit(fmt))? { return Ok(()) diff --git a/crates/fmt/src/solang_ext/ast_eq.rs b/crates/fmt/src/solang_ext/ast_eq.rs index 9990618df5655..f29a7cc026831 100644 --- a/crates/fmt/src/solang_ext/ast_eq.rs +++ b/crates/fmt/src/solang_ext/ast_eq.rs @@ -311,7 +311,7 @@ impl AstEq for Statement { While(loc, expr, stmt1), DoWhile(loc, stmt1, expr), For(loc, stmt1, expr, stmt2, stmt3), - Try(loc, expr, params, claus), + Try(loc, expr, params, clause), Error(loc) _ Block { diff --git a/crates/fmt/testdata/DocComments/fmt.sol b/crates/fmt/testdata/DocComments/fmt.sol index a002e6c2364f4..4248f0fe587da 100644 --- a/crates/fmt/testdata/DocComments/fmt.sol +++ b/crates/fmt/testdata/DocComments/fmt.sol @@ -49,7 +49,7 @@ contract HelloWorld { /// A long doc line comment that will be wrapped function docLineOverflow() external {} - function docLinePostfixOveflow() external {} + function docLinePostfixOverflow() external {} /// A long doc line comment that will be wrapped @@ -87,7 +87,7 @@ contract HelloWorld { * } * } */ - function malformedIndentOveflow() external {} + function malformedIndentOverflow() external {} } /** diff --git a/crates/fmt/testdata/DocComments/original.sol b/crates/fmt/testdata/DocComments/original.sol index dff602236c248..28f654b57903d 100644 --- a/crates/fmt/testdata/DocComments/original.sol +++ b/crates/fmt/testdata/DocComments/original.sol @@ -46,7 +46,7 @@ contract HelloWorld { /// A long doc line comment that will be wrapped function docLineOverflow() external {} - function docLinePostfixOveflow() external {} /// A long doc line comment that will be wrapped + function docLinePostfixOverflow() external {} /// A long doc line comment that will be wrapped /** * @notice Here is my comment @@ -82,7 +82,7 @@ function withALongNameThatWillCauseCommentWrap() public { } } */ - function malformedIndentOveflow() external {} + function malformedIndentOverflow() external {} } /** diff --git a/crates/fmt/testdata/DocComments/wrap-comments.fmt.sol b/crates/fmt/testdata/DocComments/wrap-comments.fmt.sol index 6d7f3c584ce44..c3c7fe00c9180 100644 --- a/crates/fmt/testdata/DocComments/wrap-comments.fmt.sol +++ b/crates/fmt/testdata/DocComments/wrap-comments.fmt.sol @@ -64,7 +64,7 @@ contract HelloWorld { external {} - function docLinePostfixOveflow() + function docLinePostfixOverflow() external {} @@ -113,7 +113,7 @@ contract HelloWorld { * } * } */ - function malformedIndentOveflow() + function malformedIndentOverflow() external {} } diff --git a/crates/fmt/testdata/InlineDisable/fmt.sol b/crates/fmt/testdata/InlineDisable/fmt.sol index 03979bc188935..31667c5e99a43 100644 --- a/crates/fmt/testdata/InlineDisable/fmt.sol +++ b/crates/fmt/testdata/InlineDisable/fmt.sol @@ -406,9 +406,9 @@ function testUnit() { value = 1 gwei; value = 1 ether; - uint256 someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue; + uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; - value = someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 + value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 value = 1 // comment3 // comment4 diff --git a/crates/fmt/testdata/InlineDisable/original.sol b/crates/fmt/testdata/InlineDisable/original.sol index 617da7719c2c6..83d4ee172b00d 100644 --- a/crates/fmt/testdata/InlineDisable/original.sol +++ b/crates/fmt/testdata/InlineDisable/original.sol @@ -387,9 +387,9 @@ function testUnit() { value = 1 gwei; value = 1 ether; - uint256 someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue; + uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; - value = someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 + value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 value = 1 // comment3 // comment4 diff --git a/crates/fmt/testdata/UnitExpression/fmt.sol b/crates/fmt/testdata/UnitExpression/fmt.sol index 2d616ee6e07a0..ceb16c86c7813 100644 --- a/crates/fmt/testdata/UnitExpression/fmt.sol +++ b/crates/fmt/testdata/UnitExpression/fmt.sol @@ -12,9 +12,9 @@ contract UnitExpression { value = 1 gwei; value = 1 ether; - uint256 someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue; + uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; - value = someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue + value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 value = 1 // comment3 diff --git a/crates/fmt/testdata/UnitExpression/original.sol b/crates/fmt/testdata/UnitExpression/original.sol index b48a1d49fc6a5..f85af34fe7770 100644 --- a/crates/fmt/testdata/UnitExpression/original.sol +++ b/crates/fmt/testdata/UnitExpression/original.sol @@ -12,9 +12,9 @@ contract UnitExpression { value = 1 gwei; value = 1 ether; - uint256 someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue; + uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; - value = someVeryVeryVeryLongVaribleNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 + value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 value = 1 // comment3 // comment4 diff --git a/crates/forge/bin/cmd/script/receipts.rs b/crates/forge/bin/cmd/script/receipts.rs index 638e92f91f86a..79565996587fe 100644 --- a/crates/forge/bin/cmd/script/receipts.rs +++ b/crates/forge/bin/cmd/script/receipts.rs @@ -41,7 +41,7 @@ pub async fn wait_for_pending( } /// Traverses a set of pendings and either finds receipts, or clears them from -/// the deployment sequnce. +/// the deployment sequence. /// /// If no `tx_hashes` are provided, then `deployment_sequence.pending` will be /// used. For each `tx_hash`, we check if it has confirmed. If it has @@ -111,7 +111,7 @@ pub async fn clear_pendings( deployment_sequence.add_receipt(receipt); } - // print any erros + // print any errors if !errors.is_empty() { let mut error_msg = errors.join("\n"); if !deployment_sequence.pending.is_empty() { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index a9eee34f3a528..8eafecce5845c 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1401,9 +1401,9 @@ contract ContractThreeTest is DSTest { }); forgetest_init!(can_use_absolute_imports, |prj, cmd| { - let remapping = prj.paths().libraries[0].join("myDepdendency"); + let remapping = prj.paths().libraries[0].join("myDependency"); let config = Config { - remappings: vec![Remapping::from_str(&format!("myDepdendency/={}", remapping.display())) + remappings: vec![Remapping::from_str(&format!("myDependency/={}", remapping.display())) .unwrap() .into()], ..Default::default() @@ -1411,7 +1411,7 @@ forgetest_init!(can_use_absolute_imports, |prj, cmd| { prj.write_config(config); prj.add_lib( - "myDepdendency/src/interfaces/IConfig.sol", + "myDependency/src/interfaces/IConfig.sol", r" interface IConfig {} @@ -1420,7 +1420,7 @@ forgetest_init!(can_use_absolute_imports, |prj, cmd| { .unwrap(); prj.add_lib( - "myDepdendency/src/Config.sol", + "myDependency/src/Config.sol", r#" import "src/interfaces/IConfig.sol"; @@ -1432,7 +1432,7 @@ forgetest_init!(can_use_absolute_imports, |prj, cmd| { prj.add_source( "Greeter", r#" - import "myDepdendency/src/Config.sol"; + import "myDependency/src/Config.sol"; contract Greeter {} "#, diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 10a6db9fdddb0..6a879378acdf7 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -225,7 +225,7 @@ pub fn setup_forge_remote(prj: impl Into) -> (TestProject, TestCo try_setup_forge_remote(prj).unwrap() } -/// Same as `setup_forge_remote` but not panicing +/// Same as `setup_forge_remote` but not panicking pub fn try_setup_forge_remote( config: impl Into, ) -> Result<(TestProject, TestCommand)> { diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index d795d667dd038..92c58ebbacaf8 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -286,7 +286,7 @@ fn recurse_link<'a>( // libraries we have already deployed during the linking process. // the key is `file:contract` and the value is the address we computed internally_deployed_libraries: &'a mut HashMap, - // deployed library addresses fname => adddress + // deployed library addresses fname => address deployed_library_addresses: &'a Libraries, // nonce to start at nonce: &mut u64, diff --git a/testdata/cheats/Env.t.sol b/testdata/cheats/Env.t.sol index 179f2c2998e35..ae6c89ec9856c 100644 --- a/testdata/cheats/Env.t.sol +++ b/testdata/cheats/Env.t.sol @@ -968,8 +968,8 @@ contract EnvTest is DSTest { } } - function testEnvWithDefaulBytesEmptyArrKey() public { - string memory key = "_foundryCheatcodeEnvWithDefaulBytesEmptyArrTestKey"; + function testEnvWithDefaultBytesEmptyArrKey() public { + string memory key = "_foundryCheatcodeEnvWithDefaultBytesEmptyArrTestKey"; string memory value = ""; bytes[] memory expected = new bytes[](0); bytes[] memory defaultValues = new bytes[](0); @@ -980,13 +980,13 @@ contract EnvTest is DSTest { for (uint256 i = 0; i < expected.length; ++i) { require( keccak256(abi.encodePacked((output[i]))) == keccak256(abi.encodePacked((expected[i]))), - "envWithDefaulBytesEmptyArrKey failed" + "envWithDefaultBytesEmptyArrKey failed" ); } } - function testEnvWithDefaulBytesEmptyArrDefault() public { - string memory key = "_foundryCheatcodeEnvWithDefaulBytesEmptyArrTestDefault"; + function testEnvWithDefaultBytesEmptyArrDefault() public { + string memory key = "_foundryCheatcodeEnvWithDefaultBytesEmptyArrTestDefault"; string memory value = ""; bytes[] memory expected = new bytes[](0); bytes[] memory defaultValues = new bytes[](0); @@ -996,7 +996,7 @@ contract EnvTest is DSTest { for (uint256 i = 0; i < expected.length; ++i) { require( keccak256(abi.encodePacked((output[i]))) == keccak256(abi.encodePacked((expected[i]))), - "envWithDefaulBytesEmptyArrDefault failed" + "envWithDefaultBytesEmptyArrDefault failed" ); } } diff --git a/testdata/cheats/ExpectCall.t.sol b/testdata/cheats/ExpectCall.t.sol index 2fb33d91fcaa2..3cc9e6c573c07 100644 --- a/testdata/cheats/ExpectCall.t.sol +++ b/testdata/cheats/ExpectCall.t.sol @@ -451,7 +451,7 @@ contract ExpectCallMixedTest is DSTest { function testExpectMatchPartialAndFull() public { Contract target = new Contract(); vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector), 2); - // Even if a partial match is speciifed, you should still be able to look for full matches + // Even if a partial match is specified, you should still be able to look for full matches // as one does not override the other. vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); this.exposed_expectMatchPartialAndFull(target); @@ -465,7 +465,7 @@ contract ExpectCallMixedTest is DSTest { function testExpectMatchPartialAndFullFlipped() public { Contract target = new Contract(); vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); - // Even if a partial match is speciifed, you should still be able to look for full matches + // Even if a partial match is specified, you should still be able to look for full matches // as one does not override the other. vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); this.exposed_expectMatchPartialAndFullFlipped(target); diff --git a/testdata/cheats/ExpectRevert.t.sol b/testdata/cheats/ExpectRevert.t.sol index 9fdeb2fef9d43..b2179a25db982 100644 --- a/testdata/cheats/ExpectRevert.t.sol +++ b/testdata/cheats/ExpectRevert.t.sol @@ -89,7 +89,7 @@ contract ExpectRevertTest is DSTest { function testFailRevertNotOnImmediateNextCall() public { Reverter reverter = new Reverter(); // expectRevert should only work for the next call. However, - // we do not inmediately revert, so, + // we do not immediately revert, so, // we fail. vm.expectRevert("revert"); reverter.doNotRevert(); diff --git a/testdata/cheats/Fork2.t.sol b/testdata/cheats/Fork2.t.sol index c4cab03b880c5..382cb1b915962 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/cheats/Fork2.t.sol @@ -62,7 +62,7 @@ contract ForkTest is DSTest { } // ensures forks have different block hashes - function testBlockNumbersMimatch() public { + function testBlockNumbersMismatch() public { vm.selectFork(mainnetFork); uint256 num = block.number; bytes32 mainHash = blockhash(block.number - 1); diff --git a/testdata/cheats/RecordAccountAccesses.t.sol b/testdata/cheats/RecordAccountAccesses.t.sol index 60652c130ed0e..9f818e8eed8f6 100644 --- a/testdata/cheats/RecordAccountAccesses.t.sol +++ b/testdata/cheats/RecordAccountAccesses.t.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "./Vm.sol"; -/// @notice Helper contract with a constructo that makes a call to itself then +/// @notice Helper contract with a construction that makes a call to itself then /// optionally reverts if zero-length data is passed contract SelfCaller { constructor(bytes memory) payable { diff --git a/testdata/repros/Issue3437.t.sol b/testdata/repros/Issue3437.t.sol index 4174bea208880..acd02ada74214 100644 --- a/testdata/repros/Issue3437.t.sol +++ b/testdata/repros/Issue3437.t.sol @@ -8,12 +8,12 @@ import "../cheats/Vm.sol"; contract Issue3347Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - function rever() internal { + function internalRevert() internal { revert(); } function testFailExample() public { vm.expectRevert(); - rever(); + internalRevert(); } } From 7fcb73039515d9815b32e6ca4202cbab5f3b9553 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 22 Nov 2023 19:09:28 +0100 Subject: [PATCH 0321/1963] test: add cast proof test (#6403) * test: add test for cast proof * add additional cases --- crates/cast/bin/opts.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index b763821fa06da..dcd557d310fae 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -883,6 +883,35 @@ mod tests { use cast::SimpleCast; use ethers_core::types::BlockNumber; + #[test] + fn parse_proof_slot() { + let args: Opts = Opts::parse_from([ + "foundry-cli", + "proof", + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "0", + "1", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x1", + "0x01", + ]); + match args.sub { + Subcommands::Proof { slots, .. } => { + assert_eq!( + slots, + vec![ + B256::ZERO, + U256::from(1).into(), + B256::ZERO, + U256::from(1).into(), + U256::from(1).into() + ] + ); + } + _ => unreachable!(), + }; + } + #[test] fn parse_call_data() { let args: Opts = Opts::parse_from([ From fdaed8603fc330cbc94c936f15594bccdc381225 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 22 Nov 2023 20:01:31 +0100 Subject: [PATCH 0322/1963] refactor: remove foundry-utils (#6401) * refactor: rewrite ErrorExt * chore: move linking code to forge crate * refactor: remove foundry-utils * rm dead code * improve Retry * fmt * clippy, bump, use Vec instead of Bytes * let-else * fix decoding * mkconst --- Cargo.lock | 56 ++------- Cargo.toml | 2 - crates/anvil/Cargo.toml | 1 - crates/anvil/core/Cargo.toml | 4 +- crates/anvil/core/src/eth/proof.rs | 3 +- crates/anvil/core/src/eth/receipt.rs | 2 +- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- crates/anvil/core/src/eth/utils.rs | 2 +- crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/api.rs | 3 +- crates/anvil/src/eth/backend/db.rs | 3 +- crates/anvil/src/eth/backend/executor.rs | 2 +- crates/anvil/src/eth/backend/genesis.rs | 2 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 2 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 4 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/eth/backend/mem/state.rs | 2 +- crates/anvil/src/eth/backend/mem/storage.rs | 4 +- crates/anvil/src/eth/otterscan/types.rs | 2 +- crates/anvil/src/eth/util.rs | 2 +- crates/anvil/src/genesis.rs | 3 +- crates/anvil/tests/it/fork.rs | 7 +- crates/anvil/tests/it/proof/mod.rs | 2 +- crates/cast/Cargo.toml | 1 - crates/cast/bin/cmd/access_list.rs | 2 +- crates/cast/bin/cmd/call.rs | 6 +- crates/cast/bin/cmd/find_block.rs | 2 +- crates/cast/bin/cmd/run.rs | 3 +- crates/cast/bin/cmd/send.rs | 6 +- crates/cast/bin/cmd/storage.rs | 2 +- crates/cast/bin/cmd/wallet/mod.rs | 6 +- crates/cast/bin/cmd/wallet/vanity.rs | 2 +- crates/cast/bin/main.rs | 2 +- crates/cast/src/base.rs | 2 +- crates/cast/src/lib.rs | 10 +- crates/cast/src/tx.rs | 8 +- crates/cast/tests/cli/main.rs | 2 +- crates/cheatcodes/Cargo.toml | 1 - crates/cheatcodes/src/error.rs | 28 +++-- crates/cheatcodes/src/evm.rs | 3 +- crates/cheatcodes/src/evm/fork.rs | 6 +- crates/cheatcodes/src/inspector.rs | 9 +- crates/cheatcodes/src/script.rs | 2 +- crates/cheatcodes/src/test/expect.rs | 73 +++++------ crates/cheatcodes/src/utils.rs | 2 +- crates/chisel/Cargo.toml | 1 - crates/chisel/src/executor.rs | 2 +- crates/cli/Cargo.toml | 3 +- crates/cli/src/opts/wallet/mod.rs | 3 +- crates/cli/src/opts/wallet/multi_wallet.rs | 3 +- crates/cli/src/utils/mod.rs | 10 +- crates/common/Cargo.toml | 4 +- crates/common/src/fmt/ui.rs | 2 +- crates/common/src/fs.rs | 9 ++ crates/common/src/glob.rs | 26 +++- crates/common/src/lib.rs | 3 + crates/common/src/retry.rs | 58 +++++++++ crates/{utils => common}/src/rpc.rs | 4 +- crates/common/src/traits.rs | 16 ++- crates/{utils => common}/src/types.rs | 2 + crates/doc/Cargo.toml | 2 +- crates/doc/src/builder.rs | 2 +- crates/evm/core/Cargo.toml | 1 - crates/evm/core/src/abi/console.rs | 2 +- crates/evm/core/src/backend/mod.rs | 7 +- crates/evm/core/src/fork/backend.rs | 6 +- crates/evm/core/src/fork/database.rs | 2 +- crates/evm/core/src/fork/init.rs | 3 +- crates/evm/core/src/fork/multi.rs | 3 +- crates/evm/core/src/utils.rs | 2 +- crates/evm/evm/Cargo.toml | 1 - crates/evm/evm/src/inspectors/access_list.rs | 2 +- crates/evm/evm/src/inspectors/debugger.rs | 4 +- crates/evm/evm/src/inspectors/logs.rs | 10 +- crates/evm/fuzz/Cargo.toml | 1 - crates/evm/fuzz/src/inspector.rs | 2 +- crates/evm/fuzz/src/strategies/state.rs | 6 +- crates/evm/traces/Cargo.toml | 2 - crates/evm/traces/src/lib.rs | 6 +- crates/evm/traces/src/node.rs | 2 +- crates/forge/Cargo.toml | 1 - crates/forge/bin/cmd/create.rs | 7 +- crates/forge/bin/cmd/fmt.rs | 5 +- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/bin/cmd/retry.rs | 5 +- crates/forge/bin/cmd/script/broadcast.rs | 2 +- crates/forge/bin/cmd/script/build.rs | 4 +- crates/forge/bin/cmd/script/cmd.rs | 7 +- crates/forge/bin/cmd/script/executor.rs | 3 +- crates/forge/bin/cmd/script/mod.rs | 5 +- crates/forge/bin/cmd/script/providers.rs | 3 +- crates/forge/bin/cmd/script/receipts.rs | 6 +- crates/forge/bin/cmd/script/sequence.rs | 7 +- crates/forge/bin/cmd/script/transaction.rs | 7 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 23 ++-- crates/forge/bin/cmd/verify/sourcify.rs | 3 +- crates/forge/src/coverage.rs | 2 + crates/forge/src/gas_report.rs | 2 + crates/forge/src/lib.rs | 42 +++++-- .../{utils/src/lib.rs => forge/src/link.rs} | 115 +----------------- crates/forge/src/multi_runner.rs | 11 +- crates/forge/src/result.rs | 2 +- crates/forge/src/runner.rs | 2 + crates/forge/tests/cli/cmd.rs | 2 +- crates/forge/tests/cli/multi_script.rs | 2 +- crates/forge/tests/cli/script.rs | 4 +- crates/forge/tests/cli/test_cmd.rs | 2 +- crates/forge/tests/cli/verify.rs | 11 +- crates/forge/tests/it/fork.rs | 4 +- crates/test-utils/Cargo.toml | 1 - crates/test-utils/src/macros.rs | 2 +- crates/test-utils/src/script.rs | 7 +- crates/utils/Cargo.toml | 33 ----- crates/utils/README.md | 3 - crates/utils/src/abi.rs | 8 -- crates/utils/src/error.rs | 33 ----- crates/utils/src/glob.rs | 13 -- crates/utils/src/path.rs | 10 -- 118 files changed, 405 insertions(+), 500 deletions(-) create mode 100644 crates/common/src/retry.rs rename crates/{utils => common}/src/rpc.rs (97%) rename crates/{utils => common}/src/types.rs (98%) rename crates/{utils/src/lib.rs => forge/src/link.rs} (90%) delete mode 100644 crates/utils/Cargo.toml delete mode 100644 crates/utils/README.md delete mode 100644 crates/utils/src/abi.rs delete mode 100644 crates/utils/src/error.rs delete mode 100644 crates/utils/src/glob.rs delete mode 100644 crates/utils/src/path.rs diff --git a/Cargo.lock b/Cargo.lock index 8434a01d431e9..44d590ae527d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" +source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -110,7 +110,7 @@ dependencies = [ [[package]] name = "alloy-json-abi" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" +source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "alloy-primitives" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" +source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" dependencies = [ "alloy-rlp", "arbitrary", @@ -168,7 +168,7 @@ dependencies = [ [[package]] name = "alloy-sol-macro" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" +source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" dependencies = [ "alloy-json-abi", "const-hex", @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" +source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" dependencies = [ "winnow", ] @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-sol-types" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" +source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -312,7 +312,6 @@ dependencies = [ "foundry-common", "foundry-config", "foundry-evm", - "foundry-utils", "futures", "hash-db", "hyper", @@ -344,8 +343,8 @@ dependencies = [ "anvil-core", "bytes", "ethers-core", + "foundry-common", "foundry-evm", - "foundry-utils", "hash-db", "hash256-std-hasher", "keccak-hasher", @@ -1003,7 +1002,6 @@ dependencies = [ "foundry-config", "foundry-evm", "foundry-test-utils", - "foundry-utils", "futures", "indicatif", "itertools 0.11.0", @@ -1071,7 +1069,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm", - "foundry-utils", "once_cell", "regex", "reqwest", @@ -2535,7 +2532,6 @@ dependencies = [ "foundry-debugger", "foundry-evm", "foundry-test-utils", - "foundry-utils", "futures", "globset", "hyper", @@ -2578,9 +2574,9 @@ dependencies = [ "derive_more", "eyre", "forge-fmt", + "foundry-common", "foundry-compilers", "foundry-config", - "foundry-utils", "itertools 0.11.0", "mdbook", "once_cell", @@ -2667,7 +2663,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm-core", - "foundry-utils", "itertools 0.11.0", "jsonpath_lib", "revm", @@ -2703,12 +2698,12 @@ dependencies = [ "ethers-providers", "ethers-signers", "eyre", + "forge-fmt", "foundry-common", "foundry-compilers", "foundry-config", "foundry-debugger", "foundry-evm", - "foundry-utils", "indicatif", "itertools 0.11.0", "once_cell", @@ -2735,6 +2730,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-sol-types", "async-trait", "auto_impl", "clap", @@ -2749,10 +2745,11 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-macros", - "foundry-utils", + "glob", "globset", "once_cell", "pretty_assertions", + "rand 0.8.5", "regex", "reqwest", "semver 1.0.20", @@ -2873,7 +2870,6 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-fuzz", "foundry-evm-traces", - "foundry-utils", "hashbrown 0.14.2", "parking_lot", "proptest", @@ -2900,7 +2896,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-macros", - "foundry-utils", "futures", "itertools 0.11.0", "once_cell", @@ -2944,7 +2939,6 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "foundry-utils", "hashbrown 0.14.2", "itertools 0.11.0", "parking_lot", @@ -2972,7 +2966,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm-core", - "foundry-utils", "futures", "hashbrown 0.14.2", "itertools 0.11.0", @@ -3008,7 +3001,6 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", - "foundry-utils", "once_cell", "parking_lot", "pretty_assertions", @@ -3019,28 +3011,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "foundry-utils" -version = "0.2.0" -dependencies = [ - "alloy-json-abi", - "alloy-primitives", - "alloy-sol-types", - "dunce", - "ethers-core", - "ethers-providers", - "eyre", - "forge-fmt", - "foundry-common", - "foundry-compilers", - "futures", - "glob", - "once_cell", - "rand 0.8.5", - "serde_json", - "tracing", -] - [[package]] name = "fs2" version = "0.4.3" @@ -6814,7 +6784,7 @@ dependencies = [ [[package]] name = "syn-solidity" version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#389e256e9f82c797dd0ed642348b7b8d2e0bcf90" +source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 65df6bd086ff7..13c8a68d31c99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ members = [ "crates/forge/", "crates/macros/", "crates/test-utils/", - "crates/utils/", ] resolver = "2" @@ -125,7 +124,6 @@ foundry-evm-fuzz = { path = "crates/evm/fuzz" } foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } -foundry-utils = { path = "crates/utils" } # block explorer & verification bindings foundry-block-explorers = { version = "0.1", default-features = false } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 2879a8803eb93..c6430cffdb8c2 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -26,7 +26,6 @@ anvil-server = { path = "server" } foundry-common.workspace = true foundry-config.workspace = true foundry-evm.workspace = true -foundry-utils.workspace = true # evm support bytes = "1.4.0" diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index b5d4040ce43db..034a40737108a 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -10,9 +10,9 @@ homepage.workspace = true repository.workspace = true [dependencies] -# foundry internal +foundry-common.workspace = true foundry-evm.workspace = true -foundry-utils.workspace = true + revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } alloy-primitives = { workspace = true, features = ["serde"] } diff --git a/crates/anvil/core/src/eth/proof.rs b/crates/anvil/core/src/eth/proof.rs index 733cd044f634a..09c14bec26070 100644 --- a/crates/anvil/core/src/eth/proof.rs +++ b/crates/anvil/core/src/eth/proof.rs @@ -5,8 +5,9 @@ use ethers_core::{ types::{H256, U256}, utils::rlp, }; -use foundry_utils::types::ToEthers; +use foundry_common::types::ToEthers; use revm::primitives::KECCAK_EMPTY; + // reexport for convenience pub use ethers_core::types::{EIP1186ProofResponse as AccountProof, StorageProof}; diff --git a/crates/anvil/core/src/eth/receipt.rs b/crates/anvil/core/src/eth/receipt.rs index 1e3d507d197a3..02b696582ef63 100644 --- a/crates/anvil/core/src/eth/receipt.rs +++ b/crates/anvil/core/src/eth/receipt.rs @@ -6,7 +6,7 @@ use ethers_core::{ rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, }, }; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_common::types::{ToAlloy, ToEthers}; #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 9ce28ff74f780..a1747706e4beb 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -14,8 +14,8 @@ use ethers_core::{ rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, }, }; +use foundry_common::types::ToAlloy; use foundry_evm::traces::CallTraceArena; -use foundry_utils::types::ToAlloy; use revm::{ interpreter::InstructionResult, primitives::{CreateScheme, TransactTo, TxEnv}, diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index 3e903e4270fdb..21711cb3eb9cb 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -6,7 +6,7 @@ use ethers_core::{ rlp::{Encodable, RlpStream}, }, }; -use foundry_utils::types::ToAlloy; +use foundry_common::types::ToAlloy; pub fn enveloped(id: u8, v: &T, s: &mut RlpStream) { let encoded = rlp::encode(v); diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 9809869703010..cad1d7f628479 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -28,6 +28,7 @@ use ethers::{ utils::{format_ether, hex, to_checksum, WEI_IN_ETHER}, }; use foundry_common::{ + types::{ToAlloy, ToEthers}, ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, }; use foundry_config::Config; @@ -38,7 +39,6 @@ use foundry_evm::{ revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv, U256 as rU256}, utils::apply_chain_and_block_specific_env_changes, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::RwLock; use serde_json::{json, to_writer, Value}; use std::{ diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 71fd8170b22e4..ff9a0cbab7e1e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -61,7 +61,7 @@ use ethers::{ }, utils::rlp, }; -use foundry_common::ProviderBuilder; +use foundry_common::{types::ToEthers, ProviderBuilder}; use foundry_evm::{ backend::DatabaseError, revm::{ @@ -70,7 +70,6 @@ use foundry_evm::{ primitives::BlockEnv, }, }; -use foundry_utils::types::ToEthers; use futures::channel::{mpsc::Receiver, oneshot}; use parking_lot::RwLock; use std::{collections::HashSet, future::Future, sync::Arc, time::Duration}; diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 781fb5c0bdde1..8d4fa9421fbe8 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -8,7 +8,7 @@ use ethers::{ types::{BlockId, H256}, utils::keccak256, }; -use foundry_common::errors::FsPathError; +use foundry_common::{errors::FsPathError, types::ToAlloy}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, MemDb, StateSnapshot}, fork::BlockchainDb, @@ -19,7 +19,6 @@ use foundry_evm::{ Database, DatabaseCommit, }, }; -use foundry_utils::types::ToAlloy; use hash_db::HashDB; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt, path::Path}; diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index d942ca122cea6..1f3f8f45f7606 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -17,6 +17,7 @@ use ethers::{ types::{Bloom, H256, U256}, utils::rlp, }; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::DatabaseError, revm, @@ -27,7 +28,6 @@ use foundry_evm::{ traces::{CallTraceArena, CallTraceNode}, utils::{eval_to_instruction_result, halt_to_instruction_result}, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use std::sync::Arc; /// Represents an executed transaction (transacted on the DB) diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 5178b001300c4..9c52a5b3c7ba0 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -9,6 +9,7 @@ use ethers::{ abi::ethereum_types::BigEndianHash, types::{Address, H256}, }; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, StateSnapshot}, revm::{ @@ -16,7 +17,6 @@ use foundry_evm::{ primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::Mutex; use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLockWriteGuard; diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 2c84f22599a5a..72895ac4a2fcb 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -7,12 +7,12 @@ use crate::{ Address, U256, }; use ethers::{prelude::H256, types::BlockId}; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::{DatabaseResult, StateSnapshot}, fork::{database::ForkDbSnapshot, BlockchainDb}, revm::Database, }; -use foundry_utils::types::{ToAlloy, ToEthers}; pub use foundry_evm::fork::database::ForkedDatabase; diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 159e8aca2366e..bb440488eff75 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -10,11 +10,11 @@ use crate::{ Address, U256, }; use ethers::{prelude::H256, types::BlockId}; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::{DatabaseResult, StateSnapshot}, fork::BlockchainDb, }; -use foundry_utils::types::{ToAlloy, ToEthers}; // reexport for convenience pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; @@ -141,11 +141,11 @@ mod tests { }; use alloy_primitives::{Bytes, U256 as rU256}; use ethers::types::U256; + use foundry_common::types::ToAlloy; use foundry_evm::{ backend::MemDb, revm::primitives::{Bytecode, KECCAK_EMPTY}, }; - use foundry_utils::types::ToAlloy; use std::{collections::BTreeMap, str::FromStr}; // verifies that all substantial aspects of a loaded account remain the state after an account diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index edd35972f963d..72d105a0ac767 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -56,6 +56,7 @@ use ethers::{ utils::{keccak256, rlp}, }; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, @@ -72,7 +73,6 @@ use foundry_evm::{ }, utils::{eval_to_instruction_result, halt_to_instruction_result, u256_to_h256_be}, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use futures::channel::mpsc::{unbounded, UnboundedSender}; use hash_db::HashDB; use parking_lot::{Mutex, RwLock}; diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index 9abe81fef3f88..bda955860d4a9 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -7,6 +7,7 @@ use ethers::{ types::H256, utils::{rlp, rlp::RlpStream}, }; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::DatabaseError, hashbrown::HashMap as Map, @@ -15,7 +16,6 @@ use foundry_evm::{ primitives::{AccountInfo, Bytecode, Log}, }, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use memory_db::HashKey; use trie_db::TrieMut; diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 10f7ded45eda6..074ebeeced89a 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -15,8 +15,8 @@ use ethers::{ prelude::{BlockId, BlockNumber, DefaultFrame, Trace, H256, H256 as TxHash, U64}, types::{ActionType, Bytes, GethDebugTracingOptions, TransactionReceipt, U256}, }; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::revm::{interpreter::InstructionResult, primitives::Env}; -use foundry_utils::types::{ToAlloy, ToEthers}; use parking_lot::RwLock; use std::{ collections::{HashMap, VecDeque}, @@ -441,6 +441,7 @@ mod tests { use super::*; use crate::eth::backend::db::Db; use ethers::{abi::ethereum_types::BigEndianHash, types::Address}; + use foundry_common::types::ToAlloy; use foundry_evm::{ backend::MemDb, revm::{ @@ -448,7 +449,6 @@ mod tests { primitives::{AccountInfo, U256 as rU256}, }, }; - use foundry_utils::types::ToAlloy; #[test] fn test_interval_update() { diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 1848f0e506437..9843e0536549f 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -6,8 +6,8 @@ use alloy_primitives::U256 as rU256; use ethers::types::{ Action, Address, Block, Bytes, CallType, Trace, Transaction, TransactionReceipt, H256, U256, }; +use foundry_common::types::ToEthers; use foundry_evm::{revm::interpreter::InstructionResult, utils::CallKind}; -use foundry_utils::types::ToEthers; use futures::future::join_all; use serde::{de::DeserializeOwned, Serialize}; use serde_repr::Serialize_repr; diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 76816b4b30f4e..183b37e8eea08 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -1,6 +1,6 @@ use ethers::abi::Address; +use foundry_common::types::ToEthers; use foundry_evm::revm::{self, precompile::Precompiles, primitives::SpecId}; -use foundry_utils::types::ToEthers; use std::fmt; pub fn get_precompiles_for(spec_id: SpecId) -> Vec
{ diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 56cba8360483e..23afd5fc3c9a4 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -4,9 +4,8 @@ use ethers::{ signers::LocalWallet, types::{serde_helpers::*, Address, Bytes, H256, U256}, }; -use foundry_common::errors::FsPathError; +use foundry_common::{errors::FsPathError, types::ToAlloy}; use foundry_evm::revm::primitives::{Bytecode, Env, KECCAK_EMPTY, U256 as rU256}; -use foundry_utils::types::ToAlloy; use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashMap}, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 2258d0341772d..490121afaacae 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -13,13 +13,12 @@ use ethers::{ U256, }, }; -use foundry_common::get_http_provider; -use foundry_config::Config; -use foundry_utils::{ - rpc, +use foundry_common::{ + get_http_provider, rpc, rpc::next_http_rpc_endpoint, types::{ToAlloy, ToEthers}, }; +use foundry_config::Config; use futures::StreamExt; use std::{sync::Arc, time::Duration}; diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs index 4b6f25569c97e..2e6278bb18266 100644 --- a/crates/anvil/tests/it/proof/mod.rs +++ b/crates/anvil/tests/it/proof/mod.rs @@ -11,8 +11,8 @@ use ethers::{ types::{Address, H256, U256}, utils::{keccak256, rlp}, }; +use foundry_common::types::ToEthers; use foundry_evm::revm::primitives::KECCAK_EMPTY; -use foundry_utils::types::ToEthers; mod eip1186; diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index ad9fbb0a2b99a..be3acb15f531a 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -24,7 +24,6 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm.workspace = true -foundry-utils.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 171853faf7824..28be54ee04fa7 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -7,8 +7,8 @@ use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils, }; +use foundry_common::types::ToEthers; use foundry_config::{Chain, Config}; -use foundry_utils::types::ToEthers; use std::str::FromStr; /// CLI arguments for `cast access-list`. diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 6c9fc22aa64f5..b5cc9e2b8a4b2 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -7,11 +7,13 @@ use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils::{self, handle_traces, parse_ether_value, TraceResult}, }; -use foundry_common::runtime_client::RuntimeClient; +use foundry_common::{ + runtime_client::RuntimeClient, + types::{ToAlloy, ToEthers}, +}; use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{executors::TracingExecutor, opts::EvmOpts}; -use foundry_utils::types::{ToAlloy, ToEthers}; use std::str::FromStr; type Provider = ethers_providers::Provider; diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index 188655ca3dae7..6186e47a6741b 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -4,8 +4,8 @@ use clap::Parser; use ethers_providers::Middleware; use eyre::Result; use foundry_cli::{opts::RpcOpts, utils}; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_config::Config; -use foundry_utils::types::{ToAlloy, ToEthers}; use futures::join; /// CLI arguments for `cast find-block`. diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index a715b20faa6a6..2f6fcbd95d91a 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -8,7 +8,7 @@ use foundry_cli::{ update_progress, utils, utils::{handle_traces, TraceResult}, }; -use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_known_system_sender, types::ToAlloy, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{ @@ -16,7 +16,6 @@ use foundry_evm::{ opts::EvmOpts, utils::configure_tx_env, }; -use foundry_utils::types::ToAlloy; /// CLI arguments for `cast run`. #[derive(Debug, Clone, Parser)] diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 725e540fce18c..b79bf1d7cd9bd 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -9,9 +9,11 @@ use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils, }; -use foundry_common::cli_warn; +use foundry_common::{ + cli_warn, + types::{ToAlloy, ToEthers}, +}; use foundry_config::{Chain, Config}; -use foundry_utils::types::{ToAlloy, ToEthers}; use std::str::FromStr; /// CLI arguments for `cast send`. diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 32433115de090..676d9e4db1f24 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -14,6 +14,7 @@ use foundry_cli::{ use foundry_common::{ abi::find_source, compile::{compile, etherscan_project, suppress_compile}, + types::{ToAlloy, ToEthers}, RetryProvider, }; use foundry_compilers::{artifacts::StorageLayout, ConfigurableContractArtifact, Project, Solc}; @@ -21,7 +22,6 @@ use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, impl_figment_convert_cast, Config, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future::join_all; use semver::Version; use std::str::FromStr; diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index abe4df5d4704a..b4cec44e0879f 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -10,9 +10,11 @@ use ethers_signers::{ }; use eyre::{Context, Result}; use foundry_cli::opts::{RawWallet, Wallet}; -use foundry_common::fs; +use foundry_common::{ + fs, + types::{ToAlloy, ToEthers}, +}; use foundry_config::Config; -use foundry_utils::types::{ToAlloy, ToEthers}; use serde_json::json; use std::path::Path; use yansi::Paint; diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 012104bb15a64..6063eada11a26 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -3,7 +3,7 @@ use clap::{builder::TypedValueParser, Parser}; use ethers_core::{k256::ecdsa::SigningKey, rand, utils::secret_key_to_address}; use ethers_signers::{LocalWallet, Signer}; use eyre::Result; -use foundry_utils::types::ToAlloy; +use foundry_common::types::ToAlloy; use rayon::iter::{self, ParallelIterator}; use regex::Regex; use std::time::Instant; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index edbe9d9804c24..5ceea192a0b54 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -17,9 +17,9 @@ use foundry_common::{ decode_calldata, decode_event_topic, decode_function_selector, import_selectors, parse_signatures, pretty_calldata, ParsedSignatures, SelectorImportData, }, + types::{ToAlloy, ToEthers}, }; use foundry_config::Config; -use foundry_utils::types::{ToAlloy, ToEthers}; use std::time::Instant; pub mod cmd; diff --git a/crates/cast/src/base.rs b/crates/cast/src/base.rs index 2b412878a20ff..80d2f6047fc4b 100644 --- a/crates/cast/src/base.rs +++ b/crates/cast/src/base.rs @@ -1,7 +1,7 @@ use alloy_primitives::{Sign, I256, U256}; use ethers_core::utils::ParseUnits; use eyre::Result; -use foundry_utils::types::ToAlloy; +use foundry_common::types::ToAlloy; use std::{ convert::Infallible, fmt::{Binary, Debug, Display, Formatter, LowerHex, Octal, Result as FmtResult, UpperHex}, diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index fee1f7d28900b..0fad3aeb740a2 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -15,9 +15,13 @@ use ethers_providers::{Middleware, PendingTransaction, PubsubClient}; use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::Client; -use foundry_common::{abi::encode_function_args, fmt::*, TransactionReceiptWithRevertReason}; +use foundry_common::{ + abi::encode_function_args, + fmt::*, + types::{ToAlloy, ToEthers}, + TransactionReceiptWithRevertReason, +}; use foundry_config::Chain; -use foundry_utils::types::{ToAlloy, ToEthers}; use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; use std::{ @@ -1630,7 +1634,7 @@ impl SimpleCast { .iter() .zip(contract_names) .map(|(contract_abi, name)| { - let source = foundry_utils::abi::abi_to_solidity(contract_abi, &name)?; + let source = foundry_cli::utils::abi_to_solidity(contract_abi, &name)?; Ok(InterfaceSource { name, json_abi: serde_json::to_string_pretty(contract_abi)?, diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs index 67d12e9efcb8b..1bfd0c40ff67c 100644 --- a/crates/cast/src/tx.rs +++ b/crates/cast/src/tx.rs @@ -7,9 +7,11 @@ use ethers_core::types::{ }; use ethers_providers::Middleware; use eyre::{eyre, Result}; -use foundry_common::abi::{encode_function_args, get_func, get_func_etherscan}; +use foundry_common::{ + abi::{encode_function_args, get_func, get_func_etherscan}, + types::{ToAlloy, ToEthers}, +}; use foundry_config::Chain; -use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future::join_all; pub type TxBuilderOutput = (TypedTransaction, Option); @@ -276,8 +278,8 @@ mod tests { use async_trait::async_trait; use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress, H160}; use ethers_providers::{JsonRpcClient, Middleware, ProviderError}; + use foundry_common::types::ToEthers; use foundry_config::NamedChain; - use foundry_utils::types::ToEthers; use serde::{de::DeserializeOwned, Serialize}; use std::str::FromStr; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 8374d393d068c..c685584863753 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,7 +1,7 @@ //! Contains various tests for checking cast commands +use foundry_common::rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}; use foundry_test_utils::{casttest, util::OutputExt}; -use foundry_utils::rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}; use std::{io::Write, path::Path}; // tests `--help` is printed to std out diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index e21273798f753..d4b87891b3fa5 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -17,7 +17,6 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm-core.workspace = true -foundry-utils.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 494c43d083d3e..80ab7324a793d 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -6,7 +6,7 @@ use ethers_signers::WalletError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; use foundry_evm_core::backend::DatabaseError; -use std::{borrow::Cow, fmt, ptr::NonNull}; +use std::{borrow::Cow, fmt}; /// Cheatcode result type. /// @@ -88,7 +88,7 @@ pub struct Error { /// in `impl Drop`. drop: bool, /// The error data. Always a valid pointer, and never modified. - data: NonNull<[u8]>, + data: *const [u8], } impl std::error::Error for Error {} @@ -137,7 +137,7 @@ impl Error { Self::fmt(format_args!("{msg}")) } - /// Creates a new error with a custom `fmt::Arguments` message. + /// Creates a new error with a custom [`fmt::Arguments`] message. pub fn fmt(args: fmt::Arguments<'_>) -> Self { match args.as_str() { Some(s) => Self::new_str(s), @@ -145,7 +145,8 @@ impl Error { } } - /// ABI-encodes this error as `CheatcodeError(string)`. + /// ABI-encodes this error as `CheatcodeError(string)` if the inner message is a string, + /// otherwise returns the raw bytes. pub fn abi_encode(&self) -> Vec { match self.kind() { ErrorKind::String(string) => Vm::CheatcodeError { message: string.into() }.abi_encode(), @@ -158,6 +159,7 @@ impl Error { pub fn kind(&self) -> ErrorKind<'_> { let data = self.data(); if self.is_str { + debug_assert!(std::str::from_utf8(data).is_ok()); ErrorKind::String(unsafe { std::str::from_utf8_unchecked(data) }) } else { ErrorKind::Bytes(data) @@ -167,32 +169,33 @@ impl Error { /// Returns the raw data of this error. #[inline(always)] pub fn data(&self) -> &[u8] { - unsafe { &*self.data.as_ptr() } + unsafe { &*self.data } } #[inline(always)] fn new_str(data: &'static str) -> Self { - Self::new(true, false, data.as_bytes() as *const [u8] as *mut [u8]) + Self::_new(true, false, data.as_bytes()) } #[inline(always)] fn new_string(data: String) -> Self { - Self::new(true, true, Box::into_raw(data.into_boxed_str().into_boxed_bytes())) + Self::_new(true, true, Box::into_raw(data.into_boxed_str().into_boxed_bytes())) } #[inline(always)] fn new_bytes(data: &'static [u8]) -> Self { - Self::new(false, false, data as *const [u8] as *mut [u8]) + Self::_new(false, false, data) } #[inline(always)] fn new_vec(data: Vec) -> Self { - Self::new(false, true, Box::into_raw(data.into_boxed_slice())) + Self::_new(false, true, Box::into_raw(data.into_boxed_slice())) } #[inline(always)] - fn new(is_str: bool, drop: bool, data: *mut [u8]) -> Self { - Self { is_str, drop, data: unsafe { NonNull::new_unchecked(data) } } + fn _new(is_str: bool, drop: bool, data: *const [u8]) -> Self { + debug_assert!(!data.is_null()); + Self { is_str, drop, data } } } @@ -200,7 +203,7 @@ impl Drop for Error { #[inline] fn drop(&mut self) { if self.drop { - drop(unsafe { Box::from_raw(self.data.as_ptr()) }); + drop(unsafe { Box::<[u8]>::from_raw(self.data.cast_mut()) }); } } } @@ -266,6 +269,7 @@ impl From for Error { } } +// So we can use `?` on `Result<_, Error>`. macro_rules! impl_from { ($($t:ty),* $(,)?) => {$( impl From<$t> for Error { diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 630e3a8f9fad4..136cdb8f80481 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -5,9 +5,8 @@ use alloy_primitives::{Address, Bytes, U256}; use alloy_sol_types::SolValue; use ethers_core::utils::{Genesis, GenesisAccount}; use ethers_signers::Signer; -use foundry_common::fs::read_json_file; +use foundry_common::{fs::read_json_file, types::ToAlloy}; use foundry_evm_core::backend::DatabaseExt; -use foundry_utils::types::ToAlloy; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, EVMData, diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 25b224182b1d6..f246d264c4dc5 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -3,10 +3,12 @@ use alloy_primitives::B256; use alloy_sol_types::SolValue; use ethers_core::types::Filter; use ethers_providers::Middleware; -use foundry_common::ProviderBuilder; +use foundry_common::{ + types::{ToAlloy, ToEthers}, + ProviderBuilder, +}; use foundry_compilers::utils::RuntimeOrHandle; use foundry_evm_core::fork::CreateFork; -use foundry_utils::types::{ToAlloy, ToEthers}; impl Cheatcode for activeForkCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 7a5859c5fe910..2eef1975502b1 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -19,13 +19,12 @@ use ethers_core::types::{ transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest, }; use ethers_signers::LocalWallet; -use foundry_common::{evm::Breakpoints, RpcUrl}; +use foundry_common::{evm::Breakpoints, types::ToEthers, RpcUrl}; use foundry_evm_core::{ backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP}, utils::get_create_address, }; -use foundry_utils::types::ToEthers; use itertools::Itertools; use revm::{ interpreter::{ @@ -908,7 +907,7 @@ impl Inspector for Cheatcodes { let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); return match expect::handle_expect_revert( false, - expected_revert.reason.as_ref(), + expected_revert.reason.as_deref(), status, retdata, ) { @@ -1069,7 +1068,7 @@ impl Inspector for Cheatcodes { }; let s = if *count == 1 { "" } else { "s" }; let msg = format!( - "Expected call to {address} with {expected_values} \ + "expected call to {address} with {expected_values} \ to be called {count} time{s}, but {but}" ); return (InstructionResult::Revert, remaining_gas, Error::encode(msg)) @@ -1240,7 +1239,7 @@ impl Inspector for Cheatcodes { let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); return match expect::handle_expect_revert( true, - expected_revert.reason.as_ref(), + expected_revert.reason.as_deref(), status, retdata, ) { diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 8e7df685c9edd..f4530b9fb5af1 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -3,8 +3,8 @@ use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, U256}; use ethers_signers::Signer; +use foundry_common::types::ToAlloy; use foundry_config::Config; -use foundry_utils::types::ToAlloy; impl Cheatcode for broadcast_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 3d5d95dff09fa..bdecef14204a3 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,8 +1,8 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_dyn_abi::DynSolType; -use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; -use foundry_utils::error::{ERROR_PREFIX, REVERT_PREFIX}; +use alloy_primitives::{address, Address, Bytes, Log as RawLog, B256, U256}; +use alloy_sol_types::{SolError, SolValue}; use revm::interpreter::{return_ok, InstructionResult}; +use spec::Vm; use std::collections::{hash_map::Entry, HashMap}; /// For some cheatcodes we may internally change the status of the call, i.e. in `expectRevert`. @@ -14,8 +14,7 @@ use std::collections::{hash_map::Entry, HashMap}; static DUMMY_CALL_OUTPUT: Bytes = Bytes::from_static(&[0u8; 8192]); /// Same reasoning as [DUMMY_CALL_OUTPUT], but for creates. -static DUMMY_CREATE_ADDRESS: Address = - Address::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); +const DUMMY_CREATE_ADDRESS: Address = address!("0000000000000000000000000000000000000001"); /// Tracks the expected calls per address. /// @@ -57,7 +56,7 @@ pub enum ExpectedCallType { #[derive(Clone, Debug, Default)] pub struct ExpectedRevert { /// The expected data returned by the revert, None being any - pub reason: Option, + pub reason: Option>, /// The depth at which the revert is expected pub depth: u64, } @@ -436,66 +435,60 @@ fn expect_revert(state: &mut Cheatcodes, reason: Option<&[u8]>, depth: u64) -> R state.expected_revert.is_none(), "you must call another function prior to expecting a second revert" ); - state.expected_revert = - Some(ExpectedRevert { reason: reason.map(Bytes::copy_from_slice), depth }); + state.expected_revert = Some(ExpectedRevert { reason: reason.map(<[_]>::to_vec), depth }); Ok(Default::default()) } pub(crate) fn handle_expect_revert( is_create: bool, - expected_revert: Option<&Bytes>, + expected_revert: Option<&[u8]>, status: InstructionResult, retdata: Bytes, ) -> Result<(Option
, Bytes)> { - ensure!(!matches!(status, return_ok!()), "call did not revert as expected"); + let success_return = || { + if is_create { + (Some(DUMMY_CREATE_ADDRESS), Bytes::new()) + } else { + (None, DUMMY_CALL_OUTPUT.clone()) + } + }; - macro_rules! success_return { - () => { - Ok(if is_create { - (Some(DUMMY_CREATE_ADDRESS), Default::default()) - } else { - trace!("successfully handled expected revert"); - (None, DUMMY_CALL_OUTPUT.clone()) - }) - }; - } + ensure!(!matches!(status, return_ok!()), "call did not revert as expected"); // If None, accept any revert - let mut expected_revert = match expected_revert { - Some(x) => x.clone(), - None => return success_return!(), + let Some(expected_revert) = expected_revert else { + return Ok(success_return()); }; if !expected_revert.is_empty() && retdata.is_empty() { bail!("call reverted as expected, but without data"); } - let mut actual_revert = retdata; - if actual_revert.len() >= 4 && - matches!(actual_revert[..4].try_into(), Ok(ERROR_PREFIX | REVERT_PREFIX)) - { - if let Ok(parsed_bytes) = DynSolType::Bytes.abi_decode(&actual_revert[4..]) { - if let Some(bytes) = parsed_bytes.as_bytes().map(|b| b.to_vec()) { - actual_revert = bytes.into(); - } + let mut actual_revert: Vec = retdata.into(); + + // Try decoding as known errors + if matches!( + actual_revert.get(..4).map(|s| s.try_into().unwrap()), + Some(Vm::CheatcodeError::SELECTOR | alloy_sol_types::Revert::SELECTOR) + ) { + if let Ok(decoded) = Vec::::abi_decode(&actual_revert[4..], false) { + actual_revert = decoded; } } - if actual_revert == *expected_revert { - success_return!() + if actual_revert == expected_revert { + Ok(success_return()) } else { - let stringify = |data: &mut Bytes| { - DynSolType::String - .abi_decode(data.0.as_ref()) + let stringify = |data: &[u8]| { + String::abi_decode(data, false) .ok() - .and_then(|d| d.as_str().map(|s| s.to_owned())) - .or_else(|| std::str::from_utf8(data.as_ref()).ok().map(ToOwned::to_owned)) + .or_else(|| std::str::from_utf8(data).ok().map(ToOwned::to_owned)) .unwrap_or_else(|| hex::encode_prefixed(data)) }; Err(fmt_err!( "Error != expected error: {} != {}", - stringify(&mut actual_revert), - stringify(&mut expected_revert), + stringify(&actual_revert), + stringify(expected_revert), )) } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index e319cfebc895c..8955bebff4db0 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -15,8 +15,8 @@ use ethers_signers::{ }, LocalWallet, MnemonicBuilder, Signer, }; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; -use foundry_utils::types::{ToAlloy, ToEthers}; /// The BIP32 default derivation path prefix. const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index b8f100a773bf6..92048950cb1a3 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -25,7 +25,6 @@ foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["project-util", "full"] } foundry-config.workspace = true foundry-evm.workspace = true -foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 04af448c75b92..9015ce1a10fa3 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -10,12 +10,12 @@ use alloy_json_abi::EventParam; use alloy_primitives::{hex, Address, U256}; use core::fmt::Debug; use eyre::{Result, WrapErr}; +use foundry_common::types::ToEthers; use foundry_compilers::Artifact; use foundry_evm::{ backend::Backend, decode::decode_console_logs, executors::ExecutorBuilder, inspectors::CheatsConfig, }; -use foundry_utils::types::ToEthers; use solang_parser::pt::{self, CodeLocation}; use std::str::FromStr; use yansi::Paint; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 679d658b6dca7..60b80fc799110 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -10,12 +10,11 @@ homepage.workspace = true repository.workspace = true [dependencies] -# foundry internal +forge-fmt.workspace = true foundry-common.workspace = true foundry-config.workspace = true foundry-debugger.workspace = true foundry-evm.workspace = true -foundry-utils.workspace = true foundry-compilers = { workspace = true, features = ["full"] } diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/cli/src/opts/wallet/mod.rs index 8a17adabe913d..e7b0db68e02d0 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/cli/src/opts/wallet/mod.rs @@ -11,9 +11,8 @@ use ethers_signers::{ LocalWallet, MnemonicBuilder, Signer, Trezor, TrezorError, TrezorHDPath, WalletError, }; use eyre::{bail, Result, WrapErr}; -use foundry_common::fs; +use foundry_common::{fs, types::ToAlloy}; use foundry_config::Config; -use foundry_utils::types::ToAlloy; use rusoto_core::{ credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, request::HttpClient as AwsHttpClient, Client as AwsClient, diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index 701a55dd45ae9..1114d24fa65ad 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -6,9 +6,8 @@ use ethers_signers::{ AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, Signer, Trezor, TrezorHDPath, }; use eyre::{Context, ContextCompat, Result}; -use foundry_common::RetryProvider; +use foundry_common::{types::ToAlloy, RetryProvider}; use foundry_config::Config; -use foundry_utils::types::ToAlloy; use itertools::izip; use rusoto_core::{ credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 124df64537ccc..8a0e51ad9b78d 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -1,10 +1,10 @@ +use alloy_json_abi::JsonAbi; use alloy_primitives::U256; use ethers_core::types::TransactionReceipt; use ethers_providers::Middleware; use eyre::{ContextCompat, Result}; -use foundry_common::units::format_units; +use foundry_common::{types::ToAlloy, units::format_units}; use foundry_config::{Chain, Config}; -use foundry_utils::types::ToAlloy; use std::{ ffi::OsStr, future::Future, @@ -75,6 +75,12 @@ pub fn subscriber() { .init() } +pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { + let s = abi.to_sol(name); + let s = forge_fmt::format(&s)?; + Ok(s) +} + /// Returns a [RetryProvider](foundry_common::RetryProvider) instantiated using [Config]'s RPC URL /// and chain. /// diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 177027f054ca0..ff7472d61dbaf 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -13,7 +13,6 @@ repository.workspace = true foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-compilers.workspace = true foundry-config.workspace = true -foundry-utils.workspace = true ethers-core.workspace = true ethers-middleware.workspace = true @@ -22,6 +21,7 @@ ethers-providers = { workspace = true, features = ["ws", "ipc"] } alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-sol-types.workspace = true async-trait = "0.1" auto_impl = "1.1.0" @@ -29,9 +29,11 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" dunce = "1" eyre.workspace = true +glob = "0.3" globset = "0.4" hex.workspace = true once_cell = "1" +rand.workspace = true regex = "1" reqwest = { version = "0.11", default-features = false } semver = "1" diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index ef31df85792d8..98f6968686d68 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -313,7 +313,7 @@ impl UIfmt for EthValue { mod temp_ethers { use super::UIfmt; use ethers_core::types::{Address, Bloom, Bytes, H256, H64, I256, U256, U64}; - use foundry_utils::types::ToAlloy; + use foundry_common::types::ToAlloy; macro_rules! with_alloy { ($($t:ty),*) => {$( diff --git a/crates/common/src/fs.rs b/crates/common/src/fs.rs index 25c20ab49f50a..83b98670affc8 100644 --- a/crates/common/src/fs.rs +++ b/crates/common/src/fs.rs @@ -14,6 +14,7 @@ pub fn create_file(path: impl AsRef) -> Result { let path = path.as_ref(); File::create(path).map_err(|err| FsPathError::create_file(err, path)) } + /// Wrapper for [`std::fs::remove_file`]. pub fn remove_file(path: impl AsRef) -> Result<()> { let path = path.as_ref(); @@ -148,6 +149,14 @@ pub fn json_files(root: impl AsRef) -> Vec { files_with_ext(root, "json") } +/// Canonicalize a path, returning an error if the path does not exist. +/// +/// Mainly useful to apply canonicalization to paths obtained from project files but still error +/// properly instead of flattening the errors. +pub fn canonicalize_path(path: impl AsRef) -> std::io::Result { + dunce::canonicalize(path) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/common/src/glob.rs b/crates/common/src/glob.rs index c6bff0176ee83..8557c35b5985a 100644 --- a/crates/common/src/glob.rs +++ b/crates/common/src/glob.rs @@ -1,5 +1,25 @@ -//! Contains `globset::Glob` wrapper functions used for filtering -use std::{fmt, str::FromStr}; +//! Contains `globset::Glob` wrapper functions used for filtering. + +use std::{ + fmt, + path::{Path, PathBuf}, + str::FromStr, +}; + +/// Expand globs with a root path. +pub fn expand_globs( + root: &Path, + patterns: impl IntoIterator>, +) -> eyre::Result> { + let mut expanded = Vec::new(); + for pattern in patterns { + for paths in glob::glob(&root.join(pattern.as_ref()).display().to_string())? { + expanded.push(paths?); + } + } + Ok(expanded) +} + /// A `globset::Glob` that creates its `globset::GlobMatcher` when its created, so it doesn't need /// to be compiled when the filter functions `TestFilter` functions are called. #[derive(Debug, Clone)] @@ -10,8 +30,6 @@ pub struct GlobMatcher { pub matcher: globset::GlobMatcher, } -// === impl GlobMatcher === - impl GlobMatcher { /// Tests whether the given path matches this pattern or not. /// diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index daeb88cefbb81..02d11bb43590d 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -19,12 +19,15 @@ pub mod fmt; pub mod fs; pub mod glob; pub mod provider; +pub mod retry; +pub mod rpc; pub mod runtime_client; pub mod selectors; pub mod shell; pub mod term; pub mod traits; pub mod transactions; +pub mod types; pub mod units; pub use constants::*; diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs new file mode 100644 index 0000000000000..9ace81a289e2a --- /dev/null +++ b/crates/common/src/retry.rs @@ -0,0 +1,58 @@ +//! Retry utilities. + +use eyre::{Error, Result}; +use std::{future::Future, time::Duration}; + +/// A type that keeps track of attempts. +#[derive(Debug, Clone)] +pub struct Retry { + retries: u32, + delay: Option, +} + +impl Retry { + /// Creates a new `Retry` instance. + pub fn new(retries: u32, delay: Option) -> Self { + Self { retries, delay } + } + + /// Runs the given closure in a loop, retrying if it fails up to the specified number of times. + pub fn run Result, T>(mut self, mut callback: F) -> Result { + loop { + match callback() { + Err(e) if self.retries > 0 => { + self.handle_err(e); + if let Some(delay) = self.delay { + std::thread::sleep(delay); + } + } + res => return res, + } + } + } + + /// Runs the given async closure in a loop, retrying if it fails up to the specified number of + /// times. + pub async fn run_async(mut self, mut callback: F) -> Result + where + F: FnMut() -> Fut, + Fut: Future>, + { + loop { + match callback().await { + Err(e) if self.retries > 0 => { + self.handle_err(e); + if let Some(delay) = self.delay { + tokio::time::sleep(delay).await; + } + } + res => return res, + }; + } + } + + fn handle_err(&mut self, err: Error) { + self.retries -= 1; + warn!("erroneous attempt ({} tries remaining): {}", self.retries, err.root_cause()); + } +} diff --git a/crates/utils/src/rpc.rs b/crates/common/src/rpc.rs similarity index 97% rename from crates/utils/src/rpc.rs rename to crates/common/src/rpc.rs index a41f2dddaba42..eb53213353056 100644 --- a/crates/utils/src/rpc.rs +++ b/crates/common/src/rpc.rs @@ -1,4 +1,4 @@ -//! Support rpc api keys +//! RPC API keys utilities. use once_cell::sync::Lazy; use rand::seq::SliceRandom; @@ -77,6 +77,7 @@ pub fn next_ws_rpc_endpoint() -> String { next_ws_endpoint("mainnet") } +/// Returns the next HTTP RPC endpoint. pub fn next_rpc_endpoint(network: &str) -> String { let idx = next() % num_keys(); if idx < INFURA_KEYS.len() { @@ -87,6 +88,7 @@ pub fn next_rpc_endpoint(network: &str) -> String { } } +/// Returns the next WS RPC endpoint. pub fn next_ws_endpoint(network: &str) -> String { let idx = next() % num_keys(); if idx < INFURA_KEYS.len() { diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index ca46e0f56c709..c5e8f96a278c6 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -1,6 +1,8 @@ -//! Commonly used traits +//! Commonly used traits. use alloy_json_abi::Function; +use alloy_primitives::Bytes; +use alloy_sol_types::SolError; use auto_impl::auto_impl; /// Extension trait for matching tests @@ -95,3 +97,15 @@ impl TestFunctionExt for str { self.eq_ignore_ascii_case("setup") } } + +/// An extension trait for `std::error::Error` for ABI encoding. +pub trait ErrorExt: std::error::Error { + /// ABI-encodes the error using `Revert(string)`. + fn abi_encode_revert(&self) -> Bytes; +} + +impl ErrorExt for T { + fn abi_encode_revert(&self) -> Bytes { + alloy_sol_types::Revert::from(self.to_string()).abi_encode().into() + } +} diff --git a/crates/utils/src/types.rs b/crates/common/src/types.rs similarity index 98% rename from crates/utils/src/types.rs rename to crates/common/src/types.rs index a62422c3db6d6..0413805a16aa0 100644 --- a/crates/utils/src/types.rs +++ b/crates/common/src/types.rs @@ -12,6 +12,7 @@ use ethers_core::{ /// Conversion trait to easily convert from Ethers types to Alloy types. pub trait ToAlloy { + /// The corresponding Alloy type. type To; /// Converts the Ethers type to the corresponding Alloy type. @@ -196,6 +197,7 @@ impl ToAlloy for ethabi::StateMutability { /// Conversion trait to easily convert from Alloy types to Ethers types. pub trait ToEthers { + /// The corresponding Ethers type. type To; /// Converts the Alloy type to the corresponding Ethers type. diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 42f99243a7efe..523c0e3a4be77 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -12,9 +12,9 @@ repository.workspace = true [dependencies] forge-fmt.workspace = true +foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true -foundry-utils.workspace = true alloy-primitives.workspace = true diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index 177c45e7c31e3..ddee58bddf972 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -3,9 +3,9 @@ use crate::{ ParseSource, Parser, Preprocessor, }; use forge_fmt::{FormatterConfig, Visitable}; +use foundry_common::glob::expand_globs; use foundry_compilers::utils::source_files_iter; use foundry_config::DocConfig; -use foundry_utils::glob::expand_globs; use itertools::Itertools; use mdbook::MDBook; use rayon::prelude::*; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 1ac4ffdd30cc6..65d2e4fe01a71 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -16,7 +16,6 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-macros.workspace = true -foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true diff --git a/crates/evm/core/src/abi/console.rs b/crates/evm/core/src/abi/console.rs index 5f8932435e912..ce8dc6d5752cc 100644 --- a/crates/evm/core/src/abi/console.rs +++ b/crates/evm/core/src/abi/console.rs @@ -1,7 +1,7 @@ use alloy_primitives::{hex, I256, U256}; use alloy_sol_types::sol; use derive_more::Display; -use foundry_utils::types::ToEthers; +use foundry_common::types::ToEthers; use itertools::Itertools; // TODO: Use `UiFmt` diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 1600f0e6484ea..3a2d8a5f4a638 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -11,8 +11,11 @@ use ethers_core::{ types::{Block, BlockNumber, Transaction}, utils::GenesisAccount, }; -use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_common::{ + is_known_system_sender, + types::{ToAlloy, ToEthers}, + SYSTEM_TRANSACTION_TYPE, +}; use revm::{ db::{CacheDB, DatabaseRef}, inspectors::NoOpInspector, diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index ba9329c36761c..5777ef8ad3107 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -9,8 +9,10 @@ use ethers_core::{ types::{Block, BlockId, NameOrAddress, Transaction}, }; use ethers_providers::Middleware; -use foundry_common::NON_ARCHIVE_NODE_WARNING; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_common::{ + types::{ToAlloy, ToEthers}, + NON_ARCHIVE_NODE_WARNING, +}; use futures::{ channel::mpsc::{channel, Receiver, Sender}, stream::Stream, diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 3eaeb6465bfb0..f81a6a9d3b1f4 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -271,7 +271,7 @@ mod tests { /// `AccountInfo` #[tokio::test(flavor = "multi_thread")] async fn fork_db_insert_basic_default() { - let rpc = foundry_utils::rpc::next_http_rpc_endpoint(); + let rpc = foundry_common::rpc::next_http_rpc_endpoint(); let provider = get_http_provider(rpc.clone()); let meta = BlockchainDbMeta { cfg_env: Default::default(), diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index 1c52072d49e04..35c15f6d96f2d 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -3,8 +3,7 @@ use alloy_primitives::{Address, U256}; use ethers_core::types::{Block, TxHash}; use ethers_providers::Middleware; use eyre::WrapErr; -use foundry_common::NON_ARCHIVE_NODE_WARNING; -use foundry_utils::types::ToAlloy; +use foundry_common::{types::ToAlloy, NON_ARCHIVE_NODE_WARNING}; use futures::TryFutureExt; use revm::primitives::{BlockEnv, CfgEnv, Env, TxEnv}; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index cfcbc13d82769..3bc129718e318 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -6,9 +6,8 @@ use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; use ethers_core::types::{BlockId, BlockNumber}; use ethers_providers::Provider; -use foundry_common::{runtime_client::RuntimeClient, ProviderBuilder}; +use foundry_common::{runtime_client::RuntimeClient, types::ToEthers, ProviderBuilder}; use foundry_config::Config; -use foundry_utils::types::ToEthers; use futures::{ channel::mpsc::{channel, Receiver, Sender}, stream::{Fuse, Stream}, diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index f4196ac589c50..c4cf12517631f 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -2,7 +2,7 @@ use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, FixedBytes, B256}; use ethers_core::types::{ActionType, Block, CallType, Chain, Transaction, H256, U256}; use eyre::ContextCompat; -use foundry_utils::types::ToAlloy; +use foundry_common::types::ToAlloy; use revm::{ interpreter::{opcode, opcode::spec_opcode_gas, CallScheme, CreateInputs, InstructionResult}, primitives::{CreateScheme, Eval, Halt, SpecId, TransactTo}, diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 215608f674695..8594576874f33 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -19,7 +19,6 @@ foundry-evm-core.workspace = true foundry-evm-coverage.workspace = true foundry-evm-fuzz.workspace = true foundry-evm-traces.workspace = true -foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs index 56ad89729973d..102e19fb5dea9 100644 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ b/crates/evm/evm/src/inspectors/access_list.rs @@ -1,6 +1,6 @@ use alloy_primitives::{Address, B256}; use ethers_core::types::transaction::eip2930::{AccessList, AccessListItem}; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_common::types::{ToAlloy, ToEthers}; use hashbrown::{HashMap, HashSet}; use revm::{ interpreter::{opcode, Interpreter}, diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index bd3ca6b3e0de8..f66fdbc9beaf9 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -1,5 +1,5 @@ use alloy_primitives::{Address, Bytes}; -use foundry_common::SELECTOR_LEN; +use foundry_common::{ErrorExt, SELECTOR_LEN}; use foundry_evm_core::{ backend::DatabaseExt, constants::CHEATCODE_ADDRESS, @@ -127,7 +127,7 @@ impl Inspector for Debugger { // TODO: Does this increase gas cost? if let Err(err) = data.journaled_state.load_account(call.caller, data.db) { let gas = Gas::new(call.gas_limit); - return (InstructionResult::Revert, None, gas, foundry_cheatcodes::Error::encode(err)) + return (InstructionResult::Revert, None, gas, err.abi_encode_revert()) } let nonce = data.journaled_state.account(call.caller).info.nonce; diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index 277a3bcf804d6..466cf9fee7b80 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,12 +1,11 @@ use alloy_primitives::{Address, Bytes, B256}; use alloy_sol_types::{SolEvent, SolInterface, SolValue}; use ethers_core::types::Log; -use foundry_common::fmt::ConsoleFmt; +use foundry_common::{fmt::ConsoleFmt, types::ToEthers, ErrorExt}; use foundry_evm_core::{ abi::{patch_hardhat_console_selector, Console, HardhatConsole}, constants::HARDHAT_CONSOLE_ADDRESS, }; -use foundry_utils::types::ToEthers; use revm::{ interpreter::{CallInputs, Gas, InstructionResult}, Database, EVMData, Inspector, @@ -29,12 +28,7 @@ impl LogCollector { // Decode the call let decoded = match HardhatConsole::HardhatConsoleCalls::abi_decode(&input, false) { Ok(inner) => inner, - Err(err) => { - return ( - InstructionResult::Revert, - foundry_cheatcodes::Error::encode(err.to_string()), - ) - } + Err(err) => return (InstructionResult::Revert, err.abi_encode_revert()), }; // Convert the decoded call to a DS `log(string)` event diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 6d0d35705ec7c..49b10fc9d21a5 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -17,7 +17,6 @@ foundry-config.workspace = true foundry-evm-core.workspace = true foundry-evm-coverage.workspace = true foundry-evm-traces.workspace = true -foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index 21517805ce3f1..6190c073dfc6d 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -1,7 +1,7 @@ use crate::{invariant::RandomCallGenerator, strategies::EvmFuzzState}; use alloy_primitives::Bytes; +use foundry_common::types::ToEthers; use foundry_evm_core::utils; -use foundry_utils::types::ToEthers; use revm::{ interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, Database, EVMData, Inspector, diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 74e5a8e966900..33a0ddf329284 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -4,10 +4,12 @@ use alloy_dyn_abi::{DynSolType, JsonAbiExt}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers_core::types::Log; -use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_common::{ + contracts::{ContractsByAddress, ContractsByArtifact}, + types::ToEthers, +}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; -use foundry_utils::types::ToEthers; use hashbrown::HashSet; use parking_lot::RwLock; use proptest::prelude::{BoxedStrategy, Strategy}; diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 7edaedd94e0ff..7e11d23f8f543 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -16,7 +16,6 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm-core.workspace = true -foundry-utils.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true @@ -39,5 +38,4 @@ tracing = "0.1" yansi = "0.5" [dev-dependencies] -foundry-utils.workspace = true tempfile = "3" diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index d0bb8dd4eb467..3d88ee23ff1eb 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -9,9 +9,11 @@ extern crate tracing; use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; use ethers_core::types::{DefaultFrame, GethDebugTracingOptions, StructLog}; -use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_common::{ + contracts::{ContractsByAddress, ContractsByArtifact}, + types::ToEthers, +}; use foundry_evm_core::{constants::CHEATCODE_ADDRESS, debug::Instruction, utils::CallKind}; -use foundry_utils::types::ToEthers; use hashbrown::HashMap; use itertools::Itertools; use revm::interpreter::{opcode, CallContext, InstructionResult, Stack}; diff --git a/crates/evm/traces/src/node.rs b/crates/evm/traces/src/node.rs index 29bba93f1c192..e68840b69e962 100644 --- a/crates/evm/traces/src/node.rs +++ b/crates/evm/traces/src/node.rs @@ -1,7 +1,7 @@ use crate::{CallTrace, LogCallOrder, TraceLog}; use ethers_core::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; +use foundry_common::types::ToEthers; use foundry_evm_core::utils::CallKind; -use foundry_utils::types::ToEthers; use revm::interpreter::InstructionResult; use serde::{Deserialize, Serialize}; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 100545babbb58..c92778c16a6d8 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -24,7 +24,6 @@ foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["full"] } foundry-config.workspace = true foundry-evm.workspace = true -foundry-utils.workspace = true ethers-contract.workspace = true ethers-core.workspace = true diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 42c3149eafc07..74d56caa20912 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -18,9 +18,12 @@ use foundry_cli::{ opts::{CoreBuildArgs, EthereumOpts, EtherscanOpts, TransactionOpts}, utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; -use foundry_common::{compile, estimate_eip1559_fees, fmt::parse_tokens}; +use foundry_common::{ + compile, estimate_eip1559_fees, + fmt::parse_tokens, + types::{ToAlloy, ToEthers}, +}; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalized}; -use foundry_utils::types::{ToAlloy, ToEthers}; use serde_json::json; use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc}; diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 7886ae278170d..77d0e6aed4314 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -2,9 +2,8 @@ use clap::{Parser, ValueHint}; use eyre::Result; use forge_fmt::{format_to, parse, print_diagnostics_report}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; -use foundry_common::{fs, term::cli_warn}; +use foundry_common::{fs, glob::expand_globs, term::cli_warn}; use foundry_config::impl_figment_convert_basic; -use foundry_utils::glob::expand_globs; use rayon::prelude::*; use similar::{ChangeTag, TextDiff}; use std::{ @@ -52,7 +51,7 @@ impl FmtArgs { // Expand ignore globs and canonicalize from the get go let ignored = expand_globs(&config.__root.0, config.fmt.ignore.iter())? .iter() - .flat_map(foundry_utils::path::canonicalize_path) + .flat_map(foundry_common::fs::canonicalize_path) .collect::>(); let cwd = std::env::current_dir()?; diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index e7fc089ec55b4..6490cc0901060 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -202,7 +202,7 @@ impl InspectArgs { pub fn print_abi(abi: &JsonAbi, pretty: bool) -> Result<()> { let s = if pretty { - foundry_utils::abi::abi_to_solidity(abi, "")? + foundry_cli::utils::abi_to_solidity(abi, "")? } else { serde_json::to_string_pretty(&abi)? }; diff --git a/crates/forge/bin/cmd/retry.rs b/crates/forge/bin/cmd/retry.rs index 0a8db8f1fd523..4f9d979632361 100644 --- a/crates/forge/bin/cmd/retry.rs +++ b/crates/forge/bin/cmd/retry.rs @@ -1,5 +1,6 @@ use clap::{builder::RangedU64ValueParser, Parser}; -use foundry_utils::Retry; +use foundry_common::retry::Retry; +use std::time::Duration; /// Retry config used when waiting for verification pub const RETRY_CHECK_ON_VERIFY: RetryArgs = RetryArgs { retries: 8, delay: 15 }; @@ -36,7 +37,7 @@ impl Default for RetryArgs { impl From for Retry { fn from(r: RetryArgs) -> Self { - Retry::new(r.retries, Some(r.delay)) + Retry::new(r.retries, Some(Duration::from_secs(r.delay as u64))) } } diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index c57e1ec383bcc..636cfdce60e74 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -229,7 +229,7 @@ impl ScriptArgs { let from = tx.from().expect("no sender"); if sequential_broadcast { - let nonce = foundry_utils::next_nonce((*from).to_alloy(), fork_url, None) + let nonce = forge::next_nonce((*from).to_alloy(), fork_url, None) .await .map_err(|_| eyre::eyre!("Not able to query the EOA nonce."))?; diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 427c3401c4532..1ac4b63e3d37f 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,6 +1,7 @@ use super::*; use alloy_primitives::{Address, Bytes}; use eyre::{Context, ContextCompat, Result}; +use forge::link::{link_with_nonce_or_address, PostLinkInput, ResolvedDependency}; use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compact_to_contract, @@ -14,7 +15,6 @@ use foundry_compilers::{ info::ContractInfo, ArtifactId, Project, ProjectCompileOutput, }; -use foundry_utils::{PostLinkInput, ResolvedDependency}; use std::{collections::BTreeMap, str::FromStr}; impl ScriptArgs { @@ -119,7 +119,7 @@ impl ScriptArgs { } } - foundry_utils::link_with_nonce_or_address( + link_with_nonce_or_address( contracts.clone(), &mut highlevel_known_contracts, libs, diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index cbdd94ef829be..81627126049e9 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -5,9 +5,8 @@ use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::Result; use foundry_cli::utils::LoadConfig; -use foundry_common::{contracts::flatten_contracts, try_get_http_provider}; +use foundry_common::{contracts::flatten_contracts, try_get_http_provider, types::ToAlloy}; use foundry_debugger::DebuggerArgs; -use foundry_utils::types::ToAlloy; use std::sync::Arc; /// Helper alias type for the collection of data changed due to the new sender. @@ -33,7 +32,7 @@ impl ScriptArgs { if let Some(ref fork_url) = script_config.evm_opts.fork_url { // when forking, override the sender's nonce to the onchain value script_config.sender_nonce = - foundry_utils::next_nonce(script_config.evm_opts.sender, fork_url, None).await? + forge::next_nonce(script_config.evm_opts.sender, fork_url, None).await? } else { // if not forking, then ignore any pre-deployed library addresses script_config.config.libraries = Default::default(); @@ -297,7 +296,7 @@ impl ScriptArgs { ) -> Result<(Libraries, ArtifactContracts)> { // if we had a new sender that requires relinking, we need to // get the nonce mainnet for accurate addresses for predeploy libs - let nonce = foundry_utils::next_nonce( + let nonce = forge::next_nonce( new_sender, script_config.evm_opts.fork_url.as_ref().ok_or_else(|| { eyre::eyre!("You must provide an RPC URL (see --fork-url) when broadcasting.") diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 2d85e46b5c1b5..fec89e62a3a0f 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -15,9 +15,8 @@ use forge::{ utils::CallKind, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; -use foundry_common::{shell, RpcUrl}; +use foundry_common::{shell, types::ToEthers, RpcUrl}; use foundry_compilers::artifacts::CompactContractBytecode; -use foundry_utils::types::ToEthers; use futures::future::join_all; use parking_lot::RwLock; use std::{collections::VecDeque, sync::Arc}; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index a825a2e39921c..472b38c752fdf 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -29,7 +29,9 @@ use foundry_common::{ errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, fmt::{format_token, format_token_raw}, - shell, ContractsByArtifact, RpcUrl, CONTRACT_MAX_SIZE, SELECTOR_LEN, + shell, + types::{ToAlloy, ToEthers}, + ContractsByArtifact, RpcUrl, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::{ artifacts::{ContractBytecodeSome, Libraries}, @@ -49,7 +51,6 @@ use foundry_evm::{ decode, inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, }; -use foundry_utils::types::{ToAlloy, ToEthers}; use futures::future; use itertools::Itertools; use serde::{Deserialize, Serialize}; diff --git a/crates/forge/bin/cmd/script/providers.rs b/crates/forge/bin/cmd/script/providers.rs index ab417ca156bb5..92638becaac4f 100644 --- a/crates/forge/bin/cmd/script/providers.rs +++ b/crates/forge/bin/cmd/script/providers.rs @@ -1,9 +1,8 @@ use alloy_primitives::U256; use ethers_providers::{Middleware, Provider}; use eyre::{Result, WrapErr}; -use foundry_common::{get_http_provider, runtime_client::RuntimeClient, RpcUrl}; +use foundry_common::{get_http_provider, runtime_client::RuntimeClient, types::ToAlloy, RpcUrl}; use foundry_config::Chain; -use foundry_utils::types::ToAlloy; use std::{ collections::{hash_map::Entry, HashMap}, ops::Deref, diff --git a/crates/forge/bin/cmd/script/receipts.rs b/crates/forge/bin/cmd/script/receipts.rs index 79565996587fe..fb8640903c950 100644 --- a/crates/forge/bin/cmd/script/receipts.rs +++ b/crates/forge/bin/cmd/script/receipts.rs @@ -4,8 +4,10 @@ use ethers_core::types::TransactionReceipt; use ethers_providers::{Middleware, PendingTransaction}; use eyre::Result; use foundry_cli::{init_progress, update_progress, utils::print_receipt}; -use foundry_common::RetryProvider; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_common::{ + types::{ToAlloy, ToEthers}, + RetryProvider, +}; use futures::StreamExt; use std::sync::Arc; diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 4d6239dc92abe..d8cc0050c5d45 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -11,10 +11,13 @@ use alloy_primitives::{Address, TxHash}; use ethers_core::types::{transaction::eip2718::TypedTransaction, TransactionReceipt}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_cli::utils::now; -use foundry_common::{fs, shell, SELECTOR_LEN}; +use foundry_common::{ + fs, shell, + types::{ToAlloy, ToEthers}, + SELECTOR_LEN, +}; use foundry_compilers::{artifacts::Libraries, ArtifactId}; use foundry_config::Config; -use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; use std::{ collections::{HashMap, VecDeque}, diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 091a2a9ac4082..f010f1b90b410 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -4,9 +4,12 @@ use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, B256}; use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress}; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{fmt::format_token_raw, RpcUrl, SELECTOR_LEN}; +use foundry_common::{ + fmt::format_token_raw, + types::{ToAlloy, ToEthers}, + RpcUrl, SELECTOR_LEN, +}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder, utils::CallKind}; -use foundry_utils::types::{ToAlloy, ToEthers}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 2bd045f241bf1..e9a72d85abcba 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -9,10 +9,9 @@ use foundry_block_explorers::{ Client, }; use foundry_cli::utils::{get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; -use foundry_common::abi::encode_function_args; +use foundry_common::{abi::encode_function_args, retry::Retry}; use foundry_compilers::{artifacts::CompactContract, cache::CacheEntry, Project, Solc}; use foundry_config::{Chain, Config, SolcReq}; -use foundry_utils::Retry; use futures::FutureExt; use once_cell::sync::Lazy; use regex::Regex; @@ -71,9 +70,12 @@ impl VerificationProvider for EtherscanVerificationProvider { trace!(target: "forge::verify", ?verify_args, "submitting verification request"); let retry: Retry = args.retry.into(); - let resp = retry.run_async(|| { - async { - println!("\nSubmitting verification for [{}] {:?}.", verify_args.contract_name, verify_args.address.to_checksum(None)); + let resp = retry + .run_async(|| async { + println!( + "\nSubmitting verification for [{}] {}.", + verify_args.contract_name, verify_args.address + ); let resp = etherscan .submit_contract_verification(&verify_args) .await @@ -98,16 +100,15 @@ impl VerificationProvider for EtherscanVerificationProvider { warn!("Failed verify submission: {:?}", resp); eprintln!( - "Encountered an error verifying this contract:\nResponse: `{}`\nDetails: `{}`", - resp.message, resp.result - ); + "Encountered an error verifying this contract:\nResponse: `{}`\nDetails: `{}`", + resp.message, resp.result + ); std::process::exit(1); } Ok(Some(resp)) - } - .boxed() - }).await?; + }) + .await?; if let Some(resp) = resp { println!( diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index 4f85404809020..3a4593c4e15d6 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -2,9 +2,8 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use async_trait::async_trait; use eyre::Result; use foundry_cli::utils::{get_cached_entry_by_name, LoadConfig}; -use foundry_common::fs; +use foundry_common::{fs, retry::Retry}; use foundry_compilers::ConfigurableContractArtifact; -use foundry_utils::Retry; use futures::FutureExt; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index d9cfabaff900b..2561de9aee086 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -1,3 +1,5 @@ +//! Coverage reports. + use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Row, Table}; pub use foundry_evm::coverage::*; use std::io::Write; diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 43dfa39a347a0..2fb0ff46a34eb 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -1,3 +1,5 @@ +//! Gas reports. + use crate::{ constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, hashbrown::HashSet, diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index c797e96bef427..a8e5b97604761 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate tracing; + use alloy_primitives::B256; use foundry_compilers::ProjectCompileOutput; use foundry_config::{ @@ -8,29 +11,22 @@ use foundry_config::{ use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; use std::path::Path; -#[macro_use] -extern crate tracing; +pub mod coverage; -/// Gas reports pub mod gas_report; -/// Coverage reports -pub mod coverage; +pub mod link; -/// The Forge test runner -mod runner; -pub use runner::ContractRunner; - -/// Forge test runners for multiple contracts mod multi_runner; pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder}; -/// reexport -pub use foundry_common::traits::TestFilter; +mod runner; +pub use runner::ContractRunner; pub mod result; -/// The Forge EVM backend +// TODO: remove +pub use foundry_common::traits::TestFilter; pub use foundry_evm::*; /// Metadata on how to run fuzz/invariant tests @@ -215,3 +211,23 @@ impl TestOptionsBuilder { TestOptions::new(output, root, profiles, base_fuzz, base_invariant) } } + +mod utils2 { + use alloy_primitives::Address; + use ethers_core::types::BlockId; + use ethers_providers::{Middleware, Provider}; + use eyre::Context; + use foundry_common::types::{ToAlloy, ToEthers}; + + pub async fn next_nonce( + caller: Address, + provider_url: &str, + block: Option, + ) -> eyre::Result { + let provider = Provider::try_from(provider_url) + .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; + let res = provider.get_transaction_count(caller.to_ethers(), block).await?.to_alloy(); + res.try_into().map_err(Into::into) + } +} +pub use utils2::*; diff --git a/crates/utils/src/lib.rs b/crates/forge/src/link.rs similarity index 90% rename from crates/utils/src/lib.rs rename to crates/forge/src/link.rs index 92c58ebbacaf8..5eff7ee9ea4a8 100644 --- a/crates/utils/src/lib.rs +++ b/crates/forge/src/link.rs @@ -1,36 +1,17 @@ -#![doc = include_str!("../README.md")] -#![warn(unused_crate_dependencies)] - -#[macro_use] -extern crate tracing; - -use crate::types::{ToAlloy, ToEthers}; use alloy_primitives::{Address, Bytes}; -use ethers_core::types::BlockId; -use ethers_providers::{Middleware, Provider}; -use eyre::{Result, WrapErr}; +use eyre::Result; use foundry_compilers::{ artifacts::{BytecodeObject, CompactBytecode, CompactContractBytecode, Libraries}, contracts::ArtifactContracts, ArtifactId, }; -use futures::future::BoxFuture; use std::{ collections::{BTreeMap, HashMap}, - env::VarError, - fmt::{Formatter, Write}, + fmt, path::{Path, PathBuf}, str::FromStr, - time::Duration, }; -pub mod abi; -pub mod error; -pub mod glob; -pub mod path; -pub mod rpc; -pub mod types; - /// Data passed to the post link handler of the linker for each linked artifact. #[derive(Debug)] pub struct PostLinkInput<'a, T, U> { @@ -104,7 +85,7 @@ pub struct ResolvedDependency { } impl std::fmt::Display for ResolvedDependency { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{} @ {} (resolved with nonce {})", self.id, self.address, self.nonce) } } @@ -139,7 +120,6 @@ impl std::fmt::Display for ResolvedDependency { /// /// For an example of this, see [here](https://github.com/foundry-rs/foundry/blob/2308972dbc3a89c03488a05aceb3c428bb3e08c0/cli/src/cmd/forge/script/build.rs#L130-L151C9). #[allow(clippy::too_many_arguments)] - pub fn link_with_nonce_or_address( contracts: ArtifactContracts, known_contracts: &mut BTreeMap, @@ -416,95 +396,6 @@ fn recurse_link<'a>( } } -/// Given a k/v serde object, it pretty prints its keys and values as a table. -pub fn to_table(value: serde_json::Value) -> String { - match value { - serde_json::Value::String(s) => s, - serde_json::Value::Object(map) => { - let mut s = String::new(); - for (k, v) in map.iter() { - writeln!(&mut s, "{k: <20} {v}\n").expect("could not write k/v to table"); - } - s - } - _ => String::new(), - } -} - -/// Reads the `ETHERSCAN_API_KEY` env variable -pub fn etherscan_api_key() -> eyre::Result { - std::env::var("ETHERSCAN_API_KEY").map_err(|err| match err { - VarError::NotPresent => { - eyre::eyre!( - r#" - You need an Etherscan Api Key to verify contracts. - Create one at https://etherscan.io/myapikey - Then export it with \`export ETHERSCAN_API_KEY=xxxxxxxx'"# - ) - } - VarError::NotUnicode(err) => { - eyre::eyre!("Invalid `ETHERSCAN_API_KEY`: {:?}", err) - } - }) -} - -/// A type that keeps track of attempts -#[derive(Debug, Clone)] -pub struct Retry { - retries: u32, - delay: Option, -} - -/// Sample retry logic implementation -impl Retry { - pub fn new(retries: u32, delay: Option) -> Self { - Self { retries, delay } - } - - fn handle_err(&mut self, err: eyre::Report) { - self.retries -= 1; - warn!("erroneous attempt ({} tries remaining): {}", self.retries, err.root_cause()); - if let Some(delay) = self.delay { - std::thread::sleep(Duration::from_secs(delay.into())); - } - } - - pub fn run(mut self, mut callback: F) -> eyre::Result - where - F: FnMut() -> eyre::Result, - { - loop { - match callback() { - Err(e) if self.retries > 0 => self.handle_err(e), - res => return res, - } - } - } - - pub async fn run_async<'a, T, F>(mut self, mut callback: F) -> eyre::Result - where - F: FnMut() -> BoxFuture<'a, eyre::Result>, - { - loop { - match callback().await { - Err(e) if self.retries > 0 => self.handle_err(e), - res => return res, - }; - } - } -} - -pub async fn next_nonce( - caller: Address, - provider_url: &str, - block: Option, -) -> Result { - let provider = Provider::try_from(provider_url) - .wrap_err_with(|| format!("Bad fork_url provider: {provider_url}"))?; - let res = provider.get_transaction_count(caller.to_ethers(), block).await?.to_alloy(); - res.try_into().map_err(|e| eyre::eyre!("{e}")) -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 5253bf7c103c5..5d39d48582ed4 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,4 +1,10 @@ -use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; +//! Forge test runner for multiple contracts. + +use crate::{ + link::{link_with_nonce_or_address, PostLinkInput, ResolvedDependency}, + result::SuiteResult, + ContractRunner, TestFilter, TestOptions, +}; use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; @@ -15,7 +21,6 @@ use foundry_evm::{ opts::EvmOpts, revm, }; -use foundry_utils::{PostLinkInput, ResolvedDependency}; use rayon::prelude::*; use revm::primitives::SpecId; use std::{ @@ -293,7 +298,7 @@ impl MultiContractRunnerBuilder { filtered } - foundry_utils::link_with_nonce_or_address( + link_with_nonce_or_address( ArtifactContracts::from_iter(contracts), &mut known_contracts, Default::default(), diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 9cd84f7c760a0..604fbb6983026 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,4 +1,4 @@ -//! test outcomes +//! Test outcomes. use alloy_primitives::Address; use ethers_core::types::Log; diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 36c3001a95f00..e070eeadb588c 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -1,3 +1,5 @@ +//! The Forge test runner. + use crate::{ result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 8eafecce5845c..b43617078fa85 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -750,7 +750,7 @@ forgetest!( .to_string(); println!("project root: \"{root}\""); - let eth_rpc_url = foundry_utils::rpc::next_http_archive_rpc_endpoint(); + let eth_rpc_url = foundry_common::rpc::next_http_archive_rpc_endpoint(); let dss_exec_lib = "src/DssSpell.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4"; cmd.args([ diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index c9b78e381cb16..fb052b40b8a8d 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -1,7 +1,7 @@ //! Contains various tests related to forge script use anvil::{spawn, NodeConfig}; +use foundry_common::types::ToEthers; use foundry_test_utils::{ScriptOutcome, ScriptTester}; -use foundry_utils::types::ToEthers; forgetest_async!(can_deploy_multi_chain_script_without_lib, |prj, cmd| { let (api1, handle1) = spawn(NodeConfig::test()).await; diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index da9c2f66a2f6a..6fd5dcd06a082 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3,8 +3,8 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::Address; use anvil::{spawn, NodeConfig}; +use foundry_common::{rpc, types::ToEthers}; use foundry_test_utils::{util::OutputExt, ScriptOutcome, ScriptTester}; -use foundry_utils::{rpc, types::ToEthers}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; @@ -32,7 +32,7 @@ contract ContractScript is Script { ) .unwrap(); - let rpc = foundry_utils::rpc::next_http_rpc_endpoint(); + let rpc = foundry_common::rpc::next_http_rpc_endpoint(); cmd.arg("script").arg(script).args(["--fork-url", rpc.as_str(), "-vvvvv"]).assert_success(); } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index cb2cfd121e037..97d428e3d0ee3 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,7 +1,7 @@ //! Contains various tests for checking `forge test` +use foundry_common::rpc; use foundry_config::Config; use foundry_test_utils::util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}; -use foundry_utils::rpc; use std::{path::PathBuf, process::Command, str::FromStr}; // tests that test filters are handled correctly diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index 8c916db1deb31..c35640a147504 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -1,12 +1,13 @@ -//! Contains various tests for checking forge commands related to verifying contracts on etherscan -//! and sourcify +//! Contains various tests for checking forge commands related to verifying contracts on Etherscan +//! and Sourcify. use crate::utils::{self, EnvExternalities}; +use foundry_common::retry::Retry; use foundry_test_utils::{ forgetest, util::{TestCommand, TestProject}, }; -use foundry_utils::Retry; +use std::time::Duration; /// Adds a `Unique` contract to the source directory of the project that can be imported as /// `import {Unique} from "./unique.sol";` @@ -40,7 +41,7 @@ function doStuff() external {} fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Result<()> { // give etherscan some time to verify the contract - let retry = Retry::new(retries, Some(30)); + let retry = Retry::new(retries, Some(Duration::from_secs(30))); retry.run(|| -> eyre::Result<()> { let output = cmd.unchecked_output(); let out = String::from_utf8_lossy(&output.stdout); @@ -82,7 +83,7 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te // `verify-contract` let guid = { // give etherscan some time to detect the transaction - let retry = Retry::new(5, Some(60)); + let retry = Retry::new(5, Some(Duration::from_secs(60))); retry .run(|| -> eyre::Result { let output = cmd.unchecked_output(); diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 77e9691ef1e62..e66e975fdc86c 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -71,7 +71,7 @@ async fn test_rpc_fork() { /// Tests that we can launch in forking mode #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork() { - let rpc_url = foundry_utils::rpc::next_http_archive_rpc_endpoint(); + let rpc_url = foundry_common::rpc::next_http_archive_rpc_endpoint(); let runner = forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; @@ -80,7 +80,7 @@ async fn test_launch_fork() { /// Smoke test that forking workings with websockets #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork_ws() { - let rpc_url = foundry_utils::rpc::next_ws_archive_rpc_endpoint(); + let rpc_url = foundry_common::rpc::next_ws_archive_rpc_endpoint(); let runner = forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 7c555927ea8b2..8e2b75931734b 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -15,7 +15,6 @@ repository.workspace = true foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["project-util"] } foundry-config.workspace = true -foundry-utils.workspace = true alloy-primitives.workspace = true diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index fb8ee4e0b83f6..d5cb88e5a8ba1 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -162,7 +162,7 @@ macro_rules! forgetest_external { ]); cmd.set_env("FOUNDRY_FUZZ_RUNS", "1"); - let next_eth_rpc_url = foundry_utils::rpc::next_http_archive_rpc_endpoint(); + let next_eth_rpc_url = foundry_common::rpc::next_http_archive_rpc_endpoint(); if $fork_block > 0 { cmd.set_env("FOUNDRY_ETH_RPC_URL", next_eth_rpc_url); cmd.set_env("FOUNDRY_FORK_BLOCK_NUMBER", stringify!($fork_block)); diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 81af31de5e95f..a2f47ed4d7e42 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -3,8 +3,11 @@ use alloy_primitives::{Address, U256}; use ethers_core::types::NameOrAddress; use ethers_providers::Middleware; use eyre::Result; -use foundry_common::{get_http_provider, RetryProvider}; -use foundry_utils::types::{ToAlloy, ToEthers}; +use foundry_common::{ + get_http_provider, + types::{ToAlloy, ToEthers}, + RetryProvider, +}; use std::{collections::BTreeMap, fs, path::Path, str::FromStr}; const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml deleted file mode 100644 index acbb6041fffdb..0000000000000 --- a/crates/utils/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "foundry-utils" - -version.workspace = true -edition.workspace = true -rust-version.workspace = true -authors.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -foundry-compilers = { workspace = true, default-features = false } -forge-fmt.workspace = true - -alloy-json-abi.workspace = true -alloy-primitives.workspace = true -alloy-sol-types.workspace = true - -ethers-core.workspace = true -ethers-providers.workspace = true - -dunce = "1" -eyre = { version = "0.6", default-features = false } -futures = "0.3" -glob = "0.3" -once_cell = "1" -rand = "0.8" -serde_json.workspace = true -tracing.workspace = true - -[dev-dependencies] -foundry-common.workspace = true diff --git a/crates/utils/README.md b/crates/utils/README.md deleted file mode 100644 index 45334f7718af8..0000000000000 --- a/crates/utils/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# foundry-utils - -Helper methods for interacting with EVM ABIs diff --git a/crates/utils/src/abi.rs b/crates/utils/src/abi.rs deleted file mode 100644 index 19cb0ebbb0aee..0000000000000 --- a/crates/utils/src/abi.rs +++ /dev/null @@ -1,8 +0,0 @@ -use alloy_json_abi::JsonAbi; -use eyre::Result; - -pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { - let s = abi.to_sol(name); - let s = forge_fmt::format(&s)?; - Ok(s) -} diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs deleted file mode 100644 index 99bc541eb90bb..0000000000000 --- a/crates/utils/src/error.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! error handling and support - -use alloy_primitives::Bytes; -use alloy_sol_types::{SolError, SolValue}; - -/// Solidity revert prefix. -/// -/// `keccak256("Error(string)")[..4] == 0x08c379a0` -pub const REVERT_PREFIX: [u8; 4] = [8, 195, 121, 160]; - -/// Custom Cheatcode error prefix. -/// -/// `keccak256("CheatcodeError(string)")[..4] == 0xeeaa9e6f` -pub const ERROR_PREFIX: [u8; 4] = [238, 170, 158, 111]; - -/// An extension trait for `std::error::Error` that can ABI-encode itself. -pub trait ErrorExt: std::error::Error { - /// ABI-encodes the error using `Revert(string)`. - fn encode_error(&self) -> Bytes; - - /// ABI-encodes the error as a string. - fn encode_string(&self) -> Bytes; -} - -impl ErrorExt for T { - fn encode_error(&self) -> Bytes { - alloy_sol_types::Revert::from(self.to_string()).abi_encode().into() - } - - fn encode_string(&self) -> Bytes { - self.to_string().abi_encode().into() - } -} diff --git a/crates/utils/src/glob.rs b/crates/utils/src/glob.rs deleted file mode 100644 index e461895d0f288..0000000000000 --- a/crates/utils/src/glob.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::path::{Path, PathBuf}; - -/// Expand globs with a root path. -pub fn expand_globs( - root: &Path, - mut patterns: impl Iterator>, -) -> eyre::Result> { - patterns.try_fold(Vec::default(), |mut expanded, pattern| { - let paths = glob::glob(&root.join(pattern.as_ref()).display().to_string())?; - expanded.extend(paths.into_iter().collect::, _>>()?); - Ok(expanded) - }) -} diff --git a/crates/utils/src/path.rs b/crates/utils/src/path.rs deleted file mode 100644 index 45e4e07d9b826..0000000000000 --- a/crates/utils/src/path.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! General Foundry path utils - -use std::path::PathBuf; - -/// Canonicalize a path, returning an error if the path does not exist. -/// Mainly useful to apply canonicalization to paths obtained from project files -/// but still error properly instead of flattening the errors. -pub fn canonicalize_path(path: &PathBuf) -> eyre::Result { - Ok(dunce::canonicalize(path)?) -} From 89f74f26926b552e0fbfca0858f0a129dec79881 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 22 Nov 2023 20:41:41 +0100 Subject: [PATCH 0323/1963] chore: remove foundry-binder (#6405) --- Cargo.lock | 13 - Cargo.toml | 2 - crates/binder/Cargo.toml | 20 - crates/binder/README.md | 42 -- crates/binder/src/lib.rs | 380 ------------------ crates/binder/src/utils.rs | 802 ------------------------------------- 6 files changed, 1259 deletions(-) delete mode 100644 crates/binder/Cargo.toml delete mode 100644 crates/binder/README.md delete mode 100644 crates/binder/src/lib.rs delete mode 100644 crates/binder/src/utils.rs diff --git a/Cargo.lock b/Cargo.lock index 44d590ae527d4..12355e728b75c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2614,19 +2614,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "foundry-binder" -version = "0.2.0" -dependencies = [ - "ethers-contract", - "eyre", - "foundry-config", - "git2", - "tempfile", - "tracing", - "url", -] - [[package]] name = "foundry-block-explorers" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 13c8a68d31c99..68d4ccc90eefe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ members = [ "crates/anvil/core/", "crates/anvil/rpc/", "crates/anvil/server/", - "crates/binder/", "crates/cast/", "crates/cheatcodes/", "crates/cheatcodes/spec/", @@ -110,7 +109,6 @@ forge = { path = "crates/forge" } forge-doc = { path = "crates/doc" } forge-fmt = { path = "crates/fmt" } -foundry-binder = { path = "crates/binder" } foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } foundry-cli = { path = "crates/cli" } diff --git a/crates/binder/Cargo.toml b/crates/binder/Cargo.toml deleted file mode 100644 index 29a127268ca04..0000000000000 --- a/crates/binder/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "foundry-binder" -description = "Generate rust bindings for solidity projects" - -version.workspace = true -edition.workspace = true -rust-version.workspace = true -authors.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -foundry-config.workspace = true -ethers-contract = { workspace = true, features = ["abigen"] } -eyre.workspace = true -git2 = { version = "0.18", default-features = false } -tempfile = "3" -tracing.workspace = true -url = "2" diff --git a/crates/binder/README.md b/crates/binder/README.md deleted file mode 100644 index d69c970e682d5..0000000000000 --- a/crates/binder/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# foundry-binder - -Utilities for generating bindings for solidity projects in one step. - -First add `foundry-binder` to your cargo build-dependencies. - -```toml -[build-dependencies] -foundry-binder = { git = "https://github.com/foundry-rs/foundry" } -# required in order to enable ssh support in [libgit2](https://github.com/rust-lang/git2-rs) -git2 = "0.16.1" -``` - -```rust -use foundry_binder::{Binder, RepositoryBuilder, Url}; - -// github repository url -const REPO_URL: &str = ""; - -// the release tag for which to generate bindings for -const RELEASE_TAG: &str = "v3.0.0"; - -/// This clones the project, builds the project and generates rust bindings -fn generate() { - let binder = - Binder::new(RepositoryBuilder::new(Url::parse(REPO_URL).unwrap()) - // generate bindings for this release tag - // if not set, then the default branch will be used - .tag(RELEASE_TAG)) - // keep build artifacts in `artifacts` folder - .keep_artifacts("artifacts"); - - binder.generate().expect("Failed to generate bindings") -} - -fn main() { - // only generate if `FRESH_BINDINGS` env var is set - if std::env::var("FRESH_BINDINGS").is_ok() { - generate() - } -} -``` diff --git a/crates/binder/src/lib.rs b/crates/binder/src/lib.rs deleted file mode 100644 index 269719da9db32..0000000000000 --- a/crates/binder/src/lib.rs +++ /dev/null @@ -1,380 +0,0 @@ -//! Generate [ethers-rs]("https://github.com/gakonst/ethers-rs") bindings for solidity projects in a build script. - -#![warn(unused_crate_dependencies)] - -#[macro_use] -extern crate tracing; - -use crate::utils::{GitReference, GitRemote}; -use ethers_contract::MultiAbigen; -pub use foundry_config::Config; -use std::{ - path::{Path, PathBuf}, - process::{Command, Stdio}, -}; -use tempfile::{tempdir, TempDir}; - -pub use url::Url; - -pub mod utils; - -/// Contains all the options to configure the gen process -#[derive(Debug)] -pub struct Binder { - /// Where to find the project - location: SourceLocation, - /// Whether to include the bytecode in the bindings to be able to deploy them - deployable: bool, - /// Contains the directory where the artifacts should be written, if `None`, the artifacts will - /// be cleaned up - keep_artifacts: Option, - /// additional commands to run in the repo - commands: Vec>, - /// The foundry config to use in order to compile the project - config: Option, - /// Path to where the contract artifacts are stored - bindings: Option, -} - -// == impl Binder == - -impl Binder { - /// Creates a new `Binder` instance for the given location - /// - /// # Example - /// - /// Local repository: - /// - /// ``` - /// use foundry_binder::Binder; - /// - /// let binder = Binder::new("./aave-v3-core"); - /// ``` - /// - /// Remote repository with default branch: - /// - /// ``` - /// use foundry_binder::Binder; - /// use url::Url; - /// - /// let binder = Binder::new(Url::parse("https://github.com/aave/aave-v3-core").unwrap()); - /// ``` - pub fn new(location: impl Into) -> Self { - Self { - location: location.into(), - deployable: true, - keep_artifacts: None, - commands: vec![], - config: None, - bindings: None, - } - } - - /// Add a command to run in the project before generating the bindings - /// - /// # Example - /// - /// Add a `yarn install` command - /// - /// ``` - /// use foundry_binder::{Binder, RepositoryBuilder}; - /// use url::Url; - /// - /// let binder = Binder::new( - /// RepositoryBuilder::new(Url::parse("https://github.com/aave/aave-v3-core").unwrap()) - /// .tag("v1.16.0"), - /// ) - /// .command(["yarn", "install"]); - /// ``` - #[must_use] - pub fn command(mut self, cmd: I) -> Self - where - I: IntoIterator, - S: Into, - { - self.commands.push(cmd.into_iter().map(Into::into).collect()); - self - } - - /// If `deployable` set to `true` then the generated contract bindings will include the - /// generated bytecode which makes the contracts deployable - #[must_use] - pub fn set_deployable(mut self, deployable: bool) -> Self { - self.deployable = deployable; - self - } - - /// If set, the project's artifacts will be written there - #[must_use] - pub fn keep_artifacts(mut self, keep_artifacts: impl Into) -> Self { - self.keep_artifacts = Some(keep_artifacts.into()); - self - } - - /// Sets the path where to write the bindings to - #[must_use] - pub fn bindings(mut self, bindings: impl Into) -> Self { - self.bindings = Some(bindings.into()); - self - } - - /// Sets the config which contains all settings for how to compile the project - /// - /// ## Example - /// - /// ``` - /// use foundry_binder::{Binder, Config, RepositoryBuilder}; - /// use url::Url; - /// - /// let binder = Binder::new( - /// RepositoryBuilder::new(Url::parse("https://github.com/aave/aave-v3-core").unwrap()) - /// .tag("v1.16.0"), - /// ) - /// .command(["yarn", "install"]) - /// .config(Config { src: "src".into(), out: "artifacts".into(), ..Default::default() }); - /// ``` - #[must_use] - pub fn config(mut self, config: Config) -> Self { - self.config = Some(config); - self - } - - /// Generates the bindings - pub fn generate(&self) -> eyre::Result<()> { - let project = self.location.get()?; - - let config = if let Some(mut config) = self.config.clone() { - config.__root = project.into(); - config - } else { - foundry_config::load_config_with_root(Some(project)) - }; - - // run all commands - for mut args in self.commands.clone() { - eyre::ensure!(!args.is_empty(), "Command can't be empty"); - - let mut cmd = Command::new(args.remove(0)); - cmd.current_dir(&config.__root.0) - .args(args) - .stderr(Stdio::inherit()) - .stdout(Stdio::inherit()); - trace!("Executing command {:?}", cmd); - cmd.output()?; - } - - let mut project = config.project()?; - - // overwrite the artifacts dir - if let Some(keep_artifacts) = self.keep_artifacts.clone() { - let _ = std::fs::create_dir_all(&keep_artifacts); - project.paths.artifacts = keep_artifacts; - } - - let compiled = project.compile()?; - if compiled.has_compiler_errors() { - eyre::bail!("Compiled with errors:\n{compiled}"); - } - - trace!("Generating bindings"); - let bindings = MultiAbigen::from_json_files(project.artifacts_path())?.build()?; - trace!("Generated bindings"); - - trace!("Writing bindings to `src/contracts`"); - let module = self.bindings.clone().unwrap_or_else(|| "src/contracts".into()); - bindings.write_to_module(module, false)?; - - Ok(()) - } -} - -/// Where to find the source project -#[derive(Debug)] -pub enum SourceLocation { - Local(PathBuf), - Remote(Repository), -} - -// === impl SourceLocation === - -impl SourceLocation { - /// Returns the path to the project - /// - /// If this is a remote repository this will clone it - pub fn get(&self) -> eyre::Result { - let path = match self { - SourceLocation::Local(p) => p.clone(), - SourceLocation::Remote(r) => { - r.checkout()?; - r.dest.as_ref().to_path_buf() - } - }; - Ok(path) - } -} - -impl From for SourceLocation { - fn from(repo: Repository) -> Self { - SourceLocation::Remote(repo) - } -} - -impl From for SourceLocation { - fn from(builder: RepositoryBuilder) -> Self { - SourceLocation::Remote(builder.build()) - } -} - -impl From for SourceLocation { - fn from(url: Url) -> Self { - RepositoryBuilder::new(url).into() - } -} - -impl<'a> From<&'a str> for SourceLocation { - fn from(path: &'a str) -> Self { - SourceLocation::Local(path.into()) - } -} - -impl<'a> From<&'a String> for SourceLocation { - fn from(path: &'a String) -> Self { - SourceLocation::Local(path.into()) - } -} - -impl From for SourceLocation { - fn from(path: String) -> Self { - SourceLocation::Local(path.into()) - } -} - -#[derive(Debug)] -pub enum RepositoryDestination { - Path(PathBuf), - Temp(TempDir), -} - -impl AsRef for RepositoryDestination { - fn as_ref(&self) -> &Path { - match self { - RepositoryDestination::Path(p) => p, - RepositoryDestination::Temp(dir) => dir.path(), - } - } -} - -#[derive(Debug)] -pub struct Repository { - /// github project repository like - pub repo: GitRemote, - /// The version tag, branch or rev to checkout - pub rev: GitReference, - /// where to checkout the database - pub db_path: Option, - /// Where to clone into - pub dest: RepositoryDestination, -} - -// === impl Repository === - -impl Repository { - pub fn checkout(&self) -> eyre::Result<()> { - fn copy_to( - repo: &GitRemote, - rev: &GitReference, - db_path: &Path, - dest: &Path, - ) -> eyre::Result<()> { - let (local, oid) = repo.checkout(db_path, rev, None)?; - local.copy_to(oid, dest)?; - Ok(()) - } - - if let Some(ref db) = self.db_path { - copy_to(&self.repo, &self.rev, db, self.dest.as_ref()) - } else { - let tmp = tempdir()?; - let db = tmp.path().join(self.dest.as_ref().file_name().unwrap()); - copy_to(&self.repo, &self.rev, &db, self.dest.as_ref()) - } - } -} - -#[derive(Debug, Clone)] -#[must_use] -pub struct RepositoryBuilder { - repo: GitRemote, - rev: GitReference, - dest: Option, - db_path: Option, -} - -// === impl RepositoryBuilder === - -impl RepositoryBuilder { - pub fn new(url: Url) -> Self { - Self { repo: GitRemote::new(url), rev: Default::default(), dest: None, db_path: None } - } - - /// Specify the branch to checkout - pub fn branch(mut self, branch: impl Into) -> Self { - self.rev = GitReference::Branch(branch.into()); - self - } - - /// Specify the tag to checkout - pub fn tag(mut self, tag: impl Into) -> Self { - self.rev = GitReference::Tag(tag.into()); - self - } - - /// Specify the specific commit to checkout - pub fn rev(mut self, rev: impl Into) -> Self { - self.rev = GitReference::Rev(rev.into()); - self - } - - /// Specify a persistent location to clone into - pub fn dest(mut self, dest: impl Into) -> Self { - self.dest = Some(dest.into()); - self - } - - /// Sets the path to where to store the git database of the repo - /// - /// If None is provided a tempdir is used and the db is cleaned up after cloning - pub fn database(mut self, db_path: impl Into) -> Self { - self.db_path = Some(db_path.into()); - self - } - - pub fn build(self) -> Repository { - let RepositoryBuilder { repo, rev, dest, db_path } = self; - let dest = if let Some(dest) = dest { - RepositoryDestination::Path(dest) - } else { - let name = repo.url().path_segments().unwrap().last().unwrap(); - let dir = - tempfile::Builder::new().prefix(name).tempdir().expect("Failed to create tempdir"); - RepositoryDestination::Temp(dir) - }; - Repository { dest, repo, rev, db_path } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - #[ignore] - fn can_checkout_repo() { - let _dest = "./assets/aave-v3-core"; - - let repo = - RepositoryBuilder::new("https://github.com/aave/aave-v3-core".parse().unwrap()).build(); - - repo.checkout().unwrap(); - } -} diff --git a/crates/binder/src/utils.rs b/crates/binder/src/utils.rs deleted file mode 100644 index a2186b650a9e6..0000000000000 --- a/crates/binder/src/utils.rs +++ /dev/null @@ -1,802 +0,0 @@ -//! Utilities for handling git repositories. - -// Adapted from https://github.com/rust-lang/cargo/blob/f51e799636fcba6aeb98dc2ca7e440ecd9afe909/src/cargo/sources/git/utils.rs - -use eyre::Context; -use git2::{self, ErrorClass, ObjectType}; -use std::{ - env, - fmt::Write, - fs, - path::{Path, PathBuf}, - process::Command, -}; -use url::Url; - -/// Represents a remote repository. -/// It gets cloned into a local `GitLocal`. -#[derive(PartialEq, Eq, Clone, Debug)] -pub struct GitRemote { - url: Url, -} - -// === impl GitRemote === - -impl GitRemote { - pub fn new(url: Url) -> GitRemote { - GitRemote { url } - } - - pub fn url(&self) -> &Url { - &self.url - } - - pub fn rev_for( - &self, - path: impl AsRef, - reference: &GitReference, - ) -> eyre::Result { - reference.resolve(&self.open_local(path)?.repo) - } - - /// opens a local repository - pub fn open_local(&self, path: impl AsRef) -> eyre::Result { - let path = path.as_ref(); - let repo = git2::Repository::open(path)?; - Ok(GitLocal { remote: self.clone(), path: path.to_path_buf(), repo }) - } - - pub fn checkout( - &self, - into: &Path, - reference: &GitReference, - db: Option, - ) -> eyre::Result<(GitLocal, git2::Oid)> { - // If we have a previous instance of `GitDatabase` then fetch into that - // if we can. If that can successfully load our revision then we've - // populated the database with the latest version of `reference`, so - // return that database and the rev we resolve to. - if let Some(mut db) = db { - fetch(&mut db.repo, self.url.as_str(), reference, false) - .context(format!("failed to fetch into: {}", into.display()))?; - - if let Ok(rev) = reference.resolve(&db.repo) { - return Ok((db, rev)) - } - } - - // Otherwise, start from scratch to handle corrupt git repositories. - // After our fetch (which is interpreted as a clone now) we do the same - // resolution to figure out what we cloned. - if into.exists() { - fs::remove_dir_all(into)?; - } - fs::create_dir_all(into)?; - let mut repo = init(into, true)?; - fetch(&mut repo, self.url.as_str(), reference, false) - .context(format!("failed to clone into: {}", into.display()))?; - - let rev = reference.resolve(&repo)?; - - Ok((GitLocal { remote: self.clone(), path: into.to_path_buf(), repo }, rev)) - } -} - -/// Represents a local clone of a remote repository's database. -/// -/// Supports multiple `GitCheckouts` than can be cloned from this type. -pub struct GitLocal { - pub remote: GitRemote, - pub path: PathBuf, - pub repo: git2::Repository, -} - -// === impl GitLocal === - -impl GitLocal { - pub fn contains(&self, oid: git2::Oid) -> bool { - self.repo.revparse_single(&oid.to_string()).is_ok() - } - - pub fn copy_to(&self, rev: git2::Oid, dest: impl AsRef) -> eyre::Result> { - let dest = dest.as_ref(); - let mut checkout = None; - if let Ok(repo) = git2::Repository::open(dest) { - let mut co = GitCheckout::new(dest, self, rev, repo); - // After a successful fetch operation the subsequent reset can - // fail sometimes for corrupt repositories where the fetch - // operation succeeds but the object isn't actually there in one - // way or another. In these situations just skip the error and - // try blowing away the whole repository and trying with a - // clone. - co.fetch()?; - match co.reset() { - Ok(()) => { - checkout = Some(co); - } - Err(e) => debug!("failed reset after fetch {:?}", e), - } - }; - let checkout = match checkout { - Some(c) => c, - None => GitCheckout::clone_into(dest, self, rev)?, - }; - checkout.update_submodules()?; - Ok(checkout) - } -} - -/// Represents a local checkout of a particular revision. Calling -/// `clone_into` with a reference will resolve the reference into a revision, -pub struct GitCheckout<'a> { - database: &'a GitLocal, - _location: PathBuf, - revision: git2::Oid, - repo: git2::Repository, -} - -// === impl GitCheckout === - -impl<'a> GitCheckout<'a> { - pub fn new( - location: impl Into, - database: &'a GitLocal, - revision: git2::Oid, - repo: git2::Repository, - ) -> GitCheckout<'a> { - GitCheckout { _location: location.into(), database, revision, repo } - } - - fn fetch(&mut self) -> eyre::Result<()> { - info!("fetch {}", self.repo.path().display()); - let url = Url::from_file_path(&self.database.path) - .map_err(|_| eyre::eyre!("Invalid file url {}", self.database.path.display()))?; - let reference = GitReference::Rev(self.revision.to_string()); - fetch(&mut self.repo, url.as_str(), &reference, false)?; - Ok(()) - } - - pub fn clone_into( - into: &Path, - local: &'a GitLocal, - revision: git2::Oid, - ) -> eyre::Result> { - let dirname = into.parent().unwrap(); - fs::create_dir_all(dirname)?; - if into.exists() { - fs::remove_dir_all(into)?; - } - - // we're doing a local filesystem-to-filesystem clone so there should - // be no need to respect global configuration options, so pass in - // an empty instance of `git2::Config` below. - let git_config = git2::Config::new()?; - - // Clone the repository, but make sure we use the "local" option in - // libgit2 which will attempt to use hardlinks to set up the database. - // This should speed up the clone operation quite a bit if it works. - // - // Note that we still use the same fetch options because while we don't - // need authentication information we may want progress bars and such. - let url = Url::from_file_path(&local.path) - .map_err(|_| eyre::eyre!("Invalid file url {}", local.path.display()))?; - - let mut checkout = git2::build::CheckoutBuilder::new(); - checkout.dry_run(); // we'll do this below during a `reset` - let mut checkout = Some(checkout); - let mut repo = None; - - with_retry(|| { - with_authentication(url.as_str(), &git_config, |_| { - let r = git2::build::RepoBuilder::new() - // use hard links and/or copy the database, we're doing a - // filesystem clone so this'll speed things up quite a bit. - .clone_local(git2::build::CloneLocal::Local) - .with_checkout(checkout.take().unwrap()) - .fetch_options(git2::FetchOptions::new()) - .clone(url.as_str(), into)?; - repo = Some(r); - Ok(()) - }) - })?; - - let repo = repo.unwrap(); - - let checkout = GitCheckout::new(into, local, revision, repo); - checkout.reset()?; - Ok(checkout) - } - - /// This will perform a reset - fn reset(&self) -> eyre::Result<()> { - info!("reset {} to {}", self.repo.path().display(), self.revision); - // Ensure libgit2 won't mess with newlines when we vendor. - if let Ok(mut git_config) = self.repo.config() { - git_config.set_bool("core.autocrlf", false)?; - } - - let object = self.repo.find_object(self.revision, None)?; - reset(&self.repo, &object)?; - Ok(()) - } - - fn update_submodules(&self) -> eyre::Result<()> { - fn update_submodules(repo: &git2::Repository) -> eyre::Result<()> { - debug!("update submodules for: {:?}", repo.workdir().unwrap()); - - for mut child in repo.submodules()? { - update_submodule(repo, &mut child).with_context(|| { - format!("failed to update submodule `{}`", child.name().unwrap_or("")) - })?; - } - Ok(()) - } - - fn update_submodule( - parent: &git2::Repository, - child: &mut git2::Submodule<'_>, - ) -> eyre::Result<()> { - child.init(false)?; - let url = child - .url() - .ok_or_else(|| eyre::eyre!("non-utf8 url for submodule {:?}?", child.path()))?; - - // A submodule which is listed in .gitmodules but not actually - // checked out will not have a head id, so we should ignore it. - let head = match child.head_id() { - Some(head) => head, - None => return Ok(()), - }; - - // If the submodule hasn't been checked out yet, we need to - // clone it. If it has been checked out and the head is the same - // as the submodule's head, then we can skip an update and keep - // recursing. - let head_and_repo = child.open().and_then(|repo| { - let target = repo.head()?.target(); - Ok((target, repo)) - }); - let mut repo = match head_and_repo { - Ok((head, repo)) => { - if child.head_id() == head { - return update_submodules(&repo) - } - repo - } - Err(..) => { - let path = parent.workdir().unwrap().join(child.path()); - let _ = fs::remove_dir_all(&path); - init(&path, false)? - } - }; - // Fetch data from origin and reset to the head commit - let reference = GitReference::Rev(head.to_string()); - - fetch(&mut repo, url, &reference, false).with_context(|| { - format!("failed to fetch submodule `{}` from {url}", child.name().unwrap_or("")) - })?; - - let obj = repo.find_object(head, None)?; - reset(&repo, &obj)?; - update_submodules(&repo) - } - - update_submodules(&self.repo) - } -} - -/// Represents a specific commit in a git repository -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -pub enum GitReference { - /// Tag, like a release v0.0.1 - Tag(String), - /// Specific Branch - Branch(String), - /// Specific revision. - Rev(String), - /// Default branch - #[default] - DefaultBranch, -} - -// === impl GitReference === - -impl GitReference { - /// Resolves the unique identify of the reference for the given [Repository](git2::Repository) - pub fn resolve(&self, repo: &git2::Repository) -> eyre::Result { - let id = match self { - GitReference::Tag(s) => { - let resolve_tag = move || -> eyre::Result { - let refname = format!("refs/remotes/origin/tags/{s}"); - let id = repo.refname_to_id(&refname)?; - let obj = repo.find_object(id, None)?; - let obj = obj.peel(ObjectType::Commit)?; - Ok(obj.id()) - }; - resolve_tag().with_context(|| format!("failed to find tag `{s}`"))? - } - GitReference::Branch(s) => { - let name = format!("origin/{s}"); - let b = repo - .find_branch(&name, git2::BranchType::Remote) - .with_context(|| format!("failed to find branch `{s}`"))?; - b.get().target().ok_or_else(|| eyre::eyre!("branch `{s}` did not have a target"))? - } - - // use the HEAD commit - GitReference::DefaultBranch => { - let head_id = repo.refname_to_id("refs/remotes/origin/HEAD")?; - let head = repo.find_object(head_id, None)?; - head.peel(ObjectType::Commit)?.id() - } - - GitReference::Rev(s) => { - let obj = repo.revparse_single(s)?; - if let Some(tag) = obj.as_tag() { - tag.target_id() - } else { - obj.id() - } - } - }; - Ok(id) - } -} - -fn reinitialize(repo: &mut git2::Repository) -> eyre::Result<()> { - // Here we want to drop the current repository object pointed to by `repo`, - // so we initialize temporary repository in a sub-folder, blow away the - // existing git folder, and then recreate the git repo. Finally we blow away - // the `tmp` folder we allocated. - let path = repo.path().to_path_buf(); - debug!("reinitializing git repo at {:?}", path); - let tmp = path.join("tmp"); - let bare = !repo.path().ends_with(".git"); - *repo = init(&tmp, false)?; - for entry in path.read_dir()? { - let entry = entry?; - if entry.file_name().to_str() == Some("tmp") { - continue - } - let path = entry.path(); - let _ = fs::remove_file(&path).or_else(|_| fs::remove_dir_all(&path)); - } - *repo = init(&path, bare)?; - fs::remove_dir_all(&tmp)?; - Ok(()) -} - -fn init(path: &Path, bare: bool) -> eyre::Result { - let mut opts = git2::RepositoryInitOptions::new(); - // Skip anything related to templates, they just call all sorts of issues as - // we really don't want to use them yet they insist on being used. See #6240 - // for an example issue that comes up. - opts.external_template(false); - opts.bare(bare); - Ok(git2::Repository::init_opts(path, &opts)?) -} - -fn reset(repo: &git2::Repository, obj: &git2::Object<'_>) -> eyre::Result<()> { - let mut opts = git2::build::CheckoutBuilder::new(); - debug!("doing git reset"); - repo.reset(obj, git2::ResetType::Hard, Some(&mut opts))?; - debug!("git reset done"); - Ok(()) -} - -pub struct Retry { - remaining: u32, -} - -impl Retry { - pub fn new(remaining: u32) -> Self { - Self { remaining } - } - - pub fn r#try(&mut self, f: impl FnOnce() -> eyre::Result) -> eyre::Result> { - match f() { - Err(ref e) if maybe_spurious(e) && self.remaining > 0 => { - let msg = format!( - "spurious network error ({} tries remaining): {}", - self.remaining, - e.root_cause(), - ); - println!("{msg}"); - self.remaining -= 1; - Ok(None) - } - other => other.map(Some), - } - } -} - -fn maybe_spurious(err: &eyre::Error) -> bool { - if let Some(git_err) = err.downcast_ref::() { - match git_err.class() { - git2::ErrorClass::Net | - git2::ErrorClass::Os | - git2::ErrorClass::Zlib | - git2::ErrorClass::Http => return true, - _ => (), - } - } - false -} - -pub fn with_retry(mut callback: F) -> eyre::Result -where - F: FnMut() -> eyre::Result, -{ - let mut retry = Retry::new(2); - loop { - if let Some(ret) = retry.r#try(&mut callback)? { - return Ok(ret) - } - } -} - -/// Prepare the authentication callbacks for cloning a git repository. -/// -/// The main purpose of this function is to construct the "authentication -/// callback" which is used to clone a repository. This callback will attempt to -/// find the right authentication on the system (without user input) and will -/// guide libgit2 in doing so. -/// -/// The callback is provided `allowed` types of credentials, and we try to do as -/// much as possible based on that: -/// -/// * Prioritize SSH keys from the local ssh agent as they're likely the most reliable. The username -/// here is prioritized from the credential callback, then from whatever is configured in git -/// itself, and finally we fall back to the generic user of `git`. -/// -/// * If a username/password is allowed, then we fallback to git2-rs's implementation of the -/// credential helper. This is what is configured with `credential.helper` in git, and is the -/// interface for the macOS keychain, for example. -/// -/// * After the above two have failed, we just kinda grapple attempting to return *something*. -/// -/// If any form of authentication fails, libgit2 will repeatedly ask us for -/// credentials until we give it a reason to not do so. To ensure we don't -/// just sit here looping forever we keep track of authentications we've -/// attempted and we don't try the same ones again. -fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) -> eyre::Result -where - F: FnMut(&mut git2::Credentials<'_>) -> eyre::Result, -{ - let mut cred_helper = git2::CredentialHelper::new(url); - cred_helper.config(cfg); - - let mut ssh_username_requested = false; - let mut cred_helper_bad = None; - let mut ssh_agent_attempts = Vec::new(); - let mut any_attempts = false; - let mut tried_sshkey = false; - let mut url_attempt = None; - - let orig_url = url; - let mut res = f(&mut |url, username, allowed| { - any_attempts = true; - if url != orig_url { - url_attempt = Some(url.to_string()); - } - // libgit2's "USERNAME" authentication actually means that it's just - // asking us for a username to keep going. This is currently only really - // used for SSH authentication and isn't really an authentication type. - // The logic currently looks like: - // - // let user = ...; - // if (user.is_null()) - // user = callback(USERNAME, null, ...); - // - // callback(SSH_KEY, user, ...) - // - // So if we're being called here then we know that (a) we're using ssh - // authentication and (b) no username was specified in the URL that - // we're trying to clone. We need to guess an appropriate username here, - // but that may involve a few attempts. Unfortunately we can't switch - // usernames during one authentication session with libgit2, so to - // handle this we bail out of this authentication session after setting - // the flag `ssh_username_requested`, and then we handle this below. - if allowed.contains(git2::CredentialType::USERNAME) { - debug_assert!(username.is_none()); - ssh_username_requested = true; - return Err(git2::Error::from_str("gonna try usernames later")) - } - - // An "SSH_KEY" authentication indicates that we need some sort of SSH - // authentication. This can currently either come from the ssh-agent - // process or from a raw in-memory SSH key. We only support using - // ssh-agent currently. - // - // If we get called with this then the only way that should be possible - // is if a username is specified in the URL itself (e.g., `username` is - // Some), hence the unwrap() here. We try custom usernames down below. - if allowed.contains(git2::CredentialType::SSH_KEY) && !tried_sshkey { - // If ssh-agent authentication fails, libgit2 will keep - // calling this callback asking for other authentication - // methods to try. Make sure we only try ssh-agent once, - // to avoid looping forever. - tried_sshkey = true; - let username = username.unwrap(); - debug_assert!(!ssh_username_requested); - ssh_agent_attempts.push(username.to_string()); - return git2::Cred::ssh_key_from_agent(username) - } - - // Sometimes libgit2 will ask for a username/password in plaintext. - // - // If ssh-agent authentication fails, libgit2 will keep calling this - // callback asking for other authentication methods to try. Check - // cred_helper_bad to make sure we only try the git credential helper - // once, to avoid looping forever. - if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none() - { - let r = git2::Cred::credential_helper(cfg, url, username); - cred_helper_bad = Some(r.is_err()); - return r - } - - // I'm... not sure what the DEFAULT kind of authentication is, but seems - // easy to support? - if allowed.contains(git2::CredentialType::DEFAULT) { - return git2::Cred::default() - } - - // Whelp, we tried our best - Err(git2::Error::from_str("no authentication available")) - }); - - // Ok, so if it looks like we're going to be doing ssh authentication, we - // want to try a few different usernames as one wasn't specified in the URL - // for us to use. In order, we'll try: - // - // * A credential helper's username for this URL, if available. - // * This account's username. - // * "git" - // - // We have to restart the authentication session each time (due to - // constraints in libssh2 I guess? maybe this is inherent to ssh?), so we - // call our callback, `f`, in a loop here. - if ssh_username_requested { - debug_assert!(res.is_err()); - let mut attempts = vec![String::from("git")]; - if let Ok(s) = env::var("USER").or_else(|_| env::var("USERNAME")) { - attempts.push(s); - } - if let Some(ref s) = cred_helper.username { - attempts.push(s.clone()); - } - - while let Some(s) = attempts.pop() { - // We should get `USERNAME` first, where we just return our attempt, - // and then after that we should get `SSH_KEY`. If the first attempt - // fails we'll get called again, but we don't have another option so - // we bail out. - let mut attempts = 0; - res = f(&mut |_url, username, allowed| { - if allowed.contains(git2::CredentialType::USERNAME) { - return git2::Cred::username(&s) - } - if allowed.contains(git2::CredentialType::SSH_KEY) { - debug_assert_eq!(Some(&s[..]), username); - attempts += 1; - if attempts == 1 { - ssh_agent_attempts.push(s.to_string()); - return git2::Cred::ssh_key_from_agent(&s) - } - } - Err(git2::Error::from_str("no authentication available")) - }); - - // If we made two attempts then that means: - // - // 1. A username was requested, we returned `s`. - // 2. An ssh key was requested, we returned to look up `s` in the ssh agent. - // 3. For whatever reason that lookup failed, so we were asked again for another mode of - // authentication. - // - // Essentially, if `attempts == 2` then in theory the only error was - // that this username failed to authenticate (e.g., no other network - // errors happened). Otherwise something else is funny so we bail - // out. - if attempts != 2 { - break - } - } - } - let mut err = match res { - Ok(e) => return Ok(e), - Err(e) => e, - }; - - // In the case of an authentication failure (where we tried something) then - // we try to give a more helpful error message about precisely what we - // tried. - if any_attempts { - let mut msg = "failed to authenticate when downloading \ - repository" - .to_string(); - - if let Some(attempt) = &url_attempt { - if url != attempt { - msg.push_str(": "); - msg.push_str(attempt); - } - } - msg.push('\n'); - if !ssh_agent_attempts.is_empty() { - let names = - ssh_agent_attempts.iter().map(|s| format!("`{s}`")).collect::>().join(", "); - write!( - &mut msg, - "\n* attempted ssh-agent authentication, but \ - no usernames succeeded: {names}" - ) - .expect("could not write to msg"); - } - if let Some(failed_cred_helper) = cred_helper_bad { - if failed_cred_helper { - msg.push_str( - "\n* attempted to find username/password via \ - git's `credential.helper` support, but failed", - ); - } else { - msg.push_str( - "\n* attempted to find username/password via \ - `credential.helper`, but maybe the found \ - credentials were incorrect", - ); - } - } - err = err.wrap_err(msg); - - // Otherwise if we didn't even get to the authentication phase them we may - // have failed to set up a connection, in these cases hint on the - // `net.git-fetch-with-cli` configuration option. - } else if let Some(e) = err.downcast_ref::() { - match e.class() { - ErrorClass::Net | - ErrorClass::Ssl | - ErrorClass::Submodule | - ErrorClass::FetchHead | - ErrorClass::Ssh | - ErrorClass::Callback | - ErrorClass::Http => { - err = err.wrap_err("network failure seems to have happened"); - } - _ => {} - } - } - - Err(err) -} - -pub fn fetch( - repo: &mut git2::Repository, - url: &str, - reference: &GitReference, - git_fetch_with_cli: bool, -) -> eyre::Result<()> { - // Translate the reference desired here into an actual list of refspecs - // which need to get fetched. Additionally record if we're fetching tags. - let mut refspecs = Vec::new(); - let mut tags = false; - // The `+` symbol on the refspec means to allow a forced (fast-forward) - // update which is needed if there is ever a force push that requires a - // fast-forward. - match reference { - // For branches and tags we can fetch simply one reference and copy it - // locally, no need to fetch other branches/tags. - GitReference::Branch(b) => { - refspecs.push(format!("+refs/heads/{b}:refs/remotes/origin/{b}")); - } - GitReference::Tag(t) => { - refspecs.push(format!("+refs/tags/{t}:refs/remotes/origin/tags/{t}")); - } - - GitReference::DefaultBranch => { - refspecs.push(String::from("+HEAD:refs/remotes/origin/HEAD")); - } - - GitReference::Rev(rev) => { - if rev.starts_with("refs/") { - refspecs.push(format!("+{rev}:{rev}")); - } else { - // We don't know what the rev will point to. To handle this - // situation we fetch all branches and tags, and then we pray - // it's somewhere in there. - refspecs.push(String::from("+refs/heads/*:refs/remotes/origin/*")); - refspecs.push(String::from("+HEAD:refs/remotes/origin/HEAD")); - tags = true; - } - } - } - - // Unfortunately `libgit2` is notably lacking in the realm of authentication - // when compared to the `git` command line. As a result, allow an escape - // hatch for users that would prefer to use `git`-the-CLI for fetching - // repositories instead of `libgit2`-the-library. This should make more - // flavors of authentication possible while also still giving us all the - // speed and portability of using `libgit2`. - if git_fetch_with_cli { - return fetch_with_cli(repo, url, &refspecs, tags) - } - - debug!("doing a fetch for {url}"); - let git_config = git2::Config::open_default()?; - - with_retry(|| { - with_authentication(url, &git_config, |f| { - let mut opts = git2::FetchOptions::new(); - let mut rcb = git2::RemoteCallbacks::new(); - rcb.credentials(f); - opts.remote_callbacks(rcb); - if tags { - opts.download_tags(git2::AutotagOption::All); - } - // The `fetch` operation here may fail spuriously due to a corrupt - // repository. It could also fail, however, for a whole slew of other - // reasons (aka network related reasons). - // - // Consequently, we save off the error of the `fetch` operation and if it - // looks like a "corrupt repo" error then we blow away the repo and try - // again. If it looks like any other kind of error, or if we've already - // blown away the repository, then we want to return the error as-is. - let mut repo_reinitialized = false; - loop { - debug!("initiating fetch of {:?} from {}", refspecs, url); - let res = repo.remote_anonymous(url)?.fetch(&refspecs, Some(&mut opts), None); - let err = match res { - Ok(()) => break, - Err(e) => e, - }; - debug!("fetch failed: {err}"); - - if !repo_reinitialized && - matches!(err.class(), ErrorClass::Reference | ErrorClass::Odb) - { - repo_reinitialized = true; - debug!( - "looks like this is a corrupt repository, reinitializing \ - and trying again" - ); - if reinitialize(repo).is_ok() { - continue - } - } - - return Err(err.into()) - } - Ok(()) - }) - })?; - Ok(()) -} - -fn fetch_with_cli( - repo: &git2::Repository, - url: &str, - refspecs: &[String], - tags: bool, -) -> eyre::Result<()> { - let mut cmd = Command::new("git"); - cmd.arg("fetch"); - if tags { - cmd.arg("--tags"); - } - cmd.arg("--force") // handle force pushes - .arg("--update-head-ok") - .arg(url) - .args(refspecs) - .env_remove("GIT_DIR") - // The reset of these may not be necessary, but I'm including them - // just to be extra paranoid and avoid any issues. - .env_remove("GIT_WORK_TREE") - .env_remove("GIT_INDEX_FILE") - .env_remove("GIT_OBJECT_DIRECTORY") - .env_remove("GIT_ALTERNATE_OBJECT_DIRECTORIES") - .current_dir(repo.path()); - - cmd.output()?; - Ok(()) -} From 388e181c50c9313ca8cfe2c4f413397100dd1ce7 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Thu, 23 Nov 2023 04:44:11 -0800 Subject: [PATCH 0324/1963] feat(anvil): support for op-stack deposit transactions (#6073) * Add support for op-stack deposit transactions * Fix deposit tx nonce handling * Add --optimism flag * Re-enable other field * Rename OpDeposit to Deposit * Fixes from rebase * Rebase foundry and ethersrs again * Fix cmd flag message * Feature flags and add one test * Additional OP tests, still some TODOs * fmt and clippy * Comments and final TODOs * bump ethers after dependency PR merged * bump revm * more comments * Fix cache tests * touchups * clarify deps * use default branch --------- Co-authored-by: Anika Raghuvanshi Co-authored-by: anikaraghu Co-authored-by: Matthias Seitz --- Cargo.lock | 29 +- Cargo.toml | 20 +- crates/anvil/Cargo.toml | 3 +- crates/anvil/core/Cargo.toml | 10 +- crates/anvil/core/src/eth/receipt.rs | 37 ++- .../core/src/eth/transaction/ethers_compat.rs | 73 ++++- crates/anvil/core/src/eth/transaction/mod.rs | 255 +++++++++++++++++- crates/anvil/src/cmd.rs | 5 + crates/anvil/src/config.rs | 11 + crates/anvil/src/eth/api.rs | 31 ++- crates/anvil/src/eth/backend/executor.rs | 13 +- crates/anvil/src/eth/backend/mem/mod.rs | 30 ++- crates/anvil/src/eth/error.rs | 5 + crates/anvil/src/eth/fees.rs | 1 + crates/anvil/src/eth/sign.rs | 31 ++- crates/anvil/src/eth/util.rs | 2 + crates/anvil/tests/it/main.rs | 1 + crates/anvil/tests/it/optimism.rs | 132 +++++++++ crates/evm/core/Cargo.toml | 1 + crates/evm/core/src/fork/cache.rs | 5 + crates/evm/core/src/utils.rs | 1 + crates/forge/bin/cmd/script/broadcast.rs | 10 +- 22 files changed, 649 insertions(+), 57 deletions(-) create mode 100644 crates/anvil/tests/it/optimism.rs diff --git a/Cargo.lock b/Cargo.lock index 12355e728b75c..797bca799a0b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,6 +306,7 @@ dependencies = [ "ctrlc", "ethereum-forkid", "ethers", + "ethers-core", "ethers-solc", "fdlimit", "flate2", @@ -342,7 +343,10 @@ dependencies = [ "alloy-primitives", "anvil-core", "bytes", + "ethers-contract", "ethers-core", + "ethers-middleware", + "ethers-providers", "foundry-common", "foundry-evm", "hash-db", @@ -2071,7 +2075,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2086,7 +2090,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "ethers-core", "once_cell", @@ -2097,7 +2101,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2115,7 +2119,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "Inflector", "const-hex", @@ -2138,7 +2142,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "Inflector", "const-hex", @@ -2153,7 +2157,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "arrayvec", "bytes", @@ -2182,7 +2186,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "chrono", "ethers-core", @@ -2197,7 +2201,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "async-trait", "auto_impl", @@ -2222,7 +2226,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "async-trait", "auto_impl", @@ -2260,7 +2264,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "async-trait", "coins-bip32", @@ -2288,7 +2292,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=4e09be88730045dd6c4ed8a4e198a9956931e7bd#4e09be88730045dd6c4ed8a4e198a9956931e7bd" +source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" dependencies = [ "cfg-if", "const-hex", @@ -2617,8 +2621,7 @@ dependencies = [ [[package]] name = "foundry-block-explorers" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc59cf4c18884c485b20f376e98946774b76f3b8e2e71e4f35723ffb34b8544" +source = "git+https://github.com/foundry-rs/block-explorers#714c1537cf09d9a96293aadc633166c97d19da95" dependencies = [ "alloy-chains", "alloy-json-abi", diff --git a/Cargo.toml b/Cargo.toml index 68d4ccc90eefe..1aee8f58d2ab5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -189,16 +189,16 @@ tower-http = "0.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-addressbook = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "4e09be88730045dd6c4ed8a4e198a9956931e7bd" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } + +foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index c6430cffdb8c2..dbced4c69d71f 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -31,7 +31,7 @@ foundry-evm.workspace = true bytes = "1.4.0" # needed as documented in https://github.com/foundry-rs/foundry/pull/6358 k256 = "=0.13.1" -ethers = { workspace = true, features = ["rustls", "ws", "ipc"] } +ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } trie-db = "0.23" hash-db = "0.15" memory-db = "0.29" @@ -75,6 +75,7 @@ ethereum-forkid = "0.12" [dev-dependencies] ethers = { workspace = true, features = ["abigen"] } +ethers-core = { workspace = true, features = ["optimism"] } ethers-solc = { workspace = true, features = ["project-util", "full"] } pretty_assertions = "1.3.0" tokio = { version = "1", features = ["full"] } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 034a40737108a..91d86986da824 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -13,10 +13,14 @@ repository.workspace = true foundry-common.workspace = true foundry-evm.workspace = true +alloy-primitives = { workspace = true, features = ["serde"] } revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } +ethers-core = { workspace = true, features = ["optimism"] } +# theses are not used by anvil-core, but are required by ethers, because pulled in via foundry-common +ethers-contract = { workspace = true, features = ["optimism"] } +ethers-providers = { workspace = true, features = ["optimism"] } +ethers-middleware = { workspace = true, features = ["optimism"] } -alloy-primitives = { workspace = true, features = ["serde"] } -ethers-core.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true bytes = { version = "1.4" } @@ -36,4 +40,4 @@ anvil-core = { path = ".", features = ["serde"] } default = ["serde"] impersonated-tx = [] fastrlp = ["dep:open-fastrlp"] -serde = ["dep:serde"] +serde = ["dep:serde"] \ No newline at end of file diff --git a/crates/anvil/core/src/eth/receipt.rs b/crates/anvil/core/src/eth/receipt.rs index 02b696582ef63..c651124878a73 100644 --- a/crates/anvil/core/src/eth/receipt.rs +++ b/crates/anvil/core/src/eth/receipt.rs @@ -94,6 +94,7 @@ impl Decodable for EIP658Receipt { // same underlying data structure pub type EIP2930Receipt = EIP658Receipt; pub type EIP1559Receipt = EIP658Receipt; +pub type DepositReceipt = EIP658Receipt; #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -104,6 +105,8 @@ pub enum TypedReceipt { EIP2930(EIP2930Receipt), /// EIP-1559 receipt EIP1559(EIP1559Receipt), + /// op-stack deposit receipt + Deposit(DepositReceipt), } // == impl TypedReceipt == @@ -112,18 +115,20 @@ impl TypedReceipt { /// Returns the gas used by the transactions pub fn gas_used(&self) -> U256 { match self { - TypedReceipt::Legacy(r) | TypedReceipt::EIP2930(r) | TypedReceipt::EIP1559(r) => { - r.gas_used - } + TypedReceipt::Legacy(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::Deposit(r) => r.gas_used, } } /// Returns the gas used by the transactions pub fn logs_bloom(&self) -> &Bloom { match self { - TypedReceipt::Legacy(r) | TypedReceipt::EIP2930(r) | TypedReceipt::EIP1559(r) => { - &r.logs_bloom - } + TypedReceipt::Legacy(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::Deposit(r) => &r.logs_bloom, } } } @@ -134,6 +139,7 @@ impl Encodable for TypedReceipt { TypedReceipt::Legacy(r) => r.rlp_append(s), TypedReceipt::EIP2930(r) => enveloped(1, r, s), TypedReceipt::EIP1559(r) => enveloped(2, r, s), + TypedReceipt::Deposit(r) => enveloped(0x7E, r, s), } } } @@ -158,6 +164,10 @@ impl Decodable for TypedReceipt { return rlp::decode(s).map(TypedReceipt::EIP1559) } + if first == 0x7E { + return rlp::decode(s).map(TypedReceipt::Deposit) + } + Err(DecoderError::Custom("unknown receipt type")) } } @@ -171,6 +181,7 @@ impl open_fastrlp::Encodable for TypedReceipt { let payload_len = match receipt { TypedReceipt::EIP2930(r) => r.length() + 1, TypedReceipt::EIP1559(r) => r.length() + 1, + TypedReceipt::Deposit(r) => r.length() + 1, _ => unreachable!("receipt already matched"), }; @@ -188,6 +199,7 @@ impl open_fastrlp::Encodable for TypedReceipt { let payload_len = match receipt { TypedReceipt::EIP2930(r) => r.length() + 1, TypedReceipt::EIP1559(r) => r.length() + 1, + TypedReceipt::Deposit(r) => r.length() + 1, _ => unreachable!("receipt already matched"), }; @@ -208,6 +220,14 @@ impl open_fastrlp::Encodable for TypedReceipt { out.put_u8(0x02); r.encode(out); } + TypedReceipt::Deposit(r) => { + let receipt_string_header = + Header { list: false, payload_length: payload_len }; + + receipt_string_header.encode(out); + out.put_u8(0x7E); + r.encode(out); + } _ => unreachable!("receipt already matched"), } } @@ -244,6 +264,10 @@ impl open_fastrlp::Decodable for TypedReceipt { buf.advance(1); ::decode(buf) .map(TypedReceipt::EIP1559) + } else if receipt_type == 0x7E { + buf.advance(1); + ::decode(buf) + .map(TypedReceipt::Deposit) } else { Err(open_fastrlp::DecodeError::Custom("invalid receipt type")) } @@ -264,6 +288,7 @@ impl From for EIP658Receipt { TypedReceipt::Legacy(receipt) => receipt, TypedReceipt::EIP2930(receipt) => receipt, TypedReceipt::EIP1559(receipt) => receipt, + TypedReceipt::Deposit(receipt) => receipt, } } } diff --git a/crates/anvil/core/src/eth/transaction/ethers_compat.rs b/crates/anvil/core/src/eth/transaction/ethers_compat.rs index 21e2cb8b91307..54e2c16c535a8 100644 --- a/crates/anvil/core/src/eth/transaction/ethers_compat.rs +++ b/crates/anvil/core/src/eth/transaction/ethers_compat.rs @@ -2,12 +2,15 @@ use super::EthTransactionRequest; use crate::eth::transaction::{ - EIP1559TransactionRequest, EIP2930TransactionRequest, LegacyTransactionRequest, - MaybeImpersonatedTransaction, TypedTransaction, TypedTransactionRequest, + DepositTransactionRequest, EIP1559TransactionRequest, EIP2930TransactionRequest, + LegacyTransactionRequest, MaybeImpersonatedTransaction, TypedTransaction, + TypedTransactionRequest, }; use ethers_core::types::{ - transaction::eip2718::TypedTransaction as EthersTypedTransactionRequest, Address, - Eip1559TransactionRequest as EthersEip1559TransactionRequest, + transaction::{ + eip2718::TypedTransaction as EthersTypedTransactionRequest, optimism::DepositTransaction, + }, + Address, Eip1559TransactionRequest as EthersEip1559TransactionRequest, Eip2930TransactionRequest as EthersEip2930TransactionRequest, NameOrAddress, Transaction as EthersTransaction, TransactionRequest as EthersLegacyTransactionRequest, TransactionRequest, H256, U256, U64, @@ -87,6 +90,33 @@ impl From for EthersTypedTransactionRequest { chain_id: Some(chain_id.into()), }) } + TypedTransactionRequest::Deposit(tx) => { + let DepositTransactionRequest { + source_hash, + from, + kind, + mint, + value, + gas_limit, + is_system_tx, + input, + } = tx; + EthersTypedTransactionRequest::DepositTransaction(DepositTransaction { + tx: TransactionRequest { + from: Some(from), + to: kind.as_call().cloned().map(Into::into), + gas: Some(gas_limit), + value: Some(value), + data: Some(input), + gas_price: Some(0.into()), + nonce: Some(0.into()), + chain_id: None, + }, + source_hash, + mint: Some(mint), + is_system_tx, + }) + } } } } @@ -117,6 +147,9 @@ fn to_ethers_transaction_with_hash_and_sender( s: t.signature.s, access_list: None, transaction_type: None, + source_hash: H256::zero(), + mint: None, + is_system_tx: false, other: Default::default(), }, TypedTransaction::EIP2930(t) => EthersTransaction { @@ -139,6 +172,9 @@ fn to_ethers_transaction_with_hash_and_sender( s: U256::from(t.s.as_bytes()), access_list: Some(t.access_list), transaction_type: Some(1u64.into()), + source_hash: H256::zero(), + mint: None, + is_system_tx: false, other: Default::default(), }, TypedTransaction::EIP1559(t) => EthersTransaction { @@ -161,6 +197,34 @@ fn to_ethers_transaction_with_hash_and_sender( s: U256::from(t.s.as_bytes()), access_list: Some(t.access_list), transaction_type: Some(2u64.into()), + source_hash: H256::zero(), + mint: None, + is_system_tx: false, + other: Default::default(), + }, + TypedTransaction::Deposit(t) => EthersTransaction { + hash, + nonce: t.nonce, + block_hash: None, + block_number: None, + transaction_index: None, + from, + to: None, + value: t.value, + gas_price: Some(0.into()), + max_fee_per_gas: Some(0.into()), + max_priority_fee_per_gas: Some(0.into()), + gas: t.gas_limit, + input: t.input.clone(), + chain_id: t.chain_id().map(Into::into), + v: 0.into(), + r: 0.into(), + s: 0.into(), + access_list: None, + transaction_type: Some(126u64.into()), + source_hash: t.source_hash, + mint: Some(t.mint), + is_system_tx: t.is_system_tx, other: Default::default(), }, } @@ -201,6 +265,7 @@ impl From for EthTransactionRequest { chain_id, access_list: None, transaction_type: None, + optimism_fields: None, } } } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index a1747706e4beb..68cd9b48fa8dc 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -18,7 +18,7 @@ use foundry_common::types::ToAlloy; use foundry_evm::traces::CallTraceArena; use revm::{ interpreter::InstructionResult, - primitives::{CreateScheme, TransactTo, TxEnv}, + primitives::{CreateScheme, OptimismFields, TransactTo, TxEnv}, }; use std::ops::Deref; @@ -36,11 +36,13 @@ pub const IMPERSONATED_SIGNATURE: Signature = /// 1. Legacy (pre-EIP2718) [`LegacyTransactionRequest`] /// 2. EIP2930 (state access lists) [`EIP2930TransactionRequest`] /// 3. EIP1559 [`EIP1559TransactionRequest`] +/// 4. Deposit [`DepositTransactionRequest`] #[derive(Debug, Clone, Eq, PartialEq)] pub enum TypedTransactionRequest { Legacy(LegacyTransactionRequest), EIP2930(EIP2930TransactionRequest), EIP1559(EIP1559TransactionRequest), + Deposit(DepositTransactionRequest), } /// Represents _all_ transaction requests received from RPC @@ -80,6 +82,22 @@ pub struct EthTransactionRequest { /// EIP-2718 type #[cfg_attr(feature = "serde", serde(rename = "type"))] pub transaction_type: Option, + /// Optimism Deposit Request Fields + #[serde(flatten)] + pub optimism_fields: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, Default, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(deny_unknown_fields))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +pub struct OptimismDepositRequestFields { + /// op-stack deposit source hash + pub source_hash: H256, + /// op-stack deposit mint + pub mint: U256, + /// op-stack deposit system tx + pub is_system_tx: bool, } // == impl EthTransactionRequest == @@ -88,6 +106,7 @@ impl EthTransactionRequest { /// Converts the request into a [TypedTransactionRequest] pub fn into_typed_request(self) -> Option { let EthTransactionRequest { + from, to, gas_price, max_fee_per_gas, @@ -99,10 +118,27 @@ impl EthTransactionRequest { mut access_list, chain_id, transaction_type, + optimism_fields, .. } = self; let chain_id = chain_id.map(|id| id.as_u64()); let transaction_type = transaction_type.map(|id| id.as_u64()); + // op-stack deposit tx + if optimism_fields.is_some() && transaction_type == Some(126) { + return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { + source_hash: optimism_fields.clone()?.source_hash, + from: from.unwrap_or_default(), + kind: match to { + Some(to) => TransactionKind::Call(to), + None => TransactionKind::Create, + }, + mint: optimism_fields.clone()?.mint, + value: value.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), + is_system_tx: optimism_fields.clone()?.is_system_tx, + input: data.clone().unwrap_or_default(), + })); + } match ( transaction_type, gas_price, @@ -414,6 +450,55 @@ impl Encodable for EIP1559TransactionRequest { } } +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct DepositTransactionRequest { + pub from: Address, + pub source_hash: H256, + pub kind: TransactionKind, + pub mint: U256, + pub value: U256, + pub gas_limit: U256, + pub is_system_tx: bool, + pub input: Bytes, +} + +// == impl DepositTransactionRequest == + +impl DepositTransactionRequest { + pub fn hash(&self) -> H256 { + H256::from_slice(keccak256(&rlp::encode(self)).as_slice()) + } +} + +impl From for DepositTransactionRequest { + fn from(tx: DepositTransaction) -> Self { + Self { + from: tx.from, + source_hash: tx.source_hash, + kind: tx.kind, + mint: tx.mint, + value: tx.value, + gas_limit: tx.gas_limit, + is_system_tx: tx.is_system_tx, + input: tx.input, + } + } +} + +impl Encodable for DepositTransactionRequest { + fn rlp_append(&self, s: &mut RlpStream) { + s.begin_list(8); + s.append(&self.from); + s.append(&self.source_hash); + s.append(&self.kind); + s.append(&self.mint); + s.append(&self.value); + s.append(&self.gas_limit); + s.append(&self.is_system_tx); + s.append(&self.input.as_ref()); + } +} + /// A wrapper for `TypedTransaction` that allows impersonating accounts. /// /// This is a helper that carries the `impersonated` sender so that the right hash @@ -532,6 +617,8 @@ pub enum TypedTransaction { EIP2930(EIP2930Transaction), /// EIP-1559 transaction EIP1559(EIP1559Transaction), + /// op-stack deposit transaction + Deposit(DepositTransaction), } // == impl TypedTransaction == @@ -547,6 +634,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.gas_price, TypedTransaction::EIP2930(tx) => tx.gas_price, TypedTransaction::EIP1559(tx) => tx.max_fee_per_gas, + TypedTransaction::Deposit(_) => U256::from(0), } } @@ -555,6 +643,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.gas_limit, TypedTransaction::EIP2930(tx) => tx.gas_limit, TypedTransaction::EIP1559(tx) => tx.gas_limit, + TypedTransaction::Deposit(tx) => tx.gas_limit, } } @@ -563,6 +652,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.value, TypedTransaction::EIP2930(tx) => tx.value, TypedTransaction::EIP1559(tx) => tx.value, + TypedTransaction::Deposit(tx) => tx.value, } } @@ -571,6 +661,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => &tx.input, TypedTransaction::EIP2930(tx) => &tx.input, TypedTransaction::EIP1559(tx) => &tx.input, + TypedTransaction::Deposit(tx) => &tx.input, } } @@ -580,6 +671,7 @@ impl TypedTransaction { TypedTransaction::Legacy(_) => None, TypedTransaction::EIP2930(_) => Some(1), TypedTransaction::EIP1559(_) => Some(2), + TypedTransaction::Deposit(_) => Some(0x7E), } } @@ -627,6 +719,18 @@ impl TypedTransaction { chain_id: Some(t.chain_id), access_list: t.access_list.clone(), }, + TypedTransaction::Deposit(t) => TransactionEssentials { + kind: t.kind, + input: t.input.clone(), + nonce: t.nonce, + gas_limit: t.gas_limit, + gas_price: Some(U256::from(0)), + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + value: t.value, + chain_id: t.chain_id(), + access_list: Default::default(), + }, } } @@ -635,6 +739,7 @@ impl TypedTransaction { TypedTransaction::Legacy(t) => t.nonce(), TypedTransaction::EIP2930(t) => t.nonce(), TypedTransaction::EIP1559(t) => t.nonce(), + TypedTransaction::Deposit(t) => t.nonce(), } } @@ -643,6 +748,7 @@ impl TypedTransaction { TypedTransaction::Legacy(t) => t.chain_id(), TypedTransaction::EIP2930(t) => Some(t.chain_id), TypedTransaction::EIP1559(t) => Some(t.chain_id), + TypedTransaction::Deposit(t) => t.chain_id(), } } @@ -672,6 +778,7 @@ impl TypedTransaction { TypedTransaction::Legacy(t) => t.hash(), TypedTransaction::EIP2930(t) => t.hash(), TypedTransaction::EIP1559(t) => t.hash(), + TypedTransaction::Deposit(t) => t.hash(), } } @@ -697,6 +804,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.recover(), TypedTransaction::EIP2930(tx) => tx.recover(), TypedTransaction::EIP1559(tx) => tx.recover(), + TypedTransaction::Deposit(tx) => tx.recover(), } } @@ -706,6 +814,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => &tx.kind, TypedTransaction::EIP2930(tx) => &tx.kind, TypedTransaction::EIP1559(tx) => &tx.kind, + TypedTransaction::Deposit(tx) => &tx.kind, } } @@ -730,6 +839,7 @@ impl TypedTransaction { let s = U256::from_big_endian(&tx.s[..]); Signature { r, s, v: v.into() } } + TypedTransaction::Deposit(_) => Signature { r: U256::zero(), s: U256::zero(), v: 0 }, } } } @@ -740,6 +850,7 @@ impl Encodable for TypedTransaction { TypedTransaction::Legacy(tx) => tx.rlp_append(s), TypedTransaction::EIP2930(tx) => enveloped(1, tx, s), TypedTransaction::EIP1559(tx) => enveloped(2, tx, s), + TypedTransaction::Deposit(tx) => enveloped(0x7E, tx, s), } } } @@ -754,9 +865,11 @@ impl Decodable for TypedTransaction { }; // "advance" the header, see comments in fastrlp impl below let s = if s.is_empty() { &rlp.as_raw()[1..] } else { s }; + match *first { 0x01 => rlp::decode(s).map(TypedTransaction::EIP2930), 0x02 => rlp::decode(s).map(TypedTransaction::EIP1559), + 0x7E => rlp::decode(s).map(TypedTransaction::Deposit), _ => Err(DecoderError::Custom("invalid tx type")), } } @@ -771,6 +884,7 @@ impl open_fastrlp::Encodable for TypedTransaction { let payload_len = match tx { TypedTransaction::EIP2930(tx) => tx.length() + 1, TypedTransaction::EIP1559(tx) => tx.length() + 1, + TypedTransaction::Deposit(tx) => tx.length() + 1, _ => unreachable!("legacy tx length already matched"), }; @@ -791,6 +905,14 @@ impl open_fastrlp::Encodable for TypedTransaction { out.put_u8(0x02); tx.encode(out); } + TypedTransaction::Deposit(tx) => { + let tx_string_header = + open_fastrlp::Header { list: false, payload_length: payload_len }; + + tx_string_header.encode(out); + out.put_u8(0x7E); + tx.encode(out); + } _ => unreachable!("legacy tx encode already matched"), } } @@ -803,6 +925,7 @@ impl open_fastrlp::Encodable for TypedTransaction { let payload_len = match tx { TypedTransaction::EIP2930(tx) => tx.length() + 1, TypedTransaction::EIP1559(tx) => tx.length() + 1, + TypedTransaction::Deposit(tx) => tx.length() + 1, _ => unreachable!("legacy tx length already matched"), }; // we include a string header for signed types txs, so include the length here @@ -848,6 +971,10 @@ impl open_fastrlp::Decodable for TypedTransaction { buf.advance(1); ::decode(buf) .map(TypedTransaction::EIP1559) + } else if tx_type == 0x7E { + buf.advance(1); + ::decode(buf) + .map(TypedTransaction::Deposit) } else { Err(open_fastrlp::DecodeError::Custom("invalid tx type")) } @@ -1123,6 +1250,76 @@ impl Decodable for EIP1559Transaction { } } +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + +pub struct DepositTransaction { + pub nonce: U256, + pub source_hash: H256, + pub from: Address, + pub kind: TransactionKind, + pub mint: U256, + pub value: U256, + pub gas_limit: U256, + pub is_system_tx: bool, + pub input: Bytes, +} + +impl DepositTransaction { + pub fn nonce(&self) -> &U256 { + &self.nonce + } + + pub fn hash(&self) -> H256 { + H256::from_slice(keccak256(&rlp::encode(self)).as_slice()) + } + + /// Recovers the Ethereum address which was used to sign the transaction. + pub fn recover(&self) -> Result { + Ok(self.from) + } + + pub fn chain_id(&self) -> Option { + None + } +} + +impl Encodable for DepositTransaction { + fn rlp_append(&self, s: &mut RlpStream) { + s.begin_list(9); + s.append(&self.nonce); + s.append(&self.source_hash); + s.append(&self.from); + s.append(&self.kind); + s.append(&self.mint); + s.append(&self.value); + s.append(&self.gas_limit); + s.append(&self.is_system_tx); + s.append(&self.input.as_ref()); + } +} + +impl Decodable for DepositTransaction { + fn decode(rlp: &Rlp) -> Result { + if rlp.item_count()? != 8 { + return Err(DecoderError::RlpIncorrectListLen) + } + + Ok(Self { + source_hash: rlp.val_at(0)?, + from: rlp.val_at(1)?, + kind: rlp.val_at(2)?, + mint: rlp.val_at(3)?, + value: rlp.val_at(4)?, + gas_limit: rlp.val_at(5)?, + is_system_tx: rlp.val_at(6)?, + input: rlp.val_at::>(7)?.into(), + nonce: U256::from(0), + }) + } +} + #[derive(Clone, Debug, PartialEq, Eq)] pub struct TransactionEssentials { pub kind: TransactionKind, @@ -1264,6 +1461,39 @@ impl PendingTransaction { ..Default::default() } } + TypedTransaction::Deposit(tx) => { + let chain_id = tx.chain_id(); + let DepositTransaction { + nonce, + source_hash, + gas_limit, + value, + kind, + mint, + input, + is_system_tx, + .. + } = tx; + TxEnv { + caller: caller.to_alloy(), + transact_to: transact_to(kind), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id, + nonce: Some(nonce.as_u64()), + value: (*value).to_alloy(), + gas_price: 0.to_alloy(), + gas_priority_fee: None, + gas_limit: gas_limit.as_u64(), + access_list: vec![], + optimism: OptimismFields { + source_hash: Some(source_hash.to_alloy()), + mint: Some(mint.as_u128()), + is_system_transaction: Some(*is_system_tx), + enveloped_tx: None, + }, + ..Default::default() + } + } } } } @@ -1281,6 +1511,7 @@ pub struct TransactionInfo { pub traces: CallTraceArena, pub exit: InstructionResult, pub out: Option, + pub nonce: u64, } // === impl TransactionInfo === @@ -1585,6 +1816,28 @@ mod tests { expected, ::decode(bytes_fifth).unwrap() ); + + let bytes_sixth = &mut &hex::decode("b8587ef85507a0000000000000000000000000000000000000000000000000000000000000000094cf7f9e66af820a19257a2108375b180b0ec491679461815774383099e24810ab832a5b2a5425c154d5808230398287fb0180").unwrap()[..]; + let expected: TypedTransaction = TypedTransaction::Deposit(DepositTransaction { + nonce: 7u64.into(), + source_hash: H256::from_str( + "0000000000000000000000000000000000000000000000000000000000000000", + ) + .unwrap(), + from: "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(), + kind: TransactionKind::Call(Address::from_slice( + &hex::decode("61815774383099e24810ab832a5b2a5425c154d5").unwrap()[..], + )), + mint: U256::zero(), + value: 12345u64.into(), + gas_limit: 34811u64.into(), + input: Bytes::default(), + is_system_tx: true, + }); + assert_eq!( + expected, + ::decode(bytes_sixth).unwrap() + ); } // diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index b6dbfbc8c2653..5f184cb80dd74 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -230,6 +230,7 @@ impl NodeArgs { .set_pruned_history(self.prune_history) .with_init_state(self.load_state.or_else(|| self.state.and_then(|s| s.state))) .with_transaction_block_keeper(self.transaction_block_keeper) + .with_optimism(self.evm_opts.optimism) } fn account_generator(&self) -> AccountGenerator { @@ -500,6 +501,10 @@ pub struct AnvilEvmArgs { /// Enable autoImpersonate on startup #[clap(long, visible_alias = "auto-impersonate")] pub auto_impersonate: bool, + + /// Run an Optimism chain + #[clap(long, visible_alias = "optimism")] + pub optimism: bool, } /// Resolves an alias passed as fork-url to the matching url defined in the rpc_endpoints section diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index cad1d7f628479..2b6f9fad7cbad 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -169,6 +169,8 @@ pub struct NodeConfig { pub transaction_block_keeper: Option, /// Disable the default CREATE2 deployer pub disable_default_create2_deployer: bool, + /// Enable Optimism deposit transaction + pub enable_optimism: bool, } impl NodeConfig { @@ -406,6 +408,7 @@ impl Default for NodeConfig { init_state: None, transaction_block_keeper: None, disable_default_create2_deployer: false, + enable_optimism: false, } } } @@ -784,6 +787,13 @@ impl NodeConfig { Config::foundry_block_cache_file(chain_id, block) } + /// Sets whether to enable optimism support + #[must_use] + pub fn with_optimism(mut self, enable_optimism: bool) -> Self { + self.enable_optimism = enable_optimism; + self + } + /// Configures everything related to env, backend and database and returns the /// [Backend](mem::Backend) /// @@ -800,6 +810,7 @@ impl NodeConfig { // caller is a contract. So we disable the check by default. cfg.disable_eip3607 = true; cfg.disable_block_gas_limit = self.disable_block_gas_limit; + cfg.optimism = self.enable_optimism; let mut env = revm::primitives::Env { cfg, diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index ff9a0cbab7e1e..232045e7552d9 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -56,8 +56,8 @@ use ethers::{ eip712::TypedData, }, Address, Block, BlockId, BlockNumber, Bytes, FeeHistory, Filter, FilteredParams, - GethDebugTracingOptions, GethTrace, Log, Trace, Transaction, TransactionReceipt, TxHash, - TxpoolContent, TxpoolInspectSummary, TxpoolStatus, H256, U256, U64, + GethDebugTracingOptions, GethTrace, Log, Signature, Trace, Transaction, TransactionReceipt, + TxHash, TxpoolContent, TxpoolInspectSummary, TxpoolStatus, H256, U256, U64, }, utils::rlp, }; @@ -408,10 +408,19 @@ impl EthApi { from: &Address, request: TypedTransactionRequest, ) -> Result { - for signer in self.signers.iter() { - if signer.accounts().contains(from) { - let signature = signer.sign_transaction(request.clone(), from)?; - return build_typed_transaction(request, signature) + match request { + TypedTransactionRequest::Deposit(_) => { + const NIL_SIGNATURE: ethers::types::Signature = + Signature { r: U256::zero(), s: U256::zero(), v: 0 }; + return build_typed_transaction(request, NIL_SIGNATURE) + } + _ => { + for signer in self.signers.iter() { + if signer.accounts().contains(from) { + let signature = signer.sign_transaction(request.clone(), from)?; + return build_typed_transaction(request, signature) + } + } } } Err(BlockchainError::NoSignerAvailable) @@ -835,7 +844,6 @@ impl EthApi { let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; let request = self.build_typed_tx_request(request, nonce)?; - // if the sender is currently impersonated we need to "bypass" signing let pending_transaction = if self.is_impersonated(from) { let bypass_signature = self.backend.cheats().bypass_signature(); @@ -2427,6 +2435,10 @@ impl EthApi { } TypedTransactionRequest::EIP1559(m) } + Some(TypedTransactionRequest::Deposit(mut m)) => { + m.gas_limit = gas_limit; + TypedTransactionRequest::Deposit(m) + } _ => return Err(BlockchainError::FailedToDecodeTransaction), }; Ok(request) @@ -2503,6 +2515,7 @@ impl EthApi { match &tx { TypedTransaction::EIP2930(_) => self.backend.ensure_eip2930_active(), TypedTransaction::EIP1559(_) => self.backend.ensure_eip1559_active(), + TypedTransaction::Deposit(_) => self.backend.ensure_op_deposits_active(), TypedTransaction::Legacy(_) => Ok(()), } } @@ -2591,6 +2604,10 @@ fn determine_base_gas_by_kind(request: EthTransactionRequest) -> U256 { TransactionKind::Call(_) => MIN_TRANSACTION_GAS, TransactionKind::Create => MIN_CREATE_GAS, }, + TypedTransactionRequest::Deposit(req) => match req.kind { + TransactionKind::Call(_) => MIN_TRANSACTION_GAS, + TransactionKind::Create => MIN_CREATE_GAS, + }, }, // Tighten the gas limit upwards if we don't know the transaction type to avoid deployments // failing. diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 1f3f8f45f7606..df71bc1fd1518 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -8,7 +8,7 @@ use crate::{ }; use anvil_core::eth::{ block::{Block, BlockInfo, Header, PartialHeader}, - receipt::{EIP1559Receipt, EIP2930Receipt, EIP658Receipt, Log, TypedReceipt}, + receipt::{DepositReceipt, EIP1559Receipt, EIP2930Receipt, EIP658Receipt, Log, TypedReceipt}, transaction::{PendingTransaction, TransactionInfo, TypedTransaction}, trie, }; @@ -38,6 +38,7 @@ pub struct ExecutedTransaction { gas_used: u64, logs: Vec, traces: Vec, + nonce: u64, } // == impl ExecutedTransaction == @@ -71,6 +72,12 @@ impl ExecutedTransaction { logs_bloom: bloom, logs, }), + TypedTransaction::Deposit(_) => TypedReceipt::Deposit(DepositReceipt { + status_code, + gas_used: used_gas, + logs_bloom: bloom, + logs, + }), } } } @@ -171,6 +178,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' Some(Output::Create(b, _)) => Some(ethers::types::Bytes(b.0)), _ => None, }, + nonce: tx.nonce, }; transaction_infos.push(info); @@ -249,6 +257,8 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator return Some(TransactionExecutionOutcome::Invalid(transaction, err)) } + let nonce = account.nonce; + let mut evm = revm::EVM::new(); evm.env = env; evm.database(&mut self.db); @@ -312,6 +322,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator gas_used, logs: logs.unwrap_or_default().into_iter().map(Into::into).collect(), traces: inspector.tracer.unwrap_or_default().traces.arena, + nonce, }; Some(TransactionExecutionOutcome::Executed(tx)) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 72d105a0ac767..b82591d1532c4 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -553,6 +553,11 @@ impl Backend { (self.spec_id() as u8) >= (SpecId::BERLIN as u8) } + /// Returns true if op-stack deposits are active + pub fn is_optimism(&self) -> bool { + self.env.read().cfg.optimism + } + /// Returns an error if EIP1559 is not active (pre Berlin) pub fn ensure_eip1559_active(&self) -> Result<(), BlockchainError> { if self.is_eip1559() { @@ -569,6 +574,14 @@ impl Backend { Err(BlockchainError::EIP2930TransactionUnsupportedAtHardfork) } + /// Returns an error if op-stack deposits are not active + pub fn ensure_op_deposits_active(&self) -> Result<(), BlockchainError> { + if self.is_optimism() { + return Ok(()) + } + Err(BlockchainError::DepositTransactionUnsupported) + } + /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { self.env.read().block.gas_limit.to_ethers() @@ -1913,8 +1926,11 @@ impl Backend { .unwrap_or(self.base_fee()) .checked_add(t.max_priority_fee_per_gas) .unwrap_or_else(U256::max_value), + TypedTransaction::Deposit(_) => U256::from(0), }; + let deposit_nonce = transaction_type.and_then(|x| (x == 0x7E).then_some(info.nonce)); + let inner = TransactionReceipt { transaction_hash: info.transaction_hash, transaction_index: info.transaction_index.into(), @@ -1956,6 +1972,11 @@ impl Backend { logs_bloom, transaction_type: transaction_type.map(Into::into), effective_gas_price: Some(effective_gas_price), + deposit_nonce, + l1_fee: None, + l1_fee_scalar: None, + l1_gas_price: None, + l1_gas_used: None, other: OtherFields::default(), }; @@ -2234,15 +2255,17 @@ impl TransactionValidator for Backend { } // check nonce + let is_deposit_tx = + matches!(&pending.transaction.transaction, TypedTransaction::Deposit(_)); let nonce: u64 = (*tx.nonce()).try_into().map_err(|_| InvalidTransactionError::NonceMaxValue)?; - if nonce < account.nonce { + if nonce < account.nonce && !is_deposit_tx { warn!(target: "backend", "[{:?}] nonce too low", tx.hash()); return Err(InvalidTransactionError::NonceTooLow) } if (env.cfg.spec_id as u8) >= (SpecId::LONDON as u8) { - if tx.gas_price() < env.block.basefee.to_ethers() { + if tx.gas_price() < env.block.basefee.to_ethers() && !is_deposit_tx { warn!(target: "backend", "max fee per gas={}, too low, block basefee={}",tx.gas_price(), env.block.basefee); return Err(InvalidTransactionError::FeeCapTooLow) } @@ -2297,6 +2320,9 @@ pub fn transaction_build( base_fee: Option, ) -> Transaction { let mut transaction: Transaction = eth_transaction.clone().into(); + if info.is_some() && transaction.transaction_type.unwrap_or(U64::zero()).as_u64() == 0x7E { + transaction.nonce = U256::from(info.as_ref().unwrap().nonce); + } if eth_transaction.is_dynamic_fee() { if block.is_none() && info.is_none() { diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 971ef9956111c..db17c003b9b60 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -84,6 +84,8 @@ pub enum BlockchainError { EIP1559TransactionUnsupportedAtHardfork, #[error("Access list received but is not supported by the current hardfork.\n\nYou can use it by running anvil with '--hardfork berlin' or later.")] EIP2930TransactionUnsupportedAtHardfork, + #[error("op-stack deposit tx received but is not supported.\n\nYou can use it by running anvil with '--optimism'.")] + DepositTransactionUnsupported, #[error("Excess blob gas not set.")] ExcessBlobGasNotSet, } @@ -405,6 +407,9 @@ impl ToRpcResponseResult for Result { err @ BlockchainError::EIP2930TransactionUnsupportedAtHardfork => { RpcError::invalid_params(err.to_string()) } + err @ BlockchainError::DepositTransactionUnsupported => { + RpcError::invalid_params(err.to_string()) + } err @ BlockchainError::ExcessBlobGasNotSet => { RpcError::invalid_params(err.to_string()) } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 2206d302b8d91..67bc73740c4f0 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -256,6 +256,7 @@ impl FeeHistoryService { .max_priority_fee_per_gas .min(t.max_fee_per_gas.saturating_sub(base_fee)) .as_u64(), + Some(TypedTransaction::Deposit(_)) => 0, None => 0, }; diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index 46fbecb93725a..112f8c7ab46b6 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -1,7 +1,8 @@ use crate::eth::error::BlockchainError; use anvil_core::eth::transaction::{ - EIP1559Transaction, EIP1559TransactionRequest, EIP2930Transaction, EIP2930TransactionRequest, - LegacyTransaction, LegacyTransactionRequest, TypedTransaction, TypedTransactionRequest, + DepositTransaction, DepositTransactionRequest, EIP1559Transaction, EIP1559TransactionRequest, + EIP2930Transaction, EIP2930TransactionRequest, LegacyTransaction, LegacyTransactionRequest, + TypedTransaction, TypedTransactionRequest, }; use ethers::{ core::k256::ecdsa::SigningKey, @@ -11,7 +12,7 @@ use ethers::{ transaction::{ eip2718::TypedTransaction as EthersTypedTransactionRequest, eip712::TypedData, }, - Signature, H256, + Signature, H256, U256, }, }; use std::collections::HashMap; @@ -194,6 +195,30 @@ pub fn build_typed_transaction( }, }) } + TypedTransactionRequest::Deposit(tx) => { + let DepositTransactionRequest { + from, + gas_limit, + kind, + value, + input, + source_hash, + mint, + is_system_tx, + .. + } = tx; + TypedTransaction::Deposit(DepositTransaction { + from, + gas_limit, + kind, + value, + input, + source_hash, + mint, + is_system_tx, + nonce: U256::zero(), + }) + } }; Ok(tx) diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 183b37e8eea08..41f1d23bf4df1 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -79,6 +79,8 @@ pub fn to_precompile_id(spec_id: SpecId) -> revm::precompile::SpecId { SpecId::MERGE | SpecId::SHANGHAI | SpecId::CANCUN | + SpecId::BEDROCK | + SpecId::REGOLITH | SpecId::LATEST => revm::precompile::SpecId::BERLIN, } } diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index cd99a9f15a011..057a9fdea596d 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -9,6 +9,7 @@ mod genesis; mod geth; mod ipc; mod logs; +mod optimism; mod proof; mod pubsub; // mod revert; // TODO uncomment diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs new file mode 100644 index 0000000000000..5432a487fe268 --- /dev/null +++ b/crates/anvil/tests/it/optimism.rs @@ -0,0 +1,132 @@ +//! tests for OP chain support +use anvil::{spawn, NodeConfig}; +use ethers::{ + abi::Address, + providers::Middleware, + types::{ + transaction::{eip2718::TypedTransaction, optimism::DepositTransaction}, + TransactionRequest, U256, + }, +}; +use ethers_core::types::{Bytes, H256}; +use std::str::FromStr; + +#[tokio::test(flavor = "multi_thread")] +async fn test_deposits_not_supported_if_optimism_disabled() { + // optimism disabled by default + let (_, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); + let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); + let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { + tx: TransactionRequest { + chain_id: None, + from: Some(from_addr), + to: Some(ethers::types::NameOrAddress::Address(to_addr)), + value: Some("1234".parse().unwrap()), + gas: Some(U256::from(21000)), + gas_price: None, + data: Some(Bytes::default()), + nonce: None, + }, + source_hash: H256::from_str( + "0000000000000000000000000000000000000000000000000000000000000000", + ) + .unwrap(), + mint: Some(U256::zero()), + is_system_tx: true, + }); + + // sending the deposit transaction should fail with error saying not supported + let res = provider.send_transaction(deposit_tx.clone(), None).await; + assert!(res.is_err()); + assert!(res + .unwrap_err() + .to_string() + .contains("op-stack deposit tx received but is not supported")); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_send_value_deposit_transaction() { + // enable the Optimism flag + let (api, handle) = spawn(NodeConfig::test().with_optimism(true)).await; + let provider = handle.http_provider(); + + let send_value: U256 = "1234".parse().unwrap(); + let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); + let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); + + // fund the sender + api.anvil_set_balance(from_addr, send_value).await.unwrap(); + + let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { + tx: TransactionRequest { + chain_id: None, + from: Some(from_addr), + to: Some(ethers::types::NameOrAddress::Address(to_addr)), + value: Some(send_value), + gas: Some(U256::from(21000)), + gas_price: None, + data: Some(Bytes::default()), + nonce: None, + }, + source_hash: H256::from_str( + "0000000000000000000000000000000000000000000000000000000000000000", + ) + .unwrap(), + mint: Some(U256::zero()), + is_system_tx: true, + }); + provider.send_transaction(deposit_tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + + // mine block + api.evm_mine(None).await.unwrap(); + + // the recipient should have received the value + let balance = provider.get_balance(to_addr, None).await.unwrap(); + assert_eq!(balance, send_value); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_send_value_raw_deposit_transaction() { + // enable the Optimism flag + let (api, handle) = spawn(NodeConfig::test().with_optimism(true)).await; + let provider = handle.http_provider(); + + let send_value: U256 = "1234".parse().unwrap(); + let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); + let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); + + // fund the sender + api.anvil_set_balance(from_addr, send_value).await.unwrap(); + + let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { + tx: TransactionRequest { + chain_id: None, + from: Some(from_addr), + to: Some(ethers::types::NameOrAddress::Address(to_addr)), + value: Some(send_value), + gas: Some(U256::from(21000)), + gas_price: None, + data: Some(Bytes::default()), + nonce: None, + }, + source_hash: H256::from_str( + "0000000000000000000000000000000000000000000000000000000000000000", + ) + .unwrap(), + mint: Some(U256::zero()), + is_system_tx: true, + }); + + let rlpbytes = deposit_tx.rlp(); + provider.send_raw_transaction(rlpbytes).await.unwrap().await.unwrap().unwrap(); + + // mine block + api.evm_mine(None).await.unwrap(); + + // the recipient should have received the value + let balance = provider.get_balance(to_addr, None).await.unwrap(); + assert_eq!(balance, send_value); +} diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 65d2e4fe01a71..51d9ad6df13ca 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -29,6 +29,7 @@ revm = { workspace = true, default-features = false, features = [ "optional_block_gas_limit", "optional_no_base_fee", "arbitrary", + "optimism", ] } ethers-core.workspace = true diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index 4e4aa80e38ac7..ca467dbdf4b5e 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -189,6 +189,11 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { // keep default value obj.insert(key.to_string(), false.into()); } + let key = "optimism"; + if !obj.contains_key(key) { + // keep default value + obj.insert(key.to_string(), false.into()); + } } let cfg_env: revm::primitives::CfgEnv = diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index c4cf12517631f..8edaa4e21e0e4 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -132,6 +132,7 @@ pub fn halt_to_instruction_result(halt: Halt) -> InstructionResult { Halt::CallNotAllowedInsideStatic => InstructionResult::CallNotAllowedInsideStatic, Halt::OutOfFund => InstructionResult::OutOfFund, Halt::CallTooDeep => InstructionResult::CallTooDeep, + Halt::FailedDeposit => InstructionResult::Return, } } diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 636cfdce60e74..e17fb9f30f5fe 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -67,9 +67,6 @@ impl ScriptArgs { // Make a one-time gas price estimation let (gas_price, eip1559_fees) = { match deployment_sequence.transactions.front().unwrap().typed_tx() { - TypedTransaction::Legacy(_) | TypedTransaction::Eip2930(_) => { - (provider.get_gas_price().await.ok(), None) - } TypedTransaction::Eip1559(_) => { let fees = estimate_eip1559_fees(&provider, Some(chain)) .await @@ -77,6 +74,7 @@ impl ScriptArgs { (None, Some(fees)) } + _ => (provider.get_gas_price().await.ok(), None), } }; @@ -102,9 +100,6 @@ impl ScriptArgs { } else { // fill gas price match tx { - TypedTransaction::Eip2930(_) | TypedTransaction::Legacy(_) => { - tx.set_gas_price(gas_price.expect("Could not get gas_price.")); - } TypedTransaction::Eip1559(ref mut inner) => { let eip1559_fees = eip1559_fees.expect("Could not get eip1559 fee estimation."); @@ -116,6 +111,9 @@ impl ScriptArgs { } inner.max_fee_per_gas = Some(eip1559_fees.0); } + _ => { + tx.set_gas_price(gas_price.expect("Could not get gas_price.")); + } } } From 55dd5de4948a92440296f330c779d4ed778c0123 Mon Sep 17 00:00:00 2001 From: Valentin B <703631+beeb@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:39:45 +0100 Subject: [PATCH 0325/1963] fix(forge): format `new` expressions (#6408) * fix(forge): format `new` expressions * fmt * style: format * fix(forge): use write_chunk for `Expression::New` * style: format Prank.t.sol with new formatter * style: format formatter.rs * no trailing semicolons --------- Co-authored-by: Matthias Seitz --- crates/fmt/src/formatter.rs | 4 ++++ crates/fmt/testdata/ArrayExpressions/fmt.sol | 2 +- crates/fmt/testdata/ArrayExpressions/original.sol | 3 ++- .../testdata/FunctionCall/bracket-spacing.fmt.sol | 5 +++++ crates/fmt/testdata/FunctionCall/fmt.sol | 5 +++++ crates/fmt/testdata/FunctionCall/original.sol | 5 +++++ crates/fmt/testdata/FunctionType/fmt.sol | 4 ++-- crates/fmt/testdata/FunctionType/original.sol | 4 ++-- testdata/cheats/Prank.t.sol | 15 +++------------ testdata/cheats/RecordAccountAccesses.t.sol | 6 +++--- 10 files changed, 32 insertions(+), 21 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 467fa72bff2b6..4e2d3296802a6 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -2286,6 +2286,10 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { expr.visit(self)?; stmt.visit(self)?; } + Expression::New(_, expr) => { + write_chunk!(self, "new ")?; + self.visit_expr(expr.loc(), expr)?; + } _ => self.visit_source(loc)?, }; diff --git a/crates/fmt/testdata/ArrayExpressions/fmt.sol b/crates/fmt/testdata/ArrayExpressions/fmt.sol index 0476da9e1f020..adda7a30e098d 100644 --- a/crates/fmt/testdata/ArrayExpressions/fmt.sol +++ b/crates/fmt/testdata/ArrayExpressions/fmt.sol @@ -4,7 +4,7 @@ contract ArrayExpressions { uint256[10] memory sample; uint256 length = 10; - uint256[] memory sample2 = new uint[](length); + uint256[] memory sample2 = new uint256[](length); uint256[] /* comment1 */ memory /* comment2 */ sample3; // comment3 diff --git a/crates/fmt/testdata/ArrayExpressions/original.sol b/crates/fmt/testdata/ArrayExpressions/original.sol index 7f26bd5f7aaa3..919cd241fdaed 100644 --- a/crates/fmt/testdata/ArrayExpressions/original.sol +++ b/crates/fmt/testdata/ArrayExpressions/original.sol @@ -4,7 +4,8 @@ contract ArrayExpressions { uint[10] memory sample; uint256 length = 10; - uint[] memory sample2 = new uint[](length); + uint[] memory sample2 = new uint[]( + length); uint /* comment1 */ [] memory /* comment2 */ sample3 // comment3 ; diff --git a/crates/fmt/testdata/FunctionCall/bracket-spacing.fmt.sol b/crates/fmt/testdata/FunctionCall/bracket-spacing.fmt.sol index 84a4ce8b1e376..2bfe9798c5294 100644 --- a/crates/fmt/testdata/FunctionCall/bracket-spacing.fmt.sol +++ b/crates/fmt/testdata/FunctionCall/bracket-spacing.fmt.sol @@ -30,8 +30,13 @@ contract FunctionCall { function a(uint256 foo) { foo; + MyContract c = new MyContract(address(0), hex"beef"); } function b() { a({ foo: 5 }); } + +contract MyContract { + constructor(address arg, bytes memory data) { } +} diff --git a/crates/fmt/testdata/FunctionCall/fmt.sol b/crates/fmt/testdata/FunctionCall/fmt.sol index c57c5fda030aa..ff22f63aaa5ce 100644 --- a/crates/fmt/testdata/FunctionCall/fmt.sol +++ b/crates/fmt/testdata/FunctionCall/fmt.sol @@ -29,8 +29,13 @@ contract FunctionCall { function a(uint256 foo) { foo; + MyContract c = new MyContract(address(0), hex"beef"); } function b() { a({foo: 5}); } + +contract MyContract { + constructor(address arg, bytes memory data) {} +} diff --git a/crates/fmt/testdata/FunctionCall/original.sol b/crates/fmt/testdata/FunctionCall/original.sol index 8bdc92e464169..ea03850554e25 100644 --- a/crates/fmt/testdata/FunctionCall/original.sol +++ b/crates/fmt/testdata/FunctionCall/original.sol @@ -22,8 +22,13 @@ contract FunctionCall { function a(uint256 foo) { foo; + MyContract c = new MyContract(address( 0),hex"beef"); } function b() { a( {foo: 5} ); } + +contract MyContract { + constructor(address arg, bytes memory data) {} +} diff --git a/crates/fmt/testdata/FunctionType/fmt.sol b/crates/fmt/testdata/FunctionType/fmt.sol index 67c784cac68df..39053d816058f 100644 --- a/crates/fmt/testdata/FunctionType/fmt.sol +++ b/crates/fmt/testdata/FunctionType/fmt.sol @@ -5,7 +5,7 @@ library ArrayUtils { pure returns (uint256[] memory r) { - r = new uint[](self.length); + r = new uint256[](self.length); for (uint256 i = 0; i < self.length; i++) { r[i] = f(self[i]); } @@ -23,7 +23,7 @@ library ArrayUtils { } function range(uint256 length) internal pure returns (uint256[] memory r) { - r = new uint[](length); + r = new uint256[](length); for (uint256 i = 0; i < r.length; i++) { r[i] = i; } diff --git a/crates/fmt/testdata/FunctionType/original.sol b/crates/fmt/testdata/FunctionType/original.sol index 7247a4f933cc3..27b402d85ef5f 100644 --- a/crates/fmt/testdata/FunctionType/original.sol +++ b/crates/fmt/testdata/FunctionType/original.sol @@ -6,7 +6,7 @@ library ArrayUtils { uint[] memory r ) { - r = new uint[](self.length); + r = new uint[]( self.length); for (uint i = 0; i < self.length; i++) { r[i] = f(self[i]); } @@ -23,7 +23,7 @@ library ArrayUtils { } function range(uint256 length) internal pure returns (uint[] memory r) { - r = new uint[](length); + r = new uint256[](length ); for (uint i = 0; i < r.length; i++) { r[i] = i; } diff --git a/testdata/cheats/Prank.t.sol b/testdata/cheats/Prank.t.sol index fa28f0c92a96f..0e23ed7b805d9 100644 --- a/testdata/cheats/Prank.t.sol +++ b/testdata/cheats/Prank.t.sol @@ -274,10 +274,7 @@ contract PrankTest is DSTest { function testPrankConstructorSender(address sender) public { vm.prank(sender); ConstructorVictim victim = new ConstructorVictim( - sender, - "msg.sender was not set during prank", - tx.origin, - "tx.origin invariant failed" + sender, "msg.sender was not set during prank", tx.origin, "tx.origin invariant failed" ); // Ensure we cleaned up correctly @@ -290,10 +287,7 @@ contract PrankTest is DSTest { // Perform the prank vm.prank(sender, origin); ConstructorVictim victim = new ConstructorVictim( - sender, - "msg.sender was not set during prank", - origin, - "tx.origin was not set during prank" + sender, "msg.sender was not set during prank", origin, "tx.origin was not set during prank" ); // Ensure we cleaned up correctly @@ -329,10 +323,7 @@ contract PrankTest is DSTest { // Perform the prank vm.startPrank(sender, origin); ConstructorVictim victim = new ConstructorVictim( - sender, - "msg.sender was not set during prank", - origin, - "tx.origin was not set during prank" + sender, "msg.sender was not set during prank", origin, "tx.origin was not set during prank" ); new ConstructorVictim( sender, diff --git a/testdata/cheats/RecordAccountAccesses.t.sol b/testdata/cheats/RecordAccountAccesses.t.sol index 9f818e8eed8f6..e27c2dd0c5f1c 100644 --- a/testdata/cheats/RecordAccountAccesses.t.sol +++ b/testdata/cheats/RecordAccountAccesses.t.sol @@ -315,7 +315,7 @@ contract RecordAccountAccessesTest is DSTest { (succ,) = address(123469).call("hello world"); (succ,) = address(5678).call(""); // contract calls to self in constructor - SelfCaller caller = new SelfCaller{value: 2 ether}('hello2 world2'); + SelfCaller caller = new SelfCaller{value: 2 ether}("hello2 world2"); Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); assertEq(called.length, 6); @@ -1011,8 +1011,8 @@ contract RecordAccountAccessesTest is DSTest { function testSelfDestruct() public { uint256 startingBalance = address(this).balance; this.startRecordingFromLowerDepth(); - address a = address(new SelfDestructor{value:1 ether}(address(this))); - address b = address(new SelfDestructor{value:1 ether}(address(bytes20("doesn't exist yet")))); + address a = address(new SelfDestructor{value: 1 ether}(address(this))); + address b = address(new SelfDestructor{value: 1 ether}(address(bytes20("doesn't exist yet")))); Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); assertEq(called.length, 5, "incorrect length"); assertEq( From d6d8de9d7d1cb1e2e5581c05933d086a7178f84d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 24 Nov 2023 14:00:01 +0100 Subject: [PATCH 0326/1963] test: pin rpc test to block (#6420) --- testdata/cheats/Fork2.t.sol | 3 ++- testdata/fixtures/Rpc/balance_params.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/testdata/cheats/Fork2.t.sol b/testdata/cheats/Fork2.t.sol index 382cb1b915962..b3c1008b7b73f 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/cheats/Fork2.t.sol @@ -221,11 +221,12 @@ contract ForkTest is DSTest { } function testRpc() public { + // balance at block vm.selectFork(mainnetFork); string memory path = "fixtures/Rpc/balance_params.json"; string memory file = vm.readFile(path); bytes memory result = vm.rpc("eth_getBalance", file); - assertEq(result, hex"10b7c11bcb51e6"); + assertEq(hex"10b7c11bcb51e6", result); } } diff --git a/testdata/fixtures/Rpc/balance_params.json b/testdata/fixtures/Rpc/balance_params.json index 740491452728d..5004108761fbc 100644 --- a/testdata/fixtures/Rpc/balance_params.json +++ b/testdata/fixtures/Rpc/balance_params.json @@ -1 +1 @@ -["0x8D97689C9818892B700e27F316cc3E41e17fBeb9", "latest"] \ No newline at end of file +["0x8D97689C9818892B700e27F316cc3E41e17fBeb9", "0x117BC09"] \ No newline at end of file From 66967be47110e7b5c5e610cdb96c6cdde4642917 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 24 Nov 2023 16:00:36 +0100 Subject: [PATCH 0327/1963] feat: add hex underscore fmt rule (#6417) * feat: add hex underscore fmt rule * make hex underscore remove the default --- crates/config/src/fmt.rs | 59 ++++++++++++++++++- crates/fmt/src/formatter.rs | 38 ++++++++++-- .../fmt/testdata/HexUnderscore/bytes.fmt.sol | 10 ++++ crates/fmt/testdata/HexUnderscore/fmt.sol | 9 +++ .../fmt/testdata/HexUnderscore/original.sol | 9 +++ .../testdata/HexUnderscore/preserve.fmt.sol | 10 ++++ .../fmt/testdata/HexUnderscore/remove.fmt.sol | 10 ++++ .../NumberLiteralUnderscore/preserve.fmt.sol | 26 ++++++++ crates/fmt/tests/formatter.rs | 1 + 9 files changed, 165 insertions(+), 7 deletions(-) create mode 100644 crates/fmt/testdata/HexUnderscore/bytes.fmt.sol create mode 100644 crates/fmt/testdata/HexUnderscore/fmt.sol create mode 100644 crates/fmt/testdata/HexUnderscore/original.sol create mode 100644 crates/fmt/testdata/HexUnderscore/preserve.fmt.sol create mode 100644 crates/fmt/testdata/HexUnderscore/remove.fmt.sol create mode 100644 crates/fmt/testdata/NumberLiteralUnderscore/preserve.fmt.sol diff --git a/crates/config/src/fmt.rs b/crates/config/src/fmt.rs index 54fa65ed5ba10..86d31833042ef 100644 --- a/crates/config/src/fmt.rs +++ b/crates/config/src/fmt.rs @@ -19,6 +19,8 @@ pub struct FormatterConfig { pub quote_style: QuoteStyle, /// Style of underscores in number literals pub number_underscore: NumberUnderscore, + /// Style of underscores in hex literals + pub hex_underscore: HexUnderscore, /// Style of single line blocks in statements pub single_line_statement_blocks: SingleLineBlockStyle, /// Print space in state variable, function and modifier `override` attribute @@ -44,16 +46,70 @@ pub enum IntTypes { } /// Style of underscores in number literals -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum NumberUnderscore { + /// Use the underscores defined in the source code + #[default] + Preserve, /// Remove all underscores Remove, /// Add an underscore every thousand, if greater than 9999 /// e.g. 1000 -> 1000 and 10000 -> 10_000 Thousands, +} + +impl NumberUnderscore { + /// Returns true if the option is `Preserve` + #[inline] + pub fn is_preserve(self) -> bool { + matches!(self, NumberUnderscore::Preserve) + } + + /// Returns true if the option is `Remove` + #[inline] + pub fn is_remove(self) -> bool { + matches!(self, NumberUnderscore::Remove) + } + + /// Returns true if the option is `Remove` + #[inline] + pub fn is_thousands(self) -> bool { + matches!(self, NumberUnderscore::Thousands) + } +} + +/// Style of underscores in hex literals +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum HexUnderscore { /// Use the underscores defined in the source code Preserve, + /// Remove all underscores + #[default] + Remove, + /// Add underscore as separator between byte boundaries + Bytes, +} + +impl HexUnderscore { + /// Returns true if the option is `Preserve` + #[inline] + pub fn is_preserve(self) -> bool { + matches!(self, HexUnderscore::Preserve) + } + + /// Returns true if the option is `Remove` + #[inline] + pub fn is_remove(self) -> bool { + matches!(self, HexUnderscore::Remove) + } + + /// Returns true if the option is `Remove` + #[inline] + pub fn is_bytes(self) -> bool { + matches!(self, HexUnderscore::Bytes) + } } /// Style of string quotes @@ -114,6 +170,7 @@ impl Default for FormatterConfig { multiline_func_header: MultilineFuncHeaderStyle::AttributesFirst, quote_style: QuoteStyle::Double, number_underscore: NumberUnderscore::Preserve, + hex_underscore: HexUnderscore::Remove, single_line_statement_blocks: SingleLineBlockStyle::Preserve, override_spacing: false, wrap_comments: false, diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 4e2d3296802a6..b62ed81362337 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -11,10 +11,10 @@ use crate::{ solang_ext::{pt::*, *}, string::{QuoteState, QuotedStringExt}, visit::{Visitable, Visitor}, - FormatterConfig, InlineConfig, IntTypes, NumberUnderscore, + FormatterConfig, InlineConfig, IntTypes, }; use alloy_primitives::Address; -use foundry_config::fmt::{MultilineFuncHeaderStyle, SingleLineBlockStyle}; +use foundry_config::fmt::{HexUnderscore, MultilineFuncHeaderStyle, SingleLineBlockStyle}; use itertools::{Either, Itertools}; use solang_parser::pt::ImportPath; use std::{fmt::Write, str::FromStr}; @@ -1304,7 +1304,7 @@ impl<'a, W: Write> Formatter<'a, W> { let config = self.config.number_underscore; // get source if we preserve underscores - let (value, fractional, exponent) = if matches!(config, NumberUnderscore::Preserve) { + let (value, fractional, exponent) = if config.is_preserve() { let source = &self.source[loc.start()..loc.end()]; // Strip unit let (source, _) = source.split_once(' ').unwrap_or((source, "")); @@ -1336,7 +1336,7 @@ impl<'a, W: Write> Formatter<'a, W> { exp = exp.trim().trim_start_matches('0'); let add_underscores = |string: &str, reversed: bool| -> String { - if !matches!(config, NumberUnderscore::Thousands) || string.len() < 5 { + if !config.is_thousands() || string.len() < 5 { return string.to_string() } if reversed { @@ -1377,6 +1377,32 @@ impl<'a, W: Write> Formatter<'a, W> { self.write_unit(unit) } + /// Write and hex literals according to the configuration. + fn write_hex_literal(&mut self, lit: &HexLiteral) -> Result<()> { + let HexLiteral { loc, hex } = lit; + match self.config.hex_underscore { + HexUnderscore::Remove => self.write_quoted_str(*loc, Some("hex"), hex), + HexUnderscore::Preserve => { + let quote = &self.source[loc.start()..loc.end()].trim_start_matches("hex"); + // source is always quoted so we remove the quotes first so we can adhere to the + // configured quoting style + let hex = "e[1..quote.len() - 1]; + self.write_quoted_str(*loc, Some("hex"), hex) + } + HexUnderscore::Bytes => { + // split all bytes + let hex = hex + .chars() + .chunks(2) + .into_iter() + .map(|chunk| chunk.collect::()) + .collect::>() + .join("_"); + self.write_quoted_str(*loc, Some("hex"), &hex) + } + } + } + /// Write built-in unit. fn write_unit(&mut self, unit: &mut Option) -> Result<()> { if let Some(unit) = unit { @@ -2061,8 +2087,8 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { } } Expression::HexLiteral(vals) => { - for HexLiteral { loc, hex } in vals { - self.write_quoted_str(*loc, Some("hex"), hex)?; + for val in vals { + self.write_hex_literal(val)?; } } Expression::AddressLiteral(loc, val) => { diff --git a/crates/fmt/testdata/HexUnderscore/bytes.fmt.sol b/crates/fmt/testdata/HexUnderscore/bytes.fmt.sol new file mode 100644 index 0000000000000..b3be2a8657c18 --- /dev/null +++ b/crates/fmt/testdata/HexUnderscore/bytes.fmt.sol @@ -0,0 +1,10 @@ +// config: hex_underscore = "bytes" +contract HexLiteral { + function test() external { + hex"01_23_00_00"; + hex"01_23_00_00"; + hex"01_23_00_00"; + hex""; + hex"60_01_60_02_53"; + } +} diff --git a/crates/fmt/testdata/HexUnderscore/fmt.sol b/crates/fmt/testdata/HexUnderscore/fmt.sol new file mode 100644 index 0000000000000..0c8710a924758 --- /dev/null +++ b/crates/fmt/testdata/HexUnderscore/fmt.sol @@ -0,0 +1,9 @@ +contract HexLiteral { + function test() external { + hex"01230000"; + hex"01230000"; + hex"01230000"; + hex""; + hex"6001600253"; + } +} diff --git a/crates/fmt/testdata/HexUnderscore/original.sol b/crates/fmt/testdata/HexUnderscore/original.sol new file mode 100644 index 0000000000000..5c29187475489 --- /dev/null +++ b/crates/fmt/testdata/HexUnderscore/original.sol @@ -0,0 +1,9 @@ +contract HexLiteral { + function test() external { + hex"0123_0000"; + hex"01230000"; + hex"0123_00_00"; + hex""; + hex"6001_6002_53"; + } +} \ No newline at end of file diff --git a/crates/fmt/testdata/HexUnderscore/preserve.fmt.sol b/crates/fmt/testdata/HexUnderscore/preserve.fmt.sol new file mode 100644 index 0000000000000..0f5db52e3c3f3 --- /dev/null +++ b/crates/fmt/testdata/HexUnderscore/preserve.fmt.sol @@ -0,0 +1,10 @@ +// config: hex_underscore = "preserve" +contract HexLiteral { + function test() external { + hex"0123_0000"; + hex"01230000"; + hex"0123_00_00"; + hex""; + hex"6001_6002_53"; + } +} diff --git a/crates/fmt/testdata/HexUnderscore/remove.fmt.sol b/crates/fmt/testdata/HexUnderscore/remove.fmt.sol new file mode 100644 index 0000000000000..39aae1465cf7d --- /dev/null +++ b/crates/fmt/testdata/HexUnderscore/remove.fmt.sol @@ -0,0 +1,10 @@ +// config: hex_underscore = "remove" +contract HexLiteral { + function test() external { + hex"01230000"; + hex"01230000"; + hex"01230000"; + hex""; + hex"6001600253"; + } +} diff --git a/crates/fmt/testdata/NumberLiteralUnderscore/preserve.fmt.sol b/crates/fmt/testdata/NumberLiteralUnderscore/preserve.fmt.sol new file mode 100644 index 0000000000000..d87dc99d9653d --- /dev/null +++ b/crates/fmt/testdata/NumberLiteralUnderscore/preserve.fmt.sol @@ -0,0 +1,26 @@ +// config: number_underscore = "preserve" +contract NumberLiteral { + function test() external { + 1; + 123_000; + 1_2e345_678; + -1; + 2e-10; + 0.1; + 1.3; + 2.5e1; + 1.23454; + 1.2e34_5_678; + 134411.2e34_5_678; + 13431.134112e34_135_678; + 13431.0134112; + 13431.134112e-139_3141340; + 134411.2e34_5_6780; + 13431.134112e34_135_6780; + 0.134112; + 1.0; + 13431.134112e-139_3141340; + 123e456; + 1_000; + } +} diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 7aaed58e5fb83..5ef7154cd047f 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -193,6 +193,7 @@ test_directories! { IntTypes, InlineDisable, NumberLiteralUnderscore, + HexUnderscore, FunctionCall, TrailingComma, PragmaDirective, From 7842f323475b6bb7ca7c894d40e02c1e7ef25940 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 24 Nov 2023 18:57:06 +0100 Subject: [PATCH 0328/1963] chore: set hardfork explicitily for deposit tests (#6422) --- crates/anvil/tests/it/optimism.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 5432a487fe268..23a9e83e8b805 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -1,5 +1,5 @@ //! tests for OP chain support -use anvil::{spawn, NodeConfig}; +use anvil::{spawn, Hardfork, NodeConfig}; use ethers::{ abi::Address, providers::Middleware, @@ -50,7 +50,8 @@ async fn test_deposits_not_supported_if_optimism_disabled() { #[tokio::test(flavor = "multi_thread")] async fn test_send_value_deposit_transaction() { // enable the Optimism flag - let (api, handle) = spawn(NodeConfig::test().with_optimism(true)).await; + let (api, handle) = + spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; let provider = handle.http_provider(); let send_value: U256 = "1234".parse().unwrap(); @@ -91,7 +92,8 @@ async fn test_send_value_deposit_transaction() { #[tokio::test(flavor = "multi_thread")] async fn test_send_value_raw_deposit_transaction() { // enable the Optimism flag - let (api, handle) = spawn(NodeConfig::test().with_optimism(true)).await; + let (api, handle) = + spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; let provider = handle.http_provider(); let send_value: U256 = "1234".parse().unwrap(); From 970313bc973318294dd0af98e7f859684c6bf492 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 24 Nov 2023 14:22:22 -0400 Subject: [PATCH 0329/1963] chore: actually set remove as default (#6423) --- crates/config/src/fmt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/src/fmt.rs b/crates/config/src/fmt.rs index 86d31833042ef..09e8098f0f954 100644 --- a/crates/config/src/fmt.rs +++ b/crates/config/src/fmt.rs @@ -50,9 +50,9 @@ pub enum IntTypes { #[serde(rename_all = "snake_case")] pub enum NumberUnderscore { /// Use the underscores defined in the source code - #[default] Preserve, /// Remove all underscores + #[default] Remove, /// Add an underscore every thousand, if greater than 9999 /// e.g. 1000 -> 1000 and 10000 -> 10_000 From 890bc7a03fd575fbfaf02a8870241f34760e65f1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 Nov 2023 19:22:42 +0100 Subject: [PATCH 0330/1963] chore(deps): bump, unpatch Alloy (#6416) * chore(deps): bump, unpatch Alloy * fix * chore: clippy * anvil test tracing --- Cargo.lock | 142 +++++++++++++++++------------- Cargo.toml | 50 +++++------ crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/util.rs | 1 + crates/anvil/src/lib.rs | 9 +- crates/anvil/tests/it/optimism.rs | 19 ++-- crates/common/src/compile.rs | 17 ++-- crates/forge/bin/cmd/inspect.rs | 6 +- crates/forge/bin/cmd/selectors.rs | 4 +- 9 files changed, 132 insertions(+), 118 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 797bca799a0b0..459c52bbd2496 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,8 +89,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9fe14fb6dded4be3f44d053e59402a405bb231561e36a88bc2283a9829d81fe" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -109,8 +110,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cbbc8fcae58f39dbfbdc94ead48de0779910528889aebc074aed75959bffe7" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -120,8 +122,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5def4b5e1bb8fe7ea37eeac1063246d4ef26f56cbdccf864a5a6bdcb80e91f4" dependencies = [ "alloy-rlp", "arbitrary", @@ -167,8 +170,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0acd5b8d2699b095a57a0ecea6a6a2045b8e5ed6f2607bfa3382961d2889e82" dependencies = [ "alloy-json-abi", "const-hex", @@ -186,16 +190,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc77699fb68c8a2cf18efb2c51df43e09b42b53886c6eb552951b19c41ebfc84" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d483e9c6db659cdb24fc736684ef68b743705fbdb0677c6404815361871b92" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -1653,9 +1659,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "der" @@ -1863,9 +1869,9 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.7" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9775b22bc152ad86a0cf23f0f348b884b26add12bf741e7ffc4d4ab2ab4d205" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -2075,7 +2081,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2090,7 +2096,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "ethers-core", "once_cell", @@ -2101,7 +2107,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2119,7 +2125,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "Inflector", "const-hex", @@ -2142,7 +2148,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "Inflector", "const-hex", @@ -2157,7 +2163,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "arrayvec", "bytes", @@ -2186,7 +2192,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "chrono", "ethers-core", @@ -2201,7 +2207,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "async-trait", "auto_impl", @@ -2226,7 +2232,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "async-trait", "auto_impl", @@ -2264,7 +2270,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "async-trait", "coins-bip32", @@ -2292,7 +2298,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=546ea029362a7502365667c6f99fac92ad0aeb9f#546ea029362a7502365667c6f99fac92ad0aeb9f" +source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" dependencies = [ "cfg-if", "const-hex", @@ -2611,17 +2617,18 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "foundry-block-explorers" -version = "0.1.0" -source = "git+https://github.com/foundry-rs/block-explorers#714c1537cf09d9a96293aadc633166c97d19da95" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47331ff0955a60df66db753f5dcfe3ca0275abe192e58c9eb6d0d8c1a131e604" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -2756,9 +2763,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcfb3af0dd69f2989ab2311f2c97fdd470227d3c9f657be04092572a3a1db60" +checksum = "1eec9fd9df7ad0509ae45e2ea8a595cf13b1f35d69980e985b3be00ffabcc01a" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -2771,6 +2778,7 @@ dependencies = [ "glob", "home", "md-5 0.10.6", + "memmap2 0.9.0", "num_cpus", "once_cell", "path-slash", @@ -3197,9 +3205,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "git2" @@ -3376,7 +3384,7 @@ dependencies = [ "gix-path", "gix-tempfile", "gix-validate", - "memmap2", + "memmap2 0.5.10", "nom", "thiserror", ] @@ -3774,9 +3782,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -4208,9 +4216,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60" +checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" dependencies = [ "hashbrown 0.14.2", ] @@ -4326,6 +4334,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.7.1" @@ -4719,9 +4736,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.59" +version = "0.10.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" +checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -4751,9 +4768,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.95" +version = "0.9.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" dependencies = [ "cc", "libc", @@ -4961,9 +4978,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" @@ -5681,7 +5698,7 @@ dependencies = [ [[package]] name = "revm" version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" dependencies = [ "auto_impl", "revm-interpreter", @@ -5693,7 +5710,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" dependencies = [ "revm-primitives", "serde", @@ -5702,7 +5719,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -5718,7 +5735,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?rev=1609e07c68048909ad1682c98cf2b9baa76310b5#1609e07c68048909ad1682c98cf2b9baa76310b5" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -5985,9 +6002,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.24" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", @@ -6297,18 +6314,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -6773,8 +6790,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.4.2" -source = "git+https://github.com/alloy-rs/core/#78a4c55c9781cd4f7f1a3558d047a6c94c9cab88" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e349ed2ca56eff703d7c3ea013771bcbab9ad2ad39dddf863fc51d820329dc41" dependencies = [ "paste", "proc-macro2", @@ -7490,9 +7508,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -7727,9 +7745,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "which" diff --git a/Cargo.toml b/Cargo.toml index 1aee8f58d2ab5..942d29889916d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,10 +123,8 @@ foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } -# block explorer & verification bindings -foundry-block-explorers = { version = "0.1", default-features = false } -# solc & compilation utilities -foundry-compilers = { version = "0.1", default-features = false } +foundry-block-explorers = { version = "0.1.1", default-features = false } +foundry-compilers = { version = "0.1.1", default-features = false } ## revm # no default features to avoid c-kzg @@ -144,11 +142,11 @@ ethers-middleware = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy -alloy-primitives = "0.4.1" -alloy-dyn-abi = "0.4.1" -alloy-json-abi = "0.4.1" -alloy-sol-types = "0.4.1" -syn-solidity = "0.4.1" +alloy-primitives = "0.5.0" +alloy-dyn-abi = "0.5.0" +alloy-json-abi = "0.5.0" +alloy-sol-types = "0.5.0" +syn-solidity = "0.5.0" alloy-chains = "0.1.3" alloy-rlp = "0.3.3" @@ -189,24 +187,16 @@ tower-http = "0.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" } - -foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers" } - -alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" } -alloy-json-abi = { git = "https://github.com/alloy-rs/core/" } -alloy-primitives = { git = "https://github.com/alloy-rs/core/" } -alloy-sol-macro = { git = "https://github.com/alloy-rs/core/" } -alloy-sol-types = { git = "https://github.com/alloy-rs/core/" } -alloy-sol-type-parser = { git = "https://github.com/alloy-rs/core/" } -syn-solidity = { git = "https://github.com/alloy-rs/core/" } - -revm = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } -revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "1609e07c68048909ad1682c98cf2b9baa76310b5" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } + +revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } +revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } +revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } +revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 2b6f9fad7cbad..27b39aac9575b 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -357,7 +357,7 @@ impl NodeConfig { /// random, free port by setting it to `0` #[doc(hidden)] pub fn test() -> Self { - Self { enable_tracing: false, silent: true, port: 0, ..Default::default() } + Self { enable_tracing: true, silent: true, port: 0, ..Default::default() } } } diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 41f1d23bf4df1..4181df4e8d447 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -81,6 +81,7 @@ pub fn to_precompile_id(spec_id: SpecId) -> revm::precompile::SpecId { SpecId::CANCUN | SpecId::BEDROCK | SpecId::REGOLITH | + SpecId::CANYON | SpecId::LATEST => revm::precompile::SpecId::BERLIN, } } diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 5d612dab8043b..4615f6ca7f28c 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -375,18 +375,17 @@ impl Future for NodeHandle { } } -#[allow(unused)] #[doc(hidden)] pub fn init_tracing() -> LoggingManager { use tracing_subscriber::prelude::*; let manager = LoggingManager::default(); // check whether `RUST_LOG` is explicitly set - if std::env::var("RUST_LOG").is_ok() { + let _ = if std::env::var("RUST_LOG").is_ok() { tracing_subscriber::Registry::default() .with(tracing_subscriber::EnvFilter::from_default_env()) .with(tracing_subscriber::fmt::layer()) - .init(); + .try_init() } else { tracing_subscriber::Registry::default() .with(NodeLogLayer::new(manager.clone())) @@ -396,8 +395,8 @@ pub fn init_tracing() -> LoggingManager { .with_target(false) .with_level(false), ) - .init(); - } + .try_init() + }; manager } diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 23a9e83e8b805..e7ee430bb257f 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -1,4 +1,5 @@ -//! tests for OP chain support +//! Tests for OP chain support. + use anvil::{spawn, Hardfork, NodeConfig}; use ethers::{ abi::Address, @@ -40,7 +41,6 @@ async fn test_deposits_not_supported_if_optimism_disabled() { // sending the deposit transaction should fail with error saying not supported let res = provider.send_transaction(deposit_tx.clone(), None).await; - assert!(res.is_err()); assert!(res .unwrap_err() .to_string() @@ -54,7 +54,7 @@ async fn test_send_value_deposit_transaction() { spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; let provider = handle.http_provider(); - let send_value: U256 = "1234".parse().unwrap(); + let send_value = U256::from(1234); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); @@ -79,7 +79,11 @@ async fn test_send_value_deposit_transaction() { mint: Some(U256::zero()), is_system_tx: true, }); - provider.send_transaction(deposit_tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + + let pending = provider.send_transaction(deposit_tx.clone(), None).await.unwrap(); + let receipt = pending.await.unwrap().expect("dropped"); + assert_eq!(receipt.from, from_addr); + assert_eq!(receipt.to, Some(to_addr)); // mine block api.evm_mine(None).await.unwrap(); @@ -96,7 +100,7 @@ async fn test_send_value_raw_deposit_transaction() { spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; let provider = handle.http_provider(); - let send_value: U256 = "1234".parse().unwrap(); + let send_value = U256::from(1234); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); @@ -123,7 +127,10 @@ async fn test_send_value_raw_deposit_transaction() { }); let rlpbytes = deposit_tx.rlp(); - provider.send_raw_transaction(rlpbytes).await.unwrap().await.unwrap().unwrap(); + let pending = provider.send_raw_transaction(rlpbytes).await.unwrap(); + let receipt = pending.await.unwrap().expect("dropped"); + assert_eq!(receipt.from, from_addr); + assert_eq!(receipt.to, Some(to_addr)); // mine block api.evm_mine(None).await.unwrap(); diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 4362662e9a8f7..749ef15f2388a 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -148,15 +148,14 @@ impl ProjectCompiler { for (name, artifact) in artifacts { let size = deployed_contract_size(artifact).unwrap_or_default(); - let dev_functions = artifact - .abi - .as_ref() - .map(|abi| abi.abi.functions()) - .into_iter() - .flatten() - .filter(|func| { - func.name.is_test() || func.name.eq("IS_TEST") || func.name.eq("IS_SCRIPT") - }); + let dev_functions = + artifact.abi.as_ref().map(|abi| abi.functions()).into_iter().flatten().filter( + |func| { + func.name.is_test() || + func.name.eq("IS_TEST") || + func.name.eq("IS_SCRIPT") + }, + ); let is_dev_contract = dev_functions.count() > 0; size_report.contracts.insert(name, ContractInfo { size, is_dev_contract }); diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 6490cc0901060..5b4c6229ef344 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -89,7 +89,7 @@ impl InspectArgs { .abi .as_ref() .ok_or_else(|| eyre::eyre!("Failed to fetch lossless ABI"))?; - print_abi(&abi.abi, pretty)?; + print_abi(abi, pretty)?; } ContractArtifactField::Bytecode => { let tval: Value = to_value(&artifact.bytecode)?; @@ -165,7 +165,7 @@ impl InspectArgs { ContractArtifactField::Errors => { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { - let abi = &abi.abi; + let abi = &abi; // Print the signature of all errors for er in abi.errors.iter().flat_map(|(_, errors)| errors) { let types = er.inputs.iter().map(|p| p.ty.clone()).collect::>(); @@ -182,7 +182,7 @@ impl InspectArgs { ContractArtifactField::Events => { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { - let abi = &abi.abi; + let abi = &abi; // print the signature of all events including anonymous for ev in abi.events.iter().flat_map(|(_, events)| events) { let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::>(); diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 05b87b7efe71f..4b2d045c9ddfa 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -106,7 +106,7 @@ impl SelectorsSubcommands { let mut artifacts = artifacts.into_iter().peekable(); while let Some((contract, artifact)) = artifacts.next() { - let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?.abi; + let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?; if abi.functions.is_empty() && abi.events.is_empty() && abi.errors.is_empty() { continue } @@ -234,7 +234,7 @@ impl SelectorsSubcommands { let mut artifacts = artifacts.into_iter().peekable(); while let Some((contract, artifact)) = artifacts.next() { - let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?.abi; + let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?; if abi.functions.is_empty() && abi.events.is_empty() && abi.errors.is_empty() { continue } From 64320313edd81795751b8ec61d3cdcb35e419ce9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 26 Nov 2023 15:05:57 +0100 Subject: [PATCH 0331/1963] chore(deps): weekly `cargo update` (#6429) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating hidapi-rusb v1.3.2 -> v1.3.3 Co-authored-by: mattsse --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 459c52bbd2496..98d461f75f6ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3593,9 +3593,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "hidapi-rusb" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee9fc48be9eab25c28b413742b38b57b85c10b5efd2d47ef013f82335cbecc8e" +checksum = "efdc2ec354929a6e8f3c6b6923a4d97427ec2f764cfee8cd4bfe890946cdf08b" dependencies = [ "cc", "libc", From 2aa52efc9e6a27c42b483e3d91b371431e0fb23f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 27 Nov 2023 15:53:21 +0100 Subject: [PATCH 0332/1963] chore: misc stuff (#6439) * don't use eq * refactor repro tests * reorder * tokio * name * fix --- Cargo.lock | 1 + crates/cast/bin/cmd/run.rs | 2 +- crates/common/src/compile.rs | 6 +- crates/doc/src/builder.rs | 6 +- crates/doc/src/parser/comment.rs | 2 +- crates/evm/core/src/backend/mod.rs | 2 +- crates/fmt/src/formatter.rs | 2 +- crates/fmt/src/solang_ext/ast_eq.rs | 2 +- crates/forge/Cargo.toml | 1 + crates/forge/bin/cmd/inspect.rs | 4 +- crates/forge/tests/it/config.rs | 7 +- crates/forge/tests/it/repros.rs | 368 ++++++------------ .../repros/{Issue3221.sol => Issue3221.t.sol} | 0 .../repros/{Issue3223.sol => Issue3223.t.sol} | 0 .../repros/{Issue3347.sol => Issue3347.t.sol} | 0 .../repros/{Issue3661.sol => Issue3661.t.sol} | 0 .../repros/{Issue3708.sol => Issue3708.t.sol} | 0 .../repros/{Issue6180.sol => Issue6180.t.sol} | 0 18 files changed, 135 insertions(+), 268 deletions(-) rename testdata/repros/{Issue3221.sol => Issue3221.t.sol} (100%) rename testdata/repros/{Issue3223.sol => Issue3223.t.sol} (100%) rename testdata/repros/{Issue3347.sol => Issue3347.t.sol} (100%) rename testdata/repros/{Issue3661.sol => Issue3661.t.sol} (100%) rename testdata/repros/{Issue3708.sol => Issue3708.t.sol} (100%) rename testdata/repros/{Issue6180.sol => Issue6180.t.sol} (100%) diff --git a/Cargo.lock b/Cargo.lock index 98d461f75f6ce..61789333a6d28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2550,6 +2550,7 @@ dependencies = [ "once_cell", "opener", "parking_lot", + "paste", "path-slash", "pretty_assertions", "proptest", diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 2f6fcbd95d91a..12237a6d6d952 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -150,7 +150,7 @@ impl RunArgs { update_progress!(pb, index); continue } - if tx.hash.eq(&tx_hash) { + if tx.hash == tx_hash { break } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 749ef15f2388a..873ece4349ea3 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -150,10 +150,10 @@ impl ProjectCompiler { let dev_functions = artifact.abi.as_ref().map(|abi| abi.functions()).into_iter().flatten().filter( - |func| { + |&func| { func.name.is_test() || - func.name.eq("IS_TEST") || - func.name.eq("IS_SCRIPT") + func.name == "IS_TEST" || + func.name == "IS_SCRIPT" }, ); diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index ddee58bddf972..692e69b82e1dd 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -408,8 +408,8 @@ impl DocBuilder { } // Sort entries by path depth let grouped = grouped.into_iter().sorted_by(|(lhs, _), (rhs, _)| { - let lhs_at_end = lhs.extension().map(|ext| ext.eq(Self::SOL_EXT)).unwrap_or_default(); - let rhs_at_end = rhs.extension().map(|ext| ext.eq(Self::SOL_EXT)).unwrap_or_default(); + let lhs_at_end = lhs.extension().map(|ext| ext == Self::SOL_EXT).unwrap_or_default(); + let rhs_at_end = rhs.extension().map(|ext| ext == Self::SOL_EXT).unwrap_or_default(); if lhs_at_end == rhs_at_end { lhs.cmp(rhs) } else if lhs_at_end { @@ -421,7 +421,7 @@ impl DocBuilder { let mut readme = BufWriter::new("\n\n# Contents\n"); for (path, files) in grouped { - if path.extension().map(|ext| ext.eq(Self::SOL_EXT)).unwrap_or_default() { + if path.extension().map(|ext| ext == Self::SOL_EXT).unwrap_or_default() { for file in files { let ident = &file.identity; diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index 667d1aca6d46b..ca06b468ce6bb 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -87,7 +87,7 @@ impl Comment { pub fn match_first_word(&self, expected: &str) -> Option<&str> { self.split_first_word().and_then( |(word, rest)| { - if word.eq(expected) { + if word == expected { Some(rest) } else { None diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 3a2d8a5f4a638..6de59965e969c 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -873,7 +873,7 @@ impl Backend { continue } - if tx.hash.eq(&tx_hash.to_ethers()) { + if tx.hash == tx_hash.to_ethers() { // found the target transaction return Ok(Some(tx)) } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index b62ed81362337..02cf851697fe4 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -315,7 +315,7 @@ impl<'a, W: Write> Formatter<'a, W> { first_char == ch && state == CommentState::None && idx + needle.len() <= subset.len() && - subset[idx..idx + needle.len()].eq(needle) + subset[idx..idx + needle.len()] == *needle }) .map(|p| byte_offset + p) }) diff --git a/crates/fmt/src/solang_ext/ast_eq.rs b/crates/fmt/src/solang_ext/ast_eq.rs index f29a7cc026831..e31fc2b410139 100644 --- a/crates/fmt/src/solang_ext/ast_eq.rs +++ b/crates/fmt/src/solang_ext/ast_eq.rs @@ -148,7 +148,7 @@ where impl AstEq for String { fn ast_eq(&self, other: &Self) -> bool { match (Address::from_str(self), Address::from_str(other)) { - (Ok(left), Ok(right)) => left.eq(&right), + (Ok(left), Ok(right)) => left == right, _ => self == other, } } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index c92778c16a6d8..c6d1625bcf3a8 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -84,6 +84,7 @@ foundry-test-utils.workspace = true criterion = "0.5" globset = "0.4" +paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true serial_test = "2" diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 5b4c6229ef344..f1c4e09035053 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -45,7 +45,7 @@ impl InspectArgs { // Map field to ContractOutputSelection let mut cos = build.compiler.extra_output; - if !field.is_default() && !cos.iter().any(|selected| field.eq(selected)) { + if !field.is_default() && !cos.iter().any(|selected| field == *selected) { cos.push(field.into()); } @@ -165,7 +165,6 @@ impl InspectArgs { ContractArtifactField::Errors => { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { - let abi = &abi; // Print the signature of all errors for er in abi.errors.iter().flat_map(|(_, errors)| errors) { let types = er.inputs.iter().map(|p| p.ty.clone()).collect::>(); @@ -182,7 +181,6 @@ impl InspectArgs { ContractArtifactField::Events => { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { - let abi = &abi; // print the signature of all events including anonymous for ev in abi.events.iter().flat_map(|(_, events)| events) { let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::>(); diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index a9809a951f5d8..1ab7f0e318822 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -67,7 +67,7 @@ impl TestConfig { /// * filter matched 0 test cases /// * a test results deviates from the configured `should_fail` setting pub async fn try_run(&mut self) -> eyre::Result<()> { - let suite_result = self.runner.test(&self.filter, None, self.opts.clone()).await; + let suite_result = self.test().await; if suite_result.is_empty() { eyre::bail!("empty test result"); } @@ -259,8 +259,9 @@ pub fn assert_multiple( } if let Some(expected_logs) = expected_logs { - assert!( - logs.iter().eq(expected_logs.iter()), + assert_eq!( + logs, + expected_logs, "Logs did not match for test {}.\nExpected:\n{}\n\nGot:\n{}", test_name, expected_logs.join("\n"), diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 2fbc01a6b72a8..228fc27cb994d 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -1,188 +1,103 @@ -//! Tests for reproducing issues +//! Regression tests for previous issues. use crate::{config::*, test_helpers::PROJECT}; -use alloy_primitives::Address; +use alloy_primitives::{address, Address}; use ethers_core::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; use forge::result::TestStatus; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_test_utils::Filter; -use std::str::FromStr; -/// A macro that tests a single pattern (".*/repros/") +/// Creates a test that runs `testdata/repros/Issue{issue}.t.sol`. macro_rules! test_repro { - ($issue:expr) => { - test_repro!($issue, false, None) + ($issue_number:literal $(,)?) => { + test_repro!($issue_number, false, None); }; - ($issue:expr, $should_fail:expr, $sender:expr) => { - let pattern = concat!(".*repros/", $issue); - let filter = Filter::path(pattern); - - let mut config = Config::with_root(PROJECT.root()); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - if let Some(sender) = $sender { - config.sender = sender; + ($issue_number:literal, $should_fail:expr $(,)?) => { + test_repro!($issue_number, $should_fail, None); + }; + ($issue_number:literal, $should_fail:expr, $sender:expr $(,)?) => { + paste::paste! { + #[tokio::test(flavor = "multi_thread")] + async fn [< issue_ $issue_number >]() { + repro_config($issue_number, $should_fail, $sender.into()).await.run().await; + } } - - let mut config = TestConfig::with_filter(runner_with_config(config).await, filter) - .set_should_fail($should_fail); - config.run().await; }; -} - -macro_rules! test_repro_fail { - ($issue:expr) => { - test_repro!($issue, true, None) + ($issue_number:literal, $should_fail:expr, $sender:expr, |$res:ident| $e:expr $(,)?) => { + paste::paste! { + #[tokio::test(flavor = "multi_thread")] + async fn [< issue_ $issue_number >]() { + let mut $res = repro_config($issue_number, $should_fail, $sender.into()).await.test().await; + $e + } + } }; } -macro_rules! test_repro_with_sender { - ($issue:expr, $sender:expr) => { - test_repro!($issue, false, Some($sender)) - }; -} +async fn repro_config(issue: usize, should_fail: bool, sender: Option
) -> TestConfig { + let filter = Filter::path(&format!(".*repros/Issue{issue}.t.sol")); -macro_rules! run_test_repro { - ($issue:expr) => { - run_test_repro!($issue, false, None) - }; - ($issue:expr, $should_fail:expr, $sender:expr) => {{ - let pattern = concat!(".*repros/", $issue); - let filter = Filter::path(pattern); + let mut config = Config::with_root(PROJECT.root()); + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + if let Some(sender) = sender { + config.sender = sender; + } - let mut config = Config::default(); - if let Some(sender) = $sender { - config.sender = sender; - } - - let mut config = TestConfig::with_filter(runner_with_config(config).await, filter) - .set_should_fail($should_fail); - config.test().await - }}; + let runner = runner_with_config(config).await; + TestConfig::with_filter(runner, filter).set_should_fail(should_fail) } -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_2623() { - test_repro!("Issue2623"); -} +// https://github.com/foundry-rs/foundry/issues/2623 +test_repro!(2623); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_2629() { - test_repro!("Issue2629"); -} +// https://github.com/foundry-rs/foundry/issues/2629 +test_repro!(2629); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_2723() { - test_repro!("Issue2723"); -} +// https://github.com/foundry-rs/foundry/issues/2723 +test_repro!(2723); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_2898() { - test_repro!("Issue2898"); -} +// https://github.com/foundry-rs/foundry/issues/2898 +test_repro!(2898); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_2956() { - test_repro!("Issue2956"); -} +// https://github.com/foundry-rs/foundry/issues/2956 +test_repro!(2956); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_2984() { - test_repro!("Issue2984"); -} +// https://github.com/foundry-rs/foundry/issues/2984 +test_repro!(2984); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_4640() { - test_repro!("Issue4640"); -} +// https://github.com/foundry-rs/foundry/issues/3055 +test_repro!(3055, true); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3077() { - test_repro!("Issue3077"); -} +// https://github.com/foundry-rs/foundry/issues/3077 +test_repro!(3077); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3055() { - test_repro_fail!("Issue3055"); -} +// https://github.com/foundry-rs/foundry/issues/3110 +test_repro!(3110); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3192() { - test_repro!("Issue3192"); -} +// https://github.com/foundry-rs/foundry/issues/3119 +test_repro!(3119); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3110() { - test_repro!("Issue3110"); -} +// https://github.com/foundry-rs/foundry/issues/3189 +test_repro!(3189, true); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3189() { - test_repro_fail!("Issue3189"); -} +// https://github.com/foundry-rs/foundry/issues/3190 +test_repro!(3190); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3119() { - test_repro!("Issue3119"); -} +// https://github.com/foundry-rs/foundry/issues/3192 +test_repro!(3192); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3190() { - test_repro!("Issue3190"); -} +// https://github.com/foundry-rs/foundry/issues/3220 +test_repro!(3220); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3221() { - test_repro!("Issue3221"); -} +// https://github.com/foundry-rs/foundry/issues/3221 +test_repro!(3221); -// -// 1.0 related -// #[tokio::test(flavor = "multi_thread")] -// async fn test_issue_3437() { -// test_repro!("Issue3437"); -// } - -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3708() { - test_repro!("Issue3708"); -} +// https://github.com/foundry-rs/foundry/issues/3223 +test_repro!(3223, false, address!("F0959944122fb1ed4CfaBA645eA06EED30427BAA")); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3223() { - test_repro_with_sender!( - "Issue3223", - Address::from_str("0xF0959944122fb1ed4CfaBA645eA06EED30427BAA").unwrap() - ); -} - -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3220() { - test_repro!("Issue3220"); -} - -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3347() { - let mut res = run_test_repro!("Issue3347"); - let mut res = res.remove("repros/Issue3347.sol:Issue3347Test").unwrap(); +// https://github.com/foundry-rs/foundry/issues/3347 +test_repro!(3347, false, None, |res| { + let mut res = res.remove("repros/Issue3347.t.sol:Issue3347Test").unwrap(); let test = res.test_results.remove("test()").unwrap(); assert_eq!(test.logs.len(), 1); let event = Event { @@ -205,127 +120,78 @@ async fn test_issue_3347() { ] } ); -} +}); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3685() { - test_repro!("Issue3685"); -} +// https://github.com/foundry-rs/foundry/issues/3437 +// 1.0 related +// test_repro!(3437); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3653() { - test_repro!("Issue3653"); -} +// https://github.com/foundry-rs/foundry/issues/3596 +test_repro!(3596, true, None); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3596() { - test_repro!("Issue3596", true, None); -} +// https://github.com/foundry-rs/foundry/issues/3653 +test_repro!(3653); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3661() { - test_repro!("Issue3661"); -} +// https://github.com/foundry-rs/foundry/issues/3661 +test_repro!(3661); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3674() { - test_repro_with_sender!( - "Issue3674", - Address::from_str("0xF0959944122fb1ed4CfaBA645eA06EED30427BAA").unwrap() - ); -} +// https://github.com/foundry-rs/foundry/issues/3674 +test_repro!(3674, false, address!("F0959944122fb1ed4CfaBA645eA06EED30427BAA")); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3703() { - test_repro!("Issue3703"); -} +// https://github.com/foundry-rs/foundry/issues/3685 +test_repro!(3685); + +// https://github.com/foundry-rs/foundry/issues/3703 +test_repro!(3703); + +// https://github.com/foundry-rs/foundry/issues/3708 +test_repro!(3708); -// +// https://github.com/foundry-rs/foundry/issues/3723 // 1.0 related -// #[tokio::test(flavor = "multi_thread")] -// async fn test_issue_3723() { -// test_repro!("Issue3723"); -// } - -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3753() { - test_repro!("Issue3753"); -} +// test_repro!(3723); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_4630() { - test_repro!("Issue4630"); -} +// https://github.com/foundry-rs/foundry/issues/3753 +test_repro!(3753); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_4586() { - test_repro!("Issue4586"); -} +// https://github.com/foundry-rs/foundry/issues/3792 +test_repro!(3792); + +// https://github.com/foundry-rs/foundry/issues/4586 +test_repro!(4586); + +// https://github.com/foundry-rs/foundry/issues/4630 +test_repro!(4630); + +// https://github.com/foundry-rs/foundry/issues/4640 +test_repro!(4640); // https://github.com/foundry-rs/foundry/issues/4832 // 1.0 related -// #[tokio::test(flavor = "multi_thread")] -// async fn test_issue_4832() { -// test_repro!("Issue4832"); -// } - -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_5038() { - test_repro!("Issue5038"); -} +// test_repro!(4832); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_3792() { - test_repro!("Issue3792"); -} +// https://github.com/foundry-rs/foundry/issues/5038 +test_repro!(5038); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_6006() { - test_repro!("Issue6006"); -} +// https://github.com/foundry-rs/foundry/issues/5808 +test_repro!(5808); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_5808() { - test_repro!("Issue5808"); -} +// https://github.com/foundry-rs/foundry/issues/6006 +test_repro!(6006); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_6070() { - test_repro!("Issue6070"); -} +// https://github.com/foundry-rs/foundry/issues/6070 +test_repro!(6070); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_6115() { - test_repro!("Issue6115"); -} +// https://github.com/foundry-rs/foundry/issues/6115 +test_repro!(6115); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_6170() { - let mut res = run_test_repro!("Issue6170"); +// https://github.com/foundry-rs/foundry/issues/6170 +test_repro!(6170, false, None, |res| { let mut res = res.remove("repros/Issue6170.t.sol:Issue6170Test").unwrap(); let test = res.test_results.remove("test()").unwrap(); assert_eq!(test.status, TestStatus::Failure); assert_eq!(test.reason, Some("log != expected log".to_string())); -} +}); -// -#[tokio::test(flavor = "multi_thread")] -async fn test_issue_6180() { - test_repro!("Issue6180"); -} +// https://github.com/foundry-rs/foundry/issues/6180 +test_repro!(6180); diff --git a/testdata/repros/Issue3221.sol b/testdata/repros/Issue3221.t.sol similarity index 100% rename from testdata/repros/Issue3221.sol rename to testdata/repros/Issue3221.t.sol diff --git a/testdata/repros/Issue3223.sol b/testdata/repros/Issue3223.t.sol similarity index 100% rename from testdata/repros/Issue3223.sol rename to testdata/repros/Issue3223.t.sol diff --git a/testdata/repros/Issue3347.sol b/testdata/repros/Issue3347.t.sol similarity index 100% rename from testdata/repros/Issue3347.sol rename to testdata/repros/Issue3347.t.sol diff --git a/testdata/repros/Issue3661.sol b/testdata/repros/Issue3661.t.sol similarity index 100% rename from testdata/repros/Issue3661.sol rename to testdata/repros/Issue3661.t.sol diff --git a/testdata/repros/Issue3708.sol b/testdata/repros/Issue3708.t.sol similarity index 100% rename from testdata/repros/Issue3708.sol rename to testdata/repros/Issue3708.t.sol diff --git a/testdata/repros/Issue6180.sol b/testdata/repros/Issue6180.t.sol similarity index 100% rename from testdata/repros/Issue6180.sol rename to testdata/repros/Issue6180.t.sol From f0166ccf0c8dc3ff626eed3c0a060804d8b94cb1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:18:11 +0100 Subject: [PATCH 0333/1963] fix(cheatcodes): coerce root values (#6441) * fix(cheatcodes): coerce root values * simplify * fmt --- crates/cheatcodes/src/json.rs | 66 +++++++++++++-------------------- crates/cheatcodes/src/string.rs | 1 + crates/forge/tests/it/repros.rs | 3 ++ testdata/repros/Issue6437.t.sol | 32 ++++++++++++++++ 4 files changed, 61 insertions(+), 41 deletions(-) create mode 100644 testdata/repros/Issue6437.t.sol diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index 94f8f9440a28b..aa27a446d0e11 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -281,51 +281,34 @@ impl Cheatcode for writeJson_1Call { } fn parse_json(json: &str, path: &str) -> Result { - parse_json_inner(json, path, None::) -> Result>) + let value = parse_json_str(json)?; + let selected = select(&value, path)?; + let sol = json_to_sol(&selected)?; + Ok(encode(sol)) } fn parse_json_coerce(json: &str, path: &str, ty: &DynSolType) -> Result { - parse_json_inner( - json, - path, - Some(|values: Vec<&Value>| { - ensure!(!values.is_empty(), "no matching value found at {path:?}"); - - ensure!( - values.iter().all(|value| !value.is_object()), - "values at {path:?} must not be JSON objects" - ); - - let to_string = |v: &Value| { - let mut s = v.to_string(); - s.retain(|c: char| c != '"'); - s - }; - if let Some(array) = values[0].as_array() { - string::parse_array(array.iter().map(to_string), ty) - } else { - string::parse(&to_string(values[0]), ty) - } - }), - ) -} - -fn parse_json_inner(json: &str, key: &str, coerce: Option) -> Result -where - F: FnOnce(Vec<&Value>) -> Result, -{ let value = parse_json_str(json)?; - let selected = select(&value, key)?; - - // don't coerce when selecting the root value - if !matches!(key, "$" | ".") { - if let Some(coerce) = coerce { - return coerce(selected) - } + let values = select(&value, path)?; + ensure!(!values.is_empty(), "no matching value found at {path:?}"); + + ensure!( + values.iter().all(|value| !value.is_object()), + "values at {path:?} must not be JSON objects" + ); + + let to_string = |v: &Value| { + let mut s = v.to_string(); + s.retain(|c: char| c != '"'); + s + }; + if let Some(array) = values[0].as_array() { + debug!(target: "cheatcodes", %ty, "parsing array"); + string::parse_array(array.iter().map(to_string), ty) + } else { + debug!(target: "cheatcodes", %ty, "parsing string"); + string::parse(&to_string(values[0]), ty) } - - let sol = json_to_sol(&selected)?; - Ok(encode(sol)) } fn parse_json_str(json: &str) -> Result { @@ -345,6 +328,7 @@ fn select<'a>(value: &'a Value, mut path: &str) -> Result> { if path == "." { path = "$"; } + // format error with debug string because json_path errors may contain newlines jsonpath_lib::select(value, &canonicalize_json_path(path)) .map_err(|e| fmt_err!("failed selecting from JSON: {:?}", e.to_string())) } @@ -374,7 +358,7 @@ fn canonicalize_json_path(path: &str) -> Cow<'_, str> { /// The function is designed to run recursively, so that in case of an object /// it will call itself to convert each of it's value and encode the whole as a /// Tuple -#[instrument(target = "cheatcodes", level = "trace", err, ret)] +#[instrument(target = "cheatcodes", level = "trace", ret)] pub(super) fn value_to_token(value: &Value) -> Result { match value { Value::Null => Ok(DynSolValue::FixedBytes(B256::ZERO, 32)), diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index 3c53c551d7f1f..f55350592ea10 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -115,6 +115,7 @@ where } } +#[instrument(target = "cheatcodes", level = "debug", skip(ty), fields(%ty), ret)] fn parse_value(s: &str, ty: &DynSolType) -> Result { match ty.coerce_str(s) { Ok(value) => Ok(value), diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 228fc27cb994d..f134d427b94fa 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -195,3 +195,6 @@ test_repro!(6170, false, None, |res| { // https://github.com/foundry-rs/foundry/issues/6180 test_repro!(6180); + +// https://github.com/foundry-rs/foundry/issues/6437 +test_repro!(6437); diff --git a/testdata/repros/Issue6437.t.sol b/testdata/repros/Issue6437.t.sol new file mode 100644 index 0000000000000..529c96d2e5e46 --- /dev/null +++ b/testdata/repros/Issue6437.t.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6437 +contract Issue6437Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test0() public { + string memory json = "[]"; + address[] memory arr = vm.parseJsonAddressArray(json, "$"); + assertEq(arr.length, 0); + } + + function test1() public { + string memory json = "[\"0x1111111111111111111111111111111111111111\"]"; + address[] memory arr = vm.parseJsonAddressArray(json, "$"); + assertEq(arr.length, 1); + assertEq(arr[0], 0x1111111111111111111111111111111111111111); + } + + function test2() public { + string memory json = + "[\"0x1111111111111111111111111111111111111111\",\"0x2222222222222222222222222222222222222222\"]"; + address[] memory arr = vm.parseJsonAddressArray(json, "$"); + assertEq(arr.length, 2); + assertEq(arr[0], 0x1111111111111111111111111111111111111111); + assertEq(arr[1], 0x2222222222222222222222222222222222222222); + } +} From 23aa3034f1499b274da52fa0d06b071a5bf9d3de Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 28 Nov 2023 00:56:47 +0100 Subject: [PATCH 0334/1963] feat(cast): add options to randomize initial nonce (#6443) * feat(cast): add options to randomize initial nonce * update test * nonce -> salt * doc --- Cargo.lock | 1 + crates/cast/Cargo.toml | 1 + crates/cast/bin/cmd/create2.rs | 91 +++++++++++++++++++++++++++++----- 3 files changed, 80 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61789333a6d28..792cd2f89ac50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1015,6 +1015,7 @@ dependencies = [ "futures", "indicatif", "itertools 0.11.0", + "rand 0.8.5", "rayon", "regex", "rpassword", diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index be3acb15f531a..c822ffb75336a 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -38,6 +38,7 @@ evm-disassembler = "0.3" eyre.workspace = true futures = "0.3" hex.workspace = true +rand.workspace = true rayon = "1" serde_json.workspace = true serde.workspace = true diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index c28b64fa48d51..661ea3cb18569 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -1,8 +1,10 @@ use alloy_primitives::{keccak256, Address, B256, U256}; use clap::Parser; use eyre::{Result, WrapErr}; +use rand::{rngs::StdRng, RngCore, SeedableRng}; use regex::RegexSetBuilder; use std::{ + num::NonZeroUsize, sync::{ atomic::{AtomicBool, Ordering}, Arc, @@ -10,6 +12,9 @@ use std::{ time::Instant, }; +// https://etherscan.io/address/0x4e59b44847b379578588920ca78fbf26c0b4956c#code +const DEPLOYER: &str = "0x4e59b44847b379578588920ca78fbf26c0b4956c"; + /// CLI arguments for `cast create2`. #[derive(Debug, Clone, Parser)] pub struct Create2Args { @@ -38,7 +43,7 @@ pub struct Create2Args { #[clap( short, long, - default_value = "0x4e59b44847b379578588920ca78fbf26c0b4956c", + default_value = DEPLOYER, value_name = "ADDRESS" )] deployer: Address, @@ -53,11 +58,19 @@ pub struct Create2Args { /// Number of threads to use. Defaults to and caps at the number of logical cores. #[clap(short, long)] - jobs: Option, + jobs: Option, /// Address of the caller. Used for the first 20 bytes of the salt. #[clap(long, value_name = "ADDRESS")] caller: Option
, + + /// The random number generator's seed, used to initialize the salt. + #[clap(long, value_name = "HEX")] + seed: Option, + + /// Don't initialize the salt with a random value, and instead use the default value of 0. + #[clap(long, conflicts_with = "seed")] + no_random: bool, } #[allow(dead_code)] @@ -78,6 +91,8 @@ impl Create2Args { init_code_hash, jobs, caller, + seed, + no_random, } = self; let mut regexs = vec![]; @@ -131,15 +146,26 @@ impl Create2Args { let mut n_threads = std::thread::available_parallelism().map_or(1, |n| n.get()); if let Some(jobs) = jobs { - n_threads = n_threads.min(jobs); + n_threads = n_threads.min(jobs.get()); } if cfg!(test) { n_threads = n_threads.min(2); } - let mut top_bytes = B256::ZERO; - if let Some(caller_address) = caller { - top_bytes[..20].copy_from_slice(&caller_address.into_array()); + let mut salt = B256::ZERO; + let remaining = if let Some(caller_address) = caller { + salt[..20].copy_from_slice(&caller_address.into_array()); + &mut salt[20..] + } else { + &mut salt[..] + }; + + if !no_random { + let mut rng = match seed { + Some(seed) => StdRng::from_seed(seed.0), + None => StdRng::from_entropy(), + }; + rng.fill_bytes(remaining); } println!("Starting to generate deterministic contract address..."); @@ -158,14 +184,13 @@ impl Create2Args { handles.push(std::thread::spawn(move || { // Read the first bytes of the salt as a usize to be able to increment it. struct B256Aligned(B256, [usize; 0]); - let mut salt = B256Aligned(top_bytes, []); + let mut salt = B256Aligned(salt, []); // SAFETY: B256 is aligned to `usize`. let salt_word = unsafe { &mut *salt.0.as_mut_ptr().add(32 - usize::BITS as usize / 8).cast::() }; - // Important: set the salt to the start value, otherwise all threads loop over the - // same values. - *salt_word = i; + // Important: add the thread index to the salt to avoid duplicate results. + *salt_word = salt_word.wrapping_add(i); let mut checksum = [0; 42]; loop { @@ -190,7 +215,7 @@ impl Create2Args { } // Increment the salt for the next iteration. - *salt_word += increment; + *salt_word = salt_word.wrapping_add(increment); } })); } @@ -219,10 +244,9 @@ fn get_regex_hex_string(s: String) -> Result { #[cfg(test)] mod tests { use super::*; + use alloy_primitives::{address, b256}; use std::str::FromStr; - const DEPLOYER: &str = "0x4e59b44847b379578588920ca78fbf26c0b4956c"; - #[test] fn basic_create2() { let mk_args = |args: &[&str]| { @@ -332,4 +356,45 @@ mod tests { assert!(format!("{address:x}").starts_with("dd")); assert!(format!("{salt:x}").starts_with("66f9664f97f2b50f62d13ea064982f936de76657")); } + + #[test] + fn deterministic_seed() { + let args = Create2Args::parse_from([ + "foundry-cli", + "--starts-with=0x00", + "--init-code-hash=0x479d7e8f31234e208d704ba1a123c76385cea8a6981fd675b784fbd9cffb918d", + "--seed=0x479d7e8f31234e208d704ba1a123c76385cea8a6981fd675b784fbd9cffb918d", + "-j1", + ]); + let out = args.run().unwrap(); + assert_eq!(out.address, address!("00614b3D65ac4a09A376a264fE1aE5E5E12A6C43")); + assert_eq!( + out.salt, + b256!("322113f523203e2c0eb00bbc8e69208b0eb0c8dad0eaac7b01d64ff016edb40d"), + ); + } + + #[test] + fn deterministic_output() { + let args = Create2Args::parse_from([ + "foundry-cli", + "--starts-with=0x00", + "--init-code-hash=0x479d7e8f31234e208d704ba1a123c76385cea8a6981fd675b784fbd9cffb918d", + "--no-random", + "-j1", + ]); + let out = args.run().unwrap(); + assert_eq!(out.address, address!("00bF495b8b42fdFeb91c8bCEB42CA4eE7186AEd2")); + assert_eq!( + out.salt, + b256!("000000000000000000000000000000000000000000000000df00000000000000"), + ); + } + + #[test] + fn j0() { + let e = + Create2Args::try_parse_from(["foundry-cli", "--starts-with=00", "-j0"]).unwrap_err(); + let _ = e.print(); + } } From db39460cbc2f624d8ef6b274e0f2d57efb4d5da6 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 28 Nov 2023 14:08:17 +0100 Subject: [PATCH 0335/1963] fix: handle duplicate forkids (#5939) * fix: handle duplicate forkids * fix: ensure fork ids are unique * rustfmt * chore: test order --- crates/evm/core/src/backend/mod.rs | 22 ++++++++++++++++--- crates/forge/tests/it/repros.rs | 3 +++ testdata/repros/Issue5935.t.sol | 34 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 testdata/repros/Issue5935.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 6de59965e969c..e8e18c383121b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -956,11 +956,22 @@ impl DatabaseExt for Backend { } } - fn create_fork(&mut self, fork: CreateFork) -> eyre::Result { + fn create_fork(&mut self, mut create_fork: CreateFork) -> eyre::Result { trace!("create fork"); - let (fork_id, fork, _) = self.forks.create_fork(fork)?; - let fork_db = ForkDB::new(fork); + let (fork_id, fork, _) = self.forks.create_fork(create_fork.clone())?; + + // Check for an edge case where the fork_id already exists, which would mess with the + // internal mappings. This can happen when two forks are created with the same + // endpoint and block number + // This is a hacky solution but a simple fix to ensure URLs are unique + if self.inner.contains_fork(&fork_id) { + // ensure URL is unique + create_fork.url.push('/'); + debug!(?fork_id, "fork id already exists. making unique"); + return self.create_fork(create_fork) + } + let fork_db = ForkDB::new(fork); let (id, _) = self.inner.insert_new_fork(fork_id, fork_db, self.fork_init_journaled_state.clone()); Ok(id) @@ -1528,6 +1539,11 @@ pub struct BackendInner { // === impl BackendInner === impl BackendInner { + /// Returns `true` if the given [ForkId] already exists. + fn contains_fork(&self, id: &ForkId) -> bool { + self.created_forks.contains_key(id) + } + pub fn ensure_fork_id(&self, id: LocalForkId) -> eyre::Result<&ForkId> { self.issued_local_fork_ids .get(&id) diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index f134d427b94fa..3469e47b172d3 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -176,6 +176,9 @@ test_repro!(5038); // https://github.com/foundry-rs/foundry/issues/5808 test_repro!(5808); +// +test_repro!(5935); + // https://github.com/foundry-rs/foundry/issues/6006 test_repro!(6006); diff --git a/testdata/repros/Issue5935.t.sol b/testdata/repros/Issue5935.t.sol new file mode 100644 index 0000000000000..8d6f8687b9339 --- /dev/null +++ b/testdata/repros/Issue5935.t.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0 <0.9.0; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +contract SimpleStorage { + uint256 public value; + + function set(uint256 _value) external { + value = _value; + } +} + +/// @dev start anvil --port 35353 +contract Issue5935Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testFork() public { + uint256 forkId1 = + vm.createFork("https://eth-mainnet.alchemyapi.io/v2/QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", 18234083); + uint256 forkId2 = + vm.createFork("https://eth-mainnet.alchemyapi.io/v2/QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", 18234083); + vm.selectFork(forkId1); + SimpleStorage myContract = new SimpleStorage(); + myContract.set(42); + vm.selectFork(forkId2); + SimpleStorage myContract2 = new SimpleStorage(); + assertEq(myContract2.value(), 0); + + vm.selectFork(forkId1); + assertEq(myContract.value(), 42); + } +} From 1ca7a2e431f0dc466114174fb2dac2ea0aeb3385 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 28 Nov 2023 17:23:50 +0100 Subject: [PATCH 0336/1963] chore: misc verify enhancements (#6445) --- crates/forge/bin/cmd/create.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 74d56caa20912..3faa883d0813f 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -62,6 +62,13 @@ pub struct CreateArgs { #[clap(long, requires = "from")] unlocked: bool, + /// Prints the standard json compiler input if `--verify` is provided. + /// + /// The standard json compiler input can be used to manually submit contract verification in + /// the browser. + #[clap(long, requires = "verify")] + show_standard_json_input: bool, + #[clap(flatten)] opts: CoreBuildArgs, @@ -183,7 +190,7 @@ impl CreateArgs { libraries: vec![], root: None, verifier: self.verifier.clone(), - show_standard_json_input: false, + show_standard_json_input: self.show_standard_json_input, }; verify.verification_provider()?.preflight_check(verify).await?; Ok(()) @@ -322,7 +329,7 @@ impl CreateArgs { libraries: vec![], root: None, verifier: self.verifier, - show_standard_json_input: false, + show_standard_json_input: self.show_standard_json_input, }; println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier); verify.run().await From 3ea15cdd4726f822159e06200225b4faefd2feeb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 28 Nov 2023 20:12:00 +0100 Subject: [PATCH 0337/1963] chore: pin watchexec (#6448) --- Cargo.lock | 2 ++ crates/forge/Cargo.toml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 792cd2f89ac50..83312b84d93f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2574,6 +2574,8 @@ dependencies = [ "tracing-subscriber", "vergen", "watchexec", + "watchexec-events", + "watchexec-signals", "yansi 0.5.1", ] diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index c6d1625bcf3a8..e266ef2cd469b 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -70,7 +70,9 @@ solang-parser.workspace = true strum = { version = "0.25", features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["time"] } -watchexec = "2" +watchexec = "=2.3.0" +watchexec-events = "=1.0.0" +watchexec-signals = "=1.0.0" # doc server axum = { workspace = true, features = ["ws"] } From 4a5785a609522832d98cf18d556dd3891dc766f6 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 28 Nov 2023 23:13:43 +0400 Subject: [PATCH 0338/1963] Add `verify_preflight_check` for script sequences (#6372) * Add verify_preflight_check for script sequences * Change error message * rustfmt --------- Co-authored-by: Matthias Seitz --- crates/forge/bin/cmd/script/broadcast.rs | 4 ++++ crates/forge/bin/cmd/script/cmd.rs | 4 ++++ crates/forge/bin/cmd/script/multi.rs | 6 ++++++ crates/forge/bin/cmd/script/sequence.rs | 14 ++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index e17fb9f30f5fe..270552ec78d7f 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -342,6 +342,10 @@ impl ScriptArgs { ) -> Result<()> { trace!(target: "script", "broadcasting single chain deployment"); + if self.verify { + deployment_sequence.verify_preflight_check(&script_config.config, &verify)?; + } + let rpc = script_config.total_rpcs.into_iter().next().expect("exists; qed"); deployment_sequence.add_libraries(libraries); diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 81627126049e9..f72d70d6fa706 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -258,6 +258,10 @@ impl ScriptArgs { Err(err) => eyre::bail!(err), }; + if self.verify { + deployment_sequence.verify_preflight_check(&script_config.config, &verify)?; + } + receipts::wait_for_pending(provider, &mut deployment_sequence).await?; if self.resume { diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index 3f4c5ed842a5d..7fa4709a96340 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -120,6 +120,12 @@ impl ScriptArgs { eyre::bail!("Libraries are currently not supported on multi deployment setups."); } + if self.verify { + for sequence in &deployments.deployments { + sequence.verify_preflight_check(config, &verify)?; + } + } + if self.resume { trace!(target: "script", "resuming multi chain deployment"); diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index d8cc0050c5d45..62068aaf4fbd0 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -249,6 +249,20 @@ impl ScriptSequence { Ok((broadcast, cache)) } + /// Checks that there is an Etherscan key for the chain id of this sequence. + pub fn verify_preflight_check(&self, config: &Config, verify: &VerifyBundle) -> Result<()> { + if config.get_etherscan_api_key(Some(self.chain.into())).is_none() && + verify.verifier.verifier == VerificationProviderType::Etherscan + { + eyre::bail!( + "Etherscan API key wasn't found for chain id {}. On-chain execution aborted", + self.chain + ) + } + + Ok(()) + } + /// Given the broadcast log, it matches transactions with receipts, and tries to verify any /// created contract on etherscan. pub async fn verify_contracts( From 7c5295a001e0ba31975c78b5f9395e6b7721f08f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 28 Nov 2023 23:58:23 +0100 Subject: [PATCH 0339/1963] chore: add hint to --skip-cargo-toml (#6449) --- crates/forge/bin/cmd/bind.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 925a4071846c5..3ba8e00320df5 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -153,13 +153,21 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin let bindings = self.get_multi(&artifacts)?.build()?; println!("Checking bindings for {} contracts.", bindings.len()); if !self.module { - bindings.ensure_consistent_crate( - &self.crate_name, - &self.crate_version, - self.bindings_root(&artifacts), - self.single_file, - !self.skip_cargo_toml, - )?; + bindings + .ensure_consistent_crate( + &self.crate_name, + &self.crate_version, + self.bindings_root(&artifacts), + self.single_file, + !self.skip_cargo_toml, + ) + .map_err(|err| { + if !self.skip_cargo_toml && err.to_string().contains("Cargo.toml") { + err.wrap_err("To skip Cargo.toml consistency check, pass --skip-cargo-toml") + } else { + err + } + })?; } else { bindings.ensure_consistent_module(self.bindings_root(&artifacts), self.single_file)?; } From d7d2901cff66aa57cbbd0ebfdabfdb5d670dcdc7 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Nov 2023 01:00:08 +0100 Subject: [PATCH 0340/1963] chore: improve bind errors and tracing (#6452) --- crates/forge/bin/cmd/bind.rs | 65 +++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 3ba8e00320df5..199c83f65df40 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -1,6 +1,6 @@ use clap::{Parser, ValueHint}; use ethers_contract::{Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts}; -use eyre::Result; +use eyre::{Result, WrapErr}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{compile, fs::json_files}; use foundry_config::impl_figment_convert; @@ -82,6 +82,34 @@ pub struct BindArgs { } impl BindArgs { + pub fn run(self) -> Result<()> { + if !self.skip_build { + // run `forge build` + let project = self.build_args.project()?; + compile::compile(&project, false, false)?; + } + + let artifacts = self.try_load_config_emit_warnings()?.out; + + if !self.overwrite && self.bindings_exist(&artifacts) { + println!("Bindings found. Checking for consistency."); + return self.check_existing_bindings(&artifacts) + } + + if self.overwrite && self.bindings_exist(&artifacts) { + trace!(?artifacts, "Removing existing bindings"); + fs::remove_dir_all(self.bindings_root(&artifacts))?; + } + + self.generate_bindings(&artifacts)?; + + println!( + "Bindings have been output to {}", + self.bindings_root(&artifacts).to_str().unwrap() + ); + Ok(()) + } + /// Get the path to the root of the autogenerated crate fn bindings_root(&self, artifacts: impl AsRef) -> PathBuf { self.bindings.clone().unwrap_or_else(|| artifacts.as_ref().join("bindings")) @@ -131,8 +159,10 @@ impl BindArgs { Some(path) } }) - .map(|x| { - Abigen::from_file(x)? + .map(|path| { + trace!(?path, "parsing Abigen from file"); + Abigen::from_file(&path) + .wrap_err_with(|| format!("failed to parse Abigen from file: {:?}", path))? .add_derive("serde::Serialize")? .add_derive("serde::Deserialize") }) @@ -180,6 +210,7 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin let bindings = self.get_multi(&artifacts)?.build()?; println!("Generating bindings for {} contracts", bindings.len()); if !self.module { + trace!(single_file = self.single_file, "generating crate"); bindings.dependencies([r#"serde = "1""#]).write_to_crate( &self.crate_name, &self.crate_version, @@ -187,35 +218,9 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin self.single_file, )?; } else { + trace!(single_file = self.single_file, "generating module"); bindings.write_to_module(self.bindings_root(&artifacts), self.single_file)?; } Ok(()) } - - pub fn run(self) -> Result<()> { - if !self.skip_build { - // run `forge build` - let project = self.build_args.project()?; - compile::compile(&project, false, false)?; - } - - let artifacts = self.try_load_config_emit_warnings()?.out; - - if !self.overwrite && self.bindings_exist(&artifacts) { - println!("Bindings found. Checking for consistency."); - return self.check_existing_bindings(&artifacts) - } - - if self.overwrite && self.bindings_exist(&artifacts) { - fs::remove_dir_all(self.bindings_root(&artifacts))?; - } - - self.generate_bindings(&artifacts)?; - - println!( - "Bindings have been output to {}", - self.bindings_root(&artifacts).to_str().unwrap() - ); - Ok(()) - } } From 7c122b09ce506611a76e2273f50ca497f2b0385a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Nov 2023 01:19:08 +0100 Subject: [PATCH 0341/1963] feat: use non atomic tracker for snapshot reverts (#6451) * chore: clone executor per fuzz test * fix: handle snapshot reverts in fuzz+invariant calls * chore: typo --- crates/evm/core/src/backend/fuzz.rs | 22 ++------- crates/evm/core/src/backend/mod.rs | 21 ++++----- crates/evm/evm/src/executors/fuzz/mod.rs | 12 ++--- .../evm/evm/src/executors/invariant/funcs.rs | 4 +- crates/evm/evm/src/executors/mod.rs | 47 +++++++++++++++++-- crates/forge/src/runner.rs | 4 +- crates/forge/tests/it/repros.rs | 10 ++++ crates/forge/tests/it/test_helpers.rs | 2 +- testdata/repros/Issue6355.t.sol | 39 +++++++++++++++ 9 files changed, 114 insertions(+), 47 deletions(-) create mode 100644 testdata/repros/Issue6355.t.sol diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index ac15212b27440..bf32c6f8800f0 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -39,16 +39,11 @@ pub struct FuzzBackendWrapper<'a> { pub backend: Cow<'a, Backend>, /// Keeps track of whether the backed is already initialized is_initialized: bool, - /// Keeps track of whether there was a snapshot failure. - /// - /// Necessary as the backend is dropped after usage, but we'll need to persist - /// the snapshot failure anyhow. - has_snapshot_failure: bool, } impl<'a> FuzzBackendWrapper<'a> { pub fn new(backend: &'a Backend) -> Self { - Self { backend: Cow::Borrowed(backend), is_initialized: false, has_snapshot_failure: false } + Self { backend: Cow::Borrowed(backend), is_initialized: false } } /// Executes the configured transaction of the `env` without committing state changes @@ -73,14 +68,7 @@ impl<'a> FuzzBackendWrapper<'a> { /// /// This is bubbled up from the underlying Copy-On-Write backend when a revert occurs. pub fn has_snapshot_failure(&self) -> bool { - self.has_snapshot_failure - } - - /// Sets whether there was a snapshot failure in the fuzz backend. - /// - /// This is bubbled up from the underlying Copy-On-Write backend when a revert occurs. - pub fn set_snapshot_failure(&mut self, has_snapshot_failure: bool) { - self.has_snapshot_failure = has_snapshot_failure; + self.backend.has_snapshot_failure() } /// Returns a mutable instance of the Backend. @@ -110,11 +98,7 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { current: &mut Env, ) -> Option { trace!(?id, "fuzz: revert snapshot"); - let journaled_state = self.backend_mut(current).revert(id, journaled_state, current); - // Persist the snapshot failure in the fuzz backend, as the underlying backend state is lost - // after the call. - self.set_snapshot_failure(self.has_snapshot_failure || self.backend.has_snapshot_failure()); - journaled_state + self.backend_mut(current).revert(id, journaled_state, current) } fn create_fork(&mut self, fork: CreateFork) -> eyre::Result { diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index e8e18c383121b..168e9f645ad8d 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -26,13 +26,7 @@ use revm::{ }, Database, DatabaseCommit, Inspector, JournaledState, EVM, }; -use std::{ - collections::{HashMap, HashSet}, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, -}; +use std::collections::{HashMap, HashSet}; mod diagnostic; pub use diagnostic::RevertDiagnostic; @@ -568,11 +562,12 @@ impl Backend { /// /// This returns whether there was a reverted snapshot that recorded an error pub fn has_snapshot_failure(&self) -> bool { - self.inner.has_snapshot_failure.load(Ordering::Relaxed) + self.inner.has_snapshot_failure } - pub fn set_snapshot_failure(&self, has_snapshot_failure: bool) { - self.inner.has_snapshot_failure.store(has_snapshot_failure, Ordering::Relaxed); + /// Sets the snapshot failure flag. + pub fn set_snapshot_failure(&mut self, has_snapshot_failure: bool) { + self.inner.has_snapshot_failure = has_snapshot_failure } /// Checks if the test contract associated with this backend failed, See @@ -913,7 +908,7 @@ impl DatabaseExt for Backend { // need to check whether there's a global failure which means an error occurred either // during the snapshot or even before if self.is_global_failure(current_state) { - self.inner.has_snapshot_failure.store(true, Ordering::Relaxed); + self.set_snapshot_failure(true); } // merge additional logs @@ -1514,7 +1509,7 @@ pub struct BackendInner { /// reverted we get the _current_ `revm::JournaledState` which contains the state that we can /// check if the `_failed` variable is set, /// additionally - pub has_snapshot_failure: Arc, + pub has_snapshot_failure: bool, /// Tracks the address of a Test contract /// /// This address can be used to inspect the state of the contract when a test is being @@ -1733,7 +1728,7 @@ impl Default for BackendInner { created_forks: Default::default(), forks: vec![], snapshots: Default::default(), - has_snapshot_failure: Arc::new(AtomicBool::new(false)), + has_snapshot_failure: false, test_contract_address: None, caller: None, next_fork_id: Default::default(), diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 3759962932a63..321f1ddcd364d 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -28,9 +28,9 @@ pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; /// After instantiation, calling `fuzz` will proceed to hammer the deployed smart contract with /// inputs, until it finds a counterexample. The provided [`TestRunner`] contains all the /// configuration which can be overridden via [environment variables](proptest::test_runner::Config) -pub struct FuzzedExecutor<'a> { - /// The VM - executor: &'a Executor, +pub struct FuzzedExecutor { + /// The EVM executor + executor: Executor, /// The fuzzer runner: TestRunner, /// The account that calls tests @@ -39,10 +39,10 @@ pub struct FuzzedExecutor<'a> { config: FuzzConfig, } -impl<'a> FuzzedExecutor<'a> { +impl FuzzedExecutor { /// Instantiates a fuzzed executor given a testrunner pub fn new( - executor: &'a Executor, + executor: Executor, runner: TestRunner, sender: Address, config: FuzzConfig, @@ -224,7 +224,7 @@ impl<'a> FuzzedExecutor<'a> { .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); let success = - self.executor.is_success(address, call.reverted, state_changeset.clone(), should_fail); + self.executor.is_raw_call_success(address, state_changeset.clone(), &call, should_fail); if success { Ok(FuzzOutcome::Case(CaseOutcome { diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index 1c3de4407a223..2d7688729fe57 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -40,10 +40,10 @@ pub fn assert_invariants( // This will panic and get caught by the executor let is_err = call_result.reverted || - !executor.is_success( + !executor.is_raw_call_success( invariant_contract.address, - call_result.reverted, call_result.state_changeset.take().expect("we should have a state changeset"), + &call_result, false, ); if is_err { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 49d60496be3b3..dcb1682883fa9 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -282,6 +282,10 @@ impl Executor { /// Performs a raw call to an account on the current state of the VM. /// /// Any state modifications made by the call are not committed. + /// + /// This intended for fuzz calls, which try to minimize [Backend] clones by using a Cow of the + /// underlying [Backend] so it only gets cloned when cheatcodes that require mutable access are + /// used. pub fn call_raw( &self, from: Address, @@ -296,9 +300,8 @@ impl Executor { let result = db.inspect_ref(&mut env, &mut inspector)?; // Persist the snapshot failure recorded on the fuzz backend wrapper. - self.backend - .set_snapshot_failure(self.backend.has_snapshot_failure() || db.has_snapshot_failure()); - convert_executed_result(env, inspector, result) + let has_snapshot_failure = db.has_snapshot_failure(); + convert_executed_result(env, inspector, result, has_snapshot_failure) } /// Execute the transaction configured in `env.tx` and commit the changes @@ -313,7 +316,7 @@ impl Executor { // execute the call let mut inspector = self.inspector.clone(); let result = self.backend.inspect_ref(&mut env, &mut inspector)?; - convert_executed_result(env, inspector, result) + convert_executed_result(env, inspector, result, self.backend.has_snapshot_failure()) } /// Commit the changeset to the database and adjust `self.inspector_config` @@ -465,6 +468,34 @@ impl Executor { self.ensure_success(address, reverted, state_changeset, should_fail).unwrap_or_default() } + /// This is the same as [Self::is_success] but intended for outcomes of [Self::call_raw] used in + /// fuzzing and invariant testing. + /// + /// ## Background + /// + /// Executing and failure checking [Executor::ensure_success] are two steps, for ds-test + /// legacy reasons failures can be stored in a global variables and needs to be called via a + /// solidity call `failed()(bool)`. For fuzz tests we’re using the + /// `FuzzBackendWrapper` which is a Cow of the executor’s backend which lazily clones the + /// backend when it’s mutated via cheatcodes like `snapshot`. Snapshots make it even + /// more complicated because now we also need to keep track of that global variable when we + /// revert to a snapshot (because it is stored in state). Now, the problem is that + /// the `FuzzBackendWrapper` is dropped after every call, so we need to keep track of the + /// snapshot failure in the [RawCallResult] instead. + pub fn is_raw_call_success( + &self, + address: Address, + state_changeset: StateChangeset, + call_result: &RawCallResult, + should_fail: bool, + ) -> bool { + if call_result.has_snapshot_failure { + // a failure occurred in a reverted snapshot, which is considered a failed test + return should_fail + } + self.is_success(address, call_result.reverted, state_changeset, should_fail) + } + fn ensure_success( &self, address: Address, @@ -646,6 +677,11 @@ pub struct RawCallResult { pub exit_reason: InstructionResult, /// Whether the call reverted or not pub reverted: bool, + /// Whether the call includes a snapshot failure + /// + /// This is tracked separately from revert because a snapshot failure can occur without a + /// revert, since assert failures are stored in a global variable (ds-test legacy) + pub has_snapshot_failure: bool, /// The raw result of the call pub result: Bytes, /// The gas used for the call @@ -688,6 +724,7 @@ impl Default for RawCallResult { Self { exit_reason: InstructionResult::Continue, reverted: false, + has_snapshot_failure: false, result: Bytes::new(), gas_used: 0, gas_refunded: 0, @@ -719,6 +756,7 @@ fn convert_executed_result( env: Env, inspector: InspectorStack, result: ResultAndState, + has_snapshot_failure: bool, ) -> eyre::Result { let ResultAndState { result: exec_result, state: state_changeset } = result; let (exit_reason, gas_refunded, gas_used, out) = match exec_result { @@ -761,6 +799,7 @@ fn convert_executed_result( Ok(RawCallResult { exit_reason, reverted: !matches!(exit_reason, return_ok!()), + has_snapshot_failure, result, gas_used, gas_refunded, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index e070eeadb588c..0a9a121c2aae2 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -558,7 +558,7 @@ impl<'a> ContractRunner<'a> { // Run fuzz test let start = Instant::now(); let fuzzed_executor = - FuzzedExecutor::new(&self.executor, runner.clone(), self.sender, fuzz_config); + FuzzedExecutor::new(self.executor.clone(), runner.clone(), self.sender, fuzz_config); let state = fuzzed_executor.build_fuzz_state(); let mut result = fuzzed_executor.fuzz(func, address, should_fail, self.errors); @@ -598,7 +598,7 @@ impl<'a> ContractRunner<'a> { }; // rerun the last relevant test with traces let debug_result = FuzzedExecutor::new( - &debug_executor, + debug_executor, runner, self.sender, fuzz_config, diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 3469e47b172d3..fd44013dcb02e 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -199,5 +199,15 @@ test_repro!(6170, false, None, |res| { // https://github.com/foundry-rs/foundry/issues/6180 test_repro!(6180); +// https://github.com/foundry-rs/foundry/issues/6355 +test_repro!(6355, false, None, |res| { + let mut res = res.remove("repros/Issue6355.t.sol:Issue6355Test").unwrap(); + let test = res.test_results.remove("test_shouldFail()").unwrap(); + assert_eq!(test.status, TestStatus::Failure); + + let test = res.test_results.remove("test_shouldFailWithRevertTo()").unwrap(); + assert_eq!(test.status, TestStatus::Failure); +}); + // https://github.com/foundry-rs/foundry/issues/6437 test_repro!(6437); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 37393525f5978..e0bac51b4ea69 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -77,7 +77,7 @@ pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { ..Default::default() }); -pub fn fuzz_executor(executor: &Executor) -> FuzzedExecutor { +pub fn fuzz_executor(executor: Executor) -> FuzzedExecutor { let cfg = proptest::test_runner::Config { failure_persistence: None, ..Default::default() }; FuzzedExecutor::new( diff --git a/testdata/repros/Issue6355.t.sol b/testdata/repros/Issue6355.t.sol new file mode 100644 index 0000000000000..7271011c674de --- /dev/null +++ b/testdata/repros/Issue6355.t.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6355 +contract Issue6355Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + uint256 snapshot; + Target targ; + + function setUp() public { + snapshot = vm.snapshot(); + targ = new Target(); + } + + // this non-deterministically fails sometimes and passes sometimes + function test_shouldPass() public { + assertEq(2, targ.num()); + } + + // always fails + function test_shouldFailWithRevertTo() public { + assertEq(3, targ.num()); + vm.revertTo(snapshot); + } + + // always fails + function test_shouldFail() public { + assertEq(3, targ.num()); + } +} + +contract Target { + function num() public pure returns (uint256) { + return 2; + } +} From 09a48f6203e3363caffacf0b669648b336dcdeb2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Nov 2023 15:20:26 +0100 Subject: [PATCH 0342/1963] feat: prefix local address with http scheme (#6456) --- crates/common/src/provider.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/common/src/provider.rs b/crates/common/src/provider.rs index d437f92451a3f..730260d9ab4d7 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider.rs @@ -79,7 +79,7 @@ impl ProviderBuilder { // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http // prefix let storage; - if url_str.starts_with("localhost:") { + if url_str.starts_with("localhost:") || url_str.starts_with("127.0.0.1:") { storage = format!("http://{url_str}"); url_str = storage.as_str(); } From a3ec223a19cc707069af2db07199ec871487b089 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Nov 2023 15:48:31 +0100 Subject: [PATCH 0343/1963] chore: bump ethers (#6458) --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 16 ++++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83312b84d93f6..54b7895219851 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1298,14 +1298,13 @@ dependencies = [ [[package]] name = "coins-ledger" -version = "0.8.7" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fa6094030951ce3efad50fdba0efe088a93ffe05ec58c2f47cc60d9e90c715d" +checksum = "12adb2f4914ec6d8659cd9d1630463ca13ac90f5be18133cb9a70921f15fc145" dependencies = [ "async-trait", "byteorder", "cfg-if", - "futures", "getrandom 0.2.11", "hex", "hidapi-rusb", @@ -1318,6 +1317,7 @@ dependencies = [ "serde", "tap", "thiserror", + "tokio", "tracing", "wasm-bindgen", "wasm-bindgen-futures", @@ -2082,7 +2082,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "ethers-core", "once_cell", @@ -2108,7 +2108,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2126,7 +2126,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "Inflector", "const-hex", @@ -2149,7 +2149,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "Inflector", "const-hex", @@ -2164,7 +2164,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "arrayvec", "bytes", @@ -2193,7 +2193,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "chrono", "ethers-core", @@ -2208,7 +2208,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "async-trait", "auto_impl", @@ -2233,7 +2233,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "async-trait", "auto_impl", @@ -2271,7 +2271,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "async-trait", "coins-bip32", @@ -2299,7 +2299,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6#8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" +source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" dependencies = [ "cfg-if", "const-hex", diff --git a/Cargo.toml b/Cargo.toml index 942d29889916d..595eddd922388 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -187,14 +187,14 @@ tower-http = "0.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "8175f0f97070ad69abd5dfa7b8df31f1c1dcc3d6" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } From 27956b36e783eeb6845f4e8ffdbaa096025f5b4d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 Nov 2023 16:08:11 +0100 Subject: [PATCH 0344/1963] chore: revise contract empty error (#6457) --- crates/cast/src/lib.rs | 2 +- crates/forge/tests/cli/create.rs | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 0fad3aeb740a2..8ff767354a782 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -122,7 +122,7 @@ where if let Some(NameOrAddress::Address(addr)) = tx.to() { if let Ok(code) = self.provider.get_code(*addr, block).await { if code.is_empty() { - eyre::bail!("contract {addr:?} does not exist") + eyre::bail!("contract {addr:?} does not have any code") } } } diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 89ea4e47da79b..9cb15954989fe 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -280,3 +280,47 @@ contract TupleArrayConstructorContract { ); } ); + +// +forgetest_async!( + #[serial_test::serial] + can_create_and_call, + |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + let (_api, handle) = spawn(NodeConfig::test()).await; + let rpc = handle.http_endpoint(); + let wallet = handle.dev_wallets().next().unwrap(); + let pk = hex::encode(wallet.signer().to_bytes()); + + // explicitly byte code hash for consistent checks + let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; + prj.write_config(config); + + prj.add_source( + "UniswapV2Swap", + r#" +contract UniswapV2Swap { + + function pairInfo() public view returns (uint reserveA, uint reserveB, uint totalSupply) { + (reserveA, reserveB, totalSupply) = (0,0,0); + } + +} +"#, + ) + .unwrap(); + + cmd.forge_fuse().args([ + "create", + "./src/UniswapV2Swap.sol:UniswapV2Swap", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + ]); + + let (stdout, _) = cmd.output_lossy(); + assert!(stdout.contains("Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3")); + } +); From a8f50926048ab6b470b697ef93d385c1204f4989 Mon Sep 17 00:00:00 2001 From: Rim Rakhimov Date: Thu, 30 Nov 2023 14:39:05 +0400 Subject: [PATCH 0345/1963] Add a verification flag to skip contract is verified check (#6461) * Add 'skip_is_verified_check' flag into 'verify-contract' command * cargo fmt --- crates/forge/bin/cmd/create.rs | 2 ++ crates/forge/bin/cmd/script/verify.rs | 1 + crates/forge/bin/cmd/verify/etherscan/mod.rs | 9 +++++++-- crates/forge/bin/cmd/verify/mod.rs | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 3faa883d0813f..745aa390e85f1 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -185,6 +185,7 @@ impl CreateArgs { }, flatten: false, force: false, + skip_is_verified_check: false, watch: true, retry: self.retry, libraries: vec![], @@ -324,6 +325,7 @@ impl CreateArgs { etherscan: EtherscanOpts { key: self.eth.etherscan.key, chain: Some(chain.into()) }, flatten: false, force: false, + skip_is_verified_check: false, watch: true, retry: self.retry, libraries: vec![], diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 0c17260dd30ec..4c0205fcfc34a 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -103,6 +103,7 @@ impl VerifyBundle { etherscan: self.etherscan.clone(), flatten: false, force: false, + skip_is_verified_check: false, watch: true, retry: self.retry, libraries: libraries.to_vec(), diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index e9a72d85abcba..64471ed3fe02c 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -57,7 +57,9 @@ impl VerificationProvider for EtherscanVerificationProvider { async fn verify(&mut self, args: VerifyArgs) -> Result<()> { let (etherscan, verify_args) = self.prepare_request(&args).await?; - if self.is_contract_verified(ðerscan, &verify_args).await? { + if !args.skip_is_verified_check && + self.is_contract_verified(ðerscan, &verify_args).await? + { println!( "\nContract [{}] {:?} is already verified. Skipping verification.", verify_args.contract_name, @@ -89,7 +91,10 @@ impl VerificationProvider for EtherscanVerificationProvider { trace!(target: "forge::verify", ?resp, "Received verification response"); if resp.status == "0" { - if resp.result == "Contract source code already verified" { + if resp.result == "Contract source code already verified" + // specific for blockscout response + || resp.result == "Smart-contract already verified." + { return Ok(None) } diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 5544c12f0508c..1bcdd4c8baff5 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -68,6 +68,10 @@ pub struct VerifyArgs { #[clap(short, long)] pub force: bool, + /// Do not check if the contract is already verified before verifying. + #[clap(long)] + pub skip_is_verified_check: bool, + /// Wait for verification result after submission. #[clap(long)] pub watch: bool, From 494acc7da6544318a197efb7165f746f81dd8f25 Mon Sep 17 00:00:00 2001 From: albertov19 <64150856+albertov19@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:22:36 +0100 Subject: [PATCH 0346/1963] RPC-based Gas Estimation for Moonbeam-based Networks (#6460) * rpc gas estimation moonbeam * cargo fmt * Revert some fmt changes * fmt --------- Co-authored-by: Enrique Ortiz --- crates/cli/src/utils/cmd.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 309e4d2956066..bb8227f1843f7 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -170,7 +170,11 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { NamedChain::Arbitrum | NamedChain::ArbitrumTestnet | NamedChain::ArbitrumGoerli | - NamedChain::ArbitrumSepolia + NamedChain::ArbitrumSepolia | + NamedChain::Moonbeam | + NamedChain::Moonriver | + NamedChain::Moonbase | + NamedChain::MoonbeamDev ) } false From 94b5d31ed3bf6b824cf1c227dd5520b43654fada Mon Sep 17 00:00:00 2001 From: Daniel Helm Date: Thu, 30 Nov 2023 05:32:46 -0600 Subject: [PATCH 0347/1963] fix: forge create to use config values for verify preflight check (#6467) --- crates/forge/bin/cmd/create.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 745aa390e85f1..1f60813701c9c 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -172,7 +172,7 @@ impl CreateArgs { ) -> Result<()> { // NOTE: this does not represent the same `VerifyArgs` that would be sent after deployment, // since we don't know the address yet. - let verify = verify::VerifyArgs { + let mut verify = verify::VerifyArgs { address: Default::default(), contract: self.contract.clone(), compiler_version: None, @@ -193,6 +193,13 @@ impl CreateArgs { verifier: self.verifier.clone(), show_standard_json_input: self.show_standard_json_input, }; + + // Check config for Etherscan API Keys to avoid preflight check failing if no + // ETHERSCAN_API_KEY value set. + let config = verify.load_config_emit_warnings(); + verify.etherscan.key = + config.get_etherscan_config_with_chain(Some(chain.into()))?.map(|c| c.key); + verify.verification_provider()?.preflight_check(verify).await?; Ok(()) } From 87b78361f9ae3aab67bde98c652e6bdf9119f6d0 Mon Sep 17 00:00:00 2001 From: 0xtekgrinder <72015889+0xtekgrinder@users.noreply.github.com> Date: Thu, 30 Nov 2023 06:40:26 -0500 Subject: [PATCH 0348/1963] chore: update required version in the Cargo.toml (#6464) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 595eddd922388..0128a6794ccb0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.74" authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" From e26f4d8585cc543dea8aa719ab89426fc17fcdaa Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:22:32 +0100 Subject: [PATCH 0349/1963] chore(deps): unpin watchexec (#6469) --- Cargo.lock | 6 ++---- crates/forge/Cargo.toml | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54b7895219851..d86654ee931a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2574,8 +2574,6 @@ dependencies = [ "tracing-subscriber", "vergen", "watchexec", - "watchexec-events", - "watchexec-signals", "yansi 0.5.1", ] @@ -7681,9 +7679,9 @@ checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "watchexec" -version = "2.3.0" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8b97d05a9305a9aa6a7bedef64cd012ebc9b6f1f5ed0368fb48f0fe58f96988" +checksum = "5931215e14de2355a3039477138ae08a905abd7ad0265519fd79717ff1380f88" dependencies = [ "async-priority-channel", "async-recursion", diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index e266ef2cd469b..f09ffa216ab98 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -70,9 +70,7 @@ solang-parser.workspace = true strum = { version = "0.25", features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["time"] } -watchexec = "=2.3.0" -watchexec-events = "=1.0.0" -watchexec-signals = "=1.0.0" +watchexec = "2.3.2" # doc server axum = { workspace = true, features = ["ws"] } From 7369a10e4b0b3c6b2608c2e9679c0fe9216b568a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:25:11 +0100 Subject: [PATCH 0350/1963] chore: update Clippy MSRV (#6471) --- Cargo.toml | 2 +- clippy.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0128a6794ccb0..194c6329b6250 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.74" +rust-version = "1.74" # Remember to update clippy.toml as well authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" diff --git a/clippy.toml b/clippy.toml index ebba0354acd0b..866add684a962 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.72" +msrv = "1.74" From 91df94b6a300e5899d49f2340b56fdd4dab0693c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 30 Nov 2023 16:50:15 +0100 Subject: [PATCH 0351/1963] test: integrate inline config in tests (#6473) --- crates/config/src/inline/conf_parser.rs | 22 +------ crates/config/src/inline/error.rs | 45 ++++++++++++++ crates/config/src/inline/mod.rs | 80 +++++++++++-------------- crates/forge/tests/it/config.rs | 19 +++--- crates/forge/tests/it/inline.rs | 7 ++- crates/forge/tests/it/repros.rs | 3 + testdata/cheats/Sleep.t.sol | 4 +- testdata/repros/Issue5948.t.sol | 32 ++++++++++ 8 files changed, 132 insertions(+), 80 deletions(-) create mode 100644 crates/config/src/inline/error.rs create mode 100644 testdata/repros/Issue5948.t.sol diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index 844f374766f75..acad057ae0d73 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -1,25 +1,7 @@ -use super::{remove_whitespaces, INLINE_CONFIG_PREFIX}; -use crate::{InlineConfigError, NatSpec}; +use super::{remove_whitespaces, InlineConfigParserError}; +use crate::{inline::INLINE_CONFIG_PREFIX, InlineConfigError, NatSpec}; use regex::Regex; -/// Errors returned by the [`InlineConfigParser`] trait. -#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] -pub enum InlineConfigParserError { - /// An invalid configuration property has been provided. - /// The property cannot be mapped to the configuration object - #[error("'{0}' is an invalid config property")] - InvalidConfigProperty(String), - /// An invalid profile has been provided - #[error("'{0}' specifies an invalid profile. Available profiles are: {1}")] - InvalidProfile(String, String), - /// An error occurred while trying to parse an integer configuration value - #[error("Invalid config value for key '{0}'. Unable to parse '{1}' into an integer value")] - ParseInt(String, String), - /// An error occurred while trying to parse a boolean configuration value - #[error("Invalid config value for key '{0}'. Unable to parse '{1}' into a boolean value")] - ParseBool(String, String), -} - /// This trait is intended to parse configurations from /// structured text. Foundry users can annotate Solidity test functions, /// providing special configs just for the execution of a specific test. diff --git a/crates/config/src/inline/error.rs b/crates/config/src/inline/error.rs new file mode 100644 index 0000000000000..4c4f7725b0847 --- /dev/null +++ b/crates/config/src/inline/error.rs @@ -0,0 +1,45 @@ +/// Errors returned by the [`InlineConfigParser`] trait. +#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] +pub enum InlineConfigParserError { + /// An invalid configuration property has been provided. + /// The property cannot be mapped to the configuration object + #[error("'{0}' is an invalid config property")] + InvalidConfigProperty(String), + /// An invalid profile has been provided + #[error("'{0}' specifies an invalid profile. Available profiles are: {1}")] + InvalidProfile(String, String), + /// An error occurred while trying to parse an integer configuration value + #[error("Invalid config value for key '{0}'. Unable to parse '{1}' into an integer value")] + ParseInt(String, String), + /// An error occurred while trying to parse a boolean configuration value + #[error("Invalid config value for key '{0}'. Unable to parse '{1}' into a boolean value")] + ParseBool(String, String), +} + +/// Wrapper error struct that catches config parsing +/// errors [`InlineConfigParserError`], enriching them with context information +/// reporting the misconfigured line. +#[derive(thiserror::Error, Debug)] +#[error("Inline config error detected at {line}")] +pub struct InlineConfigError { + /// Specifies the misconfigured line. This is something of the form + /// `dir/TestContract.t.sol:FuzzContract:10:12:111` + pub line: String, + /// The inner error + pub source: InlineConfigParserError, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn can_format_inline_config_errors() { + let source = InlineConfigParserError::ParseBool("key".into(), "invalid-bool-value".into()); + let line = "dir/TestContract.t.sol:FuzzContract".to_string(); + let error = InlineConfigError { line: line.clone(), source }; + + let expected = format!("Inline config error detected at {line}"); + assert_eq!(error.to_string(), expected); + } +} diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 5688d6cc89c36..4ce3c62f04c02 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -1,15 +1,13 @@ use crate::Config; +pub use conf_parser::{parse_config_bool, parse_config_u32, validate_profiles, InlineConfigParser}; +pub use error::{InlineConfigError, InlineConfigParserError}; +pub use natspec::NatSpec; use once_cell::sync::Lazy; -use std::collections::HashMap; +use std::{borrow::Cow, collections::HashMap}; mod conf_parser; -pub use conf_parser::{ - parse_config_bool, parse_config_u32, validate_profiles, InlineConfigParser, - InlineConfigParserError, -}; - +mod error; mod natspec; -pub use natspec::NatSpec; pub const INLINE_CONFIG_FUZZ_KEY: &str = "fuzz"; pub const INLINE_CONFIG_INVARIANT_KEY: &str = "invariant"; @@ -20,62 +18,54 @@ static INLINE_CONFIG_PREFIX_SELECTED_PROFILE: Lazy = Lazy::new(|| { format!("{INLINE_CONFIG_PREFIX}:{selected_profile}.") }); -/// Wrapper error struct that catches config parsing -/// errors [`InlineConfigParserError`], enriching them with context information -/// reporting the misconfigured line. -#[derive(thiserror::Error, Debug)] -#[error("Inline config error detected at {line}")] -pub struct InlineConfigError { - /// Specifies the misconfigured line. This is something of the form - /// `dir/TestContract.t.sol:FuzzContract:10:12:111` - pub line: String, - /// The inner error - pub source: InlineConfigParserError, -} - -/// Represents a (test-contract, test-function) pair -type InlineConfigKey = (String, String); - /// Represents per-test configurations, declared inline /// as structured comments in Solidity test files. This allows /// to create configs directly bound to a solidity test. #[derive(Default, Debug, Clone)] -pub struct InlineConfig { +pub struct InlineConfig { /// Maps a (test-contract, test-function) pair /// to a specific configuration provided by the user. - configs: HashMap, + configs: HashMap, T>, } impl InlineConfig { /// Returns an inline configuration, if any, for a test function. /// Configuration is identified by the pair "contract", "function". - pub fn get>(&self, contract_id: S, fn_name: S) -> Option<&T> { - self.configs.get(&(contract_id.into(), fn_name.into())) + pub fn get(&self, contract_id: C, fn_name: F) -> Option<&T> + where + C: Into, + F: Into, + { + // TODO use borrow + let key = InlineConfigKey { + contract: Cow::Owned(contract_id.into()), + function: Cow::Owned(fn_name.into()), + }; + self.configs.get(&key) } /// Inserts an inline configuration, for a test function. /// Configuration is identified by the pair "contract", "function". - pub fn insert>(&mut self, contract_id: S, fn_name: S, config: T) { - self.configs.insert((contract_id.into(), fn_name.into()), config); + pub fn insert(&mut self, contract_id: C, fn_name: F, config: T) + where + C: Into, + F: Into, + { + let key = InlineConfigKey { + contract: Cow::Owned(contract_id.into()), + function: Cow::Owned(fn_name.into()), + }; + self.configs.insert(key, config); } } -fn remove_whitespaces(s: &str) -> String { - s.chars().filter(|c| !c.is_whitespace()).collect() +/// Represents a (test-contract, test-function) pair +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +struct InlineConfigKey<'a> { + contract: Cow<'a, str>, + function: Cow<'a, str>, } -#[cfg(test)] -mod tests { - use super::InlineConfigParserError; - use crate::InlineConfigError; - - #[test] - fn can_format_inline_config_errors() { - let source = InlineConfigParserError::ParseBool("key".into(), "invalid-bool-value".into()); - let line = "dir/TestContract.t.sol:FuzzContract".to_string(); - let error = InlineConfigError { line: line.clone(), source }; - - let expected = format!("Inline config error detected at {line}"); - assert_eq!(error.to_string(), expected); - } +pub(crate) fn remove_whitespaces(s: &str) -> String { + s.chars().filter(|c| !c.is_whitespace()).collect() } diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 1ab7f0e318822..cfb706d33fc3e 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -3,7 +3,7 @@ use crate::test_helpers::{COMPILED, EVM_OPTS, PROJECT}; use forge::{ result::{SuiteResult, TestStatus}, - MultiContractRunner, MultiContractRunnerBuilder, TestOptions, + MultiContractRunner, MultiContractRunnerBuilder, TestOptions, TestOptionsBuilder, }; use foundry_config::{ fs_permissions::PathPermission, Config, FsPermissions, FuzzConfig, FuzzDictionaryConfig, @@ -95,9 +95,10 @@ impl TestConfig { } } +/// Returns the [`TestOptions`] used by the tests. pub fn test_opts() -> TestOptions { - TestOptions { - fuzz: FuzzConfig { + TestOptionsBuilder::default() + .fuzz(FuzzConfig { runs: 256, max_test_rejects: 65536, seed: None, @@ -108,8 +109,8 @@ pub fn test_opts() -> TestOptions { max_fuzz_dictionary_addresses: 10_000, max_fuzz_dictionary_values: 10_000, }, - }, - invariant: InvariantConfig { + }) + .invariant(InvariantConfig { runs: 256, depth: 15, fail_on_revert: false, @@ -122,10 +123,9 @@ pub fn test_opts() -> TestOptions { max_fuzz_dictionary_values: 10_000, }, shrink_sequence: true, - }, - inline_fuzz: Default::default(), - inline_invariant: Default::default(), - } + }) + .build(&COMPILED, &PROJECT.paths.root) + .expect("Config loaded") } pub fn manifest_root() -> &'static Path { @@ -161,6 +161,7 @@ pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { let env = opts.evm_env().await.expect("could not instantiate fork environment"); let output = COMPILED.clone(); base_runner() + .with_test_options(test_opts()) .with_cheats_config(CheatsConfig::new(&config, opts.clone())) .sender(config.sender) .build(root, output, env, opts.clone()) diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 5868df31d7861..7fc2957a2a955 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -11,7 +11,7 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { - let opts = test_options(); + let opts = default_test_options(); let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); @@ -37,7 +37,7 @@ async fn inline_config_run_fuzz() { async fn inline_config_run_invariant() { const ROOT: &str = "inline/InvariantInlineConf.t.sol"; - let opts = test_options(); + let opts = default_test_options(); let filter = Filter::new(".*", ".*", ".*inline/InvariantInlineConf.t.sol"); let mut runner = runner().await; runner.test_options = opts.clone(); @@ -98,7 +98,8 @@ fn build_test_options_just_one_valid_profile() { assert!(build_result.is_err()); } -fn test_options() -> TestOptions { +/// Returns the [TestOptions] for the testing [PROJECT]. +pub fn default_test_options() -> TestOptions { let root = &PROJECT.paths.root; TestOptionsBuilder::default() .fuzz(FuzzConfig::default()) diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index fd44013dcb02e..a472123a615ae 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -179,6 +179,9 @@ test_repro!(5808); // test_repro!(5935); +// +test_repro!(5948); + // https://github.com/foundry-rs/foundry/issues/6006 test_repro!(6006); diff --git a/testdata/cheats/Sleep.t.sol b/testdata/cheats/Sleep.t.sol index 3af2ea3c0072b..37be632cc4592 100644 --- a/testdata/cheats/Sleep.t.sol +++ b/testdata/cheats/Sleep.t.sol @@ -27,8 +27,7 @@ contract SleepTest is DSTest { assertGe(end - start, milliseconds / 1000 * 1000, "sleep failed"); } - /* - /// forge-config: default.fuzz.runs = 10 + /// forge-config: default.fuzz.runs = 2 function testSleepFuzzed(uint256 _milliseconds) public { // Limit sleep time to 2 seconds to decrease test time uint256 milliseconds = _milliseconds % 2000; @@ -49,5 +48,4 @@ contract SleepTest is DSTest { // Limit precision to 1000 ms assertGe(end - start, milliseconds / 1000 * 1000, "sleep failed"); } - */ } diff --git a/testdata/repros/Issue5948.t.sol b/testdata/repros/Issue5948.t.sol new file mode 100644 index 0000000000000..b496caf66706d --- /dev/null +++ b/testdata/repros/Issue5948.t.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/5948 +contract Issue5948Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + /// forge-config: default.fuzz.runs = 2 + function testSleepFuzzed(uint256 _milliseconds) public { + // Limit sleep time to 2 seconds to decrease test time + uint256 milliseconds = _milliseconds % 2000; + + string[] memory inputs = new string[](2); + inputs[0] = "date"; + // OS X does not support precision more than 1 second + inputs[1] = "+%s000"; + + bytes memory res = vm.ffi(inputs); + uint256 start = vm.parseUint(string(res)); + + vm.sleep(milliseconds); + + res = vm.ffi(inputs); + uint256 end = vm.parseUint(string(res)); + + // Limit precision to 1000 ms + assertGe(end - start, milliseconds / 1000 * 1000, "sleep failed"); + } +} From f5c91995f80b5bf3b4c29c934d414cc198c9e7a8 Mon Sep 17 00:00:00 2001 From: greged93 <82421016+greged93@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:58:43 +0100 Subject: [PATCH 0352/1963] fix: overflow of memory offset or size in debugger (#6474) * fix overflow of memory offset or size in debugger * fix fmt --- crates/debugger/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 33bb342887013..d93ab99846b87 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -894,7 +894,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k -2 => Some(1), -1 => Some(32), 0 => None, - 1.. => Some(stack[stack_len - stack_index as usize].to()), + 1.. => Some(stack[stack_len - stack_index as usize].saturating_to()), _ => panic!("invalid stack index"), }; @@ -917,7 +917,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k draw_mem: &DrawMemory, ) { let memory = &debug_steps[current_step].memory; - let stack_space = Block::default() + let memory_space = Block::default() .title(format!("Memory (max expansion: {} bytes)", memory.len())) .borders(Borders::ALL); let max_i = memory.len() / 32; @@ -1023,7 +1023,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k Line::from(spans) }) .collect(); - let paragraph = Paragraph::new(text).block(stack_space).wrap(Wrap { trim: true }); + let paragraph = Paragraph::new(text).block(memory_space).wrap(Wrap { trim: true }); f.render_widget(paragraph, area); } } From 8918ca54bea3073c303cc89b22d147200e90b9ac Mon Sep 17 00:00:00 2001 From: Akaonetwo <107335783+Akare123@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:10:14 +0300 Subject: [PATCH 0353/1963] Update README.md (#6479) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Here is correction: Configuration Title: I change "it's" to "its" in "configure it's tools" → "configure its tools" for grammatical consistency. --- crates/config/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/README.md b/crates/config/README.md index 1fb1370006daf..3ab867949d196 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -1,6 +1,6 @@ # Configuration -Foundry's configuration system allows you to configure it's tools the way _you_ want while also providing with a +Foundry's configuration system allows you to configure its tools the way _you_ want while also providing with a sensible set of defaults. ## Profiles From 4777fbb271e465e57b9e4e175abb000f375eb680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C4=B1l?= <114004196+anil2ec4@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:17:02 +0300 Subject: [PATCH 0354/1963] Update CONTRIBUTING.md (#6476) Modification of the "By adding context" section: Originally, the phrase "and helps resolve issues" was not seamlessly integrated into the sentence. This has been revised to "such as screenshots and code snippets, which help resolve issues." This alteration clarifies how the additional context contributes to resolving issues, enhancing the sentence's clarity and coherence. Revision in the "Submitting a bug report" section: The initial text lacked a necessary comma in the sentence, "Do not worry if you cannot answer every detail, just fill in what you can." This has been corrected to "Do not worry if you cannot answer every detail; just fill in what you can." This change improves the readability of the sentence and more effectively separates two distinct thoughts. Amendments in the "Resolving an issue" section: The original phrase "Even tiny pull requests, like fixing wording, are greatly appreciated" was somewhat vague. It has been rephrased to "Even minor pull requests, such as those fixing wording, are greatly appreciated." This edit more clearly emphasizes the value and appreciation of even small contributions, enhancing the text's encouraging tone. --- CONTRIBUTING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4e6d1d4a8b86..b2bf43604dfc4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,7 @@ There are fundamentally four ways an individual can contribute: 1. **By opening an issue:** For example, if you believe that you have uncovered a bug in Foundry, creating a new issue in the issue tracker is the way to report it. 2. **By adding context:** Providing additional context to existing issues, - such as screenshots, code snippets and helps resolve issues. + such as screenshots and code snippets, which help resolve issues. 3. **By resolving issues:** Typically this is done in the form of either demonstrating that the issue reported is not a problem after all, or more often, by opening a pull request that fixes the underlying problem, in a concrete and @@ -47,8 +47,7 @@ The [Foundry Book][foundry-book] is our current best-effort attempt at keeping u When filing a new bug report in the issue tracker, you will be presented with a basic form to fill out. -If you believe that you have uncovered a bug, please fill out the form to the best of your ability. Do not worry if you cannot answer every detail, -just fill in what you can. Contributors will ask follow-up questions if something is unclear. +If you believe that you have uncovered a bug, please fill out the form to the best of your ability. Do not worry if you cannot answer every detail; just fill in what you can. Contributors will ask follow-up questions if something is unclear. The most important pieces of information we need in a bug report are: @@ -74,7 +73,7 @@ If you have examples of other tools that have the feature you are requesting, pl Pull requests are the way concrete changes are made to the code, documentation, and dependencies of Foundry. -Even tiny pull requests, like fixing wording, are greatly appreciated. Before making a large change, it is usually +Even minor pull requests, such as those fixing wording, are greatly appreciated. Before making a large change, it is usually a good idea to first open an issue describing the change to solicit feedback and guidance. This will increase the likelihood of the PR getting merged. From ab570539746d9df03fdd0fa7f7418cd964ac7210 Mon Sep 17 00:00:00 2001 From: 0xbasar <109233435+0xbasar@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:43:17 +0300 Subject: [PATCH 0355/1963] Update cheatcodes.md (#6477) In the sentence "This macro performs extra checks on functions and structs at compile time to make sure they are documented and have named parameters, and generates a macro which is later used to implement the match { ... } function that is be used to dispatch the cheatcode implementations after a call is decoded.", there's a grammatical error. It should be "that is to be used" instead of "that is be used". --- docs/dev/cheatcodes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index a74d79fcd8301..a7dd39f1a33ff 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -120,7 +120,7 @@ interface's items, as well as the `sol!`-generated items, such as the `VmCalls` This macro performs extra checks on functions and structs at compile time to make sure they are documented and have named parameters, and generates a macro which is later used to implement the -`match { ... }` function that is be used to dispatch the cheatcode implementations after a call is +`match { ... }` function that is to be used to dispatch the cheatcode implementations after a call is decoded. The latter is what fails compilation when adding a new cheatcode, and is fixed by implementing the From a7fdd78d4a67ade07e25da8223bc87b22d769609 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 1 Dec 2023 12:43:33 +0100 Subject: [PATCH 0356/1963] chore: typo readme (#6481) --- docs/dev/debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/debugging.md b/docs/dev/debugging.md index 15281efecd9c5..9431d7c33ca82 100644 --- a/docs/dev/debugging.md +++ b/docs/dev/debugging.md @@ -4,7 +4,7 @@ This is a working document intended to outline some commands contributors can us ### Logs -All crates use [tracing](https://docs.rs/tracing/latest/tracing/) for logging. An console formatter is installed in each binary (`cast`, `forge`, `anvil`). +All crates use [tracing](https://docs.rs/tracing/latest/tracing/) for logging. A console formatter is installed in each binary (`cast`, `forge`, `anvil`). By setting `RUST_LOG=` you can get a lot more info out of Forge and Cast. For example, running Forge with `RUST_LOG=forge` will emit all logs of the `cli` crate, same for Cast. From ef5ad0c305818991f4ca44f000b8a5dcc990fd2a Mon Sep 17 00:00:00 2001 From: codeesura <120671243+codeesura@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:07:55 +0300 Subject: [PATCH 0357/1963] Add `--save-path` Option to `VanityArgs` for Custom Wallet File Saving (#6475) * add save path option * implementing suggested refactorings for Wallet Data serialization... * fix clipyy error * fix rustfmt workflow error * add comments to wallet-related functions * add test for --save-path option in vanity wallet command * nightlyfmt * better test, write to given file directly * chore: clippy --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/bin/cmd/wallet/vanity.rs | 81 +++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 6063eada11a26..5dacefb52d466 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -6,7 +6,12 @@ use eyre::Result; use foundry_common::types::ToAlloy; use rayon::iter::{self, ParallelIterator}; use regex::Regex; -use std::time::Instant; +use serde::{Deserialize, Serialize}; +use std::{ + fs, + path::{Path, PathBuf}, + time::Instant, +}; /// Type alias for the result of [generate_wallet]. pub type GeneratedWallet = (SigningKey, Address); @@ -32,11 +37,44 @@ pub struct VanityArgs { /// nonce. #[clap(long)] pub nonce: Option, + + /// Path to save the generated vanity contract address to. + /// + /// If provided, the generated vanity addresses will appended to a JSON array in the specified + /// file. + #[clap( + long, + value_hint = clap::ValueHint::FilePath, + value_name = "PATH", + )] + pub save_path: Option, +} + +/// WalletData contains address and private_key information for a wallet. +#[derive(Serialize, Deserialize)] +struct WalletData { + address: String, + private_key: String, +} + +/// Wallets is a collection of WalletData. +#[derive(Default, Serialize, Deserialize)] +struct Wallets { + wallets: Vec, +} + +impl WalletData { + pub fn new(wallet: &LocalWallet) -> Self { + WalletData { + address: wallet.address().to_alloy().to_checksum(None), + private_key: format!("0x{}", hex::encode(wallet.signer().to_bytes())), + } + } } impl VanityArgs { pub fn run(self) -> Result { - let Self { starts_with, ends_with, nonce } = self; + let Self { starts_with, ends_with, nonce, save_path } = self; let mut left_exact_hex = None; let mut left_regex = None; let mut right_exact_hex = None; @@ -108,6 +146,11 @@ impl VanityArgs { } .expect("failed to generate vanity wallet"); + // If a save path is provided, save the generated vanity wallet to the specified path. + if let Some(save_path) = save_path { + save_wallet_to_file(&wallet, &save_path)?; + } + println!( "Successfully found vanity address in {} seconds.{}{}\nAddress: {}\nPrivate Key: 0x{}", timer.elapsed().as_secs(), @@ -125,6 +168,23 @@ impl VanityArgs { } } +/// Saves the specified `wallet` to a 'vanity_addresses.json' file at the given `save_path`. +/// If the file exists, the wallet data is appended to the existing content; +/// otherwise, a new file is created. +fn save_wallet_to_file(wallet: &LocalWallet, path: &Path) -> Result<()> { + let mut wallets = if path.exists() { + let data = fs::read_to_string(path)?; + serde_json::from_str::(&data).unwrap_or_default() + } else { + Wallets::default() + }; + + wallets.wallets.push(WalletData::new(wallet)); + + fs::write(path, serde_json::to_string_pretty(&wallets)?)?; + Ok(()) +} + /// Generates random wallets until `matcher` matches the wallet address, returning the wallet. pub fn find_vanity_address(matcher: T) -> Option { wallet_generator().find_any(create_matcher(matcher)).map(|(key, _)| key.into()) @@ -328,4 +388,21 @@ mod tests { let addr = format!("{addr:x}"); assert!(addr.ends_with("00")); } + + #[test] + fn save_path() { + let tmp = tempfile::NamedTempFile::new().unwrap(); + let args: VanityArgs = VanityArgs::parse_from([ + "foundry-cli", + "--starts-with", + "00", + "--save-path", + tmp.path().to_str().unwrap(), + ]); + args.run().unwrap(); + assert!(tmp.path().exists()); + let s = fs::read_to_string(tmp.path()).unwrap(); + let wallets: Wallets = serde_json::from_str(&s).unwrap(); + assert!(!wallets.wallets.is_empty()); + } } From 1529eddad39661ba5ae69415a13e5a2bbaa09e59 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:13:29 +0100 Subject: [PATCH 0358/1963] chore(deps): update (#6484) --- Cargo.lock | 250 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 161 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d86654ee931a1..4347ff35a1188 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9fe14fb6dded4be3f44d053e59402a405bb231561e36a88bc2283a9829d81fe" +checksum = "fafc3b20c6d069d9db47037f34acfb0e079c050fa5c1ff9e79855609b359b92b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cbbc8fcae58f39dbfbdc94ead48de0779910528889aebc074aed75959bffe7" +checksum = "8d32061da2f184e5defab8e65a3057f88b7017cfe1ea9e2d6b413edb5ca76a54" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -122,9 +122,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5def4b5e1bb8fe7ea37eeac1063246d4ef26f56cbdccf864a5a6bdcb80e91f4" +checksum = "08ca2c09d5911548a5cb620382ea0e1af99d3c898ce0efecbbd274a4676cf53e" dependencies = [ "alloy-rlp", "arbitrary", @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0acd5b8d2699b095a57a0ecea6a6a2045b8e5ed6f2607bfa3382961d2889e82" +checksum = "e40cea54ac58080a1b88ea6556866eac1902b321186c77d53ad2b5ebbbf0e038" dependencies = [ "alloy-json-abi", "const-hex", @@ -190,18 +190,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc77699fb68c8a2cf18efb2c51df43e09b42b53886c6eb552951b19c41ebfc84" +checksum = "f23cb462613b2046da46dbf69ebaee458b7bfd3e9d7fe05adcce38a8d4b8a14f" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d483e9c6db659cdb24fc736684ef68b743705fbdb0677c6404815361871b92" +checksum = "f81aa34725607be118c395d62c1d8d97c8a343dd1ada5370ed508ed5232eab6a" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -1160,9 +1160,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.8" +version = "4.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" dependencies = [ "clap_builder", "clap_derive", @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" dependencies = [ "anstream", "anstyle", @@ -1426,9 +1426,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -1436,9 +1436,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" @@ -1652,7 +1652,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "lock_api", "once_cell", "parking_lot_core", @@ -1967,12 +1967,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2402,13 +2402,13 @@ dependencies = [ [[package]] name = "fd-lock" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0377f1edc77dbd1118507bc7a66e4ab64d2b90c66f90726dc801e73a8c68f9" +checksum = "b93f7a0db71c99f68398f80653ed05afb0b00e062e1a20c7ff849c4edfabbbcc" dependencies = [ "cfg-if", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2870,7 +2870,7 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-fuzz", "foundry-evm-traces", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "parking_lot", "proptest", "revm", @@ -2939,7 +2939,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "itertools 0.11.0", "parking_lot", "proptest", @@ -2967,7 +2967,7 @@ dependencies = [ "foundry-config", "foundry-evm-core", "futures", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "itertools 0.11.0", "once_cell", "ordered-float", @@ -2997,7 +2997,7 @@ dependencies = [ "ethers-core", "ethers-providers", "eyre", - "fd-lock 4.0.0", + "fd-lock 4.0.1", "foundry-common", "foundry-compilers", "foundry-config", @@ -3449,15 +3449,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -3548,9 +3548,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash 0.8.6", "allocator-api2", @@ -3794,17 +3794,16 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "747ad1b4ae841a78e8aba0d63adbfbeaea26b517b63705d47856b73015d27060" dependencies = [ + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata 0.4.3", "same-file", - "thread_local", "walkdir", "winapi-util", ] @@ -3878,7 +3877,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.3", ] [[package]] @@ -3996,9 +3995,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -4196,9 +4195,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -4222,7 +4221,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" dependencies = [ - "hashbrown 0.14.2", + "hashbrown 0.14.3", ] [[package]] @@ -4295,9 +4294,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.35" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c3f88addd34930bc5f01b9dc19f780447e51c92bf2536e3ded058018271775d" +checksum = "80992cb0e05f22cc052c99f8e883f1593b891014b96a8b4637fd274d7030c85e" dependencies = [ "ammonia", "anyhow", @@ -4311,6 +4310,7 @@ dependencies = [ "memchr", "once_cell", "opener", + "pathdiff", "pulldown-cmark", "regex", "serde", @@ -4809,9 +4809,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec", "bitvec", @@ -4823,11 +4823,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 1.0.109", @@ -4918,6 +4918,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "pbkdf2" version = "0.11.0" @@ -5318,9 +5324,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -5746,7 +5752,7 @@ dependencies = [ "bitvec", "c-kzg", "enumn", - "hashbrown 0.14.2", + "hashbrown 0.14.3", "hex", "serde", ] @@ -5778,9 +5784,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +checksum = "684d5e6e18f669ccebf64a92236bb7db9a34f07be010e3627368182027180866" dependencies = [ "cc", "getrandom 0.2.11", @@ -6004,15 +6010,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.25" +version = "0.38.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" dependencies = [ "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -6034,7 +6040,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", - "ring 0.17.5", + "ring 0.17.6", "rustls-webpki", "sct", ] @@ -6066,7 +6072,7 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.5", + "ring 0.17.6", "untrusted 0.9.0", ] @@ -6216,7 +6222,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.5", + "ring 0.17.6", "untrusted 0.9.0", ] @@ -6642,9 +6648,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", @@ -6792,9 +6798,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e349ed2ca56eff703d7c3ea013771bcbab9ad2ad39dddf863fc51d820329dc41" +checksum = "e2c7ad08db24862d5b787a94714ff6b047935c3e3f60af944ac969404debd7ff" dependencies = [ "paste", "proc-macro2", @@ -7613,9 +7619,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -7623,9 +7629,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", @@ -7638,9 +7644,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if", "js-sys", @@ -7650,9 +7656,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7660,9 +7666,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", @@ -7673,9 +7679,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "watchexec" @@ -7727,9 +7733,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -7741,7 +7747,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.5", + "ring 0.17.6", "untrusted 0.9.0", ] @@ -7830,6 +7836,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -7860,6 +7875,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -7872,6 +7902,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -7884,6 +7920,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -7896,6 +7938,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -7908,6 +7956,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -7920,6 +7974,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -7932,6 +7992,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -7944,6 +8010,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" version = "0.5.19" @@ -8011,18 +8083,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.26" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.26" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" dependencies = [ "proc-macro2", "quote", From 33268831422b8905d33540458712256bf7467c24 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 1 Dec 2023 17:10:30 +0100 Subject: [PATCH 0359/1963] chore: remove fork db snapshot (#6486) * chore: remove fork db snapshot * feat: add revert action * clippy happy --- crates/anvil/src/eth/backend/db.rs | 6 +-- crates/anvil/src/eth/backend/mem/fork_db.rs | 6 +-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 6 ++- crates/anvil/src/eth/backend/mem/mod.rs | 4 +- crates/anvil/tests/it/fork.rs | 45 +++++++++++++++++++ crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/backend/snapshot.rs | 19 ++++++++ crates/evm/core/src/fork/database.rs | 9 ++-- 8 files changed, 84 insertions(+), 13 deletions(-) diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 8d4fa9421fbe8..a36d7953abce8 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -10,7 +10,7 @@ use ethers::{ }; use foundry_common::{errors::FsPathError, types::ToAlloy}; use foundry_evm::{ - backend::{DatabaseError, DatabaseResult, MemDb, StateSnapshot}, + backend::{DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot}, fork::BlockchainDb, hashbrown::HashMap, revm::{ @@ -172,7 +172,7 @@ pub trait Db: /// Reverts a snapshot /// /// Returns `true` if the snapshot was reverted - fn revert(&mut self, snapshot: U256) -> bool; + fn revert(&mut self, snapshot: U256, action: RevertSnapshotAction) -> bool; /// Returns the state root if possible to compute fn maybe_state_root(&self) -> Option { @@ -208,7 +208,7 @@ impl + Send + Sync + Clone + fmt::Debug> D U256::zero() } - fn revert(&mut self, _snapshot: U256) -> bool { + fn revert(&mut self, _snapshot: U256, _action: RevertSnapshotAction) -> bool { false } diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 72895ac4a2fcb..41cf8cdaf7920 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -9,7 +9,7 @@ use crate::{ use ethers::{prelude::H256, types::BlockId}; use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ - backend::{DatabaseResult, StateSnapshot}, + backend::{DatabaseResult, RevertSnapshotAction, StateSnapshot}, fork::{database::ForkDbSnapshot, BlockchainDb}, revm::Database, }; @@ -68,8 +68,8 @@ impl Db for ForkedDatabase { self.insert_snapshot().to_ethers() } - fn revert(&mut self, id: U256) -> bool { - self.revert_snapshot(id.to_alloy()) + fn revert(&mut self, id: U256, action: RevertSnapshotAction) -> bool { + self.revert_snapshot(id.to_alloy(), action) } fn current_state(&self) -> StateDb { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index bb440488eff75..acf929e0c6584 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -17,6 +17,7 @@ use foundry_evm::{ }; // reexport for convenience +use foundry_evm::backend::RevertSnapshotAction; pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; impl Db for MemDb { @@ -71,8 +72,11 @@ impl Db for MemDb { id.to_ethers() } - fn revert(&mut self, id: U256) -> bool { + fn revert(&mut self, id: U256, action: RevertSnapshotAction) -> bool { if let Some(snapshot) = self.snapshots.remove(id.to_alloy()) { + if action.is_keep() { + self.snapshots.insert_at(snapshot.clone(), id.to_alloy()); + } self.inner = snapshot; trace!(target: "backend::memdb", "Reverted snapshot {}", id); true diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index b82591d1532c4..9cb75bd637416 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -58,7 +58,7 @@ use ethers::{ use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ - backend::{DatabaseError, DatabaseResult}, + backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, decode::decode_revert, inspectors::AccessListTracer, @@ -686,7 +686,7 @@ impl Backend { ..Default::default() }; } - Ok(self.db.write().await.revert(id)) + Ok(self.db.write().await.revert(id, RevertSnapshotAction::RevertRemove)) } pub fn list_snapshots(&self) -> BTreeMap { diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 490121afaacae..31ef39984df1d 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -289,6 +289,51 @@ async fn test_fork_snapshotting() { assert_eq!(block_number, provider.get_block_number().await.unwrap()); } +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_snapshotting_repeated() { + let (api, handle) = spawn(fork_config()).await; + let provider = handle.http_provider(); + + let snapshot = api.evm_snapshot().await.unwrap(); + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let from = accounts[0].address(); + let to = accounts[1].address(); + let block_number = provider.get_block_number().await.unwrap(); + + let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); + let balance_before = provider.get_balance(to, None).await.unwrap(); + let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + + let tx = TransactionRequest::new().to(to).value(amount).from(from); + + let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + + let nonce = provider.get_transaction_count(from, None).await.unwrap(); + assert_eq!(nonce, initial_nonce + 1); + let to_balance = provider.get_balance(to, None).await.unwrap(); + assert_eq!(balance_before.saturating_add(amount), to_balance); + + let _second_snapshot = api.evm_snapshot().await.unwrap(); + + assert!(api.evm_revert(snapshot).await.unwrap()); + + let nonce = provider.get_transaction_count(from, None).await.unwrap(); + assert_eq!(nonce, initial_nonce); + let balance = provider.get_balance(from, None).await.unwrap(); + assert_eq!(balance, handle.genesis_balance()); + let balance = provider.get_balance(to, None).await.unwrap(); + assert_eq!(balance, handle.genesis_balance()); + assert_eq!(block_number, provider.get_block_number().await.unwrap()); + + // invalidated + // TODO enable after + // assert!(!api.evm_revert(second_snapshot).await.unwrap()); + + // nothing is reverted, snapshot gone + assert!(!api.evm_revert(snapshot).await.unwrap()); +} + /// tests that the remote state and local state are kept separate. /// changes don't make into the read only Database that holds the remote state, which is flushed to /// a cache file. diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 168e9f645ad8d..8cc10795f3a0f 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -41,7 +41,7 @@ mod in_memory_db; pub use in_memory_db::{EmptyDBWrapper, FoundryEvmInMemoryDB, MemDb}; mod snapshot; -pub use snapshot::{BackendSnapshot, StateSnapshot}; +pub use snapshot::{BackendSnapshot, RevertSnapshotAction, StateSnapshot}; // A `revm::Database` that is used in forking mode type ForkDB = CacheDB; diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index 73ec8c5d7df76..8ce506d0f0714 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -42,3 +42,22 @@ impl BackendSnapshot { self.journaled_state.logs = current.logs.clone(); } } + +/// What to do when reverting a snapshot +/// +/// Whether to remove the snapshot or keep it +#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)] +pub enum RevertSnapshotAction { + /// Remove the snapshot after reverting + #[default] + RevertRemove, + /// Keep the snapshot after reverting + RevertKeep, +} + +impl RevertSnapshotAction { + /// Returns `true` if the action is to keep the snapshot + pub fn is_keep(&self) -> bool { + matches!(self, RevertSnapshotAction::RevertKeep) + } +} diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index f81a6a9d3b1f4..1c39b99e1f9e5 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -1,7 +1,7 @@ //! A revm database that forks off a remote client use crate::{ - backend::{DatabaseError, StateSnapshot}, + backend::{DatabaseError, RevertSnapshotAction, StateSnapshot}, fork::{BlockchainDb, SharedBackend}, snapshot::Snapshots, }; @@ -110,10 +110,13 @@ impl ForkedDatabase { id } - pub fn revert_snapshot(&mut self, id: U256) -> bool { + /// Removes the snapshot from the tracked snapshot and sets it as the current state + pub fn revert_snapshot(&mut self, id: U256, action: RevertSnapshotAction) -> bool { let snapshot = { self.snapshots().lock().remove_at(id) }; if let Some(snapshot) = snapshot { - self.snapshots().lock().insert_at(snapshot.clone(), id); + if action.is_keep() { + self.snapshots().lock().insert_at(snapshot.clone(), id); + } let ForkDbSnapshot { local, snapshot: StateSnapshot { accounts, storage, block_hashes }, From 8f50260eda9795aa1de0b5bb8002fd05a3b38917 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 1 Dec 2023 18:15:44 +0100 Subject: [PATCH 0360/1963] chore: add refs to ganache spec (#6483) * chore: add refs to ganache spec * update docs --- crates/anvil/core/src/eth/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 4f1a4e869024e..3303bcd0bb80f 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -499,6 +499,8 @@ pub enum EthRequest { // Ganache compatible calls /// Snapshot the state of the blockchain at the current block. + /// + /// Ref #[cfg_attr( feature = "serde", serde(rename = "anvil_snapshot", alias = "evm_snapshot", with = "empty_params") @@ -507,6 +509,8 @@ pub enum EthRequest { /// Revert the state of the blockchain to a previous snapshot. /// Takes a single parameter, which is the snapshot id to revert to. + /// + /// Ref #[cfg_attr( feature = "serde", serde( From f17d00b6721c774be3d879bfb6cc6905b3508dc3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 1 Dec 2023 18:17:27 +0100 Subject: [PATCH 0361/1963] fix: ensure prevrandao is set on reset fork (#6488) * fix: ensure prevrandao is set on reset fork * rustfmt --- crates/anvil/src/eth/backend/mem/mod.rs | 5 ++-- crates/anvil/tests/it/fork.rs | 32 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 9cb75bd637416..6dcf120d1cd72 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -398,11 +398,12 @@ impl Backend { timestamp: fork_block.timestamp.to_alloy(), gas_limit: fork_block.gas_limit.to_alloy(), difficulty: fork_block.difficulty.to_alloy(), - prevrandao: fork_block.mix_hash.map(|h| h.to_alloy()), + // ensures prevrandao is set + prevrandao: Some(fork_block.mix_hash.map(|h| h.to_alloy()).unwrap_or_default()), // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, - ..Default::default() + ..env.block.clone() }; self.time.reset((env.block.timestamp.to_ethers()).as_u64()); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 31ef39984df1d..444b234831511 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -944,3 +944,35 @@ async fn can_override_fork_chain_id() { let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id.as_u64(), chain_id_override); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_reset_moonbeam() { + crate::init_tracing(); + let (api, handle) = spawn( + fork_config() + .with_eth_rpc_url(Some("https://rpc.api.moonbeam.network".to_string())) + .with_fork_block_number(None::), + ) + .await; + let provider = handle.http_provider(); + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let from = accounts[0].address(); + + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + assert_eq!(tx.status, Some(1u64.into())); + + // reset to check timestamp works after resetting + api.anvil_reset(Some(Forking { + json_rpc_url: Some("https://rpc.api.moonbeam.network".to_string()), + block_number: None, + })) + .await + .unwrap(); + + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + assert_eq!(tx.status, Some(1u64.into())); +} From 96bc0dc7edfba72c09ae63fbe3b418816aed67ba Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 1 Dec 2023 18:59:17 +0100 Subject: [PATCH 0362/1963] docs: fix typos (#6490) --- crates/config/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/config/README.md b/crates/config/README.md index 3ab867949d196..6e4667293cf5b 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -5,7 +5,7 @@ sensible set of defaults. ## Profiles -Configurations can be arbitrarily namespaced by profiles. Foundry's default config is also named `default`, but can +Configurations can be arbitrarily namespaced with profiles. Foundry's default config is also named `default`, but you can arbitrarily name and configure profiles as you like and set the `FOUNDRY_PROFILE` environment variable to the selected profile's name. This results in foundry's tools (forge) preferring the values in the profile with the named that's set in `FOUNDRY_PROFILE`. But all custom profiles inherit from the `default` profile. @@ -298,5 +298,5 @@ supported, this means that `FOUNDRY_SRC` and `DAPP_SRC` are equivalent. Some exceptions to the above are [explicitly ignored](https://github.com/foundry-rs/foundry/blob/10440422e63aae660104e079dfccd5b0ae5fd720/config/src/lib.rs#L1539-L15522) due to security concerns. -Environment variables take precedence over values in `foundry.toml`. Values are parsed as loose form of TOML syntax. +Environment variables take precedence over values in `foundry.toml`. Values are parsed as a loose form of TOML syntax. Consider the following examples: From 8b7500b58a79628dcebf5987e267a46ceb7a3db0 Mon Sep 17 00:00:00 2001 From: 0xMemoryGrinder <35138272+0xMemoryGrinder@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:43:23 -0500 Subject: [PATCH 0363/1963] feat(forge): added --json argument to `forge build` command (#6465) * feat(forge): added --json argument to `forge build` command * refactor(forge): added standalone functions for suppress_compile* instead of an additional parameter * fix(forge): addec conflict constraint and renamed argument to format-json to avoid conflict with the test args * test(forge): added test for conflicts with silent argument * test(forge): added cli compile command with json argument test * rustfmt * lock --------- Co-authored-by: Matthias Seitz --- Cargo.toml | 1 + crates/common/src/compile.rs | 48 +++++++++++++++---- crates/forge/bin/cmd/build.rs | 21 +++++++- crates/forge/tests/cli/build.rs | 26 ++++++++++ crates/forge/tests/cli/main.rs | 1 + .../forge/tests/fixtures/compile_json.stdout | 20 ++++++++ 6 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 crates/forge/tests/cli/build.rs create mode 100644 crates/forge/tests/fixtures/compile_json.stdout diff --git a/Cargo.toml b/Cargo.toml index 194c6329b6250..d1ed69bc386b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -200,3 +200,4 @@ revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } + diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 873ece4349ea3..eb11f0ac167c2 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -284,14 +284,20 @@ pub fn compile_with_filter( ProjectCompiler::with_filter(print_names, print_sizes, skip).compile(project) } +/// Compiles the provided [`Project`] and does not throw if there's any compiler error +/// Doesn't print anything to stdout, thus is "suppressed". +pub fn try_suppress_compile(project: &Project) -> Result { + Ok(foundry_compilers::report::with_scoped( + &foundry_compilers::report::Report::new(NoReporter::default()), + || project.compile(), + )?) +} + /// Compiles the provided [`Project`], throws if there's any compiler error and logs whether /// compilation was successful or if there was a cache hit. /// Doesn't print anything to stdout, thus is "suppressed". pub fn suppress_compile(project: &Project) -> Result { - let output = foundry_compilers::report::with_scoped( - &foundry_compilers::report::Report::new(NoReporter::default()), - || project.compile(), - )?; + let output = try_suppress_compile(project)?; if output.has_compiler_errors() { eyre::bail!(output.to_string()) @@ -301,7 +307,7 @@ pub fn suppress_compile(project: &Project) -> Result { } /// Depending on whether the `skip` is empty this will [`suppress_compile_sparse`] or -/// [`suppress_compile`] +/// [`suppress_compile`] and throw if there's any compiler error pub fn suppress_compile_with_filter( project: &Project, skip: Vec, @@ -313,6 +319,33 @@ pub fn suppress_compile_with_filter( } } +/// Depending on whether the `skip` is empty this will [`suppress_compile_sparse`] or +/// [`suppress_compile`] and does not throw if there's any compiler error +pub fn suppress_compile_with_filter_json( + project: &Project, + skip: Vec, +) -> Result { + if skip.is_empty() { + try_suppress_compile(project) + } else { + try_suppress_compile_sparse(project, SkipBuildFilters(skip)) + } +} + +/// Compiles the provided [`Project`], +/// Doesn't print anything to stdout, thus is "suppressed". +/// +/// See [`Project::compile_sparse`] +pub fn try_suppress_compile_sparse( + project: &Project, + filter: F, +) -> Result { + Ok(foundry_compilers::report::with_scoped( + &foundry_compilers::report::Report::new(NoReporter::default()), + || project.compile_sparse(filter), + )?) +} + /// Compiles the provided [`Project`], throws if there's any compiler error and logs whether /// compilation was successful or if there was a cache hit. /// Doesn't print anything to stdout, thus is "suppressed". @@ -322,10 +355,7 @@ pub fn suppress_compile_sparse( project: &Project, filter: F, ) -> Result { - let output = foundry_compilers::report::with_scoped( - &foundry_compilers::report::Report::new(NoReporter::default()), - || project.compile_sparse(filter), - )?; + let output = try_suppress_compile_sparse(project, filter)?; if output.has_compiler_errors() { eyre::bail!(output.to_string()) diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 51f17e62398f2..2c583106e3a59 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -69,6 +69,12 @@ pub struct BuildArgs { #[clap(flatten)] #[serde(skip)] pub watch: WatchArgs, + + /// Output the compilation errors in the json format. + /// This is useful when you want to use the output in other tools. + #[clap(long, conflicts_with = "silent")] + #[serde(skip)] + pub format_json: bool, } impl BuildArgs { @@ -86,7 +92,12 @@ impl BuildArgs { let filters = self.skip.unwrap_or_default(); - if self.args.silent { + if self.format_json { + let output = compile::suppress_compile_with_filter_json(&project, filters)?; + let json = serde_json::to_string_pretty(&output.clone().output())?; + println!("{}", json); + Ok(output) + } else if self.args.silent { compile::suppress_compile_with_filter(&project, filters) } else { let compiler = ProjectCompiler::with_filter(self.names, self.sizes, filters); @@ -161,4 +172,12 @@ mod tests { let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "tests", "scripts"]); assert_eq!(args.skip, Some(vec![SkipBuildFilter::Tests, SkipBuildFilter::Scripts])); } + + #[test] + fn check_conflicts() { + let args: std::result::Result = + BuildArgs::try_parse_from(["foundry-cli", "--format-json", "--silent"]); + assert!(args.is_err()); + assert!(args.unwrap_err().kind() == clap::error::ErrorKind::ArgumentConflict); + } } diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs new file mode 100644 index 0000000000000..2e97cb7491a72 --- /dev/null +++ b/crates/forge/tests/cli/build.rs @@ -0,0 +1,26 @@ +use foundry_test_utils::{forgetest, util::OutputExt}; +use std::path::PathBuf; + +// tests that json is printed when --json is passed +forgetest!(compile_json, |prj, cmd| { + prj.add_source( + "jsonError", + r" +contract Dummy { + uint256 public number; + function something(uint256 newNumber) public { + number = newnumber; // error here + } +} +", + ) + .unwrap(); + + // set up command + cmd.args(["compile", "--format-json"]); + + // run command and assert + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/compile_json.stdout"), + ); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 71e2acc492980..f8c9dcbbf0cad 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -4,6 +4,7 @@ extern crate foundry_test_utils; pub mod constants; pub mod utils; +mod build; mod cache; mod cmd; mod config; diff --git a/crates/forge/tests/fixtures/compile_json.stdout b/crates/forge/tests/fixtures/compile_json.stdout new file mode 100644 index 0000000000000..f3eb33ea0d8cd --- /dev/null +++ b/crates/forge/tests/fixtures/compile_json.stdout @@ -0,0 +1,20 @@ +{ + "errors": [ + { + "sourceLocation": { + "file": "src/jsonError.sol", + "start": 184, + "end": 193 + }, + "type": "DeclarationError", + "component": "general", + "severity": "error", + "errorCode": "7576", + "message": "Undeclared identifier. Did you mean \"newNumber\"?", + "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n --> src/dummy.sol:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" + } + ], + "sources": {}, + "contracts": {}, + "build_infos": {} +} From 1dd86be6c2d24d51ed6223da0b7fdf500f20fcb6 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 1 Dec 2023 21:09:01 +0100 Subject: [PATCH 0364/1963] chore: bump ethers+chains (#6493) --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 18 +++++++++--------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4347ff35a1188..6725991000549 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9249bbabebe77f78e6a8f1984f9cd6151bb3297e484bb073cfae7a6dbd9f22" +checksum = "e7f12f8177eddf9275fa9ae5fd73b50cee062f9b1eb95ef435f28354c79ba386" dependencies = [ "num_enum", "serde", @@ -2082,7 +2082,7 @@ dependencies = [ [[package]] name = "ethers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "ethers-addressbook" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "ethers-core", "once_cell", @@ -2108,7 +2108,7 @@ dependencies = [ [[package]] name = "ethers-contract" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2126,7 +2126,7 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "Inflector", "const-hex", @@ -2149,7 +2149,7 @@ dependencies = [ [[package]] name = "ethers-contract-derive" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "Inflector", "const-hex", @@ -2164,7 +2164,7 @@ dependencies = [ [[package]] name = "ethers-core" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "arrayvec", "bytes", @@ -2193,7 +2193,7 @@ dependencies = [ [[package]] name = "ethers-etherscan" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "chrono", "ethers-core", @@ -2208,7 +2208,7 @@ dependencies = [ [[package]] name = "ethers-middleware" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "async-trait", "auto_impl", @@ -2233,7 +2233,7 @@ dependencies = [ [[package]] name = "ethers-providers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "async-trait", "auto_impl", @@ -2271,7 +2271,7 @@ dependencies = [ [[package]] name = "ethers-signers" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "async-trait", "coins-bip32", @@ -2299,7 +2299,7 @@ dependencies = [ [[package]] name = "ethers-solc" version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=2e93fa7e0f21a0f4008dae388bb8c59ec26aab32#2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" +source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" dependencies = [ "cfg-if", "const-hex", diff --git a/Cargo.toml b/Cargo.toml index d1ed69bc386b3..19a26c63bb2ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,7 +148,7 @@ alloy-json-abi = "0.5.0" alloy-sol-types = "0.5.0" syn-solidity = "0.5.0" -alloy-chains = "0.1.3" +alloy-chains = "0.1.4" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" @@ -187,14 +187,14 @@ tower-http = "0.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "2e93fa7e0f21a0f4008dae388bb8c59ec26aab32" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } From 220f54000b925d25b4dd367c6fef2256f418d032 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:09:40 +0100 Subject: [PATCH 0365/1963] chore: debugger improvements (#6491) * chore: build op effects map at compile time * refactor: automate opcode params somewhat --- crates/debugger/src/lib.rs | 29 +-- crates/debugger/src/op.rs | 317 ++++++++++++++++++++++++++++++ crates/debugger/src/op_effects.rs | 134 ------------- 3 files changed, 332 insertions(+), 148 deletions(-) create mode 100644 crates/debugger/src/op.rs delete mode 100644 crates/debugger/src/op_effects.rs diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index d93ab99846b87..3e4616a799809 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -1,3 +1,7 @@ +//! # foundry-debugger +//! +//! Interactive Solidity TUI debugger. + #![warn(unused_crate_dependencies)] #[macro_use] @@ -49,8 +53,8 @@ pub enum TUIExitReason { CharExit, } -mod op_effects; -use op_effects::stack_indices_affected; +mod op; +use op::OpcodeParam; mod debugger; pub use debugger::*; @@ -802,12 +806,11 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k Block::default().title(format!("Stack: {}", stack.len())).borders(Borders::ALL); let min_len = usize::max(format!("{}", stack.len()).len(), 2); - let indices_affected = - if let Instruction::OpCode(op) = debug_steps[current_step].instruction { - stack_indices_affected(op) - } else { - vec![] - }; + let params = if let Instruction::OpCode(op) = debug_steps[current_step].instruction { + OpcodeParam::of(op) + } else { + &[] + }; let text: Vec = stack .iter() @@ -815,16 +818,14 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k .enumerate() .skip(draw_memory.current_stack_startline) .map(|(i, stack_item)| { - let affected = - indices_affected.iter().find(|(affected_index, _name)| *affected_index == i); - + let param = params.iter().find(|param| param.index == i); let mut words: Vec = (0..32) .rev() .map(|i| stack_item.byte(i)) .map(|byte| { Span::styled( format!("{byte:02x} "), - if affected.is_some() { + if param.is_some() { Style::default().fg(Color::Cyan) } else if byte == 0 { // this improves compatibility across terminals by not combining @@ -838,8 +839,8 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k .collect(); if stack_labels { - if let Some((_, name)) = affected { - words.push(Span::raw(format!("| {name}"))); + if let Some(param) = param { + words.push(Span::raw(format!("| {}", param.name))); } else { words.push(Span::raw("| ".to_string())); } diff --git a/crates/debugger/src/op.rs b/crates/debugger/src/op.rs new file mode 100644 index 0000000000000..a6755483678aa --- /dev/null +++ b/crates/debugger/src/op.rs @@ -0,0 +1,317 @@ +/// Named parameter of an EVM opcode. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct OpcodeParam { + /// The name of the parameter. + pub name: &'static str, + /// The index of the parameter on the stack. This is relative to the top of the stack. + pub index: usize, +} + +impl OpcodeParam { + /// Returns the list of named parameters for the given opcode. + #[inline] + pub fn of(op: u8) -> &'static [Self] { + MAP[op as usize] + } +} + +static MAP: [&[OpcodeParam]; 256] = { + let mut table = [[].as_slice(); 256]; + let mut i = 0; + while i < 256 { + table[i] = map_opcode(i as u8); + i += 1; + } + table +}; + +const fn map_opcode(op: u8) -> &'static [OpcodeParam] { + macro_rules! map { + ($($op:literal($($idx:literal : $name:literal),* $(,)?)),* $(,)?) => { + match op { + $($op => &[ + $(OpcodeParam { + name: $name, + index: $idx, + }),* + ]),* + } + }; + } + + // https://www.evm.codes + // https://github.com/smlxl/evm.codes + // https://github.com/smlxl/evm.codes/blob/HEAD/opcodes.json + // jq -rf opcodes.jq opcodes.json + /* + def mkargs(input): + input | split(" | ") | to_entries | map("\(.key): \(.value)") | join(", "); + + to_entries[] | "0x\(.key)(\(mkargs(.value.input)))," + */ + map! { + 0x00(), + 0x01(0: "a", 1: "b"), + 0x02(0: "a", 1: "b"), + 0x03(0: "a", 1: "b"), + 0x04(0: "a", 1: "b"), + 0x05(0: "a", 1: "b"), + 0x06(0: "a", 1: "b"), + 0x07(0: "a", 1: "b"), + 0x08(0: "a", 1: "b", 2: "N"), + 0x09(0: "a", 1: "b", 2: "N"), + 0x0a(0: "a", 1: "exponent"), + 0x0b(0: "b", 1: "x"), + 0x0c(), + 0x0d(), + 0x0e(), + 0x0f(), + 0x10(0: "a", 1: "b"), + 0x11(0: "a", 1: "b"), + 0x12(0: "a", 1: "b"), + 0x13(0: "a", 1: "b"), + 0x14(0: "a", 1: "b"), + 0x15(0: "a"), + 0x16(0: "a", 1: "b"), + 0x17(0: "a", 1: "b"), + 0x18(0: "a", 1: "b"), + 0x19(0: "a"), + 0x1a(0: "i", 1: "x"), + 0x1b(0: "shift", 1: "value"), + 0x1c(0: "shift", 1: "value"), + 0x1d(0: "shift", 1: "value"), + 0x1e(), + 0x1f(), + 0x20(0: "offset", 1: "size"), + 0x21(), + 0x22(), + 0x23(), + 0x24(), + 0x25(), + 0x26(), + 0x27(), + 0x28(), + 0x29(), + 0x2a(), + 0x2b(), + 0x2c(), + 0x2d(), + 0x2e(), + 0x2f(), + 0x30(), + 0x31(0: "address"), + 0x32(), + 0x33(), + 0x34(), + 0x35(0: "i"), + 0x36(), + 0x37(0: "destOffset", 1: "offset", 2: "size"), + 0x38(), + 0x39(0: "destOffset", 1: "offset", 2: "size"), + 0x3a(), + 0x3b(0: "address"), + 0x3c(0: "address", 1: "destOffset", 2: "offset", 3: "size"), + 0x3d(), + 0x3e(0: "destOffset", 1: "offset", 2: "size"), + 0x3f(0: "address"), + 0x40(0: "blockNumber"), + 0x41(), + 0x42(), + 0x43(), + 0x44(), + 0x45(), + 0x46(), + 0x47(), + 0x48(), + 0x49(), + 0x4a(), + 0x4b(), + 0x4c(), + 0x4d(), + 0x4e(), + 0x4f(), + 0x50(0: "y"), + 0x51(0: "offset"), + 0x52(0: "offset", 1: "value"), + 0x53(0: "offset", 1: "value"), + 0x54(0: "key"), + 0x55(0: "key", 1: "value"), + 0x56(0: "counter"), + 0x57(0: "counter", 1: "b"), + 0x58(), + 0x59(), + 0x5a(), + 0x5b(), + 0x5c(), + 0x5d(), + 0x5e(), + + // PUSHN + 0x5f(), + 0x60(), + 0x61(), + 0x62(), + 0x63(), + 0x64(), + 0x65(), + 0x66(), + 0x67(), + 0x68(), + 0x69(), + 0x6a(), + 0x6b(), + 0x6c(), + 0x6d(), + 0x6e(), + 0x6f(), + 0x70(), + 0x71(), + 0x72(), + 0x73(), + 0x74(), + 0x75(), + 0x76(), + 0x77(), + 0x78(), + 0x79(), + 0x7a(), + 0x7b(), + 0x7c(), + 0x7d(), + 0x7e(), + 0x7f(), + + // DUPN + 0x80(0x00: "dup_value"), + 0x81(0x01: "dup_value"), + 0x82(0x02: "dup_value"), + 0x83(0x03: "dup_value"), + 0x84(0x04: "dup_value"), + 0x85(0x05: "dup_value"), + 0x86(0x06: "dup_value"), + 0x87(0x07: "dup_value"), + 0x88(0x08: "dup_value"), + 0x89(0x09: "dup_value"), + 0x8a(0x0a: "dup_value"), + 0x8b(0x0b: "dup_value"), + 0x8c(0x0c: "dup_value"), + 0x8d(0x0d: "dup_value"), + 0x8e(0x0e: "dup_value"), + 0x8f(0x0f: "dup_value"), + + // SWAPN + 0x90(0: "a", 0x01: "swap_value"), + 0x91(0: "a", 0x02: "swap_value"), + 0x92(0: "a", 0x03: "swap_value"), + 0x93(0: "a", 0x04: "swap_value"), + 0x94(0: "a", 0x05: "swap_value"), + 0x95(0: "a", 0x06: "swap_value"), + 0x96(0: "a", 0x07: "swap_value"), + 0x97(0: "a", 0x08: "swap_value"), + 0x98(0: "a", 0x09: "swap_value"), + 0x99(0: "a", 0x0a: "swap_value"), + 0x9a(0: "a", 0x0b: "swap_value"), + 0x9b(0: "a", 0x0c: "swap_value"), + 0x9c(0: "a", 0x0d: "swap_value"), + 0x9d(0: "a", 0x0e: "swap_value"), + 0x9e(0: "a", 0x0f: "swap_value"), + 0x9f(0: "a", 0x10: "swap_value"), + + 0xa0(0: "offset", 1: "size"), + 0xa1(0: "offset", 1: "size", 2: "topic"), + 0xa2(0: "offset", 1: "size", 2: "topic1", 3: "topic2"), + 0xa3(0: "offset", 1: "size", 2: "topic1", 3: "topic2", 4: "topic3"), + 0xa4(0: "offset", 1: "size", 2: "topic1", 3: "topic2", 4: "topic3", 5: "topic4"), + 0xa5(), + 0xa6(), + 0xa7(), + 0xa8(), + 0xa9(), + 0xaa(), + 0xab(), + 0xac(), + 0xad(), + 0xae(), + 0xaf(), + 0xb0(), + 0xb1(), + 0xb2(), + 0xb3(), + 0xb4(), + 0xb5(), + 0xb6(), + 0xb7(), + 0xb8(), + 0xb9(), + 0xba(), + 0xbb(), + 0xbc(), + 0xbd(), + 0xbe(), + 0xbf(), + 0xc0(), + 0xc1(), + 0xc2(), + 0xc3(), + 0xc4(), + 0xc5(), + 0xc6(), + 0xc7(), + 0xc8(), + 0xc9(), + 0xca(), + 0xcb(), + 0xcc(), + 0xcd(), + 0xce(), + 0xcf(), + 0xd0(), + 0xd1(), + 0xd2(), + 0xd3(), + 0xd4(), + 0xd5(), + 0xd6(), + 0xd7(), + 0xd8(), + 0xd9(), + 0xda(), + 0xdb(), + 0xdc(), + 0xdd(), + 0xde(), + 0xdf(), + 0xe0(), + 0xe1(), + 0xe2(), + 0xe3(), + 0xe4(), + 0xe5(), + 0xe6(), + 0xe7(), + 0xe8(), + 0xe9(), + 0xea(), + 0xeb(), + 0xec(), + 0xed(), + 0xee(), + 0xef(), + 0xf0(0: "value", 1: "offset", 2: "size"), + 0xf1(0: "gas", 1: "address", 2: "value", 3: "argsOffset", 4: "argsSize", 5: "retOffset", 6: "retSize"), + 0xf2(0: "gas", 1: "address", 2: "value", 3: "argsOffset", 4: "argsSize", 5: "retOffset", 6: "retSize"), + 0xf3(0: "offset", 1: "size"), + 0xf4(0: "gas", 1: "address", 2: "argsOffset", 3: "argsSize", 4: "retOffset", 5: "retSize"), + 0xf5(0: "value", 1: "offset", 2: "size", 3: "salt"), + 0xf6(), + 0xf7(), + 0xf8(), + 0xf9(), + 0xfa(0: "gas", 1: "address", 2: "argsOffset", 3: "argsSize", 4: "retOffset", 5: "retSize"), + 0xfb(), + 0xfc(), + 0xfd(0: "offset", 1: "size"), + 0xfe(), + 0xff(0: "address"), + } +} diff --git a/crates/debugger/src/op_effects.rs b/crates/debugger/src/op_effects.rs deleted file mode 100644 index ad1b9fd0d0515..0000000000000 --- a/crates/debugger/src/op_effects.rs +++ /dev/null @@ -1,134 +0,0 @@ -/// Maps an opcode and returns a vector of named affected indices -pub fn stack_indices_affected(op: u8) -> Vec<(usize, &'static str)> { - match op { - 0x01 => vec![(0, "a"), (1, "b")], - 0x02 => vec![(0, "a"), (1, "b")], - 0x03 => vec![(0, "a"), (1, "b")], - 0x04 => vec![(0, "a"), (1, "b")], - 0x05 => vec![(0, "a"), (1, "b")], - 0x06 => vec![(0, "a"), (1, "b")], - 0x07 => vec![(0, "a"), (1, "b")], - 0x08 => vec![(0, "a"), (1, "b"), (2, "N")], - 0x09 => vec![(0, "a"), (1, "b"), (2, "N")], - 0x0a => vec![(0, "a"), (1, "exponent")], - 0x0b => vec![(0, "b"), (1, "x")], - 0x10 => vec![(0, "a"), (1, "b")], - 0x11 => vec![(0, "a"), (1, "b")], - 0x12 => vec![(0, "a"), (1, "b")], - 0x13 => vec![(0, "a"), (1, "b")], - 0x14 => vec![(0, "a"), (1, "b")], - 0x15 => vec![(0, "a")], - 0x16 => vec![(0, "a"), (1, "b")], - 0x17 => vec![(0, "a"), (1, "b")], - 0x18 => vec![(0, "a"), (1, "b")], - 0x19 => vec![(0, "a")], - 0x1a => vec![(0, "i"), (1, "x")], - 0x1b => vec![(0, "shift"), (1, "value")], - 0x1c => vec![(0, "shift"), (1, "value")], - 0x1d => vec![(0, "shift"), (1, "value")], - 0x20 => vec![(0, "offset"), (1, "size")], - 0x31 => vec![(0, "address")], - 0x35 => vec![(0, "offset")], - 0x37 => vec![(0, "destOffset"), (1, "offset"), (2, "size")], - 0x39 => vec![(0, "destOffset"), (1, "offset"), (2, "size")], - 0x3b => vec![(0, "address")], - 0x3c => vec![(0, "address"), (1, "destOffset"), (2, "offset"), (3, "size")], - 0x3e => vec![(0, "destOffset"), (1, "offset"), (2, "size")], - 0x3f => vec![(0, "address")], - 0x40 => vec![(0, "blockNumber")], - 0x50 => vec![(0, "y")], - 0x51 => vec![(0, "offset")], - 0x52 => vec![(0, "offset"), (1, "value")], - 0x53 => vec![(0, "offset"), (1, "value")], - 0x54 => vec![(0, "key")], - 0x55 => vec![(0, "key"), (1, "value")], - 0x56 => vec![(0, "jump_to")], - 0x57 => vec![(0, "jump_to"), (1, "if")], - 0x5c => vec![(0, "key")], - 0x5d => vec![(0, "key"), (1, "value")], - 0x80 => vec![(0, "dup_value")], - 0x81 => vec![(1, "dup_value")], - 0x82 => vec![(2, "dup_value")], - 0x83 => vec![(3, "dup_value")], - 0x84 => vec![(4, "dup_value")], - 0x85 => vec![(5, "dup_value")], - 0x86 => vec![(6, "dup_value")], - 0x87 => vec![(7, "dup_value")], - 0x88 => vec![(8, "dup_value")], - 0x89 => vec![(9, "dup_value")], - 0x8a => vec![(10, "dup_value")], - 0x8b => vec![(11, "dup_value")], - 0x8c => vec![(12, "dup_value")], - 0x8d => vec![(13, "dup_value")], - 0x8e => vec![(14, "dup_value")], - 0x8f => vec![(15, "dup_value")], - 0x90 => vec![(0, "a"), (1, "swap_value")], - 0x91 => vec![(0, "a"), (2, "swap_value")], - 0x92 => vec![(0, "a"), (3, "swap_value")], - 0x93 => vec![(0, "a"), (4, "swap_value")], - 0x94 => vec![(0, "a"), (5, "swap_value")], - 0x95 => vec![(0, "a"), (6, "swap_value")], - 0x96 => vec![(0, "a"), (7, "swap_value")], - 0x97 => vec![(0, "a"), (8, "swap_value")], - 0x98 => vec![(0, "a"), (9, "swap_value")], - 0x99 => vec![(0, "a"), (10, "swap_value")], - 0x9a => vec![(0, "a"), (11, "swap_value")], - 0x9b => vec![(0, "a"), (12, "swap_value")], - 0x9c => vec![(0, "a"), (13, "swap_value")], - 0x9d => vec![(0, "a"), (14, "swap_value")], - 0x9e => vec![(0, "a"), (15, "swap_value")], - 0x9f => vec![(0, "a"), (16, "swap_value")], - 0xa0 => vec![(0, "offset"), (1, "size")], - 0xa1 => vec![(0, "offset"), (1, "size"), (2, "topic")], - 0xa2 => vec![(0, "offset"), (1, "size"), (2, "topic1"), (3, "topic2")], - 0xa3 => vec![(0, "offset"), (1, "size"), (2, "topic1"), (3, "topic2"), (4, "topic3")], - 0xa4 => vec![ - (0, "offset"), - (1, "size"), - (2, "topic1"), - (3, "topic2"), - (4, "topic3"), - (5, "topic4"), - ], - 0xf0 => vec![(0, "value"), (1, "offset"), (2, "size")], - 0xf1 => vec![ - (0, "gas"), - (1, "address"), - (2, "value"), - (3, "argsOffset"), - (4, "argsSize"), - (5, "retOffset"), - (6, "retSize"), - ], - 0xf2 => vec![ - (0, "gas"), - (1, "address"), - (2, "value"), - (3, "argsOffset"), - (4, "argsSize"), - (5, "retOffset"), - (6, "retSize"), - ], - 0xf3 => vec![(0, "offset"), (1, "size")], - 0xf4 => vec![ - (0, "gas"), - (1, "address"), - (2, "argsOffset"), - (3, "argsSize"), - (4, "retOffset"), - (5, "retSize"), - ], - 0xf5 => vec![(0, "value"), (1, "offset"), (2, "size"), (3, "salt")], - 0xfa => vec![ - (0, "gas"), - (1, "address"), - (2, "argsOffset"), - (3, "argsSize"), - (4, "retOffset"), - (5, "retSize"), - ], - 0xfd => vec![(0, "offset"), (1, "size")], - 0xff => vec![(0, "address")], - _ => vec![], - } -} From 5b7e4cb3c882b28f3c32ba580de27ce7381f415a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:58:51 +0100 Subject: [PATCH 0366/1963] chore: debugger improvements 2 (#6494) * feat: debugger builder and clean up terminal handling * typos --- crates/anvil/src/service.rs | 2 +- crates/cli/src/utils/cmd.rs | 15 +- crates/debugger/src/builder.rs | 95 ++ crates/debugger/src/debugger.rs | 48 - crates/debugger/src/lib.rs | 1386 +----------------------- crates/debugger/src/tui.rs | 1400 +++++++++++++++++++++++++ crates/evm/core/src/debug.rs | 17 +- crates/evm/core/src/fork/backend.rs | 2 +- crates/evm/core/src/fork/multi.rs | 2 +- crates/forge/bin/cmd/create.rs | 2 +- crates/forge/bin/cmd/script/cmd.rs | 16 +- crates/forge/bin/cmd/script/runner.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 17 +- 13 files changed, 1541 insertions(+), 1463 deletions(-) create mode 100644 crates/debugger/src/builder.rs delete mode 100644 crates/debugger/src/debugger.rs create mode 100644 crates/debugger/src/tui.rs diff --git a/crates/anvil/src/service.rs b/crates/anvil/src/service.rs index f81d6f6cb1526..18ee20d998596 100644 --- a/crates/anvil/src/service.rs +++ b/crates/anvil/src/service.rs @@ -106,7 +106,7 @@ type BlockMiningFuture = Pin)> + Send + Sync>>; /// A type that exclusively mines one block at a time -#[must_use = "BlockProducer does nothing unless polled"] +#[must_use = "streams do nothing unless polled"] struct BlockProducer { /// Holds the backend if no block is being mined idle_backend: Option>, diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index bb8227f1843f7..0631ec974a639 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -10,7 +10,7 @@ use foundry_compilers::{ Artifact, ProjectCompileOutput, }; use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, NamedChain}; -use foundry_debugger::DebuggerArgs; +use foundry_debugger::DebuggerBuilder; use foundry_evm::{ debug::DebugArena, executors::{DeployResult, EvmError, ExecutionErr, RawCallResult}, @@ -404,13 +404,12 @@ pub async fn handle_traces( if debug { let sources = etherscan_identifier.get_compiled_contracts().await?; - let debugger = DebuggerArgs { - debug: vec![result.debug], - decoder: &decoder, - sources, - breakpoints: Default::default(), - }; - debugger.run()?; + let mut debugger = DebuggerBuilder::new() + .debug_arena(&result.debug) + .decoder(&decoder) + .sources(sources) + .build()?; + debugger.try_run()?; } else { print_traces(&mut result, &decoder, verbose).await?; } diff --git a/crates/debugger/src/builder.rs b/crates/debugger/src/builder.rs new file mode 100644 index 0000000000000..ff2721ec7ce7b --- /dev/null +++ b/crates/debugger/src/builder.rs @@ -0,0 +1,95 @@ +use crate::Debugger; +use alloy_primitives::Address; +use eyre::Result; +use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; +use foundry_evm_core::{ + debug::{DebugArena, DebugStep}, + utils::CallKind, +}; +use foundry_evm_traces::CallTraceDecoder; +use std::collections::HashMap; + +/// Debugger builder. +#[derive(Debug, Default)] +#[must_use = "builders do nothing unless you call `build` on them"] +pub struct DebuggerBuilder { + /// Debug traces returned from the EVM execution. + debug_arena: Vec<(Address, Vec, CallKind)>, + /// Identified contracts. + identified_contracts: HashMap, + /// Map of source files. + sources: ContractSources, + /// Map of the debugger breakpoints. + breakpoints: Breakpoints, +} + +impl DebuggerBuilder { + /// Creates a new debugger builder. + #[inline] + pub fn new() -> Self { + Self::default() + } + + /// Extends the debug arena. + #[inline] + pub fn debug_arenas(mut self, arena: &[DebugArena]) -> Self { + for arena in arena { + self = self.debug_arena(arena); + } + self + } + + /// Extends the debug arena. + #[inline] + pub fn debug_arena(mut self, arena: &DebugArena) -> Self { + arena.flatten_to(0, &mut self.debug_arena); + self + } + + /// Extends the identified contracts from multiple decoders. + #[inline] + pub fn decoders(mut self, decoders: &[CallTraceDecoder]) -> Self { + for decoder in decoders { + self = self.decoder(decoder); + } + self + } + + /// Extends the identified contracts from a decoder. + #[inline] + pub fn decoder(self, decoder: &CallTraceDecoder) -> Self { + let c = decoder.contracts.iter().map(|(k, v)| (*k, get_contract_name(v).to_string())); + self.identified_contracts(c) + } + + /// Extends the identified contracts. + #[inline] + pub fn identified_contracts( + mut self, + identified_contracts: impl IntoIterator, + ) -> Self { + self.identified_contracts.extend(identified_contracts); + self + } + + /// Sets the sources for the debugger. + #[inline] + pub fn sources(mut self, sources: ContractSources) -> Self { + self.sources = sources; + self + } + + /// Sets the breakpoints for the debugger. + #[inline] + pub fn breakpoints(mut self, breakpoints: Breakpoints) -> Self { + self.breakpoints = breakpoints; + self + } + + /// Builds the debugger. + #[inline] + pub fn build(self) -> Result { + let Self { debug_arena, identified_contracts, sources, breakpoints } = self; + Debugger::new(debug_arena, 0, identified_contracts, sources, breakpoints) + } +} diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs deleted file mode 100644 index 10893a6589492..0000000000000 --- a/crates/debugger/src/debugger.rs +++ /dev/null @@ -1,48 +0,0 @@ -use crate::{TUIExitReason, Tui, Ui}; -use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm_core::debug::DebugArena; -use foundry_evm_traces::CallTraceDecoder; - -/// Standardized way of firing up the debugger -pub struct DebuggerArgs<'a> { - /// debug traces returned from the execution - pub debug: Vec, - /// trace decoder - pub decoder: &'a CallTraceDecoder, - /// map of source files - pub sources: ContractSources, - /// map of the debugger breakpoints - pub breakpoints: Breakpoints, -} - -impl DebuggerArgs<'_> { - /// Starts the debugger - pub fn run(&self) -> eyre::Result { - trace!(target: "debugger", "running debugger"); - let flattened = self - .debug - .last() - .map(|arena| arena.flatten(0)) - .ok_or_else(|| { - error!(target: "debugger", debug_entries=?self.debug.len(), "Failed to get debug information for arena"); - eyre::eyre!("Unable to collected debug information") - })?; - - let identified_contracts = self - .decoder - .contracts - .iter() - .map(|(addr, identifier)| ((*addr), get_contract_name(identifier).to_string())) - .collect(); - - let tui = Tui::new( - flattened.into_iter().map(|i| (i.0, i.1, i.2)).collect(), - 0, - identified_contracts, - self.sources.clone(), - self.breakpoints.clone(), - )?; - - tui.start() - } -} diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 3e4616a799809..db5a012eb5990 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -7,1388 +7,10 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{Address, U256}; -use crossterm::{ - event::{ - self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, - MouseEvent, MouseEventKind, - }, - execute, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, -}; -use eyre::Result; -use foundry_common::{compile::ContractSources, evm::Breakpoints}; -use foundry_evm_core::{ - debug::{DebugStep, Instruction}, - utils::{build_pc_ic_map, CallKind, PCICMap}, -}; -use ratatui::{ - backend::CrosstermBackend, - layout::{Alignment, Constraint, Direction, Layout, Rect}, - style::{Color, Modifier, Style}, - terminal::Frame, - text::{Line, Span, Text}, - widgets::{Block, Borders, Paragraph, Wrap}, - Terminal, -}; -use revm::{interpreter::opcode, primitives::SpecId}; -use std::{ - cmp::{max, min}, - collections::{BTreeMap, HashMap, VecDeque}, - io, - sync::mpsc, - thread, - time::{Duration, Instant}, -}; - -/// Trait for starting the UI -pub trait Ui { - /// Start the agent that will now take over - fn start(self) -> Result; -} - -/// Used to indicate why the UI stopped -pub enum TUIExitReason { - /// Exit using - CharExit, -} +mod builder; +pub use builder::DebuggerBuilder; mod op; -use op::OpcodeParam; - -mod debugger; -pub use debugger::*; - -pub struct Tui { - debug_arena: Vec<(Address, Vec, CallKind)>, - terminal: Terminal>, - /// Buffer for keys prior to execution, i.e. '10' + 'k' => move up 10 operations - key_buffer: String, - /// Current step in the debug steps - current_step: usize, - identified_contracts: HashMap, - /// Source map of contract sources - contracts_sources: ContractSources, - /// A mapping of source -> (PC -> IC map for deploy code, PC -> IC map for runtime code) - pc_ic_maps: BTreeMap, - breakpoints: Breakpoints, -} - -impl Tui { - /// Create a tui - #[allow(unused_must_use)] - pub fn new( - debug_arena: Vec<(Address, Vec, CallKind)>, - current_step: usize, - identified_contracts: HashMap, - contracts_sources: ContractSources, - breakpoints: Breakpoints, - ) -> Result { - enable_raw_mode()?; - let mut stdout = io::stdout(); - execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?; - let backend = CrosstermBackend::new(stdout); - let mut terminal = Terminal::new(backend)?; - terminal.hide_cursor(); - let pc_ic_maps = contracts_sources - .0 - .iter() - .flat_map(|(contract_name, files_sources)| { - files_sources.iter().filter_map(|(_, (_, contract))| { - Some(( - contract_name.clone(), - ( - build_pc_ic_map( - SpecId::LATEST, - contract.bytecode.object.as_bytes()?.as_ref(), - ), - build_pc_ic_map( - SpecId::LATEST, - contract - .deployed_bytecode - .bytecode - .as_ref()? - .object - .as_bytes()? - .as_ref(), - ), - ), - )) - }) - }) - .collect(); - Ok(Tui { - debug_arena, - terminal, - key_buffer: String::new(), - current_step, - identified_contracts, - contracts_sources, - pc_ic_maps, - breakpoints, - }) - } - - /// Grab number from buffer. Used for something like '10k' to move up 10 operations - fn buffer_as_number(buffer: &str, default_value: usize) -> usize { - if let Ok(num) = buffer.parse() { - if num >= 1 { - num - } else { - default_value - } - } else { - default_value - } - } - - /// Create layout and subcomponents - #[allow(clippy::too_many_arguments)] - fn draw_layout( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - call_kind: CallKind, - draw_memory: &mut DrawMemory, - stack_labels: bool, - mem_utf: bool, - show_shortcuts: bool, - ) { - let total_size = f.size(); - if total_size.width < 225 { - Tui::vertical_layout( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps, - opcode_list, - current_step, - call_kind, - draw_memory, - stack_labels, - mem_utf, - show_shortcuts, - ); - } else { - Tui::square_layout( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps, - opcode_list, - current_step, - call_kind, - draw_memory, - stack_labels, - mem_utf, - show_shortcuts, - ); - } - } - - #[allow(clippy::too_many_arguments)] - fn vertical_layout( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - call_kind: CallKind, - draw_memory: &mut DrawMemory, - stack_labels: bool, - mem_utf: bool, - show_shortcuts: bool, - ) { - let total_size = f.size(); - let h_height = if show_shortcuts { 4 } else { 0 }; - - if let [app, footer] = Layout::default() - .constraints( - [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)].as_ref(), - ) - .direction(Direction::Vertical) - .split(total_size)[..] - { - if let [op_pane, stack_pane, memory_pane, src_pane] = Layout::default() - .direction(Direction::Vertical) - .constraints( - [ - Constraint::Ratio(1, 6), - Constraint::Ratio(1, 6), - Constraint::Ratio(1, 6), - Constraint::Ratio(3, 6), - ] - .as_ref(), - ) - .split(app)[..] - { - if show_shortcuts { - Tui::draw_footer(f, footer); - } - Tui::draw_src( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps[current_step].pc, - call_kind, - src_pane, - ); - Tui::draw_op_list( - f, - address, - debug_steps, - opcode_list, - current_step, - draw_memory, - op_pane, - ); - Tui::draw_stack( - f, - debug_steps, - current_step, - stack_pane, - stack_labels, - draw_memory, - ); - Tui::draw_memory(f, debug_steps, current_step, memory_pane, mem_utf, draw_memory); - } else { - panic!("unable to create vertical panes") - } - } else { - panic!("unable to create footer / app") - }; - } - - #[allow(clippy::too_many_arguments)] - fn square_layout( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - call_kind: CallKind, - draw_memory: &mut DrawMemory, - stack_labels: bool, - mem_utf: bool, - show_shortcuts: bool, - ) { - let total_size = f.size(); - let h_height = if show_shortcuts { 4 } else { 0 }; - - // split in 2 vertically - - if let [app, footer] = Layout::default() - .direction(Direction::Vertical) - .constraints( - [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)].as_ref(), - ) - .split(total_size)[..] - { - if let [left_pane, right_pane] = Layout::default() - .direction(Direction::Horizontal) - .constraints([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)].as_ref()) - .split(app)[..] - { - // split right pane horizontally to construct stack and memory - if let [op_pane, src_pane] = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)].as_ref()) - .split(left_pane)[..] - { - if let [stack_pane, memory_pane] = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)].as_ref()) - .split(right_pane)[..] - { - if show_shortcuts { - Tui::draw_footer(f, footer) - }; - Tui::draw_src( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps[current_step].pc, - call_kind, - src_pane, - ); - Tui::draw_op_list( - f, - address, - debug_steps, - opcode_list, - current_step, - draw_memory, - op_pane, - ); - Tui::draw_stack( - f, - debug_steps, - current_step, - stack_pane, - stack_labels, - draw_memory, - ); - Tui::draw_memory( - f, - debug_steps, - current_step, - memory_pane, - mem_utf, - draw_memory, - ); - } - } else { - panic!("Couldn't generate horizontal split layout 1:2."); - } - } else { - panic!("Couldn't generate vertical split layout 1:2."); - } - } else { - panic!("Couldn't generate application & footer") - } - } - - fn draw_footer(f: &mut Frame<'_>, area: Rect) { - let block_controls = Block::default(); - - let text_output = vec![Line::from(Span::styled( - "[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end", Style::default().add_modifier(Modifier::DIM))), -Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | [']: goto breakpoint | [h] toggle help", Style::default().add_modifier(Modifier::DIM)))]; - - let paragraph = Paragraph::new(text_output) - .block(block_controls) - .alignment(Alignment::Center) - .wrap(Wrap { trim: false }); - - f.render_widget(paragraph, area); - } - - #[allow(clippy::too_many_arguments)] - fn draw_src( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - pc: usize, - call_kind: CallKind, - area: Rect, - ) { - let block_source_code = Block::default() - .title(match call_kind { - CallKind::Create | CallKind::Create2 => "Contract creation", - CallKind::Call => "Contract call", - CallKind::StaticCall => "Contract staticcall", - CallKind::CallCode => "Contract callcode", - CallKind::DelegateCall => "Contract delegatecall", - }) - .borders(Borders::ALL); - - let mut text_output: Text = Text::from(""); - - if let Some(contract_name) = identified_contracts.get(&address) { - if let Some(files_source_code) = contracts_sources.0.get(contract_name) { - let pc_ic_map = pc_ic_maps.get(contract_name); - // find the contract source with the correct source_element's file_id - if let Some((source_element, source_code)) = files_source_code.iter().find_map( - |(file_id, (source_code, contract_source))| { - // grab either the creation source map or runtime sourcemap - if let Some((Ok(source_map), ic)) = - if matches!(call_kind, CallKind::Create | CallKind::Create2) { - contract_source - .bytecode - .source_map() - .zip(pc_ic_map.and_then(|(c, _)| c.get(&pc))) - } else { - contract_source - .deployed_bytecode - .bytecode - .as_ref() - .expect("no bytecode") - .source_map() - .zip(pc_ic_map.and_then(|(_, r)| r.get(&pc))) - } - { - let source_element = source_map[*ic].clone(); - if let Some(index) = source_element.index { - if *file_id == index { - Some((source_element, source_code)) - } else { - None - } - } else { - None - } - } else { - None - } - }, - ) { - // we are handed a vector of SourceElements that give - // us a span of sourcecode that is currently being executed - // This includes an offset and length. This vector is in - // instruction pointer order, meaning the location of - // the instruction - sum(push_bytes[..pc]) - let offset = source_element.offset; - let len = source_element.length; - let max = source_code.len(); - - // split source into before, relevant, and after chunks - // split by line as well to do some formatting stuff - let mut before = source_code[..std::cmp::min(offset, max)] - .split_inclusive('\n') - .collect::>(); - let actual = source_code - [std::cmp::min(offset, max)..std::cmp::min(offset + len, max)] - .split_inclusive('\n') - .map(|s| s.to_string()) - .collect::>(); - let mut after = source_code[std::cmp::min(offset + len, max)..] - .split_inclusive('\n') - .collect::>(); - - let mut line_number = 0; - - let num_lines = before.len() + actual.len() + after.len(); - let height = area.height as usize; - let needed_highlight = actual.len(); - let mid_len = before.len() + actual.len(); - - // adjust what text we show of the source code - let (start_line, end_line) = if needed_highlight > height { - // highlighted section is more lines than we have avail - (before.len(), before.len() + needed_highlight) - } else if height > num_lines { - // we can fit entire source - (0, num_lines) - } else { - let remaining = height - needed_highlight; - let mut above = remaining / 2; - let mut below = remaining / 2; - if below > after.len() { - // unused space below the highlight - above += below - after.len(); - } else if above > before.len() { - // we have unused space above the highlight - below += above - before.len(); - } else { - // no unused space - } - - (before.len().saturating_sub(above), mid_len + below) - }; - - let max_line_num = num_lines.to_string().len(); - // We check if there is other text on the same line before the - // highlight starts - if let Some(last) = before.pop() { - if !last.ends_with('\n') { - before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default().fg(Color::Gray).bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default().add_modifier(Modifier::DIM), - ), - ])); - line_number += 1; - }); - - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::raw(last), - Span::styled( - actual[0].to_string(), - Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - - actual.iter().skip(1).for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - // this is a hack to add coloring - // because tui does weird trimming - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } else { - before.push(last); - before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default().fg(Color::Gray).bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default().add_modifier(Modifier::DIM), - ), - ])); - - line_number += 1; - }); - actual.iter().for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } - } else { - actual.iter().for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } - - // fill in the rest of the line as unhighlighted - if let Some(last) = actual.last() { - if !last.ends_with('\n') { - if let Some(post) = after.pop_front() { - if let Some(last) = text_output.lines.last_mut() { - last.spans.push(Span::raw(post)); - } - } - } - } - - // add after highlighted text - while mid_len + after.len() > end_line { - after.pop_back(); - } - after.iter().for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default().fg(Color::Gray).bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default().add_modifier(Modifier::DIM), - ), - ])); - line_number += 1; - }); - } else { - text_output.extend(Text::from("No sourcemap for contract")); - } - } else { - text_output - .extend(Text::from(format!("No srcmap index for contract {contract_name}"))); - } - } else { - text_output.extend(Text::from(format!("Unknown contract at address {address}"))); - } - - let paragraph = - Paragraph::new(text_output).block(block_source_code).wrap(Wrap { trim: false }); - f.render_widget(paragraph, area); - } - - /// Draw opcode list into main component - fn draw_op_list( - f: &mut Frame<'_>, - address: Address, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - draw_memory: &mut DrawMemory, - area: Rect, - ) { - let block_source_code = Block::default() - .title(format!( - "Address: {} | PC: {} | Gas used in call: {}", - address, - if let Some(step) = debug_steps.get(current_step) { - step.pc.to_string() - } else { - "END".to_string() - }, - debug_steps[current_step].total_gas_used, - )) - .borders(Borders::ALL); - let mut text_output: Vec = Vec::new(); - - // Scroll: - // Focused line is line that should always be at the center of the screen. - let display_start; - - let height = area.height as i32; - let extra_top_lines = height / 2; - let prev_start = draw_memory.current_startline; - // Absolute minimum start line - let abs_min_start = 0; - // Adjust for weird scrolling for max top line - let abs_max_start = (opcode_list.len() as i32 - 1) - (height / 2); - // actual minimum start line - let mut min_start = - max(current_step as i32 - height + extra_top_lines, abs_min_start) as usize; - - // actual max start line - let mut max_start = - max(min(current_step as i32 - extra_top_lines, abs_max_start), abs_min_start) as usize; - - // Sometimes, towards end of file, maximum and minim lines have swapped values. Swap if the - // case - if min_start > max_start { - std::mem::swap(&mut min_start, &mut max_start); - } - - if prev_start < min_start { - display_start = min_start; - } else if prev_start > max_start { - display_start = max_start; - } else { - display_start = prev_start; - } - draw_memory.current_startline = display_start; - - let max_pc_len = - debug_steps.iter().fold(0, |max_val, val| val.pc.max(max_val)).to_string().len(); - - // Define closure that prints one more line of source code - let mut add_new_line = |line_number| { - let bg_color = if line_number == current_step { Color::DarkGray } else { Color::Reset }; - - // Format line number - let line_number_format = if line_number == current_step { - let step: &DebugStep = &debug_steps[line_number]; - format!("{:0>max_pc_len$x}|▶", step.pc) - } else if line_number < debug_steps.len() { - let step: &DebugStep = &debug_steps[line_number]; - format!("{:0>max_pc_len$x}| ", step.pc) - } else { - "END CALL".to_string() - }; - - if let Some(op) = opcode_list.get(line_number) { - text_output.push(Line::from(Span::styled( - format!("{line_number_format}{op}"), - Style::default().fg(Color::White).bg(bg_color), - ))); - } else { - text_output.push(Line::from(Span::styled( - line_number_format, - Style::default().fg(Color::White).bg(bg_color), - ))); - } - }; - for number in display_start..opcode_list.len() { - add_new_line(number); - } - // Add one more "phantom" line so we see line where current segment execution ends - add_new_line(opcode_list.len()); - let paragraph = - Paragraph::new(text_output).block(block_source_code).wrap(Wrap { trim: true }); - f.render_widget(paragraph, area); - } - - /// Draw the stack into the stack pane - fn draw_stack( - f: &mut Frame<'_>, - debug_steps: &[DebugStep], - current_step: usize, - area: Rect, - stack_labels: bool, - draw_memory: &DrawMemory, - ) { - let stack = &debug_steps[current_step].stack; - let stack_space = - Block::default().title(format!("Stack: {}", stack.len())).borders(Borders::ALL); - let min_len = usize::max(format!("{}", stack.len()).len(), 2); - - let params = if let Instruction::OpCode(op) = debug_steps[current_step].instruction { - OpcodeParam::of(op) - } else { - &[] - }; - - let text: Vec = stack - .iter() - .rev() - .enumerate() - .skip(draw_memory.current_stack_startline) - .map(|(i, stack_item)| { - let param = params.iter().find(|param| param.index == i); - let mut words: Vec = (0..32) - .rev() - .map(|i| stack_item.byte(i)) - .map(|byte| { - Span::styled( - format!("{byte:02x} "), - if param.is_some() { - Style::default().fg(Color::Cyan) - } else if byte == 0 { - // this improves compatibility across terminals by not combining - // color with DIM modifier - Style::default().add_modifier(Modifier::DIM) - } else { - Style::default().fg(Color::White) - }, - ) - }) - .collect(); - - if stack_labels { - if let Some(param) = param { - words.push(Span::raw(format!("| {}", param.name))); - } else { - words.push(Span::raw("| ".to_string())); - } - } - - let mut spans = vec![Span::styled( - format!("{i:0min_len$}| "), - Style::default().fg(Color::White), - )]; - spans.extend(words); - spans.push(Span::raw("\n")); - - Line::from(spans) - }) - .collect(); - - let paragraph = Paragraph::new(text).block(stack_space).wrap(Wrap { trim: true }); - f.render_widget(paragraph, area); - } - - /// The memory_access variable stores the index on the stack that indicates the memory - /// offset/size accessed by the given opcode: - /// (read memory offset, read memory size, write memory offset, write memory size) - /// >= 1: the stack index - /// 0: no memory access - /// -1: a fixed size of 32 bytes - /// -2: a fixed size of 1 byte - /// The return value is a tuple about accessed memory region by the given opcode: - /// (read memory offset, read memory size, write memory offset, write memory size) - fn get_memory_access( - op: u8, - stack: &Vec, - ) -> (Option, Option, Option, Option) { - let memory_access = match op { - opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => (1, 2, 0, 0), - opcode::CALLDATACOPY | opcode::CODECOPY | opcode::RETURNDATACOPY => (0, 0, 1, 3), - opcode::EXTCODECOPY => (0, 0, 2, 4), - opcode::MLOAD => (1, -1, 0, 0), - opcode::MSTORE => (0, 0, 1, -1), - opcode::MSTORE8 => (0, 0, 1, -2), - opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => { - (1, 2, 0, 0) - } - opcode::CREATE | opcode::CREATE2 => (2, 3, 0, 0), - opcode::CALL | opcode::CALLCODE => (4, 5, 0, 0), - opcode::DELEGATECALL | opcode::STATICCALL => (3, 4, 0, 0), - _ => Default::default(), - }; - - let stack_len = stack.len(); - let get_size = |stack_index| match stack_index { - -2 => Some(1), - -1 => Some(32), - 0 => None, - 1.. => Some(stack[stack_len - stack_index as usize].saturating_to()), - _ => panic!("invalid stack index"), - }; - - let (read_offset, read_size, write_offset, write_size) = ( - get_size(memory_access.0), - get_size(memory_access.1), - get_size(memory_access.2), - get_size(memory_access.3), - ); - (read_offset, read_size, write_offset, write_size) - } - - /// Draw memory in memory pane - fn draw_memory( - f: &mut Frame<'_>, - debug_steps: &[DebugStep], - current_step: usize, - area: Rect, - mem_utf8: bool, - draw_mem: &DrawMemory, - ) { - let memory = &debug_steps[current_step].memory; - let memory_space = Block::default() - .title(format!("Memory (max expansion: {} bytes)", memory.len())) - .borders(Borders::ALL); - let max_i = memory.len() / 32; - let min_len = format!("{:x}", max_i * 32).len(); - - // color memory region based on write/read - let mut offset: Option = None; - let mut size: Option = None; - let mut color = None; - if let Instruction::OpCode(op) = debug_steps[current_step].instruction { - let stack_len = debug_steps[current_step].stack.len(); - if stack_len > 0 { - let (read_offset, read_size, write_offset, write_size) = - Tui::get_memory_access(op, &debug_steps[current_step].stack); - if read_offset.is_some() { - offset = read_offset; - size = read_size; - color = Some(Color::Cyan); - } else if write_offset.is_some() { - offset = write_offset; - size = write_size; - color = Some(Color::Red); - } - } - } - - // color word on previous write op - if current_step > 0 { - let prev_step = current_step - 1; - if let Instruction::OpCode(op) = debug_steps[prev_step].instruction { - let (_, _, write_offset, write_size) = - Tui::get_memory_access(op, &debug_steps[prev_step].stack); - if write_offset.is_some() { - offset = write_offset; - size = write_size; - color = Some(Color::Green); - } - } - } - - let height = area.height as usize; - let end_line = draw_mem.current_mem_startline + height; - - let text: Vec = memory - .chunks(32) - .enumerate() - .skip(draw_mem.current_mem_startline) - .take_while(|(i, _)| i < &end_line) - .map(|(i, mem_word)| { - let words: Vec = mem_word - .iter() - .enumerate() - .map(|(j, byte)| { - Span::styled( - format!("{byte:02x} "), - if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { - if (i == offset / 32 && j >= offset % 32) || - (i > offset / 32 && i < (offset + size - 1) / 32) || - (i == (offset + size - 1) / 32 && - j <= (offset + size - 1) % 32) - { - // [offset, offset + size] is the memory region to be colored. - // If a byte at row i and column j in the memory panel - // falls in this region, set the color. - Style::default().fg(color) - } else if *byte == 0 { - Style::default().add_modifier(Modifier::DIM) - } else { - Style::default().fg(Color::White) - } - } else if *byte == 0 { - Style::default().add_modifier(Modifier::DIM) - } else { - Style::default().fg(Color::White) - }, - ) - }) - .collect(); - - let mut spans = vec![Span::styled( - format!("{:0min_len$x}| ", i * 32), - Style::default().fg(Color::White), - )]; - spans.extend(words); - - if mem_utf8 { - let chars: Vec = mem_word - .chunks(4) - .map(|utf| { - if let Ok(utf_str) = std::str::from_utf8(utf) { - Span::raw(utf_str.replace(char::from(0), ".")) - } else { - Span::raw(".") - } - }) - .collect(); - spans.push(Span::raw("|")); - spans.extend(chars); - } - - spans.push(Span::raw("\n")); - - Line::from(spans) - }) - .collect(); - let paragraph = Paragraph::new(text).block(memory_space).wrap(Wrap { trim: true }); - f.render_widget(paragraph, area); - } -} - -impl Ui for Tui { - fn start(mut self) -> Result { - // If something panics inside here, we should do everything we can to - // not corrupt the user's terminal. - std::panic::set_hook(Box::new(|e| { - disable_raw_mode().expect("Unable to disable raw mode"); - execute!(io::stdout(), LeaveAlternateScreen, DisableMouseCapture) - .expect("unable to execute disable mouse capture"); - println!("{e}"); - })); - // This is the recommend tick rate from tui-rs, based on their examples - let tick_rate = Duration::from_millis(200); - - // Setup a channel to send interrupts - let (tx, rx) = mpsc::channel(); - thread::Builder::new() - .name("event-listener".into()) - .spawn(move || { - let mut last_tick = Instant::now(); - loop { - // Poll events since last tick - if last tick is greater than tick_rate, we - // demand immediate availability of the event. This may affect interactivity, - // but I'm not sure as it is hard to test. - if event::poll(tick_rate.saturating_sub(last_tick.elapsed())).unwrap() { - let event = event::read().unwrap(); - if let Event::Key(key) = event { - if tx.send(Interrupt::KeyPressed(key)).is_err() { - return - } - } else if let Event::Mouse(mouse) = event { - if tx.send(Interrupt::MouseEvent(mouse)).is_err() { - return - } - } - } - // Force update if time has passed - if last_tick.elapsed() > tick_rate { - if tx.send(Interrupt::IntervalElapsed).is_err() { - return - } - last_tick = Instant::now(); - } - } - }) - .expect("failed to spawn thread"); - - self.terminal.clear()?; - let mut draw_memory: DrawMemory = DrawMemory::default(); - - let debug_call: Vec<(Address, Vec, CallKind)> = self.debug_arena.clone(); - let mut opcode_list: Vec = - debug_call[0].1.iter().map(|step| step.pretty_opcode()).collect(); - let mut last_index = 0; - - let mut stack_labels = false; - let mut mem_utf = false; - let mut show_shortcuts = true; - // UI thread that manages drawing - loop { - if last_index != draw_memory.inner_call_index { - opcode_list = debug_call[draw_memory.inner_call_index] - .1 - .iter() - .map(|step| step.pretty_opcode()) - .collect(); - last_index = draw_memory.inner_call_index; - } - // Grab interrupt - - let receiver = rx.recv()?; - - if let Some(c) = receiver.char_press() { - if self.key_buffer.ends_with('\'') { - // Find the location of the called breakpoint in the whole debug arena (at this - // address with this pc) - if let Some((caller, pc)) = self.breakpoints.get(&c) { - for (i, (_caller, debug_steps, _)) in debug_call.iter().enumerate() { - if _caller == caller { - if let Some(step) = - debug_steps.iter().position(|step| step.pc == *pc) - { - draw_memory.inner_call_index = i; - self.current_step = step; - break - } - } - } - } - self.key_buffer.clear(); - } else if let Interrupt::KeyPressed(event) = receiver { - match event.code { - // Exit - KeyCode::Char('q') => { - disable_raw_mode()?; - execute!( - self.terminal.backend_mut(), - LeaveAlternateScreen, - DisableMouseCapture - )?; - return Ok(TUIExitReason::CharExit) - } - // Move down - KeyCode::Char('j') | KeyCode::Down => { - // Grab number of times to do it - for _ in 0..Tui::buffer_as_number(&self.key_buffer, 1) { - if event.modifiers.contains(KeyModifiers::CONTROL) { - let max_mem = (debug_call[draw_memory.inner_call_index].1 - [self.current_step] - .memory - .len() / - 32) - .saturating_sub(1); - if draw_memory.current_mem_startline < max_mem { - draw_memory.current_mem_startline += 1; - } - } else if self.current_step < opcode_list.len() - 1 { - self.current_step += 1; - } else if draw_memory.inner_call_index < debug_call.len() - 1 { - draw_memory.inner_call_index += 1; - self.current_step = 0; - } - } - self.key_buffer.clear(); - } - KeyCode::Char('J') => { - for _ in 0..Tui::buffer_as_number(&self.key_buffer, 1) { - let max_stack = debug_call[draw_memory.inner_call_index].1 - [self.current_step] - .stack - .len() - .saturating_sub(1); - if draw_memory.current_stack_startline < max_stack { - draw_memory.current_stack_startline += 1; - } - } - self.key_buffer.clear(); - } - // Move up - KeyCode::Char('k') | KeyCode::Up => { - for _ in 0..Tui::buffer_as_number(&self.key_buffer, 1) { - if event.modifiers.contains(KeyModifiers::CONTROL) { - draw_memory.current_mem_startline = - draw_memory.current_mem_startline.saturating_sub(1); - } else if self.current_step > 0 { - self.current_step -= 1; - } else if draw_memory.inner_call_index > 0 { - draw_memory.inner_call_index -= 1; - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - } - } - self.key_buffer.clear(); - } - KeyCode::Char('K') => { - for _ in 0..Tui::buffer_as_number(&self.key_buffer, 1) { - draw_memory.current_stack_startline = - draw_memory.current_stack_startline.saturating_sub(1); - } - self.key_buffer.clear(); - } - // Go to top of file - KeyCode::Char('g') => { - draw_memory.inner_call_index = 0; - self.current_step = 0; - self.key_buffer.clear(); - } - // Go to bottom of file - KeyCode::Char('G') => { - draw_memory.inner_call_index = debug_call.len() - 1; - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - self.key_buffer.clear(); - } - // Go to previous call - KeyCode::Char('c') => { - draw_memory.inner_call_index = - draw_memory.inner_call_index.saturating_sub(1); - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - self.key_buffer.clear(); - } - // Go to next call - KeyCode::Char('C') => { - if debug_call.len() > draw_memory.inner_call_index + 1 { - draw_memory.inner_call_index += 1; - self.current_step = 0; - } - self.key_buffer.clear(); - } - // Step forward - KeyCode::Char('s') => { - for _ in 0..Tui::buffer_as_number(&self.key_buffer, 1) { - let remaining_ops = - opcode_list[self.current_step..].to_vec().clone(); - self.current_step += remaining_ops - .iter() - .enumerate() - .find_map(|(i, op)| { - if i < remaining_ops.len() - 1 { - match ( - op.contains("JUMP") && op != "JUMPDEST", - &*remaining_ops[i + 1], - ) { - (true, "JUMPDEST") => Some(i + 1), - _ => None, - } - } else { - None - } - }) - .unwrap_or(opcode_list.len() - 1); - if self.current_step > opcode_list.len() { - self.current_step = opcode_list.len() - 1 - }; - } - self.key_buffer.clear(); - } - // Step backwards - KeyCode::Char('a') => { - for _ in 0..Tui::buffer_as_number(&self.key_buffer, 1) { - let prev_ops = opcode_list[..self.current_step].to_vec().clone(); - self.current_step = prev_ops - .iter() - .enumerate() - .rev() - .find_map(|(i, op)| { - if i > 0 { - match ( - prev_ops[i - 1].contains("JUMP") && - prev_ops[i - 1] != "JUMPDEST", - &**op, - ) { - (true, "JUMPDEST") => Some(i - 1), - _ => None, - } - } else { - None - } - }) - .unwrap_or_default(); - } - self.key_buffer.clear(); - } - // toggle stack labels - KeyCode::Char('t') => { - stack_labels = !stack_labels; - } - // toggle memory utf8 decoding - KeyCode::Char('m') => { - mem_utf = !mem_utf; - } - // toggle help notice - KeyCode::Char('h') => { - show_shortcuts = !show_shortcuts; - } - KeyCode::Char(other) => match other { - '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '\'' => { - self.key_buffer.push(other); - } - _ => { - // Invalid key, clear buffer - self.key_buffer.clear(); - } - }, - _ => { - self.key_buffer.clear(); - } - } - } - } else { - match receiver { - Interrupt::MouseEvent(event) => match event.kind { - MouseEventKind::ScrollUp => { - if self.current_step > 0 { - self.current_step -= 1; - } else if draw_memory.inner_call_index > 0 { - draw_memory.inner_call_index -= 1; - draw_memory.current_mem_startline = 0; - draw_memory.current_stack_startline = 0; - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - } - } - MouseEventKind::ScrollDown => { - if self.current_step < opcode_list.len() - 1 { - self.current_step += 1; - } else if draw_memory.inner_call_index < debug_call.len() - 1 { - draw_memory.inner_call_index += 1; - draw_memory.current_mem_startline = 0; - draw_memory.current_stack_startline = 0; - self.current_step = 0; - } - } - _ => {} - }, - Interrupt::IntervalElapsed => {} - _ => (), - } - } - - // Draw - let current_step = self.current_step; - self.terminal.draw(|f| { - Tui::draw_layout( - f, - debug_call[draw_memory.inner_call_index].0, - &self.identified_contracts, - &self.pc_ic_maps, - &self.contracts_sources, - &debug_call[draw_memory.inner_call_index].1[..], - &opcode_list, - current_step, - debug_call[draw_memory.inner_call_index].2, - &mut draw_memory, - stack_labels, - mem_utf, - show_shortcuts, - ) - })?; - } - } -} - -/// Why did we wake up drawing thread? -enum Interrupt { - KeyPressed(KeyEvent), - MouseEvent(MouseEvent), - IntervalElapsed, -} - -impl Interrupt { - fn char_press(&self) -> Option { - if let Self::KeyPressed(event) = &self { - if let KeyCode::Char(c) = event.code { - if c.is_alphanumeric() || c == '\'' { - return Some(c) - } - } - } - - None - } -} - -/// This is currently used to remember last scroll -/// position so screen doesn't wiggle as much. -struct DrawMemory { - pub current_startline: usize, - pub inner_call_index: usize, - pub current_mem_startline: usize, - pub current_stack_startline: usize, -} -impl DrawMemory { - fn default() -> Self { - DrawMemory { - current_startline: 0, - inner_call_index: 0, - current_mem_startline: 0, - current_stack_startline: 0, - } - } -} +mod tui; +pub use tui::{Debugger, ExitReason}; diff --git a/crates/debugger/src/tui.rs b/crates/debugger/src/tui.rs new file mode 100644 index 0000000000000..7cd2b67efd0ce --- /dev/null +++ b/crates/debugger/src/tui.rs @@ -0,0 +1,1400 @@ +//! The TUI implementation. + +use crate::{op::OpcodeParam, DebuggerBuilder}; +use alloy_primitives::{Address, U256}; +use crossterm::{ + event::{ + self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, + MouseEvent, MouseEventKind, + }, + execute, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, +}; +use eyre::Result; +use foundry_common::{compile::ContractSources, evm::Breakpoints}; +use foundry_evm_core::{ + debug::{DebugStep, Instruction}, + utils::{build_pc_ic_map, CallKind, PCICMap}, +}; +use ratatui::{ + backend::CrosstermBackend, + layout::{Alignment, Constraint, Direction, Layout, Rect}, + style::{Color, Modifier, Style}, + terminal::Frame, + text::{Line, Span, Text}, + widgets::{Block, Borders, Paragraph, Wrap}, + Terminal, +}; +use revm::{interpreter::opcode, primitives::SpecId}; +use std::{ + cmp::{max, min}, + collections::{BTreeMap, HashMap, VecDeque}, + io, + sync::mpsc, + thread, + time::{Duration, Instant}, +}; + +/// Used to indicate why the debugger quit. +#[derive(Debug)] +pub enum ExitReason { + /// Exit using 'q'. + CharExit, +} + +/// The TUI debugger. +pub struct Debugger { + debug_arena: Vec<(Address, Vec, CallKind)>, + terminal: Terminal>, + /// Buffer for keys prior to execution, i.e. '10' + 'k' => move up 10 operations + key_buffer: String, + /// Current step in the debug steps + current_step: usize, + identified_contracts: HashMap, + /// Source map of contract sources + contracts_sources: ContractSources, + /// A mapping of source -> (PC -> IC map for deploy code, PC -> IC map for runtime code) + pc_ic_maps: BTreeMap, + breakpoints: Breakpoints, +} + +impl Debugger { + /// Creates a new debugger builder. + #[inline] + pub fn builder() -> DebuggerBuilder { + DebuggerBuilder::new() + } + + /// Creates a new debugger. + pub fn new( + debug_arena: Vec<(Address, Vec, CallKind)>, + current_step: usize, + identified_contracts: HashMap, + contracts_sources: ContractSources, + breakpoints: Breakpoints, + ) -> Result { + let backend = CrosstermBackend::new(io::stdout()); + let terminal = Terminal::new(backend)?; + let pc_ic_maps = contracts_sources + .0 + .iter() + .flat_map(|(contract_name, files_sources)| { + files_sources.iter().filter_map(|(_, (_, contract))| { + Some(( + contract_name.clone(), + ( + build_pc_ic_map( + SpecId::LATEST, + contract.bytecode.object.as_bytes()?.as_ref(), + ), + build_pc_ic_map( + SpecId::LATEST, + contract + .deployed_bytecode + .bytecode + .as_ref()? + .object + .as_bytes()? + .as_ref(), + ), + ), + )) + }) + }) + .collect(); + Ok(Debugger { + debug_arena, + terminal, + key_buffer: String::new(), + current_step, + identified_contracts, + contracts_sources, + pc_ic_maps, + breakpoints, + }) + } + + /// Starts the debugger TUI. Terminates the current process on failure or user exit. + pub fn run_exit(mut self) -> ! { + let code = match self.try_run() { + Ok(ExitReason::CharExit) => 0, + Err(e) => { + println!("{e}"); + 1 + } + }; + std::process::exit(code) + } + + /// Starts the debugger TUI. + pub fn try_run(&mut self) -> Result { + let mut guard = DebuggerGuard::setup(self)?; + let r = guard.0.try_run_real(); + // Cleanup only once. + guard.restore()?; + std::mem::forget(guard); + r + } + + #[instrument(target = "debugger", name = "run", skip_all, ret)] + fn try_run_real(&mut self) -> Result { + // Setup a channel to send interrupts + let (tx, rx) = mpsc::channel(); + thread::Builder::new() + .name("event-listener".into()) + .spawn(move || event_listener(tx)) + .expect("failed to spawn thread"); + + self.terminal.clear()?; + let mut draw_memory = DrawMemory::default(); + + let debug_call = self.debug_arena.clone(); + let mut opcode_list: Vec = + debug_call[0].1.iter().map(|step| step.pretty_opcode()).collect(); + let mut last_index = 0; + + let mut stack_labels = false; + let mut mem_utf = false; + let mut show_shortcuts = true; + + // UI thread that manages drawing + loop { + if last_index != draw_memory.inner_call_index { + opcode_list = debug_call[draw_memory.inner_call_index] + .1 + .iter() + .map(|step| step.pretty_opcode()) + .collect(); + last_index = draw_memory.inner_call_index; + } + + // Grab interrupt + let receiver = rx.recv()?; + + if let Some(c) = receiver.char_press() { + if self.key_buffer.ends_with('\'') { + // Find the location of the called breakpoint in the whole debug arena (at this + // address with this pc) + if let Some((caller, pc)) = self.breakpoints.get(&c) { + for (i, (_caller, debug_steps, _)) in debug_call.iter().enumerate() { + if _caller == caller { + if let Some(step) = + debug_steps.iter().position(|step| step.pc == *pc) + { + draw_memory.inner_call_index = i; + self.current_step = step; + break + } + } + } + } + self.key_buffer.clear(); + } else if let Interrupt::KeyEvent(event) = receiver { + match event.code { + // Exit + KeyCode::Char('q') => return Ok(ExitReason::CharExit), + // Move down + KeyCode::Char('j') | KeyCode::Down => { + // Grab number of times to do it + for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { + if event.modifiers.contains(KeyModifiers::CONTROL) { + let max_mem = (debug_call[draw_memory.inner_call_index].1 + [self.current_step] + .memory + .len() / + 32) + .saturating_sub(1); + if draw_memory.current_mem_startline < max_mem { + draw_memory.current_mem_startline += 1; + } + } else if self.current_step < opcode_list.len() - 1 { + self.current_step += 1; + } else if draw_memory.inner_call_index < debug_call.len() - 1 { + draw_memory.inner_call_index += 1; + self.current_step = 0; + } + } + self.key_buffer.clear(); + } + KeyCode::Char('J') => { + for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { + let max_stack = debug_call[draw_memory.inner_call_index].1 + [self.current_step] + .stack + .len() + .saturating_sub(1); + if draw_memory.current_stack_startline < max_stack { + draw_memory.current_stack_startline += 1; + } + } + self.key_buffer.clear(); + } + // Move up + KeyCode::Char('k') | KeyCode::Up => { + for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { + if event.modifiers.contains(KeyModifiers::CONTROL) { + draw_memory.current_mem_startline = + draw_memory.current_mem_startline.saturating_sub(1); + } else if self.current_step > 0 { + self.current_step -= 1; + } else if draw_memory.inner_call_index > 0 { + draw_memory.inner_call_index -= 1; + self.current_step = + debug_call[draw_memory.inner_call_index].1.len() - 1; + } + } + self.key_buffer.clear(); + } + KeyCode::Char('K') => { + for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { + draw_memory.current_stack_startline = + draw_memory.current_stack_startline.saturating_sub(1); + } + self.key_buffer.clear(); + } + // Go to top of file + KeyCode::Char('g') => { + draw_memory.inner_call_index = 0; + self.current_step = 0; + self.key_buffer.clear(); + } + // Go to bottom of file + KeyCode::Char('G') => { + draw_memory.inner_call_index = debug_call.len() - 1; + self.current_step = + debug_call[draw_memory.inner_call_index].1.len() - 1; + self.key_buffer.clear(); + } + // Go to previous call + KeyCode::Char('c') => { + draw_memory.inner_call_index = + draw_memory.inner_call_index.saturating_sub(1); + self.current_step = + debug_call[draw_memory.inner_call_index].1.len() - 1; + self.key_buffer.clear(); + } + // Go to next call + KeyCode::Char('C') => { + if debug_call.len() > draw_memory.inner_call_index + 1 { + draw_memory.inner_call_index += 1; + self.current_step = 0; + } + self.key_buffer.clear(); + } + // Step forward + KeyCode::Char('s') => { + for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { + let remaining_ops = + opcode_list[self.current_step..].to_vec().clone(); + self.current_step += remaining_ops + .iter() + .enumerate() + .find_map(|(i, op)| { + if i < remaining_ops.len() - 1 { + match ( + op.contains("JUMP") && op != "JUMPDEST", + &*remaining_ops[i + 1], + ) { + (true, "JUMPDEST") => Some(i + 1), + _ => None, + } + } else { + None + } + }) + .unwrap_or(opcode_list.len() - 1); + if self.current_step > opcode_list.len() { + self.current_step = opcode_list.len() - 1 + }; + } + self.key_buffer.clear(); + } + // Step backwards + KeyCode::Char('a') => { + for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { + let prev_ops = opcode_list[..self.current_step].to_vec().clone(); + self.current_step = prev_ops + .iter() + .enumerate() + .rev() + .find_map(|(i, op)| { + if i > 0 { + match ( + prev_ops[i - 1].contains("JUMP") && + prev_ops[i - 1] != "JUMPDEST", + &**op, + ) { + (true, "JUMPDEST") => Some(i - 1), + _ => None, + } + } else { + None + } + }) + .unwrap_or_default(); + } + self.key_buffer.clear(); + } + // toggle stack labels + KeyCode::Char('t') => stack_labels = !stack_labels, + // toggle memory utf8 decoding + KeyCode::Char('m') => mem_utf = !mem_utf, + // toggle help notice + KeyCode::Char('h') => show_shortcuts = !show_shortcuts, + KeyCode::Char(other) => match other { + '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '\'' => { + self.key_buffer.push(other); + } + // Invalid key, clear buffer + _ => self.key_buffer.clear(), + }, + _ => self.key_buffer.clear(), + } + } + } else { + match receiver { + Interrupt::MouseEvent(event) => match event.kind { + MouseEventKind::ScrollUp => { + if self.current_step > 0 { + self.current_step -= 1; + } else if draw_memory.inner_call_index > 0 { + draw_memory.inner_call_index -= 1; + draw_memory.current_mem_startline = 0; + draw_memory.current_stack_startline = 0; + self.current_step = + debug_call[draw_memory.inner_call_index].1.len() - 1; + } + } + MouseEventKind::ScrollDown => { + if self.current_step < opcode_list.len() - 1 { + self.current_step += 1; + } else if draw_memory.inner_call_index < debug_call.len() - 1 { + draw_memory.inner_call_index += 1; + draw_memory.current_mem_startline = 0; + draw_memory.current_stack_startline = 0; + self.current_step = 0; + } + } + _ => {} + }, + Interrupt::IntervalElapsed => {} + _ => (), + } + } + + // Draw + let current_step = self.current_step; + self.terminal.draw(|f| { + Debugger::draw_layout( + f, + debug_call[draw_memory.inner_call_index].0, + &self.identified_contracts, + &self.pc_ic_maps, + &self.contracts_sources, + &debug_call[draw_memory.inner_call_index].1[..], + &opcode_list, + current_step, + debug_call[draw_memory.inner_call_index].2, + &mut draw_memory, + stack_labels, + mem_utf, + show_shortcuts, + ) + })?; + } + } + + /// Grab number from buffer. Used for something like '10k' to move up 10 operations + fn buffer_as_number(s: &str, default_value: usize) -> usize { + match s.parse() { + Ok(num) if num >= 1 => num, + _ => default_value, + } + } + + /// Create layout and subcomponents + #[allow(clippy::too_many_arguments)] + fn draw_layout( + f: &mut Frame<'_>, + address: Address, + identified_contracts: &HashMap, + pc_ic_maps: &BTreeMap, + contracts_sources: &ContractSources, + debug_steps: &[DebugStep], + opcode_list: &[String], + current_step: usize, + call_kind: CallKind, + draw_memory: &mut DrawMemory, + stack_labels: bool, + mem_utf: bool, + show_shortcuts: bool, + ) { + let total_size = f.size(); + if total_size.width < 225 { + Debugger::vertical_layout( + f, + address, + identified_contracts, + pc_ic_maps, + contracts_sources, + debug_steps, + opcode_list, + current_step, + call_kind, + draw_memory, + stack_labels, + mem_utf, + show_shortcuts, + ); + } else { + Debugger::square_layout( + f, + address, + identified_contracts, + pc_ic_maps, + contracts_sources, + debug_steps, + opcode_list, + current_step, + call_kind, + draw_memory, + stack_labels, + mem_utf, + show_shortcuts, + ); + } + } + + #[allow(clippy::too_many_arguments)] + fn vertical_layout( + f: &mut Frame<'_>, + address: Address, + identified_contracts: &HashMap, + pc_ic_maps: &BTreeMap, + contracts_sources: &ContractSources, + debug_steps: &[DebugStep], + opcode_list: &[String], + current_step: usize, + call_kind: CallKind, + draw_memory: &mut DrawMemory, + stack_labels: bool, + mem_utf: bool, + show_shortcuts: bool, + ) { + let total_size = f.size(); + let h_height = if show_shortcuts { 4 } else { 0 }; + + if let [app, footer] = Layout::default() + .constraints( + [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)].as_ref(), + ) + .direction(Direction::Vertical) + .split(total_size)[..] + { + if let [op_pane, stack_pane, memory_pane, src_pane] = Layout::default() + .direction(Direction::Vertical) + .constraints( + [ + Constraint::Ratio(1, 6), + Constraint::Ratio(1, 6), + Constraint::Ratio(1, 6), + Constraint::Ratio(3, 6), + ] + .as_ref(), + ) + .split(app)[..] + { + if show_shortcuts { + Debugger::draw_footer(f, footer); + } + Debugger::draw_src( + f, + address, + identified_contracts, + pc_ic_maps, + contracts_sources, + debug_steps[current_step].pc, + call_kind, + src_pane, + ); + Debugger::draw_op_list( + f, + address, + debug_steps, + opcode_list, + current_step, + draw_memory, + op_pane, + ); + Debugger::draw_stack( + f, + debug_steps, + current_step, + stack_pane, + stack_labels, + draw_memory, + ); + Debugger::draw_memory( + f, + debug_steps, + current_step, + memory_pane, + mem_utf, + draw_memory, + ); + } else { + panic!("unable to create vertical panes") + } + } else { + panic!("unable to create footer / app") + }; + } + + #[allow(clippy::too_many_arguments)] + fn square_layout( + f: &mut Frame<'_>, + address: Address, + identified_contracts: &HashMap, + pc_ic_maps: &BTreeMap, + contracts_sources: &ContractSources, + debug_steps: &[DebugStep], + opcode_list: &[String], + current_step: usize, + call_kind: CallKind, + draw_memory: &mut DrawMemory, + stack_labels: bool, + mem_utf: bool, + show_shortcuts: bool, + ) { + let total_size = f.size(); + let h_height = if show_shortcuts { 4 } else { 0 }; + + // split in 2 vertically + + if let [app, footer] = Layout::default() + .direction(Direction::Vertical) + .constraints( + [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)].as_ref(), + ) + .split(total_size)[..] + { + if let [left_pane, right_pane] = Layout::default() + .direction(Direction::Horizontal) + .constraints([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)].as_ref()) + .split(app)[..] + { + // split right pane horizontally to construct stack and memory + if let [op_pane, src_pane] = Layout::default() + .direction(Direction::Vertical) + .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)].as_ref()) + .split(left_pane)[..] + { + if let [stack_pane, memory_pane] = Layout::default() + .direction(Direction::Vertical) + .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)].as_ref()) + .split(right_pane)[..] + { + if show_shortcuts { + Debugger::draw_footer(f, footer) + }; + Debugger::draw_src( + f, + address, + identified_contracts, + pc_ic_maps, + contracts_sources, + debug_steps[current_step].pc, + call_kind, + src_pane, + ); + Debugger::draw_op_list( + f, + address, + debug_steps, + opcode_list, + current_step, + draw_memory, + op_pane, + ); + Debugger::draw_stack( + f, + debug_steps, + current_step, + stack_pane, + stack_labels, + draw_memory, + ); + Debugger::draw_memory( + f, + debug_steps, + current_step, + memory_pane, + mem_utf, + draw_memory, + ); + } + } else { + panic!("Couldn't generate horizontal split layout 1:2."); + } + } else { + panic!("Couldn't generate vertical split layout 1:2."); + } + } else { + panic!("Couldn't generate application & footer") + } + } + + fn draw_footer(f: &mut Frame<'_>, area: Rect) { + let block_controls = Block::default(); + + let text_output = vec![Line::from(Span::styled( + "[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end", Style::default().add_modifier(Modifier::DIM))), +Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | [']: goto breakpoint | [h] toggle help", Style::default().add_modifier(Modifier::DIM)))]; + + let paragraph = Paragraph::new(text_output) + .block(block_controls) + .alignment(Alignment::Center) + .wrap(Wrap { trim: false }); + + f.render_widget(paragraph, area); + } + + #[allow(clippy::too_many_arguments)] + fn draw_src( + f: &mut Frame<'_>, + address: Address, + identified_contracts: &HashMap, + pc_ic_maps: &BTreeMap, + contracts_sources: &ContractSources, + pc: usize, + call_kind: CallKind, + area: Rect, + ) { + let block_source_code = Block::default() + .title(match call_kind { + CallKind::Create | CallKind::Create2 => "Contract creation", + CallKind::Call => "Contract call", + CallKind::StaticCall => "Contract staticcall", + CallKind::CallCode => "Contract callcode", + CallKind::DelegateCall => "Contract delegatecall", + }) + .borders(Borders::ALL); + + let mut text_output: Text = Text::from(""); + + if let Some(contract_name) = identified_contracts.get(&address) { + if let Some(files_source_code) = contracts_sources.0.get(contract_name) { + let pc_ic_map = pc_ic_maps.get(contract_name); + // find the contract source with the correct source_element's file_id + if let Some((source_element, source_code)) = files_source_code.iter().find_map( + |(file_id, (source_code, contract_source))| { + // grab either the creation source map or runtime sourcemap + if let Some((Ok(source_map), ic)) = + if matches!(call_kind, CallKind::Create | CallKind::Create2) { + contract_source + .bytecode + .source_map() + .zip(pc_ic_map.and_then(|(c, _)| c.get(&pc))) + } else { + contract_source + .deployed_bytecode + .bytecode + .as_ref() + .expect("no bytecode") + .source_map() + .zip(pc_ic_map.and_then(|(_, r)| r.get(&pc))) + } + { + let source_element = source_map[*ic].clone(); + if let Some(index) = source_element.index { + if *file_id == index { + Some((source_element, source_code)) + } else { + None + } + } else { + None + } + } else { + None + } + }, + ) { + // we are handed a vector of SourceElements that give + // us a span of sourcecode that is currently being executed + // This includes an offset and length. This vector is in + // instruction pointer order, meaning the location of + // the instruction - sum(push_bytes[..pc]) + let offset = source_element.offset; + let len = source_element.length; + let max = source_code.len(); + + // split source into before, relevant, and after chunks + // split by line as well to do some formatting stuff + let mut before = source_code[..std::cmp::min(offset, max)] + .split_inclusive('\n') + .collect::>(); + let actual = source_code + [std::cmp::min(offset, max)..std::cmp::min(offset + len, max)] + .split_inclusive('\n') + .map(|s| s.to_string()) + .collect::>(); + let mut after = source_code[std::cmp::min(offset + len, max)..] + .split_inclusive('\n') + .collect::>(); + + let mut line_number = 0; + + let num_lines = before.len() + actual.len() + after.len(); + let height = area.height as usize; + let needed_highlight = actual.len(); + let mid_len = before.len() + actual.len(); + + // adjust what text we show of the source code + let (start_line, end_line) = if needed_highlight > height { + // highlighted section is more lines than we have avail + (before.len(), before.len() + needed_highlight) + } else if height > num_lines { + // we can fit entire source + (0, num_lines) + } else { + let remaining = height - needed_highlight; + let mut above = remaining / 2; + let mut below = remaining / 2; + if below > after.len() { + // unused space below the highlight + above += below - after.len(); + } else if above > before.len() { + // we have unused space above the highlight + below += above - before.len(); + } else { + // no unused space + } + + (before.len().saturating_sub(above), mid_len + below) + }; + + let max_line_num = num_lines.to_string().len(); + // We check if there is other text on the same line before the + // highlight starts + if let Some(last) = before.pop() { + if !last.ends_with('\n') { + before.iter().skip(start_line).for_each(|line| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default().fg(Color::Gray).bg(Color::DarkGray), + ), + Span::styled( + "\u{2800} ".to_string() + line, + Style::default().add_modifier(Modifier::DIM), + ), + ])); + line_number += 1; + }); + + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::raw(last), + Span::styled( + actual[0].to_string(), + Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + + actual.iter().skip(1).for_each(|s| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::styled( + // this is a hack to add coloring + // because tui does weird trimming + if s.is_empty() || s == "\n" { + "\u{2800} \n".to_string() + } else { + s.to_string() + }, + Style::default() + .fg(Color::Cyan) + .add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + }); + } else { + before.push(last); + before.iter().skip(start_line).for_each(|line| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default().fg(Color::Gray).bg(Color::DarkGray), + ), + Span::styled( + "\u{2800} ".to_string() + line, + Style::default().add_modifier(Modifier::DIM), + ), + ])); + + line_number += 1; + }); + actual.iter().for_each(|s| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::styled( + if s.is_empty() || s == "\n" { + "\u{2800} \n".to_string() + } else { + s.to_string() + }, + Style::default() + .fg(Color::Cyan) + .add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + }); + } + } else { + actual.iter().for_each(|s| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default() + .fg(Color::Cyan) + .bg(Color::DarkGray) + .add_modifier(Modifier::BOLD), + ), + Span::raw("\u{2800} "), + Span::styled( + if s.is_empty() || s == "\n" { + "\u{2800} \n".to_string() + } else { + s.to_string() + }, + Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), + ), + ])); + line_number += 1; + }); + } + + // fill in the rest of the line as unhighlighted + if let Some(last) = actual.last() { + if !last.ends_with('\n') { + if let Some(post) = after.pop_front() { + if let Some(last) = text_output.lines.last_mut() { + last.spans.push(Span::raw(post)); + } + } + } + } + + // add after highlighted text + while mid_len + after.len() > end_line { + after.pop_back(); + } + after.iter().for_each(|line| { + text_output.lines.push(Line::from(vec![ + Span::styled( + format!( + "{: >max_line_num$}", + line_number.to_string(), + max_line_num = max_line_num + ), + Style::default().fg(Color::Gray).bg(Color::DarkGray), + ), + Span::styled( + "\u{2800} ".to_string() + line, + Style::default().add_modifier(Modifier::DIM), + ), + ])); + line_number += 1; + }); + } else { + text_output.extend(Text::from("No sourcemap for contract")); + } + } else { + text_output + .extend(Text::from(format!("No srcmap index for contract {contract_name}"))); + } + } else { + text_output.extend(Text::from(format!("Unknown contract at address {address}"))); + } + + let paragraph = + Paragraph::new(text_output).block(block_source_code).wrap(Wrap { trim: false }); + f.render_widget(paragraph, area); + } + + /// Draw opcode list into main component + fn draw_op_list( + f: &mut Frame<'_>, + address: Address, + debug_steps: &[DebugStep], + opcode_list: &[String], + current_step: usize, + draw_memory: &mut DrawMemory, + area: Rect, + ) { + let block_source_code = Block::default() + .title(format!( + "Address: {} | PC: {} | Gas used in call: {}", + address, + if let Some(step) = debug_steps.get(current_step) { + step.pc.to_string() + } else { + "END".to_string() + }, + debug_steps[current_step].total_gas_used, + )) + .borders(Borders::ALL); + let mut text_output: Vec = Vec::new(); + + // Scroll: + // Focused line is line that should always be at the center of the screen. + let display_start; + + let height = area.height as i32; + let extra_top_lines = height / 2; + let prev_start = draw_memory.current_startline; + // Absolute minimum start line + let abs_min_start = 0; + // Adjust for weird scrolling for max top line + let abs_max_start = (opcode_list.len() as i32 - 1) - (height / 2); + // actual minimum start line + let mut min_start = + max(current_step as i32 - height + extra_top_lines, abs_min_start) as usize; + + // actual max start line + let mut max_start = + max(min(current_step as i32 - extra_top_lines, abs_max_start), abs_min_start) as usize; + + // Sometimes, towards end of file, maximum and minim lines have swapped values. Swap if the + // case + if min_start > max_start { + std::mem::swap(&mut min_start, &mut max_start); + } + + if prev_start < min_start { + display_start = min_start; + } else if prev_start > max_start { + display_start = max_start; + } else { + display_start = prev_start; + } + draw_memory.current_startline = display_start; + + let max_pc_len = + debug_steps.iter().fold(0, |max_val, val| val.pc.max(max_val)).to_string().len(); + + // Define closure that prints one more line of source code + let mut add_new_line = |line_number| { + let bg_color = if line_number == current_step { Color::DarkGray } else { Color::Reset }; + + // Format line number + let line_number_format = if line_number == current_step { + let step: &DebugStep = &debug_steps[line_number]; + format!("{:0>max_pc_len$x}|▶", step.pc) + } else if line_number < debug_steps.len() { + let step: &DebugStep = &debug_steps[line_number]; + format!("{:0>max_pc_len$x}| ", step.pc) + } else { + "END CALL".to_string() + }; + + if let Some(op) = opcode_list.get(line_number) { + text_output.push(Line::from(Span::styled( + format!("{line_number_format}{op}"), + Style::default().fg(Color::White).bg(bg_color), + ))); + } else { + text_output.push(Line::from(Span::styled( + line_number_format, + Style::default().fg(Color::White).bg(bg_color), + ))); + } + }; + for number in display_start..opcode_list.len() { + add_new_line(number); + } + // Add one more "phantom" line so we see line where current segment execution ends + add_new_line(opcode_list.len()); + let paragraph = + Paragraph::new(text_output).block(block_source_code).wrap(Wrap { trim: true }); + f.render_widget(paragraph, area); + } + + /// Draw the stack into the stack pane + fn draw_stack( + f: &mut Frame<'_>, + debug_steps: &[DebugStep], + current_step: usize, + area: Rect, + stack_labels: bool, + draw_memory: &DrawMemory, + ) { + let stack = &debug_steps[current_step].stack; + let stack_space = + Block::default().title(format!("Stack: {}", stack.len())).borders(Borders::ALL); + let min_len = usize::max(format!("{}", stack.len()).len(), 2); + + let params = if let Instruction::OpCode(op) = debug_steps[current_step].instruction { + OpcodeParam::of(op) + } else { + &[] + }; + + let text: Vec = stack + .iter() + .rev() + .enumerate() + .skip(draw_memory.current_stack_startline) + .map(|(i, stack_item)| { + let param = params.iter().find(|param| param.index == i); + let mut words: Vec = (0..32) + .rev() + .map(|i| stack_item.byte(i)) + .map(|byte| { + Span::styled( + format!("{byte:02x} "), + if param.is_some() { + Style::default().fg(Color::Cyan) + } else if byte == 0 { + // this improves compatibility across terminals by not combining + // color with DIM modifier + Style::default().add_modifier(Modifier::DIM) + } else { + Style::default().fg(Color::White) + }, + ) + }) + .collect(); + + if stack_labels { + if let Some(param) = param { + words.push(Span::raw(format!("| {}", param.name))); + } else { + words.push(Span::raw("| ".to_string())); + } + } + + let mut spans = vec![Span::styled( + format!("{i:0min_len$}| "), + Style::default().fg(Color::White), + )]; + spans.extend(words); + spans.push(Span::raw("\n")); + + Line::from(spans) + }) + .collect(); + + let paragraph = Paragraph::new(text).block(stack_space).wrap(Wrap { trim: true }); + f.render_widget(paragraph, area); + } + + /// The memory_access variable stores the index on the stack that indicates the memory + /// offset/size accessed by the given opcode: + /// (read memory offset, read memory size, write memory offset, write memory size) + /// >= 1: the stack index + /// 0: no memory access + /// -1: a fixed size of 32 bytes + /// -2: a fixed size of 1 byte + /// The return value is a tuple about accessed memory region by the given opcode: + /// (read memory offset, read memory size, write memory offset, write memory size) + fn get_memory_access( + op: u8, + stack: &Vec, + ) -> (Option, Option, Option, Option) { + let memory_access = match op { + opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => (1, 2, 0, 0), + opcode::CALLDATACOPY | opcode::CODECOPY | opcode::RETURNDATACOPY => (0, 0, 1, 3), + opcode::EXTCODECOPY => (0, 0, 2, 4), + opcode::MLOAD => (1, -1, 0, 0), + opcode::MSTORE => (0, 0, 1, -1), + opcode::MSTORE8 => (0, 0, 1, -2), + opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => { + (1, 2, 0, 0) + } + opcode::CREATE | opcode::CREATE2 => (2, 3, 0, 0), + opcode::CALL | opcode::CALLCODE => (4, 5, 0, 0), + opcode::DELEGATECALL | opcode::STATICCALL => (3, 4, 0, 0), + _ => Default::default(), + }; + + let stack_len = stack.len(); + let get_size = |stack_index| match stack_index { + -2 => Some(1), + -1 => Some(32), + 0 => None, + 1.. => Some(stack[stack_len - stack_index as usize].saturating_to()), + _ => panic!("invalid stack index"), + }; + + let (read_offset, read_size, write_offset, write_size) = ( + get_size(memory_access.0), + get_size(memory_access.1), + get_size(memory_access.2), + get_size(memory_access.3), + ); + (read_offset, read_size, write_offset, write_size) + } + + /// Draw memory in memory pane + fn draw_memory( + f: &mut Frame<'_>, + debug_steps: &[DebugStep], + current_step: usize, + area: Rect, + mem_utf8: bool, + draw_mem: &DrawMemory, + ) { + let memory = &debug_steps[current_step].memory; + let memory_space = Block::default() + .title(format!("Memory (max expansion: {} bytes)", memory.len())) + .borders(Borders::ALL); + let max_i = memory.len() / 32; + let min_len = format!("{:x}", max_i * 32).len(); + + // color memory region based on write/read + let mut offset: Option = None; + let mut size: Option = None; + let mut color = None; + if let Instruction::OpCode(op) = debug_steps[current_step].instruction { + let stack_len = debug_steps[current_step].stack.len(); + if stack_len > 0 { + let (read_offset, read_size, write_offset, write_size) = + Debugger::get_memory_access(op, &debug_steps[current_step].stack); + if read_offset.is_some() { + offset = read_offset; + size = read_size; + color = Some(Color::Cyan); + } else if write_offset.is_some() { + offset = write_offset; + size = write_size; + color = Some(Color::Red); + } + } + } + + // color word on previous write op + if current_step > 0 { + let prev_step = current_step - 1; + if let Instruction::OpCode(op) = debug_steps[prev_step].instruction { + let (_, _, write_offset, write_size) = + Debugger::get_memory_access(op, &debug_steps[prev_step].stack); + if write_offset.is_some() { + offset = write_offset; + size = write_size; + color = Some(Color::Green); + } + } + } + + let height = area.height as usize; + let end_line = draw_mem.current_mem_startline + height; + + let text: Vec = memory + .chunks(32) + .enumerate() + .skip(draw_mem.current_mem_startline) + .take_while(|(i, _)| i < &end_line) + .map(|(i, mem_word)| { + let words: Vec = mem_word + .iter() + .enumerate() + .map(|(j, byte)| { + Span::styled( + format!("{byte:02x} "), + if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { + if (i == offset / 32 && j >= offset % 32) || + (i > offset / 32 && i < (offset + size - 1) / 32) || + (i == (offset + size - 1) / 32 && + j <= (offset + size - 1) % 32) + { + // [offset, offset + size] is the memory region to be colored. + // If a byte at row i and column j in the memory panel + // falls in this region, set the color. + Style::default().fg(color) + } else if *byte == 0 { + Style::default().add_modifier(Modifier::DIM) + } else { + Style::default().fg(Color::White) + } + } else if *byte == 0 { + Style::default().add_modifier(Modifier::DIM) + } else { + Style::default().fg(Color::White) + }, + ) + }) + .collect(); + + let mut spans = vec![Span::styled( + format!("{:0min_len$x}| ", i * 32), + Style::default().fg(Color::White), + )]; + spans.extend(words); + + if mem_utf8 { + let chars: Vec = mem_word + .chunks(4) + .map(|utf| { + if let Ok(utf_str) = std::str::from_utf8(utf) { + Span::raw(utf_str.replace(char::from(0), ".")) + } else { + Span::raw(".") + } + }) + .collect(); + spans.push(Span::raw("|")); + spans.extend(chars); + } + + spans.push(Span::raw("\n")); + + Line::from(spans) + }) + .collect(); + let paragraph = Paragraph::new(text).block(memory_space).wrap(Wrap { trim: true }); + f.render_widget(paragraph, area); + } +} + +/// Message sent from the event listener to the main thread. +enum Interrupt { + KeyEvent(KeyEvent), + MouseEvent(MouseEvent), + IntervalElapsed, +} + +impl Interrupt { + fn char_press(&self) -> Option { + match *self { + Self::KeyEvent(KeyEvent { code: KeyCode::Char(code), .. }) + if code.is_alphanumeric() || code == '\'' => + { + Some(code) + } + _ => None, + } + } +} + +/// This is currently used to remember last scroll position so screen doesn't wiggle as much. +#[derive(Default)] +struct DrawMemory { + current_startline: usize, + inner_call_index: usize, + current_mem_startline: usize, + current_stack_startline: usize, +} + +/// Handles terminal state. `restore` should be called before drop to handle errors. +#[must_use] +struct DebuggerGuard<'a>(&'a mut Debugger); + +impl<'a> DebuggerGuard<'a> { + fn setup(dbg: &'a mut Debugger) -> Result { + let this = Self(dbg); + enable_raw_mode()?; + execute!(*this.0.terminal.backend_mut(), EnterAlternateScreen, EnableMouseCapture)?; + this.0.terminal.hide_cursor()?; + Ok(this) + } + + fn restore(&mut self) -> Result<()> { + disable_raw_mode()?; + execute!(*self.0.terminal.backend_mut(), LeaveAlternateScreen, DisableMouseCapture)?; + self.0.terminal.show_cursor()?; + Ok(()) + } +} + +impl Drop for DebuggerGuard<'_> { + #[inline] + fn drop(&mut self) { + let _ = self.restore(); + } +} + +fn event_listener(tx: mpsc::Sender) { + // This is the recommend tick rate from `ratatui`, based on their examples + let tick_rate = Duration::from_millis(200); + + let mut last_tick = Instant::now(); + loop { + // Poll events since last tick - if last tick is greater than tick_rate, we + // demand immediate availability of the event. This may affect interactivity, + // but I'm not sure as it is hard to test. + if event::poll(tick_rate.saturating_sub(last_tick.elapsed())).unwrap() { + let event = event::read().unwrap(); + match event { + Event::Key(key) => { + if tx.send(Interrupt::KeyEvent(key)).is_err() { + return + } + } + Event::Mouse(mouse) => { + if tx.send(Interrupt::MouseEvent(mouse)).is_err() { + return + } + } + Event::FocusGained | Event::FocusLost | Event::Paste(_) | Event::Resize(..) => {} + } + } + + // Force update if time has passed + if last_tick.elapsed() > tick_rate { + if tx.send(Interrupt::IntervalElapsed).is_err() { + return + } + last_tick = Instant::now(); + } + } +} diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index e14fdea0e9d16..ce2f2f03afcbf 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -65,15 +65,24 @@ impl DebugArena { /// /// This makes it easy to pretty print the execution steps. pub fn flatten(&self, entry: usize) -> Vec<(Address, Vec, CallKind)> { + let mut flattened = Vec::new(); + self.flatten_to(entry, &mut flattened); + flattened + } + + /// Recursively traverses the tree of debug nodes and flattens it into the given list. + /// + /// See [`flatten`](Self::flatten) for more information. + pub fn flatten_to(&self, entry: usize, out: &mut Vec<(Address, Vec, CallKind)>) { let node = &self.arena[entry]; - let mut flattened = vec![]; if !node.steps.is_empty() { - flattened.push((node.address, node.steps.clone(), node.kind)); + out.push((node.address, node.steps.clone(), node.kind)); } - flattened.extend(node.children.iter().flat_map(|child| self.flatten(*child))); - flattened + for child in &node.children { + self.flatten_to(*child, out); + } } } diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 5777ef8ad3107..ed708bc011736 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -84,7 +84,7 @@ enum BackendRequest { /// /// This handler will remain active as long as it is reachable (request channel still open) and /// requests are in progress. -#[must_use = "BackendHandler does nothing unless polled."] +#[must_use = "futures do nothing unless polled"] pub struct BackendHandler { provider: M, /// Stores all the data. diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 3bc129718e318..f00d5ffeda77f 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -179,7 +179,7 @@ enum ForkTask { } /// The type that manages connections in the background -#[must_use = "MultiForkHandler does nothing unless polled."] +#[must_use = "futures do nothing unless polled"] pub struct MultiForkHandler { /// Incoming requests from the `MultiFork`. incoming: Fuse>, diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 1f60813701c9c..8f1787671cb22 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -379,7 +379,7 @@ pub type ContractFactory = DeploymentTxFactory, M>; /// /// Currently, we recommend using the [`ContractDeployer`] type alias. #[derive(Debug)] -#[must_use = "DeploymentTx does nothing unless you `send` it"] +#[must_use = "ContractDeploymentTx does nothing unless you `send` it"] pub struct ContractDeploymentTx { /// the actual deployer, exposed for overriding the defaults pub deployer: Deployer, diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index f72d70d6fa706..f2a8d21f14472 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -6,7 +6,7 @@ use ethers_signers::Signer; use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider, types::ToAlloy}; -use foundry_debugger::DebuggerArgs; +use foundry_debugger::DebuggerBuilder; use std::sync::Arc; /// Helper alias type for the collection of data changed due to the new sender. @@ -84,13 +84,13 @@ impl ScriptArgs { let mut decoder = self.decode_traces(&script_config, &mut result, &known_contracts)?; if self.debug { - let debugger = DebuggerArgs { - debug: result.debug.clone().unwrap_or_default(), - decoder: &decoder, - sources, - breakpoints: result.breakpoints.clone(), - }; - debugger.run()?; + let mut debugger = DebuggerBuilder::new() + .debug_arenas(result.debug.as_deref().unwrap_or_default()) + .decoder(&decoder) + .sources(sources) + .breakpoints(result.breakpoints.clone()) + .build()?; + debugger.try_run()?; } if let Some((new_traces, updated_libraries, updated_contracts)) = self diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 592501cc5541a..8678848d74868 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -306,7 +306,7 @@ impl ScriptRunner { vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), - debug: vec![debug].into_iter().collect(), + debug: debug.map(|d| vec![d]), labeled_addresses: labels, transactions, address: None, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 42040a03744f4..e9e822214974a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -31,7 +31,7 @@ use foundry_config::{ }, get_available_profiles, Config, }; -use foundry_debugger::DebuggerArgs; +use foundry_debugger::DebuggerBuilder; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use watchexec::config::{InitConfig, RuntimeConfig}; @@ -315,13 +315,14 @@ impl TestArgs { let test = outcome.clone().into_tests().next().unwrap(); let result = test.result; // Run the debugger - let debugger = DebuggerArgs { - debug: result.debug.map_or(vec![], |debug| vec![debug]), - decoder: decoders.first().unwrap(), - sources, - breakpoints: result.breakpoints, - }; - debugger.run()?; + let mut debugger = DebuggerBuilder::new() + // TODO: `Option::as_slice` in 1.75 + .debug_arenas(result.debug.as_ref().map(core::slice::from_ref).unwrap_or_default()) + .decoders(&decoders) + .sources(sources) + .breakpoints(result.breakpoints) + .build()?; + debugger.try_run()?; } Ok(outcome) From de73dde2814a78fee1eb959f4db91a1890c6f47b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 2 Dec 2023 15:07:53 +0100 Subject: [PATCH 0367/1963] chore: misc fmt (#6498) * chore: misc fmt * chore: order doc parser --- crates/config/src/inline/natspec.rs | 1 + crates/doc/src/parser/mod.rs | 20 +- crates/fmt/src/formatter.rs | 1778 +++++++++++++-------------- 3 files changed, 900 insertions(+), 899 deletions(-) diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index c73cc4492dc75..11557fd7a8295 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -7,6 +7,7 @@ use serde_json::Value; use std::{collections::BTreeMap, path::Path}; /// Convenient struct to hold in-line per-test configurations +#[derive(Debug)] pub struct NatSpec { /// The parent contract of the natspec pub contract: String, diff --git a/crates/doc/src/parser/mod.rs b/crates/doc/src/parser/mod.rs index 4b3e99ce13b03..6f03a5fb2b1dd 100644 --- a/crates/doc/src/parser/mod.rs +++ b/crates/doc/src/parser/mod.rs @@ -171,6 +171,14 @@ impl Visitor for Parser { Ok(()) } + fn visit_enum(&mut self, enumerable: &mut EnumDefinition) -> ParserResult<()> { + self.add_element_to_parent(ParseSource::Enum(enumerable.clone()), enumerable.loc) + } + + fn visit_var_definition(&mut self, var: &mut VariableDefinition) -> ParserResult<()> { + self.add_element_to_parent(ParseSource::Variable(var.clone()), var.loc) + } + fn visit_function(&mut self, func: &mut FunctionDefinition) -> ParserResult<()> { // If the function parameter doesn't have a name, try to set it with // `@custom:name` tag if any was provided @@ -195,8 +203,8 @@ impl Visitor for Parser { self.add_element_to_parent(ParseSource::Function(func.clone()), func.loc) } - fn visit_var_definition(&mut self, var: &mut VariableDefinition) -> ParserResult<()> { - self.add_element_to_parent(ParseSource::Variable(var.clone()), var.loc) + fn visit_struct(&mut self, structure: &mut StructDefinition) -> ParserResult<()> { + self.add_element_to_parent(ParseSource::Struct(structure.clone()), structure.loc) } fn visit_event(&mut self, event: &mut EventDefinition) -> ParserResult<()> { @@ -207,14 +215,6 @@ impl Visitor for Parser { self.add_element_to_parent(ParseSource::Error(error.clone()), error.loc) } - fn visit_struct(&mut self, structure: &mut StructDefinition) -> ParserResult<()> { - self.add_element_to_parent(ParseSource::Struct(structure.clone()), structure.loc) - } - - fn visit_enum(&mut self, enumerable: &mut EnumDefinition) -> ParserResult<()> { - self.add_element_to_parent(ParseSource::Enum(enumerable.clone()), enumerable.loc) - } - fn visit_type_definition(&mut self, def: &mut TypeDefinition) -> ParserResult<()> { self.add_element_to_parent(ParseSource::Type(def.clone()), def.loc) } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 02cf851697fe4..2ed579dce59cb 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -92,46 +92,6 @@ pub struct Formatter<'a, W> { inline_config: InlineConfig, } -/// An action which may be committed to a Formatter -struct Transaction<'f, 'a, W> { - fmt: &'f mut Formatter<'a, W>, - buffer: String, - comments: Comments, -} - -impl<'f, 'a, W> std::ops::Deref for Transaction<'f, 'a, W> { - type Target = Formatter<'a, W>; - fn deref(&self) -> &Self::Target { - self.fmt - } -} - -impl<'f, 'a, W> std::ops::DerefMut for Transaction<'f, 'a, W> { - fn deref_mut(&mut self) -> &mut Self::Target { - self.fmt - } -} - -impl<'f, 'a, W: Write> Transaction<'f, 'a, W> { - /// Create a new transaction from a callback - fn new( - fmt: &'f mut Formatter<'a, W>, - fun: impl FnMut(&mut Formatter<'a, W>) -> Result<()>, - ) -> Result { - let mut comments = fmt.comments.clone(); - let buffer = fmt.with_temp_buf(fun)?.w; - comments = std::mem::replace(&mut fmt.comments, comments); - Ok(Self { fmt, buffer, comments }) - } - - /// Commit the transaction to the Formatter - fn commit(self) -> Result { - self.fmt.comments = self.comments; - write_chunk!(self.fmt, "{}", self.buffer)?; - Ok(self.buffer) - } -} - impl<'a, W: Write> Formatter<'a, W> { pub fn new( w: W, @@ -1826,6 +1786,18 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Ok(()) } + // Support extension for Solana/Substrate + #[instrument(name = "annotation", skip_all)] + fn visit_annotation(&mut self, annotation: &mut Annotation) -> Result<()> { + return_source_if_disabled!(self, annotation.loc); + let id = self.simulate_to_string(|fmt| annotation.id.visit(fmt))?; + write!(self.buf(), "@{id}")?; + write!(self.buf(), "(")?; + annotation.value.visit(self)?; + write!(self.buf(), ")")?; + Ok(()) + } + #[instrument(name = "pragma", skip_all)] fn visit_pragma( &mut self, @@ -1991,6 +1963,114 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Ok(()) } + #[instrument(name = "assembly", skip_all)] + fn visit_assembly( + &mut self, + loc: Loc, + dialect: &mut Option, + block: &mut YulBlock, + flags: &mut Option>, + ) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc); + + write_chunk!(self, loc.start(), "assembly")?; + if let Some(StringLiteral { loc, string, .. }) = dialect { + write_chunk!(self, loc.start(), loc.end(), "\"{string}\"")?; + } + if let Some(flags) = flags { + if !flags.is_empty() { + let loc_start = flags.first().unwrap().loc.start(); + self.surrounded( + SurroundingChunk::new("(", Some(loc_start), None), + SurroundingChunk::new(")", None, Some(block.loc.start())), + |fmt, _| { + let mut flags = flags.iter_mut().peekable(); + let mut chunks = vec![]; + while let Some(flag) = flags.next() { + let next_byte_offset = + flags.peek().map(|next_flag| next_flag.loc.start()); + chunks.push(fmt.chunked( + flag.loc.start(), + next_byte_offset, + |fmt| { + write!(fmt.buf(), "\"{}\"", flag.string)?; + Ok(()) + }, + )?); + } + fmt.write_chunks_separated(&chunks, ",", false)?; + Ok(()) + }, + )?; + } + } + + block.visit(self) + } + + #[instrument(name = "block", skip_all)] + fn visit_block( + &mut self, + loc: Loc, + unchecked: bool, + statements: &mut Vec, + ) -> Result<()> { + return_source_if_disabled!(self, loc); + if unchecked { + write_chunk!(self, loc.start(), "unchecked ")?; + } + + self.visit_block(loc, statements, false, false)?; + Ok(()) + } + + #[instrument(name = "args", skip_all)] + fn visit_args(&mut self, loc: Loc, args: &mut Vec) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc); + + write!(self.buf(), "{{")?; + + let mut args_iter = args.iter_mut().peekable(); + let mut chunks = Vec::new(); + while let Some(NamedArgument { loc: arg_loc, name, expr }) = args_iter.next() { + let next_byte_offset = args_iter + .peek() + .map(|NamedArgument { loc: arg_loc, .. }| arg_loc.start()) + .unwrap_or_else(|| loc.end()); + chunks.push(self.chunked(arg_loc.start(), Some(next_byte_offset), |fmt| { + fmt.grouped(|fmt| { + write_chunk!(fmt, name.loc.start(), "{}: ", name.name)?; + expr.visit(fmt) + })?; + Ok(()) + })?); + } + + if let Some(first) = chunks.first_mut() { + if first.prefixes.is_empty() && + first.postfixes_before.is_empty() && + !self.config.bracket_spacing + { + first.needs_space = Some(false); + } + } + let multiline = self.are_chunks_separated_multiline("{}}", &chunks, ",")?; + self.indented_if(multiline, 1, |fmt| fmt.write_chunks_separated(&chunks, ",", multiline))?; + + let prefix = if multiline && !self.is_beginning_of_line() { + "\n" + } else if self.config.bracket_spacing { + " " + } else { + "" + }; + let closing_bracket = format!("{prefix}{}", "}"); + let closing_bracket_loc = args.last().unwrap().loc.end(); + write_chunk!(self, closing_bracket_loc, "{closing_bracket}")?; + + Ok(()) + } + #[instrument(name = "expr", skip_all)] fn visit_expr(&mut self, loc: Loc, expr: &mut Expression) -> Result<()> { return_source_if_disabled!(self, loc); @@ -2361,6 +2441,62 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Ok(()) } + #[instrument(name = "var_definition", skip_all)] + fn visit_var_definition(&mut self, var: &mut VariableDefinition) -> Result<()> { + return_source_if_disabled!(self, var.loc, ';'); + + var.ty.visit(self)?; + + let multiline = self.grouped(|fmt| { + let var_name = var.name.safe_unwrap_mut(); + let name_start = var_name.loc.start(); + + let attrs = fmt.items_to_chunks_sorted(Some(name_start), var.attrs.iter_mut())?; + if !fmt.try_on_single_line(|fmt| fmt.write_chunks_separated(&attrs, "", false))? { + fmt.write_chunks_separated(&attrs, "", true)?; + } + + let mut name = fmt.visit_to_chunk(name_start, Some(var_name.loc.end()), var_name)?; + if var.initializer.is_some() { + name.content.push_str(" ="); + } + fmt.write_chunk(&name)?; + + Ok(()) + })?; + + var.initializer + .as_mut() + .map(|init| self.indented_if(multiline, 1, |fmt| fmt.visit_assignment(init))) + .transpose()?; + + self.write_semicolon()?; + + Ok(()) + } + + #[instrument(name = "var_definition_stmt", skip_all)] + fn visit_var_definition_stmt( + &mut self, + loc: Loc, + declaration: &mut VariableDeclaration, + expr: &mut Option, + ) -> Result<()> { + return_source_if_disabled!(self, loc, ';'); + + let declaration = self + .chunked(declaration.loc.start(), None, |fmt| fmt.visit_var_declaration(declaration))?; + let multiline = declaration.content.contains('\n'); + self.write_chunk(&declaration)?; + + if let Some(expr) = expr { + write!(self.buf(), " =")?; + self.indented_if(multiline, 1, |fmt| fmt.visit_assignment(expr))?; + } + + self.write_semicolon() + } + #[instrument(name = "var_declaration", skip_all)] fn visit_var_declaration(&mut self, var: &mut VariableDeclaration) -> Result<()> { return_source_if_disabled!(self, var.loc); @@ -2375,526 +2511,321 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Ok(()) } - #[instrument(name = "break", skip_all)] - fn visit_break(&mut self, loc: Loc, semicolon: bool) -> Result<()> { - if semicolon { - return_source_if_disabled!(self, loc, ';'); - } else { - return_source_if_disabled!(self, loc); - } - write_chunk!(self, loc.start(), loc.end(), "break{}", if semicolon { ";" } else { "" }) - } + #[instrument(name = "return", skip_all)] + fn visit_return(&mut self, loc: Loc, expr: &mut Option) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc, ';'); - #[instrument(name = "continue", skip_all)] - fn visit_continue(&mut self, loc: Loc, semicolon: bool) -> Result<()> { - if semicolon { - return_source_if_disabled!(self, loc, ';'); - } else { - return_source_if_disabled!(self, loc); - } - write_chunk!(self, loc.start(), loc.end(), "continue{}", if semicolon { ";" } else { "" }) - } + self.write_postfix_comments_before(loc.start())?; + self.write_prefix_comments_before(loc.start())?; - #[instrument(name = "function", skip_all)] - fn visit_function(&mut self, func: &mut FunctionDefinition) -> Result<()> { - if func.body.is_some() { - return_source_if_disabled!(self, func.loc()); - } else { - return_source_if_disabled!(self, func.loc(), ';'); + if expr.is_none() { + write_chunk!(self, loc.end(), "return;")?; + return Ok(()) } - self.with_function_context(func.clone(), |fmt| { - fmt.write_postfix_comments_before(func.loc.start())?; - fmt.write_prefix_comments_before(func.loc.start())?; - - let body_loc = func.body.as_ref().map(CodeLocation::loc); - let mut attrs_multiline = false; - let fits_on_single = fmt.try_on_single_line(|fmt| { - fmt.write_function_header(func, body_loc, false)?; - Ok(()) - })?; - if !fits_on_single { - attrs_multiline = fmt.write_function_header(func, body_loc, true)?; - } - - // write function body - match &mut func.body { - Some(body) => { - let body_loc = body.loc(); - let byte_offset = body_loc.start(); - let body = fmt.visit_to_chunk(byte_offset, Some(body_loc.end()), body)?; - fmt.write_whitespace_separator( - attrs_multiline && !(func.attributes.is_empty() && func.returns.is_empty()), - )?; - fmt.write_chunk(&body)?; - } - None => fmt.write_semicolon()?, - } - + let expr = expr.as_mut().unwrap(); + let expr_loc_start = expr.loc().start(); + let write_return = |fmt: &mut Self| -> Result<()> { + write_chunk!(fmt, loc.start(), "return")?; + fmt.write_postfix_comments_before(expr_loc_start)?; Ok(()) - })?; - - Ok(()) - } - - #[instrument(name = "function_attribute", skip_all)] - fn visit_function_attribute(&mut self, attribute: &mut FunctionAttribute) -> Result<()> { - return_source_if_disabled!(self, attribute.loc()); + }; - match attribute { - FunctionAttribute::Mutability(mutability) => { - write_chunk!(self, mutability.loc().end(), "{mutability}")? - } - FunctionAttribute::Visibility(visibility) => { - // Visibility will always have a location in a Function attribute - write_chunk!(self, visibility.loc_opt().unwrap().end(), "{visibility}")? - } - FunctionAttribute::Virtual(loc) => write_chunk!(self, loc.end(), "virtual")?, - FunctionAttribute::Immutable(loc) => write_chunk!(self, loc.end(), "immutable")?, - FunctionAttribute::Override(loc, args) => { - write_chunk!(self, loc.start(), "override")?; - if !args.is_empty() && self.config.override_spacing { - self.write_whitespace_separator(false)?; - } - self.visit_list("", args, None, Some(loc.end()), false)? + let mut write_return_with_expr = |fmt: &mut Self| -> Result<()> { + let fits_on_single = fmt.try_on_single_line(|fmt| { + write_return(fmt)?; + expr.visit(fmt) + })?; + if fits_on_single { + return Ok(()) } - FunctionAttribute::BaseOrModifier(loc, base) => { - let is_contract_base = self.context.contract.as_ref().map_or(false, |contract| { - contract.base.iter().any(|contract_base| { - contract_base - .name - .identifiers - .iter() - .zip(&base.name.identifiers) - .all(|(l, r)| l.name == r.name) - }) - }); - if is_contract_base { - base.visit(self)?; - } else { - let mut base_or_modifier = - self.visit_to_chunk(loc.start(), Some(loc.end()), base)?; - if base_or_modifier.content.ends_with("()") { - base_or_modifier.content.truncate(base_or_modifier.content.len() - 2); + let mut fit_on_next_line = false; + let tx = fmt.transact(|fmt| { + fmt.grouped(|fmt| { + write_return(fmt)?; + if !fmt.is_beginning_of_line() { + fmt.write_whitespace_separator(true)?; } - self.write_chunk(&base_or_modifier)?; - } + fit_on_next_line = fmt.try_on_single_line(|fmt| expr.visit(fmt))?; + Ok(()) + })?; + Ok(()) + })?; + if fit_on_next_line { + tx.commit()?; + return Ok(()) } - FunctionAttribute::Error(loc) => self.visit_parser_error(*loc)?, + + write_return(fmt)?; + expr.visit(fmt)?; + Ok(()) }; + write_return_with_expr(self)?; + write_chunk!(self, loc.end(), ";")?; Ok(()) } - #[instrument(name = "base", skip_all)] - fn visit_base(&mut self, base: &mut Base) -> Result<()> { - return_source_if_disabled!(self, base.loc); - - let name_loc = &base.name.loc; - let mut name = self.chunked(name_loc.start(), Some(name_loc.end()), |fmt| { - fmt.visit_ident_path(&mut base.name)?; - Ok(()) - })?; - - if base.args.is_none() || base.args.as_ref().unwrap().is_empty() { - if self.context.function.is_some() { - name.content.push_str("()"); - } - self.write_chunk(&name)?; - return Ok(()) + #[instrument(name = "revert", skip_all)] + fn visit_revert( + &mut self, + loc: Loc, + error: &mut Option, + args: &mut Vec, + ) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc, ';'); + write_chunk!(self, loc.start(), "revert")?; + if let Some(error) = error { + error.visit(self)?; } - - let args = base.args.as_mut().unwrap(); - let args_start = CodeLocation::loc(args.first().unwrap()).start(); - - name.content.push('('); - let formatted_name = self.chunk_to_string(&name)?; - - let multiline = !self.will_it_fit(&formatted_name); - - self.surrounded( - SurroundingChunk::new(&formatted_name, Some(args_start), None), - SurroundingChunk::new(")", None, Some(base.loc.end())), - |fmt, multiline_hint| { - let args = fmt.items_to_chunks( - Some(base.loc.end()), - args.iter_mut().map(|arg| (arg.loc(), arg)), - )?; - let multiline = multiline || - multiline_hint || - fmt.are_chunks_separated_multiline("{}", &args, ",")?; - fmt.write_chunks_separated(&args, ",", multiline)?; - Ok(()) - }, - )?; + self.visit_list("", args, None, Some(loc.end()), true)?; + self.write_semicolon()?; Ok(()) } - #[instrument(name = "parameter", skip_all)] - fn visit_parameter(&mut self, parameter: &mut Parameter) -> Result<()> { - return_source_if_disabled!(self, parameter.loc); - self.grouped(|fmt| { - parameter.ty.visit(fmt)?; - if let Some(storage) = ¶meter.storage { - write_chunk!(fmt, storage.loc().end(), "{storage}")?; - } - if let Some(name) = ¶meter.name { - write_chunk!(fmt, parameter.loc.end(), "{}", name.name)?; - } - Ok(()) - })?; - Ok(()) - } + #[instrument(name = "revert_named_args", skip_all)] + fn visit_revert_named_args( + &mut self, + loc: Loc, + error: &mut Option, + args: &mut Vec, + ) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc, ';'); - #[instrument(name = "struct", skip_all)] - fn visit_struct(&mut self, structure: &mut StructDefinition) -> Result<()> { - return_source_if_disabled!(self, structure.loc); - self.grouped(|fmt| { - let struct_name = structure.name.safe_unwrap_mut(); - write_chunk!(fmt, struct_name.loc.start(), "struct")?; - struct_name.visit(fmt)?; - if structure.fields.is_empty() { - return fmt.write_empty_brackets() + write_chunk!(self, loc.start(), "revert")?; + let mut error_indented = false; + if let Some(error) = error { + if !self.try_on_single_line(|fmt| error.visit(fmt))? { + error.visit(self)?; + error_indented = true; } + } - write!(fmt.buf(), " {{")?; - fmt.surrounded( - SurroundingChunk::new("", Some(struct_name.loc.end()), None), - SurroundingChunk::new("}", None, Some(structure.loc.end())), - |fmt, _multiline| { - let chunks = fmt.items_to_chunks( - Some(structure.loc.end()), - structure.fields.iter_mut().map(|ident| (ident.loc, ident)), - )?; - for mut chunk in chunks { - chunk.content.push(';'); - fmt.write_chunk(&chunk)?; - fmt.write_whitespace_separator(true)?; - } - Ok(()) - }, - ) - })?; + if args.is_empty() { + write!(self.buf(), "({{}});")?; + return Ok(()) + } + + write!(self.buf(), "(")?; + self.indented_if(error_indented, 1, |fmt| fmt.visit_args(loc, args))?; + write!(self.buf(), ")")?; + self.write_semicolon()?; Ok(()) } - #[instrument(name = "type_definition", skip_all)] - fn visit_type_definition(&mut self, def: &mut TypeDefinition) -> Result<()> { - return_source_if_disabled!(self, def.loc, ';'); - self.grouped(|fmt| { - write_chunk!(fmt, def.loc.start(), def.name.loc.start(), "type")?; - def.name.visit(fmt)?; - write_chunk!(fmt, def.name.loc.end(), CodeLocation::loc(&def.ty).start(), "is")?; - def.ty.visit(fmt)?; - fmt.write_semicolon()?; - Ok(()) - })?; - Ok(()) + #[instrument(name = "break", skip_all)] + fn visit_break(&mut self, loc: Loc, semicolon: bool) -> Result<()> { + if semicolon { + return_source_if_disabled!(self, loc, ';'); + } else { + return_source_if_disabled!(self, loc); + } + write_chunk!(self, loc.start(), loc.end(), "break{}", if semicolon { ";" } else { "" }) } - #[instrument(name = "stray_semicolon", skip_all)] - fn visit_stray_semicolon(&mut self) -> Result<()> { - self.write_semicolon() + #[instrument(name = "continue", skip_all)] + fn visit_continue(&mut self, loc: Loc, semicolon: bool) -> Result<()> { + if semicolon { + return_source_if_disabled!(self, loc, ';'); + } else { + return_source_if_disabled!(self, loc); + } + write_chunk!(self, loc.start(), loc.end(), "continue{}", if semicolon { ";" } else { "" }) } - #[instrument(name = "block", skip_all)] - fn visit_block( + #[instrument(name = "try", skip_all)] + fn visit_try( &mut self, loc: Loc, - unchecked: bool, - statements: &mut Vec, - ) -> Result<()> { - return_source_if_disabled!(self, loc); - if unchecked { - write_chunk!(self, loc.start(), "unchecked ")?; - } - - self.visit_block(loc, statements, false, false)?; - Ok(()) - } - - #[instrument(name = "opening_paren", skip_all)] - fn visit_opening_paren(&mut self) -> Result<()> { - write_chunk!(self, "(")?; - Ok(()) - } - - #[instrument(name = "closing_paren", skip_all)] - fn visit_closing_paren(&mut self) -> Result<()> { - write_chunk!(self, ")")?; - Ok(()) - } - - #[instrument(name = "newline", skip_all)] - fn visit_newline(&mut self) -> Result<()> { - writeln_chunk!(self)?; - Ok(()) - } - - #[instrument(name = "event", skip_all)] - fn visit_event(&mut self, event: &mut EventDefinition) -> Result<()> { - return_source_if_disabled!(self, event.loc, ';'); - - let event_name = event.name.safe_unwrap_mut(); - let mut name = - self.visit_to_chunk(event_name.loc.start(), Some(event.loc.end()), event_name)?; - name.content = format!("event {}(", name.content); - - let last_chunk = if event.anonymous { ") anonymous;" } else { ");" }; - if event.fields.is_empty() { - name.content.push_str(last_chunk); - self.write_chunk(&name)?; - } else { - let byte_offset = event.fields.first().unwrap().loc.start(); - let first_chunk = self.chunk_to_string(&name)?; - self.surrounded( - SurroundingChunk::new(first_chunk, Some(byte_offset), None), - SurroundingChunk::new(last_chunk, None, Some(event.loc.end())), - |fmt, multiline| { - let params = fmt - .items_to_chunks(None, event.fields.iter_mut().map(|arg| (arg.loc, arg)))?; - - let multiline = - multiline && fmt.are_chunks_separated_multiline("{}", ¶ms, ",")?; - fmt.write_chunks_separated(¶ms, ",", multiline) - }, - )?; - } - - Ok(()) - } - - #[instrument(name = "event_parameter", skip_all)] - fn visit_event_parameter(&mut self, param: &mut EventParameter) -> Result<()> { - return_source_if_disabled!(self, param.loc); - - self.grouped(|fmt| { - param.ty.visit(fmt)?; - if param.indexed { - write_chunk!(fmt, param.loc.start(), "indexed")?; - } - if let Some(name) = ¶m.name { - write_chunk!(fmt, name.loc.end(), "{}", name.name)?; - } - Ok(()) - })?; - Ok(()) - } - - #[instrument(name = "error", skip_all)] - fn visit_error(&mut self, error: &mut ErrorDefinition) -> Result<()> { - return_source_if_disabled!(self, error.loc, ';'); - - let error_name = error.name.safe_unwrap_mut(); - let mut name = self.visit_to_chunk(error_name.loc.start(), None, error_name)?; - name.content = format!("error {}", name.content); - - let formatted_name = self.chunk_to_string(&name)?; - write!(self.buf(), "{formatted_name}")?; - let start_offset = error.fields.first().map(|f| f.loc.start()); - self.visit_list("", &mut error.fields, start_offset, Some(error.loc.end()), true)?; - self.write_semicolon()?; - - Ok(()) - } + expr: &mut Expression, + returns: &mut Option<(Vec<(Loc, Option)>, Box)>, + clauses: &mut Vec, + ) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc); - #[instrument(name = "error_parameter", skip_all)] - fn visit_error_parameter(&mut self, param: &mut ErrorParameter) -> Result<()> { - return_source_if_disabled!(self, param.loc); - self.grouped(|fmt| { - param.ty.visit(fmt)?; - if let Some(name) = ¶m.name { - write_chunk!(fmt, name.loc.end(), "{}", name.name)?; + let try_next_byte = clauses.first().map(|c| match c { + CatchClause::Simple(loc, ..) => loc.start(), + CatchClause::Named(loc, ..) => loc.start(), + }); + let try_chunk = self.chunked(loc.start(), try_next_byte, |fmt| { + write_chunk!(fmt, loc.start(), expr.loc().start(), "try")?; + expr.visit(fmt)?; + if let Some((params, stmt)) = returns { + let mut params = + params.iter_mut().filter(|(_, param)| param.is_some()).collect::>(); + let byte_offset = params.first().map_or(stmt.loc().start(), |p| p.0.start()); + fmt.surrounded( + SurroundingChunk::new("returns (", Some(byte_offset), None), + SurroundingChunk::new(")", None, params.last().map(|p| p.0.end())), + |fmt, _| { + let chunks = fmt.items_to_chunks( + Some(stmt.loc().start()), + params.iter_mut().map(|(loc, ref mut ident)| (*loc, ident)), + )?; + let multiline = fmt.are_chunks_separated_multiline("{})", &chunks, ",")?; + fmt.write_chunks_separated(&chunks, ",", multiline)?; + Ok(()) + }, + )?; + stmt.visit(fmt)?; } Ok(()) })?; - Ok(()) - } - - #[instrument(name = "using", skip_all)] - fn visit_using(&mut self, using: &mut Using) -> Result<()> { - return_source_if_disabled!(self, using.loc, ';'); - - write_chunk!(self, using.loc.start(), "using")?; - - let ty_start = using.ty.as_mut().map(|ty| CodeLocation::loc(&ty).start()); - let global_start = using.global.as_mut().map(|global| global.loc.start()); - let loc_end = using.loc.end(); - let (is_library, mut list_chunks) = match &mut using.list { - UsingList::Library(library) => { - (true, vec![self.visit_to_chunk(library.loc.start(), None, library)?]) - } - UsingList::Functions(funcs) => { - let mut funcs = funcs.iter_mut().peekable(); - let mut chunks = Vec::new(); - while let Some(func) = funcs.next() { - let next_byte_end = funcs.peek().map(|func| func.loc.start()); - chunks.push(self.chunked(func.loc.start(), next_byte_end, |fmt| { - fmt.visit_ident_path(&mut func.path)?; - if let Some(op) = func.oper { - write!(fmt.buf(), " as {op}")?; - } - Ok(()) - })?); + let mut chunks = vec![try_chunk]; + for clause in clauses { + let (loc, ident, mut param, stmt) = match clause { + CatchClause::Simple(loc, param, stmt) => (loc, None, param.as_mut(), stmt), + CatchClause::Named(loc, ident, param, stmt) => { + (loc, Some(ident), Some(param), stmt) } - (false, chunks) - } - UsingList::Error => return self.visit_parser_error(using.loc), - }; - - let for_chunk = self.chunk_at( - using.loc.start(), - Some(ty_start.or(global_start).unwrap_or(loc_end)), - None, - "for", - ); - let ty_chunk = if let Some(ty) = &mut using.ty { - self.visit_to_chunk(ty.loc().start(), Some(global_start.unwrap_or(loc_end)), ty)? - } else { - self.chunk_at(using.loc.start(), Some(global_start.unwrap_or(loc_end)), None, "*") - }; - let global_chunk = using - .global - .as_mut() - .map(|global| self.visit_to_chunk(global.loc.start(), Some(using.loc.end()), global)) - .transpose()?; + }; - let write_for_def = |fmt: &mut Self| { - fmt.grouped(|fmt| { - fmt.write_chunk(&for_chunk)?; - fmt.write_chunk(&ty_chunk)?; - if let Some(global_chunk) = global_chunk.as_ref() { - fmt.write_chunk(global_chunk)?; + let chunk = self.chunked(loc.start(), Some(stmt.loc().start()), |fmt| { + write_chunk!(fmt, "catch")?; + if let Some(ident) = ident.as_ref() { + fmt.write_postfix_comments_before( + param.as_ref().map(|p| p.loc.start()).unwrap_or_else(|| ident.loc.end()), + )?; + write_chunk!(fmt, ident.loc.start(), "{}", ident.name)?; } + if let Some(param) = param.as_mut() { + write_chunk_spaced!(fmt, param.loc.start(), Some(ident.is_none()), "(")?; + fmt.surrounded( + SurroundingChunk::new("", Some(param.loc.start()), None), + SurroundingChunk::new(")", None, Some(stmt.loc().start())), + |fmt, _| param.visit(fmt), + )?; + } + + stmt.visit(fmt)?; Ok(()) })?; - Ok(()) - }; - let simulated_for_def = self.simulate_to_string(write_for_def)?; - - if is_library { - let chunk = list_chunks.pop().unwrap(); - if self.will_chunk_fit(&format!("{{}} {simulated_for_def};"), &chunk)? { - self.write_chunk(&chunk)?; - write_for_def(self)?; - } else { - self.write_whitespace_separator(true)?; - self.grouped(|fmt| { - fmt.write_chunk(&chunk)?; - Ok(()) - })?; - self.write_whitespace_separator(true)?; - write_for_def(self)?; - } - } else { - self.surrounded( - SurroundingChunk::new("{", Some(using.loc.start()), None), - SurroundingChunk::new( - "}", - None, - Some(ty_start.or(global_start).unwrap_or(loc_end)), - ), - |fmt, _multiline| { - let multiline = fmt.are_chunks_separated_multiline( - &format!("{{ {{}} }} {simulated_for_def};"), - &list_chunks, - ",", - )?; - fmt.write_chunks_separated(&list_chunks, ",", multiline)?; - Ok(()) - }, - )?; - write_for_def(self)?; + chunks.push(chunk); } - self.write_semicolon()?; + let multiline = self.are_chunks_separated_multiline("{}", &chunks, "")?; + if !multiline { + self.write_chunks_separated(&chunks, "", false)?; + return Ok(()) + } - Ok(()) - } + let mut chunks = chunks.iter_mut().peekable(); + let mut prev_multiline = false; - #[instrument(name = "var_attribute", skip_all)] - fn visit_var_attribute(&mut self, attribute: &mut VariableAttribute) -> Result<()> { - return_source_if_disabled!(self, attribute.loc()); + // write try chunk first + if let Some(chunk) = chunks.next() { + let chunk_str = self.simulate_to_string(|fmt| fmt.write_chunk(chunk))?; + write!(self.buf(), "{chunk_str}")?; + prev_multiline = chunk_str.contains('\n'); + } - let token = match attribute { - VariableAttribute::Visibility(visibility) => Some(visibility.to_string()), - VariableAttribute::Constant(_) => Some("constant".to_string()), - VariableAttribute::Immutable(_) => Some("immutable".to_string()), - VariableAttribute::Override(loc, idents) => { - write_chunk!(self, loc.start(), "override")?; - if !idents.is_empty() && self.config.override_spacing { - self.write_whitespace_separator(false)?; - } - self.visit_list("", idents, Some(loc.start()), Some(loc.end()), false)?; - None - } - }; - if let Some(token) = token { - let loc = attribute.loc(); - write_chunk!(self, loc.start(), loc.end(), "{}", token)?; + while let Some(chunk) = chunks.next() { + let chunk_str = self.simulate_to_string(|fmt| fmt.write_chunk(chunk))?; + let multiline = chunk_str.contains('\n'); + self.indented_if(!multiline, 1, |fmt| { + chunk.needs_space = Some(false); + let on_same_line = prev_multiline && (multiline || chunks.peek().is_none()); + let prefix = if fmt.is_beginning_of_line() { + "" + } else if on_same_line { + " " + } else { + "\n" + }; + let chunk_str = format!("{prefix}{chunk_str}"); + write!(fmt.buf(), "{chunk_str}")?; + Ok(()) + })?; + prev_multiline = multiline; } Ok(()) } - #[instrument(name = "var_definition", skip_all)] - fn visit_var_definition(&mut self, var: &mut VariableDefinition) -> Result<()> { - return_source_if_disabled!(self, var.loc, ';'); - - var.ty.visit(self)?; - - let multiline = self.grouped(|fmt| { - let var_name = var.name.safe_unwrap_mut(); - let name_start = var_name.loc.start(); - - let attrs = fmt.items_to_chunks_sorted(Some(name_start), var.attrs.iter_mut())?; - if !fmt.try_on_single_line(|fmt| fmt.write_chunks_separated(&attrs, "", false))? { - fmt.write_chunks_separated(&attrs, "", true)?; - } + #[instrument(name = "if", skip_all)] + fn visit_if( + &mut self, + loc: Loc, + cond: &mut Expression, + if_branch: &mut Box, + else_branch: &mut Option>, + is_first_stmt: bool, + ) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc); - let mut name = fmt.visit_to_chunk(name_start, Some(var_name.loc.end()), var_name)?; - if var.initializer.is_some() { - name.content.push_str(" ="); - } - fmt.write_chunk(&name)?; + if !is_first_stmt { + self.write_if_stmt(loc, cond, if_branch, else_branch)?; + return Ok(()) + } + self.context.if_stmt_single_line = Some(true); + let mut stmt_fits_on_single = false; + let tx = self.transact(|fmt| { + stmt_fits_on_single = match fmt.write_if_stmt(loc, cond, if_branch, else_branch) { + Ok(()) => true, + Err(FormatterError::Fmt(_)) => false, + Err(err) => bail!(err), + }; Ok(()) })?; - var.initializer - .as_mut() - .map(|init| self.indented_if(multiline, 1, |fmt| fmt.visit_assignment(init))) - .transpose()?; - - self.write_semicolon()?; + if stmt_fits_on_single { + tx.commit()?; + } else { + self.context.if_stmt_single_line = Some(false); + self.write_if_stmt(loc, cond, if_branch, else_branch)?; + } + self.context.if_stmt_single_line = None; Ok(()) } - #[instrument(name = "var_definition_stmt", skip_all)] - fn visit_var_definition_stmt( + #[instrument(name = "do_while", skip_all)] + fn visit_do_while( &mut self, loc: Loc, - declaration: &mut VariableDeclaration, - expr: &mut Option, - ) -> Result<()> { + body: &mut Statement, + cond: &mut Expression, + ) -> Result<(), Self::Error> { return_source_if_disabled!(self, loc, ';'); + write_chunk!(self, loc.start(), "do ")?; + self.visit_stmt_as_block(body, false)?; + visit_source_if_disabled_else!(self, loc.with_start(body.loc().end()), { + self.surrounded( + SurroundingChunk::new("while (", Some(cond.loc().start()), None), + SurroundingChunk::new(");", None, Some(loc.end())), + |fmt, _| cond.visit(fmt), + )?; + }); + Ok(()) + } - let declaration = self - .chunked(declaration.loc.start(), None, |fmt| fmt.visit_var_declaration(declaration))?; - let multiline = declaration.content.contains('\n'); - self.write_chunk(&declaration)?; - - if let Some(expr) = expr { - write!(self.buf(), " =")?; - self.indented_if(multiline, 1, |fmt| fmt.visit_assignment(expr))?; - } + #[instrument(name = "while", skip_all)] + fn visit_while( + &mut self, + loc: Loc, + cond: &mut Expression, + body: &mut Statement, + ) -> Result<(), Self::Error> { + return_source_if_disabled!(self, loc); + self.surrounded( + SurroundingChunk::new("while (", Some(loc.start()), None), + SurroundingChunk::new(")", None, Some(cond.loc().end())), + |fmt, _| { + cond.visit(fmt)?; + fmt.write_postfix_comments_before(body.loc().start()) + }, + )?; - self.write_semicolon() + let cond_close_paren_loc = + self.find_next_in_src(cond.loc().end(), ')').unwrap_or_else(|| cond.loc().end()); + let attempt_single_line = self.should_attempt_block_single_line(body, cond_close_paren_loc); + self.visit_stmt_as_block(body, attempt_single_line)?; + Ok(()) } #[instrument(name = "for", skip_all)] @@ -2928,416 +2859,457 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { fmt.write_whitespace_separator(true)?; } - match update { - Some(expr) => expr.visit(fmt), - None => Ok(()), + match update { + Some(expr) => expr.visit(fmt), + None => Ok(()), + } + }; + let multiline = !fmt.try_on_single_line(|fmt| write_for_loop_header(fmt, false))?; + if multiline { + write_for_loop_header(fmt, true)?; + } + Ok(()) + }, + )?; + match body { + Some(body) => { + self.visit_stmt_as_block(body, false)?; + } + None => { + self.write_empty_brackets()?; + } + }; + Ok(()) + } + + #[instrument(name = "function", skip_all)] + fn visit_function(&mut self, func: &mut FunctionDefinition) -> Result<()> { + if func.body.is_some() { + return_source_if_disabled!(self, func.loc()); + } else { + return_source_if_disabled!(self, func.loc(), ';'); + } + + self.with_function_context(func.clone(), |fmt| { + fmt.write_postfix_comments_before(func.loc.start())?; + fmt.write_prefix_comments_before(func.loc.start())?; + + let body_loc = func.body.as_ref().map(CodeLocation::loc); + let mut attrs_multiline = false; + let fits_on_single = fmt.try_on_single_line(|fmt| { + fmt.write_function_header(func, body_loc, false)?; + Ok(()) + })?; + if !fits_on_single { + attrs_multiline = fmt.write_function_header(func, body_loc, true)?; + } + + // write function body + match &mut func.body { + Some(body) => { + let body_loc = body.loc(); + let byte_offset = body_loc.start(); + let body = fmt.visit_to_chunk(byte_offset, Some(body_loc.end()), body)?; + fmt.write_whitespace_separator( + attrs_multiline && !(func.attributes.is_empty() && func.returns.is_empty()), + )?; + fmt.write_chunk(&body)?; + } + None => fmt.write_semicolon()?, + } + + Ok(()) + })?; + + Ok(()) + } + + #[instrument(name = "function_attribute", skip_all)] + fn visit_function_attribute(&mut self, attribute: &mut FunctionAttribute) -> Result<()> { + return_source_if_disabled!(self, attribute.loc()); + + match attribute { + FunctionAttribute::Mutability(mutability) => { + write_chunk!(self, mutability.loc().end(), "{mutability}")? + } + FunctionAttribute::Visibility(visibility) => { + // Visibility will always have a location in a Function attribute + write_chunk!(self, visibility.loc_opt().unwrap().end(), "{visibility}")? + } + FunctionAttribute::Virtual(loc) => write_chunk!(self, loc.end(), "virtual")?, + FunctionAttribute::Immutable(loc) => write_chunk!(self, loc.end(), "immutable")?, + FunctionAttribute::Override(loc, args) => { + write_chunk!(self, loc.start(), "override")?; + if !args.is_empty() && self.config.override_spacing { + self.write_whitespace_separator(false)?; + } + self.visit_list("", args, None, Some(loc.end()), false)? + } + FunctionAttribute::BaseOrModifier(loc, base) => { + let is_contract_base = self.context.contract.as_ref().map_or(false, |contract| { + contract.base.iter().any(|contract_base| { + contract_base + .name + .identifiers + .iter() + .zip(&base.name.identifiers) + .all(|(l, r)| l.name == r.name) + }) + }); + + if is_contract_base { + base.visit(self)?; + } else { + let mut base_or_modifier = + self.visit_to_chunk(loc.start(), Some(loc.end()), base)?; + if base_or_modifier.content.ends_with("()") { + base_or_modifier.content.truncate(base_or_modifier.content.len() - 2); } - }; - let multiline = !fmt.try_on_single_line(|fmt| write_for_loop_header(fmt, false))?; - if multiline { - write_for_loop_header(fmt, true)?; + self.write_chunk(&base_or_modifier)?; } - Ok(()) - }, - )?; - match body { - Some(body) => { - self.visit_stmt_as_block(body, false)?; - } - None => { - self.write_empty_brackets()?; } + FunctionAttribute::Error(loc) => self.visit_parser_error(*loc)?, }; - Ok(()) - } - #[instrument(name = "while", skip_all)] - fn visit_while( - &mut self, - loc: Loc, - cond: &mut Expression, - body: &mut Statement, - ) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc); - self.surrounded( - SurroundingChunk::new("while (", Some(loc.start()), None), - SurroundingChunk::new(")", None, Some(cond.loc().end())), - |fmt, _| { - cond.visit(fmt)?; - fmt.write_postfix_comments_before(body.loc().start()) - }, - )?; - - let cond_close_paren_loc = - self.find_next_in_src(cond.loc().end(), ')').unwrap_or_else(|| cond.loc().end()); - let attempt_single_line = self.should_attempt_block_single_line(body, cond_close_paren_loc); - self.visit_stmt_as_block(body, attempt_single_line)?; Ok(()) } - #[instrument(name = "do_while", skip_all)] - fn visit_do_while( - &mut self, - loc: Loc, - body: &mut Statement, - cond: &mut Expression, - ) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc, ';'); - write_chunk!(self, loc.start(), "do ")?; - self.visit_stmt_as_block(body, false)?; - visit_source_if_disabled_else!(self, loc.with_start(body.loc().end()), { - self.surrounded( - SurroundingChunk::new("while (", Some(cond.loc().start()), None), - SurroundingChunk::new(");", None, Some(loc.end())), - |fmt, _| cond.visit(fmt), - )?; - }); + #[instrument(name = "var_attribute", skip_all)] + fn visit_var_attribute(&mut self, attribute: &mut VariableAttribute) -> Result<()> { + return_source_if_disabled!(self, attribute.loc()); + + let token = match attribute { + VariableAttribute::Visibility(visibility) => Some(visibility.to_string()), + VariableAttribute::Constant(_) => Some("constant".to_string()), + VariableAttribute::Immutable(_) => Some("immutable".to_string()), + VariableAttribute::Override(loc, idents) => { + write_chunk!(self, loc.start(), "override")?; + if !idents.is_empty() && self.config.override_spacing { + self.write_whitespace_separator(false)?; + } + self.visit_list("", idents, Some(loc.start()), Some(loc.end()), false)?; + None + } + }; + if let Some(token) = token { + let loc = attribute.loc(); + write_chunk!(self, loc.start(), loc.end(), "{}", token)?; + } Ok(()) } - #[instrument(name = "if", skip_all)] - fn visit_if( - &mut self, - loc: Loc, - cond: &mut Expression, - if_branch: &mut Box, - else_branch: &mut Option>, - is_first_stmt: bool, - ) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc); - - if !is_first_stmt { - self.write_if_stmt(loc, cond, if_branch, else_branch)?; - return Ok(()) - } + #[instrument(name = "base", skip_all)] + fn visit_base(&mut self, base: &mut Base) -> Result<()> { + return_source_if_disabled!(self, base.loc); - self.context.if_stmt_single_line = Some(true); - let mut stmt_fits_on_single = false; - let tx = self.transact(|fmt| { - stmt_fits_on_single = match fmt.write_if_stmt(loc, cond, if_branch, else_branch) { - Ok(()) => true, - Err(FormatterError::Fmt(_)) => false, - Err(err) => bail!(err), - }; + let name_loc = &base.name.loc; + let mut name = self.chunked(name_loc.start(), Some(name_loc.end()), |fmt| { + fmt.visit_ident_path(&mut base.name)?; Ok(()) })?; - if stmt_fits_on_single { - tx.commit()?; - } else { - self.context.if_stmt_single_line = Some(false); - self.write_if_stmt(loc, cond, if_branch, else_branch)?; + if base.args.is_none() || base.args.as_ref().unwrap().is_empty() { + if self.context.function.is_some() { + name.content.push_str("()"); + } + self.write_chunk(&name)?; + return Ok(()) } - self.context.if_stmt_single_line = None; - Ok(()) - } + let args = base.args.as_mut().unwrap(); + let args_start = CodeLocation::loc(args.first().unwrap()).start(); - #[instrument(name = "args", skip_all)] - fn visit_args(&mut self, loc: Loc, args: &mut Vec) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc); + name.content.push('('); + let formatted_name = self.chunk_to_string(&name)?; - write!(self.buf(), "{{")?; + let multiline = !self.will_it_fit(&formatted_name); - let mut args_iter = args.iter_mut().peekable(); - let mut chunks = Vec::new(); - while let Some(NamedArgument { loc: arg_loc, name, expr }) = args_iter.next() { - let next_byte_offset = args_iter - .peek() - .map(|NamedArgument { loc: arg_loc, .. }| arg_loc.start()) - .unwrap_or_else(|| loc.end()); - chunks.push(self.chunked(arg_loc.start(), Some(next_byte_offset), |fmt| { - fmt.grouped(|fmt| { - write_chunk!(fmt, name.loc.start(), "{}: ", name.name)?; - expr.visit(fmt) - })?; + self.surrounded( + SurroundingChunk::new(&formatted_name, Some(args_start), None), + SurroundingChunk::new(")", None, Some(base.loc.end())), + |fmt, multiline_hint| { + let args = fmt.items_to_chunks( + Some(base.loc.end()), + args.iter_mut().map(|arg| (arg.loc(), arg)), + )?; + let multiline = multiline || + multiline_hint || + fmt.are_chunks_separated_multiline("{}", &args, ",")?; + fmt.write_chunks_separated(&args, ",", multiline)?; Ok(()) - })?); - } + }, + )?; - if let Some(first) = chunks.first_mut() { - if first.prefixes.is_empty() && - first.postfixes_before.is_empty() && - !self.config.bracket_spacing - { - first.needs_space = Some(false); + Ok(()) + } + + #[instrument(name = "parameter", skip_all)] + fn visit_parameter(&mut self, parameter: &mut Parameter) -> Result<()> { + return_source_if_disabled!(self, parameter.loc); + self.grouped(|fmt| { + parameter.ty.visit(fmt)?; + if let Some(storage) = ¶meter.storage { + write_chunk!(fmt, storage.loc().end(), "{storage}")?; } - } - let multiline = self.are_chunks_separated_multiline("{}}", &chunks, ",")?; - self.indented_if(multiline, 1, |fmt| fmt.write_chunks_separated(&chunks, ",", multiline))?; + if let Some(name) = ¶meter.name { + write_chunk!(fmt, parameter.loc.end(), "{}", name.name)?; + } + Ok(()) + })?; + Ok(()) + } - let prefix = if multiline && !self.is_beginning_of_line() { - "\n" - } else if self.config.bracket_spacing { - " " - } else { - "" - }; - let closing_bracket = format!("{prefix}{}", "}"); - let closing_bracket_loc = args.last().unwrap().loc.end(); - write_chunk!(self, closing_bracket_loc, "{closing_bracket}")?; + #[instrument(name = "struct", skip_all)] + fn visit_struct(&mut self, structure: &mut StructDefinition) -> Result<()> { + return_source_if_disabled!(self, structure.loc); + self.grouped(|fmt| { + let struct_name = structure.name.safe_unwrap_mut(); + write_chunk!(fmt, struct_name.loc.start(), "struct")?; + struct_name.visit(fmt)?; + if structure.fields.is_empty() { + return fmt.write_empty_brackets() + } + + write!(fmt.buf(), " {{")?; + fmt.surrounded( + SurroundingChunk::new("", Some(struct_name.loc.end()), None), + SurroundingChunk::new("}", None, Some(structure.loc.end())), + |fmt, _multiline| { + let chunks = fmt.items_to_chunks( + Some(structure.loc.end()), + structure.fields.iter_mut().map(|ident| (ident.loc, ident)), + )?; + for mut chunk in chunks { + chunk.content.push(';'); + fmt.write_chunk(&chunk)?; + fmt.write_whitespace_separator(true)?; + } + Ok(()) + }, + ) + })?; Ok(()) } - #[instrument(name = "revert", skip_all)] - fn visit_revert( - &mut self, - loc: Loc, - error: &mut Option, - args: &mut Vec, - ) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc, ';'); - write_chunk!(self, loc.start(), "revert")?; - if let Some(error) = error { - error.visit(self)?; + #[instrument(name = "event", skip_all)] + fn visit_event(&mut self, event: &mut EventDefinition) -> Result<()> { + return_source_if_disabled!(self, event.loc, ';'); + + let event_name = event.name.safe_unwrap_mut(); + let mut name = + self.visit_to_chunk(event_name.loc.start(), Some(event.loc.end()), event_name)?; + name.content = format!("event {}(", name.content); + + let last_chunk = if event.anonymous { ") anonymous;" } else { ");" }; + if event.fields.is_empty() { + name.content.push_str(last_chunk); + self.write_chunk(&name)?; + } else { + let byte_offset = event.fields.first().unwrap().loc.start(); + let first_chunk = self.chunk_to_string(&name)?; + self.surrounded( + SurroundingChunk::new(first_chunk, Some(byte_offset), None), + SurroundingChunk::new(last_chunk, None, Some(event.loc.end())), + |fmt, multiline| { + let params = fmt + .items_to_chunks(None, event.fields.iter_mut().map(|arg| (arg.loc, arg)))?; + + let multiline = + multiline && fmt.are_chunks_separated_multiline("{}", ¶ms, ",")?; + fmt.write_chunks_separated(¶ms, ",", multiline) + }, + )?; } - self.visit_list("", args, None, Some(loc.end()), true)?; - self.write_semicolon()?; Ok(()) } - #[instrument(name = "revert_named_args", skip_all)] - fn visit_revert_named_args( - &mut self, - loc: Loc, - error: &mut Option, - args: &mut Vec, - ) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc, ';'); + #[instrument(name = "event_parameter", skip_all)] + fn visit_event_parameter(&mut self, param: &mut EventParameter) -> Result<()> { + return_source_if_disabled!(self, param.loc); - write_chunk!(self, loc.start(), "revert")?; - let mut error_indented = false; - if let Some(error) = error { - if !self.try_on_single_line(|fmt| error.visit(fmt))? { - error.visit(self)?; - error_indented = true; + self.grouped(|fmt| { + param.ty.visit(fmt)?; + if param.indexed { + write_chunk!(fmt, param.loc.start(), "indexed")?; } - } - - if args.is_empty() { - write!(self.buf(), "({{}});")?; - return Ok(()) - } - - write!(self.buf(), "(")?; - self.indented_if(error_indented, 1, |fmt| fmt.visit_args(loc, args))?; - write!(self.buf(), ")")?; - self.write_semicolon()?; - + if let Some(name) = ¶m.name { + write_chunk!(fmt, name.loc.end(), "{}", name.name)?; + } + Ok(()) + })?; Ok(()) } - #[instrument(name = "return", skip_all)] - fn visit_return(&mut self, loc: Loc, expr: &mut Option) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc, ';'); - - self.write_postfix_comments_before(loc.start())?; - self.write_prefix_comments_before(loc.start())?; + #[instrument(name = "error", skip_all)] + fn visit_error(&mut self, error: &mut ErrorDefinition) -> Result<()> { + return_source_if_disabled!(self, error.loc, ';'); - if expr.is_none() { - write_chunk!(self, loc.end(), "return;")?; - return Ok(()) - } + let error_name = error.name.safe_unwrap_mut(); + let mut name = self.visit_to_chunk(error_name.loc.start(), None, error_name)?; + name.content = format!("error {}", name.content); - let expr = expr.as_mut().unwrap(); - let expr_loc_start = expr.loc().start(); - let write_return = |fmt: &mut Self| -> Result<()> { - write_chunk!(fmt, loc.start(), "return")?; - fmt.write_postfix_comments_before(expr_loc_start)?; - Ok(()) - }; + let formatted_name = self.chunk_to_string(&name)?; + write!(self.buf(), "{formatted_name}")?; + let start_offset = error.fields.first().map(|f| f.loc.start()); + self.visit_list("", &mut error.fields, start_offset, Some(error.loc.end()), true)?; + self.write_semicolon()?; - let mut write_return_with_expr = |fmt: &mut Self| -> Result<()> { - let fits_on_single = fmt.try_on_single_line(|fmt| { - write_return(fmt)?; - expr.visit(fmt) - })?; - if fits_on_single { - return Ok(()) - } + Ok(()) + } - let mut fit_on_next_line = false; - let tx = fmt.transact(|fmt| { - fmt.grouped(|fmt| { - write_return(fmt)?; - if !fmt.is_beginning_of_line() { - fmt.write_whitespace_separator(true)?; - } - fit_on_next_line = fmt.try_on_single_line(|fmt| expr.visit(fmt))?; - Ok(()) - })?; - Ok(()) - })?; - if fit_on_next_line { - tx.commit()?; - return Ok(()) + #[instrument(name = "error_parameter", skip_all)] + fn visit_error_parameter(&mut self, param: &mut ErrorParameter) -> Result<()> { + return_source_if_disabled!(self, param.loc); + self.grouped(|fmt| { + param.ty.visit(fmt)?; + if let Some(name) = ¶m.name { + write_chunk!(fmt, name.loc.end(), "{}", name.name)?; } - - write_return(fmt)?; - expr.visit(fmt)?; Ok(()) - }; - - write_return_with_expr(self)?; - write_chunk!(self, loc.end(), ";")?; + })?; Ok(()) } - #[instrument(name = "try", skip_all)] - fn visit_try( - &mut self, - loc: Loc, - expr: &mut Expression, - returns: &mut Option<(Vec<(Loc, Option)>, Box)>, - clauses: &mut Vec, - ) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc); - - let try_next_byte = clauses.first().map(|c| match c { - CatchClause::Simple(loc, ..) => loc.start(), - CatchClause::Named(loc, ..) => loc.start(), - }); - let try_chunk = self.chunked(loc.start(), try_next_byte, |fmt| { - write_chunk!(fmt, loc.start(), expr.loc().start(), "try")?; - expr.visit(fmt)?; - if let Some((params, stmt)) = returns { - let mut params = - params.iter_mut().filter(|(_, param)| param.is_some()).collect::>(); - let byte_offset = params.first().map_or(stmt.loc().start(), |p| p.0.start()); - fmt.surrounded( - SurroundingChunk::new("returns (", Some(byte_offset), None), - SurroundingChunk::new(")", None, params.last().map(|p| p.0.end())), - |fmt, _| { - let chunks = fmt.items_to_chunks( - Some(stmt.loc().start()), - params.iter_mut().map(|(loc, ref mut ident)| (*loc, ident)), - )?; - let multiline = fmt.are_chunks_separated_multiline("{})", &chunks, ",")?; - fmt.write_chunks_separated(&chunks, ",", multiline)?; - Ok(()) - }, - )?; - stmt.visit(fmt)?; - } + #[instrument(name = "type_definition", skip_all)] + fn visit_type_definition(&mut self, def: &mut TypeDefinition) -> Result<()> { + return_source_if_disabled!(self, def.loc, ';'); + self.grouped(|fmt| { + write_chunk!(fmt, def.loc.start(), def.name.loc.start(), "type")?; + def.name.visit(fmt)?; + write_chunk!(fmt, def.name.loc.end(), CodeLocation::loc(&def.ty).start(), "is")?; + def.ty.visit(fmt)?; + fmt.write_semicolon()?; Ok(()) })?; + Ok(()) + } - let mut chunks = vec![try_chunk]; - for clause in clauses { - let (loc, ident, mut param, stmt) = match clause { - CatchClause::Simple(loc, param, stmt) => (loc, None, param.as_mut(), stmt), - CatchClause::Named(loc, ident, param, stmt) => { - (loc, Some(ident), Some(param), stmt) - } - }; - - let chunk = self.chunked(loc.start(), Some(stmt.loc().start()), |fmt| { - write_chunk!(fmt, "catch")?; - if let Some(ident) = ident.as_ref() { - fmt.write_postfix_comments_before( - param.as_ref().map(|p| p.loc.start()).unwrap_or_else(|| ident.loc.end()), - )?; - write_chunk!(fmt, ident.loc.start(), "{}", ident.name)?; - } - if let Some(param) = param.as_mut() { - write_chunk_spaced!(fmt, param.loc.start(), Some(ident.is_none()), "(")?; - fmt.surrounded( - SurroundingChunk::new("", Some(param.loc.start()), None), - SurroundingChunk::new(")", None, Some(stmt.loc().start())), - |fmt, _| param.visit(fmt), - )?; - } - - stmt.visit(fmt)?; - Ok(()) - })?; - - chunks.push(chunk); - } - - let multiline = self.are_chunks_separated_multiline("{}", &chunks, "")?; - if !multiline { - self.write_chunks_separated(&chunks, "", false)?; - return Ok(()) - } + #[instrument(name = "stray_semicolon", skip_all)] + fn visit_stray_semicolon(&mut self) -> Result<()> { + self.write_semicolon() + } - let mut chunks = chunks.iter_mut().peekable(); - let mut prev_multiline = false; + #[instrument(name = "opening_paren", skip_all)] + fn visit_opening_paren(&mut self) -> Result<()> { + write_chunk!(self, "(")?; + Ok(()) + } - // write try chunk first - if let Some(chunk) = chunks.next() { - let chunk_str = self.simulate_to_string(|fmt| fmt.write_chunk(chunk))?; - write!(self.buf(), "{chunk_str}")?; - prev_multiline = chunk_str.contains('\n'); - } + #[instrument(name = "closing_paren", skip_all)] + fn visit_closing_paren(&mut self) -> Result<()> { + write_chunk!(self, ")")?; + Ok(()) + } - while let Some(chunk) = chunks.next() { - let chunk_str = self.simulate_to_string(|fmt| fmt.write_chunk(chunk))?; - let multiline = chunk_str.contains('\n'); - self.indented_if(!multiline, 1, |fmt| { - chunk.needs_space = Some(false); - let on_same_line = prev_multiline && (multiline || chunks.peek().is_none()); - let prefix = if fmt.is_beginning_of_line() { - "" - } else if on_same_line { - " " - } else { - "\n" - }; - let chunk_str = format!("{prefix}{chunk_str}"); - write!(fmt.buf(), "{chunk_str}")?; - Ok(()) - })?; - prev_multiline = multiline; - } + #[instrument(name = "newline", skip_all)] + fn visit_newline(&mut self) -> Result<()> { + writeln_chunk!(self)?; Ok(()) } - #[instrument(name = "assembly", skip_all)] - fn visit_assembly( - &mut self, - loc: Loc, - dialect: &mut Option, - block: &mut YulBlock, - flags: &mut Option>, - ) -> Result<(), Self::Error> { - return_source_if_disabled!(self, loc); + #[instrument(name = "using", skip_all)] + fn visit_using(&mut self, using: &mut Using) -> Result<()> { + return_source_if_disabled!(self, using.loc, ';'); - write_chunk!(self, loc.start(), "assembly")?; - if let Some(StringLiteral { loc, string, .. }) = dialect { - write_chunk!(self, loc.start(), loc.end(), "\"{string}\"")?; - } - if let Some(flags) = flags { - if !flags.is_empty() { - let loc_start = flags.first().unwrap().loc.start(); - self.surrounded( - SurroundingChunk::new("(", Some(loc_start), None), - SurroundingChunk::new(")", None, Some(block.loc.start())), - |fmt, _| { - let mut flags = flags.iter_mut().peekable(); - let mut chunks = vec![]; - while let Some(flag) = flags.next() { - let next_byte_offset = - flags.peek().map(|next_flag| next_flag.loc.start()); - chunks.push(fmt.chunked( - flag.loc.start(), - next_byte_offset, - |fmt| { - write!(fmt.buf(), "\"{}\"", flag.string)?; - Ok(()) - }, - )?); + write_chunk!(self, using.loc.start(), "using")?; + + let ty_start = using.ty.as_mut().map(|ty| CodeLocation::loc(&ty).start()); + let global_start = using.global.as_mut().map(|global| global.loc.start()); + let loc_end = using.loc.end(); + + let (is_library, mut list_chunks) = match &mut using.list { + UsingList::Library(library) => { + (true, vec![self.visit_to_chunk(library.loc.start(), None, library)?]) + } + UsingList::Functions(funcs) => { + let mut funcs = funcs.iter_mut().peekable(); + let mut chunks = Vec::new(); + while let Some(func) = funcs.next() { + let next_byte_end = funcs.peek().map(|func| func.loc.start()); + chunks.push(self.chunked(func.loc.start(), next_byte_end, |fmt| { + fmt.visit_ident_path(&mut func.path)?; + if let Some(op) = func.oper { + write!(fmt.buf(), " as {op}")?; } - fmt.write_chunks_separated(&chunks, ",", false)?; Ok(()) - }, - )?; + })?); + } + (false, chunks) + } + UsingList::Error => return self.visit_parser_error(using.loc), + }; + + let for_chunk = self.chunk_at( + using.loc.start(), + Some(ty_start.or(global_start).unwrap_or(loc_end)), + None, + "for", + ); + let ty_chunk = if let Some(ty) = &mut using.ty { + self.visit_to_chunk(ty.loc().start(), Some(global_start.unwrap_or(loc_end)), ty)? + } else { + self.chunk_at(using.loc.start(), Some(global_start.unwrap_or(loc_end)), None, "*") + }; + let global_chunk = using + .global + .as_mut() + .map(|global| self.visit_to_chunk(global.loc.start(), Some(using.loc.end()), global)) + .transpose()?; + + let write_for_def = |fmt: &mut Self| { + fmt.grouped(|fmt| { + fmt.write_chunk(&for_chunk)?; + fmt.write_chunk(&ty_chunk)?; + if let Some(global_chunk) = global_chunk.as_ref() { + fmt.write_chunk(global_chunk)?; + } + Ok(()) + })?; + Ok(()) + }; + + let simulated_for_def = self.simulate_to_string(write_for_def)?; + + if is_library { + let chunk = list_chunks.pop().unwrap(); + if self.will_chunk_fit(&format!("{{}} {simulated_for_def};"), &chunk)? { + self.write_chunk(&chunk)?; + write_for_def(self)?; + } else { + self.write_whitespace_separator(true)?; + self.grouped(|fmt| { + fmt.write_chunk(&chunk)?; + Ok(()) + })?; + self.write_whitespace_separator(true)?; + write_for_def(self)?; } + } else { + self.surrounded( + SurroundingChunk::new("{", Some(using.loc.start()), None), + SurroundingChunk::new( + "}", + None, + Some(ty_start.or(global_start).unwrap_or(loc_end)), + ), + |fmt, _multiline| { + let multiline = fmt.are_chunks_separated_multiline( + &format!("{{ {{}} }} {simulated_for_def};"), + &list_chunks, + ",", + )?; + fmt.write_chunks_separated(&list_chunks, ",", multiline)?; + Ok(()) + }, + )?; + write_for_def(self)?; } - block.visit(self) + self.write_semicolon()?; + + Ok(()) } #[instrument(name = "yul_block", skip_all)] @@ -3352,38 +3324,6 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Ok(()) } - #[instrument(name = "yul_assignment", skip_all)] - fn visit_yul_assignment( - &mut self, - loc: Loc, - exprs: &mut Vec, - expr: &mut Option<&mut YulExpression>, - ) -> Result<(), Self::Error> - where - T: Visitable + CodeLocation, - { - return_source_if_disabled!(self, loc); - - self.grouped(|fmt| { - let chunks = - fmt.items_to_chunks(None, exprs.iter_mut().map(|expr| (expr.loc(), expr)))?; - - let multiline = fmt.are_chunks_separated_multiline("{} := ", &chunks, ",")?; - fmt.write_chunks_separated(&chunks, ",", multiline)?; - - if let Some(expr) = expr { - write_chunk!(fmt, expr.loc().start(), ":=")?; - let chunk = fmt.visit_to_chunk(expr.loc().start(), Some(loc.end()), expr)?; - if !fmt.will_chunk_fit("{}", &chunk)? { - fmt.write_whitespace_separator(true)?; - } - fmt.write_chunk(&chunk)?; - } - Ok(()) - })?; - Ok(()) - } - #[instrument(name = "yul_expr", skip_all)] fn visit_yul_expr(&mut self, expr: &mut YulExpression) -> Result<(), Self::Error> { return_source_if_disabled!(self, expr.loc()); @@ -3428,6 +3368,38 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { } } + #[instrument(name = "yul_assignment", skip_all)] + fn visit_yul_assignment( + &mut self, + loc: Loc, + exprs: &mut Vec, + expr: &mut Option<&mut YulExpression>, + ) -> Result<(), Self::Error> + where + T: Visitable + CodeLocation, + { + return_source_if_disabled!(self, loc); + + self.grouped(|fmt| { + let chunks = + fmt.items_to_chunks(None, exprs.iter_mut().map(|expr| (expr.loc(), expr)))?; + + let multiline = fmt.are_chunks_separated_multiline("{} := ", &chunks, ",")?; + fmt.write_chunks_separated(&chunks, ",", multiline)?; + + if let Some(expr) = expr { + write_chunk!(fmt, expr.loc().start(), ":=")?; + let chunk = fmt.visit_to_chunk(expr.loc().start(), Some(loc.end()), expr)?; + if !fmt.will_chunk_fit("{}", &chunk)? { + fmt.write_whitespace_separator(true)?; + } + fmt.write_chunk(&chunk)?; + } + Ok(()) + })?; + Ok(()) + } + #[instrument(name = "yul_for", skip_all)] fn visit_yul_for(&mut self, stmt: &mut YulFor) -> Result<(), Self::Error> { return_source_if_disabled!(self, stmt.loc); @@ -3446,12 +3418,6 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { self.visit_list("", &mut stmt.arguments, None, Some(stmt.loc.end()), true) } - #[instrument(name = "yul_typed_ident", skip_all)] - fn visit_yul_typed_ident(&mut self, ident: &mut YulTypedIdentifier) -> Result<(), Self::Error> { - return_source_if_disabled!(self, ident.loc); - self.visit_yul_string_with_ident(ident.loc, &ident.id.name, &mut ident.ty) - } - #[instrument(name = "yul_fun_def", skip_all)] fn visit_yul_fun_def(&mut self, stmt: &mut YulFunctionDefinition) -> Result<(), Self::Error> { return_source_if_disabled!(self, stmt.loc); @@ -3540,16 +3506,10 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Ok(()) } - // Support extension for Solana/Substrate - #[instrument(name = "annotation", skip_all)] - fn visit_annotation(&mut self, annotation: &mut Annotation) -> Result<()> { - return_source_if_disabled!(self, annotation.loc); - let id = self.simulate_to_string(|fmt| annotation.id.visit(fmt))?; - write!(self.buf(), "@{id}")?; - write!(self.buf(), "(")?; - annotation.value.visit(self)?; - write!(self.buf(), ")")?; - Ok(()) + #[instrument(name = "yul_typed_ident", skip_all)] + fn visit_yul_typed_ident(&mut self, ident: &mut YulTypedIdentifier) -> Result<(), Self::Error> { + return_source_if_disabled!(self, ident.loc); + self.visit_yul_string_with_ident(ident.loc, &ident.id.name, &mut ident.ty) } #[instrument(name = "parser_error", skip_all)] @@ -3557,3 +3517,43 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { Err(FormatterError::InvalidParsedItem(loc)) } } + +/// An action which may be committed to a Formatter +struct Transaction<'f, 'a, W> { + fmt: &'f mut Formatter<'a, W>, + buffer: String, + comments: Comments, +} + +impl<'f, 'a, W> std::ops::Deref for Transaction<'f, 'a, W> { + type Target = Formatter<'a, W>; + fn deref(&self) -> &Self::Target { + self.fmt + } +} + +impl<'f, 'a, W> std::ops::DerefMut for Transaction<'f, 'a, W> { + fn deref_mut(&mut self) -> &mut Self::Target { + self.fmt + } +} + +impl<'f, 'a, W: Write> Transaction<'f, 'a, W> { + /// Create a new transaction from a callback + fn new( + fmt: &'f mut Formatter<'a, W>, + fun: impl FnMut(&mut Formatter<'a, W>) -> Result<()>, + ) -> Result { + let mut comments = fmt.comments.clone(); + let buffer = fmt.with_temp_buf(fun)?.w; + comments = std::mem::replace(&mut fmt.comments, comments); + Ok(Self { fmt, buffer, comments }) + } + + /// Commit the transaction to the Formatter + fn commit(self) -> Result { + self.fmt.comments = self.comments; + write_chunk!(self.fmt, "{}", self.buffer)?; + Ok(self.buffer) + } +} From 87bf7e4dc29e5714b62b703b29c1605c06b0e7d4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 2 Dec 2023 15:27:15 +0100 Subject: [PATCH 0368/1963] chore: better parse error messages (#6499) * chore: better parse error messages * chore: clippy --- crates/cast/src/lib.rs | 15 ++++-------- crates/common/src/abi.rs | 32 ++++++++++--------------- crates/evm/fuzz/src/strategies/param.rs | 4 ++-- crates/forge/bin/cmd/script/mod.rs | 4 ++-- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 8ff767354a782..427fdb0b1dbb4 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1,5 +1,5 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; -use alloy_json_abi::{ContractObject, Function}; +use alloy_json_abi::ContractObject; use alloy_primitives::{Address, I256, U256}; use alloy_rlp::Decodable; use base::{Base, NumberWithBase, ToBase}; @@ -16,7 +16,7 @@ use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::Client; use foundry_common::{ - abi::encode_function_args, + abi::{encode_function_args, get_func}, fmt::*, types::{ToAlloy, ToEthers}, TransactionReceiptWithRevertReason, @@ -1561,12 +1561,7 @@ impl SimpleCast { /// # Ok::<_, eyre::Report>(()) /// ``` pub fn abi_encode(sig: &str, args: &[impl AsRef]) -> Result { - let func = match Function::parse(sig) { - Ok(func) => func, - Err(err) => { - eyre::bail!("Could not process human-readable ABI. Please check if you've left the parenthesis unclosed or if some type is incomplete.\nError:\n{}", err) - } - }; + let func = get_func(sig)?; let calldata = match encode_function_args(&func, args) { Ok(res) => hex::encode(res), Err(e) => eyre::bail!("Could not ABI encode the function and arguments. Did you pass in the right types?\nError\n{}", e), @@ -1589,7 +1584,7 @@ impl SimpleCast { /// # Ok::<_, eyre::Report>(()) /// ``` pub fn calldata_encode(sig: impl AsRef, args: &[impl AsRef]) -> Result { - let func = Function::parse(sig.as_ref())?; + let func = get_func(sig.as_ref())?; let calldata = encode_function_args(&func, args)?; Ok(hex::encode_prefixed(calldata)) } @@ -1909,7 +1904,7 @@ impl SimpleCast { eyre::bail!("number of leading zeroes must not be greater than 4"); } if optimize == 0 { - let selector = Function::parse(signature)?.selector(); + let selector = get_func(signature)?.selector(); return Ok((selector.to_string(), String::from(signature))) } let Some((name, params)) = signature.split_once('(') else { diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 5a166a20f09e0..622d8481cf924 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -1,9 +1,9 @@ //! ABI related helper functions. use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{AbiItem, Event, Function}; +use alloy_json_abi::{Event, Function}; use alloy_primitives::{hex, Address, Log}; -use eyre::{ContextCompat, Result}; +use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; use foundry_config::Chain; use std::{future::Future, pin::Pin}; @@ -28,7 +28,7 @@ pub fn abi_decode_calldata( input: bool, fn_selector: bool, ) -> Result> { - let func = Function::parse(sig)?; + let func = get_func(sig)?; let calldata = hex::decode(calldata)?; let mut calldata = calldata.as_slice(); @@ -56,7 +56,7 @@ pub fn abi_decode_calldata( pub trait IntoFunction { /// Consumes self and produces a function /// - /// # Panic + /// # Panics /// /// This function does not return a Result, so it is expected that the consumer /// uses it correctly so that it does not panic. @@ -70,38 +70,30 @@ impl IntoFunction for Function { } impl IntoFunction for String { + #[track_caller] fn into(self) -> Function { IntoFunction::into(self.as_str()) } } impl<'a> IntoFunction for &'a str { + #[track_caller] fn into(self) -> Function { - Function::parse(self).expect("could not parse function") + match get_func(self) { + Ok(func) => func, + Err(e) => panic!("could not parse function: {e}"), + } } } /// Given a function signature string, it tries to parse it as a `Function` pub fn get_func(sig: &str) -> Result { - if let Ok(func) = Function::parse(sig) { - Ok(func) - } else { - // Try to parse as human readable ABI. - let item = match AbiItem::parse(sig) { - Ok(item) => match item { - AbiItem::Function(func) => func, - _ => return Err(eyre::eyre!("Expected function, got {:?}", item)), - }, - Err(e) => return Err(e.into()), - }; - Ok(item.into_owned().to_owned()) - } + Function::parse(sig).wrap_err("could not parse function signature") } /// Given an event signature string, it tries to parse it as a `Event` pub fn get_event(sig: &str) -> Result { - let sig = sig.strip_prefix("event").unwrap_or(sig).trim(); - Ok(Event::parse(sig)?) + Event::parse(sig).wrap_err("could not parse event signature") } /// Given an event without indexed parameters and a rawlog, it tries to return the event with the diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 09fbfe590bc2f..093cb29c8b426 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -166,14 +166,14 @@ pub fn fuzz_param_from_state( #[cfg(test)] mod tests { use crate::strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state}; - use alloy_json_abi::Function; + use foundry_common::abi::get_func; use foundry_config::FuzzDictionaryConfig; use revm::db::{CacheDB, EmptyDB}; #[test] fn can_fuzz_array() { let f = "testArray(uint64[2] calldata values)"; - let func = Function::parse(f).unwrap(); + let func = get_func(f).unwrap(); let db = CacheDB::new(EmptyDB::default()); let state = build_initial_state(&db, &FuzzDictionaryConfig::default()); let strat = proptest::strategy::Union::new_weighted(vec![ diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 472b38c752fdf..335c89f1b9c57 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -24,7 +24,7 @@ use forge::{ }; use foundry_cli::opts::MultiWallet; use foundry_common::{ - abi::encode_function_args, + abi::{encode_function_args, get_func}, contracts::get_contract_name, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, @@ -445,7 +445,7 @@ impl ScriptArgs { /// /// Note: We assume that the `sig` is already stripped of its prefix, See [`ScriptArgs`] fn get_method_and_calldata(&self, abi: &Abi) -> Result<(Function, Bytes)> { - let (func, data) = if let Ok(func) = Function::parse(&self.sig) { + let (func, data) = if let Ok(func) = get_func(&self.sig) { ( abi.functions().find(|&abi_func| abi_func.selector() == func.selector()).wrap_err( format!("Function `{}` is not implemented in your script.", self.sig), From d4e6b43ea694f31ef2915e75d81c3308479ef8fd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 3 Dec 2023 01:48:09 +0100 Subject: [PATCH 0369/1963] chore(deps): weekly `cargo update` (#6505) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating coins-ledger v0.9.1 -> v0.9.2 Updating deranged v0.3.9 -> v0.3.10 Removing matches v0.1.10 Co-authored-by: mattsse --- Cargo.lock | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6725991000549..8e89b6a51bc56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1298,9 +1298,9 @@ dependencies = [ [[package]] name = "coins-ledger" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12adb2f4914ec6d8659cd9d1630463ca13ac90f5be18133cb9a70921f15fc145" +checksum = "9b913b49d2e008b23cffb802f29b8051feddf7b2cc37336ab9a7a410f832395a" dependencies = [ "async-trait", "byteorder", @@ -1309,13 +1309,9 @@ dependencies = [ "hex", "hidapi-rusb", "js-sys", - "lazy_static", - "libc", "log", - "matches", "nix 0.26.4", - "serde", - "tap", + "once_cell", "thiserror", "tokio", "tracing", @@ -1676,9 +1672,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" dependencies = [ "powerfmt", ] @@ -4259,12 +4255,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - [[package]] name = "matchit" version = "0.7.3" From d2183dad59eeed8af4b8b037c5b51483aef1314d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:27:34 +0100 Subject: [PATCH 0370/1963] refactor(debugger): modularize and add a context struct (#6495) --- crates/debugger/src/lib.rs | 5 +- crates/debugger/src/{ => tui}/builder.rs | 4 +- crates/debugger/src/tui/context.rs | 335 +++++++++++++ crates/debugger/src/{tui.rs => tui/draw.rs} | 497 +------------------- crates/debugger/src/tui/mod.rs | 200 ++++++++ 5 files changed, 546 insertions(+), 495 deletions(-) rename crates/debugger/src/{ => tui}/builder.rs (96%) create mode 100644 crates/debugger/src/tui/context.rs rename crates/debugger/src/{tui.rs => tui/draw.rs} (64%) create mode 100644 crates/debugger/src/tui/mod.rs diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index db5a012eb5990..a50a73660fd76 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -7,10 +7,7 @@ #[macro_use] extern crate tracing; -mod builder; -pub use builder::DebuggerBuilder; - mod op; mod tui; -pub use tui::{Debugger, ExitReason}; +pub use tui::{Debugger, DebuggerBuilder, ExitReason}; diff --git a/crates/debugger/src/builder.rs b/crates/debugger/src/tui/builder.rs similarity index 96% rename from crates/debugger/src/builder.rs rename to crates/debugger/src/tui/builder.rs index ff2721ec7ce7b..e8f27b1c0e88e 100644 --- a/crates/debugger/src/builder.rs +++ b/crates/debugger/src/tui/builder.rs @@ -1,3 +1,5 @@ +//! TUI debugger builder. + use crate::Debugger; use alloy_primitives::Address; use eyre::Result; @@ -90,6 +92,6 @@ impl DebuggerBuilder { #[inline] pub fn build(self) -> Result { let Self { debug_arena, identified_contracts, sources, breakpoints } = self; - Debugger::new(debug_arena, 0, identified_contracts, sources, breakpoints) + Debugger::new(debug_arena, identified_contracts, sources, breakpoints) } } diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs new file mode 100644 index 0000000000000..ac0a9e1fd4289 --- /dev/null +++ b/crates/debugger/src/tui/context.rs @@ -0,0 +1,335 @@ +//! Debugger context and event handler implementation. + +use crate::{Debugger, ExitReason}; +use alloy_primitives::Address; +use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; +use eyre::Result; +use foundry_evm_core::{debug::DebugStep, utils::CallKind}; +use std::ops::ControlFlow; + +/// This is currently used to remember last scroll position so screen doesn't wiggle as much. +#[derive(Default)] +pub(crate) struct DrawMemory { + pub(crate) current_startline: usize, + pub(crate) inner_call_index: usize, + pub(crate) current_mem_startline: usize, + pub(crate) current_stack_startline: usize, +} + +pub(crate) struct DebuggerContext<'a> { + pub(crate) debugger: &'a mut Debugger, + + /// Buffer for keys prior to execution, i.e. '10' + 'k' => move up 10 operations. + pub(crate) key_buffer: String, + /// Current step in the debug steps. + pub(crate) current_step: usize, + pub(crate) draw_memory: DrawMemory, + pub(crate) opcode_list: Vec, + pub(crate) last_index: usize, + + pub(crate) stack_labels: bool, + pub(crate) mem_utf: bool, + pub(crate) show_shortcuts: bool, +} + +impl<'a> DebuggerContext<'a> { + pub(crate) fn new(debugger: &'a mut Debugger) -> Self { + DebuggerContext { + debugger, + + key_buffer: String::with_capacity(64), + current_step: 0, + draw_memory: DrawMemory::default(), + opcode_list: Vec::new(), + last_index: 0, + + stack_labels: false, + mem_utf: false, + show_shortcuts: true, + } + } + + pub(crate) fn init(&mut self) -> Result<()> { + self.debugger.terminal.clear()?; + self.gen_opcode_list(); + Ok(()) + } + + fn debug_arena(&self) -> &[(Address, Vec, CallKind)] { + &self.debugger.debug_arena + } + + fn gen_opcode_list(&mut self) { + self.opcode_list = self.opcode_list(); + } + + fn opcode_list(&self) -> Vec { + self.debugger.debug_arena[self.draw_memory.inner_call_index] + .1 + .iter() + .map(DebugStep::pretty_opcode) + .collect() + } +} + +impl DebuggerContext<'_> { + pub(crate) fn handle_event(&mut self, event: Event) -> ControlFlow { + if self.last_index != self.draw_memory.inner_call_index { + self.opcode_list = self.debug_arena()[self.draw_memory.inner_call_index] + .1 + .iter() + .map(|step| step.pretty_opcode()) + .collect(); + self.last_index = self.draw_memory.inner_call_index; + } + + match event { + Event::Key(event) => self.handle_key_event(event), + Event::Mouse(event) => self.handle_mouse_event(event), + _ => ControlFlow::Continue(()), + } + } + + fn handle_key_event(&mut self, event: KeyEvent) -> ControlFlow { + if let KeyCode::Char(c) = event.code { + if c.is_alphanumeric() || c == '\'' { + self.handle_breakpoint(c); + return ControlFlow::Continue(()); + } + } + + match event.code { + // Exit + KeyCode::Char('q') => return ControlFlow::Break(ExitReason::CharExit), + // Move down + KeyCode::Char('j') | KeyCode::Down => { + // Grab number of times to do it + for _ in 0..buffer_as_number(&self.key_buffer, 1) { + if event.modifiers.contains(KeyModifiers::CONTROL) { + let max_mem = (self.debug_arena()[self.draw_memory.inner_call_index].1 + [self.current_step] + .memory + .len() / + 32) + .saturating_sub(1); + if self.draw_memory.current_mem_startline < max_mem { + self.draw_memory.current_mem_startline += 1; + } + } else if self.current_step < self.opcode_list.len() - 1 { + self.current_step += 1; + } else if self.draw_memory.inner_call_index < self.debug_arena().len() - 1 { + self.draw_memory.inner_call_index += 1; + self.current_step = 0; + } + } + self.key_buffer.clear(); + } + KeyCode::Char('J') => { + for _ in 0..buffer_as_number(&self.key_buffer, 1) { + let max_stack = self.debug_arena()[self.draw_memory.inner_call_index].1 + [self.current_step] + .stack + .len() + .saturating_sub(1); + if self.draw_memory.current_stack_startline < max_stack { + self.draw_memory.current_stack_startline += 1; + } + } + self.key_buffer.clear(); + } + // Move up + KeyCode::Char('k') | KeyCode::Up => { + for _ in 0..buffer_as_number(&self.key_buffer, 1) { + if event.modifiers.contains(KeyModifiers::CONTROL) { + self.draw_memory.current_mem_startline = + self.draw_memory.current_mem_startline.saturating_sub(1); + } else if self.current_step > 0 { + self.current_step -= 1; + } else if self.draw_memory.inner_call_index > 0 { + self.draw_memory.inner_call_index -= 1; + self.current_step = + self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + } + } + self.key_buffer.clear(); + } + KeyCode::Char('K') => { + for _ in 0..buffer_as_number(&self.key_buffer, 1) { + self.draw_memory.current_stack_startline = + self.draw_memory.current_stack_startline.saturating_sub(1); + } + self.key_buffer.clear(); + } + // Go to top of file + KeyCode::Char('g') => { + self.draw_memory.inner_call_index = 0; + self.current_step = 0; + self.key_buffer.clear(); + } + // Go to bottom of file + KeyCode::Char('G') => { + self.draw_memory.inner_call_index = self.debug_arena().len() - 1; + self.current_step = + self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + self.key_buffer.clear(); + } + // Go to previous call + KeyCode::Char('c') => { + self.draw_memory.inner_call_index = + self.draw_memory.inner_call_index.saturating_sub(1); + self.current_step = + self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + self.key_buffer.clear(); + } + // Go to next call + KeyCode::Char('C') => { + if self.debug_arena().len() > self.draw_memory.inner_call_index + 1 { + self.draw_memory.inner_call_index += 1; + self.current_step = 0; + } + self.key_buffer.clear(); + } + // Step forward + KeyCode::Char('s') => { + for _ in 0..buffer_as_number(&self.key_buffer, 1) { + let remaining_ops = self.opcode_list[self.current_step..].to_vec(); + self.current_step += remaining_ops + .iter() + .enumerate() + .find_map(|(i, op)| { + if i < remaining_ops.len() - 1 { + match ( + op.contains("JUMP") && op != "JUMPDEST", + &*remaining_ops[i + 1], + ) { + (true, "JUMPDEST") => Some(i + 1), + _ => None, + } + } else { + None + } + }) + .unwrap_or(self.opcode_list.len() - 1); + if self.current_step > self.opcode_list.len() { + self.current_step = self.opcode_list.len() - 1 + }; + } + self.key_buffer.clear(); + } + // Step backwards + KeyCode::Char('a') => { + for _ in 0..buffer_as_number(&self.key_buffer, 1) { + let prev_ops = self.opcode_list[..self.current_step].to_vec(); + self.current_step = prev_ops + .iter() + .enumerate() + .rev() + .find_map(|(i, op)| { + if i > 0 { + match ( + prev_ops[i - 1].contains("JUMP") && + prev_ops[i - 1] != "JUMPDEST", + &**op, + ) { + (true, "JUMPDEST") => Some(i - 1), + _ => None, + } + } else { + None + } + }) + .unwrap_or_default(); + } + self.key_buffer.clear(); + } + // toggle stack labels + KeyCode::Char('t') => self.stack_labels = !self.stack_labels, + // toggle memory utf8 decoding + KeyCode::Char('m') => self.mem_utf = !self.mem_utf, + // toggle help notice + KeyCode::Char('h') => self.show_shortcuts = !self.show_shortcuts, + KeyCode::Char( + other @ ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '\''), + ) => self.key_buffer.push(other), + _ => self.key_buffer.clear(), + }; + + ControlFlow::Continue(()) + } + + fn handle_breakpoint(&mut self, c: char) { + // Find the location of the called breakpoint in the whole debug arena (at this address with + // this pc) + if let Some((caller, pc)) = self.debugger.breakpoints.get(&c) { + for (i, (_caller, debug_steps, _)) in self.debug_arena().iter().enumerate() { + if _caller == caller { + if let Some(step) = debug_steps.iter().position(|step| step.pc == *pc) { + self.draw_memory.inner_call_index = i; + self.current_step = step; + break + } + } + } + } + self.key_buffer.clear(); + } + + fn handle_mouse_event(&mut self, event: MouseEvent) -> ControlFlow { + match event.kind { + MouseEventKind::ScrollUp => { + if self.current_step > 0 { + self.current_step -= 1; + } else if self.draw_memory.inner_call_index > 0 { + self.draw_memory.inner_call_index -= 1; + self.draw_memory.current_mem_startline = 0; + self.draw_memory.current_stack_startline = 0; + self.current_step = + self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + } + } + MouseEventKind::ScrollDown => { + if self.current_step < self.opcode_list.len() - 1 { + self.current_step += 1; + } else if self.draw_memory.inner_call_index < self.debug_arena().len() - 1 { + self.draw_memory.inner_call_index += 1; + self.draw_memory.current_mem_startline = 0; + self.draw_memory.current_stack_startline = 0; + self.current_step = 0; + } + } + _ => {} + } + + ControlFlow::Continue(()) + } + + pub(crate) fn draw(&mut self) -> Result<()> { + self.debugger.terminal.draw(|f| { + let debug_arena = &self.debugger.debug_arena; + Debugger::draw_layout( + f, + debug_arena[self.draw_memory.inner_call_index].0, + &self.debugger.identified_contracts, + &self.debugger.pc_ic_maps, + &self.debugger.contracts_sources, + &debug_arena[self.draw_memory.inner_call_index].1[..], + &self.opcode_list, + self.current_step, + debug_arena[self.draw_memory.inner_call_index].2, + &mut self.draw_memory, + self.stack_labels, + self.mem_utf, + self.show_shortcuts, + ) + })?; + Ok(()) + } +} + +/// Grab number from buffer. Used for something like '10k' to move up 10 operations +fn buffer_as_number(s: &str, default_value: usize) -> usize { + match s.parse() { + Ok(num) if num >= 1 => num, + _ => default_value, + } +} diff --git a/crates/debugger/src/tui.rs b/crates/debugger/src/tui/draw.rs similarity index 64% rename from crates/debugger/src/tui.rs rename to crates/debugger/src/tui/draw.rs index 7cd2b67efd0ce..cfba3c6001b0c 100644 --- a/crates/debugger/src/tui.rs +++ b/crates/debugger/src/tui/draw.rs @@ -1,420 +1,30 @@ -//! The TUI implementation. +//! TUI draw implementation. -use crate::{op::OpcodeParam, DebuggerBuilder}; +use super::context::DrawMemory; +use crate::{op::OpcodeParam, Debugger}; use alloy_primitives::{Address, U256}; -use crossterm::{ - event::{ - self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, KeyModifiers, - MouseEvent, MouseEventKind, - }, - execute, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, -}; -use eyre::Result; -use foundry_common::{compile::ContractSources, evm::Breakpoints}; +use foundry_common::compile::ContractSources; use foundry_evm_core::{ debug::{DebugStep, Instruction}, - utils::{build_pc_ic_map, CallKind, PCICMap}, + utils::{CallKind, PCICMap}, }; use ratatui::{ - backend::CrosstermBackend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, terminal::Frame, text::{Line, Span, Text}, widgets::{Block, Borders, Paragraph, Wrap}, - Terminal, }; -use revm::{interpreter::opcode, primitives::SpecId}; +use revm::interpreter::opcode; use std::{ cmp::{max, min}, collections::{BTreeMap, HashMap, VecDeque}, - io, - sync::mpsc, - thread, - time::{Duration, Instant}, }; -/// Used to indicate why the debugger quit. -#[derive(Debug)] -pub enum ExitReason { - /// Exit using 'q'. - CharExit, -} - -/// The TUI debugger. -pub struct Debugger { - debug_arena: Vec<(Address, Vec, CallKind)>, - terminal: Terminal>, - /// Buffer for keys prior to execution, i.e. '10' + 'k' => move up 10 operations - key_buffer: String, - /// Current step in the debug steps - current_step: usize, - identified_contracts: HashMap, - /// Source map of contract sources - contracts_sources: ContractSources, - /// A mapping of source -> (PC -> IC map for deploy code, PC -> IC map for runtime code) - pc_ic_maps: BTreeMap, - breakpoints: Breakpoints, -} - impl Debugger { - /// Creates a new debugger builder. - #[inline] - pub fn builder() -> DebuggerBuilder { - DebuggerBuilder::new() - } - - /// Creates a new debugger. - pub fn new( - debug_arena: Vec<(Address, Vec, CallKind)>, - current_step: usize, - identified_contracts: HashMap, - contracts_sources: ContractSources, - breakpoints: Breakpoints, - ) -> Result { - let backend = CrosstermBackend::new(io::stdout()); - let terminal = Terminal::new(backend)?; - let pc_ic_maps = contracts_sources - .0 - .iter() - .flat_map(|(contract_name, files_sources)| { - files_sources.iter().filter_map(|(_, (_, contract))| { - Some(( - contract_name.clone(), - ( - build_pc_ic_map( - SpecId::LATEST, - contract.bytecode.object.as_bytes()?.as_ref(), - ), - build_pc_ic_map( - SpecId::LATEST, - contract - .deployed_bytecode - .bytecode - .as_ref()? - .object - .as_bytes()? - .as_ref(), - ), - ), - )) - }) - }) - .collect(); - Ok(Debugger { - debug_arena, - terminal, - key_buffer: String::new(), - current_step, - identified_contracts, - contracts_sources, - pc_ic_maps, - breakpoints, - }) - } - - /// Starts the debugger TUI. Terminates the current process on failure or user exit. - pub fn run_exit(mut self) -> ! { - let code = match self.try_run() { - Ok(ExitReason::CharExit) => 0, - Err(e) => { - println!("{e}"); - 1 - } - }; - std::process::exit(code) - } - - /// Starts the debugger TUI. - pub fn try_run(&mut self) -> Result { - let mut guard = DebuggerGuard::setup(self)?; - let r = guard.0.try_run_real(); - // Cleanup only once. - guard.restore()?; - std::mem::forget(guard); - r - } - - #[instrument(target = "debugger", name = "run", skip_all, ret)] - fn try_run_real(&mut self) -> Result { - // Setup a channel to send interrupts - let (tx, rx) = mpsc::channel(); - thread::Builder::new() - .name("event-listener".into()) - .spawn(move || event_listener(tx)) - .expect("failed to spawn thread"); - - self.terminal.clear()?; - let mut draw_memory = DrawMemory::default(); - - let debug_call = self.debug_arena.clone(); - let mut opcode_list: Vec = - debug_call[0].1.iter().map(|step| step.pretty_opcode()).collect(); - let mut last_index = 0; - - let mut stack_labels = false; - let mut mem_utf = false; - let mut show_shortcuts = true; - - // UI thread that manages drawing - loop { - if last_index != draw_memory.inner_call_index { - opcode_list = debug_call[draw_memory.inner_call_index] - .1 - .iter() - .map(|step| step.pretty_opcode()) - .collect(); - last_index = draw_memory.inner_call_index; - } - - // Grab interrupt - let receiver = rx.recv()?; - - if let Some(c) = receiver.char_press() { - if self.key_buffer.ends_with('\'') { - // Find the location of the called breakpoint in the whole debug arena (at this - // address with this pc) - if let Some((caller, pc)) = self.breakpoints.get(&c) { - for (i, (_caller, debug_steps, _)) in debug_call.iter().enumerate() { - if _caller == caller { - if let Some(step) = - debug_steps.iter().position(|step| step.pc == *pc) - { - draw_memory.inner_call_index = i; - self.current_step = step; - break - } - } - } - } - self.key_buffer.clear(); - } else if let Interrupt::KeyEvent(event) = receiver { - match event.code { - // Exit - KeyCode::Char('q') => return Ok(ExitReason::CharExit), - // Move down - KeyCode::Char('j') | KeyCode::Down => { - // Grab number of times to do it - for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { - if event.modifiers.contains(KeyModifiers::CONTROL) { - let max_mem = (debug_call[draw_memory.inner_call_index].1 - [self.current_step] - .memory - .len() / - 32) - .saturating_sub(1); - if draw_memory.current_mem_startline < max_mem { - draw_memory.current_mem_startline += 1; - } - } else if self.current_step < opcode_list.len() - 1 { - self.current_step += 1; - } else if draw_memory.inner_call_index < debug_call.len() - 1 { - draw_memory.inner_call_index += 1; - self.current_step = 0; - } - } - self.key_buffer.clear(); - } - KeyCode::Char('J') => { - for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { - let max_stack = debug_call[draw_memory.inner_call_index].1 - [self.current_step] - .stack - .len() - .saturating_sub(1); - if draw_memory.current_stack_startline < max_stack { - draw_memory.current_stack_startline += 1; - } - } - self.key_buffer.clear(); - } - // Move up - KeyCode::Char('k') | KeyCode::Up => { - for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { - if event.modifiers.contains(KeyModifiers::CONTROL) { - draw_memory.current_mem_startline = - draw_memory.current_mem_startline.saturating_sub(1); - } else if self.current_step > 0 { - self.current_step -= 1; - } else if draw_memory.inner_call_index > 0 { - draw_memory.inner_call_index -= 1; - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - } - } - self.key_buffer.clear(); - } - KeyCode::Char('K') => { - for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { - draw_memory.current_stack_startline = - draw_memory.current_stack_startline.saturating_sub(1); - } - self.key_buffer.clear(); - } - // Go to top of file - KeyCode::Char('g') => { - draw_memory.inner_call_index = 0; - self.current_step = 0; - self.key_buffer.clear(); - } - // Go to bottom of file - KeyCode::Char('G') => { - draw_memory.inner_call_index = debug_call.len() - 1; - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - self.key_buffer.clear(); - } - // Go to previous call - KeyCode::Char('c') => { - draw_memory.inner_call_index = - draw_memory.inner_call_index.saturating_sub(1); - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - self.key_buffer.clear(); - } - // Go to next call - KeyCode::Char('C') => { - if debug_call.len() > draw_memory.inner_call_index + 1 { - draw_memory.inner_call_index += 1; - self.current_step = 0; - } - self.key_buffer.clear(); - } - // Step forward - KeyCode::Char('s') => { - for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { - let remaining_ops = - opcode_list[self.current_step..].to_vec().clone(); - self.current_step += remaining_ops - .iter() - .enumerate() - .find_map(|(i, op)| { - if i < remaining_ops.len() - 1 { - match ( - op.contains("JUMP") && op != "JUMPDEST", - &*remaining_ops[i + 1], - ) { - (true, "JUMPDEST") => Some(i + 1), - _ => None, - } - } else { - None - } - }) - .unwrap_or(opcode_list.len() - 1); - if self.current_step > opcode_list.len() { - self.current_step = opcode_list.len() - 1 - }; - } - self.key_buffer.clear(); - } - // Step backwards - KeyCode::Char('a') => { - for _ in 0..Debugger::buffer_as_number(&self.key_buffer, 1) { - let prev_ops = opcode_list[..self.current_step].to_vec().clone(); - self.current_step = prev_ops - .iter() - .enumerate() - .rev() - .find_map(|(i, op)| { - if i > 0 { - match ( - prev_ops[i - 1].contains("JUMP") && - prev_ops[i - 1] != "JUMPDEST", - &**op, - ) { - (true, "JUMPDEST") => Some(i - 1), - _ => None, - } - } else { - None - } - }) - .unwrap_or_default(); - } - self.key_buffer.clear(); - } - // toggle stack labels - KeyCode::Char('t') => stack_labels = !stack_labels, - // toggle memory utf8 decoding - KeyCode::Char('m') => mem_utf = !mem_utf, - // toggle help notice - KeyCode::Char('h') => show_shortcuts = !show_shortcuts, - KeyCode::Char(other) => match other { - '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '\'' => { - self.key_buffer.push(other); - } - // Invalid key, clear buffer - _ => self.key_buffer.clear(), - }, - _ => self.key_buffer.clear(), - } - } - } else { - match receiver { - Interrupt::MouseEvent(event) => match event.kind { - MouseEventKind::ScrollUp => { - if self.current_step > 0 { - self.current_step -= 1; - } else if draw_memory.inner_call_index > 0 { - draw_memory.inner_call_index -= 1; - draw_memory.current_mem_startline = 0; - draw_memory.current_stack_startline = 0; - self.current_step = - debug_call[draw_memory.inner_call_index].1.len() - 1; - } - } - MouseEventKind::ScrollDown => { - if self.current_step < opcode_list.len() - 1 { - self.current_step += 1; - } else if draw_memory.inner_call_index < debug_call.len() - 1 { - draw_memory.inner_call_index += 1; - draw_memory.current_mem_startline = 0; - draw_memory.current_stack_startline = 0; - self.current_step = 0; - } - } - _ => {} - }, - Interrupt::IntervalElapsed => {} - _ => (), - } - } - - // Draw - let current_step = self.current_step; - self.terminal.draw(|f| { - Debugger::draw_layout( - f, - debug_call[draw_memory.inner_call_index].0, - &self.identified_contracts, - &self.pc_ic_maps, - &self.contracts_sources, - &debug_call[draw_memory.inner_call_index].1[..], - &opcode_list, - current_step, - debug_call[draw_memory.inner_call_index].2, - &mut draw_memory, - stack_labels, - mem_utf, - show_shortcuts, - ) - })?; - } - } - - /// Grab number from buffer. Used for something like '10k' to move up 10 operations - fn buffer_as_number(s: &str, default_value: usize) -> usize { - match s.parse() { - Ok(num) if num >= 1 => num, - _ => default_value, - } - } - /// Create layout and subcomponents #[allow(clippy::too_many_arguments)] - fn draw_layout( + pub(crate) fn draw_layout( f: &mut Frame<'_>, address: Address, identified_contracts: &HashMap, @@ -1305,96 +915,3 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k f.render_widget(paragraph, area); } } - -/// Message sent from the event listener to the main thread. -enum Interrupt { - KeyEvent(KeyEvent), - MouseEvent(MouseEvent), - IntervalElapsed, -} - -impl Interrupt { - fn char_press(&self) -> Option { - match *self { - Self::KeyEvent(KeyEvent { code: KeyCode::Char(code), .. }) - if code.is_alphanumeric() || code == '\'' => - { - Some(code) - } - _ => None, - } - } -} - -/// This is currently used to remember last scroll position so screen doesn't wiggle as much. -#[derive(Default)] -struct DrawMemory { - current_startline: usize, - inner_call_index: usize, - current_mem_startline: usize, - current_stack_startline: usize, -} - -/// Handles terminal state. `restore` should be called before drop to handle errors. -#[must_use] -struct DebuggerGuard<'a>(&'a mut Debugger); - -impl<'a> DebuggerGuard<'a> { - fn setup(dbg: &'a mut Debugger) -> Result { - let this = Self(dbg); - enable_raw_mode()?; - execute!(*this.0.terminal.backend_mut(), EnterAlternateScreen, EnableMouseCapture)?; - this.0.terminal.hide_cursor()?; - Ok(this) - } - - fn restore(&mut self) -> Result<()> { - disable_raw_mode()?; - execute!(*self.0.terminal.backend_mut(), LeaveAlternateScreen, DisableMouseCapture)?; - self.0.terminal.show_cursor()?; - Ok(()) - } -} - -impl Drop for DebuggerGuard<'_> { - #[inline] - fn drop(&mut self) { - let _ = self.restore(); - } -} - -fn event_listener(tx: mpsc::Sender) { - // This is the recommend tick rate from `ratatui`, based on their examples - let tick_rate = Duration::from_millis(200); - - let mut last_tick = Instant::now(); - loop { - // Poll events since last tick - if last tick is greater than tick_rate, we - // demand immediate availability of the event. This may affect interactivity, - // but I'm not sure as it is hard to test. - if event::poll(tick_rate.saturating_sub(last_tick.elapsed())).unwrap() { - let event = event::read().unwrap(); - match event { - Event::Key(key) => { - if tx.send(Interrupt::KeyEvent(key)).is_err() { - return - } - } - Event::Mouse(mouse) => { - if tx.send(Interrupt::MouseEvent(mouse)).is_err() { - return - } - } - Event::FocusGained | Event::FocusLost | Event::Paste(_) | Event::Resize(..) => {} - } - } - - // Force update if time has passed - if last_tick.elapsed() > tick_rate { - if tx.send(Interrupt::IntervalElapsed).is_err() { - return - } - last_tick = Instant::now(); - } - } -} diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs new file mode 100644 index 0000000000000..b4cc1bf75c83c --- /dev/null +++ b/crates/debugger/src/tui/mod.rs @@ -0,0 +1,200 @@ +//! The TUI implementation. + +use alloy_primitives::Address; +use crossterm::{ + event::{self, DisableMouseCapture, EnableMouseCapture, Event}, + execute, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, +}; +use eyre::Result; +use foundry_common::{compile::ContractSources, evm::Breakpoints}; +use foundry_evm_core::{ + debug::DebugStep, + utils::{build_pc_ic_map, CallKind, PCICMap}, +}; +use ratatui::{backend::CrosstermBackend, Terminal}; +use revm::primitives::SpecId; +use std::{ + collections::{BTreeMap, HashMap}, + io, + ops::ControlFlow, + sync::mpsc, + thread, + time::{Duration, Instant}, +}; + +mod builder; +pub use builder::DebuggerBuilder; + +mod context; +use context::DebuggerContext; + +mod draw; + +/// Debugger exit reason. +#[derive(Debug)] +pub enum ExitReason { + /// Exit using 'q'. + CharExit, +} + +/// The TUI debugger. +pub struct Debugger { + debug_arena: Vec<(Address, Vec, CallKind)>, + terminal: Terminal>, + identified_contracts: HashMap, + /// Source map of contract sources + contracts_sources: ContractSources, + /// A mapping of source -> (PC -> IC map for deploy code, PC -> IC map for runtime code) + pc_ic_maps: BTreeMap, + breakpoints: Breakpoints, +} + +impl Debugger { + /// Creates a new debugger builder. + #[inline] + pub fn builder() -> DebuggerBuilder { + DebuggerBuilder::new() + } + + /// Creates a new debugger. + pub fn new( + debug_arena: Vec<(Address, Vec, CallKind)>, + identified_contracts: HashMap, + contracts_sources: ContractSources, + breakpoints: Breakpoints, + ) -> Result { + let backend = CrosstermBackend::new(io::stdout()); + let terminal = Terminal::new(backend)?; + let pc_ic_maps = contracts_sources + .0 + .iter() + .flat_map(|(contract_name, files_sources)| { + files_sources.iter().filter_map(|(_, (_, contract))| { + Some(( + contract_name.clone(), + ( + build_pc_ic_map( + SpecId::LATEST, + contract.bytecode.object.as_bytes()?.as_ref(), + ), + build_pc_ic_map( + SpecId::LATEST, + contract + .deployed_bytecode + .bytecode + .as_ref()? + .object + .as_bytes()? + .as_ref(), + ), + ), + )) + }) + }) + .collect(); + Ok(Self { + debug_arena, + terminal, + identified_contracts, + contracts_sources, + pc_ic_maps, + breakpoints, + }) + } + + /// Starts the debugger TUI. Terminates the current process on failure or user exit. + pub fn run_exit(mut self) -> ! { + let code = match self.try_run() { + Ok(ExitReason::CharExit) => 0, + Err(e) => { + println!("{e}"); + 1 + } + }; + std::process::exit(code) + } + + /// Starts the debugger TUI. + pub fn try_run(&mut self) -> Result { + let mut guard = DebuggerGuard::setup(self)?; + let r = guard.0.try_run_real(); + // Cleanup only once. + guard.restore()?; + std::mem::forget(guard); + r + } + + #[instrument(target = "debugger", name = "run", skip_all, ret)] + fn try_run_real(&mut self) -> Result { + // Create the context. + let mut cx = DebuggerContext::new(self); + cx.init()?; + + // Create an event listener in a different thread. + let (tx, rx) = mpsc::channel(); + thread::Builder::new() + .name("event-listener".into()) + .spawn(move || Self::event_listener(tx)) + .expect("failed to spawn thread"); + + loop { + match cx.handle_event(rx.recv()?) { + ControlFlow::Continue(()) => {} + ControlFlow::Break(reason) => return Ok(reason), + } + cx.draw()?; + } + } + + fn event_listener(tx: mpsc::Sender) { + // This is the recommend tick rate from `ratatui`, based on their examples + let tick_rate = Duration::from_millis(200); + + let mut last_tick = Instant::now(); + loop { + // Poll events since last tick - if last tick is greater than tick_rate, we + // demand immediate availability of the event. This may affect interactivity, + // but I'm not sure as it is hard to test. + if event::poll(tick_rate.saturating_sub(last_tick.elapsed())).unwrap() { + let event = event::read().unwrap(); + if tx.send(event).is_err() { + return; + } + } + + // Force update if time has passed + if last_tick.elapsed() > tick_rate { + last_tick = Instant::now(); + } + } + } +} + +/// Handles terminal state. `restore` should be called before drop to handle errors. +#[must_use] +struct DebuggerGuard<'a>(&'a mut Debugger); + +impl<'a> DebuggerGuard<'a> { + fn setup(dbg: &'a mut Debugger) -> Result { + let this = Self(dbg); + enable_raw_mode()?; + execute!(*this.0.terminal.backend_mut(), EnterAlternateScreen, EnableMouseCapture)?; + this.0.terminal.hide_cursor()?; + Ok(this) + } + + fn restore(&mut self) -> Result<()> { + disable_raw_mode()?; + execute!(*self.0.terminal.backend_mut(), LeaveAlternateScreen, DisableMouseCapture)?; + self.0.terminal.show_cursor()?; + Ok(()) + } +} + +impl Drop for DebuggerGuard<'_> { + #[inline] + fn drop(&mut self) { + let _ = self.restore(); + } +} From b256474c4a6ea10906cd7c7fbc755e1c54d0476c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:46:20 +0100 Subject: [PATCH 0371/1963] feat: decode Hardhat console logs in traces (#6504) * chore: add tracing to trace decoder * cleanup hh console * feat: decode Hardhat console logs in traces * chore: clippy --- crates/evm/core/src/abi/hardhat_console.rs | 42 +++++--- crates/evm/core/src/abi/mod.rs | 5 +- crates/evm/evm/src/inspectors/logs.rs | 4 +- crates/evm/traces/src/decoder/mod.rs | 107 ++++++++++++------- crates/evm/traces/src/decoder/precompiles.rs | 1 + crates/forge/tests/it/repros.rs | 46 ++++++++ testdata/repros/Issue6501.t.sol | 14 +++ 7 files changed, 162 insertions(+), 57 deletions(-) create mode 100644 testdata/repros/Issue6501.t.sol diff --git a/crates/evm/core/src/abi/hardhat_console.rs b/crates/evm/core/src/abi/hardhat_console.rs index 955ebc087f9dd..4b9aa3ba2a898 100644 --- a/crates/evm/core/src/abi/hardhat_console.rs +++ b/crates/evm/core/src/abi/hardhat_console.rs @@ -1,3 +1,4 @@ +use alloy_primitives::Selector; use alloy_sol_types::sol; use foundry_macros::ConsoleFmt; use once_cell::sync::Lazy; @@ -10,25 +11,34 @@ sol!( "src/abi/HardhatConsole.json" ); -/// If the input starts with a known `hardhat/console.log` `uint` selector, then this will replace -/// it with the selector `abigen!` bindings expect. -pub fn patch_hardhat_console_selector(input: &mut [u8]) { - if let Some(selector) = input.get_mut(..4) { - let selector: &mut [u8; 4] = selector.try_into().unwrap(); - if let Some(generated_selector) = HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector) { - *selector = *generated_selector; - } +/// Patches the given Hardhat `console` function selector to its ABI-normalized form. +/// +/// See [`HARDHAT_CONSOLE_SELECTOR_PATCHES`] for more details. +pub fn patch_hh_console_selector(input: &mut [u8]) { + if let Some(selector) = hh_console_selector(input) { + input[..4].copy_from_slice(selector.as_slice()); + } +} + +/// Returns the ABI-normalized selector for the given Hardhat `console` function selector. +/// +/// See [`HARDHAT_CONSOLE_SELECTOR_PATCHES`] for more details. +pub fn hh_console_selector(input: &[u8]) -> Option<&'static Selector> { + if let Some(selector) = input.get(..4) { + let selector: &[u8; 4] = selector.try_into().unwrap(); + HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector).map(Into::into) + } else { + None } } -/// This contains a map with all the `hardhat/console.log` log selectors that use `uint` or `int` -/// as key and the selector of the call with `uint256`, +/// Maps all the `hardhat/console.log` log selectors that use the legacy ABI (`int`, `uint`) to +/// their normalized counterparts (`int256`, `uint256`). /// -/// This is a bit terrible but a workaround for the differing selectors used by hardhat and the call -/// bindings which `abigen!` creates. `hardhat/console.log` logs its events in functions that accept -/// `uint` manually as `abi.encodeWithSignature("log(int)", p0)`, but `abigen!` uses `uint256` for -/// its call bindings (`HardhatConsoleCalls`) as generated by solc. -static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { +/// `hardhat/console.log` logs its events manually, and in functions that accept integers they're +/// encoded as `abi.encodeWithSignature("log(int)", p0)`, which is not the canonical ABI encoding +/// for `int` that Solc (and [`sol!`]) uses. +pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { HashMap::from([ // log(bool,uint256,uint256,address) ([241, 97, 178, 33], [0, 221, 135, 185]), @@ -549,7 +559,7 @@ mod tests { fn hardhat_console_patch() { for (hh, generated) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { let mut hh = *hh; - patch_hardhat_console_selector(&mut hh); + patch_hh_console_selector(&mut hh); assert_eq!(hh, *generated); } } diff --git a/crates/evm/core/src/abi/mod.rs b/crates/evm/core/src/abi/mod.rs index 6fba308b2d268..39566cf796fcf 100644 --- a/crates/evm/core/src/abi/mod.rs +++ b/crates/evm/core/src/abi/mod.rs @@ -6,4 +6,7 @@ mod console; pub use console::Console; mod hardhat_console; -pub use hardhat_console::{patch_hardhat_console_selector, HardhatConsole}; +pub use hardhat_console::{ + hh_console_selector, patch_hh_console_selector, HardhatConsole, + HARDHAT_CONSOLE_SELECTOR_PATCHES, +}; diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index 466cf9fee7b80..f517f042e7ed5 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -3,7 +3,7 @@ use alloy_sol_types::{SolEvent, SolInterface, SolValue}; use ethers_core::types::Log; use foundry_common::{fmt::ConsoleFmt, types::ToEthers, ErrorExt}; use foundry_evm_core::{ - abi::{patch_hardhat_console_selector, Console, HardhatConsole}, + abi::{patch_hh_console_selector, Console, HardhatConsole}, constants::HARDHAT_CONSOLE_ADDRESS, }; use revm::{ @@ -23,7 +23,7 @@ pub struct LogCollector { impl LogCollector { fn hardhat_log(&mut self, mut input: Vec) -> (InstructionResult, Bytes) { // Patch the Hardhat-style selector (`uint` instead of `uint256`) - patch_hardhat_console_selector(&mut input); + patch_hh_console_selector(&mut input); // Decode the call let decoded = match HardhatConsole::HardhatConsoleCalls::abi_decode(&input, false) { diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 2866d8319a396..3c4c1d766212e 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -7,7 +7,7 @@ use alloy_json_abi::{Event, Function, JsonAbi as Abi}; use alloy_primitives::{Address, Selector, B256}; use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ - abi::{Console, HardhatConsole, Vm}, + abi::{Console, HardhatConsole, Vm, HARDHAT_CONSOLE_SELECTOR_PATCHES}, constants::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS, @@ -17,6 +17,7 @@ use foundry_evm_core::{ use itertools::Itertools; use once_cell::sync::OnceCell; use std::collections::{hash_map::Entry, BTreeMap, HashMap}; +use tracing::field; mod precompiles; @@ -117,6 +118,23 @@ impl CallTraceDecoder { } fn init() -> Self { + /// All functions from the Hardhat console ABI. + /// + /// See [`HARDHAT_CONSOLE_SELECTOR_PATCHES`] for more details. + fn hh_funcs() -> impl Iterator { + let functions = HardhatConsole::abi::functions(); + let mut functions: Vec<_> = + functions.into_values().flatten().map(|func| (func.selector(), func)).collect(); + let len = functions.len(); + // `functions` is the list of all patched functions; duplicate the unpatched ones + for (unpatched, patched) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { + if let Some((_, func)) = functions[..len].iter().find(|(sel, _)| sel == patched) { + functions.push((unpatched.into(), func.clone())); + } + } + functions.into_iter() + } + Self { contracts: Default::default(), @@ -129,11 +147,14 @@ impl CallTraceDecoder { ] .into(), - functions: HardhatConsole::abi::functions() - .into_values() - .chain(Vm::abi::functions().into_values()) - .flatten() - .map(|func| (func.selector(), vec![func])) + functions: hh_funcs() + .chain( + Vm::abi::functions() + .into_values() + .flatten() + .map(|func| (func.selector(), func)), + ) + .map(|(selector, func)| (selector, vec![func])) .collect(), events: Console::abi::events() @@ -223,14 +244,17 @@ impl CallTraceDecoder { } async fn decode_function(&self, trace: &mut CallTrace) { + let span = trace_span!("decode_function", label = field::Empty).entered(); + // Decode precompile if precompiles::decode(trace, 1) { - return + return; } // Set label if trace.label.is_none() { if let Some(label) = self.labels.get(&trace.address) { + span.record("label", label); trace.label = Some(label.clone()); } } @@ -245,8 +269,9 @@ impl CallTraceDecoder { let TraceCallData::Raw(cdata) = &trace.data else { return }; if trace.address == DEFAULT_CREATE2_DEPLOYER { + trace!("decoded as create2"); trace.data = TraceCallData::Decoded { signature: "create2".to_string(), args: vec![] }; - return + return; } if cdata.len() >= SELECTOR_LEN { @@ -273,15 +298,15 @@ impl CallTraceDecoder { let signature = if cdata.is_empty() && has_receive { "receive()" } else { "fallback()" }.into(); let args = if cdata.is_empty() { Vec::new() } else { vec![cdata.to_string()] }; + trace!(?signature, ?args, "decoded fallback data"); trace.data = TraceCallData::Decoded { signature, args }; if let TraceRetData::Raw(rdata) = &trace.output { if !trace.success { - trace.output = TraceRetData::Decoded(decode::decode_revert( - rdata, - Some(&self.errors), - Some(trace.status), - )); + let decoded = + decode::decode_revert(rdata, Some(&self.errors), Some(trace.status)); + trace!(?decoded, "decoded fallback output"); + trace.output = TraceRetData::Decoded(decoded); } } } @@ -305,8 +330,10 @@ impl CallTraceDecoder { } } } - trace.data = - TraceCallData::Decoded { signature: func.signature(), args: args.unwrap_or_default() }; + + let signature = func.signature(); + trace!(?signature, ?args, "decoded function input"); + trace.data = TraceCallData::Decoded { signature, args: args.unwrap_or_default() }; } /// Custom decoding for cheatcode inputs. @@ -377,34 +404,36 @@ impl CallTraceDecoder { /// Decodes a function's output into the given trace. fn decode_function_output(&self, trace: &mut CallTrace, funcs: &[Function]) { let TraceRetData::Raw(data) = &trace.output else { return }; + let mut s = None; if trace.success { if trace.address == CHEATCODE_ADDRESS { - if let Some(decoded) = - funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)) - { - trace.output = TraceRetData::Decoded(decoded); - return - } + s = funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)); } - if let Some(values) = - funcs.iter().find_map(|func| func.abi_decode_output(data, false).ok()) - { - // Functions coming from an external database do not have any outputs specified, - // and will lead to returning an empty list of values. - if values.is_empty() { - return + if s.is_some() { + if let Some(values) = + funcs.iter().find_map(|func| func.abi_decode_output(data, false).ok()) + { + // Functions coming from an external database do not have any outputs specified, + // and will lead to returning an empty list of values. + if !values.is_empty() { + s = Some( + values + .iter() + .map(|value| self.apply_label(value)) + .format(", ") + .to_string(), + ); + } } - trace.output = TraceRetData::Decoded( - values.iter().map(|value| self.apply_label(value)).format(", ").to_string(), - ); } } else { - trace.output = TraceRetData::Decoded(decode::decode_revert( - data, - Some(&self.errors), - Some(trace.status), - )); + s = decode::maybe_decode_revert(data, Some(&self.errors), Some(trace.status)); + } + + if let Some(decoded) = s { + trace!(?decoded, "decoded function output"); + trace.output = TraceRetData::Decoded(decoded); } } @@ -440,8 +469,10 @@ impl CallTraceDecoder { for event in events { if let Ok(decoded) = event.decode_log(raw_log, false) { let params = reconstruct_params(event, &decoded); + let name = event.name.clone(); + trace!(?name, ?params, "decoded event"); *log = TraceLog::Decoded( - event.name.clone(), + name, params .into_iter() .zip(event.inputs.iter()) @@ -452,7 +483,7 @@ impl CallTraceDecoder { }) .collect(), ); - break + break; } } } diff --git a/crates/evm/traces/src/decoder/precompiles.rs b/crates/evm/traces/src/decoder/precompiles.rs index a1b3f94250343..801ec92df844b 100644 --- a/crates/evm/traces/src/decoder/precompiles.rs +++ b/crates/evm/traces/src/decoder/precompiles.rs @@ -76,6 +76,7 @@ pub(super) fn decode(trace: &mut CallTrace, _chain_id: u64) -> bool { // TODO: Other chain precompiles + trace!(?signature, ?args, "decoded precompile call"); trace.data = TraceCallData::Decoded { signature: signature.to_string(), args }; trace.label = Some("PRECOMPILES".into()); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index a472123a615ae..36ee48d390d30 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -5,6 +5,11 @@ use alloy_primitives::{address, Address}; use ethers_core::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; use forge::result::TestStatus; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_evm::{ + constants::HARDHAT_CONSOLE_ADDRESS, + traces::{CallTraceDecoder, TraceCallData, TraceKind}, + utils::CallKind, +}; use foundry_test_utils::Filter; /// Creates a test that runs `testdata/repros/Issue{issue}.t.sol`. @@ -214,3 +219,44 @@ test_repro!(6355, false, None, |res| { // https://github.com/foundry-rs/foundry/issues/6437 test_repro!(6437); + +// Test we decode Hardhat console logs AND traces correctly. +// https://github.com/foundry-rs/foundry/issues/6501 +test_repro!(6501, false, None, |res| { + let mut res = res.remove("repros/Issue6501.t.sol:Issue6501Test").unwrap(); + let test = res.test_results.remove("test_hhLogs()").unwrap(); + assert_eq!(test.status, TestStatus::Success); + assert_eq!(test.decoded_logs, ["a".to_string(), "1".to_string(), "b 2".to_string()]); + + let (kind, mut traces) = test.traces[1].clone(); + assert_eq!(kind, TraceKind::Execution); + + let test_call = traces.arena.first().unwrap(); + assert_eq!(test_call.idx, 0); + assert_eq!(test_call.children, [1, 2, 3]); + assert_eq!(test_call.trace.depth, 0); + assert!(test_call.trace.success); + + CallTraceDecoder::new().decode(&mut traces).await; + + let expected = [ + ("log(string)", vec!["\"a\""]), + ("log(uint256)", vec!["1"]), + ("log(string,uint256)", vec!["\"b\"", "2"]), + ]; + for (node, expected) in traces.arena[1..=3].iter().zip(expected) { + let trace = &node.trace; + assert_eq!(trace.kind, CallKind::StaticCall); + assert_eq!(trace.address, HARDHAT_CONSOLE_ADDRESS); + assert_eq!(trace.label, Some("console".into())); + assert_eq!(trace.depth, 1); + assert!(trace.success); + assert_eq!( + trace.data, + TraceCallData::Decoded { + signature: expected.0.into(), + args: expected.1.into_iter().map(ToOwned::to_owned).collect(), + } + ); + } +}); diff --git a/testdata/repros/Issue6501.t.sol b/testdata/repros/Issue6501.t.sol new file mode 100644 index 0000000000000..392f0f1abc8a9 --- /dev/null +++ b/testdata/repros/Issue6501.t.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../logs/console.sol"; + +// https://github.com/foundry-rs/foundry/issues/6501 +contract Issue6501Test is DSTest { + function test_hhLogs() public { + console.log("a"); + console.log(uint256(1)); + console.log("b", uint256(2)); + } +} From 3ee4135ce8512dae0e6cea60f143c2e6672213c5 Mon Sep 17 00:00:00 2001 From: Cheng-Kang Chen Date: Mon, 4 Dec 2023 22:12:01 +0800 Subject: [PATCH 0372/1963] fix(debugger): a potential underflow in memory highlighting (#6508) The debugger colors memory region for a variety of instructions that access the memory, as described in #5940. But there is a potential underflow if the size is 0 (where offset + size - 1 underflows). Change to a simpler and more robust way to index the memory region. Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/debugger/src/tui/draw.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index cfba3c6001b0c..7a044025d028f 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -782,7 +782,13 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k -2 => Some(1), -1 => Some(32), 0 => None, - 1.. => Some(stack[stack_len - stack_index as usize].saturating_to()), + 1.. => { + if (stack_index as usize) <= stack_len { + Some(stack[stack_len - stack_index as usize].saturating_to()) + } else { + None + } + } _ => panic!("invalid stack index"), }; @@ -862,11 +868,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k Span::styled( format!("{byte:02x} "), if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { - if (i == offset / 32 && j >= offset % 32) || - (i > offset / 32 && i < (offset + size - 1) / 32) || - (i == (offset + size - 1) / 32 && - j <= (offset + size - 1) % 32) - { + if i * 32 + j >= offset && i * 32 + j < offset + size { // [offset, offset + size] is the memory region to be colored. // If a byte at row i and column j in the memory panel // falls in this region, set the color. From adf30996a8320166f0730b2eb0041f4a9a9519d2 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 4 Dec 2023 11:53:20 -0400 Subject: [PATCH 0373/1963] chore: make clippy happy (#6518) --- crates/debugger/src/tui/draw.rs | 2 +- crates/fmt/src/formatter.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 7a044025d028f..307eae05bc860 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -759,7 +759,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k /// (read memory offset, read memory size, write memory offset, write memory size) fn get_memory_access( op: u8, - stack: &Vec, + stack: &[U256], ) -> (Option, Option, Option, Option) { let memory_access = match op { opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => (1, 2, 0, 0), diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 2ed579dce59cb..650f87e2e4fa1 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1070,7 +1070,7 @@ impl<'a, W: Write> Formatter<'a, W> { fn visit_list( &mut self, prefix: &str, - items: &mut Vec, + items: &mut [T], start_offset: Option, end_offset: Option, paren_required: bool, @@ -1113,7 +1113,7 @@ impl<'a, W: Write> Formatter<'a, W> { fn visit_block( &mut self, loc: Loc, - statements: &mut Vec, + statements: &mut [T], attempt_single_line: bool, attempt_omit_braces: bool, ) -> Result @@ -1167,7 +1167,7 @@ impl<'a, W: Write> Formatter<'a, W> { Statement::Block { loc, statements, .. } => { self.visit_block(*loc, statements, attempt_single_line, true) } - _ => self.visit_block(stmt.loc(), &mut vec![stmt], attempt_single_line, true), + _ => self.visit_block(stmt.loc(), &mut [stmt], attempt_single_line, true), } } From 677e81028e971e7564e882e924875d78a0d07c8d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:04:22 +0100 Subject: [PATCH 0374/1963] refactor(debugger): use context when drawing (#6520) * refactor: name `DebugArena::flatten` return type * refactor: use context in draw * refactor: move terminal out of debugger struct * dedup * stuff * fix: draw initial state before any event is received * fix: breakpoint handling --- crates/cli/src/utils/cmd.rs | 2 +- crates/debugger/src/tui/builder.rs | 10 +- crates/debugger/src/tui/context.rs | 108 ++++------ crates/debugger/src/tui/draw.rs | 333 +++++++---------------------- crates/debugger/src/tui/mod.rs | 86 ++++---- crates/evm/core/src/debug.rs | 67 +++++- crates/forge/bin/cmd/script/cmd.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- 8 files changed, 231 insertions(+), 379 deletions(-) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 0631ec974a639..910e137fce2a9 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -408,7 +408,7 @@ pub async fn handle_traces( .debug_arena(&result.debug) .decoder(&decoder) .sources(sources) - .build()?; + .build(); debugger.try_run()?; } else { print_traces(&mut result, &decoder, verbose).await?; diff --git a/crates/debugger/src/tui/builder.rs b/crates/debugger/src/tui/builder.rs index e8f27b1c0e88e..6289b0b8814fa 100644 --- a/crates/debugger/src/tui/builder.rs +++ b/crates/debugger/src/tui/builder.rs @@ -2,12 +2,8 @@ use crate::Debugger; use alloy_primitives::Address; -use eyre::Result; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm_core::{ - debug::{DebugArena, DebugStep}, - utils::CallKind, -}; +use foundry_evm_core::debug::{DebugArena, DebugNodeFlat}; use foundry_evm_traces::CallTraceDecoder; use std::collections::HashMap; @@ -16,7 +12,7 @@ use std::collections::HashMap; #[must_use = "builders do nothing unless you call `build` on them"] pub struct DebuggerBuilder { /// Debug traces returned from the EVM execution. - debug_arena: Vec<(Address, Vec, CallKind)>, + debug_arena: Vec, /// Identified contracts. identified_contracts: HashMap, /// Map of source files. @@ -90,7 +86,7 @@ impl DebuggerBuilder { /// Builds the debugger. #[inline] - pub fn build(self) -> Result { + pub fn build(self) -> Debugger { let Self { debug_arena, identified_contracts, sources, breakpoints } = self; Debugger::new(debug_arena, identified_contracts, sources, breakpoints) } diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index ac0a9e1fd4289..c70bec28f279b 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -3,14 +3,17 @@ use crate::{Debugger, ExitReason}; use alloy_primitives::Address; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; -use eyre::Result; -use foundry_evm_core::{debug::DebugStep, utils::CallKind}; -use std::ops::ControlFlow; +use foundry_evm_core::{ + debug::{DebugNodeFlat, DebugStep}, + utils::CallKind, +}; +use std::{cell::RefCell, ops::ControlFlow}; /// This is currently used to remember last scroll position so screen doesn't wiggle as much. #[derive(Default)] pub(crate) struct DrawMemory { - pub(crate) current_startline: usize, + // TODO + pub(crate) current_startline: RefCell, pub(crate) inner_call_index: usize, pub(crate) current_mem_startline: usize, pub(crate) current_stack_startline: usize, @@ -49,37 +52,51 @@ impl<'a> DebuggerContext<'a> { } } - pub(crate) fn init(&mut self) -> Result<()> { - self.debugger.terminal.clear()?; + pub(crate) fn init(&mut self) { self.gen_opcode_list(); - Ok(()) } - fn debug_arena(&self) -> &[(Address, Vec, CallKind)] { + pub(crate) fn debug_arena(&self) -> &[DebugNodeFlat] { &self.debugger.debug_arena } + pub(crate) fn debug_call(&self) -> &DebugNodeFlat { + &self.debug_arena()[self.draw_memory.inner_call_index] + } + + /// Returns the current call address. + pub(crate) fn address(&self) -> &Address { + &self.debug_call().address + } + + /// Returns the current call kind. + pub(crate) fn call_kind(&self) -> CallKind { + self.debug_call().kind + } + + /// Returns the current debug steps. + pub(crate) fn debug_steps(&self) -> &[DebugStep] { + &self.debug_call().steps + } + + /// Returns the current debug step. + pub(crate) fn current_step(&self) -> &DebugStep { + &self.debug_steps()[self.current_step] + } + fn gen_opcode_list(&mut self) { self.opcode_list = self.opcode_list(); } fn opcode_list(&self) -> Vec { - self.debugger.debug_arena[self.draw_memory.inner_call_index] - .1 - .iter() - .map(DebugStep::pretty_opcode) - .collect() + self.debug_steps().iter().map(DebugStep::pretty_opcode).collect() } } impl DebuggerContext<'_> { pub(crate) fn handle_event(&mut self, event: Event) -> ControlFlow { if self.last_index != self.draw_memory.inner_call_index { - self.opcode_list = self.debug_arena()[self.draw_memory.inner_call_index] - .1 - .iter() - .map(|step| step.pretty_opcode()) - .collect(); + self.gen_opcode_list(); self.last_index = self.draw_memory.inner_call_index; } @@ -92,7 +109,7 @@ impl DebuggerContext<'_> { fn handle_key_event(&mut self, event: KeyEvent) -> ControlFlow { if let KeyCode::Char(c) = event.code { - if c.is_alphanumeric() || c == '\'' { + if c.is_alphabetic() && self.key_buffer.starts_with('\'') { self.handle_breakpoint(c); return ControlFlow::Continue(()); } @@ -106,12 +123,7 @@ impl DebuggerContext<'_> { // Grab number of times to do it for _ in 0..buffer_as_number(&self.key_buffer, 1) { if event.modifiers.contains(KeyModifiers::CONTROL) { - let max_mem = (self.debug_arena()[self.draw_memory.inner_call_index].1 - [self.current_step] - .memory - .len() / - 32) - .saturating_sub(1); + let max_mem = (self.current_step().memory.len() / 32).saturating_sub(1); if self.draw_memory.current_mem_startline < max_mem { self.draw_memory.current_mem_startline += 1; } @@ -126,11 +138,7 @@ impl DebuggerContext<'_> { } KeyCode::Char('J') => { for _ in 0..buffer_as_number(&self.key_buffer, 1) { - let max_stack = self.debug_arena()[self.draw_memory.inner_call_index].1 - [self.current_step] - .stack - .len() - .saturating_sub(1); + let max_stack = self.current_step().stack.len().saturating_sub(1); if self.draw_memory.current_stack_startline < max_stack { self.draw_memory.current_stack_startline += 1; } @@ -147,8 +155,7 @@ impl DebuggerContext<'_> { self.current_step -= 1; } else if self.draw_memory.inner_call_index > 0 { self.draw_memory.inner_call_index -= 1; - self.current_step = - self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + self.current_step = self.debug_steps().len() - 1; } } self.key_buffer.clear(); @@ -169,16 +176,14 @@ impl DebuggerContext<'_> { // Go to bottom of file KeyCode::Char('G') => { self.draw_memory.inner_call_index = self.debug_arena().len() - 1; - self.current_step = - self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + self.current_step = self.debug_steps().len() - 1; self.key_buffer.clear(); } // Go to previous call KeyCode::Char('c') => { self.draw_memory.inner_call_index = self.draw_memory.inner_call_index.saturating_sub(1); - self.current_step = - self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + self.current_step = self.debug_steps().len() - 1; self.key_buffer.clear(); } // Go to next call @@ -261,9 +266,9 @@ impl DebuggerContext<'_> { // Find the location of the called breakpoint in the whole debug arena (at this address with // this pc) if let Some((caller, pc)) = self.debugger.breakpoints.get(&c) { - for (i, (_caller, debug_steps, _)) in self.debug_arena().iter().enumerate() { - if _caller == caller { - if let Some(step) = debug_steps.iter().position(|step| step.pc == *pc) { + for (i, node) in self.debug_arena().iter().enumerate() { + if node.address == *caller { + if let Some(step) = node.steps.iter().position(|step| step.pc == *pc) { self.draw_memory.inner_call_index = i; self.current_step = step; break @@ -283,8 +288,7 @@ impl DebuggerContext<'_> { self.draw_memory.inner_call_index -= 1; self.draw_memory.current_mem_startline = 0; self.draw_memory.current_stack_startline = 0; - self.current_step = - self.debug_arena()[self.draw_memory.inner_call_index].1.len() - 1; + self.current_step = self.debug_steps().len() - 1; } } MouseEventKind::ScrollDown => { @@ -302,28 +306,6 @@ impl DebuggerContext<'_> { ControlFlow::Continue(()) } - - pub(crate) fn draw(&mut self) -> Result<()> { - self.debugger.terminal.draw(|f| { - let debug_arena = &self.debugger.debug_arena; - Debugger::draw_layout( - f, - debug_arena[self.draw_memory.inner_call_index].0, - &self.debugger.identified_contracts, - &self.debugger.pc_ic_maps, - &self.debugger.contracts_sources, - &debug_arena[self.draw_memory.inner_call_index].1[..], - &self.opcode_list, - self.current_step, - debug_arena[self.draw_memory.inner_call_index].2, - &mut self.draw_memory, - self.stack_labels, - self.mem_utf, - self.show_shortcuts, - ) - })?; - Ok(()) - } } /// Grab number from buffer. Used for something like '10k' to move up 10 operations diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 307eae05bc860..50f66a05b0a0d 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -1,13 +1,9 @@ //! TUI draw implementation. -use super::context::DrawMemory; -use crate::{op::OpcodeParam, Debugger}; -use alloy_primitives::{Address, U256}; -use foundry_common::compile::ContractSources; -use foundry_evm_core::{ - debug::{DebugStep, Instruction}, - utils::{CallKind, PCICMap}, -}; +use super::context::DebuggerContext; +use crate::op::OpcodeParam; +use alloy_primitives::U256; +use foundry_evm_core::{debug::Instruction, utils::CallKind}; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, @@ -16,83 +12,25 @@ use ratatui::{ widgets::{Block, Borders, Paragraph, Wrap}, }; use revm::interpreter::opcode; -use std::{ - cmp::{max, min}, - collections::{BTreeMap, HashMap, VecDeque}, -}; +use std::{cmp, collections::VecDeque, io}; -impl Debugger { - /// Create layout and subcomponents - #[allow(clippy::too_many_arguments)] - pub(crate) fn draw_layout( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - call_kind: CallKind, - draw_memory: &mut DrawMemory, - stack_labels: bool, - mem_utf: bool, - show_shortcuts: bool, - ) { - let total_size = f.size(); - if total_size.width < 225 { - Debugger::vertical_layout( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps, - opcode_list, - current_step, - call_kind, - draw_memory, - stack_labels, - mem_utf, - show_shortcuts, - ); +impl DebuggerContext<'_> { + /// Draws the TUI layout and subcomponents to the given terminal. + pub(crate) fn draw(&self, terminal: &mut super::DebuggerTerminal) -> io::Result<()> { + terminal.draw(|f| self.draw_layout(f)).map(drop) + } + + fn draw_layout(&self, f: &mut Frame<'_>) { + if f.size().width < 225 { + self.vertical_layout(f); } else { - Debugger::square_layout( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps, - opcode_list, - current_step, - call_kind, - draw_memory, - stack_labels, - mem_utf, - show_shortcuts, - ); + self.square_layout(f); } } - #[allow(clippy::too_many_arguments)] - fn vertical_layout( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - call_kind: CallKind, - draw_memory: &mut DrawMemory, - stack_labels: bool, - mem_utf: bool, - show_shortcuts: bool, - ) { + fn vertical_layout(&self, f: &mut Frame<'_>) { let total_size = f.size(); - let h_height = if show_shortcuts { 4 } else { 0 }; + let h_height = if self.show_shortcuts { 4 } else { 0 }; if let [app, footer] = Layout::default() .constraints( @@ -114,44 +52,13 @@ impl Debugger { ) .split(app)[..] { - if show_shortcuts { - Debugger::draw_footer(f, footer); + if self.show_shortcuts { + Self::draw_footer(f, footer); } - Debugger::draw_src( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps[current_step].pc, - call_kind, - src_pane, - ); - Debugger::draw_op_list( - f, - address, - debug_steps, - opcode_list, - current_step, - draw_memory, - op_pane, - ); - Debugger::draw_stack( - f, - debug_steps, - current_step, - stack_pane, - stack_labels, - draw_memory, - ); - Debugger::draw_memory( - f, - debug_steps, - current_step, - memory_pane, - mem_utf, - draw_memory, - ); + self.draw_src(f, src_pane); + self.draw_op_list(f, op_pane); + self.draw_stack(f, stack_pane); + self.draw_memory(f, memory_pane); } else { panic!("unable to create vertical panes") } @@ -160,24 +67,9 @@ impl Debugger { }; } - #[allow(clippy::too_many_arguments)] - fn square_layout( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - call_kind: CallKind, - draw_memory: &mut DrawMemory, - stack_labels: bool, - mem_utf: bool, - show_shortcuts: bool, - ) { + fn square_layout(&self, f: &mut Frame<'_>) { let total_size = f.size(); - let h_height = if show_shortcuts { 4 } else { 0 }; + let h_height = if self.show_shortcuts { 4 } else { 0 }; // split in 2 vertically @@ -204,44 +96,13 @@ impl Debugger { .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)].as_ref()) .split(right_pane)[..] { - if show_shortcuts { - Debugger::draw_footer(f, footer) + if self.show_shortcuts { + Self::draw_footer(f, footer) }; - Debugger::draw_src( - f, - address, - identified_contracts, - pc_ic_maps, - contracts_sources, - debug_steps[current_step].pc, - call_kind, - src_pane, - ); - Debugger::draw_op_list( - f, - address, - debug_steps, - opcode_list, - current_step, - draw_memory, - op_pane, - ); - Debugger::draw_stack( - f, - debug_steps, - current_step, - stack_pane, - stack_labels, - draw_memory, - ); - Debugger::draw_memory( - f, - debug_steps, - current_step, - memory_pane, - mem_utf, - draw_memory, - ); + self.draw_src(f, src_pane); + self.draw_op_list(f, op_pane); + self.draw_stack(f, stack_pane); + self.draw_memory(f, memory_pane); } } else { panic!("Couldn't generate horizontal split layout 1:2."); @@ -269,19 +130,9 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k f.render_widget(paragraph, area); } - #[allow(clippy::too_many_arguments)] - fn draw_src( - f: &mut Frame<'_>, - address: Address, - identified_contracts: &HashMap, - pc_ic_maps: &BTreeMap, - contracts_sources: &ContractSources, - pc: usize, - call_kind: CallKind, - area: Rect, - ) { + fn draw_src(&self, f: &mut Frame<'_>, area: Rect) { let block_source_code = Block::default() - .title(match call_kind { + .title(match self.call_kind() { CallKind::Create | CallKind::Create2 => "Contract creation", CallKind::Call => "Contract call", CallKind::StaticCall => "Contract staticcall", @@ -292,15 +143,16 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let mut text_output: Text = Text::from(""); - if let Some(contract_name) = identified_contracts.get(&address) { - if let Some(files_source_code) = contracts_sources.0.get(contract_name) { - let pc_ic_map = pc_ic_maps.get(contract_name); + let pc = self.current_step().pc; + if let Some(contract_name) = self.debugger.identified_contracts.get(self.address()) { + if let Some(files_source_code) = self.debugger.contracts_sources.0.get(contract_name) { + let pc_ic_map = self.debugger.pc_ic_maps.get(contract_name); // find the contract source with the correct source_element's file_id if let Some((source_element, source_code)) = files_source_code.iter().find_map( |(file_id, (source_code, contract_source))| { // grab either the creation source map or runtime sourcemap if let Some((Ok(source_map), ic)) = - if matches!(call_kind, CallKind::Create | CallKind::Create2) { + if matches!(self.call_kind(), CallKind::Create | CallKind::Create2) { contract_source .bytecode .source_map() @@ -573,6 +425,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k .extend(Text::from(format!("No srcmap index for contract {contract_name}"))); } } else { + let address = self.address(); text_output.extend(Text::from(format!("Unknown contract at address {address}"))); } @@ -582,25 +435,14 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } /// Draw opcode list into main component - fn draw_op_list( - f: &mut Frame<'_>, - address: Address, - debug_steps: &[DebugStep], - opcode_list: &[String], - current_step: usize, - draw_memory: &mut DrawMemory, - area: Rect, - ) { + fn draw_op_list(&self, f: &mut Frame<'_>, area: Rect) { + let step = self.current_step(); let block_source_code = Block::default() .title(format!( "Address: {} | PC: {} | Gas used in call: {}", - address, - if let Some(step) = debug_steps.get(current_step) { - step.pc.to_string() - } else { - "END".to_string() - }, - debug_steps[current_step].total_gas_used, + self.address(), + step.pc, + step.total_gas_used, )) .borders(Borders::ALL); let mut text_output: Vec = Vec::new(); @@ -611,18 +453,20 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let height = area.height as i32; let extra_top_lines = height / 2; - let prev_start = draw_memory.current_startline; + let prev_start = *self.draw_memory.current_startline.borrow(); // Absolute minimum start line let abs_min_start = 0; // Adjust for weird scrolling for max top line - let abs_max_start = (opcode_list.len() as i32 - 1) - (height / 2); + let abs_max_start = (self.opcode_list.len() as i32 - 1) - (height / 2); // actual minimum start line let mut min_start = - max(current_step as i32 - height + extra_top_lines, abs_min_start) as usize; + cmp::max(self.current_step as i32 - height + extra_top_lines, abs_min_start) as usize; // actual max start line - let mut max_start = - max(min(current_step as i32 - extra_top_lines, abs_max_start), abs_min_start) as usize; + let mut max_start = cmp::max( + cmp::min(self.current_step as i32 - extra_top_lines, abs_max_start), + abs_min_start, + ) as usize; // Sometimes, towards end of file, maximum and minim lines have swapped values. Swap if the // case @@ -637,27 +481,26 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } else { display_start = prev_start; } - draw_memory.current_startline = display_start; + *self.draw_memory.current_startline.borrow_mut() = display_start; let max_pc_len = - debug_steps.iter().fold(0, |max_val, val| val.pc.max(max_val)).to_string().len(); + self.debug_steps().iter().fold(0, |max_val, val| val.pc.max(max_val)).to_string().len(); // Define closure that prints one more line of source code let mut add_new_line = |line_number| { - let bg_color = if line_number == current_step { Color::DarkGray } else { Color::Reset }; + let is_current_step = line_number == self.current_step; + let bg_color = if is_current_step { Color::DarkGray } else { Color::Reset }; // Format line number - let line_number_format = if line_number == current_step { - let step: &DebugStep = &debug_steps[line_number]; + let line_number_format = if is_current_step { format!("{:0>max_pc_len$x}|▶", step.pc) - } else if line_number < debug_steps.len() { - let step: &DebugStep = &debug_steps[line_number]; + } else if line_number < self.debug_steps().len() { format!("{:0>max_pc_len$x}| ", step.pc) } else { "END CALL".to_string() }; - if let Some(op) = opcode_list.get(line_number) { + if let Some(op) = self.opcode_list.get(line_number) { text_output.push(Line::from(Span::styled( format!("{line_number_format}{op}"), Style::default().fg(Color::White).bg(bg_color), @@ -669,41 +512,32 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k ))); } }; - for number in display_start..opcode_list.len() { + for number in display_start..self.opcode_list.len() { add_new_line(number); } // Add one more "phantom" line so we see line where current segment execution ends - add_new_line(opcode_list.len()); + add_new_line(self.opcode_list.len()); let paragraph = Paragraph::new(text_output).block(block_source_code).wrap(Wrap { trim: true }); f.render_widget(paragraph, area); } /// Draw the stack into the stack pane - fn draw_stack( - f: &mut Frame<'_>, - debug_steps: &[DebugStep], - current_step: usize, - area: Rect, - stack_labels: bool, - draw_memory: &DrawMemory, - ) { - let stack = &debug_steps[current_step].stack; + fn draw_stack(&self, f: &mut Frame<'_>, area: Rect) { + let step = self.current_step(); + let stack = &step.stack; let stack_space = Block::default().title(format!("Stack: {}", stack.len())).borders(Borders::ALL); let min_len = usize::max(format!("{}", stack.len()).len(), 2); - let params = if let Instruction::OpCode(op) = debug_steps[current_step].instruction { - OpcodeParam::of(op) - } else { - &[] - }; + let params = + if let Instruction::OpCode(op) = step.instruction { OpcodeParam::of(op) } else { &[] }; let text: Vec = stack .iter() .rev() .enumerate() - .skip(draw_memory.current_stack_startline) + .skip(self.draw_memory.current_stack_startline) .map(|(i, stack_item)| { let param = params.iter().find(|param| param.index == i); let mut words: Vec = (0..32) @@ -725,7 +559,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k }) .collect(); - if stack_labels { + if self.stack_labels { if let Some(param) = param { words.push(Span::raw(format!("| {}", param.name))); } else { @@ -802,15 +636,9 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } /// Draw memory in memory pane - fn draw_memory( - f: &mut Frame<'_>, - debug_steps: &[DebugStep], - current_step: usize, - area: Rect, - mem_utf8: bool, - draw_mem: &DrawMemory, - ) { - let memory = &debug_steps[current_step].memory; + fn draw_memory(&self, f: &mut Frame<'_>, area: Rect) { + let step = self.current_step(); + let memory = &step.memory; let memory_space = Block::default() .title(format!("Memory (max expansion: {} bytes)", memory.len())) .borders(Borders::ALL); @@ -821,11 +649,11 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let mut offset: Option = None; let mut size: Option = None; let mut color = None; - if let Instruction::OpCode(op) = debug_steps[current_step].instruction { - let stack_len = debug_steps[current_step].stack.len(); + if let Instruction::OpCode(op) = step.instruction { + let stack_len = step.stack.len(); if stack_len > 0 { let (read_offset, read_size, write_offset, write_size) = - Debugger::get_memory_access(op, &debug_steps[current_step].stack); + Self::get_memory_access(op, &step.stack); if read_offset.is_some() { offset = read_offset; size = read_size; @@ -839,11 +667,12 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } // color word on previous write op - if current_step > 0 { - let prev_step = current_step - 1; - if let Instruction::OpCode(op) = debug_steps[prev_step].instruction { + if self.current_step > 0 { + let prev_step = self.current_step - 1; + let prev_step = &self.debug_steps()[prev_step]; + if let Instruction::OpCode(op) = prev_step.instruction { let (_, _, write_offset, write_size) = - Debugger::get_memory_access(op, &debug_steps[prev_step].stack); + Self::get_memory_access(op, &prev_step.stack); if write_offset.is_some() { offset = write_offset; size = write_size; @@ -853,12 +682,12 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k } let height = area.height as usize; - let end_line = draw_mem.current_mem_startline + height; + let end_line = self.draw_memory.current_mem_startline + height; let text: Vec = memory .chunks(32) .enumerate() - .skip(draw_mem.current_mem_startline) + .skip(self.draw_memory.current_mem_startline) .take_while(|(i, _)| i < &end_line) .map(|(i, mem_word)| { let words: Vec = mem_word @@ -893,7 +722,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k )]; spans.extend(words); - if mem_utf8 { + if self.mem_utf { let chars: Vec = mem_word .chunks(4) .map(|utf| { diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index b4cc1bf75c83c..01043fc53b547 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -9,10 +9,13 @@ use crossterm::{ use eyre::Result; use foundry_common::{compile::ContractSources, evm::Breakpoints}; use foundry_evm_core::{ - debug::DebugStep, - utils::{build_pc_ic_map, CallKind, PCICMap}, + debug::DebugNodeFlat, + utils::{build_pc_ic_map, PCICMap}, +}; +use ratatui::{ + backend::{Backend, CrosstermBackend}, + Terminal, }; -use ratatui::{backend::CrosstermBackend, Terminal}; use revm::primitives::SpecId; use std::{ collections::{BTreeMap, HashMap}, @@ -31,6 +34,8 @@ use context::DebuggerContext; mod draw; +type DebuggerTerminal = Terminal>; + /// Debugger exit reason. #[derive(Debug)] pub enum ExitReason { @@ -40,8 +45,7 @@ pub enum ExitReason { /// The TUI debugger. pub struct Debugger { - debug_arena: Vec<(Address, Vec, CallKind)>, - terminal: Terminal>, + debug_arena: Vec, identified_contracts: HashMap, /// Source map of contract sources contracts_sources: ContractSources, @@ -59,13 +63,11 @@ impl Debugger { /// Creates a new debugger. pub fn new( - debug_arena: Vec<(Address, Vec, CallKind)>, + debug_arena: Vec, identified_contracts: HashMap, contracts_sources: ContractSources, breakpoints: Breakpoints, - ) -> Result { - let backend = CrosstermBackend::new(io::stdout()); - let terminal = Terminal::new(backend)?; + ) -> Self { let pc_ic_maps = contracts_sources .0 .iter() @@ -93,14 +95,7 @@ impl Debugger { }) }) .collect(); - Ok(Self { - debug_arena, - terminal, - identified_contracts, - contracts_sources, - pc_ic_maps, - breakpoints, - }) + Self { debug_arena, identified_contracts, contracts_sources, pc_ic_maps, breakpoints } } /// Starts the debugger TUI. Terminates the current process on failure or user exit. @@ -117,19 +112,16 @@ impl Debugger { /// Starts the debugger TUI. pub fn try_run(&mut self) -> Result { - let mut guard = DebuggerGuard::setup(self)?; - let r = guard.0.try_run_real(); - // Cleanup only once. - guard.restore()?; - std::mem::forget(guard); - r + let backend = CrosstermBackend::new(io::stdout()); + let mut terminal = Terminal::new(backend)?; + TerminalGuard::with(&mut terminal, |terminal| self.try_run_real(terminal)) } #[instrument(target = "debugger", name = "run", skip_all, ret)] - fn try_run_real(&mut self) -> Result { + fn try_run_real(&mut self, terminal: &mut DebuggerTerminal) -> Result { // Create the context. let mut cx = DebuggerContext::new(self); - cx.init()?; + cx.init(); // Create an event listener in a different thread. let (tx, rx) = mpsc::channel(); @@ -138,12 +130,16 @@ impl Debugger { .spawn(move || Self::event_listener(tx)) .expect("failed to spawn thread"); + // Draw the initial state. + cx.draw(terminal)?; + + // Start the event loop. loop { match cx.handle_event(rx.recv()?) { ControlFlow::Continue(()) => {} ControlFlow::Break(reason) => return Ok(reason), } - cx.draw()?; + cx.draw(terminal)?; } } @@ -171,30 +167,34 @@ impl Debugger { } } -/// Handles terminal state. `restore` should be called before drop to handle errors. +/// Handles terminal state. #[must_use] -struct DebuggerGuard<'a>(&'a mut Debugger); - -impl<'a> DebuggerGuard<'a> { - fn setup(dbg: &'a mut Debugger) -> Result { - let this = Self(dbg); - enable_raw_mode()?; - execute!(*this.0.terminal.backend_mut(), EnterAlternateScreen, EnableMouseCapture)?; - this.0.terminal.hide_cursor()?; - Ok(this) +struct TerminalGuard<'a, B: Backend + io::Write>(&'a mut Terminal); + +impl<'a, B: Backend + io::Write> TerminalGuard<'a, B> { + fn with(terminal: &'a mut Terminal, mut f: impl FnMut(&mut Terminal) -> T) -> T { + let mut guard = Self(terminal); + guard.setup(); + f(guard.0) + } + + fn setup(&mut self) { + let _ = enable_raw_mode(); + let _ = execute!(*self.0.backend_mut(), EnterAlternateScreen, EnableMouseCapture); + let _ = self.0.hide_cursor(); + let _ = self.0.clear(); } - fn restore(&mut self) -> Result<()> { - disable_raw_mode()?; - execute!(*self.0.terminal.backend_mut(), LeaveAlternateScreen, DisableMouseCapture)?; - self.0.terminal.show_cursor()?; - Ok(()) + fn restore(&mut self) { + let _ = disable_raw_mode(); + let _ = execute!(*self.0.backend_mut(), LeaveAlternateScreen, DisableMouseCapture); + let _ = self.0.show_cursor(); } } -impl Drop for DebuggerGuard<'_> { +impl Drop for TerminalGuard<'_, B> { #[inline] fn drop(&mut self) { - let _ = self.restore(); + self.restore(); } } diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index ce2f2f03afcbf..11cd4f383eb21 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -64,7 +64,7 @@ impl DebugArena { /// - An enum denoting the type of call this is /// /// This makes it easy to pretty print the execution steps. - pub fn flatten(&self, entry: usize) -> Vec<(Address, Vec, CallKind)> { + pub fn flatten(&self, entry: usize) -> Vec { let mut flattened = Vec::new(); self.flatten_to(entry, &mut flattened); flattened @@ -73,11 +73,11 @@ impl DebugArena { /// Recursively traverses the tree of debug nodes and flattens it into the given list. /// /// See [`flatten`](Self::flatten) for more information. - pub fn flatten_to(&self, entry: usize, out: &mut Vec<(Address, Vec, CallKind)>) { + pub fn flatten_to(&self, entry: usize, out: &mut Vec) { let node = &self.arena[entry]; if !node.steps.is_empty() { - out.push((node.address, node.steps.clone(), node.kind)); + out.push(node.flat()); } for child in &node.children { @@ -86,31 +86,76 @@ impl DebugArena { } } -/// A node in the arena -#[derive(Default, Debug, Clone, Serialize, Deserialize)] +/// A node in the arena. +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct DebugNode { - /// Parent node index in the arena + /// Parent node index in the arena. pub parent: Option, - /// Children node indexes in the arena + /// Children node indexes in the arena. pub children: Vec, - /// Location in parent + /// Location in parent. pub location: usize, /// Execution context. /// /// Note that this is the address of the *code*, not necessarily the address of the storage. pub address: Address, - /// The kind of call this is + /// The kind of call this is. pub kind: CallKind, - /// Depth + /// Depth of the call. pub depth: usize, - /// The debug steps + /// The debug steps. pub steps: Vec, } +impl From for DebugNodeFlat { + #[inline] + fn from(node: DebugNode) -> Self { + node.into_flat() + } +} + +impl From<&DebugNode> for DebugNodeFlat { + #[inline] + fn from(node: &DebugNode) -> Self { + node.flat() + } +} + impl DebugNode { + /// Creates a new debug node. pub fn new(address: Address, depth: usize, steps: Vec) -> Self { Self { address, depth, steps, ..Default::default() } } + + /// Flattens this node into a [`DebugNodeFlat`]. + pub fn flat(&self) -> DebugNodeFlat { + DebugNodeFlat { address: self.address, kind: self.kind, steps: self.steps.clone() } + } + + /// Flattens this node into a [`DebugNodeFlat`]. + pub fn into_flat(self) -> DebugNodeFlat { + DebugNodeFlat { address: self.address, kind: self.kind, steps: self.steps } + } +} + +/// Flattened [`DebugNode`] from an arena. +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct DebugNodeFlat { + /// Execution context. + /// + /// Note that this is the address of the *code*, not necessarily the address of the storage. + pub address: Address, + /// The kind of call this is. + pub kind: CallKind, + /// The debug steps. + pub steps: Vec, +} + +impl DebugNodeFlat { + /// Creates a new debug node flat. + pub fn new(address: Address, kind: CallKind, steps: Vec) -> Self { + Self { address, kind, steps } + } } /// A `DebugStep` is a snapshot of the EVM's runtime state. diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index f2a8d21f14472..b44cf71d00263 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -89,7 +89,7 @@ impl ScriptArgs { .decoder(&decoder) .sources(sources) .breakpoints(result.breakpoints.clone()) - .build()?; + .build(); debugger.try_run()?; } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index e9e822214974a..cb32bed9c50b0 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -321,7 +321,7 @@ impl TestArgs { .decoders(&decoders) .sources(sources) .breakpoints(result.breakpoints) - .build()?; + .build(); debugger.try_run()?; } From 13af418e724e141ae7dfa7957476d691eee7d0e9 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 4 Dec 2023 19:13:41 -0400 Subject: [PATCH 0375/1963] fix(`forge`): pre-emptively create `lib` dir if it doesn't exist for updating submodules (#6521) * fix(forge): pre-emptively create lib dir if it doesn't exist for updating submodules * chore: only run submodule update if the dir is not empty * chore: revert to prev behavior * chore: add extra check for .gitmodules * chore: remove useless checks * fix: only update submodules if there are any * fix: only search for top git repo if its being used * relax error and add test --------- Co-authored-by: Matthias Seitz --- crates/cli/src/utils/mod.rs | 13 +++++++++++++ crates/forge/bin/cmd/install.rs | 20 +++++++++++++++++--- crates/forge/tests/cli/cmd.rs | 17 +++++++++++++++++ crates/test-utils/src/util.rs | 25 +++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 8a0e51ad9b78d..425732de95e6c 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -540,6 +540,19 @@ https://github.com/foundry-rs/foundry/issues/new/choose" .map(|stdout| stdout.lines().any(|line| line.starts_with('-'))) } + /// Returns true if the given path has no submodules by checking `git submodule status` + pub fn has_submodules(self, paths: I) -> Result + where + I: IntoIterator, + S: AsRef, + { + self.cmd() + .args(["submodule", "status"]) + .args(paths) + .get_stdout_lossy() + .map(|stdout| stdout.trim().lines().next().is_some()) + } + pub fn submodule_add( self, force: bool, diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index d01fe97940621..270e8c97ce4e2 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -124,10 +124,24 @@ impl DependencyInstallOpts { let libs = git.root.join(install_lib_dir); if dependencies.is_empty() && !self.no_git { - p_println!(!self.quiet => "Updating dependencies in {}", libs.display()); - // recursively fetch all submodules (without fetching latest) - git.submodule_update(false, false, false, true, Some(&libs))?; + // Use the root of the git repository to look for submodules. + let root = Git::root_of(git.root)?; + match git.has_submodules(Some(&root)) { + Ok(true) => { + p_println!(!quiet => "Updating dependencies in {}", libs.display()); + // recursively fetch all submodules (without fetching latest) + git.submodule_update(false, false, false, true, Some(&libs))?; + } + + Err(err) => { + warn!(?err, "Failed to check for submodules"); + } + _ => { + // no submodules, nothing to do + } + } } + fs::create_dir_all(&libs)?; let installer = Installer { git, no_commit }; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index b43617078fa85..5e8283f2785a3 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -895,6 +895,23 @@ forgetest!(can_install_and_remove, |prj, cmd| { remove(&mut cmd, "lib/forge-std"); }); +// test to check we can run `forge install` in an empty dir +forgetest!(can_install_empty, |prj, cmd| { + // create + cmd.git_init(); + cmd.forge_fuse().args(["install"]); + cmd.assert_empty_stdout(); + + // create initial commit + fs::write(prj.root().join("README.md"), "Initial commit").unwrap(); + + cmd.git_add().unwrap(); + cmd.git_commit("Initial commit").unwrap(); + + cmd.forge_fuse().args(["install"]); + cmd.assert_empty_stdout(); +}); + // test to check that package can be reinstalled after manually removing the directory forgetest!(can_reinstall_after_manual_remove, |prj, cmd| { cmd.git_init(); diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 6a879378acdf7..9f5e541b1325a 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -680,6 +680,31 @@ impl TestCommand { output } + /// Returns a new [Command] that is inside the current project dir + pub fn cmd_in_current_dir(&self, program: &str) -> Command { + let mut cmd = Command::new(program); + cmd.current_dir(self.project.root()); + cmd + } + + /// Runs `git add .` inside the project's dir + #[track_caller] + pub fn git_add(&self) -> Result<()> { + let mut cmd = self.cmd_in_current_dir("git"); + cmd.arg("add").arg("."); + let output = cmd.output()?; + self.ensure_success(&output) + } + + /// Runs `git commit .` inside the project's dir + #[track_caller] + pub fn git_commit(&self, msg: &str) -> Result<()> { + let mut cmd = self.cmd_in_current_dir("git"); + cmd.arg("commit").arg("-m").arg(msg); + let output = cmd.output()?; + self.ensure_success(&output) + } + /// Executes the command and returns the `(stdout, stderr)` of the output as lossy `String`s. /// /// Expects the command to be successful. From dcf25ffa1f96869095c07676f7924a9208ddfdde Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 5 Dec 2023 18:48:16 +0100 Subject: [PATCH 0376/1963] chore: skip is verified check for script deployments (#6523) --- crates/forge/bin/cmd/create.rs | 2 +- crates/forge/bin/cmd/script/verify.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 8f1787671cb22..580c23fe4cb98 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -185,7 +185,7 @@ impl CreateArgs { }, flatten: false, force: false, - skip_is_verified_check: false, + skip_is_verified_check: true, watch: true, retry: self.retry, libraries: vec![], diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 4c0205fcfc34a..1837b5fd64be6 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -103,7 +103,7 @@ impl VerifyBundle { etherscan: self.etherscan.clone(), flatten: false, force: false, - skip_is_verified_check: false, + skip_is_verified_check: true, watch: true, retry: self.retry, libraries: libraries.to_vec(), From 9093207ce676979638599873be18aa5ca0ea5f92 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 6 Dec 2023 00:38:49 +0400 Subject: [PATCH 0377/1963] Fix (#6526) --- crates/evm/traces/src/decoder/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 3c4c1d766212e..87d813ec3d488 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -410,7 +410,7 @@ impl CallTraceDecoder { s = funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)); } - if s.is_some() { + if s.is_none() { if let Some(values) = funcs.iter().find_map(|func| func.abi_decode_output(data, false).ok()) { From fdad9fb0dde45d3476fc5d1fe6f40e8dc7c17caa Mon Sep 17 00:00:00 2001 From: Inphi Date: Tue, 5 Dec 2023 17:56:19 -0500 Subject: [PATCH 0378/1963] fix(cheatcodes): recorded created account during broadcast (#6527) Ensure that the appropriate caller is used to compute the deployed address during a CREATE/CREATE2 operation. As such, during broadcast, the configured wallet address is used rather than the current EVM caller. --- crates/cheatcodes/src/inspector.rs | 7 ++++--- testdata/cheats/RecordAccountAccesses.t.sol | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 2eef1975502b1..b154955330aff 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1102,9 +1102,6 @@ impl Inspector for Cheatcodes { ) -> (InstructionResult, Option
, Gas, Bytes) { let gas = Gas::new(call.gas_limit); - // allow cheatcodes from the address of the new contract - let address = self.allow_cheatcodes_on_create(data, call); - // Apply our prank if let Some(prank) = &self.prank { if data.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { @@ -1171,6 +1168,10 @@ impl Inspector for Cheatcodes { } } + // allow cheatcodes from the address of the new contract + // Compute the address *after* any possible broadcast updates, so it's based on the updated + // call inputs + let address = self.allow_cheatcodes_on_create(data, call); // If `recordAccountAccesses` has been called, record the create if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { // Record the create context as an account access and create a new vector to record all diff --git a/testdata/cheats/RecordAccountAccesses.t.sol b/testdata/cheats/RecordAccountAccesses.t.sol index e27c2dd0c5f1c..4ab707edbfac0 100644 --- a/testdata/cheats/RecordAccountAccesses.t.sol +++ b/testdata/cheats/RecordAccountAccesses.t.sol @@ -1085,6 +1085,20 @@ contract RecordAccountAccessesTest is DSTest { ); } + /// @notice Asserts interaction between broadcast and recording cheatcodes + function testIssue6514() public { + cheats.startStateDiffRecording(); + cheats.startBroadcast(); + + StorageAccessor a = new StorageAccessor(); + + cheats.stopBroadcast(); + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 1, "incorrect length"); + assertEq(toUint(called[0].kind), toUint(Vm.AccountAccessKind.Create)); + assertEq(called[0].account, address(a)); + } + function startRecordingFromLowerDepth() external { cheats.startStateDiffRecording(); assembly { From 5a4daafb51b6d764addacf0a5c3ed7c07747f66b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 6 Dec 2023 20:23:22 +0100 Subject: [PATCH 0379/1963] fix: don't reinitialize created accounts (#6534) --- crates/evm/core/src/backend/mod.rs | 26 +++++++++++++--- crates/forge/tests/it/repros.rs | 6 +++- testdata/repros/Issue6032.t.sol | 48 ++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 testdata/repros/Issue6032.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 8cc10795f3a0f..c0ffdfd8f6135 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -777,6 +777,13 @@ impl Backend { self.inner.precompiles().contains(addr) } + /// Sets the initial journaled state to use when initializing forks + #[inline] + fn set_init_journaled_state(&mut self, journaled_state: JournaledState) { + trace!("recording fork init journaled_state"); + self.fork_init_journaled_state = journaled_state; + } + /// Cleans up already loaded accounts that would be initialized without the correct data from /// the fork. /// @@ -800,10 +807,21 @@ impl Backend { let mut journaled_state = self.fork_init_journaled_state.clone(); for loaded_account in loaded_accounts.iter().copied() { trace!(?loaded_account, "replacing account on init"); - let fork_account = Database::basic(&mut fork.db, loaded_account)? - .ok_or(DatabaseError::MissingAccount(loaded_account))?; let init_account = journaled_state.state.get_mut(&loaded_account).expect("exists; qed"); + + // here's an edge case where we need to check if this account has been created, in + // which case we don't need to replace it with the account from the fork because the + // created account takes precedence: for example contract creation in setups + if init_account.is_created() { + trace!(?loaded_account, "skipping created account"); + continue + } + + // otherwise we need to replace the account's info with the one from the fork's + // database + let fork_account = Database::basic(&mut fork.db, loaded_account)? + .ok_or(DatabaseError::MissingAccount(loaded_account))?; init_account.info = fork_account; } fork.journaled_state = journaled_state; @@ -1043,8 +1061,8 @@ impl DatabaseExt for Backend { // different forks. Since the `JournaledState` is valid for all forks until the // first fork is selected, we need to update it for all forks and use it as init state // for all future forks - trace!("recording fork init journaled_state"); - self.fork_init_journaled_state = active_journaled_state.clone(); + + self.set_init_journaled_state(active_journaled_state.clone()); self.prepare_init_journal_state()?; // Make sure that the next created fork has a depth of 0. diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 36ee48d390d30..f07b1dcb5c412 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -43,7 +43,8 @@ async fn repro_config(issue: usize, should_fail: bool, sender: Option
) let filter = Filter::path(&format!(".*repros/Issue{issue}.t.sol")); let mut config = Config::with_root(PROJECT.root()); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + config.fs_permissions = + FsPermissions::new(vec![PathPermission::read("./fixtures"), PathPermission::read("out")]); if let Some(sender) = sender { config.sender = sender; } @@ -190,6 +191,9 @@ test_repro!(5948); // https://github.com/foundry-rs/foundry/issues/6006 test_repro!(6006); +// https://github.com/foundry-rs/foundry/issues/6032 +test_repro!(6032); + // https://github.com/foundry-rs/foundry/issues/6070 test_repro!(6070); diff --git a/testdata/repros/Issue6032.t.sol b/testdata/repros/Issue6032.t.sol new file mode 100644 index 0000000000000..c9f82f209d51d --- /dev/null +++ b/testdata/repros/Issue6032.t.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6032 +contract Issue6032Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testEtchFork() public { + // Deploy initial contract + Counter counter = new Counter(); + counter.setNumber(42); + + address counterAddress = address(counter); + // Enter the fork + vm.createSelectFork("rpcAlias"); + assert(counterAddress.code.length > 0); + // `Counter` is not deployed on the fork, which is expected. + + // Etch the contract into the fork. + bytes memory code = vm.getDeployedCode("Issue6032.t.sol:CounterEtched"); + vm.etch(counterAddress, code); + // `Counter` is now deployed on the fork. + assert(counterAddress.code.length > 0); + + // Now we can etch the code, but state will remain. + CounterEtched counterEtched = CounterEtched(counterAddress); + assertEq(counterEtched.numberHalf(), 21); + } +} + +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } +} + +contract CounterEtched { + uint256 public number; + + function numberHalf() public view returns (uint256) { + return number / 2; + } +} From bacacceb97da35ccd03b955aab2a6642ccfedd37 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:51:59 +0100 Subject: [PATCH 0380/1963] refactor(debugger): rewrite draw code (#6522) * chore: enable unreachable_pub * chore: use Debugger::builder() * test: add a simple debuggable test * refactor: use let-else to reduce indentation * fix: debugger panic handler * test: update debugger test * fix: solc artifact absolute path * refactor: src_text * refactor: add a wrapper for source lines * feat: minimum terminal size * refactor: rest of the draw functions * chore: explain panic hook * chore: remove whitespace hack * chore: clippy --- .cargo/config.toml | 15 +- Cargo.lock | 1 + crates/cli/src/utils/cmd.rs | 4 +- crates/debugger/Cargo.toml | 3 +- crates/debugger/src/lib.rs | 2 +- crates/debugger/src/op.rs | 8 +- crates/debugger/src/tui/draw.rs | 1109 ++++++++++++------------- crates/debugger/src/tui/mod.rs | 46 +- crates/forge/bin/cmd/script/build.rs | 9 +- crates/forge/bin/cmd/script/cmd.rs | 4 +- crates/forge/bin/cmd/test/mod.rs | 7 +- crates/forge/tests/cli/debug.rs | 94 +++ crates/forge/tests/cli/main.rs | 1 + crates/forge/tests/it/cheats.rs | 2 +- crates/forge/tests/it/config.rs | 4 +- crates/forge/tests/it/core.rs | 2 +- crates/forge/tests/it/fork.rs | 2 +- crates/forge/tests/it/fs.rs | 2 +- crates/forge/tests/it/fuzz.rs | 2 +- crates/forge/tests/it/inline.rs | 2 + crates/forge/tests/it/invariant.rs | 2 +- crates/forge/tests/it/spec.rs | 2 + crates/forge/tests/it/test_helpers.rs | 2 + 23 files changed, 711 insertions(+), 614 deletions(-) create mode 100644 crates/forge/tests/cli/debug.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 45bca53ae5eb9..76cf725f9e2e2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,16 +1,11 @@ [alias] cheats = "test -p foundry-cheatcodes-spec --features schema tests::" +test-debugger = "test -p forge --test cli manual_debug_setup -- --include-ignored --nocapture" +# Increase the stack size to 10MB for Windows targets, which is in line with Linux +# (whereas default for Windows is 1MB). [target.x86_64-pc-windows-msvc] -rustflags = [ - # Increases the stack size to 10MB, which is - # in line with Linux (whereas default for Windows is 1MB) - "-Clink-arg=/STACK:10000000", -] +rustflags = ["-Clink-arg=/STACK:10000000"] [target.i686-pc-windows-msvc] -rustflags = [ - # Increases the stack size to 10MB, which is - # in line with Linux (whereas default for Windows is 1MB) - "-Clink-arg=/STACK:10000000", -] +rustflags = ["-Clink-arg=/STACK:10000000"] diff --git a/Cargo.lock b/Cargo.lock index 8e89b6a51bc56..10914dff0b4de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2839,6 +2839,7 @@ dependencies = [ "crossterm", "eyre", "foundry-common", + "foundry-compilers", "foundry-evm-core", "foundry-evm-traces", "ratatui", diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 910e137fce2a9..e0e11d21a51fc 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -10,7 +10,7 @@ use foundry_compilers::{ Artifact, ProjectCompileOutput, }; use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, NamedChain}; -use foundry_debugger::DebuggerBuilder; +use foundry_debugger::Debugger; use foundry_evm::{ debug::DebugArena, executors::{DeployResult, EvmError, ExecutionErr, RawCallResult}, @@ -404,7 +404,7 @@ pub async fn handle_traces( if debug { let sources = etherscan_identifier.get_compiled_contracts().await?; - let mut debugger = DebuggerBuilder::new() + let mut debugger = Debugger::builder() .debug_arena(&result.debug) .decoder(&decoder) .sources(sources) diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index fa67b59294c80..a350d34b2cb00 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -10,9 +10,10 @@ homepage.workspace = true repository.workspace = true [dependencies] +foundry-common.workspace = true +foundry-compilers.workspace = true foundry-evm-core.workspace = true foundry-evm-traces.workspace = true -foundry-common.workspace = true alloy-primitives.workspace = true diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index a50a73660fd76..5683cb8a5b7c4 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -2,7 +2,7 @@ //! //! Interactive Solidity TUI debugger. -#![warn(unused_crate_dependencies)] +#![warn(unused_crate_dependencies, unreachable_pub)] #[macro_use] extern crate tracing; diff --git a/crates/debugger/src/op.rs b/crates/debugger/src/op.rs index a6755483678aa..486fbe09fbeb0 100644 --- a/crates/debugger/src/op.rs +++ b/crates/debugger/src/op.rs @@ -1,16 +1,16 @@ /// Named parameter of an EVM opcode. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub struct OpcodeParam { +pub(crate) struct OpcodeParam { /// The name of the parameter. - pub name: &'static str, + pub(crate) name: &'static str, /// The index of the parameter on the stack. This is relative to the top of the stack. - pub index: usize, + pub(crate) index: usize, } impl OpcodeParam { /// Returns the list of named parameters for the given opcode. #[inline] - pub fn of(op: u8) -> &'static [Self] { + pub(crate) fn of(op: u8) -> &'static [Self] { MAP[op as usize] } } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 50f66a05b0a0d..84e56ffe1e120 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -3,6 +3,7 @@ use super::context::DebuggerContext; use crate::op::OpcodeParam; use alloy_primitives::U256; +use foundry_compilers::sourcemap::SourceElement; use foundry_evm_core::{debug::Instruction, utils::CallKind}; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, @@ -12,7 +13,7 @@ use ratatui::{ widgets::{Block, Borders, Paragraph, Wrap}, }; use revm::interpreter::opcode; -use std::{cmp, collections::VecDeque, io}; +use std::{cmp, collections::VecDeque, fmt::Write, io}; impl DebuggerContext<'_> { /// Draws the TUI layout and subcomponents to the given terminal. @@ -20,440 +21,345 @@ impl DebuggerContext<'_> { terminal.draw(|f| self.draw_layout(f)).map(drop) } + #[inline] fn draw_layout(&self, f: &mut Frame<'_>) { - if f.size().width < 225 { - self.vertical_layout(f); + // We need 100 columns to display a 32 byte word in the memory and stack panes. + let size = f.size(); + let min_width = 100; + let min_height = 16; + if size.width < min_width || size.height < min_height { + self.size_too_small(f, min_width, min_height); + return; + } + + // The horizontal layout draws these panes at 50% width. + let min_column_width_for_horizontal = 200; + if size.width >= min_column_width_for_horizontal { + self.horizontal_layout(f); } else { - self.square_layout(f); + self.vertical_layout(f); } } + fn size_too_small(&self, f: &mut Frame<'_>, min_width: u16, min_height: u16) { + let mut lines = Vec::with_capacity(4); + + let l1 = "Terminal size too small:"; + lines.push(Line::from(l1)); + + let size = f.size(); + let width_color = if size.width >= min_width { Color::Green } else { Color::Red }; + let height_color = if size.height >= min_height { Color::Green } else { Color::Red }; + let l2 = vec![ + Span::raw("Width = "), + Span::styled(size.width.to_string(), Style::new().fg(width_color)), + Span::raw(" Height = "), + Span::styled(size.height.to_string(), Style::new().fg(height_color)), + ]; + lines.push(Line::from(l2)); + + let l3 = "Needed for current config:"; + lines.push(Line::from(l3)); + let l4 = format!("Width = {min_width} Height = {min_height}"); + lines.push(Line::from(l4)); + + let paragraph = + Paragraph::new(lines).alignment(Alignment::Center).wrap(Wrap { trim: true }); + f.render_widget(paragraph, size) + } + + /// Draws the layout in vertical mode. + /// + /// ```text + /// |-----------------------------| + /// | op | + /// |-----------------------------| + /// | stack | + /// |-----------------------------| + /// | mem | + /// |-----------------------------| + /// | | + /// | src | + /// | | + /// |-----------------------------| + /// ``` fn vertical_layout(&self, f: &mut Frame<'_>) { - let total_size = f.size(); + let area = f.size(); let h_height = if self.show_shortcuts { 4 } else { 0 }; - if let [app, footer] = Layout::default() - .constraints( - [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)].as_ref(), - ) + // NOTE: `Layout::split` always returns a slice of the same length as the number of + // constraints, so the `else` branch is unreachable. + + // Split off footer. + let [app, footer] = Layout::new() + .constraints([Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)]) .direction(Direction::Vertical) - .split(total_size)[..] - { - if let [op_pane, stack_pane, memory_pane, src_pane] = Layout::default() - .direction(Direction::Vertical) - .constraints( - [ - Constraint::Ratio(1, 6), - Constraint::Ratio(1, 6), - Constraint::Ratio(1, 6), - Constraint::Ratio(3, 6), - ] - .as_ref(), - ) - .split(app)[..] - { - if self.show_shortcuts { - Self::draw_footer(f, footer); - } - self.draw_src(f, src_pane); - self.draw_op_list(f, op_pane); - self.draw_stack(f, stack_pane); - self.draw_memory(f, memory_pane); - } else { - panic!("unable to create vertical panes") - } - } else { - panic!("unable to create footer / app") + .split(area)[..] + else { + unreachable!() }; + + // Split the app in 4 vertically to construct all the panes. + let [op_pane, stack_pane, memory_pane, src_pane] = Layout::new() + .direction(Direction::Vertical) + .constraints([ + Constraint::Ratio(1, 6), + Constraint::Ratio(1, 6), + Constraint::Ratio(1, 6), + Constraint::Ratio(3, 6), + ]) + .split(app)[..] + else { + unreachable!() + }; + + if self.show_shortcuts { + self.draw_footer(f, footer); + } + self.draw_src(f, src_pane); + self.draw_op_list(f, op_pane); + self.draw_stack(f, stack_pane); + self.draw_memory(f, memory_pane); } - fn square_layout(&self, f: &mut Frame<'_>) { - let total_size = f.size(); + /// Draws the layout in horizontal mode. + /// + /// ```text + /// |-----------------|-----------| + /// | op | stack | + /// |-----------------|-----------| + /// | | | + /// | src | mem | + /// | | | + /// |-----------------|-----------| + /// ``` + fn horizontal_layout(&self, f: &mut Frame<'_>) { + let area = f.size(); let h_height = if self.show_shortcuts { 4 } else { 0 }; - // split in 2 vertically - - if let [app, footer] = Layout::default() + // Split off footer. + let [app, footer] = Layout::new() .direction(Direction::Vertical) - .constraints( - [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)].as_ref(), - ) - .split(total_size)[..] - { - if let [left_pane, right_pane] = Layout::default() - .direction(Direction::Horizontal) - .constraints([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)].as_ref()) - .split(app)[..] - { - // split right pane horizontally to construct stack and memory - if let [op_pane, src_pane] = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)].as_ref()) - .split(left_pane)[..] - { - if let [stack_pane, memory_pane] = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)].as_ref()) - .split(right_pane)[..] - { - if self.show_shortcuts { - Self::draw_footer(f, footer) - }; - self.draw_src(f, src_pane); - self.draw_op_list(f, op_pane); - self.draw_stack(f, stack_pane); - self.draw_memory(f, memory_pane); - } - } else { - panic!("Couldn't generate horizontal split layout 1:2."); - } - } else { - panic!("Couldn't generate vertical split layout 1:2."); - } - } else { - panic!("Couldn't generate application & footer") - } - } + .constraints([Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)]) + .split(area)[..] + else { + unreachable!() + }; - fn draw_footer(f: &mut Frame<'_>, area: Rect) { - let block_controls = Block::default(); + // Split app in 2 horizontally. + let [app_left, app_right] = Layout::new() + .direction(Direction::Horizontal) + .constraints([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)]) + .split(app)[..] + else { + unreachable!() + }; + + // Split left pane in 2 vertically to opcode list and source. + let [op_pane, src_pane] = Layout::new() + .direction(Direction::Vertical) + .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)]) + .split(app_left)[..] + else { + unreachable!() + }; - let text_output = vec![Line::from(Span::styled( - "[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end", Style::default().add_modifier(Modifier::DIM))), -Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | [']: goto breakpoint | [h] toggle help", Style::default().add_modifier(Modifier::DIM)))]; + // Split right pane horizontally to construct stack and memory. + let [stack_pane, memory_pane] = Layout::new() + .direction(Direction::Vertical) + .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)]) + .split(app_right)[..] + else { + unreachable!() + }; - let paragraph = Paragraph::new(text_output) - .block(block_controls) - .alignment(Alignment::Center) - .wrap(Wrap { trim: false }); + if self.show_shortcuts { + self.draw_footer(f, footer); + } + self.draw_src(f, src_pane); + self.draw_op_list(f, op_pane); + self.draw_stack(f, stack_pane); + self.draw_memory(f, memory_pane); + } + fn draw_footer(&self, f: &mut Frame<'_>, area: Rect) { + let l1 = "[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end"; + let l2 = "[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | [']: goto breakpoint | [h] toggle help"; + let dimmed = Style::new().add_modifier(Modifier::DIM); + let lines = + vec![Line::from(Span::styled(l1, dimmed)), Line::from(Span::styled(l2, dimmed))]; + let paragraph = + Paragraph::new(lines).alignment(Alignment::Center).wrap(Wrap { trim: false }); f.render_widget(paragraph, area); } fn draw_src(&self, f: &mut Frame<'_>, area: Rect) { - let block_source_code = Block::default() - .title(match self.call_kind() { - CallKind::Create | CallKind::Create2 => "Contract creation", - CallKind::Call => "Contract call", - CallKind::StaticCall => "Contract staticcall", - CallKind::CallCode => "Contract callcode", - CallKind::DelegateCall => "Contract delegatecall", - }) - .borders(Borders::ALL); + let text_output = self.src_text(area); + let title = match self.call_kind() { + CallKind::Create | CallKind::Create2 => "Contract creation", + CallKind::Call => "Contract call", + CallKind::StaticCall => "Contract staticcall", + CallKind::CallCode => "Contract callcode", + CallKind::DelegateCall => "Contract delegatecall", + }; + let block = Block::default().title(title).borders(Borders::ALL); + let paragraph = Paragraph::new(text_output).block(block).wrap(Wrap { trim: false }); + f.render_widget(paragraph, area); + } - let mut text_output: Text = Text::from(""); + fn src_text(&self, area: Rect) -> Text<'_> { + let (source_element, source_code) = match self.src_map() { + Ok(r) => r, + Err(e) => return Text::from(e), + }; - let pc = self.current_step().pc; - if let Some(contract_name) = self.debugger.identified_contracts.get(self.address()) { - if let Some(files_source_code) = self.debugger.contracts_sources.0.get(contract_name) { - let pc_ic_map = self.debugger.pc_ic_maps.get(contract_name); - // find the contract source with the correct source_element's file_id - if let Some((source_element, source_code)) = files_source_code.iter().find_map( - |(file_id, (source_code, contract_source))| { - // grab either the creation source map or runtime sourcemap - if let Some((Ok(source_map), ic)) = - if matches!(self.call_kind(), CallKind::Create | CallKind::Create2) { - contract_source - .bytecode - .source_map() - .zip(pc_ic_map.and_then(|(c, _)| c.get(&pc))) - } else { - contract_source - .deployed_bytecode - .bytecode - .as_ref() - .expect("no bytecode") - .source_map() - .zip(pc_ic_map.and_then(|(_, r)| r.get(&pc))) - } - { - let source_element = source_map[*ic].clone(); - if let Some(index) = source_element.index { - if *file_id == index { - Some((source_element, source_code)) - } else { - None - } - } else { - None - } - } else { - None - } - }, - ) { - // we are handed a vector of SourceElements that give - // us a span of sourcecode that is currently being executed - // This includes an offset and length. This vector is in - // instruction pointer order, meaning the location of - // the instruction - sum(push_bytes[..pc]) - let offset = source_element.offset; - let len = source_element.length; - let max = source_code.len(); - - // split source into before, relevant, and after chunks - // split by line as well to do some formatting stuff - let mut before = source_code[..std::cmp::min(offset, max)] - .split_inclusive('\n') - .collect::>(); - let actual = source_code - [std::cmp::min(offset, max)..std::cmp::min(offset + len, max)] - .split_inclusive('\n') - .map(|s| s.to_string()) - .collect::>(); - let mut after = source_code[std::cmp::min(offset + len, max)..] - .split_inclusive('\n') - .collect::>(); - - let mut line_number = 0; - - let num_lines = before.len() + actual.len() + after.len(); - let height = area.height as usize; - let needed_highlight = actual.len(); - let mid_len = before.len() + actual.len(); - - // adjust what text we show of the source code - let (start_line, end_line) = if needed_highlight > height { - // highlighted section is more lines than we have avail - (before.len(), before.len() + needed_highlight) - } else if height > num_lines { - // we can fit entire source - (0, num_lines) - } else { - let remaining = height - needed_highlight; - let mut above = remaining / 2; - let mut below = remaining / 2; - if below > after.len() { - // unused space below the highlight - above += below - after.len(); - } else if above > before.len() { - // we have unused space above the highlight - below += above - before.len(); - } else { - // no unused space - } + // We are handed a vector of SourceElements that give us a span of sourcecode that is + // currently being executed. This includes an offset and length. + // This vector is in instruction pointer order, meaning the location of the instruction + // minus `sum(push_bytes[..pc])`. + let offset = source_element.offset; + let len = source_element.length; + let max = source_code.len(); - (before.len().saturating_sub(above), mid_len + below) - }; - - let max_line_num = num_lines.to_string().len(); - // We check if there is other text on the same line before the - // highlight starts - if let Some(last) = before.pop() { - if !last.ends_with('\n') { - before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default().fg(Color::Gray).bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default().add_modifier(Modifier::DIM), - ), - ])); - line_number += 1; - }); - - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::raw(last), - Span::styled( - actual[0].to_string(), - Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - - actual.iter().skip(1).for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - // this is a hack to add coloring - // because tui does weird trimming - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } else { - before.push(last); - before.iter().skip(start_line).for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default().fg(Color::Gray).bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default().add_modifier(Modifier::DIM), - ), - ])); - - line_number += 1; - }); - actual.iter().for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default() - .fg(Color::Cyan) - .add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } - } else { - actual.iter().for_each(|s| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default() - .fg(Color::Cyan) - .bg(Color::DarkGray) - .add_modifier(Modifier::BOLD), - ), - Span::raw("\u{2800} "), - Span::styled( - if s.is_empty() || s == "\n" { - "\u{2800} \n".to_string() - } else { - s.to_string() - }, - Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD), - ), - ])); - line_number += 1; - }); - } + // Split source into before, relevant, and after chunks, split by line, for formatting. + let actual_start = offset.min(max); + let actual_end = (offset + len).min(max); - // fill in the rest of the line as unhighlighted - if let Some(last) = actual.last() { - if !last.ends_with('\n') { - if let Some(post) = after.pop_front() { - if let Some(last) = text_output.lines.last_mut() { - last.spans.push(Span::raw(post)); - } - } - } - } + let mut before: Vec<_> = source_code[..actual_start].split_inclusive('\n').collect(); + let actual: Vec<_> = source_code[actual_start..actual_end].split_inclusive('\n').collect(); + let mut after: VecDeque<_> = source_code[actual_end..].split_inclusive('\n').collect(); - // add after highlighted text - while mid_len + after.len() > end_line { - after.pop_back(); - } - after.iter().for_each(|line| { - text_output.lines.push(Line::from(vec![ - Span::styled( - format!( - "{: >max_line_num$}", - line_number.to_string(), - max_line_num = max_line_num - ), - Style::default().fg(Color::Gray).bg(Color::DarkGray), - ), - Span::styled( - "\u{2800} ".to_string() + line, - Style::default().add_modifier(Modifier::DIM), - ), - ])); - line_number += 1; - }); - } else { - text_output.extend(Text::from("No sourcemap for contract")); - } + let num_lines = before.len() + actual.len() + after.len(); + let height = area.height as usize; + let needed_highlight = actual.len(); + let mid_len = before.len() + actual.len(); + + // adjust what text we show of the source code + let (start_line, end_line) = if needed_highlight > height { + // highlighted section is more lines than we have avail + (before.len(), before.len() + needed_highlight) + } else if height > num_lines { + // we can fit entire source + (0, num_lines) + } else { + let remaining = height - needed_highlight; + let mut above = remaining / 2; + let mut below = remaining / 2; + if below > after.len() { + // unused space below the highlight + above += below - after.len(); + } else if above > before.len() { + // we have unused space above the highlight + below += above - before.len(); + } else { + // no unused space + } + + (before.len().saturating_sub(above), mid_len + below) + }; + + // Unhighlighted line number: gray. + let u_num = Style::new().fg(Color::Gray); + // Unhighlighted text: default, dimmed. + let u_text = Style::new().add_modifier(Modifier::DIM); + // Highlighted line number: cyan. + let h_num = Style::new().fg(Color::Cyan); + // Highlighted text: cyan, bold. + let h_text = Style::new().fg(Color::Cyan).add_modifier(Modifier::BOLD); + + let mut lines = SourceLines::new(decimal_digits(num_lines)); + + // We check if there is other text on the same line before the highlight starts. + if let Some(last) = before.pop() { + let last_has_nl = last.ends_with('\n'); + + if last_has_nl { + before.push(last); + } + for line in &before[start_line..] { + lines.push(u_num, line, u_text); + } + + let first = if !last_has_nl { + lines.push_raw(h_num, &[Span::raw(last), Span::styled(actual[0], h_text)]); + 1 } else { - text_output - .extend(Text::from(format!("No srcmap index for contract {contract_name}"))); + 0 + }; + + // Skip the first line if it has already been handled above. + for line in &actual[first..] { + lines.push(h_num, line, h_text); } } else { - let address = self.address(); - text_output.extend(Text::from(format!("Unknown contract at address {address}"))); + // No text before the current line. + for line in &actual { + lines.push(h_num, line, h_text); + } } - let paragraph = - Paragraph::new(text_output).block(block_source_code).wrap(Wrap { trim: false }); - f.render_widget(paragraph, area); + // Fill in the rest of the line as unhighlighted. + if let Some(last) = actual.last() { + if !last.ends_with('\n') { + if let Some(post) = after.pop_front() { + if let Some(last) = lines.lines.last_mut() { + last.spans.push(Span::raw(post)); + } + } + } + } + + // Add after highlighted text. + while mid_len + after.len() > end_line { + after.pop_back(); + } + for line in after { + lines.push(u_num, line, u_text); + } + + Text::from(lines.lines) } - /// Draw opcode list into main component - fn draw_op_list(&self, f: &mut Frame<'_>, area: Rect) { - let step = self.current_step(); - let block_source_code = Block::default() - .title(format!( - "Address: {} | PC: {} | Gas used in call: {}", - self.address(), - step.pc, - step.total_gas_used, - )) - .borders(Borders::ALL); - let mut text_output: Vec = Vec::new(); - - // Scroll: - // Focused line is line that should always be at the center of the screen. - let display_start; + fn src_map(&self) -> Result<(SourceElement, &str), String> { + let address = self.address(); + let Some(contract_name) = self.debugger.identified_contracts.get(address) else { + return Err(format!("Unknown contract at address {address}")); + }; + let Some(files_source_code) = self.debugger.contracts_sources.0.get(contract_name) else { + return Err(format!("No source map index for contract {contract_name}")); + }; + + let Some((create_map, rt_map)) = self.debugger.pc_ic_maps.get(contract_name) else { + return Err(format!("No PC-IC maps for contract {contract_name}")); + }; + + let is_create = matches!(self.call_kind(), CallKind::Create | CallKind::Create2); + let pc = self.current_step().pc; + let Some((source_element, source_code)) = + files_source_code.iter().find_map(|(file_id, (source_code, contract_source))| { + let bytecode = if is_create { + &contract_source.bytecode + } else { + contract_source.deployed_bytecode.bytecode.as_ref()? + }; + let mut source_map = bytecode.source_map()?.ok()?; + + let pc_ic_map = if is_create { create_map } else { rt_map }; + let ic = pc_ic_map.get(&pc)?; + let source_element = source_map.swap_remove(*ic); + (*file_id == source_element.index?).then_some((source_element, source_code)) + }) + else { + return Err(format!("No source map for contract {contract_name}")); + }; + + Ok((source_element, source_code)) + } + + fn draw_op_list(&self, f: &mut Frame<'_>, area: Rect) { let height = area.height as i32; let extra_top_lines = height / 2; - let prev_start = *self.draw_memory.current_startline.borrow(); // Absolute minimum start line let abs_min_start = 0; // Adjust for weird scrolling for max top line @@ -474,61 +380,58 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k std::mem::swap(&mut min_start, &mut max_start); } - if prev_start < min_start { - display_start = min_start; - } else if prev_start > max_start { - display_start = max_start; - } else { - display_start = prev_start; - } + let prev_start = *self.draw_memory.current_startline.borrow(); + let display_start = prev_start.clamp(min_start, max_start); *self.draw_memory.current_startline.borrow_mut() = display_start; - let max_pc_len = - self.debug_steps().iter().fold(0, |max_val, val| val.pc.max(max_val)).to_string().len(); + let max_pc = self.debug_steps().iter().map(|step| step.pc).max().unwrap_or(0); + let max_pc_len = hex_digits(max_pc); - // Define closure that prints one more line of source code - let mut add_new_line = |line_number| { - let is_current_step = line_number == self.current_step; - let bg_color = if is_current_step { Color::DarkGray } else { Color::Reset }; + let debug_steps = self.debug_steps(); + let mut lines = Vec::new(); + let mut add_new_line = |line_number: usize| { + let mut line = String::with_capacity(64); - // Format line number - let line_number_format = if is_current_step { - format!("{:0>max_pc_len$x}|▶", step.pc) - } else if line_number < self.debug_steps().len() { - format!("{:0>max_pc_len$x}| ", step.pc) - } else { - "END CALL".to_string() - }; - - if let Some(op) = self.opcode_list.get(line_number) { - text_output.push(Line::from(Span::styled( - format!("{line_number_format}{op}"), - Style::default().fg(Color::White).bg(bg_color), - ))); + let is_current_step = line_number == self.current_step; + if line_number < self.debug_steps().len() { + let step = &debug_steps[line_number]; + write!(line, "{:0>max_pc_len$x}|", step.pc).unwrap(); + line.push_str(if is_current_step { "▶" } else { " " }); + if let Some(op) = self.opcode_list.get(line_number) { + line.push_str(op); + } } else { - text_output.push(Line::from(Span::styled( - line_number_format, - Style::default().fg(Color::White).bg(bg_color), - ))); + line.push_str("END CALL"); } + + let bg_color = if is_current_step { Color::DarkGray } else { Color::Reset }; + let style = Style::new().fg(Color::White).bg(bg_color); + lines.push(Line::from(Span::styled(line, style))); }; + for number in display_start..self.opcode_list.len() { add_new_line(number); } + // Add one more "phantom" line so we see line where current segment execution ends add_new_line(self.opcode_list.len()); - let paragraph = - Paragraph::new(text_output).block(block_source_code).wrap(Wrap { trim: true }); + + let title = format!( + "Address: {} | PC: {} | Gas used in call: {}", + self.address(), + self.current_step().pc, + self.current_step().total_gas_used, + ); + let block = Block::default().title(title).borders(Borders::ALL); + let paragraph = Paragraph::new(lines).block(block).wrap(Wrap { trim: true }); f.render_widget(paragraph, area); } - /// Draw the stack into the stack pane fn draw_stack(&self, f: &mut Frame<'_>, area: Rect) { let step = self.current_step(); let stack = &step.stack; - let stack_space = - Block::default().title(format!("Stack: {}", stack.len())).borders(Borders::ALL); - let min_len = usize::max(format!("{}", stack.len()).len(), 2); + + let min_len = decimal_digits(stack.len()).max(2); let params = if let Instruction::OpCode(op) = step.instruction { OpcodeParam::of(op) } else { &[] }; @@ -540,120 +443,55 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k .skip(self.draw_memory.current_stack_startline) .map(|(i, stack_item)| { let param = params.iter().find(|param| param.index == i); - let mut words: Vec = (0..32) - .rev() - .map(|i| stack_item.byte(i)) - .map(|byte| { - Span::styled( - format!("{byte:02x} "), - if param.is_some() { - Style::default().fg(Color::Cyan) - } else if byte == 0 { - // this improves compatibility across terminals by not combining - // color with DIM modifier - Style::default().add_modifier(Modifier::DIM) - } else { - Style::default().fg(Color::White) - }, - ) - }) - .collect(); + + let mut spans = Vec::with_capacity(1 + 32 * 2 + 3); + + // Stack index. + spans.push(Span::styled(format!("{i:0min_len$}| "), Style::new().fg(Color::White))); + + // Item hex bytes. + hex_bytes_spans(&stack_item.to_be_bytes::<32>(), &mut spans, |_, _| { + if param.is_some() { + Style::new().fg(Color::Cyan) + } else { + Style::new().fg(Color::White) + } + }); if self.stack_labels { if let Some(param) = param { - words.push(Span::raw(format!("| {}", param.name))); - } else { - words.push(Span::raw("| ".to_string())); + spans.push(Span::raw("| ")); + spans.push(Span::raw(param.name)); } } - let mut spans = vec![Span::styled( - format!("{i:0min_len$}| "), - Style::default().fg(Color::White), - )]; - spans.extend(words); spans.push(Span::raw("\n")); Line::from(spans) }) .collect(); - let paragraph = Paragraph::new(text).block(stack_space).wrap(Wrap { trim: true }); + let title = format!("Stack: {}", stack.len()); + let block = Block::default().title(title).borders(Borders::ALL); + let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true }); f.render_widget(paragraph, area); } - /// The memory_access variable stores the index on the stack that indicates the memory - /// offset/size accessed by the given opcode: - /// (read memory offset, read memory size, write memory offset, write memory size) - /// >= 1: the stack index - /// 0: no memory access - /// -1: a fixed size of 32 bytes - /// -2: a fixed size of 1 byte - /// The return value is a tuple about accessed memory region by the given opcode: - /// (read memory offset, read memory size, write memory offset, write memory size) - fn get_memory_access( - op: u8, - stack: &[U256], - ) -> (Option, Option, Option, Option) { - let memory_access = match op { - opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => (1, 2, 0, 0), - opcode::CALLDATACOPY | opcode::CODECOPY | opcode::RETURNDATACOPY => (0, 0, 1, 3), - opcode::EXTCODECOPY => (0, 0, 2, 4), - opcode::MLOAD => (1, -1, 0, 0), - opcode::MSTORE => (0, 0, 1, -1), - opcode::MSTORE8 => (0, 0, 1, -2), - opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => { - (1, 2, 0, 0) - } - opcode::CREATE | opcode::CREATE2 => (2, 3, 0, 0), - opcode::CALL | opcode::CALLCODE => (4, 5, 0, 0), - opcode::DELEGATECALL | opcode::STATICCALL => (3, 4, 0, 0), - _ => Default::default(), - }; - - let stack_len = stack.len(); - let get_size = |stack_index| match stack_index { - -2 => Some(1), - -1 => Some(32), - 0 => None, - 1.. => { - if (stack_index as usize) <= stack_len { - Some(stack[stack_len - stack_index as usize].saturating_to()) - } else { - None - } - } - _ => panic!("invalid stack index"), - }; - - let (read_offset, read_size, write_offset, write_size) = ( - get_size(memory_access.0), - get_size(memory_access.1), - get_size(memory_access.2), - get_size(memory_access.3), - ); - (read_offset, read_size, write_offset, write_size) - } - - /// Draw memory in memory pane fn draw_memory(&self, f: &mut Frame<'_>, area: Rect) { let step = self.current_step(); let memory = &step.memory; - let memory_space = Block::default() - .title(format!("Memory (max expansion: {} bytes)", memory.len())) - .borders(Borders::ALL); - let max_i = memory.len() / 32; - let min_len = format!("{:x}", max_i * 32).len(); - - // color memory region based on write/read - let mut offset: Option = None; - let mut size: Option = None; + + let min_len = hex_digits(memory.len()); + + // Color memory region based on read/write. + let mut offset = None; + let mut size = None; let mut color = None; if let Instruction::OpCode(op) = step.instruction { let stack_len = step.stack.len(); if stack_len > 0 { let (read_offset, read_size, write_offset, write_size) = - Self::get_memory_access(op, &step.stack); + get_memory_access(op, &step.stack); if read_offset.is_some() { offset = read_offset; size = read_size; @@ -671,8 +509,7 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k let prev_step = self.current_step - 1; let prev_step = &self.debug_steps()[prev_step]; if let Instruction::OpCode(op) = prev_step.instruction { - let (_, _, write_offset, write_size) = - Self::get_memory_access(op, &prev_step.stack); + let (_, _, write_offset, write_size) = get_memory_access(op, &prev_step.stack); if write_offset.is_some() { offset = write_offset; size = write_size; @@ -688,53 +525,40 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k .chunks(32) .enumerate() .skip(self.draw_memory.current_mem_startline) - .take_while(|(i, _)| i < &end_line) + .take_while(|(i, _)| *i < end_line) .map(|(i, mem_word)| { - let words: Vec = mem_word - .iter() - .enumerate() - .map(|(j, byte)| { - Span::styled( - format!("{byte:02x} "), - if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { - if i * 32 + j >= offset && i * 32 + j < offset + size { - // [offset, offset + size] is the memory region to be colored. - // If a byte at row i and column j in the memory panel - // falls in this region, set the color. - Style::default().fg(color) - } else if *byte == 0 { - Style::default().add_modifier(Modifier::DIM) - } else { - Style::default().fg(Color::White) - } - } else if *byte == 0 { - Style::default().add_modifier(Modifier::DIM) - } else { - Style::default().fg(Color::White) - }, - ) - }) - .collect(); - - let mut spans = vec![Span::styled( + let mut spans = Vec::with_capacity(1 + 32 * 2 + 1 + 32 / 4 + 1); + + // Memory index. + spans.push(Span::styled( format!("{:0min_len$x}| ", i * 32), - Style::default().fg(Color::White), - )]; - spans.extend(words); + Style::new().fg(Color::White), + )); + + // Word hex bytes. + hex_bytes_spans(mem_word, &mut spans, |j, _| { + let mut byte_color = Color::White; + if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { + let idx = i * 32 + j; + if (offset..offset + size).contains(&idx) { + // [offset, offset + size] is the memory region to be colored. + // If a byte at row i and column j in the memory panel + // falls in this region, set the color. + byte_color = color; + } + } + Style::new().fg(byte_color) + }); if self.mem_utf { - let chars: Vec = mem_word - .chunks(4) - .map(|utf| { - if let Ok(utf_str) = std::str::from_utf8(utf) { - Span::raw(utf_str.replace(char::from(0), ".")) - } else { - Span::raw(".") - } - }) - .collect(); spans.push(Span::raw("|")); - spans.extend(chars); + for utf in mem_word.chunks(4) { + if let Ok(utf_str) = std::str::from_utf8(utf) { + spans.push(Span::raw(utf_str.replace('\0', "."))); + } else { + spans.push(Span::raw(".")); + } + } } spans.push(Span::raw("\n")); @@ -742,7 +566,152 @@ Line::from(Span::styled("[t]: stack labels | [m]: memory decoding | [shift + j/k Line::from(spans) }) .collect(); - let paragraph = Paragraph::new(text).block(memory_space).wrap(Wrap { trim: true }); + + let title = format!("Memory (max expansion: {} bytes)", memory.len()); + let block = Block::default().title(title).borders(Borders::ALL); + let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true }); f.render_widget(paragraph, area); } } + +/// Wrapper around a list of [`Line`]s that prepends the line number on each new line. +struct SourceLines<'a> { + lines: Vec>, + max_line_num: usize, +} + +impl<'a> SourceLines<'a> { + fn new(max_line_num: usize) -> Self { + Self { lines: Vec::new(), max_line_num } + } + + fn push(&mut self, line_number_style: Style, line: &'a str, line_style: Style) { + self.push_raw(line_number_style, &[Span::styled(line, line_style)]); + } + + fn push_raw(&mut self, line_number_style: Style, spans: &[Span<'a>]) { + let mut line_spans = Vec::with_capacity(4); + + let line_number = + format!("{number: >width$} ", number = self.lines.len() + 1, width = self.max_line_num); + line_spans.push(Span::styled(line_number, line_number_style)); + + // Space between line number and line text. + line_spans.push(Span::raw(" ")); + + line_spans.extend_from_slice(spans); + + self.lines.push(Line::from(line_spans)); + } +} + +/// The memory_access variable stores the index on the stack that indicates the memory +/// offset/size accessed by the given opcode: +/// (read memory offset, read memory size, write memory offset, write memory size) +/// >= 1: the stack index +/// 0: no memory access +/// -1: a fixed size of 32 bytes +/// -2: a fixed size of 1 byte +/// The return value is a tuple about accessed memory region by the given opcode: +/// (read memory offset, read memory size, write memory offset, write memory size) +fn get_memory_access( + op: u8, + stack: &[U256], +) -> (Option, Option, Option, Option) { + let memory_access = match op { + opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => (1, 2, 0, 0), + opcode::CALLDATACOPY | opcode::CODECOPY | opcode::RETURNDATACOPY => (0, 0, 1, 3), + opcode::EXTCODECOPY => (0, 0, 2, 4), + opcode::MLOAD => (1, -1, 0, 0), + opcode::MSTORE => (0, 0, 1, -1), + opcode::MSTORE8 => (0, 0, 1, -2), + opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => (1, 2, 0, 0), + opcode::CREATE | opcode::CREATE2 => (2, 3, 0, 0), + opcode::CALL | opcode::CALLCODE => (4, 5, 0, 0), + opcode::DELEGATECALL | opcode::STATICCALL => (3, 4, 0, 0), + _ => Default::default(), + }; + + let stack_len = stack.len(); + let get_size = |stack_index| match stack_index { + -2 => Some(1), + -1 => Some(32), + 0 => None, + 1.. => { + if (stack_index as usize) <= stack_len { + Some(stack[stack_len - stack_index as usize].saturating_to()) + } else { + None + } + } + _ => panic!("invalid stack index"), + }; + + let (read_offset, read_size, write_offset, write_size) = ( + get_size(memory_access.0), + get_size(memory_access.1), + get_size(memory_access.2), + get_size(memory_access.3), + ); + (read_offset, read_size, write_offset, write_size) +} + +fn hex_bytes_spans(bytes: &[u8], spans: &mut Vec>, f: impl Fn(usize, u8) -> Style) { + for (i, &byte) in bytes.iter().enumerate() { + if i > 0 { + spans.push(Span::raw(" ")); + } + spans.push(Span::styled(alloy_primitives::hex::encode([byte]), f(i, byte))); + } +} + +/// Returns the number of decimal digits in the given number. +/// +/// This is the same as `n.to_string().len()`. +fn decimal_digits(n: usize) -> usize { + n.checked_ilog10().unwrap_or(0) as usize + 1 +} + +/// Returns the number of hexadecimal digits in the given number. +/// +/// This is the same as `format!("{n:x}").len()`. +fn hex_digits(n: usize) -> usize { + n.checked_ilog(16).unwrap_or(0) as usize + 1 +} + +#[cfg(test)] +mod tests { + #[test] + fn decimal_digits() { + assert_eq!(super::decimal_digits(0), 1); + assert_eq!(super::decimal_digits(1), 1); + assert_eq!(super::decimal_digits(2), 1); + assert_eq!(super::decimal_digits(9), 1); + assert_eq!(super::decimal_digits(10), 2); + assert_eq!(super::decimal_digits(11), 2); + assert_eq!(super::decimal_digits(50), 2); + assert_eq!(super::decimal_digits(99), 2); + assert_eq!(super::decimal_digits(100), 3); + assert_eq!(super::decimal_digits(101), 3); + assert_eq!(super::decimal_digits(201), 3); + assert_eq!(super::decimal_digits(999), 3); + assert_eq!(super::decimal_digits(1000), 4); + assert_eq!(super::decimal_digits(1001), 4); + } + + #[test] + fn hex_digits() { + assert_eq!(super::hex_digits(0), 1); + assert_eq!(super::hex_digits(1), 1); + assert_eq!(super::hex_digits(2), 1); + assert_eq!(super::hex_digits(9), 1); + assert_eq!(super::hex_digits(10), 1); + assert_eq!(super::hex_digits(11), 1); + assert_eq!(super::hex_digits(15), 1); + assert_eq!(super::hex_digits(16), 2); + assert_eq!(super::hex_digits(17), 2); + assert_eq!(super::hex_digits(0xff), 2); + assert_eq!(super::hex_digits(0x100), 3); + assert_eq!(super::hex_digits(0x101), 3); + } +} diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 01043fc53b547..399c63dfabfac 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -21,7 +21,7 @@ use std::{ collections::{BTreeMap, HashMap}, io, ops::ControlFlow, - sync::mpsc, + sync::{mpsc, Arc}, thread, time::{Duration, Instant}, }; @@ -167,28 +167,56 @@ impl Debugger { } } +type PanicHandler = Box) + 'static + Sync + Send>; + /// Handles terminal state. #[must_use] -struct TerminalGuard<'a, B: Backend + io::Write>(&'a mut Terminal); +struct TerminalGuard<'a, B: Backend + io::Write> { + terminal: &'a mut Terminal, + hook: Option>, +} impl<'a, B: Backend + io::Write> TerminalGuard<'a, B> { fn with(terminal: &'a mut Terminal, mut f: impl FnMut(&mut Terminal) -> T) -> T { - let mut guard = Self(terminal); + let mut guard = Self { terminal, hook: None }; guard.setup(); - f(guard.0) + f(guard.terminal) } fn setup(&mut self) { + let previous = Arc::new(std::panic::take_hook()); + self.hook = Some(previous.clone()); + // We need to restore the terminal state before displaying the panic message. + // TODO: Use `std::panic::update_hook` when it's stable + std::panic::set_hook(Box::new(move |info| { + Self::half_restore(&mut std::io::stdout()); + (previous)(info) + })); + let _ = enable_raw_mode(); - let _ = execute!(*self.0.backend_mut(), EnterAlternateScreen, EnableMouseCapture); - let _ = self.0.hide_cursor(); - let _ = self.0.clear(); + let _ = execute!(*self.terminal.backend_mut(), EnterAlternateScreen, EnableMouseCapture); + let _ = self.terminal.hide_cursor(); + let _ = self.terminal.clear(); } fn restore(&mut self) { + if !std::thread::panicking() { + let _ = std::panic::take_hook(); + let prev = self.hook.take().unwrap(); + let prev = match Arc::try_unwrap(prev) { + Ok(prev) => prev, + Err(_) => unreachable!(), + }; + std::panic::set_hook(prev); + } + + Self::half_restore(self.terminal.backend_mut()); + let _ = self.terminal.show_cursor(); + } + + fn half_restore(w: &mut impl io::Write) { let _ = disable_raw_mode(); - let _ = execute!(*self.0.backend_mut(), LeaveAlternateScreen, DisableMouseCapture); - let _ = self.0.show_cursor(); + let _ = execute!(*w, LeaveAlternateScreen, DisableMouseCapture); } } diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 1ac4b63e3d37f..784cd5cd7bd88 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -38,12 +38,13 @@ impl ScriptArgs { // Sources are only required for the debugger, but it *might* mean that there's // something wrong with the build and/or artifacts. if let Some(source) = artifact.source_file() { - let abs_path = source + let path = source .ast - .ok_or_else(|| eyre::eyre!("Source from artifact has no AST."))? + .ok_or_else(|| eyre::eyre!("source from artifact has no AST"))? .absolute_path; + let abs_path = project.root().join(path); let source_code = fs::read_to_string(abs_path).wrap_err_with(|| { - format!("Failed to read artifact source file for `{}`", id.identifier()) + format!("failed to read artifact source file for `{}`", id.identifier()) })?; let contract = artifact.clone().into_contract_bytecode(); let source_contract = compact_to_contract(contract)?; @@ -53,7 +54,7 @@ impl ScriptArgs { .or_default() .insert(source.id, (source_code, source_contract)); } else { - warn!("source not found for artifact={:?}", id); + warn!(?id, "source not found"); } Ok((id, artifact)) }) diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index b44cf71d00263..3fbdfc5149508 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -6,7 +6,7 @@ use ethers_signers::Signer; use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_common::{contracts::flatten_contracts, try_get_http_provider, types::ToAlloy}; -use foundry_debugger::DebuggerBuilder; +use foundry_debugger::Debugger; use std::sync::Arc; /// Helper alias type for the collection of data changed due to the new sender. @@ -84,7 +84,7 @@ impl ScriptArgs { let mut decoder = self.decode_traces(&script_config, &mut result, &known_contracts)?; if self.debug { - let mut debugger = DebuggerBuilder::new() + let mut debugger = Debugger::builder() .debug_arenas(result.debug.as_deref().unwrap_or_default()) .decoder(&decoder) .sources(sources) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index cb32bed9c50b0..1f79b253267fa 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -31,7 +31,7 @@ use foundry_config::{ }, get_available_profiles, Config, }; -use foundry_debugger::DebuggerBuilder; +use foundry_debugger::Debugger; use regex::Regex; use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; use watchexec::config::{InitConfig, RuntimeConfig}; @@ -297,10 +297,11 @@ impl TestArgs { // Sources are only required for the debugger, but it *might* mean that there's // something wrong with the build and/or artifacts. if let Some(source) = artifact.source_file() { - let abs_path = source + let path = source .ast .ok_or_else(|| eyre::eyre!("Source from artifact has no AST."))? .absolute_path; + let abs_path = project.root().join(&path); let source_code = fs::read_to_string(abs_path)?; let contract = artifact.clone().into_contract_bytecode(); let source_contract = compact_to_contract(contract)?; @@ -315,7 +316,7 @@ impl TestArgs { let test = outcome.clone().into_tests().next().unwrap(); let result = test.result; // Run the debugger - let mut debugger = DebuggerBuilder::new() + let mut debugger = Debugger::builder() // TODO: `Option::as_slice` in 1.75 .debug_arenas(result.debug.as_ref().map(core::slice::from_ref).unwrap_or_default()) .decoders(&decoders) diff --git a/crates/forge/tests/cli/debug.rs b/crates/forge/tests/cli/debug.rs new file mode 100644 index 0000000000000..3e3d08c7e2ad7 --- /dev/null +++ b/crates/forge/tests/cli/debug.rs @@ -0,0 +1,94 @@ +use itertools::Itertools; +use std::path::Path; + +// Sets up a debuggable test case. +// Run with `cargo test-debugger`. +forgetest_async!( + #[ignore = "ran manually"] + manual_debug_setup, + |prj, cmd| { + cmd.args(["init", "--force"]).arg(prj.root()).assert_non_empty_stdout(); + cmd.forge_fuse(); + + prj.add_source("Counter2.sol", r#" +contract A { + address public a; + uint public b; + int public c; + bytes32 public d; + bool public e; + bytes public f; + string public g; + + constructor(address _a, uint _b, int _c, bytes32 _d, bool _e, bytes memory _f, string memory _g) { + a = _a; + b = _b; + c = _c; + d = _d; + e = _e; + f = _f; + g = _g; + } + + function getA() public view returns (address) { + return a; + } + + function setA(address _a) public { + a = _a; + } +}"#, + ) + .unwrap(); + + let script = prj.add_script("Counter.s.sol", r#" +import "../src/Counter2.sol"; +import "forge-std/Script.sol"; +import "forge-std/Test.sol"; + +contract B is A { + A public other; + address public self = address(this); + + constructor(address _a, uint _b, int _c, bytes32 _d, bool _e, bytes memory _f, string memory _g) + A(_a, _b, _c, _d, _e, _f, _g) + { + other = new A(_a, _b, _c, _d, _e, _f, _g); + } +} + +contract Script0 is Script, Test { + function run() external { + assertEq(uint256(1), uint256(1)); + + vm.startBroadcast(); + B b = new B(msg.sender, 2 ** 32, -1 * (2 ** 32), keccak256(abi.encode(1)), true, "abcdef", "hello"); + assertEq(b.getA(), msg.sender); + b.setA(tx.origin); + assertEq(b.getA(), tx.origin); + address _b = b.self(); + bytes32 _d = b.d(); + bytes32 _d2 = b.other().d(); + } +}"#, + ) + .unwrap(); + + cmd.args(["build"]).assert_success(); + cmd.forge_fuse(); + + cmd.args([ + "script", + script.to_str().unwrap(), + "--root", + prj.root().to_str().unwrap(), + "--tc=Script0", + "--debug", + ]); + eprintln!("root: {}", prj.root().display()); + let cmd_path = Path::new(cmd.cmd().get_program()).canonicalize().unwrap(); + let args = cmd.cmd().get_args().map(|s| s.to_str().unwrap()).format(" "); + eprintln!(" cmd: {} {args}", cmd_path.display()); + std::mem::forget(prj); + } +); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index f8c9dcbbf0cad..d25297119e570 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -10,6 +10,7 @@ mod cmd; mod config; mod coverage; mod create; +mod debug; mod doc; mod multi_script; mod script; diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index c0265c3d6c742..078361fab8e04 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -1,4 +1,4 @@ -//! forge tests for cheat codes +//! Forge tests for cheatcodes. use crate::{ config::*, diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index cfb706d33fc3e..899f0711a5f45 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -1,4 +1,4 @@ -//! Test setup +//! Test config. use crate::test_helpers::{COMPILED, EVM_OPTS, PROJECT}; use forge::{ @@ -16,7 +16,7 @@ use foundry_test_utils::{init_tracing, Filter}; use itertools::Itertools; use std::{collections::BTreeMap, path::Path}; -/// How to execute a a test run +/// How to execute a test run. pub struct TestConfig { pub runner: MultiContractRunner, pub should_fail: bool, diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 07b89a6c14a7f..eba2372c1df7f 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -1,4 +1,4 @@ -//! forge tests for core functionality +//! Forge tests for core functionality. use crate::config::*; use forge::result::SuiteResult; diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index e66e975fdc86c..814d1b09ebd27 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -1,4 +1,4 @@ -//! forge tests for cheat codes +//! Forge forking tests. use crate::{ config::*, diff --git a/crates/forge/tests/it/fs.rs b/crates/forge/tests/it/fs.rs index 9ab7711eda3c7..29affe05c8519 100644 --- a/crates/forge/tests/it/fs.rs +++ b/crates/forge/tests/it/fs.rs @@ -1,4 +1,4 @@ -//! Tests for reproducing issues +//! Filesystem tests. use crate::{config::*, test_helpers::PROJECT}; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 5654cb070a811..d16befa350647 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -1,4 +1,4 @@ -//! Tests for invariants +//! Fuzz tests. use crate::config::*; use alloy_primitives::U256; diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 7fc2957a2a955..821077b704e61 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -1,3 +1,5 @@ +//! Inline configuration tests. + use crate::{ config::runner, test_helpers::{COMPILED, PROJECT}, diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index bfd28d1435b96..587eedaf8bc29 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -1,4 +1,4 @@ -//! Tests for invariants +//! Invariant tests. use crate::config::*; use alloy_primitives::U256; diff --git a/crates/forge/tests/it/spec.rs b/crates/forge/tests/it/spec.rs index 16ed249833096..724aaa0ff4ffd 100644 --- a/crates/forge/tests/it/spec.rs +++ b/crates/forge/tests/it/spec.rs @@ -1,3 +1,5 @@ +//! Integration tests for EVM specifications. + use crate::config::*; use foundry_evm::revm::primitives::SpecId; use foundry_test_utils::Filter; diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index e0bac51b4ea69..31a330d2afb05 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -1,3 +1,5 @@ +//! Test helpers for Forge integration tests. + use alloy_primitives::U256; use foundry_compilers::{ artifacts::{Libraries, Settings}, From 70225e314350d72254b412a1fd34f498424a5d3a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 6 Dec 2023 21:07:54 +0100 Subject: [PATCH 0381/1963] chore: backwardscompat blockenv serializer (#6535) --- crates/evm/core/src/fork/cache.rs | 98 +++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index ca467dbdf4b5e..4a7e573d82c68 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -14,7 +14,6 @@ use std::{ path::PathBuf, sync::Arc, }; - use url::Url; pub type StorageInfo = Map; @@ -154,10 +153,10 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { where D: Deserializer<'de>, { - /// A backwards compatible representation of [revm::CfgEnv] + /// A backwards compatible representation of [revm::primitives::CfgEnv] /// /// This prevents deserialization errors of cache files caused by breaking changes to the - /// default [revm::CfgEnv], for example enabling an optional feature. + /// default [revm::primitives::CfgEnv], for example enabling an optional feature. /// By hand rolling deserialize impl we can prevent cache file issues struct CfgEnvBackwardsCompat { inner: revm::primitives::CfgEnv, @@ -202,11 +201,43 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { } } + /// A backwards compatible representation of [revm::primitives::BlockEnv] + /// + /// This prevents deserialization errors of cache files caused by breaking changes to the + /// default [revm::primitives::BlockEnv], for example enabling an optional feature. + /// By hand rolling deserialize impl we can prevent cache file issues + struct BlockEnvBackwardsCompat { + inner: revm::primitives::BlockEnv, + } + + impl<'de> Deserialize<'de> for BlockEnvBackwardsCompat { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let mut value = serde_json::Value::deserialize(deserializer)?; + + // we check for breaking changes here + if let Some(obj) = value.as_object_mut() { + // additional EIP-4844 fields that are present by default + let key = "blob_excess_gas_and_price"; + if !obj.contains_key(key) { + let value = revm::primitives::BlockEnv::default().blob_excess_gas_and_price; + obj.insert(key.to_string(), serde_json::to_value(value).unwrap()); + } + } + + let cfg_env: revm::primitives::BlockEnv = + serde_json::from_value(value).map_err(serde::de::Error::custom)?; + Ok(Self { inner: cfg_env }) + } + } + // custom deserialize impl to not break existing cache files #[derive(Deserialize)] struct Meta { cfg_env: CfgEnvBackwardsCompat, - block_env: revm::primitives::BlockEnv, + block_env: BlockEnvBackwardsCompat, /// all the hosts used to connect to #[serde(alias = "host")] hosts: Hosts, @@ -222,7 +253,7 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { let Meta { cfg_env, block_env, hosts } = Meta::deserialize(deserializer)?; Ok(Self { cfg_env: cfg_env.inner, - block_env, + block_env: block_env.inner, hosts: match hosts { Hosts::Multi(hosts) => hosts, Hosts::Single(host) => BTreeSet::from([host]), @@ -533,4 +564,61 @@ mod tests { let _s = serde_json::to_string(&cache).unwrap(); } + + #[test] + fn can_deserialize_cache_post_4844() { + let s = r#"{ + "meta": { + "cfg_env": { + "chain_id": 1, + "spec_id": "LATEST", + "perf_analyse_created_bytecodes": "Analyse", + "limit_contract_code_size": 18446744073709551615, + "memory_limit": 134217728, + "disable_block_gas_limit": false, + "disable_eip3607": true, + "disable_base_fee": false, + "optimism": false + }, + "block_env": { + "number": "0x11c99bc", + "coinbase": "0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97", + "timestamp": "0x65627003", + "gas_limit": "0x1c9c380", + "basefee": "0x64288ff1f", + "difficulty": "0xc6b1a299886016dea3865689f8393b9bf4d8f4fe8c0ad25f0058b3569297c057", + "prevrandao": "0xc6b1a299886016dea3865689f8393b9bf4d8f4fe8c0ad25f0058b3569297c057", + "blob_excess_gas_and_price": { + "excess_blob_gas": 0, + "blob_gasprice": 1 + } + }, + "hosts": [ + "eth-mainnet.alchemyapi.io" + ] + }, + "accounts": { + "0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97": { + "balance": "0x8e0c373cfcdfd0eb", + "nonce": 128912, + "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "code": { + "bytecode": "0x000000000000000000000000000000000000000000000000000000000000000000", + "state": { + "Checked": { + "len": 0 + } + } + } + } + }, + "storage": {}, + "block_hashes": {} +}"#; + + let cache: JsonBlockCacheData = serde_json::from_str(s).unwrap(); + assert_eq!(cache.data.accounts.read().len(), 1); + + let _s = serde_json::to_string(&cache).unwrap(); + } } From 54b369564937f5f5d4f2525622e8b9808b1645f6 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 6 Dec 2023 23:22:36 +0100 Subject: [PATCH 0382/1963] chore: solve breakin serde env changes once and for all (#6536) --- crates/evm/core/src/fork/cache.rs | 40 ++++++++++--------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index 4a7e573d82c68..791660d632d45 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -171,27 +171,12 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { // we check for breaking changes here if let Some(obj) = value.as_object_mut() { - // additional field `disable_eip3607` enabled by the `optional_eip3607` feature - let key = "disable_eip3607"; - if !obj.contains_key(key) { - obj.insert(key.to_string(), true.into()); - } - // additional field `disable_block_gas_limit` enabled by the - // `optional_block_gas_limit` feature - let key = "disable_block_gas_limit"; - if !obj.contains_key(key) { - // keep default value - obj.insert(key.to_string(), false.into()); - } - let key = "disable_base_fee"; - if !obj.contains_key(key) { - // keep default value - obj.insert(key.to_string(), false.into()); - } - let key = "optimism"; - if !obj.contains_key(key) { - // keep default value - obj.insert(key.to_string(), false.into()); + let default_value = + serde_json::to_value(revm::primitives::CfgEnv::default()).unwrap(); + for (key, value) in default_value.as_object().unwrap() { + if !obj.contains_key(key) { + obj.insert(key.to_string(), value.clone()); + } } } @@ -217,13 +202,14 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { { let mut value = serde_json::Value::deserialize(deserializer)?; - // we check for breaking changes here + // we check for any missing fields here if let Some(obj) = value.as_object_mut() { - // additional EIP-4844 fields that are present by default - let key = "blob_excess_gas_and_price"; - if !obj.contains_key(key) { - let value = revm::primitives::BlockEnv::default().blob_excess_gas_and_price; - obj.insert(key.to_string(), serde_json::to_value(value).unwrap()); + let default_value = + serde_json::to_value(revm::primitives::BlockEnv::default()).unwrap(); + for (key, value) in default_value.as_object().unwrap() { + if !obj.contains_key(key) { + obj.insert(key.to_string(), value.clone()); + } } } From 8a31bf1ec2fb386e5441ee2a629b0c12b4433aed Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 8 Dec 2023 00:21:33 +0400 Subject: [PATCH 0383/1963] fix(forge) Prefund test/script contracts before deployment (#6300) * Add test * Prefund script/test contracts before construction * Use correct sender for scripts * ref -> basic_ref --------- Co-authored-by: evalir --- crates/evm/evm/src/executors/mod.rs | 5 +++++ crates/forge/bin/cmd/script/runner.rs | 8 ++++++- crates/forge/src/runner.rs | 32 +++++++++++++++------------ crates/forge/tests/it/repros.rs | 3 +++ testdata/repros/Issue6293.t.sol | 19 ++++++++++++++++ 5 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 testdata/repros/Issue6293.t.sol diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index dcb1682883fa9..f7dd6f6876e9c 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -138,6 +138,11 @@ impl Executor { Ok(self) } + /// Gets the nonce of an account + pub fn get_nonce(&self, address: Address) -> DatabaseResult { + Ok(self.backend.basic_ref(address)?.map(|acc| acc.nonce).unwrap_or_default()) + } + #[inline] pub fn set_tracing(&mut self, tracing: bool) -> &mut Self { self.inspector.tracing(tracing); diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 8678848d74868..ca5de4b28b47d 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -70,6 +70,13 @@ impl ScriptRunner { .map(|traces| (TraceKind::Deployment, traces)) .collect(); + let sender_nonce = self.executor.get_nonce(CALLER)?; + let address = CALLER.create(sender_nonce); + + // Set the contracts initial balance before deployment, so it is available during the + // construction + self.executor.set_balance(address, self.initial_balance)?; + // Deploy an instance of the contract let DeployResult { address, @@ -83,7 +90,6 @@ impl ScriptRunner { .map_err(|err| eyre::eyre!("Failed to deploy script:\n{}", err))?; traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); - self.executor.set_balance(address, self.initial_balance)?; // Optionally call the `setUp` function let (success, gas_used, labeled_addresses, transactions, debug, script_wallets) = if !setup diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 0a9a121c2aae2..a08678a3e540d 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -115,22 +115,26 @@ impl<'a> ContractRunner<'a> { } } - // Deploy the test contract - let address = - match self.executor.deploy(self.sender, self.code.clone(), U256::ZERO, self.errors) { - Ok(d) => { - logs.extend(d.logs); - traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); - d.address - } - Err(e) => { - return Ok(TestSetup::from_evm_error_with(e, logs, traces, Default::default())) - } - }; + let sender_nonce = self.executor.get_nonce(self.sender)?; + let address = self.sender.create(sender_nonce); - // Now we set the contracts initial balance, and we also reset `self.sender`s and `CALLER`s - // balance to the initial balance we want + // Set the contracts initial balance before deployment, so it is available during + // construction self.executor.set_balance(address, self.initial_balance)?; + + // Deploy the test contract + match self.executor.deploy(self.sender, self.code.clone(), U256::ZERO, self.errors) { + Ok(d) => { + logs.extend(d.logs); + traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); + d.address + } + Err(e) => { + return Ok(TestSetup::from_evm_error_with(e, logs, traces, Default::default())) + } + }; + + // Reset `self.sender`s and `CALLER`s balance to the initial balance we want self.executor.set_balance(self.sender, self.initial_balance)?; self.executor.set_balance(CALLER, self.initial_balance)?; diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index f07b1dcb5c412..490954eb83e29 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -208,6 +208,9 @@ test_repro!(6170, false, None, |res| { assert_eq!(test.reason, Some("log != expected log".to_string())); }); +// +test_repro!(6293); + // https://github.com/foundry-rs/foundry/issues/6180 test_repro!(6180); diff --git a/testdata/repros/Issue6293.t.sol b/testdata/repros/Issue6293.t.sol new file mode 100644 index 0000000000000..c90f56806203f --- /dev/null +++ b/testdata/repros/Issue6293.t.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6293 +contract Issue6293Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + constructor() { + require(address(this).balance > 0); + payable(address(1)).call{value: 1}(""); + } + + function test() public { + assertGt(address(this).balance, 0); + } +} From fb601f535e563001210c142118c550b8422db335 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:54:12 +0100 Subject: [PATCH 0384/1963] fix(debugger): don't panic when arena is empty (#6547) --- crates/debugger/src/tui/mod.rs | 2 ++ crates/forge/bin/cmd/test/mod.rs | 17 +++-------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 399c63dfabfac..1b25b8befee68 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -130,6 +130,8 @@ impl Debugger { .spawn(move || Self::event_listener(tx)) .expect("failed to spawn thread"); + eyre::ensure!(!cx.debug_arena().is_empty(), "debug arena is empty"); + // Draw the initial state. cx.draw(terminal)?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1f79b253267fa..91e33d972576d 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -188,7 +188,7 @@ impl TestArgs { // Prepare the test builder let should_debug = self.debug.is_some(); - let mut runner_builder = MultiContractRunnerBuilder::default() + let runner_builder = MultiContractRunnerBuilder::default() .set_debug(should_debug) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) @@ -197,7 +197,7 @@ impl TestArgs { .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone())) .with_test_options(test_options.clone()); - let mut runner = runner_builder.clone().build( + let runner = runner_builder.clone().build( project_root, output.clone(), env.clone(), @@ -213,17 +213,6 @@ impl TestArgs { Use --match-contract and --match-path to further limit the search." ); } - let test_funcs = runner.get_matching_test_functions(&filter); - // if we debug a fuzz test, we should not collect data on the first run - if !test_funcs.first().expect("matching function exists").inputs.is_empty() { - runner_builder = runner_builder.set_debug(false); - runner = runner_builder.clone().build( - project_root, - output.clone(), - env.clone(), - evm_opts.clone(), - )?; - } } let known_contracts = runner.known_contracts.clone(); @@ -307,7 +296,7 @@ impl TestArgs { let source_contract = compact_to_contract(contract)?; sources .0 - .entry(id.clone().name) + .entry(id.name.clone()) .or_default() .insert(source.id, (source_code, source_contract)); } From f460583ba4ea5fc7d3917eb071c544c1fbd3eadd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 8 Dec 2023 12:05:50 +0100 Subject: [PATCH 0385/1963] chore: replace expect with wrap_err (#6549) --- crates/forge/bin/cmd/script/executor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index fec89e62a3a0f..b38f48e595867 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -156,7 +156,7 @@ impl ScriptArgs { tx.data.clone().map(|b| b.to_alloy()), tx.value.map(|v| v.to_alloy()), ) - .expect("Internal EVM error"); + .wrap_err("Internal EVM error during simulation")?; if !result.success || result.traces.is_empty() { return Ok((None, result.traces)) From 80331395ad0da36795a3603746848a806e2bc920 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 8 Dec 2023 12:46:02 +0100 Subject: [PATCH 0386/1963] refactor: only use channel to return test results (#6550) * refactor: only use channel to return test results * error * rm auto_impl * rm unused * inline useless function * rename to test_collect * doc * fmt * fmt --- Cargo.lock | 1 - crates/common/Cargo.toml | 1 - crates/common/src/traits.rs | 38 +-- crates/forge/bin/cmd/coverage.rs | 17 +- crates/forge/bin/cmd/test/filter.rs | 38 +-- crates/forge/bin/cmd/test/mod.rs | 447 +++++++++++++--------------- crates/forge/src/multi_runner.rs | 98 +++--- crates/forge/src/runner.rs | 6 +- crates/forge/tests/it/config.rs | 2 +- crates/forge/tests/it/core.rs | 15 +- crates/forge/tests/it/fork.rs | 3 +- crates/forge/tests/it/fuzz.rs | 5 +- crates/forge/tests/it/inline.rs | 4 +- crates/forge/tests/it/invariant.rs | 15 +- crates/test-utils/src/filter.rs | 23 +- 15 files changed, 347 insertions(+), 366 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10914dff0b4de..90423c3bdd76e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2727,7 +2727,6 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "async-trait", - "auto_impl", "clap", "comfy-table", "const-hex", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index ff7472d61dbaf..d6f11bcf5d584 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -24,7 +24,6 @@ alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitr alloy-sol-types.workspace = true async-trait = "0.1" -auto_impl = "1.1.0" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" dunce = "1" diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index c5e8f96a278c6..4232fb946dc3b 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -3,31 +3,35 @@ use alloy_json_abi::Function; use alloy_primitives::Bytes; use alloy_sol_types::SolError; -use auto_impl::auto_impl; +use std::path::Path; -/// Extension trait for matching tests -#[auto_impl(&)] +/// Test filter. pub trait TestFilter: Send + Sync { - /// Returns whether the test should be included - fn matches_test(&self, test_name: impl AsRef) -> bool; - /// Returns whether the contract should be included - fn matches_contract(&self, contract_name: impl AsRef) -> bool; - /// Returns a contract with the given path should be included - fn matches_path(&self, path: impl AsRef) -> bool; + /// Returns whether the test should be included. + fn matches_test(&self, test_name: &str) -> bool; + + /// Returns whether the contract should be included. + fn matches_contract(&self, contract_name: &str) -> bool; + + /// Returns a contract with the given path should be included. + fn matches_path(&self, path: &Path) -> bool; } -/// Extension trait for `Function` -#[auto_impl(&)] +/// Extension trait for `Function`. pub trait TestFunctionExt { - /// Whether this function should be executed as invariant test + /// Returns whether this function should be executed as invariant test. fn is_invariant_test(&self) -> bool; - /// Whether this function should be executed as fuzz test + + /// Returns whether this function should be executed as fuzz test. fn is_fuzz_test(&self) -> bool; - /// Whether this function is a test + + /// Returns whether this function is a test. fn is_test(&self) -> bool; - /// Whether this function is a test that should fail + + /// Returns whether this function is a test that should fail. fn is_test_fail(&self) -> bool; - /// Whether this function is a `setUp` function + + /// Returns whether this function is a `setUp` function. fn is_setup(&self) -> bool; } @@ -82,7 +86,7 @@ impl TestFunctionExt for str { } fn is_fuzz_test(&self) -> bool { - unimplemented!("no naming convention for fuzz tests.") + unimplemented!("no naming convention for fuzz tests") } fn is_test(&self) -> bool { diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 635991ad49c52..4ee84951ac881 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -310,12 +310,10 @@ impl CoverageArgs { let filter = self.filter; let (tx, rx) = channel::<(String, SuiteResult)>(); let handle = - tokio::task::spawn( - async move { runner.test(filter, Some(tx), Default::default()).await }, - ); + tokio::task::spawn(async move { runner.test(&filter, tx, Default::default()).await }); // Add hit data to the coverage report - for (artifact_id, hits) in rx + let data = rx .into_iter() .flat_map(|(_, suite)| suite.test_results.into_values()) .filter_map(|mut result| result.coverage.take()) @@ -323,8 +321,8 @@ impl CoverageArgs { hit_maps.0.into_values().filter_map(|map| { Some((known_contracts.find_by_code(map.bytecode.as_ref())?.0, map)) }) - }) - { + }); + for (artifact_id, hits) in data { // TODO: Note down failing tests if let Some(source_id) = report.get_source_id( artifact_id.version.clone(), @@ -344,7 +342,12 @@ impl CoverageArgs { } // Reattach the thread - let _ = handle.await; + if let Err(e) = handle.await { + match e.try_into_panic() { + Ok(payload) => std::panic::resume_unwind(payload), + Err(e) => return Err(e.into()), + } + } // Output final report for report_kind in self.report { diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index 7af0e4042a8f7..abed3d892e668 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -101,38 +101,39 @@ impl FileFilter for FilterArgs { } impl TestFilter for FilterArgs { - fn matches_test(&self, test_name: impl AsRef) -> bool { + fn matches_test(&self, test_name: &str) -> bool { let mut ok = true; - let test_name = test_name.as_ref(); if let Some(re) = &self.test_pattern { - ok &= re.is_match(test_name); + ok = ok && re.is_match(test_name); } if let Some(re) = &self.test_pattern_inverse { - ok &= !re.is_match(test_name); + ok = ok && !re.is_match(test_name); } ok } - fn matches_contract(&self, contract_name: impl AsRef) -> bool { + fn matches_contract(&self, contract_name: &str) -> bool { let mut ok = true; - let contract_name = contract_name.as_ref(); if let Some(re) = &self.contract_pattern { - ok &= re.is_match(contract_name); + ok = ok && re.is_match(contract_name); } if let Some(re) = &self.contract_pattern_inverse { - ok &= !re.is_match(contract_name); + ok = ok && !re.is_match(contract_name); } ok } - fn matches_path(&self, path: impl AsRef) -> bool { + fn matches_path(&self, path: &Path) -> bool { + let Some(path) = path.to_str() else { + return false; + }; + let mut ok = true; - let path = path.as_ref(); - if let Some(ref glob) = self.path_pattern { - ok &= glob.is_match(path); + if let Some(re) = &self.path_pattern { + ok = ok && re.is_match(path); } - if let Some(ref glob) = self.path_pattern_inverse { - ok &= !glob.is_match(path); + if let Some(re) = &self.path_pattern_inverse { + ok = ok && !re.is_match(path); } ok } @@ -195,18 +196,17 @@ impl FileFilter for ProjectPathsAwareFilter { } impl TestFilter for ProjectPathsAwareFilter { - fn matches_test(&self, test_name: impl AsRef) -> bool { + fn matches_test(&self, test_name: &str) -> bool { self.args_filter.matches_test(test_name) } - fn matches_contract(&self, contract_name: impl AsRef) -> bool { + fn matches_contract(&self, contract_name: &str) -> bool { self.args_filter.matches_contract(contract_name) } - fn matches_path(&self, path: impl AsRef) -> bool { - let path = path.as_ref(); + fn matches_path(&self, path: &Path) -> bool { // we don't want to test files that belong to a library - self.args_filter.matches_path(path) && !self.paths.has_library_ancestor(Path::new(path)) + self.args_filter.matches_path(path) && !self.paths.has_library_ancestor(path) } } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 91e33d972576d..e649d889f3515 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -80,15 +80,15 @@ pub struct TestArgs { #[clap(long, short, help_heading = "Display options")] json: bool, - /// Stop running tests after the first failure + /// Stop running tests after the first failure. #[clap(long)] pub fail_fast: bool, - /// The Etherscan (or equivalent) API key + /// The Etherscan (or equivalent) API key. #[clap(long, env = "ETHERSCAN_API_KEY", value_name = "KEY")] etherscan_api_key: Option, - /// List tests instead of running them + /// List tests instead of running them. #[clap(long, short, help_heading = "Display options")] list: bool, @@ -111,12 +111,12 @@ pub struct TestArgs { #[clap(flatten)] pub watch: WatchArgs, - /// Print test summary table + /// Print test summary table. #[clap(long, help_heading = "Display options")] pub summary: bool, - /// Print detailed test summary table - #[clap(long, help_heading = "Display options")] + /// Print detailed test summary table. + #[clap(long, help_heading = "Display options", requires = "summary")] pub detailed: bool, } @@ -220,7 +220,7 @@ impl TestArgs { let remote_chain_id = runner.evm_opts.get_remote_chain_id(); let outcome = self - .run_tests(runner, config.clone(), verbosity, filter.clone(), test_options.clone()) + .run_tests(runner, config.clone(), verbosity, &filter, test_options.clone()) .await?; if should_debug { @@ -324,38 +324,216 @@ impl TestArgs { mut runner: MultiContractRunner, config: Config, verbosity: u8, - mut filter: ProjectPathsAwareFilter, + filter: &ProjectPathsAwareFilter, test_options: TestOptions, ) -> eyre::Result { - if self.debug.is_some() { - filter.args_mut().test_pattern = self.debug.clone(); - // Run the test - let results = runner.test(&filter, None, test_options).await; - - Ok(TestOutcome::new(results, self.allow_failure)) - } else if self.list { - list(runner, filter, self.json) - } else { - if self.detailed && !self.summary { - return Err(eyre::eyre!( - "Missing `--summary` option in your command. You must pass it along with the `--detailed` option to view detailed test summary." - )); + if self.list { + return list(runner, filter, self.json); + } + + if let Some(debug_regex) = self.debug.as_ref() { + let mut filter = filter.clone(); + filter.args_mut().test_pattern = Some(debug_regex.clone()); + let results = runner.test_collect(&filter, test_options).await; + return Ok(TestOutcome::new(results, self.allow_failure)); + } + + trace!(target: "forge::test", "running all tests"); + + if runner.matching_test_function_count(filter) == 0 { + let filter_str = filter.to_string(); + if filter_str.is_empty() { + println!( + "\nNo tests found in project! \ + Forge looks for functions that starts with `test`." + ); + } else { + println!("\nNo tests match the provided pattern:\n{filter_str}"); + // Try to suggest a test when there's no match + if let Some(test_pattern) = &filter.args().test_pattern { + let test_name = test_pattern.as_str(); + let candidates = runner.get_tests(filter); + if let Some(suggestion) = utils::did_you_mean(test_name, candidates).pop() { + println!("\nDid you mean `{suggestion}`?"); + } + } + } + } + + if self.json { + let results = runner.test_collect(filter, test_options).await; + println!("{}", serde_json::to_string(&results)?); + return Ok(TestOutcome::new(results, self.allow_failure)) + } + + // Set up identifiers + let known_contracts = runner.known_contracts.clone(); + let mut local_identifier = LocalTraceIdentifier::new(&known_contracts); + let remote_chain_id = runner.evm_opts.get_remote_chain_id(); + // Do not re-query etherscan for contracts that you've already queried today. + let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; + + // Set up test reporter channel + let (tx, rx) = channel::<(String, SuiteResult)>(); + + // Run tests + let handle = tokio::task::spawn({ + let filter = filter.clone(); + async move { runner.test(&filter, tx, test_options).await } + }); + + let mut results = BTreeMap::new(); + let mut gas_report = GasReport::new(config.gas_reports, config.gas_reports_ignore); + let sig_identifier = + SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; + + let mut total_passed = 0; + let mut total_failed = 0; + let mut total_skipped = 0; + let mut suite_results: Vec = Vec::new(); + + 'outer: for (contract_name, suite_result) in rx { + results.insert(contract_name.clone(), suite_result.clone()); + + let mut tests = suite_result.test_results.clone(); + println!(); + for warning in suite_result.warnings.iter() { + eprintln!("{} {warning}", Paint::yellow("Warning:").bold()); + } + if !tests.is_empty() { + let term = if tests.len() > 1 { "tests" } else { "test" }; + println!("Running {} {term} for {contract_name}", tests.len()); + } + for (name, result) in &mut tests { + short_test_result(name, result); + + // If the test failed, we want to stop processing the rest of the tests + if self.fail_fast && result.status == TestStatus::Failure { + break 'outer + } + + // We only display logs at level 2 and above + if verbosity >= 2 { + // We only decode logs from Hardhat and DS-style console events + let console_logs = decode_console_logs(&result.logs); + if !console_logs.is_empty() { + println!("Logs:"); + for log in console_logs { + println!(" {log}"); + } + println!(); + } + } + + if result.traces.is_empty() { + continue + } + + // Identify addresses in each trace + let mut builder = CallTraceDecoderBuilder::new() + .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) + .with_events(local_identifier.events().cloned()) + .with_verbosity(verbosity); + + // Signatures are of no value for gas reports + if !self.gas_report { + builder = builder.with_signature_identifier(sig_identifier.clone()); + } + + let mut decoder = builder.build(); + + // Decode the traces + let mut decoded_traces = Vec::with_capacity(result.traces.len()); + for (kind, trace) in &mut result.traces { + decoder.identify(trace, &mut local_identifier); + decoder.identify(trace, &mut etherscan_identifier); + + // verbosity: + // - 0..3: nothing + // - 3: only display traces for failed tests + // - 4: also display the setup trace for failed tests + // - 5..: display all traces for all tests + let should_include = match kind { + TraceKind::Execution => { + (verbosity == 3 && result.status.is_failure()) || verbosity >= 4 + } + TraceKind::Setup => { + (verbosity == 4 && result.status.is_failure()) || verbosity >= 5 + } + TraceKind::Deployment => false, + }; + + // Decode the trace if we either need to build a gas report or we need to print + // it + if should_include || self.gas_report { + decoder.decode(trace).await; + } + + if should_include { + decoded_traces.push(trace.to_string()); + } + } + + if !decoded_traces.is_empty() { + println!("Traces:"); + decoded_traces.into_iter().for_each(|trace| println!("{trace}")); + } + + if self.gas_report { + gas_report.analyze(&result.traces); + } } - test( - config, - runner, - verbosity, - filter, - self.json, + let block_outcome = TestOutcome::new( + [(contract_name.clone(), suite_result)].into(), self.allow_failure, - test_options, - self.gas_report, - self.fail_fast, - self.summary, - self.detailed, - ) - .await + ); + + total_passed += block_outcome.successes().count(); + total_failed += block_outcome.failures().count(); + total_skipped += block_outcome.skips().count(); + + println!("{}", block_outcome.summary()); + + if self.summary { + suite_results.push(block_outcome.clone()); + } + } + + if self.gas_report { + println!("{}", gas_report.finalize()); + } + + let num_test_suites = results.len(); + + if num_test_suites > 0 { + println!( + "{}", + format_aggregated_summary( + num_test_suites, + total_passed, + total_failed, + total_skipped + ) + ); + + if self.summary { + let mut summary_table = TestSummaryReporter::new(self.detailed); + println!("\n\nTest Summary:"); + summary_table.print_summary(suite_results); + } } + + // Reattach the task. + if let Err(e) = handle.await { + match e.try_into_panic() { + Ok(payload) => std::panic::resume_unwind(payload), + Err(e) => return Err(e.into()), + } + } + + trace!(target: "forge::test", "received {} results", results.len()); + + Ok(TestOutcome::new(results, self.allow_failure)) } /// Returns the flattened [`FilterArgs`] arguments merged with [`Config`]. @@ -556,10 +734,10 @@ fn format_aggregated_summary( /// Lists all matching tests fn list( runner: MultiContractRunner, - filter: ProjectPathsAwareFilter, + filter: &ProjectPathsAwareFilter, json: bool, ) -> Result { - let results = runner.list(&filter); + let results = runner.list(filter); if json { println!("{}", serde_json::to_string(&results)?); @@ -575,203 +753,6 @@ fn list( Ok(TestOutcome::new(BTreeMap::new(), false)) } -/// Runs all the tests -#[allow(clippy::too_many_arguments)] -async fn test( - config: Config, - mut runner: MultiContractRunner, - verbosity: u8, - filter: ProjectPathsAwareFilter, - json: bool, - allow_failure: bool, - test_options: TestOptions, - gas_reporting: bool, - fail_fast: bool, - summary: bool, - detailed: bool, -) -> Result { - trace!(target: "forge::test", "running all tests"); - - if runner.matching_test_function_count(&filter) == 0 { - let filter_str = filter.to_string(); - if filter_str.is_empty() { - println!( - "\nNo tests found in project! Forge looks for functions that starts with `test`." - ); - } else { - println!("\nNo tests match the provided pattern:"); - println!("{filter_str}"); - // Try to suggest a test when there's no match - if let Some(ref test_pattern) = filter.args().test_pattern { - let test_name = test_pattern.as_str(); - let candidates = runner.get_tests(&filter); - if let Some(suggestion) = utils::did_you_mean(test_name, candidates).pop() { - println!("\nDid you mean `{suggestion}`?"); - } - } - } - } - - if json { - let results = runner.test(filter, None, test_options).await; - println!("{}", serde_json::to_string(&results)?); - return Ok(TestOutcome::new(results, allow_failure)) - } - - // Set up identifiers - let known_contracts = runner.known_contracts.clone(); - let mut local_identifier = LocalTraceIdentifier::new(&known_contracts); - let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - // Do not re-query etherscan for contracts that you've already queried today. - let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; - - // Set up test reporter channel - let (tx, rx) = channel::<(String, SuiteResult)>(); - - // Run tests - let handle = - tokio::task::spawn(async move { runner.test(filter, Some(tx), test_options).await }); - - let mut results = BTreeMap::new(); - let mut gas_report = GasReport::new(config.gas_reports, config.gas_reports_ignore); - let sig_identifier = SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; - - let mut total_passed = 0; - let mut total_failed = 0; - let mut total_skipped = 0; - let mut suite_results: Vec = Vec::new(); - - 'outer: for (contract_name, suite_result) in rx { - results.insert(contract_name.clone(), suite_result.clone()); - - let mut tests = suite_result.test_results.clone(); - println!(); - for warning in suite_result.warnings.iter() { - eprintln!("{} {warning}", Paint::yellow("Warning:").bold()); - } - if !tests.is_empty() { - let term = if tests.len() > 1 { "tests" } else { "test" }; - println!("Running {} {term} for {contract_name}", tests.len()); - } - for (name, result) in &mut tests { - short_test_result(name, result); - - // If the test failed, we want to stop processing the rest of the tests - if fail_fast && result.status == TestStatus::Failure { - break 'outer - } - - // We only display logs at level 2 and above - if verbosity >= 2 { - // We only decode logs from Hardhat and DS-style console events - let console_logs = decode_console_logs(&result.logs); - if !console_logs.is_empty() { - println!("Logs:"); - for log in console_logs { - println!(" {log}"); - } - println!(); - } - } - - if result.traces.is_empty() { - continue - } - - // Identify addresses in each trace - let mut builder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) - .with_events(local_identifier.events().cloned()) - .with_verbosity(verbosity); - - // Signatures are of no value for gas reports - if !gas_reporting { - builder = builder.with_signature_identifier(sig_identifier.clone()); - } - - let mut decoder = builder.build(); - - // Decode the traces - let mut decoded_traces = Vec::with_capacity(result.traces.len()); - for (kind, trace) in &mut result.traces { - decoder.identify(trace, &mut local_identifier); - decoder.identify(trace, &mut etherscan_identifier); - - // verbosity: - // - 0..3: nothing - // - 3: only display traces for failed tests - // - 4: also display the setup trace for failed tests - // - 5..: display all traces for all tests - let should_include = match kind { - TraceKind::Execution => { - (verbosity == 3 && result.status.is_failure()) || verbosity >= 4 - } - TraceKind::Setup => { - (verbosity == 4 && result.status.is_failure()) || verbosity >= 5 - } - TraceKind::Deployment => false, - }; - - // Decode the trace if we either need to build a gas report or we need to print it - if should_include || gas_reporting { - decoder.decode(trace).await; - } - - if should_include { - decoded_traces.push(trace.to_string()); - } - } - - if !decoded_traces.is_empty() { - println!("Traces:"); - decoded_traces.into_iter().for_each(|trace| println!("{trace}")); - } - - if gas_reporting { - gas_report.analyze(&result.traces); - } - } - let block_outcome = - TestOutcome::new([(contract_name.clone(), suite_result)].into(), allow_failure); - - total_passed += block_outcome.successes().count(); - total_failed += block_outcome.failures().count(); - total_skipped += block_outcome.skips().count(); - - println!("{}", block_outcome.summary()); - - if summary { - suite_results.push(block_outcome.clone()); - } - } - - if gas_reporting { - println!("{}", gas_report.finalize()); - } - - let num_test_suites = results.len(); - - if num_test_suites > 0 { - println!( - "{}", - format_aggregated_summary(num_test_suites, total_passed, total_failed, total_skipped) - ); - - if summary { - let mut summary_table = TestSummaryReporter::new(detailed); - println!("\n\nTest Summary:"); - summary_table.print_summary(suite_results); - } - } - - // reattach the task - let _results = handle.await?; - - trace!(target: "forge::test", "received {} results", results.len()); - - Ok(TestOutcome::new(results, allow_failure)) -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 5d39d48582ed4..59f73cda785df 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -27,7 +27,7 @@ use std::{ collections::{BTreeMap, HashSet}, iter::Iterator, path::Path, - sync::{mpsc::Sender, Arc}, + sync::{mpsc, Arc}, }; pub type DeployableContracts = BTreeMap)>; @@ -66,51 +66,34 @@ pub struct MultiContractRunner { impl MultiContractRunner { /// Returns the number of matching tests - pub fn matching_test_function_count(&self, filter: &impl TestFilter) -> usize { + pub fn matching_test_function_count(&self, filter: &dyn TestFilter) -> usize { self.matching_test_functions(filter).count() } - /// Returns all test functions matching the filter - pub fn get_matching_test_functions<'a>( - &'a self, - filter: &'a impl TestFilter, - ) -> Vec<&Function> { - self.matching_test_functions(filter).collect() - } - /// Returns all test functions matching the filter pub fn matching_test_functions<'a>( &'a self, - filter: &'a impl TestFilter, + filter: &'a dyn TestFilter, ) -> impl Iterator { self.contracts .iter() - .filter(|(id, _)| { - filter.matches_path(id.source.to_string_lossy()) && - filter.matches_contract(&id.name) - }) + .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) .flat_map(|(_, (abi, _, _))| { - abi.functions().filter(|func| filter.matches_test(func.signature())) + abi.functions().filter(|func| filter.matches_test(&func.signature())) }) } /// Get an iterator over all test contract functions that matches the filter path and contract /// name - fn filtered_tests<'a>( - &'a self, - filter: &'a impl TestFilter, - ) -> impl Iterator { + fn filtered_tests<'a>(&'a self, filter: &'a dyn TestFilter) -> impl Iterator { self.contracts .iter() - .filter(|(id, _)| { - filter.matches_path(id.source.to_string_lossy()) && - filter.matches_contract(&id.name) - }) + .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) .flat_map(|(_, (abi, _, _))| abi.functions()) } /// Get all test names matching the filter - pub fn get_tests(&self, filter: &impl TestFilter) -> Vec { + pub fn get_tests(&self, filter: &dyn TestFilter) -> Vec { self.filtered_tests(filter) .map(|func| func.name.clone()) .filter(|name| name.is_test()) @@ -118,16 +101,10 @@ impl MultiContractRunner { } /// Returns all matching tests grouped by contract grouped by file (file -> (contract -> tests)) - pub fn list( - &self, - filter: &impl TestFilter, - ) -> BTreeMap>> { + pub fn list(&self, filter: &dyn TestFilter) -> BTreeMap>> { self.contracts .iter() - .filter(|(id, _)| { - filter.matches_path(id.source.to_string_lossy()) && - filter.matches_contract(&id.name) - }) + .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) .filter(|(_, (abi, _, _))| abi.functions().any(|func| filter.matches_test(&func.name))) .map(|(id, (abi, _, _))| { let source = id.source.as_path().display().to_string(); @@ -135,7 +112,7 @@ impl MultiContractRunner { let tests = abi .functions() .filter(|func| func.name.is_test()) - .filter(|func| filter.matches_test(func.signature())) + .filter(|func| filter.matches_test(&func.signature())) .map(|func| func.name.clone()) .collect::>(); @@ -147,7 +124,35 @@ impl MultiContractRunner { }) } - /// Executes _all_ tests that match the given `filter` + /// Executes _all_ tests that match the given `filter`. + /// + /// The same as [`test`](Self::test), but returns the results instead of streaming them. + /// + /// Note that this method returns only when all tests have been executed. + pub async fn test_collect( + &mut self, + filter: &dyn TestFilter, + test_options: TestOptions, + ) -> BTreeMap { + self.test_iter(filter, test_options).await.collect() + } + + /// Executes _all_ tests that match the given `filter`. + /// + /// The same as [`test`](Self::test), but returns the results instead of streaming them. + /// + /// Note that this method returns only when all tests have been executed. + pub async fn test_iter( + &mut self, + filter: &dyn TestFilter, + test_options: TestOptions, + ) -> impl Iterator { + let (tx, rx) = mpsc::channel(); + self.test(filter, tx, test_options).await; + rx.into_iter() + } + + /// Executes _all_ tests that match the given `filter`. /// /// This will create the runtime based on the configured `evm` ops and create the `Backend` /// before executing all contracts and their tests in _parallel_. @@ -155,24 +160,20 @@ impl MultiContractRunner { /// Each Executor gets its own instance of the `Backend`. pub async fn test( &mut self, - filter: impl TestFilter, - stream_result: Option>, + filter: &dyn TestFilter, + stream_result: mpsc::Sender<(String, SuiteResult)>, test_options: TestOptions, - ) -> BTreeMap { + ) { trace!("running all tests"); // the db backend that serves all the data, each contract gets its own instance let db = Backend::spawn(self.fork.take()).await; - let filter = &filter; self.contracts .par_iter() - .filter(|(id, _)| { - filter.matches_path(id.source.to_string_lossy()) && - filter.matches_contract(&id.name) - }) + .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) .filter(|(_, (abi, _, _))| abi.functions().any(|func| filter.matches_test(&func.name))) - .map_with(stream_result, |stream_result, (id, (abi, deploy_code, libs))| { + .for_each_with(stream_result, |stream_result, (id, (abi, deploy_code, libs))| { let executor = ExecutorBuilder::new() .inspectors(|stack| { stack @@ -198,13 +199,8 @@ impl MultiContractRunner { ); trace!(contract=?identifier, "executed all tests in contract"); - if let Some(stream_result) = stream_result { - let _ = stream_result.send((identifier.clone(), result.clone())); - } - - (identifier, result) + let _ = stream_result.send((identifier, result)); }) - .collect() } #[instrument(skip_all, fields(name = %name))] @@ -216,7 +212,7 @@ impl MultiContractRunner { executor: Executor, deploy_code: Bytes, libs: &[Bytes], - filter: impl TestFilter, + filter: &dyn TestFilter, test_options: TestOptions, ) -> SuiteResult { let runner = ContractRunner::new( diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index a08678a3e540d..4417c2309545c 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -175,7 +175,7 @@ impl<'a> ContractRunner<'a> { /// Runs all tests for a contract whose names match the provided regular expression pub fn run_tests( mut self, - filter: impl TestFilter, + filter: &dyn TestFilter, test_options: TestOptions, known_contracts: Option<&ContractsByArtifact>, ) -> SuiteResult { @@ -247,7 +247,7 @@ impl<'a> ContractRunner<'a> { let functions: Vec<_> = self.contract.functions().collect(); let mut test_results = functions .par_iter() - .filter(|&&func| func.is_test() && filter.matches_test(func.signature())) + .filter(|&&func| func.is_test() && filter.matches_test(&func.signature())) .map(|&func| { let should_fail = func.is_test_fail(); let res = if func.is_fuzz_test() { @@ -265,7 +265,7 @@ impl<'a> ContractRunner<'a> { let identified_contracts = load_contracts(setup.traces.clone(), known_contracts); let results: Vec<_> = functions .par_iter() - .filter(|&&func| func.is_invariant_test() && filter.matches_test(func.signature())) + .filter(|&&func| func.is_invariant_test() && filter.matches_test(&func.signature())) .map(|&func| { let runner = test_options.invariant_runner(self.name, &func.name); let invariant_config = test_options.invariant_config(self.name, &func.name); diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 899f0711a5f45..ecd171ec6f93c 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -54,7 +54,7 @@ impl TestConfig { /// Executes the test runner pub async fn test(&mut self) -> BTreeMap { - self.runner.test(&self.filter, None, self.opts.clone()).await + self.runner.test_collect(&self.filter, self.opts.clone()).await } pub async fn run(&mut self) { diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index eba2372c1df7f..660ab06777858 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -9,7 +9,7 @@ use std::{collections::BTreeMap, env}; #[tokio::test(flavor = "multi_thread")] async fn test_core() { let mut runner = runner().await; - let results = runner.test(&Filter::new(".*", ".*", ".*core"), None, test_opts()).await; + let results = runner.test_collect(&Filter::new(".*", ".*", ".*core"), test_opts()).await; assert_multiple( &results, @@ -78,7 +78,7 @@ async fn test_core() { #[tokio::test(flavor = "multi_thread")] async fn test_linking() { let mut runner = runner().await; - let results = runner.test(&Filter::new(".*", ".*", ".*linking"), None, test_opts()).await; + let results = runner.test_collect(&Filter::new(".*", ".*", ".*linking"), test_opts()).await; assert_multiple( &results, @@ -111,7 +111,7 @@ async fn test_linking() { #[tokio::test(flavor = "multi_thread")] async fn test_logs() { let mut runner = runner().await; - let results = runner.test(&Filter::new(".*", ".*", ".*logs"), None, test_opts()).await; + let results = runner.test_collect(&Filter::new(".*", ".*", ".*logs"), test_opts()).await; assert_multiple( &results, @@ -674,7 +674,7 @@ async fn test_env_vars() { // test `setEnv` first, and confirm that it can correctly set environment variables, // so that we can use it in subsequent `env*` tests - runner.test(&Filter::new("testSetEnv", ".*", ".*"), None, test_opts()).await; + let _ = runner.test_collect(&Filter::new("testSetEnv", ".*", ".*"), test_opts()).await; let env_var_key = "_foundryCheatcodeSetEnvTestKey"; let env_var_val = "_foundryCheatcodeSetEnvTestVal"; let res = env::var(env_var_key); @@ -689,7 +689,10 @@ Reason: `setEnv` failed to set an environment variable `{env_var_key}={env_var_v async fn test_doesnt_run_abstract_contract() { let mut runner = runner().await; let results = runner - .test(&Filter::new(".*", ".*", ".*Abstract.t.sol".to_string().as_str()), None, test_opts()) + .test_collect( + &Filter::new(".*", ".*", ".*Abstract.t.sol".to_string().as_str()), + test_opts(), + ) .await; assert!(results.get("core/Abstract.t.sol:AbstractTestBase").is_none()); assert!(results.get("core/Abstract.t.sol:AbstractTest").is_some()); @@ -698,7 +701,7 @@ async fn test_doesnt_run_abstract_contract() { #[tokio::test(flavor = "multi_thread")] async fn test_trace() { let mut runner = tracing_runner().await; - let suite_result = runner.test(&Filter::new(".*", ".*", ".*trace"), None, test_opts()).await; + let suite_result = runner.test_collect(&Filter::new(".*", ".*", ".*trace"), test_opts()).await; // TODO: This trace test is very basic - it is probably a good candidate for snapshot // testing. diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 814d1b09ebd27..f34cc59bb3c7c 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -13,13 +13,12 @@ use foundry_test_utils::Filter; async fn test_cheats_fork_revert() { let mut runner = runner().await; let suite_result = runner - .test( + .test_collect( &Filter::new( "testNonExistingContractRevert", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork"), ), - None, test_opts(), ) .await; diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index d16befa350647..66f2b4d38287b 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -11,11 +11,10 @@ async fn test_fuzz() { let mut runner = runner().await; let suite_result = runner - .test( + .test_collect( &Filter::new(".*", ".*", ".*fuzz/") .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)") .exclude_paths("invariant"), - None, test_opts(), ) .await; @@ -62,7 +61,7 @@ async fn test_fuzz_collection() { runner.test_options = opts.clone(); let results = - runner.test(&Filter::new(".*", ".*", ".*fuzz/FuzzCollection.t.sol"), None, opts).await; + runner.test_collect(&Filter::new(".*", ".*", ".*fuzz/FuzzCollection.t.sol"), opts).await; assert_multiple( &results, diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 821077b704e61..0001bea298da2 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -20,7 +20,7 @@ async fn inline_config_run_fuzz() { let mut runner = runner().await; runner.test_options = opts.clone(); - let result = runner.test(&filter, None, opts).await; + let result = runner.test_collect(&filter, opts).await; let suite_result: &SuiteResult = result.get("inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); let test_result: &TestResult = @@ -44,7 +44,7 @@ async fn inline_config_run_invariant() { let mut runner = runner().await; runner.test_options = opts.clone(); - let result = runner.test(&filter, None, opts).await; + let result = runner.test_collect(&filter, opts).await; let suite_result_1 = result.get(&format!("{ROOT}:InvariantInlineConf")).expect("Result exists"); let suite_result_2 = diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 587eedaf8bc29..617fa7ab29a1a 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -11,9 +11,8 @@ async fn test_invariant() { let mut runner = runner().await; let results = runner - .test( + .test_collect( &Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"), - None, test_opts(), ) .await; @@ -132,9 +131,8 @@ async fn test_invariant_override() { runner.test_options = opts.clone(); let results = runner - .test( + .test_collect( &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantReentrancy.t.sol"), - None, opts, ) .await; @@ -159,9 +157,8 @@ async fn test_invariant_fail_on_revert() { runner.test_options = opts.clone(); let results = runner - .test( + .test_collect( &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantHandlerFailure.t.sol"), - None, opts, ) .await; @@ -192,9 +189,8 @@ async fn test_invariant_storage() { runner.test_options = opts.clone(); let results = runner - .test( + .test_collect( &Filter::new(".*", ".*", ".*fuzz/invariant/storage/InvariantStorageTest.t.sol"), - None, opts, ) .await; @@ -223,9 +219,8 @@ async fn test_invariant_shrink() { runner.test_options = opts.clone(); let results = runner - .test( + .test_collect( &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"), - None, opts, ) .await; diff --git a/crates/test-utils/src/filter.rs b/crates/test-utils/src/filter.rs index c04eb2a39a6fd..fb07237f22af2 100644 --- a/crates/test-utils/src/filter.rs +++ b/crates/test-utils/src/filter.rs @@ -1,5 +1,6 @@ use foundry_common::TestFilter; use regex::Regex; +use std::path::Path; pub struct Filter { test_regex: Regex, @@ -60,25 +61,27 @@ impl Filter { } impl TestFilter for Filter { - fn matches_test(&self, test_name: impl AsRef) -> bool { - let test_name = test_name.as_ref(); - if let Some(ref exclude) = self.exclude_tests { + fn matches_test(&self, test_name: &str) -> bool { + if let Some(exclude) = &self.exclude_tests { if exclude.is_match(test_name) { - return false + return false; } } self.test_regex.is_match(test_name) } - fn matches_contract(&self, contract_name: impl AsRef) -> bool { - self.contract_regex.is_match(contract_name.as_ref()) + fn matches_contract(&self, contract_name: &str) -> bool { + self.contract_regex.is_match(contract_name) } - fn matches_path(&self, path: impl AsRef) -> bool { - let path = path.as_ref(); - if let Some(ref exclude) = self.exclude_paths { + fn matches_path(&self, path: &Path) -> bool { + let Some(path) = path.to_str() else { + return false; + }; + + if let Some(exclude) = &self.exclude_paths { if exclude.is_match(path) { - return false + return false; } } self.path_regex.is_match(path) From 0928844d33fde5c78881e2d1e8718d1d5c0fde60 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 8 Dec 2023 13:59:17 +0100 Subject: [PATCH 0387/1963] chore: update contributing.md (#6552) --- CONTRIBUTING.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2bf43604dfc4..859aaa6d6e0dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,8 +4,6 @@ Thanks for your interest in improving Foundry! There are multiple opportunities to contribute at any level. It doesn't matter if you are just getting started with Rust or are the most weathered expert, we can use your help. -**No contribution is too small and all contributions are valued.** - This document will help you get started. **Do not let the document intimidate you**. It should be considered as a guide to help you navigate the process. @@ -33,6 +31,11 @@ There are fundamentally four ways an individual can contribute: **Anybody can participate in any stage of contribution**. We urge you to participate in the discussion around bugs and participate in reviewing PRs. +### Contributions Related to Spelling and Grammar + +At this time, we will not be accepting contributions that only fix spelling or grammatical errors in documentation, code or +elsewhere. + ### Asking for help If you have reviewed existing documentation and still have questions, or you are having problems, you can get help in the following ways: From 18a7104bcae31ff07f69f908768c310cae754577 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 8 Dec 2023 14:43:43 +0100 Subject: [PATCH 0388/1963] chore: bump foundry-block-explorers (#6553) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 90423c3bdd76e..d1b59596ebc24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2624,9 +2624,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47331ff0955a60df66db753f5dcfe3ca0275abe192e58c9eb6d0d8c1a131e604" +checksum = "43408b384e5888fed99a5f25f86cef7e19dca10c750e948cbeb219f59847712f" dependencies = [ "alloy-chains", "alloy-json-abi", diff --git a/Cargo.toml b/Cargo.toml index 19a26c63bb2ed..f04f0f55671a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,7 +123,7 @@ foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } -foundry-block-explorers = { version = "0.1.1", default-features = false } +foundry-block-explorers = { version = "0.1.2", default-features = false } foundry-compilers = { version = "0.1.1", default-features = false } ## revm From acbd53fb32ab1bd1059997663468e689455a89c7 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 8 Dec 2023 23:47:17 +0100 Subject: [PATCH 0389/1963] chore: better error for missing contract bytecode (#6551) --- crates/common/src/compile.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index eb11f0ac167c2..8ecf37fccca6e 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -453,7 +453,12 @@ pub async fn compile_from_source( .map(|(aid, art)| { (aid, art.source_file().expect("no source file").id, art.into_contract_bytecode()) }) - .expect("there should be a contract with bytecode"); + .ok_or_else(|| { + eyre::eyre!( + "Unable to find bytecode in compiled output for contract: {}", + metadata.contract_name + ) + })?; let bytecode = compact_to_contract(contract)?; root.close()?; From e972bf70412e51b1e15041341f7c29725bb6ac17 Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Sat, 9 Dec 2023 17:22:23 -0800 Subject: [PATCH 0390/1963] feat(forge): account access cheatcode accounts for extcode* and balance opcodes (#6545) * account access cheatcode accounts for ext* opcodes * run forge fmt * add balance to accountaccesskind --- crates/cheatcodes/spec/src/vm.rs | 8 ++ crates/cheatcodes/src/inspector.rs | 54 ++++++++++++++ testdata/cheats/RecordAccountAccesses.t.sol | 81 ++++++++++++++++++--- testdata/cheats/Vm.sol | 2 +- 4 files changed, 134 insertions(+), 11 deletions(-) diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index a9421d087daa8..50bdd26f3aa43 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -53,6 +53,14 @@ interface Vm { SelfDestruct, /// Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess). Resume, + /// The account's balance was read. + Balance, + /// The account's codesize was read. + Extcodesize, + /// The account's code was copied. + Extcodecopy, + /// The account's codehash was read. + Extcodehash, } /// An Ethereum log. Returned by `getRecordedLogs`. diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index b154955330aff..390c16fb92f57 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -505,6 +505,60 @@ impl Inspector for Cheatcodes { data.journaled_state.depth(), ); } + // Record account accesses via the EXT family of opcodes + opcode::EXTCODECOPY | + opcode::EXTCODESIZE | + opcode::EXTCODEHASH | + opcode::BALANCE => { + let kind = match interpreter.current_opcode() { + opcode::EXTCODECOPY => crate::Vm::AccountAccessKind::Extcodecopy, + opcode::EXTCODESIZE => crate::Vm::AccountAccessKind::Extcodesize, + opcode::EXTCODEHASH => crate::Vm::AccountAccessKind::Extcodehash, + opcode::BALANCE => crate::Vm::AccountAccessKind::Balance, + _ => unreachable!(), + }; + let address = Address::from_word(B256::from(try_or_continue!(interpreter + .stack() + .peek(0)))); + let balance; + let initialized; + if let Ok((acc, _)) = data.journaled_state.load_account(address, data.db) { + initialized = acc.info.exists(); + balance = acc.info.balance; + } else { + initialized = false; + balance = U256::ZERO; + } + let account_access = crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), + }, + accessor: interpreter.contract().address, + account: address, + kind, + initialized, + oldBalance: balance, + newBalance: balance, + value: U256::ZERO, + data: vec![], + reverted: false, + deployedCode: vec![], + storageAccesses: vec![], + }; + let access = AccountAccess { + access: account_access, + // use current depth; EXT* opcodes are not creating new contexts + depth: data.journaled_state.depth(), + }; + // Record the EXT* call as an account access at the current depth + // (future storage accesses will be recorded in a new "Resume" context) + if let Some(last) = recorded_account_diffs_stack.last_mut() { + last.push(access); + } else { + recorded_account_diffs_stack.push(vec![access]); + } + } _ => (), } } diff --git a/testdata/cheats/RecordAccountAccesses.t.sol b/testdata/cheats/RecordAccountAccesses.t.sol index 4ab707edbfac0..15c1780b1a358 100644 --- a/testdata/cheats/RecordAccountAccesses.t.sol +++ b/testdata/cheats/RecordAccountAccesses.t.sol @@ -121,6 +121,19 @@ contract NestedRunner { } } +/// Helper contract that uses all three EXT* opcodes on a given address +contract ExtChecker { + function checkExts(address a) external { + assembly { + let x := extcodesize(a) + let y := extcodehash(a) + extcodecopy(a, x, y, 0) + // sstore to check that storage accesses are correctly stored in a new access with a "resume" context + sstore(0, balance(a)) + } + } +} + /// @notice Helper contract that writes to storage in a nested call contract NestedStorer { mapping(bytes32 key => uint256 value) slots; @@ -196,6 +209,7 @@ contract RecordAccountAccessesTest is DSTest { Create2or create2or; StorageAccessor test1; StorageAccessor test2; + ExtChecker extChecker; function setUp() public { runner = new NestedRunner(); @@ -203,6 +217,7 @@ contract RecordAccountAccessesTest is DSTest { create2or = new Create2or(); test1 = new StorageAccessor(); test2 = new StorageAccessor(); + extChecker = new ExtChecker(); } function testStorageAccessDelegateCall() public { @@ -211,7 +226,7 @@ contract RecordAccountAccessesTest is DSTest { cheats.startStateDiffRecording(); address(proxy).call(abi.encodeCall(StorageAccessor.read, bytes32(uint256(1234)))); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 2, "incorrect length"); @@ -246,7 +261,7 @@ contract RecordAccountAccessesTest is DSTest { two.write(bytes32(uint256(5678)), bytes32(uint256(123469))); two.write(bytes32(uint256(5678)), bytes32(uint256(1234))); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 4, "incorrect length"); assertEq(called[0].storageAccesses.length, 1, "incorrect storage length"); @@ -317,7 +332,7 @@ contract RecordAccountAccessesTest is DSTest { // contract calls to self in constructor SelfCaller caller = new SelfCaller{value: 2 ether}("hello2 world2"); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 6); assertEq( called[0], @@ -430,7 +445,7 @@ contract RecordAccountAccessesTest is DSTest { uint256 initBalance = address(this).balance; cheats.startStateDiffRecording(); try this.revertingCall{value: 1 ether}(address(1234), "") {} catch {} - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 2); assertEq( called[0], @@ -485,7 +500,7 @@ contract RecordAccountAccessesTest is DSTest { /// @param shouldRevert Whether the first call should revert function runNested(bool shouldRevert, bool expectFirstCall) public { try runner.run{value: 1 ether}(shouldRevert) {} catch {} - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 7 + toUint(expectFirstCall), "incorrect length"); uint256 startingIndex = toUint(expectFirstCall); @@ -737,7 +752,7 @@ contract RecordAccountAccessesTest is DSTest { function testNestedStorage() public { cheats.startStateDiffRecording(); nestedStorer.run(); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 3, "incorrect account access length"); assertEq(called[0].storageAccesses.length, 2, "incorrect run storage length"); @@ -858,7 +873,7 @@ contract RecordAccountAccessesTest is DSTest { bytes memory creationCode = abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(true)); address hypotheticalStorer = deriveCreate2Address(address(create2or), bytes32(0), keccak256(creationCode)); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 3, "incorrect account access length"); assertEq(toUint(called[0].kind), toUint(Vm.AccountAccessKind.Create), "incorrect kind"); assertEq(toUint(called[1].kind), toUint(Vm.AccountAccessKind.Call), "incorrect kind"); @@ -967,7 +982,7 @@ contract RecordAccountAccessesTest is DSTest { try create2or.create2(bytes32(0), creationCode) {} catch {} address hypotheticalAddress = deriveCreate2Address(address(create2or), bytes32(0), keccak256(creationCode)); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 3, "incorrect length"); assertEq( called[1], @@ -1013,7 +1028,7 @@ contract RecordAccountAccessesTest is DSTest { this.startRecordingFromLowerDepth(); address a = address(new SelfDestructor{value: 1 ether}(address(this))); address b = address(new SelfDestructor{value: 1 ether}(address(bytes20("doesn't exist yet")))); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 5, "incorrect length"); assertEq( called[1], @@ -1093,12 +1108,58 @@ contract RecordAccountAccessesTest is DSTest { StorageAccessor a = new StorageAccessor(); cheats.stopBroadcast(); - Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 1, "incorrect length"); assertEq(toUint(called[0].kind), toUint(Vm.AccountAccessKind.Create)); assertEq(called[0].account, address(a)); } + /// @notice Test that EXT* opcodes are recorded as account accesses + function testExtOpcodes() public { + cheats.startStateDiffRecording(); + extChecker.checkExts(address(1234)); + Vm.AccountAccess[] memory called = cheats.stopAndReturnStateDiff(); + assertEq(called.length, 7, "incorrect length"); + // initial solidity extcodesize check for calling extChecker + assertEq(toUint(called[0].kind), toUint(Vm.AccountAccessKind.Extcodesize)); + // call to extChecker + assertEq(toUint(called[1].kind), toUint(Vm.AccountAccessKind.Call)); + // extChecker checks + assertEq(toUint(called[2].kind), toUint(Vm.AccountAccessKind.Extcodesize)); + assertEq(toUint(called[3].kind), toUint(Vm.AccountAccessKind.Extcodehash)); + assertEq(toUint(called[4].kind), toUint(Vm.AccountAccessKind.Extcodecopy)); + assertEq(toUint(called[5].kind), toUint(Vm.AccountAccessKind.Balance)); + // resume of extChecker to hold SSTORE access + assertEq(toUint(called[6].kind), toUint(Vm.AccountAccessKind.Resume)); + assertEq(called[6].storageAccesses.length, 1, "incorrect length"); + } + + /** + * @notice Filter out extcodesize account accesses for legacy tests written before + * EXT* opcodes were supported. + */ + function filterExtcodesizeForLegacyTests(Vm.AccountAccess[] memory inArr) + internal + pure + returns (Vm.AccountAccess[] memory out) + { + // allocate max length for out array + out = new Vm.AccountAccess[](inArr.length); + // track end size + uint256 size; + for (uint256 i = 0; i < inArr.length; ++i) { + // only append if not extcodesize + if (inArr[i].kind != Vm.AccountAccessKind.Extcodesize) { + out[size] = inArr[i]; + ++size; + } + } + // manually truncate out array + assembly { + mstore(out, size) + } + } + function startRecordingFromLowerDepth() external { cheats.startStateDiffRecording(); assembly { diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 4fc5c3ce51b29..ab301787465bb 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -7,7 +7,7 @@ pragma solidity ^0.8.4; interface Vm { error CheatcodeError(string message); enum CallerMode { None, Broadcast, RecurrentBroadcast, Prank, RecurrentPrank } - enum AccountAccessKind { Call, DelegateCall, CallCode, StaticCall, Create, SelfDestruct, Resume } + enum AccountAccessKind { Call, DelegateCall, CallCode, StaticCall, Create, SelfDestruct, Resume, Balance, Extcodesize, Extcodecopy, Extcodehash } 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; } From 03f60264a6c3a0fbdc98839f5585c37db31199bb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 10 Dec 2023 04:30:24 +0100 Subject: [PATCH 0391/1963] chore(deps): weekly `cargo update` (#6555) * chore(deps): weekly `cargo update` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating anstream v0.6.4 -> v0.6.5 Updating anstyle-parse v0.2.2 -> v0.2.3 Updating anstyle-query v1.0.0 -> v1.0.2 Updating anstyle-wincon v3.0.1 -> v3.0.2 Updating clap v4.4.10 -> v4.4.11 Updating clap_builder v4.4.9 -> v4.4.11 Updating eyre v0.6.9 -> v0.6.10 Updating filetime v0.2.22 -> v0.2.23 Updating gix-trace v0.1.3 -> v0.1.4 Updating gix-utils v0.1.5 -> v0.1.6 Updating http-body v0.4.5 -> v0.4.6 Updating itoa v1.0.9 -> v1.0.10 Updating mio v0.8.9 -> v0.8.10 Updating once_cell v1.18.0 -> v1.19.0 Updating openssl v0.10.60 -> v0.10.61 Updating openssl-sys v0.9.96 -> v0.9.97 Updating ordered-float v4.1.1 -> v4.2.0 Updating portable-atomic v1.5.1 -> v1.6.0 Removing redox_syscall v0.3.5 Updating ring v0.17.6 -> v0.17.7 Updating rustix v0.38.26 -> v0.38.28 Updating rustls v0.21.9 -> v0.21.10 Updating ryu v1.0.15 -> v1.0.16 Updating secp256k1-sys v0.9.0 -> v0.9.1 Updating tokio v1.34.0 -> v1.35.0 Updating try-lock v0.2.4 -> v0.2.5 Updating unicode-bidi v0.3.13 -> v0.3.14 Updating winnow v0.5.19 -> v0.5.26 Updating zerocopy v0.7.28 -> v0.7.30 Updating zerocopy-derive v0.7.28 -> v0.7.30 * fix breakage * test * cheats * cheats2 * cheats3 * msg * msg2 * fix --------- Co-authored-by: mattsse Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- .config/nextest.toml | 6 +- Cargo.lock | 157 ++++++++++----------- crates/cheatcodes/assets/cheatcodes.json | 16 +++ crates/cheatcodes/spec/src/lib.rs | 2 +- crates/cheatcodes/src/env.rs | 23 +-- crates/doc/src/preprocessor/deployments.rs | 28 ++-- testdata/repros/Issue6070.t.sol | 2 +- 7 files changed, 120 insertions(+), 114 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 4629c63f29c3f..b471b448c2cc0 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -6,6 +6,10 @@ slow-timeout = { period = "1m", terminate-after = 3 } filter = "test(/ext_integration|can_test_forge_std/)" slow-timeout = { period = "5m", terminate-after = 4 } +[[profile.default.overrides]] +filter = "package(foundry-cheatcodes-spec)" +retries = 0 + [profile.heavy] retries = 1 -slow-timeout = { period = "120m", terminate-after = 1} \ No newline at end of file +slow-timeout = { period = "120m", terminate-after = 1 } diff --git a/Cargo.lock b/Cargo.lock index d1b59596ebc24..b162242612b98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -246,9 +246,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" dependencies = [ "anstyle", "anstyle-parse", @@ -266,30 +266,30 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1160,9 +1160,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.10" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.9" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -2347,9 +2347,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f656be11ddf91bd709454d15d5bd896fbaf4cc3314e69349e4d1569f5b46cd" +checksum = "8bbb8258be8305fb0237d7b295f47bb24ff1b136a535f473baf40e70468515aa" dependencies = [ "indenter", "once_cell", @@ -2445,14 +2445,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", + "redox_syscall", + "windows-sys 0.52.0", ] [[package]] @@ -3414,15 +3414,15 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b6d623a1152c3facb79067d6e2ecdae48130030cf27d6eb21109f13bd7b836" +checksum = "b686a35799b53a9825575ca3f06481d0a053a409c4d97ffcf5ddd67a8760b497" [[package]] name = "gix-utils" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b85d89dc728613e26e0ed952a19583744e7f5240fcd4aa30d6c824ffd8b52f0f" +checksum = "9f82c41937f00e15a1f6cb0b55307f0ca1f77f4407ff2bf440be35aa688c6a3e" dependencies = [ "fastrand", ] @@ -3656,9 +3656,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -3737,7 +3737,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.9", + "rustls 0.21.10", "tokio", "tokio-rustls 0.24.1", ] @@ -3976,9 +3976,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" @@ -4162,7 +4162,7 @@ checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ "bitflags 2.4.1", "libc", - "redox_syscall 0.4.1", + "redox_syscall", ] [[package]] @@ -4420,9 +4420,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", @@ -4674,9 +4674,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -4728,9 +4728,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.60" +version = "0.10.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" +checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -4760,9 +4760,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.96" +version = "0.9.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" +checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" dependencies = [ "cc", "libc", @@ -4778,9 +4778,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "4.1.1" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "536900a8093134cf9ccf00a27deb3532421099e958d9dd431135d0c7543ca1e8" +checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ "num-traits", ] @@ -4880,7 +4880,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", "windows-targets 0.48.5", ] @@ -5213,9 +5213,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "powerfmt" @@ -5556,15 +5556,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -5674,7 +5665,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.9", + "rustls 0.21.10", "rustls-native-certs", "rustls-pemfile", "serde", @@ -5774,9 +5765,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.6" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684d5e6e18f669ccebf64a92236bb7db9a34f07be010e3627368182027180866" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", "getrandom 0.2.11", @@ -6000,9 +5991,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.26" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags 2.4.1", "errno", @@ -6025,12 +6016,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.9" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", - "ring 0.17.6", + "ring 0.17.7", "rustls-webpki", "sct", ] @@ -6062,7 +6053,7 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.6", + "ring 0.17.7", "untrusted 0.9.0", ] @@ -6109,9 +6100,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "salsa20" @@ -6212,7 +6203,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.6", + "ring 0.17.7", "untrusted 0.9.0", ] @@ -6241,9 +6232,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09e67c467c38fd24bd5499dc9a18183b31575c12ee549197e3e20d57aa4fe3b7" +checksum = "4dd97a086ec737e30053fd5c46f097465d25bb81dd3608825f65298c4c98be83" dependencies = [ "cc", ] @@ -6851,7 +6842,7 @@ checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", + "redox_syscall", "rustix", "windows-sys 0.48.0", ] @@ -7016,9 +7007,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.34.0" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" dependencies = [ "backtrace", "bytes", @@ -7071,7 +7062,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.9", + "rustls 0.21.10", "tokio", ] @@ -7095,7 +7086,7 @@ dependencies = [ "futures-util", "log", "native-tls", - "rustls 0.21.9", + "rustls 0.21.10", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -7373,9 +7364,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" @@ -7391,7 +7382,7 @@ dependencies = [ "log", "native-tls", "rand 0.8.5", - "rustls 0.21.9", + "rustls 0.21.10", "sha1", "thiserror", "url", @@ -7449,9 +7440,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-bom" @@ -7737,7 +7728,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.6", + "ring 0.17.7", "untrusted 0.9.0", ] @@ -8008,9 +7999,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.19" +version = "0.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +checksum = "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff" dependencies = [ "memchr", ] @@ -8073,18 +8064,18 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.28" +version = "0.7.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e" +checksum = "306dca4455518f1f31635ec308b6b3e4eb1b11758cefafc782827d0aa7acb5c7" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.28" +version = "0.7.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b" +checksum = "be912bf68235a88fbefd1b73415cb218405958d1655b2ece9035a19920bdf6ba" dependencies = [ "proc-macro2", "quote", diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index c835e46339970..3c814e5cafcd7 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -65,6 +65,22 @@ { "name": "Resume", "description": "Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess)." + }, + { + "name": "Balance", + "description": "The account's balance was read." + }, + { + "name": "Extcodesize", + "description": "The account's codesize was read." + }, + { + "name": "Extcodecopy", + "description": "The account's code was copied." + }, + { + "name": "Extcodehash", + "description": "The account's codehash was read." } ] } diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index 9e0cf12dde025..f524e458d2fed 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -164,7 +164,7 @@ interface Vm {{ eprintln!("\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n", file.display()); if std::env::var("CI").is_ok() { - eprintln!(" NOTE: run `cargo test` locally and commit the updated files\n"); + eprintln!(" NOTE: run `cargo cheats` locally and commit the updated files\n"); } if let Some(parent) = file.parent() { let _ = fs::create_dir_all(parent); diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index b4a4a9a0c1f96..2b8d061f2fbeb 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -267,20 +267,11 @@ fn get_env(key: &str) -> Result { /// doesn't leak the value. fn map_env_err<'a>(key: &'a str, value: &'a str) -> impl FnOnce(Error) -> Error + 'a { move |e| { - let e = e.to_string(); // failed parsing \"xy(123)\" as type `uint256`: parser error:\nxy(123)\n ^\nexpected at - // least one digit - let mut e = e.as_str(); - // cut off the message to not leak the value - let sep = if let Some(idx) = e.rfind(" as type `") { - e = &e[idx..]; - "" - } else { - ": " - }; - // ensure we're also removing the value from the underlying alloy parser error message, See - // [alloy_dyn_abi::parser::Error::parser] - let e = e.replacen(&format!("\n{value}\n"), &format!("\n${key}\n"), 1); - fmt_err!("failed parsing ${key}{sep}{e}") + // failed parsing as type `uint256`: parser error: + // + // ^ + // expected at least one digit + Error::from(e.to_string().replace(value, &format!("${key}"))) } } @@ -291,12 +282,12 @@ mod tests { #[test] fn parse_env_uint() { let key = "parse_env_uint"; - let value = "xy(123)"; + let value = "123xyz"; env::set_var(key, value); let err = env(key, &DynSolType::Uint(256)).unwrap_err().to_string(); assert!(!err.contains(value)); - assert_eq!(err, "failed parsing $parse_env_uint as type `uint256`: parser error:\n$parse_env_uint\n ^\nexpected at least one digit"); + assert_eq!(err.matches("$parse_env_uint").count(), 2, "{err:?}"); env::remove_var(key); } } diff --git a/crates/doc/src/preprocessor/deployments.rs b/crates/doc/src/preprocessor/deployments.rs index b081ed59a0d71..aaef8e42501f8 100644 --- a/crates/doc/src/preprocessor/deployments.rs +++ b/crates/doc/src/preprocessor/deployments.rs @@ -1,7 +1,10 @@ use super::{Preprocessor, PreprocessorId}; use crate::{Document, PreprocessorOutput}; use alloy_primitives::Address; -use std::{fs, path::PathBuf}; +use std::{ + fs, + path::{Path, PathBuf}, +}; /// [Deployments] preprocessor id. pub const DEPLOYMENTS_ID: PreprocessorId = PreprocessorId("deployments"); @@ -33,20 +36,21 @@ impl Preprocessor for Deployments { fn preprocess(&self, documents: Vec) -> Result, eyre::Error> { let deployments_dir = - self.root.join(self.deployments.as_ref().unwrap_or(&PathBuf::from("deployments"))); + self.root.join(self.deployments.as_deref().unwrap_or(Path::new("deployments"))); // Gather all networks from the deployments directory. let networks = fs::read_dir(&deployments_dir)? - .map(|x| { - x.map(|y| { - if y.file_type()?.is_dir() { - Ok(y.file_name().into_string().map_err(|e| { - eyre::eyre!("Failed to extract directory name: {:?}", e) - })?) - } else { - eyre::bail!("Not a directory.") - } - })? + .map(|entry| { + let entry = entry?; + let path = entry.path(); + if entry.file_type()?.is_dir() { + entry + .file_name() + .into_string() + .map_err(|e| eyre::eyre!("failed to extract directory name: {e:?}")) + } else { + eyre::bail!("not a directory: {}", path.display()) + } }) .collect::, _>>()?; diff --git a/testdata/repros/Issue6070.t.sol b/testdata/repros/Issue6070.t.sol index dc068f22cf406..b96c42f60c4bc 100644 --- a/testdata/repros/Issue6070.t.sol +++ b/testdata/repros/Issue6070.t.sol @@ -11,7 +11,7 @@ contract Issue6066Test is DSTest { function testNonPrefixed() public { vm.setEnv("__FOUNDRY_ISSUE_6066", "abcd"); vm.expectRevert( - "failed parsing $__FOUNDRY_ISSUE_6066 as type `uint256`: missing hex prefix (\"0x\") for hex string" + "failed parsing \"$__FOUNDRY_ISSUE_6066\" as type `uint256`: missing hex prefix (\"0x\") for hex string" ); uint256 x = vm.envUint("__FOUNDRY_ISSUE_6066"); } From aa9c49f878b0bf2554756d2c137b2d748275831c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 10 Dec 2023 05:00:05 +0100 Subject: [PATCH 0392/1963] fix(cheatcodes): env error formatting (#6557) --- crates/cheatcodes/src/env.rs | 8 +++++--- testdata/repros/Issue6070.t.sol | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index 2b8d061f2fbeb..d6aaea149ee3c 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -271,7 +271,10 @@ fn map_env_err<'a>(key: &'a str, value: &'a str) -> impl FnOnce(Error) -> Error // // ^ // expected at least one digit - Error::from(e.to_string().replace(value, &format!("${key}"))) + let mut e = e.to_string(); + e = e.replacen(&format!("\"{value}\""), &format!("${key}"), 1); + e = e.replacen(&format!("\n{value}\n"), &format!("\n${key}\n"), 1); + Error::from(e) } } @@ -282,11 +285,10 @@ mod tests { #[test] fn parse_env_uint() { let key = "parse_env_uint"; - let value = "123xyz"; + let value = "t"; env::set_var(key, value); let err = env(key, &DynSolType::Uint(256)).unwrap_err().to_string(); - assert!(!err.contains(value)); assert_eq!(err.matches("$parse_env_uint").count(), 2, "{err:?}"); env::remove_var(key); } diff --git a/testdata/repros/Issue6070.t.sol b/testdata/repros/Issue6070.t.sol index b96c42f60c4bc..dc068f22cf406 100644 --- a/testdata/repros/Issue6070.t.sol +++ b/testdata/repros/Issue6070.t.sol @@ -11,7 +11,7 @@ contract Issue6066Test is DSTest { function testNonPrefixed() public { vm.setEnv("__FOUNDRY_ISSUE_6066", "abcd"); vm.expectRevert( - "failed parsing \"$__FOUNDRY_ISSUE_6066\" as type `uint256`: missing hex prefix (\"0x\") for hex string" + "failed parsing $__FOUNDRY_ISSUE_6066 as type `uint256`: missing hex prefix (\"0x\") for hex string" ); uint256 x = vm.envUint("__FOUNDRY_ISSUE_6066"); } From ef1989d2bacef05fefc41d019e803b5793cb1b56 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 10 Dec 2023 13:02:50 +0100 Subject: [PATCH 0393/1963] test: add snapshot revert test (#6560) --- crates/anvil/tests/it/fork.rs | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 444b234831511..15e5a3756dbb9 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -334,6 +334,56 @@ async fn test_fork_snapshotting_repeated() { assert!(!api.evm_revert(snapshot).await.unwrap()); } +// +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_snapshotting_blocks() { + let (api, handle) = spawn(fork_config()).await; + let provider = handle.http_provider(); + + // create a snapshot + let snapshot = api.evm_snapshot().await.unwrap(); + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let from = accounts[0].address(); + let to = accounts[1].address(); + let block_number = provider.get_block_number().await.unwrap(); + + let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); + let balance_before = provider.get_balance(to, None).await.unwrap(); + let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + + // send the transaction + let tx = TransactionRequest::new().to(to).value(amount).from(from); + let _ = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + + let block_number_after = provider.get_block_number().await.unwrap(); + assert_eq!(block_number_after, block_number + 1); + + let nonce = provider.get_transaction_count(from, None).await.unwrap(); + assert_eq!(nonce, initial_nonce + 1); + let to_balance = provider.get_balance(to, None).await.unwrap(); + assert_eq!(balance_before.saturating_add(amount), to_balance); + + // revert snapshot + assert!(api.evm_revert(snapshot).await.unwrap()); + + assert_eq!(initial_nonce, provider.get_transaction_count(from, None).await.unwrap()); + let block_number_after = provider.get_block_number().await.unwrap(); + assert_eq!(block_number_after, block_number); + + // repeat transaction + let _ = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let nonce = provider.get_transaction_count(from, None).await.unwrap(); + assert_eq!(nonce, initial_nonce + 1); + + // revert again: nothing to revert since snapshot gone + assert!(!api.evm_revert(snapshot).await.unwrap()); + let nonce = provider.get_transaction_count(from, None).await.unwrap(); + assert_eq!(nonce, initial_nonce + 1); + let block_number_after = provider.get_block_number().await.unwrap(); + assert_eq!(block_number_after, block_number + 1); +} + /// tests that the remote state and local state are kept separate. /// changes don't make into the read only Database that holds the remote state, which is flushed to /// a cache file. From 22f3d70c9340f25a9e4316a828ed63769169e8e5 Mon Sep 17 00:00:00 2001 From: Valentin B <703631+beeb@users.noreply.github.com> Date: Sun, 10 Dec 2023 19:57:57 +0100 Subject: [PATCH 0394/1963] chore: add nix flake for dev shell (#6412) * chore: add nix flake for dev shell * chore: use same flake-utils input for solc overlay * chore: add macOS deps to nix flake --- flake.lock | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 56 +++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000000..a0330581343f0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,109 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1700538105, + "narHash": "sha256-uZhOCmwv8VupEmPZm3erbr9XXmyg7K67Ul3+Rx2XMe0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "51a01a7e5515b469886c120e38db325c96694c2f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", + "solc": "solc" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700705722, + "narHash": "sha256-cFfTFToYTeRQtdNqo53+E+G5RxPiTbWusGq+MpZSpbA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "67998ae1cabcf683cb115c5ab01ae4ff067e3d60", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "solc": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700417764, + "narHash": "sha256-ssdwqKWkYUd/Nr6P9veR4D/PrtlwGJkPoUQoEgVJVpo=", + "owner": "hellwolf", + "repo": "solc.nix", + "rev": "80d2e38e98e589872b0dc3770f838c4be847305e", + "type": "github" + }, + "original": { + "owner": "hellwolf", + "repo": "solc.nix", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000000..5abae8e648bea --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + solc = { + url = "github:hellwolf/solc.nix"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, solc }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default solc.overlay ]; + }; + lib = pkgs.lib; + toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + extensions = [ "rustfmt" "clippy" "rust-src" ]; + }); + in + { + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + pkg-config + libusb1 + ] ++ lib.optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.AppKit + ]; + buildInputs = [ + pkgs.rust-analyzer-unwrapped + toolchain + ]; + packages = with pkgs; [ + solc_0_8_20 + (solc.mkDefault pkgs solc_0_8_20) + ]; + + # Environment variables + RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; + LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ]; + }; + }); +} From e911d2256393190c0ff5e9f72653d5ea359ac40f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 10 Dec 2023 23:19:30 +0400 Subject: [PATCH 0395/1963] tracing: Improve decoding of functions output (#6531) * Add test * Add test * Add default contracts events and functions to decoder by default * with_local_identifier_abis * fix clippy warning * Fix test --------- Co-authored-by: Matthias Seitz --- crates/evm/traces/src/decoder/mod.rs | 19 ++++++++++- crates/evm/traces/src/identifier/local.rs | 7 +++- crates/forge/bin/cmd/script/mod.rs | 1 + crates/forge/bin/cmd/test/mod.rs | 4 +-- crates/forge/tests/cli/test_cmd.rs | 34 +++++++++++++++++++ crates/forge/tests/fixtures/repro_6531.stdout | 19 +++++++++++ crates/test-utils/src/util.rs | 12 +++++-- 7 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 crates/forge/tests/fixtures/repro_6531.stdout diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 87d813ec3d488..14d29a5673178 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -1,5 +1,7 @@ use crate::{ - identifier::{AddressIdentity, SingleSignaturesIdentifier, TraceIdentifier}, + identifier::{ + AddressIdentity, LocalTraceIdentifier, SingleSignaturesIdentifier, TraceIdentifier, + }, CallTrace, CallTraceArena, TraceCallData, TraceLog, TraceRetData, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; @@ -42,6 +44,15 @@ impl CallTraceDecoderBuilder { self } + /// Add known functions to the decoder. + #[inline] + pub fn with_functions(mut self, functions: impl IntoIterator) -> Self { + for function in functions { + self.decoder.functions.entry(function.selector()).or_default().push(function); + } + self + } + /// Add known events to the decoder. #[inline] pub fn with_events(mut self, events: impl IntoIterator) -> Self { @@ -55,6 +66,12 @@ impl CallTraceDecoderBuilder { self } + #[inline] + pub fn with_local_identifier_abis(self, identifier: &LocalTraceIdentifier<'_>) -> Self { + self.with_events(identifier.events().cloned()) + .with_functions(identifier.functions().cloned()) + } + /// Sets the verbosity level of the decoder. #[inline] pub fn with_verbosity(mut self, level: u8) -> Self { diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index f0bc851562ea3..174a698bad7b8 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -1,5 +1,5 @@ use super::{AddressIdentity, TraceIdentifier}; -use alloy_json_abi::Event; +use alloy_json_abi::{Event, Function}; use alloy_primitives::Address; use foundry_common::contracts::{diff_score, ContractsByArtifact}; use ordered_float::OrderedFloat; @@ -15,6 +15,11 @@ impl<'a> LocalTraceIdentifier<'a> { Self { known_contracts } } + /// Get all the functions of the local contracts. + pub fn functions(&self) -> impl Iterator { + self.known_contracts.iter().flat_map(|(_, (abi, _))| abi.functions()) + } + /// Get all the events of the local contracts. pub fn events(&self) -> impl Iterator { self.known_contracts.iter().flat_map(|(_, (abi, _))| abi.events()) diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 335c89f1b9c57..c6d5b9294d16a 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -220,6 +220,7 @@ impl ScriptArgs { let mut decoder = CallTraceDecoderBuilder::new() .with_labels(result.labeled_addresses.clone()) .with_verbosity(verbosity) + .with_local_identifier_abis(&local_identifier) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), script_config.config.offline, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index e649d889f3515..0d099486e5699 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -231,7 +231,7 @@ impl TestArgs { // Identify addresses in each trace let mut builder = CallTraceDecoderBuilder::new() .with_labels(result.labeled_addresses.clone()) - .with_events(local_identifier.events().cloned()) + .with_local_identifier_abis(&local_identifier) .with_verbosity(verbosity); // Signatures are of no value for gas reports @@ -432,7 +432,7 @@ impl TestArgs { // Identify addresses in each trace let mut builder = CallTraceDecoderBuilder::new() .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) - .with_events(local_identifier.events().cloned()) + .with_local_identifier_abis(&local_identifier) .with_verbosity(verbosity); // Signatures are of no value for gas reports diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 97d428e3d0ee3..e7ed7747b1c8f 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -367,3 +367,37 @@ forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { // run command and assert error exit code cmd.assert_err(); }); + +forgetest_init!(repro_6531, |prj, cmd| { + prj.wipe_contracts(); + + let endpoint = rpc::next_http_archive_rpc_endpoint(); + + prj.add_test( + "Contract.t.sol", + &r#" +import {Test} from "forge-std/Test.sol"; + +interface IERC20 { + function name() external view returns (string memory); +} + +contract USDCCallingTest is Test { + function test() public { + vm.createSelectFork(""); + IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48).name(); + } +} + "# + .replace("", &endpoint), + ) + .unwrap(); + + let expected = std::fs::read_to_string( + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/repro_6531.stdout"), + ) + .unwrap() + .replace("", &endpoint); + + cmd.args(["test", "-vvvv"]).unchecked_output().stdout_matches_content(&expected); +}); diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout new file mode 100644 index 0000000000000..319d0a422dff1 --- /dev/null +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -0,0 +1,19 @@ +Compiling 1 files with 0.8.23 + +Compiler run successful! + +Running 1 test for test/Contract.t.sol:USDCCallingTest +[PASS] test() (gas: 16799) +Traces: + [16799] USDCCallingTest::test() + ├─ [0] VM::createSelectFork("") + │ └─ ← 0 + ├─ [10350] 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48::name() [staticcall] + │ ├─ [3061] 0xa2327a938Febf5FEC13baCFb16Ae10EcBc4cbDCF::name() [delegatecall] + │ │ └─ ← "USD Coin" + │ └─ ← "USD Coin" + └─ ← () + +Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s + +Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 9f5e541b1325a..dedbc589901f6 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -897,6 +897,9 @@ stderr: /// fixture. Since `forge` commands may emit colorized output depending on whether the current /// terminal is tty, the path argument can be wrapped in [tty_fixture_path()] pub trait OutputExt { + /// Ensure the command wrote the expected data to `stdout`. + fn stdout_matches_content(&self, expected: &str); + /// Ensure the command wrote the expected data to `stdout`. fn stdout_matches_path(&self, expected_path: impl AsRef); @@ -931,11 +934,16 @@ fn normalize_output(s: &str) -> String { } impl OutputExt for Output { + #[track_caller] + fn stdout_matches_content(&self, expected: &str) { + let out = lossy_string(&self.stdout); + pretty_assertions::assert_eq!(normalize_output(&out), normalize_output(expected)); + } + #[track_caller] fn stdout_matches_path(&self, expected_path: impl AsRef) { let expected = fs::read_to_string(expected_path).unwrap(); - let out = lossy_string(&self.stdout); - pretty_assertions::assert_eq!(normalize_output(&out), normalize_output(&expected)); + self.stdout_matches_content(&expected); } #[track_caller] From 0ae39ea8e43e629d67e9373d189f3730019b4bfc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 10 Dec 2023 22:49:35 +0100 Subject: [PATCH 0396/1963] feat: support overlapping permissions (#6561) * feat: support overlapping permissions * cleanup --- crates/config/src/fs_permissions.rs | 43 +++++++++++++++++++++++++++-- crates/forge/tests/it/repros.rs | 18 ++++++++++++ testdata/repros/Issue6554.t.sol | 16 +++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 testdata/repros/Issue6554.t.sol diff --git a/crates/config/src/fs_permissions.rs b/crates/config/src/fs_permissions.rs index 3128cd6014c22..5a8328ba4b1c5 100644 --- a/crates/config/src/fs_permissions.rs +++ b/crates/config/src/fs_permissions.rs @@ -25,6 +25,11 @@ impl FsPermissions { Self { permissions: permissions.into_iter().collect() } } + /// Adds a new permission + pub fn add(&mut self, permission: PathPermission) { + self.permissions.push(permission) + } + /// Returns true if access to the specified path is allowed with the specified. /// /// This first checks permission, and only if it is granted, whether the path is allowed. @@ -37,9 +42,28 @@ impl FsPermissions { self.find_permission(path).map(|perm| perm.is_granted(kind)).unwrap_or_default() } - /// Returns the permission for the matching path + /// Returns the permission for the matching path. + /// + /// This finds the longest matching path, e.g. if we have the following permissions: + /// + /// `./out` = `read` + /// `./out/contracts` = `read-write` + /// + /// And we check for `./out/contracts/MyContract.sol` we will get `read-write` as permission. pub fn find_permission(&self, path: &Path) -> Option { - self.permissions.iter().find(|perm| path.starts_with(&perm.path)).map(|perm| perm.access) + let mut permission: Option<&PathPermission> = None; + for perm in &self.permissions { + if path.starts_with(&perm.path) { + if let Some(active_perm) = permission.as_ref() { + // the longest path takes precedence + if perm.path < active_perm.path { + continue; + } + } + permission = Some(perm); + } + } + permission.map(|perm| perm.access) } /// Updates all `allowed_paths` and joins ([`Path::join`]) the `root` with all entries @@ -238,4 +262,19 @@ mod tests { assert_eq!(FsAccessPermission::Read, "read".parse().unwrap()); assert_eq!(FsAccessPermission::Write, "write".parse().unwrap()); } + + #[test] + fn nested_permissions() { + let permissions = FsPermissions::new(vec![ + PathPermission::read("./"), + PathPermission::write("./out"), + PathPermission::read_write("./out/contracts"), + ]); + + let permission = + permissions.find_permission(Path::new("./out/contracts/MyContract.sol")).unwrap(); + assert_eq!(FsAccessPermission::ReadWrite, permission); + let permission = permissions.find_permission(Path::new("./out/MyContract.sol")).unwrap(); + assert_eq!(FsAccessPermission::Write, permission); + } } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 490954eb83e29..5ea2bd37845c7 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -37,6 +37,16 @@ macro_rules! test_repro { } } }; + ($issue_number:literal; |$config:ident| $e:expr $(,)?) => { + paste::paste! { + #[tokio::test(flavor = "multi_thread")] + async fn [< issue_ $issue_number >]() { + let mut $config = repro_config($issue_number, false, None).await; + $e + $config.run().await; + } + } + }; } async fn repro_config(issue: usize, should_fail: bool, sender: Option
) -> TestConfig { @@ -267,3 +277,11 @@ test_repro!(6501, false, None, |res| { ); } }); + +// https://github.com/foundry-rs/foundry/issues/6554 +test_repro!(6554; |config| { + let mut cheats_config = config.runner.cheats_config.as_ref().clone(); + let path = cheats_config.root.join("out/Issue6554.t.sol"); + cheats_config.fs_permissions.add(PathPermission::read_write(path)); + config.runner.cheats_config = std::sync::Arc::new(cheats_config); +}); diff --git a/testdata/repros/Issue6554.t.sol b/testdata/repros/Issue6554.t.sol new file mode 100644 index 0000000000000..be7af3d9d9ca2 --- /dev/null +++ b/testdata/repros/Issue6554.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6554 +contract Issue6554Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testPermissions() public { + vm.writeFile("./out/Issue6554.t.sol/cachedFile.txt", "cached data"); + string memory content = vm.readFile("./out/Issue6554.t.sol/cachedFile.txt"); + assertEq(content, "cached data"); + } +} From 6998c7977481bea8b7ea2a84c74b4c463a4ed8b7 Mon Sep 17 00:00:00 2001 From: brockelmore <31553173+brockelmore@users.noreply.github.com> Date: Mon, 11 Dec 2023 00:51:23 +0000 Subject: [PATCH 0397/1963] fix(forge): Invariant Shrinking (#6530) --- Cargo.lock | 2 + crates/config/src/invariant.rs | 3 + crates/evm/evm/Cargo.toml | 2 + .../evm/evm/src/executors/invariant/error.rs | 264 ++++++++++++++---- .../evm/evm/src/executors/invariant/funcs.rs | 2 + crates/evm/evm/src/executors/invariant/mod.rs | 14 +- crates/forge/tests/it/config.rs | 1 + crates/forge/tests/it/invariant.rs | 7 +- 8 files changed, 232 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b162242612b98..d82cf66ac6d5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2867,8 +2867,10 @@ dependencies = [ "foundry-evm-fuzz", "foundry-evm-traces", "hashbrown 0.14.3", + "itertools 0.11.0", "parking_lot", "proptest", + "rayon", "revm", "thiserror", "tracing", diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 1b3cd6218a627..f31794bf576ae 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -26,6 +26,8 @@ pub struct InvariantConfig { pub dictionary: FuzzDictionaryConfig, /// Attempt to shrink the failure case to its smallest sequence of calls pub shrink_sequence: bool, + /// The maximum number of attempts to shrink the sequence + pub shrink_run_limit: usize, } impl Default for InvariantConfig { @@ -37,6 +39,7 @@ impl Default for InvariantConfig { call_override: false, dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() }, shrink_sequence: true, + shrink_run_limit: 2usize.pow(18_u32), } } } diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 8594576874f33..b05871c6494dc 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -37,6 +37,7 @@ revm = { workspace = true, default-features = false, features = [ ethers-core.workspace = true ethers-signers.workspace = true +itertools.workspace = true eyre = "0.6" hex.workspace = true @@ -44,3 +45,4 @@ parking_lot = "0.12" proptest = "1" thiserror = "1" tracing = "0.1" +rayon = "1" diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 19250984cc61e..f0f476f8adcc8 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -2,14 +2,19 @@ use super::{BasicTxDetails, InvariantContract}; use crate::executors::{Executor, RawCallResult}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes}; -use ethers_core::types::Log; +use ethers_core::{ + rand::{seq, thread_rng, Rng}, + types::Log, +}; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::{constants::CALLER, decode::decode_revert}; use foundry_evm_fuzz::{BaseCounterExample, CounterExample, FuzzedCases, Reason}; use foundry_evm_traces::{load_contracts, CallTraceArena, TraceKind, Traces}; +use itertools::Itertools; use parking_lot::RwLock; use proptest::test_runner::TestError; +use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use revm::primitives::U256; use std::sync::Arc; @@ -68,6 +73,8 @@ pub struct InvariantFuzzError { pub inner_sequence: Vec>, /// Shrink the failed test case to the smallest sequence. pub shrink: bool, + /// Shrink run limit + pub shrink_run_limit: usize, } impl InvariantFuzzError { @@ -78,6 +85,7 @@ impl InvariantFuzzError { call_result: RawCallResult, inner_sequence: &[Option], shrink: bool, + shrink_run_limit: usize, ) -> Self { let (func, origin) = if let Some(f) = error_func { (Some(f.selector().to_vec().into()), f.name.as_str()) @@ -103,6 +111,7 @@ impl InvariantFuzzError { func, inner_sequence: inner_sequence.to_vec(), shrink, + shrink_run_limit, } } @@ -116,14 +125,14 @@ impl InvariantFuzzError { traces: &mut Traces, ) -> Result> { let mut counterexample_sequence = vec![]; - let calls = match self.test_error { + let mut calls = match self.test_error { // Don't use at the moment. TestError::Abort(_) => return Ok(None), - TestError::Fail(_, ref calls) => calls, + TestError::Fail(_, ref calls) => calls.clone(), }; if self.shrink { - let _ = self.try_shrinking(calls, &executor); + calls = self.try_shrinking(&calls, &executor).into_iter().cloned().collect(); } else { trace!(target: "forge::test", "Shrinking disabled."); } @@ -175,23 +184,36 @@ impl InvariantFuzzError { .then_some(CounterExample::Sequence(counterexample_sequence))) } - /// Tests that the modified sequence of calls successfully reverts on the error function. - fn fails_successfully<'a>( + /// Checks that a subsequence of the provided calls fails the provided invariant test + /// and updates an Arc Mutex of the indices of the shortest sequence + fn set_fails_successfully( &self, mut executor: Executor, - calls: &'a [BasicTxDetails], - anchor: usize, - removed_calls: &[usize], - ) -> Result, ()> { + calls: &[BasicTxDetails], + use_calls: &[usize], + curr_seq: Arc>>, + ) { + if curr_seq.read().len() == 1 { + // if current sequence is already the smallest possible, just return + return; + } + let mut new_sequence = Vec::with_capacity(calls.len()); - for (index, details) in calls.iter().enumerate() { - if anchor > index || removed_calls.contains(&index) { + for index in 0..calls.len() { + if !use_calls.contains(&index) { continue } - new_sequence.push(details); + new_sequence.push(index); + + // If the new sequence is already longer than the known best, skip execution + if new_sequence.len() >= curr_seq.read().len() { + return + } + } - let (sender, (addr, bytes)) = details; + for (seq_idx, call_index) in new_sequence.iter().enumerate() { + let (sender, (addr, bytes)) = &calls[*call_index]; executor .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) @@ -202,70 +224,198 @@ impl InvariantFuzzError { let error_call_result = executor .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) .expect("bad call to evm"); - if error_call_result.reverted { - return Ok(new_sequence) + let mut locked = curr_seq.write(); + if new_sequence[..=seq_idx].len() < locked.len() { + // update the curr_sequence if the new sequence is lower than + *locked = new_sequence[..=seq_idx].to_vec(); + } } } } - - Err(()) } /// Tries to shrink the failure case to its smallest sequence of calls. /// - /// Sets an anchor at the beginning (index=0) and tries to remove all other calls one by one, - /// until it reaches the last one. The elements which were removed and lead to a failure are - /// kept in the removal list. The removed ones that didn't lead to a failure are inserted - /// back into the sequence. - /// - /// Once it reaches the end, it increments the anchor, resets the removal list and starts the - /// same process again. - /// - /// Returns the smallest sequence found. + /// If the number of calls is small enough, we can guarantee maximal shrinkage fn try_shrinking<'a>( &self, calls: &'a [BasicTxDetails], executor: &Executor, ) -> Vec<&'a BasicTxDetails> { - let mut anchor = 0; - let mut removed_calls = vec![]; - let mut shrunk = calls.iter().collect::>(); trace!(target: "forge::test", "Shrinking."); - while anchor != calls.len() { - // Get the latest removed element, so we know which one to remove next. - let removed = - match self.fails_successfully(executor.clone(), calls, anchor, &removed_calls) { - Ok(new_sequence) => { - if shrunk.len() > new_sequence.len() { - shrunk = new_sequence; - } - removed_calls.last().cloned() - } - Err(_) => removed_calls.pop(), - }; + // Special case test: the invariant is *unsatisfiable* - it took 0 calls to + // break the invariant -- consider emitting a warning. + if let Some(func) = &self.func { + let error_call_result = executor + .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) + .expect("bad call to evm"); + if error_call_result.reverted { + return vec![]; + } + } - if let Some(last_removed) = removed { - // If we haven't reached the end of the sequence, then remove the next element. - // Otherwise, restart the process with an incremented anchor. + let shrunk_call_indices = self.try_shrinking_recurse(calls, executor, 0, 0); - let next_removed = last_removed + 1; + // Filter the calls by if the call index is present in `shrunk_call_indices` + calls + .iter() + .enumerate() + .filter_map( + |(i, call)| if shrunk_call_indices.contains(&i) { Some(call) } else { None }, + ) + .collect() + } - if next_removed > calls.len() - 1 { - anchor += 1; - removed_calls = vec![]; - continue - } + /// We try to construct a [powerset](https://en.wikipedia.org/wiki/Power_set) of the sequence if + /// the configuration allows for it and the length of the sequence is small enough. If we + /// do construct the powerset, we run all of the sequences in parallel, finding the smallest + /// one. If we have ran the powerset, we are guaranteed to find the smallest sequence for a + /// given set of calls (however, not guaranteed *global* smallest if a random sequence was + /// used at any point during recursion). + /// + /// If we were unable to construct a powerset, we construct a random sample over the sequence + /// and run these sequences in parallel instead. + /// + /// After running either the powerset or the random sequences, we check if we successfully + /// shrunk the call sequence. + fn try_shrinking_recurse( + &self, + calls: &[BasicTxDetails], + executor: &Executor, + runs: usize, + retries: usize, + ) -> Vec { + // Construct a ArcRwLock vector of indices of `calls` + let shrunk_call_indices = Arc::new(RwLock::new((0..calls.len()).collect())); + let shrink_limit = self.shrink_run_limit - runs; + + // We construct either a full powerset (this guarantees we maximally shrunk for the given + // calls) or a random subset + let (set_of_indices, is_powerset): (Vec<_>, bool) = if calls.len() <= 64 && + 2_usize.pow(calls.len() as u32) <= shrink_limit + { + // We add the last tx always because thats ultimately what broke the invariant + let powerset = (0..calls.len() - 1) + .powerset() + .map(|mut subset| { + subset.push(calls.len() - 1); + subset + }) + .collect(); + (powerset, true) + } else { + // construct a random set of subsequences + let mut rng = thread_rng(); + ( + (0..shrink_limit / 3) + .map(|_| { + // Select between 1 and calls.len() - 2 number of indices + let amt: usize = rng.gen_range(1..calls.len() - 1); + // Construct a random sequence of indices, up to calls.len() - 1 (sample is + // exclusive range and we dont include the last tx + // because its always included), and amt number of indices + let mut seq = seq::index::sample(&mut rng, calls.len() - 1, amt).into_vec(); + // Sort the indices because seq::index::sample is unordered + seq.sort(); + // We add the last tx always because thats what ultimately broke the + // invariant + seq.push(calls.len() - 1); + seq + }) + .collect(), + false, + ) + }; - removed_calls.push(next_removed); - } else { - // When the process is restarted, `removed_calls` will be empty. - removed_calls.push(anchor + 1); - } + let new_runs = set_of_indices.len(); + + // just try all of them in parallel + set_of_indices.par_iter().for_each(|use_calls| { + self.set_fails_successfully( + executor.clone(), + calls, + use_calls, + Arc::clone(&shrunk_call_indices), + ); + }); + + // SAFETY: there are no more live references to shrunk_call_indices as the parallel + // execution is finished, so it is fine to get the inner value via unwrap & + // into_inner + let shrunk_call_indices = + Arc::>>::try_unwrap(shrunk_call_indices).unwrap().into_inner(); + + if is_powerset { + // a powerset is guaranteed to be smallest local subset, so we return early + return shrunk_call_indices } - shrunk + let computation_budget_not_hit = new_runs + runs < self.shrink_run_limit; + // If the new shrunk_call_indices is less than the input calls length, + // we found a subsequence that is shorter. So we can measure if we made progress by + // comparing them + let made_progress = shrunk_call_indices.len() < calls.len(); + // We limit the number of times we can iterate without making progress + let has_remaining_retries = retries <= 3; + + match (computation_budget_not_hit, made_progress) { + (true, false) if has_remaining_retries => { + // we havent hit the computation budget and we have retries remaining + // + // use the same call set but increase retries which should select a different random + // subset we dont need to do the mapping stuff like above because we dont + // take a subset of the input + self.try_shrinking_recurse(calls, executor, runs + new_runs, retries + 1) + } + (true, true) => { + // We construct a *new* subset of calls using the `shrunk_call_indices` of the + // passed in calls i.e. if shrunk_call_indices == [1, 3], and calls + // is: [call0, call1, call2, call3] then new_calls == [call1, call3] + let new_calls: Vec<_> = calls + .iter() + .enumerate() + .filter_map(|(i, call)| { + if shrunk_call_indices.contains(&i) { + Some(call.clone()) + } else { + None + } + }) + .collect(); + + // We rerun this algorithm as if the new smaller subset above were the original + // calls. i.e. if [call0, call1, call2, call3] got reduced to + // [call1, call3] (in the above line) and we still have progress + // to make, we recall this function with [call1, call3]. Then after this call say it + // returns [1]. This means `call3` is all that is required to break + // the invariant. + let new_calls_idxs = + self.try_shrinking_recurse(&new_calls, executor, runs + new_runs, 0); + + // Notably, the indices returned above are relative to `new_calls`, *not* the + // originally passed in `calls`. So we map back by filtering + // `new_calls` by index if the index was returned above, and finding the position + // of the `new_call` in the passed in `call` + new_calls + .iter() + .enumerate() + .filter_map(|(idx, new_call)| { + if !new_calls_idxs.contains(&idx) { + None + } else { + calls.iter().position(|r| r == new_call) + } + }) + .collect() + } + _ => { + // The computation budget has been hit or no retries remaining, stop trying to make + // progress + shrunk_call_indices + } + } } } diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index 2d7688729fe57..c0a053d0f26d6 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -19,6 +19,7 @@ pub fn assert_invariants( calldata: &[BasicTxDetails], invariant_failures: &mut InvariantFailures, shrink_sequence: bool, + shrink_run_limit: usize, ) -> Option { let mut inner_sequence = vec![]; @@ -56,6 +57,7 @@ pub fn assert_invariants( call_result, &inner_sequence, shrink_sequence, + shrink_run_limit, )); return None } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index fa56c97c4dc9b..ffde3b59c5bd8 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -125,6 +125,7 @@ impl<'a> InvariantExecutor<'a> { &[], &mut failures.borrow_mut(), self.config.shrink_sequence, + self.config.shrink_run_limit, )); if last_call_results.borrow().is_none() { @@ -203,6 +204,7 @@ impl<'a> InvariantExecutor<'a> { state_changeset, self.config.fail_on_revert, self.config.shrink_sequence, + self.config.shrink_run_limit, ); if !can_continue || current_run == self.config.depth - 1 { @@ -730,6 +732,7 @@ fn can_continue( state_changeset: StateChangeset, fail_on_revert: bool, shrink_sequence: bool, + shrink_run_limit: usize, ) -> RichInvariantResults { let mut call_results = None; @@ -741,8 +744,14 @@ fn can_continue( // Assert invariants IFF the call did not revert and the handlers did not fail. if !call_result.reverted && !handlers_failed { - call_results = - assert_invariants(invariant_contract, executor, calldata, failures, shrink_sequence); + call_results = assert_invariants( + invariant_contract, + executor, + calldata, + failures, + shrink_sequence, + shrink_run_limit, + ); if call_results.is_none() { return RichInvariantResults::new(false, None) } @@ -758,6 +767,7 @@ fn can_continue( call_result, &[], shrink_sequence, + shrink_run_limit, ); failures.revert_reason = Some(error.revert_reason.clone()); diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index ecd171ec6f93c..17cace7c908d9 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -123,6 +123,7 @@ pub fn test_opts() -> TestOptions { max_fuzz_dictionary_values: 10_000, }, shrink_sequence: true, + shrink_run_limit: 2usize.pow(18u32), }) .build(&COMPILED, &PROJECT.paths.root) .expect("Config loaded") diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 617fa7ab29a1a..4fcc8ffe33b7b 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -215,7 +215,7 @@ async fn test_invariant_shrink() { let mut runner = runner().await; let mut opts = test_opts(); - opts.fuzz.seed = Some(U256::from(102u32)); + opts.fuzz.seed = Some(U256::from(119u32)); runner.test_options = opts.clone(); let results = runner @@ -238,10 +238,9 @@ async fn test_invariant_shrink() { match counter { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), - // `fuzz_seed` at 100 makes this sequence shrinkable from 4 to 2. + // `fuzz_seed` at 119 makes this sequence shrinkable from 4 to 2. CounterExample::Sequence(sequence) => { - // there some diff across platforms for some reason, either 3 or 2 - assert!(sequence.len() <= 3) + assert!(sequence.len() == 2) } }; } From 120ae66da3501c312d1bed4a72c935868b68cacd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 11 Dec 2023 02:28:22 +0100 Subject: [PATCH 0398/1963] feat: add additional snapshot cheatcodes (#6548) * feat: add additional snapshot cheatcodes * chore: docs * cargo cheats --- crates/cheatcodes/assets/cheatcodes.json | 62 +++++++++++++++++++++++- crates/cheatcodes/spec/src/vm.rs | 26 +++++++++- crates/cheatcodes/src/evm.rs | 45 +++++++++++++++-- crates/evm/core/src/backend/fuzz.rs | 26 +++++++++- crates/evm/core/src/backend/mod.rs | 27 ++++++++++- crates/evm/core/src/snapshot.rs | 5 ++ testdata/cheats/Snapshots.t.sol | 47 ++++++++++++++++++ testdata/cheats/Vm.sol | 3 ++ 8 files changed, 232 insertions(+), 9 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 3c814e5cafcd7..927ebb78c20c5 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -1013,6 +1013,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "deleteSnapshot", + "description": "Removes the snapshot with the given ID created by `snapshot`.\nTakes the snapshot ID to delete.\nReturns `true` if the snapshot was successfully deleted.\nReturns `false` if the snapshot does not exist.", + "declaration": "function deleteSnapshot(uint256 snapshotId) external returns (bool success);", + "visibility": "external", + "mutability": "", + "signature": "deleteSnapshot(uint256)", + "selector": "0xa6368557", + "selectorBytes": [ + 166, + 54, + 133, + 87 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "deleteSnapshots", + "description": "Removes _all_ snapshots previously created by `snapshot`.", + "declaration": "function deleteSnapshots() external;", + "visibility": "external", + "mutability": "", + "signature": "deleteSnapshots()", + "selector": "0x421ae469", + "selectorBytes": [ + 66, + 26, + 228, + 105 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "deriveKey_0", @@ -3476,7 +3516,7 @@ { "func": { "id": "revertTo", - "description": "Revert the state of the EVM to a previous snapshot\nTakes the snapshot ID to revert to.\nThis deletes the snapshot and all snapshots taken after the given snapshot ID.", + "description": "Revert the state of the EVM to a previous snapshot\nTakes the snapshot ID to revert to.\nReturns `true` if the snapshot was successfully reverted.\nReturns `false` if the snapshot does not exist.\n**Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteSnapshot`.", "declaration": "function revertTo(uint256 snapshotId) external returns (bool success);", "visibility": "external", "mutability": "", @@ -3493,6 +3533,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "revertToAndDelete", + "description": "Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots\nTakes the snapshot ID to revert to.\nReturns `true` if the snapshot was successfully reverted and deleted.\nReturns `false` if the snapshot does not exist.", + "declaration": "function revertToAndDelete(uint256 snapshotId) external returns (bool success);", + "visibility": "external", + "mutability": "", + "signature": "revertToAndDelete(uint256)", + "selector": "0x03e0aca9", + "selectorBytes": [ + 3, + 224, + 172, + 169 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "revokePersistent_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 50bdd26f3aa43..ae6622842fae3 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -419,10 +419,34 @@ interface Vm { /// Revert the state of the EVM to a previous snapshot /// Takes the snapshot ID to revert to. - /// This deletes the snapshot and all snapshots taken after the given snapshot ID. + /// + /// Returns `true` if the snapshot was successfully reverted. + /// Returns `false` if the snapshot does not exist. + /// + /// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteSnapshot`. #[cheatcode(group = Evm, safety = Unsafe)] function revertTo(uint256 snapshotId) external returns (bool success); + /// Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots + /// Takes the snapshot ID to revert to. + /// + /// Returns `true` if the snapshot was successfully reverted and deleted. + /// Returns `false` if the snapshot does not exist. + #[cheatcode(group = Evm, safety = Unsafe)] + function revertToAndDelete(uint256 snapshotId) external returns (bool success); + + /// Removes the snapshot with the given ID created by `snapshot`. + /// Takes the snapshot ID to delete. + /// + /// Returns `true` if the snapshot was successfully deleted. + /// Returns `false` if the snapshot does not exist. + #[cheatcode(group = Evm, safety = Unsafe)] + function deleteSnapshot(uint256 snapshotId) external returns (bool success); + + /// Removes _all_ snapshots previously created by `snapshot`. + #[cheatcode(group = Evm, safety = Unsafe)] + function deleteSnapshots() external; + // -------- Forking -------- // --- Creation and Selection --- diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 136cdb8f80481..b8afe62a291ff 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -6,7 +6,7 @@ use alloy_sol_types::SolValue; use ethers_core::utils::{Genesis, GenesisAccount}; use ethers_signers::Signer; use foundry_common::{fs::read_json_file, types::ToAlloy}; -use foundry_evm_core::backend::DatabaseExt; +use foundry_evm_core::backend::{DatabaseExt, RevertSnapshotAction}; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, EVMData, @@ -327,9 +327,12 @@ impl Cheatcode for snapshotCall { impl Cheatcode for revertToCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; - let result = if let Some(journaled_state) = - ccx.data.db.revert(*snapshotId, &ccx.data.journaled_state, ccx.data.env) - { + let result = if let Some(journaled_state) = ccx.data.db.revert( + *snapshotId, + &ccx.data.journaled_state, + ccx.data.env, + RevertSnapshotAction::RevertKeep, + ) { // we reset the evm's journaled_state to the state of the snapshot previous state ccx.data.journaled_state = journaled_state; true @@ -340,6 +343,40 @@ impl Cheatcode for revertToCall { } } +impl Cheatcode for revertToAndDeleteCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { snapshotId } = self; + let result = if let Some(journaled_state) = ccx.data.db.revert( + *snapshotId, + &ccx.data.journaled_state, + ccx.data.env, + RevertSnapshotAction::RevertRemove, + ) { + // we reset the evm's journaled_state to the state of the snapshot previous state + ccx.data.journaled_state = journaled_state; + true + } else { + false + }; + Ok(result.abi_encode()) + } +} + +impl Cheatcode for deleteSnapshotCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { snapshotId } = self; + let result = ccx.data.db.delete_snapshot(*snapshotId); + Ok(result.abi_encode()) + } +} +impl Cheatcode for deleteSnapshotsCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + ccx.data.db.delete_snapshots(); + Ok(Default::default()) + } +} + impl Cheatcode for startStateDiffRecordingCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index bf32c6f8800f0..0a963810abde5 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -3,6 +3,7 @@ use crate::{ backend::{ diagnostic::RevertDiagnostic, error::DatabaseError, Backend, DatabaseExt, LocalForkId, + RevertSnapshotAction, }, fork::{CreateFork, ForkId}, }; @@ -83,6 +84,14 @@ impl<'a> FuzzBackendWrapper<'a> { } self.backend.to_mut() } + + /// Returns a mutable instance of the Backend if it is initialized. + fn initialized_backend_mut(&mut self) -> Option<&mut Backend> { + if self.is_initialized { + return Some(self.backend.to_mut()) + } + None + } } impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { @@ -96,9 +105,24 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { id: U256, journaled_state: &JournaledState, current: &mut Env, + action: RevertSnapshotAction, ) -> Option { trace!(?id, "fuzz: revert snapshot"); - self.backend_mut(current).revert(id, journaled_state, current) + self.backend_mut(current).revert(id, journaled_state, current, action) + } + + fn delete_snapshot(&mut self, id: U256) -> bool { + // delete snapshot requires a previous snapshot to be initialized + if let Some(backend) = self.initialized_backend_mut() { + return backend.delete_snapshot(id) + } + false + } + + fn delete_snapshots(&mut self) { + if let Some(backend) = self.initialized_backend_mut() { + backend.delete_snapshots() + } } fn create_fork(&mut self, fork: CreateFork) -> eyre::Result { diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index c0ffdfd8f6135..246a38320e2b1 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -82,14 +82,26 @@ pub trait DatabaseExt: Database { /// since the snapshots was created. This way we can show logs that were emitted between /// snapshot and its revert. /// This will also revert any changes in the `Env` and replace it with the captured `Env` of - /// `Self::snapshot` + /// `Self::snapshot`. + /// + /// Depending on [RevertSnapshotAction] it will keep the snapshot alive or delete it. fn revert( &mut self, id: U256, journaled_state: &JournaledState, env: &mut Env, + action: RevertSnapshotAction, ) -> Option; + /// Deletes the snapshot with the given `id` + /// + /// Returns `true` if the snapshot was successfully deleted, `false` if no snapshot for that id + /// exists. + fn delete_snapshot(&mut self, id: U256) -> bool; + + /// Deletes all snapshots. + fn delete_snapshots(&mut self); + /// Creates and also selects a new fork /// /// This is basically `create_fork` + `select_fork` @@ -918,11 +930,14 @@ impl DatabaseExt for Backend { id: U256, current_state: &JournaledState, current: &mut Env, + action: RevertSnapshotAction, ) -> Option { trace!(?id, "revert snapshot"); if let Some(mut snapshot) = self.inner.snapshots.remove_at(id) { // Re-insert snapshot to persist it - self.inner.snapshots.insert_at(snapshot.clone(), id); + if action.is_keep() { + self.inner.snapshots.insert_at(snapshot.clone(), id); + } // need to check whether there's a global failure which means an error occurred either // during the snapshot or even before if self.is_global_failure(current_state) { @@ -969,6 +984,14 @@ impl DatabaseExt for Backend { } } + fn delete_snapshot(&mut self, id: U256) -> bool { + self.inner.snapshots.remove_at(id).is_some() + } + + fn delete_snapshots(&mut self) { + self.inner.snapshots.clear() + } + fn create_fork(&mut self, mut create_fork: CreateFork) -> eyre::Result { trace!("create fork"); let (fork_id, fork, _) = self.forks.create_fork(create_fork.clone())?; diff --git a/crates/evm/core/src/snapshot.rs b/crates/evm/core/src/snapshot.rs index bcd1c92913191..705c5baf7f275 100644 --- a/crates/evm/core/src/snapshot.rs +++ b/crates/evm/core/src/snapshot.rs @@ -39,6 +39,11 @@ impl Snapshots { snapshot } + /// Removes all snapshots + pub fn clear(&mut self) { + self.snapshots.clear(); + } + /// Removes the snapshot with the given `id`. /// /// Does not remove snapshots after it. diff --git a/testdata/cheats/Snapshots.t.sol b/testdata/cheats/Snapshots.t.sol index 9a174be98c524..baf82e2e57c1d 100644 --- a/testdata/cheats/Snapshots.t.sol +++ b/testdata/cheats/Snapshots.t.sol @@ -32,6 +32,53 @@ contract SnapshotTest is DSTest { assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); } + function testSnapshotRevertDelete() public { + uint256 snapshot = vm.snapshot(); + store.slot0 = 300; + store.slot1 = 400; + + assertEq(store.slot0, 300); + assertEq(store.slot1, 400); + + vm.revertToAndDelete(snapshot); + assertEq(store.slot0, 10, "snapshot revert for slot 0 unsuccessful"); + assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); + // nothing to revert to anymore + assert(!vm.revertTo(snapshot)); + } + + function testSnapshotDelete() public { + uint256 snapshot = vm.snapshot(); + store.slot0 = 300; + store.slot1 = 400; + + vm.deleteSnapshot(snapshot); + // nothing to revert to anymore + assert(!vm.revertTo(snapshot)); + } + + function testSnapshotDeleteAll() public { + uint256 snapshot = vm.snapshot(); + store.slot0 = 300; + store.slot1 = 400; + + vm.deleteSnapshots(); + // nothing to revert to anymore + assert(!vm.revertTo(snapshot)); + } + + // + function testSnapshotsMany() public { + uint256 preState; + for (uint256 c = 0; c < 10; c++) { + for (uint256 cc = 0; cc < 10; cc++) { + preState = vm.snapshot(); + vm.revertToAndDelete(preState); + assert(!vm.revertTo(preState)); + } + } + } + // tests that snapshots can also revert changes to `block` function testBlockValues() public { uint256 num = block.number; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index ab301787465bb..a8c885f6e352c 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -48,6 +48,8 @@ interface Vm { function createWallet(uint256 privateKey) external returns (Wallet memory wallet); function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet); function deal(address account, uint256 newBalance) external; + function deleteSnapshot(uint256 snapshotId) external returns (bool success); + function deleteSnapshots() external; 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); @@ -172,6 +174,7 @@ interface Vm { function resetNonce(address account) external; function resumeGasMetering() external; function revertTo(uint256 snapshotId) external returns (bool success); + function revertToAndDelete(uint256 snapshotId) external returns (bool success); function revokePersistent(address account) external; function revokePersistent(address[] calldata accounts) external; function roll(uint256 newHeight) external; From cdbaf9dda688cab08b9f6945af287534d68b1e1f Mon Sep 17 00:00:00 2001 From: Meet Mangukiya Date: Mon, 11 Dec 2023 19:33:07 +0530 Subject: [PATCH 0399/1963] feat(fmt): add sort_imports config (#5442) * sort imports wip * feat: complete sort imports * chore: rm useless check --------- Co-authored-by: Matthias Seitz --- crates/config/src/fmt.rs | 3 + crates/fmt/src/formatter.rs | 89 ++++++++++++++++++- crates/fmt/testdata/SortedImports/fmt.sol | 34 +++++++ .../fmt/testdata/SortedImports/original.sol | 23 +++++ crates/fmt/tests/formatter.rs | 43 +++++++-- 5 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 crates/fmt/testdata/SortedImports/fmt.sol create mode 100644 crates/fmt/testdata/SortedImports/original.sol diff --git a/crates/config/src/fmt.rs b/crates/config/src/fmt.rs index 09e8098f0f954..44e624b127aa1 100644 --- a/crates/config/src/fmt.rs +++ b/crates/config/src/fmt.rs @@ -31,6 +31,8 @@ pub struct FormatterConfig { pub ignore: Vec, /// Add new line at start and end of contract declarations pub contract_new_lines: bool, + /// Sort import statements alphabetically in groups (a group is separated by a newline). + pub sort_imports: bool, } /// Style of uint/int256 types @@ -176,6 +178,7 @@ impl Default for FormatterConfig { wrap_comments: false, ignore: vec![], contract_new_lines: false, + sort_imports: false, } } } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 650f87e2e4fa1..79fd2aa6b03a7 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -236,6 +236,10 @@ impl<'a, W: Write> Formatter<'a, W> { /// Returns number of blank lines in source between two byte indexes fn blank_lines(&self, start: usize, end: usize) -> usize { + // because of sorting import statements, start can be greater than end + if start > end { + return 0 + } self.source[start..end].trim_comments().matches('\n').count() } @@ -949,7 +953,10 @@ impl<'a, W: Write> Formatter<'a, W> { (None, None) => return Ok(()), } .start(); + let mut last_loc: Option = None; + let mut visited_locs: Vec = Vec::new(); + let mut needs_space = false; while let Some(mut line_item) = pop_next(self, &mut items) { let loc = line_item.as_ref().either(|c| c.loc, |i| i.loc()); @@ -979,7 +986,19 @@ impl<'a, W: Write> Formatter<'a, W> { Either::Right(item) => { if !ignore_whitespace { self.write_whitespace_separator(true)?; - if let Some(last_loc) = last_loc { + if let Some(mut last_loc) = last_loc { + // here's an edge case when we reordered items so the last_loc isn't + // necessarily the item that directly precedes the current item because + // the order might have changed, so we need to find the last item that + // is before the current item by checking the recorded locations + if let Some(last_item) = visited_locs + .iter() + .rev() + .find(|prev_item| prev_item.start() > last_loc.end()) + { + last_loc = *last_item; + } + if needs_space || self.blank_lines(last_loc.end(), loc.start()) > 1 { writeln!(self.buf())?; } @@ -997,6 +1016,8 @@ impl<'a, W: Write> Formatter<'a, W> { } last_loc = Some(loc); + visited_locs.push(loc); + last_byte_written = loc.end(); if let Some(comment) = line_item.as_ref().left() { if comment.is_line() { @@ -1593,6 +1614,69 @@ impl<'a, W: Write> Formatter<'a, W> { } Ok(()) } + + /// Sorts grouped import statement alphabetically. + fn sort_imports(&self, source_unit: &mut SourceUnit) { + // first we need to find the grouped import statements + // A group is defined as a set of import statements that are separated by a blank line + let mut import_groups = Vec::new(); + let mut current_group = Vec::new(); + let mut source_unit_parts = source_unit.0.iter().enumerate().peekable(); + while let Some((i, part)) = source_unit_parts.next() { + if let SourceUnitPart::ImportDirective(_) = part { + current_group.push(i); + let current_loc = part.loc(); + if let Some((_, next_part)) = source_unit_parts.peek() { + let next_loc = next_part.loc(); + // import statements are followed by a new line, so if there are more than one + // we have a group + if self.blank_lines(current_loc.end(), next_loc.start()) > 1 { + import_groups.push(std::mem::take(&mut current_group)); + } + } + } else if !current_group.is_empty() { + import_groups.push(std::mem::take(&mut current_group)); + } + } + + if !current_group.is_empty() { + import_groups.push(current_group); + } + + if import_groups.is_empty() { + // nothing to sort + return + } + + // order all groups alphabetically + for group in import_groups.iter() { + // SAFETY: group is not empty + let first = group[0]; + let last = group.last().copied().expect("group is not empty"); + let import_directives = &mut source_unit.0[first..=last]; + + // sort rename style imports alphabetically based on the actual import and not the + // rename + for source_unit_part in import_directives.iter_mut() { + if let SourceUnitPart::ImportDirective(Import::Rename(_, renames, _)) = + source_unit_part + { + renames.sort_by_cached_key(|(og_ident, _)| og_ident.name.clone()); + } + } + + import_directives.sort_by_cached_key(|item| match item { + SourceUnitPart::ImportDirective(import) => match import { + Import::Plain(path, _) => path.to_string(), + Import::GlobalSymbol(path, _, _) => path.to_string(), + Import::Rename(path, _, _) => path.to_string(), + }, + _ => { + unreachable!("import group contains non-import statement") + } + }); + } + } } // Traverse the Solidity Parse Tree and write to the code formatter @@ -1619,6 +1703,9 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { #[instrument(name = "SU", skip_all)] fn visit_source_unit(&mut self, source_unit: &mut SourceUnit) -> Result<()> { + if self.config.sort_imports { + self.sort_imports(source_unit); + } // TODO: do we need to put pragma and import directives at the top of the file? // source_unit.0.sort_by_key(|item| match item { // SourceUnitPart::PragmaDirective(_, _, _) => 0, diff --git a/crates/fmt/testdata/SortedImports/fmt.sol b/crates/fmt/testdata/SortedImports/fmt.sol new file mode 100644 index 0000000000000..f9b2c0ee2a9c3 --- /dev/null +++ b/crates/fmt/testdata/SortedImports/fmt.sol @@ -0,0 +1,34 @@ +// config: sort_imports = true +import "SomeFile0.sol" as SomeOtherFile; +import "SomeFile1.sol" as SomeOtherFile; +import "SomeFile2.sol"; +import "SomeFile3.sol"; + +import "AnotherFile1.sol" as SomeSymbol; +import "AnotherFile2.sol" as SomeSymbol; + +import { + symbol1 as alias3, + symbol2 as alias2, + symbol3 as alias1, + symbol4 +} from "File0.sol"; +import {symbol1 as alias, symbol2} from "File2.sol"; +import {symbol1 as alias, symbol2} from "File3.sol"; +import { + symbol1 as alias1, + symbol2 as alias2, + symbol3 as alias3, + symbol4 +} from "File6.sol"; + +uint256 constant someConstant = 10; + +import {Something2, Something3} from "someFile.sol"; + +// This is a comment +import {Something2, Something3} from "someFile.sol"; + +import {symbol1 as alias, symbol2} from "File3.sol"; +// comment inside group is treated as a separator for now +import {symbol1 as alias, symbol2} from "File2.sol"; diff --git a/crates/fmt/testdata/SortedImports/original.sol b/crates/fmt/testdata/SortedImports/original.sol new file mode 100644 index 0000000000000..54b3ca3b59cfb --- /dev/null +++ b/crates/fmt/testdata/SortedImports/original.sol @@ -0,0 +1,23 @@ +import "SomeFile3.sol"; +import "SomeFile2.sol"; +import "SomeFile1.sol" as SomeOtherFile; +import "SomeFile0.sol" as SomeOtherFile; + +import "AnotherFile2.sol" as SomeSymbol; +import "AnotherFile1.sol" as SomeSymbol; + +import {symbol2, symbol1 as alias} from "File3.sol"; +import {symbol2, symbol1 as alias} from "File2.sol"; +import {symbol2 as alias2, symbol1 as alias1, symbol3 as alias3, symbol4} from "File6.sol"; +import {symbol3 as alias1, symbol2 as alias2, symbol1 as alias3, symbol4} from "File0.sol"; + +uint256 constant someConstant = 10; + +import {Something3, Something2} from "someFile.sol"; + +// This is a comment +import {Something3, Something2} from "someFile.sol"; + +import {symbol2, symbol1 as alias} from "File3.sol"; +// comment inside group is treated as a separator for now +import {symbol2, symbol1 as alias} from "File2.sol"; \ No newline at end of file diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 5ef7154cd047f..13709b4e8058d 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -11,7 +11,7 @@ fn tracing() { let _ = tracing::subscriber::set_global_default(subscriber); } -fn test_directory(base_name: &str) { +fn test_directory(base_name: &str, test_config: TestConfig) { tracing(); let mut original = None; @@ -74,6 +74,7 @@ fn test_directory(base_name: &str) { config, original.as_ref().expect("original.sol not found"), &formatted, + test_config, ); } } @@ -82,7 +83,13 @@ fn assert_eof(content: &str) { assert!(content.ends_with('\n') && !content.ends_with("\n\n")); } -fn test_formatter(filename: &str, config: FormatterConfig, source: &str, expected_source: &str) { +fn test_formatter( + filename: &str, + config: FormatterConfig, + source: &str, + expected_source: &str, + test_config: TestConfig, +) { #[derive(Eq)] struct PrettyString(String); @@ -103,7 +110,7 @@ fn test_formatter(filename: &str, config: FormatterConfig, source: &str, expecte let source_parsed = parse(source).unwrap(); let expected_parsed = parse(expected_source).unwrap(); - if !source_parsed.pt.ast_eq(&expected_parsed.pt) { + if !test_config.skip_compare_ast_eq && !source_parsed.pt.ast_eq(&expected_parsed.pt) { pretty_assertions::assert_eq!( source_parsed.pt, expected_parsed.pt, @@ -118,7 +125,6 @@ fn test_formatter(filename: &str, config: FormatterConfig, source: &str, expecte format_to(&mut source_formatted, source_parsed, config.clone()).unwrap(); assert_eof(&source_formatted); - // println!("{}", source_formatted); let source_formatted = PrettyString(source_formatted); pretty_assertions::assert_eq!( @@ -142,13 +148,34 @@ fn test_formatter(filename: &str, config: FormatterConfig, source: &str, expecte ); } -macro_rules! test_directories { - ($($dir:ident),+ $(,)?) => {$( +#[derive(Default, Copy, Clone)] +struct TestConfig { + /// Whether to compare the formatted source code AST with the original AST + skip_compare_ast_eq: bool, +} + +impl TestConfig { + fn skip_compare_ast_eq() -> Self { + Self { skip_compare_ast_eq: true } + } +} + +macro_rules! test_dir { + ($dir:ident $(,)?) => { + test_dir!($dir, Default::default()); + }; + ($dir:ident, $config:expr $(,)?) => { #[allow(non_snake_case)] #[test] fn $dir() { - test_directory(stringify!($dir)); + test_directory(stringify!($dir), $config); } + }; +} + +macro_rules! test_directories { + ($($dir:ident),+ $(,)?) => {$( + test_dir!($dir); )+}; } @@ -202,3 +229,5 @@ test_directories! { EmitStatement, Repros, } + +test_dir!(SortedImports, TestConfig::skip_compare_ast_eq()); From 7d21fe7d01cf6d7ae7785327f3ead67f73a61116 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 12 Dec 2023 16:59:46 +0100 Subject: [PATCH 0400/1963] test: add alias test (#6585) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/config/src/etherscan.rs | 4 +++- crates/config/src/lib.rs | 27 +++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d82cf66ac6d5e..de7128f57bbed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f12f8177eddf9275fa9ae5fd73b50cee062f9b1eb95ef435f28354c79ba386" +checksum = "4df496257fe2fae392687ef30207325c50c68520108a94798b0c6cc1a6102f70" dependencies = [ "num_enum", "serde", diff --git a/Cargo.toml b/Cargo.toml index f04f0f55671a3..398936a749554 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,7 +148,7 @@ alloy-json-abi = "0.5.0" alloy-sol-types = "0.5.0" syn-solidity = "0.5.0" -alloy-chains = "0.1.4" +alloy-chains = "0.1.5" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 01e0f3b924501..1af928b7cced8 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -194,7 +194,9 @@ impl EtherscanConfig { Ok(ResolvedEtherscanConfig { api_url, browser_url: None, key, chain: None }) } (None, None) => { - let msg = alias.map(|a| format!(" for Etherscan config `{a}`")).unwrap_or_default(); + let msg = alias + .map(|a| format!(" for Etherscan config with unknown alias `{a}`")) + .unwrap_or_default(); Err(EtherscanConfigError::MissingUrlOrChain(msg)) } } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 5175775315d5c..e2725d6a6c130 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -3089,6 +3089,33 @@ mod tests { }) } + #[test] + fn test_resolve_rpc_aliases() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [profile.default] + [etherscan] + arbitrum_alias = { key = "${TEST_RESOLVE_RPC_ALIAS_ARBISCAN}" } + [rpc_endpoints] + arbitrum_alias = "https://arb-mainnet.g.alchemy.com/v2/${TEST_RESOLVE_RPC_ALIAS_ARB_ONE}" + "#, + )?; + + jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARB_ONE", "123455"); + jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARBISCAN", "123455"); + + let config = Config::load(); + + let config = config.get_etherscan_config_with_chain(Some(NamedChain::Arbitrum.into())); + assert!(config.is_err()); + assert_eq!(config.unwrap_err().to_string(), "At least one of `url` or `chain` must be present for Etherscan config with unknown alias `arbitrum_alias`"); + + Ok(()) + }); + } + #[test] fn test_resolve_endpoints() { figment::Jail::expect_with(|jail| { From fa26c843b6e2dbd63b60c068d01ff3d3f8c854d9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 13 Dec 2023 00:01:07 +0100 Subject: [PATCH 0401/1963] test: add test for custom type decoding (#6587) --- crates/forge/tests/cli/test_cmd.rs | 31 +++++++++++++++++++ .../include_custom_types_in_traces.stdout | 25 +++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 crates/forge/tests/fixtures/include_custom_types_in_traces.stdout diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index e7ed7747b1c8f..25a30a1fd0404 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -368,6 +368,7 @@ forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { cmd.assert_err(); }); +// forgetest_init!(repro_6531, |prj, cmd| { prj.wipe_contracts(); @@ -401,3 +402,33 @@ contract USDCCallingTest is Test { cmd.args(["test", "-vvvv"]).unchecked_output().stdout_matches_content(&expected); }); + +// +forgetest_init!(include_custom_types_in_traces, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "Contract.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +error PoolNotInitialized(); +event MyEvent(uint256 a); + +contract CustomTypesTest is Test { + function testErr() public pure { + revert PoolNotInitialized(); + } + function testEvent() public { + emit MyEvent(100); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "-vvvv"]).unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/include_custom_types_in_traces.stdout"), + ); +}); diff --git a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout new file mode 100644 index 0000000000000..be5d7706debb7 --- /dev/null +++ b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout @@ -0,0 +1,25 @@ +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 798.51ms +Compiler run successful! + +Running 2 tests for test/Contract.t.sol:CustomTypesTest +[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231) +Traces: + [231] CustomTypesTest::testErr() + └─ ← PoolNotInitialized() + +[PASS] testEvent() (gas: 1312) +Traces: + [1312] CustomTypesTest::testEvent() + ├─ emit MyEvent(a: 100) + └─ ← () + +Test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms + +Ran 1 test suites: 1 tests passed, 1 failed, 0 skipped (2 total tests) + +Failing tests: +Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest +[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231) + +Encountered a total of 1 failing tests, 1 tests succeeded From b6e6ce3110d478037040cb60789a247c26ff536c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 14 Dec 2023 02:35:39 +0400 Subject: [PATCH 0402/1963] Fix sender_nonce shadowing (#6589) * Fix sender_nonce shadowing * Fix sender_nonce --- crates/forge/bin/cmd/script/runner.rs | 3 +-- crates/forge/src/runner.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index ca5de4b28b47d..4dc2857db8834 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -70,8 +70,7 @@ impl ScriptRunner { .map(|traces| (TraceKind::Deployment, traces)) .collect(); - let sender_nonce = self.executor.get_nonce(CALLER)?; - let address = CALLER.create(sender_nonce); + let address = CALLER.create(self.executor.get_nonce(CALLER)?); // Set the contracts initial balance before deployment, so it is available during the // construction diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 4417c2309545c..389d22913e4fb 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -115,8 +115,7 @@ impl<'a> ContractRunner<'a> { } } - let sender_nonce = self.executor.get_nonce(self.sender)?; - let address = self.sender.create(sender_nonce); + let address = self.sender.create(self.executor.get_nonce(self.sender)?); // Set the contracts initial balance before deployment, so it is available during // construction From 53b15e6cee787a7765988bb7228f26f62eb78129 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 13 Dec 2023 19:32:28 -0400 Subject: [PATCH 0403/1963] chore: fix typos (#6597) --- docs/dev/cheatcodes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index a7dd39f1a33ff..43521f596d7cc 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -109,7 +109,7 @@ called in the [`Cheatcodes` inspector](#cheatcode-inspector) implementation. Generates the raw Rust bindings for the cheatcodes, as well as lets us specify custom attributes individually for each item, such as functions and structs, or for entire interfaces. -The way bindings are generated and extra information can be found the [`sol!`] documentation. +The way bindings are generated and extra information can be found in the [`sol!`] documentation. We leverage this macro to apply the [`Cheatcode` derive macro](#cheatcode-derive-macro) on the `Vm` interface. @@ -127,7 +127,7 @@ The latter is what fails compilation when adding a new cheatcode, and is fixed b [`Cheatcode` trait](#cheatcode-trait) to the newly-generated function call struct(s). The `Cheatcode` derive macro also parses the `#[cheatcode(...)]` attributes on functions, which are -used to specify additional properties the JSON interface. +used to specify additional properties of the JSON interface. These are all the attributes that can be specified on cheatcode functions: - `#[cheatcode(group = )]`: The group that the cheatcode belongs to. Required. From 6fcbbd866bc0f8a988471eb5588b8de33578bc74 Mon Sep 17 00:00:00 2001 From: Leechael Date: Fri, 15 Dec 2023 03:46:35 +0800 Subject: [PATCH 0404/1963] chore: add `--encoded-constructor-args` to `verify-contract` as alias for `--constructor-args` (#6454) * chore: fix `forge verify-contract` argument parsing * chore: add encoded-constructor-args alias --------- Co-authored-by: Enrique Ortiz --- crates/forge/bin/cmd/verify/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 1bcdd4c8baff5..09f033ec76251 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -45,7 +45,12 @@ pub struct VerifyArgs { pub contract: ContractInfo, /// The ABI-encoded constructor arguments. - #[clap(long, conflicts_with = "constructor_args_path", value_name = "ARGS")] + #[clap( + long, + conflicts_with = "constructor_args_path", + value_name = "ARGS", + visible_alias = "encoded-constructor-args" + )] pub constructor_args: Option, /// The path to a file containing the constructor arguments. From 3d6bfddf1e9335c623ba47b590da532f8d785ef4 Mon Sep 17 00:00:00 2001 From: Bobface Date: Fri, 15 Dec 2023 14:50:05 +0200 Subject: [PATCH 0405/1963] feat: re-implement event selector printing (#6607) --- crates/chisel/src/executor.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 9015ce1a10fa3..090d5d11794d6 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -450,7 +450,7 @@ fn format_event_definition(event_definition: &pt::EventDefinition) -> Result Result Date: Sat, 16 Dec 2023 18:32:38 +0100 Subject: [PATCH 0406/1963] fix: update outdated links to external resources (#6611) * fix: update outdated link to foundry book * fix: update outdated link fo gnosis safe FAQ --- crates/anvil/tests/it/anvil_api.rs | 2 +- crates/forge/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 6591dd25d3d26..1a7c19981ba75 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -187,7 +187,7 @@ async fn can_impersonate_gnosis_safe() { let (api, handle) = spawn(fork_config()).await; let provider = handle.http_provider(); - // + // let safe: Address = "0xA063Cb7CFd8E57c30c788A0572CBbf2129ae56B6".parse().unwrap(); let code = provider.get_code(safe, None).await.unwrap(); diff --git a/crates/forge/README.md b/crates/forge/README.md index 35cb196ced432..5ac9d57478b56 100644 --- a/crates/forge/README.md +++ b/crates/forge/README.md @@ -404,7 +404,7 @@ For example, if you have `@openzeppelin` imports, you would ## Github Actions CI -We recommend using the [Github Actions CI setup](https://book.getfoundry.sh/config/continous-integration.html) from the [📖 Foundry Book](https://book.getfoundry.sh/index.html). +We recommend using the [Github Actions CI setup](https://book.getfoundry.sh/config/continuous-integration) from the [📖 Foundry Book](https://book.getfoundry.sh/index.html). ## Future Features From 9888a7a954120823d0d0ebf34f2984bb269ef0d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Dec 2023 23:20:09 +0200 Subject: [PATCH 0407/1963] chore(deps): weekly `cargo update` (#6612) --- Cargo.lock | 171 ++++++++++++++++++++++++++--------------------------- 1 file changed, 85 insertions(+), 86 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de7128f57bbed..3c118719d80a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fafc3b20c6d069d9db47037f34acfb0e079c050fa5c1ff9e79855609b359b92b" +checksum = "74ab9cc043cd4b0a806f79e32624c148efecd9c9395e4a75000d51fdc9726be0" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d32061da2f184e5defab8e65a3057f88b7017cfe1ea9e2d6b413edb5ca76a54" +checksum = "cf8889c85658aae27e96515ff2c9200cb8d8c78baefad5aee088e49b47f5f6f3" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -122,9 +122,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08ca2c09d5911548a5cb620382ea0e1af99d3c898ce0efecbbd274a4676cf53e" +checksum = "6c0e5e60ff0e0c34c553822dabcfe0f5fece5a8c52f08a915be8c737de4b03fa" dependencies = [ "alloy-rlp", "arbitrary", @@ -165,14 +165,14 @@ checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] name = "alloy-sol-macro" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e40cea54ac58080a1b88ea6556866eac1902b321186c77d53ad2b5ebbbf0e038" +checksum = "a8c9d43ca0a56b356f35775deecc8f660ac99e34cbf4a33462d4bd8addd9ab6f" dependencies = [ "alloy-json-abi", "const-hex", @@ -183,25 +183,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.39", + "syn 2.0.41", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-type-parser" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23cb462613b2046da46dbf69ebaee458b7bfd3e9d7fe05adcce38a8d4b8a14f" +checksum = "41cdf1064e9b5160ae47b5190171a0655c8b4966b9657b04f48ff5d868684ade" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81aa34725607be118c395d62c1d8d97c8a343dd1ada5370ed508ed5232eab6a" +checksum = "c169266a4b5ecf6f471947be10690f0aa295063774853b50540708b267a96e51" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -575,7 +575,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -586,7 +586,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -759,7 +759,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.39", + "syn 2.0.41", "which", ] @@ -1211,7 +1211,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -1404,9 +1404,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "constant_time_eq" @@ -1518,9 +1518,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "14c3242926edf34aec4ac3a77108ad4854bffaa2e4ddc1824124ce59231302d5" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1528,9 +1528,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -1539,22 +1539,21 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", "memoffset 0.9.0", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" dependencies = [ "cfg-if", ] @@ -1698,7 +1697,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -1939,7 +1938,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -2137,7 +2136,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.39", + "syn 2.0.41", "toml 0.8.8", "walkdir", ] @@ -2154,7 +2153,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -2179,7 +2178,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.39", + "syn 2.0.41", "tempfile", "thiserror", "tiny-keccak", @@ -2347,9 +2346,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bbb8258be8305fb0237d7b295f47bb24ff1b136a535f473baf40e70468515aa" +checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" dependencies = [ "indenter", "once_cell", @@ -2382,7 +2381,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -2775,7 +2774,7 @@ dependencies = [ "glob", "home", "md-5 0.10.6", - "memmap2 0.9.0", + "memmap2 0.9.1", "num_cpus", "once_cell", "path-slash", @@ -2984,7 +2983,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -3116,7 +3115,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -3624,11 +3623,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.5" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -4124,9 +4123,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libgit2-sys" @@ -4330,9 +4329,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375" +checksum = "8f850157af41022bbb1b04ed15c011ce4d59520be82a4e3718b10c34b02cb85e" dependencies = [ "libc", ] @@ -4386,7 +4385,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -4647,7 +4646,7 @@ dependencies = [ "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -4751,7 +4750,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -4940,9 +4939,9 @@ dependencies = [ [[package]] name = "pear" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a386cd715229d399604b50d1361683fe687066f42d56f54be995bc6868f71c" +checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" dependencies = [ "inlinable_string", "pear_codegen", @@ -4951,14 +4950,14 @@ dependencies = [ [[package]] name = "pear_codegen" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f0f13dac8069c139e8300a6510e3f4143ecf5259c60b116a9b271b4ca0d54" +checksum = "2e22670e8eb757cff11d6c199ca7b987f352f0346e0be4dd23869ec72cb53c77" dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -5013,7 +5012,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -5116,7 +5115,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -5154,7 +5153,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -5254,7 +5253,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -5331,7 +5330,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", "version_check", "yansi 1.0.0-rc.1", ] @@ -6320,7 +6319,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -6374,7 +6373,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -6420,7 +6419,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -6702,7 +6701,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -6770,9 +6769,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" dependencies = [ "proc-macro2", "quote", @@ -6781,14 +6780,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2c7ad08db24862d5b787a94714ff6b047935c3e3f60af944ac969404debd7ff" +checksum = "c4e95b65f5854377a31ebfa69d71b87c9d0d9922fddbfeb91a8eda4a0c5868eb" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -6905,22 +6904,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -7034,7 +7033,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -7255,7 +7254,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -7621,7 +7620,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", "wasm-bindgen-shared", ] @@ -7655,7 +7654,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8001,9 +8000,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.26" +version = "0.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff" +checksum = "6c830786f7720c2fd27a1a0e27a709dbd3c4d009b56d098fc742d4f4eab91fe2" dependencies = [ "memchr", ] @@ -8066,22 +8065,22 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.30" +version = "0.7.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306dca4455518f1f31635ec308b6b3e4eb1b11758cefafc782827d0aa7acb5c7" +checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.30" +version = "0.7.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be912bf68235a88fbefd1b73415cb218405958d1655b2ece9035a19920bdf6ba" +checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] @@ -8101,7 +8100,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.41", ] [[package]] From 477b3450f464bbe763dad6b38f718fa467e841d2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 17 Dec 2023 23:02:10 +0100 Subject: [PATCH 0408/1963] chore: remove outdated clippy (#6614) * chore: remove outdated clippy * chore: rm weird match --- crates/common/src/runtime_client.rs | 1 - crates/evm/core/src/fork/backend.rs | 14 ++++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index 972ee9029540a..a14ea20593be7 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -277,7 +277,6 @@ fn url_to_file_path(url: &Url) -> Result { impl JsonRpcClient for RuntimeClient { type Error = RuntimeClientError; - #[allow(implied_bounds_entailment)] async fn request(&self, method: &str, params: T) -> Result where T: Debug + Serialize + Send + Sync, diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index ed708bc011736..4ef698eb6bbd7 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -661,16 +661,13 @@ impl DatabaseRef for SharedBackend { fn storage_ref(&self, address: Address, index: U256) -> Result { trace!(target: "sharedbackend", "request storage {:?} at {:?}", address, index); - match self.do_get_storage(address, index).map_err(|err| { + self.do_get_storage(address, index).map_err(|err| { error!(target: "sharedbackend", %err, %address, %index, "Failed to send/recv `storage`"); if err.is_possibly_non_archive_node_error() { error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); } err - }) { - Ok(val) => Ok(val), - Err(err) => Err(err), - } + }) } fn block_hash_ref(&self, number: U256) -> Result { @@ -680,16 +677,13 @@ impl DatabaseRef for SharedBackend { let number: U256 = number; let number = number.to(); trace!(target: "sharedbackend", "request block hash for number {:?}", number); - match self.do_get_block_hash(number).map_err(|err| { + self.do_get_block_hash(number).map_err(|err| { error!(target: "sharedbackend", %err, %number, "Failed to send/recv `block_hash`"); if err.is_possibly_non_archive_node_error() { error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); } err - }) { - Ok(val) => Ok(val), - Err(err) => Err(err), - } + }) } } From 6a42b0f4d142a42b36c63de13065e15ee0bc3744 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 18 Dec 2023 20:44:33 +0400 Subject: [PATCH 0409/1963] Fix multichain scripts resume functionality (#6447) * Add test * Multi script caching * Change to function --- crates/forge/bin/cmd/script/broadcast.rs | 2 +- crates/forge/bin/cmd/script/cmd.rs | 2 +- crates/forge/bin/cmd/script/multi.rs | 112 ++++++++++++++++++----- crates/forge/bin/cmd/script/sequence.rs | 15 +-- crates/forge/tests/cli/multi_script.rs | 15 +++ 5 files changed, 115 insertions(+), 31 deletions(-) diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 270552ec78d7f..a0523ba918ad7 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -296,7 +296,7 @@ impl ScriptArgs { deployments.clone(), &self.sig, script_config.target_contract(), - &script_config.config.broadcast, + &script_config.config, self.broadcast, )?; diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 3fbdfc5149508..5aadaa9771044 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -192,7 +192,7 @@ impl ScriptArgs { return self .multi_chain_deployment( MultiChainSequence::load( - &script_config.config.broadcast, + &script_config.config, &self.sig, script_config.target_contract(), )?, diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index 7fa4709a96340..a412ca4534265 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -1,6 +1,6 @@ use super::{ receipts, - sequence::{ScriptSequence, DRY_RUN_DIR}, + sequence::{sig_to_file_name, ScriptSequence, SensitiveScriptSequence, DRY_RUN_DIR}, verify::VerifyBundle, ScriptArgs, }; @@ -22,10 +22,25 @@ use std::{ #[derive(Deserialize, Serialize, Clone, Default)] pub struct MultiChainSequence { pub deployments: Vec, + #[serde(skip)] pub path: PathBuf, + #[serde(skip)] + pub sensitive_path: PathBuf, pub timestamp: u64, } +/// Sensitive values from script sequences. +#[derive(Deserialize, Serialize, Clone, Default)] +pub struct SensitiveMultiChainSequence { + pub deployments: Vec, +} + +fn to_sensitive(sequence: &mut MultiChainSequence) -> SensitiveMultiChainSequence { + SensitiveMultiChainSequence { + deployments: sequence.deployments.iter_mut().map(|sequence| sequence.into()).collect(), + } +} + impl Drop for MultiChainSequence { fn drop(&mut self) { self.deployments.iter_mut().for_each(|sequence| sequence.sort_receipts()); @@ -38,26 +53,38 @@ impl MultiChainSequence { deployments: Vec, sig: &str, target: &ArtifactId, - log_folder: &Path, + config: &Config, broadcasted: bool, ) -> Result { - let path = - MultiChainSequence::get_path(&log_folder.join("multi"), sig, target, broadcasted)?; - - Ok(MultiChainSequence { deployments, path, timestamp: now().as_secs() }) + let (path, sensitive_path) = MultiChainSequence::get_paths( + &config.broadcast, + &config.cache_path, + sig, + target, + broadcasted, + )?; + + Ok(MultiChainSequence { deployments, path, sensitive_path, timestamp: now().as_secs() }) } - /// Saves to ./broadcast/multi/contract_filename[-timestamp]/sig.json - pub fn get_path( - out: &Path, + /// Gets paths in the formats + /// ./broadcast/multi/contract_filename[-timestamp]/sig.json and + /// ./cache/multi/contract_filename[-timestamp]/sig.json + pub fn get_paths( + broadcast: &Path, + cache: &Path, sig: &str, target: &ArtifactId, broadcasted: bool, - ) -> Result { - let mut out = out.to_path_buf(); + ) -> Result<(PathBuf, PathBuf)> { + let mut broadcast = broadcast.to_path_buf(); + let mut cache = cache.to_path_buf(); + let mut common = PathBuf::new(); + + common.push("multi"); if !broadcasted { - out.push(DRY_RUN_DIR); + common.push(DRY_RUN_DIR); } let target_fname = target @@ -65,29 +92,55 @@ impl MultiChainSequence { .file_name() .wrap_err_with(|| format!("No filename for {:?}", target.source))? .to_string_lossy(); - out.push(format!("{target_fname}-latest")); - fs::create_dir_all(&out)?; + common.push(format!("{target_fname}-latest")); + + broadcast.push(common.clone()); + cache.push(common); - let filename = sig - .split_once('(') - .wrap_err_with(|| format!("Failed to compute file name: Signature {sig} is invalid."))? - .0; - out.push(format!("{filename}.json")); + fs::create_dir_all(&broadcast)?; + fs::create_dir_all(&cache)?; - Ok(out) + let filename = format!("{}.json", sig_to_file_name(sig)); + + broadcast.push(filename.clone()); + cache.push(filename); + + Ok((broadcast, cache)) } /// Loads the sequences for the multi chain deployment. - pub fn load(log_folder: &Path, sig: &str, target: &ArtifactId) -> Result { - let path = MultiChainSequence::get_path(&log_folder.join("multi"), sig, target, true)?; - foundry_compilers::utils::read_json_file(path).wrap_err("Multi-chain deployment not found.") + pub fn load(config: &Config, sig: &str, target: &ArtifactId) -> Result { + let (path, sensitive_path) = MultiChainSequence::get_paths( + &config.broadcast, + &config.cache_path, + sig, + target, + true, + )?; + let mut sequence: MultiChainSequence = foundry_compilers::utils::read_json_file(&path) + .wrap_err("Multi-chain deployment not found.")?; + let sensitive_sequence: SensitiveMultiChainSequence = + foundry_compilers::utils::read_json_file(&sensitive_path) + .wrap_err("Multi-chain deployment sensitive details not found.")?; + + sequence.deployments.iter_mut().enumerate().for_each(|(i, sequence)| { + sequence.fill_sensitive(&sensitive_sequence.deployments[i]); + }); + + sequence.path = path; + sequence.sensitive_path = sensitive_path; + + Ok(sequence) } /// Saves the transactions as file if it's a standalone deployment. pub fn save(&mut self) -> Result<()> { self.timestamp = now().as_secs(); + let sensitive_sequence: SensitiveMultiChainSequence = to_sensitive(self); + + // broadcast writes //../Contract-latest/run.json let mut writer = BufWriter::new(fs::create_file(&self.path)?); serde_json::to_writer_pretty(&mut writer, &self)?; @@ -99,7 +152,20 @@ impl MultiChainSequence { fs::create_dir_all(file.parent().unwrap())?; fs::copy(&self.path, &file)?; + // cache writes + //../Contract-latest/run.json + let mut writer = BufWriter::new(fs::create_file(&self.sensitive_path)?); + serde_json::to_writer_pretty(&mut writer, &sensitive_sequence)?; + writer.flush()?; + + //../Contract-[timestamp]/run.json + let path = self.sensitive_path.to_string_lossy(); + let file = PathBuf::from(&path.replace("-latest", &format!("-{}", self.timestamp))); + fs::create_dir_all(file.parent().unwrap())?; + fs::copy(&self.sensitive_path, &file)?; + println!("\nTransactions saved to: {}\n", self.path.display()); + println!("Sensitive details saved to: {}\n", self.sensitive_path.display()); Ok(()) } diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 62068aaf4fbd0..6b6eb4acacb8e 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -136,11 +136,7 @@ impl ScriptSequence { "Deployment's sensitive details not found for chain `{chain_id}`." ))?; - script_sequence - .transactions - .iter_mut() - .enumerate() - .for_each(|(i, tx)| tx.rpc = sensitive_script_sequence.transactions[i].rpc.clone()); + script_sequence.fill_sensitive(&sensitive_script_sequence); script_sequence.path = path; script_sequence.sensitive_path = sensitive_path; @@ -366,6 +362,13 @@ impl ScriptSequence { }) .collect() } + + pub fn fill_sensitive(&mut self, sensitive: &SensitiveScriptSequence) { + self.transactions + .iter_mut() + .enumerate() + .for_each(|(i, tx)| tx.rpc = sensitive.transactions[i].rpc.clone()); + } } impl Drop for ScriptSequence { @@ -379,7 +382,7 @@ impl Drop for ScriptSequence { /// /// This accepts either the signature of the function or the raw calldata -fn sig_to_file_name(sig: &str) -> String { +pub fn sig_to_file_name(sig: &str) -> String { if let Some((name, _)) = sig.split_once('(') { // strip until call argument parenthesis return name.to_string() diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index fb052b40b8a8d..f6f3adb9dadb4 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -61,3 +61,18 @@ forgetest_async!(can_not_change_fork_during_broadcast, |prj, cmd| { .args(&[&handle1.http_endpoint(), &handle2.http_endpoint()]) .broadcast(ScriptOutcome::ErrorSelectForkOnBroadcast); }); + +forgetest_async!(can_resume_multi_chain_script, |prj, cmd| { + let (_, handle1) = spawn(NodeConfig::test()).await; + let (_, handle2) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); + + tester + .add_sig("MultiChainBroadcastNoLink", "deploy(string memory,string memory)") + .args(&[&handle1.http_endpoint(), &handle2.http_endpoint()]) + .broadcast(ScriptOutcome::MissingWallet) + .load_private_keys(&[0, 1]) + .await + .arg("--multi") + .resume(ScriptOutcome::OkBroadcast); +}); From 73fb616bca68507a705456458899ff5b2232a948 Mon Sep 17 00:00:00 2001 From: clabby Date: Mon, 18 Dec 2023 14:34:25 -0500 Subject: [PATCH 0410/1963] chisel: add bit size information to `int` & `uint` types (#6620) --- crates/chisel/src/executor.rs | 38 ++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 090d5d11794d6..0864ce2ea9240 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -321,26 +321,44 @@ fn format_token(token: DynSolValue) -> String { DynSolValue::Address(a) => { format!("Type: {}\n└ Data: {}", Paint::red("address"), Paint::cyan(a.to_string())) } - DynSolValue::FixedBytes(b, _) => { + DynSolValue::FixedBytes(b, byte_len) => { format!( "Type: {}\n└ Data: {}", - Paint::red(format!("bytes{}", b.len())), + Paint::red(format!("bytes{byte_len}")), Paint::cyan(hex::encode_prefixed(b)) ) } - DynSolValue::Int(i, _) => { + DynSolValue::Int(i, bit_len) => { format!( - "Type: {}\n├ Hex: {}\n└ Decimal: {}", - Paint::red("int"), - Paint::cyan(format!("0x{i:x}")), + "Type: {}\n├ Hex: {}\n├ Hex (full word): {}\n└ Decimal: {}", + Paint::red(format!("int{}", bit_len)), + Paint::cyan(format!( + "0x{}", + format!("{i:x}") + .char_indices() + .skip(64 - bit_len / 4) + .take(bit_len / 4) + .map(|(_, c)| c) + .collect::() + )), + Paint::cyan(format!("{i:#x}")), Paint::cyan(i) ) } - DynSolValue::Uint(i, _) => { + DynSolValue::Uint(i, bit_len) => { format!( - "Type: {}\n├ Hex: {}\n└ Decimal: {}", - Paint::red("uint"), - Paint::cyan(format!("0x{i:x}")), + "Type: {}\n├ Hex: {}\n├ Hex (full word): {}\n└ Decimal: {}", + Paint::red(format!("uint{}", bit_len)), + Paint::cyan(format!( + "0x{}", + format!("{i:x}") + .char_indices() + .skip(64 - bit_len / 4) + .take(bit_len / 4) + .map(|(_, c)| c) + .collect::() + )), + Paint::cyan(format!("{i:#x}")), Paint::cyan(i) ) } From b9d9a5cab21100450eb644dc087fdb5648550e76 Mon Sep 17 00:00:00 2001 From: maxim <92998635+0xmp@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:04:45 -0500 Subject: [PATCH 0411/1963] fix(forge): Don't ignore config.toml when running invariant tests for coverage (#6566) * fix(forge): Coverage for invariant tests no longer take default config * chore: fmt/merge --------- Co-authored-by: 0xmp <> Co-authored-by: Enrique Ortiz --- crates/forge/bin/cmd/coverage.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 4ee84951ac881..2c2e00b0858a9 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -301,7 +301,11 @@ impl CoverageArgs { .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone())) - .with_test_options(TestOptions { fuzz: config.fuzz, ..Default::default() }) + .with_test_options(TestOptions { + fuzz: config.fuzz, + invariant: config.invariant, + ..Default::default() + }) .set_coverage(true) .build(root.clone(), output, env, evm_opts)?; @@ -309,8 +313,9 @@ impl CoverageArgs { let known_contracts = runner.known_contracts.clone(); let filter = self.filter; let (tx, rx) = channel::<(String, SuiteResult)>(); - let handle = - tokio::task::spawn(async move { runner.test(&filter, tx, Default::default()).await }); + let handle = tokio::task::spawn(async move { + runner.test(&filter, tx, runner.test_options.clone()).await + }); // Add hit data to the coverage report let data = rx From eb2141c6b756e06437b837294d6fa485cb3916ef Mon Sep 17 00:00:00 2001 From: mountainpath9 <93360511+mountainpath9@users.noreply.github.com> Date: Wed, 20 Dec 2023 01:30:41 +1100 Subject: [PATCH 0412/1963] Bytecode level coverage reporting (#6563) * feat(forge): add bytecode level coverage report * include source references in bytecode coverage * map source ranges to linenumbers in bytecode coverage * clippy fixes * format fixes * nits --------- Co-authored-by: Enrique Ortiz --- Cargo.lock | 1 + Cargo.toml | 1 + crates/cast/Cargo.toml | 2 +- crates/evm/coverage/src/lib.rs | 53 ++++++++++++++- crates/forge/Cargo.toml | 1 + crates/forge/bin/cmd/coverage.rs | 18 +++-- crates/forge/src/coverage.rs | 109 ++++++++++++++++++++++++++++++- 7 files changed, 178 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c118719d80a4..50f1e23a07811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2527,6 +2527,7 @@ dependencies = [ "ethers-middleware", "ethers-providers", "ethers-signers", + "evm-disassembler", "eyre", "forge-doc", "forge-fmt", diff --git a/Cargo.toml b/Cargo.toml index 398936a749554..ba2c45fff1dfb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,6 +168,7 @@ serde_json = { version = "1.0", features = ["arbitrary_precision"] } toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" +evm-disassembler = "0.3" axum = "0.6" hyper = "0.14" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index c822ffb75336a..2dad8ff5b8298 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -34,7 +34,7 @@ ethers-core.workspace = true ethers-providers.workspace = true chrono.workspace = true -evm-disassembler = "0.3" +evm-disassembler.workspace = true eyre.workspace = true futures = "0.3" hex.workspace = true diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 0ae3d6ea4ae73..cd9785b12ef1f 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -8,6 +8,7 @@ extern crate tracing; use alloy_primitives::{Bytes, B256}; +use foundry_compilers::sourcemap::SourceElement; use semver::Version; use std::{ collections::{BTreeMap, HashMap}, @@ -15,6 +16,8 @@ use std::{ ops::{AddAssign, Deref, DerefMut}, }; +use eyre::{Context, Result}; + pub mod analysis; pub mod anchors; @@ -35,6 +38,10 @@ pub struct CoverageReport { pub items: HashMap>, /// All item anchors for the codebase, keyed by their contract ID. pub anchors: HashMap>, + /// All the bytecode hits for the codebase + pub bytecode_hits: HashMap, + /// The bytecode -> source mappings + pub source_maps: HashMap, Vec)>, } impl CoverageReport { @@ -49,6 +56,14 @@ impl CoverageReport { self.source_paths_to_ids.get(&(version, path)) } + /// Add the source maps + pub fn add_source_maps( + &mut self, + source_maps: HashMap, Vec)>, + ) { + self.source_maps.extend(source_maps); + } + /// Add coverage items to this report pub fn add_items(&mut self, version: Version, items: Vec) { self.items.entry(version).or_default().extend(items); @@ -109,7 +124,20 @@ impl CoverageReport { /// /// This function should only be called *after* all the relevant sources have been processed and /// added to the map (see [add_source]). - pub fn add_hit_map(&mut self, contract_id: &ContractId, hit_map: &HitMap) { + pub fn add_hit_map(&mut self, contract_id: &ContractId, hit_map: &HitMap) -> Result<()> { + // Add bytecode level hits + let e = self + .bytecode_hits + .entry(contract_id.clone()) + .or_insert_with(|| HitMap::new(hit_map.bytecode.clone())); + e.merge(hit_map).context(format!( + "contract_id {:?}, hash {}, hash {}", + contract_id, + e.bytecode.clone(), + hit_map.bytecode.clone(), + ))?; + + // Add source level hits if let Some(anchors) = self.anchors.get(contract_id) { for anchor in anchors { if let Some(hits) = hit_map.hits.get(&anchor.instruction) { @@ -121,6 +149,7 @@ impl CoverageReport { } } } + Ok(()) } } @@ -174,6 +203,28 @@ impl HitMap { pub fn hit(&mut self, pc: usize) { *self.hits.entry(pc).or_default() += 1; } + + /// Merge another hitmap into this, assuming the bytecode is consistent + pub fn merge(&mut self, other: &HitMap) -> Result<(), eyre::Report> { + for (pc, hits) in &other.hits { + *self.hits.entry(*pc).or_default() += hits; + } + Ok(()) + } + + pub fn consistent_bytecode(&self, hm1: &HitMap, hm2: &HitMap) -> bool { + // Consider the bytecodes consistent if they are the same out as far as the + // recorded hits + let len1 = hm1.hits.last_key_value(); + let len2 = hm2.hits.last_key_value(); + if let (Some(len1), Some(len2)) = (len1, len2) { + let len = std::cmp::max(len1.0, len2.0); + let ok = hm1.bytecode.0[..*len] == hm2.bytecode.0[..*len]; + println!("consistent_bytecode: {}, {}, {}, {}", ok, len1.0, len2.0, len); + return ok; + } + true + } } /// A unique identifier for a contract diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index f09ffa216ab98..0779ecb4ee9c8 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -71,6 +71,7 @@ strum = { version = "0.25", features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["time"] } watchexec = "2.3.2" +evm-disassembler.workspace = true # doc server axum = { workspace = true, features = ["ws"] } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 2c2e00b0858a9..e9b1ba3a5e53d 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -4,8 +4,8 @@ use clap::{Parser, ValueEnum, ValueHint}; use eyre::{Context, Result}; use forge::{ coverage::{ - analysis::SourceAnalyzer, anchors::find_anchors, ContractId, CoverageReport, - CoverageReporter, DebugReporter, ItemAnchor, LcovReporter, SummaryReporter, + analysis::SourceAnalyzer, anchors::find_anchors, BytecodeReporter, ContractId, + CoverageReport, CoverageReporter, DebugReporter, ItemAnchor, LcovReporter, SummaryReporter, }, inspectors::CheatsConfig, opts::EvmOpts, @@ -161,6 +161,8 @@ impl CoverageArgs { let mut versioned_asts: HashMap> = HashMap::new(); let mut versioned_sources: HashMap> = HashMap::new(); for (path, mut source_file, version) in sources.into_sources_with_version() { + report.add_source(version.clone(), source_file.id as usize, path.clone()); + // Filter out dependencies if project_paths.has_library_ancestor(std::path::Path::new(&path)) { continue @@ -180,7 +182,6 @@ impl CoverageArgs { fs::read_to_string(&file) .wrap_err("Could not read source code for analysis")?, ); - report.add_source(version, source_file.id as usize, path); } } @@ -279,6 +280,8 @@ impl CoverageArgs { report.add_anchors(anchors); } + report.add_source_maps(source_maps); + Ok(report) } @@ -342,7 +345,7 @@ impl CoverageArgs { contract_name: artifact_id.name.clone(), }, &hits, - ); + )?; } } @@ -367,6 +370,12 @@ impl CoverageArgs { .report(&report) } } + CoverageReportKind::Bytecode => { + let destdir = root.join("bytecode-coverage"); + fs::create_dir_all(&destdir)?; + BytecodeReporter::new(root.clone(), destdir).report(&report)?; + Ok(()) + } CoverageReportKind::Debug => DebugReporter.report(&report), }?; } @@ -385,6 +394,7 @@ pub enum CoverageReportKind { Summary, Lcov, Debug, + Bytecode, } /// Helper function that will link references in unlinked bytecode to the 0 address. diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 2561de9aee086..dda7eba6e4fc3 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -1,8 +1,14 @@ //! Coverage reports. use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Row, Table}; +use evm_disassembler::disassemble_bytes; +use foundry_common::fs; pub use foundry_evm::coverage::*; -use std::io::Write; +use std::{ + collections::{hash_map, HashMap}, + io::Write, + path::PathBuf, +}; /// A coverage reporter. pub trait CoverageReporter { @@ -170,3 +176,104 @@ impl CoverageReporter for DebugReporter { Ok(()) } } + +pub struct BytecodeReporter { + root: PathBuf, + destdir: PathBuf, +} + +impl BytecodeReporter { + pub fn new(root: PathBuf, destdir: PathBuf) -> BytecodeReporter { + Self { root, destdir } + } +} + +impl CoverageReporter for BytecodeReporter { + fn report(self, report: &CoverageReport) -> eyre::Result<()> { + use std::fmt::Write; + + let no_source_elements = Vec::new(); + let mut line_number_cache = LineNumberCache::new(self.root.clone()); + + for (contract_id, hits) in &report.bytecode_hits { + let ops = disassemble_bytes(hits.bytecode.to_vec())?; + let mut formatted = String::new(); + + let source_elements = + report.source_maps.get(contract_id).map(|sm| &sm.1).unwrap_or(&no_source_elements); + + for (code, source_element) in std::iter::zip(ops.iter(), source_elements) { + let hits = hits + .hits + .get(&(code.offset as usize)) + .map(|h| format!("[{:03}]", h)) + .unwrap_or(" ".to_owned()); + let source_id = source_element.index; + let source_path = source_id.and_then(|i| { + report.source_paths.get(&(contract_id.version.clone(), i as usize)) + }); + + let code = format!("{:?}", code); + let start = source_element.offset; + let end = source_element.offset + source_element.length; + + if let Some(source_path) = source_path { + let (sline, spos) = line_number_cache.get_position(source_path, start)?; + let (eline, epos) = line_number_cache.get_position(source_path, end)?; + writeln!( + formatted, + "{} {:40} // {}: {}:{}-{}:{} ({}-{})", + hits, code, source_path, sline, spos, eline, epos, start, end + )?; + } else if let Some(source_id) = source_id { + writeln!( + formatted, + "{} {:40} // SRCID{}: ({}-{})", + hits, code, source_id, start, end + )?; + } else { + writeln!(formatted, "{} {:40}", hits, code)?; + } + } + fs::write( + &self.destdir.join(contract_id.contract_name.clone()).with_extension("asm"), + formatted, + )?; + } + + Ok(()) + } +} + +/// Cache line number offsets for source files +struct LineNumberCache { + root: PathBuf, + line_offsets: HashMap>, +} + +impl LineNumberCache { + pub fn new(root: PathBuf) -> Self { + LineNumberCache { root, line_offsets: HashMap::new() } + } + + pub fn get_position(&mut self, path: &str, offset: usize) -> eyre::Result<(usize, usize)> { + let line_offsets = match self.line_offsets.entry(path.to_owned()) { + hash_map::Entry::Occupied(o) => o.into_mut(), + hash_map::Entry::Vacant(v) => { + let text = fs::read_to_string(self.root.join(path))?; + let mut line_offsets = vec![0]; + for line in text.lines() { + let line_offset = line.as_ptr() as usize - text.as_ptr() as usize; + line_offsets.push(line_offset); + } + v.insert(line_offsets) + } + }; + let lo = match line_offsets.binary_search(&offset) { + Ok(lo) => lo, + Err(lo) => lo - 1, + }; + let pos = offset - line_offsets.get(lo).unwrap() + 1; + Ok((lo, pos)) + } +} From aaf1273b22a32070377a29ab7a228eb486eaec73 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 20 Dec 2023 15:18:23 +0100 Subject: [PATCH 0413/1963] fix: tightly pack doc comments (#6624) * fix: tightly pack doc comments * docs: wording --- crates/fmt/src/comments.rs | 4 +++ crates/fmt/src/formatter.rs | 22 ++++++++++++++-- crates/fmt/testdata/BlockComments/fmt.sol | 25 ++++++++++++++++++ .../fmt/testdata/BlockComments/original.sol | 26 +++++++++++++++++++ crates/fmt/tests/formatter.rs | 1 + 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 crates/fmt/testdata/BlockComments/fmt.sol create mode 100644 crates/fmt/testdata/BlockComments/original.sol diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index f0316aa2b9c9a..4b373590b35fe 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -152,6 +152,10 @@ impl CommentWithMetadata { matches!(self.ty, CommentType::Line | CommentType::DocLine) } + pub fn is_doc_block(&self) -> bool { + matches!(self.ty, CommentType::DocBlock) + } + pub fn is_prefix(&self) -> bool { matches!(self.position, CommentPosition::Prefix) } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 79fd2aa6b03a7..3312b00b73ca3 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -957,7 +957,10 @@ impl<'a, W: Write> Formatter<'a, W> { let mut last_loc: Option = None; let mut visited_locs: Vec = Vec::new(); + // marker for whether the next item needs additional space let mut needs_space = false; + let mut last_comment = None; + while let Some(mut line_item) = pop_next(self, &mut items) { let loc = line_item.as_ref().either(|c| c.loc, |i| i.loc()); let (unwritten_whitespace_loc, unwritten_whitespace) = @@ -999,7 +1002,19 @@ impl<'a, W: Write> Formatter<'a, W> { last_loc = *last_item; } - if needs_space || self.blank_lines(last_loc.end(), loc.start()) > 1 { + // The blank lines check is susceptible additional trailing new lines + // because the block docs can contain + // multiple lines, but the function def should follow directly after the + // block comment + let is_last_doc_comment = matches!( + last_comment, + Some(CommentWithMetadata { ty: CommentType::DocBlock, .. }) + ); + + if needs_space || + (!is_last_doc_comment && + self.blank_lines(last_loc.end(), loc.start()) > 1) + { writeln!(self.buf())?; } } @@ -1018,12 +1033,15 @@ impl<'a, W: Write> Formatter<'a, W> { last_loc = Some(loc); visited_locs.push(loc); + last_comment = None; + last_byte_written = loc.end(); - if let Some(comment) = line_item.as_ref().left() { + if let Some(comment) = line_item.left() { if comment.is_line() { last_byte_written = self.find_next_line(last_byte_written).unwrap_or(last_byte_written); } + last_comment = Some(comment); } } diff --git a/crates/fmt/testdata/BlockComments/fmt.sol b/crates/fmt/testdata/BlockComments/fmt.sol new file mode 100644 index 0000000000000..1d7025f2ad591 --- /dev/null +++ b/crates/fmt/testdata/BlockComments/fmt.sol @@ -0,0 +1,25 @@ +contract CounterTest is Test { + /** + * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev See {IERC721-balanceOf}. + */ + function test_Increment() public { + counter.increment(); + assertEq(counter.number(), 1); + } + + /** + * @dev See {IERC165-supportsInterface}. + */ + function test_Increment() public { + counter.increment(); + assertEq(counter.number(), 1); + } +} diff --git a/crates/fmt/testdata/BlockComments/original.sol b/crates/fmt/testdata/BlockComments/original.sol new file mode 100644 index 0000000000000..b91934bf7d12b --- /dev/null +++ b/crates/fmt/testdata/BlockComments/original.sol @@ -0,0 +1,26 @@ +contract CounterTest is Test { + /** + * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. + */ + + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev See {IERC721-balanceOf}. + */ + function test_Increment() public { + counter.increment(); + assertEq(counter.number(), 1); + } + + /** + * @dev See {IERC165-supportsInterface}. + */ function test_Increment() public { + counter.increment(); + assertEq(counter.number(), 1); +} + +} \ No newline at end of file diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 13709b4e8058d..317cd28efd3e5 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -228,6 +228,7 @@ test_directories! { MappingType, EmitStatement, Repros, + BlockComments, } test_dir!(SortedImports, TestConfig::skip_compare_ast_eq()); From 8be264961d104501cbfa8e6fb85b7fabd316cb3f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 20 Dec 2023 16:44:34 +0100 Subject: [PATCH 0414/1963] feat(doc): inline doc links (#6626) * feat: infer hyperlinks * feat: inline doc links * rustfmt --- Cargo.lock | 1 + crates/doc/Cargo.toml | 1 + crates/doc/src/builder.rs | 2 +- crates/doc/src/document.rs | 112 ++++++- .../doc/src/preprocessor/infer_hyperlinks.rs | 314 ++++++++++++++++++ crates/doc/src/preprocessor/mod.rs | 3 + crates/doc/src/writer/as_doc.rs | 101 +++--- crates/forge/bin/cmd/doc/mod.rs | 5 +- 8 files changed, 482 insertions(+), 57 deletions(-) create mode 100644 crates/doc/src/preprocessor/infer_hyperlinks.rs diff --git a/Cargo.lock b/Cargo.lock index 50f1e23a07811..cbc8190ad0a78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2589,6 +2589,7 @@ dependencies = [ "mdbook", "once_cell", "rayon", + "regex", "serde", "serde_json", "solang-parser", diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 523c0e3a4be77..73368bd9f1f26 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -31,3 +31,4 @@ solang-parser.workspace = true thiserror = "1" toml.workspace = true tracing.workspace = true +regex = "1.10.2" diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index 692e69b82e1dd..ac54e97e21e22 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -42,7 +42,7 @@ pub struct DocBuilder { // TODO: consider using `tfio` impl DocBuilder { - const SRC: &'static str = "src"; + pub(crate) const SRC: &'static str = "src"; const SOL_EXT: &'static str = "sol"; const README: &'static str = "README.md"; const SUMMARY: &'static str = "SUMMARY.md"; diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index dcd54247e6ab3..3f1f2935c0bd8 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -1,5 +1,10 @@ -use crate::{ParseItem, PreprocessorId, PreprocessorOutput}; -use std::{collections::HashMap, path::PathBuf, sync::Mutex}; +use crate::{DocBuilder, ParseItem, PreprocessorId, PreprocessorOutput}; +use std::{ + collections::HashMap, + path::{Path, PathBuf}, + slice::IterMut, + sync::Mutex, +}; /// The wrapper around the [ParseItem] containing additional /// information the original item and extra context for outputting it. @@ -62,6 +67,15 @@ impl Document { let context = self.context.lock().expect("failed to lock context"); context.get(&id).cloned() } + + fn try_relative_output_path(&self) -> Option<&Path> { + self.target_path.strip_prefix(&self.out_target_dir).ok()?.strip_prefix(DocBuilder::SRC).ok() + } + + /// Returns the relative path of the document output. + pub fn relative_output_path(&self) -> &Path { + self.try_relative_output_path().unwrap_or(self.target_path.as_path()) + } } /// The content of the document. @@ -73,6 +87,100 @@ pub enum DocumentContent { OverloadedFunctions(Vec), } +impl DocumentContent { + pub(crate) fn len(&self) -> usize { + match self { + DocumentContent::Empty => 0, + DocumentContent::Single(_) => 1, + DocumentContent::Constants(items) => items.len(), + DocumentContent::OverloadedFunctions(items) => items.len(), + } + } + + pub(crate) fn get_mut(&mut self, index: usize) -> Option<&mut ParseItem> { + match self { + DocumentContent::Empty => None, + DocumentContent::Single(item) => { + if index == 0 { + Some(item) + } else { + None + } + } + DocumentContent::Constants(items) => items.get_mut(index), + DocumentContent::OverloadedFunctions(items) => items.get_mut(index), + } + } + + pub fn iter_items(&self) -> ParseItemIter<'_> { + match self { + DocumentContent::Empty => ParseItemIter { next: None, other: None }, + DocumentContent::Single(item) => ParseItemIter { next: Some(item), other: None }, + DocumentContent::Constants(items) => { + ParseItemIter { next: None, other: Some(items.iter()) } + } + DocumentContent::OverloadedFunctions(items) => { + ParseItemIter { next: None, other: Some(items.iter()) } + } + } + } + + pub fn iter_items_mut(&mut self) -> ParseItemIterMut<'_> { + match self { + DocumentContent::Empty => ParseItemIterMut { next: None, other: None }, + DocumentContent::Single(item) => ParseItemIterMut { next: Some(item), other: None }, + DocumentContent::Constants(items) => { + ParseItemIterMut { next: None, other: Some(items.iter_mut()) } + } + DocumentContent::OverloadedFunctions(items) => { + ParseItemIterMut { next: None, other: Some(items.iter_mut()) } + } + } + } +} + +#[derive(Debug)] +pub struct ParseItemIter<'a> { + next: Option<&'a ParseItem>, + other: Option>, +} + +impl<'a> Iterator for ParseItemIter<'a> { + type Item = &'a ParseItem; + + fn next(&mut self) -> Option { + if let Some(next) = self.next.take() { + return Some(next) + } + if let Some(other) = self.other.as_mut() { + return other.next() + } + + None + } +} + +#[derive(Debug)] +pub struct ParseItemIterMut<'a> { + next: Option<&'a mut ParseItem>, + other: Option>, +} + +impl<'a> Iterator for ParseItemIterMut<'a> { + type Item = &'a mut ParseItem; + + fn next(&mut self) -> Option { + if let Some(next) = self.next.take() { + return Some(next) + } + if let Some(other) = self.other.as_mut() { + return other.next() + } + + None + } +} + /// Read the preprocessor output variant from document context. /// Returns [None] if there is no output. macro_rules! read_context { diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs new file mode 100644 index 0000000000000..edec34d0dac02 --- /dev/null +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -0,0 +1,314 @@ +use super::{Preprocessor, PreprocessorId}; +use crate::{Comments, Document, ParseItem, ParseSource}; +use forge_fmt::solang_ext::SafeUnwrap; +use once_cell::sync::Lazy; +use regex::{Captures, Match, Regex}; +use std::{ + borrow::Cow, + path::{Path, PathBuf}, +}; + +/// A regex that matches `{identifier-part}` placeholders +/// +/// Overloaded functions are referenced by including the exact function arguments in the `part` +/// section of the placeholder. +static RE_INLINE_LINK: Lazy = Lazy::new(|| { + Regex::new(r"(?m)(\{(?Pxref-)?(?P[a-zA-Z_][0-9a-zA-Z_]*)(-(?P[a-zA-Z_][0-9a-zA-Z_-]*))?}(\[(?P(.*?))\])?)").unwrap() +}); + +/// [InferInlineHyperlinks] preprocessor id. +pub const INFER_INLINE_HYPERLINKS_ID: PreprocessorId = PreprocessorId("infer inline hyperlinks"); + +/// The infer hyperlinks preprocessor tries to map @dev tags to referenced items +/// Traverses the documents and attempts to find referenced items +/// comments for dev comment tags. +/// +/// This preprocessor replaces inline links in comments with the links to the referenced items. +#[derive(Default, Debug)] +#[non_exhaustive] +pub struct InferInlineHyperlinks; + +impl Preprocessor for InferInlineHyperlinks { + fn id(&self) -> PreprocessorId { + INFER_INLINE_HYPERLINKS_ID + } + + fn preprocess(&self, mut documents: Vec) -> Result, eyre::Error> { + // traverse all comments and try to match inline links and replace with inline links for + // markdown + let mut docs = Vec::with_capacity(documents.len()); + while !documents.is_empty() { + let mut document = documents.remove(0); + let target_path = document.relative_output_path().to_path_buf(); + for idx in 0..document.content.len() { + let (mut comments, item_children_len) = { + let item = document.content.get_mut(idx).unwrap(); + let comments = std::mem::take(&mut item.comments); + let children = item.children.len(); + (comments, children) + }; + Self::inline_doc_links(&documents, &target_path, &mut comments, &document); + document.content.get_mut(idx).unwrap().comments = comments; + + // we also need to iterate over all child items + // This is a bit horrible but we need to traverse all items in all documents + for child_idx in 0..item_children_len { + let mut comments = { + let item = document.content.get_mut(idx).unwrap(); + + std::mem::take(&mut item.children[child_idx].comments) + }; + Self::inline_doc_links(&documents, &target_path, &mut comments, &document); + document.content.get_mut(idx).unwrap().children[child_idx].comments = comments; + } + } + + docs.push(document); + } + + Ok(docs) + } +} + +impl InferInlineHyperlinks { + /// Finds the first match for the given link. + /// + /// All items get their own section in the markdown file. + /// This section uses the identifier of the item: `#functionname` + /// + /// Note: the target path is the relative path to the markdown file. + fn find_match<'a>( + link: &InlineLink<'a>, + target_path: &Path, + items: impl Iterator, + ) -> Option> { + for item in items { + match &item.source { + ParseSource::Contract(contract) => { + let name = &contract.name.safe_unwrap().name; + if name == link.identifier { + if link.part.is_none() { + return Some(InlineLinkTarget::borrowed(name, target_path.to_path_buf())) + } + // try to find the referenced item in the contract's children + return Self::find_match(link, target_path, item.children.iter()) + } + } + ParseSource::Function(fun) => { + // TODO: handle overloaded functions + // functions can be overloaded so we need to keep track of how many matches we + // have so we can match the correct one + let fun_name = &fun.name.safe_unwrap().name; + if fun_name == link.ref_name() { + return Some(InlineLinkTarget::borrowed(fun_name, target_path.to_path_buf())) + } + } + ParseSource::Variable(_) => {} + ParseSource::Event(ev) => { + let ev_name = &ev.name.safe_unwrap().name; + if ev_name == link.ref_name() { + return Some(InlineLinkTarget::borrowed(ev_name, target_path.to_path_buf())) + } + } + ParseSource::Error(err) => { + let err_name = &err.name.safe_unwrap().name; + if err_name == link.ref_name() { + return Some(InlineLinkTarget::borrowed(err_name, target_path.to_path_buf())) + } + } + ParseSource::Struct(structdef) => { + let struct_name = &structdef.name.safe_unwrap().name; + if struct_name == link.ref_name() { + return Some(InlineLinkTarget::borrowed( + struct_name, + target_path.to_path_buf(), + )) + } + } + ParseSource::Enum(_) => {} + ParseSource::Type(_) => {} + } + } + + None + } + + /// Attempts to convert inline links to markdown links. + fn inline_doc_links( + documents: &[Document], + target_path: &Path, + comments: &mut Comments, + parent: &Document, + ) { + // loop over all comments in the item + for comment in comments.iter_mut() { + let val = comment.value.clone(); + // replace all links with inline markdown links + for link in InlineLink::captures(val.as_str()) { + let target = if link.is_external() { + // find in all documents + documents.iter().find_map(|doc| { + Self::find_match( + &link, + doc.relative_output_path(), + doc.content.iter_items().flat_map(|item| { + Some(item).into_iter().chain(item.children.iter()) + }), + ) + }) + } else { + // find matches in the document + Self::find_match( + &link, + target_path, + parent + .content + .iter_items() + .flat_map(|item| Some(item).into_iter().chain(item.children.iter())), + ) + }; + if let Some(target) = target { + let display_value = link.markdown_link_display_value(); + let markdown_link = format!("[{}]({})", display_value, target); + // replace the link with the markdown link + comment.value = + comment.value.as_str().replacen(link.as_str(), markdown_link.as_str(), 1); + } + } + } + } +} + +struct InlineLinkTarget<'a> { + section: Cow<'a, str>, + target_path: PathBuf, +} + +impl<'a> InlineLinkTarget<'a> { + fn borrowed(section: &'a str, target_path: PathBuf) -> Self { + Self { section: Cow::Borrowed(section), target_path } + } +} + +impl<'a> std::fmt::Display for InlineLinkTarget<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + // NOTE: the url should be absolute for markdown and section names are lowercase + write!(f, "/{}#{}", self.target_path.display(), self.section.to_lowercase()) + } +} + +/// A parsed link to an item. +#[derive(Debug)] +struct InlineLink<'a> { + outer: Match<'a>, + identifier: &'a str, + part: Option<&'a str>, + link: Option<&'a str>, +} + +impl<'a> InlineLink<'a> { + fn from_capture(cap: Captures<'a>) -> Option { + Some(Self { + outer: cap.get(1)?, + identifier: cap.name("identifier")?.as_str(), + part: cap.name("part").map(|m| m.as_str()), + link: cap.name("link").map(|m| m.as_str()), + }) + } + + fn captures(s: &'a str) -> impl Iterator + '_ { + RE_INLINE_LINK.captures(s).map(Self::from_capture).into_iter().flatten() + } + + /// Parses the first inline link. + #[allow(unused)] + fn capture(s: &'a str) -> Option { + let cap = RE_INLINE_LINK.captures(s)?; + Self::from_capture(cap) + } + + /// Returns the name of the link + fn markdown_link_display_value(&self) -> Cow<'_, str> { + if let Some(link) = self.link { + Cow::Borrowed(link) + } else if let Some(part) = self.part { + Cow::Owned(format!("{}-{}", self.identifier, part)) + } else { + Cow::Borrowed(self.identifier) + } + } + + /// Returns the name of the referenced item. + fn ref_name(&self) -> &str { + self.exact_identifier().split('-').next().unwrap() + } + + fn exact_identifier(&self) -> &str { + let mut name = self.identifier; + if let Some(part) = self.part { + name = part; + } + name + } + + /// Returns the name of the referenced item and its arguments, if any. + /// + /// Eg: `safeMint-address-uint256-` returns `("safeMint", ["address", "uint256"])` + #[allow(unused)] + fn ref_name_exact(&self) -> (&str, impl Iterator + '_) { + let identifier = self.exact_identifier(); + let mut iter = identifier.split('-'); + (iter.next().unwrap(), iter.filter(|s| !s.is_empty())) + } + + /// Returns the content of the matched link. + fn as_str(&self) -> &str { + self.outer.as_str() + } + + /// Returns true if the link is external. + fn is_external(&self) -> bool { + self.part.is_some() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_inline_links() { + let s = " {IERC165-supportsInterface} "; + let cap = RE_INLINE_LINK.captures(s).unwrap(); + + let identifier = cap.name("identifier").unwrap().as_str(); + assert_eq!(identifier, "IERC165"); + let part = cap.name("part").unwrap().as_str(); + assert_eq!(part, "supportsInterface"); + + let s = " {supportsInterface} "; + let cap = RE_INLINE_LINK.captures(s).unwrap(); + + let identifier = cap.name("identifier").unwrap().as_str(); + assert_eq!(identifier, "supportsInterface"); + + let s = "{xref-ERC721-_safeMint-address-uint256-}"; + let cap = RE_INLINE_LINK.captures(s).unwrap(); + + let identifier = cap.name("identifier").unwrap().as_str(); + assert_eq!(identifier, "ERC721"); + let identifier = cap.name("xref").unwrap().as_str(); + assert_eq!(identifier, "xref-"); + let identifier = cap.name("part").unwrap().as_str(); + assert_eq!(identifier, "_safeMint-address-uint256-"); + + let link = InlineLink::capture(s).unwrap(); + assert_eq!(link.ref_name(), "_safeMint"); + assert_eq!(link.as_str(), "{xref-ERC721-_safeMint-address-uint256-}"); + + let s = "{xref-ERC721-_safeMint-address-uint256-}[`Named link`]"; + let link = InlineLink::capture(s).unwrap(); + assert_eq!(link.link, Some("`Named link`")); + assert_eq!(link.markdown_link_display_value(), "`Named link`"); + } +} diff --git a/crates/doc/src/preprocessor/mod.rs b/crates/doc/src/preprocessor/mod.rs index 40cb7843cb669..96af88ebc97e7 100644 --- a/crates/doc/src/preprocessor/mod.rs +++ b/crates/doc/src/preprocessor/mod.rs @@ -9,6 +9,9 @@ pub use contract_inheritance::{ContractInheritance, CONTRACT_INHERITANCE_ID}; mod inheritdoc; pub use inheritdoc::{Inheritdoc, INHERITDOC_ID}; +mod infer_hyperlinks; +pub use infer_hyperlinks::{InferInlineHyperlinks, INFER_INLINE_HYPERLINKS_ID}; + mod git_source; pub use git_source::{GitSource, GIT_SOURCE_ID}; diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index c62e2a106948b..68e4451fae890 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -7,8 +7,8 @@ use crate::{ }; use forge_fmt::solang_ext::SafeUnwrap; use itertools::Itertools; -use solang_parser::pt::Base; -use std::path::Path; +use solang_parser::pt::{Base, FunctionDefinition}; +use std::path::{Path, PathBuf}; /// The result of [Asdoc::as_doc] method. pub type AsDocResult = Result; @@ -127,9 +127,8 @@ impl AsDoc for Document { if !contract.base.is_empty() { writer.write_bold("Inherits:")?; - // Where all the source files are written to // we need this to find the _relative_ paths - let src_target_dir = self.out_target_dir.join("src"); + let src_target_dir = self.target_src_dir(); let mut bases = vec![]; let linked = @@ -179,56 +178,10 @@ impl AsDoc for Document { if let Some(funcs) = item.functions() { writer.write_subtitle("Functions")?; - funcs.into_iter().try_for_each(|(func, comments, code)| { - let func_name = func - .name - .as_ref() - .map_or(func.ty.to_string(), |n| n.name.to_owned()); - let comments = comments.merge_inheritdoc( - &func_name, - read_context!(self, INHERITDOC_ID, Inheritdoc), - ); - // Write function name - writer.write_heading(&func_name)?; - writer.writeln()?; - - // Write function docs - writer.writeln_doc( - comments.exclude_tags(&[CommentTag::Param, CommentTag::Return]), - )?; - - // Write function header - writer.write_code(code)?; - - // Write function parameter comments in a table - let params = func - .params - .iter() - .filter_map(|p| p.1.as_ref()) - .collect::>(); - writer.try_write_param_table( - CommentTag::Param, - ¶ms, - &comments, - )?; - - // Write function parameter comments in a table - let returns = func - .returns - .iter() - .filter_map(|p| p.1.as_ref()) - .collect::>(); - writer.try_write_param_table( - CommentTag::Return, - &returns, - &comments, - )?; - - writer.writeln()?; - - Ok::<(), std::fmt::Error>(()) - })?; + for (func, comments, code) in funcs.iter() { + self.write_function(&mut writer, func, comments, code)?; + } } if let Some(events) = item.events() { @@ -317,3 +270,45 @@ impl AsDoc for Document { Ok(writer.finish()) } } + +impl Document { + /// Where all the source files are written to + fn target_src_dir(&self) -> PathBuf { + self.out_target_dir.join("src") + } + + /// Writes a function to the buffer. + fn write_function( + &self, + writer: &mut BufWriter, + func: &FunctionDefinition, + comments: &Comments, + code: &str, + ) -> Result<(), std::fmt::Error> { + let func_name = func.name.as_ref().map_or(func.ty.to_string(), |n| n.name.to_owned()); + let comments = + comments.merge_inheritdoc(&func_name, read_context!(self, INHERITDOC_ID, Inheritdoc)); + + // Write function name + writer.write_heading(&func_name)?; + + writer.writeln()?; + + // Write function docs + writer.writeln_doc(comments.exclude_tags(&[CommentTag::Param, CommentTag::Return]))?; + + // Write function header + writer.write_code(code)?; + + // Write function parameter comments in a table + let params = func.params.iter().filter_map(|p| p.1.as_ref()).collect::>(); + writer.try_write_param_table(CommentTag::Param, ¶ms, &comments)?; + + // Write function parameter comments in a table + let returns = func.returns.iter().filter_map(|p| p.1.as_ref()).collect::>(); + writer.try_write_param_table(CommentTag::Return, &returns, &comments)?; + + writer.writeln()?; + Ok(()) + } +} diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index dbef459ca73cf..9bb8b21cf7e32 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -1,6 +1,8 @@ use clap::{Parser, ValueHint}; use eyre::Result; -use forge_doc::{ContractInheritance, Deployments, DocBuilder, GitSource, Inheritdoc}; +use forge_doc::{ + ContractInheritance, Deployments, DocBuilder, GitSource, InferInlineHyperlinks, Inheritdoc, +}; use foundry_cli::opts::GH_REPO_PREFIX_REGEX; use foundry_config::{find_project_root_path, load_config_with_root}; use std::{path::PathBuf, process::Command}; @@ -98,6 +100,7 @@ impl DocArgs { .with_fmt(config.fmt) .with_preprocessor(ContractInheritance { include_libraries: self.include_libraries }) .with_preprocessor(Inheritdoc::default()) + .with_preprocessor(InferInlineHyperlinks::default()) .with_preprocessor(GitSource { root: root.clone(), commit, From 70195e7e069b2dfea4177bbf66035b413e7839d3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 20 Dec 2023 23:01:12 +0100 Subject: [PATCH 0415/1963] fix(fmt): properly format enums (#6637) --- crates/fmt/src/formatter.rs | 40 +++++++++---------- crates/fmt/testdata/EnumVariants/fmt.sol | 19 +++++++++ crates/fmt/testdata/EnumVariants/original.sol | 23 +++++++++++ crates/fmt/tests/formatter.rs | 1 + 4 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 crates/fmt/testdata/EnumVariants/fmt.sol create mode 100644 crates/fmt/testdata/EnumVariants/original.sol diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 3312b00b73ca3..825cbb0321c0b 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -2038,31 +2038,27 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { let enum_name = enumeration.name.safe_unwrap_mut(); let mut name = self.visit_to_chunk(enum_name.loc.start(), Some(enum_name.loc.end()), enum_name)?; - name.content = format!("enum {}", name.content); - self.write_chunk(&name)?; - + name.content = format!("enum {} ", name.content); if enumeration.values.is_empty() { + self.write_chunk(&name)?; self.write_empty_brackets()?; } else { - self.surrounded( - SurroundingChunk::new( - "{", - Some(enumeration.values.first_mut().unwrap().safe_unwrap().loc.start()), - None, - ), - SurroundingChunk::new("}", None, Some(enumeration.loc.end())), - |fmt, _multiline| { - let values = fmt.items_to_chunks( - Some(enumeration.loc.end()), - enumeration.values.iter_mut().map(|ident| { - let ident = ident.safe_unwrap_mut(); - (ident.loc, ident) - }), - )?; - fmt.write_chunks_separated(&values, ",", true)?; - Ok(()) - }, - )?; + name.content.push('{'); + self.write_chunk(&name)?; + + self.indented(1, |fmt| { + let values = fmt.items_to_chunks( + Some(enumeration.loc.end()), + enumeration.values.iter_mut().map(|ident| { + let ident = ident.safe_unwrap_mut(); + (ident.loc, ident) + }), + )?; + fmt.write_chunks_separated(&values, ",", true)?; + writeln!(fmt.buf())?; + Ok(()) + })?; + write_chunk!(self, "}}")?; } Ok(()) diff --git a/crates/fmt/testdata/EnumVariants/fmt.sol b/crates/fmt/testdata/EnumVariants/fmt.sol new file mode 100644 index 0000000000000..b33b8846984d2 --- /dev/null +++ b/crates/fmt/testdata/EnumVariants/fmt.sol @@ -0,0 +1,19 @@ +interface I { + enum Empty {} + + /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. + enum CallerMode { + /// No caller modification is currently active. + None + } + + /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. + enum CallerMode2 { + /// No caller modification is currently active. + None, + /// No caller modification is currently active2. + Some + } + + function bar() public {} +} diff --git a/crates/fmt/testdata/EnumVariants/original.sol b/crates/fmt/testdata/EnumVariants/original.sol new file mode 100644 index 0000000000000..8e146ae0fb574 --- /dev/null +++ b/crates/fmt/testdata/EnumVariants/original.sol @@ -0,0 +1,23 @@ +interface I { + enum Empty { + + } + + /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. + enum CallerMode + {/// No caller modification is currently active. + None + } + + /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. + enum CallerMode2 + {/// No caller modification is currently active. + None,/// No caller modification is currently active2. + + Some + } + + function bar() public { + + } +} \ No newline at end of file diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 317cd28efd3e5..5ec767b4ed571 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -229,6 +229,7 @@ test_directories! { EmitStatement, Repros, BlockComments, + EnumVariants, } test_dir!(SortedImports, TestConfig::skip_compare_ast_eq()); From b4b691b79d88452c5a071a333feba8d1313ad7bd Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 20 Dec 2023 18:07:43 -0400 Subject: [PATCH 0416/1963] chore: fail fast AFTER processing traces (#6628) --- crates/forge/bin/cmd/test/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 0d099486e5699..1def1c49d06d8 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -407,11 +407,6 @@ impl TestArgs { for (name, result) in &mut tests { short_test_result(name, result); - // If the test failed, we want to stop processing the rest of the tests - if self.fail_fast && result.status == TestStatus::Failure { - break 'outer - } - // We only display logs at level 2 and above if verbosity >= 2 { // We only decode logs from Hardhat and DS-style console events @@ -482,6 +477,11 @@ impl TestArgs { if self.gas_report { gas_report.analyze(&result.traces); } + + // If the test failed, we want to stop processing the rest of the tests + if self.fail_fast && result.status == TestStatus::Failure { + break 'outer + } } let block_outcome = TestOutcome::new( [(contract_name.clone(), suite_result)].into(), From c679bea7be0062f0581759d6789b0a450af47169 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:10:02 +0200 Subject: [PATCH 0417/1963] fix(cheatcodes): silence warnings for older Solidity versions (#6638) --- crates/cheatcodes/assets/cheatcodes.json | 4 ++-- crates/cheatcodes/spec/src/vm.rs | 4 ++-- crates/cheatcodes/src/evm/fork.rs | 4 ++-- testdata/cheats/Vm.sol | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 927ebb78c20c5..fceb5bcbf76e6 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -1737,7 +1737,7 @@ "func": { "id": "eth_getLogs", "description": "Gets all the logs according to specified filter.", - "declaration": "function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics) external returns (EthGetLogs[] memory logs);", + "declaration": "function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) external returns (EthGetLogs[] memory logs);", "visibility": "external", "mutability": "", "signature": "eth_getLogs(uint256,uint256,address,bytes32[])", @@ -4397,7 +4397,7 @@ "func": { "id": "stopAndReturnStateDiff", "description": "Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session.", - "declaration": "function stopAndReturnStateDiff() external returns (AccountAccess[] memory accesses);", + "declaration": "function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);", "visibility": "external", "mutability": "", "signature": "stopAndReturnStateDiff()", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index ae6622842fae3..907dce1dc3660 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -260,7 +260,7 @@ interface Vm { /// Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session. #[cheatcode(group = Evm, safety = Safe)] - function stopAndReturnStateDiff() external returns (AccountAccess[] memory accesses); + function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses); // -------- Recording Map Writes -------- @@ -508,7 +508,7 @@ interface Vm { /// Gets all the logs according to specified filter. #[cheatcode(group = Evm, safety = Safe)] - function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics) + function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) external returns (EthGetLogs[] memory logs); diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index f246d264c4dc5..57683a76003b5 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -239,7 +239,7 @@ impl Cheatcode for rpcCall { impl Cheatcode for eth_getLogsCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { fromBlock, toBlock, addr, topics } = self; + let Self { fromBlock, toBlock, target, topics } = self; let (Ok(from_block), Ok(to_block)) = (u64::try_from(fromBlock), u64::try_from(toBlock)) else { bail!("blocks in block range must be less than 2^64 - 1") @@ -253,7 +253,7 @@ impl Cheatcode for eth_getLogsCall { ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; let mut filter = - Filter::new().address(addr.to_ethers()).from_block(from_block).to_block(to_block); + Filter::new().address(target.to_ethers()).from_block(from_block).to_block(to_block); for (i, topic) in topics.iter().enumerate() { let topic = topic.to_ethers(); match i { diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index a8c885f6e352c..aeea7cdaf43e0 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -84,7 +84,7 @@ interface Vm { function envUint(string calldata name) external view returns (uint256 value); function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value); function etch(address target, bytes calldata newRuntimeBytecode) external; - function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics) external returns (EthGetLogs[] memory logs); + function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) external returns (EthGetLogs[] memory logs); function exists(string calldata path) external 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; @@ -217,7 +217,7 @@ interface Vm { function startPrank(address msgSender) external; function startPrank(address msgSender, address txOrigin) external; function startStateDiffRecording() external; - function stopAndReturnStateDiff() external returns (AccountAccess[] memory accesses); + function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses); function stopBroadcast() external; function stopMappingRecording() external; function stopPrank() external; From 9c4d3f91435ad90e369ebf05cacad0c89ed598c0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 21 Dec 2023 01:24:14 +0200 Subject: [PATCH 0418/1963] fix(cheatcodes): update cool status, fix AccountAccessKind ordering (#6641) * chore(cheatcodes): update cool status * fix(cheatcodes): reorder AccountAccessKind enum variants to match forge-std --- crates/cheatcodes/assets/cheatcodes.json | 10 +++++----- crates/cheatcodes/spec/src/vm.rs | 6 +++--- testdata/cheats/Vm.sol | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index fceb5bcbf76e6..55fca77e13cda 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -74,13 +74,13 @@ "name": "Extcodesize", "description": "The account's codesize was read." }, - { - "name": "Extcodecopy", - "description": "The account's code was copied." - }, { "name": "Extcodehash", "description": "The account's codehash was read." + }, + { + "name": "Extcodecopy", + "description": "The account's code was copied." } ] } @@ -770,7 +770,7 @@ ] }, "group": "evm", - "status": "stable", + "status": "experimental", "safety": "unsafe" }, { diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 907dce1dc3660..9a70337ab82b8 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -57,10 +57,10 @@ interface Vm { Balance, /// The account's codesize was read. Extcodesize, - /// The account's code was copied. - Extcodecopy, /// The account's codehash was read. Extcodehash, + /// The account's code was copied. + Extcodecopy, } /// An Ethereum log. Returned by `getRecordedLogs`. @@ -352,7 +352,7 @@ interface Vm { function store(address target, bytes32 slot, bytes32 value) external; /// Marks the slots of an account and the account address as cold. - #[cheatcode(group = Evm, safety = Unsafe)] + #[cheatcode(group = Evm, safety = Unsafe, status = Experimental)] function cool(address target) external; // -------- Call Manipulation -------- diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index aeea7cdaf43e0..3dfa2afbc0ef2 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -7,7 +7,7 @@ pragma solidity ^0.8.4; interface Vm { error CheatcodeError(string message); enum CallerMode { None, Broadcast, RecurrentBroadcast, Prank, RecurrentPrank } - enum AccountAccessKind { Call, DelegateCall, CallCode, StaticCall, Create, SelfDestruct, Resume, Balance, Extcodesize, Extcodecopy, Extcodehash } + enum AccountAccessKind { Call, DelegateCall, CallCode, StaticCall, Create, SelfDestruct, Resume, Balance, Extcodesize, Extcodehash, Extcodecopy } 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; } From df49ddda8591c666d6b32dc0696db727a0eaa65d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 21 Dec 2023 02:06:44 +0200 Subject: [PATCH 0419/1963] test: disable PRB ext tests on Windows (#6639) --- crates/forge/tests/cli/ext_integration.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 55c128b07f500..a819edd364c97 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -1,6 +1,14 @@ forgetest_external!(solmate, "transmissions11/solmate"); -forgetest_external!(prb_math, "PaulRBerg/prb-math"); -forgetest_external!(prb_proxy, "PaulRBerg/prb-proxy"); +forgetest_external!( + #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] + prb_math, + "PaulRBerg/prb-math" +); +forgetest_external!( + #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] + prb_proxy, + "PaulRBerg/prb-proxy" +); forgetest_external!(solady, "Vectorized/solady"); forgetest_external!( #[cfg_attr(windows, ignore = "weird git fail")] From cb6c44da96dcbda4311d571950a8fa0d33abd86e Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 20 Dec 2023 23:46:10 -0400 Subject: [PATCH 0420/1963] feat(`cheatcodes`): `getBlockNumber` and `getBlockTimestamp` (#6630) * feat: getBlockTimestamp and getBlockHeight * tests * chore: rename getBlockHeight to getBlockNumber * cargo cheats * chore: make fns safe & view * Update testdata/cheats/GetBlockTimestamp.t.sol Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * chore: update docs * chore: cargo cheats --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 40 ++++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 14 +++++++++ crates/cheatcodes/src/evm.rs | 14 +++++++++ testdata/cheats/GetBlockTimestamp.t.sol | 26 +++++++++++++++ testdata/cheats/Vm.sol | 2 ++ testdata/cheats/getBlockNumber.t.sol | 25 +++++++++++++++ 6 files changed, 121 insertions(+) create mode 100644 testdata/cheats/GetBlockTimestamp.t.sol create mode 100644 testdata/cheats/getBlockNumber.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 55fca77e13cda..de243861068a8 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2173,6 +2173,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getBlockNumber", + "description": "Gets the current `block.number`.\nYou should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", + "declaration": "function getBlockNumber() external view returns (uint256 height);", + "visibility": "external", + "mutability": "view", + "signature": "getBlockNumber()", + "selector": "0x42cbb15c", + "selectorBytes": [ + 66, + 203, + 177, + 92 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getBlockTimestamp", + "description": "Gets the current `block.timestamp`.\nYou should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", + "declaration": "function getBlockTimestamp() external view returns (uint256 timestamp);", + "visibility": "external", + "mutability": "view", + "signature": "getBlockTimestamp()", + "selector": "0x796b89b9", + "selectorBytes": [ + 121, + 107, + 137, + 185 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "getCode", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 9a70337ab82b8..99d81137a9141 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -317,6 +317,13 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function roll(uint256 newHeight) external; + /// Gets the current `block.number`. + /// You should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction, + /// and as a result will get optimized out by the compiler. + /// See https://github.com/foundry-rs/foundry/issues/6180 + #[cheatcode(group = Evm, safety = Safe)] + function getBlockNumber() external view returns (uint256 height); + /// Sets `tx.gasprice`. #[cheatcode(group = Evm, safety = Unsafe)] function txGasPrice(uint256 newGasPrice) external; @@ -325,6 +332,13 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function warp(uint256 newTimestamp) external; + /// Gets the current `block.timestamp`. + /// You should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction, + /// and as a result will get optimized out by the compiler. + /// See https://github.com/foundry-rs/foundry/issues/6180 + #[cheatcode(group = Evm, safety = Safe)] + function getBlockTimestamp() external view returns (uint256 timestamp); + // -------- Account State -------- /// Sets an address' balance. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index b8afe62a291ff..e8b4178fd9372 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -210,6 +210,13 @@ impl Cheatcode for rollCall { } } +impl Cheatcode for getBlockNumberCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + Ok(ccx.data.env.block.number.abi_encode()) + } +} + impl Cheatcode for txGasPriceCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newGasPrice } = self; @@ -226,6 +233,13 @@ impl Cheatcode for warpCall { } } +impl Cheatcode for getBlockTimestampCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + Ok(ccx.data.env.block.timestamp.abi_encode()) + } +} + impl Cheatcode for dealCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account: address, newBalance: new_balance } = *self; diff --git a/testdata/cheats/GetBlockTimestamp.t.sol b/testdata/cheats/GetBlockTimestamp.t.sol new file mode 100644 index 0000000000000..144d6b56ebf75 --- /dev/null +++ b/testdata/cheats/GetBlockTimestamp.t.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract GetBlockTimestampTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testGetTimestamp() public { + uint256 timestamp = vm.getBlockTimestamp(); + assertEq(timestamp, 1, "timestamp should be 1"); + } + + function testGetTimestampWithWarp() public { + assertEq(vm.getBlockTimestamp(), 1, "timestamp should be 1"); + vm.warp(10); + assertEq(vm.getBlockTimestamp(), 10, "warp failed"); + } + + function testGetTimestampWithWarpFuzzed(uint128 jump) public { + uint256 pre = vm.getBlockTimestamp(); + vm.warp(pre + jump); + assertEq(vm.getBlockTimestamp(), pre + jump, "warp failed"); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 3dfa2afbc0ef2..3bfc15665a07d 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -106,6 +106,8 @@ interface Vm { function fee(uint256 newBasefee) external; function ffi(string[] calldata commandInput) external returns (bytes memory result); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); + function getBlockNumber() external view returns (uint256 height); + function getBlockTimestamp() external view returns (uint256 timestamp); function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); function getLabel(address account) external returns (string memory currentLabel); diff --git a/testdata/cheats/getBlockNumber.t.sol b/testdata/cheats/getBlockNumber.t.sol new file mode 100644 index 0000000000000..77409174711e3 --- /dev/null +++ b/testdata/cheats/getBlockNumber.t.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract GetBlockNumberTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testGetBlockNumber() public { + uint256 height = vm.getBlockNumber(); + assertEq(height, uint256(block.number), "height should be equal to block.number"); + } + + function testGetBlockNumberWithRoll() public { + vm.roll(10); + assertEq(vm.getBlockNumber(), 10, "could not get correct block height after roll"); + } + + function testGetBlockNumberWithRollFuzzed(uint128 jump) public { + uint256 pre = vm.getBlockNumber(); + vm.roll(pre + jump); + assertEq(vm.getBlockNumber(), pre + jump, "could not get correct block height after roll"); + } +} From 1978a036e0312f43f00f37b52902536d06e86384 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 21 Dec 2023 10:39:01 +0100 Subject: [PATCH 0421/1963] fix(doc): handle constructor edge case (#6644) --- crates/doc/src/preprocessor/infer_hyperlinks.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index edec34d0dac02..ba20d95e79f42 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -98,9 +98,19 @@ impl InferInlineHyperlinks { // TODO: handle overloaded functions // functions can be overloaded so we need to keep track of how many matches we // have so we can match the correct one - let fun_name = &fun.name.safe_unwrap().name; - if fun_name == link.ref_name() { - return Some(InlineLinkTarget::borrowed(fun_name, target_path.to_path_buf())) + if let Some(id) = &fun.name { + // Note: constructors don't have a name + if id.name == link.ref_name() { + return Some(InlineLinkTarget::borrowed( + &id.name, + target_path.to_path_buf(), + )) + } + } else if link.ref_name() == "constructor" { + return Some(InlineLinkTarget::borrowed( + "constructor", + target_path.to_path_buf(), + )) } } ParseSource::Variable(_) => {} From ce3d88a0dc71a338cc5b63979cdfbaf9562e1890 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 21 Dec 2023 16:37:18 +0100 Subject: [PATCH 0422/1963] fix: use next base fee of forked block +1 on reset (#6645) --- crates/anvil/src/eth/backend/mem/mod.rs | 24 +++++++++++++++++++----- crates/anvil/tests/it/fork.rs | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 6dcf120d1cd72..d8c4cdac8ccc2 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -359,10 +359,15 @@ impl Backend { if let Some(eth_rpc_url) = forking.clone().json_rpc_url { let mut env = self.env.read().clone(); - let mut node_config = self.node_config.write().await; + let (db, config) = { + let mut node_config = self.node_config.write().await; - let (db, config) = - node_config.setup_fork_db_config(eth_rpc_url, &mut env, &self.fees).await; + // we want to force the correct base fee for the next block during + // `setup_fork_db_config` + node_config.base_fee.take(); + + node_config.setup_fork_db_config(eth_rpc_url, &mut env, &self.fees).await + }; *self.db.write().await = Box::new(db); @@ -406,8 +411,17 @@ impl Backend { ..env.block.clone() }; - self.time.reset((env.block.timestamp.to_ethers()).as_u64()); - self.fees.set_base_fee(env.block.basefee.to_ethers()); + self.time.reset(env.block.timestamp.to_ethers().as_u64()); + + // this is the base fee of the current block, but we need the base fee of + // the next block + let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( + fork_block.gas_used, + fork_block.gas_limit, + fork_block.base_fee_per_gas.unwrap_or_default(), + ); + + self.fees.set_base_fee(next_block_base_fee.into()); // also reset the total difficulty self.blockchain.storage.write().total_difficulty = fork.total_difficulty(); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 15e5a3756dbb9..a128483a42258 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1026,3 +1026,27 @@ async fn test_fork_reset_moonbeam() { let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); } + +// + let (api, _handle) = spawn(fork_config().with_fork_block_number(Some(18835000u64))).await; + + api.mine_one().await; + let latest = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + + // basefee of +1 block: + assert_eq!(latest.base_fee_per_gas.unwrap(), 59455969592u64.into()); + + // now reset to block 18835000 -1 + api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(18835000u64 - 1) })) + .await + .unwrap(); + + api.mine_one().await; + let latest = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + + // basefee of the forked block: + assert_eq!(latest.base_fee_per_gas.unwrap(), 59017001138u64.into()); +} From d4b616fcecec7da8119bc4ef39b276be98a760f5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 21 Dec 2023 17:28:16 +0100 Subject: [PATCH 0423/1963] chore: install tracing and error hook for chisel (#6646) --- crates/chisel/bin/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 00cb59ed71874..246ebaa52e2c0 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -10,6 +10,7 @@ use chisel::{ use clap::Parser; use eyre::Context; use foundry_cli::{ + handler, opts::CoreBuildArgs, utils::{self, LoadConfig}, }; @@ -82,6 +83,8 @@ pub enum ChiselParserSub { #[tokio::main] async fn main() -> eyre::Result<()> { + handler::install()?; + utils::subscriber(); #[cfg(windows)] if !Paint::enable_windows_ascii() { Paint::disable() From c312c0da8eea81515f35cb12d106314cd737d170 Mon Sep 17 00:00:00 2001 From: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:55:48 -0800 Subject: [PATCH 0424/1963] fix(cast/bin) ; correcting the offset of Storage (#6370) * Update storage.rs * Update storage.rs * cleanup offsets --------- Co-authored-by: Matthias Seitz --- crates/cast/bin/cmd/storage.rs | 67 +++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 676d9e4db1f24..1862cb6231161 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -22,7 +22,6 @@ use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, impl_figment_convert_cast, Config, }; -use futures::future::join_all; use semver::Version; use std::str::FromStr; @@ -180,6 +179,37 @@ impl StorageArgs { } } +/// Represents the value of a storage slot `eth_getStorageAt` call. +#[derive(Debug, Clone, Eq, PartialEq)] +struct StorageValue { + /// The slot number. + slot: B256, + /// The value as returned by `eth_getStorageAt`. + raw_slot_value: B256, +} + +impl StorageValue { + /// Returns the value of the storage slot, applying the offset if necessary. + fn value(&self, offset: i64, number_of_bytes: Option) -> B256 { + let offset = offset as usize; + let mut end = 32; + if let Some(number_of_bytes) = number_of_bytes { + end = offset + number_of_bytes; + if end > 32 { + end = 32; + } + } + let mut value = [0u8; 32]; + + // reverse range, because the value is stored in big endian + let offset = 32 - offset; + let end = 32 - end; + + value[end..offset].copy_from_slice(&self.raw_slot_value.as_slice()[end..offset]); + B256::from(value) + } +} + async fn fetch_and_print_storage( provider: RetryProvider, address: NameOrAddress, @@ -200,34 +230,35 @@ async fn fetch_storage_slots( provider: RetryProvider, address: NameOrAddress, layout: &StorageLayout, -) -> Result> { - // TODO: Batch request - let futures: Vec<_> = layout - .storage - .iter() - .map(|slot| { - let slot = B256::from(U256::from_str(&slot.slot)?); - Ok(provider.get_storage_at(address.clone(), slot.to_ethers(), None)) - }) - .collect::>()?; - - join_all(futures).await.into_iter().map(|r| Ok(r?.to_alloy())).collect() +) -> Result> { + let requests = layout.storage.iter().map(|storage_slot| async { + let slot = B256::from(U256::from_str(&storage_slot.slot)?); + let raw_slot_value = + provider.get_storage_at(address.clone(), slot.to_ethers(), None).await?.to_alloy(); + + let value = StorageValue { slot, raw_slot_value }; + + Ok(value) + }); + + futures::future::try_join_all(requests).await } -fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Result<()> { +fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Result<()> { if !pretty { println!("{}", serde_json::to_string_pretty(&serde_json::to_value(layout)?)?); - return Ok(()); + return Ok(()) } let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); table.set_header(["Name", "Type", "Slot", "Offset", "Bytes", "Value", "Hex Value", "Contract"]); - for (slot, value) in layout.storage.into_iter().zip(values) { + for (slot, storage_value) in layout.storage.into_iter().zip(values) { let storage_type = layout.types.get(&slot.storage_type); - let raw_value_bytes = value.0; - let converted_value = U256::from_be_bytes(raw_value_bytes); + let value = storage_value + .value(slot.offset, storage_type.and_then(|t| t.number_of_bytes.parse::().ok())); + let converted_value = U256::from_be_bytes(value.0); table.add_row([ slot.label.as_str(), From a5171a4a08353a916f429fb9c9ef8aeeb9778d5b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 22 Dec 2023 13:36:58 +0100 Subject: [PATCH 0425/1963] test: add sablier-v2 (#6655) --- crates/forge/tests/cli/ext_integration.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index a819edd364c97..2b3cc437f2fdc 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -9,6 +9,13 @@ forgetest_external!( prb_proxy, "PaulRBerg/prb-proxy" ); +forgetest_external!( + #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] + sablier_v2, + "sablier-labs/v2-core", + // skip fork tests + &["--nmc", "Fork"] +); forgetest_external!(solady, "Vectorized/solady"); forgetest_external!( #[cfg_attr(windows, ignore = "weird git fail")] From ba0cc1d4f39cd4797caf048defbcf7171d92341d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 24 Dec 2023 13:29:44 +0200 Subject: [PATCH 0426/1963] chore(deps): weekly `cargo update` (#6659) --- Cargo.lock | 182 ++++++++++++++++++++++++----------------------------- 1 file changed, 81 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbc8190ad0a78..e5753f2fef9fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df496257fe2fae392687ef30207325c50c68520108a94798b0c6cc1a6102f70" +checksum = "68a33ec1fdb68c347fdab62e1194c059a00143d97401b32aaa420ecbe4c2fbed" dependencies = [ "num_enum", "serde", @@ -147,25 +147,24 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc0fac0fc16baf1f63f78b47c3d24718f3619b0714076f6a02957d808d52cbef" +checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" dependencies = [ "alloy-rlp-derive", "arrayvec", "bytes", - "smol_str", ] [[package]] name = "alloy-rlp-derive" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0391754c09fab4eae3404d19d0d297aa1c670c1775ab51d8a5312afeca23157" +checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -183,7 +182,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.41", + "syn 2.0.42", "syn-solidity", "tiny-keccak", ] @@ -399,9 +398,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "59d2a3357dde987206219e78ecfbbb6e8dad06cbb65292758d3270e6254f7355" [[package]] name = "arbitrary" @@ -575,18 +574,18 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -759,7 +758,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.41", + "syn 2.0.42", "which", ] @@ -1211,7 +1210,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1632,12 +1631,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.1" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e95fbd621905b854affdc67943b043a0fbb6ed7385fd5a25650d19a8a6cfdf" +checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" dependencies = [ "nix 0.27.1", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1697,7 +1696,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1938,7 +1937,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -2136,7 +2135,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.41", + "syn 2.0.42", "toml 0.8.8", "walkdir", ] @@ -2153,7 +2152,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -2178,7 +2177,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.41", + "syn 2.0.42", "tempfile", "thiserror", "tiny-keccak", @@ -2381,7 +2380,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -2776,7 +2775,7 @@ dependencies = [ "glob", "home", "md-5 0.10.6", - "memmap2 0.9.1", + "memmap2 0.9.3", "num_cpus", "once_cell", "path-slash", @@ -2985,7 +2984,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -3117,7 +3116,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -3694,9 +3693,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -3709,7 +3708,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2", "tokio", "tower-service", "tracing", @@ -4331,9 +4330,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f850157af41022bbb1b04ed15c011ce4d59520be82a4e3718b10c34b02cb85e" +checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92" dependencies = [ "libc", ] @@ -4387,7 +4386,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -4648,7 +4647,7 @@ dependencies = [ "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -4731,9 +4730,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.61" +version = "0.10.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" +checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -4752,7 +4751,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -4763,9 +4762,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.97" +version = "0.9.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" +checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" dependencies = [ "cc", "libc", @@ -4959,7 +4958,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -5014,7 +5013,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -5117,7 +5116,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -5155,7 +5154,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -5182,9 +5181,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" [[package]] name = "plotters" @@ -5255,7 +5254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -5317,9 +5316,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" dependencies = [ "unicode-ident", ] @@ -5332,7 +5331,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", "version_check", "yansi 1.0.0-rc.1", ] @@ -5645,9 +5644,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ "base64 0.21.5", "bytes", @@ -6321,7 +6320,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -6375,14 +6374,14 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] name = "serde_spanned" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -6421,7 +6420,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -6575,25 +6574,6 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" -[[package]] -name = "smol_str" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" -dependencies = [ - "serde", -] - -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.5.5" @@ -6703,7 +6683,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -6771,9 +6751,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.41" +version = "2.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" dependencies = [ "proc-macro2", "quote", @@ -6789,7 +6769,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -6921,7 +6901,7 @@ checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -6945,9 +6925,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ "deranged", "itoa", @@ -6967,9 +6947,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" dependencies = [ "time-core", ] @@ -7010,9 +6990,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -7022,7 +7002,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -7035,7 +7015,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -7256,7 +7236,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -7622,7 +7602,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", "wasm-bindgen-shared", ] @@ -7656,7 +7636,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8002,9 +7982,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.28" +version = "0.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c830786f7720c2fd27a1a0e27a709dbd3c4d009b56d098fc742d4f4eab91fe2" +checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" dependencies = [ "memchr", ] @@ -8067,22 +8047,22 @@ checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -8102,7 +8082,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] From f11da382d69ee7df32c56290101f6ef5e0cf9317 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 24 Dec 2023 23:24:31 +0200 Subject: [PATCH 0427/1963] fmt: sort derives (#6663) --- crates/anvil/core/src/eth/block.rs | 4 ++-- crates/anvil/core/src/eth/mod.rs | 2 +- crates/anvil/core/src/eth/proof.rs | 2 +- crates/anvil/core/src/eth/state.rs | 2 +- crates/anvil/core/src/eth/subscription.rs | 10 +++++----- crates/anvil/core/src/eth/transaction/mod.rs | 16 ++++++++-------- crates/anvil/core/src/types.rs | 16 ++++++++-------- crates/anvil/rpc/src/error.rs | 4 ++-- crates/anvil/rpc/src/request.rs | 14 +++++++------- crates/anvil/rpc/src/response.rs | 6 +++--- crates/anvil/server/src/config.rs | 4 ++-- crates/anvil/src/anvil.rs | 2 +- crates/anvil/src/cmd.rs | 6 +++--- crates/anvil/src/config.rs | 6 +++--- crates/anvil/src/eth/backend/cheats.rs | 4 ++-- crates/anvil/src/eth/backend/db.rs | 4 ++-- crates/anvil/src/eth/backend/executor.rs | 2 +- crates/anvil/src/eth/backend/fork.rs | 6 +++--- crates/anvil/src/eth/backend/genesis.rs | 2 +- crates/anvil/src/eth/backend/mem/inspector.rs | 2 +- crates/anvil/src/eth/backend/mem/storage.rs | 6 +++--- crates/anvil/src/eth/backend/time.rs | 2 +- crates/anvil/src/eth/error.rs | 8 ++++---- crates/anvil/src/eth/fees.rs | 6 +++--- crates/anvil/src/eth/miner.rs | 2 +- crates/anvil/src/eth/otterscan/types.rs | 18 +++++++++--------- crates/anvil/src/eth/pool/mod.rs | 4 ++-- crates/anvil/src/eth/pool/transactions.rs | 12 ++++++------ crates/anvil/src/filter.rs | 2 +- crates/anvil/src/genesis.rs | 2 +- crates/anvil/src/hardfork.rs | 2 +- crates/anvil/src/logging.rs | 4 ++-- crates/anvil/src/pubsub.rs | 4 ++-- crates/anvil/tests/it/proof/eip1186.rs | 2 +- crates/cast/bin/cmd/bind.rs | 2 +- crates/cast/bin/cmd/create2.rs | 2 +- crates/cast/bin/cmd/find_block.rs | 2 +- crates/cast/bin/cmd/interface.rs | 2 +- crates/cast/bin/cmd/rpc.rs | 2 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/cmd/storage.rs | 4 ++-- crates/cast/bin/cmd/wallet/vanity.rs | 4 ++-- crates/cast/src/errors.rs | 2 +- crates/cast/src/rlp_converter.rs | 2 +- crates/cheatcodes/src/evm.rs | 2 +- crates/cheatcodes/src/inspector.rs | 4 ++-- crates/chisel/bin/main.rs | 2 +- crates/chisel/src/executor.rs | 4 ++-- crates/chisel/src/session_source.rs | 10 +++++----- crates/cli/src/opts/build/core.rs | 2 +- crates/cli/src/opts/build/mod.rs | 2 +- crates/cli/src/opts/build/paths.rs | 2 +- crates/cli/src/opts/dependency.rs | 2 +- crates/cli/src/opts/ethereum.rs | 2 +- crates/cli/src/opts/transaction.rs | 2 +- crates/cli/src/opts/wallet/mod.rs | 6 +++--- crates/cli/src/opts/wallet/multi_wallet.rs | 2 +- crates/common/src/compile.rs | 10 +++++----- crates/common/src/contracts.rs | 2 +- crates/common/src/evm.rs | 4 ++-- crates/common/src/fmt/ui.rs | 2 +- crates/common/src/glob.rs | 2 +- crates/common/src/retry.rs | 2 +- crates/common/src/runtime_client.rs | 2 +- crates/common/src/selectors.rs | 6 +++--- crates/common/src/shell.rs | 4 ++-- crates/common/src/transactions.rs | 2 +- crates/common/src/units.rs | 4 ++-- crates/config/src/cache.rs | 6 +++--- crates/config/src/doc.rs | 2 +- crates/config/src/endpoints.rs | 6 +++--- crates/config/src/error.rs | 4 ++-- crates/config/src/etherscan.rs | 12 ++++++------ crates/config/src/fmt.rs | 14 +++++++------- crates/config/src/fs_permissions.rs | 8 ++++---- crates/config/src/fuzz.rs | 4 ++-- crates/config/src/inline/error.rs | 4 ++-- crates/config/src/inline/mod.rs | 4 ++-- crates/config/src/invariant.rs | 2 +- crates/config/src/lib.rs | 12 ++++++------ crates/config/src/providers/remappings.rs | 2 +- crates/config/src/resolve.rs | 2 +- crates/config/src/utils.rs | 2 +- crates/config/src/warning.rs | 2 +- crates/doc/src/parser/comment.rs | 8 ++++---- crates/doc/src/parser/error.rs | 2 +- crates/doc/src/parser/item.rs | 4 ++-- .../src/preprocessor/contract_inheritance.rs | 2 +- crates/doc/src/preprocessor/deployments.rs | 2 +- .../doc/src/preprocessor/infer_hyperlinks.rs | 2 +- crates/doc/src/preprocessor/inheritdoc.rs | 2 +- crates/doc/src/preprocessor/mod.rs | 4 ++-- crates/doc/src/writer/buf_writer.rs | 2 +- crates/evm/core/src/backend/diagnostic.rs | 2 +- crates/evm/core/src/backend/fuzz.rs | 2 +- crates/evm/core/src/backend/in_memory_db.rs | 2 +- crates/evm/core/src/backend/mod.rs | 8 ++++---- crates/evm/core/src/backend/snapshot.rs | 4 ++-- crates/evm/core/src/debug.rs | 6 +++--- crates/evm/core/src/fork/backend.rs | 2 +- crates/evm/core/src/fork/cache.rs | 2 +- crates/evm/core/src/fork/database.rs | 2 +- crates/evm/core/src/fork/mod.rs | 2 +- crates/evm/core/src/fork/multi.rs | 4 ++-- crates/evm/core/src/opts.rs | 4 ++-- crates/evm/core/src/snapshot.rs | 2 +- crates/evm/core/src/utils.rs | 2 +- crates/evm/coverage/src/analysis.rs | 4 ++-- crates/evm/coverage/src/inspector.rs | 2 +- crates/evm/coverage/src/lib.rs | 12 ++++++------ .../evm/evm/src/executors/invariant/error.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 6 +++--- crates/evm/evm/src/inspectors/access_list.rs | 2 +- crates/evm/evm/src/inspectors/debugger.rs | 2 +- crates/evm/evm/src/inspectors/logs.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 2 +- crates/evm/fuzz/src/invariant/call_override.rs | 2 +- crates/evm/fuzz/src/invariant/mod.rs | 2 +- crates/evm/traces/src/decoder/mod.rs | 2 +- crates/evm/traces/src/identifier/signatures.rs | 2 +- crates/evm/traces/src/inspector.rs | 2 +- crates/evm/traces/src/lib.rs | 14 +++++++------- crates/evm/traces/src/node.rs | 2 +- crates/fmt/src/buffer.rs | 2 +- crates/fmt/src/comments.rs | 10 +++++----- crates/fmt/src/formatter.rs | 4 ++-- crates/fmt/src/inline_config.rs | 4 ++-- crates/fmt/src/string.rs | 2 +- crates/fmt/tests/formatter.rs | 2 +- crates/forge/bin/cmd/bind.rs | 2 +- crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/cache.rs | 2 +- crates/forge/bin/cmd/config.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 4 ++-- crates/forge/bin/cmd/create.rs | 2 +- crates/forge/bin/cmd/debug.rs | 2 +- crates/forge/bin/cmd/doc/mod.rs | 2 +- crates/forge/bin/cmd/flatten.rs | 2 +- crates/forge/bin/cmd/fmt.rs | 2 +- crates/forge/bin/cmd/geiger/find.rs | 4 ++-- crates/forge/bin/cmd/geiger/mod.rs | 2 +- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/bin/cmd/install.rs | 4 ++-- crates/forge/bin/cmd/mod.rs | 2 +- crates/forge/bin/cmd/remappings.rs | 2 +- crates/forge/bin/cmd/remove.rs | 2 +- crates/forge/bin/cmd/retry.rs | 2 +- crates/forge/bin/cmd/script/mod.rs | 4 ++-- crates/forge/bin/cmd/script/multi.rs | 4 ++-- crates/forge/bin/cmd/script/sequence.rs | 6 +++--- crates/forge/bin/cmd/script/transaction.rs | 6 +++--- crates/forge/bin/cmd/selectors.rs | 2 +- crates/forge/bin/cmd/snapshot.rs | 10 +++++----- crates/forge/bin/cmd/test/filter.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 4 ++-- crates/forge/bin/cmd/tree.rs | 2 +- crates/forge/bin/cmd/update.rs | 2 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 2 +- crates/forge/bin/cmd/verify/mod.rs | 6 +++--- crates/forge/bin/cmd/verify/provider.rs | 2 +- crates/forge/bin/cmd/verify/sourcify.rs | 8 ++++---- crates/forge/bin/cmd/watch.rs | 4 ++-- crates/forge/src/gas_report.rs | 6 +++--- crates/forge/src/lib.rs | 2 +- crates/forge/src/multi_runner.rs | 2 +- crates/forge/src/result.rs | 4 ++-- crates/forge/src/runner.rs | 2 +- crates/test-utils/src/util.rs | 2 +- 169 files changed, 331 insertions(+), 331 deletions(-) diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 36956f9c4c0be..1675abc8f22c7 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -8,7 +8,7 @@ use ethers_core::{ }; /// Container type that gathers all block data -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct BlockInfo { pub block: Block, pub transactions: Vec, @@ -281,7 +281,7 @@ impl open_fastrlp::Decodable for Header { } /// Partial header definition without ommers hash and transactions root -#[derive(Clone, Debug, PartialEq, Eq, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct PartialHeader { pub parent_hash: H256, pub beneficiary: Address, diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 3303bcd0bb80f..e8b793a786c4c 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -33,7 +33,7 @@ use ethers_core::types::serde_helpers::*; use self::serde_helpers::*; /// Wrapper type that ensures the type is named `params` -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize))] pub struct Params { #[cfg_attr(feature = "serde", serde(default))] diff --git a/crates/anvil/core/src/eth/proof.rs b/crates/anvil/core/src/eth/proof.rs index 09c14bec26070..1fd22a4cae5ce 100644 --- a/crates/anvil/core/src/eth/proof.rs +++ b/crates/anvil/core/src/eth/proof.rs @@ -12,7 +12,7 @@ use revm::primitives::KECCAK_EMPTY; pub use ethers_core::types::{EIP1186ProofResponse as AccountProof, StorageProof}; /// Basic account type. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] pub struct BasicAccount { /// Nonce of the account. diff --git a/crates/anvil/core/src/eth/state.rs b/crates/anvil/core/src/eth/state.rs index 1a1b9da3308a8..b492a06a0d593 100644 --- a/crates/anvil/core/src/eth/state.rs +++ b/crates/anvil/core/src/eth/state.rs @@ -1,7 +1,7 @@ use ethers_core::types::{Address, Bytes, H256, U256}; use std::collections::HashMap; -#[derive(Clone, Debug, PartialEq, Eq, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] diff --git a/crates/anvil/core/src/eth/subscription.rs b/crates/anvil/core/src/eth/subscription.rs index 791bac2526951..7f1432af99183 100644 --- a/crates/anvil/core/src/eth/subscription.rs +++ b/crates/anvil/core/src/eth/subscription.rs @@ -9,7 +9,7 @@ use ethers_core::{ use std::fmt; /// Result of a subscription -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", serde(untagged))] pub enum SubscriptionResult { @@ -24,7 +24,7 @@ pub enum SubscriptionResult { } /// Sync status -#[derive(Debug, Eq, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct SyncStatus { @@ -32,7 +32,7 @@ pub struct SyncStatus { } /// Params for a subscription request -#[derive(Debug, PartialEq, Eq, Hash, Clone, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct SubscriptionParams { /// holds the filter params field if present in the request pub filter: Option, @@ -58,7 +58,7 @@ impl<'a> serde::Deserialize<'a> for SubscriptionParams { } /// Subscription kind -#[derive(Debug, PartialEq, Eq, Hash, Clone)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] @@ -112,7 +112,7 @@ impl fmt::Debug for SubscriptionId { } /// Provides random hex identifier with a certain length -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct HexIdProvider { len: usize, } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 68cd9b48fa8dc..b324c63a5776e 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -37,7 +37,7 @@ pub const IMPERSONATED_SIGNATURE: Signature = /// 2. EIP2930 (state access lists) [`EIP2930TransactionRequest`] /// 3. EIP1559 [`EIP1559TransactionRequest`] /// 4. Deposit [`DepositTransactionRequest`] -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum TypedTransactionRequest { Legacy(LegacyTransactionRequest), EIP2930(EIP2930TransactionRequest), @@ -46,7 +46,7 @@ pub enum TypedTransactionRequest { } /// Represents _all_ transaction requests received from RPC -#[derive(Clone, Debug, PartialEq, Eq, Default, Hash)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] @@ -87,7 +87,7 @@ pub struct EthTransactionRequest { pub optimism_fields: Option, } -#[derive(Clone, Debug, PartialEq, Eq, Default, Hash)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] @@ -282,7 +282,7 @@ impl open_fastrlp::Decodable for TransactionKind { } } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] pub struct EIP2930TransactionRequest { pub chain_id: u64, @@ -334,7 +334,7 @@ impl Encodable for EIP2930TransactionRequest { } } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct LegacyTransactionRequest { pub nonce: U256, pub gas_price: U256, @@ -393,7 +393,7 @@ impl Encodable for LegacyTransactionRequest { } } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] pub struct EIP1559TransactionRequest { pub chain_id: u64, @@ -450,7 +450,7 @@ impl Encodable for EIP1559TransactionRequest { } } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct DepositTransactionRequest { pub from: Address, pub source_hash: H256, @@ -1499,7 +1499,7 @@ impl PendingTransaction { } /// Represents all relevant information of an executed transaction -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct TransactionInfo { pub transaction_hash: H256, pub transaction_index: u32, diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 34d6627498b8d..147db557ef997 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -9,7 +9,7 @@ use serde::{de::Error, Deserializer, Serializer}; /// Represents the params to set forking which can take various forms /// - untagged /// - tagged `forking` -#[derive(Clone, Debug, PartialEq, Eq, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct Forking { pub json_rpc_url: Option, pub block_number: Option, @@ -90,7 +90,7 @@ impl Default for EvmMineOptions { /// Represents the result of `eth_getWork` /// This may or may not include the block number -#[derive(Debug, PartialEq, Eq, Default)] +#[derive(Debug, Default, PartialEq, Eq)] pub struct Work { pub pow_hash: H256, pub seed_hash: H256, @@ -113,7 +113,7 @@ impl serde::Serialize for Work { } /// A hex encoded or decimal index -#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct Index(usize); impl From for usize { @@ -174,7 +174,7 @@ impl<'a> serde::Deserialize<'a> for Index { } } -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct NodeInfo { @@ -187,7 +187,7 @@ pub struct NodeInfo { pub fork_config: NodeForkConfig, } -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct NodeEnvironment { @@ -197,7 +197,7 @@ pub struct NodeEnvironment { pub gas_price: U256, } -#[derive(Debug, Clone, Default, Eq, PartialEq)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct NodeForkConfig { @@ -209,7 +209,7 @@ pub struct NodeForkConfig { /// Anvil equivalent of `hardhat_metadata`. /// Metadata about the current Anvil instance. /// See -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct AnvilMetadata { @@ -224,7 +224,7 @@ pub struct AnvilMetadata { /// Information about the forked network. /// See -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct ForkedNetwork { diff --git a/crates/anvil/rpc/src/error.rs b/crates/anvil/rpc/src/error.rs index 427acd384ced4..b1929818fa8c6 100644 --- a/crates/anvil/rpc/src/error.rs +++ b/crates/anvil/rpc/src/error.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{borrow::Cow, fmt}; /// Represents a JSON-RPC error -#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct RpcError { pub code: ErrorCode, @@ -75,7 +75,7 @@ impl fmt::Display for RpcError { } /// List of JSON-RPC error codes -#[derive(Debug, Copy, PartialEq, Eq, Clone)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ErrorCode { /// Server received Invalid JSON. /// server side error while parsing JSON diff --git a/crates/anvil/rpc/src/request.rs b/crates/anvil/rpc/src/request.rs index 8745cf2a3b09e..8630f4a4c1f5a 100644 --- a/crates/anvil/rpc/src/request.rs +++ b/crates/anvil/rpc/src/request.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; use std::fmt; /// A JSON-RPC request object, a method call -#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct RpcMethodCall { /// The version of the protocol @@ -26,7 +26,7 @@ impl RpcMethodCall { /// Represents a JSON-RPC request which is considered a notification (missing [Id] optional /// [Version]) -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct RpcNotification { pub jsonrpc: Option, @@ -36,7 +36,7 @@ pub struct RpcNotification { } /// Representation of a single JSON-RPC call -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged)] pub enum RpcCall { /// the RPC method to invoke @@ -52,7 +52,7 @@ pub enum RpcCall { } /// Represents a JSON-RPC request. -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] #[serde(untagged)] pub enum Request { @@ -63,7 +63,7 @@ pub enum Request { } /// Request parameters -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged, deny_unknown_fields)] pub enum RequestParams { /// no parameters provided @@ -89,13 +89,13 @@ fn no_params() -> RequestParams { } /// Represents the version of the RPC protocol -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Version { #[serde(rename = "2.0")] V2, } -#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged)] pub enum Id { String(String), diff --git a/crates/anvil/rpc/src/response.rs b/crates/anvil/rpc/src/response.rs index 8600996f46b6c..c7649dbe351a8 100644 --- a/crates/anvil/rpc/src/response.rs +++ b/crates/anvil/rpc/src/response.rs @@ -5,7 +5,7 @@ use crate::{ use serde::{Deserialize, Serialize}; /// Response of a _single_ rpc call -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct RpcResponse { // JSON RPC version @@ -33,7 +33,7 @@ impl RpcResponse { } /// Represents the result of a call either success or error -#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub enum ResponseResult { #[serde(rename = "result")] @@ -61,7 +61,7 @@ impl From for ResponseResult { } } /// Synchronous response -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] #[serde(untagged)] pub enum Response { diff --git a/crates/anvil/server/src/config.rs b/crates/anvil/server/src/config.rs index 3e7170718809a..7e23528317b1b 100644 --- a/crates/anvil/server/src/config.rs +++ b/crates/anvil/server/src/config.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::str::FromStr; /// Additional server options. -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "clap", derive(clap::Parser), clap(next_help_heading = "Server options"))] pub struct ServerConfig { /// The cors `allow_origin` header @@ -48,7 +48,7 @@ impl Default for ServerConfig { } } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct HeaderValueWrapper(pub HeaderValue); impl FromStr for HeaderValueWrapper { diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index ebdb1fadb7975..c969c09420c1f 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -13,7 +13,7 @@ pub struct App { pub cmd: Option, } -#[derive(Clone, Debug, Subcommand, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq, Subcommand)] pub enum Commands { /// Generate shell completions script. #[clap(visible_alias = "com")] diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 5f184cb80dd74..576e1f1697627 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -345,7 +345,7 @@ impl NodeArgs { } /// Anvil's EVM related arguments. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] #[clap(next_help_heading = "EVM options")] pub struct AnvilEvmArgs { /// Fetch state over a remote endpoint instead of starting from an empty state. @@ -604,7 +604,7 @@ impl Future for PeriodicStateDumper { } /// Represents the --state flag and where to load from, or dump the state to -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct StateFile { pub path: PathBuf, pub state: Option, @@ -631,7 +631,7 @@ impl StateFile { /// Represents the input URL for a fork with an optional trailing block number: /// `http://localhost:8545@1000000` -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ForkUrl { /// The endpoint url pub url: String, diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 27b39aac9575b..612a7ec071c58 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -87,7 +87,7 @@ const BANNER: &str = r" "; /// Configurations of the EVM node -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct NodeConfig { /// Chain ID of the EVM chain pub chain_id: Option, @@ -1085,7 +1085,7 @@ latest block number: {latest_block}" } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct PruneStateHistoryConfig { pub enabled: bool, pub max_memory_history: Option, @@ -1110,7 +1110,7 @@ impl PruneStateHistoryConfig { } /// Can create dev accounts -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct AccountGenerator { chain_id: u64, amount: usize, diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 2a90d2156264a..68cbd8706ba64 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -9,7 +9,7 @@ use std::sync::Arc; /// Manages user modifications that may affect the node's behavior /// /// Contains the state of executed, non-eth standard cheat code RPC -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct CheatsManager { /// shareable state state: Arc>, @@ -70,7 +70,7 @@ impl CheatsManager { } /// Container type for all the state variables -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct CheatsState { /// All accounts that are currently impersonated pub impersonated_accounts: HashSet
, diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index a36d7953abce8..87684b9a64b81 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -326,7 +326,7 @@ impl MaybeHashDatabase for StateDb { } } -#[derive(Serialize, Deserialize, Clone, Debug, Default)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct SerializableState { pub accounts: BTreeMap, } @@ -350,7 +350,7 @@ impl SerializableState { } } -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct SerializableAccountRecord { pub nonce: u64, pub balance: U256, diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index df71bc1fd1518..ed7adfc413314 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -83,7 +83,7 @@ impl ExecutedTransaction { } /// Represents the outcome of mining a new block -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ExecutedTransactions { /// The block created after executing the `included` transactions pub block: BlockInfo, diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 6ffd32d5d1b93..c58ed414b38b8 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -24,7 +24,7 @@ use tokio::sync::RwLock as AsyncRwLock; /// /// This type contains a subset of the [`EthApi`](crate::eth::EthApi) functions but will exclusively /// fetch the requested data from the remote client, if it wasn't already fetched. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ClientFork { /// Contains the cached data pub storage: Arc>, @@ -522,7 +522,7 @@ impl ClientFork { } /// Contains all fork metadata -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ClientForkConfig { pub eth_rpc_url: String, pub block_number: u64, @@ -591,7 +591,7 @@ impl ClientForkConfig { } /// Contains cached state fetched to serve EthApi requests -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct ForkedStorage { pub uncles: HashMap>>, pub blocks: HashMap>, diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 9c52a5b3c7ba0..ab8b8984118bd 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -22,7 +22,7 @@ use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLockWriteGuard; /// Genesis settings -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct GenesisConfig { /// The initial timestamp for the genesis block pub timestamp: u64, diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 295558408ba3d..6c978ac386c55 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -15,7 +15,7 @@ use foundry_evm::{ }; /// The [`revm::Inspector`] used when transacting in the evm -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct Inspector { pub tracer: Option, /// collects all `console.sol` logs diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 074ebeeced89a..327bb96974499 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -368,7 +368,7 @@ impl Blockchain { } /// Represents the outcome of mining a new block -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct MinedBlockOutcome { /// The block that was mined pub block_number: U64, @@ -380,7 +380,7 @@ pub struct MinedBlockOutcome { } /// Container type for a mined transaction -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct MinedTransaction { pub info: TransactionInfo, pub receipt: TypedReceipt, @@ -428,7 +428,7 @@ impl MinedTransaction { } /// Intermediary Anvil representation of a receipt -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct MinedTransactionReceipt { /// The actual json rpc receipt object pub inner: TransactionReceipt, diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index 783966dbe36b3..f51ff93feac1d 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -14,7 +14,7 @@ pub fn utc_from_secs(secs: u64) -> DateTime { } /// Manages block time -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct TimeManager { /// tracks the overall applied timestamp offset offset: Arc>, diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index db17c003b9b60..2cb67e496c6ab 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -24,7 +24,7 @@ use serde::Serialize; pub(crate) type Result = std::result::Result; -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error)] pub enum BlockchainError { #[error(transparent)] Pool(#[from] PoolError), @@ -113,7 +113,7 @@ where } /// Errors that can occur in the transaction pool -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error)] pub enum PoolError { #[error("Transaction with cyclic dependent transactions")] CyclicTransaction, @@ -125,7 +125,7 @@ pub enum PoolError { } /// Errors that can occur with `eth_feeHistory` -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error)] pub enum FeeHistoryError { #[error("Requested block range is out of bounds")] InvalidBlockRange, @@ -137,7 +137,7 @@ pub struct ErrDetail { } /// An error due to invalid transaction -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error)] pub enum InvalidTransactionError { /// returned if the nonce of a transaction is lower than the one present in the local chain. #[error("nonce too low")] diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 67bc73740c4f0..43228e0a6e615 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -36,7 +36,7 @@ pub fn default_elasticity() -> f64 { } /// Stores the fee related information -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct FeeManager { /// Hardfork identifier spec_id: SpecId, @@ -329,14 +329,14 @@ impl Future for FeeHistoryService { pub type FeeHistoryCache = Arc>>; /// A single item in the whole fee history cache -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct FeeHistoryCacheItem { pub base_fee: u64, pub gas_used_ratio: f64, pub rewards: Vec, } -#[derive(Default, Clone)] +#[derive(Clone, Default)] pub struct FeeDetails { pub gas_price: Option, pub max_fee_per_gas: Option, diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index 0c1d1758db214..4478328434ec4 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -17,7 +17,7 @@ use std::{ }; use tokio::time::Interval; -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Miner { /// The mode this miner currently operates in mode: Arc>, diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 9843e0536549f..cc9e763e4c33e 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -22,7 +22,7 @@ pub struct OtsBlock { } /// Block structure with additional details regarding fees and issuance -#[derive(Serialize, Debug)] +#[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct OtsBlockDetails { pub block: OtsBlock, @@ -31,7 +31,7 @@ pub struct OtsBlockDetails { } /// Issuance information for a block. Expected by Otterscan in ots_getBlockDetails calls -#[derive(Debug, Serialize, Default)] +#[derive(Debug, Default, Serialize)] pub struct Issuance { block_reward: U256, uncle_reward: U256, @@ -39,7 +39,7 @@ pub struct Issuance { } /// Holds both transactions and receipts for a block -#[derive(Serialize, Debug)] +#[derive(Debug, Serialize)] pub struct OtsBlockTransactions { pub fullblock: OtsBlock, pub receipts: Vec, @@ -55,14 +55,14 @@ pub struct OtsTransactionReceipt { } /// Information about the creator address and transaction for a contract -#[derive(Serialize, Debug)] +#[derive(Debug, Serialize)] pub struct OtsContractCreator { pub hash: H256, pub creator: Address, } /// Paginated search results of an account's history -#[derive(Serialize, Debug)] +#[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct OtsSearchTransactions { pub txs: Vec, @@ -72,7 +72,7 @@ pub struct OtsSearchTransactions { } /// Otterscan format for listing relevant internal operations -#[derive(Serialize, Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] pub struct OtsInternalOperation { pub r#type: OtsInternalOperationType, @@ -82,7 +82,7 @@ pub struct OtsInternalOperation { } /// Types of internal operations recognized by Otterscan -#[derive(Serialize_repr, Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize_repr)] #[repr(u8)] pub enum OtsInternalOperationType { Transfer = 0, @@ -92,7 +92,7 @@ pub enum OtsInternalOperationType { } /// Otterscan's representation of a trace -#[derive(Serialize, Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize)] pub struct OtsTrace { pub r#type: OtsTraceType, pub depth: usize, @@ -104,7 +104,7 @@ pub struct OtsTrace { /// The type of call being described by an Otterscan trace. Only CALL, STATICCALL and DELEGATECALL /// are represented -#[derive(Serialize, Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize)] #[serde(rename_all = "UPPERCASE")] pub enum OtsTraceType { Call, diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index 4fca41febccf6..d66fd4a522313 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -375,7 +375,7 @@ impl fmt::Debug for PruneResult { } } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ReadyTransaction { /// the hash of the submitted transaction hash: TxHash, @@ -398,7 +398,7 @@ impl ReadyTransaction { } } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub enum AddedTransaction { /// transaction was successfully added and being processed Ready(ReadyTransaction), diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index e6b7890f6c8d9..458c811caa3a5 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -25,7 +25,7 @@ pub fn to_marker(nonce: u64, from: Address) -> TxMarker { /// Modes that determine the transaction ordering of the mempool /// /// This type controls the transaction order via the priority metric of a transaction -#[derive(Debug, Clone, Eq, PartialEq, Copy, serde::Serialize, serde::Deserialize, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub enum TransactionOrder { /// Keep the pool transaction transactions sorted in the order they arrive. /// @@ -67,7 +67,7 @@ impl FromStr for TransactionOrder { /// /// The `TransactionPriority` determines the ordering of two transactions that have all their /// markers satisfied. -#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] pub struct TransactionPriority(pub U256); /// Internal Transaction type @@ -112,7 +112,7 @@ impl fmt::Debug for PoolTransaction { /// A waiting pool of transaction that are pending, but not yet ready to be included in a new block. /// /// Keeps a set of transactions that are waiting for other transactions -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct PendingTransactions { /// markers that aren't yet provided by any transaction required_markers: HashMap>, @@ -349,7 +349,7 @@ impl Iterator for TransactionsIterator { } /// transactions that are ready to be included in a block. -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct ReadyTransactions { /// keeps track of transactions inserted in the pool /// @@ -631,7 +631,7 @@ impl ReadyTransactions { } /// A reference to a transaction in the pool -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct PoolTransactionRef { /// actual transaction pub transaction: Arc, @@ -662,7 +662,7 @@ impl Ord for PoolTransactionRef { } } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ReadyTransaction { /// ref to the actual transaction pub transaction: PoolTransactionRef, diff --git a/crates/anvil/src/filter.rs b/crates/anvil/src/filter.rs index e6083df27b423..9a537a5cb28f4 100644 --- a/crates/anvil/src/filter.rs +++ b/crates/anvil/src/filter.rs @@ -27,7 +27,7 @@ type FilterMap = Arc>>; pub const ACTIVE_FILTER_TIMEOUT_SECS: u64 = 60 * 5; /// Contains all registered filters -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Filters { /// all currently active filters active_filters: FilterMap, diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 23afd5fc3c9a4..64cda289c82e3 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -107,7 +107,7 @@ impl Genesis { } } -#[derive(Clone, Debug, Serialize, Deserialize, Default)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(transparent)] pub struct Alloc { pub accounts: BTreeMap, diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index 42745fb80ce84..322c5071ac3a6 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -3,7 +3,7 @@ use ethers::types::BlockNumber; use foundry_evm::revm::primitives::SpecId; use std::str::FromStr; -#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum Hardfork { Frontier, Homestead, diff --git a/crates/anvil/src/logging.rs b/crates/anvil/src/logging.rs index ecab2000ec5ae..5819aafc99c2d 100644 --- a/crates/anvil/src/logging.rs +++ b/crates/anvil/src/logging.rs @@ -12,7 +12,7 @@ pub(crate) const NODE_USER_LOG_TARGET: &str = "node::user"; /// /// This layer is intended to be used as filter for `NODE_USER_LOG_TARGET` events that will /// eventually be logged to stdout -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct NodeLogLayer { state: LoggingManager, } @@ -45,7 +45,7 @@ where } /// Contains the configuration of the logger -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct LoggingManager { /// Whether the logger is currently enabled pub enabled: Arc>, diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index 0c58327959315..0d311d810a2da 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -67,7 +67,7 @@ impl LogsSubscription { } } -#[derive(Debug, PartialEq, Eq, Clone, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct EthSubscriptionResponse { jsonrpc: Version, method: &'static str, @@ -83,7 +83,7 @@ impl EthSubscriptionResponse { } /// Represents the `params` field of an `eth_subscription` event -#[derive(Debug, PartialEq, Eq, Clone, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct EthSubscriptionParams { subscription: SubscriptionId, #[serde(flatten)] diff --git a/crates/anvil/tests/it/proof/eip1186.rs b/crates/anvil/tests/it/proof/eip1186.rs index 2c6875ecaa4da..c83cdf4f8e061 100644 --- a/crates/anvil/tests/it/proof/eip1186.rs +++ b/crates/anvil/tests/it/proof/eip1186.rs @@ -8,7 +8,7 @@ use trie_db::{ /// Errors that may occur during proof verification. Most of the errors types simply indicate that /// the proof is invalid with respect to the statement being verified, and the exact error type can /// be used for debugging. -#[derive(PartialEq, Eq, Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum VerifyError<'a, HO, CE> { /// The proof does not contain any value for the given key /// the error carries the nibbles left after traversing the trie diff --git a/crates/cast/bin/cmd/bind.rs b/crates/cast/bin/cmd/bind.rs index 3496302917392..2de32e2ff6877 100644 --- a/crates/cast/bin/cmd/bind.rs +++ b/crates/cast/bin/cmd/bind.rs @@ -10,7 +10,7 @@ static DEFAULT_CRATE_NAME: &str = "foundry-contracts"; static DEFAULT_CRATE_VERSION: &str = "0.0.1"; /// CLI arguments for `cast bind`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct BindArgs { /// The contract address, or the path to an ABI Directory /// diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 661ea3cb18569..dfe34724df453 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -16,7 +16,7 @@ use std::{ const DEPLOYER: &str = "0x4e59b44847b379578588920ca78fbf26c0b4956c"; /// CLI arguments for `cast create2`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct Create2Args { /// Prefix for the contract address. #[clap( diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index 6186e47a6741b..381d52c50cc31 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -9,7 +9,7 @@ use foundry_config::Config; use futures::join; /// CLI arguments for `cast find-block`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct FindBlockArgs { /// The UNIX timestamp to search for, in seconds. timestamp: u64, diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index cc2b7290cc97a..9d3af767f2e11 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -8,7 +8,7 @@ use itertools::Itertools; use std::path::{Path, PathBuf}; /// CLI arguments for `cast interface`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct InterfaceArgs { /// The contract address, or the path to an ABI file. /// diff --git a/crates/cast/bin/cmd/rpc.rs b/crates/cast/bin/cmd/rpc.rs index 78c0105de6c96..44275204adefb 100644 --- a/crates/cast/bin/cmd/rpc.rs +++ b/crates/cast/bin/cmd/rpc.rs @@ -6,7 +6,7 @@ use foundry_config::Config; use itertools::Itertools; /// CLI arguments for `cast rpc`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct RpcArgs { /// RPC method name method: String, diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 12237a6d6d952..535dc3b46a7b4 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -18,7 +18,7 @@ use foundry_evm::{ }; /// CLI arguments for `cast run`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct RunArgs { /// The transaction hash. tx_hash: String, diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 1862cb6231161..293833fb42be3 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -31,7 +31,7 @@ use std::str::FromStr; const MIN_SOLC: Version = Version::new(0, 6, 5); /// CLI arguments for `cast storage`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct StorageArgs { /// The contract address. #[clap(value_parser = NameOrAddress::from_str)] @@ -180,7 +180,7 @@ impl StorageArgs { } /// Represents the value of a storage slot `eth_getStorageAt` call. -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] struct StorageValue { /// The slot number. slot: B256, diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 5dacefb52d466..579265bee868c 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -17,7 +17,7 @@ use std::{ pub type GeneratedWallet = (SigningKey, Address); /// CLI arguments for `cast wallet vanity`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct VanityArgs { /// Prefix for the vanity address. #[clap( @@ -333,7 +333,7 @@ impl VanityMatcher for RegexMatcher { } /// Parse 40 byte addresses -#[derive(Copy, Clone, Debug, Default)] +#[derive(Clone, Copy, Debug, Default)] pub struct HexAddressValidator; impl TypedValueParser for HexAddressValidator { diff --git a/crates/cast/src/errors.rs b/crates/cast/src/errors.rs index 235ec4d7ca44f..40a8e9755b112 100644 --- a/crates/cast/src/errors.rs +++ b/crates/cast/src/errors.rs @@ -4,7 +4,7 @@ use foundry_config::Chain; use std::fmt; /// An error thrown when resolving a function via signature failed -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub enum FunctionSignatureError { MissingSignature, MissingEtherscan { sig: String }, diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index 3a520844d76b1..d0e94301ee658 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -5,7 +5,7 @@ use std::fmt; /// Arbitrary nested data /// Item::Array(vec![]); is equivalent to [] /// Item::Array(vec![Item::Data(vec![])]); is equivalent to [""] or [null] -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Item { Data(Vec), Array(Vec), diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index e8b4178fd9372..b148ea361332e 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -28,7 +28,7 @@ pub struct RecordAccess { } /// Records `deal` cheatcodes -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct DealRecord { /// Target of the deal. pub address: Address, diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 390c16fb92f57..f139e47cd8c40 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -75,7 +75,7 @@ impl Context { } /// Helps collecting transactions from different forks. -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct BroadcastableTransaction { /// The optional RPC URL. pub rpc: Option, @@ -86,7 +86,7 @@ pub struct BroadcastableTransaction { /// List of transactions that can be broadcasted. pub type BroadcastableTransactions = VecDeque; -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct AccountAccess { /// The account access. pub access: crate::Vm::AccountAccess, diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 246ebaa52e2c0..2bea10e82fcd5 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -60,7 +60,7 @@ pub struct ChiselParser { } /// Chisel binary subcommands -#[derive(clap::Subcommand, Debug)] +#[derive(Debug, clap::Subcommand)] pub enum ChiselParserSub { /// List all cached sessions List, diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 0864ce2ea9240..9fc65c055bc36 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -499,7 +499,7 @@ fn format_event_definition(event_definition: &pt::EventDefinition) -> Result) -> Result { } } -#[derive(Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] struct Instruction { pub pc: usize, pub opcode: u8, diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 4a05d2cde11ee..3e4efa2fd8c8f 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -22,7 +22,7 @@ use yansi::Paint; static VM_SOURCE: &str = include_str!("../../../testdata/cheats/Vm.sol"); /// Intermediate output for the compiled [SessionSource] -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct IntermediateOutput { /// All expressions within the REPL contract's run function and top level scope. #[serde(skip)] @@ -34,7 +34,7 @@ pub struct IntermediateOutput { /// A refined intermediate parse tree for a contract that enables easy lookups /// of definitions. -#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct IntermediateContract { /// All function definitions within the contract #[serde(skip)] @@ -54,7 +54,7 @@ pub struct IntermediateContract { type IntermediateContracts = HashMap; /// Full compilation output for the [SessionSource] -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct GeneratedOutput { /// The [IntermediateOutput] component pub intermediate: IntermediateOutput, @@ -63,7 +63,7 @@ pub struct GeneratedOutput { } /// Configuration for the [SessionSource] -#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct SessionSourceConfig { /// Foundry configuration pub foundry_config: Config, @@ -143,7 +143,7 @@ You can also set the solc version in your foundry.toml.") /// REPL Session Source wrapper /// /// Heavily based on soli's [`ConstructedSource`](https://github.com/jpopesculian/soli/blob/master/src/main.rs#L166) -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct SessionSource { /// The file name pub file_name: PathBuf, diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index aec937c780e6f..02c14a90fa6e7 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -18,7 +18,7 @@ use foundry_config::{ use serde::Serialize; use std::path::PathBuf; -#[derive(Debug, Clone, Parser, Serialize, Default)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Build options")] pub struct CoreBuildArgs { /// Clear the cache and artifacts folder and recompile. diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index aca7fba75a1c0..d502de2d41b95 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -12,7 +12,7 @@ pub use self::paths::ProjectPathsArgs; // to be merged into an existing `foundry_config::Config`. // // See also `BuildArgs`. -#[derive(Default, Debug, Clone, Parser, Serialize)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Compiler options")] pub struct CompilerArgs { /// The target EVM version. diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index 4989bf7d911c7..29f505ee34cf2 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -14,7 +14,7 @@ use serde::Serialize; use std::path::PathBuf; /// Common arguments for a project's paths. -#[derive(Debug, Clone, Parser, Serialize, Default)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Project options")] pub struct ProjectPathsArgs { /// The project's root path. diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index a4478f358d7ee..5fa1d851f3cfc 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -35,7 +35,7 @@ const COMMON_ORG_ALIASES: &[(&str, &str); 2] = /// /// Non Github URLs must be provided with an https:// prefix. /// Adding dependencies as local paths is not supported yet. -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Dependency { /// The name of the dependency pub name: String, diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 17319952b01a5..8a034a8a07e17 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -83,7 +83,7 @@ impl RpcOpts { } } -#[derive(Clone, Debug, Default, Parser, Serialize)] +#[derive(Clone, Debug, Default, Serialize, Parser)] pub struct EtherscanOpts { /// The Etherscan (or equivalent) API key. #[clap(short = 'e', long = "etherscan-api-key", alias = "api-key", env = "ETHERSCAN_API_KEY")] diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index ec92ce3ef457b..bda2fb02118a1 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -3,7 +3,7 @@ use alloy_primitives::U256; use clap::Parser; use serde::Serialize; -#[derive(Parser, Debug, Clone, Serialize)] +#[derive(Clone, Debug, Serialize, Parser)] #[clap(next_help_heading = "Transaction options")] pub struct TransactionOpts { /// Gas limit for the transaction. diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/cli/src/opts/wallet/mod.rs index e7b0db68e02d0..66523e92ec5cc 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/cli/src/opts/wallet/mod.rs @@ -34,7 +34,7 @@ pub mod error; /// 1. Private Key (cleartext in CLI) /// 2. Private Key (interactively via secure prompt) /// 3. Mnemonic (via file path) -#[derive(Parser, Debug, Default, Clone, Serialize)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Wallet options - raw", about = None, long_about = None)] pub struct RawWallet { /// Open an interactive prompt to enter your private key. @@ -76,7 +76,7 @@ pub struct RawWallet { /// 3. Trezor /// 4. Keystore (via file path) /// 5. AWS KMS -#[derive(Parser, Debug, Default, Clone, Serialize)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Wallet options", about = None, long_about = None)] pub struct Wallet { /// The sender account. @@ -549,7 +549,7 @@ impl Signer for &WalletSigner { } /// Excerpt of a keystore file. -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct KeystoreFile { pub address: Address, } diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index 1114d24fa65ad..0ca13005ef0cb 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -70,7 +70,7 @@ macro_rules! create_hw_wallets { /// 5. Private Keys (cleartext in CLI) /// 6. Private Keys (interactively via secure prompt) /// 7. AWS KMS -#[derive(Parser, Debug, Clone, Serialize, Default)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Wallet options", about = None, long_about = None)] pub struct MultiWallet { /// The sender accounts. diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 8ecf37fccca6e..3d1db499d4072 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -23,7 +23,7 @@ use std::{ /// /// This is merely a wrapper for [Project::compile()] which also prints to stdout dependent on its /// settings -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct ProjectCompiler { /// whether to also print the contract names print_names: bool, @@ -172,7 +172,7 @@ impl ProjectCompiler { } /// Map over artifacts contract sources name -> file_id -> (source, contract) -#[derive(Default, Debug, Clone)] +#[derive(Clone, Debug, Default)] pub struct ContractSources(pub HashMap>); // https://eips.ethereum.org/EIPS/eip-170 @@ -253,7 +253,7 @@ pub fn deployed_contract_size(artifact: &T) -> Option { } /// How big the contract is and whether it is a dev contract where size limits can be neglected -#[derive(Debug, Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct ContractInfo { /// size of the contract in bytes pub size: usize, @@ -513,7 +513,7 @@ pub fn etherscan_project(metadata: &Metadata, target_path: impl AsRef) -> } /// Bundles multiple `SkipBuildFilter` into a single `FileFilter` -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct SkipBuildFilters(pub Vec); impl FileFilter for SkipBuildFilters { @@ -524,7 +524,7 @@ impl FileFilter for SkipBuildFilters { } /// A filter that excludes matching contracts from the build -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum SkipBuildFilter { /// Exclude all `.t.sol` contracts Tests, diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 652db9531d1cc..cad74931766eb 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -17,7 +17,7 @@ use std::{ type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a (Abi, Vec)); /// Wrapper type that maps an artifact to a contract ABI and bytecode. -#[derive(Default, Clone)] +#[derive(Clone, Default)] pub struct ContractsByArtifact(pub BTreeMap)>); impl ContractsByArtifact { diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 830ae35da3d45..2080951abb4a2 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -38,7 +38,7 @@ pub type Breakpoints = HashMap; /// let opts = figment.extract::().unwrap(); /// # } /// ``` -#[derive(Debug, Clone, Default, Parser, Serialize)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "EVM options", about = None, long_about = None)] // override doc pub struct EvmArgs { /// Fetch state over a remote endpoint instead of starting from an empty state. @@ -178,7 +178,7 @@ impl Provider for EvmArgs { } /// Configures the executor environment during tests. -#[derive(Debug, Clone, Default, Parser, Serialize)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Executor environment config")] pub struct EnvArgs { /// The block gas limit. diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 98f6968686d68..28ceef610ad21 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -280,7 +280,7 @@ revertReason {}", } /// Various numerical ethereum types used for pretty printing -#[derive(Debug, Clone, Deserialize)] +#[derive(Clone, Debug, Deserialize)] #[serde(untagged)] #[allow(missing_docs)] pub enum EthValue { diff --git a/crates/common/src/glob.rs b/crates/common/src/glob.rs index 8557c35b5985a..e573104f67a55 100644 --- a/crates/common/src/glob.rs +++ b/crates/common/src/glob.rs @@ -22,7 +22,7 @@ pub fn expand_globs( /// A `globset::Glob` that creates its `globset::GlobMatcher` when its created, so it doesn't need /// to be compiled when the filter functions `TestFilter` functions are called. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct GlobMatcher { /// The parsed glob pub glob: globset::Glob, diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs index 9ace81a289e2a..1f8949aa023ed 100644 --- a/crates/common/src/retry.rs +++ b/crates/common/src/retry.rs @@ -4,7 +4,7 @@ use eyre::{Error, Result}; use std::{future::Future, time::Duration}; /// A type that keeps track of attempts. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Retry { retries: u32, delay: Option, diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index a14ea20593be7..fc53d87caea85 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -28,7 +28,7 @@ enum InnerClient { } /// Error type for the runtime provider -#[derive(Error, Debug)] +#[derive(Debug, Error)] pub enum RuntimeClientError { /// Internal provider error #[error(transparent)] diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index da4884deb1b81..682b31f2f8d7a 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -24,7 +24,7 @@ const REQ_TIMEOUT: Duration = Duration::from_secs(15); const MAX_TIMEDOUT_REQ: usize = 4usize; /// A client that can request API data from `https://api.openchain.xyz` -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct SignEthClient { inner: reqwest::Client, /// Whether the connection is spurious, or API is down @@ -418,7 +418,7 @@ pub async fn pretty_calldata( SignEthClient::new()?.pretty_calldata(calldata, offline).await } -#[derive(Default, Serialize, PartialEq, Debug, Eq)] +#[derive(Debug, Default, PartialEq, Eq, Serialize)] pub struct RawSelectorImportData { pub function: Vec, pub event: Vec, @@ -490,7 +490,7 @@ pub async fn import_selectors(data: SelectorImportData) -> eyre::Result, diff --git a/crates/common/src/shell.rs b/crates/common/src/shell.rs index 9b359fbc49350..9955269ee38aa 100644 --- a/crates/common/src/shell.rs +++ b/crates/common/src/shell.rs @@ -13,7 +13,7 @@ use std::{ static SHELL: OnceCell = OnceCell::new(); /// Error indicating that `set_hook` was unable to install the provided ErrorHook -#[derive(Debug, Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct InstallError; impl fmt::Display for InstallError { @@ -283,7 +283,7 @@ impl ShellOut { } /// The requested verbosity of output. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum Verbosity { /// only allow json output Json, diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 78838bb957b49..b337147d6171f 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -5,7 +5,7 @@ use eyre::Result; use serde::{Deserialize, Serialize}; /// Helper type to carry a transaction along with an optional revert reason -#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct TransactionReceiptWithRevertReason { /// The underlying transaction receipt #[serde(flatten)] diff --git a/crates/common/src/units.rs b/crates/common/src/units.rs index 3a85ba3e04b19..9dc40e6ce8a91 100644 --- a/crates/common/src/units.rs +++ b/crates/common/src/units.rs @@ -137,7 +137,7 @@ impl Units { /// This enum holds the numeric types that a possible to be returned by `parse_units` and /// that are taken by `format_units`. -#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum ParseUnits { /// Unsigned 256-bit integer. U256(U256), @@ -212,7 +212,7 @@ construct_signed_format_units_from! { } /// Handles all possible conversion errors. -#[derive(Error, Debug)] +#[derive(Debug, Error)] pub enum ConversionError { /// The unit is unrecognized. #[error("Unknown units: {0}")] diff --git a/crates/config/src/cache.rs b/crates/config/src/cache.rs index bebb3e5284cc3..ef0ca40a468ea 100644 --- a/crates/config/src/cache.rs +++ b/crates/config/src/cache.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{fmt, fmt::Formatter, str::FromStr}; /// Settings to configure caching of remote -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct StorageCachingConfig { /// chains to cache pub chains: CachedChains, @@ -31,7 +31,7 @@ impl StorageCachingConfig { } /// What chains to cache -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub enum CachedChains { /// Cache all chains #[default] @@ -89,7 +89,7 @@ impl<'de> Deserialize<'de> for CachedChains { } /// What endpoints to enable caching for -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub enum CachedEndpoints { /// Cache all endpoints #[default] diff --git a/crates/config/src/doc.rs b/crates/config/src/doc.rs index 2dfac01b4df44..36e8a12b08df2 100644 --- a/crates/config/src/doc.rs +++ b/crates/config/src/doc.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use std::path::PathBuf; /// Contains the config for parsing and rendering docs -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct DocConfig { /// Doc output path. pub out: PathBuf, diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index 1f0708c109694..d3e90702a6ce7 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -9,7 +9,7 @@ use std::{ }; /// Container type for API endpoints, like various RPC endpoints -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(transparent)] pub struct RpcEndpoints { endpoints: BTreeMap, @@ -50,7 +50,7 @@ impl Deref for RpcEndpoints { /// env var, then the `Endpoint::Env` var will hold the reference (`${MAIN_NET}`) and _not_ the /// value of the env var itself. /// In other words, this type does not resolve env vars when it's being deserialized -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum RpcEndpoint { /// A raw Url (ws, http) Url(String), @@ -135,7 +135,7 @@ impl<'de> Deserialize<'de> for RpcEndpoint { } /// Container type for _resolved_ endpoints, see [RpcEndpoints::resolve_all()] -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ResolvedRpcEndpoints { /// contains all named endpoints and their URL or an error if we failed to resolve the env var /// alias diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 2073151533809..97f0ec10de579 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -55,7 +55,7 @@ impl Error for ExtractConfigError { } /// Represents an error that can occur when constructing the `Config` -#[derive(Debug, Clone, PartialEq)] +#[derive(Clone, Debug, PartialEq)] pub enum FoundryConfigError { /// An error thrown during toml parsing Toml(figment::Error), @@ -98,7 +98,7 @@ impl Error for FoundryConfigError { } /// A non-exhaustive list of solidity error codes -#[derive(Debug, Clone, Copy, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SolidityErrorCode { /// Warning that SPDX license identifier not provided in source file SpdxLicenseNotProvided, diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 1af928b7cced8..ce1c4324d5bc1 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -16,7 +16,7 @@ use std::{ pub const ETHERSCAN_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); /// Errors that can occur when creating an `EtherscanConfig` -#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] +#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)] pub enum EtherscanConfigError { #[error(transparent)] Unresolved(#[from] UnresolvedEnvVarError), @@ -29,7 +29,7 @@ pub enum EtherscanConfigError { } /// Container type for Etherscan API keys and URLs. -#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(transparent)] pub struct EtherscanConfigs { configs: BTreeMap, @@ -83,7 +83,7 @@ impl DerefMut for EtherscanConfigs { } /// Container type for _resolved_ etherscan keys, see [EtherscanConfigs::resolve_all()] -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ResolvedEtherscanConfigs { /// contains all named `ResolvedEtherscanConfig` or an error if we failed to resolve the env /// var alias @@ -138,7 +138,7 @@ impl DerefMut for ResolvedEtherscanConfigs { } /// Represents all info required to create an etherscan client -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct EtherscanConfig { /// The chain name or EIP-155 chain ID used to derive the API URL. #[serde(default, skip_serializing_if = "Option::is_none")] @@ -204,7 +204,7 @@ impl EtherscanConfig { } /// Contains required url + api key to set up an etherscan client -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct ResolvedEtherscanConfig { /// Etherscan API URL. #[serde(rename = "url")] @@ -300,7 +300,7 @@ impl ResolvedEtherscanConfig { /// env var, then the `EtherscanKey::Key` var will hold the reference (`${MAIN_NET}`) and _not_ the /// value of the env var itself. /// In other words, this type does not resolve env vars when it's being deserialized -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum EtherscanApiKey { /// A raw key Key(String), diff --git a/crates/config/src/fmt.rs b/crates/config/src/fmt.rs index 44e624b127aa1..a1cc66c080648 100644 --- a/crates/config/src/fmt.rs +++ b/crates/config/src/fmt.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; /// Contains the config and rule set -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct FormatterConfig { /// Maximum line length where formatter will try to wrap the line pub line_length: usize, @@ -36,7 +36,7 @@ pub struct FormatterConfig { } /// Style of uint/int256 types -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum IntTypes { /// Print the explicit uint256 or int256 @@ -48,7 +48,7 @@ pub enum IntTypes { } /// Style of underscores in number literals -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum NumberUnderscore { /// Use the underscores defined in the source code @@ -82,7 +82,7 @@ impl NumberUnderscore { } /// Style of underscores in hex literals -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum HexUnderscore { /// Use the underscores defined in the source code @@ -115,7 +115,7 @@ impl HexUnderscore { } /// Style of string quotes -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum QuoteStyle { /// Use double quotes where possible @@ -138,7 +138,7 @@ impl QuoteStyle { } /// Style of single line blocks in statements -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum SingleLineBlockStyle { /// Prefer single line block when possible @@ -150,7 +150,7 @@ pub enum SingleLineBlockStyle { } /// Style of function header in case it doesn't fit -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum MultilineFuncHeaderStyle { /// Write function parameters multiline first diff --git a/crates/config/src/fs_permissions.rs b/crates/config/src/fs_permissions.rs index 5a8328ba4b1c5..ead647a6febab 100644 --- a/crates/config/src/fs_permissions.rs +++ b/crates/config/src/fs_permissions.rs @@ -10,7 +10,7 @@ use std::{ /// Configures file system access /// /// E.g. for cheat codes (`vm.writeFile`) -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(transparent)] pub struct FsPermissions { /// what kind of access is allowed @@ -98,7 +98,7 @@ impl FsPermissions { } /// Represents an access permission to a single path -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct PathPermission { /// Permission level to access the `path` pub access: FsAccessPermission, @@ -141,7 +141,7 @@ impl PathPermission { } /// Represents the operation on the fs -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum FsAccessKind { /// read from fs (`vm.readFile`) Read, @@ -159,7 +159,7 @@ impl fmt::Display for FsAccessKind { } /// Determines the status of file system access -#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum FsAccessPermission { /// FS access is _not_ allowed #[default] diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index ff59f10fc32e7..1d033b3ef18d5 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -7,7 +7,7 @@ use alloy_primitives::U256; use serde::{Deserialize, Serialize}; /// Contains for fuzz testing -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct FuzzConfig { /// The number of test cases that must execute for each property test pub runs: u32, @@ -67,7 +67,7 @@ impl InlineConfigParser for FuzzConfig { } /// Contains for fuzz testing -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct FuzzDictionaryConfig { /// The weight of the dictionary #[serde(deserialize_with = "crate::deserialize_stringified_percent")] diff --git a/crates/config/src/inline/error.rs b/crates/config/src/inline/error.rs index 4c4f7725b0847..e998a2156d8cd 100644 --- a/crates/config/src/inline/error.rs +++ b/crates/config/src/inline/error.rs @@ -1,5 +1,5 @@ /// Errors returned by the [`InlineConfigParser`] trait. -#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] +#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)] pub enum InlineConfigParserError { /// An invalid configuration property has been provided. /// The property cannot be mapped to the configuration object @@ -19,7 +19,7 @@ pub enum InlineConfigParserError { /// Wrapper error struct that catches config parsing /// errors [`InlineConfigParserError`], enriching them with context information /// reporting the misconfigured line. -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error)] #[error("Inline config error detected at {line}")] pub struct InlineConfigError { /// Specifies the misconfigured line. This is something of the form diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 4ce3c62f04c02..af2cbe7e3cf1d 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -21,7 +21,7 @@ static INLINE_CONFIG_PREFIX_SELECTED_PROFILE: Lazy = Lazy::new(|| { /// Represents per-test configurations, declared inline /// as structured comments in Solidity test files. This allows /// to create configs directly bound to a solidity test. -#[derive(Default, Debug, Clone)] +#[derive(Clone, Debug, Default)] pub struct InlineConfig { /// Maps a (test-contract, test-function) pair /// to a specific configuration provided by the user. @@ -60,7 +60,7 @@ impl InlineConfig { } /// Represents a (test-contract, test-function) pair -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] struct InlineConfigKey<'a> { contract: Cow<'a, str>, function: Cow<'a, str>, diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index f31794bf576ae..e4e2f86a81d4e 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -10,7 +10,7 @@ use crate::{ use serde::{Deserialize, Serialize}; /// Contains for invariant testing -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct InvariantConfig { /// The number of runs that must execute for each invariant test group. pub runs: u32, diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index e2725d6a6c130..c5fccf3296ab9 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -128,7 +128,7 @@ pub use inline::{validate_profiles, InlineConfig, InlineConfigError, InlineConfi /// the "default" meta-profile. /// /// Note that these behaviors differ from those of [`Config::figment()`]. -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Config { /// The selected profile. **(default: _default_ `default`)** /// @@ -1620,7 +1620,7 @@ impl From for Figment { } /// Wrapper type for `regex::Regex` that implements `PartialEq` -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] #[serde(transparent)] pub struct RegexWrapper { #[serde(with = "serde_regex")] @@ -1680,7 +1680,7 @@ pub(crate) mod from_opt_glob { } /// A helper wrapper around the root path used during Config detection -#[derive(Debug, PartialEq, Eq, Hash, Clone, PartialOrd, Ord, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct RootPath(pub PathBuf); @@ -1841,7 +1841,7 @@ impl Default for Config { /// /// Due to this limitation this type will be serialized/deserialized as String if it's larger than /// `i64` -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct GasLimit(pub u64); impl From for GasLimit { @@ -1911,7 +1911,7 @@ impl<'de> Deserialize<'de> for GasLimit { } /// Variants for selecting the [`Solc`] instance -#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged)] pub enum SolcReq { /// Requires a specific solc version, that's either already installed (via `svm`) or will be @@ -2451,7 +2451,7 @@ impl ProviderExt for P {} /// /// let my_config = Config::figment().extract::(); /// ``` -#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct BasicConfig { /// the profile tag: `[profile.default]` #[serde(skip)] diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 7d81b568c8902..67ae449fb8141 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -12,7 +12,7 @@ use std::{ }; /// Wrapper types over a `Vec` that only appends unique remappings. -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct Remappings { /// Remappings. remappings: Vec, diff --git a/crates/config/src/resolve.rs b/crates/config/src/resolve.rs index b062558b353d3..b817f43677c62 100644 --- a/crates/config/src/resolve.rs +++ b/crates/config/src/resolve.rs @@ -9,7 +9,7 @@ pub static RE_PLACEHOLDER: Lazy = Lazy::new(|| Regex::new(r"(?m)(?P\$\{\s*(?P.*?)\s*})").unwrap()); /// Error when we failed to resolve an env var -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct UnresolvedEnvVarError { /// The unresolved input string pub unresolved: String, diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 8fb3289227c6d..da067a1ed8cd0 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -264,7 +264,7 @@ where } /// Helper type to parse both `u64` and `U256` -#[derive(Copy, Clone, Deserialize)] +#[derive(Clone, Copy, Deserialize)] #[serde(untagged)] pub enum Numeric { /// A [U256] value. diff --git a/crates/config/src/warning.rs b/crates/config/src/warning.rs index fc98be3d4fa25..027554ff1047f 100644 --- a/crates/config/src/warning.rs +++ b/crates/config/src/warning.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use std::{fmt, path::PathBuf}; /// Warnings emitted during loading or managing Configuration -#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(tag = "type")] pub enum Warning { /// An unknown section was encountered in a TOML file diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index ca06b468ce6bb..b6e6d08af276a 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; /// The natspec comment tag explaining the purpose of the comment. /// See: https://docs.soliditylang.org/en/v0.8.17/natspec-format.html#tags. -#[derive(PartialEq, Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub enum CommentTag { /// A title that should describe the contract/interface Title, @@ -55,7 +55,7 @@ impl CommentTag { /// The natspec documentation comment. /// https://docs.soliditylang.org/en/v0.8.17/natspec-format.html -#[derive(PartialEq, Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub struct Comment { /// The doc comment tag. pub tag: CommentTag, @@ -98,7 +98,7 @@ impl Comment { } /// The collection of natspec [Comment] items. -#[derive(Deref, DerefMut, PartialEq, Default, Clone, Debug)] +#[derive(Clone, Debug, Default, PartialEq, Deref, DerefMut)] pub struct Comments(Vec); /// Forward the [Comments] function implementation to the [CommentsRef] @@ -152,7 +152,7 @@ impl From> for Comments { } /// The collection of references to natspec [Comment] items. -#[derive(Deref, PartialEq, Default, Debug)] +#[derive(Debug, Default, PartialEq, Deref)] pub struct CommentsRef<'a>(Vec<&'a Comment>); impl<'a> CommentsRef<'a> { diff --git a/crates/doc/src/parser/error.rs b/crates/doc/src/parser/error.rs index 26ffb6256fc60..770137f99d173 100644 --- a/crates/doc/src/parser/error.rs +++ b/crates/doc/src/parser/error.rs @@ -2,7 +2,7 @@ use forge_fmt::FormatterError; use thiserror::Error; /// The parser error. -#[derive(Error, Debug)] +#[derive(Debug, Error)] #[error(transparent)] pub enum ParserError { /// Formatter error. diff --git a/crates/doc/src/parser/item.rs b/crates/doc/src/parser/item.rs index 0321fc411a975..60faf78b411b1 100644 --- a/crates/doc/src/parser/item.rs +++ b/crates/doc/src/parser/item.rs @@ -9,7 +9,7 @@ use solang_parser::pt::{ }; /// The parsed item. -#[derive(PartialEq, Debug)] +#[derive(Debug, PartialEq)] pub struct ParseItem { /// The parse tree source. pub source: ParseSource, @@ -147,7 +147,7 @@ impl ParseItem { } /// A wrapper type around pt token. -#[derive(PartialEq, Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub enum ParseSource { /// Source contract definition. Contract(Box), diff --git a/crates/doc/src/preprocessor/contract_inheritance.rs b/crates/doc/src/preprocessor/contract_inheritance.rs index 7b4b28e10e060..894f373e775ff 100644 --- a/crates/doc/src/preprocessor/contract_inheritance.rs +++ b/crates/doc/src/preprocessor/contract_inheritance.rs @@ -12,7 +12,7 @@ pub const CONTRACT_INHERITANCE_ID: PreprocessorId = PreprocessorId("contract_inh /// to link them with the paths of the other contract documents. /// /// This preprocessor writes to [Document]'s context. -#[derive(Default, Debug)] +#[derive(Debug, Default)] pub struct ContractInheritance { /// Whether to capture inherited contracts from libraries. pub include_libraries: bool, diff --git a/crates/doc/src/preprocessor/deployments.rs b/crates/doc/src/preprocessor/deployments.rs index aaef8e42501f8..9ad360c57487f 100644 --- a/crates/doc/src/preprocessor/deployments.rs +++ b/crates/doc/src/preprocessor/deployments.rs @@ -21,7 +21,7 @@ pub struct Deployments { } /// A contract deployment. -#[derive(serde::Deserialize, Debug, Clone)] +#[derive(Clone, Debug, serde::Deserialize)] pub struct Deployment { /// The contract address pub address: Address, diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index ba20d95e79f42..865c4302fdf46 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -24,7 +24,7 @@ pub const INFER_INLINE_HYPERLINKS_ID: PreprocessorId = PreprocessorId("infer inl /// comments for dev comment tags. /// /// This preprocessor replaces inline links in comments with the links to the referenced items. -#[derive(Default, Debug)] +#[derive(Debug, Default)] #[non_exhaustive] pub struct InferInlineHyperlinks; diff --git a/crates/doc/src/preprocessor/inheritdoc.rs b/crates/doc/src/preprocessor/inheritdoc.rs index 3989991865574..583df72ba863d 100644 --- a/crates/doc/src/preprocessor/inheritdoc.rs +++ b/crates/doc/src/preprocessor/inheritdoc.rs @@ -13,7 +13,7 @@ pub const INHERITDOC_ID: PreprocessorId = PreprocessorId("inheritdoc"); /// comments for inheritdoc comment tags. /// /// This preprocessor writes to [Document]'s context. -#[derive(Default, Debug)] +#[derive(Debug, Default)] #[non_exhaustive] pub struct Inheritdoc; diff --git a/crates/doc/src/preprocessor/mod.rs b/crates/doc/src/preprocessor/mod.rs index 96af88ebc97e7..25ed4db231ae7 100644 --- a/crates/doc/src/preprocessor/mod.rs +++ b/crates/doc/src/preprocessor/mod.rs @@ -19,13 +19,13 @@ mod deployments; pub use deployments::{Deployment, Deployments, DEPLOYMENTS_ID}; /// The preprocessor id. -#[derive(Debug, Eq, Hash, PartialEq)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct PreprocessorId(&'static str); /// Preprocessor output. /// Wraps all existing preprocessor outputs /// in a single abstraction. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub enum PreprocessorOutput { /// The contract inheritance output. /// The map of contract base idents to the path of the base contract. diff --git a/crates/doc/src/writer/buf_writer.rs b/crates/doc/src/writer/buf_writer.rs index 3c1728b840ba4..7ab47c953c5fe 100644 --- a/crates/doc/src/writer/buf_writer.rs +++ b/crates/doc/src/writer/buf_writer.rs @@ -19,7 +19,7 @@ static DEPLOYMENTS_TABLE_SEPARATOR: Lazy = /// The buffered writer. /// Writes various display items into the internal buffer. -#[derive(Default, Debug)] +#[derive(Debug, Default)] pub struct BufWriter { buf: String, } diff --git a/crates/evm/core/src/backend/diagnostic.rs b/crates/evm/core/src/backend/diagnostic.rs index 0dc788e830583..f4de9260ab565 100644 --- a/crates/evm/core/src/backend/diagnostic.rs +++ b/crates/evm/core/src/backend/diagnostic.rs @@ -4,7 +4,7 @@ use itertools::Itertools; use std::collections::HashMap; /// Represents possible diagnostic cases on revert -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub enum RevertDiagnostic { /// The `contract` does not exist on the `active` fork but exist on other fork(s) ContractExistsOnOtherForks { diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index 0a963810abde5..b3cf5a959a4ae 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -32,7 +32,7 @@ use std::{borrow::Cow, collections::HashMap}; /// don't make use of them. Alternatively each test case would require its own `Backend` clone, /// which would add significant overhead for large fuzz sets even if the Database is not big after /// setup. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct FuzzBackendWrapper<'a> { /// The underlying immutable `Backend` /// diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index 6cb2c73eebdee..b27bbe750cc7c 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -87,7 +87,7 @@ impl DatabaseCommit for MemDb { /// If an account is `NotExisting`, `Database(Ref)::basic` will always return `None` for the /// requested `AccountInfo`. To prevent this, we ensure that a missing account is never marked as /// `NotExisting` by always returning `Some` with this type. -#[derive(Debug, Default, Clone)] +#[derive(Clone, Debug, Default)] pub struct EmptyDBWrapper(EmptyDB); impl DatabaseRef for EmptyDBWrapper { diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 246a38320e2b1..35a56371680c4 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -373,7 +373,7 @@ pub trait DatabaseExt: Database { /// **Note:** Snapshots work across fork-swaps, e.g. if fork `A` is currently active, then a /// snapshot is created before fork `B` is selected, then fork `A` will be the active fork again /// after reverting the snapshot. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Backend { /// The access point for managing forks forks: MultiFork, @@ -1484,7 +1484,7 @@ impl Database for Backend { } /// Variants of a [revm::Database] -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub enum BackendDatabaseSnapshot { /// Simple in-memory [revm::Database] InMemory(FoundryEvmInMemoryDB), @@ -1493,7 +1493,7 @@ pub enum BackendDatabaseSnapshot { } /// Represents a fork -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Fork { db: ForkDB, journaled_state: JournaledState, @@ -1514,7 +1514,7 @@ impl Fork { } /// Container type for various Backend related data -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct BackendInner { /// Stores the `ForkId` of the fork the `Backend` launched with from the start. /// diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index 8ce506d0f0714..35ca9222b88a6 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -6,7 +6,7 @@ use revm::{ use serde::{Deserialize, Serialize}; /// A minimal abstraction of a state at a certain point in time -#[derive(Default, Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct StateSnapshot { pub accounts: Map, pub storage: Map>, @@ -46,7 +46,7 @@ impl BackendSnapshot { /// What to do when reverting a snapshot /// /// Whether to remove the snapshot or keep it -#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum RevertSnapshotAction { /// Remove the snapshot after reverting #[default] diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 11cd4f383eb21..0312c05a4981a 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use std::fmt::Display; /// An arena of [DebugNode]s -#[derive(Default, Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct DebugArena { /// The arena of nodes pub arena: Vec, @@ -163,7 +163,7 @@ impl DebugNodeFlat { /// It holds the current program counter (where in the program you are), /// the stack and memory (prior to the opcodes execution), any bytes to be /// pushed onto the stack, and the instruction counter for use with sourcemap. -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct DebugStep { /// Stack *prior* to running the associated opcode pub stack: Vec, @@ -206,7 +206,7 @@ impl DebugStep { } } -#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Instruction { OpCode(u8), Cheatcode([u8; 4]), diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 4ef698eb6bbd7..a68a1220715dd 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -507,7 +507,7 @@ where // > Runs the provided blocking function on the current thread without blocking the executor. // This prevents issues (hangs) we ran into were the [SharedBackend] itself is called from a spawned // task. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct SharedBackend { /// channel used for sending commands related to database operations backend: Sender, diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index 791660d632d45..60d4cbd7276c0 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -116,7 +116,7 @@ impl BlockchainDb { } /// relevant identifying markers in the context of [BlockchainDb] -#[derive(Debug, Clone, Eq, Serialize)] +#[derive(Clone, Debug, Eq, Serialize)] pub struct BlockchainDbMeta { pub cfg_env: revm::primitives::CfgEnv, pub block_env: revm::primitives::BlockEnv, diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 1c39b99e1f9e5..67fdc90547d4b 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -21,7 +21,7 @@ use std::sync::Arc; /// endpoint. The inner in-memory database holds this storage and will be used for write operations. /// This database uses the `backend` for read and the `db` for write operations. But note the /// `backend` will also write (missing) data to the `db` in the background -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ForkedDatabase { /// responsible for fetching missing data /// diff --git a/crates/evm/core/src/fork/mod.rs b/crates/evm/core/src/fork/mod.rs index f9042ac91d3c5..61dd7bf47bf4b 100644 --- a/crates/evm/core/src/fork/mod.rs +++ b/crates/evm/core/src/fork/mod.rs @@ -16,7 +16,7 @@ mod multi; pub use multi::{ForkId, MultiFork, MultiForkHandler}; /// Represents a _fork_ of a remote chain whose data is available only via the `url` endpoint. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct CreateFork { /// Whether to enable rpc storage caching for this fork pub enable_caching: bool, diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index f00d5ffeda77f..480869bff9d65 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -28,7 +28,7 @@ use std::{ /// The identifier for a specific fork, this could be the name of the network a custom descriptive /// name. -#[derive(Debug, Clone, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct ForkId(pub String); impl fmt::Display for ForkId { @@ -45,7 +45,7 @@ impl> From for ForkId { /// The Sender half of multi fork pair. /// Can send requests to the `MultiForkHandler` to create forks -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct MultiFork { /// Channel to send `Request`s to the handler handler: Sender, diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 1ccac43d42257..6e1ae5aa07647 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -10,7 +10,7 @@ use foundry_config::{Chain, Config}; use revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}; use serde::{Deserialize, Deserializer, Serialize}; -#[derive(Debug, Clone, Serialize, Deserialize, Default)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct EvmOpts { /// The EVM environment configuration. #[serde(flatten)] @@ -197,7 +197,7 @@ impl EvmOpts { } } -#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct Env { /// The block gas limit. #[serde(deserialize_with = "string_or_number")] diff --git a/crates/evm/core/src/snapshot.rs b/crates/evm/core/src/snapshot.rs index 705c5baf7f275..423f853eed498 100644 --- a/crates/evm/core/src/snapshot.rs +++ b/crates/evm/core/src/snapshot.rs @@ -4,7 +4,7 @@ use alloy_primitives::U256; use std::{collections::HashMap, ops::Add}; /// Represents all snapshots -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Snapshots { id: U256, snapshots: HashMap, diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 8edaa4e21e0e4..fac8e7a5c4ffb 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -13,7 +13,7 @@ use std::collections::BTreeMap; pub use foundry_compilers::utils::RuntimeOrHandle; pub use revm::primitives::State as StateChangeset; -#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "UPPERCASE")] #[derive(Default)] pub enum CallKind { diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 8928f44770c1e..2ebd1be106365 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -5,7 +5,7 @@ use semver::Version; use std::collections::{HashMap, HashSet}; /// A visitor that walks the AST of a single contract and finds coverage items. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ContractVisitor<'a> { /// The source ID of the contract. source_id: usize, @@ -440,7 +440,7 @@ pub struct SourceAnalysis { } /// Analyzes a set of sources to find coverage items. -#[derive(Default, Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct SourceAnalyzer { /// A map of source IDs to their source code sources: HashMap, diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index 8a57a2349d877..8d75e0e941a08 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -2,7 +2,7 @@ use crate::{HitMap, HitMaps}; use alloy_primitives::Bytes; use revm::{interpreter::Interpreter, Database, EVMData, Inspector}; -#[derive(Clone, Default, Debug)] +#[derive(Clone, Debug, Default)] pub struct CoverageCollector { /// Maps that track instruction hit data. pub maps: HitMaps, diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index cd9785b12ef1f..04ecaf948b81b 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -28,7 +28,7 @@ pub use inspector::CoverageCollector; /// /// A coverage report contains coverage items and opcodes corresponding to those items (called /// "anchors"). A single coverage item may be referred to by multiple anchors. -#[derive(Default, Debug, Clone)] +#[derive(Clone, Debug, Default)] pub struct CoverageReport { /// A map of source IDs to the source path pub source_paths: HashMap<(Version, usize), String>, @@ -154,7 +154,7 @@ impl CoverageReport { } /// A collection of [HitMap]s -#[derive(Default, Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct HitMaps(pub HashMap); impl HitMaps { @@ -188,7 +188,7 @@ impl DerefMut for HitMaps { /// Hit data for an address. /// /// Contains low-level data about hit counters for the instructions in the bytecode of a contract. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct HitMap { pub bytecode: Bytes, pub hits: BTreeMap, @@ -228,7 +228,7 @@ impl HitMap { } /// A unique identifier for a contract -#[derive(Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct ContractId { pub version: Version, pub source_id: usize, @@ -315,7 +315,7 @@ impl Display for CoverageItem { } } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct SourceLocation { /// The source ID. pub source_id: usize, @@ -343,7 +343,7 @@ impl Display for SourceLocation { } /// Coverage summary for a source file. -#[derive(Default, Debug, Clone)] +#[derive(Clone, Debug, Default)] pub struct CoverageSummary { /// The number of executable lines in the source file. pub line_count: usize, diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index f0f476f8adcc8..28ed361bf92ef 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -55,7 +55,7 @@ pub struct InvariantFuzzTestResult { pub last_run_inputs: Vec, } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct InvariantFuzzError { pub logs: Vec, pub traces: Option, diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index f7dd6f6876e9c..05838560bdb0b 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -55,7 +55,7 @@ pub use tracing::TracingExecutor; /// - `committing`: any state changes made during the call are recorded and are persisting /// - `raw`: state changes only exist for the duration of the call and are discarded afterwards, in /// other words: the state of the underlying database remains unchanged. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Executor { /// The underlying `revm::Database` that contains the EVM storage. // Note: We do not store an EVM here, since we are really @@ -582,7 +582,7 @@ impl Executor { } /// Represents the context after an execution error occurred. -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error)] #[error("Execution reverted: {reason} (gas: {gas_used})")] pub struct ExecutionErr { pub reverted: bool, @@ -599,7 +599,7 @@ pub struct ExecutionErr { pub script_wallets: Vec, } -#[derive(thiserror::Error, Debug)] +#[derive(Debug, thiserror::Error)] pub enum EvmError { /// Error which occurred during execution of a transaction #[error(transparent)] diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs index 102e19fb5dea9..37f4e13edbc87 100644 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ b/crates/evm/evm/src/inspectors/access_list.rs @@ -8,7 +8,7 @@ use revm::{ }; /// An inspector that collects touched accounts and storage slots. -#[derive(Default, Debug)] +#[derive(Debug, Default)] pub struct AccessListTracer { excluded: HashSet
, access_list: HashMap>, diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index f66fdbc9beaf9..c61a7f859dd0a 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -15,7 +15,7 @@ use revm::{ }; /// An inspector that collects debug nodes on every step of the interpreter. -#[derive(Clone, Default, Debug)] +#[derive(Clone, Debug, Default)] pub struct Debugger { /// The arena of [DebugNode]s pub arena: DebugArena, diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index f517f042e7ed5..d0089ee263caa 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -14,7 +14,7 @@ use revm::{ /// An inspector that collects logs during execution. /// /// The inspector collects logs from the `LOG` opcodes as well as Hardhat-style logs. -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct LogCollector { /// The collected logs. Includes both `LOG` opcodes and Hardhat-style logs. pub logs: Vec, diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index d72d2ef0eed55..3cd5c1a2fea16 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -198,7 +198,7 @@ pub struct InspectorData { /// /// If a call to an inspector returns a value other than [InstructionResult::Continue] (or /// equivalent) the remaining inspectors are not called. -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct InspectorStack { pub cheatcodes: Option, pub chisel_state: Option, diff --git a/crates/evm/fuzz/src/invariant/call_override.rs b/crates/evm/fuzz/src/invariant/call_override.rs index c9a0b4ff10357..1d9edba5c3db1 100644 --- a/crates/evm/fuzz/src/invariant/call_override.rs +++ b/crates/evm/fuzz/src/invariant/call_override.rs @@ -10,7 +10,7 @@ use std::sync::Arc; /// Given a TestRunner and a strategy, it generates calls. Used inside the Fuzzer inspector to /// override external calls to test for potential reentrancy vulnerabilities.. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct RandomCallGenerator { /// Address of the test contract. pub test_address: Address, diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index 6a0a6ec7543c2..7faeb7a58ebfa 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -16,7 +16,7 @@ pub type FuzzRunIdentifiedContracts = Arc>; pub type BasicTxDetails = (Address, (Address, Bytes)); /// Test contract which is testing its invariants. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct InvariantContract<'a> { /// Address of the test contract. pub address: Address, diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 14d29a5673178..c13ce494a1a8e 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -100,7 +100,7 @@ impl CallTraceDecoderBuilder { /// /// Note that a call trace decoder is required for each new set of traces, since addresses in /// different sets might overlap. -#[derive(Clone, Default, Debug)] +#[derive(Clone, Debug, Default)] pub struct CallTraceDecoder { /// Addresses identified to be a specific contract. /// diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 0364133b9760c..7809a1c554737 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -11,7 +11,7 @@ use tokio::sync::RwLock; pub type SingleSignaturesIdentifier = Arc>; -#[derive(Debug, Deserialize, Serialize, Default)] +#[derive(Debug, Default, Serialize, Deserialize)] struct CachedSignatures { events: BTreeMap, functions: BTreeMap, diff --git a/crates/evm/traces/src/inspector.rs b/crates/evm/traces/src/inspector.rs index 09a6cbfdd259e..14714a141b76e 100644 --- a/crates/evm/traces/src/inspector.rs +++ b/crates/evm/traces/src/inspector.rs @@ -15,7 +15,7 @@ use revm::{ }; /// An inspector that collects call traces. -#[derive(Default, Debug, Clone)] +#[derive(Clone, Debug, Default)] pub struct Tracer { pub traces: CallTraceArena, trace_stack: Vec, diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 3d88ee23ff1eb..dc25ab3a7cece 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -42,7 +42,7 @@ pub use node::CallTraceNode; pub type Traces = Vec<(TraceKind, CallTraceArena)>; /// An arena of [CallTraceNode]s -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct CallTraceArena { /// The arena of nodes pub arena: Vec, @@ -256,7 +256,7 @@ impl fmt::Display for CallTraceArena { } /// A raw or decoded log. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum TraceLog { /// A raw log Raw(RawLog), @@ -299,14 +299,14 @@ impl fmt::Display for TraceLog { /// /// i.e. if Call 0 occurs before Log 0, it will be pushed into the `CallTraceNode`'s ordering before /// the log. -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum LogCallOrder { Log(usize), Call(usize), } /// Raw or decoded calldata. -#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TraceCallData { /// Raw calldata bytes. Raw(Bytes), @@ -335,7 +335,7 @@ impl TraceCallData { } /// Raw or decoded return data. -#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TraceRetData { /// Raw return data. Raw(Bytes), @@ -378,7 +378,7 @@ impl fmt::Display for TraceRetData { } } -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct CallTraceStep { // Fields filled in `step` /// Call depth @@ -432,7 +432,7 @@ impl From<&CallTraceStep> for StructLog { } /// A trace of a call. -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct CallTrace { /// The depth of the call pub depth: usize, diff --git a/crates/evm/traces/src/node.rs b/crates/evm/traces/src/node.rs index e68840b69e962..5eff992956a33 100644 --- a/crates/evm/traces/src/node.rs +++ b/crates/evm/traces/src/node.rs @@ -6,7 +6,7 @@ use revm::interpreter::InstructionResult; use serde::{Deserialize, Serialize}; /// A node in the arena -#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct CallTraceNode { /// Parent node index in the arena pub parent: Option, diff --git a/crates/fmt/src/buffer.rs b/crates/fmt/src/buffer.rs index 2f26f650b72bb..11c0838ecd370 100644 --- a/crates/fmt/src/buffer.rs +++ b/crates/fmt/src/buffer.rs @@ -7,7 +7,7 @@ use crate::{ use std::fmt::Write; /// An indent group. The group may optionally skip the first line -#[derive(Default, Clone, Debug)] +#[derive(Clone, Debug, Default)] struct IndentGroup { skip_line: bool, } diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index 4b373590b35fe..295d171531c48 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -4,7 +4,7 @@ use solang_parser::pt::*; use std::collections::VecDeque; /// The type of a Comment -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CommentType { /// A Line comment (e.g. `// ...`) Line, @@ -17,7 +17,7 @@ pub enum CommentType { } /// The comment position -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CommentPosition { /// Comes before the code it describes Prefix, @@ -26,7 +26,7 @@ pub enum CommentPosition { } /// Comment with additional metadata -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct CommentWithMetadata { pub ty: CommentType, pub loc: Loc, @@ -212,7 +212,7 @@ impl CommentWithMetadata { } /// A list of comments -#[derive(Default, Debug, Clone)] +#[derive(Clone, Debug, Default)] pub struct Comments { prefixes: VecDeque, postfixes: VecDeque, @@ -299,7 +299,7 @@ impl Comments { } /// The state of a character in a string with possible comments -#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum CommentState { /// character not in a comment #[default] diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 825cbb0321c0b..774cd3345264a 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -23,7 +23,7 @@ use thiserror::Error; type Result = std::result::Result; /// A custom Error thrown by the Formatter -#[derive(Error, Debug)] +#[derive(Debug, Error)] pub enum FormatterError { /// Error thrown by `std::fmt::Write` interfaces #[error(transparent)] @@ -73,7 +73,7 @@ macro_rules! bail { // TODO: store context entities as references without copying /// Current context of the Formatter (e.g. inside Contract or Function definition) -#[derive(Default, Debug)] +#[derive(Debug, Default)] struct Context { contract: Option, function: Option, diff --git a/crates/fmt/src/inline_config.rs b/crates/fmt/src/inline_config.rs index b0e3893d50da4..702669fe518bd 100644 --- a/crates/fmt/src/inline_config.rs +++ b/crates/fmt/src/inline_config.rs @@ -5,7 +5,7 @@ use std::{fmt, str::FromStr}; /// An inline config item #[allow(clippy::enum_variant_names)] -#[derive(Debug, Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum InlineConfigItem { /// Disables the next code item regardless of newlines DisableNextItem, @@ -63,7 +63,7 @@ impl DisabledRange { /// This is a list of Inline Config items for locations in a source file. This is /// usually acquired by parsing the comments for an `forgefmt:` items. See /// [`Comments::parse_inline_config_items`] for details. -#[derive(Default, Debug)] +#[derive(Debug, Default)] pub struct InlineConfig { disabled_ranges: Vec, } diff --git a/crates/fmt/src/string.rs b/crates/fmt/src/string.rs index 76f3a0df6c7dc..6ffc0b9598f27 100644 --- a/crates/fmt/src/string.rs +++ b/crates/fmt/src/string.rs @@ -4,7 +4,7 @@ /// This is a simplified version of the /// [actual parser](https://docs.soliditylang.org/en/v0.8.15/grammar.html#a4.SolidityLexer.EscapeSequence) /// as we don't care about hex or other character meanings -#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum QuoteState { /// Not currently in quoted string #[default] diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 5ec767b4ed571..4a391ee773dd0 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -148,7 +148,7 @@ fn test_formatter( ); } -#[derive(Default, Copy, Clone)] +#[derive(Clone, Copy, Default)] struct TestConfig { /// Whether to compare the formatted source code AST with the original AST skip_compare_ast_eq: bool, diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 199c83f65df40..2f0a53fcbfeca 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -15,7 +15,7 @@ const DEFAULT_CRATE_NAME: &str = "foundry-contracts"; const DEFAULT_CRATE_VERSION: &str = "0.1.0"; /// CLI arguments for `forge bind`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct BindArgs { /// Path to where the contract artifacts are stored. #[clap( diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 2c583106e3a59..46ebb02041bbf 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -42,7 +42,7 @@ foundry_config::merge_impl_figment_convert!(BuildArgs, args); /// /// Some arguments are marked as `#[serde(skip)]` and require manual processing in /// `figment::Provider` implementation -#[derive(Debug, Clone, Parser, Serialize, Default)] +#[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Build options", about = None, long_about = None)] // override doc pub struct BuildArgs { /// Print compiled contract names. diff --git a/crates/forge/bin/cmd/cache.rs b/crates/forge/bin/cmd/cache.rs index 53dbeb9fbcb8a..4ae2056c483fb 100644 --- a/crates/forge/bin/cmd/cache.rs +++ b/crates/forge/bin/cmd/cache.rs @@ -107,7 +107,7 @@ impl LsArgs { } } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub enum ChainOrAll { NamedChain(NamedChain), All, diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index a8e33cdba38ca..731a545e46100 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -8,7 +8,7 @@ use foundry_config::fix::fix_tomls; foundry_config::impl_figment_convert!(ConfigArgs, opts, evm_opts); /// CLI arguments for `forge config`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct ConfigArgs { /// Print only a basic set of the currently set config values. #[clap(long)] diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index e9b1ba3a5e53d..db550b4b07d2a 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -37,7 +37,7 @@ type SourceMaps = HashMap; foundry_config::impl_figment_convert!(CoverageArgs, opts, evm_opts); /// CLI arguments for `forge coverage`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct CoverageArgs { /// The report type to use for coverage. /// @@ -389,7 +389,7 @@ impl CoverageArgs { } // TODO: HTML -#[derive(Debug, Clone, ValueEnum)] +#[derive(Clone, Debug, ValueEnum)] pub enum CoverageReportKind { Summary, Lcov, diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 580c23fe4cb98..5f22cc146cab4 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -28,7 +28,7 @@ use serde_json::json; use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc}; /// CLI arguments for `forge create`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct CreateArgs { /// The contract identifier in the form `:`. contract: ContractInfo, diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs index bdcea1c0db60c..a69c2da3ca9eb 100644 --- a/crates/forge/bin/cmd/debug.rs +++ b/crates/forge/bin/cmd/debug.rs @@ -8,7 +8,7 @@ use std::path::PathBuf; foundry_config::impl_figment_convert!(DebugArgs, opts, evm_opts); /// CLI arguments for `forge debug`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct DebugArgs { /// The contract you want to run. Either the file path or contract name. /// diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index 9bb8b21cf7e32..c3ef50aa2fda1 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -10,7 +10,7 @@ use std::{path::PathBuf, process::Command}; mod server; use server::Server; -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct DocArgs { /// The project's root path. /// diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 64d62b4d9d349..03aa7cf6d8f42 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -8,7 +8,7 @@ use foundry_common::fs; use std::path::PathBuf; /// CLI arguments for `forge flatten`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct FlattenArgs { /// The path to the contract to flatten. #[clap(value_hint = ValueHint::FilePath, value_name = "PATH")] diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 77d0e6aed4314..a4787ed7ddc30 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -15,7 +15,7 @@ use std::{ use yansi::Color; /// CLI arguments for `forge fmt`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct FmtArgs { /// Path to the file, directory or '-' to read from stdin. #[clap(value_hint = ValueHint::FilePath, value_name = "PATH", num_args(1..))] diff --git a/crates/forge/bin/cmd/geiger/find.rs b/crates/forge/bin/cmd/geiger/find.rs index d86dcd0fc2957..ed1d5e691ae89 100644 --- a/crates/forge/bin/cmd/geiger/find.rs +++ b/crates/forge/bin/cmd/geiger/find.rs @@ -26,7 +26,7 @@ pub fn find_cheatcodes_in_string(src: &str) -> Result fmt::Display for SolFileMetricsPrinter<'a, 'b> { } /// Unsafe usage metrics collection. -#[derive(Clone, Debug, Default, Eq, PartialEq)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct UnsafeCheatcodes { pub ffi: Vec, pub read_file: Vec, diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 8e5b67d6f24d2..79d8e25b2eb47 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -16,7 +16,7 @@ use find::{find_cheatcodes_in_file, SolFileMetricsPrinter}; mod visitor; /// CLI arguments for `forge geiger`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct GeigerArgs { /// Paths to files or directories to detect. #[clap( diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 864babf557102..784ebae3dc517 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf}; use yansi::Paint; /// CLI arguments for `forge init`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct InitArgs { /// The root directory of the new project. #[clap(value_hint = ValueHint::DirPath, default_value = ".", value_name = "PATH")] diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index f1c4e09035053..a05dbb3c1ee70 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -19,7 +19,7 @@ use serde_json::{to_value, Value}; use std::fmt; /// CLI arguments for `forge inspect`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct InspectArgs { /// The identifier of the contract to inspect in the form `(:)?`. pub contract: ContractInfo, diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 270e8c97ce4e2..140cd7b5a5b15 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -21,7 +21,7 @@ static DEPENDENCY_VERSION_TAG_REGEX: Lazy = Lazy::new(|| Regex::new(r"^v?\d+(\.\d+)*$").unwrap()); /// CLI arguments for `forge install`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] #[clap(override_usage = "forge install [OPTIONS] [DEPENDENCIES]... forge install [OPTIONS] /@... forge install [OPTIONS] =/@... @@ -62,7 +62,7 @@ impl InstallArgs { } } -#[derive(Debug, Clone, Default, Copy, Parser)] +#[derive(Clone, Copy, Debug, Default, Parser)] pub struct DependencyInstallOpts { /// Perform shallow clones instead of deep ones. /// diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index 7b0c979efe6eb..97d1887736503 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -21,7 +21,7 @@ //! use foundry_config::{figment::Figment, *}; //! //! // A new clap subcommand that accepts both `EvmArgs` and `BuildArgs` -//! #[derive(Debug, Clone, Parser)] +//! #[derive(Clone, Debug, Parser)] //! pub struct MyArgs { //! #[clap(flatten)] //! evm_opts: EvmArgs, diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index a1a5f903f3ff2..d01243b35d3a8 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -7,7 +7,7 @@ use foundry_evm::hashbrown::HashMap; use std::path::PathBuf; /// CLI arguments for `forge remappings`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct RemappingArgs { /// The project's root path. /// diff --git a/crates/forge/bin/cmd/remove.rs b/crates/forge/bin/cmd/remove.rs index f5deb00b2e1fa..0b77515c86ff2 100644 --- a/crates/forge/bin/cmd/remove.rs +++ b/crates/forge/bin/cmd/remove.rs @@ -8,7 +8,7 @@ use foundry_config::impl_figment_convert_basic; use std::path::PathBuf; /// CLI arguments for `forge remove`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct RemoveArgs { /// The dependencies you want to remove. dependencies: Vec, diff --git a/crates/forge/bin/cmd/retry.rs b/crates/forge/bin/cmd/retry.rs index 4f9d979632361..8e536bb446603 100644 --- a/crates/forge/bin/cmd/retry.rs +++ b/crates/forge/bin/cmd/retry.rs @@ -9,7 +9,7 @@ pub const RETRY_CHECK_ON_VERIFY: RetryArgs = RetryArgs { retries: 8, delay: 15 } pub const RETRY_VERIFY_ON_CREATE: RetryArgs = RetryArgs { retries: 15, delay: 5 }; /// Retry arguments for contract verification. -#[derive(Debug, Clone, Copy, Parser)] +#[derive(Clone, Copy, Debug, Parser)] #[clap(about = "Allows to use retry arguments for contract verification")] // override doc pub struct RetryArgs { /// Number of attempts for retrying verification. diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index c6d5b9294d16a..e7dab664b2ebf 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -74,7 +74,7 @@ mod verify; foundry_config::merge_impl_figment_convert!(ScriptArgs, opts, evm_opts); /// CLI arguments for `forge script`. -#[derive(Debug, Clone, Parser, Default)] +#[derive(Clone, Debug, Default, Parser)] pub struct ScriptArgs { /// The contract you want to run. Either the file path or contract name. /// @@ -621,7 +621,7 @@ struct JsonResult { returns: HashMap, } -#[derive(Serialize, Deserialize, Clone)] +#[derive(Clone, Serialize, Deserialize)] pub struct NestedValue { pub internal_type: String, pub value: String, diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index a412ca4534265..fc94fc487642b 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -19,7 +19,7 @@ use std::{ }; /// Holds the sequences of multiple chain deployments. -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Clone, Default, Serialize, Deserialize)] pub struct MultiChainSequence { pub deployments: Vec, #[serde(skip)] @@ -30,7 +30,7 @@ pub struct MultiChainSequence { } /// Sensitive values from script sequences. -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Clone, Default, Serialize, Deserialize)] pub struct SensitiveMultiChainSequence { pub deployments: Vec, } diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 6b6eb4acacb8e..5056fa9ec2967 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -30,7 +30,7 @@ pub const DRY_RUN_DIR: &str = "dry-run"; /// Helper that saves the transactions sequence and its state on which transactions have been /// broadcasted -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Clone, Default, Serialize, Deserialize)] pub struct ScriptSequence { pub transactions: VecDeque, #[serde(serialize_with = "wrapper::serialize_receipts")] @@ -50,13 +50,13 @@ pub struct ScriptSequence { } /// Sensitive values from the transactions in a script sequence -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Clone, Default, Serialize, Deserialize)] pub struct SensitiveTransactionMetadata { pub rpc: Option, } /// Sensitive info from the script sequence which is saved into the cache folder -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Clone, Default, Serialize, Deserialize)] pub struct SensitiveScriptSequence { pub transactions: VecDeque, } diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index f010f1b90b410..f3af7470b62ee 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -13,7 +13,7 @@ use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder, use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; -#[derive(Debug, Deserialize, Serialize, Clone, Default)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct AdditionalContract { #[serde(rename = "transactionType")] @@ -23,7 +23,7 @@ pub struct AdditionalContract { pub init_code: Bytes, } -#[derive(Debug, Serialize, Deserialize, Clone, Default)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct TransactionWithMetadata { pub hash: Option, @@ -378,7 +378,7 @@ pub mod wrapper { // "Receipt" of an executed transaction: details of its execution. // copied from https://github.com/gakonst/ethers-rs - #[derive(Default, Clone, Serialize, Deserialize)] + #[derive(Clone, Default, Serialize, Deserialize)] pub struct WrappedTransactionReceipt { /// Transaction hash. #[serde(rename = "transactionHash")] diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 4b2d045c9ddfa..6bcb7dde34dde 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -13,7 +13,7 @@ use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, in use std::fs::canonicalize; /// CLI arguments for `forge selectors`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub enum SelectorsSubcommands { /// Check for selector collisions between contracts #[clap(visible_alias = "co")] diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index cee3a66e98328..bd657abe84386 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -27,7 +27,7 @@ pub static RE_BASIC_SNAPSHOT_ENTRY: Lazy = Lazy::new(|| { }); /// CLI arguments for `forge snapshot`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct SnapshotArgs { /// Output a diff against a pre-existing snapshot. /// @@ -124,7 +124,7 @@ impl SnapshotArgs { } // TODO implement pretty tables -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub enum Format { Table, } @@ -141,7 +141,7 @@ impl FromStr for Format { } /// Additional filters that can be applied on the test results -#[derive(Debug, Clone, Parser, Default)] +#[derive(Clone, Debug, Default, Parser)] struct SnapshotConfig { /// Sort results by gas used (ascending). #[clap(long)] @@ -197,7 +197,7 @@ impl SnapshotConfig { /// `(gas:? 40181)` for normal tests /// `(runs: 256, μ: 40181, ~: 40181)` for fuzz tests /// `(runs: 256, calls: 40181, reverts: 40181)` for invariant tests -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct SnapshotEntry { pub contract_name: String, pub signature: String, @@ -293,7 +293,7 @@ fn write_to_snapshot_file( } /// A Snapshot entry diff -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct SnapshotDiff { pub signature: String, pub source_gas_used: TestKindReport, diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index abed3d892e668..71abb41b0039e 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -165,7 +165,7 @@ impl fmt::Display for FilterArgs { } /// A filter that combines all command line arguments and the paths of the current projects -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ProjectPathsAwareFilter { args_filter: FilterArgs, paths: ProjectPathsConfig, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1def1c49d06d8..09d92fb41230f 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -47,7 +47,7 @@ pub use filter::FilterArgs; foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); /// CLI arguments for `forge test`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] #[clap(next_help_heading = "Test options")] pub struct TestArgs { /// Run a test in the debugger. @@ -582,7 +582,7 @@ impl Provider for TestArgs { } /// The result of a single test -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct Test { /// The identifier of the artifact/contract in the form of `:` diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index ccd260fd072d0..689d6e4442bdb 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -7,7 +7,7 @@ use foundry_compilers::{ }; /// CLI arguments for `forge tree`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct TreeArgs { /// Do not de-duplicate (repeats all shared dependencies) #[clap(long)] diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index 28b6429967473..37e5baccb6622 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -8,7 +8,7 @@ use foundry_config::{impl_figment_convert_basic, Config}; use std::path::PathBuf; /// CLI arguments for `forge update`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct UpdateArgs { /// The dependencies you want to update. dependencies: Vec, diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 64471ed3fe02c..f6e8a03c6df60 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -27,7 +27,7 @@ mod standard_json; pub static RE_BUILD_COMMIT: Lazy = Lazy::new(|| Regex::new(r"(?Pcommit\.[0-9,a-f]{8})").unwrap()); -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] #[non_exhaustive] pub struct EtherscanVerificationProvider { /// Memoized cached entry of the target contract diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 09f033ec76251..c0f58d6aef501 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -18,7 +18,7 @@ use provider::VerificationProvider; mod sourcify; /// Verification provider arguments -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct VerifierArgs { /// The contract verification provider to use. #[clap(long, help_heading = "Verifier options", default_value = "etherscan", value_enum)] @@ -36,7 +36,7 @@ impl Default for VerifierArgs { } /// CLI arguments for `forge verify`. -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct VerifyArgs { /// The address of the contract to verify. pub address: Address, @@ -179,7 +179,7 @@ impl VerifyArgs { } /// Check verification status arguments -#[derive(Debug, Clone, Parser)] +#[derive(Clone, Debug, Parser)] pub struct VerifyCheckArgs { /// The verification ID. /// diff --git a/crates/forge/bin/cmd/verify/provider.rs b/crates/forge/bin/cmd/verify/provider.rs index 08f4a65e2146e..d5721018dce84 100644 --- a/crates/forge/bin/cmd/verify/provider.rs +++ b/crates/forge/bin/cmd/verify/provider.rs @@ -55,7 +55,7 @@ impl fmt::Display for VerificationProviderType { } } -#[derive(clap::ValueEnum, Debug, Default, Clone, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq, Eq, clap::ValueEnum)] pub enum VerificationProviderType { #[default] Etherscan, diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index 3a4593c4e15d6..ef9f0635018e1 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -11,7 +11,7 @@ use std::{collections::HashMap, path::PathBuf}; pub static SOURCIFY_URL: &str = "https://sourcify.dev/server/"; /// The type that can verify a contract on `sourcify` -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] #[non_exhaustive] pub struct SourcifyVerificationProvider; @@ -184,7 +184,7 @@ metadata output can be enabled via `extra_output = ["metadata"]` in `foundry.tom } } -#[derive(Serialize, Debug)] +#[derive(Debug, Serialize)] pub struct SourcifyVerifyRequest { address: String, chain: String, @@ -193,12 +193,12 @@ pub struct SourcifyVerifyRequest { chosen_contract: Option, } -#[derive(Deserialize, Debug)] +#[derive(Debug, Deserialize)] pub struct SourcifyVerificationResponse { result: Vec, } -#[derive(Deserialize, Debug)] +#[derive(Debug, Deserialize)] pub struct SourcifyResponseElement { status: String, #[serde(rename = "storageTimestamp")] diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 8a9c9c983457f..fce58df37e710 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -15,7 +15,7 @@ use watchexec::{ Watchexec, }; -#[derive(Debug, Clone, Parser, Default)] +#[derive(Clone, Debug, Default, Parser)] #[clap(next_help_heading = "Watch options")] pub struct WatchArgs { /// Watch the given files or directories for changes. @@ -150,7 +150,7 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { Ok(()) } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] struct WatchTestState { /// the root directory of the project project_root: PathBuf, diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 2fb0ff46a34eb..411e7bdced514 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; /// Represents the gas report for a set of contracts. -#[derive(Default, Debug, Serialize, Deserialize)] +#[derive(Debug, Default, Serialize, Deserialize)] pub struct GasReport { /// Whether to report any contracts. report_any: bool, @@ -176,14 +176,14 @@ impl Display for GasReport { } } -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Default, Serialize, Deserialize)] pub struct ContractInfo { pub gas: U256, pub size: U256, pub functions: BTreeMap>, } -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Default, Serialize, Deserialize)] pub struct GasInfo { pub calls: Vec, pub min: U256, diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index a8e5b97604761..16343fc096558 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -30,7 +30,7 @@ pub use foundry_common::traits::TestFilter; pub use foundry_evm::*; /// Metadata on how to run fuzz/invariant tests -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] pub struct TestOptions { /// The base "fuzz" test configuration. To be used as a fallback in case /// no more specific configs are found for a given run. diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 59f73cda785df..c32cf41c88ff0 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -231,7 +231,7 @@ impl MultiContractRunner { } /// Builder used for instantiating the multi-contract runner -#[derive(Debug, Default, Clone)] +#[derive(Clone, Debug, Default)] pub struct MultiContractRunnerBuilder { /// The address which will be used to deploy the initial contracts and send all /// transactions diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 604fbb6983026..b1fccc87e0bde 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -19,7 +19,7 @@ use std::{ use yansi::Paint; /// Results and duration for a set of tests included in the same test contract -#[derive(Debug, Clone, Serialize)] +#[derive(Clone, Debug, Serialize)] pub struct SuiteResult { /// Total duration of the test run for this block of tests pub duration: Duration, @@ -180,7 +180,7 @@ impl TestResult { } /// Data report by a test. -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum TestKindReport { Standard { gas: u64 }, Fuzz { runs: usize, mean_gas: u64, median_gas: u64 }, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 389d22913e4fb..0308fd218e191 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -32,7 +32,7 @@ use std::{ }; /// A type that executes all tests of a contract -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ContractRunner<'a> { pub name: &'a str, /// The executor used by the runner. diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index dedbc589901f6..e90a02d5e5442 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -168,7 +168,7 @@ pub fn setup_forge_project(test: TestProject) -> (TestProject, TestCommand) { } /// How to initialize a remote git project -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct RemoteProject { id: String, run_build: bool, From 67ab8704476d55e47545cf6217e236553c427a80 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 24 Dec 2023 23:24:43 +0200 Subject: [PATCH 0428/1963] docs: remove forge-std PR requirement for new cheatcodes (#6662) --- docs/dev/cheatcodes.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index 43521f596d7cc..67e11c415e78e 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -165,11 +165,9 @@ update of the files. 3. If a struct, enum, error, or event was added to `Vm`, update [`spec::Cheatcodes::new`] 4. Update the JSON interface by running `cargo cheats` twice. This is expected to fail the first time that this is run after adding a new cheatcode; see [JSON interface](#json-interface) 5. Write an integration test for the cheatcode in [`testdata/cheats/`] -6. Submit a PR to [`forge-std`] updating the Solidity interfaces as necessary. Note that this step won't be necessary once the Solidity interfaces are generated using the JSON interface [`sol!`]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html [`cheatcodes/spec/src/vm.rs`]: ../../crates/cheatcodes/spec/src/vm.rs [`cheatcodes`]: ../../crates/cheatcodes/ [`spec::Cheatcodes::new`]: ../../crates/cheatcodes/spec/src/lib.rs#L74 [`testdata/cheats/`]: ../../testdata/cheats/ -[`forge-std`]: https://github.com/foundry-rs/forge-std From 6d7cceafdcbdb5e48c128a5b32cb7267498f4674 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 29 Dec 2023 11:44:56 +0100 Subject: [PATCH 0429/1963] chore: bump foundry-compilers (#6682) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5753f2fef9fc..4b8fcd5678063 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2760,9 +2760,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eec9fd9df7ad0509ae45e2ea8a595cf13b1f35d69980e985b3be00ffabcc01a" +checksum = "d82d3c3ef0ea3749b6e873c3f24e8bf6ead058757fa793de8940c03fc01bb83b" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index ba2c45fff1dfb..55a6e42e0bc67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,7 +124,7 @@ foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } foundry-block-explorers = { version = "0.1.2", default-features = false } -foundry-compilers = { version = "0.1.1", default-features = false } +foundry-compilers = { version = "0.1.2", default-features = false } ## revm # no default features to avoid c-kzg From 2bcb4a1aded22c7f5c1263462acb6c75409dabeb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 31 Dec 2023 07:06:35 +0100 Subject: [PATCH 0430/1963] chore(deps): weekly `cargo update` (#6687) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating ahash v0.8.6 -> v0.8.7 Updating alloy-chains v0.1.6 -> v0.1.7 Updating alloy-dyn-abi v0.5.3 -> v0.5.4 Updating alloy-json-abi v0.5.3 -> v0.5.4 Updating alloy-primitives v0.5.3 -> v0.5.4 Updating alloy-sol-macro v0.5.3 -> v0.5.4 Updating alloy-sol-type-parser v0.5.3 -> v0.5.4 Updating alloy-sol-types v0.5.3 -> v0.5.4 Updating anyhow v1.0.76 -> v1.0.78 Updating async-trait v0.1.75 -> v0.1.76 Updating bstr v1.8.0 -> v1.9.0 Updating cargo-platform v0.1.5 -> v0.1.6 Updating clap v4.4.11 -> v4.4.12 Updating clap_builder v4.4.11 -> v4.4.12 Updating clap_complete v4.4.4 -> v4.4.5 Updating crossbeam-channel v0.5.9 -> v0.5.10 Updating crossbeam-epoch v0.9.16 -> v0.9.17 Updating crossbeam-utils v0.8.17 -> v0.8.18 Updating deranged v0.3.10 -> v0.3.11 Updating fd-lock v4.0.1 -> v4.0.2 Updating futures v0.3.29 -> v0.3.30 Updating futures-channel v0.3.29 -> v0.3.30 Updating futures-core v0.3.29 -> v0.3.30 Updating futures-executor v0.3.29 -> v0.3.30 Updating futures-io v0.3.29 -> v0.3.30 Updating futures-macro v0.3.29 -> v0.3.30 Updating futures-sink v0.3.29 -> v0.3.30 Updating futures-task v0.3.29 -> v0.3.30 Updating futures-util v0.3.29 -> v0.3.30 Updating gix-trace v0.1.4 -> v0.1.6 Updating gix-utils v0.1.6 -> v0.1.8 Updating iana-time-zone v0.1.58 -> v0.1.59 Updating is-terminal v0.4.9 -> v0.4.10 Adding keccak-asm v0.1.0 Updating memchr v2.6.4 -> v2.7.1 Removing memoffset v0.9.0 Updating object v0.32.1 -> v0.32.2 Updating schannel v0.1.22 -> v0.1.23 Adding sha3-asm v0.1.0 Updating similar v2.3.0 -> v2.4.0 Updating syn v2.0.42 -> v2.0.43 Updating syn-solidity v0.5.3 -> v0.5.4 Updating tempfile v3.8.1 -> v3.9.0 Updating thiserror v1.0.51 -> v1.0.53 Updating thiserror-impl v1.0.51 -> v1.0.53 Updating windows-core v0.51.1 -> v0.52.0 Updating winnow v0.5.30 -> v0.5.31 Co-authored-by: mattsse --- Cargo.lock | 291 +++++++++++++++++++++++++++-------------------------- 1 file changed, 151 insertions(+), 140 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b8fcd5678063..359bd11bd7b89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "once_cell", @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a33ec1fdb68c347fdab62e1194c059a00143d97401b32aaa420ecbe4c2fbed" +checksum = "aa1873637aa7f20369eae38b312cf7550c266d13ebc60f176fd5c82c5127810b" dependencies = [ "num_enum", "serde", @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74ab9cc043cd4b0a806f79e32624c148efecd9c9395e4a75000d51fdc9726be0" +checksum = "7cb9c4b008d0004a0518ba69f3cd9e94795f3c23b71a80e1ef3bf499f67fba23" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf8889c85658aae27e96515ff2c9200cb8d8c78baefad5aee088e49b47f5f6f3" +checksum = "838228983f74f30e4efbd8d42d25bfe1b5bf6450ca71ee9d7628f134fbe8ae8e" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -122,9 +122,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c0e5e60ff0e0c34c553822dabcfe0f5fece5a8c52f08a915be8c737de4b03fa" +checksum = "9c234f92024707f224510ff82419b2be0e1d8e1fd911defcac5a085cd7f83898" dependencies = [ "alloy-rlp", "arbitrary", @@ -137,6 +137,7 @@ dependencies = [ "getrandom 0.2.11", "hex-literal", "itoa", + "keccak-asm", "proptest", "proptest-derive", "rand 0.8.5", @@ -164,14 +165,14 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] name = "alloy-sol-macro" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8c9d43ca0a56b356f35775deecc8f660ac99e34cbf4a33462d4bd8addd9ab6f" +checksum = "970e5cf1ca089e964d4f7f7afc7c9ad642bfb1bdc695a20b0cba3b3c28954774" dependencies = [ "alloy-json-abi", "const-hex", @@ -182,25 +183,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.42", + "syn 2.0.43", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-type-parser" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cdf1064e9b5160ae47b5190171a0655c8b4966b9657b04f48ff5d868684ade" +checksum = "c82c1ed2d61e982cef4c4d709f4aeef5f39a6a6a7c59b6e54c9ed4f3f7e3741b" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c169266a4b5ecf6f471947be10690f0aa295063774853b50540708b267a96e51" +checksum = "2a059d4d2c78f8f21e470772c75f9abd9ac6d48c2aaf6b278d1ead06ed9ac664" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -398,9 +399,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59d2a3357dde987206219e78ecfbbb6e8dad06cbb65292758d3270e6254f7355" +checksum = "ca87830a3e3fb156dc96cfbd31cb620265dd053be734723f22b760d6cc3c3051" [[package]] name = "arbitrary" @@ -574,18 +575,18 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] name = "async-trait" -version = "0.1.75" +version = "0.1.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" +checksum = "531b97fb4cd3dfdce92c35dedbfdc1f0b9d8091c8ca943d6dae340ef5012d514" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -758,7 +759,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.42", + "syn 2.0.43", "which", ] @@ -848,9 +849,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" +checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" dependencies = [ "memchr", "regex-automata 0.4.3", @@ -952,9 +953,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" +checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" dependencies = [ "serde", ] @@ -1159,9 +1160,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" dependencies = [ "clap_builder", "clap_derive", @@ -1169,9 +1170,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" dependencies = [ "anstream", "anstyle", @@ -1184,9 +1185,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.4" +version = "4.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae" +checksum = "a51919c5608a32e34ea1d6be321ad070065e17613e168c5b6977024290f2630b" dependencies = [ "clap", ] @@ -1210,7 +1211,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -1517,9 +1518,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c3242926edf34aec4ac3a77108ad4854bffaa2e4ddc1824124ce59231302d5" +checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1538,21 +1539,20 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.16" +version = "0.9.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" +checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", ] [[package]] name = "crossbeam-utils" -version = "0.8.17" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ "cfg-if", ] @@ -1670,9 +1670,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", ] @@ -1696,7 +1696,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -1937,7 +1937,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -2135,7 +2135,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.42", + "syn 2.0.43", "toml 0.8.8", "walkdir", ] @@ -2152,7 +2152,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -2177,7 +2177,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.42", + "syn 2.0.43", "tempfile", "thiserror", "tiny-keccak", @@ -2380,7 +2380,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -2396,9 +2396,9 @@ dependencies = [ [[package]] name = "fd-lock" -version = "4.0.1" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93f7a0db71c99f68398f80653ed05afb0b00e062e1a20c7ff849c4edfabbbcc" +checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", "rustix", @@ -2984,7 +2984,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -2995,7 +2995,7 @@ dependencies = [ "ethers-core", "ethers-providers", "eyre", - "fd-lock 4.0.1", + "fd-lock 4.0.2", "foundry-common", "foundry-compilers", "foundry-config", @@ -3052,9 +3052,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -3067,9 +3067,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -3077,15 +3077,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -3094,9 +3094,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-locks" @@ -3110,26 +3110,26 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -3143,9 +3143,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -3416,15 +3416,15 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b686a35799b53a9825575ca3f06481d0a053a409c4d97ffcf5ddd67a8760b497" +checksum = "e8e1127ede0475b58f4fe9c0aaa0d9bb0bad2af90bbd93ccd307c8632b863d89" [[package]] name = "gix-utils" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f82c41937f00e15a1f6cb0b55307f0ca1f77f4407ff2bf440be35aa688c6a3e" +checksum = "de6225e2de30b6e9bca2d9f1cc4731640fcef0fb3cabddceee366e7e85d3e94f" dependencies = [ "fastrand", ] @@ -3550,7 +3550,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.7", "allocator-api2", "serde", ] @@ -3759,9 +3759,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3949,13 +3949,13 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ "hermit-abi", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -4048,6 +4048,16 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keccak-asm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb8515fff80ed850aea4a1595f2e519c003e2a00a82fe168ebf5269196caf444" +dependencies = [ + "digest 0.10.7", + "sha3-asm", +] + [[package]] name = "keccak-hasher" version = "0.15.3" @@ -4315,9 +4325,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmap2" @@ -4346,15 +4356,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "memory-db" version = "0.29.0" @@ -4386,7 +4387,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -4474,7 +4475,7 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", - "memoffset 0.7.1", + "memoffset", "pin-utils", ] @@ -4647,7 +4648,7 @@ dependencies = [ "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -4667,9 +4668,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -4751,7 +4752,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -4958,7 +4959,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -5013,7 +5014,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -5116,7 +5117,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -5154,7 +5155,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -5254,7 +5255,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -5331,7 +5332,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", "version_check", "yansi 1.0.0-rc.1", ] @@ -6150,11 +6151,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -6320,7 +6321,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -6374,7 +6375,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -6420,7 +6421,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -6474,6 +6475,16 @@ dependencies = [ "keccak", ] +[[package]] +name = "sha3-asm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac61da6b35ad76b195eb4771210f947734321a8d81d7738e1580d953bc7a15e" +dependencies = [ + "cc", + "cfg-if", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -6537,9 +6548,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" +checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" [[package]] name = "simple_asn1" @@ -6683,7 +6694,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -6751,9 +6762,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.42" +version = "2.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" +checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" dependencies = [ "proc-macro2", "quote", @@ -6762,14 +6773,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4e95b65f5854377a31ebfa69d71b87c9d0d9922fddbfeb91a8eda4a0c5868eb" +checksum = "91ede2e5b2c6bfac4bc0ff4499957a11725dc12a7ddb86270e827ef575892553" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -6819,15 +6830,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand", "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -6886,22 +6897,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.51" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" +checksum = "b2cd5904763bad08ad5513ddbb12cf2ae273ca53fa9f68e843e236ec6dfccc09" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.51" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" +checksum = "3dcf4a824cce0aeacd6f38ae6f24234c8e80d68632338ebaa1443b5df9e29e19" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -7015,7 +7026,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -7236,7 +7247,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -7602,7 +7613,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", "wasm-bindgen-shared", ] @@ -7636,7 +7647,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7775,11 +7786,11 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -7982,9 +7993,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.30" +version = "0.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" +checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" dependencies = [ "memchr", ] @@ -8062,7 +8073,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] @@ -8082,7 +8093,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.43", ] [[package]] From 0f20cc609b04b9b086122d85e0994c820105a47c Mon Sep 17 00:00:00 2001 From: yanziseeker <153156292+AdventureSeeker987@users.noreply.github.com> Date: Tue, 2 Jan 2024 20:28:43 +0800 Subject: [PATCH 0431/1963] docs(crates/config): correct README.md link path (#6693) --- crates/config/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/README.md b/crates/config/README.md index 6e4667293cf5b..5308cdfab3412 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -56,7 +56,7 @@ The selected profile is the value of the `FOUNDRY_PROFILE` environment variable, ### All Options -The following is a foundry.toml file with all configuration options set. See also [/config/src/lib.rs](/config/src/lib.rs) and [/cli/tests/it/config.rs](/cli/tests/it/config.rs). +The following is a foundry.toml file with all configuration options set. See also [/config/src/lib.rs](./src/lib.rs) and [/cli/tests/it/config.rs](../forge/tests/it/config.rs). ```toml ## defaults for _all_ profiles From e575ec7ff9285eb9c7d7382418548d5b85b4c9a5 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 3 Jan 2024 11:22:04 -0400 Subject: [PATCH 0432/1963] fix(cheatcodes): always omit pk on addr (#6698) --- crates/evm/traces/src/decoder/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index c13ce494a1a8e..e37880249e74e 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -357,7 +357,7 @@ impl CallTraceDecoder { fn decode_cheatcode_inputs(&self, func: &Function, data: &[u8]) -> Option> { match func.name.as_str() { "expectRevert" => Some(vec![decode::decode_revert(data, Some(&self.errors), None)]), - "rememberKey" | "addr" | "startBroadcast" | "broadcast" => { + "rememberKey" | "startBroadcast" | "broadcast" => { // these functions accept a private key as uint256, which should not be // converted to plain text if !func.inputs.is_empty() && func.inputs[0].ty != "uint256" { @@ -375,6 +375,7 @@ impl CallTraceDecoder { } Some(decoded.iter().map(format_token).collect()) } + "addr" => Some(vec!["".to_string()]), "deriveKey" => Some(vec!["".to_string()]), "parseJson" | "parseJsonUint" | From 551195e96d1c3fac9bffca959d9b516608549c37 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 3 Jan 2024 17:05:39 +0100 Subject: [PATCH 0433/1963] chore: more chisel debug and print compile error (#6647) * chore: more chisel debug and print compile error * rustfmt --- Cargo.lock | 1 + crates/chisel/Cargo.toml | 1 + crates/chisel/bin/main.rs | 10 ++++++-- crates/chisel/src/dispatcher.rs | 11 +++++++-- crates/chisel/src/executor.rs | 43 ++++++++++++++++++++++----------- 5 files changed, 48 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 359bd11bd7b89..c17749a2c7a3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1093,6 +1093,7 @@ dependencies = [ "strum", "time", "tokio", + "tracing", "vergen", "yansi 0.5.1", ] diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 92048950cb1a3..d70473ffe7cfc 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -48,6 +48,7 @@ strum = { version = "0.25", features = ["derive"] } time = { version = "0.3", features = ["formatting"] } tokio = { version = "1", features = ["full"] } yansi = "0.5" +tracing.workspace = true [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 2bea10e82fcd5..6b94eecb498f0 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -24,6 +24,7 @@ use foundry_config::{ }; use rustyline::{config::Configurer, error::ReadlineError, Editor}; use std::path::PathBuf; +use tracing::debug; use yansi::Paint; // Loads project's figment and merges the build cli arguments into it @@ -180,6 +181,7 @@ async fn main() -> eyre::Result<()> { // Get the prompt from the dispatcher // Variable based on status of the last entry let prompt = dispatcher.get_prompt(); + rl.helper_mut().unwrap().set_errored(dispatcher.errored); // Read the next line @@ -188,6 +190,7 @@ async fn main() -> eyre::Result<()> { // Try to read the string match next_string { Ok(line) => { + debug!("dispatching next line: {line}"); // Clear interrupt flag interrupt = false; @@ -231,8 +234,11 @@ impl Provider for ChiselParser { /// Evaluate a single Solidity line. async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) { match dispatcher.dispatch(line).await { - DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => if let Some(msg) = msg { - println!("{}", Paint::green(msg)); + DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => { + debug!(%line, ?msg, "dispatch success"); + if let Some(msg) = msg { + println!("{}", Paint::green(msg)); + } }, DispatchResult::UnrecognizedCommand(e) => eprintln!("{e}"), DispatchResult::SolangParserFailed(e) => { diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index b191d8dccad3e..872e579f4104e 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -25,6 +25,7 @@ use serde::{Deserialize, Serialize}; use solang_parser::diagnostics::Diagnostic; use std::{borrow::Cow, error::Error, io::Write, path::PathBuf, process::Command}; use strum::IntoEnumIterator; +use tracing::debug; use yansi::Paint; /// Prompt arrow character @@ -807,6 +808,7 @@ impl ChiselDispatcher { } } if input.trim().is_empty() { + debug!("empty dispatch input"); return DispatchResult::Success(None) } @@ -822,6 +824,7 @@ impl ChiselDispatcher { // If the input is a comment, add it to the run code so we avoid running with empty input if COMMENT_RE.is_match(input) { + debug!(%input, "matched comment"); source.with_run_code(input); return DispatchResult::Success(None) } @@ -858,7 +861,10 @@ impl ChiselDispatcher { Ok((true, Some(res))) => println!("{res}"), Ok((true, None)) => {} // Return successfully - Ok((false, res)) => return DispatchResult::Success(res), + Ok((false, res)) => { + debug!(%input, ?res, "inspect success"); + return DispatchResult::Success(res) + } // Return with the error Err(e) => { @@ -915,7 +921,8 @@ impl ChiselDispatcher { } } else { match new_source.build() { - Ok(_) => { + Ok(out) => { + debug!(%input, ?out, "skipped execute and rebuild source"); self.session.session_source = Some(new_source); self.errored = false; DispatchResult::Success(None) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 9fc65c055bc36..f287bc5bdf212 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -18,6 +18,7 @@ use foundry_evm::{ }; use solang_parser::pt::{self, CodeLocation}; use std::str::FromStr; +use tracing::debug; use yansi::Paint; const USIZE_MAX_AS_U256: U256 = U256::from_limbs([usize::MAX as u64, 0, 0, 0]); @@ -30,6 +31,8 @@ impl SessionSource { /// /// Optionally, a tuple containing the [Address] of the deployed REPL contract as well as /// the [ChiselResult]. + /// + /// Returns an error if compilation fails. pub async fn execute(&mut self) -> Result<(Address, ChiselResult)> { // Recompile the project and ensure no errors occurred. let compiled = self.build()?; @@ -125,35 +128,41 @@ impl SessionSource { /// /// ### Returns /// - /// If the input is valid `Ok((formatted_output, continue))` where: + /// If the input is valid `Ok((continue, formatted_output))` where: /// - `continue` is true if the input should be appended to the source - /// - `formatted_output` is the formatted value + /// - `formatted_output` is the formatted value, if any pub async fn inspect(&self, input: &str) -> Result<(bool, Option)> { let line = format!("bytes memory inspectoor = abi.encode({input});"); - let mut source = match self.clone_with_new_line(line) { + let mut source = match self.clone_with_new_line(line.clone()) { Ok((source, _)) => source, - Err(_) => return Ok((true, None)), + Err(err) => { + debug!(%err, "failed to build new source"); + return Ok((true, None)) + } }; let mut source_without_inspector = self.clone(); // Events and tuples fails compilation due to it not being able to be encoded in // `inspectoor`. If that happens, try executing without the inspector. - let (mut res, has_inspector) = match source.execute().await { - Ok((_, res)) => (res, true), - Err(e) => match source_without_inspector.execute().await { - Ok((_, res)) => (res, false), - Err(_) => { - if self.config.foundry_config.verbosity >= 3 { - eprintln!("Could not inspect: {e}"); + let (mut res, err) = match source.execute().await { + Ok((_, res)) => (res, None), + Err(err) => { + debug!(?err, %input, "execution failed"); + match source_without_inspector.execute().await { + Ok((_, res)) => (res, Some(err)), + Err(_) => { + if self.config.foundry_config.verbosity >= 3 { + eprintln!("Could not inspect: {err}"); + } + return Ok((true, None)) } - return Ok((true, None)) } - }, + } }; // If abi-encoding the input failed, check whether it is an event - if !has_inspector { + if let Some(err) = err { let generated_output = source_without_inspector .generated_output .as_ref() @@ -170,6 +179,12 @@ impl SessionSource { return Ok((false, Some(formatted))) } + // we were unable to check the event + if self.config.foundry_config.verbosity >= 3 { + eprintln!("Failed eval: {err}"); + } + + debug!(%err, %input, "failed abi encode input"); return Ok((false, None)) } From 47b3695a6a7f7eeffea0c4e2f933c7deacba6894 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 3 Jan 2024 16:32:25 -0400 Subject: [PATCH 0434/1963] chore(cheatcodes): mark getLabel as view (#6700) --- crates/cheatcodes/assets/cheatcodes.json | 4 ++-- crates/cheatcodes/spec/src/vm.rs | 2 +- testdata/cheats/Vm.sol | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index de243861068a8..d877ecf98ef65 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2257,9 +2257,9 @@ "func": { "id": "getLabel", "description": "Gets the label for the specified address.", - "declaration": "function getLabel(address account) external returns (string memory currentLabel);", + "declaration": "function getLabel(address account) external view returns (string memory currentLabel);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "getLabel(address)", "selector": "0x28a249b0", "selectorBytes": [ diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 99d81137a9141..07e6cb5355c11 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1288,7 +1288,7 @@ interface Vm { /// Gets the label for the specified address. #[cheatcode(group = Utilities)] - function getLabel(address account) external returns (string memory currentLabel); + function getLabel(address account) external view returns (string memory currentLabel); /// Compute the address a contract will be deployed at for a given deployer address and nonce. #[cheatcode(group = Utilities)] diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 3bfc15665a07d..12b22b8f30f81 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -110,7 +110,7 @@ interface Vm { function getBlockTimestamp() external view returns (uint256 timestamp); function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); - function getLabel(address account) external returns (string memory currentLabel); + 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 getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length); function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value); From 9e3ab9b3aff21c6e5ef8b7290df1ad079a24ab6e Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 3 Jan 2024 19:56:03 -0400 Subject: [PATCH 0435/1963] chore: fix some docs (#6701) --- crates/evm/core/src/backend/in_memory_db.rs | 12 +++++++++--- crates/evm/core/src/backend/mod.rs | 12 ++++++------ crates/evm/evm/src/executors/mod.rs | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index b27bbe750cc7c..3b19d0fce00f1 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -84,9 +84,12 @@ impl DatabaseCommit for MemDb { /// `DbAccount`, this will be set to `AccountState::NotExisting` if the account does not exist yet. /// This is because there's a distinction between "non-existing" and "empty", /// see . -/// If an account is `NotExisting`, `Database(Ref)::basic` will always return `None` for the -/// requested `AccountInfo`. To prevent this, we ensure that a missing account is never marked as -/// `NotExisting` by always returning `Some` with this type. +/// If an account is `NotExisting`, `Database::basic_ref` will always return `None` for the +/// requested `AccountInfo`. +/// +/// To prevent this, we ensure that a missing account is never marked as `NotExisting` by always +/// returning `Some` with this type, which will then insert a default [`AccountInfo`] instead +/// of one marked as `AccountState::NotExisting`. #[derive(Clone, Debug, Default)] pub struct EmptyDBWrapper(EmptyDB); @@ -143,6 +146,7 @@ mod tests { let mut db = CacheDB::new(EmptyDB::default()); let address = Address::random(); + // We use `basic_ref` here to ensure that the account is not marked as `NotExisting`. let info = DatabaseRef::basic_ref(&db, address).unwrap(); assert!(info.is_none()); let mut info = info.unwrap_or_default(); @@ -165,6 +169,8 @@ mod tests { )); let info = Database::basic(&mut db, address).unwrap(); + // We know info exists, as MemDb always returns `Some(AccountInfo)` due to the + // `EmptyDbWrapper`. assert!(info.is_some()); let mut info = info.unwrap(); info.balance = U256::from(500u64); diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 35a56371680c4..3ba7dea53ef1c 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -69,8 +69,8 @@ pub trait DatabaseExt: Database { /// Creates a new snapshot at the current point of execution. /// /// A snapshot is associated with a new unique id that's created for the snapshot. - /// Snapshots can be reverted: [DatabaseExt::revert], however a snapshot can only be reverted - /// once. After a successful revert, the same snapshot id cannot be used again. + /// Snapshots can be reverted: [DatabaseExt::revert], however, depending on the + /// [RevertSnapshotAction], it will keep the snapshot alive or delete it. fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256; /// Reverts the snapshot if it exists @@ -204,21 +204,21 @@ pub trait DatabaseExt: Database { /// Returns the Fork url that's currently used in the database, if fork mode is on fn active_fork_url(&self) -> Option; - /// Whether the database is currently in forked + /// Whether the database is currently in forked mode. fn is_forked_mode(&self) -> bool { self.active_fork_id().is_some() } - /// Ensures that an appropriate fork exits + /// Ensures that an appropriate fork exists /// - /// If `id` contains a requested `Fork` this will ensure it exits. + /// If `id` contains a requested `Fork` this will ensure it exists. /// Otherwise, this returns the currently active fork. /// /// # Errors /// /// Returns an error if the given `id` does not match any forks /// - /// Returns an error if no fork exits + /// Returns an error if no fork exists fn ensure_fork(&self, id: Option) -> eyre::Result; /// Ensures that a corresponding `ForkId` exists for the given local `id` diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 05838560bdb0b..863de256d9760 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -2,7 +2,7 @@ //! //! Used for running tests, scripts, and interacting with the inner backend which holds the state. -// TODO: The individual executors in this module should be moved into the respective craits, and the +// TODO: The individual executors in this module should be moved into the respective crates, and the // `Executor` struct should be accessed using a trait defined in `foundry-evm-core` instead of // the concrete `Executor` type. From 4d033dad18fc2df29b04853ebf0b68fac0de2b7d Mon Sep 17 00:00:00 2001 From: cool-mestorf <141713461+cool-mestorf@users.noreply.github.com> Date: Fri, 5 Jan 2024 01:56:47 +0900 Subject: [PATCH 0436/1963] feat(cast/forge): add label addresses in foundry config (#6680) * add label section in config * use labeled addresses in `cast run` * use labeled addresses in `forge test` trace * use `labels` field as single source of state * fix test build --------- Co-authored-by: George Dent --- crates/cheatcodes/src/config.rs | 10 ++++++- crates/cheatcodes/src/inspector.rs | 39 +++++++++++++------------- crates/cli/src/utils/cmd.rs | 6 +++- crates/config/src/lib.rs | 39 ++++++++++++++++++++++++-- crates/evm/evm/src/inspectors/stack.rs | 14 ++++----- crates/forge/tests/cli/config.rs | 1 + 6 files changed, 79 insertions(+), 30 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index b3aff6b62ed82..85b2dcaab61f6 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -1,5 +1,6 @@ use super::Result; use crate::Vm::Rpc; +use alloy_primitives::Address; use foundry_common::fs::normalize_path; use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ @@ -7,7 +8,10 @@ use foundry_config::{ ResolvedRpcEndpoints, }; use foundry_evm_core::opts::EvmOpts; -use std::path::{Path, PathBuf}; +use std::{ + collections::HashMap, + path::{Path, PathBuf}, +}; /// Additional, configurable context the `Cheatcodes` inspector has access to /// @@ -30,6 +34,8 @@ pub struct CheatsConfig { pub allowed_paths: Vec, /// How the evm was configured by the user pub evm_opts: EvmOpts, + /// Address labels from config + pub labels: HashMap, } impl CheatsConfig { @@ -51,6 +57,7 @@ impl CheatsConfig { root: config.__root.0.clone(), allowed_paths, evm_opts, + labels: config.labels.clone(), } } @@ -164,6 +171,7 @@ impl Default for CheatsConfig { root: Default::default(), allowed_paths: vec![], evm_opts: Default::default(), + labels: Default::default(), } } } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index f139e47cd8c40..ffe224855543a 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -222,7 +222,8 @@ impl Cheatcodes { /// Creates a new `Cheatcodes` with the given settings. #[inline] pub fn new(config: Arc) -> Self { - Self { config, fs_commit: true, ..Default::default() } + let labels = config.labels.clone(); + Self { config, fs_commit: true, labels, ..Default::default() } } fn apply_cheatcode( @@ -262,7 +263,7 @@ impl Cheatcodes { if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { // we only grant cheat code access for new contracts if the caller also has // cheatcode access and the new contract is created in top most call - return created_address + return created_address; } data.db.allow_cheatcode_access(created_address); @@ -279,12 +280,12 @@ impl Cheatcodes { // Delay revert clean up until expected revert is handled, if set. if self.expected_revert.is_some() { - return + return; } // we only want to apply cleanup top level if data.journaled_state.depth() > 0 { - return + return; } // Roll back all previously applied deals @@ -722,11 +723,11 @@ impl Inspector for Cheatcodes { return match self.apply_cheatcode(data, call) { Ok(retdata) => (InstructionResult::Return, gas, retdata.into()), Err(err) => (InstructionResult::Revert, gas, err.abi_encode().into()), - } + }; } if call.contract == HARDHAT_CONSOLE_ADDRESS { - return (InstructionResult::Continue, gas, Bytes::new()) + return (InstructionResult::Continue, gas, Bytes::new()); } // Handle expected calls @@ -769,7 +770,7 @@ impl Inspector for Cheatcodes { }) .map(|(_, v)| v) }) { - return (return_data.ret_type, gas, return_data.data.clone()) + return (return_data.ret_type, gas, return_data.data.clone()); } } @@ -826,7 +827,7 @@ impl Inspector for Cheatcodes { if let Err(err) = data.journaled_state.load_account(broadcast.new_origin, data.db) { - return (InstructionResult::Revert, gas, Error::encode(err)) + return (InstructionResult::Revert, gas, Error::encode(err)); } let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); @@ -857,7 +858,7 @@ impl Inspector for Cheatcodes { debug!(target: "cheatcodes", address=%broadcast.new_origin, nonce=prev+1, prev, "incremented nonce"); } else if broadcast.single_call { let msg = "`staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead"; - return (InstructionResult::Revert, Gas::new(0), Error::encode(msg)) + return (InstructionResult::Revert, Gas::new(0), Error::encode(msg)); } } } @@ -920,7 +921,7 @@ impl Inspector for Cheatcodes { retdata: Bytes, ) -> (InstructionResult, Gas, Bytes) { if call.contract == CHEATCODE_ADDRESS || call.contract == HARDHAT_CONSOLE_ADDRESS { - return (status, remaining_gas, retdata) + return (status, remaining_gas, retdata); } if data.journaled_state.depth() == 0 && self.skip { @@ -928,7 +929,7 @@ impl Inspector for Cheatcodes { InstructionResult::Revert, remaining_gas, super::Error::from(MAGIC_SKIP).abi_encode().into(), - ) + ); } // Clean up pranks @@ -970,7 +971,7 @@ impl Inspector for Cheatcodes { (InstructionResult::Revert, remaining_gas, error.abi_encode().into()) } Ok((_, retdata)) => (InstructionResult::Return, remaining_gas, retdata), - } + }; } } @@ -1039,7 +1040,7 @@ impl Inspector for Cheatcodes { InstructionResult::Revert, remaining_gas, "log != expected log".abi_encode().into(), - ) + ); } else { // All emits were found, we're good. // Clear the queue, as we expect the user to declare more events for the next call @@ -1056,7 +1057,7 @@ impl Inspector for Cheatcodes { // return a better error here if status == InstructionResult::Revert { if let Some(err) = diag { - return (status, remaining_gas, Error::encode(err.to_error_msg(&self.labels))) + return (status, remaining_gas, Error::encode(err.to_error_msg(&self.labels))); } } @@ -1080,7 +1081,7 @@ impl Inspector for Cheatcodes { // earlier error that happened first with unrelated information about // another error when using cheatcodes. if status == InstructionResult::Revert { - return (status, remaining_gas, retdata) + return (status, remaining_gas, retdata); } // If there's not a revert, we can continue on to run the last logic for expect* @@ -1125,7 +1126,7 @@ impl Inspector for Cheatcodes { "expected call to {address} with {expected_values} \ to be called {count} time{s}, but {but}" ); - return (InstructionResult::Revert, remaining_gas, Error::encode(msg)) + return (InstructionResult::Revert, remaining_gas, Error::encode(msg)); } } } @@ -1142,7 +1143,7 @@ impl Inspector for Cheatcodes { "expected an emit, but the call reverted instead. \ ensure you're testing the happy path when using `expectEmit`" }; - return (InstructionResult::Revert, remaining_gas, Error::encode(msg)) + return (InstructionResult::Revert, remaining_gas, Error::encode(msg)); } } @@ -1177,7 +1178,7 @@ impl Inspector for Cheatcodes { call.caller == broadcast.original_caller { if let Err(err) = data.journaled_state.load_account(broadcast.new_origin, data.db) { - return (InstructionResult::Revert, None, gas, Error::encode(err)) + return (InstructionResult::Revert, None, gas, Error::encode(err)); } data.env.tx.caller = broadcast.new_origin; @@ -1304,7 +1305,7 @@ impl Inspector for Cheatcodes { Err(err) => { (InstructionResult::Revert, None, remaining_gas, err.abi_encode().into()) } - } + }; } } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index e0e11d21a51fc..6d100cb15d089 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -390,8 +390,12 @@ pub async fn handle_traces( None }); + let labeled_addresses_in_config = config.labels.clone().into_iter(); + + let concatenated_addresses = labeled_addresses.chain(labeled_addresses_in_config); + let mut decoder = CallTraceDecoderBuilder::new() - .with_labels(labeled_addresses) + .with_labels(concatenated_addresses) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), config.offline, diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index c5fccf3296ab9..d20eae044de45 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -369,6 +369,9 @@ pub struct Config { /// Should be removed once EvmVersion Cancun is supported by solc pub cancun: bool, + /// Address labels + pub labels: HashMap, + /// The root path where the config detection started from, `Config::with_root` #[doc(hidden)] // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] @@ -411,7 +414,7 @@ impl Config { /// Standalone sections in the config which get integrated into the selected profile pub const STANDALONE_SECTIONS: &'static [&'static str] = - &["rpc_endpoints", "etherscan", "fmt", "doc", "fuzz", "invariant"]; + &["rpc_endpoints", "etherscan", "fmt", "doc", "fuzz", "invariant", "labels"]; /// File name of config toml file pub const FILE_NAME: &'static str = "foundry.toml"; @@ -1831,6 +1834,7 @@ impl Default for Config { build_info_path: None, fmt: Default::default(), doc: Default::default(), + labels: Default::default(), __non_exhaustive: (), __warnings: vec![], } @@ -4432,7 +4436,7 @@ mod tests { "foundry.toml", r" [default] - [profile.default.optimizer_details] + [profile.default.optimizer_details] ", )?; @@ -4442,4 +4446,35 @@ mod tests { Ok(()) }); } + + #[test] + fn test_parse_labels() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [labels] + 0x1F98431c8aD98523631AE4a59f267346ea31F984 = "Uniswap V3: Factory" + 0xC36442b4a4522E871399CD717aBDD847Ab11FE88 = "Uniswap V3: Positions NFT" + "#, + )?; + + let config = Config::load(); + assert_eq!( + config.labels, + HashMap::from_iter(vec![ + ( + Address::from_str("0x1F98431c8aD98523631AE4a59f267346ea31F984").unwrap(), + "Uniswap V3: Factory".to_string() + ), + ( + Address::from_str("0xC36442b4a4522E871399CD717aBDD847Ab11FE88").unwrap(), + "Uniswap V3: Positions NFT".to_string() + ), + ]) + ); + + Ok(()) + }); + } } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 3cd5c1a2fea16..35e9e67736fd1 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -344,7 +344,7 @@ impl InspectorStack { if new_status != status || (new_status == InstructionResult::Revert && new_retdata != retdata) { - return (new_status, new_gas, new_retdata) + return (new_status, new_gas, new_retdata); } } ); @@ -371,7 +371,7 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if interpreter.instruction_result != res { #[allow(clippy::needless_return)] - return + return; } } ); @@ -395,7 +395,7 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if interpreter.instruction_result != res { #[allow(clippy::needless_return)] - return + return; } } ); @@ -433,7 +433,7 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if interpreter.instruction_result != res { #[allow(clippy::needless_return)] - return + return; } } ); @@ -460,7 +460,7 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early #[allow(clippy::needless_return)] if status != InstructionResult::Continue { - return (status, gas, retdata) + return (status, gas, retdata); } } ); @@ -509,7 +509,7 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if status != InstructionResult::Continue { - return (status, addr, gas, retdata) + return (status, addr, gas, retdata); } } ); @@ -546,7 +546,7 @@ impl Inspector for InspectorStack { ); if new_status != status { - return (new_status, new_address, new_gas, new_retdata) + return (new_status, new_address, new_gas, new_retdata); } } ); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 27001b7321720..f5c2387158bc5 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -111,6 +111,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { fmt: Default::default(), doc: Default::default(), fs_permissions: Default::default(), + labels: Default::default(), cancun: true, __non_exhaustive: (), __warnings: vec![], From 6fc74638b797b8e109452d3df8e26758f86f31fe Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 4 Jan 2024 21:04:25 +0100 Subject: [PATCH 0437/1963] refactor: rewrite compile functions to a common builder (#6702) * refactor: rewrite compile functions to a common builder * fixes * fixes2 * fix: format_json * fix: remaining tests * fix: ignore private doctest --- crates/cast/bin/cmd/access_list.rs | 1 - crates/cast/bin/cmd/call.rs | 1 - crates/cast/bin/cmd/storage.rs | 8 +- crates/cast/bin/cmd/wallet/mod.rs | 5 +- crates/cast/bin/main.rs | 2 +- crates/cast/bin/opts.rs | 17 +- crates/cast/src/base.rs | 10 +- crates/chisel/bin/main.rs | 2 +- crates/cli/src/handler.rs | 7 +- crates/cli/src/opts/wallet/mod.rs | 6 +- crates/cli/src/opts/wallet/multi_wallet.rs | 10 +- crates/common/src/clap_helpers.rs | 6 - crates/common/src/compile.rs | 393 ++++++++---------- crates/common/src/lib.rs | 1 - crates/common/src/selectors.rs | 5 +- crates/config/src/warning.rs | 45 +- crates/forge/bin/cmd/bind.rs | 9 +- crates/forge/bin/cmd/build.rs | 25 +- crates/forge/bin/cmd/create.rs | 11 +- crates/forge/bin/cmd/flatten.rs | 5 +- crates/forge/bin/cmd/inspect.rs | 125 +++--- crates/forge/bin/cmd/remappings.rs | 15 +- crates/forge/bin/cmd/script/build.rs | 8 +- crates/forge/bin/cmd/script/mod.rs | 7 +- crates/forge/bin/cmd/selectors.rs | 74 ++-- crates/forge/bin/cmd/test/mod.rs | 38 +- .../forge/bin/cmd/verify/etherscan/flatten.rs | 10 +- crates/forge/bin/cmd/verify/sourcify.rs | 51 ++- crates/forge/bin/main.rs | 2 +- crates/forge/bin/opts.rs | 17 +- crates/forge/tests/cli/config.rs | 6 +- 31 files changed, 394 insertions(+), 528 deletions(-) delete mode 100644 crates/common/src/clap_helpers.rs diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 28be54ee04fa7..fa31380ff14d5 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -33,7 +33,6 @@ pub struct AccessListArgs { #[clap( long, value_name = "DATA", - value_parser = foundry_common::clap_helpers::strip_0x_prefix, conflicts_with_all = &["sig", "args"] )] data: Option, diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index b5cc9e2b8a4b2..8217eeb9e1edc 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -34,7 +34,6 @@ pub struct CallArgs { /// Data for the transaction. #[clap( long, - value_parser = foundry_common::clap_helpers::strip_0x_prefix, conflicts_with_all = &["sig", "args"] )] data: Option, diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 293833fb42be3..da9451ccc8eff 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -13,7 +13,7 @@ use foundry_cli::{ }; use foundry_common::{ abi::find_source, - compile::{compile, etherscan_project, suppress_compile}, + compile::{etherscan_project, ProjectCompiler}, types::{ToAlloy, ToEthers}, RetryProvider, }; @@ -100,7 +100,7 @@ impl StorageArgs { if project.paths.has_input_files() { // Find in artifacts and pretty print add_storage_layout_output(&mut project); - let out = compile(&project, false, false)?; + let out = ProjectCompiler::new().compile(&project)?; let match_code = |artifact: &ConfigurableContractArtifact| -> Option { let bytes = artifact.deployed_bytecode.as_ref()?.bytecode.as_ref()?.object.as_bytes()?; @@ -146,7 +146,7 @@ impl StorageArgs { project.auto_detect = auto_detect; // Compile - let mut out = suppress_compile(&project)?; + let mut out = ProjectCompiler::new().quiet(true).compile(&project)?; let artifact = { let (_, mut artifact) = out .artifacts() @@ -159,7 +159,7 @@ impl StorageArgs { let solc = Solc::find_or_install_svm_version(MIN_SOLC.to_string())?; project.solc = solc; project.auto_detect = false; - if let Ok(output) = suppress_compile(&project) { + if let Ok(output) = ProjectCompiler::new().quiet(true).compile(&project) { out = output; let (_, new_artifact) = out .artifacts() diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index b4cec44e0879f..9a1253d42deeb 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -72,10 +72,7 @@ pub enum WalletSubcommands { #[clap(visible_aliases = &["a", "addr"])] Address { /// If provided, the address will be derived from the specified private key. - #[clap( - value_name = "PRIVATE_KEY", - value_parser = foundry_common::clap_helpers::strip_0x_prefix, - )] + #[clap(value_name = "PRIVATE_KEY")] private_key_override: Option, #[clap(flatten)] diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 5ceea192a0b54..b80d4f9285c2e 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -29,7 +29,7 @@ use opts::{Opts, Subcommands, ToBaseArgs}; #[tokio::main] async fn main() -> Result<()> { - handler::install()?; + handler::install(); utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index dcd557d310fae..df71300138be5 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -19,19 +19,20 @@ const VERSION_MESSAGE: &str = concat!( ")" ); -#[derive(Debug, Parser)] -#[clap(name = "cast", version = VERSION_MESSAGE)] +/// Perform Ethereum RPC calls from the comfort of your command line. +#[derive(Parser)] +#[clap( + name = "cast", + version = VERSION_MESSAGE, + after_help = "Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html", + next_display_order = None, +)] pub struct Opts { #[clap(subcommand)] pub sub: Subcommands, } -/// Perform Ethereum RPC calls from the comfort of your command line. -#[derive(Debug, Subcommand)] -#[clap( - after_help = "Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html", - next_display_order = None -)] +#[derive(Subcommand)] pub enum Subcommands { /// Prints the maximum value of the given integer type. #[clap(visible_aliases = &["--max-int", "maxi"])] diff --git a/crates/cast/src/base.rs b/crates/cast/src/base.rs index 80d2f6047fc4b..0ef91c6ddb071 100644 --- a/crates/cast/src/base.rs +++ b/crates/cast/src/base.rs @@ -41,12 +41,12 @@ impl FromStr for Base { "10" | "d" | "dec" | "decimal" => Ok(Self::Decimal), "16" | "h" | "hex" | "hexadecimal" => Ok(Self::Hexadecimal), s => Err(eyre::eyre!( - r#"Invalid base "{}". Possible values: -2, b, bin, binary -8, o, oct, octal + "\ +Invalid base \"{s}\". Possible values: + 2, b, bin, binary + 8, o, oct, octal 10, d, dec, decimal -16, h, hex, hexadecimal"#, - s +16, h, hex, hexadecimal" )), } } diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 6b94eecb498f0..69ae708405c56 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -84,7 +84,7 @@ pub enum ChiselParserSub { #[tokio::main] async fn main() -> eyre::Result<()> { - handler::install()?; + handler::install(); utils::subscriber(); #[cfg(windows)] if !Paint::enable_windows_ascii() { diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index f4778c43960d0..61d3246f4738b 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -1,4 +1,4 @@ -use eyre::{EyreHandler, Result}; +use eyre::EyreHandler; use std::error::Error; use yansi::Paint; @@ -47,9 +47,8 @@ impl EyreHandler for Handler { /// verbose debug-centric handler is installed. /// /// Panics are always caught by the more debug-centric handler. -pub fn install() -> Result<()> { +pub fn install() { let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok(); - if debug_enabled { if let Err(e) = color_eyre::install() { debug!("failed to install color eyre error hook: {e}"); @@ -65,6 +64,4 @@ pub fn install() -> Result<()> { debug!("failed to install eyre error hook: {e}"); } } - - Ok(()) } diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/cli/src/opts/wallet/mod.rs index 66523e92ec5cc..49f2fbc8ce39c 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/cli/src/opts/wallet/mod.rs @@ -42,11 +42,7 @@ pub struct RawWallet { pub interactive: bool, /// Use the provided private key. - #[clap( - long, - value_name = "RAW_PRIVATE_KEY", - value_parser = foundry_common::clap_helpers::strip_0x_prefix - )] + #[clap(long, value_name = "RAW_PRIVATE_KEY")] pub private_key: Option, /// Use the mnemonic phrase of mnemonic file at the specified path. diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index 0ca13005ef0cb..71baf28f529d4 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -97,12 +97,7 @@ pub struct MultiWallet { pub interactives: u32, /// Use the provided private keys. - #[clap( - long, - help_heading = "Wallet options - raw", - value_name = "RAW_PRIVATE_KEYS", - value_parser = foundry_common::clap_helpers::strip_0x_prefix, - )] + #[clap(long, help_heading = "Wallet options - raw", value_name = "RAW_PRIVATE_KEYS")] pub private_keys: Option>, /// Use the provided private key. @@ -110,8 +105,7 @@ pub struct MultiWallet { long, help_heading = "Wallet options - raw", conflicts_with = "private_keys", - value_name = "RAW_PRIVATE_KEY", - value_parser = foundry_common::clap_helpers::strip_0x_prefix, + value_name = "RAW_PRIVATE_KEY" )] pub private_key: Option, diff --git a/crates/common/src/clap_helpers.rs b/crates/common/src/clap_helpers.rs deleted file mode 100644 index f26455b764148..0000000000000 --- a/crates/common/src/clap_helpers.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Additional utils for clap - -/// A `clap` `value_parser` that removes a `0x` prefix if it exists -pub fn strip_0x_prefix(s: &str) -> Result { - Ok(s.strip_prefix("0x").unwrap_or(s).to_string()) -} diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 3d1db499d4072..7690ddbc277de 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,12 +1,13 @@ //! Support for compiling [foundry_compilers::Project] -use crate::{compact_to_contract, glob::GlobMatcher, term, TestFunctionExt}; -use comfy_table::{presets::ASCII_MARKDOWN, *}; + +use crate::{compact_to_contract, glob::GlobMatcher, term::SpinnerReporter, TestFunctionExt}; +use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Table}; use eyre::Result; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ artifacts::{BytecodeObject, ContractBytecodeSome}, remappings::Remapping, - report::NoReporter, + report::{BasicStdoutReporter, NoReporter, Report}, Artifact, ArtifactId, FileFilter, Graph, Project, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig, }; @@ -14,105 +15,195 @@ use std::{ collections::{BTreeMap, HashMap}, convert::Infallible, fmt::Display, + io::IsTerminal, path::{Path, PathBuf}, result, str::FromStr, }; -/// Helper type to configure how to compile a project +/// Builder type to configure how to compile a project. /// -/// This is merely a wrapper for [Project::compile()] which also prints to stdout dependent on its -/// settings -#[derive(Clone, Debug, Default)] +/// This is merely a wrapper for [`Project::compile()`] which also prints to stdout depending on its +/// settings. +#[must_use = "this builder does nothing unless you call a `compile*` method"] pub struct ProjectCompiler { - /// whether to also print the contract names - print_names: bool, - /// whether to also print the contract sizes - print_sizes: bool, - /// files to exclude - filters: Vec, + /// Whether we are going to verify the contracts after compilation. + verify: Option, + + /// Whether to also print contract names. + print_names: Option, + + /// Whether to also print contract sizes. + print_sizes: Option, + + /// Whether to print anything at all. Overrides other `print` options. + quiet: Option, + + /// Whether to bail on compiler errors. + bail: Option, + + /// Files to exclude. + filter: Option>, + + /// Extra files to include, that are not necessarily in the project's source dir. + files: Vec, +} + +impl Default for ProjectCompiler { + #[inline] + fn default() -> Self { + Self::new() + } } impl ProjectCompiler { - /// Create a new instance with the settings - pub fn new(print_names: bool, print_sizes: bool) -> Self { - Self::with_filter(print_names, print_sizes, Vec::new()) + /// Create a new builder with the default settings. + #[inline] + pub fn new() -> Self { + Self { + verify: None, + print_names: None, + print_sizes: None, + quiet: Some(crate::shell::verbosity().is_silent()), + bail: None, + filter: None, + files: Vec::new(), + } } - /// Create a new instance with all settings - pub fn with_filter( - print_names: bool, - print_sizes: bool, - filters: Vec, - ) -> Self { - Self { print_names, print_sizes, filters } + /// Sets whether we are going to verify the contracts after compilation. + #[inline] + pub fn verify(mut self, yes: bool) -> Self { + self.verify = Some(yes); + self } - /// Compiles the project with [`Project::compile()`] - pub fn compile(self, project: &Project) -> Result { - let filters = self.filters.clone(); - self.compile_with(project, |prj| { - let output = if filters.is_empty() { - prj.compile() - } else { - prj.compile_sparse(SkipBuildFilters(filters)) - }?; - Ok(output) - }) + /// Sets whether to print contract names. + #[inline] + pub fn print_names(mut self, yes: bool) -> Self { + self.print_names = Some(yes); + self } - /// Compiles the project with [`Project::compile_parse()`] and the given filter. - /// - /// This will emit artifacts only for files that match the given filter. - /// Files that do _not_ match the filter are given a pruned output selection and do not generate - /// artifacts. - pub fn compile_sparse( - self, - project: &Project, - filter: F, - ) -> Result { - self.compile_with(project, |prj| Ok(prj.compile_sparse(filter)?)) + /// Sets whether to print contract sizes. + #[inline] + pub fn print_sizes(mut self, yes: bool) -> Self { + self.print_sizes = Some(yes); + self + } + + /// Sets whether to print anything at all. Overrides other `print` options. + #[inline] + #[doc(alias = "silent")] + pub fn quiet(mut self, yes: bool) -> Self { + self.quiet = Some(yes); + self + } + + /// Do not print anything at all if true. Overrides other `print` options. + #[inline] + pub fn quiet_if(mut self, maybe: bool) -> Self { + if maybe { + self.quiet = Some(true); + } + self + } + + /// Sets whether to bail on compiler errors. + #[inline] + pub fn bail(mut self, yes: bool) -> Self { + self.bail = Some(yes); + self + } + + /// Sets the filter to use. + #[inline] + pub fn filter(mut self, filter: Box) -> Self { + self.filter = Some(filter); + self + } + + /// Sets extra files to include, that are not necessarily in the project's source dir. + #[inline] + pub fn files(mut self, files: impl IntoIterator) -> Self { + self.files.extend(files); + self + } + + /// Compiles the project. + pub fn compile(mut self, project: &Project) -> Result { + // Taking is fine since we don't need these in `compile_with`. + let filter = std::mem::take(&mut self.filter); + let files = std::mem::take(&mut self.files); + self.compile_with(project, || { + if !files.is_empty() { + project.compile_files(files) + } else if let Some(filter) = filter { + project.compile_sparse(move |file: &_| filter.is_match(file)) + } else { + project.compile() + } + .map_err(Into::into) + }) } /// Compiles the project with the given closure /// /// # Example /// - /// ```no_run + /// ```ignore /// use foundry_common::compile::ProjectCompiler; /// let config = foundry_config::Config::load(); - /// ProjectCompiler::default() - /// .compile_with(&config.project().unwrap(), |prj| Ok(prj.compile()?)) - /// .unwrap(); + /// let prj = config.project().unwrap(); + /// ProjectCompiler::new().compile_with(&prj, || Ok(prj.compile()?)).unwrap(); /// ``` #[instrument(target = "forge::compile", skip_all)] - pub fn compile_with(self, project: &Project, f: F) -> Result + fn compile_with(self, project: &Project, f: F) -> Result where - F: FnOnce(&Project) -> Result, + F: FnOnce() -> Result, { + // TODO: Avoid process::exit if !project.paths.has_input_files() { println!("Nothing to compile"); // nothing to do here std::process::exit(0); } - let now = std::time::Instant::now(); - trace!("start compiling project"); + let quiet = self.quiet.unwrap_or(false); + let bail = self.bail.unwrap_or(true); + #[allow(clippy::collapsible_else_if)] + let reporter = if quiet { + Report::new(NoReporter::default()) + } else { + if std::io::stdout().is_terminal() { + Report::new(SpinnerReporter::spawn()) + } else { + Report::new(BasicStdoutReporter::default()) + } + }; + + let output = foundry_compilers::report::with_scoped(&reporter, || { + tracing::debug!("compiling project"); - let output = term::with_spinner_reporter(|| f(project))?; + let timer = std::time::Instant::now(); + let r = f(); + let elapsed = timer.elapsed(); - let elapsed = now.elapsed(); - trace!(?elapsed, "finished compiling"); + tracing::debug!("finished compiling in {:.3}s", elapsed.as_secs_f64()); + r + })?; - if output.has_compiler_errors() { - warn!("compiled with errors"); - eyre::bail!(output.to_string()) - } else if output.is_unchanged() { - println!("No files changed, compilation skipped"); - self.handle_output(&output); - } else { - // print the compiler output / warnings - println!("{output}"); + if bail && output.has_compiler_errors() { + eyre::bail!("{output}") + } + + if !quiet { + if output.is_unchanged() { + println!("No files changed, compilation skipped"); + } else { + // print the compiler output / warnings + println!("{output}"); + } self.handle_output(&output); } @@ -122,8 +213,11 @@ impl ProjectCompiler { /// If configured, this will print sizes or names fn handle_output(&self, output: &ProjectCompileOutput) { + let print_names = self.print_names.unwrap_or(false); + let print_sizes = self.print_sizes.unwrap_or(false); + // print any sizes or names - if self.print_names { + if print_names { let mut artifacts: BTreeMap<_, Vec<_>> = BTreeMap::new(); for (name, (_, version)) in output.versioned_artifacts() { artifacts.entry(version).or_default().push(name); @@ -138,11 +232,13 @@ impl ProjectCompiler { } } } - if self.print_sizes { + + if print_sizes { // add extra newline if names were already printed - if self.print_names { + if print_names { println!(); } + let mut size_report = SizeReport { contracts: BTreeMap::new() }; let artifacts: BTreeMap<_, _> = output.artifacts().collect(); for (name, artifact) in artifacts { @@ -163,6 +259,7 @@ impl ProjectCompiler { println!("{size_report}"); + // TODO: avoid process::exit // exit with error if any contract exceeds the size limit, excluding test contracts. if size_report.exceeds_size_limit() { std::process::exit(1); @@ -180,7 +277,7 @@ const CONTRACT_SIZE_LIMIT: usize = 24576; /// Contracts with info about their size pub struct SizeReport { - /// `:info>` + /// `contract name -> info` pub contracts: BTreeMap, } @@ -261,175 +358,31 @@ pub struct ContractInfo { pub is_dev_contract: bool, } -/// Compiles the provided [`Project`], throws if there's any compiler error and logs whether -/// compilation was successful or if there was a cache hit. -pub fn compile( - project: &Project, - print_names: bool, - print_sizes: bool, -) -> Result { - ProjectCompiler::new(print_names, print_sizes).compile(project) -} - -/// Compiles the provided [`Project`], throws if there's any compiler error and logs whether -/// compilation was successful or if there was a cache hit. -/// -/// Takes a list of [`SkipBuildFilter`] for files to exclude from the build. -pub fn compile_with_filter( - project: &Project, - print_names: bool, - print_sizes: bool, - skip: Vec, -) -> Result { - ProjectCompiler::with_filter(print_names, print_sizes, skip).compile(project) -} - -/// Compiles the provided [`Project`] and does not throw if there's any compiler error -/// Doesn't print anything to stdout, thus is "suppressed". -pub fn try_suppress_compile(project: &Project) -> Result { - Ok(foundry_compilers::report::with_scoped( - &foundry_compilers::report::Report::new(NoReporter::default()), - || project.compile(), - )?) -} - -/// Compiles the provided [`Project`], throws if there's any compiler error and logs whether -/// compilation was successful or if there was a cache hit. -/// Doesn't print anything to stdout, thus is "suppressed". -pub fn suppress_compile(project: &Project) -> Result { - let output = try_suppress_compile(project)?; - - if output.has_compiler_errors() { - eyre::bail!(output.to_string()) - } - - Ok(output) -} - -/// Depending on whether the `skip` is empty this will [`suppress_compile_sparse`] or -/// [`suppress_compile`] and throw if there's any compiler error -pub fn suppress_compile_with_filter( - project: &Project, - skip: Vec, -) -> Result { - if skip.is_empty() { - suppress_compile(project) - } else { - suppress_compile_sparse(project, SkipBuildFilters(skip)) - } -} - -/// Depending on whether the `skip` is empty this will [`suppress_compile_sparse`] or -/// [`suppress_compile`] and does not throw if there's any compiler error -pub fn suppress_compile_with_filter_json( - project: &Project, - skip: Vec, -) -> Result { - if skip.is_empty() { - try_suppress_compile(project) - } else { - try_suppress_compile_sparse(project, SkipBuildFilters(skip)) - } -} - -/// Compiles the provided [`Project`], -/// Doesn't print anything to stdout, thus is "suppressed". -/// -/// See [`Project::compile_sparse`] -pub fn try_suppress_compile_sparse( - project: &Project, - filter: F, -) -> Result { - Ok(foundry_compilers::report::with_scoped( - &foundry_compilers::report::Report::new(NoReporter::default()), - || project.compile_sparse(filter), - )?) -} - -/// Compiles the provided [`Project`], throws if there's any compiler error and logs whether -/// compilation was successful or if there was a cache hit. -/// Doesn't print anything to stdout, thus is "suppressed". -/// -/// See [`Project::compile_sparse`] -pub fn suppress_compile_sparse( - project: &Project, - filter: F, -) -> Result { - let output = try_suppress_compile_sparse(project, filter)?; - - if output.has_compiler_errors() { - eyre::bail!(output.to_string()) - } - - Ok(output) -} - -/// Compile a set of files not necessarily included in the `project`'s source dir -/// -/// If `silent` no solc related output will be emitted to stdout -pub fn compile_files( - project: &Project, - files: Vec, - silent: bool, -) -> Result { - let output = if silent { - foundry_compilers::report::with_scoped( - &foundry_compilers::report::Report::new(NoReporter::default()), - || project.compile_files(files), - ) - } else { - term::with_spinner_reporter(|| project.compile_files(files)) - }?; - - if output.has_compiler_errors() { - eyre::bail!(output.to_string()) - } - if !silent { - println!("{output}"); - } - - Ok(output) -} - /// Compiles target file path. /// -/// If `silent` no solc related output will be emitted to stdout. +/// If `quiet` no solc related output will be emitted to stdout. /// /// If `verify` and it's a standalone script, throw error. Only allowed for projects. /// /// **Note:** this expects the `target_path` to be absolute -pub fn compile_target( - target_path: &Path, - project: &Project, - silent: bool, - verify: bool, -) -> Result { - compile_target_with_filter(target_path, project, silent, verify, Vec::new()) -} - -/// Compiles target file path. pub fn compile_target_with_filter( target_path: &Path, project: &Project, - silent: bool, + quiet: bool, verify: bool, skip: Vec, ) -> Result { let graph = Graph::resolve(&project.paths)?; // Checking if it's a standalone script, or part of a project. - if graph.files().get(target_path).is_none() { + let mut compiler = ProjectCompiler::new().filter(Box::new(SkipBuildFilters(skip))).quiet(quiet); + if !graph.files().contains_key(target_path) { if verify { eyre::bail!("You can only verify deployments from inside a project! Make sure it exists with `forge tree`."); } - return compile_files(project, vec![target_path.to_path_buf()], silent) - } - - if silent { - suppress_compile_with_filter(project, skip) - } else { - compile_with_filter(project, false, false, skip) + compiler = compiler.files([target_path.into()]); } + compiler.compile(project) } /// Compiles an Etherscan source from metadata by creating a project. @@ -444,7 +397,7 @@ pub async fn compile_from_source( let project_output = project.compile()?; if project_output.has_compiler_errors() { - eyre::bail!(project_output.to_string()) + eyre::bail!("{project_output}") } let (artifact_id, file_id, contract) = project_output diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 02d11bb43590d..3e7e6ecbd775f 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -9,7 +9,6 @@ extern crate tracing; pub mod abi; pub mod calc; -pub mod clap_helpers; pub mod compile; pub mod constants; pub mod contracts; diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 682b31f2f8d7a..576af2b9f1190 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -1,5 +1,7 @@ +//! Support for handling/identifying selectors. + #![allow(missing_docs)] -//! Support for handling/identifying selectors + use crate::abi::abi_decode_calldata; use alloy_json_abi::JsonAbi; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; @@ -410,7 +412,6 @@ pub async fn decode_event_topic(topic: &str) -> eyre::Result> { /// # Ok(()) /// # } /// ``` - pub async fn pretty_calldata( calldata: impl AsRef, offline: bool, diff --git a/crates/config/src/warning.rs b/crates/config/src/warning.rs index 027554ff1047f..a19104eaf7b4d 100644 --- a/crates/config/src/warning.rs +++ b/crates/config/src/warning.rs @@ -53,30 +53,37 @@ impl fmt::Display for Warning { match self { Self::UnknownSection { unknown_section, source } => { let source = source.as_ref().map(|src| format!(" in {src}")).unwrap_or_default(); - f.write_fmt(format_args!("Unknown section [{unknown_section}] found{source}. This notation for profiles has been deprecated and may result in the profile not being registered in future versions. Please use [profile.{unknown_section}] instead or run `forge config --fix`.")) - } - Self::NoLocalToml(tried) => { - let path = tried.display(); - f.write_fmt(format_args!("No local TOML found to fix at {path}. Change the current directory to a project path or set the foundry.toml path with the FOUNDRY_CONFIG environment variable")) + write!( + f, + "Found unknown config section{source}: [{unknown_section}]\n\ + This notation for profiles has been deprecated and may result in the profile \ + not being registered in future versions.\n\ + Please use [profile.{unknown_section}] instead or run `forge config --fix`." + ) } + Self::NoLocalToml(path) => write!( + f, + "No local TOML found to fix at {}.\n\ + Change the current directory to a project path or set the foundry.toml path with \ + the `FOUNDRY_CONFIG` environment variable", + path.display() + ), + Self::CouldNotReadToml { path, err } => { - f.write_fmt(format_args!("Could not read TOML at {}: {err}", path.display())) + write!(f, "Could not read TOML at {}: {err}", path.display()) } Self::CouldNotWriteToml { path, err } => { - f.write_fmt(format_args!("Could not write TOML to {}: {err}", path.display())) + write!(f, "Could not write TOML to {}: {err}", path.display()) + } + Self::CouldNotFixProfile { path, profile, err } => { + write!(f, "Could not fix [{profile}] in TOML at {}: {err}", path.display()) + } + Self::DeprecatedKey { old, new } if new.is_empty() => { + write!(f, "Key `{old}` is being deprecated and will be removed in future versions.") + } + Self::DeprecatedKey { old, new } => { + write!(f, "Key `{old}` is being deprecated in favor of `{new}`. It will be removed in future versions.") } - Self::CouldNotFixProfile { path, profile, err } => f.write_fmt(format_args!( - "Could not fix [{}] in TOML at {}: {}", - profile, - path.display(), - err - )), - Self::DeprecatedKey { old, new } if new.is_empty() => f.write_fmt(format_args!( - "Key `{old}` is being deprecated and will be removed in future versions.", - )), - Self::DeprecatedKey { old, new } => f.write_fmt(format_args!( - "Key `{old}` is being deprecated in favor of `{new}`. It will be removed in future versions.", - )), } } } diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 2f0a53fcbfeca..c4fb92bd6e087 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -2,7 +2,7 @@ use clap::{Parser, ValueHint}; use ethers_contract::{Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts}; use eyre::{Result, WrapErr}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; -use foundry_common::{compile, fs::json_files}; +use foundry_common::{compile::ProjectCompiler, fs::json_files}; use foundry_config::impl_figment_convert; use std::{ fs, @@ -86,7 +86,7 @@ impl BindArgs { if !self.skip_build { // run `forge build` let project = self.build_args.project()?; - compile::compile(&project, false, false)?; + let _ = ProjectCompiler::new().compile(&project)?; } let artifacts = self.try_load_config_emit_warnings()?.out; @@ -216,11 +216,10 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin &self.crate_version, self.bindings_root(&artifacts), self.single_file, - )?; + ) } else { trace!(single_file = self.single_file, "generating module"); - bindings.write_to_module(self.bindings_root(&artifacts), self.single_file)?; + bindings.write_to_module(self.bindings_root(&artifacts), self.single_file) } - Ok(()) } } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 46ebb02041bbf..839f5a504f19c 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -2,10 +2,7 @@ use super::{install, watch::WatchArgs}; use clap::Parser; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; -use foundry_common::{ - compile, - compile::{ProjectCompiler, SkipBuildFilter}, -}; +use foundry_common::compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}; use foundry_compilers::{Project, ProjectCompileOutput}; use foundry_config::{ figment::{ @@ -90,19 +87,17 @@ impl BuildArgs { project = config.project()?; } - let filters = self.skip.unwrap_or_default(); - + let output = ProjectCompiler::new() + .print_names(self.names) + .print_sizes(self.sizes) + .quiet(self.format_json) + .bail(!self.format_json) + .filter(Box::new(SkipBuildFilters(self.skip.unwrap_or_default()))) + .compile(&project)?; if self.format_json { - let output = compile::suppress_compile_with_filter_json(&project, filters)?; - let json = serde_json::to_string_pretty(&output.clone().output())?; - println!("{}", json); - Ok(output) - } else if self.args.silent { - compile::suppress_compile_with_filter(&project, filters) - } else { - let compiler = ProjectCompiler::with_filter(self.names, self.sizes, filters); - compiler.compile(&project) + println!("{}", serde_json::to_string_pretty(&output.clone().output())?); } + Ok(output) } /// Returns the `Project` for the current workspace diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 5f22cc146cab4..93ae99d8cd97d 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -19,7 +19,8 @@ use foundry_cli::{ utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; use foundry_common::{ - compile, estimate_eip1559_fees, + compile::ProjectCompiler, + estimate_eip1559_fees, fmt::parse_tokens, types::{ToAlloy, ToEthers}, }; @@ -90,12 +91,8 @@ impl CreateArgs { pub async fn run(mut self) -> Result<()> { // Find Project & Compile let project = self.opts.project()?; - let mut output = if self.json || self.opts.silent { - // Suppress compile stdout messages when printing json output or when silent - compile::suppress_compile(&project) - } else { - compile::compile(&project, false, false) - }?; + let mut output = + ProjectCompiler::new().quiet_if(self.json || self.opts.silent).compile(&project)?; if let Some(ref mut path) = self.contract.path { // paths are absolute in the project's output diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 03aa7cf6d8f42..0716af47267ae 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -40,9 +40,8 @@ impl FlattenArgs { let paths = config.project_paths(); let target_path = dunce::canonicalize(target_path)?; - let flattened = paths - .flatten(&target_path) - .map_err(|err| eyre::Error::msg(format!("Failed to flatten the file: {err}")))?; + let flattened = + paths.flatten(&target_path).map_err(|err| eyre::eyre!("Failed to flatten: {err}"))?; match output { Some(output) => { diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index a05dbb3c1ee70..0d038c436ffcd 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -1,9 +1,8 @@ -use alloy_json_abi::JsonAbi; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; use eyre::Result; use foundry_cli::opts::{CompilerArgs, CoreBuildArgs}; -use foundry_common::compile; +use foundry_common::compile::ProjectCompiler; use foundry_compilers::{ artifacts::{ output_selection::{ @@ -15,7 +14,6 @@ use foundry_compilers::{ info::ContractInfo, utils::canonicalize, }; -use serde_json::{to_value, Value}; use std::fmt; /// CLI arguments for `forge inspect`. @@ -64,103 +62,68 @@ impl InspectArgs { // Build the project let project = modified_build_args.project()?; - let outcome = if let Some(ref mut contract_path) = contract.path { + let mut compiler = ProjectCompiler::new().quiet(true); + if let Some(contract_path) = &mut contract.path { let target_path = canonicalize(&*contract_path)?; *contract_path = target_path.to_string_lossy().to_string(); - compile::compile_files(&project, vec![target_path], true) - } else { - compile::suppress_compile(&project) - }?; + compiler = compiler.files([target_path]); + } + let output = compiler.compile(&project)?; // Find the artifact - let found_artifact = outcome.find_contract(&contract); - - trace!(target: "forge", artifact=?found_artifact, input=?contract, "Found contract"); - - // Unwrap the inner artifact - let artifact = found_artifact.ok_or_else(|| { + let artifact = output.find_contract(&contract).ok_or_else(|| { eyre::eyre!("Could not find artifact `{contract}` in the compiled artifacts") })?; - // Match on ContractArtifactFields and Pretty Print + // Match on ContractArtifactFields and pretty-print match field { ContractArtifactField::Abi => { let abi = artifact .abi .as_ref() .ok_or_else(|| eyre::eyre!("Failed to fetch lossless ABI"))?; - print_abi(abi, pretty)?; + if pretty { + let source = foundry_cli::utils::abi_to_solidity(abi, "")?; + println!("{source}"); + } else { + print_json(abi)?; + } } ContractArtifactField::Bytecode => { - let tval: Value = to_value(&artifact.bytecode)?; - println!( - "{}", - tval.get("object").unwrap_or(&tval).as_str().ok_or_else(|| eyre::eyre!( - "Failed to extract artifact bytecode as a string" - ))? - ); + print_json_str(&artifact.bytecode, Some("object"))?; } ContractArtifactField::DeployedBytecode => { - let tval: Value = to_value(&artifact.deployed_bytecode)?; - println!( - "{}", - tval.get("object").unwrap_or(&tval).as_str().ok_or_else(|| eyre::eyre!( - "Failed to extract artifact deployed bytecode as a string" - ))? - ); + print_json_str(&artifact.deployed_bytecode, Some("object"))?; } ContractArtifactField::Assembly | ContractArtifactField::AssemblyOptimized => { - println!( - "{}", - to_value(&artifact.assembly)?.as_str().ok_or_else(|| eyre::eyre!( - "Failed to extract artifact assembly as a string" - ))? - ); + print_json_str(&artifact.assembly, None)?; } ContractArtifactField::MethodIdentifiers => { - println!( - "{}", - serde_json::to_string_pretty(&to_value(&artifact.method_identifiers)?)? - ); + print_json(&artifact.method_identifiers)?; } ContractArtifactField::GasEstimates => { - println!("{}", serde_json::to_string_pretty(&to_value(&artifact.gas_estimates)?)?); + print_json(&artifact.gas_estimates)?; } ContractArtifactField::StorageLayout => { print_storage_layout(artifact.storage_layout.as_ref(), pretty)?; } ContractArtifactField::DevDoc => { - println!("{}", serde_json::to_string_pretty(&to_value(&artifact.devdoc)?)?); + print_json(&artifact.devdoc)?; } ContractArtifactField::Ir => { - println!( - "{}", - to_value(&artifact.ir)? - .as_str() - .ok_or_else(|| eyre::eyre!("Failed to extract artifact ir as a string"))? - ); + print_json_str(&artifact.ir, None)?; } ContractArtifactField::IrOptimized => { - println!( - "{}", - to_value(&artifact.ir_optimized)?.as_str().ok_or_else(|| eyre::eyre!( - "Failed to extract artifact optimized ir as a string" - ))? - ); + print_json_str(&artifact.ir_optimized, None)?; } ContractArtifactField::Metadata => { - println!("{}", serde_json::to_string_pretty(&to_value(&artifact.metadata)?)?); + print_json(&artifact.metadata)?; } ContractArtifactField::UserDoc => { - println!("{}", serde_json::to_string_pretty(&to_value(&artifact.userdoc)?)?); + print_json(&artifact.userdoc)?; } ContractArtifactField::Ewasm => { - println!( - "{}", - to_value(&artifact.ewasm)?.as_str().ok_or_else(|| eyre::eyre!( - "Failed to extract artifact ewasm as a string" - ))? - ); + print_json_str(&artifact.ewasm, None)?; } ContractArtifactField::Errors => { let mut out = serde_json::Map::new(); @@ -176,7 +139,7 @@ impl InspectArgs { ); } } - println!("{}", serde_json::to_string_pretty(&out)?); + print_json(&out)?; } ContractArtifactField::Events => { let mut out = serde_json::Map::new(); @@ -190,7 +153,7 @@ impl InspectArgs { ); } } - println!("{}", serde_json::to_string_pretty(&out)?); + print_json(&out)?; } }; @@ -198,24 +161,13 @@ impl InspectArgs { } } -pub fn print_abi(abi: &JsonAbi, pretty: bool) -> Result<()> { - let s = if pretty { - foundry_cli::utils::abi_to_solidity(abi, "")? - } else { - serde_json::to_string_pretty(&abi)? - }; - println!("{s}"); - Ok(()) -} - pub fn print_storage_layout(storage_layout: Option<&StorageLayout>, pretty: bool) -> Result<()> { let Some(storage_layout) = storage_layout else { eyre::bail!("Could not get storage layout"); }; if !pretty { - println!("{}", serde_json::to_string_pretty(&to_value(storage_layout)?)?); - return Ok(()) + return print_json(&storage_layout) } let mut table = Table::new(); @@ -235,7 +187,6 @@ pub fn print_storage_layout(storage_layout: Option<&StorageLayout>, pretty: bool } println!("{table}"); - Ok(()) } @@ -409,6 +360,26 @@ impl ContractArtifactField { } } +fn print_json(obj: &impl serde::Serialize) -> Result<()> { + println!("{}", serde_json::to_string_pretty(obj)?); + Ok(()) +} + +fn print_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result<()> { + let value = serde_json::to_value(obj)?; + let mut value_ref = &value; + if let Some(key) = key { + if let Some(value2) = value.get(key) { + value_ref = value2; + } + } + match value_ref.as_str() { + Some(s) => println!("{s}"), + None => println!("{value_ref:#}"), + } + Ok(()) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index d01243b35d3a8..2a0379af2f0e3 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -1,7 +1,6 @@ use clap::{Parser, ValueHint}; use eyre::Result; use foundry_cli::utils::LoadConfig; -use foundry_compilers::remappings::RelativeRemapping; use foundry_config::impl_figment_convert_basic; use foundry_evm::hashbrown::HashMap; use std::path::PathBuf; @@ -22,19 +21,15 @@ pub struct RemappingArgs { impl_figment_convert_basic!(RemappingArgs); impl RemappingArgs { - // TODO: Do people use `forge remappings >> file`? pub fn run(self) -> Result<()> { let config = self.try_load_config_emit_warnings()?; if self.pretty { - let groups = config.remappings.into_iter().fold( - HashMap::new(), - |mut groups: HashMap, Vec>, remapping| { - groups.entry(remapping.context.clone()).or_default().push(remapping); - groups - }, - ); - for (group, remappings) in groups.into_iter() { + let mut groups = HashMap::<_, Vec<_>>::with_capacity(config.remappings.len()); + for remapping in config.remappings { + groups.entry(remapping.context.clone()).or_default().push(remapping); + } + for (group, remappings) in groups { if let Some(group) = group { println!("Context: {group}"); } else { diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 784cd5cd7bd88..27d691eeb7457 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -5,7 +5,7 @@ use forge::link::{link_with_nonce_or_address, PostLinkInput, ResolvedDependency} use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compact_to_contract, - compile::{self, ContractSources}, + compile::{self, ContractSources, ProjectCompiler}, fs, }; use foundry_compilers::{ @@ -255,11 +255,7 @@ impl ScriptArgs { } // We received `contract_name`, and need to find its file path. - let output = if self.opts.args.silent { - compile::suppress_compile(&project) - } else { - compile::compile(&project, false, false) - }?; + let output = ProjectCompiler::new().compile(&project)?; let cache = SolFilesCache::read_joined(&project.paths).wrap_err("Could not open compiler cache")?; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index e7dab664b2ebf..c3ab3caa71163 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -91,12 +91,7 @@ pub struct ScriptArgs { pub target_contract: Option, /// The signature of the function you want to call in the contract, or raw calldata. - #[clap( - long, - short, - default_value = "run()", - value_parser = foundry_common::clap_helpers::strip_0x_prefix - )] + #[clap(long, short, default_value = "run()")] pub sig: String, /// Max priority fee per gas for EIP1559 transactions. diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 6bcb7dde34dde..7318fa04fc2ec 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -6,7 +6,7 @@ use foundry_cli::{ utils::FoundryPathExt, }; use foundry_common::{ - compile, + compile::ProjectCompiler, selectors::{import_selectors, SelectorImportData}, }; use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, info::ContractInfo}; @@ -18,21 +18,14 @@ pub enum SelectorsSubcommands { /// Check for selector collisions between contracts #[clap(visible_alias = "co")] Collision { - /// First contract - #[clap( - help = "The first of the two contracts for which to look selector collisions for, in the form `(:)?`", - value_name = "FIRST_CONTRACT" - )] + /// The first of the two contracts for which to look selector collisions for, in the form + /// `(:)?`. first_contract: ContractInfo, - /// Second contract - #[clap( - help = "The second of the two contracts for which to look selector collisions for, in the form `(:)?`", - value_name = "SECOND_CONTRACT" - )] + /// The second of the two contracts for which to look selector collisions for, in the form + /// `(:)?`. second_contract: ContractInfo, - /// Support build args #[clap(flatten)] build: Box, }, @@ -78,9 +71,9 @@ impl SelectorsSubcommands { }; let project = build_args.project()?; - let outcome = compile::suppress_compile(&project)?; + let output = ProjectCompiler::new().quiet(true).compile(&project)?; let artifacts = if all { - outcome + output .into_artifacts_with_files() .filter(|(file, _, _)| { let is_sources_path = file @@ -93,7 +86,7 @@ impl SelectorsSubcommands { .collect() } else { let contract = contract.unwrap(); - let found_artifact = outcome.find_first(&contract); + let found_artifact = output.find_first(&contract); let artifact = found_artifact .ok_or_else(|| { eyre::eyre!( @@ -122,41 +115,34 @@ impl SelectorsSubcommands { } } SelectorsSubcommands::Collision { mut first_contract, mut second_contract, build } => { - // Build first project - let first_project = build.project()?; - let first_outcome = if let Some(ref mut contract_path) = first_contract.path { + // Compile the project with the two contracts included + let project = build.project()?; + let mut compiler = ProjectCompiler::new().quiet(true); + + if let Some(contract_path) = &mut first_contract.path { let target_path = canonicalize(&*contract_path)?; *contract_path = target_path.to_string_lossy().to_string(); - compile::compile_files(&first_project, vec![target_path], true) - } else { - compile::suppress_compile(&first_project) - }?; - - // Build second project - let second_project = build.project()?; - let second_outcome = if let Some(ref mut contract_path) = second_contract.path { + compiler = compiler.files([target_path]); + } + if let Some(contract_path) = &mut second_contract.path { let target_path = canonicalize(&*contract_path)?; *contract_path = target_path.to_string_lossy().to_string(); - compile::compile_files(&second_project, vec![target_path], true) - } else { - compile::suppress_compile(&second_project) - }?; - - // Find the artifacts - let first_found_artifact = first_outcome.find_contract(&first_contract); - let second_found_artifact = second_outcome.find_contract(&second_contract); + compiler = compiler.files([target_path]); + } - // Unwrap inner artifacts - let first_artifact = first_found_artifact.ok_or_else(|| { - eyre::eyre!("Failed to extract first artifact bytecode as a string") - })?; - let second_artifact = second_found_artifact.ok_or_else(|| { - eyre::eyre!("Failed to extract second artifact bytecode as a string") - })?; + let output = compiler.compile(&project)?; // Check method selectors for collisions - let first_method_map = first_artifact.method_identifiers.as_ref().unwrap(); - let second_method_map = second_artifact.method_identifiers.as_ref().unwrap(); + let methods = |contract: &ContractInfo| -> eyre::Result<_> { + let artifact = output + .find_contract(contract) + .ok_or_else(|| eyre::eyre!("Could not find artifact for {contract}"))?; + artifact.method_identifiers.as_ref().ok_or_else(|| { + eyre::eyre!("Could not find method identifiers for {contract}") + }) + }; + let first_method_map = methods(&first_contract)?; + let second_method_map = methods(&second_contract)?; let colliding_methods: Vec<(&String, &String, &String)> = first_method_map .iter() @@ -197,7 +183,7 @@ impl SelectorsSubcommands { // compile the project to get the artifacts/abis let project = build_args.project()?; - let outcome = compile::suppress_compile(&project)?; + let outcome = ProjectCompiler::new().quiet(true).compile(&project)?; let artifacts = if let Some(contract) = contract { let found_artifact = outcome.find_first(&contract); let artifact = found_artifact diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 09d92fb41230f..1f413696f8cf3 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -19,7 +19,7 @@ use foundry_cli::{ }; use foundry_common::{ compact_to_contract, - compile::{self, ContractSources, ProjectCompiler}, + compile::{ContractSources, ProjectCompiler}, evm::EvmArgs, get_contract_name, get_file_name, shell, }; @@ -142,14 +142,10 @@ impl TestArgs { // Merge all configs let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; - let mut filter = self.filter(&config); - - trace!(target: "forge::test", ?filter, "using filter"); - - // Set up the project + // Set up the project. let mut project = config.project()?; - // install missing dependencies + // Install missing dependencies. if install::install_missing_dependencies(&mut config, self.build_args().silent) && config.auto_detect_remappings { @@ -158,15 +154,16 @@ impl TestArgs { project = config.project()?; } - let compiler = ProjectCompiler::default(); - let output = match (config.sparse_mode, self.opts.silent | self.json) { - (false, false) => compiler.compile(&project), - (true, false) => compiler.compile_sparse(&project, filter.clone()), - (false, true) => compile::suppress_compile(&project), - (true, true) => compile::suppress_compile_sparse(&project, filter.clone()), - }?; - // Create test options from general project settings - // and compiler output + let mut filter = self.filter(&config); + trace!(target: "forge::test", ?filter, "using filter"); + + let mut compiler = ProjectCompiler::new().quiet_if(self.json || self.opts.silent); + if config.sparse_mode { + compiler = compiler.filter(Box::new(filter.clone())); + } + let output = compiler.compile(&project)?; + + // Create test options from general project settings and compiler output. let project_root = &project.paths.root; let toml = config.get_config_path(); let profiles = get_available_profiles(toml)?; @@ -623,26 +620,27 @@ impl TestOutcome { Self { results, allow_failure } } - /// Iterator over all succeeding tests and their names + /// Returns an iterator over all succeeding tests and their names. pub fn successes(&self) -> impl Iterator { self.tests().filter(|(_, t)| t.status == TestStatus::Success) } - /// Iterator over all failing tests and their names + /// Returns an iterator over all failing tests and their names. pub fn failures(&self) -> impl Iterator { self.tests().filter(|(_, t)| t.status == TestStatus::Failure) } + /// Returns an iterator over all skipped tests and their names. pub fn skips(&self) -> impl Iterator { self.tests().filter(|(_, t)| t.status == TestStatus::Skipped) } - /// Iterator over all tests and their names + /// Returns an iterator over all tests and their names. pub fn tests(&self) -> impl Iterator { self.results.values().flat_map(|suite| suite.tests()) } - /// Returns an iterator over all `Test` + /// Returns an iterator over all `Test`s. pub fn into_tests(self) -> impl Iterator { self.results .into_iter() diff --git a/crates/forge/bin/cmd/verify/etherscan/flatten.rs b/crates/forge/bin/cmd/verify/etherscan/flatten.rs index a9ed47bc23709..e58b784f15d99 100644 --- a/crates/forge/bin/cmd/verify/etherscan/flatten.rs +++ b/crates/forge/bin/cmd/verify/etherscan/flatten.rs @@ -80,16 +80,16 @@ impl EtherscanFlattenedSource { if out.has_error() { let mut o = AggregatedCompilerOutput::default(); o.extend(version, out); - eprintln!("{}", o.diagnostics(&[], Default::default())); + let diags = o.diagnostics(&[], Default::default()); - eprintln!( - r#"Failed to compile the flattened code locally. + eyre::bail!( + "\ +Failed to compile the flattened code locally. This could be a bug, please inspect the output of `forge flatten {}` and report an issue. To skip this solc dry, pass `--force`. -"#, +Diagnostics: {diags}", contract_path.display() ); - std::process::exit(1) } Ok(()) diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index ef9f0635018e1..6c17d3f1293da 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -48,14 +48,10 @@ impl VerificationProvider for SourcifyVerificationProvider { let status = response.status(); if !status.is_success() { let error: serde_json::Value = response.json().await?; - eprintln!( - "Sourcify verification request for address ({}) failed with status code {}\nDetails: {:#}", - format_args!("{:?}", args.address), - status, - error + eyre::bail!( + "Sourcify verification request for address ({}) failed with status code {status}\nDetails: {error:#}", + args.address, ); - warn!("Failed verify submission: {:?}", error); - std::process::exit(1); } let text = response.text().await?; @@ -65,8 +61,7 @@ impl VerificationProvider for SourcifyVerificationProvider { }) .await?; - self.process_sourcify_response(resp.map(|r| r.result)); - Ok(()) + self.process_sourcify_response(resp.map(|r| r.result)) } async fn check(&self, args: VerifyCheckArgs) -> Result<()> { @@ -83,11 +78,10 @@ impl VerificationProvider for SourcifyVerificationProvider { let response = reqwest::get(url).await?; if !response.status().is_success() { - eprintln!( + eyre::bail!( "Failed to request verification status with status code {}", response.status() ); - std::process::exit(1); }; Ok(Some(response.json::>().await?)) @@ -96,8 +90,7 @@ impl VerificationProvider for SourcifyVerificationProvider { }) .await?; - self.process_sourcify_response(resp); - Ok(()) + self.process_sourcify_response(resp) } } @@ -165,22 +158,26 @@ metadata output can be enabled via `extra_output = ["metadata"]` in `foundry.tom Ok(req) } - fn process_sourcify_response(&self, response: Option>) { - let response = response.unwrap().remove(0); - if response.status == "perfect" { - if let Some(ts) = response.storage_timestamp { - println!("Contract source code already verified. Storage Timestamp: {ts}"); - } else { - println!("Contract successfully verified") + fn process_sourcify_response( + &self, + response: Option>, + ) -> Result<()> { + let Some([response, ..]) = response.as_deref() else { return Ok(()) }; + match response.status.as_str() { + "perfect" => { + if let Some(ts) = &response.storage_timestamp { + println!("Contract source code already verified. Storage Timestamp: {ts}"); + } else { + println!("Contract successfully verified"); + } } - } else if response.status == "partial" { - println!("The recompiled contract partially matches the deployed version") - } else if response.status == "false" { - println!("Contract source code is not verified") - } else { - eprintln!("Unknown status from sourcify. Status: {}", response.status); - std::process::exit(1); + "partial" => { + println!("The recompiled contract partially matches the deployed version"); + } + "false" => println!("Contract source code is not verified"), + s => eyre::bail!("Unknown status from sourcify. Status: {s:?}"), } + Ok(()) } } diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index f2d8e99f8fdcf..819c82f430ce9 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -13,7 +13,7 @@ use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; use opts::{Opts, Subcommands}; fn main() -> Result<()> { - handler::install()?; + handler::install(); utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 28b5039811ce7..3b9c48680e292 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -31,19 +31,20 @@ const VERSION_MESSAGE: &str = concat!( ")" ); -#[derive(Debug, Parser)] -#[clap(name = "forge", version = VERSION_MESSAGE)] +/// Build, test, fuzz, debug and deploy Solidity contracts. +#[derive(Parser)] +#[clap( + name = "forge", + version = VERSION_MESSAGE, + after_help = "Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html", + next_display_order = None, +)] pub struct Opts { #[clap(subcommand)] pub sub: Subcommands, } -#[derive(Debug, Subcommand)] -#[clap( - about = "Build, test, fuzz, debug and deploy Solidity contracts.", - after_help = "Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html", - next_display_order = None -)] +#[derive(Subcommand)] #[allow(clippy::large_enum_variant)] pub enum Subcommands { /// Run the project's tests. diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f5c2387158bc5..1b69369db52ab 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -604,10 +604,10 @@ forgetest!(config_emit_warnings, |prj, cmd| { assert_eq!( String::from_utf8_lossy(&output.stderr) .lines() - .filter(|line| { line.contains("Unknown section [default]") }) + .filter(|line| line.contains("unknown config section") && line.contains("[default]")) .count(), - 1 - ) + 1, + ); }); forgetest_init!(can_skip_remappings_auto_detection, |prj, cmd| { From 8bd27fbb656e73f97ac32d761961e4c14b7062bc Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Fri, 5 Jan 2024 17:07:17 +0300 Subject: [PATCH 0438/1963] feat(cast): add `selectors` command to extract function selectors and arguments from bytecode (#6684) * add evmole library to dependencies * cast: add 'selectors' command to extract function selectors and arguments from bytecode using the evmole library --- Cargo.lock | 10 ++++++++++ crates/cast/Cargo.toml | 1 + crates/cast/bin/main.rs | 5 +++++ crates/cast/bin/opts.rs | 4 ++++ crates/cast/src/lib.rs | 21 +++++++++++++++++++++ 5 files changed, 41 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index c17749a2c7a3c..aee130b35fb18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1004,6 +1004,7 @@ dependencies = [ "ethers-providers", "ethers-signers", "evm-disassembler", + "evmole", "eyre", "foundry-block-explorers", "foundry-cli", @@ -2344,6 +2345,15 @@ dependencies = [ "hex", ] +[[package]] +name = "evmole" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f492d1949e58ef83a1bf8e23fbd042af12b03e7642d50dbb4cfb48112de5e01f" +dependencies = [ + "ruint", +] + [[package]] name = "eyre" version = "0.6.11" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 2dad8ff5b8298..5c6066592ac85 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -69,6 +69,7 @@ tempfile = "3" tokio = { version = "1", features = ["macros", "signal"] } tracing.workspace = true yansi = "0.5" +evmole = "0.3.1" [dev-dependencies] foundry-test-utils.workspace = true diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index b80d4f9285c2e..eacae735465d5 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -269,6 +269,11 @@ async fn main() -> Result<()> { Subcommands::Disassemble { bytecode } => { println!("{}", SimpleCast::disassemble(&bytecode)?); } + Subcommands::Selectors { bytecode } => { + let s = SimpleCast::extract_selectors(&bytecode)?; + let v: Vec<_> = s.into_iter().map(|r| format!("{}\t{}", r.0, r.1)).collect(); + println!("{}", v.join("\n")); + } Subcommands::FindBlock(cmd) => cmd.run().await?, Subcommands::GasPrice { rpc } => { let config = Config::from(&rpc); diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index df71300138be5..c4a2fd0ba3413 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -859,6 +859,10 @@ pub enum Subcommands { /// Decodes a raw signed EIP 2718 typed transaction #[clap(visible_alias = "dt")] DecodeTransaction { tx: Option }, + + /// Extracts function selectors and arguments from bytecode + #[clap(visible_alias = "sel")] + Selectors { bytecode: String }, } /// CLI arguments for `cast --to-base`. diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 427fdb0b1dbb4..00f2790b1614c 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1941,6 +1941,27 @@ impl SimpleCast { } } + /// Extracts function selectors and arguments from bytecode + /// + /// # Example + /// + /// ``` + /// use cast::SimpleCast as Cast; + /// + /// let bytecode = "6080604052348015600e575f80fd5b50600436106026575f3560e01c80632125b65b14602a575b5f80fd5b603a6035366004603c565b505050565b005b5f805f60608486031215604d575f80fd5b833563ffffffff81168114605f575f80fd5b925060208401356001600160a01b03811681146079575f80fd5b915060408401356001600160e01b03811681146093575f80fd5b80915050925092509256"; + /// let selectors = Cast::extract_selectors(bytecode)?; + /// assert_eq!(selectors, vec![("0x2125b65b".to_string(), "uint32,address,uint224".to_string())]); + /// # Ok::<(), eyre::Report>(()) + /// ``` + pub fn extract_selectors(bytecode: &str) -> Result> { + let code = hex::decode(strip_0x(bytecode))?; + let s = evmole::function_selectors(&code, 0); + + Ok(s.iter() + .map(|s| (hex::encode_prefixed(s), evmole::function_arguments(&code, s, 0))) + .collect()) + } + /// Decodes a raw EIP2718 transaction payload /// Returns details about the typed transaction and ECSDA signature components /// From 398c12c78a1758aac28558ee5dde8500c5609684 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 5 Jan 2024 17:07:01 +0100 Subject: [PATCH 0439/1963] chore: bump block explorers (#6709) --- Cargo.lock | 4 ++-- crates/forge/bin/cmd/verify/etherscan/mod.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aee130b35fb18..714d6bb64f4b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2635,9 +2635,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43408b384e5888fed99a5f25f86cef7e19dca10c750e948cbeb219f59847712f" +checksum = "aa44d981bf2493204dee4af1116ed9250656050d48b5569fa1e153fa4af75bdd" dependencies = [ "alloy-chains", "alloy-json-abi", diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index f6e8a03c6df60..ec7e72b1dfcb1 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -268,8 +268,7 @@ impl EtherscanVerificationProvider { let etherscan_api_url = verifier_url .or_else(|| etherscan_config.as_ref().map(|c| c.api_url.as_str())) - .map(str::to_owned) - .map(|url| if url.ends_with('?') { url } else { url + "?" }); + .map(str::to_owned); let api_url = etherscan_api_url.as_deref(); let base_url = etherscan_config @@ -283,6 +282,8 @@ impl EtherscanVerificationProvider { let mut builder = Client::builder(); builder = if let Some(api_url) = api_url { + // we don't want any trailing slashes because this can cause cloudflare issues: + let api_url = api_url.trim_end_matches('/'); builder.with_api_url(api_url)?.with_url(base_url.unwrap_or(api_url))? } else { builder.chain(chain)? From 8f97a3cf24b7170238521fff6d2b685d0cf1e511 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 5 Jan 2024 19:06:15 +0100 Subject: [PATCH 0440/1963] chore: bump foundry-compilers 0.1.3 (#6708) * chore: bump foundry-compilers 0.1.3 * fix api change --- Cargo.lock | 8 ++++---- crates/common/src/compile.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 714d6bb64f4b9..e8d4b1148696d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2635,9 +2635,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa44d981bf2493204dee4af1116ed9250656050d48b5569fa1e153fa4af75bdd" +checksum = "43408b384e5888fed99a5f25f86cef7e19dca10c750e948cbeb219f59847712f" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -2771,9 +2771,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82d3c3ef0ea3749b6e873c3f24e8bf6ead058757fa793de8940c03fc01bb83b" +checksum = "723188b46b06f9a9836a5c6e21a5cb97c12e7411c2104afffba06a6c2beee518" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 7690ddbc277de..eccf30d73786c 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -139,7 +139,7 @@ impl ProjectCompiler { if !files.is_empty() { project.compile_files(files) } else if let Some(filter) = filter { - project.compile_sparse(move |file: &_| filter.is_match(file)) + project.compile_sparse(Box::new(move |file: &_| filter.is_match(file))) } else { project.compile() } From c7b1c18472059c938de697d4fd72de9938527b48 Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Sat, 6 Jan 2024 03:28:19 +0800 Subject: [PATCH 0441/1963] feat: add rpc endpoint config (#6582) * feat: add rpc endpoint config * wip: add test for parse rpc config * feat: support setting additional rpc values --------- Co-authored-by: Matthias Seitz --- crates/chisel/src/dispatcher.rs | 2 +- crates/config/src/endpoints.rs | 247 +++++++++++++++++++++++++++++++- crates/config/src/lib.rs | 53 ++++++- 3 files changed, 295 insertions(+), 7 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 872e579f4104e..1344690fc8d4a 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -328,7 +328,7 @@ impl ChiselDispatcher { { endpoint.clone() } else { - RpcEndpoint::Env(arg.to_string()) + RpcEndpoint::Env(arg.to_string()).into() }; let fork_url = match endpoint.resolve() { Ok(fork_url) => fork_url, diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index d3e90702a6ce7..d482a329b663b 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -1,7 +1,7 @@ //! Support for multiple RPC-endpoints use crate::resolve::{interpolate, UnresolvedEnvVarError, RE_PLACEHOLDER}; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; use std::{ collections::BTreeMap, fmt, @@ -12,15 +12,28 @@ use std::{ #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(transparent)] pub struct RpcEndpoints { - endpoints: BTreeMap, + endpoints: BTreeMap, } // === impl RpcEndpoints === impl RpcEndpoints { /// Creates a new list of endpoints - pub fn new(endpoints: impl IntoIterator, RpcEndpoint)>) -> Self { - Self { endpoints: endpoints.into_iter().map(|(name, url)| (name.into(), url)).collect() } + pub fn new( + endpoints: impl IntoIterator, impl Into)>, + ) -> Self { + Self { + endpoints: endpoints + .into_iter() + .map(|(name, e)| match e.into() { + RpcEndpointType::String(url) => ( + name.into(), + RpcEndpointConfig { endpoint: url.into(), ..Default::default() }, + ), + RpcEndpointType::Config(config) => (name.into(), config), + }) + .collect(), + } } /// Returns `true` if this type doesn't contain any endpoints @@ -37,13 +50,73 @@ impl RpcEndpoints { } impl Deref for RpcEndpoints { - type Target = BTreeMap; + type Target = BTreeMap; fn deref(&self) -> &Self::Target { &self.endpoints } } +/// RPC endpoint wrapper type +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +#[serde(untagged)] +pub enum RpcEndpointType { + /// Raw Endpoint url string + String(RpcEndpoint), + /// Config object + Config(RpcEndpointConfig), +} + +impl RpcEndpointType { + /// Returns the string variant + pub fn as_endpoint_string(&self) -> Option<&RpcEndpoint> { + match self { + RpcEndpointType::String(url) => Some(url), + RpcEndpointType::Config(_) => None, + } + } + + /// Returns the config variant + pub fn as_endpoint_config(&self) -> Option<&RpcEndpointConfig> { + match self { + RpcEndpointType::Config(config) => Some(&config), + RpcEndpointType::String(_) => None, + } + } + + /// Returns the url or config this type holds + /// + /// # Error + /// + /// Returns an error if the type holds a reference to an env var and the env var is not set + pub fn resolve(self) -> Result { + match self { + RpcEndpointType::String(url) => url.resolve(), + RpcEndpointType::Config(config) => config.endpoint.resolve(), + } + } +} + +impl fmt::Display for RpcEndpointType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + RpcEndpointType::String(url) => url.fmt(f), + RpcEndpointType::Config(config) => config.fmt(f), + } + } +} + +impl TryFrom for String { + type Error = UnresolvedEnvVarError; + + fn try_from(value: RpcEndpointType) -> Result { + match value { + RpcEndpointType::String(url) => url.resolve(), + RpcEndpointType::Config(config) => config.endpoint.resolve(), + } + } +} + /// Represents a single endpoint /// /// This type preserves the value as it's stored in the config. If the value is a reference to an @@ -134,6 +207,133 @@ impl<'de> Deserialize<'de> for RpcEndpoint { } } +impl Into for RpcEndpoint { + fn into(self) -> RpcEndpointType { + RpcEndpointType::String(self) + } +} + +impl Into for RpcEndpoint { + fn into(self) -> RpcEndpointConfig { + RpcEndpointConfig { endpoint: self, ..Default::default() } + } +} + +/// Rpc endpoint configuration variant +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RpcEndpointConfig { + /// endpoint url or env + pub endpoint: RpcEndpoint, + + /// The number of retries. + pub retries: Option, + + /// Initial retry backoff. + pub retry_backoff: Option, + + /// The available compute units per second. + /// + /// See also + pub compute_units_per_second: Option, +} + +impl RpcEndpointConfig { + /// Returns the url this type holds, see [RpcEndpoints::resolve()] + pub fn resolve(self) -> Result { + self.endpoint.resolve() + } +} + +impl fmt::Display for RpcEndpointConfig { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let RpcEndpointConfig { endpoint, retries, retry_backoff, compute_units_per_second } = self; + + write!(f, "{}", endpoint)?; + + if let Some(retries) = retries { + write!(f, ", retries={}", retries)?; + } + + if let Some(retry_backoff) = retry_backoff { + write!(f, ", retry_backoff={}", retry_backoff)?; + } + + if let Some(compute_units_per_second) = compute_units_per_second { + write!(f, ", compute_units_per_second={}", compute_units_per_second)?; + } + + Ok(()) + } +} + +impl Serialize for RpcEndpointConfig { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + if self.retries.is_none() && + self.retry_backoff.is_none() && + self.compute_units_per_second.is_none() + { + // serialize as endpoint if there's no additional config + return self.endpoint.serialize(serializer); + } else { + let mut map = serializer.serialize_map(Some(4))?; + map.serialize_entry("endpoint", &self.endpoint)?; + map.serialize_entry("retries", &self.retries)?; + map.serialize_entry("retry_backoff", &self.retry_backoff)?; + map.serialize_entry("compute_units_per_second", &self.compute_units_per_second)?; + map.end() + } + } +} + +impl<'de> Deserialize<'de> for RpcEndpointConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value = serde_json::Value::deserialize(deserializer)?; + if value.is_string() { + return Ok(Self { + endpoint: serde_json::from_value(value).map_err(serde::de::Error::custom)?, + ..Default::default() + }); + } + + #[derive(Deserialize)] + struct RpcEndpointConfigInner { + #[serde(alias = "url")] + endpoint: RpcEndpoint, + retries: Option, + retry_backoff: Option, + compute_units_per_second: Option, + } + + let RpcEndpointConfigInner { endpoint, retries, retry_backoff, compute_units_per_second } = + serde_json::from_value(value).map_err(serde::de::Error::custom)?; + + Ok(RpcEndpointConfig { endpoint, retries, retry_backoff, compute_units_per_second }) + } +} + +impl Into for RpcEndpointConfig { + fn into(self) -> RpcEndpointType { + RpcEndpointType::Config(self) + } +} + +impl Default for RpcEndpointConfig { + fn default() -> Self { + Self { + endpoint: RpcEndpoint::Url("http://localhost:8545".to_string()), + retries: None, + retry_backoff: None, + compute_units_per_second: None, + } + } +} + /// Container type for _resolved_ endpoints, see [RpcEndpoints::resolve_all()] #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ResolvedRpcEndpoints { @@ -164,3 +364,40 @@ impl DerefMut for ResolvedRpcEndpoints { &mut self.endpoints } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn serde_rpc_config() { + let s = r#"{ + "endpoint": "http://localhost:8545", + "retries": 5, + "retry_backoff": 250, + "compute_units_per_second": 100 + }"#; + let config: RpcEndpointConfig = serde_json::from_str(s).unwrap(); + assert_eq!( + config, + RpcEndpointConfig { + endpoint: RpcEndpoint::Url("http://localhost:8545".to_string()), + retries: Some(5), + retry_backoff: Some(250), + compute_units_per_second: Some(100), + } + ); + + let s = "\"http://localhost:8545\""; + let config: RpcEndpointConfig = serde_json::from_str(s).unwrap(); + assert_eq!( + config, + RpcEndpointConfig { + endpoint: RpcEndpoint::Url("http://localhost:8545".to_string()), + retries: None, + retry_backoff: None, + compute_units_per_second: None, + } + ); + } +} diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d20eae044de45..618f55a1e8632 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2519,7 +2519,7 @@ mod tests { use super::*; use crate::{ cache::{CachedChains, CachedEndpoints}, - endpoints::RpcEndpoint, + endpoints::{RpcEndpoint, RpcEndpointConfig, RpcEndpointType}, etherscan::ResolvedEtherscanConfigs, fs_permissions::PathPermission, }; @@ -3120,6 +3120,57 @@ mod tests { }); } + #[test] + fn test_resolve_rpc_config() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [rpc_endpoints] + optimism = "https://example.com/" + mainnet = { endpoint = "${_CONFIG_MAINNET}", retries = 3, retry_backoff = 1000, compute_units_per_second = 1000 } + "#, + )?; + jail.set_env("_CONFIG_MAINNET", "https://eth-mainnet.alchemyapi.io/v2/123455"); + + let config = Config::load(); + assert_eq!( + RpcEndpoints::new([ + ( + "optimism", + RpcEndpointType::String(RpcEndpoint::Url( + "https://example.com/".to_string() + )) + ), + ( + "mainnet", + RpcEndpointType::Config(RpcEndpointConfig { + endpoint: RpcEndpoint::Env("${_CONFIG_MAINNET}".to_string()), + retries: Some(3), + retry_backoff: Some(1000), + compute_units_per_second: Some(1000), + }) + ), + ]), + config.rpc_endpoints + ); + + let resolved = config.rpc_endpoints.resolved(); + assert_eq!( + RpcEndpoints::new([ + ("optimism", RpcEndpoint::Url("https://example.com/".to_string())), + ( + "mainnet", + RpcEndpoint::Url("https://eth-mainnet.alchemyapi.io/v2/123455".to_string()) + ), + ]) + .resolved(), + resolved + ); + Ok(()) + }) + } + #[test] fn test_resolve_endpoints() { figment::Jail::expect_with(|jail| { From 8343e7d8ac08724238db1c014c325bba479ba587 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 6 Jan 2024 14:43:40 +0100 Subject: [PATCH 0442/1963] chore(deps): bump foundry-compilers (#6717) --- Cargo.lock | 8 ++++---- Cargo.toml | 5 ++--- crates/common/src/compile.rs | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8d4b1148696d..90023b16f5121 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2635,9 +2635,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43408b384e5888fed99a5f25f86cef7e19dca10c750e948cbeb219f59847712f" +checksum = "aa44d981bf2493204dee4af1116ed9250656050d48b5569fa1e153fa4af75bdd" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -2771,9 +2771,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723188b46b06f9a9836a5c6e21a5cb97c12e7411c2104afffba06a6c2beee518" +checksum = "1c9f9741733af2e2ff11f5671d57ba421948ca26addf4086e1d1c849f19b73dc" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 55a6e42e0bc67..3cbe17fa2e13e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,8 +123,8 @@ foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } -foundry-block-explorers = { version = "0.1.2", default-features = false } -foundry-compilers = { version = "0.1.2", default-features = false } +foundry-block-explorers = { version = "0.1.3", default-features = false } +foundry-compilers = { version = "0.1.4", default-features = false } ## revm # no default features to avoid c-kzg @@ -201,4 +201,3 @@ revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } - diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index eccf30d73786c..df3742dd84b80 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -139,7 +139,7 @@ impl ProjectCompiler { if !files.is_empty() { project.compile_files(files) } else if let Some(filter) = filter { - project.compile_sparse(Box::new(move |file: &_| filter.is_match(file))) + project.compile_sparse(filter) } else { project.compile() } From 02292f2d2caa547968bd039c06dc53d98b72bf39 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 7 Jan 2024 12:16:43 +0100 Subject: [PATCH 0443/1963] chore(deps): weekly `cargo update` (#6720) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating anyhow v1.0.78 -> v1.0.79 Updating async-trait v0.1.76 -> v0.1.77 Updating clang-sys v1.6.1 -> v1.7.0 Updating clap v4.4.12 -> v4.4.13 Updating clap_complete v4.4.5 -> v4.4.6 Updating cpufeatures v0.2.11 -> v0.2.12 Updating enumn v0.1.12 -> v0.1.13 Updating figment v0.10.12 -> v0.10.13 Updating ignore v0.4.21 -> v0.4.22 Updating libloading v0.7.4 -> v0.8.1 Updating pest v2.7.5 -> v2.7.6 Updating pest_derive v2.7.5 -> v2.7.6 Updating pest_generator v2.7.5 -> v2.7.6 Updating pest_meta v2.7.5 -> v2.7.6 Updating prettyplease v0.2.15 -> v0.2.16 Updating proc-macro2 v1.0.71 -> v1.0.76 Updating quote v1.0.33 -> v1.0.35 Updating secp256k1 v0.28.0 -> v0.28.1 Updating secp256k1-sys v0.9.1 -> v0.9.2 Updating semver v1.0.20 -> v1.0.21 Updating serde v1.0.193 -> v1.0.195 Updating serde_derive v1.0.193 -> v1.0.195 Updating serde_json v1.0.108 -> v1.0.111 Updating serde_path_to_error v0.1.14 -> v0.1.15 Updating serde_repr v0.1.17 -> v0.1.18 Updating syn v2.0.43 -> v2.0.48 Updating thiserror v1.0.53 -> v1.0.56 Updating thiserror-impl v1.0.53 -> v1.0.56 Updating winnow v0.5.31 -> v0.5.33 Co-authored-by: mattsse --- Cargo.lock | 218 ++++++++++++++++++++++++++--------------------------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 90023b16f5121..2d453fcd442fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,7 +165,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -183,7 +183,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.43", + "syn 2.0.48", "syn-solidity", "tiny-keccak", ] @@ -399,9 +399,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca87830a3e3fb156dc96cfbd31cb620265dd053be734723f22b760d6cc3c3051" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "arbitrary" @@ -575,18 +575,18 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] name = "async-trait" -version = "0.1.76" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531b97fb4cd3dfdce92c35dedbfdc1f0b9d8091c8ca943d6dae340ef5012d514" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -759,7 +759,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.43", + "syn 2.0.48", "which", ] @@ -968,7 +968,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "thiserror", @@ -1022,7 +1022,7 @@ dependencies = [ "rpassword", "rusoto_core", "rusoto_kms", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "tempfile", @@ -1086,7 +1086,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "serial_test", @@ -1151,9 +1151,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" dependencies = [ "glob", "libc", @@ -1162,9 +1162,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.12" +version = "4.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" +checksum = "52bdc885e4cacc7f7c9eedc1ef6da641603180c783c41a15c264944deeaab642" dependencies = [ "clap_builder", "clap_derive", @@ -1187,9 +1187,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.5" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51919c5608a32e34ea1d6be321ad070065e17613e168c5b6977024290f2630b" +checksum = "97aeaa95557bd02f23fbb662f981670c3d20c5a26e69f7354b28f57092437fcd" dependencies = [ "clap", ] @@ -1213,7 +1213,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1440,9 +1440,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -1698,7 +1698,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1933,13 +1933,13 @@ dependencies = [ [[package]] name = "enumn" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" +checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -2137,7 +2137,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.43", + "syn 2.0.48", "toml 0.8.8", "walkdir", ] @@ -2154,7 +2154,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -2179,7 +2179,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.43", + "syn 2.0.48", "tempfile", "thiserror", "tiny-keccak", @@ -2194,7 +2194,7 @@ dependencies = [ "chrono", "ethers-core", "reqwest", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "thiserror", @@ -2284,7 +2284,7 @@ dependencies = [ "rand 0.8.5", "rusoto_core", "rusoto_kms", - "semver 1.0.20", + "semver 1.0.21", "sha2 0.10.8", "spki", "thiserror", @@ -2313,7 +2313,7 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "sha2 0.10.8", @@ -2391,7 +2391,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -2438,9 +2438,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.12" +version = "0.10.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649f3e5d826594057e9a519626304d8da859ea8a0b18ce99500c586b8d45faee" +checksum = "7629b8c7bcd214a072c2c88b263b5bb3ceb54c34365d8c41c1665461aeae0993" dependencies = [ "atomic", "parking_lot", @@ -2564,7 +2564,7 @@ dependencies = [ "rayon", "regex", "reqwest", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "serial_test", @@ -2644,7 +2644,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "reqwest", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "thiserror", @@ -2757,7 +2757,7 @@ dependencies = [ "rand 0.8.5", "regex", "reqwest", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "tempfile", @@ -2793,7 +2793,7 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "sha2 0.10.8", @@ -2829,7 +2829,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "serde_regex", @@ -2928,7 +2928,7 @@ dependencies = [ "foundry-compilers", "foundry-evm-core", "revm", - "semver 1.0.20", + "semver 1.0.21", "tracing", ] @@ -2995,7 +2995,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -3127,7 +3127,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -3803,9 +3803,9 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747ad1b4ae841a78e8aba0d63adbfbeaea26b517b63705d47856b73015d27060" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ "crossbeam-deque", "globset", @@ -4163,12 +4163,12 @@ dependencies = [ [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ "cfg-if", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -4398,7 +4398,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -4659,7 +4659,7 @@ dependencies = [ "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -4763,7 +4763,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -4970,7 +4970,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -4996,9 +4996,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" dependencies = [ "memchr", "thiserror", @@ -5007,9 +5007,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" dependencies = [ "pest", "pest_generator", @@ -5017,22 +5017,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] name = "pest_meta" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" dependencies = [ "once_cell", "pest", @@ -5128,7 +5128,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -5166,7 +5166,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -5261,12 +5261,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -5328,9 +5328,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -5343,7 +5343,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", "version_check", "yansi 1.0.0-rc.1", ] @@ -5429,9 +5429,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -6000,7 +6000,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.20", + "semver 1.0.21", ] [[package]] @@ -6237,18 +6237,18 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acea373acb8c21ecb5a23741452acd2593ed44ee3d343e72baaa143bc89d0d5" +checksum = "3f622567e3b4b38154fb8190bcf6b160d7a4301d70595a49195b48c116007a27" dependencies = [ "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd97a086ec737e30053fd5c46f097465d25bb81dd3608825f65298c4c98be83" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" dependencies = [ "cc", ] @@ -6287,9 +6287,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" dependencies = [ "serde", ] @@ -6317,22 +6317,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -6348,9 +6348,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "indexmap", "itoa", @@ -6360,9 +6360,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +checksum = "ebd154a240de39fdebcf5775d2675c204d7c13cf39a4c697be6493c8e734337c" dependencies = [ "itoa", "serde", @@ -6380,13 +6380,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" +checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -6432,7 +6432,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -6705,7 +6705,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -6738,7 +6738,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "sha2 0.10.8", @@ -6755,7 +6755,7 @@ checksum = "aa64b5e8eecd3a8af7cfc311e29db31a268a62d5953233d3e8243ec77a71c4e3" dependencies = [ "build_const", "hex", - "semver 1.0.20", + "semver 1.0.21", "serde_json", "svm-rs", ] @@ -6773,9 +6773,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.43" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -6791,7 +6791,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -6908,22 +6908,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.53" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2cd5904763bad08ad5513ddbb12cf2ae273ca53fa9f68e843e236ec6dfccc09" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.53" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcf4a824cce0aeacd6f38ae6f24234c8e80d68632338ebaa1443b5df9e29e19" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -7037,7 +7037,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -7258,7 +7258,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -7624,7 +7624,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -7658,7 +7658,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8004,9 +8004,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.31" +version = "0.5.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" +checksum = "b7520bbdec7211caa7c4e682eb1fbe07abe20cee6756b6e00f537c82c11816aa" dependencies = [ "memchr", ] @@ -8084,7 +8084,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -8104,7 +8104,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] From d46bcb3ddc768b35da8d1d29f85886476f974128 Mon Sep 17 00:00:00 2001 From: Bjerg Date: Mon, 8 Jan 2024 14:48:19 +0100 Subject: [PATCH 0444/1963] refactor: migrate to alloy providers (#6219) * wip * fmt * wip * more wip * wip * wip * rebase stuff * more rebase stuff * wip * fmt * wip resolve warnings * wip * wip * wip * aaand cast started complaining gn * feat(`anvil`): RPC Types migration (#6256) * wip * fmt * wip * feat: start migrating basic types * more type changes across /eth and backend * wip type replacements * chore: replace mistaken type * feat: rpc types without pubsub migrated * chore: changes from rpc types * chore: re-add changes * feat: rpc types done, onto providers * we on that grind * feat: types migrated, tests remaining * chore: comment tests for now to get proper compile errors --------- Co-authored-by: Oliver Nordbjerg * fix latest rebase errors * chore: `alloy-transports` -> `alloy-transport` (#6341) * fix: use new `TransportResult` (#6342) * fix: `TransportResult` for multi wallet (#6343) * feat: use TransportError on Anvil (#6344) * fix: uncomment serde tests, fix genesis test (#6346) * refactor: split ethers/alloy providers (#6378) * split ethers/alloy providers * chore: complete Transaction ToAlloy compat trait * chore: clone txs --------- Co-authored-by: Enrique Ortiz * fix: block numbers are u64 (#6382) * fix: remove U64 cast (#6384) * chore(`anvil`): fix tests (#6383) * wip * chore: fix u64 * fix: access lists * chore: use latest ethers * silly ahhh otterscan test failing * more fixdy * almost done lesgo * pub sob * chre: fix otterscan test --------- Co-authored-by: Oliver Nordbjerg * fix(anvil): port serde helpers, remove multiline jsons (#6404) * chore(`anvil`): extend alloy types until entry lib, cleanup warnings (#6413) * chore: extend alloy types until entry lib, cleanup warnings * chore: fix review comments * chore: pin alloy providers to repo & test fixup (#6414) * chore: pin alloy providers to repo * chore: fix doctests * clippy * clippy * clippy * fix fixtures * update * feat: reimplement rpc cheatcode * chore: fix warnings * chore: fmt, switch to local tx request type in the meanwhile for optimism tests * [Alloy providers migration]: Fix tests (#6462) * fix: properly return tx-only blocks instead of full blocks * chore: fix up fork tests * chore: mine blocks first before getting tx receipt * clippy/fmt * clippy * clippy * chore: add more delta for timestamp test * chore: fix up anvil API tests (#6517) * chore: fix up anvil API tests * fmt * feat: `RuntimeTransport` for `ws`/`ipc` support (#6525) * wip * chore: change to using the naked transport instead of an RpcClient * chore: properly implement request * always poll ready * chore: docs * chore: clippy and other fixes * chore: use call to pass down the tower stack * chore: no unwraps * chore: new fn * feat: implement runtimetransport on the alloy provider builder * chore: refactor into separate functions depending on transport * feat: RuntimeTransportBuilder, refactor * feat: cleanup, docs * feat: IPC * clippy * cosmetics * feat: enable anvil ipc tests (#6570) * refactor: replace tracers with reth tracers (#6428) * wip * wip not working still -.- - gas reports - `forge script` cannot set `gas_used` for root trace since that requires mut access to the arena - event decoding not impl possibly broken - anvil traces (not tested) - test traces (not tested) - debugging (not tested) but hey, at least it compiles... * wip * chore: fix deps * remove utils import * chore: remove errors * chore: use render_trace_arena * derive debug * fix contract identification * fix formatting * remove stray todo * fix empty output * fix unrelated test :) --------- Co-authored-by: evalir * fix lockfile * chore: fix anvil test * fixup: missing import * chore: lint * fixup: imports * fixup: more fixes * chore: fmt * clippy clippy clippy always clippy * and fmt * test: fix test * chore: add todo * clippy * feat(`anvil`/`evm`): re-add support for additional fields (#6573) * feat: re-add additional fields support * chore: clippy/fmt * bump Cargo.lock * chore: handle mixhash being optional (#6575) * fix: always ensure prevrandao is set (#6576) * chore: cleanup, reintroduce trace endpoints (#6577) * feat: re-enable debug_traceTransaction support (#6583) * chore: fix ipc test * chore: re-enable trace tests (#6586) * refactor: rm unused param * refactor: rm gas adjustment in script This should be solved in the tracer inspector itself already, cc @mattsse * chore: fix ci failures (#6595) * chore: use self.debug instead of self.verbose * chore: update lock * chore: fix deny check * feat(`RuntimeTransport`): port cups/retry logic (#6594) * some random stuff * fmt: toml * chore: use u64 in BlockRequest::Number * update * chore: remove some more ethers * chore: more ethers removals (units) * wip: remove reth * wip * rm ice * fix(`rpc-types`): use newer `alloy-rpc-types`, `alloy-rpc-trace-types` (#6705) * fix(rpc-types): use newer alloy-rpc-types, alloy-rpc-trace-types and reth inspectors * chore: remove ToReth * chore: fix imports * chore: quicknode retry (#6712) * fix(`general`): get ci green on 6219 (#6711) * chore: update doctests * chore: update cargo lock to make anvil test pass * chore: bump cargo lock again * fix: parse unit logics (#6713) --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * chore: remove borrows * chore: add removal note * chore: use alloy chains to compare * chore: remove some conversions, migrate feemanager/newblocknotifications * chore: clippy * chore: fix doctests --------- Co-authored-by: evalir Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Matthias Seitz --- Cargo.lock | 1058 ++++++++++++++++- Cargo.toml | 32 +- crates/anvil/Cargo.toml | 6 + crates/anvil/core/Cargo.toml | 8 +- crates/anvil/core/src/eth/mod.rs | 195 +-- crates/anvil/core/src/eth/serde_helpers.rs | 57 + .../core/src/eth/transaction/ethers_compat.rs | 287 ++++- crates/anvil/core/src/eth/transaction/mod.rs | 44 +- crates/anvil/core/src/types.rs | 19 +- crates/anvil/src/cmd.rs | 12 +- crates/anvil/src/config.rs | 121 +- crates/anvil/src/eth/api.rs | 586 +++++---- crates/anvil/src/eth/backend/db.rs | 58 +- crates/anvil/src/eth/backend/executor.rs | 16 +- crates/anvil/src/eth/backend/fork.rs | 325 ++--- crates/anvil/src/eth/backend/genesis.rs | 29 +- crates/anvil/src/eth/backend/info.rs | 9 +- crates/anvil/src/eth/backend/mem/cache.rs | 10 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 27 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 75 +- crates/anvil/src/eth/backend/mem/inspector.rs | 13 +- crates/anvil/src/eth/backend/mem/mod.rs | 714 ++++++----- crates/anvil/src/eth/backend/mem/state.rs | 48 +- crates/anvil/src/eth/backend/mem/storage.rs | 164 ++- crates/anvil/src/eth/backend/notifications.rs | 4 +- crates/anvil/src/eth/error.rs | 7 + crates/anvil/src/eth/fees.rs | 38 +- crates/anvil/src/eth/miner.rs | 2 +- crates/anvil/src/eth/otterscan/api.rs | 56 +- crates/anvil/src/eth/otterscan/types.rs | 125 +- crates/anvil/src/eth/pool/mod.rs | 25 +- crates/anvil/src/eth/pool/transactions.rs | 37 +- crates/anvil/src/filter.rs | 10 +- crates/anvil/src/genesis.rs | 35 +- crates/anvil/src/lib.rs | 41 +- crates/anvil/src/pubsub.rs | 69 +- crates/anvil/src/server/handler.rs | 19 +- crates/anvil/tests/it/anvil.rs | 13 +- crates/anvil/tests/it/anvil_api.rs | 150 +-- crates/anvil/tests/it/api.rs | 70 +- crates/anvil/tests/it/fork.rs | 230 ++-- crates/anvil/tests/it/gas.rs | 27 +- crates/anvil/tests/it/genesis.rs | 11 +- crates/anvil/tests/it/ipc.rs | 11 +- crates/anvil/tests/it/logs.rs | 10 +- crates/anvil/tests/it/optimism.rs | 25 +- crates/anvil/tests/it/otterscan.rs | 194 +-- crates/anvil/tests/it/proof/mod.rs | 23 +- crates/anvil/tests/it/pubsub.rs | 21 +- crates/anvil/tests/it/sign.rs | 4 +- crates/anvil/tests/it/traces.rs | 26 +- crates/anvil/tests/it/transaction.rs | 85 +- crates/anvil/tests/it/txpool.rs | 2 +- crates/anvil/tests/it/wsapi.rs | 9 +- crates/cast/bin/cmd/call.rs | 8 +- crates/cast/bin/cmd/run.rs | 12 +- crates/cast/bin/cmd/storage.rs | 6 +- crates/cast/src/lib.rs | 107 +- crates/cheatcodes/Cargo.toml | 3 +- crates/cheatcodes/src/evm/fork.rs | 52 +- crates/cheatcodes/src/inspector.rs | 2 +- crates/chisel/src/dispatcher.rs | 7 +- crates/chisel/src/runner.rs | 5 +- crates/cli/src/opts/wallet/multi_wallet.rs | 18 +- crates/cli/src/utils/cmd.rs | 28 +- crates/cli/src/utils/mod.rs | 14 +- crates/common/Cargo.toml | 11 + crates/common/src/compile.rs | 6 +- crates/common/src/lib.rs | 3 +- crates/common/src/provider/alloy.rs | 318 +++++ .../src/{provider.rs => provider/ethers.rs} | 4 +- crates/common/src/provider/mod.rs | 7 + crates/common/src/provider/retry.rs | 104 ++ .../common/src/provider/runtime_transport.rs | 310 +++++ crates/common/src/provider/tower.rs | 192 +++ crates/common/src/runtime_client.rs | 4 +- crates/common/src/serde_helpers.rs | 129 ++ crates/common/src/types.rs | 90 +- crates/config/src/endpoints.rs | 29 +- crates/config/src/macros.rs | 6 +- crates/evm/core/Cargo.toml | 5 +- crates/evm/core/src/abi/console.rs | 8 +- crates/evm/core/src/backend/error.rs | 2 +- crates/evm/core/src/backend/mod.rs | 107 +- crates/evm/core/src/fork/backend.rs | 151 ++- crates/evm/core/src/fork/database.rs | 4 +- crates/evm/core/src/fork/init.rs | 56 +- crates/evm/core/src/fork/multi.rs | 28 +- crates/evm/core/src/opts.rs | 16 +- crates/evm/core/src/utils.rs | 48 +- crates/evm/evm/src/executors/mod.rs | 4 +- crates/evm/evm/src/inspectors/mod.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 18 +- crates/evm/fuzz/src/lib.rs | 1 + crates/evm/traces/Cargo.toml | 4 +- crates/evm/traces/src/decoder/mod.rs | 189 ++- crates/evm/traces/src/decoder/precompiles.rs | 20 +- crates/evm/traces/src/lib.rs | 660 +++------- crates/forge/bin/cmd/create.rs | 4 +- crates/forge/bin/cmd/inspect.rs | 3 + crates/forge/bin/cmd/script/broadcast.rs | 38 +- crates/forge/bin/cmd/script/cmd.rs | 12 +- crates/forge/bin/cmd/script/executor.rs | 28 +- crates/forge/bin/cmd/script/mod.rs | 45 +- crates/forge/bin/cmd/script/multi.rs | 4 +- crates/forge/bin/cmd/script/providers.rs | 6 +- crates/forge/bin/cmd/script/receipts.rs | 6 +- crates/forge/bin/cmd/script/runner.rs | 10 +- crates/forge/bin/cmd/script/transaction.rs | 8 +- crates/forge/bin/cmd/test/mod.rs | 90 +- crates/forge/src/gas_report.rs | 61 +- crates/forge/src/result.rs | 1 + crates/forge/tests/cli/multi_script.rs | 22 +- crates/forge/tests/cli/script.rs | 12 +- crates/forge/tests/it/config.rs | 21 +- crates/forge/tests/it/repros.rs | 21 +- crates/test-utils/src/script.rs | 3 +- deny.toml | 1 + 118 files changed, 5461 insertions(+), 3025 deletions(-) create mode 100644 crates/common/src/provider/alloy.rs rename crates/common/src/{provider.rs => provider/ethers.rs} (99%) create mode 100644 crates/common/src/provider/mod.rs create mode 100644 crates/common/src/provider/retry.rs create mode 100644 crates/common/src/provider/runtime_transport.rs create mode 100644 crates/common/src/provider/tower.rs create mode 100644 crates/common/src/serde_helpers.rs diff --git a/Cargo.lock b/Cargo.lock index 2d453fcd442fb..053e5c49a80cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,7 +82,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa1873637aa7f20369eae38b312cf7550c266d13ebc60f176fd5c82c5127810b" dependencies = [ - "num_enum", + "num_enum 0.7.1", "serde", "strum", ] @@ -120,6 +120,27 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-json-rpc" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-networks" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-json-rpc", + "alloy-primitives", + "alloy-rlp", +] + [[package]] name = "alloy-primitives" version = "0.5.4" @@ -146,6 +167,41 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "alloy-providers" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-networks", + "alloy-primitives", + "alloy-rpc-client", + "alloy-rpc-trace-types", + "alloy-rpc-types", + "alloy-transport", + "alloy-transport-http", + "async-trait", + "auto_impl", + "reqwest", + "serde", + "thiserror", +] + +[[package]] +name = "alloy-pubsub" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-json-rpc", + "alloy-primitives", + "alloy-transport", + "bimap", + "futures", + "serde_json", + "tokio", + "tower", + "tracing", +] + [[package]] name = "alloy-rlp" version = "0.3.4" @@ -168,6 +224,52 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "alloy-rpc-client" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "alloy-transport-http", + "futures", + "pin-project", + "reqwest", + "serde_json", + "tower", + "tracing", + "url", +] + +[[package]] +name = "alloy-rpc-trace-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-rpc-types", + "itertools 0.12.0", + "jsonrpsee-types", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "itertools 0.12.0", + "jsonrpsee-types", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "alloy-sol-macro" version = "0.5.4" @@ -178,7 +280,7 @@ dependencies = [ "const-hex", "dunce", "heck", - "indexmap", + "indexmap 2.1.0", "proc-macro-error", "proc-macro2", "quote", @@ -210,6 +312,69 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-transport" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-json-rpc", + "base64 0.21.5", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "url", + "wasm-bindgen-futures", +] + +[[package]] +name = "alloy-transport-http" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "reqwest", + "serde_json", + "tower", + "url", +] + +[[package]] +name = "alloy-transport-ipc" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-json-rpc", + "alloy-pubsub", + "alloy-transport", + "bytes", + "futures", + "interprocess", + "pin-project", + "serde_json", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "alloy-transport-ws" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +dependencies = [ + "alloy-pubsub", + "alloy-transport", + "futures", + "http", + "serde_json", + "tokio", + "tokio-tungstenite", + "tracing", + "ws_stream_wasm", +] + [[package]] name = "ammonia" version = "3.3.0" @@ -296,7 +461,12 @@ dependencies = [ name = "anvil" version = "0.2.0" dependencies = [ + "alloy-chains", "alloy-primitives", + "alloy-providers", + "alloy-rpc-trace-types", + "alloy-rpc-types", + "alloy-transport", "anvil-core", "anvil-rpc", "anvil-server", @@ -314,6 +484,7 @@ dependencies = [ "ethers", "ethers-core", "ethers-solc", + "eyre", "fdlimit", "flate2", "foundry-common", @@ -347,6 +518,8 @@ name = "anvil-core" version = "0.2.0" dependencies = [ "alloy-primitives", + "alloy-rpc-trace-types", + "alloy-rpc-types", "anvil-core", "bytes", "ethers-contract", @@ -558,13 +731,37 @@ dependencies = [ "term", ] +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-lock" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +dependencies = [ + "event-listener 4.0.0", + "event-listener-strategy", + "pin-project-lite", +] + [[package]] name = "async-priority-channel" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c21678992e1b21bebfe2bc53ab5f5f68c106eddab31b24e0bb06e9b715a86640" dependencies = [ - "event-listener", + "event-listener 2.5.3", ] [[package]] @@ -578,6 +775,12 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "async-task" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" + [[package]] name = "async-trait" version = "0.1.77" @@ -615,6 +818,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "aurora-engine-modexp" version = "1.0.0" @@ -740,6 +949,21 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +dependencies = [ + "serde", +] + +[[package]] +name = "bimap" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" + [[package]] name = "bindgen" version = "0.66.1" @@ -825,6 +1049,22 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel", + "async-lock", + "async-task", + "fastrand", + "futures-io", + "futures-lite", + "piper", + "tracing", +] + [[package]] name = "blst" version = "0.3.11" @@ -837,6 +1077,144 @@ dependencies = [ "zeroize", ] +[[package]] +name = "boa_ast" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73498e9b2f0aa7db74977afa4d594657611e90587abf0dd564c0b55b4a130163" +dependencies = [ + "bitflags 2.4.1", + "boa_interner", + "boa_macros", + "indexmap 2.1.0", + "num-bigint", + "rustc-hash", +] + +[[package]] +name = "boa_engine" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16377479d5d6d33896e7acdd1cc698d04a8f72004025bbbddf47558cd29146a6" +dependencies = [ + "bitflags 2.4.1", + "boa_ast", + "boa_gc", + "boa_icu_provider", + "boa_interner", + "boa_macros", + "boa_parser", + "boa_profiler", + "chrono", + "dashmap", + "fast-float", + "icu_normalizer", + "indexmap 2.1.0", + "itertools 0.11.0", + "num-bigint", + "num-integer", + "num-traits", + "num_enum 0.6.1", + "once_cell", + "pollster", + "rand 0.8.5", + "regress", + "rustc-hash", + "ryu-js", + "serde", + "serde_json", + "sptr", + "static_assertions", + "tap", + "thin-vec", + "thiserror", +] + +[[package]] +name = "boa_gc" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c97b44beaef9d4452342d117d94607fdfa8d474280f1ba0fd97853834e3a49b2" +dependencies = [ + "boa_macros", + "boa_profiler", + "thin-vec", +] + +[[package]] +name = "boa_icu_provider" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30e52e34e451dd0bfc2c654a9a43ed34b0073dbd4ae3394b40313edda8627aa" +dependencies = [ + "icu_collections", + "icu_normalizer", + "icu_properties", + "icu_provider", + "icu_provider_adapters", + "icu_provider_blob", + "once_cell", +] + +[[package]] +name = "boa_interner" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e5afa991908cfbe79bd3109b824e473a1dc5f74f31fab91bb44c9e245daa77" +dependencies = [ + "boa_gc", + "boa_macros", + "hashbrown 0.14.3", + "indexmap 2.1.0", + "once_cell", + "phf 0.11.2", + "rustc-hash", + "static_assertions", +] + +[[package]] +name = "boa_macros" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "005fa0c5bd20805466dda55eb34cd709bb31a2592bb26927b47714eeed6914d8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "synstructure 0.13.0", +] + +[[package]] +name = "boa_parser" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e09afb035377a9044443b598187a7d34cd13164617182a4d7c348522ee3f052" +dependencies = [ + "bitflags 2.4.1", + "boa_ast", + "boa_icu_provider", + "boa_interner", + "boa_macros", + "boa_profiler", + "fast-float", + "icu_locid", + "icu_properties", + "icu_provider", + "icu_provider_macros", + "num-bigint", + "num-traits", + "once_cell", + "regress", + "rustc-hash", + "tinystr", +] + +[[package]] +name = "boa_profiler" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190f92dfe48224adc92881c620f08ccf37ff62b91a094bb357fe53bd5e84647" + [[package]] name = "bs58" version = "0.5.0" @@ -1246,6 +1624,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + [[package]] name = "coins-bip32" version = "0.8.7" @@ -1378,6 +1762,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "concurrent-queue" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.7" @@ -1518,6 +1911,12 @@ dependencies = [ "itertools 0.10.5", ] +[[package]] +name = "critical-section" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" + [[package]] name = "crossbeam-channel" version = "0.5.10" @@ -1641,6 +2040,41 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.48", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.48", +] + [[package]] name = "dashmap" version = "5.5.3" @@ -1677,6 +2111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -1814,6 +2249,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -1883,6 +2329,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + [[package]] name = "ena" version = "0.14.2" @@ -2171,7 +2623,7 @@ dependencies = [ "ethabi", "generic-array", "k256", - "num_enum", + "num_enum 0.7.1", "once_cell", "open-fastrlp", "rand 0.8.5", @@ -2193,6 +2645,7 @@ source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a68 dependencies = [ "chrono", "ethers-core", + "ethers-solc", "reqwest", "semver 1.0.21", "serde", @@ -2335,6 +2788,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", + "pin-project-lite", +] + [[package]] name = "evm-disassembler" version = "0.3.0" @@ -2364,6 +2838,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fast-float" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" + [[package]] name = "fastrand" version = "2.0.1" @@ -2658,10 +3138,11 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-providers", + "alloy-rpc-types", "alloy-sol-types", "const-hex", "ethers-core", - "ethers-providers", "ethers-signers", "eyre", "foundry-cheatcodes-spec", @@ -2735,8 +3216,17 @@ version = "0.2.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", + "alloy-json-rpc", "alloy-primitives", + "alloy-providers", + "alloy-pubsub", + "alloy-rpc-client", + "alloy-rpc-types", "alloy-sol-types", + "alloy-transport", + "alloy-transport-http", + "alloy-transport-ipc", + "alloy-transport-ws", "async-trait", "clap", "comfy-table", @@ -2763,6 +3253,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", + "tower", "tracing", "url", "walkdir", @@ -2894,11 +3385,14 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-providers", + "alloy-rpc-types", "alloy-sol-types", + "alloy-transport", "const-hex", "derive_more", + "ethers", "ethers-core", - "ethers-providers", "eyre", "foundry-cheatcodes-spec", "foundry-common", @@ -2968,7 +3462,6 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "const-hex", - "ethers-core", "eyre", "foundry-block-explorers", "foundry-common", @@ -2980,7 +3473,7 @@ dependencies = [ "itertools 0.11.0", "once_cell", "ordered-float", - "revm", + "reth-revm-inspectors", "serde", "tempfile", "tokio", @@ -3109,6 +3602,16 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +[[package]] +name = "futures-lite" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +dependencies = [ + "futures-core", + "pin-project-lite", +] + [[package]] name = "futures-locks" version = "0.7.1" @@ -3504,7 +4007,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -3555,6 +4058,15 @@ dependencies = [ "ahash 0.7.7", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.7", +] + [[package]] name = "hashbrown" version = "0.14.3" @@ -3791,6 +4303,128 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8302d8dfd6044d3ddb3f807a5ef3d7bbca9a574959c6d6e4dc39aa7012d0d5" +dependencies = [ + "displaydoc", + "serde", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3003f85dccfc0e238ff567693248c59153a46f4e6125ba4020b973cef4d1d335" +dependencies = [ + "displaydoc", + "litemap", + "serde", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "652869735c9fb9f5a64ba180ee16f2c848390469c116deef517ecc53f4343598" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_properties", + "icu_provider", + "serde", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_properties" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce0e1aa26851f16c9e04412a5911c86b7f8768dac8f8d4c5f1c568a7e5d7a434" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_provider", + "serde", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_provider" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc312a7b6148f7dfe098047ae2494d12d4034f48ade58d4f353000db376e305" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "postcard", + "serde", + "stable_deref_trait", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_adapters" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ae1e2bd0c41728b77e7c46e9afdec5e2127d1eedacc684724667d50c126bd3" +dependencies = [ + "icu_locid", + "icu_provider", + "serde", + "tinystr", + "yoke", + "zerovec", +] + +[[package]] +name = "icu_provider_blob" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd364c9a01f791a4bc04a74cf2a1d01d9f6926a40fd5ae1c28004e1e70d8338b" +dependencies = [ + "icu_provider", + "postcard", + "serde", + "writeable", + "yoke", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b728b9421e93eff1d9f8681101b78fa745e0748c95c655c83f337044a7e10" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -3879,6 +4513,17 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + [[package]] name = "indexmap" version = "2.1.0" @@ -3887,6 +4532,7 @@ checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.3", + "serde", ] [[package]] @@ -3940,18 +4586,45 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array", + "generic-array", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", ] [[package]] -name = "instant" -version = "0.1.12" +name = "interprocess" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "81f2533f3be42fffe3b5e63b71aeca416c1c3bc33e4e27be018521e76b1f38fb" dependencies = [ + "blocking", "cfg-if", + "futures-core", + "futures-io", + "intmap", + "libc", + "once_cell", + "rustc_version 0.4.0", + "spinning", + "thiserror", + "to_method", + "tokio", + "winapi", ] +[[package]] +name = "intmap" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae52f28f45ac2bc96edb7714de995cffc174a395fb0abf5bff453587c980d7b9" + [[package]] name = "ipnet" version = "2.9.0" @@ -3987,6 +4660,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -4022,6 +4704,20 @@ dependencies = [ "serde_json", ] +[[package]] +name = "jsonrpsee-types" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" +dependencies = [ + "anyhow", + "beef", + "serde", + "serde_json", + "thiserror", + "tracing", +] + [[package]] name = "jsonwebtoken" version = "8.3.0" @@ -4218,6 +4914,12 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +[[package]] +name = "litemap" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d642685b028806386b2b6e75685faadd3eb65a85fff7df711ce18446a422da" + [[package]] name = "lock_api" version = "0.4.11" @@ -4577,6 +5279,7 @@ dependencies = [ "autocfg", "num-integer", "num-traits", + "serde", ] [[package]] @@ -4641,13 +5344,34 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" +dependencies = [ + "num_enum_derive 0.6.1", +] + [[package]] name = "num_enum" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" dependencies = [ - "num_enum_derive", + "num_enum_derive 0.7.1", +] + +[[package]] +name = "num_enum_derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.48", ] [[package]] @@ -4691,6 +5415,10 @@ name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +dependencies = [ + "critical-section", + "portable-atomic", +] [[package]] name = "oorandom" @@ -4873,9 +5601,15 @@ checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ "proc-macro2", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + [[package]] name = "parking_lot" version = "0.12.1" @@ -5046,7 +5780,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.1.0", ] [[package]] @@ -5181,6 +5915,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -5225,12 +5970,29 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "pollster" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" + [[package]] name = "portable-atomic" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +[[package]] +name = "postcard" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +dependencies = [ + "cobs", + "embedded-io", + "serde", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -5654,6 +6416,16 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "regress" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a9ecfa0cb04d0b04dddb99b8ccf4f66bc8dfd23df694b398570bd8ae3a50fb" +dependencies = [ + "hashbrown 0.13.2", + "memchr", +] + [[package]] name = "reqwest" version = "0.11.23" @@ -5698,6 +6470,43 @@ dependencies = [ "winreg", ] +[[package]] +name = "reth-revm-inspectors" +version = "0.1.0-alpha.13" +source = "git+https://github.com/paradigmxyz/reth/?branch=main#8b56f50f3e326c1ef861ac3899dffd7f8a533c94" +dependencies = [ + "alloy-primitives", + "alloy-sol-types", + "boa_engine", + "boa_gc", + "reth-rpc-types", + "revm", + "serde", + "serde_json", + "thiserror", + "tokio", +] + +[[package]] +name = "reth-rpc-types" +version = "0.1.0-alpha.13" +source = "git+https://github.com/paradigmxyz/reth/?branch=main#8b56f50f3e326c1ef861ac3899dffd7f8a533c94" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-rpc-trace-types", + "alloy-rpc-types", + "bytes", + "itertools 0.12.0", + "jsonrpsee-types", + "secp256k1 0.27.0", + "serde", + "serde_json", + "serde_with", + "thiserror", + "url", +] + [[package]] name = "revm" version = "3.5.0" @@ -5730,7 +6539,7 @@ dependencies = [ "once_cell", "revm-primitives", "ripemd", - "secp256k1", + "secp256k1 0.28.1", "sha2 0.10.8", "substrate-bn", ] @@ -6118,6 +6927,12 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +[[package]] +name = "ryu-js" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6518fc26bced4d53678a22d6e423e9d8716377def84545fe328236e3af070e7f" + [[package]] name = "salsa20" version = "0.10.2" @@ -6235,13 +7050,32 @@ dependencies = [ "zeroize", ] +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "rand 0.8.5", + "secp256k1-sys 0.8.1", +] + [[package]] name = "secp256k1" version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f622567e3b4b38154fb8190bcf6b160d7a4301d70595a49195b48c116007a27" dependencies = [ - "secp256k1-sys", + "secp256k1-sys 0.9.2", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", ] [[package]] @@ -6352,7 +7186,7 @@ version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ - "indexmap", + "indexmap 2.1.0", "itoa", "ryu", "serde", @@ -6410,6 +7244,35 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" +dependencies = [ + "base64 0.21.5", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.1.0", + "serde", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "serial_test" version = "2.0.0" @@ -6632,6 +7495,15 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spinning" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d4f0e86297cad2658d92a707320d87bf4e6ae1050287f51d19b67ef3f153a7b" +dependencies = [ + "lock_api", +] + [[package]] name = "spki" version = "0.7.3" @@ -6642,6 +7514,18 @@ dependencies = [ "der", ] +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -6812,6 +7696,18 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "unicode-xid", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -6906,6 +7802,12 @@ dependencies = [ "phf_codegen 0.11.2", ] +[[package]] +name = "thin-vec" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" + [[package]] name = "thiserror" version = "1.0.56" @@ -6985,6 +7887,17 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8faa444297615a4e020acb64146b0603c9c395c03a97c17fd9028816d3b4d63e" +dependencies = [ + "displaydoc", + "serde", + "zerovec", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -7010,6 +7923,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "to_method" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c4ceeeca15c8384bbc3e011dbd8fccb7f068a440b752b7d9b32ceb0ca0e2e8" + [[package]] name = "tokio" version = "1.35.1" @@ -7107,6 +8026,7 @@ checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", + "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -7128,7 +8048,7 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ - "indexmap", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -7150,7 +8070,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap", + "indexmap 2.1.0", "toml_datetime", "winnow", ] @@ -7161,7 +8081,7 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap", + "indexmap 2.1.0", "toml_datetime", "winnow", ] @@ -7172,7 +8092,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -7517,6 +8437,18 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.1" @@ -8021,6 +8953,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad7bb64b8ef9c0aa27b6da38b452b0ee9fd82beaf276a87dd796fb55cbae14e" + [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -8067,6 +9011,30 @@ version = "1.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" +[[package]] +name = "yoke" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65e71b2e4f287f467794c671e2b8f8a5f3716b3c829079a1c44740148eff07e4" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e6936f0cce458098a201c245a11bef556c6a0181129c7034d10d76d1ec3a2b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "synstructure 0.13.0", +] + [[package]] name = "zerocopy" version = "0.7.32" @@ -8087,6 +9055,27 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "zerofrom" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655b0814c5c0b19ade497851070c640773304939a6c0fd5f5fb43da0696d05b7" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6a647510471d372f2e6c2e6b7219e44d8c574d24fdc11c610a61455782f18c3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", + "synstructure 0.13.0", +] + [[package]] name = "zeroize" version = "1.7.0" @@ -8107,6 +9096,29 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "zerovec" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "591691014119b87047ead4dcf3e6adfbf73cb7c38ab6980d4f18a32138f35d46" +dependencies = [ + "serde", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a4a1638a1934450809c2266a70362bfc96cd90550c073f5b8a55014d1010157" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "zip" version = "0.6.6" diff --git a/Cargo.toml b/Cargo.toml index 3cbe17fa2e13e..e166bc65adf0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,6 +123,7 @@ foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } +# solc & compilation utilities foundry-block-explorers = { version = "0.1.3", default-features = false } foundry-compilers = { version = "0.1.4", default-features = false } @@ -142,10 +143,20 @@ ethers-middleware = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy -alloy-primitives = "0.5.0" -alloy-dyn-abi = "0.5.0" -alloy-json-abi = "0.5.0" -alloy-sol-types = "0.5.0" +alloy-providers = "0.1.0" +alloy-transport = "0.1.0" +alloy-transport-http = "0.1.0" +alloy-transport-ws = "0.1.0" +alloy-transport-ipc = "0.1.0" +alloy-rpc-types = "0.1.0" +alloy-rpc-trace-types = "0.1.0" +alloy-json-rpc = "0.1.0" +alloy-pubsub = "0.1.0" +alloy-rpc-client = "0.1.0" +alloy-primitives = "0.5.1" +alloy-dyn-abi = "0.5.1" +alloy-json-abi = "0.5.1" +alloy-sol-types = "0.5.1" syn-solidity = "0.5.0" alloy-chains = "0.1.5" @@ -197,7 +208,18 @@ ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194 ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +alloy-providers = { git = "https://github.com/alloy-rs/alloy/" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy/" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy/" } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy/" } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy/" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy/" } +alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy/" } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy/" } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy/" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy/" } + revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } +revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } -revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index dbced4c69d71f..8db3dc7250530 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -36,6 +36,11 @@ trie-db = "0.23" hash-db = "0.15" memory-db = "0.29" alloy-primitives = { workspace = true, features = ["serde"] } +alloy-rpc-types.workspace = true +alloy-rpc-trace-types.workspace = true +alloy-providers.workspace = true +alloy-transport.workspace = true +alloy-chains.workspace = true # axum related axum.workspace = true @@ -62,6 +67,7 @@ yansi = "0.5" tempfile = "3" itertools.workspace = true rand = "0.8" +eyre.workspace = true # cli clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 91d86986da824..6828bb9f79363 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -12,9 +12,11 @@ repository.workspace = true [dependencies] foundry-common.workspace = true foundry-evm.workspace = true +revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } alloy-primitives = { workspace = true, features = ["serde"] } -revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } +alloy-rpc-types = { workspace = true } +alloy-rpc-trace-types.workspace = true ethers-core = { workspace = true, features = ["optimism"] } # theses are not used by anvil-core, but are required by ethers, because pulled in via foundry-common ethers-contract = { workspace = true, features = ["optimism"] } @@ -23,7 +25,7 @@ ethers-middleware = { workspace = true, features = ["optimism"] } serde = { workspace = true, optional = true } serde_json.workspace = true -bytes = { version = "1.4" } +bytes = "1.4" open-fastrlp = { version = "0.1.4", optional = true } # trie @@ -40,4 +42,4 @@ anvil-core = { path = ".", features = ["serde"] } default = ["serde"] impersonated-tx = [] fastrlp = ["dep:open-fastrlp"] -serde = ["dep:serde"] \ No newline at end of file +serde = ["dep:serde"] diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index e8b793a786c4c..dbe28104a7a36 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -1,18 +1,15 @@ -use self::state::StateOverride; use crate::{ - eth::{ - subscription::{SubscriptionId, SubscriptionKind, SubscriptionParams}, - transaction::EthTransactionRequest, - }, + eth::subscription::SubscriptionId, types::{EvmMineOptions, Forking, Index}, }; -use ethers_core::{ - abi::ethereum_types::H64, - types::{ - transaction::eip712::TypedData, Address, BlockId, BlockNumber, Bytes, Filter, - GethDebugTracingOptions, TxHash, H256, U256, - }, +use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256}; +use alloy_rpc_trace_types::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}; +use alloy_rpc_types::{ + pubsub::{Params as SubscriptionParams, SubscriptionKind}, + state::StateOverride, + BlockId, BlockNumberOrTag as BlockNumber, CallRequest, Filter, }; +use ethers_core::types::transaction::eip712::TypedData; pub mod block; pub mod proof; @@ -27,10 +24,13 @@ pub mod utils; pub mod serde_helpers; #[cfg(feature = "serde")] -use ethers_core::types::serde_helpers::*; +use self::serde_helpers::*; +use self::transaction::EthTransactionRequest; #[cfg(feature = "serde")] -use self::serde_helpers::*; +use foundry_common::serde_helpers::{ + deserialize_number, deserialize_number_opt, deserialize_number_seq, +}; /// Wrapper type that ensures the type is named `params` #[derive(Clone, Debug, PartialEq, Eq)] @@ -88,11 +88,14 @@ pub enum EthRequest { EthGetStorageAt(Address, U256, Option), #[cfg_attr(feature = "serde", serde(rename = "eth_getBlockByHash"))] - EthGetBlockByHash(H256, bool), + EthGetBlockByHash(B256, bool), #[cfg_attr(feature = "serde", serde(rename = "eth_getBlockByNumber"))] EthGetBlockByNumber( - #[cfg_attr(feature = "serde", serde(deserialize_with = "lenient_block_number"))] + #[cfg_attr( + feature = "serde", + serde(deserialize_with = "lenient_block_number::lenient_block_number") + )] BlockNumber, bool, ), @@ -104,13 +107,13 @@ pub enum EthRequest { feature = "serde", serde(rename = "eth_getBlockTransactionCountByHash", with = "sequence") )] - EthGetTransactionCountByHash(H256), + EthGetTransactionCountByHash(B256), #[cfg_attr( feature = "serde", serde( rename = "eth_getBlockTransactionCountByNumber", - deserialize_with = "lenient_block_number_seq" + deserialize_with = "lenient_block_number::lenient_block_number_seq" ) )] EthGetTransactionCountByNumber(BlockNumber), @@ -119,13 +122,13 @@ pub enum EthRequest { feature = "serde", serde(rename = "eth_getUncleCountByBlockHash", with = "sequence") )] - EthGetUnclesCountByHash(H256), + EthGetUnclesCountByHash(B256), #[cfg_attr( feature = "serde", serde( rename = "eth_getUncleCountByBlockNumber", - deserialize_with = "lenient_block_number_seq" + deserialize_with = "lenient_block_number::lenient_block_number_seq" ) )] EthGetUnclesCountByNumber(BlockNumber), @@ -136,7 +139,7 @@ pub enum EthRequest { /// Returns the account and storage values of the specified account including the Merkle-proof. /// This call can be used to verify that the data you are pulling from is not tampered with. #[cfg_attr(feature = "serde", serde(rename = "eth_getProof"))] - EthGetProof(Address, Vec, Option), + EthGetProof(Address, Vec, Option), /// The sign method calculates an Ethereum specific signature with: #[cfg_attr(feature = "serde", serde(rename = "eth_sign"))] @@ -165,22 +168,19 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "eth_call"))] EthCall( - EthTransactionRequest, + CallRequest, #[cfg_attr(feature = "serde", serde(default))] Option, #[cfg_attr(feature = "serde", serde(default))] Option, ), #[cfg_attr(feature = "serde", serde(rename = "eth_createAccessList"))] EthCreateAccessList( - EthTransactionRequest, + CallRequest, #[cfg_attr(feature = "serde", serde(default))] Option, ), #[cfg_attr(feature = "serde", serde(rename = "eth_estimateGas"))] - EthEstimateGas( - EthTransactionRequest, - #[cfg_attr(feature = "serde", serde(default))] Option, - ), + EthEstimateGas(CallRequest, #[cfg_attr(feature = "serde", serde(default))] Option), #[cfg_attr(feature = "serde", serde(rename = "eth_getTransactionByHash", with = "sequence"))] EthGetTransactionByHash(TxHash), @@ -189,21 +189,20 @@ pub enum EthRequest { EthGetTransactionByBlockHashAndIndex(TxHash, Index), #[cfg_attr(feature = "serde", serde(rename = "eth_getTransactionByBlockNumberAndIndex"))] - EthGetTransactionByBlockNumberAndIndex( - #[cfg_attr(feature = "serde", serde(deserialize_with = "lenient_block_number"))] - BlockNumber, - Index, - ), + EthGetTransactionByBlockNumberAndIndex(BlockNumber, Index), #[cfg_attr(feature = "serde", serde(rename = "eth_getTransactionReceipt", with = "sequence"))] - EthGetTransactionReceipt(H256), + EthGetTransactionReceipt(B256), #[cfg_attr(feature = "serde", serde(rename = "eth_getUncleByBlockHashAndIndex"))] - EthGetUncleByBlockHashAndIndex(H256, Index), + EthGetUncleByBlockHashAndIndex(B256, Index), #[cfg_attr(feature = "serde", serde(rename = "eth_getUncleByBlockNumberAndIndex"))] EthGetUncleByBlockNumberAndIndex( - #[cfg_attr(feature = "serde", serde(deserialize_with = "lenient_block_number"))] + #[cfg_attr( + feature = "serde", + serde(deserialize_with = "lenient_block_number::lenient_block_number") + )] BlockNumber, Index, ), @@ -244,10 +243,10 @@ pub enum EthRequest { EthGetWork(()), #[cfg_attr(feature = "serde", serde(rename = "eth_submitWork"))] - EthSubmitWork(H64, H256, H256), + EthSubmitWork(B64, B256, B256), #[cfg_attr(feature = "serde", serde(rename = "eth_submitHashrate"))] - EthSubmitHashRate(U256, H256), + EthSubmitHashRate(U256, B256), #[cfg_attr(feature = "serde", serde(rename = "eth_feeHistory"))] EthFeeHistory( @@ -262,26 +261,29 @@ pub enum EthRequest { /// geth's `debug_traceTransaction` endpoint #[cfg_attr(feature = "serde", serde(rename = "debug_traceTransaction"))] DebugTraceTransaction( - H256, + B256, #[cfg_attr(feature = "serde", serde(default))] GethDebugTracingOptions, ), /// geth's `debug_traceCall` endpoint #[cfg_attr(feature = "serde", serde(rename = "debug_traceCall"))] DebugTraceCall( - EthTransactionRequest, + CallRequest, #[cfg_attr(feature = "serde", serde(default))] Option, - #[cfg_attr(feature = "serde", serde(default))] GethDebugTracingOptions, + #[cfg_attr(feature = "serde", serde(default))] GethDefaultTracingOptions, ), /// Trace transaction endpoint for parity's `trace_transaction` #[cfg_attr(feature = "serde", serde(rename = "trace_transaction", with = "sequence"))] - TraceTransaction(H256), + TraceTransaction(B256), /// Trace transaction endpoint for parity's `trace_block` #[cfg_attr( feature = "serde", - serde(rename = "trace_block", deserialize_with = "lenient_block_number_seq") + serde( + rename = "trace_block", + deserialize_with = "lenient_block_number::lenient_block_number_seq" + ) )] TraceBlock(BlockNumber), @@ -363,7 +365,7 @@ pub enum EthRequest { with = "sequence" ) )] - DropTransaction(H256), + DropTransaction(B256), /// Reset the fork to a fresh forked state, and optionally update the fork config #[cfg_attr(feature = "serde", serde(rename = "anvil_reset", alias = "hardhat_reset"))] @@ -411,7 +413,7 @@ pub enum EthRequest { /// slot U256, /// value - H256, + B256, ), /// Sets the coinbase address @@ -622,7 +624,10 @@ pub enum EthRequest { /// Related upstream issue: https://github.com/otterscan/otterscan/issues/1081 #[cfg_attr(feature = "serde", serde(rename = "erigon_getHeaderByNumber"))] ErigonGetHeaderByNumber( - #[cfg_attr(feature = "serde", serde(deserialize_with = "lenient_block_number_seq"))] + #[cfg_attr( + feature = "serde", + serde(deserialize_with = "lenient_block_number::lenient_block_number_seq") + )] BlockNumber, ), @@ -635,26 +640,29 @@ pub enum EthRequest { /// Traces internal ETH transfers, contracts creation (CREATE/CREATE2) and self-destructs for a /// certain transaction. #[cfg_attr(feature = "serde", serde(rename = "ots_getInternalOperations", with = "sequence"))] - OtsGetInternalOperations(H256), + OtsGetInternalOperations(B256), /// Otterscan's `ots_hasCode` endpoint /// Check if an ETH address contains code at a certain block number. #[cfg_attr(feature = "serde", serde(rename = "ots_hasCode"))] OtsHasCode( Address, - #[cfg_attr(feature = "serde", serde(deserialize_with = "lenient_block_number", default))] + #[cfg_attr( + feature = "serde", + serde(deserialize_with = "lenient_block_number::lenient_block_number", default) + )] BlockNumber, ), /// Otterscan's `ots_traceTransaction` endpoint /// Trace a transaction and generate a trace call tree. #[cfg_attr(feature = "serde", serde(rename = "ots_traceTransaction", with = "sequence"))] - OtsTraceTransaction(H256), + OtsTraceTransaction(B256), /// Otterscan's `ots_getTransactionError` endpoint /// Given a transaction hash, returns its raw revert reason. #[cfg_attr(feature = "serde", serde(rename = "ots_getTransactionError", with = "sequence"))] - OtsGetTransactionError(H256), + OtsGetTransactionError(B256), /// Otterscan's `ots_getBlockDetails` endpoint /// Given a block number, return its data. Similar to the standard eth_getBlockByNumber/Hash @@ -662,14 +670,17 @@ pub enum EthRequest { /// logBloom #[cfg_attr(feature = "serde", serde(rename = "ots_getBlockDetails"))] OtsGetBlockDetails( - #[cfg_attr(feature = "serde", serde(deserialize_with = "lenient_block_number_seq"))] + #[cfg_attr( + feature = "serde", + serde(deserialize_with = "lenient_block_number::lenient_block_number", default) + )] BlockNumber, ), /// Otterscan's `ots_getBlockDetails` endpoint /// Same as `ots_getBlockDetails`, but receiving a block hash instead of number #[cfg_attr(feature = "serde", serde(rename = "ots_getBlockDetailsByHash", with = "sequence"))] - OtsGetBlockDetailsByHash(H256), + OtsGetBlockDetailsByHash(B256), /// Otterscan's `ots_getBlockTransactions` endpoint /// Gets paginated transaction data for a certain block. Return data is similar to @@ -806,14 +817,16 @@ mod tests { #[test] fn test_custom_impersonate_account() { - let s = r#"{"method": "anvil_impersonateAccount", "params": ["0xd84de507f3fada7df80908082d3239466db55a71"]}"#; + let s = r#"{"method": "anvil_impersonateAccount", "params": +["0xd84de507f3fada7df80908082d3239466db55a71"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } #[test] fn test_custom_stop_impersonate_account() { - let s = r#"{"method": "anvil_stopImpersonatingAccount", "params": ["0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6"]}"#; + let s = r#"{"method": "anvil_stopImpersonatingAccount", "params": +["0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } @@ -844,8 +857,8 @@ mod tests { } _ => unreachable!(), } - let s = - r#"{"method": "anvil_mine", "params": ["0xd84de507f3fada7df80908082d3239466db55a71"]}"#; + let s = r#"{"method": "anvil_mine", "params": +["0xd84de507f3fada7df80908082d3239466db55a71"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let req = serde_json::from_value::(value).unwrap(); match req { @@ -889,7 +902,8 @@ mod tests { #[test] fn test_custom_drop_tx() { - let s = r#"{"method": "anvil_dropTransaction", "params": ["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff"]}"#; + let s = r#"{"method": "anvil_dropTransaction", "params": +["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } @@ -1034,57 +1048,71 @@ mod tests { #[test] fn test_custom_set_balance() { - let s = r#"{"method": "anvil_setBalance", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; + let s = r#"{"method": "anvil_setBalance", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "anvil_setBalance", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", 1337]}"#; + let s = r#"{"method": "anvil_setBalance", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", 1337]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } #[test] fn test_custom_set_code() { - let s = r#"{"method": "anvil_setCode", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", "0x0123456789abcdef"]}"#; + let s = r#"{"method": "anvil_setCode", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", "0x0123456789abcdef"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "anvil_setCode", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", "0x"]}"#; + let s = r#"{"method": "anvil_setCode", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", "0x"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "anvil_setCode", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", ""]}"#; + let s = r#"{"method": "anvil_setCode", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", ""]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } #[test] fn test_custom_set_nonce() { - let s = r#"{"method": "anvil_setNonce", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; + let s = r#"{"method": "anvil_setNonce", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "hardhat_setNonce", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; + let s = r#"{"method": +"hardhat_setNonce", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "evm_setAccountNonce", "params": ["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; + let s = r#"{"method": "evm_setAccountNonce", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", "0x0"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } #[test] fn test_serde_custom_set_storage_at() { - let s = r#"{"method": "anvil_setStorageAt", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x0", "0x0000000000000000000000000000000000000000000000000000000000003039"]}"#; + let s = r#"{"method": "anvil_setStorageAt", "params": +["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x0", +"0x0000000000000000000000000000000000000000000000000000000000003039"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "hardhat_setStorageAt", "params": ["0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49", "0x0000000000000000000000000000000000000000000000000000000000003039"]}"#; + let s = r#"{"method": "hardhat_setStorageAt", "params": +["0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", +"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49", +"0x0000000000000000000000000000000000000000000000000000000000003039"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } #[test] fn test_serde_custom_coinbase() { - let s = r#"{"method": "anvil_setCoinbase", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251"]}"#; + let s = r#"{"method": "anvil_setCoinbase", "params": +["0x295a70b2de5e3953354a6a8344e616ed314d7251"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } @@ -1340,7 +1368,8 @@ mod tests { #[test] fn test_serde_eth_unsubscribe() { - let s = r#"{"id": 1, "method": "eth_unsubscribe", "params": ["0x9cef478923ff08bf67fde6c64013158d"]}"#; + let s = r#"{"id": 1, "method": "eth_unsubscribe", "params": +["0x9cef478923ff08bf67fde6c64013158d"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } @@ -1351,7 +1380,9 @@ mod tests { let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"id": 1, "method": "eth_subscribe", "params": ["logs", {"address": "0x8320fe7702b96808f7bbc0d4a888ed1468216cfd", "topics": ["0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"]}]}"#; + let s = r#"{"id": 1, "method": "eth_subscribe", "params": ["logs", {"address": +"0x8320fe7702b96808f7bbc0d4a888ed1468216cfd", "topics": +["0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"]}]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); @@ -1366,15 +1397,19 @@ mod tests { #[test] fn test_serde_debug_trace_transaction() { - let s = r#"{"method": "debug_traceTransaction", "params": ["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff"]}"#; + let s = r#"{"method": "debug_traceTransaction", "params": +["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "debug_traceTransaction", "params": ["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff", {}]}"#; + let s = r#"{"method": "debug_traceTransaction", "params": +["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff", {}]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); - let s = r#"{"method": "debug_traceTransaction", "params": ["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff", {"disableStorage": true}]}"#; + let s = r#"{"method": "debug_traceTransaction", "params": +["0x4a3b0fce2cb9707b0baa68640cf2fe858c8bb4121b2a8cb904ff369d38a560ff", {"disableStorage": +true}]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } @@ -1404,7 +1439,8 @@ mod tests { #[test] fn test_serde_eth_storage() { - let s = r#"{"method": "eth_getStorageAt", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x0", "latest"]}"#; + let s = r#"{"method": "eth_getStorageAt", "params": +["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x0", "latest"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } @@ -1412,27 +1448,28 @@ mod tests { #[test] fn test_eth_call() { let req = r#"{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}"#; - let _req = serde_json::from_str::(req).unwrap(); + let _req = serde_json::from_str::(req).unwrap(); - let s = r#"{"method": "eth_call", "params": [{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"},"latest"]}"#; + let s = r#"{"method": "eth_call", "params":[{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"},"latest"]}"#; let _req = serde_json::from_str::(s).unwrap(); - let s = r#"{"method": "eth_call", "params": [{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}]}"#; + let s = r#"{"method": "eth_call", "params":[{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}]}"#; let _req = serde_json::from_str::(s).unwrap(); - let s = r#"{"method": "eth_call", "params": [{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}, { "blockNumber": "latest" }]}"#; + let s = r#"{"method": "eth_call", "params":[{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}, { "blockNumber": "latest" }]}"#; let _req = serde_json::from_str::(s).unwrap(); - let s = r#"{"method": "eth_call", "params": [{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}, { "blockNumber": "0x0" }]}"#; + let s = r#"{"method": "eth_call", "params":[{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}, { "blockNumber": "0x0" }]}"#; let _req = serde_json::from_str::(s).unwrap(); - let s = r#"{"method": "eth_call", "params": [{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}, { "blockHash": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" }]}"#; + let s = r#"{"method": "eth_call", "params":[{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}, { "blockHash":"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" }]}"#; let _req = serde_json::from_str::(s).unwrap(); } #[test] fn test_serde_eth_balance() { - let s = r#"{"method": "eth_getBalance", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "latest"]}"#; + let s = r#"{"method": "eth_getBalance", "params": +["0x295a70b2de5e3953354a6a8344e616ed314d7251", "latest"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); diff --git a/crates/anvil/core/src/eth/serde_helpers.rs b/crates/anvil/core/src/eth/serde_helpers.rs index 0deeb69d6c8c1..f7d5bd46dba2e 100644 --- a/crates/anvil/core/src/eth/serde_helpers.rs +++ b/crates/anvil/core/src/eth/serde_helpers.rs @@ -51,3 +51,60 @@ pub mod empty_params { Ok(()) } } + +/// A module that deserializes either a BlockNumberOrTag, or a simple number. +pub mod lenient_block_number { + use alloy_rpc_types::BlockNumberOrTag; + use serde::{Deserialize, Deserializer}; + /// Following the spec the block parameter is either: + /// + /// > HEX String - an integer block number + /// > String "earliest" for the earliest/genesis block + /// > String "latest" - for the latest mined block + /// > String "pending" - for the pending state/transactions + /// + /// and with EIP-1898: + /// > blockNumber: QUANTITY - a block number + /// > blockHash: DATA - a block hash + /// + /// + /// + /// EIP-1898 does not all calls that use `BlockNumber` like `eth_getBlockByNumber` and doesn't + /// list raw integers as supported. + /// + /// However, there are dev node implementations that support integers, such as ganache: + /// + /// N.B.: geth does not support ints in `eth_getBlockByNumber` + pub fn lenient_block_number<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + LenientBlockNumber::deserialize(deserializer).map(Into::into) + } + + /// Same as `lenient_block_number` but requires to be `[num; 1]` + pub fn lenient_block_number_seq<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let num = <[LenientBlockNumber; 1]>::deserialize(deserializer)?[0].into(); + Ok(num) + } + + /// Various block number representations, See [`lenient_block_number()`] + #[derive(Clone, Copy, Deserialize)] + #[serde(untagged)] + pub enum LenientBlockNumber { + BlockNumber(BlockNumberOrTag), + Num(u64), + } + + impl From for BlockNumberOrTag { + fn from(b: LenientBlockNumber) -> Self { + match b { + LenientBlockNumber::BlockNumber(b) => b, + LenientBlockNumber::Num(b) => b.into(), + } + } + } +} diff --git a/crates/anvil/core/src/eth/transaction/ethers_compat.rs b/crates/anvil/core/src/eth/transaction/ethers_compat.rs index 54e2c16c535a8..8844c1bf43fde 100644 --- a/crates/anvil/core/src/eth/transaction/ethers_compat.rs +++ b/crates/anvil/core/src/eth/transaction/ethers_compat.rs @@ -1,20 +1,172 @@ //! ethers compatibility, this is mainly necessary so we can use all of `ethers` signers use super::EthTransactionRequest; -use crate::eth::transaction::{ - DepositTransactionRequest, EIP1559TransactionRequest, EIP2930TransactionRequest, - LegacyTransactionRequest, MaybeImpersonatedTransaction, TypedTransaction, - TypedTransactionRequest, +use crate::eth::{ + proof::AccountProof, + state::{AccountOverride, StateOverride as EthStateOverride}, + transaction::{ + DepositTransactionRequest, EIP1559TransactionRequest, EIP2930TransactionRequest, + LegacyTransactionRequest, MaybeImpersonatedTransaction, TypedTransaction, + TypedTransactionRequest, + }, +}; +use alloy_primitives::{U128 as rU128, U256 as rU256, U64 as rU64}; +use alloy_rpc_types::{ + state::{AccountOverride as AlloyAccountOverride, StateOverride}, + transaction::request::TransactionRequest as AlloyTransactionRequest, + AccessList as AlloyAccessList, CallRequest, Signature, Transaction as AlloyTransaction, }; use ethers_core::types::{ transaction::{ - eip2718::TypedTransaction as EthersTypedTransactionRequest, optimism::DepositTransaction, + eip2718::TypedTransaction as EthersTypedTransactionRequest, + eip2930::{AccessList, AccessListItem}, + optimism::DepositTransaction, }, - Address, Eip1559TransactionRequest as EthersEip1559TransactionRequest, - Eip2930TransactionRequest as EthersEip2930TransactionRequest, NameOrAddress, + Address, BigEndianHash, Eip1559TransactionRequest as EthersEip1559TransactionRequest, + Eip2930TransactionRequest as EthersEip2930TransactionRequest, NameOrAddress, StorageProof, Transaction as EthersTransaction, TransactionRequest as EthersLegacyTransactionRequest, TransactionRequest, H256, U256, U64, }; +use foundry_common::types::{ToAlloy, ToEthers}; + +pub fn to_alloy_proof(proof: AccountProof) -> alloy_rpc_types::EIP1186AccountProofResponse { + alloy_rpc_types::EIP1186AccountProofResponse { + address: proof.address.to_alloy(), + account_proof: proof.account_proof.into_iter().map(|b| b.0.into()).collect(), + balance: proof.balance.to_alloy(), + code_hash: proof.code_hash.to_alloy(), + nonce: proof.nonce.to_alloy().to::(), + storage_hash: proof.storage_hash.to_alloy(), + storage_proof: proof.storage_proof.iter().map(to_alloy_storage_proof).collect(), + } +} + +pub fn to_alloy_storage_proof(proof: &StorageProof) -> alloy_rpc_types::EIP1186StorageProof { + alloy_rpc_types::EIP1186StorageProof { + key: rU256::from_be_bytes(proof.key.to_alloy().0).into(), + proof: proof.proof.iter().map(|b| b.clone().0.into()).collect(), + value: proof.value.to_alloy(), + } +} + +pub fn to_internal_tx_request(request: &AlloyTransactionRequest) -> EthTransactionRequest { + EthTransactionRequest { + from: request.from.map(|a| a.to_ethers()), + to: request.to.map(|a| a.to_ethers()), + gas_price: request.gas_price.map(|g| alloy_primitives::U256::from(g).to_ethers()), + max_fee_per_gas: request + .max_fee_per_gas + .map(|g| alloy_primitives::U256::from(g).to_ethers()), + max_priority_fee_per_gas: request + .max_priority_fee_per_gas + .map(|g| alloy_primitives::U256::from(g).to_ethers()), + gas: request.gas.map(|g| g.to_ethers()), + value: request.value.map(|v| v.to_ethers()), + data: request.data.clone().map(|b| b.clone().0.into()), + nonce: request.nonce.map(|n| n.to::().into()), + chain_id: None, + access_list: request.access_list.clone().map(|a| to_ethers_access_list(a.clone()).0), + transaction_type: request.transaction_type.map(|t| t.to::().into()), + // TODO: Should this be none? + optimism_fields: None, + } +} + +pub fn call_to_internal_tx_request(request: &CallRequest) -> EthTransactionRequest { + EthTransactionRequest { + from: request.from.map(|a| a.to_ethers()), + to: request.to.map(|a| a.to_ethers()), + gas_price: request.gas_price.map(|g| alloy_primitives::U256::from(g).to_ethers()), + max_fee_per_gas: request + .max_fee_per_gas + .map(|g| alloy_primitives::U256::from(g).to_ethers()), + max_priority_fee_per_gas: request + .max_priority_fee_per_gas + .map(|g| alloy_primitives::U256::from(g).to_ethers()), + gas: request.gas.map(|g| g.to_ethers()), + value: request.value.map(|v| v.to_ethers()), + data: request.input.unique_input().unwrap().map(|b| b.clone().0.into()), + nonce: request.nonce.map(|n| n.to::().into()), + chain_id: request.chain_id.map(|c| c.to::().into()), + access_list: request.access_list.clone().map(|a| to_ethers_access_list(a.clone()).0), + transaction_type: request.transaction_type.map(|t| t.to::().into()), + // TODO: Should this be none? + optimism_fields: None, + } +} + +pub fn to_ethers_access_list(access_list: AlloyAccessList) -> AccessList { + AccessList( + access_list + .0 + .into_iter() + .map(|item| AccessListItem { + address: item.address.to_ethers(), + storage_keys: item + .storage_keys + .into_iter() + .map(|k| { + BigEndianHash::from_uint(&U256::from_big_endian(k.to_ethers().as_bytes())) + }) + .collect(), + }) + .collect(), + ) +} + +pub fn from_ethers_access_list(access_list: AccessList) -> AlloyAccessList { + AlloyAccessList(access_list.0.into_iter().map(ToAlloy::to_alloy).collect()) +} + +pub fn to_ethers_state_override(ov: StateOverride) -> EthStateOverride { + ov.into_iter() + .map(|(addr, o)| { + ( + addr.to_ethers(), + AccountOverride { + nonce: o.nonce.map(|n| n.to::()), + balance: o.balance.map(|b| b.to_ethers()), + code: o.code.map(|c| c.0.into()), + state_diff: o.state_diff.map(|s| { + s.into_iter() + .map(|(k, v)| (k.to_ethers(), H256::from_uint(&v.to_ethers()))) + .collect() + }), + state: o.state.map(|s| { + s.into_iter() + .map(|(k, v)| (k.to_ethers(), H256::from_uint(&v.to_ethers()))) + .collect() + }), + }, + ) + }) + .collect() +} + +pub fn to_alloy_state_override(ov: EthStateOverride) -> StateOverride { + ov.into_iter() + .map(|(addr, o)| { + ( + addr.to_alloy(), + AlloyAccountOverride { + nonce: o.nonce.map(rU64::from), + balance: o.balance.map(|b| b.to_alloy()), + code: o.code.map(|c| c.0.into()), + state_diff: o.state_diff.map(|s| { + s.into_iter() + .map(|(k, v)| (k.to_alloy(), rU256::from_be_bytes(v.to_alloy().0))) + .collect() + }), + state: o.state.map(|s| { + s.into_iter() + .map(|(k, v)| (k.to_alloy(), rU256::from_be_bytes(v.to_alloy().0))) + .collect() + }), + }, + ) + }) + .collect() +} impl From for EthersTypedTransactionRequest { fn from(tx: TypedTransactionRequest) -> Self { @@ -230,6 +382,118 @@ fn to_ethers_transaction_with_hash_and_sender( } } +fn to_alloy_transaction_with_hash_and_sender( + transaction: TypedTransaction, + hash: H256, + from: Address, +) -> AlloyTransaction { + match transaction { + TypedTransaction::Legacy(t) => AlloyTransaction { + hash: hash.to_alloy(), + nonce: t.nonce.to_alloy().to::(), + block_hash: None, + block_number: None, + transaction_index: None, + from: from.to_alloy(), + to: None, + value: t.value.to_alloy(), + gas_price: Some(t.gas_price.to_alloy().to::()), + max_fee_per_gas: Some(t.gas_price.to_alloy().to::()), + max_priority_fee_per_gas: Some(t.gas_price.to_alloy().to::()), + gas: t.gas_limit.to_alloy(), + input: t.input.clone().0.into(), + chain_id: t.chain_id().map(rU64::from), + signature: Some(Signature { + r: t.signature.r.to_alloy(), + s: t.signature.s.to_alloy(), + v: rU256::from(t.signature.v), + y_parity: None, + }), + access_list: None, + transaction_type: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, + TypedTransaction::EIP2930(t) => AlloyTransaction { + hash: hash.to_alloy(), + nonce: t.nonce.to_alloy().to::(), + block_hash: None, + block_number: None, + transaction_index: None, + from: from.to_alloy(), + to: None, + value: t.value.to_alloy(), + gas_price: Some(t.gas_price.to_alloy().to::()), + max_fee_per_gas: Some(t.gas_price.to_alloy().to::()), + max_priority_fee_per_gas: Some(t.gas_price.to_alloy().to::()), + gas: t.gas_limit.to_alloy(), + input: t.input.clone().0.into(), + chain_id: Some(rU64::from(t.chain_id)), + signature: Some(Signature { + r: rU256::from_be_bytes(t.r.to_alloy().0), + s: rU256::from_be_bytes(t.s.to_alloy().0), + v: rU256::from(t.odd_y_parity as u8), + y_parity: Some(t.odd_y_parity.into()), + }), + access_list: Some(from_ethers_access_list(t.access_list).0), + transaction_type: Some(rU64::from(1)), + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, + TypedTransaction::EIP1559(t) => AlloyTransaction { + hash: hash.to_alloy(), + nonce: t.nonce.to_alloy().to::(), + block_hash: None, + block_number: None, + transaction_index: None, + from: from.to_alloy(), + to: None, + value: t.value.to_alloy(), + gas_price: None, + max_fee_per_gas: Some(t.max_fee_per_gas.to_alloy().to::()), + max_priority_fee_per_gas: Some(t.max_priority_fee_per_gas.to_alloy().to::()), + gas: t.gas_limit.to_alloy(), + input: t.input.clone().0.into(), + chain_id: Some(rU64::from(t.chain_id)), + signature: Some(Signature { + r: rU256::from_be_bytes(t.r.to_alloy().0), + s: rU256::from_be_bytes(t.s.to_alloy().0), + v: rU256::from(t.odd_y_parity as u8), + y_parity: Some(t.odd_y_parity.into()), + }), + access_list: Some(from_ethers_access_list(t.access_list).0), + transaction_type: Some(rU64::from(2)), + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, + TypedTransaction::Deposit(t) => AlloyTransaction { + hash: hash.to_alloy(), + nonce: t.nonce.to_alloy().to::(), + block_hash: None, + block_number: None, + transaction_index: None, + from: from.to_alloy(), + to: None, + value: t.value.to_alloy(), + gas_price: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + gas: t.gas_limit.to_alloy(), + input: t.input.clone().0.into(), + chain_id: t.chain_id().map(rU64::from), + signature: None, + access_list: None, + transaction_type: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, + } +} + impl From for EthersTransaction { fn from(transaction: TypedTransaction) -> Self { let hash = transaction.hash(); @@ -246,6 +510,15 @@ impl From for EthersTransaction { } } +impl From for AlloyTransaction { + fn from(transaction: MaybeImpersonatedTransaction) -> Self { + let hash = transaction.hash(); + let sender = transaction.recover().unwrap_or_default(); + + to_alloy_transaction_with_hash_and_sender(transaction.into(), hash, sender) + } +} + impl From for EthTransactionRequest { fn from(req: TransactionRequest) -> Self { let TransactionRequest { from, to, gas, gas_price, value, data, nonce, chain_id, .. } = req; diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index b324c63a5776e..7c259b8cdbe0f 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -15,7 +15,7 @@ use ethers_core::{ }, }; use foundry_common::types::ToAlloy; -use foundry_evm::traces::CallTraceArena; +use foundry_evm::traces::CallTraceNode; use revm::{ interpreter::InstructionResult, primitives::{CreateScheme, OptimismFields, TransactTo, TxEnv}, @@ -25,6 +25,11 @@ use std::ops::Deref; /// compatibility with `ethers-rs` types mod ethers_compat; +pub use ethers_compat::{ + call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_alloy_state_override, + to_ethers_access_list, to_ethers_state_override, to_internal_tx_request, +}; + /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC #[cfg(feature = "impersonated-tx")] pub const IMPERSONATED_SIGNATURE: Signature = @@ -1508,47 +1513,12 @@ pub struct TransactionInfo { pub contract_address: Option
, pub logs: Vec, pub logs_bloom: Bloom, - pub traces: CallTraceArena, + pub traces: Vec, pub exit: InstructionResult, pub out: Option, pub nonce: u64, } -// === impl TransactionInfo === - -impl TransactionInfo { - /// Returns the `traceAddress` of the node in the arena - /// - /// The `traceAddress` field of all returned traces, gives the exact location in the call trace - /// [index in root, index in first CALL, index in second CALL, …]. - /// - /// # Panics - /// - /// if the `idx` does not belong to a node - pub fn trace_address(&self, idx: usize) -> Vec { - if idx == 0 { - // root call has empty traceAddress - return vec![] - } - let mut graph = vec![]; - let mut node = &self.traces.arena[idx]; - while let Some(parent) = node.parent { - // the index of the child call in the arena - let child_idx = node.idx; - node = &self.traces.arena[parent]; - // find the index of the child call in the parent node - let call_idx = node - .children - .iter() - .position(|child| *child == child_idx) - .expect("child exists in parent"); - graph.push(call_idx); - } - graph.reverse(); - graph - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 147db557ef997..d1386854d7cd1 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -1,7 +1,6 @@ -use std::collections::BTreeMap; - -use ethers_core::types::{TxHash, H256, U256, U64}; +use alloy_primitives::{TxHash, B256, U256, U64}; use revm::primitives::SpecId; +use std::collections::BTreeMap; #[cfg(feature = "serde")] use serde::{de::Error, Deserializer, Serializer}; @@ -92,9 +91,9 @@ impl Default for EvmMineOptions { /// This may or may not include the block number #[derive(Debug, Default, PartialEq, Eq)] pub struct Work { - pub pow_hash: H256, - pub seed_hash: H256, - pub target: H256, + pub pow_hash: B256, + pub seed_hash: B256, + pub target: B256, pub number: Option, } @@ -180,7 +179,7 @@ impl<'a> serde::Deserialize<'a> for Index { pub struct NodeInfo { pub current_block_number: U64, pub current_block_timestamp: u64, - pub current_block_hash: H256, + pub current_block_hash: B256, pub hard_fork: SpecId, pub transaction_order: String, pub environment: NodeEnvironment, @@ -215,11 +214,11 @@ pub struct NodeForkConfig { pub struct AnvilMetadata { pub client_version: &'static str, pub chain_id: u64, - pub instance_id: H256, + pub instance_id: B256, pub latest_block_number: u64, - pub latest_block_hash: H256, + pub latest_block_hash: B256, pub forked_network: Option, - pub snapshots: BTreeMap, + pub snapshots: BTreeMap, } /// Information about the forked network. diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 576e1f1697627..b684caffd71b3 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -4,6 +4,7 @@ use crate::{ genesis::Genesis, AccountGenerator, Hardfork, NodeConfig, CHAIN_ID, }; +use alloy_primitives::U256; use anvil_server::ServerConfig; use clap::Parser; use core::fmt; @@ -11,6 +12,7 @@ use ethers::{ signers::coins_bip39::{English, Mnemonic}, utils::WEI_IN_ETHER, }; +use foundry_common::types::ToAlloy; use foundry_config::{Chain, Config}; use futures::FutureExt; use rand::{rngs::StdRng, SeedableRng}; @@ -192,14 +194,14 @@ impl NodeArgs { }; NodeConfig::default() - .with_gas_limit(self.evm_opts.gas_limit) + .with_gas_limit(self.evm_opts.gas_limit.map(U256::from)) .disable_block_gas_limit(self.evm_opts.disable_block_gas_limit) - .with_gas_price(self.evm_opts.gas_price) + .with_gas_price(self.evm_opts.gas_price.map(U256::from)) .with_hardfork(self.hardfork) .with_blocktime(self.block_time.map(Duration::from_secs)) .with_no_mining(self.no_mining) .with_account_generator(self.account_generator()) - .with_genesis_balance(genesis_balance) + .with_genesis_balance(genesis_balance.to_alloy()) .with_genesis_timestamp(self.timestamp) .with_port(self.port) .with_fork_block_number( @@ -208,13 +210,13 @@ impl NodeArgs { .or_else(|| self.evm_opts.fork_url.as_ref().and_then(|f| f.block)), ) .with_fork_headers(self.evm_opts.fork_headers) - .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from)) + .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from).map(U256::from)) .fork_request_timeout(self.evm_opts.fork_request_timeout.map(Duration::from_millis)) .fork_request_retries(self.evm_opts.fork_request_retries) .fork_retry_backoff(self.evm_opts.fork_retry_backoff.map(Duration::from_millis)) .fork_compute_units_per_second(compute_units_per_second) .with_eth_rpc_url(self.evm_opts.fork_url.map(|fork| fork.url)) - .with_base_fee(self.evm_opts.block_base_fee_per_gas) + .with_base_fee(self.evm_opts.block_base_fee_per_gas.map(U256::from)) .with_storage_caching(self.evm_opts.no_storage_caching) .with_server_config(self.server_config) .with_host(self.host) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 612a7ec071c58..1d0a1a60dd15a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -15,28 +15,30 @@ use crate::{ mem::in_memory_db::MemDb, FeeManager, Hardfork, }; +use alloy_primitives::{hex, U256}; +use alloy_providers::provider::TempProvider; +use alloy_rpc_types::BlockNumberOrTag; +use alloy_transport::TransportError; use anvil_server::ServerConfig; use ethers::{ core::k256::ecdsa::SigningKey, - prelude::{rand::thread_rng, Wallet, U256}, - providers::Middleware, + prelude::{rand::thread_rng, Wallet}, signers::{ coins_bip39::{English, Mnemonic}, MnemonicBuilder, Signer, }, - types::BlockNumber, - utils::{format_ether, hex, to_checksum, WEI_IN_ETHER}, + utils::WEI_IN_ETHER, }; use foundry_common::{ - types::{ToAlloy, ToEthers}, - ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, + provider::alloy::ProviderBuilder, types::ToAlloy, ALCHEMY_FREE_TIER_CUPS, + NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, }; use foundry_config::Config; use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, revm, - revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv, U256 as rU256}, + revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}, utils::apply_chain_and_block_specific_env_changes, }; use parking_lot::RwLock; @@ -192,13 +194,10 @@ Available Accounts ================== "# ); - let balance = format_ether(self.genesis_balance); + let balance = alloy_primitives::utils::format_ether(self.genesis_balance); for (idx, wallet) in self.genesis_accounts.iter().enumerate() { - let _ = write!( - config_string, - "\n({idx}) {:?} ({balance} ETH)", - to_checksum(&wallet.address(), None) - ); + write!(config_string, "\n({idx}) {} ({balance} ETH)", wallet.address().to_alloy()) + .unwrap(); } let _ = write!( @@ -375,7 +374,7 @@ impl Default for NodeConfig { genesis_timestamp: None, genesis_accounts, // 100ETH default balance - genesis_balance: WEI_IN_ETHER.saturating_mul(100u64.into()), + genesis_balance: WEI_IN_ETHER.to_alloy().saturating_mul(U256::from(100u64)), block_time: None, no_mining: false, port: NODE_PORT, @@ -418,12 +417,12 @@ impl NodeConfig { pub fn get_base_fee(&self) -> U256 { self.base_fee .or_else(|| self.genesis.as_ref().and_then(|g| g.base_fee_per_gas)) - .unwrap_or_else(|| INITIAL_BASE_FEE.into()) + .unwrap_or_else(|| U256::from(INITIAL_BASE_FEE)) } /// Returns the base fee to use pub fn get_gas_price(&self) -> U256 { - self.gas_price.unwrap_or_else(|| INITIAL_GAS_PRICE.into()) + self.gas_price.unwrap_or_else(|| U256::from(INITIAL_GAS_PRICE)) } /// Returns the base fee to use @@ -473,9 +472,9 @@ impl NodeConfig { /// Sets the gas limit #[must_use] - pub fn with_gas_limit>(mut self, gas_limit: Option) -> Self { + pub fn with_gas_limit(mut self, gas_limit: Option) -> Self { if let Some(gas_limit) = gas_limit { - self.gas_limit = gas_limit.into(); + self.gas_limit = gas_limit; } self } @@ -491,7 +490,7 @@ impl NodeConfig { /// Sets the gas price #[must_use] - pub fn with_gas_price>(mut self, gas_price: Option) -> Self { + pub fn with_gas_price(mut self, gas_price: Option) -> Self { self.gas_price = gas_price.map(Into::into); self } @@ -515,7 +514,7 @@ impl NodeConfig { /// Sets the base fee #[must_use] - pub fn with_base_fee>(mut self, base_fee: Option) -> Self { + pub fn with_base_fee(mut self, base_fee: Option) -> Self { self.base_fee = base_fee.map(Into::into); self } @@ -660,7 +659,7 @@ impl NodeConfig { /// Sets the `fork_chain_id` to use to fork off local cache from #[must_use] - pub fn with_fork_chain_id>(mut self, fork_chain_id: Option) -> Self { + pub fn with_fork_chain_id(mut self, fork_chain_id: Option) -> Self { self.fork_chain_id = fork_chain_id.map(Into::into); self } @@ -769,7 +768,7 @@ impl NodeConfig { .expect("Failed writing json"); } if self.silent { - return + return; } println!("{}", self.as_string(fork)) @@ -780,7 +779,7 @@ impl NodeConfig { /// See also [ Config::foundry_block_cache_file()] pub fn block_cache_path(&self, block: u64) -> Option { if self.no_storage_caching || self.eth_rpc_url.is_none() { - return None + return None; } let chain_id = self.get_chain_id(); @@ -815,8 +814,8 @@ impl NodeConfig { let mut env = revm::primitives::Env { cfg, block: BlockEnv { - gas_limit: self.gas_limit.to_alloy(), - basefee: self.get_base_fee().to_alloy(), + gas_limit: self.gas_limit, + basefee: self.get_base_fee(), ..Default::default() }, tx: TxEnv { chain_id: self.get_chain_id().into(), ..Default::default() }, @@ -837,8 +836,8 @@ impl NodeConfig { let genesis = GenesisConfig { timestamp: self.get_genesis_timestamp(), - balance: self.genesis_balance.to_alloy(), - accounts: self.genesis_accounts.iter().map(|acc| acc.address()).collect(), + balance: self.genesis_balance, + accounts: self.genesis_accounts.iter().map(|acc| acc.address().to_alloy()).collect(), fork_genesis_account_infos: Arc::new(Default::default()), genesis_init: self.genesis.clone(), }; @@ -862,7 +861,7 @@ impl NodeConfig { // if the option is not disabled and we are not forking. if !self.disable_default_create2_deployer && self.eth_rpc_url.is_none() { backend - .set_create2_deployer(DEFAULT_CREATE2_DEPLOYER.to_ethers()) + .set_create2_deployer(DEFAULT_CREATE2_DEPLOYER) .await .expect("Failed to create default create2 deployer"); } @@ -936,13 +935,13 @@ impl NodeConfig { // auto adjust hardfork if not specified // but only if we're forking mainnet let chain_id = - provider.get_chainid().await.expect("Failed to fetch network chain id"); - if chain_id == ethers::types::Chain::Mainnet.into() { + provider.get_chain_id().await.expect("Failed to fetch network chain ID"); + if alloy_chains::NamedChain::Mainnet == chain_id.to::() { let hardfork: Hardfork = fork_block_number.into(); env.cfg.spec_id = hardfork.into(); self.hardfork = Some(hardfork); } - Some(chain_id) + Some(U256::from(chain_id)) } else { None }; @@ -950,14 +949,13 @@ impl NodeConfig { (fork_block_number, chain_id) } else { // pick the last block number but also ensure it's not pending anymore - ( - find_latest_fork_block(&provider).await.expect("Failed to get fork block number"), - None, - ) + let bn = + find_latest_fork_block(&provider).await.expect("Failed to get fork block number"); + (bn, None) }; let block = provider - .get_block(BlockNumber::Number(fork_block_number.into())) + .get_block(BlockNumberOrTag::Number(fork_block_number).into(), false) .await .expect("Failed to get fork block"); @@ -972,7 +970,7 @@ latest block number: {latest_block}" // If the `eth_getBlockByNumber` call succeeds, but returns null instead of // the block, and the block number is less than equal the latest block, then // the user is forking from a non-archive node with an older block number. - if fork_block_number <= latest_block.as_u64() { + if fork_block_number <= latest_block { message.push_str(&format!("\n{}", NON_ARCHIVE_NODE_WARNING)); } panic!("{}", message); @@ -983,18 +981,18 @@ latest block number: {latest_block}" // we only use the gas limit value of the block if it is non-zero and the block gas // limit is enabled, since there are networks where this is not used and is always // `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also - let gas_limit = if self.disable_block_gas_limit || block.gas_limit.is_zero() { - rU256::from(u64::MAX) + let gas_limit = if self.disable_block_gas_limit || block.header.gas_limit.is_zero() { + U256::from(u64::MAX) } else { - block.gas_limit.to_alloy() + block.header.gas_limit }; env.block = BlockEnv { - number: rU256::from(fork_block_number), - timestamp: block.timestamp.to_alloy(), - difficulty: block.difficulty.to_alloy(), + number: U256::from(fork_block_number), + timestamp: block.header.timestamp, + difficulty: block.header.difficulty, // ensures prevrandao is set - prevrandao: Some(block.mix_hash.unwrap_or_default()).map(|h| h.to_alloy()), + prevrandao: Some(block.header.mix_hash.unwrap_or_default()), gas_limit, // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, @@ -1007,18 +1005,18 @@ latest block number: {latest_block}" // if not set explicitly we use the base fee of the latest block if self.base_fee.is_none() { - if let Some(base_fee) = block.base_fee_per_gas { + if let Some(base_fee) = block.header.base_fee_per_gas { self.base_fee = Some(base_fee); - env.block.basefee = base_fee.to_alloy(); + env.block.basefee = base_fee; // this is the base fee of the current block, but we need the base fee of // the next block let next_block_base_fee = fees.get_next_block_base_fee_per_gas( - block.gas_used, - block.gas_limit, - block.base_fee_per_gas.unwrap_or_default(), + block.header.gas_used, + block.header.gas_limit, + block.header.base_fee_per_gas.unwrap_or_default(), ); // update next base fee - fees.set_base_fee(next_block_base_fee.into()); + fees.set_base_fee(U256::from(next_block_base_fee)); } } @@ -1030,17 +1028,16 @@ latest block number: {latest_block}" } } - let block_hash = block.hash.unwrap_or_default(); + let block_hash = block.header.hash.unwrap_or_default(); let chain_id = if let Some(chain_id) = self.chain_id { chain_id } else { let chain_id = if let Some(fork_chain_id) = fork_chain_id { - fork_chain_id + fork_chain_id.to::() } else { - provider.get_chainid().await.unwrap() - } - .as_u64(); + provider.get_chain_id().await.unwrap().to::() + }; // need to update the dev signers and env with the chain id self.set_chain_id(Some(chain_id)); @@ -1072,8 +1069,8 @@ latest block number: {latest_block}" provider, chain_id, override_chain_id, - timestamp: block.timestamp.as_u64(), - base_fee: block.base_fee_per_gas, + timestamp: block.header.timestamp.to::(), + base_fee: block.header.base_fee_per_gas, timeout: self.fork_request_timeout, retries: self.fork_request_retries, backoff: self.fork_retry_backoff, @@ -1192,15 +1189,15 @@ pub fn anvil_tmp_dir() -> Option { /// /// This fetches the "latest" block and checks whether the `Block` is fully populated (`hash` field /// is present). This prevents edge cases where anvil forks the "latest" block but `eth_getBlockByNumber` still returns a pending block, -async fn find_latest_fork_block(provider: M) -> Result { - let mut num = provider.get_block_number().await?.as_u64(); +async fn find_latest_fork_block(provider: P) -> Result { + let mut num = provider.get_block_number().await?; // walk back from the head of the chain, but at most 2 blocks, which should be more than enough // leeway for _ in 0..2 { - if let Some(block) = provider.get_block(num).await? { - if block.hash.is_some() { - break + if let Some(block) = provider.get_block(num.into(), false).await? { + if block.header.hash.is_some() { + break; } } // block not actually finalized, so we try the block before diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 232045e7552d9..84419c9ce3b46 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -29,12 +29,24 @@ use crate::{ revm::primitives::Output, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; +use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256, U64}; +use alloy_rpc_trace_types::{ + geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace, +}; +use alloy_rpc_types::{ + state::StateOverride, + txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, + AccessList, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, + BlockTransactions, CallRequest, EIP1186AccountProofResponse, FeeHistory, Filter, + FilteredParams, Log, Transaction, TransactionReceipt, +}; +use alloy_transport::TransportErrorKind; use anvil_core::{ eth::{ block::BlockInfo, - proof::AccountProof, - state::StateOverride, transaction::{ + call_to_internal_tx_request, to_alloy_proof, to_ethers_access_list, EthTransactionRequest, LegacyTransaction, PendingTransaction, TransactionKind, TypedTransaction, TypedTransactionRequest, }, @@ -46,22 +58,11 @@ use anvil_core::{ }, }; use anvil_rpc::{error::RpcError, response::ResponseResult}; -use ethers::{ - abi::ethereum_types::H64, - prelude::{DefaultFrame, TxpoolInspect}, - providers::ProviderError, - types::{ - transaction::{ - eip2930::{AccessList, AccessListWithGasUsed}, - eip712::TypedData, - }, - Address, Block, BlockId, BlockNumber, Bytes, FeeHistory, Filter, FilteredParams, - GethDebugTracingOptions, GethTrace, Log, Signature, Trace, Transaction, TransactionReceipt, - TxHash, TxpoolContent, TxpoolInspectSummary, TxpoolStatus, H256, U256, U64, - }, - utils::rlp, +use ethers::{types::transaction::eip712::TypedData, utils::rlp}; +use foundry_common::{ + provider::alloy::ProviderBuilder, + types::{ToAlloy, ToEthers}, }; -use foundry_common::{types::ToEthers, ProviderBuilder}; use foundry_evm::{ backend::DatabaseError, revm::{ @@ -109,7 +110,7 @@ pub struct EthApi { /// Whether we're listening for RPC calls net_listening: bool, /// The instance ID. Changes on every reset. - instance_id: Arc>, + instance_id: Arc>, } // === impl Eth RPC API === @@ -140,7 +141,7 @@ impl EthApi { filters, net_listening: true, transaction_order: Arc::new(RwLock::new(transactions_order)), - instance_id: Arc::new(RwLock::new(H256::random())), + instance_id: Arc::new(RwLock::new(B256::random())), } } @@ -323,16 +324,22 @@ impl EthApi { EthRequest::EvmRevert(id) => self.evm_revert(id).await.to_rpc_result(), EthRequest::EvmIncreaseTime(time) => self.evm_increase_time(time).await.to_rpc_result(), EthRequest::EvmSetNextBlockTimeStamp(time) => { - match u64::try_from(time).map_err(BlockchainError::UintConversion) { - Ok(time) => self.evm_set_next_block_timestamp(time).to_rpc_result(), - err @ Err(_) => err.to_rpc_result(), + if time >= U256::from(u64::MAX) { + return ResponseResult::Error(RpcError::invalid_params( + "The timestamp is too big", + )) } + let time = time.to::(); + self.evm_set_next_block_timestamp(time).to_rpc_result() } EthRequest::EvmSetTime(timestamp) => { - match u64::try_from(timestamp).map_err(BlockchainError::UintConversion) { - Ok(timestamp) => self.evm_set_time(timestamp).to_rpc_result(), - err @ Err(_) => err.to_rpc_result(), + if timestamp >= U256::from(u64::MAX) { + return ResponseResult::Error(RpcError::invalid_params( + "The timestamp is too big", + )) } + let time = timestamp.to::(); + self.evm_set_time(time).to_rpc_result() } EthRequest::EvmSetBlockGasLimit(gas_limit) => { self.evm_set_block_gas_limit(gas_limit).to_rpc_result() @@ -410,14 +417,18 @@ impl EthApi { ) -> Result { match request { TypedTransactionRequest::Deposit(_) => { - const NIL_SIGNATURE: ethers::types::Signature = - Signature { r: U256::zero(), s: U256::zero(), v: 0 }; + const NIL_SIGNATURE: ethers::types::Signature = ethers::types::Signature { + r: ethers::types::U256::zero(), + s: ethers::types::U256::zero(), + v: 0, + }; return build_typed_transaction(request, NIL_SIGNATURE) } _ => { for signer in self.signers.iter() { - if signer.accounts().contains(from) { - let signature = signer.sign_transaction(request.clone(), from)?; + if signer.accounts().contains(&from.to_ethers()) { + let signature = + signer.sign_transaction(request.clone(), &from.to_ethers())?; return build_typed_transaction(request, signature) } } @@ -439,7 +450,7 @@ impl EthApi { } _ => { let number = self.backend.ensure_block_number(block_number).await?; - BlockRequest::Number(number.into()) + BlockRequest::Number(number) } }; Ok(block_request) @@ -475,7 +486,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_hashrate` pub fn hashrate(&self) -> Result { node_info!("eth_hashrate"); - Ok(U256::zero()) + Ok(U256::ZERO) } /// Returns the client coinbase address. @@ -501,7 +512,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_chainId` pub fn eth_chain_id(&self) -> Result> { node_info!("eth_chainId"); - Ok(Some(self.backend.chain_id().into())) + Ok(Some(self.backend.chain_id().to::())) } /// Returns the same as `chain_id` @@ -509,7 +520,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_networkId` pub fn network_id(&self) -> Result> { node_info!("eth_networkId"); - let chain_id = self.backend.chain_id(); + let chain_id = self.backend.chain_id().to::(); Ok(Some(format!("{chain_id}"))) } @@ -562,7 +573,7 @@ impl EthApi { .into_iter() .filter(|acc| unique.insert(*acc)), ); - Ok(accounts) + Ok(accounts.into_iter().map(|acc| acc.to_alloy()).collect()) } /// Returns the number of most recent block. @@ -570,7 +581,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_blockNumber` pub fn block_number(&self) -> Result { node_info!("eth_blockNumber"); - Ok(self.backend.best_number().as_u64().into()) + Ok(U256::from(self.backend.best_number())) } /// Returns balance of the given account. @@ -581,10 +592,13 @@ impl EthApi { let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode - if let BlockRequest::Number(number) = &block_request { + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork(number.as_u64()) { - return Ok(fork.get_balance(address, number.as_u64()).await?) + if fork.predates_fork(number) { + return fork + .get_balance(address, number) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -600,17 +614,23 @@ impl EthApi { address: Address, index: U256, block_number: Option, - ) -> Result { + ) -> Result { node_info!("eth_getStorageAt"); let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode - if let BlockRequest::Number(number) = &block_request { + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork(number.as_u64()) { - return Ok(fork - .storage_at(address, index, Some(BlockNumber::Number(*number))) - .await?) + if fork.predates_fork(number) { + return Ok(B256::from( + fork.storage_at( + address, + B256::from(index), + Some(BlockNumber::Number(number)), + ) + .await + .map_err(|_| BlockchainError::DataUnavailable)?, + )); } } } @@ -621,7 +641,7 @@ impl EthApi { /// Returns block with given hash. /// /// Handler for ETH RPC call: `eth_getBlockByHash` - pub async fn block_by_hash(&self, hash: H256) -> Result>> { + pub async fn block_by_hash(&self, hash: B256) -> Result> { node_info!("eth_getBlockByHash"); self.backend.block_by_hash(hash).await } @@ -629,7 +649,7 @@ impl EthApi { /// Returns a _full_ block with given hash. /// /// Handler for ETH RPC call: `eth_getBlockByHash` - pub async fn block_by_hash_full(&self, hash: H256) -> Result>> { + pub async fn block_by_hash_full(&self, hash: B256) -> Result> { node_info!("eth_getBlockByHash"); self.backend.block_by_hash_full(hash).await } @@ -637,10 +657,10 @@ impl EthApi { /// Returns block with given number. /// /// Handler for ETH RPC call: `eth_getBlockByNumber` - pub async fn block_by_number(&self, number: BlockNumber) -> Result>> { + pub async fn block_by_number(&self, number: BlockNumber) -> Result> { node_info!("eth_getBlockByNumber"); if number == BlockNumber::Pending { - return Ok(Some(self.pending_block().await)) + return Ok(Some(self.pending_block().await)); } self.backend.block_by_number(number).await @@ -649,13 +669,10 @@ impl EthApi { /// Returns a _full_ block with given number /// /// Handler for ETH RPC call: `eth_getBlockByNumber` - pub async fn block_by_number_full( - &self, - number: BlockNumber, - ) -> Result>> { + pub async fn block_by_number_full(&self, number: BlockNumber) -> Result> { node_info!("eth_getBlockByNumber"); if number == BlockNumber::Pending { - return Ok(self.pending_block_full().await) + return Ok(self.pending_block_full().await); } self.backend.block_by_number_full(number).await } @@ -678,10 +695,15 @@ impl EthApi { /// Returns the number of transactions in a block with given hash. /// /// Handler for ETH RPC call: `eth_getBlockTransactionCountByHash` - pub async fn block_transaction_count_by_hash(&self, hash: H256) -> Result> { + pub async fn block_transaction_count_by_hash(&self, hash: B256) -> Result> { node_info!("eth_getBlockTransactionCountByHash"); let block = self.backend.block_by_hash(hash).await?; - Ok(block.map(|b| b.transactions.len().into())) + let txs = block.map(|b| match b.transactions { + BlockTransactions::Full(txs) => U256::from(txs.len()), + BlockTransactions::Hashes(txs) => U256::from(txs.len()), + BlockTransactions::Uncle => U256::from(0), + }); + Ok(txs) } /// Returns the number of transactions in a block with given block number. @@ -695,20 +717,25 @@ impl EthApi { let block_request = self.block_request(Some(block_number.into())).await?; if let BlockRequest::Pending(txs) = block_request { let block = self.backend.pending_block(txs).await; - return Ok(Some(block.transactions.len().into())) + return Ok(Some(U256::from(block.transactions.len()))); } let block = self.backend.block_by_number(block_number).await?; - Ok(block.map(|b| b.transactions.len().into())) + let txs = block.map(|b| match b.transactions { + BlockTransactions::Full(txs) => U256::from(txs.len()), + BlockTransactions::Hashes(txs) => U256::from(txs.len()), + BlockTransactions::Uncle => U256::from(0), + }); + Ok(txs) } /// Returns the number of uncles in a block with given hash. /// /// Handler for ETH RPC call: `eth_getUncleCountByBlockHash` - pub async fn block_uncles_count_by_hash(&self, hash: H256) -> Result { + pub async fn block_uncles_count_by_hash(&self, hash: B256) -> Result { node_info!("eth_getUncleCountByBlockHash"); let block = self.backend.block_by_hash(hash).await?.ok_or(BlockchainError::BlockNotFound)?; - Ok(block.uncles.len().into()) + Ok(U256::from(block.uncles.len())) } /// Returns the number of uncles in a block with given block number. @@ -721,7 +748,7 @@ impl EthApi { .block_by_number(block_number) .await? .ok_or(BlockchainError::BlockNotFound)?; - Ok(block.uncles.len().into()) + Ok(U256::from(block.uncles.len())) } /// Returns the code at given address at given time (block number). @@ -731,10 +758,13 @@ impl EthApi { node_info!("eth_getCode"); let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode - if let BlockRequest::Number(number) = &block_request { + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork(number.as_u64()) { - return Ok(fork.get_code(address, number.as_u64()).await?) + if fork.predates_fork(number) { + return fork + .get_code(address, number) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -748,24 +778,27 @@ impl EthApi { pub async fn get_proof( &self, address: Address, - keys: Vec, + keys: Vec, block_number: Option, - ) -> Result { + ) -> Result { node_info!("eth_getProof"); let block_request = self.block_request(block_number).await?; - if let BlockRequest::Number(number) = &block_request { + // If we're in forking mode, or still on the forked block (no blocks mined yet) then we can + // delegate the call. + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - // if we're in forking mode, or still on the forked block (no blocks mined yet) then - // we can delegate the call - if fork.predates_fork_inclusive(number.as_u64()) { - return Ok(fork.get_proof(address, keys, Some((*number).into())).await?) + if fork.predates_fork_inclusive(number) { + return fork + .get_proof(address, keys, Some(number.into())) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } } let proof = self.backend.prove_account_at(address, keys, Some(block_request)).await?; - Ok(proof) + Ok(to_alloy_proof(proof)) } /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md). @@ -798,7 +831,7 @@ impl EthApi { pub async fn sign_typed_data_v4(&self, address: Address, data: &TypedData) -> Result { node_info!("eth_signTypedData_v4"); let signer = self.get_signer(address).ok_or(BlockchainError::NoSignerAvailable)?; - let signature = signer.sign_typed_data(address, data).await?; + let signature = signer.sign_typed_data(address.to_ethers(), data).await?; Ok(format!("0x{signature}")) } @@ -808,7 +841,7 @@ impl EthApi { pub async fn sign(&self, address: Address, content: impl AsRef<[u8]>) -> Result { node_info!("eth_sign"); let signer = self.get_signer(address).ok_or(BlockchainError::NoSignerAvailable)?; - let signature = signer.sign(address, content.as_ref()).await?; + let signature = signer.sign(address.to_ethers(), content.as_ref()).await?; Ok(format!("0x{signature}")) } @@ -818,16 +851,24 @@ impl EthApi { pub async fn sign_transaction(&self, request: EthTransactionRequest) -> Result { node_info!("eth_signTransaction"); - let from = request.from.map(Ok).unwrap_or_else(|| { - self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) - })?; + let from = request + .from + .map(Ok) + .unwrap_or_else(|| { + self.accounts()? + .first() + .cloned() + .ok_or(BlockchainError::NoSignerAvailable) + .map(|a| a.to_ethers()) + })? + .to_alloy(); let (nonce, _) = self.request_nonce(&request, from).await?; let request = self.build_typed_tx_request(request, nonce)?; let signer = self.get_signer(from).ok_or(BlockchainError::NoSignerAvailable)?; - let signature = signer.sign_transaction(request, &from)?; + let signature = signer.sign_transaction(request, &from.to_ethers())?; Ok(format!("0x{signature}")) } @@ -837,12 +878,19 @@ impl EthApi { pub async fn send_transaction(&self, request: EthTransactionRequest) -> Result { node_info!("eth_sendTransaction"); - let from = request.from.map(Ok).unwrap_or_else(|| { - self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) - })?; + let from = request + .from + .map(Ok) + .unwrap_or_else(|| { + self.accounts()? + .first() + .cloned() + .ok_or(BlockchainError::NoSignerAvailable) + .map(|a| a.to_ethers()) + })? + .to_alloy(); let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; - let request = self.build_typed_tx_request(request, nonce)?; // if the sender is currently impersonated we need to "bypass" signing let pending_transaction = if self.is_impersonated(from) { @@ -850,7 +898,7 @@ impl EthApi { let transaction = sign::build_typed_transaction(request, bypass_signature)?; self.ensure_typed_transaction_supported(&transaction)?; trace!(target : "node", ?from, "eth_sendTransaction: impersonating"); - PendingTransaction::with_impersonated(transaction, from) + PendingTransaction::with_impersonated(transaction, from.to_ethers()) } else { let transaction = self.sign_request(&from, request)?; self.ensure_typed_transaction_supported(&transaction)?; @@ -861,7 +909,7 @@ impl EthApi { self.backend.validate_pool_transaction(&pending_transaction).await?; let requires = required_marker(nonce, on_chain_nonce, from); - let provides = vec![to_marker(nonce.as_u64(), from)]; + let provides = vec![to_marker(nonce.to::(), from)]; debug_assert!(requires != provides); self.add_pending_transaction(pending_transaction, requires, provides) @@ -874,7 +922,7 @@ impl EthApi { node_info!("eth_sendRawTransaction"); let data = tx.as_ref(); if data.is_empty() { - return Err(BlockchainError::EmptyRawTransactionData) + return Err(BlockchainError::EmptyRawTransactionData); } let transaction = if data[0] > 0x7f { // legacy transaction @@ -903,15 +951,16 @@ impl EthApi { // pre-validate self.backend.validate_pool_transaction(&pending_transaction).await?; - let on_chain_nonce = self.backend.current_nonce(*pending_transaction.sender()).await?; + let on_chain_nonce = + self.backend.current_nonce(pending_transaction.sender().to_alloy()).await?; let from = *pending_transaction.sender(); let nonce = *pending_transaction.transaction.nonce(); - let requires = required_marker(nonce, on_chain_nonce, from); + let requires = required_marker(nonce.to_alloy(), on_chain_nonce, from.to_alloy()); let priority = self.transaction_priority(&pending_transaction.transaction); let pool_transaction = PoolTransaction { requires, - provides: vec![to_marker(nonce.as_u64(), *pending_transaction.sender())], + provides: vec![to_marker(nonce.as_u64(), pending_transaction.sender().to_alloy())], pending_transaction, priority, }; @@ -926,22 +975,25 @@ impl EthApi { /// Handler for ETH RPC call: `eth_call` pub async fn call( &self, - request: EthTransactionRequest, + request: CallRequest, block_number: Option, overrides: Option, ) -> Result { node_info!("eth_call"); let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode - if let BlockRequest::Number(number) = &block_request { + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork(number.as_u64()) { + if fork.predates_fork(number) { if overrides.is_some() { return Err(BlockchainError::StateOverrideError( "not available on past forked blocks".to_string(), - )) + )); } - return Ok(fork.call(&request, Some(number.into())).await?) + return fork + .call(&request, Some(number.into())) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -952,7 +1004,7 @@ impl EthApi { request.max_priority_fee_per_gas, )? .or_zero_fees(); - + let request = call_to_internal_tx_request(&request); // this can be blocking for a bit, especially in forking mode // self.on_blocking_task(|this| async move { @@ -980,20 +1032,25 @@ impl EthApi { /// Handler for ETH RPC call: `eth_createAccessList` pub async fn create_access_list( &self, - mut request: EthTransactionRequest, + request: CallRequest, block_number: Option, ) -> Result { node_info!("eth_createAccessList"); let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode - if let BlockRequest::Number(number) = &block_request { + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork(number.as_u64()) { - return Ok(fork.create_access_list(&request, Some(number.into())).await?) + if fork.predates_fork(number) { + return fork + .create_access_list(&request, Some(number.into())) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } } + let mut request = call_to_internal_tx_request(&request); + self.backend .with_database_at(Some(block_request), |state, block_env| { let (exit, out, _, access_list) = self.backend.build_access_list_with_state( @@ -1005,7 +1062,7 @@ impl EthApi { ensure_return_ok(exit, &out)?; // execute again but with access list set - request.access_list = Some(access_list.0.clone()); + request.access_list = Some(to_ethers_access_list(access_list.clone()).0); let (exit, out, gas_used, _) = self.backend.call_with_state( &state, @@ -1017,7 +1074,7 @@ impl EthApi { Ok(AccessListWithGasUsed { access_list: AccessList(access_list.0), - gas_used: gas_used.into(), + gas_used: U256::from(gas_used), }) }) .await? @@ -1029,7 +1086,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_estimateGas` pub async fn estimate_gas( &self, - request: EthTransactionRequest, + request: CallRequest, block_number: Option, ) -> Result { node_info!("eth_estimateGas"); @@ -1043,12 +1100,12 @@ impl EthApi { /// this will also scan the mempool for a matching pending transaction /// /// Handler for ETH RPC call: `eth_getTransactionByHash` - pub async fn transaction_by_hash(&self, hash: H256) -> Result> { + pub async fn transaction_by_hash(&self, hash: B256) -> Result> { node_info!("eth_getTransactionByHash"); let mut tx = self.pool.get_transaction(hash).map(|pending| { let from = *pending.sender(); let mut tx = transaction_build( - Some(*pending.hash()), + Some(pending.hash().to_alloy()), pending.transaction, None, None, @@ -1056,7 +1113,7 @@ impl EthApi { ); // we set the from field here explicitly to the set sender of the pending transaction, // in case the transaction is impersonated. - tx.from = from; + tx.from = from.to_alloy(); tx }); if tx.is_none() { @@ -1071,7 +1128,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_getTransactionByBlockHashAndIndex` pub async fn transaction_by_block_hash_and_index( &self, - hash: H256, + hash: B256, index: Index, ) -> Result> { node_info!("eth_getTransactionByBlockHashAndIndex"); @@ -1093,11 +1150,11 @@ impl EthApi { /// Returns transaction receipt by transaction hash. /// /// Handler for ETH RPC call: `eth_getTransactionReceipt` - pub async fn transaction_receipt(&self, hash: H256) -> Result> { + pub async fn transaction_receipt(&self, hash: B256) -> Result> { node_info!("eth_getTransactionReceipt"); let tx = self.pool.get_transaction(hash); if tx.is_some() { - return Ok(None) + return Ok(None); } self.backend.transaction_receipt(hash).await } @@ -1107,14 +1164,18 @@ impl EthApi { /// Handler for ETH RPC call: `eth_getUncleByBlockHashAndIndex` pub async fn uncle_by_block_hash_and_index( &self, - block_hash: H256, + block_hash: B256, idx: Index, - ) -> Result>> { + ) -> Result> { node_info!("eth_getUncleByBlockHashAndIndex"); - let number = self.backend.ensure_block_number(Some(BlockId::Hash(block_hash))).await?; + let number = + self.backend.ensure_block_number(Some(BlockId::Hash(block_hash.into()))).await?; if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return Ok(fork.uncle_by_block_hash_and_index(block_hash, idx.into()).await?) + return fork + .uncle_by_block_hash_and_index(block_hash, idx.into()) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } // It's impossible to have uncles outside of fork mode @@ -1128,12 +1189,15 @@ impl EthApi { &self, block_number: BlockNumber, idx: Index, - ) -> Result>> { + ) -> Result> { node_info!("eth_getUncleByBlockNumberAndIndex"); let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?; if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return Ok(fork.uncle_by_block_number_and_index(number, idx.into()).await?) + return fork + .uncle_by_block_number_and_index(number, idx.into()) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } // It's impossible to have uncles outside of fork mode @@ -1167,7 +1231,7 @@ impl EthApi { /// Used for submitting a proof-of-work solution. /// /// Handler for ETH RPC call: `eth_submitWork` - pub fn submit_work(&self, _: H64, _: H256, _: H256) -> Result { + pub fn submit_work(&self, _: B64, _: B256, _: B256) -> Result { node_info!("eth_submitWork"); Err(BlockchainError::RpcUnimplemented) } @@ -1175,7 +1239,7 @@ impl EthApi { /// Used for submitting mining hashrate. /// /// Handler for ETH RPC call: `eth_submitHashrate` - pub fn submit_hashrate(&self, _: U256, _: H256) -> Result { + pub fn submit_hashrate(&self, _: U256, _: B256) -> Result { node_info!("eth_submitHashrate"); Err(BlockchainError::RpcUnimplemented) } @@ -1192,13 +1256,13 @@ impl EthApi { node_info!("eth_feeHistory"); // max number of blocks in the requested range - let current = self.backend.best_number().as_u64(); + let current = self.backend.best_number(); let slots_in_an_epoch = 32u64; let number = match newest_block { BlockNumber::Latest | BlockNumber::Pending => current, BlockNumber::Earliest => 0, - BlockNumber::Number(n) => n.as_u64(), + BlockNumber::Number(n) => n, BlockNumber::Safe => current.saturating_sub(slots_in_an_epoch), BlockNumber::Finalized => current.saturating_sub(slots_in_an_epoch * 2), }; @@ -1208,28 +1272,23 @@ impl EthApi { // if we're still at the forked block we don't have any history and can't compute it // efficiently, instead we fetch it from the fork if fork.predates_fork_inclusive(number) { - return Ok(fork - .fee_history( - block_count, - BlockNumber::Number(number.into()), - &reward_percentiles, - ) - .await?) + return fork + .fee_history(block_count, BlockNumber::Number(number), &reward_percentiles) + .await + .map_err(BlockchainError::AlloyForkProvider); } } const MAX_BLOCK_COUNT: u64 = 1024u64; - let range_limit = U256::from(MAX_BLOCK_COUNT); - let block_count = - if block_count > range_limit { range_limit.as_u64() } else { block_count.as_u64() }; + let block_count = block_count.to::().max(MAX_BLOCK_COUNT); // highest and lowest block num in the requested range let highest = number; let lowest = highest.saturating_sub(block_count.saturating_sub(1)); // only support ranges that are in cache range - if lowest < self.backend.best_number().as_u64().saturating_sub(self.fee_history_limit) { - return Err(FeeHistoryError::InvalidBlockRange.into()) + if lowest < self.backend.best_number().saturating_sub(self.fee_history_limit) { + return Err(FeeHistoryError::InvalidBlockRange.into()); } let fee_history = self.fee_history_cache.lock(); @@ -1238,7 +1297,7 @@ impl EthApi { oldest_block: U256::from(lowest), base_fee_per_gas: Vec::new(), gas_used_ratio: Vec::new(), - reward: Default::default(), + reward: Some(Default::default()), }; let mut rewards = Vec::new(); @@ -1259,7 +1318,7 @@ impl EthApi { let reward = if let Some(r) = block.rewards.get(index as usize) { U256::from(*r) } else { - U256::zero() + U256::ZERO }; block_rewards.push(reward); } @@ -1268,14 +1327,14 @@ impl EthApi { } } - response.reward = rewards; + response.reward = Some(rewards); // calculate next base fee if let (Some(last_gas_used), Some(last_fee_per_gas)) = (response.gas_used_ratio.last(), response.base_fee_per_gas.last()) { let elasticity = self.backend.elasticity(); - let last_fee_per_gas = last_fee_per_gas.as_u64() as f64; + let last_fee_per_gas = last_fee_per_gas.to::() as f64; if last_gas_used > &0.5 { // increase base gas let increase = ((last_gas_used - 0.5) * 2f64) * elasticity; @@ -1376,14 +1435,10 @@ impl EthApi { /// Handler for RPC call: `debug_traceTransaction` pub async fn debug_trace_transaction( &self, - tx_hash: H256, + tx_hash: B256, opts: GethDebugTracingOptions, ) -> Result { node_info!("debug_traceTransaction"); - if opts.tracer.is_some() { - return Err(RpcError::invalid_params("non-default tracer not supported yet").into()) - } - self.backend.debug_trace_transaction(tx_hash, opts).await } @@ -1392,14 +1447,11 @@ impl EthApi { /// Handler for RPC call: `debug_traceCall` pub async fn debug_trace_call( &self, - request: EthTransactionRequest, + request: CallRequest, block_number: Option, - opts: GethDebugTracingOptions, + opts: GethDefaultTracingOptions, ) -> Result { node_info!("debug_traceCall"); - if opts.tracer.is_some() { - return Err(RpcError::invalid_params("non-default tracer not supported yet").into()) - } let block_request = self.block_request(block_number).await?; let fees = FeeDetails::new( request.gas_price, @@ -1408,13 +1460,15 @@ impl EthApi { )? .or_zero_fees(); + let request = call_to_internal_tx_request(&request); + self.backend.call_with_tracing(request, fees, Some(block_request), opts).await } /// Returns traces for the transaction hash via parity's tracing endpoint /// /// Handler for RPC call: `trace_transaction` - pub async fn trace_transaction(&self, tx_hash: H256) -> Result> { + pub async fn trace_transaction(&self, tx_hash: B256) -> Result> { node_info!("trace_transaction"); self.backend.trace_transaction(tx_hash).await } @@ -1422,7 +1476,7 @@ impl EthApi { /// Returns traces for the transaction hash via parity's tracing endpoint /// /// Handler for RPC call: `trace_block` - pub async fn trace_block(&self, block: BlockNumber) -> Result> { + pub async fn trace_block(&self, block: BlockNumber) -> Result> { node_info!("trace_block"); self.backend.trace_block(block).await } @@ -1474,7 +1528,7 @@ impl EthApi { node_info!("evm_setAutomine"); if self.miner.is_auto_mine() { if enable_automine { - return Ok(()) + return Ok(()); } self.miner.set_mining_mode(MiningMode::None); } else if enable_automine { @@ -1490,14 +1544,14 @@ impl EthApi { /// Handler for ETH RPC call: `anvil_mine` pub async fn anvil_mine(&self, num_blocks: Option, interval: Option) -> Result<()> { node_info!("anvil_mine"); - let interval = interval.map(|i| i.as_u64()); - let blocks = num_blocks.unwrap_or_else(U256::one); - if blocks == U256::zero() { - return Ok(()) + let interval = interval.map(|i| i.to::()); + let blocks = num_blocks.unwrap_or(U256::from(1)); + if blocks == U256::ZERO { + return Ok(()); } // mine all the blocks - for _ in 0..blocks.as_u64() { + for _ in 0..blocks.to::() { self.mine_one().await; // If we have an interval, jump forwards in time to the "next" timestamp @@ -1531,9 +1585,9 @@ impl EthApi { /// Removes transactions from the pool /// /// Handler for RPC call: `anvil_dropTransaction` - pub async fn anvil_drop_transaction(&self, tx_hash: H256) -> Result> { + pub async fn anvil_drop_transaction(&self, tx_hash: B256) -> Result> { node_info!("anvil_dropTransaction"); - Ok(self.pool.drop_transaction(tx_hash).map(|tx| *tx.hash())) + Ok(self.pool.drop_transaction(tx_hash).map(|tx| tx.hash())) } /// Reset the fork to a fresh forked state, and optionally update the fork config. @@ -1592,7 +1646,7 @@ impl EthApi { &self, address: Address, slot: U256, - val: H256, + val: B256, ) -> Result { node_info!("anvil_setStorageAt"); self.backend.set_storage_at(address, slot, val).await?; @@ -1617,7 +1671,7 @@ impl EthApi { return Err(RpcError::invalid_params( "anvil_setMinGasPrice is not supported when EIP-1559 is active", ) - .into()) + .into()); } self.backend.set_gas_price(gas); Ok(()) @@ -1632,7 +1686,7 @@ impl EthApi { return Err(RpcError::invalid_params( "anvil_setNextBlockBaseFeePerGas is only supported when EIP-1559 is active", ) - .into()) + .into()); } self.backend.set_base_fee(basefee); Ok(()) @@ -1681,7 +1735,7 @@ impl EthApi { let tx_order = self.transaction_order.read(); Ok(NodeInfo { - current_block_number: self.backend.best_number(), + current_block_number: U64::from(self.backend.best_number()), current_block_timestamp: env.block.timestamp.try_into().unwrap_or(u64::MAX), current_block_hash: self.backend.best_hash(), hard_fork: env.cfg.spec_id, @@ -1691,7 +1745,7 @@ impl EthApi { }, environment: NodeEnvironment { base_fee: self.backend.base_fee(), - chain_id: self.backend.chain_id(), + chain_id: self.backend.chain_id().to::(), gas_limit: self.backend.gas_limit(), gas_price: self.backend.gas_price(), }, @@ -1719,9 +1773,9 @@ impl EthApi { Ok(AnvilMetadata { client_version: CLIENT_VERSION, - chain_id: self.backend.chain_id(), + chain_id: self.backend.chain_id().to::(), latest_block_hash: self.backend.best_hash(), - latest_block_number: self.backend.best_number().as_u64(), + latest_block_number: self.backend.best_number(), instance_id: *self.instance_id.read(), forked_network: fork_config.map(|cfg| ForkedNetwork { chain_id: cfg.chain_id(), @@ -1828,27 +1882,28 @@ impl EthApi { /// **Note**: This behaves exactly as [Self::evm_mine] but returns different output, for /// compatibility reasons, this is a separate call since `evm_mine` is not an anvil original. /// and `ganache` may change the `0x0` placeholder. - pub async fn evm_mine_detailed( - &self, - opts: Option, - ) -> Result>> { + pub async fn evm_mine_detailed(&self, opts: Option) -> Result> { node_info!("evm_mine_detailed"); let mined_blocks = self.do_evm_mine(opts).await?; let mut blocks = Vec::with_capacity(mined_blocks as usize); - let latest = self.backend.best_number().as_u64(); + let latest = self.backend.best_number(); for offset in (0..mined_blocks).rev() { let block_num = latest - offset; if let Some(mut block) = - self.backend.block_by_number_full(BlockNumber::Number(block_num.into())).await? + self.backend.block_by_number_full(BlockNumber::Number(block_num)).await? { - for tx in block.transactions.iter_mut() { + let mut block_txs = match block.transactions { + BlockTransactions::Full(txs) => txs, + BlockTransactions::Hashes(_) | BlockTransactions::Uncle => unreachable!(), + }; + for tx in block_txs.iter_mut() { if let Some(receipt) = self.backend.mined_transaction_receipt(tx.hash) { if let Some(output) = receipt.out { // insert revert reason if failure - if receipt.inner.status.unwrap_or_default().as_u64() == 0 { + if receipt.inner.status_code.unwrap_or_default().to::() == 0 { if let Some(reason) = decode_revert_reason(&output) { tx.other.insert( "revertReason".to_string(), @@ -1863,6 +1918,7 @@ impl EthApi { } } } + block.transactions = BlockTransactions::Full(block_txs); blocks.push(block); } } @@ -1886,16 +1942,16 @@ impl EthApi { node_info!("anvil_setRpcUrl"); if let Some(fork) = self.backend.get_fork() { let mut config = fork.config.write(); - let interval = config.provider.get_interval(); + // let interval = config.provider.get_interval(); let new_provider = Arc::new( - ProviderBuilder::new(&url) - .max_retry(10) - .initial_backoff(1000) - .build() - .map_err(|_| { - ProviderError::CustomError(format!("Failed to parse invalid url {url}")) - })? - .interval(interval), + ProviderBuilder::new(&url).max_retry(10).initial_backoff(1000).build().map_err( + |_| { + TransportErrorKind::custom_str( + format!("Failed to parse invalid url {url}").as_str(), + ) + }, + // TODO: Add interval + )?, // .interval(interval), ); config.provider = new_provider; trace!(target: "backend", "Updated fork rpc from \"{}\" to \"{}\"", config.eth_rpc_url, url); @@ -1922,7 +1978,7 @@ impl EthApi { ) -> Result { node_info!("eth_sendUnsignedTransaction"); // either use the impersonated account of the request's `from` field - let from = request.from.ok_or(BlockchainError::NoSignerAvailable)?; + let from = request.from.ok_or(BlockchainError::NoSignerAvailable)?.to_alloy(); let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; @@ -1933,13 +1989,14 @@ impl EthApi { self.ensure_typed_transaction_supported(&transaction)?; - let pending_transaction = PendingTransaction::with_impersonated(transaction, from); + let pending_transaction = + PendingTransaction::with_impersonated(transaction, from.to_ethers()); // pre-validate self.backend.validate_pool_transaction(&pending_transaction).await?; let requires = required_marker(nonce, on_chain_nonce, from); - let provides = vec![to_marker(nonce.as_u64(), from)]; + let provides = vec![to_marker(nonce.to::(), from)]; self.add_pending_transaction(pending_transaction, requires, provides) } @@ -1966,10 +2023,10 @@ impl EthApi { fn convert(tx: Arc) -> TxpoolInspectSummary { let tx = &tx.pending_transaction.transaction; - let to = tx.to().copied(); - let gas_price = tx.gas_price(); - let value = tx.value(); - let gas = tx.gas_limit(); + let to = tx.to().copied().map(ToAlloy::to_alloy); + let gas_price = tx.gas_price().to_alloy(); + let value = tx.value().to_alloy(); + let gas = tx.gas_limit().to_alloy(); TxpoolInspectSummary { to, value, gas, gas_price } } @@ -1980,12 +2037,14 @@ impl EthApi { // not in sequence. The transaction nonce is an incrementing number for each transaction // with the same From address. for pending in self.pool.ready_transactions() { - let entry = inspect.pending.entry(*pending.pending_transaction.sender()).or_default(); + let entry = + inspect.pending.entry(pending.pending_transaction.sender().to_alloy()).or_default(); let key = pending.pending_transaction.nonce().to_string(); entry.insert(key, convert(pending)); } for queued in self.pool.pending_transactions() { - let entry = inspect.pending.entry(*queued.pending_transaction.sender()).or_default(); + let entry = + inspect.pending.entry(queued.pending_transaction.sender().to_alloy()).or_default(); let key = queued.pending_transaction.nonce().to_string(); entry.insert(key, convert(queued)); } @@ -2004,7 +2063,7 @@ impl EthApi { fn convert(tx: Arc) -> Transaction { let from = *tx.pending_transaction.sender(); let mut tx = transaction_build( - Some(*tx.hash()), + Some(tx.hash()), tx.pending_transaction.transaction.clone(), None, None, @@ -2013,17 +2072,19 @@ impl EthApi { // we set the from field here explicitly to the set sender of the pending transaction, // in case the transaction is impersonated. - tx.from = from; + tx.from = from.to_alloy(); tx } for pending in self.pool.ready_transactions() { - let entry = content.pending.entry(*pending.pending_transaction.sender()).or_default(); + let entry = + content.pending.entry(pending.pending_transaction.sender().to_alloy()).or_default(); let key = pending.pending_transaction.nonce().to_string(); entry.insert(key, convert(pending)); } for queued in self.pool.pending_transactions() { - let entry = content.pending.entry(*queued.pending_transaction.sender()).or_default(); + let entry = + content.pending.entry(queued.pending_transaction.sender().to_alloy()).or_default(); let key = queued.pending_transaction.nonce().to_string(); entry.insert(key, convert(queued)); } @@ -2084,15 +2145,18 @@ impl EthApi { async fn do_estimate_gas( &self, - request: EthTransactionRequest, + request: CallRequest, block_number: Option, ) -> Result { let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode - if let BlockRequest::Number(number) = &block_request { + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork(number.as_u64()) { - return Ok(fork.estimate_gas(&request, Some(number.into())).await?) + if fork.predates_fork(number) { + return fork + .estimate_gas(&request, Some(number.into())) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -2106,33 +2170,34 @@ impl EthApi { /// Estimates the gas usage of the `request` with the state. /// - /// This will execute the [EthTransactionRequest] and find the best gas limit via binary search + /// This will execute the [CallRequest] and find the best gas limit via binary search fn do_estimate_gas_with_state( &self, - mut request: EthTransactionRequest, + request: CallRequest, state: D, block_env: BlockEnv, ) -> Result where D: DatabaseRef, { + let mut request = call_to_internal_tx_request(&request); // if the request is a simple transfer we can optimize let likely_transfer = request.data.as_ref().map(|data| data.as_ref().is_empty()).unwrap_or(true); if likely_transfer { if let Some(to) = request.to { - if let Ok(target_code) = self.backend.get_code_with_state(&state, to) { + if let Ok(target_code) = self.backend.get_code_with_state(&state, to.to_alloy()) { if target_code.as_ref().is_empty() { - return Ok(MIN_TRANSACTION_GAS) + return Ok(MIN_TRANSACTION_GAS); } } } } let fees = FeeDetails::new( - request.gas_price, - request.max_fee_per_gas, - request.max_priority_fee_per_gas, + request.gas_price.map(ToAlloy::to_alloy), + request.max_fee_per_gas.map(ToAlloy::to_alloy), + request.max_priority_fee_per_gas.map(ToAlloy::to_alloy), )? .or_zero_fees(); @@ -2143,20 +2208,21 @@ impl EthApi { // check with the funds of the sender if let Some(from) = request.from { let gas_price = fees.gas_price.unwrap_or_default(); - if gas_price > U256::zero() { - let mut available_funds = self.backend.get_balance_with_state(&state, from)?; + if gas_price > U256::ZERO { + let mut available_funds = + self.backend.get_balance_with_state(&state, from.to_alloy())?; if let Some(value) = request.value { - if value > available_funds { - return Err(InvalidTransactionError::InsufficientFunds.into()) + if value > available_funds.to_ethers() { + return Err(InvalidTransactionError::InsufficientFunds.into()); } // safe: value < available_funds - available_funds -= value; + available_funds -= value.to_alloy(); } // amount of gas the sender can afford with the `gas_price` let allowance = available_funds.checked_div(gas_price).unwrap_or_default(); - if highest_gas_limit > allowance { + if highest_gas_limit > allowance.to_ethers() { trace!(target: "node", "eth_estimateGas capped by limited user funds"); - highest_gas_limit = allowance; + highest_gas_limit = allowance.to_ethers(); } } } @@ -2184,8 +2250,8 @@ impl EthApi { self.backend.clone(), block_env, fees, - gas_limit, - )) + gas_limit.to_alloy(), + )); } } @@ -2209,16 +2275,17 @@ impl EthApi { self.backend.clone(), block_env, fees, - gas_limit, + gas_limit.to_alloy(), )) } else { // the transaction did fail due to lack of gas from the user - Err(InvalidTransactionError::Revert(Some(convert_transact_out(&out))).into()) - } + Err(InvalidTransactionError::Revert(Some(convert_transact_out(&out).0.into())) + .into()) + }; } reason => { warn!(target: "node", "estimation failed due to {:?}", reason); - return Err(BlockchainError::EvmError(reason)) + return Err(BlockchainError::EvmError(reason)); } } @@ -2226,16 +2293,19 @@ impl EthApi { // transaction succeeds with. we find this by doing a binary search over the // possible range NOTE: this is the gas the transaction used, which is less than the // transaction requires to succeed - let gas: U256 = gas.into(); + let gas: U256 = U256::from(gas); // Get the starting lowest gas needed depending on the transaction kind. let mut lowest_gas_limit = determine_base_gas_by_kind(request.clone()); // pick a point that's close to the estimated gas - let mut mid_gas_limit = std::cmp::min(gas * 3, (highest_gas_limit + lowest_gas_limit) / 2); + let mut mid_gas_limit = std::cmp::min( + gas * U256::from(3), + ((highest_gas_limit + lowest_gas_limit.to_ethers()) / 2).to_alloy(), + ); // Binary search for the ideal gas limit - while (highest_gas_limit - lowest_gas_limit) > U256::one() { - request.gas = Some(mid_gas_limit); + while (highest_gas_limit - lowest_gas_limit.to_ethers()).to_alloy() > U256::from(1) { + request.gas = Some(mid_gas_limit.to_ethers()); let ethres = self.backend.call_with_state( &state, request.clone(), @@ -2253,8 +2323,8 @@ impl EthApi { lowest_gas_limit = mid_gas_limit; // new midpoint - mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; - continue + mid_gas_limit = ((highest_gas_limit + lowest_gas_limit.to_ethers()) / 2).to_alloy(); + continue; } match ethres { @@ -2263,7 +2333,7 @@ impl EthApi { // at the current midpoint, as spending any more gas would // make no sense (as the TX would still succeed). return_ok!() => { - highest_gas_limit = mid_gas_limit; + highest_gas_limit = mid_gas_limit.to_ethers(); } // If the transaction failed due to lack of gas, we can set a floor for the // lowest gas limit at the current midpoint, as spending any @@ -2286,16 +2356,16 @@ impl EthApi { // real error. Err(reason) => { warn!(target: "node", "estimation failed due to {:?}", reason); - return Err(reason) + return Err(reason); } } // new midpoint - mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; + mid_gas_limit = ((highest_gas_limit + lowest_gas_limit.to_ethers()) / 2).to_alloy(); } trace!(target : "node", "Estimated Gas for call {:?}", highest_gas_limit); - Ok(highest_gas_limit) + Ok(highest_gas_limit.to_alloy()) } /// Updates the `TransactionOrder` @@ -2310,27 +2380,28 @@ impl EthApi { /// Returns the chain ID used for transaction pub fn chain_id(&self) -> u64 { - self.backend.chain_id() + self.backend.chain_id().to::() } + /// Returns the configured fork, if any. pub fn get_fork(&self) -> Option { self.backend.get_fork() } /// Returns the current instance's ID. - pub fn instance_id(&self) -> H256 { + pub fn instance_id(&self) -> B256 { *self.instance_id.read() } /// Resets the instance ID. pub fn reset_instance_id(&self) { - *self.instance_id.write() = H256::random(); + *self.instance_id.write() = B256::random(); } /// Returns the first signer that can sign for the given address #[allow(clippy::borrowed_box)] pub fn get_signer(&self, address: Address) -> Option<&Box> { - self.signers.iter().find(|signer| signer.is_signer_for(address)) + self.signers.iter().find(|signer| signer.is_signer_for(address.to_ethers())) } /// Returns a new block event stream that yields Notifications when a new block was added @@ -2363,14 +2434,14 @@ impl EthApi { } /// Returns the pending block with tx hashes - async fn pending_block(&self) -> Block { + async fn pending_block(&self) -> Block { let transactions = self.pool.ready_transactions().collect::>(); let info = self.backend.pending_block(transactions).await; self.backend.convert_block(info.block) } /// Returns the full pending block with `Transaction` objects - async fn pending_block_full(&self) -> Option> { + async fn pending_block_full(&self) -> Option { let transactions = self.pool.ready_transactions().collect::>(); let BlockInfo { block, transactions, receipts: _ } = self.backend.pending_block(transactions).await; @@ -2384,7 +2455,7 @@ impl EthApi { let tx = block.transactions.get(info.transaction_index as usize)?.clone(); let tx = transaction_build( - Some(info.transaction_hash), + Some(info.transaction_hash.to_alloy()), tx, Some(&block), Some(info), @@ -2405,38 +2476,42 @@ impl EthApi { let max_fee_per_gas = request.max_fee_per_gas; let gas_price = request.gas_price; - let gas_limit = request.gas.map(Ok).unwrap_or_else(|| self.current_gas_limit())?; + let gas_limit = request + .gas + .map(ToAlloy::to_alloy) + .map(Ok) + .unwrap_or_else(|| self.current_gas_limit())?; let request = match request.into_typed_request() { Some(TypedTransactionRequest::Legacy(mut m)) => { - m.nonce = nonce; + m.nonce = nonce.to_ethers(); m.chain_id = Some(chain_id); - m.gas_limit = gas_limit; + m.gas_limit = gas_limit.to_ethers(); if gas_price.is_none() { - m.gas_price = self.gas_price().unwrap_or_default(); + m.gas_price = self.gas_price().unwrap_or_default().to_ethers(); } TypedTransactionRequest::Legacy(m) } Some(TypedTransactionRequest::EIP2930(mut m)) => { - m.nonce = nonce; + m.nonce = nonce.to_ethers(); m.chain_id = chain_id; - m.gas_limit = gas_limit; + m.gas_limit = gas_limit.to_ethers(); if gas_price.is_none() { - m.gas_price = self.gas_price().unwrap_or_default(); + m.gas_price = self.gas_price().unwrap_or_default().to_ethers(); } TypedTransactionRequest::EIP2930(m) } Some(TypedTransactionRequest::EIP1559(mut m)) => { - m.nonce = nonce; + m.nonce = nonce.to_ethers(); m.chain_id = chain_id; - m.gas_limit = gas_limit; + m.gas_limit = gas_limit.to_ethers(); if max_fee_per_gas.is_none() { - m.max_fee_per_gas = self.gas_price().unwrap_or_default(); + m.max_fee_per_gas = self.gas_price().unwrap_or_default().to_ethers(); } TypedTransactionRequest::EIP1559(m) } Some(TypedTransactionRequest::Deposit(mut m)) => { - m.gas_limit = gas_limit; + m.gas_limit = gas_limit.to_ethers(); TypedTransactionRequest::Deposit(m) } _ => return Err(BlockchainError::FailedToDecodeTransaction), @@ -2446,7 +2521,7 @@ impl EthApi { /// Returns true if the `addr` is currently impersonated pub fn is_impersonated(&self, addr: Address) -> bool { - self.backend.cheats().is_impersonated(addr) + self.backend.cheats().is_impersonated(addr.to_ethers()) } /// Returns the nonce of the `address` depending on the `block_number` @@ -2457,10 +2532,13 @@ impl EthApi { ) -> Result { let block_request = self.block_request(block_number).await?; - if let BlockRequest::Number(number) = &block_request { + if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork_inclusive(number.as_u64()) { - return Ok(fork.get_nonce(address, number.as_u64()).await?) + if fork.predates_fork_inclusive(number) { + return fork + .get_nonce(address, number) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } } @@ -2484,7 +2562,7 @@ impl EthApi { ) -> Result<(U256, U256)> { let highest_nonce = self.get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))).await?; - let nonce = request.nonce.unwrap_or(highest_nonce); + let nonce = request.nonce.map(ToAlloy::to_alloy).unwrap_or(highest_nonce); Ok((nonce, highest_nonce)) } @@ -2506,7 +2584,7 @@ impl EthApi { } /// Returns the current state root - pub async fn state_root(&self) -> Option { + pub async fn state_root(&self) -> Option { self.backend.get_db().read().await.maybe_state_root() } @@ -2523,11 +2601,11 @@ impl EthApi { fn required_marker(provided_nonce: U256, on_chain_nonce: U256, from: Address) -> Vec { if provided_nonce == on_chain_nonce { - return Vec::new() + return Vec::new(); } - let prev_nonce = provided_nonce.saturating_sub(U256::one()); + let prev_nonce = provided_nonce.saturating_sub(U256::from(1)); if on_chain_nonce <= prev_nonce { - vec![to_marker(prev_nonce.as_u64(), from)] + vec![to_marker(prev_nonce.to::(), from)] } else { Vec::new() } @@ -2546,7 +2624,7 @@ fn ensure_return_ok(exit: InstructionResult, out: &Option) -> Result Ok(out), - return_revert!() => Err(InvalidTransactionError::Revert(Some(out)).into()), + return_revert!() => Err(InvalidTransactionError::Revert(Some(out.0.into())).into()), reason => Err(BlockchainError::EvmError(reason)), } } @@ -2565,7 +2643,7 @@ fn map_out_of_gas_err( where D: DatabaseRef, { - request.gas = Some(backend.gas_limit()); + request.gas = Some(backend.gas_limit()).map(|g| g.to_ethers()); let (exit, out, _, _) = match backend.call_with_state(&state, request, fees, block_env) { Ok(res) => res, Err(err) => return err, @@ -2574,11 +2652,11 @@ where return_ok!() => { // transaction succeeded by manually increasing the gas limit to // highest, which means the caller lacks funds to pay for the tx - InvalidTransactionError::BasicOutOfGas(gas_limit).into() + InvalidTransactionError::BasicOutOfGas(gas_limit.to_ethers()).into() } return_revert!() => { // reverted again after bumping the limit - InvalidTransactionError::Revert(Some(convert_transact_out(&out))).into() + InvalidTransactionError::Revert(Some(convert_transact_out(&out).0.into())).into() } reason => { warn!(target: "node", "estimation failed due to {:?}", reason); diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 87684b9a64b81..7d86e4893d824 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -1,14 +1,10 @@ //! Helper types for working with [revm](foundry_evm::revm) -use crate::{mem::state::trie_hash_db, revm::primitives::AccountInfo, U256}; -use alloy_primitives::{Address as B160, B256, U256 as rU256}; +use crate::{mem::state::trie_hash_db, revm::primitives::AccountInfo}; +use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; +use alloy_rpc_types::BlockId; use anvil_core::eth::trie::KeccakHasher; -use ethers::{ - prelude::{Address, Bytes}, - types::{BlockId, H256}, - utils::keccak256, -}; -use foundry_common::{errors::FsPathError, types::ToAlloy}; +use foundry_common::errors::FsPathError; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot}, fork::BlockchainDb, @@ -30,11 +26,11 @@ pub type AsHashDB = Box>>; #[auto_impl::auto_impl(Box)] pub trait MaybeHashDatabase: DatabaseRef { /// Return the DB as read-only hashdb and the root key - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, H256)> { + fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { None } /// Return the storage DB as read-only hashdb and the storage root of the account - fn maybe_account_db(&self, _addr: Address) -> Option<(AsHashDB, H256)> { + fn maybe_account_db(&self, _addr: Address) -> Option<(AsHashDB, B256)> { None } @@ -52,10 +48,10 @@ impl<'a, T: 'a + MaybeHashDatabase + ?Sized> MaybeHashDatabase for &'a T where &'a T: DatabaseRef, { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, H256)> { + fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { T::maybe_as_hash_db(self) } - fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, H256)> { + fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, B256)> { T::maybe_account_db(self, addr) } @@ -95,7 +91,7 @@ pub trait Db: /// Sets the nonce of the given address fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()> { - let mut info = self.basic(address.to_alloy())?.unwrap_or_default(); + let mut info = self.basic(address)?.unwrap_or_default(); info.nonce = nonce; self.insert_account(address, info); Ok(()) @@ -103,15 +99,15 @@ pub trait Db: /// Sets the balance of the given address fn set_balance(&mut self, address: Address, balance: U256) -> DatabaseResult<()> { - let mut info = self.basic(address.to_alloy())?.unwrap_or_default(); - info.balance = balance.to_alloy(); + let mut info = self.basic(address)?.unwrap_or_default(); + info.balance = balance; self.insert_account(address, info); Ok(()) } /// Sets the balance of the given address fn set_code(&mut self, address: Address, code: Bytes) -> DatabaseResult<()> { - let mut info = self.basic(address.to_alloy())?.unwrap_or_default(); + let mut info = self.basic(address)?.unwrap_or_default(); let code_hash = if code.as_ref().is_empty() { KECCAK_EMPTY } else { @@ -127,7 +123,7 @@ pub trait Db: fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()>; /// inserts a blockhash for the given number - fn insert_block_hash(&mut self, number: U256, hash: H256); + fn insert_block_hash(&mut self, number: U256, hash: B256); /// Write all chain data to serialized bytes buffer fn dump_state(&self) -> DatabaseResult>; @@ -135,7 +131,7 @@ pub trait Db: /// Deserialize and add all chain data to the backend storage fn load_state(&mut self, state: SerializableState) -> DatabaseResult { for (addr, account) in state.accounts.into_iter() { - let old_account_nonce = DatabaseRef::basic_ref(self, addr.to_alloy()) + let old_account_nonce = DatabaseRef::basic_ref(self, addr) .ok() .and_then(|acc| acc.map(|acc| acc.nonce)) .unwrap_or_default(); @@ -146,7 +142,7 @@ pub trait Db: self.insert_account( addr, AccountInfo { - balance: account.balance.to_alloy(), + balance: account.balance, code_hash: KECCAK_EMPTY, // will be set automatically code: if account.code.0.is_empty() { None @@ -175,7 +171,7 @@ pub trait Db: fn revert(&mut self, snapshot: U256, action: RevertSnapshotAction) -> bool; /// Returns the state root if possible to compute - fn maybe_state_root(&self) -> Option { + fn maybe_state_root(&self) -> Option { None } @@ -189,15 +185,15 @@ pub trait Db: /// [Backend::pending_block()](crate::eth::backend::mem::Backend::pending_block()) impl + Send + Sync + Clone + fmt::Debug> Db for CacheDB { fn insert_account(&mut self, address: Address, account: AccountInfo) { - self.insert_account_info(address.to_alloy(), account) + self.insert_account_info(address, account) } fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.insert_account_storage(address.to_alloy(), slot.to_alloy(), val.to_alloy()) + self.insert_account_storage(address, slot, val) } - fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.block_hashes.insert(number.to_alloy(), hash.to_alloy()); + fn insert_block_hash(&mut self, number: U256, hash: B256) { + self.block_hashes.insert(number, hash); } fn dump_state(&self) -> DatabaseResult> { @@ -205,7 +201,7 @@ impl + Send + Sync + Clone + fmt::Debug> D } fn snapshot(&mut self) -> U256 { - U256::zero() + U256::ZERO } fn revert(&mut self, _snapshot: U256, _action: RevertSnapshotAction) -> bool { @@ -218,7 +214,7 @@ impl + Send + Sync + Clone + fmt::Debug> D } impl> MaybeHashDatabase for CacheDB { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, H256)> { + fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { Some(trie_hash_db(&self.accounts)) } fn clear_into_snapshot(&mut self) -> StateSnapshot { @@ -287,7 +283,7 @@ impl StateDb { impl DatabaseRef for StateDb { type Error = DatabaseError; - fn basic_ref(&self, address: B160) -> DatabaseResult> { + fn basic_ref(&self, address: Address) -> DatabaseResult> { self.0.basic_ref(address) } @@ -295,21 +291,21 @@ impl DatabaseRef for StateDb { self.0.code_by_hash_ref(code_hash) } - fn storage_ref(&self, address: B160, index: rU256) -> DatabaseResult { + fn storage_ref(&self, address: Address, index: U256) -> DatabaseResult { self.0.storage_ref(address, index) } - fn block_hash_ref(&self, number: rU256) -> DatabaseResult { + fn block_hash_ref(&self, number: U256) -> DatabaseResult { self.0.block_hash_ref(number) } } impl MaybeHashDatabase for StateDb { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, H256)> { + fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { self.0.maybe_as_hash_db() } - fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, H256)> { + fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, B256)> { self.0.maybe_account_db(addr) } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index ed7adfc413314..a3100d5800de6 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -20,12 +20,13 @@ use ethers::{ use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::DatabaseError, + inspectors::{TracingInspector, TracingInspectorConfig}, revm, revm::{ interpreter::InstructionResult, primitives::{BlockEnv, CfgEnv, EVMError, Env, ExecutionResult, Output, SpecId}, }, - traces::{CallTraceArena, CallTraceNode}, + traces::CallTraceNode, utils::{eval_to_instruction_result, halt_to_instruction_result}, }; use std::sync::Arc; @@ -164,14 +165,14 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let transaction_index = transaction_infos.len() as u32; let info = TransactionInfo { - transaction_hash: *transaction.hash(), + transaction_hash: transaction.hash().to_ethers(), transaction_index, from: *transaction.pending_transaction.sender(), to: transaction.pending_transaction.transaction.to().copied(), contract_address: contract_address.map(|c| c.to_ethers()), logs, logs_bloom: *receipt.logs_bloom(), - traces: CallTraceArena { arena: traces }, + traces, exit, out: match out { Some(Output::Call(b)) => Some(ethers::types::Bytes(b.0)), @@ -192,7 +193,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let partial_header = PartialHeader { parent_hash, beneficiary: beneficiary.to_ethers(), - state_root: self.db.maybe_state_root().unwrap_or_default(), + state_root: self.db.maybe_state_root().unwrap_or_default().to_ethers(), receipts_root, logs_bloom: bloom, difficulty: difficulty.to_ethers(), @@ -321,7 +322,12 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator out, gas_used, logs: logs.unwrap_or_default().into_iter().map(Into::into).collect(), - traces: inspector.tracer.unwrap_or_default().traces.arena, + traces: inspector + .tracer + .unwrap_or(TracingInspector::new(TracingInspectorConfig::all())) + .get_traces() + .clone() + .into_nodes(), nonce, }; diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index c58ed414b38b8..9e6add417efd2 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -1,18 +1,19 @@ //! Support for forking off another client use crate::eth::{backend::db::Db, error::BlockchainError}; -use anvil_core::eth::{proof::AccountProof, transaction::EthTransactionRequest}; -use ethers::{ - prelude::BlockNumber, - providers::{Middleware, ProviderError}, - types::{ - transaction::eip2930::AccessListWithGasUsed, Address, Block, BlockId, Bytes, FeeHistory, - Filter, GethDebugTracingOptions, GethTrace, Log, Trace, Transaction, TransactionReceipt, - TxHash, H256, U256, - }, +use alloy_primitives::{Address, Bytes, StorageKey, StorageValue, B256, U256, U64}; +use alloy_providers::provider::TempProvider; +use alloy_rpc_trace_types::{ + geth::{GethDebugTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace as Trace, }; -use foundry_common::{ProviderBuilder, RetryProvider}; -use foundry_evm::utils::u256_to_h256_be; +use alloy_rpc_types::{ + AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + CallRequest, EIP1186AccountProofResponse, FeeHistory, Filter, Log, Transaction, + TransactionReceipt, +}; +use alloy_transport::TransportError; +use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; use parking_lot::{ lock_api::{RwLockReadGuard, RwLockWriteGuard}, RawRwLock, RwLock, @@ -63,23 +64,23 @@ impl ClientFork { self.config.write().update_url(url)?; let override_chain_id = self.config.read().override_chain_id; let chain_id = if let Some(chain_id) = override_chain_id { - chain_id.into() + chain_id } else { - self.provider().get_chainid().await? + self.provider().get_chain_id().await?.to::() }; - self.config.write().chain_id = chain_id.as_u64(); + self.config.write().chain_id = chain_id; } let provider = self.provider(); let block = - provider.get_block(block_number).await?.ok_or(BlockchainError::BlockNotFound)?; - let block_hash = block.hash.ok_or(BlockchainError::BlockNotFound)?; - let timestamp = block.timestamp.as_u64(); - let base_fee = block.base_fee_per_gas; + provider.get_block(block_number, false).await?.ok_or(BlockchainError::BlockNotFound)?; + let block_hash = block.header.hash.ok_or(BlockchainError::BlockNotFound)?; + let timestamp = block.header.timestamp.to::(); + let base_fee = block.header.base_fee_per_gas; let total_difficulty = block.total_difficulty.unwrap_or_default(); self.config.write().update_block( - block.number.ok_or(BlockchainError::BlockNotFound)?.as_u64(), + block.header.number.ok_or(BlockchainError::BlockNotFound)?.to::(), block_hash, timestamp, base_fee, @@ -121,7 +122,7 @@ impl ClientFork { self.config.read().base_fee } - pub fn block_hash(&self) -> H256 { + pub fn block_hash(&self) -> B256 { self.config.read().block_hash } @@ -151,73 +152,75 @@ impl ClientFork { block_count: U256, newest_block: BlockNumber, reward_percentiles: &[f64], - ) -> Result { - self.provider().fee_history(block_count, newest_block, reward_percentiles).await + ) -> Result { + self.provider().get_fee_history(block_count, newest_block, reward_percentiles).await } /// Sends `eth_getProof` pub async fn get_proof( &self, address: Address, - keys: Vec, + keys: Vec, block_number: Option, - ) -> Result { + ) -> Result { self.provider().get_proof(address, keys, block_number).await } /// Sends `eth_call` pub async fn call( &self, - request: &EthTransactionRequest, + request: &CallRequest, block: Option, - ) -> Result { + ) -> Result { let request = Arc::new(request.clone()); let block = block.unwrap_or(BlockNumber::Latest); if let BlockNumber::Number(num) = block { // check if this request was already been sent - let key = (request.clone(), num.as_u64()); + let key = (request.clone(), num); if let Some(res) = self.storage_read().eth_call.get(&key).cloned() { - return Ok(res) + return Ok(res); } } - let tx = ethers::utils::serialize(request.as_ref()); - let block_value = ethers::utils::serialize(&block); - let res: Bytes = self.provider().request("eth_call", [tx, block_value]).await?; + let block_id: BlockId = block.into(); + + let res: Bytes = self.provider().call((*request).clone(), Some(block_id)).await?; if let BlockNumber::Number(num) = block { // cache result let mut storage = self.storage_write(); - storage.eth_call.insert((request, num.as_u64()), res.clone()); + storage.eth_call.insert((request, num), res.clone()); } + Ok(res) } /// Sends `eth_call` pub async fn estimate_gas( &self, - request: &EthTransactionRequest, + request: &CallRequest, block: Option, - ) -> Result { + ) -> Result { let request = Arc::new(request.clone()); let block = block.unwrap_or(BlockNumber::Latest); if let BlockNumber::Number(num) = block { // check if this request was already been sent - let key = (request.clone(), num.as_u64()); + let key = (request.clone(), num); if let Some(res) = self.storage_read().eth_gas_estimations.get(&key).cloned() { - return Ok(res) + return Ok(res); } } - let tx = ethers::utils::serialize(request.as_ref()); - let block_value = ethers::utils::serialize(&block); - let res = self.provider().request("eth_estimateGas", [tx, block_value]).await?; + + let block_id: BlockId = block.into(); + + let res = self.provider().estimate_gas((*request).clone(), Some(block_id)).await?; if let BlockNumber::Number(num) = block { // cache result let mut storage = self.storage_write(); - storage.eth_gas_estimations.insert((request, num.as_u64()), res); + storage.eth_gas_estimations.insert((request, num), res); } Ok(res) @@ -226,30 +229,28 @@ impl ClientFork { /// Sends `eth_createAccessList` pub async fn create_access_list( &self, - request: &EthTransactionRequest, + request: &CallRequest, block: Option, - ) -> Result { - let tx = ethers::utils::serialize(request); - let block = ethers::utils::serialize(&block.unwrap_or(BlockNumber::Latest)); - self.provider().request("eth_createAccessList", [tx, block]).await + ) -> Result { + self.provider().create_access_list(request.clone(), block.map(|b| b.into())).await } pub async fn storage_at( &self, address: Address, - index: U256, + index: StorageKey, number: Option, - ) -> Result { - let index = u256_to_h256_be(index); + ) -> Result { + let index = B256::from(index); self.provider().get_storage_at(address, index, number.map(Into::into)).await } - pub async fn logs(&self, filter: &Filter) -> Result, ProviderError> { + pub async fn logs(&self, filter: &Filter) -> Result, TransportError> { if let Some(logs) = self.storage_read().logs.get(filter).cloned() { - return Ok(logs) + return Ok(logs); } - let logs = self.provider().get_logs(filter).await?; + let logs = self.provider().get_logs(filter.clone()).await?; let mut storage = self.storage_write(); storage.logs.insert(filter.clone(), logs.clone()); @@ -260,15 +261,18 @@ impl ClientFork { &self, address: Address, blocknumber: u64, - ) -> Result { + ) -> Result { trace!(target: "backend::fork", "get_code={:?}", address); if let Some(code) = self.storage_read().code_at.get(&(address, blocknumber)).cloned() { - return Ok(code) + return Ok(code); } - let code = self.provider().get_code(address, Some(blocknumber.into())).await?; + let block_id = BlockId::Number(blocknumber.into()); + + let code = self.provider().get_code_at(address, block_id).await?; + let mut storage = self.storage_write(); - storage.code_at.insert((address, blocknumber), code.clone()); + storage.code_at.insert((address, blocknumber), code.clone().0.into()); Ok(code) } @@ -277,7 +281,7 @@ impl ClientFork { &self, address: Address, blocknumber: u64, - ) -> Result { + ) -> Result { trace!(target: "backend::fork", "get_balance={:?}", address); self.provider().get_balance(address, Some(blocknumber.into())).await } @@ -286,7 +290,7 @@ impl ClientFork { &self, address: Address, blocknumber: u64, - ) -> Result { + ) -> Result { trace!(target: "backend::fork", "get_nonce={:?}", address); self.provider().get_transaction_count(address, Some(blocknumber.into())).await } @@ -295,10 +299,21 @@ impl ClientFork { &self, number: u64, index: usize, - ) -> Result, ProviderError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_number(number).await? { - if let Some(tx_hash) = block.transactions.get(index) { - return self.transaction_by_hash(*tx_hash).await + match block.transactions { + BlockTransactions::Full(txs) => { + if let Some(tx) = txs.get(index) { + return Ok(Some(tx.clone())); + } + } + BlockTransactions::Hashes(hashes) => { + if let Some(tx_hash) = hashes.get(index) { + return self.transaction_by_hash(*tx_hash).await; + } + } + // TODO(evalir): Is it possible to reach this case? Should we support it + BlockTransactions::Uncle => panic!("Uncles not supported"), } } Ok(None) @@ -306,12 +321,23 @@ impl ClientFork { pub async fn transaction_by_block_hash_and_index( &self, - hash: H256, + hash: B256, index: usize, - ) -> Result, ProviderError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_hash(hash).await? { - if let Some(tx_hash) = block.transactions.get(index) { - return self.transaction_by_hash(*tx_hash).await + match block.transactions { + BlockTransactions::Full(txs) => { + if let Some(tx) = txs.get(index) { + return Ok(Some(tx.clone())); + } + } + BlockTransactions::Hashes(hashes) => { + if let Some(tx_hash) = hashes.get(index) { + return self.transaction_by_hash(*tx_hash).await; + } + } + // TODO(evalir): Is it possible to reach this case? Should we support it + BlockTransactions::Uncle => panic!("Uncles not supported"), } } Ok(None) @@ -319,27 +345,27 @@ impl ClientFork { pub async fn transaction_by_hash( &self, - hash: H256, - ) -> Result, ProviderError> { + hash: B256, + ) -> Result, TransportError> { trace!(target: "backend::fork", "transaction_by_hash={:?}", hash); if let tx @ Some(_) = self.storage_read().transactions.get(&hash).cloned() { - return Ok(tx) + return Ok(tx); } - if let Some(tx) = self.provider().get_transaction(hash).await? { - let mut storage = self.storage_write(); - storage.transactions.insert(hash, tx.clone()); - return Ok(Some(tx)) - } - Ok(None) + let tx = self.provider().get_transaction_by_hash(hash).await?; + + let mut storage = self.storage_write(); + storage.transactions.insert(hash, tx.clone()); + Ok(Some(tx)) } - pub async fn trace_transaction(&self, hash: H256) -> Result, ProviderError> { + pub async fn trace_transaction(&self, hash: B256) -> Result, TransportError> { if let Some(traces) = self.storage_read().transaction_traces.get(&hash).cloned() { - return Ok(traces) + return Ok(traces); } - let traces = self.provider().trace_transaction(hash).await?; + let traces = self.provider().trace_transaction(hash).await?.into_iter().collect::>(); + let mut storage = self.storage_write(); storage.transaction_traces.insert(hash, traces.clone()); @@ -348,26 +374,29 @@ impl ClientFork { pub async fn debug_trace_transaction( &self, - hash: H256, + hash: B256, opts: GethDebugTracingOptions, - ) -> Result { + ) -> Result { if let Some(traces) = self.storage_read().geth_transaction_traces.get(&hash).cloned() { - return Ok(traces) + return Ok(traces); } let trace = self.provider().debug_trace_transaction(hash, opts).await?; + let mut storage = self.storage_write(); storage.geth_transaction_traces.insert(hash, trace.clone()); Ok(trace) } - pub async fn trace_block(&self, number: u64) -> Result, ProviderError> { + pub async fn trace_block(&self, number: u64) -> Result, TransportError> { if let Some(traces) = self.storage_read().block_traces.get(&number).cloned() { - return Ok(traces) + return Ok(traces); } - let traces = self.provider().trace_block(number.into()).await?; + let traces = + self.provider().trace_block(number.into()).await?.into_iter().collect::>(); + let mut storage = self.storage_write(); storage.block_traces.insert(number, traces.clone()); @@ -376,35 +405,36 @@ impl ClientFork { pub async fn transaction_receipt( &self, - hash: H256, - ) -> Result, ProviderError> { + hash: B256, + ) -> Result, TransportError> { if let Some(receipt) = self.storage_read().transaction_receipts.get(&hash).cloned() { - return Ok(Some(receipt)) + return Ok(Some(receipt)); } if let Some(receipt) = self.provider().get_transaction_receipt(hash).await? { let mut storage = self.storage_write(); storage.transaction_receipts.insert(hash, receipt.clone()); - return Ok(Some(receipt)) + return Ok(Some(receipt)); } Ok(None) } - pub async fn block_by_hash(&self, hash: H256) -> Result>, ProviderError> { - if let Some(block) = self.storage_read().blocks.get(&hash).cloned() { - return Ok(Some(block)) + pub async fn block_by_hash(&self, hash: B256) -> Result, TransportError> { + if let Some(mut block) = self.storage_read().blocks.get(&hash).cloned() { + block.transactions.convert_to_hashes(); + return Ok(Some(block)); } - let block = self.fetch_full_block(hash).await?.map(Into::into); - Ok(block) + + Ok(self.fetch_full_block(hash).await?.map(|mut b| { + b.transactions.convert_to_hashes(); + b + })) } - pub async fn block_by_hash_full( - &self, - hash: H256, - ) -> Result>, ProviderError> { + pub async fn block_by_hash_full(&self, hash: B256) -> Result, TransportError> { if let Some(block) = self.storage_read().blocks.get(&hash).cloned() { - return Ok(Some(self.convert_to_full_block(block))) + return Ok(Some(self.convert_to_full_block(block))); } self.fetch_full_block(hash).await } @@ -412,25 +442,28 @@ impl ClientFork { pub async fn block_by_number( &self, block_number: u64, - ) -> Result>, ProviderError> { - if let Some(block) = self + ) -> Result, TransportError> { + if let Some(mut block) = self .storage_read() .hashes .get(&block_number) - .copied() - .and_then(|hash| self.storage_read().blocks.get(&hash).cloned()) + .and_then(|hash| self.storage_read().blocks.get(hash).cloned()) { - return Ok(Some(block)) + block.transactions.convert_to_hashes(); + return Ok(Some(block)); } - let block = self.fetch_full_block(block_number).await?.map(Into::into); + let mut block = self.fetch_full_block(block_number).await?; + if let Some(block) = &mut block { + block.transactions.convert_to_hashes(); + } Ok(block) } pub async fn block_by_number_full( &self, block_number: u64, - ) -> Result>, ProviderError> { + ) -> Result, TransportError> { if let Some(block) = self .storage_read() .hashes @@ -438,7 +471,7 @@ impl ClientFork { .copied() .and_then(|hash| self.storage_read().blocks.get(&hash).cloned()) { - return Ok(Some(self.convert_to_full_block(block))) + return Ok(Some(self.convert_to_full_block(block))); } self.fetch_full_block(block_number).await @@ -447,16 +480,20 @@ impl ClientFork { async fn fetch_full_block( &self, block_id: impl Into, - ) -> Result>, ProviderError> { - if let Some(block) = self.provider().get_block_with_txs(block_id.into()).await? { - let hash = block.hash.unwrap(); - let block_number = block.number.unwrap().as_u64(); + ) -> Result, TransportError> { + if let Some(block) = self.provider().get_block(block_id.into(), true).await? { + let hash = block.header.hash.unwrap(); + let block_number = block.header.number.unwrap().to::(); let mut storage = self.storage_write(); // also insert all transactions - storage.transactions.extend(block.transactions.iter().map(|tx| (tx.hash, tx.clone()))); + let block_txs = match block.clone().transactions { + BlockTransactions::Full(txs) => txs, + _ => vec![], + }; + storage.transactions.extend(block_txs.iter().map(|tx| (tx.hash, tx.clone()))); storage.hashes.insert(block_number, hash); - storage.blocks.insert(hash, block.clone().into()); - return Ok(Some(block)) + storage.blocks.insert(hash, block.clone()); + return Ok(Some(block)); } Ok(None) @@ -464,11 +501,11 @@ impl ClientFork { pub async fn uncle_by_block_hash_and_index( &self, - hash: H256, + hash: B256, index: usize, - ) -> Result>, ProviderError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_hash(hash).await? { - return self.uncles_by_block_and_index(block, index).await + return self.uncles_by_block_and_index(block, index).await; } Ok(None) } @@ -477,28 +514,31 @@ impl ClientFork { &self, number: u64, index: usize, - ) -> Result>, ProviderError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_number(number).await? { - return self.uncles_by_block_and_index(block, index).await + return self.uncles_by_block_and_index(block, index).await; } Ok(None) } async fn uncles_by_block_and_index( &self, - block: Block, + block: Block, index: usize, - ) -> Result>, ProviderError> { - let block_hash = block - .hash - .ok_or_else(|| ProviderError::CustomError("missing block-hash".to_string()))?; + ) -> Result, TransportError> { + let block_hash = block.header.hash.expect("Missing block hash"); + let block_number = block.header.number.expect("Missing block number"); if let Some(uncles) = self.storage_read().uncles.get(&block_hash) { - return Ok(uncles.get(index).cloned()) + return Ok(uncles.get(index).cloned()); } let mut uncles = Vec::with_capacity(block.uncles.len()); for (uncle_idx, _) in block.uncles.iter().enumerate() { - let uncle = match self.provider().get_uncle(block_hash, uncle_idx.into()).await? { + let uncle = match self + .provider() + .get_uncle(block_number.to::().into(), U64::from(uncle_idx)) + .await? + { Some(u) => u, None => return Ok(None), }; @@ -509,10 +549,16 @@ impl ClientFork { } /// Converts a block of hashes into a full block - fn convert_to_full_block(&self, block: Block) -> Block { + fn convert_to_full_block(&self, block: Block) -> Block { let storage = self.storage.read(); - let mut transactions = Vec::with_capacity(block.transactions.len()); - for tx in block.transactions.iter() { + let block_txs_len = match block.transactions { + BlockTransactions::Full(ref txs) => txs.len(), + BlockTransactions::Hashes(ref hashes) => hashes.len(), + // TODO: Should this be supported at all? + BlockTransactions::Uncle => 0, + }; + let mut transactions = Vec::with_capacity(block_txs_len); + for tx in block.transactions.hashes() { if let Some(tx) = storage.transactions.get(tx).cloned() { transactions.push(tx); } @@ -526,7 +572,7 @@ impl ClientFork { pub struct ClientForkConfig { pub eth_rpc_url: String, pub block_number: u64, - pub block_hash: H256, + pub block_hash: B256, // TODO make provider agnostic pub provider: Arc, pub chain_id: u64, @@ -556,7 +602,7 @@ impl ClientForkConfig { /// /// This will fail if no new provider could be established (erroneous URL) fn update_url(&mut self, url: String) -> Result<(), BlockchainError> { - let interval = self.provider.get_interval(); + // let interval = self.provider.get_interval(); self.provider = Arc::new( ProviderBuilder::new(url.as_str()) .timeout(self.timeout) @@ -565,8 +611,7 @@ impl ClientForkConfig { .initial_backoff(self.backoff.as_millis() as u64) .compute_units_per_second(self.compute_units_per_second) .build() - .map_err(|_| BlockchainError::InvalidUrl(url.clone()))? - .interval(interval), + .map_err(|_| BlockchainError::InvalidUrl(url.clone()))?, // .interval(interval), ); trace!(target: "fork", "Updated rpc url {}", url); self.eth_rpc_url = url; @@ -576,7 +621,7 @@ impl ClientForkConfig { pub fn update_block( &mut self, block_number: u64, - block_hash: H256, + block_hash: B256, timestamp: u64, base_fee: Option, total_difficulty: U256, @@ -593,17 +638,17 @@ impl ClientForkConfig { /// Contains cached state fetched to serve EthApi requests #[derive(Clone, Debug, Default)] pub struct ForkedStorage { - pub uncles: HashMap>>, - pub blocks: HashMap>, - pub hashes: HashMap, - pub transactions: HashMap, - pub transaction_receipts: HashMap, - pub transaction_traces: HashMap>, + pub uncles: HashMap>, + pub blocks: HashMap, + pub hashes: HashMap, + pub transactions: HashMap, + pub transaction_receipts: HashMap, + pub transaction_traces: HashMap>, pub logs: HashMap>, - pub geth_transaction_traces: HashMap, + pub geth_transaction_traces: HashMap, pub block_traces: HashMap>, - pub eth_gas_estimations: HashMap<(Arc, u64), U256>, - pub eth_call: HashMap<(Arc, u64), Bytes>, + pub eth_gas_estimations: HashMap<(Arc, u64), U256>, + pub eth_call: HashMap<(Arc, u64), Bytes>, pub code_at: HashMap<(Address, u64), Bytes>, } diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index ab8b8984118bd..523208ba83b42 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -4,12 +4,7 @@ use crate::{ eth::backend::db::{Db, MaybeHashDatabase}, genesis::Genesis, }; -use alloy_primitives::{Address as aAddress, B256, U256}; -use ethers::{ - abi::ethereum_types::BigEndianHash, - types::{Address, H256}, -}; -use foundry_common::types::{ToAlloy, ToEthers}; +use alloy_primitives::{Address, B256, U256}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, StateSnapshot}, revm::{ @@ -68,7 +63,7 @@ impl GenesisConfig { db.insert_account(addr, acc.into()); // insert all storage values for (k, v) in storage.iter() { - db.set_storage_at(addr, k.into_uint(), v.into_uint())?; + db.set_storage_at(addr, U256::from_be_bytes(k.0), U256::from_be_bytes(v.0))?; } } } @@ -103,8 +98,8 @@ pub(crate) struct AtGenesisStateDb<'a> { impl<'a> DatabaseRef for AtGenesisStateDb<'a> { type Error = DatabaseError; - fn basic_ref(&self, address: aAddress) -> DatabaseResult> { - if let Some(acc) = self.accounts.get(&(address.to_ethers())).cloned() { + fn basic_ref(&self, address: Address) -> DatabaseResult> { + if let Some(acc) = self.accounts.get(&(address)).cloned() { return Ok(Some(acc)) } self.db.basic_ref(address) @@ -117,18 +112,12 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> { self.db.code_by_hash_ref(code_hash) } - fn storage_ref(&self, address: aAddress, index: U256) -> DatabaseResult { - if let Some(acc) = self - .genesis - .as_ref() - .and_then(|genesis| genesis.alloc.accounts.get(&(address.to_ethers()))) + fn storage_ref(&self, address: Address, index: U256) -> DatabaseResult { + if let Some(acc) = + self.genesis.as_ref().and_then(|genesis| genesis.alloc.accounts.get(&(address))) { - let value = acc - .storage - .get(&H256::from_uint(&(index.to_ethers()))) - .copied() - .unwrap_or_default(); - return Ok(value.into_uint().to_alloy()) + let value = acc.storage.get(&B256::from(index)).copied().unwrap_or_default(); + return Ok(U256::from_be_bytes(value.0)) } self.db.storage_ref(address, index) } diff --git a/crates/anvil/src/eth/backend/info.rs b/crates/anvil/src/eth/backend/info.rs index 8d4e3601b30d4..de0a3d2ac54e0 100644 --- a/crates/anvil/src/eth/backend/info.rs +++ b/crates/anvil/src/eth/backend/info.rs @@ -1,8 +1,9 @@ //! Handler that can get current storage related data use crate::mem::Backend; +use alloy_primitives::B256; +use alloy_rpc_types::Block as AlloyBlock; use anvil_core::eth::{block::Block, receipt::TypedReceipt}; -use ethers::types::{Block as EthersBlock, TxHash, H256}; use std::{fmt, sync::Arc}; /// A type that can fetch data related to the ethereum storage. @@ -33,17 +34,17 @@ impl StorageInfo { } /// Returns the receipts of the block with the given hash - pub fn receipts(&self, hash: H256) -> Option> { + pub fn receipts(&self, hash: B256) -> Option> { self.backend.mined_receipts(hash) } /// Returns the block with the given hash - pub fn block(&self, hash: H256) -> Option { + pub fn block(&self, hash: B256) -> Option { self.backend.get_block_by_hash(hash) } /// Returns the block with the given hash in the format of the ethereum API - pub fn eth_block(&self, hash: H256) -> Option> { + pub fn eth_block(&self, hash: B256) -> Option { let block = self.block(hash)?; Some(self.backend.convert_block(block)) } diff --git a/crates/anvil/src/eth/backend/mem/cache.rs b/crates/anvil/src/eth/backend/mem/cache.rs index a3990e82de2a7..d4aff594878d0 100644 --- a/crates/anvil/src/eth/backend/mem/cache.rs +++ b/crates/anvil/src/eth/backend/mem/cache.rs @@ -1,5 +1,5 @@ use crate::config::anvil_tmp_dir; -use ethers::prelude::H256; +use alloy_primitives::B256; use foundry_evm::backend::StateSnapshot; use std::{ io, @@ -19,7 +19,7 @@ pub struct DiskStateCache { impl DiskStateCache { /// Returns the cache file for the given hash - fn with_cache_file(&mut self, hash: H256, f: F) -> Option + fn with_cache_file(&mut self, hash: B256, f: F) -> Option where F: FnOnce(PathBuf) -> R, { @@ -56,7 +56,7 @@ impl DiskStateCache { /// Note: this writes the state on a new spawned task /// /// Caution: this requires a running tokio Runtime. - pub fn write(&mut self, hash: H256, state: StateSnapshot) { + pub fn write(&mut self, hash: B256, state: StateSnapshot) { self.with_cache_file(hash, |file| { tokio::task::spawn(async move { match foundry_common::fs::write_json_file(&file, &state) { @@ -74,7 +74,7 @@ impl DiskStateCache { /// Loads the snapshot file for the given hash /// /// Returns None if it doesn't exist or deserialization failed - pub fn read(&mut self, hash: H256) -> Option { + pub fn read(&mut self, hash: B256) -> Option { self.with_cache_file(hash, |file| { match foundry_common::fs::read_json_file::(&file) { Ok(state) => { @@ -91,7 +91,7 @@ impl DiskStateCache { } /// Removes the cache file for the given hash, if it exists - pub fn remove(&mut self, hash: H256) { + pub fn remove(&mut self, hash: B256) { self.with_cache_file(hash, |file| { foundry_common::fs::remove_file(file).map_err(|err| { error!(target: "backend", %err, %hash, "Failed to remove state snapshot"); diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 41cf8cdaf7920..c9cc10a22efc5 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -4,10 +4,9 @@ use crate::{ StateDb, }, revm::primitives::AccountInfo, - Address, U256, }; -use ethers::{prelude::H256, types::BlockId}; -use foundry_common::types::{ToAlloy, ToEthers}; +use alloy_primitives::{Address, B256, U256}; +use alloy_rpc_types::BlockId; use foundry_evm::{ backend::{DatabaseResult, RevertSnapshotAction, StateSnapshot}, fork::{database::ForkDbSnapshot, BlockchainDb}, @@ -24,12 +23,12 @@ impl Db for ForkedDatabase { fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { // this ensures the account is loaded first - let _ = Database::basic(self, address.to_alloy())?; + let _ = Database::basic(self, address)?; self.database_mut().set_storage_at(address, slot, val) } - fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.inner().block_hashes().write().insert(number.to_alloy(), hash.to_alloy()); + fn insert_block_hash(&mut self, number: U256, hash: B256) { + self.inner().block_hashes().write().insert(number, hash); } fn dump_state(&self) -> DatabaseResult> { @@ -47,16 +46,12 @@ impl Db for ForkedDatabase { } .to_checked(); Ok(( - k.to_ethers(), + k, SerializableAccountRecord { nonce: v.info.nonce, - balance: v.info.balance.to_ethers(), - code: code.bytes()[..code.len()].to_vec().into(), - storage: v - .storage - .into_iter() - .map(|kv| (kv.0.to_ethers(), kv.1.to_ethers())) - .collect(), + balance: v.info.balance, + code: code.original_bytes(), + storage: v.storage.into_iter().collect(), }, )) }) @@ -65,11 +60,11 @@ impl Db for ForkedDatabase { } fn snapshot(&mut self) -> U256 { - self.insert_snapshot().to_ethers() + self.insert_snapshot() } fn revert(&mut self, id: U256, action: RevertSnapshotAction) -> bool { - self.revert_snapshot(id.to_alloy(), action) + self.revert_snapshot(id, action) } fn current_state(&self) -> StateDb { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index acf929e0c6584..66b8c8941cebf 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -7,10 +7,9 @@ use crate::{ }, mem::state::{state_merkle_trie_root, storage_trie_db, trie_hash_db}, revm::primitives::AccountInfo, - Address, U256, }; -use ethers::{prelude::H256, types::BlockId}; -use foundry_common::types::{ToAlloy, ToEthers}; +use alloy_primitives::{Address, B256, U256}; +use alloy_rpc_types::BlockId; use foundry_evm::{ backend::{DatabaseResult, StateSnapshot}, fork::BlockchainDb, @@ -22,15 +21,15 @@ pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; impl Db for MemDb { fn insert_account(&mut self, address: Address, account: AccountInfo) { - self.inner.insert_account_info(address.to_alloy(), account) + self.inner.insert_account_info(address, account) } fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.inner.insert_account_storage(address.to_alloy(), slot.to_alloy(), val.to_alloy()) + self.inner.insert_account_storage(address, slot, val) } - fn insert_block_hash(&mut self, number: U256, hash: H256) { - self.inner.block_hashes.insert(number.to_alloy(), hash.to_alloy()); + fn insert_block_hash(&mut self, number: U256, hash: B256) { + self.inner.block_hashes.insert(number, hash); } fn dump_state(&self) -> DatabaseResult> { @@ -47,16 +46,12 @@ impl Db for MemDb { } .to_checked(); Ok(( - k.to_ethers(), + k, SerializableAccountRecord { nonce: v.info.nonce, - balance: v.info.balance.to_ethers(), - code: code.bytes()[..code.len()].to_vec().into(), - storage: v - .storage - .into_iter() - .map(|k| (k.0.to_ethers(), k.1.to_ethers())) - .collect(), + balance: v.info.balance, + code: code.original_bytes(), + storage: v.storage.into_iter().collect(), }, )) }) @@ -69,13 +64,13 @@ impl Db for MemDb { fn snapshot(&mut self) -> U256 { let id = self.snapshots.insert(self.inner.clone()); trace!(target: "backend::memdb", "Created new snapshot {}", id); - id.to_ethers() + id } fn revert(&mut self, id: U256, action: RevertSnapshotAction) -> bool { - if let Some(snapshot) = self.snapshots.remove(id.to_alloy()) { + if let Some(snapshot) = self.snapshots.remove(id) { if action.is_keep() { - self.snapshots.insert_at(snapshot.clone(), id.to_alloy()); + self.snapshots.insert_at(snapshot.clone(), id); } self.inner = snapshot; trace!(target: "backend::memdb", "Reverted snapshot {}", id); @@ -86,7 +81,7 @@ impl Db for MemDb { } } - fn maybe_state_root(&self) -> Option { + fn maybe_state_root(&self) -> Option { Some(state_merkle_trie_root(&self.inner.accounts)) } @@ -96,12 +91,12 @@ impl Db for MemDb { } impl MaybeHashDatabase for MemDb { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, H256)> { + fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { Some(trie_hash_db(&self.inner.accounts)) } - fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, H256)> { - if let Some(acc) = self.inner.accounts.get(&addr.to_alloy()) { + fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, B256)> { + if let Some(acc) = self.inner.accounts.get(&addr) { Some(storage_trie_db(&acc.storage)) } else { Some(storage_trie_db(&Default::default())) @@ -141,11 +136,8 @@ mod tests { use crate::{ eth::backend::db::{Db, SerializableAccountRecord, SerializableState}, revm::primitives::AccountInfo, - Address, }; - use alloy_primitives::{Bytes, U256 as rU256}; - use ethers::types::U256; - use foundry_common::types::ToAlloy; + use alloy_primitives::{Address, Bytes, U256}; use foundry_evm::{ backend::MemDb, revm::primitives::{Bytecode, KECCAK_EMPTY}, @@ -166,7 +158,7 @@ mod tests { dump_db.insert_account( test_addr, AccountInfo { - balance: rU256::from(123456), + balance: U256::from(123456), code_hash: KECCAK_EMPTY, code: Some(contract_code.clone()), nonce: 1234, @@ -181,15 +173,12 @@ mod tests { load_db.load_state(state).unwrap(); - let loaded_account = load_db.basic_ref(test_addr.to_alloy()).unwrap().unwrap(); + let loaded_account = load_db.basic_ref(test_addr).unwrap().unwrap(); - assert_eq!(loaded_account.balance, rU256::from(123456)); + assert_eq!(loaded_account.balance, U256::from(123456)); assert_eq!(load_db.code_by_hash_ref(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); - assert_eq!( - load_db.storage_ref(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), - rU256::from(1) - ); + assert_eq!(load_db.storage_ref(test_addr, U256::from(1234567)).unwrap(), U256::from(1)); } // verifies that multiple accounts can be loaded at a time, and storage is merged within those @@ -208,7 +197,7 @@ mod tests { db.insert_account( test_addr, AccountInfo { - balance: rU256::from(123456), + balance: U256::from(123456), code_hash: KECCAK_EMPTY, code: Some(contract_code.clone()), nonce: 1234, @@ -236,7 +225,7 @@ mod tests { new_state.accounts.insert( test_addr, SerializableAccountRecord { - balance: 100100.into(), + balance: U256::from(100100), code: contract_code.bytes()[..contract_code.len()].to_vec().into(), nonce: 100, storage: new_storage, @@ -245,21 +234,15 @@ mod tests { db.load_state(new_state).unwrap(); - let loaded_account = db.basic_ref(test_addr.to_alloy()).unwrap().unwrap(); - let loaded_account2 = db.basic_ref(test_addr2.to_alloy()).unwrap().unwrap(); + let loaded_account = db.basic_ref(test_addr).unwrap().unwrap(); + let loaded_account2 = db.basic_ref(test_addr2).unwrap().unwrap(); assert_eq!(loaded_account2.nonce, 1); - assert_eq!(loaded_account.balance, rU256::from(100100)); + assert_eq!(loaded_account.balance, U256::from(100100)); assert_eq!(db.code_by_hash_ref(loaded_account.code_hash).unwrap(), contract_code); assert_eq!(loaded_account.nonce, 1234); - assert_eq!( - db.storage_ref(test_addr.to_alloy(), rU256::from(1234567)).unwrap(), - rU256::from(1) - ); - assert_eq!( - db.storage_ref(test_addr.to_alloy(), rU256::from(1234568)).unwrap(), - rU256::from(5) - ); + assert_eq!(db.storage_ref(test_addr, U256::from(1234567)).unwrap(), U256::from(1)); + assert_eq!(db.storage_ref(test_addr, U256::from(1234568)).unwrap(), U256::from(5)); } } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 6c978ac386c55..d1b45bea453a5 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -5,19 +5,20 @@ use ethers::types::Log; use foundry_evm::{ call_inspectors, decode::decode_console_logs, - inspectors::{LogCollector, Tracer}, + inspectors::{LogCollector, TracingInspector}, revm, revm::{ interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, primitives::{Address, Bytes, B256}, EVMData, }, + traces::TracingInspectorConfig, }; /// The [`revm::Inspector`] used when transacting in the evm #[derive(Clone, Debug, Default)] pub struct Inspector { - pub tracer: Option, + pub tracer: Option, /// collects all `console.sol` logs pub log_collector: LogCollector, } @@ -34,15 +35,13 @@ impl Inspector { /// Configures the `Tracer` [`revm::Inspector`] pub fn with_tracing(mut self) -> Self { - self.tracer = Some(Default::default()); + self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all())); self } /// Enables steps recording for `Tracer`. - pub fn with_steps_tracing(mut self) -> Self { - let tracer = self.tracer.get_or_insert_with(Default::default); - tracer.record_steps(); - self + pub fn with_steps_tracing(self) -> Self { + self.with_tracing() } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d8c4cdac8ccc2..d87a9e8996a81 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -29,15 +29,24 @@ use crate::{ }, NodeConfig, }; +use alloy_primitives::{Address, Bloom, Bytes, TxHash, B256, B64, U128, U256, U64, U8}; +use alloy_rpc_trace_types::{ + geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace, +}; +use alloy_rpc_types::{ + state::StateOverride, AccessList, Block as AlloyBlock, BlockId, + BlockNumberOrTag as BlockNumber, Filter, FilteredParams, Header as AlloyHeader, Log, + Transaction, TransactionReceipt, +}; use anvil_core::{ eth::{ block::{Block, BlockInfo, Header}, proof::{AccountProof, BasicAccount, StorageProof}, receipt::{EIP658Receipt, TypedReceipt}, - state::StateOverride, transaction::{ - EthTransactionRequest, MaybeImpersonatedTransaction, PendingTransaction, - TransactionInfo, TypedTransaction, + from_ethers_access_list, EthTransactionRequest, MaybeImpersonatedTransaction, + PendingTransaction, TransactionInfo, TypedTransaction, }, trie::RefTrieDB, utils::to_revm_access_list, @@ -47,12 +56,7 @@ use anvil_core::{ use anvil_rpc::error::RpcError; use ethers::{ abi::ethereum_types::BigEndianHash, - prelude::{BlockNumber, GethTraceFrame, TxHash, H256, U256, U64}, - types::{ - transaction::eip2930::AccessList, Address, Block as EthersBlock, BlockId, Bytes, - DefaultFrame, Filter, FilteredParams, GethDebugTracingOptions, GethTrace, Log, OtherFields, - Trace, Transaction, TransactionReceipt, H160, - }, + types::transaction::eip2930::AccessList as EthersAccessList, utils::{keccak256, rlp}, }; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; @@ -67,14 +71,16 @@ use foundry_evm::{ db::CacheDB, interpreter::InstructionResult, primitives::{ - Account, BlockEnv, CreateScheme, EVMError, Env, ExecutionResult, InvalidHeader, Output, - SpecId, TransactTo, TxEnv, KECCAK_EMPTY, + BlockEnv, CreateScheme, EVMError, Env, ExecutionResult, InvalidHeader, Output, SpecId, + TransactTo, TxEnv, KECCAK_EMPTY, }, }, + traces::{TracingInspector, TracingInspectorConfig}, utils::{eval_to_instruction_result, halt_to_instruction_result, u256_to_h256_be}, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; use hash_db::HashDB; +use itertools::Itertools; use parking_lot::{Mutex, RwLock}; use std::{ collections::{BTreeMap, HashMap}, @@ -95,25 +101,24 @@ pub mod state; pub mod storage; // Gas per transaction not creating a contract. -pub const MIN_TRANSACTION_GAS: U256 = U256([21_000, 0, 0, 0]); +pub const MIN_TRANSACTION_GAS: U256 = U256::from_limbs([21_000, 0, 0, 0]); // Gas per transaction creating a contract. -pub const MIN_CREATE_GAS: U256 = U256([53_000, 0, 0, 0]); +pub const MIN_CREATE_GAS: U256 = U256::from_limbs([53_000, 0, 0, 0]); -// TODO: This is the same as foundry_evm::utils::StateChangeset but with ethers H160 -pub type State = foundry_evm::hashbrown::HashMap; +pub type State = foundry_evm::utils::StateChangeset; /// A block request, which includes the Pool Transactions if it's Pending #[derive(Debug)] pub enum BlockRequest { Pending(Vec>), - Number(U64), + Number(u64), } impl BlockRequest { pub fn block_number(&self) -> BlockNumber { - match self { + match *self { BlockRequest::Pending(_) => BlockNumber::Pending, - BlockRequest::Number(n) => BlockNumber::Number(*n), + BlockRequest::Number(n) => BlockNumber::Number(n), } } } @@ -159,7 +164,7 @@ pub struct Backend { /// listeners for new blocks that get notified when a new block was imported new_block_listeners: Arc>>>, /// keeps track of active snapshots at a specific block - active_snapshots: Arc>>, + active_snapshots: Arc>>, enable_steps_tracing: bool, /// How to keep history state prune_state_history_config: PruneStateHistoryConfig, @@ -267,7 +272,7 @@ impl Backend { // accounts concurrently by spawning the job to a new task genesis_accounts_futures.push(tokio::task::spawn(async move { let db = db.read().await; - let info = db.basic_ref(address.to_alloy())?.unwrap_or_default(); + let info = db.basic_ref(address)?.unwrap_or_default(); Ok::<_, DatabaseError>((address, info)) })); } @@ -307,20 +312,20 @@ impl Backend { /// /// Returns `true` if the account is already impersonated pub async fn impersonate(&self, addr: Address) -> DatabaseResult { - if self.cheats.impersonated_accounts().contains(&addr) { - return Ok(true) + if self.cheats.impersonated_accounts().contains(&addr.to_ethers()) { + return Ok(true); } // Ensure EIP-3607 is disabled let mut env = self.env.write(); env.cfg.disable_eip3607 = true; - Ok(self.cheats.impersonate(addr)) + Ok(self.cheats.impersonate(addr.to_ethers())) } /// Removes the account that from the impersonated set /// /// If the impersonated `addr` is a contract then we also reset the code here pub async fn stop_impersonating(&self, addr: Address) -> DatabaseResult<()> { - self.cheats.stop_impersonating(&addr); + self.cheats.stop_impersonating(&addr.to_ethers()); Ok(()) } @@ -341,7 +346,7 @@ impl Backend { /// Returns the `AccountInfo` from the database pub async fn get_account(&self, address: Address) -> DatabaseResult { - Ok(self.db.read().await.basic_ref(address.to_alloy())?.unwrap_or_default()) + Ok(self.db.read().await.basic_ref(address)?.unwrap_or_default()) } /// Whether we're forked off some remote client @@ -351,6 +356,9 @@ impl Backend { pub fn precompiles(&self) -> Vec
{ get_precompiles_for(self.env.read().cfg.spec_id) + .into_iter() + .map(ToAlloy::to_alloy) + .collect_vec() } /// Resets the fork to a fresh state @@ -379,7 +387,7 @@ impl Backend { return Err(RpcError::invalid_params( "Forking not enabled and RPC URL not provided to start forking", ) - .into()) + .into()); } } @@ -391,7 +399,8 @@ impl Backend { let fork_block_number = fork.block_number(); let fork_block = fork .block_by_number(fork_block_number) - .await? + .await + .map_err(|_| BlockchainError::DataUnavailable)? .ok_or(BlockchainError::BlockNotFound)?; // update all settings related to the forked block { @@ -400,11 +409,10 @@ impl Backend { env.block = BlockEnv { number: rU256::from(fork_block_number), - timestamp: fork_block.timestamp.to_alloy(), - gas_limit: fork_block.gas_limit.to_alloy(), - difficulty: fork_block.difficulty.to_alloy(), - // ensures prevrandao is set - prevrandao: Some(fork_block.mix_hash.map(|h| h.to_alloy()).unwrap_or_default()), + timestamp: fork_block.header.timestamp, + gas_limit: fork_block.header.gas_limit, + difficulty: fork_block.header.difficulty, + prevrandao: Some(fork_block.header.mix_hash.unwrap_or_default()), // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, @@ -416,12 +424,12 @@ impl Backend { // this is the base fee of the current block, but we need the base fee of // the next block let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( - fork_block.gas_used, - fork_block.gas_limit, - fork_block.base_fee_per_gas.unwrap_or_default(), + fork_block.header.gas_used, + fork_block.header.gas_limit, + fork_block.header.base_fee_per_gas.unwrap_or_default(), ); - self.fees.set_base_fee(next_block_base_fee.into()); + self.fees.set_base_fee(U256::from(next_block_base_fee)); // also reset the total difficulty self.blockchain.storage.write().total_difficulty = fork.total_difficulty(); @@ -479,29 +487,29 @@ impl Backend { } /// Returns the current best hash of the chain - pub fn best_hash(&self) -> H256 { + pub fn best_hash(&self) -> B256 { self.blockchain.storage.read().best_hash } /// Returns the current best number of the chain - pub fn best_number(&self) -> U64 { - self.env.read().block.number.saturating_to::().into() + pub fn best_number(&self) -> u64 { + self.env.read().block.number.try_into().unwrap_or(u64::MAX) } /// Sets the block number pub fn set_block_number(&self, number: U256) { let mut env = self.env.write(); - env.block.number = number.to_alloy(); + env.block.number = number; } /// Returns the client coinbase address. pub fn coinbase(&self) -> Address { - self.env.read().block.coinbase.to_ethers() + self.env.read().block.coinbase } /// Returns the client coinbase address. - pub fn chain_id(&self) -> u64 { - self.env.read().cfg.chain_id + pub fn chain_id(&self) -> U256 { + U256::from(self.env.read().cfg.chain_id) } pub fn set_chain_id(&self, chain_id: u64) { @@ -510,17 +518,17 @@ impl Backend { /// Returns balance of the given account. pub async fn current_balance(&self, address: Address) -> DatabaseResult { - Ok(self.get_account(address).await?.balance.to_ethers()) + Ok(self.get_account(address).await?.balance) } /// Returns balance of the given account. pub async fn current_nonce(&self, address: Address) -> DatabaseResult { - Ok(self.get_account(address).await?.nonce.into()) + Ok(U256::from(self.get_account(address).await?.nonce)) } /// Sets the coinbase address pub fn set_coinbase(&self, address: Address) { - self.env.write().block.coinbase = address.to_alloy(); + self.env.write().block.coinbase = address; } /// Sets the nonce of the given address @@ -535,7 +543,7 @@ impl Backend { /// Sets the code of the given address pub async fn set_code(&self, address: Address, code: Bytes) -> DatabaseResult<()> { - self.db.write().await.set_code(address, code) + self.db.write().await.set_code(address, code.0.into()) } /// Sets the value for the given slot of the given address @@ -543,9 +551,9 @@ impl Backend { &self, address: Address, slot: U256, - val: H256, + val: B256, ) -> DatabaseResult<()> { - self.db.write().await.set_storage_at(address, slot, val.into_uint()) + self.db.write().await.set_storage_at(address, slot, val.to_ethers().into_uint().to_alloy()) } /// Returns the configured specid @@ -576,7 +584,7 @@ impl Backend { /// Returns an error if EIP1559 is not active (pre Berlin) pub fn ensure_eip1559_active(&self) -> Result<(), BlockchainError> { if self.is_eip1559() { - return Ok(()) + return Ok(()); } Err(BlockchainError::EIP1559TransactionUnsupportedAtHardfork) } @@ -584,7 +592,7 @@ impl Backend { /// Returns an error if EIP1559 is not active (pre muirGlacier) pub fn ensure_eip2930_active(&self) -> Result<(), BlockchainError> { if self.is_eip2930() { - return Ok(()) + return Ok(()); } Err(BlockchainError::EIP2930TransactionUnsupportedAtHardfork) } @@ -599,12 +607,12 @@ impl Backend { /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { - self.env.read().block.gas_limit.to_ethers() + self.env.read().block.gas_limit } /// Sets the block gas limit pub fn set_gas_limit(&self, gas_limit: U256) { - self.env.write().block.gas_limit = gas_limit.to_alloy(); + self.env.write().block.gas_limit = gas_limit; } /// Returns the current base fee @@ -648,7 +656,7 @@ impl Backend { /// /// Returns the id of the snapshot created pub async fn create_snapshot(&self) -> U256 { - let num = self.best_number().as_u64(); + let num = self.best_number(); let hash = self.best_hash(); let id = self.db.write().await.snapshot(); trace!(target: "backend", "creating snapshot {} at {}", id, num); @@ -662,39 +670,39 @@ impl Backend { if let Some((num, hash)) = block { let best_block_hash = { // revert the storage that's newer than the snapshot - let current_height = self.best_number().as_u64(); + let current_height = self.best_number(); let mut storage = self.blockchain.storage.write(); for n in ((num + 1)..=current_height).rev() { trace!(target: "backend", "reverting block {}", n); - let n: U64 = n.into(); + let n = U64::from(n); if let Some(hash) = storage.hashes.remove(&n) { if let Some(block) = storage.blocks.remove(&hash) { for tx in block.transactions { - let _ = storage.transactions.remove(&tx.hash()); + let _ = storage.transactions.remove(&tx.hash().to_alloy()); } } } } - storage.best_number = num.into(); + storage.best_number = U64::from(num); storage.best_hash = hash; hash }; let block = self.block_by_hash(best_block_hash).await?.ok_or(BlockchainError::BlockNotFound)?; - let reset_time = block.timestamp.as_u64(); + let reset_time = block.header.timestamp.to::(); self.time.reset(reset_time); let mut env = self.env.write(); env.block = BlockEnv { number: rU256::from(num), - timestamp: block.timestamp.to_alloy(), - difficulty: block.difficulty.to_alloy(), + timestamp: block.header.timestamp, + difficulty: block.header.difficulty, // ensures prevrandao is set - prevrandao: Some(block.mix_hash.unwrap_or_default()).map(|h| h.to_alloy()), - gas_limit: block.gas_limit.to_alloy(), + prevrandao: Some(block.header.mix_hash.unwrap_or_default()), + gas_limit: block.header.gas_limit, // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, @@ -704,7 +712,7 @@ impl Backend { Ok(self.db.write().await.revert(id, RevertSnapshotAction::RevertRemove)) } - pub fn list_snapshots(&self) -> BTreeMap { + pub fn list_snapshots(&self) -> BTreeMap { self.active_snapshots.lock().clone().into_iter().collect() } @@ -758,7 +766,7 @@ impl Backend { let mut env = self.env.read().clone(); // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = self.base_fee().to_alloy(); + env.block.basefee = self.base_fee(); env.block.timestamp = rU256::from(self.time.current_call_timestamp()); env } @@ -784,8 +792,6 @@ impl Backend { Err(e) => return Err(e.into()), }; let state = result_and_state.state; - let state: revm::primitives::HashMap = - state.into_iter().map(|kv| (kv.0.to_ethers(), kv.1)).collect(); let (exit_reason, gas_used, out, logs) = match result_and_state.result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { (eval_to_instruction_result(reason), gas_used, Some(output), Some(logs)) @@ -834,8 +840,8 @@ impl Backend { pending: pool_transactions.into_iter(), block_env: env.block.clone(), cfg_env: env.cfg, - parent_hash: storage.best_hash, - gas_used: U256::zero(), + parent_hash: storage.best_hash.to_ethers(), + gas_used: U256::ZERO.to_ethers(), enable_steps_tracing: self.enable_steps_tracing, }; @@ -874,7 +880,7 @@ impl Backend { // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = current_base_fee.to_alloy(); + env.block.basefee = current_base_fee; env.block.timestamp = rU256::from(self.time.next_timestamp()); let best_hash = self.blockchain.storage.read().best_hash; @@ -893,15 +899,18 @@ impl Backend { pending: pool_transactions.into_iter(), block_env: env.block.clone(), cfg_env: env.cfg.clone(), - parent_hash: best_hash, - gas_used: U256::zero(), + parent_hash: best_hash.to_ethers(), + gas_used: U256::ZERO.to_ethers(), enable_steps_tracing: self.enable_steps_tracing, }; let executed_tx = executor.execute(); // we also need to update the new blockhash in the db itself let block_hash = executed_tx.block.block.header.hash(); - db.insert_block_hash(executed_tx.block.block.header.number, block_hash); + db.insert_block_hash( + executed_tx.block.block.header.number.to_alloy(), + block_hash.to_alloy(), + ); (executed_tx, block_hash) }; @@ -911,7 +920,7 @@ impl Backend { let BlockInfo { block, transactions, receipts } = block; let header = block.header.clone(); - let block_number: U64 = (env.block.number.to_ethers()).as_u64().into(); + let block_number: U64 = env.block.number.to::(); trace!( target: "backend", @@ -924,16 +933,16 @@ impl Backend { let mut storage = self.blockchain.storage.write(); // update block metadata storage.best_number = block_number; - storage.best_hash = block_hash; + storage.best_hash = block_hash.to_alloy(); // Difficulty is removed and not used after Paris (aka TheMerge). Value is replaced with // prevrandao. https://github.com/bluealloy/revm/blob/1839b3fce8eaeebb85025576f2519b80615aca1e/crates/interpreter/src/instructions/host_env.rs#L27 if !self.is_eip3675() { storage.total_difficulty = - storage.total_difficulty.saturating_add(header.difficulty); + storage.total_difficulty.saturating_add(header.difficulty.to_alloy()); } - storage.blocks.insert(block_hash, block); - storage.hashes.insert(block_number, block_hash); + storage.blocks.insert(block_hash.to_alloy(), block); + storage.hashes.insert(block_number, block_hash.to_alloy()); node_info!(""); // insert all transactions @@ -957,17 +966,17 @@ impl Backend { let mined_tx = MinedTransaction { info, receipt, - block_hash, - block_number: block_number.as_u64(), + block_hash: block_hash.to_alloy(), + block_number: block_number.to::(), }; - storage.transactions.insert(mined_tx.info.transaction_hash, mined_tx); + storage.transactions.insert(mined_tx.info.transaction_hash.to_alloy(), mined_tx); } // remove old transactions that exceed the transaction block keeper if let Some(transaction_block_keeper) = self.transaction_block_keeper { if storage.blocks.len() > transaction_block_keeper { let to_clear = block_number - .as_u64() + .to::() .saturating_sub(transaction_block_keeper.try_into().unwrap()); storage.remove_block_transactions_by_number(to_clear) } @@ -990,16 +999,16 @@ impl Backend { (outcome, header, block_hash) }; let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( - header.gas_used, - header.gas_limit, - header.base_fee_per_gas.unwrap_or_default(), + header.gas_used.to_alloy(), + header.gas_limit.to_alloy(), + header.base_fee_per_gas.unwrap_or_default().to_alloy(), ); // notify all listeners - self.notify_on_new_block(header, block_hash); + self.notify_on_new_block(header, block_hash.to_alloy()); // update next base fee - self.fees.set_base_fee(next_block_base_fee.into()); + self.fees.set_base_fee(U256::from(next_block_base_fee)); outcome } @@ -1021,7 +1030,7 @@ impl Backend { let (exit, out, gas, state) = match overrides { None => self.call_with_state(state, request, fee_details, block), Some(overrides) => { - let state = state::apply_state_override(overrides, state)?; + let state = state::apply_state_override(overrides.into_iter().collect(), state)?; self.call_with_state(state, request, fee_details, block) }, }?; @@ -1048,17 +1057,18 @@ impl Backend { env.cfg.disable_block_gas_limit = true; if let Some(base) = max_fee_per_gas { - env.block.basefee = base.to_alloy(); + env.block.basefee = base; } - let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); + let gas_price = + gas_price.map(|g| g).or(max_fee_per_gas.map(|g| g)).unwrap_or_else(|| self.gas_price()); let caller = from.unwrap_or_default(); env.tx = TxEnv { caller: caller.to_alloy(), gas_limit: gas_limit.as_u64(), - gas_price: gas_price.to_alloy(), - gas_priority_fee: max_priority_fee_per_gas.map(|f| f.to_alloy()), + gas_price, + gas_priority_fee: max_priority_fee_per_gas.map(|f| f), transact_to: match to { Some(addr) => TransactTo::Call(addr.to_alloy()), None => TransactTo::Create(CreateScheme::Create), @@ -1112,8 +1122,6 @@ impl Backend { }, }; let state = result_and_state.state; - let state: revm::primitives::HashMap = - state.into_iter().map(|kv| (kv.0.to_ethers(), kv.1)).collect(); let (exit_reason, gas_used, out) = match result_and_state.result { ExecutionResult::Success { reason, gas_used, output, .. } => { (eval_to_instruction_result(reason), gas_used, Some(output)) @@ -1134,7 +1142,7 @@ impl Backend { request: EthTransactionRequest, fee_details: FeeDetails, block_request: Option, - opts: GethDebugTracingOptions, + opts: GethDefaultTracingOptions, ) -> Result { self.with_database_at(block_request, |state, block| { let mut inspector = Inspector::default().with_steps_tracing(); @@ -1158,7 +1166,10 @@ impl Backend { (halt_to_instruction_result(reason), gas_used, None) }, }; - let res = inspector.tracer.unwrap_or_default().traces.geth_trace(rU256::from(gas_used), opts); + let res = inspector.tracer.unwrap_or(TracingInspector::new(TracingInspectorConfig::all())).into_geth_builder().geth_traces(gas_used, match &out { + Some(out) => out.data().clone(), + None => Bytes::new() + }, opts); trace!(target: "backend", "trace call return {:?} out: {:?} gas {} on block {}", exit_reason, out, gas_used, block_number); Ok(res) }) @@ -1184,10 +1195,10 @@ impl Backend { }; let mut tracer = AccessListTracer::new( - AccessList(request.access_list.clone().unwrap_or_default()), + EthersAccessList(request.access_list.clone().unwrap_or_default()), from, to, - self.precompiles().into_iter().map(|p| p.to_alloy()).collect(), + self.precompiles(), ); let mut evm = revm::EVM::new(); @@ -1209,7 +1220,7 @@ impl Backend { } }; let access_list = tracer.access_list(); - Ok((exit_reason, out, gas_used, access_list)) + Ok((exit_reason, out, gas_used, from_ethers_access_list(access_list))) } /// returns all receipts for the given transactions @@ -1230,14 +1241,14 @@ impl Backend { async fn logs_for_block( &self, filter: Filter, - hash: H256, + hash: B256, ) -> Result, BlockchainError> { if let Some(block) = self.blockchain.get_block_by_hash(&hash) { - return Ok(self.mined_logs_for_block(filter, block)) + return Ok(self.mined_logs_for_block(filter, block)); } if let Some(fork) = self.get_fork() { - return Ok(fork.logs(&filter).await?) + return fork.logs(&filter).await.map_err(|_| BlockchainError::DataUnavailable); } Ok(Vec::new()) @@ -1255,7 +1266,9 @@ impl Backend { block .transactions .iter() - .filter_map(|tx| storage.transactions.get(&tx.hash()).map(|tx| tx.info.clone())) + .filter_map(|tx| { + storage.transactions.get(&tx.hash().to_alloy()).map(|tx| tx.info.clone()) + }) .collect() }; @@ -1263,26 +1276,24 @@ impl Backend { let logs = transaction.logs.clone(); let transaction_hash = transaction.transaction_hash; - for (log_idx, log) in logs.into_iter().enumerate() { + for log in logs.into_iter() { let mut log = Log { - address: log.address, - topics: log.topics, - data: log.data, + address: log.address.to_alloy(), + topics: log.topics.into_iter().map(ToAlloy::to_alloy).collect(), + data: log.data.0.into(), block_hash: None, block_number: None, transaction_hash: None, transaction_index: None, log_index: None, - transaction_log_index: None, - log_type: None, - removed: Some(false), + removed: false, }; let mut is_match: bool = true; - if filter.address.is_some() && filter.has_topics() { + if !filter.address.is_empty() && filter.has_topics() { if !params.filter_address(&log) || !params.filter_topics(&log) { is_match = false; } - } else if filter.address.is_some() { + } else if !filter.address.is_empty() { if !params.filter_address(&log) { is_match = false; } @@ -1291,12 +1302,11 @@ impl Backend { } if is_match { - log.block_hash = Some(block_hash); - log.block_number = Some(block.header.number.as_u64().into()); - log.transaction_hash = Some(transaction_hash); - log.transaction_index = Some(transaction.transaction_index.into()); + log.block_hash = Some(block_hash.to_alloy()); + log.block_number = Some(block.header.number.to_alloy()); + log.transaction_hash = Some(transaction_hash.to_alloy()); + log.transaction_index = Some(U256::from(transaction.transaction_index)); log.log_index = Some(U256::from(block_log_index)); - log.transaction_log_index = Some(U256::from(log_idx)); all_logs.push(log); } block_log_index += 1; @@ -1327,7 +1337,8 @@ impl Backend { if fork.predates_fork(from) { // this data is only available on the forked client let filter = filter.clone().from_block(from).to_block(to_on_fork); - all_logs = fork.logs(&filter).await?; + all_logs = + fork.logs(&filter).await.map_err(|_| BlockchainError::DataUnavailable)?; // update the range from = fork.block_number() + 1; @@ -1349,31 +1360,28 @@ impl Backend { if let Some(hash) = filter.get_block_hash() { self.logs_for_block(filter, hash).await } else { - let best = self.best_number().as_u64(); + let best = self.best_number(); let to_block = self.convert_block_number(filter.block_option.get_to_block().copied()).min(best); let from_block = self.convert_block_number(filter.block_option.get_from_block().copied()); if from_block > best { // requested log range does not exist yet - return Ok(vec![]) + return Ok(vec![]); } self.logs_for_range(&filter, from_block, to_block).await } } - pub async fn block_by_hash( - &self, - hash: H256, - ) -> Result>, BlockchainError> { + pub async fn block_by_hash(&self, hash: B256) -> Result, BlockchainError> { trace!(target: "backend", "get block by hash {:?}", hash); if let tx @ Some(_) = self.mined_block_by_hash(hash) { - return Ok(tx) + return Ok(tx); } if let Some(fork) = self.get_fork() { - return Ok(fork.block_by_hash(hash).await?) + return fork.block_by_hash(hash).await.map_err(|_| BlockchainError::DataUnavailable); } Ok(None) @@ -1381,21 +1389,24 @@ impl Backend { pub async fn block_by_hash_full( &self, - hash: H256, - ) -> Result>, BlockchainError> { + hash: B256, + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by hash {:?}", hash); if let tx @ Some(_) = self.get_full_block(hash) { - return Ok(tx) + return Ok(tx); } if let Some(fork) = self.get_fork() { - return Ok(fork.block_by_hash_full(hash).await?) + return fork + .block_by_hash_full(hash) + .await + .map_err(|_| BlockchainError::DataUnavailable); } Ok(None) } - fn mined_block_by_hash(&self, hash: H256) -> Option> { + fn mined_block_by_hash(&self, hash: B256) -> Option { let block = self.blockchain.get_block_by_hash(&hash)?; Some(self.convert_block(block)) } @@ -1405,7 +1416,7 @@ impl Backend { number: BlockNumber, ) -> Option> { if let Some(block) = self.get_block(number) { - return self.mined_transactions_in_block(&block) + return self.mined_transactions_in_block(&block); } None } @@ -1416,10 +1427,16 @@ impl Backend { let base_fee = block.header.base_fee_per_gas; let storage = self.blockchain.storage.read(); for hash in block.transactions.iter().map(|tx| tx.hash()) { - let info = storage.transactions.get(&hash)?.info.clone(); + let info = storage.transactions.get(&hash.to_alloy())?.info.clone(); let tx = block.transactions.get(info.transaction_index as usize)?.clone(); - let tx = transaction_build(Some(hash), tx, Some(block), Some(info), base_fee); + let tx = transaction_build( + Some(hash.to_alloy()), + tx, + Some(block), + Some(info), + base_fee.map(|f| f.to_alloy()), + ); transactions.push(tx); } Some(transactions) @@ -1428,16 +1445,19 @@ impl Backend { pub async fn block_by_number( &self, number: BlockNumber, - ) -> Result>, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by number {:?}", number); if let tx @ Some(_) = self.mined_block_by_number(number) { - return Ok(tx) + return Ok(tx); } if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork_inclusive(number) { - return Ok(fork.block_by_number(number).await?) + return fork + .block_by_number(number) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } @@ -1447,16 +1467,19 @@ impl Backend { pub async fn block_by_number_full( &self, number: BlockNumber, - ) -> Result>, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by number {:?}", number); if let tx @ Some(_) = self.get_full_block(number) { - return Ok(tx) + return Ok(tx); } if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork_inclusive(number) { - return Ok(fork.block_by_number_full(number).await?) + return fork + .block_by_number_full(number) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } @@ -1465,7 +1488,7 @@ impl Backend { pub fn get_block(&self, id: impl Into) -> Option { let hash = match id.into() { - BlockId::Hash(hash) => hash, + BlockId::Hash(hash) => hash.block_hash, BlockId::Number(number) => { let storage = self.blockchain.storage.read(); let slots_in_an_epoch = U64::from(32u64); @@ -1473,7 +1496,7 @@ impl Backend { BlockNumber::Latest => storage.best_hash, BlockNumber::Earliest => storage.genesis_hash, BlockNumber::Pending => return None, - BlockNumber::Number(num) => *storage.hashes.get(&num)?, + BlockNumber::Number(num) => *storage.hashes.get(&U64::from(num))?, BlockNumber::Safe => { if storage.best_number > (slots_in_an_epoch) { *storage.hashes.get(&(storage.best_number - (slots_in_an_epoch)))? @@ -1482,8 +1505,12 @@ impl Backend { } } BlockNumber::Finalized => { - if storage.best_number > (slots_in_an_epoch * 2) { - *storage.hashes.get(&(storage.best_number - (slots_in_an_epoch * 2)))? + if storage.best_number.to_ethers() > (slots_in_an_epoch.to_ethers() * 2) { + *storage.hashes.get( + &(storage.best_number.to_ethers() - + (slots_in_an_epoch.to_ethers() * 2)) + .to_alloy(), + )? } else { storage.genesis_hash } @@ -1494,15 +1521,18 @@ impl Backend { self.get_block_by_hash(hash) } - pub fn get_block_by_hash(&self, hash: H256) -> Option { + pub fn get_block_by_hash(&self, hash: B256) -> Option { self.blockchain.get_block_by_hash(&hash) } - pub fn mined_block_by_number(&self, number: BlockNumber) -> Option> { - Some(self.convert_block(self.get_block(number)?)) + pub fn mined_block_by_number(&self, number: BlockNumber) -> Option { + let block = self.get_block(number)?; + let mut block = self.convert_block(block); + block.transactions.convert_to_hashes(); + Some(block) } - pub fn get_full_block(&self, id: impl Into) -> Option> { + pub fn get_full_block(&self, id: impl Into) -> Option { let block = self.get_block(id)?; let transactions = self.mined_transactions_in_block(&block)?; let block = self.convert_block(block); @@ -1510,7 +1540,7 @@ impl Backend { } /// Takes a block as it's stored internally and returns the eth api conform block format - pub fn convert_block(&self, block: Block) -> EthersBlock { + pub fn convert_block(&self, block: Block) -> AlloyBlock { let size = U256::from(rlp::encode(&block).len() as u32); let Block { header, transactions, .. } = block; @@ -1535,31 +1565,38 @@ impl Backend { base_fee_per_gas, } = header; - EthersBlock { - hash: Some(hash), - parent_hash, - uncles_hash: ommers_hash, - author: Some(beneficiary), - state_root, - transactions_root, - receipts_root, - number: Some(number.as_u64().into()), - gas_used, - gas_limit, - extra_data, - logs_bloom: Some(logs_bloom), - timestamp: timestamp.into(), - difficulty, + AlloyBlock { total_difficulty: Some(self.total_difficulty()), - seal_fields: { vec![mix_hash.as_bytes().to_vec().into(), nonce.0.to_vec().into()] }, - uncles: vec![], - transactions: transactions.into_iter().map(|tx| tx.hash()).collect(), + header: AlloyHeader { + hash: Some(hash.to_alloy()), + parent_hash: parent_hash.to_alloy(), + uncles_hash: ommers_hash.to_alloy(), + miner: beneficiary.to_alloy(), + state_root: state_root.to_alloy(), + transactions_root: transactions_root.to_alloy(), + receipts_root: receipts_root.to_alloy(), + number: Some(number.to_alloy()), + gas_used: gas_used.to_alloy(), + gas_limit: gas_limit.to_alloy(), + extra_data: extra_data.0.into(), + logs_bloom: Bloom::from_slice(logs_bloom.as_bytes()), + timestamp: U256::from(timestamp), + difficulty: difficulty.to_alloy(), + mix_hash: Some(mix_hash.to_alloy()), + nonce: Some(B64::from_slice(nonce.as_bytes())), + base_fee_per_gas: base_fee_per_gas.map(|f| f.to_alloy()), + withdrawals_root: None, + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + }, size: Some(size), - mix_hash: Some(mix_hash), - nonce: Some(nonce), - base_fee_per_gas, + transactions: alloy_rpc_types::BlockTransactions::Hashes( + transactions.into_iter().map(|tx| tx.hash().to_alloy()).collect(), + ), + uncles: vec![], + withdrawals: None, other: Default::default(), - ..Default::default() } } @@ -1572,23 +1609,28 @@ impl Backend { &self, block_id: Option, ) -> Result { - let current = self.best_number().as_u64(); + let current = self.best_number(); let slots_in_an_epoch = 32u64; let requested = match block_id.map(Into::into).unwrap_or(BlockId::Number(BlockNumber::Latest)) { BlockId::Hash(hash) => self - .block_by_hash(hash) + .block_by_hash(hash.block_hash) .await? .ok_or(BlockchainError::BlockNotFound)? + .header .number .ok_or(BlockchainError::BlockNotFound)? - .as_u64(), + .to::(), BlockId::Number(num) => match num { - BlockNumber::Latest | BlockNumber::Pending => self.best_number().as_u64(), - BlockNumber::Earliest => 0, - BlockNumber::Number(num) => num.as_u64(), - BlockNumber::Safe => current.saturating_sub(slots_in_an_epoch), - BlockNumber::Finalized => current.saturating_sub(slots_in_an_epoch * 2), + BlockNumber::Latest | BlockNumber::Pending => self.best_number(), + BlockNumber::Earliest => U64::ZERO.to::(), + BlockNumber::Number(num) => num, + BlockNumber::Safe => { + U64::from(current).saturating_sub(U64::from(slots_in_an_epoch)).to::() + } + BlockNumber::Finalized => U64::from(current) + .saturating_sub(U64::from(slots_in_an_epoch) * U64::from(2)) + .to::(), }, }; @@ -1600,12 +1642,12 @@ impl Backend { } pub fn convert_block_number(&self, block: Option) -> u64 { - let current = self.best_number().as_u64(); + let current = self.best_number(); let slots_in_an_epoch = 32u64; match block.unwrap_or(BlockNumber::Latest) { BlockNumber::Latest | BlockNumber::Pending => current, BlockNumber::Earliest => 0, - BlockNumber::Number(num) => num.as_u64(), + BlockNumber::Number(num) => num, BlockNumber::Safe => current.saturating_sub(slots_in_an_epoch), BlockNumber::Finalized => current.saturating_sub(slots_in_an_epoch * 2), } @@ -1638,20 +1680,20 @@ impl Backend { f(state, block) }) .await; - return Ok(result) + return Ok(result); } Some(BlockRequest::Number(bn)) => Some(BlockNumber::Number(bn)), None => None, }; - let block_number: U256 = self.convert_block_number(block_number).into(); + let block_number: U256 = U256::from(self.convert_block_number(block_number)); - if block_number.to_alloy() < self.env.read().block.number { + if block_number < self.env.read().block.number { { let mut states = self.states.write(); if let Some((state, block)) = self - .get_block(block_number.as_u64()) - .and_then(|block| Some((states.get(&block.header.hash())?, block))) + .get_block(block_number.to::()) + .and_then(|block| Some((states.get(&block.header.hash().to_alloy())?, block))) { let block = BlockEnv { number: block.header.number.to_alloy(), @@ -1663,7 +1705,7 @@ impl Backend { gas_limit: block.header.gas_limit.to_alloy(), ..Default::default() }; - return Ok(f(Box::new(state), block)) + return Ok(f(Box::new(state), block)); } } @@ -1678,19 +1720,19 @@ impl Backend { let db = self.db.read().await; let gen_db = self.genesis.state_db_at_genesis(Box::new(&*db)); - block.number = block_number.to_alloy(); + block.number = block_number; block.timestamp = rU256::from(fork.timestamp()); - block.basefee = fork.base_fee().unwrap_or_default().to_alloy(); + block.basefee = fork.base_fee().unwrap_or_default(); - return Ok(f(Box::new(&gen_db), block)) + return Ok(f(Box::new(&gen_db), block)); } } warn!(target: "backend", "Not historic state found for block={}", block_number); return Err(BlockchainError::BlockOutOfRange( self.env.read().block.number.to_ethers().as_u64(), - block_number.as_u64(), - )) + block_number.to::(), + )); } let db = self.db.read().await; @@ -1703,11 +1745,11 @@ impl Backend { address: Address, index: U256, block_request: Option, - ) -> Result { + ) -> Result { self.with_database_at(block_request, |db, _| { trace!(target: "backend", "get storage for {:?} at {:?}", address, index); - let val = db.storage_ref(address.to_alloy(), index.to_alloy())?; - Ok(u256_to_h256_be(val.to_ethers())) + let val = db.storage_ref(address, index)?; + Ok(u256_to_h256_be(val.to_ethers()).to_alloy()) }) .await? } @@ -1733,10 +1775,10 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get code for {:?}", address); - let account = state.basic_ref(address.to_alloy())?.unwrap_or_default(); + let account = state.basic_ref(address)?.unwrap_or_default(); if account.code_hash == KECCAK_EMPTY { // if the code hash is `KECCAK_EMPTY`, we check no further - return Ok(Default::default()) + return Ok(Default::default()); } let code = if let Some(code) = account.code { code @@ -1767,7 +1809,7 @@ impl Backend { D: DatabaseRef, { trace!(target: "backend", "get balance for {:?}", address); - Ok(state.basic_ref(address.to_alloy())?.unwrap_or_default().balance.to_ethers()) + Ok(state.basic_ref(address)?.unwrap_or_default().balance) } /// Returns the nonce of the address @@ -1779,8 +1821,9 @@ impl Backend { block_request: Option, ) -> Result { if let Some(BlockRequest::Pending(pool_transactions)) = block_request.as_ref() { - if let Some(value) = get_pool_transactions_nonce(pool_transactions, address) { - return Ok(value) + if let Some(value) = get_pool_transactions_nonce(pool_transactions, address.to_ethers()) + { + return Ok(value); } } let final_block_request = match block_request { @@ -1790,15 +1833,18 @@ impl Backend { }; self.with_database_at(final_block_request, |db, _| { trace!(target: "backend", "get nonce for {:?}", address); - Ok(db.basic_ref(address.to_alloy())?.unwrap_or_default().nonce.into()) + Ok(U256::from(db.basic_ref(address)?.unwrap_or_default().nonce)) }) .await? } /// Returns the traces for the given transaction - pub async fn trace_transaction(&self, hash: H256) -> Result, BlockchainError> { + pub async fn trace_transaction( + &self, + hash: B256, + ) -> Result, BlockchainError> { if let Some(traces) = self.mined_parity_trace_transaction(hash) { - return Ok(traces) + return Ok(traces); } if let Some(fork) = self.get_fork() { @@ -1809,22 +1855,28 @@ impl Backend { } /// Returns the traces for the given transaction - pub(crate) fn mined_parity_trace_transaction(&self, hash: H256) -> Option> { + pub(crate) fn mined_parity_trace_transaction( + &self, + hash: B256, + ) -> Option> { self.blockchain.storage.read().transactions.get(&hash).map(|tx| tx.parity_traces()) } /// Returns the traces for the given transaction - pub(crate) fn mined_transaction(&self, hash: H256) -> Option { + pub(crate) fn mined_transaction(&self, hash: B256) -> Option { self.blockchain.storage.read().transactions.get(&hash).cloned() } /// Returns the traces for the given block - pub(crate) fn mined_parity_trace_block(&self, block: u64) -> Option> { + pub(crate) fn mined_parity_trace_block( + &self, + block: u64, + ) -> Option> { let block = self.get_block(block)?; let mut traces = vec![]; let storage = self.blockchain.storage.read(); for tx in block.transactions { - traces.extend(storage.transactions.get(&tx.hash())?.parity_traces()); + traces.extend(storage.transactions.get(&tx.hash().to_alloy())?.parity_traces()); } Some(traces) } @@ -1832,38 +1884,44 @@ impl Backend { /// Returns the traces for the given transaction pub async fn debug_trace_transaction( &self, - hash: H256, + hash: B256, opts: GethDebugTracingOptions, ) -> Result { if let Some(traces) = self.mined_geth_trace_transaction(hash, opts.clone()) { - return Ok(GethTrace::Known(GethTraceFrame::Default(traces))) + return Ok(GethTrace::Default(traces)); } if let Some(fork) = self.get_fork() { - return Ok(fork.debug_trace_transaction(hash, opts).await?) + return fork + .debug_trace_transaction(hash, opts) + .await + .map_err(|_| BlockchainError::DataUnavailable) } - Ok(GethTrace::Known(GethTraceFrame::Default(Default::default()))) + Ok(GethTrace::Default(Default::default())) } fn mined_geth_trace_transaction( &self, - hash: H256, + hash: B256, opts: GethDebugTracingOptions, ) -> Option { - self.blockchain.storage.read().transactions.get(&hash).map(|tx| tx.geth_trace(opts)) + self.blockchain.storage.read().transactions.get(&hash).map(|tx| tx.geth_trace(opts.config)) } /// Returns the traces for the given block - pub async fn trace_block(&self, block: BlockNumber) -> Result, BlockchainError> { + pub async fn trace_block( + &self, + block: BlockNumber, + ) -> Result, BlockchainError> { let number = self.convert_block_number(Some(block)); if let Some(traces) = self.mined_parity_trace_block(number) { - return Ok(traces) + return Ok(traces); } if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { - return Ok(fork.trace_block(number).await?) + return fork.trace_block(number).await.map_err(|_| BlockchainError::DataUnavailable) } } @@ -1872,20 +1930,26 @@ impl Backend { pub async fn transaction_receipt( &self, - hash: H256, + hash: B256, ) -> Result, BlockchainError> { if let Some(receipt) = self.mined_transaction_receipt(hash) { - return Ok(Some(receipt.inner)) + return Ok(Some(receipt.inner)); } if let Some(fork) = self.get_fork() { - let receipt = fork.transaction_receipt(hash).await?; + let receipt = fork + .transaction_receipt(hash) + .await + .map_err(|_| BlockchainError::DataUnavailable)?; let number = self.convert_block_number( - receipt.clone().and_then(|r| r.block_number).map(|n| BlockNumber::from(n.as_u64())), + receipt + .clone() + .and_then(|r| r.block_number) + .map(|n| BlockNumber::from(n.to::())), ); if fork.predates_fork_inclusive(number) { - return Ok(receipt) + return Ok(receipt); } } @@ -1893,19 +1957,19 @@ impl Backend { } /// Returns all receipts of the block - pub fn mined_receipts(&self, hash: H256) -> Option> { + pub fn mined_receipts(&self, hash: B256) -> Option> { let block = self.mined_block_by_hash(hash)?; let mut receipts = Vec::new(); let storage = self.blockchain.storage.read(); - for tx in block.transactions { - let receipt = storage.transactions.get(&tx)?.receipt.clone(); + for tx in block.transactions.hashes() { + let receipt = storage.transactions.get(tx)?.receipt.clone(); receipts.push(receipt); } Some(receipts) } /// Returns the transaction receipt for the given hash - pub(crate) fn mined_transaction_receipt(&self, hash: H256) -> Option { + pub(crate) fn mined_transaction_receipt(&self, hash: B256) -> Option { let MinedTransaction { info, receipt, block_hash, .. } = self.blockchain.get_transaction_by_hash(&hash)?; @@ -1916,11 +1980,11 @@ impl Backend { let block = self.blockchain.get_block_by_hash(&block_hash)?; // TODO store cumulative gas used in receipt instead - let receipts = self.get_receipts(block.transactions.iter().map(|tx| tx.hash())); + let receipts = self.get_receipts(block.transactions.iter().map(|tx| tx.hash().to_alloy())); - let mut cumulative_gas_used = U256::zero(); + let mut cumulative_gas_used = U256::ZERO; for receipt in receipts.iter().take(index + 1) { - cumulative_gas_used = cumulative_gas_used.saturating_add(receipt.gas_used()); + cumulative_gas_used = cumulative_gas_used.saturating_add(receipt.gas_used().to_alloy()); } // cumulative_gas_used = cumulative_gas_used.saturating_sub(gas_used); @@ -1933,29 +1997,30 @@ impl Backend { let transaction_type = transaction.transaction.r#type(); let effective_gas_price = match transaction.transaction { - TypedTransaction::Legacy(t) => t.gas_price, - TypedTransaction::EIP2930(t) => t.gas_price, + TypedTransaction::Legacy(t) => t.gas_price.to_alloy(), + TypedTransaction::EIP2930(t) => t.gas_price.to_alloy(), TypedTransaction::EIP1559(t) => block .header .base_fee_per_gas + .map(|f| f.to_alloy()) .unwrap_or(self.base_fee()) - .checked_add(t.max_priority_fee_per_gas) - .unwrap_or_else(U256::max_value), + .checked_add(t.max_priority_fee_per_gas.to_alloy()) + .unwrap_or(U256::MAX), TypedTransaction::Deposit(_) => U256::from(0), }; let deposit_nonce = transaction_type.and_then(|x| (x == 0x7E).then_some(info.nonce)); - let inner = TransactionReceipt { - transaction_hash: info.transaction_hash, - transaction_index: info.transaction_index.into(), + let mut inner = TransactionReceipt { + transaction_hash: Some(info.transaction_hash.to_alloy()), + transaction_index: U64::from(info.transaction_index), block_hash: Some(block_hash), - block_number: Some(block.header.number.as_u64().into()), - from: info.from, - to: info.to, + block_number: Some(U256::from(block.header.number.as_u64())), + from: info.from.to_alloy(), + to: info.to.map(|t| t.to_alloy()), cumulative_gas_used, - gas_used: Some(gas_used), - contract_address: info.contract_address, + gas_used: Some(gas_used.to_alloy()), + contract_address: info.contract_address.map(|t| t.to_alloy()), logs: { let mut pre_receipts_log_index = None; if !cumulative_receipts.is_empty() { @@ -1966,36 +2031,36 @@ impl Backend { logs.iter() .enumerate() .map(|(i, log)| Log { - address: log.address, - topics: log.topics.clone(), - data: log.data.clone(), + address: log.address.to_alloy(), + topics: log.topics.clone().into_iter().map(|t| t.to_alloy()).collect(), + data: log.data.clone().0.into(), block_hash: Some(block_hash), - block_number: Some(block.header.number.as_u64().into()), - transaction_hash: Some(info.transaction_hash), - transaction_index: Some(info.transaction_index.into()), + block_number: Some(U256::from(block.header.number.as_u64())), + transaction_hash: Some(info.transaction_hash.to_alloy()), + transaction_index: Some(U256::from(info.transaction_index)), log_index: Some(U256::from( (pre_receipts_log_index.unwrap_or(0)) + i as u32, )), - transaction_log_index: Some(U256::from(i)), - log_type: None, - removed: Some(false), + removed: false, }) .collect() }, - status: Some(status_code.into()), - root: None, - logs_bloom, - transaction_type: transaction_type.map(Into::into), - effective_gas_price: Some(effective_gas_price), - deposit_nonce, - l1_fee: None, - l1_fee_scalar: None, - l1_gas_price: None, - l1_gas_used: None, - other: OtherFields::default(), + status_code: Some(U64::from(status_code)), + state_root: None, + logs_bloom: Bloom::from_slice(logs_bloom.as_bytes()), + transaction_type: transaction_type.map(U8::from).unwrap_or_default(), + effective_gas_price: effective_gas_price.to::(), + blob_gas_price: None, + blob_gas_used: None, + other: Default::default(), }; - Some(MinedTransactionReceipt { inner, out: info.out }) + inner.other.insert( + "deposit_nonce".to_string(), + serde_json::to_value(deposit_nonce).expect("Infallible"), + ); + + Some(MinedTransactionReceipt { inner, out: info.out.map(|o| o.0.into()) }) } pub async fn transaction_by_block_number_and_index( @@ -2003,14 +2068,17 @@ impl Backend { number: BlockNumber, index: Index, ) -> Result, BlockchainError> { - if let Some(hash) = self.mined_block_by_number(number).and_then(|b| b.hash) { - return Ok(self.mined_transaction_by_block_hash_and_index(hash, index)) + if let Some(hash) = self.mined_block_by_number(number).and_then(|b| b.header.hash) { + return Ok(self.mined_transaction_by_block_hash_and_index(hash, index)); } if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork(number) { - return Ok(fork.transaction_by_block_number_and_index(number, index.into()).await?) + return fork + .transaction_by_block_number_and_index(number, index.into()) + .await + .map_err(|_| BlockchainError::DataUnavailable); } } @@ -2019,15 +2087,18 @@ impl Backend { pub async fn transaction_by_block_hash_and_index( &self, - hash: H256, + hash: B256, index: Index, ) -> Result, BlockchainError> { if let tx @ Some(_) = self.mined_transaction_by_block_hash_and_index(hash, index) { - return Ok(tx) + return Ok(tx); } if let Some(fork) = self.get_fork() { - return Ok(fork.transaction_by_block_hash_and_index(hash, index.into()).await?) + return fork + .transaction_by_block_hash_and_index(hash, index.into()) + .await + .map_err(|_| BlockchainError::DataUnavailable); } Ok(None) @@ -2035,7 +2106,7 @@ impl Backend { fn mined_transaction_by_block_hash_and_index( &self, - block_hash: H256, + block_hash: B256, index: Index, ) -> Option { let (info, block, tx) = { @@ -2043,36 +2114,36 @@ impl Backend { let block = storage.blocks.get(&block_hash).cloned()?; let index: usize = index.into(); let tx = block.transactions.get(index)?.clone(); - let info = storage.transactions.get(&tx.hash())?.info.clone(); + let info = storage.transactions.get(&tx.hash().to_alloy())?.info.clone(); (info, block, tx) }; Some(transaction_build( - Some(info.transaction_hash), + Some(info.transaction_hash.to_alloy()), tx, Some(&block), Some(info), - block.header.base_fee_per_gas, + block.header.base_fee_per_gas.map(|g| g.to_alloy()), )) } pub async fn transaction_by_hash( &self, - hash: H256, + hash: B256, ) -> Result, BlockchainError> { trace!(target: "backend", "transaction_by_hash={:?}", hash); if let tx @ Some(_) = self.mined_transaction_by_hash(hash) { - return Ok(tx) + return Ok(tx); } if let Some(fork) = self.get_fork() { - return Ok(fork.transaction_by_hash(hash).await?) + return fork.transaction_by_hash(hash).await.map_err(BlockchainError::AlloyForkProvider) } Ok(None) } - fn mined_transaction_by_hash(&self, hash: H256) -> Option { + fn mined_transaction_by_hash(&self, hash: B256) -> Option { let (info, block) = { let storage = self.blockchain.storage.read(); let MinedTransaction { info, block_hash, .. } = @@ -2083,11 +2154,11 @@ impl Backend { let tx = block.transactions.get(info.transaction_index as usize)?.clone(); Some(transaction_build( - Some(info.transaction_hash), + Some(info.transaction_hash.to_alloy()), tx, Some(&block), Some(info), - block.header.base_fee_per_gas, + block.header.base_fee_per_gas.map(|g| g.to_alloy()), )) } @@ -2097,10 +2168,10 @@ impl Backend { pub async fn prove_account_at( &self, address: Address, - keys: Vec, + keys: Vec, block_request: Option, ) -> Result { - let account_key = H256::from(keccak256(address.as_bytes())); + let account_key = B256::from(keccak256(address.to_ethers().as_bytes())); let block_number = block_request.as_ref().map(|r| r.block_number()); self.with_database_at(block_request, |block_db, _| { @@ -2119,7 +2190,7 @@ impl Backend { }) }; let query = (&mut recorder, acc_decoder); - trie.get_with(account_key.as_bytes(), query) + trie.get_with(account_key.to_ethers().as_bytes(), query) .map_err(|err| BlockchainError::TrieError(err.to_string()))? }; let account = maybe_account.unwrap_or_default(); @@ -2140,7 +2211,7 @@ impl Backend { block_db.maybe_account_db(address).ok_or(BlockchainError::DataUnavailable)?; let account_proof = AccountProof { - address, + address: address.to_ethers(), balance: account.balance, nonce: account.nonce.as_u64().into(), code_hash: account.code_hash, @@ -2150,11 +2221,11 @@ impl Backend { .into_iter() .map(|storage_key| { // the key that should be proofed is the keccak256 of the storage key - let key = H256::from(keccak256(storage_key)); + let key = B256::from(keccak256(storage_key)); prove_storage(&account, &account_db.0, key).map( |(storage_proof, storage_value)| StorageProof { - key: storage_key, - value: storage_value.into_uint(), + key: storage_key.to_ethers(), + value: storage_value.to_ethers().into_uint(), proof: storage_proof .into_iter() .map(|proof| { @@ -2184,7 +2255,7 @@ impl Backend { } /// Notifies all `new_block_listeners` about the new block - fn notify_on_new_block(&self, header: Header, hash: H256) { + fn notify_on_new_block(&self, header: Header, hash: B256) { // cleanup closed notification streams first, if the channel is closed we can remove the // sender half for the set self.new_block_listeners.lock().retain(|tx| !tx.is_closed()); @@ -2214,7 +2285,9 @@ fn get_pool_transactions_nonce( } }); if let Some(highest_nonce_tx) = highest_nonce_tx { - return Some(highest_nonce_tx.pending_transaction.nonce().saturating_add(U256::one())) + return Some( + highest_nonce_tx.pending_transaction.nonce().to_alloy().saturating_add(U256::from(1)), + ); } None } @@ -2226,7 +2299,7 @@ impl TransactionValidator for Backend { tx: &PendingTransaction, ) -> Result<(), BlockchainError> { let address = *tx.sender(); - let account = self.get_account(address).await?; + let account = self.get_account(address.to_alloy()).await?; let env = self.next_env(); Ok(self.validate_pool_transaction_for(tx, &account, &env)?) } @@ -2241,24 +2314,25 @@ impl TransactionValidator for Backend { if let Some(tx_chain_id) = tx.chain_id() { let chain_id = self.chain_id(); - if chain_id != tx_chain_id { + if chain_id.to::() != tx_chain_id { if let Some(legacy) = tx.as_legacy() { // - if env.cfg.spec_id >= SpecId::SPURIOUS_DRAGON && !legacy.meets_eip155(chain_id) + if env.cfg.spec_id >= SpecId::SPURIOUS_DRAGON && + !legacy.meets_eip155(chain_id.to::()) { warn!(target: "backend", ?chain_id, ?tx_chain_id, "incompatible EIP155-based V"); - return Err(InvalidTransactionError::IncompatibleEIP155) + return Err(InvalidTransactionError::IncompatibleEIP155); } } else { warn!(target: "backend", ?chain_id, ?tx_chain_id, "invalid chain id"); - return Err(InvalidTransactionError::InvalidChainId) + return Err(InvalidTransactionError::InvalidChainId); } } } - if tx.gas_limit() < MIN_TRANSACTION_GAS { + if tx.gas_limit() < MIN_TRANSACTION_GAS.to_ethers() { warn!(target: "backend", "[{:?}] gas too low", tx.hash()); - return Err(InvalidTransactionError::GasTooLow) + return Err(InvalidTransactionError::GasTooLow); } // Check gas limit, iff block gas limit is set. @@ -2266,7 +2340,7 @@ impl TransactionValidator for Backend { warn!(target: "backend", "[{:?}] gas too high", tx.hash()); return Err(InvalidTransactionError::GasTooHigh(ErrDetail { detail: String::from("tx.gas_limit > env.block.gas_limit"), - })) + })); } // check nonce @@ -2276,13 +2350,13 @@ impl TransactionValidator for Backend { (*tx.nonce()).try_into().map_err(|_| InvalidTransactionError::NonceMaxValue)?; if nonce < account.nonce && !is_deposit_tx { warn!(target: "backend", "[{:?}] nonce too low", tx.hash()); - return Err(InvalidTransactionError::NonceTooLow) + return Err(InvalidTransactionError::NonceTooLow); } if (env.cfg.spec_id as u8) >= (SpecId::LONDON as u8) { if tx.gas_price() < env.block.basefee.to_ethers() && !is_deposit_tx { warn!(target: "backend", "max fee per gas={}, too low, block basefee={}",tx.gas_price(), env.block.basefee); - return Err(InvalidTransactionError::FeeCapTooLow) + return Err(InvalidTransactionError::FeeCapTooLow); } if let (Some(max_priority_fee_per_gas), Some(max_fee_per_gas)) = @@ -2290,7 +2364,7 @@ impl TransactionValidator for Backend { { if max_priority_fee_per_gas > max_fee_per_gas { warn!(target: "backend", "max priority fee per gas={}, too high, max fee per gas={}", max_priority_fee_per_gas, max_fee_per_gas); - return Err(InvalidTransactionError::TipAboveFeeCap) + return Err(InvalidTransactionError::TipAboveFeeCap); } } } @@ -2306,7 +2380,7 @@ impl TransactionValidator for Backend { if account.balance < req_funds.to_alloy() { warn!(target: "backend", "[{:?}] insufficient allowance={}, required={} account={:?}", tx.hash(), account.balance, req_funds, *pending.sender()); - return Err(InvalidTransactionError::InsufficientFunds) + return Err(InvalidTransactionError::InsufficientFunds); } Ok(()) } @@ -2319,7 +2393,7 @@ impl TransactionValidator for Backend { ) -> Result<(), InvalidTransactionError> { self.validate_pool_transaction_for(tx, account, env)?; if tx.nonce().as_u64() > account.nonce { - return Err(InvalidTransactionError::NonceTooHigh) + return Err(InvalidTransactionError::NonceTooHigh); } Ok(()) } @@ -2328,15 +2402,15 @@ impl TransactionValidator for Backend { /// Creates a `Transaction` as it's expected for the `eth` RPC api from storage data #[allow(clippy::too_many_arguments)] pub fn transaction_build( - tx_hash: Option, + tx_hash: Option, eth_transaction: MaybeImpersonatedTransaction, block: Option<&Block>, info: Option, base_fee: Option, ) -> Transaction { let mut transaction: Transaction = eth_transaction.clone().into(); - if info.is_some() && transaction.transaction_type.unwrap_or(U64::zero()).as_u64() == 0x7E { - transaction.nonce = U256::from(info.as_ref().unwrap().nonce); + if info.is_some() && transaction.transaction_type.unwrap_or(U64::ZERO).to::() == 0x7E { + transaction.nonce = U64::from(info.as_ref().unwrap().nonce); } if eth_transaction.is_dynamic_fee() { @@ -2346,11 +2420,11 @@ pub fn transaction_build( } else { // if transaction is already mined, gas price is considered base fee + priority fee: the // effective gas price. - let base_fee = base_fee.unwrap_or(U256::zero()); + let base_fee = base_fee.unwrap_or(U256::ZERO); let max_priority_fee_per_gas = - transaction.max_priority_fee_per_gas.unwrap_or(U256::zero()); + transaction.max_priority_fee_per_gas.map(|g| g.to::()).unwrap_or(U256::ZERO); transaction.gas_price = Some( - base_fee.checked_add(max_priority_fee_per_gas).unwrap_or_else(U256::max_value), + base_fee.checked_add(max_priority_fee_per_gas).unwrap_or(U256::MAX).to::(), ); } } else { @@ -2359,20 +2433,22 @@ pub fn transaction_build( } transaction.block_hash = - block.as_ref().map(|block| H256::from(keccak256(&rlp::encode(&block.header)))); + block.as_ref().map(|block| B256::from(keccak256(&rlp::encode(&block.header)))); - transaction.block_number = block.as_ref().map(|block| block.header.number.as_u64().into()); + transaction.block_number = block.as_ref().map(|block| U256::from(block.header.number.as_u64())); - transaction.transaction_index = info.as_ref().map(|status| status.transaction_index.into()); + transaction.transaction_index = + info.as_ref().map(|status| U256::from(status.transaction_index)); // need to check if the signature of the transaction is impersonated, if so then we // can't recover the sender, instead we use the sender from the executed transaction and set the // impersonated hash. if eth_transaction.is_impersonated() { - transaction.from = info.as_ref().map(|info| info.from).unwrap_or_default(); - transaction.hash = eth_transaction.impersonated_hash(transaction.from); + transaction.from = info.as_ref().map(|info| info.from).unwrap_or_default().to_alloy(); + transaction.hash = + eth_transaction.impersonated_hash(transaction.from.to_ethers()).to_alloy(); } else { - transaction.from = eth_transaction.recover().expect("can recover signed tx"); + transaction.from = eth_transaction.recover().expect("can recover signed tx").to_alloy(); } // if a specific hash was provided we update the transaction's hash @@ -2384,7 +2460,10 @@ pub fn transaction_build( transaction.hash = tx_hash; } - transaction.to = info.as_ref().map_or(eth_transaction.to().cloned(), |status| status.to); + transaction.to = info + .as_ref() + .map_or(eth_transaction.to().cloned(), |status| status.to) + .map(|t| t.to_alloy()); transaction } @@ -2397,8 +2476,8 @@ pub fn transaction_build( pub fn prove_storage( acc: &BasicAccount, data: &AsHashDB, - storage_key: H256, -) -> Result<(Vec>, H256), BlockchainError> { + storage_key: B256, +) -> Result<(Vec>, B256), BlockchainError> { let data: &dyn HashDB<_, _> = data.deref(); let mut recorder = Recorder::new(); let trie = RefTrieDB::new(&data, &acc.storage_root.0) @@ -2408,10 +2487,11 @@ pub fn prove_storage( let item: U256 = { let decode_value = |bytes: &[u8]| rlp::decode(bytes).expect("decoding db value failed"); let query = (&mut recorder, decode_value); - trie.get_with(storage_key.as_bytes(), query) + trie.get_with(storage_key.to_ethers().as_bytes(), query) .map_err(|err| BlockchainError::TrieError(err.to_string()))? - .unwrap_or_else(U256::zero) + .unwrap_or_else(|| U256::ZERO.to_ethers()) + .to_alloy() }; - Ok((recorder.drain().into_iter().map(|r| r.data).collect(), BigEndianHash::from_uint(&item))) + Ok((recorder.drain().into_iter().map(|r| r.data).collect(), B256::from(item))) } diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index bda955860d4a9..d5a2d40a7a8bb 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -1,13 +1,11 @@ //! Support for generating the state root for memdb storage use crate::eth::{backend::db::AsHashDB, error::BlockchainError}; -use alloy_primitives::{Address, Bytes, U256 as rU256}; -use anvil_core::eth::{state::StateOverride, trie::RefSecTrieDBMut}; -use ethers::{ - types::H256, - utils::{rlp, rlp::RlpStream}, -}; -use foundry_common::types::{ToAlloy, ToEthers}; +use alloy_primitives::{Address, Bytes, B256, U256 as rU256}; +use alloy_rpc_types::state::StateOverride; +use anvil_core::eth::trie::RefSecTrieDBMut; +use ethers::utils::{rlp, rlp::RlpStream}; +use foundry_common::types::ToEthers; use foundry_evm::{ backend::DatabaseError, hashbrown::HashMap as Map, @@ -22,7 +20,7 @@ use trie_db::TrieMut; /// Returns the log hash for all `logs` /// /// The log hash is `keccak(rlp(logs[]))`, -pub fn log_rlp_hash(logs: Vec) -> H256 { +pub fn log_rlp_hash(logs: Vec) -> B256 { let mut stream = RlpStream::new(); stream.begin_unbounded_list(); for log in logs { @@ -36,11 +34,11 @@ pub fn log_rlp_hash(logs: Vec) -> H256 { let out = stream.out().freeze(); let out = ethers::utils::keccak256(out); - H256::from_slice(out.as_slice()) + B256::from_slice(out.as_slice()) } /// Returns storage trie of an account as `HashDB` -pub fn storage_trie_db(storage: &Map) -> (AsHashDB, H256) { +pub fn storage_trie_db(storage: &Map) -> (AsHashDB, B256) { // Populate DB with full trie from entries. let (db, root) = { let mut db = , _>>::default(); @@ -50,7 +48,7 @@ pub fn storage_trie_db(storage: &Map) -> (AsHashDB, H256) { for (k, v) in storage.iter().filter(|(_k, v)| *v != &rU256::from(0)) { let mut temp: [u8; 32] = [0; 32]; (*k).to_ethers().to_big_endian(&mut temp); - let key = H256::from(temp); + let key = B256::from(temp).to_ethers(); let value = rlp::encode(&(*v).to_ethers()); trie.insert(key.as_bytes(), value.as_ref()).unwrap(); } @@ -58,11 +56,11 @@ pub fn storage_trie_db(storage: &Map) -> (AsHashDB, H256) { (db, root) }; - (Box::new(db), H256::from(root)) + (Box::new(db), B256::from(root)) } /// Returns the account data as `HashDB` -pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { +pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, B256) { let accounts = trie_accounts(accounts); // Populate DB with full trie from entries. @@ -78,7 +76,7 @@ pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, H256) { (db, root) }; - (Box::new(db), H256::from(root)) + (Box::new(db), B256::from(root)) } /// Returns all RLP-encoded Accounts @@ -92,7 +90,7 @@ pub fn trie_accounts(accounts: &Map) -> Vec<(Address, Bytes) .collect() } -pub fn state_merkle_trie_root(accounts: &Map) -> H256 { +pub fn state_merkle_trie_root(accounts: &Map) -> B256 { trie_hash_db(accounts).1 } @@ -101,7 +99,7 @@ pub fn trie_account_rlp(info: &AccountInfo, storage: &Map) -> Byte let mut stream = RlpStream::new_list(4); stream.append(&info.nonce); stream.append(&info.balance.to_ethers()); - stream.append(&storage_trie_db(storage).1); + stream.append(&storage_trie_db(storage).1.to_ethers()); stream.append(&info.code_hash.as_slice()); stream.out().freeze().into() } @@ -116,19 +114,19 @@ where { let mut cache_db = CacheDB::new(state); for (account, account_overrides) in overrides.iter() { - let mut account_info = cache_db.basic_ref((*account).to_alloy())?.unwrap_or_default(); + let mut account_info = cache_db.basic_ref(*account)?.unwrap_or_default(); if let Some(nonce) = account_overrides.nonce { - account_info.nonce = nonce; + account_info.nonce = nonce.to::(); } if let Some(code) = &account_overrides.code { account_info.code = Some(Bytecode::new_raw(code.to_vec().into())); } if let Some(balance) = account_overrides.balance { - account_info.balance = balance.to_alloy(); + account_info.balance = balance; } - cache_db.insert_account_info((*account).to_alloy(), account_info); + cache_db.insert_account_info(*account, account_info); // We ensure that not both state and state_diff are set. // If state is set, we must mark the account as "NewlyCreated", so that the old storage @@ -142,20 +140,16 @@ where (None, None) => (), (Some(new_account_state), None) => { cache_db.replace_account_storage( - (*account).to_alloy(), + *account, new_account_state .iter() - .map(|(key, value)| (key.to_alloy().into(), (value.to_alloy().into()))) + .map(|(key, value)| ((*key).into(), (*value))) .collect(), )?; } (None, Some(account_state_diff)) => { for (key, value) in account_state_diff.iter() { - cache_db.insert_account_storage( - (*account).to_alloy(), - key.to_alloy().into(), - value.to_alloy().into(), - )?; + cache_db.insert_account_storage(*account, (*key).into(), *value)?; } } }; diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 327bb96974499..8757ef3a5e815 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -6,17 +6,24 @@ use crate::eth::{ }, pool::transactions::PoolTransaction, }; +use alloy_primitives::{Bytes, TxHash, B256, U256, U64}; +use alloy_rpc_trace_types::{ + geth::{DefaultFrame, GethDefaultTracingOptions}, + parity::LocalizedTransactionTrace, +}; +use alloy_rpc_types::{ + BlockId, BlockNumberOrTag, TransactionInfo as RethTransactionInfo, TransactionReceipt, +}; use anvil_core::eth::{ block::{Block, PartialHeader}, receipt::TypedReceipt, transaction::{MaybeImpersonatedTransaction, TransactionInfo}, }; -use ethers::{ - prelude::{BlockId, BlockNumber, DefaultFrame, Trace, H256, H256 as TxHash, U64}, - types::{ActionType, Bytes, GethDebugTracingOptions, TransactionReceipt, U256}, -}; use foundry_common::types::{ToAlloy, ToEthers}; -use foundry_evm::revm::{interpreter::InstructionResult, primitives::Env}; +use foundry_evm::{ + revm::primitives::Env, + traces::{GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig}, +}; use parking_lot::RwLock; use std::{ collections::{HashMap, VecDeque}, @@ -37,9 +44,9 @@ const MAX_ON_DISK_HISTORY_LIMIT: usize = 3_600; /// Represents the complete state of single block pub struct InMemoryBlockStates { /// The states at a certain block - states: HashMap, + states: HashMap, /// states which data is moved to disk - on_disk_states: HashMap, + on_disk_states: HashMap, /// How many states to store at most in_memory_limit: usize, /// minimum amount of states we keep in memory @@ -49,9 +56,9 @@ pub struct InMemoryBlockStates { /// Limiting the states will prevent disk blow up, especially in interval mining mode max_on_disk_limit: usize, /// the oldest states written to disk - oldest_on_disk: VecDeque, + oldest_on_disk: VecDeque, /// all states present, used to enforce `in_memory_limit` - present: VecDeque, + present: VecDeque, /// Stores old states on disk disk_cache: DiskStateCache, } @@ -109,7 +116,7 @@ impl InMemoryBlockStates { /// the number of states/blocks until we reached the `min_limit`. /// /// When a state that was previously written to disk is requested, it is simply read from disk. - pub fn insert(&mut self, hash: H256, state: StateDb) { + pub fn insert(&mut self, hash: B256, state: StateDb) { if !self.is_memory_only() && self.present.len() >= self.in_memory_limit { // once we hit the max limit we gradually decrease it self.in_memory_limit = @@ -153,7 +160,7 @@ impl InMemoryBlockStates { } /// Returns the state for the given `hash` if present - pub fn get(&mut self, hash: &H256) -> Option<&StateDb> { + pub fn get(&mut self, hash: &B256) -> Option<&StateDb> { self.states.get(hash).or_else(|| { if let Some(state) = self.on_disk_states.get_mut(hash) { if let Some(cached) = self.disk_cache.read(*hash) { @@ -204,15 +211,15 @@ impl Default for InMemoryBlockStates { #[derive(Clone)] pub struct BlockchainStorage { /// all stored blocks (block hash -> block) - pub blocks: HashMap, + pub blocks: HashMap, /// mapping from block number -> block hash - pub hashes: HashMap, + pub hashes: HashMap, /// The current best hash - pub best_hash: H256, + pub best_hash: B256, /// The current best block number pub best_number: U64, /// genesis hash of the chain - pub genesis_hash: H256, + pub genesis_hash: B256, /// Mapping from the transaction hash to a tuple containing the transaction as well as the /// transaction receipt pub transactions: HashMap, @@ -226,7 +233,7 @@ impl BlockchainStorage { // create a dummy genesis block let partial_header = PartialHeader { timestamp, - base_fee, + base_fee: base_fee.map(|b| b.to_ethers()), gas_limit: env.block.gas_limit.to_ethers(), beneficiary: env.block.coinbase.to_ethers(), difficulty: env.block.difficulty.to_ethers(), @@ -235,25 +242,25 @@ impl BlockchainStorage { let block = Block::new::(partial_header, vec![], vec![]); let genesis_hash = block.header.hash(); let best_hash = genesis_hash; - let best_number: U64 = 0u64.into(); + let best_number: U64 = U64::from(0u64); Self { - blocks: HashMap::from([(genesis_hash, block)]), - hashes: HashMap::from([(best_number, genesis_hash)]), - best_hash, + blocks: HashMap::from([(genesis_hash.to_alloy(), block)]), + hashes: HashMap::from([(best_number, genesis_hash.to_alloy())]), + best_hash: best_hash.to_alloy(), best_number, - genesis_hash, + genesis_hash: genesis_hash.to_alloy(), transactions: Default::default(), total_difficulty: Default::default(), } } - pub fn forked(block_number: u64, block_hash: H256, total_difficulty: U256) -> Self { + pub fn forked(block_number: u64, block_hash: B256, total_difficulty: U256) -> Self { BlockchainStorage { blocks: Default::default(), - hashes: HashMap::from([(block_number.into(), block_hash)]), + hashes: HashMap::from([(U64::from(block_number), block_hash)]), best_hash: block_hash, - best_number: block_number.into(), + best_number: U64::from(block_number), genesis_hash: Default::default(), transactions: Default::default(), total_difficulty, @@ -275,16 +282,16 @@ impl BlockchainStorage { /// Removes all stored transactions for the given block number pub fn remove_block_transactions_by_number(&mut self, num: u64) { - if let Some(hash) = self.hashes.get(&(num.into())).copied() { + if let Some(hash) = self.hashes.get(&(U64::from(num))).copied() { self.remove_block_transactions(hash); } } /// Removes all stored transactions for the given block hash - pub fn remove_block_transactions(&mut self, block_hash: H256) { + pub fn remove_block_transactions(&mut self, block_hash: B256) { if let Some(block) = self.blocks.get_mut(&block_hash) { for tx in block.transactions.iter() { - self.transactions.remove(&tx.hash()); + self.transactions.remove(&tx.hash().to_alloy()); } block.transactions.clear(); } @@ -294,24 +301,26 @@ impl BlockchainStorage { // === impl BlockchainStorage === impl BlockchainStorage { - /// Returns the hash for [BlockNumber] - pub fn hash(&self, number: BlockNumber) -> Option { + /// Returns the hash for [BlockNumberOrTag] + pub fn hash(&self, number: BlockNumberOrTag) -> Option { let slots_in_an_epoch = U64::from(32u64); match number { - BlockNumber::Latest => Some(self.best_hash), - BlockNumber::Earliest => Some(self.genesis_hash), - BlockNumber::Pending => None, - BlockNumber::Number(num) => self.hashes.get(&num).copied(), - BlockNumber::Safe => { + BlockNumberOrTag::Latest => Some(self.best_hash), + BlockNumberOrTag::Earliest => Some(self.genesis_hash), + BlockNumberOrTag::Pending => None, + BlockNumberOrTag::Number(num) => self.hashes.get(&U64::from(num)).copied(), + BlockNumberOrTag::Safe => { if self.best_number > (slots_in_an_epoch) { self.hashes.get(&(self.best_number - (slots_in_an_epoch))).copied() } else { Some(self.genesis_hash) // treat the genesis block as safe "by definition" } } - BlockNumber::Finalized => { - if self.best_number > (slots_in_an_epoch * 2) { - self.hashes.get(&(self.best_number - (slots_in_an_epoch * 2))).copied() + BlockNumberOrTag::Finalized => { + if self.best_number > (slots_in_an_epoch * U64::from(2)) { + self.hashes + .get(&(self.best_number - (slots_in_an_epoch * U64::from(2)))) + .copied() } else { Some(self.genesis_hash) } @@ -335,7 +344,7 @@ impl Blockchain { Self { storage: Arc::new(RwLock::new(BlockchainStorage::new(env, base_fee, timestamp))) } } - pub fn forked(block_number: u64, block_hash: H256, total_difficulty: U256) -> Self { + pub fn forked(block_number: u64, block_hash: B256, total_difficulty: U256) -> Self { Self { storage: Arc::new(RwLock::new(BlockchainStorage::forked( block_number, @@ -346,18 +355,18 @@ impl Blockchain { } /// returns the header hash of given block - pub fn hash(&self, id: BlockId) -> Option { + pub fn hash(&self, id: BlockId) -> Option { match id { - BlockId::Hash(h) => Some(h), + BlockId::Hash(h) => Some(h.block_hash), BlockId::Number(num) => self.storage.read().hash(num), } } - pub fn get_block_by_hash(&self, hash: &H256) -> Option { + pub fn get_block_by_hash(&self, hash: &B256) -> Option { self.storage.read().blocks.get(hash).cloned() } - pub fn get_transaction_by_hash(&self, hash: &H256) -> Option { + pub fn get_transaction_by_hash(&self, hash: &B256) -> Option { self.storage.read().transactions.get(hash).cloned() } @@ -384,7 +393,7 @@ pub struct MinedBlockOutcome { pub struct MinedTransaction { pub info: TransactionInfo, pub receipt: TypedReceipt, - pub block_hash: H256, + pub block_hash: B256, pub block_number: u64, } @@ -392,38 +401,28 @@ pub struct MinedTransaction { impl MinedTransaction { /// Returns the traces of the transaction for `trace_transaction` - pub fn parity_traces(&self) -> Vec { - let mut traces = Vec::with_capacity(self.info.traces.arena.len()); - for (idx, node) in self.info.traces.arena.iter().cloned().enumerate() { - let action = node.parity_action(); - let result = node.parity_result(); - - let action_type = if node.status() == InstructionResult::SelfDestruct { - ActionType::Suicide - } else { - node.kind().into() - }; - - let trace = Trace { - action, - result: Some(result), - trace_address: self.info.trace_address(idx), - subtraces: node.children.len(), - transaction_position: Some(self.info.transaction_index as usize), - transaction_hash: Some(self.info.transaction_hash), - block_number: self.block_number, - block_hash: self.block_hash, - action_type, - error: None, - }; - traces.push(trace) - } - - traces + pub fn parity_traces(&self) -> Vec { + ParityTraceBuilder::new( + self.info.traces.clone(), + None, + TracingInspectorConfig::default_parity(), + ) + .into_localized_transaction_traces(RethTransactionInfo { + hash: Some(self.info.transaction_hash.to_alloy()), + index: Some(self.info.transaction_index as u64), + block_hash: Some(self.block_hash), + block_number: Some(self.block_number), + base_fee: None, + }) } - pub fn geth_trace(&self, opts: GethDebugTracingOptions) -> DefaultFrame { - self.info.traces.geth_trace(self.receipt.gas_used().to_alloy(), opts) + pub fn geth_trace(&self, opts: GethDefaultTracingOptions) -> DefaultFrame { + GethTraceBuilder::new(self.info.traces.clone(), TracingInspectorConfig::default_geth()) + .geth_traces( + self.receipt.gas_used().as_u64(), + self.info.out.clone().unwrap_or_default().0.into(), + opts, + ) } } @@ -440,8 +439,7 @@ pub struct MinedTransactionReceipt { mod tests { use super::*; use crate::eth::backend::db::Db; - use ethers::{abi::ethereum_types::BigEndianHash, types::Address}; - use foundry_common::types::ToAlloy; + use alloy_primitives::{Address, B256, U256}; use foundry_evm::{ backend::MemDb, revm::{ @@ -460,8 +458,8 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn can_read_write_cached_state() { let mut storage = InMemoryBlockStates::new(1); - let one = H256::from_uint(&U256::from(1)); - let two = H256::from_uint(&U256::from(2)); + let one = B256::from(U256::from(1)); + let two = B256::from(U256::from(2)); let mut state = MemDb::default(); let addr = Address::random(); @@ -478,7 +476,7 @@ mod tests { let loaded = storage.get(&one).unwrap(); - let acc = loaded.basic_ref(addr.to_alloy()).unwrap().unwrap(); + let acc = loaded.basic_ref(addr).unwrap().unwrap(); assert_eq!(acc.balance, rU256::from(1337u64)); } @@ -490,8 +488,8 @@ mod tests { let num_states = 30; for idx in 0..num_states { let mut state = MemDb::default(); - let hash = H256::from_uint(&U256::from(idx)); - let addr = Address::from(hash); + let hash = B256::from(U256::from(idx)); + let addr = Address::from_word(hash); let balance = (idx * 2) as u64; let info = AccountInfo::from_balance(rU256::from(balance)); state.insert_account(addr, info); @@ -505,10 +503,10 @@ mod tests { assert_eq!(storage.present.len(), storage.min_in_memory_limit); for idx in 0..num_states { - let hash = H256::from_uint(&U256::from(idx)); - let addr = Address::from(hash); + let hash = B256::from(U256::from(idx)); + let addr = Address::from_word(hash); let loaded = storage.get(&hash).unwrap(); - let acc = loaded.basic_ref(addr.to_alloy()).unwrap().unwrap(); + let acc = loaded.basic_ref(addr).unwrap().unwrap(); let balance = (idx * 2) as u64; assert_eq!(acc.balance, rU256::from(balance)); } diff --git a/crates/anvil/src/eth/backend/notifications.rs b/crates/anvil/src/eth/backend/notifications.rs index 7a5f428db7a41..a463dfb9446d5 100644 --- a/crates/anvil/src/eth/backend/notifications.rs +++ b/crates/anvil/src/eth/backend/notifications.rs @@ -1,7 +1,7 @@ //! Notifications emitted from the backed +use alloy_primitives::B256; use anvil_core::eth::block::Header; -use ethers::types::H256; use futures::channel::mpsc::UnboundedReceiver; use std::sync::Arc; @@ -9,7 +9,7 @@ use std::sync::Arc; #[derive(Clone, Debug)] pub struct NewBlockNotification { /// Hash of the imported block - pub hash: H256, + pub hash: B256, /// block header pub header: Arc
, } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 2cb67e496c6ab..a92df9ce92e68 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -1,6 +1,7 @@ //! Aggregated error type for this module use crate::eth::pool::transactions::PoolTransaction; +use alloy_transport::TransportError; use anvil_rpc::{ error::{ErrorCode, RpcError}, response::ResponseResult, @@ -58,6 +59,8 @@ pub enum BlockchainError { FeeHistory(#[from] FeeHistoryError), #[error(transparent)] ForkProvider(#[from] ProviderError), + #[error(transparent)] + AlloyForkProvider(#[from] TransportError), #[error("EVM error {0:?}")] EvmError(InstructionResult), #[error("Invalid url {0:?}")] @@ -371,6 +374,10 @@ impl ToRpcResponseResult for Result { error!(%err, "fork provider error"); RpcError::internal_error_with(format!("Fork Error: {err:?}")) } + BlockchainError::AlloyForkProvider(err) => { + error!(%err, "alloy fork provider error"); + RpcError::internal_error_with(format!("Fork Error: {err:?}")) + } err @ BlockchainError::EvmError(_) => { RpcError::internal_error_with(err.to_string()) } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 43228e0a6e615..685119456abc1 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -2,8 +2,9 @@ use crate::eth::{ backend::{info::StorageInfo, notifications::NewBlockNotifications}, error::BlockchainError, }; +use alloy_primitives::{B256, U256}; use anvil_core::eth::transaction::TypedTransaction; -use ethers::types::{H256, U256}; +use foundry_common::types::ToAlloy; use foundry_evm::revm::primitives::SpecId; use futures::StreamExt; use parking_lot::{Mutex, RwLock}; @@ -90,7 +91,7 @@ impl FeeManager { if self.is_eip1559() { *self.base_fee.read() } else { - U256::zero() + U256::ZERO } } @@ -99,7 +100,7 @@ impl FeeManager { /// This mirrors geth's auto values for `SuggestGasTipCap` which is: `priority fee + 2x current /// basefee`. pub fn max_priority_fee_per_gas(&self) -> U256 { - self.suggested_priority_fee() + *self.base_fee.read() * 2 + self.suggested_priority_fee() + *self.base_fee.read() * U256::from(2) } /// Returns the current gas price @@ -125,13 +126,13 @@ impl FeeManager { // It's naturally impossible for base fee to be 0; // It means it was set by the user deliberately and therefore we treat it as a constant. // Therefore, we skip the base fee calculation altogether and we return 0. - if self.base_fee() == U256::zero() { + if self.base_fee() == U256::ZERO { return 0 } calculate_next_block_base_fee( - gas_used.as_u64(), - gas_limit.as_u64(), - last_fee_per_gas.as_u64(), + gas_used.to::(), + gas_limit.to::(), + last_fee_per_gas.to::(), ) } } @@ -202,7 +203,7 @@ impl FeeHistoryService { /// Create a new history entry for the block fn create_cache_entry( &self, - hash: H256, + hash: B256, elasticity: f64, ) -> (FeeHistoryCacheItem, Option) { // percentile list from 0.0 to 100.0 with a 0.5 resolution. @@ -221,7 +222,7 @@ impl FeeHistoryService { let mut block_number: Option = None; let base_fee = self.fees.base_fee(); let mut item = FeeHistoryCacheItem { - base_fee: base_fee.as_u64(), + base_fee: base_fee.to::(), gas_used_ratio: 0f64, rewards: Vec::new(), }; @@ -247,15 +248,16 @@ impl FeeHistoryService { let effective_reward = match block.transactions.get(i).map(|tx| &tx.transaction) { Some(TypedTransaction::Legacy(t)) => { - t.gas_price.saturating_sub(base_fee).as_u64() + t.gas_price.to_alloy().saturating_sub(base_fee).to::() } Some(TypedTransaction::EIP2930(t)) => { - t.gas_price.saturating_sub(base_fee).as_u64() + t.gas_price.to_alloy().saturating_sub(base_fee).to::() } Some(TypedTransaction::EIP1559(t)) => t .max_priority_fee_per_gas - .min(t.max_fee_per_gas.saturating_sub(base_fee)) - .as_u64(), + .to_alloy() + .min(t.max_fee_per_gas.to_alloy().saturating_sub(base_fee)) + .to::(), Some(TypedTransaction::Deposit(_)) => 0, None => 0, }; @@ -347,9 +349,9 @@ impl FeeDetails { /// All values zero pub fn zero() -> Self { Self { - gas_price: Some(U256::zero()), - max_fee_per_gas: Some(U256::zero()), - max_priority_fee_per_gas: Some(U256::zero()), + gas_price: Some(U256::ZERO), + max_fee_per_gas: Some(U256::ZERO), + max_priority_fee_per_gas: Some(U256::ZERO), } } @@ -358,8 +360,8 @@ impl FeeDetails { let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = self; let no_fees = gas_price.is_none() && max_fee_per_gas.is_none(); - let gas_price = if no_fees { Some(U256::zero()) } else { gas_price }; - let max_fee_per_gas = if no_fees { Some(U256::zero()) } else { max_fee_per_gas }; + let gas_price = if no_fees { Some(U256::ZERO) } else { gas_price }; + let max_fee_per_gas = if no_fees { Some(U256::ZERO) } else { max_fee_per_gas }; Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas } } diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index 4478328434ec4..2199a50613511 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -1,7 +1,7 @@ //! Mines transactions use crate::eth::pool::{transactions::PoolTransaction, Pool}; -use ethers::prelude::TxHash; +use alloy_primitives::TxHash; use futures::{ channel::mpsc::Receiver, stream::{Fuse, Stream, StreamExt}, diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 95a255051ea9c..ac092f36c7f74 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -7,10 +7,11 @@ use crate::eth::{ macros::node_info, EthApi, }; -use ethers::types::{ - Action, Address, Block, BlockId, BlockNumber, Bytes, Call, Create, CreateResult, Res, Reward, - Transaction, TxHash, H256, U256, U64, +use alloy_primitives::{Address, Bytes, B256, U256, U64}; +use alloy_rpc_trace_types::parity::{ + Action, CallAction, CreateAction, CreateOutput, RewardAction, TraceOutput, }; +use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag as BlockNumber, Transaction}; use itertools::Itertools; impl EthApi { @@ -19,10 +20,7 @@ impl EthApi { /// /// As a faster alternative to eth_getBlockByNumber (by excluding uncle block /// information), which is not relevant in the context of an anvil node - pub async fn erigon_get_header_by_number( - &self, - number: BlockNumber, - ) -> Result>> { + pub async fn erigon_get_header_by_number(&self, number: BlockNumber) -> Result> { node_info!("ots_getApiLevel"); self.backend.block_by_number(number).await @@ -41,7 +39,7 @@ impl EthApi { /// certain transaction. pub async fn ots_get_internal_operations( &self, - hash: H256, + hash: B256, ) -> Result> { node_info!("ots_getInternalOperations"); @@ -59,19 +57,19 @@ impl EthApi { } /// Trace a transaction and generate a trace call tree. - pub async fn ots_trace_transaction(&self, hash: H256) -> Result> { + pub async fn ots_trace_transaction(&self, hash: B256) -> Result> { node_info!("ots_traceTransaction"); Ok(OtsTrace::batch_build(self.backend.trace_transaction(hash).await?)) } /// Given a transaction hash, returns its raw revert reason. - pub async fn ots_get_transaction_error(&self, hash: H256) -> Result> { + pub async fn ots_get_transaction_error(&self, hash: B256) -> Result> { node_info!("ots_getTransactionError"); if let Some(receipt) = self.backend.mined_transaction_receipt(hash) { - if receipt.inner.status == Some(U64::zero()) { - return Ok(receipt.out) + if receipt.inner.status_code == Some(U64::ZERO) { + return Ok(receipt.out.map(|b| b.0.into())) } } @@ -96,7 +94,7 @@ impl EthApi { /// For simplicity purposes, we return the entire block instead of emptying the values that /// Otterscan doesn't want. This is the original purpose of the endpoint (to save bandwidth), /// but it doesn't seem necessary in the context of an anvil node - pub async fn ots_get_block_details_by_hash(&self, hash: H256) -> Result { + pub async fn ots_get_block_details_by_hash(&self, hash: B256) -> Result { node_info!("ots_getBlockDetailsByHash"); if let Some(block) = self.backend.block_by_hash(hash).await? { @@ -133,7 +131,7 @@ impl EthApi { ) -> Result { node_info!("ots_searchTransactionsBefore"); - let best = self.backend.best_number().as_u64(); + let best = self.backend.best_number(); // we go from given block (defaulting to best) down to first block // considering only post-fork let from = if block_number == 0 { best } else { block_number }; @@ -153,8 +151,10 @@ impl EthApi { let hashes = traces .into_iter() .rev() - .filter_map(|trace| match trace.action { - Action::Call(Call { from, to, .. }) if from == address || to == address => { + .filter_map(|trace| match trace.trace.action { + Action::Call(CallAction { from, to, .. }) + if from == address || to == address => + { trace.transaction_hash } _ => None, @@ -181,7 +181,7 @@ impl EthApi { ) -> Result { node_info!("ots_searchTransactionsAfter"); - let best = self.backend.best_number().as_u64(); + let best = self.backend.best_number(); // we go from the first post-fork block, up to the tip let from = if block_number == 0 { self.get_fork().map(|f| f.block_number() + 1).unwrap_or(1) @@ -204,14 +204,16 @@ impl EthApi { let hashes = traces .into_iter() .rev() - .filter_map(|trace| match trace.action { - Action::Call(Call { from, to, .. }) if from == address || to == address => { + .filter_map(|trace| match trace.trace.action { + Action::Call(CallAction { from, to, .. }) + if from == address || to == address => + { trace.transaction_hash } - Action::Create(Create { from, .. }) if from == address => { + Action::Create(CreateAction { from, .. }) if from == address => { trace.transaction_hash } - Action::Reward(Reward { author, .. }) if author == address => { + Action::Reward(RewardAction { author, .. }) if author == address => { trace.transaction_hash } _ => None, @@ -240,12 +242,12 @@ impl EthApi { node_info!("ots_getTransactionBySenderAndNonce"); let from = self.get_fork().map(|f| f.block_number() + 1).unwrap_or_default(); - let to = self.backend.best_number().as_u64(); + let to = self.backend.best_number(); for n in (from..=to).rev() { if let Some(txs) = self.backend.mined_transactions_by_block_number(n.into()).await { for tx in txs { - if tx.nonce == nonce && tx.from == address { + if U256::from(tx.nonce) == nonce && tx.from == address { return Ok(Some(tx)) } } @@ -264,16 +266,16 @@ impl EthApi { node_info!("ots_getContractCreator"); let from = self.get_fork().map(|f| f.block_number()).unwrap_or_default(); - let to = self.backend.best_number().as_u64(); + let to = self.backend.best_number(); // loop in reverse, since we want the latest deploy to the address for n in (from..=to).rev() { if let Some(traces) = self.backend.mined_parity_trace_block(n) { for trace in traces.into_iter().rev() { - match (trace.action, trace.result) { + match (trace.trace.action, trace.trace.result) { ( - Action::Create(Create { from, .. }), - Some(Res::Create(CreateResult { address, .. })), + Action::Create(CreateAction { from, .. }), + Some(TraceOutput::Create(CreateOutput { address, .. })), ) if address == addr => { return Ok(Some(OtsContractCreator { hash: trace.transaction_hash.unwrap(), diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index cc9e763e4c33e..ff1f99ce5d136 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -2,22 +2,20 @@ use crate::eth::{ backend::mem::{storage::MinedTransaction, Backend}, error::{BlockchainError, Result}, }; -use alloy_primitives::U256 as rU256; -use ethers::types::{ - Action, Address, Block, Bytes, CallType, Trace, Transaction, TransactionReceipt, H256, U256, -}; -use foundry_common::types::ToEthers; -use foundry_evm::{revm::interpreter::InstructionResult, utils::CallKind}; +use alloy_primitives::{Address, Bytes, B256, U256 as rU256, U256}; +use alloy_rpc_trace_types::parity::{Action, CallType, LocalizedTransactionTrace}; +use alloy_rpc_types::{Block, BlockTransactions, Transaction, TransactionReceipt}; +use foundry_evm::{revm::interpreter::InstructionResult, traces::CallKind}; use futures::future::join_all; -use serde::{de::DeserializeOwned, Serialize}; +use serde::Serialize; use serde_repr::Serialize_repr; /// Patched Block struct, to include the additional `transactionCount` field expected by Otterscan -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase", bound = "TX: Serialize + DeserializeOwned")] -pub struct OtsBlock { +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct OtsBlock { #[serde(flatten)] - pub block: Block, + pub block: Block, pub transaction_count: usize, } @@ -25,7 +23,7 @@ pub struct OtsBlock { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct OtsBlockDetails { - pub block: OtsBlock, + pub block: OtsBlock, pub total_fees: U256, pub issuance: Issuance, } @@ -39,9 +37,9 @@ pub struct Issuance { } /// Holds both transactions and receipts for a block -#[derive(Debug, Serialize)] +#[derive(Clone, Serialize, Debug)] pub struct OtsBlockTransactions { - pub fullblock: OtsBlock, + pub fullblock: OtsBlock, pub receipts: Vec, } @@ -57,7 +55,7 @@ pub struct OtsTransactionReceipt { /// Information about the creator address and transaction for a contract #[derive(Debug, Serialize)] pub struct OtsContractCreator { - pub hash: H256, + pub hash: B256, pub creator: Address, } @@ -124,9 +122,14 @@ impl OtsBlockDetails { /// - It breaks the abstraction built in `OtsBlock` which computes `transaction_count` /// based on the existing list. /// Therefore we keep it simple by keeping the data in the response - pub async fn build(block: Block, backend: &Backend) -> Result { + pub async fn build(block: Block, backend: &Backend) -> Result { + let block_txs = match block.transactions.clone() { + BlockTransactions::Full(txs) => txs.into_iter().map(|tx| tx.hash).collect(), + BlockTransactions::Hashes(txs) => txs, + BlockTransactions::Uncle => return Err(BlockchainError::DataUnavailable), + }; let receipts_futs = - block.transactions.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); + block_txs.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); // fetch all receipts let receipts: Vec = join_all(receipts_futs) @@ -138,8 +141,8 @@ impl OtsBlockDetails { }) .collect::>()?; - let total_fees = receipts.iter().fold(U256::zero(), |acc, receipt| { - acc + receipt.gas_used.unwrap() * (receipt.effective_gas_price.unwrap()) + let total_fees = receipts.iter().fold(U256::ZERO, |acc, receipt| { + acc + receipt.gas_used.unwrap() * (U256::from(receipt.effective_gas_price)) }); Ok(Self { @@ -153,9 +156,13 @@ impl OtsBlockDetails { /// Converts a regular block into the patched OtsBlock format /// which includes the `transaction_count` field -impl From> for OtsBlock { - fn from(block: Block) -> Self { - let transaction_count = block.transactions.len(); +impl From for OtsBlock { + fn from(block: Block) -> Self { + let transaction_count = match block.transactions { + BlockTransactions::Full(ref txs) => txs.len(), + BlockTransactions::Hashes(ref txs) => txs.len(), + BlockTransactions::Uncle => 0, + }; Self { block, transaction_count } } @@ -164,18 +171,32 @@ impl From> for OtsBlock { impl OtsBlockTransactions { /// Fetches all receipts for the blocks's transactions, as required by the [`ots_getBlockTransactions`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) endpoint spec, and returns the final response object. pub async fn build( - mut block: Block, + mut block: Block, backend: &Backend, page: usize, page_size: usize, ) -> Result { - block.transactions = - block.transactions.into_iter().skip(page * page_size).take(page_size).collect(); + let block_txs = match block.transactions.clone() { + BlockTransactions::Full(txs) => txs.into_iter().map(|tx| tx.hash).collect(), + BlockTransactions::Hashes(txs) => txs, + BlockTransactions::Uncle => return Err(BlockchainError::DataUnavailable), + }; - let receipt_futs = block - .transactions - .iter() - .map(|tx| async { backend.transaction_receipt(tx.hash).await }); + let block_txs = + block_txs.into_iter().skip(page * page_size).take(page_size).collect::>(); + + block.transactions = match block.transactions { + BlockTransactions::Full(txs) => BlockTransactions::Full( + txs.into_iter().skip(page * page_size).take(page_size).collect(), + ), + BlockTransactions::Hashes(txs) => BlockTransactions::Hashes( + txs.into_iter().skip(page * page_size).take(page_size).collect(), + ), + BlockTransactions::Uncle => return Err(BlockchainError::DataUnavailable), + }; + + let receipt_futs = + block_txs.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); let receipts: Vec = join_all(receipt_futs) .await @@ -186,7 +207,7 @@ impl OtsBlockTransactions { }) .collect::>()?; - let fullblock: OtsBlock<_> = block.into(); + let fullblock: OtsBlock = block.into(); Ok(Self { fullblock, receipts }) } @@ -197,7 +218,7 @@ impl OtsSearchTransactions { /// `ots_searchTransactionsAfter`](lrequires not only the transactions, but also the /// corresponding receipts, which are fetched here before constructing the final) pub async fn build( - hashes: Vec, + hashes: Vec, backend: &Backend, first_page: bool, last_page: bool, @@ -216,8 +237,11 @@ impl OtsSearchTransactions { join_all(hashes.iter().map(|hash| async { match backend.transaction_receipt(*hash).await { Ok(Some(receipt)) => { - let timestamp = - backend.get_block(receipt.block_number.unwrap()).unwrap().header.timestamp; + let timestamp = backend + .get_block(receipt.block_number.unwrap().to::()) + .unwrap() + .header + .timestamp; Ok(OtsTransactionReceipt { receipt, timestamp }) } Ok(None) => Err(BlockchainError::DataUnavailable), @@ -238,35 +262,34 @@ impl OtsInternalOperation { traces .info .traces - .arena .iter() .filter_map(|node| { - match (node.kind(), node.status()) { + match (node.trace.kind, node.trace.status) { (CallKind::Call, _) if node.trace.value != rU256::ZERO => Some(Self { r#type: OtsInternalOperationType::Transfer, - from: node.trace.caller.to_ethers(), - to: node.trace.address.to_ethers(), - value: node.trace.value.to_ethers(), + from: node.trace.caller, + to: node.trace.address, + value: node.trace.value, }), (CallKind::Create, _) => Some(Self { r#type: OtsInternalOperationType::Create, - from: node.trace.caller.to_ethers(), - to: node.trace.address.to_ethers(), - value: node.trace.value.to_ethers(), + from: node.trace.caller, + to: node.trace.address, + value: node.trace.value, }), (CallKind::Create2, _) => Some(Self { r#type: OtsInternalOperationType::Create2, - from: node.trace.caller.to_ethers(), - to: node.trace.address.to_ethers(), - value: node.trace.value.to_ethers(), + from: node.trace.caller, + to: node.trace.address, + value: node.trace.value, }), (_, InstructionResult::SelfDestruct) => { Some(Self { r#type: OtsInternalOperationType::SelfDestruct, - from: node.trace.address.to_ethers(), + from: node.trace.address, // the foundry CallTraceNode doesn't have a refund address to: Default::default(), - value: node.trace.value.to_ethers(), + value: node.trace.value, }) } _ => None, @@ -279,26 +302,26 @@ impl OtsInternalOperation { impl OtsTrace { /// Converts the list of traces for a transaction into the expected Otterscan format, as /// specified in the [`ots_traceTransaction`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_tracetransaction) spec - pub fn batch_build(traces: Vec) -> Vec { + pub fn batch_build(traces: Vec) -> Vec { traces .into_iter() - .filter_map(|trace| match trace.action { + .filter_map(|trace| match trace.trace.action { Action::Call(call) => { if let Ok(ots_type) = call.call_type.try_into() { Some(OtsTrace { r#type: ots_type, - depth: trace.trace_address.len(), + depth: trace.trace.trace_address.len(), from: call.from, to: call.to, value: call.value, - input: call.input, + input: call.input.0.into(), }) } else { None } } Action::Create(_) => None, - Action::Suicide(_) => None, + Action::Selfdestruct(_) => None, Action::Reward(_) => None, }) .collect() diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index d66fd4a522313..d8e0deb055012 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -36,11 +36,10 @@ use crate::{ }, mem::storage::MinedBlockOutcome, }; +use alloy_primitives::{TxHash, U64}; +use alloy_rpc_types::txpool::TxpoolStatus; use anvil_core::eth::transaction::PendingTransaction; -use ethers::{ - prelude::TxpoolStatus, - types::{TxHash, U64}, -}; +use foundry_common::types::ToAlloy; use futures::channel::mpsc::{channel, Receiver, Sender}; use parking_lot::{Mutex, RwLock}; use std::{collections::VecDeque, fmt, sync::Arc}; @@ -77,8 +76,8 @@ impl Pool { /// Returns the number of tx that are ready and queued for further execution pub fn txpool_status(&self) -> TxpoolStatus { // Note: naming differs here compared to geth's `TxpoolStatus` - let pending = self.ready_transactions().count().into(); - let queued = self.inner.read().pending_transactions.len().into(); + let pending = U64::from(self.ready_transactions().count()); + let queued = U64::from(self.inner.read().pending_transactions.len()); TxpoolStatus { pending, queued } } @@ -89,7 +88,7 @@ impl Pool { let MinedBlockOutcome { block_number, included, invalid } = outcome; // remove invalid transactions from the pool - self.remove_invalid(invalid.into_iter().map(|tx| *tx.hash()).collect()); + self.remove_invalid(invalid.into_iter().map(|tx| tx.hash()).collect()); // prune all the markers the mined transactions provide let res = self @@ -158,7 +157,7 @@ impl Pool { let mut dropped = None; if !removed.is_empty() { - dropped = removed.into_iter().find(|t| *t.pending_transaction.hash() == tx); + dropped = removed.into_iter().find(|t| t.pending_transaction.hash().to_alloy() == tx); } dropped } @@ -226,7 +225,7 @@ impl PoolInner { } fn add_transaction(&mut self, tx: PoolTransaction) -> Result { - if self.contains(tx.hash()) { + if self.contains(&tx.hash()) { warn!(target: "txpool", "[{:?}] Already imported", tx.hash()); return Err(PoolError::AlreadyImported(Box::new(tx))) } @@ -236,7 +235,7 @@ impl PoolInner { // If all markers are not satisfied import to future if !tx.is_ready() { - let hash = *tx.transaction.hash(); + let hash = tx.transaction.hash(); self.pending_transactions.add_transaction(tx)?; return Ok(AddedTransaction::Pending { hash }) } @@ -248,7 +247,7 @@ impl PoolInner { &mut self, tx: PendingPoolTransaction, ) -> Result { - let hash = *tx.transaction.hash(); + let hash = tx.transaction.hash(); trace!(target: "txpool", "adding ready transaction [{:?}]", hash); let mut ready = ReadyTransaction::new(hash); @@ -263,7 +262,7 @@ impl PoolInner { self.pending_transactions.mark_and_unlock(¤t_tx.transaction.provides), ); - let current_hash = *current_tx.transaction.hash(); + let current_hash = current_tx.transaction.hash(); // try to add the transaction to the ready pool match self.ready_transactions.add_transaction(current_tx) { Ok(replaced_transactions) => { @@ -316,7 +315,7 @@ impl PoolInner { let mut promoted = vec![]; let mut failed = vec![]; for tx in imports { - let hash = *tx.transaction.hash(); + let hash = tx.transaction.hash(); match self.add_ready_transaction(tx) { Ok(res) => promoted.push(res), Err(e) => { diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 458c811caa3a5..d2f6a662b7bce 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -1,6 +1,7 @@ use crate::eth::{error::PoolError, util::hex_fmt_many}; +use alloy_primitives::{Address, TxHash, U256}; use anvil_core::eth::transaction::{PendingTransaction, TypedTransaction}; -use ethers::types::{Address, TxHash, U256}; +use foundry_common::types::ToAlloy; use parking_lot::RwLock; use std::{ cmp::Ordering, @@ -44,7 +45,7 @@ impl TransactionOrder { pub fn priority(&self, tx: &TypedTransaction) -> TransactionPriority { match self { TransactionOrder::Fifo => TransactionPriority::default(), - TransactionOrder::Fees => TransactionPriority(tx.gas_price()), + TransactionOrder::Fees => TransactionPriority(tx.gas_price().to_alloy()), } } } @@ -87,13 +88,13 @@ pub struct PoolTransaction { impl PoolTransaction { /// Returns the hash of this transaction - pub fn hash(&self) -> &TxHash { - self.pending_transaction.hash() + pub fn hash(&self) -> TxHash { + self.pending_transaction.hash().to_alloy() } /// Returns the gas pric of this transaction pub fn gas_price(&self) -> U256 { - self.pending_transaction.transaction.gas_price() + self.pending_transaction.transaction.gas_price().to_alloy() } } @@ -143,7 +144,7 @@ impl PendingTransactions { pub fn add_transaction(&mut self, tx: PendingPoolTransaction) -> Result<(), PoolError> { assert!(!tx.is_ready(), "transaction must not be ready"); assert!( - !self.waiting_queue.contains_key(tx.transaction.hash()), + !self.waiting_queue.contains_key(&tx.transaction.hash()), "transaction is already added" ); @@ -163,13 +164,13 @@ impl PendingTransactions { // add all missing markers for marker in &tx.missing_markers { - self.required_markers.entry(marker.clone()).or_default().insert(*tx.transaction.hash()); + self.required_markers.entry(marker.clone()).or_default().insert(tx.transaction.hash()); } // also track identifying markers - self.waiting_markers.insert(tx.transaction.provides.clone(), *tx.transaction.hash()); + self.waiting_markers.insert(tx.transaction.provides.clone(), tx.transaction.hash()); // add tx to the queue - self.waiting_queue.insert(*tx.transaction.hash(), tx); + self.waiting_queue.insert(tx.transaction.hash(), tx); Ok(()) } @@ -309,7 +310,7 @@ impl TransactionsIterator { self.independent.insert(tx_ref); } else { // otherwise we're still awaiting for some deps - self.awaiting.insert(*tx_ref.transaction.hash(), (satisfied, tx_ref)); + self.awaiting.insert(tx_ref.transaction.hash(), (satisfied, tx_ref)); } } } @@ -324,7 +325,7 @@ impl Iterator for TransactionsIterator { let hash = best.transaction.hash(); let ready = - if let Some(ready) = self.all.get(hash).cloned() { ready } else { continue }; + if let Some(ready) = self.all.get(&hash).cloned() { ready } else { continue }; // Insert transactions that just got unlocked. for hash in &ready.unlocks { @@ -409,14 +410,14 @@ impl ReadyTransactions { ) -> Result>, PoolError> { assert!(tx.is_ready(), "transaction must be ready",); assert!( - !self.ready_tx.read().contains_key(tx.transaction.hash()), + !self.ready_tx.read().contains_key(&tx.transaction.hash()), "transaction already included" ); let (replaced_tx, unlocks) = self.replaced_transactions(&tx.transaction)?; let id = self.next_id(); - let hash = *tx.transaction.hash(); + let hash = tx.transaction.hash(); let mut independent = true; let mut requires_offset = 0; @@ -473,12 +474,14 @@ impl ReadyTransactions { // construct a list of unlocked transactions // also check for transactions that shouldn't be replaced because underpriced let ready = self.ready_tx.read(); - for to_remove in remove_hashes.iter().filter_map(|hash| ready.get(hash)) { + for to_remove in remove_hashes.iter().filter_map(|hash| ready.get(*hash)) { // if we're attempting to replace a transaction that provides the exact same markers // (addr + nonce) then we check for gas price if to_remove.provides() == tx.provides { // check if underpriced - if tx.pending_transaction.transaction.gas_price() <= to_remove.gas_price() { + if tx.pending_transaction.transaction.gas_price().to_alloy() <= + to_remove.gas_price() + { warn!(target: "txpool", "ready replacement transaction underpriced [{:?}]", tx.hash()); return Err(PoolError::ReplacementUnderpriced(Box::new(tx.clone()))) } else { @@ -534,7 +537,7 @@ impl ReadyTransactions { let prev_hash = self.provided_markers.get(marker)?; let tx2 = ready.get_mut(prev_hash)?; // remove hash - if let Some(idx) = tx2.unlocks.iter().position(|i| i == hash) { + if let Some(idx) = tx2.unlocks.iter().position(|i| i == &hash) { tx2.unlocks.swap_remove(idx); } if tx2.unlocks.is_empty() { @@ -566,7 +569,7 @@ impl ReadyTransactions { for marker in &tx.provides { let removed = self.provided_markers.remove(marker); assert_eq!( - removed.as_ref(), + removed, if current_marker == marker { None } else { Some(tx.hash()) }, "The pool contains exactly one transaction providing given tag; the removed transaction claims to provide that tag, so it has to be mapped to it's hash; qed" diff --git a/crates/anvil/src/filter.rs b/crates/anvil/src/filter.rs index 9a537a5cb28f4..60dce6b669568 100644 --- a/crates/anvil/src/filter.rs +++ b/crates/anvil/src/filter.rs @@ -4,12 +4,10 @@ use crate::{ pubsub::filter_logs, StorageInfo, }; +use alloy_primitives::TxHash; +use alloy_rpc_types::{Filter, FilteredParams, Log as AlloyLog}; use anvil_core::eth::subscription::SubscriptionId; use anvil_rpc::response::ResponseResult; -use ethers::{ - prelude::{Log as EthersLog, H256 as TxHash}, - types::{Filter, FilteredParams}, -}; use futures::{channel::mpsc::Receiver, Stream, StreamExt}; use std::{ collections::HashMap, @@ -164,14 +162,14 @@ pub struct LogsFilter { /// existing logs that matched the filter when the listener was installed /// /// They'll be returned on the first pill - pub historic: Option>, + pub historic: Option>, } // === impl LogsFilter === impl LogsFilter { /// Returns all the logs since the last time this filter was polled - pub fn poll(&mut self, cx: &mut Context<'_>) -> Vec { + pub fn poll(&mut self, cx: &mut Context<'_>) -> Vec { let mut logs = self.historic.take().unwrap_or_default(); while let Poll::Ready(Some(block)) = self.blocks.poll_next_unpin(cx) { let b = self.storage.block(block.hash); diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index 64cda289c82e3..cd115c2a90c99 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -1,10 +1,8 @@ //! Bindings for geth's `genesis.json` format use crate::revm::primitives::AccountInfo; -use ethers::{ - signers::LocalWallet, - types::{serde_helpers::*, Address, Bytes, H256, U256}, -}; -use foundry_common::{errors::FsPathError, types::ToAlloy}; +use alloy_primitives::{Address, Bytes, B256, U256}; +use ethers::{signers::LocalWallet, types::serde_helpers::*}; +use foundry_common::errors::FsPathError; use foundry_evm::revm::primitives::{Bytecode, Env, KECCAK_EMPTY, U256 as rU256}; use serde::{Deserialize, Serialize}; use std::{ @@ -38,7 +36,7 @@ pub struct Genesis { #[serde(deserialize_with = "deserialize_stringified_u64")] pub difficulty: u64, #[serde(default, skip_serializing_if = "Option::is_none")] - pub mix_hash: Option, + pub mix_hash: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub coinbase: Option
, #[serde(default)] @@ -56,12 +54,8 @@ pub struct Genesis { )] pub gas_used: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - pub parent_hash: Option, - #[serde( - default, - deserialize_with = "deserialize_stringified_numeric_opt", - skip_serializing_if = "Option::is_none" - )] + pub parent_hash: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] pub base_fee_per_gas: Option, } @@ -86,19 +80,19 @@ impl Genesis { env.cfg.chain_id = chain_id; } if let Some(timestamp) = self.timestamp { - env.block.timestamp = rU256::from(timestamp); + env.block.timestamp = U256::from(timestamp); } if let Some(base_fee) = self.base_fee_per_gas { - env.block.basefee = base_fee.to_alloy(); + env.block.basefee = base_fee; } if let Some(number) = self.number { env.block.number = rU256::from(number); } if let Some(coinbase) = self.coinbase { - env.block.coinbase = coinbase.to_alloy(); + env.block.coinbase = coinbase; } - env.block.difficulty = rU256::from(self.difficulty); - env.block.gas_limit = rU256::from(self.gas_limit); + env.block.difficulty = U256::from(self.difficulty); + env.block.gas_limit = U256::from(self.gas_limit); } /// Returns all private keys from the genesis accounts, if they exist @@ -118,8 +112,7 @@ pub struct GenesisAccount { #[serde(default, skip_serializing_if = "Option::is_none")] pub code: Option, #[serde(default, skip_serializing_if = "HashMap::is_empty")] - pub storage: HashMap, - #[serde(deserialize_with = "deserialize_stringified_numeric")] + pub storage: HashMap, pub balance: U256, #[serde( default, @@ -141,7 +134,7 @@ impl From for AccountInfo { let GenesisAccount { code, balance, nonce, .. } = acc; let code = code.map(|code| Bytecode::new_raw(code.to_vec().into())); AccountInfo { - balance: balance.to_alloy(), + balance, nonce: nonce.unwrap_or_default(), code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), code, @@ -169,7 +162,7 @@ pub struct Config { #[serde(default, skip_serializing_if = "Option::is_none")] pub eip150_block: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - pub eip150_hash: Option, + pub eip150_hash: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub eip155_block: Option, #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 4615f6ca7f28c..4c478b669e3d9 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -23,7 +23,13 @@ use ethers::{ signers::Signer, types::{Address, U256}, }; -use foundry_common::{ProviderBuilder, RetryProvider}; +use foundry_common::{ + provider::{ + alloy::{ProviderBuilder, RetryProvider}, + ethers::{ProviderBuilder as EthersProviderBuilder, RetryProvider as EthersRetryProvider}, + }, + types::ToEthers, +}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; use parking_lot::Mutex; @@ -34,7 +40,6 @@ use std::{ pin::Pin, sync::Arc, task::{Context, Poll}, - time::Duration, }; use tokio::{ runtime::Handle, @@ -271,10 +276,16 @@ impl NodeHandle { /// Constructs a [`RetryProvider`] for this handle's HTTP endpoint. pub fn http_provider(&self) -> RetryProvider { - ProviderBuilder::new(&self.http_endpoint()) + ProviderBuilder::new(&self.http_endpoint()).build().expect("failed to build HTTP provider") + // .interval(Duration::from_millis(500)) + } + + /// Constructs a [`EthersRetryProvider`] for this handle's HTTP endpoint. + /// TODO: Remove once ethers is phased out of cast/alloy and tests. + pub fn ethers_http_provider(&self) -> EthersRetryProvider { + EthersProviderBuilder::new(&self.http_endpoint()) .build() - .expect("failed to build HTTP provider") - .interval(Duration::from_millis(500)) + .expect("failed to build ethers HTTP provider") } /// Constructs a [`RetryProvider`] for this handle's WS endpoint. @@ -282,11 +293,21 @@ impl NodeHandle { ProviderBuilder::new(&self.ws_endpoint()).build().expect("failed to build WS provider") } + pub fn ethers_ws_provider(&self) -> EthersRetryProvider { + EthersProviderBuilder::new(&self.ws_endpoint()) + .build() + .expect("failed to build ethers WS provider") + } + /// Constructs a [`RetryProvider`] for this handle's IPC endpoint, if any. pub fn ipc_provider(&self) -> Option { ProviderBuilder::new(&self.config.get_ipc_path()?).build().ok() } + pub fn ethers_ipc_provider(&self) -> Option { + EthersProviderBuilder::new(&self.config.get_ipc_path()?).build().ok() + } + /// Signer accounts that can sign messages/transactions from the EVM node pub fn dev_accounts(&self) -> impl Iterator + '_ { self.config.signer_accounts.iter().map(|wallet| wallet.address()) @@ -304,12 +325,12 @@ impl NodeHandle { /// Native token balance of every genesis account in the genesis block pub fn genesis_balance(&self) -> U256 { - self.config.genesis_balance + self.config.genesis_balance.to_ethers() } /// Default gas price for all txs pub fn gas_price(&self) -> U256 { - self.config.get_gas_price() + self.config.get_gas_price().to_ethers() } /// Returns the shutdown signal @@ -353,7 +374,7 @@ impl Future for NodeHandle { // poll the ipc task if let Some(mut ipc) = pin.ipc_task.take() { if let Poll::Ready(res) = ipc.poll_unpin(cx) { - return Poll::Ready(res.map(|res| res.map_err(NodeError::from))) + return Poll::Ready(res.map(|res| res.map_err(NodeError::from))); } else { pin.ipc_task = Some(ipc); } @@ -361,13 +382,13 @@ impl Future for NodeHandle { // poll the node service task if let Poll::Ready(res) = pin.node_service.poll_unpin(cx) { - return Poll::Ready(res) + return Poll::Ready(res); } // poll the axum server handles for server in pin.servers.iter_mut() { if let Poll::Ready(res) = server.poll_unpin(cx) { - return Poll::Ready(res) + return Poll::Ready(res); } } diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index 0d311d810a2da..ed061567df157 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -1,17 +1,16 @@ use crate::{ eth::{backend::notifications::NewBlockNotifications, error::to_rpc_result}, - StorageInfo, U256, + StorageInfo, }; +use alloy_primitives::{TxHash, B256, U256}; +use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log as AlloyLog}; use anvil_core::eth::{ block::Block, receipt::{EIP658Receipt, Log, TypedReceipt}, - subscription::{SubscriptionId, SubscriptionResult}, + subscription::SubscriptionId, }; use anvil_rpc::{request::Version, response::ResponseResult}; -use ethers::{ - prelude::{Log as EthersLog, H256, H256 as TxHash, U64}, - types::FilteredParams, -}; +use foundry_common::types::ToAlloy; use futures::{channel::mpsc::Receiver, ready, Stream, StreamExt}; use serde::Serialize; use std::{ @@ -26,7 +25,7 @@ pub struct LogsSubscription { pub blocks: NewBlockNotifications, pub storage: StorageInfo, pub filter: FilteredParams, - pub queued: VecDeque, + pub queued: VecDeque, pub id: SubscriptionId, } @@ -40,7 +39,7 @@ impl LogsSubscription { subscription: self.id.clone(), result: to_rpc_result(log), }; - return Poll::Ready(Some(EthSubscriptionResponse::new(params))) + return Poll::Ready(Some(EthSubscriptionResponse::new(params))); } if let Some(block) = ready!(self.blocks.poll_next_unpin(cx)) { @@ -52,16 +51,16 @@ impl LogsSubscription { // this ensures we poll the receiver until it is pending, in which case the // underlying `UnboundedReceiver` will register the new waker, see // [`futures::channel::mpsc::UnboundedReceiver::poll_next()`] - continue + continue; } self.queued.extend(logs) } } else { - return Poll::Ready(None) + return Poll::Ready(None); } if self.queued.is_empty() { - return Poll::Pending + return Poll::Pending; } } } @@ -115,10 +114,10 @@ impl EthSubscription { subscription: id.clone(), result: to_rpc_result(block), }; - return Poll::Ready(Some(EthSubscriptionResponse::new(params))) + return Poll::Ready(Some(EthSubscriptionResponse::new(params))); } } else { - return Poll::Ready(None) + return Poll::Ready(None); } } } @@ -153,21 +152,19 @@ pub fn filter_logs( block: Block, receipts: Vec, filter: &FilteredParams, -) -> Vec { +) -> Vec { /// Determines whether to add this log - fn add_log(block_hash: H256, l: &Log, block: &Block, params: &FilteredParams) -> bool { - let log = EthersLog { - address: l.address, - topics: l.topics.clone(), - data: l.data.clone(), + fn add_log(block_hash: B256, l: &Log, block: &Block, params: &FilteredParams) -> bool { + let log = AlloyLog { + address: l.address.to_alloy(), + topics: l.topics.clone().into_iter().map(|t| t.to_alloy()).collect::>(), + data: l.data.clone().0.into(), block_hash: None, block_number: None, transaction_hash: None, transaction_index: None, log_index: None, - transaction_log_index: None, - log_type: None, - removed: Some(false), + removed: false, }; if params.filter.is_some() { let block_number = block.header.number.as_u64(); @@ -176,7 +173,7 @@ pub fn filter_logs( !params.filter_address(&log) || !params.filter_topics(&log) { - return false + return false; } } true @@ -188,25 +185,23 @@ pub fn filter_logs( for (receipt_index, receipt) in receipts.into_iter().enumerate() { let receipt: EIP658Receipt = receipt.into(); let receipt_logs = receipt.logs; - let transaction_hash: Option = if !receipt_logs.is_empty() { - Some(block.transactions[receipt_index].hash()) + let transaction_hash: Option = if !receipt_logs.is_empty() { + Some(block.transactions[receipt_index].hash().to_alloy()) } else { None }; - for (transaction_log_index, log) in receipt_logs.into_iter().enumerate() { - if add_log(block_hash, &log, &block, filter) { - logs.push(EthersLog { - address: log.address, - topics: log.topics, - data: log.data, - block_hash: Some(block_hash), - block_number: Some(block.header.number.as_u64().into()), + for log in receipt_logs.into_iter() { + if add_log(block_hash.to_alloy(), &log, &block, filter) { + logs.push(AlloyLog { + address: log.address.to_alloy(), + topics: log.topics.into_iter().map(|t| t.to_alloy()).collect::>(), + data: log.data.0.into(), + block_hash: Some(block_hash.to_alloy()), + block_number: Some(U256::from(block.header.number.as_u64())), transaction_hash, - transaction_index: Some(U64::from(receipt_index)), + transaction_index: Some(U256::from(receipt_index)), log_index: Some(U256::from(log_index)), - transaction_log_index: Some(U256::from(transaction_log_index)), - log_type: None, - removed: Some(false), + removed: false, }); } log_index += 1; diff --git a/crates/anvil/src/server/handler.rs b/crates/anvil/src/server/handler.rs index 7306d603430c8..2cab0d5b7ae05 100644 --- a/crates/anvil/src/server/handler.rs +++ b/crates/anvil/src/server/handler.rs @@ -4,13 +4,13 @@ use crate::{ pubsub::{EthSubscription, LogsSubscription}, EthApi, }; -use anvil_core::eth::{ - subscription::{SubscriptionId, SubscriptionKind}, - EthPubSub, EthRequest, EthRpcCall, +use alloy_rpc_types::{ + pubsub::{Params, SubscriptionKind}, + FilteredParams, }; +use anvil_core::eth::{subscription::SubscriptionId, EthPubSub, EthRequest, EthRpcCall}; use anvil_rpc::{error::RpcError, response::ResponseResult}; use anvil_server::{PubSubContext, PubSubRpcHandler, RpcHandler}; -use ethers::types::FilteredParams; /// A `RpcHandler` that expects `EthRequest` rpc calls via http #[derive(Clone)] @@ -61,7 +61,16 @@ impl PubSubEthRpcHandler { ResponseResult::Success(canceled.into()) } EthPubSub::EthSubscribe(kind, params) => { - let params = FilteredParams::new(params.filter); + let filter = match *params { + Params::None => None, + Params::Logs(filter) => Some(*filter), + Params::Bool(_) => { + return ResponseResult::Error(RpcError::invalid_params( + "Expected params for logs subscription", + )) + } + }; + let params = FilteredParams::new(filter); let subscription = match kind { SubscriptionKind::Logs => { diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 07d8e3f967121..6d65f6fe45938 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -2,11 +2,12 @@ use anvil::{spawn, NodeConfig}; use ethers::{prelude::Middleware, types::Address}; +use foundry_common::types::ToAlloy; #[tokio::test(flavor = "multi_thread")] async fn test_can_change_mining_mode() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); assert!(api.anvil_get_auto_mine().unwrap()); @@ -35,7 +36,7 @@ async fn test_can_change_mining_mode() { #[tokio::test(flavor = "multi_thread")] async fn can_get_default_dev_keys() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let dev_accounts = handle.dev_accounts().collect::>(); let accounts = provider.get_accounts().await.unwrap(); @@ -46,8 +47,8 @@ async fn can_get_default_dev_keys() { async fn can_set_empty_code() { let (api, _handle) = spawn(NodeConfig::test()).await; let addr = Address::random(); - api.anvil_set_code(addr, Vec::new().into()).await.unwrap(); - let code = api.get_code(addr, None).await.unwrap(); + api.anvil_set_code(addr.to_alloy(), Vec::new().into()).await.unwrap(); + let code = api.get_code(addr.to_alloy(), None).await.unwrap(); assert!(code.as_ref().is_empty()); } @@ -56,7 +57,7 @@ async fn test_can_set_genesis_timestamp() { let genesis_timestamp = 1000u64; let (_api, handle) = spawn(NodeConfig::test().with_genesis_timestamp(genesis_timestamp.into())).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); assert_eq!(genesis_timestamp, provider.get_block(0).await.unwrap().unwrap().timestamp.as_u64()); } @@ -64,7 +65,7 @@ async fn test_can_set_genesis_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_can_use_default_genesis_timestamp() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); assert_ne!(0u64, provider.get_block(0).await.unwrap().unwrap().timestamp.as_u64()); } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 1a7c19981ba75..60a91ee76164a 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -1,5 +1,6 @@ //! tests for custom anvil endpoints use crate::{abi::*, fork::fork_config}; +use alloy_rpc_types::BlockNumberOrTag; use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; use anvil_core::{ eth::EthRequest, @@ -14,6 +15,7 @@ use ethers::{ }, utils::hex, }; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::revm::primitives::SpecId; use std::{ str::FromStr, @@ -24,10 +26,10 @@ use std::{ #[tokio::test(flavor = "multi_thread")] async fn can_set_gas_price() { let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); - let gas_price = 1337u64.into(); - api.anvil_set_min_gas_price(gas_price).await.unwrap(); + let gas_price: U256 = 1337u64.into(); + api.anvil_set_min_gas_price(gas_price.to_alloy()).await.unwrap(); assert_eq!(gas_price, provider.get_gas_price().await.unwrap()); } @@ -35,12 +37,13 @@ async fn can_set_gas_price() { async fn can_set_block_gas_limit() { let (api, _) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let block_gas_limit = 1337u64.into(); - assert!(api.evm_set_block_gas_limit(block_gas_limit).unwrap()); + let block_gas_limit: U256 = 1337u64.into(); + assert!(api.evm_set_block_gas_limit(block_gas_limit.to_alloy()).unwrap()); // Mine a new block, and check the new block gas limit api.mine_one().await; - let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(block_gas_limit, latest_block.gas_limit); + let latest_block = + api.block_by_number(alloy_rpc_types::BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert_eq!(block_gas_limit.to_alloy(), latest_block.header.gas_limit); } // Ref @@ -58,31 +61,31 @@ async fn can_set_storage() { let storage_value = api.storage_at(addr, slot, None).await.unwrap(); assert_eq!(val, storage_value); - assert_eq!(val, H256::from_uint(&U256::from(12345))); + assert_eq!(val.to_ethers(), H256::from_uint(&U256::from(12345))); } #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let impersonate = Address::random(); let to = Address::random(); let val = 1337u64; let funding = U256::from(1e18 as u64); // fund the impersonated account - api.anvil_set_balance(impersonate, funding).await.unwrap(); + api.anvil_set_balance(impersonate.to_alloy(), funding.to_alloy()).await.unwrap(); - let balance = api.balance(impersonate, None).await.unwrap(); - assert_eq!(balance, funding); + let balance = api.balance(impersonate.to_alloy(), None).await.unwrap(); + assert_eq!(balance, funding.to_alloy()); let tx = TransactionRequest::new().from(impersonate).to(to).value(val); let res = provider.send_transaction(tx.clone(), None).await; res.unwrap_err(); - api.anvil_impersonate_account(impersonate).await.unwrap(); - assert!(api.accounts().unwrap().contains(&impersonate)); + api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); + assert!(api.accounts().unwrap().contains(&impersonate.to_alloy())); let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); assert_eq!(res.from, impersonate); @@ -93,7 +96,7 @@ async fn can_impersonate_account() { let balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance, val.into()); - api.anvil_stop_impersonating_account(impersonate).await.unwrap(); + api.anvil_stop_impersonating_account(impersonate.to_alloy()).await.unwrap(); let res = provider.send_transaction(tx, None).await; res.unwrap_err(); } @@ -101,17 +104,17 @@ async fn can_impersonate_account() { #[tokio::test(flavor = "multi_thread")] async fn can_auto_impersonate_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let impersonate = Address::random(); let to = Address::random(); let val = 1337u64; let funding = U256::from(1e18 as u64); // fund the impersonated account - api.anvil_set_balance(impersonate, funding).await.unwrap(); + api.anvil_set_balance(impersonate.to_alloy(), funding.to_alloy()).await.unwrap(); - let balance = api.balance(impersonate, None).await.unwrap(); - assert_eq!(balance, funding); + let balance = api.balance(impersonate.to_alloy(), None).await.unwrap(); + assert_eq!(balance, funding.to_alloy()); let tx = TransactionRequest::new().from(impersonate).to(to).value(val); @@ -134,14 +137,14 @@ async fn can_auto_impersonate_account() { res.unwrap_err(); // explicitly impersonated accounts get returned by `eth_accounts` - api.anvil_impersonate_account(impersonate).await.unwrap(); - assert!(api.accounts().unwrap().contains(&impersonate)); + api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); + assert!(api.accounts().unwrap().contains(&impersonate.to_alloy())); } #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_contract() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let provider = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -153,10 +156,12 @@ async fn can_impersonate_contract() { let to = Address::random(); let val = 1337u64; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // fund the impersonated account - api.anvil_set_balance(impersonate, U256::from(1e18 as u64)).await.unwrap(); + api.anvil_set_balance(impersonate.to_alloy(), U256::from(1e18 as u64).to_alloy()) + .await + .unwrap(); let tx = TransactionRequest::new().from(impersonate).to(to).value(val); @@ -166,7 +171,7 @@ async fn can_impersonate_contract() { let greeting = greeter_contract.greet().call().await.unwrap(); assert_eq!("Hello World!", greeting); - api.anvil_impersonate_account(impersonate).await.unwrap(); + api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); assert_eq!(res.from, impersonate); @@ -174,7 +179,7 @@ async fn can_impersonate_contract() { let balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance, val.into()); - api.anvil_stop_impersonating_account(impersonate).await.unwrap(); + api.anvil_stop_impersonating_account(impersonate.to_alloy()).await.unwrap(); let res = provider.send_transaction(tx, None).await; res.unwrap_err(); @@ -185,7 +190,7 @@ async fn can_impersonate_contract() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_gnosis_safe() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // let safe: Address = "0xA063Cb7CFd8E57c30c788A0572CBbf2129ae56B6".parse().unwrap(); @@ -193,19 +198,19 @@ async fn can_impersonate_gnosis_safe() { let code = provider.get_code(safe, None).await.unwrap(); assert!(!code.is_empty()); - api.anvil_impersonate_account(safe).await.unwrap(); + api.anvil_impersonate_account(safe.to_alloy()).await.unwrap(); let code = provider.get_code(safe, None).await.unwrap(); assert!(!code.is_empty()); let balance = U256::from(1e18 as u64); // fund the impersonated account - api.anvil_set_balance(safe, balance).await.unwrap(); + api.anvil_set_balance(safe.to_alloy(), balance.to_alloy()).await.unwrap(); let on_chain_balance = provider.get_balance(safe, None).await.unwrap(); assert_eq!(on_chain_balance, balance); - api.anvil_stop_impersonating_account(safe).await.unwrap(); + api.anvil_stop_impersonating_account(safe.to_alloy()).await.unwrap(); let code = provider.get_code(safe, None).await.unwrap(); // code is added back after stop impersonating @@ -215,7 +220,7 @@ async fn can_impersonate_gnosis_safe() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_multiple_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let impersonate0 = Address::random(); let impersonate1 = Address::random(); @@ -224,13 +229,13 @@ async fn can_impersonate_multiple_account() { let val = 1337u64; let funding = U256::from(1e18 as u64); // fund the impersonated accounts - api.anvil_set_balance(impersonate0, funding).await.unwrap(); - api.anvil_set_balance(impersonate1, funding).await.unwrap(); + api.anvil_set_balance(impersonate0.to_alloy(), funding.to_alloy()).await.unwrap(); + api.anvil_set_balance(impersonate1.to_alloy(), funding.to_alloy()).await.unwrap(); let tx = TransactionRequest::new().from(impersonate0).to(to).value(val); - api.anvil_impersonate_account(impersonate0).await.unwrap(); - api.anvil_impersonate_account(impersonate1).await.unwrap(); + api.anvil_impersonate_account(impersonate0.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(impersonate1.to_alloy()).await.unwrap(); let res0 = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); assert_eq!(res0.from, impersonate0); @@ -262,7 +267,7 @@ async fn can_impersonate_multiple_account() { #[tokio::test(flavor = "multi_thread")] async fn can_mine_manually() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let start_num = provider.get_block_number().await.unwrap(); @@ -276,7 +281,7 @@ async fn can_mine_manually() { #[tokio::test(flavor = "multi_thread")] async fn test_set_next_timestamp() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -303,7 +308,7 @@ async fn test_set_next_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_evm_set_time() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -327,7 +332,7 @@ async fn test_evm_set_time() { #[tokio::test(flavor = "multi_thread")] async fn test_evm_set_time_in_past() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -347,7 +352,7 @@ async fn test_evm_set_time_in_past() { #[tokio::test(flavor = "multi_thread")] async fn test_timestamp_interval() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); api.evm_mine(None).await.unwrap(); let interval = 10; @@ -398,7 +403,7 @@ async fn test_timestamp_interval() { async fn test_can_set_storage_bsc_fork() { let (api, handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; - let provider = Arc::new(handle.http_provider()); + let provider = Arc::new(handle.ethers_http_provider()); let busd_addr: Address = "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56".parse().unwrap(); let idx: U256 = @@ -406,9 +411,9 @@ async fn test_can_set_storage_bsc_fork() { let value: H256 = "0x0000000000000000000000000000000000000000000000000000000000003039".parse().unwrap(); - api.anvil_set_storage_at(busd_addr, idx, value).await.unwrap(); - let storage = api.storage_at(busd_addr, idx, None).await.unwrap(); - assert_eq!(storage, value); + api.anvil_set_storage_at(busd_addr.to_alloy(), idx.to_alloy(), value.to_alloy()).await.unwrap(); + let storage = api.storage_at(busd_addr.to_alloy(), idx.to_alloy(), None).await.unwrap(); + assert_eq!(storage.to_ethers(), value); let input = hex::decode("70a082310000000000000000000000000000000000000000000000000000000000000000") @@ -427,22 +432,22 @@ async fn can_get_node_info() { let node_info = api.anvil_node_info().await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let block_number = provider.get_block_number().await.unwrap(); let block = provider.get_block(block_number).await.unwrap().unwrap(); let expected_node_info = NodeInfo { - current_block_number: U64([0]), + current_block_number: U64([0]).to_alloy(), current_block_timestamp: 1, - current_block_hash: block.hash.unwrap(), + current_block_hash: block.hash.unwrap().to_alloy(), hard_fork: SpecId::SHANGHAI, transaction_order: "fees".to_owned(), environment: NodeEnvironment { - base_fee: U256::from_str("0x3b9aca00").unwrap(), + base_fee: U256::from_str("0x3b9aca00").unwrap().to_alloy(), chain_id: 0x7a69, - gas_limit: U256::from_str("0x1c9c380").unwrap(), - gas_price: U256::from_str("0x77359400").unwrap(), + gas_limit: U256::from_str("0x1c9c380").unwrap().to_alloy(), + gas_price: U256::from_str("0x77359400").unwrap().to_alloy(), }, fork_config: NodeForkConfig { fork_url: None, @@ -460,14 +465,14 @@ async fn can_get_metadata() { let metadata = api.anvil_metadata().await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let block_number = provider.get_block_number().await.unwrap().as_u64(); let chain_id = provider.get_chainid().await.unwrap().as_u64(); let block = provider.get_block(block_number).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { - latest_block_hash: block.hash.unwrap(), + latest_block_hash: block.hash.unwrap().to_alloy(), latest_block_number: block_number, chain_id, client_version: CLIENT_VERSION, @@ -483,7 +488,7 @@ async fn can_get_metadata() { async fn can_get_metadata_on_fork() { let (api, handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; - let provider = Arc::new(handle.http_provider()); + let provider = Arc::new(handle.ethers_http_provider()); let metadata = api.anvil_metadata().await.unwrap(); @@ -492,7 +497,7 @@ async fn can_get_metadata_on_fork() { let block = provider.get_block(block_number).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { - latest_block_hash: block.hash.unwrap(), + latest_block_hash: block.hash.unwrap().to_alloy(), latest_block_number: block_number, chain_id, client_version: CLIENT_VERSION, @@ -500,7 +505,7 @@ async fn can_get_metadata_on_fork() { forked_network: Some(ForkedNetwork { chain_id, fork_block_number: block_number, - fork_block_hash: block.hash.unwrap(), + fork_block_hash: block.hash.unwrap().to_alloy(), }), snapshots: Default::default(), }; @@ -527,11 +532,11 @@ async fn metadata_changes_on_reset() { #[tokio::test(flavor = "multi_thread")] async fn test_get_transaction_receipt() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // set the base fee let new_base_fee = U256::from(1_000); - api.anvil_set_next_block_base_fee_per_gas(new_base_fee).await.unwrap(); + api.anvil_set_next_block_base_fee_per_gas(new_base_fee.to_alloy()).await.unwrap(); // send a EIP-1559 transaction let tx = @@ -558,7 +563,7 @@ async fn test_get_transaction_receipt() { #[tokio::test(flavor = "multi_thread")] async fn test_set_chain_id() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id, U256::from(31337)); @@ -576,17 +581,17 @@ async fn test_fork_revert_next_block_timestamp() { // Mine a new block, and check the new block gas limit api.mine_one().await; - let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); let snapshot_id = api.evm_snapshot().await.unwrap(); api.mine_one().await; api.evm_revert(snapshot_id).await.unwrap(); - let block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); assert_eq!(block, latest_block); api.mine_one().await; - let block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); - assert!(block.timestamp > latest_block.timestamp); + let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert!(block.header.timestamp > latest_block.header.timestamp); } // test that after a snapshot revert, the env block is reset @@ -594,11 +599,11 @@ async fn test_fork_revert_next_block_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_revert_call_latest_block_timestamp() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // Mine a new block, and check the new block gas limit api.mine_one().await; - let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); let snapshot_id = api.evm_snapshot().await.unwrap(); api.mine_one().await; @@ -609,11 +614,20 @@ async fn test_fork_revert_call_latest_block_timestamp() { provider.into(), ); - assert_eq!(multicall.get_current_block_timestamp().await.unwrap(), latest_block.timestamp); - assert_eq!(multicall.get_current_block_difficulty().await.unwrap(), latest_block.difficulty); - assert_eq!(multicall.get_current_block_gas_limit().await.unwrap(), latest_block.gas_limit); + assert_eq!( + multicall.get_current_block_timestamp().await.unwrap(), + latest_block.header.timestamp.to_ethers() + ); + assert_eq!( + multicall.get_current_block_difficulty().await.unwrap(), + latest_block.header.difficulty.to_ethers() + ); + assert_eq!( + multicall.get_current_block_gas_limit().await.unwrap(), + latest_block.header.gas_limit.to_ethers() + ); assert_eq!( multicall.get_current_block_coinbase().await.unwrap(), - latest_block.author.unwrap_or_default() + latest_block.header.miner.to_ethers() ); } diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 32c6fcf2ba6c5..7a6a64ae379a0 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -1,11 +1,13 @@ //! general eth api tests use crate::abi::{MulticallContract, SimpleStorage}; +use alloy_primitives::U256 as rU256; +use alloy_rpc_types::{CallInput, CallRequest}; use anvil::{ eth::{api::CLIENT_VERSION, EthApi}, spawn, NodeConfig, CHAIN_ID, }; -use anvil_core::eth::{state::AccountOverride, transaction::EthTransactionRequest}; +use anvil_core::eth::{state::AccountOverride, transaction::to_alloy_state_override}; use ethers::{ abi::{Address, Tokenizable}, prelude::{builders::ContractCall, decode_function_data, Middleware, SignerMiddleware}, @@ -13,6 +15,7 @@ use ethers::{ types::{Block, BlockNumber, Chain, Transaction, TransactionRequest, H256, U256}, utils::get_contract_address, }; +use foundry_common::types::ToAlloy; use std::{collections::HashMap, sync::Arc, time::Duration}; #[tokio::test(flavor = "multi_thread")] @@ -20,18 +23,18 @@ async fn can_get_block_number() { let (api, handle) = spawn(NodeConfig::test()).await; let block_num = api.block_number().unwrap(); - assert_eq!(block_num, U256::zero()); + assert_eq!(block_num, U256::zero().to_alloy()); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num, block_num.as_u64().into()); + assert_eq!(num, block_num.to::().into()); } #[tokio::test(flavor = "multi_thread")] async fn can_dev_get_balance() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { @@ -43,7 +46,7 @@ async fn can_dev_get_balance() { #[tokio::test(flavor = "multi_thread")] async fn can_get_price() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let _ = provider.get_gas_price().await.unwrap(); } @@ -51,7 +54,7 @@ async fn can_get_price() { #[tokio::test(flavor = "multi_thread")] async fn can_get_accounts() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let _ = provider.get_accounts().await.unwrap(); } @@ -59,7 +62,7 @@ async fn can_get_accounts() { #[tokio::test(flavor = "multi_thread")] async fn can_get_client_version() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let version = provider.client_version().await.unwrap(); assert_eq!(CLIENT_VERSION, version); @@ -68,7 +71,7 @@ async fn can_get_client_version() { #[tokio::test(flavor = "multi_thread")] async fn can_get_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id, CHAIN_ID.into()); @@ -77,7 +80,7 @@ async fn can_get_chain_id() { #[tokio::test(flavor = "multi_thread")] async fn can_modify_chain_id() { let (_api, handle) = spawn(NodeConfig::test().with_chain_id(Some(Chain::Goerli))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id, Chain::Goerli.into()); @@ -97,7 +100,7 @@ async fn can_get_network_id() { #[tokio::test(flavor = "multi_thread")] async fn can_get_block_by_number() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); let to = accounts[1].address(); @@ -119,7 +122,7 @@ async fn can_get_block_by_number() { #[tokio::test(flavor = "multi_thread")] async fn can_get_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let block = provider.get_block(BlockNumber::Pending).await.unwrap().unwrap(); @@ -153,7 +156,7 @@ async fn can_get_pending_block() { #[tokio::test(flavor = "multi_thread")] async fn can_call_on_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let num = provider.get_block_number().await.unwrap(); assert_eq!(num.as_u64(), 0u64); @@ -182,36 +185,41 @@ async fn can_call_on_pending_block() { let accounts: Vec
= handle.dev_wallets().map(|w| w.address()).collect(); for i in 1..10 { - api.anvil_set_coinbase(accounts[i % accounts.len()]).await.unwrap(); - api.evm_set_block_gas_limit((30_000_000 + i).into()).unwrap(); + api.anvil_set_coinbase(accounts[i % accounts.len()].to_alloy()).await.unwrap(); + api.evm_set_block_gas_limit(rU256::from(30_000_000 + i)).unwrap(); - api.anvil_mine(Some(1.into()), None).await.unwrap(); + api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); tokio::time::sleep(Duration::from_secs(1)).await; } // Ensure that the right header values are set when calling a past block - for block_number in 1..(api.block_number().unwrap().as_usize() + 1) { - let block_number = BlockNumber::Number(block_number.into()); - let block = api.block_by_number(block_number).await.unwrap().unwrap(); + for block_number in 1..(api.block_number().unwrap().to::() + 1) { + let block_number_alloy = alloy_rpc_types::BlockNumberOrTag::Number(block_number as u64); + let block_number_ethers = BlockNumber::Number((block_number as u64).into()); + let block = api.block_by_number(block_number_alloy).await.unwrap().unwrap(); let block_timestamp = pending_contract .get_current_block_timestamp() - .block(block_number) + .block(block_number_ethers) .call() .await .unwrap(); - assert_eq!(block.timestamp, block_timestamp); + assert_eq!(block.header.timestamp, block_timestamp.to_alloy()); let block_gas_limit = pending_contract .get_current_block_gas_limit() - .block(block_number) + .block(block_number_ethers) .call() .await .unwrap(); - assert_eq!(block.gas_limit, block_gas_limit); + assert_eq!(block.header.gas_limit, block_gas_limit.to_alloy()); - let block_coinbase = - pending_contract.get_current_block_coinbase().block(block_number).call().await.unwrap(); - assert_eq!(block.author.unwrap(), block_coinbase); + let block_coinbase = pending_contract + .get_current_block_coinbase() + .block(block_number_ethers) + .call() + .await + .unwrap(); + assert_eq!(block.header.miner, block_coinbase.to_alloy()); } } @@ -226,13 +234,13 @@ where { let result = api .call( - EthTransactionRequest { - data: call.tx.data().cloned(), - to: Some(to), + CallRequest { + input: CallInput::maybe_input(call.tx.data().cloned().map(|b| b.0.into())), + to: Some(to.to_alloy()), ..Default::default() }, None, - Some(overrides), + Some(to_alloy_state_override(overrides)), ) .await .unwrap(); @@ -242,7 +250,7 @@ where #[tokio::test(flavor = "multi_thread")] async fn can_call_with_state_override() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); api.anvil_set_auto_mine(true).await.unwrap(); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index a128483a42258..f3efb4475fab1 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1,8 +1,10 @@ //! various fork related test use crate::{abi::*, utils}; +use alloy_primitives::U256 as rU256; +use alloy_rpc_types::{BlockNumberOrTag, CallRequest}; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; -use anvil_core::{eth::transaction::EthTransactionRequest, types::Forking}; +use anvil_core::types::Forking; use ethers::{ core::rand, prelude::{Bytes, LocalWallet, Middleware, SignerMiddleware}, @@ -14,7 +16,8 @@ use ethers::{ }, }; use foundry_common::{ - get_http_provider, rpc, + provider::ethers::get_http_provider, + rpc, rpc::next_http_rpc_endpoint, types::{ToAlloy, ToEthers}, }; @@ -67,18 +70,18 @@ async fn test_spawn_fork() { assert!(api.is_fork()); let head = api.block_number().unwrap(); - assert_eq!(head, BLOCK_NUMBER.into()) + assert_eq!(head, rU256::from(BLOCK_NUMBER)) } #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_balance() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); for _ in 0..10 { let addr = Address::random(); - let balance = api.balance(addr, None).await.unwrap(); + let balance = api.balance(addr.to_alloy(), None).await.unwrap(); let provider_balance = provider.get_balance(addr, None).await.unwrap(); - assert_eq!(balance, provider_balance) + assert_eq!(balance, provider_balance.to_alloy()) } } @@ -86,7 +89,7 @@ async fn test_fork_eth_get_balance() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_balance_after_mine() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let info = api.anvil_node_info().await.unwrap(); let number = info.fork_config.fork_block_number.unwrap(); assert_eq!(number, BLOCK_NUMBER); @@ -110,7 +113,7 @@ async fn test_fork_eth_get_balance_after_mine() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_code_after_mine() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let info = api.anvil_node_info().await.unwrap(); let number = info.fork_config.fork_block_number.unwrap(); assert_eq!(number, BLOCK_NUMBER); @@ -129,23 +132,23 @@ async fn test_fork_eth_get_code_after_mine() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_code() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); for _ in 0..10 { let addr = Address::random(); - let code = api.get_code(addr, None).await.unwrap(); + let code = api.get_code(addr.to_alloy(), None).await.unwrap(); let provider_code = provider.get_code(addr, None).await.unwrap(); - assert_eq!(code, provider_code) + assert_eq!(code, provider_code.to_alloy()) } for address in utils::contract_addresses(Chain::Mainnet) { let prev_code = api - .get_code(address, Some(BlockNumber::Number((BLOCK_NUMBER - 10).into()).into())) + .get_code(address.to_alloy(), Some(BlockNumberOrTag::Number(BLOCK_NUMBER - 10).into())) .await .unwrap(); - let code = api.get_code(address, None).await.unwrap(); + let code = api.get_code(address.to_alloy(), None).await.unwrap(); let provider_code = provider.get_code(address, None).await.unwrap(); assert_eq!(code, prev_code); - assert_eq!(code, provider_code); + assert_eq!(code, provider_code.to_alloy()); assert!(!code.as_ref().is_empty()); } } @@ -153,35 +156,36 @@ async fn test_fork_eth_get_code() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_nonce() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); for _ in 0..10 { let addr = Address::random(); - let api_nonce = api.transaction_count(addr, None).await.unwrap(); + let api_nonce = api.transaction_count(addr.to_alloy(), None).await.unwrap(); let provider_nonce = provider.get_transaction_count(addr, None).await.unwrap(); - assert_eq!(api_nonce, provider_nonce); + assert_eq!(api_nonce, provider_nonce.to_alloy()); } let addr = Config::DEFAULT_SENDER; - let api_nonce = api.transaction_count(addr.to_ethers(), None).await.unwrap(); + let api_nonce = api.transaction_count(addr, None).await.unwrap(); let provider_nonce = provider.get_transaction_count(addr.to_ethers(), None).await.unwrap(); - assert_eq!(api_nonce, provider_nonce); + assert_eq!(api_nonce, provider_nonce.to_alloy()); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_fee_history() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let count = 10u64; - let _history = api.fee_history(count.into(), BlockNumber::Latest, vec![]).await.unwrap(); + let _history = + api.fee_history(rU256::from(count), BlockNumberOrTag::Latest, vec![]).await.unwrap(); let _provider_history = provider.fee_history(count, BlockNumber::Latest, &[]).await.unwrap(); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_reset() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -229,7 +233,7 @@ async fn test_fork_reset() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_reset_setup() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let dead_addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); @@ -256,7 +260,7 @@ async fn test_fork_reset_setup() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_snapshotting() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let snapshot = api.evm_snapshot().await.unwrap(); @@ -292,7 +296,7 @@ async fn test_fork_snapshotting() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_snapshotting_repeated() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let snapshot = api.evm_snapshot().await.unwrap(); @@ -338,7 +342,7 @@ async fn test_fork_snapshotting_repeated() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_snapshotting_blocks() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // create a snapshot let snapshot = api.evm_snapshot().await.unwrap(); @@ -390,14 +394,14 @@ async fn test_fork_snapshotting_blocks() { #[tokio::test(flavor = "multi_thread")] async fn test_separate_states() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(14723772u64))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); let remote_balance = provider.get_balance(addr, None).await.unwrap(); assert_eq!(remote_balance, 12556104082473169733500u128.into()); - api.anvil_set_balance(addr, 1337u64.into()).await.unwrap(); + api.anvil_set_balance(addr.to_alloy(), rU256::from(1337u64)).await.unwrap(); let balance = provider.get_balance(addr, None).await.unwrap(); assert_eq!(balance, 1337u64.into()); @@ -419,7 +423,7 @@ async fn test_separate_states() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_on_fork() { let (_api, handle) = spawn(fork_config().with_fork_block_number(Some(14723772u64))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -444,17 +448,23 @@ async fn can_deploy_greeter_on_fork() { async fn can_reset_properly() { let (origin_api, origin_handle) = spawn(NodeConfig::test()).await; let account = origin_handle.dev_accounts().next().unwrap(); - let origin_provider = origin_handle.http_provider(); - let origin_nonce = 1u64.into(); - origin_api.anvil_set_nonce(account, origin_nonce).await.unwrap(); + let origin_provider = origin_handle.ethers_http_provider(); + let origin_nonce = rU256::from(1u64); + origin_api.anvil_set_nonce(account.to_alloy(), origin_nonce).await.unwrap(); - assert_eq!(origin_nonce, origin_provider.get_transaction_count(account, None).await.unwrap()); + assert_eq!( + origin_nonce, + origin_provider.get_transaction_count(account, None).await.unwrap().to_alloy() + ); let (fork_api, fork_handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some(origin_handle.http_endpoint()))).await; - let fork_provider = fork_handle.http_provider(); - assert_eq!(origin_nonce, fork_provider.get_transaction_count(account, None).await.unwrap()); + let fork_provider = fork_handle.ethers_http_provider(); + assert_eq!( + origin_nonce, + fork_provider.get_transaction_count(account, None).await.unwrap().to_alloy() + ); let to = Address::random(); let to_balance = fork_provider.get_balance(to, None).await.unwrap(); @@ -462,19 +472,25 @@ async fn can_reset_properly() { let tx = fork_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); // nonce incremented by 1 - assert_eq!(origin_nonce + 1, fork_provider.get_transaction_count(account, None).await.unwrap()); + assert_eq!( + origin_nonce + rU256::from(1), + fork_provider.get_transaction_count(account, None).await.unwrap().to_alloy() + ); // resetting to origin state fork_api.anvil_reset(Some(Forking::default())).await.unwrap(); // nonce reset to origin - assert_eq!(origin_nonce, fork_provider.get_transaction_count(account, None).await.unwrap()); + assert_eq!( + origin_nonce, + fork_provider.get_transaction_count(account, None).await.unwrap().to_alloy() + ); // balance is reset assert_eq!(to_balance, fork_provider.get_balance(to, None).await.unwrap()); // tx does not exist anymore - assert!(fork_provider.get_transaction(tx.transaction_hash).await.unwrap().is_none()) + assert!(fork_provider.get_transaction(tx.transaction_hash).await.is_err()) } #[tokio::test(flavor = "multi_thread")] @@ -482,7 +498,7 @@ async fn test_fork_timestamp() { let start = std::time::Instant::now(); let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let block = provider.get_block(BLOCK_NUMBER).await.unwrap().unwrap(); assert_eq!(block.timestamp.as_u64(), BLOCK_TIMESTAMP); @@ -494,10 +510,10 @@ async fn test_fork_timestamp() { let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); - let elapsed = start.elapsed().as_secs(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let elapsed = start.elapsed().as_secs() + 1; + // ensure the diff between the new mined block and the original block is within the elapsed time let diff = block.timestamp - BLOCK_TIMESTAMP; assert!(diff <= elapsed.into(), "diff={diff}, elapsed={elapsed}"); @@ -557,9 +573,9 @@ async fn test_fork_can_send_tx() { let wallet = LocalWallet::new(&mut rand::thread_rng()); - api.anvil_set_balance(wallet.address(), U256::from(1e18 as u64)).await.unwrap(); + api.anvil_set_balance(wallet.address().to_alloy(), rU256::from(1e18 as u64)).await.unwrap(); - let provider = SignerMiddleware::new(handle.http_provider(), wallet); + let provider = SignerMiddleware::new(handle.ethers_http_provider(), wallet); let addr = Address::random(); let val = 1337u64; @@ -585,9 +601,9 @@ async fn test_fork_nft_set_approve_all() { // create and fund a random wallet let wallet = LocalWallet::new(&mut rand::thread_rng()); - api.anvil_set_balance(wallet.address(), U256::from(1000e18 as u64)).await.unwrap(); + api.anvil_set_balance(wallet.address().to_alloy(), rU256::from(1000e18 as u64)).await.unwrap(); - let provider = Arc::new(SignerMiddleware::new(handle.http_provider(), wallet.clone())); + let provider = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet.clone())); // pick a random nft let nouns_addr: Address = "0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03".parse().unwrap(); @@ -603,14 +619,16 @@ async fn test_fork_nft_set_approve_all() { let tx = approval.send().await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); + let real_owner = real_owner.to_alloy(); + // transfer: impersonate real owner and transfer nft api.anvil_impersonate_account(real_owner).await.unwrap(); - api.anvil_set_balance(real_owner, U256::from(10000e18 as u64)).await.unwrap(); + api.anvil_set_balance(real_owner, rU256::from(10000e18 as u64)).await.unwrap(); - let call = nouns.transfer_from(real_owner, wallet.address(), token_id); + let call = nouns.transfer_from(real_owner.to_ethers(), wallet.address(), token_id); let mut tx: TypedTransaction = call.tx; - tx.set_from(real_owner); + tx.set_from(real_owner.to_ethers()); provider.fill_transaction(&mut tx, None).await.unwrap(); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); @@ -639,7 +657,7 @@ async fn test_fork_with_custom_chain_id() { let config_chain_id = handle.config().chain_id; // check that the chainIds are the same - assert_eq!(eth_chain_id.unwrap().unwrap().as_u64(), 3145u64); + assert_eq!(eth_chain_id.unwrap().unwrap().to::(), 3145u64); assert_eq!(txn_chain_id, 3145u64); assert_eq!(config_chain_id, Some(3145u64)); } @@ -657,9 +675,9 @@ async fn test_fork_can_send_opensea_tx() { let sender: Address = "0x8fdbae54b6d9f3fc2c649e3dd4602961967fd42f".parse().unwrap(); // transfer: impersonate real sender - api.anvil_impersonate_account(sender).await.unwrap(); + api.anvil_impersonate_account(sender.to_alloy()).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let input: Bytes = "0xfb0f3ee1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ff2e795f5000000000000000000000000000023f28ae3e9756ba982a6290f9081b6a84900b758000000000000000000000000004c00500000ad104d7dbd00e3ae0a5c00560c0000000000000000000000000003235b597a78eabcb08ffcb4d97411073211dbcb0000000000000000000000000000000000000000000000000000000000000e72000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000062ad47c20000000000000000000000000000000000000000000000000000000062d43104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000df44e65d2a2cf40000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000001c6bf526340000000000000000000000000008de9c5a032463c561423387a9648c5c7bcc5bc900000000000000000000000000000000000000000000000000005543df729c0000000000000000000000000006eb234847a9e3a546539aac57a071c01dc3f398600000000000000000000000000000000000000000000000000000000000000416d39b5352353a22cf2d44faa696c2089b03137a13b5acfee0366306f2678fede043bc8c7e422f6f13a3453295a4a063dac7ee6216ab7bade299690afc77397a51c00000000000000000000000000000000000000000000000000000000000000".parse().unwrap(); let to: Address = "0x00000000006c3852cbef3e08e8df289169ede581".parse().unwrap(); @@ -682,9 +700,9 @@ async fn test_fork_base_fee() { let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); - api.anvil_set_next_block_base_fee_per_gas(U256::zero()).await.unwrap(); + api.anvil_set_next_block_base_fee_per_gas(rU256::ZERO).await.unwrap(); let addr = Address::random(); let val = 1337u64; @@ -697,7 +715,7 @@ async fn test_fork_base_fee() { async fn test_fork_init_base_fee() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(13184859u64))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); // @@ -720,7 +738,7 @@ async fn test_reset_fork_on_new_blocks() { ) .await; - let anvil_provider = handle.http_provider(); + let anvil_provider = handle.ethers_http_provider(); let endpoint = next_http_rpc_endpoint(); let provider = Arc::new(get_http_provider(&endpoint).interval(Duration::from_secs(2))); @@ -757,25 +775,29 @@ async fn test_fork_call() { let res1 = api .call( - EthTransactionRequest { to: Some(to), data: Some(input), ..Default::default() }, + CallRequest { + to: Some(to.to_alloy()), + input: input.to_alloy().into(), + ..Default::default() + }, None, None, ) .await .unwrap(); - assert_eq!(res0, res1); + assert_eq!(res0, res1.to_ethers()); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_block_timestamp() { let (api, _) = spawn(fork_config()).await; - let initial_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); - api.anvil_mine(Some(1.into()), None).await.unwrap(); - let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + let initial_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert!(initial_block.timestamp.as_u64() < latest_block.timestamp.as_u64()); + assert!(initial_block.header.timestamp.to::() < latest_block.header.timestamp.to::()); } #[tokio::test(flavor = "multi_thread")] @@ -783,33 +805,36 @@ async fn test_fork_snapshot_block_timestamp() { let (api, _) = spawn(fork_config()).await; let snapshot_id = api.evm_snapshot().await.unwrap(); - api.anvil_mine(Some(1.into()), None).await.unwrap(); - let initial_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); + let initial_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); api.evm_revert(snapshot_id).await.unwrap(); - api.evm_set_next_block_timestamp(initial_block.timestamp.as_u64()).unwrap(); - api.anvil_mine(Some(1.into()), None).await.unwrap(); - let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); - - assert_eq!(initial_block.timestamp.as_u64(), latest_block.timestamp.as_u64()); + api.evm_set_next_block_timestamp(initial_block.header.timestamp.to::()).unwrap(); + api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + + assert_eq!( + initial_block.header.timestamp.to::(), + latest_block.header.timestamp.to::() + ); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_uncles_fetch() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // Block on ETH mainnet with 2 uncles let block_with_uncles = 190u64; let block = - api.block_by_number(BlockNumber::Number(block_with_uncles.into())).await.unwrap().unwrap(); + api.block_by_number(BlockNumberOrTag::Number(block_with_uncles)).await.unwrap().unwrap(); assert_eq!(block.uncles.len(), 2); let count = provider.get_uncle_count(block_with_uncles).await.unwrap(); assert_eq!(count.as_usize(), block.uncles.len()); - let count = provider.get_uncle_count(block.hash.unwrap()).await.unwrap(); + let count = provider.get_uncle_count(block.header.hash.unwrap().to_ethers()).await.unwrap(); assert_eq!(count.as_usize(), block.uncles.len()); for (uncle_idx, uncle_hash) in block.uncles.iter().enumerate() { @@ -819,22 +844,22 @@ async fn test_fork_uncles_fetch() { .await .unwrap() .unwrap(); - assert_eq!(*uncle_hash, uncle.hash.unwrap()); + assert_eq!(*uncle_hash, uncle.hash.unwrap().to_alloy()); // Try with block hash let uncle = provider - .get_uncle(block.hash.unwrap(), (uncle_idx as u64).into()) + .get_uncle(block.header.hash.unwrap().to_ethers(), (uncle_idx as u64).into()) .await .unwrap() .unwrap(); - assert_eq!(*uncle_hash, uncle.hash.unwrap()); + assert_eq!(*uncle_hash, uncle.hash.unwrap().to_alloy()); } } #[tokio::test(flavor = "multi_thread")] async fn test_fork_block_transaction_count() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let sender = accounts[0].address(); @@ -842,36 +867,39 @@ async fn test_fork_block_transaction_count() { // disable automine (so there are pending transactions) api.anvil_set_auto_mine(false).await.unwrap(); // transfer: impersonate real sender - api.anvil_impersonate_account(sender).await.unwrap(); + api.anvil_impersonate_account(sender.to_alloy()).await.unwrap(); let tx = TransactionRequest::new().from(sender).value(42u64).gas(100_000); provider.send_transaction(tx, None).await.unwrap(); let pending_txs = - api.block_transaction_count_by_number(BlockNumber::Pending).await.unwrap().unwrap(); - assert_eq!(pending_txs.as_usize(), 1); + api.block_transaction_count_by_number(BlockNumberOrTag::Pending).await.unwrap().unwrap(); + assert_eq!(pending_txs.to::(), 1); // mine a new block api.anvil_mine(None, None).await.unwrap(); let pending_txs = - api.block_transaction_count_by_number(BlockNumber::Pending).await.unwrap().unwrap(); - assert_eq!(pending_txs.as_usize(), 0); + api.block_transaction_count_by_number(BlockNumberOrTag::Pending).await.unwrap().unwrap(); + assert_eq!(pending_txs.to::(), 0); let latest_txs = - api.block_transaction_count_by_number(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(latest_txs.as_usize(), 1); - let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); - let latest_txs = - api.block_transaction_count_by_hash(latest_block.hash.unwrap()).await.unwrap().unwrap(); - assert_eq!(latest_txs.as_usize(), 1); + api.block_transaction_count_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert_eq!(latest_txs.to::(), 1); + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + let latest_txs = api + .block_transaction_count_by_hash(latest_block.header.hash.unwrap()) + .await + .unwrap() + .unwrap(); + assert_eq!(latest_txs.to::(), 1); // check txs count on an older block: 420000 has 3 txs on mainnet let count_txs = api - .block_transaction_count_by_number(BlockNumber::Number(420000.into())) + .block_transaction_count_by_number(BlockNumberOrTag::Number(420000)) .await .unwrap() .unwrap(); - assert_eq!(count_txs.as_usize(), 3); + assert_eq!(count_txs.to::(), 3); let count_txs = api .block_transaction_count_by_hash( "0xb3b0e3e0c64e23fb7f1ccfd29245ae423d2f6f1b269b63b70ff882a983ce317c".parse().unwrap(), @@ -879,28 +907,28 @@ async fn test_fork_block_transaction_count() { .await .unwrap() .unwrap(); - assert_eq!(count_txs.as_usize(), 3); + assert_eq!(count_txs.to::(), 3); } // #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_in_fork() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15347924u64))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let token_holder: Address = "0x2f0b23f53734252bda2277357e97e1517d6b042a".parse().unwrap(); let to = Address::random(); let val = 1337u64; // fund the impersonated account - api.anvil_set_balance(token_holder, U256::from(1e18 as u64)).await.unwrap(); + api.anvil_set_balance(token_holder.to_alloy(), rU256::from(1e18 as u64)).await.unwrap(); let tx = TransactionRequest::new().from(token_holder).to(to).value(val); let res = provider.send_transaction(tx.clone(), None).await; res.unwrap_err(); - api.anvil_impersonate_account(token_holder).await.unwrap(); + api.anvil_impersonate_account(token_holder.to_alloy()).await.unwrap(); let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); assert_eq!(res.from, token_holder); @@ -909,7 +937,7 @@ async fn can_impersonate_in_fork() { let balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance, val.into()); - api.anvil_stop_impersonating_account(token_holder).await.unwrap(); + api.anvil_stop_impersonating_account(token_holder.to_alloy()).await.unwrap(); let res = provider.send_transaction(tx, None).await; res.unwrap_err(); } @@ -922,7 +950,7 @@ async fn test_total_difficulty_fork() { let total_difficulty: U256 = 46_673_965_560_973_856_260_636u128.into(); let difficulty: U256 = 13_680_435_288_526_144u128.into(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); assert_eq!(block.total_difficulty, Some(total_difficulty)); assert_eq!(block.difficulty, difficulty); @@ -970,7 +998,7 @@ async fn can_override_fork_chain_id() { .with_chain_id(Some(chain_id_override)), ) .await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -990,7 +1018,7 @@ async fn can_override_fork_chain_id() { let greeting = greeter_contract.greet().call().await.unwrap(); assert_eq!("Hello World!", greeting); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id.as_u64(), chain_id_override); } @@ -1005,7 +1033,7 @@ async fn test_fork_reset_moonbeam() { .with_fork_block_number(None::), ) .await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -1034,10 +1062,10 @@ async fn test_fork_reset_basefee() { let (api, _handle) = spawn(fork_config().with_fork_block_number(Some(18835000u64))).await; api.mine_one().await; - let latest = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + let latest = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); // basefee of +1 block: - assert_eq!(latest.base_fee_per_gas.unwrap(), 59455969592u64.into()); + assert_eq!(latest.header.base_fee_per_gas.unwrap(), rU256::from(59455969592u64)); // now reset to block 18835000 -1 api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(18835000u64 - 1) })) @@ -1045,8 +1073,8 @@ async fn test_fork_reset_basefee() { .unwrap(); api.mine_one().await; - let latest = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + let latest = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); // basefee of the forked block: - assert_eq!(latest.base_fee_per_gas.unwrap(), 59017001138u64.into()); + assert_eq!(latest.header.base_fee_per_gas.unwrap(), rU256::from(59017001138u64)); } diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index 27c6055be3ee3..bf1c91c685ce7 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -1,5 +1,6 @@ //! Gas related tests +use alloy_primitives::U256; use anvil::{eth::fees::INITIAL_BASE_FEE, spawn, NodeConfig}; use ethers::{ prelude::Middleware, @@ -8,16 +9,19 @@ use ethers::{ TransactionRequest, }, }; +use foundry_common::types::ToAlloy; const GAS_TRANSFER: u64 = 21_000u64; #[tokio::test(flavor = "multi_thread")] async fn test_basefee_full_block() { let (_api, handle) = spawn( - NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE)).with_gas_limit(Some(GAS_TRANSFER)), + NodeConfig::test() + .with_base_fee(Some(INITIAL_BASE_FEE.to_alloy())) + .with_gas_limit(Some(GAS_TRANSFER.to_alloy())), ) .await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); let base_fee = @@ -36,11 +40,11 @@ async fn test_basefee_full_block() { async fn test_basefee_half_block() { let (_api, handle) = spawn( NodeConfig::test() - .with_base_fee(Some(INITIAL_BASE_FEE)) - .with_gas_limit(Some(GAS_TRANSFER * 2)), + .with_base_fee(Some(INITIAL_BASE_FEE.to_alloy())) + .with_gas_limit(Some(GAS_TRANSFER.to_alloy() * U256::from(2))), ) .await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); @@ -53,9 +57,10 @@ async fn test_basefee_half_block() { } #[tokio::test(flavor = "multi_thread")] async fn test_basefee_empty_block() { - let (api, handle) = spawn(NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE))).await; + let (api, handle) = + spawn(NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE.to_alloy()))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let base_fee = @@ -74,8 +79,8 @@ async fn test_basefee_empty_block() { #[tokio::test(flavor = "multi_thread")] async fn test_respect_base_fee() { let base_fee = 50u64; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; - let provider = handle.http_provider(); + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee.to_alloy()))).await; + let provider = handle.ethers_http_provider(); let mut tx = TypedTransaction::default(); tx.set_value(100u64); tx.set_to(Address::random()); @@ -94,8 +99,8 @@ async fn test_respect_base_fee() { #[tokio::test(flavor = "multi_thread")] async fn test_tip_above_fee_cap() { let base_fee = 50u64; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; - let provider = handle.http_provider(); + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee.to_alloy()))).await; + let provider = handle.ethers_http_provider(); let tx = TypedTransaction::Eip1559( Eip1559TransactionRequest::new() .max_fee_per_gas(base_fee) diff --git a/crates/anvil/tests/it/genesis.rs b/crates/anvil/tests/it/genesis.rs index 6c028599fc146..2a0c2e8eed246 100644 --- a/crates/anvil/tests/it/genesis.rs +++ b/crates/anvil/tests/it/genesis.rs @@ -1,7 +1,10 @@ //! genesis.json tests +use std::str::FromStr; + +use alloy_primitives::{Address, U256, U64}; +use alloy_providers::provider::TempProvider; use anvil::{genesis::Genesis, spawn, NodeConfig}; -use ethers::{abi::Address, prelude::Middleware, types::U256}; #[tokio::test(flavor = "multi_thread")] async fn can_apply_genesis() { @@ -37,11 +40,11 @@ async fn can_apply_genesis() { let provider = handle.http_provider(); - assert_eq!(provider.get_chainid().await.unwrap(), 19763u64.into()); + assert_eq!(provider.get_chain_id().await.unwrap(), U64::from(19763u64)); - let addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); + let addr: Address = Address::from_str("71562b71999873db5b286df957af199ec94617f7").unwrap(); let balance = provider.get_balance(addr, None).await.unwrap(); - let expected: U256 = "ffffffffffffffffffffffffff".parse().unwrap(); + let expected: U256 = U256::from_str_radix("ffffffffffffffffffffffffff", 16).unwrap(); assert_eq!(balance, expected); } diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index b25bbba5249fd..5c79d29ab450d 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -1,7 +1,8 @@ //! IPC tests +use alloy_primitives::U256; use anvil::{spawn, NodeConfig}; -use ethers::{core::rand, prelude::Middleware, types::U256}; +use ethers::{core::rand, prelude::Middleware}; use futures::StreamExt; pub fn rand_ipc_endpoint() -> String { @@ -22,19 +23,19 @@ async fn can_get_block_number_ipc() { let (api, handle) = spawn(ipc_config()).await; let block_num = api.block_number().unwrap(); - assert_eq!(block_num, U256::zero()); + assert_eq!(block_num, U256::ZERO); - let provider = handle.ipc_provider().unwrap(); + let provider = handle.ethers_ipc_provider().unwrap(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num, block_num.as_u64().into()); + assert_eq!(num.as_u64(), block_num.to::()); } #[tokio::test(flavor = "multi_thread")] async fn test_sub_new_heads_ipc() { let (api, handle) = spawn(ipc_config()).await; - let provider = handle.ipc_provider().unwrap(); + let provider = handle.ethers_ipc_provider().unwrap(); let blocks = provider.subscribe_blocks().await.unwrap(); diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index 913015de5edf0..307eabf27ed3e 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -13,7 +13,7 @@ use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn get_past_events() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let address = wallet.address(); @@ -50,7 +50,7 @@ async fn get_past_events() { #[tokio::test(flavor = "multi_thread")] async fn get_all_events() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -87,7 +87,7 @@ async fn get_all_events() { #[tokio::test(flavor = "multi_thread")] async fn can_install_filter() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -130,7 +130,7 @@ async fn can_install_filter() { async fn watch_events() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); - let client = Arc::new(SignerMiddleware::new(handle.http_provider(), wallet)); + let client = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet)); let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) .unwrap() @@ -143,7 +143,7 @@ async fn watch_events() { let mut stream = event.stream().await.unwrap(); // Also set up a subscription for the same thing - let ws = Arc::new(handle.ws_provider()); + let ws = Arc::new(handle.ethers_ws_provider()); let contract2 = SimpleStorage::new(contract.address(), ws); let event2 = contract2.event::(); let mut subscription = event2.subscribe().await.unwrap(); diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index e7ee430bb257f..abd4de130484c 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -10,13 +10,14 @@ use ethers::{ }, }; use ethers_core::types::{Bytes, H256}; +use foundry_common::types::ToAlloy; use std::str::FromStr; #[tokio::test(flavor = "multi_thread")] async fn test_deposits_not_supported_if_optimism_disabled() { // optimism disabled by default let (_, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); @@ -52,14 +53,14 @@ async fn test_send_value_deposit_transaction() { // enable the Optimism flag let (api, handle) = spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let send_value = U256::from(1234); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); // fund the sender - api.anvil_set_balance(from_addr, send_value).await.unwrap(); + api.anvil_set_balance(from_addr.to_alloy(), send_value.to_alloy()).await.unwrap(); let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { tx: TransactionRequest { @@ -81,13 +82,14 @@ async fn test_send_value_deposit_transaction() { }); let pending = provider.send_transaction(deposit_tx.clone(), None).await.unwrap(); - let receipt = pending.await.unwrap().expect("dropped"); - assert_eq!(receipt.from, from_addr); - assert_eq!(receipt.to, Some(to_addr)); // mine block api.evm_mine(None).await.unwrap(); + let receipt = provider.get_transaction_receipt(pending.tx_hash()).await.unwrap().unwrap(); + assert_eq!(receipt.from, from_addr); + assert_eq!(receipt.to, Some(to_addr)); + // the recipient should have received the value let balance = provider.get_balance(to_addr, None).await.unwrap(); assert_eq!(balance, send_value); @@ -98,14 +100,14 @@ async fn test_send_value_raw_deposit_transaction() { // enable the Optimism flag let (api, handle) = spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let send_value = U256::from(1234); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); // fund the sender - api.anvil_set_balance(from_addr, send_value).await.unwrap(); + api.anvil_set_balance(from_addr.to_alloy(), send_value.to_alloy()).await.unwrap(); let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { tx: TransactionRequest { @@ -128,13 +130,14 @@ async fn test_send_value_raw_deposit_transaction() { let rlpbytes = deposit_tx.rlp(); let pending = provider.send_raw_transaction(rlpbytes).await.unwrap(); - let receipt = pending.await.unwrap().expect("dropped"); - assert_eq!(receipt.from, from_addr); - assert_eq!(receipt.to, Some(to_addr)); // mine block api.evm_mine(None).await.unwrap(); + let receipt = provider.get_transaction_receipt(pending.tx_hash()).await.unwrap().unwrap(); + assert_eq!(receipt.from, from_addr); + assert_eq!(receipt.to, Some(to_addr)); + // the recipient should have received the value let balance = provider.get_balance(to_addr, None).await.unwrap(); assert_eq!(balance, send_value); diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index becbcb852e534..ab77259814430 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -1,5 +1,7 @@ //! tests for otterscan endpoints use crate::abi::MulticallContract; +use alloy_primitives::U256 as rU256; +use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions}; use anvil::{ eth::otterscan::types::{ OtsInternalOperation, OtsInternalOperationType, OtsTrace, OtsTraceType, @@ -10,10 +12,11 @@ use ethers::{ abi::Address, prelude::{ContractFactory, ContractInstance, Middleware, SignerMiddleware}, signers::Signer, - types::{BlockNumber, Bytes, TransactionRequest, U256}, + types::{Bytes, TransactionRequest, U256}, utils::get_contract_address, }; use ethers_solc::{project_util::TempProject, Artifact}; +use foundry_common::types::{ToAlloy, ToEthers}; use std::{collections::VecDeque, str::FromStr, sync::Arc}; #[tokio::test(flavor = "multi_thread")] @@ -24,8 +27,8 @@ async fn can_call_erigon_get_header_by_number() { let res0 = api.erigon_get_header_by_number(0.into()).await.unwrap().unwrap(); let res1 = api.erigon_get_header_by_number(1.into()).await.unwrap().unwrap(); - assert_eq!(res0.number, Some(0.into())); - assert_eq!(res1.number, Some(1.into())); + assert_eq!(res0.header.number, Some(rU256::from(0))); + assert_eq!(res1.header.number, Some(rU256::from(1))); } #[tokio::test(flavor = "multi_thread")] @@ -38,7 +41,7 @@ async fn can_call_ots_get_api_level() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_internal_operations_contract_deploy() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let sender = wallet.address(); @@ -50,16 +53,16 @@ async fn can_call_ots_get_internal_operations_contract_deploy() { let receipt = client.send_transaction(deploy_tx, None).await.unwrap().await.unwrap().unwrap(); - let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); + let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( res[0], OtsInternalOperation { r#type: OtsInternalOperationType::Create, - from: sender, - to: contract_address, - value: 0.into() + from: sender.to_alloy(), + to: contract_address.to_alloy(), + value: rU256::from(0) } ); } @@ -67,7 +70,7 @@ async fn can_call_ots_get_internal_operations_contract_deploy() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_internal_operations_contract_transfer() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -80,16 +83,16 @@ async fn can_call_ots_get_internal_operations_contract_transfer() { let receipt = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); + let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( res[0], OtsInternalOperation { r#type: OtsInternalOperationType::Transfer, - from, - to, - value: amount + from: from.to_alloy(), + to: to.to_alloy(), + value: amount.to_alloy() } ); } @@ -122,7 +125,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -133,21 +136,23 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), + SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), ); let call = contract.method::<_, ()>("deploy", ()).unwrap(); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); + let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( res[0], OtsInternalOperation { r#type: OtsInternalOperationType::Create2, - from: Address::from_str("0x4e59b44847b379578588920cA78FbF26c0B4956C").unwrap(), - to: Address::from_str("0x347bcdad821abc09b8c275881b368de36476b62c").unwrap(), - value: 0.into() + from: Address::from_str("0x4e59b44847b379578588920cA78FbF26c0B4956C") + .unwrap() + .to_alloy(), + to: Address::from_str("0x347bcdad821abc09b8c275881b368de36476b62c").unwrap().to_alloy(), + value: rU256::from(0) } ); } @@ -178,7 +183,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -189,22 +194,22 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), + SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), ); let call = contract.method::<_, ()>("goodbye", ()).unwrap(); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); + let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( res[0], OtsInternalOperation { r#type: OtsInternalOperationType::SelfDestruct, - from: contract.address(), + from: contract.address().to_alloy(), to: Default::default(), - value: 0.into() + value: rU256::from(0) } ); } @@ -212,7 +217,7 @@ contract Contract { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_has_code() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let sender = wallet.address(); @@ -226,7 +231,7 @@ async fn can_call_ots_has_code() { // no code in the address before deploying assert!(!api - .ots_has_code(pending_contract_address, BlockNumber::Number(1.into())) + .ots_has_code(pending_contract_address.to_alloy(), BlockNumberOrTag::Number(1)) .await .unwrap()); @@ -237,11 +242,17 @@ async fn can_call_ots_has_code() { assert_eq!(num, receipt.block_number.unwrap()); // code is detected after deploying - assert!(api.ots_has_code(pending_contract_address, BlockNumber::Number(num)).await.unwrap()); + assert!(api + .ots_has_code(pending_contract_address.to_alloy(), BlockNumberOrTag::Number(num.as_u64())) + .await + .unwrap()); // code is not detected for the previous block assert!(!api - .ots_has_code(pending_contract_address, BlockNumber::Number(num - 1)) + .ots_has_code( + pending_contract_address.to_alloy(), + BlockNumberOrTag::Number(num.as_u64() - 1) + ) .await .unwrap()); } @@ -285,7 +296,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -296,12 +307,12 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), + SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), ); let call = contract.method::<_, ()>("run", ()).unwrap().value(1337); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - let res = api.ots_trace_transaction(receipt.transaction_hash).await.unwrap(); + let res = api.ots_trace_transaction(receipt.transaction_hash.to_alloy()).await.unwrap(); assert_eq!( res, @@ -309,42 +320,42 @@ contract Contract { OtsTrace { r#type: OtsTraceType::Call, depth: 0, - from: wallets[1].address(), - to: contract.address(), - value: 1337.into(), - input: Bytes::from_str("0xc0406226").unwrap() + from: wallets[1].address().to_alloy(), + to: contract.address().to_alloy(), + value: rU256::from(1337), + input: Bytes::from_str("0xc0406226").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::StaticCall, depth: 1, - from: contract.address(), - to: contract.address(), - value: U256::zero(), - input: Bytes::from_str("0x6a6758fe").unwrap() + from: contract.address().to_alloy(), + to: contract.address().to_alloy(), + value: U256::zero().to_alloy(), + input: Bytes::from_str("0x6a6758fe").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::Call, depth: 1, - from: contract.address(), - to: contract.address(), - value: U256::zero(), - input: Bytes::from_str("0x96385e39").unwrap() + from: contract.address().to_alloy(), + to: contract.address().to_alloy(), + value: U256::zero().to_alloy(), + input: Bytes::from_str("0x96385e39").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::Call, depth: 2, - from: contract.address(), - to: wallets[0].address(), - value: 1337.into(), - input: Bytes::from_str("0x").unwrap() + from: contract.address().to_alloy(), + to: wallets[0].address().to_alloy(), + value: U256::from(1337).to_alloy(), + input: Bytes::from_str("0x").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::DelegateCall, depth: 2, - from: contract.address(), - to: contract.address(), - value: U256::zero(), - input: Bytes::from_str("0xa1325397").unwrap() + from: contract.address().to_alloy(), + to: contract.address().to_alloy(), + value: U256::zero().to_alloy(), + input: Bytes::from_str("0xa1325397").unwrap().0.into() }, ] ); @@ -374,7 +385,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -386,14 +397,16 @@ contract Contract { let call = contract.method::<_, ()>("trigger_revert", ()).unwrap().gas(150_000u64); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - let res = api.ots_get_transaction_error(receipt.transaction_hash).await.unwrap().unwrap(); + let res = + api.ots_get_transaction_error(receipt.transaction_hash.to_alloy()).await.unwrap().unwrap(); + let res: Bytes = res.0.into(); assert_eq!(res, Bytes::from_str("0x8d6ea8be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012526576657274537472696e67466f6f4261720000000000000000000000000000").unwrap()); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_details() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -404,13 +417,18 @@ async fn can_call_ots_get_block_details() { let result = api.ots_get_block_details(1.into()).await.unwrap(); assert_eq!(result.block.transaction_count, 1); - assert_eq!(result.block.block.transactions[0], receipt.transaction_hash); + let hash = match result.block.block.transactions { + BlockTransactions::Full(txs) => txs[0].hash, + BlockTransactions::Hashes(hashes) => hashes[0], + BlockTransactions::Uncle => unreachable!(), + }; + assert_eq!(hash, receipt.transaction_hash.to_alloy()); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_details_by_hash() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -419,16 +437,21 @@ async fn can_call_ots_get_block_details_by_hash() { let receipt = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let block_hash = receipt.block_hash.unwrap(); - let result = api.ots_get_block_details_by_hash(block_hash).await.unwrap(); + let result = api.ots_get_block_details_by_hash(block_hash.to_alloy()).await.unwrap(); assert_eq!(result.block.transaction_count, 1); - assert_eq!(result.block.block.transactions[0], receipt.transaction_hash); + let hash = match result.block.block.transactions { + BlockTransactions::Full(txs) => txs[0].hash, + BlockTransactions::Hashes(hashes) => hashes[0], + BlockTransactions::Uncle => unreachable!(), + }; + assert_eq!(hash.to_ethers(), receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -450,13 +473,17 @@ async fn can_call_ots_get_block_transactions() { let result = api.ots_get_block_transactions(1, page, page_size).await.unwrap(); assert!(result.receipts.len() <= page_size); - assert!(result.fullblock.block.transactions.len() <= page_size); + let len = result.receipts.len(); + assert!(len <= page_size); assert!(result.fullblock.transaction_count == result.receipts.len()); result.receipts.iter().enumerate().for_each(|(i, receipt)| { let expected = hashes.pop_front(); - assert_eq!(expected, Some(receipt.transaction_hash)); - assert_eq!(expected, Some(result.fullblock.block.transactions[i].hash)); + assert_eq!(expected, receipt.transaction_hash.map(|h| h.to_ethers())); + assert_eq!( + expected.map(|h| h.to_alloy()), + result.fullblock.block.transactions.hashes().nth(i).copied(), + ); }); } @@ -466,7 +493,7 @@ async fn can_call_ots_get_block_transactions() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_search_transactions_before() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let sender = wallet.address(); @@ -483,16 +510,17 @@ async fn can_call_ots_search_transactions_before() { let page_size = 2; let mut block = 0; for _ in 0..4 { - let result = api.ots_search_transactions_before(sender, block, page_size).await.unwrap(); + let result = + api.ots_search_transactions_before(sender.to_alloy(), block, page_size).await.unwrap(); assert!(result.txs.len() <= page_size); // check each individual hash result.txs.iter().for_each(|tx| { - assert_eq!(hashes.pop(), Some(tx.hash)); + assert_eq!(hashes.pop(), Some(tx.hash.to_ethers())); }); - block = result.txs.last().unwrap().block_number.unwrap().as_u64() - 1; + block = result.txs.last().unwrap().block_number.unwrap().to::() - 1; } assert!(hashes.is_empty()); @@ -501,7 +529,7 @@ async fn can_call_ots_search_transactions_before() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_search_transactions_after() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let sender = wallet.address(); @@ -518,16 +546,17 @@ async fn can_call_ots_search_transactions_after() { let page_size = 2; let mut block = 0; for _ in 0..4 { - let result = api.ots_search_transactions_after(sender, block, page_size).await.unwrap(); + let result = + api.ots_search_transactions_after(sender.to_alloy(), block, page_size).await.unwrap(); assert!(result.txs.len() <= page_size); // check each individual hash result.txs.iter().for_each(|tx| { - assert_eq!(hashes.pop_back(), Some(tx.hash)); + assert_eq!(hashes.pop_back(), Some(tx.hash.to_ethers())); }); - block = result.txs.last().unwrap().block_number.unwrap().as_u64() + 1; + block = result.txs.last().unwrap().block_number.unwrap().to::() + 1; } assert!(hashes.is_empty()); @@ -536,7 +565,7 @@ async fn can_call_ots_search_transactions_after() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_transaction_by_sender_and_nonce() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); api.mine_one().await; let wallet = handle.dev_wallets().next().unwrap(); @@ -549,17 +578,23 @@ async fn can_call_ots_get_transaction_by_sender_and_nonce() { let receipt1 = client.send_transaction(tx1, None).await.unwrap().await.unwrap().unwrap(); let receipt2 = client.send_transaction(tx2, None).await.unwrap().await.unwrap().unwrap(); - let result1 = api.ots_get_transaction_by_sender_and_nonce(sender, 0.into()).await.unwrap(); - let result2 = api.ots_get_transaction_by_sender_and_nonce(sender, 1.into()).await.unwrap(); + let result1 = api + .ots_get_transaction_by_sender_and_nonce(sender.to_alloy(), rU256::from(0)) + .await + .unwrap(); + let result2 = api + .ots_get_transaction_by_sender_and_nonce(sender.to_alloy(), rU256::from(1)) + .await + .unwrap(); - assert_eq!(result1.unwrap().hash, receipt1.transaction_hash); - assert_eq!(result2.unwrap().hash, receipt2.transaction_hash); + assert_eq!(result1.unwrap().hash, receipt1.transaction_hash.to_alloy()); + assert_eq!(result2.unwrap().hash, receipt2.transaction_hash.to_alloy()); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_contract_creator() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); api.mine_one().await; let wallet = handle.dev_wallets().next().unwrap(); @@ -573,8 +608,9 @@ async fn can_call_ots_get_contract_creator() { let receipt = client.send_transaction(deploy_tx, None).await.unwrap().await.unwrap().unwrap(); - let creator = api.ots_get_contract_creator(pending_contract_address).await.unwrap().unwrap(); + let creator = + api.ots_get_contract_creator(pending_contract_address.to_alloy()).await.unwrap().unwrap(); - assert_eq!(creator.creator, sender); - assert_eq!(creator.hash, receipt.transaction_hash); + assert_eq!(creator.creator, sender.to_alloy()); + assert_eq!(creator.hash, receipt.transaction_hash.to_alloy()); } diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs index 2e6278bb18266..cbe803fb28179 100644 --- a/crates/anvil/tests/it/proof/mod.rs +++ b/crates/anvil/tests/it/proof/mod.rs @@ -1,17 +1,15 @@ //! tests for `eth_getProof` use crate::proof::eip1186::verify_proof; +use alloy_rpc_types::EIP1186AccountProofResponse; use anvil::{spawn, NodeConfig}; -use anvil_core::eth::{ - proof::{AccountProof, BasicAccount}, - trie::ExtensionLayout, -}; +use anvil_core::eth::{proof::BasicAccount, trie::ExtensionLayout}; use ethers::{ abi::ethereum_types::BigEndianHash, types::{Address, H256, U256}, utils::{keccak256, rlp}, }; -use foundry_common::types::ToEthers; +use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::revm::primitives::KECCAK_EMPTY; mod eip1186; @@ -25,20 +23,23 @@ async fn can_get_proof() { let key = U256::zero(); let value = U256::one(); - api.anvil_set_storage_at(acc, key, H256::from_uint(&value)).await.unwrap(); + api.anvil_set_storage_at(acc.to_alloy(), key.to_alloy(), H256::from_uint(&value).to_alloy()) + .await + .unwrap(); - let proof: AccountProof = api.get_proof(acc, vec![H256::from_uint(&key)], None).await.unwrap(); + let proof: EIP1186AccountProofResponse = + api.get_proof(acc.to_alloy(), vec![H256::from_uint(&key).to_alloy()], None).await.unwrap(); let account = BasicAccount { nonce: 0.into(), balance: 0.into(), - storage_root: proof.storage_hash, + storage_root: proof.storage_hash.to_ethers(), code_hash: KECCAK_EMPTY.to_ethers(), }; let rlp_account = rlp::encode(&account); - let root: H256 = api.state_root().await.unwrap(); + let root: H256 = api.state_root().await.unwrap().to_ethers(); let acc_proof: Vec> = proof .account_proof .into_iter() @@ -58,7 +59,7 @@ async fn can_get_proof() { let proof = proof.storage_proof[0].clone(); let storage_proof: Vec> = proof.proof.into_iter().map(|node| rlp::decode::>(&node).unwrap()).collect(); - let key = H256::from(keccak256(proof.key.as_bytes())); + let key = H256::from(keccak256(proof.key.0 .0)); verify_proof::( &account.storage_root.0, &storage_proof, @@ -74,7 +75,7 @@ async fn can_get_random_account_proofs() { for acc in std::iter::repeat_with(Address::random).take(10) { let _ = api - .get_proof(acc, Vec::new(), None) + .get_proof(acc.to_alloy(), Vec::new(), None) .await .unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}")); } diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index 22df53c968259..31671a53809e1 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -9,6 +9,7 @@ use ethers::{ signers::Signer, types::{Address, Block, Filter, TransactionRequest, TxHash, ValueOrArray, U256}, }; +use foundry_common::types::ToAlloy; use futures::StreamExt; use std::sync::Arc; @@ -16,7 +17,7 @@ use std::sync::Arc; async fn test_sub_new_heads() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let blocks = provider.subscribe_blocks().await.unwrap(); @@ -34,7 +35,7 @@ async fn test_sub_logs_legacy() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -73,7 +74,7 @@ async fn test_sub_logs() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -111,13 +112,13 @@ async fn test_sub_logs_impersonated() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); // impersonate account let impersonate = Address::random(); let funding = U256::from(1e18 as u64); - api.anvil_set_balance(impersonate, funding).await.unwrap(); - api.anvil_impersonate_account(impersonate).await.unwrap(); + api.anvil_set_balance(impersonate.to_alloy(), funding.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -137,7 +138,7 @@ async fn test_sub_logs_impersonated() { let tx = TransactionRequest::new().from(impersonate).to(contract.address()).data(data); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let receipt = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); @@ -152,7 +153,7 @@ async fn test_filters_legacy() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); @@ -193,7 +194,7 @@ async fn test_filters() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); @@ -253,7 +254,7 @@ async fn test_subscriptions() { async fn test_sub_new_heads_fast() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let blocks = provider.subscribe_blocks().await.unwrap(); diff --git a/crates/anvil/tests/it/sign.rs b/crates/anvil/tests/it/sign.rs index 368a34da17633..c802c0ff6e672 100644 --- a/crates/anvil/tests/it/sign.rs +++ b/crates/anvil/tests/it/sign.rs @@ -283,7 +283,7 @@ async fn can_sign_typed_data_os() { #[tokio::test(flavor = "multi_thread")] async fn rejects_different_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = SignerMiddleware::new(provider, wallet.with_chain_id(Chain::Mainnet)); @@ -299,7 +299,7 @@ async fn rejects_different_chain_id() { async fn rejects_invalid_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap().with_chain_id(99u64); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let client = SignerMiddleware::new(provider, wallet); let tx = TransactionRequest::new().to(Address::random()).value(100u64); let res = client.send_transaction(tx, None).await; diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 8a7d1a66ba812..be192fec23eab 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -10,12 +10,13 @@ use ethers::{ utils::hex, }; use ethers_solc::{project_util::TempProject, Artifact}; +use foundry_common::types::ToAlloy; use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn test_get_transfer_parity_traces() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -72,7 +73,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -83,14 +84,15 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), + SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), ); let call = contract.method::<_, ()>("goodbye", ()).unwrap(); let tx = call.send().await.unwrap().await.unwrap().unwrap(); - let traces = handle.http_provider().trace_transaction(tx.transaction_hash).await.unwrap(); + let traces = + handle.ethers_http_provider().trace_transaction(tx.transaction_hash).await.unwrap(); assert!(!traces.is_empty()); - assert_eq!(traces[0].action_type, ActionType::Suicide); + assert_eq!(traces[1].action_type, ActionType::Suicide); } #[tokio::test(flavor = "multi_thread")] @@ -119,7 +121,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallets = handle.dev_wallets().collect::>(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); @@ -130,12 +132,12 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), + SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), ); let call = contract.method::<_, ()>("goodbye", ()).unwrap(); let traces = handle - .http_provider() + .ethers_http_provider() .debug_trace_call(call.tx, None, GethDebugTracingCallOptions::default()) .await .unwrap(); @@ -158,7 +160,7 @@ contract Contract { #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15291050u64))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let input = hex::decode("43bcfab60000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000e0bd811c8769a824b00000000000000000000000000000000000000000000000e0ae9925047d8440b60000000000000000000000002e4777139254ff76db957e284b186a4507ff8c67").unwrap(); @@ -166,7 +168,7 @@ async fn test_trace_address_fork() { let to: Address = "0xe2f2a5c287993345a840db3b0845fbc70f5935a5".parse().unwrap(); let tx = TransactionRequest::new().to(to).from(from).data(input).gas(300_000); - api.anvil_impersonate_account(from).await.unwrap(); + api.anvil_impersonate_account(from.to_alloy()).await.unwrap(); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); @@ -351,7 +353,7 @@ async fn test_trace_address_fork() { #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork2() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15314401u64))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let input = hex::decode("30000003000000000000000000000000adda1059a6c6c102b0fa562b9bb2cb9a0de5b1f4000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a300000004fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000004319b52bf08b65295d49117e790000000000000000000000000000000000000000000000008b6d9e8818d6141f000000000000000000000000000000000000000000000000000000086a23af210000000000000000000000000000000000000000000000000000000000").unwrap(); @@ -359,7 +361,7 @@ async fn test_trace_address_fork2() { let to: Address = "0x99999999d116ffa7d76590de2f427d8e15aeb0b8".parse().unwrap(); let tx = TransactionRequest::new().to(to).from(from).data(input).gas(350_000); - api.anvil_impersonate_account(from).await.unwrap(); + api.anvil_impersonate_account(from.to_alloy()).await.unwrap(); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 7cb5c4bc6e5a8..b93286debd6f5 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -11,6 +11,7 @@ use ethers::{ Address, BlockNumber, Transaction, TransactionReceipt, H256, U256, }, }; +use foundry_common::types::{to_call_request_from_tx_request, ToAlloy, ToEthers}; use futures::{future::join_all, FutureExt, StreamExt}; use std::{collections::HashSet, sync::Arc, time::Duration}; use tokio::time::timeout; @@ -18,7 +19,7 @@ use tokio::time::timeout; #[tokio::test(flavor = "multi_thread")] async fn can_transfer_eth() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -53,7 +54,7 @@ async fn can_transfer_eth() { #[tokio::test(flavor = "multi_thread")] async fn can_order_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // disable automine api.anvil_set_auto_mine(false).await.unwrap(); @@ -87,7 +88,7 @@ async fn can_order_transactions() { #[tokio::test(flavor = "multi_thread")] async fn can_respect_nonces() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -126,7 +127,7 @@ async fn can_replace_transaction() { // disable auto mining api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -164,7 +165,7 @@ async fn can_replace_transaction() { #[tokio::test(flavor = "multi_thread")] async fn can_reject_too_high_gas_limits() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -176,20 +177,21 @@ async fn can_reject_too_high_gas_limits() { let tx = TransactionRequest::new().to(to).value(amount).from(from); // send transaction with the exact gas limit - let pending = provider.send_transaction(tx.clone().gas(gas_limit), None).await; + let pending = provider.send_transaction(tx.clone().gas(gas_limit.to_ethers()), None).await; pending.unwrap(); // send transaction with higher gas limit - let pending = provider.send_transaction(tx.clone().gas(gas_limit + 1u64), None).await; + let pending = + provider.send_transaction(tx.clone().gas(gas_limit.to_ethers() + 1u64), None).await; assert!(pending.is_err()); let err = pending.unwrap_err(); assert!(err.to_string().contains("gas too high")); - api.anvil_set_balance(from, U256::MAX).await.unwrap(); + api.anvil_set_balance(from.to_alloy(), U256::MAX.to_alloy()).await.unwrap(); - let pending = provider.send_transaction(tx.gas(gas_limit), None).await; + let pending = provider.send_transaction(tx.gas(gas_limit.to_ethers()), None).await; pending.unwrap(); } @@ -200,7 +202,7 @@ async fn can_reject_underpriced_replacement() { // disable auto mining api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -235,7 +237,7 @@ async fn can_reject_underpriced_replacement() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_http() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -268,7 +270,7 @@ async fn can_deploy_and_mine_manually() { // can mine in manual mode api.evm_mine(None).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -301,7 +303,7 @@ async fn can_deploy_and_mine_manually() { #[tokio::test(flavor = "multi_thread")] async fn can_mine_automatically() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); @@ -322,7 +324,7 @@ async fn can_mine_automatically() { #[tokio::test(flavor = "multi_thread")] async fn can_call_greeter_historic() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -357,7 +359,7 @@ async fn can_call_greeter_historic() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_ws() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -382,7 +384,7 @@ async fn can_deploy_greeter_ws() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_get_code() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -401,7 +403,7 @@ async fn can_deploy_get_code() { #[tokio::test(flavor = "multi_thread")] async fn get_blocktimestamp_works() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -413,14 +415,15 @@ async fn get_blocktimestamp_works() { assert!(timestamp > U256::one()); - let latest_block = api.block_by_number(BlockNumber::Latest).await.unwrap().unwrap(); + let latest_block = + api.block_by_number(alloy_rpc_types::BlockNumberOrTag::Latest).await.unwrap().unwrap(); let timestamp = contract.get_current_block_timestamp().call().await.unwrap(); - assert_eq!(timestamp, latest_block.timestamp); + assert_eq!(timestamp, latest_block.header.timestamp.to_ethers()); // repeat call same result let timestamp = contract.get_current_block_timestamp().call().await.unwrap(); - assert_eq!(timestamp, latest_block.timestamp); + assert_eq!(timestamp, latest_block.header.timestamp.to_ethers()); // mock timestamp let next_timestamp = timestamp.as_u64() + 1337; @@ -439,7 +442,7 @@ async fn get_blocktimestamp_works() { #[tokio::test(flavor = "multi_thread")] async fn call_past_state() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -496,7 +499,7 @@ async fn call_past_state() { async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -526,7 +529,7 @@ async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); @@ -560,7 +563,7 @@ async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); @@ -619,7 +622,7 @@ async fn can_get_pending_transaction() { // disable auto mining so we can check if we can return pending tx from the mempool api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let from = handle.dev_wallets().next().unwrap().address(); let tx = TransactionRequest::new().from(from).value(1337u64).to(Address::random()); @@ -640,7 +643,7 @@ async fn test_first_noce_is_zero() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let from = handle.dev_wallets().next().unwrap().address(); let nonce = provider @@ -657,7 +660,7 @@ async fn can_handle_different_sender_nonce_calculation() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from_first = accounts[0].address(); let from_second = accounts[1].address(); @@ -692,7 +695,7 @@ async fn includes_pending_tx_for_transaction_count() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let from = handle.dev_wallets().next().unwrap().address(); let tx_count = 10u64; @@ -719,7 +722,7 @@ async fn includes_pending_tx_for_transaction_count() { #[tokio::test(flavor = "multi_thread")] async fn can_get_historic_info() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -756,7 +759,7 @@ async fn test_tx_receipt() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); - let client = Arc::new(SignerMiddleware::new(handle.http_provider(), wallet)); + let client = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet)); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); @@ -777,8 +780,8 @@ async fn can_stream_pending_transactions() { let (_api, handle) = spawn(NodeConfig::test().with_blocktime(Some(Duration::from_secs(2)))).await; let num_txs = 5; - let provider = handle.http_provider(); - let ws_provider = handle.ws_provider(); + let provider = handle.ethers_http_provider(); + let ws_provider = handle.ethers_ws_provider(); let accounts = provider.get_accounts().await.unwrap(); let tx = TransactionRequest::new().from(accounts[0]).to(accounts[0]).value(1e18 as u64); @@ -861,7 +864,7 @@ async fn test_tx_access_list() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); - let client = Arc::new(SignerMiddleware::new(handle.http_provider(), wallet)); + let client = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet)); let sender = Address::random(); let other_acc = Address::random(); @@ -930,7 +933,7 @@ async fn estimates_gas_on_pending_by_default() { // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let sender = wallet.address(); @@ -943,13 +946,13 @@ async fn estimates_gas_on_pending_by_default() { let tx = TransactionRequest::new().from(recipient).to(sender).value(1e10 as u64).data(vec![0x42]); - api.estimate_gas(tx.into(), None).await.unwrap(); + api.estimate_gas(to_call_request_from_tx_request(tx), None).await.unwrap(); } #[tokio::test(flavor = "multi_thread")] async fn test_reject_gas_too_low() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let account = handle.dev_accounts().next().unwrap(); @@ -970,8 +973,8 @@ async fn test_reject_gas_too_low() { #[tokio::test(flavor = "multi_thread")] async fn can_call_with_high_gas_limit() { let (_api, handle) = - spawn(NodeConfig::test().with_gas_limit(Some(U256::from(100_000_000)))).await; - let provider = handle.http_provider(); + spawn(NodeConfig::test().with_gas_limit(Some(U256::from(100_000_000).to_alloy()))).await; + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -989,7 +992,7 @@ async fn can_call_with_high_gas_limit() { #[tokio::test(flavor = "multi_thread")] async fn test_reject_eip1559_pre_london() { let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); let wallet = handle.dev_wallets().next().unwrap(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -998,8 +1001,8 @@ async fn test_reject_eip1559_pre_london() { let gas_price = api.gas_price().unwrap(); let unsupported = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) .unwrap() - .gas(gas_limit) - .gas_price(gas_price) + .gas(gas_limit.to_ethers()) + .gas_price(gas_price.to_ethers()) .send() .await .unwrap_err() diff --git a/crates/anvil/tests/it/txpool.rs b/crates/anvil/tests/it/txpool.rs index ea0f6b4d246af..3f17e5beeaac0 100644 --- a/crates/anvil/tests/it/txpool.rs +++ b/crates/anvil/tests/it/txpool.rs @@ -9,7 +9,7 @@ use ethers::{ #[tokio::test(flavor = "multi_thread")] async fn geth_txpool() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); + let provider = handle.ethers_http_provider(); api.anvil_set_auto_mine(false).await.unwrap(); let account = provider.get_accounts().await.unwrap()[0]; diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index f185c6b8ee241..f1212bd410e50 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -2,23 +2,24 @@ use anvil::{spawn, NodeConfig}; use ethers::{prelude::Middleware, types::U256}; +use foundry_common::types::ToAlloy; #[tokio::test(flavor = "multi_thread")] async fn can_get_block_number_ws() { let (api, handle) = spawn(NodeConfig::test()).await; let block_num = api.block_number().unwrap(); - assert_eq!(block_num, U256::zero()); + assert_eq!(block_num, U256::zero().to_alloy()); - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num, block_num.as_u64().into()); + assert_eq!(num, block_num.to::().into()); } #[tokio::test(flavor = "multi_thread")] async fn can_dev_get_balance_ws() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); + let provider = handle.ethers_ws_provider(); let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 8217eeb9e1edc..29c0d5f82061e 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -165,9 +165,9 @@ impl CallArgs { Err(evm_err) => TraceResult::try_from(evm_err)?, }; - handle_traces(trace, &config, chain, labels, verbose, debug).await?; + handle_traces(trace, &config, chain, labels, verbose).await?; - return Ok(()) + return Ok(()); } // fill the builder after the conditional so we dont move values @@ -199,9 +199,9 @@ impl CallArgs { tx.value().copied().unwrap_or_default().to_alloy(), )?); - handle_traces(trace, &config, chain, labels, verbose, debug).await?; + handle_traces(trace, &config, chain, labels, verbose).await?; - return Ok(()) + return Ok(()); } } }; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 535dc3b46a7b4..8f13706e647b8 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -104,7 +104,7 @@ impl RunArgs { return Err(eyre::eyre!( "{:?} is a system transaction.\nReplaying system transactions is currently not supported.", tx.hash - )) + )); } let tx_block_number = tx @@ -148,13 +148,13 @@ impl RunArgs { Some(SYSTEM_TRANSACTION_TYPE) { update_progress!(pb, index); - continue + continue; } if tx.hash == tx_hash { - break + break; } - configure_tx_env(&mut env, &tx); + configure_tx_env(&mut env, &tx.clone().to_alloy()); if let Some(to) = tx.to { trace!(tx=?tx.hash,?to, "executing previous call transaction"); @@ -191,7 +191,7 @@ impl RunArgs { let result = { executor.set_trace_printer(self.trace_printer); - configure_tx_env(&mut env, &tx); + configure_tx_env(&mut env, &tx.clone().to_alloy()); if let Some(to) = tx.to { trace!(tx=?tx.hash, to=?to, "executing call transaction"); @@ -205,7 +205,7 @@ impl RunArgs { } }; - handle_traces(result, &config, chain, self.label, self.verbose, self.debug).await?; + handle_traces(result, &config, chain, self.label, self.debug).await?; Ok(()) } diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index da9451ccc8eff..b91258c86664a 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -14,8 +14,8 @@ use foundry_cli::{ use foundry_common::{ abi::find_source, compile::{etherscan_project, ProjectCompiler}, + provider::ethers::RetryProvider, types::{ToAlloy, ToEthers}, - RetryProvider, }; use foundry_compilers::{artifacts::StorageLayout, ConfigurableContractArtifact, Project, Solc}; use foundry_config::{ @@ -85,7 +85,7 @@ impl StorageArgs { if let Some(slot) = slot { let cast = Cast::new(provider); println!("{}", cast.storage(address, slot.to_ethers(), block).await?); - return Ok(()) + return Ok(()); } // No slot was provided @@ -109,7 +109,7 @@ impl StorageArgs { let artifact = out.artifacts().find(|(_, artifact)| match_code(artifact).unwrap_or_default()); if let Some((_, artifact)) = artifact { - return fetch_and_print_storage(provider, address.clone(), artifact, true).await + return fetch_and_print_storage(provider, address.clone(), artifact, true).await; } } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 00f2790b1614c..9eb81c4ce5678 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1,15 +1,15 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; use alloy_json_abi::ContractObject; -use alloy_primitives::{Address, I256, U256}; +use alloy_primitives::{ + utils::{keccak256, ParseUnits, Unit}, + Address, I256, U256, +}; use alloy_rlp::Decodable; use base::{Base, NumberWithBase, ToBase}; use chrono::NaiveDateTime; use ethers_core::{ types::{transaction::eip2718::TypedTransaction, *}, - utils::{ - format_bytes32_string, format_units, keccak256, parse_bytes32_string, parse_units, rlp, - Units, - }, + utils::rlp, }; use ethers_providers::{Middleware, PendingTransaction, PubsubClient}; use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; @@ -1079,13 +1079,14 @@ impl SimpleCast { /// # Ok::<_, eyre::Report>(()) /// ``` pub fn from_fixed_point(value: &str, decimals: &str) -> Result { - // first try u32 as Units assumes a string can only be "ether", "gwei"... and not a number - let units = match decimals.parse::() { - Ok(d) => Units::Other(d), - Err(_) => Units::try_from(decimals)?, + // TODO: https://github.com/alloy-rs/core/pull/461 + let units: Unit = if let Ok(x) = decimals.parse() { + Unit::new(x).ok_or_else(|| eyre::eyre!("invalid unit"))? + } else { + decimals.parse()? }; - let n: NumberWithBase = parse_units(value, units.as_num())?.into(); - Ok(format!("{n}")) + let n = ParseUnits::parse_units(value, units)?; + Ok(n.to_string()) } /// Converts integers with specified decimals into fixed point numbers @@ -1234,7 +1235,6 @@ impl SimpleCast { /// assert_eq!(Cast::to_unit("1 wei", "wei")?, "1"); /// assert_eq!(Cast::to_unit("1", "wei")?, "1"); /// assert_eq!(Cast::to_unit("1ether", "wei")?, "1000000000000000000"); - /// assert_eq!(Cast::to_unit("100 gwei", "gwei")?, "100"); /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_unit(value: &str, unit: &str) -> Result { @@ -1242,31 +1242,18 @@ impl SimpleCast { .as_uint() .wrap_err("Could not convert to uint")? .0; - - Ok(match unit { - "eth" | "ether" => foundry_common::units::format_units(value, 18)? - .trim_end_matches(".000000000000000000") - .to_string(), - "milli" | "milliether" => foundry_common::units::format_units(value, 15)? - .trim_end_matches(".000000000000000") - .to_string(), - "micro" | "microether" => foundry_common::units::format_units(value, 12)? - .trim_end_matches(".000000000000") - .to_string(), - "gwei" | "nano" | "nanoether" => foundry_common::units::format_units(value, 9)? - .trim_end_matches(".000000000") - .to_string(), - "mwei" | "mega" | "megaether" => foundry_common::units::format_units(value, 6)? - .trim_end_matches(".000000") - .to_string(), - "kwei" | "kilo" | "kiloether" => { - foundry_common::units::format_units(value, 3)?.trim_end_matches(".000").to_string() - } - "wei" => { - foundry_common::units::format_units(value, 0)?.trim_end_matches(".0").to_string() + let unit = unit.parse().wrap_err("could not parse units")?; + let mut formatted = ParseUnits::U256(value).format_units(unit); + + // Trim empty fractional part. + if let Some(dot) = formatted.find('.') { + let fractional = &formatted[dot + 1..]; + if fractional.chars().all(|c: char| c == '0') { + formatted = formatted[..dot].to_string(); } - _ => eyre::bail!("invalid unit: \"{}\"", unit), - }) + } + + Ok(formatted) } /// Converts wei into an eth amount @@ -1280,15 +1267,12 @@ impl SimpleCast { /// assert_eq!(Cast::from_wei("12340000005", "gwei")?, "12.340000005"); /// assert_eq!(Cast::from_wei("10", "ether")?, "0.000000000000000010"); /// assert_eq!(Cast::from_wei("100", "eth")?, "0.000000000000000100"); - /// assert_eq!(Cast::from_wei("17", "")?, "0.000000000000000017"); + /// assert_eq!(Cast::from_wei("17", "ether")?, "0.000000000000000017"); /// # Ok::<_, eyre::Report>(()) /// ``` pub fn from_wei(value: &str, unit: &str) -> Result { - let value = NumberWithBase::parse_int(value, None)?.number().to_ethers(); - Ok(match unit { - "gwei" => format_units(value, 9), - _ => format_units(value, 18), - }?) + let value = NumberWithBase::parse_int(value, None)?.number(); + Ok(ParseUnits::U256(value).format_units(unit.parse()?)) } /// Converts an eth amount into wei @@ -1298,18 +1282,14 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// assert_eq!(Cast::to_wei("1", "")?, "1000000000000000000"); /// assert_eq!(Cast::to_wei("100", "gwei")?, "100000000000"); /// assert_eq!(Cast::to_wei("100", "eth")?, "100000000000000000000"); /// assert_eq!(Cast::to_wei("1000", "ether")?, "1000000000000000000000"); /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_wei(value: &str, unit: &str) -> Result { - let wei = match unit { - "gwei" => parse_units(value, 9), - _ => parse_units(value, 18), - }?; - Ok(wei.to_string()) + let unit = unit.parse().wrap_err("could not parse units")?; + Ok(ParseUnits::parse_units(value, unit)?.to_string()) } /// Decodes rlp encoded list with hex data @@ -1423,21 +1403,20 @@ impl SimpleCast { /// Encodes string into bytes32 value pub fn format_bytes32_string(s: &str) -> Result { - let formatted = format_bytes32_string(s)?; - Ok(hex::encode_prefixed(formatted)) + let str_bytes: &[u8] = s.as_bytes(); + eyre::ensure!(str_bytes.len() <= 32, "bytes32 strings must not exceed 32 bytes in length"); + + let mut bytes32: [u8; 32] = [0u8; 32]; + bytes32[..str_bytes.len()].copy_from_slice(str_bytes); + Ok(hex::encode_prefixed(bytes32)) } /// Decodes string from bytes32 value pub fn parse_bytes32_string(s: &str) -> Result { let bytes = hex::decode(s)?; - if bytes.len() != 32 { - eyre::bail!("expected 64 byte hex-string, got {}", strip_0x(s)); - } - - let mut buffer = [0u8; 32]; - buffer.copy_from_slice(&bytes); - - Ok(parse_bytes32_string(&buffer)?.to_owned()) + eyre::ensure!(bytes.len() == 32, "expected 32 byte hex-string"); + let len = bytes.iter().take_while(|x| **x != 0).count(); + Ok(std::str::from_utf8(&bytes[..len])?.into()) } /// Decodes checksummed address from bytes32 value @@ -1739,14 +1718,10 @@ impl SimpleCast { /// # Ok::<_, eyre::Report>(()) /// ``` pub fn keccak(data: &str) -> Result { - let hash = match data.as_bytes() { - // 0x prefix => read as hex data - [b'0', b'x', rest @ ..] => keccak256(hex::decode(rest)?), - // No 0x prefix => read as text - _ => keccak256(data), - }; - - Ok(format!("{:?}", H256(hash))) + // Hex-decode if data starts with 0x. + let hash = + if data.starts_with("0x") { keccak256(hex::decode(data)?) } else { keccak256(data) }; + Ok(hash.to_string()) } /// Performs the left shift operation (<<) on a number diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index d4b87891b3fa5..bb000f5c3198d 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -22,9 +22,10 @@ alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-sol-types.workspace = true +alloy-providers.workspace = true +alloy-rpc-types.workspace = true ethers-core.workspace = true -ethers-providers.workspace = true ethers-signers.workspace = true eyre.workspace = true diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 57683a76003b5..436dd1c6284ed 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,12 +1,10 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::B256; +use alloy_primitives::{B256, U256}; +use alloy_providers::provider::TempProvider; +use alloy_rpc_types::Filter; use alloy_sol_types::SolValue; -use ethers_core::types::Filter; -use ethers_providers::Middleware; -use foundry_common::{ - types::{ToAlloy, ToEthers}, - ProviderBuilder, -}; +use eyre::WrapErr; +use foundry_common::{provider::alloy::ProviderBuilder, types::ToEthers}; use foundry_compilers::utils::RuntimeOrHandle; use foundry_evm_core::fork::CreateFork; @@ -224,10 +222,10 @@ impl Cheatcode for rpcCall { let url = ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; - + let method: &'static str = Box::new(method.clone()).leak(); let params_json: serde_json::Value = serde_json::from_str(params)?; let result = RuntimeOrHandle::new() - .block_on(provider.request(method, params_json)) + .block_on(provider.raw_request(method, params_json)) .map_err(|err| fmt_err!("{method:?}: {err}"))?; let result_as_tokens = crate::json::value_to_token(&result) @@ -252,35 +250,39 @@ impl Cheatcode for eth_getLogsCall { let url = ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; - let mut filter = - Filter::new().address(target.to_ethers()).from_block(from_block).to_block(to_block); + let mut filter = Filter::new().address(*target).from_block(from_block).to_block(to_block); for (i, topic) in topics.iter().enumerate() { let topic = topic.to_ethers(); + // todo: needed because rust wants to convert FixedBytes<32> to U256 to convert it back + // to FixedBytes<32> and then to Topic for some reason removing the + // From impl in alloy does not fix the situation, and it is not possible to impl + // From> either because of a conflicting impl match i { - 0 => filter = filter.topic0(topic), - 1 => filter = filter.topic1(topic), - 2 => filter = filter.topic2(topic), - 3 => filter = filter.topic3(topic), + 0 => filter = filter.event_signature(U256::from_be_bytes(topic.to_fixed_bytes())), + 1 => filter = filter.topic1(U256::from_be_bytes(topic.to_fixed_bytes())), + 2 => filter = filter.topic2(U256::from_be_bytes(topic.to_fixed_bytes())), + 3 => filter = filter.topic3(U256::from_be_bytes(topic.to_fixed_bytes())), _ => unreachable!(), }; } + // todo: handle the errors somehow let logs = RuntimeOrHandle::new() - .block_on(provider.get_logs(&filter)) - .map_err(|e| fmt_err!("eth_getLogs: {e}"))?; + .block_on(provider.get_logs(filter)) + .wrap_err("failed to get logs")?; let eth_logs = logs .into_iter() .map(|log| EthGetLogs { - emitter: log.address.to_alloy(), - topics: log.topics.into_iter().map(ToAlloy::to_alloy).collect(), + emitter: log.address, + topics: log.topics.into_iter().collect(), data: log.data.0.into(), - blockHash: log.block_hash.unwrap_or_default().to_alloy(), - blockNumber: log.block_number.unwrap_or_default().to_alloy().to(), - transactionHash: log.transaction_hash.unwrap_or_default().to_alloy(), - transactionIndex: log.transaction_index.unwrap_or_default().to_alloy().to(), - logIndex: log.log_index.unwrap_or_default().to_alloy(), - removed: log.removed.unwrap_or(false), + blockHash: log.block_hash.unwrap_or_default(), + blockNumber: log.block_number.unwrap_or_default().to(), + transactionHash: log.transaction_hash.unwrap_or_default(), + transactionIndex: log.transaction_index.unwrap_or_default().to(), + logIndex: log.log_index.unwrap_or_default(), + removed: log.removed, }) .collect::>(); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index ffe224855543a..eae7af5f2c147 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -19,7 +19,7 @@ use ethers_core::types::{ transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest, }; use ethers_signers::LocalWallet; -use foundry_common::{evm::Breakpoints, types::ToEthers, RpcUrl}; +use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, types::ToEthers}; use foundry_evm_core::{ backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP}, diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 1344690fc8d4a..8cd552baee7d6 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -15,7 +15,7 @@ use foundry_evm::{ decode::decode_console_logs, traces::{ identifier::{EtherscanIdentifier, SignaturesIdentifier}, - CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, + render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, }; use once_cell::sync::Lazy; @@ -990,11 +990,10 @@ impl ChiselDispatcher { } println!("{}", Paint::green("Traces:")); - for (kind, trace) in &mut result.traces { + for (kind, trace) in &result.traces { // Display all Setup + Execution traces. if matches!(kind, TraceKind::Setup | TraceKind::Execution) { - decoder.decode(trace).await; - println!("{trace}"); + println!("{}", render_trace_arena(trace, decoder).await?); } } diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 286cc937c9948..2127ddc4de90b 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -168,7 +168,7 @@ impl ChiselRunner { { // update the gas gas_used = highest_gas_limit; - break + break; } last_highest_gas_limit = highest_gas_limit; } @@ -203,8 +203,7 @@ impl ChiselRunner { traces: traces .map(|traces| { // Manually adjust gas for the trace to add back the stipend/real used gas - // TODO: For chisel, we may not want to perform this adjustment. - // traces.arena[0].trace.gas_cost = gas_used; + vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index 71baf28f529d4..e6d22ff5826a5 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -6,7 +6,7 @@ use ethers_signers::{ AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, Signer, Trezor, TrezorHDPath, }; use eyre::{Context, ContextCompat, Result}; -use foundry_common::{types::ToAlloy, RetryProvider}; +use foundry_common::{provider::ethers::RetryProvider, types::ToAlloy}; use foundry_config::Config; use itertools::izip; use rusoto_core::{ @@ -239,7 +239,7 @@ impl MultiWallet { local_wallets.insert(address.to_alloy(), signer); if addresses.is_empty() { - return Ok(local_wallets) + return Ok(local_wallets); } } else { // Just to show on error. @@ -270,7 +270,7 @@ impl MultiWallet { for _ in 0..self.interactives { wallets.push(self.get_from_interactive()?); } - return Ok(Some(wallets)) + return Ok(Some(wallets)); } Ok(None) } @@ -281,7 +281,7 @@ impl MultiWallet { for private_key in private_keys.iter() { wallets.push(self.get_from_private_key(private_key.trim())?); } - return Ok(Some(wallets)) + return Ok(Some(wallets)); } Ok(None) } @@ -317,7 +317,7 @@ impl MultiWallet { let wallet = self.get_from_keystore(Some(&path), passwords_iter.next().as_ref(), password_files_iter.next().as_ref())?.wrap_err("Keystore paths do not have the same length as provided passwords or password files.")?; wallets.push(wallet); } - return Ok(Some(wallets)) + return Ok(Some(wallets)); } Ok(None) } @@ -352,7 +352,7 @@ impl MultiWallet { mnemonic_index, )?) } - return Ok(Some(wallets)) + return Ok(Some(wallets)); } Ok(None) } @@ -369,7 +369,7 @@ impl MultiWallet { } create_hw_wallets!(args, chain_id, get_from_ledger, wallets); - return Ok(Some(wallets)) + return Ok(Some(wallets)); } Ok(None) } @@ -377,7 +377,7 @@ impl MultiWallet { pub async fn trezors(&self, chain_id: u64) -> Result>> { if self.trezor { create_hw_wallets!(self, chain_id, get_from_trezor, wallets); - return Ok(Some(wallets)) + return Ok(Some(wallets)); } Ok(None) } @@ -399,7 +399,7 @@ impl MultiWallet { wallets.push(aws_signer) } - return Ok(Some(wallets)) + return Ok(Some(wallets)); } Ok(None) } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 6d100cb15d089..4c226cf1b5199 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -17,7 +17,7 @@ use foundry_evm::{ opts::EvmOpts, traces::{ identifier::{EtherscanIdentifier, SignaturesIdentifier}, - CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, + render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, }; use std::{fmt::Write, path::PathBuf, str::FromStr}; @@ -93,7 +93,7 @@ pub fn get_cached_entry_by_name( } if let Some(entry) = cached_entry { - return Ok(entry) + return Ok(entry); } let mut err = format!("could not find artifact: `{name}`"); @@ -175,7 +175,7 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { NamedChain::Moonriver | NamedChain::Moonbase | NamedChain::MoonbeamDev - ) + ); } false } @@ -189,7 +189,7 @@ pub fn has_batch_support(chain_id: u64) -> bool { NamedChain::ArbitrumTestnet | NamedChain::ArbitrumGoerli | NamedChain::ArbitrumSepolia - ) + ); } true } @@ -374,7 +374,6 @@ pub async fn handle_traces( config: &Config, chain: Option, labels: Vec, - verbose: bool, debug: bool, ) -> Result<()> { let mut etherscan_identifier = EtherscanIdentifier::new(config, chain)?; @@ -384,7 +383,7 @@ pub async fn handle_traces( if let Some(addr) = iter.next() { if let (Ok(address), Some(label)) = (Address::from_str(addr), iter.next()) { - return Some((address, label.to_string())) + return Some((address, label.to_string())); } } None @@ -415,29 +414,20 @@ pub async fn handle_traces( .build(); debugger.try_run()?; } else { - print_traces(&mut result, &decoder, verbose).await?; + print_traces(&mut result, &decoder).await?; } Ok(()) } -pub async fn print_traces( - result: &mut TraceResult, - decoder: &CallTraceDecoder, - verbose: bool, -) -> Result<()> { +pub async fn print_traces(result: &mut TraceResult, decoder: &CallTraceDecoder) -> Result<()> { if result.traces.is_empty() { panic!("No traces found") } println!("Traces:"); - for (_, trace) in &mut result.traces { - decoder.decode(trace).await; - if !verbose { - println!("{trace}"); - } else { - println!("{trace:#}"); - } + for (_, arena) in &result.traces { + println!("{}", render_trace_arena(arena, decoder).await?); } println!(); diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 425732de95e6c..f900c50b071d4 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -1,9 +1,9 @@ use alloy_json_abi::JsonAbi; -use alloy_primitives::U256; +use alloy_primitives::{utils::format_units, U256}; use ethers_core::types::TransactionReceipt; use ethers_providers::Middleware; use eyre::{ContextCompat, Result}; -use foundry_common::{types::ToAlloy, units::format_units}; +use foundry_common::types::ToAlloy; use foundry_config::{Chain, Config}; use std::{ ffi::OsStr, @@ -85,7 +85,7 @@ pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { /// and chain. /// /// Defaults to `http://localhost:8545` and `Mainnet`. -pub fn get_provider(config: &Config) -> Result { +pub fn get_provider(config: &Config) -> Result { get_provider_builder(config)?.build() } @@ -93,9 +93,11 @@ pub fn get_provider(config: &Config) -> Result { /// URL and chain. /// /// Defaults to `http://localhost:8545` and `Mainnet`. -pub fn get_provider_builder(config: &Config) -> Result { +pub fn get_provider_builder( + config: &Config, +) -> Result { let url = config.get_rpc_url_or_localhost_http()?; - let mut builder = foundry_common::ProviderBuilder::new(url.as_ref()); + let mut builder = foundry_common::provider::ethers::ProviderBuilder::new(url.as_ref()); if let Ok(chain) = config.chain.unwrap_or_default().try_into() { builder = builder.chain(chain); @@ -475,7 +477,7 @@ impl<'a> Git<'a> { output.status.code(), stdout.trim(), stderr.trim() - )) + )); } } Ok(()) diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index d6f11bcf5d584..a7def0f5c6c75 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -21,8 +21,19 @@ ethers-providers = { workspace = true, features = ["ws", "ipc"] } alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-rpc-types.workspace = true +alloy-rpc-client.workspace = true +alloy-providers.workspace = true +alloy-transport.workspace = true +alloy-transport-http.workspace = true +alloy-transport-ws.workspace = true +alloy-transport-ipc.workspace = true +alloy-json-rpc.workspace = true +alloy-pubsub.workspace = true alloy-sol-types.workspace = true +tower.workspace = true + async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index df3742dd84b80..f0dd60e020fc4 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -246,10 +246,10 @@ impl ProjectCompiler { let dev_functions = artifact.abi.as_ref().map(|abi| abi.functions()).into_iter().flatten().filter( - |&func| { + |func| { func.name.is_test() || - func.name == "IS_TEST" || - func.name == "IS_SCRIPT" + func.name.eq("IS_TEST") || + func.name.eq("IS_SCRIPT") }, ); diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 3e7e6ecbd775f..c2825ac2f9977 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -22,15 +22,14 @@ pub mod retry; pub mod rpc; pub mod runtime_client; pub mod selectors; +pub mod serde_helpers; pub mod shell; pub mod term; pub mod traits; pub mod transactions; pub mod types; -pub mod units; pub use constants::*; pub use contracts::*; -pub use provider::*; pub use traits::*; pub use transactions::*; diff --git a/crates/common/src/provider/alloy.rs b/crates/common/src/provider/alloy.rs new file mode 100644 index 0000000000000..bb52778145e9f --- /dev/null +++ b/crates/common/src/provider/alloy.rs @@ -0,0 +1,318 @@ +//! Commonly used helpers to construct `Provider`s + +use crate::{ + provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, +}; +use alloy_primitives::U256; +use alloy_providers::provider::{Provider, TempProvider}; +use alloy_rpc_client::ClientBuilder; +use alloy_transport::BoxTransport; +use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; +use eyre::{Result, WrapErr}; +use foundry_common::types::ToAlloy; +use foundry_config::NamedChain; +use reqwest::Url; +use std::{ + path::{Path, PathBuf}, + time::Duration, +}; +use url::ParseError; + +use super::tower::RetryBackoffLayer; + +/// Helper type alias for a retry provider +pub type RetryProvider = Provider; + +/// Helper type alias for a rpc url +pub type RpcUrl = String; + +/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely +/// an anvil or other dev node) and with the default, or 7 second otherwise. +/// +/// See [`try_get_http_provider`] for more details. +/// +/// # Panics +/// +/// Panics if the URL is invalid. +/// +/// # Examples +/// +/// ``` +/// use foundry_common::provider::alloy::get_http_provider; +/// +/// let retry_provider = get_http_provider("http://localhost:8545"); +/// ``` +#[inline] +#[track_caller] +pub fn get_http_provider(builder: impl AsRef) -> RetryProvider { + try_get_http_provider(builder).unwrap() +} + +/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely +/// an anvil or other dev node) and with the default, or 7 second otherwise. +#[inline] +pub fn try_get_http_provider(builder: impl AsRef) -> Result { + ProviderBuilder::new(builder.as_ref()).build() +} + +/// Helper type to construct a `RetryProvider` +#[derive(Debug)] +pub struct ProviderBuilder { + // Note: this is a result, so we can easily chain builder calls + url: Result, + chain: NamedChain, + max_retry: u32, + timeout_retry: u32, + initial_backoff: u64, + timeout: Duration, + /// available CUPS + compute_units_per_second: u64, + /// JWT Secret + jwt: Option, + headers: Vec, +} + +// === impl ProviderBuilder === + +impl ProviderBuilder { + /// Creates a new builder instance + pub fn new(url_str: &str) -> Self { + // a copy is needed for the next lines to work + let mut url_str = url_str; + + // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http + // prefix + let storage; + if url_str.starts_with("localhost:") { + storage = format!("http://{url_str}"); + url_str = storage.as_str(); + } + + let url = Url::parse(url_str) + .or_else(|err| match err { + ParseError::RelativeUrlWithoutBase => { + let path = Path::new(url_str); + + if let Ok(path) = resolve_path(path) { + Url::parse(&format!("file://{}", path.display())) + } else { + Err(err) + } + } + _ => Err(err), + }) + .wrap_err_with(|| format!("invalid provider URL: {url_str:?}")); + + Self { + url, + chain: NamedChain::Mainnet, + max_retry: 8, + timeout_retry: 8, + initial_backoff: 800, + timeout: REQUEST_TIMEOUT, + // alchemy max cpus + compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, + jwt: None, + headers: vec![], + } + } + + /// Enables a request timeout. + /// + /// The timeout is applied from when the request starts connecting until the + /// response body has finished. + /// + /// Default is no timeout. + pub fn timeout(mut self, timeout: Duration) -> Self { + self.timeout = timeout; + self + } + + /// Sets the chain of the node the provider will connect to + pub fn chain(mut self, chain: NamedChain) -> Self { + self.chain = chain; + self + } + + /// How often to retry a failed request + pub fn max_retry(mut self, max_retry: u32) -> Self { + self.max_retry = max_retry; + self + } + + /// How often to retry a failed request. If `None`, defaults to the already-set value. + pub fn maybe_max_retry(mut self, max_retry: Option) -> Self { + self.max_retry = max_retry.unwrap_or(self.max_retry); + self + } + + /// The starting backoff delay to use after the first failed request. If `None`, defaults to + /// the already-set value. + pub fn maybe_initial_backoff(mut self, initial_backoff: Option) -> Self { + self.initial_backoff = initial_backoff.unwrap_or(self.initial_backoff); + self + } + + /// How often to retry a failed request due to connection issues + pub fn timeout_retry(mut self, timeout_retry: u32) -> Self { + self.timeout_retry = timeout_retry; + self + } + + /// The starting backoff delay to use after the first failed request + pub fn initial_backoff(mut self, initial_backoff: u64) -> Self { + self.initial_backoff = initial_backoff; + self + } + + /// Sets the number of assumed available compute units per second + /// + /// See also, + pub fn compute_units_per_second(mut self, compute_units_per_second: u64) -> Self { + self.compute_units_per_second = compute_units_per_second; + self + } + + /// Sets the number of assumed available compute units per second + /// + /// See also, + pub fn compute_units_per_second_opt(mut self, compute_units_per_second: Option) -> Self { + if let Some(cups) = compute_units_per_second { + self.compute_units_per_second = cups; + } + self + } + + /// Sets aggressive `max_retry` and `initial_backoff` values + /// + /// This is only recommend for local dev nodes + pub fn aggressive(self) -> Self { + self.max_retry(100).initial_backoff(100) + } + + /// Sets the JWT secret + pub fn jwt(mut self, jwt: impl Into) -> Self { + self.jwt = Some(jwt.into()); + self + } + + /// Sets http headers + pub fn headers(mut self, headers: Vec) -> Self { + self.headers = headers; + + self + } + + /// Same as [`Self:build()`] but also retrieves the `chainId` in order to derive an appropriate + /// interval. + pub async fn connect(self) -> Result { + let provider = self.build()?; + // todo: port poll interval hint + /*if let Some(blocktime) = provider.get_chainid().await.ok().and_then(|id| { + }) { + provider = provider.interval(blocktime / 2); + }*/ + Ok(provider) + } + + /// Constructs the `RetryProvider` taking all configs into account. + pub fn build(self) -> Result { + let ProviderBuilder { + url, + chain: _, + max_retry, + timeout_retry, + initial_backoff, + timeout, + compute_units_per_second, + jwt, + headers, + } = self; + let url = url?; + + let retry_layer = RetryBackoffLayer::new( + max_retry, + timeout_retry, + initial_backoff, + compute_units_per_second, + ); + let transport = RuntimeTransportBuilder::new(url.clone()) + .with_timeout(timeout) + .with_headers(headers) + .with_jwt(jwt) + .build(); + let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); + + // todo: provider polling interval + Ok(Provider::new_with_client(client.boxed())) + } +} + +/// Estimates EIP1559 fees depending on the chain +/// +/// Uses custom gas oracles for +/// - polygon +/// +/// Fallback is the default [`Provider::estimate_eip1559_fees`] implementation +pub async fn estimate_eip1559_fees( + provider: &P, + chain: Option, +) -> Result<(U256, U256)> { + let chain = if let Some(chain) = chain { + chain + } else { + provider.get_chain_id().await.wrap_err("Failed to get chain id")?.to() + }; + + if let Ok(chain) = NamedChain::try_from(chain) { + // handle chains that deviate from `eth_feeHistory` and have their own oracle + match chain { + NamedChain::Polygon | NamedChain::PolygonMumbai => { + // TODO: phase this out somehow + let chain = match chain { + NamedChain::Polygon => ethers_core::types::Chain::Polygon, + NamedChain::PolygonMumbai => ethers_core::types::Chain::PolygonMumbai, + _ => unreachable!(), + }; + let estimator = Polygon::new(chain)?.category(GasCategory::Standard); + let (a, b) = estimator.estimate_eip1559_fees().await?; + return Ok((a.to_alloy(), b.to_alloy())); + } + _ => {} + } + } + provider.estimate_eip1559_fees(None).await.wrap_err("Failed fetch EIP1559 fees") +} + +#[cfg(not(windows))] +fn resolve_path(path: &Path) -> Result { + if path.is_absolute() { + Ok(path.to_path_buf()) + } else { + std::env::current_dir().map(|d| d.join(path)).map_err(drop) + } +} + +#[cfg(windows)] +fn resolve_path(path: &Path) -> Result { + if let Some(s) = path.to_str() { + if s.starts_with(r"\\.\pipe\") { + return Ok(path.to_path_buf()); + } + } + Err(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn can_auto_correct_missing_prefix() { + let builder = ProviderBuilder::new("localhost:8545"); + assert!(builder.url.is_ok()); + + let url = builder.url.unwrap(); + assert_eq!(url, Url::parse("http://localhost:8545").unwrap()); + } +} diff --git a/crates/common/src/provider.rs b/crates/common/src/provider/ethers.rs similarity index 99% rename from crates/common/src/provider.rs rename to crates/common/src/provider/ethers.rs index 730260d9ab4d7..0d4acd2ce3776 100644 --- a/crates/common/src/provider.rs +++ b/crates/common/src/provider/ethers.rs @@ -34,7 +34,7 @@ pub type RpcUrl = String; /// # Examples /// /// ``` -/// use foundry_common::get_http_provider; +/// use foundry_common::provider::ethers::get_http_provider; /// /// let retry_provider = get_http_provider("http://localhost:8545"); /// ``` @@ -281,7 +281,7 @@ where _ => unreachable!(), }; let estimator = Polygon::new(chain)?.category(GasCategory::Standard); - return Ok(estimator.estimate_eip1559_fees().await?) + return Ok(estimator.estimate_eip1559_fees().await?); } _ => {} } diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs new file mode 100644 index 0000000000000..cbd9ecbd00ef9 --- /dev/null +++ b/crates/common/src/provider/mod.rs @@ -0,0 +1,7 @@ +//! Provider-related instantiation and usage utilities. + +pub mod alloy; +pub mod ethers; +pub mod retry; +pub mod runtime_transport; +pub mod tower; diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs new file mode 100644 index 0000000000000..e640728e0d6ac --- /dev/null +++ b/crates/common/src/provider/retry.rs @@ -0,0 +1,104 @@ +//! An utility trait for retrying requests based on the error type. See [TransportError]. +use alloy_json_rpc::ErrorPayload; +use alloy_transport::TransportError; +use serde::Deserialize; + +/// [RetryPolicy] defines logic for which [JsonRpcClient::Error] instances should +/// the client retry the request and try to recover from. +pub trait RetryPolicy: Send + Sync + std::fmt::Debug { + /// Whether to retry the request based on the given `error` + fn should_retry(&self, error: &TransportError) -> bool; + + /// Providers may include the `backoff` in the error response directly + fn backoff_hint(&self, error: &TransportError) -> Option; +} + +/// Implements [RetryPolicy] that will retry requests that errored with +/// status code 429 i.e. TOO_MANY_REQUESTS +/// +/// Infura often fails with a `"header not found"` rpc error which is apparently linked to load +/// balancing, which are retried as well. +#[derive(Clone, Debug, Default)] +pub struct RateLimitRetryPolicy; + +impl RetryPolicy for RateLimitRetryPolicy { + fn should_retry(&self, error: &TransportError) -> bool { + match error { + TransportError::Transport(_) => true, + // The transport could not serialize the error itself. The request was malformed from + // the start. + TransportError::SerError(_) => false, + TransportError::DeserError { text, .. } => { + // some providers send invalid JSON RPC in the error case (no `id:u64`), but the + // text should be a `JsonRpcError` + #[derive(Deserialize)] + struct Resp { + error: ErrorPayload, + } + + if let Ok(resp) = serde_json::from_str::(text) { + return should_retry_json_rpc_error(&resp.error) + } + false + } + TransportError::ErrorResp(err) => should_retry_json_rpc_error(err), + } + } + + fn backoff_hint(&self, error: &TransportError) -> Option { + if let TransportError::ErrorResp(resp) = error { + let data = resp.try_data_as::(); + if let Some(Ok(data)) = data { + // if daily rate limit exceeded, infura returns the requested backoff in the error + // response + let backoff_seconds = &data["rate"]["backoff_seconds"]; + // infura rate limit error + if let Some(seconds) = backoff_seconds.as_u64() { + return Some(std::time::Duration::from_secs(seconds)) + } + if let Some(seconds) = backoff_seconds.as_f64() { + return Some(std::time::Duration::from_secs(seconds as u64 + 1)) + } + } + } + None + } +} + +/// Analyzes the [ErrorPayload] and decides if the request should be retried based on the +/// error code or the message. +fn should_retry_json_rpc_error(error: &ErrorPayload) -> bool { + let ErrorPayload { code, message, .. } = error; + // alchemy throws it this way + if *code == 429 { + return true + } + + // This is an infura error code for `exceeded project rate limit` + if *code == -32005 { + return true + } + + // alternative alchemy error for specific IPs + if *code == -32016 && message.contains("rate limit") { + return true + } + + // quick node rate limit error: `100/second request limit reached - reduce calls per second or + // upgrade your account at quicknode.com` + if *code == -32007 && message.contains("request limit reached") { + return true + } + + match message.as_str() { + // this is commonly thrown by infura and is apparently a load balancer issue, see also + "header not found" => true, + // also thrown by infura if out of budget for the day and ratelimited + "daily request count exceeded, request rate limited" => true, + msg => { + msg.contains("rate limit") || + msg.contains("too many requests") || + msg.contains("request limit") + } + } +} diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs new file mode 100644 index 0000000000000..67f83998d44c7 --- /dev/null +++ b/crates/common/src/provider/runtime_transport.rs @@ -0,0 +1,310 @@ +//! Runtime transport that connects on first request, which can take either of an HTTP, +//! WebSocket, or IPC transport and supports retries based on CUPS logic. +use crate::REQUEST_TIMEOUT; +use alloy_json_rpc::{RequestPacket, ResponsePacket}; +use alloy_pubsub::{PubSubConnect, PubSubFrontend}; +use alloy_transport::{ + Authorization, BoxTransport, TransportError, TransportErrorKind, TransportFut, +}; +use alloy_transport_http::Http; +use alloy_transport_ipc::IpcConnect; +use alloy_transport_ws::WsConnect; +use ethers_providers::{JwtAuth, JwtKey}; +use reqwest::header::{HeaderName, HeaderValue}; +use std::{path::PathBuf, str::FromStr, sync::Arc}; +use thiserror::Error; +use tokio::sync::RwLock; +use tower::Service; +use url::Url; + +/// An enum representing the different transports that can be used to connect to a runtime. +/// Only meant to be used internally by [RuntimeTransport]. +#[derive(Clone, Debug)] +pub enum InnerTransport { + /// HTTP transport + Http(Http), + /// WebSocket transport + Ws(PubSubFrontend), + // TODO: IPC + /// IPC transport + Ipc(PubSubFrontend), +} + +/// Error type for the runtime transport. +#[derive(Error, Debug)] +pub enum RuntimeTransportError { + /// Internal transport error + #[error(transparent)] + TransportError(TransportError), + + /// Failed to lock the transport + #[error("Failed to lock the transport")] + LockError, + + /// Invalid URL scheme + #[error("URL scheme is not supported: {0}")] + BadScheme(String), + + /// Invalid HTTP header + #[error("Invalid HTTP header: {0}")] + BadHeader(String), + + /// Invalid file path + #[error("Invalid IPC file path: {0}")] + BadPath(String), + + /// Invalid construction of Http provider + #[error(transparent)] + HttpConstructionError(#[from] reqwest::Error), + + /// Invalid JWT + #[error("Invalid JWT: {0}")] + InvalidJwt(String), +} + +/// A runtime transport is a custom [alloy_transport::Transport] that only connects when the *first* +/// request is made. When the first request is made, it will connect to the runtime using either an +/// HTTP WebSocket, or IPC transport depending on the URL used. +/// It also supports retries for rate-limiting and timeout-related errors. +#[derive(Clone, Debug, Error)] +pub struct RuntimeTransport { + /// The inner actual transport used. + inner: Arc>>, + /// The URL to connect to. + url: Url, + /// The headers to use for requests. + headers: Vec, + /// The JWT to use for requests. + jwt: Option, + /// The timeout for requests. + timeout: std::time::Duration, +} + +/// A builder for [RuntimeTransport]. +#[derive(Debug)] +pub struct RuntimeTransportBuilder { + url: Url, + headers: Vec, + jwt: Option, + timeout: std::time::Duration, +} + +impl RuntimeTransportBuilder { + /// Create a new builder with the given URL. + pub fn new(url: Url) -> Self { + Self { url, headers: vec![], jwt: None, timeout: REQUEST_TIMEOUT } + } + + /// Set the URL for the transport. + pub fn with_headers(mut self, headers: Vec) -> Self { + self.headers = headers; + self + } + + /// Set the JWT for the transport. + pub fn with_jwt(mut self, jwt: Option) -> Self { + self.jwt = jwt; + self + } + + /// Set the timeout for the transport. + pub fn with_timeout(mut self, timeout: std::time::Duration) -> Self { + self.timeout = timeout; + self + } + + /// Builds the [RuntimeTransport] and returns it in a disconnected state. + /// The runtime transport will then connect when the first request happens. + pub fn build(self) -> RuntimeTransport { + RuntimeTransport { + inner: Arc::new(RwLock::new(None)), + url: self.url, + headers: self.headers, + jwt: self.jwt, + timeout: self.timeout, + } + } +} + +impl ::core::fmt::Display for RuntimeTransport { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + write!(f, "RuntimeTransport {}", self.url) + } +} + +impl RuntimeTransport { + /// Connects the underlying transport, depending on the URL scheme. + pub async fn connect(&self) -> Result { + match self.url.scheme() { + "http" | "https" => self.connect_http().await, + "ws" | "wss" => self.connect_ws().await, + "file" => self.connect_ipc().await, + _ => Err(RuntimeTransportError::BadScheme(self.url.scheme().to_string())), + } + } + + /// Connects to an HTTP [alloy_transport_http::Http] transport. + async fn connect_http(&self) -> Result { + let mut client_builder = reqwest::Client::builder().timeout(self.timeout); + let mut headers = reqwest::header::HeaderMap::new(); + + // If there's a JWT, add it to the headers if we can decode it. + if let Some(jwt) = self.jwt.clone() { + let auth = + build_auth(jwt).map_err(|e| RuntimeTransportError::InvalidJwt(e.to_string()))?; + + let mut auth_value: HeaderValue = + HeaderValue::from_str(&auth.to_string()).expect("Header should be valid string"); + auth_value.set_sensitive(true); + + headers.insert(reqwest::header::AUTHORIZATION, auth_value); + }; + + // Add any custom headers. + for header in self.headers.iter() { + let make_err = || RuntimeTransportError::BadHeader(header.to_string()); + + let (key, val) = header.split_once(':').ok_or_else(make_err)?; + + headers.insert( + HeaderName::from_str(key.trim()).map_err(|_| make_err())?, + HeaderValue::from_str(val.trim()).map_err(|_| make_err())?, + ); + } + + client_builder = client_builder.default_headers(headers); + + let client = + client_builder.build().map_err(RuntimeTransportError::HttpConstructionError)?; + + // todo: retry tower layer + Ok(InnerTransport::Http(Http::with_client(client, self.url.clone()))) + } + + /// Connects to a WS transport. + async fn connect_ws(&self) -> Result { + let auth = self.jwt.as_ref().and_then(|jwt| build_auth(jwt.clone()).ok()); + let ws = WsConnect { url: self.url.to_string(), auth } + .into_service() + .await + .map_err(RuntimeTransportError::TransportError)?; + Ok(InnerTransport::Ws(ws)) + } + + /// Connects to an IPC transport. + async fn connect_ipc(&self) -> Result { + let path = url_to_file_path(&self.url) + .map_err(|_| RuntimeTransportError::BadPath(self.url.to_string()))?; + let ipc_connector: IpcConnect = path.into(); + let ipc = + ipc_connector.into_service().await.map_err(RuntimeTransportError::TransportError)?; + Ok(InnerTransport::Ipc(ipc)) + } + + /// Sends a request using the underlying transport. + /// If this is the first request, it will connect to the appropiate transport depending on the + /// URL scheme. When sending the request, retries will be automatically handled depending + /// on the parameters set on the [RuntimeTransport]. + /// For sending the actual request, this action is delegated down to the + /// underlying transport through Tower's [tower::Service::call]. See tower's [tower::Service] + /// trait for more information. + pub fn request(&self, req: RequestPacket) -> TransportFut<'static> { + let this = self.clone(); + Box::pin(async move { + if this.inner.read().await.is_none() { + let mut inner = this.inner.write().await; + *inner = Some(this.connect().await.map_err(TransportErrorKind::custom)?) + } + + let mut inner = this.inner.write().await; + // SAFETY: We just checked that the inner transport exists. + let inner_mut = inner.as_mut().expect("We should have an inner transport."); + + match inner_mut { + InnerTransport::Http(http) => http.call(req), + InnerTransport::Ws(ws) => ws.call(req), + InnerTransport::Ipc(ipc) => ipc.call(req), + } + .await + }) + } + + /// Convert this transport into a boxed trait object. + pub fn boxed(self) -> BoxTransport + where + Self: Sized + Clone + Send + Sync + 'static, + { + BoxTransport::new(self) + } +} + +impl tower::Service for RuntimeTransport { + type Response = ResponsePacket; + type Error = TransportError; + type Future = TransportFut<'static>; + + #[inline] + fn poll_ready( + &mut self, + _cx: &mut std::task::Context<'_>, + ) -> std::task::Poll> { + std::task::Poll::Ready(Ok(())) + } + + #[inline] + fn call(&mut self, req: RequestPacket) -> Self::Future { + self.request(req) + } +} + +impl Service for &RuntimeTransport { + type Response = ResponsePacket; + type Error = TransportError; + type Future = TransportFut<'static>; + + #[inline] + fn poll_ready( + &mut self, + _cx: &mut std::task::Context<'_>, + ) -> std::task::Poll> { + std::task::Poll::Ready(Ok(())) + } + + #[inline] + fn call(&mut self, req: RequestPacket) -> Self::Future { + self.request(req) + } +} + +fn build_auth(jwt: String) -> eyre::Result { + // Decode jwt from hex, then generate claims (iat with current timestamp) + let jwt = hex::decode(jwt)?; + let secret = JwtKey::from_slice(&jwt).map_err(|err| eyre::eyre!("Invalid JWT: {}", err))?; + let auth = JwtAuth::new(secret, None, None); + let token = auth.generate_token()?; + + // Essentially unrolled ethers-rs new_with_auth to accomodate the custom timeout + let auth = Authorization::Bearer(token); + + Ok(auth) +} + +#[cfg(windows)] +fn url_to_file_path(url: &Url) -> Result { + const PREFIX: &str = "file:///pipe/"; + + let url_str = url.as_str(); + + if url_str.starts_with(PREFIX) { + let pipe_name = &url_str[PREFIX.len()..]; + let pipe_path = format!(r"\\.\pipe\{}", pipe_name); + return Ok(PathBuf::from(pipe_path)); + } + + url.to_file_path() +} + +#[cfg(not(windows))] +fn url_to_file_path(url: &Url) -> Result { + url.to_file_path() +} diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs new file mode 100644 index 0000000000000..5e08b836c991a --- /dev/null +++ b/crates/common/src/provider/tower.rs @@ -0,0 +1,192 @@ +//! Alloy-related tower middleware for retrying rate-limited requests +//! and applying backoff. +use std::{ + sync::{ + atomic::{AtomicU32, Ordering}, + Arc, + }, + task::{Context, Poll}, +}; + +use alloy_json_rpc::{RequestPacket, ResponsePacket}; +use alloy_transport::{TransportError, TransportErrorKind, TransportFut}; +use tower::Service; + +use super::{ + retry::{RateLimitRetryPolicy, RetryPolicy}, + runtime_transport::RuntimeTransport, +}; + +/// An Alloy Tower Layer that is responsible for retrying requests based on the +/// error type. See [TransportError]. +#[derive(Debug, Clone)] +pub struct RetryBackoffLayer { + /// The maximum number of retries for rate limit errors + max_rate_limit_retries: u32, + /// The maximum number of retries for timeout errors + max_timeout_retries: u32, + /// The initial backoff in milliseconds + initial_backoff: u64, + /// The number of compute units per second for this provider + compute_units_per_second: u64, +} + +impl RetryBackoffLayer { + /// Creates a new [RetryWithPolicyLayer] with the given parameters + pub fn new( + max_rate_limit_retries: u32, + max_timeout_retries: u32, + initial_backoff: u64, + compute_units_per_second: u64, + ) -> Self { + Self { + max_rate_limit_retries, + max_timeout_retries, + initial_backoff, + compute_units_per_second, + } + } +} + +impl tower::layer::Layer for RetryBackoffLayer { + type Service = RetryBackoffService; + + fn layer(&self, inner: S) -> Self::Service { + RetryBackoffService { + inner, + policy: RateLimitRetryPolicy, + max_rate_limit_retries: self.max_rate_limit_retries, + max_timeout_retries: self.max_timeout_retries, + initial_backoff: self.initial_backoff, + compute_units_per_second: self.compute_units_per_second, + requests_enqueued: Arc::new(AtomicU32::new(0)), + } + } +} + +/// An Alloy Tower Service that is responsible for retrying requests based on the +/// error type. See [TransportError] and [RetryWithPolicyLayer]. +#[derive(Debug, Clone)] +pub struct RetryBackoffService { + /// The inner service + inner: S, + /// The retry policy + policy: RateLimitRetryPolicy, + /// The maximum number of retries for rate limit errors + max_rate_limit_retries: u32, + /// The maximum number of retries for timeout errors + max_timeout_retries: u32, + /// The initial backoff in milliseconds + initial_backoff: u64, + /// The number of compute units per second for this service + compute_units_per_second: u64, + /// The number of requests currently enqueued + requests_enqueued: Arc, +} + +// impl tower service +impl Service for RetryBackoffService { + type Response = ResponsePacket; + type Error = TransportError; + type Future = TransportFut<'static>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + // Our middleware doesn't care about backpressure, so it's ready as long + // as the inner service is ready. + self.inner.poll_ready(cx) + } + + fn call(&mut self, request: RequestPacket) -> Self::Future { + let mut this = self.clone(); + Box::pin(async move { + let ahead_in_queue = this.requests_enqueued.fetch_add(1, Ordering::SeqCst) as u64; + let mut rate_limit_retry_number: u32 = 0; + let mut timeout_retries: u32 = 0; + loop { + let err; + let fut = this.inner.call(request.clone()).await; + + match fut { + Ok(res) => { + this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); + return Ok(res) + } + Err(e) => err = e, + } + + let err = TransportError::from(err); + let should_retry = this.policy.should_retry(&err); + if should_retry { + rate_limit_retry_number += 1; + if rate_limit_retry_number > this.max_rate_limit_retries { + return Err(TransportErrorKind::custom_str("Max retries exceeded")) + } + + let current_queued_reqs = this.requests_enqueued.load(Ordering::SeqCst) as u64; + + // try to extract the requested backoff from the error or compute the next + // backoff based on retry count + let mut next_backoff = this + .policy + .backoff_hint(&err) + .unwrap_or_else(|| std::time::Duration::from_millis(this.initial_backoff)); + + // requests are usually weighted and can vary from 10 CU to several 100 CU, + // cheaper requests are more common some example alchemy + // weights: + // - `eth_getStorageAt`: 17 + // - `eth_getBlockByNumber`: 16 + // - `eth_newFilter`: 20 + // + // (coming from forking mode) assuming here that storage request will be the + // driver for Rate limits we choose `17` as the average cost + // of any request + const AVG_COST: u64 = 17u64; + let seconds_to_wait_for_compute_budget = compute_unit_offset_in_secs( + AVG_COST, + this.compute_units_per_second, + current_queued_reqs, + ahead_in_queue, + ); + next_backoff += + std::time::Duration::from_secs(seconds_to_wait_for_compute_budget); + + tokio::time::sleep(next_backoff).await; + } else { + if timeout_retries < this.max_timeout_retries { + timeout_retries += 1; + continue; + } + + this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); + return Err(TransportErrorKind::custom_str("Max retries exceeded")) + } + } + }) + } +} + +/// Calculates an offset in seconds by taking into account the number of currently queued requests, +/// number of requests that were ahead in the queue when the request was first issued, the average +/// cost a weighted request (heuristic), and the number of available compute units per seconds. +/// +/// Returns the number of seconds (the unit the remote endpoint measures compute budget) a request +/// is supposed to wait to not get rate limited. The budget per second is +/// `compute_units_per_second`, assuming an average cost of `avg_cost` this allows (in theory) +/// `compute_units_per_second / avg_cost` requests per seconds without getting rate limited. +/// By taking into account the number of concurrent request and the position in queue when the +/// request was first issued and determine the number of seconds a request is supposed to wait, if +/// at all +fn compute_unit_offset_in_secs( + avg_cost: u64, + compute_units_per_second: u64, + current_queued_requests: u64, + ahead_in_queue: u64, +) -> u64 { + let request_capacity_per_second = compute_units_per_second.saturating_div(avg_cost); + if current_queued_requests > request_capacity_per_second { + current_queued_requests.min(ahead_in_queue).saturating_div(request_capacity_per_second) + } else { + 0 + } +} diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index fc53d87caea85..ea0fe593830c4 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -1,5 +1,5 @@ //! Wrap different providers - +// todo: remove use async_trait::async_trait; use ethers_core::types::U256; use ethers_providers::{ @@ -261,7 +261,7 @@ fn url_to_file_path(url: &Url) -> Result { if url_str.starts_with(PREFIX) { let pipe_name = &url_str[PREFIX.len()..]; let pipe_path = format!(r"\\.\pipe\{}", pipe_name); - return Ok(PathBuf::from(pipe_path)) + return Ok(PathBuf::from(pipe_path)); } url.to_file_path() diff --git a/crates/common/src/serde_helpers.rs b/crates/common/src/serde_helpers.rs new file mode 100644 index 0000000000000..c1b61b6e24241 --- /dev/null +++ b/crates/common/src/serde_helpers.rs @@ -0,0 +1,129 @@ +//! Misc Serde helpers for foundry crates. + +use alloy_primitives::U256; +use serde::{de, Deserialize, Deserializer}; +use std::str::FromStr; + +/// Helper type to parse both `u64` and `U256` +#[derive(Copy, Clone, Deserialize)] +#[serde(untagged)] +pub enum Numeric { + /// A [U256] value. + U256(U256), + /// A `u64` value. + Num(u64), +} + +impl From for U256 { + fn from(n: Numeric) -> U256 { + match n { + Numeric::U256(n) => n, + Numeric::Num(n) => U256::from(n), + } + } +} + +impl FromStr for Numeric { + type Err = String; + + fn from_str(s: &str) -> Result { + if let Ok(val) = s.parse::() { + Ok(Numeric::U256(U256::from(val))) + } else if s.starts_with("0x") { + U256::from_str_radix(s, 16).map(Numeric::U256).map_err(|err| err.to_string()) + } else { + U256::from_str(s).map(Numeric::U256).map_err(|err| err.to_string()) + } + } +} + +/// Deserializes the input into an `Option`, using [`from_int_or_hex`] to deserialize the +/// inner value. +pub fn from_int_or_hex_opt<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + match Option::::deserialize(deserializer)? { + Some(val) => val.try_into_u256().map(Some), + None => Ok(None), + } +} + +/// An enum that represents either a [serde_json::Number] integer, or a hex [U256]. +#[derive(Debug, Deserialize)] +#[serde(untagged)] +pub enum NumberOrHexU256 { + /// An integer + Int(serde_json::Number), + /// A hex U256 + Hex(U256), +} + +impl NumberOrHexU256 { + /// Tries to convert this into a [U256]]. + pub fn try_into_u256(self) -> Result { + match self { + NumberOrHexU256::Int(num) => { + U256::from_str(num.to_string().as_str()).map_err(E::custom) + } + NumberOrHexU256::Hex(val) => Ok(val), + } + } +} + +/// Deserializes the input into a U256, accepting both 0x-prefixed hex and decimal strings with +/// arbitrary precision, defined by serde_json's [`Number`](serde_json::Number). +pub fn from_int_or_hex<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + NumberOrHexU256::deserialize(deserializer)?.try_into_u256() +} + +/// Helper type to deserialize sequence of numbers +#[derive(Deserialize)] +#[serde(untagged)] +pub enum NumericSeq { + /// Single parameter sequence (e.g [1]) + Seq([Numeric; 1]), + /// U256 + U256(U256), + /// Native u64 + Num(u64), +} + +/// Deserializes a number from hex or int +pub fn deserialize_number<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + Numeric::deserialize(deserializer).map(Into::into) +} + +/// Deserializes a number from hex or int, but optionally +pub fn deserialize_number_opt<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + let num = match Option::::deserialize(deserializer)? { + Some(Numeric::U256(n)) => Some(n), + Some(Numeric::Num(n)) => Some(U256::from(n)), + _ => None, + }; + + Ok(num) +} + +/// Deserializes single integer params: `1, [1], ["0x01"]` +pub fn deserialize_number_seq<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + let num = match NumericSeq::deserialize(deserializer)? { + NumericSeq::Seq(seq) => seq[0].into(), + NumericSeq::U256(n) => n, + NumericSeq::Num(n) => U256::from(n), + }; + + Ok(num) +} diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index 0413805a16aa0..4247cc1eb808d 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -1,12 +1,16 @@ //! Temporary utility conversion traits between ethers-rs and alloy types. use alloy_json_abi::{Event, EventParam, Function, InternalType, Param, StateMutability}; -use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U256, U64}; +use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U128, U256, U64}; +use alloy_rpc_types::{AccessList, AccessListItem, CallInput, CallRequest, Signature, Transaction}; use ethers_core::{ abi as ethabi, types::{ - Bloom as EthersBloom, Bytes as EthersBytes, H160, H256, H64, I256 as EthersI256, - U256 as EthersU256, U64 as EthersU64, + transaction::eip2930::{ + AccessList as EthersAccessList, AccessListItem as EthersAccessListItem, + }, + Bloom as EthersBloom, Bytes as EthersBytes, TransactionRequest, H160, H256, H64, + I256 as EthersI256, U256 as EthersU256, U64 as EthersU64, }, }; @@ -100,6 +104,86 @@ impl ToAlloy for u64 { } } +impl ToAlloy for ethers_core::types::Transaction { + type To = Transaction; + + fn to_alloy(self) -> Self::To { + Transaction { + hash: self.hash.to_alloy(), + nonce: U64::from(self.nonce.as_u64()), + block_hash: self.block_hash.map(ToAlloy::to_alloy), + block_number: self.block_number.map(|b| U256::from(b.as_u64())), + transaction_index: self.transaction_index.map(|b| U256::from(b.as_u64())), + from: self.from.to_alloy(), + to: self.to.map(ToAlloy::to_alloy), + value: self.value.to_alloy(), + gas_price: self.gas_price.map(|a| U128::from(a.as_u128())), + gas: self.gas.to_alloy(), + max_fee_per_gas: self.max_fee_per_gas.map(|f| U128::from(f.as_u128())), + max_priority_fee_per_gas: self + .max_priority_fee_per_gas + .map(|f| U128::from(f.as_u128())), + max_fee_per_blob_gas: None, + input: self.input.0.into(), + signature: Some(Signature { + r: self.r.to_alloy(), + s: self.s.to_alloy(), + v: U256::from(self.v.as_u64()), + y_parity: None, + }), + chain_id: self.chain_id.map(|c| U64::from(c.as_u64())), + blob_versioned_hashes: Vec::new(), + access_list: self.access_list.map(|a| a.0.into_iter().map(ToAlloy::to_alloy).collect()), + transaction_type: self.transaction_type.map(|t| t.to_alloy()), + other: Default::default(), + } + } +} + +/// Converts from a [TransactionRequest] to a [CallRequest]. +pub fn to_call_request_from_tx_request(tx: TransactionRequest) -> CallRequest { + CallRequest { + from: tx.from.map(|f| f.to_alloy()), + to: match tx.to { + Some(to) => match to { + ethers_core::types::NameOrAddress::Address(addr) => Some(addr.to_alloy()), + ethers_core::types::NameOrAddress::Name(_) => None, + }, + None => None, + }, + gas_price: tx.gas_price.map(|g| g.to_alloy()), + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + gas: tx.gas.map(|g| g.to_alloy()), + value: tx.value.map(|v| v.to_alloy()), + input: CallInput::maybe_input(tx.data.map(|b| b.0.into())), + nonce: tx.nonce.map(|n| U64::from(n.as_u64())), + chain_id: tx.chain_id.map(|c| c.to_alloy()), + access_list: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: None, + transaction_type: None, + } +} + +impl ToAlloy for EthersAccessList { + type To = AccessList; + fn to_alloy(self) -> Self::To { + AccessList(self.0.into_iter().map(ToAlloy::to_alloy).collect()) + } +} + +impl ToAlloy for EthersAccessListItem { + type To = AccessListItem; + + fn to_alloy(self) -> Self::To { + AccessListItem { + address: self.address.to_alloy(), + storage_keys: self.storage_keys.into_iter().map(ToAlloy::to_alloy).collect(), + } + } +} + impl ToAlloy for ethabi::Event { type To = Event; diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index d482a329b663b..36cc8c7b6a83f 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -26,10 +26,9 @@ impl RpcEndpoints { endpoints: endpoints .into_iter() .map(|(name, e)| match e.into() { - RpcEndpointType::String(url) => ( - name.into(), - RpcEndpointConfig { endpoint: url.into(), ..Default::default() }, - ), + RpcEndpointType::String(url) => { + (name.into(), RpcEndpointConfig { endpoint: url, ..Default::default() }) + } RpcEndpointType::Config(config) => (name.into(), config), }) .collect(), @@ -79,7 +78,7 @@ impl RpcEndpointType { /// Returns the config variant pub fn as_endpoint_config(&self) -> Option<&RpcEndpointConfig> { match self { - RpcEndpointType::Config(config) => Some(&config), + RpcEndpointType::Config(config) => Some(config), RpcEndpointType::String(_) => None, } } @@ -207,15 +206,15 @@ impl<'de> Deserialize<'de> for RpcEndpoint { } } -impl Into for RpcEndpoint { - fn into(self) -> RpcEndpointType { - RpcEndpointType::String(self) +impl From for RpcEndpointType { + fn from(endpoint: RpcEndpoint) -> Self { + RpcEndpointType::String(endpoint) } } -impl Into for RpcEndpoint { - fn into(self) -> RpcEndpointConfig { - RpcEndpointConfig { endpoint: self, ..Default::default() } +impl From for RpcEndpointConfig { + fn from(endpoint: RpcEndpoint) -> Self { + RpcEndpointConfig { endpoint, ..Default::default() } } } @@ -276,7 +275,7 @@ impl Serialize for RpcEndpointConfig { self.compute_units_per_second.is_none() { // serialize as endpoint if there's no additional config - return self.endpoint.serialize(serializer); + self.endpoint.serialize(serializer) } else { let mut map = serializer.serialize_map(Some(4))?; map.serialize_entry("endpoint", &self.endpoint)?; @@ -317,9 +316,9 @@ impl<'de> Deserialize<'de> for RpcEndpointConfig { } } -impl Into for RpcEndpointConfig { - fn into(self) -> RpcEndpointType { - RpcEndpointType::Config(self) +impl From for RpcEndpointType { + fn from(config: RpcEndpointConfig) -> Self { + RpcEndpointType::Config(config) } } diff --git a/crates/config/src/macros.rs b/crates/config/src/macros.rs index 4bd501354f113..95b111bdb9911 100644 --- a/crates/config/src/macros.rs +++ b/crates/config/src/macros.rs @@ -30,7 +30,7 @@ /// Metadata::default() /// } /// -/// fn data(&self) -> Result, Error> { +/// fn data(&self) -> std::result::Result, Error> { /// let value = Value::serialize(self)?; /// let error = InvalidType(value.to_actual(), "map".into()); /// let mut dict = value.into_dict().ok_or(error)?; @@ -137,7 +137,7 @@ macro_rules! impl_figment_convert { /// Metadata::default() /// } /// -/// fn data(&self) -> Result, Error> { +/// fn data(&self) -> std::result::Result, Error> { /// todo!() /// } /// } @@ -155,7 +155,7 @@ macro_rules! impl_figment_convert { /// Metadata::default() /// } /// -/// fn data(&self) -> Result, Error> { +/// fn data(&self) -> std::result::Result, Error> { /// todo!() /// } /// } diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 51d9ad6df13ca..3671e08e36b85 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -31,9 +31,12 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", "optimism", ] } +alloy-providers = { workspace = true } +alloy-transport = { workspace = true } +alloy-rpc-types = { workspace = true } +ethers = { workspace = true, features = ["ethers-solc"] } ethers-core.workspace = true -ethers-providers.workspace = true derive_more.workspace = true eyre = "0.6" diff --git a/crates/evm/core/src/abi/console.rs b/crates/evm/core/src/abi/console.rs index ce8dc6d5752cc..54014359b9dd1 100644 --- a/crates/evm/core/src/abi/console.rs +++ b/crates/evm/core/src/abi/console.rs @@ -1,7 +1,6 @@ use alloy_primitives::{hex, I256, U256}; use alloy_sol_types::sol; use derive_more::Display; -use foundry_common::types::ToEthers; use itertools::Itertools; // TODO: Use `UiFmt` @@ -84,9 +83,8 @@ fn format_units_int(x: &I256, decimals: &U256) -> String { } fn format_units_uint(x: &U256, decimals: &U256) -> String { - // TODO: rm ethers_core - match ethers_core::utils::format_units(x.to_ethers(), decimals.saturating_to::()) { - Ok(s) => s, - Err(_) => x.to_string(), + match alloy_primitives::utils::Unit::new(decimals.saturating_to::()) { + Some(units) => alloy_primitives::utils::ParseUnits::U256(*x).format_units(units), + None => x.to_string(), } } diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index b22c768d404da..df5b094a63f86 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -1,5 +1,5 @@ use alloy_primitives::{Address, B256, U256}; -use ethers_core::types::BlockId; +use alloy_rpc_types::BlockId; use futures::channel::mpsc::{SendError, TrySendError}; use std::{ convert::Infallible, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 3ba7dea53ef1c..f2f1a355d6f5f 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -7,15 +7,9 @@ use crate::{ utils::configure_tx_env, }; use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; -use ethers_core::{ - types::{Block, BlockNumber, Transaction}, - utils::GenesisAccount, -}; -use foundry_common::{ - is_known_system_sender, - types::{ToAlloy, ToEthers}, - SYSTEM_TRANSACTION_TYPE, -}; +use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; +use ethers::utils::GenesisAccount; +use foundry_common::{is_known_system_sender, types::ToAlloy, SYSTEM_TRANSACTION_TYPE}; use revm::{ db::{CacheDB, DatabaseRef}, inspectors::NoOpInspector, @@ -306,7 +300,7 @@ pub trait DatabaseExt: Database { /// Returns an error if [`Self::has_cheatcode_access`] returns `false` fn ensure_cheatcode_access(&self, account: Address) -> Result<(), DatabaseError> { if !self.has_cheatcode_access(account) { - return Err(DatabaseError::NoCheats(account)) + return Err(DatabaseError::NoCheats(account)); } Ok(()) } @@ -315,7 +309,7 @@ pub trait DatabaseExt: Database { /// in forking mode fn ensure_cheatcode_access_forking_mode(&self, account: Address) -> Result<(), DatabaseError> { if self.is_forked_mode() { - return self.ensure_cheatcode_access(account) + return self.ensure_cheatcode_access(account); } Ok(()) } @@ -626,7 +620,7 @@ impl Backend { .cloned() .unwrap_or_default() .present_value(); - return value.as_le_bytes()[1] != 0 + return value.as_le_bytes()[1] != 0; } false @@ -639,7 +633,7 @@ impl Backend { if let Some(account) = current_state.state.get(&CHEATCODE_ADDRESS) { let slot: U256 = GLOBAL_FAILURE_SLOT.into(); let value = account.storage.get(&slot).cloned().unwrap_or_default().present_value(); - return value == revm::primitives::U256::from(1) + return value == revm::primitives::U256::from(1); } false @@ -741,7 +735,7 @@ impl Backend { all_logs.extend(f.journaled_state.logs.clone()) } }); - return all_logs + return all_logs; } logs @@ -846,26 +840,27 @@ impl Backend { &self, id: LocalForkId, transaction: B256, - ) -> eyre::Result<(U64, Block)> { + ) -> eyre::Result<(U64, Block)> { let fork = self.inner.get_fork_by_id(id)?; let tx = fork.db.db.get_transaction(transaction)?; // get the block number we need to fork if let Some(tx_block) = tx.block_number { - let block = fork.db.db.get_full_block(BlockNumber::Number(tx_block))?; + let block = fork.db.db.get_full_block(tx_block.to::())?; // we need to subtract 1 here because we want the state before the transaction // was mined - let fork_block = tx_block - 1; - Ok((U64::from(fork_block.as_u64()), block)) + let fork_block = tx_block.to::() - 1; + Ok((U64::from(fork_block), block)) } else { - let block = fork.db.db.get_full_block(BlockNumber::Latest)?; + let block = fork.db.db.get_full_block(BlockNumberOrTag::Latest)?; let number = block + .header .number - .ok_or_else(|| DatabaseError::BlockNotFound(BlockNumber::Latest.into()))?; + .ok_or_else(|| DatabaseError::BlockNotFound(BlockNumberOrTag::Latest.into()))?; - Ok((U64::from(number.as_u64()), block)) + Ok((number.to::(), block)) } } @@ -884,27 +879,33 @@ impl Backend { let fork_id = self.ensure_fork_id(id)?.clone(); let fork = self.inner.get_fork_by_id_mut(id)?; - let full_block = fork - .db - .db - .get_full_block(BlockNumber::Number(env.block.number.to_ethers().as_u64().into()))?; - - for tx in full_block.transactions.into_iter() { - // System transactions such as on L2s don't contain any pricing info so we skip them - // otherwise this would cause reverts - if is_known_system_sender(tx.from.to_alloy()) || - tx.transaction_type.map(|ty| ty.as_u64()) == Some(SYSTEM_TRANSACTION_TYPE) - { - continue - } + let full_block = fork.db.db.get_full_block(env.block.number.to::())?; + + if let BlockTransactions::Full(txs) = full_block.transactions { + for tx in txs.into_iter() { + // System transactions such as on L2s don't contain any pricing info so we skip them + // otherwise this would cause reverts + if is_known_system_sender(tx.from) || + tx.transaction_type.map(|ty| ty.to::()) == Some(SYSTEM_TRANSACTION_TYPE) + { + continue; + } - if tx.hash == tx_hash.to_ethers() { - // found the target transaction - return Ok(Some(tx)) + if tx.hash == tx_hash { + // found the target transaction + return Ok(Some(tx)) + } + trace!(tx=?tx.hash, "committing transaction"); + + commit_transaction( + tx, + env.clone(), + journaled_state, + fork, + &fork_id, + NoOpInspector, + )?; } - trace!(tx=?tx.hash, "committing transaction"); - - commit_transaction(tx, env.clone(), journaled_state, fork, &fork_id, NoOpInspector)?; } Ok(None) @@ -1048,7 +1049,7 @@ impl DatabaseExt for Backend { trace!(?id, "select fork"); if self.is_active_fork(id) { // nothing to do - return Ok(()) + return Ok(()); } let fork_id = self.ensure_fork_id(id).cloned()?; @@ -1209,13 +1210,13 @@ impl DatabaseExt for Backend { self.roll_fork(Some(id), fork_block.to(), env, journaled_state)?; // update the block's env accordingly - env.block.timestamp = block.timestamp.to_alloy(); - env.block.coinbase = block.author.unwrap_or_default().to_alloy(); - env.block.difficulty = block.difficulty.to_alloy(); - env.block.prevrandao = block.mix_hash.map(|h| h.to_alloy()); - env.block.basefee = block.base_fee_per_gas.unwrap_or_default().to_alloy(); - env.block.gas_limit = block.gas_limit.to_alloy(); - env.block.number = block.number.map(|n| n.to_alloy()).unwrap_or(fork_block).to(); + env.block.timestamp = block.header.timestamp; + env.block.coinbase = block.header.miner; + env.block.difficulty = block.header.difficulty; + env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); + env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default(); + env.block.gas_limit = block.header.gas_limit; + env.block.number = block.header.number.map(|n| n.to()).unwrap_or(fork_block.to()); // replay all transactions that came before let env = env.clone(); @@ -1263,7 +1264,7 @@ impl DatabaseExt for Backend { fn ensure_fork(&self, id: Option) -> eyre::Result { if let Some(id) = id { if self.inner.issued_local_fork_ids.contains_key(&id) { - return Ok(id) + return Ok(id); } eyre::bail!("Requested fork `{}` does not exit", id) } @@ -1289,7 +1290,7 @@ impl DatabaseExt for Backend { if self.inner.forks.len() == 1 { // we only want to provide additional diagnostics here when in multifork mode with > 1 // forks - return None + return None; } if !active_fork.is_contract(callee) && !is_contract_in_state(journaled_state, callee) { @@ -1316,7 +1317,7 @@ impl DatabaseExt for Backend { active: active_id, available_on, }) - } + }; } None } @@ -1506,7 +1507,7 @@ impl Fork { pub fn is_contract(&self, acc: Address) -> bool { if let Ok(Some(acc)) = self.db.basic_ref(acc) { if acc.code_hash != KECCAK_EMPTY { - return true + return true; } } is_contract_in_state(&self.journaled_state, acc) @@ -1844,7 +1845,7 @@ fn merge_db_account_data( acc } else { // Account does not exist - return + return; }; if let Some(code) = active.contracts.get(&acc.info.code_hash).cloned() { diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index a68a1220715dd..7932edf19ca79 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -4,15 +4,10 @@ use crate::{ fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }; use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; -use ethers_core::{ - abi::ethereum_types::BigEndianHash, - types::{Block, BlockId, NameOrAddress, Transaction}, -}; -use ethers_providers::Middleware; -use foundry_common::{ - types::{ToAlloy, ToEthers}, - NON_ARCHIVE_NODE_WARNING, -}; +use alloy_providers::provider::TempProvider; +use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag, Transaction}; +use eyre::WrapErr; +use foundry_common::NON_ARCHIVE_NODE_WARNING; use futures::{ channel::mpsc::{channel, Receiver, Sender}, stream::Stream, @@ -38,20 +33,15 @@ type AccountFuture = Pin, Address)> + Send>>; type StorageFuture = Pin, Address, U256)> + Send>>; type BlockHashFuture = Pin, u64)> + Send>>; -type FullBlockFuture = Pin< - Box< - dyn Future>, Err>, BlockId)> - + Send, - >, ->; -type TransactionFuture = Pin< - Box, Err>, B256)> + Send>, ->; +type FullBlockFuture = + Pin, Err>, BlockId)> + Send>>; +type TransactionFuture = + Pin, B256)> + Send>>; type AccountInfoSender = OneshotSender>; type StorageSender = OneshotSender>; type BlockHashSender = OneshotSender>; -type FullBlockSender = OneshotSender>>; +type FullBlockSender = OneshotSender>; type TransactionSender = OneshotSender>; /// Request variants that are executed by the provider @@ -84,13 +74,13 @@ enum BackendRequest { /// /// This handler will remain active as long as it is reachable (request channel still open) and /// requests are in progress. -#[must_use = "futures do nothing unless polled"] -pub struct BackendHandler { - provider: M, +#[must_use = "BackendHandler does nothing unless polled."] +pub struct BackendHandler

{ + provider: P, /// Stores all the data. db: BlockchainDb, /// Requests currently in progress - pending_requests: Vec>, + pending_requests: Vec>, /// Listeners that wait for a `get_account` related response account_requests: HashMap>, /// Listeners that wait for a `get_storage_at` response @@ -106,12 +96,12 @@ pub struct BackendHandler { block_id: Option, } -impl BackendHandler +impl

BackendHandler

where - M: Middleware + Clone + 'static, + P: TempProvider + Clone + 'static, { fn new( - provider: M, + provider: P, db: BlockchainDb, rx: Receiver, block_id: Option, @@ -191,15 +181,8 @@ where let fut = Box::pin(async move { // serialize & deserialize back to U256 let idx_req = B256::from(idx); - let storage = provider - .get_storage_at( - NameOrAddress::Address(address.to_ethers()), - idx_req.to_ethers(), - block_id, - ) - .await; - let storage = storage.map(|storage| storage.into_uint()).map(|s| s.to_alloy()); - (storage, address, idx) + let storage = provider.get_storage_at(address, idx_req, block_id).await; + (storage.wrap_err("could not fetch slot {idx} from {address}"), address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); } @@ -207,19 +190,16 @@ where } /// returns the future that fetches the account data - fn get_account_req(&self, address: Address) -> ProviderRequest { + fn get_account_req(&self, address: Address) -> ProviderRequest { trace!(target: "backendhandler", "preparing account request, address={:?}", address); let provider = self.provider.clone(); let block_id = self.block_id; let fut = Box::pin(async move { - let balance = - provider.get_balance(NameOrAddress::Address(address.to_ethers()), block_id); - let nonce = provider - .get_transaction_count(NameOrAddress::Address(address.to_ethers()), block_id); - let code = provider.get_code(NameOrAddress::Address(address.to_ethers()), block_id); - let resp = tokio::try_join!(balance, nonce, code).map(|(balance, nonce, code)| { - (balance.to_alloy(), nonce.to_alloy(), Bytes::from(code.0)) - }); + let balance = provider.get_balance(address, block_id); + let nonce = provider.get_transaction_count(address, block_id); + let code = + provider.get_code_at(address, block_id.unwrap_or(BlockNumberOrTag::Latest.into())); + let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); (resp, address) }); ProviderRequest::Account(fut) @@ -242,7 +222,8 @@ where fn request_full_block(&mut self, number: BlockId, sender: FullBlockSender) { let provider = self.provider.clone(); let fut = Box::pin(async move { - let block = provider.get_block_with_txs(number).await; + let block = + provider.get_block(number, true).await.wrap_err("could not fetch block {number:?}"); (sender, block, number) }); @@ -253,7 +234,10 @@ where fn request_transaction(&mut self, tx: B256, sender: TransactionSender) { let provider = self.provider.clone(); let fut = Box::pin(async move { - let block = provider.get_transaction(tx.to_ethers()).await; + let block = provider + .get_transaction_by_hash(tx) + .await + .wrap_err("could not get transaction {tx}"); (sender, block, tx) }); @@ -267,28 +251,32 @@ where entry.get_mut().push(listener); } Entry::Vacant(entry) => { - trace!(target: "backendhandler", "preparing block hash request, number={}", number); + trace!(target: "backendhandler", number, "preparing block hash request"); entry.insert(vec![listener]); let provider = self.provider.clone(); let fut = Box::pin(async move { - let block = provider.get_block(number).await; + let block = provider + .get_block_by_number(number.into(), false) + .await + .wrap_err("failed to get block"); let block_hash = match block { Ok(Some(block)) => Ok(block + .header .hash .expect("empty block hash on mined block, this should never happen")), Ok(None) => { warn!(target: "backendhandler", ?number, "block not found"); // if no block was returned then the block does not exist, in which case // we return empty hash - Ok(KECCAK_EMPTY.to_ethers()) + Ok(KECCAK_EMPTY) } Err(err) => { error!(target: "backendhandler", %err, ?number, "failed to get block"); Err(err) } }; - (block_hash.map(|h| h.to_alloy()), number) + (block_hash, number) }); self.pending_requests.push(ProviderRequest::BlockHash(fut)); } @@ -296,9 +284,9 @@ where } } -impl Future for BackendHandler +impl

Future for BackendHandler

where - M: Middleware + Clone + Unpin + 'static, + P: TempProvider + Clone + Unpin + 'static, { type Output = (); @@ -318,7 +306,7 @@ where } Poll::Ready(None) => { trace!(target: "backendhandler", "last sender dropped, ready to drop (&flush cache)"); - return Poll::Ready(()) + return Poll::Ready(()); } Poll::Pending => break, } @@ -334,7 +322,7 @@ where let (balance, nonce, code) = match resp { Ok(res) => res, Err(err) => { - let err = Arc::new(eyre::Error::new(err)); + let err = Arc::new(err); if let Some(listeners) = pin.account_requests.remove(&addr) { listeners.into_iter().for_each(|l| { let _ = l.send(Err(DatabaseError::GetAccount( @@ -343,7 +331,7 @@ where ))); }) } - continue + continue; } }; @@ -369,7 +357,7 @@ where let _ = l.send(Ok(acc.clone())); }) } - continue + continue; } } ProviderRequest::Storage(fut) => { @@ -378,7 +366,7 @@ where Ok(value) => value, Err(err) => { // notify all listeners - let err = Arc::new(eyre::Error::new(err)); + let err = Arc::new(err); if let Some(listeners) = pin.storage_requests.remove(&(addr, idx)) { @@ -390,7 +378,7 @@ where ))); }) } - continue + continue; } }; @@ -403,7 +391,7 @@ where let _ = l.send(Ok(value)); }) } - continue + continue; } } ProviderRequest::BlockHash(fut) => { @@ -411,7 +399,7 @@ where let value = match block_hash { Ok(value) => value, Err(err) => { - let err = Arc::new(eyre::Error::new(err)); + let err = Arc::new(err); // notify all listeners if let Some(listeners) = pin.block_requests.remove(&number) { listeners.into_iter().for_each(|l| { @@ -421,7 +409,7 @@ where ))); }) } - continue + continue; } }; @@ -434,7 +422,7 @@ where let _ = l.send(Ok(value)); }) } - continue + continue; } } ProviderRequest::FullBlock(fut) => { @@ -443,26 +431,25 @@ where Ok(Some(block)) => Ok(block), Ok(None) => Err(DatabaseError::BlockNotFound(number)), Err(err) => { - let err = Arc::new(eyre::Error::new(err)); + let err = Arc::new(err); Err(DatabaseError::GetFullBlock(number, err)) } }; let _ = sender.send(msg); - continue + continue; } } ProviderRequest::Transaction(fut) => { if let Poll::Ready((sender, tx, tx_hash)) = fut.poll_unpin(cx) { let msg = match tx { - Ok(Some(tx)) => Ok(tx), - Ok(None) => Err(DatabaseError::TransactionNotFound(tx_hash)), + Ok(tx) => Ok(tx), Err(err) => { - let err = Arc::new(eyre::Error::new(err)); + let err = Arc::new(err); Err(DatabaseError::GetTransaction(tx_hash, err)) } }; let _ = sender.send(msg); - continue + continue; } } } @@ -473,7 +460,7 @@ where // If no new requests have been queued, break to // be polled again later. if pin.queued_requests.is_empty() { - return Poll::Pending + return Poll::Pending; } } } @@ -526,9 +513,9 @@ impl SharedBackend { /// dropped. /// /// NOTE: this should be called with `Arc` - pub async fn spawn_backend(provider: M, db: BlockchainDb, pin_block: Option) -> Self + pub async fn spawn_backend

(provider: P, db: BlockchainDb, pin_block: Option) -> Self where - M: Middleware + Unpin + 'static + Clone, + P: TempProvider + Unpin + 'static + Clone, { let (shared, handler) = Self::new(provider, db, pin_block); // spawn the provider handler to a task @@ -539,13 +526,13 @@ impl SharedBackend { /// Same as `Self::spawn_backend` but spawns the `BackendHandler` on a separate `std::thread` in /// its own `tokio::Runtime` - pub fn spawn_backend_thread( - provider: M, + pub fn spawn_backend_thread

( + provider: P, db: BlockchainDb, pin_block: Option, ) -> Self where - M: Middleware + Unpin + 'static + Clone, + P: TempProvider + Unpin + 'static + Clone, { let (shared, handler) = Self::new(provider, db, pin_block); @@ -568,13 +555,13 @@ impl SharedBackend { } /// Returns a new `SharedBackend` and the `BackendHandler` - pub fn new( - provider: M, + pub fn new

( + provider: P, db: BlockchainDb, pin_block: Option, - ) -> (Self, BackendHandler) + ) -> (Self, BackendHandler

) where - M: Middleware + Unpin + 'static + Clone, + P: TempProvider + Clone + 'static, { let (backend, backend_rx) = channel(1); let cache = Arc::new(FlushJsonBlockCacheDB(Arc::clone(db.cache()))); @@ -589,7 +576,7 @@ impl SharedBackend { } /// Returns the full block for the given block identifier - pub fn get_full_block(&self, block: impl Into) -> DatabaseResult> { + pub fn get_full_block(&self, block: impl Into) -> DatabaseResult { tokio::task::block_in_place(|| { let (sender, rx) = oneshot_channel(); let req = BackendRequest::FullBlock(block.into(), sender); @@ -672,7 +659,7 @@ impl DatabaseRef for SharedBackend { fn block_hash_ref(&self, number: U256) -> Result { if number > U256::from(u64::MAX) { - return Ok(KECCAK_EMPTY) + return Ok(KECCAK_EMPTY); } let number: U256 = number; let number = number.to(); @@ -695,7 +682,7 @@ mod tests { fork::{BlockchainDbMeta, CreateFork, JsonBlockCacheDB}, opts::EvmOpts, }; - use foundry_common::get_http_provider; + use foundry_common::provider::alloy::get_http_provider; use foundry_config::{Config, NamedChain}; use std::{collections::BTreeSet, path::PathBuf, sync::Arc}; const ENDPOINT: &str = "https://mainnet.infura.io/v3/40bee2d557ed4b52908c3e62345a3d8b"; @@ -754,7 +741,7 @@ mod tests { async fn can_read_write_cache() { let provider = get_http_provider(ENDPOINT); - let block_num = provider.get_block_number().await.unwrap().as_u64(); + let block_num = provider.get_block_number().await.unwrap(); let config = Config::figment(); let mut evm_opts = config.extract::().unwrap(); diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 67fdc90547d4b..fdc34dbafa7de 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -6,7 +6,7 @@ use crate::{ snapshot::Snapshots, }; use alloy_primitives::{Address, B256, U256}; -use ethers_core::types::BlockId; +use alloy_rpc_types::BlockId; use parking_lot::Mutex; use revm::{ db::{CacheDB, DatabaseRef}, @@ -267,7 +267,7 @@ impl DatabaseRef for ForkDbSnapshot { mod tests { use super::*; use crate::fork::BlockchainDbMeta; - use foundry_common::get_http_provider; + use foundry_common::provider::alloy::get_http_provider; use std::collections::BTreeSet; /// Demonstrates that `Database::basic` for `ForkedDatabase` will always return the diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index 35c15f6d96f2d..11e65916498d5 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -1,40 +1,32 @@ use crate::utils::apply_chain_and_block_specific_env_changes; use alloy_primitives::{Address, U256}; -use ethers_core::types::{Block, TxHash}; -use ethers_providers::Middleware; +use alloy_providers::provider::TempProvider; +use alloy_rpc_types::{Block, BlockNumberOrTag}; use eyre::WrapErr; -use foundry_common::{types::ToAlloy, NON_ARCHIVE_NODE_WARNING}; -use futures::TryFutureExt; +use foundry_common::NON_ARCHIVE_NODE_WARNING; + use revm::primitives::{BlockEnv, CfgEnv, Env, TxEnv}; /// Initializes a REVM block environment based on a forked /// ethereum provider. -pub async fn environment( - provider: &M, +// todo(onbjerg): these bounds needed cus of the bounds in `Provider`, can simplify? +pub async fn environment( + provider: &P, memory_limit: u64, gas_price: Option, override_chain_id: Option, pin_block: Option, origin: Address, -) -> eyre::Result<(Env, Block)> -where - M::Error: 'static, -{ +) -> eyre::Result<(Env, Block)> { let block_number = if let Some(pin_block) = pin_block { pin_block } else { - provider.get_block_number().await.wrap_err("Failed to get latest block number")?.as_u64() + provider.get_block_number().await.wrap_err("Failed to get latest block number")? }; let (fork_gas_price, rpc_chain_id, block) = tokio::try_join!( - provider - .get_gas_price() - .map_err(|err| { eyre::Error::new(err).wrap_err("Failed to get gas price") }), - provider - .get_chainid() - .map_err(|err| { eyre::Error::new(err).wrap_err("Failed to get chain id") }), - provider.get_block(block_number).map_err(|err| { - eyre::Error::new(err).wrap_err(format!("Failed to get block {block_number}")) - }) + provider.get_gas_price(), + provider.get_chain_id(), + provider.get_block_by_number(BlockNumberOrTag::Number(block_number), false) )?; let block = if let Some(block) = block { block @@ -43,7 +35,7 @@ where // If the `eth_getBlockByNumber` call succeeds, but returns null instead of // the block, and the block number is less than equal the latest block, then // the user is forking from a non-archive node with an older block number. - if block_number <= latest_block.as_u64() { + if block_number <= latest_block { error!("{NON_ARCHIVE_NODE_WARNING}"); } eyre::bail!( @@ -56,7 +48,7 @@ where }; let mut cfg = CfgEnv::default(); - cfg.chain_id = override_chain_id.unwrap_or(rpc_chain_id.as_u64()); + cfg.chain_id = override_chain_id.unwrap_or(rpc_chain_id.to::()); cfg.memory_limit = memory_limit; cfg.limit_contract_code_size = Some(usize::MAX); // EIP-3607 rejects transactions from senders with deployed code. @@ -67,20 +59,20 @@ where let mut env = Env { cfg, block: BlockEnv { - number: U256::from(block.number.expect("block number not found").as_u64()), - timestamp: block.timestamp.to_alloy(), - coinbase: block.author.unwrap_or_default().to_alloy(), - difficulty: block.difficulty.to_alloy(), - prevrandao: Some(block.mix_hash.map(|h| h.to_alloy()).unwrap_or_default()), - basefee: block.base_fee_per_gas.unwrap_or_default().to_alloy(), - gas_limit: block.gas_limit.to_alloy(), + number: block.header.number.expect("block number not found"), + timestamp: block.header.timestamp, + coinbase: block.header.miner, + difficulty: block.header.difficulty, + prevrandao: Some(block.header.mix_hash.unwrap_or_default()), + basefee: block.header.base_fee_per_gas.unwrap_or_default(), + gas_limit: block.header.gas_limit, ..Default::default() }, tx: TxEnv { caller: origin, - gas_price: gas_price.map(U256::from).unwrap_or(fork_gas_price.to_alloy()), - chain_id: Some(override_chain_id.unwrap_or(rpc_chain_id.as_u64())), - gas_limit: block.gas_limit.as_u64(), + gas_price: gas_price.map(U256::from).unwrap_or(fork_gas_price), + chain_id: Some(override_chain_id.unwrap_or(rpc_chain_id.to::())), + gas_limit: block.header.gas_limit.to::(), ..Default::default() }, }; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 480869bff9d65..d09466871fdb7 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -4,9 +4,11 @@ //! concurrently active pairs at once. use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; -use ethers_core::types::{BlockId, BlockNumber}; -use ethers_providers::Provider; -use foundry_common::{runtime_client::RuntimeClient, types::ToEthers, ProviderBuilder}; +use alloy_providers::provider::Provider; +use alloy_transport::BoxTransport; +use ethers::types::BlockNumber; +use foundry_common::provider::alloy::ProviderBuilder; + use foundry_config::Config; use futures::{ channel::mpsc::{channel, Receiver, Sender}, @@ -150,7 +152,7 @@ impl MultiFork { } } -type Handler = BackendHandler>>; +type Handler = BackendHandler>>; type CreateFuture = Pin> + Send>>; type CreateSender = OneshotSender>; @@ -225,7 +227,7 @@ impl MultiForkHandler { #[allow(irrefutable_let_patterns)] if let ForkTask::Create(_, in_progress, _, additional) = task { if in_progress == id { - return Some(additional) + return Some(additional); } } } @@ -243,7 +245,7 @@ impl MultiForkHandler { // there could already be a task for the requested fork in progress if let Some(in_progress) = self.find_in_progress_task(&fork_id) { in_progress.push(sender); - return + return; } // need to create a new fork @@ -304,7 +306,7 @@ impl Future for MultiForkHandler { Poll::Ready(None) => { // channel closed, but we still need to drive the fork handlers to completion trace!(target: "fork::multi", "request channel closed"); - break + break; } Poll::Pending => break, } @@ -365,7 +367,7 @@ impl Future for MultiForkHandler { if pin.handlers.is_empty() && pin.incoming.is_done() { trace!(target: "fork::multi", "completed"); - return Poll::Ready(()) + return Poll::Ready(()); } // periodically flush cached RPC state @@ -461,21 +463,17 @@ async fn create_fork(mut fork: CreateFork) -> eyre::Result<(CreatedFork, Handler // we need to use the block number from the block because the env's number can be different on // some L2s (e.g. Arbitrum). - let number = block - .number - .map(|num| num.as_u64()) - .unwrap_or_else(|| meta.block_env.number.to_ethers().as_u64()); + let number = block.header.number.unwrap_or(meta.block_env.number); // determine the cache path if caching is enabled let cache_path = if fork.enable_caching { - Config::foundry_block_cache_dir(meta.cfg_env.chain_id, number) + Config::foundry_block_cache_dir(meta.cfg_env.chain_id, number.to::()) } else { None }; let db = BlockchainDb::new(meta, cache_path); - let (backend, handler) = - SharedBackend::new(provider, db, Some(BlockId::Number(BlockNumber::Number(number.into())))); + let (backend, handler) = SharedBackend::new(provider, db, Some(number.to::().into())); let fork = CreatedFork::new(fork, backend); Ok((fork, handler)) } diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 6e1ae5aa07647..14b3e2cfcf33e 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,10 +1,14 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; -use ethers_core::types::{Block, TxHash}; -use ethers_providers::{Middleware, Provider}; +use alloy_rpc_types::Block; +use ethers::providers::{Middleware, Provider}; use eyre::WrapErr; -use foundry_common::{self, ProviderBuilder, RpcUrl, ALCHEMY_FREE_TIER_CUPS}; +use foundry_common::{ + self, + provider::alloy::{ProviderBuilder, RpcUrl}, + ALCHEMY_FREE_TIER_CUPS, +}; use foundry_compilers::utils::RuntimeOrHandle; use foundry_config::{Chain, Config}; use revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}; @@ -75,7 +79,7 @@ impl EvmOpts { pub async fn fork_evm_env( &self, fork_url: impl AsRef, - ) -> eyre::Result<(revm::primitives::Env, Block)> { + ) -> eyre::Result<(revm::primitives::Env, Block)> { let fork_url = fork_url.as_ref(); let provider = ProviderBuilder::new(fork_url) .compute_units_per_second(self.get_compute_units_per_second()) @@ -158,7 +162,7 @@ impl EvmOpts { /// - mainnet otherwise pub fn get_chain_id(&self) -> u64 { if let Some(id) = self.env.chain_id { - return id + return id; } self.get_remote_chain_id().unwrap_or(Chain::mainnet()).id() } @@ -171,7 +175,7 @@ impl EvmOpts { if self.no_rpc_rate_limit { u64::MAX } else if let Some(cups) = self.compute_units_per_second { - return cups + return cups; } else { ALCHEMY_FREE_TIER_CUPS } diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index fac8e7a5c4ffb..996408198caf0 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,8 +1,12 @@ use alloy_json_abi::{Function, JsonAbi as Abi}; use alloy_primitives::{Address, FixedBytes, B256}; -use ethers_core::types::{ActionType, Block, CallType, Chain, Transaction, H256, U256}; +use alloy_rpc_types::{Block, Transaction}; +use ethers::types::{ActionType, CallType, Chain, H256, U256}; use eyre::ContextCompat; use foundry_common::types::ToAlloy; +pub use foundry_compilers::utils::RuntimeOrHandle; +pub use revm::primitives::State as StateChangeset; + use revm::{ interpreter::{opcode, opcode::spec_opcode_gas, CallScheme, CreateInputs, InstructionResult}, primitives::{CreateScheme, Eval, Halt, SpecId, TransactTo}, @@ -10,10 +14,8 @@ use revm::{ use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; -pub use foundry_compilers::utils::RuntimeOrHandle; -pub use revm::primitives::State as StateChangeset; - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +// TODO(onbjerg): Remove this and use `CallKind` from the tracer. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "UPPERCASE")] #[derive(Default)] pub enum CallKind { @@ -140,21 +142,18 @@ pub fn halt_to_instruction_result(halt: Halt) -> InstructionResult { /// /// This checks for: /// - prevrandao mixhash after merge -pub fn apply_chain_and_block_specific_env_changes( - env: &mut revm::primitives::Env, - block: &Block, -) { +pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::Env, block: &Block) { if let Ok(chain) = Chain::try_from(env.cfg.chain_id) { - let block_number = block.number.unwrap_or_default(); + let block_number = block.header.number.unwrap_or_default(); match chain { Chain::Mainnet => { // after merge difficulty is supplanted with prevrandao EIP-4399 - if block_number.as_u64() >= 15_537_351u64 { + if block_number.to::() >= 15_537_351u64 { env.block.difficulty = env.block.prevrandao.unwrap_or_default().into(); } - return + return; } Chain::Arbitrum | Chain::ArbitrumGoerli | @@ -173,7 +172,7 @@ pub fn apply_chain_and_block_specific_env_changes( } // if difficulty is `0` we assume it's past merge - if block.difficulty.is_zero() { + if block.header.difficulty.is_zero() { env.block.difficulty = env.block.prevrandao.unwrap_or_default().into(); } } @@ -244,28 +243,29 @@ pub fn get_function( /// Configures the env for the transaction pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { - env.tx.caller = tx.from.to_alloy(); - env.tx.gas_limit = tx.gas.as_u64(); - env.tx.gas_price = tx.gas_price.unwrap_or_default().to_alloy(); - env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(|g| g.to_alloy()); - env.tx.nonce = Some(tx.nonce.as_u64()); + env.tx.caller = tx.from; + env.tx.gas_limit = tx.gas.to(); + env.tx.gas_price = tx.gas_price.unwrap_or_default().to(); + env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(|g| g.to()); + env.tx.nonce = Some(tx.nonce.to()); env.tx.access_list = tx .access_list .clone() .unwrap_or_default() - .0 .into_iter() .map(|item| { ( - item.address.to_alloy(), - item.storage_keys.into_iter().map(h256_to_u256_be).map(|g| g.to_alloy()).collect(), + item.address, + item.storage_keys + .into_iter() + .map(|key| alloy_primitives::U256::from_be_bytes(key.0)) + .collect(), ) }) .collect(); - env.tx.value = tx.value.to_alloy(); + env.tx.value = tx.value.to(); env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); - env.tx.transact_to = - tx.to.map(|tx| tx.to_alloy()).map(TransactTo::Call).unwrap_or_else(TransactTo::create) + env.tx.transact_to = tx.to.map(TransactTo::Call).unwrap_or_else(TransactTo::create) } /// Get the address of a contract creation diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 863de256d9760..b57acc4e9b08b 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -562,7 +562,7 @@ impl Executor { // network conditions - the actual gas price is kept in `self.block` and is applied by // the cheatcode handler if it is enabled block: BlockEnv { - basefee: U256::from(0), + basefee: U256::ZERO, gas_limit: self.gas_limit, ..self.env.block.clone() }, @@ -572,7 +572,7 @@ impl Executor { data, value, // As above, we set the gas price to 0. - gas_price: U256::from(0), + gas_price: U256::ZERO, gas_priority_fee: None, gas_limit: self.gas_limit.to(), ..self.env.tx.clone() diff --git a/crates/evm/evm/src/inspectors/mod.rs b/crates/evm/evm/src/inspectors/mod.rs index b781ce96c8dd2..20dd340d3cda0 100644 --- a/crates/evm/evm/src/inspectors/mod.rs +++ b/crates/evm/evm/src/inspectors/mod.rs @@ -3,7 +3,7 @@ pub use foundry_cheatcodes::{self as cheatcodes, Cheatcodes, CheatsConfig}; pub use foundry_evm_coverage::CoverageCollector; pub use foundry_evm_fuzz::Fuzzer; -pub use foundry_evm_traces::Tracer; +pub use foundry_evm_traces::{StackSnapshotType, TracingInspector, TracingInspectorConfig}; mod access_list; pub use access_list::AccessListTracer; diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 35e9e67736fd1..87cc29b518653 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -1,6 +1,6 @@ use super::{ Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Debugger, Fuzzer, LogCollector, - TracePrinter, Tracer, + StackSnapshotType, TracePrinter, TracingInspector, TracingInspectorConfig, }; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers_core::types::Log; @@ -207,7 +207,7 @@ pub struct InspectorStack { pub fuzzer: Option, pub log_collector: Option, pub printer: Option, - pub tracer: Option, + pub tracer: Option, } impl InspectorStack { @@ -289,7 +289,17 @@ impl InspectorStack { /// Set whether to enable the tracer. #[inline] pub fn tracing(&mut self, yes: bool) { - self.tracer = yes.then(Default::default); + self.tracer = yes.then(|| { + TracingInspector::new(TracingInspectorConfig { + record_steps: false, + record_memory_snapshots: false, + record_stack_snapshots: StackSnapshotType::None, + record_state_diff: false, + exclude_precompile_calls: false, + record_call_return_data: true, + record_logs: true, + }) + }); } /// Collects all the data gathered during inspection into a single struct. @@ -304,7 +314,7 @@ impl InspectorStack { cheatcodes.labels.clone().into_iter().map(|l| (l.0, l.1)).collect() }) .unwrap_or_default(), - traces: self.tracer.map(|tracer| tracer.traces), + traces: self.tracer.map(|tracer| tracer.get_traces().clone()), debug: self.debugger.map(|debugger| debugger.arena), coverage: self.coverage.map(|coverage| coverage.maps), script_wallets: self diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 62181c2300c9b..72fded966fb58 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -49,6 +49,7 @@ pub struct BaseCounterExample { /// Contract name if it exists pub contract_name: Option, /// Traces + #[serde(skip)] pub traces: Option, #[serde(skip)] pub args: Vec, diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 7e11d23f8f543..d3fe2338e9b3b 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -21,9 +21,7 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true -revm.workspace = true - -ethers-core.workspace = true +reth-revm-inspectors = { git = "https://github.com/paradigmxyz/reth/", branch = "main" } eyre = "0.6" futures = "0.3" diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index e37880249e74e..f7c0abb8dd2e7 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -2,11 +2,11 @@ use crate::{ identifier::{ AddressIdentity, LocalTraceIdentifier, SingleSignaturesIdentifier, TraceIdentifier, }, - CallTrace, CallTraceArena, TraceCallData, TraceLog, TraceRetData, + CallTrace, CallTraceArena, DecodedCallData, DecodedCallLog, DecodedCallTrace, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function, JsonAbi as Abi}; -use alloy_primitives::{Address, Selector, B256}; +use alloy_primitives::{Address, Log, Selector, B256}; use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ abi::{Console, HardhatConsole, Vm, HARDHAT_CONSOLE_SELECTOR_PATCHES}, @@ -19,7 +19,6 @@ use foundry_evm_core::{ use itertools::Itertools; use once_cell::sync::OnceCell; use std::collections::{hash_map::Entry, BTreeMap, HashMap}; -use tracing::field; mod precompiles; @@ -198,11 +197,24 @@ impl CallTraceDecoder { #[inline(always)] fn addresses<'a>( &'a self, - trace: &'a CallTraceArena, + arena: &'a CallTraceArena, ) -> impl Iterator)> + 'a { - trace.addresses().into_iter().filter(|&(address, _)| { - !self.labels.contains_key(address) || !self.contracts.contains_key(address) - }) + arena + .nodes() + .iter() + .map(|node| { + ( + &node.trace.address, + if node.trace.kind.is_any_create() { + Some(node.trace.output.as_ref()) + } else { + None + }, + ) + }) + .filter(|(address, _)| { + !self.labels.contains_key(*address) || !self.contracts.contains_key(*address) + }) } fn collect_identities(&mut self, identities: Vec>) { @@ -250,45 +262,31 @@ impl CallTraceDecoder { } } - /// Decodes all nodes in the specified call trace. - pub async fn decode(&self, traces: &mut CallTraceArena) { - for node in &mut traces.arena { - self.decode_function(&mut node.trace).await; - for log in node.logs.iter_mut() { - self.decode_event(log).await; - } - } - } - - async fn decode_function(&self, trace: &mut CallTrace) { - let span = trace_span!("decode_function", label = field::Empty).entered(); - + pub async fn decode_function(&self, trace: &CallTrace) -> DecodedCallTrace { // Decode precompile - if precompiles::decode(trace, 1) { - return; + if let Some((label, func)) = precompiles::decode(trace, 1) { + return DecodedCallTrace { + label: Some(label), + return_data: None, + contract: None, + func: Some(func), + }; } // Set label - if trace.label.is_none() { - if let Some(label) = self.labels.get(&trace.address) { - span.record("label", label); - trace.label = Some(label.clone()); - } - } + let label = self.labels.get(&trace.address).cloned(); // Set contract name - if trace.contract.is_none() { - if let Some(contract) = self.contracts.get(&trace.address) { - trace.contract = Some(contract.clone()); - } - } - - let TraceCallData::Raw(cdata) = &trace.data else { return }; + let contract = self.contracts.get(&trace.address).cloned(); + let cdata = &trace.data; if trace.address == DEFAULT_CREATE2_DEPLOYER { - trace!("decoded as create2"); - trace.data = TraceCallData::Decoded { signature: "create2".to_string(), args: vec![] }; - return; + return DecodedCallTrace { + label, + return_data: None, + contract, + func: Some(DecodedCallData { signature: "create2".to_string(), args: vec![] }), + }; } if cdata.len() >= SELECTOR_LEN { @@ -307,50 +305,57 @@ impl CallTraceDecoder { &functions } }; - let [func, ..] = &functions[..] else { return }; - self.decode_function_input(trace, func); - self.decode_function_output(trace, functions); + let [func, ..] = &functions[..] else { + return DecodedCallTrace { label, return_data: None, contract, func: None }; + }; + + DecodedCallTrace { + label, + func: Some(self.decode_function_input(trace, func)), + return_data: self.decode_function_output(trace, functions), + contract, + } } else { let has_receive = self.receive_contracts.contains(&trace.address); let signature = if cdata.is_empty() && has_receive { "receive()" } else { "fallback()" }.into(); let args = if cdata.is_empty() { Vec::new() } else { vec![cdata.to_string()] }; - trace!(?signature, ?args, "decoded fallback data"); - trace.data = TraceCallData::Decoded { signature, args }; - - if let TraceRetData::Raw(rdata) = &trace.output { - if !trace.success { - let decoded = - decode::decode_revert(rdata, Some(&self.errors), Some(trace.status)); - trace!(?decoded, "decoded fallback output"); - trace.output = TraceRetData::Decoded(decoded); - } + DecodedCallTrace { + label, + return_data: if !trace.success { + Some(decode::decode_revert( + &trace.output, + Some(&self.errors), + Some(trace.status), + )) + } else { + None + }, + contract, + func: Some(DecodedCallData { signature, args }), } } } /// Decodes a function's input into the given trace. - fn decode_function_input(&self, trace: &mut CallTrace, func: &Function) { - let TraceCallData::Raw(data) = &trace.data else { return }; + fn decode_function_input(&self, trace: &CallTrace, func: &Function) -> DecodedCallData { let mut args = None; - if data.len() >= SELECTOR_LEN { + if trace.data.len() >= SELECTOR_LEN { if trace.address == CHEATCODE_ADDRESS { // Try to decode cheatcode inputs in a more custom way - if let Some(v) = self.decode_cheatcode_inputs(func, data) { + if let Some(v) = self.decode_cheatcode_inputs(func, &trace.data) { args = Some(v); } } if args.is_none() { - if let Ok(v) = func.abi_decode_input(&data[SELECTOR_LEN..], false) { + if let Ok(v) = func.abi_decode_input(&trace.data[SELECTOR_LEN..], false) { args = Some(v.iter().map(|value| self.apply_label(value)).collect()); } } } - let signature = func.signature(); - trace!(?signature, ?args, "decoded function input"); - trace.data = TraceCallData::Decoded { signature, args: args.unwrap_or_default() }; + DecodedCallData { signature: func.signature(), args: args.unwrap_or_default() } } /// Custom decoding for cheatcode inputs. @@ -420,38 +425,34 @@ impl CallTraceDecoder { } /// Decodes a function's output into the given trace. - fn decode_function_output(&self, trace: &mut CallTrace, funcs: &[Function]) { - let TraceRetData::Raw(data) = &trace.output else { return }; - let mut s = None; + fn decode_function_output(&self, trace: &CallTrace, funcs: &[Function]) -> Option { + let data = &trace.output; if trace.success { if trace.address == CHEATCODE_ADDRESS { - s = funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)); + if let Some(decoded) = + funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)) + { + return Some(decoded); + } } - if s.is_none() { - if let Some(values) = - funcs.iter().find_map(|func| func.abi_decode_output(data, false).ok()) - { - // Functions coming from an external database do not have any outputs specified, - // and will lead to returning an empty list of values. - if !values.is_empty() { - s = Some( - values - .iter() - .map(|value| self.apply_label(value)) - .format(", ") - .to_string(), - ); - } + if let Some(values) = + funcs.iter().find_map(|func| func.abi_decode_output(data, false).ok()) + { + // Functions coming from an external database do not have any outputs specified, + // and will lead to returning an empty list of values. + if values.is_empty() { + return None; } + + return Some( + values.iter().map(|value| self.apply_label(value)).format(", ").to_string(), + ); } - } else { - s = decode::maybe_decode_revert(data, Some(&self.errors), Some(trace.status)); - } - if let Some(decoded) = s { - trace!(?decoded, "decoded function output"); - trace.output = TraceRetData::Decoded(decoded); + None + } else { + Some(decode::decode_revert(data, Some(&self.errors), Some(trace.status))) } } @@ -468,29 +469,26 @@ impl CallTraceDecoder { } /// Decodes an event. - async fn decode_event(&self, log: &mut TraceLog) { - let TraceLog::Raw(raw_log) = log else { return }; - let &[t0, ..] = raw_log.topics() else { return }; + pub async fn decode_event<'a>(&self, log: &'a Log) -> DecodedCallLog<'a> { + let &[t0, ..] = log.topics() else { return DecodedCallLog::Raw(log) }; let mut events = Vec::new(); - let events = match self.events.get(&(t0, raw_log.topics().len() - 1)) { + let events = match self.events.get(&(t0, log.topics().len() - 1)) { Some(es) => es, None => { if let Some(identifier) = &self.signature_identifier { if let Some(event) = identifier.write().await.identify_event(&t0[..]).await { - events.push(get_indexed_event(event, raw_log)); + events.push(get_indexed_event(event, log)); } } &events } }; for event in events { - if let Ok(decoded) = event.decode_log(raw_log, false) { + if let Ok(decoded) = event.decode_log(log, false) { let params = reconstruct_params(event, &decoded); - let name = event.name.clone(); - trace!(?name, ?params, "decoded event"); - *log = TraceLog::Decoded( - name, + return DecodedCallLog::Decoded( + event.name.clone(), params .into_iter() .zip(event.inputs.iter()) @@ -501,9 +499,10 @@ impl CallTraceDecoder { }) .collect(), ); - break; } } + + DecodedCallLog::Raw(log) } fn apply_label(&self, value: &DynSolValue) -> String { diff --git a/crates/evm/traces/src/decoder/precompiles.rs b/crates/evm/traces/src/decoder/precompiles.rs index 801ec92df844b..1475208f40c88 100644 --- a/crates/evm/traces/src/decoder/precompiles.rs +++ b/crates/evm/traces/src/decoder/precompiles.rs @@ -1,4 +1,4 @@ -use crate::{CallTrace, TraceCallData}; +use crate::{CallTrace, DecodedCallData}; use alloy_primitives::{B256, U256}; use alloy_sol_types::{abi, sol, SolCall}; use itertools::Itertools; @@ -36,20 +36,20 @@ macro_rules! tri { ($e:expr) => { match $e { Ok(x) => x, - Err(_) => return false, + Err(_) => return None, } }; } -/// Tries to decode a precompile call. Returns `true` if successful. -pub(super) fn decode(trace: &mut CallTrace, _chain_id: u64) -> bool { +/// Tries to decode a precompile call. Returns `Some` if successful. +pub(super) fn decode(trace: &CallTrace, _chain_id: u64) -> Option<(String, DecodedCallData)> { let [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, x @ 0x01..=0x0a] = trace.address.0 .0 else { - return false + return None }; - let TraceCallData::Raw(data) = &trace.data else { return false }; + let data = &trace.data; let (signature, args) = match x { 0x01 => { @@ -74,13 +74,7 @@ pub(super) fn decode(trace: &mut CallTrace, _chain_id: u64) -> bool { 0x00 | 0x0b.. => unreachable!(), }; - // TODO: Other chain precompiles - - trace!(?signature, ?args, "decoded precompile call"); - trace.data = TraceCallData::Decoded { signature: signature.to_string(), args }; - trace.label = Some("PRECOMPILES".into()); - - true + Some(("PRECOMPILES".into(), DecodedCallData { signature: signature.to_string(), args })) } // Note: we use the ABI decoder, but this is not necessarily ABI-encoded data. It's just a diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index dc25ab3a7cece..3d5d09635807b 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -6,22 +6,12 @@ #[macro_use] extern crate tracing; - -use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; -use ethers_core::types::{DefaultFrame, GethDebugTracingOptions, StructLog}; -use foundry_common::{ - contracts::{ContractsByAddress, ContractsByArtifact}, - types::ToEthers, -}; -use foundry_evm_core::{constants::CHEATCODE_ADDRESS, debug::Instruction, utils::CallKind}; -use hashbrown::HashMap; -use itertools::Itertools; -use revm::interpreter::{opcode, CallContext, InstructionResult, Stack}; +use alloy_primitives::{Log, U256}; +use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_evm_core::constants::CHEATCODE_ADDRESS; +use futures::{future::BoxFuture, FutureExt}; use serde::{Deserialize, Serialize}; -use std::{ - collections::{BTreeMap, HashSet}, - fmt, -}; +use std::{collections::BTreeMap, fmt::Write}; use yansi::{Color, Paint}; /// Call trace address identifiers. @@ -33,160 +23,38 @@ use identifier::LocalTraceIdentifier; mod decoder; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; -mod inspector; -pub use inspector::Tracer; - -mod node; -pub use node::CallTraceNode; +use reth_revm_inspectors::tracing::types::LogCallOrder; +pub use reth_revm_inspectors::tracing::{ + types::{CallKind, CallTrace, CallTraceNode}, + CallTraceArena, GethTraceBuilder, ParityTraceBuilder, StackSnapshotType, TracingInspector, + TracingInspectorConfig, +}; pub type Traces = Vec<(TraceKind, CallTraceArena)>; -/// An arena of [CallTraceNode]s -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct CallTraceArena { - /// The arena of nodes - pub arena: Vec, +#[derive(Default, Debug, Eq, PartialEq)] +pub struct DecodedCallData { + pub signature: String, + pub args: Vec, } -impl Default for CallTraceArena { - fn default() -> Self { - CallTraceArena { arena: vec![Default::default()] } - } +#[derive(Default, Debug)] +pub struct DecodedCallTrace { + pub label: Option, + pub return_data: Option, + pub func: Option, + pub contract: Option, } -impl CallTraceArena { - /// Pushes a new trace into the arena, returning the trace ID - pub fn push_trace(&mut self, entry: usize, new_trace: CallTrace) -> usize { - match new_trace.depth { - // The entry node, just update it - 0 => { - self.arena[0].trace = new_trace; - 0 - } - // We found the parent node, add the new trace as a child - _ if self.arena[entry].trace.depth == new_trace.depth - 1 => { - let id = self.arena.len(); - - let trace_location = self.arena[entry].children.len(); - self.arena[entry].ordering.push(LogCallOrder::Call(trace_location)); - let node = CallTraceNode { - parent: Some(entry), - trace: new_trace, - idx: id, - ..Default::default() - }; - self.arena.push(node); - self.arena[entry].children.push(id); - - id - } - // We haven't found the parent node, go deeper - _ => self.push_trace( - *self.arena[entry].children.last().expect("Disconnected trace"), - new_trace, - ), - } - } - - pub fn addresses(&self) -> HashSet<(&Address, Option<&[u8]>)> { - self.arena - .iter() - .map(|node| { - if node.trace.created() { - if let TraceRetData::Raw(bytes) = &node.trace.output { - return (&node.trace.address, Some(bytes.as_ref())) - } - } - - (&node.trace.address, None) - }) - .collect() - } - - // Recursively fill in the geth trace by going through the traces - fn add_to_geth_trace( - &self, - storage: &mut HashMap>, - trace_node: &CallTraceNode, - struct_logs: &mut Vec, - opts: &GethDebugTracingOptions, - ) { - let mut child_id = 0; - // Iterate over the steps inside the given trace - for step in trace_node.trace.steps.iter() { - let mut log: StructLog = step.into(); - - // Fill in memory and storage depending on the options - if !opts.disable_storage.unwrap_or_default() { - let contract_storage = storage.entry(step.contract).or_default(); - if let Some((key, value)) = step.state_diff { - contract_storage.insert(B256::from(key), B256::from(value)); - log.storage = Some( - contract_storage - .iter_mut() - .map(|t| (t.0.to_ethers(), t.1.to_ethers())) - .collect(), - ); - } - } - if opts.disable_stack.unwrap_or_default() { - log.stack = None; - } - if !opts.enable_memory.unwrap_or_default() { - log.memory = None; - } - - // Add step to geth trace - struct_logs.push(log); - - // Descend into a child trace if the step was a call - if let Instruction::OpCode( - opcode::CREATE | - opcode::CREATE2 | - opcode::DELEGATECALL | - opcode::CALL | - opcode::STATICCALL | - opcode::CALLCODE, - ) = step.op - { - self.add_to_geth_trace( - storage, - &self.arena[trace_node.children[child_id]], - struct_logs, - opts, - ); - child_id += 1; - } - } - } - - /// Generate a geth-style trace e.g. for debug_traceTransaction - pub fn geth_trace( - &self, - receipt_gas_used: U256, - opts: GethDebugTracingOptions, - ) -> DefaultFrame { - if self.arena.is_empty() { - return Default::default() - } - - let mut storage = HashMap::new(); - // Fetch top-level trace - let main_trace_node = &self.arena[0]; - let main_trace = &main_trace_node.trace; - // Start geth trace - let mut acc = DefaultFrame { - // If the top-level trace succeeded, then it was a success - failed: !main_trace.success, - gas: receipt_gas_used.to_ethers(), - return_value: main_trace.output.to_bytes().to_ethers(), - ..Default::default() - }; - - self.add_to_geth_trace(&mut storage, main_trace_node, &mut acc.struct_logs, &opts); - - acc - } +#[derive(Debug)] +pub enum DecodedCallLog<'a> { + /// A raw log. + Raw(&'a Log), + /// A decoded log. + /// + /// The first member of the tuple is the event name, and the second is a vector of decoded + /// parameters. + Decoded(String, Vec<(String, String)>), } const PIPE: &str = " │ "; @@ -195,19 +63,27 @@ const BRANCH: &str = " ├─ "; const CALL: &str = "→ "; const RETURN: &str = "← "; -impl fmt::Display for CallTraceArena { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fn inner( - arena: &CallTraceArena, - f: &mut fmt::Formatter<'_>, - idx: usize, - left: &str, - child: &str, - ) -> fmt::Result { - let node = &arena.arena[idx]; +/// Render a collection of call traces. +/// +/// The traces will be decoded using the given decoder, if possible. +pub async fn render_trace_arena( + arena: &CallTraceArena, + decoder: &CallTraceDecoder, +) -> Result { + fn inner<'a>( + arena: &'a [CallTraceNode], + decoder: &'a CallTraceDecoder, + s: &'a mut String, + idx: usize, + left: &'a str, + child: &'a str, + ) -> BoxFuture<'a, Result<(), std::fmt::Error>> { + async move { + let node = &arena[idx]; // Display trace header - writeln!(f, "{left}{}", node.trace)?; + let (trace, return_data) = render_trace(&node.trace, decoder).await?; + writeln!(s, "{left}{}", trace)?; // Display logs and subcalls let left_prefix = format!("{child}{BRANCH}"); @@ -215,11 +91,12 @@ impl fmt::Display for CallTraceArena { for child in &node.ordering { match child { LogCallOrder::Log(index) => { - let log = node.logs[*index].to_string(); + let log = render_trace_log(&node.logs[*index], decoder).await?; + // Prepend our tree structure symbols to each line of the displayed log log.lines().enumerate().try_for_each(|(i, line)| { writeln!( - f, + s, "{}{}", if i == 0 { &left_prefix } else { &right_prefix }, line @@ -227,332 +104,146 @@ impl fmt::Display for CallTraceArena { })?; } LogCallOrder::Call(index) => { - inner(arena, f, node.children[*index], &left_prefix, &right_prefix)?; + inner( + arena, + decoder, + s, + node.children[*index], + &left_prefix, + &right_prefix, + ) + .await?; } } } // Display trace return data let color = trace_color(&node.trace); - write!(f, "{child}{EDGE}{}", color.paint(RETURN))?; - if node.trace.created() { - match &node.trace.output { - TraceRetData::Raw(bytes) => { - writeln!(f, "{} bytes of code", bytes.len())?; + write!(s, "{child}{EDGE}{}", color.paint(RETURN))?; + if node.trace.kind.is_any_create() { + match &return_data { + None => { + writeln!(s, "{} bytes of code", node.trace.data.len())?; } - TraceRetData::Decoded(val) => { - writeln!(f, "{val}")?; + Some(val) => { + writeln!(s, "{val}")?; } } } else { - writeln!(f, "{}", node.trace.output)?; + match &return_data { + None if node.trace.output.is_empty() => writeln!(s, "()")?, + None => writeln!(s, "{}", node.trace.output)?, + Some(val) => writeln!(s, "{val}")?, + } } Ok(()) } - - inner(self, f, 0, " ", " ") + .boxed() } -} -/// A raw or decoded log. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum TraceLog { - /// A raw log - Raw(RawLog), - /// A decoded log. - /// - /// The first member of the tuple is the event name, and the second is a vector of decoded - /// parameters. - Decoded(String, Vec<(String, String)>), + let mut s = String::new(); + inner(arena.nodes(), decoder, &mut s, 0, " ", " ").await?; + Ok(s) } -impl fmt::Display for TraceLog { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - TraceLog::Raw(log) => { - for (i, topic) in log.topics().iter().enumerate() { - writeln!( - f, - "{:>13}: {}", - if i == 0 { "emit topic 0".to_string() } else { format!("topic {i}") }, - Paint::cyan(format!("{topic:?}")) - )?; - } - - write!(f, " data: {}", Paint::cyan(hex::encode_prefixed(&log.data))) - } - TraceLog::Decoded(name, params) => { - let params = params - .iter() - .map(|(name, value)| format!("{name}: {value}")) - .collect::>() - .join(", "); - - write!(f, "emit {}({params})", Paint::cyan(name.clone())) - } - } - } -} - -/// Ordering enum for calls and logs +/// Render a call trace. /// -/// i.e. if Call 0 occurs before Log 0, it will be pushed into the `CallTraceNode`'s ordering before -/// the log. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub enum LogCallOrder { - Log(usize), - Call(usize), -} - -/// Raw or decoded calldata. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub enum TraceCallData { - /// Raw calldata bytes. - Raw(Bytes), - /// Decoded calldata. - Decoded { - /// The function signature. - signature: String, - /// The function arguments. - args: Vec, - }, -} - -impl Default for TraceCallData { - fn default() -> Self { - Self::Raw(Bytes::new()) - } -} - -impl TraceCallData { - pub fn as_bytes(&self) -> &[u8] { - match self { - TraceCallData::Raw(raw) => raw, - TraceCallData::Decoded { .. } => &[], - } - } -} - -/// Raw or decoded return data. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub enum TraceRetData { - /// Raw return data. - Raw(Bytes), - /// Decoded return data. - Decoded(String), -} - -impl Default for TraceRetData { - fn default() -> Self { - Self::Raw(Bytes::new()) - } -} - -impl TraceRetData { - /// Returns the data as [`Bytes`] - pub fn to_bytes(&self) -> Bytes { - match self { - TraceRetData::Raw(raw) => raw.clone(), - TraceRetData::Decoded(val) => val.as_bytes().to_vec().into(), - } - } - - pub fn to_raw(&self) -> Vec { - self.to_bytes().to_vec() - } -} - -impl fmt::Display for TraceRetData { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match &self { - TraceRetData::Raw(bytes) => { - if bytes.is_empty() { - write!(f, "()") +/// The trace will be decoded using the given decoder, if possible. +pub async fn render_trace( + trace: &CallTrace, + decoder: &CallTraceDecoder, +) -> Result<(String, Option), std::fmt::Error> { + let mut s = String::new(); + write!(&mut s, "[{}] ", trace.gas_used)?; + let address = trace.address.to_checksum(None); + + let decoded = decoder.decode_function(trace).await; + if trace.kind.is_any_create() { + write!( + &mut s, + "{}{} {}@{}", + Paint::yellow(CALL), + Paint::yellow("new"), + decoded.label.as_deref().unwrap_or(""), + address + )?; + } else { + let (func_name, inputs) = match &decoded.func { + Some(DecodedCallData { signature, args }) => { + let name = signature.split('(').next().unwrap(); + (name.to_string(), args.join(", ")) + } + None => { + debug!(target: "evm::traces", trace=?trace, "unhandled raw calldata"); + if trace.data.len() < 4 { + ("fallback".to_string(), hex::encode(&trace.data)) } else { - bytes.fmt(f) + let (selector, data) = trace.data.split_at(4); + (hex::encode(selector), hex::encode(data)) } } - TraceRetData::Decoded(decoded) => f.write_str(decoded), - } - } -} + }; -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct CallTraceStep { - // Fields filled in `step` - /// Call depth - pub depth: u64, - /// Program counter before step execution - pub pc: usize, - /// Opcode to be executed - pub op: Instruction, - /// Current contract address - pub contract: Address, - /// Stack before step execution - pub stack: Stack, - /// Memory before step execution - pub memory: Vec, - /// Remaining gas before step execution - pub gas: u64, - /// Gas refund counter before step execution - pub gas_refund_counter: u64, - - // Fields filled in `step_end` - /// Gas cost of step execution - pub gas_cost: u64, - /// Change of the contract state after step execution (effect of the SLOAD/SSTORE instructions) - pub state_diff: Option<(U256, U256)>, - /// Error (if any) after step execution - pub error: Option, -} + let action = match trace.kind { + CallKind::Call => "", + CallKind::StaticCall => " [staticcall]", + CallKind::CallCode => " [callcode]", + CallKind::DelegateCall => " [delegatecall]", + CallKind::Create | CallKind::Create2 => unreachable!(), + }; -impl From<&CallTraceStep> for StructLog { - fn from(step: &CallTraceStep) -> Self { - StructLog { - depth: step.depth, - error: step.error.clone(), - gas: step.gas, - gas_cost: step.gas_cost, - memory: Some(convert_memory(&step.memory)), - op: step.op.to_string(), - pc: step.pc as u64, - refund_counter: if step.gas_refund_counter > 0 { - Some(step.gas_refund_counter) + let color = trace_color(trace); + write!( + &mut s, + "{addr}::{func_name}{opt_value}({inputs}){action}", + addr = color.paint(decoded.label.as_deref().unwrap_or(&address)), + func_name = color.paint(func_name), + opt_value = if trace.value == U256::ZERO { + String::new() } else { - None + format!("{{value: {}}}", trace.value) }, - stack: Some(step.stack.data().iter().copied().map(|v| v.to_ethers()).collect_vec()), - // Filled in `CallTraceArena::geth_trace` as a result of compounding all slot changes - storage: None, - return_data: None, - mem_size: None, - } + action = Paint::yellow(action), + )?; } -} -/// A trace of a call. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct CallTrace { - /// The depth of the call - pub depth: usize, - /// Whether the call was successful - pub success: bool, - /// The name of the contract, if any. - /// - /// The format is `":"` for easy lookup in local contracts. - /// - /// This member is not used by the core call tracing functionality (decoding/displaying). The - /// intended use case is for other components that may want to process traces by specific - /// contracts (e.g. gas reports). - pub contract: Option, - /// The label for the destination address, if any - pub label: Option, - /// caller of this call - pub caller: Address, - /// The destination address of the call or the address from the created contract - pub address: Address, - /// The kind of call this is - pub kind: CallKind, - /// The value transferred in the call - pub value: U256, - /// The calldata for the call, or the init code for contract creations - pub data: TraceCallData, - /// The return data of the call if this was not a contract creation, otherwise it is the - /// runtime bytecode of the created contract - pub output: TraceRetData, - /// The gas cost of the call - pub gas_cost: u64, - /// The status of the trace's call - pub status: InstructionResult, - /// call context of the runtime - pub call_context: Option, - /// Opcode-level execution steps - pub steps: Vec, + Ok((s, decoded.return_data)) } -impl CallTrace { - /// Whether this is a contract creation or not - pub fn created(&self) -> bool { - matches!(self.kind, CallKind::Create | CallKind::Create2) - } -} +/// Render a trace log. +async fn render_trace_log( + log: &Log, + decoder: &CallTraceDecoder, +) -> Result { + let mut s = String::new(); + let decoded = decoder.decode_event(log).await; + + match decoded { + DecodedCallLog::Raw(log) => { + for (i, topic) in log.topics().iter().enumerate() { + writeln!( + s, + "{:>13}: {}", + if i == 0 { "emit topic 0".to_string() } else { format!("topic {i}") }, + Paint::cyan(format!("{topic:?}")) + )?; + } -impl Default for CallTrace { - fn default() -> Self { - Self { - depth: Default::default(), - success: Default::default(), - contract: Default::default(), - label: Default::default(), - caller: Default::default(), - address: Default::default(), - kind: Default::default(), - value: Default::default(), - data: Default::default(), - output: Default::default(), - gas_cost: Default::default(), - status: InstructionResult::Continue, - call_context: Default::default(), - steps: Default::default(), + write!(s, " data: {}", Paint::cyan(hex::encode_prefixed(&log.data)))?; } - } -} - -impl fmt::Display for CallTrace { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "[{}] ", self.gas_cost)?; - let address = self.address.to_checksum(None); - if self.created() { - write!( - f, - "{}{} {}@{}", - Paint::yellow(CALL), - Paint::yellow("new"), - self.label.as_deref().unwrap_or(""), - address - ) - } else { - let (func_name, inputs) = match &self.data { - TraceCallData::Raw(bytes) => { - debug!(target: "evm::traces", trace=?self, "unhandled raw calldata"); - if bytes.len() < 4 { - ("fallback".into(), hex::encode(bytes)) - } else { - let (selector, data) = bytes.split_at(4); - (hex::encode(selector), hex::encode(data)) - } - } - TraceCallData::Decoded { signature, args } => { - let name = signature.split('(').next().unwrap(); - (name.to_string(), args.join(", ")) - } - }; - - let action = match self.kind { - // do not show anything for CALLs - CallKind::Call => "", - CallKind::StaticCall => " [staticcall]", - CallKind::CallCode => " [callcode]", - CallKind::DelegateCall => " [delegatecall]", - CallKind::Create | CallKind::Create2 => unreachable!(), - }; - - let color = trace_color(self); - write!( - f, - "{addr}::{func_name}{opt_value}({inputs}){action}", - addr = color.paint(self.label.as_deref().unwrap_or(&address)), - func_name = color.paint(func_name), - opt_value = if self.value == U256::ZERO { - String::new() - } else { - format!("{{value: {}}}", self.value) - }, - action = Paint::yellow(action), - ) + DecodedCallLog::Decoded(name, params) => { + let params = params + .iter() + .map(|(name, value)| format!("{name}: {value}")) + .collect::>() + .join(", "); + + write!(s, "emit {}({params})", Paint::cyan(name.clone()))?; } } + + Ok(s) } /// Specifies the kind of trace. @@ -617,42 +308,9 @@ pub fn load_contracts( .iter() .filter_map(|(addr, name)| { if let Ok(Some((_, (abi, _)))) = contracts.find_by_name_or_identifier(name) { - return Some((*addr, (name.clone(), abi.clone()))) + return Some((*addr, (name.clone(), abi.clone()))); } None }) .collect() } - -/// creates the memory data in 32byte chunks -/// see -fn convert_memory(data: &[u8]) -> Vec { - let mut memory = Vec::with_capacity((data.len() + 31) / 32); - for idx in (0..data.len()).step_by(32) { - let len = std::cmp::min(idx + 32, data.len()); - memory.push(hex::encode(&data[idx..len])); - } - memory -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_convert_memory() { - let mut data = vec![0u8; 32]; - assert_eq!( - convert_memory(&data), - vec!["0000000000000000000000000000000000000000000000000000000000000000".to_string()] - ); - data.extend(data.clone()); - assert_eq!( - convert_memory(&data), - vec![ - "0000000000000000000000000000000000000000000000000000000000000000".to_string(), - "0000000000000000000000000000000000000000000000000000000000000000".to_string() - ] - ); - } -} diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 93ae99d8cd97d..acb9436d838a4 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -20,8 +20,8 @@ use foundry_cli::{ }; use foundry_common::{ compile::ProjectCompiler, - estimate_eip1559_fees, fmt::parse_tokens, + provider::ethers::estimate_eip1559_fees, types::{ToAlloy, ToEthers}, }; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalized}; @@ -312,7 +312,7 @@ impl CreateArgs { }; if !self.verify { - return Ok(()) + return Ok(()); } println!("Starting contract verification..."); diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 0d038c436ffcd..2b3c1d449ac64 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -128,6 +128,7 @@ impl InspectArgs { ContractArtifactField::Errors => { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { + let abi = &abi; // Print the signature of all errors for er in abi.errors.iter().flat_map(|(_, errors)| errors) { let types = er.inputs.iter().map(|p| p.ty.clone()).collect::>(); @@ -144,6 +145,8 @@ impl InspectArgs { ContractArtifactField::Events => { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { + let abi = &abi; + // print the signature of all events including anonymous for ev in abi.events.iter().flat_map(|(_, events)| events) { let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::>(); diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index a0523ba918ad7..b6a8456f5dd93 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -2,7 +2,7 @@ use super::{ multi::MultiChainSequence, providers::ProvidersManager, receipts::clear_pendings, sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, *, }; -use ethers_core::{types::TxHash, utils::format_units}; +use alloy_primitives::{utils::format_units, TxHash}; use ethers_providers::{JsonRpcClient, Middleware, Provider}; use ethers_signers::Signer; use eyre::{bail, ContextCompat, Result, WrapErr}; @@ -12,7 +12,11 @@ use foundry_cli::{ update_progress, utils::{has_batch_support, has_different_gas_calc}, }; -use foundry_common::{estimate_eip1559_fees, shell, try_get_http_provider, RetryProvider}; +use foundry_common::{ + provider::ethers::{estimate_eip1559_fees, try_get_http_provider, RetryProvider}, + shell, + types::{ToAlloy, ToEthers}, +}; use futures::StreamExt; use std::{cmp::min, collections::HashSet, ops::Mul, sync::Arc}; @@ -149,17 +153,13 @@ impl ScriptArgs { if sequential_broadcast { let tx_hash = tx_hash.await?; - deployment_sequence.add_pending(index, tx_hash.to_alloy()); + deployment_sequence.add_pending(index, tx_hash); update_progress!(pb, (index + already_broadcasted)); index += 1; - clear_pendings( - provider.clone(), - deployment_sequence, - Some(vec![tx_hash.to_alloy()]), - ) - .await?; + clear_pendings(provider.clone(), deployment_sequence, Some(vec![tx_hash])) + .await?; } else { pending_transactions.push(tx_hash); } @@ -170,7 +170,7 @@ impl ScriptArgs { while let Some(tx_hash) = buffer.next().await { let tx_hash = tx_hash?; - deployment_sequence.add_pending(index, tx_hash.to_alloy()); + deployment_sequence.add_pending(index, tx_hash); update_progress!(pb, (index + already_broadcasted)); index += 1; @@ -201,9 +201,9 @@ impl ScriptArgs { (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used.mul(gas_price)) }, ); - let paid = format_units(total_paid.to_ethers(), 18).unwrap_or_else(|_| "N/A".to_string()); + let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); let avg_gas_price = - format_units(total_gas_price.to_ethers() / deployment_sequence.receipts.len(), 9) + format_units(total_gas_price / U256::from(deployment_sequence.receipts.len()), 9) .unwrap_or_else(|_| "N/A".to_string()); shell::println(format!( "Total Paid: {} ETH ({} gas * avg {} gwei)", @@ -255,7 +255,7 @@ impl ScriptArgs { // Submit the transaction let pending = provider.send_transaction(tx, None).await?; - Ok(pending.tx_hash()) + Ok(pending.tx_hash().to_alloy()) } SendTransactionKind::Raw(signer) => self.broadcast(provider, signer, tx).await, } @@ -353,7 +353,7 @@ impl ScriptArgs { self.send_transactions(deployment_sequence, &rpc, &result.script_wallets).await?; if self.verify { - return deployment_sequence.verify_contracts(&script_config.config, verify).await + return deployment_sequence.verify_contracts(&script_config.config, verify).await; } Ok(()) } @@ -385,7 +385,7 @@ impl ScriptArgs { &mut script_config.config, returns, ) - .await + .await; } else if self.broadcast { eyre::bail!("No onchain transactions generated in script"); } @@ -508,7 +508,7 @@ impl ScriptArgs { // transactions. if let Some(next_tx) = txes_iter.peek() { if next_tx.rpc == Some(tx_rpc) { - continue + continue; } } @@ -549,7 +549,7 @@ impl ScriptArgs { shell::println(format!( "\nEstimated gas price: {} gwei", - format_units(per_gas.to_ethers(), 9) + format_units(per_gas, 9) .unwrap_or_else(|_| "[Could not calculate]".to_string()) .trim_end_matches('0') .trim_end_matches('.') @@ -557,7 +557,7 @@ impl ScriptArgs { shell::println(format!("\nEstimated total gas used for script: {total_gas}"))?; shell::println(format!( "\nEstimated amount required: {} ETH", - format_units(total_gas.saturating_mul(per_gas).to_ethers(), 18) + format_units(total_gas.saturating_mul(per_gas), 18) .unwrap_or_else(|_| "[Could not calculate]".to_string()) .trim_end_matches('0') ))?; @@ -598,7 +598,7 @@ impl ScriptArgs { // Submit the raw transaction let pending = provider.send_raw_transaction(legacy_or_1559.rlp_signed(&signature)).await?; - Ok(pending.tx_hash()) + Ok(pending.tx_hash().to_alloy()) } async fn estimate_gas(&self, tx: &mut TypedTransaction, provider: &Provider) -> Result<()> diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 5aadaa9771044..0f9a16b5fb078 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -5,7 +5,9 @@ use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::Result; use foundry_cli::utils::LoadConfig; -use foundry_common::{contracts::flatten_contracts, try_get_http_provider, types::ToAlloy}; +use foundry_common::{ + contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy, +}; use foundry_debugger::Debugger; use std::sync::Arc; @@ -77,7 +79,7 @@ impl ScriptArgs { result, verify, ) - .await + .await; } let known_contracts = flatten_contracts(&highlevel_known_contracts, true); @@ -154,7 +156,7 @@ impl ScriptArgs { &flatten_contracts(&highlevel_known_contracts, true), )?; - return Ok(Some((new_traces, libraries, highlevel_known_contracts))) + return Ok(Some((new_traces, libraries, highlevel_known_contracts))); } // Add predeploy libraries to the list of broadcastable transactions. @@ -201,7 +203,7 @@ impl ScriptArgs { result.script_wallets, verify, ) - .await + .await; } self.resume_single_deployment( script_config, @@ -212,7 +214,7 @@ impl ScriptArgs { ) .await .map_err(|err| { - eyre::eyre!("{err}\n\nIf you were trying to resume or verify a multi chain deployment, add `--multi` to your command invocation.") + eyre::eyre!("{err}\n\nIf you were trying to resume or verify a multi chain deployment, add `--multi` to your command invocation.") }) } diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index b38f48e595867..cee58db6852e6 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -12,10 +12,13 @@ use forge::{ executors::ExecutorBuilder, inspectors::{cheatcodes::BroadcastableTransactions, CheatsConfig}, traces::{CallTraceDecoder, Traces}, - utils::CallKind, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; -use foundry_common::{shell, types::ToEthers, RpcUrl}; +use foundry_common::{ + provider::ethers::RpcUrl, + shell, + types::{ToAlloy, ToEthers}, +}; use foundry_compilers::artifacts::CompactContractBytecode; use futures::future::join_all; use parking_lot::RwLock; @@ -128,7 +131,7 @@ impl ScriptArgs { abi, code, }; - return Some((*addr, info)) + return Some((*addr, info)); } None }) @@ -159,20 +162,20 @@ impl ScriptArgs { .wrap_err("Internal EVM error during simulation")?; if !result.success || result.traces.is_empty() { - return Ok((None, result.traces)) + return Ok((None, result.traces)); } let created_contracts = result .traces .iter() .flat_map(|(_, traces)| { - traces.arena.iter().filter_map(|node| { - if matches!(node.kind(), CallKind::Create | CallKind::Create2) { + traces.nodes().iter().filter_map(|node| { + if node.trace.kind.is_any_create() { return Some(AdditionalContract { - opcode: node.kind(), + opcode: node.trace.kind, address: node.trace.address, - init_code: node.trace.data.as_bytes().to_vec().into(), - }) + init_code: node.trace.data.clone(), + }); } None }) @@ -218,7 +221,7 @@ impl ScriptArgs { // type hint let res: Result = res; - let (tx, mut traces) = res?; + let (tx, traces) = res?; // Transaction will be `None`, if execution didn't pass. if tx.is_none() || script_config.evm_opts.verbosity > 3 { @@ -229,9 +232,8 @@ impl ScriptArgs { ); } - for (_kind, trace) in &mut traces { - decoder.decode(trace).await; - println!("{trace}"); + for (_, trace) in &traces { + println!("{}", render_trace_arena(trace, decoder).await?); } } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index c3ab3caa71163..4f6a3328a9f6e 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -18,9 +18,8 @@ use forge::{ opts::EvmOpts, traces::{ identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, - CallTraceDecoder, CallTraceDecoderBuilder, TraceCallData, TraceKind, TraceRetData, Traces, + render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, - utils::CallKind, }; use foundry_cli::opts::MultiWallet; use foundry_common::{ @@ -29,9 +28,10 @@ use foundry_common::{ errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, fmt::{format_token, format_token_raw}, + provider::ethers::RpcUrl, shell, types::{ToAlloy, ToEthers}, - ContractsByArtifact, RpcUrl, CONTRACT_MAX_SIZE, SELECTOR_LEN, + ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::{ artifacts::{ContractBytecodeSome, Libraries}, @@ -291,7 +291,7 @@ impl ScriptArgs { } shell::println("Traces:")?; - for (kind, trace) in &mut result.traces { + for (kind, trace) in &result.traces { let should_include = match kind { TraceKind::Setup => verbosity >= 5, TraceKind::Execution => verbosity > 3, @@ -299,8 +299,7 @@ impl ScriptArgs { } || !result.success; if should_include { - decoder.decode(trace).await; - shell::println(format!("{trace}"))?; + shell::println(render_trace_arena(trace, decoder).await?)?; } } shell::println(String::new())?; @@ -355,7 +354,7 @@ impl ScriptArgs { return Err(eyre::eyre!( "script failed: {}", decode::decode_revert(&result.returned[..], None, None) - )) + )); } Ok(()) @@ -395,7 +394,7 @@ impl ScriptArgs { if let Some(ns) = new_sender { if sender != ns { shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; - return Ok(None) + return Ok(None); } } else if sender != evm_opts.sender { new_sender = Some(sender); @@ -483,13 +482,13 @@ impl ScriptArgs { // From artifacts for (artifact, bytecode) in known_contracts.iter() { if bytecode.bytecode.object.is_unlinked() { - return Err(UnlinkedByteCode::Bytecode(artifact.identifier()).into()) + return Err(UnlinkedByteCode::Bytecode(artifact.identifier()).into()); } let init_code = bytecode.bytecode.object.as_bytes().unwrap(); // Ignore abstract contracts if let Some(ref deployed_code) = bytecode.deployed_bytecode.bytecode { if deployed_code.object.is_unlinked() { - return Err(UnlinkedByteCode::DeployedBytecode(artifact.identifier()).into()) + return Err(UnlinkedByteCode::DeployedBytecode(artifact.identifier()).into()); } let deployed_code = deployed_code.object.as_bytes().unwrap(); bytecodes.push((artifact.name.clone(), init_code, deployed_code)); @@ -498,27 +497,17 @@ impl ScriptArgs { // From traces let create_nodes = result.traces.iter().flat_map(|(_, traces)| { - traces - .arena - .iter() - .filter(|node| matches!(node.kind(), CallKind::Create | CallKind::Create2)) + traces.nodes().iter().filter(|node| node.trace.kind.is_any_create()) }); let mut unknown_c = 0usize; for node in create_nodes { - // Calldata == init code - if let TraceCallData::Raw(ref init_code) = node.trace.data { - // Output is the runtime code - if let TraceRetData::Raw(ref deployed_code) = node.trace.output { - // Only push if it was not present already - if !bytecodes.iter().any(|(_, b, _)| *b == init_code.as_ref()) { - bytecodes.push((format!("Unknown{unknown_c}"), init_code, deployed_code)); - unknown_c += 1; - } - continue - } + let init_code = &node.trace.data; + let deployed_code = &node.trace.output; + if !bytecodes.iter().any(|(_, b, _)| *b == init_code.as_ref()) { + bytecodes.push((format!("Unknown{unknown_c}"), init_code, deployed_code)); + unknown_c += 1; } - // Both should be raw and not decoded since it's just bytecode - eyre::bail!("Create node returned decoded data: {:?}", node); + continue; } let mut prompt_user = false; @@ -544,7 +533,7 @@ impl ScriptArgs { offset = 32; } } else if to.is_some() { - continue + continue; } // Find artifact with a deployment code same as the data. diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index fc94fc487642b..9fd3427949b29 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -7,7 +7,7 @@ use super::{ use ethers_signers::LocalWallet; use eyre::{ContextCompat, Report, Result, WrapErr}; use foundry_cli::utils::now; -use foundry_common::{fs, get_http_provider}; +use foundry_common::{fs, provider::ethers::get_http_provider}; use foundry_compilers::{artifacts::Libraries, ArtifactId}; use foundry_config::Config; use futures::future::join_all; @@ -237,7 +237,7 @@ impl ScriptArgs { let errors = results.into_iter().filter(|res| res.is_err()).collect::>(); if !errors.is_empty() { - return Err(eyre::eyre!("{errors:?}")) + return Err(eyre::eyre!("{errors:?}")); } Ok(()) diff --git a/crates/forge/bin/cmd/script/providers.rs b/crates/forge/bin/cmd/script/providers.rs index 92638becaac4f..f29a72629320a 100644 --- a/crates/forge/bin/cmd/script/providers.rs +++ b/crates/forge/bin/cmd/script/providers.rs @@ -1,7 +1,11 @@ use alloy_primitives::U256; use ethers_providers::{Middleware, Provider}; use eyre::{Result, WrapErr}; -use foundry_common::{get_http_provider, runtime_client::RuntimeClient, types::ToAlloy, RpcUrl}; +use foundry_common::{ + provider::ethers::{get_http_provider, RpcUrl}, + runtime_client::RuntimeClient, + types::ToAlloy, +}; use foundry_config::Chain; use std::{ collections::{hash_map::Entry, HashMap}, diff --git a/crates/forge/bin/cmd/script/receipts.rs b/crates/forge/bin/cmd/script/receipts.rs index fb8640903c950..29848aad35647 100644 --- a/crates/forge/bin/cmd/script/receipts.rs +++ b/crates/forge/bin/cmd/script/receipts.rs @@ -5,8 +5,8 @@ use ethers_providers::{Middleware, PendingTransaction}; use eyre::Result; use foundry_cli::{init_progress, update_progress, utils::print_receipt}; use foundry_common::{ + provider::ethers::RetryProvider, types::{ToAlloy, ToEthers}, - RetryProvider, }; use futures::StreamExt; use std::sync::Arc; @@ -36,7 +36,7 @@ pub async fn wait_for_pending( deployment_sequence: &mut ScriptSequence, ) -> Result<()> { if deployment_sequence.pending.is_empty() { - return Ok(()) + return Ok(()); } println!("##\nChecking previously pending transactions."); clear_pendings(provider, deployment_sequence, None).await @@ -138,7 +138,7 @@ async fn check_tx_status( // First check if there's a receipt let receipt_opt = provider.get_transaction_receipt(hash.to_ethers()).await?; if let Some(receipt) = receipt_opt { - return Ok(receipt.into()) + return Ok(receipt.into()); } // If the tx is present in the mempool, run the pending tx future, and diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 4dc2857db8834..28faf48be9ed7 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -244,9 +244,9 @@ impl ScriptRunner { gas_used, logs, traces: traces - .map(|mut traces| { + .map(|traces| { // Manually adjust gas for the trace to add back the stipend/real used gas - traces.arena[0].trace.gas_cost = gas_used; + vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), @@ -305,9 +305,9 @@ impl ScriptRunner { gas_used, logs, traces: traces - .map(|mut traces| { + .map(|traces| { // Manually adjust gas for the trace to add back the stipend/real used gas - traces.arena[0].trace.gas_cost = gas_used; + vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), @@ -363,7 +363,7 @@ impl ScriptRunner { { // update the gas gas_used = highest_gas_limit; - break + break; } last_highest_gas_limit = highest_gas_limit; } diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index f3af7470b62ee..a577702ba8a74 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -6,10 +6,14 @@ use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{ fmt::format_token_raw, + provider::ethers::RpcUrl, types::{ToAlloy, ToEthers}, - RpcUrl, SELECTOR_LEN, + SELECTOR_LEN, +}; +use foundry_evm::{ + constants::DEFAULT_CREATE2_DEPLOYER, + traces::{CallKind, CallTraceDecoder}, }; -use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder, utils::CallKind}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1f413696f8cf3..c54de4670cd20 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -42,6 +42,7 @@ mod summary; use summary::TestSummaryReporter; pub use filter::FilterArgs; +use forge::traces::render_trace_arena; // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); @@ -222,6 +223,8 @@ impl TestArgs { if should_debug { let tests = outcome.clone().into_tests(); + // todo(onbjerg): why do we bother decoding everything and having multiple decoders if + // we are only going to use the first one? (see `DebuggerArgs` below) let mut decoders = Vec::new(); for test in tests { let mut result = test.result; @@ -247,31 +250,9 @@ impl TestArgs { EtherscanIdentifier::new(&config, remote_chain_id)?; // Decode the traces - for (kind, trace) in &mut result.traces { + for (_, trace) in &mut result.traces { decoder.identify(trace, &mut local_identifier); decoder.identify(trace, &mut etherscan_identifier); - - let should_include = match kind { - // At verbosity level 3, we only display traces for failed tests - // At verbosity level 4, we also display the setup trace for failed - // tests At verbosity level 5, we display - // all traces for all tests - TraceKind::Setup => { - (verbosity >= 5) || - (verbosity == 4 && result.status == TestStatus::Failure) - } - TraceKind::Execution => { - verbosity > 3 || - (verbosity == 3 && result.status == TestStatus::Failure) - } - _ => false, - }; - - // We decode the trace if we either need to build a gas report or we need - // to print it - if should_include || self.gas_report { - decoder.decode(trace).await; - } } } @@ -360,7 +341,7 @@ impl TestArgs { if self.json { let results = runner.test_collect(filter, test_options).await; println!("{}", serde_json::to_string(&results)?); - return Ok(TestOutcome::new(results, self.allow_failure)) + return Ok(TestOutcome::new(results, self.allow_failure)); } // Set up identifiers @@ -418,7 +399,7 @@ impl TestArgs { } if result.traces.is_empty() { - continue + continue; } // Identify addresses in each trace @@ -436,9 +417,9 @@ impl TestArgs { // Decode the traces let mut decoded_traces = Vec::with_capacity(result.traces.len()); - for (kind, trace) in &mut result.traces { - decoder.identify(trace, &mut local_identifier); - decoder.identify(trace, &mut etherscan_identifier); + for (kind, arena) in &mut result.traces { + decoder.identify(arena, &mut local_identifier); + decoder.identify(arena, &mut etherscan_identifier); // verbosity: // - 0..3: nothing @@ -455,24 +436,18 @@ impl TestArgs { TraceKind::Deployment => false, }; - // Decode the trace if we either need to build a gas report or we need to print - // it - if should_include || self.gas_report { - decoder.decode(trace).await; - } - if should_include { - decoded_traces.push(trace.to_string()); + decoded_traces.push(render_trace_arena(arena, &decoder).await?); } } if !decoded_traces.is_empty() { - println!("Traces:"); - decoded_traces.into_iter().for_each(|trace| println!("{trace}")); + shell::println("Traces:")?; + decoded_traces.into_iter().try_for_each(shell::println)?; } if self.gas_report { - gas_report.analyze(&result.traces); + gas_report.analyze(&result.traces, &decoder).await; } // If the test failed, we want to stop processing the rest of the tests @@ -489,7 +464,7 @@ impl TestArgs { total_failed += block_outcome.failures().count(); total_skipped += block_outcome.skips().count(); - println!("{}", block_outcome.summary()); + shell::println(block_outcome.summary())?; if self.summary { suite_results.push(block_outcome.clone()); @@ -497,25 +472,22 @@ impl TestArgs { } if self.gas_report { - println!("{}", gas_report.finalize()); + shell::println(gas_report.finalize())?; } let num_test_suites = results.len(); if num_test_suites > 0 { - println!( - "{}", - format_aggregated_summary( - num_test_suites, - total_passed, - total_failed, - total_skipped - ) - ); + shell::println(format_aggregated_summary( + num_test_suites, + total_passed, + total_failed, + total_skipped, + ))?; if self.summary { let mut summary_table = TestSummaryReporter::new(self.detailed); - println!("\n\nTest Summary:"); + shell::println("\n\nTest Summary:")?; summary_table.print_summary(suite_results); } } @@ -654,7 +626,7 @@ impl TestOutcome { pub fn ensure_ok(&self) -> Result<()> { let failures = self.failures().count(); if self.allow_failure || failures == 0 { - return Ok(()) + return Ok(()); } if !shell::verbosity().is_normal() { @@ -662,27 +634,27 @@ impl TestOutcome { std::process::exit(1); } - println!(); - println!("Failing tests:"); + shell::println("")?; + shell::println("Failing tests:")?; for (suite_name, suite) in self.results.iter() { let failures = suite.failures().count(); if failures == 0 { - continue + continue; } let term = if failures > 1 { "tests" } else { "test" }; - println!("Encountered {failures} failing {term} in {suite_name}"); + shell::println(format!("Encountered {failures} failing {term} in {suite_name}"))?; for (name, result) in suite.failures() { short_test_result(name, result); } - println!(); + shell::println("")?; } let successes = self.successes().count(); - println!( + shell::println(format!( "Encountered a total of {} failing tests, {} tests succeeded", Paint::red(failures.to_string()), Paint::green(successes.to_string()) - ); + ))?; std::process::exit(1); } @@ -708,7 +680,7 @@ impl TestOutcome { } fn short_test_result(name: &str, result: &TestResult) { - println!("{result} {name} {}", result.kind.report()); + shell::println(format!("{result} {name} {}", result.kind.report())).unwrap(); } /// Formats the aggregated summary of all test suites into a string (for printing). diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 411e7bdced514..c537643ad618b 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -3,7 +3,7 @@ use crate::{ constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, hashbrown::HashSet, - traces::{CallTraceArena, TraceCallData, TraceKind}, + traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData, TraceKind}, }; use alloy_primitives::U256; use comfy_table::{presets::ASCII_MARKDOWN, *}; @@ -46,21 +46,25 @@ impl GasReport { } /// Analyzes the given traces and generates a gas report. - pub fn analyze(&mut self, traces: &[(TraceKind, CallTraceArena)]) { - traces.iter().for_each(|(_, trace)| { - self.analyze_node(0, trace); - }); + pub async fn analyze( + &mut self, + traces: &[(TraceKind, CallTraceArena)], + decoder: &CallTraceDecoder, + ) { + for node in traces.iter().flat_map(|(_, arena)| arena.nodes()) { + self.analyze_node(node, decoder).await; + } } - fn analyze_node(&mut self, node_index: usize, arena: &CallTraceArena) { - let node = &arena.arena[node_index]; + async fn analyze_node(&mut self, node: &CallTraceNode, decoder: &CallTraceDecoder) { let trace = &node.trace; + let decoded = decoder.decode_function(&node.trace).await; if trace.address == CHEATCODE_ADDRESS || trace.address == HARDHAT_CONSOLE_ADDRESS { return } - if let Some(name) = &trace.contract { + if let Some(name) = &decoded.contract { let contract_name = name.rsplit(':').next().unwrap_or(name.as_str()); // If the user listed the contract in 'gas_reports' (the foundry.toml field) a // report for the contract is generated even if it's listed in the ignore @@ -78,35 +82,26 @@ impl GasReport { if self.should_report(contract_name) { let contract_info = self.contracts.entry(name.to_string()).or_default(); - match &trace.data { - TraceCallData::Raw(bytes) => { - if trace.created() { - contract_info.gas = U256::from(trace.gas_cost); - contract_info.size = U256::from(bytes.len()); - } - } - TraceCallData::Decoded { signature, .. } => { - let name = signature.split('(').next().unwrap(); - // ignore any test/setup functions - let should_include = - !(name.is_test() || name.is_invariant_test() || name.is_setup()); - if should_include { - let gas_info = contract_info - .functions - .entry(name.into()) - .or_default() - .entry(signature.clone()) - .or_default(); - gas_info.calls.push(U256::from(trace.gas_cost)); - } + if trace.kind.is_any_create() { + contract_info.gas = U256::from(trace.gas_used); + contract_info.size = U256::from(trace.data.len()); + } else if let Some(DecodedCallData { signature, .. }) = decoded.func { + let name = signature.split('(').next().unwrap(); + // ignore any test/setup functions + let should_include = + !(name.is_test() || name.is_invariant_test() || name.is_setup()); + if should_include { + let gas_info = contract_info + .functions + .entry(name.to_string()) + .or_default() + .entry(signature.clone()) + .or_default(); + gas_info.calls.push(U256::from(trace.gas_used)); } } } } - - node.children.iter().for_each(|index| { - self.analyze_node(*index, arena); - }); } /// Finalizes the gas report by calculating the min, max, mean, and median for each function. diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index b1fccc87e0bde..94551e8763276 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -119,6 +119,7 @@ pub struct TestResult { pub kind: TestKind, /// Traces + #[serde(skip)] pub traces: Traces, /// Raw coverage info diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index f6f3adb9dadb4..d6f7628da1694 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -1,6 +1,6 @@ //! Contains various tests related to forge script use anvil::{spawn, NodeConfig}; -use foundry_common::types::ToEthers; + use foundry_test_utils::{ScriptOutcome, ScriptTester}; forgetest_async!(can_deploy_multi_chain_script_without_lib, |prj, cmd| { @@ -15,23 +15,11 @@ forgetest_async!(can_deploy_multi_chain_script_without_lib, |prj, cmd| { .args(&[&handle1.http_endpoint(), &handle2.http_endpoint()]) .broadcast(ScriptOutcome::OkBroadcast); - assert_eq!( - api1.transaction_count(tester.accounts_pub[0].to_ethers(), None).await.unwrap().as_u32(), - 1 - ); - assert_eq!( - api1.transaction_count(tester.accounts_pub[1].to_ethers(), None).await.unwrap().as_u32(), - 1 - ); + assert_eq!(api1.transaction_count(tester.accounts_pub[0], None).await.unwrap().to::(), 1); + assert_eq!(api1.transaction_count(tester.accounts_pub[1], None).await.unwrap().to::(), 1); - assert_eq!( - api2.transaction_count(tester.accounts_pub[0].to_ethers(), None).await.unwrap().as_u32(), - 2 - ); - assert_eq!( - api2.transaction_count(tester.accounts_pub[1].to_ethers(), None).await.unwrap().as_u32(), - 3 - ); + assert_eq!(api2.transaction_count(tester.accounts_pub[0], None).await.unwrap().to::(), 2); + assert_eq!(api2.transaction_count(tester.accounts_pub[1], None).await.unwrap().to::(), 3); }); forgetest_async!(can_not_deploy_multi_chain_script_with_lib, |prj, cmd| { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 6fd5dcd06a082..f9eade382d275 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1,9 +1,9 @@ //! Contains various tests related to `forge script`. use crate::constants::TEMPLATE_CONTRACT; -use alloy_primitives::Address; +use alloy_primitives::{Address, Bytes}; use anvil::{spawn, NodeConfig}; -use foundry_common::{rpc, types::ToEthers}; +use foundry_common::rpc; use foundry_test_utils::{util::OutputExt, ScriptOutcome, ScriptTester}; use regex::Regex; use serde_json::Value; @@ -561,10 +561,8 @@ forgetest_async!(can_deploy_with_create2, |prj, cmd| { // Prepare CREATE2 Deployer api.anvil_set_code( - foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER.to_ethers(), - ethers_core::types::Bytes::from_static( - foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, - ), + foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER, + Bytes::from_static(foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE), ) .await .unwrap(); @@ -653,7 +651,7 @@ forgetest_async!( // Prepare CREATE2 Deployer let addr = Address::from_str("0x4e59b44847b379578588920ca78fbf26c0b4956c").unwrap(); let code = hex::decode("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3").expect("Could not decode create2 deployer init_code").into(); - api.anvil_set_code(addr.to_ethers(), code).await.unwrap(); + api.anvil_set_code(addr, code).await.unwrap(); tester .load_private_keys(&[0]) diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 17cace7c908d9..22c01f67e155d 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -10,9 +10,13 @@ use foundry_config::{ InvariantConfig, RpcEndpoint, RpcEndpoints, }; use foundry_evm::{ - decode::decode_console_logs, inspectors::CheatsConfig, revm::primitives::SpecId, + decode::decode_console_logs, + inspectors::CheatsConfig, + revm::primitives::SpecId, + traces::{render_trace_arena, CallTraceDecoderBuilder}, }; use foundry_test_utils::{init_tracing, Filter}; +use futures::future::join_all; use itertools::Itertools; use std::{collections::BTreeMap, path::Path}; @@ -78,14 +82,25 @@ impl TestConfig { { let logs = decode_console_logs(&result.logs); let outcome = if self.should_fail { "fail" } else { "pass" }; - + let call_trace_decoder = CallTraceDecoderBuilder::default().build(); + let decoded_traces = join_all( + result + .traces + .iter() + .map(|(_, a)| render_trace_arena(a, &call_trace_decoder)) + .collect::>(), + ) + .await + .into_iter() + .map(|x| x.unwrap()) + .collect::>(); eyre::bail!( "Test {} did not {} as expected.\nReason: {:?}\nLogs:\n{}\n\nTraces:\n{}", test_name, outcome, result.reason, logs.join("\n"), - result.traces.iter().map(|(_, a)| a).format("\n"), + decoded_traces.into_iter().format("\n"), ) } } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 5ea2bd37845c7..39aeae72335ea 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -7,8 +7,7 @@ use forge::result::TestStatus; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_evm::{ constants::HARDHAT_CONSOLE_ADDRESS, - traces::{CallTraceDecoder, TraceCallData, TraceKind}, - utils::CallKind, + traces::{CallKind, CallTraceDecoder, DecodedCallData, TraceKind}, }; use foundry_test_utils::Filter; @@ -245,35 +244,35 @@ test_repro!(6501, false, None, |res| { assert_eq!(test.status, TestStatus::Success); assert_eq!(test.decoded_logs, ["a".to_string(), "1".to_string(), "b 2".to_string()]); - let (kind, mut traces) = test.traces[1].clone(); + let (kind, traces) = test.traces[1].clone(); + let nodes = traces.into_nodes(); assert_eq!(kind, TraceKind::Execution); - let test_call = traces.arena.first().unwrap(); + let test_call = nodes.first().unwrap(); assert_eq!(test_call.idx, 0); assert_eq!(test_call.children, [1, 2, 3]); assert_eq!(test_call.trace.depth, 0); assert!(test_call.trace.success); - CallTraceDecoder::new().decode(&mut traces).await; - let expected = [ ("log(string)", vec!["\"a\""]), ("log(uint256)", vec!["1"]), ("log(string,uint256)", vec!["\"b\"", "2"]), ]; - for (node, expected) in traces.arena[1..=3].iter().zip(expected) { + for (node, expected) in nodes[1..=3].iter().zip(expected) { let trace = &node.trace; + let decoded = CallTraceDecoder::new().decode_function(trace).await; assert_eq!(trace.kind, CallKind::StaticCall); assert_eq!(trace.address, HARDHAT_CONSOLE_ADDRESS); - assert_eq!(trace.label, Some("console".into())); + assert_eq!(decoded.label, Some("console".into())); assert_eq!(trace.depth, 1); assert!(trace.success); assert_eq!( - trace.data, - TraceCallData::Decoded { + decoded.func, + Some(DecodedCallData { signature: expected.0.into(), args: expected.1.into_iter().map(ToOwned::to_owned).collect(), - } + }) ); } }); diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index a2f47ed4d7e42..f4449a7694a82 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -4,9 +4,8 @@ use ethers_core::types::NameOrAddress; use ethers_providers::Middleware; use eyre::Result; use foundry_common::{ - get_http_provider, + provider::ethers::{get_http_provider, RetryProvider}, types::{ToAlloy, ToEthers}, - RetryProvider, }; use std::{collections::BTreeMap, fs, path::Path, str::FromStr}; diff --git a/deny.toml b/deny.toml index 25b3e6a971a68..f46973b5964a7 100644 --- a/deny.toml +++ b/deny.toml @@ -64,6 +64,7 @@ exceptions = [ { allow = ["CC0-1.0"], name = "secp256k1" }, { allow = ["CC0-1.0"], name = "secp256k1-sys" }, { allow = ["CC0-1.0"], name = "tiny-keccak" }, + { allow = ["CC0-1.0"], name = "to_method" }, { allow = ["CC0-1.0"], name = "more-asserts" }, { allow = ["CC0-1.0"], name = "trezor-client" }, { allow = ["CC0-1.0"], name = "notify" }, From 43eb5f022fdeb2d9cec477bac8dcab95c1dffba6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:05:11 +0100 Subject: [PATCH 0445/1963] chore: update decode_revert message for empty data (#6728) --- crates/evm/core/src/decode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 6812cfd4f5032..2df8470b6b92e 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -42,7 +42,7 @@ pub fn decode_revert( ) -> String { maybe_decode_revert(err, maybe_abi, status).unwrap_or_else(|| { if err.is_empty() { - "".to_string() + "".to_string() } else { trimmed_hex(err) } From 105de72894f7f6fb5c4045f8e4b4f965de0bb33a Mon Sep 17 00:00:00 2001 From: Inphi Date: Tue, 9 Jan 2024 07:06:01 -0500 Subject: [PATCH 0446/1963] feat(cast): Add transasctionsRoot to block fmt (#6730) --- crates/common/src/fmt/ui.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 28ceef610ad21..56ccb68a1d110 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -412,6 +412,7 @@ pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option Some(block.nonce.pretty()), "number" => Some(block.number.pretty()), "parentHash" | "parent_hash" => Some(block.parent_hash.pretty()), + "transactionsRoot" | "transactions_root" => Some(block.transactions_root.pretty()), "receiptsRoot" | "receipts_root" => Some(block.receipts_root.pretty()), "sealFields" | "seal_fields" => Some(block.seal_fields.pretty()), "sha3Uncles" | "sha_3_uncles" => Some(block.uncles_hash.pretty()), @@ -444,6 +445,7 @@ mixHash {} nonce {} number {} parentHash {} +transactionsRoot {} receiptsRoot {} sealFields {} sha3Uncles {} @@ -464,6 +466,7 @@ totalDifficulty {}{}", block.nonce.pretty(), block.number.pretty(), block.parent_hash.pretty(), + block.transactions_root.pretty(), block.receipts_root.pretty(), block.seal_fields.pretty(), block.uncles_hash.pretty(), @@ -725,6 +728,10 @@ value 0".to_string(); Some("0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5".to_string()), get_pretty_block_attr(&block, "parentHash") ); + assert_eq!( + Some("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421".to_string()), + get_pretty_block_attr(&block, "transactionsRoot") + ); assert_eq!( Some("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421".to_string()), get_pretty_block_attr(&block, "receiptsRoot") From 71d8ea5923571f33c7aab9ee6e0d1f9a348bd6be Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 9 Jan 2024 15:32:39 +0100 Subject: [PATCH 0447/1963] fix: dont record step tracing by default (#6734) --- crates/anvil/src/eth/backend/mem/inspector.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index d1b45bea453a5..bb648f6c61d8a 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -35,13 +35,14 @@ impl Inspector { /// Configures the `Tracer` [`revm::Inspector`] pub fn with_tracing(mut self) -> Self { - self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all())); + self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all().set_steps(false))); self } /// Enables steps recording for `Tracer`. - pub fn with_steps_tracing(self) -> Self { - self.with_tracing() + pub fn with_steps_tracing(mut self) -> Self { + self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all())); + self } } From 0792dc7785c630444c6f08203d9a5b41719ce949 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:22:24 +0100 Subject: [PATCH 0448/1963] chore: remove JsonAbi import renames (#6737) --- crates/cli/src/utils/cmd.rs | 8 ++++---- crates/common/src/contracts.rs | 16 ++++++++-------- crates/evm/evm/src/executors/fuzz/mod.rs | 4 ++-- crates/evm/evm/src/executors/invariant/mod.rs | 12 ++++++------ crates/evm/evm/src/executors/mod.rs | 14 +++++++------- crates/evm/fuzz/src/invariant/filters.rs | 4 ++-- crates/evm/fuzz/src/invariant/mod.rs | 8 ++++---- crates/evm/fuzz/src/strategies/invariants.rs | 9 ++++++--- crates/evm/traces/src/decoder/mod.rs | 4 ++-- crates/evm/traces/src/identifier/mod.rs | 4 ++-- crates/forge/bin/cmd/create.rs | 10 +++++----- crates/forge/bin/cmd/script/mod.rs | 4 ++-- crates/forge/src/multi_runner.rs | 12 ++++++------ crates/forge/src/runner.rs | 10 +++++----- 14 files changed, 61 insertions(+), 58 deletions(-) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 4c226cf1b5199..ecc937ae592aa 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -1,4 +1,4 @@ -use alloy_json_abi::JsonAbi as Abi; +use alloy_json_abi::JsonAbi; use alloy_primitives::Address; use eyre::{Result, WrapErr}; use foundry_common::{cli_warn, fs, TestFunctionExt}; @@ -29,7 +29,7 @@ use yansi::Paint; pub fn remove_contract( output: &mut ProjectCompileOutput, info: &ContractInfo, -) -> Result<(Abi, CompactBytecode, CompactDeployedBytecode)> { +) -> Result<(JsonAbi, CompactBytecode, CompactDeployedBytecode)> { let contract = if let Some(contract) = output.remove_contract(info) { contract } else { @@ -108,7 +108,7 @@ pub fn get_cached_entry_by_name( } /// Returns error if constructor has arguments. -pub fn ensure_clean_constructor(abi: &Abi) -> Result<()> { +pub fn ensure_clean_constructor(abi: &JsonAbi) -> Result<()> { if let Some(constructor) = &abi.constructor { if !constructor.inputs.is_empty() { eyre::bail!("Contract constructor should have no arguments. Add those arguments to `run(...)` instead, and call it with `--sig run(...)`."); @@ -117,7 +117,7 @@ pub fn ensure_clean_constructor(abi: &Abi) -> Result<()> { Ok(()) } -pub fn needs_setup(abi: &Abi) -> bool { +pub fn needs_setup(abi: &JsonAbi) -> bool { let setup_fns: Vec<_> = abi.functions().filter(|func| func.name.is_setup()).collect(); for setup_fn in setup_fns.iter() { diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index cad74931766eb..be279817603bc 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -1,6 +1,6 @@ //! Commonly used contract types and functions. -use alloy_json_abi::{Event, Function, JsonAbi as Abi}; +use alloy_json_abi::{Event, Function, JsonAbi}; use alloy_primitives::{hex, Address, B256}; use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecodeSome}, @@ -14,11 +14,11 @@ use std::{ path::PathBuf, }; -type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a (Abi, Vec)); +type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a (JsonAbi, Vec)); /// Wrapper type that maps an artifact to a contract ABI and bytecode. #[derive(Clone, Default)] -pub struct ContractsByArtifact(pub BTreeMap)>); +pub struct ContractsByArtifact(pub BTreeMap)>); impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. @@ -44,7 +44,7 @@ impl ContractsByArtifact { } /// Flattens a group of contracts into maps of all events and functions - pub fn flatten(&self) -> (BTreeMap<[u8; 4], Function>, BTreeMap, Abi) { + pub fn flatten(&self) -> (BTreeMap<[u8; 4], Function>, BTreeMap, JsonAbi) { let flattened_funcs: BTreeMap<[u8; 4], Function> = self .iter() .flat_map(|(_name, (abi, _code))| { @@ -64,7 +64,7 @@ impl ContractsByArtifact { .collect(); // We need this for better revert decoding, and want it in abi form - let mut errors_abi = Abi::default(); + let mut errors_abi = JsonAbi::default(); self.iter().for_each(|(_name, (abi, _code))| { abi.errors().for_each(|error| { let entry = @@ -77,7 +77,7 @@ impl ContractsByArtifact { } impl Deref for ContractsByArtifact { - type Target = BTreeMap)>; + type Target = BTreeMap)>; fn deref(&self) -> &Self::Target { &self.0 @@ -91,7 +91,7 @@ impl DerefMut for ContractsByArtifact { } /// Wrapper type that maps an address to a contract identifier and contract ABI. -pub type ContractsByAddress = BTreeMap; +pub type ContractsByAddress = BTreeMap; /// Very simple fuzzy matching of contract bytecode. /// @@ -113,7 +113,7 @@ pub fn diff_score(a: &[u8], b: &[u8]) -> f64 { diff_chars as f64 / cutoff_len as f64 } -/// Flattens the contracts into (`id` -> (`Abi`, `Vec`)) pairs +/// Flattens the contracts into (`id` -> (`JsonAbi`, `Vec`)) pairs pub fn flatten_contracts( contracts: &BTreeMap, deployed_code: bool, diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 321f1ddcd364d..4adcca6320ed9 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,6 +1,6 @@ use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_config::FuzzConfig; @@ -60,7 +60,7 @@ impl FuzzedExecutor { func: &Function, address: Address, should_fail: bool, - errors: Option<&Abi>, + errors: Option<&JsonAbi>, ) -> FuzzTestResult { // Stores the first Fuzzcase let first_case: RefCell> = RefCell::default(); diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index ffde3b59c5bd8..fc0a91a534bef 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -3,7 +3,7 @@ use crate::{ inspectors::Fuzzer, }; use alloy_dyn_abi::DynSolValue; -use alloy_json_abi::JsonAbi as Abi; +use alloy_json_abi::JsonAbi; use alloy_primitives::{Address, FixedBytes, U256}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; @@ -324,7 +324,7 @@ impl<'a> InvariantExecutor<'a> { pub fn select_contract_artifacts( &mut self, invariant_address: Address, - abi: &Abi, + abi: &JsonAbi, ) -> eyre::Result<()> { // targetArtifactSelectors -> (string, bytes4[])[]. let targeted_abi = self @@ -450,7 +450,7 @@ impl<'a> InvariantExecutor<'a> { pub fn select_contracts_and_senders( &self, invariant_address: Address, - abi: &Abi, + abi: &JsonAbi, ) -> eyre::Result<(SenderFilters, TargetedContracts)> { let [targeted_senders, excluded_senders, selected, excluded] = ["targetSenders", "excludeSenders", "targetContracts", "excludeContracts"].map( @@ -497,7 +497,7 @@ impl<'a> InvariantExecutor<'a> { pub fn target_interfaces( &self, invariant_address: Address, - abi: &Abi, + abi: &JsonAbi, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { let interfaces = self.get_list::<(Address, Vec)>( @@ -570,7 +570,7 @@ impl<'a> InvariantExecutor<'a> { pub fn select_selectors( &self, address: Address, - abi: &Abi, + abi: &JsonAbi, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { // `targetArtifactSelectors() -> (string, bytes4[])[]`. @@ -661,7 +661,7 @@ impl<'a> InvariantExecutor<'a> { fn get_list( &self, address: Address, - abi: &Abi, + abi: &JsonAbi, method_name: &str, f: fn(DynSolValue) -> Vec, ) -> Vec { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index b57acc4e9b08b..971a2a21f5302 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -10,7 +10,7 @@ use crate::inspectors::{ cheatcodes::BroadcastableTransactions, Cheatcodes, InspectorData, InspectorStack, }; use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use ethers_core::types::Log; use ethers_signers::LocalWallet; @@ -223,7 +223,7 @@ impl Executor { func: F, args: T, value: U256, - abi: Option<&Abi>, + abi: Option<&JsonAbi>, ) -> Result { let func = func.into(); let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); @@ -255,7 +255,7 @@ impl Executor { func: F, args: T, value: U256, - abi: Option<&Abi>, + abi: Option<&JsonAbi>, ) -> Result { let func = func.into(); let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); @@ -276,7 +276,7 @@ impl Executor { func: F, args: T, value: U256, - abi: Option<&Abi>, + abi: Option<&JsonAbi>, ) -> Result { let func = func.into(); let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); @@ -353,7 +353,7 @@ impl Executor { pub fn deploy_with_env( &mut self, env: Env, - abi: Option<&Abi>, + abi: Option<&JsonAbi>, ) -> Result { debug_assert!( matches!(env.tx.transact_to, TransactTo::Create(_)), @@ -442,7 +442,7 @@ impl Executor { from: Address, code: Bytes, value: U256, - abi: Option<&Abi>, + abi: Option<&JsonAbi>, ) -> Result { let env = self.build_test_env(from, TransactTo::Create(CreateScheme::Create), code, value); self.deploy_with_env(env, abi) @@ -825,7 +825,7 @@ fn convert_executed_result( } fn convert_call_result( - abi: Option<&Abi>, + abi: Option<&JsonAbi>, func: &Function, call_result: RawCallResult, ) -> Result { diff --git a/crates/evm/fuzz/src/invariant/filters.rs b/crates/evm/fuzz/src/invariant/filters.rs index 3561ef9d66728..c56450c27065d 100644 --- a/crates/evm/fuzz/src/invariant/filters.rs +++ b/crates/evm/fuzz/src/invariant/filters.rs @@ -1,4 +1,4 @@ -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Selector}; use foundry_compilers::ArtifactId; use foundry_evm_core::utils::get_function; @@ -23,7 +23,7 @@ impl ArtifactFilters { pub fn get_targeted_functions( &self, artifact: &ArtifactId, - abi: &Abi, + abi: &JsonAbi, ) -> eyre::Result>> { if let Some(selectors) = self.targeted.get(&artifact.identifier()) { let functions = selectors diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index 7faeb7a58ebfa..6dfcd8248739b 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -1,4 +1,4 @@ -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes}; use parking_lot::Mutex; use std::{collections::BTreeMap, sync::Arc}; @@ -9,7 +9,7 @@ pub use call_override::RandomCallGenerator; mod filters; pub use filters::{ArtifactFilters, SenderFilters}; -pub type TargetedContracts = BTreeMap)>; +pub type TargetedContracts = BTreeMap)>; pub type FuzzRunIdentifiedContracts = Arc>; /// (Sender, (TargetContract, Calldata)) @@ -22,6 +22,6 @@ pub struct InvariantContract<'a> { pub address: Address, /// Invariant function present in the test contract. pub invariant_function: &'a Function, - /// Abi of the test contract. - pub abi: &'a Abi, + /// ABI of the test contract. + pub abi: &'a JsonAbi, } diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 3534ffea17533..d095f10092851 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -3,7 +3,7 @@ use crate::{ invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, SenderFilters}, strategies::{fuzz_calldata, fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, }; -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes}; use parking_lot::RwLock; use proptest::prelude::*; @@ -119,7 +119,7 @@ fn select_random_sender( /// Strategy to randomly select a contract from the `contracts` list that has at least 1 function fn select_random_contract( contracts: FuzzRunIdentifiedContracts, -) -> impl Strategy)> { +) -> impl Strategy)> { let selectors = any::(); selectors.prop_map(move |selector| { let contracts = contracts.lock(); @@ -133,7 +133,10 @@ fn select_random_contract( /// /// If `targeted_functions` is not empty, select one from it. Otherwise, take any /// of the available abi functions. -fn select_random_function(abi: Abi, targeted_functions: Vec) -> BoxedStrategy { +fn select_random_function( + abi: JsonAbi, + targeted_functions: Vec, +) -> BoxedStrategy { let selectors = any::(); let possible_funcs: Vec = abi .functions() diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index f7c0abb8dd2e7..f1a919f249b83 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -5,7 +5,7 @@ use crate::{ CallTrace, CallTraceArena, DecodedCallData, DecodedCallLog, DecodedCallTrace, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Event, Function, JsonAbi as Abi}; +use alloy_json_abi::{Event, Function, JsonAbi}; use alloy_primitives::{Address, Log, Selector, B256}; use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ @@ -114,7 +114,7 @@ pub struct CallTraceDecoder { /// All known events. pub events: BTreeMap<(B256, usize), Vec>, /// All known errors. - pub errors: Abi, + pub errors: JsonAbi, /// A signature identifier for events and functions. pub signature_identifier: Option, /// Verbosity level diff --git a/crates/evm/traces/src/identifier/mod.rs b/crates/evm/traces/src/identifier/mod.rs index 3743cde8d6b64..6d86b072abf6e 100644 --- a/crates/evm/traces/src/identifier/mod.rs +++ b/crates/evm/traces/src/identifier/mod.rs @@ -1,4 +1,4 @@ -use alloy_json_abi::JsonAbi as Abi; +use alloy_json_abi::JsonAbi; use alloy_primitives::Address; use foundry_compilers::ArtifactId; use std::borrow::Cow; @@ -23,7 +23,7 @@ pub struct AddressIdentity<'a> { /// Note: This may be in the format `":"`. pub contract: Option, /// The ABI of the contract at this address - pub abi: Option>, + pub abi: Option>, /// The artifact ID of the contract, if any. pub artifact_id: Option, } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index acb9436d838a4..4f424d9847d8d 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -1,6 +1,6 @@ use super::{retry::RetryArgs, verify}; use alloy_dyn_abi::{DynSolValue, JsonAbiExt, ResolveSolType}; -use alloy_json_abi::{Constructor, JsonAbi as Abi}; +use alloy_json_abi::{Constructor, JsonAbi}; use alloy_primitives::{Address, Bytes}; use clap::{Parser, ValueHint}; use ethers_contract::ContractError; @@ -204,7 +204,7 @@ impl CreateArgs { /// Deploys the contract async fn deploy( self, - abi: Abi, + abi: JsonAbi, bin: BytecodeObject, args: Vec, provider: M, @@ -407,7 +407,7 @@ impl From> for ContractDeploymentTx { pub struct Deployer { /// The deployer's transaction, exposed for overriding the defaults pub tx: TypedTransaction, - abi: Abi, + abi: JsonAbi, client: B, confs: usize, block: BlockNumber, @@ -513,7 +513,7 @@ where #[derive(Debug)] pub struct DeploymentTxFactory { client: B, - abi: Abi, + abi: JsonAbi, bytecode: Bytes, _m: PhantomData, } @@ -540,7 +540,7 @@ where /// Creates a factory for deployment of the Contract with bytecode, and the /// constructor defined in the abi. The client will be used to send any deployment /// transaction. - pub fn new(abi: Abi, bytecode: Bytes, client: B) -> Self { + pub fn new(abi: JsonAbi, bytecode: Bytes, client: B) -> Self { Self { client, abi, bytecode, _m: PhantomData } } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 4f6a3328a9f6e..426b4885c24f3 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -1,7 +1,7 @@ use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; use alloy_dyn_abi::FunctionExt; -use alloy_json_abi::{Function, InternalType, JsonAbi as Abi}; +use alloy_json_abi::{Function, InternalType, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueHint}; use dialoguer::Confirm; @@ -439,7 +439,7 @@ impl ScriptArgs { /// corresponding function by matching the selector, first 4 bytes in the calldata. /// /// Note: We assume that the `sig` is already stripped of its prefix, See [`ScriptArgs`] - fn get_method_and_calldata(&self, abi: &Abi) -> Result<(Function, Bytes)> { + fn get_method_and_calldata(&self, abi: &JsonAbi) -> Result<(Function, Bytes)> { let (func, data) = if let Ok(func) = get_func(&self.sig) { ( abi.functions().find(|&abi_func| abi_func.selector() == func.selector()).wrap_err( diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index c32cf41c88ff0..b7c49e887627d 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -5,7 +5,7 @@ use crate::{ result::SuiteResult, ContractRunner, TestFilter, TestOptions, }; -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{ContractsByArtifact, TestFunctionExt}; @@ -30,15 +30,15 @@ use std::{ sync::{mpsc, Arc}, }; -pub type DeployableContracts = BTreeMap)>; +pub type DeployableContracts = BTreeMap)>; /// A multi contract runner receives a set of contracts deployed in an EVM instance and proceeds /// to run all test functions in these contracts. pub struct MultiContractRunner { - /// Mapping of contract name to Abi, creation bytecode and library bytecode which + /// Mapping of contract name to JsonAbi, creation bytecode and library bytecode which /// needs to be deployed & linked against pub contracts: DeployableContracts, - /// Compiled contracts by name that have an Abi and runtime bytecode + /// Compiled contracts by name that have an JsonAbi and runtime bytecode pub known_contracts: ContractsByArtifact, /// The EVM instance used in the test runner pub evm_opts: EvmOpts, @@ -47,7 +47,7 @@ pub struct MultiContractRunner { /// The EVM spec pub evm_spec: SpecId, /// All known errors, used for decoding reverts - pub errors: Option, + pub errors: Option, /// The address which will be used as the `from` field in all EVM calls pub sender: Option

, /// A map of contract names to absolute source file paths @@ -208,7 +208,7 @@ impl MultiContractRunner { fn run_tests( &self, name: &str, - contract: &Abi, + contract: &JsonAbi, executor: Executor, deploy_code: Bytes, libs: &[Bytes], diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 0308fd218e191..14783d47b9c7f 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -4,7 +4,7 @@ use crate::{ result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, }; -use alloy_json_abi::{Function, JsonAbi as Abi}; +use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{ @@ -42,9 +42,9 @@ pub struct ContractRunner<'a> { /// The deployed contract's code pub code: Bytes, /// The test contract's ABI - pub contract: &'a Abi, + pub contract: &'a JsonAbi, /// All known errors, used to decode reverts - pub errors: Option<&'a Abi>, + pub errors: Option<&'a JsonAbi>, /// The initial balance of the test contract pub initial_balance: U256, /// The address which will be used as the `from` field in all EVM calls @@ -58,11 +58,11 @@ impl<'a> ContractRunner<'a> { pub fn new( name: &'a str, executor: Executor, - contract: &'a Abi, + contract: &'a JsonAbi, code: Bytes, initial_balance: U256, sender: Option
, - errors: Option<&'a Abi>, + errors: Option<&'a JsonAbi>, predeploy_libs: &'a [Bytes], debug: bool, ) -> Self { From b51a3f2d40a83650c671a7b9d8f42f63d165fae5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:22:45 +0100 Subject: [PATCH 0449/1963] chore(evm): use method instead of get_create_address util (#6738) --- crates/cheatcodes/src/inspector.rs | 3 +-- crates/evm/core/src/utils.rs | 10 ---------- crates/evm/evm/src/inspectors/debugger.rs | 4 ++-- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index eae7af5f2c147..854397480cba6 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -23,7 +23,6 @@ use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, types::ToEthers} use foundry_evm_core::{ backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP}, - utils::get_create_address, }; use itertools::Itertools; use revm::{ @@ -258,7 +257,7 @@ impl Cheatcodes { .get(&inputs.caller) .map(|acc| acc.info.nonce) .unwrap_or_default(); - let created_address = get_create_address(inputs, old_nonce); + let created_address = inputs.created_address(old_nonce); if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { // we only grant cheat code access for new contracts if the caller also has diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 996408198caf0..cbce9fc9984da 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -268,16 +268,6 @@ pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { env.tx.transact_to = tx.to.map(TransactTo::Call).unwrap_or_else(TransactTo::create) } -/// Get the address of a contract creation -pub fn get_create_address(call: &CreateInputs, nonce: u64) -> Address { - match call.scheme { - CreateScheme::Create => call.caller.create(nonce), - CreateScheme::Create2 { salt } => { - call.caller.create2_from_code(B256::from(salt), &call.init_code) - } - } -} - /// Get the gas used, accounting for refunds pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 { let refund_quotient = if SpecId::enabled(spec, SpecId::LONDON) { 5 } else { 2 }; diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index c61a7f859dd0a..32345256ed07e 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -4,7 +4,7 @@ use foundry_evm_core::{ backend::DatabaseExt, constants::CHEATCODE_ADDRESS, debug::{DebugArena, DebugNode, DebugStep, Instruction}, - utils::{gas_used, get_create_address, CallKind}, + utils::{gas_used, CallKind}, }; use revm::{ interpreter::{ @@ -133,7 +133,7 @@ impl Inspector for Debugger { let nonce = data.journaled_state.account(call.caller).info.nonce; self.enter( data.journaled_state.depth() as usize, - get_create_address(call, nonce), + call.created_address(nonce), CallKind::Create, ); From fccf27a289a91ec89e95a883944d54bbcb249e7b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:24:13 +0100 Subject: [PATCH 0450/1963] chore: remove unused file (#6739) --- crates/evm/traces/src/inspector.rs | 250 ----------------------------- 1 file changed, 250 deletions(-) delete mode 100644 crates/evm/traces/src/inspector.rs diff --git a/crates/evm/traces/src/inspector.rs b/crates/evm/traces/src/inspector.rs deleted file mode 100644 index 14714a141b76e..0000000000000 --- a/crates/evm/traces/src/inspector.rs +++ /dev/null @@ -1,250 +0,0 @@ -use crate::{ - CallTrace, CallTraceArena, CallTraceStep, LogCallOrder, TraceCallData, TraceLog, TraceRetData, -}; -use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256}; -use foundry_evm_core::{ - debug::Instruction::OpCode, - utils::{gas_used, get_create_address, CallKind}, -}; -use revm::{ - interpreter::{ - opcode, return_ok, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, - Interpreter, - }, - Database, EVMData, Inspector, JournalEntry, -}; - -/// An inspector that collects call traces. -#[derive(Clone, Debug, Default)] -pub struct Tracer { - pub traces: CallTraceArena, - trace_stack: Vec, - step_stack: Vec<(usize, usize)>, // (trace_idx, step_idx) - record_steps: bool, -} - -impl Tracer { - /// Enables step recording. - pub fn record_steps(&mut self) { - self.record_steps = true; - } - - fn start_trace( - &mut self, - depth: usize, - address: Address, - data: Vec, - value: U256, - kind: CallKind, - caller: Address, - ) { - self.trace_stack.push(self.traces.push_trace( - 0, - CallTrace { - depth, - address, - kind, - data: TraceCallData::Raw(data.into()), - value, - status: InstructionResult::Continue, - caller, - ..Default::default() - }, - )); - } - - fn fill_trace( - &mut self, - status: InstructionResult, - cost: u64, - output: Vec, - address: Option
, - ) { - let success = matches!(status, return_ok!()); - let trace = &mut self.traces.arena - [self.trace_stack.pop().expect("more traces were filled than started")] - .trace; - trace.status = status; - trace.success = success; - trace.gas_cost = cost; - trace.output = TraceRetData::Raw(output.into()); - - if let Some(address) = address { - trace.address = address; - } - } - - fn start_step(&mut self, interp: &Interpreter<'_>, data: &EVMData<'_, DB>) { - let trace_idx = - *self.trace_stack.last().expect("can't start step without starting a trace first"); - let node = &mut self.traces.arena[trace_idx]; - - self.step_stack.push((trace_idx, node.trace.steps.len())); - - node.trace.steps.push(CallTraceStep { - depth: data.journaled_state.depth(), - pc: interp.program_counter(), - op: OpCode(interp.current_opcode()), - contract: interp.contract.address, - stack: interp.stack.clone(), - memory: interp.shared_memory.context_memory().to_vec(), - gas: interp.gas.remaining(), - gas_refund_counter: interp.gas.refunded() as u64, - gas_cost: 0, - state_diff: None, - error: None, - }); - } - - fn fill_step(&mut self, interp: &Interpreter<'_>, data: &EVMData<'_, DB>) { - let (trace_idx, step_idx) = - self.step_stack.pop().expect("can't fill step without starting a step first"); - let step = &mut self.traces.arena[trace_idx].trace.steps[step_idx]; - - let op = interp.current_opcode(); - let journal_entry = data - .journaled_state - .journal - .last() - // This should always work because revm initializes it as `vec![vec![]]` - .unwrap() - .last(); - step.state_diff = match (op, journal_entry) { - ( - opcode::SLOAD | opcode::SSTORE, - Some(JournalEntry::StorageChange { address, key, .. }), - ) => { - let value = data.journaled_state.state[address].storage[key].present_value(); - Some((*key, value)) - } - _ => None, - }; - - step.gas_cost = step.gas - interp.gas.remaining(); - - // Error codes only - if interp.instruction_result.is_error() { - step.error = Some(format!("{:?}", interp.instruction_result)); - } - } -} - -impl Inspector for Tracer { - #[inline] - fn step(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { - if self.record_steps { - self.start_step(interp, data); - } - } - - #[inline] - fn step_end(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { - if self.record_steps { - self.fill_step(interp, data); - } - } - - #[inline] - fn log(&mut self, _: &mut EVMData<'_, DB>, _: &Address, topics: &[B256], data: &Bytes) { - let node = &mut self.traces.arena[*self.trace_stack.last().expect("no ongoing trace")]; - node.ordering.push(LogCallOrder::Log(node.logs.len())); - let data = data.clone(); - node.logs - .push(TraceLog::Raw(RawLog::new(topics.to_vec(), data).expect("Received invalid log"))); - } - - #[inline] - fn call( - &mut self, - data: &mut EVMData<'_, DB>, - inputs: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { - let (from, to) = match inputs.context.scheme { - CallScheme::DelegateCall | CallScheme::CallCode => { - (inputs.context.address, inputs.context.code_address) - } - _ => (inputs.context.caller, inputs.context.address), - }; - - self.start_trace( - data.journaled_state.depth() as usize, - to, - inputs.input.to_vec(), - inputs.transfer.value, - inputs.context.scheme.into(), - from, - ); - - (InstructionResult::Continue, Gas::new(inputs.gas_limit), Bytes::new()) - } - - #[inline] - fn call_end( - &mut self, - data: &mut EVMData<'_, DB>, - _inputs: &CallInputs, - gas: Gas, - status: InstructionResult, - retdata: Bytes, - ) -> (InstructionResult, Gas, Bytes) { - self.fill_trace( - status, - gas_used(data.env.cfg.spec_id, gas.spend(), gas.refunded() as u64), - retdata.to_vec(), - None, - ); - - (status, gas, retdata) - } - - #[inline] - fn create( - &mut self, - data: &mut EVMData<'_, DB>, - inputs: &mut CreateInputs, - ) -> (InstructionResult, Option
, Gas, Bytes) { - // TODO: Does this increase gas cost? - let _ = data.journaled_state.load_account(inputs.caller, data.db); - let nonce = data.journaled_state.account(inputs.caller).info.nonce; - self.start_trace( - data.journaled_state.depth() as usize, - get_create_address(inputs, nonce), - inputs.init_code.to_vec(), - inputs.value, - inputs.scheme.into(), - inputs.caller, - ); - - (InstructionResult::Continue, None, Gas::new(inputs.gas_limit), Bytes::new()) - } - - #[inline] - fn create_end( - &mut self, - data: &mut EVMData<'_, DB>, - _inputs: &CreateInputs, - status: InstructionResult, - address: Option
, - gas: Gas, - retdata: Bytes, - ) -> (InstructionResult, Option
, Gas, Bytes) { - let code = match address { - Some(address) => data - .journaled_state - .account(address) - .info - .code - .as_ref() - .map_or(vec![], |code| code.bytes()[..code.len()].to_vec()), - None => vec![], - }; - self.fill_trace( - status, - gas_used(data.env.cfg.spec_id, gas.spend(), gas.refunded() as u64), - code, - address, - ); - - (status, address, gas, retdata) - } -} From 6e87f5e2d6f81ed28716f6e5c30939567ab798b3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:08:39 +0100 Subject: [PATCH 0451/1963] chore: new-type IC/PC maps (#6742) * chore: move pc_ic map to a new module * chore: create new types for pc-ic maps --- crates/cast/bin/cmd/storage.rs | 14 ++--- crates/common/src/contracts.rs | 8 +-- crates/debugger/src/tui/draw.rs | 4 +- crates/debugger/src/tui/mod.rs | 23 ++------ crates/evm/core/src/ic.rs | 78 +++++++++++++++++++++++++ crates/evm/core/src/lib.rs | 2 + crates/evm/core/src/utils.rs | 69 +++------------------- crates/evm/coverage/src/anchors.rs | 8 +-- crates/evm/traces/src/lib.rs | 1 + crates/forge/bin/cmd/coverage.rs | 8 +-- crates/forge/bin/cmd/script/executor.rs | 1 - 11 files changed, 112 insertions(+), 104 deletions(-) create mode 100644 crates/evm/core/src/ic.rs diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index b91258c86664a..d574883392ee0 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -17,7 +17,9 @@ use foundry_common::{ provider::ethers::RetryProvider, types::{ToAlloy, ToEthers}, }; -use foundry_compilers::{artifacts::StorageLayout, ConfigurableContractArtifact, Project, Solc}; +use foundry_compilers::{ + artifacts::StorageLayout, Artifact, ConfigurableContractArtifact, Project, Solc, +}; use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, impl_figment_convert_cast, Config, @@ -101,13 +103,9 @@ impl StorageArgs { // Find in artifacts and pretty print add_storage_layout_output(&mut project); let out = ProjectCompiler::new().compile(&project)?; - let match_code = |artifact: &ConfigurableContractArtifact| -> Option { - let bytes = - artifact.deployed_bytecode.as_ref()?.bytecode.as_ref()?.object.as_bytes()?; - Some(bytes == &address_code) - }; - let artifact = - out.artifacts().find(|(_, artifact)| match_code(artifact).unwrap_or_default()); + let artifact = out.artifacts().find(|(_, artifact)| { + artifact.get_deployed_bytecode_bytes().is_some_and(|b| *b == address_code) + }); if let Some((_, artifact)) = artifact { return fetch_and_print_storage(provider, address.clone(), artifact, true).await; } diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index be279817603bc..cc3b63f523607 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -125,13 +125,9 @@ pub fn flatten_contracts( let bytecode = if deployed_code { c.deployed_bytecode.clone().into_bytes() } else { - c.bytecode.clone().object.into_bytes() + c.bytecode.clone().into_bytes() }; - - if let Some(bytecode) = bytecode { - return Some((id.clone(), (c.abi.clone(), bytecode.to_vec()))) - } - None + bytecode.map(|bytecode| (id.clone(), (c.abi.clone(), bytecode.into()))) }) .collect(), ) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 84e56ffe1e120..fe51150714a7b 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -346,8 +346,8 @@ impl DebuggerContext<'_> { let mut source_map = bytecode.source_map()?.ok()?; let pc_ic_map = if is_create { create_map } else { rt_map }; - let ic = pc_ic_map.get(&pc)?; - let source_element = source_map.swap_remove(*ic); + let ic = pc_ic_map.get(pc)?; + let source_element = source_map.swap_remove(ic); (*file_id == source_element.index?).then_some((source_element, source_code)) }) else { diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 1b25b8befee68..494c905e236ed 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -8,10 +8,7 @@ use crossterm::{ }; use eyre::Result; use foundry_common::{compile::ContractSources, evm::Breakpoints}; -use foundry_evm_core::{ - debug::DebugNodeFlat, - utils::{build_pc_ic_map, PCICMap}, -}; +use foundry_evm_core::{debug::DebugNodeFlat, utils::PcIcMap}; use ratatui::{ backend::{Backend, CrosstermBackend}, Terminal, @@ -50,7 +47,7 @@ pub struct Debugger { /// Source map of contract sources contracts_sources: ContractSources, /// A mapping of source -> (PC -> IC map for deploy code, PC -> IC map for runtime code) - pc_ic_maps: BTreeMap, + pc_ic_maps: BTreeMap, breakpoints: Breakpoints, } @@ -76,20 +73,8 @@ impl Debugger { Some(( contract_name.clone(), ( - build_pc_ic_map( - SpecId::LATEST, - contract.bytecode.object.as_bytes()?.as_ref(), - ), - build_pc_ic_map( - SpecId::LATEST, - contract - .deployed_bytecode - .bytecode - .as_ref()? - .object - .as_bytes()? - .as_ref(), - ), + PcIcMap::new(SpecId::LATEST, contract.bytecode.bytes()?), + PcIcMap::new(SpecId::LATEST, contract.deployed_bytecode.bytes()?), ), )) }) diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs new file mode 100644 index 0000000000000..479a50b0a528d --- /dev/null +++ b/crates/evm/core/src/ic.rs @@ -0,0 +1,78 @@ +use revm::{ + interpreter::{opcode, opcode::spec_opcode_gas}, + primitives::{HashMap, SpecId}, +}; + +/// Maps from program counter to instruction counter. +/// +/// Inverse of [`IcPcMap`]. +pub struct PcIcMap { + pub inner: HashMap, +} + +impl PcIcMap { + /// Creates a new `PcIcMap` for the given code. + pub fn new(spec: SpecId, code: &[u8]) -> Self { + let opcode_infos = spec_opcode_gas(spec); + let mut map = HashMap::new(); + + let mut i = 0; + let mut cumulative_push_size = 0; + while i < code.len() { + let op = code[i]; + map.insert(i, i - cumulative_push_size); + if opcode_infos[op as usize].is_push() { + // Skip the push bytes. + // + // For more context on the math, see: https://github.com/bluealloy/revm/blob/007b8807b5ad7705d3cacce4d92b89d880a83301/crates/revm/src/interpreter/contract.rs#L114-L115 + i += (op - opcode::PUSH1 + 1) as usize; + cumulative_push_size += (op - opcode::PUSH1 + 1) as usize; + } + i += 1; + } + + Self { inner: map } + } + + /// Returns the instruction counter for the given program counter. + pub fn get(&self, pc: usize) -> Option { + self.inner.get(&pc).copied() + } +} + +/// Map from instruction counter to program counter. +/// +/// Inverse of [`PcIcMap`]. +pub struct IcPcMap { + pub inner: HashMap, +} + +impl IcPcMap { + /// Creates a new `IcPcMap` for the given code. + pub fn new(spec: SpecId, code: &[u8]) -> Self { + let opcode_infos = spec_opcode_gas(spec); + let mut map = HashMap::new(); + + let mut i = 0; + let mut cumulative_push_size = 0; + while i < code.len() { + let op = code[i]; + map.insert(i - cumulative_push_size, i); + if opcode_infos[op as usize].is_push() { + // Skip the push bytes. + // + // For more context on the math, see: https://github.com/bluealloy/revm/blob/007b8807b5ad7705d3cacce4d92b89d880a83301/crates/revm/src/interpreter/contract.rs#L114-L115 + i += (op - opcode::PUSH1 + 1) as usize; + cumulative_push_size += (op - opcode::PUSH1 + 1) as usize; + } + i += 1; + } + + Self { inner: map } + } + + /// Returns the program counter for the given instruction counter. + pub fn get(&self, ic: usize) -> Option { + self.inner.get(&ic).copied() + } +} diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 9864ded06f0b0..caafa8e0f4d23 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -7,6 +7,8 @@ #[macro_use] extern crate tracing; +mod ic; + pub mod abi; pub mod backend; pub mod constants; diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index cbce9fc9984da..55ec9a15bdf7d 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,18 +1,19 @@ -use alloy_json_abi::{Function, JsonAbi as Abi}; -use alloy_primitives::{Address, FixedBytes, B256}; +use alloy_json_abi::{Function, JsonAbi}; +use alloy_primitives::FixedBytes; use alloy_rpc_types::{Block, Transaction}; use ethers::types::{ActionType, CallType, Chain, H256, U256}; use eyre::ContextCompat; use foundry_common::types::ToAlloy; -pub use foundry_compilers::utils::RuntimeOrHandle; -pub use revm::primitives::State as StateChangeset; - use revm::{ - interpreter::{opcode, opcode::spec_opcode_gas, CallScheme, CreateInputs, InstructionResult}, + interpreter::{CallScheme, InstructionResult}, primitives::{CreateScheme, Eval, Halt, SpecId, TransactTo}, }; use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; + +pub use foundry_compilers::utils::RuntimeOrHandle; +pub use revm::primitives::State as StateChangeset; + +pub use crate::ic::*; // TODO(onbjerg): Remove this and use `CallKind` from the tracer. #[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] @@ -177,63 +178,11 @@ pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::En } } -/// A map of program counters to instruction counters. -pub type PCICMap = BTreeMap; - -/// Builds a mapping from program counters to instruction counters. -pub fn build_pc_ic_map(spec: SpecId, code: &[u8]) -> PCICMap { - let opcode_infos = spec_opcode_gas(spec); - let mut pc_ic_map: PCICMap = BTreeMap::new(); - - let mut i = 0; - let mut cumulative_push_size = 0; - while i < code.len() { - let op = code[i]; - pc_ic_map.insert(i, i - cumulative_push_size); - if opcode_infos[op as usize].is_push() { - // Skip the push bytes. - // - // For more context on the math, see: https://github.com/bluealloy/revm/blob/007b8807b5ad7705d3cacce4d92b89d880a83301/crates/revm/src/interpreter/contract.rs#L114-L115 - i += (op - opcode::PUSH1 + 1) as usize; - cumulative_push_size += (op - opcode::PUSH1 + 1) as usize; - } - i += 1; - } - - pc_ic_map -} - -/// A map of instruction counters to program counters. -pub type ICPCMap = BTreeMap; - -/// Builds a mapping from instruction counters to program counters. -pub fn build_ic_pc_map(spec: SpecId, code: &[u8]) -> ICPCMap { - let opcode_infos = spec_opcode_gas(spec); - let mut ic_pc_map: ICPCMap = ICPCMap::new(); - - let mut i = 0; - let mut cumulative_push_size = 0; - while i < code.len() { - let op = code[i]; - ic_pc_map.insert(i - cumulative_push_size, i); - if opcode_infos[op as usize].is_push() { - // Skip the push bytes. - // - // For more context on the math, see: https://github.com/bluealloy/revm/blob/007b8807b5ad7705d3cacce4d92b89d880a83301/crates/revm/src/interpreter/contract.rs#L114-L115 - i += (op - opcode::PUSH1 + 1) as usize; - cumulative_push_size += (op - opcode::PUSH1 + 1) as usize; - } - i += 1; - } - - ic_pc_map -} - /// Given an ABI and selector, it tries to find the respective function. pub fn get_function( contract_name: &str, selector: &FixedBytes<4>, - abi: &Abi, + abi: &JsonAbi, ) -> eyre::Result { abi.functions() .find(|func| func.selector().as_slice() == selector.as_slice()) diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index 0342b38e9527e..237d941d1a3d0 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -1,7 +1,7 @@ use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; use alloy_primitives::Bytes; use foundry_compilers::sourcemap::{SourceElement, SourceMap}; -use foundry_evm_core::utils::ICPCMap; +use foundry_evm_core::utils::IcPcMap; use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, @@ -11,7 +11,7 @@ use revm::{ pub fn find_anchors( bytecode: &Bytes, source_map: &SourceMap, - ic_pc_map: &ICPCMap, + ic_pc_map: &IcPcMap, item_ids: &[usize], items: &[CoverageItem], ) -> Vec { @@ -49,7 +49,7 @@ pub fn find_anchors( /// Find an anchor representing the first opcode within the given source range. pub fn find_anchor_simple( source_map: &SourceMap, - ic_pc_map: &ICPCMap, + ic_pc_map: &IcPcMap, item_id: usize, loc: &SourceLocation, ) -> eyre::Result { @@ -62,7 +62,7 @@ pub fn find_anchor_simple( })?; Ok(ItemAnchor { - instruction: *ic_pc_map.get(&instruction).ok_or_else(|| { + instruction: ic_pc_map.get(instruction).ok_or_else(|| { eyre::eyre!("We found an anchor, but we cant translate it to a program counter") })?, item_id, diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 3d5d09635807b..82186f3b7b643 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -6,6 +6,7 @@ #[macro_use] extern crate tracing; + use alloy_primitives::{Log, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CHEATCODE_ADDRESS; diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index db550b4b07d2a..771bd8bb09066 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -11,7 +11,7 @@ use forge::{ opts::EvmOpts, result::SuiteResult, revm::primitives::SpecId, - utils::{build_ic_pc_map, ICPCMap}, + utils::IcPcMap, MultiContractRunnerBuilder, TestOptions, }; use foundry_cli::{ @@ -233,15 +233,15 @@ impl CoverageArgs { // Since our coverage inspector collects hit data using program counters, the anchors also // need to be based on program counters. // TODO: Index by contract ID - let ic_pc_maps: HashMap = bytecodes + let ic_pc_maps: HashMap = bytecodes .iter() .map(|(id, bytecodes)| { // TODO: Creation bytecode as well ( id.clone(), ( - build_ic_pc_map(SpecId::LATEST, bytecodes.0.as_ref()), - build_ic_pc_map(SpecId::LATEST, bytecodes.1.as_ref()), + IcPcMap::new(SpecId::LATEST, bytecodes.0.as_ref()), + IcPcMap::new(SpecId::LATEST, bytecodes.1.as_ref()), ), ) }) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index cee58db6852e6..3d1eb7a887bec 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -44,7 +44,6 @@ impl ScriptArgs { let abi = abi.ok_or_else(|| eyre::eyre!("no ABI found for contract"))?; let bytecode = bytecode .ok_or_else(|| eyre::eyre!("no bytecode found for contract"))? - .object .into_bytes() .ok_or_else(|| { eyre::eyre!("expected fully linked bytecode, found unlinked bytecode") From d8ff5c5bd4846938f6a23fb295b9a61ad822623a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:18:22 +0100 Subject: [PATCH 0452/1963] chore: unify label map types to standard HashMap (#6743) --- crates/chisel/src/runner.rs | 4 ++-- crates/evm/evm/src/executors/mod.rs | 10 +++++----- crates/evm/evm/src/inspectors/stack.rs | 4 ++-- crates/evm/fuzz/src/lib.rs | 4 ++-- crates/forge/bin/cmd/script/mod.rs | 2 +- crates/forge/bin/cmd/script/runner.rs | 5 +---- crates/forge/src/result.rs | 12 ++++++------ crates/forge/src/runner.rs | 8 ++++---- 8 files changed, 23 insertions(+), 26 deletions(-) diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 2127ddc4de90b..4231c55b4122b 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -11,7 +11,7 @@ use foundry_evm::{ traces::{CallTraceArena, TraceKind}, }; use revm::interpreter::{return_ok, InstructionResult}; -use std::collections::BTreeMap; +use std::collections::HashMap; /// The function selector of the REPL contract's entrypoint, the `run()` function. static RUN_SELECTOR: [u8; 4] = [0xc0, 0x40, 0x62, 0x26]; @@ -44,7 +44,7 @@ pub struct ChiselResult { /// Amount of gas used in the transaction pub gas_used: u64, /// Map of addresses to their labels - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// Return data pub returned: Bytes, /// Called address diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 971a2a21f5302..bb660317861ef 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -33,7 +33,7 @@ use revm::{ BlockEnv, Bytecode, Env, ExecutionResult, Output, ResultAndState, SpecId, TransactTo, TxEnv, }, }; -use std::collections::BTreeMap; +use std::collections::HashMap; mod builder; pub use builder::ExecutorBuilder; @@ -593,7 +593,7 @@ pub struct ExecutionErr { pub logs: Vec, pub traces: Option, pub debug: Option, - pub labels: BTreeMap, + pub labels: HashMap, pub transactions: Option, pub state_changeset: Option, pub script_wallets: Vec, @@ -653,7 +653,7 @@ pub struct CallResult { /// The logs emitted during the call pub logs: Vec, /// The labels assigned to addresses during the call - pub labels: BTreeMap, + pub labels: HashMap, /// The traces of the call pub traces: Option, /// The coverage info collected during the call @@ -698,7 +698,7 @@ pub struct RawCallResult { /// The logs emitted during the call pub logs: Vec, /// The labels assigned to addresses during the call - pub labels: BTreeMap, + pub labels: HashMap, /// The traces of the call pub traces: Option, /// The coverage info collected during the call @@ -735,7 +735,7 @@ impl Default for RawCallResult { gas_refunded: 0, stipend: 0, logs: Vec::new(), - labels: BTreeMap::new(), + labels: HashMap::new(), traces: None, coverage: None, debug: None, diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 87cc29b518653..35044677f86c2 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -15,7 +15,7 @@ use revm::{ primitives::{BlockEnv, Env}, EVMData, Inspector, }; -use std::{collections::BTreeMap, sync::Arc}; +use std::{collections::HashMap, sync::Arc}; #[derive(Clone, Debug, Default)] #[must_use = "builders do nothing unless you call `build` on them"] @@ -185,7 +185,7 @@ macro_rules! call_inspectors { /// The collected results of [`InspectorStack`]. pub struct InspectorData { pub logs: Vec, - pub labels: BTreeMap, + pub labels: HashMap, pub traces: Option, pub debug: Option, pub coverage: Option, diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 72fded966fb58..66e59ebcb7835 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -15,7 +15,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, fmt}; +use std::{collections::HashMap, fmt}; pub use proptest::test_runner::{Config as FuzzConfig, Reason}; @@ -143,7 +143,7 @@ pub struct FuzzTestResult { pub decoded_logs: Vec, /// Labeled addresses - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// Exemplary traces for a fuzz run of the test function /// diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 426b4885c24f3..ad2941aa83ff3 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -590,7 +590,7 @@ pub struct ScriptResult { pub traces: Traces, pub debug: Option>, pub gas_used: u64, - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, pub transactions: Option, pub returned: Bytes, pub address: Option
, diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 28faf48be9ed7..1dc91041cf33a 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -165,10 +165,7 @@ impl ScriptRunner { returned: Bytes::new(), success, gas_used, - labeled_addresses: labeled_addresses - .into_iter() - .map(|l| (l.0, l.1)) - .collect::>(), + labeled_addresses, transactions, logs, traces, diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 94551e8763276..26646a38d4d0d 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -12,7 +12,7 @@ use foundry_evm::{ }; use serde::{Deserialize, Serialize}; use std::{ - collections::BTreeMap, + collections::{BTreeMap, HashMap}, fmt::{self, Write}, time::Duration, }; @@ -127,7 +127,7 @@ pub struct TestResult { pub coverage: Option, /// Labeled addresses - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// The debug nodes of the call pub debug: Option, @@ -266,7 +266,7 @@ pub struct TestSetup { /// Call traces of the setup pub traces: Traces, /// Addresses labeled during setup - pub labeled_addresses: BTreeMap, + pub labeled_addresses: HashMap, /// The reason the setup failed, if it did pub reason: Option, /// Coverage info during setup @@ -278,7 +278,7 @@ impl TestSetup { error: EvmError, mut logs: Vec, mut traces: Traces, - mut labeled_addresses: BTreeMap, + mut labeled_addresses: HashMap, ) -> Self { match error { EvmError::Execution(err) => { @@ -301,7 +301,7 @@ impl TestSetup { address: Address, logs: Vec, traces: Traces, - labeled_addresses: BTreeMap, + labeled_addresses: HashMap, coverage: Option, ) -> Self { Self { address, logs, traces, labeled_addresses, reason: None, coverage } @@ -310,7 +310,7 @@ impl TestSetup { pub fn failed_with( logs: Vec, traces: Traces, - labeled_addresses: BTreeMap, + labeled_addresses: HashMap, reason: String, ) -> Self { Self { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 14783d47b9c7f..686df8f44c336 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -157,7 +157,7 @@ impl<'a> ContractRunner<'a> { } Err(err) => { error!(reason=%err, contract=%address, "setUp failed"); - (Vec::new(), None, BTreeMap::new(), Some(format!("setup failed: {err}")), None) + (Vec::new(), None, HashMap::new(), Some(format!("setup failed: {err}")), None) } }; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); @@ -563,7 +563,7 @@ impl<'a> ContractRunner<'a> { let fuzzed_executor = FuzzedExecutor::new(self.executor.clone(), runner.clone(), self.sender, fuzz_config); let state = fuzzed_executor.build_fuzz_state(); - let mut result = fuzzed_executor.fuzz(func, address, should_fail, self.errors); + let result = fuzzed_executor.fuzz(func, address, should_fail, self.errors); let mut debug = Default::default(); let mut breakpoints = Default::default(); @@ -631,8 +631,8 @@ impl<'a> ContractRunner<'a> { }; // Record logs, labels and traces - logs.append(&mut result.logs); - labeled_addresses.append(&mut result.labeled_addresses); + logs.extend(result.logs); + labeled_addresses.extend(result.labeled_addresses); traces.extend(result.traces.map(|traces| (TraceKind::Execution, traces))); coverage = merge_coverages(coverage, result.coverage); From 3f70800588666a8caf7799ace3086cfb669fc12d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 9 Jan 2024 18:19:38 +0100 Subject: [PATCH 0453/1963] chore: update usdc addr (#6741) --- crates/forge/tests/fixtures/repro_6531.stdout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout index 319d0a422dff1..d2c2596cb169d 100644 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -9,7 +9,7 @@ Traces: ├─ [0] VM::createSelectFork("") │ └─ ← 0 ├─ [10350] 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48::name() [staticcall] - │ ├─ [3061] 0xa2327a938Febf5FEC13baCFb16Ae10EcBc4cbDCF::name() [delegatecall] + │ ├─ [3061] 0x43506849D7C04F9138D1A2050bbF3A0c054402dd::name() [delegatecall] │ │ └─ ← "USD Coin" │ └─ ← "USD Coin" └─ ← () From ce5d2b5b280a7d79b972d6ebfe6bf3925447e833 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 9 Jan 2024 18:38:08 +0100 Subject: [PATCH 0454/1963] fix: dont strip empty () on constructors (#6740) * fix: dont strip empty () on constructors * else if --- crates/fmt/src/formatter.rs | 35 +++++++++++++++++++ .../testdata/ConstructorModifierStyle/fmt.sol | 13 +++++++ .../ConstructorModifierStyle/original.sol | 13 +++++++ crates/fmt/tests/formatter.rs | 1 + 4 files changed, 62 insertions(+) create mode 100644 crates/fmt/testdata/ConstructorModifierStyle/fmt.sol create mode 100644 crates/fmt/testdata/ConstructorModifierStyle/original.sol diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 774cd3345264a..89829a59b053e 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -80,6 +80,13 @@ struct Context { if_stmt_single_line: Option, } +impl Context { + /// Returns true if the current function context is the constructor + pub(crate) fn is_constructor_function(&self) -> bool { + self.function.as_ref().map_or(false, |f| matches!(f.ty, FunctionTy::Constructor)) + } +} + /// A Solidity formatter #[derive(Debug)] pub struct Formatter<'a, W> { @@ -3047,6 +3054,18 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { self.visit_list("", args, None, Some(loc.end()), false)? } FunctionAttribute::BaseOrModifier(loc, base) => { + // here we need to find out if this attribute belongs to the constructor because the + // modifier need to include the trailing parenthesis + // This is very ambiguous because the modifier can either by an inherited contract + // or a modifier here: e.g.: This is valid constructor: + // `constructor() public Ownable() OnlyOwner {}` + let is_constructor = self.context.is_constructor_function(); + // we can't make any decisions here regarding trailing `()` because we'd need to + // find out if the `base` is a solidity modifier or an + // interface/contract therefor we we its raw content. + + // we can however check if the contract `is` the `base`, this however also does + // not cover all cases let is_contract_base = self.context.contract.as_ref().map_or(false, |contract| { contract.base.iter().any(|contract_base| { contract_base @@ -3060,6 +3079,20 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { if is_contract_base { base.visit(self)?; + } else if is_constructor { + // This is ambiguous because the modifier can either by an inherited + // contract modifiers with empty parenthesis are + // valid, but not required so we make the assumption + // here that modifiers are lowercase + let mut base_or_modifier = + self.visit_to_chunk(loc.start(), Some(loc.end()), base)?; + let is_lowercase = + base_or_modifier.content.chars().next().map_or(false, |c| c.is_lowercase()); + if is_lowercase && base_or_modifier.content.ends_with("()") { + base_or_modifier.content.truncate(base_or_modifier.content.len() - 2); + } + + self.write_chunk(&base_or_modifier)?; } else { let mut base_or_modifier = self.visit_to_chunk(loc.start(), Some(loc.end()), base)?; @@ -3110,6 +3143,8 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { })?; if base.args.is_none() || base.args.as_ref().unwrap().is_empty() { + // This is ambiguous because the modifier can either by an inherited contract or a + // modifier if self.context.function.is_some() { name.content.push_str("()"); } diff --git a/crates/fmt/testdata/ConstructorModifierStyle/fmt.sol b/crates/fmt/testdata/ConstructorModifierStyle/fmt.sol new file mode 100644 index 0000000000000..88694860aded2 --- /dev/null +++ b/crates/fmt/testdata/ConstructorModifierStyle/fmt.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.5.2; + +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import {ERC1155} from "solmate/tokens/ERC1155.sol"; + +import {IAchievements} from "./interfaces/IAchievements.sol"; +import {SoulBound1155} from "./abstracts/SoulBound1155.sol"; + +contract Achievements is IAchievements, SoulBound1155, Ownable { + constructor(address owner) Ownable() ERC1155() {} +} diff --git a/crates/fmt/testdata/ConstructorModifierStyle/original.sol b/crates/fmt/testdata/ConstructorModifierStyle/original.sol new file mode 100644 index 0000000000000..88694860aded2 --- /dev/null +++ b/crates/fmt/testdata/ConstructorModifierStyle/original.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.5.2; + +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import {ERC1155} from "solmate/tokens/ERC1155.sol"; + +import {IAchievements} from "./interfaces/IAchievements.sol"; +import {SoulBound1155} from "./abstracts/SoulBound1155.sol"; + +contract Achievements is IAchievements, SoulBound1155, Ownable { + constructor(address owner) Ownable() ERC1155() {} +} diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 4a391ee773dd0..2e5d77054051f 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -181,6 +181,7 @@ macro_rules! test_directories { test_directories! { ConstructorDefinition, + ConstructorModifierStyle, ContractDefinition, DocComments, EnumDefinition, From 4adcae5f5a833a4aa767efd7d53e09fb35a147e9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 9 Jan 2024 20:18:06 +0100 Subject: [PATCH 0455/1963] chore: rm one to_ethers call (#6745) * chore: rm one to_ethers call * Update crates/chisel/src/executor.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/chisel/src/executor.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index f287bc5bdf212..f3dcb40f37810 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -10,7 +10,6 @@ use alloy_json_abi::EventParam; use alloy_primitives::{hex, Address, U256}; use core::fmt::Debug; use eyre::{Result, WrapErr}; -use foundry_common::types::ToEthers; use foundry_compilers::Artifact; use foundry_evm::{ backend::Backend, decode::decode_console_logs, executors::ExecutorBuilder, @@ -237,7 +236,7 @@ impl SessionSource { // the file compiled correctly, thus the last stack item must be the memory offset of // the `bytes memory inspectoor` value - let mut offset = stack.data().last().unwrap().to_ethers().as_usize(); + let mut offset = stack.data().last().unwrap().to::(); let mem_offset = &memory[offset..offset + 32]; let len = U256::try_from_be_slice(mem_offset).unwrap().to::(); offset += 32; From 05d60629f9a9c328763179204772562bea4cef40 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 9 Jan 2024 22:19:36 +0100 Subject: [PATCH 0456/1963] chore: new retryable ratelimit error (#6751) --- crates/common/src/provider/retry.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index e640728e0d6ac..bf1d0c31cb074 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -97,6 +97,7 @@ fn should_retry_json_rpc_error(error: &ErrorPayload) -> bool { "daily request count exceeded, request rate limited" => true, msg => { msg.contains("rate limit") || + msg.contains("rate exceeded") || msg.contains("too many requests") || msg.contains("request limit") } From 177a1f41658db813fc4d7f50f40ab7804fcb427c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 10 Jan 2024 11:28:12 +0100 Subject: [PATCH 0457/1963] chore(deps): add revm-inspectors (#6750) --- Cargo.lock | 701 ++--------------------------------- Cargo.toml | 3 + crates/evm/traces/Cargo.toml | 2 +- crates/evm/traces/src/lib.rs | 4 +- 4 files changed, 34 insertions(+), 676 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 053e5c49a80cf..ea701b879980f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,7 +82,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa1873637aa7f20369eae38b312cf7550c266d13ebc60f176fd5c82c5127810b" dependencies = [ - "num_enum 0.7.1", + "num_enum", "serde", "strum", ] @@ -250,7 +250,6 @@ dependencies = [ "alloy-rlp", "alloy-rpc-types", "itertools 0.12.0", - "jsonrpsee-types", "serde", "serde_json", "thiserror", @@ -264,7 +263,6 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "itertools 0.12.0", - "jsonrpsee-types", "serde", "serde_json", "thiserror", @@ -280,7 +278,7 @@ dependencies = [ "const-hex", "dunce", "heck", - "indexmap 2.1.0", + "indexmap", "proc-macro-error", "proc-macro2", "quote", @@ -949,15 +947,6 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" -dependencies = [ - "serde", -] - [[package]] name = "bimap" version = "0.6.3" @@ -1077,144 +1066,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "boa_ast" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73498e9b2f0aa7db74977afa4d594657611e90587abf0dd564c0b55b4a130163" -dependencies = [ - "bitflags 2.4.1", - "boa_interner", - "boa_macros", - "indexmap 2.1.0", - "num-bigint", - "rustc-hash", -] - -[[package]] -name = "boa_engine" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16377479d5d6d33896e7acdd1cc698d04a8f72004025bbbddf47558cd29146a6" -dependencies = [ - "bitflags 2.4.1", - "boa_ast", - "boa_gc", - "boa_icu_provider", - "boa_interner", - "boa_macros", - "boa_parser", - "boa_profiler", - "chrono", - "dashmap", - "fast-float", - "icu_normalizer", - "indexmap 2.1.0", - "itertools 0.11.0", - "num-bigint", - "num-integer", - "num-traits", - "num_enum 0.6.1", - "once_cell", - "pollster", - "rand 0.8.5", - "regress", - "rustc-hash", - "ryu-js", - "serde", - "serde_json", - "sptr", - "static_assertions", - "tap", - "thin-vec", - "thiserror", -] - -[[package]] -name = "boa_gc" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c97b44beaef9d4452342d117d94607fdfa8d474280f1ba0fd97853834e3a49b2" -dependencies = [ - "boa_macros", - "boa_profiler", - "thin-vec", -] - -[[package]] -name = "boa_icu_provider" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30e52e34e451dd0bfc2c654a9a43ed34b0073dbd4ae3394b40313edda8627aa" -dependencies = [ - "icu_collections", - "icu_normalizer", - "icu_properties", - "icu_provider", - "icu_provider_adapters", - "icu_provider_blob", - "once_cell", -] - -[[package]] -name = "boa_interner" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e5afa991908cfbe79bd3109b824e473a1dc5f74f31fab91bb44c9e245daa77" -dependencies = [ - "boa_gc", - "boa_macros", - "hashbrown 0.14.3", - "indexmap 2.1.0", - "once_cell", - "phf 0.11.2", - "rustc-hash", - "static_assertions", -] - -[[package]] -name = "boa_macros" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005fa0c5bd20805466dda55eb34cd709bb31a2592bb26927b47714eeed6914d8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "synstructure 0.13.0", -] - -[[package]] -name = "boa_parser" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e09afb035377a9044443b598187a7d34cd13164617182a4d7c348522ee3f052" -dependencies = [ - "bitflags 2.4.1", - "boa_ast", - "boa_icu_provider", - "boa_interner", - "boa_macros", - "boa_profiler", - "fast-float", - "icu_locid", - "icu_properties", - "icu_provider", - "icu_provider_macros", - "num-bigint", - "num-traits", - "once_cell", - "regress", - "rustc-hash", - "tinystr", -] - -[[package]] -name = "boa_profiler" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190f92dfe48224adc92881c620f08ccf37ff62b91a094bb357fe53bd5e84647" - [[package]] name = "bs58" version = "0.5.0" @@ -1624,12 +1475,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "cobs" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" - [[package]] name = "coins-bip32" version = "0.8.7" @@ -1911,12 +1756,6 @@ dependencies = [ "itertools 0.10.5", ] -[[package]] -name = "critical-section" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" - [[package]] name = "crossbeam-channel" version = "0.5.10" @@ -2040,41 +1879,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "darling" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.48", -] - -[[package]] -name = "darling_macro" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.48", -] - [[package]] name = "dashmap" version = "5.5.3" @@ -2111,7 +1915,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde", ] [[package]] @@ -2249,17 +2052,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "dotenvy" version = "0.15.7" @@ -2329,12 +2121,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "embedded-io" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" - [[package]] name = "ena" version = "0.14.2" @@ -2623,7 +2409,7 @@ dependencies = [ "ethabi", "generic-array", "k256", - "num_enum 0.7.1", + "num_enum", "once_cell", "open-fastrlp", "rand 0.8.5", @@ -2838,12 +2624,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fast-float" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" - [[package]] name = "fastrand" version = "2.0.1" @@ -3473,7 +3253,7 @@ dependencies = [ "itertools 0.11.0", "once_cell", "ordered-float", - "reth-revm-inspectors", + "revm-inspectors", "serde", "tempfile", "tokio", @@ -4007,7 +3787,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.1.0", + "indexmap", "slab", "tokio", "tokio-util", @@ -4058,15 +3838,6 @@ dependencies = [ "ahash 0.7.7", ] -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.7", -] - [[package]] name = "hashbrown" version = "0.14.3" @@ -4303,128 +4074,6 @@ dependencies = [ "cc", ] -[[package]] -name = "icu_collections" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8302d8dfd6044d3ddb3f807a5ef3d7bbca9a574959c6d6e4dc39aa7012d0d5" -dependencies = [ - "displaydoc", - "serde", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3003f85dccfc0e238ff567693248c59153a46f4e6125ba4020b973cef4d1d335" -dependencies = [ - "displaydoc", - "litemap", - "serde", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_normalizer" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "652869735c9fb9f5a64ba180ee16f2c848390469c116deef517ecc53f4343598" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_properties", - "icu_provider", - "serde", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_properties" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce0e1aa26851f16c9e04412a5911c86b7f8768dac8f8d4c5f1c568a7e5d7a434" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_provider", - "serde", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_provider" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dc312a7b6148f7dfe098047ae2494d12d4034f48ade58d4f353000db376e305" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "postcard", - "serde", - "stable_deref_trait", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_adapters" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ae1e2bd0c41728b77e7c46e9afdec5e2127d1eedacc684724667d50c126bd3" -dependencies = [ - "icu_locid", - "icu_provider", - "serde", - "tinystr", - "yoke", - "zerovec", -] - -[[package]] -name = "icu_provider_blob" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd364c9a01f791a4bc04a74cf2a1d01d9f6926a40fd5ae1c28004e1e70d8338b" -dependencies = [ - "icu_provider", - "postcard", - "serde", - "writeable", - "yoke", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b728b9421e93eff1d9f8681101b78fa745e0748c95c655c83f337044a7e10" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "0.5.0" @@ -4513,17 +4162,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.1.0" @@ -4532,7 +4170,6 @@ checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.3", - "serde", ] [[package]] @@ -4704,20 +4341,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "jsonrpsee-types" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "jsonwebtoken" version = "8.3.0" @@ -4914,12 +4537,6 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" -[[package]] -name = "litemap" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d642685b028806386b2b6e75685faadd3eb65a85fff7df711ce18446a422da" - [[package]] name = "lock_api" version = "0.4.11" @@ -5279,7 +4896,6 @@ dependencies = [ "autocfg", "num-integer", "num-traits", - "serde", ] [[package]] @@ -5344,34 +4960,13 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive 0.6.1", -] - [[package]] name = "num_enum" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" dependencies = [ - "num_enum_derive 0.7.1", -] - -[[package]] -name = "num_enum_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 2.0.48", + "num_enum_derive", ] [[package]] @@ -5415,10 +5010,6 @@ name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -dependencies = [ - "critical-section", - "portable-atomic", -] [[package]] name = "oorandom" @@ -5601,7 +5192,7 @@ checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ "proc-macro2", "syn 1.0.109", - "synstructure 0.12.6", + "synstructure", ] [[package]] @@ -5780,7 +5371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap", ] [[package]] @@ -5970,29 +5561,12 @@ dependencies = [ "plotters-backend", ] -[[package]] -name = "pollster" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" - [[package]] name = "portable-atomic" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" -[[package]] -name = "postcard" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" -dependencies = [ - "cobs", - "embedded-io", - "serde", -] - [[package]] name = "powerfmt" version = "0.2.0" @@ -6416,16 +5990,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" -[[package]] -name = "regress" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a9ecfa0cb04d0b04dddb99b8ccf4f66bc8dfd23df694b398570bd8ae3a50fb" -dependencies = [ - "hashbrown 0.13.2", - "memchr", -] - [[package]] name = "reqwest" version = "0.11.23" @@ -6471,52 +6035,28 @@ dependencies = [ ] [[package]] -name = "reth-revm-inspectors" -version = "0.1.0-alpha.13" -source = "git+https://github.com/paradigmxyz/reth/?branch=main#8b56f50f3e326c1ef861ac3899dffd7f8a533c94" +name = "revm" +version = "3.5.0" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" dependencies = [ - "alloy-primitives", - "alloy-sol-types", - "boa_engine", - "boa_gc", - "reth-rpc-types", - "revm", + "auto_impl", + "revm-interpreter", + "revm-precompile", "serde", "serde_json", - "thiserror", - "tokio", ] [[package]] -name = "reth-rpc-types" -version = "0.1.0-alpha.13" -source = "git+https://github.com/paradigmxyz/reth/?branch=main#8b56f50f3e326c1ef861ac3899dffd7f8a533c94" +name = "revm-inspectors" +version = "0.1.0" +source = "git+https://github.com/paradigmxyz/evm-inspectors#31a9593b253b382312be0b814091bb5ff057364d" dependencies = [ "alloy-primitives", - "alloy-rlp", "alloy-rpc-trace-types", "alloy-rpc-types", - "bytes", - "itertools 0.12.0", - "jsonrpsee-types", - "secp256k1 0.27.0", - "serde", - "serde_json", - "serde_with", - "thiserror", - "url", -] - -[[package]] -name = "revm" -version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" -dependencies = [ - "auto_impl", - "revm-interpreter", - "revm-precompile", + "alloy-sol-types", + "revm", "serde", - "serde_json", ] [[package]] @@ -6539,7 +6079,7 @@ dependencies = [ "once_cell", "revm-primitives", "ripemd", - "secp256k1 0.28.1", + "secp256k1", "sha2 0.10.8", "substrate-bn", ] @@ -6555,9 +6095,11 @@ dependencies = [ "bitflags 2.4.1", "bitvec", "c-kzg", + "derive_more", "enumn", "hashbrown 0.14.3", "hex", + "once_cell", "serde", ] @@ -6927,12 +6469,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" -[[package]] -name = "ryu-js" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6518fc26bced4d53678a22d6e423e9d8716377def84545fe328236e3af070e7f" - [[package]] name = "salsa20" version = "0.10.2" @@ -7050,32 +6586,13 @@ dependencies = [ "zeroize", ] -[[package]] -name = "secp256k1" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" -dependencies = [ - "rand 0.8.5", - "secp256k1-sys 0.8.1", -] - [[package]] name = "secp256k1" version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f622567e3b4b38154fb8190bcf6b160d7a4301d70595a49195b48c116007a27" dependencies = [ - "secp256k1-sys 0.9.2", -] - -[[package]] -name = "secp256k1-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" -dependencies = [ - "cc", + "secp256k1-sys", ] [[package]] @@ -7186,7 +6703,7 @@ version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ - "indexmap 2.1.0", + "indexmap", "itoa", "ryu", "serde", @@ -7244,35 +6761,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" -dependencies = [ - "base64 0.21.5", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.1.0", - "serde", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "serial_test" version = "2.0.0" @@ -7514,18 +7002,6 @@ dependencies = [ "der", ] -[[package]] -name = "sptr" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" @@ -7696,18 +7172,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "synstructure" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "unicode-xid", -] - [[package]] name = "system-configuration" version = "0.5.1" @@ -7802,12 +7266,6 @@ dependencies = [ "phf_codegen 0.11.2", ] -[[package]] -name = "thin-vec" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" - [[package]] name = "thiserror" version = "1.0.56" @@ -7887,17 +7345,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinystr" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8faa444297615a4e020acb64146b0603c9c395c03a97c17fd9028816d3b4d63e" -dependencies = [ - "displaydoc", - "serde", - "zerovec", -] - [[package]] name = "tinytemplate" version = "1.2.1" @@ -8048,7 +7495,7 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ - "indexmap 2.1.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -8070,7 +7517,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap", "toml_datetime", "winnow", ] @@ -8081,7 +7528,7 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.1.0", + "indexmap", "toml_datetime", "winnow", ] @@ -8092,7 +7539,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.1.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -8437,18 +7884,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.1" @@ -8953,18 +8388,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad7bb64b8ef9c0aa27b6da38b452b0ee9fd82beaf276a87dd796fb55cbae14e" - [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -9011,30 +8434,6 @@ version = "1.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" -[[package]] -name = "yoke" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e71b2e4f287f467794c671e2b8f8a5f3716b3c829079a1c44740148eff07e4" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e6936f0cce458098a201c245a11bef556c6a0181129c7034d10d76d1ec3a2b8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "synstructure 0.13.0", -] - [[package]] name = "zerocopy" version = "0.7.32" @@ -9055,27 +8454,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "zerofrom" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655b0814c5c0b19ade497851070c640773304939a6c0fd5f5fb43da0696d05b7" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a647510471d372f2e6c2e6b7219e44d8c574d24fdc11c610a61455782f18c3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "synstructure 0.13.0", -] - [[package]] name = "zeroize" version = "1.7.0" @@ -9096,29 +8474,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "zerovec" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "591691014119b87047ead4dcf3e6adfbf73cb7c38ab6980d4f18a32138f35d46" -dependencies = [ - "serde", - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4a1638a1934450809c2266a70362bfc96cd90550c073f5b8a55014d1010157" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "zip" version = "0.6.6" diff --git a/Cargo.toml b/Cargo.toml index e166bc65adf0e..3989bcd43ff1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,6 +131,7 @@ foundry-compilers = { version = "0.1.4", default-features = false } # no default features to avoid c-kzg revm = { version = "3", default-features = false } revm-primitives = { version = "1", default-features = false } +revm-inspectors = { version = "0.1", default-features = false } ## ethers ethers = { version = "2.0", default-features = false } @@ -223,3 +224,5 @@ revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } + +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors" } diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index d3fe2338e9b3b..28d81e2fee7f5 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -21,7 +21,7 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true -reth-revm-inspectors = { git = "https://github.com/paradigmxyz/reth/", branch = "main" } +revm-inspectors.workspace = true eyre = "0.6" futures = "0.3" diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 82186f3b7b643..b9ddbd5c592ad 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -24,8 +24,8 @@ use identifier::LocalTraceIdentifier; mod decoder; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; -use reth_revm_inspectors::tracing::types::LogCallOrder; -pub use reth_revm_inspectors::tracing::{ +use revm_inspectors::tracing::types::LogCallOrder; +pub use revm_inspectors::tracing::{ types::{CallKind, CallTrace, CallTraceNode}, CallTraceArena, GethTraceBuilder, ParityTraceBuilder, StackSnapshotType, TracingInspector, TracingInspectorConfig, From 61b2e1f598a568553a457e81402ffb63d37ca6ca Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:46:57 +0100 Subject: [PATCH 0458/1963] chore(deps): bump alloys (#6754) --- Cargo.lock | 219 +++++++++++++++------------ Cargo.toml | 49 +++--- crates/cheatcodes/src/test/expect.rs | 2 +- crates/common/src/abi.rs | 11 +- crates/evm/core/src/decode.rs | 2 +- crates/evm/traces/src/decoder/mod.rs | 4 +- crates/evm/traces/src/lib.rs | 6 +- 7 files changed, 159 insertions(+), 134 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea701b879980f..f87f19d905fae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", "once_cell", "version_check", ] @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb9c4b008d0004a0518ba69f3cd9e94795f3c23b71a80e1ef3bf499f67fba23" +checksum = "fcf1d316f6375d7cff11b526e91938b199e021da118861f9d238438938e0ac7d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -108,11 +108,22 @@ dependencies = [ "winnow", ] +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "serde", + "thiserror", +] + [[package]] name = "alloy-json-abi" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "838228983f74f30e4efbd8d42d25bfe1b5bf6450ca71ee9d7628f134fbe8ae8e" +checksum = "b7b07fb0de8c985deebc60b97fc8c45fd45c101822c3241c1f389e9f9a557dd7" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -123,7 +134,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-primitives", "serde", @@ -132,20 +143,22 @@ dependencies = [ ] [[package]] -name = "alloy-networks" +name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ + "alloy-eips", "alloy-json-rpc", "alloy-primitives", "alloy-rlp", + "serde", ] [[package]] name = "alloy-primitives" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c234f92024707f224510ff82419b2be0e1d8e1fd911defcac5a085cd7f83898" +checksum = "3729132072f369bc4e8e6e070f9cf4deb3490fc9b9eea6f71f75ec19406df811" dependencies = [ "alloy-rlp", "arbitrary", @@ -155,9 +168,10 @@ dependencies = [ "derive_arbitrary", "derive_more", "ethereum_ssz", - "getrandom 0.2.11", + "getrandom 0.2.12", "hex-literal", "itoa", + "k256", "keccak-asm", "proptest", "proptest-derive", @@ -170,9 +184,9 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ - "alloy-networks", + "alloy-network", "alloy-primitives", "alloy-rpc-client", "alloy-rpc-trace-types", @@ -189,7 +203,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -227,7 +241,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -244,7 +258,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -258,7 +272,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -270,9 +284,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970e5cf1ca089e964d4f7f7afc7c9ad642bfb1bdc695a20b0cba3b3c28954774" +checksum = "5531f0a16e36c547e68c73a1638bea1f26237ee8ae785527190c4e4f9fecd2c5" dependencies = [ "alloy-json-abi", "const-hex", @@ -290,18 +304,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82c1ed2d61e982cef4c4d709f4aeef5f39a6a6a7c59b6e54c9ed4f3f7e3741b" +checksum = "6958f72e4aa4acc979ea70bca59204336c0686e92b26d02d48244cf25b0dabb0" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a059d4d2c78f8f21e470772c75f9abd9ac6d48c2aaf6b278d1ead06ed9ac664" +checksum = "783eb720b73d38f9d4c1fb9890e4db6bc8c708f7aa77d3071a19e06091ecd1c9" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -313,10 +327,10 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-json-rpc", - "base64 0.21.5", + "base64 0.21.6", "serde", "serde_json", "thiserror", @@ -329,7 +343,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -342,7 +356,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -360,7 +374,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy/#ec44bb040721e4dd85a3f1de5aeb92d4b29563ce" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -736,7 +750,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener 4.0.0", + "event-listener 4.0.3", "event-listener-strategy", "futures-core", "pin-project-lite", @@ -744,11 +758,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ - "event-listener 4.0.0", + "event-listener 4.0.3", "event-listener-strategy", "pin-project-lite", ] @@ -775,9 +789,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.5.0" +version = "4.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" +checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" @@ -858,7 +872,7 @@ checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", - "base64 0.21.5", + "base64 0.21.6", "bitflags 1.3.2", "bytes", "futures-util", @@ -931,9 +945,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "c79fed4cdb43e993fcdadc7e58a09fd0e3e649c4436fa11da71c9f1f3ee7feb9" [[package]] name = "base64ct" @@ -1391,9 +1405,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.13" +version = "4.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52bdc885e4cacc7f7c9eedc1ef6da641603180c783c41a15c264944deeaab642" +checksum = "33e92c5c1a78c62968ec57dbc2440366a2d6e5a23faf829970ff1585dc6b18e2" dependencies = [ "clap_builder", "clap_derive", @@ -1401,9 +1415,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.12" +version = "4.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" +checksum = "f4323769dc8a61e2c39ad7dc26f6f2800524691a44d74fe3d1071a5c24db6370" dependencies = [ "anstream", "anstyle", @@ -1513,7 +1527,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.5", + "base64 0.21.6", "bech32", "bs58", "digest 0.10.7", @@ -1536,7 +1550,7 @@ dependencies = [ "async-trait", "byteorder", "cfg-if", - "getrandom 0.2.11", + "getrandom 0.2.12", "hex", "hidapi-rusb", "js-sys", @@ -1618,15 +1632,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -1758,44 +1772,37 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2" +checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.17" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crossterm" @@ -2157,7 +2164,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" dependencies = [ - "base64 0.21.5", + "base64 0.21.6", "bytes", "hex", "k256", @@ -2472,7 +2479,7 @@ source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a68 dependencies = [ "async-trait", "auto_impl", - "base64 0.21.5", + "base64 0.21.6", "bytes", "const-hex", "enr", @@ -2576,9 +2583,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "4.0.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" dependencies = [ "concurrent-queue", "parking", @@ -2591,7 +2598,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 4.0.0", + "event-listener 4.0.3", "pin-project-lite", ] @@ -2895,9 +2902,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa44d981bf2493204dee4af1116ed9250656050d48b5569fa1e153fa4af75bdd" +checksum = "3e3511658a04060f9c28b45ef0f3a483f605ba2f7a3563f993476115e247eef9" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3042,9 +3049,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.1.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9f9741733af2e2ff11f5671d57ba421948ca26addf4086e1d1c849f19b73dc" +checksum = "20ee41934709326534bf5fdc3b6e438d1c39c9cad019a7ec5b9fcdb28019a0e5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3384,9 +3391,9 @@ checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" dependencies = [ "futures-core", "pin-project-lite", @@ -3486,9 +3493,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -4347,7 +4354,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.5", + "base64 0.21.6", "pem", "ring 0.16.20", "serde", @@ -4464,9 +4471,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libgit2-sys" @@ -4521,9 +4528,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.12" +version = "1.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +checksum = "295c17e837573c8c821dbaeb3cceb3d745ad082f7572191409e69cbc1b3fd050" dependencies = [ "cc", "libc", @@ -4962,20 +4969,20 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5638,6 +5645,15 @@ dependencies = [ "toml_edit 0.20.7", ] +[[package]] +name = "proc-macro-crate" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" +dependencies = [ + "toml_edit 0.21.0", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -5847,7 +5863,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", ] [[package]] @@ -5921,7 +5937,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", "libredox", "thiserror", ] @@ -5996,7 +6012,7 @@ version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ - "base64 0.21.5", + "base64 0.21.6", "bytes", "encoding_rs", "futures-core", @@ -6037,7 +6053,7 @@ dependencies = [ [[package]] name = "revm" version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" dependencies = [ "auto_impl", "revm-interpreter", @@ -6049,7 +6065,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#31a9593b253b382312be0b814091bb5ff057364d" +source = "git+https://github.com/paradigmxyz/evm-inspectors#b9e6e4ea25b00e0ddcbe1f295c8a69a6d2a08e39" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6062,7 +6078,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" dependencies = [ "revm-primitives", "serde", @@ -6071,7 +6087,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6087,7 +6103,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#b00ebab8b3477f87e3d876a11b8f18d00a8f4103" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -6135,7 +6151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", - "getrandom 0.2.11", + "getrandom 0.2.12", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -6409,7 +6425,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.5", + "base64 0.21.6", ] [[package]] @@ -7144,9 +7160,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ede2e5b2c6bfac4bc0ff4499957a11725dc12a7ddb86270e827ef575892553" +checksum = "3cfbd642e1748fd9e47951973abfa78f825b11fbf68af9e6b9db4c983a770166" dependencies = [ "paste", "proc-macro2", @@ -7236,9 +7252,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -7896,7 +7912,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", "serde", ] @@ -8522,3 +8538,8 @@ dependencies = [ "cc", "pkg-config", ] + +[[patch.unused]] +name = "alloy-signer" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" diff --git a/Cargo.toml b/Cargo.toml index 3989bcd43ff1c..9b2ef7a62336f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,8 +124,8 @@ foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities -foundry-block-explorers = { version = "0.1.3", default-features = false } -foundry-compilers = { version = "0.1.4", default-features = false } +foundry-block-explorers = { version = "0.2.0", default-features = false } +foundry-compilers = { version = "0.2.1", default-features = false } ## revm # no default features to avoid c-kzg @@ -144,21 +144,22 @@ ethers-middleware = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy +alloy-consensus = "0.1.0" +alloy-json-rpc = "0.1.0" alloy-providers = "0.1.0" +alloy-pubsub = "0.1.0" +alloy-rpc-client = "0.1.0" +alloy-rpc-trace-types = "0.1.0" +alloy-rpc-types = "0.1.0" alloy-transport = "0.1.0" alloy-transport-http = "0.1.0" -alloy-transport-ws = "0.1.0" alloy-transport-ipc = "0.1.0" -alloy-rpc-types = "0.1.0" -alloy-rpc-trace-types = "0.1.0" -alloy-json-rpc = "0.1.0" -alloy-pubsub = "0.1.0" -alloy-rpc-client = "0.1.0" -alloy-primitives = "0.5.1" -alloy-dyn-abi = "0.5.1" -alloy-json-abi = "0.5.1" -alloy-sol-types = "0.5.1" -syn-solidity = "0.5.0" +alloy-transport-ws = "0.1.0" +alloy-primitives = "0.6.0" +alloy-dyn-abi = "0.6.0" +alloy-json-abi = "0.6.0" +alloy-sol-types = "0.6.0" +syn-solidity = "0.6.0" alloy-chains = "0.1.5" alloy-rlp = "0.3.3" @@ -209,16 +210,18 @@ ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194 ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -alloy-providers = { git = "https://github.com/alloy-rs/alloy/" } -alloy-transport = { git = "https://github.com/alloy-rs/alloy/" } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy/" } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy/" } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy/" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy/" } -alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy/" } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy/" } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy/" } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy/" } +# alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" } +alloy-providers = { git = "https://github.com/alloy-rs/alloy" } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" } +alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index bdecef14204a3..2904be99e09e8 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,5 +1,5 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::{address, Address, Bytes, Log as RawLog, B256, U256}; +use alloy_primitives::{address, Address, Bytes, LogData as RawLog, B256, U256}; use alloy_sol_types::{SolError, SolValue}; use revm::interpreter::{return_ok, InstructionResult}; use spec::Vm; diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 622d8481cf924..011f51cb807c0 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -2,7 +2,7 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function}; -use alloy_primitives::{hex, Address, Log}; +use alloy_primitives::{hex, Address, LogData}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; use foundry_config::Chain; @@ -98,7 +98,7 @@ pub fn get_event(sig: &str) -> Result { /// Given an event without indexed parameters and a rawlog, it tries to return the event with the /// proper indexed parameters. Otherwise, it returns the original event. -pub fn get_indexed_event(mut event: Event, raw_log: &Log) -> Event { +pub fn get_indexed_event(mut event: Event, raw_log: &LogData) -> Event { if !event.anonymous && raw_log.topics().len() > 1 { let indexed_params = raw_log.topics().len() - 1; let num_inputs = event.inputs.len(); @@ -186,7 +186,7 @@ fn coerce_value(ty: &str, arg: &str) -> Result { mod tests { use super::*; use alloy_dyn_abi::EventExt; - use alloy_primitives::{B256, U256}; + use alloy_primitives::{LogData, B256, U256}; #[test] fn test_get_func() { @@ -216,7 +216,8 @@ mod tests { let param0 = B256::random(); let param1 = vec![3; 32]; let param2 = B256::random(); - let log = Log::new_unchecked(vec![event.selector(), param0, param2], param1.clone().into()); + let log = + LogData::new_unchecked(vec![event.selector(), param0, param2], param1.clone().into()); let event = get_indexed_event(event, &log); assert_eq!(event.inputs.len(), 3); @@ -237,7 +238,7 @@ mod tests { let param0 = B256::random(); let param1 = vec![3; 32]; let param2 = B256::random(); - let log = Log::new_unchecked( + let log = LogData::new_unchecked( vec![event.selector(), param0, B256::from_slice(¶m1), param2], vec![].into(), ); diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 2df8470b6b92e..3416305361e56 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -26,7 +26,7 @@ pub fn decode_console_log(log: &Log) -> Option { let topics = unsafe { &*(topics as *const [ethers_core::types::H256] as *const [alloy_primitives::B256]) }; - Console::ConsoleEvents::decode_log(topics, &log.data, false) + Console::ConsoleEvents::decode_raw_log(topics, &log.data, false) .ok() .map(|decoded| decoded.to_string()) } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index f1a919f249b83..29b46ad6c6bef 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -6,7 +6,7 @@ use crate::{ }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function, JsonAbi}; -use alloy_primitives::{Address, Log, Selector, B256}; +use alloy_primitives::{Address, LogData, Selector, B256}; use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ abi::{Console, HardhatConsole, Vm, HARDHAT_CONSOLE_SELECTOR_PATCHES}, @@ -469,7 +469,7 @@ impl CallTraceDecoder { } /// Decodes an event. - pub async fn decode_event<'a>(&self, log: &'a Log) -> DecodedCallLog<'a> { + pub async fn decode_event<'a>(&self, log: &'a LogData) -> DecodedCallLog<'a> { let &[t0, ..] = log.topics() else { return DecodedCallLog::Raw(log) }; let mut events = Vec::new(); diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index b9ddbd5c592ad..4ee5dbd54a9aa 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -7,7 +7,7 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{Log, U256}; +use alloy_primitives::{LogData, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CHEATCODE_ADDRESS; use futures::{future::BoxFuture, FutureExt}; @@ -50,7 +50,7 @@ pub struct DecodedCallTrace { #[derive(Debug)] pub enum DecodedCallLog<'a> { /// A raw log. - Raw(&'a Log), + Raw(&'a LogData), /// A decoded log. /// /// The first member of the tuple is the event name, and the second is a vector of decoded @@ -214,7 +214,7 @@ pub async fn render_trace( /// Render a trace log. async fn render_trace_log( - log: &Log, + log: &LogData, decoder: &CallTraceDecoder, ) -> Result { let mut s = String::new(); From 68c3663e0dd0261bbb14284b492ce0b0e703006b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:37:54 +0100 Subject: [PATCH 0459/1963] chore: some more ToEthers removals (#6755) --- crates/evm/fuzz/src/inspector.rs | 4 +- crates/evm/fuzz/src/strategies/state.rs | 7 +-- crates/evm/traces/src/node.rs | 83 ------------------------- 3 files changed, 3 insertions(+), 91 deletions(-) delete mode 100644 crates/evm/traces/src/node.rs diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index 6190c073dfc6d..65c6e5ec99c8f 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -1,7 +1,5 @@ use crate::{invariant::RandomCallGenerator, strategies::EvmFuzzState}; use alloy_primitives::Bytes; -use foundry_common::types::ToEthers; -use foundry_evm_core::utils; use revm::{ interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, Database, EVMData, Inspector, @@ -73,7 +71,7 @@ impl Fuzzer { let mut state = self.fuzz_state.write(); for slot in interpreter.stack().data() { - state.values_mut().insert(utils::u256_to_h256_be(slot.to_ethers()).into()); + state.values_mut().insert(slot.to_be_bytes()); } // TODO: disabled for now since it's flooding the dictionary diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 33a0ddf329284..8f7feb2093209 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -4,10 +4,7 @@ use alloy_dyn_abi::{DynSolType, JsonAbiExt}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers_core::types::Log; -use foundry_common::{ - contracts::{ContractsByAddress, ContractsByArtifact}, - types::ToEthers, -}; +use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; use hashbrown::HashSet; @@ -232,7 +229,7 @@ fn collect_push_bytes(code: &[u8]) -> Vec<[u8; 32]> { } let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); - bytes.push(push_value.to_ethers().into()); + bytes.push(push_value.to_be_bytes()); // also add the value below and above the push value to the dictionary. if push_value != U256::ZERO { bytes.push((push_value - U256::from(1)).to_be_bytes()); diff --git a/crates/evm/traces/src/node.rs b/crates/evm/traces/src/node.rs deleted file mode 100644 index 5eff992956a33..0000000000000 --- a/crates/evm/traces/src/node.rs +++ /dev/null @@ -1,83 +0,0 @@ -use crate::{CallTrace, LogCallOrder, TraceLog}; -use ethers_core::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; -use foundry_common::types::ToEthers; -use foundry_evm_core::utils::CallKind; -use revm::interpreter::InstructionResult; -use serde::{Deserialize, Serialize}; - -/// A node in the arena -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub struct CallTraceNode { - /// Parent node index in the arena - pub parent: Option, - /// Children node indexes in the arena - pub children: Vec, - /// This node's index in the arena - pub idx: usize, - /// The call trace - pub trace: CallTrace, - /// Logs - #[serde(skip)] - pub logs: Vec, - /// Ordering of child calls and logs - pub ordering: Vec, -} - -impl CallTraceNode { - /// Returns the kind of call the trace belongs to - pub fn kind(&self) -> CallKind { - self.trace.kind - } - - /// Returns the status of the call - pub fn status(&self) -> InstructionResult { - self.trace.status - } - - /// Returns the `Res` for a parity trace - pub fn parity_result(&self) -> Res { - match self.kind() { - CallKind::Call | CallKind::StaticCall | CallKind::CallCode | CallKind::DelegateCall => { - Res::Call(CallResult { - gas_used: self.trace.gas_cost.into(), - output: self.trace.output.to_raw().into(), - }) - } - CallKind::Create | CallKind::Create2 => Res::Create(CreateResult { - gas_used: self.trace.gas_cost.into(), - code: self.trace.output.to_raw().into(), - address: self.trace.address.to_ethers(), - }), - } - } - - /// Returns the `Action` for a parity trace - pub fn parity_action(&self) -> Action { - if self.status() == InstructionResult::SelfDestruct { - return Action::Suicide(Suicide { - address: self.trace.address.to_ethers(), - // TODO deserialize from calldata here? - refund_address: Default::default(), - balance: self.trace.value.to_ethers(), - }) - } - match self.kind() { - CallKind::Call | CallKind::StaticCall | CallKind::CallCode | CallKind::DelegateCall => { - Action::Call(Call { - from: self.trace.caller.to_ethers(), - to: self.trace.address.to_ethers(), - value: self.trace.value.to_ethers(), - gas: self.trace.gas_cost.into(), - input: self.trace.data.as_bytes().to_vec().into(), - call_type: self.kind().into(), - }) - } - CallKind::Create | CallKind::Create2 => Action::Create(Create { - from: self.trace.caller.to_ethers(), - value: self.trace.value.to_ethers(), - gas: self.trace.gas_cost.into(), - init: self.trace.data.as_bytes().to_vec().into(), - }), - } - } -} From 33744b396a80dc149f111bc8778f33f26067e3eb Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Thu, 11 Jan 2024 07:09:40 -0800 Subject: [PATCH 0460/1963] feat: LogCollector use alloy_primitives::Log (#6752) * feat: LogCollector use alloy_rpc_types::Log * fix: remove comment * fix: clippy error * fix: use to_ethers() * fix: update log to use Default * fix: decode_console_log types * feat: use alloy_primitives::Log --- Cargo.lock | 3 ++- crates/anvil/src/eth/backend/mem/inspector.rs | 2 +- crates/chisel/Cargo.toml | 1 + crates/chisel/src/runner.rs | 3 +-- crates/evm/core/src/decode.rs | 16 ++++---------- .../evm/evm/src/executors/invariant/error.rs | 7 ++----- .../evm/evm/src/executors/invariant/funcs.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 3 +-- crates/evm/evm/src/inspectors/logs.rs | 21 +++++++------------ crates/evm/evm/src/inspectors/stack.rs | 3 +-- crates/evm/fuzz/Cargo.toml | 2 -- crates/evm/fuzz/src/lib.rs | 5 ++--- crates/evm/fuzz/src/strategies/state.rs | 11 +++++----- crates/forge/Cargo.toml | 17 ++++++++++++--- crates/forge/bin/cmd/script/mod.rs | 4 ++-- crates/forge/src/result.rs | 3 +-- crates/forge/tests/it/repros.rs | 7 +++++-- 17 files changed, 50 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f87f19d905fae..c41229c84e243 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1313,6 +1313,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-rpc-types", "clap", "criterion", "dirs 5.0.1", @@ -2788,6 +2789,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-rpc-types", "anvil", "async-trait", "axum", @@ -3221,7 +3223,6 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "arbitrary", - "ethers-core", "eyre", "foundry-common", "foundry-compilers", diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index bb648f6c61d8a..6072e4f938b71 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -1,7 +1,7 @@ //! Anvil specific [`revm::Inspector`] implementation use crate::{eth::macros::node_info, revm::Database}; -use ethers::types::Log; +use alloy_primitives::Log; use foundry_evm::{ call_inspectors, decode::decode_console_logs, diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index d70473ffe7cfc..7e0cfd1de7d44 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -29,6 +29,7 @@ foundry-evm.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-json-abi.workspace = true +alloy-rpc-types.workspace = true ethers-core.workspace = true diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 4231c55b4122b..dfbc301891470 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -3,8 +3,7 @@ //! This module contains the `ChiselRunner` struct, which assists with deploying //! and calling the REPL contract on a in-memory REVM instance. -use alloy_primitives::{Address, Bytes, U256}; -use ethers_core::types::Log; +use alloy_primitives::{Address, Bytes, Log, U256}; use eyre::Result; use foundry_evm::{ executors::{DeployResult, Executor, RawCallResult}, diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 3416305361e56..ff28631fbeb20 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -3,8 +3,8 @@ use crate::abi::{Console, Vm}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::JsonAbi; +use alloy_primitives::Log; use alloy_sol_types::{SolCall, SolError, SolEventInterface, SolInterface, SolValue}; -use ethers_core::types::Log; use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; @@ -18,17 +18,9 @@ pub fn decode_console_logs(logs: &[Log]) -> Vec { /// /// This function returns [None] if it is not a DSTest log or the result of a Hardhat /// `console.log`. -#[instrument(level = "debug", skip_all, fields(topics=?log.topics, data=%log.data), ret)] +#[instrument(level = "debug", skip_all, fields(topics=?log.data.topics(), data=%log.data.data), ret)] pub fn decode_console_log(log: &Log) -> Option { - let topics = log.topics.as_slice(); - // SAFETY: Same type - // TODO: Remove when `ethers::Log` has been replaced - let topics = unsafe { - &*(topics as *const [ethers_core::types::H256] as *const [alloy_primitives::B256]) - }; - Console::ConsoleEvents::decode_raw_log(topics, &log.data, false) - .ok() - .map(|decoded| decoded.to_string()) + Console::ConsoleEvents::decode_log(log, false).ok().map(|decoded| decoded.to_string()) } /// Tries to decode an error message from the given revert bytes. @@ -64,7 +56,7 @@ pub fn maybe_decode_revert( None } else { Some(format!("custom error bytes {}", hex::encode_prefixed(err))) - } + }; } if err == crate::constants::MAGIC_SKIP { diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 28ed361bf92ef..f4e11aa6434ae 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -1,11 +1,8 @@ use super::{BasicTxDetails, InvariantContract}; use crate::executors::{Executor, RawCallResult}; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes}; -use ethers_core::{ - rand::{seq, thread_rng, Rng}, - types::Log, -}; +use alloy_primitives::{Address, Bytes, Log}; +use ethers_core::rand::{seq, thread_rng, Rng}; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::{constants::CALLER, decode::decode_revert}; diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index c0a053d0f26d6..810abb259d0cc 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -2,7 +2,7 @@ use super::{InvariantFailures, InvariantFuzzError}; use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use ethers_core::types::Log; +use alloy_primitives::Log; use foundry_common::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CALLER; use foundry_evm_coverage::HitMaps; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index bb660317861ef..e8bcbaf879c11 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -11,8 +11,7 @@ use crate::inspectors::{ }; use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Bytes, U256}; -use ethers_core::types::Log; +use alloy_primitives::{Address, Bytes, Log, U256}; use ethers_signers::LocalWallet; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; use foundry_evm_core::{ diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index d0089ee263caa..b5324f576a587 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,7 +1,6 @@ -use alloy_primitives::{Address, Bytes, B256}; +use alloy_primitives::{Address, Bytes, Log, B256}; use alloy_sol_types::{SolEvent, SolInterface, SolValue}; -use ethers_core::types::Log; -use foundry_common::{fmt::ConsoleFmt, types::ToEthers, ErrorExt}; +use foundry_common::{fmt::ConsoleFmt, ErrorExt}; use foundry_evm_core::{ abi::{patch_hh_console_selector, Console, HardhatConsole}, constants::HARDHAT_CONSOLE_ADDRESS, @@ -40,12 +39,9 @@ impl LogCollector { impl Inspector for LogCollector { fn log(&mut self, _: &mut EVMData<'_, DB>, address: &Address, topics: &[B256], data: &Bytes) { - self.logs.push(Log { - address: address.to_ethers(), - topics: topics.iter().copied().map(|t| t.to_ethers()).collect(), - data: data.clone().to_ethers(), - ..Default::default() - }); + if let Some(log) = Log::new(*address, topics.to_vec(), data.clone()) { + self.logs.push(log); + } } fn call( @@ -66,9 +62,6 @@ impl Inspector for LogCollector { fn convert_hh_log_to_event(call: HardhatConsole::HardhatConsoleCalls) -> Log { // Convert the parameters of the call to their string representation using `ConsoleFmt`. let fmt = call.fmt(Default::default()); - Log { - topics: vec![Console::log::SIGNATURE_HASH.to_ethers()], - data: fmt.abi_encode().into(), - ..Default::default() - } + Log::new(Address::default(), vec![Console::log::SIGNATURE_HASH], fmt.abi_encode().into()) + .unwrap_or_else(|| Log { ..Default::default() }) } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 35044677f86c2..659710b071fff 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -2,8 +2,7 @@ use super::{ Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Debugger, Fuzzer, LogCollector, StackSnapshotType, TracePrinter, TracingInspector, TracingInspectorConfig, }; -use alloy_primitives::{Address, Bytes, B256, U256}; -use ethers_core::types::Log; +use alloy_primitives::{Address, Bytes, Log, B256, U256}; use ethers_signers::LocalWallet; use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; use foundry_evm_coverage::HitMaps; diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 49b10fc9d21a5..47b5787285149 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -31,8 +31,6 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } -ethers-core.workspace = true - arbitrary = "1.3.1" eyre = "0.6" hashbrown = { version = "0.14", features = ["serde"] } diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 66e59ebcb7835..55c1f1c3e5d55 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -8,8 +8,7 @@ extern crate tracing; use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; -use alloy_primitives::{Address, Bytes, U256}; -use ethers_core::types::Log; +use alloy_primitives::{Address, Bytes, Log, U256}; use foundry_common::{calc, contracts::ContractsByAddress}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; @@ -75,7 +74,7 @@ impl BaseCounterExample { contract_name: Some(name.clone()), traces, args, - } + }; } } } diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 8f7feb2093209..ba628f921d074 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -2,8 +2,7 @@ use super::fuzz_param_from_state; use crate::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}; use alloy_dyn_abi::{DynSolType, JsonAbiExt}; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes, B256, U256}; -use ethers_core::types::Log; +use alloy_primitives::{Address, Bytes, Log, B256, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; @@ -184,15 +183,15 @@ pub fn collect_state_from_call( } } } else { - return + return; } // Insert log topics and data for log in logs { - log.topics.iter().for_each(|topic| { + log.data.topics().iter().for_each(|topic| { state.values_mut().insert(topic.0); }); - log.data.0.chunks(32).for_each(|chunk| { + log.data.data.chunks(32).for_each(|chunk| { let mut buffer: [u8; 32] = [0; 32]; let _ = (&mut buffer[..]) .write(chunk) @@ -225,7 +224,7 @@ fn collect_push_bytes(code: &[u8]) -> Vec<[u8; 32]> { // As a precaution, if a fuzz test deploys malformed bytecode (such as using `CREATE2`) // this will terminate the loop early. if push_start > code.len() || push_end > code.len() { - return bytes + return bytes; } let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 0779ecb4ee9c8..113e2d1f530cc 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,7 +15,11 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { version = "8", default-features = false, features = ["build", "git", "git2"] } +vergen = { version = "8", default-features = false, features = [ + "build", + "git", + "git2", +] } [dependencies] # lib @@ -48,6 +52,7 @@ foundry-debugger.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde"] } +alloy-rpc-types.workspace = true async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } @@ -89,13 +94,19 @@ paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true serial_test = "2" -svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } +svm = { package = "svm-rs", version = "0.3", default-features = false, features = [ + "rustls", +] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } [features] default = ["rustls"] -rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] +rustls = [ + "foundry-cli/rustls", + "reqwest/rustls-tls", + "reqwest/rustls-tls-native-roots", +] openssl = ["foundry-cli/openssl", "reqwest/default-tls"] # feature for heavy (long-running) integration tests diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index ad2941aa83ff3..b1e3e1c301ccf 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -2,11 +2,11 @@ use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{Address, Bytes, Log, U256}; use clap::{Parser, ValueHint}; use dialoguer::Confirm; use ethers_core::types::{ - transaction::eip2718::TypedTransaction, Log, NameOrAddress, TransactionRequest, + transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest, }; use ethers_providers::{Http, Middleware}; use ethers_signers::LocalWallet; diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 26646a38d4d0d..fe490dda45bd1 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,7 +1,6 @@ //! Test outcomes. -use alloy_primitives::Address; -use ethers_core::types::Log; +use alloy_primitives::{Address, Log}; use foundry_common::evm::Breakpoints; use foundry_evm::{ coverage::HitMaps, diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 39aeae72335ea..6845f51b9bd4c 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -4,6 +4,7 @@ use crate::{config::*, test_helpers::PROJECT}; use alloy_primitives::{address, Address}; use ethers_core::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; use forge::result::TestStatus; +use foundry_common::types::ToEthers; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_evm::{ constants::HARDHAT_CONSOLE_ADDRESS, @@ -123,8 +124,10 @@ test_repro!(3347, false, None, |res| { ], anonymous: false, }; - let raw_log = - RawLog { topics: test.logs[0].topics.clone(), data: test.logs[0].data.clone().to_vec() }; + let raw_log = RawLog { + topics: test.logs[0].data.topics().iter().map(|t| t.to_ethers()).collect(), + data: test.logs[0].data.data.clone().to_vec(), + }; let log = event.parse_log(raw_log).unwrap(); assert_eq!( log, From 69a9c1456069027b54aebcf30dfdb5ecee74c786 Mon Sep 17 00:00:00 2001 From: anikaraghu Date: Thu, 11 Jan 2024 09:18:44 -0800 Subject: [PATCH 0461/1963] Add view modifier to envOr (#6757) --- crates/anvil/src/eth/backend/mem/mod.rs | 5 +-- crates/cheatcodes/assets/cheatcodes.json | 56 ++++++++++++------------ crates/cheatcodes/spec/src/vm.rs | 28 ++++++------ testdata/cheats/Vm.sol | 28 ++++++------ 4 files changed, 58 insertions(+), 59 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d87a9e8996a81..9523aa5b1304c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1060,15 +1060,14 @@ impl Backend { env.block.basefee = base; } - let gas_price = - gas_price.map(|g| g).or(max_fee_per_gas.map(|g| g)).unwrap_or_else(|| self.gas_price()); + let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); let caller = from.unwrap_or_default(); env.tx = TxEnv { caller: caller.to_alloy(), gas_limit: gas_limit.as_u64(), gas_price, - gas_priority_fee: max_priority_fee_per_gas.map(|f| f), + gas_priority_fee: max_priority_fee_per_gas, transact_to: match to { Some(addr) => TransactTo::Call(addr.to_alloy()), None => TransactTo::Create(CreateScheme::Create), diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d877ecf98ef65..8b69d7e257ccc 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -1357,9 +1357,9 @@ "func": { "id": "envOr_0", "description": "Gets the environment variable `name` and parses it as `bool`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, bool defaultValue) external returns (bool value);", + "declaration": "function envOr(string calldata name, bool defaultValue) external view returns (bool value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,bool)", "selector": "0x4777f3cf", "selectorBytes": [ @@ -1377,9 +1377,9 @@ "func": { "id": "envOr_1", "description": "Gets the environment variable `name` and parses it as `uint256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);", + "declaration": "function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,uint256)", "selector": "0x5e97348f", "selectorBytes": [ @@ -1397,9 +1397,9 @@ "func": { "id": "envOr_10", "description": "Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external returns (address[] memory value);", + "declaration": "function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external view returns (address[] memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string,address[])", "selector": "0xc74e9deb", "selectorBytes": [ @@ -1417,9 +1417,9 @@ "func": { "id": "envOr_11", "description": "Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external returns (bytes32[] memory value);", + "declaration": "function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external view returns (bytes32[] memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string,bytes32[])", "selector": "0x2281f367", "selectorBytes": [ @@ -1437,9 +1437,9 @@ "func": { "id": "envOr_12", "description": "Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external returns (string[] memory value);", + "declaration": "function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external view returns (string[] memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string,string[])", "selector": "0x859216bc", "selectorBytes": [ @@ -1457,9 +1457,9 @@ "func": { "id": "envOr_13", "description": "Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external returns (bytes[] memory value);", + "declaration": "function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external view returns (bytes[] memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string,bytes[])", "selector": "0x64bc3e64", "selectorBytes": [ @@ -1477,9 +1477,9 @@ "func": { "id": "envOr_2", "description": "Gets the environment variable `name` and parses it as `int256`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, int256 defaultValue) external returns (int256 value);", + "declaration": "function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,int256)", "selector": "0xbbcb713e", "selectorBytes": [ @@ -1497,9 +1497,9 @@ "func": { "id": "envOr_3", "description": "Gets the environment variable `name` and parses it as `address`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, address defaultValue) external returns (address value);", + "declaration": "function envOr(string calldata name, address defaultValue) external view returns (address value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,address)", "selector": "0x561fe540", "selectorBytes": [ @@ -1517,9 +1517,9 @@ "func": { "id": "envOr_4", "description": "Gets the environment variable `name` and parses it as `bytes32`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);", + "declaration": "function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,bytes32)", "selector": "0xb4a85892", "selectorBytes": [ @@ -1537,9 +1537,9 @@ "func": { "id": "envOr_5", "description": "Gets the environment variable `name` and parses it as `string`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);", + "declaration": "function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string)", "selector": "0xd145736c", "selectorBytes": [ @@ -1557,9 +1557,9 @@ "func": { "id": "envOr_6", "description": "Gets the environment variable `name` and parses it as `bytes`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);", + "declaration": "function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,bytes)", "selector": "0xb3e47705", "selectorBytes": [ @@ -1577,9 +1577,9 @@ "func": { "id": "envOr_7", "description": "Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external returns (bool[] memory value);", + "declaration": "function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external view returns (bool[] memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string,bool[])", "selector": "0xeb85e83b", "selectorBytes": [ @@ -1597,9 +1597,9 @@ "func": { "id": "envOr_8", "description": "Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external returns (uint256[] memory value);", + "declaration": "function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external view returns (uint256[] memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string,uint256[])", "selector": "0x74318528", "selectorBytes": [ @@ -1617,9 +1617,9 @@ "func": { "id": "envOr_9", "description": "Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.\nReverts if the variable could not be parsed.\nReturns `defaultValue` if the variable was not found.", - "declaration": "function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external returns (int256[] memory value);", + "declaration": "function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external view returns (int256[] memory value);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "envOr(string,string,int256[])", "selector": "0x4700d74b", "selectorBytes": [ diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 07e6cb5355c11..1577e6189b849 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -895,86 +895,86 @@ interface Vm { /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] - function envOr(string calldata name, bool defaultValue) external returns (bool value); + function envOr(string calldata name, bool defaultValue) external view returns (bool value); /// Gets the environment variable `name` and parses it as `uint256`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] - function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value); + function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value); /// Gets the environment variable `name` and parses it as `int256`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] - function envOr(string calldata name, int256 defaultValue) external returns (int256 value); + function envOr(string calldata name, int256 defaultValue) external view returns (int256 value); /// Gets the environment variable `name` and parses it as `address`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] - function envOr(string calldata name, address defaultValue) external returns (address value); + function envOr(string calldata name, address defaultValue) external view returns (address value); /// Gets the environment variable `name` and parses it as `bytes32`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] - function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value); + function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value); /// Gets the environment variable `name` and parses it as `string`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] - function envOr(string calldata name, string calldata defaultValue) external returns (string memory value); + function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value); /// Gets the environment variable `name` and parses it as `bytes`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] - function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value); + function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value); /// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) - external + external view returns (bool[] memory value); /// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) - external + external view returns (uint256[] memory value); /// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) - external + external view returns (int256[] memory value); /// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) - external + external view returns (address[] memory value); /// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) - external + external view returns (bytes32[] memory value); /// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) - external + external view returns (string[] memory value); /// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`. /// Reverts if the variable could not be parsed. /// Returns `defaultValue` if the variable was not found. #[cheatcode(group = Environment)] function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) - external + external view returns (bytes[] memory value); // ======== Scripts ======== diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 12b22b8f30f81..cc9a1aa8ab220 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -65,20 +65,20 @@ interface Vm { function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value); function envInt(string calldata name) external view returns (int256 value); function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value); - function envOr(string calldata name, bool defaultValue) external returns (bool value); - function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value); - function envOr(string calldata name, string calldata delim, address[] calldata defaultValue) external returns (address[] memory value); - function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue) external returns (bytes32[] memory value); - function envOr(string calldata name, string calldata delim, string[] calldata defaultValue) external returns (string[] memory value); - function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue) external returns (bytes[] memory value); - function envOr(string calldata name, int256 defaultValue) external returns (int256 value); - function envOr(string calldata name, address defaultValue) external returns (address value); - function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value); - function envOr(string calldata name, string calldata defaultValue) external returns (string memory value); - function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value); - function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue) external returns (bool[] memory value); - function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue) external returns (uint256[] memory value); - function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue) external 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, 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 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); From 47696fbb7509d9257366dd288d3815d179a24c88 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 11 Jan 2024 18:22:24 +0100 Subject: [PATCH 0462/1963] feat: include block env in --dump state (#6763) --- crates/anvil/src/cmd.rs | 17 ++++++---- crates/anvil/src/config.rs | 21 +++++++------ crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/backend/db.rs | 10 ++++-- crates/anvil/src/eth/backend/mem/fork_db.rs | 5 +-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 8 ++--- crates/anvil/src/eth/backend/mem/mod.rs | 31 +++++++++++++------ crates/anvil/tests/it/main.rs | 2 ++ crates/anvil/tests/it/state.rs | 23 ++++++++++++++ 9 files changed, 84 insertions(+), 35 deletions(-) create mode 100644 crates/anvil/tests/it/state.rs diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index b684caffd71b3..e1eb0eb3d27f4 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -19,7 +19,7 @@ use rand::{rngs::StdRng, SeedableRng}; use std::{ future::Future, net::IpAddr, - path::PathBuf, + path::{Path, PathBuf}, pin::Pin, str::FromStr, sync::{ @@ -119,8 +119,8 @@ pub struct NodeArgs { /// This is an alias for both --load-state and --dump-state. /// - /// It initializes the chain with the state stored at the file, if it exists, and dumps the - /// chain's state on exit. + /// It initializes the chain with the state and block environment stored at the file, if it + /// exists, and dumps the chain's state on exit. #[clap( long, value_name = "PATH", @@ -133,13 +133,13 @@ pub struct NodeArgs { )] pub state: Option, - /// Interval in seconds at which the status is to be dumped to disk. + /// Interval in seconds at which the state and block environment is to be dumped to disk. /// /// See --state and --dump-state #[clap(short, long, value_name = "SECONDS")] pub state_interval: Option, - /// Dump the state of chain on exit to the given file. + /// Dump the state and block environment of chain on exit to the given file. /// /// If the value is a directory, the state will be written to `/state.json`. #[clap(long, value_name = "PATH", conflicts_with = "init")] @@ -616,7 +616,12 @@ impl StateFile { /// This is used as the clap `value_parser` implementation to parse from file but only if it /// exists fn parse(path: &str) -> Result { - let mut path = PathBuf::from(path); + Self::parse_path(path) + } + + /// Parse from file but only if it exists + pub fn parse_path(path: impl AsRef) -> Result { + let mut path = path.as_ref().to_path_buf(); if path.is_dir() { path = path.join("state.json"); } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 1d0a1a60dd15a..b8430a74601a6 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1,4 +1,5 @@ use crate::{ + cmd::StateFile, eth::{ backend::{ db::{Db, SerializableState}, @@ -48,7 +49,7 @@ use std::{ fmt::Write as FmtWrite, fs::File, net::{IpAddr, Ipv4Addr}, - path::PathBuf, + path::{Path, PathBuf}, sync::Arc, time::Duration, }; @@ -437,13 +438,20 @@ impl NodeConfig { self } - /// Sets a custom code size limit + /// Sets the init state if any #[must_use] pub fn with_init_state(mut self, init_state: Option) -> Self { self.init_state = init_state; self } + /// Loads the init state from a file if it exists + #[must_use] + pub fn with_init_state_path(mut self, path: impl AsRef) -> Self { + self.init_state = StateFile::parse_path(path).ok().and_then(|file| file.state); + self + } + /// Sets the chain ID #[must_use] pub fn with_chain_id>(mut self, chain_id: Option) -> Self { @@ -866,13 +874,8 @@ impl NodeConfig { .expect("Failed to create default create2 deployer"); } - if let Some(ref state) = self.init_state { - backend - .get_db() - .write() - .await - .load_state(state.clone()) - .expect("Failed to load init state"); + if let Some(state) = self.init_state.clone() { + backend.load_state(state).await.expect("Failed to load init state"); } backend diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 84419c9ce3b46..d0ec41acf0230 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1721,7 +1721,7 @@ impl EthApi { /// Handler for RPC call: `anvil_loadState` pub async fn anvil_load_state(&self, buf: Bytes) -> Result { node_info!("anvil_loadState"); - self.backend.load_state(buf).await + self.backend.load_state_bytes(buf).await } /// Retrieves the Anvil node configuration params. diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 7d86e4893d824..02e7db113a728 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -11,7 +11,7 @@ use foundry_evm::{ hashbrown::HashMap, revm::{ db::{CacheDB, DatabaseRef, DbAccount}, - primitives::{Bytecode, KECCAK_EMPTY}, + primitives::{BlockEnv, Bytecode, KECCAK_EMPTY}, Database, DatabaseCommit, }, }; @@ -126,7 +126,7 @@ pub trait Db: fn insert_block_hash(&mut self, number: U256, hash: B256); /// Write all chain data to serialized bytes buffer - fn dump_state(&self) -> DatabaseResult>; + fn dump_state(&self, at: BlockEnv) -> DatabaseResult>; /// Deserialize and add all chain data to the backend storage fn load_state(&mut self, state: SerializableState) -> DatabaseResult { @@ -196,7 +196,7 @@ impl + Send + Sync + Clone + fmt::Debug> D self.block_hashes.insert(number, hash); } - fn dump_state(&self) -> DatabaseResult> { + fn dump_state(&self, _at: BlockEnv) -> DatabaseResult> { Ok(None) } @@ -324,6 +324,10 @@ impl MaybeHashDatabase for StateDb { #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct SerializableState { + /// The block number of the state + /// + /// Note: This is an Option for backwards compatibility: + pub block: Option, pub accounts: BTreeMap, } diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index c9cc10a22efc5..354971ce595b7 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -14,6 +14,7 @@ use foundry_evm::{ }; pub use foundry_evm::fork::database::ForkedDatabase; +use foundry_evm::revm::primitives::BlockEnv; /// Implement the helper for the fork database impl Db for ForkedDatabase { @@ -31,7 +32,7 @@ impl Db for ForkedDatabase { self.inner().block_hashes().write().insert(number, hash); } - fn dump_state(&self) -> DatabaseResult> { + fn dump_state(&self, at: BlockEnv) -> DatabaseResult> { let mut db = self.database().clone(); let accounts = self .database() @@ -56,7 +57,7 @@ impl Db for ForkedDatabase { )) }) .collect::>()?; - Ok(Some(SerializableState { accounts })) + Ok(Some(SerializableState { block: Some(at), accounts })) } fn snapshot(&mut self) -> U256 { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 66b8c8941cebf..f9b1cb6da9ef0 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -16,8 +16,8 @@ use foundry_evm::{ }; // reexport for convenience -use foundry_evm::backend::RevertSnapshotAction; pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; +use foundry_evm::{backend::RevertSnapshotAction, revm::primitives::BlockEnv}; impl Db for MemDb { fn insert_account(&mut self, address: Address, account: AccountInfo) { @@ -32,7 +32,7 @@ impl Db for MemDb { self.inner.block_hashes.insert(number, hash); } - fn dump_state(&self) -> DatabaseResult> { + fn dump_state(&self, at: BlockEnv) -> DatabaseResult> { let accounts = self .inner .accounts @@ -57,7 +57,7 @@ impl Db for MemDb { }) .collect::>()?; - Ok(Some(SerializableState { accounts })) + Ok(Some(SerializableState { block: Some(at), accounts })) } /// Creates a new snapshot @@ -167,7 +167,7 @@ mod tests { dump_db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); - let state = dump_db.dump_state().unwrap().unwrap(); + let state = dump_db.dump_state(Default::default()).unwrap().unwrap(); let mut load_db = MemDb::default(); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 9523aa5b1304c..02edc0aa3db1c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -718,7 +718,8 @@ impl Backend { /// Get the current state. pub async fn serialized_state(&self) -> Result { - let state = self.db.read().await.dump_state()?; + let at = self.env.read().block.clone(); + let state = self.db.read().await.dump_state(at)?; state.ok_or_else(|| { RpcError::invalid_params("Dumping state not supported with the current configuration") .into() @@ -735,8 +736,25 @@ impl Backend { Ok(encoder.finish().unwrap_or_default().into()) } + /// Apply [SerializableState] data to the backend storage. + pub async fn load_state(&self, state: SerializableState) -> Result { + // reset the block env + if let Some(block) = state.block.clone() { + self.env.write().block = block; + } + + if !self.db.write().await.load_state(state)? { + Err(RpcError::invalid_params( + "Loading state not supported with the current configuration", + ) + .into()) + } else { + Ok(true) + } + } + /// Deserialize and add all chain data to the backend storage - pub async fn load_state(&self, buf: Bytes) -> Result { + pub async fn load_state_bytes(&self, buf: Bytes) -> Result { let orig_buf = &buf.0[..]; let mut decoder = GzDecoder::new(orig_buf); let mut decoded_data = Vec::new(); @@ -751,14 +769,7 @@ impl Backend { }) .map_err(|_| BlockchainError::FailedToDecodeStateDump)?; - if !self.db.write().await.load_state(state)? { - Err(RpcError::invalid_params( - "Loading state not supported with the current configuration", - ) - .into()) - } else { - Ok(true) - } + self.load_state(state).await } /// Returns the environment for the next block diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 057a9fdea596d..1ba8e3fe9da92 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -14,7 +14,9 @@ mod proof; mod pubsub; // mod revert; // TODO uncomment mod otterscan; + mod sign; +mod state; mod traces; mod transaction; mod txpool; diff --git a/crates/anvil/tests/it/state.rs b/crates/anvil/tests/it/state.rs new file mode 100644 index 0000000000000..7e822ee23b5ac --- /dev/null +++ b/crates/anvil/tests/it/state.rs @@ -0,0 +1,23 @@ +//! general eth api tests + +use anvil::{spawn, NodeConfig}; + +#[tokio::test(flavor = "multi_thread")] +async fn can_load_state() { + let tmp = tempfile::tempdir().unwrap(); + let state_file = tmp.path().join("state.json"); + + let (api, _handle) = spawn(NodeConfig::test()).await; + + api.mine_one().await; + + let num = api.block_number().unwrap(); + + let state = api.serialized_state().await.unwrap(); + foundry_common::fs::write_json_file(&state_file, &state).unwrap(); + + let (api, _handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; + + let num2 = api.block_number().unwrap(); + assert_eq!(num, num2); +} From 06fc9eab0e03df12ef2a124278907f88f05fdaa1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 11 Jan 2024 20:13:26 +0100 Subject: [PATCH 0463/1963] fix: make ForkIds unique (#6765) * fix: make ForkIds unique * fix return correct id --- crates/evm/core/src/backend/mod.rs | 23 ++--------- crates/evm/core/src/fork/multi.rs | 61 +++++++++++++++++++++++------- crates/forge/tests/it/repros.rs | 3 ++ testdata/repros/Issue6759.t.sol | 19 ++++++++++ 4 files changed, 73 insertions(+), 33 deletions(-) create mode 100644 testdata/repros/Issue6759.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index f2f1a355d6f5f..771ba7b3d57c9 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -993,20 +993,9 @@ impl DatabaseExt for Backend { self.inner.snapshots.clear() } - fn create_fork(&mut self, mut create_fork: CreateFork) -> eyre::Result { + fn create_fork(&mut self, create_fork: CreateFork) -> eyre::Result { trace!("create fork"); - let (fork_id, fork, _) = self.forks.create_fork(create_fork.clone())?; - - // Check for an edge case where the fork_id already exists, which would mess with the - // internal mappings. This can happen when two forks are created with the same - // endpoint and block number - // This is a hacky solution but a simple fix to ensure URLs are unique - if self.inner.contains_fork(&fork_id) { - // ensure URL is unique - create_fork.url.push('/'); - debug!(?fork_id, "fork id already exists. making unique"); - return self.create_fork(create_fork) - } + let (fork_id, fork, _) = self.forks.create_fork(create_fork)?; let fork_db = ForkDB::new(fork); let (id, _) = @@ -1134,7 +1123,8 @@ impl DatabaseExt for Backend { Ok(()) } - /// This is effectively the same as [`Self::create_select_fork()`] but updating an existing fork + /// This is effectively the same as [`Self::create_select_fork()`] but updating an existing + /// [ForkId] that is mapped to the [LocalForkId] fn roll_fork( &mut self, id: Option, @@ -1576,11 +1566,6 @@ pub struct BackendInner { // === impl BackendInner === impl BackendInner { - /// Returns `true` if the given [ForkId] already exists. - fn contains_fork(&self, id: &ForkId) -> bool { - self.created_forks.contains_key(id) - } - pub fn ensure_fork_id(&self, id: LocalForkId) -> eyre::Result<&ForkId> { self.issued_local_fork_ids .get(&id) diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index d09466871fdb7..5aa7261bd4406 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -22,17 +22,25 @@ use std::{ fmt, pin::Pin, sync::{ + atomic::AtomicUsize, mpsc::{channel as oneshot_channel, Sender as OneshotSender}, Arc, }, time::Duration, }; -/// The identifier for a specific fork, this could be the name of the network a custom descriptive -/// name. +/// The _unique_ identifier for a specific fork, this could be the name of the network a custom +/// descriptive name. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct ForkId(pub String); +impl ForkId { + /// Returns the identifier of the fork + pub fn as_str(&self) -> &str { + &self.0 + } +} + impl fmt::Display for ForkId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) @@ -165,7 +173,7 @@ enum Request { CreateFork(Box, CreateSender), /// Returns the Fork backend for the `ForkId` if it exists GetFork(ForkId, OneshotSender>), - /// Adjusts the block that's being forked + /// Adjusts the block that's being forked, by creating a new fork at the new block RollFork(ForkId, u64, CreateSender), /// Returns the environment of the fork GetEnv(ForkId, GetEnvSender), @@ -194,7 +202,10 @@ pub struct MultiForkHandler { // tasks currently in progress pending_tasks: Vec, - /// All created Forks in order to reuse them + /// All _unique_ forkids mapped to their corresponding backend. + /// + /// Note: The backend can be shared by multiple ForkIds if the target the same provider and + /// block number. forks: HashMap, /// Optional periodic interval to flush rpc cache @@ -238,9 +249,16 @@ impl MultiForkHandler { let fork_id = create_fork_id(&fork.url, fork.evm_opts.fork_block_number); trace!(?fork_id, "created new forkId"); - if let Some(fork) = self.forks.get_mut(&fork_id) { - fork.num_senders += 1; - let _ = sender.send(Ok((fork_id, fork.backend.clone(), fork.opts.env.clone()))); + if let Some(fork) = self.forks.get(&fork_id).cloned() { + // assign a new unique fork id but reuse the existing backend + let unique_fork_id: ForkId = + format!("{}-{}", fork_id.as_str(), fork.num_senders()).into(); + trace!(?fork_id, ?unique_fork_id, "created new unique forkId"); + fork.inc_senders(); + let backend = fork.backend.clone(); + let env = fork.opts.env.clone(); + self.forks.insert(unique_fork_id.clone(), fork); + let _ = sender.send(Ok((unique_fork_id, backend, env))); } else { // there could already be a task for the requested fork in progress if let Some(in_progress) = self.find_in_progress_task(&fork_id) { @@ -323,14 +341,21 @@ impl Future for MultiForkHandler { pin.handlers.push((id.clone(), handler)); let backend = fork.backend.clone(); let env = fork.opts.env.clone(); - pin.forks.insert(id.clone(), fork); + pin.forks.insert(id.clone(), fork.clone()); let _ = sender.send(Ok((id.clone(), backend.clone(), env.clone()))); - // also notify all additional senders + // also notify all additional senders and track unique forkIds for sender in additional_senders { - let _ = - sender.send(Ok((id.clone(), backend.clone(), env.clone()))); + fork.inc_senders(); + let unique_fork_id: ForkId = + format!("{}-{}", id.as_str(), fork.num_senders()).into(); + pin.forks.insert(unique_fork_id.clone(), fork.clone()); + let _ = sender.send(Ok(( + unique_fork_id, + backend.clone(), + env.clone(), + ))); } } Err(err) => { @@ -394,7 +419,7 @@ impl Future for MultiForkHandler { } /// Tracks the created Fork -#[derive(Debug)] +#[derive(Debug, Clone)] struct CreatedFork { /// How the fork was initially created opts: CreateFork, @@ -402,14 +427,22 @@ struct CreatedFork { backend: SharedBackend, /// How many consumers there are, since a `SharedBacked` can be used by multiple /// consumers - num_senders: usize, + num_senders: Arc, } // === impl CreatedFork === impl CreatedFork { pub fn new(opts: CreateFork, backend: SharedBackend) -> Self { - Self { opts, backend, num_senders: 1 } + Self { opts, backend, num_senders: Arc::new(AtomicUsize::new(1)) } + } + + fn inc_senders(&self) { + self.num_senders.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + } + + fn num_senders(&self) -> usize { + self.num_senders.load(std::sync::atomic::Ordering::Relaxed) } } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 6845f51b9bd4c..b53002ae2d170 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -287,3 +287,6 @@ test_repro!(6554; |config| { cheats_config.fs_permissions.add(PathPermission::read_write(path)); config.runner.cheats_config = std::sync::Arc::new(cheats_config); }); + +// https://github.com/foundry-rs/foundry/issues/6759 +test_repro!(6759); diff --git a/testdata/repros/Issue6759.t.sol b/testdata/repros/Issue6759.t.sol new file mode 100644 index 0000000000000..45a2f42b0620d --- /dev/null +++ b/testdata/repros/Issue6759.t.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6759 +contract Issue6759Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testCreateMulti() public { + uint256 fork1 = vm.createFork("rpcAlias", 10); + uint256 fork2 = vm.createFork("rpcAlias", 10); + uint256 fork3 = vm.createFork("rpcAlias", 10); + assert(fork1 != fork2); + assert(fork1 != fork3); + assert(fork2 != fork3); + } +} From b320027a8e9f26aca2c2b4490f106c4701597dc1 Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 11 Jan 2024 16:06:46 -0400 Subject: [PATCH 0464/1963] chore: use alloy state override on anvil (#6766) --- crates/anvil/core/src/eth/mod.rs | 1 - crates/anvil/core/src/eth/state.rs | 16 ------ .../core/src/eth/transaction/ethers_compat.rs | 52 ------------------- crates/anvil/core/src/eth/transaction/mod.rs | 4 +- crates/anvil/tests/it/api.rs | 36 ++++++++----- 5 files changed, 24 insertions(+), 85 deletions(-) delete mode 100644 crates/anvil/core/src/eth/state.rs diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index dbe28104a7a36..c2532bcb8760c 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -14,7 +14,6 @@ use ethers_core::types::transaction::eip712::TypedData; pub mod block; pub mod proof; pub mod receipt; -pub mod state; pub mod subscription; pub mod transaction; pub mod trie; diff --git a/crates/anvil/core/src/eth/state.rs b/crates/anvil/core/src/eth/state.rs deleted file mode 100644 index b492a06a0d593..0000000000000 --- a/crates/anvil/core/src/eth/state.rs +++ /dev/null @@ -1,16 +0,0 @@ -use ethers_core::types::{Address, Bytes, H256, U256}; -use std::collections::HashMap; - -#[derive(Clone, Debug, Default, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(deny_unknown_fields))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct AccountOverride { - pub nonce: Option, - pub code: Option, - pub balance: Option, - pub state: Option>, - pub state_diff: Option>, -} - -pub type StateOverride = HashMap; diff --git a/crates/anvil/core/src/eth/transaction/ethers_compat.rs b/crates/anvil/core/src/eth/transaction/ethers_compat.rs index 8844c1bf43fde..64e60151670fe 100644 --- a/crates/anvil/core/src/eth/transaction/ethers_compat.rs +++ b/crates/anvil/core/src/eth/transaction/ethers_compat.rs @@ -3,7 +3,6 @@ use super::EthTransactionRequest; use crate::eth::{ proof::AccountProof, - state::{AccountOverride, StateOverride as EthStateOverride}, transaction::{ DepositTransactionRequest, EIP1559TransactionRequest, EIP2930TransactionRequest, LegacyTransactionRequest, MaybeImpersonatedTransaction, TypedTransaction, @@ -12,7 +11,6 @@ use crate::eth::{ }; use alloy_primitives::{U128 as rU128, U256 as rU256, U64 as rU64}; use alloy_rpc_types::{ - state::{AccountOverride as AlloyAccountOverride, StateOverride}, transaction::request::TransactionRequest as AlloyTransactionRequest, AccessList as AlloyAccessList, CallRequest, Signature, Transaction as AlloyTransaction, }; @@ -118,56 +116,6 @@ pub fn from_ethers_access_list(access_list: AccessList) -> AlloyAccessList { AlloyAccessList(access_list.0.into_iter().map(ToAlloy::to_alloy).collect()) } -pub fn to_ethers_state_override(ov: StateOverride) -> EthStateOverride { - ov.into_iter() - .map(|(addr, o)| { - ( - addr.to_ethers(), - AccountOverride { - nonce: o.nonce.map(|n| n.to::()), - balance: o.balance.map(|b| b.to_ethers()), - code: o.code.map(|c| c.0.into()), - state_diff: o.state_diff.map(|s| { - s.into_iter() - .map(|(k, v)| (k.to_ethers(), H256::from_uint(&v.to_ethers()))) - .collect() - }), - state: o.state.map(|s| { - s.into_iter() - .map(|(k, v)| (k.to_ethers(), H256::from_uint(&v.to_ethers()))) - .collect() - }), - }, - ) - }) - .collect() -} - -pub fn to_alloy_state_override(ov: EthStateOverride) -> StateOverride { - ov.into_iter() - .map(|(addr, o)| { - ( - addr.to_alloy(), - AlloyAccountOverride { - nonce: o.nonce.map(rU64::from), - balance: o.balance.map(|b| b.to_alloy()), - code: o.code.map(|c| c.0.into()), - state_diff: o.state_diff.map(|s| { - s.into_iter() - .map(|(k, v)| (k.to_alloy(), rU256::from_be_bytes(v.to_alloy().0))) - .collect() - }), - state: o.state.map(|s| { - s.into_iter() - .map(|(k, v)| (k.to_alloy(), rU256::from_be_bytes(v.to_alloy().0))) - .collect() - }), - }, - ) - }) - .collect() -} - impl From for EthersTypedTransactionRequest { fn from(tx: TypedTransactionRequest) -> Self { match tx { diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 7c259b8cdbe0f..3fcedd7f66382 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -26,8 +26,8 @@ use std::ops::Deref; mod ethers_compat; pub use ethers_compat::{ - call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_alloy_state_override, - to_ethers_access_list, to_ethers_state_override, to_internal_tx_request, + call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_ethers_access_list, + to_internal_tx_request, }; /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 7a6a64ae379a0..84c93ea0338ef 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -1,21 +1,23 @@ //! general eth api tests use crate::abi::{MulticallContract, SimpleStorage}; -use alloy_primitives::U256 as rU256; -use alloy_rpc_types::{CallInput, CallRequest}; +use alloy_primitives::{B256, U256 as rU256}; +use alloy_rpc_types::{ + state::{AccountOverride, StateOverride}, + CallInput, CallRequest, +}; use anvil::{ eth::{api::CLIENT_VERSION, EthApi}, spawn, NodeConfig, CHAIN_ID, }; -use anvil_core::eth::{state::AccountOverride, transaction::to_alloy_state_override}; use ethers::{ abi::{Address, Tokenizable}, prelude::{builders::ContractCall, decode_function_data, Middleware, SignerMiddleware}, signers::Signer, - types::{Block, BlockNumber, Chain, Transaction, TransactionRequest, H256, U256}, + types::{Block, BlockNumber, Chain, Transaction, TransactionRequest, U256}, utils::get_contract_address, }; -use foundry_common::types::ToAlloy; +use foundry_common::types::{ToAlloy, ToEthers}; use std::{collections::HashMap, sync::Arc, time::Duration}; #[tokio::test(flavor = "multi_thread")] @@ -227,7 +229,7 @@ async fn call_with_override( api: &EthApi, call: ContractCall, to: Address, - overrides: HashMap, + overrides: StateOverride, ) -> D where D: Tokenizable, @@ -240,7 +242,7 @@ where ..Default::default() }, None, - Some(to_alloy_state_override(overrides)), + Some(overrides), ) .await .unwrap(); @@ -268,25 +270,28 @@ async fn can_call_with_state_override() { .unwrap(); // Test the `balance` account override - let balance = 42u64.into(); + let balance = rU256::from(42u64); let result = call_with_override( &api, multicall.get_eth_balance(account), multicall.address(), HashMap::from([( - account, + account.to_alloy(), AccountOverride { balance: Some(balance), ..Default::default() }, )]), ) .await; - assert_eq!(result, balance); + assert_eq!(result, balance.to_ethers()); // Test the `state_diff` account override let overrides = HashMap::from([( - simple_storage.address(), + simple_storage.address().to_alloy(), AccountOverride { // The `lastSender` is in the first storage slot - state_diff: Some(HashMap::from([(H256::from_low_u64_be(0), account.into())])), + state_diff: Some(HashMap::from([( + B256::ZERO, + rU256::from_be_slice(B256::from(account.to_alloy().into_word()).as_slice()), + )])), ..Default::default() }, )]); @@ -317,10 +322,13 @@ async fn can_call_with_state_override() { // Test the `state` account override let overrides = HashMap::from([( - simple_storage.address(), + simple_storage.address().to_alloy(), AccountOverride { // The `lastSender` is in the first storage slot - state: Some(HashMap::from([(H256::from_low_u64_be(0), account.into())])), + state: Some(HashMap::from([( + B256::ZERO, + rU256::from_be_slice(B256::from(account.to_alloy().into_word()).as_slice()), + )])), ..Default::default() }, )]); From 18f5022e5036be1e5f23daf8def74f29aee326bd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 12 Jan 2024 12:04:06 +0100 Subject: [PATCH 0465/1963] chore: bump alloy chains (#6773) --- Cargo.lock | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c41229c84e243..ed9e2f41ee81a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa1873637aa7f20369eae38b312cf7550c266d13ebc60f176fd5c82c5127810b" +checksum = "59a5f61137c31916542bb63cd70d0e0dd7a76f76b7f962f4337bc438612d45b2" dependencies = [ "num_enum", "serde", @@ -4983,7 +4983,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.0.0", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5646,15 +5646,6 @@ dependencies = [ "toml_edit 0.20.7", ] -[[package]] -name = "proc-macro-crate" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" -dependencies = [ - "toml_edit 0.21.0", -] - [[package]] name = "proc-macro-error" version = "1.0.4" From d2372db7b38aea9d2f8b055185035a9720338875 Mon Sep 17 00:00:00 2001 From: KallyDev Date: Fri, 12 Jan 2024 19:40:48 +0800 Subject: [PATCH 0466/1963] feat(anvil): support eth_getBlockReceipts method (#6771) * feat(anvil): support eth_getBlockReceipts method * chore(anvil): cargo fmt --- Cargo.lock | 66 ++++++++++++------------- crates/anvil/core/src/eth/mod.rs | 3 ++ crates/anvil/src/eth/api.rs | 14 ++++++ crates/anvil/src/eth/backend/fork.rs | 24 +++++++++ crates/anvil/src/eth/backend/mem/mod.rs | 38 ++++++++++++++ crates/anvil/tests/it/fork.rs | 14 ++++++ 6 files changed, 126 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed9e2f41ee81a..7b65741545c04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-primitives", "serde", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -184,7 +184,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-network", "alloy-primitives", @@ -203,7 +203,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -241,7 +241,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -258,7 +258,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -272,7 +272,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -327,10 +327,10 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-json-rpc", - "base64 0.21.6", + "base64 0.21.7", "serde", "serde_json", "thiserror", @@ -343,7 +343,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -356,7 +356,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -374,7 +374,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -423,9 +423,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", @@ -872,7 +872,7 @@ checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", - "base64 0.21.6", + "base64 0.21.7", "bitflags 1.3.2", "bytes", "futures-util", @@ -945,9 +945,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.6" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79fed4cdb43e993fcdadc7e58a09fd0e3e649c4436fa11da71c9f1f3ee7feb9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64ct" @@ -1406,9 +1406,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.14" +version = "4.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e92c5c1a78c62968ec57dbc2440366a2d6e5a23faf829970ff1585dc6b18e2" +checksum = "c12ed66a79a555082f595f7eb980d08669de95009dd4b3d61168c573ebe38fc9" dependencies = [ "clap_builder", "clap_derive", @@ -1416,9 +1416,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.14" +version = "4.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4323769dc8a61e2c39ad7dc26f6f2800524691a44d74fe3d1071a5c24db6370" +checksum = "0f4645eab3431e5a8403a96bea02506a8b35d28cd0f0330977dd5d22f9c84f43" dependencies = [ "anstream", "anstyle", @@ -1528,7 +1528,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.6", + "base64 0.21.7", "bech32", "bs58", "digest 0.10.7", @@ -2165,7 +2165,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" dependencies = [ - "base64 0.21.6", + "base64 0.21.7", "bytes", "hex", "k256", @@ -2480,7 +2480,7 @@ source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a68 dependencies = [ "async-trait", "auto_impl", - "base64 0.21.6", + "base64 0.21.7", "bytes", "const-hex", "enr", @@ -3785,9 +3785,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "b553656127a00601c8ae5590fcfdc118e4083a7924b6cf4ffc1ea4b99dc429d7" dependencies = [ "bytes", "fnv", @@ -4355,7 +4355,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.6", + "base64 0.21.7", "pem", "ring 0.16.20", "serde", @@ -6004,7 +6004,7 @@ version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ - "base64 0.21.6", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -6417,7 +6417,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.6", + "base64 0.21.7", ] [[package]] @@ -8379,9 +8379,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.33" +version = "0.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7520bbdec7211caa7c4e682eb1fbe07abe20cee6756b6e00f537c82c11816aa" +checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" dependencies = [ "memchr", ] @@ -8534,4 +8534,4 @@ dependencies = [ [[patch.unused]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3" +source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index c2532bcb8760c..e6fb8789fcd79 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -193,6 +193,9 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "eth_getTransactionReceipt", with = "sequence"))] EthGetTransactionReceipt(B256), + #[cfg_attr(feature = "serde", serde(rename = "eth_getBlockReceipts", with = "sequence"))] + EthGetBlockReceipts(BlockNumber), + #[cfg_attr(feature = "serde", serde(rename = "eth_getUncleByBlockHashAndIndex"))] EthGetUncleByBlockHashAndIndex(B256, Index), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index d0ec41acf0230..6fbe1ac166cf7 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -241,6 +241,9 @@ impl EthApi { EthRequest::EthGetTransactionReceipt(tx) => { self.transaction_receipt(tx).await.to_rpc_result() } + EthRequest::EthGetBlockReceipts(number) => { + self.block_receipts(number).await.to_rpc_result() + } EthRequest::EthGetUncleByBlockHashAndIndex(hash, index) => { self.uncle_by_block_hash_and_index(hash, index).await.to_rpc_result() } @@ -1159,6 +1162,17 @@ impl EthApi { self.backend.transaction_receipt(hash).await } + /// Returns block receipts by block number. + /// + /// Handler for ETH RPC call: `eth_getBlockReceipts` + pub async fn block_receipts( + &self, + number: BlockNumber, + ) -> Result>> { + node_info!("eth_getBlockReceipts"); + self.backend.block_receipts(number).await + } + /// Returns an uncles at given block and index. /// /// Handler for ETH RPC call: `eth_getUncleByBlockHashAndIndex` diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 9e6add417efd2..029b92f167c20 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -420,6 +420,29 @@ impl ClientFork { Ok(None) } + pub async fn block_receipts( + &self, + number: u64, + ) -> Result>, TransportError> { + if let receipts @ Some(_) = self.storage_read().block_receipts.get(&number).cloned() { + return Ok(receipts); + } + + // TODO Needs to be removed. + // Since alloy doesn't indicate in the result whether the block exists, + // this is being temporarily implemented in anvil. + if self.predates_fork_inclusive(number) { + let receipts = self.provider().get_block_receipts(BlockNumber::Number(number)).await?; + + let mut storage = self.storage_write(); + storage.block_receipts.insert(number, receipts.clone()); + + return Ok(Some(receipts)); + } + + Ok(None) + } + pub async fn block_by_hash(&self, hash: B256) -> Result, TransportError> { if let Some(mut block) = self.storage_read().blocks.get(&hash).cloned() { block.transactions.convert_to_hashes(); @@ -647,6 +670,7 @@ pub struct ForkedStorage { pub logs: HashMap>, pub geth_transaction_traces: HashMap, pub block_traces: HashMap>, + pub block_receipts: HashMap>, pub eth_gas_estimations: HashMap<(Arc, u64), U256>, pub eth_call: HashMap<(Arc, u64), Bytes>, pub code_at: HashMap<(Address, u64), Bytes>, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 02edc0aa3db1c..d27b45d2ce702 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1978,6 +1978,19 @@ impl Backend { Some(receipts) } + /// Returns all transaction receipts of the block + pub fn mined_block_receipts(&self, id: impl Into) -> Option> { + let mut receipts = Vec::new(); + let block = self.get_block(id)?; + + for transaction in block.transactions { + let receipt = self.mined_transaction_receipt(transaction.hash().to_alloy())?; + receipts.push(receipt.inner); + } + + Some(receipts) + } + /// Returns the transaction receipt for the given hash pub(crate) fn mined_transaction_receipt(&self, hash: B256) -> Option { let MinedTransaction { info, receipt, block_hash, .. } = @@ -2073,6 +2086,31 @@ impl Backend { Some(MinedTransactionReceipt { inner, out: info.out.map(|o| o.0.into()) }) } + /// Returns the blocks receipts for the given number + pub async fn block_receipts( + &self, + number: BlockNumber, + ) -> Result>, BlockchainError> { + if let Some(receipts) = self.mined_block_receipts(number) { + return Ok(Some(receipts)); + } + + if let Some(fork) = self.get_fork() { + let number = self.convert_block_number(Some(number)); + + if fork.predates_fork_inclusive(number) { + let receipts = fork + .block_receipts(number) + .await + .map_err(BlockchainError::AlloyForkProvider)?; + + return Ok(receipts); + } + } + + Ok(None) + } + pub async fn transaction_by_block_number_and_index( &self, number: BlockNumber, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index f3efb4475fab1..871f629f0c894 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -989,6 +989,20 @@ async fn test_transaction_receipt() { assert!(receipt.is_none()); } +// +#[tokio::test(flavor = "multi_thread")] +async fn test_block_receipts() { + let (api, _) = spawn(fork_config()).await; + + // Receipts from the forked block (14608400) + let receipts = api.block_receipts(BlockNumberOrTag::Number(BLOCK_NUMBER)).await.unwrap(); + assert!(receipts.is_some()); + + // Receipts from a block in the future (14608401) + let receipts = api.block_receipts(BlockNumberOrTag::Number(BLOCK_NUMBER + 1)).await.unwrap(); + assert!(receipts.is_none()); +} + #[tokio::test(flavor = "multi_thread")] async fn can_override_fork_chain_id() { let chain_id_override = 5u64; From b0e70ba7401d120701de10dee2b09d4e55c7354e Mon Sep 17 00:00:00 2001 From: Enrique Date: Fri, 12 Jan 2024 10:12:39 -0400 Subject: [PATCH 0467/1963] chore(`anvil`): remove ethers usage on subscription (#6775) * chore: remove ethers usage for anvil subscriptions * chore: fmt --- Cargo.lock | 1 + crates/anvil/core/Cargo.toml | 3 + crates/anvil/core/src/eth/subscription.rs | 74 +---------------------- 3 files changed, 6 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b65741545c04..4140ae6b64670 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -544,6 +544,7 @@ dependencies = [ "hash256-std-hasher", "keccak-hasher", "open-fastrlp", + "rand 0.8.5", "reference-trie", "revm", "serde", diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 6828bb9f79363..1a69cd012a878 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -35,6 +35,9 @@ triehash = { version = "0.8", default-features = false } reference-trie = "0.25" keccak-hasher = "0.15" +# misc +rand = "0.8" + [dev-dependencies] anvil-core = { path = ".", features = ["serde"] } diff --git a/crates/anvil/core/src/eth/subscription.rs b/crates/anvil/core/src/eth/subscription.rs index 7f1432af99183..cc162cc4dc9f7 100644 --- a/crates/anvil/core/src/eth/subscription.rs +++ b/crates/anvil/core/src/eth/subscription.rs @@ -1,78 +1,8 @@ //! Subscription types - -use crate::eth::block::Header; -use ethers_core::{ - rand::{distributions::Alphanumeric, thread_rng, Rng}, - types::{Filter, Log, TxHash}, - utils::hex, -}; +use alloy_primitives::hex; +use rand::{distributions::Alphanumeric, thread_rng, Rng}; use std::fmt; -/// Result of a subscription -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[cfg_attr(feature = "serde", serde(untagged))] -pub enum SubscriptionResult { - /// New block header - Header(Box
), - /// Log - Log(Box), - /// Transaction hash - TransactionHash(TxHash), - /// SyncStatus - Sync(SyncStatus), -} - -/// Sync status -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct SyncStatus { - pub syncing: bool, -} - -/// Params for a subscription request -#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] -pub struct SubscriptionParams { - /// holds the filter params field if present in the request - pub filter: Option, -} - -#[cfg(feature = "serde")] -impl<'a> serde::Deserialize<'a> for SubscriptionParams { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'a>, - { - use serde::de::Error; - - let val = serde_json::Value::deserialize(deserializer)?; - if val.is_null() { - return Ok(SubscriptionParams::default()) - } - - let filter: Filter = serde_json::from_value(val) - .map_err(|e| D::Error::custom(format!("Invalid Subscription parameters: {e}")))?; - Ok(SubscriptionParams { filter: Some(filter) }) - } -} - -/// Subscription kind -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(deny_unknown_fields))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub enum SubscriptionKind { - /// subscribe to new heads - NewHeads, - /// subscribe to new logs - Logs, - /// subscribe to pending transactions - NewPendingTransactions, - /// syncing subscription - Syncing, -} - /// Unique subscription id #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] From 82ec19aec2a6981194475abf544ab1edd5f8ebc0 Mon Sep 17 00:00:00 2001 From: Enrique Date: Fri, 12 Jan 2024 12:39:30 -0400 Subject: [PATCH 0468/1963] chore(`anvil`): mostly remove EthTransactionRequest usage, migrate AccessListTracer (#6776) * chore: remove EthTransactionRequest usage, migrate AccessListTracer * chore: remove unneeded conv func * chore: remove unnecesary clone --- Cargo.lock | 1 + .../core/src/eth/transaction/ethers_compat.rs | 24 ------- crates/anvil/core/src/eth/transaction/mod.rs | 1 - crates/anvil/core/src/eth/utils.rs | 7 ++ crates/anvil/src/eth/api.rs | 71 +++++++++---------- crates/anvil/src/eth/backend/mem/mod.rs | 48 ++++++------- crates/evm/evm/Cargo.toml | 1 + crates/evm/evm/src/inspectors/access_list.rs | 16 ++--- 8 files changed, 69 insertions(+), 100 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4140ae6b64670..d5106ad37e495 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3145,6 +3145,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-rpc-types", "alloy-sol-types", "const-hex", "ethers-core", diff --git a/crates/anvil/core/src/eth/transaction/ethers_compat.rs b/crates/anvil/core/src/eth/transaction/ethers_compat.rs index 64e60151670fe..88e87a9d7cde1 100644 --- a/crates/anvil/core/src/eth/transaction/ethers_compat.rs +++ b/crates/anvil/core/src/eth/transaction/ethers_compat.rs @@ -11,7 +11,6 @@ use crate::eth::{ }; use alloy_primitives::{U128 as rU128, U256 as rU256, U64 as rU64}; use alloy_rpc_types::{ - transaction::request::TransactionRequest as AlloyTransactionRequest, AccessList as AlloyAccessList, CallRequest, Signature, Transaction as AlloyTransaction, }; use ethers_core::types::{ @@ -47,29 +46,6 @@ pub fn to_alloy_storage_proof(proof: &StorageProof) -> alloy_rpc_types::EIP1186S } } -pub fn to_internal_tx_request(request: &AlloyTransactionRequest) -> EthTransactionRequest { - EthTransactionRequest { - from: request.from.map(|a| a.to_ethers()), - to: request.to.map(|a| a.to_ethers()), - gas_price: request.gas_price.map(|g| alloy_primitives::U256::from(g).to_ethers()), - max_fee_per_gas: request - .max_fee_per_gas - .map(|g| alloy_primitives::U256::from(g).to_ethers()), - max_priority_fee_per_gas: request - .max_priority_fee_per_gas - .map(|g| alloy_primitives::U256::from(g).to_ethers()), - gas: request.gas.map(|g| g.to_ethers()), - value: request.value.map(|v| v.to_ethers()), - data: request.data.clone().map(|b| b.clone().0.into()), - nonce: request.nonce.map(|n| n.to::().into()), - chain_id: None, - access_list: request.access_list.clone().map(|a| to_ethers_access_list(a.clone()).0), - transaction_type: request.transaction_type.map(|t| t.to::().into()), - // TODO: Should this be none? - optimism_fields: None, - } -} - pub fn call_to_internal_tx_request(request: &CallRequest) -> EthTransactionRequest { EthTransactionRequest { from: request.from.map(|a| a.to_ethers()), diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 3fcedd7f66382..ef67a4667d710 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -27,7 +27,6 @@ mod ethers_compat; pub use ethers_compat::{ call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_ethers_access_list, - to_internal_tx_request, }; /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index 21711cb3eb9cb..e67e5dd4a9053 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,4 +1,5 @@ use alloy_primitives::{Address, U256}; +use alloy_rpc_types::AccessListItem as AlloyAccessListItem; use ethers_core::{ types::transaction::eip2930::AccessListItem, utils::{ @@ -26,3 +27,9 @@ pub fn to_revm_access_list(list: Vec) -> Vec<(Address, Vec }) .collect() } + +pub fn alloy_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { + list.into_iter() + .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) + .collect() +} diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 6fbe1ac166cf7..c90bdc3bc9125 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -46,9 +46,8 @@ use anvil_core::{ eth::{ block::BlockInfo, transaction::{ - call_to_internal_tx_request, to_alloy_proof, to_ethers_access_list, - EthTransactionRequest, LegacyTransaction, PendingTransaction, TransactionKind, - TypedTransaction, TypedTransactionRequest, + call_to_internal_tx_request, to_alloy_proof, EthTransactionRequest, LegacyTransaction, + PendingTransaction, TransactionKind, TypedTransaction, TypedTransactionRequest, }, EthRequest, }, @@ -1007,7 +1006,6 @@ impl EthApi { request.max_priority_fee_per_gas, )? .or_zero_fees(); - let request = call_to_internal_tx_request(&request); // this can be blocking for a bit, especially in forking mode // self.on_blocking_task(|this| async move { @@ -1035,7 +1033,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_createAccessList` pub async fn create_access_list( &self, - request: CallRequest, + mut request: CallRequest, block_number: Option, ) -> Result { node_info!("eth_createAccessList"); @@ -1052,8 +1050,6 @@ impl EthApi { } } - let mut request = call_to_internal_tx_request(&request); - self.backend .with_database_at(Some(block_request), |state, block_env| { let (exit, out, _, access_list) = self.backend.build_access_list_with_state( @@ -1065,7 +1061,7 @@ impl EthApi { ensure_return_ok(exit, &out)?; // execute again but with access list set - request.access_list = Some(to_ethers_access_list(access_list.clone()).0); + request.access_list = Some(access_list.clone()); let (exit, out, gas_used, _) = self.backend.call_with_state( &state, @@ -1474,8 +1470,6 @@ impl EthApi { )? .or_zero_fees(); - let request = call_to_internal_tx_request(&request); - self.backend.call_with_tracing(request, fees, Some(block_request), opts).await } @@ -2187,20 +2181,19 @@ impl EthApi { /// This will execute the [CallRequest] and find the best gas limit via binary search fn do_estimate_gas_with_state( &self, - request: CallRequest, + mut request: CallRequest, state: D, block_env: BlockEnv, ) -> Result where D: DatabaseRef, { - let mut request = call_to_internal_tx_request(&request); - // if the request is a simple transfer we can optimize - let likely_transfer = - request.data.as_ref().map(|data| data.as_ref().is_empty()).unwrap_or(true); + // If the request is a simple native token transfer we can optimize + // We assume it's a transfer if we have no input data. + let likely_transfer = request.input.clone().into_input().is_none(); if likely_transfer { if let Some(to) = request.to { - if let Ok(target_code) = self.backend.get_code_with_state(&state, to.to_alloy()) { + if let Ok(target_code) = self.backend.get_code_with_state(&state, to) { if target_code.as_ref().is_empty() { return Ok(MIN_TRANSACTION_GAS); } @@ -2209,34 +2202,33 @@ impl EthApi { } let fees = FeeDetails::new( - request.gas_price.map(ToAlloy::to_alloy), - request.max_fee_per_gas.map(ToAlloy::to_alloy), - request.max_priority_fee_per_gas.map(ToAlloy::to_alloy), + request.gas_price, + request.max_fee_per_gas, + request.max_priority_fee_per_gas, )? .or_zero_fees(); // get the highest possible gas limit, either the request's set value or the currently // configured gas limit - let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit.to_ethers()); + let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit); // check with the funds of the sender if let Some(from) = request.from { let gas_price = fees.gas_price.unwrap_or_default(); if gas_price > U256::ZERO { - let mut available_funds = - self.backend.get_balance_with_state(&state, from.to_alloy())?; + let mut available_funds = self.backend.get_balance_with_state(&state, from)?; if let Some(value) = request.value { - if value > available_funds.to_ethers() { + if value > available_funds { return Err(InvalidTransactionError::InsufficientFunds.into()); } // safe: value < available_funds - available_funds -= value.to_alloy(); + available_funds -= value; } // amount of gas the sender can afford with the `gas_price` let allowance = available_funds.checked_div(gas_price).unwrap_or_default(); - if highest_gas_limit > allowance.to_ethers() { + if highest_gas_limit > allowance { trace!(target: "node", "eth_estimateGas capped by limited user funds"); - highest_gas_limit = allowance.to_ethers(); + highest_gas_limit = allowance; } } } @@ -2264,7 +2256,7 @@ impl EthApi { self.backend.clone(), block_env, fees, - gas_limit.to_alloy(), + gas_limit, )); } } @@ -2275,7 +2267,7 @@ impl EthApi { // succeeded } InstructionResult::OutOfGas | InstructionResult::OutOfFund => { - return Err(InvalidTransactionError::BasicOutOfGas(gas_limit).into()) + return Err(InvalidTransactionError::BasicOutOfGas(gas_limit.to_ethers()).into()) } // need to check if the revert was due to lack of gas or unrelated reason // we're also checking for InvalidFEOpcode here because this can be used to trigger an error common usage in openzeppelin @@ -2289,7 +2281,7 @@ impl EthApi { self.backend.clone(), block_env, fees, - gas_limit.to_alloy(), + gas_limit, )) } else { // the transaction did fail due to lack of gas from the user @@ -2309,17 +2301,18 @@ impl EthApi { // transaction requires to succeed let gas: U256 = U256::from(gas); // Get the starting lowest gas needed depending on the transaction kind. - let mut lowest_gas_limit = determine_base_gas_by_kind(request.clone()); + let mut lowest_gas_limit = + determine_base_gas_by_kind(call_to_internal_tx_request(&request)); // pick a point that's close to the estimated gas let mut mid_gas_limit = std::cmp::min( gas * U256::from(3), - ((highest_gas_limit + lowest_gas_limit.to_ethers()) / 2).to_alloy(), + (highest_gas_limit + lowest_gas_limit) / U256::from(2), ); // Binary search for the ideal gas limit - while (highest_gas_limit - lowest_gas_limit.to_ethers()).to_alloy() > U256::from(1) { - request.gas = Some(mid_gas_limit.to_ethers()); + while (highest_gas_limit - lowest_gas_limit) > U256::from(1) { + request.gas = Some(mid_gas_limit); let ethres = self.backend.call_with_state( &state, request.clone(), @@ -2337,7 +2330,7 @@ impl EthApi { lowest_gas_limit = mid_gas_limit; // new midpoint - mid_gas_limit = ((highest_gas_limit + lowest_gas_limit.to_ethers()) / 2).to_alloy(); + mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / U256::from(2); continue; } @@ -2347,7 +2340,7 @@ impl EthApi { // at the current midpoint, as spending any more gas would // make no sense (as the TX would still succeed). return_ok!() => { - highest_gas_limit = mid_gas_limit.to_ethers(); + highest_gas_limit = mid_gas_limit; } // If the transaction failed due to lack of gas, we can set a floor for the // lowest gas limit at the current midpoint, as spending any @@ -2374,12 +2367,12 @@ impl EthApi { } } // new midpoint - mid_gas_limit = ((highest_gas_limit + lowest_gas_limit.to_ethers()) / 2).to_alloy(); + mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / U256::from(2); } trace!(target : "node", "Estimated Gas for call {:?}", highest_gas_limit); - Ok(highest_gas_limit.to_alloy()) + Ok(highest_gas_limit) } /// Updates the `TransactionOrder` @@ -2647,7 +2640,7 @@ fn ensure_return_ok(exit: InstructionResult, out: &Option) -> Result( - mut request: EthTransactionRequest, + mut request: CallRequest, state: D, backend: Arc, block_env: BlockEnv, @@ -2657,7 +2650,7 @@ fn map_out_of_gas_err( where D: DatabaseRef, { - request.gas = Some(backend.gas_limit()).map(|g| g.to_ethers()); + request.gas = Some(backend.gas_limit()); let (exit, out, _, _) = match backend.call_with_state(&state, request, fees, block_env) { Ok(res) => res, Err(err) => return err, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d27b45d2ce702..d55f060412878 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -36,8 +36,8 @@ use alloy_rpc_trace_types::{ }; use alloy_rpc_types::{ state::StateOverride, AccessList, Block as AlloyBlock, BlockId, - BlockNumberOrTag as BlockNumber, Filter, FilteredParams, Header as AlloyHeader, Log, - Transaction, TransactionReceipt, + BlockNumberOrTag as BlockNumber, CallRequest, Filter, FilteredParams, Header as AlloyHeader, + Log, Transaction, TransactionReceipt, }; use anvil_core::{ eth::{ @@ -45,18 +45,16 @@ use anvil_core::{ proof::{AccountProof, BasicAccount, StorageProof}, receipt::{EIP658Receipt, TypedReceipt}, transaction::{ - from_ethers_access_list, EthTransactionRequest, MaybeImpersonatedTransaction, - PendingTransaction, TransactionInfo, TypedTransaction, + MaybeImpersonatedTransaction, PendingTransaction, TransactionInfo, TypedTransaction, }, trie::RefTrieDB, - utils::to_revm_access_list, + utils::alloy_to_revm_access_list, }, types::{Forking, Index}, }; use anvil_rpc::error::RpcError; use ethers::{ abi::ethereum_types::BigEndianHash, - types::transaction::eip2930::AccessList as EthersAccessList, utils::{keccak256, rlp}, }; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; @@ -1024,14 +1022,14 @@ impl Backend { outcome } - /// Executes the `EthTransactionRequest` without writing to the DB + /// Executes the [CallRequest] without writing to the DB /// /// # Errors /// /// Returns an error if the `block_number` is greater than the current height pub async fn call( &self, - request: EthTransactionRequest, + request: CallRequest, fee_details: FeeDetails, block_request: Option, overrides: Option, @@ -1052,15 +1050,15 @@ impl Backend { fn build_call_env( &self, - request: EthTransactionRequest, + request: CallRequest, fee_details: FeeDetails, block_env: BlockEnv, ) -> Env { - let EthTransactionRequest { from, to, gas, value, data, nonce, access_list, .. } = request; + let CallRequest { from, to, gas, value, input, nonce, access_list, .. } = request; let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = fee_details; - let gas_limit = gas.unwrap_or(block_env.gas_limit.to_ethers()); + let gas_limit = gas.unwrap_or(block_env.gas_limit); let mut env = self.env.read().clone(); env.block = block_env; // we want to disable this in eth_call, since this is common practice used by other node @@ -1075,19 +1073,19 @@ impl Backend { let caller = from.unwrap_or_default(); env.tx = TxEnv { - caller: caller.to_alloy(), - gas_limit: gas_limit.as_u64(), + caller, + gas_limit: gas_limit.to::(), gas_price, gas_priority_fee: max_priority_fee_per_gas, transact_to: match to { - Some(addr) => TransactTo::Call(addr.to_alloy()), + Some(addr) => TransactTo::Call(addr), None => TransactTo::Create(CreateScheme::Create), }, - value: value.unwrap_or_default().to_alloy(), - data: data.unwrap_or_default().to_vec().into(), + value: value.unwrap_or_default(), + data: input.into_input().unwrap_or_default(), chain_id: None, - nonce: nonce.map(|n| n.as_u64()), - access_list: to_revm_access_list(access_list.unwrap_or_default()), + nonce: nonce.map(|n| n.to::()), + access_list: alloy_to_revm_access_list(access_list.unwrap_or_default().0), ..Default::default() }; @@ -1103,7 +1101,7 @@ impl Backend { pub fn call_with_state( &self, state: D, - request: EthTransactionRequest, + request: CallRequest, fee_details: FeeDetails, block_env: BlockEnv, ) -> Result<(InstructionResult, Option, u64, State), BlockchainError> @@ -1149,7 +1147,7 @@ impl Backend { pub async fn call_with_tracing( &self, - request: EthTransactionRequest, + request: CallRequest, fee_details: FeeDetails, block_request: Option, opts: GethDefaultTracingOptions, @@ -1189,23 +1187,23 @@ impl Backend { pub fn build_access_list_with_state( &self, state: D, - request: EthTransactionRequest, + request: CallRequest, fee_details: FeeDetails, block_env: BlockEnv, ) -> Result<(InstructionResult, Option, u64, AccessList), BlockchainError> where D: DatabaseRef, { - let from = request.from.unwrap_or_default().to_alloy(); + let from = request.from.unwrap_or_default(); let to = if let Some(to) = request.to { - to.to_alloy() + to } else { let nonce = state.basic_ref(from)?.unwrap_or_default().nonce; from.create(nonce) }; let mut tracer = AccessListTracer::new( - EthersAccessList(request.access_list.clone().unwrap_or_default()), + request.access_list.clone().unwrap_or_default(), from, to, self.precompiles(), @@ -1230,7 +1228,7 @@ impl Backend { } }; let access_list = tracer.access_list(); - Ok((exit_reason, out, gas_used, from_ethers_access_list(access_list))) + Ok((exit_reason, out, gas_used, access_list)) } /// returns all receipts for the given transactions diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index b05871c6494dc..ccf2cb1ac4fad 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -24,6 +24,7 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true +alloy-rpc-types.workspace = true hashbrown = { version = "0.14", features = ["serde"] } revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs index 37f4e13edbc87..d7425730f6cf3 100644 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ b/crates/evm/evm/src/inspectors/access_list.rs @@ -1,6 +1,5 @@ use alloy_primitives::{Address, B256}; -use ethers_core::types::transaction::eip2930::{AccessList, AccessListItem}; -use foundry_common::types::{ToAlloy, ToEthers}; +use alloy_rpc_types::{AccessList, AccessListItem}; use hashbrown::{HashMap, HashSet}; use revm::{ interpreter::{opcode, Interpreter}, @@ -26,23 +25,18 @@ impl AccessListTracer { access_list: access_list .0 .iter() - .map(|v| { - ( - v.address.to_alloy(), - v.storage_keys.iter().copied().map(|v| v.to_alloy()).collect(), - ) - }) + .map(|v| (v.address, v.storage_keys.iter().copied().map(|k| k.into()).collect())) .collect(), } } pub fn access_list(&self) -> AccessList { - AccessList::from( + AccessList( self.access_list .iter() .map(|(address, slots)| AccessListItem { - address: address.to_ethers(), - storage_keys: slots.iter().copied().map(|k| k.to_ethers()).collect(), + address: *address, + storage_keys: slots.iter().copied().map(|k| k.into()).collect(), }) .collect::>(), ) From 54f773348ba1632ad3ebdfcb72b48c8e65af2346 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:17:40 +0100 Subject: [PATCH 0469/1963] chore: bring back the clippy (#6777) --- Cargo.lock | 5 ----- Cargo.toml | 2 +- crates/evm/evm/src/inspectors/access_list.rs | 4 ++-- crates/evm/evm/src/inspectors/stack.rs | 1 + 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5106ad37e495..eaa505b042b5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8532,8 +8532,3 @@ dependencies = [ "cc", "pkg-config", ] - -[[patch.unused]] -name = "alloy-signer" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" diff --git a/Cargo.toml b/Cargo.toml index 9b2ef7a62336f..730355287dc3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -217,7 +217,7 @@ alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy" } +# alloy-signer = { git = "https://github.com/alloy-rs/alloy" } alloy-transport = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs index d7425730f6cf3..ea43336a754ad 100644 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ b/crates/evm/evm/src/inspectors/access_list.rs @@ -25,7 +25,7 @@ impl AccessListTracer { access_list: access_list .0 .iter() - .map(|v| (v.address, v.storage_keys.iter().copied().map(|k| k.into()).collect())) + .map(|v| (v.address, v.storage_keys.iter().copied().collect())) .collect(), } } @@ -36,7 +36,7 @@ impl AccessListTracer { .iter() .map(|(address, slots)| AccessListItem { address: *address, - storage_keys: slots.iter().copied().map(|k| k.into()).collect(), + storage_keys: slots.iter().copied().collect(), }) .collect::>(), ) diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 659710b071fff..48ac5a8df5ab0 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -316,6 +316,7 @@ impl InspectorStack { traces: self.tracer.map(|tracer| tracer.get_traces().clone()), debug: self.debugger.map(|debugger| debugger.arena), coverage: self.coverage.map(|coverage| coverage.maps), + #[allow(clippy::useless_asref)] // https://github.com/rust-lang/rust-clippy/issues/12135 script_wallets: self .cheatcodes .as_ref() From 78b22dbed88f1b7a9b02351be4cce26ac907d4ef Mon Sep 17 00:00:00 2001 From: Enrique Date: Fri, 12 Jan 2024 15:37:11 -0400 Subject: [PATCH 0470/1963] chore(`anvil`): migrate cheatsmanager to alloy (#6767) * chore: migrate cheatsmanager to alloy * resolve nit * merge --- .../core/src/eth/transaction/ethers_compat.rs | 17 +++++++++++++ crates/anvil/core/src/eth/transaction/mod.rs | 13 +++++++--- crates/anvil/src/eth/api.rs | 25 +++++++++++++------ crates/anvil/src/eth/backend/cheats.rs | 3 ++- crates/anvil/src/eth/backend/mem/mod.rs | 6 ++--- 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/ethers_compat.rs b/crates/anvil/core/src/eth/transaction/ethers_compat.rs index 88e87a9d7cde1..50bb60b459814 100644 --- a/crates/anvil/core/src/eth/transaction/ethers_compat.rs +++ b/crates/anvil/core/src/eth/transaction/ethers_compat.rs @@ -26,6 +26,23 @@ use ethers_core::types::{ }; use foundry_common::types::{ToAlloy, ToEthers}; +pub fn to_alloy_signature(signature: ethers_core::types::Signature) -> alloy_rpc_types::Signature { + alloy_rpc_types::Signature { + r: signature.r.to_alloy(), + s: signature.s.to_alloy(), + v: signature.v.to_alloy().to::(), + y_parity: None, + } +} + +pub fn to_ethers_signature(signature: alloy_rpc_types::Signature) -> ethers_core::types::Signature { + ethers_core::types::Signature { + r: signature.r.to_ethers(), + s: signature.s.to_ethers(), + v: signature.v.to::(), + } +} + pub fn to_alloy_proof(proof: AccountProof) -> alloy_rpc_types::EIP1186AccountProofResponse { alloy_rpc_types::EIP1186AccountProofResponse { address: proof.address.to_alloy(), diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index ef67a4667d710..5fa6d1fc0bfd0 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -26,13 +26,18 @@ use std::ops::Deref; mod ethers_compat; pub use ethers_compat::{ - call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_ethers_access_list, + call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_alloy_signature, + to_ethers_access_list, to_ethers_signature, }; /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC #[cfg(feature = "impersonated-tx")] -pub const IMPERSONATED_SIGNATURE: Signature = - Signature { r: U256([0, 0, 0, 0]), s: U256([0, 0, 0, 0]), v: 0 }; +pub const IMPERSONATED_SIGNATURE: alloy_rpc_types::Signature = alloy_rpc_types::Signature { + r: alloy_primitives::U256::ZERO, + s: alloy_primitives::U256::ZERO, + v: alloy_primitives::U256::ZERO, + y_parity: None, +}; /// Container type for various Ethereum transaction requests /// @@ -789,7 +794,7 @@ impl TypedTransaction { /// Returns true if the transaction was impersonated (using the impersonate Signature) #[cfg(feature = "impersonated-tx")] pub fn is_impersonated(&self) -> bool { - self.signature() == IMPERSONATED_SIGNATURE + to_alloy_signature(self.signature()) == IMPERSONATED_SIGNATURE } /// Returns the hash if the transaction is impersonated (using a fake signature) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index c90bdc3bc9125..a814258d54697 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -46,8 +46,9 @@ use anvil_core::{ eth::{ block::BlockInfo, transaction::{ - call_to_internal_tx_request, to_alloy_proof, EthTransactionRequest, LegacyTransaction, - PendingTransaction, TransactionKind, TypedTransaction, TypedTransactionRequest, + call_to_internal_tx_request, to_alloy_proof, to_ethers_signature, + EthTransactionRequest, LegacyTransaction, PendingTransaction, TransactionKind, + TypedTransaction, TypedTransactionRequest, }, EthRequest, }, @@ -564,9 +565,15 @@ impl EthApi { pub fn accounts(&self) -> Result> { node_info!("eth_accounts"); let mut unique = HashSet::new(); - let mut accounts = Vec::new(); + let mut accounts: Vec
= Vec::new(); for signer in self.signers.iter() { - accounts.extend(signer.accounts().into_iter().filter(|acc| unique.insert(*acc))); + accounts.extend( + signer + .accounts() + .into_iter() + .map(|a| a.to_alloy()) + .filter(|acc| unique.insert(*acc)), + ); } accounts.extend( self.backend @@ -575,7 +582,7 @@ impl EthApi { .into_iter() .filter(|acc| unique.insert(*acc)), ); - Ok(accounts.into_iter().map(|acc| acc.to_alloy()).collect()) + Ok(accounts.into_iter().collect()) } /// Returns the number of most recent block. @@ -897,7 +904,8 @@ impl EthApi { // if the sender is currently impersonated we need to "bypass" signing let pending_transaction = if self.is_impersonated(from) { let bypass_signature = self.backend.cheats().bypass_signature(); - let transaction = sign::build_typed_transaction(request, bypass_signature)?; + let transaction = + sign::build_typed_transaction(request, to_ethers_signature(bypass_signature))?; self.ensure_typed_transaction_supported(&transaction)?; trace!(target : "node", ?from, "eth_sendTransaction: impersonating"); PendingTransaction::with_impersonated(transaction, from.to_ethers()) @@ -1993,7 +2001,8 @@ impl EthApi { let request = self.build_typed_tx_request(request, nonce)?; let bypass_signature = self.backend.cheats().bypass_signature(); - let transaction = sign::build_typed_transaction(request, bypass_signature)?; + let transaction = + sign::build_typed_transaction(request, to_ethers_signature(bypass_signature))?; self.ensure_typed_transaction_supported(&transaction)?; @@ -2528,7 +2537,7 @@ impl EthApi { /// Returns true if the `addr` is currently impersonated pub fn is_impersonated(&self, addr: Address) -> bool { - self.backend.cheats().is_impersonated(addr.to_ethers()) + self.backend.cheats().is_impersonated(addr) } /// Returns the nonce of the `address` depending on the `block_number` diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 68cbd8706ba64..a3cde4ccbd3eb 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -1,7 +1,8 @@ //! Support for "cheat codes" / bypass functions +use alloy_primitives::Address; +use alloy_rpc_types::Signature; use anvil_core::eth::transaction::IMPERSONATED_SIGNATURE; -use ethers::types::{Address, Signature}; use foundry_evm::hashbrown::HashSet; use parking_lot::RwLock; use std::sync::Arc; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d55f060412878..8af81395a726d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -310,20 +310,20 @@ impl Backend { /// /// Returns `true` if the account is already impersonated pub async fn impersonate(&self, addr: Address) -> DatabaseResult { - if self.cheats.impersonated_accounts().contains(&addr.to_ethers()) { + if self.cheats.impersonated_accounts().contains(&addr) { return Ok(true); } // Ensure EIP-3607 is disabled let mut env = self.env.write(); env.cfg.disable_eip3607 = true; - Ok(self.cheats.impersonate(addr.to_ethers())) + Ok(self.cheats.impersonate(addr)) } /// Removes the account that from the impersonated set /// /// If the impersonated `addr` is a contract then we also reset the code here pub async fn stop_impersonating(&self, addr: Address) -> DatabaseResult<()> { - self.cheats.stop_impersonating(&addr.to_ethers()); + self.cheats.stop_impersonating(&addr); Ok(()) } From 293fad73670b7b59ca901c7f2105bf7a29165a90 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 13 Jan 2024 11:42:03 +0100 Subject: [PATCH 0471/1963] chore: bump evm inspectors (#6783) --- Cargo.lock | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eaa505b042b5e..67f8a1acf5924 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6059,7 +6059,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#b9e6e4ea25b00e0ddcbe1f295c8a69a6d2a08e39" +source = "git+https://github.com/paradigmxyz/evm-inspectors#5028bdbc01a3ead97f7ebf742afaf8d058bee2ae" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6105,11 +6105,9 @@ dependencies = [ "bitflags 2.4.1", "bitvec", "c-kzg", - "derive_more", "enumn", "hashbrown 0.14.3", "hex", - "once_cell", "serde", ] From c3b6555aff4edd3ff66c84895adfe2b045c1b0af Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 14 Jan 2024 03:11:52 +0100 Subject: [PATCH 0472/1963] chore(deps): weekly `cargo update` (#6786) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-network v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-providers v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-pubsub v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-rpc-client v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-rpc-trace-types v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-rpc-types v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-transport v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-transport-http v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-transport-ipc v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating alloy-transport-ws v0.1.0 (https://github.com/alloy-rs/alloy#4db40b05) -> #44ddd61d Updating clap v4.4.15 -> v4.4.16 Updating clap_builder v4.4.15 -> v4.4.16 Updating js-sys v0.3.66 -> v0.3.67 Updating keccak v0.1.4 -> v0.1.5 Adding proc-macro-crate v3.0.0 Updating revm-inspectors v0.1.0 (https://github.com/paradigmxyz/evm-inspectors#5028bdbc) -> #29bb8540 Updating rustix v0.38.28 -> v0.38.30 Updating smallvec v1.11.2 -> v1.12.0 Updating vergen v8.2.6 -> v8.2.8 Updating wasm-bindgen v0.2.89 -> v0.2.90 Updating wasm-bindgen-backend v0.2.89 -> v0.2.90 Updating wasm-bindgen-futures v0.4.39 -> v0.4.40 Updating wasm-bindgen-macro v0.2.89 -> v0.2.90 Updating wasm-bindgen-macro-support v0.2.89 -> v0.2.90 Updating wasm-bindgen-shared v0.2.89 -> v0.2.90 Updating web-sys v0.3.66 -> v0.3.67 Co-authored-by: mattsse --- Cargo.lock | 96 +++++++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67f8a1acf5924..02bb79be5d207 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-primitives", "serde", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -184,7 +184,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-network", "alloy-primitives", @@ -203,7 +203,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -241,7 +241,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -258,21 +258,18 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-primitives", - "alloy-rlp", "alloy-rpc-types", - "itertools 0.12.0", "serde", "serde_json", - "thiserror", ] [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -327,7 +324,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -343,7 +340,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -356,7 +353,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -374,7 +371,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#4db40b051a1f2443b9c18fa0cf62d0ac24d07012" +source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1407,9 +1404,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.15" +version = "4.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c12ed66a79a555082f595f7eb980d08669de95009dd4b3d61168c573ebe38fc9" +checksum = "58e54881c004cec7895b0068a0a954cd5d62da01aef83fa35b1e594497bf5445" dependencies = [ "clap_builder", "clap_derive", @@ -1417,9 +1414,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.15" +version = "4.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4645eab3431e5a8403a96bea02506a8b35d28cd0f0330977dd5d22f9c84f43" +checksum = "59cb82d7f531603d2fd1f507441cdd35184fa81beff7bd489570de7f773460bb" dependencies = [ "anstream", "anstyle", @@ -4333,9 +4330,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] @@ -4381,9 +4378,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] @@ -4985,7 +4982,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5648,6 +5645,15 @@ dependencies = [ "toml_edit 0.20.7", ] +[[package]] +name = "proc-macro-crate" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" +dependencies = [ + "toml_edit 0.21.0", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -6059,7 +6065,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#5028bdbc01a3ead97f7ebf742afaf8d058bee2ae" +source = "git+https://github.com/paradigmxyz/evm-inspectors#29bb854055855daf84c5aac796681e3aae208895" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6364,9 +6370,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ "bitflags 2.4.1", "errno", @@ -6951,9 +6957,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "socket2" @@ -7922,9 +7928,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.6" +version = "8.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1290fd64cc4e7d3c9b07d7f333ce0ce0007253e32870e632624835cc80b83939" +checksum = "6cf9c2670809c4840d4648fc7daa396551d7d88966f9ba93821b81a5c0c2d3f5" dependencies = [ "anyhow", "git2", @@ -7980,9 +7986,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -7990,9 +7996,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", @@ -8005,9 +8011,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -8017,9 +8023,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -8027,9 +8033,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", @@ -8040,9 +8046,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "watchexec" @@ -8094,9 +8100,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", From bb35926e8a23824dda45e32c892b78419c597dba Mon Sep 17 00:00:00 2001 From: Andrew Tretyakov <42178850+0xAndoroid@users.noreply.github.com> Date: Sat, 13 Jan 2024 22:22:31 -0500 Subject: [PATCH 0473/1963] feat: `bytes` to base64 encoding in VM (#6785) * Base64 cheatcode * Removed `toBase64(string calldata data)` * Typo fix * Changed version of base64 * Fix failed tests * Replaced `string::parse` with `abi_encode()` --- Cargo.lock | 1 + Cargo.toml | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 40 +++++++++++++++++++ .../cheatcodes/assets/cheatcodes.schema.json | 7 ++++ crates/cheatcodes/spec/src/cheatcode.rs | 8 ++++ crates/cheatcodes/spec/src/vm.rs | 10 +++++ crates/cheatcodes/src/base64.rs | 17 ++++++++ crates/cheatcodes/src/lib.rs | 1 + testdata/cheats/Base64.t.sol | 24 +++++++++++ testdata/cheats/Vm.sol | 2 + 11 files changed, 112 insertions(+) create mode 100644 crates/cheatcodes/src/base64.rs create mode 100644 testdata/cheats/Base64.t.sol diff --git a/Cargo.lock b/Cargo.lock index 02bb79be5d207..0fde23ac095c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2928,6 +2928,7 @@ dependencies = [ "alloy-providers", "alloy-rpc-types", "alloy-sol-types", + "base64 0.21.7", "const-hex", "ethers-core", "ethers-signers", diff --git a/Cargo.toml b/Cargo.toml index 730355287dc3d..21acb389c2b54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,6 +178,7 @@ protobuf = "=3.2.0" rand = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } +base64 = "0.21" toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index bb000f5c3198d..7225111fed4de 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -34,5 +34,6 @@ itertools.workspace = true jsonpath_lib.workspace = true revm.workspace = true serde_json.workspace = true +base64.workspace = true tracing.workspace = true walkdir = "2" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 8b69d7e257ccc..fea491981bafa 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4533,6 +4533,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "toBase64", + "description": "Encodes a `bytes` value to base64 string", + "declaration": "function toBase64(bytes calldata data) external pure returns (string memory);", + "visibility": "external", + "mutability": "pure", + "signature": "toBase64(bytes)", + "selector": "0xa5cbfe65", + "selectorBytes": [ + 165, + 203, + 254, + 101 + ] + }, + "group": "base64", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toBase64URL", + "description": "Encodes a `bytes` value to base64url string", + "declaration": "function toBase64URL(bytes calldata data) external pure returns (string memory);", + "visibility": "external", + "mutability": "pure", + "signature": "toBase64URL(bytes)", + "selector": "0xc8bd0e4a", + "selectorBytes": [ + 200, + 189, + 14, + 74 + ] + }, + "group": "base64", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "toString_0", diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index 7b68420ad63bf..1231ec0458e60 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -298,6 +298,13 @@ "json" ] }, + { + "description": "Utility cheatcodes that deal with encoding and decoding Base64.\n\nExamples: `toBase64`, `toBase64URL`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "base64" + ] + }, { "description": "Generic, uncategorized utilities.\n\nExamples: `toString`, `parse*`, `serialize*`.\n\nSafety: safe.", "type": "string", diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index f7e0c87b306f2..e6ed724629fe6 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -103,6 +103,12 @@ pub enum Group { /// /// Safety: safe. Json, + /// Utility cheatcodes that deal with encoding and decoding Base64. + /// + /// Examples: `toBase64`, `toBase64URL`. + /// + /// Safety: safe. + Base64, /// Generic, uncategorized utilities. /// /// Examples: `toString`, `parse*`, `serialize*`. @@ -125,6 +131,7 @@ impl Group { Self::Environment | Self::String | Self::Json | + Self::Base64 | Self::Utilities => Some(Safety::Safe), } } @@ -140,6 +147,7 @@ impl Group { Self::Environment => "environment", Self::String => "string", Self::Json => "json", + Self::Base64 => "base64", Self::Utilities => "utilities", } } diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 1577e6189b849..819ddd41ceafd 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1228,6 +1228,16 @@ interface Vm { #[cheatcode(group = Json)] function writeJson(string calldata json, string calldata path, string calldata valueKey) external; + // -------- Base64 -------- + + /// Encodes a `bytes` value to base64 string + #[cheatcode(group = Base64)] + function toBase64(bytes calldata data) external pure returns (string memory); + + /// Encodes a `bytes` value to base64url string + #[cheatcode(group = Base64)] + function toBase64URL(bytes calldata data) external pure returns (string memory); + // -------- Key Management -------- /// Derives a private key from the name, labels the account with that name, and returns the wallet. diff --git a/crates/cheatcodes/src/base64.rs b/crates/cheatcodes/src/base64.rs new file mode 100644 index 0000000000000..d9d0bc86f76c2 --- /dev/null +++ b/crates/cheatcodes/src/base64.rs @@ -0,0 +1,17 @@ +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use alloy_sol_types::SolValue; +use base64::prelude::*; + +impl Cheatcode for toBase64Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { data } = self; + Ok(BASE64_STANDARD.encode(data).abi_encode()) + } +} + +impl Cheatcode for toBase64URLCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { data } = self; + Ok(BASE64_URL_SAFE.encode(data).abi_encode()) + } +} diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index b7a401c074a81..856467f2990d7 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -26,6 +26,7 @@ pub use config::CheatsConfig; mod inspector; pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; +mod base64; mod env; mod evm; mod fs; diff --git a/testdata/cheats/Base64.t.sol b/testdata/cheats/Base64.t.sol new file mode 100644 index 0000000000000..88b792cb2991f --- /dev/null +++ b/testdata/cheats/Base64.t.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; +import "../logs/console.sol"; + +contract Base64Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_toBase64() public { + bytes memory input = hex"00112233445566778899aabbccddeeff"; + string memory expected = "ABEiM0RVZneImaq7zN3u/w=="; + string memory actual = vm.toBase64(input); + assertEq(actual, expected); + } + + function test_toBase64URL() public { + bytes memory input = hex"00112233445566778899aabbccddeeff"; + string memory expected = "ABEiM0RVZneImaq7zN3u_w=="; + string memory actual = vm.toBase64URL(input); + assertEq(actual, expected); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index cc9a1aa8ab220..86afd8d06d2b6 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -224,6 +224,8 @@ interface Vm { function stopMappingRecording() external; function stopPrank() external; function store(address target, bytes32 slot, bytes32 value) external; + function toBase64(bytes calldata data) external pure returns (string memory); + function toBase64URL(bytes calldata data) external pure returns (string memory); function toString(address value) external pure returns (string memory stringifiedValue); function toString(bytes calldata value) external pure returns (string memory stringifiedValue); function toString(bytes32 value) external pure returns (string memory stringifiedValue); From c367a789e4bae61bba3d1177bfe8d00c4047ffea Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 14 Jan 2024 11:22:00 +0100 Subject: [PATCH 0474/1963] fmt: restore whitespace in fuzz files (#6788) --- crates/evm/fuzz/src/strategies/int.rs | 18 +++++++++++++++++- crates/evm/fuzz/src/strategies/uint.rs | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/evm/fuzz/src/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs index 5c95235f2a3a7..e92c2d4642ca3 100644 --- a/crates/evm/fuzz/src/strategies/int.rs +++ b/crates/evm/fuzz/src/strategies/int.rs @@ -17,6 +17,7 @@ pub struct IntValueTree { /// If true cannot be simplified or complexified fixed: bool, } + impl IntValueTree { /// Create a new tree /// # Arguments @@ -37,6 +38,7 @@ impl IntValueTree { true } } + fn magnitude_greater(lhs: I256, rhs: I256) -> bool { if lhs.is_zero() { return false @@ -44,11 +46,14 @@ impl IntValueTree { (lhs > rhs) ^ (lhs.is_negative()) } } + impl ValueTree for IntValueTree { type Value = I256; + fn current(&self) -> Self::Value { self.curr } + fn simplify(&mut self) -> bool { if self.fixed || !IntValueTree::magnitude_greater(self.hi, self.lo) { return false @@ -56,6 +61,7 @@ impl ValueTree for IntValueTree { self.hi = self.curr; self.reposition() } + fn complicate(&mut self) -> bool { if self.fixed || !IntValueTree::magnitude_greater(self.hi, self.lo) { return false @@ -66,6 +72,7 @@ impl ValueTree for IntValueTree { self.reposition() } } + /// Value tree for signed ints (up to int256). /// The strategy combines 3 different strategies, each assigned a specific weight: /// 1. Generate purely random value in a range. This will first choose bit size uniformly (up `bits` @@ -85,6 +92,7 @@ pub struct IntStrategy { /// The weight for purely random values random_weight: usize, } + impl IntStrategy { /// Create a new strategy. /// #Arguments @@ -99,6 +107,7 @@ impl IntStrategy { random_weight: 50usize, } } + fn generate_edge_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); @@ -117,6 +126,7 @@ impl IntStrategy { }; Ok(IntValueTree::new(start, false)) } + fn generate_fixtures_tree(&self, runner: &mut TestRunner) -> NewTree { // generate edge cases if there's no fixtures if self.fixtures.is_empty() { @@ -125,8 +135,10 @@ impl IntStrategy { let idx = runner.rng().gen_range(0..self.fixtures.len()); Ok(IntValueTree::new(self.fixtures[idx], false)) } + fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); + // generate random number of bits uniformly let bits = rng.gen_range(0..=self.bits); @@ -137,6 +149,7 @@ impl IntStrategy { // init 2 128-bit randoms let mut higher: u128 = rng.gen_range(0..=u128::MAX); let mut lower: u128 = rng.gen_range(0..=u128::MAX); + // cut 2 randoms according to bits size match bits - 1 { x if x < 128 => { @@ -154,17 +167,20 @@ impl IntStrategy { inner[1] = (lower >> 64) as u64; inner[2] = (higher & mask64) as u64; inner[3] = (higher >> 64) as u64; - let sign = if rng.gen_bool(0.5) { Sign::Positive } else { Sign::Negative }; + // we have a small bias here, i.e. intN::min will never be generated // but it's ok since it's generated in `fn generate_edge_tree(...)` + let sign = if rng.gen_bool(0.5) { Sign::Positive } else { Sign::Negative }; let (start, _) = I256::overflowing_from_sign_and_abs(sign, U256::from_limbs(inner)); Ok(IntValueTree::new(start, false)) } } + impl Strategy for IntStrategy { type Tree = IntValueTree; type Value = I256; + fn new_tree(&self, runner: &mut TestRunner) -> NewTree { let total_weight = self.random_weight + self.fixtures_weight + self.edge_weight; let bias = runner.rng().gen_range(0..total_weight); diff --git a/crates/evm/fuzz/src/strategies/uint.rs b/crates/evm/fuzz/src/strategies/uint.rs index 5f53d838754aa..e1d74552612e9 100644 --- a/crates/evm/fuzz/src/strategies/uint.rs +++ b/crates/evm/fuzz/src/strategies/uint.rs @@ -17,6 +17,7 @@ pub struct UintValueTree { /// If true cannot be simplified or complexified fixed: bool, } + impl UintValueTree { /// Create a new tree /// # Arguments @@ -38,11 +39,14 @@ impl UintValueTree { } } } + impl ValueTree for UintValueTree { type Value = U256; + fn current(&self) -> Self::Value { self.curr } + fn simplify(&mut self) -> bool { if self.fixed || (self.hi <= self.lo) { return false @@ -50,6 +54,7 @@ impl ValueTree for UintValueTree { self.hi = self.curr; self.reposition() } + fn complicate(&mut self) -> bool { if self.fixed || (self.hi <= self.lo) { return false @@ -59,6 +64,7 @@ impl ValueTree for UintValueTree { self.reposition() } } + /// Value tree for unsigned ints (up to uint256). /// The strategy combines 3 different strategies, each assigned a specific weight: /// 1. Generate purely random value in a range. This will first choose bit size uniformly (up `bits` @@ -78,6 +84,7 @@ pub struct UintStrategy { /// The weight for purely random values random_weight: usize, } + impl UintStrategy { /// Create a new strategy. /// #Arguments @@ -92,6 +99,7 @@ impl UintStrategy { random_weight: 50usize, } } + fn generate_edge_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); // Choose if we want values around 0 or max @@ -102,6 +110,7 @@ impl UintStrategy { let start = if is_min { offset } else { max.saturating_sub(offset) }; Ok(UintValueTree::new(start, false)) } + fn generate_fixtures_tree(&self, runner: &mut TestRunner) -> NewTree { // generate edge cases if there's no fixtures if self.fixtures.is_empty() { @@ -110,13 +119,17 @@ impl UintStrategy { let idx = runner.rng().gen_range(0..self.fixtures.len()); Ok(UintValueTree::new(self.fixtures[idx], false)) } + fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree { let rng = runner.rng(); + // generate random number of bits uniformly let bits = rng.gen_range(0..=self.bits); + // init 2 128-bit randoms let mut higher: u128 = rng.gen_range(0..=u128::MAX); let mut lower: u128 = rng.gen_range(0..=u128::MAX); + // cut 2 randoms according to bits size match bits { x if x < 128 => { @@ -126,6 +139,7 @@ impl UintStrategy { x if (128..256).contains(&x) => higher &= (1u128 << (x - 128)) - 1, _ => {} }; + // init U256 from 2 randoms let mut inner: [u64; 4] = [0; 4]; let mask64 = (1 << 65) - 1; @@ -138,6 +152,7 @@ impl UintStrategy { Ok(UintValueTree::new(start, false)) } } + impl Strategy for UintStrategy { type Tree = UintValueTree; type Value = U256; From c5fd67bc85b10d18c9b5d195337d750b9dbbca65 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 14 Jan 2024 11:22:31 +0100 Subject: [PATCH 0475/1963] chore: don't use ethers in evm-core (#6787) --- Cargo.lock | 3 +-- crates/evm/core/Cargo.toml | 2 +- crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/fork/multi.rs | 3 +-- crates/evm/core/src/opts.rs | 2 +- crates/evm/core/src/utils.rs | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fde23ac095c2..8ce6db782467b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2437,7 +2437,6 @@ source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a68 dependencies = [ "chrono", "ethers-core", - "ethers-solc", "reqwest", "semver 1.0.21", "serde", @@ -3180,8 +3179,8 @@ dependencies = [ "alloy-transport", "const-hex", "derive_more", - "ethers", "ethers-core", + "ethers-providers", "eyre", "foundry-cheatcodes-spec", "foundry-common", diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 3671e08e36b85..62b59a1f61563 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -34,9 +34,9 @@ revm = { workspace = true, default-features = false, features = [ alloy-providers = { workspace = true } alloy-transport = { workspace = true } alloy-rpc-types = { workspace = true } -ethers = { workspace = true, features = ["ethers-solc"] } ethers-core.workspace = true +ethers-providers.workspace = true derive_more.workspace = true eyre = "0.6" diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 771ba7b3d57c9..76a78fb6e10fd 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -8,7 +8,7 @@ use crate::{ }; use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; -use ethers::utils::GenesisAccount; +use ethers_core::utils::GenesisAccount; use foundry_common::{is_known_system_sender, types::ToAlloy, SYSTEM_TRANSACTION_TYPE}; use revm::{ db::{CacheDB, DatabaseRef}, diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 5aa7261bd4406..acf5095471868 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -6,9 +6,8 @@ use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; use alloy_providers::provider::Provider; use alloy_transport::BoxTransport; -use ethers::types::BlockNumber; +use ethers_core::types::BlockNumber; use foundry_common::provider::alloy::ProviderBuilder; - use foundry_config::Config; use futures::{ channel::mpsc::{channel, Receiver, Sender}, diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 14b3e2cfcf33e..7eceb7c5afa21 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -2,7 +2,7 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types::Block; -use ethers::providers::{Middleware, Provider}; +use ethers_providers::{Middleware, Provider}; use eyre::WrapErr; use foundry_common::{ self, diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 55ec9a15bdf7d..778b9ba13cdd3 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,7 +1,7 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::FixedBytes; use alloy_rpc_types::{Block, Transaction}; -use ethers::types::{ActionType, CallType, Chain, H256, U256}; +use ethers_core::types::{ActionType, CallType, Chain, H256, U256}; use eyre::ContextCompat; use foundry_common::types::ToAlloy; use revm::{ From 95e8385da5937bcb081908d0d7d354ccf992c5bb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 15 Jan 2024 14:34:46 +0100 Subject: [PATCH 0476/1963] test: add arbitrum fork test (#6800) --- crates/anvil/src/eth/backend/fork.rs | 2 ++ crates/anvil/tests/it/fork.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 029b92f167c20..34a67fcf1a0db 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -594,7 +594,9 @@ impl ClientFork { #[derive(Clone, Debug)] pub struct ClientForkConfig { pub eth_rpc_url: String, + /// The block number of the forked block pub block_number: u64, + /// The hash of the forked block pub block_hash: B256, // TODO make provider agnostic pub provider: Arc, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 871f629f0c894..987bc05041d5a 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1092,3 +1092,21 @@ async fn test_fork_reset_basefee() { // basefee of the forked block: assert_eq!(latest.header.base_fee_per_gas.unwrap(), rU256::from(59017001138u64)); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_arbitrum_fork_dev_balance() { + let (api, handle) = spawn( + fork_config() + .with_fork_block_number(None::) + .with_eth_rpc_url(Some("https://arb1.arbitrum.io/rpc".to_string())), + ) + .await; + + let accounts: Vec<_> = handle.dev_wallets().collect(); + for acc in accounts { + let balance = + api.balance(acc.address().to_alloy(), Some(Default::default())).await.unwrap(); + assert_eq!(balance, rU256::from(100000000000000000000u128)); + } +} From 34d51ff3066b0908a31de2d3b3b87c2802fe51f1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 15 Jan 2024 15:33:43 +0100 Subject: [PATCH 0477/1963] chore: use is_zero fn (#6802) --- crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/eth/fees.rs | 2 +- crates/evm/core/src/fork/cache.rs | 2 +- crates/evm/traces/src/lib.rs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index a814258d54697..2bf44a3a35c9a 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1562,7 +1562,7 @@ impl EthApi { node_info!("anvil_mine"); let interval = interval.map(|i| i.to::()); let blocks = num_blocks.unwrap_or(U256::from(1)); - if blocks == U256::ZERO { + if blocks.is_zero() { return Ok(()); } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 8af81395a726d..81395f40d0504 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -881,7 +881,7 @@ impl Backend { let mut env = self.env.read().clone(); - if env.block.basefee == revm::primitives::U256::ZERO { + if env.block.basefee.is_zero() { // this is an edge case because the evm fails if `tx.effective_gas_price < base_fee` // 0 is only possible if it's manually set env.cfg.disable_base_fee = true; diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 685119456abc1..1b8680981916e 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -126,7 +126,7 @@ impl FeeManager { // It's naturally impossible for base fee to be 0; // It means it was set by the user deliberately and therefore we treat it as a constant. // Therefore, we skip the base fee calculation altogether and we return 0. - if self.base_fee() == U256::ZERO { + if self.base_fee().is_zero() { return 0 } calculate_next_block_base_fee( diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index 60d4cbd7276c0..607eced688945 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -301,7 +301,7 @@ impl MemDb { acc_storage.clear(); } for (index, value) in acc.storage { - if value.present_value() == U256::from(0) { + if value.present_value().is_zero() { acc_storage.remove(&index); } else { acc_storage.insert(index, value.present_value()); diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 4ee5dbd54a9aa..7ad2f6bf09752 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -7,7 +7,7 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{LogData, U256}; +use alloy_primitives::LogData; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CHEATCODE_ADDRESS; use futures::{future::BoxFuture, FutureExt}; @@ -200,7 +200,7 @@ pub async fn render_trace( "{addr}::{func_name}{opt_value}({inputs}){action}", addr = color.paint(decoded.label.as_deref().unwrap_or(&address)), func_name = color.paint(func_name), - opt_value = if trace.value == U256::ZERO { + opt_value = if trace.value.is_zero() { String::new() } else { format!("{{value: {}}}", trace.value) From 7c9507b643bd5504d770bde20a0cb3703a19245c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 15 Jan 2024 15:53:34 +0100 Subject: [PATCH 0478/1963] fix: respect --offline in etherscan identifier (#6801) --- crates/evm/traces/src/identifier/etherscan.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index e6e566cc8a4d1..cb6952ab50dd9 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -41,6 +41,10 @@ pub struct EtherscanIdentifier { impl EtherscanIdentifier { /// Creates a new Etherscan identifier with the given client pub fn new(config: &Config, chain: Option) -> eyre::Result { + if config.offline { + // offline mode, don't use etherscan + return Ok(Default::default()) + } if let Some(config) = config.get_etherscan_config_with_chain(chain)? { trace!(target: "etherscanidentifier", chain=?config.chain, url=?config.api_url, "using etherscan identifier"); Ok(Self { From 54cd6a4c773c358b0f4f5ac22861039a2b8d07ff Mon Sep 17 00:00:00 2001 From: galois Date: Tue, 16 Jan 2024 00:44:42 +0800 Subject: [PATCH 0479/1963] feat(cast): support `cast wallet derive-private-key` (#6774) * feat: support `cast wallet get-private-key` * chore: use `derive` instead of `get` * style: fix cargo fmt * style: fix cargo fmt --- crates/cast/bin/cmd/wallet/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 9a1253d42deeb..c38826ce152a2 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -138,6 +138,9 @@ pub enum WalletSubcommands { /// List all the accounts in the keystore default directory #[clap(visible_alias = "ls")] List, + + #[clap(name = "derive-private-key", visible_aliases = &["--derive-private-key"])] + DerivePrivateKey { mnemonic: String, mnemonic_index: Option }, } impl WalletSubcommands { @@ -353,6 +356,19 @@ flag to set your key via: Err(e) => return Err(e), } } + WalletSubcommands::DerivePrivateKey { mnemonic, mnemonic_index } => { + let phrase = Mnemonic::::new_from_phrase(mnemonic.as_str())?.to_phrase(); + let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); + let derivation_path = "m/44'/60'/0'/0/"; + let index = if let Some(i) = mnemonic_index { i } else { 0 }; + let wallet = builder + .clone() + .derivation_path(&format!("{derivation_path}{index}"))? + .build()?; + println!("- Account:"); + println!("Address: {}", wallet.address().to_alloy()); + println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); + } }; Ok(()) From fbd8c3467fb98acf4a3153d9c4ab4ae09d70eceb Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 15 Jan 2024 13:49:54 -0400 Subject: [PATCH 0480/1963] chore(`anvil`): Add base alloy types (#6778) * chore: typedtx skeleton * feat: add all alloy tx types * chore: add op deposit tx support * chore: add block type * feat: proof type * chore: fix test * docs * chore: move optimism types to their own file * chore: more docs --- Cargo.lock | 52 +- Cargo.toml | 8 +- crates/anvil/core/Cargo.toml | 4 + crates/anvil/core/src/eth/alloy_block.rs | 271 +++++ crates/anvil/core/src/eth/alloy_proof.rs | 25 + crates/anvil/core/src/eth/mod.rs | 2 + .../anvil/core/src/eth/transaction/alloy.rs | 1073 +++++++++++++++++ crates/anvil/core/src/eth/transaction/mod.rs | 7 +- .../core/src/eth/transaction/optimism.rs | 179 +++ crates/anvil/core/src/eth/utils.rs | 8 + 10 files changed, 1608 insertions(+), 21 deletions(-) create mode 100644 crates/anvil/core/src/eth/alloy_block.rs create mode 100644 crates/anvil/core/src/eth/alloy_proof.rs create mode 100644 crates/anvil/core/src/eth/transaction/alloy.rs create mode 100644 crates/anvil/core/src/eth/transaction/optimism.rs diff --git a/Cargo.lock b/Cargo.lock index 8ce6db782467b..ecafc175ce6f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,6 +87,17 @@ dependencies = [ "strum", ] +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +dependencies = [ + "alloy-eips", + "alloy-network", + "alloy-primitives", + "alloy-rlp", +] + [[package]] name = "alloy-dyn-abi" version = "0.6.0" @@ -111,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -134,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-primitives", "serde", @@ -145,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -184,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-network", "alloy-primitives", @@ -203,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -241,7 +252,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -258,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -269,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -324,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -340,7 +351,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -353,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -371,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#44ddd61de3f4c7d6c6a021c65af5de25ad9871dd" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -526,7 +537,11 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-network", "alloy-primitives", + "alloy-rlp", "alloy-rpc-trace-types", "alloy-rpc-types", "anvil-core", @@ -3717,9 +3732,9 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e1127ede0475b58f4fe9c0aaa0d9bb0bad2af90bbd93ccd307c8632b863d89" +checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" [[package]] name = "gix-utils" @@ -7928,9 +7943,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.8" +version = "8.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cf9c2670809c4840d4648fc7daa396551d7d88966f9ba93821b81a5c0c2d3f5" +checksum = "03c7b513a7d40506d5a07f186a298821cc9ec2cc22088a3593f7b612a66659f6" dependencies = [ "anyhow", "git2", @@ -8536,3 +8551,8 @@ dependencies = [ "cc", "pkg-config", ] + +[[patch.unused]] +name = "alloy-signer" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" diff --git a/Cargo.toml b/Cargo.toml index 21acb389c2b54..cac488bd48f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -145,12 +145,14 @@ ethers-solc = { version = "2.0", default-features = false } ## alloy alloy-consensus = "0.1.0" +alloy-network = "0.1.0" alloy-json-rpc = "0.1.0" alloy-providers = "0.1.0" alloy-pubsub = "0.1.0" alloy-rpc-client = "0.1.0" alloy-rpc-trace-types = "0.1.0" alloy-rpc-types = "0.1.0" +alloy-eips = "0.1.0" alloy-transport = "0.1.0" alloy-transport-http = "0.1.0" alloy-transport-ipc = "0.1.0" @@ -211,14 +213,16 @@ ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194 ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -# alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } +alloy-network = { git = "https://github.com/alloy-rs/alloy" } alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" } alloy-providers = { git = "https://github.com/alloy-rs/alloy" } alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } -# alloy-signer = { git = "https://github.com/alloy-rs/alloy" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy" } alloy-transport = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 1a69cd012a878..9fb87785cbca5 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -17,6 +17,10 @@ revm = { workspace = true, default-features = false, features = ["std", "serde", alloy-primitives = { workspace = true, features = ["serde"] } alloy-rpc-types = { workspace = true } alloy-rpc-trace-types.workspace = true +alloy-rlp.workspace = true +alloy-eips.workspace = true +alloy-network = { workspace = true, features = ["k256"] } +alloy-consensus.workspace = true ethers-core = { workspace = true, features = ["optimism"] } # theses are not used by anvil-core, but are required by ethers, because pulled in via foundry-common ethers-contract = { workspace = true, features = ["optimism"] } diff --git a/crates/anvil/core/src/eth/alloy_block.rs b/crates/anvil/core/src/eth/alloy_block.rs new file mode 100644 index 0000000000000..44536f8862584 --- /dev/null +++ b/crates/anvil/core/src/eth/alloy_block.rs @@ -0,0 +1,271 @@ +use super::trie; +use alloy_consensus::Header; +use alloy_primitives::{Address, Bloom, Bytes, B256, U256}; +use alloy_rlp::{RlpDecodable, RlpEncodable}; +use foundry_common::types::ToAlloy; + +// Type alias to optionally support impersonated transactions +#[cfg(not(feature = "impersonated-tx"))] +type Transaction = crate::eth::transaction::alloy::TypedTransaction; +#[cfg(feature = "impersonated-tx")] +type Transaction = crate::eth::transaction::alloy::MaybeImpersonatedTransaction; + +/// An Ethereum Block +#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable)] +pub struct Block { + pub header: Header, + pub transactions: Vec, + pub ommers: Vec
, +} + +impl Block { + /// Creates a new block + /// + /// Note: if the `impersonate-tx` feature is enabled this will also accept + /// [MaybeImpersonatedTransaction] + pub fn new( + partial_header: PartialHeader, + transactions: impl IntoIterator, + ommers: Vec
, + ) -> Self + where + T: Into, + { + let transactions: Vec<_> = transactions.into_iter().map(Into::into).collect(); + let mut encoded_ommers: Vec = Vec::new(); + alloy_rlp::encode_list(&ommers, &mut encoded_ommers); + let ommers_hash = + B256::from_slice(alloy_primitives::utils::keccak256(encoded_ommers).as_slice()); + let transactions_root = + trie::ordered_trie_root(transactions.iter().map(|r| Bytes::from(alloy_rlp::encode(r)))) + .to_alloy(); + + Self { + header: Header { + parent_hash: partial_header.parent_hash, + beneficiary: partial_header.beneficiary, + ommers_hash, + state_root: partial_header.state_root, + transactions_root, + receipts_root: partial_header.receipts_root, + logs_bloom: partial_header.logs_bloom, + difficulty: partial_header.difficulty, + number: partial_header.number, + gas_limit: partial_header.gas_limit, + gas_used: partial_header.gas_used, + timestamp: partial_header.timestamp, + extra_data: partial_header.extra_data, + mix_hash: partial_header.mix_hash, + withdrawals_root: Some(partial_header.mix_hash), + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + nonce: partial_header.nonce, + base_fee_per_gas: partial_header.base_fee, + }, + transactions, + ommers, + } + } +} + +/// Partial header definition without ommers hash and transactions root +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct PartialHeader { + pub parent_hash: B256, + pub beneficiary: Address, + pub state_root: B256, + pub receipts_root: B256, + pub logs_bloom: Bloom, + pub difficulty: U256, + pub number: u64, + pub gas_limit: u64, + pub gas_used: u64, + pub timestamp: u64, + pub extra_data: Bytes, + pub mix_hash: B256, + pub nonce: u64, + pub base_fee: Option, +} + +impl From
for PartialHeader { + fn from(value: Header) -> Self { + Self { + parent_hash: value.parent_hash, + beneficiary: value.beneficiary, + state_root: value.state_root, + receipts_root: value.receipts_root, + logs_bloom: value.logs_bloom, + difficulty: value.difficulty, + number: value.number, + gas_limit: value.gas_limit, + gas_used: value.gas_used, + timestamp: value.timestamp, + extra_data: value.extra_data, + mix_hash: value.mix_hash, + nonce: value.nonce, + base_fee: value.base_fee_per_gas, + } + } +} + +#[cfg(test)] +mod tests { + use alloy_network::Sealable; + use alloy_primitives::{ + b256, + hex::{self, FromHex}, + }; + use alloy_rlp::Decodable; + + use super::*; + use std::str::FromStr; + + #[test] + fn header_rlp_roundtrip() { + let mut header = Header { + parent_hash: Default::default(), + ommers_hash: Default::default(), + beneficiary: Default::default(), + state_root: Default::default(), + transactions_root: Default::default(), + receipts_root: Default::default(), + logs_bloom: Default::default(), + difficulty: Default::default(), + number: 124u64, + gas_limit: Default::default(), + gas_used: 1337u64, + timestamp: 0, + extra_data: Default::default(), + mix_hash: Default::default(), + nonce: 99u64, + withdrawals_root: Default::default(), + blob_gas_used: Default::default(), + excess_blob_gas: Default::default(), + parent_beacon_block_root: Default::default(), + base_fee_per_gas: None, + }; + + let encoded = alloy_rlp::encode(&header); + let decoded: Header =
::decode(&mut encoded.as_ref()).unwrap(); + assert_eq!(header, decoded); + + header.base_fee_per_gas = Some(12345u64); + + let encoded = alloy_rlp::encode(&header); + let decoded: Header =
::decode(&mut encoded.as_ref()).unwrap(); + assert_eq!(header, decoded); + } + + #[test] + fn test_encode_block_header() { + use alloy_rlp::Encodable; + + let expected = hex::decode("f901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000").unwrap(); + let mut data = vec![]; + let header = Header { + parent_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + ommers_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + beneficiary: Address::from_str("0000000000000000000000000000000000000000").unwrap(), + state_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + transactions_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + receipts_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), + difficulty: U256::from(2222), + number: 0xd05u64, + gas_limit: 0x115cu64, + gas_used: 0x15b3u64, + timestamp: 0x1a0au64, + extra_data: hex::decode("7788").unwrap().into(), + mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + withdrawals_root: None, + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + nonce: 0, + base_fee_per_gas: None, + }; + + header.encode(&mut data); + assert_eq!(hex::encode(&data), hex::encode(expected)); + assert_eq!(header.length(), data.len()); + } + + #[test] + // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 + fn test_decode_block_header() { + let data = hex::decode("f901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000").unwrap(); + let expected = Header { + parent_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + ommers_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + beneficiary: Address::from_str("0000000000000000000000000000000000000000").unwrap(), + state_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + transactions_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + receipts_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), + difficulty: U256::from(2222), + number: 0xd05u64, + gas_limit: 0x115cu64, + gas_used: 0x15b3u64, + timestamp: 0x1a0au64, + extra_data: hex::decode("7788").unwrap().into(), + mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + nonce: 0, + withdrawals_root: None, + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + base_fee_per_gas: None, + }; + let header =
::decode(&mut data.as_slice()).unwrap(); + assert_eq!(header, expected); + } + + #[test] + // Test vector from: https://github.com/ethereum/tests/blob/f47bbef4da376a49c8fc3166f09ab8a6d182f765/BlockchainTests/ValidBlocks/bcEIP1559/baseFee.json#L15-L36 + fn test_eip1559_block_header_hash() { + let expected_hash = + b256!("6a251c7c3c5dca7b42407a3752ff48f3bbca1fab7f9868371d9918daf1988d1f"); + let header = Header { + parent_hash: B256::from_str("e0a94a7a3c9617401586b1a27025d2d9671332d22d540e0af72b069170380f2a").unwrap(), + ommers_hash: B256::from_str("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347").unwrap(), + beneficiary: Address::from_str("ba5e000000000000000000000000000000000000").unwrap(), + state_root: B256::from_str("ec3c94b18b8a1cff7d60f8d258ec723312932928626b4c9355eb4ab3568ec7f7").unwrap(), + transactions_root: B256::from_str("50f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accf").unwrap(), + receipts_root: B256::from_str("29b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9").unwrap(), + logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), + difficulty: U256::from(0x020000), + number: 1u64, + gas_limit: U256::from(0x016345785d8a0000u128).to::(), + gas_used: U256::from(0x015534).to::(), + timestamp: 0x079e, + extra_data: hex::decode("42").unwrap().into(), + mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + nonce: 0, + base_fee_per_gas: Some(875), + withdrawals_root: None, + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + }; + assert_eq!(header.hash(), expected_hash); + } + + #[test] + // Test vector from network + fn block_network_roundtrip() { + use alloy_rlp::Encodable; + + let data = hex::decode("f9034df90348a0fbdbd8d2d0ac5f14bd5fa90e547fe6f1d15019c724f8e7b60972d381cd5d9cf8a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794c9577e7945db22e38fc060909f2278c7746b0f9ba05017cfa3b0247e35197215ae8d610265ffebc8edca8ea66d6567eb0adecda867a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018355bb7b871fffffffffffff808462bd0e1ab9014bf90148a00000000000000000000000000000000000000000000000000000000000000000f85494319fa8f1bc4e53410e92d10d918659b16540e60a945a573efb304d04c1224cd012313e827eca5dce5d94a9c831c5a268031176ebf5f3de5051e8cba0dbfe94c9577e7945db22e38fc060909f2278c7746b0f9b808400000000f8c9b841a6946f2d16f68338cbcbd8b117374ab421128ce422467088456bceba9d70c34106128e6d4564659cf6776c08a4186063c0a05f7cffd695c10cf26a6f301b67f800b8412b782100c18c35102dc0a37ece1a152544f04ad7dc1868d18a9570f744ace60870f822f53d35e89a2ea9709ccbf1f4a25ee5003944faa845d02dde0a41d5704601b841d53caebd6c8a82456e85c2806a9e08381f959a31fb94a77e58f00e38ad97b2e0355b8519ab2122662cbe022f2a4ef7ff16adc0b2d5dcd123181ec79705116db300a063746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365880000000000000000c0c0").unwrap(); + + let block = ::decode(&mut data.as_slice()).unwrap(); + + // encode and check that it matches the original data + let mut encoded = Vec::new(); + block.encode(&mut encoded); + assert_eq!(data, encoded); + + // check that length of encoding is the same as the output of `length` + assert_eq!(block.length(), encoded.len()); + } +} diff --git a/crates/anvil/core/src/eth/alloy_proof.rs b/crates/anvil/core/src/eth/alloy_proof.rs new file mode 100644 index 0000000000000..adef84ae93ef6 --- /dev/null +++ b/crates/anvil/core/src/eth/alloy_proof.rs @@ -0,0 +1,25 @@ +//! Return types for `eth_getProof` + +use crate::eth::trie::KECCAK_NULL_RLP; +use alloy_primitives::{B256, U256}; +use foundry_common::types::ToAlloy; +use revm::primitives::KECCAK_EMPTY; + +#[derive(Clone, Debug, PartialEq, Eq, alloy_rlp::RlpEncodable, alloy_rlp::RlpDecodable)] +pub struct BasicAccount { + pub nonce: U256, + pub balance: U256, + pub storage_root: B256, + pub code_hash: B256, +} + +impl Default for BasicAccount { + fn default() -> Self { + BasicAccount { + balance: U256::ZERO, + nonce: U256::ZERO, + code_hash: KECCAK_EMPTY, + storage_root: KECCAK_NULL_RLP.to_alloy(), + } + } +} diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index e6fb8789fcd79..799c6ff6b3591 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -11,6 +11,8 @@ use alloy_rpc_types::{ }; use ethers_core::types::transaction::eip712::TypedData; +pub mod alloy_block; +pub mod alloy_proof; pub mod block; pub mod proof; pub mod receipt; diff --git a/crates/anvil/core/src/eth/transaction/alloy.rs b/crates/anvil/core/src/eth/transaction/alloy.rs new file mode 100644 index 0000000000000..d0608fc5f33d2 --- /dev/null +++ b/crates/anvil/core/src/eth/transaction/alloy.rs @@ -0,0 +1,1073 @@ +use crate::eth::{ + transaction::optimism::{DepositTransaction, DepositTransactionRequest}, + utils::eip_to_revm_access_list, +}; +use alloy_consensus::{ReceiptWithBloom, TxEip1559, TxEip2930, TxLegacy}; +use alloy_network::{Signed, Transaction, TxKind}; +use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, B256, U256}; +use alloy_rlp::{Decodable, Encodable}; +use alloy_rpc_types::{request::TransactionRequest, AccessList, CallRequest}; +use foundry_evm::traces::CallTraceNode; +use revm::{ + interpreter::InstructionResult, + primitives::{CreateScheme, OptimismFields, TransactTo, TxEnv}, +}; +use std::ops::Deref; + +/// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC +#[cfg(feature = "impersonated-tx")] +pub fn impersonated_signature() -> Signature { + Signature::from_scalars_and_parity(B256::ZERO, B256::ZERO, false).unwrap() +} + +pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { + let TransactionRequest { + from, + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + gas, + value, + data, + nonce, + mut access_list, + transaction_type, + other, + .. + } = tx; + let transaction_type = transaction_type.map(|id| id.to::()); + + // Special case: OP-stack deposit tx + if transaction_type == Some(126) { + return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { + from: from.unwrap_or_default(), + source_hash: other.get_deserialized::("sourceHash")?.ok()?, + kind: TxKind::Create, + mint: other.get_deserialized::("mint")?.ok()?, + value: value.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), + is_system_tx: other.get_deserialized::("isSystemTx")?.ok()?, + input: data.unwrap_or_default(), + })) + } + + match ( + transaction_type, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + access_list.take(), + ) { + // legacy transaction + (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { + Some(TypedTransactionRequest::Legacy(TxLegacy { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data.unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: None, + })) + } + // EIP2930 + (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { + Some(TypedTransactionRequest::EIP2930(TxEip2930 { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data.unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: 0, + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) + } + // EIP1559 + (Some(2), None, _, _, _) | + (None, None, Some(_), _, _) | + (None, None, _, Some(_), _) | + (None, None, None, None, None) => { + // Empty fields fall back to the canonical transaction schema. + Some(TypedTransactionRequest::EIP1559(TxEip1559 { + nonce: nonce.unwrap_or_default().to::(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data.unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: 0, + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) + } + _ => None, + } +} + +pub fn call_request_to_typed(tx: CallRequest) -> Option { + let CallRequest { + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + gas, + value, + input, + chain_id, + nonce, + mut access_list, + transaction_type, + .. + } = tx; + let chain_id = chain_id.map(|id| id.to::()); + let transaction_type = transaction_type.map(|id| id.to::()); + + match ( + transaction_type, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + access_list.take(), + ) { + // legacy transaction + (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { + Some(TypedTransactionRequest::Legacy(TxLegacy { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id, + })) + } + // EIP2930 + (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { + Some(TypedTransactionRequest::EIP2930(TxEip2930 { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: chain_id.unwrap_or_default(), + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) + } + // EIP1559 + (Some(2), None, _, _, _) | + (None, None, Some(_), _, _) | + (None, None, _, Some(_), _) | + (None, None, None, None, None) => { + // Empty fields fall back to the canonical transaction schema. + Some(TypedTransactionRequest::EIP1559(TxEip1559 { + nonce: nonce.unwrap_or_default().to::(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: chain_id.unwrap_or_default(), + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) + } + _ => None, + } +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum TypedTransactionRequest { + Legacy(TxLegacy), + EIP2930(TxEip2930), + EIP1559(TxEip1559), + Deposit(DepositTransactionRequest), +} + +/// A wrapper for [TypedTransaction] that allows impersonating accounts. +/// +/// This is a helper that carries the `impersonated` sender so that the right hash +/// [TypedTransaction::impersonated_hash] can be created. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MaybeImpersonatedTransaction { + pub transaction: TypedTransaction, + pub impersonated_sender: Option
, +} + +impl MaybeImpersonatedTransaction { + /// Creates a new wrapper for the given transaction + pub fn new(transaction: TypedTransaction) -> Self { + Self { transaction, impersonated_sender: None } + } + + /// Creates a new impersonated transaction wrapper using the given sender + pub fn impersonated(transaction: TypedTransaction, impersonated_sender: Address) -> Self { + Self { transaction, impersonated_sender: Some(impersonated_sender) } + } + + /// Recovers the Ethereum address which was used to sign the transaction. + /// + /// Note: this is feature gated so it does not conflict with the `Deref`ed + /// [TypedTransaction::recover] function by default. + #[cfg(feature = "impersonated-tx")] + pub fn recover(&self) -> Result { + if let Some(sender) = self.impersonated_sender { + return Ok(sender) + } + self.transaction.recover() + } + + /// Returns the hash of the transaction + /// + /// Note: this is feature gated so it does not conflict with the `Deref`ed + /// [TypedTransaction::hash] function by default. + #[cfg(feature = "impersonated-tx")] + pub fn hash(&self) -> B256 { + if self.transaction.is_impersonated() { + if let Some(sender) = self.impersonated_sender { + return self.transaction.impersonated_hash(sender) + } + } + self.transaction.hash() + } +} + +impl Encodable for MaybeImpersonatedTransaction { + fn encode(&self, out: &mut dyn bytes::BufMut) { + self.transaction.encode(out) + } +} + +impl From for TypedTransaction { + fn from(value: MaybeImpersonatedTransaction) -> Self { + value.transaction + } +} + +impl From for MaybeImpersonatedTransaction { + fn from(value: TypedTransaction) -> Self { + MaybeImpersonatedTransaction::new(value) + } +} + +impl Decodable for MaybeImpersonatedTransaction { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + TypedTransaction::decode(buf).map(MaybeImpersonatedTransaction::new) + } +} + +impl AsRef for MaybeImpersonatedTransaction { + fn as_ref(&self) -> &TypedTransaction { + &self.transaction + } +} + +impl Deref for MaybeImpersonatedTransaction { + type Target = TypedTransaction; + + fn deref(&self) -> &Self::Target { + &self.transaction + } +} + +/// Queued transaction +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct PendingTransaction { + /// The actual transaction + pub transaction: MaybeImpersonatedTransaction, + /// the recovered sender of this transaction + sender: Address, + /// hash of `transaction`, so it can easily be reused with encoding and hashing agan + hash: TxHash, +} + +impl PendingTransaction { + pub fn new(transaction: TypedTransaction) -> Result { + let sender = transaction.recover()?; + let hash = transaction.hash(); + Ok(Self { transaction: MaybeImpersonatedTransaction::new(transaction), sender, hash }) + } + + #[cfg(feature = "impersonated-tx")] + pub fn with_impersonated(transaction: TypedTransaction, sender: Address) -> Self { + let hash = transaction.impersonated_hash(sender); + Self { + transaction: MaybeImpersonatedTransaction::impersonated(transaction, sender), + sender, + hash, + } + } + + pub fn nonce(&self) -> U256 { + self.transaction.nonce() + } + + pub fn hash(&self) -> &TxHash { + &self.hash + } + + pub fn sender(&self) -> &Address { + &self.sender + } + + /// Converts the [PendingTransaction] into the [TxEnv] context that [`revm`](foundry_evm) + /// expects. + pub fn to_revm_tx_env(&self) -> TxEnv { + fn transact_to(kind: &TxKind) -> TransactTo { + match kind { + TxKind::Call(c) => TransactTo::Call(*c), + TxKind::Create => TransactTo::Create(CreateScheme::Create), + } + } + + let caller = *self.sender(); + match &self.transaction.transaction { + TypedTransaction::Legacy(tx) => { + let chain_id = tx.chain_id(); + let TxLegacy { nonce, gas_price, gas_limit, value, to, input, .. } = tx.tx(); + TxEnv { + caller, + transact_to: transact_to(to), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id, + nonce: Some(*nonce), + value: (*value), + gas_price: U256::from(*gas_price), + gas_priority_fee: None, + gas_limit: *gas_limit, + access_list: vec![], + ..Default::default() + } + } + TypedTransaction::EIP2930(tx) => { + let TxEip2930 { + chain_id, + nonce, + gas_price, + gas_limit, + to, + value, + input, + access_list, + .. + } = tx.tx(); + TxEnv { + caller, + transact_to: transact_to(to), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id: Some(*chain_id), + nonce: Some(*nonce), + value: *value, + gas_price: U256::from(*gas_price), + gas_priority_fee: None, + gas_limit: *gas_limit, + access_list: eip_to_revm_access_list(access_list.0.clone()), + ..Default::default() + } + } + TypedTransaction::EIP1559(tx) => { + let TxEip1559 { + chain_id, + nonce, + max_priority_fee_per_gas, + max_fee_per_gas, + gas_limit, + to, + value, + input, + access_list, + .. + } = tx.tx(); + TxEnv { + caller, + transact_to: transact_to(to), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id: Some(*chain_id), + nonce: Some(*nonce), + value: *value, + gas_price: U256::from(*max_fee_per_gas), + gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), + gas_limit: *gas_limit, + access_list: eip_to_revm_access_list(access_list.0.clone()), + ..Default::default() + } + } + TypedTransaction::Deposit(tx) => { + let chain_id = tx.chain_id(); + let DepositTransaction { + nonce, + source_hash, + gas_limit, + value, + kind, + mint, + input, + is_system_tx, + .. + } = tx; + TxEnv { + caller, + transact_to: transact_to(kind), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id, + nonce: Some(nonce.to::()), + value: *value, + gas_price: U256::ZERO, + gas_priority_fee: None, + gas_limit: gas_limit.to::(), + access_list: vec![], + optimism: OptimismFields { + source_hash: Some(*source_hash), + mint: Some(mint.to::()), + is_system_transaction: Some(*is_system_tx), + enveloped_tx: None, + }, + ..Default::default() + } + } + } + } +} + +/// Container type for signed, typed transactions. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum TypedTransaction { + /// Legacy transaction type + Legacy(Signed), + /// EIP-2930 transaction + EIP2930(Signed), + /// EIP-1559 transaction + EIP1559(Signed), + /// op-stack deposit transaction + Deposit(DepositTransaction), +} + +impl TypedTransaction { + /// Returns true if the transaction uses dynamic fees: EIP1559 + pub fn is_dynamic_fee(&self) -> bool { + matches!(self, TypedTransaction::EIP1559(_)) + } + + pub fn gas_price(&self) -> U256 { + U256::from(match self { + TypedTransaction::Legacy(tx) => tx.gas_price, + TypedTransaction::EIP2930(tx) => tx.gas_price, + TypedTransaction::EIP1559(tx) => tx.max_fee_per_gas, + TypedTransaction::Deposit(_) => 0, + }) + } + + pub fn gas_limit(&self) -> U256 { + U256::from(match self { + TypedTransaction::Legacy(tx) => tx.gas_limit, + TypedTransaction::EIP2930(tx) => tx.gas_limit, + TypedTransaction::EIP1559(tx) => tx.gas_limit, + TypedTransaction::Deposit(tx) => tx.gas_limit.to::(), + }) + } + + pub fn value(&self) -> U256 { + U256::from(match self { + TypedTransaction::Legacy(tx) => tx.value, + TypedTransaction::EIP2930(tx) => tx.value, + TypedTransaction::EIP1559(tx) => tx.value, + TypedTransaction::Deposit(tx) => tx.value, + }) + } + + pub fn data(&self) -> &Bytes { + match self { + TypedTransaction::Legacy(tx) => &tx.input, + TypedTransaction::EIP2930(tx) => &tx.input, + TypedTransaction::EIP1559(tx) => &tx.input, + TypedTransaction::Deposit(tx) => &tx.input, + } + } + + /// Returns the transaction type + pub fn r#type(&self) -> Option { + match self { + TypedTransaction::Legacy(_) => None, + TypedTransaction::EIP2930(_) => Some(1), + TypedTransaction::EIP1559(_) => Some(2), + TypedTransaction::Deposit(_) => Some(0x7E), + } + } + + /// Max cost of the transaction + pub fn max_cost(&self) -> U256 { + self.gas_limit().saturating_mul(self.gas_price()) + } + + /// Returns a helper type that contains commonly used values as fields + pub fn essentials(&self) -> TransactionEssentials { + match self { + TypedTransaction::Legacy(t) => TransactionEssentials { + kind: t.tx().to, + input: t.input.clone(), + nonce: U256::from(t.tx().nonce), + gas_limit: U256::from(t.tx().gas_limit), + gas_price: Some(U256::from(t.tx().gas_price)), + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + value: t.value, + chain_id: t.tx().chain_id, + access_list: Default::default(), + }, + TypedTransaction::EIP2930(t) => TransactionEssentials { + kind: t.tx().to, + input: t.input.clone(), + nonce: U256::from(t.tx().nonce), + gas_limit: U256::from(t.tx().gas_limit), + gas_price: Some(U256::from(t.tx().gas_price)), + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + value: t.value, + chain_id: Some(t.chain_id), + access_list: to_alloy_access_list(t.access_list.clone()), + }, + TypedTransaction::EIP1559(t) => TransactionEssentials { + kind: t.to, + input: t.input.clone(), + nonce: U256::from(t.nonce), + gas_limit: U256::from(t.gas_limit), + gas_price: None, + max_fee_per_gas: Some(U256::from(t.max_fee_per_gas)), + max_priority_fee_per_gas: Some(U256::from(t.max_priority_fee_per_gas)), + value: t.value, + chain_id: Some(t.chain_id), + access_list: to_alloy_access_list(t.access_list.clone()), + }, + TypedTransaction::Deposit(t) => TransactionEssentials { + kind: t.kind, + input: t.input.clone(), + nonce: t.nonce, + gas_limit: t.gas_limit, + gas_price: Some(U256::from(0)), + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + value: t.value, + chain_id: t.chain_id(), + access_list: Default::default(), + }, + } + } + + pub fn nonce(&self) -> U256 { + match self { + TypedTransaction::Legacy(t) => U256::from(t.nonce), + TypedTransaction::EIP2930(t) => U256::from(t.nonce), + TypedTransaction::EIP1559(t) => U256::from(t.nonce), + TypedTransaction::Deposit(t) => U256::from(t.nonce), + } + } + + pub fn chain_id(&self) -> Option { + match self { + TypedTransaction::Legacy(t) => t.chain_id, + TypedTransaction::EIP2930(t) => Some(t.chain_id), + TypedTransaction::EIP1559(t) => Some(t.chain_id), + TypedTransaction::Deposit(t) => t.chain_id(), + } + } + + pub fn as_legacy(&self) -> Option<&Signed> { + match self { + TypedTransaction::Legacy(tx) => Some(tx), + _ => None, + } + } + + /// Returns true whether this tx is a legacy transaction + pub fn is_legacy(&self) -> bool { + matches!(self, TypedTransaction::Legacy(_)) + } + + /// Returns true whether this tx is a EIP1559 transaction + pub fn is_eip1559(&self) -> bool { + matches!(self, TypedTransaction::EIP1559(_)) + } + + /// Returns the hash of the transaction. + /// + /// Note: If this transaction has the Impersonated signature then this returns a modified unique + /// hash. This allows us to treat impersonated transactions as unique. + pub fn hash(&self) -> B256 { + match self { + TypedTransaction::Legacy(t) => *t.hash(), + TypedTransaction::EIP2930(t) => *t.hash(), + TypedTransaction::EIP1559(t) => *t.hash(), + TypedTransaction::Deposit(t) => t.hash(), + } + } + + /// Returns true if the transaction was impersonated (using the impersonate Signature) + #[cfg(feature = "impersonated-tx")] + pub fn is_impersonated(&self) -> bool { + self.signature() == impersonated_signature() + } + + /// Returns the hash if the transaction is impersonated (using a fake signature) + /// + /// This appends the `address` before hashing it + #[cfg(feature = "impersonated-tx")] + pub fn impersonated_hash(&self, sender: Address) -> B256 { + let mut buffer = Vec::::new(); + Encodable::encode(self, &mut buffer); + buffer.extend_from_slice(sender.as_ref()); + B256::from_slice(alloy_primitives::utils::keccak256(&buffer).as_slice()) + } + + /// Recovers the Ethereum address which was used to sign the transaction. + pub fn recover(&self) -> Result { + match self { + TypedTransaction::Legacy(tx) => tx.recover_signer(), + TypedTransaction::EIP2930(tx) => tx.recover_signer(), + TypedTransaction::EIP1559(tx) => tx.recover_signer(), + TypedTransaction::Deposit(tx) => tx.recover(), + } + } + + /// Returns what kind of transaction this is + pub fn kind(&self) -> &TxKind { + match self { + TypedTransaction::Legacy(tx) => &tx.to, + TypedTransaction::EIP2930(tx) => &tx.to, + TypedTransaction::EIP1559(tx) => &tx.to, + TypedTransaction::Deposit(tx) => &tx.kind, + } + } + + /// Returns the callee if this transaction is a call + pub fn to(&self) -> Option
{ + self.kind().to() + } + + /// Returns the Signature of the transaction + pub fn signature(&self) -> Signature { + match self { + TypedTransaction::Legacy(tx) => *tx.signature(), + TypedTransaction::EIP2930(tx) => *tx.signature(), + TypedTransaction::EIP1559(tx) => *tx.signature(), + TypedTransaction::Deposit(_) => { + Signature::from_scalars_and_parity(B256::ZERO, B256::ZERO, false).unwrap() + } + } + } +} + +impl Encodable for TypedTransaction { + fn encode(&self, out: &mut dyn bytes::BufMut) { + match self { + TypedTransaction::Legacy(tx) => tx.encode(out), + TypedTransaction::EIP2930(tx) => tx.encode(out), + TypedTransaction::EIP1559(tx) => tx.encode(out), + TypedTransaction::Deposit(tx) => tx.encode(out), + } + } +} + +impl Decodable for TypedTransaction { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + use bytes::Buf; + use std::cmp::Ordering; + + let first = *buf.first().ok_or(alloy_rlp::Error::Custom("empty slice"))?; + + // a signed transaction is either encoded as a string (non legacy) or a list (legacy). + // We should not consume the buffer if we are decoding a legacy transaction, so let's + // check if the first byte is between 0x80 and 0xbf. + match first.cmp(&alloy_rlp::EMPTY_LIST_CODE) { + Ordering::Less => { + // strip out the string header + // NOTE: typed transaction encodings either contain a "rlp header" which contains + // the type of the payload and its length, or they do not contain a header and + // start with the tx type byte. + // + // This line works for both types of encodings because byte slices starting with + // 0x01 and 0x02 return a Header { list: false, payload_length: 1 } when input to + // Header::decode. + // If the encoding includes a header, the header will be properly decoded and + // consumed. + // Otherwise, header decoding will succeed but nothing is consumed. + let _header = alloy_rlp::Header::decode(buf)?; + let tx_type = *buf.first().ok_or(alloy_rlp::Error::Custom( + "typed tx cannot be decoded from an empty slice", + ))?; + if tx_type == 0x01 { + buf.advance(1); + as Decodable>::decode(buf).map(TypedTransaction::EIP2930) + } else if tx_type == 0x02 { + buf.advance(1); + as Decodable>::decode(buf).map(TypedTransaction::EIP1559) + } else if tx_type == 0x7E { + buf.advance(1); + ::decode(buf).map(TypedTransaction::Deposit) + } else { + Err(alloy_rlp::Error::Custom("invalid tx type")) + } + } + Ordering::Equal => { + Err(alloy_rlp::Error::Custom("an empty list is not a valid transaction encoding")) + } + Ordering::Greater => { + as Decodable>::decode(buf).map(TypedTransaction::Legacy) + } + } + } +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct TransactionEssentials { + pub kind: TxKind, + pub input: Bytes, + pub nonce: U256, + pub gas_limit: U256, + pub gas_price: Option, + pub max_fee_per_gas: Option, + pub max_priority_fee_per_gas: Option, + pub value: U256, + pub chain_id: Option, + pub access_list: AccessList, +} + +/// Represents all relevant information of an executed transaction +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct TransactionInfo { + pub transaction_hash: B256, + pub transaction_index: u32, + pub from: Address, + pub to: Option
, + pub contract_address: Option
, + pub logs: Vec, + pub logs_bloom: Bloom, + pub traces: Vec, + pub exit: InstructionResult, + pub out: Option, + pub nonce: u64, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum TypedReceipt { + Legacy(ReceiptWithBloom), + EIP2930(ReceiptWithBloom), + EIP1559(ReceiptWithBloom), + Deposit(ReceiptWithBloom), +} + +impl TypedReceipt { + pub fn gas_used(&self) -> U256 { + match self { + TypedReceipt::Legacy(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::Deposit(r) => U256::from(r.receipt.cumulative_gas_used), + } + } + + pub fn logs_bloom(&self) -> &Bloom { + match self { + TypedReceipt::Legacy(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::Deposit(r) => &r.bloom, + } + } +} + +impl Encodable for TypedReceipt { + fn encode(&self, out: &mut dyn bytes::BufMut) { + use alloy_rlp::Header; + + match self { + TypedReceipt::Legacy(r) => r.encode(out), + receipt => { + let payload_len = match receipt { + TypedReceipt::EIP2930(r) => r.length() + 1, + TypedReceipt::EIP1559(r) => r.length() + 1, + TypedReceipt::Deposit(r) => r.length() + 1, + _ => unreachable!("receipt already matched"), + }; + + match receipt { + TypedReceipt::EIP2930(r) => { + Header { list: true, payload_length: payload_len }.encode(out); + 1u8.encode(out); + r.encode(out); + } + TypedReceipt::EIP1559(r) => { + Header { list: true, payload_length: payload_len }.encode(out); + 2u8.encode(out); + r.encode(out); + } + TypedReceipt::Deposit(r) => { + Header { list: true, payload_length: payload_len }.encode(out); + 0x7Eu8.encode(out); + r.encode(out); + } + _ => unreachable!("receipt already matched"), + } + } + } + } +} + +impl Decodable for TypedReceipt { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + use alloy_rlp::Header; + use bytes::Buf; + use std::cmp::Ordering; + + // a receipt is either encoded as a string (non legacy) or a list (legacy). + // We should not consume the buffer if we are decoding a legacy receipt, so let's + // check if the first byte is between 0x80 and 0xbf. + let rlp_type = *buf + .first() + .ok_or(alloy_rlp::Error::Custom("cannot decode a receipt from empty bytes"))?; + + match rlp_type.cmp(&alloy_rlp::EMPTY_LIST_CODE) { + Ordering::Less => { + // strip out the string header + let _header = Header::decode(buf)?; + let receipt_type = *buf.first().ok_or(alloy_rlp::Error::Custom( + "typed receipt cannot be decoded from an empty slice", + ))?; + if receipt_type == 0x01 { + buf.advance(1); + ::decode(buf).map(TypedReceipt::EIP2930) + } else if receipt_type == 0x02 { + buf.advance(1); + ::decode(buf).map(TypedReceipt::EIP1559) + } else if receipt_type == 0x7E { + buf.advance(1); + ::decode(buf).map(TypedReceipt::Deposit) + } else { + Err(alloy_rlp::Error::Custom("invalid receipt type")) + } + } + Ordering::Equal => { + Err(alloy_rlp::Error::Custom("an empty list is not a valid receipt encoding")) + } + Ordering::Greater => { + ::decode(buf).map(TypedReceipt::Legacy) + } + } + } +} + +/// Translates an EIP-2930 access list to an alloy-rpc-types access list. +pub fn to_alloy_access_list( + access_list: alloy_eips::eip2930::AccessList, +) -> alloy_rpc_types::AccessList { + alloy_rpc_types::AccessList( + access_list + .0 + .into_iter() + .map(|item| alloy_rpc_types::AccessListItem { + address: item.address, + storage_keys: item.storage_keys, + }) + .collect(), + ) +} + +/// Translates an alloy-rpc-types access list to an EIP-2930 access list. +pub fn to_eip_access_list( + access_list: alloy_rpc_types::AccessList, +) -> alloy_eips::eip2930::AccessList { + alloy_eips::eip2930::AccessList( + access_list + .0 + .into_iter() + .map(|item| alloy_eips::eip2930::AccessListItem { + address: item.address, + storage_keys: item.storage_keys, + }) + .collect(), + ) +} + +#[cfg(test)] +mod tests { + use alloy_consensus::Receipt; + use alloy_primitives::{b256, hex, LogData, Signature}; + use std::str::FromStr; + + use super::*; + + #[test] + fn test_decode_call() { + let bytes_first = &mut &hex::decode("f86b02843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba00eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5aea03a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18").unwrap()[..]; + let decoded = TypedTransaction::decode(&mut &bytes_first[..]).unwrap(); + println!("{:?}", hex::encode(decoded.signature().as_bytes())); + let tx = TxLegacy { + nonce: 2u64, + gas_price: 1000000000u64.into(), + gas_limit: 100000u64, + to: TxKind::Call(Address::from_slice( + &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], + )), + value: U256::from(1000000000000000u64), + input: Bytes::default(), + chain_id: None, + }; + + let signature = Signature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap(); + + let tx = TypedTransaction::Legacy(Signed::new_unchecked( + tx.clone(), + signature, + b256!("a517b206d2223278f860ea017d3626cacad4f52ff51030dc9a96b432f17f8d34"), + )); + + println!("{:#?}", decoded); + assert_eq!(tx, decoded); + } + + #[test] + fn test_decode_create_goerli() { + // test that an example create tx from goerli decodes properly + let tx_bytes = + hex::decode("02f901ee05228459682f008459682f11830209bf8080b90195608060405234801561001057600080fd5b50610175806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80630c49c36c14610030575b600080fd5b61003861004e565b604051610045919061011d565b60405180910390f35b60606020600052600f6020527f68656c6c6f2073746174656d696e64000000000000000000000000000000000060405260406000f35b600081519050919050565b600082825260208201905092915050565b60005b838110156100be5780820151818401526020810190506100a3565b838111156100cd576000848401525b50505050565b6000601f19601f8301169050919050565b60006100ef82610084565b6100f9818561008f565b93506101098185602086016100a0565b610112816100d3565b840191505092915050565b6000602082019050818103600083015261013781846100e4565b90509291505056fea264697066735822122051449585839a4ea5ac23cae4552ef8a96b64ff59d0668f76bfac3796b2bdbb3664736f6c63430008090033c080a0136ebffaa8fc8b9fda9124de9ccb0b1f64e90fbd44251b4c4ac2501e60b104f9a07eb2999eec6d185ef57e91ed099afb0a926c5b536f0155dd67e537c7476e1471") + .unwrap(); + let _decoded = + ::decode(&mut &tx_bytes[..]).unwrap(); + } + + #[test] + fn can_recover_sender() { + // random mainnet tx: https://etherscan.io/tx/0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f + let bytes = hex::decode("02f872018307910d808507204d2cb1827d0094388c818ca8b9251b393131c08a736a67ccb19297880320d04823e2701c80c001a0cf024f4815304df2867a1a74e9d2707b6abda0337d2d54a4438d453f4160f190a07ac0e6b3bc9395b5b9c8b9e6d77204a236577a5b18467b9175c01de4faa208d9").unwrap(); + + let Ok(TypedTransaction::EIP1559(tx)) = TypedTransaction::decode(&mut &bytes[..]) else { + panic!("decoding TypedTransaction failed"); + }; + + assert_eq!( + tx.hash(), + &"0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f" + .parse::() + .unwrap() + ); + assert_eq!( + tx.recover_signer().unwrap(), + "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5".parse::
().unwrap() + ); + } + + #[test] + fn can_recover_sender_not_normalized() { + let bytes = hex::decode("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap(); + + let Ok(TypedTransaction::Legacy(tx)) = TypedTransaction::decode(&mut &bytes[..]) else { + panic!("decoding TypedTransaction failed"); + }; + + assert_eq!(tx.input, Bytes::from(b"")); + assert_eq!(tx.gas_price, 1); + assert_eq!(tx.gas_limit, 21000); + assert_eq!(tx.nonce, 0); + if let TxKind::Call(to) = tx.to { + assert_eq!( + to, + "0x095e7baea6a6c7c4c2dfeb977efac326af552d87".parse::
().unwrap() + ); + } else { + panic!("expected a call transaction"); + } + assert_eq!(tx.value, U256::from(0x0au64)); + assert_eq!( + tx.recover_signer().unwrap(), + "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse::
().unwrap() + ); + } + + #[test] + fn encode_legacy_receipt() { + let expected = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); + + let mut data = vec![]; + let receipt = TypedReceipt::Legacy(ReceiptWithBloom { + receipt: Receipt { + success: false, + cumulative_gas_used: 0x1u64, + logs: vec![Log { + address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), + data: LogData::new_unchecked( + vec![ + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000dead", + ) + .unwrap(), + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000beef", + ) + .unwrap(), + ], + Bytes::from_str("0100ff").unwrap(), + ), + }], + }, + bloom: [0; 256].into(), + }); + + receipt.encode(&mut data); + + // check that the rlp length equals the length of the expected rlp + assert_eq!(receipt.length(), expected.len()); + assert_eq!(data, expected); + } + + #[test] + fn decode_legacy_receipt() { + let data = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); + + let expected = TypedReceipt::Legacy(ReceiptWithBloom { + receipt: Receipt { + success: false, + cumulative_gas_used: 0x1u64, + logs: vec![Log { + address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), + data: LogData::new_unchecked( + vec![ + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000dead", + ) + .unwrap(), + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000beef", + ) + .unwrap(), + ], + Bytes::from_str("0100ff").unwrap(), + ), + }], + }, + bloom: [0; 256].into(), + }); + + let receipt = TypedReceipt::decode(&mut &data[..]).unwrap(); + + assert_eq!(receipt, expected); + } +} diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 5fa6d1fc0bfd0..4a878ddfbbf40 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -22,9 +22,10 @@ use revm::{ }; use std::ops::Deref; +pub mod alloy; /// compatibility with `ethers-rs` types mod ethers_compat; - +pub mod optimism; pub use ethers_compat::{ call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_alloy_signature, to_ethers_access_list, to_ethers_signature, @@ -512,7 +513,7 @@ impl Encodable for DepositTransactionRequest { /// /// This is a helper that carries the `impersonated` sender so that the right hash /// [TypedTransaction::impersonated_hash] can be created. -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MaybeImpersonatedTransaction { #[cfg_attr(feature = "serde", serde(flatten))] @@ -617,7 +618,7 @@ impl Deref for MaybeImpersonatedTransaction { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum TypedTransaction { /// Legacy transaction type diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs new file mode 100644 index 0000000000000..f6b3b47e13be1 --- /dev/null +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -0,0 +1,179 @@ +use alloy_network::TxKind; +use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_rlp::{Decodable, Encodable, Error as DecodeError, Header as RlpHeader}; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct DepositTransactionRequest { + pub from: Address, + pub source_hash: B256, + pub kind: TxKind, + pub mint: U256, + pub value: U256, + pub gas_limit: U256, + pub is_system_tx: bool, + pub input: Bytes, +} + +impl DepositTransactionRequest { + pub fn hash(&self) -> B256 { + B256::from_slice(alloy_primitives::keccak256(alloy_rlp::encode(self)).as_slice()) + } + + /// Encodes only the transaction's fields into the desired buffer, without a RLP header. + pub(crate) fn encode_fields(&self, out: &mut dyn alloy_rlp::BufMut) { + self.from.encode(out); + self.source_hash.encode(out); + self.kind.encode(out); + self.mint.encode(out); + self.value.encode(out); + self.gas_limit.encode(out); + self.is_system_tx.encode(out); + self.input.encode(out); + } + + /// Calculates the length of the RLP-encoded transaction's fields. + pub(crate) fn fields_len(&self) -> usize { + let mut len = 0; + len += self.source_hash.length(); + len += self.from.length(); + len += self.kind.length(); + len += self.mint.length(); + len += self.value.length(); + len += self.gas_limit.length(); + len += self.is_system_tx.length(); + len += self.input.length(); + len + } +} + +impl From for DepositTransactionRequest { + fn from(tx: DepositTransaction) -> Self { + Self { + from: tx.from, + source_hash: tx.source_hash, + kind: tx.kind, + mint: tx.mint, + value: tx.value, + gas_limit: tx.gas_limit, + is_system_tx: tx.is_system_tx, + input: tx.input, + } + } +} + +impl Encodable for DepositTransactionRequest { + fn encode(&self, out: &mut dyn bytes::BufMut) { + RlpHeader { list: true, payload_length: self.fields_len() }.encode(out); + self.encode_fields(out); + } +} + +/// An op-stack deposit transaction. +/// See +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct DepositTransaction { + pub nonce: U256, + pub source_hash: B256, + pub from: Address, + pub kind: TxKind, + pub mint: U256, + pub value: U256, + pub gas_limit: U256, + pub is_system_tx: bool, + pub input: Bytes, +} + +impl DepositTransaction { + pub fn nonce(&self) -> &U256 { + &self.nonce + } + + pub fn hash(&self) -> B256 { + B256::from_slice(alloy_primitives::keccak256(alloy_rlp::encode(self)).as_slice()) + } + + // /// Recovers the Ethereum address which was used to sign the transaction. + pub fn recover(&self) -> Result { + Ok(self.from) + } + + pub fn chain_id(&self) -> Option { + None + } + + /// Encodes only the transaction's fields into the desired buffer, without a RLP header. + pub(crate) fn encode_fields(&self, out: &mut dyn alloy_rlp::BufMut) { + self.nonce.encode(out); + self.source_hash.encode(out); + self.from.encode(out); + self.kind.encode(out); + self.mint.encode(out); + self.value.encode(out); + self.gas_limit.encode(out); + self.is_system_tx.encode(out); + self.input.encode(out); + } + + /// Calculates the length of the RLP-encoded transaction's fields. + pub(crate) fn fields_len(&self) -> usize { + let mut len = 0; + len += self.nonce.length(); + len += self.source_hash.length(); + len += self.from.length(); + len += self.kind.length(); + len += self.mint.length(); + len += self.value.length(); + len += self.gas_limit.length(); + len += self.is_system_tx.length(); + len += self.input.length(); + len + } + + /// Decodes the inner [TxDeposit] fields from RLP bytes. + /// + /// NOTE: This assumes a RLP header has already been decoded, and _just_ decodes the following + /// RLP fields in the following order: + /// + /// - `nonce` + /// - `source_hash` + /// - `from` + /// - `kind` + /// - `mint` + /// - `value` + /// - `gas_limit` + /// - `is_system_tx` + /// - `input` + pub fn decode_inner(buf: &mut &[u8]) -> Result { + Ok(Self { + nonce: Decodable::decode(buf)?, + source_hash: Decodable::decode(buf)?, + from: Decodable::decode(buf)?, + kind: Decodable::decode(buf)?, + mint: Decodable::decode(buf)?, + value: Decodable::decode(buf)?, + gas_limit: Decodable::decode(buf)?, + is_system_tx: Decodable::decode(buf)?, + input: Decodable::decode(buf)?, + }) + } +} + +impl Encodable for DepositTransaction { + fn encode(&self, out: &mut dyn bytes::BufMut) { + RlpHeader { list: true, payload_length: self.fields_len() }.encode(out); + self.encode_fields(out); + } +} + +impl Decodable for DepositTransaction { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + let header = RlpHeader::decode(buf)?; + let remaining_len = buf.len(); + + if header.payload_length > remaining_len { + return Err(alloy_rlp::Error::InputTooShort); + } + + Self::decode_inner(buf) + } +} diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index e67e5dd4a9053..d9d8c09872e5b 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,3 +1,4 @@ +use alloy_eips::eip2930::AccessListItem as AlloyEipAccessListItem; use alloy_primitives::{Address, U256}; use alloy_rpc_types::AccessListItem as AlloyAccessListItem; use ethers_core::{ @@ -33,3 +34,10 @@ pub fn alloy_to_revm_access_list(list: Vec) -> Vec<(Address .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) .collect() } + +/// Translates a vec of [AlloyEipAccessListItem] to a revm style Access List. +pub fn eip_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { + list.into_iter() + .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) + .collect() +} From f20818784e484a1baeaced440c95af36696e0f6a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 15 Jan 2024 20:24:14 +0100 Subject: [PATCH 0481/1963] fix: handle all payload errors (#6805) --- Cargo.lock | 36 ++++++++++++++-------------- crates/anvil/src/eth/backend/fork.rs | 8 ++++--- crates/common/src/provider/tower.rs | 11 +++++---- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecafc175ce6f5..26b7339750400 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "serde", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -252,7 +252,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -3732,9 +3732,9 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" +checksum = "e8e1127ede0475b58f4fe9c0aaa0d9bb0bad2af90bbd93ccd307c8632b863d89" [[package]] name = "gix-utils" @@ -7943,9 +7943,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.9" +version = "8.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c7b513a7d40506d5a07f186a298821cc9ec2cc22088a3593f7b612a66659f6" +checksum = "6cf9c2670809c4840d4648fc7daa396551d7d88966f9ba93821b81a5c0c2d3f5" dependencies = [ "anyhow", "git2", @@ -8555,4 +8555,4 @@ dependencies = [ [[patch.unused]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 34a67fcf1a0db..857d241cce539 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -434,10 +434,12 @@ impl ClientFork { if self.predates_fork_inclusive(number) { let receipts = self.provider().get_block_receipts(BlockNumber::Number(number)).await?; - let mut storage = self.storage_write(); - storage.block_receipts.insert(number, receipts.clone()); + if let Some(receipts) = receipts.clone() { + let mut storage = self.storage_write(); + storage.block_receipts.insert(number, receipts); + } - return Ok(Some(receipts)); + return Ok(receipts); } Ok(None) diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs index 5e08b836c991a..632d8b29951d3 100644 --- a/crates/common/src/provider/tower.rs +++ b/crates/common/src/provider/tower.rs @@ -108,13 +108,16 @@ impl Service for RetryBackoffService { match fut { Ok(res) => { - this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); - return Ok(res) + if let Some(e) = res.as_error() { + err = TransportError::ErrorResp(e.clone()) + } else { + this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); + return Ok(res) + } } Err(e) => err = e, } - let err = TransportError::from(err); let should_retry = this.policy.should_retry(&err); if should_retry { rate_limit_retry_number += 1; @@ -159,7 +162,7 @@ impl Service for RetryBackoffService { } this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); - return Err(TransportErrorKind::custom_str("Max retries exceeded")) + return Err(err) } } }) From 24abca6c9133618e0c355842d2be2dd4f36da46d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:50:48 +0100 Subject: [PATCH 0482/1963] feat: stop using console2 (#6804) --- crates/forge/assets/CounterTemplate.s.sol | 2 +- crates/forge/assets/CounterTemplate.t.sol | 2 +- crates/forge/assets/generated/TestTemplate.t.sol | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/forge/assets/CounterTemplate.s.sol b/crates/forge/assets/CounterTemplate.s.sol index 1a47b40b82aab..df9ee8b02ce4d 100644 --- a/crates/forge/assets/CounterTemplate.s.sol +++ b/crates/forge/assets/CounterTemplate.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {Script, console2} from "forge-std/Script.sol"; +import {Script, console} from "forge-std/Script.sol"; contract CounterScript is Script { function setUp() public {} diff --git a/crates/forge/assets/CounterTemplate.t.sol b/crates/forge/assets/CounterTemplate.t.sol index e9b9e6acf2b43..54b724f7ae766 100644 --- a/crates/forge/assets/CounterTemplate.t.sol +++ b/crates/forge/assets/CounterTemplate.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {Test, console2} from "forge-std/Test.sol"; +import {Test, console} from "forge-std/Test.sol"; import {Counter} from "../src/Counter.sol"; contract CounterTest is Test { diff --git a/crates/forge/assets/generated/TestTemplate.t.sol b/crates/forge/assets/generated/TestTemplate.t.sol index 468acba01069a..816a8c68fd0a9 100644 --- a/crates/forge/assets/generated/TestTemplate.t.sol +++ b/crates/forge/assets/generated/TestTemplate.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {Test, console2} from "forge-std/Test.sol"; +import {Test, console} from "forge-std/Test.sol"; import {{contract_name}} from "../src/{contract_name}.sol"; contract {contract_name}Test is Test { @@ -10,4 +10,4 @@ contract {contract_name}Test is Test { function setUp() public { {instance_name} = new {contract_name}(); } -} \ No newline at end of file +} From 78ed7076e85629495e440a67ace5d335b95c3aff Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 16 Jan 2024 14:20:53 +0100 Subject: [PATCH 0483/1963] fix: use provided name for inspect pretty (#6817) --- crates/fmt/src/helpers.rs | 17 ++++++++++++++++- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/tests/cli/cmd.rs | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index 9d2988a6342b8..8d472e3bb33be 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -46,7 +46,10 @@ pub fn format_to( /// Parse and format a string with default settings pub fn format(src: &str) -> Result { - let parsed = parse(src).map_err(|_| FormatterError::Fmt(std::fmt::Error))?; + let parsed = parse(src).map_err(|err| { + debug!(?err, "Parse error"); + FormatterError::Fmt(std::fmt::Error) + })?; let mut output = String::new(); format_to(&mut output, parsed, FormatterConfig::default())?; @@ -105,3 +108,15 @@ pub fn import_path_string(path: &ImportPath) -> String { ImportPath::Path(p) => p.to_string(), } } + +#[cfg(test)] +mod tests { + use super::*; + + // + #[test] + fn test_interface_format() { + let s = "interface I {\n function increment() external;\n function number() external view returns (uint256);\n function setNumber(uint256 newNumber) external;\n}"; + let _formatted = format(s).unwrap(); + } +} diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 2b3c1d449ac64..37912e1c2d987 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -83,7 +83,7 @@ impl InspectArgs { .as_ref() .ok_or_else(|| eyre::eyre!("Failed to fetch lossless ABI"))?; if pretty { - let source = foundry_cli::utils::abi_to_solidity(abi, "")?; + let source = foundry_cli::utils::abi_to_solidity(abi, &contract.name)?; println!("{source}"); } else { print_json(abi)?; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 5e8283f2785a3..107b25cc6f06d 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1611,3 +1611,17 @@ forgetest_init!(can_build_names_repeatedly, |prj, cmd| { let unchanged = cmd.stdout_lossy(); assert!(unchanged.contains(list), "{}", list); }); + +// +forgetest_init!(can_inspect_counter_pretty, |prj, cmd| { + cmd.args(["inspect", "src/Counter.sol:Counter", "abi", "--pretty"]); + let output = cmd.stdout_lossy(); + assert_eq!( + output.trim(), + "interface Counter { + function increment() external; + function number() external view returns (uint256); + function setNumber(uint256 newNumber) external; +}" + ); +}); From 04ccec7ace1687cd8067e2aee8bc3f338107a87a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 16 Jan 2024 16:12:29 +0100 Subject: [PATCH 0484/1963] fix: capacity overflow on invariant shrinking (#6819) --- crates/evm/evm/src/executors/invariant/error.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index f4e11aa6434ae..1f4c87c8d5926 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -288,16 +288,17 @@ impl InvariantFuzzError { let shrunk_call_indices = Arc::new(RwLock::new((0..calls.len()).collect())); let shrink_limit = self.shrink_run_limit - runs; + let upper_bound = calls.len().saturating_sub(1); // We construct either a full powerset (this guarantees we maximally shrunk for the given // calls) or a random subset let (set_of_indices, is_powerset): (Vec<_>, bool) = if calls.len() <= 64 && 2_usize.pow(calls.len() as u32) <= shrink_limit { // We add the last tx always because thats ultimately what broke the invariant - let powerset = (0..calls.len() - 1) + let powerset = (0..upper_bound) .powerset() .map(|mut subset| { - subset.push(calls.len() - 1); + subset.push(upper_bound); subset }) .collect(); @@ -309,16 +310,16 @@ impl InvariantFuzzError { (0..shrink_limit / 3) .map(|_| { // Select between 1 and calls.len() - 2 number of indices - let amt: usize = rng.gen_range(1..calls.len() - 1); + let amt: usize = rng.gen_range(1..upper_bound); // Construct a random sequence of indices, up to calls.len() - 1 (sample is // exclusive range and we dont include the last tx // because its always included), and amt number of indices - let mut seq = seq::index::sample(&mut rng, calls.len() - 1, amt).into_vec(); + let mut seq = seq::index::sample(&mut rng, upper_bound, amt).into_vec(); // Sort the indices because seq::index::sample is unordered seq.sort(); // We add the last tx always because thats what ultimately broke the // invariant - seq.push(calls.len() - 1); + seq.push(upper_bound); seq }) .collect(), From 36044daf324a9f57d00b60566f9729ceaf667dd4 Mon Sep 17 00:00:00 2001 From: wilsoncusack Date: Tue, 16 Jan 2024 10:27:33 -0500 Subject: [PATCH 0485/1963] signP256 Cheat (#6797) * started, need to test * update lock * track Vm.sol diff * SignP256.t.sol * added tests, fix tests, other cleanup * update json * improve tests * add comment * CI clippy * typo --- Cargo.lock | 33 ++++++++++ crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 22 ++++++- crates/cheatcodes/spec/src/vm.rs | 6 +- crates/cheatcodes/src/evm.rs | 7 +++ crates/cheatcodes/src/utils.rs | 80 ++++++++++++++++++++++++ testdata/cheats/SignP256.t.sol | 18 ++++++ testdata/cheats/Vm.sol | 1 + 8 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 testdata/cheats/SignP256.t.sol diff --git a/Cargo.lock b/Cargo.lock index 26b7339750400..c04981ad91df3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1926,6 +1926,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -2135,6 +2136,7 @@ dependencies = [ "ff", "generic-array", "group", + "pem-rfc7468", "pkcs8", "rand_core 0.6.4", "sec1", @@ -2954,6 +2956,7 @@ dependencies = [ "foundry-evm-core", "itertools 0.11.0", "jsonpath_lib", + "p256", "revm", "serde_json", "tracing", @@ -5152,6 +5155,18 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + [[package]] name = "parity-scale-codec" version = "3.6.9" @@ -5335,6 +5350,15 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -5627,6 +5651,15 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "primitive-types" version = "0.12.2" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 7225111fed4de..7c3d2db0a4ccb 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -37,3 +37,4 @@ serde_json.workspace = true base64.workspace = true tracing.workspace = true walkdir = "2" +p256 = "0.13.2" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index fea491981bafa..7819914cba8cc 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4193,10 +4193,30 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "signP256", + "description": "Signs `digest` with `privateKey` using the secp256r1 curve.", + "declaration": "function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "pure", + "signature": "signP256(uint256,bytes32)", + "selector": "0x83211b40", + "selectorBytes": [ + 131, + 33, + 27, + 64 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "sign_0", - "description": "Signs data.", + "description": "Signs `digest` with `privateKey` using the secp256k1 curve.", "declaration": "function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", "visibility": "external", "mutability": "pure", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 819ddd41ceafd..d1611222d54b6 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -239,10 +239,14 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function loadAllocs(string calldata pathToAllocsJson) external; - /// Signs data. + /// Signs `digest` with `privateKey` using the secp256k1 curve. #[cheatcode(group = Evm, safety = Safe)] function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + /// Signs `digest` with `privateKey` using the secp256r1 curve. + #[cheatcode(group = Evm, safety = Safe)] + function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); + // -------- Record Storage -------- /// Records all storage reads and writes. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index b148ea361332e..24e26def0efd8 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -93,6 +93,13 @@ impl Cheatcode for sign_0Call { } } +impl Cheatcode for signP256Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { privateKey, digest } = self; + super::utils::sign_p256(privateKey, digest, ccx.state) + } +} + impl Cheatcode for recordCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 8955bebff4db0..68c88da76be91 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -17,6 +17,7 @@ use ethers_signers::{ }; use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; +use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; /// The BIP32 default derivation path prefix. const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; @@ -171,6 +172,22 @@ pub(super) fn sign(private_key: &U256, digest: &B256, chain_id: u64) -> Result { Ok((sig.v, r_bytes, s_bytes).abi_encode()) } +pub(super) fn sign_p256(private_key: &U256, digest: &B256, _state: &mut Cheatcodes) -> Result { + ensure!(*private_key != U256::ZERO, "private key cannot be 0"); + let n = U256::from_limbs(*p256::NistP256::ORDER.as_words()); + ensure!( + *private_key < n, + format!("private key must be less than the secp256r1 curve order ({})", n), + ); + let bytes = private_key.to_be_bytes(); + let signing_key = P256SigningKey::from_bytes((&bytes).into())?; + let signature: Signature = signing_key.sign_prehash(digest.as_slice())?; + let r_bytes: [u8; 32] = signature.r().to_bytes().into(); + let s_bytes: [u8; 32] = signature.s().to_bytes().into(); + + Ok((r_bytes, s_bytes).abi_encode()) +} + pub(super) fn parse_private_key(private_key: &U256) -> Result { ensure!(*private_key != U256::ZERO, "private key cannot be 0"); ensure!( @@ -219,3 +236,66 @@ fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { let private_key = U256::from_be_bytes(wallet.signer().to_bytes().into()); Ok(private_key.abi_encode()) } + +#[cfg(test)] +mod tests { + use super::*; + use crate::CheatsConfig; + use alloy_primitives::FixedBytes; + use hex::FromHex; + use p256::ecdsa::{signature::hazmat::PrehashVerifier, Signature}; + use std::{path::PathBuf, sync::Arc}; + + fn cheats() -> Cheatcodes { + let config = CheatsConfig { + ffi: true, + root: PathBuf::from(&env!("CARGO_MANIFEST_DIR")), + ..Default::default() + }; + Cheatcodes { config: Arc::new(config), ..Default::default() } + } + + #[test] + fn test_sign_p256() { + use p256::ecdsa::VerifyingKey; + + let pk_u256: U256 = "1".parse().unwrap(); + let signing_key = P256SigningKey::from_bytes(&pk_u256.to_be_bytes().into()).unwrap(); + let digest = FixedBytes::from_hex( + "0x44acf6b7e36c1342c2c5897204fe09504e1e2efb1a900377dbc4e7a6a133ec56", + ) + .unwrap(); + let mut cheats = cheats(); + + let result = sign_p256(&pk_u256, &digest, &mut cheats).unwrap(); + let result_bytes: [u8; 64] = result.try_into().unwrap(); + let signature = Signature::from_bytes(&result_bytes.into()).unwrap(); + let verifying_key = VerifyingKey::from(&signing_key); + assert!(verifying_key.verify_prehash(digest.as_slice(), &signature).is_ok()); + } + + #[test] + fn test_sign_p256_pk_too_large() { + // max n from https://neuromancer.sk/std/secg/secp256r1 + let pk = + "0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551".parse().unwrap(); + let digest = FixedBytes::from_hex( + "0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad", + ) + .unwrap(); + let mut cheats = cheats(); + let result = sign_p256(&pk, &digest, &mut cheats); + assert_eq!(result.err().unwrap().to_string(), "private key must be less than the secp256r1 curve order (115792089210356248762697446949407573529996955224135760342422259061068512044369)"); + } + + #[test] + fn test_sign_p256_pk_0() { + let digest = FixedBytes::from_hex( + "0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad", + ) + .unwrap(); + let mut cheats = cheats(); + let result = sign_p256(&U256::ZERO, &digest, &mut cheats); + assert_eq!(result.err().unwrap().to_string(), "private key cannot be 0"); + } +} diff --git a/testdata/cheats/SignP256.t.sol b/testdata/cheats/SignP256.t.sol new file mode 100644 index 0000000000000..ee0363e970987 --- /dev/null +++ b/testdata/cheats/SignP256.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract SignTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testSignP256() public { + bytes32 pk = hex"A8568B74282DCC66FF70F10B4CE5CC7B391282F5381BBB4F4D8DD96974B16E6B"; + bytes32 digest = hex"54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad"; + + (bytes32 r, bytes32 s) = vm.signP256(uint256(pk), digest); + assertEq(r, hex"7C11C3641B19E7822DB644CBF76ED0420A013928C2FD3E36D8EF983B103BDFE1"); + assertEq(s, hex"317D89879868D484810D4E508A96109F8C87617B7BE9337411348D7B786F945F"); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 86afd8d06d2b6..78ca56eda8359 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -207,6 +207,7 @@ interface Vm { function setEnv(string calldata name, string calldata value) external; function setNonce(address account, uint64 newNonce) external; function setNonceUnsafe(address account, uint64 newNonce) external; + function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); function skip(bool skipTest) external; From f180a132e308cc91589fd4ce332d2110ea975881 Mon Sep 17 00:00:00 2001 From: Miao ZhiCheng Date: Tue, 16 Jan 2024 17:39:28 +0200 Subject: [PATCH 0486/1963] Update prune-prereleases.js pruning rules (#6806) * Update prune-prereleases.js pruning rules // Pruning rules: // 1. only keep the earliest release of the month // 2. to keep the newest 3 nightlies ``` import { Octokit, App } from "octokit"; // Create a personal access token at https://github.com/settings/tokens/new?scopes=repo const octokit = new Octokit({ }); // In case node 21 is not used. function groupBy(array, keyOrIterator) { var iterator; // use the function passed in, or create one if(typeof keyOrIterator !== 'function') { const key = String(keyOrIterator); iterator = function (item) { return item[key]; }; } else { iterator = keyOrIterator; } return array.reduce(function (memo, item) { const key = iterator(item); memo[key] = memo[key] || []; memo[key].push(item); return memo; }, {}); } async function separateReleases({ github, context }) { console.log("Pruning old prereleases"); // doc: https://docs.github.com/en/rest/releases/releases const { data: releases } = await github.rest.repos.listReleases({ owner: context.repo.owner, repo: context.repo.repo, }); let nightlies = releases.filter( release => // Only consider releases tagged `nightly-${SHA}` for deletion release.tag_name.includes("nightly") && release.tag_name !== "nightly" ); // group releases by months const groups = groupBy(nightlies, i => i.created_at.slice(0, 7)); // Pruning rules: // 1. only keep the earliest release of the month // 2. to keep the newest 3 nightlies const toPrune = Object.values(groups) .reduce((acc, cur) => acc.concat(cur.slice(0, -1)), []) .slice(3); const toKeep = Object.values(groups).reduce((acc, cur) => acc.concat(cur.slice(-1)), []); return { toPrune, toKeep, }; }; (async() => { const releases = await separateReleases({ github : octokit, context : { repo : { owner: "foundry-rs", repo: "foundry" } }, }); console.log("To prune:", releases.toPrune.map(i => i.name)); console.log("To keep:", releases.toKeep.map(i => i.name)); })(); ``` ``` $ node index.mjs Pruning old prereleases To prune: [ 'Nightly (2023-11-01)' ] To keep: [ 'Nightly (2024-01-12)', 'Nightly (2023-12-02)', 'Nightly (2023-11-02)', 'Nightly (2023-10-02)', 'Nightly (2023-08-02)', 'Nightly (2023-07-02)', 'Nightly (2023-06-02)', 'Nightly (2023-05-02)', 'Nightly (2023-04-02)', 'Nightly (2023-03-02)', 'Nightly (2023-01-03)' ] ``` * Update prune-prereleases.js * Update prune-prereleases.js * Update prune-prereleases.js --- .github/scripts/prune-prereleases.js | 43 +++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/scripts/prune-prereleases.js b/.github/scripts/prune-prereleases.js index 0537fbf1380ae..bbdb0696f516e 100644 --- a/.github/scripts/prune-prereleases.js +++ b/.github/scripts/prune-prereleases.js @@ -1,3 +1,23 @@ +// In case node 21 is not used. +function groupBy(array, keyOrIterator) { + var iterator; + + // use the function passed in, or create one + if(typeof keyOrIterator !== 'function') { + const key = String(keyOrIterator); + iterator = function (item) { return item[key]; }; + } else { + iterator = keyOrIterator; + } + + return array.reduce(function (memo, item) { + const key = iterator(item); + memo[key] = memo[key] || []; + memo[key].push(item); + return memo; + }, {}); +} + module.exports = async ({ github, context }) => { console.log("Pruning old prereleases"); @@ -11,16 +31,25 @@ module.exports = async ({ github, context }) => { release => // Only consider releases tagged `nightly-${SHA}` for deletion release.tag_name.includes("nightly") && - release.tag_name !== "nightly" && - // ref: https://github.com/foundry-rs/foundry/issues/3881 - // Skipping pruning the build on 1st day of each month - !release.created_at.includes("-01T") + release.tag_name !== "nightly" ); - // Keep newest 3 nightlies - nightlies = nightlies.slice(3); + // Pruning rules: + // 1. only keep the earliest (by created_at) release of the month + // 2. to keep the newest 3 nightlies + // Notes: + // - This addresses https://github.com/foundry-rs/foundry/issues/6732 + // - Name of the release may deviate from created_at due to the usage of different timezones. + + // Group releases by months. + // Per doc: + // > The latest release is the most recent non-prerelease, non-draft release, sorted by the created_at attribute. + const groups = groupBy(nightlies, i => i.created_at.slice(0, 7)); + const nightliesToPrune = Object.values(groups) + .reduce((acc, cur) => acc.concat(cur.slice(0, -1)), []) // rule 1 + .slice(3); // rule 2 - for (const nightly of nightlies) { + for (const nightly of nightliesToPrune) { console.log(`Deleting nightly: ${nightly.tag_name}`); await github.rest.repos.deleteRelease({ owner: context.repo.owner, From 62179f7690710487c3f336b66aa6b66a9c180362 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:23:45 +0100 Subject: [PATCH 0487/1963] chore(deps): remove patch in favor of git deps (#6799) --- Cargo.lock | 60 +++++++++++++++++++++++++----------------------------- Cargo.toml | 41 ++++++++++++------------------------- 2 files changed, 41 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c04981ad91df3..0b4bcdec40b1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-primitives", "serde", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -252,7 +252,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" +source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1419,9 +1419,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.16" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e54881c004cec7895b0068a0a954cd5d62da01aef83fa35b1e594497bf5445" +checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" dependencies = [ "clap_builder", "clap_derive", @@ -1429,9 +1429,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.16" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59cb82d7f531603d2fd1f507441cdd35184fa81beff7bd489570de7f773460bb" +checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" dependencies = [ "anstream", "anstyle", @@ -1444,9 +1444,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97aeaa95557bd02f23fbb662f981670c3d20c5a26e69f7354b28f57092437fcd" +checksum = "dfb0d4825b75ff281318c393e8e1b80c4da9fb75a6b1d98547d389d6fe1f48d2" dependencies = [ "clap", ] @@ -3735,9 +3735,9 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e1127ede0475b58f4fe9c0aaa0d9bb0bad2af90bbd93ccd307c8632b863d89" +checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" [[package]] name = "gix-utils" @@ -6101,7 +6101,7 @@ dependencies = [ [[package]] name = "revm" version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" dependencies = [ "auto_impl", "revm-interpreter", @@ -6126,7 +6126,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" dependencies = [ "revm-primitives", "serde", @@ -6135,7 +6135,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6151,7 +6151,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#5ea9d7948bd5cd34bc5fe00e33ae9fcba5340448" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -7976,11 +7976,12 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.8" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cf9c2670809c4840d4648fc7daa396551d7d88966f9ba93821b81a5c0c2d3f5" +checksum = "ec0d895592fa7710eba03fe072e614e3dc6a61ab76ae7ae10d2eb4a7ed5b00ca" dependencies = [ "anyhow", + "cfg-if", "git2", "rustversion", "time", @@ -8584,8 +8585,3 @@ dependencies = [ "cc", "pkg-config", ] - -[[patch.unused]] -name = "alloy-signer" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" diff --git a/Cargo.toml b/Cargo.toml index cac488bd48f61..56593d6a37217 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,19 +144,19 @@ ethers-middleware = { version = "2.0", default-features = false } ethers-solc = { version = "2.0", default-features = false } ## alloy -alloy-consensus = "0.1.0" -alloy-network = "0.1.0" -alloy-json-rpc = "0.1.0" -alloy-providers = "0.1.0" -alloy-pubsub = "0.1.0" -alloy-rpc-client = "0.1.0" -alloy-rpc-trace-types = "0.1.0" -alloy-rpc-types = "0.1.0" -alloy-eips = "0.1.0" -alloy-transport = "0.1.0" -alloy-transport-http = "0.1.0" -alloy-transport-ipc = "0.1.0" -alloy-transport-ws = "0.1.0" +alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } +alloy-network = { git = "https://github.com/alloy-rs/alloy" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" } +alloy-providers = { git = "https://github.com/alloy-rs/alloy" } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" } +alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } alloy-primitives = "0.6.0" alloy-dyn-abi = "0.6.0" alloy-json-abi = "0.6.0" @@ -213,21 +213,6 @@ ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194 ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } -alloy-network = { git = "https://github.com/alloy-rs/alloy" } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" } -alloy-providers = { git = "https://github.com/alloy-rs/alloy" } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-eips = { git = "https://github.com/alloy-rs/alloy" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } - revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } From b3f57f1d74ad106d48d76e81ab5e90549402eed4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:25:29 +0100 Subject: [PATCH 0488/1963] chore(chisel): remove ethers (#6822) --- Cargo.lock | 1 - crates/chisel/Cargo.toml | 2 -- 2 files changed, 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b4bcdec40b1f..62984f0154871 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1330,7 +1330,6 @@ dependencies = [ "clap", "criterion", "dirs 5.0.1", - "ethers-core", "eyre", "forge-fmt", "foundry-cli", diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 7e0cfd1de7d44..ae8f6c5b3e27e 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -31,8 +31,6 @@ alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitr alloy-json-abi.workspace = true alloy-rpc-types.workspace = true -ethers-core.workspace = true - clap = { version = "4", features = ["derive", "env", "wrap_help"] } dirs = "5" eyre.workspace = true From e4de7b7883a61d489613d3ae9d10695fc336e41b Mon Sep 17 00:00:00 2001 From: Bjerg Date: Tue, 16 Jan 2024 18:33:23 +0100 Subject: [PATCH 0489/1963] refactor: replace internal `CallKind` (#6824) * refactor: replace internal `CallKind` * chore: fmt --- Cargo.lock | 4 ++ crates/debugger/Cargo.toml | 1 + crates/debugger/src/tui/context.rs | 8 +-- crates/debugger/src/tui/draw.rs | 3 +- crates/evm/core/Cargo.toml | 1 + crates/evm/core/src/debug.rs | 2 +- crates/evm/core/src/utils.rs | 66 +--------------------- crates/evm/evm/Cargo.toml | 2 +- crates/evm/evm/src/inspectors/debugger.rs | 5 +- crates/forge/Cargo.toml | 2 + crates/forge/bin/cmd/script/transaction.rs | 6 +- 11 files changed, 23 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62984f0154871..d3b288ea1fe10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2846,6 +2846,7 @@ dependencies = [ "rayon", "regex", "reqwest", + "revm-inspectors", "semver 1.0.21", "serde", "serde_json", @@ -3149,6 +3150,7 @@ dependencies = [ "foundry-evm-traces", "ratatui", "revm", + "revm-inspectors", "tracing", ] @@ -3179,6 +3181,7 @@ dependencies = [ "proptest", "rayon", "revm", + "revm-inspectors", "thiserror", "tracing", ] @@ -3209,6 +3212,7 @@ dependencies = [ "once_cell", "parking_lot", "revm", + "revm-inspectors", "serde", "serde_json", "thiserror", diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index a350d34b2cb00..3c1fe8480116e 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -14,6 +14,7 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-evm-core.workspace = true foundry-evm-traces.workspace = true +revm-inspectors.workspace = true alloy-primitives.workspace = true diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index c70bec28f279b..6bcd35d1c9017 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -3,10 +3,8 @@ use crate::{Debugger, ExitReason}; use alloy_primitives::Address; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; -use foundry_evm_core::{ - debug::{DebugNodeFlat, DebugStep}, - utils::CallKind, -}; +use foundry_evm_core::debug::{DebugNodeFlat, DebugStep}; +use revm_inspectors::tracing::types::CallKind; use std::{cell::RefCell, ops::ControlFlow}; /// This is currently used to remember last scroll position so screen doesn't wiggle as much. @@ -271,7 +269,7 @@ impl DebuggerContext<'_> { if let Some(step) = node.steps.iter().position(|step| step.pc == *pc) { self.draw_memory.inner_call_index = i; self.current_step = step; - break + break; } } } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index fe51150714a7b..dd313750259b7 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -4,7 +4,7 @@ use super::context::DebuggerContext; use crate::op::OpcodeParam; use alloy_primitives::U256; use foundry_compilers::sourcemap::SourceElement; -use foundry_evm_core::{debug::Instruction, utils::CallKind}; +use foundry_evm_core::debug::Instruction; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, @@ -13,6 +13,7 @@ use ratatui::{ widgets::{Block, Borders, Paragraph, Wrap}, }; use revm::interpreter::opcode; +use revm_inspectors::tracing::types::CallKind; use std::{cmp, collections::VecDeque, fmt::Write, io}; impl DebuggerContext<'_> { diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 62b59a1f61563..750403cf5d982 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -31,6 +31,7 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", "optimism", ] } +revm-inspectors.workspace = true alloy-providers = { workspace = true } alloy-transport = { workspace = true } alloy-rpc-types = { workspace = true } diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 0312c05a4981a..9981955fda909 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,6 +1,6 @@ -use crate::utils::CallKind; use alloy_primitives::{Address, U256}; use revm::interpreter::OpCode; +use revm_inspectors::tracing::types::CallKind; use serde::{Deserialize, Serialize}; use std::fmt::Display; diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 778b9ba13cdd3..aad717afb133b 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,79 +1,19 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::FixedBytes; use alloy_rpc_types::{Block, Transaction}; -use ethers_core::types::{ActionType, CallType, Chain, H256, U256}; +use ethers_core::types::{Chain, H256, U256}; use eyre::ContextCompat; use foundry_common::types::ToAlloy; use revm::{ - interpreter::{CallScheme, InstructionResult}, - primitives::{CreateScheme, Eval, Halt, SpecId, TransactTo}, + interpreter::InstructionResult, + primitives::{Eval, Halt, SpecId, TransactTo}, }; -use serde::{Deserialize, Serialize}; pub use foundry_compilers::utils::RuntimeOrHandle; pub use revm::primitives::State as StateChangeset; pub use crate::ic::*; -// TODO(onbjerg): Remove this and use `CallKind` from the tracer. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "UPPERCASE")] -#[derive(Default)] -pub enum CallKind { - #[default] - Call, - StaticCall, - CallCode, - DelegateCall, - Create, - Create2, -} - -impl From for CallKind { - fn from(scheme: CallScheme) -> Self { - match scheme { - CallScheme::Call => CallKind::Call, - CallScheme::StaticCall => CallKind::StaticCall, - CallScheme::CallCode => CallKind::CallCode, - CallScheme::DelegateCall => CallKind::DelegateCall, - } - } -} - -impl From for CallKind { - fn from(create: CreateScheme) -> Self { - match create { - CreateScheme::Create => CallKind::Create, - CreateScheme::Create2 { .. } => CallKind::Create2, - } - } -} - -impl From for ActionType { - fn from(kind: CallKind) -> Self { - match kind { - CallKind::Call | CallKind::StaticCall | CallKind::DelegateCall | CallKind::CallCode => { - ActionType::Call - } - CallKind::Create => ActionType::Create, - CallKind::Create2 => ActionType::Create, - } - } -} - -impl From for CallType { - fn from(ty: CallKind) -> Self { - match ty { - CallKind::Call => CallType::Call, - CallKind::StaticCall => CallType::StaticCall, - CallKind::CallCode => CallType::CallCode, - CallKind::DelegateCall => CallType::DelegateCall, - CallKind::Create => CallType::None, - CallKind::Create2 => CallType::None, - } - } -} - /// Small helper function to convert [U256] into [H256]. #[inline] pub fn u256_to_h256_le(u: U256) -> H256 { diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index ccf2cb1ac4fad..dddf79e2a18bc 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -35,7 +35,7 @@ revm = { workspace = true, default-features = false, features = [ "optional_no_base_fee", "arbitrary", ] } - +revm-inspectors.workspace = true ethers-core.workspace = true ethers-signers.workspace = true itertools.workspace = true diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index 32345256ed07e..a43bb2a42b962 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -4,7 +4,7 @@ use foundry_evm_core::{ backend::DatabaseExt, constants::CHEATCODE_ADDRESS, debug::{DebugArena, DebugNode, DebugStep, Instruction}, - utils::{gas_used, CallKind}, + utils::gas_used, }; use revm::{ interpreter::{ @@ -13,6 +13,7 @@ use revm::{ }, EVMData, Inspector, }; +use revm_inspectors::tracing::types::CallKind; /// An inspector that collects debug nodes on every step of the interpreter. #[derive(Clone, Debug, Default)] @@ -127,7 +128,7 @@ impl Inspector for Debugger { // TODO: Does this increase gas cost? if let Err(err) = data.journaled_state.load_account(call.caller, data.db) { let gas = Gas::new(call.gas_limit); - return (InstructionResult::Revert, None, gas, err.abi_encode_revert()) + return (InstructionResult::Revert, None, gas, err.abi_encode_revert()); } let nonce = data.journaled_state.account(call.caller).info.nonce; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 113e2d1f530cc..46d448a656019 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -35,6 +35,8 @@ ethers-middleware.workspace = true ethers-providers.workspace = true ethers-signers.workspace = true +revm-inspectors.workspace = true + comfy-table = "7" eyre.workspace = true proptest = "1" diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index a577702ba8a74..26446bd45e840 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -10,10 +10,8 @@ use foundry_common::{ types::{ToAlloy, ToEthers}, SELECTOR_LEN, }; -use foundry_evm::{ - constants::DEFAULT_CREATE2_DEPLOYER, - traces::{CallKind, CallTraceDecoder}, -}; +use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; +use revm_inspectors::tracing::types::CallKind; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; From f8dfd2c3ae3e6ac829f344a7ab0c229e969b10f7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:38:52 +0100 Subject: [PATCH 0490/1963] refactor(chisel): remove 'errored', make session_source non-optional (#6748) --- Cargo.lock | 1 + crates/chisel/Cargo.toml | 1 + crates/chisel/bin/main.rs | 11 +- crates/chisel/src/dispatcher.rs | 615 ++++++++++++++------------------ crates/chisel/src/session.rs | 11 +- crates/chisel/tests/cache.rs | 10 +- 6 files changed, 290 insertions(+), 359 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3b288ea1fe10..7d49bdea78315 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1332,6 +1332,7 @@ dependencies = [ "dirs 5.0.1", "eyre", "forge-fmt", + "foundry-block-explorers", "foundry-cli", "foundry-common", "foundry-compilers", diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index ae8f6c5b3e27e..b5b3a2167c0e1 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -20,6 +20,7 @@ vergen = { version = "8", default-features = false, features = ["build", "git", [dependencies] # forge forge-fmt.workspace = true +foundry-block-explorers.workspace = true foundry-cli.workspace = true foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["project-util", "full"] } diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 69ae708405c56..a6819ebb6e60e 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -182,8 +182,6 @@ async fn main() -> eyre::Result<()> { // Variable based on status of the last entry let prompt = dispatcher.get_prompt(); - rl.helper_mut().unwrap().set_errored(dispatcher.errored); - // Read the next line let next_string = rl.readline(prompt.as_ref()); @@ -195,7 +193,8 @@ async fn main() -> eyre::Result<()> { interrupt = false; // Dispatch and match results - dispatch_repl_line(&mut dispatcher, &line).await; + let errored = dispatch_repl_line(&mut dispatcher, &line).await; + rl.helper_mut().unwrap().set_errored(errored); } Err(ReadlineError::Interrupted) => { if interrupt { @@ -232,8 +231,9 @@ impl Provider for ChiselParser { } /// Evaluate a single Solidity line. -async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) { - match dispatcher.dispatch(line).await { +async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) -> bool { + let r = dispatcher.dispatch(line).await; + match &r { DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => { debug!(%line, ?msg, "dispatch success"); if let Some(msg) = msg { @@ -249,6 +249,7 @@ async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) { DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => eprintln!("{}", Paint::red(msg)), DispatchResult::Failure(None) => eprintln!("{}\nPlease Report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose", Paint::red("⚒️ Unknown Chisel Error ⚒️")), } + r.is_error() } /// Evaluate multiple Solidity source files contained within a diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 8cd552baee7d6..67329f89c11b4 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -3,9 +3,12 @@ //! This module contains the `ChiselDispatcher` struct, which handles the dispatching //! of both builtin commands and Solidity snippets. -use crate::prelude::{ - ChiselCommand, ChiselResult, ChiselSession, CmdCategory, CmdDescriptor, SessionSourceConfig, - SolidityHelper, +use crate::{ + prelude::{ + ChiselCommand, ChiselResult, ChiselSession, CmdCategory, CmdDescriptor, + SessionSourceConfig, SolidityHelper, + }, + session_source::SessionSource, }; use alloy_json_abi::JsonAbi; use alloy_primitives::{hex, Address}; @@ -23,7 +26,13 @@ use regex::Regex; use reqwest::Url; use serde::{Deserialize, Serialize}; use solang_parser::diagnostics::Diagnostic; -use std::{borrow::Cow, error::Error, io::Write, path::PathBuf, process::Command}; +use std::{ + borrow::Cow, + error::Error, + io::Write, + path::{Path, PathBuf}, + process::Command, +}; use strum::IntoEnumIterator; use tracing::debug; use yansi::Paint; @@ -47,8 +56,6 @@ static ADDRESS_RE: Lazy = Lazy::new(|| Regex::new(r"0x[a-fA-F0-9]{40}").u /// Chisel input dispatcher #[derive(Debug)] pub struct ChiselDispatcher { - /// The status of the previous dispatch - pub errored: bool, /// A Chisel Session pub session: ChiselSession, } @@ -72,6 +79,20 @@ pub enum DispatchResult { FileIoError(Box), } +impl DispatchResult { + /// Returns `true` if the result is an error. + pub fn is_error(&self) -> bool { + matches!( + self, + DispatchResult::Failure(_) | + DispatchResult::CommandFailed(_) | + DispatchResult::UnrecognizedCommand(_) | + DispatchResult::SolangParserFailed(_) | + DispatchResult::FileIoError(_) + ) + } +} + /// A response from the Etherscan API's `getabi` action #[derive(Debug, Serialize, Deserialize)] pub struct EtherscanABIResponse { @@ -113,7 +134,29 @@ pub fn format_source(source: &str, config: FormatterConfig) -> eyre::Result eyre::Result { - ChiselSession::new(config).map(|session| Self { errored: false, session }) + ChiselSession::new(config).map(|session| Self { session }) + } + + /// Returns the optional ID of the current session. + pub fn id(&self) -> Option<&str> { + self.session.id.as_deref() + } + + /// Returns the [`SessionSource`]. + pub fn source(&self) -> &SessionSource { + &self.session.session_source + } + + /// Returns the [`SessionSource`]. + pub fn source_mut(&mut self) -> &mut SessionSource { + &mut self.session.session_source + } + + fn format_source(&self) -> eyre::Result { + format_source( + &self.source().to_repl_source(), + self.source().config.foundry_config.fmt.clone(), + ) } /// Returns the prompt based on the current status of the Dispatcher @@ -188,18 +231,10 @@ impl ChiselDispatcher { std::process::exit(0); } ChiselCommand::Clear => { - if let Some(session_source) = self.session.session_source.as_mut() { - // Drain all source sections - session_source.drain_run(); - session_source.drain_global_code(); - session_source.drain_top_level_code(); - - DispatchResult::CommandSuccess(Some(String::from("Cleared session!"))) - } else { - DispatchResult::CommandFailed( - Paint::red("Session source not present!").to_string(), - ) - } + self.source_mut().drain_run(); + self.source_mut().drain_global_code(); + self.source_mut().drain_top_level_code(); + DispatchResult::CommandSuccess(Some(String::from("Cleared session!"))) } ChiselCommand::Save => { if args.len() <= 1 { @@ -232,15 +267,14 @@ impl ChiselDispatcher { // Use args as the name let name = args[0]; // Try to save the current session before loading another - if let Some(session_source) = &self.session.session_source { - // Don't save an empty session - if !session_source.run_code.is_empty() { - if let Err(e) = self.session.write() { - return DispatchResult::FileIoError(e.into()) - } - println!("{}", Paint::green("Saved current session!")); + // Don't save an empty session + if !self.source().run_code.is_empty() { + if let Err(e) = self.session.write() { + return DispatchResult::FileIoError(e.into()) } + println!("{}", Paint::green("Saved current session!")); } + // Parse the arguments let new_session = match name { "latest" => ChiselSession::latest(), @@ -254,7 +288,7 @@ impl ChiselDispatcher { // SAFETY // Should never panic due to the checks performed when the session was created // in the first place. - new_session.session_source.as_mut().unwrap().build().unwrap(); + new_session.session_source.build().unwrap(); self.session = new_session; DispatchResult::CommandSuccess(Some(format!( @@ -281,23 +315,14 @@ impl ChiselDispatcher { "No sessions found. Use the `!save` command to save a session.", )), }, - ChiselCommand::Source => { - if let Some(session_source) = self.session.session_source.as_ref() { - match format_source( - &session_source.to_repl_source(), - session_source.config.foundry_config.fmt.clone(), - ) { - Ok(formatted_source) => DispatchResult::CommandSuccess(Some( - SolidityHelper::highlight(&formatted_source).into_owned(), - )), - Err(_) => DispatchResult::CommandFailed(String::from( - "Failed to format session source", - )), - } - } else { - DispatchResult::CommandFailed(Self::make_error("Session not present.")) + ChiselCommand::Source => match self.format_source() { + Ok(formatted_source) => DispatchResult::CommandSuccess(Some( + SolidityHelper::highlight(&formatted_source).into_owned(), + )), + Err(_) => { + DispatchResult::CommandFailed(String::from("Failed to format session source")) } - } + }, ChiselCommand::ClearCache => match ChiselSession::clear_cache() { Ok(_) => { self.session.id = None; @@ -306,191 +331,158 @@ impl ChiselDispatcher { Err(_) => DispatchResult::CommandFailed(Self::make_error("Failed to clear cache!")), }, ChiselCommand::Fork => { - if let Some(session_source) = self.session.session_source.as_mut() { - if args.is_empty() || args[0].trim().is_empty() { - session_source.config.evm_opts.fork_url = None; - return DispatchResult::CommandSuccess(Some( - "Now using local environment.".to_string(), - )) - } - if args.len() != 1 { - return DispatchResult::CommandFailed(Self::make_error( - "Must supply a session ID as the argument.", - )) + if args.is_empty() || args[0].trim().is_empty() { + self.source_mut().config.evm_opts.fork_url = None; + return DispatchResult::CommandSuccess(Some( + "Now using local environment.".to_string(), + )) + } + if args.len() != 1 { + return DispatchResult::CommandFailed(Self::make_error( + "Must supply a session ID as the argument.", + )) + } + let arg = *args.first().unwrap(); + + // If the argument is an RPC alias designated in the + // `[rpc_endpoints]` section of the `foundry.toml` within + // the pwd, use the URL matched to the key. + let endpoint = if let Some(endpoint) = + self.source_mut().config.foundry_config.rpc_endpoints.get(arg) + { + endpoint.clone() + } else { + RpcEndpoint::Env(arg.to_string()).into() + }; + let fork_url = match endpoint.resolve() { + Ok(fork_url) => fork_url, + Err(e) => { + return DispatchResult::CommandFailed(Self::make_error(format!( + "\"{}\" ENV Variable not set!", + e.var + ))) } - let arg = *args.first().unwrap(); - - // If the argument is an RPC alias designated in the - // `[rpc_endpoints]` section of the `foundry.toml` within - // the pwd, use the URL matched to the key. - let endpoint = if let Some(endpoint) = - session_source.config.foundry_config.rpc_endpoints.get(arg) - { - endpoint.clone() - } else { - RpcEndpoint::Env(arg.to_string()).into() - }; - let fork_url = match endpoint.resolve() { - Ok(fork_url) => fork_url, - Err(e) => { - return DispatchResult::CommandFailed(Self::make_error(format!( - "\"{}\" ENV Variable not set!", - e.var - ))) - } - }; + }; - // Check validity of URL - if Url::parse(&fork_url).is_err() { - return DispatchResult::CommandFailed(Self::make_error("Invalid fork URL!")) - } + // Check validity of URL + if Url::parse(&fork_url).is_err() { + return DispatchResult::CommandFailed(Self::make_error("Invalid fork URL!")) + } - // Create success message before moving the fork_url - let success_msg = format!("Set fork URL to {}", Paint::yellow(&fork_url)); + // Create success message before moving the fork_url + let success_msg = format!("Set fork URL to {}", Paint::yellow(&fork_url)); - // Update the fork_url inside of the [SessionSourceConfig]'s [EvmOpts] - // field - session_source.config.evm_opts.fork_url = Some(fork_url); + // Update the fork_url inside of the [SessionSourceConfig]'s [EvmOpts] + // field + self.source_mut().config.evm_opts.fork_url = Some(fork_url); - // Clear the backend so that it is re-instantiated with the new fork - // upon the next execution of the session source. - session_source.config.backend = None; + // Clear the backend so that it is re-instantiated with the new fork + // upon the next execution of the session source. + self.source_mut().config.backend = None; - DispatchResult::CommandSuccess(Some(success_msg)) - } else { - DispatchResult::CommandFailed(Self::make_error("Session not present.")) - } + DispatchResult::CommandSuccess(Some(success_msg)) } ChiselCommand::Traces => { - if let Some(session_source) = self.session.session_source.as_mut() { - session_source.config.traces = !session_source.config.traces; - DispatchResult::CommandSuccess(Some(format!( - "{} traces!", - if session_source.config.traces { "Enabled" } else { "Disabled" } - ))) - } else { - DispatchResult::CommandFailed(Self::make_error("Session not present.")) - } + self.source_mut().config.traces = !self.source_mut().config.traces; + DispatchResult::CommandSuccess(Some(format!( + "{} traces!", + if self.source_mut().config.traces { "Enabled" } else { "Disabled" } + ))) } ChiselCommand::Calldata => { - if let Some(session_source) = self.session.session_source.as_mut() { - // remove empty space, double quotes, and 0x prefix - let arg = args - .first() - .map(|s| { - s.trim_matches(|c: char| c.is_whitespace() || c == '"' || c == '\'') - }) - .map(|s| s.strip_prefix("0x").unwrap_or(s)) - .unwrap_or(""); - - if arg.is_empty() { - session_source.config.calldata = None; - return DispatchResult::CommandSuccess(Some("Calldata cleared.".to_string())) - } + // remove empty space, double quotes, and 0x prefix + let arg = args + .first() + .map(|s| s.trim_matches(|c: char| c.is_whitespace() || c == '"' || c == '\'')) + .map(|s| s.strip_prefix("0x").unwrap_or(s)) + .unwrap_or(""); + + if arg.is_empty() { + self.source_mut().config.calldata = None; + return DispatchResult::CommandSuccess(Some("Calldata cleared.".to_string())) + } - let calldata = hex::decode(arg); - match calldata { - Ok(calldata) => { - session_source.config.calldata = Some(calldata); - DispatchResult::CommandSuccess(Some(format!( - "Set calldata to '{}'", - Paint::yellow(arg) - ))) - } - Err(e) => DispatchResult::CommandFailed(Self::make_error(format!( - "Invalid calldata: {}", - e - ))), + let calldata = hex::decode(arg); + match calldata { + Ok(calldata) => { + self.source_mut().config.calldata = Some(calldata); + DispatchResult::CommandSuccess(Some(format!( + "Set calldata to '{}'", + Paint::yellow(arg) + ))) } - } else { - DispatchResult::CommandFailed(Self::make_error("Session not present.")) + Err(e) => DispatchResult::CommandFailed(Self::make_error(format!( + "Invalid calldata: {}", + e + ))), } } ChiselCommand::MemDump | ChiselCommand::StackDump => { - if let Some(session_source) = self.session.session_source.as_mut() { - match session_source.execute().await { - Ok((_, res)) => { - if let Some((stack, mem, _)) = res.state.as_ref() { - if matches!(cmd, ChiselCommand::MemDump) { - // Print memory by word - (0..mem.len()).step_by(32).for_each(|i| { - println!( - "{}: {}", - Paint::yellow(format!( - "[0x{:02x}:0x{:02x}]", - i, - i + 32 - )), - Paint::cyan(hex::encode_prefixed(&mem[i..i + 32])) - ); - }); - } else { - // Print all stack items - (0..stack.len()).rev().for_each(|i| { - println!( - "{}: {}", - Paint::yellow(format!("[{}]", stack.len() - i - 1)), - Paint::cyan(format!("0x{:02x}", stack.data()[i])) - ); - }); - } - DispatchResult::CommandSuccess(None) + match self.source_mut().execute().await { + Ok((_, res)) => { + if let Some((stack, mem, _)) = res.state.as_ref() { + if matches!(cmd, ChiselCommand::MemDump) { + // Print memory by word + (0..mem.len()).step_by(32).for_each(|i| { + println!( + "{}: {}", + Paint::yellow(format!("[0x{:02x}:0x{:02x}]", i, i + 32)), + Paint::cyan(hex::encode_prefixed(&mem[i..i + 32])) + ); + }); } else { - DispatchResult::CommandFailed(Self::make_error( - "Run function is empty.", - )) + // Print all stack items + (0..stack.len()).rev().for_each(|i| { + println!( + "{}: {}", + Paint::yellow(format!("[{}]", stack.len() - i - 1)), + Paint::cyan(format!("0x{:02x}", stack.data()[i])) + ); + }); } + DispatchResult::CommandSuccess(None) + } else { + DispatchResult::CommandFailed(Self::make_error( + "Run function is empty.", + )) } - Err(e) => DispatchResult::CommandFailed(Self::make_error(e.to_string())), } - } else { - DispatchResult::CommandFailed(Self::make_error("Session not present.")) + Err(e) => DispatchResult::CommandFailed(Self::make_error(e.to_string())), } } ChiselCommand::Export => { // Check if the current session inherits `Script.sol` before exporting - if let Some(session_source) = self.session.session_source.as_ref() { - // Check if the pwd is a foundry project - if PathBuf::from("foundry.toml").exists() { - // Create "script" dir if it does not already exist. - if !PathBuf::from("script").exists() { - if let Err(e) = std::fs::create_dir_all("script") { - return DispatchResult::CommandFailed(Self::make_error( - e.to_string(), - )) - } - } - match format_source( - &session_source.to_script_source(), - session_source.config.foundry_config.fmt.clone(), - ) { - Ok(formatted_source) => { - // Write session source to `script/REPL.s.sol` - if let Err(e) = std::fs::write( - PathBuf::from("script/REPL.s.sol"), - formatted_source, - ) { - return DispatchResult::CommandFailed(Self::make_error( - e.to_string(), - )) - } + // Check if the pwd is a foundry project + if !Path::new("foundry.toml").exists() { + return DispatchResult::CommandFailed(Self::make_error( + "Must be in a foundry project to export source to script.", + )); + } - DispatchResult::CommandSuccess(Some(String::from( - "Exported session source to script/REPL.s.sol!", - ))) - } - Err(_) => DispatchResult::CommandFailed(String::from( - "Failed to format session source", - )), + // Create "script" dir if it does not already exist. + if !Path::new("script").exists() { + if let Err(e) = std::fs::create_dir_all("script") { + return DispatchResult::CommandFailed(Self::make_error(e.to_string())) + } + } + + match self.format_source() { + Ok(formatted_source) => { + // Write session source to `script/REPL.s.sol` + if let Err(e) = + std::fs::write(PathBuf::from("script/REPL.s.sol"), formatted_source) + { + return DispatchResult::CommandFailed(Self::make_error(e.to_string())) } - } else { - DispatchResult::CommandFailed(Self::make_error( - "Must be in a foundry project to export source to script.", - )) + + DispatchResult::CommandSuccess(Some(String::from( + "Exported session source to script/REPL.s.sol!", + ))) } - } else { - DispatchResult::CommandFailed(Self::make_error("Session not present.")) + Err(_) => DispatchResult::CommandFailed(String::from( + "Failed to format session source", + )), } } ChiselCommand::Fetch => { @@ -503,15 +495,8 @@ impl ChiselDispatcher { let request_url = format!( "https://api.etherscan.io/api?module=contract&action=getabi&address={}{}", args[0], - if let Some(api_key) = self - .session - .session_source - .as_ref() - .unwrap() - .config - .foundry_config - .etherscan_api_key - .as_ref() + if let Some(api_key) = + self.source().config.foundry_config.etherscan_api_key.as_ref() { format!("&apikey={api_key}") } else { @@ -602,11 +587,7 @@ impl ChiselDispatcher { // Add the interface to the source outright - no need to verify // syntax via compilation and/or // parsing. - self.session - .session_source - .as_mut() - .unwrap() - .with_global_code(&interface); + self.source_mut().with_global_code(&interface); DispatchResult::CommandSuccess(Some(format!( "Added {}'s interface to source as `{}`", @@ -653,97 +634,91 @@ impl ChiselDispatcher { } } ChiselCommand::Edit => { - if let Some(session_source) = self.session.session_source.as_mut() { - // create a temp file with the content of the run code - let mut temp_file_path = std::env::temp_dir(); - temp_file_path.push("chisel-tmp.sol"); - let result = std::fs::File::create(&temp_file_path) - .map(|mut file| file.write_all(session_source.run_code.as_bytes())); - if let Err(e) = result { - return DispatchResult::CommandFailed(format!( - "Could not write to a temporary file: {e}" - )) - } + // create a temp file with the content of the run code + let mut temp_file_path = std::env::temp_dir(); + temp_file_path.push("chisel-tmp.sol"); + let result = std::fs::File::create(&temp_file_path) + .map(|mut file| file.write_all(self.source().run_code.as_bytes())); + if let Err(e) = result { + return DispatchResult::CommandFailed(format!( + "Could not write to a temporary file: {e}" + )) + } - // open the temp file with the editor - let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vim".to_string()); - let mut cmd = Command::new(editor); - cmd.arg(&temp_file_path); - - match cmd.status() { - Ok(status) => { - if !status.success() { - if let Some(status_code) = status.code() { - return DispatchResult::CommandFailed(format!( - "Editor exited with status {status_code}" - )) - } else { - return DispatchResult::CommandFailed( - "Editor exited without a status code".to_string(), - ) - } + // open the temp file with the editor + let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vim".to_string()); + let mut cmd = Command::new(editor); + cmd.arg(&temp_file_path); + + match cmd.status() { + Ok(status) => { + if !status.success() { + if let Some(status_code) = status.code() { + return DispatchResult::CommandFailed(format!( + "Editor exited with status {status_code}" + )) + } else { + return DispatchResult::CommandFailed( + "Editor exited without a status code".to_string(), + ) } } - Err(_) => { - return DispatchResult::CommandFailed( - "Editor exited without a status code".to_string(), - ) - } } - - let mut new_session_source = session_source.clone(); - if let Ok(edited_code) = std::fs::read_to_string(temp_file_path) { - new_session_source.drain_run(); - new_session_source.with_run_code(&edited_code); - } else { + Err(_) => { return DispatchResult::CommandFailed( - "Could not read the edited file".to_string(), + "Editor exited without a status code".to_string(), ) } + } - // if the editor exited successfully, try to compile the new code - match new_session_source.execute().await { - Ok((_, mut res)) => { - let failed = !res.success; - if new_session_source.config.traces || failed { - if let Ok(decoder) = - Self::decode_traces(&new_session_source.config, &mut res) - { - if let Err(e) = Self::show_traces(&decoder, &mut res).await { - self.errored = true; - return DispatchResult::CommandFailed(e.to_string()) - }; - - // Show console logs, if there are any - let decoded_logs = decode_console_logs(&res.logs); - if !decoded_logs.is_empty() { - println!("{}", Paint::green("Logs:")); - for log in decoded_logs { - println!(" {log}"); - } + let mut new_session_source = self.source().clone(); + if let Ok(edited_code) = std::fs::read_to_string(temp_file_path) { + new_session_source.drain_run(); + new_session_source.with_run_code(&edited_code); + } else { + return DispatchResult::CommandFailed( + "Could not read the edited file".to_string(), + ) + } + + // if the editor exited successfully, try to compile the new code + match new_session_source.execute().await { + Ok((_, mut res)) => { + let failed = !res.success; + if new_session_source.config.traces || failed { + if let Ok(decoder) = + Self::decode_traces(&new_session_source.config, &mut res) + { + if let Err(e) = Self::show_traces(&decoder, &mut res).await { + return DispatchResult::CommandFailed(e.to_string()) + }; + + // Show console logs, if there are any + let decoded_logs = decode_console_logs(&res.logs); + if !decoded_logs.is_empty() { + println!("{}", Paint::green("Logs:")); + for log in decoded_logs { + println!(" {log}"); } } - - // If the contract execution failed, continue on without - // updating the source. - self.errored = true; - DispatchResult::CommandFailed(Self::make_error( - "Failed to execute edited contract!", - )) - } else { - // the code could be compiled, save it - *session_source = new_session_source; - DispatchResult::CommandSuccess(Some(String::from( - "Successfully edited `run()` function's body!", - ))) } + + // If the contract execution failed, continue on without + // updating the source. + DispatchResult::CommandFailed(Self::make_error( + "Failed to execute edited contract!", + )) + } else { + // the code could be compiled, save it + *self.source_mut() = new_session_source; + DispatchResult::CommandSuccess(Some(String::from( + "Successfully edited `run()` function's body!", + ))) } - Err(_) => DispatchResult::CommandFailed( - "The code could not be compiled".to_string(), - ), } - } else { - DispatchResult::CommandFailed(Self::make_error("Session not present.")) + Err(_) => { + DispatchResult::CommandFailed("The code could not be compiled".to_string()) + } } } ChiselCommand::RawStack => { @@ -760,14 +735,7 @@ impl ChiselDispatcher { let to_inspect = args.first().unwrap(); // Get a mutable reference to the session source - let source = match self.session.session_source.as_mut() { - Some(session_source) => session_source, - _ => { - return DispatchResult::CommandFailed( - "Session source not present".to_string(), - ) - } - }; + let source = self.source_mut(); // Copy the variable's stack contents into a bytes32 variable without updating // the current session source. @@ -796,15 +764,8 @@ impl ChiselDispatcher { let raw_cmd = &split[0][1..]; return match raw_cmd.parse::() { - Ok(cmd) => { - let command_dispatch = self.dispatch_command(cmd, &split[1..]).await; - self.errored = !matches!(command_dispatch, DispatchResult::CommandSuccess(_)); - command_dispatch - } - Err(e) => { - self.errored = true; - DispatchResult::UnrecognizedCommand(e) - } + Ok(cmd) => self.dispatch_command(cmd, &split[1..]).await, + Err(e) => DispatchResult::UnrecognizedCommand(e), } } if input.trim().is_empty() { @@ -813,14 +774,7 @@ impl ChiselDispatcher { } // Get a mutable reference to the session source - let source = match self.session.session_source.as_mut().ok_or(DispatchResult::Failure(None)) - { - Ok(project) => project, - Err(e) => { - self.errored = true; - return e - } - }; + let source = self.source_mut(); // If the input is a comment, add it to the run code so we avoid running with empty input if COMMENT_RE.is_match(input) { @@ -847,7 +801,6 @@ impl ChiselDispatcher { let (mut new_source, do_execute) = match source.clone_with_new_line(input.to_string()) { Ok(new) => new, Err(e) => { - self.errored = true; return DispatchResult::CommandFailed(Self::make_error(format!( "Failed to parse input! {e}" ))) @@ -867,10 +820,7 @@ impl ChiselDispatcher { } // Return with the error - Err(e) => { - self.errored = true; - return DispatchResult::CommandFailed(Self::make_error(e)) - } + Err(e) => return DispatchResult::CommandFailed(Self::make_error(e)), } if do_execute { @@ -883,7 +833,6 @@ impl ChiselDispatcher { if new_source.config.traces || failed { if let Ok(decoder) = Self::decode_traces(&new_source.config, &mut res) { if let Err(e) = Self::show_traces(&decoder, &mut res).await { - self.errored = true; return DispatchResult::CommandFailed(e.to_string()) }; @@ -899,7 +848,6 @@ impl ChiselDispatcher { // If the contract execution failed, continue on without adding the new // line to the source. if failed { - self.errored = true; return DispatchResult::Failure(Some(Self::make_error( "Failed to execute REPL contract!", ))) @@ -908,29 +856,20 @@ impl ChiselDispatcher { } // Replace the old session source with the new version - self.session.session_source = Some(new_source); - // Clear any outstanding errors - self.errored = false; + *self.source_mut() = new_source; DispatchResult::Success(None) } - Err(e) => { - self.errored = true; - DispatchResult::Failure(Some(e.to_string())) - } + Err(e) => DispatchResult::Failure(Some(e.to_string())), } } else { match new_source.build() { Ok(out) => { debug!(%input, ?out, "skipped execute and rebuild source"); - self.session.session_source = Some(new_source); - self.errored = false; + *self.source_mut() = new_source; DispatchResult::Success(None) } - Err(e) => { - self.errored = true; - DispatchResult::Failure(Some(e.to_string())) - } + Err(e) => DispatchResult::Failure(Some(e.to_string())), } } } diff --git a/crates/chisel/src/session.rs b/crates/chisel/src/session.rs index f0f1debd5a705..3be34a179cc90 100644 --- a/crates/chisel/src/session.rs +++ b/crates/chisel/src/session.rs @@ -13,7 +13,7 @@ use time::{format_description, OffsetDateTime}; #[derive(Debug, Serialize, Deserialize)] pub struct ChiselSession { /// The `SessionSource` object that houses the REPL session. - pub session_source: Option, + pub session_source: SessionSource, /// The current session's identifier pub id: Option, } @@ -31,9 +31,8 @@ impl ChiselSession { /// A new instance of [ChiselSession] pub fn new(config: SessionSourceConfig) -> Result { let solc = config.solc()?; - // Return initialized ChiselSession with set solc version - Ok(Self { session_source: Some(SessionSource::new(solc, config)), id: None }) + Ok(Self { session_source: SessionSource::new(solc, config), id: None }) } /// Render the full source code for the current session. @@ -47,11 +46,7 @@ impl ChiselSession { /// This function will not panic, but will return a blank string if the /// session's [SessionSource] is None. pub fn contract_source(&self) -> String { - if let Some(source) = &self.session_source { - source.to_repl_source() - } else { - String::default() - } + self.session_source.to_repl_source() } /// Clears the cache directory diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index dda53cd62382c..ff5fe60fc91b6 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -163,10 +163,7 @@ fn test_load_cache() { assert!(new_env.is_ok()); let new_env = new_env.unwrap(); assert_eq!(new_env.id.unwrap(), String::from("0")); - assert_eq!( - new_env.session_source.unwrap().to_repl_source(), - env.session_source.unwrap().to_repl_source() - ); + assert_eq!(new_env.session_source.to_repl_source(), env.session_source.to_repl_source()); } #[test] @@ -225,8 +222,5 @@ fn test_load_latest_cache() { // Validate the session assert_eq!(new_env.id.unwrap(), "1"); - assert_eq!( - new_env.session_source.unwrap().to_repl_source(), - env.session_source.unwrap().to_repl_source() - ); + assert_eq!(new_env.session_source.to_repl_source(), env.session_source.to_repl_source()); } From 0f68fa918eef45526dc8478ef6f50e7def1935ae Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:49:19 +0100 Subject: [PATCH 0491/1963] chore(evm): rm more etherses (#6823) --- Cargo.lock | 28 +++++------ Cargo.toml | 6 ++- crates/anvil/src/eth/backend/mem/mod.rs | 4 +- crates/evm/core/Cargo.toml | 7 +-- crates/evm/core/src/fork/multi.rs | 24 ++++++---- crates/evm/core/src/utils.rs | 47 ++++--------------- crates/evm/evm/Cargo.toml | 3 +- .../evm/evm/src/executors/invariant/error.rs | 2 +- 8 files changed, 50 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d49bdea78315..a913af40aae83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-primitives", "serde", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -252,7 +252,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#87de288dd3e6258ff634ce147f5fd06382d29660" +source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -3165,7 +3165,6 @@ dependencies = [ "alloy-rpc-types", "alloy-sol-types", "const-hex", - "ethers-core", "ethers-signers", "eyre", "foundry-cheatcodes", @@ -3180,6 +3179,7 @@ dependencies = [ "itertools 0.11.0", "parking_lot", "proptest", + "rand 0.8.5", "rayon", "revm", "revm-inspectors", diff --git a/Cargo.toml b/Cargo.toml index 56593d6a37217..3c4d6f16cc9bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -145,14 +145,16 @@ ethers-solc = { version = "2.0", default-features = false } ## alloy alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } -alloy-network = { git = "https://github.com/alloy-rs/alloy" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy" } alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" } +alloy-network = { git = "https://github.com/alloy-rs/alloy" } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy" } alloy-providers = { git = "https://github.com/alloy-rs/alloy" } alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-eips = { git = "https://github.com/alloy-rs/alloy" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy" } alloy-transport = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 81395f40d0504..f3ae13126de29 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -74,7 +74,7 @@ use foundry_evm::{ }, }, traces::{TracingInspector, TracingInspectorConfig}, - utils::{eval_to_instruction_result, halt_to_instruction_result, u256_to_h256_be}, + utils::{eval_to_instruction_result, halt_to_instruction_result}, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; use hash_db::HashDB; @@ -1757,7 +1757,7 @@ impl Backend { self.with_database_at(block_request, |db, _| { trace!(target: "backend", "get storage for {:?} at {:?}", address, index); let val = db.storage_ref(address, index)?; - Ok(u256_to_h256_be(val.to_ethers()).to_alloy()) + Ok(val.into()) }) .await? } diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 750403cf5d982..97b9f77a40f2a 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -20,7 +20,11 @@ foundry-macros.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-providers.workspace = true +alloy-rpc-types.workspace = true alloy-sol-types.workspace = true +alloy-transport.workspace = true + revm = { workspace = true, default-features = false, features = [ "std", "serde", @@ -32,9 +36,6 @@ revm = { workspace = true, default-features = false, features = [ "optimism", ] } revm-inspectors.workspace = true -alloy-providers = { workspace = true } -alloy-transport = { workspace = true } -alloy-rpc-types = { workspace = true } ethers-core.workspace = true ethers-providers.workspace = true diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index acf5095471868..483686980833c 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -6,7 +6,6 @@ use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; use alloy_providers::provider::Provider; use alloy_transport::BoxTransport; -use ethers_core::types::BlockNumber; use foundry_common::provider::alloy::ProviderBuilder; use foundry_config::Config; use futures::{ @@ -18,7 +17,7 @@ use futures::{ use revm::primitives::Env; use std::{ collections::HashMap, - fmt, + fmt::{self, Write}, pin::Pin, sync::{ atomic::AtomicUsize, @@ -34,7 +33,18 @@ use std::{ pub struct ForkId(pub String); impl ForkId { - /// Returns the identifier of the fork + /// Returns the identifier for a Fork from a URL and block number. + pub fn new(url: &str, num: Option) -> Self { + let mut id = url.to_string(); + id.push('@'); + match num { + Some(n) => write!(id, "{n:#x}").unwrap(), + None => id.push_str("latest"), + } + ForkId(id) + } + + /// Returns the identifier of the fork. pub fn as_str(&self) -> &str { &self.0 } @@ -245,7 +255,7 @@ impl MultiForkHandler { } fn create_fork(&mut self, fork: CreateFork, sender: CreateSender) { - let fork_id = create_fork_id(&fork.url, fork.evm_opts.fork_block_number); + let fork_id = ForkId::new(&fork.url, fork.evm_opts.fork_block_number); trace!(?fork_id, "created new forkId"); if let Some(fork) = self.forks.get(&fork_id).cloned() { @@ -470,12 +480,6 @@ impl Drop for ShutDownMultiFork { } } -/// Returns the identifier for a Fork which consists of the url and the block number -fn create_fork_id(url: &str, num: Option) -> ForkId { - let num = num.map(|num| BlockNumber::Number(num.into())).unwrap_or(BlockNumber::Latest); - ForkId(format!("{url}@{num}")) -} - /// Creates a new fork /// /// This will establish a new `Provider` to the endpoint and return the Fork Backend diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index aad717afb133b..e0f0f1ee80f48 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,9 +1,8 @@ use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::FixedBytes; +use alloy_primitives::{FixedBytes, U256}; use alloy_rpc_types::{Block, Transaction}; -use ethers_core::types::{Chain, H256, U256}; use eyre::ContextCompat; -use foundry_common::types::ToAlloy; +use foundry_config::NamedChain; use revm::{ interpreter::InstructionResult, primitives::{Eval, Halt, SpecId, TransactTo}, @@ -14,34 +13,6 @@ pub use revm::primitives::State as StateChangeset; pub use crate::ic::*; -/// Small helper function to convert [U256] into [H256]. -#[inline] -pub fn u256_to_h256_le(u: U256) -> H256 { - let mut h = H256::default(); - u.to_little_endian(h.as_mut()); - h -} - -/// Small helper function to convert [U256] into [H256]. -#[inline] -pub fn u256_to_h256_be(u: U256) -> H256 { - let mut h = H256::default(); - u.to_big_endian(h.as_mut()); - h -} - -/// Small helper function to convert [H256] into [U256]. -#[inline] -pub fn h256_to_u256_be(storage: H256) -> U256 { - U256::from_big_endian(storage.as_bytes()) -} - -/// Small helper function to convert [H256] into [U256]. -#[inline] -pub fn h256_to_u256_le(storage: H256) -> U256 { - U256::from_little_endian(storage.as_bytes()) -} - /// Small helper function to convert an Eval into an InstructionResult #[inline] pub fn eval_to_instruction_result(eval: Eval) -> InstructionResult { @@ -84,11 +55,11 @@ pub fn halt_to_instruction_result(halt: Halt) -> InstructionResult { /// This checks for: /// - prevrandao mixhash after merge pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::Env, block: &Block) { - if let Ok(chain) = Chain::try_from(env.cfg.chain_id) { + if let Ok(chain) = NamedChain::try_from(env.cfg.chain_id) { let block_number = block.header.number.unwrap_or_default(); match chain { - Chain::Mainnet => { + NamedChain::Mainnet => { // after merge difficulty is supplanted with prevrandao EIP-4399 if block_number.to::() >= 15_537_351u64 { env.block.difficulty = env.block.prevrandao.unwrap_or_default().into(); @@ -96,15 +67,15 @@ pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::En return; } - Chain::Arbitrum | - Chain::ArbitrumGoerli | - Chain::ArbitrumNova | - Chain::ArbitrumTestnet => { + NamedChain::Arbitrum | + NamedChain::ArbitrumGoerli | + NamedChain::ArbitrumNova | + NamedChain::ArbitrumTestnet => { // on arbitrum `block.number` is the L1 block which is included in the // `l1BlockNumber` field if let Some(l1_block_number) = block.other.get("l1BlockNumber").cloned() { if let Ok(l1_block_number) = serde_json::from_value::(l1_block_number) { - env.block.number = l1_block_number.to_alloy(); + env.block.number = l1_block_number; } } } diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index dddf79e2a18bc..0ad1d709e05ff 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -36,7 +36,7 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } revm-inspectors.workspace = true -ethers-core.workspace = true + ethers-signers.workspace = true itertools.workspace = true @@ -47,3 +47,4 @@ proptest = "1" thiserror = "1" tracing = "0.1" rayon = "1" +rand.workspace = true diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 1f4c87c8d5926..7dd67289a5beb 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -2,7 +2,6 @@ use super::{BasicTxDetails, InvariantContract}; use crate::executors::{Executor, RawCallResult}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log}; -use ethers_core::rand::{seq, thread_rng, Rng}; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::{constants::CALLER, decode::decode_revert}; @@ -11,6 +10,7 @@ use foundry_evm_traces::{load_contracts, CallTraceArena, TraceKind, Traces}; use itertools::Itertools; use parking_lot::RwLock; use proptest::test_runner::TestError; +use rand::{seq, thread_rng, Rng}; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use revm::primitives::U256; use std::sync::Arc; From 156cb1396b7076c6f9cb56f3719f8c90f7f52064 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 16 Jan 2024 22:13:14 +0100 Subject: [PATCH 0492/1963] test: add sanity test for with gas price (#6826) --- crates/forge/bin/cmd/script/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index b1e3e1c301ccf..9dae655b5a71f 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -953,4 +953,17 @@ mod tests { ScriptArgs::parse_from(["foundry-cli", "DeployV1", "--priority-gas-price", "100"]); assert!(args.priority_gas_price.is_some()); } + + // + #[test] + fn test_5910() { + let args: ScriptArgs = ScriptArgs::parse_from([ + "foundry-cli", + "--broadcast", + "--with-gas-price", + "0", + "SolveTutorial", + ]); + assert!(args.with_gas_price.unwrap().is_zero()); + } } From 02f1c1ed723bd7b66017976aaf461634768d3bef Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 17 Jan 2024 12:31:42 +0100 Subject: [PATCH 0493/1963] chore: replace some from with try_from calls (#6832) --- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/run.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index c3352cab35b85..6089f0153fd78 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -80,7 +80,7 @@ impl EstimateArgs { let EstimateArgs { from, to, sig, args, value, rpc, etherscan, command } = self; let figment = Figment::from(Config::figment()).merge(etherscan).merge(rpc); - let config = Config::from_provider(figment); + let config = Config::try_from(figment)?; let provider = utils::get_provider(&config)?; let chain = utils::get_chain(config.chain, &provider).await?; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 8f13706e647b8..fb7ae35cba073 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -82,7 +82,7 @@ impl RunArgs { let figment = Config::figment_with_root(find_project_root_path(None).unwrap()).merge(self.rpc); let evm_opts = figment.extract::()?; - let mut config = Config::from_provider(figment).sanitized(); + let mut config = Config::try_from(figment)?.sanitized(); let compute_units_per_second = if self.no_rate_limit { Some(u64::MAX) } else { self.compute_units_per_second }; From 9e2830d7f0566e0d00b1104eeaedd5032a4e556e Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 17 Jan 2024 18:40:39 +0300 Subject: [PATCH 0494/1963] feat: vm.dumpState (#6827) * feat: vm.dumpState Implements a cheatcode `vm.dumpState(string)` that dumps the current revm state to disk in the same format as the "allocs" field in a geth style `genesis.json`. This can dump state that can be read in by `vm.loadAllocs(string)`. The implementation of the cheatcode skips dumping system contracts. It includes various test coverage. * solidity: forge fmt * spec: update Run `cargo test` from within the specs crate * dumpstate: cleanup Better implementation based on review --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++ crates/cheatcodes/spec/src/vm.rs | 4 + crates/cheatcodes/src/evm.rs | 65 +++++++++++- testdata/cheats/Vm.sol | 1 + testdata/cheats/dumpState.t.sol | 123 +++++++++++++++++++++++ 5 files changed, 210 insertions(+), 3 deletions(-) create mode 100644 testdata/cheats/dumpState.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 7819914cba8cc..a88ebf3b52329 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -1153,6 +1153,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "dumpState", + "description": "Dump a genesis JSON file's `allocs` to disk.", + "declaration": "function dumpState(string calldata pathToStateJson) external;", + "visibility": "external", + "mutability": "", + "signature": "dumpState(string)", + "selector": "0x709ecd3f", + "selectorBytes": [ + 112, + 158, + 205, + 63 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "envAddress_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index d1611222d54b6..5178bd83d8247 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -227,6 +227,10 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function addr(uint256 privateKey) external pure returns (address keyAddr); + /// Dump a genesis JSON file's `allocs` to disk. + #[cheatcode(group = Evm, safety = Unsafe)] + function dumpState(string calldata pathToStateJson) external; + /// Gets the nonce of an account. #[cheatcode(group = Evm, safety = Safe)] function getNonce(address account) external view returns (uint64 nonce); diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 24e26def0efd8..94a15e6cbb9d9 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -3,10 +3,19 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, Bytes, U256}; use alloy_sol_types::SolValue; -use ethers_core::utils::{Genesis, GenesisAccount}; +use ethers_core::{ + types::H256, + utils::{Genesis, GenesisAccount}, +}; use ethers_signers::Signer; -use foundry_common::{fs::read_json_file, types::ToAlloy}; -use foundry_evm_core::backend::{DatabaseExt, RevertSnapshotAction}; +use foundry_common::{ + fs::{read_json_file, write_json_file}, + types::{ToAlloy, ToEthers}, +}; +use foundry_evm_core::{ + backend::{DatabaseExt, RevertSnapshotAction}, + constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS}, +}; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, EVMData, @@ -86,6 +95,56 @@ impl Cheatcode for loadAllocsCall { } } +impl Cheatcode for dumpStateCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { pathToStateJson } = self; + let path = Path::new(pathToStateJson); + + // Do not include system accounts in the dump. + let skip = |key: &Address| { + key == &CHEATCODE_ADDRESS || + key == &CALLER || + key == &HARDHAT_CONSOLE_ADDRESS || + key == &TEST_CONTRACT_ADDRESS || + key == &ccx.caller || + key == &ccx.state.config.evm_opts.sender + }; + + let alloc = ccx + .data + .journaled_state + .state() + .into_iter() + .filter(|(key, _)| !skip(key)) + .map(|(key, val)| { + ( + key, + GenesisAccount { + nonce: Some(val.info.nonce), + balance: val.info.balance.to_ethers(), + code: Some( + val.info.code.clone().unwrap_or_default().original_bytes().to_ethers(), + ), + storage: Some( + val.storage + .iter() + .map(|(k, v)| { + let key = k.to_be_bytes::<32>(); + let val = v.present_value().to_be_bytes::<32>(); + (H256::from_slice(&key), H256::from_slice(&val)) + }) + .collect(), + ), + }, + ) + }) + .collect::>(); + + write_json_file(path, &alloc)?; + Ok(Default::default()) + } +} + impl Cheatcode for sign_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey, digest } = self; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 78ca56eda8359..237b68db8835a 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -55,6 +55,7 @@ interface Vm { 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 envAddress(string calldata name) external view returns (address value); function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value); function envBool(string calldata name) external view returns (bool value); diff --git a/testdata/cheats/dumpState.t.sol b/testdata/cheats/dumpState.t.sol new file mode 100644 index 0000000000000..51d6eb38ab8fc --- /dev/null +++ b/testdata/cheats/dumpState.t.sol @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract SimpleContract { + constructor() { + assembly { + sstore(1, 2) + } + } +} + +contract DumpStateTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testDumpStateCheatAccount() public { + // Path to temporary file that is deleted after the test + string memory path = string.concat(vm.projectRoot(), "/fixtures/Json/test_dump_state_cheat.json"); + + // Define some values to set in the state using cheatcodes + address target = address(1001); + bytes memory bytecode = hex"11223344"; + uint256 balance = 1.2 ether; + uint64 nonce = 45; + + vm.etch(target, bytecode); + vm.deal(target, balance); + vm.setNonce(target, nonce); + vm.store(target, bytes32(uint256(0x20)), bytes32(uint256(0x40))); + vm.store(target, bytes32(uint256(0x40)), bytes32(uint256(0x60))); + + // Write the state to disk + vm.dumpState(path); + + string memory json = vm.readFile(path); + string[] memory keys = vm.parseJsonKeys(json, ""); + assertEq(keys.length, 1); + + string memory key = keys[0]; + assertEq(nonce, vm.parseJsonUint(json, string.concat(".", key, ".nonce"))); + assertEq(balance, vm.parseJsonUint(json, string.concat(".", key, ".balance"))); + assertEq(bytecode, vm.parseJsonBytes(json, string.concat(".", key, ".code"))); + + string[] memory slots = vm.parseJsonKeys(json, string.concat(".", key, ".storage")); + assertEq(slots.length, 2); + + assertEq( + bytes32(uint256(0x40)), + vm.parseJsonBytes32(json, string.concat(".", key, ".storage.", vm.toString(bytes32(uint256(0x20))))) + ); + assertEq( + bytes32(uint256(0x60)), + vm.parseJsonBytes32(json, string.concat(".", key, ".storage.", vm.toString(bytes32(uint256(0x40))))) + ); + + vm.removeFile(path); + } + + function testDumpStateMultipleAccounts() public { + string memory path = string.concat(vm.projectRoot(), "/fixtures/Json/test_dump_state_multiple_accounts.json"); + + vm.setNonce(address(0x100), 1); + vm.deal(address(0x200), 1 ether); + vm.store(address(0x300), bytes32(uint256(1)), bytes32(uint256(2))); + vm.etch(address(0x400), hex"af"); + + vm.dumpState(path); + + string memory json = vm.readFile(path); + string[] memory keys = vm.parseJsonKeys(json, ""); + assertEq(keys.length, 4); + + assertEq(4, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x100)))).length); + assertEq(1, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x100)), ".nonce"))); + assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x100)), ".balance"))); + assertEq(hex"", vm.parseJsonBytes(json, string.concat(".", vm.toString(address(0x100)), ".code"))); + assertEq(0, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x100)), ".storage")).length); + + assertEq(4, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x200)))).length); + assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x200)), ".nonce"))); + assertEq(1 ether, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x200)), ".balance"))); + assertEq(hex"", vm.parseJsonBytes(json, string.concat(".", vm.toString(address(0x200)), ".code"))); + assertEq(0, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x200)), ".storage")).length); + + assertEq(4, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x300)))).length); + assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x300)), ".nonce"))); + assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x300)), ".balance"))); + assertEq(hex"", vm.parseJsonBytes(json, string.concat(".", vm.toString(address(0x300)), ".code"))); + assertEq(1, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x300)), ".storage")).length); + assertEq( + 2, + vm.parseJsonUint( + json, string.concat(".", vm.toString(address(0x300)), ".storage.", vm.toString(bytes32(uint256(1)))) + ) + ); + + assertEq(4, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x400)))).length); + assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x400)), ".nonce"))); + assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x400)), ".balance"))); + assertEq(hex"af", vm.parseJsonBytes(json, string.concat(".", vm.toString(address(0x400)), ".code"))); + assertEq(0, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x400)), ".storage")).length); + + vm.removeFile(path); + } + + function testDumpStateDeployment() public { + string memory path = string.concat(vm.projectRoot(), "/fixtures/Json/test_dump_state_deployment.json"); + + SimpleContract s = new SimpleContract(); + vm.dumpState(path); + + string memory json = vm.readFile(path); + string[] memory keys = vm.parseJsonKeys(json, ""); + assertEq(keys.length, 1); + assertEq(address(s), vm.parseAddress(keys[0])); + assertEq(1, vm.parseJsonKeys(json, string.concat(".", keys[0], ".storage")).length); + assertEq(2, vm.parseJsonUint(json, string.concat(".", keys[0], ".storage.", vm.toString(bytes32(uint256(1)))))); + + vm.removeFile(path); + } +} From 03f5a95dbbe8d384f69de670d583e4fab24c8a71 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:37:07 +0100 Subject: [PATCH 0495/1963] chore(cheatcodes): remove base64 group, add string overloads (#6830) --- crates/cheatcodes/assets/cheatcodes.json | 66 +++++++++++++++---- .../cheatcodes/assets/cheatcodes.schema.json | 7 -- crates/cheatcodes/spec/src/cheatcode.rs | 8 --- crates/cheatcodes/spec/src/vm.rs | 26 +++++--- crates/cheatcodes/src/base64.rs | 18 ++++- testdata/cheats/Vm.sol | 4 +- 6 files changed, 88 insertions(+), 41 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index a88ebf3b52329..e404eb0323070 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4575,8 +4575,48 @@ }, { "func": { - "id": "toBase64", - "description": "Encodes a `bytes` value to base64 string", + "id": "toBase64URL_0", + "description": "Encodes a `bytes` value to a base64url string.", + "declaration": "function toBase64URL(bytes calldata data) external pure returns (string memory);", + "visibility": "external", + "mutability": "pure", + "signature": "toBase64URL(bytes)", + "selector": "0xc8bd0e4a", + "selectorBytes": [ + 200, + 189, + 14, + 74 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toBase64URL_1", + "description": "Encodes a `string` value to a base64url string.", + "declaration": "function toBase64URL(string calldata data) external pure returns (string memory);", + "visibility": "external", + "mutability": "pure", + "signature": "toBase64URL(string)", + "selector": "0xae3165b3", + "selectorBytes": [ + 174, + 49, + 101, + 179 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "toBase64_0", + "description": "Encodes a `bytes` value to a base64 string.", "declaration": "function toBase64(bytes calldata data) external pure returns (string memory);", "visibility": "external", "mutability": "pure", @@ -4589,27 +4629,27 @@ 101 ] }, - "group": "base64", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "toBase64URL", - "description": "Encodes a `bytes` value to base64url string", - "declaration": "function toBase64URL(bytes calldata data) external pure returns (string memory);", + "id": "toBase64_1", + "description": "Encodes a `string` value to a base64 string.", + "declaration": "function toBase64(string calldata data) external pure returns (string memory);", "visibility": "external", "mutability": "pure", - "signature": "toBase64URL(bytes)", - "selector": "0xc8bd0e4a", + "signature": "toBase64(string)", + "selector": "0x3f8be2c8", "selectorBytes": [ - 200, - 189, - 14, - 74 + 63, + 139, + 226, + 200 ] }, - "group": "base64", + "group": "utilities", "status": "stable", "safety": "safe" }, diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index 1231ec0458e60..7b68420ad63bf 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -298,13 +298,6 @@ "json" ] }, - { - "description": "Utility cheatcodes that deal with encoding and decoding Base64.\n\nExamples: `toBase64`, `toBase64URL`.\n\nSafety: safe.", - "type": "string", - "enum": [ - "base64" - ] - }, { "description": "Generic, uncategorized utilities.\n\nExamples: `toString`, `parse*`, `serialize*`.\n\nSafety: safe.", "type": "string", diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index e6ed724629fe6..f7e0c87b306f2 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -103,12 +103,6 @@ pub enum Group { /// /// Safety: safe. Json, - /// Utility cheatcodes that deal with encoding and decoding Base64. - /// - /// Examples: `toBase64`, `toBase64URL`. - /// - /// Safety: safe. - Base64, /// Generic, uncategorized utilities. /// /// Examples: `toString`, `parse*`, `serialize*`. @@ -131,7 +125,6 @@ impl Group { Self::Environment | Self::String | Self::Json | - Self::Base64 | Self::Utilities => Some(Safety::Safe), } } @@ -147,7 +140,6 @@ impl Group { Self::Environment => "environment", Self::String => "string", Self::Json => "json", - Self::Base64 => "base64", Self::Utilities => "utilities", } } diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 5178bd83d8247..813c912d324a8 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1236,16 +1236,6 @@ interface Vm { #[cheatcode(group = Json)] function writeJson(string calldata json, string calldata path, string calldata valueKey) external; - // -------- Base64 -------- - - /// Encodes a `bytes` value to base64 string - #[cheatcode(group = Base64)] - function toBase64(bytes calldata data) external pure returns (string memory); - - /// Encodes a `bytes` value to base64url string - #[cheatcode(group = Base64)] - function toBase64URL(bytes calldata data) external pure returns (string memory); - // -------- Key Management -------- /// Derives a private key from the name, labels the account with that name, and returns the wallet. @@ -1319,5 +1309,21 @@ interface Vm { /// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer. #[cheatcode(group = Utilities)] function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address); + + /// Encodes a `bytes` value to a base64 string. + #[cheatcode(group = Utilities)] + function toBase64(bytes calldata data) external pure returns (string memory); + + /// Encodes a `string` value to a base64 string. + #[cheatcode(group = Utilities)] + function toBase64(string calldata data) external pure returns (string memory); + + /// Encodes a `bytes` value to a base64url string. + #[cheatcode(group = Utilities)] + function toBase64URL(bytes calldata data) external pure returns (string memory); + + /// Encodes a `string` value to a base64url string. + #[cheatcode(group = Utilities)] + function toBase64URL(string calldata data) external pure returns (string memory); } } diff --git a/crates/cheatcodes/src/base64.rs b/crates/cheatcodes/src/base64.rs index d9d0bc86f76c2..4aa4ba74a0e4b 100644 --- a/crates/cheatcodes/src/base64.rs +++ b/crates/cheatcodes/src/base64.rs @@ -2,14 +2,28 @@ use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_sol_types::SolValue; use base64::prelude::*; -impl Cheatcode for toBase64Call { +impl Cheatcode for toBase64_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { data } = self; Ok(BASE64_STANDARD.encode(data).abi_encode()) } } -impl Cheatcode for toBase64URLCall { +impl Cheatcode for toBase64_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { data } = self; + Ok(BASE64_STANDARD.encode(data).abi_encode()) + } +} + +impl Cheatcode for toBase64URL_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { data } = self; + Ok(BASE64_URL_SAFE.encode(data).abi_encode()) + } +} + +impl Cheatcode for toBase64URL_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { data } = self; Ok(BASE64_URL_SAFE.encode(data).abi_encode()) diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 237b68db8835a..82a4b84358fc4 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -226,8 +226,10 @@ interface Vm { function stopMappingRecording() external; function stopPrank() external; function store(address target, bytes32 slot, bytes32 value) external; - function toBase64(bytes calldata data) external pure returns (string memory); function toBase64URL(bytes calldata data) external pure returns (string memory); + function toBase64URL(string calldata data) external pure returns (string memory); + function toBase64(bytes calldata data) external pure returns (string memory); + function toBase64(string calldata data) external pure returns (string memory); function toString(address value) external pure returns (string memory stringifiedValue); function toString(bytes calldata value) external pure returns (string memory stringifiedValue); function toString(bytes32 value) external pure returns (string memory stringifiedValue); From f32550c65d9a1655cf6e249ff03daab65c954692 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:11:39 +0100 Subject: [PATCH 0496/1963] feat(cli): Update Flashbots URL to use `fast` endpoint to improve transaction inclusion guarantees (#6831) * update flashbots URL to share private transaction with all registered builders rather than just the Flashbots builder * improve documentation of method --- crates/cli/src/opts/ethereum.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 8a034a8a07e17..017e8098dd3c1 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -12,7 +12,7 @@ use foundry_config::{ use serde::Serialize; use std::borrow::Cow; -const FLASHBOTS_URL: &str = "https://rpc.flashbots.net"; +const FLASHBOTS_URL: &str = "https://rpc.flashbots.net/fast"; #[derive(Clone, Debug, Default, Parser)] pub struct RpcOpts { @@ -20,7 +20,9 @@ pub struct RpcOpts { #[clap(short = 'r', long = "rpc-url", env = "ETH_RPC_URL")] pub url: Option, - /// Use the Flashbots RPC URL (https://rpc.flashbots.net). + /// Use the Flashbots RPC URL with fast mode (https://rpc.flashbots.net/fast). + /// This shares the transaction privately with all registered builders. + /// https://docs.flashbots.net/flashbots-protect/quick-start#faster-transactions #[clap(long)] pub flashbots: bool, From 648a5359b98d3c8f6e9a4508b041196f6f4687b2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 17 Jan 2024 23:49:54 +0100 Subject: [PATCH 0497/1963] fix: update env in transact cheatcode (#6835) --- crates/evm/core/src/backend/mod.rs | 46 +++++++++++++++++++----------- crates/forge/tests/it/repros.rs | 4 +++ testdata/repros/Issue6538.t.sol | 17 +++++++++++ 3 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 testdata/repros/Issue6538.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 76a78fb6e10fd..72906407365bf 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -20,7 +20,10 @@ use revm::{ }, Database, DatabaseCommit, Inspector, JournaledState, EVM, }; -use std::collections::{HashMap, HashSet}; +use std::{ + collections::{HashMap, HashSet}, + time::Instant, +}; mod diagnostic; pub use diagnostic::RevertDiagnostic; @@ -888,6 +891,7 @@ impl Backend { if is_known_system_sender(tx.from) || tx.transaction_type.map(|ty| ty.to::()) == Some(SYSTEM_TRANSACTION_TYPE) { + trace!(tx=?tx.hash, "skipping system transaction"); continue; } @@ -1199,14 +1203,7 @@ impl DatabaseExt for Backend { // roll the fork to the transaction's block or latest if it's pending self.roll_fork(Some(id), fork_block.to(), env, journaled_state)?; - // update the block's env accordingly - env.block.timestamp = block.header.timestamp; - env.block.coinbase = block.header.miner; - env.block.difficulty = block.header.difficulty; - env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); - env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default(); - env.block.gas_limit = block.header.gas_limit; - env.block.number = block.header.number.map(|n| n.to()).unwrap_or(fork_block.to()); + update_env_block(env, fork_block, &block); // replay all transactions that came before let env = env.clone(); @@ -1228,17 +1225,19 @@ impl DatabaseExt for Backend { let id = self.ensure_fork(maybe_id)?; let fork_id = self.ensure_fork_id(id).cloned()?; - let env = if maybe_id.is_none() { - self.forks - .get_env(fork_id.clone())? - .ok_or_else(|| eyre::eyre!("Requested fork `{}` does not exit", id))? - } else { - env.clone() + let tx = { + let fork = self.inner.get_fork_by_id_mut(id)?; + fork.db.db.get_transaction(transaction)? }; - let fork = self.inner.get_fork_by_id_mut(id)?; - let tx = fork.db.db.get_transaction(transaction)?; + // This is a bit ambiguous because the user wants to transact an arbitrary transaction in the current context, but we're assuming the user wants to transact the transaction as it was mined. Usually this is used in a combination of a fork at the transaction's parent transaction in the block and then the transaction is transacted: + // So we modify the env to match the transaction's block + let (fork_block, block) = + self.get_block_number_and_block_for_transaction(id, transaction)?; + let mut env = env.clone(); + update_env_block(&mut env, fork_block, &block); + let fork = self.inner.get_fork_by_id_mut(id)?; commit_transaction(tx, env, journaled_state, fork, &fork_id, inspector) } @@ -1856,6 +1855,17 @@ fn is_contract_in_state(journaled_state: &JournaledState, acc: Address) -> bool .unwrap_or_default() } +/// Updates the env's block with the block's data +fn update_env_block(env: &mut Env, fork_block: U64, block: &Block) { + env.block.timestamp = block.header.timestamp; + env.block.coinbase = block.header.miner; + env.block.difficulty = block.header.difficulty; + env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); + env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default(); + env.block.gas_limit = block.header.gas_limit; + env.block.number = block.header.number.map(|n| n.to()).unwrap_or(fork_block.to()); +} + /// Executes the given transaction and commits state changes to the database _and_ the journaled /// state, with an optional inspector fn commit_transaction>( @@ -1868,6 +1878,7 @@ fn commit_transaction>( ) -> eyre::Result<()> { configure_tx_env(&mut env, &tx); + let now = Instant::now(); let state = { let mut evm = EVM::new(); evm.env = env; @@ -1883,6 +1894,7 @@ fn commit_transaction>( Err(e) => eyre::bail!("backend: failed committing transaction: {e}"), } }; + trace!(elapsed = ?now.elapsed(), "transacted transaction"); apply_state_changeset(state, journaled_state, fork); Ok(()) diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index b53002ae2d170..61d9d97ff8537 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -50,6 +50,7 @@ macro_rules! test_repro { } async fn repro_config(issue: usize, should_fail: bool, sender: Option
) -> TestConfig { + foundry_test_utils::init_tracing(); let filter = Filter::path(&format!(".*repros/Issue{issue}.t.sol")); let mut config = Config::with_root(PROJECT.root()); @@ -280,6 +281,9 @@ test_repro!(6501, false, None, |res| { } }); +// https://github.com/foundry-rs/foundry/issues/6538 +test_repro!(6538); + // https://github.com/foundry-rs/foundry/issues/6554 test_repro!(6554; |config| { let mut cheats_config = config.runner.cheats_config.as_ref().clone(); diff --git a/testdata/repros/Issue6538.t.sol b/testdata/repros/Issue6538.t.sol new file mode 100644 index 0000000000000..d174449c787aa --- /dev/null +++ b/testdata/repros/Issue6538.t.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6538 +contract Issue6538Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_transact() public { + bytes32 lastHash = 0xdbdce1d5c14a6ca17f0e527ab762589d6a73f68697606ae0bb90df7ac9ec5087; + vm.createSelectFork("rpcAlias", lastHash); + bytes32 txhash = 0xadbe5cf9269a001d50990d0c29075b402bcc3a0b0f3258821881621b787b35c6; + vm.transact(txhash); + } +} From d9e25fa713bf2c70f1e60bc607fd2cf6912e42ac Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 17 Jan 2024 23:50:21 +0100 Subject: [PATCH 0498/1963] fix: skip trailing white space for doc comments (#6834) --- crates/fmt/src/comments.rs | 8 ++++---- crates/fmt/src/formatter.rs | 8 ++++++-- .../testdata/BlockCommentsFunction/fmt.sol | 20 +++++++++++++++++++ .../BlockCommentsFunction/original.sol | 20 +++++++++++++++++++ crates/fmt/tests/formatter.rs | 1 + 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 crates/fmt/testdata/BlockCommentsFunction/fmt.sol create mode 100644 crates/fmt/testdata/BlockCommentsFunction/original.sol diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index 295d171531c48..03f4e41813c19 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -398,13 +398,13 @@ impl Iterator for CommentStateCharIndices<'_> { } #[inline] - fn count(self) -> usize { - self.iter.count() + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() } #[inline] - fn size_hint(&self) -> (usize, Option) { - self.iter.size_hint() + fn count(self) -> usize { + self.iter.count() } } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 89829a59b053e..347d7188f14e5 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -528,8 +528,12 @@ impl<'a, W: Write> Formatter<'a, W> { .take_while(|(idx, ch)| ch.is_whitespace() && *idx <= self.buf.current_indent_len()) .count(); let to_skip = indent_whitespace_count - indent_whitespace_count % self.config.tab_width; - write!(self.buf(), " * ")?; - self.write_comment_line(comment, &line[to_skip..])?; + write!(self.buf(), " *")?; + let content = &line[to_skip..]; + if !content.trim().is_empty() { + write!(self.buf(), " ")?; + self.write_comment_line(comment, &line[to_skip..])?; + } self.write_whitespace_separator(true)?; Ok(()) } diff --git a/crates/fmt/testdata/BlockCommentsFunction/fmt.sol b/crates/fmt/testdata/BlockCommentsFunction/fmt.sol new file mode 100644 index 0000000000000..368749bf4fdaf --- /dev/null +++ b/crates/fmt/testdata/BlockCommentsFunction/fmt.sol @@ -0,0 +1,20 @@ +contract A { + Counter public counter; + /** + * TODO: this fuzz use too much time to execute + * function testGetFuzz(bytes[2][] memory kvs) public { + * for (uint256 i = 0; i < kvs.length; i++) { + * bytes32 root = trie.update(kvs[i][0], kvs[i][1]); + * console.logBytes32(root); + * } + * + * for (uint256 i = 0; i < kvs.length; i++) { + * (bool exist, bytes memory value) = trie.get(kvs[i][0]); + * console.logBool(exist); + * console.logBytes(value); + * require(exist); + * require(BytesSlice.equal(value, trie.getRaw(kvs[i][0]))); + * } + * } + */ +} diff --git a/crates/fmt/testdata/BlockCommentsFunction/original.sol b/crates/fmt/testdata/BlockCommentsFunction/original.sol new file mode 100644 index 0000000000000..089f1bac430cd --- /dev/null +++ b/crates/fmt/testdata/BlockCommentsFunction/original.sol @@ -0,0 +1,20 @@ +contract A { + Counter public counter; + /** + * TODO: this fuzz use too much time to execute + function testGetFuzz(bytes[2][] memory kvs) public { + for (uint256 i = 0; i < kvs.length; i++) { + bytes32 root = trie.update(kvs[i][0], kvs[i][1]); + console.logBytes32(root); + } + + for (uint256 i = 0; i < kvs.length; i++) { + (bool exist, bytes memory value) = trie.get(kvs[i][0]); + console.logBool(exist); + console.logBytes(value); + require(exist); + require(BytesSlice.equal(value, trie.getRaw(kvs[i][0]))); + } + } + */ +} \ No newline at end of file diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 2e5d77054051f..18b72a54512be 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -230,6 +230,7 @@ test_directories! { EmitStatement, Repros, BlockComments, + BlockCommentsFunction, EnumVariants, } From 375df5834d0fea8350a4aae9ca34a0dab55d74ac Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 17 Jan 2024 23:50:50 +0100 Subject: [PATCH 0499/1963] chore: better retry tracing (#6836) --- crates/common/src/provider/tower.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs index 632d8b29951d3..0df22bb01e8cc 100644 --- a/crates/common/src/provider/tower.rs +++ b/crates/common/src/provider/tower.rs @@ -124,14 +124,14 @@ impl Service for RetryBackoffService { if rate_limit_retry_number > this.max_rate_limit_retries { return Err(TransportErrorKind::custom_str("Max retries exceeded")) } + trace!("retrying request due to {:?}", err); let current_queued_reqs = this.requests_enqueued.load(Ordering::SeqCst) as u64; // try to extract the requested backoff from the error or compute the next // backoff based on retry count - let mut next_backoff = this - .policy - .backoff_hint(&err) + let backoff_hint = this.policy.backoff_hint(&err); + let next_backoff = backoff_hint .unwrap_or_else(|| std::time::Duration::from_millis(this.initial_backoff)); // requests are usually weighted and can vary from 10 CU to several 100 CU, @@ -151,10 +151,12 @@ impl Service for RetryBackoffService { current_queued_reqs, ahead_in_queue, ); - next_backoff += + let total_backoff = next_backoff + std::time::Duration::from_secs(seconds_to_wait_for_compute_budget); - tokio::time::sleep(next_backoff).await; + trace!(?total_backoff, budget_backoff = ?seconds_to_wait_for_compute_budget, default_backoff = ?next_backoff, ?backoff_hint, "backing off due to rate limit"); + + tokio::time::sleep(total_backoff).await; } else { if timeout_retries < this.max_timeout_retries { timeout_retries += 1; From b51c05734d0bc8879df64d00f536acb7413c84fa Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 18 Jan 2024 00:20:16 +0100 Subject: [PATCH 0500/1963] fix: add missing receipt fields to pretty fmt (#6838) --- crates/common/src/fmt/ui.rs | 63 ++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 56ccb68a1d110..4c21328cea886 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -127,13 +127,34 @@ impl UIfmt for U64 { impl UIfmt for TransactionReceipt { fn pretty(&self) -> String { - format!( + let Self { + transaction_hash, + transaction_index, + block_hash, + block_number, + from, + to, + cumulative_gas_used, + gas_used, + contract_address, + logs, + status, + root, + logs_bloom, + transaction_type, + effective_gas_price, + other, + .. + } = self; + + let mut pretty = format!( " blockHash {} blockNumber {} contractAddress {} cumulativeGasUsed {} effectiveGasPrice {} +from {} gasUsed {} logs {} logsBloom {} @@ -142,20 +163,32 @@ status {} transactionHash {} transactionIndex {} type {}", - self.block_hash.pretty(), - self.block_number.pretty(), - self.contract_address.pretty(), - self.cumulative_gas_used.pretty(), - self.effective_gas_price.pretty(), - self.gas_used.pretty(), - serde_json::to_string(&self.logs).unwrap(), - self.logs_bloom.pretty(), - self.root.pretty(), - self.status.pretty(), - self.transaction_hash.pretty(), - self.transaction_index.pretty(), - self.transaction_type.pretty() - ) + block_hash.pretty(), + block_number.pretty(), + contract_address.pretty(), + cumulative_gas_used.pretty(), + effective_gas_price.pretty(), + from.pretty(), + gas_used.pretty(), + serde_json::to_string(logs).unwrap(), + logs_bloom.pretty(), + root.pretty(), + status.pretty(), + transaction_hash.pretty(), + transaction_index.pretty(), + transaction_type.pretty() + ); + + if let Some(to) = to { + pretty.push_str(&format!("\nto {}", to)); + } + + // additional captured fields + for (key, val) in other.iter() { + pretty.push_str(&format!("\n{} {}", key, val)); + } + + pretty } } From 8bd1483e16c06e1162ce42a8f4a31556edfb717a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:08:51 +0100 Subject: [PATCH 0501/1963] fix: format `web3_sha3` result as an hexadecimal string (#6843) * fix: format `web3_sha3` result as an hexadecimal string * chore: use `alloy_primitives::utils` instead of `ethers::utils` --- crates/anvil/src/eth/api.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 2bf44a3a35c9a..45a84c04a336d 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -473,7 +473,8 @@ impl EthApi { pub fn sha3(&self, bytes: Bytes) -> Result { node_info!("web3_sha3"); let hash = ethers::utils::keccak256(bytes.as_ref()); - Ok(ethers::utils::hex::encode(&hash[..])) + let hex_hash = alloy_primitives::utils::hex::encode(&hash[..]); + Ok(format!("0x{hex_hash}")) } /// Returns protocol version encoded as a string (quotes are necessary). From 2125803d089c4a5eefe42e4aba7542a5272c387f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Jan 2024 19:52:16 +0100 Subject: [PATCH 0502/1963] fix: make anvil compile (#6845) --- crates/anvil/src/eth/api.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 45a84c04a336d..f99b8eb1274b1 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -472,9 +472,8 @@ impl EthApi { /// Handler for ETH RPC call: `web3_sha3` pub fn sha3(&self, bytes: Bytes) -> Result { node_info!("web3_sha3"); - let hash = ethers::utils::keccak256(bytes.as_ref()); - let hex_hash = alloy_primitives::utils::hex::encode(&hash[..]); - Ok(format!("0x{hex_hash}")) + let hash = alloy_primitives::keccak256(bytes.as_ref()); + Ok(alloy_primitives::hex::encode_prefixed(&hash[..])) } /// Returns protocol version encoded as a string (quotes are necessary). From 41242d4095ddeccaa85f3fd13af7a055429c5703 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Thu, 18 Jan 2024 09:03:13 -1000 Subject: [PATCH 0503/1963] [forge] verify-contract: support --via-ir flag (#6781) * [forge] verify-contract: support --via-ir flag * Formatting --- crates/forge/bin/cmd/create.rs | 2 ++ crates/forge/bin/cmd/script/verify.rs | 5 +++++ crates/forge/bin/cmd/verify/mod.rs | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 4f424d9847d8d..57c12eef887ae 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -188,6 +188,7 @@ impl CreateArgs { libraries: vec![], root: None, verifier: self.verifier.clone(), + via_ir: self.opts.via_ir, show_standard_json_input: self.show_standard_json_input, }; @@ -335,6 +336,7 @@ impl CreateArgs { libraries: vec![], root: None, verifier: self.verifier, + via_ir: self.opts.via_ir, show_standard_json_input: self.show_standard_json_input, }; println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier); diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 1837b5fd64be6..f525f08a0585f 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -18,6 +18,7 @@ pub struct VerifyBundle { pub etherscan: EtherscanOpts, pub retry: RetryArgs, pub verifier: VerifierArgs, + pub via_ir: bool, } impl VerifyBundle { @@ -44,6 +45,8 @@ impl VerifyBundle { config_path: if config_path.exists() { Some(config_path) } else { None }, }; + let via_ir = config.via_ir; + VerifyBundle { num_of_optimizations, known_contracts, @@ -51,6 +54,7 @@ impl VerifyBundle { project_paths, retry, verifier, + via_ir, } } @@ -109,6 +113,7 @@ impl VerifyBundle { libraries: libraries.to_vec(), root: None, verifier: self.verifier.clone(), + via_ir: self.via_ir, show_standard_json_input: false, }; diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index c0f58d6aef501..53e411ac752bd 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -107,6 +107,10 @@ pub struct VerifyArgs { #[clap(flatten)] pub verifier: VerifierArgs, + + /// Use the Yul intermediate representation compilation pipeline. + #[clap(long)] + pub via_ir: bool, } impl_figment_convert!(VerifyArgs); @@ -129,6 +133,9 @@ impl figment::Provider for VerifyArgs { figment::value::Value::serialize(optimizer_runs)?, ); } + if self.via_ir { + dict.insert("via_ir".to_string(), figment::value::Value::serialize(self.via_ir)?); + } Ok(figment::value::Map::from([(Config::selected_profile(), dict)])) } } @@ -238,4 +245,15 @@ mod tests { assert!(is_host_only(&Url::parse("https://blockscout.net/").unwrap())); assert!(is_host_only(&Url::parse("https://blockscout.net").unwrap())); } + + #[test] + fn can_parse_verify_contract() { + let args: VerifyArgs = VerifyArgs::parse_from([ + "foundry-cli", + "0x0000000000000000000000000000000000000000", + "src/Domains.sol:Domains", + "--via-ir", + ]); + assert!(args.via_ir); + } } From 8fc9f362c5e3acabac2c8f4aef1105be6b6a0969 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Jan 2024 21:11:59 +0100 Subject: [PATCH 0504/1963] chore: fix deny checks (#6847) --- Cargo.lock | 4 ++-- deny.toml | 18 +++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a913af40aae83..35bbf7d77d9c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3806,9 +3806,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b553656127a00601c8ae5590fcfdc118e4083a7924b6cf4ffc1ea4b99dc429d7" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", diff --git a/deny.toml b/deny.toml index f46973b5964a7..4b394a5255e3a 100644 --- a/deny.toml +++ b/deny.toml @@ -10,9 +10,7 @@ vulnerability = "deny" unmaintained = "warn" yanked = "warn" notice = "warn" -ignore = [ - "RUSTSEC-2020-0071", # https://rustsec.org/advisories/RUSTSEC-2020-0071 -] +ignore = [] # This section is considered when running `cargo deny check bans`. # More documentation about the 'bans' section can be found here: @@ -24,9 +22,7 @@ multiple-versions = "warn" wildcards = "allow" highlight = "all" # List of crates to deny -deny = [ - { name = "openssl" }, -] +deny = [{ name = "openssl" }] # Certain crates/versions that will be skipped when doing duplicate detection. skip = [] # Similarly to `skip` allows you to skip certain crates during duplicate @@ -82,16 +78,12 @@ exceptions = [ name = "unicode-ident" version = "*" expression = "(MIT OR Apache-2.0) AND Unicode-DFS-2016" -license-files = [ - { path = "LICENSE-UNICODE", hash = 0x3fb01745 } -] +license-files = [{ path = "LICENSE-UNICODE", hash = 0x3fb01745 }] [[licenses.clarify]] name = "ring" version = "*" expression = "OpenSSL" -license-files = [ - { path = "LICENSE", hash = 0xbd0eed23 } -] +license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] # This section is considered when running `cargo deny check sources`. # More documentation about the 'sources' section can be found here: @@ -102,4 +94,4 @@ license-files = [ unknown-registry = "warn" # Lint level for what to happen when a crate from a git repository that is not # in the allow list is encountered -unknown-git = "allow" \ No newline at end of file +unknown-git = "allow" From 2335dea2e0d938d769a2b87947e79e02484a8c5a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Jan 2024 21:26:05 +0100 Subject: [PATCH 0505/1963] feat: add viaIR to etherscan verification input (#6846) * feat: add viaIR to etherscan verification input * chore: set via ir to true if provided --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 4 ++-- crates/forge/bin/cmd/verify/etherscan/mod.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35bbf7d77d9c3..20a9a74112642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2919,9 +2919,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e3511658a04060f9c28b45ef0f3a483f605ba2f7a3563f993476115e247eef9" +checksum = "3388fca613939d3431dcf951a349753c00478bc839821ce1b0910563cce41a99" dependencies = [ "alloy-chains", "alloy-json-abi", diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index ec7e72b1dfcb1..956e583ab2d6b 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -323,6 +323,14 @@ impl EtherscanVerificationProvider { .constructor_arguments(constructor_args) .code_format(code_format); + if args.via_ir { + // we explicitly set this __undocumented__ argument to true if provided by the user, + // though this info is also available in the compiler settings of the standard json + // object if standard json is used + // unclear how etherscan interprets this field in standard-json mode + verify_args = verify_args.via_ir(true); + } + if code_format == CodeFormat::SingleFile { verify_args = if let Some(optimizations) = args.num_of_optimizations { verify_args.optimized().runs(optimizations as u32) From af1569ffaab36d712d3df8f8224c7d0387d0e6c1 Mon Sep 17 00:00:00 2001 From: christn Date: Fri, 19 Jan 2024 12:29:43 +0800 Subject: [PATCH 0506/1963] chore(cast): Bump evm-disassembler dependency to add PUSH0 support (#6849) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20a9a74112642..568e5e85bf2f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2619,9 +2619,9 @@ dependencies = [ [[package]] name = "evm-disassembler" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef8b778f0f7ba24aaa7c1d8fa7ec75db869f8a8508907be49eac899865ea52d" +checksum = "0f6fc9c732a3210153e6aa26746f0abd8773dbf204c64ae3e824309b32b384c5" dependencies = [ "eyre", "hex", diff --git a/Cargo.toml b/Cargo.toml index 3c4d6f16cc9bf..83654e64fbad7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,7 +186,7 @@ base64 = "0.21" toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" -evm-disassembler = "0.3" +evm-disassembler = "0.4" axum = "0.6" hyper = "0.14" From d6612e3e8688ebd9c4250f60b16fd2ea84ca06ec Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 19 Jan 2024 12:40:41 +0100 Subject: [PATCH 0507/1963] chore: error instead of panic on create fork failure (#6852) --- crates/forge/bin/cmd/script/executor.rs | 192 +++++++++---------- crates/forge/bin/cmd/verify/etherscan/mod.rs | 9 +- 2 files changed, 97 insertions(+), 104 deletions(-) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 3d1eb7a887bec..6a5b792fe1969 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -11,7 +11,7 @@ use forge::{ backend::Backend, executors::ExecutorBuilder, inspectors::{cheatcodes::BroadcastableTransactions, CheatsConfig}, - traces::{CallTraceDecoder, Traces}, + traces::CallTraceDecoder, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ @@ -24,9 +24,6 @@ use futures::future::join_all; use parking_lot::RwLock; use std::{collections::VecDeque, sync::Arc}; -/// Helper alias type for the processed result of a runner onchain simulation. -type RunnerResult = (Option, Traces); - impl ScriptArgs { /// Locally deploys and executes the contract method that will collect all broadcastable /// transactions. @@ -51,7 +48,7 @@ impl ScriptArgs { ensure_clean_constructor(&abi)?; - let mut runner = self.prepare_runner(script_config, sender, SimulationStage::Local).await; + let mut runner = self.prepare_runner(script_config, sender, SimulationStage::Local).await?; let (address, mut result) = runner.setup( predeploy_libraries, bytecode, @@ -105,7 +102,7 @@ impl ScriptArgs { let runners = Arc::new( self.build_runners(script_config) - .await + .await? .into_iter() .map(|(rpc, runner)| (rpc, Arc::new(RwLock::new(runner)))) .collect::>(), @@ -139,87 +136,81 @@ impl ScriptArgs { let mut final_txs = VecDeque::new(); // Executes all transactions from the different forks concurrently. - let futs = - transactions - .into_iter() - .map(|transaction| async { - let mut runner = runners - .get(transaction.rpc.as_ref().expect("to have been filled already.")) - .expect("to have been built.") - .write(); - - if let TypedTransaction::Legacy(mut tx) = transaction.transaction { - let result = runner - .simulate( - tx.from.expect( - "Transaction doesn't have a `from` address at execution time", - ).to_alloy(), - tx.to.clone(), - tx.data.clone().map(|b| b.to_alloy()), - tx.value.map(|v| v.to_alloy()), - ) - .wrap_err("Internal EVM error during simulation")?; - - if !result.success || result.traces.is_empty() { - return Ok((None, result.traces)); - } - - let created_contracts = result - .traces - .iter() - .flat_map(|(_, traces)| { - traces.nodes().iter().filter_map(|node| { - if node.trace.kind.is_any_create() { - return Some(AdditionalContract { - opcode: node.trace.kind, - address: node.trace.address, - init_code: node.trace.data.clone(), - }); - } - None - }) - }) - .collect(); - - // Simulate mining the transaction if the user passes `--slow`. - if self.slow { - runner.executor.env.block.number += U256::from(1); - } - - let is_fixed_gas_limit = tx.gas.is_some(); - // If tx.gas is already set that means it was specified in script - if !is_fixed_gas_limit { - // We inflate the gas used by the user specified percentage - tx.gas = Some( - U256::from(result.gas_used * self.gas_estimate_multiplier / 100) - .to_ethers(), - ); - } else { - println!("Gas limit was set in script to {:}", tx.gas.unwrap()); - } - - let tx = TransactionWithMetadata::new( - tx.into(), - transaction.rpc, - &result, - &address_to_abi, - decoder, - created_contracts, - is_fixed_gas_limit, - )?; - - Ok((Some(tx), result.traces)) - } else { - unreachable!() + let futs = transactions + .into_iter() + .map(|transaction| async { + let rpc = transaction.rpc.as_ref().expect("missing broadcastable tx rpc url"); + let mut runner = runners.get(rpc).expect("invalid rpc url").write(); + + let TypedTransaction::Legacy(mut tx) = transaction.transaction else { + unreachable!() + }; + let result = runner + .simulate( + tx.from + .expect("transaction doesn't have a `from` address at execution time") + .to_alloy(), + tx.to.clone(), + tx.data.clone().map(|b| b.to_alloy()), + tx.value.map(|v| v.to_alloy()), + ) + .wrap_err("Internal EVM error during simulation")?; + + if !result.success || result.traces.is_empty() { + return Ok((None, result.traces)); + } + + let created_contracts = result + .traces + .iter() + .flat_map(|(_, traces)| { + traces.nodes().iter().filter_map(|node| { + if node.trace.kind.is_any_create() { + return Some(AdditionalContract { + opcode: node.trace.kind, + address: node.trace.address, + init_code: node.trace.data.clone(), + }); + } + None + }) + }) + .collect(); + + // Simulate mining the transaction if the user passes `--slow`. + if self.slow { + runner.executor.env.block.number += U256::from(1); + } + + let is_fixed_gas_limit = tx.gas.is_some(); + match tx.gas { + // If tx.gas is already set that means it was specified in script + Some(gas) => { + println!("Gas limit was set in script to {gas}"); } - }) - .collect::>(); + // We inflate the gas used by the user specified percentage + None => { + let gas = U256::from(result.gas_used * self.gas_estimate_multiplier / 100); + tx.gas = Some(gas.to_ethers()); + } + } + + let tx = TransactionWithMetadata::new( + tx.into(), + transaction.rpc, + &result, + &address_to_abi, + decoder, + created_contracts, + is_fixed_gas_limit, + )?; + + eyre::Ok((Some(tx), result.traces)) + }) + .collect::>(); let mut abort = false; for res in join_all(futs).await { - // type hint - let res: Result = res; - let (tx, traces) = res?; // Transaction will be `None`, if execution didn't pass. @@ -251,7 +242,10 @@ impl ScriptArgs { } /// Build the multiple runners from different forks. - async fn build_runners(&self, script_config: &ScriptConfig) -> HashMap { + async fn build_runners( + &self, + script_config: &ScriptConfig, + ) -> Result> { let sender = script_config.evm_opts.sender; if !shell::verbosity().is_silent() { @@ -266,11 +260,10 @@ impl ScriptArgs { .map(|rpc| async { let mut script_config = script_config.clone(); script_config.evm_opts.fork_url = Some(rpc.clone()); - - ( - rpc.clone(), - self.prepare_runner(&mut script_config, sender, SimulationStage::OnChain).await, - ) + let runner = self + .prepare_runner(&mut script_config, sender, SimulationStage::OnChain) + .await?; + Ok((rpc.clone(), runner)) }) .collect::>(); @@ -283,22 +276,19 @@ impl ScriptArgs { script_config: &mut ScriptConfig, sender: Address, stage: SimulationStage, - ) -> ScriptRunner { + ) -> Result { trace!("preparing script runner"); - let env = - script_config.evm_opts.evm_env().await.expect("Could not instantiate fork environment"); + let env = script_config.evm_opts.evm_env().await?; // The db backend that serves all the data. let db = match &script_config.evm_opts.fork_url { Some(url) => match script_config.backends.get(url) { Some(db) => db.clone(), None => { - let backend = Backend::spawn( - script_config.evm_opts.get_fork(&script_config.config, env.clone()), - ) - .await; - script_config.backends.insert(url.clone(), backend); - script_config.backends.get(url).unwrap().clone() + let fork = script_config.evm_opts.get_fork(&script_config.config, env.clone()); + let backend = Backend::spawn(fork).await; + script_config.backends.insert(url.clone(), backend.clone()); + backend } }, None => { @@ -324,6 +314,10 @@ impl ScriptArgs { }); } - ScriptRunner::new(builder.build(env, db), script_config.evm_opts.initial_balance, sender) + Ok(ScriptRunner::new( + builder.build(env, db), + script_config.evm_opts.initial_balance, + sender, + )) } } diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 956e583ab2d6b..60fdfa3103458 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -105,9 +105,9 @@ impl VerificationProvider for EtherscanVerificationProvider { warn!("Failed verify submission: {:?}", resp); eprintln!( - "Encountered an error verifying this contract:\nResponse: `{}`\nDetails: `{}`", - resp.message, resp.result - ); + "Encountered an error verifying this contract:\nResponse: `{}`\nDetails: `{}`", + resp.message, resp.result + ); std::process::exit(1); } @@ -117,8 +117,7 @@ impl VerificationProvider for EtherscanVerificationProvider { if let Some(resp) = resp { println!( - "Submitted contract for verification:\n\tResponse: `{}`\n\tGUID: `{}`\n\tURL: - {}", + "Submitted contract for verification:\n\tResponse: `{}`\n\tGUID: `{}`\n\tURL: {}", resp.message, resp.result, etherscan.address_url(args.address) From 77e977fd1aeb15992cec47e62fdde6ed0441c015 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 19 Jan 2024 17:13:10 +0100 Subject: [PATCH 0508/1963] chore: update alloy (#6857) --- Cargo.lock | 26 +++++++++++++------------- crates/anvil/src/eth/api.rs | 10 +++------- crates/anvil/src/eth/backend/fork.rs | 5 ++--- crates/evm/core/src/fork/backend.rs | 4 +--- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 568e5e85bf2f4..8dbe652e1c27a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-primitives", "serde", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -252,7 +252,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#ccc6c9340be86cf6c054776747daf70ce18cc4aa" +source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" dependencies = [ "alloy-pubsub", "alloy-transport", diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index f99b8eb1274b1..8337ce6d30012 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -632,13 +632,9 @@ impl EthApi { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { return Ok(B256::from( - fork.storage_at( - address, - B256::from(index), - Some(BlockNumber::Number(number)), - ) - .await - .map_err(|_| BlockchainError::DataUnavailable)?, + fork.storage_at(address, index, Some(BlockNumber::Number(number))) + .await + .map_err(|_| BlockchainError::DataUnavailable)?, )); } } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 857d241cce539..75312b6a63bb9 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -1,7 +1,7 @@ //! Support for forking off another client use crate::eth::{backend::db::Db, error::BlockchainError}; -use alloy_primitives::{Address, Bytes, StorageKey, StorageValue, B256, U256, U64}; +use alloy_primitives::{Address, Bytes, StorageValue, B256, U256, U64}; use alloy_providers::provider::TempProvider; use alloy_rpc_trace_types::{ geth::{GethDebugTracingOptions, GethTrace}, @@ -238,10 +238,9 @@ impl ClientFork { pub async fn storage_at( &self, address: Address, - index: StorageKey, + index: U256, number: Option, ) -> Result { - let index = B256::from(index); self.provider().get_storage_at(address, index, number.map(Into::into)).await } diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 7932edf19ca79..0748c2eb98e8f 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -179,9 +179,7 @@ where let provider = self.provider.clone(); let block_id = self.block_id; let fut = Box::pin(async move { - // serialize & deserialize back to U256 - let idx_req = B256::from(idx); - let storage = provider.get_storage_at(address, idx_req, block_id).await; + let storage = provider.get_storage_at(address, idx, block_id).await; (storage.wrap_err("could not fetch slot {idx} from {address}"), address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); From 6b2633c6fe7d894c4ae46899f9cd928e4d49d227 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 19 Jan 2024 17:24:42 +0100 Subject: [PATCH 0509/1963] feat(chisel): add --no-vm option, enabled by default for old Solc versions (#6854) * feat(chisel): add --no-vm option, enabled by default for old Solc versions * fix * feat: allow >=0.6.2 <0.8.4 * chore: clippy --- crates/cheatcodes/spec/src/lib.rs | 7 +- crates/chisel/benches/session_source.rs | 13 +--- crates/chisel/bin/main.rs | 9 +++ crates/chisel/src/session_source.rs | 93 ++++++++++++++++--------- crates/chisel/tests/cache.rs | 6 +- crates/evm/core/src/fork/backend.rs | 7 +- testdata/cheats/Vm.sol | 4 +- 7 files changed, 81 insertions(+), 58 deletions(-) diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index f524e458d2fed..10a53e18d8741 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -120,14 +120,17 @@ mod tests { } fn sol_iface() -> String { - let cheats = Cheatcodes::new().to_string().trim().replace('\n', "\n "); + let mut cheats = Cheatcodes::new(); + cheats.errors = Default::default(); // Skip errors to allow <0.8.4. + let cheats = cheats.to_string().trim().replace('\n', "\n "); format!( "\ // Automatically generated from `foundry-cheatcodes` Vm definitions. Do not modify manually. // This interface is just for internal testing purposes. Use `forge-std` instead. // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity ^0.8.4; +pragma solidity >=0.6.2 <0.9.0; +pragma experimental ABIEncoderV2; interface Vm {{ {cheats} diff --git a/crates/chisel/benches/session_source.rs b/crates/chisel/benches/session_source.rs index 3088c3efe41ff..3c3196956b950 100644 --- a/crates/chisel/benches/session_source.rs +++ b/crates/chisel/benches/session_source.rs @@ -1,8 +1,6 @@ use chisel::session_source::{SessionSource, SessionSourceConfig}; use criterion::{criterion_group, Criterion}; use foundry_compilers::Solc; -use foundry_config::Config; -use foundry_evm::opts::EvmOpts; use once_cell::sync::Lazy; use std::hint::black_box; use tokio::runtime::Runtime; @@ -66,16 +64,7 @@ fn inspect(c: &mut Criterion) { /// Helper function for getting an empty [SessionSource] with default configuration fn get_empty_session_source() -> SessionSource { - SessionSource::new( - SOLC.clone(), - SessionSourceConfig { - foundry_config: Config::default(), - evm_opts: EvmOpts::default(), - backend: None, - traces: false, - calldata: None, - }, - ) + SessionSource::new(SOLC.clone(), SessionSourceConfig::default()) } fn rt() -> Runtime { diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index a6819ebb6e60e..d9028965a6270 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -53,6 +53,14 @@ pub struct ChiselParser { #[clap(long, help_heading = "REPL options")] pub prelude: Option, + /// Disable the default `Vm` import. + #[clap(long, help_heading = "REPL options", long_help = format!( + "Disable the default `Vm` import.\n\n\ + The import is disabled by default if the Solc version is less than {}.", + chisel::session_source::MIN_VM_VERSION + ))] + pub no_vm: bool, + #[clap(flatten)] pub opts: CoreBuildArgs, @@ -107,6 +115,7 @@ async fn main() -> eyre::Result<()> { // Enable traces if any level of verbosity was passed traces: config.verbosity > 0, foundry_config: config, + no_vm: args.no_vm, evm_opts, backend: None, calldata: None, diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 3e4efa2fd8c8f..322598e36940f 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -18,6 +18,9 @@ use solang_parser::pt; use std::{collections::HashMap, fs, path::PathBuf}; use yansi::Paint; +/// The minimum Solidity version of the `Vm` interface. +pub const MIN_VM_VERSION: Version = Version::new(0, 6, 2); + /// Solidity source for the `Vm` interface in [forge-std](https://github.com/foundry-rs/forge-std) static VM_SOURCE: &str = include_str!("../../../testdata/cheats/Vm.sol"); @@ -69,6 +72,8 @@ pub struct SessionSourceConfig { pub foundry_config: Config, /// EVM Options pub evm_opts: EvmOpts, + /// Disable the default `Vm` import. + pub no_vm: bool, #[serde(skip)] /// In-memory REVM db for the session's runner. pub backend: Option, @@ -184,9 +189,13 @@ impl SessionSource { /// /// A new instance of [SessionSource] #[track_caller] - pub fn new(solc: Solc, config: SessionSourceConfig) -> Self { - #[cfg(debug_assertions)] - let _ = solc.version().unwrap(); + pub fn new(solc: Solc, mut config: SessionSourceConfig) -> Self { + if let Ok(v) = solc.version_short() { + if v < MIN_VM_VERSION && !config.no_vm { + tracing::info!(version=%v, minimum=%MIN_VM_VERSION, "Disabling VM injection"); + config.no_vm = true; + } + } Self { file_name: PathBuf::from("ReplContract.sol".to_string()), @@ -315,14 +324,15 @@ impl SessionSource { sources.insert(self.file_name.clone(), Source::new(self.to_repl_source())); // Include Vm.sol if forge-std remapping is not available - if !self - .config - .foundry_config - .get_all_remappings() - .into_iter() - .any(|r| r.name.starts_with("forge-std")) + if !self.config.no_vm && + !self + .config + .foundry_config + .get_all_remappings() + .into_iter() + .any(|r| r.name.starts_with("forge-std")) { - sources.insert(PathBuf::from("forge-std/Vm.sol"), Source::new(VM_SOURCE.to_owned())); + sources.insert(PathBuf::from("forge-std/Vm.sol"), Source::new(VM_SOURCE)); } // we only care about the solidity source, so we can safely unwrap @@ -446,24 +456,27 @@ impl SessionSource { /// The [SessionSource] represented as a Forge Script contract. pub fn to_script_source(&self) -> String { let Version { major, minor, patch, .. } = self.solc.version().unwrap(); + let Self { contract_name, global_code, top_level_code, run_code, config, .. } = self; + + let script_import = + if !config.no_vm { "import {Script} from \"forge-std/Script.sol\";\n" } else { "" }; + format!( r#" // SPDX-License-Identifier: UNLICENSED pragma solidity ^{major}.{minor}.{patch}; -import {{Script}} from "forge-std/Script.sol"; -{} +{script_import} +{global_code} -contract {} is Script {{ - {} - +contract {contract_name} is Script {{ + {top_level_code} + /// @notice Script entry point function run() public {{ - {} + {run_code} }} -}} - "#, - self.global_code, self.contract_name, self.top_level_code, self.run_code, +}}"#, ) } @@ -474,25 +487,34 @@ contract {} is Script {{ /// The [SessionSource] represented as a REPL contract. pub fn to_repl_source(&self) -> String { let Version { major, minor, patch, .. } = self.solc.version().unwrap(); + let Self { contract_name, global_code, top_level_code, run_code, config, .. } = self; + + let (vm_import, vm_constant) = if !config.no_vm { + ( + "import {Vm} from \"forge-std/Vm.sol\";\n", + "Vm internal constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n" + ) + } else { + ("", "") + }; + format!( r#" // SPDX-License-Identifier: UNLICENSED pragma solidity ^{major}.{minor}.{patch}; -import {{Vm}} from "forge-std/Vm.sol"; -{} +{vm_import} +{global_code} -contract {} {{ - Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); - {} +contract {contract_name} {{ + {vm_constant} + {top_level_code} /// @notice REPL contract entry point function run() public {{ - {} + {run_code} }} -}} - "#, - self.global_code, self.contract_name, self.top_level_code, self.run_code, +}}"#, ) } @@ -646,14 +668,17 @@ pub fn parse_fragment( ) -> Option { let mut base = SessionSource::new(solc, config); - if base.clone().with_run_code(buffer).parse().is_ok() { - return Some(ParseTreeFragment::Function) + match base.clone().with_run_code(buffer).parse() { + Ok(_) => return Some(ParseTreeFragment::Function), + Err(e) => tracing::debug!(?e), } - if base.clone().with_top_level_code(buffer).parse().is_ok() { - return Some(ParseTreeFragment::Contract) + match base.clone().with_top_level_code(buffer).parse() { + Ok(_) => return Some(ParseTreeFragment::Contract), + Err(e) => tracing::debug!(?e), } - if base.with_global_code(buffer).parse().is_ok() { - return Some(ParseTreeFragment::Source) + match base.with_global_code(buffer).parse() { + Ok(_) => return Some(ParseTreeFragment::Source), + Err(e) => tracing::debug!(?e), } None diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index ff5fe60fc91b6..9173e8bc791df 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -1,7 +1,6 @@ use chisel::session::ChiselSession; use foundry_compilers::EvmVersion; use foundry_config::Config; -use foundry_evm::opts::EvmOpts; use serial_test::serial; use std::path::Path; @@ -43,10 +42,7 @@ fn test_write_session() { // Create a new session let mut env = ChiselSession::new(chisel::session_source::SessionSourceConfig { foundry_config, - evm_opts: EvmOpts::default(), - backend: None, - traces: false, - calldata: None, + ..Default::default() }) .unwrap_or_else(|e| panic!("Failed to create ChiselSession!, {}", e)); diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 0748c2eb98e8f..eb3638ecea87f 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -174,13 +174,14 @@ where entry.get_mut().push(listener); } Entry::Vacant(entry) => { - trace!(target: "backendhandler", "preparing storage request, address={:?}, idx={}", address, idx); + trace!(target: "backendhandler", %address, %idx, "preparing storage request"); entry.insert(vec![listener]); let provider = self.provider.clone(); let block_id = self.block_id; let fut = Box::pin(async move { - let storage = provider.get_storage_at(address, idx, block_id).await; - (storage.wrap_err("could not fetch slot {idx} from {address}"), address, idx) + let storage = + provider.get_storage_at(address, idx, block_id).await.map_err(Into::into); + (storage, address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 82a4b84358fc4..7a1be2721b9a1 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -2,10 +2,10 @@ // This interface is just for internal testing purposes. Use `forge-std` instead. // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity ^0.8.4; +pragma solidity >=0.6.2 <0.9.0; +pragma experimental ABIEncoderV2; interface Vm { - error CheatcodeError(string message); enum CallerMode { None, Broadcast, RecurrentBroadcast, Prank, RecurrentPrank } enum AccountAccessKind { Call, DelegateCall, CallCode, StaticCall, Create, SelfDestruct, Resume, Balance, Extcodesize, Extcodehash, Extcodecopy } struct Log { bytes32[] topics; bytes data; address emitter; } From 5240bba44efe3620df71da959efd124a50a754aa Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 19 Jan 2024 21:35:08 +0400 Subject: [PATCH 0510/1963] Bump foundry-compilers (#6858) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8dbe652e1c27a..6ee3ceab2fd99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3068,9 +3068,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ee41934709326534bf5fdc3b6e438d1c39c9cad019a7ec5b9fcdb28019a0e5" +checksum = "5409d75d032836be70c1786c20cd135e3c4ae21e397db97f2cd0a321d3e41c37" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 83654e64fbad7..de2fdf63dbfb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,7 +125,7 @@ foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.0", default-features = false } -foundry-compilers = { version = "0.2.1", default-features = false } +foundry-compilers = { version = "0.2.2", default-features = false } ## revm # no default features to avoid c-kzg From 4c73702d605287c39cb73a6d9a6879c5c3ead0dc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 20 Jan 2024 08:11:12 +0100 Subject: [PATCH 0511/1963] feat: resolve multiple function/event selectors in one openchain.xyz request (#6863) * feat(common): send multiple selectors in one request to openchain.xyz * feat(evm/traces): resolve multiple selectors in one request * chore:touchups --------- Co-authored-by: Maxim Andreev --- crates/common/src/selectors.rs | 130 +++++++++++++----- crates/evm/traces/src/decoder/mod.rs | 25 +++- .../evm/traces/src/identifier/signatures.rs | 75 +++++----- crates/evm/traces/src/lib.rs | 2 + 4 files changed, 163 insertions(+), 69 deletions(-) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 576af2b9f1190..13979b3874ecf 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -16,8 +16,8 @@ use std::{ time::Duration, }; -static SELECTOR_DATABASE_URL: &str = "https://api.openchain.xyz/signature-database/v1/"; -static SELECTOR_IMPORT_URL: &str = "https://api.openchain.xyz/signature-database/v1/import"; +const SELECTOR_LOOKUP_URL: &str = "https://api.openchain.xyz/signature-database/v1/lookup"; +const SELECTOR_IMPORT_URL: &str = "https://api.openchain.xyz/signature-database/v1/import"; /// The standard request timeout for API requests const REQ_TIMEOUT: Duration = Duration::from_secs(15); @@ -98,13 +98,13 @@ impl SignEthClient { fn on_reqwest_err(&self, err: &reqwest::Error) { fn is_connectivity_err(err: &reqwest::Error) -> bool { if err.is_timeout() || err.is_connect() { - return true + return true; } // Error HTTP codes (5xx) are considered connectivity issues and will prompt retry if let Some(status) = err.status() { let code = status.as_u16(); if (500..600).contains(&code) { - return true + return true; } } false @@ -142,19 +142,51 @@ impl SignEthClient { selector: &str, selector_type: SelectorType, ) -> eyre::Result> { + self.decode_selectors(selector_type, std::iter::once(selector)) + .await? + .pop() // Not returning on the previous line ensures a vector with exactly 1 element + .unwrap() + .ok_or(eyre::eyre!("No signature found")) + } + + /// Decodes the given function or event selectors using https://api.openchain.xyz + pub async fn decode_selectors( + &self, + selector_type: SelectorType, + selectors: impl IntoIterator>, + ) -> eyre::Result>>> { + let selectors: Vec = selectors + .into_iter() + .map(Into::into) + .map(|s| if s.starts_with("0x") { s } else { format!("0x{s}") }) + .collect(); + + if selectors.is_empty() { + return Ok(vec![]); + } + // exit early if spurious connection self.ensure_not_spurious()?; + let expected_len = match selector_type { + SelectorType::Function => 10, // 0x + hex(4bytes) + SelectorType::Event => 66, // 0x + hex(32bytes) + }; + if let Some(s) = selectors.iter().find(|s| s.len() != expected_len) { + eyre::bail!( + "Invalid selector {s}: expected {expected_len} characters (including 0x prefix)." + ) + } + #[derive(Deserialize)] struct Decoded { name: String, - filtered: bool, } #[derive(Deserialize)] struct ApiResult { - event: HashMap>, - function: HashMap>, + event: HashMap>>, + function: HashMap>>, } #[derive(Deserialize)] @@ -165,10 +197,14 @@ impl SignEthClient { // using openchain.xyz signature database over 4byte // see https://github.com/foundry-rs/foundry/issues/1672 - let url = match selector_type { - SelectorType::Function => format!("{SELECTOR_DATABASE_URL}lookup?function={selector}"), - SelectorType::Event => format!("{SELECTOR_DATABASE_URL}lookup?event={selector}"), - }; + let url = format!( + "{SELECTOR_LOOKUP_URL}?{ltype}={selectors_str}", + ltype = match selector_type { + SelectorType::Function => "function", + SelectorType::Event => "event", + }, + selectors_str = selectors.join(",") + ); let res = self.get_text(&url).await?; let api_response = match serde_json::from_str::(&res) { @@ -187,27 +223,18 @@ impl SignEthClient { SelectorType::Event => api_response.result.event, }; - Ok(decoded - .get(selector) - .ok_or_else(|| eyre::eyre!("No signature found"))? - .iter() - .filter(|&d| !d.filtered) - .map(|d| d.name.clone()) - .collect::>()) + Ok(selectors + .into_iter() + .map(|selector| match decoded.get(&selector) { + Some(Some(r)) => Some(r.iter().map(|d| d.name.clone()).collect()), + _ => None, + }) + .collect()) } /// Fetches a function signature given the selector using https://api.openchain.xyz pub async fn decode_function_selector(&self, selector: &str) -> eyre::Result> { - let stripped_selector = selector.strip_prefix("0x").unwrap_or(selector); - let prefixed_selector = format!("0x{}", stripped_selector); - if prefixed_selector.len() != 10 { - eyre::bail!( - "Invalid selector: expected 8 characters (excluding 0x prefix), got {}.", - stripped_selector.len() - ) - } - - self.decode_selector(&prefixed_selector[..10], SelectorType::Function).await + self.decode_selector(selector, SelectorType::Function).await } /// Fetches all possible signatures and attempts to abi decode the calldata @@ -232,11 +259,7 @@ impl SignEthClient { /// Fetches an event signature given the 32 byte topic using https://api.openchain.xyz pub async fn decode_event_topic(&self, topic: &str) -> eyre::Result> { - let prefixed_topic = format!("0x{}", topic.strip_prefix("0x").unwrap_or(topic)); - if prefixed_topic.len() != 66 { - eyre::bail!("Invalid topic: expected 64 characters (excluding 0x prefix), got {} characters (including 0x prefix).", prefixed_topic.len()) - } - self.decode_selector(&prefixed_topic[..66], SelectorType::Event).await + self.decode_selector(topic, SelectorType::Event).await } /// Pretty print calldata and if available, fetch possible function signatures @@ -376,12 +399,20 @@ pub enum SelectorType { /// Decodes the given function or event selector using https://api.openchain.xyz pub async fn decode_selector( - selector: &str, selector_type: SelectorType, + selector: &str, ) -> eyre::Result> { SignEthClient::new()?.decode_selector(selector, selector_type).await } +/// Decodes the given function or event selectors using https://api.openchain.xyz +pub async fn decode_selectors( + selector_type: SelectorType, + selectors: impl IntoIterator>, +) -> eyre::Result>>> { + SignEthClient::new()?.decode_selectors(selector_type, selectors).await +} + /// Fetches a function signature given the selector https://api.openchain.xyz pub async fn decode_function_selector(selector: &str) -> eyre::Result> { SignEthClient::new()?.decode_function_selector(selector).await @@ -569,7 +600,7 @@ mod tests { .map_err(|e| { assert_eq!( e.to_string(), - "Invalid selector: expected 8 characters (excluding 0x prefix), got 6." + "Invalid selector 0xa9059c: expected 10 characters (including 0x prefix)." ) }) .map(|_| panic!("Expected fourbyte error")) @@ -685,4 +716,33 @@ mod tests { .await; assert_eq!(decoded.unwrap()[0], "canCall(address,address,bytes4)".to_string()); } + + #[tokio::test(flavor = "multi_thread")] + async fn test_decode_selectors() { + let event_topics = vec![ + "7e1db2a1cd12f0506ecd806dba508035b290666b84b096a87af2fd2a1516ede6", + "0xb7009613e63fb13fd59a2fa4c206a992c1f090a44e5d530be255aa17fed0b3dd", + ]; + let decoded = decode_selectors(SelectorType::Event, event_topics).await; + let decoded = decoded.unwrap(); + assert_eq!( + decoded, + vec![ + Some(vec!["updateAuthority(address,uint8)".to_string()]), + Some(vec!["canCall(address,address,bytes4)".to_string()]), + ] + ); + + let function_selectors = vec!["0xa9059cbb", "0x70a08231", "313ce567"]; + let decoded = decode_selectors(SelectorType::Function, function_selectors).await; + let decoded = decoded.unwrap(); + assert_eq!( + decoded, + vec![ + Some(vec!["transfer(address,uint256)".to_string()]), + Some(vec!["balanceOf(address)".to_string()]), + Some(vec!["decimals()".to_string()]), + ] + ); + } } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 29b46ad6c6bef..9f430912d5a75 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -2,7 +2,7 @@ use crate::{ identifier::{ AddressIdentity, LocalTraceIdentifier, SingleSignaturesIdentifier, TraceIdentifier, }, - CallTrace, CallTraceArena, DecodedCallData, DecodedCallLog, DecodedCallTrace, + CallTrace, CallTraceArena, CallTraceNode, DecodedCallData, DecodedCallLog, DecodedCallTrace, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Event, Function, JsonAbi}; @@ -505,6 +505,29 @@ impl CallTraceDecoder { DecodedCallLog::Raw(log) } + /// Prefetches function and event signatures into the identifier cache + pub async fn prefetch_signatures(&self, nodes: &[CallTraceNode]) { + let Some(identifier) = &self.signature_identifier else { return }; + + let events_it = nodes + .iter() + .flat_map(|node| node.logs.iter().filter_map(|log| log.topics().first())) + .unique(); + identifier.write().await.identify_events(events_it).await; + + const DEFAULT_CREATE2_DEPLOYER_BYTES: [u8; 20] = DEFAULT_CREATE2_DEPLOYER.0 .0; + let funcs_it = nodes + .iter() + .filter_map(|n| match n.trace.address.0 .0 { + DEFAULT_CREATE2_DEPLOYER_BYTES => None, + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01..=0x0a] => None, + _ => n.trace.data.get(..SELECTOR_LEN), + }) + .filter(|v| !self.functions.contains_key(*v)) + .unique(); + identifier.write().await.identify_functions(funcs_it).await; + } + fn apply_label(&self, value: &DynSolValue) -> String { if let DynSolValue::Address(addr) = value { if let Some(label) = self.labels.get(addr) { diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 7809a1c554737..46766b0a88028 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -26,7 +26,7 @@ pub struct SignaturesIdentifier { /// Location where to save `CachedSignatures` cached_path: Option, /// Selectors that were unavailable during the session. - unavailable: HashSet>, + unavailable: HashSet, /// The API client to fetch signatures from sign_eth_api: SignEthClient, /// whether traces should be decoded via `sign_eth_api` @@ -95,59 +95,68 @@ impl SignaturesIdentifier { async fn identify( &mut self, selector_type: SelectorType, - identifier: &[u8], + identifiers: impl IntoIterator>, get_type: impl Fn(&str) -> eyre::Result, - ) -> Option { - // Exit early if we have unsuccessfully queried it before. - if self.unavailable.contains(identifier) { - return None - } - - let map = match selector_type { + ) -> Vec> { + let cache = match selector_type { SelectorType::Function => &mut self.cached.functions, SelectorType::Event => &mut self.cached.events, }; - let hex_identifier = hex::encode_prefixed(identifier); + let hex_identifiers: Vec = + identifiers.into_iter().map(hex::encode_prefixed).collect(); + + if !self.offline { + let query: Vec<_> = hex_identifiers + .iter() + .filter(|v| !cache.contains_key(v.as_str())) + .filter(|v| !self.unavailable.contains(v.as_str())) + .collect(); - if !self.offline && !map.contains_key(&hex_identifier) { - if let Ok(signatures) = - self.sign_eth_api.decode_selector(&hex_identifier, selector_type).await + if let Ok(res) = self.sign_eth_api.decode_selectors(selector_type, query.clone()).await { - if let Some(signature) = signatures.into_iter().next() { - map.insert(hex_identifier.clone(), signature); + for (hex_id, selector_result) in query.into_iter().zip(res.into_iter()) { + let mut found = false; + if let Some(decoded_results) = selector_result { + if let Some(decoded_result) = decoded_results.into_iter().next() { + cache.insert(hex_id.clone(), decoded_result); + found = true; + } + } + if !found { + self.unavailable.insert(hex_id.clone()); + } } } } - if let Some(signature) = map.get(&hex_identifier) { - return get_type(signature).ok() - } - - self.unavailable.insert(identifier.to_vec()); - - None + hex_identifiers.iter().map(|v| cache.get(v).and_then(|v| get_type(v).ok())).collect() } - /// Returns `None` if in offline mode - fn ensure_not_offline(&self) -> Option<()> { - if self.offline { - None - } else { - Some(()) - } + /// Identifies `Function`s from its cache or `https://api.openchain.xyz` + pub async fn identify_functions( + &mut self, + identifiers: impl IntoIterator>, + ) -> Vec> { + self.identify(SelectorType::Function, identifiers, get_func).await } /// Identifies `Function` from its cache or `https://api.openchain.xyz` pub async fn identify_function(&mut self, identifier: &[u8]) -> Option { - self.ensure_not_offline()?; - self.identify(SelectorType::Function, identifier, get_func).await + self.identify_functions(&[identifier]).await.pop().unwrap() + } + + /// Identifies `Event`s from its cache or `https://api.openchain.xyz` + pub async fn identify_events( + &mut self, + identifiers: impl IntoIterator>, + ) -> Vec> { + self.identify(SelectorType::Event, identifiers, get_event).await } /// Identifies `Event` from its cache or `https://api.openchain.xyz` pub async fn identify_event(&mut self, identifier: &[u8]) -> Option { - self.ensure_not_offline()?; - self.identify(SelectorType::Event, identifier, get_event).await + self.identify_events(&[identifier]).await.pop().unwrap() } } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 7ad2f6bf09752..91a693656d90d 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -71,6 +71,8 @@ pub async fn render_trace_arena( arena: &CallTraceArena, decoder: &CallTraceDecoder, ) -> Result { + decoder.prefetch_signatures(arena.nodes()).await; + fn inner<'a>( arena: &'a [CallTraceNode], decoder: &'a CallTraceDecoder, From eeef40c0b92c2d53de0159df9bbcdd0a5bac0e08 Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Sat, 20 Jan 2024 11:13:23 +0300 Subject: [PATCH 0512/1963] feat(cast/selectors): add optional selectors resolving (#6864) --- crates/cast/bin/main.rs | 31 +++++++++++++++++++++++++------ crates/cast/bin/opts.rs | 9 ++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index eacae735465d5..24d7b62904a40 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -14,8 +14,9 @@ use foundry_common::{ fmt::format_tokens, fs, selectors::{ - decode_calldata, decode_event_topic, decode_function_selector, import_selectors, - parse_signatures, pretty_calldata, ParsedSignatures, SelectorImportData, + decode_calldata, decode_event_topic, decode_function_selector, decode_selectors, + import_selectors, parse_signatures, pretty_calldata, ParsedSignatures, SelectorImportData, + SelectorType, }, types::{ToAlloy, ToEthers}, }; @@ -269,10 +270,28 @@ async fn main() -> Result<()> { Subcommands::Disassemble { bytecode } => { println!("{}", SimpleCast::disassemble(&bytecode)?); } - Subcommands::Selectors { bytecode } => { - let s = SimpleCast::extract_selectors(&bytecode)?; - let v: Vec<_> = s.into_iter().map(|r| format!("{}\t{}", r.0, r.1)).collect(); - println!("{}", v.join("\n")); + Subcommands::Selectors { bytecode, resolve } => { + let selectors_and_args = SimpleCast::extract_selectors(&bytecode)?; + if resolve { + let selectors_it = selectors_and_args.iter().map(|r| &r.0); + let resolve_results = + decode_selectors(SelectorType::Function, selectors_it).await?; + + let max_args_len = selectors_and_args.iter().map(|r| r.1.len()).max().unwrap_or(0); + for ((selector, arguments), func_names) in + selectors_and_args.into_iter().zip(resolve_results.into_iter()) + { + let resolved = match func_names { + Some(v) => v.join("|"), + None => "".to_string(), + }; + println!("{selector}\t{arguments:max_args_len$}\t{resolved}"); + } + } else { + for (selector, arguments) in selectors_and_args { + println!("{selector}\t{arguments}"); + } + } } Subcommands::FindBlock(cmd) => cmd.run().await?, Subcommands::GasPrice { rpc } => { diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index c4a2fd0ba3413..141861a9e3801 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -862,7 +862,14 @@ pub enum Subcommands { /// Extracts function selectors and arguments from bytecode #[clap(visible_alias = "sel")] - Selectors { bytecode: String }, + Selectors { + /// The hex encoded bytecode. + bytecode: String, + + /// Resolve the function signatures for the extracted selectors using https://openchain.xyz + #[clap(long, short)] + resolve: bool, + }, } /// CLI arguments for `cast --to-base`. From d2e264c615a662f4b87863c6c0c796c697c00084 Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Sat, 20 Jan 2024 13:53:30 +0300 Subject: [PATCH 0513/1963] fix(cast) lowercase selectors before send API request to openchain.xyz (#6865) --- crates/common/src/selectors.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 13979b3874ecf..cda4ccb6c9219 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -158,6 +158,7 @@ impl SignEthClient { let selectors: Vec = selectors .into_iter() .map(Into::into) + .map(|s| s.to_lowercase()) .map(|s| if s.starts_with("0x") { s } else { format!("0x{s}") }) .collect(); From d0a4452212f54cfe6b6ef03cf4f92c013e38af04 Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Sat, 20 Jan 2024 14:04:25 +0300 Subject: [PATCH 0514/1963] fix(cast): add description to 'cast wallet derive-private-key' (#6866) --- crates/cast/bin/cmd/wallet/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index c38826ce152a2..6a026904dcbab 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -139,6 +139,7 @@ pub enum WalletSubcommands { #[clap(visible_alias = "ls")] List, + /// Derives private key from mnemonic #[clap(name = "derive-private-key", visible_aliases = &["--derive-private-key"])] DerivePrivateKey { mnemonic: String, mnemonic_index: Option }, } From 7116e2429434ecb1b8ea71fd1dc90a5ab6e0968c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 21 Jan 2024 11:35:00 +0100 Subject: [PATCH 0515/1963] chore(deps): weekly `cargo update` (#6870) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating git repository `https://github.com/alloy-rs/alloy` Updating alloy-consensus v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-network v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-providers v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-pubsub v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-rpc-client v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-rpc-trace-types v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-rpc-types v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-transport v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-transport-http v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-transport-ipc v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating alloy-transport-ws v0.1.0 (https://github.com/alloy-rs/alloy#e4092e25) -> #42778ba4 Updating anstream v0.6.7 -> v0.6.11 Updating bitflags v2.4.1 -> v2.4.2 Updating clap v4.4.17 -> v4.4.18 Updating clap_builder v4.4.17 -> v4.4.18 Updating clap_complete v4.4.7 -> v4.4.8 Updating env_logger v0.10.1 -> v0.10.2 Updating evmole v0.3.1 -> v0.3.2 Updating figment v0.10.13 -> v0.10.14 Updating gix-utils v0.1.8 -> v0.1.9 Updating hermit-abi v0.3.3 -> v0.3.4 Updating linux-raw-sys v0.4.12 -> v0.4.13 Updating openssl v0.10.62 -> v0.10.63 Updating openssl-sys v0.9.98 -> v0.9.99 Updating pkg-config v0.3.28 -> v0.3.29 Updating proc-macro-crate v3.0.0 -> v3.1.0 Updating rayon v1.8.0 -> v1.8.1 Updating rayon-core v1.12.0 -> v1.12.1 Updating revm-inspectors v0.1.0 (https://github.com/paradigmxyz/evm-inspectors#29bb8540) -> #5ee90076 Updating smallvec v1.12.0 -> v1.13.1 Updating unicode-bidi v0.3.14 -> v0.3.15 Updating vergen v8.3.0 -> v8.3.1 Co-authored-by: mattsse --- Cargo.lock | 141 +++++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ee3ceab2fd99..db3c1f8aa359d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-primitives", "serde", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -252,7 +252,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e4092e255b933605382f7b5dc25d67dcce54c7db" +source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -431,9 +431,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.7" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", @@ -986,7 +986,7 @@ version = "0.66.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cexpr", "clang-sys", "lazy_static", @@ -1026,9 +1026,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" dependencies = [ "arbitrary", "serde", @@ -1419,9 +1419,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.17" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", "clap_derive", @@ -1429,9 +1429,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.17" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstream", "anstyle", @@ -1444,9 +1444,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb0d4825b75ff281318c393e8e1b80c4da9fb75a6b1d98547d389d6fe1f48d2" +checksum = "eaf7dcb7c21d8ca1a2482ee0f1d341f437c9a7af6ca6da359dc5e1b164e98215" dependencies = [ "clap", ] @@ -1824,7 +1824,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "crossterm_winapi", "libc", "mio", @@ -2205,9 +2205,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -2629,9 +2629,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f492d1949e58ef83a1bf8e23fbd042af12b03e7642d50dbb4cfb48112de5e01f" +checksum = "8ef57dfcf13fc3486c3a760427d88ab0d97cb911f7104fe5a132f2b934d0fe29" dependencies = [ "ruint", ] @@ -2720,9 +2720,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.13" +version = "0.10.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7629b8c7bcd214a072c2c88b263b5bb3ceb54c34365d8c41c1665461aeae0993" +checksum = "2b6e5bc7bd59d60d0d45a6ccab6cf0f4ce28698fb4e81e750ddf229c9b824026" dependencies = [ "atomic", "parking_lot", @@ -3538,7 +3538,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "libgit2-sys", "log", @@ -3587,7 +3587,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bstr", "gix-path", "libc", @@ -3633,7 +3633,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bstr", "gix-features", "gix-path", @@ -3718,7 +3718,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "gix-path", "libc", "windows", @@ -3745,11 +3745,12 @@ checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" [[package]] name = "gix-utils" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de6225e2de30b6e9bca2d9f1cc4731640fcef0fb3cabddceee366e7e85d3e94f" +checksum = "56e839f3d0798b296411263da6bee780a176ef8008a5dfc31287f7eda9266ab8" dependencies = [ "fastrand", + "unicode-normalization", ] [[package]] @@ -3895,9 +3896,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -4531,7 +4532,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall", ] @@ -4562,9 +4563,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -4844,7 +4845,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "libc", ] @@ -5004,7 +5005,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5090,11 +5091,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.62" +version = "0.10.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "foreign-types", "libc", @@ -5122,9 +5123,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.98" +version = "0.9.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" dependencies = [ "cc", "libc", @@ -5579,9 +5580,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "plotters" @@ -5699,9 +5700,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ "toml_edit 0.21.0", ] @@ -5771,7 +5772,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.1", + "bitflags 2.4.2", "lazy_static", "num-traits", "rand 0.8.5", @@ -5942,7 +5943,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cassowary", "crossterm", "indoc", @@ -5956,9 +5957,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" dependencies = [ "either", "rayon-core", @@ -5966,9 +5967,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -6117,7 +6118,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#29bb854055855daf84c5aac796681e3aae208895" +source = "git+https://github.com/paradigmxyz/evm-inspectors#5ee90076f88e64a059e4c0c268929cf9ec91ed6d" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6160,7 +6161,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "auto_impl", - "bitflags 2.4.1", + "bitflags 2.4.2", "bitvec", "c-kzg", "enumn", @@ -6426,7 +6427,7 @@ version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -6512,7 +6513,7 @@ version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "clipboard-win", "fd-lock 3.0.13", @@ -7009,9 +7010,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -7640,7 +7641,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "futures-core", "futures-util", @@ -7878,9 +7879,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-bom" @@ -7980,9 +7981,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.3.0" +version = "8.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0d895592fa7710eba03fe072e614e3dc6a61ab76ae7ae10d2eb4a7ed5b00ca" +checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" dependencies = [ "anyhow", "cfg-if", From d91748a1181d0ff234509b00265aa843463c21d2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 21 Jan 2024 12:18:29 +0100 Subject: [PATCH 0516/1963] test: add chain id to legacy rlp test (#6871) --- crates/anvil/core/src/eth/transaction/alloy.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/alloy.rs b/crates/anvil/core/src/eth/transaction/alloy.rs index d0608fc5f33d2..1c3ba1641aa39 100644 --- a/crates/anvil/core/src/eth/transaction/alloy.rs +++ b/crates/anvil/core/src/eth/transaction/alloy.rs @@ -919,7 +919,6 @@ mod tests { fn test_decode_call() { let bytes_first = &mut &hex::decode("f86b02843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba00eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5aea03a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18").unwrap()[..]; let decoded = TypedTransaction::decode(&mut &bytes_first[..]).unwrap(); - println!("{:?}", hex::encode(decoded.signature().as_bytes())); let tx = TxLegacy { nonce: 2u64, gas_price: 1000000000u64.into(), @@ -929,7 +928,7 @@ mod tests { )), value: U256::from(1000000000000000u64), input: Bytes::default(), - chain_id: None, + chain_id: Some(4), }; let signature = Signature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap(); @@ -940,7 +939,6 @@ mod tests { b256!("a517b206d2223278f860ea017d3626cacad4f52ff51030dc9a96b432f17f8d34"), )); - println!("{:#?}", decoded); assert_eq!(tx, decoded); } From 5ea2c5e64de91b4e470dee2abee1770ae3f79122 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 21 Jan 2024 15:55:42 +0100 Subject: [PATCH 0517/1963] fix: forge build spinner output (#6872) --- crates/common/src/compile.rs | 3 +++ crates/common/src/term.rs | 1 + crates/forge/tests/cli/build.rs | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index f0dd60e020fc4..1cc49e80e1405 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -193,6 +193,9 @@ impl ProjectCompiler { r })?; + // need to drop the reporter here, so that the spinner terminates + drop(reporter); + if bail && output.has_compiler_errors() { eyre::bail!("{output}") } diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 573bfb2f5e618..afeae0664049c 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -86,6 +86,7 @@ impl Spinner { /// /// This reporter will prefix messages with a spinning cursor #[derive(Debug)] +#[must_use = "Terminates the spinner on drop"] pub struct SpinnerReporter { /// The sender to the spinner thread. sender: mpsc::Sender, diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 2e97cb7491a72..240b5461442c8 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -24,3 +24,24 @@ contract Dummy { PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/compile_json.stdout"), ); }); + +// tests build output is as expected +forgetest_init!(exact_build_output, |prj, cmd| { + cmd.args(["build", "--force"]); + let (stdout, _) = cmd.unchecked_output_lossy(); + // Expected output from build + let expected = r#"Compiling 24 files with 0.8.23 +Solc 0.8.23 finished in 2.36s +Compiler run successful! +"#; + + // skip all dynamic parts of the output (numbers) + let expected_words = + expected.split(|c: char| c == ' ').filter(|w| !w.chars().next().unwrap().is_numeric()); + let output_words = + stdout.split(|c: char| c == ' ').filter(|w| !w.chars().next().unwrap().is_numeric()); + + for (expected, output) in expected_words.zip(output_words) { + assert_eq!(expected, output, "expected: {}, output: {}", expected, output); + } +}); From 27a1e51e72d6e462894b87c23ffa6e93cf2ea8c0 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 22 Jan 2024 15:14:59 +0100 Subject: [PATCH 0518/1963] feat(`forge`) `_expectRevertCheatcode` (#6841) * Add _expectRevertCheatcode cheats * update tests * Clear pranks and broadcasts before expecting reverts * rustfmt * Ignore reverts in CREATE * Fix tests * rustfmt + clippy * Fix extCall revert test * Review fixes * expectCheatcodeRevert * More docs * rustfmt * Add Internal status * Fix testReadDir test * pending -> pending_processing * Add doc --- crates/cheatcodes/assets/cheatcodes.json | 60 ++++++++++ .../cheatcodes/assets/cheatcodes.schema.json | 7 ++ crates/cheatcodes/spec/src/cheatcode.rs | 5 + crates/cheatcodes/spec/src/vm.rs | 12 ++ crates/cheatcodes/src/inspector.rs | 111 +++++++++++------- crates/cheatcodes/src/test.rs | 1 - crates/cheatcodes/src/test/expect.rs | 60 +++++++++- testdata/cheats/Etch.t.sol | 2 +- testdata/cheats/ExpectRevert.t.sol | 16 +++ testdata/cheats/Fs.t.sol | 46 ++++---- testdata/cheats/Json.t.sol | 26 ++-- testdata/cheats/RpcUrls.t.sol | 16 +-- testdata/cheats/Vm.sol | 3 + testdata/fixtures/Dir/depth1 | 2 +- testdata/fs/Default.t.sol | 8 +- testdata/fs/Disabled.t.sol | 10 +- testdata/repros/Issue4630.t.sol | 8 +- testdata/repros/Issue5808.t.sol | 2 +- testdata/repros/Issue6070.t.sol | 2 +- 19 files changed, 281 insertions(+), 116 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index e404eb0323070..3225893d14c39 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -413,6 +413,66 @@ } ], "cheatcodes": [ + { + "func": { + "id": "_expectCheatcodeRevert_0", + "description": "Expects an error on next cheatcode call with any revert data.", + "declaration": "function _expectCheatcodeRevert() external;", + "visibility": "external", + "mutability": "", + "signature": "_expectCheatcodeRevert()", + "selector": "0x79a4f48a", + "selectorBytes": [ + 121, + 164, + 244, + 138 + ] + }, + "group": "testing", + "status": "internal", + "safety": "unsafe" + }, + { + "func": { + "id": "_expectCheatcodeRevert_1", + "description": "Expects an error on next cheatcode call that starts with the revert data.", + "declaration": "function _expectCheatcodeRevert(bytes4 revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "_expectCheatcodeRevert(bytes4)", + "selector": "0x884cb0ae", + "selectorBytes": [ + 136, + 76, + 176, + 174 + ] + }, + "group": "testing", + "status": "internal", + "safety": "unsafe" + }, + { + "func": { + "id": "_expectCheatcodeRevert_2", + "description": "Expects an error on next cheatcode call that exactly matches the revert data.", + "declaration": "function _expectCheatcodeRevert(bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "_expectCheatcodeRevert(bytes)", + "selector": "0x7843b44d", + "selectorBytes": [ + 120, + 67, + 180, + 77 + ] + }, + "group": "testing", + "status": "internal", + "safety": "unsafe" + }, { "func": { "id": "accesses", diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index 7b68420ad63bf..31f9a1922f058 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -382,6 +382,13 @@ "enum": [ "removed" ] + }, + { + "description": "The cheatcode is only used internally for foundry testing and may be changed or removed at any time.\n\nUse of internal cheatcodes is discouraged and will result in a warning.", + "type": "string", + "enum": [ + "internal" + ] } ] }, diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index f7e0c87b306f2..b78659410b44a 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -50,6 +50,11 @@ pub enum Status { /// /// Use of removed cheatcodes will result in a hard error. Removed, + /// The cheatcode is only used internally for foundry testing and may be changed or removed at + /// any time. + /// + /// Use of internal cheatcodes is discouraged and will result in a warning. + Internal, } /// Cheatcode groups. diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 813c912d324a8..8daca4ef31d2b 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -684,6 +684,18 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectRevert(bytes calldata revertData) external; + /// Expects an error on next cheatcode call with any revert data. + #[cheatcode(group = Testing, safety = Unsafe, status = Internal)] + function _expectCheatcodeRevert() external; + + /// Expects an error on next cheatcode call that starts with the revert data. + #[cheatcode(group = Testing, safety = Unsafe, status = Internal)] + function _expectCheatcodeRevert(bytes4 revertData) external; + + /// Expects an error on next cheatcode call that exactly matches the revert data. + #[cheatcode(group = Testing, safety = Unsafe, status = Internal)] + function _expectCheatcodeRevert(bytes calldata revertData) external; + /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other /// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set. #[cheatcode(group = Testing, safety = Unsafe)] diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 854397480cba6..ee2ed1586d0cf 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -9,7 +9,8 @@ use crate::{ }, script::Broadcast, test::expect::{ - self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, ExpectedRevert, + self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, + ExpectedRevert, ExpectedRevertKind, }, CheatsConfig, CheatsCtxt, Error, Result, Vm, }; @@ -22,7 +23,7 @@ use ethers_signers::LocalWallet; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, types::ToEthers}; use foundry_evm_core::{ backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, - constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_SKIP}, + constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS}, }; use itertools::Itertools; use revm::{ @@ -130,9 +131,6 @@ pub struct Cheatcodes { /// Remembered private keys pub script_wallets: Vec, - /// Whether the skip cheatcode was activated - pub skip: bool, - /// Prank information pub prank: Option, @@ -919,38 +917,34 @@ impl Inspector for Cheatcodes { status: InstructionResult, retdata: Bytes, ) -> (InstructionResult, Gas, Bytes) { - if call.contract == CHEATCODE_ADDRESS || call.contract == HARDHAT_CONSOLE_ADDRESS { - return (status, remaining_gas, retdata); - } - - if data.journaled_state.depth() == 0 && self.skip { - return ( - InstructionResult::Revert, - remaining_gas, - super::Error::from(MAGIC_SKIP).abi_encode().into(), - ); - } - - // Clean up pranks - if let Some(prank) = &self.prank { - if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = prank.prank_origin; + let cheatcode_call = + call.contract == CHEATCODE_ADDRESS || call.contract == 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 appplied for cheatcodes in the `call` hook. + // This should be placed before the revert handling, because we might exit early there + if !cheatcode_call { + // Clean up pranks + if let Some(prank) = &self.prank { + if data.journaled_state.depth() == prank.depth { + data.env.tx.caller = prank.prank_origin; - // Clean single-call prank once we have returned to the original depth - if prank.single_call { - let _ = self.prank.take(); + // Clean single-call prank once we have returned to the original depth + if prank.single_call { + let _ = self.prank.take(); + } } } - } - // Clean up broadcast - if let Some(broadcast) = &self.broadcast { - if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = broadcast.original_origin; + // Clean up broadcast + if let Some(broadcast) = &self.broadcast { + if data.journaled_state.depth() == broadcast.depth { + data.env.tx.caller = broadcast.original_origin; - // Clean single-call broadcast once we have returned to the original depth - if broadcast.single_call { - let _ = self.broadcast.take(); + // Clean single-call broadcast once we have returned to the original depth + if broadcast.single_call { + let _ = self.broadcast.take(); + } } } } @@ -958,22 +952,49 @@ impl Inspector for Cheatcodes { // Handle expected reverts if let Some(expected_revert) = &self.expected_revert { if data.journaled_state.depth() <= expected_revert.depth { - let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - return match expect::handle_expect_revert( - false, - expected_revert.reason.as_deref(), - status, - retdata, - ) { - Err(error) => { - trace!(expected=?expected_revert, ?error, ?status, "Expected revert mismatch"); - (InstructionResult::Revert, remaining_gas, error.abi_encode().into()) + let needs_processing: bool = match expected_revert.kind { + ExpectedRevertKind::Default => !cheatcode_call, + // `pending_processing` == true means that we're in the `call_end` hook for + // `vm.expectCheatcodeRevert` and shouldn't expect revert here + ExpectedRevertKind::Cheatcode { pending_processing } => { + cheatcode_call && !pending_processing } - Ok((_, retdata)) => (InstructionResult::Return, remaining_gas, retdata), }; + + if needs_processing { + let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); + return match expect::handle_expect_revert( + false, + expected_revert.reason.as_deref(), + status, + retdata, + ) { + Err(error) => { + trace!(expected=?expected_revert, ?error, ?status, "Expected revert mismatch"); + (InstructionResult::Revert, remaining_gas, error.abi_encode().into()) + } + Ok((_, retdata)) => (InstructionResult::Return, remaining_gas, retdata), + }; + } + + // Flip `pending_processing` flag for cheatcode revert expectations, marking that + // we've exited the `expectCheatcodeRevert` call scope + if let ExpectedRevertKind::Cheatcode { pending_processing } = + &mut self.expected_revert.as_mut().unwrap().kind + { + if *pending_processing { + *pending_processing = false; + } + } } } + // Exit early for calls to cheatcodes as other logic is not relevant for cheatcode + // invocations + if cheatcode_call { + return (status, remaining_gas, retdata); + } + // If `startStateDiffRecording` has been called, update the `reverted` status of the // previous call depth's recorded accesses, if any if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { @@ -1290,7 +1311,9 @@ impl Inspector for Cheatcodes { // Handle expected reverts if let Some(expected_revert) = &self.expected_revert { - if data.journaled_state.depth() <= expected_revert.depth { + if data.journaled_state.depth() <= expected_revert.depth && + matches!(expected_revert.kind, ExpectedRevertKind::Default) + { let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); return match expect::handle_expect_revert( true, diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 0294b23b73d6a..740d4687e181f 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -69,7 +69,6 @@ impl Cheatcode for skipCall { // Skip should not work if called deeper than at test level. // Since we're not returning the magic skip bytes, this will cause a test failure. ensure!(ccx.data.journaled_state.depth() <= 1, "`skip` can only be used at test level"); - ccx.state.skip = true; Err(MAGIC_SKIP.into()) } else { Ok(Default::default()) diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 2904be99e09e8..002a23acd28e2 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -53,12 +53,27 @@ pub enum ExpectedCallType { Count, } -#[derive(Clone, Debug, Default)] +/// The type of expected revert. +#[derive(Clone, Debug)] +pub enum ExpectedRevertKind { + /// Expects revert from the next non-cheatcode call. + Default, + /// Expects revert from the next cheatcode call. + /// + /// The `pending_processing` flag is used to track whether we have exited + /// `expectCheatcodeRevert` context or not. + /// We have to track it to avoid expecting `expectCheatcodeRevert` call to revert itself. + Cheatcode { pending_processing: bool }, +} + +#[derive(Clone, Debug)] pub struct ExpectedRevert { /// The expected data returned by the revert, None being any pub reason: Option>, /// The depth at which the revert is expected pub depth: u64, + /// The type of expected revert. + pub kind: ExpectedRevertKind, } #[derive(Clone, Debug)] @@ -222,21 +237,41 @@ impl Cheatcode for expectEmit_3Call { impl Cheatcode for expectRevert_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_revert(ccx.state, None, ccx.data.journaled_state.depth()) + expect_revert(ccx.state, None, ccx.data.journaled_state.depth(), false) } } impl Cheatcode for expectRevert_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData.as_ref()), ccx.data.journaled_state.depth()) + expect_revert(ccx.state, Some(revertData.as_ref()), ccx.data.journaled_state.depth(), false) } } impl Cheatcode for expectRevert_2Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData), ccx.data.journaled_state.depth()) + expect_revert(ccx.state, Some(revertData), ccx.data.journaled_state.depth(), false) + } +} + +impl Cheatcode for _expectCheatcodeRevert_0Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + expect_revert(ccx.state, None, ccx.data.journaled_state.depth(), true) + } +} + +impl Cheatcode for _expectCheatcodeRevert_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData } = self; + expect_revert(ccx.state, Some(revertData.as_ref()), ccx.data.journaled_state.depth(), true) + } +} + +impl Cheatcode for _expectCheatcodeRevert_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData } = self; + expect_revert(ccx.state, Some(revertData), ccx.data.journaled_state.depth(), true) } } @@ -430,12 +465,25 @@ pub(crate) fn handle_expect_emit( } } -fn expect_revert(state: &mut Cheatcodes, reason: Option<&[u8]>, depth: u64) -> Result { +fn expect_revert( + state: &mut Cheatcodes, + reason: Option<&[u8]>, + depth: u64, + cheatcode: bool, +) -> Result { ensure!( state.expected_revert.is_none(), "you must call another function prior to expecting a second revert" ); - state.expected_revert = Some(ExpectedRevert { reason: reason.map(<[_]>::to_vec), depth }); + state.expected_revert = Some(ExpectedRevert { + reason: reason.map(<[_]>::to_vec), + depth, + kind: if cheatcode { + ExpectedRevertKind::Cheatcode { pending_processing: true } + } else { + ExpectedRevertKind::Default + }, + }); Ok(Default::default()) } diff --git a/testdata/cheats/Etch.t.sol b/testdata/cheats/Etch.t.sol index 81e70d37de4ad..f93a002b29634 100644 --- a/testdata/cheats/Etch.t.sol +++ b/testdata/cheats/Etch.t.sol @@ -17,7 +17,7 @@ contract EtchTest is DSTest { function testEtchNotAvailableOnPrecompiles() public { address target = address(1); bytes memory code = hex"1010"; - vm.expectRevert(bytes("cannot call `etch` on precompile 0x0000000000000000000000000000000000000001")); + vm._expectCheatcodeRevert(bytes("cannot call `etch` on precompile 0x0000000000000000000000000000000000000001")); vm.etch(target, code); } } diff --git a/testdata/cheats/ExpectRevert.t.sol b/testdata/cheats/ExpectRevert.t.sol index b2179a25db982..6006f45066a9f 100644 --- a/testdata/cheats/ExpectRevert.t.sol +++ b/testdata/cheats/ExpectRevert.t.sol @@ -186,4 +186,20 @@ contract ExpectRevertTest is DSTest { function testFailExpectRevertDangling() public { vm.expectRevert("dangling"); } + + function testexpectCheatcodeRevert() public { + vm._expectCheatcodeRevert("JSON value at \".a\" is not an object"); + vm.parseJsonKeys('{"a": "b"}', ".a"); + } + + function testFailexpectCheatcodeRevertForExtCall() public { + Reverter reverter = new Reverter(); + vm._expectCheatcodeRevert(); + reverter.revertWithMessage("revert"); + } + + function testFailexpectCheatcodeRevertForCreate() public { + vm._expectCheatcodeRevert(); + new ConstructorReverter("some message"); + } } diff --git a/testdata/cheats/Fs.t.sol b/testdata/cheats/Fs.t.sol index c1f79c15a621d..13093ede6eff3 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/cheats/Fs.t.sol @@ -23,10 +23,10 @@ contract FsTest is DSTest { assertEq(vm.readFile(path), "hello readable world\nthis is the second line!"); - vm.expectRevert(FOUNDRY_READ_ERR); + vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); vm.readFile("/etc/hosts"); - vm.expectRevert(FOUNDRY_READ_ERR); + vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); vm.readFileBinary("/etc/hosts"); } @@ -37,7 +37,7 @@ contract FsTest is DSTest { assertEq(vm.readLine(path), "this is the second line!"); assertEq(vm.readLine(path), ""); - vm.expectRevert(FOUNDRY_READ_ERR); + vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); vm.readLine("/etc/hosts"); } @@ -50,9 +50,9 @@ contract FsTest is DSTest { vm.removeFile(path); - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); vm.writeFile("/etc/hosts", "malicious stuff"); - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); vm.writeFileBinary("/etc/hosts", "malicious stuff"); } @@ -78,7 +78,7 @@ contract FsTest is DSTest { vm.removeFile(path); - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); vm.writeLine("/etc/hosts", "malicious stuff"); } @@ -103,7 +103,7 @@ contract FsTest is DSTest { vm.removeFile(path); - vm.expectRevert(FOUNDRY_WRITE_ERR); + vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); vm.removeFile("/etc/hosts"); } @@ -111,16 +111,16 @@ contract FsTest is DSTest { string memory root = vm.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeLine(foundryToml, "\nffi = true\n"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeLine("foundry.toml", "\nffi = true\n"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeLine("./foundry.toml", "\nffi = true\n"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeLine("./Foundry.toml", "\nffi = true\n"); } @@ -128,16 +128,16 @@ contract FsTest is DSTest { string memory root = vm.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeFile(foundryToml, "\nffi = true\n"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeFile("foundry.toml", "\nffi = true\n"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeFile("./foundry.toml", "\nffi = true\n"); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeFile("./Foundry.toml", "\nffi = true\n"); } @@ -156,7 +156,7 @@ contract FsTest is DSTest { assertEq(entries[1].path, entries2[1].path); string memory contents = vm.readFile(entries[0].path); - assertEq(contents, unicode"Wow! 😀\n"); + assertEq(contents, unicode"Wow! 😀"); } { @@ -172,7 +172,7 @@ contract FsTest is DSTest { assertEntry(entries[4], 3, false); } - vm.expectRevert(FOUNDRY_READ_DIR_ERR); + vm._expectCheatcodeRevert(FOUNDRY_READ_DIR_ERR); vm.readDir("/etc"); } @@ -184,11 +184,11 @@ contract FsTest is DSTest { assertEq(vm.fsMetadata(path).isDir, true); vm.removeDir(path, false); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.fsMetadata(path); // reverts because not recursive - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.createDir(child, false); vm.createDir(child, true); @@ -196,9 +196,9 @@ contract FsTest is DSTest { // deleted both, recursively vm.removeDir(path, true); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.fsMetadata(path); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.fsMetadata(child); } @@ -226,10 +226,10 @@ contract FsTest is DSTest { // TODO: symlinks are canonicalized away in `ensure_path_allowed` // assertEq(metadata.isSymlink, true); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.fsMetadata("../not-found"); - vm.expectRevert(FOUNDRY_READ_ERR); + vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); vm.fsMetadata("/etc/hosts"); } diff --git a/testdata/cheats/Json.t.sol b/testdata/cheats/Json.t.sol index b4b7059979307..a43a7be5a6b90 100644 --- a/testdata/cheats/Json.t.sol +++ b/testdata/cheats/Json.t.sol @@ -98,12 +98,8 @@ contract ParseJsonTest is DSTest { } function test_coercionRevert() public { - vm.expectRevert("values at \".nestedObject\" must not be JSON objects"); - uint256 number = this.parseJsonUint(json, ".nestedObject"); - } - - function parseJsonUint(string memory json, string memory path) public returns (uint256) { - uint256 data = vm.parseJsonUint(json, path); + vm._expectCheatcodeRevert("values at \".nestedObject\" must not be JSON objects"); + uint256 number = vm.parseJsonUint(json, ".nestedObject"); } function test_coercionUint() public { @@ -155,19 +151,27 @@ contract ParseJsonTest is DSTest { function test_parseJsonKeys() public { string memory jsonString = '{"some_key_to_value": "some_value", "some_key_to_array": [1, 2, 3], "some_key_to_object": {"key1": "value1", "key2": 2}}'; + string[] memory keys = vm.parseJsonKeys(jsonString, "$"); - assertEq(abi.encode(keys), abi.encode(["some_key_to_value", "some_key_to_array", "some_key_to_object"])); + string[] memory expected = new string[](3); + expected[0] = "some_key_to_value"; + expected[1] = "some_key_to_array"; + expected[2] = "some_key_to_object"; + assertEq(abi.encode(keys), abi.encode(expected)); keys = vm.parseJsonKeys(jsonString, ".some_key_to_object"); - assertEq(abi.encode(keys), abi.encode(["key1", "key2"])); + expected = new string[](2); + expected[0] = "key1"; + expected[1] = "key2"; + assertEq(abi.encode(keys), abi.encode(expected)); - vm.expectRevert("JSON value at \".some_key_to_array\" is not an object"); + vm._expectCheatcodeRevert("JSON value at \".some_key_to_array\" is not an object"); vm.parseJsonKeys(jsonString, ".some_key_to_array"); - vm.expectRevert("JSON value at \".some_key_to_value\" is not an object"); + vm._expectCheatcodeRevert("JSON value at \".some_key_to_value\" is not an object"); vm.parseJsonKeys(jsonString, ".some_key_to_value"); - vm.expectRevert("JSON value at \".*\" is not an object"); + vm._expectCheatcodeRevert("key \".*\" must return exactly one JSON object"); vm.parseJsonKeys(jsonString, ".*"); } } diff --git a/testdata/cheats/RpcUrls.t.sol b/testdata/cheats/RpcUrls.t.sol index c974bf1475369..282c2adddad34 100644 --- a/testdata/cheats/RpcUrls.t.sol +++ b/testdata/cheats/RpcUrls.t.sol @@ -15,17 +15,17 @@ contract RpcUrlTest is DSTest { // returns an error if env alias does not exist function testRevertsOnMissingEnv() public { - vm.expectRevert("invalid rpc url: rpcUrlEnv"); - string memory url = this.rpcUrl("rpcUrlEnv"); + vm._expectCheatcodeRevert("invalid rpc url: rpcUrlEnv"); + string memory url = vm.rpcUrl("rpcUrlEnv"); } // can set env and return correct url function testCanSetAndGetURLAndAllUrls() public { // this will fail because alias is not set - vm.expectRevert( + vm._expectCheatcodeRevert( "Failed to resolve env var `RPC_ENV_ALIAS` in `${RPC_ENV_ALIAS}`: environment variable not found" ); - string[2][] memory _urls = this.rpcUrls(); + string[2][] memory _urls = vm.rpcUrls(); string memory url = vm.rpcUrl("rpcAlias"); vm.setEnv("RPC_ENV_ALIAS", url); @@ -41,12 +41,4 @@ contract RpcUrlTest is DSTest { string[2] memory env = allUrls[1]; assertEq(env[0], "rpcEnvAlias"); } - - function rpcUrl(string memory _alias) public returns (string memory) { - return vm.rpcUrl(_alias); - } - - function rpcUrls() public returns (string[2][] memory) { - return vm.rpcUrls(); - } } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 7a1be2721b9a1..08c8f570bd3eb 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -18,6 +18,9 @@ interface Vm { 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; } struct StorageAccess { address account; bytes32 slot; bool isWrite; bytes32 previousValue; bytes32 newValue; bool reverted; } + function _expectCheatcodeRevert() external; + function _expectCheatcodeRevert(bytes4 revertData) external; + function _expectCheatcodeRevert(bytes calldata revertData) external; function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots); function activeFork() external view returns (uint256 forkId); function addr(uint256 privateKey) external pure returns (address keyAddr); diff --git a/testdata/fixtures/Dir/depth1 b/testdata/fixtures/Dir/depth1 index febdc5997fa40..17c01c6ebd131 100644 --- a/testdata/fixtures/Dir/depth1 +++ b/testdata/fixtures/Dir/depth1 @@ -1 +1 @@ -Wow! 😀 +Wow! 😀 \ No newline at end of file diff --git a/testdata/fs/Default.t.sol b/testdata/fs/Default.t.sol index 379de1ea66b6d..7ef8c5bd2ff01 100644 --- a/testdata/fs/Default.t.sol +++ b/testdata/fs/Default.t.sol @@ -23,10 +23,10 @@ contract DefaultAccessTest is DSTest { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeFile(path, data); - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeFileBinary(path, bytes(data)); } @@ -34,14 +34,14 @@ contract DefaultAccessTest is DSTest { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeLine(path, data); } function testRemoveFile() public { string memory path = "fixtures/File/write_file.txt"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.removeFile(path); } } diff --git a/testdata/fs/Disabled.t.sol b/testdata/fs/Disabled.t.sol index 40741644ecc8d..4c818d91400d4 100644 --- a/testdata/fs/Disabled.t.sol +++ b/testdata/fs/Disabled.t.sol @@ -9,33 +9,33 @@ contract DisabledTest is DSTest { function testReadFile() public { string memory path = "fixtures/File/read.txt"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.readFile(path); } function testReadLine() public { string memory path = "fixtures/File/read.txt"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.readLine(path); } function testWriteFile() public { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeFile(path, data); } function testWriteLine() public { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.writeLine(path, data); } function testRemoveFile() public { string memory path = "fixtures/File/write_file.txt"; - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.removeFile(path); } } diff --git a/testdata/repros/Issue4630.t.sol b/testdata/repros/Issue4630.t.sol index a9334dc8e3850..3979d5072e595 100644 --- a/testdata/repros/Issue4630.t.sol +++ b/testdata/repros/Issue4630.t.sol @@ -18,11 +18,7 @@ contract Issue4630Test is DSTest { function testMissingValue() public { string memory path = "fixtures/Json/Issue4630.json"; string memory json = vm.readFile(path); - vm.expectRevert(); - uint256 val = this.parseJsonUint(json, ".localempty.prop1"); - } - - function parseJsonUint(string memory json, string memory path) public returns (uint256) { - return vm.parseJsonUint(json, path); + vm._expectCheatcodeRevert(); + vm.parseJsonUint(json, ".localempty.prop1"); } } diff --git a/testdata/repros/Issue5808.t.sol b/testdata/repros/Issue5808.t.sol index e2a6a20888307..1914264bfe90c 100644 --- a/testdata/repros/Issue5808.t.sol +++ b/testdata/repros/Issue5808.t.sol @@ -10,7 +10,7 @@ contract Issue5808Test is DSTest { function testReadInt() public { string memory str1 = '["ffffffff","00000010"]'; - vm.expectRevert(); + vm._expectCheatcodeRevert(); int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); string memory str2 = '["0xffffffff","0x00000010"]'; diff --git a/testdata/repros/Issue6070.t.sol b/testdata/repros/Issue6070.t.sol index dc068f22cf406..db330f4b103b1 100644 --- a/testdata/repros/Issue6070.t.sol +++ b/testdata/repros/Issue6070.t.sol @@ -10,7 +10,7 @@ contract Issue6066Test is DSTest { function testNonPrefixed() public { vm.setEnv("__FOUNDRY_ISSUE_6066", "abcd"); - vm.expectRevert( + vm._expectCheatcodeRevert( "failed parsing $__FOUNDRY_ISSUE_6066 as type `uint256`: missing hex prefix (\"0x\") for hex string" ); uint256 x = vm.envUint("__FOUNDRY_ISSUE_6066"); From 1befba2490e1bfbb22a02315c74a216cf84ebdb1 Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 22 Jan 2024 14:09:50 -0400 Subject: [PATCH 0519/1963] chore(deny): ignore shlex (#6877) --- deny.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deny.toml b/deny.toml index 4b394a5255e3a..816574f430e92 100644 --- a/deny.toml +++ b/deny.toml @@ -1,6 +1,6 @@ # Temporarily exclude rusoto and ethers-providers from bans since we've yet to transition to the # Rust AWS SDK. -exclude = ["rusoto_core", "rusoto_kms", "rusoto_credential", "ethers-providers", "tungstenite"] +exclude = ["rusoto_core", "rusoto_kms", "rusoto_credential", "ethers-providers", "tungstenite", "shlex"] # This section is considered when running `cargo deny check advisories` # More documentation for the advisories section can be found here: From c6790a02bb80b163469e2e3bb0b16ae95ad7334f Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 22 Jan 2024 15:09:43 -0400 Subject: [PATCH 0520/1963] feat(`evm`, `forge`): use alloy `TransactionRequest` for saving `BroadcastableTransactions` (#6876) * feat(evm, forge): use alloy TransactionRequest instead of ethers for broadcastable txs * chore: review * chore: bump h2 * clippy --- Cargo.lock | 115 ++++++++++----------- crates/cheatcodes/src/inspector.rs | 42 ++++---- crates/forge/bin/cmd/script/broadcast.rs | 3 +- crates/forge/bin/cmd/script/cmd.rs | 6 +- crates/forge/bin/cmd/script/executor.rs | 24 ++--- crates/forge/bin/cmd/script/mod.rs | 50 ++++----- crates/forge/bin/cmd/script/runner.rs | 13 +-- crates/forge/bin/cmd/script/transaction.rs | 27 ++++- 8 files changed, 136 insertions(+), 144 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db3c1f8aa359d..81488f848be6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,9 +431,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", @@ -986,7 +986,7 @@ version = "0.66.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "cexpr", "clang-sys", "lazy_static", @@ -1026,9 +1026,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" dependencies = [ "arbitrary", "serde", @@ -1419,9 +1419,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" dependencies = [ "clap_builder", "clap_derive", @@ -1429,9 +1429,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" dependencies = [ "anstream", "anstyle", @@ -1444,9 +1444,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.8" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf7dcb7c21d8ca1a2482ee0f1d341f437c9a7af6ca6da359dc5e1b164e98215" +checksum = "dfb0d4825b75ff281318c393e8e1b80c4da9fb75a6b1d98547d389d6fe1f48d2" dependencies = [ "clap", ] @@ -1824,7 +1824,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "crossterm_winapi", "libc", "mio", @@ -2205,9 +2205,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.2" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -2629,9 +2629,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef57dfcf13fc3486c3a760427d88ab0d97cb911f7104fe5a132f2b934d0fe29" +checksum = "f492d1949e58ef83a1bf8e23fbd042af12b03e7642d50dbb4cfb48112de5e01f" dependencies = [ "ruint", ] @@ -2720,9 +2720,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.14" +version = "0.10.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6e5bc7bd59d60d0d45a6ccab6cf0f4ce28698fb4e81e750ddf229c9b824026" +checksum = "7629b8c7bcd214a072c2c88b263b5bb3ceb54c34365d8c41c1665461aeae0993" dependencies = [ "atomic", "parking_lot", @@ -3538,7 +3538,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "libc", "libgit2-sys", "log", @@ -3587,7 +3587,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "bstr", "gix-path", "libc", @@ -3633,7 +3633,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "bstr", "gix-features", "gix-path", @@ -3718,7 +3718,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "gix-path", "libc", "windows", @@ -3745,12 +3745,11 @@ checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" [[package]] name = "gix-utils" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e839f3d0798b296411263da6bee780a176ef8008a5dfc31287f7eda9266ab8" +checksum = "de6225e2de30b6e9bca2d9f1cc4731640fcef0fb3cabddceee366e7e85d3e94f" dependencies = [ "fastrand", - "unicode-normalization", ] [[package]] @@ -3896,9 +3895,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -4532,7 +4531,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "libc", "redox_syscall", ] @@ -4563,9 +4562,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -4845,7 +4844,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "cfg-if", "libc", ] @@ -5005,7 +5004,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5091,11 +5090,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -5123,9 +5122,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" dependencies = [ "cc", "libc", @@ -5580,9 +5579,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" [[package]] name = "plotters" @@ -5700,9 +5699,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" dependencies = [ "toml_edit 0.21.0", ] @@ -5772,7 +5771,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.4.1", "lazy_static", "num-traits", "rand 0.8.5", @@ -5943,7 +5942,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "cassowary", "crossterm", "indoc", @@ -5957,9 +5956,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -5967,9 +5966,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -6118,7 +6117,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#5ee90076f88e64a059e4c0c268929cf9ec91ed6d" +source = "git+https://github.com/paradigmxyz/evm-inspectors#29bb854055855daf84c5aac796681e3aae208895" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6161,7 +6160,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "auto_impl", - "bitflags 2.4.2", + "bitflags 2.4.1", "bitvec", "c-kzg", "enumn", @@ -6427,7 +6426,7 @@ version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -6513,7 +6512,7 @@ version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "cfg-if", "clipboard-win", "fd-lock 3.0.13", @@ -7010,9 +7009,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "socket2" @@ -7641,7 +7640,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.4.1", "bytes", "futures-core", "futures-util", @@ -7879,9 +7878,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-bom" @@ -7981,9 +7980,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.3.1" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" +checksum = "ec0d895592fa7710eba03fe072e614e3dc6a61ab76ae7ae10d2eb4a7ed5b00ca" dependencies = [ "anyhow", "cfg-if", diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index ee2ed1586d0cf..3f856c5586c19 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -14,13 +14,11 @@ use crate::{ }, CheatsConfig, CheatsCtxt, Error, Result, Vm, }; -use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_primitives::{Address, Bytes, B256, U256, U64}; +use alloy_rpc_types::request::TransactionRequest; use alloy_sol_types::{SolInterface, SolValue}; -use ethers_core::types::{ - transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest, -}; use ethers_signers::LocalWallet; -use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, types::ToEthers}; +use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl}; use foundry_evm_core::{ backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS}, @@ -80,7 +78,7 @@ pub struct BroadcastableTransaction { /// The optional RPC URL. pub rpc: Option, /// The transaction to broadcast. - pub transaction: TypedTransaction, + pub transaction: TransactionRequest, } /// List of transactions that can be broadcasted. @@ -834,19 +832,19 @@ impl Inspector for Cheatcodes { self.broadcastable_transactions.push_back(BroadcastableTransaction { rpc: data.db.active_fork_url(), - transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(broadcast.new_origin.to_ethers()), - to: Some(NameOrAddress::Address(call.contract.to_ethers())), - value: Some(call.transfer.value.to_ethers()), - data: Some(call.input.clone().to_ethers()), - nonce: Some(account.info.nonce.into()), + transaction: TransactionRequest { + from: Some(broadcast.new_origin), + to: Some(call.contract), + value: Some(call.transfer.value), + data: Some(call.input.clone()), + nonce: Some(U64::from(account.info.nonce)), gas: if is_fixed_gas_limit { - Some(call.gas_limit.into()) + Some(U256::from(call.gas_limit)) } else { None }, ..Default::default() - }), + }, }); debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable call"); @@ -1220,19 +1218,19 @@ impl Inspector for Cheatcodes { self.broadcastable_transactions.push_back(BroadcastableTransaction { rpc: data.db.active_fork_url(), - transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(broadcast.new_origin.to_ethers()), - to: to.map(|a| NameOrAddress::Address(a.to_ethers())), - value: Some(call.value.to_ethers()), - data: Some(bytecode.to_ethers()), - nonce: Some(nonce.into()), + transaction: TransactionRequest { + from: Some(broadcast.new_origin), + to, + value: Some(call.value), + data: Some(bytecode), + nonce: Some(U64::from(nonce)), gas: if is_fixed_gas_limit { - Some(call.gas_limit.into()) + Some(U256::from(call.gas_limit)) } else { None }, ..Default::default() - }), + }, }); let kind = match call.scheme { CreateScheme::Create => "create", diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index b6a8456f5dd93..e32cd02e0c410 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -3,6 +3,7 @@ use super::{ sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, *, }; use alloy_primitives::{utils::format_units, TxHash}; +use ethers_core::types::transaction::eip2718::TypedTransaction; use ethers_providers::{JsonRpcClient, Middleware, Provider}; use ethers_signers::Signer; use eyre::{bail, ContextCompat, Result, WrapErr}; @@ -407,7 +408,7 @@ impl ScriptArgs { shell::println("\nSKIPPING ON CHAIN SIMULATION.")?; txs.into_iter() .map(|btx| { - let mut tx = TransactionWithMetadata::from_typed_transaction(btx.transaction); + let mut tx = TransactionWithMetadata::from_tx_request(btx.transaction); tx.rpc = btx.rpc; tx }) diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 0f9a16b5fb078..244615b994ca9 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -1,6 +1,6 @@ use super::{multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, *}; use alloy_primitives::Bytes; -use ethers_core::types::transaction::eip2718::TypedTransaction; + use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::Result; @@ -171,7 +171,7 @@ impl ScriptArgs { for tx in txs.iter() { lib_deploy.push_back(BroadcastableTransaction { rpc: tx.rpc.clone(), - transaction: TypedTransaction::Legacy(tx.transaction.clone().into()), + transaction: tx.transaction.clone(), }); } *txs = lib_deploy; @@ -336,7 +336,7 @@ impl ScriptArgs { for new_tx in new_txs.iter() { txs.push_back(BroadcastableTransaction { rpc: new_tx.rpc.clone(), - transaction: TypedTransaction::Legacy(new_tx.transaction.clone().into()), + transaction: new_tx.transaction.clone(), }); } } diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 6a5b792fe1969..bea7af8cb2c76 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -5,7 +5,6 @@ use super::{ *, }; use alloy_primitives::{Address, Bytes, U256}; -use ethers_core::types::transaction::eip2718::TypedTransaction; use eyre::Result; use forge::{ backend::Backend, @@ -14,11 +13,7 @@ use forge::{ traces::CallTraceDecoder, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; -use foundry_common::{ - provider::ethers::RpcUrl, - shell, - types::{ToAlloy, ToEthers}, -}; +use foundry_common::{provider::ethers::RpcUrl, shell}; use foundry_compilers::artifacts::CompactContractBytecode; use futures::future::join_all; use parking_lot::RwLock; @@ -142,17 +137,14 @@ impl ScriptArgs { let rpc = transaction.rpc.as_ref().expect("missing broadcastable tx rpc url"); let mut runner = runners.get(rpc).expect("invalid rpc url").write(); - let TypedTransaction::Legacy(mut tx) = transaction.transaction else { - unreachable!() - }; + let mut tx = transaction.transaction; let result = runner .simulate( tx.from - .expect("transaction doesn't have a `from` address at execution time") - .to_alloy(), - tx.to.clone(), - tx.data.clone().map(|b| b.to_alloy()), - tx.value.map(|v| v.to_alloy()), + .expect("transaction doesn't have a `from` address at execution time"), + tx.to, + tx.data.clone(), + tx.value, ) .wrap_err("Internal EVM error during simulation")?; @@ -191,12 +183,12 @@ impl ScriptArgs { // We inflate the gas used by the user specified percentage None => { let gas = U256::from(result.gas_used * self.gas_estimate_multiplier / 100); - tx.gas = Some(gas.to_ethers()); + tx.gas = Some(gas); } } let tx = TransactionWithMetadata::new( - tx.into(), + tx, transaction.rpc, &result, &address_to_abi, diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 9dae655b5a71f..245c59ad63ace 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -2,12 +2,10 @@ use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{Address, Bytes, Log, U256, U64}; +use alloy_rpc_types::request::TransactionRequest; use clap::{Parser, ValueHint}; use dialoguer::Confirm; -use ethers_core::types::{ - transaction::eip2718::TypedTransaction, NameOrAddress, TransactionRequest, -}; use ethers_providers::{Http, Middleware}; use ethers_signers::LocalWallet; use eyre::{ContextCompat, Result, WrapErr}; @@ -29,9 +27,7 @@ use foundry_common::{ evm::{Breakpoints, EvmArgs}, fmt::{format_token, format_token_raw}, provider::ethers::RpcUrl, - shell, - types::{ToAlloy, ToEthers}, - ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, + shell, ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::{ artifacts::{ContractBytecodeSome, Libraries}, @@ -387,21 +383,16 @@ impl ScriptArgs { // If the user passed a `--sender` don't check anything. if !predeploy_libraries.is_empty() && self.evm_opts.sender.is_none() { for tx in txs.iter() { - match &tx.transaction { - TypedTransaction::Legacy(tx) => { - if tx.to.is_none() { - let sender = tx.from.expect("no sender").to_alloy(); - if let Some(ns) = new_sender { - if sender != ns { - shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; - return Ok(None); - } - } else if sender != evm_opts.sender { - new_sender = Some(sender); - } + if tx.transaction.to.is_none() { + let sender = tx.transaction.from.expect("no sender"); + if let Some(ns) = new_sender { + if sender != ns { + shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; + return Ok(None); } + } else if sender != evm_opts.sender { + new_sender = Some(sender); } - _ => unreachable!(), } } } @@ -422,12 +413,12 @@ impl ScriptArgs { .enumerate() .map(|(i, bytes)| BroadcastableTransaction { rpc: fork_url.clone(), - transaction: TypedTransaction::Legacy(TransactionRequest { - from: Some(from.to_ethers()), - data: Some(bytes.clone().to_ethers()), - nonce: Some((nonce + i as u64).into()), + transaction: TransactionRequest { + from: Some(from), + data: Some(bytes.clone()), + nonce: Some(U64::from(nonce + i as u64)), ..Default::default() - }), + }, }) .collect() } @@ -519,16 +510,17 @@ impl ScriptArgs { for (data, to) in result.transactions.iter().flat_map(|txes| { txes.iter().filter_map(|tx| { tx.transaction - .data() + .data + .clone() .filter(|data| data.len() > max_size) - .map(|data| (data, tx.transaction.to())) + .map(|data| (data, tx.transaction.to)) }) }) { let mut offset = 0; // Find if it's a CREATE or CREATE2. Otherwise, skip transaction. - if let Some(NameOrAddress::Address(to)) = to { - if to.to_alloy() == DEFAULT_CREATE2_DEPLOYER { + if let Some(to) = to { + if to == DEFAULT_CREATE2_DEPLOYER { // Size of the salt prefix. offset = 32; } diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 1dc91041cf33a..4893c21fa9ea9 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -1,6 +1,5 @@ use super::*; use alloy_primitives::{Address, Bytes, U256}; -use ethers_core::types::NameOrAddress; use eyre::Result; use forge::{ constants::CALLER, @@ -204,18 +203,12 @@ impl ScriptRunner { pub fn simulate( &mut self, from: Address, - to: Option, + to: Option
, calldata: Option, value: Option, ) -> Result { - if let Some(NameOrAddress::Address(to)) = to { - self.call( - from, - to.to_alloy(), - calldata.unwrap_or_default(), - value.unwrap_or(U256::ZERO), - true, - ) + if let Some(to) = to { + self.call(from, to, calldata.unwrap_or_default(), value.unwrap_or(U256::ZERO), true) } else if to.is_none() { let (address, gas_used, logs, traces, debug) = match self.executor.deploy( from, diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 26446bd45e840..5a446648c1acf 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -2,7 +2,11 @@ use super::{artifacts::ArtifactInfo, ScriptResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, B256}; -use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress}; +use alloy_rpc_types::request::TransactionRequest; +use ethers_core::types::{ + transaction::eip2718::TypedTransaction, NameOrAddress, + TransactionRequest as EthersTransactionRequest, +}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{ fmt::format_token_raw, @@ -59,12 +63,23 @@ fn default_vec_of_strings() -> Option> { } impl TransactionWithMetadata { - pub fn from_typed_transaction(transaction: TypedTransaction) -> Self { - Self { transaction, ..Default::default() } + pub fn from_tx_request(transaction: TransactionRequest) -> Self { + Self { + transaction: TypedTransaction::Legacy(EthersTransactionRequest { + from: transaction.from.map(ToEthers::to_ethers), + to: transaction.to.map(ToEthers::to_ethers).map(Into::into), + value: transaction.value.map(ToEthers::to_ethers), + data: transaction.data.map(ToEthers::to_ethers), + nonce: transaction.nonce.map(|n| n.to::().into()), + gas: transaction.gas.map(ToEthers::to_ethers), + ..Default::default() + }), + ..Default::default() + } } pub fn new( - transaction: TypedTransaction, + transaction: TransactionRequest, rpc: Option, result: &ScriptResult, local_contracts: &BTreeMap, @@ -72,7 +87,9 @@ impl TransactionWithMetadata { additional_contracts: Vec, is_fixed_gas_limit: bool, ) -> Result { - let mut metadata = Self { transaction, rpc, is_fixed_gas_limit, ..Default::default() }; + let mut metadata = Self::from_tx_request(transaction); + metadata.rpc = rpc; + metadata.is_fixed_gas_limit = is_fixed_gas_limit; // Specify if any contract was directly created with this transaction if let Some(NameOrAddress::Address(to)) = metadata.transaction.to().cloned() { From f0199f022c2daa2a7aa7d627b60b25ab28b63286 Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 22 Jan 2024 17:39:07 -0400 Subject: [PATCH 0521/1963] feat: use alloy provider to fetch chain id, remove ethers-providers (#6881) --- Cargo.lock | 1 - crates/evm/core/Cargo.toml | 1 - crates/evm/core/src/opts.rs | 15 +++++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81488f848be6c..c0e125eb8a5ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3201,7 +3201,6 @@ dependencies = [ "const-hex", "derive_more", "ethers-core", - "ethers-providers", "eyre", "foundry-cheatcodes-spec", "foundry-common", diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 97b9f77a40f2a..69770d00a5767 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -38,7 +38,6 @@ revm = { workspace = true, default-features = false, features = [ revm-inspectors.workspace = true ethers-core.workspace = true -ethers-providers.workspace = true derive_more.workspace = true eyre = "0.6" diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 7eceb7c5afa21..1e52f484bde3e 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,8 +1,8 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; +use alloy_providers::provider::TempProvider; use alloy_rpc_types::Block; -use ethers_providers::{Middleware, Provider}; use eyre::WrapErr; use foundry_common::{ self, @@ -189,11 +189,14 @@ impl EvmOpts { return Some(Chain::mainnet()); } trace!(?url, "retrieving chain via eth_chainId"); - let provider = Provider::try_from(url.as_str()) - .unwrap_or_else(|_| panic!("Failed to establish provider to {url}")); - - if let Ok(id) = RuntimeOrHandle::new().block_on(provider.get_chainid()) { - return Some(Chain::from(id.as_u64())); + let provider = ProviderBuilder::new(url.as_str()) + .compute_units_per_second(self.get_compute_units_per_second()) + .build() + .ok() + .unwrap_or_else(|| panic!("Failed to establish provider to {url}")); + + if let Ok(id) = RuntimeOrHandle::new().block_on(provider.get_chain_id()) { + return Some(Chain::from(id.to::())); } } From 3344e2ceeb68fd77d6be001ce7990742debc2e9a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 23 Jan 2024 14:18:13 +0100 Subject: [PATCH 0522/1963] fix: fix off by one debugger draw (#6886) --- crates/debugger/src/tui/draw.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index dd313750259b7..8394d3a2e4b64 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -237,8 +237,9 @@ impl DebuggerContext<'_> { // adjust what text we show of the source code let (start_line, end_line) = if needed_highlight > height { - // highlighted section is more lines than we have avail - (before.len(), before.len() + needed_highlight) + // highlighted section is more lines than we have available + let start_line = before.len().saturating_sub(1); + (start_line, before.len() + needed_highlight) } else if height > num_lines { // we can fit entire source (0, num_lines) From 070297f52a8f807a1b0ad645a969255b441eff7b Mon Sep 17 00:00:00 2001 From: Enrique Date: Wed, 24 Jan 2024 15:19:40 -0400 Subject: [PATCH 0523/1963] feat(`evm`): migrate to `alloy-genesis`, rm `ethers-core` (#6880) * feat: migrate to alloy-genesis, drop ethers-core from evm * fixes * clippy * chore: correct loadAllocs cheatcode * address comment * danis suggestion * clippy + fmt --- Cargo.lock | 212 +++++++++++++++------------- Cargo.toml | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/src/evm.rs | 34 ++--- crates/evm/core/Cargo.toml | 3 +- crates/evm/core/src/backend/fuzz.rs | 2 +- crates/evm/core/src/backend/mod.rs | 6 +- 7 files changed, 135 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0e125eb8a5ec..f22b8beaff3f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -130,6 +130,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-genesis" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types", + "serde", +] + [[package]] name = "alloy-json-abi" version = "0.6.0" @@ -145,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-primitives", "serde", @@ -156,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -195,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -252,7 +262,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -269,7 +279,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -280,7 +290,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -335,7 +345,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -351,7 +361,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -364,7 +374,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -382,7 +392,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#42778ba44fbf9fdcfd44de81436f65d73e70ede2" +source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -431,9 +441,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.7" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", @@ -986,7 +996,7 @@ version = "0.66.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cexpr", "clang-sys", "lazy_static", @@ -1026,9 +1036,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" dependencies = [ "arbitrary", "serde", @@ -1110,7 +1120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" dependencies = [ "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.4", "serde", ] @@ -1358,22 +1368,22 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] name = "ciborium" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", @@ -1382,15 +1392,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", "half", @@ -1419,9 +1429,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.17" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", "clap_derive", @@ -1429,9 +1439,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.17" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstream", "anstyle", @@ -1444,9 +1454,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.7" +version = "4.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb0d4825b75ff281318c393e8e1b80c4da9fb75a6b1d98547d389d6fe1f48d2" +checksum = "df631ae429f6613fcd3a7c1adbdb65f637271e561b03680adaa6573015dfb106" dependencies = [ "clap", ] @@ -1824,7 +1834,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "crossterm_winapi", "libc", "mio", @@ -2205,9 +2215,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -2629,9 +2639,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f492d1949e58ef83a1bf8e23fbd042af12b03e7642d50dbb4cfb48112de5e01f" +checksum = "8ef57dfcf13fc3486c3a760427d88ab0d97cb911f7104fe5a132f2b934d0fe29" dependencies = [ "ruint", ] @@ -2720,9 +2730,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.13" +version = "0.10.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7629b8c7bcd214a072c2c88b263b5bb3ceb54c34365d8c41c1665461aeae0993" +checksum = "2b6e5bc7bd59d60d0d45a6ccab6cf0f4ce28698fb4e81e750ddf229c9b824026" dependencies = [ "atomic", "parking_lot", @@ -2940,6 +2950,7 @@ name = "foundry-cheatcodes" version = "0.2.0" dependencies = [ "alloy-dyn-abi", + "alloy-genesis", "alloy-json-abi", "alloy-primitives", "alloy-providers", @@ -3192,6 +3203,7 @@ name = "foundry-evm-core" version = "0.2.0" dependencies = [ "alloy-dyn-abi", + "alloy-genesis", "alloy-json-abi", "alloy-primitives", "alloy-providers", @@ -3200,7 +3212,6 @@ dependencies = [ "alloy-transport", "const-hex", "derive_more", - "ethers-core", "eyre", "foundry-cheatcodes-spec", "foundry-common", @@ -3537,7 +3548,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "libgit2-sys", "log", @@ -3586,7 +3597,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bstr", "gix-path", "libc", @@ -3632,7 +3643,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bstr", "gix-features", "gix-path", @@ -3717,7 +3728,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "gix-path", "libc", "windows", @@ -3744,11 +3755,12 @@ checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" [[package]] name = "gix-utils" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de6225e2de30b6e9bca2d9f1cc4731640fcef0fb3cabddceee366e7e85d3e94f" +checksum = "56e839f3d0798b296411263da6bee780a176ef8008a5dfc31287f7eda9266ab8" dependencies = [ "fastrand", + "unicode-normalization", ] [[package]] @@ -3776,7 +3788,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.3", + "regex-automata 0.4.4", "regex-syntax 0.8.2", ] @@ -3824,9 +3836,13 @@ dependencies = [ [[package]] name = "half" -version = "1.8.2" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" +dependencies = [ + "cfg-if", + "crunchy", +] [[package]] name = "handlebars" @@ -3894,9 +3910,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -4122,7 +4138,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.4", "same-file", "walkdir", "winapi-util", @@ -4530,7 +4546,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall", ] @@ -4561,9 +4577,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -4843,7 +4859,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "libc", ] @@ -5003,7 +5019,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5089,11 +5105,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.62" +version = "0.10.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" +checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "foreign-types", "libc", @@ -5121,9 +5137,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.98" +version = "0.9.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" dependencies = [ "cc", "libc", @@ -5578,9 +5594,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "plotters" @@ -5698,9 +5714,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ "toml_edit 0.21.0", ] @@ -5731,9 +5747,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -5770,7 +5786,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.1", + "bitflags 2.4.2", "lazy_static", "num-traits", "rand 0.8.5", @@ -5941,7 +5957,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cassowary", "crossterm", "indoc", @@ -5955,9 +5971,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" dependencies = [ "either", "rayon-core", @@ -5965,9 +5981,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -6009,13 +6025,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.4", "regex-syntax 0.8.2", ] @@ -6030,9 +6046,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" dependencies = [ "aho-corasick", "memchr", @@ -6116,7 +6132,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#29bb854055855daf84c5aac796681e3aae208895" +source = "git+https://github.com/paradigmxyz/evm-inspectors#5ee90076f88e64a059e4c0c268929cf9ec91ed6d" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6159,7 +6175,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "auto_impl", - "bitflags 2.4.1", + "bitflags 2.4.2", "bitvec", "c-kzg", "enumn", @@ -6425,7 +6441,7 @@ version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -6511,7 +6527,7 @@ version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "clipboard-win", "fd-lock 3.0.13", @@ -6929,9 +6945,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shlex" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook" @@ -7008,9 +7024,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -7154,9 +7170,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "svm-rs" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20689c7d03b6461b502d0b95d6c24874c7d24dea2688af80486a130a06af3b07" +checksum = "7ce290b5536ab2a42a61c9c6f22d6bfa8f26339c602aa62db4c978c95d1afc47" dependencies = [ "dirs 5.0.1", "fs2", @@ -7639,7 +7655,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "futures-core", "futures-util", @@ -7859,9 +7875,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "uncased" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" dependencies = [ "version_check", ] @@ -7877,9 +7893,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-bom" @@ -7979,9 +7995,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.3.0" +version = "8.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0d895592fa7710eba03fe072e614e3dc6a61ab76ae7ae10d2eb4a7ed5b00ca" +checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" dependencies = [ "anyhow", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index de2fdf63dbfb9..1db94b79705b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -146,6 +146,7 @@ ethers-solc = { version = "2.0", default-features = false } ## alloy alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } alloy-eips = { git = "https://github.com/alloy-rs/alloy" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy" } alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" } alloy-network = { git = "https://github.com/alloy-rs/alloy" } alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy" } diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 7c3d2db0a4ccb..8d05a8a8ad2ba 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -21,6 +21,7 @@ foundry-evm-core.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true +alloy-genesis.workspace = true alloy-sol-types.workspace = true alloy-providers.workspace = true alloy-rpc-types.workspace = true diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 94a15e6cbb9d9..f2e5b2026b0dc 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1,16 +1,13 @@ //! Implementations of [`Evm`](crate::Group::Evm) cheatcodes. use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_genesis::{Genesis, GenesisAccount}; +use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_sol_types::SolValue; -use ethers_core::{ - types::H256, - utils::{Genesis, GenesisAccount}, -}; use ethers_signers::Signer; use foundry_common::{ fs::{read_json_file, write_json_file}, - types::{ToAlloy, ToEthers}, + types::ToAlloy, }; use foundry_evm_core::{ backend::{DatabaseExt, RevertSnapshotAction}, @@ -79,11 +76,14 @@ impl Cheatcode for loadAllocsCall { let path = Path::new(pathToAllocsJson); ensure!(path.exists(), "allocs file does not exist: {pathToAllocsJson}"); - // Let's first assume we're reading a genesis.json file. - let allocs: HashMap = match read_json_file::(path) { - Ok(genesis) => genesis.alloc.into_iter().map(|(k, g)| (k.to_alloy(), g)).collect(), - // If that fails, let's try reading a file with just the genesis accounts. - Err(_) => read_json_file(path)?, + // Let's first assume we're reading a file with only the allocs. + let allocs: HashMap = match read_json_file(path) { + Ok(allocs) => allocs, + Err(_) => { + // Let's try and read from a genesis file, and extract allocs. + let genesis = read_json_file::(path)?; + genesis.alloc + } }; // Then, load the allocs into the database. @@ -121,18 +121,12 @@ impl Cheatcode for dumpStateCall { key, GenesisAccount { nonce: Some(val.info.nonce), - balance: val.info.balance.to_ethers(), - code: Some( - val.info.code.clone().unwrap_or_default().original_bytes().to_ethers(), - ), + balance: val.info.balance, + code: val.info.code.as_ref().map(|o| o.original_bytes()), storage: Some( val.storage .iter() - .map(|(k, v)| { - let key = k.to_be_bytes::<32>(); - let val = v.present_value().to_be_bytes::<32>(); - (H256::from_slice(&key), H256::from_slice(&val)) - }) + .map(|(k, v)| (B256::from(*k), B256::from(v.present_value()))) .collect(), ), }, diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 69770d00a5767..04403a9f8c5a5 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -20,6 +20,7 @@ foundry-macros.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-genesis.workspace = true alloy-providers.workspace = true alloy-rpc-types.workspace = true alloy-sol-types.workspace = true @@ -37,8 +38,6 @@ revm = { workspace = true, default-features = false, features = [ ] } revm-inspectors.workspace = true -ethers-core.workspace = true - derive_more.workspace = true eyre = "0.6" futures = "0.3" diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index b3cf5a959a4ae..5a7946d3c998f 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -7,8 +7,8 @@ use crate::{ }, fork::{CreateFork, ForkId}, }; +use alloy_genesis::GenesisAccount; use alloy_primitives::{Address, B256, U256}; -use ethers_core::utils::GenesisAccount; use revm::{ db::DatabaseRef, primitives::{AccountInfo, Bytecode, Env, ResultAndState}, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 72906407365bf..c45771894ddd3 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -6,10 +6,10 @@ use crate::{ snapshot::Snapshots, utils::configure_tx_env, }; +use alloy_genesis::GenesisAccount; use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; -use ethers_core::utils::GenesisAccount; -use foundry_common::{is_known_system_sender, types::ToAlloy, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use revm::{ db::{CacheDB, DatabaseRef}, inspectors::NoOpInspector, @@ -1354,7 +1354,7 @@ impl DatabaseExt for Backend { } // Set the account's nonce and balance. state_acc.info.nonce = acc.nonce.unwrap_or_default(); - state_acc.info.balance = acc.balance.to_alloy(); + state_acc.info.balance = acc.balance; // Touch the account to ensure the loaded information persists if called in `setUp`. journaled_state.touch(addr); From 8972a9fbe9a2d4bb45acd8162085561f4ee2559f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 24 Jan 2024 22:45:49 +0100 Subject: [PATCH 0524/1963] feat: keep debug symbols in release builds (#6894) --- Cargo.toml | 2 +- crates/cli/src/handler.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1db94b79705b6..40a424679f6d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,7 @@ incremental = false [profile.release] opt-level = 3 lto = "fat" -strip = true +strip = "debuginfo" panic = "abort" codegen-units = 1 diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index 61d3246f4738b..6666686c5555d 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -48,6 +48,11 @@ impl EyreHandler for Handler { /// /// Panics are always caught by the more debug-centric handler. pub fn install() { + // If the user has not explicitly overridden "RUST_BACKTRACE", then produce full backtraces. + if std::env::var_os("RUST_BACKTRACE").is_none() { + std::env::set_var("RUST_BACKTRACE", "full"); + } + let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok(); if debug_enabled { if let Err(e) = color_eyre::install() { From 4a643801d0b3855934cdec778e33e79c79971783 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 25 Jan 2024 01:30:35 +0200 Subject: [PATCH 0525/1963] feat(`forge`) Native assertion cheatcodes (#6803) * Add assertEq, assertNotEq, assertGt, assertGe, assertLt, assertLe cheatcodes * rustfmt * fix clippy warning * dedicated errors * fix clippy warning * assertFalse * assertEqAbs * Prettify format_for_arrays * (a, b) -> (left, right) * Refactor + decimals cheatcods * Some fixes * chore: remove allows * assertApproxEqRel cheatcodes * Remove unneccesary conversions * Fix formatting * Add tests * rustfmt * fix clippy warning * lowercase error messages --- Cargo.lock | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 2320 ++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 546 +++++ crates/cheatcodes/src/test.rs | 1 + crates/cheatcodes/src/test/assert.rs | 1182 +++++++++++ crates/evm/core/src/abi/console.rs | 4 +- crates/evm/core/src/abi/mod.rs | 2 +- testdata/cheats/Assert.t.sol | 823 ++++++++ testdata/cheats/Vm.sol | 116 ++ 10 files changed, 4993 insertions(+), 3 deletions(-) create mode 100644 crates/cheatcodes/src/test/assert.rs create mode 100644 testdata/cheats/Assert.t.sol diff --git a/Cargo.lock b/Cargo.lock index f22b8beaff3f6..f54e2b9cd3172 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2971,6 +2971,7 @@ dependencies = [ "p256", "revm", "serde_json", + "thiserror", "tracing", "walkdir", ] diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 8d05a8a8ad2ba..14cb26e289d22 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -39,3 +39,4 @@ base64.workspace = true tracing.workspace = true walkdir = "2" p256 = "0.13.2" +thiserror = "1" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 3225893d14c39..6ccbcd21f968c 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -553,6 +553,2326 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "assertApproxEqAbsDecimal_0", + "description": "Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.\nFormats values with decimals in failure message.", + "declaration": "function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbsDecimal(uint256,uint256,uint256,uint256)", + "selector": "0x045c55ce", + "selectorBytes": [ + 4, + 92, + 85, + 206 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqAbsDecimal_1", + "description": "Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbsDecimal(uint256,uint256,uint256,uint256,string)", + "selector": "0x60429eb2", + "selectorBytes": [ + 96, + 66, + 158, + 178 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqAbsDecimal_2", + "description": "Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.\nFormats values with decimals in failure message.", + "declaration": "function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbsDecimal(int256,int256,uint256,uint256)", + "selector": "0x3d5bc8bc", + "selectorBytes": [ + 61, + 91, + 200, + 188 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqAbsDecimal_3", + "description": "Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbsDecimal(int256,int256,uint256,uint256,string)", + "selector": "0x6a5066d4", + "selectorBytes": [ + 106, + 80, + 102, + 212 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqAbs_0", + "description": "Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.", + "declaration": "function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbs(uint256,uint256,uint256)", + "selector": "0x16d207c6", + "selectorBytes": [ + 22, + 210, + 7, + 198 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqAbs_1", + "description": "Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.\nIncludes error message into revert string on failure.", + "declaration": "function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbs(uint256,uint256,uint256,string)", + "selector": "0xf710b062", + "selectorBytes": [ + 247, + 16, + 176, + 98 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqAbs_2", + "description": "Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.", + "declaration": "function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbs(int256,int256,uint256)", + "selector": "0x240f839d", + "selectorBytes": [ + 36, + 15, + 131, + 157 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqAbs_3", + "description": "Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.\nIncludes error message into revert string on failure.", + "declaration": "function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqAbs(int256,int256,uint256,string)", + "selector": "0x8289e621", + "selectorBytes": [ + 130, + 137, + 230, + 33 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRelDecimal_0", + "description": "Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%\nFormats values with decimals in failure message.", + "declaration": "function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRelDecimal(uint256,uint256,uint256,uint256)", + "selector": "0x21ed2977", + "selectorBytes": [ + 33, + 237, + 41, + 119 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRelDecimal_1", + "description": "Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRelDecimal(uint256,uint256,uint256,uint256,string)", + "selector": "0x82d6c8fd", + "selectorBytes": [ + 130, + 214, + 200, + 253 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRelDecimal_2", + "description": "Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%\nFormats values with decimals in failure message.", + "declaration": "function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRelDecimal(int256,int256,uint256,uint256)", + "selector": "0xabbf21cc", + "selectorBytes": [ + 171, + 191, + 33, + 204 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRelDecimal_3", + "description": "Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRelDecimal(int256,int256,uint256,uint256,string)", + "selector": "0xfccc11c4", + "selectorBytes": [ + 252, + 204, + 17, + 196 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRel_0", + "description": "Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%", + "declaration": "function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRel(uint256,uint256,uint256)", + "selector": "0x8cf25ef4", + "selectorBytes": [ + 140, + 242, + 94, + 244 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRel_1", + "description": "Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%\nIncludes error message into revert string on failure.", + "declaration": "function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRel(uint256,uint256,uint256,string)", + "selector": "0x1ecb7d33", + "selectorBytes": [ + 30, + 203, + 125, + 51 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRel_2", + "description": "Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%", + "declaration": "function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRel(int256,int256,uint256)", + "selector": "0xfea2d14f", + "selectorBytes": [ + 254, + 162, + 209, + 79 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertApproxEqRel_3", + "description": "Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.\n`maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%\nIncludes error message into revert string on failure.", + "declaration": "function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertApproxEqRel(int256,int256,uint256,string)", + "selector": "0xef277d72", + "selectorBytes": [ + 239, + 39, + 125, + 114 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEqDecimal_0", + "description": "Asserts that two `uint256` values are equal, formatting them with decimals in failure message.", + "declaration": "function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEqDecimal(uint256,uint256,uint256)", + "selector": "0x27af7d9c", + "selectorBytes": [ + 39, + 175, + 125, + 156 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEqDecimal_1", + "description": "Asserts that two `uint256` values are equal, formatting them with decimals in failure message.\nIncludes error message into revert string on failure.", + "declaration": "function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEqDecimal(uint256,uint256,uint256,string)", + "selector": "0xd0cbbdef", + "selectorBytes": [ + 208, + 203, + 189, + 239 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEqDecimal_2", + "description": "Asserts that two `int256` values are equal, formatting them with decimals in failure message.", + "declaration": "function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEqDecimal(int256,int256,uint256)", + "selector": "0x48016c04", + "selectorBytes": [ + 72, + 1, + 108, + 4 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEqDecimal_3", + "description": "Asserts that two `int256` values are equal, formatting them with decimals in failure message.\nIncludes error message into revert string on failure.", + "declaration": "function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEqDecimal(int256,int256,uint256,string)", + "selector": "0x7e77b0c5", + "selectorBytes": [ + 126, + 119, + 176, + 197 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_0", + "description": "Asserts that two `bool` values are equal.", + "declaration": "function assertEq(bool left, bool right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bool,bool)", + "selector": "0xf7fe3477", + "selectorBytes": [ + 247, + 254, + 52, + 119 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_1", + "description": "Asserts that two `bool` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(bool left, bool right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bool,bool,string)", + "selector": "0x4db19e7e", + "selectorBytes": [ + 77, + 177, + 158, + 126 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_10", + "description": "Asserts that two `string` values are equal.", + "declaration": "function assertEq(string calldata left, string calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(string,string)", + "selector": "0xf320d963", + "selectorBytes": [ + 243, + 32, + 217, + 99 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_11", + "description": "Asserts that two `string` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(string calldata left, string calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(string,string,string)", + "selector": "0x36f656d8", + "selectorBytes": [ + 54, + 246, + 86, + 216 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_12", + "description": "Asserts that two `bytes` values are equal.", + "declaration": "function assertEq(bytes calldata left, bytes calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes,bytes)", + "selector": "0x97624631", + "selectorBytes": [ + 151, + 98, + 70, + 49 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_13", + "description": "Asserts that two `bytes` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes,bytes,string)", + "selector": "0xe24fed00", + "selectorBytes": [ + 226, + 79, + 237, + 0 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_14", + "description": "Asserts that two arrays of `bool` values are equal.", + "declaration": "function assertEq(bool[] calldata left, bool[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bool[],bool[])", + "selector": "0x707df785", + "selectorBytes": [ + 112, + 125, + 247, + 133 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_15", + "description": "Asserts that two arrays of `bool` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bool[],bool[],string)", + "selector": "0xe48a8f8d", + "selectorBytes": [ + 228, + 138, + 143, + 141 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_16", + "description": "Asserts that two arrays of `uint256 values are equal.", + "declaration": "function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(uint256[],uint256[])", + "selector": "0x975d5a12", + "selectorBytes": [ + 151, + 93, + 90, + 18 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_17", + "description": "Asserts that two arrays of `uint256` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(uint256[],uint256[],string)", + "selector": "0x5d18c73a", + "selectorBytes": [ + 93, + 24, + 199, + 58 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_18", + "description": "Asserts that two arrays of `int256` values are equal.", + "declaration": "function assertEq(int256[] calldata left, int256[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(int256[],int256[])", + "selector": "0x711043ac", + "selectorBytes": [ + 113, + 16, + 67, + 172 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_19", + "description": "Asserts that two arrays of `int256` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(int256[],int256[],string)", + "selector": "0x191f1b30", + "selectorBytes": [ + 25, + 31, + 27, + 48 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_2", + "description": "Asserts that two `uint256` values are equal.", + "declaration": "function assertEq(uint256 left, uint256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(uint256,uint256)", + "selector": "0x98296c54", + "selectorBytes": [ + 152, + 41, + 108, + 84 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_20", + "description": "Asserts that two arrays of `address` values are equal.", + "declaration": "function assertEq(address[] calldata left, address[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(address[],address[])", + "selector": "0x3868ac34", + "selectorBytes": [ + 56, + 104, + 172, + 52 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_21", + "description": "Asserts that two arrays of `address` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(address[],address[],string)", + "selector": "0x3e9173c5", + "selectorBytes": [ + 62, + 145, + 115, + 197 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_22", + "description": "Asserts that two arrays of `bytes32` values are equal.", + "declaration": "function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes32[],bytes32[])", + "selector": "0x0cc9ee84", + "selectorBytes": [ + 12, + 201, + 238, + 132 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_23", + "description": "Asserts that two arrays of `bytes32` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes32[],bytes32[],string)", + "selector": "0xe03e9177", + "selectorBytes": [ + 224, + 62, + 145, + 119 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_24", + "description": "Asserts that two arrays of `string` values are equal.", + "declaration": "function assertEq(string[] calldata left, string[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(string[],string[])", + "selector": "0xcf1c049c", + "selectorBytes": [ + 207, + 28, + 4, + 156 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_25", + "description": "Asserts that two arrays of `string` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(string[],string[],string)", + "selector": "0xeff6b27d", + "selectorBytes": [ + 239, + 246, + 178, + 125 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_26", + "description": "Asserts that two arrays of `bytes` values are equal.", + "declaration": "function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes[],bytes[])", + "selector": "0xe5fb9b4a", + "selectorBytes": [ + 229, + 251, + 155, + 74 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_27", + "description": "Asserts that two arrays of `bytes` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes[],bytes[],string)", + "selector": "0xf413f0b6", + "selectorBytes": [ + 244, + 19, + 240, + 182 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_3", + "description": "Asserts that two `uint256` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(uint256 left, uint256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(uint256,uint256,string)", + "selector": "0x88b44c85", + "selectorBytes": [ + 136, + 180, + 76, + 133 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_4", + "description": "Asserts that two `int256` values are equal.", + "declaration": "function assertEq(int256 left, int256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(int256,int256)", + "selector": "0xfe74f05b", + "selectorBytes": [ + 254, + 116, + 240, + 91 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_5", + "description": "Asserts that two `int256` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(int256 left, int256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(int256,int256,string)", + "selector": "0x714a2f13", + "selectorBytes": [ + 113, + 74, + 47, + 19 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_6", + "description": "Asserts that two `address` values are equal.", + "declaration": "function assertEq(address left, address right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(address,address)", + "selector": "0x515361f6", + "selectorBytes": [ + 81, + 83, + 97, + 246 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_7", + "description": "Asserts that two `address` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(address left, address right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(address,address,string)", + "selector": "0x2f2769d1", + "selectorBytes": [ + 47, + 39, + 105, + 209 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_8", + "description": "Asserts that two `bytes32` values are equal.", + "declaration": "function assertEq(bytes32 left, bytes32 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes32,bytes32)", + "selector": "0x7c84c69b", + "selectorBytes": [ + 124, + 132, + 198, + 155 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertEq_9", + "description": "Asserts that two `bytes32` values are equal and includes error message into revert string on failure.", + "declaration": "function assertEq(bytes32 left, bytes32 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertEq(bytes32,bytes32,string)", + "selector": "0xc1fa1ed0", + "selectorBytes": [ + 193, + 250, + 30, + 208 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertFalse_0", + "description": "Asserts that the given condition is false.", + "declaration": "function assertFalse(bool condition) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertFalse(bool)", + "selector": "0xa5982885", + "selectorBytes": [ + 165, + 152, + 40, + 133 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertFalse_1", + "description": "Asserts that the given condition is false and includes error message into revert string on failure.", + "declaration": "function assertFalse(bool condition, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertFalse(bool,string)", + "selector": "0x7ba04809", + "selectorBytes": [ + 123, + 160, + 72, + 9 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGeDecimal_0", + "description": "Compares two `uint256` values. Expects first value to be greater than or equal to second.\nFormats values with decimals in failure message.", + "declaration": "function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGeDecimal(uint256,uint256,uint256)", + "selector": "0x3d1fe08a", + "selectorBytes": [ + 61, + 31, + 224, + 138 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGeDecimal_1", + "description": "Compares two `uint256` values. Expects first value to be greater than or equal to second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGeDecimal(uint256,uint256,uint256,string)", + "selector": "0x8bff9133", + "selectorBytes": [ + 139, + 255, + 145, + 51 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGeDecimal_2", + "description": "Compares two `int256` values. Expects first value to be greater than or equal to second.\nFormats values with decimals in failure message.", + "declaration": "function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGeDecimal(int256,int256,uint256)", + "selector": "0xdc28c0f1", + "selectorBytes": [ + 220, + 40, + 192, + 241 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGeDecimal_3", + "description": "Compares two `int256` values. Expects first value to be greater than or equal to second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGeDecimal(int256,int256,uint256,string)", + "selector": "0x5df93c9b", + "selectorBytes": [ + 93, + 249, + 60, + 155 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGe_0", + "description": "Compares two `uint256` values. Expects first value to be greater than or equal to second.", + "declaration": "function assertGe(uint256 left, uint256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGe(uint256,uint256)", + "selector": "0xa8d4d1d9", + "selectorBytes": [ + 168, + 212, + 209, + 217 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGe_1", + "description": "Compares two `uint256` values. Expects first value to be greater than or equal to second.\nIncludes error message into revert string on failure.", + "declaration": "function assertGe(uint256 left, uint256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGe(uint256,uint256,string)", + "selector": "0xe25242c0", + "selectorBytes": [ + 226, + 82, + 66, + 192 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGe_2", + "description": "Compares two `int256` values. Expects first value to be greater than or equal to second.", + "declaration": "function assertGe(int256 left, int256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGe(int256,int256)", + "selector": "0x0a30b771", + "selectorBytes": [ + 10, + 48, + 183, + 113 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGe_3", + "description": "Compares two `int256` values. Expects first value to be greater than or equal to second.\nIncludes error message into revert string on failure.", + "declaration": "function assertGe(int256 left, int256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGe(int256,int256,string)", + "selector": "0xa84328dd", + "selectorBytes": [ + 168, + 67, + 40, + 221 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGtDecimal_0", + "description": "Compares two `uint256` values. Expects first value to be greater than second.\nFormats values with decimals in failure message.", + "declaration": "function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGtDecimal(uint256,uint256,uint256)", + "selector": "0xeccd2437", + "selectorBytes": [ + 236, + 205, + 36, + 55 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGtDecimal_1", + "description": "Compares two `uint256` values. Expects first value to be greater than second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGtDecimal(uint256,uint256,uint256,string)", + "selector": "0x64949a8d", + "selectorBytes": [ + 100, + 148, + 154, + 141 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGtDecimal_2", + "description": "Compares two `int256` values. Expects first value to be greater than second.\nFormats values with decimals in failure message.", + "declaration": "function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGtDecimal(int256,int256,uint256)", + "selector": "0x78611f0e", + "selectorBytes": [ + 120, + 97, + 31, + 14 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGtDecimal_3", + "description": "Compares two `int256` values. Expects first value to be greater than second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGtDecimal(int256,int256,uint256,string)", + "selector": "0x04a5c7ab", + "selectorBytes": [ + 4, + 165, + 199, + 171 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGt_0", + "description": "Compares two `uint256` values. Expects first value to be greater than second.", + "declaration": "function assertGt(uint256 left, uint256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGt(uint256,uint256)", + "selector": "0xdb07fcd2", + "selectorBytes": [ + 219, + 7, + 252, + 210 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGt_1", + "description": "Compares two `uint256` values. Expects first value to be greater than second.\nIncludes error message into revert string on failure.", + "declaration": "function assertGt(uint256 left, uint256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGt(uint256,uint256,string)", + "selector": "0xd9a3c4d2", + "selectorBytes": [ + 217, + 163, + 196, + 210 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGt_2", + "description": "Compares two `int256` values. Expects first value to be greater than second.", + "declaration": "function assertGt(int256 left, int256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGt(int256,int256)", + "selector": "0x5a362d45", + "selectorBytes": [ + 90, + 54, + 45, + 69 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertGt_3", + "description": "Compares two `int256` values. Expects first value to be greater than second.\nIncludes error message into revert string on failure.", + "declaration": "function assertGt(int256 left, int256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertGt(int256,int256,string)", + "selector": "0xf8d33b9b", + "selectorBytes": [ + 248, + 211, + 59, + 155 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLeDecimal_0", + "description": "Compares two `uint256` values. Expects first value to be less than or equal to second.\nFormats values with decimals in failure message.", + "declaration": "function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLeDecimal(uint256,uint256,uint256)", + "selector": "0xc304aab7", + "selectorBytes": [ + 195, + 4, + 170, + 183 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLeDecimal_1", + "description": "Compares two `uint256` values. Expects first value to be less than or equal to second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLeDecimal(uint256,uint256,uint256,string)", + "selector": "0x7fefbbe0", + "selectorBytes": [ + 127, + 239, + 187, + 224 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLeDecimal_2", + "description": "Compares two `int256` values. Expects first value to be less than or equal to second.\nFormats values with decimals in failure message.", + "declaration": "function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLeDecimal(int256,int256,uint256)", + "selector": "0x11d1364a", + "selectorBytes": [ + 17, + 209, + 54, + 74 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLeDecimal_3", + "description": "Compares two `int256` values. Expects first value to be less than or equal to second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLeDecimal(int256,int256,uint256,string)", + "selector": "0xaa5cf788", + "selectorBytes": [ + 170, + 92, + 247, + 136 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLe_0", + "description": "Compares two `uint256` values. Expects first value to be less than or equal to second.", + "declaration": "function assertLe(uint256 left, uint256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLe(uint256,uint256)", + "selector": "0x8466f415", + "selectorBytes": [ + 132, + 102, + 244, + 21 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLe_1", + "description": "Compares two `uint256` values. Expects first value to be less than or equal to second.\nIncludes error message into revert string on failure.", + "declaration": "function assertLe(uint256 left, uint256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLe(uint256,uint256,string)", + "selector": "0xd17d4b0d", + "selectorBytes": [ + 209, + 125, + 75, + 13 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLe_2", + "description": "Compares two `int256` values. Expects first value to be less than or equal to second.", + "declaration": "function assertLe(int256 left, int256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLe(int256,int256)", + "selector": "0x95fd154e", + "selectorBytes": [ + 149, + 253, + 21, + 78 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLe_3", + "description": "Compares two `int256` values. Expects first value to be less than or equal to second.\nIncludes error message into revert string on failure.", + "declaration": "function assertLe(int256 left, int256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLe(int256,int256,string)", + "selector": "0x4dfe692c", + "selectorBytes": [ + 77, + 254, + 105, + 44 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLtDecimal_0", + "description": "Compares two `uint256` values. Expects first value to be less than second.\nFormats values with decimals in failure message.", + "declaration": "function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLtDecimal(uint256,uint256,uint256)", + "selector": "0x2077337e", + "selectorBytes": [ + 32, + 119, + 51, + 126 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLtDecimal_1", + "description": "Compares two `uint256` values. Expects first value to be less than second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLtDecimal(uint256,uint256,uint256,string)", + "selector": "0xa972d037", + "selectorBytes": [ + 169, + 114, + 208, + 55 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLtDecimal_2", + "description": "Compares two `int256` values. Expects first value to be less than second.\nFormats values with decimals in failure message.", + "declaration": "function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLtDecimal(int256,int256,uint256)", + "selector": "0xdbe8d88b", + "selectorBytes": [ + 219, + 232, + 216, + 139 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLtDecimal_3", + "description": "Compares two `int256` values. Expects first value to be less than second.\nFormats values with decimals in failure message. Includes error message into revert string on failure.", + "declaration": "function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLtDecimal(int256,int256,uint256,string)", + "selector": "0x40f0b4e0", + "selectorBytes": [ + 64, + 240, + 180, + 224 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLt_0", + "description": "Compares two `uint256` values. Expects first value to be less than second.", + "declaration": "function assertLt(uint256 left, uint256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLt(uint256,uint256)", + "selector": "0xb12fc005", + "selectorBytes": [ + 177, + 47, + 192, + 5 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLt_1", + "description": "Compares two `uint256` values. Expects first value to be less than second.\nIncludes error message into revert string on failure.", + "declaration": "function assertLt(uint256 left, uint256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLt(uint256,uint256,string)", + "selector": "0x65d5c135", + "selectorBytes": [ + 101, + 213, + 193, + 53 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLt_2", + "description": "Compares two `int256` values. Expects first value to be less than second.", + "declaration": "function assertLt(int256 left, int256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLt(int256,int256)", + "selector": "0x3e914080", + "selectorBytes": [ + 62, + 145, + 64, + 128 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertLt_3", + "description": "Compares two `int256` values. Expects first value to be less than second.\nIncludes error message into revert string on failure.", + "declaration": "function assertLt(int256 left, int256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertLt(int256,int256,string)", + "selector": "0x9ff531e3", + "selectorBytes": [ + 159, + 245, + 49, + 227 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEqDecimal_0", + "description": "Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.", + "declaration": "function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEqDecimal(uint256,uint256,uint256)", + "selector": "0x669efca7", + "selectorBytes": [ + 102, + 158, + 252, + 167 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEqDecimal_1", + "description": "Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.\nIncludes error message into revert string on failure.", + "declaration": "function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEqDecimal(uint256,uint256,uint256,string)", + "selector": "0xf5a55558", + "selectorBytes": [ + 245, + 165, + 85, + 88 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEqDecimal_2", + "description": "Asserts that two `int256` values are not equal, formatting them with decimals in failure message.", + "declaration": "function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEqDecimal(int256,int256,uint256)", + "selector": "0x14e75680", + "selectorBytes": [ + 20, + 231, + 86, + 128 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEqDecimal_3", + "description": "Asserts that two `int256` values are not equal, formatting them with decimals in failure message.\nIncludes error message into revert string on failure.", + "declaration": "function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEqDecimal(int256,int256,uint256,string)", + "selector": "0x33949f0b", + "selectorBytes": [ + 51, + 148, + 159, + 11 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_0", + "description": "Asserts that two `bool` values are not equal.", + "declaration": "function assertNotEq(bool left, bool right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bool,bool)", + "selector": "0x236e4d66", + "selectorBytes": [ + 35, + 110, + 77, + 102 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_1", + "description": "Asserts that two `bool` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(bool left, bool right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bool,bool,string)", + "selector": "0x1091a261", + "selectorBytes": [ + 16, + 145, + 162, + 97 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_10", + "description": "Asserts that two `string` values are not equal.", + "declaration": "function assertNotEq(string calldata left, string calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(string,string)", + "selector": "0x6a8237b3", + "selectorBytes": [ + 106, + 130, + 55, + 179 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_11", + "description": "Asserts that two `string` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(string calldata left, string calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(string,string,string)", + "selector": "0x78bdcea7", + "selectorBytes": [ + 120, + 189, + 206, + 167 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_12", + "description": "Asserts that two `bytes` values are not equal.", + "declaration": "function assertNotEq(bytes calldata left, bytes calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes,bytes)", + "selector": "0x3cf78e28", + "selectorBytes": [ + 60, + 247, + 142, + 40 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_13", + "description": "Asserts that two `bytes` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes,bytes,string)", + "selector": "0x9507540e", + "selectorBytes": [ + 149, + 7, + 84, + 14 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_14", + "description": "Asserts that two arrays of `bool` values are not equal.", + "declaration": "function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bool[],bool[])", + "selector": "0x286fafea", + "selectorBytes": [ + 40, + 111, + 175, + 234 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_15", + "description": "Asserts that two arrays of `bool` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bool[],bool[],string)", + "selector": "0x62c6f9fb", + "selectorBytes": [ + 98, + 198, + 249, + 251 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_16", + "description": "Asserts that two arrays of `uint256` values are not equal.", + "declaration": "function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(uint256[],uint256[])", + "selector": "0x56f29cba", + "selectorBytes": [ + 86, + 242, + 156, + 186 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_17", + "description": "Asserts that two arrays of `uint256` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(uint256[],uint256[],string)", + "selector": "0x9a7fbd8f", + "selectorBytes": [ + 154, + 127, + 189, + 143 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_18", + "description": "Asserts that two arrays of `int256` values are not equal.", + "declaration": "function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(int256[],int256[])", + "selector": "0x0b72f4ef", + "selectorBytes": [ + 11, + 114, + 244, + 239 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_19", + "description": "Asserts that two arrays of `int256` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(int256[],int256[],string)", + "selector": "0xd3977322", + "selectorBytes": [ + 211, + 151, + 115, + 34 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_2", + "description": "Asserts that two `uint256` values are not equal.", + "declaration": "function assertNotEq(uint256 left, uint256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(uint256,uint256)", + "selector": "0xb7909320", + "selectorBytes": [ + 183, + 144, + 147, + 32 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_20", + "description": "Asserts that two arrays of `address` values are not equal.", + "declaration": "function assertNotEq(address[] calldata left, address[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(address[],address[])", + "selector": "0x46d0b252", + "selectorBytes": [ + 70, + 208, + 178, + 82 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_21", + "description": "Asserts that two arrays of `address` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(address[],address[],string)", + "selector": "0x72c7e0b5", + "selectorBytes": [ + 114, + 199, + 224, + 181 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_22", + "description": "Asserts that two arrays of `bytes32` values are not equal.", + "declaration": "function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes32[],bytes32[])", + "selector": "0x0603ea68", + "selectorBytes": [ + 6, + 3, + 234, + 104 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_23", + "description": "Asserts that two arrays of `bytes32` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes32[],bytes32[],string)", + "selector": "0xb873634c", + "selectorBytes": [ + 184, + 115, + 99, + 76 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_24", + "description": "Asserts that two arrays of `string` values are not equal.", + "declaration": "function assertNotEq(string[] calldata left, string[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(string[],string[])", + "selector": "0xbdfacbe8", + "selectorBytes": [ + 189, + 250, + 203, + 232 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_25", + "description": "Asserts that two arrays of `string` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(string[],string[],string)", + "selector": "0xb67187f3", + "selectorBytes": [ + 182, + 113, + 135, + 243 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_26", + "description": "Asserts that two arrays of `bytes` values are not equal.", + "declaration": "function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes[],bytes[])", + "selector": "0xedecd035", + "selectorBytes": [ + 237, + 236, + 208, + 53 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_27", + "description": "Asserts that two arrays of `bytes` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes[],bytes[],string)", + "selector": "0x1dcd1f68", + "selectorBytes": [ + 29, + 205, + 31, + 104 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_3", + "description": "Asserts that two `uint256` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(uint256 left, uint256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(uint256,uint256,string)", + "selector": "0x98f9bdbd", + "selectorBytes": [ + 152, + 249, + 189, + 189 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_4", + "description": "Asserts that two `int256` values are not equal.", + "declaration": "function assertNotEq(int256 left, int256 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(int256,int256)", + "selector": "0xf4c004e3", + "selectorBytes": [ + 244, + 192, + 4, + 227 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_5", + "description": "Asserts that two `int256` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(int256 left, int256 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(int256,int256,string)", + "selector": "0x4724c5b9", + "selectorBytes": [ + 71, + 36, + 197, + 185 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_6", + "description": "Asserts that two `address` values are not equal.", + "declaration": "function assertNotEq(address left, address right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(address,address)", + "selector": "0xb12e1694", + "selectorBytes": [ + 177, + 46, + 22, + 148 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_7", + "description": "Asserts that two `address` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(address left, address right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(address,address,string)", + "selector": "0x8775a591", + "selectorBytes": [ + 135, + 117, + 165, + 145 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_8", + "description": "Asserts that two `bytes32` values are not equal.", + "declaration": "function assertNotEq(bytes32 left, bytes32 right) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes32,bytes32)", + "selector": "0x898e83fc", + "selectorBytes": [ + 137, + 142, + 131, + 252 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertNotEq_9", + "description": "Asserts that two `bytes32` values are not equal and includes error message into revert string on failure.", + "declaration": "function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertNotEq(bytes32,bytes32,string)", + "selector": "0xb2332f51", + "selectorBytes": [ + 178, + 51, + 47, + 81 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertTrue_0", + "description": "Asserts that the given condition is true.", + "declaration": "function assertTrue(bool condition) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertTrue(bool)", + "selector": "0x0c9fd581", + "selectorBytes": [ + 12, + 159, + 213, + 129 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assertTrue_1", + "description": "Asserts that the given condition is true and includes error message into revert string on failure.", + "declaration": "function assertTrue(bool condition, string calldata error) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assertTrue(bool,string)", + "selector": "0xa34edc03", + "selectorBytes": [ + 163, + 78, + 220, + 3 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "assume", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 8daca4ef31d2b..69f1e084572dc 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -711,6 +711,552 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function skip(bool skipTest) external; + /// Asserts that the given condition is true. + #[cheatcode(group = Testing, safety = Safe)] + function assertTrue(bool condition) external pure; + + /// Asserts that the given condition is true and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertTrue(bool condition, string calldata error) external pure; + + /// Asserts that the given condition is false. + #[cheatcode(group = Testing, safety = Safe)] + function assertFalse(bool condition) external pure; + + /// Asserts that the given condition is false and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertFalse(bool condition, string calldata error) external pure; + + /// Asserts that two `bool` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bool left, bool right) external pure; + + /// Asserts that two `bool` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bool left, bool right, string calldata error) external pure; + + /// Asserts that two `uint256` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(uint256 left, uint256 right) external pure; + + /// Asserts that two `uint256` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(uint256 left, uint256 right, string calldata error) external pure; + + /// Asserts that two `int256` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(int256 left, int256 right) external pure; + + /// Asserts that two `int256` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(int256 left, int256 right, string calldata error) external pure; + + /// Asserts that two `address` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(address left, address right) external pure; + + /// Asserts that two `address` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(address left, address right, string calldata error) external pure; + + /// Asserts that two `bytes32` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes32 left, bytes32 right) external pure; + + /// Asserts that two `bytes32` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes32 left, bytes32 right, string calldata error) external pure; + + /// Asserts that two `string` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(string calldata left, string calldata right) external pure; + + /// Asserts that two `string` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(string calldata left, string calldata right, string calldata error) external pure; + + /// Asserts that two `bytes` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes calldata left, bytes calldata right) external pure; + + /// Asserts that two `bytes` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `bool` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bool[] calldata left, bool[] calldata right) external pure; + + /// Asserts that two arrays of `bool` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `uint256 values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(uint256[] calldata left, uint256[] calldata right) external pure; + + /// Asserts that two arrays of `uint256` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `int256` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(int256[] calldata left, int256[] calldata right) external pure; + + /// Asserts that two arrays of `int256` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `address` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(address[] calldata left, address[] calldata right) external pure; + + /// Asserts that two arrays of `address` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `bytes32` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure; + + /// Asserts that two arrays of `bytes32` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `string` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(string[] calldata left, string[] calldata right) external pure; + + /// Asserts that two arrays of `string` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `bytes` values are equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes[] calldata left, bytes[] calldata right) external pure; + + /// Asserts that two arrays of `bytes` values are equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure; + + /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + + /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + + /// Asserts that two `int256` values are equal, formatting them with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure; + + /// Asserts that two `int256` values are equal, formatting them with decimals in failure message. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + + /// Asserts that two `bool` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bool left, bool right) external pure; + + /// Asserts that two `bool` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bool left, bool right, string calldata error) external pure; + + /// Asserts that two `uint256` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(uint256 left, uint256 right) external pure; + + /// Asserts that two `uint256` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(uint256 left, uint256 right, string calldata error) external pure; + + /// Asserts that two `int256` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(int256 left, int256 right) external pure; + + /// Asserts that two `int256` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(int256 left, int256 right, string calldata error) external pure; + + /// Asserts that two `address` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(address left, address right) external pure; + + /// Asserts that two `address` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(address left, address right, string calldata error) external pure; + + /// Asserts that two `bytes32` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes32 left, bytes32 right) external pure; + + /// Asserts that two `bytes32` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure; + + /// Asserts that two `string` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(string calldata left, string calldata right) external pure; + + /// Asserts that two `string` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(string calldata left, string calldata right, string calldata error) external pure; + + /// Asserts that two `bytes` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes calldata left, bytes calldata right) external pure; + + /// Asserts that two `bytes` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `bool` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bool[] calldata left, bool[] calldata right) external pure; + + /// Asserts that two arrays of `bool` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `uint256` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure; + + /// Asserts that two arrays of `uint256` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `int256` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(int256[] calldata left, int256[] calldata right) external pure; + + /// Asserts that two arrays of `int256` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `address` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(address[] calldata left, address[] calldata right) external pure; + + /// Asserts that two arrays of `address` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `bytes32` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure; + + /// Asserts that two arrays of `bytes32` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `string` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(string[] calldata left, string[] calldata right) external pure; + + /// Asserts that two arrays of `string` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure; + + /// Asserts that two arrays of `bytes` values are not equal. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure; + + /// Asserts that two arrays of `bytes` values are not equal and includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure; + + /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + + /// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + + /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure; + + /// Asserts that two `int256` values are not equal, formatting them with decimals in failure message. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than second. + #[cheatcode(group = Testing, safety = Safe)] + function assertGt(uint256 left, uint256 right) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGt(uint256 left, uint256 right, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be greater than second. + #[cheatcode(group = Testing, safety = Safe)] + function assertGt(int256 left, int256 right) external pure; + + /// Compares two `int256` values. Expects first value to be greater than second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGt(int256 left, int256 right, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be greater than second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure; + + /// Compares two `int256` values. Expects first value to be greater than second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than or equal to second. + #[cheatcode(group = Testing, safety = Safe)] + function assertGe(uint256 left, uint256 right) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than or equal to second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGe(uint256 left, uint256 right, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be greater than or equal to second. + #[cheatcode(group = Testing, safety = Safe)] + function assertGe(int256 left, int256 right) external pure; + + /// Compares two `int256` values. Expects first value to be greater than or equal to second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGe(int256 left, int256 right, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than or equal to second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + + /// Compares two `uint256` values. Expects first value to be greater than or equal to second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be greater than or equal to second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure; + + /// Compares two `int256` values. Expects first value to be greater than or equal to second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be less than second. + #[cheatcode(group = Testing, safety = Safe)] + function assertLt(uint256 left, uint256 right) external pure; + + /// Compares two `uint256` values. Expects first value to be less than second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLt(uint256 left, uint256 right, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be less than second. + #[cheatcode(group = Testing, safety = Safe)] + function assertLt(int256 left, int256 right) external pure; + + /// Compares two `int256` values. Expects first value to be less than second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLt(int256 left, int256 right, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be less than second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + + /// Compares two `uint256` values. Expects first value to be less than second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be less than second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure; + + /// Compares two `int256` values. Expects first value to be less than second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be less than or equal to second. + #[cheatcode(group = Testing, safety = Safe)] + function assertLe(uint256 left, uint256 right) external pure; + + /// Compares two `uint256` values. Expects first value to be less than or equal to second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLe(uint256 left, uint256 right, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be less than or equal to second. + #[cheatcode(group = Testing, safety = Safe)] + function assertLe(int256 left, int256 right) external pure; + + /// Compares two `int256` values. Expects first value to be less than or equal to second. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLe(int256 left, int256 right, string calldata error) external pure; + + /// Compares two `uint256` values. Expects first value to be less than or equal to second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + + /// Compares two `uint256` values. Expects first value to be less than or equal to second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `int256` values. Expects first value to be less than or equal to second. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure; + + /// Compares two `int256` values. Expects first value to be less than or equal to second. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + + /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure; + + /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure; + + /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure; + + /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure; + + /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure; + + /// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbsDecimal( + uint256 left, + uint256 right, + uint256 maxDelta, + uint256 decimals, + string calldata error + ) external pure; + + /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure; + + /// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`. + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqAbsDecimal( + int256 left, + int256 right, + uint256 maxDelta, + uint256 decimals, + string calldata error + ) external pure; + + /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure; + + /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure; + + /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure; + + /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + /// Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure; + + /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRelDecimal( + uint256 left, + uint256 right, + uint256 maxPercentDelta, + uint256 decimals + ) external pure; + + /// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRelDecimal( + uint256 left, + uint256 right, + uint256 maxPercentDelta, + uint256 decimals, + string calldata error + ) external pure; + + /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + /// Formats values with decimals in failure message. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRelDecimal( + int256 left, + int256 right, + uint256 maxPercentDelta, + uint256 decimals + ) external pure; + + /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. + /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% + /// Formats values with decimals in failure message. Includes error message into revert string on failure. + #[cheatcode(group = Testing, safety = Safe)] + function assertApproxEqRelDecimal( + int256 left, + int256 right, + uint256 maxPercentDelta, + uint256 decimals, + string calldata error + ) external pure; + // ======== OS and Filesystem ======== // -------- Metadata -------- diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 740d4687e181f..0d557db223291 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -5,6 +5,7 @@ use alloy_primitives::Address; use alloy_sol_types::SolValue; use foundry_evm_core::constants::{MAGIC_ASSUME, MAGIC_SKIP}; +pub(crate) mod assert; pub(crate) mod expect; impl Cheatcode for assumeCall { diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs new file mode 100644 index 0000000000000..70b2d5971a457 --- /dev/null +++ b/crates/cheatcodes/src/test/assert.rs @@ -0,0 +1,1182 @@ +use std::fmt::{Debug, Display}; + +use alloy_primitives::{I256, U256}; +use foundry_evm_core::abi::{format_units_int, format_units_uint}; +use itertools::Itertools; + +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; + +const EQ_REL_DELTA_RESOLUTION: U256 = U256::from_limbs([18, 0, 0, 0]); + +#[derive(Debug, thiserror::Error)] +#[error("assertion failed")] +struct SimpleAssertionError; + +#[derive(thiserror::Error, Debug)] +enum ComparisonAssertionError<'a, T> { + Ne { left: &'a T, right: &'a T }, + Eq { left: &'a T, right: &'a T }, + Ge { left: &'a T, right: &'a T }, + Gt { left: &'a T, right: &'a T }, + Le { left: &'a T, right: &'a T }, + Lt { left: &'a T, right: &'a T }, +} + +macro_rules! format_values { + ($self:expr, $format_fn:expr) => { + match $self { + Self::Ne { left, right } => format!("{} == {}", $format_fn(left), $format_fn(right)), + Self::Eq { left, right } => format!("{} != {}", $format_fn(left), $format_fn(right)), + Self::Ge { left, right } => format!("{} < {}", $format_fn(left), $format_fn(right)), + Self::Gt { left, right } => format!("{} <= {}", $format_fn(left), $format_fn(right)), + Self::Le { left, right } => format!("{} > {}", $format_fn(left), $format_fn(right)), + Self::Lt { left, right } => format!("{} >= {}", $format_fn(left), $format_fn(right)), + } + }; +} + +impl<'a, T: Display> ComparisonAssertionError<'a, T> { + fn format_for_values(&self) -> String { + format_values!(self, T::to_string) + } +} + +impl<'a, T: Display> ComparisonAssertionError<'a, Vec> { + fn format_for_arrays(&self) -> String { + let formatter = |v: &Vec| format!("[{}]", v.iter().format(", ")); + format_values!(self, formatter) + } +} + +impl<'a> ComparisonAssertionError<'a, U256> { + fn format_with_decimals(&self, decimals: &U256) -> String { + let formatter = |v: &U256| format_units_uint(v, decimals); + format_values!(self, formatter) + } +} + +impl<'a> ComparisonAssertionError<'a, I256> { + fn format_with_decimals(&self, decimals: &U256) -> String { + let formatter = |v: &I256| format_units_int(v, decimals); + format_values!(self, formatter) + } +} + +#[derive(thiserror::Error, Debug)] +#[error("{left} !~= {right} (max delta: {max_delta}, real delta: {real_delta})")] +struct EqAbsAssertionError { + left: T, + right: T, + max_delta: D, + real_delta: D, +} + +impl EqAbsAssertionError { + fn format_with_decimals(&self, decimals: &U256) -> String { + format!( + "{} !~= {} (max delta: {}, real delta: {})", + format_units_uint(&self.left, decimals), + format_units_uint(&self.right, decimals), + format_units_uint(&self.max_delta, decimals), + format_units_uint(&self.real_delta, decimals), + ) + } +} + +impl EqAbsAssertionError { + fn format_with_decimals(&self, decimals: &U256) -> String { + format!( + "{} !~= {} (max delta: {}, real delta: {})", + format_units_int(&self.left, decimals), + format_units_int(&self.right, decimals), + format_units_uint(&self.max_delta, decimals), + format_units_uint(&self.real_delta, decimals), + ) + } +} + +fn format_delta_percent(delta: &U256) -> String { + format!("{}%", format_units_uint(delta, &(EQ_REL_DELTA_RESOLUTION - U256::from(2)))) +} + +#[derive(thiserror::Error, Debug)] +#[error( + "{left} !~= {right} (max delta: {}, real delta: {})", + format_delta_percent(max_delta), + format_delta_percent(real_delta) +)] +struct EqRelAssertionFailure { + left: T, + right: T, + max_delta: U256, + real_delta: U256, +} + +#[derive(thiserror::Error, Debug)] +enum EqRelAssertionError { + #[error(transparent)] + Failure(Box>), + #[error("overflow in delta calculation")] + Overflow, +} + +impl EqRelAssertionError { + fn format_with_decimals(&self, decimals: &U256) -> String { + match self { + Self::Failure(f) => format!( + "{} !~= {} (max delta: {}, real delta: {})", + format_units_uint(&f.left, decimals), + format_units_uint(&f.right, decimals), + format_delta_percent(&f.max_delta), + format_delta_percent(&f.real_delta), + ), + Self::Overflow => self.to_string(), + } + } +} + +impl EqRelAssertionError { + fn format_with_decimals(&self, decimals: &U256) -> String { + match self { + Self::Failure(f) => format!( + "{} !~= {} (max delta: {}, real delta: {})", + format_units_int(&f.left, decimals), + format_units_int(&f.right, decimals), + format_delta_percent(&f.max_delta), + format_delta_percent(&f.real_delta), + ), + Self::Overflow => self.to_string(), + } + } +} + +type ComparisonResult<'a, T> = Result, ComparisonAssertionError<'a, T>>; + +impl Cheatcode for assertTrue_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_true(self.condition).map_err(|e| e.to_string())?) + } +} + +impl Cheatcode for assertTrue_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_true(self.condition).map_err(|_| self.error.to_string())?) + } +} + +impl Cheatcode for assertFalse_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_false(self.condition).map_err(|e| e.to_string())?) + } +} + +impl Cheatcode for assertFalse_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_false(self.condition).map_err(|_| self.error.to_string())?) + } +} + +impl Cheatcode for assertEq_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_4Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_5Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_6Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_7Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_8Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_9Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_10Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_11Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_12Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_13Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertEq_14Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_15Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_16Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_17Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_18Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_19Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_20Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_21Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_22Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_23Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_24Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_25Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_26Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + let left = left.iter().map(hex::encode_prefixed).collect::>(); + let right = right.iter().map(hex::encode_prefixed).collect::>(); + Ok(assert_eq(&left, &right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEq_27Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + let left = left.iter().map(hex::encode_prefixed).collect::>(); + let right = right.iter().map(hex::encode_prefixed).collect::>(); + Ok(assert_eq(&left, &right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertEqDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_eq(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertEqDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_eq(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertEqDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_eq(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertEqDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_eq(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertNotEq_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_4Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_5Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_6Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_7Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_8Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_9Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_10Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_11Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_12Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_13Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) + .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertNotEq_14Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_15Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_16Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_17Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_18Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_19Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_20Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_21Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_22Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_23Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_24Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_25Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_not_eq(left, right) + .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_26Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + let left = left.iter().map(hex::encode_prefixed).collect::>(); + let right = right.iter().map(hex::encode_prefixed).collect::>(); + Ok(assert_not_eq(&left, &right) + .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEq_27Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + let left = left.iter().map(hex::encode_prefixed).collect::>(); + let right = right.iter().map(hex::encode_prefixed).collect::>(); + Ok(assert_not_eq(&left, &right) + .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) + } +} + +impl Cheatcode for assertNotEqDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_not_eq(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertNotEqDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_not_eq(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertNotEqDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_not_eq(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertNotEqDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_not_eq(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGt_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_gt(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertGt_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_gt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertGt_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_gt(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertGt_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_gt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertGtDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_gt(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGtDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_gt(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGtDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_gt(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGtDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_gt(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGe_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_ge(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertGe_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_ge(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertGe_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_ge(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertGe_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_ge(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertGeDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_ge(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGeDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_ge(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGeDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_ge(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertGeDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_ge(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLt_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_lt(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertLt_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_lt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertLt_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_lt(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertLt_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_lt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertLtDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_lt(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLtDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_lt(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLtDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_lt(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLtDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_lt(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLe_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_le(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertLe_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_le(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertLe_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right } = self; + Ok(assert_le(left, right) + .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) + } +} + +impl Cheatcode for assertLe_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { left, right, error } = self; + Ok(assert_le(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) + } +} + +impl Cheatcode for assertLeDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_le(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLeDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_le(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLeDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_le(&self.left, &self.right) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertLeDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(assert_le(&self.left, &self.right) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqAbs_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("assertion failed: {}", e))?) + } +} + +impl Cheatcode for assertApproxEqAbs_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("{}: {}", self.error, e))?) + } +} + +impl Cheatcode for assertApproxEqAbs_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("assertion failed: {}", e))?) + } +} + +impl Cheatcode for assertApproxEqAbs_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("{}: {}", self.error, e))?) + } +} + +impl Cheatcode for assertApproxEqAbsDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqAbsDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqAbsDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqAbsDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqRel_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("assertion failed: {}", e))?) + } +} + +impl Cheatcode for assertApproxEqRel_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("{}: {}", self.error, e))?) + } +} + +impl Cheatcode for assertApproxEqRel_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("assertion failed: {}", e))?) + } +} + +impl Cheatcode for assertApproxEqRel_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("{}: {}", self.error, e))?) + } +} + +impl Cheatcode for assertApproxEqRelDecimal_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqRelDecimal_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqRelDecimal_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) + } +} + +impl Cheatcode for assertApproxEqRelDecimal_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) + .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) + } +} + +fn assert_true(condition: bool) -> Result, SimpleAssertionError> { + if condition { + Ok(Default::default()) + } else { + Err(SimpleAssertionError) + } +} + +fn assert_false(condition: bool) -> Result, SimpleAssertionError> { + if !condition { + Ok(Default::default()) + } else { + Err(SimpleAssertionError) + } +} + +fn assert_eq<'a, T: PartialEq>(left: &'a T, right: &'a T) -> ComparisonResult<'a, T> { + if left == right { + Ok(Default::default()) + } else { + Err(ComparisonAssertionError::Eq { left, right }) + } +} + +fn assert_not_eq<'a, T: PartialEq>(left: &'a T, right: &'a T) -> ComparisonResult<'a, T> { + if left != right { + Ok(Default::default()) + } else { + Err(ComparisonAssertionError::Ne { left, right }) + } +} + +fn get_delta_uint(left: U256, right: U256) -> U256 { + if left > right { + left - right + } else { + right - left + } +} + +fn get_delta_int(left: I256, right: I256) -> U256 { + let (left_sign, left_abs) = left.into_sign_and_abs(); + let (right_sign, right_abs) = right.into_sign_and_abs(); + + if left_sign == right_sign { + if left_abs > right_abs { + left_abs - right_abs + } else { + right_abs - left_abs + } + } else { + left_abs + right_abs + } +} + +fn uint_assert_approx_eq_abs( + left: U256, + right: U256, + max_delta: U256, +) -> Result, Box>> { + let delta = get_delta_uint(left, right); + + if delta <= max_delta { + Ok(Default::default()) + } else { + Err(Box::new(EqAbsAssertionError { left, right, max_delta, real_delta: delta })) + } +} + +fn int_assert_approx_eq_abs( + left: I256, + right: I256, + max_delta: U256, +) -> Result, Box>> { + let delta = get_delta_int(left, right); + + if delta <= max_delta { + Ok(Default::default()) + } else { + Err(Box::new(EqAbsAssertionError { left, right, max_delta, real_delta: delta })) + } +} + +fn uint_assert_approx_eq_rel( + left: U256, + right: U256, + max_delta: U256, +) -> Result, EqRelAssertionError> { + let delta = get_delta_uint(left, right) + .checked_mul(U256::pow(U256::from(10), EQ_REL_DELTA_RESOLUTION)) + .ok_or(EqRelAssertionError::Overflow)? + .checked_div(right) + .ok_or(EqRelAssertionError::Overflow)?; + + if delta <= max_delta { + Ok(Default::default()) + } else { + Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { + left, + right, + max_delta, + real_delta: delta, + }))) + } +} + +fn int_assert_approx_eq_rel( + left: I256, + right: I256, + max_delta: U256, +) -> Result, EqRelAssertionError> { + let (_, abs_right) = right.into_sign_and_abs(); + let delta = get_delta_int(left, right) + .checked_mul(U256::pow(U256::from(10), EQ_REL_DELTA_RESOLUTION)) + .ok_or(EqRelAssertionError::Overflow)? + .checked_div(abs_right) + .ok_or(EqRelAssertionError::Overflow)?; + + if delta <= max_delta { + Ok(Default::default()) + } else { + Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { + left, + right, + max_delta, + real_delta: delta, + }))) + } +} + +fn assert_gt<'a, T: PartialOrd>(left: &'a T, right: &'a T) -> ComparisonResult<'a, T> { + if left > right { + Ok(Default::default()) + } else { + Err(ComparisonAssertionError::Gt { left, right }) + } +} + +fn assert_ge<'a, T: PartialOrd>(left: &'a T, right: &'a T) -> ComparisonResult<'a, T> { + if left >= right { + Ok(Default::default()) + } else { + Err(ComparisonAssertionError::Ge { left, right }) + } +} + +fn assert_lt<'a, T: PartialOrd>(left: &'a T, right: &'a T) -> ComparisonResult<'a, T> { + if left < right { + Ok(Default::default()) + } else { + Err(ComparisonAssertionError::Lt { left, right }) + } +} + +fn assert_le<'a, T: PartialOrd>(left: &'a T, right: &'a T) -> ComparisonResult<'a, T> { + if left <= right { + Ok(Default::default()) + } else { + Err(ComparisonAssertionError::Le { left, right }) + } +} diff --git a/crates/evm/core/src/abi/console.rs b/crates/evm/core/src/abi/console.rs index 54014359b9dd1..e9757a4768de8 100644 --- a/crates/evm/core/src/abi/console.rs +++ b/crates/evm/core/src/abi/console.rs @@ -77,12 +77,12 @@ interface Console { } } -fn format_units_int(x: &I256, decimals: &U256) -> String { +pub fn format_units_int(x: &I256, decimals: &U256) -> String { let (sign, x) = x.into_sign_and_abs(); format!("{sign}{}", format_units_uint(&x, decimals)) } -fn format_units_uint(x: &U256, decimals: &U256) -> String { +pub fn format_units_uint(x: &U256, decimals: &U256) -> String { match alloy_primitives::utils::Unit::new(decimals.saturating_to::()) { Some(units) => alloy_primitives::utils::ParseUnits::U256(*x).format_units(units), None => x.to_string(), diff --git a/crates/evm/core/src/abi/mod.rs b/crates/evm/core/src/abi/mod.rs index 39566cf796fcf..54f35c966af29 100644 --- a/crates/evm/core/src/abi/mod.rs +++ b/crates/evm/core/src/abi/mod.rs @@ -3,7 +3,7 @@ pub use foundry_cheatcodes_spec::Vm; mod console; -pub use console::Console; +pub use console::{format_units_int, format_units_uint, Console}; mod hardhat_console; pub use hardhat_console::{ diff --git a/testdata/cheats/Assert.t.sol b/testdata/cheats/Assert.t.sol new file mode 100644 index 0000000000000..680300dde988d --- /dev/null +++ b/testdata/cheats/Assert.t.sol @@ -0,0 +1,823 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract AssertionsTest is DSTest { + string constant errorMessage = "User provided message"; + uint256 constant maxDecimals = 77; + + Vm constant vm = Vm(HEVM_ADDRESS); + + function _abs(int256 a) internal pure returns (uint256) { + // Required or it will fail when `a = type(int256).min` + if (a == type(int256).min) { + return uint256(type(int256).max) + 1; + } + + return uint256(a > 0 ? a : -a); + } + + function _getDelta(uint256 a, uint256 b) internal pure returns (uint256) { + return a > b ? a - b : b - a; + } + + function _getDelta(int256 a, int256 b) internal pure returns (uint256) { + // a and b are of the same sign + // this works thanks to two's complement, the left-most bit is the sign bit + if ((a ^ b) > -1) { + return _getDelta(_abs(a), _abs(b)); + } + + // a and b are of opposite signs + return _abs(a) + _abs(b); + } + + function _prefixDecWithZeroes(string memory intPart, string memory decimalPart, uint256 decimals) + internal + returns (string memory) + { + while (bytes(decimalPart).length < decimals) { + decimalPart = string.concat("0", decimalPart); + } + + return string.concat(intPart, ".", decimalPart); + } + + function _formatWithDecimals(uint256 value, uint256 decimals) internal returns (string memory) { + string memory intPart = vm.toString(value / (10 ** decimals)); + string memory decimalPart = vm.toString(value % (10 ** decimals)); + + return _prefixDecWithZeroes(intPart, decimalPart, decimals); + } + + function _formatWithDecimals(int256 value, uint256 decimals) internal returns (string memory) { + string memory intPart = vm.toString(value / int256(10 ** decimals)); + int256 mod = value % int256(10 ** decimals); + string memory decimalPart = vm.toString(mod > 0 ? mod : -mod); + + // Add - if we have something like 0.123 + if ((value < 0) && keccak256(abi.encode(intPart)) == keccak256(abi.encode("0"))) { + intPart = string.concat("-", intPart); + } + + return _prefixDecWithZeroes(intPart, decimalPart, decimals); + } + + function testFuzzAssertEqNotEq(uint256 left, uint256 right, uint256 decimals) public { + vm.assume(left != right); + vm.assume(decimals <= maxDecimals); + + vm.assertEq(left, left); + vm.assertEq(right, right); + vm.assertNotEq(left, right); + vm.assertNotEq(right, left); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " != ", vm.toString(right))) + ); + vm.assertEq(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " == ", vm.toString(left))) + ); + vm.assertNotEq(left, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " != ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertEqDecimal(left, right, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " == ", + _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertNotEqDecimal(left, left, decimals); + } + + function testFuzzAssertEqNotEq(int256 left, int256 right, uint256 decimals) public { + vm.assume(left != right); + vm.assume(decimals <= maxDecimals); + + vm.assertEq(left, left); + vm.assertEq(right, right); + vm.assertNotEq(left, right); + vm.assertNotEq(right, left); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " != ", vm.toString(right))) + ); + vm.assertEq(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " == ", vm.toString(left))) + ); + vm.assertNotEq(left, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + errorMessage, + ": ", + _formatWithDecimals(left, decimals), + " != ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertEqDecimal(left, right, decimals, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + errorMessage, ": ", _formatWithDecimals(left, decimals), " == ", _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertNotEqDecimal(left, left, decimals, errorMessage); + } + + function testFuzzAssertEqNotEq(bool left, bool right) public { + vm.assume(left != right); + + vm.assertEq(left, left); + vm.assertEq(right, right); + vm.assertNotEq(left, right); + vm.assertNotEq(right, left); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " != ", vm.toString(right))) + ); + vm.assertEq(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " == ", vm.toString(left))) + ); + vm.assertNotEq(left, left, errorMessage); + } + + function testFuzzAssertEqNotEq(address left, address right) public { + vm.assume(left != right); + + vm.assertEq(left, left); + vm.assertEq(right, right); + vm.assertNotEq(left, right); + vm.assertNotEq(right, left); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " != ", vm.toString(right))) + ); + vm.assertEq(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " == ", vm.toString(left))) + ); + vm.assertNotEq(left, left, errorMessage); + } + + function testFuzzAssertEqNotEq(bytes32 left, bytes32 right) public { + vm.assume(left != right); + + vm.assertEq(left, left); + vm.assertEq(right, right); + vm.assertNotEq(left, right); + vm.assertNotEq(right, left); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " != ", vm.toString(right))) + ); + vm.assertEq(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " == ", vm.toString(left))) + ); + vm.assertNotEq(left, left, errorMessage); + } + + function testFuzzAssertEqNotEq(string memory left, string memory right) public { + vm.assume(keccak256(abi.encodePacked(left)) != keccak256(abi.encodePacked(right))); + + vm.assertEq(left, left); + vm.assertEq(right, right); + vm.assertNotEq(left, right); + vm.assertNotEq(right, left); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": ", left, " != ", right))); + vm.assertEq(left, right, errorMessage); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": ", left, " == ", left))); + vm.assertNotEq(left, left, errorMessage); + } + + function testFuzzAssertEqNotEq(bytes memory left, bytes memory right) public { + vm.assume(keccak256(left) != keccak256(right)); + + vm.assertEq(left, left); + vm.assertEq(right, right); + vm.assertNotEq(left, right); + vm.assertNotEq(right, left); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " != ", vm.toString(right))) + ); + vm.assertEq(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " == ", vm.toString(left))) + ); + vm.assertNotEq(left, left, errorMessage); + } + + function testFuzzAssertGtLt(uint256 left, uint256 right, uint256 decimals) public { + vm.assume(left < right); + vm.assume(decimals <= maxDecimals); + + vm.assertGt(right, left); + vm.assertLt(left, right); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " <= ", vm.toString(right))) + ); + vm.assertGt(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(right), " <= ", vm.toString(right))) + ); + vm.assertGt(right, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " >= ", vm.toString(left))) + ); + vm.assertLt(left, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(right), " >= ", vm.toString(left))) + ); + vm.assertLt(right, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " <= ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertGtDecimal(left, right, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(right, decimals), + " <= ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertGtDecimal(right, right, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " >= ", + _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertLtDecimal(left, left, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(right, decimals), + " >= ", + _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertLtDecimal(right, left, decimals); + } + + function testFuzzAssertGtLt(int256 left, int256 right, uint256 decimals) public { + vm.assume(left < right); + vm.assume(decimals <= maxDecimals); + + vm.assertGt(right, left); + vm.assertLt(left, right); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " <= ", vm.toString(right))) + ); + vm.assertGt(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(right), " <= ", vm.toString(right))) + ); + vm.assertGt(right, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " >= ", vm.toString(left))) + ); + vm.assertLt(left, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(right), " >= ", vm.toString(left))) + ); + vm.assertLt(right, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " <= ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertGtDecimal(left, right, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(right, decimals), + " <= ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertGtDecimal(right, right, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " >= ", + _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertLtDecimal(left, left, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(right, decimals), + " >= ", + _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertLtDecimal(right, left, decimals); + } + + function testFuzzAssertGeLe(uint256 left, uint256 right, uint256 decimals) public { + vm.assume(left < right); + vm.assume(decimals <= maxDecimals); + + vm.assertGe(left, left); + vm.assertLe(left, left); + vm.assertGe(right, right); + vm.assertLe(right, right); + vm.assertGe(right, left); + vm.assertLe(left, right); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " < ", vm.toString(right))) + ); + vm.assertGe(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(right), " > ", vm.toString(left))) + ); + vm.assertLe(right, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " < ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertGeDecimal(left, right, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(right, decimals), + " > ", + _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertLeDecimal(right, left, decimals); + } + + function testFuzzAssertGeLe(int256 left, int256 right, uint256 decimals) public { + vm.assume(left < right); + vm.assume(decimals <= maxDecimals); + + vm.assertGe(left, left); + vm.assertLe(left, left); + vm.assertGe(right, right); + vm.assertLe(right, right); + vm.assertGe(right, left); + vm.assertLe(left, right); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(left), " < ", vm.toString(right))) + ); + vm.assertGe(left, right, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": ", vm.toString(right), " > ", vm.toString(left))) + ); + vm.assertLe(right, left, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " < ", + _formatWithDecimals(right, decimals) + ) + ) + ); + vm.assertGeDecimal(left, right, decimals); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(right, decimals), + " > ", + _formatWithDecimals(left, decimals) + ) + ) + ); + vm.assertLeDecimal(right, left, decimals); + } + + function testFuzzAssertApproxEqAbs(uint256 left, uint256 right, uint256 decimals) public { + uint256 delta = _getDelta(right, left); + vm.assume(decimals <= maxDecimals); + + vm.assertApproxEqAbs(left, right, delta); + + if (delta > 0) { + vm._expectCheatcodeRevert( + bytes( + string.concat( + errorMessage, + ": ", + vm.toString(left), + " !~= ", + vm.toString(right), + " (max delta: ", + vm.toString(delta - 1), + ", real delta: ", + vm.toString(delta), + ")" + ) + ) + ); + vm.assertApproxEqAbs(left, right, delta - 1, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " !~= ", + _formatWithDecimals(right, decimals), + " (max delta: ", + _formatWithDecimals(delta - 1, decimals), + ", real delta: ", + _formatWithDecimals(delta, decimals), + ")" + ) + ) + ); + vm.assertApproxEqAbsDecimal(left, right, delta - 1, decimals); + } + } + + function testFuzzAssertApproxEqAbs(int256 left, int256 right, uint256 decimals) public { + uint256 delta = _getDelta(right, left); + vm.assume(decimals <= maxDecimals); + + vm.assertApproxEqAbs(left, right, delta); + + if (delta > 0) { + vm._expectCheatcodeRevert( + bytes( + string.concat( + errorMessage, + ": ", + vm.toString(left), + " !~= ", + vm.toString(right), + " (max delta: ", + vm.toString(delta - 1), + ", real delta: ", + vm.toString(delta), + ")" + ) + ) + ); + vm.assertApproxEqAbs(left, right, delta - 1, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " !~= ", + _formatWithDecimals(right, decimals), + " (max delta: ", + _formatWithDecimals(delta - 1, decimals), + ", real delta: ", + _formatWithDecimals(delta, decimals), + ")" + ) + ) + ); + vm.assertApproxEqAbsDecimal(left, right, delta - 1, decimals); + } + } + + function testFuzzAssertApproxEqRel(uint256 left, uint256 right, uint256 decimals) public { + vm.assume(right != 0); + uint256 delta = _getDelta(right, left); + vm.assume(delta < type(uint256).max / (10 ** 18)); + vm.assume(decimals <= maxDecimals); + + uint256 percentDelta = delta * (10 ** 18) / right; + + vm.assertApproxEqRel(left, right, percentDelta); + + if (percentDelta > 0) { + vm._expectCheatcodeRevert( + bytes( + string.concat( + errorMessage, + ": ", + vm.toString(left), + " !~= ", + vm.toString(right), + " (max delta: ", + _formatWithDecimals(percentDelta - 1, 16), + "%, real delta: ", + _formatWithDecimals(percentDelta, 16), + "%)" + ) + ) + ); + vm.assertApproxEqRel(left, right, percentDelta - 1, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " !~= ", + _formatWithDecimals(right, decimals), + " (max delta: ", + _formatWithDecimals(percentDelta - 1, 16), + "%, real delta: ", + _formatWithDecimals(percentDelta, 16), + "%)" + ) + ) + ); + vm.assertApproxEqRelDecimal(left, right, percentDelta - 1, decimals); + } + } + + function testFuzzAssertApproxEqRel(int256 left, int256 right, uint256 decimals) public { + vm.assume(left < right); + vm.assume(right != 0); + uint256 delta = _getDelta(right, left); + vm.assume(delta < type(uint256).max / (10 ** 18)); + vm.assume(decimals <= maxDecimals); + + uint256 percentDelta = delta * (10 ** 18) / _abs(right); + + vm.assertApproxEqRel(left, right, percentDelta); + + if (percentDelta > 0) { + vm._expectCheatcodeRevert( + bytes( + string.concat( + errorMessage, + ": ", + vm.toString(left), + " !~= ", + vm.toString(right), + " (max delta: ", + _formatWithDecimals(percentDelta - 1, 16), + "%, real delta: ", + _formatWithDecimals(percentDelta, 16), + "%)" + ) + ) + ); + vm.assertApproxEqRel(left, right, percentDelta - 1, errorMessage); + + vm._expectCheatcodeRevert( + bytes( + string.concat( + "assertion failed: ", + _formatWithDecimals(left, decimals), + " !~= ", + _formatWithDecimals(right, decimals), + " (max delta: ", + _formatWithDecimals(percentDelta - 1, 16), + "%, real delta: ", + _formatWithDecimals(percentDelta, 16), + "%)" + ) + ) + ); + vm.assertApproxEqRelDecimal(left, right, percentDelta - 1, decimals); + } + } + + function testAssertEqNotEqArrays() public { + { + uint256[] memory arr1 = new uint256[](1); + arr1[0] = 1; + uint256[] memory arr2 = new uint256[](2); + arr2[0] = 1; + arr2[1] = 2; + + vm.assertEq(arr1, arr1); + vm.assertEq(arr2, arr2); + vm.assertNotEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes("assertion failed: [1] != [1, 2]")); + vm.assertEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes(string.concat("assertion failed: [1, 2] == [1, 2]"))); + vm.assertNotEq(arr2, arr2); + } + { + int256[] memory arr1 = new int256[](2); + int256[] memory arr2 = new int256[](1); + arr1[0] = 5; + arr2[0] = type(int256).max; + + vm.assertEq(arr1, arr1); + vm.assertEq(arr2, arr2); + vm.assertNotEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": [5, 0] != [", vm.toString(arr2[0]), "]"))); + vm.assertEq(arr1, arr2, errorMessage); + + vm._expectCheatcodeRevert(bytes(string.concat("assertion failed: [5, 0] == [5, 0]"))); + vm.assertNotEq(arr1, arr1); + } + { + bool[] memory arr1 = new bool[](2); + bool[] memory arr2 = new bool[](2); + arr1[0] = true; + arr2[1] = true; + + vm.assertEq(arr1, arr1); + vm.assertEq(arr2, arr2); + vm.assertNotEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": [true, false] != [false, true]"))); + vm.assertEq(arr1, arr2, errorMessage); + + vm._expectCheatcodeRevert(bytes(string("assertion failed: [true, false] == [true, false]"))); + vm.assertNotEq(arr1, arr1); + } + { + address[] memory arr1 = new address[](1); + address[] memory arr2 = new address[](0); + + vm.assertEq(arr1, arr1); + vm.assertEq(arr2, arr2); + vm.assertNotEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": [", vm.toString(arr1[0]), "] != []"))); + vm.assertEq(arr1, arr2, errorMessage); + + vm._expectCheatcodeRevert(bytes(string("assertion failed: [] == []"))); + vm.assertNotEq(arr2, arr2); + } + { + bytes32[] memory arr1 = new bytes32[](1); + bytes32[] memory arr2 = new bytes32[](1); + arr1[0] = bytes32(uint256(1)); + + vm.assertEq(arr1, arr1); + vm.assertEq(arr2, arr2); + vm.assertNotEq(arr1, arr2); + + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": [", vm.toString(arr1[0]), "] != [", vm.toString(arr2[0]), "]")) + ); + vm.assertEq(arr1, arr2, errorMessage); + + vm._expectCheatcodeRevert( + bytes(string.concat("assertion failed: [", vm.toString(arr2[0]), "] == [", vm.toString(arr2[0]), "]")) + ); + vm.assertNotEq(arr2, arr2); + } + { + string[] memory arr1 = new string[](1); + string[] memory arr2 = new string[](3); + + arr1[0] = "foo"; + arr2[2] = "bar"; + + vm.assertEq(arr1, arr1); + vm.assertEq(arr2, arr2); + vm.assertNotEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes("assertion failed: [foo] != [, , bar]")); + vm.assertEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": [foo] == [foo]"))); + vm.assertNotEq(arr1, arr1, errorMessage); + } + { + bytes[] memory arr1 = new bytes[](1); + bytes[] memory arr2 = new bytes[](2); + + arr1[0] = hex"1111"; + arr2[1] = hex"1234"; + + vm.assertEq(arr1, arr1); + vm.assertEq(arr2, arr2); + vm.assertNotEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes("assertion failed: [0x1111] != [0x, 0x1234]")); + vm.assertEq(arr1, arr2); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": [0x1111] == [0x1111]"))); + vm.assertNotEq(arr1, arr1, errorMessage); + } + } + + function testAssertBool() public { + vm.assertTrue(true); + vm.assertFalse(false); + + vm._expectCheatcodeRevert(bytes("assertion failed")); + vm.assertTrue(false); + + vm._expectCheatcodeRevert(bytes(errorMessage)); + vm.assertTrue(false, errorMessage); + + vm._expectCheatcodeRevert(bytes("assertion failed")); + vm.assertFalse(true); + + vm._expectCheatcodeRevert(bytes(errorMessage)); + vm.assertFalse(true, errorMessage); + } + + function testAssertApproxEqRel() public { + vm._expectCheatcodeRevert(bytes("assertion failed: overflow in delta calculation")); + vm.assertApproxEqRel(type(int256).min, type(int256).max, 0); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": overflow in delta calculation"))); + vm.assertApproxEqRel(int256(1), int256(0), 0, errorMessage); + + vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": overflow in delta calculation"))); + vm.assertApproxEqRel(uint256(0), type(uint256).max, 0, errorMessage); + + vm._expectCheatcodeRevert(bytes("assertion failed: overflow in delta calculation")); + vm.assertApproxEqRel(uint256(1), uint256(0), uint256(0)); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 08c8f570bd3eb..ed1563aa2b76a 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -25,6 +25,122 @@ interface Vm { function activeFork() external view returns (uint256 forkId); 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(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 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 assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) 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 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; + function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + function assertEq(bool left, bool right) external pure; + function assertEq(bool left, bool right, string calldata error) external pure; + function assertEq(string calldata left, string calldata right) external pure; + function assertEq(string calldata left, string calldata right, string calldata error) external pure; + function assertEq(bytes calldata left, bytes calldata right) external pure; + function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure; + function assertEq(bool[] calldata left, bool[] calldata right) external pure; + function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure; + function assertEq(uint256[] calldata left, uint256[] calldata right) external pure; + function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure; + function assertEq(int256[] calldata left, int256[] calldata right) external pure; + function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure; + function assertEq(uint256 left, uint256 right) external pure; + function assertEq(address[] calldata left, address[] calldata right) external pure; + function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure; + function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure; + function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure; + function assertEq(string[] calldata left, string[] calldata right) external pure; + function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure; + function assertEq(bytes[] calldata left, bytes[] calldata right) external pure; + function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure; + function assertEq(uint256 left, uint256 right, string calldata error) external pure; + function assertEq(int256 left, int256 right) external pure; + function assertEq(int256 left, int256 right, string calldata error) external pure; + function assertEq(address left, address right) external pure; + function assertEq(address left, address right, string calldata error) external pure; + function assertEq(bytes32 left, bytes32 right) external pure; + function assertEq(bytes32 left, bytes32 right, string calldata error) external pure; + function assertFalse(bool condition) external pure; + function assertFalse(bool condition, string calldata error) external pure; + function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure; + function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + function assertGe(uint256 left, uint256 right) external pure; + function assertGe(uint256 left, uint256 right, string calldata error) external pure; + function assertGe(int256 left, int256 right) external pure; + function assertGe(int256 left, int256 right, string calldata error) external pure; + function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure; + function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + function assertGt(uint256 left, uint256 right) external pure; + function assertGt(uint256 left, uint256 right, string calldata error) external pure; + function assertGt(int256 left, int256 right) external pure; + function assertGt(int256 left, int256 right, string calldata error) external pure; + function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure; + function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + function assertLe(uint256 left, uint256 right) external pure; + function assertLe(uint256 left, uint256 right, string calldata error) external pure; + function assertLe(int256 left, int256 right) external pure; + function assertLe(int256 left, int256 right, string calldata error) external pure; + function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure; + function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + function assertLt(uint256 left, uint256 right) external pure; + function assertLt(uint256 left, uint256 right, string calldata error) external pure; + function assertLt(int256 left, int256 right) external pure; + function assertLt(int256 left, int256 right, string calldata error) external pure; + function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure; + function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure; + function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure; + function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure; + function assertNotEq(bool left, bool right) external pure; + function assertNotEq(bool left, bool right, string calldata error) external pure; + function assertNotEq(string calldata left, string calldata right) external pure; + function assertNotEq(string calldata left, string calldata right, string calldata error) external pure; + function assertNotEq(bytes calldata left, bytes calldata right) external pure; + function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure; + function assertNotEq(bool[] calldata left, bool[] calldata right) external pure; + function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure; + function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure; + function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure; + function assertNotEq(int256[] calldata left, int256[] calldata right) external pure; + function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure; + function assertNotEq(uint256 left, uint256 right) external pure; + function assertNotEq(address[] calldata left, address[] calldata right) external pure; + function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure; + function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure; + function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure; + function assertNotEq(string[] calldata left, string[] calldata right) external pure; + function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure; + function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure; + function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure; + function assertNotEq(uint256 left, uint256 right, string calldata error) external pure; + function assertNotEq(int256 left, int256 right) external pure; + function assertNotEq(int256 left, int256 right, string calldata error) external pure; + function assertNotEq(address left, address right) external pure; + function assertNotEq(address left, address right, string calldata error) external pure; + function assertNotEq(bytes32 left, bytes32 right) external pure; + function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure; + function assertTrue(bool condition) external pure; + function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; function breakpoint(string calldata char) external; function breakpoint(string calldata char, bool value) external; From 4a1ad3658d35810a375ef0e58c45a4f67822076d Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 25 Jan 2024 15:59:56 -0400 Subject: [PATCH 0526/1963] feat(`anvil`): Core types migration (#6808) * here we go again * wip: storage * chore: migrate executor, fmt * wip * chore: roughly only signers left * feat: migrate proof, bar trie stuff * chore: onto tests * chore: passing most tests * chore: fix impersonate * chore: op tests passing * txenvelope * chore: some fixes, typed data * feat(`anvil`): remove old ethers-dependent anvil core types (#6842) * feat: remove most ethers and old anvil core types * chore: replace handles for providers constructed on actual tests * finish moving test providers * chore: switch to decode_revert * chore: replace with maybe_decode_revert * u256::decode * chore: move all of anvil but tests and block subscriptions off ethers * re-enable opt * solve nits * chore: remove more println * chore: rename to gen * chore: update alloy, cleanup * chore: fix tests * chore: rename to sign * chore: fmt * chore: cleanup * docs * chore: more cleanup * clippy/fmt * chore: remove ethers from anvil-core, rm fastrlp * chore: remove fastrlp from exceptions in deny.toml * chore: rename and cleanup * directly use type to decode * address review comments * feat: onbjerg nits * chore: fix deny check * bump alloy * chore: add to_ethers ext trait for wallets * chore: update deps, revert changed typed-data tests, set chain id as none when signing typed data --------- Co-authored-by: Oliver Nordbjerg --- Cargo.lock | 85 +- Cargo.toml | 8 +- crates/anvil/Cargo.toml | 8 +- crates/anvil/core/Cargo.toml | 4 +- crates/anvil/core/src/eth/alloy_block.rs | 271 -- crates/anvil/core/src/eth/alloy_proof.rs | 25 - crates/anvil/core/src/eth/block.rs | 530 ++-- crates/anvil/core/src/eth/mod.rs | 13 +- crates/anvil/core/src/eth/proof.rs | 49 +- crates/anvil/core/src/eth/receipt.rs | 376 --- crates/anvil/core/src/eth/serde_helpers.rs | 29 + .../anvil/core/src/eth/transaction/alloy.rs | 1071 -------- .../core/src/eth/transaction/ethers_compat.rs | 501 ---- crates/anvil/core/src/eth/transaction/mod.rs | 2324 +++++++---------- .../core/src/eth/transaction/optimism.rs | 197 +- crates/anvil/core/src/eth/trie.rs | 16 +- crates/anvil/core/src/eth/utils.rs | 59 +- crates/anvil/core/src/types.rs | 6 +- crates/anvil/src/cmd.rs | 12 +- crates/anvil/src/config.rs | 46 +- crates/anvil/src/eth/api.rs | 218 +- crates/anvil/src/eth/backend/cheats.rs | 7 +- crates/anvil/src/eth/backend/executor.rs | 109 +- crates/anvil/src/eth/backend/info.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 279 +- crates/anvil/src/eth/backend/mem/state.rs | 55 +- crates/anvil/src/eth/backend/mem/storage.rs | 27 +- crates/anvil/src/eth/backend/notifications.rs | 2 +- crates/anvil/src/eth/error.rs | 41 +- crates/anvil/src/eth/fees.rs | 25 +- crates/anvil/src/eth/mod.rs | 2 +- crates/anvil/src/eth/pool/mod.rs | 3 +- crates/anvil/src/eth/pool/transactions.rs | 11 +- crates/anvil/src/eth/sign.rs | 145 +- crates/anvil/src/eth/util.rs | 10 +- crates/anvil/src/genesis.rs | 29 +- crates/anvil/src/hardfork.rs | 12 +- crates/anvil/src/lib.rs | 40 +- crates/anvil/src/pubsub.rs | 37 +- crates/anvil/tests/it/anvil.rs | 17 +- crates/anvil/tests/it/anvil_api.rs | 42 +- crates/anvil/tests/it/api.rs | 48 +- crates/anvil/tests/it/fork.rs | 186 +- crates/anvil/tests/it/gas.rs | 11 +- crates/anvil/tests/it/ipc.rs | 6 +- crates/anvil/tests/it/logs.rs | 25 +- crates/anvil/tests/it/optimism.rs | 7 +- crates/anvil/tests/it/otterscan.rs | 90 +- crates/anvil/tests/it/proof/mod.rs | 44 +- crates/anvil/tests/it/pubsub.rs | 29 +- crates/anvil/tests/it/sign.rs | 16 +- crates/anvil/tests/it/traces.rs | 43 +- crates/anvil/tests/it/transaction.rs | 169 +- crates/anvil/tests/it/txpool.rs | 3 +- crates/anvil/tests/it/utils.rs | 16 + crates/anvil/tests/it/wsapi.rs | 9 +- crates/common/Cargo.toml | 2 + crates/common/src/types.rs | 21 + deny.toml | 3 - 59 files changed, 2328 insertions(+), 5143 deletions(-) delete mode 100644 crates/anvil/core/src/eth/alloy_block.rs delete mode 100644 crates/anvil/core/src/eth/alloy_proof.rs delete mode 100644 crates/anvil/core/src/eth/receipt.rs delete mode 100644 crates/anvil/core/src/eth/transaction/alloy.rs delete mode 100644 crates/anvil/core/src/eth/transaction/ethers_compat.rs diff --git a/Cargo.lock b/Cargo.lock index f54e2b9cd3172..125d824ffc169 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-eips", "alloy-network", @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf1d316f6375d7cff11b526e91938b199e021da118861f9d238438938e0ac7d" +checksum = "c7265ac54c88a78604cea8444addfa9dfdad08d3098f153484cb4ee66fc202cc" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b07fb0de8c985deebc60b97fc8c45fd45c101822c3241c1f389e9f9a557dd7" +checksum = "a7c5aecfe87e06da0e760840974c6e3cc19d4247be17a3172825fbbe759c8e60" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -177,9 +177,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3729132072f369bc4e8e6e070f9cf4deb3490fc9b9eea6f71f75ec19406df811" +checksum = "f4b6fb2b432ff223d513db7f908937f63c252bee0af9b82bfd25b0a5dd1eb0d8" dependencies = [ "alloy-rlp", "arbitrary", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -262,7 +262,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -279,7 +279,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -290,7 +290,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -300,11 +300,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-signer" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +dependencies = [ + "alloy-network", + "alloy-primitives", + "alloy-sol-types", + "async-trait", + "auto_impl", + "coins-bip32", + "coins-bip39", + "elliptic-curve", + "k256", + "rand 0.8.5", + "thiserror", +] + [[package]] name = "alloy-sol-macro" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5531f0a16e36c547e68c73a1638bea1f26237ee8ae785527190c4e4f9fecd2c5" +checksum = "8b0b5ab0cb07c21adf9d72e988b34e8200ce648c2bba8d009183bb1c50fb1216" dependencies = [ "alloy-json-abi", "const-hex", @@ -322,18 +340,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6958f72e4aa4acc979ea70bca59204336c0686e92b26d02d48244cf25b0dabb0" +checksum = "4dd124ec0a456ec5e9dcca5b6e8b011bc723cc410d4d9a66bf032770feaeef4b" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "783eb720b73d38f9d4c1fb9890e4db6bc8c708f7aa77d3071a19e06091ecd1c9" +checksum = "6c08f62ded7ce03513bfb60ef5cad4fff5d4f67eac6feb4df80426b7b9ffb06e" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -345,7 +363,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -361,7 +379,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -374,7 +392,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -392,7 +410,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#d68e1103bda0a0b95e1928c56091dc48e64c95de" +source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -492,10 +510,16 @@ name = "anvil" version = "0.2.0" dependencies = [ "alloy-chains", + "alloy-consensus", + "alloy-dyn-abi", + "alloy-network", "alloy-primitives", "alloy-providers", + "alloy-rlp", "alloy-rpc-trace-types", "alloy-rpc-types", + "alloy-signer", + "alloy-sol-types", "alloy-transport", "anvil-core", "anvil-rpc", @@ -548,6 +572,7 @@ name = "anvil-core" version = "0.2.0" dependencies = [ "alloy-consensus", + "alloy-dyn-abi", "alloy-eips", "alloy-network", "alloy-primitives", @@ -557,7 +582,6 @@ dependencies = [ "anvil-core", "bytes", "ethers-contract", - "ethers-core", "ethers-middleware", "ethers-providers", "foundry-common", @@ -565,7 +589,6 @@ dependencies = [ "hash-db", "hash256-std-hasher", "keccak-hasher", - "open-fastrlp", "rand 0.8.5", "reference-trie", "revm", @@ -3040,6 +3063,7 @@ dependencies = [ "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", + "alloy-signer", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3053,6 +3077,7 @@ dependencies = [ "ethers-core", "ethers-middleware", "ethers-providers", + "ethers-signers", "eyre", "foundry-block-explorers", "foundry-compilers", @@ -7226,9 +7251,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cfbd642e1748fd9e47951973abfa78f825b11fbf68af9e6b9db4c983a770166" +checksum = "63bef2e2c735acbc06874eca3a8506f02a3c4700e6e748afc92cc2e4220e8a03" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 40a424679f6d6..ab0714e681522 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -160,10 +160,10 @@ alloy-transport = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } -alloy-primitives = "0.6.0" -alloy-dyn-abi = "0.6.0" -alloy-json-abi = "0.6.0" -alloy-sol-types = "0.6.0" +alloy-primitives = "0.6.2" +alloy-dyn-abi = "0.6.2" +alloy-json-abi = "0.6.2" +alloy-sol-types = "0.6.2" syn-solidity = "0.6.0" alloy-chains = "0.1.5" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 8db3dc7250530..15e6ea9921fb8 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -20,7 +20,7 @@ vergen = { version = "8", default-features = false, features = ["build", "git", [dependencies] # foundry internal -anvil-core = { path = "core", features = ["fastrlp", "serde", "impersonated-tx"] } +anvil-core = { path = "core", features = ["serde", "impersonated-tx"] } anvil-rpc = { path = "rpc" } anvil-server = { path = "server" } foundry-common.workspace = true @@ -36,6 +36,12 @@ trie-db = "0.23" hash-db = "0.15" memory-db = "0.29" alloy-primitives = { workspace = true, features = ["serde"] } +alloy-consensus.workspace = true +alloy-network.workspace = true +alloy-rlp.workspace = true +alloy-signer = { workspace = true, features = ["eip712", "mnemonic"] } +alloy-sol-types = { workspace = true, features = ["std"] } +alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-rpc-types.workspace = true alloy-rpc-trace-types.workspace = true alloy-providers.workspace = true diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 9fb87785cbca5..5919c0d7d4177 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -21,7 +21,7 @@ alloy-rlp.workspace = true alloy-eips.workspace = true alloy-network = { workspace = true, features = ["k256"] } alloy-consensus.workspace = true -ethers-core = { workspace = true, features = ["optimism"] } +alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } # theses are not used by anvil-core, but are required by ethers, because pulled in via foundry-common ethers-contract = { workspace = true, features = ["optimism"] } ethers-providers = { workspace = true, features = ["optimism"] } @@ -30,7 +30,6 @@ ethers-middleware = { workspace = true, features = ["optimism"] } serde = { workspace = true, optional = true } serde_json.workspace = true bytes = "1.4" -open-fastrlp = { version = "0.1.4", optional = true } # trie hash-db = { version = "0.15", default-features = false } @@ -48,5 +47,4 @@ anvil-core = { path = ".", features = ["serde"] } [features] default = ["serde"] impersonated-tx = [] -fastrlp = ["dep:open-fastrlp"] serde = ["dep:serde"] diff --git a/crates/anvil/core/src/eth/alloy_block.rs b/crates/anvil/core/src/eth/alloy_block.rs deleted file mode 100644 index 44536f8862584..0000000000000 --- a/crates/anvil/core/src/eth/alloy_block.rs +++ /dev/null @@ -1,271 +0,0 @@ -use super::trie; -use alloy_consensus::Header; -use alloy_primitives::{Address, Bloom, Bytes, B256, U256}; -use alloy_rlp::{RlpDecodable, RlpEncodable}; -use foundry_common::types::ToAlloy; - -// Type alias to optionally support impersonated transactions -#[cfg(not(feature = "impersonated-tx"))] -type Transaction = crate::eth::transaction::alloy::TypedTransaction; -#[cfg(feature = "impersonated-tx")] -type Transaction = crate::eth::transaction::alloy::MaybeImpersonatedTransaction; - -/// An Ethereum Block -#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable)] -pub struct Block { - pub header: Header, - pub transactions: Vec, - pub ommers: Vec
, -} - -impl Block { - /// Creates a new block - /// - /// Note: if the `impersonate-tx` feature is enabled this will also accept - /// [MaybeImpersonatedTransaction] - pub fn new( - partial_header: PartialHeader, - transactions: impl IntoIterator, - ommers: Vec
, - ) -> Self - where - T: Into, - { - let transactions: Vec<_> = transactions.into_iter().map(Into::into).collect(); - let mut encoded_ommers: Vec = Vec::new(); - alloy_rlp::encode_list(&ommers, &mut encoded_ommers); - let ommers_hash = - B256::from_slice(alloy_primitives::utils::keccak256(encoded_ommers).as_slice()); - let transactions_root = - trie::ordered_trie_root(transactions.iter().map(|r| Bytes::from(alloy_rlp::encode(r)))) - .to_alloy(); - - Self { - header: Header { - parent_hash: partial_header.parent_hash, - beneficiary: partial_header.beneficiary, - ommers_hash, - state_root: partial_header.state_root, - transactions_root, - receipts_root: partial_header.receipts_root, - logs_bloom: partial_header.logs_bloom, - difficulty: partial_header.difficulty, - number: partial_header.number, - gas_limit: partial_header.gas_limit, - gas_used: partial_header.gas_used, - timestamp: partial_header.timestamp, - extra_data: partial_header.extra_data, - mix_hash: partial_header.mix_hash, - withdrawals_root: Some(partial_header.mix_hash), - blob_gas_used: None, - excess_blob_gas: None, - parent_beacon_block_root: None, - nonce: partial_header.nonce, - base_fee_per_gas: partial_header.base_fee, - }, - transactions, - ommers, - } - } -} - -/// Partial header definition without ommers hash and transactions root -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct PartialHeader { - pub parent_hash: B256, - pub beneficiary: Address, - pub state_root: B256, - pub receipts_root: B256, - pub logs_bloom: Bloom, - pub difficulty: U256, - pub number: u64, - pub gas_limit: u64, - pub gas_used: u64, - pub timestamp: u64, - pub extra_data: Bytes, - pub mix_hash: B256, - pub nonce: u64, - pub base_fee: Option, -} - -impl From
for PartialHeader { - fn from(value: Header) -> Self { - Self { - parent_hash: value.parent_hash, - beneficiary: value.beneficiary, - state_root: value.state_root, - receipts_root: value.receipts_root, - logs_bloom: value.logs_bloom, - difficulty: value.difficulty, - number: value.number, - gas_limit: value.gas_limit, - gas_used: value.gas_used, - timestamp: value.timestamp, - extra_data: value.extra_data, - mix_hash: value.mix_hash, - nonce: value.nonce, - base_fee: value.base_fee_per_gas, - } - } -} - -#[cfg(test)] -mod tests { - use alloy_network::Sealable; - use alloy_primitives::{ - b256, - hex::{self, FromHex}, - }; - use alloy_rlp::Decodable; - - use super::*; - use std::str::FromStr; - - #[test] - fn header_rlp_roundtrip() { - let mut header = Header { - parent_hash: Default::default(), - ommers_hash: Default::default(), - beneficiary: Default::default(), - state_root: Default::default(), - transactions_root: Default::default(), - receipts_root: Default::default(), - logs_bloom: Default::default(), - difficulty: Default::default(), - number: 124u64, - gas_limit: Default::default(), - gas_used: 1337u64, - timestamp: 0, - extra_data: Default::default(), - mix_hash: Default::default(), - nonce: 99u64, - withdrawals_root: Default::default(), - blob_gas_used: Default::default(), - excess_blob_gas: Default::default(), - parent_beacon_block_root: Default::default(), - base_fee_per_gas: None, - }; - - let encoded = alloy_rlp::encode(&header); - let decoded: Header =
::decode(&mut encoded.as_ref()).unwrap(); - assert_eq!(header, decoded); - - header.base_fee_per_gas = Some(12345u64); - - let encoded = alloy_rlp::encode(&header); - let decoded: Header =
::decode(&mut encoded.as_ref()).unwrap(); - assert_eq!(header, decoded); - } - - #[test] - fn test_encode_block_header() { - use alloy_rlp::Encodable; - - let expected = hex::decode("f901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000").unwrap(); - let mut data = vec![]; - let header = Header { - parent_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - ommers_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - beneficiary: Address::from_str("0000000000000000000000000000000000000000").unwrap(), - state_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - transactions_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - receipts_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), - difficulty: U256::from(2222), - number: 0xd05u64, - gas_limit: 0x115cu64, - gas_used: 0x15b3u64, - timestamp: 0x1a0au64, - extra_data: hex::decode("7788").unwrap().into(), - mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - withdrawals_root: None, - blob_gas_used: None, - excess_blob_gas: None, - parent_beacon_block_root: None, - nonce: 0, - base_fee_per_gas: None, - }; - - header.encode(&mut data); - assert_eq!(hex::encode(&data), hex::encode(expected)); - assert_eq!(header.length(), data.len()); - } - - #[test] - // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 - fn test_decode_block_header() { - let data = hex::decode("f901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000").unwrap(); - let expected = Header { - parent_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - ommers_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - beneficiary: Address::from_str("0000000000000000000000000000000000000000").unwrap(), - state_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - transactions_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - receipts_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: U256::from(2222), - number: 0xd05u64, - gas_limit: 0x115cu64, - gas_used: 0x15b3u64, - timestamp: 0x1a0au64, - extra_data: hex::decode("7788").unwrap().into(), - mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: 0, - withdrawals_root: None, - blob_gas_used: None, - excess_blob_gas: None, - parent_beacon_block_root: None, - base_fee_per_gas: None, - }; - let header =
::decode(&mut data.as_slice()).unwrap(); - assert_eq!(header, expected); - } - - #[test] - // Test vector from: https://github.com/ethereum/tests/blob/f47bbef4da376a49c8fc3166f09ab8a6d182f765/BlockchainTests/ValidBlocks/bcEIP1559/baseFee.json#L15-L36 - fn test_eip1559_block_header_hash() { - let expected_hash = - b256!("6a251c7c3c5dca7b42407a3752ff48f3bbca1fab7f9868371d9918daf1988d1f"); - let header = Header { - parent_hash: B256::from_str("e0a94a7a3c9617401586b1a27025d2d9671332d22d540e0af72b069170380f2a").unwrap(), - ommers_hash: B256::from_str("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347").unwrap(), - beneficiary: Address::from_str("ba5e000000000000000000000000000000000000").unwrap(), - state_root: B256::from_str("ec3c94b18b8a1cff7d60f8d258ec723312932928626b4c9355eb4ab3568ec7f7").unwrap(), - transactions_root: B256::from_str("50f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accf").unwrap(), - receipts_root: B256::from_str("29b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9").unwrap(), - logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), - difficulty: U256::from(0x020000), - number: 1u64, - gas_limit: U256::from(0x016345785d8a0000u128).to::(), - gas_used: U256::from(0x015534).to::(), - timestamp: 0x079e, - extra_data: hex::decode("42").unwrap().into(), - mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: 0, - base_fee_per_gas: Some(875), - withdrawals_root: None, - blob_gas_used: None, - excess_blob_gas: None, - parent_beacon_block_root: None, - }; - assert_eq!(header.hash(), expected_hash); - } - - #[test] - // Test vector from network - fn block_network_roundtrip() { - use alloy_rlp::Encodable; - - let data = hex::decode("f9034df90348a0fbdbd8d2d0ac5f14bd5fa90e547fe6f1d15019c724f8e7b60972d381cd5d9cf8a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794c9577e7945db22e38fc060909f2278c7746b0f9ba05017cfa3b0247e35197215ae8d610265ffebc8edca8ea66d6567eb0adecda867a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018355bb7b871fffffffffffff808462bd0e1ab9014bf90148a00000000000000000000000000000000000000000000000000000000000000000f85494319fa8f1bc4e53410e92d10d918659b16540e60a945a573efb304d04c1224cd012313e827eca5dce5d94a9c831c5a268031176ebf5f3de5051e8cba0dbfe94c9577e7945db22e38fc060909f2278c7746b0f9b808400000000f8c9b841a6946f2d16f68338cbcbd8b117374ab421128ce422467088456bceba9d70c34106128e6d4564659cf6776c08a4186063c0a05f7cffd695c10cf26a6f301b67f800b8412b782100c18c35102dc0a37ece1a152544f04ad7dc1868d18a9570f744ace60870f822f53d35e89a2ea9709ccbf1f4a25ee5003944faa845d02dde0a41d5704601b841d53caebd6c8a82456e85c2806a9e08381f959a31fb94a77e58f00e38ad97b2e0355b8519ab2122662cbe022f2a4ef7ff16adc0b2d5dcd123181ec79705116db300a063746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365880000000000000000c0c0").unwrap(); - - let block = ::decode(&mut data.as_slice()).unwrap(); - - // encode and check that it matches the original data - let mut encoded = Vec::new(); - block.encode(&mut encoded); - assert_eq!(data, encoded); - - // check that length of encoding is the same as the output of `length` - assert_eq!(block.length(), encoded.len()); - } -} diff --git a/crates/anvil/core/src/eth/alloy_proof.rs b/crates/anvil/core/src/eth/alloy_proof.rs deleted file mode 100644 index adef84ae93ef6..0000000000000 --- a/crates/anvil/core/src/eth/alloy_proof.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! Return types for `eth_getProof` - -use crate::eth::trie::KECCAK_NULL_RLP; -use alloy_primitives::{B256, U256}; -use foundry_common::types::ToAlloy; -use revm::primitives::KECCAK_EMPTY; - -#[derive(Clone, Debug, PartialEq, Eq, alloy_rlp::RlpEncodable, alloy_rlp::RlpDecodable)] -pub struct BasicAccount { - pub nonce: U256, - pub balance: U256, - pub storage_root: B256, - pub code_hash: B256, -} - -impl Default for BasicAccount { - fn default() -> Self { - BasicAccount { - balance: U256::ZERO, - nonce: U256::ZERO, - code_hash: KECCAK_EMPTY, - storage_root: KECCAK_NULL_RLP.to_alloy(), - } - } -} diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 1675abc8f22c7..c304eefa4a10a 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -1,11 +1,16 @@ -use crate::eth::{receipt::TypedReceipt, transaction::TransactionInfo, trie}; -use ethers_core::{ - types::{Address, Bloom, Bytes, H256, H64, U256}, - utils::{ - keccak256, rlp, - rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, - }, +use super::{ + transaction::{TransactionInfo, TypedReceipt}, + trie, }; +use alloy_consensus::Header; +use alloy_primitives::{Address, Bloom, Bytes, B256, U256}; +use alloy_rlp::{RlpDecodable, RlpEncodable}; + +// Type alias to optionally support impersonated transactions +#[cfg(not(feature = "impersonated-tx"))] +type Transaction = crate::eth::transaction::TypedTransaction; +#[cfg(feature = "impersonated-tx")] +type Transaction = crate::eth::transaction::MaybeImpersonatedTransaction; /// Container type that gathers all block data #[derive(Clone, Debug)] @@ -15,25 +20,14 @@ pub struct BlockInfo { pub receipts: Vec, } -// Type alias to optionally support impersonated transactions -#[cfg(not(feature = "impersonated-tx"))] -type Transaction = crate::eth::transaction::TypedTransaction; -#[cfg(feature = "impersonated-tx")] -type Transaction = crate::eth::transaction::MaybeImpersonatedTransaction; - -/// An Ethereum block -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +/// An Ethereum Block +#[derive(Clone, Debug, PartialEq, Eq, RlpEncodable, RlpDecodable)] pub struct Block { pub header: Header, - /// Note: this supports impersonated transactions pub transactions: Vec, pub ommers: Vec
, } -// == impl Block == - impl Block { /// Creates a new block /// @@ -48,285 +42,92 @@ impl Block { T: Into, { let transactions: Vec<_> = transactions.into_iter().map(Into::into).collect(); - let ommers_hash = H256::from_slice(keccak256(&rlp::encode_list(&ommers)[..]).as_slice()); + let mut encoded_ommers: Vec = Vec::new(); + alloy_rlp::encode_list(&ommers, &mut encoded_ommers); + let ommers_hash = + B256::from_slice(alloy_primitives::utils::keccak256(encoded_ommers).as_slice()); let transactions_root = - trie::ordered_trie_root(transactions.iter().map(|r| rlp::encode(r).freeze())); + trie::ordered_trie_root(transactions.iter().map(|r| Bytes::from(alloy_rlp::encode(r)))); Self { - header: Header::new(partial_header, ommers_hash, transactions_root), + header: Header { + parent_hash: partial_header.parent_hash, + beneficiary: partial_header.beneficiary, + ommers_hash, + state_root: partial_header.state_root, + transactions_root, + receipts_root: partial_header.receipts_root, + logs_bloom: partial_header.logs_bloom, + difficulty: partial_header.difficulty, + number: partial_header.number, + gas_limit: partial_header.gas_limit, + gas_used: partial_header.gas_used, + timestamp: partial_header.timestamp, + extra_data: partial_header.extra_data, + mix_hash: partial_header.mix_hash, + withdrawals_root: Some(partial_header.mix_hash), + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + nonce: partial_header.nonce, + base_fee_per_gas: partial_header.base_fee, + }, transactions, ommers, } } } -impl Encodable for Block { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(3); - s.append(&self.header); - s.append_list(&self.transactions); - s.append_list(&self.ommers); - } -} - -impl Decodable for Block { - fn decode(rlp: &Rlp) -> Result { - Ok(Self { header: rlp.val_at(0)?, transactions: rlp.list_at(1)?, ommers: rlp.list_at(2)? }) - } -} - -/// ethereum block header -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct Header { - pub parent_hash: H256, - pub ommers_hash: H256, - pub beneficiary: Address, - pub state_root: H256, - pub transactions_root: H256, - pub receipts_root: H256, - pub logs_bloom: Bloom, - pub difficulty: U256, - pub number: U256, - pub gas_limit: U256, - pub gas_used: U256, - pub timestamp: u64, - pub extra_data: Bytes, - pub mix_hash: H256, - pub nonce: H64, - /// BaseFee was added by EIP-1559 and is ignored in legacy headers. - pub base_fee_per_gas: Option, -} - -// == impl Header == - -impl Header { - pub fn new(partial_header: PartialHeader, ommers_hash: H256, transactions_root: H256) -> Self { - Self { - parent_hash: partial_header.parent_hash, - ommers_hash, - beneficiary: partial_header.beneficiary, - state_root: partial_header.state_root, - transactions_root, - receipts_root: partial_header.receipts_root, - logs_bloom: partial_header.logs_bloom, - difficulty: partial_header.difficulty, - number: partial_header.number, - gas_limit: partial_header.gas_limit, - gas_used: partial_header.gas_used, - timestamp: partial_header.timestamp, - extra_data: partial_header.extra_data, - mix_hash: partial_header.mix_hash, - nonce: partial_header.nonce, - base_fee_per_gas: partial_header.base_fee, - } - } - - pub fn hash(&self) -> H256 { - H256::from_slice(keccak256(&rlp::encode(self)).as_slice()) - } - - /// Returns the rlp length of the Header body, _not including_ trailing EIP155 fields or the - /// rlp list header - /// To get the length including the rlp list header, refer to the Encodable implementation. - #[cfg(feature = "fastrlp")] - pub(crate) fn header_payload_length(&self) -> usize { - use open_fastrlp::Encodable; - - let mut length = 0; - length += self.parent_hash.length(); - length += self.ommers_hash.length(); - length += self.beneficiary.length(); - length += self.state_root.length(); - length += self.transactions_root.length(); - length += self.receipts_root.length(); - length += self.logs_bloom.length(); - length += self.difficulty.length(); - length += self.number.length(); - length += self.gas_limit.length(); - length += self.gas_used.length(); - length += self.timestamp.length(); - length += self.extra_data.length(); - length += self.mix_hash.length(); - length += self.nonce.length(); - length += self.base_fee_per_gas.map(|fee| fee.length()).unwrap_or_default(); - length - } -} - -impl rlp::Encodable for Header { - fn rlp_append(&self, s: &mut rlp::RlpStream) { - if self.base_fee_per_gas.is_none() { - s.begin_list(15); - } else { - s.begin_list(16); - } - s.append(&self.parent_hash); - s.append(&self.ommers_hash); - s.append(&self.beneficiary); - s.append(&self.state_root); - s.append(&self.transactions_root); - s.append(&self.receipts_root); - s.append(&self.logs_bloom); - s.append(&self.difficulty); - s.append(&self.number); - s.append(&self.gas_limit); - s.append(&self.gas_used); - s.append(&self.timestamp); - s.append(&self.extra_data.as_ref()); - s.append(&self.mix_hash); - s.append(&self.nonce); - if let Some(ref base_fee) = self.base_fee_per_gas { - s.append(base_fee); - } - } -} - -impl rlp::Decodable for Header { - fn decode(rlp: &rlp::Rlp) -> Result { - let result = Header { - parent_hash: rlp.val_at(0)?, - ommers_hash: rlp.val_at(1)?, - beneficiary: rlp.val_at(2)?, - state_root: rlp.val_at(3)?, - transactions_root: rlp.val_at(4)?, - receipts_root: rlp.val_at(5)?, - logs_bloom: rlp.val_at(6)?, - difficulty: rlp.val_at(7)?, - number: rlp.val_at(8)?, - gas_limit: rlp.val_at(9)?, - gas_used: rlp.val_at(10)?, - timestamp: rlp.val_at(11)?, - extra_data: rlp.val_at::>(12)?.into(), - mix_hash: rlp.val_at(13)?, - nonce: rlp.val_at(14)?, - base_fee_per_gas: if let Ok(base_fee) = rlp.at(15) { - Some(::decode(&base_fee)?) - } else { - None - }, - }; - Ok(result) - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Encodable for Header { - fn length(&self) -> usize { - // add each of the fields' rlp encoded lengths - let mut length = 0; - length += self.header_payload_length(); - length += open_fastrlp::length_of_length(length); - - length - } - - fn encode(&self, out: &mut dyn open_fastrlp::BufMut) { - let list_header = - open_fastrlp::Header { list: true, payload_length: self.header_payload_length() }; - list_header.encode(out); - self.parent_hash.encode(out); - self.ommers_hash.encode(out); - self.beneficiary.encode(out); - self.state_root.encode(out); - self.transactions_root.encode(out); - self.receipts_root.encode(out); - self.logs_bloom.encode(out); - self.difficulty.encode(out); - self.number.encode(out); - self.gas_limit.encode(out); - self.gas_used.encode(out); - self.timestamp.encode(out); - self.extra_data.encode(out); - self.mix_hash.encode(out); - self.nonce.encode(out); - if let Some(base_fee_per_gas) = self.base_fee_per_gas { - base_fee_per_gas.encode(out); - } - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Decodable for Header { - fn decode(buf: &mut &[u8]) -> Result { - // slice out the rlp list header - let header = open_fastrlp::Header::decode(buf)?; - let start_len = buf.len(); - - Ok(Header { - parent_hash: ::decode(buf)?, - ommers_hash: ::decode(buf)?, - beneficiary:
::decode(buf)?, - state_root: ::decode(buf)?, - transactions_root: ::decode(buf)?, - receipts_root: ::decode(buf)?, - logs_bloom: ::decode(buf)?, - difficulty: ::decode(buf)?, - number: ::decode(buf)?, - gas_limit: ::decode(buf)?, - gas_used: ::decode(buf)?, - timestamp: ::decode(buf)?, - extra_data: ::decode(buf)?, - mix_hash: ::decode(buf)?, - nonce: ::decode(buf)?, - base_fee_per_gas: if start_len - header.payload_length < buf.len() { - // if there is leftover data in the payload, decode the base fee - Some(::decode(buf)?) - } else { - None - }, - }) - } -} - /// Partial header definition without ommers hash and transactions root #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct PartialHeader { - pub parent_hash: H256, + pub parent_hash: B256, pub beneficiary: Address, - pub state_root: H256, - pub receipts_root: H256, + pub state_root: B256, + pub receipts_root: B256, pub logs_bloom: Bloom, pub difficulty: U256, - pub number: U256, - pub gas_limit: U256, - pub gas_used: U256, + pub number: u64, + pub gas_limit: u64, + pub gas_used: u64, pub timestamp: u64, pub extra_data: Bytes, - pub mix_hash: H256, - pub nonce: H64, - pub base_fee: Option, + pub mix_hash: B256, + pub nonce: u64, + pub base_fee: Option, } impl From
for PartialHeader { - fn from(header: Header) -> PartialHeader { + fn from(value: Header) -> Self { Self { - parent_hash: header.parent_hash, - beneficiary: header.beneficiary, - state_root: header.state_root, - receipts_root: header.receipts_root, - logs_bloom: header.logs_bloom, - difficulty: header.difficulty, - number: header.number, - gas_limit: header.gas_limit, - gas_used: header.gas_used, - timestamp: header.timestamp, - extra_data: header.extra_data, - mix_hash: header.mix_hash, - nonce: header.nonce, - base_fee: header.base_fee_per_gas, + parent_hash: value.parent_hash, + beneficiary: value.beneficiary, + state_root: value.state_root, + receipts_root: value.receipts_root, + logs_bloom: value.logs_bloom, + difficulty: value.difficulty, + number: value.number, + gas_limit: value.gas_limit, + gas_used: value.gas_used, + timestamp: value.timestamp, + extra_data: value.extra_data, + mix_hash: value.mix_hash, + nonce: value.nonce, + base_fee: value.base_fee_per_gas, } } } #[cfg(test)] mod tests { - use super::*; - use ethers_core::{ - types::H160, - utils::{hex, hex::FromHex}, + use alloy_network::Sealable; + use alloy_primitives::{ + b256, + hex::{self, FromHex}, }; + use alloy_rlp::Decodable; + + use super::*; use std::str::FromStr; #[test] @@ -340,158 +141,133 @@ mod tests { receipts_root: Default::default(), logs_bloom: Default::default(), difficulty: Default::default(), - number: 124u64.into(), - gas_limit: Default::default(), - gas_used: 1337u64.into(), - timestamp: 0, - extra_data: Default::default(), - mix_hash: Default::default(), - nonce: 99u64.to_be_bytes().into(), - base_fee_per_gas: None, - }; - - let encoded = rlp::encode(&header); - let decoded: Header = rlp::decode(encoded.as_ref()).unwrap(); - assert_eq!(header, decoded); - - header.base_fee_per_gas = Some(12345u64.into()); - - let encoded = rlp::encode(&header); - let decoded: Header = rlp::decode(encoded.as_ref()).unwrap(); - assert_eq!(header, decoded); - } - - #[test] - #[cfg(feature = "fastrlp")] - fn header_fastrlp_roundtrip() { - let mut header = Header { - parent_hash: Default::default(), - ommers_hash: Default::default(), - beneficiary: Default::default(), - state_root: Default::default(), - transactions_root: Default::default(), - receipts_root: Default::default(), - logs_bloom: Default::default(), - difficulty: Default::default(), - number: 124u64.into(), + number: 124u64, gas_limit: Default::default(), - gas_used: 1337u64.into(), + gas_used: 1337u64, timestamp: 0, extra_data: Default::default(), mix_hash: Default::default(), - nonce: H64::from_low_u64_be(99u64), + nonce: 99u64, + withdrawals_root: Default::default(), + blob_gas_used: Default::default(), + excess_blob_gas: Default::default(), + parent_beacon_block_root: Default::default(), base_fee_per_gas: None, }; - let mut encoded = vec![]; -
::encode(&header, &mut encoded); - let decoded: Header = -
::decode(&mut encoded.as_slice()).unwrap(); + let encoded = alloy_rlp::encode(&header); + let decoded: Header = Header::decode(&mut encoded.as_ref()).unwrap(); assert_eq!(header, decoded); - header.base_fee_per_gas = Some(12345u64.into()); + header.base_fee_per_gas = Some(12345u64); - encoded.clear(); -
::encode(&header, &mut encoded); - let decoded: Header = -
::decode(&mut encoded.as_slice()).unwrap(); + let encoded = alloy_rlp::encode(&header); + let decoded: Header = Header::decode(&mut encoded.as_ref()).unwrap(); assert_eq!(header, decoded); } #[test] - #[cfg(feature = "fastrlp")] - // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 fn test_encode_block_header() { - use open_fastrlp::Encodable; + use alloy_rlp::Encodable; let expected = hex::decode("f901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000").unwrap(); let mut data = vec![]; let header = Header { - parent_hash: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - ommers_hash: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - beneficiary: H160::from_str("0000000000000000000000000000000000000000").unwrap(), - state_root: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - transactions_root: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - receipts_root: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: 0x8aeu64.into(), - number: 0xd05u64.into(), - gas_limit: 0x115cu64.into(), - gas_used: 0x15b3u64.into(), + parent_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + ommers_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + beneficiary: Address::from_str("0000000000000000000000000000000000000000").unwrap(), + state_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + transactions_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + receipts_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), + difficulty: U256::from(2222), + number: 0xd05u64, + gas_limit: 0x115cu64, + gas_used: 0x15b3u64, timestamp: 0x1a0au64, extra_data: hex::decode("7788").unwrap().into(), - mix_hash: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: H64::from_low_u64_be(0x0), + mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + withdrawals_root: None, + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + nonce: 0, base_fee_per_gas: None, }; + header.encode(&mut data); assert_eq!(hex::encode(&data), hex::encode(expected)); assert_eq!(header.length(), data.len()); } #[test] - // Test vector from: https://github.com/ethereum/tests/blob/f47bbef4da376a49c8fc3166f09ab8a6d182f765/BlockchainTests/ValidBlocks/bcEIP1559/baseFee.json#L15-L36 - fn test_eip1559_block_header_hash() { - let expected_hash = - H256::from_str("6a251c7c3c5dca7b42407a3752ff48f3bbca1fab7f9868371d9918daf1988d1f") - .unwrap(); - let header = Header { - parent_hash: H256::from_str("e0a94a7a3c9617401586b1a27025d2d9671332d22d540e0af72b069170380f2a").unwrap(), - ommers_hash: H256::from_str("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347").unwrap(), - beneficiary: H160::from_str("ba5e000000000000000000000000000000000000").unwrap(), - state_root: H256::from_str("ec3c94b18b8a1cff7d60f8d258ec723312932928626b4c9355eb4ab3568ec7f7").unwrap(), - transactions_root: H256::from_str("50f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accf").unwrap(), - receipts_root: H256::from_str("29b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9").unwrap(), - logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: 0x020000.into(), - number: 0x01.into(), - gas_limit: U256::from_str("016345785d8a0000").unwrap(), - gas_used: 0x015534.into(), - timestamp: 0x079e, - extra_data: hex::decode("42").unwrap().into(), - mix_hash: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: H64::from_low_u64_be(0x0), - base_fee_per_gas: Some(0x036b.into()), - }; - assert_eq!(header.hash(), expected_hash); - } - - #[test] - #[cfg(feature = "fastrlp")] // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 fn test_decode_block_header() { let data = hex::decode("f901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000").unwrap(); let expected = Header { - parent_hash: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - ommers_hash: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - beneficiary: H160::from_str("0000000000000000000000000000000000000000").unwrap(), - state_root: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - transactions_root: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - receipts_root: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + parent_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + ommers_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + beneficiary: Address::from_str("0000000000000000000000000000000000000000").unwrap(), + state_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + transactions_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + receipts_root: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), - difficulty: 0x8aeu64.into(), - number: 0xd05u64.into(), - gas_limit: 0x115cu64.into(), - gas_used: 0x15b3u64.into(), + difficulty: U256::from(2222), + number: 0xd05u64, + gas_limit: 0x115cu64, + gas_used: 0x15b3u64, timestamp: 0x1a0au64, extra_data: hex::decode("7788").unwrap().into(), - mix_hash: H256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: H64::from_low_u64_be(0x0), + mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + nonce: 0, + withdrawals_root: None, + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, base_fee_per_gas: None, }; - let header =
::decode(&mut data.as_slice()).unwrap(); + let header = Header::decode(&mut data.as_slice()).unwrap(); assert_eq!(header, expected); } #[test] - #[cfg(feature = "fastrlp")] + // Test vector from: https://github.com/ethereum/tests/blob/f47bbef4da376a49c8fc3166f09ab8a6d182f765/BlockchainTests/ValidBlocks/bcEIP1559/baseFee.json#L15-L36 + fn test_eip1559_block_header_hash() { + let expected_hash = + b256!("6a251c7c3c5dca7b42407a3752ff48f3bbca1fab7f9868371d9918daf1988d1f"); + let header = Header { + parent_hash: B256::from_str("e0a94a7a3c9617401586b1a27025d2d9671332d22d540e0af72b069170380f2a").unwrap(), + ommers_hash: B256::from_str("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347").unwrap(), + beneficiary: Address::from_str("ba5e000000000000000000000000000000000000").unwrap(), + state_root: B256::from_str("ec3c94b18b8a1cff7d60f8d258ec723312932928626b4c9355eb4ab3568ec7f7").unwrap(), + transactions_root: B256::from_str("50f738580ed699f0469702c7ccc63ed2e51bc034be9479b7bff4e68dee84accf").unwrap(), + receipts_root: B256::from_str("29b0562f7140574dd0d50dee8a271b22e1a0a7b78fca58f7c60370d8317ba2a9").unwrap(), + logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), + difficulty: U256::from(0x020000), + number: 1u64, + gas_limit: U256::from(0x016345785d8a0000u128).to::(), + gas_used: U256::from(0x015534).to::(), + timestamp: 0x079e, + extra_data: hex::decode("42").unwrap().into(), + mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), + nonce: 0, + base_fee_per_gas: Some(875), + withdrawals_root: None, + blob_gas_used: None, + excess_blob_gas: None, + parent_beacon_block_root: None, + }; + assert_eq!(header.hash(), expected_hash); + } + + #[test] // Test vector from network - fn block_network_fastrlp_roundtrip() { - use open_fastrlp::Encodable; + fn block_network_roundtrip() { + use alloy_rlp::Encodable; let data = hex::decode("f9034df90348a0fbdbd8d2d0ac5f14bd5fa90e547fe6f1d15019c724f8e7b60972d381cd5d9cf8a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794c9577e7945db22e38fc060909f2278c7746b0f9ba05017cfa3b0247e35197215ae8d610265ffebc8edca8ea66d6567eb0adecda867a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018355bb7b871fffffffffffff808462bd0e1ab9014bf90148a00000000000000000000000000000000000000000000000000000000000000000f85494319fa8f1bc4e53410e92d10d918659b16540e60a945a573efb304d04c1224cd012313e827eca5dce5d94a9c831c5a268031176ebf5f3de5051e8cba0dbfe94c9577e7945db22e38fc060909f2278c7746b0f9b808400000000f8c9b841a6946f2d16f68338cbcbd8b117374ab421128ce422467088456bceba9d70c34106128e6d4564659cf6776c08a4186063c0a05f7cffd695c10cf26a6f301b67f800b8412b782100c18c35102dc0a37ece1a152544f04ad7dc1868d18a9570f744ace60870f822f53d35e89a2ea9709ccbf1f4a25ee5003944faa845d02dde0a41d5704601b841d53caebd6c8a82456e85c2806a9e08381f959a31fb94a77e58f00e38ad97b2e0355b8519ab2122662cbe022f2a4ef7ff16adc0b2d5dcd123181ec79705116db300a063746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365880000000000000000c0c0").unwrap(); - let block = ::decode(&mut data.as_slice()).unwrap(); + let block = Block::decode(&mut data.as_slice()).unwrap(); // encode and check that it matches the original data let mut encoded = Vec::new(); diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 799c6ff6b3591..3fd0c6ed889c1 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -1,5 +1,5 @@ use crate::{ - eth::subscription::SubscriptionId, + eth::{subscription::SubscriptionId, transaction::EthTransactionRequest}, types::{EvmMineOptions, Forking, Index}, }; use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256}; @@ -9,13 +9,9 @@ use alloy_rpc_types::{ state::StateOverride, BlockId, BlockNumberOrTag as BlockNumber, CallRequest, Filter, }; -use ethers_core::types::transaction::eip712::TypedData; -pub mod alloy_block; -pub mod alloy_proof; pub mod block; pub mod proof; -pub mod receipt; pub mod subscription; pub mod transaction; pub mod trie; @@ -26,7 +22,6 @@ pub mod serde_helpers; #[cfg(feature = "serde")] use self::serde_helpers::*; -use self::transaction::EthTransactionRequest; #[cfg(feature = "serde")] use foundry_common::serde_helpers::{ @@ -42,7 +37,7 @@ pub struct Params { } /// Represents ethereum JSON-RPC API -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "method", content = "params"))] pub enum EthRequest { @@ -159,7 +154,7 @@ pub enum EthRequest { /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md), and includes full support of arrays and recursive data structures. #[cfg_attr(feature = "serde", serde(rename = "eth_signTypedData_v4"))] - EthSignTypedDataV4(Address, TypedData), + EthSignTypedDataV4(Address, alloy_dyn_abi::TypedData), #[cfg_attr(feature = "serde", serde(rename = "eth_sendTransaction", with = "sequence"))] EthSendTransaction(Box), @@ -737,7 +732,7 @@ pub enum EthPubSub { } /// Container type for either a request or a pub sub -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[cfg_attr(feature = "serde", serde(untagged))] pub enum EthRpcCall { diff --git a/crates/anvil/core/src/eth/proof.rs b/crates/anvil/core/src/eth/proof.rs index 1fd22a4cae5ce..ba2357bffd578 100644 --- a/crates/anvil/core/src/eth/proof.rs +++ b/crates/anvil/core/src/eth/proof.rs @@ -1,59 +1,24 @@ //! Return types for `eth_getProof` use crate::eth::trie::KECCAK_NULL_RLP; -use ethers_core::{ - types::{H256, U256}, - utils::rlp, -}; -use foundry_common::types::ToEthers; +use alloy_primitives::{B256, U256}; use revm::primitives::KECCAK_EMPTY; -// reexport for convenience -pub use ethers_core::types::{EIP1186ProofResponse as AccountProof, StorageProof}; - -/// Basic account type. -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] +#[derive(Clone, Debug, PartialEq, Eq, alloy_rlp::RlpEncodable, alloy_rlp::RlpDecodable)] pub struct BasicAccount { - /// Nonce of the account. pub nonce: U256, - /// Balance of the account. pub balance: U256, - /// Storage root of the account. - pub storage_root: H256, - /// Code hash of the account. - pub code_hash: H256, + pub storage_root: B256, + pub code_hash: B256, } impl Default for BasicAccount { fn default() -> Self { BasicAccount { - balance: 0.into(), - nonce: 0.into(), - code_hash: KECCAK_EMPTY.to_ethers(), + balance: U256::ZERO, + nonce: U256::ZERO, + code_hash: KECCAK_EMPTY, storage_root: KECCAK_NULL_RLP, } } } - -impl rlp::Encodable for BasicAccount { - fn rlp_append(&self, stream: &mut rlp::RlpStream) { - stream.begin_list(4); - stream.append(&self.nonce); - stream.append(&self.balance); - stream.append(&self.storage_root); - stream.append(&self.code_hash); - } -} - -impl rlp::Decodable for BasicAccount { - fn decode(rlp: &rlp::Rlp) -> Result { - let result = BasicAccount { - nonce: rlp.val_at(0)?, - balance: rlp.val_at(1)?, - storage_root: rlp.val_at(2)?, - code_hash: rlp.val_at(3)?, - }; - Ok(result) - } -} diff --git a/crates/anvil/core/src/eth/receipt.rs b/crates/anvil/core/src/eth/receipt.rs deleted file mode 100644 index c651124878a73..0000000000000 --- a/crates/anvil/core/src/eth/receipt.rs +++ /dev/null @@ -1,376 +0,0 @@ -use crate::eth::utils::enveloped; -use ethers_core::{ - types::{Address, Bloom, Bytes, H256, U256}, - utils::{ - rlp, - rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, - }, -}; -use foundry_common::types::{ToAlloy, ToEthers}; - -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Log { - pub address: Address, - pub topics: Vec, - pub data: Bytes, -} - -impl From for Log { - fn from(log: revm::primitives::Log) -> Self { - let revm::primitives::Log { address, topics, data } = log; - Log { - address: address.to_ethers(), - topics: topics.into_iter().map(|h| h.to_ethers()).collect(), - data: ethers_core::types::Bytes(data.0), - } - } -} - -impl From for revm::primitives::Log { - fn from(log: Log) -> Self { - let Log { address, topics, data } = log; - revm::primitives::Log { - address: address.to_alloy(), - topics: topics.into_iter().map(|t| t.to_alloy()).collect(), - data: alloy_primitives::Bytes(data.0), - } - } -} - -impl Encodable for Log { - fn rlp_append(&self, stream: &mut rlp::RlpStream) { - stream.begin_list(3); - stream.append(&self.address); - stream.append_list(&self.topics); - stream.append(&self.data.as_ref()); - } -} - -impl Decodable for Log { - fn decode(rlp: &Rlp) -> Result { - let result = Log { - address: rlp.val_at(0)?, - topics: rlp.list_at(1)?, - data: rlp.val_at::>(2)?.into(), - }; - Ok(result) - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EIP658Receipt { - pub status_code: u8, - pub gas_used: U256, - pub logs_bloom: Bloom, - pub logs: Vec, -} - -impl Encodable for EIP658Receipt { - fn rlp_append(&self, stream: &mut RlpStream) { - stream.begin_list(4); - stream.append(&self.status_code); - stream.append(&self.gas_used); - stream.append(&self.logs_bloom); - stream.append_list(&self.logs); - } -} - -impl Decodable for EIP658Receipt { - fn decode(rlp: &Rlp) -> Result { - let result = EIP658Receipt { - status_code: rlp.val_at(0)?, - gas_used: rlp.val_at(1)?, - logs_bloom: rlp.val_at(2)?, - logs: rlp.list_at(3)?, - }; - Ok(result) - } -} - -// same underlying data structure -pub type EIP2930Receipt = EIP658Receipt; -pub type EIP1559Receipt = EIP658Receipt; -pub type DepositReceipt = EIP658Receipt; - -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TypedReceipt { - /// Legacy receipt - Legacy(EIP658Receipt), - /// EIP-2930 receipt - EIP2930(EIP2930Receipt), - /// EIP-1559 receipt - EIP1559(EIP1559Receipt), - /// op-stack deposit receipt - Deposit(DepositReceipt), -} - -// == impl TypedReceipt == - -impl TypedReceipt { - /// Returns the gas used by the transactions - pub fn gas_used(&self) -> U256 { - match self { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::Deposit(r) => r.gas_used, - } - } - - /// Returns the gas used by the transactions - pub fn logs_bloom(&self) -> &Bloom { - match self { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::Deposit(r) => &r.logs_bloom, - } - } -} - -impl Encodable for TypedReceipt { - fn rlp_append(&self, s: &mut RlpStream) { - match self { - TypedReceipt::Legacy(r) => r.rlp_append(s), - TypedReceipt::EIP2930(r) => enveloped(1, r, s), - TypedReceipt::EIP1559(r) => enveloped(2, r, s), - TypedReceipt::Deposit(r) => enveloped(0x7E, r, s), - } - } -} - -impl Decodable for TypedReceipt { - fn decode(rlp: &Rlp) -> Result { - let slice = rlp.data()?; - - let first = *slice.first().ok_or(DecoderError::Custom("empty receipt"))?; - - if rlp.is_list() { - return Ok(TypedReceipt::Legacy(Decodable::decode(rlp)?)) - } - - let s = slice.get(1..).ok_or(DecoderError::Custom("no receipt content"))?; - - if first == 0x01 { - return rlp::decode(s).map(TypedReceipt::EIP2930) - } - - if first == 0x02 { - return rlp::decode(s).map(TypedReceipt::EIP1559) - } - - if first == 0x7E { - return rlp::decode(s).map(TypedReceipt::Deposit) - } - - Err(DecoderError::Custom("unknown receipt type")) - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Encodable for TypedReceipt { - fn length(&self) -> usize { - match self { - TypedReceipt::Legacy(r) => r.length(), - receipt => { - let payload_len = match receipt { - TypedReceipt::EIP2930(r) => r.length() + 1, - TypedReceipt::EIP1559(r) => r.length() + 1, - TypedReceipt::Deposit(r) => r.length() + 1, - _ => unreachable!("receipt already matched"), - }; - - // we include a string header for typed receipts, so include the length here - payload_len + open_fastrlp::length_of_length(payload_len) - } - } - } - fn encode(&self, out: &mut dyn open_fastrlp::BufMut) { - use open_fastrlp::Header; - - match self { - TypedReceipt::Legacy(r) => r.encode(out), - receipt => { - let payload_len = match receipt { - TypedReceipt::EIP2930(r) => r.length() + 1, - TypedReceipt::EIP1559(r) => r.length() + 1, - TypedReceipt::Deposit(r) => r.length() + 1, - _ => unreachable!("receipt already matched"), - }; - - match receipt { - TypedReceipt::EIP2930(r) => { - let receipt_string_header = - Header { list: false, payload_length: payload_len }; - - receipt_string_header.encode(out); - out.put_u8(0x01); - r.encode(out); - } - TypedReceipt::EIP1559(r) => { - let receipt_string_header = - Header { list: false, payload_length: payload_len }; - - receipt_string_header.encode(out); - out.put_u8(0x02); - r.encode(out); - } - TypedReceipt::Deposit(r) => { - let receipt_string_header = - Header { list: false, payload_length: payload_len }; - - receipt_string_header.encode(out); - out.put_u8(0x7E); - r.encode(out); - } - _ => unreachable!("receipt already matched"), - } - } - } - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Decodable for TypedReceipt { - fn decode(buf: &mut &[u8]) -> Result { - use bytes::Buf; - use open_fastrlp::Header; - use std::cmp::Ordering; - - // a receipt is either encoded as a string (non legacy) or a list (legacy). - // We should not consume the buffer if we are decoding a legacy receipt, so let's - // check if the first byte is between 0x80 and 0xbf. - let rlp_type = *buf - .first() - .ok_or(open_fastrlp::DecodeError::Custom("cannot decode a receipt from empty bytes"))?; - - match rlp_type.cmp(&open_fastrlp::EMPTY_LIST_CODE) { - Ordering::Less => { - // strip out the string header - let _header = Header::decode(buf)?; - let receipt_type = *buf.first().ok_or(open_fastrlp::DecodeError::Custom( - "typed receipt cannot be decoded from an empty slice", - ))?; - if receipt_type == 0x01 { - buf.advance(1); - ::decode(buf) - .map(TypedReceipt::EIP2930) - } else if receipt_type == 0x02 { - buf.advance(1); - ::decode(buf) - .map(TypedReceipt::EIP1559) - } else if receipt_type == 0x7E { - buf.advance(1); - ::decode(buf) - .map(TypedReceipt::Deposit) - } else { - Err(open_fastrlp::DecodeError::Custom("invalid receipt type")) - } - } - Ordering::Equal => Err(open_fastrlp::DecodeError::Custom( - "an empty list is not a valid receipt encoding", - )), - Ordering::Greater => { - ::decode(buf).map(TypedReceipt::Legacy) - } - } - } -} - -impl From for EIP658Receipt { - fn from(v3: TypedReceipt) -> Self { - match v3 { - TypedReceipt::Legacy(receipt) => receipt, - TypedReceipt::EIP2930(receipt) => receipt, - TypedReceipt::EIP1559(receipt) => receipt, - TypedReceipt::Deposit(receipt) => receipt, - } - } -} - -#[cfg(test)] -mod tests { - #[test] - #[cfg(feature = "fastrlp")] - // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 - fn encode_legacy_receipt() { - use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt}; - use ethers_core::{ - types::{Bytes, H160, H256}, - utils::hex, - }; - use open_fastrlp::Encodable; - use std::str::FromStr; - - let expected = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); - - let mut data = vec![]; - let receipt = TypedReceipt::Legacy(EIP658Receipt { - logs_bloom: [0; 256].into(), - gas_used: 0x1u64.into(), - logs: vec![Log { - address: H160::from_str("0000000000000000000000000000000000000011").unwrap(), - topics: vec![ - H256::from_str( - "000000000000000000000000000000000000000000000000000000000000dead", - ) - .unwrap(), - H256::from_str( - "000000000000000000000000000000000000000000000000000000000000beef", - ) - .unwrap(), - ], - data: Bytes::from_str("0100ff").unwrap(), - }], - status_code: 0, - }); - receipt.encode(&mut data); - - // check that the rlp length equals the length of the expected rlp - assert_eq!(receipt.length(), expected.len()); - assert_eq!(data, expected); - } - - #[test] - #[cfg(feature = "fastrlp")] - // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 - fn decode_legacy_receipt() { - use crate::eth::receipt::{EIP658Receipt, Log, TypedReceipt}; - use ethers_core::{ - types::{Bytes, H160, H256}, - utils::hex, - }; - use open_fastrlp::Decodable; - use std::str::FromStr; - - let data = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); - - let expected = TypedReceipt::Legacy(EIP658Receipt { - logs_bloom: [0; 256].into(), - gas_used: 0x1u64.into(), - logs: vec![Log { - address: H160::from_str("0000000000000000000000000000000000000011").unwrap(), - topics: vec![ - H256::from_str( - "000000000000000000000000000000000000000000000000000000000000dead", - ) - .unwrap(), - H256::from_str( - "000000000000000000000000000000000000000000000000000000000000beef", - ) - .unwrap(), - ], - data: Bytes::from_str("0100ff").unwrap(), - }], - status_code: 0, - }); - - let receipt = TypedReceipt::decode(&mut &data[..]).unwrap(); - assert_eq!(receipt, expected); - } -} diff --git a/crates/anvil/core/src/eth/serde_helpers.rs b/crates/anvil/core/src/eth/serde_helpers.rs index f7d5bd46dba2e..311b3a9f27e80 100644 --- a/crates/anvil/core/src/eth/serde_helpers.rs +++ b/crates/anvil/core/src/eth/serde_helpers.rs @@ -33,6 +33,35 @@ pub mod sequence { } } +pub mod numeric { + use alloy_primitives::U256; + use serde::{Deserialize, Deserializer}; + /// Supports parsing u64 + /// + /// See + pub fn deserialize_stringified_u64_opt<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + if let Some(num) = Option::::deserialize(deserializer)? { + num.try_into().map(Some).map_err(serde::de::Error::custom) + } else { + Ok(None) + } + } + + /// Supports parsing u64 + /// + /// See + pub fn deserialize_stringified_u64<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let num = U256::deserialize(deserializer)?; + num.try_into().map_err(serde::de::Error::custom) + } +} + /// A module that deserializes `[]` optionally pub mod empty_params { use serde::{Deserialize, Deserializer}; diff --git a/crates/anvil/core/src/eth/transaction/alloy.rs b/crates/anvil/core/src/eth/transaction/alloy.rs deleted file mode 100644 index 1c3ba1641aa39..0000000000000 --- a/crates/anvil/core/src/eth/transaction/alloy.rs +++ /dev/null @@ -1,1071 +0,0 @@ -use crate::eth::{ - transaction::optimism::{DepositTransaction, DepositTransactionRequest}, - utils::eip_to_revm_access_list, -}; -use alloy_consensus::{ReceiptWithBloom, TxEip1559, TxEip2930, TxLegacy}; -use alloy_network::{Signed, Transaction, TxKind}; -use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, B256, U256}; -use alloy_rlp::{Decodable, Encodable}; -use alloy_rpc_types::{request::TransactionRequest, AccessList, CallRequest}; -use foundry_evm::traces::CallTraceNode; -use revm::{ - interpreter::InstructionResult, - primitives::{CreateScheme, OptimismFields, TransactTo, TxEnv}, -}; -use std::ops::Deref; - -/// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC -#[cfg(feature = "impersonated-tx")] -pub fn impersonated_signature() -> Signature { - Signature::from_scalars_and_parity(B256::ZERO, B256::ZERO, false).unwrap() -} - -pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { - let TransactionRequest { - from, - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - gas, - value, - data, - nonce, - mut access_list, - transaction_type, - other, - .. - } = tx; - let transaction_type = transaction_type.map(|id| id.to::()); - - // Special case: OP-stack deposit tx - if transaction_type == Some(126) { - return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { - from: from.unwrap_or_default(), - source_hash: other.get_deserialized::("sourceHash")?.ok()?, - kind: TxKind::Create, - mint: other.get_deserialized::("mint")?.ok()?, - value: value.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - is_system_tx: other.get_deserialized::("isSystemTx")?.ok()?, - input: data.unwrap_or_default(), - })) - } - - match ( - transaction_type, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - access_list.take(), - ) { - // legacy transaction - (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { - Some(TypedTransactionRequest::Legacy(TxLegacy { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: data.unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: None, - })) - } - // EIP2930 - (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { - Some(TypedTransactionRequest::EIP2930(TxEip2930 { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: data.unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: 0, - access_list: to_eip_access_list(access_list.unwrap_or_default()), - })) - } - // EIP1559 - (Some(2), None, _, _, _) | - (None, None, Some(_), _, _) | - (None, None, _, Some(_), _) | - (None, None, None, None, None) => { - // Empty fields fall back to the canonical transaction schema. - Some(TypedTransactionRequest::EIP1559(TxEip1559 { - nonce: nonce.unwrap_or_default().to::(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: data.unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: 0, - access_list: to_eip_access_list(access_list.unwrap_or_default()), - })) - } - _ => None, - } -} - -pub fn call_request_to_typed(tx: CallRequest) -> Option { - let CallRequest { - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - gas, - value, - input, - chain_id, - nonce, - mut access_list, - transaction_type, - .. - } = tx; - let chain_id = chain_id.map(|id| id.to::()); - let transaction_type = transaction_type.map(|id| id.to::()); - - match ( - transaction_type, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - access_list.take(), - ) { - // legacy transaction - (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { - Some(TypedTransactionRequest::Legacy(TxLegacy { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id, - })) - } - // EIP2930 - (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { - Some(TypedTransactionRequest::EIP2930(TxEip2930 { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: chain_id.unwrap_or_default(), - access_list: to_eip_access_list(access_list.unwrap_or_default()), - })) - } - // EIP1559 - (Some(2), None, _, _, _) | - (None, None, Some(_), _, _) | - (None, None, _, Some(_), _) | - (None, None, None, None, None) => { - // Empty fields fall back to the canonical transaction schema. - Some(TypedTransactionRequest::EIP1559(TxEip1559 { - nonce: nonce.unwrap_or_default().to::(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: chain_id.unwrap_or_default(), - access_list: to_eip_access_list(access_list.unwrap_or_default()), - })) - } - _ => None, - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum TypedTransactionRequest { - Legacy(TxLegacy), - EIP2930(TxEip2930), - EIP1559(TxEip1559), - Deposit(DepositTransactionRequest), -} - -/// A wrapper for [TypedTransaction] that allows impersonating accounts. -/// -/// This is a helper that carries the `impersonated` sender so that the right hash -/// [TypedTransaction::impersonated_hash] can be created. -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct MaybeImpersonatedTransaction { - pub transaction: TypedTransaction, - pub impersonated_sender: Option
, -} - -impl MaybeImpersonatedTransaction { - /// Creates a new wrapper for the given transaction - pub fn new(transaction: TypedTransaction) -> Self { - Self { transaction, impersonated_sender: None } - } - - /// Creates a new impersonated transaction wrapper using the given sender - pub fn impersonated(transaction: TypedTransaction, impersonated_sender: Address) -> Self { - Self { transaction, impersonated_sender: Some(impersonated_sender) } - } - - /// Recovers the Ethereum address which was used to sign the transaction. - /// - /// Note: this is feature gated so it does not conflict with the `Deref`ed - /// [TypedTransaction::recover] function by default. - #[cfg(feature = "impersonated-tx")] - pub fn recover(&self) -> Result { - if let Some(sender) = self.impersonated_sender { - return Ok(sender) - } - self.transaction.recover() - } - - /// Returns the hash of the transaction - /// - /// Note: this is feature gated so it does not conflict with the `Deref`ed - /// [TypedTransaction::hash] function by default. - #[cfg(feature = "impersonated-tx")] - pub fn hash(&self) -> B256 { - if self.transaction.is_impersonated() { - if let Some(sender) = self.impersonated_sender { - return self.transaction.impersonated_hash(sender) - } - } - self.transaction.hash() - } -} - -impl Encodable for MaybeImpersonatedTransaction { - fn encode(&self, out: &mut dyn bytes::BufMut) { - self.transaction.encode(out) - } -} - -impl From for TypedTransaction { - fn from(value: MaybeImpersonatedTransaction) -> Self { - value.transaction - } -} - -impl From for MaybeImpersonatedTransaction { - fn from(value: TypedTransaction) -> Self { - MaybeImpersonatedTransaction::new(value) - } -} - -impl Decodable for MaybeImpersonatedTransaction { - fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - TypedTransaction::decode(buf).map(MaybeImpersonatedTransaction::new) - } -} - -impl AsRef for MaybeImpersonatedTransaction { - fn as_ref(&self) -> &TypedTransaction { - &self.transaction - } -} - -impl Deref for MaybeImpersonatedTransaction { - type Target = TypedTransaction; - - fn deref(&self) -> &Self::Target { - &self.transaction - } -} - -/// Queued transaction -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct PendingTransaction { - /// The actual transaction - pub transaction: MaybeImpersonatedTransaction, - /// the recovered sender of this transaction - sender: Address, - /// hash of `transaction`, so it can easily be reused with encoding and hashing agan - hash: TxHash, -} - -impl PendingTransaction { - pub fn new(transaction: TypedTransaction) -> Result { - let sender = transaction.recover()?; - let hash = transaction.hash(); - Ok(Self { transaction: MaybeImpersonatedTransaction::new(transaction), sender, hash }) - } - - #[cfg(feature = "impersonated-tx")] - pub fn with_impersonated(transaction: TypedTransaction, sender: Address) -> Self { - let hash = transaction.impersonated_hash(sender); - Self { - transaction: MaybeImpersonatedTransaction::impersonated(transaction, sender), - sender, - hash, - } - } - - pub fn nonce(&self) -> U256 { - self.transaction.nonce() - } - - pub fn hash(&self) -> &TxHash { - &self.hash - } - - pub fn sender(&self) -> &Address { - &self.sender - } - - /// Converts the [PendingTransaction] into the [TxEnv] context that [`revm`](foundry_evm) - /// expects. - pub fn to_revm_tx_env(&self) -> TxEnv { - fn transact_to(kind: &TxKind) -> TransactTo { - match kind { - TxKind::Call(c) => TransactTo::Call(*c), - TxKind::Create => TransactTo::Create(CreateScheme::Create), - } - } - - let caller = *self.sender(); - match &self.transaction.transaction { - TypedTransaction::Legacy(tx) => { - let chain_id = tx.chain_id(); - let TxLegacy { nonce, gas_price, gas_limit, value, to, input, .. } = tx.tx(); - TxEnv { - caller, - transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id, - nonce: Some(*nonce), - value: (*value), - gas_price: U256::from(*gas_price), - gas_priority_fee: None, - gas_limit: *gas_limit, - access_list: vec![], - ..Default::default() - } - } - TypedTransaction::EIP2930(tx) => { - let TxEip2930 { - chain_id, - nonce, - gas_price, - gas_limit, - to, - value, - input, - access_list, - .. - } = tx.tx(); - TxEnv { - caller, - transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id: Some(*chain_id), - nonce: Some(*nonce), - value: *value, - gas_price: U256::from(*gas_price), - gas_priority_fee: None, - gas_limit: *gas_limit, - access_list: eip_to_revm_access_list(access_list.0.clone()), - ..Default::default() - } - } - TypedTransaction::EIP1559(tx) => { - let TxEip1559 { - chain_id, - nonce, - max_priority_fee_per_gas, - max_fee_per_gas, - gas_limit, - to, - value, - input, - access_list, - .. - } = tx.tx(); - TxEnv { - caller, - transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id: Some(*chain_id), - nonce: Some(*nonce), - value: *value, - gas_price: U256::from(*max_fee_per_gas), - gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), - gas_limit: *gas_limit, - access_list: eip_to_revm_access_list(access_list.0.clone()), - ..Default::default() - } - } - TypedTransaction::Deposit(tx) => { - let chain_id = tx.chain_id(); - let DepositTransaction { - nonce, - source_hash, - gas_limit, - value, - kind, - mint, - input, - is_system_tx, - .. - } = tx; - TxEnv { - caller, - transact_to: transact_to(kind), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id, - nonce: Some(nonce.to::()), - value: *value, - gas_price: U256::ZERO, - gas_priority_fee: None, - gas_limit: gas_limit.to::(), - access_list: vec![], - optimism: OptimismFields { - source_hash: Some(*source_hash), - mint: Some(mint.to::()), - is_system_transaction: Some(*is_system_tx), - enveloped_tx: None, - }, - ..Default::default() - } - } - } - } -} - -/// Container type for signed, typed transactions. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum TypedTransaction { - /// Legacy transaction type - Legacy(Signed), - /// EIP-2930 transaction - EIP2930(Signed), - /// EIP-1559 transaction - EIP1559(Signed), - /// op-stack deposit transaction - Deposit(DepositTransaction), -} - -impl TypedTransaction { - /// Returns true if the transaction uses dynamic fees: EIP1559 - pub fn is_dynamic_fee(&self) -> bool { - matches!(self, TypedTransaction::EIP1559(_)) - } - - pub fn gas_price(&self) -> U256 { - U256::from(match self { - TypedTransaction::Legacy(tx) => tx.gas_price, - TypedTransaction::EIP2930(tx) => tx.gas_price, - TypedTransaction::EIP1559(tx) => tx.max_fee_per_gas, - TypedTransaction::Deposit(_) => 0, - }) - } - - pub fn gas_limit(&self) -> U256 { - U256::from(match self { - TypedTransaction::Legacy(tx) => tx.gas_limit, - TypedTransaction::EIP2930(tx) => tx.gas_limit, - TypedTransaction::EIP1559(tx) => tx.gas_limit, - TypedTransaction::Deposit(tx) => tx.gas_limit.to::(), - }) - } - - pub fn value(&self) -> U256 { - U256::from(match self { - TypedTransaction::Legacy(tx) => tx.value, - TypedTransaction::EIP2930(tx) => tx.value, - TypedTransaction::EIP1559(tx) => tx.value, - TypedTransaction::Deposit(tx) => tx.value, - }) - } - - pub fn data(&self) -> &Bytes { - match self { - TypedTransaction::Legacy(tx) => &tx.input, - TypedTransaction::EIP2930(tx) => &tx.input, - TypedTransaction::EIP1559(tx) => &tx.input, - TypedTransaction::Deposit(tx) => &tx.input, - } - } - - /// Returns the transaction type - pub fn r#type(&self) -> Option { - match self { - TypedTransaction::Legacy(_) => None, - TypedTransaction::EIP2930(_) => Some(1), - TypedTransaction::EIP1559(_) => Some(2), - TypedTransaction::Deposit(_) => Some(0x7E), - } - } - - /// Max cost of the transaction - pub fn max_cost(&self) -> U256 { - self.gas_limit().saturating_mul(self.gas_price()) - } - - /// Returns a helper type that contains commonly used values as fields - pub fn essentials(&self) -> TransactionEssentials { - match self { - TypedTransaction::Legacy(t) => TransactionEssentials { - kind: t.tx().to, - input: t.input.clone(), - nonce: U256::from(t.tx().nonce), - gas_limit: U256::from(t.tx().gas_limit), - gas_price: Some(U256::from(t.tx().gas_price)), - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - value: t.value, - chain_id: t.tx().chain_id, - access_list: Default::default(), - }, - TypedTransaction::EIP2930(t) => TransactionEssentials { - kind: t.tx().to, - input: t.input.clone(), - nonce: U256::from(t.tx().nonce), - gas_limit: U256::from(t.tx().gas_limit), - gas_price: Some(U256::from(t.tx().gas_price)), - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - value: t.value, - chain_id: Some(t.chain_id), - access_list: to_alloy_access_list(t.access_list.clone()), - }, - TypedTransaction::EIP1559(t) => TransactionEssentials { - kind: t.to, - input: t.input.clone(), - nonce: U256::from(t.nonce), - gas_limit: U256::from(t.gas_limit), - gas_price: None, - max_fee_per_gas: Some(U256::from(t.max_fee_per_gas)), - max_priority_fee_per_gas: Some(U256::from(t.max_priority_fee_per_gas)), - value: t.value, - chain_id: Some(t.chain_id), - access_list: to_alloy_access_list(t.access_list.clone()), - }, - TypedTransaction::Deposit(t) => TransactionEssentials { - kind: t.kind, - input: t.input.clone(), - nonce: t.nonce, - gas_limit: t.gas_limit, - gas_price: Some(U256::from(0)), - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - value: t.value, - chain_id: t.chain_id(), - access_list: Default::default(), - }, - } - } - - pub fn nonce(&self) -> U256 { - match self { - TypedTransaction::Legacy(t) => U256::from(t.nonce), - TypedTransaction::EIP2930(t) => U256::from(t.nonce), - TypedTransaction::EIP1559(t) => U256::from(t.nonce), - TypedTransaction::Deposit(t) => U256::from(t.nonce), - } - } - - pub fn chain_id(&self) -> Option { - match self { - TypedTransaction::Legacy(t) => t.chain_id, - TypedTransaction::EIP2930(t) => Some(t.chain_id), - TypedTransaction::EIP1559(t) => Some(t.chain_id), - TypedTransaction::Deposit(t) => t.chain_id(), - } - } - - pub fn as_legacy(&self) -> Option<&Signed> { - match self { - TypedTransaction::Legacy(tx) => Some(tx), - _ => None, - } - } - - /// Returns true whether this tx is a legacy transaction - pub fn is_legacy(&self) -> bool { - matches!(self, TypedTransaction::Legacy(_)) - } - - /// Returns true whether this tx is a EIP1559 transaction - pub fn is_eip1559(&self) -> bool { - matches!(self, TypedTransaction::EIP1559(_)) - } - - /// Returns the hash of the transaction. - /// - /// Note: If this transaction has the Impersonated signature then this returns a modified unique - /// hash. This allows us to treat impersonated transactions as unique. - pub fn hash(&self) -> B256 { - match self { - TypedTransaction::Legacy(t) => *t.hash(), - TypedTransaction::EIP2930(t) => *t.hash(), - TypedTransaction::EIP1559(t) => *t.hash(), - TypedTransaction::Deposit(t) => t.hash(), - } - } - - /// Returns true if the transaction was impersonated (using the impersonate Signature) - #[cfg(feature = "impersonated-tx")] - pub fn is_impersonated(&self) -> bool { - self.signature() == impersonated_signature() - } - - /// Returns the hash if the transaction is impersonated (using a fake signature) - /// - /// This appends the `address` before hashing it - #[cfg(feature = "impersonated-tx")] - pub fn impersonated_hash(&self, sender: Address) -> B256 { - let mut buffer = Vec::::new(); - Encodable::encode(self, &mut buffer); - buffer.extend_from_slice(sender.as_ref()); - B256::from_slice(alloy_primitives::utils::keccak256(&buffer).as_slice()) - } - - /// Recovers the Ethereum address which was used to sign the transaction. - pub fn recover(&self) -> Result { - match self { - TypedTransaction::Legacy(tx) => tx.recover_signer(), - TypedTransaction::EIP2930(tx) => tx.recover_signer(), - TypedTransaction::EIP1559(tx) => tx.recover_signer(), - TypedTransaction::Deposit(tx) => tx.recover(), - } - } - - /// Returns what kind of transaction this is - pub fn kind(&self) -> &TxKind { - match self { - TypedTransaction::Legacy(tx) => &tx.to, - TypedTransaction::EIP2930(tx) => &tx.to, - TypedTransaction::EIP1559(tx) => &tx.to, - TypedTransaction::Deposit(tx) => &tx.kind, - } - } - - /// Returns the callee if this transaction is a call - pub fn to(&self) -> Option
{ - self.kind().to() - } - - /// Returns the Signature of the transaction - pub fn signature(&self) -> Signature { - match self { - TypedTransaction::Legacy(tx) => *tx.signature(), - TypedTransaction::EIP2930(tx) => *tx.signature(), - TypedTransaction::EIP1559(tx) => *tx.signature(), - TypedTransaction::Deposit(_) => { - Signature::from_scalars_and_parity(B256::ZERO, B256::ZERO, false).unwrap() - } - } - } -} - -impl Encodable for TypedTransaction { - fn encode(&self, out: &mut dyn bytes::BufMut) { - match self { - TypedTransaction::Legacy(tx) => tx.encode(out), - TypedTransaction::EIP2930(tx) => tx.encode(out), - TypedTransaction::EIP1559(tx) => tx.encode(out), - TypedTransaction::Deposit(tx) => tx.encode(out), - } - } -} - -impl Decodable for TypedTransaction { - fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - use bytes::Buf; - use std::cmp::Ordering; - - let first = *buf.first().ok_or(alloy_rlp::Error::Custom("empty slice"))?; - - // a signed transaction is either encoded as a string (non legacy) or a list (legacy). - // We should not consume the buffer if we are decoding a legacy transaction, so let's - // check if the first byte is between 0x80 and 0xbf. - match first.cmp(&alloy_rlp::EMPTY_LIST_CODE) { - Ordering::Less => { - // strip out the string header - // NOTE: typed transaction encodings either contain a "rlp header" which contains - // the type of the payload and its length, or they do not contain a header and - // start with the tx type byte. - // - // This line works for both types of encodings because byte slices starting with - // 0x01 and 0x02 return a Header { list: false, payload_length: 1 } when input to - // Header::decode. - // If the encoding includes a header, the header will be properly decoded and - // consumed. - // Otherwise, header decoding will succeed but nothing is consumed. - let _header = alloy_rlp::Header::decode(buf)?; - let tx_type = *buf.first().ok_or(alloy_rlp::Error::Custom( - "typed tx cannot be decoded from an empty slice", - ))?; - if tx_type == 0x01 { - buf.advance(1); - as Decodable>::decode(buf).map(TypedTransaction::EIP2930) - } else if tx_type == 0x02 { - buf.advance(1); - as Decodable>::decode(buf).map(TypedTransaction::EIP1559) - } else if tx_type == 0x7E { - buf.advance(1); - ::decode(buf).map(TypedTransaction::Deposit) - } else { - Err(alloy_rlp::Error::Custom("invalid tx type")) - } - } - Ordering::Equal => { - Err(alloy_rlp::Error::Custom("an empty list is not a valid transaction encoding")) - } - Ordering::Greater => { - as Decodable>::decode(buf).map(TypedTransaction::Legacy) - } - } - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct TransactionEssentials { - pub kind: TxKind, - pub input: Bytes, - pub nonce: U256, - pub gas_limit: U256, - pub gas_price: Option, - pub max_fee_per_gas: Option, - pub max_priority_fee_per_gas: Option, - pub value: U256, - pub chain_id: Option, - pub access_list: AccessList, -} - -/// Represents all relevant information of an executed transaction -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct TransactionInfo { - pub transaction_hash: B256, - pub transaction_index: u32, - pub from: Address, - pub to: Option
, - pub contract_address: Option
, - pub logs: Vec, - pub logs_bloom: Bloom, - pub traces: Vec, - pub exit: InstructionResult, - pub out: Option, - pub nonce: u64, -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum TypedReceipt { - Legacy(ReceiptWithBloom), - EIP2930(ReceiptWithBloom), - EIP1559(ReceiptWithBloom), - Deposit(ReceiptWithBloom), -} - -impl TypedReceipt { - pub fn gas_used(&self) -> U256 { - match self { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::Deposit(r) => U256::from(r.receipt.cumulative_gas_used), - } - } - - pub fn logs_bloom(&self) -> &Bloom { - match self { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::Deposit(r) => &r.bloom, - } - } -} - -impl Encodable for TypedReceipt { - fn encode(&self, out: &mut dyn bytes::BufMut) { - use alloy_rlp::Header; - - match self { - TypedReceipt::Legacy(r) => r.encode(out), - receipt => { - let payload_len = match receipt { - TypedReceipt::EIP2930(r) => r.length() + 1, - TypedReceipt::EIP1559(r) => r.length() + 1, - TypedReceipt::Deposit(r) => r.length() + 1, - _ => unreachable!("receipt already matched"), - }; - - match receipt { - TypedReceipt::EIP2930(r) => { - Header { list: true, payload_length: payload_len }.encode(out); - 1u8.encode(out); - r.encode(out); - } - TypedReceipt::EIP1559(r) => { - Header { list: true, payload_length: payload_len }.encode(out); - 2u8.encode(out); - r.encode(out); - } - TypedReceipt::Deposit(r) => { - Header { list: true, payload_length: payload_len }.encode(out); - 0x7Eu8.encode(out); - r.encode(out); - } - _ => unreachable!("receipt already matched"), - } - } - } - } -} - -impl Decodable for TypedReceipt { - fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - use alloy_rlp::Header; - use bytes::Buf; - use std::cmp::Ordering; - - // a receipt is either encoded as a string (non legacy) or a list (legacy). - // We should not consume the buffer if we are decoding a legacy receipt, so let's - // check if the first byte is between 0x80 and 0xbf. - let rlp_type = *buf - .first() - .ok_or(alloy_rlp::Error::Custom("cannot decode a receipt from empty bytes"))?; - - match rlp_type.cmp(&alloy_rlp::EMPTY_LIST_CODE) { - Ordering::Less => { - // strip out the string header - let _header = Header::decode(buf)?; - let receipt_type = *buf.first().ok_or(alloy_rlp::Error::Custom( - "typed receipt cannot be decoded from an empty slice", - ))?; - if receipt_type == 0x01 { - buf.advance(1); - ::decode(buf).map(TypedReceipt::EIP2930) - } else if receipt_type == 0x02 { - buf.advance(1); - ::decode(buf).map(TypedReceipt::EIP1559) - } else if receipt_type == 0x7E { - buf.advance(1); - ::decode(buf).map(TypedReceipt::Deposit) - } else { - Err(alloy_rlp::Error::Custom("invalid receipt type")) - } - } - Ordering::Equal => { - Err(alloy_rlp::Error::Custom("an empty list is not a valid receipt encoding")) - } - Ordering::Greater => { - ::decode(buf).map(TypedReceipt::Legacy) - } - } - } -} - -/// Translates an EIP-2930 access list to an alloy-rpc-types access list. -pub fn to_alloy_access_list( - access_list: alloy_eips::eip2930::AccessList, -) -> alloy_rpc_types::AccessList { - alloy_rpc_types::AccessList( - access_list - .0 - .into_iter() - .map(|item| alloy_rpc_types::AccessListItem { - address: item.address, - storage_keys: item.storage_keys, - }) - .collect(), - ) -} - -/// Translates an alloy-rpc-types access list to an EIP-2930 access list. -pub fn to_eip_access_list( - access_list: alloy_rpc_types::AccessList, -) -> alloy_eips::eip2930::AccessList { - alloy_eips::eip2930::AccessList( - access_list - .0 - .into_iter() - .map(|item| alloy_eips::eip2930::AccessListItem { - address: item.address, - storage_keys: item.storage_keys, - }) - .collect(), - ) -} - -#[cfg(test)] -mod tests { - use alloy_consensus::Receipt; - use alloy_primitives::{b256, hex, LogData, Signature}; - use std::str::FromStr; - - use super::*; - - #[test] - fn test_decode_call() { - let bytes_first = &mut &hex::decode("f86b02843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba00eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5aea03a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18").unwrap()[..]; - let decoded = TypedTransaction::decode(&mut &bytes_first[..]).unwrap(); - let tx = TxLegacy { - nonce: 2u64, - gas_price: 1000000000u64.into(), - gas_limit: 100000u64, - to: TxKind::Call(Address::from_slice( - &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], - )), - value: U256::from(1000000000000000u64), - input: Bytes::default(), - chain_id: Some(4), - }; - - let signature = Signature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap(); - - let tx = TypedTransaction::Legacy(Signed::new_unchecked( - tx.clone(), - signature, - b256!("a517b206d2223278f860ea017d3626cacad4f52ff51030dc9a96b432f17f8d34"), - )); - - assert_eq!(tx, decoded); - } - - #[test] - fn test_decode_create_goerli() { - // test that an example create tx from goerli decodes properly - let tx_bytes = - hex::decode("02f901ee05228459682f008459682f11830209bf8080b90195608060405234801561001057600080fd5b50610175806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80630c49c36c14610030575b600080fd5b61003861004e565b604051610045919061011d565b60405180910390f35b60606020600052600f6020527f68656c6c6f2073746174656d696e64000000000000000000000000000000000060405260406000f35b600081519050919050565b600082825260208201905092915050565b60005b838110156100be5780820151818401526020810190506100a3565b838111156100cd576000848401525b50505050565b6000601f19601f8301169050919050565b60006100ef82610084565b6100f9818561008f565b93506101098185602086016100a0565b610112816100d3565b840191505092915050565b6000602082019050818103600083015261013781846100e4565b90509291505056fea264697066735822122051449585839a4ea5ac23cae4552ef8a96b64ff59d0668f76bfac3796b2bdbb3664736f6c63430008090033c080a0136ebffaa8fc8b9fda9124de9ccb0b1f64e90fbd44251b4c4ac2501e60b104f9a07eb2999eec6d185ef57e91ed099afb0a926c5b536f0155dd67e537c7476e1471") - .unwrap(); - let _decoded = - ::decode(&mut &tx_bytes[..]).unwrap(); - } - - #[test] - fn can_recover_sender() { - // random mainnet tx: https://etherscan.io/tx/0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f - let bytes = hex::decode("02f872018307910d808507204d2cb1827d0094388c818ca8b9251b393131c08a736a67ccb19297880320d04823e2701c80c001a0cf024f4815304df2867a1a74e9d2707b6abda0337d2d54a4438d453f4160f190a07ac0e6b3bc9395b5b9c8b9e6d77204a236577a5b18467b9175c01de4faa208d9").unwrap(); - - let Ok(TypedTransaction::EIP1559(tx)) = TypedTransaction::decode(&mut &bytes[..]) else { - panic!("decoding TypedTransaction failed"); - }; - - assert_eq!( - tx.hash(), - &"0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f" - .parse::() - .unwrap() - ); - assert_eq!( - tx.recover_signer().unwrap(), - "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5".parse::
().unwrap() - ); - } - - #[test] - fn can_recover_sender_not_normalized() { - let bytes = hex::decode("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap(); - - let Ok(TypedTransaction::Legacy(tx)) = TypedTransaction::decode(&mut &bytes[..]) else { - panic!("decoding TypedTransaction failed"); - }; - - assert_eq!(tx.input, Bytes::from(b"")); - assert_eq!(tx.gas_price, 1); - assert_eq!(tx.gas_limit, 21000); - assert_eq!(tx.nonce, 0); - if let TxKind::Call(to) = tx.to { - assert_eq!( - to, - "0x095e7baea6a6c7c4c2dfeb977efac326af552d87".parse::
().unwrap() - ); - } else { - panic!("expected a call transaction"); - } - assert_eq!(tx.value, U256::from(0x0au64)); - assert_eq!( - tx.recover_signer().unwrap(), - "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse::
().unwrap() - ); - } - - #[test] - fn encode_legacy_receipt() { - let expected = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); - - let mut data = vec![]; - let receipt = TypedReceipt::Legacy(ReceiptWithBloom { - receipt: Receipt { - success: false, - cumulative_gas_used: 0x1u64, - logs: vec![Log { - address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), - data: LogData::new_unchecked( - vec![ - B256::from_str( - "000000000000000000000000000000000000000000000000000000000000dead", - ) - .unwrap(), - B256::from_str( - "000000000000000000000000000000000000000000000000000000000000beef", - ) - .unwrap(), - ], - Bytes::from_str("0100ff").unwrap(), - ), - }], - }, - bloom: [0; 256].into(), - }); - - receipt.encode(&mut data); - - // check that the rlp length equals the length of the expected rlp - assert_eq!(receipt.length(), expected.len()); - assert_eq!(data, expected); - } - - #[test] - fn decode_legacy_receipt() { - let data = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); - - let expected = TypedReceipt::Legacy(ReceiptWithBloom { - receipt: Receipt { - success: false, - cumulative_gas_used: 0x1u64, - logs: vec![Log { - address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), - data: LogData::new_unchecked( - vec![ - B256::from_str( - "000000000000000000000000000000000000000000000000000000000000dead", - ) - .unwrap(), - B256::from_str( - "000000000000000000000000000000000000000000000000000000000000beef", - ) - .unwrap(), - ], - Bytes::from_str("0100ff").unwrap(), - ), - }], - }, - bloom: [0; 256].into(), - }); - - let receipt = TypedReceipt::decode(&mut &data[..]).unwrap(); - - assert_eq!(receipt, expected); - } -} diff --git a/crates/anvil/core/src/eth/transaction/ethers_compat.rs b/crates/anvil/core/src/eth/transaction/ethers_compat.rs deleted file mode 100644 index 50bb60b459814..0000000000000 --- a/crates/anvil/core/src/eth/transaction/ethers_compat.rs +++ /dev/null @@ -1,501 +0,0 @@ -//! ethers compatibility, this is mainly necessary so we can use all of `ethers` signers - -use super::EthTransactionRequest; -use crate::eth::{ - proof::AccountProof, - transaction::{ - DepositTransactionRequest, EIP1559TransactionRequest, EIP2930TransactionRequest, - LegacyTransactionRequest, MaybeImpersonatedTransaction, TypedTransaction, - TypedTransactionRequest, - }, -}; -use alloy_primitives::{U128 as rU128, U256 as rU256, U64 as rU64}; -use alloy_rpc_types::{ - AccessList as AlloyAccessList, CallRequest, Signature, Transaction as AlloyTransaction, -}; -use ethers_core::types::{ - transaction::{ - eip2718::TypedTransaction as EthersTypedTransactionRequest, - eip2930::{AccessList, AccessListItem}, - optimism::DepositTransaction, - }, - Address, BigEndianHash, Eip1559TransactionRequest as EthersEip1559TransactionRequest, - Eip2930TransactionRequest as EthersEip2930TransactionRequest, NameOrAddress, StorageProof, - Transaction as EthersTransaction, TransactionRequest as EthersLegacyTransactionRequest, - TransactionRequest, H256, U256, U64, -}; -use foundry_common::types::{ToAlloy, ToEthers}; - -pub fn to_alloy_signature(signature: ethers_core::types::Signature) -> alloy_rpc_types::Signature { - alloy_rpc_types::Signature { - r: signature.r.to_alloy(), - s: signature.s.to_alloy(), - v: signature.v.to_alloy().to::(), - y_parity: None, - } -} - -pub fn to_ethers_signature(signature: alloy_rpc_types::Signature) -> ethers_core::types::Signature { - ethers_core::types::Signature { - r: signature.r.to_ethers(), - s: signature.s.to_ethers(), - v: signature.v.to::(), - } -} - -pub fn to_alloy_proof(proof: AccountProof) -> alloy_rpc_types::EIP1186AccountProofResponse { - alloy_rpc_types::EIP1186AccountProofResponse { - address: proof.address.to_alloy(), - account_proof: proof.account_proof.into_iter().map(|b| b.0.into()).collect(), - balance: proof.balance.to_alloy(), - code_hash: proof.code_hash.to_alloy(), - nonce: proof.nonce.to_alloy().to::(), - storage_hash: proof.storage_hash.to_alloy(), - storage_proof: proof.storage_proof.iter().map(to_alloy_storage_proof).collect(), - } -} - -pub fn to_alloy_storage_proof(proof: &StorageProof) -> alloy_rpc_types::EIP1186StorageProof { - alloy_rpc_types::EIP1186StorageProof { - key: rU256::from_be_bytes(proof.key.to_alloy().0).into(), - proof: proof.proof.iter().map(|b| b.clone().0.into()).collect(), - value: proof.value.to_alloy(), - } -} - -pub fn call_to_internal_tx_request(request: &CallRequest) -> EthTransactionRequest { - EthTransactionRequest { - from: request.from.map(|a| a.to_ethers()), - to: request.to.map(|a| a.to_ethers()), - gas_price: request.gas_price.map(|g| alloy_primitives::U256::from(g).to_ethers()), - max_fee_per_gas: request - .max_fee_per_gas - .map(|g| alloy_primitives::U256::from(g).to_ethers()), - max_priority_fee_per_gas: request - .max_priority_fee_per_gas - .map(|g| alloy_primitives::U256::from(g).to_ethers()), - gas: request.gas.map(|g| g.to_ethers()), - value: request.value.map(|v| v.to_ethers()), - data: request.input.unique_input().unwrap().map(|b| b.clone().0.into()), - nonce: request.nonce.map(|n| n.to::().into()), - chain_id: request.chain_id.map(|c| c.to::().into()), - access_list: request.access_list.clone().map(|a| to_ethers_access_list(a.clone()).0), - transaction_type: request.transaction_type.map(|t| t.to::().into()), - // TODO: Should this be none? - optimism_fields: None, - } -} - -pub fn to_ethers_access_list(access_list: AlloyAccessList) -> AccessList { - AccessList( - access_list - .0 - .into_iter() - .map(|item| AccessListItem { - address: item.address.to_ethers(), - storage_keys: item - .storage_keys - .into_iter() - .map(|k| { - BigEndianHash::from_uint(&U256::from_big_endian(k.to_ethers().as_bytes())) - }) - .collect(), - }) - .collect(), - ) -} - -pub fn from_ethers_access_list(access_list: AccessList) -> AlloyAccessList { - AlloyAccessList(access_list.0.into_iter().map(ToAlloy::to_alloy).collect()) -} - -impl From for EthersTypedTransactionRequest { - fn from(tx: TypedTransactionRequest) -> Self { - match tx { - TypedTransactionRequest::Legacy(tx) => { - let LegacyTransactionRequest { - nonce, - gas_price, - gas_limit, - kind, - value, - input, - chain_id, - } = tx; - EthersTypedTransactionRequest::Legacy(EthersLegacyTransactionRequest { - from: None, - to: kind.as_call().cloned().map(Into::into), - gas: Some(gas_limit), - gas_price: Some(gas_price), - value: Some(value), - data: Some(input), - nonce: Some(nonce), - chain_id: chain_id.map(Into::into), - }) - } - TypedTransactionRequest::EIP2930(tx) => { - let EIP2930TransactionRequest { - chain_id, - nonce, - gas_price, - gas_limit, - kind, - value, - input, - access_list, - } = tx; - EthersTypedTransactionRequest::Eip2930(EthersEip2930TransactionRequest { - tx: EthersLegacyTransactionRequest { - from: None, - to: kind.as_call().cloned().map(Into::into), - gas: Some(gas_limit), - gas_price: Some(gas_price), - value: Some(value), - data: Some(input), - nonce: Some(nonce), - chain_id: Some(chain_id.into()), - }, - access_list: access_list.into(), - }) - } - TypedTransactionRequest::EIP1559(tx) => { - let EIP1559TransactionRequest { - chain_id, - nonce, - max_priority_fee_per_gas, - max_fee_per_gas, - gas_limit, - kind, - value, - input, - access_list, - } = tx; - EthersTypedTransactionRequest::Eip1559(EthersEip1559TransactionRequest { - from: None, - to: kind.as_call().cloned().map(Into::into), - gas: Some(gas_limit), - value: Some(value), - data: Some(input), - nonce: Some(nonce), - access_list: access_list.into(), - max_priority_fee_per_gas: Some(max_priority_fee_per_gas), - max_fee_per_gas: Some(max_fee_per_gas), - chain_id: Some(chain_id.into()), - }) - } - TypedTransactionRequest::Deposit(tx) => { - let DepositTransactionRequest { - source_hash, - from, - kind, - mint, - value, - gas_limit, - is_system_tx, - input, - } = tx; - EthersTypedTransactionRequest::DepositTransaction(DepositTransaction { - tx: TransactionRequest { - from: Some(from), - to: kind.as_call().cloned().map(Into::into), - gas: Some(gas_limit), - value: Some(value), - data: Some(input), - gas_price: Some(0.into()), - nonce: Some(0.into()), - chain_id: None, - }, - source_hash, - mint: Some(mint), - is_system_tx, - }) - } - } - } -} - -fn to_ethers_transaction_with_hash_and_sender( - transaction: TypedTransaction, - hash: H256, - from: Address, -) -> EthersTransaction { - match transaction { - TypedTransaction::Legacy(t) => EthersTransaction { - hash, - nonce: t.nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: None, - value: t.value, - gas_price: Some(t.gas_price), - max_fee_per_gas: Some(t.gas_price), - max_priority_fee_per_gas: Some(t.gas_price), - gas: t.gas_limit, - input: t.input.clone(), - chain_id: t.chain_id().map(Into::into), - v: t.signature.v.into(), - r: t.signature.r, - s: t.signature.s, - access_list: None, - transaction_type: None, - source_hash: H256::zero(), - mint: None, - is_system_tx: false, - other: Default::default(), - }, - TypedTransaction::EIP2930(t) => EthersTransaction { - hash, - nonce: t.nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: None, - value: t.value, - gas_price: Some(t.gas_price), - max_fee_per_gas: Some(t.gas_price), - max_priority_fee_per_gas: Some(t.gas_price), - gas: t.gas_limit, - input: t.input.clone(), - chain_id: Some(t.chain_id.into()), - v: U64::from(t.odd_y_parity as u8), - r: U256::from(t.r.as_bytes()), - s: U256::from(t.s.as_bytes()), - access_list: Some(t.access_list), - transaction_type: Some(1u64.into()), - source_hash: H256::zero(), - mint: None, - is_system_tx: false, - other: Default::default(), - }, - TypedTransaction::EIP1559(t) => EthersTransaction { - hash, - nonce: t.nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: None, - value: t.value, - gas_price: None, - max_fee_per_gas: Some(t.max_fee_per_gas), - max_priority_fee_per_gas: Some(t.max_priority_fee_per_gas), - gas: t.gas_limit, - input: t.input.clone(), - chain_id: Some(t.chain_id.into()), - v: U64::from(t.odd_y_parity as u8), - r: U256::from(t.r.as_bytes()), - s: U256::from(t.s.as_bytes()), - access_list: Some(t.access_list), - transaction_type: Some(2u64.into()), - source_hash: H256::zero(), - mint: None, - is_system_tx: false, - other: Default::default(), - }, - TypedTransaction::Deposit(t) => EthersTransaction { - hash, - nonce: t.nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: None, - value: t.value, - gas_price: Some(0.into()), - max_fee_per_gas: Some(0.into()), - max_priority_fee_per_gas: Some(0.into()), - gas: t.gas_limit, - input: t.input.clone(), - chain_id: t.chain_id().map(Into::into), - v: 0.into(), - r: 0.into(), - s: 0.into(), - access_list: None, - transaction_type: Some(126u64.into()), - source_hash: t.source_hash, - mint: Some(t.mint), - is_system_tx: t.is_system_tx, - other: Default::default(), - }, - } -} - -fn to_alloy_transaction_with_hash_and_sender( - transaction: TypedTransaction, - hash: H256, - from: Address, -) -> AlloyTransaction { - match transaction { - TypedTransaction::Legacy(t) => AlloyTransaction { - hash: hash.to_alloy(), - nonce: t.nonce.to_alloy().to::(), - block_hash: None, - block_number: None, - transaction_index: None, - from: from.to_alloy(), - to: None, - value: t.value.to_alloy(), - gas_price: Some(t.gas_price.to_alloy().to::()), - max_fee_per_gas: Some(t.gas_price.to_alloy().to::()), - max_priority_fee_per_gas: Some(t.gas_price.to_alloy().to::()), - gas: t.gas_limit.to_alloy(), - input: t.input.clone().0.into(), - chain_id: t.chain_id().map(rU64::from), - signature: Some(Signature { - r: t.signature.r.to_alloy(), - s: t.signature.s.to_alloy(), - v: rU256::from(t.signature.v), - y_parity: None, - }), - access_list: None, - transaction_type: None, - max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], - other: Default::default(), - }, - TypedTransaction::EIP2930(t) => AlloyTransaction { - hash: hash.to_alloy(), - nonce: t.nonce.to_alloy().to::(), - block_hash: None, - block_number: None, - transaction_index: None, - from: from.to_alloy(), - to: None, - value: t.value.to_alloy(), - gas_price: Some(t.gas_price.to_alloy().to::()), - max_fee_per_gas: Some(t.gas_price.to_alloy().to::()), - max_priority_fee_per_gas: Some(t.gas_price.to_alloy().to::()), - gas: t.gas_limit.to_alloy(), - input: t.input.clone().0.into(), - chain_id: Some(rU64::from(t.chain_id)), - signature: Some(Signature { - r: rU256::from_be_bytes(t.r.to_alloy().0), - s: rU256::from_be_bytes(t.s.to_alloy().0), - v: rU256::from(t.odd_y_parity as u8), - y_parity: Some(t.odd_y_parity.into()), - }), - access_list: Some(from_ethers_access_list(t.access_list).0), - transaction_type: Some(rU64::from(1)), - max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], - other: Default::default(), - }, - TypedTransaction::EIP1559(t) => AlloyTransaction { - hash: hash.to_alloy(), - nonce: t.nonce.to_alloy().to::(), - block_hash: None, - block_number: None, - transaction_index: None, - from: from.to_alloy(), - to: None, - value: t.value.to_alloy(), - gas_price: None, - max_fee_per_gas: Some(t.max_fee_per_gas.to_alloy().to::()), - max_priority_fee_per_gas: Some(t.max_priority_fee_per_gas.to_alloy().to::()), - gas: t.gas_limit.to_alloy(), - input: t.input.clone().0.into(), - chain_id: Some(rU64::from(t.chain_id)), - signature: Some(Signature { - r: rU256::from_be_bytes(t.r.to_alloy().0), - s: rU256::from_be_bytes(t.s.to_alloy().0), - v: rU256::from(t.odd_y_parity as u8), - y_parity: Some(t.odd_y_parity.into()), - }), - access_list: Some(from_ethers_access_list(t.access_list).0), - transaction_type: Some(rU64::from(2)), - max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], - other: Default::default(), - }, - TypedTransaction::Deposit(t) => AlloyTransaction { - hash: hash.to_alloy(), - nonce: t.nonce.to_alloy().to::(), - block_hash: None, - block_number: None, - transaction_index: None, - from: from.to_alloy(), - to: None, - value: t.value.to_alloy(), - gas_price: None, - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - gas: t.gas_limit.to_alloy(), - input: t.input.clone().0.into(), - chain_id: t.chain_id().map(rU64::from), - signature: None, - access_list: None, - transaction_type: None, - max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], - other: Default::default(), - }, - } -} - -impl From for EthersTransaction { - fn from(transaction: TypedTransaction) -> Self { - let hash = transaction.hash(); - let sender = transaction.recover().unwrap_or_default(); - to_ethers_transaction_with_hash_and_sender(transaction, hash, sender) - } -} - -impl From for EthersTransaction { - fn from(transaction: MaybeImpersonatedTransaction) -> Self { - let hash = transaction.hash(); - let sender = transaction.recover().unwrap_or_default(); - to_ethers_transaction_with_hash_and_sender(transaction.into(), hash, sender) - } -} - -impl From for AlloyTransaction { - fn from(transaction: MaybeImpersonatedTransaction) -> Self { - let hash = transaction.hash(); - let sender = transaction.recover().unwrap_or_default(); - - to_alloy_transaction_with_hash_and_sender(transaction.into(), hash, sender) - } -} - -impl From for EthTransactionRequest { - fn from(req: TransactionRequest) -> Self { - let TransactionRequest { from, to, gas, gas_price, value, data, nonce, chain_id, .. } = req; - EthTransactionRequest { - from, - to: to.and_then(|to| match to { - NameOrAddress::Name(_) => None, - NameOrAddress::Address(to) => Some(to), - }), - gas_price, - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - gas, - value, - data, - nonce, - chain_id, - access_list: None, - transaction_type: None, - optimism_fields: None, - } - } -} - -impl From for TransactionRequest { - fn from(req: EthTransactionRequest) -> Self { - let EthTransactionRequest { from, to, gas_price, gas, value, data, nonce, .. } = req; - TransactionRequest { - from, - to: to.map(NameOrAddress::Address), - gas, - gas_price, - value, - data, - nonce, - chain_id: None, - } - } -} diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 4a878ddfbbf40..d3cf7aa7d82b1 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1,20 +1,17 @@ -//! transaction related data +//! Transaction related types use crate::eth::{ - receipt::Log, - utils::{enveloped, to_revm_access_list}, + transaction::optimism::{DepositTransaction, DepositTransactionRequest}, + utils::eip_to_revm_access_list, }; -use ethers_core::{ - types::{ - transaction::eip2930::{AccessList, AccessListItem}, - Address, Bloom, Bytes, Signature, SignatureError, TxHash, H256, U256, U64, - }, - utils::{ - keccak256, rlp, - rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}, - }, +use alloy_consensus::{ReceiptWithBloom, TxEip1559, TxEip2930, TxLegacy}; +use alloy_network::{Signed, Transaction, TxKind}; +use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, B256, U128, U256, U64}; +use alloy_rlp::{Decodable, Encodable}; +use alloy_rpc_types::{ + request::TransactionRequest, AccessList, AccessListItem, CallRequest, + Signature as RpcSignature, Transaction as RpcTransaction, }; -use foundry_common::types::ToAlloy; use foundry_evm::traces::CallTraceNode; use revm::{ interpreter::InstructionResult, @@ -22,37 +19,15 @@ use revm::{ }; use std::ops::Deref; -pub mod alloy; -/// compatibility with `ethers-rs` types -mod ethers_compat; +use super::utils::from_eip_to_alloy_access_list; + pub mod optimism; -pub use ethers_compat::{ - call_to_internal_tx_request, from_ethers_access_list, to_alloy_proof, to_alloy_signature, - to_ethers_access_list, to_ethers_signature, -}; /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC #[cfg(feature = "impersonated-tx")] -pub const IMPERSONATED_SIGNATURE: alloy_rpc_types::Signature = alloy_rpc_types::Signature { - r: alloy_primitives::U256::ZERO, - s: alloy_primitives::U256::ZERO, - v: alloy_primitives::U256::ZERO, - y_parity: None, -}; - -/// Container type for various Ethereum transaction requests -/// -/// Its variants correspond to specific allowed transactions: -/// 1. Legacy (pre-EIP2718) [`LegacyTransactionRequest`] -/// 2. EIP2930 (state access lists) [`EIP2930TransactionRequest`] -/// 3. EIP1559 [`EIP1559TransactionRequest`] -/// 4. Deposit [`DepositTransactionRequest`] -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum TypedTransactionRequest { - Legacy(LegacyTransactionRequest), - EIP2930(EIP2930TransactionRequest), - EIP1559(EIP1559TransactionRequest), - Deposit(DepositTransactionRequest), +pub fn impersonated_signature() -> Signature { + Signature::from_scalars_and_parity(B256::with_last_byte(1), B256::with_last_byte(1), false) + .unwrap() } /// Represents _all_ transaction requests received from RPC @@ -103,17 +78,14 @@ pub struct EthTransactionRequest { #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct OptimismDepositRequestFields { /// op-stack deposit source hash - pub source_hash: H256, + pub source_hash: B256, /// op-stack deposit mint pub mint: U256, /// op-stack deposit system tx pub is_system_tx: bool, } -// == impl EthTransactionRequest == - impl EthTransactionRequest { - /// Converts the request into a [TypedTransactionRequest] pub fn into_typed_request(self) -> Option { let EthTransactionRequest { from, @@ -126,29 +98,29 @@ impl EthTransactionRequest { data, nonce, mut access_list, - chain_id, transaction_type, optimism_fields, .. } = self; - let chain_id = chain_id.map(|id| id.as_u64()); - let transaction_type = transaction_type.map(|id| id.as_u64()); - // op-stack deposit tx - if optimism_fields.is_some() && transaction_type == Some(126) { + let transaction_type = transaction_type.map(|id| id.to::()); + let data = data.clone().unwrap_or_default(); + // Special case: OP-stack deposit tx + if transaction_type == Some(126) { return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { - source_hash: optimism_fields.clone()?.source_hash, from: from.unwrap_or_default(), + source_hash: optimism_fields.clone()?.source_hash, kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => TxKind::Call(to), + None => TxKind::Create, }, mint: optimism_fields.clone()?.mint, value: value.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), is_system_tx: optimism_fields.clone()?.is_system_tx, - input: data.clone().unwrap_or_default(), - })); + input: data, + })) } + match ( transaction_type, gas_price, @@ -158,33 +130,33 @@ impl EthTransactionRequest { ) { // legacy transaction (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { - Some(TypedTransactionRequest::Legacy(LegacyTransactionRequest { - nonce: nonce.unwrap_or(U256::zero()), - gas_price: gas_price.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - value: value.unwrap_or(U256::zero()), - input: data.unwrap_or_default(), - kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(TypedTransactionRequest::Legacy(TxLegacy { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data, + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, }, - chain_id, + chain_id: None, })) } // EIP2930 (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { - Some(TypedTransactionRequest::EIP2930(EIP2930TransactionRequest { - nonce: nonce.unwrap_or(U256::zero()), - gas_price: gas_price.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - value: value.unwrap_or(U256::zero()), - input: data.unwrap_or_default(), - kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(TypedTransactionRequest::EIP2930(TxEip2930 { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data, + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, }, - chain_id: chain_id.unwrap_or_default(), - access_list: access_list.unwrap_or_default(), + chain_id: 0, + access_list: to_eip_access_list(AccessList(access_list.unwrap_or_default())), })) } // EIP1559 @@ -193,19 +165,21 @@ impl EthTransactionRequest { (None, None, _, Some(_), _) | (None, None, None, None, None) => { // Empty fields fall back to the canonical transaction schema. - Some(TypedTransactionRequest::EIP1559(EIP1559TransactionRequest { - nonce: nonce.unwrap_or(U256::zero()), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or(U256::zero()), - gas_limit: gas.unwrap_or_default(), - value: value.unwrap_or(U256::zero()), - input: data.unwrap_or_default(), - kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(TypedTransactionRequest::EIP1559(TxEip1559 { + nonce: nonce.unwrap_or_default().to::(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), + max_priority_fee_per_gas: max_priority_fee_per_gas + .unwrap_or_default() + .to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data, + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, }, - chain_id: chain_id.unwrap_or_default(), - access_list: access_list.unwrap_or_default(), + chain_id: 0, + access_list: to_eip_access_list(AccessList(access_list.unwrap_or_default())), })) } _ => None, @@ -213,317 +187,200 @@ impl EthTransactionRequest { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TransactionKind { - Call(Address), - Create, -} - -// == impl TransactionKind == - -impl TransactionKind { - /// If this transaction is a call this returns the address of the callee - pub fn as_call(&self) -> Option<&Address> { - match self { - TransactionKind::Call(to) => Some(to), - TransactionKind::Create => None, - } - } -} - -impl Encodable for TransactionKind { - fn rlp_append(&self, s: &mut RlpStream) { - match self { - TransactionKind::Call(address) => { - s.encoder().encode_value(&address[..]); - } - TransactionKind::Create => s.encoder().encode_value(&[]), - } - } -} - -impl Decodable for TransactionKind { - fn decode(rlp: &Rlp) -> Result { - if rlp.is_empty() { - if rlp.is_data() { - Ok(TransactionKind::Create) - } else { - Err(DecoderError::RlpExpectedToBeData) - } - } else { - Ok(TransactionKind::Call(rlp.as_val()?)) - } - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Encodable for TransactionKind { - fn length(&self) -> usize { - match self { - TransactionKind::Call(to) => to.length(), - TransactionKind::Create => ([]).length(), - } - } - fn encode(&self, out: &mut dyn open_fastrlp::BufMut) { - match self { - TransactionKind::Call(to) => to.encode(out), - TransactionKind::Create => ([]).encode(out), +pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { + let TransactionRequest { + from, + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + gas, + value, + data, + nonce, + mut access_list, + transaction_type, + other, + .. + } = tx; + let transaction_type = transaction_type.map(|id| id.to::()); + + // Special case: OP-stack deposit tx + if transaction_type == Some(126) { + return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { + from: from.unwrap_or_default(), + source_hash: other.get_deserialized::("sourceHash")?.ok()?, + kind: TxKind::Create, + mint: other.get_deserialized::("mint")?.ok()?, + value: value.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), + is_system_tx: other.get_deserialized::("isSystemTx")?.ok()?, + input: data.unwrap_or_default(), + })) + } + + match ( + transaction_type, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + access_list.take(), + ) { + // legacy transaction + (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { + Some(TypedTransactionRequest::Legacy(TxLegacy { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data.unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: None, + })) } - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Decodable for TransactionKind { - fn decode(buf: &mut &[u8]) -> Result { - use bytes::Buf; - - if let Some(&first) = buf.first() { - if first == 0x80 { - buf.advance(1); - Ok(TransactionKind::Create) - } else { - let addr =
::decode(buf)?; - Ok(TransactionKind::Call(addr)) - } - } else { - Err(open_fastrlp::DecodeError::InputTooShort) + // EIP2930 + (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { + Some(TypedTransactionRequest::EIP2930(TxEip2930 { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data.unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: 0, + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) } - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -pub struct EIP2930TransactionRequest { - pub chain_id: u64, - pub nonce: U256, - pub gas_price: U256, - pub gas_limit: U256, - pub kind: TransactionKind, - pub value: U256, - pub input: Bytes, - pub access_list: Vec, -} - -impl EIP2930TransactionRequest { - pub fn hash(&self) -> H256 { - let encoded = rlp::encode(self); - let mut out = vec![0; 1 + encoded.len()]; - out[0] = 1; - out[1..].copy_from_slice(&encoded); - H256::from_slice(keccak256(&out).as_slice()) - } -} - -impl From for EIP2930TransactionRequest { - fn from(tx: EIP2930Transaction) -> Self { - Self { - chain_id: tx.chain_id, - nonce: tx.nonce, - gas_price: tx.gas_price, - gas_limit: tx.gas_limit, - kind: tx.kind, - value: tx.value, - input: tx.input, - access_list: tx.access_list.0, + // EIP1559 + (Some(2), None, _, _, _) | + (None, None, Some(_), _, _) | + (None, None, _, Some(_), _) | + (None, None, None, None, None) => { + // Empty fields fall back to the canonical transaction schema. + Some(TypedTransactionRequest::EIP1559(TxEip1559 { + nonce: nonce.unwrap_or_default().to::(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: data.unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: 0, + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) } + _ => None, } } -impl Encodable for EIP2930TransactionRequest { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(8); - s.append(&self.chain_id); - s.append(&self.nonce); - s.append(&self.gas_price); - s.append(&self.gas_limit); - s.append(&self.kind); - s.append(&self.value); - s.append(&self.input.as_ref()); - s.append_list(&self.access_list); - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct LegacyTransactionRequest { - pub nonce: U256, - pub gas_price: U256, - pub gas_limit: U256, - pub kind: TransactionKind, - pub value: U256, - pub input: Bytes, - pub chain_id: Option, -} - -// == impl LegacyTransactionRequest == - -impl LegacyTransactionRequest { - pub fn hash(&self) -> H256 { - H256::from_slice(keccak256(&rlp::encode(self)).as_slice()) - } -} - -impl From for LegacyTransactionRequest { - fn from(tx: LegacyTransaction) -> Self { - let chain_id = tx.chain_id(); - Self { - nonce: tx.nonce, - gas_price: tx.gas_price, - gas_limit: tx.gas_limit, - kind: tx.kind, - value: tx.value, - input: tx.input, - chain_id, +pub fn call_request_to_typed(tx: CallRequest) -> Option { + let CallRequest { + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + gas, + value, + input, + chain_id, + nonce, + mut access_list, + transaction_type, + .. + } = tx; + let chain_id = chain_id.map(|id| id.to::()); + let transaction_type = transaction_type.map(|id| id.to::()); + + match ( + transaction_type, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + access_list.take(), + ) { + // legacy transaction + (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { + Some(TypedTransactionRequest::Legacy(TxLegacy { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id, + })) } - } -} - -impl Encodable for LegacyTransactionRequest { - fn rlp_append(&self, s: &mut RlpStream) { - if let Some(chain_id) = self.chain_id { - s.begin_list(9); - s.append(&self.nonce); - s.append(&self.gas_price); - s.append(&self.gas_limit); - s.append(&self.kind); - s.append(&self.value); - s.append(&self.input.as_ref()); - s.append(&chain_id); - s.append(&0u8); - s.append(&0u8); - } else { - s.begin_list(6); - s.append(&self.nonce); - s.append(&self.gas_price); - s.append(&self.gas_limit); - s.append(&self.kind); - s.append(&self.value); - s.append(&self.input.as_ref()); + // EIP2930 + (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { + Some(TypedTransactionRequest::EIP2930(TxEip2930 { + nonce: nonce.unwrap_or_default().to::(), + gas_price: gas_price.unwrap_or_default().to(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: chain_id.unwrap_or_default(), + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) } - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -pub struct EIP1559TransactionRequest { - pub chain_id: u64, - pub nonce: U256, - pub max_priority_fee_per_gas: U256, - pub max_fee_per_gas: U256, - pub gas_limit: U256, - pub kind: TransactionKind, - pub value: U256, - pub input: Bytes, - pub access_list: Vec, -} - -// == impl EIP1559TransactionRequest == - -impl EIP1559TransactionRequest { - pub fn hash(&self) -> H256 { - let encoded = rlp::encode(self); - let mut out = vec![0; 1 + encoded.len()]; - out[0] = 2; - out[1..].copy_from_slice(&encoded); - H256::from_slice(keccak256(&out).as_slice()) - } -} - -impl From for EIP1559TransactionRequest { - fn from(t: EIP1559Transaction) -> Self { - Self { - chain_id: t.chain_id, - nonce: t.nonce, - max_priority_fee_per_gas: t.max_priority_fee_per_gas, - max_fee_per_gas: t.max_fee_per_gas, - gas_limit: t.gas_limit, - kind: t.kind, - value: t.value, - input: t.input, - access_list: t.access_list.0, + // EIP1559 + (Some(2), None, _, _, _) | + (None, None, Some(_), _, _) | + (None, None, _, Some(_), _) | + (None, None, None, None, None) => { + // Empty fields fall back to the canonical transaction schema. + Some(TypedTransactionRequest::EIP1559(TxEip1559 { + nonce: nonce.unwrap_or_default().to::(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: chain_id.unwrap_or_default(), + access_list: to_eip_access_list(access_list.unwrap_or_default()), + })) } - } -} - -impl Encodable for EIP1559TransactionRequest { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(9); - s.append(&self.chain_id); - s.append(&self.nonce); - s.append(&self.max_priority_fee_per_gas); - s.append(&self.max_fee_per_gas); - s.append(&self.gas_limit); - s.append(&self.kind); - s.append(&self.value); - s.append(&self.input.as_ref()); - s.append_list(&self.access_list); + _ => None, } } #[derive(Clone, Debug, PartialEq, Eq)] -pub struct DepositTransactionRequest { - pub from: Address, - pub source_hash: H256, - pub kind: TransactionKind, - pub mint: U256, - pub value: U256, - pub gas_limit: U256, - pub is_system_tx: bool, - pub input: Bytes, -} - -// == impl DepositTransactionRequest == - -impl DepositTransactionRequest { - pub fn hash(&self) -> H256 { - H256::from_slice(keccak256(&rlp::encode(self)).as_slice()) - } -} - -impl From for DepositTransactionRequest { - fn from(tx: DepositTransaction) -> Self { - Self { - from: tx.from, - source_hash: tx.source_hash, - kind: tx.kind, - mint: tx.mint, - value: tx.value, - gas_limit: tx.gas_limit, - is_system_tx: tx.is_system_tx, - input: tx.input, - } - } -} - -impl Encodable for DepositTransactionRequest { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(8); - s.append(&self.from); - s.append(&self.source_hash); - s.append(&self.kind); - s.append(&self.mint); - s.append(&self.value); - s.append(&self.gas_limit); - s.append(&self.is_system_tx); - s.append(&self.input.as_ref()); - } +pub enum TypedTransactionRequest { + Legacy(TxLegacy), + EIP2930(TxEip2930), + EIP1559(TxEip1559), + Deposit(DepositTransactionRequest), } -/// A wrapper for `TypedTransaction` that allows impersonating accounts. +/// A wrapper for [TypedTransaction] that allows impersonating accounts. /// /// This is a helper that carries the `impersonated` sender so that the right hash /// [TypedTransaction::impersonated_hash] can be created. #[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MaybeImpersonatedTransaction { - #[cfg_attr(feature = "serde", serde(flatten))] pub transaction: TypedTransaction, - #[cfg_attr(feature = "serde", serde(skip))] pub impersonated_sender: Option
, } -// === impl MaybeImpersonatedTransaction === - impl MaybeImpersonatedTransaction { /// Creates a new wrapper for the given transaction pub fn new(transaction: TypedTransaction) -> Self { @@ -540,7 +397,7 @@ impl MaybeImpersonatedTransaction { /// Note: this is feature gated so it does not conflict with the `Deref`ed /// [TypedTransaction::recover] function by default. #[cfg(feature = "impersonated-tx")] - pub fn recover(&self) -> Result { + pub fn recover(&self) -> Result { if let Some(sender) = self.impersonated_sender { return Ok(sender) } @@ -552,7 +409,7 @@ impl MaybeImpersonatedTransaction { /// Note: this is feature gated so it does not conflict with the `Deref`ed /// [TypedTransaction::hash] function by default. #[cfg(feature = "impersonated-tx")] - pub fn hash(&self) -> H256 { + pub fn hash(&self) -> B256 { if self.transaction.is_impersonated() { if let Some(sender) = self.impersonated_sender { return self.transaction.impersonated_hash(sender) @@ -563,8 +420,8 @@ impl MaybeImpersonatedTransaction { } impl Encodable for MaybeImpersonatedTransaction { - fn rlp_append(&self, s: &mut RlpStream) { - self.transaction.rlp_append(s) + fn encode(&self, out: &mut dyn bytes::BufMut) { + self.transaction.encode(out) } } @@ -581,26 +438,8 @@ impl From for MaybeImpersonatedTransaction { } impl Decodable for MaybeImpersonatedTransaction { - fn decode(rlp: &Rlp) -> Result { - let transaction = TypedTransaction::decode(rlp)?; - Ok(Self { transaction, impersonated_sender: None }) - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Encodable for MaybeImpersonatedTransaction { - fn encode(&self, out: &mut dyn open_fastrlp::BufMut) { - self.transaction.encode(out) - } - fn length(&self) -> usize { - self.transaction.length() - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Decodable for MaybeImpersonatedTransaction { - fn decode(buf: &mut &[u8]) -> Result { - Ok(Self { transaction: open_fastrlp::Decodable::decode(buf)?, impersonated_sender: None }) + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + TypedTransaction::decode(buf).map(MaybeImpersonatedTransaction::new) } } @@ -618,123 +457,400 @@ impl Deref for MaybeImpersonatedTransaction { } } -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TypedTransaction { - /// Legacy transaction type - Legacy(LegacyTransaction), - /// EIP-2930 transaction - EIP2930(EIP2930Transaction), - /// EIP-1559 transaction - EIP1559(EIP1559Transaction), - /// op-stack deposit transaction - Deposit(DepositTransaction), +impl From for RpcTransaction { + fn from(value: MaybeImpersonatedTransaction) -> Self { + let hash = value.hash(); + let sender = value.recover().unwrap_or_default(); + to_alloy_transaction_with_hash_and_sender(value.transaction, hash, sender) + } } -// == impl TypedTransaction == - -impl TypedTransaction { - /// Returns true if the transaction uses dynamic fees: EIP1559 - pub fn is_dynamic_fee(&self) -> bool { - matches!(self, TypedTransaction::EIP1559(_)) +pub fn to_alloy_transaction_with_hash_and_sender( + transaction: TypedTransaction, + hash: B256, + from: Address, +) -> RpcTransaction { + match transaction { + TypedTransaction::Legacy(t) => RpcTransaction { + hash, + nonce: U64::from(t.nonce), + block_hash: None, + block_number: None, + transaction_index: None, + from, + to: None, + value: t.value, + gas_price: Some(U128::from(t.gas_price)), + max_fee_per_gas: Some(U128::from(t.gas_price)), + max_priority_fee_per_gas: Some(U128::from(t.gas_price)), + gas: U256::from(t.gas_limit), + input: t.input.clone(), + chain_id: t.chain_id.map(U64::from), + signature: Some(RpcSignature { + r: t.signature().r(), + s: t.signature().s(), + v: U256::from(t.signature().v().y_parity_byte()), + y_parity: None, + }), + access_list: None, + transaction_type: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, + TypedTransaction::EIP2930(t) => RpcTransaction { + hash, + nonce: U64::from(t.nonce), + block_hash: None, + block_number: None, + transaction_index: None, + from, + to: None, + value: t.value, + gas_price: Some(U128::from(t.gas_price)), + max_fee_per_gas: Some(U128::from(t.gas_price)), + max_priority_fee_per_gas: Some(U128::from(t.gas_price)), + gas: U256::from(t.gas_limit), + input: t.input.clone(), + chain_id: Some(U64::from(t.chain_id)), + signature: Some(RpcSignature { + r: t.signature().r(), + s: t.signature().s(), + v: U256::from(t.signature().v().y_parity_byte()), + y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), + }), + access_list: Some(from_eip_to_alloy_access_list(t.access_list.clone()).0), + transaction_type: Some(U64::from(1)), + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, + TypedTransaction::EIP1559(t) => RpcTransaction { + hash, + nonce: U64::from(t.nonce), + block_hash: None, + block_number: None, + transaction_index: None, + from, + to: None, + value: t.value, + gas_price: None, + max_fee_per_gas: Some(U128::from(t.max_fee_per_gas)), + max_priority_fee_per_gas: Some(U128::from(t.max_priority_fee_per_gas)), + gas: U256::from(t.gas_limit), + input: t.input.clone(), + chain_id: Some(U64::from(t.chain_id)), + signature: Some(RpcSignature { + r: t.signature().r(), + s: t.signature().s(), + v: U256::from(t.signature().v().y_parity_byte()), + y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), + }), + access_list: Some(from_eip_to_alloy_access_list(t.access_list.clone()).0), + transaction_type: Some(U64::from(2)), + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, + TypedTransaction::Deposit(t) => RpcTransaction { + hash, + nonce: U64::from(t.nonce), + block_hash: None, + block_number: None, + transaction_index: None, + from, + to: None, + value: t.value, + gas_price: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + gas: U256::from(t.gas_limit), + input: t.input.clone().0.into(), + chain_id: t.chain_id().map(U64::from), + signature: None, + access_list: None, + transaction_type: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: vec![], + other: Default::default(), + }, } +} - pub fn gas_price(&self) -> U256 { - match self { - TypedTransaction::Legacy(tx) => tx.gas_price, - TypedTransaction::EIP2930(tx) => tx.gas_price, - TypedTransaction::EIP1559(tx) => tx.max_fee_per_gas, - TypedTransaction::Deposit(_) => U256::from(0), - } - } +/// Queued transaction +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct PendingTransaction { + /// The actual transaction + pub transaction: MaybeImpersonatedTransaction, + /// the recovered sender of this transaction + sender: Address, + /// hash of `transaction`, so it can easily be reused with encoding and hashing agan + hash: TxHash, +} - pub fn gas_limit(&self) -> U256 { - match self { - TypedTransaction::Legacy(tx) => tx.gas_limit, - TypedTransaction::EIP2930(tx) => tx.gas_limit, - TypedTransaction::EIP1559(tx) => tx.gas_limit, - TypedTransaction::Deposit(tx) => tx.gas_limit, - } +impl PendingTransaction { + pub fn new(transaction: TypedTransaction) -> Result { + let sender = transaction.recover()?; + let hash = transaction.hash(); + Ok(Self { transaction: MaybeImpersonatedTransaction::new(transaction), sender, hash }) } - pub fn value(&self) -> U256 { - match self { - TypedTransaction::Legacy(tx) => tx.value, - TypedTransaction::EIP2930(tx) => tx.value, - TypedTransaction::EIP1559(tx) => tx.value, - TypedTransaction::Deposit(tx) => tx.value, + #[cfg(feature = "impersonated-tx")] + pub fn with_impersonated(transaction: TypedTransaction, sender: Address) -> Self { + let hash = transaction.impersonated_hash(sender); + Self { + transaction: MaybeImpersonatedTransaction::impersonated(transaction, sender), + sender, + hash, } } - pub fn data(&self) -> &Bytes { - match self { - TypedTransaction::Legacy(tx) => &tx.input, - TypedTransaction::EIP2930(tx) => &tx.input, - TypedTransaction::EIP1559(tx) => &tx.input, - TypedTransaction::Deposit(tx) => &tx.input, - } + pub fn nonce(&self) -> U256 { + self.transaction.nonce() } - /// Returns the transaction type - pub fn r#type(&self) -> Option { - match self { - TypedTransaction::Legacy(_) => None, - TypedTransaction::EIP2930(_) => Some(1), - TypedTransaction::EIP1559(_) => Some(2), - TypedTransaction::Deposit(_) => Some(0x7E), - } + pub fn hash(&self) -> &TxHash { + &self.hash } - /// Max cost of the transaction - pub fn max_cost(&self) -> U256 { - self.gas_limit().saturating_mul(self.gas_price()) + pub fn sender(&self) -> &Address { + &self.sender } - /// Returns a helper type that contains commonly used values as fields - pub fn essentials(&self) -> TransactionEssentials { - match self { - TypedTransaction::Legacy(t) => TransactionEssentials { - kind: t.kind, - input: t.input.clone(), - nonce: t.nonce, - gas_limit: t.gas_limit, - gas_price: Some(t.gas_price), - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - value: t.value, - chain_id: t.chain_id(), - access_list: Default::default(), - }, - TypedTransaction::EIP2930(t) => TransactionEssentials { - kind: t.kind, - input: t.input.clone(), - nonce: t.nonce, - gas_limit: t.gas_limit, - gas_price: Some(t.gas_price), - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - value: t.value, - chain_id: Some(t.chain_id), - access_list: t.access_list.clone(), - }, - TypedTransaction::EIP1559(t) => TransactionEssentials { - kind: t.kind, - input: t.input.clone(), - nonce: t.nonce, - gas_limit: t.gas_limit, - gas_price: None, - max_fee_per_gas: Some(t.max_fee_per_gas), - max_priority_fee_per_gas: Some(t.max_priority_fee_per_gas), - value: t.value, - chain_id: Some(t.chain_id), - access_list: t.access_list.clone(), - }, - TypedTransaction::Deposit(t) => TransactionEssentials { - kind: t.kind, - input: t.input.clone(), - nonce: t.nonce, - gas_limit: t.gas_limit, - gas_price: Some(U256::from(0)), + /// Converts the [PendingTransaction] into the [TxEnv] context that [`revm`](foundry_evm) + /// expects. + pub fn to_revm_tx_env(&self) -> TxEnv { + fn transact_to(kind: &TxKind) -> TransactTo { + match kind { + TxKind::Call(c) => TransactTo::Call(*c), + TxKind::Create => TransactTo::Create(CreateScheme::Create), + } + } + + let caller = *self.sender(); + match &self.transaction.transaction { + TypedTransaction::Legacy(tx) => { + let chain_id = tx.chain_id(); + let TxLegacy { nonce, gas_price, gas_limit, value, to, input, .. } = tx.tx(); + TxEnv { + caller, + transact_to: transact_to(to), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id, + nonce: Some(*nonce), + value: (*value), + gas_price: U256::from(*gas_price), + gas_priority_fee: None, + gas_limit: *gas_limit, + access_list: vec![], + ..Default::default() + } + } + TypedTransaction::EIP2930(tx) => { + let TxEip2930 { + chain_id, + nonce, + gas_price, + gas_limit, + to, + value, + input, + access_list, + .. + } = tx.tx(); + TxEnv { + caller, + transact_to: transact_to(to), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id: Some(*chain_id), + nonce: Some(*nonce), + value: *value, + gas_price: U256::from(*gas_price), + gas_priority_fee: None, + gas_limit: *gas_limit, + access_list: eip_to_revm_access_list(access_list.0.clone()), + ..Default::default() + } + } + TypedTransaction::EIP1559(tx) => { + let TxEip1559 { + chain_id, + nonce, + max_priority_fee_per_gas, + max_fee_per_gas, + gas_limit, + to, + value, + input, + access_list, + .. + } = tx.tx(); + TxEnv { + caller, + transact_to: transact_to(to), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id: Some(*chain_id), + nonce: Some(*nonce), + value: *value, + gas_price: U256::from(*max_fee_per_gas), + gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), + gas_limit: *gas_limit, + access_list: eip_to_revm_access_list(access_list.0.clone()), + ..Default::default() + } + } + TypedTransaction::Deposit(tx) => { + let chain_id = tx.chain_id(); + let DepositTransaction { + nonce, + source_hash, + gas_limit, + value, + kind, + mint, + input, + is_system_tx, + .. + } = tx; + TxEnv { + caller, + transact_to: transact_to(kind), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id, + nonce: Some(nonce.to::()), + value: *value, + gas_price: U256::ZERO, + gas_priority_fee: None, + gas_limit: gas_limit.to::(), + access_list: vec![], + optimism: OptimismFields { + source_hash: Some(*source_hash), + mint: Some(mint.to::()), + is_system_transaction: Some(*is_system_tx), + enveloped_tx: None, + }, + ..Default::default() + } + } + } + } +} + +/// Container type for signed, typed transactions. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum TypedTransaction { + /// Legacy transaction type + Legacy(Signed), + /// EIP-2930 transaction + EIP2930(Signed), + /// EIP-1559 transaction + EIP1559(Signed), + /// op-stack deposit transaction + Deposit(DepositTransaction), +} + +impl TypedTransaction { + /// Returns true if the transaction uses dynamic fees: EIP1559 + pub fn is_dynamic_fee(&self) -> bool { + matches!(self, TypedTransaction::EIP1559(_)) + } + + pub fn gas_price(&self) -> U256 { + U256::from(match self { + TypedTransaction::Legacy(tx) => tx.gas_price, + TypedTransaction::EIP2930(tx) => tx.gas_price, + TypedTransaction::EIP1559(tx) => tx.max_fee_per_gas, + TypedTransaction::Deposit(_) => 0, + }) + } + + pub fn gas_limit(&self) -> U256 { + U256::from(match self { + TypedTransaction::Legacy(tx) => tx.gas_limit, + TypedTransaction::EIP2930(tx) => tx.gas_limit, + TypedTransaction::EIP1559(tx) => tx.gas_limit, + TypedTransaction::Deposit(tx) => tx.gas_limit.to::(), + }) + } + + pub fn value(&self) -> U256 { + U256::from(match self { + TypedTransaction::Legacy(tx) => tx.value, + TypedTransaction::EIP2930(tx) => tx.value, + TypedTransaction::EIP1559(tx) => tx.value, + TypedTransaction::Deposit(tx) => tx.value, + }) + } + + pub fn data(&self) -> &Bytes { + match self { + TypedTransaction::Legacy(tx) => &tx.input, + TypedTransaction::EIP2930(tx) => &tx.input, + TypedTransaction::EIP1559(tx) => &tx.input, + TypedTransaction::Deposit(tx) => &tx.input, + } + } + + /// Returns the transaction type + pub fn r#type(&self) -> Option { + match self { + TypedTransaction::Legacy(_) => None, + TypedTransaction::EIP2930(_) => Some(1), + TypedTransaction::EIP1559(_) => Some(2), + TypedTransaction::Deposit(_) => Some(0x7E), + } + } + + /// Max cost of the transaction + pub fn max_cost(&self) -> U256 { + self.gas_limit().saturating_mul(self.gas_price()) + } + + /// Returns a helper type that contains commonly used values as fields + pub fn essentials(&self) -> TransactionEssentials { + match self { + TypedTransaction::Legacy(t) => TransactionEssentials { + kind: t.tx().to, + input: t.input.clone(), + nonce: U256::from(t.tx().nonce), + gas_limit: U256::from(t.tx().gas_limit), + gas_price: Some(U256::from(t.tx().gas_price)), + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + value: t.value, + chain_id: t.tx().chain_id, + access_list: Default::default(), + }, + TypedTransaction::EIP2930(t) => TransactionEssentials { + kind: t.tx().to, + input: t.input.clone(), + nonce: U256::from(t.tx().nonce), + gas_limit: U256::from(t.tx().gas_limit), + gas_price: Some(U256::from(t.tx().gas_price)), + max_fee_per_gas: None, + max_priority_fee_per_gas: None, + value: t.value, + chain_id: Some(t.chain_id), + access_list: to_alloy_access_list(t.access_list.clone()), + }, + TypedTransaction::EIP1559(t) => TransactionEssentials { + kind: t.to, + input: t.input.clone(), + nonce: U256::from(t.nonce), + gas_limit: U256::from(t.gas_limit), + gas_price: None, + max_fee_per_gas: Some(U256::from(t.max_fee_per_gas)), + max_priority_fee_per_gas: Some(U256::from(t.max_priority_fee_per_gas)), + value: t.value, + chain_id: Some(t.chain_id), + access_list: to_alloy_access_list(t.access_list.clone()), + }, + TypedTransaction::Deposit(t) => TransactionEssentials { + kind: t.kind, + input: t.input.clone(), + nonce: t.nonce, + gas_limit: t.gas_limit, + gas_price: Some(U256::from(0)), max_fee_per_gas: None, max_priority_fee_per_gas: None, value: t.value, @@ -744,25 +860,25 @@ impl TypedTransaction { } } - pub fn nonce(&self) -> &U256 { + pub fn nonce(&self) -> U256 { match self { - TypedTransaction::Legacy(t) => t.nonce(), - TypedTransaction::EIP2930(t) => t.nonce(), - TypedTransaction::EIP1559(t) => t.nonce(), - TypedTransaction::Deposit(t) => t.nonce(), + TypedTransaction::Legacy(t) => U256::from(t.nonce), + TypedTransaction::EIP2930(t) => U256::from(t.nonce), + TypedTransaction::EIP1559(t) => U256::from(t.nonce), + TypedTransaction::Deposit(t) => U256::from(t.nonce), } } pub fn chain_id(&self) -> Option { match self { - TypedTransaction::Legacy(t) => t.chain_id(), + TypedTransaction::Legacy(t) => t.chain_id, TypedTransaction::EIP2930(t) => Some(t.chain_id), TypedTransaction::EIP1559(t) => Some(t.chain_id), TypedTransaction::Deposit(t) => t.chain_id(), } } - pub fn as_legacy(&self) -> Option<&LegacyTransaction> { + pub fn as_legacy(&self) -> Option<&Signed> { match self { TypedTransaction::Legacy(tx) => Some(tx), _ => None, @@ -783,11 +899,11 @@ impl TypedTransaction { /// /// Note: If this transaction has the Impersonated signature then this returns a modified unique /// hash. This allows us to treat impersonated transactions as unique. - pub fn hash(&self) -> H256 { + pub fn hash(&self) -> B256 { match self { - TypedTransaction::Legacy(t) => t.hash(), - TypedTransaction::EIP2930(t) => t.hash(), - TypedTransaction::EIP1559(t) => t.hash(), + TypedTransaction::Legacy(t) => *t.hash(), + TypedTransaction::EIP2930(t) => *t.hash(), + TypedTransaction::EIP1559(t) => *t.hash(), TypedTransaction::Deposit(t) => t.hash(), } } @@ -795,168 +911,83 @@ impl TypedTransaction { /// Returns true if the transaction was impersonated (using the impersonate Signature) #[cfg(feature = "impersonated-tx")] pub fn is_impersonated(&self) -> bool { - to_alloy_signature(self.signature()) == IMPERSONATED_SIGNATURE + self.signature() == impersonated_signature() } /// Returns the hash if the transaction is impersonated (using a fake signature) /// /// This appends the `address` before hashing it #[cfg(feature = "impersonated-tx")] - pub fn impersonated_hash(&self, sender: Address) -> H256 { - let mut bytes = rlp::encode(self); - bytes.extend_from_slice(sender.as_ref()); - H256::from_slice(keccak256(&bytes).as_slice()) + pub fn impersonated_hash(&self, sender: Address) -> B256 { + let mut buffer = Vec::::new(); + Encodable::encode(self, &mut buffer); + buffer.extend_from_slice(sender.as_ref()); + B256::from_slice(alloy_primitives::utils::keccak256(&buffer).as_slice()) } /// Recovers the Ethereum address which was used to sign the transaction. - pub fn recover(&self) -> Result { + pub fn recover(&self) -> Result { match self { - TypedTransaction::Legacy(tx) => tx.recover(), - TypedTransaction::EIP2930(tx) => tx.recover(), - TypedTransaction::EIP1559(tx) => tx.recover(), + TypedTransaction::Legacy(tx) => tx.recover_signer(), + TypedTransaction::EIP2930(tx) => tx.recover_signer(), + TypedTransaction::EIP1559(tx) => tx.recover_signer(), TypedTransaction::Deposit(tx) => tx.recover(), } } /// Returns what kind of transaction this is - pub fn kind(&self) -> &TransactionKind { + pub fn kind(&self) -> &TxKind { match self { - TypedTransaction::Legacy(tx) => &tx.kind, - TypedTransaction::EIP2930(tx) => &tx.kind, - TypedTransaction::EIP1559(tx) => &tx.kind, + TypedTransaction::Legacy(tx) => &tx.to, + TypedTransaction::EIP2930(tx) => &tx.to, + TypedTransaction::EIP1559(tx) => &tx.to, TypedTransaction::Deposit(tx) => &tx.kind, } } /// Returns the callee if this transaction is a call - pub fn to(&self) -> Option<&Address> { - self.kind().as_call() + pub fn to(&self) -> Option
{ + self.kind().to() } /// Returns the Signature of the transaction pub fn signature(&self) -> Signature { match self { - TypedTransaction::Legacy(tx) => tx.signature, - TypedTransaction::EIP2930(tx) => { - let v = tx.odd_y_parity as u8; - let r = U256::from_big_endian(&tx.r[..]); - let s = U256::from_big_endian(&tx.s[..]); - Signature { r, s, v: v.into() } - } - TypedTransaction::EIP1559(tx) => { - let v = tx.odd_y_parity as u8; - let r = U256::from_big_endian(&tx.r[..]); - let s = U256::from_big_endian(&tx.s[..]); - Signature { r, s, v: v.into() } - } - TypedTransaction::Deposit(_) => Signature { r: U256::zero(), s: U256::zero(), v: 0 }, + TypedTransaction::Legacy(tx) => *tx.signature(), + TypedTransaction::EIP2930(tx) => *tx.signature(), + TypedTransaction::EIP1559(tx) => *tx.signature(), + TypedTransaction::Deposit(_) => Signature::from_scalars_and_parity( + B256::with_last_byte(1), + B256::with_last_byte(1), + false, + ) + .unwrap(), } } } impl Encodable for TypedTransaction { - fn rlp_append(&self, s: &mut RlpStream) { - match self { - TypedTransaction::Legacy(tx) => tx.rlp_append(s), - TypedTransaction::EIP2930(tx) => enveloped(1, tx, s), - TypedTransaction::EIP1559(tx) => enveloped(2, tx, s), - TypedTransaction::Deposit(tx) => enveloped(0x7E, tx, s), - } - } -} - -impl Decodable for TypedTransaction { - fn decode(rlp: &Rlp) -> Result { - if rlp.is_list() { - return Ok(TypedTransaction::Legacy(rlp.as_val()?)) - } - let [first, s @ ..] = rlp.data()? else { - return Err(DecoderError::Custom("empty slice")); - }; - // "advance" the header, see comments in fastrlp impl below - let s = if s.is_empty() { &rlp.as_raw()[1..] } else { s }; - - match *first { - 0x01 => rlp::decode(s).map(TypedTransaction::EIP2930), - 0x02 => rlp::decode(s).map(TypedTransaction::EIP1559), - 0x7E => rlp::decode(s).map(TypedTransaction::Deposit), - _ => Err(DecoderError::Custom("invalid tx type")), - } - } -} - -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Encodable for TypedTransaction { - fn encode(&self, out: &mut dyn open_fastrlp::BufMut) { + fn encode(&self, out: &mut dyn bytes::BufMut) { match self { TypedTransaction::Legacy(tx) => tx.encode(out), - tx => { - let payload_len = match tx { - TypedTransaction::EIP2930(tx) => tx.length() + 1, - TypedTransaction::EIP1559(tx) => tx.length() + 1, - TypedTransaction::Deposit(tx) => tx.length() + 1, - _ => unreachable!("legacy tx length already matched"), - }; - - match tx { - TypedTransaction::EIP2930(tx) => { - let tx_string_header = - open_fastrlp::Header { list: false, payload_length: payload_len }; - - tx_string_header.encode(out); - out.put_u8(0x01); - tx.encode(out); - } - TypedTransaction::EIP1559(tx) => { - let tx_string_header = - open_fastrlp::Header { list: false, payload_length: payload_len }; - - tx_string_header.encode(out); - out.put_u8(0x02); - tx.encode(out); - } - TypedTransaction::Deposit(tx) => { - let tx_string_header = - open_fastrlp::Header { list: false, payload_length: payload_len }; - - tx_string_header.encode(out); - out.put_u8(0x7E); - tx.encode(out); - } - _ => unreachable!("legacy tx encode already matched"), - } - } - } - } - fn length(&self) -> usize { - match self { - TypedTransaction::Legacy(tx) => tx.length(), - tx => { - let payload_len = match tx { - TypedTransaction::EIP2930(tx) => tx.length() + 1, - TypedTransaction::EIP1559(tx) => tx.length() + 1, - TypedTransaction::Deposit(tx) => tx.length() + 1, - _ => unreachable!("legacy tx length already matched"), - }; - // we include a string header for signed types txs, so include the length here - payload_len + open_fastrlp::length_of_length(payload_len) - } + TypedTransaction::EIP2930(tx) => tx.encode(out), + TypedTransaction::EIP1559(tx) => tx.encode(out), + TypedTransaction::Deposit(tx) => tx.encode(out), } } } -#[cfg(feature = "fastrlp")] -impl open_fastrlp::Decodable for TypedTransaction { - fn decode(buf: &mut &[u8]) -> Result { +impl Decodable for TypedTransaction { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { use bytes::Buf; use std::cmp::Ordering; - let first = *buf.first().ok_or(open_fastrlp::DecodeError::Custom("empty slice"))?; + let first = *buf.first().ok_or(alloy_rlp::Error::Custom("empty slice"))?; // a signed transaction is either encoded as a string (non legacy) or a list (legacy). // We should not consume the buffer if we are decoding a legacy transaction, so let's // check if the first byte is between 0x80 and 0xbf. - match first.cmp(&open_fastrlp::EMPTY_LIST_CODE) { + match first.cmp(&alloy_rlp::EMPTY_LIST_CODE) { Ordering::Less => { // strip out the string header // NOTE: typed transaction encodings either contain a "rlp header" which contains @@ -969,581 +1000,277 @@ impl open_fastrlp::Decodable for TypedTransaction { // If the encoding includes a header, the header will be properly decoded and // consumed. // Otherwise, header decoding will succeed but nothing is consumed. - let _header = open_fastrlp::Header::decode(buf)?; - let tx_type = *buf.first().ok_or(open_fastrlp::DecodeError::Custom( + let _header = alloy_rlp::Header::decode(buf)?; + let tx_type = *buf.first().ok_or(alloy_rlp::Error::Custom( "typed tx cannot be decoded from an empty slice", ))?; if tx_type == 0x01 { buf.advance(1); - ::decode(buf) - .map(TypedTransaction::EIP2930) + as Decodable>::decode(buf).map(TypedTransaction::EIP2930) } else if tx_type == 0x02 { buf.advance(1); - ::decode(buf) - .map(TypedTransaction::EIP1559) + as Decodable>::decode(buf).map(TypedTransaction::EIP1559) } else if tx_type == 0x7E { buf.advance(1); - ::decode(buf) - .map(TypedTransaction::Deposit) + ::decode(buf).map(TypedTransaction::Deposit) } else { - Err(open_fastrlp::DecodeError::Custom("invalid tx type")) + Err(alloy_rlp::Error::Custom("invalid tx type")) } } - Ordering::Equal => Err(open_fastrlp::DecodeError::Custom( - "an empty list is not a valid transaction encoding", - )), - Ordering::Greater => ::decode(buf) - .map(TypedTransaction::Legacy), + Ordering::Equal => { + Err(alloy_rlp::Error::Custom("an empty list is not a valid transaction encoding")) + } + Ordering::Greater => { + as Decodable>::decode(buf).map(TypedTransaction::Legacy) + } } } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LegacyTransaction { +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct TransactionEssentials { + pub kind: TxKind, + pub input: Bytes, pub nonce: U256, - pub gas_price: U256, pub gas_limit: U256, - pub kind: TransactionKind, + pub gas_price: Option, + pub max_fee_per_gas: Option, + pub max_priority_fee_per_gas: Option, pub value: U256, - pub input: Bytes, - pub signature: Signature, + pub chain_id: Option, + pub access_list: AccessList, } -impl LegacyTransaction { - pub fn nonce(&self) -> &U256 { - &self.nonce - } - - pub fn hash(&self) -> H256 { - H256::from_slice(keccak256(&rlp::encode(self)).as_slice()) - } +/// Represents all relevant information of an executed transaction +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct TransactionInfo { + pub transaction_hash: B256, + pub transaction_index: u32, + pub from: Address, + pub to: Option
, + pub contract_address: Option
, + pub logs: Vec, + pub logs_bloom: Bloom, + pub traces: Vec, + pub exit: InstructionResult, + pub out: Option, + pub nonce: u64, +} - /// Recovers the Ethereum address which was used to sign the transaction. - pub fn recover(&self) -> Result { - self.signature.recover(LegacyTransactionRequest::from(self.clone()).hash()) - } +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum TypedReceipt { + Legacy(ReceiptWithBloom), + EIP2930(ReceiptWithBloom), + EIP1559(ReceiptWithBloom), + Deposit(ReceiptWithBloom), +} - pub fn chain_id(&self) -> Option { - if self.signature.v > 36 { - Some((self.signature.v - 35) / 2) - } else { - None +impl TypedReceipt { + pub fn gas_used(&self) -> U256 { + match self { + TypedReceipt::Legacy(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::Deposit(r) => U256::from(r.receipt.cumulative_gas_used), } } - /// See - /// > If you do, then the v of the signature MUST be set to {0,1} + CHAIN_ID * 2 + 35 where - /// > {0,1} is the parity of the y value of the curve point for which r is the x-value in the - /// > secp256k1 signing process. - pub fn meets_eip155(&self, chain_id: u64) -> bool { - let double_chain_id = chain_id.saturating_mul(2); - let v = self.signature.v; - v == double_chain_id + 35 || v == double_chain_id + 36 + pub fn logs_bloom(&self) -> &Bloom { + match self { + TypedReceipt::Legacy(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::Deposit(r) => &r.bloom, + } } } -impl Encodable for LegacyTransaction { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(9); - s.append(&self.nonce); - s.append(&self.gas_price); - s.append(&self.gas_limit); - s.append(&self.kind); - s.append(&self.value); - s.append(&self.input.as_ref()); - s.append(&self.signature.v); - s.append(&self.signature.r); - s.append(&self.signature.s); +impl From for ReceiptWithBloom { + fn from(val: TypedReceipt) -> Self { + match val { + TypedReceipt::Legacy(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::Deposit(r) => r, + } } } -impl Decodable for LegacyTransaction { - fn decode(rlp: &Rlp) -> Result { - if rlp.item_count()? != 9 { - return Err(DecoderError::RlpIncorrectListLen) - } +impl Encodable for TypedReceipt { + fn encode(&self, out: &mut dyn bytes::BufMut) { + use alloy_rlp::Header; - let v = rlp.val_at(6)?; - let r = rlp.val_at::(7)?; - let s = rlp.val_at::(8)?; - - Ok(Self { - nonce: rlp.val_at(0)?, - gas_price: rlp.val_at(1)?, - gas_limit: rlp.val_at(2)?, - kind: rlp.val_at(3)?, - value: rlp.val_at(4)?, - input: rlp.val_at::>(5)?.into(), - signature: Signature { v, r, s }, - }) + match self { + TypedReceipt::Legacy(r) => r.encode(out), + receipt => { + let payload_len = match receipt { + TypedReceipt::EIP2930(r) => r.length() + 1, + TypedReceipt::EIP1559(r) => r.length() + 1, + TypedReceipt::Deposit(r) => r.length() + 1, + _ => unreachable!("receipt already matched"), + }; + + match receipt { + TypedReceipt::EIP2930(r) => { + Header { list: true, payload_length: payload_len }.encode(out); + 1u8.encode(out); + r.encode(out); + } + TypedReceipt::EIP1559(r) => { + Header { list: true, payload_length: payload_len }.encode(out); + 2u8.encode(out); + r.encode(out); + } + TypedReceipt::Deposit(r) => { + Header { list: true, payload_length: payload_len }.encode(out); + 0x7Eu8.encode(out); + r.encode(out); + } + _ => unreachable!("receipt already matched"), + } + } + } } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EIP2930Transaction { - pub chain_id: u64, - pub nonce: U256, - pub gas_price: U256, - pub gas_limit: U256, - pub kind: TransactionKind, - pub value: U256, - pub input: Bytes, - pub access_list: AccessList, - pub odd_y_parity: bool, - pub r: H256, - pub s: H256, -} - -impl EIP2930Transaction { - pub fn nonce(&self) -> &U256 { - &self.nonce - } - - pub fn hash(&self) -> H256 { - let encoded = rlp::encode(self); - let mut out = vec![0; 1 + encoded.len()]; - out[0] = 1; - out[1..].copy_from_slice(&encoded); - H256::from_slice(keccak256(&out).as_slice()) - } - - /// Recovers the Ethereum address which was used to sign the transaction. - pub fn recover(&self) -> Result { - let mut sig = [0u8; 65]; - sig[0..32].copy_from_slice(&self.r[..]); - sig[32..64].copy_from_slice(&self.s[..]); - sig[64] = self.odd_y_parity as u8; - let signature = Signature::try_from(&sig[..])?; - signature.recover(EIP2930TransactionRequest::from(self.clone()).hash()) - } -} - -impl Encodable for EIP2930Transaction { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(11); - s.append(&self.chain_id); - s.append(&self.nonce); - s.append(&self.gas_price); - s.append(&self.gas_limit); - s.append(&self.kind); - s.append(&self.value); - s.append(&self.input.as_ref()); - s.append(&self.access_list); - s.append(&self.odd_y_parity); - s.append(&U256::from_big_endian(&self.r[..])); - s.append(&U256::from_big_endian(&self.s[..])); - } -} - -impl Decodable for EIP2930Transaction { - fn decode(rlp: &Rlp) -> Result { - if rlp.item_count()? != 11 { - return Err(DecoderError::RlpIncorrectListLen) - } - - Ok(Self { - chain_id: rlp.val_at(0)?, - nonce: rlp.val_at(1)?, - gas_price: rlp.val_at(2)?, - gas_limit: rlp.val_at(3)?, - kind: rlp.val_at(4)?, - value: rlp.val_at(5)?, - input: rlp.val_at::>(6)?.into(), - access_list: rlp.val_at(7)?, - odd_y_parity: rlp.val_at(8)?, - r: { - let mut rarr = [0u8; 32]; - rlp.val_at::(9)?.to_big_endian(&mut rarr); - H256::from(rarr) - }, - s: { - let mut sarr = [0u8; 32]; - rlp.val_at::(10)?.to_big_endian(&mut sarr); - H256::from(sarr) - }, - }) - } -} - -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct EIP1559Transaction { - pub chain_id: u64, - pub nonce: U256, - pub max_priority_fee_per_gas: U256, - pub max_fee_per_gas: U256, - pub gas_limit: U256, - pub kind: TransactionKind, - pub value: U256, - pub input: Bytes, - pub access_list: AccessList, - pub odd_y_parity: bool, - pub r: H256, - pub s: H256, -} - -impl EIP1559Transaction { - pub fn nonce(&self) -> &U256 { - &self.nonce - } - - pub fn hash(&self) -> H256 { - let encoded = rlp::encode(self); - let mut out = vec![0; 1 + encoded.len()]; - out[0] = 2; - out[1..].copy_from_slice(&encoded); - H256::from_slice(keccak256(&out).as_slice()) - } - - /// Recovers the Ethereum address which was used to sign the transaction. - pub fn recover(&self) -> Result { - let mut sig = [0u8; 65]; - sig[0..32].copy_from_slice(&self.r[..]); - sig[32..64].copy_from_slice(&self.s[..]); - sig[64] = self.odd_y_parity as u8; - let signature = Signature::try_from(&sig[..])?; - signature.recover(EIP1559TransactionRequest::from(self.clone()).hash()) - } -} +impl Decodable for TypedReceipt { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + use alloy_rlp::Header; + use bytes::Buf; + use std::cmp::Ordering; -impl Encodable for EIP1559Transaction { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(12); - s.append(&self.chain_id); - s.append(&self.nonce); - s.append(&self.max_priority_fee_per_gas); - s.append(&self.max_fee_per_gas); - s.append(&self.gas_limit); - s.append(&self.kind); - s.append(&self.value); - s.append(&self.input.as_ref()); - s.append(&self.access_list); - s.append(&self.odd_y_parity); - s.append(&U256::from_big_endian(&self.r[..])); - s.append(&U256::from_big_endian(&self.s[..])); - } -} + // a receipt is either encoded as a string (non legacy) or a list (legacy). + // We should not consume the buffer if we are decoding a legacy receipt, so let's + // check if the first byte is between 0x80 and 0xbf. + let rlp_type = *buf + .first() + .ok_or(alloy_rlp::Error::Custom("cannot decode a receipt from empty bytes"))?; -impl Decodable for EIP1559Transaction { - fn decode(rlp: &Rlp) -> Result { - if rlp.item_count()? != 12 { - return Err(DecoderError::RlpIncorrectListLen) + match rlp_type.cmp(&alloy_rlp::EMPTY_LIST_CODE) { + Ordering::Less => { + // strip out the string header + let _header = Header::decode(buf)?; + let receipt_type = *buf.first().ok_or(alloy_rlp::Error::Custom( + "typed receipt cannot be decoded from an empty slice", + ))?; + if receipt_type == 0x01 { + buf.advance(1); + ::decode(buf).map(TypedReceipt::EIP2930) + } else if receipt_type == 0x02 { + buf.advance(1); + ::decode(buf).map(TypedReceipt::EIP1559) + } else if receipt_type == 0x7E { + buf.advance(1); + ::decode(buf).map(TypedReceipt::Deposit) + } else { + Err(alloy_rlp::Error::Custom("invalid receipt type")) + } + } + Ordering::Equal => { + Err(alloy_rlp::Error::Custom("an empty list is not a valid receipt encoding")) + } + Ordering::Greater => { + ::decode(buf).map(TypedReceipt::Legacy) + } } - - Ok(Self { - chain_id: rlp.val_at(0)?, - nonce: rlp.val_at(1)?, - max_priority_fee_per_gas: rlp.val_at(2)?, - max_fee_per_gas: rlp.val_at(3)?, - gas_limit: rlp.val_at(4)?, - kind: rlp.val_at(5)?, - value: rlp.val_at(6)?, - input: rlp.val_at::>(7)?.into(), - access_list: rlp.val_at(8)?, - odd_y_parity: rlp.val_at(9)?, - r: { - let mut rarr = [0u8; 32]; - rlp.val_at::(10)?.to_big_endian(&mut rarr); - H256::from(rarr) - }, - s: { - let mut sarr = [0u8; 32]; - rlp.val_at::(11)?.to_big_endian(&mut sarr); - H256::from(sarr) - }, - }) } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "fastrlp", derive(open_fastrlp::RlpEncodable, open_fastrlp::RlpDecodable))] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - -pub struct DepositTransaction { - pub nonce: U256, - pub source_hash: H256, - pub from: Address, - pub kind: TransactionKind, - pub mint: U256, - pub value: U256, - pub gas_limit: U256, - pub is_system_tx: bool, - pub input: Bytes, +/// Translates an EIP-2930 access list to an alloy-rpc-types access list. +pub fn to_alloy_access_list( + access_list: alloy_eips::eip2930::AccessList, +) -> alloy_rpc_types::AccessList { + alloy_rpc_types::AccessList( + access_list + .0 + .into_iter() + .map(|item| alloy_rpc_types::AccessListItem { + address: item.address, + storage_keys: item.storage_keys, + }) + .collect(), + ) } -impl DepositTransaction { - pub fn nonce(&self) -> &U256 { - &self.nonce - } - - pub fn hash(&self) -> H256 { - H256::from_slice(keccak256(&rlp::encode(self)).as_slice()) - } - - /// Recovers the Ethereum address which was used to sign the transaction. - pub fn recover(&self) -> Result { - Ok(self.from) - } - - pub fn chain_id(&self) -> Option { - None - } +/// Translates an alloy-rpc-types access list to an EIP-2930 access list. +pub fn to_eip_access_list( + access_list: alloy_rpc_types::AccessList, +) -> alloy_eips::eip2930::AccessList { + alloy_eips::eip2930::AccessList( + access_list + .0 + .into_iter() + .map(|item| alloy_eips::eip2930::AccessListItem { + address: item.address, + storage_keys: item.storage_keys, + }) + .collect(), + ) } -impl Encodable for DepositTransaction { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(9); - s.append(&self.nonce); - s.append(&self.source_hash); - s.append(&self.from); - s.append(&self.kind); - s.append(&self.mint); - s.append(&self.value); - s.append(&self.gas_limit); - s.append(&self.is_system_tx); - s.append(&self.input.as_ref()); - } -} - -impl Decodable for DepositTransaction { - fn decode(rlp: &Rlp) -> Result { - if rlp.item_count()? != 8 { - return Err(DecoderError::RlpIncorrectListLen) - } - - Ok(Self { - source_hash: rlp.val_at(0)?, - from: rlp.val_at(1)?, - kind: rlp.val_at(2)?, - mint: rlp.val_at(3)?, - value: rlp.val_at(4)?, - gas_limit: rlp.val_at(5)?, - is_system_tx: rlp.val_at(6)?, - input: rlp.val_at::>(7)?.into(), - nonce: U256::from(0), - }) - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct TransactionEssentials { - pub kind: TransactionKind, - pub input: Bytes, - pub nonce: U256, - pub gas_limit: U256, - pub gas_price: Option, - pub max_fee_per_gas: Option, - pub max_priority_fee_per_gas: Option, - pub value: U256, - pub chain_id: Option, - pub access_list: AccessList, -} - -/// Queued transaction -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct PendingTransaction { - /// The actual transaction - pub transaction: MaybeImpersonatedTransaction, - /// the recovered sender of this transaction - sender: Address, - /// hash of `transaction`, so it can easily be reused with encoding and hashing agan - hash: TxHash, -} +#[cfg(test)] +mod tests { + use alloy_consensus::Receipt; + use alloy_primitives::{b256, hex, LogData, Signature}; + use std::str::FromStr; -// == impl PendingTransaction == + use super::*; -impl PendingTransaction { - /// Creates a new pending transaction and tries to verify transaction and recover sender. - pub fn new(transaction: TypedTransaction) -> Result { - let sender = transaction.recover()?; - Ok(Self { hash: transaction.hash(), transaction: transaction.into(), sender }) - } + #[test] + fn test_decode_call() { + let bytes_first = &mut &hex::decode("f86b02843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba00eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5aea03a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18").unwrap()[..]; + let decoded = TypedTransaction::decode(&mut &bytes_first[..]).unwrap(); - /// Creates a new transaction with the given sender. - /// - /// In order to prevent collisions from multiple different impersonated accounts, we update the - /// transaction's hash with the address to make it unique. - /// - /// See: - #[cfg(feature = "impersonated-tx")] - pub fn with_impersonated(transaction: TypedTransaction, sender: Address) -> Self { - let hash = transaction.impersonated_hash(sender); - let transaction = MaybeImpersonatedTransaction::impersonated(transaction, sender); - Self { hash, transaction, sender } - } + let tx = TxLegacy { + nonce: 2u64, + gas_price: 1000000000u64.into(), + gas_limit: 100000u64, + to: TxKind::Call(Address::from_slice( + &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], + )), + value: U256::from(1000000000000000u64), + input: Bytes::default(), + chain_id: Some(4), + }; - pub fn nonce(&self) -> &U256 { - self.transaction.nonce() - } + let signature = Signature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap(); - pub fn hash(&self) -> &TxHash { - &self.hash - } + let tx = TypedTransaction::Legacy(Signed::new_unchecked( + tx.clone(), + signature, + b256!("a517b206d2223278f860ea017d3626cacad4f52ff51030dc9a96b432f17f8d34"), + )); - pub fn sender(&self) -> &Address { - &self.sender + assert_eq!(tx, decoded); } - /// Converts the [PendingTransaction] into the [TxEnv] context that [`revm`](foundry_evm) - /// expects. - pub fn to_revm_tx_env(&self) -> TxEnv { - fn transact_to(kind: &TransactionKind) -> TransactTo { - match kind { - TransactionKind::Call(c) => TransactTo::Call((*c).to_alloy()), - TransactionKind::Create => TransactTo::Create(CreateScheme::Create), - } - } - - let caller = *self.sender(); - match &self.transaction.transaction { - TypedTransaction::Legacy(tx) => { - let chain_id = tx.chain_id(); - let LegacyTransaction { nonce, gas_price, gas_limit, value, kind, input, .. } = tx; - TxEnv { - caller: caller.to_alloy(), - transact_to: transact_to(kind), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id, - nonce: Some(nonce.as_u64()), - value: (*value).to_alloy(), - gas_price: (*gas_price).to_alloy(), - gas_priority_fee: None, - gas_limit: gas_limit.as_u64(), - access_list: vec![], - ..Default::default() - } - } - TypedTransaction::EIP2930(tx) => { - let EIP2930Transaction { - chain_id, - nonce, - gas_price, - gas_limit, - kind, - value, - input, - access_list, - .. - } = tx; - TxEnv { - caller: (caller).to_alloy(), - transact_to: transact_to(kind), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id: Some(*chain_id), - nonce: Some(nonce.as_u64()), - value: (*value).to_alloy(), - gas_price: (*gas_price).to_alloy(), - gas_priority_fee: None, - gas_limit: gas_limit.as_u64(), - access_list: to_revm_access_list(access_list.0.clone()), - ..Default::default() - } - } - TypedTransaction::EIP1559(tx) => { - let EIP1559Transaction { - chain_id, - nonce, - max_priority_fee_per_gas, - max_fee_per_gas, - gas_limit, - kind, - value, - input, - access_list, - .. - } = tx; - TxEnv { - caller: (caller).to_alloy(), - transact_to: transact_to(kind), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id: Some(*chain_id), - nonce: Some(nonce.as_u64()), - value: (*value).to_alloy(), - gas_price: (*max_fee_per_gas).to_alloy(), - gas_priority_fee: Some((*max_priority_fee_per_gas).to_alloy()), - gas_limit: gas_limit.as_u64(), - access_list: to_revm_access_list(access_list.0.clone()), - ..Default::default() - } - } - TypedTransaction::Deposit(tx) => { - let chain_id = tx.chain_id(); - let DepositTransaction { - nonce, - source_hash, - gas_limit, - value, - kind, - mint, - input, - is_system_tx, - .. - } = tx; - TxEnv { - caller: caller.to_alloy(), - transact_to: transact_to(kind), - data: alloy_primitives::Bytes(input.0.clone()), - chain_id, - nonce: Some(nonce.as_u64()), - value: (*value).to_alloy(), - gas_price: 0.to_alloy(), - gas_priority_fee: None, - gas_limit: gas_limit.as_u64(), - access_list: vec![], - optimism: OptimismFields { - source_hash: Some(source_hash.to_alloy()), - mint: Some(mint.as_u128()), - is_system_transaction: Some(*is_system_tx), - enveloped_tx: None, - }, - ..Default::default() - } - } - } + #[test] + fn test_decode_create_goerli() { + // test that an example create tx from goerli decodes properly + let tx_bytes = + hex::decode("02f901ee05228459682f008459682f11830209bf8080b90195608060405234801561001057600080fd5b50610175806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80630c49c36c14610030575b600080fd5b61003861004e565b604051610045919061011d565b60405180910390f35b60606020600052600f6020527f68656c6c6f2073746174656d696e64000000000000000000000000000000000060405260406000f35b600081519050919050565b600082825260208201905092915050565b60005b838110156100be5780820151818401526020810190506100a3565b838111156100cd576000848401525b50505050565b6000601f19601f8301169050919050565b60006100ef82610084565b6100f9818561008f565b93506101098185602086016100a0565b610112816100d3565b840191505092915050565b6000602082019050818103600083015261013781846100e4565b90509291505056fea264697066735822122051449585839a4ea5ac23cae4552ef8a96b64ff59d0668f76bfac3796b2bdbb3664736f6c63430008090033c080a0136ebffaa8fc8b9fda9124de9ccb0b1f64e90fbd44251b4c4ac2501e60b104f9a07eb2999eec6d185ef57e91ed099afb0a926c5b536f0155dd67e537c7476e1471") + .unwrap(); + let _decoded = TypedTransaction::decode(&mut &tx_bytes[..]).unwrap(); } -} - -/// Represents all relevant information of an executed transaction -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct TransactionInfo { - pub transaction_hash: H256, - pub transaction_index: u32, - pub from: Address, - pub to: Option
, - pub contract_address: Option
, - pub logs: Vec, - pub logs_bloom: Bloom, - pub traces: Vec, - pub exit: InstructionResult, - pub out: Option, - pub nonce: u64, -} - -#[cfg(test)] -mod tests { - use super::*; - use ethers_core::utils::hex; #[test] fn can_recover_sender() { // random mainnet tx: https://etherscan.io/tx/0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f let bytes = hex::decode("02f872018307910d808507204d2cb1827d0094388c818ca8b9251b393131c08a736a67ccb19297880320d04823e2701c80c001a0cf024f4815304df2867a1a74e9d2707b6abda0337d2d54a4438d453f4160f190a07ac0e6b3bc9395b5b9c8b9e6d77204a236577a5b18467b9175c01de4faa208d9").unwrap(); - let Ok(TypedTransaction::EIP1559(tx)) = rlp::decode(&bytes) else { + let Ok(TypedTransaction::EIP1559(tx)) = TypedTransaction::decode(&mut &bytes[..]) else { panic!("decoding TypedTransaction failed"); }; + assert_eq!( tx.hash(), - "0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f".parse().unwrap() + &"0x86718885c4b4218c6af87d3d0b0d83e3cc465df2a05c048aa4db9f1a6f9de91f" + .parse::() + .unwrap() ); assert_eq!( - tx.recover().unwrap(), - "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5".parse().unwrap() + tx.recover_signer().unwrap(), + "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5".parse::
().unwrap() ); } @@ -1551,278 +1278,95 @@ mod tests { fn can_recover_sender_not_normalized() { let bytes = hex::decode("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap(); - let tx: TypedTransaction = rlp::decode(&bytes).expect("decoding TypedTransaction failed"); - let tx = match tx { - TypedTransaction::Legacy(tx) => tx, - _ => panic!("Invalid typed transaction"), + let Ok(TypedTransaction::Legacy(tx)) = TypedTransaction::decode(&mut &bytes[..]) else { + panic!("decoding TypedTransaction failed"); }; + assert_eq!(tx.input, Bytes::from(b"")); - assert_eq!(tx.gas_price, U256::from(0x01u64)); - assert_eq!(tx.gas_limit, U256::from(0x5208u64)); - assert_eq!(tx.nonce, U256::from(0x00u64)); - if let TransactionKind::Call(ref to) = tx.kind { - assert_eq!(*to, "095e7baea6a6c7c4c2dfeb977efac326af552d87".parse().unwrap()); + assert_eq!(tx.gas_price, 1); + assert_eq!(tx.gas_limit, 21000); + assert_eq!(tx.nonce, 0); + if let TxKind::Call(to) = tx.to { + assert_eq!( + to, + "0x095e7baea6a6c7c4c2dfeb977efac326af552d87".parse::
().unwrap() + ); } else { - panic!(); + panic!("expected a call transaction"); } assert_eq!(tx.value, U256::from(0x0au64)); assert_eq!( - tx.recover().unwrap(), - "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse().unwrap() + tx.recover_signer().unwrap(), + "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse::
().unwrap() ); } #[test] - #[cfg(feature = "fastrlp")] - fn test_decode_fastrlp_create() { - use bytes::BytesMut; - use open_fastrlp::Encodable; - - // tests that a contract creation tx encodes and decodes properly - - let tx = TypedTransaction::EIP2930(EIP2930Transaction { - chain_id: 1u64, - nonce: U256::from(0), - gas_price: U256::from(1), - gas_limit: U256::from(2), - kind: TransactionKind::Create, - value: U256::from(3), - input: Bytes::from(vec![1, 2]), - odd_y_parity: true, - r: H256::default(), - s: H256::default(), - access_list: vec![].into(), - }); - - let mut encoded = BytesMut::new(); - tx.encode(&mut encoded); - - let decoded = - ::decode(&mut &*encoded).unwrap(); - assert_eq!(decoded, tx); - } - - #[test] - #[cfg(feature = "fastrlp")] - fn test_decode_fastrlp_create_goerli() { - // test that an example create tx from goerli decodes properly - let tx_bytes = - hex::decode("02f901ee05228459682f008459682f11830209bf8080b90195608060405234801561001057600080fd5b50610175806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80630c49c36c14610030575b600080fd5b61003861004e565b604051610045919061011d565b60405180910390f35b60606020600052600f6020527f68656c6c6f2073746174656d696e64000000000000000000000000000000000060405260406000f35b600081519050919050565b600082825260208201905092915050565b60005b838110156100be5780820151818401526020810190506100a3565b838111156100cd576000848401525b50505050565b6000601f19601f8301169050919050565b60006100ef82610084565b6100f9818561008f565b93506101098185602086016100a0565b610112816100d3565b840191505092915050565b6000602082019050818103600083015261013781846100e4565b90509291505056fea264697066735822122051449585839a4ea5ac23cae4552ef8a96b64ff59d0668f76bfac3796b2bdbb3664736f6c63430008090033c080a0136ebffaa8fc8b9fda9124de9ccb0b1f64e90fbd44251b4c4ac2501e60b104f9a07eb2999eec6d185ef57e91ed099afb0a926c5b536f0155dd67e537c7476e1471") - .unwrap(); - let _decoded = - ::decode(&mut &tx_bytes[..]).unwrap(); - } - - #[test] - #[cfg(feature = "fastrlp")] - fn test_decode_fastrlp_call() { - use bytes::BytesMut; - use open_fastrlp::Encodable; - - let tx = TypedTransaction::EIP2930(EIP2930Transaction { - chain_id: 1u64, - nonce: U256::from(0), - gas_price: U256::from(1), - gas_limit: U256::from(2), - kind: TransactionKind::Call(Address::default()), - value: U256::from(3), - input: Bytes::from(vec![1, 2]), - odd_y_parity: true, - r: H256::default(), - s: H256::default(), - access_list: vec![].into(), + fn encode_legacy_receipt() { + let expected = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); + + let mut data = vec![]; + let receipt = TypedReceipt::Legacy(ReceiptWithBloom { + receipt: Receipt { + success: false, + cumulative_gas_used: 0x1u64, + logs: vec![Log { + address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), + data: LogData::new_unchecked( + vec![ + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000dead", + ) + .unwrap(), + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000beef", + ) + .unwrap(), + ], + Bytes::from_str("0100ff").unwrap(), + ), + }], + }, + bloom: [0; 256].into(), }); - let mut encoded = BytesMut::new(); - tx.encode(&mut encoded); - - let decoded = - ::decode(&mut &*encoded).unwrap(); - assert_eq!(decoded, tx); - } + receipt.encode(&mut data); - #[test] - #[cfg(feature = "fastrlp")] - fn decode_transaction_consumes_buffer() { - let bytes = &mut &hex::decode("b87502f872041a8459682f008459682f0d8252089461815774383099e24810ab832a5b2a5425c154d58829a2241af62c000080c001a059e6b67f48fb32e7e570dfb11e042b5ad2e55e3ce3ce9cd989c7e06e07feeafda0016b83f4f980694ed2eee4d10667242b1f40dc406901b34125b008d334d47469").unwrap()[..]; - let _transaction_res = - ::decode(bytes).unwrap(); - assert_eq!( - bytes.len(), - 0, - "did not consume all bytes in the buffer, {:?} remaining", - bytes.len() - ); + // check that the rlp length equals the length of the expected rlp + assert_eq!(receipt.length(), expected.len()); + assert_eq!(data, expected); } #[test] - #[cfg(feature = "fastrlp")] - fn decode_multiple_network_txs() { - use std::str::FromStr; - - let bytes_first = &mut &hex::decode("f86b02843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba00eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5aea03a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18").unwrap()[..]; - let expected = TypedTransaction::Legacy(LegacyTransaction { - nonce: 2u64.into(), - gas_price: 1000000000u64.into(), - gas_limit: 100000u64.into(), - kind: TransactionKind::Call(Address::from_slice( - &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], - )), - value: 1000000000000000u64.into(), - input: Bytes::default(), - signature: Signature { - v: 43, - r: U256::from_str( - "eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae", - ) - .unwrap(), - s: U256::from_str( - "3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18", - ) - .unwrap(), + fn decode_legacy_receipt() { + let data = hex::decode("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff").unwrap(); + + let expected = TypedReceipt::Legacy(ReceiptWithBloom { + receipt: Receipt { + success: false, + cumulative_gas_used: 0x1u64, + logs: vec![Log { + address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), + data: LogData::new_unchecked( + vec![ + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000dead", + ) + .unwrap(), + B256::from_str( + "000000000000000000000000000000000000000000000000000000000000beef", + ) + .unwrap(), + ], + Bytes::from_str("0100ff").unwrap(), + ), + }], }, + bloom: [0; 256].into(), }); - assert_eq!( - expected, - ::decode(bytes_first).unwrap() - ); - let bytes_second = &mut &hex::decode("f86b01843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac3960468702769bb01b2a00802ba0e24d8bd32ad906d6f8b8d7741e08d1959df021698b19ee232feba15361587d0aa05406ad177223213df262cb66ccbb2f46bfdccfdfbbb5ffdda9e2c02d977631da").unwrap()[..]; - let expected = TypedTransaction::Legacy(LegacyTransaction { - nonce: 1u64.into(), - gas_price: 1000000000u64.into(), - gas_limit: 100000u64.into(), - kind: TransactionKind::Call(Address::from_slice( - &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], - )), - value: 693361000000000u64.into(), - input: Bytes::default(), - signature: Signature { - v: 43, - r: U256::from_str( - "e24d8bd32ad906d6f8b8d7741e08d1959df021698b19ee232feba15361587d0a", - ) - .unwrap(), - s: U256::from_str( - "5406ad177223213df262cb66ccbb2f46bfdccfdfbbb5ffdda9e2c02d977631da", - ) - .unwrap(), - }, - }); - assert_eq!( - expected, - ::decode(bytes_second).unwrap() - ); - - let bytes_third = &mut &hex::decode("f86b0384773594008398968094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba0ce6834447c0a4193c40382e6c57ae33b241379c5418caac9cdc18d786fd12071a03ca3ae86580e94550d7c071e3a02eadb5a77830947c9225165cf9100901bee88").unwrap()[..]; - let expected = TypedTransaction::Legacy(LegacyTransaction { - nonce: 3u64.into(), - gas_price: 2000000000u64.into(), - gas_limit: 10000000u64.into(), - kind: TransactionKind::Call(Address::from_slice( - &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], - )), - value: 1000000000000000u64.into(), - input: Bytes::default(), - signature: Signature { - v: 43, - r: U256::from_str( - "ce6834447c0a4193c40382e6c57ae33b241379c5418caac9cdc18d786fd12071", - ) - .unwrap(), - s: U256::from_str( - "3ca3ae86580e94550d7c071e3a02eadb5a77830947c9225165cf9100901bee88", - ) - .unwrap(), - }, - }); - assert_eq!( - expected, - ::decode(bytes_third).unwrap() - ); - - let bytes_fourth = &mut &hex::decode("b87502f872041a8459682f008459682f0d8252089461815774383099e24810ab832a5b2a5425c154d58829a2241af62c000080c001a059e6b67f48fb32e7e570dfb11e042b5ad2e55e3ce3ce9cd989c7e06e07feeafda0016b83f4f980694ed2eee4d10667242b1f40dc406901b34125b008d334d47469").unwrap()[..]; - let expected = TypedTransaction::EIP1559(EIP1559Transaction { - chain_id: 4, - nonce: 26u64.into(), - max_priority_fee_per_gas: 1500000000u64.into(), - max_fee_per_gas: 1500000013u64.into(), - gas_limit: 21000u64.into(), - kind: TransactionKind::Call(Address::from_slice( - &hex::decode("61815774383099e24810ab832a5b2a5425c154d5").unwrap()[..], - )), - value: 3000000000000000000u64.into(), - input: Bytes::default(), - access_list: AccessList::default(), - odd_y_parity: true, - r: H256::from_str("59e6b67f48fb32e7e570dfb11e042b5ad2e55e3ce3ce9cd989c7e06e07feeafd") - .unwrap(), - s: H256::from_str("016b83f4f980694ed2eee4d10667242b1f40dc406901b34125b008d334d47469") - .unwrap(), - }); - assert_eq!( - expected, - ::decode(bytes_fourth).unwrap() - ); - - let bytes_fifth = &mut &hex::decode("f8650f84832156008287fb94cf7f9e66af820a19257a2108375b180b0ec491678204d2802ca035b7bfeb9ad9ece2cbafaaf8e202e706b4cfaeb233f46198f00b44d4a566a981a0612638fb29427ca33b9a3be2a0a561beecfe0269655be160d35e72d366a6a860").unwrap()[..]; - let expected = TypedTransaction::Legacy(LegacyTransaction { - nonce: 15u64.into(), - gas_price: 2200000000u64.into(), - gas_limit: 34811u64.into(), - kind: TransactionKind::Call(Address::from_slice( - &hex::decode("cf7f9e66af820a19257a2108375b180b0ec49167").unwrap()[..], - )), - value: 1234u64.into(), - input: Bytes::default(), - signature: Signature { - v: 44, - r: U256::from_str( - "35b7bfeb9ad9ece2cbafaaf8e202e706b4cfaeb233f46198f00b44d4a566a981", - ) - .unwrap(), - s: U256::from_str( - "612638fb29427ca33b9a3be2a0a561beecfe0269655be160d35e72d366a6a860", - ) - .unwrap(), - }, - }); - assert_eq!( - expected, - ::decode(bytes_fifth).unwrap() - ); - - let bytes_sixth = &mut &hex::decode("b8587ef85507a0000000000000000000000000000000000000000000000000000000000000000094cf7f9e66af820a19257a2108375b180b0ec491679461815774383099e24810ab832a5b2a5425c154d5808230398287fb0180").unwrap()[..]; - let expected: TypedTransaction = TypedTransaction::Deposit(DepositTransaction { - nonce: 7u64.into(), - source_hash: H256::from_str( - "0000000000000000000000000000000000000000000000000000000000000000", - ) - .unwrap(), - from: "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(), - kind: TransactionKind::Call(Address::from_slice( - &hex::decode("61815774383099e24810ab832a5b2a5425c154d5").unwrap()[..], - )), - mint: U256::zero(), - value: 12345u64.into(), - gas_limit: 34811u64.into(), - input: Bytes::default(), - is_system_tx: true, - }); - assert_eq!( - expected, - ::decode(bytes_sixth).unwrap() - ); - } - - // - #[test] - fn test_recover_legacy_tx() { - let raw_tx = "f9015482078b8505d21dba0083022ef1947a250d5630b4cf539739df2c5dacb4c659f2488d880c46549a521b13d8b8e47ff36ab50000000000000000000000000000000000000000000066ab5a608bd00a23f2fe000000000000000000000000000000000000000000000000000000000000008000000000000000000000000048c04ed5691981c42154c6167398f95e8f38a7ff00000000000000000000000000000000000000000000000000000000632ceac70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006c6ee5e31d828de241282b9606c8e98ea48526e225a0c9077369501641a92ef7399ff81c21639ed4fd8fc69cb793cfa1dbfab342e10aa0615facb2f1bcf3274a354cfe384a38d0cc008a11c2dd23a69111bc6930ba27a8"; + let receipt = TypedReceipt::decode(&mut &data[..]).unwrap(); - let tx: TypedTransaction = rlp::decode(&hex::decode(raw_tx).unwrap()).unwrap(); - let recovered = tx.recover().unwrap(); - let expected: Address = "0xa12e1462d0ced572f396f58b6e2d03894cd7c8a4".parse().unwrap(); - assert_eq!(expected, recovered); + assert_eq!(receipt, expected); } } diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index f6b3b47e13be1..614ba15b81d60 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -1,11 +1,15 @@ -use alloy_network::TxKind; -use alloy_primitives::{Address, Bytes, B256, U256}; -use alloy_rlp::{Decodable, Encodable, Error as DecodeError, Header as RlpHeader}; +use alloy_consensus::TxType; +use alloy_network::{Transaction, TxKind}; +use alloy_primitives::{Address, Bytes, ChainId, Signature, B256, U256}; +use alloy_rlp::{ + length_of_length, Decodable, Encodable, Error as DecodeError, Header as RlpHeader, +}; +use std::mem; #[derive(Clone, Debug, PartialEq, Eq)] pub struct DepositTransactionRequest { - pub from: Address, pub source_hash: B256, + pub from: Address, pub kind: TxKind, pub mint: U256, pub value: U256, @@ -44,6 +48,187 @@ impl DepositTransactionRequest { len += self.input.length(); len } + + /// Decodes the inner [DepositTransactionRequest] fields from RLP bytes. + /// + /// NOTE: This assumes a RLP header has already been decoded, and _just_ decodes the following + /// RLP fields in the following order: + /// + /// - `source_hash` + /// - `from` + /// - `kind` + /// - `mint` + /// - `value` + /// - `gas_limit` + /// - `is_system_tx` + /// - `input` + pub fn decode_inner(buf: &mut &[u8]) -> Result { + Ok(Self { + source_hash: Decodable::decode(buf)?, + from: Decodable::decode(buf)?, + kind: Decodable::decode(buf)?, + mint: Decodable::decode(buf)?, + value: Decodable::decode(buf)?, + gas_limit: Decodable::decode(buf)?, + is_system_tx: Decodable::decode(buf)?, + input: Decodable::decode(buf)?, + }) + } + + /// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating + /// hash that for eip2718 does not require rlp header + pub(crate) fn encode_with_signature( + &self, + signature: &Signature, + out: &mut dyn alloy_rlp::BufMut, + ) { + let payload_length = self.fields_len() + signature.rlp_vrs_len(); + let header = alloy_rlp::Header { list: true, payload_length }; + header.encode(out); + self.encode_fields(out); + signature.write_rlp_vrs(out); + } + + /// Output the length of the RLP signed transaction encoding, _without_ a RLP string header. + pub fn payload_len_with_signature_without_header(&self, signature: &Signature) -> usize { + let payload_length = self.fields_len() + signature.rlp_vrs_len(); + // 'transaction type byte length' + 'header length' + 'payload length' + 1 + length_of_length(payload_length) + payload_length + } + + /// Output the length of the RLP signed transaction encoding. This encodes with a RLP header. + pub fn payload_len_with_signature(&self, signature: &Signature) -> usize { + let len = self.payload_len_with_signature_without_header(signature); + length_of_length(len) + len + } + + /// Get transaction type + pub(crate) const fn tx_type(&self) -> TxType { + TxType::Eip1559 + } + + /// Calculates a heuristic for the in-memory size of the [DepositTransaction] transaction. + #[inline] + pub fn size(&self) -> usize { + mem::size_of::() + // source_hash + mem::size_of::
() + // from + self.kind.size() + // to + mem::size_of::() + // mint + mem::size_of::() + // value + mem::size_of::() + // gas_limit + mem::size_of::() + // is_system_transaction + self.input.len() // input + } + + /// Encodes the legacy transaction in RLP for signing. + pub(crate) fn encode_for_signing(&self, out: &mut dyn alloy_rlp::BufMut) { + out.put_u8(self.tx_type() as u8); + alloy_rlp::Header { list: true, payload_length: self.fields_len() }.encode(out); + self.encode_fields(out); + } + + /// Outputs the length of the signature RLP encoding for the transaction. + pub(crate) fn payload_len_for_signature(&self) -> usize { + let payload_length = self.fields_len(); + // 'transaction type byte length' + 'header length' + 'payload length' + 1 + length_of_length(payload_length) + payload_length + } + + /// Outputs the signature hash of the transaction by first encoding without a signature, then + /// hashing. + pub(crate) fn signature_hash(&self) -> B256 { + let mut buf = Vec::with_capacity(self.payload_len_for_signature()); + self.encode_for_signing(&mut buf); + alloy_primitives::utils::keccak256(&buf) + } +} + +impl Transaction for DepositTransactionRequest { + type Signature = Signature; + + fn chain_id(&self) -> Option { + None + } + + fn gas_limit(&self) -> u64 { + self.gas_limit.to::() + } + + fn nonce(&self) -> u64 { + u64::MAX + } + + fn decode_signed(buf: &mut &[u8]) -> alloy_rlp::Result> + where + Self: Sized, + { + let header = alloy_rlp::Header::decode(buf)?; + if !header.list { + return Err(alloy_rlp::Error::UnexpectedString); + } + + let tx = Self::decode_inner(buf)?; + let signature = Signature::decode_rlp_vrs(buf)?; + + Ok(tx.into_signed(signature)) + } + + fn encode_signed(&self, signature: &Signature, out: &mut dyn bytes::BufMut) { + self.encode_with_signature(signature, out) + } + + fn gas_price(&self) -> Option { + None + } + + fn input(&self) -> &[u8] { + &self.input + } + + fn input_mut(&mut self) -> &mut Bytes { + &mut self.input + } + + fn into_signed(self, signature: Signature) -> alloy_network::Signed + where + Self: Sized, + { + alloy_network::Signed::new_unchecked(self.clone(), signature, self.signature_hash()) + } + + fn set_chain_id(&mut self, _chain_id: ChainId) {} + + fn set_gas_limit(&mut self, limit: u64) { + self.gas_limit = U256::from(limit); + } + + fn set_gas_price(&mut self, _price: U256) {} + + fn set_input(&mut self, data: Bytes) { + self.input = data; + } + + fn set_nonce(&mut self, _nonce: u64) {} + + fn set_to(&mut self, to: TxKind) { + self.kind = to; + } + + fn set_value(&mut self, value: U256) { + self.value = value; + } + + fn signature_hash(&self) -> B256 { + self.signature_hash() + } + + fn to(&self) -> TxKind { + self.kind + } + + fn value(&self) -> U256 { + self.value + } } impl From for DepositTransactionRequest { @@ -117,7 +302,6 @@ impl DepositTransaction { /// Calculates the length of the RLP-encoded transaction's fields. pub(crate) fn fields_len(&self) -> usize { let mut len = 0; - len += self.nonce.length(); len += self.source_hash.length(); len += self.from.length(); len += self.kind.length(); @@ -134,7 +318,6 @@ impl DepositTransaction { /// NOTE: This assumes a RLP header has already been decoded, and _just_ decodes the following /// RLP fields in the following order: /// - /// - `nonce` /// - `source_hash` /// - `from` /// - `kind` @@ -145,7 +328,7 @@ impl DepositTransaction { /// - `input` pub fn decode_inner(buf: &mut &[u8]) -> Result { Ok(Self { - nonce: Decodable::decode(buf)?, + nonce: U256::ZERO, source_hash: Decodable::decode(buf)?, from: Decodable::decode(buf)?, kind: Decodable::decode(buf)?, diff --git a/crates/anvil/core/src/eth/trie.rs b/crates/anvil/core/src/eth/trie.rs index 6187c5087d950..5d144a5db13ca 100644 --- a/crates/anvil/core/src/eth/trie.rs +++ b/crates/anvil/core/src/eth/trie.rs @@ -1,5 +1,5 @@ //! Utility functions for Ethereum adapted from https://github.dev/rust-blockchain/ethereum/blob/755dffaa4903fbec1269f50cde9863cf86269a14/src/util.rs -use ethers_core::types::H256; +use alloy_primitives::B256; pub use keccak_hasher::KeccakHasher; @@ -7,36 +7,36 @@ pub use keccak_hasher::KeccakHasher; pub use reference_trie::*; /// The KECCAK of the RLP encoding of empty data. -pub const KECCAK_NULL_RLP: H256 = H256([ +pub const KECCAK_NULL_RLP: B256 = B256::new([ 0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, 0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21, ]); /// Generates a trie root hash for a vector of key-value tuples -pub fn trie_root(input: I) -> H256 +pub fn trie_root(input: I) -> B256 where I: IntoIterator, K: AsRef<[u8]> + Ord, V: AsRef<[u8]>, { - H256::from(triehash::trie_root::(input)) + B256::from(triehash::trie_root::(input)) } /// Generates a key-hashed (secure) trie root hash for a vector of key-value tuples. -pub fn sec_trie_root(input: I) -> H256 +pub fn sec_trie_root(input: I) -> B256 where I: IntoIterator, K: AsRef<[u8]>, V: AsRef<[u8]>, { - H256::from(triehash::sec_trie_root::(input)) + B256::from(triehash::sec_trie_root::(input)) } /// Generates a trie root hash for a vector of values -pub fn ordered_trie_root(input: I) -> H256 +pub fn ordered_trie_root(input: I) -> B256 where I: IntoIterator, V: AsRef<[u8]>, { - H256::from(triehash::ordered_trie_root::(input)) + B256::from(triehash::ordered_trie_root::(input)) } diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index d9d8c09872e5b..27bb46523da4d 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,33 +1,8 @@ -use alloy_eips::eip2930::AccessListItem as AlloyEipAccessListItem; -use alloy_primitives::{Address, U256}; -use alloy_rpc_types::AccessListItem as AlloyAccessListItem; -use ethers_core::{ - types::transaction::eip2930::AccessListItem, - utils::{ - rlp, - rlp::{Encodable, RlpStream}, - }, +use alloy_eips::eip2930::{ + AccessList as AlloyEipAccessList, AccessListItem as AlloyEipAccessListItem, }; -use foundry_common::types::ToAlloy; - -pub fn enveloped(id: u8, v: &T, s: &mut RlpStream) { - let encoded = rlp::encode(v); - let mut out = vec![0; 1 + encoded.len()]; - out[0] = id; - out[1..].copy_from_slice(&encoded); - out.rlp_append(s) -} - -pub fn to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { - list.into_iter() - .map(|item| { - ( - item.address.to_alloy(), - item.storage_keys.into_iter().map(|k| k.to_alloy().into()).collect(), - ) - }) - .collect() -} +use alloy_primitives::{Address, Parity, U256}; +use alloy_rpc_types::{AccessList as AlloyAccessList, AccessListItem as AlloyAccessListItem}; pub fn alloy_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { list.into_iter() @@ -35,9 +10,35 @@ pub fn alloy_to_revm_access_list(list: Vec) -> Vec<(Address .collect() } +/// Translates a vec of [AlloyEipAccessListItem] to a [AlloyAccessList], translating from internal +/// type to rpc type. +pub fn from_eip_to_alloy_access_list(list: AlloyEipAccessList) -> AlloyAccessList { + AlloyAccessList( + list.0 + .into_iter() + .map(|item| AlloyAccessListItem { + address: item.address, + storage_keys: item.storage_keys.into_iter().collect(), + }) + .collect(), + ) +} + /// Translates a vec of [AlloyEipAccessListItem] to a revm style Access List. pub fn eip_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { list.into_iter() .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) .collect() } + +/// See +/// > If you do, then the v of the signature MUST be set to {0,1} + CHAIN_ID * 2 + 35 where +/// > {0,1} is the parity of the y value of the curve point for which r is the x-value in the +/// > secp256k1 signing process. +pub fn meets_eip155(chain_id: u64, v: Parity) -> bool { + let double_chain_id = chain_id.saturating_mul(2); + match v { + Parity::Eip155(v) => v == double_chain_id + 35 || v == double_chain_id + 36, + _ => false, + } +} diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index d1386854d7cd1..db966d956d206 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -26,7 +26,7 @@ impl<'de> serde::Deserialize<'de> for Forking { pub json_rpc_url: Option, #[serde( default, - deserialize_with = "ethers_core::types::serde_helpers::deserialize_stringified_u64_opt" + deserialize_with = "crate::eth::serde_helpers::numeric::deserialize_stringified_u64_opt" )] pub block_number: Option, } @@ -63,7 +63,7 @@ pub enum EvmMineOptions { #[cfg_attr( feature = "serde", serde( - deserialize_with = "ethers_core::types::serde_helpers::deserialize_stringified_u64_opt" + deserialize_with = "crate::eth::serde_helpers::numeric::deserialize_stringified_u64_opt" ) )] timestamp: Option, @@ -75,7 +75,7 @@ pub enum EvmMineOptions { #[cfg_attr( feature = "serde", serde( - deserialize_with = "ethers_core::types::serde_helpers::deserialize_stringified_u64_opt" + deserialize_with = "crate::eth::serde_helpers::numeric::deserialize_stringified_u64_opt" ) )] Timestamp(Option), diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index e1eb0eb3d27f4..9ddd53434f6c3 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -4,15 +4,11 @@ use crate::{ genesis::Genesis, AccountGenerator, Hardfork, NodeConfig, CHAIN_ID, }; -use alloy_primitives::U256; +use alloy_primitives::{utils::Unit, U256}; +use alloy_signer::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; use clap::Parser; use core::fmt; -use ethers::{ - signers::coins_bip39::{English, Mnemonic}, - utils::WEI_IN_ETHER, -}; -use foundry_common::types::ToAlloy; use foundry_config::{Chain, Config}; use futures::FutureExt; use rand::{rngs::StdRng, SeedableRng}; @@ -186,7 +182,7 @@ const DEFAULT_DUMP_INTERVAL: Duration = Duration::from_secs(60); impl NodeArgs { pub fn into_node_config(self) -> NodeConfig { - let genesis_balance = WEI_IN_ETHER.saturating_mul(self.balance.into()); + let genesis_balance = Unit::ETHER.wei().saturating_mul(U256::from(self.balance)); let compute_units_per_second = if self.evm_opts.no_rate_limit { Some(u64::MAX) } else { @@ -201,7 +197,7 @@ impl NodeArgs { .with_blocktime(self.block_time.map(Duration::from_secs)) .with_no_mining(self.no_mining) .with_account_generator(self.account_generator()) - .with_genesis_balance(genesis_balance.to_alloy()) + .with_genesis_balance(genesis_balance) .with_genesis_timestamp(self.timestamp) .with_port(self.port) .with_fork_block_number( diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index b8430a74601a6..3e370b5768476 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -16,23 +16,18 @@ use crate::{ mem::in_memory_db::MemDb, FeeManager, Hardfork, }; -use alloy_primitives::{hex, U256}; +use alloy_primitives::{hex, utils::Unit, U256}; use alloy_providers::provider::TempProvider; use alloy_rpc_types::BlockNumberOrTag; +use alloy_signer::{ + coins_bip39::{English, Mnemonic}, + LocalWallet, MnemonicBuilder, Signer as AlloySigner, +}; use alloy_transport::TransportError; use anvil_server::ServerConfig; -use ethers::{ - core::k256::ecdsa::SigningKey, - prelude::{rand::thread_rng, Wallet}, - signers::{ - coins_bip39::{English, Mnemonic}, - MnemonicBuilder, Signer, - }, - utils::WEI_IN_ETHER, -}; use foundry_common::{ - provider::alloy::ProviderBuilder, types::ToAlloy, ALCHEMY_FREE_TIER_CUPS, - NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, + provider::alloy::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, + REQUEST_TIMEOUT, }; use foundry_config::Config; use foundry_evm::{ @@ -43,6 +38,7 @@ use foundry_evm::{ utils::apply_chain_and_block_specific_env_changes, }; use parking_lot::RwLock; +use rand::thread_rng; use serde_json::{json, to_writer, Value}; use std::{ collections::HashMap, @@ -105,13 +101,13 @@ pub struct NodeConfig { /// The hardfork to use pub hardfork: Option, /// Signer accounts that will be initialised with `genesis_balance` in the genesis block - pub genesis_accounts: Vec>, + pub genesis_accounts: Vec, /// Native token balance of every genesis account in the genesis block pub genesis_balance: U256, /// Genesis block timestamp pub genesis_timestamp: Option, /// Signer accounts that can sign messages/transactions from the EVM node - pub signer_accounts: Vec>, + pub signer_accounts: Vec, /// Configured block time for the EVM chain. Use `None` to mine a new block for every tx pub block_time: Option, /// Disable auto, interval mining mode uns use `MiningMode::None` instead @@ -197,8 +193,7 @@ Available Accounts ); let balance = alloy_primitives::utils::format_ether(self.genesis_balance); for (idx, wallet) in self.genesis_accounts.iter().enumerate() { - write!(config_string, "\n({idx}) {} ({balance} ETH)", wallet.address().to_alloy()) - .unwrap(); + write!(config_string, "\n({idx}) {} ({balance} ETH)", wallet.address()).unwrap(); } let _ = write!( @@ -375,7 +370,7 @@ impl Default for NodeConfig { genesis_timestamp: None, genesis_accounts, // 100ETH default balance - genesis_balance: WEI_IN_ETHER.to_alloy().saturating_mul(U256::from(100u64)), + genesis_balance: Unit::ETHER.wei().saturating_mul(U256::from(100u64)), block_time: None, no_mining: false, port: NODE_PORT, @@ -471,10 +466,10 @@ impl NodeConfig { self.chain_id = chain_id.map(Into::into); let chain_id = self.get_chain_id(); self.genesis_accounts.iter_mut().for_each(|wallet| { - *wallet = wallet.clone().with_chain_id(chain_id); + *wallet = wallet.clone().with_chain_id(Some(chain_id)); }); self.signer_accounts.iter_mut().for_each(|wallet| { - *wallet = wallet.clone().with_chain_id(chain_id); + *wallet = wallet.clone().with_chain_id(Some(chain_id)); }) } @@ -559,14 +554,14 @@ impl NodeConfig { /// Sets the genesis accounts #[must_use] - pub fn with_genesis_accounts(mut self, accounts: Vec>) -> Self { + pub fn with_genesis_accounts(mut self, accounts: Vec) -> Self { self.genesis_accounts = accounts; self } /// Sets the signer accounts #[must_use] - pub fn with_signer_accounts(mut self, accounts: Vec>) -> Self { + pub fn with_signer_accounts(mut self, accounts: Vec) -> Self { self.signer_accounts = accounts; self } @@ -845,7 +840,7 @@ impl NodeConfig { let genesis = GenesisConfig { timestamp: self.get_genesis_timestamp(), balance: self.genesis_balance, - accounts: self.genesis_accounts.iter().map(|acc| acc.address().to_alloy()).collect(), + accounts: self.genesis_accounts.iter().map(|acc| acc.address()).collect(), fork_genesis_account_infos: Arc::new(Default::default()), genesis_init: self.genesis.clone(), }; @@ -1160,18 +1155,17 @@ impl AccountGenerator { } impl AccountGenerator { - pub fn gen(&self) -> Vec> { + pub fn gen(&self) -> Vec { let builder = MnemonicBuilder::::default().phrase(self.phrase.as_str()); - // use the + // use the derivation path let derivation_path = self.get_derivation_path(); let mut wallets = Vec::with_capacity(self.amount); - for idx in 0..self.amount { let builder = builder.clone().derivation_path(&format!("{derivation_path}{idx}")).unwrap(); - let wallet = builder.build().unwrap().with_chain_id(self.chain_id); + let wallet = builder.build().unwrap().with_chain_id(Some(self.chain_id)); wallets.push(wallet) } wallets diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 8337ce6d30012..dffc035df634e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -9,8 +9,7 @@ use crate::{ validate::TransactionValidator, }, error::{ - decode_revert_reason, BlockchainError, FeeHistoryError, InvalidTransactionError, - Result, ToRpcResponseResult, + BlockchainError, FeeHistoryError, InvalidTransactionError, Result, ToRpcResponseResult, }, fees::{FeeDetails, FeeHistoryCache}, macros::node_info, @@ -29,7 +28,11 @@ use crate::{ revm::primitives::Output, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; +use alloy_consensus::TxLegacy; +use alloy_dyn_abi::TypedData; +use alloy_network::{Signed, TxKind}; use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256, U64}; +use alloy_rlp::Decodable; use alloy_rpc_trace_types::{ geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, @@ -46,9 +49,8 @@ use anvil_core::{ eth::{ block::BlockInfo, transaction::{ - call_to_internal_tx_request, to_alloy_proof, to_ethers_signature, - EthTransactionRequest, LegacyTransaction, PendingTransaction, TransactionKind, - TypedTransaction, TypedTransactionRequest, + call_request_to_typed, EthTransactionRequest, PendingTransaction, TypedTransaction, + TypedTransactionRequest, }, EthRequest, }, @@ -58,13 +60,10 @@ use anvil_core::{ }, }; use anvil_rpc::{error::RpcError, response::ResponseResult}; -use ethers::{types::transaction::eip712::TypedData, utils::rlp}; -use foundry_common::{ - provider::alloy::ProviderBuilder, - types::{ToAlloy, ToEthers}, -}; +use foundry_common::provider::alloy::ProviderBuilder; use foundry_evm::{ backend::DatabaseError, + decode::maybe_decode_revert, revm::{ db::DatabaseRef, interpreter::{return_ok, return_revert, InstructionResult}, @@ -420,18 +419,19 @@ impl EthApi { ) -> Result { match request { TypedTransactionRequest::Deposit(_) => { - const NIL_SIGNATURE: ethers::types::Signature = ethers::types::Signature { - r: ethers::types::U256::zero(), - s: ethers::types::U256::zero(), - v: 0, - }; - return build_typed_transaction(request, NIL_SIGNATURE) + let nil_signature: alloy_primitives::Signature = + alloy_primitives::Signature::from_scalars_and_parity( + B256::with_last_byte(1), + B256::with_last_byte(1), + false, + ) + .unwrap(); + return build_typed_transaction(request, nil_signature) } _ => { for signer in self.signers.iter() { - if signer.accounts().contains(&from.to_ethers()) { - let signature = - signer.sign_transaction(request.clone(), &from.to_ethers())?; + if signer.accounts().contains(from) { + let signature = signer.sign_transaction(request.clone(), from)?; return build_typed_transaction(request, signature) } } @@ -567,13 +567,7 @@ impl EthApi { let mut unique = HashSet::new(); let mut accounts: Vec
= Vec::new(); for signer in self.signers.iter() { - accounts.extend( - signer - .accounts() - .into_iter() - .map(|a| a.to_alloy()) - .filter(|acc| unique.insert(*acc)), - ); + accounts.extend(signer.accounts().into_iter().filter(|acc| unique.insert(*acc))); } accounts.extend( self.backend @@ -803,7 +797,7 @@ impl EthApi { } let proof = self.backend.prove_account_at(address, keys, Some(block_request)).await?; - Ok(to_alloy_proof(proof)) + Ok(proof) } /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md). @@ -836,7 +830,8 @@ impl EthApi { pub async fn sign_typed_data_v4(&self, address: Address, data: &TypedData) -> Result { node_info!("eth_signTypedData_v4"); let signer = self.get_signer(address).ok_or(BlockchainError::NoSignerAvailable)?; - let signature = signer.sign_typed_data(address.to_ethers(), data).await?; + let signature = signer.sign_typed_data(address, data).await?; + let signature = alloy_primitives::hex::encode(signature.as_bytes()); Ok(format!("0x{signature}")) } @@ -846,7 +841,8 @@ impl EthApi { pub async fn sign(&self, address: Address, content: impl AsRef<[u8]>) -> Result { node_info!("eth_sign"); let signer = self.get_signer(address).ok_or(BlockchainError::NoSignerAvailable)?; - let signature = signer.sign(address.to_ethers(), content.as_ref()).await?; + let signature = + alloy_primitives::hex::encode(signer.sign(address, content.as_ref()).await?.as_bytes()); Ok(format!("0x{signature}")) } @@ -856,24 +852,17 @@ impl EthApi { pub async fn sign_transaction(&self, request: EthTransactionRequest) -> Result { node_info!("eth_signTransaction"); - let from = request - .from - .map(Ok) - .unwrap_or_else(|| { - self.accounts()? - .first() - .cloned() - .ok_or(BlockchainError::NoSignerAvailable) - .map(|a| a.to_ethers()) - })? - .to_alloy(); + let from = request.from.map(Ok).unwrap_or_else(|| { + self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) + })?; let (nonce, _) = self.request_nonce(&request, from).await?; let request = self.build_typed_tx_request(request, nonce)?; let signer = self.get_signer(from).ok_or(BlockchainError::NoSignerAvailable)?; - let signature = signer.sign_transaction(request, &from.to_ethers())?; + let signature = + alloy_primitives::hex::encode(signer.sign_transaction(request, &from)?.as_bytes()); Ok(format!("0x{signature}")) } @@ -883,34 +872,23 @@ impl EthApi { pub async fn send_transaction(&self, request: EthTransactionRequest) -> Result { node_info!("eth_sendTransaction"); - let from = request - .from - .map(Ok) - .unwrap_or_else(|| { - self.accounts()? - .first() - .cloned() - .ok_or(BlockchainError::NoSignerAvailable) - .map(|a| a.to_ethers()) - })? - .to_alloy(); - + let from = request.from.map(Ok).unwrap_or_else(|| { + self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) + })?; let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; let request = self.build_typed_tx_request(request, nonce)?; // if the sender is currently impersonated we need to "bypass" signing let pending_transaction = if self.is_impersonated(from) { let bypass_signature = self.backend.cheats().bypass_signature(); - let transaction = - sign::build_typed_transaction(request, to_ethers_signature(bypass_signature))?; + let transaction = sign::build_typed_transaction(request, bypass_signature)?; self.ensure_typed_transaction_supported(&transaction)?; trace!(target : "node", ?from, "eth_sendTransaction: impersonating"); - PendingTransaction::with_impersonated(transaction, from.to_ethers()) + PendingTransaction::with_impersonated(transaction, from) } else { let transaction = self.sign_request(&from, request)?; self.ensure_typed_transaction_supported(&transaction)?; PendingTransaction::new(transaction)? }; - // pre-validate self.backend.validate_pool_transaction(&pending_transaction).await?; @@ -926,13 +904,13 @@ impl EthApi { /// Handler for ETH RPC call: `eth_sendRawTransaction` pub async fn send_raw_transaction(&self, tx: Bytes) -> Result { node_info!("eth_sendRawTransaction"); - let data = tx.as_ref(); + let mut data = tx.as_ref(); if data.is_empty() { return Err(BlockchainError::EmptyRawTransactionData); } let transaction = if data[0] > 0x7f { // legacy transaction - match rlp::decode::(data) { + match Signed::::decode(&mut data) { Ok(transaction) => TypedTransaction::Legacy(transaction), Err(_) => return Err(BlockchainError::FailedToDecodeSignedTransaction), } @@ -941,32 +919,29 @@ impl EthApi { // but EIP-1559 prepends a version byte, so we need to encode the data first to get a // valid rlp and then rlp decode impl of `TypedTransaction` will remove and check the // version byte - let extend = rlp::encode(&data); - let tx = match rlp::decode::(&extend[..]) { + let extend = alloy_rlp::encode(data); + let tx = match TypedTransaction::decode(&mut &extend[..]) { Ok(transaction) => transaction, Err(_) => return Err(BlockchainError::FailedToDecodeSignedTransaction), }; self.ensure_typed_transaction_supported(&tx)?; - tx }; - let pending_transaction = PendingTransaction::new(transaction)?; // pre-validate self.backend.validate_pool_transaction(&pending_transaction).await?; - let on_chain_nonce = - self.backend.current_nonce(pending_transaction.sender().to_alloy()).await?; + let on_chain_nonce = self.backend.current_nonce(*pending_transaction.sender()).await?; let from = *pending_transaction.sender(); - let nonce = *pending_transaction.transaction.nonce(); - let requires = required_marker(nonce.to_alloy(), on_chain_nonce, from.to_alloy()); + let nonce = pending_transaction.transaction.nonce(); + let requires = required_marker(nonce, on_chain_nonce, from); let priority = self.transaction_priority(&pending_transaction.transaction); let pool_transaction = PoolTransaction { requires, - provides: vec![to_marker(nonce.as_u64(), pending_transaction.sender().to_alloy())], + provides: vec![to_marker(nonce.to::(), *pending_transaction.sender())], pending_transaction, priority, }; @@ -1108,7 +1083,7 @@ impl EthApi { let mut tx = self.pool.get_transaction(hash).map(|pending| { let from = *pending.sender(); let mut tx = transaction_build( - Some(pending.hash().to_alloy()), + Some(*pending.hash()), pending.transaction, None, None, @@ -1116,7 +1091,7 @@ impl EthApi { ); // we set the from field here explicitly to the set sender of the pending transaction, // in case the transaction is impersonated. - tx.from = from.to_alloy(); + tx.from = from; tx }); if tx.is_none() { @@ -1916,7 +1891,7 @@ impl EthApi { if let Some(output) = receipt.out { // insert revert reason if failure if receipt.inner.status_code.unwrap_or_default().to::() == 0 { - if let Some(reason) = decode_revert_reason(&output) { + if let Some(reason) = maybe_decode_revert(&output, None, None) { tx.other.insert( "revertReason".to_string(), serde_json::to_value(reason).expect("Infallible"), @@ -1990,20 +1965,18 @@ impl EthApi { ) -> Result { node_info!("eth_sendUnsignedTransaction"); // either use the impersonated account of the request's `from` field - let from = request.from.ok_or(BlockchainError::NoSignerAvailable)?.to_alloy(); + let from = request.from.ok_or(BlockchainError::NoSignerAvailable)?; let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; let request = self.build_typed_tx_request(request, nonce)?; let bypass_signature = self.backend.cheats().bypass_signature(); - let transaction = - sign::build_typed_transaction(request, to_ethers_signature(bypass_signature))?; + let transaction = sign::build_typed_transaction(request, bypass_signature)?; self.ensure_typed_transaction_supported(&transaction)?; - let pending_transaction = - PendingTransaction::with_impersonated(transaction, from.to_ethers()); + let pending_transaction = PendingTransaction::with_impersonated(transaction, from); // pre-validate self.backend.validate_pool_transaction(&pending_transaction).await?; @@ -2036,10 +2009,10 @@ impl EthApi { fn convert(tx: Arc) -> TxpoolInspectSummary { let tx = &tx.pending_transaction.transaction; - let to = tx.to().copied().map(ToAlloy::to_alloy); - let gas_price = tx.gas_price().to_alloy(); - let value = tx.value().to_alloy(); - let gas = tx.gas_limit().to_alloy(); + let to = tx.to(); + let gas_price = tx.gas_price(); + let value = tx.value(); + let gas = tx.gas_limit(); TxpoolInspectSummary { to, value, gas, gas_price } } @@ -2050,14 +2023,12 @@ impl EthApi { // not in sequence. The transaction nonce is an incrementing number for each transaction // with the same From address. for pending in self.pool.ready_transactions() { - let entry = - inspect.pending.entry(pending.pending_transaction.sender().to_alloy()).or_default(); + let entry = inspect.pending.entry(*pending.pending_transaction.sender()).or_default(); let key = pending.pending_transaction.nonce().to_string(); entry.insert(key, convert(pending)); } for queued in self.pool.pending_transactions() { - let entry = - inspect.pending.entry(queued.pending_transaction.sender().to_alloy()).or_default(); + let entry = inspect.pending.entry(*queued.pending_transaction.sender()).or_default(); let key = queued.pending_transaction.nonce().to_string(); entry.insert(key, convert(queued)); } @@ -2085,19 +2056,17 @@ impl EthApi { // we set the from field here explicitly to the set sender of the pending transaction, // in case the transaction is impersonated. - tx.from = from.to_alloy(); + tx.from = from; tx } for pending in self.pool.ready_transactions() { - let entry = - content.pending.entry(pending.pending_transaction.sender().to_alloy()).or_default(); + let entry = content.pending.entry(*pending.pending_transaction.sender()).or_default(); let key = pending.pending_transaction.nonce().to_string(); entry.insert(key, convert(pending)); } for queued in self.pool.pending_transactions() { - let entry = - content.pending.entry(queued.pending_transaction.sender().to_alloy()).or_default(); + let entry = content.pending.entry(*queued.pending_transaction.sender()).or_default(); let key = queued.pending_transaction.nonce().to_string(); entry.insert(key, convert(queued)); } @@ -2272,7 +2241,7 @@ impl EthApi { // succeeded } InstructionResult::OutOfGas | InstructionResult::OutOfFund => { - return Err(InvalidTransactionError::BasicOutOfGas(gas_limit.to_ethers()).into()) + return Err(InvalidTransactionError::BasicOutOfGas(gas_limit).into()) } // need to check if the revert was due to lack of gas or unrelated reason // we're also checking for InvalidFEOpcode here because this can be used to trigger an error common usage in openzeppelin @@ -2306,8 +2275,7 @@ impl EthApi { // transaction requires to succeed let gas: U256 = U256::from(gas); // Get the starting lowest gas needed depending on the transaction kind. - let mut lowest_gas_limit = - determine_base_gas_by_kind(call_to_internal_tx_request(&request)); + let mut lowest_gas_limit = determine_base_gas_by_kind(&request); // pick a point that's close to the estimated gas let mut mid_gas_limit = std::cmp::min( @@ -2413,7 +2381,7 @@ impl EthApi { /// Returns the first signer that can sign for the given address #[allow(clippy::borrowed_box)] pub fn get_signer(&self, address: Address) -> Option<&Box> { - self.signers.iter().find(|signer| signer.is_signer_for(address.to_ethers())) + self.signers.iter().find(|signer| signer.is_signer_for(address)) } /// Returns a new block event stream that yields Notifications when a new block was added @@ -2458,7 +2426,7 @@ impl EthApi { let BlockInfo { block, transactions, receipts: _ } = self.backend.pending_block(transactions).await; - let ethers_block = self.backend.convert_block(block.clone()); + let partial_block = self.backend.convert_block(block.clone()); let mut block_transactions = Vec::with_capacity(block.transactions.len()); let base_fee = self.backend.base_fee(); @@ -2467,7 +2435,7 @@ impl EthApi { let tx = block.transactions.get(info.transaction_index as usize)?.clone(); let tx = transaction_build( - Some(info.transaction_hash.to_alloy()), + Some(info.transaction_hash), tx, Some(&block), Some(info), @@ -2476,7 +2444,7 @@ impl EthApi { block_transactions.push(tx); } - Some(ethers_block.into_full_block(block_transactions)) + Some(partial_block.into_full_block(block_transactions)) } fn build_typed_tx_request( @@ -2484,46 +2452,42 @@ impl EthApi { request: EthTransactionRequest, nonce: U256, ) -> Result { - let chain_id = request.chain_id.map(|c| c.as_u64()).unwrap_or_else(|| self.chain_id()); + let chain_id = request.chain_id.map(|c| c.to::()).unwrap_or_else(|| self.chain_id()); let max_fee_per_gas = request.max_fee_per_gas; let gas_price = request.gas_price; - let gas_limit = request - .gas - .map(ToAlloy::to_alloy) - .map(Ok) - .unwrap_or_else(|| self.current_gas_limit())?; + let gas_limit = request.gas.map(Ok).unwrap_or_else(|| self.current_gas_limit())?; let request = match request.into_typed_request() { Some(TypedTransactionRequest::Legacy(mut m)) => { - m.nonce = nonce.to_ethers(); + m.nonce = nonce.to::(); m.chain_id = Some(chain_id); - m.gas_limit = gas_limit.to_ethers(); + m.gas_limit = gas_limit.to::(); if gas_price.is_none() { - m.gas_price = self.gas_price().unwrap_or_default().to_ethers(); + m.gas_price = self.gas_price().unwrap_or_default().to::(); } TypedTransactionRequest::Legacy(m) } Some(TypedTransactionRequest::EIP2930(mut m)) => { - m.nonce = nonce.to_ethers(); + m.nonce = nonce.to::(); m.chain_id = chain_id; - m.gas_limit = gas_limit.to_ethers(); + m.gas_limit = gas_limit.to::(); if gas_price.is_none() { - m.gas_price = self.gas_price().unwrap_or_default().to_ethers(); + m.gas_price = self.gas_price().unwrap_or_default().to::(); } TypedTransactionRequest::EIP2930(m) } Some(TypedTransactionRequest::EIP1559(mut m)) => { - m.nonce = nonce.to_ethers(); + m.nonce = nonce.to::(); m.chain_id = chain_id; - m.gas_limit = gas_limit.to_ethers(); + m.gas_limit = gas_limit.to::(); if max_fee_per_gas.is_none() { - m.max_fee_per_gas = self.gas_price().unwrap_or_default().to_ethers(); + m.max_fee_per_gas = self.gas_price().unwrap_or_default().to::(); } TypedTransactionRequest::EIP1559(m) } Some(TypedTransactionRequest::Deposit(mut m)) => { - m.gas_limit = gas_limit.to_ethers(); + m.gas_limit = gas_limit; TypedTransactionRequest::Deposit(m) } _ => return Err(BlockchainError::FailedToDecodeTransaction), @@ -2574,7 +2538,7 @@ impl EthApi { ) -> Result<(U256, U256)> { let highest_nonce = self.get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))).await?; - let nonce = request.nonce.map(ToAlloy::to_alloy).unwrap_or(highest_nonce); + let nonce = request.nonce.unwrap_or(highest_nonce); Ok((nonce, highest_nonce)) } @@ -2664,7 +2628,7 @@ where return_ok!() => { // transaction succeeded by manually increasing the gas limit to // highest, which means the caller lacks funds to pay for the tx - InvalidTransactionError::BasicOutOfGas(gas_limit.to_ethers()).into() + InvalidTransactionError::BasicOutOfGas(gas_limit).into() } return_revert!() => { // reverted again after bumping the limit @@ -2679,24 +2643,24 @@ where /// Determines the minimum gas needed for a transaction depending on the transaction kind. #[inline] -fn determine_base_gas_by_kind(request: EthTransactionRequest) -> U256 { - match request.into_typed_request() { +fn determine_base_gas_by_kind(request: &CallRequest) -> U256 { + match call_request_to_typed(request.clone()) { Some(request) => match request { - TypedTransactionRequest::Legacy(req) => match req.kind { - TransactionKind::Call(_) => MIN_TRANSACTION_GAS, - TransactionKind::Create => MIN_CREATE_GAS, + TypedTransactionRequest::Legacy(req) => match req.to { + TxKind::Call(_) => MIN_TRANSACTION_GAS, + TxKind::Create => MIN_CREATE_GAS, }, - TypedTransactionRequest::EIP1559(req) => match req.kind { - TransactionKind::Call(_) => MIN_TRANSACTION_GAS, - TransactionKind::Create => MIN_CREATE_GAS, + TypedTransactionRequest::EIP1559(req) => match req.to { + TxKind::Call(_) => MIN_TRANSACTION_GAS, + TxKind::Create => MIN_CREATE_GAS, }, - TypedTransactionRequest::EIP2930(req) => match req.kind { - TransactionKind::Call(_) => MIN_TRANSACTION_GAS, - TransactionKind::Create => MIN_CREATE_GAS, + TypedTransactionRequest::EIP2930(req) => match req.to { + TxKind::Call(_) => MIN_TRANSACTION_GAS, + TxKind::Create => MIN_CREATE_GAS, }, TypedTransactionRequest::Deposit(req) => match req.kind { - TransactionKind::Call(_) => MIN_TRANSACTION_GAS, - TransactionKind::Create => MIN_CREATE_GAS, + TxKind::Call(_) => MIN_TRANSACTION_GAS, + TxKind::Create => MIN_CREATE_GAS, }, }, // Tighten the gas limit upwards if we don't know the transaction type to avoid deployments diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index a3cde4ccbd3eb..949ea10e7a332 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -1,8 +1,7 @@ //! Support for "cheat codes" / bypass functions -use alloy_primitives::Address; -use alloy_rpc_types::Signature; -use anvil_core::eth::transaction::IMPERSONATED_SIGNATURE; +use alloy_primitives::{Address, Signature}; +use anvil_core::eth::transaction::impersonated_signature; use foundry_evm::hashbrown::HashSet; use parking_lot::RwLock; use std::sync::Arc; @@ -85,7 +84,7 @@ impl Default for CheatsState { fn default() -> Self { Self { impersonated_accounts: Default::default(), - bypass_signature: IMPERSONATED_SIGNATURE, + bypass_signature: impersonated_signature(), auto_impersonate_accounts: false, } } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index a3100d5800de6..7e15c67abadc9 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -6,18 +6,13 @@ use crate::{ }, mem::inspector::Inspector, }; +use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; +use alloy_primitives::{Bloom, BloomInput, Log, B256, U256}; use anvil_core::eth::{ - block::{Block, BlockInfo, Header, PartialHeader}, - receipt::{DepositReceipt, EIP1559Receipt, EIP2930Receipt, EIP658Receipt, Log, TypedReceipt}, - transaction::{PendingTransaction, TransactionInfo, TypedTransaction}, + block::{Block, BlockInfo, PartialHeader}, + transaction::{PendingTransaction, TransactionInfo, TypedReceipt, TypedTransaction}, trie, }; -use ethers::{ - abi::ethereum_types::BloomInput, - types::{Bloom, H256, U256}, - utils::rlp, -}; -use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ backend::DatabaseError, inspectors::{TracingInspector, TracingInspectorConfig}, @@ -47,7 +42,7 @@ pub struct ExecutedTransaction { impl ExecutedTransaction { /// Creates the receipt for the transaction fn create_receipt(&self) -> TypedReceipt { - let used_gas: U256 = self.gas_used.into(); + let used_gas = U256::from(self.gas_used); let mut bloom = Bloom::default(); logs_bloom(self.logs.clone(), &mut bloom); let logs = self.logs.clone(); @@ -55,29 +50,37 @@ impl ExecutedTransaction { // successful return see [Return] let status_code = u8::from(self.exit_reason as u8 <= InstructionResult::SelfDestruct as u8); match &self.transaction.pending_transaction.transaction.transaction { - TypedTransaction::Legacy(_) => TypedReceipt::Legacy(EIP658Receipt { - status_code, - gas_used: used_gas, - logs_bloom: bloom, - logs, + TypedTransaction::Legacy(_) => TypedReceipt::Legacy(ReceiptWithBloom { + receipt: Receipt { + success: status_code == 1, + cumulative_gas_used: used_gas.to::(), + logs, + }, + bloom, }), - TypedTransaction::EIP2930(_) => TypedReceipt::EIP2930(EIP2930Receipt { - status_code, - gas_used: used_gas, - logs_bloom: bloom, - logs, + TypedTransaction::EIP2930(_) => TypedReceipt::EIP2930(ReceiptWithBloom { + receipt: Receipt { + success: status_code == 1, + cumulative_gas_used: used_gas.to::(), + logs, + }, + bloom, }), - TypedTransaction::EIP1559(_) => TypedReceipt::EIP1559(EIP1559Receipt { - status_code, - gas_used: used_gas, - logs_bloom: bloom, - logs, + TypedTransaction::EIP1559(_) => TypedReceipt::EIP1559(ReceiptWithBloom { + receipt: Receipt { + success: status_code == 1, + cumulative_gas_used: used_gas.to::(), + logs, + }, + bloom, }), - TypedTransaction::Deposit(_) => TypedReceipt::Deposit(DepositReceipt { - status_code, - gas_used: used_gas, - logs_bloom: bloom, - logs, + TypedTransaction::Deposit(_) => TypedReceipt::Deposit(ReceiptWithBloom { + receipt: Receipt { + success: status_code == 1, + cumulative_gas_used: used_gas.to::(), + logs, + }, + bloom, }), } } @@ -105,7 +108,7 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> pub pending: std::vec::IntoIter>, pub block_env: BlockEnv, pub cfg_env: CfgEnv, - pub parent_hash: H256, + pub parent_hash: B256, /// Cumulative gas used by all executed transactions pub gas_used: U256, pub enable_steps_tracing: bool, @@ -118,7 +121,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let mut transaction_infos = Vec::new(); let mut receipts = Vec::new(); let mut bloom = Bloom::default(); - let mut cumulative_gas_used = U256::zero(); + let mut cumulative_gas_used = U256::ZERO; let mut invalid = Vec::new(); let mut included = Vec::new(); let gas_limit = self.block_env.gas_limit; @@ -126,7 +129,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let block_number = self.block_env.number; let difficulty = self.block_env.difficulty; let beneficiary = self.block_env.coinbase; - let timestamp = self.block_env.timestamp.to_ethers().as_u64(); + let timestamp = self.block_env.timestamp.to::(); let base_fee = if (self.cfg_env.spec_id as u8) >= (SpecId::LONDON as u8) { Some(self.block_env.basefee) } else { @@ -165,18 +168,18 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let transaction_index = transaction_infos.len() as u32; let info = TransactionInfo { - transaction_hash: transaction.hash().to_ethers(), + transaction_hash: transaction.hash(), transaction_index, from: *transaction.pending_transaction.sender(), - to: transaction.pending_transaction.transaction.to().copied(), - contract_address: contract_address.map(|c| c.to_ethers()), + to: transaction.pending_transaction.transaction.to(), + contract_address, logs, logs_bloom: *receipt.logs_bloom(), traces, exit, out: match out { - Some(Output::Call(b)) => Some(ethers::types::Bytes(b.0)), - Some(Output::Create(b, _)) => Some(ethers::types::Bytes(b.0)), + Some(Output::Call(b)) => Some(alloy_primitives::Bytes(b.0)), + Some(Output::Create(b, _)) => Some(alloy_primitives::Bytes(b.0)), _ => None, }, nonce: tx.nonce, @@ -188,23 +191,23 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' } let ommers: Vec
= Vec::new(); - let receipts_root = trie::ordered_trie_root(receipts.iter().map(rlp::encode)); + let receipts_root = trie::ordered_trie_root(receipts.iter().map(alloy_rlp::encode)); let partial_header = PartialHeader { parent_hash, - beneficiary: beneficiary.to_ethers(), - state_root: self.db.maybe_state_root().unwrap_or_default().to_ethers(), + beneficiary, + state_root: self.db.maybe_state_root().unwrap_or_default(), receipts_root, logs_bloom: bloom, - difficulty: difficulty.to_ethers(), - number: block_number.to_ethers(), - gas_limit: gas_limit.to_ethers(), - gas_used: cumulative_gas_used, + difficulty, + number: block_number.to::(), + gas_limit: gas_limit.to::(), + gas_used: cumulative_gas_used.to::(), timestamp, extra_data: Default::default(), mix_hash: Default::default(), nonce: Default::default(), - base_fee: base_fee.map(|b| b.to_ethers()), + base_fee: base_fee.map(|b| b.to::()), }; let block = Block::new(partial_header, transactions.clone(), ommers); @@ -237,14 +240,14 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator fn next(&mut self) -> Option { let transaction = self.pending.next()?; let sender = *transaction.pending_transaction.sender(); - let account = match self.db.basic(sender.to_alloy()).map(|acc| acc.unwrap_or_default()) { + let account = match self.db.basic(sender).map(|acc| acc.unwrap_or_default()) { Ok(account) => account, Err(err) => return Some(TransactionExecutionOutcome::DatabaseError(transaction, err)), }; let env = self.env_for(&transaction.pending_transaction); // check that we comply with the block's gas limit let max_gas = self.gas_used.saturating_add(U256::from(env.tx.gas_limit)); - if max_gas > env.block.gas_limit.to_ethers() { + if max_gas > env.block.gas_limit { return Some(TransactionExecutionOutcome::Exhausted(transaction)) } @@ -312,7 +315,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator trace!(target: "backend", ?exit_reason, ?gas_used, "[{:?}] executed with out={:?}", transaction.hash(), out); - self.gas_used.saturating_add(U256::from(gas_used)); + self.gas_used = self.gas_used.saturating_add(U256::from(gas_used)); trace!(target: "backend::executor", "transacted [{:?}], result: {:?} gas {}", transaction.hash(), exit_reason, gas_used); @@ -321,7 +324,11 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator exit_reason, out, gas_used, - logs: logs.unwrap_or_default().into_iter().map(Into::into).collect(), + logs: logs + .unwrap_or_default() + .into_iter() + .map(|log| Log::new_unchecked(log.address, log.topics, log.data)) + .collect(), traces: inspector .tracer .unwrap_or(TracingInspector::new(TracingInspectorConfig::all())) @@ -339,7 +346,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator fn logs_bloom(logs: Vec, bloom: &mut Bloom) { for log in logs { bloom.accrue(BloomInput::Raw(&log.address[..])); - for topic in log.topics { + for topic in log.topics() { bloom.accrue(BloomInput::Raw(&topic[..])); } } diff --git a/crates/anvil/src/eth/backend/info.rs b/crates/anvil/src/eth/backend/info.rs index de0a3d2ac54e0..7b4c5d9c7e7ab 100644 --- a/crates/anvil/src/eth/backend/info.rs +++ b/crates/anvil/src/eth/backend/info.rs @@ -3,7 +3,7 @@ use crate::mem::Backend; use alloy_primitives::B256; use alloy_rpc_types::Block as AlloyBlock; -use anvil_core::eth::{block::Block, receipt::TypedReceipt}; +use anvil_core::eth::{block::Block, transaction::TypedReceipt}; use std::{fmt, sync::Arc}; /// A type that can fetch data related to the ethereum storage. diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f3ae13126de29..f95b6b96ee9a3 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -29,36 +29,36 @@ use crate::{ }, NodeConfig, }; -use alloy_primitives::{Address, Bloom, Bytes, TxHash, B256, B64, U128, U256, U64, U8}; +use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; +use alloy_network::Sealable; +use alloy_primitives::{keccak256, Address, Bytes, TxHash, B256, B64, U128, U256, U64, U8}; +use alloy_rlp::Decodable; use alloy_rpc_trace_types::{ geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, }; use alloy_rpc_types::{ state::StateOverride, AccessList, Block as AlloyBlock, BlockId, - BlockNumberOrTag as BlockNumber, CallRequest, Filter, FilteredParams, Header as AlloyHeader, - Log, Transaction, TransactionReceipt, + BlockNumberOrTag as BlockNumber, CallRequest, EIP1186AccountProofResponse as AccountProof, + EIP1186StorageProof as StorageProof, Filter, FilteredParams, Header as AlloyHeader, Log, + Transaction, TransactionReceipt, }; use anvil_core::{ eth::{ - block::{Block, BlockInfo, Header}, - proof::{AccountProof, BasicAccount, StorageProof}, - receipt::{EIP658Receipt, TypedReceipt}, + block::{Block, BlockInfo}, + proof::BasicAccount, transaction::{ - MaybeImpersonatedTransaction, PendingTransaction, TransactionInfo, TypedTransaction, + MaybeImpersonatedTransaction, PendingTransaction, TransactionInfo, TypedReceipt, + TypedTransaction, }, trie::RefTrieDB, - utils::alloy_to_revm_access_list, + utils::{alloy_to_revm_access_list, meets_eip155}, }, types::{Forking, Index}, }; use anvil_rpc::error::RpcError; -use ethers::{ - abi::ethereum_types::BigEndianHash, - utils::{keccak256, rlp}, -}; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; -use foundry_common::types::{ToAlloy, ToEthers}; +use foundry_common::types::ToAlloy; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, @@ -78,7 +78,6 @@ use foundry_evm::{ }; use futures::channel::mpsc::{unbounded, UnboundedSender}; use hash_db::HashDB; -use itertools::Itertools; use parking_lot::{Mutex, RwLock}; use std::{ collections::{BTreeMap, HashMap}, @@ -354,9 +353,6 @@ impl Backend { pub fn precompiles(&self) -> Vec
{ get_precompiles_for(self.env.read().cfg.spec_id) - .into_iter() - .map(ToAlloy::to_alloy) - .collect_vec() } /// Resets the fork to a fresh state @@ -417,7 +413,7 @@ impl Backend { ..env.block.clone() }; - self.time.reset(env.block.timestamp.to_ethers().as_u64()); + self.time.reset(env.block.timestamp.to::()); // this is the base fee of the current block, but we need the base fee of // the next block @@ -551,7 +547,7 @@ impl Backend { slot: U256, val: B256, ) -> DatabaseResult<()> { - self.db.write().await.set_storage_at(address, slot, val.to_ethers().into_uint().to_alloy()) + self.db.write().await.set_storage_at(address, slot, U256::from_be_bytes(val.0)) } /// Returns the configured specid @@ -677,7 +673,7 @@ impl Backend { if let Some(hash) = storage.hashes.remove(&n) { if let Some(block) = storage.blocks.remove(&hash) { for tx in block.transactions { - let _ = storage.transactions.remove(&tx.hash().to_alloy()); + let _ = storage.transactions.remove(&tx.hash()); } } } @@ -849,8 +845,8 @@ impl Backend { pending: pool_transactions.into_iter(), block_env: env.block.clone(), cfg_env: env.cfg, - parent_hash: storage.best_hash.to_ethers(), - gas_used: U256::ZERO.to_ethers(), + parent_hash: storage.best_hash, + gas_used: U256::ZERO, enable_steps_tracing: self.enable_steps_tracing, }; @@ -908,18 +904,15 @@ impl Backend { pending: pool_transactions.into_iter(), block_env: env.block.clone(), cfg_env: env.cfg.clone(), - parent_hash: best_hash.to_ethers(), - gas_used: U256::ZERO.to_ethers(), + parent_hash: best_hash, + gas_used: U256::ZERO, enable_steps_tracing: self.enable_steps_tracing, }; let executed_tx = executor.execute(); // we also need to update the new blockhash in the db itself let block_hash = executed_tx.block.block.header.hash(); - db.insert_block_hash( - executed_tx.block.block.header.number.to_alloy(), - block_hash.to_alloy(), - ); + db.insert_block_hash(U256::from(executed_tx.block.block.header.number), block_hash); (executed_tx, block_hash) }; @@ -942,16 +935,16 @@ impl Backend { let mut storage = self.blockchain.storage.write(); // update block metadata storage.best_number = block_number; - storage.best_hash = block_hash.to_alloy(); + storage.best_hash = block_hash; // Difficulty is removed and not used after Paris (aka TheMerge). Value is replaced with // prevrandao. https://github.com/bluealloy/revm/blob/1839b3fce8eaeebb85025576f2519b80615aca1e/crates/interpreter/src/instructions/host_env.rs#L27 if !self.is_eip3675() { storage.total_difficulty = - storage.total_difficulty.saturating_add(header.difficulty.to_alloy()); + storage.total_difficulty.saturating_add(header.difficulty); } - storage.blocks.insert(block_hash.to_alloy(), block); - storage.hashes.insert(block_number, block_hash.to_alloy()); + storage.blocks.insert(block_hash, block); + storage.hashes.insert(block_number, block_hash); node_info!(""); // insert all transactions @@ -964,7 +957,7 @@ impl Backend { node_info!(" Gas used: {}", receipt.gas_used()); if !info.exit.is_ok() { let r = decode_revert( - info.out.as_deref().unwrap_or_default(), + info.out.clone().unwrap_or_default().as_ref(), None, Some(info.exit), ); @@ -975,10 +968,10 @@ impl Backend { let mined_tx = MinedTransaction { info, receipt, - block_hash: block_hash.to_alloy(), + block_hash, block_number: block_number.to::(), }; - storage.transactions.insert(mined_tx.info.transaction_hash.to_alloy(), mined_tx); + storage.transactions.insert(mined_tx.info.transaction_hash, mined_tx); } // remove old transactions that exceed the transaction block keeper @@ -1008,13 +1001,13 @@ impl Backend { (outcome, header, block_hash) }; let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( - header.gas_used.to_alloy(), - header.gas_limit.to_alloy(), - header.base_fee_per_gas.unwrap_or_default().to_alloy(), + U256::from(header.gas_used), + U256::from(header.gas_limit), + U256::from(header.base_fee_per_gas.unwrap_or_default()), ); // notify all listeners - self.notify_on_new_block(header, block_hash.to_alloy()); + self.notify_on_new_block(header, block_hash); // update next base fee self.fees.set_base_fee(U256::from(next_block_base_fee)); @@ -1035,7 +1028,7 @@ impl Backend { overrides: Option, ) -> Result<(InstructionResult, Option, u64, State), BlockchainError> { self.with_database_at(block_request, |state, block| { - let block_number = (block.number.to_ethers()).as_u64(); + let block_number = block.number.to::(); let (exit, out, gas, state) = match overrides { None => self.call_with_state(state, request, fee_details, block), Some(overrides) => { @@ -1274,9 +1267,7 @@ impl Backend { block .transactions .iter() - .filter_map(|tx| { - storage.transactions.get(&tx.hash().to_alloy()).map(|tx| tx.info.clone()) - }) + .filter_map(|tx| storage.transactions.get(&tx.hash()).map(|tx| tx.info.clone())) .collect() }; @@ -1286,9 +1277,9 @@ impl Backend { for log in logs.into_iter() { let mut log = Log { - address: log.address.to_alloy(), - topics: log.topics.into_iter().map(ToAlloy::to_alloy).collect(), - data: log.data.0.into(), + address: log.address, + topics: log.topics().to_vec(), + data: log.data.data, block_hash: None, block_number: None, transaction_hash: None, @@ -1310,9 +1301,9 @@ impl Backend { } if is_match { - log.block_hash = Some(block_hash.to_alloy()); + log.block_hash = Some(block_hash); log.block_number = Some(block.header.number.to_alloy()); - log.transaction_hash = Some(transaction_hash.to_alloy()); + log.transaction_hash = Some(transaction_hash); log.transaction_index = Some(U256::from(transaction.transaction_index)); log.log_index = Some(U256::from(block_log_index)); all_logs.push(log); @@ -1435,11 +1426,11 @@ impl Backend { let base_fee = block.header.base_fee_per_gas; let storage = self.blockchain.storage.read(); for hash in block.transactions.iter().map(|tx| tx.hash()) { - let info = storage.transactions.get(&hash.to_alloy())?.info.clone(); + let info = storage.transactions.get(&hash)?.info.clone(); let tx = block.transactions.get(info.transaction_index as usize)?.clone(); let tx = transaction_build( - Some(hash.to_alloy()), + Some(hash), tx, Some(block), Some(info), @@ -1513,12 +1504,10 @@ impl Backend { } } BlockNumber::Finalized => { - if storage.best_number.to_ethers() > (slots_in_an_epoch.to_ethers() * 2) { - *storage.hashes.get( - &(storage.best_number.to_ethers() - - (slots_in_an_epoch.to_ethers() * 2)) - .to_alloy(), - )? + if storage.best_number > (slots_in_an_epoch * U64::from(2)) { + *storage + .hashes + .get(&(storage.best_number - (slots_in_an_epoch * U64::from(2))))? } else { storage.genesis_hash } @@ -1549,7 +1538,7 @@ impl Backend { /// Takes a block as it's stored internally and returns the eth api conform block format pub fn convert_block(&self, block: Block) -> AlloyBlock { - let size = U256::from(rlp::encode(&block).len() as u32); + let size = U256::from(alloy_rlp::encode(&block).len() as u32); let Block { header, transactions, .. } = block; @@ -1571,27 +1560,31 @@ impl Backend { mix_hash, nonce, base_fee_per_gas, + withdrawals_root: _, + blob_gas_used: _, + excess_blob_gas: _, + parent_beacon_block_root: _, } = header; AlloyBlock { total_difficulty: Some(self.total_difficulty()), header: AlloyHeader { - hash: Some(hash.to_alloy()), - parent_hash: parent_hash.to_alloy(), - uncles_hash: ommers_hash.to_alloy(), - miner: beneficiary.to_alloy(), - state_root: state_root.to_alloy(), - transactions_root: transactions_root.to_alloy(), - receipts_root: receipts_root.to_alloy(), + hash: Some(hash), + parent_hash, + uncles_hash: ommers_hash, + miner: beneficiary, + state_root, + transactions_root, + receipts_root, number: Some(number.to_alloy()), gas_used: gas_used.to_alloy(), gas_limit: gas_limit.to_alloy(), extra_data: extra_data.0.into(), - logs_bloom: Bloom::from_slice(logs_bloom.as_bytes()), + logs_bloom, timestamp: U256::from(timestamp), - difficulty: difficulty.to_alloy(), - mix_hash: Some(mix_hash.to_alloy()), - nonce: Some(B64::from_slice(nonce.as_bytes())), + difficulty, + mix_hash: Some(mix_hash), + nonce: Some(B64::from(nonce)), base_fee_per_gas: base_fee_per_gas.map(|f| f.to_alloy()), withdrawals_root: None, blob_gas_used: None, @@ -1600,7 +1593,7 @@ impl Backend { }, size: Some(size), transactions: alloy_rpc_types::BlockTransactions::Hashes( - transactions.into_iter().map(|tx| tx.hash().to_alloy()).collect(), + transactions.into_iter().map(|tx| tx.hash()).collect(), ), uncles: vec![], withdrawals: None, @@ -1677,10 +1670,10 @@ impl Backend { let block = block.block; let block = BlockEnv { number: block.header.number.to_alloy(), - coinbase: block.header.beneficiary.to_alloy(), + coinbase: block.header.beneficiary, timestamp: rU256::from(block.header.timestamp), - difficulty: block.header.difficulty.to_alloy(), - prevrandao: Some(block.header.mix_hash).map(|h| h.to_alloy()), + difficulty: block.header.difficulty, + prevrandao: Some(block.header.mix_hash), basefee: block.header.base_fee_per_gas.unwrap_or_default().to_alloy(), gas_limit: block.header.gas_limit.to_alloy(), ..Default::default() @@ -1701,14 +1694,14 @@ impl Backend { if let Some((state, block)) = self .get_block(block_number.to::()) - .and_then(|block| Some((states.get(&block.header.hash().to_alloy())?, block))) + .and_then(|block| Some((states.get(&block.header.hash())?, block))) { let block = BlockEnv { number: block.header.number.to_alloy(), - coinbase: block.header.beneficiary.to_alloy(), + coinbase: block.header.beneficiary, timestamp: rU256::from(block.header.timestamp), - difficulty: block.header.difficulty.to_alloy(), - prevrandao: Some(block.header.mix_hash).map(|h| h.to_alloy()), + difficulty: block.header.difficulty, + prevrandao: Some(block.header.mix_hash), basefee: block.header.base_fee_per_gas.unwrap_or_default().to_alloy(), gas_limit: block.header.gas_limit.to_alloy(), ..Default::default() @@ -1738,7 +1731,7 @@ impl Backend { warn!(target: "backend", "Not historic state found for block={}", block_number); return Err(BlockchainError::BlockOutOfRange( - self.env.read().block.number.to_ethers().as_u64(), + self.env.read().block.number.to::(), block_number.to::(), )); } @@ -1829,8 +1822,7 @@ impl Backend { block_request: Option, ) -> Result { if let Some(BlockRequest::Pending(pool_transactions)) = block_request.as_ref() { - if let Some(value) = get_pool_transactions_nonce(pool_transactions, address.to_ethers()) - { + if let Some(value) = get_pool_transactions_nonce(pool_transactions, address) { return Ok(value); } } @@ -1884,7 +1876,7 @@ impl Backend { let mut traces = vec![]; let storage = self.blockchain.storage.read(); for tx in block.transactions { - traces.extend(storage.transactions.get(&tx.hash().to_alloy())?.parity_traces()); + traces.extend(storage.transactions.get(&tx.hash())?.parity_traces()); } Some(traces) } @@ -1982,7 +1974,7 @@ impl Backend { let block = self.get_block(id)?; for transaction in block.transactions { - let receipt = self.mined_transaction_receipt(transaction.hash().to_alloy())?; + let receipt = self.mined_transaction_receipt(transaction.hash())?; receipts.push(receipt.inner); } @@ -1994,18 +1986,20 @@ impl Backend { let MinedTransaction { info, receipt, block_hash, .. } = self.blockchain.get_transaction_by_hash(&hash)?; - let EIP658Receipt { status_code, gas_used, logs_bloom, logs } = receipt.into(); + let ReceiptWithBloom { receipt, bloom } = receipt.into(); + let Receipt { success, cumulative_gas_used: _, logs } = receipt; + let logs_bloom = bloom; let index = info.transaction_index as usize; let block = self.blockchain.get_block_by_hash(&block_hash)?; // TODO store cumulative gas used in receipt instead - let receipts = self.get_receipts(block.transactions.iter().map(|tx| tx.hash().to_alloy())); + let receipts = self.get_receipts(block.transactions.iter().map(|tx| tx.hash())); let mut cumulative_gas_used = U256::ZERO; for receipt in receipts.iter().take(index + 1) { - cumulative_gas_used = cumulative_gas_used.saturating_add(receipt.gas_used().to_alloy()); + cumulative_gas_used = cumulative_gas_used.saturating_add(receipt.gas_used()); } // cumulative_gas_used = cumulative_gas_used.saturating_sub(gas_used); @@ -2018,30 +2012,29 @@ impl Backend { let transaction_type = transaction.transaction.r#type(); let effective_gas_price = match transaction.transaction { - TypedTransaction::Legacy(t) => t.gas_price.to_alloy(), - TypedTransaction::EIP2930(t) => t.gas_price.to_alloy(), + TypedTransaction::Legacy(t) => t.gas_price, + TypedTransaction::EIP2930(t) => t.gas_price, TypedTransaction::EIP1559(t) => block .header .base_fee_per_gas - .map(|f| f.to_alloy()) - .unwrap_or(self.base_fee()) - .checked_add(t.max_priority_fee_per_gas.to_alloy()) - .unwrap_or(U256::MAX), - TypedTransaction::Deposit(_) => U256::from(0), + .map_or(self.base_fee().to::(), |b| b as u128) + .checked_add(t.max_priority_fee_per_gas) + .unwrap_or(u128::MAX), + TypedTransaction::Deposit(_) => 0_u128, }; let deposit_nonce = transaction_type.and_then(|x| (x == 0x7E).then_some(info.nonce)); let mut inner = TransactionReceipt { - transaction_hash: Some(info.transaction_hash.to_alloy()), + transaction_hash: Some(info.transaction_hash), transaction_index: U64::from(info.transaction_index), block_hash: Some(block_hash), - block_number: Some(U256::from(block.header.number.as_u64())), - from: info.from.to_alloy(), - to: info.to.map(|t| t.to_alloy()), + block_number: Some(U256::from(block.header.number)), + from: info.from, + to: info.to, cumulative_gas_used, - gas_used: Some(gas_used.to_alloy()), - contract_address: info.contract_address.map(|t| t.to_alloy()), + gas_used: Some(cumulative_gas_used), + contract_address: info.contract_address, logs: { let mut pre_receipts_log_index = None; if !cumulative_receipts.is_empty() { @@ -2052,12 +2045,12 @@ impl Backend { logs.iter() .enumerate() .map(|(i, log)| Log { - address: log.address.to_alloy(), - topics: log.topics.clone().into_iter().map(|t| t.to_alloy()).collect(), - data: log.data.clone().0.into(), + address: log.address, + topics: log.topics().to_vec(), + data: log.data.data.clone(), block_hash: Some(block_hash), - block_number: Some(U256::from(block.header.number.as_u64())), - transaction_hash: Some(info.transaction_hash.to_alloy()), + block_number: Some(U256::from(block.header.number)), + transaction_hash: Some(info.transaction_hash), transaction_index: Some(U256::from(info.transaction_index)), log_index: Some(U256::from( (pre_receipts_log_index.unwrap_or(0)) + i as u32, @@ -2066,11 +2059,11 @@ impl Backend { }) .collect() }, - status_code: Some(U64::from(status_code)), + status_code: Some(U64::from(success)), state_root: None, - logs_bloom: Bloom::from_slice(logs_bloom.as_bytes()), + logs_bloom, transaction_type: transaction_type.map(U8::from).unwrap_or_default(), - effective_gas_price: effective_gas_price.to::(), + effective_gas_price: U128::from(effective_gas_price), blob_gas_price: None, blob_gas_used: None, other: Default::default(), @@ -2160,12 +2153,12 @@ impl Backend { let block = storage.blocks.get(&block_hash).cloned()?; let index: usize = index.into(); let tx = block.transactions.get(index)?.clone(); - let info = storage.transactions.get(&tx.hash().to_alloy())?.info.clone(); + let info = storage.transactions.get(&tx.hash())?.info.clone(); (info, block, tx) }; Some(transaction_build( - Some(info.transaction_hash.to_alloy()), + Some(info.transaction_hash), tx, Some(&block), Some(info), @@ -2200,7 +2193,7 @@ impl Backend { let tx = block.transactions.get(info.transaction_index as usize)?.clone(); Some(transaction_build( - Some(info.transaction_hash.to_alloy()), + Some(info.transaction_hash), tx, Some(&block), Some(info), @@ -2217,7 +2210,7 @@ impl Backend { keys: Vec, block_request: Option, ) -> Result { - let account_key = B256::from(keccak256(address.to_ethers().as_bytes())); + let account_key = B256::from(alloy_primitives::utils::keccak256(address)); let block_number = block_request.as_ref().map(|r| r.block_number()); self.with_database_at(block_request, |block_db, _| { @@ -2230,13 +2223,13 @@ impl Backend { .map_err(|err| BlockchainError::TrieError(err.to_string()))?; let maybe_account: Option = { - let acc_decoder = |bytes: &[u8]| { - rlp::decode(bytes).unwrap_or_else(|_| { + let acc_decoder = |mut bytes: &[u8]| { + BasicAccount::decode(&mut bytes).unwrap_or_else(|_| { panic!("prove_account_at, could not query trie for account={:?}", &address) }) }; let query = (&mut recorder, acc_decoder); - trie.get_with(account_key.to_ethers().as_bytes(), query) + trie.get_with(account_key.as_slice(), query) .map_err(|err| BlockchainError::TrieError(err.to_string()))? }; let account = maybe_account.unwrap_or_default(); @@ -2249,7 +2242,7 @@ impl Backend { // proof is rlp encoded: // // - rlp::encode(&record).to_vec().into() + alloy_rlp::encode(record).to_vec().into() }) .collect::>(); @@ -2257,9 +2250,9 @@ impl Backend { block_db.maybe_account_db(address).ok_or(BlockchainError::DataUnavailable)?; let account_proof = AccountProof { - address: address.to_ethers(), + address, balance: account.balance, - nonce: account.nonce.as_u64().into(), + nonce: account.nonce.to::(), code_hash: account.code_hash, storage_hash: account.storage_root, account_proof: proof, @@ -2270,15 +2263,15 @@ impl Backend { let key = B256::from(keccak256(storage_key)); prove_storage(&account, &account_db.0, key).map( |(storage_proof, storage_value)| StorageProof { - key: storage_key.to_ethers(), - value: storage_value.to_ethers().into_uint(), + key: alloy_rpc_types::JsonStorageKey(storage_key), + value: U256::from_be_bytes(storage_value.0), proof: storage_proof .into_iter() .map(|proof| { // proof is rlp encoded: // // - rlp::encode(&proof).to_vec().into() + alloy_rlp::encode(proof).to_vec().into() }) .collect(), }, @@ -2317,23 +2310,21 @@ impl Backend { /// Get max nonce from transaction pool by address fn get_pool_transactions_nonce( pool_transactions: &[Arc], - address: ethers::types::H160, + address: Address, ) -> Option { let highest_nonce_tx = pool_transactions .iter() .filter(|tx| *tx.pending_transaction.sender() == address) .reduce(|accum, item| { let nonce = item.pending_transaction.nonce(); - if nonce.gt(accum.pending_transaction.nonce()) { + if nonce > accum.pending_transaction.nonce() { item } else { accum } }); if let Some(highest_nonce_tx) = highest_nonce_tx { - return Some( - highest_nonce_tx.pending_transaction.nonce().to_alloy().saturating_add(U256::from(1)), - ); + return Some(highest_nonce_tx.pending_transaction.nonce().saturating_add(U256::from(1))); } None } @@ -2345,7 +2336,7 @@ impl TransactionValidator for Backend { tx: &PendingTransaction, ) -> Result<(), BlockchainError> { let address = *tx.sender(); - let account = self.get_account(address.to_alloy()).await?; + let account = self.get_account(address).await?; let env = self.next_env(); Ok(self.validate_pool_transaction_for(tx, &account, &env)?) } @@ -2364,7 +2355,7 @@ impl TransactionValidator for Backend { if let Some(legacy) = tx.as_legacy() { // if env.cfg.spec_id >= SpecId::SPURIOUS_DRAGON && - !legacy.meets_eip155(chain_id.to::()) + !meets_eip155(chain_id.to::(), legacy.signature().v()) { warn!(target: "backend", ?chain_id, ?tx_chain_id, "incompatible EIP155-based V"); return Err(InvalidTransactionError::IncompatibleEIP155); @@ -2376,13 +2367,13 @@ impl TransactionValidator for Backend { } } - if tx.gas_limit() < MIN_TRANSACTION_GAS.to_ethers() { + if tx.gas_limit() < MIN_TRANSACTION_GAS { warn!(target: "backend", "[{:?}] gas too low", tx.hash()); return Err(InvalidTransactionError::GasTooLow); } // Check gas limit, iff block gas limit is set. - if !env.cfg.disable_block_gas_limit && tx.gas_limit() > env.block.gas_limit.to_ethers() { + if !env.cfg.disable_block_gas_limit && tx.gas_limit() > env.block.gas_limit { warn!(target: "backend", "[{:?}] gas too high", tx.hash()); return Err(InvalidTransactionError::GasTooHigh(ErrDetail { detail: String::from("tx.gas_limit > env.block.gas_limit"), @@ -2393,14 +2384,14 @@ impl TransactionValidator for Backend { let is_deposit_tx = matches!(&pending.transaction.transaction, TypedTransaction::Deposit(_)); let nonce: u64 = - (*tx.nonce()).try_into().map_err(|_| InvalidTransactionError::NonceMaxValue)?; + tx.nonce().try_into().map_err(|_| InvalidTransactionError::NonceMaxValue)?; if nonce < account.nonce && !is_deposit_tx { warn!(target: "backend", "[{:?}] nonce too low", tx.hash()); return Err(InvalidTransactionError::NonceTooLow); } if (env.cfg.spec_id as u8) >= (SpecId::LONDON as u8) { - if tx.gas_price() < env.block.basefee.to_ethers() && !is_deposit_tx { + if tx.gas_price() < env.block.basefee && !is_deposit_tx { warn!(target: "backend", "max fee per gas={}, too low, block basefee={}",tx.gas_price(), env.block.basefee); return Err(InvalidTransactionError::FeeCapTooLow); } @@ -2423,8 +2414,7 @@ impl TransactionValidator for Backend { tx.hash()); InvalidTransactionError::InsufficientFunds })?; - - if account.balance < req_funds.to_alloy() { + if account.balance < req_funds { warn!(target: "backend", "[{:?}] insufficient allowance={}, required={} account={:?}", tx.hash(), account.balance, req_funds, *pending.sender()); return Err(InvalidTransactionError::InsufficientFunds); } @@ -2438,7 +2428,7 @@ impl TransactionValidator for Backend { env: &Env, ) -> Result<(), InvalidTransactionError> { self.validate_pool_transaction_for(tx, account, env)?; - if tx.nonce().as_u64() > account.nonce { + if tx.nonce().to::() > account.nonce { return Err(InvalidTransactionError::NonceTooHigh); } Ok(()) @@ -2479,9 +2469,9 @@ pub fn transaction_build( } transaction.block_hash = - block.as_ref().map(|block| B256::from(keccak256(&rlp::encode(&block.header)))); + block.as_ref().map(|block| B256::from(keccak256(alloy_rlp::encode(&block.header)))); - transaction.block_number = block.as_ref().map(|block| U256::from(block.header.number.as_u64())); + transaction.block_number = block.as_ref().map(|block| U256::from(block.header.number)); transaction.transaction_index = info.as_ref().map(|status| U256::from(status.transaction_index)); @@ -2490,11 +2480,10 @@ pub fn transaction_build( // can't recover the sender, instead we use the sender from the executed transaction and set the // impersonated hash. if eth_transaction.is_impersonated() { - transaction.from = info.as_ref().map(|info| info.from).unwrap_or_default().to_alloy(); - transaction.hash = - eth_transaction.impersonated_hash(transaction.from.to_ethers()).to_alloy(); + transaction.from = info.as_ref().map(|info| info.from).unwrap_or_default(); + transaction.hash = eth_transaction.impersonated_hash(transaction.from); } else { - transaction.from = eth_transaction.recover().expect("can recover signed tx").to_alloy(); + transaction.from = eth_transaction.recover().expect("can recover signed tx"); } // if a specific hash was provided we update the transaction's hash @@ -2506,11 +2495,7 @@ pub fn transaction_build( transaction.hash = tx_hash; } - transaction.to = info - .as_ref() - .map_or(eth_transaction.to().cloned(), |status| status.to) - .map(|t| t.to_alloy()); - + transaction.to = info.as_ref().map_or(eth_transaction.to(), |status| status.to); transaction } @@ -2531,12 +2516,12 @@ pub fn prove_storage( .unwrap(); let item: U256 = { - let decode_value = |bytes: &[u8]| rlp::decode(bytes).expect("decoding db value failed"); + let decode_value = + |mut bytes: &[u8]| U256::decode(&mut bytes).expect("decoding db value failed"); let query = (&mut recorder, decode_value); - trie.get_with(storage_key.to_ethers().as_bytes(), query) + trie.get_with(storage_key.as_slice(), query) .map_err(|err| BlockchainError::TrieError(err.to_string()))? - .unwrap_or_else(|| U256::ZERO.to_ethers()) - .to_alloy() + .unwrap_or(U256::ZERO) }; Ok((recorder.drain().into_iter().map(|r| r.data).collect(), B256::from(item))) diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index d5a2d40a7a8bb..af936578d04a3 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -1,56 +1,34 @@ //! Support for generating the state root for memdb storage use crate::eth::{backend::db::AsHashDB, error::BlockchainError}; -use alloy_primitives::{Address, Bytes, B256, U256 as rU256}; +use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_rlp::Encodable; use alloy_rpc_types::state::StateOverride; use anvil_core::eth::trie::RefSecTrieDBMut; -use ethers::utils::{rlp, rlp::RlpStream}; -use foundry_common::types::ToEthers; use foundry_evm::{ backend::DatabaseError, hashbrown::HashMap as Map, revm::{ db::{CacheDB, DatabaseRef, DbAccount}, - primitives::{AccountInfo, Bytecode, Log}, + primitives::{AccountInfo, Bytecode}, }, }; use memory_db::HashKey; use trie_db::TrieMut; -/// Returns the log hash for all `logs` -/// -/// The log hash is `keccak(rlp(logs[]))`, -pub fn log_rlp_hash(logs: Vec) -> B256 { - let mut stream = RlpStream::new(); - stream.begin_unbounded_list(); - for log in logs { - let topics = log.topics.into_iter().map(|t| t.to_ethers()).collect::>(); - stream.begin_list(3); - stream.append(&(log.address.to_ethers())); - stream.append_list(&topics); - stream.append(&log.data.0); - } - stream.finalize_unbounded_list(); - let out = stream.out().freeze(); - - let out = ethers::utils::keccak256(out); - B256::from_slice(out.as_slice()) -} - /// Returns storage trie of an account as `HashDB` -pub fn storage_trie_db(storage: &Map) -> (AsHashDB, B256) { +pub fn storage_trie_db(storage: &Map) -> (AsHashDB, B256) { // Populate DB with full trie from entries. let (db, root) = { let mut db = , _>>::default(); let mut root = Default::default(); { let mut trie = RefSecTrieDBMut::new(&mut db, &mut root); - for (k, v) in storage.iter().filter(|(_k, v)| *v != &rU256::from(0)) { - let mut temp: [u8; 32] = [0; 32]; - (*k).to_ethers().to_big_endian(&mut temp); - let key = B256::from(temp).to_ethers(); - let value = rlp::encode(&(*v).to_ethers()); - trie.insert(key.as_bytes(), value.as_ref()).unwrap(); + for (k, v) in storage.iter().filter(|(_k, v)| *v != &U256::from(0)) { + let key = B256::from(*k); + let mut value: Vec = Vec::new(); + U256::encode(v, &mut value); + trie.insert(key.as_slice(), value.as_ref()).unwrap(); } } (db, root) @@ -95,13 +73,14 @@ pub fn state_merkle_trie_root(accounts: &Map) -> B256 { } /// Returns the RLP for this account. -pub fn trie_account_rlp(info: &AccountInfo, storage: &Map) -> Bytes { - let mut stream = RlpStream::new_list(4); - stream.append(&info.nonce); - stream.append(&info.balance.to_ethers()); - stream.append(&storage_trie_db(storage).1.to_ethers()); - stream.append(&info.code_hash.as_slice()); - stream.out().freeze().into() +pub fn trie_account_rlp(info: &AccountInfo, storage: &Map) -> Bytes { + let mut out: Vec = Vec::new(); + let list: [&dyn Encodable; 4] = + [&info.nonce, &info.balance, &storage_trie_db(storage).1, &info.code_hash]; + + alloy_rlp::encode_list::<_, dyn Encodable>(&list, &mut out); + + out.into() } /// Applies the given state overrides to the state, returning a new CacheDB state diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 8757ef3a5e815..b84a34dc7312b 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -6,6 +6,7 @@ use crate::eth::{ }, pool::transactions::PoolTransaction, }; +use alloy_network::Sealable; use alloy_primitives::{Bytes, TxHash, B256, U256, U64}; use alloy_rpc_trace_types::{ geth::{DefaultFrame, GethDefaultTracingOptions}, @@ -16,10 +17,8 @@ use alloy_rpc_types::{ }; use anvil_core::eth::{ block::{Block, PartialHeader}, - receipt::TypedReceipt, - transaction::{MaybeImpersonatedTransaction, TransactionInfo}, + transaction::{MaybeImpersonatedTransaction, TransactionInfo, TypedReceipt}, }; -use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::{ revm::primitives::Env, traces::{GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig}, @@ -233,10 +232,10 @@ impl BlockchainStorage { // create a dummy genesis block let partial_header = PartialHeader { timestamp, - base_fee: base_fee.map(|b| b.to_ethers()), - gas_limit: env.block.gas_limit.to_ethers(), - beneficiary: env.block.coinbase.to_ethers(), - difficulty: env.block.difficulty.to_ethers(), + base_fee: base_fee.map(|b| b.to::()), + gas_limit: env.block.gas_limit.to::(), + beneficiary: env.block.coinbase, + difficulty: env.block.difficulty, ..Default::default() }; let block = Block::new::(partial_header, vec![], vec![]); @@ -245,11 +244,11 @@ impl BlockchainStorage { let best_number: U64 = U64::from(0u64); Self { - blocks: HashMap::from([(genesis_hash.to_alloy(), block)]), - hashes: HashMap::from([(best_number, genesis_hash.to_alloy())]), - best_hash: best_hash.to_alloy(), + blocks: HashMap::from([(genesis_hash, block)]), + hashes: HashMap::from([(best_number, genesis_hash)]), + best_hash, best_number, - genesis_hash: genesis_hash.to_alloy(), + genesis_hash, transactions: Default::default(), total_difficulty: Default::default(), } @@ -291,7 +290,7 @@ impl BlockchainStorage { pub fn remove_block_transactions(&mut self, block_hash: B256) { if let Some(block) = self.blocks.get_mut(&block_hash) { for tx in block.transactions.iter() { - self.transactions.remove(&tx.hash().to_alloy()); + self.transactions.remove(&tx.hash()); } block.transactions.clear(); } @@ -408,7 +407,7 @@ impl MinedTransaction { TracingInspectorConfig::default_parity(), ) .into_localized_transaction_traces(RethTransactionInfo { - hash: Some(self.info.transaction_hash.to_alloy()), + hash: Some(self.info.transaction_hash), index: Some(self.info.transaction_index as u64), block_hash: Some(self.block_hash), block_number: Some(self.block_number), @@ -419,7 +418,7 @@ impl MinedTransaction { pub fn geth_trace(&self, opts: GethDefaultTracingOptions) -> DefaultFrame { GethTraceBuilder::new(self.info.traces.clone(), TracingInspectorConfig::default_geth()) .geth_traces( - self.receipt.gas_used().as_u64(), + self.receipt.gas_used().to::(), self.info.out.clone().unwrap_or_default().0.into(), opts, ) diff --git a/crates/anvil/src/eth/backend/notifications.rs b/crates/anvil/src/eth/backend/notifications.rs index a463dfb9446d5..795de0cca9a55 100644 --- a/crates/anvil/src/eth/backend/notifications.rs +++ b/crates/anvil/src/eth/backend/notifications.rs @@ -1,7 +1,7 @@ //! Notifications emitted from the backed +use alloy_consensus::Header; use alloy_primitives::B256; -use anvil_core::eth::block::Header; use futures::channel::mpsc::UnboundedReceiver; use std::sync::Arc; diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index a92df9ce92e68..d0b48e411af64 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -1,20 +1,16 @@ //! Aggregated error type for this module use crate::eth::pool::transactions::PoolTransaction; +use alloy_primitives::{Bytes, SignatureError as AlloySignatureError, U256}; +use alloy_signer::Error as AlloySignerError; use alloy_transport::TransportError; use anvil_rpc::{ error::{ErrorCode, RpcError}, response::ResponseResult, }; -use ethers::{ - abi::AbiDecode, - providers::ProviderError, - signers::WalletError, - types::{Bytes, SignatureError, U256}, -}; -use foundry_common::SELECTOR_LEN; use foundry_evm::{ backend::DatabaseError, + decode::maybe_decode_revert, revm::{ self, interpreter::InstructionResult, @@ -46,9 +42,9 @@ pub enum BlockchainError { #[error("Prevrandao not in th EVM's environment after merge")] PrevrandaoNotSet, #[error(transparent)] - SignatureError(#[from] SignatureError), + AlloySignatureError(#[from] AlloySignatureError), #[error(transparent)] - WalletError(#[from] WalletError), + AlloySignerError(#[from] AlloySignerError), #[error("Rpc Endpoint not implemented")] RpcUnimplemented, #[error("Rpc error {0:?}")] @@ -58,8 +54,6 @@ pub enum BlockchainError { #[error(transparent)] FeeHistory(#[from] FeeHistoryError), #[error(transparent)] - ForkProvider(#[from] ProviderError), - #[error(transparent)] AlloyForkProvider(#[from] TransportError), #[error("EVM error {0:?}")] EvmError(InstructionResult), @@ -263,17 +257,6 @@ impl From for InvalidTransactionError { } } -/// Returns the revert reason from the `revm::TransactOut` data, if it's an abi encoded String. -/// -/// **Note:** it's assumed the `out` buffer starts with the call's signature -pub(crate) fn decode_revert_reason(out: impl AsRef<[u8]>) -> Option { - let out = out.as_ref(); - if out.len() < SELECTOR_LEN { - return None - } - String::decode(&out[SELECTOR_LEN..]).ok() -} - /// Helper trait to easily convert results to rpc results pub(crate) trait ToRpcResponseResult { fn to_rpc_result(self) -> ResponseResult; @@ -319,7 +302,9 @@ impl ToRpcResponseResult for Result { InvalidTransactionError::Revert(data) => { // this mimics geth revert error let mut msg = "execution reverted".to_string(); - if let Some(reason) = data.as_ref().and_then(decode_revert_reason) { + if let Some(reason) = + data.as_ref().and_then(|data| maybe_decode_revert(data, None, None)) + { msg = format!("{msg}: {reason}"); } RpcError { @@ -360,8 +345,10 @@ impl ToRpcResponseResult for Result { BlockchainError::FailedToDecodeStateDump => { RpcError::invalid_params("Failed to decode state dump") } - BlockchainError::SignatureError(err) => RpcError::invalid_params(err.to_string()), - BlockchainError::WalletError(err) => RpcError::invalid_params(err.to_string()), + BlockchainError::AlloySignerError(err) => RpcError::invalid_params(err.to_string()), + BlockchainError::AlloySignatureError(err) => { + RpcError::invalid_params(err.to_string()) + } BlockchainError::RpcUnimplemented => { RpcError::internal_error_with("Not implemented") } @@ -370,10 +357,6 @@ impl ToRpcResponseResult for Result { BlockchainError::InvalidFeeInput => RpcError::invalid_params( "Invalid input: `max_priority_fee_per_gas` greater than `max_fee_per_gas`", ), - BlockchainError::ForkProvider(err) => { - error!(%err, "fork provider error"); - RpcError::internal_error_with(format!("Fork Error: {err:?}")) - } BlockchainError::AlloyForkProvider(err) => { error!(%err, "alloy fork provider error"); RpcError::internal_error_with(format!("Fork Error: {err:?}")) diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 1b8680981916e..ef597331a6cd6 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -4,7 +4,6 @@ use crate::eth::{ }; use alloy_primitives::{B256, U256}; use anvil_core::eth::transaction::TypedTransaction; -use foundry_common::types::ToAlloy; use foundry_evm::revm::primitives::SpecId; use futures::StreamExt; use parking_lot::{Mutex, RwLock}; @@ -231,10 +230,10 @@ impl FeeHistoryService { let current_receipts = self.storage_info.receipts(hash); if let (Some(block), Some(receipts)) = (current_block, current_receipts) { - block_number = Some(block.header.number.as_u64()); + block_number = Some(block.header.number); - let gas_used = block.header.gas_used.as_u64() as f64; - let gas_limit = block.header.gas_limit.as_u64() as f64; + let gas_used = block.header.gas_used as f64; + let gas_limit = block.header.gas_limit as f64; let gas_target = gas_limit / elasticity; item.gas_used_ratio = gas_used / (gas_target * elasticity); @@ -244,25 +243,25 @@ impl FeeHistoryService { .iter() .enumerate() .map(|(i, receipt)| { - let gas_used = receipt.gas_used().as_u64(); + let gas_used = receipt.gas_used(); let effective_reward = match block.transactions.get(i).map(|tx| &tx.transaction) { Some(TypedTransaction::Legacy(t)) => { - t.gas_price.to_alloy().saturating_sub(base_fee).to::() + U256::from(t.gas_price).saturating_sub(base_fee).to::() } Some(TypedTransaction::EIP2930(t)) => { - t.gas_price.to_alloy().saturating_sub(base_fee).to::() + U256::from(t.gas_price).saturating_sub(base_fee).to::() + } + Some(TypedTransaction::EIP1559(t)) => { + U256::from(t.max_priority_fee_per_gas) + .min(U256::from(t.max_fee_per_gas).saturating_sub(base_fee)) + .to::() } - Some(TypedTransaction::EIP1559(t)) => t - .max_priority_fee_per_gas - .to_alloy() - .min(t.max_fee_per_gas.to_alloy().saturating_sub(base_fee)) - .to::(), Some(TypedTransaction::Deposit(_)) => 0, None => 0, }; - (gas_used, effective_reward) + (gas_used.to::(), effective_reward) }) .collect(); diff --git a/crates/anvil/src/eth/mod.rs b/crates/anvil/src/eth/mod.rs index a9acd1d9af4cd..393a9ff213306 100644 --- a/crates/anvil/src/eth/mod.rs +++ b/crates/anvil/src/eth/mod.rs @@ -1,5 +1,6 @@ pub mod api; pub mod otterscan; +pub mod sign; pub use api::EthApi; pub mod backend; @@ -10,5 +11,4 @@ pub mod fees; pub(crate) mod macros; pub mod miner; pub mod pool; -pub mod sign; pub mod util; diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index d8e0deb055012..8848a954bd376 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -39,7 +39,6 @@ use crate::{ use alloy_primitives::{TxHash, U64}; use alloy_rpc_types::txpool::TxpoolStatus; use anvil_core::eth::transaction::PendingTransaction; -use foundry_common::types::ToAlloy; use futures::channel::mpsc::{channel, Receiver, Sender}; use parking_lot::{Mutex, RwLock}; use std::{collections::VecDeque, fmt, sync::Arc}; @@ -157,7 +156,7 @@ impl Pool { let mut dropped = None; if !removed.is_empty() { - dropped = removed.into_iter().find(|t| t.pending_transaction.hash().to_alloy() == tx); + dropped = removed.into_iter().find(|t| *t.pending_transaction.hash() == tx); } dropped } diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index d2f6a662b7bce..312bde4818bff 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -1,7 +1,6 @@ use crate::eth::{error::PoolError, util::hex_fmt_many}; use alloy_primitives::{Address, TxHash, U256}; use anvil_core::eth::transaction::{PendingTransaction, TypedTransaction}; -use foundry_common::types::ToAlloy; use parking_lot::RwLock; use std::{ cmp::Ordering, @@ -45,7 +44,7 @@ impl TransactionOrder { pub fn priority(&self, tx: &TypedTransaction) -> TransactionPriority { match self { TransactionOrder::Fifo => TransactionPriority::default(), - TransactionOrder::Fees => TransactionPriority(tx.gas_price().to_alloy()), + TransactionOrder::Fees => TransactionPriority(tx.gas_price()), } } } @@ -89,12 +88,12 @@ pub struct PoolTransaction { impl PoolTransaction { /// Returns the hash of this transaction pub fn hash(&self) -> TxHash { - self.pending_transaction.hash().to_alloy() + *self.pending_transaction.hash() } /// Returns the gas pric of this transaction pub fn gas_price(&self) -> U256 { - self.pending_transaction.transaction.gas_price().to_alloy() + self.pending_transaction.transaction.gas_price() } } @@ -479,9 +478,7 @@ impl ReadyTransactions { // (addr + nonce) then we check for gas price if to_remove.provides() == tx.provides { // check if underpriced - if tx.pending_transaction.transaction.gas_price().to_alloy() <= - to_remove.gas_price() - { + if tx.pending_transaction.transaction.gas_price() <= to_remove.gas_price() { warn!(target: "txpool", "ready replacement transaction underpriced [{:?}]", tx.hash()); return Err(PoolError::ReplacementUnderpriced(Box::new(tx.clone()))) } else { diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index 112f8c7ab46b6..34b3fa2855626 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -1,20 +1,12 @@ use crate::eth::error::BlockchainError; +use alloy_dyn_abi::TypedData; +use alloy_network::{Signed, Transaction}; +use alloy_primitives::{Address, Signature, B256, U256}; +use alloy_signer::{LocalWallet, Signer as AlloySigner, SignerSync as AlloySignerSync}; use anvil_core::eth::transaction::{ - DepositTransaction, DepositTransactionRequest, EIP1559Transaction, EIP1559TransactionRequest, - EIP2930Transaction, EIP2930TransactionRequest, LegacyTransaction, LegacyTransactionRequest, + optimism::{DepositTransaction, DepositTransactionRequest}, TypedTransaction, TypedTransactionRequest, }; -use ethers::{ - core::k256::ecdsa::SigningKey, - prelude::{Address, Wallet}, - signers::Signer as EthersSigner, - types::{ - transaction::{ - eip2718::TypedTransaction as EthersTypedTransactionRequest, eip712::TypedData, - }, - Signature, H256, U256, - }, -}; use std::collections::HashMap; /// A transaction signer @@ -31,13 +23,17 @@ pub trait Signer: Send + Sync { /// Returns the signature async fn sign(&self, address: Address, message: &[u8]) -> Result; - /// Encodes and signs the typed data according EIP-712. Payload must implement Eip712 trait. + /// Encodes and signs the typed data according EIP-712. Payload must conform to the EIP-712 + /// standard. async fn sign_typed_data( &self, address: Address, payload: &TypedData, ) -> Result; + /// Signs the given hash. + async fn sign_hash(&self, address: Address, hash: B256) -> Result; + /// signs a transaction request using the given account in request fn sign_transaction( &self, @@ -49,11 +45,11 @@ pub trait Signer: Send + Sync { /// Maintains developer keys pub struct DevSigner { addresses: Vec
, - accounts: HashMap>, + accounts: HashMap, } impl DevSigner { - pub fn new(accounts: Vec>) -> Self { + pub fn new(accounts: Vec) -> Self { let addresses = accounts.iter().map(|wallet| wallet.address()).collect::>(); let accounts = addresses.iter().cloned().zip(accounts).collect(); Self { addresses, accounts } @@ -81,8 +77,24 @@ impl Signer for DevSigner { address: Address, payload: &TypedData, ) -> Result { + let mut signer = + self.accounts.get(&address).ok_or(BlockchainError::NoSignerAvailable)?.to_owned(); + + // Explicitly set chainID as none, to avoid any EIP-155 application to `v` when signing + // typed data. + signer.set_chain_id(None); + + Ok(signer + .sign_hash( + payload.eip712_signing_hash().map_err(|_| BlockchainError::NoSignerAvailable)?, + ) + .await?) + } + + async fn sign_hash(&self, address: Address, hash: B256) -> Result { let signer = self.accounts.get(&address).ok_or(BlockchainError::NoSignerAvailable)?; - Ok(signer.sign_typed_data(payload).await?) + + Ok(signer.sign_hash(hash).await?) } fn sign_transaction( @@ -91,9 +103,12 @@ impl Signer for DevSigner { address: &Address, ) -> Result { let signer = self.accounts.get(address).ok_or(BlockchainError::NoSignerAvailable)?; - let ethers_tx: EthersTypedTransactionRequest = request.into(); - - Ok(signer.sign_transaction_sync(ðers_tx)?) + match request { + TypedTransactionRequest::Legacy(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), + TypedTransactionRequest::EIP2930(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), + TypedTransactionRequest::EIP1559(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), + TypedTransactionRequest::Deposit(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), + } } } @@ -108,92 +123,16 @@ pub fn build_typed_transaction( ) -> Result { let tx = match request { TypedTransactionRequest::Legacy(tx) => { - let LegacyTransactionRequest { - nonce, gas_price, gas_limit, kind, value, input, .. - } = tx; - TypedTransaction::Legacy(LegacyTransaction { - nonce, - gas_price, - gas_limit, - kind, - value, - input, - signature, - }) + let sighash = tx.signature_hash(); + TypedTransaction::Legacy(Signed::new_unchecked(tx, signature, sighash)) } TypedTransactionRequest::EIP2930(tx) => { - let EIP2930TransactionRequest { - chain_id, - nonce, - gas_price, - gas_limit, - kind, - value, - input, - access_list, - } = tx; - - let recid: u8 = signature.recovery_id()?.into(); - - TypedTransaction::EIP2930(EIP2930Transaction { - chain_id, - nonce, - gas_price, - gas_limit, - kind, - value, - input, - access_list: access_list.into(), - odd_y_parity: recid != 0, - r: { - let mut rarr = [0_u8; 32]; - signature.r.to_big_endian(&mut rarr); - H256::from(rarr) - }, - s: { - let mut sarr = [0_u8; 32]; - signature.s.to_big_endian(&mut sarr); - H256::from(sarr) - }, - }) + let sighash = tx.signature_hash(); + TypedTransaction::EIP2930(Signed::new_unchecked(tx, signature, sighash)) } TypedTransactionRequest::EIP1559(tx) => { - let EIP1559TransactionRequest { - chain_id, - nonce, - max_priority_fee_per_gas, - max_fee_per_gas, - gas_limit, - kind, - value, - input, - access_list, - } = tx; - - let recid: u8 = signature.recovery_id()?.into(); - - TypedTransaction::EIP1559(EIP1559Transaction { - chain_id, - nonce, - max_priority_fee_per_gas, - max_fee_per_gas, - gas_limit, - kind, - value, - input, - access_list: access_list.into(), - odd_y_parity: recid != 0, - r: { - let mut rarr = [0u8; 32]; - signature.r.to_big_endian(&mut rarr); - H256::from(rarr) - }, - s: { - let mut sarr = [0u8; 32]; - signature.s.to_big_endian(&mut sarr); - H256::from(sarr) - }, - }) + let sighash = tx.signature_hash(); + TypedTransaction::EIP1559(Signed::new_unchecked(tx, signature, sighash)) } TypedTransactionRequest::Deposit(tx) => { let DepositTransactionRequest { @@ -216,7 +155,7 @@ pub fn build_typed_transaction( source_hash, mint, is_system_tx, - nonce: U256::zero(), + nonce: U256::ZERO, }) } }; diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 4181df4e8d447..5153178f598c0 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -1,15 +1,9 @@ -use ethers::abi::Address; -use foundry_common::types::ToEthers; +use alloy_primitives::Address; use foundry_evm::revm::{self, precompile::Precompiles, primitives::SpecId}; use std::fmt; pub fn get_precompiles_for(spec_id: SpecId) -> Vec
{ - Precompiles::new(to_precompile_id(spec_id)) - .addresses() - .into_iter() - .copied() - .map(|item| item.to_ethers()) - .collect() + Precompiles::new(to_precompile_id(spec_id)).addresses().into_iter().copied().collect() } /// wrapper type that displays byte as hex diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs index cd115c2a90c99..3525838a77562 100644 --- a/crates/anvil/src/genesis.rs +++ b/crates/anvil/src/genesis.rs @@ -1,7 +1,7 @@ //! Bindings for geth's `genesis.json` format use crate::revm::primitives::AccountInfo; use alloy_primitives::{Address, Bytes, B256, U256}; -use ethers::{signers::LocalWallet, types::serde_helpers::*}; +use alloy_signer::LocalWallet; use foundry_common::errors::FsPathError; use foundry_evm::revm::primitives::{Bytecode, Env, KECCAK_EMPTY, U256 as rU256}; use serde::{Deserialize, Serialize}; @@ -19,21 +19,25 @@ pub struct Genesis { pub config: Option, #[serde( default, - deserialize_with = "deserialize_stringified_u64_opt", + deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", skip_serializing_if = "Option::is_none" )] pub nonce: Option, #[serde( default, - deserialize_with = "deserialize_stringified_u64_opt", + deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", skip_serializing_if = "Option::is_none" )] pub timestamp: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub extra_data: Option, - #[serde(deserialize_with = "deserialize_stringified_u64")] + #[serde( + deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64" + )] pub gas_limit: u64, - #[serde(deserialize_with = "deserialize_stringified_u64")] + #[serde( + deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64" + )] pub difficulty: u64, #[serde(default, skip_serializing_if = "Option::is_none")] pub mix_hash: Option, @@ -43,13 +47,13 @@ pub struct Genesis { pub alloc: Alloc, #[serde( default, - deserialize_with = "deserialize_stringified_u64_opt", + deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", skip_serializing_if = "Option::is_none" )] pub number: Option, #[serde( default, - deserialize_with = "deserialize_stringified_u64_opt", + deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", skip_serializing_if = "Option::is_none" )] pub gas_used: Option, @@ -116,7 +120,7 @@ pub struct GenesisAccount { pub balance: U256, #[serde( default, - deserialize_with = "deserialize_stringified_u64_opt", + deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", skip_serializing_if = "Option::is_none" )] pub nonce: Option, @@ -213,7 +217,9 @@ pub struct CliqueConfig { /// serde support for `secretKey` in genesis pub mod secret_key { - use ethers::{core::k256::SecretKey, signers::LocalWallet, types::Bytes}; + use alloy_primitives::Bytes; + use alloy_signer::LocalWallet; + use k256::{ecdsa::SigningKey, SecretKey}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; pub fn serialize(value: &Option, serializer: S) -> Result @@ -221,7 +227,10 @@ pub mod secret_key { S: Serializer, { if let Some(wallet) = value { - Bytes::from(wallet.signer().to_bytes().as_ref()).serialize(serializer) + let signer: SigningKey = wallet.signer().clone(); + let signer_bytes = signer.to_bytes(); + let signer_bytes2: [u8; 32] = *signer_bytes.as_ref(); + Bytes::from(signer_bytes2).serialize(serializer) } else { serializer.serialize_none() } diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index 322c5071ac3a6..a5e92284cb511 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -1,5 +1,5 @@ +use alloy_rpc_types::BlockNumberOrTag; use ethereum_forkid::{ForkHash, ForkId}; -use ethers::types::BlockNumber; use foundry_evm::revm::primitives::SpecId; use std::str::FromStr; @@ -160,11 +160,11 @@ impl From for SpecId { } } -impl> From for Hardfork { - fn from(block: T) -> Hardfork { +impl> From for Hardfork { + fn from(block: T) -> Self { let num = match block.into() { - BlockNumber::Earliest => 0, - BlockNumber::Number(num) => num.as_u64(), + BlockNumberOrTag::Earliest => 0, + BlockNumberOrTag::Number(num) => num, _ => u64::MAX, }; @@ -190,8 +190,8 @@ impl> From for Hardfork { #[cfg(test)] mod tests { use crate::Hardfork; + use alloy_primitives::hex; use crc::{Crc, CRC_32_ISO_HDLC}; - use ethers::utils::hex; #[test] fn test_hardfork_blocks() { diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 4c478b669e3d9..322b14aad60f7 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -16,20 +16,10 @@ use crate::{ shutdown::Signal, tasks::TaskManager, }; +use alloy_primitives::{Address, U256}; +use alloy_signer::{LocalWallet, Signer as AlloySigner}; use eth::backend::fork::ClientFork; -use ethers::{ - core::k256::ecdsa::SigningKey, - prelude::Wallet, - signers::Signer, - types::{Address, U256}, -}; -use foundry_common::{ - provider::{ - alloy::{ProviderBuilder, RetryProvider}, - ethers::{ProviderBuilder as EthersProviderBuilder, RetryProvider as EthersRetryProvider}, - }, - types::ToEthers, -}; +use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; use parking_lot::Mutex; @@ -280,41 +270,23 @@ impl NodeHandle { // .interval(Duration::from_millis(500)) } - /// Constructs a [`EthersRetryProvider`] for this handle's HTTP endpoint. - /// TODO: Remove once ethers is phased out of cast/alloy and tests. - pub fn ethers_http_provider(&self) -> EthersRetryProvider { - EthersProviderBuilder::new(&self.http_endpoint()) - .build() - .expect("failed to build ethers HTTP provider") - } - /// Constructs a [`RetryProvider`] for this handle's WS endpoint. pub fn ws_provider(&self) -> RetryProvider { ProviderBuilder::new(&self.ws_endpoint()).build().expect("failed to build WS provider") } - pub fn ethers_ws_provider(&self) -> EthersRetryProvider { - EthersProviderBuilder::new(&self.ws_endpoint()) - .build() - .expect("failed to build ethers WS provider") - } - /// Constructs a [`RetryProvider`] for this handle's IPC endpoint, if any. pub fn ipc_provider(&self) -> Option { ProviderBuilder::new(&self.config.get_ipc_path()?).build().ok() } - pub fn ethers_ipc_provider(&self) -> Option { - EthersProviderBuilder::new(&self.config.get_ipc_path()?).build().ok() - } - /// Signer accounts that can sign messages/transactions from the EVM node pub fn dev_accounts(&self) -> impl Iterator + '_ { self.config.signer_accounts.iter().map(|wallet| wallet.address()) } /// Signer accounts that can sign messages/transactions from the EVM node - pub fn dev_wallets(&self) -> impl Iterator> + '_ { + pub fn dev_wallets(&self) -> impl Iterator + '_ { self.config.signer_accounts.iter().cloned() } @@ -325,12 +297,12 @@ impl NodeHandle { /// Native token balance of every genesis account in the genesis block pub fn genesis_balance(&self) -> U256 { - self.config.genesis_balance.to_ethers() + self.config.genesis_balance } /// Default gas price for all txs pub fn gas_price(&self) -> U256 { - self.config.get_gas_price().to_ethers() + self.config.get_gas_price() } /// Returns the shutdown signal diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index ed061567df157..ce2f7e2450c48 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -2,15 +2,12 @@ use crate::{ eth::{backend::notifications::NewBlockNotifications, error::to_rpc_result}, StorageInfo, }; -use alloy_primitives::{TxHash, B256, U256}; +use alloy_consensus::ReceiptWithBloom; +use alloy_network::Sealable; +use alloy_primitives::{Log, TxHash, B256, U256}; use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log as AlloyLog}; -use anvil_core::eth::{ - block::Block, - receipt::{EIP658Receipt, Log, TypedReceipt}, - subscription::SubscriptionId, -}; +use anvil_core::eth::{block::Block, subscription::SubscriptionId, transaction::TypedReceipt}; use anvil_rpc::{request::Version, response::ResponseResult}; -use foundry_common::types::ToAlloy; use futures::{channel::mpsc::Receiver, ready, Stream, StreamExt}; use serde::Serialize; use std::{ @@ -156,9 +153,9 @@ pub fn filter_logs( /// Determines whether to add this log fn add_log(block_hash: B256, l: &Log, block: &Block, params: &FilteredParams) -> bool { let log = AlloyLog { - address: l.address.to_alloy(), - topics: l.topics.clone().into_iter().map(|t| t.to_alloy()).collect::>(), - data: l.data.clone().0.into(), + address: l.address, + topics: l.topics().to_vec(), + data: l.data.data.clone(), block_hash: None, block_number: None, transaction_hash: None, @@ -167,7 +164,7 @@ pub fn filter_logs( removed: false, }; if params.filter.is_some() { - let block_number = block.header.number.as_u64(); + let block_number = block.header.number; if !params.filter_block_range(block_number) || !params.filter_block_hash(block_hash) || !params.filter_address(&log) || @@ -183,21 +180,21 @@ pub fn filter_logs( let mut logs = vec![]; let mut log_index: u32 = 0; for (receipt_index, receipt) in receipts.into_iter().enumerate() { - let receipt: EIP658Receipt = receipt.into(); - let receipt_logs = receipt.logs; + let receipt: ReceiptWithBloom = receipt.into(); + let receipt_logs = receipt.receipt.logs; let transaction_hash: Option = if !receipt_logs.is_empty() { - Some(block.transactions[receipt_index].hash().to_alloy()) + Some(block.transactions[receipt_index].hash()) } else { None }; for log in receipt_logs.into_iter() { - if add_log(block_hash.to_alloy(), &log, &block, filter) { + if add_log(block_hash, &log, &block, filter) { logs.push(AlloyLog { - address: log.address.to_alloy(), - topics: log.topics.into_iter().map(|t| t.to_alloy()).collect::>(), - data: log.data.0.into(), - block_hash: Some(block_hash.to_alloy()), - block_number: Some(U256::from(block.header.number.as_u64())), + address: log.address, + topics: log.topics().to_vec(), + data: log.data.data, + block_hash: Some(block_hash), + block_number: Some(U256::from(block.header.number)), transaction_hash, transaction_index: Some(U256::from(receipt_index)), log_index: Some(U256::from(log_index)), diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 6d65f6fe45938..3a39f7e74664a 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -1,5 +1,6 @@ //! tests for anvil specific logic +use crate::utils::ethers_http_provider; use anvil::{spawn, NodeConfig}; use ethers::{prelude::Middleware, types::Address}; use foundry_common::types::ToAlloy; @@ -7,7 +8,7 @@ use foundry_common::types::ToAlloy; #[tokio::test(flavor = "multi_thread")] async fn test_can_change_mining_mode() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); assert!(api.anvil_get_auto_mine().unwrap()); @@ -36,10 +37,16 @@ async fn test_can_change_mining_mode() { #[tokio::test(flavor = "multi_thread")] async fn can_get_default_dev_keys() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let dev_accounts = handle.dev_accounts().collect::>(); - let accounts = provider.get_accounts().await.unwrap(); + let accounts = provider + .get_accounts() + .await + .unwrap() + .into_iter() + .map(ToAlloy::to_alloy) + .collect::>(); assert_eq!(dev_accounts, accounts); } @@ -57,7 +64,7 @@ async fn test_can_set_genesis_timestamp() { let genesis_timestamp = 1000u64; let (_api, handle) = spawn(NodeConfig::test().with_genesis_timestamp(genesis_timestamp.into())).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); assert_eq!(genesis_timestamp, provider.get_block(0).await.unwrap().unwrap().timestamp.as_u64()); } @@ -65,7 +72,7 @@ async fn test_can_set_genesis_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_can_use_default_genesis_timestamp() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); assert_ne!(0u64, provider.get_block(0).await.unwrap().unwrap().timestamp.as_u64()); } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 60a91ee76164a..e487033cc179f 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -1,5 +1,5 @@ //! tests for custom anvil endpoints -use crate::{abi::*, fork::fork_config}; +use crate::{abi::*, fork::fork_config, utils::ethers_http_provider}; use alloy_rpc_types::BlockNumberOrTag; use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; use anvil_core::{ @@ -26,7 +26,7 @@ use std::{ #[tokio::test(flavor = "multi_thread")] async fn can_set_gas_price() { let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let gas_price: U256 = 1337u64.into(); api.anvil_set_min_gas_price(gas_price.to_alloy()).await.unwrap(); @@ -67,7 +67,7 @@ async fn can_set_storage() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let impersonate = Address::random(); let to = Address::random(); @@ -104,7 +104,7 @@ async fn can_impersonate_account() { #[tokio::test(flavor = "multi_thread")] async fn can_auto_impersonate_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let impersonate = Address::random(); let to = Address::random(); @@ -144,9 +144,9 @@ async fn can_auto_impersonate_account() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_contract() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let provider = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = @@ -156,7 +156,7 @@ async fn can_impersonate_contract() { let to = Address::random(); let val = 1337u64; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); // fund the impersonated account api.anvil_set_balance(impersonate.to_alloy(), U256::from(1e18 as u64).to_alloy()) @@ -190,7 +190,7 @@ async fn can_impersonate_contract() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_gnosis_safe() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); // let safe: Address = "0xA063Cb7CFd8E57c30c788A0572CBbf2129ae56B6".parse().unwrap(); @@ -220,7 +220,7 @@ async fn can_impersonate_gnosis_safe() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_multiple_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let impersonate0 = Address::random(); let impersonate1 = Address::random(); @@ -267,7 +267,7 @@ async fn can_impersonate_multiple_account() { #[tokio::test(flavor = "multi_thread")] async fn can_mine_manually() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let start_num = provider.get_block_number().await.unwrap(); @@ -281,7 +281,7 @@ async fn can_mine_manually() { #[tokio::test(flavor = "multi_thread")] async fn test_set_next_timestamp() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -308,7 +308,7 @@ async fn test_set_next_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_evm_set_time() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -332,7 +332,7 @@ async fn test_evm_set_time() { #[tokio::test(flavor = "multi_thread")] async fn test_evm_set_time_in_past() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -352,7 +352,7 @@ async fn test_evm_set_time_in_past() { #[tokio::test(flavor = "multi_thread")] async fn test_timestamp_interval() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); api.evm_mine(None).await.unwrap(); let interval = 10; @@ -403,7 +403,7 @@ async fn test_timestamp_interval() { async fn test_can_set_storage_bsc_fork() { let (api, handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; - let provider = Arc::new(handle.ethers_http_provider()); + let provider = Arc::new(ethers_http_provider(&handle.http_endpoint())); let busd_addr: Address = "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56".parse().unwrap(); let idx: U256 = @@ -432,7 +432,7 @@ async fn can_get_node_info() { let node_info = api.anvil_node_info().await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let block_number = provider.get_block_number().await.unwrap(); let block = provider.get_block(block_number).await.unwrap().unwrap(); @@ -465,7 +465,7 @@ async fn can_get_metadata() { let metadata = api.anvil_metadata().await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let block_number = provider.get_block_number().await.unwrap().as_u64(); let chain_id = provider.get_chainid().await.unwrap().as_u64(); @@ -488,7 +488,7 @@ async fn can_get_metadata() { async fn can_get_metadata_on_fork() { let (api, handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; - let provider = Arc::new(handle.ethers_http_provider()); + let provider = Arc::new(ethers_http_provider(&handle.http_endpoint())); let metadata = api.anvil_metadata().await.unwrap(); @@ -532,7 +532,7 @@ async fn metadata_changes_on_reset() { #[tokio::test(flavor = "multi_thread")] async fn test_get_transaction_receipt() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); // set the base fee let new_base_fee = U256::from(1_000); @@ -563,7 +563,7 @@ async fn test_get_transaction_receipt() { #[tokio::test(flavor = "multi_thread")] async fn test_set_chain_id() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id, U256::from(31337)); @@ -599,7 +599,7 @@ async fn test_fork_revert_next_block_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_revert_call_latest_block_timestamp() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); // Mine a new block, and check the new block gas limit api.mine_one().await; diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 84c93ea0338ef..50a239b48a25c 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -1,11 +1,16 @@ //! general eth api tests -use crate::abi::{MulticallContract, SimpleStorage}; -use alloy_primitives::{B256, U256 as rU256}; +use crate::{ + abi::{MulticallContract, SimpleStorage}, + utils::ethers_http_provider, +}; +use alloy_primitives::{Address as rAddress, B256, U256 as rU256}; +use alloy_providers::provider::TempProvider; use alloy_rpc_types::{ state::{AccountOverride, StateOverride}, CallInput, CallRequest, }; +use alloy_signer::Signer as AlloySigner; use anvil::{ eth::{api::CLIENT_VERSION, EthApi}, spawn, NodeConfig, CHAIN_ID, @@ -27,7 +32,7 @@ async fn can_get_block_number() { let block_num = api.block_number().unwrap(); assert_eq!(block_num, U256::zero().to_alloy()); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, block_num.to::().into()); @@ -36,7 +41,7 @@ async fn can_get_block_number() { #[tokio::test(flavor = "multi_thread")] async fn can_dev_get_balance() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = handle.http_provider(); let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { @@ -48,7 +53,7 @@ async fn can_dev_get_balance() { #[tokio::test(flavor = "multi_thread")] async fn can_get_price() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let _ = provider.get_gas_price().await.unwrap(); } @@ -56,7 +61,7 @@ async fn can_get_price() { #[tokio::test(flavor = "multi_thread")] async fn can_get_accounts() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let _ = provider.get_accounts().await.unwrap(); } @@ -64,7 +69,7 @@ async fn can_get_accounts() { #[tokio::test(flavor = "multi_thread")] async fn can_get_client_version() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let version = provider.client_version().await.unwrap(); assert_eq!(CLIENT_VERSION, version); @@ -73,7 +78,7 @@ async fn can_get_client_version() { #[tokio::test(flavor = "multi_thread")] async fn can_get_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id, CHAIN_ID.into()); @@ -82,7 +87,7 @@ async fn can_get_chain_id() { #[tokio::test(flavor = "multi_thread")] async fn can_modify_chain_id() { let (_api, handle) = spawn(NodeConfig::test().with_chain_id(Some(Chain::Goerli))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id, Chain::Goerli.into()); @@ -102,13 +107,16 @@ async fn can_get_network_id() { #[tokio::test(flavor = "multi_thread")] async fn can_get_block_by_number() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); // send a dummy transactions - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let tx = TransactionRequest::new() + .to(to.to_ethers()) + .value(amount.to_ethers()) + .from(from.to_ethers()); let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let block: Block = provider.get_block_with_txs(1u64).await.unwrap().unwrap(); @@ -124,7 +132,7 @@ async fn can_get_block_by_number() { #[tokio::test(flavor = "multi_thread")] async fn can_get_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let accounts: Vec<_> = handle.dev_wallets().collect(); let block = provider.get_block(BlockNumber::Pending).await.unwrap().unwrap(); @@ -138,7 +146,7 @@ async fn can_get_pending_block() { let from = accounts[0].address(); let to = accounts[1].address(); - let tx = TransactionRequest::new().to(to).value(100u64).from(from); + let tx = TransactionRequest::new().to(to.to_ethers()).value(100u64).from(from.to_ethers()); let tx = provider.send_transaction(tx, None).await.unwrap(); @@ -158,14 +166,14 @@ async fn can_get_pending_block() { #[tokio::test(flavor = "multi_thread")] async fn can_call_on_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let num = provider.get_block_number().await.unwrap(); assert_eq!(num.as_u64(), 0u64); api.anvil_set_auto_mine(false).await.unwrap(); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -185,9 +193,9 @@ async fn can_call_on_pending_block() { pending_contract.aggregate(vec![]).block(BlockNumber::Pending).call().await.unwrap(); assert_eq!(ret_block_number.as_u64(), 1u64); - let accounts: Vec
= handle.dev_wallets().map(|w| w.address()).collect(); + let accounts: Vec = handle.dev_wallets().map(|w| w.address()).collect(); for i in 1..10 { - api.anvil_set_coinbase(accounts[i % accounts.len()].to_alloy()).await.unwrap(); + api.anvil_set_coinbase(accounts[i % accounts.len()]).await.unwrap(); api.evm_set_block_gas_limit(rU256::from(30_000_000 + i)).unwrap(); api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); @@ -252,11 +260,11 @@ where #[tokio::test(flavor = "multi_thread")] async fn can_call_with_state_override() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); api.anvil_set_auto_mine(true).await.unwrap(); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let account = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 987bc05041d5a..d0f60d5e941b7 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1,8 +1,13 @@ //! various fork related test -use crate::{abi::*, utils}; +use crate::{ + abi::*, + utils::{self, ethers_http_provider}, +}; use alloy_primitives::U256 as rU256; +use alloy_providers::provider::TempProvider; use alloy_rpc_types::{BlockNumberOrTag, CallRequest}; +use alloy_signer::Signer as AlloySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; use ethers::{ @@ -76,7 +81,7 @@ async fn test_spawn_fork() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_balance() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); for _ in 0..10 { let addr = Address::random(); let balance = api.balance(addr.to_alloy(), None).await.unwrap(); @@ -89,7 +94,7 @@ async fn test_fork_eth_get_balance() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_balance_after_mine() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let info = api.anvil_node_info().await.unwrap(); let number = info.fork_config.fork_block_number.unwrap(); assert_eq!(number, BLOCK_NUMBER); @@ -113,7 +118,7 @@ async fn test_fork_eth_get_balance_after_mine() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_code_after_mine() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let info = api.anvil_node_info().await.unwrap(); let number = info.fork_config.fork_block_number.unwrap(); assert_eq!(number, BLOCK_NUMBER); @@ -132,7 +137,7 @@ async fn test_fork_eth_get_code_after_mine() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_code() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); for _ in 0..10 { let addr = Address::random(); let code = api.get_code(addr.to_alloy(), None).await.unwrap(); @@ -156,7 +161,7 @@ async fn test_fork_eth_get_code() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_nonce() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); for _ in 0..10 { let addr = Address::random(); @@ -174,7 +179,7 @@ async fn test_fork_eth_get_nonce() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_fee_history() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let count = 10u64; let _history = @@ -185,18 +190,18 @@ async fn test_fork_eth_fee_history() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_reset() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let accounts: Vec<_> = handle.dev_wallets().collect(); - let from = accounts[0].address(); - let to = accounts[1].address(); + let from = accounts[0].address().to_ethers(); + let to = accounts[1].address().to_ethers(); let block_number = provider.get_block_number().await.unwrap(); let balance_before = provider.get_balance(to, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.transaction_index, 0u64.into()); @@ -205,7 +210,7 @@ async fn test_fork_reset() { assert_eq!(nonce, initial_nonce + 1); let to_balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance_before.saturating_add(amount), to_balance); + assert_eq!(balance_before.saturating_add(amount.to_ethers()), to_balance); api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(block_number.as_u64()), @@ -219,9 +224,9 @@ async fn test_fork_reset() { let nonce = provider.get_transaction_count(from, None).await.unwrap(); assert_eq!(nonce, initial_nonce); let balance = provider.get_balance(from, None).await.unwrap(); - assert_eq!(balance, handle.genesis_balance()); + assert_eq!(balance, handle.genesis_balance().to_ethers()); let balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance, handle.genesis_balance()); + assert_eq!(balance, handle.genesis_balance().to_ethers()); // reset to latest api.anvil_reset(Some(Forking::default())).await.unwrap(); @@ -233,7 +238,7 @@ async fn test_fork_reset() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_reset_setup() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let dead_addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); @@ -260,8 +265,7 @@ async fn test_fork_reset_setup() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_snapshotting() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); - + let provider = handle.http_provider(); let snapshot = api.evm_snapshot().await.unwrap(); let accounts: Vec<_> = handle.dev_wallets().collect(); @@ -271,14 +275,20 @@ async fn test_fork_snapshotting() { let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); let balance_before = provider.get_balance(to, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let provider = ethers_http_provider(&handle.http_endpoint()); + let tx = TransactionRequest::new() + .to(to.to_ethers()) + .value(amount.to_ethers()) + .from(from.to_ethers()); let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let provider = handle.http_provider(); + let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + 1); + assert_eq!(nonce, initial_nonce + rU256::from(1)); let to_balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); @@ -296,7 +306,7 @@ async fn test_fork_snapshotting() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_snapshotting_repeated() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = handle.http_provider(); let snapshot = api.evm_snapshot().await.unwrap(); @@ -307,14 +317,17 @@ async fn test_fork_snapshotting_repeated() { let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); let balance_before = provider.get_balance(to, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); - - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let amount = handle.genesis_balance().checked_div(rU256::from(92u64)).unwrap(); - let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = TransactionRequest::new() + .to(to.to_ethers()) + .value(amount.to_ethers()) + .from(from.to_ethers()); + let tx_provider = ethers_http_provider(&handle.http_endpoint()); + let _ = tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + 1); + assert_eq!(nonce, initial_nonce + rU256::from(1)); let to_balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); @@ -342,7 +355,8 @@ async fn test_fork_snapshotting_repeated() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_snapshotting_blocks() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = handle.http_provider(); + let tx_provider = ethers_http_provider(&handle.http_endpoint()); // create a snapshot let snapshot = api.evm_snapshot().await.unwrap(); @@ -354,17 +368,20 @@ async fn test_fork_snapshotting_blocks() { let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); let balance_before = provider.get_balance(to, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); // send the transaction - let tx = TransactionRequest::new().to(to).value(amount).from(from); - let _ = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let tx = TransactionRequest::new() + .to(to.to_ethers()) + .value(amount.to_ethers()) + .from(from.to_ethers()); + let _ = tx_provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + 1); + assert_eq!(nonce, initial_nonce + rU256::from(1)); let to_balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); @@ -376,14 +393,14 @@ async fn test_fork_snapshotting_blocks() { assert_eq!(block_number_after, block_number); // repeat transaction - let _ = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let _ = tx_provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + 1); + assert_eq!(nonce, initial_nonce + rU256::from(1)); // revert again: nothing to revert since snapshot gone assert!(!api.evm_revert(snapshot).await.unwrap()); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + 1); + assert_eq!(nonce, initial_nonce + rU256::from(1)); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); } @@ -394,7 +411,7 @@ async fn test_fork_snapshotting_blocks() { #[tokio::test(flavor = "multi_thread")] async fn test_separate_states() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(14723772u64))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); @@ -423,9 +440,9 @@ async fn test_separate_states() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_on_fork() { let (_api, handle) = spawn(fork_config().with_fork_block_number(Some(14723772u64))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) @@ -448,49 +465,41 @@ async fn can_deploy_greeter_on_fork() { async fn can_reset_properly() { let (origin_api, origin_handle) = spawn(NodeConfig::test()).await; let account = origin_handle.dev_accounts().next().unwrap(); - let origin_provider = origin_handle.ethers_http_provider(); + let origin_provider = origin_handle.http_provider(); let origin_nonce = rU256::from(1u64); - origin_api.anvil_set_nonce(account.to_alloy(), origin_nonce).await.unwrap(); + origin_api.anvil_set_nonce(account, origin_nonce).await.unwrap(); - assert_eq!( - origin_nonce, - origin_provider.get_transaction_count(account, None).await.unwrap().to_alloy() - ); + assert_eq!(origin_nonce, origin_provider.get_transaction_count(account, None).await.unwrap()); let (fork_api, fork_handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some(origin_handle.http_endpoint()))).await; - let fork_provider = fork_handle.ethers_http_provider(); - assert_eq!( - origin_nonce, - fork_provider.get_transaction_count(account, None).await.unwrap().to_alloy() - ); + let fork_provider = fork_handle.http_provider(); + let fork_tx_provider = ethers_http_provider(&fork_handle.http_endpoint()); + assert_eq!(origin_nonce, fork_provider.get_transaction_count(account, None).await.unwrap()); let to = Address::random(); - let to_balance = fork_provider.get_balance(to, None).await.unwrap(); - let tx = TransactionRequest::new().from(account).to(to).value(1337u64); - let tx = fork_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let to_balance = fork_provider.get_balance(to.to_alloy(), None).await.unwrap(); + let tx = TransactionRequest::new().from(account.to_ethers()).to(to).value(1337u64); + let tx = fork_tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); // nonce incremented by 1 assert_eq!( origin_nonce + rU256::from(1), - fork_provider.get_transaction_count(account, None).await.unwrap().to_alloy() + fork_provider.get_transaction_count(account, None).await.unwrap() ); // resetting to origin state fork_api.anvil_reset(Some(Forking::default())).await.unwrap(); // nonce reset to origin - assert_eq!( - origin_nonce, - fork_provider.get_transaction_count(account, None).await.unwrap().to_alloy() - ); + assert_eq!(origin_nonce, fork_provider.get_transaction_count(account, None).await.unwrap()); // balance is reset - assert_eq!(to_balance, fork_provider.get_balance(to, None).await.unwrap()); + assert_eq!(to_balance, fork_provider.get_balance(to.to_alloy(), None).await.unwrap()); // tx does not exist anymore - assert!(fork_provider.get_transaction(tx.transaction_hash).await.is_err()) + assert!(fork_tx_provider.get_transaction(tx.transaction_hash).await.is_err()) } #[tokio::test(flavor = "multi_thread")] @@ -498,7 +507,7 @@ async fn test_fork_timestamp() { let start = std::time::Instant::now(); let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let block = provider.get_block(BLOCK_NUMBER).await.unwrap().unwrap(); assert_eq!(block.timestamp.as_u64(), BLOCK_TIMESTAMP); @@ -506,7 +515,7 @@ async fn test_fork_timestamp() { let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); @@ -526,7 +535,7 @@ async fn test_fork_timestamp() { let block = provider.get_block(BLOCK_NUMBER).await.unwrap().unwrap(); assert_eq!(block.timestamp.as_u64(), BLOCK_TIMESTAMP); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); @@ -540,13 +549,13 @@ async fn test_fork_timestamp() { .await .unwrap(); api.evm_set_next_block_timestamp(BLOCK_TIMESTAMP + 1).unwrap(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); assert_eq!(block.timestamp.as_u64(), BLOCK_TIMESTAMP + 1); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); @@ -572,15 +581,16 @@ async fn test_fork_can_send_tx() { spawn(fork_config().with_blocktime(Some(std::time::Duration::from_millis(800)))).await; let wallet = LocalWallet::new(&mut rand::thread_rng()); + let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = SignerMiddleware::new(provider, wallet); - api.anvil_set_balance(wallet.address().to_alloy(), rU256::from(1e18 as u64)).await.unwrap(); - - let provider = SignerMiddleware::new(handle.ethers_http_provider(), wallet); + api.anvil_set_balance(provider.address().to_alloy(), rU256::MAX).await.unwrap(); + let balance = provider.get_balance(provider.address(), None).await.unwrap(); + assert_eq!(balance, rU256::MAX.to_ethers()); let addr = Address::random(); let val = 1337u64; let tx = TransactionRequest::new().to(addr).value(val); - // broadcast it via the eth_sendTransaction API let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); @@ -603,7 +613,8 @@ async fn test_fork_nft_set_approve_all() { let wallet = LocalWallet::new(&mut rand::thread_rng()); api.anvil_set_balance(wallet.address().to_alloy(), rU256::from(1000e18 as u64)).await.unwrap(); - let provider = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet.clone())); + let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = Arc::new(SignerMiddleware::new(provider, wallet.clone())); // pick a random nft let nouns_addr: Address = "0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03".parse().unwrap(); @@ -677,7 +688,7 @@ async fn test_fork_can_send_opensea_tx() { // transfer: impersonate real sender api.anvil_impersonate_account(sender.to_alloy()).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let input: Bytes = "0xfb0f3ee1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ff2e795f5000000000000000000000000000023f28ae3e9756ba982a6290f9081b6a84900b758000000000000000000000000004c00500000ad104d7dbd00e3ae0a5c00560c0000000000000000000000000003235b597a78eabcb08ffcb4d97411073211dbcb0000000000000000000000000000000000000000000000000000000000000e72000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000062ad47c20000000000000000000000000000000000000000000000000000000062d43104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000df44e65d2a2cf40000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000001c6bf526340000000000000000000000000008de9c5a032463c561423387a9648c5c7bcc5bc900000000000000000000000000000000000000000000000000005543df729c0000000000000000000000000006eb234847a9e3a546539aac57a071c01dc3f398600000000000000000000000000000000000000000000000000000000000000416d39b5352353a22cf2d44faa696c2089b03137a13b5acfee0366306f2678fede043bc8c7e422f6f13a3453295a4a063dac7ee6216ab7bade299690afc77397a51c00000000000000000000000000000000000000000000000000000000000000".parse().unwrap(); let to: Address = "0x00000000006c3852cbef3e08e8df289169ede581".parse().unwrap(); @@ -700,13 +711,13 @@ async fn test_fork_base_fee() { let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); api.anvil_set_next_block_base_fee_per_gas(rU256::ZERO).await.unwrap(); let addr = Address::random(); let val = 1337u64; - let tx = TransactionRequest::new().from(from).to(addr).value(val); + let tx = TransactionRequest::new().from(from.to_ethers()).to(addr).value(val); let _res = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); } @@ -715,7 +726,7 @@ async fn test_fork_base_fee() { async fn test_fork_init_base_fee() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(13184859u64))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); // @@ -738,7 +749,7 @@ async fn test_reset_fork_on_new_blocks() { ) .await; - let anvil_provider = handle.ethers_http_provider(); + let anvil_provider = ethers_http_provider(&handle.http_endpoint()); let endpoint = next_http_rpc_endpoint(); let provider = Arc::new(get_http_provider(&endpoint).interval(Duration::from_secs(2))); @@ -821,7 +832,7 @@ async fn test_fork_snapshot_block_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_uncles_fetch() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); // Block on ETH mainnet with 2 uncles let block_with_uncles = 190u64; @@ -859,7 +870,7 @@ async fn test_fork_uncles_fetch() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_block_transaction_count() { let (api, handle) = spawn(fork_config()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let accounts: Vec<_> = handle.dev_wallets().collect(); let sender = accounts[0].address(); @@ -867,9 +878,9 @@ async fn test_fork_block_transaction_count() { // disable automine (so there are pending transactions) api.anvil_set_auto_mine(false).await.unwrap(); // transfer: impersonate real sender - api.anvil_impersonate_account(sender.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(sender).await.unwrap(); - let tx = TransactionRequest::new().from(sender).value(42u64).gas(100_000); + let tx = TransactionRequest::new().from(sender.to_ethers()).value(42u64).gas(100_000); provider.send_transaction(tx, None).await.unwrap(); let pending_txs = @@ -914,7 +925,7 @@ async fn test_fork_block_transaction_count() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_in_fork() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15347924u64))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let token_holder: Address = "0x2f0b23f53734252bda2277357e97e1517d6b042a".parse().unwrap(); let to = Address::random(); @@ -950,7 +961,7 @@ async fn test_total_difficulty_fork() { let total_difficulty: U256 = 46_673_965_560_973_856_260_636u128.into(); let difficulty: U256 = 13_680_435_288_526_144u128.into(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); assert_eq!(block.total_difficulty, Some(total_difficulty)); assert_eq!(block.difficulty, difficulty); @@ -1012,9 +1023,9 @@ async fn can_override_fork_chain_id() { .with_chain_id(Some(chain_id_override)), ) .await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) @@ -1032,7 +1043,7 @@ async fn can_override_fork_chain_id() { let greeting = greeter_contract.greet().call().await.unwrap(); assert_eq!("Hello World!", greeting); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let chain_id = provider.get_chainid().await.unwrap(); assert_eq!(chain_id.as_u64(), chain_id_override); } @@ -1047,12 +1058,12 @@ async fn test_fork_reset_moonbeam() { .with_fork_block_number(None::), ) .await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); @@ -1064,7 +1075,7 @@ async fn test_fork_reset_moonbeam() { .await .unwrap(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from); + let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); assert_eq!(tx.status, Some(1u64.into())); } @@ -1105,8 +1116,7 @@ async fn test_arbitrum_fork_dev_balance() { let accounts: Vec<_> = handle.dev_wallets().collect(); for acc in accounts { - let balance = - api.balance(acc.address().to_alloy(), Some(Default::default())).await.unwrap(); + let balance = api.balance(acc.address(), Some(Default::default())).await.unwrap(); assert_eq!(balance, rU256::from(100000000000000000000u128)); } } diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index bf1c91c685ce7..4f6098bfb2df0 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -1,5 +1,6 @@ //! Gas related tests +use crate::utils::ethers_http_provider; use alloy_primitives::U256; use anvil::{eth::fees::INITIAL_BASE_FEE, spawn, NodeConfig}; use ethers::{ @@ -21,7 +22,7 @@ async fn test_basefee_full_block() { .with_gas_limit(Some(GAS_TRANSFER.to_alloy())), ) .await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); let base_fee = @@ -44,7 +45,7 @@ async fn test_basefee_half_block() { .with_gas_limit(Some(GAS_TRANSFER.to_alloy() * U256::from(2))), ) .await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); @@ -60,7 +61,7 @@ async fn test_basefee_empty_block() { let (api, handle) = spawn(NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE.to_alloy()))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let base_fee = @@ -80,7 +81,7 @@ async fn test_basefee_empty_block() { async fn test_respect_base_fee() { let base_fee = 50u64; let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee.to_alloy()))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let mut tx = TypedTransaction::default(); tx.set_value(100u64); tx.set_to(Address::random()); @@ -100,7 +101,7 @@ async fn test_respect_base_fee() { async fn test_tip_above_fee_cap() { let base_fee = 50u64; let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee.to_alloy()))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let tx = TypedTransaction::Eip1559( Eip1559TransactionRequest::new() .max_fee_per_gas(base_fee) diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index 5c79d29ab450d..6e3204d9d6b3f 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -5,6 +5,8 @@ use anvil::{spawn, NodeConfig}; use ethers::{core::rand, prelude::Middleware}; use futures::StreamExt; +use crate::utils::ethers_ipc_provider; + pub fn rand_ipc_endpoint() -> String { let num: u64 = rand::Rng::gen(&mut rand::thread_rng()); if cfg!(windows) { @@ -25,7 +27,7 @@ async fn can_get_block_number_ipc() { let block_num = api.block_number().unwrap(); assert_eq!(block_num, U256::ZERO); - let provider = handle.ethers_ipc_provider().unwrap(); + let provider = ethers_ipc_provider(handle.ipc_path()).unwrap(); let num = provider.get_block_number().await.unwrap(); assert_eq!(num.as_u64(), block_num.to::()); @@ -35,7 +37,7 @@ async fn can_get_block_number_ipc() { async fn test_sub_new_heads_ipc() { let (api, handle) = spawn(ipc_config()).await; - let provider = handle.ethers_ipc_provider().unwrap(); + let provider = ethers_ipc_provider(handle.ipc_path()).unwrap(); let blocks = provider.subscribe_blocks().await.unwrap(); diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index 307eabf27ed3e..5fc9cf9f22f16 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -1,21 +1,25 @@ //! log/event related tests -use crate::abi::*; +use crate::{ + abi::*, + utils::{ethers_http_provider, ethers_ws_provider}, +}; use anvil::{spawn, NodeConfig}; use ethers::{ middleware::SignerMiddleware, prelude::{BlockNumber, Filter, FilterKind, Middleware, Signer, H256}, types::Log, }; +use foundry_common::types::ToEthers; use futures::StreamExt; use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn get_past_events() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let address = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -50,9 +54,9 @@ async fn get_past_events() { #[tokio::test(flavor = "multi_thread")] async fn get_all_events() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) @@ -87,9 +91,9 @@ async fn get_all_events() { #[tokio::test(flavor = "multi_thread")] async fn can_install_filter() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) @@ -129,8 +133,9 @@ async fn can_install_filter() { #[tokio::test(flavor = "multi_thread")] async fn watch_events() { let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let client = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet)); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let provider = ethers_http_provider(&handle.http_endpoint()); + let client = Arc::new(SignerMiddleware::new(provider, wallet)); let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) .unwrap() @@ -143,7 +148,7 @@ async fn watch_events() { let mut stream = event.stream().await.unwrap(); // Also set up a subscription for the same thing - let ws = Arc::new(handle.ethers_ws_provider()); + let ws = Arc::new(ethers_ws_provider(&handle.ws_endpoint())); let contract2 = SimpleStorage::new(contract.address(), ws); let event2 = contract2.event::(); let mut subscription = event2.subscribe().await.unwrap(); diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index abd4de130484c..de9f0c875672c 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -1,5 +1,6 @@ //! Tests for OP chain support. +use crate::utils::ethers_http_provider; use anvil::{spawn, Hardfork, NodeConfig}; use ethers::{ abi::Address, @@ -17,7 +18,7 @@ use std::str::FromStr; async fn test_deposits_not_supported_if_optimism_disabled() { // optimism disabled by default let (_, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); @@ -53,7 +54,7 @@ async fn test_send_value_deposit_transaction() { // enable the Optimism flag let (api, handle) = spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let send_value = U256::from(1234); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); @@ -100,7 +101,7 @@ async fn test_send_value_raw_deposit_transaction() { // enable the Optimism flag let (api, handle) = spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let send_value = U256::from(1234); let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index ab77259814430..8dca5f7a2e251 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -1,7 +1,11 @@ //! tests for otterscan endpoints -use crate::abi::MulticallContract; +use crate::{ + abi::MulticallContract, + utils::{ethers_http_provider, ethers_ws_provider}, +}; use alloy_primitives::U256 as rU256; use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions}; +use alloy_signer::Signer as AlloySigner; use anvil::{ eth::otterscan::types::{ OtsInternalOperation, OtsInternalOperationType, OtsTrace, OtsTraceType, @@ -12,7 +16,7 @@ use ethers::{ abi::Address, prelude::{ContractFactory, ContractInstance, Middleware, SignerMiddleware}, signers::Signer, - types::{Bytes, TransactionRequest, U256}, + types::{Bytes, TransactionRequest}, utils::get_contract_address, }; use ethers_solc::{project_util::TempProject, Artifact}; @@ -41,9 +45,9 @@ async fn can_call_ots_get_api_level() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_internal_operations_contract_deploy() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -70,16 +74,18 @@ async fn can_call_ots_get_internal_operations_contract_deploy() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_internal_operations_contract_transfer() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); let to = accounts[1].address(); - //let client = Arc::new(SignerMiddleware::new(provider, wallet)); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let tx = TransactionRequest::new() + .to(to.to_ethers()) + .value(amount.to_ethers()) + .from(from.to_ethers()); let receipt = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); @@ -90,9 +96,9 @@ async fn can_call_ots_get_internal_operations_contract_transfer() { res[0], OtsInternalOperation { r#type: OtsInternalOperationType::Transfer, - from: from.to_alloy(), - to: to.to_alloy(), - value: amount.to_alloy() + from, + to, + value: amount } ); } @@ -125,8 +131,8 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); - let wallets = handle.dev_wallets().collect::>(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); + let wallets = handle.dev_wallets().collect::>().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully @@ -136,7 +142,7 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), + SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), ); let call = contract.method::<_, ()>("deploy", ()).unwrap(); @@ -183,8 +189,8 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); - let wallets = handle.dev_wallets().collect::>(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); + let wallets = handle.dev_wallets().collect::>().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully @@ -194,7 +200,7 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), + SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), ); let call = contract.method::<_, ()>("goodbye", ()).unwrap(); @@ -217,9 +223,9 @@ contract Contract { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_has_code() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); api.mine_one().await; @@ -296,8 +302,8 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); - let wallets = handle.dev_wallets().collect::>(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); + let wallets = handle.dev_wallets().collect::>().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully @@ -307,7 +313,7 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), + SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), ); let call = contract.method::<_, ()>("run", ()).unwrap().value(1337); let receipt = call.send().await.unwrap().await.unwrap().unwrap(); @@ -330,7 +336,7 @@ contract Contract { depth: 1, from: contract.address().to_alloy(), to: contract.address().to_alloy(), - value: U256::zero().to_alloy(), + value: rU256::ZERO, input: Bytes::from_str("0x6a6758fe").unwrap().0.into() }, OtsTrace { @@ -338,7 +344,7 @@ contract Contract { depth: 1, from: contract.address().to_alloy(), to: contract.address().to_alloy(), - value: U256::zero().to_alloy(), + value: rU256::ZERO, input: Bytes::from_str("0x96385e39").unwrap().0.into() }, OtsTrace { @@ -346,7 +352,7 @@ contract Contract { depth: 2, from: contract.address().to_alloy(), to: wallets[0].address().to_alloy(), - value: U256::from(1337).to_alloy(), + value: rU256::from(1337), input: Bytes::from_str("0x").unwrap().0.into() }, OtsTrace { @@ -354,7 +360,7 @@ contract Contract { depth: 2, from: contract.address().to_alloy(), to: contract.address().to_alloy(), - value: U256::zero().to_alloy(), + value: rU256::ZERO, input: Bytes::from_str("0xa1325397").unwrap().0.into() }, ] @@ -385,9 +391,9 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); // deploy successfully @@ -406,9 +412,9 @@ contract Contract { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_details() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let tx = TransactionRequest::new().to(Address::random()).value(100u64); @@ -428,9 +434,9 @@ async fn can_call_ots_get_block_details() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_details_by_hash() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let tx = TransactionRequest::new().to(Address::random()).value(100u64); @@ -451,9 +457,9 @@ async fn can_call_ots_get_block_details_by_hash() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); // disable automine @@ -493,9 +499,9 @@ async fn can_call_ots_get_block_transactions() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_search_transactions_before() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -529,9 +535,9 @@ async fn can_call_ots_search_transactions_before() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_search_transactions_after() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -565,10 +571,10 @@ async fn can_call_ots_search_transactions_after() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_transaction_by_sender_and_nonce() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); api.mine_one().await; - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -594,10 +600,10 @@ async fn can_call_ots_get_transaction_by_sender_and_nonce() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_contract_creator() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); api.mine_one().await; - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs index cbe803fb28179..85e8c630f7d56 100644 --- a/crates/anvil/tests/it/proof/mod.rs +++ b/crates/anvil/tests/it/proof/mod.rs @@ -1,15 +1,11 @@ //! tests for `eth_getProof` use crate::proof::eip1186::verify_proof; +use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_rlp::Decodable; use alloy_rpc_types::EIP1186AccountProofResponse; use anvil::{spawn, NodeConfig}; use anvil_core::eth::{proof::BasicAccount, trie::ExtensionLayout}; -use ethers::{ - abi::ethereum_types::BigEndianHash, - types::{Address, H256, U256}, - utils::{keccak256, rlp}, -}; -use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::revm::primitives::KECCAK_EMPTY; mod eip1186; @@ -20,50 +16,48 @@ async fn can_get_proof() { let acc: Address = "0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa".parse().unwrap(); - let key = U256::zero(); - let value = U256::one(); + let key = U256::ZERO; + let value = U256::from(1); - api.anvil_set_storage_at(acc.to_alloy(), key.to_alloy(), H256::from_uint(&value).to_alloy()) - .await - .unwrap(); + api.anvil_set_storage_at(acc, key, B256::from(value)).await.unwrap(); let proof: EIP1186AccountProofResponse = - api.get_proof(acc.to_alloy(), vec![H256::from_uint(&key).to_alloy()], None).await.unwrap(); + api.get_proof(acc, vec![B256::from(key)], None).await.unwrap(); let account = BasicAccount { - nonce: 0.into(), - balance: 0.into(), - storage_root: proof.storage_hash.to_ethers(), - code_hash: KECCAK_EMPTY.to_ethers(), + nonce: U256::from(0), + balance: U256::from(0), + storage_root: proof.storage_hash, + code_hash: KECCAK_EMPTY, }; - let rlp_account = rlp::encode(&account); + let rlp_account = alloy_rlp::encode(&account); - let root: H256 = api.state_root().await.unwrap().to_ethers(); + let root: B256 = api.state_root().await.unwrap(); let acc_proof: Vec> = proof .account_proof .into_iter() - .map(|node| rlp::decode::>(&node).unwrap()) + .map(|node| Vec::::decode(&mut &node[..]).unwrap()) .collect(); verify_proof::( &root.0, &acc_proof, - &keccak256(acc.as_bytes())[..], + &keccak256(acc.as_slice())[..], Some(rlp_account.as_ref()), ) .unwrap(); assert_eq!(proof.storage_proof.len(), 1); - let expected_value = rlp::encode(&value); + let expected_value = alloy_rlp::encode(value); let proof = proof.storage_proof[0].clone(); let storage_proof: Vec> = - proof.proof.into_iter().map(|node| rlp::decode::>(&node).unwrap()).collect(); - let key = H256::from(keccak256(proof.key.0 .0)); + proof.proof.into_iter().map(|node| Vec::::decode(&mut &node[..]).unwrap()).collect(); + let key = B256::from(keccak256(proof.key.0 .0)); verify_proof::( &account.storage_root.0, &storage_proof, - key.as_bytes(), + key.as_slice(), Some(expected_value.as_ref()), ) .unwrap(); @@ -75,7 +69,7 @@ async fn can_get_random_account_proofs() { for acc in std::iter::repeat_with(Address::random).take(10) { let _ = api - .get_proof(acc.to_alloy(), Vec::new(), None) + .get_proof(acc, Vec::new(), None) .await .unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}")); } diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index 31671a53809e1..a8dd6d3d75558 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -1,5 +1,6 @@ //! tests for subscriptions +use crate::utils::{ethers_http_provider, ethers_ws_provider}; use anvil::{spawn, NodeConfig}; use ethers::{ contract::abigen, @@ -9,7 +10,7 @@ use ethers::{ signers::Signer, types::{Address, Block, Filter, TransactionRequest, TxHash, ValueOrArray, U256}, }; -use foundry_common::types::ToAlloy; +use foundry_common::types::{ToAlloy, ToEthers}; use futures::StreamExt; use std::sync::Arc; @@ -17,7 +18,7 @@ use std::sync::Arc; async fn test_sub_new_heads() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); let blocks = provider.subscribe_blocks().await.unwrap(); @@ -35,9 +36,9 @@ async fn test_sub_logs_legacy() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let msg = "First Message".to_string(); @@ -74,9 +75,9 @@ async fn test_sub_logs() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let msg = "First Message".to_string(); @@ -112,7 +113,7 @@ async fn test_sub_logs_impersonated() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); // impersonate account let impersonate = Address::random(); @@ -120,7 +121,7 @@ async fn test_sub_logs_impersonated() { api.anvil_set_balance(impersonate.to_alloy(), funding.to_alloy()).await.unwrap(); api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let msg = "First Message".to_string(); @@ -138,7 +139,7 @@ async fn test_sub_logs_impersonated() { let tx = TransactionRequest::new().from(impersonate).to(contract.address()).data(data); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let receipt = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); @@ -153,9 +154,9 @@ async fn test_filters_legacy() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let from = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -194,9 +195,9 @@ async fn test_filters() { abigen!(EmitLogs, "test-data/emit_logs.json"); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let from = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -254,7 +255,7 @@ async fn test_subscriptions() { async fn test_sub_new_heads_fast() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); let blocks = provider.subscribe_blocks().await.unwrap(); diff --git a/crates/anvil/tests/it/sign.rs b/crates/anvil/tests/it/sign.rs index c802c0ff6e672..79b8efbf17691 100644 --- a/crates/anvil/tests/it/sign.rs +++ b/crates/anvil/tests/it/sign.rs @@ -1,9 +1,12 @@ +use crate::utils::ethers_http_provider; +use alloy_dyn_abi::TypedData; use anvil::{spawn, NodeConfig}; use ethers::{ prelude::{Middleware, SignerMiddleware}, signers::Signer, - types::{transaction::eip712::TypedData, Address, Chain, TransactionRequest}, + types::{Address, Chain, TransactionRequest}, }; +use foundry_common::types::ToEthers; #[tokio::test(flavor = "multi_thread")] async fn can_sign_typed_data() { @@ -283,23 +286,24 @@ async fn can_sign_typed_data_os() { #[tokio::test(flavor = "multi_thread")] async fn rejects_different_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = SignerMiddleware::new(provider, wallet.with_chain_id(Chain::Mainnet)); let tx = TransactionRequest::new().to(Address::random()).value(100u64); let res = client.send_transaction(tx, None).await; let err = res.unwrap_err(); - assert!(err.to_string().contains("signed for another chain")); + assert!(err.to_string().contains("signed for another chain"), "{}", err.to_string()); } #[tokio::test(flavor = "multi_thread")] async fn rejects_invalid_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap().with_chain_id(99u64); - let provider = handle.ethers_http_provider(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = wallet.with_chain_id(99u64); + let provider = ethers_http_provider(&handle.http_endpoint()); let client = SignerMiddleware::new(provider, wallet); let tx = TransactionRequest::new().to(Address::random()).value(100u64); let res = client.send_transaction(tx, None).await; diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index be192fec23eab..e7d42051b1a4f 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,4 +1,8 @@ -use crate::fork::fork_config; +use crate::{ + fork::fork_config, + utils::{ethers_http_provider, ethers_ws_provider}, +}; +use alloy_primitives::U256; use anvil::{spawn, NodeConfig}; use ethers::{ contract::ContractInstance, @@ -10,20 +14,20 @@ use ethers::{ utils::hex, }; use ethers_solc::{project_util::TempProject, Artifact}; -use foundry_common::types::ToAlloy; +use foundry_common::types::{ToAlloy, ToEthers}; use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn test_get_transfer_parity_traces() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); // specify the `from` field so that the client knows which account to use - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); // broadcast it via the eth_sendTransaction API let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); @@ -35,7 +39,7 @@ async fn test_get_transfer_parity_traces() { Action::Call(ref call) => { assert_eq!(call.from, from); assert_eq!(call.to, to); - assert_eq!(call.value, amount); + assert_eq!(call.value, amount.to_ethers()); } _ => unreachable!("unexpected action"), } @@ -73,8 +77,8 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); - let wallets = handle.dev_wallets().collect::>(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); + let wallets = handle.dev_wallets().collect::>().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully @@ -84,13 +88,15 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), + SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), ); let call = contract.method::<_, ()>("goodbye", ()).unwrap(); let tx = call.send().await.unwrap().await.unwrap().unwrap(); - let traces = - handle.ethers_http_provider().trace_transaction(tx.transaction_hash).await.unwrap(); + let traces = ethers_http_provider(&handle.http_endpoint()) + .trace_transaction(tx.transaction_hash) + .await + .unwrap(); assert!(!traces.is_empty()); assert_eq!(traces[1].action_type, ActionType::Suicide); } @@ -121,8 +127,8 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); - let wallets = handle.dev_wallets().collect::>(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); + let wallets = handle.dev_wallets().collect::>().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully @@ -132,12 +138,11 @@ contract Contract { let contract = ContractInstance::new( contract.address(), abi.unwrap(), - SignerMiddleware::new(handle.ethers_http_provider(), wallets[1].clone()), + SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), ); let call = contract.method::<_, ()>("goodbye", ()).unwrap(); - let traces = handle - .ethers_http_provider() + let traces = ethers_http_provider(&handle.http_endpoint()) .debug_trace_call(call.tx, None, GethDebugTracingCallOptions::default()) .await .unwrap(); @@ -160,7 +165,7 @@ contract Contract { #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15291050u64))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let input = hex::decode("43bcfab60000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000e0bd811c8769a824b00000000000000000000000000000000000000000000000e0ae9925047d8440b60000000000000000000000002e4777139254ff76db957e284b186a4507ff8c67").unwrap(); @@ -353,7 +358,7 @@ async fn test_trace_address_fork() { #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork2() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15314401u64))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let input = hex::decode("30000003000000000000000000000000adda1059a6c6c102b0fa562b9bb2cb9a0de5b1f4000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a300000004fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000004319b52bf08b65295d49117e790000000000000000000000000000000000000000000000008b6d9e8818d6141f000000000000000000000000000000000000000000000000000000086a23af210000000000000000000000000000000000000000000000000000000000").unwrap(); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index b93286debd6f5..9facf3dca9c4d 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -1,4 +1,9 @@ -use crate::abi::*; +use crate::{ + abi::*, + utils::{ethers_http_provider, ethers_ws_provider}, +}; +use alloy_primitives::U256 as rU256; +use alloy_signer::Signer as AlloySigner; use anvil::{spawn, Hardfork, NodeConfig}; use ethers::{ abi::ethereum_types::BigEndianHash, @@ -19,9 +24,9 @@ use tokio::time::timeout; #[tokio::test(flavor = "multi_thread")] async fn can_transfer_eth() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); @@ -30,11 +35,11 @@ async fn can_transfer_eth() { let balance_before = provider.get_balance(to, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); // craft the tx // specify the `from` field so that the client knows which account to use - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); // broadcast it via the eth_sendTransaction API let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); @@ -48,31 +53,36 @@ async fn can_transfer_eth() { let to_balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance_before.saturating_add(amount), to_balance); + assert_eq!(balance_before.saturating_add(amount.to_ethers()), to_balance); } #[tokio::test(flavor = "multi_thread")] async fn can_order_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); // disable automine api.anvil_set_auto_mine(false).await.unwrap(); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); // craft the tx with lower price - let tx = TransactionRequest::new().to(to).from(from).value(amount).gas_price(gas_price); + let tx = + TransactionRequest::new().to(to).from(from).value(amount.to_ethers()).gas_price(gas_price); let tx_lower = provider.send_transaction(tx, None).await.unwrap(); // craft the tx with higher price - let tx = TransactionRequest::new().to(from).from(to).value(amount).gas_price(gas_price + 1); + let tx = TransactionRequest::new() + .to(from) + .from(to) + .value(amount.to_ethers()) + .gas_price(gas_price + 1); let tx_higher = provider.send_transaction(tx, None).await.unwrap(); // manually mine the block with the transactions @@ -88,16 +98,16 @@ async fn can_order_transactions() { #[tokio::test(flavor = "multi_thread")] async fn can_respect_nonces() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(3u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); // send the transaction with higher nonce than on chain let higher_pending_tx = @@ -127,17 +137,17 @@ async fn can_replace_transaction() { // disable auto mining api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let amount = handle.genesis_balance().checked_div(3u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from).nonce(nonce); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from).nonce(nonce); // send transaction with lower gas price let lower_priced_pending_tx = @@ -165,16 +175,16 @@ async fn can_replace_transaction() { #[tokio::test(flavor = "multi_thread")] async fn can_reject_too_high_gas_limits() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); let gas_limit = api.gas_limit(); - let amount = handle.genesis_balance().checked_div(3u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); // send transaction with the exact gas limit let pending = provider.send_transaction(tx.clone().gas(gas_limit.to_ethers()), None).await; @@ -202,17 +212,17 @@ async fn can_reject_underpriced_replacement() { // disable auto mining api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let amount = handle.genesis_balance().checked_div(3u64.into()).unwrap(); + let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from).nonce(nonce); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from).nonce(nonce); // send transaction with higher gas price let higher_priced_pending_tx = @@ -237,9 +247,9 @@ async fn can_reject_underpriced_replacement() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_http() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) @@ -270,9 +280,9 @@ async fn can_deploy_and_mine_manually() { // can mine in manual mode api.evm_mine(None).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let tx = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()).unwrap().deployer.tx; @@ -303,12 +313,12 @@ async fn can_deploy_and_mine_manually() { #[tokio::test(flavor = "multi_thread")] async fn can_mine_automatically() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let tx = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()).unwrap().deployer.tx; @@ -324,9 +334,9 @@ async fn can_mine_automatically() { #[tokio::test(flavor = "multi_thread")] async fn can_call_greeter_historic() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) @@ -359,9 +369,9 @@ async fn can_call_greeter_historic() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_ws() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) @@ -384,9 +394,9 @@ async fn can_deploy_greeter_ws() { #[tokio::test(flavor = "multi_thread")] async fn can_deploy_get_code() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) @@ -403,9 +413,9 @@ async fn can_deploy_get_code() { #[tokio::test(flavor = "multi_thread")] async fn get_blocktimestamp_works() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let contract = @@ -442,9 +452,9 @@ async fn get_blocktimestamp_works() { #[tokio::test(flavor = "multi_thread")] async fn call_past_state() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) @@ -499,9 +509,9 @@ async fn call_past_state() { async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); @@ -529,9 +539,9 @@ async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let from = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let nonce = client.get_transaction_count(from, None).await.unwrap(); @@ -563,9 +573,9 @@ async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let from = wallet.address(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); @@ -622,10 +632,10 @@ async fn can_get_pending_transaction() { // disable auto mining so we can check if we can return pending tx from the mempool api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let from = handle.dev_wallets().next().unwrap().address(); - let tx = TransactionRequest::new().from(from).value(1337u64).to(Address::random()); + let tx = TransactionRequest::new().from(from.to_ethers()).value(1337u64).to(Address::random()); let tx = provider.send_transaction(tx, None).await.unwrap(); let pending = provider.get_transaction(tx.tx_hash()).await.unwrap(); @@ -643,11 +653,11 @@ async fn test_first_noce_is_zero() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let from = handle.dev_wallets().next().unwrap().address(); let nonce = provider - .get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))) + .get_transaction_count(from.to_ethers(), Some(BlockId::Number(BlockNumber::Pending))) .await .unwrap(); @@ -660,8 +670,8 @@ async fn can_handle_different_sender_nonce_calculation() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.ethers_http_provider(); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let provider = ethers_http_provider(&handle.http_endpoint()); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from_first = accounts[0].address(); let from_second = accounts[1].address(); @@ -695,17 +705,18 @@ async fn includes_pending_tx_for_transaction_count() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let from = handle.dev_wallets().next().unwrap().address(); let tx_count = 10u64; // send a bunch of tx to the mempool and check nonce is returned correctly for idx in 1..=tx_count { - let tx = TransactionRequest::new().from(from).value(1337u64).to(Address::random()); + let tx = + TransactionRequest::new().from(from.to_ethers()).value(1337u64).to(Address::random()); let _tx = provider.send_transaction(tx, None).await.unwrap(); let nonce = provider - .get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))) + .get_transaction_count(from.to_ethers(), Some(BlockId::Number(BlockNumber::Pending))) .await .unwrap(); assert_eq!(nonce, idx.into()); @@ -713,7 +724,7 @@ async fn includes_pending_tx_for_transaction_count() { api.mine_one().await; let nonce = provider - .get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))) + .get_transaction_count(from.to_ethers(), Some(BlockId::Number(BlockNumber::Pending))) .await .unwrap(); assert_eq!(nonce, tx_count.into()); @@ -722,14 +733,14 @@ async fn includes_pending_tx_for_transaction_count() { #[tokio::test(flavor = "multi_thread")] async fn can_get_historic_info() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let accounts: Vec<_> = handle.dev_wallets().collect(); + let accounts = handle.dev_wallets().collect::>().to_ethers(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(2u64.into()).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount).from(from); + let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); + let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let nonce_pre = provider @@ -750,7 +761,7 @@ async fn can_get_historic_info() { assert!(balance_post < balance_pre); let to_balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance_pre.saturating_add(amount), to_balance); + assert_eq!(balance_pre.saturating_add(amount.to_ethers()), to_balance); } // @@ -758,8 +769,9 @@ async fn can_get_historic_info() { async fn test_tx_receipt() { let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let client = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet)); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let client = + Arc::new(SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallet)); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); @@ -780,8 +792,8 @@ async fn can_stream_pending_transactions() { let (_api, handle) = spawn(NodeConfig::test().with_blocktime(Some(Duration::from_secs(2)))).await; let num_txs = 5; - let provider = handle.ethers_http_provider(); - let ws_provider = handle.ethers_ws_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); + let ws_provider = ethers_ws_provider(&handle.ws_endpoint()); let accounts = provider.get_accounts().await.unwrap(); let tx = TransactionRequest::new().from(accounts[0]).to(accounts[0]).value(1e18 as u64); @@ -863,8 +875,9 @@ async fn test_tx_access_list() { // - The sender shouldn't be in the AL let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let client = Arc::new(SignerMiddleware::new(handle.ethers_http_provider(), wallet)); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let client = + Arc::new(SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallet)); let sender = Address::random(); let other_acc = Address::random(); @@ -933,9 +946,9 @@ async fn estimates_gas_on_pending_by_default() { // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let sender = wallet.address(); let recipient = Address::random(); @@ -952,7 +965,7 @@ async fn estimates_gas_on_pending_by_default() { #[tokio::test(flavor = "multi_thread")] async fn test_reject_gas_too_low() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); let account = handle.dev_accounts().next().unwrap(); @@ -960,7 +973,7 @@ async fn test_reject_gas_too_low() { let tx = TransactionRequest::new() .to(Address::random()) .value(U256::from(1337u64)) - .from(account) + .from(account.to_ethers()) .gas(gas); let resp = provider.send_transaction(tx, None).await; @@ -974,9 +987,9 @@ async fn test_reject_gas_too_low() { async fn can_call_with_high_gas_limit() { let (_api, handle) = spawn(NodeConfig::test().with_gas_limit(Some(U256::from(100_000_000).to_alloy()))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) @@ -992,9 +1005,9 @@ async fn can_call_with_high_gas_limit() { #[tokio::test(flavor = "multi_thread")] async fn test_reject_eip1559_pre_london() { let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap(); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallet)); let gas_limit = api.gas_limit(); diff --git a/crates/anvil/tests/it/txpool.rs b/crates/anvil/tests/it/txpool.rs index 3f17e5beeaac0..3c10a577f306a 100644 --- a/crates/anvil/tests/it/txpool.rs +++ b/crates/anvil/tests/it/txpool.rs @@ -1,5 +1,6 @@ //! txpool related tests +use crate::utils::ethers_http_provider; use anvil::{spawn, NodeConfig}; use ethers::{ prelude::Middleware, @@ -9,7 +10,7 @@ use ethers::{ #[tokio::test(flavor = "multi_thread")] async fn geth_txpool() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_http_provider(); + let provider = ethers_http_provider(&handle.http_endpoint()); api.anvil_set_auto_mine(false).await.unwrap(); let account = provider.get_accounts().await.unwrap()[0]; diff --git a/crates/anvil/tests/it/utils.rs b/crates/anvil/tests/it/utils.rs index 0a566609300fe..7fdd90823a3db 100644 --- a/crates/anvil/tests/it/utils.rs +++ b/crates/anvil/tests/it/utils.rs @@ -2,6 +2,7 @@ use ethers::{ addressbook::contract, types::{Address, Chain}, }; +use foundry_common::provider::ethers::{ProviderBuilder, RetryProvider}; /// Returns a set of various contract addresses pub fn contract_addresses(chain: Chain) -> Vec
{ @@ -13,3 +14,18 @@ pub fn contract_addresses(chain: Chain) -> Vec
{ contract("uniswapV3SwapRouter02").unwrap().address(chain).unwrap(), ] } + +/// Builds an ethers HTTP [RetryProvider] +pub fn ethers_http_provider(http_endpoint: &str) -> RetryProvider { + ProviderBuilder::new(http_endpoint).build().expect("failed to build ethers HTTP provider") +} + +/// Builds an ethers ws [RetryProvider] +pub fn ethers_ws_provider(ws_endpoint: &str) -> RetryProvider { + ProviderBuilder::new(ws_endpoint).build().expect("failed to build ethers HTTP provider") +} + +/// Builds an ethers ws [RetryProvider] +pub fn ethers_ipc_provider(ipc_endpoint: Option) -> Option { + ProviderBuilder::new(&ipc_endpoint?).build().ok() +} diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index f1212bd410e50..7d31bdbcab752 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -1,7 +1,8 @@ //! general eth api tests with websocket provider +use alloy_providers::provider::TempProvider; use anvil::{spawn, NodeConfig}; -use ethers::{prelude::Middleware, types::U256}; +use ethers::types::U256; use foundry_common::types::ToAlloy; #[tokio::test(flavor = "multi_thread")] @@ -10,16 +11,16 @@ async fn can_get_block_number_ws() { let block_num = api.block_number().unwrap(); assert_eq!(block_num, U256::zero().to_alloy()); - let provider = handle.ethers_ws_provider(); + let provider = handle.ws_provider(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num, block_num.to::().into()); + assert_eq!(num, block_num.to::()); } #[tokio::test(flavor = "multi_thread")] async fn can_dev_get_balance_ws() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ethers_ws_provider(); + let provider = handle.ws_provider(); let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index a7def0f5c6c75..530d75d8ef707 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -17,6 +17,7 @@ foundry-config.workspace = true ethers-core.workspace = true ethers-middleware.workspace = true ethers-providers = { workspace = true, features = ["ws", "ipc"] } +ethers-signers.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true @@ -25,6 +26,7 @@ alloy-rpc-types.workspace = true alloy-rpc-client.workspace = true alloy-providers.workspace = true alloy-transport.workspace = true +alloy-signer.workspace = true alloy-transport-http.workspace = true alloy-transport-ws.workspace = true alloy-transport-ipc.workspace = true diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index 4247cc1eb808d..aea3bf6319bc8 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -3,6 +3,7 @@ use alloy_json_abi::{Event, EventParam, Function, InternalType, Param, StateMutability}; use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U128, U256, U64}; use alloy_rpc_types::{AccessList, AccessListItem, CallInput, CallRequest, Signature, Transaction}; +use alloy_signer::{LocalWallet, Signer}; use ethers_core::{ abi as ethabi, types::{ @@ -140,6 +141,26 @@ impl ToAlloy for ethers_core::types::Transaction { } } +impl ToEthers for alloy_signer::LocalWallet { + type To = ethers_signers::LocalWallet; + + fn to_ethers(self) -> Self::To { + ethers_signers::LocalWallet::new_with_signer( + self.signer().clone(), + self.address().to_ethers(), + self.chain_id().unwrap(), + ) + } +} + +impl ToEthers for Vec { + type To = Vec; + + fn to_ethers(self) -> Self::To { + self.into_iter().map(ToEthers::to_ethers).collect() + } +} + /// Converts from a [TransactionRequest] to a [CallRequest]. pub fn to_call_request_from_tx_request(tx: TransactionRequest) -> CallRequest { CallRequest { diff --git a/deny.toml b/deny.toml index 816574f430e92..e3ae679d035c3 100644 --- a/deny.toml +++ b/deny.toml @@ -67,9 +67,6 @@ exceptions = [ { allow = ["CC0-1.0"], name = "constant_time_eq" }, { allow = ["CC0-1.0"], name = "dunce" }, { allow = ["CC0-1.0"], name = "aurora-engine-modexp" }, - - { allow = ["GPL-3.0"], name = "fastrlp" }, - { allow = ["GPL-3.0"], name = "fastrlp-derive" }, ] #copyleft = "deny" From 3cc7bda0add291710da9f34af90f647741254d0a Mon Sep 17 00:00:00 2001 From: Cruz Molina Date: Thu, 25 Jan 2024 13:31:55 -0800 Subject: [PATCH 0527/1963] chore: update `alloy-chains` (#6896) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 125d824ffc169..8c7748906188d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a5f61137c31916542bb63cd70d0e0dd7a76f76b7f962f4337bc438612d45b2" +checksum = "206e825321d0ed5b6e3907e6ddf70c2139cfdc6274e83a1ca2f4784bd0abc0c9" dependencies = [ "num_enum", "serde", diff --git a/Cargo.toml b/Cargo.toml index ab0714e681522..077fb93f10b55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -166,7 +166,7 @@ alloy-json-abi = "0.6.2" alloy-sol-types = "0.6.2" syn-solidity = "0.6.0" -alloy-chains = "0.1.5" +alloy-chains = "0.1.10" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" From c61dc80ce75156d717b968c9f0f882b5d021aa1e Mon Sep 17 00:00:00 2001 From: Darex <1010adigupta@gmail.com> Date: Fri, 26 Jan 2024 03:02:54 +0530 Subject: [PATCH 0528/1963] native string utils cheatcodes (#6891) * string utils cheatcodes created * fmt: run rustfmt * tests: solidity tests added * cargo cheats * update * update * chore: update defs --------- Co-authored-by: Matthias Seitz Co-authored-by: Enrique Ortiz --- crates/cheatcodes/assets/cheatcodes.json | 100 +++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 16 ++++ crates/cheatcodes/src/string.rs | 47 ++++++++++- testdata/cheats/StringUtils.t.sol | 42 ++++++++++ testdata/cheats/Vm.sol | 5 ++ 5 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 testdata/cheats/StringUtils.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 6ccbcd21f968c..7198f615288af 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5913,6 +5913,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "replace", + "description": "Replaces occurrences of `from` in the given `string` with `to`.", + "declaration": "function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output);", + "visibility": "external", + "mutability": "pure", + "signature": "replace(string,string,string)", + "selector": "0xe00ad03e", + "selectorBytes": [ + 224, + 10, + 208, + 62 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "resetNonce", @@ -6713,6 +6733,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "split", + "description": "Splits the given `string` into an array of strings divided by the `delimiter`.", + "declaration": "function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);", + "visibility": "external", + "mutability": "pure", + "signature": "split(string,string)", + "selector": "0x8bb75533", + "selectorBytes": [ + 139, + 183, + 85, + 51 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "startBroadcast_0", @@ -7033,6 +7073,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "toLowercase", + "description": "Converts the given `string` value to Lowercase.", + "declaration": "function toLowercase(string calldata input) external pure returns (string memory output);", + "visibility": "external", + "mutability": "pure", + "signature": "toLowercase(string)", + "selector": "0x50bb0884", + "selectorBytes": [ + 80, + 187, + 8, + 132 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "toString_0", @@ -7153,6 +7213,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "toUppercase", + "description": "Converts the given `string` value to Uppercase.", + "declaration": "function toUppercase(string calldata input) external pure returns (string memory output);", + "visibility": "external", + "mutability": "pure", + "signature": "toUppercase(string)", + "selector": "0x074ae3d7", + "selectorBytes": [ + 7, + 74, + 227, + 215 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "transact_0", @@ -7193,6 +7273,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "trim", + "description": "Trims leading and trailing whitespace from the given `string` value.", + "declaration": "function trim(string calldata input) external pure returns (string memory output);", + "visibility": "external", + "mutability": "pure", + "signature": "trim(string)", + "selector": "0xb2dad155", + "selectorBytes": [ + 178, + 218, + 209, + 85 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "tryFfi", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 69f1e084572dc..6ab18d10935b5 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1623,6 +1623,22 @@ interface Vm { #[cheatcode(group = String)] function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); + /// Converts the given `string` value to Lowercase. + #[cheatcode(group = String)] + function toLowercase(string calldata input) external pure returns (string memory output); + /// Converts the given `string` value to Uppercase. + #[cheatcode(group = String)] + function toUppercase(string calldata input) external pure returns (string memory output); + /// Trims leading and trailing whitespace from the given `string` value. + #[cheatcode(group = String)] + function trim(string calldata input) external pure returns (string memory output); + /// Replaces occurrences of `from` in the given `string` with `to`. + #[cheatcode(group = String)] + function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output); + /// Splits the given `string` into an array of strings divided by the `delimiter`. + #[cheatcode(group = String)] + function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs); + // ======== JSON Parsing and Manipulation ======== // -------- Reading -------- diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index f55350592ea10..b7992b9450fd3 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -94,6 +94,47 @@ impl Cheatcode for parseBoolCall { } } +// toLowercase +impl Cheatcode for toLowercaseCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { input } = self; + Ok(input.to_lowercase().abi_encode()) + } +} + +// toUppercase +impl Cheatcode for toUppercaseCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { input } = self; + Ok(input.to_uppercase().abi_encode()) + } +} + +// trim +impl Cheatcode for trimCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { input } = self; + Ok(input.trim().abi_encode()) + } +} + +// Replace +impl Cheatcode for replaceCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { input, from, to } = self; + Ok(input.replace(from, to).abi_encode()) + } +} + +// Split +impl Cheatcode for splitCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { input, delimiter } = self; + let parts: Vec<&str> = input.split(delimiter).collect(); + Ok(parts.abi_encode()) + } +} + pub(super) fn parse(s: &str, ty: &DynSolType) -> Result { parse_value(s, ty).map(|v| v.abi_encode()) } @@ -136,7 +177,9 @@ fn parse_value_fallback(s: &str, ty: &DynSolType) -> Option false, s if s.eq_ignore_ascii_case("true") => true, s if s.eq_ignore_ascii_case("false") => false, - _ => return None, + _ => { + return None; + } }; return Some(Ok(DynSolValue::Bool(b))); } @@ -145,7 +188,7 @@ fn parse_value_fallback(s: &str, ty: &DynSolType) -> Option { if !s.starts_with("0x") && s.chars().all(|c| c.is_ascii_hexdigit()) { - return Some(Err("missing hex prefix (\"0x\") for hex string")) + return Some(Err("missing hex prefix (\"0x\") for hex string")); } } _ => {} diff --git a/testdata/cheats/StringUtils.t.sol b/testdata/cheats/StringUtils.t.sol new file mode 100644 index 0000000000000..4fe8bba01447a --- /dev/null +++ b/testdata/cheats/StringUtils.t.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; + +contract StringManipulationTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testToLowercase() public { + string memory original = "Hello World"; + string memory lowercased = vm.toLowercase(original); + assertEq("hello world", lowercased); + } + + function testToUppercase() public { + string memory original = "Hello World"; + string memory uppercased = vm.toUppercase(original); + assertEq("HELLO WORLD", uppercased); + } + + function testTrim() public { + string memory original = " Hello World "; + string memory trimmed = vm.trim(original); + assertEq("Hello World", trimmed); + } + + function testReplace() public { + string memory original = "Hello World"; + string memory replaced = vm.replace(original, "World", "Reth"); + assertEq("Hello Reth", replaced); + } + + function testSplit() public { + string memory original = "Hello,World,Reth"; + string[] memory splitResult = vm.split(original, ","); + assertEq(3, splitResult.length); + assertEq("Hello", splitResult[0]); + assertEq("World", splitResult[1]); + assertEq("Reth", splitResult[2]); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index ed1563aa2b76a..bac97febb2f91 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -293,6 +293,7 @@ interface Vm { function rememberKey(uint256 privateKey) external returns (address keyAddr); 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 resetNonce(address account) external; function resumeGasMetering() external; function revertTo(uint256 snapshotId) external returns (bool success); @@ -333,6 +334,7 @@ interface Vm { function skip(bool skipTest) external; function sleep(uint256 duration) external; function snapshot() external returns (uint256 snapshotId); + function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs); function startBroadcast() external; function startBroadcast(address signer) external; function startBroadcast(uint256 privateKey) external; @@ -349,14 +351,17 @@ interface Vm { function toBase64URL(string calldata data) external pure returns (string memory); function toBase64(bytes calldata data) external pure returns (string memory); function toBase64(string calldata data) external pure returns (string memory); + function toLowercase(string calldata input) external pure returns (string memory output); function toString(address value) external pure returns (string memory stringifiedValue); function toString(bytes calldata value) external pure returns (string memory stringifiedValue); function toString(bytes32 value) external pure returns (string memory stringifiedValue); function toString(bool value) external pure returns (string memory stringifiedValue); function toString(uint256 value) external pure returns (string memory stringifiedValue); function toString(int256 value) external pure returns (string memory stringifiedValue); + function toUppercase(string calldata input) external pure returns (string memory output); function transact(bytes32 txHash) external; function transact(uint256 forkId, bytes32 txHash) external; + function trim(string calldata input) external pure returns (string memory output); function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result); function txGasPrice(uint256 newGasPrice) external; function unixTime() external returns (uint256 milliseconds); From ee362bdb90ae68bd2e40c49fb8f631e0f3bdb5bf Mon Sep 17 00:00:00 2001 From: galois Date: Fri, 26 Jan 2024 13:53:29 +0800 Subject: [PATCH 0529/1963] feat(cast): support short cut for querying erc20 balance in cast balance (#6828) --- crates/cast/bin/main.rs | 49 ++++++++++++++++++++++++++++------- crates/cast/bin/opts.rs | 5 ++++ crates/cast/tests/cli/main.rs | 27 +++++++++++++++++++ 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 24d7b62904a40..9c992e7667f25 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -2,17 +2,18 @@ extern crate tracing; use alloy_primitives::{keccak256, Address, B256}; -use cast::{Cast, SimpleCast}; +use cast::{Cast, SimpleCast, TxBuilder}; use clap::{CommandFactory, Parser}; use clap_complete::generate; -use ethers_core::types::{BlockId, BlockNumber::Latest}; -use ethers_providers::Middleware; +use ethers_core::types::{BlockId, BlockNumber::Latest, NameOrAddress}; +use ethers_providers::{Middleware, Provider}; use eyre::Result; use foundry_cli::{handler, prompt, stdin, utils}; use foundry_common::{ abi::get_event, fmt::format_tokens, fs, + runtime_client::RuntimeClient, selectors::{ decode_calldata, decode_event_topic, decode_function_selector, decode_selectors, import_selectors, parse_signatures, pretty_calldata, ParsedSignatures, SelectorImportData, @@ -201,14 +202,44 @@ async fn main() -> Result<()> { Cast::new(provider).age(block.unwrap_or(BlockId::Number(Latest))).await? ); } - Subcommands::Balance { block, who, ether, rpc } => { + Subcommands::Balance { block, who, ether, rpc, erc20 } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - let value = Cast::new(provider).balance(who, block).await?; - if ether { - println!("{}", SimpleCast::from_wei(&value.to_string(), "eth")?); - } else { - println!("{value}"); + + match erc20 { + Some(token) => { + let chain = utils::get_chain(config.chain, &provider).await?; + let mut builder: TxBuilder<'_, Provider> = TxBuilder::new( + &provider, + NameOrAddress::Address(Address::ZERO.to_ethers()), + Some(NameOrAddress::Address(token.to_ethers())), + chain, + true, + ) + .await?; + + let account_addr = match who { + NameOrAddress::Name(ens_name) => provider.resolve_name(&ens_name).await?, + NameOrAddress::Address(addr) => addr, + }; + + builder + .set_args( + "balanceOf(address) returns (uint256)", + vec![format!("{account_addr:#x}")], + ) + .await?; + let builder_output = builder.build(); + println!("{}", Cast::new(provider).call(builder_output, block).await?); + } + None => { + let value = Cast::new(provider).balance(who, block).await?; + if ether { + println!("{}", SimpleCast::from_wei(&value.to_string(), "eth")?); + } else { + println!("{value}"); + } + } } } Subcommands::BaseFee { block, rpc } => { diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 141861a9e3801..89ef6f96744a4 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -625,6 +625,11 @@ pub enum Subcommands { #[clap(flatten)] rpc: RpcOpts, + + /// erc20 address to query, with the method `balanceOf(address) return (uint256)`, alias + /// with '--erc721' + #[clap(long, alias = "erc721")] + erc20: Option
, }, /// Get the basefee of a block. diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index c685584863753..28703b5a116e6 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -556,3 +556,30 @@ casttest!(storage, |_prj, cmd| { cmd.cast_fuse().args(["storage", usdt, decimals_slot, "--rpc-url", &rpc]); assert_eq!(cmd.stdout_lossy().trim(), six); }); + +casttest!(balance, |_prj, cmd| { + let rpc = next_http_rpc_endpoint(); + let usdt = "0xdac17f958d2ee523a2206206994597c13d831ec7"; + cmd.cast_fuse().args([ + "balance", + "0x0000000000000000000000000000000000000000", + "--erc20", + usdt, + "--rpc-url", + &rpc, + ]); + cmd.cast_fuse().args([ + "balance", + "0x0000000000000000000000000000000000000000", + "--erc721", + usdt, + "--rpc-url", + &rpc, + ]); + + let usdt_result = cmd.stdout_lossy(); + let alias_result = cmd.stdout_lossy(); + + assert_ne!(usdt_result, "0x0000000000000000000000000000000000000000000000000000000000000000"); + assert_eq!(alias_result, usdt_result); +}); From 631efd7e8183aa63762640a8f39a61c58863fdeb Mon Sep 17 00:00:00 2001 From: yanziseeker <153156292+AdventureSeeker987@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:59:37 +0800 Subject: [PATCH 0530/1963] docs(docs/dev): correct cheatcodes.rs's md link path (#6902) --- docs/dev/cheatcodes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index 67e11c415e78e..ca4226be31f48 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -113,7 +113,7 @@ The way bindings are generated and extra information can be found in the [`sol!` We leverage this macro to apply the [`Cheatcode` derive macro](#cheatcode-derive-macro) on the `Vm` interface. -### [`Cheatcode`](../../crates/macros/impl/src/cheatcodes.rs) derive macro +### [`Cheatcode`](../../crates/macros/src/cheatcodes.rs) derive macro This is derived once on the `Vm` interface declaration, which recursively applies it to all of the interface's items, as well as the `sol!`-generated items, such as the `VmCalls` enum. From d4e5e145755046cad44cb599b57c44a9fd22aabc Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:26:32 +0100 Subject: [PATCH 0531/1963] chore: symlink config to crates/config for visibility (#6900) --- config | 1 + 1 file changed, 1 insertion(+) create mode 120000 config diff --git a/config b/config new file mode 120000 index 0000000000000..b13da88639799 --- /dev/null +++ b/config @@ -0,0 +1 @@ +crates/config \ No newline at end of file From fa6b46d3d2ab0875c120d1a4c6726e55c4cd54a9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:27:39 +0100 Subject: [PATCH 0532/1963] Revert "chore: symlink config to crates/config for visibility" (#6904) --- config | 1 - 1 file changed, 1 deletion(-) delete mode 120000 config diff --git a/config b/config deleted file mode 120000 index b13da88639799..0000000000000 --- a/config +++ /dev/null @@ -1 +0,0 @@ -crates/config \ No newline at end of file From a6350ea7b76f200b1d4efd6b51c1006fd335c1ec Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 26 Jan 2024 14:54:18 +0100 Subject: [PATCH 0533/1963] test: add another fork test (#6907) --- crates/forge/tests/it/repros.rs | 3 +++ testdata/repros/Issue5929.t.sol | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 testdata/repros/Issue5929.t.sol diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 61d9d97ff8537..d5dee2523e1e0 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -195,6 +195,9 @@ test_repro!(5038); // https://github.com/foundry-rs/foundry/issues/5808 test_repro!(5808); +// +test_repro!(5929); + // test_repro!(5935); diff --git a/testdata/repros/Issue5929.t.sol b/testdata/repros/Issue5929.t.sol new file mode 100644 index 0000000000000..53ca10ae86e2f --- /dev/null +++ b/testdata/repros/Issue5929.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/5929 +contract Issue5929Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_transact_not_working() public { + vm.createSelectFork("rpcAlias", 15625301); + // https://etherscan.io/tx/0x96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143 + vm.transact(hex"96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143"); + } +} From 8ba6d5649befb77047c4e276949fe66e0897caa1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 26 Jan 2024 15:06:54 +0100 Subject: [PATCH 0534/1963] fix: resolve more chain alias variants (#6905) --- crates/config/src/etherscan.rs | 46 +++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index ce1c4324d5bc1..5860fd7598e82 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -4,6 +4,7 @@ use crate::{ resolve::{interpolate, UnresolvedEnvVarError, RE_PLACEHOLDER}, Chain, Config, NamedChain, }; +use inflector::Inflector; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{ collections::BTreeMap, @@ -172,7 +173,19 @@ impl EtherscanConfig { let (chain, alias) = match (chain, alias) { // fill one with the other (Some(chain), None) => (Some(chain), Some(chain.to_string())), - (None, Some(alias)) => (alias.parse().ok(), Some(alias.into())), + (None, Some(alias)) => { + // alloy chain is parsed as kebab case + ( + alias.to_kebab_case().parse().ok().or_else(|| { + // if this didn't work try to parse as json because the deserialize impl + // supports more aliases + serde_json::from_str::(&format!("\"{alias}\"")) + .map(Into::into) + .ok() + }), + Some(alias.into()), + ) + } // leave as is (Some(chain), Some(alias)) => (Some(chain), Some(alias.into())), (None, None) => (None, None), @@ -441,4 +454,35 @@ mod tests { std::env::remove_var(env); } + + #[test] + fn resolve_etherscan_alias_config() { + let mut configs = EtherscanConfigs::default(); + configs.insert( + "blast_sepolia".to_string(), + EtherscanConfig { + chain: None, + url: Some("https://api.etherscan.io/api".to_string()), + key: EtherscanApiKey::Key("ABCDEFG".to_string()), + }, + ); + + let mut resolved = configs.clone().resolved(); + let config = resolved.remove("blast_sepolia").unwrap().unwrap(); + assert_eq!(config.chain, Some(Chain::blast_sepolia())); + } + + #[test] + fn resolve_etherscan_alias() { + let config = EtherscanConfig { + chain: None, + url: Some("https://api.etherscan.io/api".to_string()), + key: EtherscanApiKey::Key("ABCDEFG".to_string()), + }; + let resolved = config.clone().resolve(Some("base_sepolia")).unwrap(); + assert_eq!(resolved.chain, Some(Chain::base_sepolia())); + + let resolved = config.resolve(Some("base-sepolia")).unwrap(); + assert_eq!(resolved.chain, Some(Chain::base_sepolia())); + } } From 14bab74577751decb0b7bd87a4757b610b3c2587 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:32:29 +0100 Subject: [PATCH 0535/1963] chore: update .gitattributes and rustfmt.toml (#6909) --- .gitattributes | 4 ---- rustfmt.toml | 3 --- 2 files changed, 7 deletions(-) diff --git a/.gitattributes b/.gitattributes index f492456d97b17..0e34b8632d97e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,2 @@ -# auto-detection may fail for human-readable files, like the ones in abi/abi/*.sol -**/*.sol linguist-language=Solidity - -crates/abi/src/bindings/*.rs linguist-generated crates/cheatcodes/assets/*.json linguist-generated testdata/cheats/Vm.sol linguist-generated diff --git a/rustfmt.toml b/rustfmt.toml index 7fabf2c1de8f1..68c3c93033d4f 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -9,6 +9,3 @@ trailing_semicolon = false use_field_init_shorthand = true format_code_in_doc_comments = true doc_comment_code_block_width = 100 - -# Ignore automatically-generated code. -ignore = ["crates/abi/src/bindings"] From ae0ef191bb9fe144af6736bf56a4fa25f781d39a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 26 Jan 2024 20:10:37 +0100 Subject: [PATCH 0536/1963] chore(deps): unpin k256 (#6912) --- crates/anvil/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 15e6ea9921fb8..6d51daed08773 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -29,8 +29,7 @@ foundry-evm.workspace = true # evm support bytes = "1.4.0" -# needed as documented in https://github.com/foundry-rs/foundry/pull/6358 -k256 = "=0.13.1" +k256 = "0.13" ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } trie-db = "0.23" hash-db = "0.15" From deb3116955eea4333f9e4e4516104be4182e9ee2 Mon Sep 17 00:00:00 2001 From: Enrique Date: Fri, 26 Jan 2024 15:51:27 -0400 Subject: [PATCH 0537/1963] feat(`evm`/`cheatcodes`): Use `alloy-signer`, rm `ethers-signers`/`ethers-core` (#6911) * feat: use alloy-signer on cheatcodes * feat(evm): remove ethers-signers for alloy-signers * chore: fully remove ethers deps * Update Cargo.toml Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 7 ++-- Cargo.toml | 1 + crates/anvil/Cargo.toml | 2 +- crates/cheatcodes/Cargo.toml | 4 +-- crates/cheatcodes/src/error.rs | 7 ++-- crates/cheatcodes/src/evm.rs | 13 +++---- crates/cheatcodes/src/inspector.rs | 2 +- crates/cheatcodes/src/script.rs | 8 ++--- crates/cheatcodes/src/utils.rs | 50 +++++++++++++------------- crates/evm/evm/Cargo.toml | 2 +- crates/evm/evm/src/executors/mod.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 2 +- crates/forge/bin/cmd/script/runner.rs | 5 +-- 13 files changed, 52 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c7748906188d..e174364f2a745 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -313,6 +313,7 @@ dependencies = [ "coins-bip32", "coins-bip39", "elliptic-curve", + "eth-keystore", "k256", "rand 0.8.5", "thiserror", @@ -2978,11 +2979,10 @@ dependencies = [ "alloy-primitives", "alloy-providers", "alloy-rpc-types", + "alloy-signer", "alloy-sol-types", "base64 0.21.7", "const-hex", - "ethers-core", - "ethers-signers", "eyre", "foundry-cheatcodes-spec", "foundry-common", @@ -2991,6 +2991,7 @@ dependencies = [ "foundry-evm-core", "itertools 0.11.0", "jsonpath_lib", + "k256", "p256", "revm", "serde_json", @@ -3200,9 +3201,9 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-rpc-types", + "alloy-signer", "alloy-sol-types", "const-hex", - "ethers-signers", "eyre", "foundry-cheatcodes", "foundry-common", diff --git a/Cargo.toml b/Cargo.toml index 077fb93f10b55..11dd5a0e769b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -188,6 +188,7 @@ toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" evm-disassembler = "0.4" +k256 = "0.13" axum = "0.6" hyper = "0.14" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 6d51daed08773..3a3168ddf7237 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -29,7 +29,7 @@ foundry-evm.workspace = true # evm support bytes = "1.4.0" -k256 = "0.13" +k256.workspace = true ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } trie-db = "0.23" hash-db = "0.15" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 14cb26e289d22..4c2e69a364839 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -25,9 +25,8 @@ alloy-genesis.workspace = true alloy-sol-types.workspace = true alloy-providers.workspace = true alloy-rpc-types.workspace = true +alloy-signer = { workspace = true, features = ["mnemonic", "keystore"] } -ethers-core.workspace = true -ethers-signers.workspace = true eyre.workspace = true hex.workspace = true @@ -37,6 +36,7 @@ revm.workspace = true serde_json.workspace = true base64.workspace = true tracing.workspace = true +k256.workspace = true walkdir = "2" p256 = "0.13.2" thiserror = "1" diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 80ab7324a793d..19475982f3ede 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -1,11 +1,11 @@ use crate::Vm; use alloy_primitives::{Address, Bytes}; +use alloy_signer::{Error as SignerError, WalletError}; use alloy_sol_types::SolError; -use ethers_core::k256::ecdsa::signature::Error as SignatureError; -use ethers_signers::WalletError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; use foundry_evm_core::backend::DatabaseError; +use k256::ecdsa::signature::Error as SignatureError; use std::{borrow::Cow, fmt}; /// Cheatcode result type. @@ -283,7 +283,7 @@ macro_rules! impl_from { impl_from!( alloy_sol_types::Error, - ethers_core::types::SignatureError, + alloy_primitives::SignatureError, FsPathError, hex::FromHexError, eyre::Error, @@ -297,6 +297,7 @@ impl_from!( std::string::FromUtf8Error, UnresolvedEnvVarError, WalletError, + SignerError, ); #[cfg(test)] diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index f2e5b2026b0dc..5bd7750cfe290 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -3,12 +3,9 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_genesis::{Genesis, GenesisAccount}; use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_signer::Signer; use alloy_sol_types::SolValue; -use ethers_signers::Signer; -use foundry_common::{ - fs::{read_json_file, write_json_file}, - types::ToAlloy, -}; +use foundry_common::fs::{read_json_file, write_json_file}; use foundry_evm_core::{ backend::{DatabaseExt, RevertSnapshotAction}, constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS}, @@ -48,7 +45,7 @@ impl Cheatcode for addrCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { privateKey } = self; let wallet = super::utils::parse_wallet(privateKey)?; - Ok(wallet.address().to_alloy().abi_encode()) + Ok(wallet.address().abi_encode()) } } @@ -140,9 +137,9 @@ impl Cheatcode for dumpStateCall { } impl Cheatcode for sign_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_full(&self, _: &mut CheatsCtxt) -> Result { let Self { privateKey, digest } = self; - super::utils::sign(privateKey, digest, ccx.data.env.cfg.chain_id) + super::utils::sign(privateKey, digest) } } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 3f856c5586c19..4e48c5e9e28d3 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -16,8 +16,8 @@ use crate::{ }; use alloy_primitives::{Address, Bytes, B256, U256, U64}; use alloy_rpc_types::request::TransactionRequest; +use alloy_signer::LocalWallet; use alloy_sol_types::{SolInterface, SolValue}; -use ethers_signers::LocalWallet; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl}; use foundry_evm_core::{ backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index f4530b9fb5af1..820d3ffd9a18f 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -2,8 +2,7 @@ use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, U256}; -use ethers_signers::Signer; -use foundry_common::types::ToAlloy; +use alloy_signer::Signer; use foundry_config::Config; impl Cheatcode for broadcast_0Call { @@ -107,8 +106,9 @@ fn broadcast_key( private_key: &U256, single_call: bool, ) -> Result { - let wallet = super::utils::parse_wallet(private_key)?.with_chain_id(ccx.data.env.cfg.chain_id); - let new_origin = &wallet.address().to_alloy(); + let mut wallet = super::utils::parse_wallet(private_key)?; + wallet.set_chain_id(Some(ccx.data.env.cfg.chain_id)); + let new_origin = &wallet.address(); let result = broadcast(ccx, Some(new_origin), single_call); if result.is_ok() { diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 68c88da76be91..bb47264311888 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -2,21 +2,20 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{keccak256, B256, U256}; -use alloy_sol_types::SolValue; -use ethers_core::k256::{ - ecdsa::SigningKey, - elliptic_curve::{sec1::ToEncodedPoint, Curve}, - Secp256k1, -}; -use ethers_signers::{ +use alloy_signer::{ coins_bip39::{ ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, Portuguese, Spanish, Wordlist, }, - LocalWallet, MnemonicBuilder, Signer, + LocalWallet, MnemonicBuilder, Signer, SignerSync, }; -use foundry_common::types::{ToAlloy, ToEthers}; +use alloy_sol_types::SolValue; use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; +use k256::{ + ecdsa::SigningKey, + elliptic_curve::{sec1::ToEncodedPoint, Curve}, + Secp256k1, +}; use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; /// The BIP32 default derivation path prefix. @@ -51,9 +50,9 @@ impl Cheatcode for getNonce_1Call { } impl Cheatcode for sign_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_full(&self, _: &mut CheatsCtxt) -> Result { let Self { wallet, digest } = self; - sign(&wallet.privateKey, digest, ccx.data.env.cfg.chain_id) + sign(&wallet.privateKey, digest) } } @@ -88,10 +87,10 @@ impl Cheatcode for deriveKey_3Call { impl Cheatcode for rememberKeyCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; - let wallet = parse_wallet(privateKey)?.with_chain_id(ccx.data.env.cfg.chain_id); + let wallet = parse_wallet(privateKey)?.with_chain_id(Some(ccx.data.env.cfg.chain_id)); let address = wallet.address(); ccx.state.script_wallets.push(wallet); - Ok(address.to_alloy().abi_encode()) + Ok(address.abi_encode()) } } @@ -141,7 +140,7 @@ impl Cheatcode for computeCreate2Address_1Call { /// If 'label' is set to 'Some()', assign that label to the associated ETH address in state fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes) -> Result { let key = parse_private_key(private_key)?; - let addr = ethers_core::utils::secret_key_to_address(&key).to_alloy(); + let addr = alloy_signer::utils::secret_key_to_address(&key); let pub_key = key.verifying_key().as_affine().to_encoded_point(false); let pub_key_x = U256::from_be_bytes((*pub_key.x().unwrap()).into()); @@ -155,21 +154,20 @@ fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes .abi_encode()) } -pub(super) fn sign(private_key: &U256, digest: &B256, chain_id: u64) -> Result { - let wallet = parse_wallet(private_key)?.with_chain_id(chain_id); +pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { + // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. + let wallet = parse_wallet(private_key)?; - // The `ecrecover` precompile does not use EIP-155 - let sig = wallet.sign_hash(digest.to_ethers())?; - let recovered = sig.recover(digest.to_ethers())?.to_alloy(); + let sig = wallet.sign_hash_sync(*digest)?; + let recovered = sig.recover_address_from_prehash(digest)?; - assert_eq!(recovered, wallet.address().to_alloy()); + assert_eq!(recovered, wallet.address()); - let mut r_bytes = [0u8; 32]; - let mut s_bytes = [0u8; 32]; - sig.r.to_big_endian(&mut r_bytes); - sig.s.to_big_endian(&mut s_bytes); + let v = U256::from(sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte())); + let r = B256::from(sig.r()); + let s = B256::from(sig.s()); - Ok((sig.v, r_bytes, s_bytes).abi_encode()) + Ok((v, r, s).abi_encode()) } pub(super) fn sign_p256(private_key: &U256, digest: &B256, _state: &mut Cheatcodes) -> Result { @@ -231,7 +229,7 @@ fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { let wallet = MnemonicBuilder::::default() .phrase(mnemonic) - .derivation_path(&derive_key_path(path, index))? + .derivation_path(derive_key_path(path, index))? .build()?; let private_key = U256::from_be_bytes(wallet.signer().to_bytes().into()); Ok(private_key.abi_encode()) diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 0ad1d709e05ff..9ea7dd0fa51e5 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -25,6 +25,7 @@ alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true alloy-rpc-types.workspace = true +alloy-signer.workspace = true hashbrown = { version = "0.14", features = ["serde"] } revm = { workspace = true, default-features = false, features = [ "std", @@ -37,7 +38,6 @@ revm = { workspace = true, default-features = false, features = [ ] } revm-inspectors.workspace = true -ethers-signers.workspace = true itertools.workspace = true eyre = "0.6" diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index e8bcbaf879c11..092e0641e546e 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -12,7 +12,7 @@ use crate::inspectors::{ use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, Log, U256}; -use ethers_signers::LocalWallet; +use alloy_signer::LocalWallet; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; use foundry_evm_core::{ backend::{Backend, DatabaseError, DatabaseExt, DatabaseResult, FuzzBackendWrapper}, diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 48ac5a8df5ab0..6ece0f2da4ff9 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -3,7 +3,7 @@ use super::{ StackSnapshotType, TracePrinter, TracingInspector, TracingInspectorConfig, }; use alloy_primitives::{Address, Bytes, Log, B256, U256}; -use ethers_signers::LocalWallet; +use alloy_signer::LocalWallet; use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 4893c21fa9ea9..6afb1a4441b05 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -7,6 +7,7 @@ use forge::{ revm::interpreter::{return_ok, InstructionResult}, traces::{TraceKind, Traces}, }; +use foundry_common::types::ToEthers; /// Represents which simulation stage is the script execution at. pub enum SimulationStage { @@ -170,7 +171,7 @@ impl ScriptRunner { traces, debug, address: None, - script_wallets, + script_wallets: script_wallets.to_ethers(), ..Default::default() }, )) @@ -305,7 +306,7 @@ impl ScriptRunner { labeled_addresses: labels, transactions, address: None, - script_wallets, + script_wallets: script_wallets.to_ethers(), breakpoints, }) } From ae32c178152986e98372076d0c29c25a13d69b94 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 27 Jan 2024 13:56:26 +0100 Subject: [PATCH 0538/1963] chore: use EvmVersion::Cancun (#6906) * chore: deprecate cancun key * rustfmt * use const entries * Update crates/config/src/lib.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/config/src/lib.rs | 15 +++++++++------ crates/config/src/providers/mod.rs | 15 +++++++++++---- crates/config/src/utils.rs | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e174364f2a745..35dcea09248de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3106,9 +3106,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5409d75d032836be70c1786c20cd135e3c4ae21e397db97f2cd0a321d3e41c37" +checksum = "343530a6efe3786d26e1357f15605bb5cd28bd1133e6aab812126508a064bca7" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 11dd5a0e769b6..dc2cb823ade35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,7 +125,7 @@ foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.0", default-features = false } -foundry-compilers = { version = "0.2.2", default-features = false } +foundry-compilers = { version = "0.2.3", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 618f55a1e8632..66bc76991338c 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -25,7 +25,6 @@ use foundry_compilers::{ ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, SolcConfig, }; use inflector::Inflector; -use once_cell::sync::Lazy; use regex::Regex; use revm_primitives::SpecId; use semver::Version; @@ -36,6 +35,7 @@ use std::{ fs, path::{Path, PathBuf}, str::FromStr, + string::ToString, }; // Macros useful for creating a figment. @@ -396,11 +396,12 @@ pub struct Config { } /// Mapping of fallback standalone sections. See [`FallbackProfileProvider`] -pub static STANDALONE_FALLBACK_SECTIONS: Lazy> = - Lazy::new(|| HashMap::from([("invariant", "fuzz")])); +pub const STANDALONE_FALLBACK_SECTIONS: &[(&str, &str)] = &[("invariant", "fuzz")]; -/// Deprecated keys. -pub static DEPRECATIONS: Lazy> = Lazy::new(|| HashMap::from([])); +/// Deprecated keys and their replacements. +/// +/// See [Warning::DeprecatedKey] +pub const DEPRECATIONS: &[(&str, &str)] = &[("cancun", "evm_version = Cancun")]; impl Config { /// The default profile: "default" @@ -1534,7 +1535,9 @@ impl Config { } // merge special keys into config for standalone_key in Config::STANDALONE_SECTIONS { - if let Some(fallback) = STANDALONE_FALLBACK_SECTIONS.get(standalone_key) { + if let Some((_, fallback)) = + STANDALONE_FALLBACK_SECTIONS.iter().find(|(key, _)| standalone_key == key) + { figment = figment.merge( provider .fallback(standalone_key, fallback) diff --git a/crates/config/src/providers/mod.rs b/crates/config/src/providers/mod.rs index a7e567788ba2c..239ee0c74a36b 100644 --- a/crates/config/src/providers/mod.rs +++ b/crates/config/src/providers/mod.rs @@ -66,10 +66,17 @@ impl WarningsProvider

{ .unwrap_or_default() .iter() .flat_map(|(profile, dict)| dict.keys().map(move |key| format!("{profile}.{key}"))) - .filter(|k| DEPRECATIONS.contains_key(k)) - .map(|deprecated_key| Warning::DeprecatedKey { - old: deprecated_key.clone(), - new: DEPRECATIONS.get(&deprecated_key).unwrap().to_string(), + .filter_map(|key| { + DEPRECATIONS.iter().find_map(|(deprecated_key, new_value)| { + if key == *deprecated_key { + Some(Warning::DeprecatedKey { + old: deprecated_key.to_string(), + new: new_value.to_string(), + }) + } else { + None + } + }) }), ); Ok(out) diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index da067a1ed8cd0..d0d6f8e06663f 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -309,6 +309,7 @@ pub fn evm_spec_id(evm_version: &EvmVersion) -> SpecId { EvmVersion::London => SpecId::LONDON, EvmVersion::Paris => SpecId::MERGE, EvmVersion::Shanghai => SpecId::SHANGHAI, + EvmVersion::Cancun => SpecId::CANCUN, } } From 1839c72fbe1cfd178acf33178231e65ea63b0b70 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 27 Jan 2024 14:52:32 +0100 Subject: [PATCH 0539/1963] chore: solc 0.8.24 (#6916) * chore: solc 0.8.24 * Update crates/forge/tests/cli/svm.rs Co-authored-by: Enrique --------- Co-authored-by: Enrique --- Cargo.lock | 25 +++++++++++++++++++------ Cargo.toml | 2 +- crates/forge/tests/cli/svm.rs | 7 ++++--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35dcea09248de..286a7eb6769f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2614,7 +2614,7 @@ dependencies = [ "sha2 0.10.8", "solang-parser", "svm-rs", - "svm-rs-builds", + "svm-rs-builds 0.2.3", "tempfile", "thiserror", "tiny-keccak", @@ -3106,9 +3106,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343530a6efe3786d26e1357f15605bb5cd28bd1133e6aab812126508a064bca7" +checksum = "5106d26aa9a9955c852bed6f9d8994d7229a177969ae5a813008022b022f31ae" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3134,7 +3134,7 @@ dependencies = [ "sha2 0.10.8", "solang-parser", "svm-rs", - "svm-rs-builds", + "svm-rs-builds 0.3.5", "tempfile", "thiserror", "tiny-keccak", @@ -7197,9 +7197,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "svm-rs" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce290b5536ab2a42a61c9c6f22d6bfa8f26339c602aa62db4c978c95d1afc47" +checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" dependencies = [ "dirs 5.0.1", "fs2", @@ -7228,6 +7228,19 @@ dependencies = [ "svm-rs", ] +[[package]] +name = "svm-rs-builds" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8d3c94c4d3337336f58493471b98d712c267c66977b0fbe48efd6cbf69ffd0" +dependencies = [ + "build_const", + "hex", + "semver 1.0.21", + "serde_json", + "svm-rs", +] + [[package]] name = "syn" version = "1.0.109" diff --git a/Cargo.toml b/Cargo.toml index dc2cb823ade35..d379d9ceadcb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,7 +125,7 @@ foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.0", default-features = false } -foundry-compilers = { version = "0.2.3", default-features = false } +foundry-compilers = { version = "0.2.4", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 08df1e3f815a6..431a36a1c859f 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -8,9 +8,10 @@ use svm::Platform; /// Solc to Foundry release process: /// 1. new solc release /// 2. svm updated with all build info -/// 3. svm bumped in ethers-rs -/// 4. ethers bumped in foundry + update the `LATEST_SOLC` -const LATEST_SOLC: Version = Version::new(0, 8, 23); +/// 3. svm bumped in foundry-compilers +/// 4. foundry-compilers update with any breaking changes +/// 5. upgrade the `LATEST_SOLC` +const LATEST_SOLC: Version = Version::new(0, 8, 24); macro_rules! ensure_svm_releases { ($($test:ident => $platform:ident),* $(,)?) => {$( From 47e458b286781c8f2eb7ddff2a309b13e9eb8da4 Mon Sep 17 00:00:00 2001 From: Csongor Kiss Date: Sat, 27 Jan 2024 16:45:25 +0000 Subject: [PATCH 0540/1963] fix: print actual length in bytes in `trimmed_hex` (#6919) --- crates/evm/core/src/decode.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index ff28631fbeb20..d4b889779859e 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -124,11 +124,28 @@ pub fn maybe_decode_revert( } fn trimmed_hex(s: &[u8]) -> String { - let s = hex::encode(s); - let n = 32 * 2; + let n = 32; if s.len() <= n { - s + hex::encode(s) } else { - format!("{}…{} ({} bytes)", &s[..n / 2], &s[s.len() - n / 2..], s.len()) + format!( + "{}…{} ({} bytes)", + &hex::encode(&s[..n / 2]), + &hex::encode(&s[s.len() - n / 2..]), + s.len() + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn test_trimmed_hex() { + assert_eq!(trimmed_hex(&hex::decode("1234567890").unwrap()), "1234567890"); + assert_eq!( + trimmed_hex(&hex::decode("492077697368207275737420737570706F72746564206869676865722D6B696E646564207479706573").unwrap()), + "49207769736820727573742073757070…6865722d6b696e646564207479706573 (41 bytes)" + ); } } From e0db5f2d258bfe6ed16c46738a6ca81e081a941f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 27 Jan 2024 20:58:33 +0100 Subject: [PATCH 0541/1963] fix: improve compiler version check (#6920) --- crates/forge/bin/cmd/verify/etherscan/mod.rs | 29 ++++++----- crates/forge/tests/cli/verify.rs | 51 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 12 deletions(-) diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 60fdfa3103458..7bea01bb566f0 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -2,6 +2,7 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use crate::cmd::retry::RETRY_CHECK_ON_VERIFY; use alloy_json_abi::Function; use eyre::{eyre, Context, Result}; +use forge::hashbrown::HashSet; use foundry_block_explorers::{ errors::EtherscanError, utils::lookup_compiler_version, @@ -394,23 +395,27 @@ impl EtherscanVerificationProvider { "If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml" )?; let artifacts = entry.artifacts_versions().collect::>(); - if artifacts.len() == 1 { - let mut version = artifacts[0].0.to_owned(); - version.build = match RE_BUILD_COMMIT.captures(version.build.as_str()) { - Some(cap) => BuildMetadata::new(cap.name("commit").unwrap().as_str())?, - _ => BuildMetadata::EMPTY, - }; - return Ok(version) - } if artifacts.is_empty() { - warn!("No artifacts detected") - } else { - let versions = artifacts.iter().map(|a| a.0.to_string()).collect::>(); + eyre::bail!("No matching artifact found for {}", args.contract.name); + } + + // ensure we have a single version + let unique_versions = artifacts.iter().map(|a| a.0.to_string()).collect::>(); + if unique_versions.len() > 1 { + let versions = unique_versions.into_iter().collect::>(); warn!("Ambiguous compiler versions found in cache: {}", versions.join(", ")); + eyre::bail!("Compiler version has to be set in `foundry.toml`. If the project was not deployed with foundry, specify the version through `--compiler-version` flag.") } - eyre::bail!("Compiler version has to be set in `foundry.toml`. If the project was not deployed with foundry, specify the version through `--compiler-version` flag.") + // we have a unique version + let mut version = artifacts[0].0.clone(); + version.build = match RE_BUILD_COMMIT.captures(version.build.as_str()) { + Some(cap) => BuildMetadata::new(cap.name("commit").unwrap().as_str())?, + _ => BuildMetadata::EMPTY, + }; + + Ok(version) } /// Return the optional encoded constructor arguments. If the path to diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index c35640a147504..ffd245a4f4a79 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -39,12 +39,29 @@ function doStuff() external {} .unwrap(); } +fn add_single_verify_target_file(prj: &TestProject) { + let timestamp = utils::millis_since_epoch(); + let contract = format!( + r#" +contract Unique {{ + uint public _timestamp = {timestamp}; +}} +contract Verify is Unique {{ +function doStuff() external {{}} +}} +"# + ); + + prj.add_source("Verify.sol", &contract).unwrap(); +} + fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Result<()> { // give etherscan some time to verify the contract let retry = Retry::new(retries, Some(Duration::from_secs(30))); retry.run(|| -> eyre::Result<()> { let output = cmd.unchecked_output(); let out = String::from_utf8_lossy(&output.stdout); + println!("{}", out); if out.contains("Contract successfully verified") { return Ok(()) } @@ -75,6 +92,7 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te info.chain.to_string(), address, contract_path.to_string(), + "--etherscan-api-key".to_string(), info.etherscan.to_string(), "--verifier".to_string(), info.verifier.to_string(), @@ -114,6 +132,26 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te } } +/// Executes create --verify on the given chain +fn create_verify_on_chain(info: Option, prj: TestProject, mut cmd: TestCommand) { + // only execute if keys present + if let Some(info) = info { + println!("verifying on {}", info.chain); + add_single_verify_target_file(&prj); + + let contract_path = "src/Verify.sol:Verify"; + cmd.arg("create").args(info.create_args()).args([ + contract_path, + "--etherscan-api-key", + info.etherscan.as_str(), + "--verify", + ]); + + let out = cmd.stdout_lossy(); + assert!(out.contains("Contract successfully verified"), "{}", out); + } +} + // tests `create && contract-verify && verify-check` on Fantom testnet if correct env vars are set forgetest!(can_verify_random_contract_fantom_testnet, |prj, cmd| { verify_on_chain(EnvExternalities::ftm_testnet(), prj, cmd); @@ -123,3 +161,16 @@ forgetest!(can_verify_random_contract_fantom_testnet, |prj, cmd| { forgetest!(can_verify_random_contract_optimism_kovan, |prj, cmd| { verify_on_chain(EnvExternalities::optimism_kovan(), prj, cmd); }); + +// tests `create && contract-verify && verify-check` on Sepolia testnet if correct env vars are set +forgetest!(can_verify_random_contract_sepolia, |prj, cmd| { + verify_on_chain(EnvExternalities::sepolia(), prj, cmd); +}); + +// tests `create --verify on Sepolia testnet if correct env vars are set +// SEPOLIA_RPC_URL=https://rpc.sepolia.org +// TEST_PRIVATE_KEY=0x... +// ETHERSCAN_API_KEY= +forgetest!(can_create_verify_random_contract_sepolia, |prj, cmd| { + create_verify_on_chain(EnvExternalities::sepolia(), prj, cmd); +}); From 2249e077b39dd27fe09f5192223383d4146a6852 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 27 Jan 2024 20:59:23 +0100 Subject: [PATCH 0542/1963] fix: ignore ETHERSCAN_API_KEY if empty (#6918) --- crates/cast/bin/cmd/storage.rs | 2 +- crates/cli/src/opts/ethereum.rs | 41 ++++++++++++++++---- crates/config/src/etherscan.rs | 3 ++ crates/config/src/lib.rs | 31 ++++++++++++++- crates/forge/bin/cmd/create.rs | 7 +--- crates/forge/bin/cmd/script/mod.rs | 4 +- crates/forge/bin/cmd/script/sequence.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 4 +- crates/forge/bin/cmd/verify/etherscan/mod.rs | 8 ++-- crates/forge/bin/cmd/verify/mod.rs | 6 +-- 10 files changed, 83 insertions(+), 25 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index d574883392ee0..b580d9a9d8352 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -115,7 +115,7 @@ impl StorageArgs { // Get code from Etherscan eprintln!("No matching artifacts found, fetching source code from Etherscan..."); - if self.etherscan.key.is_none() { + if !self.etherscan.has_key() { eyre::bail!("You must provide an Etherscan API key if you're fetching a remote contract's storage."); } diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 017e8098dd3c1..1d3474b1fe156 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -4,7 +4,7 @@ use eyre::Result; use foundry_config::{ figment::{ self, - value::{Dict, Map, Value}, + value::{Dict, Map}, Metadata, Profile, }, impl_figment_convert_cast, Chain, Config, @@ -117,16 +117,25 @@ impl figment::Provider for EtherscanOpts { } impl EtherscanOpts { - pub fn key<'a>(&'a self, config: Option<&'a Config>) -> Option> { - match (self.key.as_deref(), config) { - (Some(key), _) => Some(Cow::Borrowed(key)), - (None, Some(config)) => config.get_etherscan_api_key(self.chain).map(Cow::Owned), - (None, None) => None, - } + /// Returns true if the Etherscan API key is set. + pub fn has_key(&self) -> bool { + self.key.as_ref().filter(|key| !key.trim().is_empty()).is_some() + } + + /// Returns the Etherscan API key. + pub fn key(&self) -> Option { + self.key.as_ref().filter(|key| !key.trim().is_empty()).cloned() } pub fn dict(&self) -> Dict { - Value::serialize(self).unwrap().into_dict().unwrap() + let mut dict = Dict::new(); + if let Some(key) = self.key() { + dict.insert("etherscan_api_key".into(), key.into()); + } + if let Some(chain) = self.chain { + dict.insert("chain_id".into(), chain.to_string().into()); + } + dict } } @@ -168,3 +177,19 @@ impl figment::Provider for EthereumOpts { Ok(Map::from([(Config::selected_profile(), dict)])) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_etherscan_opts() { + let args: EtherscanOpts = + EtherscanOpts::parse_from(["foundry-cli", "--etherscan-api-key", "dummykey"]); + assert_eq!(args.key(), Some("dummykey".to_string())); + + let args: EtherscanOpts = + EtherscanOpts::parse_from(["foundry-cli", "--etherscan-api-key", ""]); + assert!(!args.has_key()); + } +} diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 5860fd7598e82..32d6648b80341 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -13,6 +13,9 @@ use std::{ time::Duration, }; +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct MaybeEtherscanApiKey(pub Option); + /// The user agent to use when querying the etherscan API. pub const ETHERSCAN_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 66bc76991338c..fc9ff98affadb 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1587,7 +1587,6 @@ impl From for Figment { .global(), ) .merge(DappEnvCompatProvider) - .merge(Env::raw().only(&["ETHERSCAN_API_KEY"])) .merge( Env::prefixed("FOUNDRY_") .ignore(&["PROFILE", "REMAPPINGS", "LIBRARIES", "FFI", "FS_PERMISSIONS"]) @@ -1605,6 +1604,15 @@ impl From for Figment { ) .select(profile.clone()); + // Ensure only non empty etherscan var is merged + // This prevents `ETHERSCAN_API_KEY=""` if it's set but empty + let env_provider = Env::raw().only(&["ETHERSCAN_API_KEY"]); + if let Some((key, value)) = env_provider.iter().next() { + if !value.trim().is_empty() { + figment = figment.merge((key.as_str(), value)); + } + } + // we try to merge remappings after we've merged all other providers, this prevents // redundant fs lookups to determine the default remappings that are eventually updated by // other providers, like the toml file @@ -4333,6 +4341,27 @@ mod tests { }); } + #[test] + fn test_etherscan_api_key() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r" + [default] + ", + )?; + jail.set_env("ETHERSCAN_API_KEY", ""); + let loaded = Config::load().sanitized(); + assert!(loaded.etherscan_api_key.is_none()); + + jail.set_env("ETHERSCAN_API_KEY", "DUMMY"); + let loaded = Config::load().sanitized(); + assert_eq!(loaded.etherscan_api_key, Some("DUMMY".into())); + + Ok(()) + }); + } + // a test to print the config, mainly used to update the example config in the README #[test] #[ignore] diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 57c12eef887ae..a6510e0ce1f17 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -176,10 +176,7 @@ impl CreateArgs { constructor_args, constructor_args_path: None, num_of_optimizations: None, - etherscan: EtherscanOpts { - key: self.eth.etherscan.key.clone(), - chain: Some(chain.into()), - }, + etherscan: EtherscanOpts { key: self.eth.etherscan.key(), chain: Some(chain.into()) }, flatten: false, force: false, skip_is_verified_check: true, @@ -327,7 +324,7 @@ impl CreateArgs { constructor_args, constructor_args_path: None, num_of_optimizations, - etherscan: EtherscanOpts { key: self.eth.etherscan.key, chain: Some(chain.into()) }, + etherscan: EtherscanOpts { key: self.eth.etherscan.key(), chain: Some(chain.into()) }, flatten: false, force: false, skip_is_verified_check: false, diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 245c59ad63ace..5ea7119a93ec7 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -565,7 +565,9 @@ impl Provider for ScriptArgs { fn data(&self) -> Result, figment::Error> { let mut dict = Dict::default(); - if let Some(ref etherscan_api_key) = self.etherscan_api_key { + if let Some(ref etherscan_api_key) = + self.etherscan_api_key.as_ref().filter(|s| !s.trim().is_empty()) + { dict.insert( "etherscan_api_key".to_string(), figment::value::Value::from(etherscan_api_key.to_string()), diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 5056fa9ec2967..b2b4c1abdbff8 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -270,7 +270,7 @@ impl ScriptSequence { verify.set_chain(config, self.chain.into()); - if verify.etherscan.key.is_some() || + if verify.etherscan.has_key() || verify.verifier.verifier != VerificationProviderType::Etherscan { trace!(target: "script", "prepare future verifications"); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index c54de4670cd20..bd8787bcd49e9 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -542,7 +542,9 @@ impl Provider for TestArgs { } dict.insert("fuzz".to_string(), fuzz_dict.into()); - if let Some(ref etherscan_api_key) = self.etherscan_api_key { + if let Some(etherscan_api_key) = + self.etherscan_api_key.as_ref().filter(|s| !s.trim().is_empty()) + { dict.insert("etherscan_api_key".to_string(), etherscan_api_key.to_string().into()); } diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 7bea01bb566f0..2304871941c5e 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -147,7 +147,7 @@ impl VerificationProvider for EtherscanVerificationProvider { let etherscan = self.client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), - args.etherscan.key.as_deref(), + args.etherscan.key().as_deref(), &config, )?; let retry: Retry = args.retry.into(); @@ -230,7 +230,7 @@ impl EtherscanVerificationProvider { let etherscan = self.client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), - args.etherscan.key.as_deref(), + args.etherscan.key().as_deref(), &config, )?; let verify_args = self.create_verify_request(args, Some(config)).await?; @@ -508,7 +508,7 @@ mod tests { .client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), - args.etherscan.key.as_deref(), + args.etherscan.key().as_deref(), &config, ) .unwrap(); @@ -535,7 +535,7 @@ mod tests { .client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), - args.etherscan.key.as_deref(), + args.etherscan.key().as_deref(), &config, ) .unwrap(); diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 53e411ac752bd..404ed2251b12d 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -157,7 +157,7 @@ impl VerifyArgs { let verifier_url = self.verifier.verifier_url.clone(); println!("Start verifying contract `{}` deployed on {chain}", self.address); - self.verifier.verifier.client(&self.etherscan.key)?.verify(self).await.map_err(|err| { + self.verifier.verifier.client(&self.etherscan.key())?.verify(self).await.map_err(|err| { if let Some(verifier_url) = verifier_url { match Url::parse(&verifier_url) { Ok(url) => { @@ -181,7 +181,7 @@ impl VerifyArgs { /// Returns the configured verification provider pub fn verification_provider(&self) -> Result> { - self.verifier.verifier.client(&self.etherscan.key) + self.verifier.verifier.client(&self.etherscan.key()) } } @@ -211,7 +211,7 @@ impl VerifyCheckArgs { /// Run the verify command to submit the contract's source code for verification on etherscan pub async fn run(self) -> Result<()> { println!("Checking verification status on {}", self.etherscan.chain.unwrap_or_default()); - self.verifier.verifier.client(&self.etherscan.key)?.check(self).await + self.verifier.verifier.client(&self.etherscan.key())?.check(self).await } } From 4a36f53ac0640b759e7768fedd8c11ef4ec133a0 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 27 Jan 2024 22:08:21 +0100 Subject: [PATCH 0543/1963] chore: rm unused type (#6921) --- crates/config/src/etherscan.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 32d6648b80341..5860fd7598e82 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -13,9 +13,6 @@ use std::{ time::Duration, }; -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct MaybeEtherscanApiKey(pub Option); - /// The user agent to use when querying the etherscan API. pub const ETHERSCAN_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); From 831fa5f4e08f4a7b5e7937d13e735c7b145950e0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:29:53 +0100 Subject: [PATCH 0544/1963] chore(deps): weekly `cargo update` (#6923) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating git repository `https://github.com/alloy-rs/alloy` Updating alloy-consensus v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-genesis v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-network v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-providers v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-pubsub v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-rpc-client v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-rpc-trace-types v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-rpc-types v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-signer v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-transport v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-transport-http v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-transport-ipc v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating alloy-transport-ws v0.1.0 (https://github.com/alloy-rs/alloy#5fa63d72) -> #53ef6c2d Updating auto_impl v1.1.0 -> v1.1.1 Updating bytemuck v1.14.0 -> v1.14.1 Updating chrono v0.4.32 -> v0.4.33 Updating foundry-block-explorers v0.2.1 -> v0.2.2 Updating k256 v0.13.1 -> v0.13.3 Updating libz-sys v1.1.14 -> v1.1.15 Updating memmap2 v0.9.3 -> v0.9.4 Updating pin-project v1.1.3 -> v1.1.4 Updating pin-project-internal v1.1.3 -> v1.1.4 Updating pulldown-cmark v0.9.3 -> v0.9.4 Updating regex-automata v0.4.4 -> v0.4.5 Updating revm v3.5.0 (https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041) -> #2caa13db Updating revm-interpreter v1.3.0 (https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041) -> #2caa13db Updating revm-precompile v2.2.0 (https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041) -> #2caa13db Updating revm-primitives v1.3.0 (https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041) -> #2caa13db Updating serde v1.0.195 -> v1.0.196 Updating serde_derive v1.0.195 -> v1.0.196 Updating serde_json v1.0.111 -> v1.0.112 Updating winnow v0.5.34 -> v0.5.35 Co-authored-by: mattsse --- Cargo.lock | 112 ++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 286a7eb6769f4..ed06ee544396c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -262,7 +262,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -279,7 +279,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -290,7 +290,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -303,7 +303,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-network", "alloy-primitives", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -380,7 +380,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -411,7 +411,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5fa63d7259351c0c5222095006a912a610e4e1e8" +source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -895,14 +895,14 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +checksum = "972d3215e2b5ab2408f98713bee04b8b8d2f915bfecfcb569e07a14edec1e1e1" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -1144,7 +1144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" dependencies = [ "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.5", "serde", ] @@ -1177,9 +1177,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" [[package]] name = "byteorder" @@ -1392,9 +1392,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", @@ -2953,9 +2953,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3388fca613939d3431dcf951a349753c00478bc839821ce1b0910563cce41a99" +checksum = "ebeafdc703baf5bb879b276653735cddb2e0244e5e59c24f3aeab5686d801006" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3121,7 +3121,7 @@ dependencies = [ "glob", "home", "md-5 0.10.6", - "memmap2 0.9.3", + "memmap2 0.9.4", "num_cpus", "once_cell", "path-slash", @@ -3815,7 +3815,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.4", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -4165,7 +4165,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.5", "same-file", "walkdir", "winapi-util", @@ -4428,9 +4428,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -4592,9 +4592,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.14" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "295c17e837573c8c821dbaeb3cceb3d745ad082f7572191409e69cbc1b3fd050" +checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" dependencies = [ "cc", "libc", @@ -4741,9 +4741,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] @@ -5568,18 +5568,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", @@ -5858,11 +5858,11 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +checksum = "b16a41fe73d9f20da4dae1440a2c4f23db602db9b4699b9b694f007c0a84f67d" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "memchr", "unicase", ] @@ -6058,7 +6058,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -6073,9 +6073,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -6147,7 +6147,7 @@ dependencies = [ [[package]] name = "revm" version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" dependencies = [ "auto_impl", "revm-interpreter", @@ -6172,7 +6172,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" dependencies = [ "revm-primitives", "serde", @@ -6181,7 +6181,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6197,7 +6197,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#e13f6041e2b4c0fca1028632a17d5a736212e6ec" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -6776,18 +6776,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -6807,9 +6807,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "4d1bd37ce2324cf3bf85e5a25f96eb4baf0d5aa6eba43e7ae8958870c4ec48ed" dependencies = [ "indexmap", "itoa", @@ -8493,9 +8493,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" dependencies = [ "memchr", ] From 7147485cf2845633f9b21b6c70da7bfb2724f541 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 28 Jan 2024 18:01:24 +0100 Subject: [PATCH 0545/1963] test: fix etherscan test args (#6929) --- crates/forge/tests/cli/verify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index ffd245a4f4a79..8874af9534e7c 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -123,7 +123,7 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te .arg(guid) .arg("--chain-id") .arg(info.chain.to_string()) - .arg("--etherscan-key") + .arg("--etherscan-api-key") .arg(info.etherscan) .arg("--verifier") .arg(info.verifier); From caef1360e29dfefb1723fa501f425e6f7824bf7f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 28 Jan 2024 18:42:18 +0100 Subject: [PATCH 0546/1963] make clippy happy (#6930) --- crates/test-utils/src/fd_lock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/test-utils/src/fd_lock.rs b/crates/test-utils/src/fd_lock.rs index 222ac3cfbd88a..1c5a479cd5efd 100644 --- a/crates/test-utils/src/fd_lock.rs +++ b/crates/test-utils/src/fd_lock.rs @@ -13,7 +13,7 @@ pub fn new_lock(lock_path: impl AsRef) -> RwLock { fn new_lock(lock_path: &Path) -> RwLock { let lock_file = pretty_err( lock_path, - OpenOptions::new().read(true).write(true).create(true).open(lock_path), + OpenOptions::new().read(true).write(true).create(true).truncate(false).open(lock_path), ); RwLock::new(lock_file) } From 3de288ba3236a77d7af6b8ac3cf5d832ba70b90c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 29 Jan 2024 14:37:35 +0200 Subject: [PATCH 0547/1963] fix(`forge`): Small fix for `ProjectCompiler` (#6935) * Fix ProjectCompiler * fix doc --- crates/common/src/compile.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 1cc49e80e1405..86dd4edf6c278 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -132,10 +132,17 @@ impl ProjectCompiler { /// Compiles the project. pub fn compile(mut self, project: &Project) -> Result { + // TODO: Avoid process::exit + if !project.paths.has_input_files() && self.files.is_empty() { + println!("Nothing to compile"); + // nothing to do here + std::process::exit(0); + } + // Taking is fine since we don't need these in `compile_with`. let filter = std::mem::take(&mut self.filter); let files = std::mem::take(&mut self.files); - self.compile_with(project, || { + self.compile_with(|| { if !files.is_empty() { project.compile_files(files) } else if let Some(filter) = filter { @@ -155,20 +162,13 @@ impl ProjectCompiler { /// use foundry_common::compile::ProjectCompiler; /// let config = foundry_config::Config::load(); /// let prj = config.project().unwrap(); - /// ProjectCompiler::new().compile_with(&prj, || Ok(prj.compile()?)).unwrap(); + /// ProjectCompiler::new().compile_with(|| Ok(prj.compile()?)).unwrap(); /// ``` #[instrument(target = "forge::compile", skip_all)] - fn compile_with(self, project: &Project, f: F) -> Result + fn compile_with(self, f: F) -> Result where F: FnOnce() -> Result, { - // TODO: Avoid process::exit - if !project.paths.has_input_files() { - println!("Nothing to compile"); - // nothing to do here - std::process::exit(0); - } - let quiet = self.quiet.unwrap_or(false); let bail = self.bail.unwrap_or(true); #[allow(clippy::collapsible_else_if)] From 5c26704ff3109d9e79ecfbcd7d00424468d65bf9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 29 Jan 2024 14:39:07 +0100 Subject: [PATCH 0548/1963] fix: estimate gas if missing for eth_sendTransaction (#6934) * fix: estimate gas if missing for eth_sendTransaction * rm dbg --- crates/anvil/core/src/eth/transaction/mod.rs | 38 +++++++++++++++++++- crates/anvil/src/eth/api.rs | 19 ++++++++-- crates/anvil/src/eth/backend/executor.rs | 8 ++++- crates/anvil/tests/it/transaction.rs | 27 ++++++++++++++ 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index d3cf7aa7d82b1..5582ca80df340 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -9,7 +9,7 @@ use alloy_network::{Signed, Transaction, TxKind}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, B256, U128, U256, U64}; use alloy_rlp::{Decodable, Encodable}; use alloy_rpc_types::{ - request::TransactionRequest, AccessList, AccessListItem, CallRequest, + request::TransactionRequest, AccessList, AccessListItem, CallInput, CallRequest, Signature as RpcSignature, Transaction as RpcTransaction, }; use foundry_evm::traces::CallTraceNode; @@ -72,6 +72,42 @@ pub struct EthTransactionRequest { pub optimism_fields: Option, } +impl EthTransactionRequest { + pub fn into_call_request(self) -> CallRequest { + let Self { + from, + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + gas, + value, + data, + nonce, + chain_id, + access_list, + transaction_type, + optimism_fields: _, + } = self; + CallRequest { + from, + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + gas, + value, + input: CallInput::maybe_input(data), + nonce: nonce.map(|n| n.to()), + chain_id, + access_list: access_list.map(AccessList), + max_fee_per_blob_gas: None, + blob_versioned_hashes: None, + transaction_type: transaction_type.map(|ty| ty.to()), + } + } +} + #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index dffc035df634e..cb6c9d5b8b174 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -849,7 +849,7 @@ impl EthApi { /// Signs a transaction /// /// Handler for ETH RPC call: `eth_signTransaction` - pub async fn sign_transaction(&self, request: EthTransactionRequest) -> Result { + pub async fn sign_transaction(&self, mut request: EthTransactionRequest) -> Result { node_info!("eth_signTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { @@ -858,6 +858,13 @@ impl EthApi { let (nonce, _) = self.request_nonce(&request, from).await?; + if request.gas.is_none() { + // estimate if not provided + if let Ok(gas) = self.estimate_gas(request.clone().into_call_request(), None).await { + request.gas = Some(gas); + } + } + let request = self.build_typed_tx_request(request, nonce)?; let signer = self.get_signer(from).ok_or(BlockchainError::NoSignerAvailable)?; @@ -869,13 +876,21 @@ impl EthApi { /// Sends a transaction /// /// Handler for ETH RPC call: `eth_sendTransaction` - pub async fn send_transaction(&self, request: EthTransactionRequest) -> Result { + pub async fn send_transaction(&self, mut request: EthTransactionRequest) -> Result { node_info!("eth_sendTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) })?; let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; + + if request.gas.is_none() { + // estimate if not provided + if let Ok(gas) = self.estimate_gas(request.clone().into_call_request(), None).await { + request.gas = Some(gas); + } + } + let request = self.build_typed_tx_request(request, nonce)?; // if the sender is currently impersonated we need to "bypass" signing let pending_transaction = if self.is_impersonated(from) { diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 7e15c67abadc9..d4ba69264ab1f 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -27,6 +27,7 @@ use foundry_evm::{ use std::sync::Arc; /// Represents an executed transaction (transacted on the DB) +#[derive(Debug)] pub struct ExecutedTransaction { transaction: Arc, exit_reason: InstructionResult, @@ -142,8 +143,12 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' included.push(tx.transaction.clone()); tx } - TransactionExecutionOutcome::Exhausted(_) => continue, + TransactionExecutionOutcome::Exhausted(tx) => { + trace!(target: "backend", tx_gas_limit = %tx.pending_transaction.transaction.gas_limit(), ?tx, "block gas limit exhausting, skipping transaction"); + continue + } TransactionExecutionOutcome::Invalid(tx, _) => { + trace!(target: "backend", ?tx, "skipping invalid transaction"); invalid.push(tx); continue } @@ -221,6 +226,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' } /// Represents the result of a single transaction execution attempt +#[derive(Debug)] pub enum TransactionExecutionOutcome { /// Transaction successfully executed Executed(ExecutedTransaction), diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 9facf3dca9c4d..4e793964299b2 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -3,8 +3,10 @@ use crate::{ utils::{ethers_http_provider, ethers_ws_provider}, }; use alloy_primitives::U256 as rU256; +use alloy_rpc_types::BlockNumberOrTag; use alloy_signer::Signer as AlloySigner; use anvil::{spawn, Hardfork, NodeConfig}; +use anvil_core::eth::transaction::EthTransactionRequest; use ethers::{ abi::ethereum_types::BigEndianHash, prelude::{ @@ -1032,3 +1034,28 @@ async fn test_reject_eip1559_pre_london() { let greeting = greeter_contract.greet().call().await.unwrap(); assert_eq!("Hello World!", greeting); } + +// https://github.com/foundry-rs/foundry/issues/6931 +#[tokio::test(flavor = "multi_thread")] +async fn can_mine_multiple_in_block() { + let (api, _handle) = spawn(NodeConfig::test()).await; + + // disable auto mine + api.anvil_set_auto_mine(false).await.unwrap(); + + let tx = EthTransactionRequest { + from: Some("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266".parse().unwrap()), + ..Default::default() + }; + + // broadcast it via the eth_sendTransaction API + let first = api.send_transaction(tx.clone()).await.unwrap(); + let second = api.send_transaction(tx.clone()).await.unwrap(); + + api.anvil_mine(Some(rU256::from(1)), Some(rU256::ZERO)).await.unwrap(); + + let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + + let txs = block.transactions.hashes().copied().collect::>(); + assert_eq!(txs, vec![first, second]); +} From c3904f306139d642663fa812060c23140c1a4121 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 29 Jan 2024 19:51:26 +0100 Subject: [PATCH 0549/1963] chore: tweak `debug` config for all profiles (#6940) --- Cargo.toml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d379d9ceadcb2..8ab5b54c614ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,19 +35,20 @@ homepage = "https://github.com/foundry-rs/foundry" repository = "https://github.com/foundry-rs/foundry" exclude = ["benches/", "tests/", "test-data/", "testdata/"] +# Speed up compilation time for dev builds by reducing emitted debug info. +# NOTE: Debuggers may provide less useful information with this setting. +# Uncomment this section if you're using a debugger. [profile.dev] -# Disabling debug info speeds up builds a bunch, -# and we don't rely on it for debugging that much -debug = 0 +debug = 1 -# Speed up tests and dev build +# Speed up tests and dev build. [profile.dev.package] -# solc +# Solc and artifacts foundry-compilers.opt-level = 3 solang-parser.opt-level = 3 serde_json.opt-level = 3 -# evm +# EVM alloy-primitives.opt-level = 3 alloy-sol-types.opt-level = 3 hashbrown.opt-level = 3 @@ -67,11 +68,11 @@ scrypt.opt-level = 3 # forking axum.opt-level = 3 -# Local "release" mode, more optimized than dev but much faster to compile than release +# Local "release" mode, more optimized than dev but much faster to compile than release. [profile.local] inherits = "dev" opt-level = 1 -strip = true +strip = "debuginfo" panic = "abort" codegen-units = 16 @@ -83,15 +84,16 @@ strip = "none" panic = "unwind" incremental = false -# Optimized release profile +# Optimized release profile. [profile.release] opt-level = 3 +debug = "line-tables-only" lto = "fat" strip = "debuginfo" panic = "abort" codegen-units = 1 -# Override packages which aren't perf-sensitive for faster compilation speed +# Override packages which aren't perf-sensitive for faster compilation speed. [profile.release.package] mdbook.opt-level = 1 protobuf.opt-level = 1 From 3237a8b13f449faeb6acd9b0d1393154eafbcd05 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:35:33 +0100 Subject: [PATCH 0550/1963] fix(cast/call): remove --verbose, fix --debug (#6939) --- crates/cast/bin/cmd/call.rs | 25 +++++++------------------ crates/cli/src/utils/cmd.rs | 1 + crates/debugger/src/tui/mod.rs | 30 ++++++++++++++++++------------ 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 29c0d5f82061e..5845b721018b5 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -42,28 +42,18 @@ pub struct CallArgs { #[clap(long, default_value_t = false)] trace: bool, - /// Can only be used with "--trace" - /// - /// opens an interactive debugger + /// Opens an interactive debugger. + /// Can only be used with `--trace`. #[clap(long, requires = "trace")] debug: bool, - /// Can only be used with "--trace" - /// - /// prints a more verbose trace - #[clap(long, requires = "trace")] - verbose: bool, - - /// Can only be used with "--trace" - /// Labels to apply to the traces. - /// - /// Format: `address:label` + /// Labels to apply to the traces; format: `address:label`. + /// Can only be used with `--trace`. #[clap(long, requires = "trace")] labels: Vec, - /// Can only be used with "--trace" - /// /// The EVM Version to use. + /// Can only be used with `--trace`. #[clap(long, requires = "trace")] evm_version: Option, @@ -121,7 +111,6 @@ impl CallArgs { trace, evm_version, debug, - verbose, labels, } = self; @@ -165,7 +154,7 @@ impl CallArgs { Err(evm_err) => TraceResult::try_from(evm_err)?, }; - handle_traces(trace, &config, chain, labels, verbose).await?; + handle_traces(trace, &config, chain, labels, debug).await?; return Ok(()); } @@ -199,7 +188,7 @@ impl CallArgs { tx.value().copied().unwrap_or_default().to_alloy(), )?); - handle_traces(trace, &config, chain, labels, verbose).await?; + handle_traces(trace, &config, chain, labels, debug).await?; return Ok(()); } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index ecc937ae592aa..11d996af405d7 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -316,6 +316,7 @@ pub fn read_constructor_args_file(constructor_args_path: PathBuf) -> Result Result { + eyre::ensure!(!self.debug_arena.is_empty(), "debug arena is empty"); + let backend = CrosstermBackend::new(io::stdout()); - let mut terminal = Terminal::new(backend)?; - TerminalGuard::with(&mut terminal, |terminal| self.try_run_real(terminal)) + let terminal = Terminal::new(backend)?; + TerminalGuard::with(terminal, |terminal| self.try_run_real(terminal)) } #[instrument(target = "debugger", name = "run", skip_all, ret)] fn try_run_real(&mut self, terminal: &mut DebuggerTerminal) -> Result { // Create the context. let mut cx = DebuggerContext::new(self); + cx.init(); // Create an event listener in a different thread. @@ -115,8 +118,6 @@ impl Debugger { .spawn(move || Self::event_listener(tx)) .expect("failed to spawn thread"); - eyre::ensure!(!cx.debug_arena().is_empty(), "debug arena is empty"); - // Draw the initial state. cx.draw(terminal)?; @@ -158,16 +159,16 @@ type PanicHandler = Box) + 'static + Sync + Se /// Handles terminal state. #[must_use] -struct TerminalGuard<'a, B: Backend + io::Write> { - terminal: &'a mut Terminal, +struct TerminalGuard { + terminal: Terminal, hook: Option>, } -impl<'a, B: Backend + io::Write> TerminalGuard<'a, B> { - fn with(terminal: &'a mut Terminal, mut f: impl FnMut(&mut Terminal) -> T) -> T { +impl TerminalGuard { + fn with(terminal: Terminal, mut f: impl FnMut(&mut Terminal) -> T) -> T { let mut guard = Self { terminal, hook: None }; guard.setup(); - f(guard.terminal) + f(&mut guard.terminal) } fn setup(&mut self) { @@ -188,16 +189,21 @@ impl<'a, B: Backend + io::Write> TerminalGuard<'a, B> { fn restore(&mut self) { if !std::thread::panicking() { + // Drop the current hook to guarantee that `self.hook` is the only reference to it. let _ = std::panic::take_hook(); + // Restore the previous panic hook. let prev = self.hook.take().unwrap(); let prev = match Arc::try_unwrap(prev) { Ok(prev) => prev, - Err(_) => unreachable!(), + Err(_) => unreachable!("`self.hook` is not the only reference to the panic hook"), }; std::panic::set_hook(prev); + + // NOTE: Our panic handler calls this function, so we only have to call it here if we're + // not panicking. + Self::half_restore(self.terminal.backend_mut()); } - Self::half_restore(self.terminal.backend_mut()); let _ = self.terminal.show_cursor(); } @@ -207,7 +213,7 @@ impl<'a, B: Backend + io::Write> TerminalGuard<'a, B> { } } -impl Drop for TerminalGuard<'_, B> { +impl Drop for TerminalGuard { #[inline] fn drop(&mut self) { self.restore(); From bf3b4b0e41299bbf6bb35e42c69c0587d745c2cd Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Mon, 29 Jan 2024 15:58:07 -0800 Subject: [PATCH 0551/1963] chore: add funding.json for receiving drips --- FUNDING.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 FUNDING.json diff --git a/FUNDING.json b/FUNDING.json new file mode 100644 index 0000000000000..52baedf3bfc3c --- /dev/null +++ b/FUNDING.json @@ -0,0 +1,7 @@ +{ + "drips": { + "ethereum": { + "ownedBy": "0x86308c59a6005d012C51Eef104bBc21786aC5D2E" + } + } +} From 56e95834a962209dcee81ca549f39627cfae870d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:39:59 +0100 Subject: [PATCH 0552/1963] refactor: TransactionWithMetadata decode fns (#6945) --- crates/forge/bin/cmd/script/transaction.rs | 152 +++++++++------------ 1 file changed, 68 insertions(+), 84 deletions(-) diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 5a446648c1acf..4568ad357cbcd 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -1,6 +1,5 @@ use super::{artifacts::ArtifactInfo, ScriptResult}; use alloy_dyn_abi::JsonAbiExt; -use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, B256}; use alloy_rpc_types::request::TransactionRequest; use ethers_core::types::{ @@ -15,6 +14,7 @@ use foundry_common::{ SELECTOR_LEN, }; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; +use itertools::Itertools; use revm_inspectors::tracing::types::CallKind; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -146,57 +146,44 @@ impl TransactionWithMetadata { self.opcode = CallKind::Create; } - self.contract_name = contracts.get(&address).map(|info| info.contract_name.clone()); + let info = contracts.get(&address); + self.contract_name = info.map(|info| info.contract_name.clone()); self.contract_address = Some(address); - if let Some(data) = self.transaction.data() { - if let Some(info) = contracts.get(&address) { - // constructor args are postfixed to creation code - // and create2 transactions are prefixed by 32 byte salt - let contains_constructor_args = if is_create2 { - data.len() - 32 > info.code.len() - } else { - data.len() > info.code.len() - }; - - if contains_constructor_args { - if let Some(constructor) = info.abi.constructor() { - let creation_code = if is_create2 { &data[32..] } else { data }; - - let on_err = || { - let inputs = constructor - .inputs - .iter() - .map(|p| p.ty.clone()) - .collect::>() - .join(","); - let signature = format!("constructor({inputs})"); - let bytecode = hex::encode(creation_code); - (signature, bytecode) - }; - - // the constructor args start after bytecode - let constructor_args = &creation_code[info.code.len()..]; - - let constructor_fn = Function { - name: "constructor".to_string(), - inputs: constructor.inputs.clone(), - outputs: vec![], - state_mutability: constructor.state_mutability, - }; - - if let Ok(arguments) = - constructor_fn.abi_decode_input(constructor_args, false) - { - self.arguments = Some(arguments.iter().map(format_token_raw).collect()); - } else { - let (signature, bytecode) = on_err(); - error!(constructor=?signature, contract=?self.contract_name, bytecode, "Failed to decode constructor arguments") - }; - } - } + let Some(data) = self.transaction.data() else { return Ok(()) }; + let Some(info) = info else { return Ok(()) }; + + // `create2` transactions are prefixed by a 32 byte salt. + let creation_code = if is_create2 { + if data.len() < 32 { + return Ok(()) } + &data[32..] + } else { + data + }; + + // The constructor args start after bytecode. + let contains_constructor_args = creation_code.len() > info.code.len(); + if !contains_constructor_args { + return Ok(()); } + let constructor_args = &creation_code[info.code.len()..]; + + let Some(constructor) = info.abi.constructor() else { return Ok(()) }; + let values = constructor.abi_decode_input(constructor_args, false).map_err(|e| { + error!( + contract=?self.contract_name, + signature=%format!("constructor({})", constructor.inputs.iter().map(|p| &p.ty).format(",")), + is_create2, + constructor_args=%hex::encode(constructor_args), + "Failed to decode constructor arguments", + ); + debug!(full_data=%hex::encode(data), bytecode=%hex::encode(creation_code)); + e + })?; + self.arguments = Some(values.iter().map(format_token_raw).collect()); + Ok(()) } @@ -209,44 +196,41 @@ impl TransactionWithMetadata { ) -> Result<()> { self.opcode = CallKind::Call; - if let Some(data) = self.transaction.data() { - if data.0.len() >= SELECTOR_LEN { - if let Some(info) = local_contracts.get(&target) { - // This CALL is made to a local contract. - - self.contract_name = Some(info.contract_name.clone()); - if let Some(function) = info - .abi - .functions() - .find(|function| function.selector() == data.0[..SELECTOR_LEN]) - { - self.function = Some(function.signature()); - self.arguments = Some( - function - .abi_decode_input(&data.0[SELECTOR_LEN..], false) - .map(|tokens| tokens.iter().map(format_token_raw).collect())?, - ); - } - } else { - // This CALL is made to an external contract. We can only decode it, if it has - // been verified and identified by etherscan. - - if let Some(function) = - decoder.functions.get(&data.0[..SELECTOR_LEN]).and_then(|v| v.first()) - { - self.contract_name = decoder.contracts.get(&target).cloned(); - - self.function = Some(function.signature()); - self.arguments = Some( - function - .abi_decode_input(&data.0[SELECTOR_LEN..], false) - .map(|tokens| tokens.iter().map(format_token_raw).collect())?, - ); - } - } - self.contract_address = Some(target); + let Some(data) = self.transaction.data() else { return Ok(()) }; + if data.len() < SELECTOR_LEN { + return Ok(()); + } + let (selector, data) = data.split_at(SELECTOR_LEN); + + let function = if let Some(info) = local_contracts.get(&target) { + // This CALL is made to a local contract. + self.contract_name = Some(info.contract_name.clone()); + info.abi.functions().find(|function| function.selector() == selector) + } else { + // This CALL is made to an external contract; try to decode it from the given decoder. + decoder.functions.get(selector).and_then(|v| v.first()) + }; + if let Some(function) = function { + if self.contract_address.is_none() { + self.contract_name = decoder.contracts.get(&target).cloned(); } + + self.function = Some(function.signature()); + + let values = function.abi_decode_input(data, false).map_err(|e| { + error!( + contract=?self.contract_name, + signature=?function, + data=hex::encode(data), + "Failed to decode function arguments", + ); + e + })?; + self.arguments = Some(values.iter().map(format_token_raw).collect()); } + + self.contract_address = Some(target); + Ok(()) } From b40ae8b3c9c6038c1916b434d02b15cb2f31d550 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 30 Jan 2024 14:23:23 +0100 Subject: [PATCH 0553/1963] chore: uncap verification retries (#6956) --- crates/forge/bin/cmd/retry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/retry.rs b/crates/forge/bin/cmd/retry.rs index 8e536bb446603..45305288e89b5 100644 --- a/crates/forge/bin/cmd/retry.rs +++ b/crates/forge/bin/cmd/retry.rs @@ -15,7 +15,7 @@ pub struct RetryArgs { /// Number of attempts for retrying verification. #[clap( long, - value_parser = RangedU64ValueParser::::new().range(1..=10), + value_parser = RangedU64ValueParser::::new().range(1..), default_value = "5", )] pub retries: u32, From e5b872a2c7bf06b133c2dcc47115a33b416ebb07 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:37:18 +0100 Subject: [PATCH 0554/1963] chore: halve the size of GlobMatcher (#6952) --- crates/common/src/glob.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/common/src/glob.rs b/crates/common/src/glob.rs index e573104f67a55..d8907633c2fe2 100644 --- a/crates/common/src/glob.rs +++ b/crates/common/src/glob.rs @@ -24,13 +24,16 @@ pub fn expand_globs( /// to be compiled when the filter functions `TestFilter` functions are called. #[derive(Clone, Debug)] pub struct GlobMatcher { - /// The parsed glob - pub glob: globset::Glob, /// The compiled glob pub matcher: globset::GlobMatcher, } impl GlobMatcher { + /// Creates a new `GlobMatcher` from a `globset::Glob`. + pub fn new(glob: globset::Glob) -> Self { + Self { matcher: glob.compile_matcher() } + } + /// Tests whether the given path matches this pattern or not. /// /// The glob `./test/*` won't match absolute paths like `test/Contract.sol`, which is common @@ -43,15 +46,20 @@ impl GlobMatcher { matches } + /// Returns the `globset::Glob`. + pub fn glob(&self) -> &globset::Glob { + self.matcher.glob() + } + /// Returns the `Glob` string used to compile this matcher. pub fn as_str(&self) -> &str { - self.glob.glob() + self.glob().glob() } } impl fmt::Display for GlobMatcher { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.glob.fmt(f) + self.glob().fmt(f) } } @@ -59,16 +67,16 @@ impl FromStr for GlobMatcher { type Err = globset::Error; fn from_str(s: &str) -> Result { - s.parse::().map(Into::into) + s.parse::().map(Self::new) } } impl From for GlobMatcher { fn from(glob: globset::Glob) -> Self { - let matcher = glob.compile_matcher(); - Self { glob, matcher } + Self::new(glob) } } + #[cfg(test)] mod tests { use super::*; From 725c9a95b1331c67b55facd4da1598cbc8e03112 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:37:29 +0100 Subject: [PATCH 0555/1963] chore: only use a compiler filter if not empty (#6954) --- crates/common/src/compile.rs | 80 ++++++++++++++---------- crates/common/src/glob.rs | 18 +++--- crates/forge/bin/cmd/build.rs | 14 +++-- crates/forge/bin/cmd/test/filter.rs | 94 +++++++++++++++-------------- crates/forge/bin/cmd/test/mod.rs | 12 ++-- 5 files changed, 125 insertions(+), 93 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 86dd4edf6c278..eccea208cd043 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -378,7 +378,10 @@ pub fn compile_target_with_filter( let graph = Graph::resolve(&project.paths)?; // Checking if it's a standalone script, or part of a project. - let mut compiler = ProjectCompiler::new().filter(Box::new(SkipBuildFilters(skip))).quiet(quiet); + let mut compiler = ProjectCompiler::new().quiet(quiet); + if !skip.is_empty() { + compiler = compiler.filter(Box::new(SkipBuildFilters::new(skip)?)); + } if !graph.files().contains_key(target_path) { if verify { eyre::bail!("You can only verify deployments from inside a project! Make sure it exists with `forge tree`."); @@ -469,13 +472,20 @@ pub fn etherscan_project(metadata: &Metadata, target_path: impl AsRef) -> } /// Bundles multiple `SkipBuildFilter` into a single `FileFilter` -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct SkipBuildFilters(pub Vec); +#[derive(Clone, Debug)] +pub struct SkipBuildFilters(Vec); impl FileFilter for SkipBuildFilters { /// Only returns a match if _no_ exclusion filter matches fn is_match(&self, file: &Path) -> bool { - self.0.iter().all(|filter| filter.is_match(file)) + self.0.iter().all(|matcher| is_match_exclude(matcher, file)) + } +} + +impl SkipBuildFilters { + /// Creates a new `SkipBuildFilters` from multiple `SkipBuildFilter`. + pub fn new(matchers: impl IntoIterator) -> Result { + matchers.into_iter().map(|m| m.compile()).collect::>().map(Self) } } @@ -491,6 +501,14 @@ pub enum SkipBuildFilter { } impl SkipBuildFilter { + fn new(s: &str) -> Self { + match s { + "test" | "tests" => SkipBuildFilter::Tests, + "script" | "scripts" => SkipBuildFilter::Scripts, + s => SkipBuildFilter::Custom(s.to_string()), + } + } + /// Returns the pattern to match against a file fn file_pattern(&self) -> &str { match self { @@ -499,15 +517,9 @@ impl SkipBuildFilter { SkipBuildFilter::Custom(s) => s.as_str(), } } -} -impl> From for SkipBuildFilter { - fn from(s: T) -> Self { - match s.as_ref() { - "test" | "tests" => SkipBuildFilter::Tests, - "script" | "scripts" => SkipBuildFilter::Scripts, - s => SkipBuildFilter::Custom(s.to_string()), - } + fn compile(&self) -> Result { + self.file_pattern().parse().map_err(Into::into) } } @@ -515,23 +527,20 @@ impl FromStr for SkipBuildFilter { type Err = Infallible; fn from_str(s: &str) -> result::Result { - Ok(s.into()) + Ok(Self::new(s)) } } -impl FileFilter for SkipBuildFilter { - /// Matches file only if the filter does not apply - /// - /// This is returns the inverse of `file.name.contains(pattern) || matcher.is_match(file)` - fn is_match(&self, file: &Path) -> bool { - fn exclude(file: &Path, pattern: &str) -> Option { - let matcher: GlobMatcher = pattern.parse().unwrap(); - let file_name = file.file_name()?.to_str()?; - Some(file_name.contains(pattern) || matcher.is_match(file.as_os_str().to_str()?)) - } - - !exclude(file, self.file_pattern()).unwrap_or_default() +/// Matches file only if the filter does not apply. +/// +/// This returns the inverse of `file.name.contains(pattern) || matcher.is_match(file)`. +fn is_match_exclude(matcher: &GlobMatcher, path: &Path) -> bool { + fn is_match(matcher: &GlobMatcher, path: &Path) -> Option { + let file_name = path.file_name()?.to_str()?; + Some(file_name.contains(matcher.as_str()) || matcher.is_match(path)) } + + !is_match(matcher, path).unwrap_or_default() } #[cfg(test)] @@ -540,19 +549,24 @@ mod tests { #[test] fn test_build_filter() { + let tests = SkipBuildFilter::Tests.compile().unwrap(); + let scripts = SkipBuildFilter::Scripts.compile().unwrap(); + let custom = |s: &str| SkipBuildFilter::Custom(s.to_string()).compile().unwrap(); + let file = Path::new("A.t.sol"); - assert!(!SkipBuildFilter::Tests.is_match(file)); - assert!(SkipBuildFilter::Scripts.is_match(file)); - assert!(!SkipBuildFilter::Custom("A.t".to_string()).is_match(file)); + assert!(!is_match_exclude(&tests, file)); + assert!(is_match_exclude(&scripts, file)); + assert!(!is_match_exclude(&custom("A.t"), file)); let file = Path::new("A.s.sol"); - assert!(SkipBuildFilter::Tests.is_match(file)); - assert!(!SkipBuildFilter::Scripts.is_match(file)); - assert!(!SkipBuildFilter::Custom("A.s".to_string()).is_match(file)); + assert!(is_match_exclude(&tests, file)); + assert!(!is_match_exclude(&scripts, file)); + assert!(!is_match_exclude(&custom("A.s"), file)); let file = Path::new("/home/test/Foo.sol"); - assert!(!SkipBuildFilter::Custom("*/test/**".to_string()).is_match(file)); + assert!(!is_match_exclude(&custom("*/test/**"), file)); + let file = Path::new("/home/script/Contract.sol"); - assert!(!SkipBuildFilter::Custom("*/script/**".to_string()).is_match(file)); + assert!(!is_match_exclude(&custom("*/script/**"), file)); } } diff --git a/crates/common/src/glob.rs b/crates/common/src/glob.rs index d8907633c2fe2..070f703675fd8 100644 --- a/crates/common/src/glob.rs +++ b/crates/common/src/glob.rs @@ -38,12 +38,16 @@ impl GlobMatcher { /// /// The glob `./test/*` won't match absolute paths like `test/Contract.sol`, which is common /// format here, so we also handle this case here - pub fn is_match(&self, path: &str) -> bool { - let mut matches = self.matcher.is_match(path); - if !matches && !path.starts_with("./") && self.as_str().starts_with("./") { - matches = self.matcher.is_match(format!("./{path}")); + pub fn is_match(&self, path: &Path) -> bool { + if self.matcher.is_match(path) { + return true; } - matches + + if !path.starts_with("./") && self.as_str().starts_with("./") { + return self.matcher.is_match(format!("./{}", path.display())); + } + + false } /// Returns the `globset::Glob`. @@ -84,7 +88,7 @@ mod tests { #[test] fn can_match_glob_paths() { let matcher: GlobMatcher = "./test/*".parse().unwrap(); - assert!(matcher.is_match("test/Contract.sol")); - assert!(matcher.is_match("./test/Contract.sol")); + assert!(matcher.is_match(Path::new("test/Contract.sol"))); + assert!(matcher.is_match(Path::new("./test/Contract.sol"))); } } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 839f5a504f19c..a24f84b6925db 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -87,16 +87,22 @@ impl BuildArgs { project = config.project()?; } - let output = ProjectCompiler::new() + let mut compiler = ProjectCompiler::new() .print_names(self.names) .print_sizes(self.sizes) .quiet(self.format_json) - .bail(!self.format_json) - .filter(Box::new(SkipBuildFilters(self.skip.unwrap_or_default()))) - .compile(&project)?; + .bail(!self.format_json); + if let Some(skip) = self.skip { + if !skip.is_empty() { + compiler = compiler.filter(Box::new(SkipBuildFilters::new(skip)?)); + } + } + let output = compiler.compile(&project)?; + if self.format_json { println!("{}", serde_json::to_string_pretty(&output.clone().output())?); } + Ok(output) } diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index 71abb41b0039e..81497ca14fe14 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -43,29 +43,37 @@ pub struct FilterArgs { } impl FilterArgs { + /// Returns true if the filter is empty. + pub fn is_empty(&self) -> bool { + self.test_pattern.is_none() && + self.test_pattern_inverse.is_none() && + self.contract_pattern.is_none() && + self.contract_pattern_inverse.is_none() && + self.path_pattern.is_none() && + self.path_pattern_inverse.is_none() + } + /// Merges the set filter globs with the config's values - pub fn merge_with_config(&self, config: &Config) -> ProjectPathsAwareFilter { - let mut filter = self.clone(); - if filter.test_pattern.is_none() { - filter.test_pattern = config.test_pattern.clone().map(|p| p.into()); + pub fn merge_with_config(mut self, config: &Config) -> ProjectPathsAwareFilter { + if self.test_pattern.is_none() { + self.test_pattern = config.test_pattern.clone().map(Into::into); } - if filter.test_pattern_inverse.is_none() { - filter.test_pattern_inverse = config.test_pattern_inverse.clone().map(|p| p.into()); + if self.test_pattern_inverse.is_none() { + self.test_pattern_inverse = config.test_pattern_inverse.clone().map(Into::into); } - if filter.contract_pattern.is_none() { - filter.contract_pattern = config.contract_pattern.clone().map(|p| p.into()); + if self.contract_pattern.is_none() { + self.contract_pattern = config.contract_pattern.clone().map(Into::into); } - if filter.contract_pattern_inverse.is_none() { - filter.contract_pattern_inverse = - config.contract_pattern_inverse.clone().map(|p| p.into()); + if self.contract_pattern_inverse.is_none() { + self.contract_pattern_inverse = config.contract_pattern_inverse.clone().map(Into::into); } - if filter.path_pattern.is_none() { - filter.path_pattern = config.path_pattern.clone().map(Into::into); + if self.path_pattern.is_none() { + self.path_pattern = config.path_pattern.clone().map(Into::into); } - if filter.path_pattern_inverse.is_none() { - filter.path_pattern_inverse = config.path_pattern_inverse.clone().map(Into::into); + if self.path_pattern_inverse.is_none() { + self.path_pattern_inverse = config.path_pattern_inverse.clone().map(Into::into); } - ProjectPathsAwareFilter { args_filter: filter, paths: config.project_paths() } + ProjectPathsAwareFilter { args_filter: self, paths: config.project_paths() } } } @@ -86,15 +94,13 @@ impl FileFilter for FilterArgs { /// Returns true if the file regex pattern match the `file` /// /// If no file regex is set this returns true if the file ends with `.t.sol`, see - /// [FoundryPathExr::is_sol_test()] + /// [`FoundryPathExt::is_sol_test()`]. fn is_match(&self, file: &Path) -> bool { - if let Some(file) = file.as_os_str().to_str() { - if let Some(ref glob) = self.path_pattern { - return glob.is_match(file) - } - if let Some(ref glob) = self.path_pattern_inverse { - return !glob.is_match(file) - } + if let Some(glob) = &self.path_pattern { + return glob.is_match(file) + } + if let Some(glob) = &self.path_pattern_inverse { + return !glob.is_match(file) } file.is_sol_test() } @@ -124,10 +130,6 @@ impl TestFilter for FilterArgs { } fn matches_path(&self, path: &Path) -> bool { - let Some(path) = path.to_str() else { - return false; - }; - let mut ok = true; if let Some(re) = &self.path_pattern { ok = ok && re.is_match(path); @@ -141,26 +143,25 @@ impl TestFilter for FilterArgs { impl fmt::Display for FilterArgs { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut patterns = Vec::new(); - if let Some(ref p) = self.test_pattern { - patterns.push(format!("\tmatch-test: `{}`", p.as_str())); + if let Some(p) = &self.test_pattern { + writeln!(f, "\tmatch-test: `{}`", p.as_str())?; } - if let Some(ref p) = self.test_pattern_inverse { - patterns.push(format!("\tno-match-test: `{}`", p.as_str())); + if let Some(p) = &self.test_pattern_inverse { + writeln!(f, "\tno-match-test: `{}`", p.as_str())?; } - if let Some(ref p) = self.contract_pattern { - patterns.push(format!("\tmatch-contract: `{}`", p.as_str())); + if let Some(p) = &self.contract_pattern { + writeln!(f, "\tmatch-contract: `{}`", p.as_str())?; } - if let Some(ref p) = self.contract_pattern_inverse { - patterns.push(format!("\tno-match-contract: `{}`", p.as_str())); + if let Some(p) = &self.contract_pattern_inverse { + writeln!(f, "\tno-match-contract: `{}`", p.as_str())?; } - if let Some(ref p) = self.path_pattern { - patterns.push(format!("\tmatch-path: `{}`", p.as_str())); + if let Some(p) = &self.path_pattern { + writeln!(f, "\tmatch-path: `{}`", p.as_str())?; } - if let Some(ref p) = self.path_pattern_inverse { - patterns.push(format!("\tno-match-path: `{}`", p.as_str())); + if let Some(p) = &self.path_pattern_inverse { + writeln!(f, "\tno-match-path: `{}`", p.as_str())?; } - write!(f, "{}", patterns.join("\n")) + Ok(()) } } @@ -174,12 +175,17 @@ pub struct ProjectPathsAwareFilter { // === impl ProjectPathsAwareFilter === impl ProjectPathsAwareFilter { - /// Returns the CLI arguments + /// Returns true if the filter is empty. + pub fn is_empty(&self) -> bool { + self.args_filter.is_empty() + } + + /// Returns the CLI arguments. pub fn args(&self) -> &FilterArgs { &self.args_filter } - /// Returns the CLI arguments mutably + /// Returns the CLI arguments mutably. pub fn args_mut(&mut self) -> &mut FilterArgs { &mut self.args_filter } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index bd8787bcd49e9..8fe5966faa472 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -319,14 +319,16 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); if runner.matching_test_function_count(filter) == 0 { - let filter_str = filter.to_string(); - if filter_str.is_empty() { + println!(); + if filter.is_empty() { println!( - "\nNo tests found in project! \ + "No tests found in project! \ Forge looks for functions that starts with `test`." ); } else { - println!("\nNo tests match the provided pattern:\n{filter_str}"); + println!("No tests match the provided pattern:"); + print!("{filter}"); + // Try to suggest a test when there's no match if let Some(test_pattern) = &filter.args().test_pattern { let test_name = test_pattern.as_str(); @@ -507,7 +509,7 @@ impl TestArgs { /// Returns the flattened [`FilterArgs`] arguments merged with [`Config`]. pub fn filter(&self, config: &Config) -> ProjectPathsAwareFilter { - self.filter.merge_with_config(config) + self.filter.clone().merge_with_config(config) } /// Returns whether `BuildArgs` was configured with `--watch` From 43b9017c547c4620e8ae3618ffb709fb9cfe7794 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 30 Jan 2024 09:46:07 -0400 Subject: [PATCH 0556/1963] chore: remove unneeded ethers deps from anvil (#6957) --- Cargo.lock | 3 --- crates/anvil/core/Cargo.toml | 4 ---- 2 files changed, 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed06ee544396c..a51c4e0d343f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -582,9 +582,6 @@ dependencies = [ "alloy-rpc-types", "anvil-core", "bytes", - "ethers-contract", - "ethers-middleware", - "ethers-providers", "foundry-common", "foundry-evm", "hash-db", diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 5919c0d7d4177..3b164a9d81207 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -22,10 +22,6 @@ alloy-eips.workspace = true alloy-network = { workspace = true, features = ["k256"] } alloy-consensus.workspace = true alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } -# theses are not used by anvil-core, but are required by ethers, because pulled in via foundry-common -ethers-contract = { workspace = true, features = ["optimism"] } -ethers-providers = { workspace = true, features = ["optimism"] } -ethers-middleware = { workspace = true, features = ["optimism"] } serde = { workspace = true, optional = true } serde_json.workspace = true From 74938a0fdbdfefdcb442290b23d1d9620134c9ac Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 30 Jan 2024 22:12:38 +0100 Subject: [PATCH 0557/1963] ci: update actions/github-script (#6962) --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3934a8970f992..2664f0369dcf4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,7 @@ jobs: # the changelog. - name: Create build-specific nightly tag if: ${{ env.IS_NIGHTLY }} - uses: actions/github-script@v6 + uses: actions/github-script@v7 env: TAG_NAME: ${{ steps.release_info.outputs.tag_name }} with: @@ -221,14 +221,14 @@ jobs: # Moves the `nightly` tag to `HEAD` - name: Move nightly tag if: ${{ env.IS_NIGHTLY }} - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const moveTag = require('./.github/scripts/move-tag.js') await moveTag({ github, context }, 'nightly') - name: Delete old nightlies - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const prunePrereleases = require('./.github/scripts/prune-prereleases.js') From b78289a0bc9df6e35624c632396e16f27d4ccb3f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 30 Jan 2024 23:30:12 +0100 Subject: [PATCH 0558/1963] feat: add asm-keccak feature (#6941) --- .github/workflows/release.yml | 13 +++++++++---- crates/anvil/Cargo.toml | 1 + crates/cast/Cargo.toml | 1 + crates/chisel/Cargo.toml | 1 + crates/forge/Cargo.toml | 17 ++++------------- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2664f0369dcf4..fee941b987d3c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -130,11 +130,16 @@ jobs: env: SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} shell: bash - # Windows runs out of RAM when building binaries with LLVM run: | - flags=() - [[ "${{ matrix.target }}" == *windows* ]] && flags+=(-j1) - cargo build --release --bins --target ${{ matrix.target }} "${flags[@]}" + target="${{ matrix.target }}" + flags=() + + # `keccak-asm` does not support MSVC or aarch64 Linux. + [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]] && flags+=(--features=asm-keccak) + + # Windows runs out of RAM when building binaries with LLVM + [[ "$target" == *windows* ]] && flags+=(-j1) + cargo build --release --bins --target "${{ matrix.target }}" "${flags[@]}" - name: Archive binaries id: artifacts diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 3a3168ddf7237..21633df0c09ad 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -96,3 +96,4 @@ crc = "3.0.1" default = ["cli"] cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"] cli = ["tokio/full", "cmd", "fdlimit"] +asm-keccak = ["alloy-primitives/asm-keccak"] diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 5c6066592ac85..58c5786b38ca5 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -80,6 +80,7 @@ criterion = "0.5" default = ["rustls"] rustls = ["foundry-cli/rustls"] openssl = ["foundry-cli/openssl"] +asm-keccak = ["alloy-primitives/asm-keccak"] [[bench]] name = "vanity" diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index b5b3a2167c0e1..0fec11be95317 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -59,6 +59,7 @@ serial_test = "2" default = ["rustls"] rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-compilers/openssl", "reqwest/default-tls"] +asm-keccak = ["alloy-primitives/asm-keccak"] [[bench]] name = "session_source" diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 46d448a656019..ac120687da2fe 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,11 +15,7 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { version = "8", default-features = false, features = [ - "build", - "git", - "git2", -] } +vergen = { version = "8", default-features = false, features = ["build", "git", "git2"] } [dependencies] # lib @@ -96,20 +92,15 @@ paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true serial_test = "2" -svm = { package = "svm-rs", version = "0.3", default-features = false, features = [ - "rustls", -] } +svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } [features] default = ["rustls"] -rustls = [ - "foundry-cli/rustls", - "reqwest/rustls-tls", - "reqwest/rustls-tls-native-roots", -] +rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-cli/openssl", "reqwest/default-tls"] +asm-keccak = ["alloy-primitives/asm-keccak"] # feature for heavy (long-running) integration tests heavy-integration-tests = [] From b8b234df22a36c7c667d64bdf24dbd8666addd75 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 31 Jan 2024 19:25:58 +0100 Subject: [PATCH 0559/1963] chore: revert k256 bump (again) (#6969) --- Cargo.lock | 4 ++-- Cargo.toml | 4 +++- crates/forge/tests/it/repros.rs | 3 +++ testdata/repros/Issue6966.t.sol | 16 ++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 testdata/repros/Issue6966.t.sol diff --git a/Cargo.lock b/Cargo.lock index a51c4e0d343f1..c90fa32f91754 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4425,9 +4425,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", "ecdsa", diff --git a/Cargo.toml b/Cargo.toml index 8ab5b54c614ac..88ecea80484ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -190,7 +190,9 @@ toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" evm-disassembler = "0.4" -k256 = "0.13" +# TODO: bumping to >=0.13.2 breaks ecrecover: https://github.com/foundry-rs/foundry/pull/6969 +# TODO: unpin on next revm release: https://github.com/bluealloy/revm/pull/870 +k256 = "=0.13.1" axum = "0.6" hyper = "0.14" diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index d5dee2523e1e0..9c743a12c325b 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -297,3 +297,6 @@ test_repro!(6554; |config| { // https://github.com/foundry-rs/foundry/issues/6759 test_repro!(6759); + +// https://github.com/foundry-rs/foundry/issues/6966 +test_repro!(6966); diff --git a/testdata/repros/Issue6966.t.sol b/testdata/repros/Issue6966.t.sol new file mode 100644 index 0000000000000..f7a8db7000acb --- /dev/null +++ b/testdata/repros/Issue6966.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +// https://github.com/foundry-rs/foundry/issues/6966 +// See also https://github.com/RustCrypto/elliptic-curves/issues/988#issuecomment-1817681013 +contract Issue6966Test is DSTest { + function testEcrecover() public { + bytes32 h = 0x0000000000000000000000000000000000000000000000000000000000000000; + uint8 v = 27; + bytes32 r = bytes32(0xf87fff3202dfeae34ce9cb8151ce2e176bee02a937baac6de85c4ea03d6a6618); + bytes32 s = bytes32(0xedf9ab5c7d3ec1df1c2b48600ab0a35f586e069e9a69c6cdeebc99920128d1a5); + assert(ecrecover(h, v, r, s) != address(0)); + } +} From 1e8fb252f19b906d156f28421e79b8dfda5ed478 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 31 Jan 2024 19:29:03 +0100 Subject: [PATCH 0560/1963] ci: update runners (#6963) * ci: update runners * test binaries * disable debug info in ci * try j1 * j1 * larger runners * Revert "larger runners" This reverts commit 888d3492091e16cf736519c493a5c76a2dd7f5b7. * 2004 --- .github/workflows/release.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fee941b987d3c..e4051415a2fd9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -131,15 +131,30 @@ jobs: SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} shell: bash run: | + set -eo pipefail target="${{ matrix.target }}" flags=() + # TODO: default GHA runners run out of RAM when building with any debug info + flags+=(-j1) + # `keccak-asm` does not support MSVC or aarch64 Linux. [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]] && flags+=(--features=asm-keccak) # Windows runs out of RAM when building binaries with LLVM - [[ "$target" == *windows* ]] && flags+=(-j1) - cargo build --release --bins --target "${{ matrix.target }}" "${flags[@]}" + # [[ "$target" == *windows* ]] && flags+=(-j1) + + [[ "$target" == *windows* ]] && exe=".exe" + + cargo build --release --bins --target "$target" "${flags[@]}" + + bins=(anvil cast chisel forge) + for name in "${bins[@]}"; do + bin=./target/$target/release/$name$exe + file "$bin" || true + ldd "$bin" || true + $bin --version || true + done - name: Archive binaries id: artifacts From ceb739ac9e79f91b23ba3a3dfe1348569b1e16f2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 1 Feb 2024 00:04:46 +0100 Subject: [PATCH 0561/1963] chore: remove heavy integration tests (#6977) --- .config/nextest.toml | 4 -- .github/workflows/heavy-integration.yml | 59 --------------------- crates/forge/Cargo.toml | 3 -- crates/forge/tests/cli/heavy_integration.rs | 3 -- crates/forge/tests/cli/main.rs | 3 -- 5 files changed, 72 deletions(-) delete mode 100644 .github/workflows/heavy-integration.yml delete mode 100644 crates/forge/tests/cli/heavy_integration.rs diff --git a/.config/nextest.toml b/.config/nextest.toml index b471b448c2cc0..56f40c364142e 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -9,7 +9,3 @@ slow-timeout = { period = "5m", terminate-after = 4 } [[profile.default.overrides]] filter = "package(foundry-cheatcodes-spec)" retries = 0 - -[profile.heavy] -retries = 1 -slow-timeout = { period = "120m", terminate-after = 1 } diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml deleted file mode 100644 index 8583f7bae237a..0000000000000 --- a/.github/workflows/heavy-integration.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: heavy integration - -on: - schedule: - # Runs at 10PM utc - - cron: "0 22 * * *" - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - heavy-integration: - name: heavy (long-running) integration tests - runs-on: ubuntu-latest - timeout-minutes: 120 - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: taiki-e/install-action@nextest - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Forge RPC cache - uses: actions/cache@v3 - with: - path: | - ~/.foundry/cache - ~/.config/.foundry/cache - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - name: Force use of HTTPS for submodules - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - name: test - run: | - cargo nextest run --profile heavy -p forge \ - --test cli --features heavy-integration-tests -E "test(~heavy_integration)" - - # If any of the jobs fail, this will create a high-priority issue to signal so. - issue: - name: Open an issue - runs-on: ubuntu-latest - needs: heavy-integration - if: ${{ failure() }} - steps: - - uses: actions/checkout@v4 - - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_URL: | - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - with: - update_existing: true - filename: .github/INTEGRATION_FAILURE.md diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index ac120687da2fe..51b0777c05ebb 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -102,9 +102,6 @@ rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native openssl = ["foundry-cli/openssl", "reqwest/default-tls"] asm-keccak = ["alloy-primitives/asm-keccak"] -# feature for heavy (long-running) integration tests -heavy-integration-tests = [] - [[bench]] name = "test" harness = false diff --git a/crates/forge/tests/cli/heavy_integration.rs b/crates/forge/tests/cli/heavy_integration.rs deleted file mode 100644 index 1b21eb85f9ebb..0000000000000 --- a/crates/forge/tests/cli/heavy_integration.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Heavy integration tests that can take an hour to run or more. - -forgetest_external!(maple, "maple-labs/maple-core-v2"); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index d25297119e570..e9dab70f7d1ad 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -19,6 +19,3 @@ mod test_cmd; mod verify; mod ext_integration; - -#[cfg(feature = "heavy-integration-tests")] -mod heavy_integration; From 505ff79a869455ba203d451504f7209e5cef3390 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:10:07 +0100 Subject: [PATCH 0562/1963] chore: remove unnecessary to_vec (#6983) --- crates/evm/evm/src/executors/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 092e0641e546e..f3aae1330002a 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -225,7 +225,7 @@ impl Executor { abi: Option<&JsonAbi>, ) -> Result { let func = func.into(); - let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); + let calldata = Bytes::from(func.abi_encode_input(&args.into())?); let result = self.call_raw_committing(from, to, calldata, value)?; convert_call_result(abi, &func, result) } From 00cec1d2445ad9b8917a377cb6f9b755728eb9da Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 1 Feb 2024 12:50:21 +0100 Subject: [PATCH 0563/1963] fix: fix etherscan api parsing again (#6984) --- crates/cast/bin/cmd/storage.rs | 20 ++++++++++++++++++++ crates/config/src/etherscan.rs | 30 ++++++++++++++++++++++++++++++ crates/config/src/lib.rs | 33 ++++++++++++++++++++++++--------- 3 files changed, 74 insertions(+), 9 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index b580d9a9d8352..eb5b7cd4323f4 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -288,3 +288,23 @@ fn is_storage_layout_empty(storage_layout: &Option) -> bool { true } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_storage_etherscan_api_key() { + let args = + StorageArgs::parse_from(["foundry-cli", "addr", "--etherscan-api-key", "dummykey"]); + assert_eq!(args.etherscan.key(), Some("dummykey".to_string())); + + std::env::set_var("ETHERSCAN_API_KEY", "FXY"); + let config = Config::from(&args); + std::env::remove_var("ETHERSCAN_API_KEY"); + assert_eq!(config.etherscan_api_key, Some("dummykey".to_string())); + + let key = config.get_etherscan_api_key(None).unwrap(); + assert_eq!(key, "dummykey".to_string()); + } +} diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 5860fd7598e82..6e2030cb968b0 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -4,6 +4,11 @@ use crate::{ resolve::{interpolate, UnresolvedEnvVarError, RE_PLACEHOLDER}, Chain, Config, NamedChain, }; +use figment::{ + providers::Env, + value::{Dict, Map}, + Error, Metadata, Profile, Provider, +}; use inflector::Inflector; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{ @@ -16,6 +21,31 @@ use std::{ /// The user agent to use when querying the etherscan API. pub const ETHERSCAN_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); +/// A [Provider] that provides Etherscan API key from the environment if it's not empty. +/// +/// This prevents `ETHERSCAN_API_KEY=""` if it's set but empty +#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[non_exhaustive] +pub(crate) struct EtherscanEnvProvider; + +impl Provider for EtherscanEnvProvider { + fn metadata(&self) -> Metadata { + Env::raw().metadata() + } + + fn data(&self) -> Result, Error> { + let mut dict = Dict::default(); + let env_provider = Env::raw().only(&["ETHERSCAN_API_KEY"]); + if let Some((key, value)) = env_provider.iter().next() { + if !value.trim().is_empty() { + dict.insert(key.as_str().to_string(), value.into()); + } + } + + Ok(Map::from([(Config::selected_profile(), dict)])) + } +} + /// Errors that can occur when creating an `EtherscanConfig` #[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)] pub enum EtherscanConfigError { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index fc9ff98affadb..c10c41028c25a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -95,6 +95,7 @@ pub use invariant::InvariantConfig; use providers::remappings::RemappingsProvider; mod inline; +use crate::etherscan::EtherscanEnvProvider; pub use inline::{validate_profiles, InlineConfig, InlineConfigError, InlineConfigParser, NatSpec}; /// Foundry configuration @@ -1587,6 +1588,7 @@ impl From for Figment { .global(), ) .merge(DappEnvCompatProvider) + .merge(EtherscanEnvProvider::default()) .merge( Env::prefixed("FOUNDRY_") .ignore(&["PROFILE", "REMAPPINGS", "LIBRARIES", "FFI", "FS_PERMISSIONS"]) @@ -1604,15 +1606,6 @@ impl From for Figment { ) .select(profile.clone()); - // Ensure only non empty etherscan var is merged - // This prevents `ETHERSCAN_API_KEY=""` if it's set but empty - let env_provider = Env::raw().only(&["ETHERSCAN_API_KEY"]); - if let Some((key, value)) = env_provider.iter().next() { - if !value.trim().is_empty() { - figment = figment.merge((key.as_str(), value)); - } - } - // we try to merge remappings after we've merged all other providers, this prevents // redundant fs lookups to determine the default remappings that are eventually updated by // other providers, like the toml file @@ -4362,6 +4355,28 @@ mod tests { }); } + #[test] + fn test_etherscan_api_key_figment() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r" + [default] + etherscan_api_key = 'DUMMY' + ", + )?; + jail.set_env("ETHERSCAN_API_KEY", "ETHER"); + + let figment = Config::figment_with_root(jail.directory()) + .merge(("etherscan_api_key", "USER_KEY")); + + let loaded = Config::from_provider(figment); + assert_eq!(loaded.etherscan_api_key, Some("USER_KEY".into())); + + Ok(()) + }); + } + // a test to print the config, mainly used to update the example config in the README #[test] #[ignore] From 877ff2f7dcc295f55bcb299393b6cd7583f31ad3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 1 Feb 2024 14:31:57 +0100 Subject: [PATCH 0564/1963] ci: update runners (part 2) (#6972) --- .github/scripts/matrices.py | 22 +++++++++++----------- .github/workflows/docker-publish.yml | 2 +- .github/workflows/release.yml | 13 +++++-------- .github/workflows/test.yml | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 9cd1eb5ebfa3c..99fdc78e735ab 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -6,15 +6,15 @@ # A runner target class Target: - # GitHub runner OS - os_id: str + # GHA runner + runner_label: str # Rust target triple target: str # SVM Solc target svm_target_platform: str - def __init__(self, os_id: str, target: str, svm_target_platform: str): - self.os_id = os_id + def __init__(self, runner_label: str, target: str, svm_target_platform: str): + self.runner_label = runner_label self.target = target self.svm_target_platform = svm_target_platform @@ -42,7 +42,7 @@ def __init__( # GHA matrix entry class Expanded: name: str - os: str + runner_label: str target: str svm_target_platform: str flags: str @@ -51,14 +51,14 @@ class Expanded: def __init__( self, name: str, - os: str, + runner_label: str, target: str, svm_target_platform: str, flags: str, partition: int, ): self.name = name - self.os = os + self.runner_label = runner_label self.target = target self.svm_target_platform = svm_target_platform self.flags = flags @@ -66,10 +66,10 @@ def __init__( is_pr = os.environ.get("EVENT_NAME") == "pull_request" -t_linux_x86 = Target("ubuntu-latest", "x86_64-unknown-linux-gnu", "linux-amd64") +t_linux_x86 = Target("Linux-22.04", "x86_64-unknown-linux-gnu", "linux-amd64") # 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", "x86_64-apple-darwin", "macosx-amd64") +# t_linux_arm = Target("Linux-22.04", "aarch64-unknown-linux-gnu", "linux-aarch64") +t_macos = Target("macos-latest-large", "x86_64-apple-darwin", "macosx-amd64") 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] @@ -129,7 +129,7 @@ def main(): obj = Expanded( name=name, - os=target.os_id, + runner_label=target.runner_label, target=target.target, svm_target_platform=target.svm_target_platform, flags=flags, diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 835fa8b9c8ef6..a4d2543c20846 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -17,7 +17,7 @@ env: jobs: container: - runs-on: ubuntu-20.04 + runs-on: Linux-20.04 # https://docs.github.com/en/actions/reference/authentication-in-a-workflow permissions: id-token: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e4051415a2fd9..776c36e023144 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,22 +78,22 @@ jobs: # `target`: Rust build target triple # `platform` and `arch`: Used in tarball names # `svm`: target platform to use for the Solc binary: https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 - - os: ubuntu-20.04 + - os: Linux-20.04 target: x86_64-unknown-linux-gnu svm_target_platform: linux-amd64 platform: linux arch: amd64 - - os: ubuntu-20.04 + - os: Linux-20.04 target: aarch64-unknown-linux-gnu svm_target_platform: linux-aarch64 platform: linux arch: arm64 - - os: macos-latest + - os: macos-latest-large target: x86_64-apple-darwin svm_target_platform: macosx-amd64 platform: darwin arch: amd64 - - os: macos-latest + - os: macos-latest-large target: aarch64-apple-darwin svm_target_platform: macosx-aarch64 platform: darwin @@ -135,14 +135,11 @@ jobs: target="${{ matrix.target }}" flags=() - # TODO: default GHA runners run out of RAM when building with any debug info - flags+=(-j1) - # `keccak-asm` does not support MSVC or aarch64 Linux. [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]] && flags+=(--features=asm-keccak) # Windows runs out of RAM when building binaries with LLVM - # [[ "$target" == *windows* ]] && flags+=(-j1) + [[ "$target" == *windows* ]] && flags+=(-j1) [[ "$target" == *windows* ]] && exe=".exe" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d816ea2e5d376..842a9713c85c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: test: name: test ${{ matrix.name }} - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.runner_label }} timeout-minutes: 60 needs: matrices strategy: From 631ba73d15561b462035e7c0dd3b48af1a52ca7d Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Thu, 1 Feb 2024 19:56:05 +0300 Subject: [PATCH 0565/1963] foundry: `vm.dumpState` skips empty accounts (#6986) * foundry: `vm.dumpState` skips empty accounts Update `vm.dumpState` to also skip empty accounts. Empty accounts are not particularly useful and would otherwise require a postprocessing step after the state dump to remove. Adds a unit test showing that it works and updates an old unit test as an empty account is defined by a nonce of 0, no balance and no code. If there is storage, it still counts as an empty account. cargo fmt * testdata: cleanup --- crates/cheatcodes/src/evm.rs | 9 +++++---- testdata/cheats/dumpState.t.sol | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 5bd7750cfe290..41ae1e486049e 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -97,14 +97,15 @@ impl Cheatcode for dumpStateCall { let Self { pathToStateJson } = self; let path = Path::new(pathToStateJson); - // Do not include system accounts in the dump. - let skip = |key: &Address| { + // Do not include system account or empty accounts in the dump. + let skip = |key: &Address, val: &Account| { key == &CHEATCODE_ADDRESS || key == &CALLER || key == &HARDHAT_CONSOLE_ADDRESS || key == &TEST_CONTRACT_ADDRESS || key == &ccx.caller || - key == &ccx.state.config.evm_opts.sender + key == &ccx.state.config.evm_opts.sender || + val.is_empty() }; let alloc = ccx @@ -112,7 +113,7 @@ impl Cheatcode for dumpStateCall { .journaled_state .state() .into_iter() - .filter(|(key, _)| !skip(key)) + .filter(|(key, val)| !skip(key, val)) .map(|(key, val)| { ( key, diff --git a/testdata/cheats/dumpState.t.sol b/testdata/cheats/dumpState.t.sol index 51d6eb38ab8fc..387865a1bf9d5 100644 --- a/testdata/cheats/dumpState.t.sol +++ b/testdata/cheats/dumpState.t.sol @@ -63,6 +63,7 @@ contract DumpStateTest is DSTest { vm.setNonce(address(0x100), 1); vm.deal(address(0x200), 1 ether); + vm.setNonce(address(0x300), 1); vm.store(address(0x300), bytes32(uint256(1)), bytes32(uint256(2))); vm.etch(address(0x400), hex"af"); @@ -85,7 +86,7 @@ contract DumpStateTest is DSTest { assertEq(0, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x200)), ".storage")).length); assertEq(4, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x300)))).length); - assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x300)), ".nonce"))); + assertEq(1, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x300)), ".nonce"))); assertEq(0, vm.parseJsonUint(json, string.concat(".", vm.toString(address(0x300)), ".balance"))); assertEq(hex"", vm.parseJsonBytes(json, string.concat(".", vm.toString(address(0x300)), ".code"))); assertEq(1, vm.parseJsonKeys(json, string.concat(".", vm.toString(address(0x300)), ".storage")).length); @@ -120,4 +121,19 @@ contract DumpStateTest is DSTest { vm.removeFile(path); } + + function testDumpStateEmptyAccount() public { + string memory path = string.concat(vm.projectRoot(), "/fixtures/Json/test_dump_state_empty_account.json"); + + SimpleContract s = new SimpleContract(); + vm.etch(address(s), hex""); + vm.resetNonce(address(s)); + + vm.dumpState(path); + string memory json = vm.readFile(path); + string[] memory keys = vm.parseJsonKeys(json, ""); + assertEq(keys.length, 0); + + vm.removeFile(path); + } } From 4574f05378890d989de0bad87d5587d35a864310 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 1 Feb 2024 20:26:59 +0100 Subject: [PATCH 0566/1963] ci: update runners (part 3) (final) (#6987) --- .github/scripts/matrices.py | 2 +- .github/workflows/release.yml | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 99fdc78e735ab..090ca98bd3efa 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -70,7 +70,7 @@ def __init__( # TODO: Figure out how to make this work # t_linux_arm = Target("Linux-22.04", "aarch64-unknown-linux-gnu", "linux-aarch64") t_macos = Target("macos-latest-large", "x86_64-apple-darwin", "macosx-amd64") -t_windows = Target("windows-latest", "x86_64-pc-windows-msvc", "windows-amd64") +t_windows = Target("Windows", "x86_64-pc-windows-msvc", "windows-amd64") targets = [t_linux_x86, t_windows] if is_pr else [t_linux_x86, t_macos, t_windows] config = [ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 776c36e023144..071b0f6286815 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,39 +66,39 @@ jobs: uses: ./.github/workflows/docker-publish.yml release: - name: ${{ matrix.target }} (${{ matrix.os }}) - runs-on: ${{ matrix.os }} + name: ${{ matrix.target }} (${{ matrix.runner }}) + runs-on: ${{ matrix.runner }} timeout-minutes: 240 needs: prepare strategy: fail-fast: false matrix: include: - # `os`: GHA runner + # `runner`: GHA runner label # `target`: Rust build target triple # `platform` and `arch`: Used in tarball names # `svm`: target platform to use for the Solc binary: https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 - - os: Linux-20.04 + - runner: Linux-20.04 target: x86_64-unknown-linux-gnu svm_target_platform: linux-amd64 platform: linux arch: amd64 - - os: Linux-20.04 + - runner: Linux-20.04 target: aarch64-unknown-linux-gnu svm_target_platform: linux-aarch64 platform: linux arch: arm64 - - os: macos-latest-large + - runner: macos-latest-large target: x86_64-apple-darwin svm_target_platform: macosx-amd64 platform: darwin arch: amd64 - - os: macos-latest-large + - runner: macos-latest-large target: aarch64-apple-darwin svm_target_platform: macosx-aarch64 platform: darwin arch: arm64 - - os: windows-latest + - runner: Windows target: x86_64-pc-windows-msvc svm_target_platform: windows-amd64 platform: win32 @@ -138,9 +138,6 @@ jobs: # `keccak-asm` does not support MSVC or aarch64 Linux. [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]] && flags+=(--features=asm-keccak) - # Windows runs out of RAM when building binaries with LLVM - [[ "$target" == *windows* ]] && flags+=(-j1) - [[ "$target" == *windows* ]] && exe=".exe" cargo build --release --bins --target "$target" "${flags[@]}" From b73df7cc6bca599079f240697040c1036b5164fe Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 1 Feb 2024 16:05:35 -0400 Subject: [PATCH 0567/1963] feat(`anvil`): migrate in-house `Genesis` to `alloy-genesis` (#6970) * wip: migrate to alloy genesis * feat: switch out from in-house genesis to alloy genesis * chore: rem unneeded file * chore: update alloy, use from_bytes * chore: use proper fns on trait * chore: use block number --- Cargo.lock | 31 +- crates/anvil/Cargo.toml | 1 + .../core/src/eth/transaction/optimism.rs | 8 + crates/anvil/src/cmd.rs | 9 +- crates/anvil/src/config.rs | 18 +- crates/anvil/src/eth/backend/genesis.rs | 35 +- crates/anvil/src/genesis.rs | 300 ------------------ crates/anvil/src/lib.rs | 13 +- crates/anvil/tests/it/genesis.rs | 3 +- crates/cheatcodes/src/evm.rs | 1 + 10 files changed, 78 insertions(+), 341 deletions(-) delete mode 100644 crates/anvil/src/genesis.rs diff --git a/Cargo.lock b/Cargo.lock index c90fa32f91754..72c7688b2f1ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -262,7 +262,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -279,7 +279,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -290,7 +290,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -303,7 +303,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-network", "alloy-primitives", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -380,7 +380,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -411,7 +411,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#53ef6c2dc9867f03320131ff0f25577502259138" +source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -513,6 +513,7 @@ dependencies = [ "alloy-chains", "alloy-consensus", "alloy-dyn-abi", + "alloy-genesis", "alloy-network", "alloy-primitives", "alloy-providers", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 21633df0c09ad..f6d4f518561bd 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -46,6 +46,7 @@ alloy-rpc-trace-types.workspace = true alloy-providers.workspace = true alloy-transport.workspace = true alloy-chains.workspace = true +alloy-genesis.workspace = true # axum related axum.workspace = true diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 614ba15b81d60..86edc810a537f 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -229,6 +229,14 @@ impl Transaction for DepositTransactionRequest { fn value(&self) -> U256 { self.value } + + fn encode_for_signing(&self, out: &mut dyn alloy_rlp::BufMut) { + self.encode_for_signing(out) + } + + fn payload_len_for_signature(&self) -> usize { + self.payload_len_for_signature() + } } impl From for DepositTransactionRequest { diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 9ddd53434f6c3..b87da35572ff3 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -1,9 +1,9 @@ use crate::{ config::DEFAULT_MNEMONIC, eth::{backend::db::SerializableState, pool::transactions::TransactionOrder, EthApi}, - genesis::Genesis, AccountGenerator, Hardfork, NodeConfig, CHAIN_ID, }; +use alloy_genesis::Genesis; use alloy_primitives::{utils::Unit, U256}; use alloy_signer::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; @@ -110,7 +110,7 @@ pub struct NodeArgs { pub order: TransactionOrder, /// Initialize the genesis block with the given `genesis.json` file. - #[clap(long, value_name = "PATH", value_parser = Genesis::parse)] + #[clap(long, value_name = "PATH", value_parser= read_genesis_file)] pub init: Option, /// This is an alias for both --load-state and --dump-state. @@ -672,6 +672,11 @@ impl FromStr for ForkUrl { } } +/// Clap's value parser for genesis. Loads a genesis.json file. +fn read_genesis_file(path: &str) -> Result { + foundry_common::fs::read_json_file(path.as_ref()).map_err(|err| err.to_string()) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 3e370b5768476..e7bec82bfcbf9 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -11,11 +11,11 @@ use crate::{ fees::{INITIAL_BASE_FEE, INITIAL_GAS_PRICE}, pool::transactions::TransactionOrder, }, - genesis::Genesis, mem, mem::in_memory_db::MemDb, FeeManager, Hardfork, }; +use alloy_genesis::Genesis; use alloy_primitives::{hex, utils::Unit, U256}; use alloy_providers::provider::TempProvider; use alloy_rpc_types::BlockNumberOrTag; @@ -412,7 +412,7 @@ impl NodeConfig { /// Returns the base fee to use pub fn get_base_fee(&self) -> U256 { self.base_fee - .or_else(|| self.genesis.as_ref().and_then(|g| g.base_fee_per_gas)) + .or_else(|| self.genesis.as_ref().and_then(|g| g.base_fee_per_gas.map(U256::from))) .unwrap_or_else(|| U256::from(INITIAL_BASE_FEE)) } @@ -457,7 +457,7 @@ impl NodeConfig { /// Returns the chain ID to use pub fn get_chain_id(&self) -> u64 { self.chain_id - .or_else(|| self.genesis.as_ref().and_then(|g| g.chain_id())) + .or_else(|| self.genesis.as_ref().map(|g| g.config.chain_id)) .unwrap_or(CHAIN_ID) } @@ -532,7 +532,7 @@ impl NodeConfig { /// Returns the genesis timestamp to use pub fn get_genesis_timestamp(&self) -> u64 { self.genesis_timestamp - .or_else(|| self.genesis.as_ref().and_then(|g| g.timestamp)) + .or_else(|| self.genesis.as_ref().map(|g| g.timestamp)) .unwrap_or_else(|| duration_since_unix_epoch().as_secs()) } @@ -834,7 +834,15 @@ impl NodeConfig { // if provided use all settings of `genesis.json` if let Some(ref genesis) = self.genesis { - genesis.apply(&mut env); + env.cfg.chain_id = genesis.config.chain_id; + env.block.timestamp = U256::from(genesis.timestamp); + if let Some(base_fee) = genesis.base_fee_per_gas { + env.block.basefee = U256::from(base_fee); + } + if let Some(number) = genesis.number { + env.block.number = U256::from(number); + } + env.block.coinbase = genesis.coinbase; } let genesis = GenesisConfig { diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 523208ba83b42..c6e75bb4440f8 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -1,9 +1,7 @@ //! Genesis settings -use crate::{ - eth::backend::db::{Db, MaybeHashDatabase}, - genesis::Genesis, -}; +use crate::eth::backend::db::{Db, MaybeHashDatabase}; +use alloy_genesis::{Genesis, GenesisAccount}; use alloy_primitives::{Address, B256, U256}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, StateSnapshot}, @@ -57,12 +55,12 @@ impl GenesisConfig { mut db: RwLockWriteGuard<'_, Box>, ) -> DatabaseResult<()> { if let Some(ref genesis) = self.genesis_init { - for (addr, mut acc) in genesis.alloc.accounts.clone() { + for (addr, mut acc) in genesis.alloc.clone() { let storage = std::mem::take(&mut acc.storage); // insert all accounts - db.insert_account(addr, acc.into()); + db.insert_account(addr, self.genesis_to_account_info(&acc)); // insert all storage values - for (k, v) in storage.iter() { + for (k, v) in storage.unwrap_or_default().iter() { db.set_storage_at(addr, U256::from_be_bytes(k.0), U256::from_be_bytes(v.0))?; } } @@ -70,6 +68,18 @@ impl GenesisConfig { Ok(()) } + /// Converts a [`GenesisAccount`] to an [`AccountInfo`] + fn genesis_to_account_info(&self, acc: &GenesisAccount) -> AccountInfo { + let GenesisAccount { code, balance, nonce, .. } = acc.clone(); + let code = code.map(|code| Bytecode::new_raw(code.to_vec().into())); + AccountInfo { + balance, + nonce: nonce.unwrap_or_default(), + code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), + code, + } + } + /// Returns a database wrapper that points to the genesis and is aware of all provided /// [AccountInfo] pub(crate) fn state_db_at_genesis<'a>( @@ -113,11 +123,12 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> { } fn storage_ref(&self, address: Address, index: U256) -> DatabaseResult { - if let Some(acc) = - self.genesis.as_ref().and_then(|genesis| genesis.alloc.accounts.get(&(address))) - { - let value = acc.storage.get(&B256::from(index)).copied().unwrap_or_default(); - return Ok(U256::from_be_bytes(value.0)) + if let Some(acc) = self.genesis.as_ref().and_then(|genesis| genesis.alloc.get(&(address))) { + if let Some(storage) = acc.storage.as_ref() { + return Ok(U256::from_be_bytes( + storage.get(&B256::from(index)).copied().unwrap_or_default().0, + )) + } } self.db.storage_ref(address, index) } diff --git a/crates/anvil/src/genesis.rs b/crates/anvil/src/genesis.rs deleted file mode 100644 index 3525838a77562..0000000000000 --- a/crates/anvil/src/genesis.rs +++ /dev/null @@ -1,300 +0,0 @@ -//! Bindings for geth's `genesis.json` format -use crate::revm::primitives::AccountInfo; -use alloy_primitives::{Address, Bytes, B256, U256}; -use alloy_signer::LocalWallet; -use foundry_common::errors::FsPathError; -use foundry_evm::revm::primitives::{Bytecode, Env, KECCAK_EMPTY, U256 as rU256}; -use serde::{Deserialize, Serialize}; -use std::{ - collections::{BTreeMap, HashMap}, - path::Path, -}; - -/// Genesis specifies the header fields, state of a genesis block. It also defines hard fork -/// switch-over blocks through the chain configuration See also: -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Genesis { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub config: Option, - #[serde( - default, - deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", - skip_serializing_if = "Option::is_none" - )] - pub nonce: Option, - #[serde( - default, - deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", - skip_serializing_if = "Option::is_none" - )] - pub timestamp: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub extra_data: Option, - #[serde( - deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64" - )] - pub gas_limit: u64, - #[serde( - deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64" - )] - pub difficulty: u64, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub mix_hash: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub coinbase: Option

, - #[serde(default)] - pub alloc: Alloc, - #[serde( - default, - deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", - skip_serializing_if = "Option::is_none" - )] - pub number: Option, - #[serde( - default, - deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", - skip_serializing_if = "Option::is_none" - )] - pub gas_used: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub parent_hash: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub base_fee_per_gas: Option, -} - -impl Genesis { - /// Loads the `Genesis` object from the given json file path - pub fn load(path: impl AsRef) -> Result { - foundry_common::fs::read_json_file(path.as_ref()) - } - - /// The clap `value_parser` function - pub(crate) fn parse(path: &str) -> Result { - Self::load(path).map_err(|err| err.to_string()) - } - - pub fn chain_id(&self) -> Option { - self.config.as_ref().and_then(|c| c.chain_id) - } - - /// Applies all settings to the given `env` - pub fn apply(&self, env: &mut Env) { - if let Some(chain_id) = self.chain_id() { - env.cfg.chain_id = chain_id; - } - if let Some(timestamp) = self.timestamp { - env.block.timestamp = U256::from(timestamp); - } - if let Some(base_fee) = self.base_fee_per_gas { - env.block.basefee = base_fee; - } - if let Some(number) = self.number { - env.block.number = rU256::from(number); - } - if let Some(coinbase) = self.coinbase { - env.block.coinbase = coinbase; - } - env.block.difficulty = U256::from(self.difficulty); - env.block.gas_limit = U256::from(self.gas_limit); - } - - /// Returns all private keys from the genesis accounts, if they exist - pub fn private_keys(&self) -> Vec { - self.alloc.accounts.values().filter_map(|acc| acc.private_key.clone()).collect() - } -} - -#[derive(Clone, Debug, Default, Serialize, Deserialize)] -#[serde(transparent)] -pub struct Alloc { - pub accounts: BTreeMap, -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct GenesisAccount { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub code: Option, - #[serde(default, skip_serializing_if = "HashMap::is_empty")] - pub storage: HashMap, - pub balance: U256, - #[serde( - default, - deserialize_with = "anvil_core::eth::serde_helpers::numeric::deserialize_stringified_u64_opt", - skip_serializing_if = "Option::is_none" - )] - pub nonce: Option, - #[serde( - rename = "secretKey", - default, - skip_serializing_if = "Option::is_none", - with = "secret_key" - )] - pub private_key: Option, -} - -impl From for AccountInfo { - fn from(acc: GenesisAccount) -> Self { - let GenesisAccount { code, balance, nonce, .. } = acc; - let code = code.map(|code| Bytecode::new_raw(code.to_vec().into())); - AccountInfo { - balance, - nonce: nonce.unwrap_or_default(), - code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY), - code, - } - } -} - -/// ChainConfig is the core config which determines the blockchain settings. -/// -/// ChainConfig is stored in the database on a per block basis. This means -/// that any network, identified by its genesis block, can have its own -/// set of configuration options. -/// <(https://github.com/ethereum/go-ethereum/blob/0ce494b60cd00d70f1f9f2dd0b9bfbd76204168a/params/config.go#L342-L387> -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Config { - #[serde(default, skip_serializing_if = "Option::is_none")] - pub chain_id: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub homestead_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub dao_fork_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub dao_fork_support: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub eip150_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub eip150_hash: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub eip155_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub eip158_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub byzantium_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub constantinople_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub petersburg_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub istanbul_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub muir_glacier_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub berlin_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub london_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub arrow_glacier_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub gray_glacier_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub merge_netsplit_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub shanghai_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub cancun_block: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub terminal_total_difficulty: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub terminal_total_difficulty_passed: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub ethash: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub clique: Option, -} - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct EthashConfig {} - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct CliqueConfig { - pub period: u64, - pub epoch: u64, -} - -/// serde support for `secretKey` in genesis - -pub mod secret_key { - use alloy_primitives::Bytes; - use alloy_signer::LocalWallet; - use k256::{ecdsa::SigningKey, SecretKey}; - use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; - - pub fn serialize(value: &Option, serializer: S) -> Result - where - S: Serializer, - { - if let Some(wallet) = value { - let signer: SigningKey = wallet.signer().clone(); - let signer_bytes = signer.to_bytes(); - let signer_bytes2: [u8; 32] = *signer_bytes.as_ref(); - Bytes::from(signer_bytes2).serialize(serializer) - } else { - serializer.serialize_none() - } - } - - pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> - where - D: Deserializer<'de>, - { - if let Some(s) = Option::::deserialize(deserializer)? { - if s.is_empty() { - return Ok(None) - } - SecretKey::from_bytes(s.as_ref().into()) - .map_err(de::Error::custom) - .map(Into::into) - .map(Some) - } else { - Ok(None) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_parse_genesis_json() { - let s = r#"{ - "config": { - "chainId": 19763, - "homesteadBlock": 0, - "eip150Block": 0, - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "ethash": {} - }, - "nonce": "0xdeadbeefdeadbeef", - "timestamp": "0x0", - "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", - "gasLimit": "0x80000000", - "difficulty": "0x20000", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "alloc": { - "71562b71999873db5b286df957af199ec94617f7": { - "balance": "0xffffffffffffffffffffffffff", - "secretkey": "0x305b526d493844b63466be6d48a424ab83f5216011eef860acc6db4c1821adc9" - } - }, - "number": "0x0", - "gasUsed": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" -} -"#; - - let gen: Genesis = serde_json::from_str(s).unwrap(); - assert_eq!(gen.nonce, Some(16045690984833335023)); - assert_eq!(gen.gas_limit, 2147483648); - assert_eq!(gen.difficulty, 131072); - assert_eq!(gen.alloc.accounts.len(), 1); - let config = gen.config.unwrap(); - assert_eq!(config.chain_id, Some(19763)); - } -} diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 322b14aad60f7..d2503410f0e65 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -52,8 +52,6 @@ pub use hardfork::Hardfork; pub mod eth; /// support for polling filters pub mod filter; -/// support for handling `genesis.json` files -pub mod genesis; /// commandline output pub mod logging; /// types for subscriptions @@ -128,11 +126,14 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { let dev_signer: Box = Box::new(DevSigner::new(signer_accounts)); let mut signers = vec![dev_signer]; if let Some(genesis) = genesis { - // include all signers from genesis.json if any - let genesis_signers = genesis.private_keys(); + let genesis_signers = genesis + .alloc + .values() + .filter_map(|acc| acc.private_key) + .flat_map(|k| LocalWallet::from_bytes(&k)) + .collect::>(); if !genesis_signers.is_empty() { - let genesis_signers: Box = Box::new(DevSigner::new(genesis_signers)); - signers.push(genesis_signers); + signers.push(Box::new(DevSigner::new(genesis_signers))); } } diff --git a/crates/anvil/tests/it/genesis.rs b/crates/anvil/tests/it/genesis.rs index 2a0c2e8eed246..9b822aff72074 100644 --- a/crates/anvil/tests/it/genesis.rs +++ b/crates/anvil/tests/it/genesis.rs @@ -2,9 +2,10 @@ use std::str::FromStr; +use alloy_genesis::Genesis; use alloy_primitives::{Address, U256, U64}; use alloy_providers::provider::TempProvider; -use anvil::{genesis::Genesis, spawn, NodeConfig}; +use anvil::{spawn, NodeConfig}; #[tokio::test(flavor = "multi_thread")] async fn can_apply_genesis() { diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 41ae1e486049e..27eb17733ae83 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -127,6 +127,7 @@ impl Cheatcode for dumpStateCall { .map(|(k, v)| (B256::from(*k), B256::from(v.present_value()))) .collect(), ), + private_key: None, }, ) }) From f5af8d6a74d808b0abdc53224a29e328dcf5d4d5 Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 1 Feb 2024 17:36:49 -0400 Subject: [PATCH 0568/1963] chore(`perf`): remove unneeded to_vec conversion (#6990) * chore: remove unneeded to_vec conversion * clippy --- crates/anvil/src/eth/backend/genesis.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index c6e75bb4440f8..14197b63d9bab 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -71,7 +71,7 @@ impl GenesisConfig { /// Converts a [`GenesisAccount`] to an [`AccountInfo`] fn genesis_to_account_info(&self, acc: &GenesisAccount) -> AccountInfo { let GenesisAccount { code, balance, nonce, .. } = acc.clone(); - let code = code.map(|code| Bytecode::new_raw(code.to_vec().into())); + let code = code.map(Bytecode::new_raw); AccountInfo { balance, nonce: nonce.unwrap_or_default(), From 996c643bde2edf583adbb03567c1e21d5e7b0ff7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:44:15 +0100 Subject: [PATCH 0569/1963] fix: actually run all unit tests in CI (#6989) --- .github/scripts/matrices.py | 2 +- crates/cast/bin/cmd/call.rs | 8 ++--- crates/forge/bin/cmd/install.rs | 1 + crates/forge/bin/cmd/script/mod.rs | 33 ++++++++------------ crates/forge/bin/cmd/verify/etherscan/mod.rs | 4 +-- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 090ca98bd3efa..3594fd2673141 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -76,7 +76,7 @@ def __init__( config = [ Case( name="unit", - filter="kind(lib) | kind(bench) | kind(proc-macro)", + filter="!kind(test)", n_partitions=1, pr_cross_platform=True, ), diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 5845b721018b5..4851e9cf9a6fa 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -254,11 +254,11 @@ mod tests { #[test] fn can_parse_call_data() { let data = hex::encode("hello"); - let args: CallArgs = - CallArgs::parse_from(["foundry-cli", "--data", format!("0x{data}").as_str()]); - assert_eq!(args.data, Some(data.clone())); + let args = CallArgs::parse_from(["foundry-cli", "--data", data.as_str()]); + assert_eq!(args.data, Some(data)); - let args: CallArgs = CallArgs::parse_from(["foundry-cli", "--data", data.as_str()]); + let data = hex::encode_prefixed("hello"); + let args = CallArgs::parse_from(["foundry-cli", "--data", data.as_str()]); assert_eq!(args.data, Some(data)); } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 140cd7b5a5b15..a990c4a910048 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -505,6 +505,7 @@ mod tests { use tempfile::tempdir; #[test] + #[ignore = "slow"] fn get_oz_tags() { let tmp = tempdir().unwrap(); let git = Git::new(tmp.path()); diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 5ea7119a93ec7..ede0b19fd388a 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -703,21 +703,14 @@ mod tests { #[test] fn can_parse_sig() { - let args: ScriptArgs = ScriptArgs::parse_from([ - "foundry-cli", - "Contract.sol", - "--sig", - "0x522bb704000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfFFb92266", - ]); - assert_eq!( - args.sig, - "522bb704000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfFFb92266" - ); + let sig = "0x522bb704000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfFFb92266"; + let args = ScriptArgs::parse_from(["foundry-cli", "Contract.sol", "--sig", sig]); + assert_eq!(args.sig, sig); } #[test] fn can_parse_unlocked() { - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "Contract.sol", "--sender", @@ -741,7 +734,7 @@ mod tests { #[test] fn can_merge_script_config() { - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "Contract.sol", "--etherscan-api-key", @@ -753,7 +746,7 @@ mod tests { #[test] fn can_parse_verifier_url() { - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "script", "script/Test.s.sol:TestScript", @@ -775,7 +768,7 @@ mod tests { #[test] fn can_extract_code_size_limit() { - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "script", "script/Test.s.sol:TestScript", @@ -803,7 +796,7 @@ mod tests { let toml_file = root.join(Config::FILE_NAME); fs::write(toml_file, config).unwrap(); - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "Contract.sol", "--etherscan-api-key", @@ -831,7 +824,7 @@ mod tests { let toml_file = root.join(Config::FILE_NAME); fs::write(toml_file, config).unwrap(); - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "DeployV1", "--rpc-url", @@ -870,7 +863,7 @@ mod tests { let toml_file = root.join(Config::FILE_NAME); fs::write(toml_file, config).unwrap(); - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "DeployV1", "--rpc-url", @@ -915,7 +908,7 @@ mod tests { let toml_file = root.join(Config::FILE_NAME); fs::write(toml_file, config).unwrap(); - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "DeployV1", "--rpc-url", @@ -943,7 +936,7 @@ mod tests { // #[test] fn test_5923() { - let args: ScriptArgs = + let args = ScriptArgs::parse_from(["foundry-cli", "DeployV1", "--priority-gas-price", "100"]); assert!(args.priority_gas_price.is_some()); } @@ -951,7 +944,7 @@ mod tests { // #[test] fn test_5910() { - let args: ScriptArgs = ScriptArgs::parse_from([ + let args = ScriptArgs::parse_from([ "foundry-cli", "--broadcast", "--with-gas-price", diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 2304871941c5e..e973189036fb2 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -512,7 +512,7 @@ mod tests { &config, ) .unwrap(); - assert_eq!(client.etherscan_api_url().as_str(), "https://api-testnet.polygonscan.com/?/"); + assert_eq!(client.etherscan_api_url().as_str(), "https://api-testnet.polygonscan.com/"); assert!(format!("{client:?}").contains("dummykey")); @@ -539,7 +539,7 @@ mod tests { &config, ) .unwrap(); - assert_eq!(client.etherscan_api_url().as_str(), "https://verifier-url.com/?/"); + assert_eq!(client.etherscan_api_url().as_str(), "https://verifier-url.com/"); assert!(format!("{client:?}").contains("dummykey")); } From 84d98427e17370ff08ec34f00e3c7e539753a760 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 2 Feb 2024 01:04:21 +0100 Subject: [PATCH 0570/1963] test: improve external tests (#6991) * test: improve external tests * untrack * try winders * dont bun on windows * fixwindows * restore * node * win * winder * restore --- .github/workflows/test.yml | 17 +- crates/forge/tests/cli/config.rs | 2 +- crates/forge/tests/cli/ext_integration.rs | 145 ++++++++++++----- crates/test-utils/src/macros.rs | 79 --------- crates/test-utils/src/util.rs | 187 +++++++++++++++++++--- 5 files changed, 278 insertions(+), 152 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 842a9713c85c0..fda10266fcc78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,22 +51,21 @@ jobs: - uses: taiki-e/install-action@nextest # External tests dependencies - - name: Setup Python - if: contains(matrix.name, 'external') - uses: actions/setup-python@v4 - with: - python-version: 3.11 - name: Setup Node.js if: contains(matrix.name, 'external') uses: actions/setup-node@v4 with: node-version: 20 - - name: Install pnpm + - name: Install Bun + if: contains(matrix.name, 'external') && !contains(matrix.runner_label, 'windows') + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Setup Python if: contains(matrix.name, 'external') - uses: pnpm/action-setup@v2 + uses: actions/setup-python@v4 with: - version: latest - run_install: false + python-version: 3.11 - name: Install Vyper if: contains(matrix.name, 'external') run: pip install vyper diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 1b69369db52ab..92d02ac2da4e9 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -409,7 +409,7 @@ Compiler run successful! // tests that the lib triple can be parsed forgetest_init!(can_parse_dapp_libraries, |_prj, cmd| { - cmd.set_env( + cmd.env( "DAPP_LIBRARIES", "src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6", ); diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 2b3cc437f2fdc..f0044848a198a 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -1,47 +1,104 @@ -forgetest_external!(solmate, "transmissions11/solmate"); -forgetest_external!( - #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] - prb_math, - "PaulRBerg/prb-math" -); -forgetest_external!( - #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] - prb_proxy, - "PaulRBerg/prb-proxy" -); -forgetest_external!( - #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] - sablier_v2, - "sablier-labs/v2-core", - // skip fork tests - &["--nmc", "Fork"] -); -forgetest_external!(solady, "Vectorized/solady"); -forgetest_external!( - #[cfg_attr(windows, ignore = "weird git fail")] - geb, - "reflexer-labs/geb", - &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] -); -forgetest_external!(stringutils, "Arachnid/solidity-stringutils"); -forgetest_external!(lootloose, "gakonst/lootloose"); -forgetest_external!(lil_web3, "m1guelpf/lil-web3"); -forgetest_external!( - // https://github.com/foundry-rs/foundry/pull/6280 - // `run: pnpm --version` is ok, `Command::new("pnpm")` isn't. Good job Windows. - #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] - snekmate, - "pcaversaccio/snekmate" -); +use foundry_test_utils::util::ExtTester; + +#[test] +fn solmate() { + ExtTester::new("transmissions11", "solmate", "c892309933b25c03d32b1b0d674df7ae292ba925").run(); +} + +#[test] +#[cfg_attr(windows, ignore = "Windows cannot find installed programs")] +fn prb_math() { + ExtTester::new("PaulRBerg", "prb-math", "5b6279a0cf7c1b1b6a5cc96082811f7ef620cf60").run(); +} + +#[test] +#[cfg_attr(windows, ignore = "Windows cannot find installed programs")] +fn prb_proxy() { + ExtTester::new("PaulRBerg", "prb-proxy", "fa13cf09fbf544a2d575b45884b8e94a79a02c06").run(); +} + +#[test] +#[cfg_attr(windows, ignore = "Windows cannot find installed programs")] +fn sablier_v2() { + ExtTester::new("sablier-labs", "v2-core", "84758a40077bf3ccb1c8f7bb8d00278e672fbfef") + // skip fork tests + .args(["--nmc", "Fork"]) + // run tests without optimizations + .env("FOUNDRY_PROFILE", "lite") + .run(); +} + +#[test] +fn solady() { + ExtTester::new("Vectorized", "solady", "54ea1543a229b88b44ccb6ec5ea570135811a7d9").run(); +} + +#[test] +#[cfg_attr(windows, ignore = "weird git fail")] +fn geb() { + ExtTester::new("reflexer-labs", "geb", "1a59f16a377386c49f520006ed0f7fd9d128cb09") + .args(["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"]) + .run(); +} + +#[test] +fn stringutils() { + ExtTester::new("Arachnid", "solidity-stringutils", "4b2fcc43fa0426e19ce88b1f1ec16f5903a2e461") + .run(); +} + +#[test] +fn lootloose() { + ExtTester::new("gakonst", "lootloose", "7b639efe97836155a6a6fc626bf1018d4f8b2495").run(); +} + +#[test] +fn lil_web3() { + ExtTester::new("m1guelpf", "lil-web3", "7346bd28c2586da3b07102d5290175a276949b15").run(); +} + +#[test] +#[cfg_attr(windows, ignore = "Windows cannot find installed programs")] +fn snekmate() { + ExtTester::new("pcaversaccio", "snekmate", "ed49a0454393673cdf9a4250dd7051c28e6ac35f").run(); +} + +#[test] +fn makerdao_multicall() { + ExtTester::new("makerdao", "multicall", "103a8a28e4e372d582d6539b30031bda4cd48e21") + .args(["--block-number", "1"]) + .run(); +} + +#[test] +fn mds1_multicall() { + ExtTester::new("mds1", "multicall", "263ef67f29ab9e450142b42dde617ad69adbf211").run(); +} // Forking tests -forgetest_external!(multicall, "makerdao/multicall", &["--block-number", "1"]); -forgetest_external!( - drai, - "mds1/drai", - 13633752, - &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] -); -forgetest_external!(gunilev, "hexonaut/guni-lev", 13633752); -forgetest_external!(convex, "mds1/convex-shutdown-simulation", 14445961); +#[test] +fn drai() { + ExtTester::new("mds1", "drai", "f31ce4fb15bbb06c94eefea2a3a43384c75b95cf") + .args(["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"]) + .fork_block(13633752) + .run(); +} + +#[test] +fn gunilev() { + ExtTester::new("hexonaut", "guni-lev", "15ee8b4c2d28e553c5cd5ba9a2a274af97563bc4") + .fork_block(13633752) + .run(); +} + +#[test] +fn convex() { + ExtTester::new( + "mds1", + "convex-shutdown-simulation", + "2537cdebce4396753225c5e616c8e00547d2fcea", + ) + .fork_block(14445961) + .run(); +} diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index d5cb88e5a8ba1..f05c8e36b8e42 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -92,82 +92,3 @@ macro_rules! forgetest_init { } }; } - -/// Clones an external repository and makes sure the tests pass. -/// Can optionally enable fork mode as well if a fork block is passed. -/// The fork block needs to be greater than 0. -#[macro_export] -macro_rules! forgetest_external { - // forgetest_external!(test_name, "owner/repo"); - ($(#[$attr:meta])* $test:ident, $repo:literal) => { - $crate::forgetest_external!($(#[$attr])* $test, $repo, 0, Vec::::new()); - }; - // forgetest_external!(test_name, "owner/repo", 1234); - ($(#[$attr:meta])* $test:ident, $repo:literal, $fork_block:literal) => { - $crate::forgetest_external!( - $(#[$attr])* - $test, - $repo, - $crate::foundry_compilers::PathStyle::Dapptools, - $fork_block, - Vec::::new() - ); - }; - // forgetest_external!(test_name, "owner/repo", &["--extra-opt", "val"]); - ($(#[$attr:meta])* $test:ident, $repo:literal, $forge_opts:expr) => { - $crate::forgetest_external!($(#[$attr])* $test, $repo, 0, $forge_opts); - }; - // forgetest_external!(test_name, "owner/repo", 1234, &["--extra-opt", "val"]); - ($(#[$attr:meta])* $test:ident, $repo:literal, $fork_block:literal, $forge_opts:expr) => { - $crate::forgetest_external!( - $(#[$attr])* - $test, - $repo, - $crate::foundry_compilers::PathStyle::Dapptools, - $fork_block, - $forge_opts - ); - }; - // forgetest_external!(test_name, "owner/repo", PathStyle::Dapptools, 123); - ($(#[$attr:meta])* $test:ident, $repo:literal, $style:expr, $fork_block:literal, $forge_opts:expr) => { - #[test] - $(#[$attr])* - fn $test() { - use std::process::{Command, Stdio}; - - // Skip fork tests if the RPC url is not set. - if $fork_block > 0 && std::env::var("ETH_RPC_URL").is_err() { - eprintln!("Skipping test {}. ETH_RPC_URL is not set.", $repo); - return - }; - - let (prj, mut cmd) = $crate::util::setup_forge(stringify!($test), $style); - - // Wipe the default structure - prj.wipe(); - - // Clone the external repository - $crate::util::clone_remote(concat!("https://github.com/", $repo), prj.root().to_str().unwrap()); - - // Run common installation commands - $crate::util::run_install_commands(prj.root()); - - // Run the tests - cmd.arg("test").args($forge_opts).args([ - "--optimize", - "--optimizer-runs=20000", - "--fuzz-runs=256", - "--ffi", - "-vvvvv", - ]); - cmd.set_env("FOUNDRY_FUZZ_RUNS", "1"); - - let next_eth_rpc_url = foundry_common::rpc::next_http_archive_rpc_endpoint(); - if $fork_block > 0 { - cmd.set_env("FOUNDRY_ETH_RPC_URL", next_eth_rpc_url); - cmd.set_env("FOUNDRY_FORK_BLOCK_NUMBER", stringify!($fork_block)); - } - cmd.assert_non_empty_stdout(); - } - }; -} diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index e90a02d5e5442..beed4498b8b02 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -13,7 +13,6 @@ use regex::Regex; use std::{ env, ffi::OsStr, - fmt::Display, fs, fs::File, io::{BufWriter, IsTerminal, Write}, @@ -50,6 +49,137 @@ pub const SOLC_VERSION: &str = "0.8.23"; /// versions. pub const OTHER_SOLC_VERSION: &str = "0.8.22"; +/// External test builder +#[derive(Clone, Debug)] +#[must_use = "call run()"] +pub struct ExtTester { + pub org: &'static str, + pub name: &'static str, + pub rev: &'static str, + pub style: PathStyle, + pub fork_block: Option, + pub args: Vec, + pub envs: Vec<(String, String)>, +} + +impl ExtTester { + /// Creates a new external test builder. + pub fn new(org: &'static str, name: &'static str, rev: &'static str) -> Self { + Self { + org, + name, + rev, + style: PathStyle::Dapptools, + fork_block: None, + args: vec![], + envs: vec![], + } + } + + /// Sets the path style. + pub fn style(mut self, style: PathStyle) -> Self { + self.style = style; + self + } + + /// Sets the fork block. + pub fn fork_block(mut self, fork_block: u64) -> Self { + self.fork_block = Some(fork_block); + self + } + + /// Adds an argument to the forge command. + pub fn arg(mut self, arg: impl Into) -> Self { + self.args.push(arg.into()); + self + } + + /// Adds multiple arguments to the forge command. + pub fn args(mut self, args: I) -> Self + where + I: IntoIterator, + A: Into, + { + self.args.extend(args.into_iter().map(Into::into)); + self + } + + /// Adds an environment variable to the forge command. + pub fn env(mut self, key: impl Into, value: impl Into) -> Self { + self.envs.push((key.into(), value.into())); + self + } + + /// Adds multiple environment variables to the forge command. + pub fn envs(mut self, envs: I) -> Self + where + I: IntoIterator, + K: Into, + V: Into, + { + self.envs.extend(envs.into_iter().map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Runs the test. + pub fn run(&self) { + // Skip fork tests if the RPC url is not set. + if self.fork_block.is_some() && std::env::var_os("ETH_RPC_URL").is_none() { + eprintln!("ETH_RPC_URL is not set; skipping"); + return; + } + + let (prj, mut cmd) = setup_forge(self.name, self.style.clone()); + + // Wipe the default structure. + prj.wipe(); + + // Clone the external repository. + let repo_url = format!("https://github.com/{}/{}.git", self.org, self.name); + let root = prj.root().to_str().unwrap(); + clone_remote(&repo_url, root); + + // Checkout the revision. + if self.rev.is_empty() { + let mut cmd = Command::new("git"); + cmd.current_dir(root).args(["log", "-n", "1"]); + eprintln!("$ {cmd:?}"); + let output = cmd.output().unwrap(); + if !output.status.success() { + panic!("git log failed: {output:?}"); + } + let stdout = String::from_utf8(output.stdout).unwrap(); + let commit = stdout.lines().next().unwrap().split_whitespace().nth(1).unwrap(); + panic!("pin to latest commit: {commit}"); + } else { + let mut cmd = Command::new("git"); + cmd.current_dir(root).args(["checkout", self.rev]); + eprintln!("$ {cmd:?}"); + let status = cmd.status().unwrap(); + if !status.success() { + panic!("git checkout failed: {status}"); + } + } + + // Run common installation commands. + run_install_commands(prj.root()); + + // Run the tests. + cmd.arg("test"); + cmd.args(&self.args); + cmd.args(["--fuzz-runs=256", "--ffi", "-vvvvv"]); + + cmd.envs(self.envs.iter().map(|(k, v)| (k, v))); + cmd.env("FOUNDRY_FUZZ_RUNS", "1"); + if let Some(fork_block) = self.fork_block { + cmd.env("FOUNDRY_ETH_RPC_URL", foundry_common::rpc::next_http_archive_rpc_endpoint()); + cmd.env("FOUNDRY_FORK_BLOCK_NUMBER", fork_block.to_string()); + } + + cmd.assert_non_empty_stdout(); + } +} + /// Initializes a project with `forge init` at the given path. /// /// This should be called after an empty project is created like in @@ -112,11 +242,12 @@ pub fn initialize(target: &Path) { /// Clones a remote repository into the specified directory. Panics if the command fails. pub fn clone_remote(repo_url: &str, target_dir: &str) { let mut cmd = Command::new("git"); - cmd.args(["clone", "--depth=1", "--recursive", "--shallow-submodules", repo_url, target_dir]); + cmd.args(["clone", "--no-tags", "--recursive", "--shallow-submodules"]); + cmd.args([repo_url, target_dir]); eprintln!("{cmd:?}"); let status = cmd.status().unwrap(); if !status.success() { - panic!("git clone failed: {status:?}"); + panic!("git clone failed: {status}"); } eprintln!(); } @@ -130,26 +261,34 @@ pub fn run_install_commands(root: &Path) { let mut cmd = Command::new(args[0]); cmd.args(&args[1..]).current_dir(root); eprintln!("cd {}; {cmd:?}", root.display()); - #[cfg(windows)] - let st = cmd.status(); - #[cfg(not(windows))] - let st = cmd.status().unwrap(); - eprintln!("\n\n{cmd:?}: {st:?}"); + match cmd.status() { + Ok(s) => { + eprintln!("\n\n{cmd:?}: {s}"); + s.success() + } + Err(e) => { + eprintln!("\n\n{cmd:?}: {e}"); + false + } + } }; let maybe_run = |path: &str, args: &[&str]| { - let c = contains(path); - if c { - run(args); + if contains(path) { + run(args) + } else { + false } - c }; maybe_run("Makefile", &["make", "install"]); - let pnpm = maybe_run("pnpm-lock.yaml", &["pnpm", "install", "--prefer-offline"]); - let yarn = maybe_run("yarn.lock", &["yarn", "install", "--prefer-offline"]); - if !pnpm && !yarn && contains("package.json") { - run(&["npm", "install"]); - } + + // Only run one of these for `node_modules`. + let mut nm = false; + nm = nm || maybe_run("bun.lockb", &["bun", "install", "--prefer-offline"]); + nm = nm || maybe_run("pnpm-lock.yaml", &["pnpm", "install", "--prefer-offline"]); + nm = nm || maybe_run("yarn.lock", &["yarn", "install", "--prefer-offline"]); + nm = nm || maybe_run("package.json", &["npm", "install", "--prefer-offline"]); + let _ = nm; } /// Setup an empty test project and return a command pointing to the forge @@ -640,8 +779,18 @@ impl TestCommand { } /// Set the environment variable `k` to value `v` for the command. - pub fn set_env(&mut self, k: impl AsRef, v: impl Display) { - self.cmd.env(k, v.to_string()); + pub fn env(&mut self, k: impl AsRef, v: impl AsRef) { + self.cmd.env(k, v); + } + + /// Set the environment variable `k` to value `v` for the command. + pub fn envs(&mut self, envs: I) + where + I: IntoIterator, + K: AsRef, + V: AsRef, + { + self.cmd.envs(envs); } /// Unsets the environment variable `k` for the command. From e2d32789141e62432f3f4afd40f56e34f1011224 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 2 Feb 2024 15:24:53 +0300 Subject: [PATCH 0571/1963] feat(`forge`): new `flatten` implementation (#6936) * Update Flatten impl * Bump foundry-compilers * fix error handling * Update crates/forge/bin/cmd/flatten.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * error handling * Bump compilers and block-explorers * Simplify compilation * fmt * fix doc * use patch * bump compilers --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 12 ++++-------- Cargo.toml | 6 +++--- crates/forge/bin/cmd/flatten.rs | 23 +++++++++++++++++++---- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72c7688b2f1ae..c65fd0e82b4d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2951,9 +2951,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebeafdc703baf5bb879b276653735cddb2e0244e5e59c24f3aeab5686d801006" +checksum = "5a056d4aa33a639c0aa1e9e473c25b9b191be30cbea94b31445fac5c272418ae" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3104,23 +3104,20 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.2.4" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5106d26aa9a9955c852bed6f9d8994d7229a177969ae5a813008022b022f31ae" +checksum = "7fd693c0870b3817b215417ff0f2f0df02cddf296dc5524c330f99186a42cf29" dependencies = [ "alloy-json-abi", "alloy-primitives", "cfg-if", - "const-hex", "dirs 5.0.1", "dunce", "fs_extra", "futures-util", - "glob", "home", "md-5 0.10.6", "memmap2 0.9.4", - "num_cpus", "once_cell", "path-slash", "rand 0.8.5", @@ -3135,7 +3132,6 @@ dependencies = [ "svm-rs-builds 0.3.5", "tempfile", "thiserror", - "tiny-keccak", "tokio", "tracing", "walkdir", diff --git a/Cargo.toml b/Cargo.toml index 88ecea80484ab..1d5f7db36c060 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,8 +126,8 @@ foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities -foundry-block-explorers = { version = "0.2.0", default-features = false } -foundry-compilers = { version = "0.2.4", default-features = false } +foundry-block-explorers = { version = "0.2.3", default-features = false } +foundry-compilers = { version = "0.3.1", default-features = false } ## revm # no default features to avoid c-kzg @@ -226,4 +226,4 @@ revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_fr revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors" } +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors" } \ No newline at end of file diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 0716af47267ae..9831e17cecce9 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -4,7 +4,8 @@ use foundry_cli::{ opts::{CoreBuildArgs, ProjectPathsArgs}, utils::LoadConfig, }; -use foundry_common::fs; +use foundry_common::{compile::ProjectCompiler, fs}; +use foundry_compilers::{error::SolcError, flatten::Flattener}; use std::path::PathBuf; /// CLI arguments for `forge flatten`. @@ -38,10 +39,24 @@ impl FlattenArgs { let config = build_args.try_load_config_emit_warnings()?; - let paths = config.project_paths(); let target_path = dunce::canonicalize(target_path)?; - let flattened = - paths.flatten(&target_path).map_err(|err| eyre::eyre!("Failed to flatten: {err}"))?; + + let project = config.ephemeral_no_artifacts_project()?; + + let compiler_output = ProjectCompiler::new().files([target_path.clone()]).compile(&project); + + let flattened = match compiler_output { + Ok(compiler_output) => { + Flattener::new(&project, &compiler_output, &target_path).map(|f| f.flatten()) + } + Err(_) => { + // Fallback to the old flattening implementation if we couldn't compile the target + // successfully. This would be the case if the target has invalid + // syntax. (e.g. Solang) + project.paths.flatten(&target_path) + } + } + .map_err(|err: SolcError| eyre::eyre!("Failed to flatten: {err}"))?; match output { Some(output) => { From 0a883bfd518a38fa81fc5b91456dff66b65c1ffa Mon Sep 17 00:00:00 2001 From: Bjerg Date: Fri, 2 Feb 2024 16:11:48 +0100 Subject: [PATCH 0572/1963] chore: fix typos (#7000) --- crates/common/src/provider/runtime_transport.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 67f83998d44c7..eefb740e9e479 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -202,7 +202,7 @@ impl RuntimeTransport { } /// Sends a request using the underlying transport. - /// If this is the first request, it will connect to the appropiate transport depending on the + /// If this is the first request, it will connect to the appropriate transport depending on the /// URL scheme. When sending the request, retries will be automatically handled depending /// on the parameters set on the [RuntimeTransport]. /// For sending the actual request, this action is delegated down to the @@ -283,7 +283,7 @@ fn build_auth(jwt: String) -> eyre::Result { let auth = JwtAuth::new(secret, None, None); let token = auth.generate_token()?; - // Essentially unrolled ethers-rs new_with_auth to accomodate the custom timeout + // Essentially unrolled ethers-rs new_with_auth to accommodate the custom timeout let auth = Authorization::Bearer(token); Ok(auth) From 2cb875799419c907cc3709e586ece2559e6b340e Mon Sep 17 00:00:00 2001 From: Luca Provini Date: Fri, 2 Feb 2024 19:06:39 +0100 Subject: [PATCH 0573/1963] added arg and computing state in function of some overrides (#6985) * added arg and computing state in function of some overrides * review * corrected H160 to alloy address --- crates/anvil/core/src/eth/mod.rs | 6 +++- crates/anvil/src/eth/api.rs | 40 ++++++++++++++++++----- crates/anvil/tests/it/transaction.rs | 49 ++++++++++++++++++++++++++-- 3 files changed, 84 insertions(+), 11 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 3fd0c6ed889c1..4a63675917c98 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -176,7 +176,11 @@ pub enum EthRequest { ), #[cfg_attr(feature = "serde", serde(rename = "eth_estimateGas"))] - EthEstimateGas(CallRequest, #[cfg_attr(feature = "serde", serde(default))] Option), + EthEstimateGas( + CallRequest, + #[cfg_attr(feature = "serde", serde(default))] Option, + #[cfg_attr(feature = "serde", serde(default))] Option, + ), #[cfg_attr(feature = "serde", serde(rename = "eth_getTransactionByHash", with = "sequence"))] EthGetTransactionByHash(TxHash), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index cb6c9d5b8b174..e796e4f4dde7c 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1,4 +1,7 @@ -use super::{backend::mem::BlockRequest, sign::build_typed_transaction}; +use super::{ + backend::mem::{state, BlockRequest}, + sign::build_typed_transaction, +}; use crate::{ eth::{ backend, @@ -228,8 +231,8 @@ impl EthApi { EthRequest::EthCreateAccessList(call, block) => { self.create_access_list(call, block).await.to_rpc_result() } - EthRequest::EthEstimateGas(call, block) => { - self.estimate_gas(call, block).await.to_rpc_result() + EthRequest::EthEstimateGas(call, block, overrides) => { + self.estimate_gas(call, block, overrides).await.to_rpc_result() } EthRequest::EthGetTransactionByBlockHashAndIndex(hash, index) => { self.transaction_by_block_hash_and_index(hash, index).await.to_rpc_result() @@ -860,7 +863,9 @@ impl EthApi { if request.gas.is_none() { // estimate if not provided - if let Ok(gas) = self.estimate_gas(request.clone().into_call_request(), None).await { + if let Ok(gas) = + self.estimate_gas(request.clone().into_call_request(), None, None).await + { request.gas = Some(gas); } } @@ -886,7 +891,9 @@ impl EthApi { if request.gas.is_none() { // estimate if not provided - if let Ok(gas) = self.estimate_gas(request.clone().into_call_request(), None).await { + if let Ok(gas) = + self.estimate_gas(request.clone().into_call_request(), None, None).await + { request.gas = Some(gas); } } @@ -1081,10 +1088,15 @@ impl EthApi { &self, request: CallRequest, block_number: Option, + overrides: Option, ) -> Result { node_info!("eth_estimateGas"); - self.do_estimate_gas(request, block_number.or_else(|| Some(BlockNumber::Pending.into()))) - .await + self.do_estimate_gas( + request, + block_number.or_else(|| Some(BlockNumber::Pending.into())), + overrides, + ) + .await } /// Get transaction by its hash. @@ -2144,12 +2156,18 @@ impl EthApi { &self, request: CallRequest, block_number: Option, + overrides: Option, ) -> Result { let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { + if overrides.is_some() { + return Err(BlockchainError::StateOverrideError( + "not available on past forked blocks".to_string(), + )); + } return fork .estimate_gas(&request, Some(number.into())) .await @@ -2159,7 +2177,13 @@ impl EthApi { } self.backend - .with_database_at(Some(block_request), |state, block| { + .with_database_at(Some(block_request), |mut state, block| { + if let Some(overrides) = overrides { + state = Box::new(state::apply_state_override( + overrides.into_iter().collect(), + state, + )?); + } self.do_estimate_gas_with_state(request, state, block) }) .await? diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 4e793964299b2..fd8dee363d694 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -3,7 +3,10 @@ use crate::{ utils::{ethers_http_provider, ethers_ws_provider}, }; use alloy_primitives::U256 as rU256; -use alloy_rpc_types::BlockNumberOrTag; +use alloy_rpc_types::{ + state::{AccountOverride, StateOverride}, + BlockNumberOrTag, +}; use alloy_signer::Signer as AlloySigner; use anvil::{spawn, Hardfork, NodeConfig}; use anvil_core::eth::transaction::EthTransactionRequest; @@ -961,7 +964,49 @@ async fn estimates_gas_on_pending_by_default() { let tx = TransactionRequest::new().from(recipient).to(sender).value(1e10 as u64).data(vec![0x42]); - api.estimate_gas(to_call_request_from_tx_request(tx), None).await.unwrap(); + api.estimate_gas(to_call_request_from_tx_request(tx), None, None).await.unwrap(); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_estimate_gas() { + let (api, handle) = spawn(NodeConfig::test()).await; + + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let sender = wallet.address(); + let recipient = Address::random(); + + let tx = + TransactionRequest::new().from(recipient).to(sender).value(1e10 as u64).data(vec![0x42]); + // Expect the gas estimation to fail due to insufficient funds. + let error_result = + api.estimate_gas(to_call_request_from_tx_request(tx.clone()), None, None).await; + + assert!(error_result.is_err(), "Expected an error due to insufficient funds"); + let error_message = error_result.unwrap_err().to_string(); + assert!( + error_message.contains("Insufficient funds for gas * price + value"), + "Error message did not match expected: {}", + error_message + ); + + // Setup state override to simulate sufficient funds for the recipient. + let addr = alloy_primitives::Address::from_slice(recipient.as_bytes()); + let account_override = + AccountOverride { balance: Some(alloy_primitives::U256::from(1e18)), ..Default::default() }; + let mut state_override = StateOverride::new(); + state_override.insert(addr, account_override); + + // Estimate gas with state override implying sufficient funds. + let gas_estimate = api + .estimate_gas(to_call_request_from_tx_request(tx), None, Some(state_override)) + .await + .expect("Failed to estimate gas with state override"); + + // Assert the gas estimate meets the expected minimum. + assert!( + gas_estimate >= alloy_primitives::U256::from(21000), + "Gas estimate is lower than expected minimum" + ); } #[tokio::test(flavor = "multi_thread")] From 51ccfdb6444d0f3c89467e6d6aa6be8b52162eed Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 3 Feb 2024 22:04:19 +0100 Subject: [PATCH 0574/1963] chore: add new solidity warning code (#7007) --- crates/config/src/error.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 97f0ec10de579..b4f7b85aa2918 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -102,6 +102,9 @@ impl Error for FoundryConfigError { pub enum SolidityErrorCode { /// Warning that SPDX license identifier not provided in source file SpdxLicenseNotProvided, + /// Warning: Visibility for constructor is ignored. If you want the contract to be + /// non-deployable, making it "abstract" is sufficient + VisibilityForConstructorIsIgnored, /// Warning that contract code size exceeds 24576 bytes (a limit introduced in Spurious /// Dragon). ContractExceeds24576Bytes, @@ -158,6 +161,7 @@ impl SolidityErrorCode { SolidityErrorCode::Unreachable => "unreachable", SolidityErrorCode::PragmaSolidity => "pragma-solidity", SolidityErrorCode::Other(code) => return Err(*code), + SolidityErrorCode::VisibilityForConstructorIsIgnored => "constructor-visibility", }; Ok(s) } @@ -180,6 +184,7 @@ impl From for u64 { SolidityErrorCode::Unreachable => 5740, SolidityErrorCode::PragmaSolidity => 3420, SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes => 3860, + SolidityErrorCode::VisibilityForConstructorIsIgnored => 2462, SolidityErrorCode::Other(code) => code, } } @@ -212,6 +217,7 @@ impl FromStr for SolidityErrorCode { "virtual-interfaces" => SolidityErrorCode::InterfacesExplicitlyVirtual, "missing-receive-ether" => SolidityErrorCode::PayableNoReceiveEther, "same-varname" => SolidityErrorCode::DeclarationSameNameAsAnother, + "constructor-visibility" => SolidityErrorCode::VisibilityForConstructorIsIgnored, _ => return Err(format!("Unknown variant {s}")), }; @@ -236,6 +242,7 @@ impl From for SolidityErrorCode { 6321 => SolidityErrorCode::UnnamedReturnVariable, 3420 => SolidityErrorCode::PragmaSolidity, 5740 => SolidityErrorCode::Unreachable, + 2462 => SolidityErrorCode::VisibilityForConstructorIsIgnored, other => SolidityErrorCode::Other(other), } } From f53fb3a9392be675ac695a34ee7027e2ef7288bc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 14:10:11 +0100 Subject: [PATCH 0575/1963] chore(deps): weekly `cargo update` (#7008) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating git repository `https://github.com/alloy-rs/alloy` Updating alloy-consensus v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-genesis v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-network v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-providers v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-pubsub v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-rpc-client v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-rpc-trace-types v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-rpc-types v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-signer v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-transport v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-transport-http v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-transport-ipc v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating alloy-transport-ws v0.1.0 (https://github.com/alloy-rs/alloy#11b80310) -> #2be62140 Updating anstyle v1.0.4 -> v1.0.5 Updating auto_impl v1.1.1 -> v1.1.2 Updating clap_complete v4.4.9 -> v4.4.10 Updating coins-ledger v0.9.2 -> v0.9.3 Updating eyre v0.6.11 -> v0.6.12 Updating iana-time-zone v0.1.59 -> v0.1.60 Updating indexmap v2.1.0 -> v2.2.2 Updating itertools v0.12.0 -> v0.12.1 Updating libc v0.2.152 -> v0.2.153 Updating lru v0.12.1 -> v0.12.2 Updating miniz_oxide v0.7.1 -> v0.7.2 Adding num-conv v0.1.0 Updating pulldown-cmark v0.9.4 -> v0.9.6 Updating reqwest v0.11.23 -> v0.11.24 Updating revm v3.5.0 (https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db) -> #ba28a423 Updating revm-inspectors v0.1.0 (https://github.com/paradigmxyz/evm-inspectors#5ee90076) -> #e9005236 Updating revm-interpreter v1.3.0 (https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db) -> #ba28a423 Updating revm-precompile v2.2.0 (https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db) -> #ba28a423 Updating revm-primitives v1.3.0 (https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db) -> #ba28a423 Updating rustix v0.38.30 -> v0.38.31 Updating secp256k1 v0.28.1 -> v0.28.2 Updating serde_json v1.0.112 -> v1.0.113 Updating time v0.3.31 -> v0.3.34 Updating time-macros v0.2.16 -> v0.2.17 Updating tokio v1.35.1 -> v1.36.0 Updating toml v0.8.8 -> v0.8.9 Updating toml_edit v0.21.0 -> v0.21.1 Updating webpki-roots v0.25.3 -> v0.25.4 Updating winnow v0.5.35 -> v0.5.37 Co-authored-by: mattsse --- Cargo.lock | 162 ++++++++++++++++++++++++++++------------------------- 1 file changed, 86 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c65fd0e82b4d1..d62ee18693986 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,13 +224,14 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-json-rpc", "alloy-primitives", "alloy-transport", "bimap", "futures", + "serde", "serde_json", "tokio", "tower", @@ -262,7 +263,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -279,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -290,11 +291,11 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-primitives", "alloy-rlp", - "itertools 0.12.0", + "itertools 0.12.1", "serde", "serde_json", "thiserror", @@ -303,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-network", "alloy-primitives", @@ -364,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -380,7 +381,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -393,7 +394,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -411,7 +412,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#11b80310b1dd717e5e799942534f1f8b9fb2ee46" +source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -474,9 +475,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" [[package]] name = "anstyle-parse" @@ -893,11 +894,10 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972d3215e2b5ab2408f98713bee04b8b8d2f915bfecfcb569e07a14edec1e1e1" +checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", "syn 2.0.48", @@ -1476,9 +1476,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.9" +version = "4.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df631ae429f6613fcd3a7c1adbdb65f637271e561b03680adaa6573015dfb106" +checksum = "abb745187d7f4d76267b37485a65e0149edd0e91a4cfcdd3f27524ad86cee9f3" dependencies = [ "clap", ] @@ -1589,9 +1589,9 @@ dependencies = [ [[package]] name = "coins-ledger" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b913b49d2e008b23cffb802f29b8051feddf7b2cc37336ab9a7a410f832395a" +checksum = "d0a3eedd46b3c8c0b9fbe6359078d375008c11824fadc4b7462491bb445e8904" dependencies = [ "async-trait", "byteorder", @@ -2431,7 +2431,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.48", - "toml 0.8.8", + "toml 0.8.9", "walkdir", ] @@ -2670,9 +2670,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" dependencies = [ "indenter", "once_cell", @@ -2761,7 +2761,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.8", + "toml 0.8.9", "uncased", "version_check", ] @@ -2920,7 +2920,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.8", + "toml 0.8.9", "tracing", ] @@ -2935,7 +2935,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.8", + "toml 0.8.9", "tracing", "tracing-subscriber", ] @@ -3164,8 +3164,8 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.8", - "toml_edit 0.21.0", + "toml 0.8.9", + "toml_edit 0.21.1", "tracing", "walkdir", ] @@ -4118,9 +4118,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -4229,9 +4229,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -4364,9 +4364,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] @@ -4529,9 +4529,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libgit2-sys" @@ -4620,9 +4620,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" +checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22" dependencies = [ "hashbrown 0.14.3", ] @@ -4809,9 +4809,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -4972,6 +4972,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -5739,7 +5745,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit 0.21.0", + "toml_edit 0.21.1", ] [[package]] @@ -5852,9 +5858,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16a41fe73d9f20da4dae1440a2c4f23db602db9b4699b9b694f007c0a84f67d" +checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ "bitflags 2.4.2", "memchr", @@ -6096,9 +6102,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.23" +version = "0.11.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ "base64 0.21.7", "bytes", @@ -6125,6 +6131,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", @@ -6141,7 +6148,7 @@ dependencies = [ [[package]] name = "revm" version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" dependencies = [ "auto_impl", "revm-interpreter", @@ -6153,7 +6160,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#5ee90076f88e64a059e4c0c268929cf9ec91ed6d" +source = "git+https://github.com/paradigmxyz/evm-inspectors#e90052361276aebcdc67cb24d8e2c4d907b6d299" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6166,7 +6173,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" dependencies = [ "revm-primitives", "serde", @@ -6175,7 +6182,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6191,7 +6198,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#2caa13db91db770e7e015a6e52b5feedbb38ee8a" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -6199,6 +6206,7 @@ dependencies = [ "bitflags 2.4.2", "bitvec", "c-kzg", + "cfg-if", "enumn", "hashbrown 0.14.3", "hex", @@ -6458,9 +6466,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", @@ -6690,9 +6698,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.28.1" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f622567e3b4b38154fb8190bcf6b160d7a4301d70595a49195b48c116007a27" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ "secp256k1-sys", ] @@ -6801,9 +6809,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.112" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d1bd37ce2324cf3bf85e5a25f96eb4baf0d5aa6eba43e7ae8958870c4ec48ed" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "indexmap", "itoa", @@ -7422,13 +7430,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", "libc", + "num-conv", "num_threads", "powerfmt", "serde", @@ -7444,10 +7453,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -7493,9 +7503,9 @@ checksum = "c7c4ceeeca15c8384bbc3e011dbd8fccb7f068a440b752b7d9b32ceb0ca0e2e8" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -7606,15 +7616,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "c6a4b9e8023eb94392d3dca65d717c53abc5dad49c07cb65bb8fcd87115fa325" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.0", + "toml_edit 0.21.1", ] [[package]] @@ -7650,9 +7660,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "serde", @@ -8222,9 +8232,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "which" @@ -8487,9 +8497,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.35" +version = "0.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" dependencies = [ "memchr", ] From 7922fd5482f9561699e0fe5a903c90b3fa1fc50d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 4 Feb 2024 14:51:28 +0100 Subject: [PATCH 0576/1963] chore: bump strum (#7010) --- Cargo.lock | 55 +++++++++++++++++++++++++--------------- Cargo.toml | 3 ++- crates/chisel/Cargo.toml | 2 +- crates/cli/Cargo.toml | 2 +- crates/forge/Cargo.toml | 2 +- 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d62ee18693986..4f742d4b408fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,13 +78,13 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206e825321d0ed5b6e3907e6ddf70c2139cfdc6274e83a1ca2f4784bd0abc0c9" +checksum = "45625825df98039a6dced71fedca82e69a8a0177453e21faeed47b9a6f16a178" dependencies = [ "num_enum", "serde", - "strum", + "strum 0.26.1", ] [[package]] @@ -1380,7 +1380,7 @@ dependencies = [ "serde_json", "serial_test", "solang-parser", - "strum", + "strum 0.26.1", "time", "tokio", "tracing", @@ -1650,8 +1650,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ "crossterm", - "strum", - "strum_macros", + "strum 0.25.0", + "strum_macros 0.25.3", "unicode-width", ] @@ -2471,7 +2471,7 @@ dependencies = [ "rlp", "serde", "serde_json", - "strum", + "strum 0.25.0", "syn 2.0.48", "tempfile", "thiserror", @@ -2886,7 +2886,7 @@ dependencies = [ "serial_test", "similar", "solang-parser", - "strum", + "strum 0.26.1", "svm-rs", "tempfile", "thiserror", @@ -3040,7 +3040,7 @@ dependencies = [ "rusoto_kms", "serde", "strsim", - "strum", + "strum 0.26.1", "tempfile", "thiserror", "tokio", @@ -5046,7 +5046,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5739,15 +5739,6 @@ dependencies = [ "toml_edit 0.20.7", ] -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -5991,7 +5982,7 @@ dependencies = [ "itertools 0.11.0", "lru", "paste", - "strum", + "strum 0.25.0", "unicode-segmentation", "unicode-width", ] @@ -7162,7 +7153,16 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" dependencies = [ - "strum_macros", + "strum_macros 0.25.3", +] + +[[package]] +name = "strum" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" +dependencies = [ + "strum_macros 0.26.1", ] [[package]] @@ -7178,6 +7178,19 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "strum_macros" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.48", +] + [[package]] name = "substrate-bn" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 1d5f7db36c060..e73e80e20eef9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,8 +167,8 @@ alloy-dyn-abi = "0.6.2" alloy-json-abi = "0.6.2" alloy-sol-types = "0.6.2" syn-solidity = "0.6.0" +alloy-chains = "0.1" -alloy-chains = "0.1.10" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" @@ -186,6 +186,7 @@ rand = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } base64 = "0.21" +strum = "0.26" toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 0fec11be95317..5b22c3065e839 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -44,7 +44,7 @@ semver = "1" serde_json.workspace = true serde.workspace = true solang-parser.workspace = true -strum = { version = "0.25", features = ["derive"] } +strum = { workspace = true, features = ["derive"] } time = { version = "0.3", features = ["formatting"] } tokio = { version = "1", features = ["full"] } yansi = "0.5" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 60b80fc799110..4cae11791032d 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -42,7 +42,7 @@ regex = { version = "1", default-features = false } rpassword = "7" serde.workspace = true strsim = "0.10" -strum = { version = "0.25", features = ["derive"] } +strum = { workspace = true, features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["macros"] } tracing-error = "0.2" diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 51b0777c05ebb..0a6b9c1efbfeb 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -70,7 +70,7 @@ semver = "1" serde_json.workspace = true similar = { version = "2", features = ["inline"] } solang-parser.workspace = true -strum = { version = "0.25", features = ["derive"] } +strum = { workspace = true, features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["time"] } watchexec = "2.3.2" From 317ca389e28a66ec58bab1035e518236f83be7c4 Mon Sep 17 00:00:00 2001 From: g-01234 <97188867+g-01234@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:40:03 -0600 Subject: [PATCH 0577/1963] fix(cast): pass blocknum to cast storage rather than always using latest (#7009) * fix: pass blockid to get_storage_at() * fix: test for cast storage --block fix --- crates/cast/bin/cmd/storage.rs | 11 +++++++---- crates/cast/tests/cli/main.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index eb5b7cd4323f4..5769360484ad7 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -107,7 +107,8 @@ impl StorageArgs { artifact.get_deployed_bytecode_bytes().is_some_and(|b| *b == address_code) }); if let Some((_, artifact)) = artifact { - return fetch_and_print_storage(provider, address.clone(), artifact, true).await; + return fetch_and_print_storage(provider, address.clone(), block, artifact, true) + .await; } } @@ -173,7 +174,7 @@ impl StorageArgs { // Clear temp directory root.close()?; - fetch_and_print_storage(provider, address, artifact, true).await + fetch_and_print_storage(provider, address, block, artifact, true).await } } @@ -211,6 +212,7 @@ impl StorageValue { async fn fetch_and_print_storage( provider: RetryProvider, address: NameOrAddress, + block: Option, artifact: &ConfigurableContractArtifact, pretty: bool, ) -> Result<()> { @@ -219,7 +221,7 @@ async fn fetch_and_print_storage( Ok(()) } else { let layout = artifact.storage_layout.as_ref().unwrap().clone(); - let values = fetch_storage_slots(provider, address, &layout).await?; + let values = fetch_storage_slots(provider, address, block, &layout).await?; print_storage(layout, values, pretty) } } @@ -227,12 +229,13 @@ async fn fetch_and_print_storage( async fn fetch_storage_slots( provider: RetryProvider, address: NameOrAddress, + block: Option, layout: &StorageLayout, ) -> Result> { let requests = layout.storage.iter().map(|storage_slot| async { let slot = B256::from(U256::from_str(&storage_slot.slot)?); let raw_slot_value = - provider.get_storage_at(address.clone(), slot.to_ethers(), None).await?.to_alloy(); + provider.get_storage_at(address.clone(), slot.to_ethers(), block).await?.to_alloy(); let value = StorageValue { slot, raw_slot_value }; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 28703b5a116e6..e4009aa4af9f6 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -555,6 +555,32 @@ casttest!(storage, |_prj, cmd| { let six = "0x0000000000000000000000000000000000000000000000000000000000000006"; cmd.cast_fuse().args(["storage", usdt, decimals_slot, "--rpc-url", &rpc]); assert_eq!(cmd.stdout_lossy().trim(), six); + + let rpc = next_http_rpc_endpoint(); + let total_supply_slot = "0x01"; + let issued = "0x000000000000000000000000000000000000000000000000000000174876e800"; + let block_before = "4634747"; + let block_after = "4634748"; + cmd.cast_fuse().args([ + "storage", + usdt, + total_supply_slot, + "--rpc-url", + &rpc, + "--block", + block_before, + ]); + assert_eq!(cmd.stdout_lossy().trim(), empty); + cmd.cast_fuse().args([ + "storage", + usdt, + total_supply_slot, + "--rpc-url", + &rpc, + "--block", + block_after, + ]); + assert_eq!(cmd.stdout_lossy().trim(), issued); }); casttest!(balance, |_prj, cmd| { From 0688b5ad19a637303c038d1a66aec62a73713e20 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 6 Feb 2024 01:46:04 +0200 Subject: [PATCH 0578/1963] chore(deps): pin revm-inspectors (#7016) --- Cargo.lock | 99 ++++++++++++++++++++++++++++++++---------------------- Cargo.toml | 4 +-- 2 files changed, 60 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f742d4b408fb..b1a0e595dda0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-network", "alloy-primitives", @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -381,7 +381,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -412,7 +412,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#2be621406132ba034e6c9729e3f1fbd0e26bda4d" +source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -475,9 +475,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -2431,7 +2431,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.48", - "toml 0.8.9", + "toml 0.8.10", "walkdir", ] @@ -2761,7 +2761,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.9", + "toml 0.8.10", "uncased", "version_check", ] @@ -2920,7 +2920,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.9", + "toml 0.8.10", "tracing", ] @@ -2935,7 +2935,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.9", + "toml 0.8.10", "tracing", "tracing-subscriber", ] @@ -3164,7 +3164,7 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.9", + "toml 0.8.10", "toml_edit 0.21.1", "tracing", "walkdir", @@ -3931,9 +3931,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -5046,7 +5046,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.48", @@ -5413,9 +5413,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", @@ -5424,9 +5424,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" +checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" dependencies = [ "pest", "pest_generator", @@ -5434,9 +5434,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" +checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" dependencies = [ "pest", "pest_meta", @@ -5447,9 +5447,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" +checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" dependencies = [ "once_cell", "pest", @@ -5739,6 +5739,15 @@ dependencies = [ "toml_edit 0.20.7", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -6151,7 +6160,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors#e90052361276aebcdc67cb24d8e2c4d907b6d299" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=e90052361276aebcdc67cb24d8e2c4d907b6d299#e90052361276aebcdc67cb24d8e2c4d907b6d299" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -7337,13 +7346,12 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] @@ -7629,15 +7637,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a4b9e8023eb94392d3dca65d717c53abc5dad49c07cb65bb8fcd87115fa325" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.1", + "toml_edit 0.22.0", ] [[package]] @@ -7676,6 +7684,17 @@ name = "toml_edit" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8dc77def39ce6079c2d0c866cc20848f591b1898f153c9fe7c4f29e1154510b" dependencies = [ "indexmap", "serde", diff --git a/Cargo.toml b/Cargo.toml index e73e80e20eef9..70b3c069e097c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -133,7 +133,7 @@ foundry-compilers = { version = "0.3.1", default-features = false } # no default features to avoid c-kzg revm = { version = "3", default-features = false } revm-primitives = { version = "1", default-features = false } -revm-inspectors = { version = "0.1", default-features = false } +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "e90052361276aebcdc67cb24d8e2c4d907b6d299", default-features = false } ## ethers ethers = { version = "2.0", default-features = false } @@ -226,5 +226,3 @@ revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } - -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors" } \ No newline at end of file From f957e82f3f79f2358ab91d67e3b15054e6d15462 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 6 Feb 2024 04:20:14 -0400 Subject: [PATCH 0579/1963] fix(foundry-common): Do not retry custom errors (#7017) --- crates/common/src/provider/retry.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index bf1d0c31cb074..39248a8a38e95 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -1,6 +1,6 @@ //! An utility trait for retrying requests based on the error type. See [TransportError]. use alloy_json_rpc::ErrorPayload; -use alloy_transport::TransportError; +use alloy_transport::{TransportError, TransportErrorKind}; use serde::Deserialize; /// [RetryPolicy] defines logic for which [JsonRpcClient::Error] instances should @@ -24,7 +24,9 @@ pub struct RateLimitRetryPolicy; impl RetryPolicy for RateLimitRetryPolicy { fn should_retry(&self, error: &TransportError) -> bool { match error { - TransportError::Transport(_) => true, + // There was a transport-level error. This is either a non-retryable error, + // or a server error that should be retried. + TransportError::Transport(err) => should_retry_transport_level_error(err), // The transport could not serialize the error itself. The request was malformed from // the start. TransportError::SerError(_) => false, @@ -65,6 +67,18 @@ impl RetryPolicy for RateLimitRetryPolicy { } } +/// Analyzes the [TransportErrorKind] and decides if the request should be retried based on the +/// variant. +fn should_retry_transport_level_error(error: &TransportErrorKind) -> bool { + match error { + // Missing batch response errors can be retried. + TransportErrorKind::MissingBatchResponse(_) => true, + // If the backend is gone, or there's a completely custom error, we should assume it's not + // retryable. + _ => false, + } +} + /// Analyzes the [ErrorPayload] and decides if the request should be retried based on the /// error code or the message. fn should_retry_json_rpc_error(error: &ErrorPayload) -> bool { From 2b24a106629ee622a615fa602633be21330e3c3a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 6 Feb 2024 09:22:45 +0100 Subject: [PATCH 0580/1963] fix: normalize default evm version if solc configured (#7018) --- crates/config/src/lib.rs | 67 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index c10c41028c25a..ef8aef44021e2 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -560,6 +560,29 @@ impl Config { self } + /// Normalizes the evm version if a [SolcReq] is set + pub fn normalized_evm_version(mut self) -> Self { + self.normalize_evm_version(); + self + } + + /// Normalizes the evm version if a [SolcReq] is set to a valid version. + pub fn normalize_evm_version(&mut self) { + self.evm_version = self.get_normalized_evm_version(); + } + + /// Returns the normalized [EvmVersion] if a [SolcReq] is set to a valid version. + /// + /// Otherwise it returns the configured [EvmVersion]. + pub fn get_normalized_evm_version(&self) -> EvmVersion { + if let Some(SolcReq::Version(version)) = &self.solc { + if let Some(evm_version) = self.evm_version.normalize_version(version) { + return evm_version; + } + } + self.evm_version + } + /// Returns a sanitized version of the Config where are paths are set correctly and potential /// duplicates are resolved /// @@ -1552,10 +1575,30 @@ impl Config { figment = figment.merge(provider); figment } + + /// Check if any defaults need to be normalized. + /// + /// This normalizes the default `evm_version` if a `solc` was provided in the config. + /// + /// See also + fn normalize_defaults(&mut self, figment: Figment) -> Figment { + if let Ok(version) = figment.extract_inner::("solc") { + // check if evm_version is set + // TODO: add a warning if evm_version is provided but incompatible + if figment.find_value("evm_version").is_err() { + if let Some(version) = self.evm_version.normalize_version(&version) { + // normalize evm_version based on the provided solc version + self.evm_version = version; + } + } + } + + figment + } } impl From for Figment { - fn from(c: Config) -> Figment { + fn from(mut c: Config) -> Figment { let profile = Config::selected_profile(); let mut figment = Figment::default().merge(DappHardhatDirProvider(&c.__root.0)); @@ -1622,6 +1665,9 @@ impl From for Figment { }; let merge = figment.merge(remappings); + // normalize defaults + let merge = c.normalize_defaults(merge); + Figment::from(c).merge(merge).select(profile) } } @@ -3877,7 +3923,7 @@ mod tests { #[test] fn can_handle_deviating_dapp_aliases() { figment::Jail::expect_with(|jail| { - let addr = Address::random(); + let addr = Address::ZERO; jail.set_env("DAPP_TEST_NUMBER", 1337); jail.set_env("DAPP_TEST_ADDRESS", format!("{addr:?}")); jail.set_env("DAPP_TEST_FUZZ_RUNS", 420); @@ -4377,6 +4423,23 @@ mod tests { }); } + #[test] + fn test_normalize_defaults() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r" + [default] + solc = '0.8.13' + ", + )?; + + let loaded = Config::load().sanitized(); + assert_eq!(loaded.evm_version, EvmVersion::London); + Ok(()) + }); + } + // a test to print the config, mainly used to update the example config in the README #[test] #[ignore] From 9ce80908977836bf07b7a6d6c5573943ecb16b17 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Tue, 6 Feb 2024 02:23:44 -0600 Subject: [PATCH 0581/1963] fix(chisel): validate that EVM version is compatible with solc version (#7019) --- crates/chisel/src/session_source.rs | 29 ++++++++++++----------------- crates/chisel/tests/cache.rs | 26 +++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 322598e36940f..36fb5cf1c1673 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -8,7 +8,7 @@ use eyre::Result; use forge_fmt::solang_ext::SafeUnwrap; use foundry_compilers::{ artifacts::{Source, Sources}, - CompilerInput, CompilerOutput, EvmVersion, Solc, + CompilerInput, CompilerOutput, Solc, }; use foundry_config::{Config, SolcReq}; use foundry_evm::{backend::Backend, opts::EvmOpts}; @@ -105,22 +105,17 @@ impl SessionSourceConfig { match solc_req { SolcReq::Version(version) => { - // We now need to verify if the solc version provided is supported by the evm - // version set. If not, we bail and ask the user to provide a newer version. - // 1. Do we need solc 0.8.18 or higher? - let evm_version = self.foundry_config.evm_version; - let needs_post_merge_solc = evm_version >= EvmVersion::Paris; - // 2. Check if the version provided is less than 0.8.18 and bail, - // or leave it as-is if we don't need a post merge solc version or the version we - // have is good enough. - let v = if needs_post_merge_solc && version < Version::new(0, 8, 18) { - eyre::bail!("solc {version} is not supported by the set evm version: {evm_version}. Please install and use a version of solc higher or equal to 0.8.18. -You can also set the solc version in your foundry.toml.") - } else { - version.to_string() - }; + // Validate that the requested evm version is supported by the solc version + let req_evm_version = self.foundry_config.evm_version; + if let Some(compat_evm_version) = req_evm_version.normalize_version(&version) { + if req_evm_version > compat_evm_version { + eyre::bail!( + "The set evm version, {req_evm_version}, is not supported by solc {version}. Upgrade to a newer solc version." + ); + } + } - let mut solc = Solc::find_svm_installed_version(&v)?; + let mut solc = Solc::find_svm_installed_version(version.to_string())?; if solc.is_none() { if self.foundry_config.offline { @@ -131,7 +126,7 @@ You can also set the solc version in your foundry.toml.") Paint::green(format!("Installing solidity version {version}...")) ); Solc::blocking_install(&version)?; - solc = Solc::find_svm_installed_version(&v)?; + solc = Solc::find_svm_installed_version(version.to_string())?; } solc.ok_or_else(|| eyre::eyre!("Failed to install {version}")) } diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index 9173e8bc791df..c6b9625ebd7c3 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -1,6 +1,6 @@ use chisel::session::ChiselSession; use foundry_compilers::EvmVersion; -use foundry_config::Config; +use foundry_config::{Config, SolcReq}; use serial_test::serial; use std::path::Path; @@ -220,3 +220,27 @@ fn test_load_latest_cache() { assert_eq!(new_env.id.unwrap(), "1"); assert_eq!(new_env.session_source.to_repl_source(), env.session_source.to_repl_source()); } + +#[test] +#[serial] +fn test_solc_evm_configuration_mismatch() { + // Create and clear the cache directory + ChiselSession::create_cache_dir().unwrap(); + ChiselSession::clear_cache().unwrap(); + + // Force the solc version to be 0.8.13 which does not support Paris + let foundry_config = Config { + evm_version: EvmVersion::Paris, + solc: Some(SolcReq::Version("0.8.13".parse().expect("invalid semver"))), + ..Default::default() + }; + + // Create a new session that is expected to fail + let error = ChiselSession::new(chisel::session_source::SessionSourceConfig { + foundry_config, + ..Default::default() + }) + .unwrap_err(); + + assert_eq!(error.to_string(), "The set evm version, paris, is not supported by solc 0.8.13. Upgrade to a newer solc version."); +} From 0b63398e69522bb25562b0646afbaa874c99c1c3 Mon Sep 17 00:00:00 2001 From: Bjerg Date: Tue, 6 Feb 2024 13:34:38 +0100 Subject: [PATCH 0582/1963] chore: pin nightly (#7020) --- .github/workflows/test.yml | 277 +++++++++++++++++++------------------ 1 file changed, 140 insertions(+), 137 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fda10266fcc78..669002cb01346 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,154 +1,157 @@ name: test on: - push: - branches: - - master - pull_request: + push: + branches: + - master + pull_request: concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true env: - CARGO_TERM_COLOR: always + CARGO_TERM_COLOR: always jobs: - matrices: - name: build matrices - runs-on: ubuntu-latest - outputs: - test-matrix: ${{ steps.gen.outputs.test-matrix }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - name: Generate matrices - id: gen - env: - EVENT_NAME: ${{ github.event_name }} - run: | - output=$(python3 .github/scripts/matrices.py) - echo "::debug::test-matrix=$output" - echo "test-matrix=$output" >> $GITHUB_OUTPUT - - test: - name: test ${{ matrix.name }} - runs-on: ${{ matrix.runner_label }} - timeout-minutes: 60 - needs: matrices - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} + matrices: + name: build matrices + runs-on: ubuntu-latest + outputs: + test-matrix: ${{ steps.gen.outputs.test-matrix }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Generate matrices + id: gen env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - target: ${{ matrix.target }} - - uses: taiki-e/install-action@nextest + EVENT_NAME: ${{ github.event_name }} + run: | + output=$(python3 .github/scripts/matrices.py) + echo "::debug::test-matrix=$output" + echo "test-matrix=$output" >> $GITHUB_OUTPUT + + test: + name: test ${{ matrix.name }} + runs-on: ${{ matrix.runner_label }} + timeout-minutes: 60 + needs: matrices + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} + env: + ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + target: ${{ matrix.target }} + - uses: taiki-e/install-action@nextest - # External tests dependencies - - name: Setup Node.js - if: contains(matrix.name, 'external') - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Install Bun - if: contains(matrix.name, 'external') && !contains(matrix.runner_label, 'windows') - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - name: Setup Python - if: contains(matrix.name, 'external') - uses: actions/setup-python@v4 - with: - python-version: 3.11 - - name: Install Vyper - if: contains(matrix.name, 'external') - run: pip install vyper + # External tests dependencies + - name: Setup Node.js + if: contains(matrix.name, 'external') + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install Bun + if: contains(matrix.name, 'external') && !contains(matrix.runner_label, 'windows') + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Setup Python + if: contains(matrix.name, 'external') + uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: Install Vyper + if: contains(matrix.name, 'external') + run: pip install vyper - - name: Forge RPC cache - uses: actions/cache@v3 - with: - path: | - ~/.foundry/cache - ~/.config/.foundry/cache - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Setup Git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - git config --global url."https://github.com/".insteadOf "git@github.com:" - - name: Test - env: - SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} - run: cargo nextest run ${{ matrix.flags }} + - name: Forge RPC cache + uses: actions/cache@v3 + with: + path: | + ~/.foundry/cache + ~/.config/.foundry/cache + key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Setup Git config + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "<>" + git config --global url."https://github.com/".insteadOf "git@github.com:" + - name: Test + env: + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + run: cargo nextest run ${{ matrix.flags }} - doctest: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - run: cargo test --workspace --doc + doctest: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: cargo test --workspace --doc - clippy: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@clippy - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - run: cargo clippy --workspace --all-targets --all-features - env: - RUSTFLAGS: -Dwarnings + clippy: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@clippy + with: + toolchain: nightly-2024-02-03 + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: cargo clippy --workspace --all-targets --all-features + env: + RUSTFLAGS: -Dwarnings - rustfmt: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - run: cargo fmt --all --check + rustfmt: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2024-02-03 + components: rustfmt + - run: cargo fmt --all --check - forge-fmt: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: forge fmt - shell: bash - # We have to ignore at shell level because testdata/ is not a valid Foundry project, - # so running `forge fmt` with `--root testdata` won't actually check anything - run: | - shopt -s extglob - cargo run --bin forge -- fmt --check testdata/**/!(Vm).sol + forge-fmt: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: forge fmt + shell: bash + # We have to ignore at shell level because testdata/ is not a valid Foundry project, + # so running `forge fmt` with `--root testdata` won't actually check anything + run: | + shopt -s extglob + cargo run --bin forge -- fmt --check testdata/**/!(Vm).sol - crate-checks: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: taiki-e/install-action@cargo-hack - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - run: cargo hack check + crate-checks: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@cargo-hack + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: cargo hack check From 865a0d1f2d082c2d1d1314e0c2afb153751e29b4 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 6 Feb 2024 11:24:43 -0400 Subject: [PATCH 0583/1963] chore(cast): improve cast wallet new (#7021) --- crates/cast/bin/cmd/wallet/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 6a026904dcbab..2018c4420a8f6 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -152,7 +152,14 @@ impl WalletSubcommands { let mut json_values = if json { Some(vec![]) } else { None }; if let Some(path) = path { - let path = dunce::canonicalize(path)?; + let path = match dunce::canonicalize(path.clone()) { + Ok(path) => path, + // If the path doesn't exist, it will fail to be canonicalized, + // so we attach more context to the error message. + Err(e) => { + eyre::bail!("If you specified a directory, please make sure it exists, or create it before running `cast wallet new `.\n{path} is not a directory.\nError: {}", e); + } + }; if !path.is_dir() { // we require path to be an existing directory eyre::bail!("`{}` is not a directory", path.display()); From 2cf84d9f3ba7b6f4a9296299e7036ecc24cfa1da Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 6 Feb 2024 18:59:34 +0200 Subject: [PATCH 0584/1963] test: add `Command::debug_assert` tests to CLIs (#7024) --- crates/anvil/src/anvil.rs | 34 +++++--- crates/cast/bin/main.rs | 170 +++++++++++++++++++------------------- crates/cast/bin/opts.rs | 30 ++++--- crates/chisel/bin/main.rs | 37 ++++++--- crates/forge/bin/main.rs | 66 +++++++-------- crates/forge/bin/opts.rs | 17 +++- 6 files changed, 195 insertions(+), 159 deletions(-) diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index c969c09420c1f..5ff9394821d87 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -3,18 +3,18 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; /// A fast local Ethereum development node. -#[derive(Debug, Parser)] +#[derive(Parser)] #[clap(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] -pub struct App { +pub struct Anvil { #[clap(flatten)] pub node: NodeArgs, #[clap(subcommand)] - pub cmd: Option, + pub cmd: Option, } -#[derive(Clone, Debug, PartialEq, Eq, Subcommand)] -pub enum Commands { +#[derive(Subcommand)] +pub enum AnvilSubcommand { /// Generate shell completions script. #[clap(visible_alias = "com")] Completions { @@ -29,22 +29,22 @@ pub enum Commands { #[tokio::main] async fn main() -> Result<(), Box> { - let mut app = App::parse(); + let mut app = Anvil::parse(); app.node.evm_opts.resolve_rpc_alias(); if let Some(ref cmd) = app.cmd { match cmd { - Commands::Completions { shell } => { + AnvilSubcommand::Completions { shell } => { clap_complete::generate( *shell, - &mut App::command(), + &mut Anvil::command(), "anvil", &mut std::io::stdout(), ); } - Commands::GenerateFigSpec => clap_complete::generate( + AnvilSubcommand::GenerateFigSpec => clap_complete::generate( clap_complete_fig::Fig, - &mut App::command(), + &mut Anvil::command(), "anvil", &mut std::io::stdout(), ), @@ -62,14 +62,22 @@ async fn main() -> Result<(), Box> { mod tests { use super::*; + #[test] + fn verify_cli() { + Anvil::command().debug_assert(); + } + #[test] fn can_parse_help() { - let _: App = App::parse_from(["anvil", "--help"]); + let _: Anvil = Anvil::parse_from(["anvil", "--help"]); } #[test] fn can_parse_completions() { - let args: App = App::parse_from(["anvil", "completions", "bash"]); - assert_eq!(args.cmd, Some(Commands::Completions { shell: clap_complete::Shell::Bash })); + let args: Anvil = Anvil::parse_from(["anvil", "completions", "bash"]); + assert!(matches!( + args.cmd, + Some(AnvilSubcommand::Completions { shell: clap_complete::Shell::Bash }) + )); } } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 9c992e7667f25..c4ee0e56388eb 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -27,7 +27,7 @@ use std::time::Instant; pub mod cmd; pub mod opts; -use opts::{Opts, Subcommands, ToBaseArgs}; +use opts::{Cast as Opts, CastSubcommand, ToBaseArgs}; #[tokio::main] async fn main() -> Result<()> { @@ -37,42 +37,42 @@ async fn main() -> Result<()> { utils::enable_paint(); let opts = Opts::parse(); - match opts.sub { + match opts.cmd { // Constants - Subcommands::MaxInt { r#type } => { + CastSubcommand::MaxInt { r#type } => { println!("{}", SimpleCast::max_int(&r#type)?); } - Subcommands::MinInt { r#type } => { + CastSubcommand::MinInt { r#type } => { println!("{}", SimpleCast::min_int(&r#type)?); } - Subcommands::MaxUint { r#type } => { + CastSubcommand::MaxUint { r#type } => { println!("{}", SimpleCast::max_int(&r#type)?); } - Subcommands::AddressZero => { + CastSubcommand::AddressZero => { println!("{:?}", Address::ZERO); } - Subcommands::HashZero => { + CastSubcommand::HashZero => { println!("{:?}", B256::ZERO); } // Conversions & transformations - Subcommands::FromUtf8 { text } => { + CastSubcommand::FromUtf8 { text } => { let value = stdin::unwrap(text, false)?; println!("{}", SimpleCast::from_utf8(&value)); } - Subcommands::ToAscii { hexdata } => { + CastSubcommand::ToAscii { hexdata } => { let value = stdin::unwrap(hexdata, false)?; println!("{}", SimpleCast::to_ascii(&value)?); } - Subcommands::FromFixedPoint { value, decimals } => { + CastSubcommand::FromFixedPoint { value, decimals } => { let (value, decimals) = stdin::unwrap2(value, decimals)?; println!("{}", SimpleCast::from_fixed_point(&value, &decimals)?); } - Subcommands::ToFixedPoint { value, decimals } => { + CastSubcommand::ToFixedPoint { value, decimals } => { let (value, decimals) = stdin::unwrap2(value, decimals)?; println!("{}", SimpleCast::to_fixed_point(&value, &decimals)?); } - Subcommands::ConcatHex { data } => { + CastSubcommand::ConcatHex { data } => { if data.is_empty() { let s = stdin::read(true)?; println!("{}", SimpleCast::concat_hex(s.split_whitespace())) @@ -80,11 +80,11 @@ async fn main() -> Result<()> { println!("{}", SimpleCast::concat_hex(data)) } } - Subcommands::FromBin => { + CastSubcommand::FromBin => { let hex = stdin::read_bytes(false)?; println!("{}", hex::encode_prefixed(hex)); } - Subcommands::ToHexdata { input } => { + CastSubcommand::ToHexdata { input } => { let value = stdin::unwrap_line(input)?; let output = match value { s if s.starts_with('@') => hex::encode(std::env::var(&s[1..])?), @@ -93,91 +93,91 @@ async fn main() -> Result<()> { }; println!("0x{output}"); } - Subcommands::ToCheckSumAddress { address } => { + CastSubcommand::ToCheckSumAddress { address } => { let value = stdin::unwrap_line(address)?; println!("{}", value.to_checksum(None)); } - Subcommands::ToUint256 { value } => { + CastSubcommand::ToUint256 { value } => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::to_uint256(&value)?); } - Subcommands::ToInt256 { value } => { + CastSubcommand::ToInt256 { value } => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::to_int256(&value)?); } - Subcommands::ToUnit { value, unit } => { + CastSubcommand::ToUnit { value, unit } => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::to_unit(&value, &unit)?); } - Subcommands::FromWei { value, unit } => { + CastSubcommand::FromWei { value, unit } => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::from_wei(&value, &unit)?); } - Subcommands::ToWei { value, unit } => { + CastSubcommand::ToWei { value, unit } => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::to_wei(&value, &unit)?); } - Subcommands::FromRlp { value } => { + CastSubcommand::FromRlp { value } => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::from_rlp(value)?); } - Subcommands::ToRlp { value } => { + CastSubcommand::ToRlp { value } => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::to_rlp(&value)?); } - Subcommands::ToHex(ToBaseArgs { value, base_in }) => { + CastSubcommand::ToHex(ToBaseArgs { value, base_in }) => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "hex")?); } - Subcommands::ToDec(ToBaseArgs { value, base_in }) => { + CastSubcommand::ToDec(ToBaseArgs { value, base_in }) => { let value = stdin::unwrap_line(value)?; println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "dec")?); } - Subcommands::ToBase { base: ToBaseArgs { value, base_in }, base_out } => { + CastSubcommand::ToBase { base: ToBaseArgs { value, base_in }, base_out } => { let (value, base_out) = stdin::unwrap2(value, base_out)?; println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), &base_out)?); } - Subcommands::ToBytes32 { bytes } => { + CastSubcommand::ToBytes32 { bytes } => { let value = stdin::unwrap_line(bytes)?; println!("{}", SimpleCast::to_bytes32(&value)?); } - Subcommands::FormatBytes32String { string } => { + CastSubcommand::FormatBytes32String { string } => { let value = stdin::unwrap_line(string)?; println!("{}", SimpleCast::format_bytes32_string(&value)?); } - Subcommands::ParseBytes32String { bytes } => { + CastSubcommand::ParseBytes32String { bytes } => { let value = stdin::unwrap_line(bytes)?; println!("{}", SimpleCast::parse_bytes32_string(&value)?); } - Subcommands::ParseBytes32Address { bytes } => { + CastSubcommand::ParseBytes32Address { bytes } => { let value = stdin::unwrap_line(bytes)?; println!("{}", SimpleCast::parse_bytes32_address(&value)?); } // ABI encoding & decoding - Subcommands::AbiDecode { sig, calldata, input } => { + CastSubcommand::AbiDecode { sig, calldata, input } => { let tokens = SimpleCast::abi_decode(&sig, &calldata, input)?; let tokens = format_tokens(&tokens); tokens.for_each(|t| println!("{t}")); } - Subcommands::AbiEncode { sig, args } => { + CastSubcommand::AbiEncode { sig, args } => { println!("{}", SimpleCast::abi_encode(&sig, &args)?); } - Subcommands::CalldataDecode { sig, calldata } => { + CastSubcommand::CalldataDecode { sig, calldata } => { let tokens = SimpleCast::calldata_decode(&sig, &calldata, true)?; let tokens = format_tokens(&tokens); tokens.for_each(|t| println!("{t}")); } - Subcommands::CalldataEncode { sig, args } => { + CastSubcommand::CalldataEncode { sig, args } => { println!("{}", SimpleCast::calldata_encode(sig, &args)?); } - Subcommands::Interface(cmd) => cmd.run().await?, - Subcommands::Bind(cmd) => cmd.run().await?, - Subcommands::PrettyCalldata { calldata, offline } => { + CastSubcommand::Interface(cmd) => cmd.run().await?, + CastSubcommand::Bind(cmd) => cmd.run().await?, + CastSubcommand::PrettyCalldata { calldata, offline } => { let calldata = stdin::unwrap_line(calldata)?; println!("{}", pretty_calldata(&calldata, offline).await?); } - Subcommands::Sig { sig, optimize } => { + CastSubcommand::Sig { sig, optimize } => { let sig = stdin::unwrap_line(sig)?; match optimize { Some(opt) => { @@ -193,8 +193,8 @@ async fn main() -> Result<()> { } // Blockchain & RPC queries - Subcommands::AccessList(cmd) => cmd.run().await?, - Subcommands::Age { block, rpc } => { + CastSubcommand::AccessList(cmd) => cmd.run().await?, + CastSubcommand::Age { block, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!( @@ -202,7 +202,7 @@ async fn main() -> Result<()> { Cast::new(provider).age(block.unwrap_or(BlockId::Number(Latest))).await? ); } - Subcommands::Balance { block, who, ether, rpc, erc20 } => { + CastSubcommand::Balance { block, who, ether, rpc, erc20 } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; @@ -242,7 +242,7 @@ async fn main() -> Result<()> { } } } - Subcommands::BaseFee { block, rpc } => { + CastSubcommand::BaseFee { block, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!( @@ -250,7 +250,7 @@ async fn main() -> Result<()> { Cast::new(provider).base_fee(block.unwrap_or(BlockId::Number(Latest))).await? ); } - Subcommands::Block { block, full, field, json, rpc } => { + CastSubcommand::Block { block, full, field, json, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!( @@ -260,37 +260,37 @@ async fn main() -> Result<()> { .await? ); } - Subcommands::BlockNumber { rpc } => { + CastSubcommand::BlockNumber { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).block_number().await?); } - Subcommands::Chain { rpc } => { + CastSubcommand::Chain { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).chain().await?); } - Subcommands::ChainId { rpc } => { + CastSubcommand::ChainId { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).chain_id().await?); } - Subcommands::Client { rpc } => { + CastSubcommand::Client { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", provider.client_version().await?); } - Subcommands::Code { block, who, disassemble, rpc } => { + CastSubcommand::Code { block, who, disassemble, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).code(who, block, disassemble).await?); } - Subcommands::Codesize { block, who, rpc } => { + CastSubcommand::Codesize { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).codesize(who, block).await?); } - Subcommands::ComputeAddress { address, nonce, rpc } => { + CastSubcommand::ComputeAddress { address, nonce, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; @@ -298,10 +298,10 @@ async fn main() -> Result<()> { let computed = Cast::new(&provider).compute_address(address, nonce).await?; println!("Computed Address: {}", computed.to_checksum(None)); } - Subcommands::Disassemble { bytecode } => { + CastSubcommand::Disassemble { bytecode } => { println!("{}", SimpleCast::disassemble(&bytecode)?); } - Subcommands::Selectors { bytecode, resolve } => { + CastSubcommand::Selectors { bytecode, resolve } => { let selectors_and_args = SimpleCast::extract_selectors(&bytecode)?; if resolve { let selectors_it = selectors_and_args.iter().map(|r| &r.0); @@ -324,31 +324,31 @@ async fn main() -> Result<()> { } } } - Subcommands::FindBlock(cmd) => cmd.run().await?, - Subcommands::GasPrice { rpc } => { + CastSubcommand::FindBlock(cmd) => cmd.run().await?, + CastSubcommand::GasPrice { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).gas_price().await?); } - Subcommands::Index { key_type, key, slot_number } => { + CastSubcommand::Index { key_type, key, slot_number } => { println!("{}", SimpleCast::index(&key_type, &key, &slot_number)?); } - Subcommands::Implementation { block, who, rpc } => { + CastSubcommand::Implementation { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).implementation(who, block).await?); } - Subcommands::Admin { block, who, rpc } => { + CastSubcommand::Admin { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).admin(who, block).await?); } - Subcommands::Nonce { block, who, rpc } => { + CastSubcommand::Nonce { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!("{}", Cast::new(provider).nonce(who, block).await?); } - Subcommands::Proof { address, slots, rpc, block } => { + CastSubcommand::Proof { address, slots, rpc, block } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let value = provider @@ -356,13 +356,13 @@ async fn main() -> Result<()> { .await?; println!("{}", serde_json::to_string(&value)?); } - Subcommands::Rpc(cmd) => cmd.run().await?, - Subcommands::Storage(cmd) => cmd.run().await?, + CastSubcommand::Rpc(cmd) => cmd.run().await?, + CastSubcommand::Storage(cmd) => cmd.run().await?, // Calls & transactions - Subcommands::Call(cmd) => cmd.run().await?, - Subcommands::Estimate(cmd) => cmd.run().await?, - Subcommands::PublishTx { raw_tx, cast_async, rpc } => { + CastSubcommand::Call(cmd) => cmd.run().await?, + CastSubcommand::Estimate(cmd) => cmd.run().await?, + CastSubcommand::PublishTx { raw_tx, cast_async, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let cast = Cast::new(&provider); @@ -377,7 +377,7 @@ async fn main() -> Result<()> { println!("{}", serde_json::json!(receipt)); } } - Subcommands::Receipt { tx_hash, field, json, cast_async, confirmations, rpc } => { + CastSubcommand::Receipt { tx_hash, field, json, cast_async, confirmations, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; println!( @@ -387,9 +387,9 @@ async fn main() -> Result<()> { .await? ); } - Subcommands::Run(cmd) => cmd.run().await?, - Subcommands::SendTx(cmd) => cmd.run().await?, - Subcommands::Tx { tx_hash, field, raw, json, rpc } => { + CastSubcommand::Run(cmd) => cmd.run().await?, + CastSubcommand::SendTx(cmd) => cmd.run().await?, + CastSubcommand::Tx { tx_hash, field, raw, json, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; @@ -400,7 +400,7 @@ async fn main() -> Result<()> { } // 4Byte - Subcommands::FourByte { selector } => { + CastSubcommand::FourByte { selector } => { let selector = stdin::unwrap_line(selector)?; let sigs = decode_function_selector(&selector).await?; if sigs.is_empty() { @@ -410,7 +410,7 @@ async fn main() -> Result<()> { println!("{sig}"); } } - Subcommands::FourByteDecode { calldata } => { + CastSubcommand::FourByteDecode { calldata } => { let calldata = stdin::unwrap_line(calldata)?; let sigs = decode_calldata(&calldata).await?; sigs.iter().enumerate().for_each(|(i, sig)| println!("{}) \"{sig}\"", i + 1)); @@ -429,7 +429,7 @@ async fn main() -> Result<()> { println!("{token}"); } } - Subcommands::FourByteEvent { topic } => { + CastSubcommand::FourByteEvent { topic } => { let topic = stdin::unwrap_line(topic)?; let sigs = decode_event_topic(&topic).await?; if sigs.is_empty() { @@ -439,7 +439,7 @@ async fn main() -> Result<()> { println!("{sig}"); } } - Subcommands::UploadSignature { signatures } => { + CastSubcommand::UploadSignature { signatures } => { let signatures = stdin::unwrap_vec(signatures)?; let ParsedSignatures { signatures, abis } = parse_signatures(signatures); if !abis.is_empty() { @@ -451,11 +451,11 @@ async fn main() -> Result<()> { } // ENS - Subcommands::Namehash { name } => { + CastSubcommand::Namehash { name } => { let name = stdin::unwrap_line(name)?; println!("{}", SimpleCast::namehash(&name)?); } - Subcommands::LookupAddress { who, rpc, verify } => { + CastSubcommand::LookupAddress { who, rpc, verify } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; @@ -470,7 +470,7 @@ async fn main() -> Result<()> { } println!("{name}"); } - Subcommands::ResolveName { who, rpc, verify } => { + CastSubcommand::ResolveName { who, rpc, verify } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; @@ -487,7 +487,7 @@ async fn main() -> Result<()> { } // Misc - Subcommands::Keccak { data } => { + CastSubcommand::Keccak { data } => { let bytes = match data { Some(data) => data.into_bytes(), None => stdin::read_bytes(false)?, @@ -504,18 +504,18 @@ async fn main() -> Result<()> { } }; } - Subcommands::SigEvent { event_string } => { + CastSubcommand::SigEvent { event_string } => { let event_string = stdin::unwrap_line(event_string)?; let parsed_event = get_event(&event_string)?; println!("{:?}", parsed_event.selector()); } - Subcommands::LeftShift { value, bits, base_in, base_out } => { + CastSubcommand::LeftShift { value, bits, base_in, base_out } => { println!("{}", SimpleCast::left_shift(&value, &bits, base_in.as_deref(), &base_out)?); } - Subcommands::RightShift { value, bits, base_in, base_out } => { + CastSubcommand::RightShift { value, bits, base_in, base_out } => { println!("{}", SimpleCast::right_shift(&value, &bits, base_in.as_deref(), &base_out)?); } - Subcommands::EtherscanSource { address, directory, etherscan } => { + CastSubcommand::EtherscanSource { address, directory, etherscan } => { let config = Config::from(ðerscan); let chain = config.chain.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); @@ -529,21 +529,21 @@ async fn main() -> Result<()> { } } } - Subcommands::Create2(cmd) => { + CastSubcommand::Create2(cmd) => { cmd.run()?; } - Subcommands::Wallet { command } => command.run().await?, - Subcommands::Completions { shell } => { + CastSubcommand::Wallet { command } => command.run().await?, + CastSubcommand::Completions { shell } => { generate(shell, &mut Opts::command(), "cast", &mut std::io::stdout()) } - Subcommands::GenerateFigSpec => clap_complete::generate( + CastSubcommand::GenerateFigSpec => clap_complete::generate( clap_complete_fig::Fig, &mut Opts::command(), "cast", &mut std::io::stdout(), ), - Subcommands::Logs(cmd) => cmd.run().await?, - Subcommands::DecodeTransaction { tx } => { + CastSubcommand::Logs(cmd) => cmd.run().await?, + CastSubcommand::DecodeTransaction { tx } => { let tx = stdin::unwrap_line(tx)?; let (tx, sig) = SimpleCast::decode_raw_transaction(&tx)?; diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 89ef6f96744a4..2f09c2534830d 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -27,13 +27,13 @@ const VERSION_MESSAGE: &str = concat!( after_help = "Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html", next_display_order = None, )] -pub struct Opts { +pub struct Cast { #[clap(subcommand)] - pub sub: Subcommands, + pub cmd: CastSubcommand, } #[derive(Subcommand)] -pub enum Subcommands { +pub enum CastSubcommand { /// Prints the maximum value of the given integer type. #[clap(visible_aliases = &["--max-int", "maxi"])] MaxInt { @@ -898,11 +898,17 @@ pub fn parse_slot(s: &str) -> Result { mod tests { use super::*; use cast::SimpleCast; + use clap::CommandFactory; use ethers_core::types::BlockNumber; + #[test] + fn verify_cli() { + Cast::command().debug_assert(); + } + #[test] fn parse_proof_slot() { - let args: Opts = Opts::parse_from([ + let args: Cast = Cast::parse_from([ "foundry-cli", "proof", "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", @@ -912,8 +918,8 @@ mod tests { "0x1", "0x01", ]); - match args.sub { - Subcommands::Proof { slots, .. } => { + match args.cmd { + CastSubcommand::Proof { slots, .. } => { assert_eq!( slots, vec![ @@ -931,15 +937,15 @@ mod tests { #[test] fn parse_call_data() { - let args: Opts = Opts::parse_from([ + let args: Cast = Cast::parse_from([ "foundry-cli", "calldata", "f()", "5c9d55b78febcc2061715ba4f57ecf8ea2711f2c", "2", ]); - match args.sub { - Subcommands::CalldataEncode { args, .. } => { + match args.cmd { + CastSubcommand::CalldataEncode { args, .. } => { assert_eq!( args, vec!["5c9d55b78febcc2061715ba4f57ecf8ea2711f2c".to_string(), "2".to_string()] @@ -952,13 +958,13 @@ mod tests { // #[test] fn parse_signature() { - let args: Opts = Opts::parse_from([ + let args: Cast = Cast::parse_from([ "foundry-cli", "sig", "__$_$__$$$$$__$$_$$$_$$__$$___$$(address,address,uint256)", ]); - match args.sub { - Subcommands::Sig { sig, .. } => { + match args.cmd { + CastSubcommand::Sig { sig, .. } => { let sig = sig.unwrap(); assert_eq!( sig, diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index d9028965a6270..9da885860b62f 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -7,7 +7,7 @@ use chisel::{ history::chisel_history_file, prelude::{ChiselCommand, ChiselDispatcher, DispatchResult, SolidityHelper}, }; -use clap::Parser; +use clap::{Parser, Subcommand}; use eyre::Context; use foundry_cli::{ handler, @@ -28,7 +28,7 @@ use tracing::debug; use yansi::Paint; // Loads project's figment and merges the build cli arguments into it -foundry_config::merge_impl_figment_convert!(ChiselParser, opts, evm_opts); +foundry_config::merge_impl_figment_convert!(Chisel, opts, evm_opts); const VERSION_MESSAGE: &str = concat!( env!("CARGO_PKG_VERSION"), @@ -42,9 +42,9 @@ const VERSION_MESSAGE: &str = concat!( /// Fast, utilitarian, and verbose Solidity REPL. #[derive(Debug, Parser)] #[clap(name = "chisel", version = VERSION_MESSAGE)] -pub struct ChiselParser { +pub struct Chisel { #[command(subcommand)] - pub sub: Option, + pub cmd: Option, /// Path to a directory containing Solidity files to import, or path to a single Solidity file. /// @@ -69,8 +69,8 @@ pub struct ChiselParser { } /// Chisel binary subcommands -#[derive(Debug, clap::Subcommand)] -pub enum ChiselParserSub { +#[derive(Debug, Subcommand)] +pub enum ChiselSubcommand { /// List all cached sessions List, @@ -102,7 +102,7 @@ async fn main() -> eyre::Result<()> { utils::load_dotenv(); // Parse command args - let args = ChiselParser::parse(); + let args = Chisel::parse(); // Keeps track of whether or not an interrupt was the last input let mut interrupt = false; @@ -125,8 +125,8 @@ async fn main() -> eyre::Result<()> { evaluate_prelude(&mut dispatcher, args.prelude).await?; // Check for chisel subcommands - match &args.sub { - Some(ChiselParserSub::List) => { + match &args.cmd { + Some(ChiselSubcommand::List) => { let sessions = dispatcher.dispatch_command(ChiselCommand::ListSessions, &[]).await; match sessions { DispatchResult::CommandSuccess(Some(session_list)) => { @@ -137,7 +137,7 @@ async fn main() -> eyre::Result<()> { } return Ok(()) } - Some(ChiselParserSub::Load { id }) | Some(ChiselParserSub::View { id }) => { + Some(ChiselSubcommand::Load { id }) | Some(ChiselSubcommand::View { id }) => { // For both of these subcommands, we need to attempt to load the session from cache match dispatcher.dispatch_command(ChiselCommand::Load, &[id]).await { DispatchResult::CommandSuccess(_) => { /* Continue */ } @@ -149,7 +149,7 @@ async fn main() -> eyre::Result<()> { } // If the subcommand was `view`, print the source and exit. - if matches!(args.sub, Some(ChiselParserSub::View { .. })) { + if matches!(args.cmd, Some(ChiselSubcommand::View { .. })) { match dispatcher.dispatch_command(ChiselCommand::Source, &[]).await { DispatchResult::CommandSuccess(Some(source)) => { println!("{source}"); @@ -159,7 +159,7 @@ async fn main() -> eyre::Result<()> { return Ok(()) } } - Some(ChiselParserSub::ClearCache) => { + Some(ChiselSubcommand::ClearCache) => { match dispatcher.dispatch_command(ChiselCommand::ClearCache, &[]).await { DispatchResult::CommandSuccess(Some(msg)) => println!("{}", Paint::green(msg)), DispatchResult::CommandFailed(e) => eprintln!("{e}"), @@ -229,7 +229,7 @@ async fn main() -> eyre::Result<()> { } /// [Provider] impl -impl Provider for ChiselParser { +impl Provider for Chisel { fn metadata(&self) -> Metadata { Metadata::named("Script Args Provider") } @@ -294,3 +294,14 @@ async fn load_prelude_file(dispatcher: &mut ChiselDispatcher, file: PathBuf) -> dispatch_repl_line(dispatcher, &prelude).await; Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + use clap::CommandFactory; + + #[test] + fn verify_cli() { + Chisel::command().debug_assert(); + } +} diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 819c82f430ce9..5fdc7c408a830 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -10,7 +10,7 @@ mod cmd; mod opts; use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; -use opts::{Opts, Subcommands}; +use opts::{Forge, ForgeSubcommand}; fn main() -> Result<()> { handler::install(); @@ -18,9 +18,9 @@ fn main() -> Result<()> { utils::subscriber(); utils::enable_paint(); - let opts = Opts::parse(); - match opts.sub { - Subcommands::Test(cmd) => { + let opts = Forge::parse(); + match opts.cmd { + ForgeSubcommand::Test(cmd) => { if cmd.is_watch() { utils::block_on(watch::watch_test(cmd)) } else { @@ -28,7 +28,7 @@ fn main() -> Result<()> { outcome.ensure_ok() } } - Subcommands::Script(cmd) => { + ForgeSubcommand::Script(cmd) => { // install the shell before executing the command foundry_common::shell::set_shell(foundry_common::shell::Shell::from_args( cmd.opts.args.silent, @@ -36,59 +36,59 @@ fn main() -> Result<()> { ))?; utils::block_on(cmd.run_script()) } - Subcommands::Coverage(cmd) => utils::block_on(cmd.run()), - Subcommands::Bind(cmd) => cmd.run(), - Subcommands::Build(cmd) => { + ForgeSubcommand::Coverage(cmd) => utils::block_on(cmd.run()), + ForgeSubcommand::Bind(cmd) => cmd.run(), + ForgeSubcommand::Build(cmd) => { if cmd.is_watch() { utils::block_on(watch::watch_build(cmd)) } else { cmd.run().map(|_| ()) } } - Subcommands::Debug(cmd) => utils::block_on(cmd.run()), - Subcommands::VerifyContract(args) => utils::block_on(args.run()), - Subcommands::VerifyCheck(args) => utils::block_on(args.run()), - Subcommands::Cache(cmd) => match cmd.sub { + ForgeSubcommand::Debug(cmd) => utils::block_on(cmd.run()), + ForgeSubcommand::VerifyContract(args) => utils::block_on(args.run()), + ForgeSubcommand::VerifyCheck(args) => utils::block_on(args.run()), + ForgeSubcommand::Cache(cmd) => match cmd.sub { CacheSubcommands::Clean(cmd) => cmd.run(), CacheSubcommands::Ls(cmd) => cmd.run(), }, - Subcommands::Create(cmd) => utils::block_on(cmd.run()), - Subcommands::Update(cmd) => cmd.run(), - Subcommands::Install(cmd) => cmd.run(), - Subcommands::Remove(cmd) => cmd.run(), - Subcommands::Remappings(cmd) => cmd.run(), - Subcommands::Init(cmd) => cmd.run(), - Subcommands::Completions { shell } => { - generate(shell, &mut Opts::command(), "forge", &mut std::io::stdout()); + ForgeSubcommand::Create(cmd) => utils::block_on(cmd.run()), + ForgeSubcommand::Update(cmd) => cmd.run(), + ForgeSubcommand::Install(cmd) => cmd.run(), + ForgeSubcommand::Remove(cmd) => cmd.run(), + ForgeSubcommand::Remappings(cmd) => cmd.run(), + ForgeSubcommand::Init(cmd) => cmd.run(), + ForgeSubcommand::Completions { shell } => { + generate(shell, &mut Forge::command(), "forge", &mut std::io::stdout()); Ok(()) } - Subcommands::GenerateFigSpec => { + ForgeSubcommand::GenerateFigSpec => { clap_complete::generate( clap_complete_fig::Fig, - &mut Opts::command(), + &mut Forge::command(), "forge", &mut std::io::stdout(), ); Ok(()) } - Subcommands::Clean { root } => { + ForgeSubcommand::Clean { root } => { let config = utils::load_config_with_root(root); config.project()?.cleanup()?; Ok(()) } - Subcommands::Snapshot(cmd) => { + ForgeSubcommand::Snapshot(cmd) => { if cmd.is_watch() { utils::block_on(watch::watch_snapshot(cmd)) } else { utils::block_on(cmd.run()) } } - Subcommands::Fmt(cmd) => cmd.run(), - Subcommands::Config(cmd) => cmd.run(), - Subcommands::Flatten(cmd) => cmd.run(), - Subcommands::Inspect(cmd) => cmd.run(), - Subcommands::Tree(cmd) => cmd.run(), - Subcommands::Geiger(cmd) => { + ForgeSubcommand::Fmt(cmd) => cmd.run(), + ForgeSubcommand::Config(cmd) => cmd.run(), + ForgeSubcommand::Flatten(cmd) => cmd.run(), + ForgeSubcommand::Inspect(cmd) => cmd.run(), + ForgeSubcommand::Tree(cmd) => cmd.run(), + ForgeSubcommand::Geiger(cmd) => { let check = cmd.check; let n = cmd.run()?; if check && n > 0 { @@ -96,9 +96,9 @@ fn main() -> Result<()> { } Ok(()) } - Subcommands::Doc(cmd) => cmd.run(), - Subcommands::Selectors { command } => utils::block_on(command.run()), - Subcommands::Generate(cmd) => match cmd.sub { + ForgeSubcommand::Doc(cmd) => cmd.run(), + ForgeSubcommand::Selectors { command } => utils::block_on(command.run()), + ForgeSubcommand::Generate(cmd) => match cmd.sub { GenerateSubcommands::Test(cmd) => cmd.run(), }, } diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 3b9c48680e292..e62ac19083dce 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -39,14 +39,14 @@ const VERSION_MESSAGE: &str = concat!( after_help = "Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html", next_display_order = None, )] -pub struct Opts { +pub struct Forge { #[clap(subcommand)] - pub sub: Subcommands, + pub cmd: ForgeSubcommand, } #[derive(Subcommand)] #[allow(clippy::large_enum_variant)] -pub enum Subcommands { +pub enum ForgeSubcommand { /// Run the project's tests. #[clap(visible_alias = "t")] Test(test::TestArgs), @@ -168,3 +168,14 @@ pub enum Subcommands { /// Generate scaffold files. Generate(generate::GenerateArgs), } + +#[cfg(test)] +mod tests { + use super::*; + use clap::CommandFactory; + + #[test] + fn verify_cli() { + Forge::command().debug_assert(); + } +} From 8885e972b69646f0eb910cbc9dd51fb4aeda0eb0 Mon Sep 17 00:00:00 2001 From: p3nj Date: Wed, 7 Feb 2024 22:03:16 +1000 Subject: [PATCH 0585/1963] Update README.md (#7030) Add `--offline --locked` prevent cargo from fetching the latest source, will cause FeeHistory to break due to a newer update of `alloy-rs` --- crates/anvil/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/README.md b/crates/anvil/README.md index 165f6285b8999..d811bf3cebc4c 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -20,7 +20,7 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** ```sh git clone https://github.com/foundry-rs/foundry cd foundry -cargo install --path ./crates/anvil --profile local --force +cargo install --path ./crates/anvil --profile local --locked --offline --force ``` ## Getting started From 5ef0d6f22305b78ed240a7371be57108941f12cc Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 7 Feb 2024 19:33:04 +0300 Subject: [PATCH 0586/1963] feat(`cheatcodes`): `stopExpectSafeMemory` (#7028) * add cheat * fix spec --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++ crates/cheatcodes/spec/src/vm.rs | 4 +++ crates/cheatcodes/src/test/expect.rs | 8 +++++ testdata/cheats/MemSafety.t.sol | 41 ++++++++++++++++++++++++ testdata/cheats/Vm.sol | 1 + 5 files changed, 74 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 7198f615288af..c4f6cc8d738b7 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6933,6 +6933,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "stopExpectSafeMemory", + "description": "Stops all safe memory expectation in the current subcontext.", + "declaration": "function stopExpectSafeMemory() external;", + "visibility": "external", + "mutability": "", + "signature": "stopExpectSafeMemory()", + "selector": "0x0956441b", + "selectorBytes": [ + 9, + 86, + 68, + 27 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "stopMappingRecording", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 6ab18d10935b5..370c8b27a4cff 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -701,6 +701,10 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectSafeMemory(uint64 min, uint64 max) external; + /// Stops all safe memory expectation in the current subcontext. + #[cheatcode(group = Testing, safety = Unsafe)] + function stopExpectSafeMemory() external; + /// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. /// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges /// to the set. diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 002a23acd28e2..e4cc34986f5b0 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -282,6 +282,14 @@ impl Cheatcode for expectSafeMemoryCall { } } +impl Cheatcode for stopExpectSafeMemoryCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + ccx.state.allowed_mem_writes.remove(&ccx.data.journaled_state.depth()); + Ok(Default::default()) + } +} + impl Cheatcode for expectSafeMemoryCallCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { min, max } = *self; diff --git a/testdata/cheats/MemSafety.t.sol b/testdata/cheats/MemSafety.t.sol index 0da135d0c2a8a..48205233b1e34 100644 --- a/testdata/cheats/MemSafety.t.sol +++ b/testdata/cheats/MemSafety.t.sol @@ -670,6 +670,47 @@ contract MemSafetyTest is DSTest { } } + //////////////////////////////////////////////////////////////// + // `stopExpectSafeMemory` cheatcode // + //////////////////////////////////////////////////////////////// + + /// @dev Tests that the `stopExpectSafeMemory` cheatcode works as expected. + function testStopExpectSafeMemory() public { + uint64 initPtr; + assembly { + initPtr := mload(0x40) + } + + vm.expectSafeMemory(initPtr, initPtr + 0x20); + assembly { + // write to allowed range + mstore(initPtr, 0x01) + } + + vm.stopExpectSafeMemory(); + + assembly { + // write ouside allowed range, this should be fine + mstore(add(initPtr, 0x20), 0x01) + } + } + + /// @dev Tests that the `stopExpectSafeMemory` cheatcode does not cause violations not being noticed. + function testFailStopExpectSafeMemory() public { + uint64 initPtr; + assembly { + initPtr := mload(0x40) + } + + vm.expectSafeMemory(initPtr, initPtr + 0x20); + assembly { + // write outside of allowed range, this should revert + mstore(add(initPtr, 0x20), 0x01) + } + + vm.stopExpectSafeMemory(); + } + //////////////////////////////////////////////////////////////// // HELPERS // //////////////////////////////////////////////////////////////// diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index bac97febb2f91..4bc85d457ce0c 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -344,6 +344,7 @@ interface Vm { function startStateDiffRecording() external; function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses); function stopBroadcast() external; + function stopExpectSafeMemory() external; function stopMappingRecording() external; function stopPrank() external; function store(address target, bytes32 slot, bytes32 value) external; From a5efe4f8f425e2f6fb35b0e298f0f46acce11dad Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 7 Feb 2024 19:08:07 +0100 Subject: [PATCH 0587/1963] chore(deps): bump compilers 0.3.2 (#7036) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1a0e595dda0e..c7421accaecc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3104,9 +3104,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd693c0870b3817b215417ff0f2f0df02cddf296dc5524c330f99186a42cf29" +checksum = "5d88392f8b9848cfac5b11054b14e14268ae5361450bd45169df276f9af748c5" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 70b3c069e097c..9beebb39db30c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,7 @@ foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } -foundry-compilers = { version = "0.3.1", default-features = false } +foundry-compilers = { version = "0.3.2", default-features = false } ## revm # no default features to avoid c-kzg From b320f350156a0fb15c2eb13dc380deb2367c4474 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 8 Feb 2024 13:17:40 +0100 Subject: [PATCH 0588/1963] chore: improve address regex (#7037) --- crates/chisel/src/dispatcher.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 67329f89c11b4..46086f1dc56da 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -50,8 +50,10 @@ pub static CHISEL_CHAR: &str = "⚒️"; static COMMENT_RE: Lazy = Lazy::new(|| Regex::new(r"^\s*(?://.*\s*$)|(/*[\s\S]*?\*/\s*$)").unwrap()); -/// Matches Ethereum addresses -static ADDRESS_RE: Lazy = Lazy::new(|| Regex::new(r"0x[a-fA-F0-9]{40}").unwrap()); +/// Matches Ethereum addresses that are not strings +static ADDRESS_RE: Lazy = Lazy::new(|| { + Regex::new(r#"(?m)(([^"']\s*)|^)(?P
0x[a-fA-F0-9]{40})((\s*[^"'\w])|$)"#).unwrap() +}); /// Chisel input dispatcher #[derive(Debug)] @@ -786,9 +788,10 @@ impl ChiselDispatcher { // If there is an address (or multiple addresses) in the input, ensure that they are // encoded with a valid checksum per EIP-55. let mut heap_input = input.to_string(); - ADDRESS_RE.find_iter(input).for_each(|m| { + ADDRESS_RE.captures_iter(input).for_each(|m| { // Convert the match to a string slice - let match_str = m.as_str(); + let match_str = m.name("address").expect("exists").as_str(); + // We can always safely unwrap here due to the regex matching. let addr: Address = match_str.parse().expect("Valid address regex"); // Replace all occurrences of the address with a checksummed version @@ -967,4 +970,16 @@ mod tests { assert!(COMMENT_RE.is_match(" \t\n /* block \n \t comment */\n")); assert!(!COMMENT_RE.is_match("/* block \n \t comment */\nwith \tother")); } + + #[test] + fn test_address_regex() { + assert!(ADDRESS_RE.is_match("0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4")); + assert!(ADDRESS_RE.is_match(" 0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4 ")); + assert!(ADDRESS_RE.is_match("0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4,")); + assert!(ADDRESS_RE.is_match("(0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4)")); + assert!(!ADDRESS_RE.is_match("0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4aaa")); + assert!(!ADDRESS_RE.is_match("'0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4'")); + assert!(!ADDRESS_RE.is_match("' 0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4'")); + assert!(!ADDRESS_RE.is_match("'0xe5f3aF50FE5d0bF402a3C6F55ccC47d4307922d4'")); + } } From b174c3a4f80938636f18b3c9e49d45e6643f64a9 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 8 Feb 2024 22:01:14 +0100 Subject: [PATCH 0589/1963] (fix): correctly redact private keys in traces #6995 (#7049) * handle edge cases and lay out structure for test * add various testcases, complete but quite verbose * change to parameterized test * remove debug lines * clean up * fix linting issue * fix rustfmt * address feedback --- crates/evm/traces/src/decoder/mod.rs | 122 ++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 11 deletions(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 9f430912d5a75..f07e0bc519420 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -362,26 +362,41 @@ impl CallTraceDecoder { fn decode_cheatcode_inputs(&self, func: &Function, data: &[u8]) -> Option> { match func.name.as_str() { "expectRevert" => Some(vec![decode::decode_revert(data, Some(&self.errors), None)]), - "rememberKey" | "startBroadcast" | "broadcast" => { - // these functions accept a private key as uint256, which should not be - // converted to plain text - if !func.inputs.is_empty() && func.inputs[0].ty != "uint256" { - // redact private key input + "addr" | "createWallet" | "deriveKey" | "rememberKey" => { + // Redact private key in all cases + Some(vec!["".to_string()]) + } + "broadcast" | "startBroadcast" => { + // Redact private key if defined + // broadcast(uint256) / startBroadcast(uint256) + if !func.inputs.is_empty() && func.inputs[0].ty == "uint256" { Some(vec!["".to_string()]) } else { None } } - "sign" => { - // sign(uint256,bytes32) + "getNonce" => { + // Redact private key if defined + // getNonce(Wallet) + if !func.inputs.is_empty() && func.inputs[0].ty == "tuple" { + Some(vec!["".to_string()]) + } else { + None + } + } + "sign" | "signP256" => { let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; - if !decoded.is_empty() && func.inputs[0].ty != "uint256" { + + // Redact private key and replace in trace + // sign(uint256,bytes32) / signP256(uint256,bytes32) / sign(Wallet,bytes32) + if !decoded.is_empty() && + (func.inputs[0].ty == "uint256" || func.inputs[0].ty == "tuple") + { decoded[0] = DynSolValue::String("".to_string()); } + Some(decoded.iter().map(format_token).collect()) } - "addr" => Some(vec!["".to_string()]), - "deriveKey" => Some(vec!["".to_string()]), "parseJson" | "parseJsonUint" | "parseJsonUintArray" | @@ -460,7 +475,7 @@ impl CallTraceDecoder { fn decode_cheatcode_outputs(&self, func: &Function) -> Option { match func.name.as_str() { s if s.starts_with("env") => Some(""), - "deriveKey" => Some(""), + "createWallet" | "deriveKey" => Some(""), "parseJson" if self.verbosity < 5 => Some(""), "readFile" if self.verbosity < 5 => Some(""), _ => None, @@ -560,3 +575,88 @@ fn reconstruct_params(event: &Event, decoded: &DecodedEvent) -> Vec fn indexed_inputs(event: &Event) -> usize { event.inputs.iter().filter(|param| param.indexed).count() } + +#[cfg(test)] +mod tests { + use super::*; + use alloy_primitives::hex; + + #[test] + fn test_should_redact_pk() { + let decoder = CallTraceDecoder::new(); + + // [function_signature, data, expected] + let cheatcode_input_test_cases = vec![ + // Should redact private key from traces in all cases: + ("addr(uint256)", vec![], Some(vec!["".to_string()])), + ("createWallet(string)", vec![], Some(vec!["".to_string()])), + ("createWallet(uint256)", vec![], Some(vec!["".to_string()])), + ("deriveKey(string,uint32)", vec![], Some(vec!["".to_string()])), + ("deriveKey(string,string,uint32)", vec![], Some(vec!["".to_string()])), + ("deriveKey(string,uint32,string)", vec![], Some(vec!["".to_string()])), + ("deriveKey(string,string,uint32,string)", vec![], Some(vec!["".to_string()])), + ("rememberKey(uint256)", vec![], Some(vec!["".to_string()])), + // + // Should redact private key from traces in specific cases with exceptions: + ("broadcast(uint256)", vec![], Some(vec!["".to_string()])), + ("broadcast()", vec![], None), // Ignore: `private key` is not passed. + ("startBroadcast(uint256)", vec![], Some(vec!["".to_string()])), + ("startBroadcast()", vec![], None), // Ignore: `private key` is not passed. + ("getNonce((address,uint256,uint256,uint256))", vec![], Some(vec!["".to_string()])), + ("getNonce(address)", vec![], None), // Ignore: `address` is public. + // + // Should redact private key and replace in trace in cases: + ( + "sign(uint256,bytes32)", + hex!( + " + e341eaa4 + 7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 + 0000000000000000000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"\"".to_string(), + "0x0000000000000000000000000000000000000000000000000000000000000000" + .to_string(), + ]), + ), + ( + "signP256(uint256,bytes32)", + hex!( + " + 83211b40 + 7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 + 0000000000000000000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"\"".to_string(), + "0x0000000000000000000000000000000000000000000000000000000000000000" + .to_string(), + ]), + ), + ]; + + // [function_signature, expected] + let cheatcode_output_test_cases = vec![ + // Should redact private key on output in all cases: + ("createWallet(string)", Some("".to_string())), + ("deriveKey(string,uint32)", Some("".to_string())), + ]; + + for (function_signature, data, expected) in cheatcode_input_test_cases { + let function = Function::parse(function_signature).unwrap(); + let result = decoder.decode_cheatcode_inputs(&function, &data); + assert_eq!(result, expected, "Input case failed for: {}", function_signature); + } + + for (function_signature, expected) in cheatcode_output_test_cases { + let function = Function::parse(function_signature).unwrap(); + let result = Some(decoder.decode_cheatcode_outputs(&function).unwrap_or_default()); + assert_eq!(result, expected, "Output case failed for: {}", function_signature); + } + } +} From 2ca93507e760f528cb24d33ddb036eb0d3f6ed1c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 9 Feb 2024 14:59:43 +0300 Subject: [PATCH 0590/1963] fix(`forge`): more precise diff_score (#7057) * more precise diff_score * avoid 0 division --- crates/common/src/contracts.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index cc3b63f523607..86e2abf5b851d 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -97,20 +97,23 @@ pub type ContractsByAddress = BTreeMap; /// /// Will fail for small contracts that are essentially all immutable variables. pub fn diff_score(a: &[u8], b: &[u8]) -> f64 { - let cutoff_len = usize::min(a.len(), b.len()); - if cutoff_len == 0 { - return 1.0 + let max_len = usize::max(a.len(), b.len()); + let min_len = usize::min(a.len(), b.len()); + + if max_len == 0 { + return 1.0; } - let a = &a[..cutoff_len]; - let b = &b[..cutoff_len]; + let a = &a[..min_len]; + let b = &b[..min_len]; let mut diff_chars = 0; - for i in 0..cutoff_len { + for i in 0..min_len { if a[i] != b[i] { diff_chars += 1; } } - diff_chars as f64 / cutoff_len as f64 + diff_chars += max_len - min_len; + diff_chars as f64 / max_len as f64 } /// Flattens the contracts into (`id` -> (`JsonAbi`, `Vec`)) pairs From 52794a3b8bc60ce920510911392454458029087c Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Fri, 9 Feb 2024 04:15:40 -0800 Subject: [PATCH 0591/1963] always subtract at least 1 from before.len() when calculating start_line (#7059) --- crates/debugger/src/tui/draw.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 8394d3a2e4b64..e38ac170b9104 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -257,6 +257,12 @@ impl DebuggerContext<'_> { // no unused space } + // since above is subtracted from before.len(), and the resulting + // start_line is used to index into before, above must be at least + // 1 to avoid out-of-range accesses. + if above == 0 { + above = 1; + } (before.len().saturating_sub(above), mid_len + below) }; From a1fc146a0c94fcacd29492fff0747fe0d3c0d33f Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:04:31 +0200 Subject: [PATCH 0592/1963] #6981: `fs_permissions` find permission also sym links (#7022) * - find permission for resolved sym links * Use dunce to canonicalize permission path * Add integration tests - for default fs permissions config - for parsing custom fs permissions - to resolve symlink permissions * Fix clippy target --- Cargo.lock | 1 + crates/config/Cargo.toml | 1 + crates/config/src/fs_permissions.rs | 6 ++- crates/forge/tests/cli/config.rs | 81 ++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7421accaecc3..e50a9085dd536 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3146,6 +3146,7 @@ dependencies = [ "alloy-chains", "alloy-primitives", "dirs-next", + "dunce", "eyre", "figment", "foundry-block-explorers", diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 9afbc7dfb8c9f..b3f4c514a7660 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -19,6 +19,7 @@ alloy-primitives = { workspace = true, features = ["serde"] } revm-primitives = { workspace = true, default-features = false, features = ["std"] } dirs-next = "2" +dunce = "1" eyre.workspace = true figment = { version = "0.10", features = ["toml", "env"] } globset = "0.4" diff --git a/crates/config/src/fs_permissions.rs b/crates/config/src/fs_permissions.rs index ead647a6febab..fbbe67af9fdb8 100644 --- a/crates/config/src/fs_permissions.rs +++ b/crates/config/src/fs_permissions.rs @@ -44,7 +44,8 @@ impl FsPermissions { /// Returns the permission for the matching path. /// - /// This finds the longest matching path, e.g. if we have the following permissions: + /// This finds the longest matching path with resolved sym links, e.g. if we have the following + /// permissions: /// /// `./out` = `read` /// `./out/contracts` = `read-write` @@ -53,7 +54,8 @@ impl FsPermissions { pub fn find_permission(&self, path: &Path) -> Option { let mut permission: Option<&PathPermission> = None; for perm in &self.permissions { - if path.starts_with(&perm.path) { + let permission_path = dunce::canonicalize(&perm.path).unwrap_or(perm.path.clone()); + if path.starts_with(permission_path) { if let Some(active_perm) = permission.as_ref() { // the longest path takes precedence if perm.path < active_perm.path { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 92d02ac2da4e9..4c4f56eb3d270 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -5,7 +5,8 @@ use foundry_cli::utils as forge_utils; use foundry_compilers::artifacts::{OptimizerDetails, RevertStrings, YulDetails}; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, - Config, FuzzConfig, InvariantConfig, SolcReq, + fs_permissions::{FsAccessPermission, PathPermission}, + Config, FsPermissions, FuzzConfig, InvariantConfig, SolcReq, }; use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ @@ -14,7 +15,11 @@ use foundry_test_utils::{ }; use path_slash::PathBufExt; use pretty_assertions::assert_eq; -use std::{fs, path::PathBuf, str::FromStr}; +use std::{ + fs, + path::{Path, PathBuf}, + str::FromStr, +}; // tests all config values that are in use forgetest!(can_extract_config_values, |prj, cmd| { @@ -625,3 +630,75 @@ forgetest_init!(can_skip_remappings_auto_detection, |prj, cmd| { assert_eq!(config.remappings.len(), 1); assert_eq!("remapping/=lib/remapping/", config.remappings[0].to_string()); }); + +forgetest_init!(can_parse_default_fs_permissions, |_prj, cmd| { + let config = cmd.config(); + + assert_eq!(config.fs_permissions.len(), 1); + let out_permission = config.fs_permissions.find_permission(Path::new("out")).unwrap(); + assert_eq!(FsAccessPermission::Read, out_permission); +}); + +forgetest_init!(can_parse_custom_fs_permissions, |prj, cmd| { + // explicitly set fs permissions + let custom_permissions = FsPermissions::new(vec![ + PathPermission::read("./read"), + PathPermission::write("./write"), + PathPermission::read_write("./write/contracts"), + ]); + + let config = Config { fs_permissions: custom_permissions, ..Default::default() }; + prj.write_config(config); + + let config = cmd.config(); + + assert_eq!(config.fs_permissions.len(), 3); + + // check read permission + let permission = config.fs_permissions.find_permission(Path::new("./read")).unwrap(); + assert_eq!(permission, FsAccessPermission::Read); + // check nested write permission + let permission = + config.fs_permissions.find_permission(Path::new("./write/MyContract.sol")).unwrap(); + assert_eq!(permission, FsAccessPermission::Write); + // check nested read-write permission + let permission = config + .fs_permissions + .find_permission(Path::new("./write/contracts/MyContract.sol")) + .unwrap(); + assert_eq!(permission, FsAccessPermission::ReadWrite); + // check no permission + let permission = + config.fs_permissions.find_permission(Path::new("./bogus")).unwrap_or_default(); + assert_eq!(permission, FsAccessPermission::None); +}); + +#[cfg(not(target_os = "windows"))] +forgetest_init!(can_resolve_symlink_fs_permissions, |prj, cmd| { + // write config in packages/files/config.json + let config_path = prj.root().join("packages").join("files"); + fs::create_dir_all(&config_path).unwrap(); + fs::write(config_path.join("config.json"), "{ enabled: true }").unwrap(); + + // symlink packages/files dir as links/ + std::os::unix::fs::symlink( + Path::new("./packages/../packages/../packages/files"), + prj.root().join("links"), + ) + .unwrap(); + + // write config, give read access to links/ symlink to packages/files/ + let permissions = + FsPermissions::new(vec![PathPermission::read(Path::new("./links/config.json"))]); + let config = Config { fs_permissions: permissions, ..Default::default() }; + prj.write_config(config); + + let config = cmd.config(); + let mut fs_permissions = config.fs_permissions; + fs_permissions.join_all(prj.root()); + assert_eq!(fs_permissions.len(), 1); + + // read permission to file should be granted through symlink + let permission = fs_permissions.find_permission(&config_path.join("config.json")).unwrap(); + assert_eq!(permission, FsAccessPermission::Read); +}); From 08407628958f5288a785a72a75086b0c3dc57789 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:29:54 +0200 Subject: [PATCH 0593/1963] ci: revert to free GHA runners for tests (#7064) --- .github/scripts/matrices.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 3594fd2673141..0a47c96a21959 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -66,11 +66,11 @@ def __init__( is_pr = os.environ.get("EVENT_NAME") == "pull_request" -t_linux_x86 = Target("Linux-22.04", "x86_64-unknown-linux-gnu", "linux-amd64") +t_linux_x86 = Target("ubuntu-latest", "x86_64-unknown-linux-gnu", "linux-amd64") # TODO: Figure out how to make this work -# t_linux_arm = Target("Linux-22.04", "aarch64-unknown-linux-gnu", "linux-aarch64") -t_macos = Target("macos-latest-large", "x86_64-apple-darwin", "macosx-amd64") -t_windows = Target("Windows", "x86_64-pc-windows-msvc", "windows-amd64") +# t_linux_arm = Target("ubuntu-latest", "aarch64-unknown-linux-gnu", "linux-aarch64") +t_macos = Target("macos-latest", "x86_64-apple-darwin", "macosx-amd64") +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] config = [ From 6be2e775cc83e9e1d9badcb918cf500de24890a2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 9 Feb 2024 17:32:18 +0100 Subject: [PATCH 0594/1963] fix: use join for check-by-address path (#7062) --- crates/forge/bin/cmd/verify/sourcify.rs | 26 +++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/forge/bin/cmd/verify/sourcify.rs index 6c17d3f1293da..d30946f8945e6 100644 --- a/crates/forge/bin/cmd/verify/sourcify.rs +++ b/crates/forge/bin/cmd/verify/sourcify.rs @@ -5,8 +5,9 @@ use foundry_cli::utils::{get_cached_entry_by_name, LoadConfig}; use foundry_common::{fs, retry::Retry}; use foundry_compilers::ConfigurableContractArtifact; use futures::FutureExt; +use reqwest::Url; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, path::PathBuf}; +use std::{collections::HashMap, path::PathBuf, str::FromStr}; pub static SOURCIFY_URL: &str = "https://sourcify.dev/server/"; @@ -69,13 +70,15 @@ impl VerificationProvider for SourcifyVerificationProvider { let resp = retry .run_async(|| { async { - let url = format!( - "{}check-by-addresses?addresses={}&chainIds={}", + let url = Url::from_str( args.verifier.verifier_url.as_deref().unwrap_or(SOURCIFY_URL), + )?; + let query = format!( + "check-by-addresses?addresses={}&chainIds={}", args.id, args.etherscan.chain.unwrap_or_default().id(), ); - + let url = url.join(&query)?; let response = reqwest::get(url).await?; if !response.status().is_success() { eyre::bail!( @@ -201,3 +204,18 @@ pub struct SourcifyResponseElement { #[serde(rename = "storageTimestamp")] storage_timestamp: Option, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_check_addresses_url() { + let url = Url::from_str("https://server-verify.hashscan.io").unwrap(); + let url = url.join("check-by-addresses?addresses=0x1234&chainIds=1").unwrap(); + assert_eq!( + url.as_str(), + "https://server-verify.hashscan.io/check-by-addresses?addresses=0x1234&chainIds=1" + ); + } +} From 282b0c307314636ed10f405cafcca351e06cff40 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 9 Feb 2024 18:17:49 +0100 Subject: [PATCH 0595/1963] test: use assert_eq (#7065) --- crates/forge/tests/it/invariant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 4fcc8ffe33b7b..333392b29106d 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -240,7 +240,7 @@ async fn test_invariant_shrink() { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), // `fuzz_seed` at 119 makes this sequence shrinkable from 4 to 2. CounterExample::Sequence(sequence) => { - assert!(sequence.len() == 2) + assert_eq!(sequence.len(), 2); } }; } From 113ab8b36f499509efc83eda9e53db7bc15ceda3 Mon Sep 17 00:00:00 2001 From: Luca Provini Date: Fri, 9 Feb 2024 18:19:22 +0100 Subject: [PATCH 0596/1963] parsing file paths from foundry.toml (#7063) * parsing file paths from foundry.toml * e2e test * fix * review: renaming * Update crates/forge/tests/cli/cmd.rs Co-authored-by: Matthias Seitz * review: improved test readability --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 4 +- Cargo.toml | 4 +- crates/config/README.md | 1 + crates/config/src/lib.rs | 25 ++++++++++++ .../forge/bin/cmd/verify/etherscan/flatten.rs | 2 +- crates/forge/tests/cli/cmd.rs | 38 ++++++++++++++++++- crates/forge/tests/cli/config.rs | 1 + 7 files changed, 69 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e50a9085dd536..23110498ad232 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3104,9 +3104,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d88392f8b9848cfac5b11054b14e14268ae5361450bd45169df276f9af748c5" +checksum = "9b9af6e08b6e1e2c9fa47cf39edcddeed5e96554d8a205c1fc1a8d2f092220c3" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 9beebb39db30c..5baa93d547f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,7 @@ foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } -foundry-compilers = { version = "0.3.2", default-features = false } +foundry-compilers = { version = "0.3.4", default-features = false } ## revm # no default features to avoid c-kzg @@ -162,7 +162,7 @@ alloy-transport = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } -alloy-primitives = "0.6.2" +alloy-primitives = { version ="0.6.2", features = ["getrandom"] } alloy-dyn-abi = "0.6.2" alloy-json-abi = "0.6.2" alloy-sol-types = "0.6.2" diff --git a/crates/config/README.md b/crates/config/README.md index 5308cdfab3412..2944105d53824 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -106,6 +106,7 @@ etherscan_api_key = "YOURETHERSCANAPIKEY" # known error codes are: ["unreachable", "unused-return", "unused-param", "unused-var", "code-size", "shadowing", "func-mutability", "license", "pragma-solidity", "virtual-interfaces", "same-varname"] # additional warnings can be added using their numeric error code: ["license", 1337] ignored_error_codes = ["license", "code-size"] +ignored_warnings_from = ["path_to_ignore"] deny_warnings = false match_test = "Foo" no_match_test = "Bar" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ef8aef44021e2..c55dcb752c3c5 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -214,6 +214,9 @@ pub struct Config { pub etherscan: EtherscanConfigs, /// list of solidity error codes to always silence in the compiler output pub ignored_error_codes: Vec, + /// list of file paths to ignore + #[serde(rename = "ignored_warnings_from")] + pub ignored_file_paths: Vec, /// When true, compiler warnings are treated as errors pub deny_warnings: bool, /// Only run test functions matching the specified regex pattern. @@ -657,6 +660,7 @@ impl Config { .include_paths(&self.include_paths) .solc_config(SolcConfig::builder().settings(self.solc_settings()?).build()) .ignore_error_codes(self.ignored_error_codes.iter().copied().map(Into::into)) + .ignore_paths(self.ignored_file_paths.clone()) .set_compiler_severity_filter(if self.deny_warnings { Severity::Warning } else { @@ -1868,6 +1872,7 @@ impl Default for Config { SolidityErrorCode::ContractExceeds24576Bytes, SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes, ], + ignored_file_paths: vec![], deny_warnings: false, via_ir: false, rpc_storage_caching: Default::default(), @@ -3514,6 +3519,7 @@ mod tests { gas_price = 0 gas_reports = ['*'] ignored_error_codes = [1878] + ignored_warnings_from = ["something"] deny_warnings = false initial_balance = '0xffffffffffffffffffffffff' libraries = [] @@ -3561,6 +3567,7 @@ mod tests { let config = Config::load_with_root(jail.directory()); + assert_eq!(config.ignored_file_paths, vec![PathBuf::from("something")]); assert_eq!(config.fuzz.seed, Some(U256::from(1000))); assert_eq!( config.remappings, @@ -4590,6 +4597,24 @@ mod tests { }); } + #[test] + fn test_parse_file_paths() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [default] + ignored_warnings_from = ["something"] + "#, + )?; + + let config = Config::load(); + assert_eq!(config.ignored_file_paths, vec![Path::new("something").to_path_buf()]); + + Ok(()) + }); + } + #[test] fn test_parse_optimizer_settings() { figment::Jail::expect_with(|jail| { diff --git a/crates/forge/bin/cmd/verify/etherscan/flatten.rs b/crates/forge/bin/cmd/verify/etherscan/flatten.rs index e58b784f15d99..62e534a66785e 100644 --- a/crates/forge/bin/cmd/verify/etherscan/flatten.rs +++ b/crates/forge/bin/cmd/verify/etherscan/flatten.rs @@ -80,7 +80,7 @@ impl EtherscanFlattenedSource { if out.has_error() { let mut o = AggregatedCompilerOutput::default(); o.extend(version, out); - let diags = o.diagnostics(&[], Default::default()); + let diags = o.diagnostics(&[], &[], Default::default()); eyre::bail!( "\ diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 107b25cc6f06d..222248f84e6cb 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -10,7 +10,7 @@ use foundry_test_utils::{ use semver::Version; use std::{ env, fs, - path::PathBuf, + path::{Path, PathBuf}, process::{Command, Stdio}, str::FromStr, }; @@ -666,6 +666,42 @@ contract ATest is DSTest { } ); +// test that `forge build` does not print `(with warnings)` if file path is ignored +forgetest!(can_compile_without_warnings_ignored_file_paths, |prj, cmd| { + // Ignoring path and setting empty error_codes as default would set would set some error codes + prj.write_config(Config { + ignored_file_paths: vec![Path::new("src").to_path_buf()], + ignored_error_codes: vec![], + ..Default::default() + }); + + prj.add_raw_source( + "src/example.sol", + r" +pragma solidity *; +contract A { + function testExample() public {} +} +", + ) + .unwrap(); + + cmd.args(["build", "--force"]); + let out = cmd.stdout_lossy(); + // expect no warning as path is ignored + assert!(out.contains("Compiler run successful!")); + assert!(!out.contains("Compiler run successful with warnings:")); + + // Reconfigure without ignored paths or error codes and check for warnings + // need to reset empty error codes as default would set some error codes + prj.write_config(Config { ignored_error_codes: vec![], ..Default::default() }); + + let out = cmd.stdout_lossy(); + // expect warnings as path is not ignored + assert!(out.contains("Compiler run successful with warnings:"), "{out}"); + assert!(out.contains("Warning") && out.contains("SPDX-License-Identifier"), "{out}"); +}); + // test that `forge build` does not print `(with warnings)` if there arent any forgetest!(can_compile_without_warnings, |prj, cmd| { let config = Config { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 4c4f56eb3d270..0c540d65a4fc3 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -95,6 +95,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { "src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6".to_string() ], ignored_error_codes: vec![], + ignored_file_paths: vec![], deny_warnings: false, via_ir: true, rpc_storage_caching: StorageCachingConfig { From ff391b5fbef93a5dc6d28055501d5bdc39aee1c8 Mon Sep 17 00:00:00 2001 From: Enrique Date: Fri, 9 Feb 2024 13:20:53 -0400 Subject: [PATCH 0597/1963] refactor: use `TransactionRequest` everywhere (#7040) * refactor: remove EthTransactionRequest and CallRequest for TransactionRequest * add note about removing transaction_request_to_typed * update alloy * chore(general): last conversions * chore: update alloy, fix tests --- Cargo.lock | 30 +- crates/anvil/core/src/eth/mod.rs | 21 +- crates/anvil/core/src/eth/transaction/mod.rs | 292 +------------------ crates/anvil/src/eth/api.rs | 49 ++-- crates/anvil/src/eth/backend/fork.rs | 16 +- crates/anvil/src/eth/backend/mem/mod.rs | 18 +- crates/anvil/tests/it/api.rs | 2 +- crates/anvil/tests/it/fork.rs | 2 +- crates/anvil/tests/it/transaction.rs | 4 +- crates/cheatcodes/src/inspector.rs | 6 +- crates/common/src/types.rs | 10 +- crates/forge/bin/cmd/script/executor.rs | 2 +- crates/forge/bin/cmd/script/mod.rs | 5 +- crates/forge/bin/cmd/script/transaction.rs | 2 +- 14 files changed, 97 insertions(+), 362 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23110498ad232..c7a7497e09a91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-network", "alloy-primitives", @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -381,7 +381,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -394,7 +394,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -412,7 +412,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#32618e9243a761858a0843e7e55575e48fdbf500" +source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" dependencies = [ "alloy-pubsub", "alloy-transport", diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 4a63675917c98..87c02d9b82990 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -1,13 +1,14 @@ use crate::{ - eth::{subscription::SubscriptionId, transaction::EthTransactionRequest}, + eth::subscription::SubscriptionId, types::{EvmMineOptions, Forking, Index}, }; use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256}; use alloy_rpc_trace_types::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}; use alloy_rpc_types::{ pubsub::{Params as SubscriptionParams, SubscriptionKind}, + request::TransactionRequest, state::StateOverride, - BlockId, BlockNumberOrTag as BlockNumber, CallRequest, Filter, + BlockId, BlockNumberOrTag as BlockNumber, Filter, }; pub mod block; @@ -142,7 +143,7 @@ pub enum EthRequest { EthSign(Address, Bytes), #[cfg_attr(feature = "serde", serde(rename = "eth_signTransaction"))] - EthSignTransaction(Box), + EthSignTransaction(Box), /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md). #[cfg_attr(feature = "serde", serde(rename = "eth_signTypedData"))] @@ -157,27 +158,27 @@ pub enum EthRequest { EthSignTypedDataV4(Address, alloy_dyn_abi::TypedData), #[cfg_attr(feature = "serde", serde(rename = "eth_sendTransaction", with = "sequence"))] - EthSendTransaction(Box), + EthSendTransaction(Box), #[cfg_attr(feature = "serde", serde(rename = "eth_sendRawTransaction", with = "sequence"))] EthSendRawTransaction(Bytes), #[cfg_attr(feature = "serde", serde(rename = "eth_call"))] EthCall( - CallRequest, + TransactionRequest, #[cfg_attr(feature = "serde", serde(default))] Option, #[cfg_attr(feature = "serde", serde(default))] Option, ), #[cfg_attr(feature = "serde", serde(rename = "eth_createAccessList"))] EthCreateAccessList( - CallRequest, + TransactionRequest, #[cfg_attr(feature = "serde", serde(default))] Option, ), #[cfg_attr(feature = "serde", serde(rename = "eth_estimateGas"))] EthEstimateGas( - CallRequest, + TransactionRequest, #[cfg_attr(feature = "serde", serde(default))] Option, #[cfg_attr(feature = "serde", serde(default))] Option, ), @@ -271,7 +272,7 @@ pub enum EthRequest { /// geth's `debug_traceCall` endpoint #[cfg_attr(feature = "serde", serde(rename = "debug_traceCall"))] DebugTraceCall( - CallRequest, + TransactionRequest, #[cfg_attr(feature = "serde", serde(default))] Option, #[cfg_attr(feature = "serde", serde(default))] GethDefaultTracingOptions, ), @@ -596,7 +597,7 @@ pub enum EthRequest { feature = "serde", serde(rename = "eth_sendUnsignedTransaction", with = "sequence") )] - EthSendUnsignedTransaction(Box), + EthSendUnsignedTransaction(Box), /// Turn on call traces for transactions that are returned to the user when they execute a /// transaction (instead of just txhash/receipt) @@ -1451,7 +1452,7 @@ true}]}"#; #[test] fn test_eth_call() { let req = r#"{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"}"#; - let _req = serde_json::from_str::(req).unwrap(); + let _req = serde_json::from_str::(req).unwrap(); let s = r#"{"method": "eth_call", "params":[{"data":"0xcfae3217","from":"0xd84de507f3fada7df80908082d3239466db55a71","to":"0xcbe828fdc46e3b1c351ec90b1a5e7d9742c0398d"},"latest"]}"#; let _req = serde_json::from_str::(s).unwrap(); diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 5582ca80df340..502cd075dafff 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -9,8 +9,8 @@ use alloy_network::{Signed, Transaction, TxKind}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, B256, U128, U256, U64}; use alloy_rlp::{Decodable, Encodable}; use alloy_rpc_types::{ - request::TransactionRequest, AccessList, AccessListItem, CallInput, CallRequest, - Signature as RpcSignature, Transaction as RpcTransaction, + request::TransactionRequest, AccessList, Signature as RpcSignature, + Transaction as RpcTransaction, }; use foundry_evm::traces::CallTraceNode; use revm::{ @@ -30,199 +30,8 @@ pub fn impersonated_signature() -> Signature { .unwrap() } -/// Represents _all_ transaction requests received from RPC -#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(deny_unknown_fields))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct EthTransactionRequest { - /// from address - pub from: Option
, - /// to address - pub to: Option
, - /// legacy, gas Price - #[cfg_attr(feature = "serde", serde(default))] - pub gas_price: Option, - /// max base fee per gas sender is willing to pay - #[cfg_attr(feature = "serde", serde(default))] - pub max_fee_per_gas: Option, - /// miner tip - #[cfg_attr(feature = "serde", serde(default))] - pub max_priority_fee_per_gas: Option, - /// gas - pub gas: Option, - /// value of th tx in wei - pub value: Option, - /// Any additional data sent - #[cfg_attr(feature = "serde", serde(alias = "input"))] - pub data: Option, - /// Transaction nonce - pub nonce: Option, - /// chain id - #[cfg_attr(feature = "serde", serde(default))] - pub chain_id: Option, - /// warm storage access pre-payment - #[cfg_attr(feature = "serde", serde(default))] - pub access_list: Option>, - /// EIP-2718 type - #[cfg_attr(feature = "serde", serde(rename = "type"))] - pub transaction_type: Option, - /// Optimism Deposit Request Fields - #[serde(flatten)] - pub optimism_fields: Option, -} - -impl EthTransactionRequest { - pub fn into_call_request(self) -> CallRequest { - let Self { - from, - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - gas, - value, - data, - nonce, - chain_id, - access_list, - transaction_type, - optimism_fields: _, - } = self; - CallRequest { - from, - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - gas, - value, - input: CallInput::maybe_input(data), - nonce: nonce.map(|n| n.to()), - chain_id, - access_list: access_list.map(AccessList), - max_fee_per_blob_gas: None, - blob_versioned_hashes: None, - transaction_type: transaction_type.map(|ty| ty.to()), - } - } -} - -#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(deny_unknown_fields))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct OptimismDepositRequestFields { - /// op-stack deposit source hash - pub source_hash: B256, - /// op-stack deposit mint - pub mint: U256, - /// op-stack deposit system tx - pub is_system_tx: bool, -} - -impl EthTransactionRequest { - pub fn into_typed_request(self) -> Option { - let EthTransactionRequest { - from, - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - gas, - value, - data, - nonce, - mut access_list, - transaction_type, - optimism_fields, - .. - } = self; - let transaction_type = transaction_type.map(|id| id.to::()); - let data = data.clone().unwrap_or_default(); - // Special case: OP-stack deposit tx - if transaction_type == Some(126) { - return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { - from: from.unwrap_or_default(), - source_hash: optimism_fields.clone()?.source_hash, - kind: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - mint: optimism_fields.clone()?.mint, - value: value.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - is_system_tx: optimism_fields.clone()?.is_system_tx, - input: data, - })) - } - - match ( - transaction_type, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - access_list.take(), - ) { - // legacy transaction - (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { - Some(TypedTransactionRequest::Legacy(TxLegacy { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: data, - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: None, - })) - } - // EIP2930 - (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { - Some(TypedTransactionRequest::EIP2930(TxEip2930 { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: data, - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: 0, - access_list: to_eip_access_list(AccessList(access_list.unwrap_or_default())), - })) - } - // EIP1559 - (Some(2), None, _, _, _) | - (None, None, Some(_), _, _) | - (None, None, _, Some(_), _) | - (None, None, None, None, None) => { - // Empty fields fall back to the canonical transaction schema. - Some(TypedTransactionRequest::EIP1559(TxEip1559 { - nonce: nonce.unwrap_or_default().to::(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), - max_priority_fee_per_gas: max_priority_fee_per_gas - .unwrap_or_default() - .to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: data, - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: 0, - access_list: to_eip_access_list(AccessList(access_list.unwrap_or_default())), - })) - } - _ => None, - } - } -} - +/// Converts a [TransactionRequest] into a [TypedTransactionRequest]. +/// Should be removed once the call builder abstraction for providers is in place. pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { let TransactionRequest { from, @@ -232,7 +41,7 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option Option("sourceHash")?.ok()?, - kind: TxKind::Create, + kind: to.into(), mint: other.get_deserialized::("mint")?.ok()?, value: value.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), is_system_tx: other.get_deserialized::("isSystemTx")?.ok()?, - input: data.unwrap_or_default(), + input: input.into_input().unwrap_or_default(), })) } @@ -269,7 +78,7 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option(), gas_limit: gas.unwrap_or_default().to::(), value: value.unwrap_or(U256::ZERO), - input: data.unwrap_or_default(), + input: input.into_input().unwrap_or_default(), to: match to { Some(to) => TxKind::Call(to), None => TxKind::Create, @@ -284,7 +93,7 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option(), value: value.unwrap_or(U256::ZERO), - input: data.unwrap_or_default(), + input: input.into_input().unwrap_or_default(), to: match to { Some(to) => TxKind::Call(to), None => TxKind::Create, @@ -305,7 +114,7 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option(), gas_limit: gas.unwrap_or_default().to::(), value: value.unwrap_or(U256::ZERO), - input: data.unwrap_or_default(), + input: input.into_input().unwrap_or_default(), to: match to { Some(to) => TxKind::Call(to), None => TxKind::Create, @@ -318,87 +127,6 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option Option { - let CallRequest { - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - gas, - value, - input, - chain_id, - nonce, - mut access_list, - transaction_type, - .. - } = tx; - let chain_id = chain_id.map(|id| id.to::()); - let transaction_type = transaction_type.map(|id| id.to::()); - - match ( - transaction_type, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - access_list.take(), - ) { - // legacy transaction - (Some(0), _, None, None, None) | (None, Some(_), None, None, None) => { - Some(TypedTransactionRequest::Legacy(TxLegacy { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id, - })) - } - // EIP2930 - (Some(1), _, None, None, _) | (None, _, None, None, Some(_)) => { - Some(TypedTransactionRequest::EIP2930(TxEip2930 { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: chain_id.unwrap_or_default(), - access_list: to_eip_access_list(access_list.unwrap_or_default()), - })) - } - // EIP1559 - (Some(2), None, _, _, _) | - (None, None, Some(_), _, _) | - (None, None, _, Some(_), _) | - (None, None, None, None, None) => { - // Empty fields fall back to the canonical transaction schema. - Some(TypedTransactionRequest::EIP1559(TxEip1559 { - nonce: nonce.unwrap_or_default().to::(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), - value: value.unwrap_or(U256::ZERO), - input: input.try_into_unique_input().unwrap_or_default().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, - chain_id: chain_id.unwrap_or_default(), - access_list: to_eip_access_list(access_list.unwrap_or_default()), - })) - } - _ => None, - } -} - #[derive(Clone, Debug, PartialEq, Eq)] pub enum TypedTransactionRequest { Legacy(TxLegacy), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index e796e4f4dde7c..fff26c9d9ffb4 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -41,18 +41,19 @@ use alloy_rpc_trace_types::{ parity::LocalizedTransactionTrace, }; use alloy_rpc_types::{ + request::TransactionRequest, state::StateOverride, txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, AccessList, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, - BlockTransactions, CallRequest, EIP1186AccountProofResponse, FeeHistory, Filter, - FilteredParams, Log, Transaction, TransactionReceipt, + BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Log, + Transaction, TransactionReceipt, }; use alloy_transport::TransportErrorKind; use anvil_core::{ eth::{ block::BlockInfo, transaction::{ - call_request_to_typed, EthTransactionRequest, PendingTransaction, TypedTransaction, + transaction_request_to_typed, PendingTransaction, TypedTransaction, TypedTransactionRequest, }, EthRequest, @@ -852,7 +853,7 @@ impl EthApi { /// Signs a transaction /// /// Handler for ETH RPC call: `eth_signTransaction` - pub async fn sign_transaction(&self, mut request: EthTransactionRequest) -> Result { + pub async fn sign_transaction(&self, mut request: TransactionRequest) -> Result { node_info!("eth_signTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { @@ -863,9 +864,7 @@ impl EthApi { if request.gas.is_none() { // estimate if not provided - if let Ok(gas) = - self.estimate_gas(request.clone().into_call_request(), None, None).await - { + if let Ok(gas) = self.estimate_gas(request.clone(), None, None).await { request.gas = Some(gas); } } @@ -881,7 +880,7 @@ impl EthApi { /// Sends a transaction /// /// Handler for ETH RPC call: `eth_sendTransaction` - pub async fn send_transaction(&self, mut request: EthTransactionRequest) -> Result { + pub async fn send_transaction(&self, mut request: TransactionRequest) -> Result { node_info!("eth_sendTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { @@ -891,9 +890,7 @@ impl EthApi { if request.gas.is_none() { // estimate if not provided - if let Ok(gas) = - self.estimate_gas(request.clone().into_call_request(), None, None).await - { + if let Ok(gas) = self.estimate_gas(request.clone(), None, None).await { request.gas = Some(gas); } } @@ -978,7 +975,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_call` pub async fn call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, overrides: Option, ) -> Result { @@ -1034,7 +1031,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_createAccessList` pub async fn create_access_list( &self, - mut request: CallRequest, + mut request: TransactionRequest, block_number: Option, ) -> Result { node_info!("eth_createAccessList"); @@ -1086,7 +1083,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_estimateGas` pub async fn estimate_gas( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, overrides: Option, ) -> Result { @@ -1314,6 +1311,8 @@ impl EthApi { base_fee_per_gas: Vec::new(), gas_used_ratio: Vec::new(), reward: Some(Default::default()), + base_fee_per_blob_gas: Default::default(), + blob_gas_used_ratio: Default::default(), }; let mut rewards = Vec::new(); @@ -1463,7 +1462,7 @@ impl EthApi { /// Handler for RPC call: `debug_traceCall` pub async fn debug_trace_call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, opts: GethDefaultTracingOptions, ) -> Result { @@ -1988,7 +1987,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_sendUnsignedTransaction` pub async fn eth_send_unsigned_transaction( &self, - request: EthTransactionRequest, + request: TransactionRequest, ) -> Result { node_info!("eth_sendUnsignedTransaction"); // either use the impersonated account of the request's `from` field @@ -2154,7 +2153,7 @@ impl EthApi { async fn do_estimate_gas( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, overrides: Option, ) -> Result { @@ -2194,7 +2193,7 @@ impl EthApi { /// This will execute the [CallRequest] and find the best gas limit via binary search fn do_estimate_gas_with_state( &self, - mut request: CallRequest, + mut request: TransactionRequest, state: D, block_env: BlockEnv, ) -> Result @@ -2488,7 +2487,7 @@ impl EthApi { fn build_typed_tx_request( &self, - request: EthTransactionRequest, + request: TransactionRequest, nonce: U256, ) -> Result { let chain_id = request.chain_id.map(|c| c.to::()).unwrap_or_else(|| self.chain_id()); @@ -2497,7 +2496,7 @@ impl EthApi { let gas_limit = request.gas.map(Ok).unwrap_or_else(|| self.current_gas_limit())?; - let request = match request.into_typed_request() { + let request = match transaction_request_to_typed(request) { Some(TypedTransactionRequest::Legacy(mut m)) => { m.nonce = nonce.to::(); m.chain_id = Some(chain_id); @@ -2572,12 +2571,12 @@ impl EthApi { /// This will also check the tx pool for pending transactions from the sender. async fn request_nonce( &self, - request: &EthTransactionRequest, + request: &TransactionRequest, from: Address, ) -> Result<(U256, U256)> { let highest_nonce = self.get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))).await?; - let nonce = request.nonce.unwrap_or(highest_nonce); + let nonce = request.nonce.map(|n| n.to::()).unwrap_or(highest_nonce); Ok((nonce, highest_nonce)) } @@ -2648,7 +2647,7 @@ fn ensure_return_ok(exit: InstructionResult, out: &Option) -> Result( - mut request: CallRequest, + mut request: TransactionRequest, state: D, backend: Arc, block_env: BlockEnv, @@ -2682,8 +2681,8 @@ where /// Determines the minimum gas needed for a transaction depending on the transaction kind. #[inline] -fn determine_base_gas_by_kind(request: &CallRequest) -> U256 { - match call_request_to_typed(request.clone()) { +fn determine_base_gas_by_kind(request: &TransactionRequest) -> U256 { + match transaction_request_to_typed(request.clone()) { Some(request) => match request { TypedTransactionRequest::Legacy(req) => match req.to { TxKind::Call(_) => MIN_TRANSACTION_GAS, diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 75312b6a63bb9..baf177e25b629 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -8,9 +8,9 @@ use alloy_rpc_trace_types::{ parity::LocalizedTransactionTrace as Trace, }; use alloy_rpc_types::{ - AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, - CallRequest, EIP1186AccountProofResponse, FeeHistory, Filter, Log, Transaction, - TransactionReceipt, + request::TransactionRequest, AccessListWithGasUsed, Block, BlockId, + BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, + Filter, Log, Transaction, TransactionReceipt, }; use alloy_transport::TransportError; use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; @@ -169,7 +169,7 @@ impl ClientFork { /// Sends `eth_call` pub async fn call( &self, - request: &CallRequest, + request: &TransactionRequest, block: Option, ) -> Result { let request = Arc::new(request.clone()); @@ -199,7 +199,7 @@ impl ClientFork { /// Sends `eth_call` pub async fn estimate_gas( &self, - request: &CallRequest, + request: &TransactionRequest, block: Option, ) -> Result { let request = Arc::new(request.clone()); @@ -229,7 +229,7 @@ impl ClientFork { /// Sends `eth_createAccessList` pub async fn create_access_list( &self, - request: &CallRequest, + request: &TransactionRequest, block: Option, ) -> Result { self.provider().create_access_list(request.clone(), block.map(|b| b.into())).await @@ -674,8 +674,8 @@ pub struct ForkedStorage { pub geth_transaction_traces: HashMap, pub block_traces: HashMap>, pub block_receipts: HashMap>, - pub eth_gas_estimations: HashMap<(Arc, u64), U256>, - pub eth_call: HashMap<(Arc, u64), Bytes>, + pub eth_gas_estimations: HashMap<(Arc, u64), U256>, + pub eth_call: HashMap<(Arc, u64), Bytes>, pub code_at: HashMap<(Address, u64), Bytes>, } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f95b6b96ee9a3..da599966bc068 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -38,8 +38,8 @@ use alloy_rpc_trace_types::{ parity::LocalizedTransactionTrace, }; use alloy_rpc_types::{ - state::StateOverride, AccessList, Block as AlloyBlock, BlockId, - BlockNumberOrTag as BlockNumber, CallRequest, EIP1186AccountProofResponse as AccountProof, + request::TransactionRequest, state::StateOverride, AccessList, Block as AlloyBlock, BlockId, + BlockNumberOrTag as BlockNumber, EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, FilteredParams, Header as AlloyHeader, Log, Transaction, TransactionReceipt, }; @@ -1015,14 +1015,14 @@ impl Backend { outcome } - /// Executes the [CallRequest] without writing to the DB + /// Executes the [TransactionRequest] without writing to the DB /// /// # Errors /// /// Returns an error if the `block_number` is greater than the current height pub async fn call( &self, - request: CallRequest, + request: TransactionRequest, fee_details: FeeDetails, block_request: Option, overrides: Option, @@ -1043,11 +1043,11 @@ impl Backend { fn build_call_env( &self, - request: CallRequest, + request: TransactionRequest, fee_details: FeeDetails, block_env: BlockEnv, ) -> Env { - let CallRequest { from, to, gas, value, input, nonce, access_list, .. } = request; + let TransactionRequest { from, to, gas, value, input, nonce, access_list, .. } = request; let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = fee_details; @@ -1094,7 +1094,7 @@ impl Backend { pub fn call_with_state( &self, state: D, - request: CallRequest, + request: TransactionRequest, fee_details: FeeDetails, block_env: BlockEnv, ) -> Result<(InstructionResult, Option, u64, State), BlockchainError> @@ -1140,7 +1140,7 @@ impl Backend { pub async fn call_with_tracing( &self, - request: CallRequest, + request: TransactionRequest, fee_details: FeeDetails, block_request: Option, opts: GethDefaultTracingOptions, @@ -1180,7 +1180,7 @@ impl Backend { pub fn build_access_list_with_state( &self, state: D, - request: CallRequest, + request: TransactionRequest, fee_details: FeeDetails, block_env: BlockEnv, ) -> Result<(InstructionResult, Option, u64, AccessList), BlockchainError> diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 50a239b48a25c..fb3c3742b2e62 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -7,8 +7,8 @@ use crate::{ use alloy_primitives::{Address as rAddress, B256, U256 as rU256}; use alloy_providers::provider::TempProvider; use alloy_rpc_types::{ + request::{TransactionInput as CallInput, TransactionRequest as CallRequest}, state::{AccountOverride, StateOverride}, - CallInput, CallRequest, }; use alloy_signer::Signer as AlloySigner; use anvil::{ diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index d0f60d5e941b7..0bd6f7dcb78ed 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -6,7 +6,7 @@ use crate::{ }; use alloy_primitives::U256 as rU256; use alloy_providers::provider::TempProvider; -use alloy_rpc_types::{BlockNumberOrTag, CallRequest}; +use alloy_rpc_types::{request::TransactionRequest as CallRequest, BlockNumberOrTag}; use alloy_signer::Signer as AlloySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index fd8dee363d694..18a74e1a9d8ae 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -4,12 +4,12 @@ use crate::{ }; use alloy_primitives::U256 as rU256; use alloy_rpc_types::{ + request::TransactionRequest as AlloyTransactionRequest, state::{AccountOverride, StateOverride}, BlockNumberOrTag, }; use alloy_signer::Signer as AlloySigner; use anvil::{spawn, Hardfork, NodeConfig}; -use anvil_core::eth::transaction::EthTransactionRequest; use ethers::{ abi::ethereum_types::BigEndianHash, prelude::{ @@ -1088,7 +1088,7 @@ async fn can_mine_multiple_in_block() { // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); - let tx = EthTransactionRequest { + let tx = AlloyTransactionRequest { from: Some("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266".parse().unwrap()), ..Default::default() }; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 4e48c5e9e28d3..8290b9b951de9 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -15,7 +15,7 @@ use crate::{ CheatsConfig, CheatsCtxt, Error, Result, Vm, }; use alloy_primitives::{Address, Bytes, B256, U256, U64}; -use alloy_rpc_types::request::TransactionRequest; +use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_signer::LocalWallet; use alloy_sol_types::{SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl}; @@ -836,7 +836,7 @@ impl Inspector for Cheatcodes { from: Some(broadcast.new_origin), to: Some(call.contract), value: Some(call.transfer.value), - data: Some(call.input.clone()), + input: TransactionInput::new(call.input.clone()), nonce: Some(U64::from(account.info.nonce)), gas: if is_fixed_gas_limit { Some(U256::from(call.gas_limit)) @@ -1222,7 +1222,7 @@ impl Inspector for Cheatcodes { from: Some(broadcast.new_origin), to, value: Some(call.value), - data: Some(bytecode), + input: TransactionInput::new(bytecode), nonce: Some(U64::from(nonce)), gas: if is_fixed_gas_limit { Some(U256::from(call.gas_limit)) diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index aea3bf6319bc8..2917d92edd6e2 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -2,7 +2,11 @@ use alloy_json_abi::{Event, EventParam, Function, InternalType, Param, StateMutability}; use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U128, U256, U64}; -use alloy_rpc_types::{AccessList, AccessListItem, CallInput, CallRequest, Signature, Transaction}; +use alloy_rpc_types::{ + other::OtherFields, + request::{TransactionInput, TransactionRequest as CallRequest}, + AccessList, AccessListItem, Signature, Transaction, +}; use alloy_signer::{LocalWallet, Signer}; use ethers_core::{ abi as ethabi, @@ -177,13 +181,15 @@ pub fn to_call_request_from_tx_request(tx: TransactionRequest) -> CallRequest { max_priority_fee_per_gas: None, gas: tx.gas.map(|g| g.to_alloy()), value: tx.value.map(|v| v.to_alloy()), - input: CallInput::maybe_input(tx.data.map(|b| b.0.into())), + input: TransactionInput::maybe_input(tx.data.map(|b| b.0.into())), nonce: tx.nonce.map(|n| U64::from(n.as_u64())), chain_id: tx.chain_id.map(|c| c.to_alloy()), access_list: None, max_fee_per_blob_gas: None, blob_versioned_hashes: None, transaction_type: None, + sidecar: None, + other: OtherFields::default(), } } diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index bea7af8cb2c76..c77c4c1a826d7 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -143,7 +143,7 @@ impl ScriptArgs { tx.from .expect("transaction doesn't have a `from` address at execution time"), tx.to, - tx.data.clone(), + tx.input.clone().into_input(), tx.value, ) .wrap_err("Internal EVM error during simulation")?; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index ede0b19fd388a..50ae7481ad864 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -415,7 +415,7 @@ impl ScriptArgs { rpc: fork_url.clone(), transaction: TransactionRequest { from: Some(from), - data: Some(bytes.clone()), + input: Some(bytes.clone()).into(), nonce: Some(U64::from(nonce + i as u64)), ..Default::default() }, @@ -510,8 +510,9 @@ impl ScriptArgs { for (data, to) in result.transactions.iter().flat_map(|txes| { txes.iter().filter_map(|tx| { tx.transaction - .data + .input .clone() + .into_input() .filter(|data| data.len() > max_size) .map(|data| (data, tx.transaction.to)) }) diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/forge/bin/cmd/script/transaction.rs index 4568ad357cbcd..fec73b22f001e 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/forge/bin/cmd/script/transaction.rs @@ -69,7 +69,7 @@ impl TransactionWithMetadata { from: transaction.from.map(ToEthers::to_ethers), to: transaction.to.map(ToEthers::to_ethers).map(Into::into), value: transaction.value.map(ToEthers::to_ethers), - data: transaction.data.map(ToEthers::to_ethers), + data: transaction.input.into_input().map(ToEthers::to_ethers), nonce: transaction.nonce.map(|n| n.to::().into()), gas: transaction.gas.map(ToEthers::to_ethers), ..Default::default() From c41048c966b60918e70e0146dcc8f20e012f7243 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 9 Feb 2024 22:59:28 +0300 Subject: [PATCH 0598/1963] Fix failing invariant test (#7067) --- crates/evm/fuzz/src/strategies/state.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index ba628f921d074..2beedb1e75a2d 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -259,7 +259,8 @@ pub fn collect_created_contracts( if !setup_contracts.contains_key(address) { if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { if !code.is_empty() { - if let Some((artifact, (abi, _))) = project_contracts.find_by_code(code.bytes()) + if let Some((artifact, (abi, _))) = + project_contracts.find_by_code(&code.original_bytes()) { if let Some(functions) = artifact_filters.get_targeted_functions(artifact, abi)? From d37328af42ea766943f407a7f7448f6965b7ed97 Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Sat, 10 Feb 2024 03:26:03 -0800 Subject: [PATCH 0599/1963] fix(forge): debugger should load sourcemaps by file_id (#7058) * initial fix for sourcemaps in debugger * refactor sources_by_name to ids_by_name * bring up nested or_else * return iterators and update docstring * cargo fmt * then_some -> then * remove whitespace --- crates/common/src/compile.rs | 45 ++++++++++++++++++- crates/debugger/src/tui/draw.rs | 21 +++++++-- crates/debugger/src/tui/mod.rs | 21 ++++----- crates/evm/traces/src/identifier/etherscan.rs | 6 +-- crates/forge/bin/cmd/script/build.rs | 6 +-- crates/forge/bin/cmd/test/mod.rs | 6 +-- 6 files changed, 73 insertions(+), 32 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index eccea208cd043..15debf8a539bd 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -271,9 +271,50 @@ impl ProjectCompiler { } } -/// Map over artifacts contract sources name -> file_id -> (source, contract) +/// Contract source code and bytecode. #[derive(Clone, Debug, Default)] -pub struct ContractSources(pub HashMap>); +pub struct ContractSources { + /// Map over artifacts' contract names -> vector of file IDs + pub ids_by_name: HashMap>, + /// Map over file_id -> (source code, contract) + pub sources_by_id: HashMap, +} + +impl ContractSources { + /// Inserts a contract into the sources. + pub fn insert( + &mut self, + artifact_id: &ArtifactId, + file_id: u32, + source: String, + bytecode: ContractBytecodeSome, + ) { + self.ids_by_name.entry(artifact_id.name.clone()).or_default().push(file_id); + self.sources_by_id.insert(file_id, (source, bytecode)); + } + + /// Returns the source for a contract by file ID. + pub fn get(&self, id: u32) -> Option<&(String, ContractBytecodeSome)> { + self.sources_by_id.get(&id) + } + + /// Returns all sources for a contract by name. + pub fn get_sources( + &self, + name: &str, + ) -> Option> { + self.ids_by_name + .get(name) + .map(|ids| ids.iter().filter_map(|id| Some((*id, self.sources_by_id.get(id)?)))) + } + + /// Returns all (name, source) pairs. + pub fn entries(&self) -> impl Iterator { + self.ids_by_name.iter().flat_map(|(name, ids)| { + ids.iter().filter_map(|id| self.sources_by_id.get(id).map(|s| (name.clone(), s))) + }) + } +} // https://eips.ethereum.org/EIPS/eip-170 const CONTRACT_SIZE_LIMIT: usize = 24576; diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index e38ac170b9104..7a834392986d9 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -334,7 +334,9 @@ impl DebuggerContext<'_> { return Err(format!("Unknown contract at address {address}")); }; - let Some(files_source_code) = self.debugger.contracts_sources.0.get(contract_name) else { + let Some(mut files_source_code) = + self.debugger.contracts_sources.get_sources(contract_name) + else { return Err(format!("No source map index for contract {contract_name}")); }; @@ -345,7 +347,7 @@ impl DebuggerContext<'_> { let is_create = matches!(self.call_kind(), CallKind::Create | CallKind::Create2); let pc = self.current_step().pc; let Some((source_element, source_code)) = - files_source_code.iter().find_map(|(file_id, (source_code, contract_source))| { + files_source_code.find_map(|(file_id, (source_code, contract_source))| { let bytecode = if is_create { &contract_source.bytecode } else { @@ -356,7 +358,20 @@ impl DebuggerContext<'_> { let pc_ic_map = if is_create { create_map } else { rt_map }; let ic = pc_ic_map.get(pc)?; let source_element = source_map.swap_remove(ic); - (*file_id == source_element.index?).then_some((source_element, source_code)) + // if the source element has an index, find the sourcemap for that index + source_element + .index + .and_then(|index| + // if index matches current file_id, return current source code + (index == file_id).then(|| (source_element.clone(), source_code))) + .or_else(|| { + // otherwise find the source code for the element's index + self.debugger + .contracts_sources + .sources_by_id + .get(&(source_element.index?)) + .map(|(source_code, _)| (source_element.clone(), source_code)) + }) }) else { return Err(format!("No source map for contract {contract_name}")); diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 523e7faf15a00..d9543fc58a8d8 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -66,18 +66,15 @@ impl Debugger { breakpoints: Breakpoints, ) -> Self { let pc_ic_maps = contracts_sources - .0 - .iter() - .flat_map(|(contract_name, files_sources)| { - files_sources.iter().filter_map(|(_, (_, contract))| { - Some(( - contract_name.clone(), - ( - PcIcMap::new(SpecId::LATEST, contract.bytecode.bytes()?), - PcIcMap::new(SpecId::LATEST, contract.deployed_bytecode.bytes()?), - ), - )) - }) + .entries() + .filter_map(|(contract_name, (_, contract))| { + Some(( + contract_name.clone(), + ( + PcIcMap::new(SpecId::LATEST, contract.bytecode.bytes()?), + PcIcMap::new(SpecId::LATEST, contract.deployed_bytecode.bytes()?), + ), + )) }) .collect(); Self { debug_arena, identified_contracts, contracts_sources, pc_ic_maps, breakpoints } diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index cb6952ab50dd9..1ddbf2457d6ff 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -87,11 +87,7 @@ impl EtherscanIdentifier { for (results, (_, metadata)) in artifacts.into_iter().zip(contracts_iter) { // get the inner type let (artifact_id, file_id, bytecode) = results?; - sources - .0 - .entry(artifact_id.clone().name) - .or_default() - .insert(file_id, (metadata.source_code(), bytecode)); + sources.insert(&artifact_id, file_id, metadata.source_code(), bytecode); } Ok(sources) diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 27d691eeb7457..979ac5ee5a0f8 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -48,11 +48,7 @@ impl ScriptArgs { })?; let contract = artifact.clone().into_contract_bytecode(); let source_contract = compact_to_contract(contract)?; - sources - .0 - .entry(id.clone().name) - .or_default() - .insert(source.id, (source_code, source_contract)); + sources.insert(&id, source.id, source_code, source_contract); } else { warn!(?id, "source not found"); } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 8fe5966faa472..1a8cf9eed418f 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -272,11 +272,7 @@ impl TestArgs { let source_code = fs::read_to_string(abs_path)?; let contract = artifact.clone().into_contract_bytecode(); let source_contract = compact_to_contract(contract)?; - sources - .0 - .entry(id.name.clone()) - .or_default() - .insert(source.id, (source_code, source_contract)); + sources.insert(&id, source.id, source_code, source_contract); } } From 174752fd1e58b3469ca82bb994cce8e4dffb5577 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:47:20 +0100 Subject: [PATCH 0600/1963] fix(`forge`): forge script --json always returns zero exit code #2508 (#7071) * add basic tests * catch error even if --json is passed * nit --- crates/forge/bin/cmd/script/mod.rs | 7 +++++ crates/forge/tests/cli/script.rs | 41 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 50ae7481ad864..0ab5cb50857d4 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -364,6 +364,13 @@ impl ScriptArgs { let j = serde_json::to_string(&output)?; shell::println(j)?; + if !result.success { + return Err(eyre::eyre!( + "script failed: {}", + decode::decode_revert(&result.returned[..], None, None) + )); + } + Ok(()) } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index f9eade382d275..167145d9d209f 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -107,6 +107,47 @@ contract Demo { ); }); +static FAILING_SCRIPT: &str = r#" +import "forge-std/Script.sol"; + +contract FailingScript is Script { + function run() external { + revert("failed"); + } +} +"#; + +// Tests that execution throws upon encountering a revert in the script. +forgetest_async!(assert_exit_code_error_on_failure_script, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let script = prj.add_source("FailingScript", FAILING_SCRIPT).unwrap(); + + // set up command + cmd.arg("script").arg(script); + + // run command and assert error exit code + cmd.assert_err(); + + let output = cmd.stderr_lossy(); + assert!(output.contains("script failed: revert: failed")); +}); + +// Tests that execution throws upon encountering a revert in the script with --json option. +// +forgetest_async!(assert_exit_code_error_on_failure_script_with_json, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let script = prj.add_source("FailingScript", FAILING_SCRIPT).unwrap(); + + // set up command + cmd.arg("script").arg(script).arg("--json"); + + // run command and assert error exit code + cmd.assert_err(); + + let output = cmd.stderr_lossy(); + assert!(output.contains("script failed: revert: failed")); +}); + // Tests that the manually specified gas limit is used when using the --unlocked option forgetest_async!(can_execute_script_command_with_manual_gas_limit_unlocked, |prj, cmd| { foundry_test_utils::util::initialize(prj.root()); From e5f63a272a384be36be0d55a49998fe2b3405e9d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 10 Feb 2024 17:02:54 +0300 Subject: [PATCH 0601/1963] fix(`forge`): fix cache search for verification (#7053) * fix * fmt * clippy * if let some * fixes --- crates/forge/bin/cmd/verify/etherscan/mod.rs | 61 +++++++++++++++----- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index e973189036fb2..961b6db47d96a 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -11,7 +11,9 @@ use foundry_block_explorers::{ }; use foundry_cli::utils::{get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; use foundry_common::{abi::encode_function_args, retry::Retry}; -use foundry_compilers::{artifacts::CompactContract, cache::CacheEntry, Project, Solc}; +use foundry_compilers::{ + artifacts::CompactContract, cache::CacheEntry, info::ContractInfo, Project, Solc, +}; use foundry_config::{Chain, Config, SolcReq}; use futures::FutureExt; use once_cell::sync::Lazy; @@ -212,15 +214,28 @@ impl EtherscanVerificationProvider { fn cache_entry( &mut self, project: &Project, - contract_name: &str, + contract: &ContractInfo, ) -> Result<&(PathBuf, CacheEntry, CompactContract)> { if let Some(ref entry) = self.cached_entry { return Ok(entry) } let cache = project.read_cache_file()?; - let (path, entry) = get_cached_entry_by_name(&cache, contract_name)?; - let contract: CompactContract = cache.read_artifact(path.clone(), contract_name)?; + let (path, entry) = if let Some(path) = contract.path.as_ref() { + let path = project.root().join(path); + ( + path.clone(), + cache + .entry(&path) + .ok_or_else(|| { + eyre::eyre!(format!("Cache entry not found for {}", path.display())) + })? + .to_owned(), + ) + } else { + get_cached_entry_by_name(&cache, &contract.name)? + }; + let contract: CompactContract = cache.read_artifact(path.clone(), &contract.name)?; Ok(self.cached_entry.insert((path, entry, contract))) } @@ -347,14 +362,13 @@ impl EtherscanVerificationProvider { /// Get the target contract path. If it wasn't provided, attempt a lookup /// in cache. Validate the path indeed exists on disk. fn contract_path(&mut self, args: &VerifyArgs, project: &Project) -> Result { - let path = match args.contract.path.as_ref() { - Some(path) => project.root().join(path), - None => { - let (path, _, _) = self.cache_entry(project, &args.contract.name).wrap_err( - "If cache is disabled, contract info must be provided in the format :", - )?; - path.to_owned() - } + let path = if let Some(path) = args.contract.path.as_ref() { + project.root().join(path) + } else { + let (path, _, _) = self.cache_entry(project, &args.contract).wrap_err( + "If cache is disabled, contract info must be provided in the format :", + )?; + path.to_owned() }; // check that the provided contract is part of the source dir @@ -391,7 +405,7 @@ impl EtherscanVerificationProvider { } } - let (_, entry, _) = self.cache_entry(project, &args.contract.name).wrap_err( + let (_, entry, _) = self.cache_entry(project, &args.contract).wrap_err( "If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml" )?; let artifacts = entry.artifacts_versions().collect::>(); @@ -423,7 +437,7 @@ impl EtherscanVerificationProvider { /// return whatever was set in the [VerifyArgs] args. fn constructor_args(&mut self, args: &VerifyArgs, project: &Project) -> Result> { if let Some(ref constructor_args_path) = args.constructor_args_path { - let (_, _, contract) = self.cache_entry(project, &args.contract.name).wrap_err( + let (_, _, contract) = self.cache_entry(project, &args.contract).wrap_err( "Cache must be enabled in order to use the `--constructor-args-path` option", )?; let abi = @@ -474,6 +488,7 @@ mod tests { use clap::Parser; use foundry_cli::utils::LoadConfig; use foundry_common::fs; + use foundry_test_utils::forgetest_async; use tempfile::tempdir; #[test] @@ -613,4 +628,22 @@ mod tests { "Cache must be enabled in order to use the `--constructor-args-path` option", ); } + + forgetest_async!(respects_path_for_duplicate, |prj, cmd| { + prj.add_source("Counter1", "contract Counter {}").unwrap(); + prj.add_source("Counter2", "contract Counter {}").unwrap(); + + cmd.args(["build", "--force"]).ensure_execute_success().unwrap(); + + let args = VerifyArgs::parse_from([ + "foundry-cli", + "0x0000000000000000000000000000000000000000", + "src/Counter1.sol:Counter", + "--root", + &prj.root().to_string_lossy(), + ]); + + let mut etherscan = EtherscanVerificationProvider::default(); + etherscan.preflight_check(args).await.unwrap(); + }); } From 68c673b1ed40f6fc5ba2898f24c60bca6738bcc1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 10 Feb 2024 15:03:19 +0100 Subject: [PATCH 0602/1963] chore: add warn logs for fork delegations (#7073) --- crates/anvil/src/eth/backend/mem/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index da599966bc068..05a2ae8511a19 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1892,10 +1892,10 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return fork - .debug_trace_transaction(hash, opts) - .await - .map_err(|_| BlockchainError::DataUnavailable) + return fork.debug_trace_transaction(hash, opts).await.map_err(|err| { + warn!(target: "backend", "error delegating debug_traceTransaction: {:?}", err); + BlockchainError::DataUnavailable + }) } Ok(GethTrace::Default(Default::default())) @@ -1921,7 +1921,10 @@ impl Backend { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { - return fork.trace_block(number).await.map_err(|_| BlockchainError::DataUnavailable) + return fork.trace_block(number).await.map_err(|err| { + warn!(target: "backend", "error delegating trace_block: {:?}", err); + BlockchainError::DataUnavailable + }) } } From 219188f87e6beb393bae554022f65c83625f7bf0 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 10 Feb 2024 19:42:18 +0300 Subject: [PATCH 0603/1963] Bump foundry-compilers (#7077) * bump * fix weird formatting * fix cargo deny --- Cargo.lock | 8 ++++---- Cargo.toml | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7a7497e09a91..01e6d3935c4f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3104,9 +3104,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b9af6e08b6e1e2c9fa47cf39edcddeed5e96554d8a205c1fc1a8d2f092220c3" +checksum = "7accbeb76f0a3f75a7fed9c4c008b956311f1c4edbd0b301716647c12f763f6c" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -4536,9 +4536,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libgit2-sys" -version = "0.16.1+1.7.1" +version = "0.16.2+1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index 5baa93d547f61..2bf9584d9812c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,7 @@ foundry-test-utils = { path = "crates/test-utils" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } -foundry-compilers = { version = "0.3.4", default-features = false } +foundry-compilers = { version = "0.3.5", default-features = false } ## revm # no default features to avoid c-kzg @@ -162,7 +162,7 @@ alloy-transport = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } -alloy-primitives = { version ="0.6.2", features = ["getrandom"] } +alloy-primitives = { version = "0.6.2", features = ["getrandom"] } alloy-dyn-abi = "0.6.2" alloy-json-abi = "0.6.2" alloy-sol-types = "0.6.2" @@ -173,7 +173,10 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" eyre = "0.6" From 7271aee55bad39734d4ec67147e9ec9558002279 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 10 Feb 2024 17:45:13 +0100 Subject: [PATCH 0604/1963] chore: rm high priority fee adjustment (#7074) --- crates/anvil/src/eth/fees.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index ef597331a6cd6..d71f8463c4ca8 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -96,10 +96,9 @@ impl FeeManager { /// Returns the suggested fee cap /// - /// This mirrors geth's auto values for `SuggestGasTipCap` which is: `priority fee + 2x current - /// basefee`. + /// Note: This currently returns a constant value: [Self::suggested_priority_fee] pub fn max_priority_fee_per_gas(&self) -> U256 { - self.suggested_priority_fee() + *self.base_fee.read() * U256::from(2) + self.suggested_priority_fee() } /// Returns the current gas price From e897bd6874312d2c2d9acc7d24081ef721845b29 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:58:12 +0200 Subject: [PATCH 0605/1963] chore(deps): remove build-time dependency on libgit2 (#7078) --- Cargo.lock | 38 -------------------------------------- Cargo.toml | 1 + crates/anvil/Cargo.toml | 2 +- crates/cast/Cargo.toml | 2 +- crates/chisel/Cargo.toml | 2 +- crates/forge/Cargo.toml | 2 +- 6 files changed, 5 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01e6d3935c4f3..bead4eaab72e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3564,19 +3564,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "git2" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" -dependencies = [ - "bitflags 2.4.2", - "libc", - "libgit2-sys", - "log", - "url", -] - [[package]] name = "gix-actor" version = "0.20.0" @@ -4534,18 +4521,6 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -[[package]] -name = "libgit2-sys" -version = "0.16.2+1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" -dependencies = [ - "cc", - "libc", - "libz-sys", - "pkg-config", -] - [[package]] name = "libloading" version = "0.8.1" @@ -4585,18 +4560,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "libz-sys" -version = "1.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -8078,7 +8041,6 @@ checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" dependencies = [ "anyhow", "cfg-if", - "git2", "rustversion", "time", ] diff --git a/Cargo.toml b/Cargo.toml index 2bf9584d9812c..9126a020628b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -194,6 +194,7 @@ toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" evm-disassembler = "0.4" +vergen = "8" # TODO: bumping to >=0.13.2 breaks ecrecover: https://github.com/foundry-rs/foundry/pull/6969 # TODO: unpin on next revm release: https://github.com/bluealloy/revm/pull/870 k256 = "=0.13.1" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index f6d4f518561bd..ff59985f0441b 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,7 +16,7 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { version = "8", default-features = false, features = ["build", "git", "git2"] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # foundry internal diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 58c5786b38ca5..952b57f701fef 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -15,7 +15,7 @@ name = "cast" path = "bin/main.rs" [build-dependencies] -vergen = { version = "8", default-features = false, features = ["build", "git", "git2"] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # lib diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 5b22c3065e839..4a6364af66f20 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -15,7 +15,7 @@ name = "chisel" path = "bin/main.rs" [build-dependencies] -vergen = { version = "8", default-features = false, features = ["build", "git", "git2"] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # forge diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 0a6b9c1efbfeb..a939774abd20f 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,7 +15,7 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { version = "8", default-features = false, features = ["build", "git", "git2"] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # lib From 92ba67f45085cf75e8eb72e410367dc117e38e82 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 11 Feb 2024 04:48:28 +0100 Subject: [PATCH 0606/1963] chore(deps): weekly `cargo update` (#7079) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating ahash v0.7.7 -> v0.7.8 (latest: v0.8.7) Updating async-channel v2.1.1 -> v2.2.0 Removing bindgen v0.66.1 Updating bytemuck v1.14.1 -> v1.14.3 Updating c-kzg v0.4.0 -> v0.4.1 Updating cargo-platform v0.1.6 -> v0.1.7 Removing cexpr v0.6.0 Removing clang-sys v1.7.0 Updating clap v4.4.18 -> v4.5.0 Updating clap_builder v4.4.18 -> v4.5.0 Updating clap_complete v4.4.10 -> v4.5.0 Updating clap_complete_fig v4.4.2 -> v4.5.0 Updating clap_derive v4.4.7 -> v4.5.0 Updating clap_lex v0.6.0 -> v0.7.0 Updating const-hex v1.10.0 -> v1.11.0 Updating either v1.9.0 -> v1.10.0 Adding env_filter v0.1.0 Updating env_logger v0.10.2 -> v0.11.1 Adding event-listener v5.0.0 Adding event-listener-strategy v0.5.0 Updating handlebars v4.5.0 -> v5.1.0 Updating indicatif v0.17.7 -> v0.17.8 Updating is-terminal v0.4.10 -> v0.4.12 Updating jobserver v0.1.27 -> v0.1.28 Updating js-sys v0.3.67 -> v0.3.68 Removing lazycell v1.3.0 Removing libloading v0.8.1 Updating mdbook v0.4.36 -> v0.4.37 Updating num-complex v0.4.4 -> v0.4.5 Updating num-integer v0.1.45 -> v0.1.46 Updating num-iter v0.1.43 -> v0.1.44 Updating num-traits v0.2.17 -> v0.2.18 Removing pathdiff v0.2.1 Removing peeking_take_while v0.1.2 Updating pulldown-cmark v0.9.6 -> v0.10.0 Adding pulldown-cmark-escape v0.10.0 Removing rustc-hash v1.1.0 Adding strsim v0.11.0 Removing termcolor v1.4.1 Updating toml_edit v0.22.0 -> v0.22.4 Updating unicode-segmentation v1.10.1 -> v1.11.0 Updating wasm-bindgen v0.2.90 -> v0.2.91 Updating wasm-bindgen-backend v0.2.90 -> v0.2.91 Updating wasm-bindgen-futures v0.4.40 -> v0.4.41 Updating wasm-bindgen-macro v0.2.90 -> v0.2.91 Updating wasm-bindgen-macro-support v0.2.90 -> v0.2.91 Updating wasm-bindgen-shared v0.2.90 -> v0.2.91 Updating web-sys v0.3.67 -> v0.3.68 Updating winnow v0.5.37 -> v0.5.39 note: pass `--verbose` to see 176 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 295 +++++++++++++++++++++++------------------------------ 1 file changed, 125 insertions(+), 170 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bead4eaab72e6..b4550462b1715 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom 0.2.12", "once_cell", @@ -791,13 +791,13 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 4.0.3", - "event-listener-strategy", + "event-listener 5.0.0", + "event-listener-strategy 0.5.0", "futures-core", "pin-project-lite", ] @@ -809,7 +809,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ "event-listener 4.0.3", - "event-listener-strategy", + "event-listener-strategy 0.4.0", "pin-project-lite", ] @@ -1012,29 +1012,6 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" -[[package]] -name = "bindgen" -version = "0.66.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" -dependencies = [ - "bitflags 2.4.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.48", - "which", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -1175,9 +1152,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" @@ -1217,11 +1194,10 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32700dc7904064bb64e857d38a1766607372928e2466ee5f02a869829b3297d7" +checksum = "b9d8c306be83ec04bf5f73710badd8edf56dea23f2f0d8b7f9fe4644d371c758" dependencies = [ - "bindgen", "blst", "cc", "glob", @@ -1241,9 +1217,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -1336,15 +1312,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -1438,22 +1405,11 @@ dependencies = [ "inout", ] -[[package]] -name = "clang-sys" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -1461,14 +1417,14 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.0", "terminal_size", "unicase", "unicode-width", @@ -1476,18 +1432,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.4.10" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb745187d7f4d76267b37485a65e0149edd0e91a4cfcdd3f27524ad86cee9f3" +checksum = "299353be8209bd133b049bf1c63582d184a8b39fd9c04f15fe65f50f88bdfe6c" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "4.4.2" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e571d70e22ec91d34e1c5317c8308035a2280d925167646bf094fc5de1737c" +checksum = "54b3e65f91fabdd23cac3d57d39d5d938b4daabd070c335c006dccb866a61110" dependencies = [ "clap", "clap_complete", @@ -1495,9 +1451,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", @@ -1507,9 +1463,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "clearscreen" @@ -1691,9 +1647,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5104de16b218eddf8e34ffe2f86f74bfa4e61e95a1b89732fccf6325efd0557" +checksum = "18d59688ad0945eaf6b84cb44fedbe93484c81b48970e98f09db8a22832d7961" dependencies = [ "cfg-if", "cpufeatures", @@ -2140,9 +2096,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elasticlunr-rs" @@ -2235,17 +2191,27 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" -version = "0.10.2" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "05e7cf40684ae96ade6232ed84582f40ce0a66efcd43a5117aef610534f8e0b8" dependencies = [ + "anstream", + "anstyle", + "env_filter", "humantime", - "is-terminal", "log", - "regex", - "termcolor", ] [[package]] @@ -2639,6 +2605,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "event-listener" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b72557800024fabbaa2449dd4bf24e37b93702d457a4d4f2b0dd1f0f039f20c1" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + [[package]] name = "event-listener-strategy" version = "0.4.0" @@ -2649,6 +2626,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "event-listener-strategy" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +dependencies = [ + "event-listener 5.0.0", + "pin-project-lite", +] + [[package]] name = "evm-disassembler" version = "0.4.0" @@ -3039,7 +3026,7 @@ dependencies = [ "rusoto_core", "rusoto_kms", "serde", - "strsim", + "strsim 0.10.0", "strum 0.26.1", "tempfile", "thiserror", @@ -3855,9 +3842,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.5.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" +checksum = "ab283476b99e66691dee3f1640fea91487a8d81f50fb5ecc75538f8f8879a1e4" dependencies = [ "log", "pest", @@ -3888,7 +3875,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] [[package]] @@ -4227,9 +4214,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" dependencies = [ "console", "instant", @@ -4323,12 +4310,12 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", - "rustix", + "libc", "windows-sys 0.52.0", ] @@ -4367,18 +4354,18 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -4509,28 +4496,12 @@ dependencies = [ "spin 0.5.2", ] -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -[[package]] -name = "libloading" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "libm" version = "0.2.8" @@ -4655,9 +4626,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.36" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80992cb0e05f22cc052c99f8e883f1593b891014b96a8b4637fd274d7030c85e" +checksum = "0c33564061c3c640bed5ace7d6a2a1b65f2c64257d1ac930c15e94ed0fb561d3" dependencies = [ "ammonia", "anyhow", @@ -4671,7 +4642,6 @@ dependencies = [ "memchr", "once_cell", "opener", - "pathdiff", "pulldown-cmark", "regex", "serde", @@ -4929,9 +4899,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] @@ -4944,19 +4914,18 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -4977,9 +4946,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -5294,12 +5263,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" -[[package]] -name = "pathdiff" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" - [[package]] name = "pbkdf2" version = "0.11.0" @@ -5345,12 +5308,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "pem" version = "1.1.1" @@ -5822,15 +5779,22 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" +checksum = "dce76ce678ffc8e5675b22aa1405de0b7037e2fdf8913fea40d1926c6fe1e6e7" dependencies = [ "bitflags 2.4.2", "memchr", + "pulldown-cmark-escape", "unicase", ] +[[package]] +name = "pulldown-cmark-escape" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d8f9aa0e3cbcfaf8bf00300004ee3b72f74770f9cbac93f6928771f613276b" + [[package]] name = "quick-error" version = "1.2.3" @@ -6398,12 +6362,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-hex" version = "2.1.0" @@ -7120,6 +7078,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "strum" version = "0.25.0" @@ -7342,15 +7306,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "terminal_size" version = "0.3.0" @@ -7609,7 +7564,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.0", + "toml_edit 0.22.4", ] [[package]] @@ -7656,9 +7611,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.0" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8dc77def39ce6079c2d0c866cc20848f591b1898f153c9fe7c4f29e1154510b" +checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" dependencies = [ "indexmap", "serde", @@ -7960,9 +7915,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -8093,9 +8048,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -8103,9 +8058,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -8118,9 +8073,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -8130,9 +8085,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -8140,9 +8095,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -8153,9 +8108,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "watchexec" @@ -8207,9 +8162,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -8492,9 +8447,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.37" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] From 93f094bfa54111f5689c346206d70ef45b4dd680 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 11 Feb 2024 21:00:10 +0200 Subject: [PATCH 0607/1963] perf: add a dyn Cheatcode trait to reduce generated code (#7082) --- Cargo.toml | 7 ++----- crates/cheatcodes/src/lib.rs | 33 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9126a020628b5..cbde283b1f0a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -173,10 +173,7 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" eyre = "0.6" @@ -194,7 +191,7 @@ toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" evm-disassembler = "0.4" -vergen = "8" +vergen = { version = "8", default-features = false } # TODO: bumping to >=0.13.2 breaks ecrecover: https://github.com/foundry-rs/foundry/pull/6969 # TODO: unpin on next revm release: https://github.com/bluealloy/revm/pull/870 k256 = "=0.13.1" diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 856467f2990d7..caaef1d8fee45 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -39,7 +39,7 @@ mod utils; pub use test::expect::ExpectedCallTracker; /// Cheatcode implementation. -pub(crate) trait Cheatcode: CheatcodeDef { +pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { /// Applies this cheatcode to the given state. /// /// Implement this function if you don't need access to the EVM data. @@ -65,13 +65,17 @@ pub(crate) trait Cheatcode: CheatcodeDef { trace_return(&result); return result; - // Separate functions to avoid inline and monomorphization bloat. - fn trace_span(cheat: &T) -> tracing::Span { - if enabled!(tracing::Level::TRACE) { - trace_span!(target: "cheatcodes", "apply", cheat=?cheat) - } else { - debug_span!(target: "cheatcodes", "apply", id=%T::CHEATCODE.func.id) + // Separate and non-generic functions to avoid inline and monomorphization bloat. + fn trace_span(cheat: &dyn DynCheatcode) -> tracing::Span { + let span = debug_span!(target: "cheatcodes", "apply"); + if !span.is_disabled() { + if enabled!(tracing::Level::TRACE) { + span.record("cheat", tracing::field::debug(cheat.as_debug())); + } else { + span.record("id", cheat.cheatcode().func.id); + } } + span } fn trace_call() { @@ -90,6 +94,21 @@ pub(crate) trait Cheatcode: CheatcodeDef { } } +pub(crate) trait DynCheatcode { + fn cheatcode(&self) -> &'static foundry_cheatcodes_spec::Cheatcode<'static>; + fn as_debug(&self) -> &dyn std::fmt::Debug; +} + +impl DynCheatcode for T { + fn cheatcode(&self) -> &'static foundry_cheatcodes_spec::Cheatcode<'static> { + T::CHEATCODE + } + + fn as_debug(&self) -> &dyn std::fmt::Debug { + self + } +} + /// The cheatcode context, used in [`Cheatcode`]. pub(crate) struct CheatsCtxt<'a, 'b, 'c, DB: DatabaseExt> { /// The cheatcodes inspector state. From b783a50d0eabf1615e1ef45c8e5667ad2ae007aa Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 12 Feb 2024 22:29:35 +0300 Subject: [PATCH 0608/1963] init foundry-wallets (#7086) --- Cargo.lock | 34 +++++++-- Cargo.toml | 1 + crates/cast/Cargo.toml | 5 +- crates/cast/bin/cmd/wallet/mod.rs | 2 +- crates/cli/Cargo.toml | 14 +--- crates/cli/src/opts/ethereum.rs | 3 +- crates/cli/src/opts/mod.rs | 2 - crates/cli/src/opts/wallet/error.rs | 11 --- crates/forge/Cargo.toml | 5 +- crates/forge/bin/cmd/script/broadcast.rs | 5 +- crates/forge/bin/cmd/script/mod.rs | 2 +- crates/wallets/Cargo.toml | 38 ++++++++++ crates/wallets/src/error.rs | 22 ++++++ crates/wallets/src/lib.rs | 11 +++ .../wallet => wallets/src}/multi_wallet.rs | 2 +- crates/wallets/src/raw_wallet.rs | 39 ++++++++++ .../wallet/mod.rs => wallets/src/wallet.rs} | 75 +++---------------- 17 files changed, 165 insertions(+), 106 deletions(-) delete mode 100644 crates/cli/src/opts/wallet/error.rs create mode 100644 crates/wallets/Cargo.toml create mode 100644 crates/wallets/src/error.rs create mode 100644 crates/wallets/src/lib.rs rename crates/{cli/src/opts/wallet => wallets/src}/multi_wallet.rs (99%) create mode 100644 crates/wallets/src/raw_wallet.rs rename crates/{cli/src/opts/wallet/mod.rs => wallets/src/wallet.rs} (90%) diff --git a/Cargo.lock b/Cargo.lock index b4550462b1715..8957b6d8f43f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1277,6 +1277,7 @@ dependencies = [ "foundry-config", "foundry-evm", "foundry-test-utils", + "foundry-wallets", "futures", "indicatif", "itertools 0.11.0", @@ -2851,6 +2852,7 @@ dependencies = [ "foundry-debugger", "foundry-evm", "foundry-test-utils", + "foundry-wallets", "futures", "globset", "hyper", @@ -3003,14 +3005,11 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "async-trait", "clap", "color-eyre", - "const-hex", "dotenvy", "ethers-core", "ethers-providers", - "ethers-signers", "eyre", "forge-fmt", "foundry-common", @@ -3018,18 +3017,14 @@ dependencies = [ "foundry-config", "foundry-debugger", "foundry-evm", + "foundry-wallets", "indicatif", - "itertools 0.11.0", "once_cell", "regex", - "rpassword", - "rusoto_core", - "rusoto_kms", "serde", "strsim 0.10.0", "strum 0.26.1", "tempfile", - "thiserror", "tokio", "tracing", "tracing-error", @@ -3341,6 +3336,29 @@ dependencies = [ "walkdir", ] +[[package]] +name = "foundry-wallets" +version = "0.2.0" +dependencies = [ + "alloy-primitives", + "async-trait", + "clap", + "const-hex", + "ethers-core", + "ethers-providers", + "ethers-signers", + "eyre", + "foundry-common", + "foundry-config", + "itertools 0.11.0", + "rpassword", + "rusoto_core", + "rusoto_kms", + "serde", + "thiserror", + "tracing", +] + [[package]] name = "fs2" version = "0.4.3" diff --git a/Cargo.toml b/Cargo.toml index cbde283b1f0a6..94db2e9bb7c85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,6 +124,7 @@ foundry-evm-fuzz = { path = "crates/evm/fuzz" } foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } +foundry-wallets = { path = "crates/wallets" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 952b57f701fef..513de26cb7bab 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -24,6 +24,7 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm.workspace = true +foundry-wallets.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true @@ -78,8 +79,8 @@ criterion = "0.5" [features] default = ["rustls"] -rustls = ["foundry-cli/rustls"] -openssl = ["foundry-cli/openssl"] +rustls = ["foundry-cli/rustls", "foundry-wallets/rustls"] +openssl = ["foundry-cli/openssl", "foundry-wallets/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] [[bench]] diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 2018c4420a8f6..a028f86f80c23 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -9,12 +9,12 @@ use ethers_signers::{ LocalWallet, MnemonicBuilder, Signer, }; use eyre::{Context, Result}; -use foundry_cli::opts::{RawWallet, Wallet}; use foundry_common::{ fs, types::{ToAlloy, ToEthers}, }; use foundry_config::Config; +use foundry_wallets::{RawWallet, Wallet}; use serde_json::json; use std::path::Path; use yansi::Paint; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 4cae11791032d..aad365bb52b09 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -15,6 +15,7 @@ foundry-common.workspace = true foundry-config.workspace = true foundry-debugger.workspace = true foundry-evm.workspace = true +foundry-wallets.workspace = true foundry-compilers = { workspace = true, features = ["full"] } @@ -24,26 +25,17 @@ alloy-primitives.workspace = true ethers-core.workspace = true ethers-providers.workspace = true -ethers-signers = { workspace = true, features = ["aws", "ledger", "trezor"] } -rusoto_core = { version = "0.48", default-features = false } -rusoto_kms = { version = "0.48", default-features = false } - -async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } color-eyre.workspace = true dotenvy = "0.15" eyre.workspace = true -hex = { workspace = true, features = ["serde"] } indicatif = "0.17" -itertools.workspace = true once_cell = "1" regex = { version = "1", default-features = false } -rpassword = "7" serde.workspace = true strsim = "0.10" strum = { workspace = true, features = ["derive"] } -thiserror = "1" tokio = { version = "1", features = ["macros"] } tracing-error = "0.2" tracing-subscriber = { workspace = true, features = ["registry", "env-filter", "fmt"] } @@ -55,5 +47,5 @@ tempfile = "3.7" [features] default = ["rustls"] -rustls = ["ethers-providers/rustls", "rusoto_core/rustls"] -openssl = ["ethers-providers/openssl", "foundry-compilers/openssl"] +rustls = ["ethers-providers/rustls", "foundry-wallets/rustls"] +openssl = ["ethers-providers/openssl", "foundry-compilers/openssl", "foundry-wallets/openssl"] diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 1d3474b1fe156..9a1d8653bf476 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -1,4 +1,4 @@ -use super::{ChainValueParser, Wallet, WalletSigner}; +use crate::opts::ChainValueParser; use clap::Parser; use eyre::Result; use foundry_config::{ @@ -9,6 +9,7 @@ use foundry_config::{ }, impl_figment_convert_cast, Chain, Config, }; +use foundry_wallets::{Wallet, WalletSigner}; use serde::Serialize; use std::borrow::Cow; diff --git a/crates/cli/src/opts/mod.rs b/crates/cli/src/opts/mod.rs index 76480f400ed84..7825cba3c8b36 100644 --- a/crates/cli/src/opts/mod.rs +++ b/crates/cli/src/opts/mod.rs @@ -3,11 +3,9 @@ mod chain; mod dependency; mod ethereum; mod transaction; -mod wallet; pub use build::*; pub use chain::*; pub use dependency::*; pub use ethereum::*; pub use transaction::*; -pub use wallet::*; diff --git a/crates/cli/src/opts/wallet/error.rs b/crates/cli/src/opts/wallet/error.rs deleted file mode 100644 index e8ad90a891de3..0000000000000 --- a/crates/cli/src/opts/wallet/error.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Errors when working with wallets - -use hex::FromHexError; - -#[derive(Debug, thiserror::Error)] -pub enum PrivateKeyError { - #[error("Failed to create wallet from private key. Private key is invalid hex: {0}")] - InvalidHex(#[from] FromHexError), - #[error("Failed to create wallet from private key. Invalid private key. But env var {0} exists. Is the `$` anchor missing?")] - ExistsAsEnvVar(String), -} diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index a939774abd20f..cf4640bb8ab44 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -24,6 +24,7 @@ foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["full"] } foundry-config.workspace = true foundry-evm.workspace = true +foundry-wallets.workspace = true ethers-contract.workspace = true ethers-core.workspace = true @@ -98,8 +99,8 @@ tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } [features] default = ["rustls"] -rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] -openssl = ["foundry-cli/openssl", "reqwest/default-tls"] +rustls = ["foundry-cli/rustls", "foundry-wallets/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] +openssl = ["foundry-cli/openssl", "reqwest/default-tls", "foundry-wallets/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] [[bench]] diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index e32cd02e0c410..7488bbd1071bf 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -8,9 +8,7 @@ use ethers_providers::{JsonRpcClient, Middleware, Provider}; use ethers_signers::Signer; use eyre::{bail, ContextCompat, Result, WrapErr}; use foundry_cli::{ - init_progress, - opts::WalletSigner, - update_progress, + init_progress, update_progress, utils::{has_batch_support, has_different_gas_calc}, }; use foundry_common::{ @@ -18,6 +16,7 @@ use foundry_common::{ shell, types::{ToAlloy, ToEthers}, }; +use foundry_wallets::WalletSigner; use futures::StreamExt; use std::{cmp::min, collections::HashSet, ops::Mul, sync::Arc}; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 0ab5cb50857d4..e6f3d6cfa28d6 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -19,7 +19,6 @@ use forge::{ render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, }; -use foundry_cli::opts::MultiWallet; use foundry_common::{ abi::{encode_function_args, get_func}, contracts::get_contract_name, @@ -47,6 +46,7 @@ use foundry_evm::{ decode, inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, }; +use foundry_wallets::MultiWallet; use futures::future; use itertools::Itertools; use serde::{Deserialize, Serialize}; diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml new file mode 100644 index 0000000000000..f531fd343ce63 --- /dev/null +++ b/crates/wallets/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "foundry-wallets" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +alloy-primitives.workspace = true + +ethers-core.workspace = true +ethers-providers.workspace = true +ethers-signers = { workspace = true, features = ["aws", "ledger", "trezor"] } + +rusoto_core = { version = "0.48", default-features = false } +rusoto_kms = { version = "0.48", default-features = false } + +foundry-config.workspace = true +foundry-common.workspace = true + +async-trait = "0.1" +clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } +eyre.workspace = true +hex = { workspace = true, features = ["serde"] } +itertools.workspace = true +rpassword = "7" +serde.workspace = true +thiserror = "1" +tracing.workspace = true + +[features] +default = ["rustls"] +rustls = ["ethers-providers/rustls", "rusoto_core/rustls"] +openssl = ["ethers-providers/openssl"] diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs new file mode 100644 index 0000000000000..6e6bb5f145db9 --- /dev/null +++ b/crates/wallets/src/error.rs @@ -0,0 +1,22 @@ +use ethers_signers::{AwsSignerError, LedgerError, TrezorError, WalletError}; +use hex::FromHexError; + +#[derive(Debug, thiserror::Error)] +pub enum PrivateKeyError { + #[error("Failed to create wallet from private key. Private key is invalid hex: {0}")] + InvalidHex(#[from] FromHexError), + #[error("Failed to create wallet from private key. Invalid private key. But env var {0} exists. Is the `$` anchor missing?")] + ExistsAsEnvVar(String), +} + +#[derive(Debug, thiserror::Error)] +pub enum WalletSignerError { + #[error(transparent)] + Local(#[from] WalletError), + #[error(transparent)] + Ledger(#[from] LedgerError), + #[error(transparent)] + Trezor(#[from] TrezorError), + #[error(transparent)] + Aws(#[from] AwsSignerError), +} diff --git a/crates/wallets/src/lib.rs b/crates/wallets/src/lib.rs new file mode 100644 index 0000000000000..0e17c4ced3bec --- /dev/null +++ b/crates/wallets/src/lib.rs @@ -0,0 +1,11 @@ +#[macro_use] +extern crate tracing; + +pub mod error; +pub mod multi_wallet; +pub mod raw_wallet; +pub mod wallet; + +pub use multi_wallet::MultiWallet; +pub use raw_wallet::RawWallet; +pub use wallet::{Wallet, WalletSigner}; diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs similarity index 99% rename from crates/cli/src/opts/wallet/multi_wallet.rs rename to crates/wallets/src/multi_wallet.rs index e6d22ff5826a5..4b7280731e5f8 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -1,4 +1,4 @@ -use super::{WalletSigner, WalletTrait}; +use crate::wallet::{WalletSigner, WalletTrait}; use alloy_primitives::Address; use clap::Parser; use ethers_providers::Middleware; diff --git a/crates/wallets/src/raw_wallet.rs b/crates/wallets/src/raw_wallet.rs new file mode 100644 index 0000000000000..e33dc22876c51 --- /dev/null +++ b/crates/wallets/src/raw_wallet.rs @@ -0,0 +1,39 @@ +use clap::Parser; +use serde::Serialize; + +/// A wrapper for the raw data options for `Wallet`, extracted to also be used standalone. +/// The raw wallet options can either be: +/// 1. Private Key (cleartext in CLI) +/// 2. Private Key (interactively via secure prompt) +/// 3. Mnemonic (via file path) +#[derive(Clone, Debug, Default, Serialize, Parser)] +#[clap(next_help_heading = "Wallet options - raw", about = None, long_about = None)] +pub struct RawWallet { + /// Open an interactive prompt to enter your private key. + #[clap(long, short)] + pub interactive: bool, + + /// Use the provided private key. + #[clap(long, value_name = "RAW_PRIVATE_KEY")] + pub private_key: Option, + + /// Use the mnemonic phrase of mnemonic file at the specified path. + #[clap(long, alias = "mnemonic-path")] + pub mnemonic: Option, + + /// Use a BIP39 passphrase for the mnemonic. + #[clap(long, value_name = "PASSPHRASE")] + pub mnemonic_passphrase: Option, + + /// The wallet derivation path. + /// + /// Works with both --mnemonic-path and hardware wallets. + #[clap(long = "mnemonic-derivation-path", alias = "hd-path", value_name = "PATH")] + pub hd_path: Option, + + /// Use the private key from the given mnemonic index. + /// + /// Used with --mnemonic-path. + #[clap(long, conflicts_with = "hd_path", default_value_t = 0, value_name = "INDEX")] + pub mnemonic_index: u32, +} diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/wallets/src/wallet.rs similarity index 90% rename from crates/cli/src/opts/wallet/mod.rs rename to crates/wallets/src/wallet.rs index 49f2fbc8ce39c..1f40b980fe74c 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/wallets/src/wallet.rs @@ -1,4 +1,7 @@ -use crate::opts::error::PrivateKeyError; +use crate::{ + error::{PrivateKeyError, WalletSignerError}, + raw_wallet::RawWallet, +}; use alloy_primitives::Address; use async_trait::async_trait; use clap::Parser; @@ -7,8 +10,8 @@ use ethers_core::types::{ Signature, }; use ethers_signers::{ - coins_bip39::English, AwsSigner, AwsSignerError, HDPath as LedgerHDPath, Ledger, LedgerError, - LocalWallet, MnemonicBuilder, Signer, Trezor, TrezorError, TrezorHDPath, WalletError, + coins_bip39::English, AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, MnemonicBuilder, + Signer, Trezor, TrezorHDPath, WalletError, }; use eyre::{bail, Result, WrapErr}; use foundry_common::{fs, types::ToAlloy}; @@ -24,48 +27,6 @@ use std::{ str::FromStr, }; -pub mod multi_wallet; -pub use multi_wallet::*; - -pub mod error; - -/// A wrapper for the raw data options for `Wallet`, extracted to also be used standalone. -/// The raw wallet options can either be: -/// 1. Private Key (cleartext in CLI) -/// 2. Private Key (interactively via secure prompt) -/// 3. Mnemonic (via file path) -#[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Wallet options - raw", about = None, long_about = None)] -pub struct RawWallet { - /// Open an interactive prompt to enter your private key. - #[clap(long, short)] - pub interactive: bool, - - /// Use the provided private key. - #[clap(long, value_name = "RAW_PRIVATE_KEY")] - pub private_key: Option, - - /// Use the mnemonic phrase of mnemonic file at the specified path. - #[clap(long, alias = "mnemonic-path")] - pub mnemonic: Option, - - /// Use a BIP39 passphrase for the mnemonic. - #[clap(long, value_name = "PASSPHRASE")] - pub mnemonic_passphrase: Option, - - /// The wallet derivation path. - /// - /// Works with both --mnemonic-path and hardware wallets. - #[clap(long = "mnemonic-derivation-path", alias = "hd-path", value_name = "PATH")] - pub hd_path: Option, - - /// Use the private key from the given mnemonic index. - /// - /// Used with --mnemonic-path. - #[clap(long, conflicts_with = "hd_path", default_value_t = 0, value_name = "INDEX")] - pub mnemonic_index: u32, -} - /// The wallet options can either be: /// 1. Raw (via private key / mnemonic file, see `RawWallet`) /// 2. Ledger @@ -143,12 +104,6 @@ pub struct Wallet { pub aws: bool, } -impl From for Wallet { - fn from(options: RawWallet) -> Self { - Self { raw: options, ..Default::default() } - } -} - impl Wallet { pub fn interactive(&self) -> Result> { Ok(if self.raw.interactive { Some(self.get_from_interactive()?) } else { None }) @@ -407,24 +362,18 @@ pub trait WalletTrait { } } +impl From for Wallet { + fn from(options: RawWallet) -> Self { + Self { raw: options, ..Default::default() } + } +} + impl WalletTrait for Wallet { fn sender(&self) -> Option
{ self.from } } -#[derive(Debug, thiserror::Error)] -pub enum WalletSignerError { - #[error(transparent)] - Local(#[from] WalletError), - #[error(transparent)] - Ledger(#[from] LedgerError), - #[error(transparent)] - Trezor(#[from] TrezorError), - #[error(transparent)] - Aws(#[from] AwsSignerError), -} - #[derive(Debug)] pub enum WalletSigner { Local(LocalWallet), From 79d2de6087e313351b8ecd5b0c1308cc39230fad Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:39:33 +0200 Subject: [PATCH 0609/1963] test: manually add install commands (#7090) * test: manually add install commands * test: npm i in snekmate * test: npm if bun is not installed * updatesomestuff --- crates/forge/tests/cli/ext_integration.rs | 35 +++++-- crates/test-utils/src/util.rs | 107 ++++++++++------------ 2 files changed, 72 insertions(+), 70 deletions(-) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index f0044848a198a..76c497837be33 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -8,23 +8,34 @@ fn solmate() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn prb_math() { - ExtTester::new("PaulRBerg", "prb-math", "5b6279a0cf7c1b1b6a5cc96082811f7ef620cf60").run(); + ExtTester::new("PaulRBerg", "prb-math", "5b6279a0cf7c1b1b6a5cc96082811f7ef620cf60") + .install_command(&["bun", "install", "--prefer-offline"]) + // Try npm if bun fails / is not installed. + .install_command(&["npm", "install", "--prefer-offline"]) + .run(); } #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn prb_proxy() { - ExtTester::new("PaulRBerg", "prb-proxy", "fa13cf09fbf544a2d575b45884b8e94a79a02c06").run(); + ExtTester::new("PaulRBerg", "prb-proxy", "fa13cf09fbf544a2d575b45884b8e94a79a02c06") + .install_command(&["bun", "install", "--prefer-offline"]) + // Try npm if bun fails / is not installed. + .install_command(&["npm", "install", "--prefer-offline"]) + .run(); } #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn sablier_v2() { ExtTester::new("sablier-labs", "v2-core", "84758a40077bf3ccb1c8f7bb8d00278e672fbfef") - // skip fork tests + // Skip fork tests. .args(["--nmc", "Fork"]) - // run tests without optimizations + // Run tests without optimizations. .env("FOUNDRY_PROFILE", "lite") + .install_command(&["bun", "install", "--prefer-offline"]) + // Try npm if bun fails / is not installed. + .install_command(&["npm", "install", "--prefer-offline"]) .run(); } @@ -49,7 +60,9 @@ fn stringutils() { #[test] fn lootloose() { - ExtTester::new("gakonst", "lootloose", "7b639efe97836155a6a6fc626bf1018d4f8b2495").run(); + ExtTester::new("gakonst", "lootloose", "7b639efe97836155a6a6fc626bf1018d4f8b2495") + .install_command(&["make", "install"]) + .run(); } #[test] @@ -60,14 +73,16 @@ fn lil_web3() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn snekmate() { - ExtTester::new("pcaversaccio", "snekmate", "ed49a0454393673cdf9a4250dd7051c28e6ac35f").run(); + ExtTester::new("pcaversaccio", "snekmate", "ed49a0454393673cdf9a4250dd7051c28e6ac35f") + .install_command(&["pnpm", "install", "--prefer-offline"]) + // Try npm if pnpm fails / is not installed. + .install_command(&["npm", "install", "--prefer-offline"]) + .run(); } #[test] fn makerdao_multicall() { - ExtTester::new("makerdao", "multicall", "103a8a28e4e372d582d6539b30031bda4cd48e21") - .args(["--block-number", "1"]) - .run(); + ExtTester::new("makerdao", "multicall", "103a8a28e4e372d582d6539b30031bda4cd48e21").run(); } #[test] @@ -93,7 +108,7 @@ fn gunilev() { } #[test] -fn convex() { +fn convex_shutdown_simulation() { ExtTester::new( "mds1", "convex-shutdown-simulation", diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index beed4498b8b02..ec54b1ef6c654 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -60,6 +60,7 @@ pub struct ExtTester { pub fork_block: Option, pub args: Vec, pub envs: Vec<(String, String)>, + pub install_commands: Vec>, } impl ExtTester { @@ -73,6 +74,7 @@ impl ExtTester { fork_block: None, args: vec![], envs: vec![], + install_commands: vec![], } } @@ -121,6 +123,15 @@ impl ExtTester { self } + /// Adds a command to run after the project is cloned. + /// + /// Note that the command is run in the project's root directory, and it won't fail the test if + /// it fails. + pub fn install_command(mut self, command: &[&str]) -> Self { + self.install_commands.push(command.iter().map(|s| s.to_string()).collect()); + self + } + /// Runs the test. pub fn run(&self) { // Skip fork tests if the RPC url is not set. @@ -129,7 +140,7 @@ impl ExtTester { return; } - let (prj, mut cmd) = setup_forge(self.name, self.style.clone()); + let (prj, mut test_cmd) = setup_forge(self.name, self.style.clone()); // Wipe the default structure. prj.wipe(); @@ -141,10 +152,10 @@ impl ExtTester { // Checkout the revision. if self.rev.is_empty() { - let mut cmd = Command::new("git"); - cmd.current_dir(root).args(["log", "-n", "1"]); - eprintln!("$ {cmd:?}"); - let output = cmd.output().unwrap(); + let mut git = Command::new("git"); + git.current_dir(root).args(["log", "-n", "1"]); + eprintln!("$ {git:?}"); + let output = git.output().unwrap(); if !output.status.success() { panic!("git log failed: {output:?}"); } @@ -152,31 +163,44 @@ impl ExtTester { let commit = stdout.lines().next().unwrap().split_whitespace().nth(1).unwrap(); panic!("pin to latest commit: {commit}"); } else { - let mut cmd = Command::new("git"); - cmd.current_dir(root).args(["checkout", self.rev]); - eprintln!("$ {cmd:?}"); - let status = cmd.status().unwrap(); + let mut git = Command::new("git"); + git.current_dir(root).args(["checkout", self.rev]); + eprintln!("$ {git:?}"); + let status = git.status().unwrap(); if !status.success() { panic!("git checkout failed: {status}"); } } - // Run common installation commands. - run_install_commands(prj.root()); + // Run installation command. + for install_command in &self.install_commands { + let mut install_cmd = Command::new(&install_command[0]); + install_cmd.args(&install_command[1..]).current_dir(root); + eprintln!("cd {root}; {install_cmd:?}"); + match install_cmd.status() { + Ok(s) => { + eprintln!("\n\n{install_cmd:?}: {s}"); + if s.success() { + break; + } + } + Err(e) => eprintln!("\n\n{install_cmd:?}: {e}"), + } + } // Run the tests. - cmd.arg("test"); - cmd.args(&self.args); - cmd.args(["--fuzz-runs=256", "--ffi", "-vvvvv"]); + test_cmd.arg("test"); + test_cmd.args(&self.args); + test_cmd.args(["--fuzz-runs=32", "--ffi", "-vvvvv"]); - cmd.envs(self.envs.iter().map(|(k, v)| (k, v))); - cmd.env("FOUNDRY_FUZZ_RUNS", "1"); + test_cmd.envs(self.envs.iter().map(|(k, v)| (k, v))); if let Some(fork_block) = self.fork_block { - cmd.env("FOUNDRY_ETH_RPC_URL", foundry_common::rpc::next_http_archive_rpc_endpoint()); - cmd.env("FOUNDRY_FORK_BLOCK_NUMBER", fork_block.to_string()); + test_cmd + .env("FOUNDRY_ETH_RPC_URL", foundry_common::rpc::next_http_archive_rpc_endpoint()); + test_cmd.env("FOUNDRY_FORK_BLOCK_NUMBER", fork_block.to_string()); } - cmd.assert_non_empty_stdout(); + test_cmd.assert_non_empty_stdout(); } } @@ -252,45 +276,6 @@ pub fn clone_remote(repo_url: &str, target_dir: &str) { eprintln!(); } -/// Runs common installation commands, such as `make` and `npm`. Continues if any command fails. -pub fn run_install_commands(root: &Path) { - let root_files = - std::fs::read_dir(root).unwrap().flatten().map(|x| x.path()).collect::>(); - let contains = |path: &str| root_files.iter().any(|p| p.to_str().unwrap().contains(path)); - let run = |args: &[&str]| { - let mut cmd = Command::new(args[0]); - cmd.args(&args[1..]).current_dir(root); - eprintln!("cd {}; {cmd:?}", root.display()); - match cmd.status() { - Ok(s) => { - eprintln!("\n\n{cmd:?}: {s}"); - s.success() - } - Err(e) => { - eprintln!("\n\n{cmd:?}: {e}"); - false - } - } - }; - let maybe_run = |path: &str, args: &[&str]| { - if contains(path) { - run(args) - } else { - false - } - }; - - maybe_run("Makefile", &["make", "install"]); - - // Only run one of these for `node_modules`. - let mut nm = false; - nm = nm || maybe_run("bun.lockb", &["bun", "install", "--prefer-offline"]); - nm = nm || maybe_run("pnpm-lock.yaml", &["pnpm", "install", "--prefer-offline"]); - nm = nm || maybe_run("yarn.lock", &["yarn", "install", "--prefer-offline"]); - nm = nm || maybe_run("package.json", &["npm", "install", "--prefer-offline"]); - let _ = nm; -} - /// Setup an empty test project and return a command pointing to the forge /// executable whose CWD is set to the project's root. /// @@ -628,7 +613,8 @@ impl TestProject { /// Returns the path to the forge executable. pub fn forge_bin(&self) -> Command { - let forge = self.exe_root.join(format!("../forge{}", env::consts::EXE_SUFFIX)); + let forge = self.exe_root.join("../forge").with_extension(env::consts::EXE_SUFFIX); + let forge = forge.canonicalize().unwrap(); let mut cmd = Command::new(forge); cmd.current_dir(self.inner.root()); // disable color output for comparisons @@ -638,7 +624,8 @@ impl TestProject { /// Returns the path to the cast executable. pub fn cast_bin(&self) -> Command { - let cast = self.exe_root.join(format!("../cast{}", env::consts::EXE_SUFFIX)); + let cast = self.exe_root.join("../cast").with_extension(env::consts::EXE_SUFFIX); + let cast = cast.canonicalize().unwrap(); let mut cmd = Command::new(cast); // disable color output for comparisons cmd.env("NO_COLOR", "1"); From 74b12eef5ee2e500521f3017171c9cc2c306879d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 12 Feb 2024 23:16:03 +0200 Subject: [PATCH 0610/1963] test: don't fail on canonicalize (#7094) --- crates/test-utils/src/util.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index ec54b1ef6c654..ca081bf63edc5 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -613,8 +613,8 @@ impl TestProject { /// Returns the path to the forge executable. pub fn forge_bin(&self) -> Command { - let forge = self.exe_root.join("../forge").with_extension(env::consts::EXE_SUFFIX); - let forge = forge.canonicalize().unwrap(); + let forge = self.exe_root.join(format!("../forge{}", env::consts::EXE_SUFFIX)); + let forge = forge.canonicalize().unwrap_or_else(|_| forge.clone()); let mut cmd = Command::new(forge); cmd.current_dir(self.inner.root()); // disable color output for comparisons @@ -624,8 +624,8 @@ impl TestProject { /// Returns the path to the cast executable. pub fn cast_bin(&self) -> Command { - let cast = self.exe_root.join("../cast").with_extension(env::consts::EXE_SUFFIX); - let cast = cast.canonicalize().unwrap(); + let cast = self.exe_root.join(format!("../cast{}", env::consts::EXE_SUFFIX)); + let cast = cast.canonicalize().unwrap_or_else(|_| cast.clone()); let mut cmd = Command::new(cast); // disable color output for comparisons cmd.env("NO_COLOR", "1"); From 1f19d3c79e8a77172f9f5983cd85f9627f36d09f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 12 Feb 2024 23:52:22 +0200 Subject: [PATCH 0611/1963] perf: touch up flatten_contracts (#7092) --- crates/common/src/contracts.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 86e2abf5b851d..b47e928b11eb3 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -125,12 +125,9 @@ pub fn flatten_contracts( contracts .iter() .filter_map(|(id, c)| { - let bytecode = if deployed_code { - c.deployed_bytecode.clone().into_bytes() - } else { - c.bytecode.clone().into_bytes() - }; - bytecode.map(|bytecode| (id.clone(), (c.abi.clone(), bytecode.into()))) + let bytecode = + if deployed_code { c.deployed_bytecode.bytes() } else { c.bytecode.bytes() }; + bytecode.cloned().map(|code| (id.clone(), (c.abi.clone(), code.into()))) }) .collect(), ) From 0f746d6f87e90a3ff3ee3af0879cf1b9459b9093 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 13 Feb 2024 00:02:10 +0200 Subject: [PATCH 0612/1963] test: don't hardcode an endpoint (#7095) --- crates/evm/core/src/fork/backend.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index eb3638ecea87f..4223e2dea7722 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -684,15 +684,18 @@ mod tests { use foundry_common::provider::alloy::get_http_provider; use foundry_config::{Config, NamedChain}; use std::{collections::BTreeSet, path::PathBuf, sync::Arc}; - const ENDPOINT: &str = "https://mainnet.infura.io/v3/40bee2d557ed4b52908c3e62345a3d8b"; + + const ENDPOINT: Option<&str> = option_env!("ETH_RPC_URL"); #[tokio::test(flavor = "multi_thread")] async fn shared_backend() { - let provider = get_http_provider(ENDPOINT); + let Some(endpoint) = ENDPOINT else { return }; + + let provider = get_http_provider(endpoint); let meta = BlockchainDbMeta { cfg_env: Default::default(), block_env: Default::default(), - hosts: BTreeSet::from([ENDPOINT.to_string()]), + hosts: BTreeSet::from([endpoint.to_string()]), }; let db = BlockchainDb::new(meta, None); @@ -738,7 +741,9 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn can_read_write_cache() { - let provider = get_http_provider(ENDPOINT); + let Some(endpoint) = ENDPOINT else { return }; + + let provider = get_http_provider(endpoint); let block_num = provider.get_block_number().await.unwrap(); @@ -746,11 +751,11 @@ mod tests { let mut evm_opts = config.extract::().unwrap(); evm_opts.fork_block_number = Some(block_num); - let (env, _block) = evm_opts.fork_evm_env(ENDPOINT).await.unwrap(); + let (env, _block) = evm_opts.fork_evm_env(endpoint).await.unwrap(); let fork = CreateFork { enable_caching: true, - url: ENDPOINT.to_string(), + url: endpoint.to_string(), env: env.clone(), evm_opts, }; From 446bba8893e8673ee373f86af01b14234861baf1 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 13 Feb 2024 01:43:24 +0300 Subject: [PATCH 0613/1963] feat: Linking rewrite (#7027) * rewrite linking * fix ci * fix ci 2 * fix ci 3 * docs * Refactor * fix * fix tests * handle root path * tests * clippy * tests * Bump compilers * review fixes * fix Cargo.toml * docs * ok_or_eyre -> ok_or_else for dynamic errors * refactor * filter empty bytecode in scripts * fix known_contracts for tests * get_bytecode_bytes * cycle lib deps * add doc about cyclic dependencies * add missed test file * Update crates/forge/src/link.rs Co-authored-by: Bjerg * LinkerError * clippy * small fix * fmt --------- Co-authored-by: Bjerg --- Cargo.toml | 5 +- crates/forge/bin/cmd/script/build.rs | 211 ++--- crates/forge/bin/cmd/script/cmd.rs | 85 +- crates/forge/bin/cmd/script/executor.rs | 15 +- crates/forge/bin/cmd/script/mod.rs | 2 +- crates/forge/src/link.rs | 1050 +++++++++-------------- crates/forge/src/multi_runner.rs | 109 +-- testdata/linking/cycle/Cycle.t.sol | 16 + 8 files changed, 595 insertions(+), 898 deletions(-) create mode 100644 testdata/linking/cycle/Cycle.t.sol diff --git a/Cargo.toml b/Cargo.toml index 94db2e9bb7c85..6dd40aa25b570 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -174,7 +174,10 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" eyre = "0.6" diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 979ac5ee5a0f8..09cbf20d4438b 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,7 +1,7 @@ use super::*; use alloy_primitives::{Address, Bytes}; use eyre::{Context, ContextCompat, Result}; -use forge::link::{link_with_nonce_or_address, PostLinkInput, ResolvedDependency}; +use forge::link::{LinkOutput, Linker}; use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compact_to_contract, @@ -9,13 +9,13 @@ use foundry_common::{ fs, }; use foundry_compilers::{ - artifacts::{CompactContractBytecode, ContractBytecode, ContractBytecodeSome, Libraries}, + artifacts::{ContractBytecode, ContractBytecodeSome, Libraries}, cache::SolFilesCache, contracts::ArtifactContracts, info::ContractInfo, ArtifactId, Project, ProjectCompileOutput, }; -use std::{collections::BTreeMap, str::FromStr}; +use std::str::FromStr; impl ScriptArgs { /// Compiles the file or project and the verify metadata. @@ -56,32 +56,39 @@ impl ScriptArgs { }) .collect::>()?; - let mut output = self.link( - project, - contracts, - script_config.config.parsed_libraries()?, + let target = self.find_target(&project, &contracts)?.clone(); + script_config.target_contract = Some(target.clone()); + + let libraries = script_config.config.solc_settings()?.libraries; + let linker = Linker::new(project.root(), contracts); + + let (highlevel_known_contracts, libraries, predeploy_libraries) = self.link_script_target( + &linker, + libraries, script_config.evm_opts.sender, script_config.sender_nonce, + target.clone(), )?; - output.sources = sources; - script_config.target_contract = Some(output.target.clone()); + let contract = highlevel_known_contracts.get(&target).unwrap(); - Ok(output) + Ok(BuildOutput { + project, + linker, + contract: contract.clone(), + highlevel_known_contracts, + libraries, + predeploy_libraries, + sources, + }) } - pub fn link( + /// Tries to find artifact for the target script contract. + pub fn find_target<'a>( &self, - project: Project, - contracts: ArtifactContracts, - libraries_addresses: Libraries, - sender: Address, - nonce: u64, - ) -> Result { - let mut run_dependencies = vec![]; - let mut contract = CompactContractBytecode::default(); - let mut highlevel_known_contracts = BTreeMap::new(); - + project: &Project, + contracts: &'a ArtifactContracts, + ) -> Result<&'a ArtifactId> { let mut target_fname = dunce::canonicalize(&self.path) .wrap_err("Couldn't convert contract path to absolute path.")? .strip_prefix(project.root()) @@ -97,114 +104,60 @@ impl ScriptArgs { true }; - let mut extra_info = ExtraLinkingInfo { - no_target_name, - target_fname: target_fname.clone(), - contract: &mut contract, - dependencies: &mut run_dependencies, - matched: false, - target_id: None, - }; - - // link_with_nonce_or_address expects absolute paths - let mut libs = libraries_addresses.clone(); - for (file, libraries) in libraries_addresses.libs.iter() { - if file.is_relative() { - let mut absolute_path = project.root().clone(); - absolute_path.push(file); - libs.libs.insert(absolute_path, libraries.clone()); - } - } - - link_with_nonce_or_address( - contracts.clone(), - &mut highlevel_known_contracts, - libs, - sender, - nonce, - &mut extra_info, - |post_link_input| { - let PostLinkInput { - contract, - known_contracts: highlevel_known_contracts, - id, - extra, - dependencies, - } = post_link_input; + let mut target = None; - fn unique_deps(deps: Vec) -> Vec<(String, Bytes)> { - let mut filtered = Vec::new(); - let mut seen = HashSet::new(); - for dep in deps { - if !seen.insert(dep.id.clone()) { - continue - } - filtered.push((dep.id, dep.bytecode)); + for (id, contract) in contracts.iter() { + if no_target_name { + // Match artifact source, and ignore interfaces + if id.source == std::path::Path::new(&target_fname) && + contract.bytecode.as_ref().map_or(false, |b| b.object.bytes_len() > 0) + { + if target.is_some() { + eyre::bail!("Multiple contracts in the target path. Please specify the contract name with `--tc ContractName`") } - - filtered + target = Some(id); } - - // if it's the target contract, grab the info - if extra.no_target_name { - // Match artifact source, and ignore interfaces - if id.source == std::path::Path::new(&extra.target_fname) && - contract.bytecode.as_ref().map_or(false, |b| b.object.bytes_len() > 0) - { - if extra.matched { - eyre::bail!("Multiple contracts in the target path. Please specify the contract name with `--tc ContractName`") - } - *extra.dependencies = unique_deps(dependencies); - *extra.contract = contract.clone(); - extra.matched = true; - extra.target_id = Some(id.clone()); - } - } else { - let (path, name) = extra - .target_fname - .rsplit_once(':') - .expect("The target specifier is malformed."); - let path = std::path::Path::new(path); - if path == id.source && name == id.name { - *extra.dependencies = unique_deps(dependencies); - *extra.contract = contract.clone(); - extra.matched = true; - extra.target_id = Some(id.clone()); - } + } else { + let (path, name) = + target_fname.rsplit_once(':').expect("The target specifier is malformed."); + let path = std::path::Path::new(path); + if path == id.source && name == id.name { + target = Some(id); } + } + } - if let Ok(tc) = ContractBytecode::from(contract).try_into() { - highlevel_known_contracts.insert(id, tc); - } - - Ok(()) - }, - project.root(), - )?; - - let target = extra_info - .target_id - .ok_or_else(|| eyre::eyre!("Could not find target contract: {}", target_fname))?; - - let (new_libraries, predeploy_libraries): (Vec<_>, Vec<_>) = - run_dependencies.into_iter().unzip(); + target.ok_or_else(|| eyre::eyre!("Could not find target contract: {}", target_fname)) + } - // Merge with user provided libraries - let mut new_libraries = Libraries::parse(&new_libraries)?; - for (file, libraries) in libraries_addresses.libs.into_iter() { - new_libraries.libs.entry(file).or_default().extend(libraries) - } + /// Links script artifact with given libraries or library addresses computed from script sender + /// and nonce. + /// + /// Populates [BuildOutput] with linked target contract, libraries, bytes of libs that need to + /// be predeployed and `highlevel_known_contracts` - set of known fully linked contracts + pub fn link_script_target( + &self, + linker: &Linker, + libraries: Libraries, + sender: Address, + nonce: u64, + target: ArtifactId, + ) -> Result<(ArtifactContracts, Libraries, Vec)> { + let LinkOutput { libs_to_deploy, contracts, libraries } = + linker.link_with_nonce_or_address(libraries, sender, nonce, &target)?; + + // Collect all linked contracts with non-empty bytecode + let highlevel_known_contracts = contracts + .iter() + .filter_map(|(id, contract)| { + ContractBytecodeSome::try_from(ContractBytecode::from(contract.clone())) + .ok() + .map(|tc| (id.clone(), tc)) + }) + .filter(|(_, tc)| tc.bytecode.object.is_non_empty_bytecode()) + .collect(); - Ok(BuildOutput { - target, - contract, - known_contracts: contracts, - highlevel_known_contracts: ArtifactContracts(highlevel_known_contracts), - predeploy_libraries, - sources: Default::default(), - project, - libraries: new_libraries, - }) + Ok((highlevel_known_contracts, libraries, libs_to_deploy)) } pub fn get_project_and_output( @@ -263,20 +216,10 @@ impl ScriptArgs { } } -struct ExtraLinkingInfo<'a> { - no_target_name: bool, - target_fname: String, - contract: &'a mut CompactContractBytecode, - dependencies: &'a mut Vec<(String, Bytes)>, - matched: bool, - target_id: Option, -} - pub struct BuildOutput { pub project: Project, - pub target: ArtifactId, - pub contract: CompactContractBytecode, - pub known_contracts: ArtifactContracts, + pub contract: ContractBytecodeSome, + pub linker: Linker, pub highlevel_known_contracts: ArtifactContracts, pub libraries: Libraries, pub predeploy_libraries: Vec, diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 244615b994ca9..ebb9f97aa5927 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -3,7 +3,8 @@ use alloy_primitives::Bytes; use ethers_providers::Middleware; use ethers_signers::Signer; -use eyre::Result; +use eyre::{OptionExt, Result}; +use forge::link::Linker; use foundry_cli::utils::LoadConfig; use foundry_common::{ contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy, @@ -51,11 +52,10 @@ impl ScriptArgs { ); let BuildOutput { - project, contract, mut highlevel_known_contracts, predeploy_libraries, - known_contracts: default_known_contracts, + linker, sources, mut libraries, .. @@ -70,16 +70,7 @@ impl ScriptArgs { self.execute(&mut script_config, contract, sender, &predeploy_libraries).await?; if self.resume || (self.verify && !self.broadcast) { - return self - .resume_deployment( - script_config, - project, - default_known_contracts, - libraries, - result, - verify, - ) - .await; + return self.resume_deployment(script_config, linker, libraries, result, verify).await; } let known_contracts = flatten_contracts(&highlevel_known_contracts, true); @@ -96,13 +87,7 @@ impl ScriptArgs { } if let Some((new_traces, updated_libraries, updated_contracts)) = self - .maybe_prepare_libraries( - &mut script_config, - project, - default_known_contracts, - predeploy_libraries, - &mut result, - ) + .maybe_prepare_libraries(&mut script_config, linker, predeploy_libraries, &mut result) .await? { decoder = new_traces; @@ -128,8 +113,7 @@ impl ScriptArgs { async fn maybe_prepare_libraries( &mut self, script_config: &mut ScriptConfig, - project: Project, - default_known_contracts: ArtifactContracts, + linker: Linker, predeploy_libraries: Vec, result: &mut ScriptResult, ) -> Result> { @@ -139,15 +123,8 @@ impl ScriptArgs { &predeploy_libraries, )? { // We have a new sender, so we need to relink all the predeployed libraries. - let (libraries, highlevel_known_contracts) = self - .rerun_with_new_deployer( - project, - script_config, - new_sender, - result, - default_known_contracts, - ) - .await?; + let (libraries, highlevel_known_contracts) = + self.rerun_with_new_deployer(script_config, new_sender, result, linker).await?; // redo traces for the new addresses let new_traces = self.decode_traces( @@ -184,8 +161,7 @@ impl ScriptArgs { async fn resume_deployment( &mut self, script_config: ScriptConfig, - project: Project, - default_known_contracts: ArtifactContracts, + linker: Linker, libraries: Libraries, result: ScriptResult, verify: VerifyBundle, @@ -207,8 +183,7 @@ impl ScriptArgs { } self.resume_single_deployment( script_config, - project, - default_known_contracts, + linker, result, verify, ) @@ -222,8 +197,7 @@ impl ScriptArgs { async fn resume_single_deployment( &mut self, script_config: ScriptConfig, - project: Project, - default_known_contracts: ArtifactContracts, + linker: Linker, result: ScriptResult, mut verify: VerifyBundle, ) -> Result<()> { @@ -272,17 +246,24 @@ impl ScriptArgs { } if self.verify { + let target = script_config.target_contract(); + let libraries = Libraries::parse(&deployment_sequence.libraries)? + .with_stripped_file_prefixes(linker.root.as_path()); // We might have predeployed libraries from the broadcasting, so we need to // relink the contracts with them, since their mapping is // not included in the solc cache files. - let BuildOutput { highlevel_known_contracts, .. } = self.link( - project, - default_known_contracts, - Libraries::parse(&deployment_sequence.libraries)?, + let (highlevel_known_contracts, _, predeploy_libraries) = self.link_script_target( + &linker, + libraries, script_config.config.sender, // irrelevant, since we're not creating any 0, // irrelevant, since we're not creating any + target.clone(), )?; + if !predeploy_libraries.is_empty() { + eyre::bail!("Incomplete set of libraries in deployment artifact."); + } + verify.known_contracts = flatten_contracts(&highlevel_known_contracts, false); deployment_sequence.verify_contracts(&script_config.config, verify).await?; @@ -294,11 +275,10 @@ impl ScriptArgs { /// Reruns the execution with a new sender and relinks the libraries accordingly async fn rerun_with_new_deployer( &mut self, - project: Project, script_config: &mut ScriptConfig, new_sender: Address, first_run_result: &mut ScriptResult, - default_known_contracts: ArtifactContracts, + linker: Linker, ) -> Result<(Libraries, ArtifactContracts)> { // if we had a new sender that requires relinking, we need to // get the nonce mainnet for accurate addresses for predeploy libs @@ -311,16 +291,17 @@ impl ScriptArgs { ) .await?; script_config.sender_nonce = nonce; + let target = script_config.target_contract(); - let BuildOutput { - libraries, contract, highlevel_known_contracts, predeploy_libraries, .. - } = self.link( - project, - default_known_contracts, - script_config.config.parsed_libraries()?, - new_sender, - nonce, - )?; + let libraries = script_config.config.solc_settings()?.libraries; + + let (highlevel_known_contracts, libraries, predeploy_libraries) = + self.link_script_target(&linker, libraries, new_sender, nonce, target.clone())?; + + let contract = highlevel_known_contracts + .get(target) + .ok_or_eyre("target not found in linked artifacts")? + .clone(); let mut txs = self.create_deploy_transactions( new_sender, diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index c77c4c1a826d7..588af4c10d1e7 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -14,7 +14,6 @@ use forge::{ }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{provider::ethers::RpcUrl, shell}; -use foundry_compilers::artifacts::CompactContractBytecode; use futures::future::join_all; use parking_lot::RwLock; use std::{collections::VecDeque, sync::Arc}; @@ -25,21 +24,17 @@ impl ScriptArgs { pub async fn execute( &self, script_config: &mut ScriptConfig, - contract: CompactContractBytecode, + contract: ContractBytecodeSome, sender: Address, predeploy_libraries: &[Bytes], ) -> Result { trace!(target: "script", "start executing script"); - let CompactContractBytecode { abi, bytecode, .. } = contract; + let ContractBytecodeSome { abi, bytecode, .. } = contract; - let abi = abi.ok_or_else(|| eyre::eyre!("no ABI found for contract"))?; - let bytecode = bytecode - .ok_or_else(|| eyre::eyre!("no bytecode found for contract"))? - .into_bytes() - .ok_or_else(|| { - eyre::eyre!("expected fully linked bytecode, found unlinked bytecode") - })?; + let bytecode = bytecode.into_bytes().ok_or_else(|| { + eyre::eyre!("expected fully linked bytecode, found unlinked bytecode") + })?; ensure_clean_constructor(&abi)?; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index e6f3d6cfa28d6..9d641abe356ed 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -31,7 +31,7 @@ use foundry_common::{ use foundry_compilers::{ artifacts::{ContractBytecodeSome, Libraries}, contracts::ArtifactContracts, - ArtifactId, Project, + ArtifactId, }; use foundry_config::{ figment, diff --git a/crates/forge/src/link.rs b/crates/forge/src/link.rs index 5eff7ee9ea4a8..97ab5f88a4605 100644 --- a/crates/forge/src/link.rs +++ b/crates/forge/src/link.rs @@ -1,415 +1,211 @@ use alloy_primitives::{Address, Bytes}; -use eyre::Result; -use foundry_compilers::{ - artifacts::{BytecodeObject, CompactBytecode, CompactContractBytecode, Libraries}, - contracts::ArtifactContracts, - ArtifactId, -}; +use foundry_compilers::{artifacts::Libraries, contracts::ArtifactContracts, Artifact, ArtifactId}; +use semver::Version; use std::{ - collections::{BTreeMap, HashMap}, - fmt, + collections::BTreeSet, path::{Path, PathBuf}, str::FromStr, }; -/// Data passed to the post link handler of the linker for each linked artifact. -#[derive(Debug)] -pub struct PostLinkInput<'a, T, U> { - /// The fully linked bytecode of the artifact - pub contract: CompactContractBytecode, - /// All artifacts passed to the linker - pub known_contracts: &'a mut BTreeMap, - /// The ID of the artifact - pub id: ArtifactId, - /// Extra data passed to the handler, which can be used as a scratch space. - pub extra: &'a mut U, - /// Each dependency of the contract in their resolved form. - pub dependencies: Vec, -} - -/// Dependencies for an artifact. -#[derive(Debug)] -struct ArtifactDependencies { - /// All references to dependencies in the artifact's unlinked bytecode. - dependencies: Vec, - /// The ID of the artifact - artifact_id: ArtifactId, +/// Errors that can occur during linking. +#[derive(Debug, thiserror::Error)] +pub enum LinkerError { + #[error("wasn't able to find artifact for library {name} at {file}")] + MissingLibraryArtifact { file: String, name: String }, + #[error("target artifact is not present in provided artifacts set")] + MissingTargetArtifact, + #[error(transparent)] + InvalidAddress(
::Err), } -/// A dependency of an artifact. -#[derive(Debug)] -struct ArtifactDependency { - file: String, - key: String, - version: String, +pub struct Linker { + /// Root of the project, used to determine whether artifact/library path can be stripped. + pub root: PathBuf, + /// Compilation artifacts. + contracts: ArtifactContracts, } -struct ArtifactCode { - code: CompactContractBytecode, - artifact_id: ArtifactId, +/// Output of the `link_with_nonce_or_address` +pub struct LinkOutput { + /// [ArtifactContracts] object containing all artifacts linked with known libraries + /// It is guaranteed to contain `target` and all it's dependencies fully linked, and any other + /// contract may still be partially unlinked. + pub contracts: ArtifactContracts, + /// Resolved library addresses. Contains both user-provided and newly deployed libraries. + /// It will always contain library paths with stripped path prefixes. + pub libraries: Libraries, + /// Vector of libraries that need to be deployed from sender address. + /// The order in which they appear in the vector is the order in which they should be deployed. + pub libs_to_deploy: Vec, } -impl std::fmt::Debug for ArtifactCode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.artifact_id.fmt(f) +impl Linker { + pub fn new(root: impl Into, contracts: ArtifactContracts) -> Self { + Linker { root: root.into(), contracts } } -} - -#[derive(Debug)] -struct AllArtifactsBySlug { - /// all artifacts grouped by identifier - inner: BTreeMap, -} -impl AllArtifactsBySlug { - /// Finds the code for the target of the artifact and the matching key. - fn find_code(&self, identifier: &String, version: &String) -> Option { - trace!(target: "forge::link", identifier, "fetching artifact by identifier"); - let code = self - .inner - .get(identifier) - .or(self.inner.get(&format!("{}.{}", identifier, version)))?; + /// Helper method to convert [ArtifactId] to the format in which libraries are stored in + /// [Libraries] object. + /// + /// Strips project root path from source file path. + fn convert_artifact_id_to_lib_path(&self, id: &ArtifactId) -> (PathBuf, String) { + let path = id.source.strip_prefix(self.root.as_path()).unwrap_or(&id.source); + // name is either {LibName} or {LibName}.{version} + let name = id.name.split('.').next().unwrap(); - Some(code.code.clone()) + (path.to_path_buf(), name.to_owned()) } -} -#[derive(Debug)] -pub struct ResolvedDependency { - /// The address the linker resolved - pub address: Address, - /// The nonce used to resolve the dependency - pub nonce: u64, - pub id: String, - pub bytecode: Bytes, -} + /// Finds an [ArtifactId] object in the given [ArtifactContracts] keys which corresponds to the + /// library path in the form of "./path/to/Lib.sol:Lib" + /// + /// Optionally accepts solc version, and if present, only compares artifacts with given version. + fn find_artifact_id_by_library_path<'a>( + &'a self, + file: &str, + name: &str, + version: Option<&Version>, + ) -> Option<&'a ArtifactId> { + for id in self.contracts.keys() { + if let Some(version) = version { + if id.version != *version { + continue; + } + } + let (artifact_path, artifact_name) = self.convert_artifact_id_to_lib_path(id); -impl std::fmt::Display for ResolvedDependency { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{} @ {} (resolved with nonce {})", self.id, self.address, self.nonce) + if artifact_name == *name && artifact_path == Path::new(file) { + return Some(id); + } + } + + None } -} -/// Links the given artifacts with a link key constructor function, passing the result of each -/// linkage to the given callback. -/// -/// This function will recursively link all artifacts until none are unlinked. It does this by: -/// -/// 1. Using the specified predeployed library addresses (`deployed_library_addresses`) for known -/// libraries (specified by the user) 2. Otherwise, computing the address the library would live at -/// if deployed by `sender`, given a starting nonce of `nonce`. -/// -/// If the library was already deployed previously in step 2, the linker will re-use the previously -/// computed address instead of re-computing it. -/// -/// The linker will call `post_link` for each linked artifact, providing: -/// -/// 1. User-specified data (`extra`) -/// 2. The linked artifact's bytecode -/// 3. The ID of the artifact -/// 4. The dependencies necessary to deploy the contract -/// -/// # Note -/// -/// If you want to collect all dependencies of a set of contracts, you cannot just collect the -/// `dependencies` passed to the callback in a `Vec`, since the same library contract (with the -/// exact same address) might show up as a dependency for multiple contracts. -/// -/// Instead, you must deduplicate *and* preserve the deployment order by pushing the dependencies to -/// a `Vec` iff it has not been seen before. -/// -/// For an example of this, see [here](https://github.com/foundry-rs/foundry/blob/2308972dbc3a89c03488a05aceb3c428bb3e08c0/cli/src/cmd/forge/script/build.rs#L130-L151C9). -#[allow(clippy::too_many_arguments)] -pub fn link_with_nonce_or_address( - contracts: ArtifactContracts, - known_contracts: &mut BTreeMap, - deployed_library_addresses: Libraries, - sender: Address, - nonce: u64, - extra: &mut U, - post_link: impl Fn(PostLinkInput) -> eyre::Result<()>, - root: impl AsRef, -) -> Result<()> { - // create a mapping of fname => Vec<(fname, file, key)>, - let link_tree: BTreeMap = contracts - .iter() - .map(|(id, contract)| { - let key = id.identifier(); - let version = id.version.to_string(); - // Check if the version has metadata appended to it, which will be after the semver - // version with a `+` separator. If so, strip it off. - let version = match version.find('+') { - Some(idx) => (version[..idx]).to_string(), - None => version, - }; - let references = contract - .all_link_references() - .iter() - .flat_map(|(file, link)| link.keys().map(|key| (file.to_string(), key.to_string()))) - .map(|(file, key)| ArtifactDependency { - file, - key, - version: version.clone().to_owned(), - }) - .collect(); - - let references = - ArtifactDependencies { dependencies: references, artifact_id: id.clone() }; - (key, references) - }) - .collect(); - - let artifacts_by_slug = AllArtifactsBySlug { - inner: contracts - .iter() - .map(|(artifact_id, c)| { - ( - artifact_id.identifier(), - ArtifactCode { code: c.clone(), artifact_id: artifact_id.clone() }, - ) - }) - .collect(), - }; - - for (id, contract) in contracts.into_iter() { - let (abi, maybe_deployment_bytes, maybe_runtime) = ( - contract.abi.as_ref(), - contract.bytecode.as_ref(), - contract.deployed_bytecode.as_ref(), - ); - let mut internally_deployed_libraries = HashMap::new(); - - if let (Some(abi), Some(bytecode), Some(runtime)) = - (abi, maybe_deployment_bytes, maybe_runtime) - { - // we are going to mutate, but library contract addresses may change based on - // the test so we clone - let mut target_bytecode = bytecode.clone(); - let mut rt = runtime.clone(); - let mut target_bytecode_runtime = rt.bytecode.expect("No target runtime").clone(); - - // instantiate a vector that gets filled with library deployment bytecode - let mut dependencies = vec![]; - - match bytecode.object { - BytecodeObject::Unlinked(_) => { - trace!(target: "forge::link", target=id.identifier(), version=?id.version, "unlinked contract"); - - // link needed - recurse_link( - id.identifier(), - (&mut target_bytecode, &mut target_bytecode_runtime), - &artifacts_by_slug, - &link_tree, - &mut dependencies, - &mut internally_deployed_libraries, - &deployed_library_addresses, - &mut nonce.clone(), - sender, - root.as_ref(), - ); - } - BytecodeObject::Bytecode(ref bytes) => { - if bytes.as_ref().is_empty() { - // Handle case where bytecode bytes are empty - let tc = CompactContractBytecode { - abi: Some(abi.clone()), - bytecode: None, - deployed_bytecode: None, - }; - - let post_link_input = PostLinkInput { - contract: tc, - known_contracts, - id, - extra, - dependencies, - }; - - post_link(post_link_input)?; - continue - } + /// Performs DFS on the graph of link references, and populates `deps` with all found libraries. + fn collect_dependencies<'a>( + &'a self, + target: &'a ArtifactId, + deps: &mut BTreeSet<&'a ArtifactId>, + ) -> Result<(), LinkerError> { + let references = self + .contracts + .get(target) + .ok_or(LinkerError::MissingTargetArtifact)? + .all_link_references(); + for (file, libs) in &references { + for contract in libs.keys() { + let id = self + .find_artifact_id_by_library_path(file, contract, Some(&target.version)) + .ok_or_else(|| LinkerError::MissingLibraryArtifact { + file: file.to_string(), + name: contract.to_string(), + })?; + if deps.insert(id) { + self.collect_dependencies(id, deps)?; } } + } - rt.bytecode = Some(target_bytecode_runtime); - let tc = CompactContractBytecode { - abi: Some(abi.clone()), - bytecode: Some(target_bytecode), - deployed_bytecode: Some(rt), - }; - - let post_link_input = - PostLinkInput { contract: tc, known_contracts, id, extra, dependencies }; + Ok(()) + } - post_link(post_link_input)?; + /// Links given artifact with either given library addresses or address computed from sender and + /// nonce. + /// + /// Each key in `libraries` should either be a global path or relative to project root. All + /// remappings should be resolved. + /// + /// When calling for `target` being an external library itself, you should check that `target` + /// does not appear in `libs_to_deploy` to avoid deploying it twice. It may happen in cases + /// when there is a dependency cycle including `target`. + pub fn link_with_nonce_or_address<'a>( + &'a self, + libraries: Libraries, + sender: Address, + mut nonce: u64, + target: &'a ArtifactId, + ) -> Result { + // Library paths in `link_references` keys are always stripped, so we have to strip + // user-provided paths to be able to match them correctly. + let mut libraries = libraries.with_stripped_file_prefixes(self.root.as_path()); + + let mut needed_libraries = BTreeSet::new(); + self.collect_dependencies(target, &mut needed_libraries)?; + + let mut libs_to_deploy = Vec::new(); + + // If `libraries` does not contain needed dependency, compute its address and add to + // `libs_to_deploy`. + for id in needed_libraries { + let (lib_path, lib_name) = self.convert_artifact_id_to_lib_path(id); + + libraries.libs.entry(lib_path).or_default().entry(lib_name).or_insert_with(|| { + let address = sender.create(nonce); + libs_to_deploy.push((id, address)); + nonce += 1; + + address.to_checksum(None) + }); } - } - Ok(()) -} -/// Recursively links bytecode given a target contract artifact name, the bytecode(s) to be linked, -/// a mapping of contract artifact name to bytecode, a dependency mapping, a mutable list that -/// will be filled with the predeploy libraries, initial nonce, and the sender. -#[allow(clippy::too_many_arguments)] -fn recurse_link<'a>( - // target name - target: String, - // to-be-modified/linked bytecode - target_bytecode: (&'a mut CompactBytecode, &'a mut CompactBytecode), - // All contract artifacts - artifacts: &'a AllArtifactsBySlug, - // fname => Vec<(fname, file, key)> - dependency_tree: &'a BTreeMap, - // library deployment vector (file:contract:address, bytecode) - deployment: &'a mut Vec, - // libraries we have already deployed during the linking process. - // the key is `file:contract` and the value is the address we computed - internally_deployed_libraries: &'a mut HashMap, - // deployed library addresses fname => address - deployed_library_addresses: &'a Libraries, - // nonce to start at - nonce: &mut u64, - // sender - sender: Address, - // project root path - root: impl AsRef, -) { - // check if we have dependencies - if let Some(dependencies) = dependency_tree.get(&target) { - trace!(target: "forge::link", ?target, "linking contract"); - - // for each dependency, try to link - dependencies.dependencies.iter().for_each(|dep| { - let ArtifactDependency { file, key, version } = dep; - let next_target = format!("{file}:{key}"); - let root = PathBuf::from(root.as_ref().to_str().unwrap()); - // get the dependency - trace!(target: "forge::link", dependency=next_target, file, key, version=?dependencies.artifact_id.version, "get dependency"); - let artifact = match artifacts - .find_code(&next_target, version) { - Some(artifact) => artifact, - None => { - // In some project setups, like JS-style workspaces, you might not have node_modules available at the root of the foundry project. - // In this case, imported dependencies from outside the root might not have their paths tripped correctly. - // Therefore, we fall back to a manual path join to locate the file. - let fallback_path = dunce::canonicalize(root.join(file)).unwrap_or_else(|e| panic!("No artifact for contract \"{next_target}\". Attempted to compose fallback path but got got error {e}")); - let fallback_path = fallback_path.to_str().unwrap_or("No artifact for contract \"{next_target}\". Attempted to compose fallback path but could not create valid string"); - let fallback_target = format!("{fallback_path}:{key}"); - - trace!(target: "forge::link", fallback_dependency=fallback_target, file, key, version=?dependencies.artifact_id.version, "get dependency with fallback path"); - - match artifacts.find_code(&fallback_target, version) { - Some(artifact) => artifact, - None => panic!("No artifact for contract {next_target}"), - }}, - }; - let mut next_target_bytecode = artifact - .bytecode - .unwrap_or_else(|| panic!("No bytecode for contract {next_target}")); - let mut next_target_runtime_bytecode = artifact - .deployed_bytecode - .expect("No target runtime bytecode") - .bytecode - .expect("No target runtime"); - - // make sure dependency is fully linked - if let Some(deps) = dependency_tree.get(&format!("{file}:{key}")) { - if !deps.dependencies.is_empty() { - trace!(target: "forge::link", dependency=next_target, file, key, version=?dependencies.artifact_id.version, "dependency has dependencies"); - - // actually link the nested dependencies to this dependency - recurse_link( - format!("{file}:{key}"), - (&mut next_target_bytecode, &mut next_target_runtime_bytecode), - artifacts, - dependency_tree, - deployment, - internally_deployed_libraries, - deployed_library_addresses, - nonce, - sender, - root, - ); - } - } + // Link contracts + let contracts = self.link(&libraries)?; - let mut deployed_address = None; + // Collect bytecodes for `libs_to_deploy`, as we have them linked now. + let libs_to_deploy = libs_to_deploy + .into_iter() + .map(|(id, _)| contracts.get(id).unwrap().get_bytecode_bytes().unwrap().into_owned()) + .collect(); - if let Some(library_file) = deployed_library_addresses - .libs - .get(&PathBuf::from_str(file).expect("Invalid library path.")) - { - if let Some(address) = library_file.get(key) { - deployed_address = - Some(Address::from_str(address).expect("Invalid library address passed.")); - } - } + Ok(LinkOutput { contracts, libraries, libs_to_deploy }) + } - let address = if let Some(deployed_address) = deployed_address { - trace!(target: "forge::link", dependency=next_target, file, key, "dependency has pre-defined address"); - - // the user specified the library address - deployed_address - } else if let Some((cached_nonce, deployed_address)) = internally_deployed_libraries.get(&format!("{file}:{key}")) { - trace!(target: "forge::link", dependency=next_target, file, key, "dependency was previously deployed"); - - // we previously deployed the library - let library = format!("{file}:{key}:0x{deployed_address:x}"); - - // push the dependency into the library deployment vector - deployment.push(ResolvedDependency { - id: library, - address: *deployed_address, - nonce: *cached_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")), - }); - *deployed_address - } else { - trace!(target: "forge::link", dependency=next_target, file, key, "dependency has to be deployed"); - - // we need to deploy the library - let used_nonce = *nonce; - let computed_address = sender.create(used_nonce); - *nonce += 1; - let library = format!("{file}:{key}:0x{computed_address:x}"); - - // push the dependency into the library deployment vector - deployment.push(ResolvedDependency { - id: library, - address: computed_address, - nonce: used_nonce, - bytecode: next_target_bytecode.object.into_bytes().unwrap_or_else(|| panic!("Bytecode should be linked for {next_target}")), - }); - - // remember this library for later - internally_deployed_libraries.insert(format!("{file}:{key}"), (used_nonce, computed_address)); - - computed_address - }; - - // link the dependency to the target - target_bytecode.0.link(file.clone(), key.clone(), address); - target_bytecode.1.link(file.clone(), key.clone(), address); - trace!(target: "forge::link", ?target, dependency=next_target, file, key, "linking dependency done"); - }); + /// Links given artifacts with given library addresses. + /// + /// Artifacts returned by this function may still be partially unlinked if some of their + /// dependencies weren't present in `libraries`. + pub fn link(&self, libraries: &Libraries) -> Result { + self.contracts + .iter() + .map(|(id, contract)| { + let mut contract = contract.clone(); + + for (file, libs) in &libraries.libs { + for (name, address) in libs { + let address = + Address::from_str(address).map_err(LinkerError::InvalidAddress)?; + if let Some(bytecode) = contract.bytecode.as_mut() { + bytecode.link(file.to_string_lossy(), name, address); + } + if let Some(deployed_bytecode) = + contract.deployed_bytecode.as_mut().and_then(|b| b.bytecode.as_mut()) + { + deployed_bytecode.link(file.to_string_lossy(), name, address); + } + } + } + Ok((id.clone(), contract)) + }) + .collect() } } #[cfg(test)] mod tests { + use std::{collections::HashMap, path::PathBuf}; + use super::*; - use foundry_common::ContractsByArtifact; use foundry_compilers::{Project, ProjectPathsConfig}; struct LinkerTest { - contracts: ArtifactContracts, - dependency_assertions: HashMap>, project: Project, + linker: Linker, + dependency_assertions: HashMap>, } impl LinkerTest { - fn new(path: impl Into) -> Self { + fn new(path: impl Into, strip_prefixes: bool) -> Self { let path = path.into(); let paths = ProjectPathsConfig::builder() .root("../../testdata/linking") @@ -421,302 +217,294 @@ mod tests { let project = Project::builder().paths(paths).ephemeral().no_artifacts().build().unwrap(); - let contracts = project - .compile() - .unwrap() - .with_stripped_file_prefixes(project.root()) + + let mut contracts = project.compile().unwrap(); + + if strip_prefixes { + contracts = contracts.with_stripped_file_prefixes(project.root()); + } + + let contracts = contracts .into_artifacts() .map(|(id, c)| (id, c.into_contract_bytecode())) .collect::(); - Self { contracts, dependency_assertions: HashMap::new(), project } + let linker = Linker::new(project.root(), contracts); + + Self { project, linker, dependency_assertions: HashMap::new() } } fn assert_dependencies( mut self, artifact_id: String, - deps: Vec<(String, u64, Address)>, + deps: Vec<(String, Address)>, ) -> Self { self.dependency_assertions.insert(artifact_id, deps); self } fn test_with_sender_and_nonce(self, sender: Address, initial_nonce: u64) { - let mut called_once = false; - link_with_nonce_or_address( - self.contracts, - &mut ContractsByArtifact::default(), - Default::default(), - sender, - initial_nonce, - &mut called_once, - |post_link_input| { - *post_link_input.extra = true; - let identifier = post_link_input.id.identifier(); - - // Skip ds-test as it always has no dependencies etc. (and the path is outside root so is not sanitized) - if identifier.contains("DSTest") { - return Ok(()) - } + for id in self.linker.contracts.keys() { + // If we didn't strip paths, artifacts will have absolute paths. + // That's expected and we want to ensure that only `libraries` object has relative + // paths, artifacts should be kept as is. + let source = id + .source + .strip_prefix(self.project.root()) + .unwrap_or(&id.source) + .to_string_lossy(); + let identifier = format!("{source}:{}", id.name); + + // Skip ds-test as it always has no dependencies etc. (and the path is outside root + // so is not sanitized) + if identifier.contains("DSTest") { + continue; + } - let assertions = self - .dependency_assertions - .get(&identifier) - .unwrap_or_else(|| panic!("Unexpected artifact: {identifier}")); - - assert_eq!( - post_link_input.dependencies.len(), - assertions.len(), - "artifact {identifier} has more/less dependencies than expected ({} vs {}): {:#?}", - post_link_input.dependencies.len(), - assertions.len(), - post_link_input.dependencies - ); - - for (expected, actual) in assertions.iter().zip(post_link_input.dependencies.iter()) { - let expected_lib_id = format!("{}:{:?}", expected.0, expected.2); - assert_eq!(expected_lib_id, actual.id, "unexpected dependency, expected: {}, got: {}", expected_lib_id, actual.id); - assert_eq!(actual.nonce, expected.1, "nonce wrong for dependency, expected: {}, got: {}", expected.1, actual.nonce); - assert_eq!(actual.address, expected.2, "address wrong for dependency, expected: {}, got: {}", expected.2, actual.address); + let LinkOutput { libs_to_deploy, libraries, .. } = self + .linker + .link_with_nonce_or_address(Default::default(), sender, initial_nonce, id) + .expect("Linking failed"); + + let assertions = self + .dependency_assertions + .get(&identifier) + .unwrap_or_else(|| panic!("Unexpected artifact: {identifier}")); + + assert_eq!( + libs_to_deploy.len(), + assertions.len(), + "artifact {identifier} has more/less dependencies than expected ({} vs {}): {:#?}", + libs_to_deploy.len(), + assertions.len(), + libs_to_deploy + ); + + for (dep_identifier, address) in assertions { + let (file, name) = dep_identifier.split_once(':').unwrap(); + if let Some(lib_address) = + libraries.libs.get(&PathBuf::from(file)).and_then(|libs| libs.get(name)) + { + assert_eq!(*lib_address, address.to_string(), "incorrect library address for dependency {dep_identifier} of {identifier}"); + } else { + panic!("Library not found") } - - Ok(()) - }, - self.project.root(), - ) - .expect("Linking failed"); - - assert!(called_once, "linker did nothing"); + } + } } } + fn link_test(path: impl Into, test_fn: impl Fn(LinkerTest)) { + let path = path.into(); + test_fn(LinkerTest::new(path.clone(), true)); + test_fn(LinkerTest::new(path, false)); + } + #[test] fn link_simple() { - LinkerTest::new("../../testdata/linking/simple") - .assert_dependencies("simple/Simple.t.sol:Lib".to_string(), vec![]) - .assert_dependencies( - "simple/Simple.t.sol:LibraryConsumer".to_string(), - vec![( - "simple/Simple.t.sol:Lib".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - )], - ) - .assert_dependencies( - "simple/Simple.t.sol:SimpleLibraryLinkingTest".to_string(), - vec![( - "simple/Simple.t.sol:Lib".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - )], - ) - .test_with_sender_and_nonce(Address::default(), 1); + link_test("../../testdata/linking/simple", |linker| { + linker + .assert_dependencies("simple/Simple.t.sol:Lib".to_string(), vec![]) + .assert_dependencies( + "simple/Simple.t.sol:LibraryConsumer".to_string(), + vec![( + "simple/Simple.t.sol:Lib".to_string(), + Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), + )], + ) + .assert_dependencies( + "simple/Simple.t.sol:SimpleLibraryLinkingTest".to_string(), + vec![( + "simple/Simple.t.sol:Lib".to_string(), + Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), + )], + ) + .test_with_sender_and_nonce(Address::default(), 1); + }); } #[test] fn link_nested() { - LinkerTest::new("../../testdata/linking/nested") - .assert_dependencies("nested/Nested.t.sol:Lib".to_string(), vec![]) - .assert_dependencies( - "nested/Nested.t.sol:NestedLib".to_string(), - vec![( - "nested/Nested.t.sol:Lib".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - )], - ) - .assert_dependencies( - "nested/Nested.t.sol:LibraryConsumer".to_string(), - vec![ - // Lib shows up here twice, because the linker sees it twice, but it should - // have the same address and nonce. - ( - "nested/Nested.t.sol:Lib".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( + link_test("../../testdata/linking/nested", |linker| { + linker + .assert_dependencies("nested/Nested.t.sol:Lib".to_string(), vec![]) + .assert_dependencies( + "nested/Nested.t.sol:NestedLib".to_string(), + vec![( "nested/Nested.t.sol:Lib".to_string(), - 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "nested/Nested.t.sol:NestedLib".to_string(), - 2, - Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), - ), - ], - ) - .assert_dependencies( - "nested/Nested.t.sol:NestedLibraryLinkingTest".to_string(), - vec![ - ( - "nested/Nested.t.sol:Lib".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "nested/Nested.t.sol:Lib".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "nested/Nested.t.sol:NestedLib".to_string(), - 2, - Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), - ), - ], - ) - .test_with_sender_and_nonce(Address::default(), 1); + )], + ) + .assert_dependencies( + "nested/Nested.t.sol:LibraryConsumer".to_string(), + vec![ + // Lib shows up here twice, because the linker sees it twice, but it should + // have the same address and nonce. + ( + "nested/Nested.t.sol:Lib".to_string(), + Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") + .unwrap(), + ), + ( + "nested/Nested.t.sol:NestedLib".to_string(), + Address::from_str("0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D") + .unwrap(), + ), + ], + ) + .assert_dependencies( + "nested/Nested.t.sol:NestedLibraryLinkingTest".to_string(), + vec![ + ( + "nested/Nested.t.sol:Lib".to_string(), + Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") + .unwrap(), + ), + ( + "nested/Nested.t.sol:NestedLib".to_string(), + Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") + .unwrap(), + ), + ], + ) + .test_with_sender_and_nonce(Address::default(), 1); + }); } - /// This test ensures that complicated setups with many libraries, some of which are referenced - /// in more than one place, result in correct linking. - /// - /// Each `assert_dependencies` should be considered in isolation, i.e. read it as "if I wanted - /// to deploy this contract, I would have to deploy the dependencies in this order with this - /// nonce". - /// - /// A library may show up more than once, but it should *always* have the same nonce and address - /// with respect to the single `assert_dependencies` call. There should be no gaps in the nonce - /// otherwise, i.e. whenever a new dependency is encountered, the nonce should be a single - /// increment larger than the previous largest nonce. #[test] fn link_duplicate() { - LinkerTest::new("../../testdata/linking/duplicate") - .assert_dependencies("duplicate/Duplicate.t.sol:A".to_string(), vec![]) - .assert_dependencies("duplicate/Duplicate.t.sol:B".to_string(), vec![]) - .assert_dependencies( - "duplicate/Duplicate.t.sol:C".to_string(), - vec![( - "duplicate/Duplicate.t.sol:A".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - )], - ) - .assert_dependencies( - "duplicate/Duplicate.t.sol:D".to_string(), - vec![( - "duplicate/Duplicate.t.sol:B".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - )], - ) - .assert_dependencies( - "duplicate/Duplicate.t.sol:E".to_string(), - vec![ - ( - "duplicate/Duplicate.t.sol:A".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:C".to_string(), - 2, - Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), - ), - ], - ) - .assert_dependencies( - "duplicate/Duplicate.t.sol:LibraryConsumer".to_string(), - vec![ - ( + link_test("../../testdata/linking/duplicate", |linker| { + linker + .assert_dependencies("duplicate/Duplicate.t.sol:A".to_string(), vec![]) + .assert_dependencies("duplicate/Duplicate.t.sol:B".to_string(), vec![]) + .assert_dependencies( + "duplicate/Duplicate.t.sol:C".to_string(), + vec![( "duplicate/Duplicate.t.sol:A".to_string(), - 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:B".to_string(), - 2, - Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:A".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:C".to_string(), - 3, - Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:B".to_string(), - 2, - Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:D".to_string(), - 4, - Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:A".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:C".to_string(), - 3, - Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:E".to_string(), - 5, - Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f").unwrap(), - ), - ], - ) - .assert_dependencies( - "duplicate/Duplicate.t.sol:DuplicateLibraryLinkingTest".to_string(), - vec![ - ( - "duplicate/Duplicate.t.sol:A".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:B".to_string(), - 2, - Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:A".to_string(), - 1, - Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:C".to_string(), - 3, - Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), - ), - ( + )], + ) + .assert_dependencies( + "duplicate/Duplicate.t.sol:D".to_string(), + vec![( "duplicate/Duplicate.t.sol:B".to_string(), - 2, - Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:D".to_string(), - 4, - Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:A".to_string(), - 1, Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:C".to_string(), - 3, - Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca").unwrap(), - ), - ( - "duplicate/Duplicate.t.sol:E".to_string(), - 5, - Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f").unwrap(), - ), - ], - ) - .test_with_sender_and_nonce(Address::default(), 1); + )], + ) + .assert_dependencies( + "duplicate/Duplicate.t.sol:E".to_string(), + vec![ + ( + "duplicate/Duplicate.t.sol:A".to_string(), + Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:C".to_string(), + Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") + .unwrap(), + ), + ], + ) + .assert_dependencies( + "duplicate/Duplicate.t.sol:LibraryConsumer".to_string(), + vec![ + ( + "duplicate/Duplicate.t.sol:A".to_string(), + Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:B".to_string(), + Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:C".to_string(), + Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:D".to_string(), + Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:E".to_string(), + Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f") + .unwrap(), + ), + ], + ) + .assert_dependencies( + "duplicate/Duplicate.t.sol:DuplicateLibraryLinkingTest".to_string(), + vec![ + ( + "duplicate/Duplicate.t.sol:A".to_string(), + Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:B".to_string(), + Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:C".to_string(), + Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:D".to_string(), + Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782") + .unwrap(), + ), + ( + "duplicate/Duplicate.t.sol:E".to_string(), + Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f") + .unwrap(), + ), + ], + ) + .test_with_sender_and_nonce(Address::default(), 1); + }); + } + + #[test] + fn link_cycle() { + link_test("../../testdata/linking/cycle", |linker| { + linker + .assert_dependencies( + "cycle/Cycle.t.sol:Foo".to_string(), + vec![ + ( + "cycle/Cycle.t.sol:Foo".to_string(), + Address::from_str("0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D") + .unwrap(), + ), + ( + "cycle/Cycle.t.sol:Bar".to_string(), + Address::from_str("0x5a443704dd4B594B382c22a083e2BD3090A6feF3") + .unwrap(), + ), + ], + ) + .assert_dependencies( + "cycle/Cycle.t.sol:Bar".to_string(), + vec![ + ( + "cycle/Cycle.t.sol:Foo".to_string(), + Address::from_str("0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D") + .unwrap(), + ), + ( + "cycle/Cycle.t.sol:Bar".to_string(), + Address::from_str("0x5a443704dd4B594B382c22a083e2BD3090A6feF3") + .unwrap(), + ), + ], + ) + .test_with_sender_and_nonce(Address::default(), 1); + }); } } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index b7c49e887627d..4f9f7bce9f220 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,17 +1,16 @@ //! Forge test runner for multiple contracts. use crate::{ - link::{link_with_nonce_or_address, PostLinkInput, ResolvedDependency}, + link::{LinkOutput, Linker}, result::SuiteResult, ContractRunner, TestFilter, TestOptions, }; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; -use eyre::Result; +use eyre::{OptionExt, Result}; use foundry_common::{ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{ - artifacts::CompactContractBytecode, contracts::ArtifactContracts, Artifact, ArtifactId, - ArtifactOutput, ProjectCompileOutput, + artifacts::CompactContractBytecode, Artifact, ArtifactId, ArtifactOutput, ProjectCompileOutput, }; use foundry_evm::{ backend::Backend, @@ -24,7 +23,8 @@ use foundry_evm::{ use rayon::prelude::*; use revm::primitives::SpecId; use std::{ - collections::{BTreeMap, HashSet}, + collections::BTreeMap, + fmt::Debug, iter::Iterator, path::Path, sync::{mpsc, Arc}, @@ -263,12 +263,12 @@ impl MultiContractRunnerBuilder { evm_opts: EvmOpts, ) -> Result where - A: ArtifactOutput, + A: ArtifactOutput + Debug, { + let output = output.with_stripped_file_prefixes(&root); // This is just the contracts compiled, but we need to merge this with the read cached // artifacts let contracts = output - .with_stripped_file_prefixes(&root) .into_artifacts() .map(|(i, c)| (i, c.into_contract_bytecode())) .collect::>(); @@ -281,72 +281,43 @@ impl MultiContractRunnerBuilder { // create a mapping of name => (abi, deployment code, Vec) let mut deployable_contracts = DeployableContracts::default(); - fn unique_deps(deps: Vec) -> Vec { - let mut filtered = Vec::new(); - let mut seen = HashSet::new(); - for dep in deps { - if !seen.insert(dep.id.clone()) { - continue - } - filtered.push(dep); + let artifact_contracts = contracts.iter().cloned().collect(); + + let linker = Linker::new(root.as_ref(), artifact_contracts); + + for (id, contract) in contracts { + let abi = contract.abi.as_ref().ok_or_eyre("we should have an abi by now")?; + + let LinkOutput { contracts, libs_to_deploy, .. } = + linker.link_with_nonce_or_address(Default::default(), evm_opts.sender, 1, &id)?; + + let linked_contract = contracts.get(&id).unwrap().clone(); + + // get bytes if deployable, else add to known contracts and continue. + // interfaces and abstract contracts should be known to enable fuzzing of their ABI + // but they should not be deployable and their source code should be skipped by the + // debugger and linker. + let Some(bytecode) = linked_contract + .get_bytecode_bytes() + .map(|b| b.into_owned()) + .filter(|b| !b.is_empty()) + else { + known_contracts.insert(id.clone(), (abi.clone(), vec![])); + continue; + }; + + // if it's a test, add it to deployable contracts + if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && + abi.functions().any(|func| func.name.is_test() || func.name.is_invariant_test()) + { + deployable_contracts.insert(id.clone(), (abi.clone(), bytecode, libs_to_deploy)); } - filtered + linked_contract.get_deployed_bytecode_bytes().map(|b| b.into_owned()).and_then( + |bytes| known_contracts.insert(id.clone(), (abi.clone(), bytes.to_vec())), + ); } - link_with_nonce_or_address( - ArtifactContracts::from_iter(contracts), - &mut known_contracts, - Default::default(), - evm_opts.sender, - 1, - &mut deployable_contracts, - |post_link_input| { - let PostLinkInput { - contract, - known_contracts, - id, - extra: deployable_contracts, - dependencies, - } = post_link_input; - let dependencies = unique_deps(dependencies); - - let abi = contract.abi.expect("We should have an abi by now"); - - // get bytes if deployable, else add to known contracts and return. - // interfaces and abstract contracts should be known to enable fuzzing of their ABI - // but they should not be deployable and their source code should be skipped by the - // debugger and linker. - let Some(bytecode) = contract.bytecode.and_then(|b| b.object.into_bytes()) else { - known_contracts.insert(id.clone(), (abi.clone(), vec![])); - return Ok(()) - }; - - // if it's a test, add it to deployable contracts - if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && - abi.functions() - .any(|func| func.name.is_test() || func.name.is_invariant_test()) - { - deployable_contracts.insert( - id.clone(), - ( - abi.clone(), - bytecode, - dependencies.into_iter().map(|dep| dep.bytecode).collect::>(), - ), - ); - } - - contract - .deployed_bytecode - .and_then(|d_bcode| d_bcode.bytecode) - .and_then(|bcode| bcode.object.into_bytes()) - .and_then(|bytes| known_contracts.insert(id.clone(), (abi, bytes.to_vec()))); - Ok(()) - }, - root, - )?; - let execution_info = known_contracts.flatten(); Ok(MultiContractRunner { contracts: deployable_contracts, diff --git a/testdata/linking/cycle/Cycle.t.sol b/testdata/linking/cycle/Cycle.t.sol new file mode 100644 index 0000000000000..424bc001fbab6 --- /dev/null +++ b/testdata/linking/cycle/Cycle.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +library Foo { + function foo() external { + Bar.bar(); + } + + function flum() external {} +} + +library Bar { + function bar() external { + Foo.flum(); + } +} From 5a9b1dce1c413788d5ce7ac3dbf7a49260a43b85 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 13 Feb 2024 10:20:37 -0400 Subject: [PATCH 0614/1963] chore: remove unneeded ethers conversions (#7103) --- crates/common/src/types.rs | 109 ++----------------------------------- 1 file changed, 5 insertions(+), 104 deletions(-) diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index 2917d92edd6e2..6f4284b324104 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -1,6 +1,5 @@ //! Temporary utility conversion traits between ethers-rs and alloy types. -use alloy_json_abi::{Event, EventParam, Function, InternalType, Param, StateMutability}; use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U128, U256, U64}; use alloy_rpc_types::{ other::OtherFields, @@ -8,15 +7,12 @@ use alloy_rpc_types::{ AccessList, AccessListItem, Signature, Transaction, }; use alloy_signer::{LocalWallet, Signer}; -use ethers_core::{ - abi as ethabi, - types::{ - transaction::eip2930::{ - AccessList as EthersAccessList, AccessListItem as EthersAccessListItem, - }, - Bloom as EthersBloom, Bytes as EthersBytes, TransactionRequest, H160, H256, H64, - I256 as EthersI256, U256 as EthersU256, U64 as EthersU64, +use ethers_core::types::{ + transaction::eip2930::{ + AccessList as EthersAccessList, AccessListItem as EthersAccessListItem, }, + Bloom as EthersBloom, Bytes as EthersBytes, TransactionRequest, H160, H256, H64, + I256 as EthersI256, U256 as EthersU256, U64 as EthersU64, }; /// Conversion trait to easily convert from Ethers types to Alloy types. @@ -211,101 +207,6 @@ impl ToAlloy for EthersAccessListItem { } } -impl ToAlloy for ethabi::Event { - type To = Event; - - fn to_alloy(self) -> Self::To { - Event { - name: self.name, - inputs: self.inputs.into_iter().map(ToAlloy::to_alloy).collect(), - anonymous: self.anonymous, - } - } -} - -impl ToAlloy for ethabi::Function { - type To = Function; - - fn to_alloy(self) -> Self::To { - Function { - name: self.name, - inputs: self.inputs.into_iter().map(ToAlloy::to_alloy).collect(), - outputs: self.outputs.into_iter().map(ToAlloy::to_alloy).collect(), - state_mutability: self.state_mutability.to_alloy(), - } - } -} - -impl ToAlloy for ethabi::Param { - type To = Param; - - fn to_alloy(self) -> Self::To { - let (ty, components) = self.kind.to_alloy(); - Param { - name: self.name, - ty, - internal_type: self.internal_type.as_deref().and_then(InternalType::parse), - components, - } - } -} - -impl ToAlloy for ethabi::EventParam { - type To = EventParam; - - fn to_alloy(self) -> Self::To { - let (ty, components) = self.kind.to_alloy(); - EventParam { name: self.name, ty, internal_type: None, components, indexed: self.indexed } - } -} - -impl ToAlloy for ethabi::ParamType { - type To = (String, Vec); - - fn to_alloy(self) -> Self::To { - let (s, t) = split_pt(self); - (s, t.into_iter().map(pt_to_param).collect()) - } -} - -fn split_pt(x: ethabi::ParamType) -> (String, Vec) { - let s = ethabi::ethabi::param_type::Writer::write_for_abi(&x, false); - let t = get_tuple(x); - (s, t) -} - -fn get_tuple(x: ethabi::ParamType) -> Vec { - match x { - ethabi::ParamType::FixedArray(x, _) | ethabi::ParamType::Array(x) => get_tuple(*x), - ethabi::ParamType::Tuple(t) => t, - _ => Default::default(), - } -} - -fn pt_to_param(x: ethabi::ParamType) -> Param { - let (ty, components) = split_pt(x); - Param { - name: String::new(), - ty, - internal_type: None, - components: components.into_iter().map(pt_to_param).collect(), - } -} - -impl ToAlloy for ethabi::StateMutability { - type To = StateMutability; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - match self { - ethabi::StateMutability::Pure => StateMutability::Pure, - ethabi::StateMutability::View => StateMutability::View, - ethabi::StateMutability::NonPayable => StateMutability::NonPayable, - ethabi::StateMutability::Payable => StateMutability::Payable, - } - } -} - /// Conversion trait to easily convert from Alloy types to Ethers types. pub trait ToEthers { /// The corresponding Ethers type. From 29ad753b516d887d97fdb7695cff58fe7062b6bd Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 13 Feb 2024 11:05:12 -0400 Subject: [PATCH 0615/1963] feat(`cast`): `cast wallet` & `cast run` alloy migration (#7088) * feat: partially migrate a few cast files * migrate cast wallet vanity * migrate cast wallet * clippy * clippy * nits * Apply suggestions from code review Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * nits * chore: remove comment --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 3 ++ crates/cast/Cargo.toml | 3 ++ crates/cast/bin/cmd/run.rs | 60 ++++++++++++++++------------ crates/cast/bin/cmd/wallet/mod.rs | 56 +++++++++++--------------- crates/cast/bin/cmd/wallet/vanity.rs | 12 +++--- crates/cast/src/base.rs | 8 ++-- crates/cast/src/lib.rs | 12 +++--- 7 files changed, 79 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8957b6d8f43f3..7722eae46ce72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1251,7 +1251,10 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-providers", "alloy-rlp", + "alloy-rpc-types", + "alloy-signer", "async-trait", "chrono", "clap", diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 513de26cb7bab..e97ae59c52414 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -30,6 +30,9 @@ alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-rlp.workspace = true +alloy-providers.workspace = true +alloy-rpc-types.workspace = true +alloy-signer.workspace = true ethers-core.workspace = true ethers-providers.workspace = true diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index fb7ae35cba073..2f3050e4c450c 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,14 +1,15 @@ use alloy_primitives::U256; +use alloy_providers::provider::TempProvider; +use alloy_rpc_types::BlockTransactions; use clap::Parser; -use ethers_providers::Middleware; use eyre::{Result, WrapErr}; use foundry_cli::{ init_progress, opts::RpcOpts, - update_progress, utils, + update_progress, utils::{handle_traces, TraceResult}, }; -use foundry_common::{is_known_system_sender, types::ToAlloy, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{ @@ -87,19 +88,21 @@ impl RunArgs { let compute_units_per_second = if self.no_rate_limit { Some(u64::MAX) } else { self.compute_units_per_second }; - let provider = utils::get_provider_builder(&config)? - .compute_units_per_second_opt(compute_units_per_second) - .build()?; + let provider = foundry_common::provider::alloy::ProviderBuilder::new( + &config.get_rpc_url_or_localhost_http()?, + ) + .compute_units_per_second_opt(compute_units_per_second) + .build()?; let tx_hash = self.tx_hash.parse().wrap_err("invalid tx hash")?; let tx = provider - .get_transaction(tx_hash) - .await? - .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; + .get_transaction_by_hash(tx_hash) + .await + .wrap_err_with(|| format!("tx not found: {:?}", tx_hash))?; // check if the tx is a system transaction - if is_known_system_sender(tx.from.to_alloy()) || - tx.transaction_type.map(|ty| ty.as_u64()) == Some(SYSTEM_TRANSACTION_TYPE) + if is_known_system_sender(tx.from) || + tx.transaction_type.map(|ty| ty.to::()) == Some(SYSTEM_TRANSACTION_TYPE) { return Err(eyre::eyre!( "{:?} is a system transaction.\nReplaying system transactions is currently not supported.", @@ -110,7 +113,7 @@ impl RunArgs { let tx_block_number = tx .block_number .ok_or_else(|| eyre::eyre!("tx may still be pending: {:?}", tx_hash))? - .as_u64(); + .to::(); // we need to fork off the parent block config.fork_block_number = Some(tx_block_number - 1); @@ -122,14 +125,14 @@ impl RunArgs { env.block.number = U256::from(tx_block_number); - let block = provider.get_block_with_txs(tx_block_number).await?; + let block = provider.get_block(tx_block_number.into(), true).await?; if let Some(ref block) = block { - env.block.timestamp = block.timestamp.to_alloy(); - env.block.coinbase = block.author.unwrap_or_default().to_alloy(); - env.block.difficulty = block.difficulty.to_alloy(); - env.block.prevrandao = Some(block.mix_hash.map(|h| h.to_alloy()).unwrap_or_default()); - env.block.basefee = block.base_fee_per_gas.unwrap_or_default().to_alloy(); - env.block.gas_limit = block.gas_limit.to_alloy(); + env.block.timestamp = block.header.timestamp; + env.block.coinbase = block.header.miner; + env.block.difficulty = block.header.difficulty; + env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); + env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default(); + env.block.gas_limit = block.header.gas_limit; } // Set the state to the moment right before the transaction @@ -140,11 +143,16 @@ impl RunArgs { let pb = init_progress!(block.transactions, "tx"); pb.set_position(0); - for (index, tx) in block.transactions.into_iter().enumerate() { - // System transactions such as on L2s don't contain any pricing info so we skip - // them otherwise this would cause reverts - if is_known_system_sender(tx.from.to_alloy()) || - tx.transaction_type.map(|ty| ty.as_u64()) == + let BlockTransactions::Full(txs) = block.transactions else { + return Err(eyre::eyre!("Could not get block txs")) + }; + + for (index, tx) in txs.into_iter().enumerate() { + // System transactions such as on L2s don't contain any pricing info so + // we skip them otherwise this would cause + // reverts + if is_known_system_sender(tx.from) || + tx.transaction_type.map(|ty| ty.to::()) == Some(SYSTEM_TRANSACTION_TYPE) { update_progress!(pb, index); @@ -154,7 +162,7 @@ impl RunArgs { break; } - configure_tx_env(&mut env, &tx.clone().to_alloy()); + configure_tx_env(&mut env, &tx); if let Some(to) = tx.to { trace!(tx=?tx.hash,?to, "executing previous call transaction"); @@ -191,7 +199,7 @@ impl RunArgs { let result = { executor.set_trace_printer(self.trace_printer); - configure_tx_env(&mut env, &tx.clone().to_alloy()); + configure_tx_env(&mut env, &tx); if let Some(to) = tx.to { trace!(tx=?tx.hash, to=?to, "executing call transaction"); diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index a028f86f80c23..acf578dc02bbb 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,22 +1,18 @@ -use alloy_primitives::Address; -use clap::Parser; -use ethers_core::{ - rand::thread_rng, - types::{transaction::eip712::TypedData, Signature}, -}; -use ethers_signers::{ +use alloy_primitives::{Address, Signature, B256}; +use alloy_signer::{ coins_bip39::{English, Mnemonic}, - LocalWallet, MnemonicBuilder, Signer, + LocalWallet, MnemonicBuilder, Signer as AlloySigner, }; +use clap::Parser; +use ethers_core::types::transaction::eip712::TypedData; +use ethers_signers::Signer; use eyre::{Context, Result}; -use foundry_common::{ - fs, - types::{ToAlloy, ToEthers}, -}; +use foundry_common::{fs, types::ToAlloy}; use foundry_config::Config; use foundry_wallets::{RawWallet, Wallet}; +use rand::thread_rng; use serde_json::json; -use std::path::Path; +use std::{path::Path, str::FromStr}; use yansi::Paint; pub mod vanity; @@ -178,7 +174,7 @@ impl WalletSubcommands { if let Some(json) = json_values.as_mut() { json.push(json!({ - "address": wallet.address().to_alloy().to_checksum(None), + "address": wallet.address().to_checksum(None), "path": format!("{}", path.join(uuid).display()), } )); @@ -187,7 +183,7 @@ impl WalletSubcommands { "Created new encrypted keystore file: {}", path.join(uuid).display() ); - println!("Address: {}", wallet.address().to_alloy().to_checksum(None)); + println!("Address: {}", wallet.address().to_checksum(None)); } } @@ -196,19 +192,16 @@ impl WalletSubcommands { } } else { for _ in 0..number { - let wallet = LocalWallet::new(&mut rng); + let wallet = LocalWallet::random_with(&mut rng); if let Some(json) = json_values.as_mut() { json.push(json!({ - "address": wallet.address().to_alloy().to_checksum(None), + "address": wallet.address().to_checksum(None), "private_key": format!("0x{}", hex::encode(wallet.signer().to_bytes())), })) } else { println!("Successfully created new keypair."); - println!( - "Address: {}", - wallet.address().to_alloy().to_checksum(None) - ); + println!("Address: {}", wallet.address().to_checksum(None)); println!("Private key: 0x{}", hex::encode(wallet.signer().to_bytes())); } } @@ -225,7 +218,7 @@ impl WalletSubcommands { let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); let derivation_path = "m/44'/60'/0'/0/"; let wallets = (0..accounts) - .map(|i| builder.clone().derivation_path(&format!("{derivation_path}{i}"))) + .map(|i| builder.clone().derivation_path(format!("{derivation_path}{i}"))) .collect::, _>>()?; let wallets = wallets.into_iter().map(|b| b.build()).collect::, _>>()?; @@ -235,7 +228,7 @@ impl WalletSubcommands { println!("\nAccounts:"); for (i, wallet) in wallets.iter().enumerate() { println!("- Account {i}:"); - println!("Address: {}", wallet.address().to_alloy()); + println!("Address: {}", wallet.address()); println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); } } @@ -271,13 +264,12 @@ impl WalletSubcommands { println!("0x{sig}"); } WalletSubcommands::Verify { message, signature, address } => { - match signature.verify(Self::hex_str_to_bytes(&message)?, address.to_ethers()) { - Ok(_) => { - println!("Validation succeeded. Address {address} signed this message.") - } - Err(_) => { - println!("Validation failed. Address {address} did not sign this message.") - } + let recovered_address = + signature.recover_address_from_prehash(&B256::from_str(&message)?)?; + if recovered_address == address { + println!("Validation succeeded. Address {address} signed this message."); + } else { + println!("Validation failed. Address {address} did not sign this message."); } } WalletSubcommands::Import { account_name, keystore_dir, raw_wallet_options } => { @@ -371,10 +363,10 @@ flag to set your key via: let index = if let Some(i) = mnemonic_index { i } else { 0 }; let wallet = builder .clone() - .derivation_path(&format!("{derivation_path}{index}"))? + .derivation_path(format!("{derivation_path}{index}"))? .build()?; println!("- Account:"); - println!("Address: {}", wallet.address().to_alloy()); + println!("Address: {}", wallet.address()); println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); } }; diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 579265bee868c..a466bbe31cf23 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,9 +1,7 @@ use alloy_primitives::Address; +use alloy_signer::{k256::ecdsa::SigningKey, utils::secret_key_to_address, LocalWallet, Signer}; use clap::{builder::TypedValueParser, Parser}; -use ethers_core::{k256::ecdsa::SigningKey, rand, utils::secret_key_to_address}; -use ethers_signers::{LocalWallet, Signer}; use eyre::Result; -use foundry_common::types::ToAlloy; use rayon::iter::{self, ParallelIterator}; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -66,7 +64,7 @@ struct Wallets { impl WalletData { pub fn new(wallet: &LocalWallet) -> Self { WalletData { - address: wallet.address().to_alloy().to_checksum(None), + address: wallet.address().to_checksum(None), private_key: format!("0x{}", hex::encode(wallet.signer().to_bytes())), } } @@ -156,11 +154,11 @@ impl VanityArgs { timer.elapsed().as_secs(), if nonce.is_some() { "\nContract address: " } else { "" }, if nonce.is_some() { - wallet.address().to_alloy().create(nonce.unwrap()).to_checksum(None) + wallet.address().create(nonce.unwrap()).to_checksum(None) } else { String::new() }, - wallet.address().to_alloy().to_checksum(None), + wallet.address().to_checksum(None), hex::encode(wallet.signer().to_bytes()), ); @@ -229,7 +227,7 @@ pub fn wallet_generator() -> iter::Map, impl Fn(()) -> Generate pub fn generate_wallet() -> GeneratedWallet { let key = SigningKey::random(&mut rand::thread_rng()); let address = secret_key_to_address(&key); - (key, address.to_alloy()) + (key, address) } /// A trait to match vanity addresses. diff --git a/crates/cast/src/base.rs b/crates/cast/src/base.rs index 0ef91c6ddb071..44f58091e4193 100644 --- a/crates/cast/src/base.rs +++ b/crates/cast/src/base.rs @@ -1,7 +1,5 @@ -use alloy_primitives::{Sign, I256, U256}; -use ethers_core::utils::ParseUnits; +use alloy_primitives::{utils::ParseUnits, Sign, I256, U256}; use eyre::Result; -use foundry_common::types::ToAlloy; use std::{ convert::Infallible, fmt::{Binary, Debug, Display, Formatter, LowerHex, Octal, Result as FmtResult, UpperHex}, @@ -281,8 +279,8 @@ impl From for NumberWithBase { impl From for NumberWithBase { fn from(value: ParseUnits) -> Self { match value { - ParseUnits::U256(val) => val.to_alloy().into(), - ParseUnits::I256(val) => val.to_alloy().into(), + ParseUnits::U256(val) => val.into(), + ParseUnits::I256(val) => val.into(), } } } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 9eb81c4ce5678..0c941913cf14c 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -2,13 +2,16 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; use alloy_json_abi::ContractObject; use alloy_primitives::{ utils::{keccak256, ParseUnits, Unit}, - Address, I256, U256, + Address, Bytes, B256, I256, U256, }; use alloy_rlp::Decodable; use base::{Base, NumberWithBase, ToBase}; use chrono::NaiveDateTime; use ethers_core::{ - types::{transaction::eip2718::TypedTransaction, *}, + types::{ + transaction::eip2718::TypedTransaction, BlockId, BlockNumber, Filter, NameOrAddress, + Signature, H160, H256, U64, + }, utils::rlp, }; use ethers_providers::{Middleware, PendingTransaction, PubsubClient}; @@ -264,7 +267,7 @@ where None => raw_tx, }; let tx = Bytes::from(hex::decode(raw_tx)?); - let res = self.provider.send_raw_transaction(tx).await?; + let res = self.provider.send_raw_transaction(tx.0.into()).await?; Ok::<_, eyre::Error>(res) } @@ -1397,8 +1400,7 @@ impl SimpleCast { } let padded = format!("{s:0<64}"); - // need to use the Debug implementation - Ok(format!("{:?}", H256::from_str(&padded)?)) + Ok(padded.parse::()?.to_string()) } /// Encodes string into bytes32 value From fd87629fbc4ae2e0fa00ccf42b4a9ebe1b521d55 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 13 Feb 2024 18:21:49 +0300 Subject: [PATCH 0616/1963] bump (#7104) --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7722eae46ce72..ec2e562b8f2ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3089,9 +3089,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7accbeb76f0a3f75a7fed9c4c008b956311f1c4edbd0b301716647c12f763f6c" +checksum = "ba64504d49ebda9141869b2ba23db2d685ae4cf17bcddf5e61f0e4bc515ebb25" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3101,6 +3101,7 @@ dependencies = [ "fs_extra", "futures-util", "home", + "itertools 0.12.1", "md-5 0.10.6", "memmap2 0.9.4", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 6dd40aa25b570..97e815342e714 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,7 +128,7 @@ foundry-wallets = { path = "crates/wallets" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } -foundry-compilers = { version = "0.3.5", default-features = false } +foundry-compilers = { version = "0.3.6", default-features = false } ## revm # no default features to avoid c-kzg From 2c2f2fdf44ff3c22f6a18429955f7592568317de Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 14 Feb 2024 02:18:58 +0200 Subject: [PATCH 0617/1963] ci: disable debuginfo for tests (#7114) --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 669002cb01346..cb25172002e74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,7 @@ jobs: matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD + CARGO_PROFILE_DEV_DEBUG: 0 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable From ab70b565b1398c44991e0ef2261b971b020774de Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 14 Feb 2024 04:22:28 +0300 Subject: [PATCH 0618/1963] perf: improve linker performance (#7115) * perf improvements * comment --- crates/forge/bin/cmd/script/build.rs | 5 +- crates/forge/src/link.rs | 77 ++++++++++++++-------------- crates/forge/src/multi_runner.rs | 4 +- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 09cbf20d4438b..deafa961f7cf3 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -143,11 +143,12 @@ impl ScriptArgs { nonce: u64, target: ArtifactId, ) -> Result<(ArtifactContracts, Libraries, Vec)> { - let LinkOutput { libs_to_deploy, contracts, libraries } = + let LinkOutput { libs_to_deploy, libraries } = linker.link_with_nonce_or_address(libraries, sender, nonce, &target)?; // Collect all linked contracts with non-empty bytecode - let highlevel_known_contracts = contracts + let highlevel_known_contracts = linker + .get_linked_artifacts(&libraries)? .iter() .filter_map(|(id, contract)| { ContractBytecodeSome::try_from(ContractBytecode::from(contract.clone())) diff --git a/crates/forge/src/link.rs b/crates/forge/src/link.rs index 97ab5f88a4605..6b67bd03bda3c 100644 --- a/crates/forge/src/link.rs +++ b/crates/forge/src/link.rs @@ -1,5 +1,9 @@ use alloy_primitives::{Address, Bytes}; -use foundry_compilers::{artifacts::Libraries, contracts::ArtifactContracts, Artifact, ArtifactId}; +use foundry_compilers::{ + artifacts::{CompactContractBytecode, Libraries}, + contracts::ArtifactContracts, + Artifact, ArtifactId, +}; use semver::Version; use std::{ collections::BTreeSet, @@ -27,10 +31,6 @@ pub struct Linker { /// Output of the `link_with_nonce_or_address` pub struct LinkOutput { - /// [ArtifactContracts] object containing all artifacts linked with known libraries - /// It is guaranteed to contain `target` and all it's dependencies fully linked, and any other - /// contract may still be partially unlinked. - pub contracts: ArtifactContracts, /// Resolved library addresses. Contains both user-provided and newly deployed libraries. /// It will always contain library paths with stripped path prefixes. pub libraries: Libraries, @@ -149,45 +149,46 @@ impl Linker { }); } - // Link contracts - let contracts = self.link(&libraries)?; - - // Collect bytecodes for `libs_to_deploy`, as we have them linked now. + // Link and collect bytecodes for `libs_to_deploy`. let libs_to_deploy = libs_to_deploy .into_iter() - .map(|(id, _)| contracts.get(id).unwrap().get_bytecode_bytes().unwrap().into_owned()) - .collect(); + .map(|(id, _)| { + Ok(self.link(id, &libraries)?.get_bytecode_bytes().unwrap().into_owned()) + }) + .collect::, LinkerError>>()?; - Ok(LinkOutput { contracts, libraries, libs_to_deploy }) + Ok(LinkOutput { libraries, libs_to_deploy }) } - /// Links given artifacts with given library addresses. - /// - /// Artifacts returned by this function may still be partially unlinked if some of their - /// dependencies weren't present in `libraries`. - pub fn link(&self, libraries: &Libraries) -> Result { - self.contracts - .iter() - .map(|(id, contract)| { - let mut contract = contract.clone(); - - for (file, libs) in &libraries.libs { - for (name, address) in libs { - let address = - Address::from_str(address).map_err(LinkerError::InvalidAddress)?; - if let Some(bytecode) = contract.bytecode.as_mut() { - bytecode.link(file.to_string_lossy(), name, address); - } - if let Some(deployed_bytecode) = - contract.deployed_bytecode.as_mut().and_then(|b| b.bytecode.as_mut()) - { - deployed_bytecode.link(file.to_string_lossy(), name, address); - } - } + /// Links given artifact with given libraries. + pub fn link( + &self, + target: &ArtifactId, + libraries: &Libraries, + ) -> Result { + let mut contract = + self.contracts.get(target).ok_or(LinkerError::MissingTargetArtifact)?.clone(); + for (file, libs) in &libraries.libs { + for (name, address) in libs { + let address = Address::from_str(address).map_err(LinkerError::InvalidAddress)?; + if let Some(bytecode) = contract.bytecode.as_mut() { + bytecode.link(file.to_string_lossy(), name, address); } - Ok((id.clone(), contract)) - }) - .collect() + if let Some(deployed_bytecode) = + contract.deployed_bytecode.as_mut().and_then(|b| b.bytecode.as_mut()) + { + deployed_bytecode.link(file.to_string_lossy(), name, address); + } + } + } + Ok(contract) + } + + pub fn get_linked_artifacts( + &self, + libraries: &Libraries, + ) -> Result { + self.contracts.keys().map(|id| Ok((id.clone(), self.link(id, libraries)?))).collect() } } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 4f9f7bce9f220..eb68a3067cc45 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -288,10 +288,10 @@ impl MultiContractRunnerBuilder { for (id, contract) in contracts { let abi = contract.abi.as_ref().ok_or_eyre("we should have an abi by now")?; - let LinkOutput { contracts, libs_to_deploy, .. } = + let LinkOutput { libs_to_deploy, libraries } = linker.link_with_nonce_or_address(Default::default(), evm_opts.sender, 1, &id)?; - let linked_contract = contracts.get(&id).unwrap().clone(); + let linked_contract = linker.link(&id, &libraries)?; // get bytes if deployable, else add to known contracts and continue. // interfaces and abstract contracts should be known to enable fuzzing of their ABI From 82f2a26440565e1f0caf55498fefe90ad45d146d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 14 Feb 2024 03:39:25 +0200 Subject: [PATCH 0619/1963] perf: don't clone artifacts when building multi runner (#7116) --- crates/cast/bin/cmd/storage.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/link.rs | 2 +- crates/forge/src/multi_runner.rs | 18 ++++++++---------- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 5769360484ad7..557b68a1e2970 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -266,7 +266,7 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) storage_type.map_or("?", |t| &t.label), &slot.slot, &slot.offset.to_string(), - &storage_type.map_or("?", |t| &t.number_of_bytes), + storage_type.map_or("?", |t| &t.number_of_bytes), &converted_value.to_string(), &value.to_string(), &slot.contract, diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 37912e1c2d987..e85fc37b09721 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -184,7 +184,7 @@ pub fn print_storage_layout(storage_layout: Option<&StorageLayout>, pretty: bool storage_type.map_or("?", |t| &t.label), &slot.slot, &slot.offset.to_string(), - &storage_type.map_or("?", |t| &t.number_of_bytes), + storage_type.map_or("?", |t| &t.number_of_bytes), &slot.contract, ]); } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1a8cf9eed418f..10d188c4b6a22 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -742,7 +742,7 @@ mod tests { // #[test] - fn issue_5913() { + fn fuzz_seed_exists() { let args: TestArgs = TestArgs::parse_from(["foundry-cli", "-vvv", "--gas-report", "--fuzz-seed", "0x10"]); assert!(args.fuzz_seed.is_some()); diff --git a/crates/forge/src/link.rs b/crates/forge/src/link.rs index 6b67bd03bda3c..3779f69caf261 100644 --- a/crates/forge/src/link.rs +++ b/crates/forge/src/link.rs @@ -26,7 +26,7 @@ pub struct Linker { /// Root of the project, used to determine whether artifact/library path can be stripped. pub root: PathBuf, /// Compilation artifacts. - contracts: ArtifactContracts, + pub contracts: ArtifactContracts, } /// Output of the `link_with_nonce_or_address` diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index eb68a3067cc45..5cfd59d2752a5 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -10,7 +10,7 @@ use alloy_primitives::{Address, Bytes, U256}; use eyre::{OptionExt, Result}; use foundry_common::{ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{ - artifacts::CompactContractBytecode, Artifact, ArtifactId, ArtifactOutput, ProjectCompileOutput, + contracts::ArtifactContracts, Artifact, ArtifactId, ArtifactOutput, ProjectCompileOutput, }; use foundry_evm::{ backend::Backend, @@ -267,13 +267,12 @@ impl MultiContractRunnerBuilder { { let output = output.with_stripped_file_prefixes(&root); // This is just the contracts compiled, but we need to merge this with the read cached - // artifacts + // artifacts. let contracts = output .into_artifacts() .map(|(i, c)| (i, c.into_contract_bytecode())) - .collect::>(); + .collect::(); - let mut known_contracts = ContractsByArtifact::default(); let source_paths = contracts .iter() .map(|(i, _)| (i.identifier(), root.as_ref().join(&i.source).to_string_lossy().into())) @@ -281,17 +280,16 @@ impl MultiContractRunnerBuilder { // create a mapping of name => (abi, deployment code, Vec) let mut deployable_contracts = DeployableContracts::default(); - let artifact_contracts = contracts.iter().cloned().collect(); - - let linker = Linker::new(root.as_ref(), artifact_contracts); + let linker = Linker::new(root.as_ref(), contracts); - for (id, contract) in contracts { + let mut known_contracts = ContractsByArtifact::default(); + for (id, contract) in &linker.contracts.0 { let abi = contract.abi.as_ref().ok_or_eyre("we should have an abi by now")?; let LinkOutput { libs_to_deploy, libraries } = - linker.link_with_nonce_or_address(Default::default(), evm_opts.sender, 1, &id)?; + linker.link_with_nonce_or_address(Default::default(), evm_opts.sender, 1, id)?; - let linked_contract = linker.link(&id, &libraries)?; + let linked_contract = linker.link(id, &libraries)?; // get bytes if deployable, else add to known contracts and continue. // interfaces and abstract contracts should be known to enable fuzzing of their ABI From e3d0d15a3d417d5a780609cfd5c999b432f40edd Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 14 Feb 2024 04:26:16 +0200 Subject: [PATCH 0620/1963] chore: better ContractsByArtifact flatten (#7107) --- crates/common/src/contracts.rs | 58 +++++++++++++++----------------- crates/forge/src/multi_runner.rs | 4 +-- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index b47e928b11eb3..650280cc5375f 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -1,7 +1,7 @@ //! Commonly used contract types and functions. use alloy_json_abi::{Event, Function, JsonAbi}; -use alloy_primitives::{hex, Address, B256}; +use alloy_primitives::{hex, Address, Selector, B256}; use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecodeSome}, ArtifactId, ProjectPathsConfig, @@ -43,36 +43,34 @@ impl ContractsByArtifact { Ok(contracts.first().cloned()) } - /// Flattens a group of contracts into maps of all events and functions - pub fn flatten(&self) -> (BTreeMap<[u8; 4], Function>, BTreeMap, JsonAbi) { - let flattened_funcs: BTreeMap<[u8; 4], Function> = self - .iter() - .flat_map(|(_name, (abi, _code))| { - abi.functions() - .map(|func| (func.selector().into(), func.clone())) - .collect::>() - }) - .collect(); + /// Flattens the contracts into functions, events and errors. + pub fn flatten(&self) -> (BTreeMap, BTreeMap, JsonAbi) { + let mut funcs = BTreeMap::new(); + let mut events = BTreeMap::new(); + let mut errors_abi = JsonAbi::new(); + for (_name, (abi, _code)) in self.iter() { + for func in abi.functions() { + funcs.insert(func.selector(), func.clone()); + } + for event in abi.events() { + events.insert(event.selector(), event.clone()); + } + for error in abi.errors() { + errors_abi.errors.entry(error.name.clone()).or_default().push(error.clone()); + } + } + (funcs, events, errors_abi) + } - let flattened_events: BTreeMap = self - .iter() - .flat_map(|(_name, (abi, _code))| { - abi.events() - .map(|event| (event.selector(), event.clone())) - .collect::>() - }) - .collect(); - - // We need this for better revert decoding, and want it in abi form - let mut errors_abi = JsonAbi::default(); - self.iter().for_each(|(_name, (abi, _code))| { - abi.errors().for_each(|error| { - let entry = - errors_abi.errors.entry(error.name.clone()).or_insert_with(Default::default); - entry.push(error.clone()); - }); - }); - (flattened_funcs, flattened_events, errors_abi) + /// Flattens the errors into a single JsonAbi. + pub fn flatten_errors(&self) -> JsonAbi { + let mut errors_abi = JsonAbi::new(); + for (_name, (abi, _code)) in self.iter() { + for error in abi.errors() { + errors_abi.errors.entry(error.name.clone()).or_default().push(error.clone()); + } + } + errors_abi } } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 5cfd59d2752a5..0c876a640f29d 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -316,7 +316,7 @@ impl MultiContractRunnerBuilder { ); } - let execution_info = known_contracts.flatten(); + let errors = known_contracts.flatten_errors(); Ok(MultiContractRunner { contracts: deployable_contracts, known_contracts, @@ -324,7 +324,7 @@ impl MultiContractRunnerBuilder { env, evm_spec: self.evm_spec.unwrap_or(SpecId::MERGE), sender: self.sender, - errors: Some(execution_info.2), + errors: Some(errors), source_paths, fork: self.fork, cheats_config: self.cheats_config.unwrap_or_default().into(), From 79ed5a90058691549546194c6884440bfa3039ae Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 14 Feb 2024 04:27:02 +0200 Subject: [PATCH 0621/1963] refactor: local trace decoder and identifier (#7108) * refactor: local trace decoder and identifier * chore: explain size check * chore: clippy * fix: remove cache --- crates/cli/src/utils/cmd.rs | 13 +-- crates/common/src/contracts.rs | 51 ++++++--- crates/evm/traces/src/decoder/mod.rs | 125 +++++++++++----------- crates/evm/traces/src/identifier/local.rs | 50 ++++----- 4 files changed, 128 insertions(+), 111 deletions(-) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 11d996af405d7..00a76002c831f 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -377,9 +377,7 @@ pub async fn handle_traces( labels: Vec, debug: bool, ) -> Result<()> { - let mut etherscan_identifier = EtherscanIdentifier::new(config, chain)?; - - let labeled_addresses = labels.iter().filter_map(|label_str| { + let labels = labels.iter().filter_map(|label_str| { let mut iter = label_str.split(':'); if let Some(addr) = iter.next() { @@ -389,19 +387,16 @@ pub async fn handle_traces( } None }); - - let labeled_addresses_in_config = config.labels.clone().into_iter(); - - let concatenated_addresses = labeled_addresses.chain(labeled_addresses_in_config); - + let config_labels = config.labels.clone().into_iter(); let mut decoder = CallTraceDecoderBuilder::new() - .with_labels(concatenated_addresses) + .with_labels(labels.chain(config_labels)) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), config.offline, )?) .build(); + let mut etherscan_identifier = EtherscanIdentifier::new(config, chain)?; for (_, trace) in &mut result.traces { decoder.identify(trace, &mut etherscan_identifier); } diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 650280cc5375f..65d8a8b8b52e9 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -23,8 +23,9 @@ pub struct ContractsByArtifact(pub BTreeMap)>); impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. pub fn find_by_code(&self, code: &[u8]) -> Option { - self.iter().find(|(_, (_, known_code))| diff_score(known_code, code) < 0.1) + self.iter().find(|(_, (_, known_code))| bytecode_diff_score(known_code, code) <= 0.1) } + /// Finds a contract which has the same contract name or identifier as `id`. If more than one is /// found, return error. pub fn find_by_name_or_identifier( @@ -93,25 +94,27 @@ pub type ContractsByAddress = BTreeMap; /// Very simple fuzzy matching of contract bytecode. /// -/// Will fail for small contracts that are essentially all immutable variables. -pub fn diff_score(a: &[u8], b: &[u8]) -> f64 { - let max_len = usize::max(a.len(), b.len()); - let min_len = usize::min(a.len(), b.len()); +/// Returns a value between `0.0` (identical) and `1.0` (completely different). +pub fn bytecode_diff_score<'a>(mut a: &'a [u8], mut b: &'a [u8]) -> f64 { + if a.len() < b.len() { + std::mem::swap(&mut a, &mut b); + } + + // Account for different lengths. + let mut n_different_bytes = a.len() - b.len(); - if max_len == 0 { + // If the difference is more than 32 bytes and more than 10% of the total length, + // we assume the bytecodes are completely different. + // This is a simple heuristic to avoid checking every byte when the lengths are very different. + // 32 is chosen to be a reasonable minimum as it's the size of metadata hashes and one EVM word. + if n_different_bytes > 32 && n_different_bytes * 10 > a.len() { return 1.0; } - let a = &a[..min_len]; - let b = &b[..min_len]; - let mut diff_chars = 0; - for i in 0..min_len { - if a[i] != b[i] { - diff_chars += 1; - } - } - diff_chars += max_len - min_len; - diff_chars as f64 / max_len as f64 + // Count different bytes. + n_different_bytes += std::iter::zip(a, b).filter(|(a, b)| a != b).count(); + + n_different_bytes as f64 / a.len() as f64 } /// Flattens the contracts into (`id` -> (`JsonAbi`, `Vec`)) pairs @@ -270,4 +273,20 @@ mod tests { ]); let _decoded = params.abi_decode_params(args).unwrap(); } + + #[test] + fn bytecode_diffing() { + assert_eq!(bytecode_diff_score(b"a", b"a"), 0.0); + assert_eq!(bytecode_diff_score(b"a", b"b"), 1.0); + + let a_100 = &b"a".repeat(100)[..]; + assert_eq!(bytecode_diff_score(a_100, &b"b".repeat(100)), 1.0); + assert_eq!(bytecode_diff_score(a_100, &b"b".repeat(99)), 1.0); + assert_eq!(bytecode_diff_score(a_100, &b"b".repeat(101)), 1.0); + assert_eq!(bytecode_diff_score(a_100, &b"b".repeat(120)), 1.0); + assert_eq!(bytecode_diff_score(a_100, &b"b".repeat(1000)), 1.0); + + let a_99 = &b"a".repeat(99)[..]; + assert!(bytecode_diff_score(a_100, a_99) <= 0.01); + } } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index f07e0bc519420..0fac862b29eb5 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -5,7 +5,7 @@ use crate::{ CallTrace, CallTraceArena, CallTraceNode, DecodedCallData, DecodedCallLog, DecodedCallTrace, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Event, Function, JsonAbi}; +use alloy_json_abi::{Error, Event, Function, JsonAbi}; use alloy_primitives::{Address, LogData, Selector, B256}; use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; use foundry_evm_core::{ @@ -43,34 +43,24 @@ impl CallTraceDecoderBuilder { self } - /// Add known functions to the decoder. + /// Add known errors to the decoder. #[inline] - pub fn with_functions(mut self, functions: impl IntoIterator) -> Self { - for function in functions { - self.decoder.functions.entry(function.selector()).or_default().push(function); - } + pub fn with_abi(mut self, abi: &JsonAbi) -> Self { + self.decoder.collect_abi(abi, None); self } - /// Add known events to the decoder. + /// Add known contracts to the decoder from a `LocalTraceIdentifier`. #[inline] - pub fn with_events(mut self, events: impl IntoIterator) -> Self { - for event in events { - self.decoder - .events - .entry((event.selector(), indexed_inputs(&event))) - .or_default() - .push(event); + pub fn with_local_identifier_abis(mut self, identifier: &LocalTraceIdentifier<'_>) -> Self { + let contracts = identifier.contracts(); + trace!(target: "evm::traces", len=contracts.len(), "collecting local identifier ABIs"); + for (abi, _) in contracts.values() { + self.decoder.collect_abi(abi, None); } self } - #[inline] - pub fn with_local_identifier_abis(self, identifier: &LocalTraceIdentifier<'_>) -> Self { - self.with_events(identifier.events().cloned()) - .with_functions(identifier.functions().cloned()) - } - /// Sets the verbosity level of the decoder. #[inline] pub fn with_verbosity(mut self, level: u8) -> Self { @@ -189,12 +179,37 @@ impl CallTraceDecoder { /// Identify unknown addresses in the specified call trace using the specified identifier. /// /// Unknown contracts are contracts that either lack a label or an ABI. - #[inline] pub fn identify(&mut self, trace: &CallTraceArena, identifier: &mut impl TraceIdentifier) { self.collect_identities(identifier.identify_addresses(self.addresses(trace))); } - #[inline(always)] + /// Adds a single event to the decoder. + pub fn push_event(&mut self, event: Event) { + self.events.entry((event.selector(), indexed_inputs(&event))).or_default().push(event); + } + + /// Adds a single function to the decoder. + pub fn push_function(&mut self, function: Function) { + match self.functions.entry(function.selector()) { + Entry::Occupied(entry) => { + // This shouldn't happen that often + if entry.get().contains(&function) { + return; + } + debug!(target: "evm::traces", selector=%entry.key(), new=%function.signature(), "duplicate selector"); + entry.into_mut().push(function); + } + Entry::Vacant(entry) => { + entry.insert(vec![function]); + } + } + } + + /// Adds a single error to the decoder. + pub fn push_error(&mut self, error: Error) { + self.errors.errors.entry(error.name.clone()).or_default().push(error); + } + fn addresses<'a>( &'a self, arena: &'a CallTraceArena, @@ -205,11 +220,7 @@ impl CallTraceDecoder { .map(|node| { ( &node.trace.address, - if node.trace.kind.is_any_create() { - Some(node.trace.output.as_ref()) - } else { - None - }, + node.trace.kind.is_any_create().then_some(&node.trace.output[..]), ) }) .filter(|(address, _)| { @@ -218,46 +229,38 @@ impl CallTraceDecoder { } fn collect_identities(&mut self, identities: Vec>) { - for identity in identities { - let address = identity.address; + trace!(target: "evm::traces", len=identities.len(), "collecting address identities"); + for AddressIdentity { address, label, contract, abi, artifact_id: _ } in identities { + let _span = trace_span!(target: "evm::traces", "identity", ?contract, ?label).entered(); - if let Some(contract) = &identity.contract { - self.contracts.entry(address).or_insert_with(|| contract.to_string()); + if let Some(contract) = contract { + self.contracts.entry(address).or_insert(contract); } - if let Some(label) = &identity.label { - self.labels.entry(address).or_insert_with(|| label.to_string()); + if let Some(label) = label { + self.labels.entry(address).or_insert(label); } - if let Some(abi) = &identity.abi { - // Store known functions for the address - for function in abi.functions() { - match self.functions.entry(function.selector()) { - Entry::Occupied(entry) => { - // This shouldn't happen that often - debug!(target: "evm::traces", selector=%entry.key(), old=?entry.get(), new=?function, "Duplicate function"); - entry.into_mut().push(function.clone()); - } - Entry::Vacant(entry) => { - entry.insert(vec![function.clone()]); - } - } - } - - // Flatten events from all ABIs - for event in abi.events() { - let sig = (event.selector(), indexed_inputs(event)); - self.events.entry(sig).or_default().push(event.clone()); - } - - // Flatten errors from all ABIs - for error in abi.errors() { - self.errors.errors.entry(error.name.clone()).or_default().push(error.clone()); - } + if let Some(abi) = abi { + self.collect_abi(&abi, Some(&address)); + } + } + } - if abi.receive.is_some() { - self.receive_contracts.push(address); - } + fn collect_abi(&mut self, abi: &JsonAbi, address: Option<&Address>) { + trace!(target: "evm::traces", len=abi.len(), ?address, "collecting ABI"); + for function in abi.functions() { + self.push_function(function.clone()); + } + for event in abi.events() { + self.push_event(event.clone()); + } + for error in abi.errors() { + self.push_error(error.clone()); + } + if let Some(address) = address { + if abi.receive.is_some() { + self.receive_contracts.push(*address); } } } diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index 174a698bad7b8..d37552a78426c 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -1,7 +1,8 @@ use super::{AddressIdentity, TraceIdentifier}; -use alloy_json_abi::{Event, Function}; +use alloy_json_abi::JsonAbi; use alloy_primitives::Address; -use foundry_common::contracts::{diff_score, ContractsByArtifact}; +use foundry_common::contracts::{bytecode_diff_score, ContractsByArtifact}; +use foundry_compilers::ArtifactId; use ordered_float::OrderedFloat; use std::borrow::Cow; @@ -11,18 +12,33 @@ pub struct LocalTraceIdentifier<'a> { } impl<'a> LocalTraceIdentifier<'a> { + /// Creates a new local trace identifier. + #[inline] pub fn new(known_contracts: &'a ContractsByArtifact) -> Self { Self { known_contracts } } - /// Get all the functions of the local contracts. - pub fn functions(&self) -> impl Iterator { - self.known_contracts.iter().flat_map(|(_, (abi, _))| abi.functions()) + /// Returns the known contracts. + #[inline] + pub fn contracts(&self) -> &'a ContractsByArtifact { + self.known_contracts } - /// Get all the events of the local contracts. - pub fn events(&self) -> impl Iterator { - self.known_contracts.iter().flat_map(|(_, (abi, _))| abi.events()) + fn find_contract_from_bytecode( + &mut self, + code: &[u8], + ) -> Option<(&'a ArtifactId, &'a JsonAbi)> { + self.known_contracts + .iter() + .filter_map(|(id, (abi, known_code))| { + // Note: the diff score can be inaccurate for small contracts so we're using + // a relatively high threshold here to avoid filtering out too many + // contracts. + let score = bytecode_diff_score(known_code, code); + (score < 0.85).then_some((score, id, abi)) + }) + .min_by_key(|(score, _, _)| OrderedFloat(*score)) + .map(|(_, id, abi)| (id, abi)) } } @@ -33,23 +49,7 @@ impl TraceIdentifier for LocalTraceIdentifier<'_> { { addresses .filter_map(|(address, code)| { - let code = code?; - let (_, id, abi) = self - .known_contracts - .iter() - .filter_map(|(id, (abi, known_code))| { - let score = diff_score(known_code, code); - // Note: the diff score can be inaccurate for small contracts so we're using - // a relatively high threshold here to avoid filtering out too many - // contracts. - if score < 0.85 { - Some((OrderedFloat(score), id, abi)) - } else { - None - } - }) - .min_by_key(|(score, _, _)| *score)?; - + let (id, abi) = self.find_contract_from_bytecode(code?)?; Some(AddressIdentity { address: *address, contract: Some(id.identifier()), From e10b03933a581e60c35ceb4bd520017aa34fbd12 Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Wed, 14 Feb 2024 10:14:32 -0800 Subject: [PATCH 0622/1963] feat(forge): add calldata and returndata views to debugger (#7110) * add calldata and returndata views to debugger * appease clippy * remove todo * add active_buffer() helper and use active buffer len for repeat buffer scroll down calculations * consolidate BufferKind enum * remove commented code * refactor get_buffer_access(es) * return None for ops that don't read/write --- crates/debugger/src/tui/context.rs | 66 +++++++-- crates/debugger/src/tui/draw.rs | 158 ++++++++++++++-------- crates/evm/core/src/debug.rs | 6 + crates/evm/evm/src/inspectors/debugger.rs | 2 + 4 files changed, 161 insertions(+), 71 deletions(-) diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index 6bcd35d1c9017..6f8c30939769e 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -13,10 +13,38 @@ pub(crate) struct DrawMemory { // TODO pub(crate) current_startline: RefCell, pub(crate) inner_call_index: usize, - pub(crate) current_mem_startline: usize, + pub(crate) current_buf_startline: usize, pub(crate) current_stack_startline: usize, } +/// Used to keep track of which buffer is currently active to be drawn by the debugger. +#[derive(Debug, PartialEq)] +pub(crate) enum BufferKind { + Memory, + Calldata, + Returndata, +} + +impl BufferKind { + /// Helper to cycle through the active buffers. + pub(crate) fn next(&self) -> Self { + match self { + BufferKind::Memory => BufferKind::Calldata, + BufferKind::Calldata => BufferKind::Returndata, + BufferKind::Returndata => BufferKind::Memory, + } + } + + /// Helper to format the title of the active buffer pane + pub(crate) fn title(&self, size: usize) -> String { + match self { + BufferKind::Memory => format!("Memory (max expansion: {} bytes)", size), + BufferKind::Calldata => format!("Calldata (size: {} bytes)", size), + BufferKind::Returndata => format!("Returndata (size: {} bytes)", size), + } + } +} + pub(crate) struct DebuggerContext<'a> { pub(crate) debugger: &'a mut Debugger, @@ -29,8 +57,11 @@ pub(crate) struct DebuggerContext<'a> { pub(crate) last_index: usize, pub(crate) stack_labels: bool, - pub(crate) mem_utf: bool, + /// Whether to decode active buffer as utf8 or not. + pub(crate) buf_utf: bool, pub(crate) show_shortcuts: bool, + /// The currently active buffer (memory, calldata, returndata) to be drawn. + pub(crate) active_buffer: BufferKind, } impl<'a> DebuggerContext<'a> { @@ -45,8 +76,9 @@ impl<'a> DebuggerContext<'a> { last_index: 0, stack_labels: false, - mem_utf: false, + buf_utf: false, show_shortcuts: true, + active_buffer: BufferKind::Memory, } } @@ -89,6 +121,14 @@ impl<'a> DebuggerContext<'a> { fn opcode_list(&self) -> Vec { self.debug_steps().iter().map(DebugStep::pretty_opcode).collect() } + + fn active_buffer(&self) -> &[u8] { + match self.active_buffer { + BufferKind::Memory => &self.current_step().memory, + BufferKind::Calldata => &self.current_step().calldata, + BufferKind::Returndata => &self.current_step().returndata, + } + } } impl DebuggerContext<'_> { @@ -121,9 +161,9 @@ impl DebuggerContext<'_> { // Grab number of times to do it for _ in 0..buffer_as_number(&self.key_buffer, 1) { if event.modifiers.contains(KeyModifiers::CONTROL) { - let max_mem = (self.current_step().memory.len() / 32).saturating_sub(1); - if self.draw_memory.current_mem_startline < max_mem { - self.draw_memory.current_mem_startline += 1; + let max_buf = (self.active_buffer().len() / 32).saturating_sub(1); + if self.draw_memory.current_buf_startline < max_buf { + self.draw_memory.current_buf_startline += 1; } } else if self.current_step < self.opcode_list.len() - 1 { self.current_step += 1; @@ -147,8 +187,8 @@ impl DebuggerContext<'_> { KeyCode::Char('k') | KeyCode::Up => { for _ in 0..buffer_as_number(&self.key_buffer, 1) { if event.modifiers.contains(KeyModifiers::CONTROL) { - self.draw_memory.current_mem_startline = - self.draw_memory.current_mem_startline.saturating_sub(1); + self.draw_memory.current_buf_startline = + self.draw_memory.current_buf_startline.saturating_sub(1); } else if self.current_step > 0 { self.current_step -= 1; } else if self.draw_memory.inner_call_index > 0 { @@ -165,6 +205,10 @@ impl DebuggerContext<'_> { } self.key_buffer.clear(); } + KeyCode::Char('b') => { + self.active_buffer = self.active_buffer.next(); + self.draw_memory.current_buf_startline = 0; + } // Go to top of file KeyCode::Char('g') => { self.draw_memory.inner_call_index = 0; @@ -248,7 +292,7 @@ impl DebuggerContext<'_> { // toggle stack labels KeyCode::Char('t') => self.stack_labels = !self.stack_labels, // toggle memory utf8 decoding - KeyCode::Char('m') => self.mem_utf = !self.mem_utf, + KeyCode::Char('m') => self.buf_utf = !self.buf_utf, // toggle help notice KeyCode::Char('h') => self.show_shortcuts = !self.show_shortcuts, KeyCode::Char( @@ -284,7 +328,7 @@ impl DebuggerContext<'_> { self.current_step -= 1; } else if self.draw_memory.inner_call_index > 0 { self.draw_memory.inner_call_index -= 1; - self.draw_memory.current_mem_startline = 0; + self.draw_memory.current_buf_startline = 0; self.draw_memory.current_stack_startline = 0; self.current_step = self.debug_steps().len() - 1; } @@ -294,7 +338,7 @@ impl DebuggerContext<'_> { self.current_step += 1; } else if self.draw_memory.inner_call_index < self.debug_arena().len() - 1 { self.draw_memory.inner_call_index += 1; - self.draw_memory.current_mem_startline = 0; + self.draw_memory.current_buf_startline = 0; self.draw_memory.current_stack_startline = 0; self.current_step = 0; } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 7a834392986d9..fbee1c6a00316 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -1,6 +1,6 @@ //! TUI draw implementation. -use super::context::DebuggerContext; +use super::context::{BufferKind, DebuggerContext}; use crate::op::OpcodeParam; use alloy_primitives::U256; use foundry_compilers::sourcemap::SourceElement; @@ -77,7 +77,7 @@ impl DebuggerContext<'_> { /// |-----------------------------| /// | stack | /// |-----------------------------| - /// | mem | + /// | buf | /// |-----------------------------| /// | | /// | src | @@ -120,7 +120,7 @@ impl DebuggerContext<'_> { self.draw_src(f, src_pane); self.draw_op_list(f, op_pane); self.draw_stack(f, stack_pane); - self.draw_memory(f, memory_pane); + self.draw_buffer(f, memory_pane); } /// Draws the layout in horizontal mode. @@ -130,7 +130,7 @@ impl DebuggerContext<'_> { /// | op | stack | /// |-----------------|-----------| /// | | | - /// | src | mem | + /// | src | buf | /// | | | /// |-----------------|-----------| /// ``` @@ -180,12 +180,12 @@ impl DebuggerContext<'_> { self.draw_src(f, src_pane); self.draw_op_list(f, op_pane); self.draw_stack(f, stack_pane); - self.draw_memory(f, memory_pane); + self.draw_buffer(f, memory_pane); } fn draw_footer(&self, f: &mut Frame<'_>, area: Rect) { - let l1 = "[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end"; - let l2 = "[t]: stack labels | [m]: memory decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll memory | [']: goto breakpoint | [h] toggle help"; + let l1 = "[q]: quit | [k/j]: prev/next op | [a/s]: prev/next jump | [c/C]: prev/next call | [g/G]: start/end | [b]: cycle memory/calldata/returndata buffers"; + let l2 = "[t]: stack labels | [m]: buffer decoding | [shift + j/k]: scroll stack | [ctrl + j/k]: scroll buffer | [']: goto breakpoint | [h] toggle help"; let dimmed = Style::new().add_modifier(Modifier::DIM); let lines = vec![Line::from(Span::styled(l1, dimmed)), Line::from(Span::styled(l2, dimmed))]; @@ -500,11 +500,15 @@ impl DebuggerContext<'_> { f.render_widget(paragraph, area); } - fn draw_memory(&self, f: &mut Frame<'_>, area: Rect) { + fn draw_buffer(&self, f: &mut Frame<'_>, area: Rect) { let step = self.current_step(); - let memory = &step.memory; + let buf = match self.active_buffer { + BufferKind::Memory => &step.memory, + BufferKind::Calldata => &step.calldata, + BufferKind::Returndata => &step.returndata, + }; - let min_len = hex_digits(memory.len()); + let min_len = hex_digits(buf.len()); // Color memory region based on read/write. let mut offset = None; @@ -513,16 +517,22 @@ impl DebuggerContext<'_> { if let Instruction::OpCode(op) = step.instruction { let stack_len = step.stack.len(); if stack_len > 0 { - let (read_offset, read_size, write_offset, write_size) = - get_memory_access(op, &step.stack); - if read_offset.is_some() { - offset = read_offset; - size = read_size; - color = Some(Color::Cyan); - } else if write_offset.is_some() { - offset = write_offset; - size = write_size; - color = Some(Color::Red); + if let Some(accesses) = get_buffer_accesses(op, &step.stack) { + if let Some(read_access) = accesses.read { + if read_access.0 == self.active_buffer { + offset = Some(read_access.1.offset); + size = Some(read_access.1.size); + color = Some(Color::Cyan); + } + } else if let Some(write_access) = accesses.write { + // TODO: with MCOPY, it will be possible to both read from and write to the + // memory buffer with the same opcode + if self.active_buffer == BufferKind::Memory { + offset = Some(write_access.offset); + size = Some(write_access.size); + color = Some(Color::Red); + } + } } } } @@ -532,34 +542,37 @@ impl DebuggerContext<'_> { let prev_step = self.current_step - 1; let prev_step = &self.debug_steps()[prev_step]; if let Instruction::OpCode(op) = prev_step.instruction { - let (_, _, write_offset, write_size) = get_memory_access(op, &prev_step.stack); - if write_offset.is_some() { - offset = write_offset; - size = write_size; - color = Some(Color::Green); + if let Some(write_access) = + get_buffer_accesses(op, &prev_step.stack).and_then(|a| a.write) + { + if self.active_buffer == BufferKind::Memory { + offset = Some(write_access.offset); + size = Some(write_access.size); + color = Some(Color::Green); + } } } } let height = area.height as usize; - let end_line = self.draw_memory.current_mem_startline + height; + let end_line = self.draw_memory.current_buf_startline + height; - let text: Vec = memory + let text: Vec = buf .chunks(32) .enumerate() - .skip(self.draw_memory.current_mem_startline) + .skip(self.draw_memory.current_buf_startline) .take_while(|(i, _)| *i < end_line) - .map(|(i, mem_word)| { + .map(|(i, buf_word)| { let mut spans = Vec::with_capacity(1 + 32 * 2 + 1 + 32 / 4 + 1); - // Memory index. + // Buffer index. spans.push(Span::styled( format!("{:0min_len$x}| ", i * 32), Style::new().fg(Color::White), )); // Word hex bytes. - hex_bytes_spans(mem_word, &mut spans, |j, _| { + hex_bytes_spans(buf_word, &mut spans, |j, _| { let mut byte_color = Color::White; if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { let idx = i * 32 + j; @@ -573,9 +586,9 @@ impl DebuggerContext<'_> { Style::new().fg(byte_color) }); - if self.mem_utf { + if self.buf_utf { spans.push(Span::raw("|")); - for utf in mem_word.chunks(4) { + for utf in buf_word.chunks(4) { if let Ok(utf_str) = std::str::from_utf8(utf) { spans.push(Span::raw(utf_str.replace('\0', "."))); } else { @@ -590,7 +603,7 @@ impl DebuggerContext<'_> { }) .collect(); - let title = format!("Memory (max expansion: {} bytes)", memory.len()); + let title = self.active_buffer.title(buf.len()); let block = Block::default().title(title).borders(Borders::ALL); let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true }); f.render_widget(paragraph, area); @@ -628,30 +641,48 @@ impl<'a> SourceLines<'a> { } } -/// The memory_access variable stores the index on the stack that indicates the memory +/// Container for buffer access information. +struct BufferAccess { + offset: usize, + size: usize, +} + +/// Container for read and write buffer access information. +struct BufferAccesses { + /// The read buffer kind and access information. + read: Option<(BufferKind, BufferAccess)>, + /// The only mutable buffer is the memory buffer, so don't store the buffer kind. + write: Option, +} + +/// The memory_access variable stores the index on the stack that indicates the buffer /// offset/size accessed by the given opcode: -/// (read memory offset, read memory size, write memory offset, write memory size) +/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) /// >= 1: the stack index /// 0: no memory access /// -1: a fixed size of 32 bytes /// -2: a fixed size of 1 byte -/// The return value is a tuple about accessed memory region by the given opcode: -/// (read memory offset, read memory size, write memory offset, write memory size) -fn get_memory_access( - op: u8, - stack: &[U256], -) -> (Option, Option, Option, Option) { - let memory_access = match op { - opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => (1, 2, 0, 0), - opcode::CALLDATACOPY | opcode::CODECOPY | opcode::RETURNDATACOPY => (0, 0, 1, 3), - opcode::EXTCODECOPY => (0, 0, 2, 4), - opcode::MLOAD => (1, -1, 0, 0), - opcode::MSTORE => (0, 0, 1, -1), - opcode::MSTORE8 => (0, 0, 1, -2), - opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => (1, 2, 0, 0), - opcode::CREATE | opcode::CREATE2 => (2, 3, 0, 0), - opcode::CALL | opcode::CALLCODE => (4, 5, 0, 0), - opcode::DELEGATECALL | opcode::STATICCALL => (3, 4, 0, 0), +/// The return value is a tuple about accessed buffer region by the given opcode: +/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) +fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { + let buffer_access = match op { + opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => { + (Some((BufferKind::Memory, 1, 2)), None) + } + opcode::CALLDATACOPY => (Some((BufferKind::Calldata, 2, 3)), Some((1, 3))), + opcode::RETURNDATACOPY => (Some((BufferKind::Returndata, 2, 3)), Some((1, 3))), + opcode::CALLDATALOAD => (Some((BufferKind::Calldata, 1, -1)), None), + opcode::CODECOPY => (None, Some((1, 3))), + opcode::EXTCODECOPY => (None, Some((2, 4))), + opcode::MLOAD => (Some((BufferKind::Memory, 1, -1)), None), + opcode::MSTORE => (None, Some((1, -1))), + opcode::MSTORE8 => (None, Some((1, -2))), + opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => { + (Some((BufferKind::Memory, 1, 2)), None) + } + opcode::CREATE | opcode::CREATE2 => (Some((BufferKind::Memory, 2, 3)), None), + opcode::CALL | opcode::CALLCODE => (Some((BufferKind::Memory, 4, 5)), None), + opcode::DELEGATECALL | opcode::STATICCALL => (Some((BufferKind::Memory, 3, 4)), None), _ => Default::default(), }; @@ -670,13 +701,20 @@ fn get_memory_access( _ => panic!("invalid stack index"), }; - let (read_offset, read_size, write_offset, write_size) = ( - get_size(memory_access.0), - get_size(memory_access.1), - get_size(memory_access.2), - get_size(memory_access.3), - ); - (read_offset, read_size, write_offset, write_size) + if buffer_access.0.is_some() || buffer_access.1.is_some() { + let (read, write) = buffer_access; + let read_access = read.and_then(|b| { + let (buffer, offset, size) = b; + Some((buffer, BufferAccess { offset: get_size(offset)?, size: get_size(size)? })) + }); + let write_access = write.and_then(|b| { + let (offset, size) = b; + Some(BufferAccess { offset: get_size(offset)?, size: get_size(size)? }) + }); + Some(BufferAccesses { read: read_access, write: write_access }) + } else { + None + } } fn hex_bytes_spans(bytes: &[u8], spans: &mut Vec>, f: impl Fn(usize, u8) -> Style) { diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 9981955fda909..d6f459339c177 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -169,6 +169,10 @@ pub struct DebugStep { pub stack: Vec, /// Memory *prior* to running the associated opcode pub memory: Vec, + /// Calldata *prior* to running the associated opcode + pub calldata: Vec, + /// Returndata *prior* to running the associated opcode + pub returndata: Vec, /// Opcode to be executed pub instruction: Instruction, /// Optional bytes that are being pushed onto the stack @@ -187,6 +191,8 @@ impl Default for DebugStep { Self { stack: vec![], memory: Default::default(), + calldata: Default::default(), + returndata: Default::default(), instruction: Instruction::OpCode(revm::interpreter::opcode::INVALID), push_bytes: None, pc: 0, diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index a43bb2a42b962..bb327b36e5bee 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -75,6 +75,8 @@ impl Inspector for Debugger { pc, stack: interpreter.stack().data().clone(), memory: interpreter.shared_memory.context_memory().to_vec(), + calldata: interpreter.contract().input.to_vec(), + returndata: interpreter.return_data_buffer.to_vec(), instruction: Instruction::OpCode(op), push_bytes, total_gas_used, From e9dad710d60e3ce84bf81cb3c20d0a2c34041a5f Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Wed, 14 Feb 2024 10:49:26 -0800 Subject: [PATCH 0623/1963] fix read/write fallthrough check (#7126) --- crates/debugger/src/tui/draw.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index fbee1c6a00316..585375b245f68 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -518,12 +518,11 @@ impl DebuggerContext<'_> { let stack_len = step.stack.len(); if stack_len > 0 { if let Some(accesses) = get_buffer_accesses(op, &step.stack) { - if let Some(read_access) = accesses.read { - if read_access.0 == self.active_buffer { - offset = Some(read_access.1.offset); - size = Some(read_access.1.size); - color = Some(Color::Cyan); - } + if accesses.read.as_ref().is_some_and(|a| a.0 == self.active_buffer) { + let read_access = accesses.read.unwrap(); + offset = Some(read_access.1.offset); + size = Some(read_access.1.size); + color = Some(Color::Cyan); } else if let Some(write_access) = accesses.write { // TODO: with MCOPY, it will be possible to both read from and write to the // memory buffer with the same opcode From 92e50bf34e4bf222dd17a3bd61a4d6806e8ad97f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 15 Feb 2024 00:01:13 +0400 Subject: [PATCH 0624/1963] fix (#7124) --- crates/forge/bin/cmd/script/build.rs | 13 +++++++-- crates/forge/tests/cli/script.rs | 43 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index deafa961f7cf3..fd66377cdfac5 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -104,7 +104,7 @@ impl ScriptArgs { true }; - let mut target = None; + let mut target: Option<&ArtifactId> = None; for (id, contract) in contracts.iter() { if no_target_name { @@ -112,8 +112,15 @@ impl ScriptArgs { if id.source == std::path::Path::new(&target_fname) && contract.bytecode.as_ref().map_or(false, |b| b.object.bytes_len() > 0) { - if target.is_some() { - eyre::bail!("Multiple contracts in the target path. Please specify the contract name with `--tc ContractName`") + if let Some(target) = target { + // We might have multiple artifacts for the same contract but with different + // solc versions. Their names will have form of {name}.0.X.Y, so we are + // stripping versions off before comparing them. + let target_name = target.name.split('.').next().unwrap(); + let id_name = id.name.split('.').next().unwrap(); + if target_name != id_name { + eyre::bail!("Multiple contracts in the target path. Please specify the contract name with `--tc ContractName`") + } } target = Some(id); } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 167145d9d209f..bcd53afcf3d07 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1127,3 +1127,46 @@ forgetest_async!(assert_can_resume_with_additional_contracts, |prj, cmd| { .await .resume(ScriptOutcome::OkBroadcast); }); + +forgetest_async!(can_detect_contract_when_multiple_versions, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + prj.add_script( + "A.sol", + r#"pragma solidity 0.8.20; +import "./B.sol"; + +contract ScriptA {} +"#, + ) + .unwrap(); + + prj.add_script( + "B.sol", + r#"pragma solidity >=0.8.5 <=0.8.20; +import 'forge-std/Script.sol'; + +contract ScriptB is Script { + function run() external { + vm.broadcast(); + address(0).call(""); + } +} +"#, + ) + .unwrap(); + + prj.add_script( + "C.sol", + r#"pragma solidity 0.8.5; +import "./B.sol"; + +contract ScriptC {} +"#, + ) + .unwrap(); + + let mut tester = ScriptTester::new(cmd, None, prj.root(), "script/B.sol"); + tester.cmd.forge_fuse().args(["script", "script/B.sol"]); + tester.simulate(ScriptOutcome::OkNoEndpoint); +}); From 73383b5438f1b558e603431a26968bd0adafc019 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 15 Feb 2024 00:28:48 +0200 Subject: [PATCH 0625/1963] perf: improve LocalTraceIdentifier performance (#7118) * perf: improve LocalTraceIdentifier performance Implementation modified from https://github.com/foundry-rs/foundry/pull/7105, see that PR for more information. Co-authored-by: Arsenii Kulikov * docs * fix: account for multiple matches * feat: search len*0.9 .. len*1.1 * perf: start searching at same code length for common case * fix: oob --------- Co-authored-by: Arsenii Kulikov --- Cargo.lock | 10 --- crates/common/src/contracts.rs | 7 ++ crates/evm/traces/Cargo.toml | 1 - crates/evm/traces/src/identifier/local.rs | 100 ++++++++++++++++++---- 4 files changed, 89 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec2e562b8f2ff..21251c8ef0697 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3299,7 +3299,6 @@ dependencies = [ "hashbrown 0.14.3", "itertools 0.11.0", "once_cell", - "ordered-float", "revm-inspectors", "serde", "tempfile", @@ -5135,15 +5134,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "ordered-float" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" -dependencies = [ - "num-traits", -] - [[package]] name = "overload" version = "0.1.1" diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 65d8a8b8b52e9..818dee04596af 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -10,6 +10,7 @@ use once_cell::sync::Lazy; use regex::Regex; use std::{ collections::BTreeMap, + fmt, ops::{Deref, DerefMut}, path::PathBuf, }; @@ -20,6 +21,12 @@ type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a (JsonAbi, Vec)); #[derive(Clone, Default)] pub struct ContractsByArtifact(pub BTreeMap)>); +impl fmt::Debug for ContractsByArtifact { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_map().entries(self.iter().map(|(k, (v1, v2))| (k, (v1, hex::encode(v2))))).finish() + } +} + impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. pub fn find_by_code(&self, code: &[u8]) -> Option { diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 28d81e2fee7f5..94dd36b63d28c 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -29,7 +29,6 @@ hashbrown = "0.14" hex.workspace = true itertools.workspace = true once_cell = "1" -ordered-float = "4" serde = "1" tokio = { version = "1", features = ["time", "macros"] } tracing = "0.1" diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index d37552a78426c..c9bcd6fa4d5f3 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -3,19 +3,24 @@ use alloy_json_abi::JsonAbi; use alloy_primitives::Address; use foundry_common::contracts::{bytecode_diff_score, ContractsByArtifact}; use foundry_compilers::ArtifactId; -use ordered_float::OrderedFloat; use std::borrow::Cow; /// A trace identifier that tries to identify addresses using local contracts. pub struct LocalTraceIdentifier<'a> { + /// Known contracts to search through. known_contracts: &'a ContractsByArtifact, + /// Vector of pairs of artifact ID and the code length of the given artifact. + ordered_ids: Vec<(&'a ArtifactId, usize)>, } impl<'a> LocalTraceIdentifier<'a> { /// Creates a new local trace identifier. #[inline] pub fn new(known_contracts: &'a ContractsByArtifact) -> Self { - Self { known_contracts } + let mut ordered_ids = + known_contracts.iter().map(|(id, contract)| (id, contract.1.len())).collect::>(); + ordered_ids.sort_by_key(|(_, len)| *len); + Self { known_contracts, ordered_ids } } /// Returns the known contracts. @@ -24,21 +29,73 @@ impl<'a> LocalTraceIdentifier<'a> { self.known_contracts } - fn find_contract_from_bytecode( - &mut self, - code: &[u8], - ) -> Option<(&'a ArtifactId, &'a JsonAbi)> { - self.known_contracts - .iter() - .filter_map(|(id, (abi, known_code))| { - // Note: the diff score can be inaccurate for small contracts so we're using - // a relatively high threshold here to avoid filtering out too many - // contracts. - let score = bytecode_diff_score(known_code, code); - (score < 0.85).then_some((score, id, abi)) - }) - .min_by_key(|(score, _, _)| OrderedFloat(*score)) - .map(|(_, id, abi)| (id, abi)) + /// Iterates over artifacts with code length less than or equal to the given code and tries to + /// find a match. + /// + /// We do not consider artifacts with code length greater than the given code length as it is + /// considered that after compilation code can only be extended by additional parameters + /// (immutables) and cannot be shortened. + pub fn identify_code(&self, code: &[u8]) -> Option<(&'a ArtifactId, &'a JsonAbi)> { + let len = code.len(); + + let mut min_score = f64::MAX; + let mut min_score_id = None; + + let mut check = |id| { + let (abi, known_code) = self.known_contracts.get(id)?; + let score = bytecode_diff_score(known_code, code); + if score <= 0.1 { + trace!(%score, "found close-enough match"); + return Some((id, abi)); + } + if score < min_score { + min_score = score; + min_score_id = Some((id, abi)); + } + None + }; + + // Check `[len * 0.9, ..., len * 1.1]`. + let max_len = (len * 11) / 10; + + // Start at artifacts with the same code length: `len..len*1.1`. + let same_length_idx = self.find_index(len); + for idx in same_length_idx..self.ordered_ids.len() { + let (id, len) = self.ordered_ids[idx]; + if len > max_len { + break; + } + if let found @ Some(_) = check(id) { + return found; + } + } + + // Iterate over the remaining artifacts with less code length: `len*0.9..len`. + let min_len = (len * 9) / 10; + let idx = self.find_index(min_len); + for i in idx..same_length_idx { + let (id, _) = self.ordered_ids[i]; + if let found @ Some(_) = check(id) { + return found; + } + } + + trace!(%min_score, "no close-enough match found"); + min_score_id + } + + /// Returns the index of the artifact with the given code length, or the index of the first + /// artifact with a greater code length if the exact code length is not found. + fn find_index(&self, len: usize) -> usize { + let (Ok(mut idx) | Err(mut idx)) = + self.ordered_ids.binary_search_by(|(_, probe)| probe.cmp(&len)); + + // In case of multiple artifacts with the same code length, we need to find the first one. + while idx > 0 && self.ordered_ids[idx - 1].1 == len { + idx -= 1; + } + + idx } } @@ -47,9 +104,16 @@ impl TraceIdentifier for LocalTraceIdentifier<'_> { where A: Iterator)>, { + trace!("identify {:?} addresses", addresses.size_hint().1); + addresses .filter_map(|(address, code)| { - let (id, abi) = self.find_contract_from_bytecode(code?)?; + let _span = trace_span!("identify", %address).entered(); + + trace!("identifying"); + let (id, abi) = self.identify_code(code?)?; + trace!(id=%id.identifier(), "identified"); + Some(AddressIdentity { address: *address, contract: Some(id.identifier()), From 85669c27554ecafb18f1c65770b5eaaef5c004c9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 15 Feb 2024 00:29:03 +0200 Subject: [PATCH 0626/1963] perf/refactor: partial test runner refactor (#7109) * perf/refactor: partial test runner refactor * fix: update test output * fix: identify addresses if *any* trace * fix: clear addresses before decoding traces * fix: keep default labels * fix: mean overflow * chore: reorder some stuff * perf: speed up bytecode_diff_score in debug mode --- Cargo.toml | 13 +- clippy.toml | 2 +- crates/common/src/calc.rs | 56 ++- crates/common/src/contracts.rs | 28 +- crates/evm/core/src/decode.rs | 3 + crates/evm/fuzz/src/lib.rs | 22 +- crates/evm/traces/src/decoder/mod.rs | 20 +- crates/evm/traces/src/identifier/etherscan.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/snapshot.rs | 15 +- crates/forge/bin/cmd/test/mod.rs | 406 +++++------------- crates/forge/bin/cmd/test/summary.rs | 76 ++-- crates/forge/src/gas_report.rs | 99 ++--- crates/forge/src/multi_runner.rs | 122 +++--- crates/forge/src/result.rs | 248 ++++++++++- crates/forge/tests/cli/cmd.rs | 28 +- .../tests/fixtures/can_check_snapshot.stdout | 6 +- .../can_run_test_in_custom_test_folder.stdout | 6 +- .../tests/fixtures/can_test_repeatedly.stdout | 6 +- .../can_use_libs_in_multi_fork.stdout | 6 +- .../include_custom_types_in_traces.stdout | 6 +- crates/forge/tests/fixtures/repro_6531.stdout | 6 +- ...xactly_once_with_changed_versions.1.stdout | 6 +- ...xactly_once_with_changed_versions.2.stdout | 6 +- 24 files changed, 617 insertions(+), 573 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 97e815342e714..d4196400e1dcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.74" # Remember to update clippy.toml as well +rust-version = "1.75" # Remember to update clippy.toml as well authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" @@ -49,7 +49,10 @@ solang-parser.opt-level = 3 serde_json.opt-level = 3 # EVM +alloy-dyn-abi.opt-level = 3 +alloy-json-abi.opt-level = 3 alloy-primitives.opt-level = 3 +alloy-sol-type-parser.opt-level = 3 alloy-sol-types.opt-level = 3 hashbrown.opt-level = 3 keccak.opt-level = 3 @@ -62,12 +65,16 @@ sha2.opt-level = 3 sha3.opt-level = 3 tiny-keccak.opt-level = 3 -# keystores -scrypt.opt-level = 3 +# fuzzing +proptest.opt-level = 3 +foundry-evm-fuzz.opt-level = 3 # forking axum.opt-level = 3 +# keystores +scrypt.opt-level = 3 + # Local "release" mode, more optimized than dev but much faster to compile than release. [profile.local] inherits = "dev" diff --git a/clippy.toml b/clippy.toml index 866add684a962..cc4ad18b1872b 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.74" +msrv = "1.75" diff --git a/crates/common/src/calc.rs b/crates/common/src/calc.rs index e404c45201669..bde75635ce7fe 100644 --- a/crates/common/src/calc.rs +++ b/crates/common/src/calc.rs @@ -1,29 +1,28 @@ //! Commonly used calculations. use alloy_primitives::{Sign, U256}; -use std::ops::Div; -/// Returns the mean of the slice +/// Returns the mean of the slice. #[inline] -pub fn mean(values: &[U256]) -> U256 { +pub fn mean(values: &[u64]) -> u64 { if values.is_empty() { - return U256::ZERO + return 0; } - values.iter().copied().fold(U256::ZERO, |sum, val| sum + val).div(U256::from(values.len())) + (values.iter().map(|x| *x as u128).sum::() / values.len() as u128) as u64 } -/// Returns the median of a _sorted_ slice +/// Returns the median of a _sorted_ slice. #[inline] -pub fn median_sorted(values: &[U256]) -> U256 { +pub fn median_sorted(values: &[u64]) -> u64 { if values.is_empty() { - return U256::ZERO + return 0; } let len = values.len(); let mid = len / 2; if len % 2 == 0 { - (values[mid - 1] + values[mid]) / U256::from(2u64) + (values[mid - 1] + values[mid]) / 2 } else { values[mid] } @@ -70,49 +69,42 @@ mod tests { #[test] fn calc_mean_empty() { - let values: [U256; 0] = []; - let m = mean(&values); - assert_eq!(m, U256::ZERO); + let m = mean(&[]); + assert_eq!(m, 0); } #[test] fn calc_mean() { - let values = [ - U256::ZERO, - U256::from(1), - U256::from(2u64), - U256::from(3u64), - U256::from(4u64), - U256::from(5u64), - U256::from(6u64), - ]; - let m = mean(&values); - assert_eq!(m, U256::from(3u64)); + let m = mean(&[0, 1, 2, 3, 4, 5, 6]); + assert_eq!(m, 3); + } + + #[test] + fn calc_mean_overflow() { + let m = mean(&[0, 1, 2, u32::MAX as u64, 3, u16::MAX as u64, u64::MAX, 6]); + assert_eq!(m, 2305843009750573057); } #[test] fn calc_median_empty() { - let values: Vec = vec![]; - let m = median_sorted(&values); - assert_eq!(m, U256::from(0)); + let m = median_sorted(&[]); + assert_eq!(m, 0); } #[test] fn calc_median() { - let mut values = - vec![29, 30, 31, 40, 59, 61, 71].into_iter().map(U256::from).collect::>(); + let mut values = vec![29, 30, 31, 40, 59, 61, 71]; values.sort(); let m = median_sorted(&values); - assert_eq!(m, U256::from(40)); + assert_eq!(m, 40); } #[test] fn calc_median_even() { - let mut values = - vec![80, 90, 30, 40, 50, 60, 10, 20].into_iter().map(U256::from).collect::>(); + let mut values = vec![80, 90, 30, 40, 50, 60, 10, 20]; values.sort(); let m = median_sorted(&values); - assert_eq!(m, U256::from(45)); + assert_eq!(m, 45); } #[test] diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 818dee04596af..cef420518c0f6 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -103,6 +103,7 @@ pub type ContractsByAddress = BTreeMap; /// /// Returns a value between `0.0` (identical) and `1.0` (completely different). pub fn bytecode_diff_score<'a>(mut a: &'a [u8], mut b: &'a [u8]) -> f64 { + // Make sure `a` is the longer one. if a.len() < b.len() { std::mem::swap(&mut a, &mut b); } @@ -119,11 +120,36 @@ pub fn bytecode_diff_score<'a>(mut a: &'a [u8], mut b: &'a [u8]) -> f64 { } // Count different bytes. - n_different_bytes += std::iter::zip(a, b).filter(|(a, b)| a != b).count(); + // SAFETY: `a` is longer than `b`. + n_different_bytes += unsafe { count_different_bytes(a, b) }; n_different_bytes as f64 / a.len() as f64 } +/// Returns the amount of different bytes between two slices. +/// +/// # Safety +/// +/// `a` must be at least as long as `b`. +unsafe fn count_different_bytes(a: &[u8], b: &[u8]) -> usize { + // This could've been written as `std::iter::zip(a, b).filter(|(x, y)| x != y).count()`, + // however this function is very hot, and has been written to be as primitive as + // possible for lower optimization levels. + + let a_ptr = a.as_ptr(); + let b_ptr = b.as_ptr(); + let len = b.len(); + + let mut sum = 0; + let mut i = 0; + while i < len { + // SAFETY: `a` is at least as long as `b`, and `i` is in bound of `b`. + sum += unsafe { *a_ptr.add(i) != *b_ptr.add(i) } as usize; + i += 1; + } + sum +} + /// Flattens the contracts into (`id` -> (`JsonAbi`, `Vec`)) pairs pub fn flatten_contracts( contracts: &BTreeMap, diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index d4b889779859e..b9b1d9f521632 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -41,6 +41,9 @@ pub fn decode_revert( }) } +/// Tries to decode an error message from the given revert bytes. +/// +/// See [`decode_revert`] for more information. pub fn maybe_decode_revert( err: &[u8], maybe_abi: Option<&JsonAbi>, diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 55c1f1c3e5d55..ed3b50178f574 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -8,7 +8,7 @@ extern crate tracing; use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{Address, Bytes, Log}; use foundry_common::{calc, contracts::ContractsByAddress}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; @@ -157,18 +157,16 @@ pub struct FuzzTestResult { impl FuzzTestResult { /// Returns the median gas of all test cases pub fn median_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + let mut values = self.gas_values(with_stipend); values.sort_unstable(); - calc::median_sorted(&values).to::() + calc::median_sorted(&values) } /// Returns the average gas use of all test cases pub fn mean_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + let mut values = self.gas_values(with_stipend); values.sort_unstable(); - calc::mean(&values).to::() + calc::mean(&values) } fn gas_values(&self, with_stipend: bool) -> Vec { @@ -223,19 +221,17 @@ impl FuzzedCases { /// Returns the median gas of all test cases #[inline] pub fn median_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + let mut values = self.gas_values(with_stipend); values.sort_unstable(); - calc::median_sorted(&values).to::() + calc::median_sorted(&values) } /// Returns the average gas use of all test cases #[inline] pub fn mean_gas(&self, with_stipend: bool) -> u64 { - let mut values = - self.gas_values(with_stipend).into_iter().map(U256::from).collect::>(); + let mut values = self.gas_values(with_stipend); values.sort_unstable(); - calc::mean(&values).to::() + calc::mean(&values) } #[inline] diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 0fac862b29eb5..9057fb92a7a3e 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -99,12 +99,14 @@ pub struct CallTraceDecoder { pub labels: HashMap, /// Contract addresses that have a receive function. pub receive_contracts: Vec
, + /// All known functions. pub functions: HashMap>, /// All known events. pub events: BTreeMap<(B256, usize), Vec>, /// All known errors. pub errors: JsonAbi, + /// A signature identifier for events and functions. pub signature_identifier: Option, /// Verbosity level @@ -143,7 +145,6 @@ impl CallTraceDecoder { Self { contracts: Default::default(), - labels: [ (CHEATCODE_ADDRESS, "VM".to_string()), (HARDHAT_CONSOLE_ADDRESS, "console".to_string()), @@ -152,6 +153,7 @@ impl CallTraceDecoder { (TEST_CONTRACT_ADDRESS, "DefaultTestContract".to_string()), ] .into(), + receive_contracts: Default::default(), functions: hh_funcs() .chain( @@ -162,20 +164,30 @@ impl CallTraceDecoder { ) .map(|(selector, func)| (selector, vec![func])) .collect(), - events: Console::abi::events() .into_values() .flatten() .map(|event| ((event.selector(), indexed_inputs(&event)), vec![event])) .collect(), - errors: Default::default(), + signature_identifier: None, - receive_contracts: Default::default(), verbosity: 0, } } + /// Clears all known addresses. + pub fn clear_addresses(&mut self) { + self.contracts.clear(); + + let default_labels = &Self::new().labels; + if self.labels.len() > default_labels.len() { + self.labels = default_labels.clone(); + } + + self.receive_contracts.clear(); + } + /// Identify unknown addresses in the specified call trace using the specified identifier. /// /// Unknown contracts are contracts that either lack a label or an ABI. diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 1ddbf2457d6ff..e995b36f9b666 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -99,7 +99,7 @@ impl TraceIdentifier for EtherscanIdentifier { where A: Iterator)>, { - trace!(target: "etherscanidentifier", "identify {:?} addresses", addresses.size_hint().1); + trace!("identify {:?} addresses", addresses.size_hint().1); let Some(client) = self.client.clone() else { // no client was configured diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 771bd8bb09066..ab78bdff2ff3f 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -310,7 +310,7 @@ impl CoverageArgs { ..Default::default() }) .set_coverage(true) - .build(root.clone(), output, env, evm_opts)?; + .build(&root, output, env, evm_opts)?; // Run tests let known_contracts = runner.known_contracts.clone(); diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index bd657abe84386..f60ab01bb01d3 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -1,11 +1,8 @@ -use super::{ - test, - test::{Test, TestOutcome}, -}; +use super::test; use alloy_primitives::U256; use clap::{builder::RangedU64ValueParser, Parser, ValueHint}; use eyre::{Context, Result}; -use forge::result::TestKindReport; +use forge::result::{SuiteTestResult, TestKindReport, TestOutcome}; use foundry_cli::utils::STATIC_FUZZ_SEED; use once_cell::sync::Lazy; use regex::Regex; @@ -175,7 +172,7 @@ impl SnapshotConfig { true } - fn apply(&self, outcome: TestOutcome) -> Vec { + fn apply(&self, outcome: TestOutcome) -> Vec { let mut tests = outcome .into_tests() .filter(|test| self.is_in_gas_range(test.gas_used())) @@ -274,7 +271,7 @@ fn read_snapshot(path: impl AsRef) -> Result> { /// Writes a series of tests to a snapshot file after sorting them fn write_to_snapshot_file( - tests: &[Test], + tests: &[SuiteTestResult], path: impl AsRef, _format: Option, ) -> Result<()> { @@ -318,7 +315,7 @@ impl SnapshotDiff { /// Compares the set of tests with an existing snapshot /// /// Returns true all tests match -fn check(tests: Vec, snaps: Vec, tolerance: Option) -> bool { +fn check(tests: Vec, snaps: Vec, tolerance: Option) -> bool { let snaps = snaps .into_iter() .map(|s| ((s.contract_name, s.signature), s.gas_used)) @@ -352,7 +349,7 @@ fn check(tests: Vec, snaps: Vec, tolerance: Option) -> } /// Compare the set of tests with an existing snapshot -fn diff(tests: Vec, snaps: Vec) -> Result<()> { +fn diff(tests: Vec, snaps: Vec) -> Result<()> { let snaps = snaps .into_iter() .map(|s| ((s.contract_name, s.signature), s.gas_used)) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 10d188c4b6a22..102f93e31ef17 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -6,7 +6,7 @@ use forge::{ decode::decode_console_logs, gas_report::GasReport, inspectors::CheatsConfig, - result::{SuiteResult, TestResult, TestStatus}, + result::{SuiteResult, TestOutcome, TestStatus}, traces::{ identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, CallTraceDecoderBuilder, TraceKind, @@ -21,7 +21,7 @@ use foundry_common::{ compact_to_contract, compile::{ContractSources, ProjectCompiler}, evm::EvmArgs, - get_contract_name, get_file_name, shell, + shell, }; use foundry_config::{ figment, @@ -33,7 +33,7 @@ use foundry_config::{ }; use foundry_debugger::Debugger; use regex::Regex; -use std::{collections::BTreeMap, fs, sync::mpsc::channel, time::Duration}; +use std::{collections::BTreeMap, fs, sync::mpsc::channel}; use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; @@ -186,81 +186,35 @@ impl TestArgs { // Prepare the test builder let should_debug = self.debug.is_some(); - let runner_builder = MultiContractRunnerBuilder::default() + // Clone the output only if we actually need it later for the debugger. + let output_clone = should_debug.then(|| output.clone()); + + let runner = MultiContractRunnerBuilder::default() .set_debug(should_debug) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone())) - .with_test_options(test_options.clone()); - - let runner = runner_builder.clone().build( - project_root, - output.clone(), - env.clone(), - evm_opts.clone(), - )?; + .with_test_options(test_options.clone()) + .build(project_root, output, env, evm_opts)?; - if should_debug { - filter.args_mut().test_pattern = self.debug.clone(); - let num_filtered = runner.matching_test_function_count(&filter); - if num_filtered != 1 { + if let Some(debug_test_pattern) = &self.debug { + let test_pattern = &mut filter.args_mut().test_pattern; + if test_pattern.is_some() { eyre::bail!( - "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n\n\ - Use --match-contract and --match-path to further limit the search." + "Cannot specify both --debug and --match-test. \ + Use --match-contract and --match-path to further limit the search instead." ); } + *test_pattern = Some(debug_test_pattern.clone()); } - let known_contracts = runner.known_contracts.clone(); - let mut local_identifier = LocalTraceIdentifier::new(&known_contracts); - let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - - let outcome = self - .run_tests(runner, config.clone(), verbosity, &filter, test_options.clone()) - .await?; + let outcome = self.run_tests(runner, config, verbosity, &filter, test_options).await?; if should_debug { - let tests = outcome.clone().into_tests(); - // todo(onbjerg): why do we bother decoding everything and having multiple decoders if - // we are only going to use the first one? (see `DebuggerArgs` below) - let mut decoders = Vec::new(); - for test in tests { - let mut result = test.result; - // Identify addresses in each trace - let mut builder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.clone()) - .with_local_identifier_abis(&local_identifier) - .with_verbosity(verbosity); - - // Signatures are of no value for gas reports - if !self.gas_report { - let sig_identifier = - SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; - builder = builder.with_signature_identifier(sig_identifier.clone()); - } - - let mut decoder = builder.build(); - - if !result.traces.is_empty() { - // Set up identifiers - // Do not re-query etherscan for contracts that you've already queried today. - let mut etherscan_identifier = - EtherscanIdentifier::new(&config, remote_chain_id)?; - - // Decode the traces - for (_, trace) in &mut result.traces { - decoder.identify(trace, &mut local_identifier); - decoder.identify(trace, &mut etherscan_identifier); - } - } - - decoders.push(decoder); - } - - let mut sources: ContractSources = Default::default(); - for (id, artifact) in output.into_artifacts() { + let mut sources = ContractSources::default(); + for (id, artifact) in output_clone.unwrap().into_artifacts() { // Sources are only required for the debugger, but it *might* mean that there's // something wrong with the build and/or artifacts. if let Some(source) = artifact.source_file() { @@ -276,16 +230,20 @@ impl TestArgs { } } - let test = outcome.clone().into_tests().next().unwrap(); - let result = test.result; - // Run the debugger - let mut debugger = Debugger::builder() - // TODO: `Option::as_slice` in 1.75 - .debug_arenas(result.debug.as_ref().map(core::slice::from_ref).unwrap_or_default()) - .decoders(&decoders) + // There is only one test. + let Some(test) = outcome.into_tests_cloned().next() else { + return Err(eyre::eyre!("no tests were executed")); + }; + + // Run the debugger. + let mut builder = Debugger::builder() + .debug_arenas(test.result.debug.as_slice()) .sources(sources) - .breakpoints(result.breakpoints) - .build(); + .breakpoints(test.result.breakpoints); + if let Some(decoder) = &outcome.decoder { + builder = builder.decoder(decoder); + } + let mut debugger = builder.build(); debugger.try_run()?; } @@ -305,16 +263,10 @@ impl TestArgs { return list(runner, filter, self.json); } - if let Some(debug_regex) = self.debug.as_ref() { - let mut filter = filter.clone(); - filter.args_mut().test_pattern = Some(debug_regex.clone()); - let results = runner.test_collect(&filter, test_options).await; - return Ok(TestOutcome::new(results, self.allow_failure)); - } - trace!(target: "forge::test", "running all tests"); - if runner.matching_test_function_count(filter) == 0 { + let num_filtered = runner.matching_test_function_count(filter); + if num_filtered == 0 { println!(); if filter.is_empty() { println!( @@ -335,6 +287,13 @@ impl TestArgs { } } } + if self.debug.is_some() && num_filtered != 1 { + eyre::bail!( + "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n\n\ + Use --match-contract and --match-path to further limit the search.\n\ + Filter used:\n{filter}" + ); + } if self.json { let results = runner.test_collect(filter, test_options).await; @@ -342,46 +301,58 @@ impl TestArgs { return Ok(TestOutcome::new(results, self.allow_failure)); } - // Set up identifiers + // Set up trace identifiers. let known_contracts = runner.known_contracts.clone(); let mut local_identifier = LocalTraceIdentifier::new(&known_contracts); let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - // Do not re-query etherscan for contracts that you've already queried today. let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; - // Set up test reporter channel + // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); - - // Run tests let handle = tokio::task::spawn({ let filter = filter.clone(); async move { runner.test(&filter, tx, test_options).await } }); - let mut results = BTreeMap::new(); - let mut gas_report = GasReport::new(config.gas_reports, config.gas_reports_ignore); - let sig_identifier = - SignaturesIdentifier::new(Config::foundry_cache_dir(), config.offline)?; + let mut gas_report = + self.gas_report.then(|| GasReport::new(config.gas_reports, config.gas_reports_ignore)); + + // Build the trace decoder. + let mut builder = CallTraceDecoderBuilder::new() + .with_local_identifier_abis(&local_identifier) + .with_verbosity(verbosity); + // Signatures are of no value for gas reports. + if !self.gas_report { + builder = builder.with_signature_identifier(SignaturesIdentifier::new( + Config::foundry_cache_dir(), + config.offline, + )?); + } + let mut decoder = builder.build(); + + // We identify addresses if we're going to print *any* trace or gas report. + let identify_addresses = verbosity >= 3 || self.gas_report || self.debug.is_some(); - let mut total_passed = 0; - let mut total_failed = 0; - let mut total_skipped = 0; - let mut suite_results: Vec = Vec::new(); + let mut outcome = TestOutcome::empty(self.allow_failure); - 'outer: for (contract_name, suite_result) in rx { - results.insert(contract_name.clone(), suite_result.clone()); + let mut any_test_failed = false; + for (contract_name, suite_result) in rx { + let tests = &suite_result.test_results; - let mut tests = suite_result.test_results.clone(); + // Print suite header. println!(); for warning in suite_result.warnings.iter() { eprintln!("{} {warning}", Paint::yellow("Warning:").bold()); } if !tests.is_empty() { - let term = if tests.len() > 1 { "tests" } else { "test" }; - println!("Running {} {term} for {contract_name}", tests.len()); + let len = tests.len(); + let tests = if len > 1 { "tests" } else { "test" }; + println!("Ran {len} {tests} for {contract_name}"); } - for (name, result) in &mut tests { - short_test_result(name, result); + + // Process individual test results, printing logs and traces when necessary. + for (name, result) in tests { + shell::println(result.short_result(name))?; // We only display logs at level 2 and above if verbosity >= 2 { @@ -396,28 +367,27 @@ impl TestArgs { } } + // We shouldn't break out of the outer loop directly here so that we finish + // processing the remaining tests and print the suite summary. + any_test_failed |= result.status == TestStatus::Failure; + if result.traces.is_empty() { continue; } - // Identify addresses in each trace - let mut builder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.iter().map(|(a, s)| (*a, s.clone()))) - .with_local_identifier_abis(&local_identifier) - .with_verbosity(verbosity); - - // Signatures are of no value for gas reports - if !self.gas_report { - builder = builder.with_signature_identifier(sig_identifier.clone()); - } + // Clear the addresses and labels from previous runs. + decoder.clear_addresses(); + decoder + .labels + .extend(result.labeled_addresses.iter().map(|(k, v)| (*k, v.clone()))); - let mut decoder = builder.build(); - - // Decode the traces + // Identify addresses and decode traces. let mut decoded_traces = Vec::with_capacity(result.traces.len()); - for (kind, arena) in &mut result.traces { - decoder.identify(arena, &mut local_identifier); - decoder.identify(arena, &mut etherscan_identifier); + for (kind, arena) in &result.traces { + if identify_addresses { + decoder.identify(arena, &mut local_identifier); + decoder.identify(arena, &mut etherscan_identifier); + } // verbosity: // - 0..3: nothing @@ -441,52 +411,43 @@ impl TestArgs { if !decoded_traces.is_empty() { shell::println("Traces:")?; - decoded_traces.into_iter().try_for_each(shell::println)?; + for trace in &decoded_traces { + shell::println(trace)?; + } } - if self.gas_report { + if let Some(gas_report) = &mut gas_report { gas_report.analyze(&result.traces, &decoder).await; } - - // If the test failed, we want to stop processing the rest of the tests - if self.fail_fast && result.status == TestStatus::Failure { - break 'outer - } } - let block_outcome = TestOutcome::new( - [(contract_name.clone(), suite_result)].into(), - self.allow_failure, - ); - total_passed += block_outcome.successes().count(); - total_failed += block_outcome.failures().count(); - total_skipped += block_outcome.skips().count(); + // Print suite summary. + shell::println(suite_result.summary())?; - shell::println(block_outcome.summary())?; + // Add the suite result to the outcome. + outcome.results.insert(contract_name, suite_result); - if self.summary { - suite_results.push(block_outcome.clone()); + // Stop processing the remaining suites if any test failed and `fail_fast` is set. + if self.fail_fast && any_test_failed { + break; } } - if self.gas_report { + trace!(target: "forge::test", len=outcome.results.len(), %any_test_failed, "done with results"); + + outcome.decoder = Some(decoder); + + if let Some(gas_report) = gas_report { shell::println(gas_report.finalize())?; } - let num_test_suites = results.len(); - - if num_test_suites > 0 { - shell::println(format_aggregated_summary( - num_test_suites, - total_passed, - total_failed, - total_skipped, - ))?; + if !outcome.results.is_empty() { + shell::println(outcome.summary())?; if self.summary { let mut summary_table = TestSummaryReporter::new(self.detailed); shell::println("\n\nTest Summary:")?; - summary_table.print_summary(suite_results); + summary_table.print_summary(&outcome); } } @@ -498,9 +459,7 @@ impl TestArgs { } } - trace!(target: "forge::test", "received {} results", results.len()); - - Ok(TestOutcome::new(results, self.allow_failure)) + Ok(outcome) } /// Returns the flattened [`FilterArgs`] arguments merged with [`Config`]. @@ -550,157 +509,6 @@ impl Provider for TestArgs { } } -/// The result of a single test -#[derive(Clone, Debug)] -pub struct Test { - /// The identifier of the artifact/contract in the form of `:` - pub artifact_id: String, - /// The signature of the solidity test - pub signature: String, - /// Result of the executed solidity test - pub result: TestResult, -} - -impl Test { - pub fn gas_used(&self) -> u64 { - self.result.kind.report().gas() - } - - /// Returns the contract name of the artifact id - pub fn contract_name(&self) -> &str { - get_contract_name(&self.artifact_id) - } - - /// Returns the file name of the artifact id - pub fn file_name(&self) -> &str { - get_file_name(&self.artifact_id) - } -} - -/// Represents the bundled results of all tests -#[derive(Clone, Debug)] -pub struct TestOutcome { - /// Whether failures are allowed - pub allow_failure: bool, - /// Results for each suite of tests `contract -> SuiteResult` - pub results: BTreeMap, -} - -impl TestOutcome { - fn new(results: BTreeMap, allow_failure: bool) -> Self { - Self { results, allow_failure } - } - - /// Returns an iterator over all succeeding tests and their names. - pub fn successes(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Success) - } - - /// Returns an iterator over all failing tests and their names. - pub fn failures(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Failure) - } - - /// Returns an iterator over all skipped tests and their names. - pub fn skips(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Skipped) - } - - /// Returns an iterator over all tests and their names. - pub fn tests(&self) -> impl Iterator { - self.results.values().flat_map(|suite| suite.tests()) - } - - /// Returns an iterator over all `Test`s. - pub fn into_tests(self) -> impl Iterator { - self.results - .into_iter() - .flat_map(|(file, SuiteResult { test_results, .. })| { - test_results.into_iter().map(move |t| (file.clone(), t)) - }) - .map(|(artifact_id, (signature, result))| Test { artifact_id, signature, result }) - } - - /// Checks if there are any failures and failures are disallowed - pub fn ensure_ok(&self) -> Result<()> { - let failures = self.failures().count(); - if self.allow_failure || failures == 0 { - return Ok(()); - } - - if !shell::verbosity().is_normal() { - // skip printing and exit early - std::process::exit(1); - } - - shell::println("")?; - shell::println("Failing tests:")?; - for (suite_name, suite) in self.results.iter() { - let failures = suite.failures().count(); - if failures == 0 { - continue; - } - - let term = if failures > 1 { "tests" } else { "test" }; - shell::println(format!("Encountered {failures} failing {term} in {suite_name}"))?; - for (name, result) in suite.failures() { - short_test_result(name, result); - } - shell::println("")?; - } - let successes = self.successes().count(); - shell::println(format!( - "Encountered a total of {} failing tests, {} tests succeeded", - Paint::red(failures.to_string()), - Paint::green(successes.to_string()) - ))?; - - std::process::exit(1); - } - - pub fn duration(&self) -> Duration { - self.results - .values() - .fold(Duration::ZERO, |acc, SuiteResult { duration, .. }| acc + *duration) - } - - pub fn summary(&self) -> String { - let failed = self.failures().count(); - let result = if failed == 0 { Paint::green("ok") } else { Paint::red("FAILED") }; - format!( - "Test result: {}. {} passed; {} failed; {} skipped; finished in {:.2?}", - result, - Paint::green(self.successes().count()), - Paint::red(failed), - Paint::yellow(self.skips().count()), - self.duration() - ) - } -} - -fn short_test_result(name: &str, result: &TestResult) { - shell::println(format!("{result} {name} {}", result.kind.report())).unwrap(); -} - -/// Formats the aggregated summary of all test suites into a string (for printing). -fn format_aggregated_summary( - num_test_suites: usize, - total_passed: usize, - total_failed: usize, - total_skipped: usize, -) -> String { - let total_tests = total_passed + total_failed + total_skipped; - format!( - " \nRan {} test suites: {} tests passed, {} failed, {} skipped ({} total tests)", - num_test_suites, - Paint::green(total_passed), - Paint::red(total_failed), - Paint::yellow(total_skipped), - total_tests - ) -} - /// Lists all matching tests fn list( runner: MultiContractRunner, diff --git a/crates/forge/bin/cmd/test/summary.rs b/crates/forge/bin/cmd/test/summary.rs index 5f8bd9650bd8b..561ea6b6824c6 100644 --- a/crates/forge/bin/cmd/test/summary.rs +++ b/crates/forge/bin/cmd/test/summary.rs @@ -48,64 +48,46 @@ impl TestSummaryReporter { Self { table, is_detailed } } - pub(crate) fn print_summary(&mut self, mut test_results: Vec) { - // Sort by suite name first - - // Using `sort_by_cached_key` so that the key extraction logic runs only once - test_results.sort_by_cached_key(|test_outcome| { - test_outcome - .results - .keys() - .next() - .and_then(|suite| suite.split(':').nth(1)) - .unwrap() - .to_string() - }); - + pub(crate) fn print_summary(&mut self, outcome: &TestOutcome) { // Traverse the test_results vector and build the table - for suite in &test_results { - for contract in suite.results.keys() { - let mut row = Row::new(); - let suite_name = contract.split(':').nth(1).unwrap(); - let suite_path = contract.split(':').nth(0).unwrap(); - - let passed = suite.successes().count(); - let mut passed_cell = Cell::new(passed).set_alignment(CellAlignment::Center); + for (contract, suite) in &outcome.results { + let mut row = Row::new(); + let (suite_path, suite_name) = contract.split_once(':').unwrap(); - let failed = suite.failures().count(); - let mut failed_cell = Cell::new(failed).set_alignment(CellAlignment::Center); + let passed = suite.successes().count(); + let mut passed_cell = Cell::new(passed).set_alignment(CellAlignment::Center); - let skipped = suite.skips().count(); - let mut skipped_cell = Cell::new(skipped).set_alignment(CellAlignment::Center); + let failed = suite.failures().count(); + let mut failed_cell = Cell::new(failed).set_alignment(CellAlignment::Center); - let duration = suite.duration(); + let skipped = suite.skips().count(); + let mut skipped_cell = Cell::new(skipped).set_alignment(CellAlignment::Center); - row.add_cell(Cell::new(suite_name)); + row.add_cell(Cell::new(suite_name)); - if passed > 0 { - passed_cell = passed_cell.fg(Color::Green); - } - row.add_cell(passed_cell); - - if failed > 0 { - failed_cell = failed_cell.fg(Color::Red); - } - row.add_cell(failed_cell); + if passed > 0 { + passed_cell = passed_cell.fg(Color::Green); + } + row.add_cell(passed_cell); - if skipped > 0 { - skipped_cell = skipped_cell.fg(Color::Yellow); - } - row.add_cell(skipped_cell); + if failed > 0 { + failed_cell = failed_cell.fg(Color::Red); + } + row.add_cell(failed_cell); - if self.is_detailed { - row.add_cell(Cell::new(suite_path)); - row.add_cell(Cell::new(format!("{:.2?}", duration).to_string())); - } + if skipped > 0 { + skipped_cell = skipped_cell.fg(Color::Yellow); + } + row.add_cell(skipped_cell); - self.table.add_row(row); + if self.is_detailed { + row.add_cell(Cell::new(suite_path)); + row.add_cell(Cell::new(format!("{:.2?}", suite.duration).to_string())); } + + self.table.add_row(row); } - // Print the summary table + println!("\n{}", self.table); } } diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index c537643ad618b..9d416e36ff1c2 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -5,7 +5,6 @@ use crate::{ hashbrown::HashSet, traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData, TraceKind}, }; -use alloy_primitives::U256; use comfy_table::{presets::ASCII_MARKDOWN, *}; use foundry_common::{calc, TestFunctionExt}; use serde::{Deserialize, Serialize}; @@ -37,10 +36,23 @@ impl GasReport { } /// Whether the given contract should be reported. + #[instrument(level = "trace", skip(self), ret)] fn should_report(&self, contract_name: &str) -> bool { if self.ignore.contains(contract_name) { - // could be specified in both ignore and report_for - return self.report_for.contains(contract_name) + let contains_anyway = self.report_for.contains(contract_name); + if contains_anyway { + // If the user listed the contract in 'gas_reports' (the foundry.toml field) a + // report for the contract is generated even if it's listed in the ignore + // list. This is addressed this way because getting a report you don't expect is + // preferable than not getting one you expect. A warning is printed to stderr + // indicating the "double listing". + eprintln!( + "{}: {} is listed in both 'gas_reports' and 'gas_reports_ignore'.", + yansi::Paint::yellow("warning").bold(), + contract_name + ); + } + return contains_anyway; } self.report_any || self.report_for.contains(contract_name) } @@ -58,48 +70,38 @@ impl GasReport { async fn analyze_node(&mut self, node: &CallTraceNode, decoder: &CallTraceDecoder) { let trace = &node.trace; - let decoded = decoder.decode_function(&node.trace).await; if trace.address == CHEATCODE_ADDRESS || trace.address == HARDHAT_CONSOLE_ADDRESS { - return + return; } - if let Some(name) = &decoded.contract { - let contract_name = name.rsplit(':').next().unwrap_or(name.as_str()); - // If the user listed the contract in 'gas_reports' (the foundry.toml field) a - // report for the contract is generated even if it's listed in the ignore - // list. This is addressed this way because getting a report you don't expect is - // preferable than not getting one you expect. A warning is printed to stderr - // indicating the "double listing". - if self.report_for.contains(contract_name) && self.ignore.contains(contract_name) { - eprintln!( - "{}: {} is listed in both 'gas_reports' and 'gas_reports_ignore'.", - yansi::Paint::yellow("warning").bold(), - contract_name - ); - } + let decoded = decoder.decode_function(&node.trace).await; + + let Some(name) = &decoded.contract else { return }; + let contract_name = name.rsplit(':').next().unwrap_or(name); + + if !self.should_report(contract_name) { + return; + } - if self.should_report(contract_name) { - let contract_info = self.contracts.entry(name.to_string()).or_default(); - - if trace.kind.is_any_create() { - contract_info.gas = U256::from(trace.gas_used); - contract_info.size = U256::from(trace.data.len()); - } else if let Some(DecodedCallData { signature, .. }) = decoded.func { - let name = signature.split('(').next().unwrap(); - // ignore any test/setup functions - let should_include = - !(name.is_test() || name.is_invariant_test() || name.is_setup()); - if should_include { - let gas_info = contract_info - .functions - .entry(name.to_string()) - .or_default() - .entry(signature.clone()) - .or_default(); - gas_info.calls.push(U256::from(trace.gas_used)); - } - } + let contract_info = self.contracts.entry(name.to_string()).or_default(); + if trace.kind.is_any_create() { + trace!(contract_name, "adding create gas info"); + contract_info.gas = trace.gas_used; + contract_info.size = trace.data.len(); + } else if let Some(DecodedCallData { signature, .. }) = decoded.func { + let name = signature.split('(').next().unwrap(); + // ignore any test/setup functions + let should_include = !(name.is_test() || name.is_invariant_test() || name.is_setup()); + if should_include { + trace!(contract_name, signature, "adding gas info"); + let gas_info = contract_info + .functions + .entry(name.to_string()) + .or_default() + .entry(signature.clone()) + .or_default(); + gas_info.calls.push(trace.gas_used); } } } @@ -114,7 +116,7 @@ impl GasReport { func.min = func.calls.first().copied().unwrap_or_default(); func.max = func.calls.last().copied().unwrap_or_default(); func.mean = calc::mean(&func.calls); - func.median = U256::from(calc::median_sorted(func.calls.as_slice())); + func.median = calc::median_sorted(func.calls.as_slice()); }); }); }); @@ -173,16 +175,17 @@ impl Display for GasReport { #[derive(Debug, Default, Serialize, Deserialize)] pub struct ContractInfo { - pub gas: U256, - pub size: U256, + pub gas: u64, + pub size: usize, + /// Function name -> Function signature -> GasInfo pub functions: BTreeMap>, } #[derive(Debug, Default, Serialize, Deserialize)] pub struct GasInfo { - pub calls: Vec, - pub min: U256, - pub mean: U256, - pub median: U256, - pub max: U256, + pub calls: Vec, + pub min: u64, + pub mean: u64, + pub median: u64, + pub max: u64, } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 0c876a640f29d..a15934c7be3ef 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -9,9 +9,7 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::{OptionExt, Result}; use foundry_common::{ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{ - contracts::ArtifactContracts, Artifact, ArtifactId, ArtifactOutput, ProjectCompileOutput, -}; +use foundry_compilers::{contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput}; use foundry_evm::{ backend::Backend, executors::{Executor, ExecutorBuilder}, @@ -232,6 +230,7 @@ impl MultiContractRunner { /// Builder used for instantiating the multi-contract runner #[derive(Clone, Debug, Default)] +#[must_use = "builders do nothing unless you call `build` on them"] pub struct MultiContractRunnerBuilder { /// The address which will be used to deploy the initial contracts and send all /// transactions @@ -253,36 +252,75 @@ pub struct MultiContractRunnerBuilder { } impl MultiContractRunnerBuilder { + pub fn sender(mut self, sender: Address) -> Self { + self.sender = Some(sender); + self + } + + pub fn initial_balance(mut self, initial_balance: U256) -> Self { + self.initial_balance = initial_balance; + self + } + + pub fn evm_spec(mut self, spec: SpecId) -> Self { + self.evm_spec = Some(spec); + self + } + + pub fn with_fork(mut self, fork: Option) -> Self { + self.fork = fork; + self + } + + pub fn with_cheats_config(mut self, cheats_config: CheatsConfig) -> Self { + self.cheats_config = Some(cheats_config); + self + } + + pub fn with_test_options(mut self, test_options: TestOptions) -> Self { + self.test_options = Some(test_options); + self + } + + pub fn set_coverage(mut self, enable: bool) -> Self { + self.coverage = enable; + self + } + + pub fn set_debug(mut self, enable: bool) -> Self { + self.debug = enable; + self + } + /// Given an EVM, proceeds to return a runner which is able to execute all tests /// against that evm - pub fn build( + pub fn build( self, - root: impl AsRef, - output: ProjectCompileOutput, + root: &Path, + output: ProjectCompileOutput, env: revm::primitives::Env, evm_opts: EvmOpts, - ) -> Result - where - A: ArtifactOutput + Debug, - { - let output = output.with_stripped_file_prefixes(&root); + ) -> Result { // This is just the contracts compiled, but we need to merge this with the read cached // artifacts. let contracts = output + .with_stripped_file_prefixes(root) .into_artifacts() .map(|(i, c)| (i, c.into_contract_bytecode())) .collect::(); let source_paths = contracts .iter() - .map(|(i, _)| (i.identifier(), root.as_ref().join(&i.source).to_string_lossy().into())) + .map(|(i, _)| (i.identifier(), root.join(&i.source).to_string_lossy().into())) .collect::>(); - // create a mapping of name => (abi, deployment code, Vec) - let mut deployable_contracts = DeployableContracts::default(); - let linker = Linker::new(root.as_ref(), contracts); + let linker = Linker::new(root, contracts); + + // Create a mapping of name => (abi, deployment code, Vec) + let mut deployable_contracts = DeployableContracts::default(); let mut known_contracts = ContractsByArtifact::default(); + for (id, contract) in &linker.contracts.0 { let abi = contract.abi.as_ref().ok_or_eyre("we should have an abi by now")?; @@ -311,9 +349,9 @@ impl MultiContractRunnerBuilder { deployable_contracts.insert(id.clone(), (abi.clone(), bytecode, libs_to_deploy)); } - linked_contract.get_deployed_bytecode_bytes().map(|b| b.into_owned()).and_then( - |bytes| known_contracts.insert(id.clone(), (abi.clone(), bytes.to_vec())), - ); + if let Some(bytes) = linked_contract.get_deployed_bytecode_bytes() { + known_contracts.insert(id.clone(), (abi.clone(), bytes.to_vec())); + } } let errors = known_contracts.flatten_errors(); @@ -333,52 +371,4 @@ impl MultiContractRunnerBuilder { test_options: self.test_options.unwrap_or_default(), }) } - - #[must_use] - pub fn sender(mut self, sender: Address) -> Self { - self.sender = Some(sender); - self - } - - #[must_use] - pub fn initial_balance(mut self, initial_balance: U256) -> Self { - self.initial_balance = initial_balance; - self - } - - #[must_use] - pub fn evm_spec(mut self, spec: SpecId) -> Self { - self.evm_spec = Some(spec); - self - } - - #[must_use] - pub fn with_fork(mut self, fork: Option) -> Self { - self.fork = fork; - self - } - - #[must_use] - pub fn with_cheats_config(mut self, cheats_config: CheatsConfig) -> Self { - self.cheats_config = Some(cheats_config); - self - } - - #[must_use] - pub fn with_test_options(mut self, test_options: TestOptions) -> Self { - self.test_options = Some(test_options); - self - } - - #[must_use] - pub fn set_coverage(mut self, enable: bool) -> Self { - self.coverage = enable; - self - } - - #[must_use] - pub fn set_debug(mut self, enable: bool) -> Self { - self.debug = enable; - self - } } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index fe490dda45bd1..2e22adc85b219 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,13 +1,13 @@ //! Test outcomes. use alloy_primitives::{Address, Log}; -use foundry_common::evm::Breakpoints; +use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ coverage::HitMaps, debug::DebugArena, executors::EvmError, fuzz::{CounterExample, FuzzCase}, - traces::{TraceKind, Traces}, + traces::{CallTraceDecoder, TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; use std::{ @@ -17,14 +17,173 @@ use std::{ }; use yansi::Paint; -/// Results and duration for a set of tests included in the same test contract +/// The aggregated result of a test run. +#[derive(Clone, Debug)] +pub struct TestOutcome { + /// The results of all test suites by their identifier (`path:contract_name`). + /// + /// Essentially `identifier => signature => result`. + pub results: BTreeMap, + /// Whether to allow test failures without failing the entire test run. + pub allow_failure: bool, + /// The decoder used to decode traces and logs. + /// + /// This is `None` if traces and logs were not decoded. + /// + /// Note that `Address` fields only contain the last executed test case's data. + pub decoder: Option, +} + +impl TestOutcome { + /// Creates a new test outcome with the given results. + pub fn new(results: BTreeMap, allow_failure: bool) -> Self { + Self { results, allow_failure, decoder: None } + } + + /// Creates a new empty test outcome. + pub fn empty(allow_failure: bool) -> Self { + Self { results: BTreeMap::new(), allow_failure, decoder: None } + } + + /// Returns an iterator over all individual succeeding tests and their names. + pub fn successes(&self) -> impl Iterator { + self.tests().filter(|(_, t)| t.status == TestStatus::Success) + } + + /// Returns an iterator over all individual skipped tests and their names. + pub fn skips(&self) -> impl Iterator { + self.tests().filter(|(_, t)| t.status == TestStatus::Skipped) + } + + /// Returns an iterator over all individual failing tests and their names. + pub fn failures(&self) -> impl Iterator { + self.tests().filter(|(_, t)| t.status == TestStatus::Failure) + } + + /// Returns an iterator over all individual tests and their names. + pub fn tests(&self) -> impl Iterator { + self.results.values().flat_map(|suite| suite.tests()) + } + + /// Flattens the test outcome into a list of individual tests. + // TODO: Replace this with `tests` and make it return `TestRef<'_>` + pub fn into_tests_cloned(&self) -> impl Iterator + '_ { + self.results + .iter() + .flat_map(|(file, suite)| { + suite + .test_results + .iter() + .map(move |(sig, result)| (file.clone(), sig.clone(), result.clone())) + }) + .map(|(artifact_id, signature, result)| SuiteTestResult { + artifact_id, + signature, + result, + }) + } + + /// Flattens the test outcome into a list of individual tests. + pub fn into_tests(self) -> impl Iterator { + self.results + .into_iter() + .flat_map(|(file, suite)| { + suite.test_results.into_iter().map(move |t| (file.clone(), t)) + }) + .map(|(artifact_id, (signature, result))| SuiteTestResult { + artifact_id, + signature, + result, + }) + } + + /// Returns the number of tests that passed. + pub fn passed(&self) -> usize { + self.successes().count() + } + + /// Returns the number of tests that were skipped. + pub fn skipped(&self) -> usize { + self.skips().count() + } + + /// Returns the number of tests that failed. + pub fn failed(&self) -> usize { + self.failures().count() + } + + /// Calculates the total duration of all test suites. + pub fn duration(&self) -> Duration { + self.results.values().map(|suite| suite.duration).sum() + } + + /// Formats the aggregated summary of all test suites into a string (for printing). + pub fn summary(&self) -> String { + let num_test_suites = self.results.len(); + let suites = if num_test_suites == 1 { "suite" } else { "suites" }; + let total_passed = self.passed(); + let total_failed = self.failed(); + let total_skipped = self.skipped(); + let total_tests = total_passed + total_failed + total_skipped; + format!( + "\nRan {} test {}: {} tests passed, {} failed, {} skipped ({} total tests)", + num_test_suites, + suites, + Paint::green(total_passed), + Paint::red(total_failed), + Paint::yellow(total_skipped), + total_tests + ) + } + + /// Checks if there are any failures and failures are disallowed. + pub fn ensure_ok(&self) -> eyre::Result<()> { + let outcome = self; + let failures = outcome.failures().count(); + if outcome.allow_failure || failures == 0 { + return Ok(()); + } + + if !shell::verbosity().is_normal() { + // TODO: Avoid process::exit + std::process::exit(1); + } + + shell::println("")?; + shell::println("Failing tests:")?; + for (suite_name, suite) in outcome.results.iter() { + let failed = suite.failed(); + if failed == 0 { + continue; + } + + let term = if failed > 1 { "tests" } else { "test" }; + shell::println(format!("Encountered {failed} failing {term} in {suite_name}"))?; + for (name, result) in suite.failures() { + shell::println(result.short_result(name))?; + } + shell::println("")?; + } + let successes = outcome.passed(); + shell::println(format!( + "Encountered a total of {} failing tests, {} tests succeeded", + Paint::red(failures.to_string()), + Paint::green(successes.to_string()) + ))?; + + // TODO: Avoid process::exit + std::process::exit(1); + } +} + +/// A set of test results for a single test suite, which is all the tests in a single contract. #[derive(Clone, Debug, Serialize)] pub struct SuiteResult { - /// Total duration of the test run for this block of tests + /// Total duration of the test run for this block of tests. pub duration: Duration, - /// Individual test results. `test fn signature -> TestResult` + /// Individual test results: `test fn signature -> TestResult`. pub test_results: BTreeMap, - /// Warnings + /// Generated warnings. pub warnings: Vec, } @@ -37,16 +196,36 @@ impl SuiteResult { Self { duration, test_results, warnings } } - /// Iterator over all succeeding tests and their names + /// Returns an iterator over all individual succeeding tests and their names. pub fn successes(&self) -> impl Iterator { self.tests().filter(|(_, t)| t.status == TestStatus::Success) } - /// Iterator over all failing tests and their names + /// Returns an iterator over all individual skipped tests and their names. + pub fn skips(&self) -> impl Iterator { + self.tests().filter(|(_, t)| t.status == TestStatus::Skipped) + } + + /// Returns an iterator over all individual failing tests and their names. pub fn failures(&self) -> impl Iterator { self.tests().filter(|(_, t)| t.status == TestStatus::Failure) } + /// Returns the number of tests that passed. + pub fn passed(&self) -> usize { + self.successes().count() + } + + /// Returns the number of tests that were skipped. + pub fn skipped(&self) -> usize { + self.skips().count() + } + + /// Returns the number of tests that failed. + pub fn failed(&self) -> usize { + self.failures().count() + } + /// Iterator over all tests and their names pub fn tests(&self) -> impl Iterator { self.test_results.iter() @@ -61,8 +240,54 @@ impl SuiteResult { pub fn len(&self) -> usize { self.test_results.len() } + + /// Returns the summary of a single test suite. + pub fn summary(&self) -> String { + let failed = self.failed(); + let result = if failed == 0 { Paint::green("ok") } else { Paint::red("FAILED") }; + format!( + "Test result: {}. {} passed; {} failed; {} skipped; finished in {:.2?}", + result, + Paint::green(self.passed()), + Paint::red(failed), + Paint::yellow(self.skipped()), + self.duration, + ) + } +} + +/// The result of a single test in a test suite. +/// +/// This is flattened from a [`TestOutcome`]. +#[derive(Clone, Debug)] +pub struct SuiteTestResult { + /// The identifier of the artifact/contract in the form: + /// `:`. + pub artifact_id: String, + /// The function signature of the Solidity test. + pub signature: String, + /// The result of the executed test. + pub result: TestResult, } +impl SuiteTestResult { + /// Returns the gas used by the test. + pub fn gas_used(&self) -> u64 { + self.result.kind.report().gas() + } + + /// Returns the contract name of the artifact ID. + pub fn contract_name(&self) -> &str { + get_contract_name(&self.artifact_id) + } + + /// Returns the file name of the artifact ID. + pub fn file_name(&self) -> &str { + get_file_name(&self.artifact_id) + } +} + +/// The status of a test. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub enum TestStatus { Success, @@ -91,7 +316,7 @@ impl TestStatus { } } -/// The result of an executed solidity test +/// The result of an executed test. #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct TestResult { /// The test status, indicating whether the test case succeeded, failed, or was marked as @@ -177,6 +402,11 @@ impl TestResult { pub fn is_fuzz(&self) -> bool { matches!(self.kind, TestKind::Fuzz { .. }) } + + /// Formats the test result into a string (for printing). + pub fn short_result(&self, name: &str) -> String { + format!("{self} {name} {}", self.kind.report()) + } } /// Data report by a test. diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 222248f84e6cb..a187169fae98b 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1291,36 +1291,34 @@ contract ContractThreeTest is DSTest { .unwrap(); // report for One - prj.write_config(Config { - gas_reports: (vec!["ContractOne".to_string()]), - gas_reports_ignore: (vec![]), - ..Default::default() - }); + prj.write_config(Config { gas_reports: vec!["ContractOne".to_string()], ..Default::default() }); cmd.forge_fuse(); let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); - assert!(first_out.contains("foo") && !first_out.contains("bar") && !first_out.contains("baz")); + assert!( + first_out.contains("foo") && !first_out.contains("bar") && !first_out.contains("baz"), + "foo:\n{first_out}" + ); // report for Two - cmd.forge_fuse(); - prj.write_config(Config { - gas_reports: (vec!["ContractTwo".to_string()]), - ..Default::default() - }); + prj.write_config(Config { gas_reports: vec!["ContractTwo".to_string()], ..Default::default() }); cmd.forge_fuse(); let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); assert!( - !second_out.contains("foo") && second_out.contains("bar") && !second_out.contains("baz") + !second_out.contains("foo") && second_out.contains("bar") && !second_out.contains("baz"), + "bar:\n{second_out}" ); // report for Three - cmd.forge_fuse(); prj.write_config(Config { - gas_reports: (vec!["ContractThree".to_string()]), + gas_reports: vec!["ContractThree".to_string()], ..Default::default() }); cmd.forge_fuse(); let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); - assert!(!third_out.contains("foo") && !third_out.contains("bar") && third_out.contains("baz")); + assert!( + !third_out.contains("foo") && !third_out.contains("bar") && third_out.contains("baz"), + "baz:\n{third_out}" + ); }); forgetest!(gas_ignore_some_contracts, |prj, cmd| { diff --git a/crates/forge/tests/fixtures/can_check_snapshot.stdout b/crates/forge/tests/fixtures/can_check_snapshot.stdout index dffc5df496344..1846bd5778b67 100644 --- a/crates/forge/tests/fixtures/can_check_snapshot.stdout +++ b/crates/forge/tests/fixtures/can_check_snapshot.stdout @@ -2,8 +2,8 @@ Compiling 2 files with 0.8.23 Solc 0.8.23 finished in 424.55ms Compiler run successful! -Running 1 test for src/ATest.t.sol:ATest +Ran 1 test for src/ATest.t.sol:ATest [PASS] testExample() (gas: 168) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.42ms - -Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout index 5cf274ebc7de2..1701d90029b98 100644 --- a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout +++ b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout @@ -2,8 +2,8 @@ Compiling 2 files with 0.8.23 Solc 0.8.23 finished in 185.25ms Compiler run successful! -Running 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest +Ran 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest [PASS] testTrue() (gas: 168) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93ms - -Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout index 6d645a5606b55..3d782aa358727 100644 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ b/crates/forge/tests/fixtures/can_test_repeatedly.stdout @@ -1,8 +1,8 @@ No files changed, compilation skipped -Running 2 tests for test/Counter.t.sol:CounterTest +Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) [PASS] test_Increment() (gas: 28379) Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms - -Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests) + +Ran 1 test suite: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout index 4c954e6c37c9c..5a5b2f621811c 100644 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout @@ -2,8 +2,8 @@ Compiling 2 files with 0.8.23 Solc 0.8.23 finished in 1.95s Compiler run successful! -Running 1 test for test/Contract.t.sol:ContractTest +Ran 1 test for test/Contract.t.sol:ContractTest [PASS] test() (gas: 70360) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s - -Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout index be5d7706debb7..19771e0920f58 100644 --- a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout +++ b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout @@ -2,7 +2,7 @@ Compiling 1 files with 0.8.23 Solc 0.8.23 finished in 798.51ms Compiler run successful! -Running 2 tests for test/Contract.t.sol:CustomTypesTest +Ran 2 tests for test/Contract.t.sol:CustomTypesTest [FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231) Traces: [231] CustomTypesTest::testErr() @@ -15,8 +15,8 @@ Traces: └─ ← () Test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms - -Ran 1 test suites: 1 tests passed, 1 failed, 0 skipped (2 total tests) + +Ran 1 test suite: 1 tests passed, 1 failed, 0 skipped (2 total tests) Failing tests: Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout index d2c2596cb169d..1dfca09d72ff2 100644 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -2,7 +2,7 @@ Compiling 1 files with 0.8.23 Compiler run successful! -Running 1 test for test/Contract.t.sol:USDCCallingTest +Ran 1 test for test/Contract.t.sol:USDCCallingTest [PASS] test() (gas: 16799) Traces: [16799] USDCCallingTest::test() @@ -15,5 +15,5 @@ Traces: └─ ← () Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s - -Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout index aee6fb691ce3e..c46d083296faf 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout @@ -2,8 +2,8 @@ Compiling 2 files with 0.8.23 Solc 0.8.23 finished in 185.25ms Compiler run successful! -Running 1 test for src/Contract.t.sol:ContractTest +Ran 1 test for src/Contract.t.sol:ContractTest [PASS] testExample() (gas: 190) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms - -Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout index 691af81679df1..28dbffcc86c34 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout @@ -2,8 +2,8 @@ Compiling 2 files with 0.8.22 Solc 0.8.22 finished in 185.25ms Compiler run successful! -Running 1 test for src/Contract.t.sol:ContractTest +Ran 1 test for src/Contract.t.sol:ContractTest [PASS] testExample() (gas: 190) Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms - -Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) From 3cdee829b44a3f2b112b4b7f0baa5f721b54cea2 Mon Sep 17 00:00:00 2001 From: James Wenzel Date: Wed, 14 Feb 2024 14:45:24 -0800 Subject: [PATCH 0627/1963] support mcopy (#7130) --- crates/debugger/src/tui/draw.rs | 46 ++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 585375b245f68..d06e5c231eb9a 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -513,23 +513,22 @@ impl DebuggerContext<'_> { // Color memory region based on read/write. let mut offset = None; let mut size = None; + let mut write_offset = None; + let mut write_size = None; let mut color = None; if let Instruction::OpCode(op) = step.instruction { let stack_len = step.stack.len(); if stack_len > 0 { if let Some(accesses) = get_buffer_accesses(op, &step.stack) { - if accesses.read.as_ref().is_some_and(|a| a.0 == self.active_buffer) { - let read_access = accesses.read.unwrap(); + if let Some(read_access) = accesses.read { offset = Some(read_access.1.offset); size = Some(read_access.1.size); color = Some(Color::Cyan); - } else if let Some(write_access) = accesses.write { - // TODO: with MCOPY, it will be possible to both read from and write to the - // memory buffer with the same opcode + } + if let Some(write_access) = accesses.write { if self.active_buffer == BufferKind::Memory { - offset = Some(write_access.offset); - size = Some(write_access.size); - color = Some(Color::Red); + write_offset = Some(write_access.offset); + write_size = Some(write_access.size); } } } @@ -537,6 +536,9 @@ impl DebuggerContext<'_> { } // color word on previous write op + // TODO: technically it's possible for this to conflict with the current op, ie, with + // subsequent MCOPYs, but solc can't seem to generate that code even with high optimizer + // settings if self.current_step > 0 { let prev_step = self.current_step - 1; let prev_step = &self.debug_steps()[prev_step]; @@ -573,8 +575,10 @@ impl DebuggerContext<'_> { // Word hex bytes. hex_bytes_spans(buf_word, &mut spans, |j, _| { let mut byte_color = Color::White; + let mut end = None; + let idx = i * 32 + j; if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { - let idx = i * 32 + j; + end = Some(offset + size); if (offset..offset + size).contains(&idx) { // [offset, offset + size] is the memory region to be colored. // If a byte at row i and column j in the memory panel @@ -582,6 +586,29 @@ impl DebuggerContext<'_> { byte_color = color; } } + if let (Some(write_offset), Some(write_size)) = (write_offset, write_size) { + // check for overlap with read region + let write_end = write_offset + write_size; + if let Some(read_end) = end { + let read_start = offset.unwrap(); + if (write_offset..write_end).contains(&read_end) { + // if it contains end, start from write_start up to read_end + if (write_offset..read_end).contains(&idx) { + return Style::new().fg(Color::Yellow); + } + } else if (write_offset..write_end).contains(&read_start) { + // otherwise if it contains read start, start from read_start up to + // write_end + if (read_start..write_end).contains(&idx) { + return Style::new().fg(Color::Yellow); + } + } + } + if (write_offset..write_end).contains(&idx) { + byte_color = Color::Red; + } + } + Style::new().fg(byte_color) }); @@ -682,6 +709,7 @@ fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { opcode::CREATE | opcode::CREATE2 => (Some((BufferKind::Memory, 2, 3)), None), opcode::CALL | opcode::CALLCODE => (Some((BufferKind::Memory, 4, 5)), None), opcode::DELEGATECALL | opcode::STATICCALL => (Some((BufferKind::Memory, 3, 4)), None), + opcode::MCOPY => (Some((BufferKind::Memory, 2, 3)), Some((1, 3))), _ => Default::default(), }; From 95aae1e63b36ab926792cbe76028ddf822b3ffa3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:12:19 +0200 Subject: [PATCH 0628/1963] feat: add a revert decoder to eagerly hash error selectors (#7133) --- crates/anvil/src/eth/api.rs | 6 +- crates/anvil/src/eth/backend/mem/mod.rs | 7 +- crates/anvil/src/eth/error.rs | 7 +- crates/common/src/contracts.rs | 11 - crates/evm/core/src/decode.rs | 231 +++++++++++------- crates/evm/evm/src/executors/fuzz/mod.rs | 8 +- .../evm/evm/src/executors/invariant/error.rs | 12 +- crates/evm/evm/src/executors/invariant/mod.rs | 11 +- crates/evm/evm/src/executors/mod.rs | 28 +-- crates/evm/traces/src/decoder/mod.rs | 22 +- crates/forge/bin/cmd/script/mod.rs | 6 +- crates/forge/src/multi_runner.rs | 12 +- crates/forge/src/runner.rs | 30 ++- 13 files changed, 221 insertions(+), 170 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index fff26c9d9ffb4..b7ed87e3c4f10 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -67,7 +67,7 @@ use anvil_rpc::{error::RpcError, response::ResponseResult}; use foundry_common::provider::alloy::ProviderBuilder; use foundry_evm::{ backend::DatabaseError, - decode::maybe_decode_revert, + decode::RevertDecoder, revm::{ db::DatabaseRef, interpreter::{return_ok, return_revert, InstructionResult}, @@ -1917,7 +1917,9 @@ impl EthApi { if let Some(output) = receipt.out { // insert revert reason if failure if receipt.inner.status_code.unwrap_or_default().to::() == 0 { - if let Some(reason) = maybe_decode_revert(&output, None, None) { + if let Some(reason) = + RevertDecoder::new().maybe_decode(&output, None) + { tx.other.insert( "revertReason".to_string(), serde_json::to_value(reason).expect("Infallible"), diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 05a2ae8511a19..43b1f2aca39e2 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -62,7 +62,7 @@ use foundry_common::types::ToAlloy; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, - decode::decode_revert, + decode::RevertDecoder, inspectors::AccessListTracer, revm::{ self, @@ -956,9 +956,8 @@ impl Backend { } node_info!(" Gas used: {}", receipt.gas_used()); if !info.exit.is_ok() { - let r = decode_revert( - info.out.clone().unwrap_or_default().as_ref(), - None, + let r = RevertDecoder::new().decode( + info.out.as_ref().map(|b| &b[..]).unwrap_or_default(), Some(info.exit), ); node_info!(" Error: reverted with: {r}"); diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index d0b48e411af64..37e0fce549201 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -10,7 +10,7 @@ use anvil_rpc::{ }; use foundry_evm::{ backend::DatabaseError, - decode::maybe_decode_revert, + decode::RevertDecoder, revm::{ self, interpreter::InstructionResult, @@ -302,8 +302,9 @@ impl ToRpcResponseResult for Result { InvalidTransactionError::Revert(data) => { // this mimics geth revert error let mut msg = "execution reverted".to_string(); - if let Some(reason) = - data.as_ref().and_then(|data| maybe_decode_revert(data, None, None)) + if let Some(reason) = data + .as_ref() + .and_then(|data| RevertDecoder::new().maybe_decode(data, None)) { msg = format!("{msg}: {reason}"); } diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index cef420518c0f6..72d101852dfa4 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -69,17 +69,6 @@ impl ContractsByArtifact { } (funcs, events, errors_abi) } - - /// Flattens the errors into a single JsonAbi. - pub fn flatten_errors(&self) -> JsonAbi { - let mut errors_abi = JsonAbi::new(); - for (_name, (abi, _code)) in self.iter() { - for error in abi.errors() { - errors_abi.errors.entry(error.name.clone()).or_default().push(error.clone()); - } - } - errors_abi - } } impl Deref for ContractsByArtifact { diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index b9b1d9f521632..2646edabedfbc 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -2,12 +2,13 @@ use crate::abi::{Console, Vm}; use alloy_dyn_abi::JsonAbiExt; -use alloy_json_abi::JsonAbi; -use alloy_primitives::Log; +use alloy_json_abi::{Error, JsonAbi}; +use alloy_primitives::{Log, Selector}; use alloy_sol_types::{SolCall, SolError, SolEventInterface, SolInterface, SolValue}; use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; +use std::{collections::HashMap, sync::OnceLock}; /// Decode a set of logs, only returning logs from DSTest logging events and Hardhat's `console.log` pub fn decode_console_logs(logs: &[Log]) -> Vec { @@ -23,107 +24,165 @@ pub fn decode_console_log(log: &Log) -> Option { Console::ConsoleEvents::decode_log(log, false).ok().map(|decoded| decoded.to_string()) } -/// Tries to decode an error message from the given revert bytes. -/// -/// Note that this is just a best-effort guess, and should not be relied upon for anything other -/// than user output. -pub fn decode_revert( - err: &[u8], - maybe_abi: Option<&JsonAbi>, - status: Option, -) -> String { - maybe_decode_revert(err, maybe_abi, status).unwrap_or_else(|| { - if err.is_empty() { - "".to_string() - } else { - trimmed_hex(err) - } - }) +/// Decodes revert data. +#[derive(Clone, Debug, Default)] +pub struct RevertDecoder { + /// The custom errors to use for decoding. + pub errors: HashMap>, } -/// Tries to decode an error message from the given revert bytes. -/// -/// See [`decode_revert`] for more information. -pub fn maybe_decode_revert( - err: &[u8], - maybe_abi: Option<&JsonAbi>, - status: Option, -) -> Option { - if err.len() < SELECTOR_LEN { - if let Some(status) = status { - if !status.is_ok() { - return Some(format!("EvmError: {status:?}")); - } - } - return if err.is_empty() { - None - } else { - Some(format!("custom error bytes {}", hex::encode_prefixed(err))) - }; +impl Default for &RevertDecoder { + fn default() -> Self { + static EMPTY: OnceLock = OnceLock::new(); + EMPTY.get_or_init(RevertDecoder::new) } +} - if err == crate::constants::MAGIC_SKIP { - // Also used in forge fuzz runner - return Some("SKIPPED".to_string()); +impl RevertDecoder { + /// Creates a new, empty revert decoder. + pub fn new() -> Self { + Self::default() } - // Solidity's `Error(string)` or `Panic(uint256)` - if let Ok(e) = alloy_sol_types::GenericContractError::abi_decode(err, false) { - return Some(e.to_string()); + /// Sets the ABIs to use for error decoding. + /// + /// Note that this is decently expensive as it will hash all errors for faster indexing. + pub fn with_abis<'a>(mut self, abi: impl IntoIterator) -> Self { + self.extend_from_abis(abi); + self } - let (selector, data) = err.split_at(SELECTOR_LEN); - let selector: &[u8; 4] = selector.try_into().unwrap(); + /// Sets the ABI to use for error decoding. + /// + /// Note that this is decently expensive as it will hash all errors for faster indexing. + pub fn with_abi(mut self, abi: &JsonAbi) -> Self { + self.extend_from_abi(abi); + self + } - match *selector { - // `CheatcodeError(string)` - Vm::CheatcodeError::SELECTOR => { - let e = Vm::CheatcodeError::abi_decode_raw(data, false).ok()?; - return Some(e.message); + /// Sets the ABI to use for error decoding, if it is present. + /// + /// Note that this is decently expensive as it will hash all errors for faster indexing. + pub fn with_abi_opt(mut self, abi: Option<&JsonAbi>) -> Self { + if let Some(abi) = abi { + self.extend_from_abi(abi); } - // `expectRevert(bytes)` - Vm::expectRevert_2Call::SELECTOR => { - let e = Vm::expectRevert_2Call::abi_decode_raw(data, false).ok()?; - return maybe_decode_revert(&e.revertData[..], maybe_abi, status); - } - // `expectRevert(bytes4)` - Vm::expectRevert_1Call::SELECTOR => { - let e = Vm::expectRevert_1Call::abi_decode_raw(data, false).ok()?; - return maybe_decode_revert(&e.revertData[..], maybe_abi, status); + self + } + + /// Extends the decoder with the given ABI's custom errors. + pub fn extend_from_abis<'a>(&mut self, abi: impl IntoIterator) { + for abi in abi { + self.extend_from_abi(abi); } - _ => {} } - // Custom error from the given ABI - if let Some(abi) = maybe_abi { - if let Some(abi_error) = abi.errors().find(|e| selector == e.selector()) { - // if we don't decode, don't return an error, try to decode as a string later - if let Ok(decoded) = abi_error.abi_decode_input(data, false) { - return Some(format!( - "{}({})", - abi_error.name, - decoded.iter().map(foundry_common::fmt::format_token).format(", ") - )); - } + /// Extends the decoder with the given ABI's custom errors. + pub fn extend_from_abi(&mut self, abi: &JsonAbi) { + for error in abi.errors() { + self.push_error(error.clone()); } } - // ABI-encoded `string` - if let Ok(s) = String::abi_decode(err, false) { - return Some(s); + /// Adds a custom error to use for decoding. + pub fn push_error(&mut self, error: Error) { + self.errors.entry(error.selector()).or_default().push(error); } - // UTF-8-encoded string - if let Ok(s) = std::str::from_utf8(err) { - return Some(s.to_string()); + /// Tries to decode an error message from the given revert bytes. + /// + /// Note that this is just a best-effort guess, and should not be relied upon for anything other + /// than user output. + pub fn decode(&self, err: &[u8], status: Option) -> String { + self.maybe_decode(err, status).unwrap_or_else(|| { + if err.is_empty() { + "".to_string() + } else { + trimmed_hex(err) + } + }) } - // Generic custom error - Some(format!( - "custom error {}:{}", - hex::encode(selector), - std::str::from_utf8(data).map_or_else(|_| trimmed_hex(data), String::from) - )) + /// Tries to decode an error message from the given revert bytes. + /// + /// See [`decode_revert`] for more information. + pub fn maybe_decode(&self, err: &[u8], status: Option) -> Option { + if err.len() < SELECTOR_LEN { + if let Some(status) = status { + if !status.is_ok() { + return Some(format!("EvmError: {status:?}")); + } + } + return if err.is_empty() { + None + } else { + Some(format!("custom error bytes {}", hex::encode_prefixed(err))) + }; + } + + if err == crate::constants::MAGIC_SKIP { + // Also used in forge fuzz runner + return Some("SKIPPED".to_string()); + } + + // Solidity's `Error(string)` or `Panic(uint256)` + if let Ok(e) = alloy_sol_types::GenericContractError::abi_decode(err, false) { + return Some(e.to_string()); + } + + let (selector, data) = err.split_at(SELECTOR_LEN); + let selector: &[u8; 4] = selector.try_into().unwrap(); + + match *selector { + // `CheatcodeError(string)` + Vm::CheatcodeError::SELECTOR => { + let e = Vm::CheatcodeError::abi_decode_raw(data, false).ok()?; + return Some(e.message); + } + // `expectRevert(bytes)` + Vm::expectRevert_2Call::SELECTOR => { + let e = Vm::expectRevert_2Call::abi_decode_raw(data, false).ok()?; + return self.maybe_decode(&e.revertData[..], status); + } + // `expectRevert(bytes4)` + Vm::expectRevert_1Call::SELECTOR => { + let e = Vm::expectRevert_1Call::abi_decode_raw(data, false).ok()?; + return self.maybe_decode(&e.revertData[..], status); + } + _ => {} + } + + // Custom errors. + if let Some(errors) = self.errors.get(selector) { + for error in errors { + // If we don't decode, don't return an error, try to decode as a string later. + if let Ok(decoded) = error.abi_decode_input(data, false) { + return Some(format!( + "{}({})", + error.name, + decoded.iter().map(foundry_common::fmt::format_token).format(", ") + )); + } + } + } + + // ABI-encoded `string`. + if let Ok(s) = String::abi_decode(err, false) { + return Some(s); + } + + // UTF-8-encoded string. + if let Ok(s) = std::str::from_utf8(err) { + return Some(s.to_string()); + } + + // Generic custom error. + Some(format!( + "custom error {}:{}", + hex::encode(selector), + std::str::from_utf8(data).map_or_else(|_| trimmed_hex(data), String::from) + )) + } } fn trimmed_hex(s: &[u8]) -> String { @@ -147,8 +206,8 @@ mod tests { fn test_trimmed_hex() { assert_eq!(trimmed_hex(&hex::decode("1234567890").unwrap()), "1234567890"); assert_eq!( - trimmed_hex(&hex::decode("492077697368207275737420737570706F72746564206869676865722D6B696E646564207479706573").unwrap()), - "49207769736820727573742073757070…6865722d6b696e646564207479706573 (41 bytes)" - ); + trimmed_hex(&hex::decode("492077697368207275737420737570706F72746564206869676865722D6B696E646564207479706573").unwrap()), + "49207769736820727573742073757070…6865722d6b696e646564207479706573 (41 bytes)" + ); } } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 4adcca6320ed9..ab8989f30f02c 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,12 +1,12 @@ use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; -use alloy_json_abi::{Function, JsonAbi}; +use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_config::FuzzConfig; use foundry_evm_core::{ constants::MAGIC_ASSUME, - decode::{self, decode_console_logs}, + decode::{decode_console_logs, RevertDecoder}, }; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ @@ -60,7 +60,7 @@ impl FuzzedExecutor { func: &Function, address: Address, should_fail: bool, - errors: Option<&JsonAbi>, + rd: &RevertDecoder, ) -> FuzzTestResult { // Stores the first Fuzzcase let first_case: RefCell> = RefCell::default(); @@ -130,7 +130,7 @@ impl FuzzedExecutor { let call_res = _counterexample.1.result.clone(); *counterexample.borrow_mut() = _counterexample; // HACK: we have to use an empty string here to denote `None` - let reason = decode::maybe_decode_revert(&call_res, errors, Some(status)); + let reason = rd.maybe_decode(&call_res, Some(status)); Err(TestCaseError::fail(reason.unwrap_or_default())) } } diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 7dd67289a5beb..c8990efb7f7bf 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -4,7 +4,7 @@ use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log}; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; -use foundry_evm_core::{constants::CALLER, decode::decode_revert}; +use foundry_evm_core::{constants::CALLER, decode::RevertDecoder}; use foundry_evm_fuzz::{BaseCounterExample, CounterExample, FuzzedCases, Reason}; use foundry_evm_traces::{load_contracts, CallTraceArena, TraceKind, Traces}; use itertools::Itertools; @@ -15,8 +15,8 @@ use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use revm::primitives::U256; use std::sync::Arc; -#[derive(Clone, Default)] /// Stores information about failures and reverts of the invariant tests. +#[derive(Clone, Default)] pub struct InvariantFailures { /// Total number of reverts. pub reverts: usize, @@ -89,11 +89,9 @@ impl InvariantFuzzError { } else { (None, "Revert") }; - let revert_reason = decode_revert( - call_result.result.as_ref(), - Some(invariant_contract.abi), - Some(call_result.exit_reason), - ); + let revert_reason = RevertDecoder::new() + .with_abi(invariant_contract.abi) + .decode(call_result.result.as_ref(), Some(call_result.exit_reason)); InvariantFuzzError { logs: call_result.logs, diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index fc0a91a534bef..d0e3d36fe995c 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -666,14 +666,9 @@ impl<'a> InvariantExecutor<'a> { f: fn(DynSolValue) -> Vec, ) -> Vec { if let Some(func) = abi.functions().find(|func| func.name == method_name) { - if let Ok(call_result) = self.executor.call::<_, _>( - CALLER, - address, - func.clone(), - vec![], - U256::ZERO, - Some(abi), - ) { + if let Ok(call_result) = + self.executor.call::<_, _>(CALLER, address, func.clone(), vec![], U256::ZERO, None) + { return f(call_result.result) } else { warn!( diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index f3aae1330002a..76d00b80b2b71 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -10,7 +10,7 @@ use crate::inspectors::{ cheatcodes::BroadcastableTransactions, Cheatcodes, InspectorData, InspectorStack, }; use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Function, JsonAbi}; +use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log, U256}; use alloy_signer::LocalWallet; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; @@ -20,7 +20,7 @@ use foundry_evm_core::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, }, debug::DebugArena, - decode, + decode::RevertDecoder, utils::{eval_to_instruction_result, halt_to_instruction_result, StateChangeset}, }; use foundry_evm_coverage::HitMaps; @@ -222,12 +222,12 @@ impl Executor { func: F, args: T, value: U256, - abi: Option<&JsonAbi>, + rd: Option<&RevertDecoder>, ) -> Result { let func = func.into(); let calldata = Bytes::from(func.abi_encode_input(&args.into())?); let result = self.call_raw_committing(from, to, calldata, value)?; - convert_call_result(abi, &func, result) + convert_call_result(rd, &func, result) } /// Performs a raw call to an account on the current state of the VM. @@ -254,7 +254,7 @@ impl Executor { func: F, args: T, value: U256, - abi: Option<&JsonAbi>, + rd: Option<&RevertDecoder>, ) -> Result { let func = func.into(); let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); @@ -262,7 +262,7 @@ impl Executor { // execute the call let env = self.build_test_env(from, TransactTo::Call(test_contract), calldata, value); let call_result = self.call_raw_with_env(env)?; - convert_call_result(abi, &func, call_result) + convert_call_result(rd, &func, call_result) } /// Performs a call to an account on the current state of the VM. @@ -275,12 +275,12 @@ impl Executor { func: F, args: T, value: U256, - abi: Option<&JsonAbi>, + rd: Option<&RevertDecoder>, ) -> Result { let func = func.into(); let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); let call_result = self.call_raw(from, to, calldata, value)?; - convert_call_result(abi, &func, call_result) + convert_call_result(rd, &func, call_result) } /// Performs a raw call to an account on the current state of the VM. @@ -352,7 +352,7 @@ impl Executor { pub fn deploy_with_env( &mut self, env: Env, - abi: Option<&JsonAbi>, + rd: Option<&RevertDecoder>, ) -> Result { debug_assert!( matches!(env.tx.transact_to, TransactTo::Create(_)), @@ -405,7 +405,7 @@ impl Executor { } } _ => { - let reason = decode::decode_revert(result.as_ref(), abi, Some(exit_reason)); + let reason = rd.unwrap_or_default().decode(&result, Some(exit_reason)); return Err(EvmError::Execution(Box::new(ExecutionErr { reverted: true, reason, @@ -441,10 +441,10 @@ impl Executor { from: Address, code: Bytes, value: U256, - abi: Option<&JsonAbi>, + rd: Option<&RevertDecoder>, ) -> Result { let env = self.build_test_env(from, TransactTo::Create(CreateScheme::Create), code, value); - self.deploy_with_env(env, abi) + self.deploy_with_env(env, rd) } /// Check if a call to a test contract was successful. @@ -824,7 +824,7 @@ fn convert_executed_result( } fn convert_call_result( - abi: Option<&JsonAbi>, + rd: Option<&RevertDecoder>, func: &Function, call_result: RawCallResult, ) -> Result { @@ -885,7 +885,7 @@ fn convert_call_result( if &result == crate::constants::MAGIC_SKIP { return Err(EvmError::SkipError) } - let reason = decode::decode_revert(&result, abi, Some(status)); + let reason = rd.unwrap_or_default().decode(&result, Some(status)); Err(EvmError::Execution(Box::new(ExecutionErr { reverted, reason, diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 9057fb92a7a3e..9e881488eb636 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -14,7 +14,7 @@ use foundry_evm_core::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS, }, - decode, + decode::RevertDecoder, }; use itertools::Itertools; use once_cell::sync::OnceCell; @@ -104,8 +104,8 @@ pub struct CallTraceDecoder { pub functions: HashMap>, /// All known events. pub events: BTreeMap<(B256, usize), Vec>, - /// All known errors. - pub errors: JsonAbi, + /// Revert decoder. Contains all known custom errors. + pub revert_decoder: RevertDecoder, /// A signature identifier for events and functions. pub signature_identifier: Option, @@ -169,7 +169,7 @@ impl CallTraceDecoder { .flatten() .map(|event| ((event.selector(), indexed_inputs(&event)), vec![event])) .collect(), - errors: Default::default(), + revert_decoder: Default::default(), signature_identifier: None, verbosity: 0, @@ -208,7 +208,7 @@ impl CallTraceDecoder { if entry.get().contains(&function) { return; } - debug!(target: "evm::traces", selector=%entry.key(), new=%function.signature(), "duplicate selector"); + debug!(target: "evm::traces", selector=%entry.key(), new=%function.signature(), "duplicate function selector"); entry.into_mut().push(function); } Entry::Vacant(entry) => { @@ -219,7 +219,7 @@ impl CallTraceDecoder { /// Adds a single error to the decoder. pub fn push_error(&mut self, error: Error) { - self.errors.errors.entry(error.name.clone()).or_default().push(error); + self.revert_decoder.push_error(error); } fn addresses<'a>( @@ -338,11 +338,7 @@ impl CallTraceDecoder { DecodedCallTrace { label, return_data: if !trace.success { - Some(decode::decode_revert( - &trace.output, - Some(&self.errors), - Some(trace.status), - )) + Some(self.revert_decoder.decode(&trace.output, Some(trace.status))) } else { None }, @@ -376,7 +372,7 @@ impl CallTraceDecoder { /// Custom decoding for cheatcode inputs. fn decode_cheatcode_inputs(&self, func: &Function, data: &[u8]) -> Option> { match func.name.as_str() { - "expectRevert" => Some(vec![decode::decode_revert(data, Some(&self.errors), None)]), + "expectRevert" => Some(vec![self.revert_decoder.decode(data, None)]), "addr" | "createWallet" | "deriveKey" | "rememberKey" => { // Redact private key in all cases Some(vec!["".to_string()]) @@ -482,7 +478,7 @@ impl CallTraceDecoder { None } else { - Some(decode::decode_revert(data, Some(&self.errors), Some(trace.status))) + Some(self.revert_decoder.decode(data, Some(trace.status))) } } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 9d641abe356ed..bde7436fcbbee 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -43,7 +43,7 @@ use foundry_config::{ }; use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, - decode, + decode::RevertDecoder, inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, }; use foundry_wallets::MultiWallet; @@ -349,7 +349,7 @@ impl ScriptArgs { if !result.success { return Err(eyre::eyre!( "script failed: {}", - decode::decode_revert(&result.returned[..], None, None) + RevertDecoder::new().decode(&result.returned[..], None) )); } @@ -367,7 +367,7 @@ impl ScriptArgs { if !result.success { return Err(eyre::eyre!( "script failed: {}", - decode::decode_revert(&result.returned[..], None, None) + RevertDecoder::new().decode(&result.returned[..], None) )); } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index a15934c7be3ef..2f981892aec53 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -12,6 +12,7 @@ use foundry_common::{ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput}; use foundry_evm::{ backend::Backend, + decode::RevertDecoder, executors::{Executor, ExecutorBuilder}, fork::CreateFork, inspectors::CheatsConfig, @@ -44,8 +45,8 @@ pub struct MultiContractRunner { pub env: revm::primitives::Env, /// The EVM spec pub evm_spec: SpecId, - /// All known errors, used for decoding reverts - pub errors: Option, + /// Revert decoder. Contains all known errors and their selectors. + pub revert_decoder: RevertDecoder, /// The address which will be used as the `from` field in all EVM calls pub sender: Option
, /// A map of contract names to absolute source file paths @@ -220,7 +221,7 @@ impl MultiContractRunner { deploy_code, self.evm_opts.initial_balance, self.sender, - self.errors.as_ref(), + &self.revert_decoder, libs, self.debug, ); @@ -354,7 +355,8 @@ impl MultiContractRunnerBuilder { } } - let errors = known_contracts.flatten_errors(); + let revert_decoder = + RevertDecoder::new().with_abis(known_contracts.values().map(|(abi, _)| abi)); Ok(MultiContractRunner { contracts: deployable_contracts, known_contracts, @@ -362,7 +364,7 @@ impl MultiContractRunnerBuilder { env, evm_spec: self.evm_spec.unwrap_or(SpecId::MERGE), sender: self.sender, - errors: Some(errors), + revert_decoder, source_paths, fork: self.fork, cheats_config: self.cheats_config.unwrap_or_default().into(), diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 686df8f44c336..493ec704d9978 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -15,7 +15,7 @@ use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_evm::{ constants::CALLER, coverage::HitMaps, - decode::decode_console_logs, + decode::{decode_console_logs, RevertDecoder}, executors::{ fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, invariant::{replay_run, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult}, @@ -43,8 +43,8 @@ pub struct ContractRunner<'a> { pub code: Bytes, /// The test contract's ABI pub contract: &'a JsonAbi, - /// All known errors, used to decode reverts - pub errors: Option<&'a JsonAbi>, + /// Revert decoder. Contains all known errors. + pub revert_decoder: &'a RevertDecoder, /// The initial balance of the test contract pub initial_balance: U256, /// The address which will be used as the `from` field in all EVM calls @@ -62,7 +62,7 @@ impl<'a> ContractRunner<'a> { code: Bytes, initial_balance: U256, sender: Option
, - errors: Option<&'a JsonAbi>, + revert_decoder: &'a RevertDecoder, predeploy_libs: &'a [Bytes], debug: bool, ) -> Self { @@ -73,7 +73,7 @@ impl<'a> ContractRunner<'a> { code, initial_balance, sender: sender.unwrap_or_default(), - errors, + revert_decoder, predeploy_libs, debug, } @@ -104,7 +104,12 @@ impl<'a> ContractRunner<'a> { let mut logs = Vec::new(); let mut traces = Vec::with_capacity(self.predeploy_libs.len()); for code in self.predeploy_libs.iter() { - match self.executor.deploy(self.sender, code.clone(), U256::ZERO, self.errors) { + match self.executor.deploy( + self.sender, + code.clone(), + U256::ZERO, + Some(self.revert_decoder), + ) { Ok(d) => { logs.extend(d.logs); traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); @@ -122,7 +127,12 @@ impl<'a> ContractRunner<'a> { self.executor.set_balance(address, self.initial_balance)?; // Deploy the test contract - match self.executor.deploy(self.sender, self.code.clone(), U256::ZERO, self.errors) { + match self.executor.deploy( + self.sender, + self.code.clone(), + U256::ZERO, + Some(self.revert_decoder), + ) { Ok(d) => { logs.extend(d.logs); traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); @@ -320,7 +330,7 @@ impl<'a> ContractRunner<'a> { func.clone(), vec![], U256::ZERO, - self.errors, + Some(self.revert_decoder), ) { Ok(CallResult { reverted, @@ -438,7 +448,7 @@ impl<'a> ContractRunner<'a> { func.clone(), vec![], U256::ZERO, - self.errors, + Some(self.revert_decoder), ) { return TestResult { status: TestStatus::Skipped, @@ -563,7 +573,7 @@ impl<'a> ContractRunner<'a> { let fuzzed_executor = FuzzedExecutor::new(self.executor.clone(), runner.clone(), self.sender, fuzz_config); let state = fuzzed_executor.build_fuzz_state(); - let result = fuzzed_executor.fuzz(func, address, should_fail, self.errors); + let result = fuzzed_executor.fuzz(func, address, should_fail, self.revert_decoder); let mut debug = Default::default(); let mut breakpoints = Default::default(); From 8cebc1f581010209eb4aaf325eef3e503d9daba6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:23:06 +0200 Subject: [PATCH 0629/1963] feat: print total duration in final test summary (#7134) * feat: print total duration in final test summary * fix: ignore regex --- crates/forge/src/result.rs | 3 ++- crates/test-utils/src/util.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 2e22adc85b219..cb53756551d72 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -126,9 +126,10 @@ impl TestOutcome { let total_skipped = self.skipped(); let total_tests = total_passed + total_failed + total_skipped; format!( - "\nRan {} test {}: {} tests passed, {} failed, {} skipped ({} total tests)", + "\nRan {} test {} in {:.2?}: {} tests passed, {} failed, {} skipped ({} total tests)", num_test_suites, suites, + self.duration(), Paint::green(total_passed), Paint::red(total_failed), Paint::yellow(total_skipped), diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index ca081bf63edc5..f5beda7785636 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1054,7 +1054,7 @@ static IGNORE_IN_FIXTURES: Lazy = Lazy::new(|| { // solc runs r"runs: \d+, μ: \d+, ~: \d+", // elapsed time - "finished in .*?s", + "(?:finished)? ?in .*?s", // file paths r"-->.*\.sol", r"Location(.|\n)*\.rs(.|\n)*Backtrace", From a170021b0e058925047a2c9697ba61f10fc0b2ce Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 16 Feb 2024 00:08:03 +0400 Subject: [PATCH 0630/1963] fix(forge): update submodules after dependency checkout (#7142) * fix(forge): update submodules after dependency checkout * update submodules after checkout * std::iter::empty --- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/install.rs | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 784ebae3dc517..9dc1eea1ba831 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -84,7 +84,7 @@ impl InitArgs { git.submodule_init()?; } else { // if not shallow, initialize and clone submodules (without fetching latest) - git.submodule_update(false, false, true, true, None::)?; + git.submodule_update(false, false, true, true, std::iter::empty::())?; } } else { // if target is not empty diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index a990c4a910048..b7690d45845c1 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -236,6 +236,15 @@ impl Installer<'_> { // checkout the tag if necessary self.git_checkout(&dep, path, false)?; + trace!("updating dependency submodules recursively"); + self.git.root(path).submodule_update( + false, + false, + false, + true, + std::iter::empty::(), + )?; + // remove git artifacts fs::remove_dir_all(path.join(".git"))?; @@ -259,6 +268,15 @@ impl Installer<'_> { // checkout the tag if necessary self.git_checkout(&dep, path, true)?; + trace!("updating dependency submodules recursively"); + self.git.root(path).submodule_update( + false, + false, + false, + true, + std::iter::empty::(), + )?; + if !self.no_commit { self.git.add(Some(path))?; } @@ -315,10 +333,7 @@ impl Installer<'_> { let path = path.strip_prefix(self.git.root).unwrap(); trace!(?dep, url, ?path, "installing git submodule"); - self.git.submodule_add(true, url, path)?; - - trace!("initializing submodule recursively"); - self.git.submodule_update(false, false, false, true, Some(path)) + self.git.submodule_add(true, url, path) } fn git_checkout(self, dep: &Dependency, path: &Path, recurse: bool) -> Result { From adca55d2945de6ffaeae342ac4b49714f8b1fdd0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 16 Feb 2024 04:59:54 +0200 Subject: [PATCH 0631/1963] chore: reduce trace output (#7148) --- crates/evm/core/src/decode.rs | 1 - crates/evm/traces/src/decoder/mod.rs | 9 +++++++-- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/src/multi_runner.rs | 13 +++++++++++-- crates/forge/src/runner.rs | 27 ++++++++++++++++++++++++--- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 2646edabedfbc..bf82c2d349208 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -19,7 +19,6 @@ pub fn decode_console_logs(logs: &[Log]) -> Vec { /// /// This function returns [None] if it is not a DSTest log or the result of a Hardhat /// `console.log`. -#[instrument(level = "debug", skip_all, fields(topics=?log.data.topics(), data=%log.data.data), ret)] pub fn decode_console_log(log: &Log) -> Option { Console::ConsoleEvents::decode_log(log, false).ok().map(|decoded| decoded.to_string()) } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 9e881488eb636..6b5aaf35deaf9 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -204,11 +204,11 @@ impl CallTraceDecoder { pub fn push_function(&mut self, function: Function) { match self.functions.entry(function.selector()) { Entry::Occupied(entry) => { - // This shouldn't happen that often + // This shouldn't happen that often. if entry.get().contains(&function) { return; } - debug!(target: "evm::traces", selector=%entry.key(), new=%function.signature(), "duplicate function selector"); + trace!(target: "evm::traces", selector=%entry.key(), new=%function.signature(), "duplicate function selector"); entry.into_mut().push(function); } Entry::Vacant(entry) => { @@ -241,6 +241,11 @@ impl CallTraceDecoder { } fn collect_identities(&mut self, identities: Vec>) { + // Skip logging if there are no identities. + if identities.is_empty() { + return; + } + trace!(target: "evm::traces", len=identities.len(), "collecting address identities"); for AddressIdentity { address, label, contract, abi, artifact_id: _ } in identities { let _span = trace_span!(target: "evm::traces", "identity", ?contract, ?label).entered(); diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index ab78bdff2ff3f..7b674138a3b95 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -149,7 +149,7 @@ impl CoverageArgs { } /// Builds the coverage report. - #[instrument(name = "prepare coverage", skip_all)] + #[instrument(name = "prepare", skip_all)] fn prepare(&self, config: &Config, output: ProjectCompileOutput) -> Result { let project_paths = config.project_paths(); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 2f981892aec53..67b96cb2326ad 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -8,7 +8,7 @@ use crate::{ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::{OptionExt, Result}; -use foundry_common::{ContractsByArtifact, TestFunctionExt}; +use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput}; use foundry_evm::{ backend::Backend, @@ -202,7 +202,6 @@ impl MultiContractRunner { }) } - #[instrument(skip_all, fields(name = %name))] #[allow(clippy::too_many_arguments)] fn run_tests( &self, @@ -214,6 +213,16 @@ impl MultiContractRunner { filter: &dyn TestFilter, test_options: TestOptions, ) -> SuiteResult { + let span = info_span!("run_tests"); + if !span.is_disabled() { + if enabled!(tracing::Level::TRACE) { + span.record("contract", name); + } else { + span.record("contract", get_contract_name(name)); + } + } + let _guard = span.enter(); + let runner = ContractRunner::new( name, executor, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 493ec704d9978..6f955f6133f18 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -313,8 +313,18 @@ impl<'a> ContractRunner<'a> { /// /// State modifications are not committed to the evm database but discarded after the call, /// similar to `eth_call`. - #[instrument(name = "test", skip_all, fields(name = %func.signature(), %should_fail))] pub fn run_test(&self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { + let span = info_span!("test", %should_fail); + if !span.is_disabled() { + let sig = &func.signature()[..]; + if enabled!(tracing::Level::TRACE) { + span.record("sig", &sig); + } else { + span.record("sig", sig.split('(').next().unwrap()); + } + } + let _guard = span.enter(); + let TestSetup { address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. } = setup; @@ -426,7 +436,7 @@ impl<'a> ContractRunner<'a> { } } - #[instrument(name = "invariant-test", skip_all)] + #[instrument(name = "invariant_test", skip_all)] pub fn run_invariant_test( &self, runner: TestRunner, @@ -555,7 +565,7 @@ impl<'a> ContractRunner<'a> { } } - #[instrument(name = "fuzz-test", skip_all, fields(name = %func.signature(), %should_fail))] + #[instrument(name = "fuzz_test", skip_all, fields(name = %func.signature(), %should_fail))] pub fn run_fuzz_test( &self, func: &Function, @@ -564,6 +574,17 @@ impl<'a> ContractRunner<'a> { setup: TestSetup, fuzz_config: FuzzConfig, ) -> TestResult { + let span = info_span!("fuzz_test", %should_fail); + if !span.is_disabled() { + let sig = &func.signature()[..]; + if enabled!(tracing::Level::TRACE) { + span.record("test", &sig); + } else { + span.record("test", sig.split('(').next().unwrap()); + } + } + let _guard = span.enter(); + let TestSetup { address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. } = setup; From 6ee3e88d2a48c7df48c85986e67f73cd2e6403d8 Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Fri, 16 Feb 2024 11:43:36 +0200 Subject: [PATCH 0632/1963] chore(deps): bump alloys (#7149) --- Cargo.lock | 59 ++++++++++++++-------------- Cargo.toml | 10 ++--- crates/anvil/src/eth/backend/fork.rs | 2 +- crates/evm/core/src/fork/backend.rs | 5 +-- crates/forge/src/runner.rs | 4 +- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21251c8ef0697..82185caa026b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-eips", "alloy-network", @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7265ac54c88a78604cea8444addfa9dfdad08d3098f153484cb4ee66fc202cc" +checksum = "13b1a44ed6b4126e4818d20c9e48176ae9d6d4fcbe6c909f8cd0bf050eb56fd8" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c5aecfe87e06da0e760840974c6e3cc19d4247be17a3172825fbbe759c8e60" +checksum = "30c6a6c5140fc762edfe55349f9ddefa821f4b7f2339cef582de911a3f1fb6d3" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -177,9 +177,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4b6fb2b432ff223d513db7f908937f63c252bee0af9b82bfd25b0a5dd1eb0d8" +checksum = "ef197eb250c64962003cb08b90b17f0882c192f4a6f2f544809d424fd7cb0e7d" dependencies = [ "alloy-rlp", "arbitrary", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-network", "alloy-primitives", @@ -322,9 +322,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0b5ab0cb07c21adf9d72e988b34e8200ce648c2bba8d009183bb1c50fb1216" +checksum = "82e92100dee7fd1e44abbe0ef6607f18758cf0ad4e483f4c65ff5c8d85428a6d" dependencies = [ "alloy-json-abi", "const-hex", @@ -342,18 +342,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd124ec0a456ec5e9dcca5b6e8b011bc723cc410d4d9a66bf032770feaeef4b" +checksum = "d146adca22a853b5aaaa98a6c78bd9d8f1d627ca7b01d170edccf45430e9b2cb" dependencies = [ "winnow", ] [[package]] name = "alloy-sol-types" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c08f62ded7ce03513bfb60ef5cad4fff5d4f67eac6feb4df80426b7b9ffb06e" +checksum = "3e7c6a8c492b1d6a4f92a8fc6a13cf39473978dd7d459d7221969ce5a73d97cd" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -365,10 +365,11 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-json-rpc", "base64 0.21.7", + "futures-util", "serde", "serde_json", "thiserror", @@ -381,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -394,7 +395,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -412,7 +413,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#098ad5657d55bbc5fe9469ede2a9ca79def738f2" +source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -7229,9 +7230,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63bef2e2c735acbc06874eca3a8506f02a3c4700e6e748afc92cc2e4220e8a03" +checksum = "e656cbcef8a77543b5accbd76f60f9e0bc4be364b0aba4263a6f313f8a355511" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index d4196400e1dcc..2c650152f1863 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,11 +170,11 @@ alloy-transport = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } -alloy-primitives = { version = "0.6.2", features = ["getrandom"] } -alloy-dyn-abi = "0.6.2" -alloy-json-abi = "0.6.2" -alloy-sol-types = "0.6.2" -syn-solidity = "0.6.0" +alloy-primitives = { version = "0.6.3", features = ["getrandom"] } +alloy-dyn-abi = "0.6.3" +alloy-json-abi = "0.6.3" +alloy-sol-types = "0.6.3" +syn-solidity = "0.6.3" alloy-chains = "0.1" alloy-rlp = "0.3.3" diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index baf177e25b629..033039bfa49c3 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -268,7 +268,7 @@ impl ClientFork { let block_id = BlockId::Number(blocknumber.into()); - let code = self.provider().get_code_at(address, block_id).await?; + let code = self.provider().get_code_at(address, Some(block_id)).await?; let mut storage = self.storage_write(); storage.code_at.insert((address, blocknumber), code.clone().0.into()); diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 4223e2dea7722..3a87583b6da4f 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -5,7 +5,7 @@ use crate::{ }; use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; use alloy_providers::provider::TempProvider; -use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag, Transaction}; +use alloy_rpc_types::{Block, BlockId, Transaction}; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; use futures::{ @@ -196,8 +196,7 @@ where let fut = Box::pin(async move { let balance = provider.get_balance(address, block_id); let nonce = provider.get_transaction_count(address, block_id); - let code = - provider.get_code_at(address, block_id.unwrap_or(BlockNumberOrTag::Latest.into())); + let code = provider.get_code_at(address, block_id); let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); (resp, address) }); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 6f955f6133f18..912fbb895d20d 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -318,7 +318,7 @@ impl<'a> ContractRunner<'a> { if !span.is_disabled() { let sig = &func.signature()[..]; if enabled!(tracing::Level::TRACE) { - span.record("sig", &sig); + span.record("sig", sig); } else { span.record("sig", sig.split('(').next().unwrap()); } @@ -578,7 +578,7 @@ impl<'a> ContractRunner<'a> { if !span.is_disabled() { let sig = &func.signature()[..]; if enabled!(tracing::Level::TRACE) { - span.record("test", &sig); + span.record("test", sig); } else { span.record("test", sig.split('(').next().unwrap()); } From 4f00ec6fa1ec0d2787a9d2c4925bf6fc375b58ca Mon Sep 17 00:00:00 2001 From: Enrique Date: Fri, 16 Feb 2024 10:44:11 -0400 Subject: [PATCH 0633/1963] chore(common): remove unused code (#7153) --- Cargo.lock | 1 - crates/common/Cargo.toml | 1 - crates/common/src/contracts.rs | 76 -------- crates/common/src/units.rs | 329 --------------------------------- 4 files changed, 407 deletions(-) delete mode 100644 crates/common/src/units.rs diff --git a/Cargo.lock b/Cargo.lock index 82185caa026b0..f950b24c341f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3073,7 +3073,6 @@ dependencies = [ "once_cell", "pretty_assertions", "rand 0.8.5", - "regex", "reqwest", "semver 1.0.21", "serde", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 530d75d8ef707..49be9df68407f 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -46,7 +46,6 @@ globset = "0.4" hex.workspace = true once_cell = "1" rand.workspace = true -regex = "1" reqwest = { version = "0.11", default-features = false } semver = "1" serde_json.workspace = true diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 72d101852dfa4..ed6c6ae20f71f 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -6,8 +6,6 @@ use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecodeSome}, ArtifactId, ProjectPathsConfig, }; -use once_cell::sync::Lazy; -use regex::Regex; use std::{ collections::BTreeMap, fmt, @@ -204,40 +202,6 @@ pub fn get_artifact_path(paths: &ProjectPathsConfig, path: &str) -> PathBuf { } } -/// Given the transaction data tries to identify the constructor arguments -/// The constructor data is encoded as: Constructor Code + Contract Code + Constructor arguments -/// decoding the arguments here with only the transaction data is not trivial here, we try to find -/// the beginning of the constructor arguments by finding the length of the code, which is PUSH op -/// code which holds the code size and the code starts after the invalid op code (0xfe) -/// -/// finding the `0xfe` (invalid opcode) in the data which should mark the beginning of constructor -/// arguments -pub fn find_constructor_args(data: &[u8]) -> Option<&[u8]> { - // ref - static CONSTRUCTOR_CODE_RE: Lazy = Lazy::new(|| { - Regex::new(r"(?m)(?:5b)?(?:60([a-z0-9]{2})|61([a-z0-9_]{4})|62([a-z0-9_]{6}))80(?:60([a-z0-9]{2})|61([a-z0-9_]{4})|62([a-z0-9_]{6}))(6000396000f3fe)").unwrap() - }); - let s = hex::encode(data); - - // we're only interested in the last occurrence which skips additional CREATE inside the - // constructor itself - let caps = CONSTRUCTOR_CODE_RE.captures_iter(&s).last()?; - - let contract_len = u64::from_str_radix( - caps.get(1).or_else(|| caps.get(2)).or_else(|| caps.get(3))?.as_str(), - 16, - ) - .unwrap(); - - // the end position of the constructor code, we use this instead of the contract offset , since - // there could be multiple CREATE inside the data we need to divide by 2 for hex conversion - let constructor_end = (caps.get(7)?.end() / 2) as u64; - let start = (contract_len + constructor_end) as usize; - let args = &data[start..]; - - Some(args) -} - /// Helper function to convert CompactContractBytecode ~> ContractBytecodeSome pub fn compact_to_contract( contract: CompactContractBytecode, @@ -255,46 +219,6 @@ pub fn compact_to_contract( #[cfg(test)] mod tests { use super::*; - use alloy_dyn_abi::DynSolType; - - // - #[test] - fn test_find_constructor_args() { - let code = "6080604052348015600f57600080fd5b50604051610121380380610121833981016040819052602c91606e565b600080546001600160a01b0319166001600160a01b0396909616959095179094556001929092556002556003556004805460ff191691151591909117905560d4565b600080600080600060a08688031215608557600080fd5b85516001600160a01b0381168114609b57600080fd5b809550506020860151935060408601519250606086015191506080860151801515811460c657600080fd5b809150509295509295909350565b603f806100e26000396000f3fe6080604052600080fdfea264697066735822122089f2c61beace50d105ec1b6a56a1204301b5595e850e7576f6f3aa8e76f12d0b64736f6c6343000810003300000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea720000000000000000000000000000000000000000000000000000000100000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60000000000000000000000000000000000000000000000000000000000000001"; - - let code = hex::decode(code).unwrap(); - - let args = find_constructor_args(&code).unwrap(); - - let params = DynSolType::Tuple(vec![ - DynSolType::Address, - DynSolType::Uint(256), - DynSolType::Int(256), - DynSolType::FixedBytes(32), - DynSolType::Bool, - ]); - let _decoded = params.abi_decode_params(args).unwrap(); - } - - #[test] - fn test_find_constructor_args_nested_deploy() { - let code = "608060405234801561001057600080fd5b5060405161066d38038061066d83398101604081905261002f9161014a565b868686868686866040516100429061007c565b610052979695949392919061022f565b604051809103906000f08015801561006e573d6000803e3d6000fd5b50505050505050505061028a565b610396806102d783390190565b634e487b7160e01b600052604160045260246000fd5b60005b838110156100ba5781810151838201526020016100a2565b50506000910152565b600082601f8301126100d457600080fd5b81516001600160401b03808211156100ee576100ee610089565b604051601f8301601f19908116603f0116810190828211818310171561011657610116610089565b8160405283815286602085880101111561012f57600080fd5b61014084602083016020890161009f565b9695505050505050565b600080600080600080600060e0888a03121561016557600080fd5b87516001600160a01b038116811461017c57600080fd5b80975050602088015195506040880151945060608801519350608088015180151581146101a857600080fd5b60a08901519093506001600160401b03808211156101c557600080fd5b6101d18b838c016100c3565b935060c08a01519150808211156101e757600080fd5b506101f48a828b016100c3565b91505092959891949750929550565b6000815180845261021b81602086016020860161009f565b601f01601f19169290920160200192915050565b60018060a01b0388168152866020820152856040820152846060820152831515608082015260e060a0820152600061026a60e0830185610203565b82810360c084015261027c8185610203565b9a9950505050505050505050565b603f806102986000396000f3fe6080604052600080fdfea264697066735822122072aeef1567521008007b956bd7c6e9101a9b49fbce1f45210fa929c79d28bd9364736f6c63430008110033608060405234801561001057600080fd5b5060405161039638038061039683398101604081905261002f91610148565b600080546001600160a01b0319166001600160a01b0389161790556001869055600285905560038490556004805460ff19168415151790556005610073838261028a565b506006610080828261028a565b5050505050505050610349565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126100b457600080fd5b81516001600160401b03808211156100ce576100ce61008d565b604051601f8301601f19908116603f011681019082821181831017156100f6576100f661008d565b8160405283815260209250868385880101111561011257600080fd5b600091505b838210156101345785820183015181830184015290820190610117565b600093810190920192909252949350505050565b600080600080600080600060e0888a03121561016357600080fd5b87516001600160a01b038116811461017a57600080fd5b80975050602088015195506040880151945060608801519350608088015180151581146101a657600080fd5b60a08901519093506001600160401b03808211156101c357600080fd5b6101cf8b838c016100a3565b935060c08a01519150808211156101e557600080fd5b506101f28a828b016100a3565b91505092959891949750929550565b600181811c9082168061021557607f821691505b60208210810361023557634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561028557600081815260208120601f850160051c810160208610156102625750805b601f850160051c820191505b818110156102815782815560010161026e565b5050505b505050565b81516001600160401b038111156102a3576102a361008d565b6102b7816102b18454610201565b8461023b565b602080601f8311600181146102ec57600084156102d45750858301515b600019600386901b1c1916600185901b178555610281565b600085815260208120601f198616915b8281101561031b578886015182559484019460019091019084016102fc565b50858210156103395787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b603f806103576000396000f3fe6080604052600080fdfea2646970667358221220a468ac913d3ecf191b6559ae7dca58e05ba048434318f393b86640b25cbbf1ed64736f6c6343000811003300000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea720000000000000000000000000000000000000000000000000000000100000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000066162636465660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000"; - - let code = hex::decode(code).unwrap(); - - let args = find_constructor_args(&code).unwrap(); - - let params = DynSolType::Tuple(vec![ - DynSolType::Address, - DynSolType::Uint(256), - DynSolType::Int(256), - DynSolType::FixedBytes(32), - DynSolType::Bool, - DynSolType::Bytes, - DynSolType::String, - ]); - let _decoded = params.abi_decode_params(args).unwrap(); - } #[test] fn bytecode_diffing() { diff --git a/crates/common/src/units.rs b/crates/common/src/units.rs deleted file mode 100644 index 9dc40e6ce8a91..0000000000000 --- a/crates/common/src/units.rs +++ /dev/null @@ -1,329 +0,0 @@ -//! Unit conversion utilities. - -use alloy_primitives::{Address, ParseSignedError, I256, U256}; -use std::{fmt, str::FromStr}; -use thiserror::Error; - -/// I256 overflows for numbers wider than 77 units. -const OVERFLOW_I256_UNITS: usize = 77; -/// U256 overflows for numbers wider than 78 units. -const OVERFLOW_U256_UNITS: usize = 78; - -/// Common Ethereum unit types. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum Units { - /// Wei is equivalent to 1 wei. - Wei, - /// Kwei is equivalent to 1e3 wei. - Kwei, - /// Mwei is equivalent to 1e6 wei. - Mwei, - /// Gwei is equivalent to 1e9 wei. - Gwei, - /// Twei is equivalent to 1e12 wei. - Twei, - /// Pwei is equivalent to 1e15 wei. - Pwei, - /// Ether is equivalent to 1e18 wei. - Ether, - /// Other less frequent unit sizes, equivalent to 1e{0} wei. - Other(u32), -} - -impl fmt::Display for Units { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad(self.as_num().to_string().as_str()) - } -} - -impl TryFrom for Units { - type Error = ConversionError; - - fn try_from(value: u32) -> Result { - Ok(Units::Other(value)) - } -} - -impl TryFrom for Units { - type Error = ConversionError; - - fn try_from(value: i32) -> Result { - Ok(Units::Other(value as u32)) - } -} - -impl TryFrom for Units { - type Error = ConversionError; - - fn try_from(value: usize) -> Result { - Ok(Units::Other(value as u32)) - } -} - -impl TryFrom for Units { - type Error = ConversionError; - - fn try_from(value: String) -> Result { - Self::from_str(&value) - } -} - -impl<'a> TryFrom<&'a String> for Units { - type Error = ConversionError; - - fn try_from(value: &'a String) -> Result { - Self::from_str(value) - } -} - -impl TryFrom<&str> for Units { - type Error = ConversionError; - - fn try_from(value: &str) -> Result { - Self::from_str(value) - } -} - -impl FromStr for Units { - type Err = ConversionError; - - fn from_str(s: &str) -> Result { - Ok(match s.to_lowercase().as_str() { - "eth" | "ether" => Units::Ether, - "pwei" | "milli" | "milliether" | "finney" => Units::Pwei, - "twei" | "micro" | "microether" | "szabo" => Units::Twei, - "gwei" | "nano" | "nanoether" | "shannon" => Units::Gwei, - "mwei" | "pico" | "picoether" | "lovelace" => Units::Mwei, - "kwei" | "femto" | "femtoether" | "babbage" => Units::Kwei, - "wei" => Units::Wei, - _ => return Err(ConversionError::UnrecognizedUnits(s.to_string())), - }) - } -} - -impl From for u32 { - fn from(units: Units) -> Self { - units.as_num() - } -} - -impl From for i32 { - fn from(units: Units) -> Self { - units.as_num() as i32 - } -} - -impl From for usize { - fn from(units: Units) -> Self { - units.as_num() as usize - } -} - -impl Units { - /// Converts the ethereum unit to its numeric representation. - pub fn as_num(&self) -> u32 { - match self { - Units::Wei => 0, - Units::Kwei => 3, - Units::Mwei => 6, - Units::Gwei => 9, - Units::Twei => 12, - Units::Pwei => 15, - Units::Ether => 18, - Units::Other(inner) => *inner, - } - } -} - -/// This enum holds the numeric types that a possible to be returned by `parse_units` and -/// that are taken by `format_units`. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum ParseUnits { - /// Unsigned 256-bit integer. - U256(U256), - /// Signed 256-bit integer. - I256(I256), -} - -impl From for U256 { - fn from(n: ParseUnits) -> Self { - match n { - ParseUnits::U256(n) => n, - ParseUnits::I256(n) => n.into_raw(), - } - } -} - -impl From for I256 { - fn from(n: ParseUnits) -> Self { - match n { - ParseUnits::I256(n) => n, - ParseUnits::U256(n) => I256::from_raw(n), - } - } -} - -impl From> for ParseUnits { - fn from(n: alloy_primitives::Signed<256, 4>) -> Self { - Self::I256(n) - } -} - -impl fmt::Display for ParseUnits { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - ParseUnits::U256(val) => val.fmt(f), - ParseUnits::I256(val) => val.fmt(f), - } - } -} - -macro_rules! construct_format_units_from { - ($( $t:ty[$convert:ident] ),*) => { - $( - impl From<$t> for ParseUnits { - fn from(num: $t) -> Self { - Self::$convert(U256::from(num)) - } - } - )* - } -} - -macro_rules! construct_signed_format_units_from { - ($( $t:ty[$convert:ident] ),*) => { - $( - impl From<$t> for ParseUnits { - fn from(num: $t) -> Self { - Self::$convert(I256::from_raw(U256::from(num))) - } - } - )* - } -} - -// Generate the From code for the given numeric types below. -construct_format_units_from! { - u8[U256], u16[U256], u32[U256], u64[U256], u128[U256], U256[U256], usize[U256] -} - -construct_signed_format_units_from! { - i8[I256], i16[I256], i32[I256], i64[I256], i128[I256], isize[I256] -} - -/// Handles all possible conversion errors. -#[derive(Debug, Error)] -pub enum ConversionError { - /// The unit is unrecognized. - #[error("Unknown units: {0}")] - UnrecognizedUnits(String), - /// The provided hex string is invalid (too long). - #[error("bytes32 strings must not exceed 32 bytes in length")] - TextTooLong, - /// The provided string cannot be converted from Utf8. - #[error(transparent)] - Utf8Error(#[from] std::str::Utf8Error), - /// Invalid float. - #[error(transparent)] - InvalidFloat(#[from] std::num::ParseFloatError), - /// Could not convert from decimal string. - #[error("Invalid decimal string: {0}")] - FromDecStrError(String), - /// Overflowed while parsing. - #[error("Overflow parsing string")] - ParseOverflow, - /// Could not convert from signed decimal string. - #[error("Parse Signed Error")] - ParseI256Error(#[from] ParseSignedError), - /// Invalid checksum. - #[error("Invalid address checksum")] - InvalidAddressChecksum, - /// Invalid hex. - #[error(transparent)] - FromHexError(
::Err), -} - -/// Divides the provided amount with 10^{units} provided. -pub fn format_units(amount: T, units: K) -> Result -where - T: Into, - K: TryInto, -{ - let units: usize = units.try_into()?.into(); - let amount = amount.into(); - - match amount { - // 2**256 ~= 1.16e77 - ParseUnits::U256(_) if units >= OVERFLOW_U256_UNITS => { - return Err(ConversionError::ParseOverflow) - } - // 2**255 ~= 5.79e76 - ParseUnits::I256(_) if units >= OVERFLOW_I256_UNITS => { - return Err(ConversionError::ParseOverflow) - } - _ => {} - }; - let exp10 = U256::pow(U256::from(10), U256::from(units)); - - // `decimals` are formatted twice because U256 does not support alignment (`:0>width`). - match amount { - ParseUnits::U256(amount) => { - let integer = amount / exp10; - let decimals = (amount % exp10).to_string(); - Ok(format!("{integer}.{decimals:0>units$}")) - } - ParseUnits::I256(amount) => { - let exp10 = I256::from_raw(exp10); - let sign = if amount.is_negative() { "-" } else { "" }; - let integer = (amount / exp10).twos_complement(); - let decimals = ((amount % exp10).twos_complement()).to_string(); - Ok(format!("{sign}{integer}.{decimals:0>units$}")) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use Units::*; - - #[test] - fn test_units() { - assert_eq!(Wei.as_num(), 0); - assert_eq!(Kwei.as_num(), 3); - assert_eq!(Mwei.as_num(), 6); - assert_eq!(Gwei.as_num(), 9); - assert_eq!(Twei.as_num(), 12); - assert_eq!(Pwei.as_num(), 15); - assert_eq!(Ether.as_num(), 18); - assert_eq!(Other(10).as_num(), 10); - assert_eq!(Other(20).as_num(), 20); - } - - #[test] - fn test_into() { - assert_eq!(Units::try_from("wei").unwrap(), Wei); - assert_eq!(Units::try_from("kwei").unwrap(), Kwei); - assert_eq!(Units::try_from("mwei").unwrap(), Mwei); - assert_eq!(Units::try_from("gwei").unwrap(), Gwei); - assert_eq!(Units::try_from("twei").unwrap(), Twei); - assert_eq!(Units::try_from("pwei").unwrap(), Pwei); - assert_eq!(Units::try_from("ether").unwrap(), Ether); - - assert_eq!(Units::try_from("wei".to_string()).unwrap(), Wei); - assert_eq!(Units::try_from("kwei".to_string()).unwrap(), Kwei); - assert_eq!(Units::try_from("mwei".to_string()).unwrap(), Mwei); - assert_eq!(Units::try_from("gwei".to_string()).unwrap(), Gwei); - assert_eq!(Units::try_from("twei".to_string()).unwrap(), Twei); - assert_eq!(Units::try_from("pwei".to_string()).unwrap(), Pwei); - assert_eq!(Units::try_from("ether".to_string()).unwrap(), Ether); - - assert_eq!(Units::try_from(&"wei".to_string()).unwrap(), Wei); - assert_eq!(Units::try_from(&"kwei".to_string()).unwrap(), Kwei); - assert_eq!(Units::try_from(&"mwei".to_string()).unwrap(), Mwei); - assert_eq!(Units::try_from(&"gwei".to_string()).unwrap(), Gwei); - assert_eq!(Units::try_from(&"twei".to_string()).unwrap(), Twei); - assert_eq!(Units::try_from(&"pwei".to_string()).unwrap(), Pwei); - assert_eq!(Units::try_from(&"ether".to_string()).unwrap(), Ether); - } -} From ee4153245bf3915c8fa24847c4184fbf307de65e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 17 Feb 2024 08:44:56 +0100 Subject: [PATCH 0634/1963] chore: bump alloy rpc (#7155) --- Cargo.lock | 30 ++++++++++++------------- crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/backend/fork.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f950b24c341f2..1268179014445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-network", "alloy-primitives", @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -413,7 +413,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#e127fed9118b53c9f6776ce7aed412788827e9a5" +source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" dependencies = [ "alloy-pubsub", "alloy-transport", diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index e7bec82bfcbf9..5f471e32f1148 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1081,7 +1081,7 @@ latest block number: {latest_block}" retries: self.fork_request_retries, backoff: self.fork_retry_backoff, compute_units_per_second: self.compute_units_per_second, - total_difficulty: block.total_difficulty.unwrap_or_default(), + total_difficulty: block.header.total_difficulty.unwrap_or_default(), }; (ForkedDatabase::new(backend, block_chain_db), config) diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 033039bfa49c3..94408756f64da 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -77,7 +77,7 @@ impl ClientFork { let block_hash = block.header.hash.ok_or(BlockchainError::BlockNotFound)?; let timestamp = block.header.timestamp.to::(); let base_fee = block.header.base_fee_per_gas; - let total_difficulty = block.total_difficulty.unwrap_or_default(); + let total_difficulty = block.header.total_difficulty.unwrap_or_default(); self.config.write().update_block( block.header.number.ok_or(BlockchainError::BlockNotFound)?.to::(), diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 43b1f2aca39e2..3d8f1773e86af 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1566,7 +1566,6 @@ impl Backend { } = header; AlloyBlock { - total_difficulty: Some(self.total_difficulty()), header: AlloyHeader { hash: Some(hash), parent_hash, @@ -1581,6 +1580,7 @@ impl Backend { extra_data: extra_data.0.into(), logs_bloom, timestamp: U256::from(timestamp), + total_difficulty: Some(self.total_difficulty()), difficulty, mix_hash: Some(mix_hash), nonce: Some(B64::from(nonce)), From 9e24233a307374b3cf8181a2fa384fadad47db4c Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Sat, 17 Feb 2024 09:50:09 +0200 Subject: [PATCH 0635/1963] feat(cast): abi-encode-packed (#7150) --- crates/cast/bin/main.rs | 8 ++++++-- crates/cast/bin/opts.rs | 4 ++++ crates/cast/src/lib.rs | 32 ++++++++++++++++++++++++++++++++ crates/common/src/abi.rs | 17 +++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index c4ee0e56388eb..93c686cb31e01 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -160,8 +160,12 @@ async fn main() -> Result<()> { let tokens = format_tokens(&tokens); tokens.for_each(|t| println!("{t}")); } - CastSubcommand::AbiEncode { sig, args } => { - println!("{}", SimpleCast::abi_encode(&sig, &args)?); + CastSubcommand::AbiEncode { sig, packed, args } => { + if !packed { + println!("{}", SimpleCast::abi_encode(&sig, &args)?); + } else { + println!("{}", SimpleCast::abi_encode_packed(&sig, &args)?); + } } CastSubcommand::CalldataDecode { sig, calldata } => { let tokens = SimpleCast::calldata_decode(&sig, &calldata, true)?; diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 2f09c2534830d..9cce3349474fa 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -491,6 +491,10 @@ pub enum CastSubcommand { /// The function signature. sig: String, + /// Whether to use packed encoding. + #[clap(long)] + packed: bool, + /// The arguments of the function. #[clap(allow_hyphen_values = true)] args: Vec, diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 0c941913cf14c..7d701cb5095c9 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -36,6 +36,7 @@ use std::{ use tokio::signal::ctrl_c; use tx::{TxBuilderOutput, TxBuilderPeekOutput}; +use foundry_common::abi::encode_function_args_packed; pub use foundry_evm::*; pub use rusoto_core::{ credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, @@ -1551,6 +1552,37 @@ impl SimpleCast { Ok(format!("0x{encoded}")) } + /// Performs packed ABI encoding based off of the function signature or tuple. + /// + /// # Examplez + /// + /// ``` + /// use cast::SimpleCast as Cast; + /// + /// assert_eq!( + /// "0x0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000012c00000000000000c8", + /// Cast::abi_encode_packed("(uint128[] a, uint64 b)", &["[100, 300]", "200"]).unwrap().as_str() + /// ); + /// + /// assert_eq!( + /// "0x8dbd1b711dc621e1404633da156fcc779e1c6f3e68656c6c6f20776f726c64", + /// Cast::abi_encode_packed("foo(address a, string b)", &["0x8dbd1b711dc621e1404633da156fcc779e1c6f3e", "hello world"]).unwrap().as_str() + /// ); + /// # Ok::<_, eyre::Report>(()) + /// ``` + pub fn abi_encode_packed(sig: &str, args: &[impl AsRef]) -> Result { + // If the signature is a tuple, we need to prefix it to make it a function + let sig = + if sig.trim_start().starts_with('(') { format!("foo{sig}") } else { sig.to_string() }; + + let func = get_func(sig.as_str())?; + let encoded = match encode_function_args_packed(&func, args) { + Ok(res) => hex::encode(res), + Err(e) => eyre::bail!("Could not ABI encode the function and arguments. Did you pass in the right types?\nError\n{}", e), + }; + Ok(format!("0x{encoded}")) + } + /// Performs ABI encoding to produce the hexadecimal calldata with the given arguments. /// /// # Example diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 011f51cb807c0..fc3e8083e4a3f 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -21,6 +21,23 @@ where func.abi_encode_input(params.as_slice()).map_err(Into::into) } +/// Given a function and a vector of string arguments, it proceeds to convert the args to alloy +/// [DynSolValue]s and encode them using the packed encoding. +pub fn encode_function_args_packed(func: &Function, args: I) -> Result> +where + I: IntoIterator, + S: AsRef, +{ + let params: Vec> = std::iter::zip(&func.inputs, args) + .map(|(input, arg)| coerce_value(&input.selector_type(), arg.as_ref())) + .collect::>>()? + .into_iter() + .map(|v| v.abi_encode_packed()) + .collect(); + + Ok(params.concat()) +} + /// Decodes the calldata of the function pub fn abi_decode_calldata( sig: &str, From 28dc37f62da4b6cccb37ae25244512d7c83759e7 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 17 Feb 2024 11:50:29 +0400 Subject: [PATCH 0636/1963] fix(cheatcodes): fix assertApproxEqRel (#7145) * fix(cheatcodes): fix assertApproxEqRel * fix * forgefmt --- crates/cheatcodes/src/test/assert.rs | 55 ++++++++++++++++++++++------ testdata/cheats/Assert.t.sol | 8 +++- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index 70b2d5971a457..d727626ca48cb 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -99,17 +99,32 @@ fn format_delta_percent(delta: &U256) -> String { format!("{}%", format_units_uint(delta, &(EQ_REL_DELTA_RESOLUTION - U256::from(2)))) } +#[derive(Debug)] +enum EqRelDelta { + Defined(U256), + Undefined, +} + +impl Display for EqRelDelta { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Defined(delta) => write!(f, "{}", format_delta_percent(delta)), + Self::Undefined => write!(f, "undefined"), + } + } +} + #[derive(thiserror::Error, Debug)] #[error( "{left} !~= {right} (max delta: {}, real delta: {})", format_delta_percent(max_delta), - format_delta_percent(real_delta) + real_delta )] struct EqRelAssertionFailure { left: T, right: T, max_delta: U256, - real_delta: U256, + real_delta: EqRelDelta, } #[derive(thiserror::Error, Debug)] @@ -128,7 +143,7 @@ impl EqRelAssertionError { format_units_uint(&f.left, decimals), format_units_uint(&f.right, decimals), format_delta_percent(&f.max_delta), - format_delta_percent(&f.real_delta), + &f.real_delta, ), Self::Overflow => self.to_string(), } @@ -143,7 +158,7 @@ impl EqRelAssertionError { format_units_int(&f.left, decimals), format_units_int(&f.right, decimals), format_delta_percent(&f.max_delta), - format_delta_percent(&f.real_delta), + &f.real_delta, ), Self::Overflow => self.to_string(), } @@ -1107,11 +1122,19 @@ fn uint_assert_approx_eq_rel( right: U256, max_delta: U256, ) -> Result, EqRelAssertionError> { + if right.is_zero() && !left.is_zero() { + return Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { + left, + right, + max_delta, + real_delta: EqRelDelta::Undefined, + }))) + } + let delta = get_delta_uint(left, right) .checked_mul(U256::pow(U256::from(10), EQ_REL_DELTA_RESOLUTION)) - .ok_or(EqRelAssertionError::Overflow)? - .checked_div(right) - .ok_or(EqRelAssertionError::Overflow)?; + .ok_or(EqRelAssertionError::Overflow)? / + right; if delta <= max_delta { Ok(Default::default()) @@ -1120,7 +1143,7 @@ fn uint_assert_approx_eq_rel( left, right, max_delta, - real_delta: delta, + real_delta: EqRelDelta::Defined(delta), }))) } } @@ -1130,12 +1153,20 @@ fn int_assert_approx_eq_rel( right: I256, max_delta: U256, ) -> Result, EqRelAssertionError> { + if right.is_zero() && !left.is_zero() { + return Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { + left, + right, + max_delta, + real_delta: EqRelDelta::Undefined, + }))) + } + let (_, abs_right) = right.into_sign_and_abs(); let delta = get_delta_int(left, right) .checked_mul(U256::pow(U256::from(10), EQ_REL_DELTA_RESOLUTION)) - .ok_or(EqRelAssertionError::Overflow)? - .checked_div(abs_right) - .ok_or(EqRelAssertionError::Overflow)?; + .ok_or(EqRelAssertionError::Overflow)? / + abs_right; if delta <= max_delta { Ok(Default::default()) @@ -1144,7 +1175,7 @@ fn int_assert_approx_eq_rel( left, right, max_delta, - real_delta: delta, + real_delta: EqRelDelta::Defined(delta), }))) } } diff --git a/testdata/cheats/Assert.t.sol b/testdata/cheats/Assert.t.sol index 680300dde988d..10015a8502c68 100644 --- a/testdata/cheats/Assert.t.sol +++ b/testdata/cheats/Assert.t.sol @@ -811,13 +811,17 @@ contract AssertionsTest is DSTest { vm._expectCheatcodeRevert(bytes("assertion failed: overflow in delta calculation")); vm.assertApproxEqRel(type(int256).min, type(int256).max, 0); - vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": overflow in delta calculation"))); + vm._expectCheatcodeRevert( + bytes(string.concat(errorMessage, ": 1 !~= 0 (max delta: 0.0000000000000000%, real delta: undefined)")) + ); vm.assertApproxEqRel(int256(1), int256(0), 0, errorMessage); vm._expectCheatcodeRevert(bytes(string.concat(errorMessage, ": overflow in delta calculation"))); vm.assertApproxEqRel(uint256(0), type(uint256).max, 0, errorMessage); - vm._expectCheatcodeRevert(bytes("assertion failed: overflow in delta calculation")); + vm._expectCheatcodeRevert( + bytes("assertion failed: 1 !~= 0 (max delta: 0.0000000000000000%, real delta: undefined)") + ); vm.assertApproxEqRel(uint256(1), uint256(0), uint256(0)); } } From c631cf37928c4292c3b73a84f337a86281a8db78 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 17 Feb 2024 19:20:28 +0400 Subject: [PATCH 0637/1963] fix(providers): remove locks on requests (#7156) * fix(providers): remove locks on requests * fmt * refactor * nits * fmt --- .../common/src/provider/runtime_transport.rs | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index eefb740e9e479..eab2addb81dda 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -211,19 +211,33 @@ impl RuntimeTransport { pub fn request(&self, req: RequestPacket) -> TransportFut<'static> { let this = self.clone(); Box::pin(async move { - if this.inner.read().await.is_none() { - let mut inner = this.inner.write().await; - *inner = Some(this.connect().await.map_err(TransportErrorKind::custom)?) + let mut inner = this.inner.read().await; + if inner.is_none() { + drop(inner); + { + let mut inner_mut = this.inner.write().await; + if inner_mut.is_none() { + *inner_mut = + Some(this.connect().await.map_err(TransportErrorKind::custom)?); + } + } + inner = this.inner.read().await; } - let mut inner = this.inner.write().await; // SAFETY: We just checked that the inner transport exists. - let inner_mut = inner.as_mut().expect("We should have an inner transport."); - - match inner_mut { - InnerTransport::Http(http) => http.call(req), - InnerTransport::Ws(ws) => ws.call(req), - InnerTransport::Ipc(ipc) => ipc.call(req), + match inner.as_ref().expect("must've been initialized") { + InnerTransport::Http(http) => { + let mut http = http; + http.call(req) + } + InnerTransport::Ws(ws) => { + let mut ws = ws; + ws.call(req) + } + InnerTransport::Ipc(ipc) => { + let mut ipc = ipc; + ipc.call(req) + } } .await }) From e32ebe143d042f5bdbc81ded86cae090c8c737c6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 18 Feb 2024 13:14:57 +0100 Subject: [PATCH 0638/1963] chore(deps): weekly `cargo update` (#7158) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating aes v0.8.3 -> v0.8.4 Updating ahash v0.8.7 -> v0.8.8 Updating alloy-chains v0.1.11 -> v0.1.12 Updating bumpalo v3.14.0 -> v3.15.0 Updating chrono v0.4.33 -> v0.4.34 Updating clap v4.5.0 -> v4.5.1 Updating clap_builder v4.5.0 -> v4.5.1 Updating clap_complete v4.5.0 -> v4.5.1 Updating crc32fast v1.3.2 -> v1.4.0 Updating env_logger v0.11.1 -> v0.11.2 Updating hermit-abi v0.3.5 -> v0.3.6 Updating indexmap v2.2.2 -> v2.2.3 Updating normpath v1.1.1 -> v1.2.0 Updating num_threads v0.1.6 -> v0.1.7 Updating pkg-config v0.3.29 -> v0.3.30 Updating ring v0.17.7 -> v0.17.8 Updating syn v2.0.48 -> v2.0.49 Updating thiserror v1.0.56 -> v1.0.57 Updating thiserror-impl v1.0.56 -> v1.0.57 Updating toml_edit v0.22.4 -> v0.22.6 Removing winnow v0.5.39 Adding winnow v0.5.40 (latest: v0.6.1) Adding winnow v0.6.1 note: pass `--verbose` to see 177 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 194 ++++++++++++++++++++++++++++------------------------- 1 file changed, 102 insertions(+), 92 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1268179014445..fde0c6326e50f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,9 +29,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aes" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" dependencies = [ "cfg-if", "once_cell", @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45625825df98039a6dced71fedca82e69a8a0177453e21faeed47b9a6f16a178" +checksum = "146dc3f33a9e282751a62ddd6687292c504605cc285a49500541e5d1e5b7617b" dependencies = [ "num_enum", "serde", @@ -116,7 +116,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -257,7 +257,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -335,7 +335,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.48", + "syn 2.0.49", "syn-solidity", "tiny-keccak", ] @@ -346,7 +346,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d146adca22a853b5aaaa98a6c78bd9d8f1d627ca7b01d170edccf45430e9b2cb" dependencies = [ - "winnow", + "winnow 0.5.40", ] [[package]] @@ -831,7 +831,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -848,7 +848,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -901,7 +901,7 @@ checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -1141,9 +1141,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" [[package]] name = "byte-slice-cast" @@ -1362,9 +1362,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1412,9 +1412,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", "clap_derive", @@ -1422,9 +1422,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstream", "anstyle", @@ -1437,9 +1437,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299353be8209bd133b049bf1c63582d184a8b39fd9c04f15fe65f50f88bdfe6c" +checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c" dependencies = [ "clap", ] @@ -1463,7 +1463,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -1732,9 +1732,9 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -1951,7 +1951,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2193,7 +2193,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2208,9 +2208,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e7cf40684ae96ade6232ed84582f40ce0a66efcd43a5117aef610534f8e0b8" +checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" dependencies = [ "anstream", "anstyle", @@ -2401,7 +2401,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.48", + "syn 2.0.49", "toml 0.8.10", "walkdir", ] @@ -2418,7 +2418,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -2443,7 +2443,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.48", + "syn 2.0.49", "tempfile", "thiserror", "tiny-keccak", @@ -2697,7 +2697,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3314,7 +3314,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3479,7 +3479,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -3905,7 +3905,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.8", "allocator-api2", "serde", ] @@ -3927,9 +3927,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" [[package]] name = "hex" @@ -4225,9 +4225,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -4737,7 +4737,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -4858,11 +4858,11 @@ checksum = "f5438dd2b2ff4c6df6e1ce22d825ed2fa93ee2922235cc45186991717f0a892d" [[package]] name = "normpath" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec60c60a693226186f5d6edf073232bfb6464ed97eb22cf3b01c1e8198fd97f5" +checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -5003,14 +5003,14 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] name = "num_threads" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" dependencies = [ "libc", ] @@ -5107,7 +5107,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5317,7 +5317,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5375,7 +5375,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5478,7 +5478,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5516,7 +5516,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5554,9 +5554,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" @@ -5627,7 +5627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -5722,7 +5722,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "version_check", "yansi 1.0.0-rc.1", ] @@ -6180,16 +6180,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom 0.2.12", "libc", "spin 0.9.8", "untrusted 0.9.0", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -6430,7 +6431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", - "ring 0.17.7", + "ring 0.17.8", "rustls-webpki", "sct", ] @@ -6462,7 +6463,7 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -6612,7 +6613,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -6727,7 +6728,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -6781,7 +6782,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -6827,7 +6828,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7124,7 +7125,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7137,7 +7138,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7218,9 +7219,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" dependencies = [ "proc-macro2", "quote", @@ -7236,7 +7237,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7343,22 +7344,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7480,7 +7481,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -7576,7 +7577,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.4", + "toml_edit 0.22.6", ] [[package]] @@ -7596,7 +7597,7 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -7607,7 +7608,7 @@ checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ "indexmap", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -7618,20 +7619,20 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.4" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.1", ] [[package]] @@ -7713,7 +7714,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -8079,7 +8080,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "wasm-bindgen-shared", ] @@ -8113,7 +8114,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8188,7 +8189,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -8459,9 +8460,18 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.39" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" +checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" dependencies = [ "memchr", ] @@ -8539,7 +8549,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] @@ -8559,7 +8569,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.49", ] [[package]] From a9c4d30b51fb7b2d5bd58c7996e78574bbf724e8 Mon Sep 17 00:00:00 2001 From: Enrique Date: Sun, 18 Feb 2024 08:27:48 -0400 Subject: [PATCH 0639/1963] fix(anvil): properly set deposit nonce key on other fields for ser (#7159) --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/tests/it/optimism.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 3d8f1773e86af..f7234d9cd7c02 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2072,7 +2072,7 @@ impl Backend { }; inner.other.insert( - "deposit_nonce".to_string(), + "depositNonce".to_string(), serde_json::to_value(deposit_nonce).expect("Infallible"), ); diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index de9f0c875672c..78dcf92277480 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -138,6 +138,7 @@ async fn test_send_value_raw_deposit_transaction() { let receipt = provider.get_transaction_receipt(pending.tx_hash()).await.unwrap().unwrap(); assert_eq!(receipt.from, from_addr); assert_eq!(receipt.to, Some(to_addr)); + assert_eq!(receipt.other.get_deserialized::("depositNonce").unwrap().unwrap(), 0); // the recipient should have received the value let balance = provider.get_balance(to_addr, None).await.unwrap(); From 1bb2d67804b5d0a182460d5d6fdb76fadde846c4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 18 Feb 2024 23:05:19 +0100 Subject: [PATCH 0640/1963] chore: retry quicknode error (#7162) --- crates/common/src/provider/retry.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index 39248a8a38e95..70c5998c73de0 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -98,6 +98,12 @@ fn should_retry_json_rpc_error(error: &ErrorPayload) -> bool { return true } + // quick node error `"credits limited to 6000/sec"` + // + if *code == -32012 && message.contains("credits") { + return true + } + // quick node rate limit error: `100/second request limit reached - reduce calls per second or // upgrade your account at quicknode.com` if *code == -32007 && message.contains("request limit reached") { @@ -113,6 +119,7 @@ fn should_retry_json_rpc_error(error: &ErrorPayload) -> bool { msg.contains("rate limit") || msg.contains("rate exceeded") || msg.contains("too many requests") || + msg.contains("credits limited") || msg.contains("request limit") } } From 507c2673333800c5767d39ee1675de1a8071770b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:52:50 +0200 Subject: [PATCH 0641/1963] fix: only early-return if an exact bytecode match is found (#7165) * fix: only early-return if an exact bytecode match is found * chore: re-add min threshold --- crates/evm/traces/src/identifier/local.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index c9bcd6fa4d5f3..0cf5c7c702cde 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -29,12 +29,7 @@ impl<'a> LocalTraceIdentifier<'a> { self.known_contracts } - /// Iterates over artifacts with code length less than or equal to the given code and tries to - /// find a match. - /// - /// We do not consider artifacts with code length greater than the given code length as it is - /// considered that after compilation code can only be extended by additional parameters - /// (immutables) and cannot be shortened. + /// Tries to the bytecode most similar to the given one. pub fn identify_code(&self, code: &[u8]) -> Option<(&'a ArtifactId, &'a JsonAbi)> { let len = code.len(); @@ -44,8 +39,8 @@ impl<'a> LocalTraceIdentifier<'a> { let mut check = |id| { let (abi, known_code) = self.known_contracts.get(id)?; let score = bytecode_diff_score(known_code, code); - if score <= 0.1 { - trace!(%score, "found close-enough match"); + if score == 0.0 { + trace!("found exact match"); return Some((id, abi)); } if score < min_score { @@ -80,8 +75,15 @@ impl<'a> LocalTraceIdentifier<'a> { } } - trace!(%min_score, "no close-enough match found"); - min_score_id + trace!(%min_score, "no exact match found"); + + // Note: the diff score can be inaccurate for small contracts so we're using a relatively + // high threshold here to avoid filtering out too many contracts. + if min_score < 0.85 { + min_score_id + } else { + None + } } /// Returns the index of the artifact with the given code length, or the index of the first From 2e5a603cc6073a79b03c073cb4222889ef59b491 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:37:54 +0200 Subject: [PATCH 0642/1963] #6616: createSelectFork does not fork latest block number if you sleep (#7087) * - if no block provided then fork is created using latest block for fork id (url@latest_block). if block provided then fork id is url@provided_block (this means there'll no longer be a url@latest fork id but always url@block) - after creation of fork the id is checked if in inserted forks. If it doesn't exist then it's inserted, otherwise the existing backend is reused and a new fork url@latest_block-1 recorded CreatedFork::inc_senders increments number of senders and returns the new unique fork id. CreatedFork::num_senders was removed MultiForkHandler::insert_new_fork added to handle fork insertion / send on channels * Dummy test * Add back comment, minor code style * Consume fork ids in insert_new_fork * add comment --------- Co-authored-by: Matthias Seitz --- crates/evm/core/src/fork/multi.rs | 103 +++++++++++++++--------------- crates/forge/tests/it/repros.rs | 3 + testdata/repros/Issue6616.t.sol | 22 +++++++ 3 files changed, 78 insertions(+), 50 deletions(-) create mode 100644 testdata/repros/Issue6616.t.sol diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 483686980833c..deb0e9f551611 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -171,7 +171,8 @@ impl MultiFork { type Handler = BackendHandler>>; -type CreateFuture = Pin> + Send>>; +type CreateFuture = + Pin> + Send>>; type CreateSender = OneshotSender>; type GetEnvSender = OneshotSender>; @@ -258,26 +259,32 @@ impl MultiForkHandler { let fork_id = ForkId::new(&fork.url, fork.evm_opts.fork_block_number); trace!(?fork_id, "created new forkId"); - if let Some(fork) = self.forks.get(&fork_id).cloned() { - // assign a new unique fork id but reuse the existing backend - let unique_fork_id: ForkId = - format!("{}-{}", fork_id.as_str(), fork.num_senders()).into(); - trace!(?fork_id, ?unique_fork_id, "created new unique forkId"); - fork.inc_senders(); - let backend = fork.backend.clone(); - let env = fork.opts.env.clone(); - self.forks.insert(unique_fork_id.clone(), fork); - let _ = sender.send(Ok((unique_fork_id, backend, env))); - } else { - // there could already be a task for the requested fork in progress - if let Some(in_progress) = self.find_in_progress_task(&fork_id) { - in_progress.push(sender); - return; - } + // there could already be a task for the requested fork in progress + if let Some(in_progress) = self.find_in_progress_task(&fork_id) { + in_progress.push(sender); + return; + } - // need to create a new fork - let task = Box::pin(create_fork(fork)); - self.pending_tasks.push(ForkTask::Create(task, fork_id, sender, Vec::new())); + // need to create a new fork + let task = Box::pin(create_fork(fork)); + self.pending_tasks.push(ForkTask::Create(task, fork_id, sender, Vec::new())); + } + + fn insert_new_fork( + &mut self, + fork_id: ForkId, + fork: CreatedFork, + sender: CreateSender, + additional_senders: Vec, + ) { + self.forks.insert(fork_id.clone(), fork.clone()); + let _ = sender.send(Ok((fork_id.clone(), fork.backend.clone(), fork.opts.env.clone()))); + + // notify all additional senders and track unique forkIds + for sender in additional_senders { + let next_fork_id = fork.inc_senders(fork_id.clone()); + self.forks.insert(next_fork_id.clone(), fork.clone()); + let _ = sender.send(Ok((next_fork_id, fork.backend.clone(), fork.opts.env.clone()))); } } @@ -346,25 +353,17 @@ impl Future for MultiForkHandler { ForkTask::Create(mut fut, id, sender, additional_senders) => { if let Poll::Ready(resp) = fut.poll_unpin(cx) { match resp { - Ok((fork, handler)) => { - pin.handlers.push((id.clone(), handler)); - let backend = fork.backend.clone(); - let env = fork.opts.env.clone(); - pin.forks.insert(id.clone(), fork.clone()); - - let _ = sender.send(Ok((id.clone(), backend.clone(), env.clone()))); - - // also notify all additional senders and track unique forkIds - for sender in additional_senders { - fork.inc_senders(); - let unique_fork_id: ForkId = - format!("{}-{}", id.as_str(), fork.num_senders()).into(); - pin.forks.insert(unique_fork_id.clone(), fork.clone()); - let _ = sender.send(Ok(( - unique_fork_id, - backend.clone(), - env.clone(), - ))); + Ok((fork_id, fork, handler)) => { + if let Some(fork) = pin.forks.get(&fork_id).cloned() { + pin.insert_new_fork( + fork.inc_senders(fork_id), + fork, + sender, + additional_senders, + ); + } else { + pin.handlers.push((fork_id.clone(), handler)); + pin.insert_new_fork(fork_id, fork, sender, additional_senders); } } Err(err) => { @@ -446,12 +445,14 @@ impl CreatedFork { Self { opts, backend, num_senders: Arc::new(AtomicUsize::new(1)) } } - fn inc_senders(&self) { - self.num_senders.fetch_add(1, std::sync::atomic::Ordering::Relaxed); - } - - fn num_senders(&self) -> usize { - self.num_senders.load(std::sync::atomic::Ordering::Relaxed) + /// Increment senders and return unique identifier of the fork + fn inc_senders(&self, fork_id: ForkId) -> ForkId { + format!( + "{}-{}", + fork_id.as_str(), + self.num_senders.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + ) + .into() } } @@ -483,7 +484,7 @@ impl Drop for ShutDownMultiFork { /// Creates a new fork /// /// This will establish a new `Provider` to the endpoint and return the Fork Backend -async fn create_fork(mut fork: CreateFork) -> eyre::Result<(CreatedFork, Handler)> { +async fn create_fork(mut fork: CreateFork) -> eyre::Result<(ForkId, CreatedFork, Handler)> { let provider = Arc::new( ProviderBuilder::new(fork.url.as_str()) .maybe_max_retry(fork.evm_opts.fork_retries) @@ -499,17 +500,19 @@ async fn create_fork(mut fork: CreateFork) -> eyre::Result<(CreatedFork, Handler // we need to use the block number from the block because the env's number can be different on // some L2s (e.g. Arbitrum). - let number = block.header.number.unwrap_or(meta.block_env.number); + let number = block.header.number.unwrap_or(meta.block_env.number).to::(); // determine the cache path if caching is enabled let cache_path = if fork.enable_caching { - Config::foundry_block_cache_dir(meta.cfg_env.chain_id, number.to::()) + Config::foundry_block_cache_dir(meta.cfg_env.chain_id, number) } else { None }; let db = BlockchainDb::new(meta, cache_path); - let (backend, handler) = SharedBackend::new(provider, db, Some(number.to::().into())); + let (backend, handler) = SharedBackend::new(provider, db, Some(number.into())); let fork = CreatedFork::new(fork, backend); - Ok((fork, handler)) + let fork_id = ForkId::new(&fork.opts.url, number.into()); + + Ok((fork_id, fork, handler)) } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 9c743a12c325b..0838ffed019f5 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -300,3 +300,6 @@ test_repro!(6759); // https://github.com/foundry-rs/foundry/issues/6966 test_repro!(6966); + +// https://github.com/foundry-rs/foundry/issues/6616 +test_repro!(6616); diff --git a/testdata/repros/Issue6616.t.sol b/testdata/repros/Issue6616.t.sol new file mode 100644 index 0000000000000..6c9991f0e79b6 --- /dev/null +++ b/testdata/repros/Issue6616.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/6616 +contract Issue6616Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testCreateForkRollLatestBlock() public { + vm.createSelectFork("rpcAlias"); + uint256 startBlock = block.number; + // this will create new forks and exit once a new latest block is found + for (uint256 i; i < 10; i++) { + vm.sleep(5000); + vm.createSelectFork("rpcAlias"); + if (block.number > startBlock) break; + } + assertGt(block.number, startBlock); + } +} From 602cea3ce901a452d8666cfa68305a39ff58342a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:44:20 +0200 Subject: [PATCH 0643/1963] fix(foundryup): address shellcheck in installer (#7168) * fix(foundryup): address shellcheck in installer * formatting --- foundryup/install | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/foundryup/install b/foundryup/install index 0c6f7b1f15bd8..19bfe573873df 100755 --- a/foundryup/install +++ b/foundryup/install @@ -1,29 +1,28 @@ #!/usr/bin/env bash -set -e +set -eo pipefail -echo Installing foundryup... +echo "Installing foundryup..." -BASE_DIR=${XDG_CONFIG_HOME:-$HOME} -FOUNDRY_DIR=${FOUNDRY_DIR-"$BASE_DIR/.foundry"} +BASE_DIR="${XDG_CONFIG_HOME:-$HOME}" +FOUNDRY_DIR="${FOUNDRY_DIR-"$BASE_DIR/.foundry"}" FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin" FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1" BIN_URL="https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup" BIN_PATH="$FOUNDRY_BIN_DIR/foundryup" - # Create the .foundry bin directory and foundryup binary if it doesn't exist. -mkdir -p $FOUNDRY_BIN_DIR -curl -# -L $BIN_URL -o $BIN_PATH -chmod +x $BIN_PATH +mkdir -p "$FOUNDRY_BIN_DIR" +curl -sSf -L "$BIN_URL" -o "$BIN_PATH" +chmod +x "$BIN_PATH" # Create the man directory for future man files if it doesn't exist. -mkdir -p $FOUNDRY_MAN_DIR +mkdir -p "$FOUNDRY_MAN_DIR" # Store the correct profile file (i.e. .profile for bash or .zshenv for ZSH). case $SHELL in */zsh) - PROFILE=${ZDOTDIR-"$HOME"}/.zshenv + PROFILE="${ZDOTDIR-"$HOME"}/.zshenv" PREF_SHELL=zsh ;; */bash) @@ -46,7 +45,7 @@ esac # Only add foundryup if it isn't already in PATH. if [[ ":$PATH:" != *":${FOUNDRY_BIN_DIR}:"* ]]; then # Add the foundryup directory to the path and ensure the old PATH variables remain. - echo >> $PROFILE && echo "export PATH=\"\$PATH:$FOUNDRY_BIN_DIR\"" >> $PROFILE + echo >> "$PROFILE" && echo "export PATH=\"\$PATH:$FOUNDRY_BIN_DIR\"" >> "$PROFILE" fi # Warn MacOS users that they may need to manually install libusb via Homebrew: @@ -54,5 +53,7 @@ if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/libusb/lib/libusb-1.0.0. echo && echo "warning: libusb not found. You may need to install it manually on MacOS via Homebrew (brew install libusb)." fi -echo && echo "Detected your preferred shell is ${PREF_SHELL} and added foundryup to PATH. Run 'source ${PROFILE}' or start a new terminal session to use foundryup." +echo +echo "Detected your preferred shell is $PREF_SHELL and added foundryup to PATH." +echo "Run 'source $PROFILE' or start a new terminal session to use foundryup." echo "Then, simply run 'foundryup' to install Foundry." From 7b32fdee1baaaa097b556324e9268a83b46f3ce8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:44:51 +0200 Subject: [PATCH 0644/1963] ci: remove project.yml (#7169) --- .github/workflows/project.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/workflows/project.yml diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml deleted file mode 100644 index dd2899dd36972..0000000000000 --- a/.github/workflows/project.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: project - -on: - issues: - types: [opened, transferred] - -jobs: - add-to-project: - name: add issue - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/add-to-project@main - with: - project-url: https://github.com/orgs/foundry-rs/projects/2 - github-token: ${{ secrets.GH_PROJECTS_TOKEN }} From d52f449306ed237f517c4f845ee140f921206450 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:45:01 +0200 Subject: [PATCH 0645/1963] chore: add evm::traces target to tracing (#7167) --- crates/evm/traces/src/identifier/etherscan.rs | 2 +- crates/evm/traces/src/identifier/local.rs | 12 ++++++------ crates/evm/traces/src/identifier/signatures.rs | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index e995b36f9b666..43552f12b250c 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -99,7 +99,7 @@ impl TraceIdentifier for EtherscanIdentifier { where A: Iterator)>, { - trace!("identify {:?} addresses", addresses.size_hint().1); + trace!(target: "evm::traces", "identify {:?} addresses", addresses.size_hint().1); let Some(client) = self.client.clone() else { // no client was configured diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index 0cf5c7c702cde..193a8c526183c 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -40,7 +40,7 @@ impl<'a> LocalTraceIdentifier<'a> { let (abi, known_code) = self.known_contracts.get(id)?; let score = bytecode_diff_score(known_code, code); if score == 0.0 { - trace!("found exact match"); + trace!(target: "evm::traces", "found exact match"); return Some((id, abi)); } if score < min_score { @@ -75,7 +75,7 @@ impl<'a> LocalTraceIdentifier<'a> { } } - trace!(%min_score, "no exact match found"); + trace!(target: "evm::traces", %min_score, "no exact match found"); // Note: the diff score can be inaccurate for small contracts so we're using a relatively // high threshold here to avoid filtering out too many contracts. @@ -106,15 +106,15 @@ impl TraceIdentifier for LocalTraceIdentifier<'_> { where A: Iterator)>, { - trace!("identify {:?} addresses", addresses.size_hint().1); + trace!(target: "evm::traces", "identify {:?} addresses", addresses.size_hint().1); addresses .filter_map(|(address, code)| { - let _span = trace_span!("identify", %address).entered(); + let _span = trace_span!(target: "evm::traces", "identify", %address).entered(); - trace!("identifying"); + trace!(target: "evm::traces", "identifying"); let (id, abi) = self.identify_code(code?)?; - trace!(id=%id.identifier(), "identified"); + trace!(target: "evm::traces", id=%id.identifier(), "identified"); Some(AddressIdentity { address: *address, diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 46766b0a88028..b1f3124cdf1bd 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -34,7 +34,7 @@ pub struct SignaturesIdentifier { } impl SignaturesIdentifier { - #[instrument(target = "forge::signatures")] + #[instrument(target = "evm::traces")] pub fn new( cache_path: Option, offline: bool, @@ -43,14 +43,14 @@ impl SignaturesIdentifier { let identifier = if let Some(cache_path) = cache_path { let path = cache_path.join("signatures"); - trace!(?path, "reading signature cache"); + trace!(target: "evm::traces", ?path, "reading signature cache"); let cached = if path.is_file() { fs::read_json_file(&path) - .map_err(|err| warn!(?path, ?err, "failed to read cache file")) + .map_err(|err| warn!(target: "evm::traces", ?path, ?err, "failed to read cache file")) .unwrap_or_default() } else { if let Err(err) = std::fs::create_dir_all(cache_path) { - warn!("could not create signatures cache dir: {:?}", err); + warn!(target: "evm::traces", "could not create signatures cache dir: {:?}", err); } CachedSignatures::default() }; @@ -74,18 +74,18 @@ impl SignaturesIdentifier { Ok(Arc::new(RwLock::new(identifier))) } - #[instrument(target = "forge::signatures", skip(self))] + #[instrument(target = "evm::traces", skip(self))] pub fn save(&self) { if let Some(cached_path) = &self.cached_path { if let Some(parent) = cached_path.parent() { if let Err(err) = std::fs::create_dir_all(parent) { - warn!(?parent, ?err, "failed to create cache"); + warn!(target: "evm::traces", ?parent, ?err, "failed to create cache"); } } if let Err(err) = fs::write_json_file(cached_path, &self.cached) { - warn!(?cached_path, ?err, "failed to flush signature cache"); + warn!(target: "evm::traces", ?cached_path, ?err, "failed to flush signature cache"); } else { - trace!(?cached_path, "flushed signature cache") + trace!(target: "evm::traces", ?cached_path, "flushed signature cache") } } } From 0cbac6361d018da0c08c5705f3c5ed26fad2dc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaya=20G=C3=B6kalp?= Date: Mon, 19 Feb 2024 07:14:00 -0800 Subject: [PATCH 0646/1963] feat(coverage): add statements to `lcov` reports (#7146) * fix: add statements to lcov reports * chore: fmt --- crates/forge/src/coverage.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index dda7eba6e4fc3..1c79c0e33ec40 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -117,7 +117,9 @@ impl<'a> CoverageReporter for LcovReporter<'a> { )?; } // Statements are not in the LCOV format - CoverageItemKind::Statement => (), + CoverageItemKind::Statement => { + writeln!(self.destination, "DA:{line},{hits}")?; + } } } From 5addb9ed9b33670e76caebd1ad9ecf16904ab681 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:41:45 +0200 Subject: [PATCH 0647/1963] chore: remove unused imports (#7170) --- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 11 ++------ crates/anvil/src/eth/backend/mem/storage.rs | 2 +- crates/anvil/tests/it/fork.rs | 1 - crates/anvil/tests/it/ipc.rs | 5 ++-- crates/cast/bin/cmd/logs.rs | 3 +-- crates/cheatcodes/src/utils.rs | 2 +- crates/common/src/abi.rs | 2 +- crates/config/src/lib.rs | 9 +++---- crates/evm/core/src/fork/backend.rs | 2 +- crates/evm/core/src/opts.rs | 1 - crates/fmt/src/formatter.rs | 1 - crates/forge/bin/cmd/script/broadcast.rs | 26 ++++++++++++++----- crates/forge/bin/cmd/script/build.rs | 2 +- crates/forge/bin/cmd/script/cmd.rs | 16 +++++++++--- crates/forge/bin/cmd/script/executor.rs | 16 +++++++----- crates/forge/bin/cmd/script/mod.rs | 7 ++--- crates/forge/bin/cmd/script/runner.rs | 4 ++- crates/forge/bin/cmd/verify/etherscan/mod.rs | 1 - crates/forge/src/link.rs | 3 +-- crates/forge/src/multi_runner.rs | 1 - 21 files changed, 61 insertions(+), 56 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 502cd075dafff..afc16b928f12b 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -975,7 +975,7 @@ pub fn to_eip_access_list( #[cfg(test)] mod tests { use alloy_consensus::Receipt; - use alloy_primitives::{b256, hex, LogData, Signature}; + use alloy_primitives::{b256, hex, LogData}; use std::str::FromStr; use super::*; diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index f9b1cb6da9ef0..e1c7deb8e9997 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -133,15 +133,8 @@ impl MaybeForkedDatabase for MemDb { #[cfg(test)] mod tests { use super::*; - use crate::{ - eth::backend::db::{Db, SerializableAccountRecord, SerializableState}, - revm::primitives::AccountInfo, - }; - use alloy_primitives::{Address, Bytes, U256}; - use foundry_evm::{ - backend::MemDb, - revm::primitives::{Bytecode, KECCAK_EMPTY}, - }; + use alloy_primitives::Bytes; + use foundry_evm::revm::primitives::{Bytecode, KECCAK_EMPTY}; use std::{collections::BTreeMap, str::FromStr}; // verifies that all substantial aspects of a loaded account remain the state after an account diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index b84a34dc7312b..9e907cff4d6b6 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -438,7 +438,7 @@ pub struct MinedTransactionReceipt { mod tests { use super::*; use crate::eth::backend::db::Db; - use alloy_primitives::{Address, B256, U256}; + use alloy_primitives::Address; use foundry_evm::{ backend::MemDb, revm::{ diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 0bd6f7dcb78ed..ceeeb16e7e1e3 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -11,7 +11,6 @@ use alloy_signer::Signer as AlloySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; use ethers::{ - core::rand, prelude::{Bytes, LocalWallet, Middleware, SignerMiddleware}, providers::{Http, Provider}, signers::Signer, diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index 6e3204d9d6b3f..8b7de088467de 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -1,12 +1,11 @@ //! IPC tests +use crate::utils::ethers_ipc_provider; use alloy_primitives::U256; use anvil::{spawn, NodeConfig}; -use ethers::{core::rand, prelude::Middleware}; +use ethers::prelude::Middleware; use futures::StreamExt; -use crate::utils::ethers_ipc_provider; - pub fn rand_ipc_endpoint() -> String { let num: u64 = rand::Rng::gen(&mut rand::thread_rng()); if cfg!(windows) { diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index e7e6aed5d9b7b..752d90dfed6c5 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -285,8 +285,7 @@ pub fn sanitize_token(token: Token) -> Token { #[cfg(test)] mod tests { use super::*; - use ethers_core::types::{H160, H256}; - use std::str::FromStr; + use ethers_core::types::H160; const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"; const TRANSFER_SIG: &str = "Transfer(address indexed,address indexed,uint256)"; diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index bb47264311888..9cfeee276b59a 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -241,7 +241,7 @@ mod tests { use crate::CheatsConfig; use alloy_primitives::FixedBytes; use hex::FromHex; - use p256::ecdsa::{signature::hazmat::PrehashVerifier, Signature}; + use p256::ecdsa::signature::hazmat::PrehashVerifier; use std::{path::PathBuf, sync::Arc}; fn cheats() -> Cheatcodes { diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index fc3e8083e4a3f..66a7c98910e23 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -203,7 +203,7 @@ fn coerce_value(ty: &str, arg: &str) -> Result { mod tests { use super::*; use alloy_dyn_abi::EventExt; - use alloy_primitives::{LogData, B256, U256}; + use alloy_primitives::{B256, U256}; #[test] fn test_get_func() { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index c55dcb752c3c5..879d3ecfb7df1 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -35,7 +35,6 @@ use std::{ fs, path::{Path, PathBuf}, str::FromStr, - string::ToString, }; // Macros useful for creating a figment. @@ -2574,15 +2573,13 @@ mod tests { use super::*; use crate::{ cache::{CachedChains, CachedEndpoints}, - endpoints::{RpcEndpoint, RpcEndpointConfig, RpcEndpointType}, + endpoints::{RpcEndpointConfig, RpcEndpointType}, etherscan::ResolvedEtherscanConfigs, - fs_permissions::PathPermission, }; - use alloy_primitives::Address; - use figment::{error::Kind::InvalidType, value::Value, Figment}; + use figment::error::Kind::InvalidType; use foundry_compilers::artifacts::{ModelCheckerEngine, YulDetails}; use pretty_assertions::assert_eq; - use std::{collections::BTreeMap, fs::File, io::Write, str::FromStr}; + use std::{collections::BTreeMap, fs::File, io::Write}; use tempfile::tempdir; use NamedChain::Moonbeam; diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 3a87583b6da4f..e319069d065ac 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -682,7 +682,7 @@ mod tests { }; use foundry_common::provider::alloy::get_http_provider; use foundry_config::{Config, NamedChain}; - use std::{collections::BTreeSet, path::PathBuf, sync::Arc}; + use std::{collections::BTreeSet, path::PathBuf}; const ENDPOINT: Option<&str> = option_env!("ETH_RPC_URL"); diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 1e52f484bde3e..094606828dfdc 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -5,7 +5,6 @@ use alloy_providers::provider::TempProvider; use alloy_rpc_types::Block; use eyre::WrapErr; use foundry_common::{ - self, provider::alloy::{ProviderBuilder, RpcUrl}, ALCHEMY_FREE_TIER_CUPS, }; diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 347d7188f14e5..00beb4d8c656a 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -16,7 +16,6 @@ use crate::{ use alloy_primitives::Address; use foundry_config::fmt::{HexUnderscore, MultilineFuncHeaderStyle, SingleLineBlockStyle}; use itertools::{Either, Itertools}; -use solang_parser::pt::ImportPath; use std::{fmt::Write, str::FromStr}; use thiserror::Error; diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 7488bbd1071bf..10d0096068b02 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -1,24 +1,36 @@ use super::{ multi::MultiChainSequence, providers::ProvidersManager, receipts::clear_pendings, - sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, *, + sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, + NestedValue, ScriptArgs, ScriptConfig, ScriptResult, }; -use alloy_primitives::{utils::format_units, TxHash}; +use alloy_primitives::{utils::format_units, Address, TxHash, U256}; use ethers_core::types::transaction::eip2718::TypedTransaction; use ethers_providers::{JsonRpcClient, Middleware, Provider}; -use ethers_signers::Signer; -use eyre::{bail, ContextCompat, Result, WrapErr}; +use ethers_signers::{LocalWallet, Signer}; +use eyre::{bail, Context, ContextCompat, Result}; +use forge::{inspectors::cheatcodes::BroadcastableTransactions, traces::CallTraceDecoder}; use foundry_cli::{ init_progress, update_progress, utils::{has_batch_support, has_different_gas_calc}, }; use foundry_common::{ - provider::ethers::{estimate_eip1559_fees, try_get_http_provider, RetryProvider}, + provider::{ + alloy::RpcUrl, + ethers::{estimate_eip1559_fees, try_get_http_provider, RetryProvider}, + }, shell, types::{ToAlloy, ToEthers}, + ContractsByArtifact, }; +use foundry_compilers::{artifacts::Libraries, ArtifactId}; +use foundry_config::Config; use foundry_wallets::WalletSigner; use futures::StreamExt; -use std::{cmp::min, collections::HashSet, ops::Mul, sync::Arc}; +use std::{ + cmp::min, + collections::{HashMap, HashSet, VecDeque}, + sync::Arc, +}; impl ScriptArgs { /// Sends the transactions which haven't been broadcasted yet. @@ -198,7 +210,7 @@ impl ScriptArgs { |acc, receipt| { let gas_used = receipt.gas_used.unwrap_or_default().to_alloy(); let gas_price = receipt.effective_gas_price.unwrap_or_default().to_alloy(); - (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used.mul(gas_price)) + (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used * gas_price) }, ); let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index fd66377cdfac5..ebd502a92a794 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,4 +1,4 @@ -use super::*; +use super::{ScriptArgs, ScriptConfig}; use alloy_primitives::{Address, Bytes}; use eyre::{Context, ContextCompat, Result}; use forge::link::{LinkOutput, Linker}; diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index ebb9f97aa5927..69032462d3e79 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -1,15 +1,23 @@ -use super::{multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, *}; -use alloy_primitives::Bytes; - +use super::{ + multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, ScriptArgs, + ScriptConfig, ScriptResult, +}; +use crate::cmd::script::{build::BuildOutput, receipts}; +use alloy_primitives::{Address, Bytes}; use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::{OptionExt, Result}; -use forge::link::Linker; +use forge::{link::Linker, traces::CallTraceDecoder}; use foundry_cli::utils::LoadConfig; use foundry_common::{ contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy, }; +use foundry_compilers::{ + artifacts::{ContractBytecodeSome, Libraries}, + contracts::ArtifactContracts, +}; use foundry_debugger::Debugger; +use foundry_evm::inspectors::cheatcodes::BroadcastableTransaction; use std::sync::Arc; /// Helper alias type for the collection of data changed due to the new sender. diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 588af4c10d1e7..ac86c112a4ead 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -1,22 +1,26 @@ use super::{ artifacts::ArtifactInfo, - runner::SimulationStage, + runner::{ScriptRunner, SimulationStage}, transaction::{AdditionalContract, TransactionWithMetadata}, - *, + ScriptArgs, ScriptConfig, ScriptResult, }; use alloy_primitives::{Address, Bytes, U256}; -use eyre::Result; +use eyre::{Context, Result}; use forge::{ backend::Backend, executors::ExecutorBuilder, inspectors::{cheatcodes::BroadcastableTransactions, CheatsConfig}, - traces::CallTraceDecoder, + traces::{render_trace_arena, CallTraceDecoder}, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; -use foundry_common::{provider::ethers::RpcUrl, shell}; +use foundry_common::{get_contract_name, provider::ethers::RpcUrl, shell, ContractsByArtifact}; +use foundry_compilers::artifacts::ContractBytecodeSome; use futures::future::join_all; use parking_lot::RwLock; -use std::{collections::VecDeque, sync::Arc}; +use std::{ + collections::{BTreeMap, HashMap, VecDeque}, + sync::Arc, +}; impl ScriptArgs { /// Locally deploys and executes the contract method that will collect all broadcastable diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index bde7436fcbbee..17ff7e569238e 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -1,4 +1,3 @@ -use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; @@ -21,7 +20,6 @@ use forge::{ }; use foundry_common::{ abi::{encode_function_args, get_func}, - contracts::get_contract_name, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, fmt::{format_token, format_token_raw}, @@ -30,7 +28,6 @@ use foundry_common::{ }; use foundry_compilers::{ artifacts::{ContractBytecodeSome, Libraries}, - contracts::ArtifactContracts, ArtifactId, }; use foundry_config::{ @@ -50,7 +47,7 @@ use foundry_wallets::MultiWallet; use futures::future; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; +use std::collections::{BTreeMap, HashMap, HashSet}; use yansi::Paint; mod artifacts; @@ -705,7 +702,7 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855", mod tests { use super::*; use foundry_cli::utils::LoadConfig; - use foundry_config::{NamedChain, UnresolvedEnvVarError}; + use foundry_config::UnresolvedEnvVarError; use std::fs; use tempfile::tempdir; diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 6afb1a4441b05..838dcfdf34b74 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -1,4 +1,4 @@ -use super::*; +use super::ScriptResult; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use forge::{ @@ -8,6 +8,8 @@ use forge::{ traces::{TraceKind, Traces}, }; use foundry_common::types::ToEthers; +use foundry_config::Config; +use yansi::Paint; /// Represents which simulation stage is the script execution at. pub enum SimulationStage { diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 961b6db47d96a..919c83b8fb0ab 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -486,7 +486,6 @@ async fn ensure_solc_build_metadata(version: Version) -> Result { mod tests { use super::*; use clap::Parser; - use foundry_cli::utils::LoadConfig; use foundry_common::fs; use foundry_test_utils::forgetest_async; use tempfile::tempdir; diff --git a/crates/forge/src/link.rs b/crates/forge/src/link.rs index 3779f69caf261..55f3f5487b3d2 100644 --- a/crates/forge/src/link.rs +++ b/crates/forge/src/link.rs @@ -194,10 +194,9 @@ impl Linker { #[cfg(test)] mod tests { - use std::{collections::HashMap, path::PathBuf}; - use super::*; use foundry_compilers::{Project, ProjectPathsConfig}; + use std::collections::HashMap; struct LinkerTest { project: Project, diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 67b96cb2326ad..21c34b6a6125a 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -24,7 +24,6 @@ use revm::primitives::SpecId; use std::{ collections::BTreeMap, fmt::Debug, - iter::Iterator, path::Path, sync::{mpsc, Arc}, }; From 928045e45b4cafc733308a97ad4c912de3c0b5ab Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:41:59 +0200 Subject: [PATCH 0648/1963] fix(chisel): enum min and max (#7173) --- Cargo.lock | 1 + crates/chisel/Cargo.toml | 1 + crates/chisel/src/executor.rs | 29 ++++++++++++++++++++--------- crates/chisel/src/session_source.rs | 18 ++++++++++++++---- crates/forge/bin/cmd/verify/mod.rs | 9 +++++---- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fde0c6326e50f..337c5f061a593 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1356,6 +1356,7 @@ dependencies = [ "time", "tokio", "tracing", + "tracing-subscriber", "vergen", "yansi 0.5.1", ] diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 4a6364af66f20..22d78e64e6113 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -54,6 +54,7 @@ tracing.workspace = true criterion = { version = "0.5", features = ["async_tokio"] } once_cell = "1" serial_test = "2" +tracing-subscriber.workspace = true [features] default = ["rustls"] diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index f3dcb40f37810..1a425d3f2e8f2 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -861,10 +861,7 @@ impl Type { "name" => Some(DynSolType::String), "creationCode" | "runtimeCode" => Some(DynSolType::Bytes), "interfaceId" => Some(DynSolType::FixedBytes(4)), - "min" | "max" => { - let arg = args.unwrap().pop().flatten().unwrap(); - Some(arg.into_builtin().unwrap()) - } + "min" | "max" => Some(DynSolType::Uint(256)), _ => None, }, "string" => match access { @@ -1570,6 +1567,8 @@ mod tests { #[test] fn test_global_vars() { + init_tracing(); + // https://docs.soliditylang.org/en/latest/cheatsheet.html#global-variables let global_variables = { use DynSolType::*; @@ -1649,9 +1648,11 @@ mod tests { ("type(C).runtimeCode", Bytes), ("type(I).interfaceId", FixedBytes(4)), ("type(uint256).min", Uint(256)), - ("type(int256).min", Int(256)), + ("type(int256).min", Uint(256)), ("type(uint256).max", Uint(256)), - ("type(int256).max", Int(256)), + ("type(int256).max", Uint(256)), + ("type(Enum1).min", Uint(256)), + ("type(Enum1).max", Uint(256)), // function ("this.run.address", Address), ("this.run.selector", FixedBytes(4)), @@ -1712,14 +1713,16 @@ mod tests { s.drain_global_code(); } - let input = input.trim_end().trim_end_matches(';').to_string() + ";"; + *s = s.clone_with_new_line("enum Enum1 { A }".into()).unwrap().0; + + let input = format!("{};", input.trim_end().trim_end_matches(';')); let (mut _s, _) = s.clone_with_new_line(input).unwrap(); *s = _s.clone(); let s = &mut _s; if let Err(e) = s.parse() { for err in e { - eprintln!("{} @ {}:{}", err.message, err.loc.start(), err.loc.end()); + eprintln!("{}:{}: {}", err.loc.start(), err.loc.end(), err.message); } let source = s.to_repl_source(); panic!("could not parse input:\n{source}") @@ -1750,7 +1753,6 @@ mod tests { ty.and_then(|ty| ty.try_as_ethabi(Some(&intermediate))) } - #[track_caller] fn generic_type_test<'a, T, I>(s: &mut SessionSource, input: I) where T: AsRef + std::fmt::Display + 'a, @@ -1762,4 +1764,13 @@ mod tests { assert_eq!(ty.as_ref(), Some(expected), "\n{input}"); } } + + fn init_tracing() { + if std::env::var_os("RUST_LOG").is_none() { + std::env::set_var("RUST_LOG", "debug"); + } + let _ = tracing_subscriber::FmtSubscriber::builder() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .try_init(); + } } diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 36fb5cf1c1673..c827454e97c4a 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -14,7 +14,7 @@ use foundry_config::{Config, SolcReq}; use foundry_evm::{backend::Backend, opts::EvmOpts}; use semver::Version; use serde::{Deserialize, Serialize}; -use solang_parser::pt; +use solang_parser::{diagnostics::Diagnostic, pt}; use std::{collections::HashMap, fs, path::PathBuf}; use yansi::Paint; @@ -665,16 +665,26 @@ pub fn parse_fragment( match base.clone().with_run_code(buffer).parse() { Ok(_) => return Some(ParseTreeFragment::Function), - Err(e) => tracing::debug!(?e), + Err(e) => debug_errors(&e), } match base.clone().with_top_level_code(buffer).parse() { Ok(_) => return Some(ParseTreeFragment::Contract), - Err(e) => tracing::debug!(?e), + Err(e) => debug_errors(&e), } match base.with_global_code(buffer).parse() { Ok(_) => return Some(ParseTreeFragment::Source), - Err(e) => tracing::debug!(?e), + Err(e) => debug_errors(&e), } None } + +fn debug_errors(errors: &[Diagnostic]) { + if !tracing::enabled!(tracing::Level::DEBUG) { + return; + } + + for error in errors { + tracing::debug!("error: {}", error.message); + } +} diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 404ed2251b12d..4590c46a3efeb 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -99,6 +99,10 @@ pub struct VerifyArgs { #[clap(long, conflicts_with = "flatten")] pub show_standard_json_input: bool, + /// Use the Yul intermediate representation compilation pipeline. + #[clap(long)] + pub via_ir: bool, + #[clap(flatten)] pub etherscan: EtherscanOpts, @@ -107,10 +111,6 @@ pub struct VerifyArgs { #[clap(flatten)] pub verifier: VerifierArgs, - - /// Use the Yul intermediate representation compilation pipeline. - #[clap(long)] - pub via_ir: bool, } impl_figment_convert!(VerifyArgs); @@ -119,6 +119,7 @@ impl figment::Provider for VerifyArgs { fn metadata(&self) -> figment::Metadata { figment::Metadata::named("Verify Provider") } + fn data( &self, ) -> Result, figment::Error> { From 2303c2d1a0b112447c88bd908276b36d5b0e53a3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 18:48:10 +0200 Subject: [PATCH 0649/1963] fix: show return data length instead of calldata for CREATE traces (#7174) --- crates/evm/traces/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 91a693656d90d..d7d55696f7b2c 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -126,7 +126,7 @@ pub async fn render_trace_arena( if node.trace.kind.is_any_create() { match &return_data { None => { - writeln!(s, "{} bytes of code", node.trace.data.len())?; + writeln!(s, "{} bytes of code", node.trace.output.len())?; } Some(val) => { writeln!(s, "{val}")?; From 95039bcf4fd3d00573d6ce515ddeb298495d8508 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 19 Feb 2024 23:32:19 +0200 Subject: [PATCH 0650/1963] feat(forge): add --evm-version to verify-contract (#7178) --- crates/cast/bin/cmd/run.rs | 3 ++- crates/forge/bin/cmd/create.rs | 2 ++ crates/forge/bin/cmd/script/verify.rs | 1 + crates/forge/bin/cmd/verify/mod.rs | 11 ++++++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 2f3050e4c450c..ccdd2648095c5 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -51,11 +51,12 @@ pub struct RunArgs { #[clap(flatten)] rpc: RpcOpts, - /// The evm version to use. + /// The EVM version to use. /// /// Overrides the version specified in the config. #[clap(long, short)] evm_version: Option, + /// Sets the number of assumed available compute units per second for this provider /// /// default value: 330 diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index a6510e0ce1f17..77deb356ac25f 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -186,6 +186,7 @@ impl CreateArgs { root: None, verifier: self.verifier.clone(), via_ir: self.opts.via_ir, + evm_version: self.opts.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, }; @@ -334,6 +335,7 @@ impl CreateArgs { root: None, verifier: self.verifier, via_ir: self.opts.via_ir, + evm_version: self.opts.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, }; println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier); diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index f525f08a0585f..6498b8f8a6dd6 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -114,6 +114,7 @@ impl VerifyBundle { root: None, verifier: self.verifier.clone(), via_ir: self.via_ir, + evm_version: None, show_standard_json_input: false, }; diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index 4590c46a3efeb..c598006d9cd6d 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -3,7 +3,7 @@ use alloy_primitives::Address; use clap::{Parser, ValueHint}; use eyre::Result; use foundry_cli::{opts::EtherscanOpts, utils::LoadConfig}; -use foundry_compilers::info::ContractInfo; +use foundry_compilers::{info::ContractInfo, EvmVersion}; use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config}; use provider::VerificationProviderType; use reqwest::Url; @@ -103,6 +103,12 @@ pub struct VerifyArgs { #[clap(long)] pub via_ir: bool, + /// The EVM version to use. + /// + /// Overrides the version specified in the config. + #[clap(long)] + pub evm_version: Option, + #[clap(flatten)] pub etherscan: EtherscanOpts, @@ -134,6 +140,9 @@ impl figment::Provider for VerifyArgs { figment::value::Value::serialize(optimizer_runs)?, ); } + if let Some(evm_version) = self.evm_version { + dict.insert("evm_version".to_string(), figment::value::Value::serialize(evm_version)?); + } if self.via_ir { dict.insert("via_ir".to_string(), figment::value::Value::serialize(self.via_ir)?); } From a2a6bcd18c89eb31347a64120b3aef1abc86840a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 00:54:51 +0200 Subject: [PATCH 0651/1963] fix: don't panic when iterating over script sequence txs (#7179) --- crates/evm/evm/src/executors/invariant/mod.rs | 3 +-- crates/forge/bin/cmd/script/broadcast.rs | 8 +++----- crates/forge/bin/cmd/script/multi.rs | 15 ++++----------- crates/forge/bin/cmd/script/sequence.rs | 14 +++++++------- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index d0e3d36fe995c..69e141255db11 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -153,8 +153,7 @@ impl<'a> InvariantExecutor<'a> { let mut created_contracts = vec![]; for current_run in 0..self.config.depth { - let (sender, (address, calldata)) = - inputs.last().expect("to have the next randomly generated input."); + let (sender, (address, calldata)) = inputs.last().expect("no input generated"); // Executes the call from the randomly generated sequence. let call_result = executor diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 10d0096068b02..49717cc9724e8 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -46,9 +46,8 @@ impl ScriptArgs { if already_broadcasted < deployment_sequence.transactions.len() { let required_addresses: HashSet
= deployment_sequence .typed_transactions() - .into_iter() .skip(already_broadcasted) - .map(|(_, tx)| (*tx.from().expect("No sender for onchain transaction!")).to_alloy()) + .map(|tx| (*tx.from().expect("No sender for onchain transaction!")).to_alloy()) .collect(); let (send_kind, chain) = if self.unlocked { @@ -61,8 +60,7 @@ impl ScriptArgs { senders.extend( deployment_sequence .typed_transactions() - .iter() - .filter_map(|(_, tx)| tx.from().copied().map(|addr| addr.to_alloy())), + .filter_map(|tx| tx.from().copied().map(|addr| addr.to_alloy())), ); (SendTransactionsKind::Unlocked(senders), chain.as_u64()) } else { @@ -324,7 +322,7 @@ impl ScriptArgs { } } else if self.broadcast { self.single_deployment( - deployments.first_mut().expect("to be set."), + deployments.first_mut().expect("missing deployment"), script_config, libraries, result, diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index 9fd3427949b29..ab8cd64cbb01d 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -199,9 +199,8 @@ impl ScriptArgs { .deployments .iter_mut() .map(|sequence| async move { - let provider = Arc::new(get_http_provider( - sequence.typed_transactions().first().unwrap().0.clone(), - )); + let rpc_url = sequence.rpc_url().unwrap(); + let provider = Arc::new(get_http_provider(rpc_url)); receipts::wait_for_pending(provider, sequence).await }) .collect::>(); @@ -219,14 +218,8 @@ impl ScriptArgs { let mut results: Vec> = Vec::new(); for sequence in deployments.deployments.iter_mut() { - let result = match self - .send_transactions( - sequence, - &sequence.typed_transactions().first().unwrap().0.clone(), - &script_wallets, - ) - .await - { + let rpc_url = sequence.rpc_url().unwrap().to_string(); + let result = match self.send_transactions(sequence, &rpc_url, &script_wallets).await { Ok(_) if self.verify => sequence.verify_contracts(config, verify.clone()).await, Ok(_) => Ok(()), Err(err) => Err(err), diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index b2b4c1abdbff8..6223bd1048485 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -353,14 +353,14 @@ impl ScriptSequence { } } + /// Returns the first RPC URL of this sequence. + pub fn rpc_url(&self) -> Option<&str> { + self.transactions.front().and_then(|tx| tx.rpc.as_deref()) + } + /// Returns the list of the transactions without the metadata. - pub fn typed_transactions(&self) -> Vec<(String, &TypedTransaction)> { - self.transactions - .iter() - .map(|tx| { - (tx.rpc.clone().expect("to have been filled with a proper rpc"), tx.typed_tx()) - }) - .collect() + pub fn typed_transactions(&self) -> impl Iterator { + self.transactions.iter().map(|tx| tx.typed_tx()) } pub fn fill_sensitive(&mut self, sensitive: &SensitiveScriptSequence) { From 107dc4156c006b9ad3cac0900a05129bee7b0b3f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 20 Feb 2024 03:48:23 +0400 Subject: [PATCH 0652/1963] fix(forge): do not error when artifact does not have an abi (#7184) * fix(forge): do not error when artifact does not have an abi * unused import --- crates/forge/src/multi_runner.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 21c34b6a6125a..0651e82d61848 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -7,7 +7,7 @@ use crate::{ }; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; -use eyre::{OptionExt, Result}; +use eyre::Result; use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput}; use foundry_evm::{ @@ -331,7 +331,9 @@ impl MultiContractRunnerBuilder { let mut known_contracts = ContractsByArtifact::default(); for (id, contract) in &linker.contracts.0 { - let abi = contract.abi.as_ref().ok_or_eyre("we should have an abi by now")?; + let Some(abi) = contract.abi.as_ref() else { + continue; + }; let LinkOutput { libs_to_deploy, libraries } = linker.link_with_nonce_or_address(Default::default(), evm_opts.sender, 1, id)?; From a436a0df05698e76ff4669c562b7374a03b83c11 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 01:48:31 +0200 Subject: [PATCH 0653/1963] chore: improve DatabaseError error messages (#7183) * chore: improve DatabaseError error messages * chore: pass Address by reference --- crates/cheatcodes/src/inspector.rs | 4 ++-- crates/cheatcodes/src/json.rs | 2 +- crates/evm/core/src/backend/error.rs | 6 +++--- crates/evm/core/src/backend/fuzz.rs | 4 ++-- crates/evm/core/src/backend/mod.rs | 30 ++++++++++++++-------------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 8290b9b951de9..7341bb6b18dbb 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -232,7 +232,7 @@ impl Cheatcodes { // ensure the caller is allowed to execute cheatcodes, // but only if the backend is in forking mode - data.db.ensure_cheatcode_access_forking_mode(caller)?; + data.db.ensure_cheatcode_access_forking_mode(&caller)?; apply_dispatch(&decoded, &mut CheatsCtxt { state: self, data, caller }) } @@ -255,7 +255,7 @@ impl Cheatcodes { .unwrap_or_default(); let created_address = inputs.created_address(old_nonce); - if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(inputs.caller) { + if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(&inputs.caller) { // we only grant cheat code access for new contracts if the caller also has // cheatcode access and the new contract is created in top most call return created_address; diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index aa27a446d0e11..758d4616088a4 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -192,7 +192,7 @@ impl Cheatcode for serializeBytes32_0Call { impl Cheatcode for serializeString_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + serialize_json(state, objectKey, Some(valueKey), value) } } diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index df5b094a63f86..a5b3d02861e58 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -15,11 +15,11 @@ pub type DatabaseResult = Result; pub enum DatabaseError { #[error("{0}")] Message(String), - #[error("no cheats available for {0}")] + #[error("cheatcodes are not enabled for {0}; see `vm.allowCheatcodes(address)`")] NoCheats(Address), - #[error("failed to fetch AccountInfo {0}")] + #[error("failed to fetch account info for {0}")] MissingAccount(Address), - #[error("code should already be loaded: {0}")] + #[error("missing bytecode for code hash {0}")] MissingCode(B256), #[error(transparent)] Recv(#[from] RecvError), diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index 5a7946d3c998f..f4d362ec8d848 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -231,11 +231,11 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { self.backend.to_mut().allow_cheatcode_access(account) } - fn revoke_cheatcode_access(&mut self, account: Address) -> bool { + fn revoke_cheatcode_access(&mut self, account: &Address) -> bool { self.backend.to_mut().revoke_cheatcode_access(account) } - fn has_cheatcode_access(&self, account: Address) -> bool { + fn has_cheatcode_access(&self, account: &Address) -> bool { self.backend.has_cheatcode_access(account) } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index c45771894ddd3..1ea450d2351ac 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -293,24 +293,24 @@ pub trait DatabaseExt: Database { /// Revokes cheatcode access for the given account /// /// Returns true if the `account` was previously allowed cheatcode access - fn revoke_cheatcode_access(&mut self, account: Address) -> bool; + fn revoke_cheatcode_access(&mut self, account: &Address) -> bool; /// Returns `true` if the given account is allowed to execute cheatcodes - fn has_cheatcode_access(&self, account: Address) -> bool; + fn has_cheatcode_access(&self, account: &Address) -> bool; /// Ensures that `account` is allowed to execute cheatcodes /// /// Returns an error if [`Self::has_cheatcode_access`] returns `false` - fn ensure_cheatcode_access(&self, account: Address) -> Result<(), DatabaseError> { + fn ensure_cheatcode_access(&self, account: &Address) -> Result<(), DatabaseError> { if !self.has_cheatcode_access(account) { - return Err(DatabaseError::NoCheats(account)); + return Err(DatabaseError::NoCheats(*account)); } Ok(()) } /// Same as [`Self::ensure_cheatcode_access()`] but only enforces it if the backend is currently /// in forking mode - fn ensure_cheatcode_access_forking_mode(&self, account: Address) -> Result<(), DatabaseError> { + fn ensure_cheatcode_access_forking_mode(&self, account: &Address) -> Result<(), DatabaseError> { if self.is_forked_mode() { return self.ensure_cheatcode_access(account); } @@ -531,7 +531,7 @@ impl Backend { // toggle the previous sender if let Some(current) = self.inner.test_contract_address.take() { self.remove_persistent_account(¤t); - self.revoke_cheatcode_access(acc); + self.revoke_cheatcode_access(&acc); } self.add_persistent_account(acc); @@ -1363,8 +1363,9 @@ impl DatabaseExt for Backend { Ok(()) } - fn is_persistent(&self, acc: &Address) -> bool { - self.inner.persistent_accounts.contains(acc) + fn add_persistent_account(&mut self, account: Address) -> bool { + trace!(?account, "add persistent account"); + self.inner.persistent_accounts.insert(account) } fn remove_persistent_account(&mut self, account: &Address) -> bool { @@ -1372,9 +1373,8 @@ impl DatabaseExt for Backend { self.inner.persistent_accounts.remove(account) } - fn add_persistent_account(&mut self, account: Address) -> bool { - trace!(?account, "add persistent account"); - self.inner.persistent_accounts.insert(account) + fn is_persistent(&self, acc: &Address) -> bool { + self.inner.persistent_accounts.contains(acc) } fn allow_cheatcode_access(&mut self, account: Address) -> bool { @@ -1382,13 +1382,13 @@ impl DatabaseExt for Backend { self.inner.cheatcode_access_accounts.insert(account) } - fn revoke_cheatcode_access(&mut self, account: Address) -> bool { + fn revoke_cheatcode_access(&mut self, account: &Address) -> bool { trace!(?account, "revoke cheatcode access"); - self.inner.cheatcode_access_accounts.remove(&account) + self.inner.cheatcode_access_accounts.remove(account) } - fn has_cheatcode_access(&self, account: Address) -> bool { - self.inner.cheatcode_access_accounts.contains(&account) + fn has_cheatcode_access(&self, account: &Address) -> bool { + self.inner.cheatcode_access_accounts.contains(account) } } From 77332d6442bd12b9ee6af92c922b59afdb5362ca Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:27:23 +0200 Subject: [PATCH 0654/1963] chore: add tracing to gas reports (#7185) --- crates/forge/src/gas_report.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 9d416e36ff1c2..afe41f76dfa51 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -109,25 +109,27 @@ impl GasReport { /// Finalizes the gas report by calculating the min, max, mean, and median for each function. #[must_use] pub fn finalize(mut self) -> Self { - self.contracts.iter_mut().for_each(|(_, contract)| { - contract.functions.iter_mut().for_each(|(_, sigs)| { - sigs.iter_mut().for_each(|(_, func)| { + trace!("finalizing gas report"); + for contract in self.contracts.values_mut() { + for sigs in contract.functions.values_mut() { + for func in sigs.values_mut() { func.calls.sort_unstable(); func.min = func.calls.first().copied().unwrap_or_default(); func.max = func.calls.last().copied().unwrap_or_default(); func.mean = calc::mean(&func.calls); - func.median = calc::median_sorted(func.calls.as_slice()); - }); - }); - }); + func.median = calc::median_sorted(&func.calls); + } + } + } self } } impl Display for GasReport { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - for (name, contract) in self.contracts.iter() { + for (name, contract) in &self.contracts { if contract.functions.is_empty() { + trace!(name, "gas report contract without functions"); continue } From 644e31e7631394814a7d872e7fbde26a786baa51 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 12:33:30 +0200 Subject: [PATCH 0655/1963] feat(cast): add `wallet sign --no-hash` (#7180) * feat(cast): add `wallet sign --no-hash` * doc * doc --- crates/cast/bin/cmd/wallet/mod.rs | 22 +++++++++------ crates/wallets/src/error.rs | 2 ++ crates/wallets/src/wallet.rs | 45 ++++++++----------------------- 3 files changed, 27 insertions(+), 42 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index acf578dc02bbb..cbbd3e8d9fb9d 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -78,12 +78,13 @@ pub enum WalletSubcommands { /// Sign a message or typed data. #[clap(visible_alias = "s")] Sign { - /// The message or typed data to sign. + /// The message, typed data, or hash to sign. + /// + /// Messages starting with 0x are expected to be hex encoded, which get decoded before + /// being signed. /// - /// Messages starting with 0x are expected to be hex encoded, - /// which get decoded before being signed. /// The message will be prefixed with the Ethereum Signed Message header and hashed before - /// signing. + /// signing, unless `--no-hash` is provided. /// /// Typed data can be provided as a json string or a file name. /// Use --data flag to denote the message is a string of typed data. @@ -92,15 +93,18 @@ pub enum WalletSubcommands { /// The data should be formatted as JSON. message: String, - /// If provided, the message will be treated as typed data. + /// Treat the message as JSON typed data. #[clap(long)] data: bool, - /// If provided, the message will be treated as a file name containing typed data. Requires - /// --data. + /// Treat the message as a file containing JSON typed data. Requires `--data`. #[clap(long, requires = "data")] from_file: bool, + /// Treat the message as a raw 32-byte hash and sign it directly without hashing it again. + #[clap(long, conflicts_with = "data")] + no_hash: bool, + #[clap(flatten)] wallet: Wallet, }, @@ -247,7 +251,7 @@ impl WalletSubcommands { let addr = wallet.address(); println!("{}", addr.to_alloy().to_checksum(None)); } - WalletSubcommands::Sign { message, data, from_file, wallet } => { + WalletSubcommands::Sign { message, data, from_file, no_hash, wallet } => { let wallet = wallet.signer(0).await?; let sig = if data { let typed_data: TypedData = if from_file { @@ -258,6 +262,8 @@ impl WalletSubcommands { serde_json::from_str(&message)? }; wallet.sign_typed_data(&typed_data).await? + } else if no_hash { + wallet.sign_hash(&message.parse()?).await? } else { wallet.sign_message(Self::hex_str_to_bytes(&message)?).await? }; diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index 6e6bb5f145db9..788c04db59119 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -19,4 +19,6 @@ pub enum WalletSignerError { Trezor(#[from] TrezorError), #[error(transparent)] Aws(#[from] AwsSignerError), + #[error("{0} cannot sign raw hashes")] + CannotSignRawHash(&'static str), } diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 1f40b980fe74c..640b7f99ce707 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -2,7 +2,7 @@ use crate::{ error::{PrivateKeyError, WalletSignerError}, raw_wallet::RawWallet, }; -use alloy_primitives::Address; +use alloy_primitives::{Address, B256}; use async_trait::async_trait; use clap::Parser; use ethers_core::types::{ @@ -457,39 +457,16 @@ impl Signer for WalletSigner { } } -#[async_trait] -impl Signer for &WalletSigner { - type Error = WalletSignerError; - - async fn sign_message>( - &self, - message: S, - ) -> Result { - (*self).sign_message(message).await - } - - async fn sign_transaction(&self, message: &TypedTransaction) -> Result { - (*self).sign_transaction(message).await - } - - async fn sign_typed_data( - &self, - payload: &T, - ) -> Result { - (*self).sign_typed_data(payload).await - } - - fn address(&self) -> ethers_core::types::Address { - (*self).address() - } - - fn chain_id(&self) -> u64 { - (*self).chain_id() - } - - fn with_chain_id>(self, chain_id: T) -> Self { - let _ = chain_id; - self +impl WalletSigner { + pub async fn sign_hash(&self, hash: &B256) -> Result { + match self { + // TODO: AWS can sign hashes but utilities aren't exposed in ethers-signers. + // TODO: Implement with alloy-signer. + Self::Aws(_aws) => Err(WalletSignerError::CannotSignRawHash("AWS")), + Self::Ledger(_) => Err(WalletSignerError::CannotSignRawHash("Ledger")), + Self::Local(wallet) => wallet.sign_hash(hash.0.into()).map_err(Into::into), + Self::Trezor(_) => Err(WalletSignerError::CannotSignRawHash("Trezor")), + } } } From 746321ae9f231c108b9aa0bcde669b35cd46b24a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 20 Feb 2024 14:46:22 +0100 Subject: [PATCH 0656/1963] fix: include base fee per gas for next block (#7188) --- crates/anvil/src/eth/api.rs | 53 ++++++++++++++++++++---------------- crates/anvil/src/eth/fees.rs | 17 ++++++------ crates/anvil/src/lib.rs | 6 ++++ 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index b7ed87e3c4f10..93d705f0bbf20 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1304,8 +1304,6 @@ impl EthApi { return Err(FeeHistoryError::InvalidBlockRange.into()); } - let fee_history = self.fee_history_cache.lock(); - let mut response = FeeHistory { oldest_block: U256::from(lowest), base_fee_per_gas: Vec::new(), @@ -1314,30 +1312,34 @@ impl EthApi { base_fee_per_blob_gas: Default::default(), blob_gas_used_ratio: Default::default(), }; - let mut rewards = Vec::new(); - // iter over the requested block range - for n in lowest..=highest { - // - if let Some(block) = fee_history.get(&n) { - response.base_fee_per_gas.push(U256::from(block.base_fee)); - response.gas_used_ratio.push(block.gas_used_ratio); - - // requested percentiles - if !reward_percentiles.is_empty() { - let mut block_rewards = Vec::new(); - let resolution_per_percentile: f64 = 2.0; - for p in &reward_percentiles { - let p = p.clamp(0.0, 100.0); - let index = ((p.round() / 2f64) * 2f64) * resolution_per_percentile; - let reward = if let Some(r) = block.rewards.get(index as usize) { - U256::from(*r) - } else { - U256::ZERO - }; - block_rewards.push(reward); + + { + let fee_history = self.fee_history_cache.lock(); + + // iter over the requested block range + for n in lowest..=highest { + // + if let Some(block) = fee_history.get(&n) { + response.base_fee_per_gas.push(U256::from(block.base_fee)); + response.gas_used_ratio.push(block.gas_used_ratio); + + // requested percentiles + if !reward_percentiles.is_empty() { + let mut block_rewards = Vec::new(); + let resolution_per_percentile: f64 = 2.0; + for p in &reward_percentiles { + let p = p.clamp(0.0, 100.0); + let index = ((p.round() / 2f64) * 2f64) * resolution_per_percentile; + let reward = if let Some(r) = block.rewards.get(index as usize) { + U256::from(*r) + } else { + U256::ZERO + }; + block_rewards.push(reward); + } + rewards.push(block_rewards); } - rewards.push(block_rewards); } } } @@ -1345,6 +1347,9 @@ impl EthApi { response.reward = Some(rewards); // calculate next base fee + // The spec states that `base_fee_per_gas` "[..] includes the next block after the + // newest of the returned range, because this value can be derived from the + // newest block" if let (Some(last_gas_used), Some(last_fee_per_gas)) = (response.gas_used_ratio.last(), response.base_fee_per_gas.last()) { diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index d71f8463c4ca8..4f341858b5e30 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -198,12 +198,15 @@ impl FeeHistoryService { self.fee_history_limit } + /// Inserts a new cache entry for the given block + pub(crate) fn insert_cache_entry_for_block(&self, hash: B256) { + let (result, block_number) = self.create_cache_entry(hash); + self.insert_cache_entry(result, block_number); + } + /// Create a new history entry for the block - fn create_cache_entry( - &self, - hash: B256, - elasticity: f64, - ) -> (FeeHistoryCacheItem, Option) { + fn create_cache_entry(&self, hash: B256) -> (FeeHistoryCacheItem, Option) { + let elasticity = self.fees.elasticity(); // percentile list from 0.0 to 100.0 with a 0.5 resolution. // this will create 200 percentile points let reward_percentiles: Vec = { @@ -315,11 +318,9 @@ impl Future for FeeHistoryService { while let Poll::Ready(Some(notification)) = pin.new_blocks.poll_next_unpin(cx) { let hash = notification.hash; - let elasticity = default_elasticity(); // add the imported block. - let (result, block_number) = pin.create_cache_entry(hash, elasticity); - pin.insert_cache_entry(result, block_number) + pin.insert_cache_entry_for_block(hash); } Poll::Pending diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index d2503410f0e65..23a328d7a8b9f 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -145,6 +145,12 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { fees, StorageInfo::new(Arc::clone(&backend)), ); + // create an entry for the best block + if let Some(best_block) = + backend.get_block(backend.best_number()).map(|block| block.header.hash_slow()) + { + fee_history_service.insert_cache_entry_for_block(best_block); + } let filters = Filters::default(); From ce585d220d0f6d86a5b7d83fe37eec2a0dde04fd Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:09:32 +0200 Subject: [PATCH 0657/1963] fix: --watch short arg detection (#7189) --- crates/forge/bin/cmd/watch.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index fce58df37e710..f2ca664be30ad 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -264,6 +264,8 @@ fn watch_command(mut args: Vec) -> Command { fn cmd_args(num: usize) -> Vec { clean_cmd_args(num, std::env::args().collect()) } + +#[instrument(level = "debug", ret)] fn clean_cmd_args(num: usize, mut cmd_args: Vec) -> Vec { if let Some(pos) = cmd_args.iter().position(|arg| arg == "--watch" || arg == "-w") { cmd_args.drain(pos..=(pos + num)); @@ -274,11 +276,12 @@ fn clean_cmd_args(num: usize, mut cmd_args: Vec) -> Vec { // this removes any `w` from concatenated short flags if let Some(pos) = cmd_args.iter().position(|arg| { fn contains_w_in_short(arg: &str) -> Option { - let mut iter = arg.chars(); - if iter.next()? != '-' { + let mut iter = arg.chars().peekable(); + if *iter.peek()? != '-' { return None } - if iter.next()? == '-' { + iter.next(); + if *iter.peek()? == '-' { return None } Some(iter.any(|c| c == 'w')) From 371dd415561eb970710db64096cce3eb7ed5078d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:23:53 +0200 Subject: [PATCH 0658/1963] fix(chisel): correct some FixedBytes expressions' types (#7190) --- crates/chisel/src/executor.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 1a425d3f2e8f2..81cf22d83994d 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -787,7 +787,7 @@ impl Type { // Array / bytes members let ty = Self::Builtin(ty); match access.as_str() { - "length" if ty.is_dynamic() || ty.is_array() => { + "length" if ty.is_dynamic() || ty.is_array() || ty.is_fixed_bytes() => { return Self::Builtin(DynSolType::Uint(256)) } "pop" if ty.is_dynamic_array() => return ty, @@ -1187,9 +1187,9 @@ impl Type { Some(DynSolType::Array(inner)) | Some(DynSolType::FixedArray(inner, _)) => { Some(*inner) } - Some(DynSolType::Bytes) | Some(DynSolType::String) => { - Some(DynSolType::FixedBytes(1)) - } + Some(DynSolType::Bytes) | + Some(DynSolType::String) | + Some(DynSolType::FixedBytes(_)) => Some(DynSolType::FixedBytes(1)), ty => ty, } } @@ -1229,6 +1229,10 @@ impl Type { fn is_dynamic_array(&self) -> bool { matches!(self, Self::Array(_) | Self::Builtin(DynSolType::Array(_))) } + + fn is_fixed_bytes(&self) -> bool { + matches!(self, Self::Builtin(DynSolType::FixedBytes(_))) + } } /// Returns Some if the custom type is a function member access From 19fdd038f05fab3095575d633360d15ee73a600e Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 20 Feb 2024 21:39:26 +0400 Subject: [PATCH 0659/1963] refactor: wallet management (#7141) * refactor foundry-wallets * Use MultiWallet in cheats * Add comments * clippy + fmt * maybe_load_private_key * fmt * fix ci * clippy * refactor * Wallet -> WalletOpts * rm blank lines * Review fixes * fix comment * comments * review fixes * clippy * fixes * fmt --- Cargo.lock | 4 +- crates/cast/bin/cmd/send.rs | 6 +- crates/cast/bin/cmd/wallet/mod.rs | 33 +- crates/cheatcodes/Cargo.toml | 2 + crates/cheatcodes/src/config.rs | 9 +- crates/cheatcodes/src/error.rs | 2 + crates/cheatcodes/src/inspector.rs | 8 +- crates/cheatcodes/src/lib.rs | 1 + crates/cheatcodes/src/script.rs | 74 +++- crates/cheatcodes/src/utils.rs | 8 +- crates/chisel/src/executor.rs | 8 +- crates/cli/src/opts/ethereum.rs | 10 +- crates/evm/evm/Cargo.toml | 1 - crates/evm/evm/src/executors/mod.rs | 27 +- crates/evm/evm/src/inspectors/stack.rs | 8 - crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/create.rs | 6 +- crates/forge/bin/cmd/script/broadcast.rs | 53 ++- crates/forge/bin/cmd/script/cmd.rs | 87 +++-- crates/forge/bin/cmd/script/executor.rs | 17 +- crates/forge/bin/cmd/script/mod.rs | 6 +- crates/forge/bin/cmd/script/multi.rs | 8 +- crates/forge/bin/cmd/script/runner.rs | 31 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/tests/it/config.rs | 2 +- crates/wallets/Cargo.toml | 3 + crates/wallets/src/error.rs | 4 + crates/wallets/src/lib.rs | 9 +- crates/wallets/src/multi_wallet.rs | 383 +++++++++---------- crates/wallets/src/raw_wallet.rs | 25 +- crates/wallets/src/utils.rs | 156 ++++++++ crates/wallets/src/wallet.rs | 462 ++++------------------- crates/wallets/src/wallet_signer.rs | 190 ++++++++++ 33 files changed, 866 insertions(+), 781 deletions(-) create mode 100644 crates/wallets/src/utils.rs create mode 100644 crates/wallets/src/wallet_signer.rs diff --git a/Cargo.lock b/Cargo.lock index 337c5f061a593..422ebd05ae4f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2981,10 +2981,12 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm-core", + "foundry-wallets", "itertools 0.11.0", "jsonpath_lib", "k256", "p256", + "parking_lot", "revm", "serde_json", "thiserror", @@ -3183,7 +3185,6 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-rpc-types", - "alloy-signer", "alloy-sol-types", "const-hex", "eyre", @@ -3360,6 +3361,7 @@ dependencies = [ "rusoto_kms", "serde", "thiserror", + "tokio", "tracing", ] diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index b79bf1d7cd9bd..b68ba5c7566d6 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -1,7 +1,7 @@ use cast::{Cast, TxBuilder}; use clap::Parser; use ethers_core::types::NameOrAddress; -use ethers_middleware::MiddlewareBuilder; +use ethers_middleware::SignerMiddleware; use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::Result; @@ -170,7 +170,7 @@ impl SendTxArgs { // enough information to sign and we must bail. } else { // Retrieve the signer, and bail if it can't be constructed. - let signer = eth.wallet.signer(chain.id()).await?; + let signer = eth.wallet.signer().await?; let from = signer.address(); // prevent misconfigured hwlib from sending a transaction that defies @@ -191,7 +191,7 @@ corresponds to the sender, or let foundry automatically detect it by not specify tx.nonce = Some(provider.get_transaction_count(from, None).await?.to_alloy()); } - let provider = provider.with_signer(signer); + let provider = SignerMiddleware::new_with_provider_chain(provider, signer).await?; cast_send( provider, diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index cbbd3e8d9fb9d..5850c523a368d 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -9,7 +9,7 @@ use ethers_signers::Signer; use eyre::{Context, Result}; use foundry_common::{fs, types::ToAlloy}; use foundry_config::Config; -use foundry_wallets::{RawWallet, Wallet}; +use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner}; use rand::thread_rng; use serde_json::json; use std::{path::Path, str::FromStr}; @@ -72,7 +72,7 @@ pub enum WalletSubcommands { private_key_override: Option, #[clap(flatten)] - wallet: Wallet, + wallet: WalletOpts, }, /// Sign a message or typed data. @@ -106,7 +106,7 @@ pub enum WalletSubcommands { no_hash: bool, #[clap(flatten)] - wallet: Wallet, + wallet: WalletOpts, }, /// Verify the signature of a message. @@ -133,7 +133,7 @@ pub enum WalletSubcommands { #[clap(long, short)] keystore_dir: Option, #[clap(flatten)] - raw_wallet_options: RawWallet, + raw_wallet_options: RawWalletOpts, }, /// List all the accounts in the keystore default directory #[clap(visible_alias = "ls")] @@ -241,18 +241,18 @@ impl WalletSubcommands { } WalletSubcommands::Address { wallet, private_key_override } => { let wallet = private_key_override - .map(|pk| Wallet { - raw: RawWallet { private_key: Some(pk), ..Default::default() }, + .map(|pk| WalletOpts { + raw: RawWalletOpts { private_key: Some(pk), ..Default::default() }, ..Default::default() }) .unwrap_or(wallet) - .signer(0) + .signer() .await?; let addr = wallet.address(); println!("{}", addr.to_alloy().to_checksum(None)); } WalletSubcommands::Sign { message, data, from_file, no_hash, wallet } => { - let wallet = wallet.signer(0).await?; + let wallet = wallet.signer().await?; let sig = if data { let typed_data: TypedData = if from_file { // data is a file name, read json from file @@ -297,16 +297,21 @@ impl WalletSubcommands { } // get wallet - let wallet: Wallet = raw_wallet_options.into(); - let wallet = wallet.try_resolve_local_wallet()?.ok_or_else(|| { - eyre::eyre!( - "\ + let wallet = raw_wallet_options + .signer()? + .and_then(|s| match s { + WalletSigner::Local(s) => Some(s), + _ => None, + }) + .ok_or_else(|| { + eyre::eyre!( + "\ Did you set a private key or mnemonic? Run `cast wallet import --help` and use the corresponding CLI flag to set your key via: --private-key, --mnemonic-path or --interactive." - ) - })?; + ) + })?; let private_key = wallet.signer().to_bytes(); let password = rpassword::prompt_password("Enter password: ")?; diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 4c2e69a364839..00cfaf7c39cf9 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -17,6 +17,7 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm-core.workspace = true +foundry-wallets.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true @@ -26,6 +27,7 @@ alloy-sol-types.workspace = true alloy-providers.workspace = true alloy-rpc-types.workspace = true alloy-signer = { workspace = true, features = ["mnemonic", "keystore"] } +parking_lot = "0.12" eyre.workspace = true diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 85b2dcaab61f6..1fdb9d4abc807 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -1,5 +1,5 @@ use super::Result; -use crate::Vm::Rpc; +use crate::{script::ScriptWallets, Vm::Rpc}; use alloy_primitives::Address; use foundry_common::fs::normalize_path; use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; @@ -36,11 +36,13 @@ pub struct CheatsConfig { pub evm_opts: EvmOpts, /// Address labels from config pub labels: HashMap, + /// Script wallets + pub script_wallets: Option, } impl CheatsConfig { /// Extracts the necessary settings from the Config - pub fn new(config: &Config, evm_opts: EvmOpts) -> Self { + pub fn new(config: &Config, evm_opts: EvmOpts, script_wallets: Option) -> Self { let mut allowed_paths = vec![config.__root.0.clone()]; allowed_paths.extend(config.libs.clone()); allowed_paths.extend(config.allow_paths.clone()); @@ -58,6 +60,7 @@ impl CheatsConfig { allowed_paths, evm_opts, labels: config.labels.clone(), + script_wallets, } } @@ -172,6 +175,7 @@ impl Default for CheatsConfig { allowed_paths: vec![], evm_opts: Default::default(), labels: Default::default(), + script_wallets: None, } } } @@ -185,6 +189,7 @@ mod tests { CheatsConfig::new( &Config { __root: PathBuf::from(root).into(), fs_permissions, ..Default::default() }, Default::default(), + None, ) } diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 19475982f3ede..66796026d5675 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -5,6 +5,7 @@ use alloy_sol_types::SolError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; use foundry_evm_core::backend::DatabaseError; +use foundry_wallets::error::WalletSignerError; use k256::ecdsa::signature::Error as SignatureError; use std::{borrow::Cow, fmt}; @@ -298,6 +299,7 @@ impl_from!( UnresolvedEnvVarError, WalletError, SignerError, + WalletSignerError, ); #[cfg(test)] diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 7341bb6b18dbb..50b5093ba6920 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -7,7 +7,7 @@ use crate::{ prank::Prank, DealRecord, RecordAccess, }, - script::Broadcast, + script::{Broadcast, ScriptWallets}, test::expect::{ self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, ExpectedRevert, ExpectedRevertKind, @@ -16,7 +16,6 @@ use crate::{ }; use alloy_primitives::{Address, Bytes, B256, U256, U64}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; -use alloy_signer::LocalWallet; use alloy_sol_types::{SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl}; use foundry_evm_core::{ @@ -127,7 +126,7 @@ pub struct Cheatcodes { pub labels: HashMap, /// Remembered private keys - pub script_wallets: Vec, + pub script_wallets: Option, /// Prank information pub prank: Option, @@ -218,7 +217,8 @@ impl Cheatcodes { #[inline] pub fn new(config: Arc) -> Self { let labels = config.labels.clone(); - Self { config, fs_commit: true, labels, ..Default::default() } + let script_wallets = config.script_wallets.clone(); + Self { config, fs_commit: true, labels, script_wallets, ..Default::default() } } fn apply_cheatcode( diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index caaef1d8fee45..86cfb0e5d00b4 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -36,6 +36,7 @@ mod string; mod test; mod utils; +pub use script::ScriptWallets; pub use test::expect::ExpectedCallTracker; /// Cheatcode implementation. diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 820d3ffd9a18f..62a7518372579 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -2,8 +2,11 @@ use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, U256}; -use alloy_signer::Signer; +use alloy_signer::{LocalWallet, Signer}; use foundry_config::Config; +use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; +use parking_lot::Mutex; +use std::sync::Arc; impl Cheatcode for broadcast_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { @@ -72,6 +75,44 @@ pub struct Broadcast { pub single_call: bool, } +/// Contains context for wallet management. +#[derive(Debug)] +pub struct ScriptWalletsInner { + /// All signers in scope of the script. + pub multi_wallet: MultiWallet, + /// Optional signer provided as `--sender` flag. + pub provided_sender: Option
, +} + +/// Clonable wrapper around [ScriptWalletsInner]. +#[derive(Debug, Clone)] +pub struct ScriptWallets { + /// Inner data. + pub inner: Arc>, +} + +impl ScriptWallets { + #[allow(missing_docs)] + pub fn new(multi_wallet: MultiWallet, provided_sender: Option
) -> Self { + Self { inner: Arc::new(Mutex::new(ScriptWalletsInner { multi_wallet, provided_sender })) } + } + + /// Consumes [ScriptWallets] and returns [MultiWallet]. + /// + /// Panics if [ScriptWallets] is still in use. + pub fn into_multi_wallet(self) -> MultiWallet { + Arc::into_inner(self.inner) + .map(|m| m.into_inner().multi_wallet) + .unwrap_or_else(|| panic!("not all instances were dropped")) + } + + /// Locks inner Mutex and adds a signer to the [MultiWallet]. + pub fn add_signer(&self, private_key: impl AsRef<[u8]>) -> Result { + self.inner.lock().multi_wallet.add_signer(WalletSigner::from_private_key(private_key)?); + Ok(Default::default()) + } +} + /// Sets up broadcasting from a script using `new_origin` as the sender. fn broadcast( ccx: &mut CheatsCtxt, @@ -86,8 +127,25 @@ fn broadcast( correct_sender_nonce(ccx)?; + let mut new_origin = new_origin.cloned(); + + if new_origin.is_none() { + if let Some(script_wallets) = &ccx.state.script_wallets { + let mut script_wallets = script_wallets.inner.lock(); + if let Some(provided_sender) = script_wallets.provided_sender { + new_origin = Some(provided_sender); + } else { + let signers = script_wallets.multi_wallet.signers()?; + if signers.len() == 1 { + let address = signers.keys().next().unwrap(); + new_origin = Some(*address); + } + } + } + } + let broadcast = Broadcast { - new_origin: *new_origin.unwrap_or(&ccx.data.env.tx.caller), + new_origin: new_origin.unwrap_or(ccx.data.env.tx.caller), original_caller: ccx.caller, original_origin: ccx.data.env.tx.caller, depth: ccx.data.journaled_state.depth(), @@ -106,13 +164,15 @@ fn broadcast_key( private_key: &U256, single_call: bool, ) -> Result { - let mut wallet = super::utils::parse_wallet(private_key)?; - wallet.set_chain_id(Some(ccx.data.env.cfg.chain_id)); - let new_origin = &wallet.address(); + let key = super::utils::parse_private_key(private_key)?; + let new_origin = LocalWallet::from(key.clone()).address(); + + let result = broadcast(ccx, Some(&new_origin), single_call); - let result = broadcast(ccx, Some(new_origin), single_call); if result.is_ok() { - ccx.state.script_wallets.push(wallet); + if let Some(script_wallets) = &ccx.state.script_wallets { + script_wallets.add_signer(key.to_bytes())?; + } } result } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 9cfeee276b59a..525120d7de8f0 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -87,9 +87,11 @@ impl Cheatcode for deriveKey_3Call { impl Cheatcode for rememberKeyCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; - let wallet = parse_wallet(privateKey)?.with_chain_id(Some(ccx.data.env.cfg.chain_id)); - let address = wallet.address(); - ccx.state.script_wallets.push(wallet); + let key = parse_private_key(privateKey)?; + let address = LocalWallet::from(key.clone()).address(); + if let Some(script_wallets) = &ccx.state.script_wallets { + script_wallets.add_signer(key.to_bytes())?; + } Ok(address.abi_encode()) } } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 81cf22d83994d..0953df29933bb 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -305,8 +305,12 @@ impl SessionSource { let executor = ExecutorBuilder::new() .inspectors(|stack| { stack.chisel_state(final_pc).trace(true).cheatcodes( - CheatsConfig::new(&self.config.foundry_config, self.config.evm_opts.clone()) - .into(), + CheatsConfig::new( + &self.config.foundry_config, + self.config.evm_opts.clone(), + None, + ) + .into(), ) }) .gas_limit(self.config.evm_opts.gas_limit()) diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 9a1d8653bf476..62cebeaec73f9 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -9,7 +9,7 @@ use foundry_config::{ }, impl_figment_convert_cast, Chain, Config, }; -use foundry_wallets::{Wallet, WalletSigner}; +use foundry_wallets::WalletOpts; use serde::Serialize; use std::borrow::Cow; @@ -150,17 +150,11 @@ pub struct EthereumOpts { pub etherscan: EtherscanOpts, #[clap(flatten)] - pub wallet: Wallet, + pub wallet: WalletOpts, } impl_figment_convert_cast!(EthereumOpts); -impl EthereumOpts { - pub async fn signer(&self) -> Result { - self.wallet.signer(self.etherscan.chain.unwrap_or_default().id()).await - } -} - // Make this args a `Figment` so that it can be merged into the `Config` impl figment::Provider for EthereumOpts { fn metadata(&self) -> Metadata { diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 9ea7dd0fa51e5..33e491e113d70 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -25,7 +25,6 @@ alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true alloy-rpc-types.workspace = true -alloy-signer.workspace = true hashbrown = { version = "0.14", features = ["serde"] } revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 76d00b80b2b71..628bc502ebb68 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -12,7 +12,6 @@ use crate::inspectors::{ use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log, U256}; -use alloy_signer::LocalWallet; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; use foundry_evm_core::{ backend::{Backend, DatabaseError, DatabaseExt, DatabaseResult, FuzzBackendWrapper}, @@ -204,7 +203,6 @@ impl Executor { labels: res.labels, state_changeset: None, transactions: None, - script_wallets: res.script_wallets, }))) } } @@ -372,7 +370,6 @@ impl Executor { labels, traces, debug, - script_wallets, env, coverage, .. @@ -400,7 +397,6 @@ impl Executor { labels, state_changeset: None, transactions: None, - script_wallets }))); } } @@ -418,7 +414,6 @@ impl Executor { labels, state_changeset: None, transactions: None, - script_wallets, }))) } }; @@ -595,7 +590,6 @@ pub struct ExecutionErr { pub labels: HashMap, pub transactions: Option, pub state_changeset: Option, - pub script_wallets: Vec, } #[derive(Debug, thiserror::Error)] @@ -666,8 +660,6 @@ pub struct CallResult { /// This is only present if the changed state was not committed to the database (i.e. if you /// used `call` and `call_raw` not `call_committing` or `call_raw_committing`). pub state_changeset: Option, - /// The wallets added during the call using the `rememberKey` cheatcode - pub script_wallets: Vec, /// The `revm::Env` after the call pub env: Env, /// breakpoints @@ -711,8 +703,6 @@ pub struct RawCallResult { /// This is only present if the changed state was not committed to the database (i.e. if you /// used `call` and `call_raw` not `call_committing` or `call_raw_committing`). pub state_changeset: Option, - /// The wallets added during the call using the `rememberKey` cheatcode - pub script_wallets: Vec, /// The `revm::Env` after the call pub env: Env, /// The cheatcode states after execution @@ -740,7 +730,6 @@ impl Default for RawCallResult { debug: None, transactions: None, state_changeset: None, - script_wallets: Vec::new(), env: Default::default(), cheatcodes: Default::default(), out: None, @@ -782,16 +771,8 @@ fn convert_executed_result( _ => Bytes::new(), }; - let InspectorData { - logs, - labels, - traces, - coverage, - debug, - cheatcodes, - script_wallets, - chisel_state, - } = inspector.collect(); + let InspectorData { logs, labels, traces, coverage, debug, cheatcodes, chisel_state } = + inspector.collect(); let transactions = match cheatcodes.as_ref() { Some(cheats) if !cheats.broadcastable_transactions.is_empty() => { @@ -815,7 +796,6 @@ fn convert_executed_result( debug, transactions, state_changeset: Some(state_changeset), - script_wallets, env, cheatcodes, out, @@ -842,7 +822,6 @@ fn convert_call_result( debug, transactions, state_changeset, - script_wallets, env, .. } = call_result; @@ -875,7 +854,6 @@ fn convert_call_result( debug, transactions, state_changeset, - script_wallets, env, breakpoints, skipped: false, @@ -898,7 +876,6 @@ fn convert_call_result( labels, transactions, state_changeset, - script_wallets, }))) } } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 6ece0f2da4ff9..a1fc13d706190 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -3,7 +3,6 @@ use super::{ StackSnapshotType, TracePrinter, TracingInspector, TracingInspectorConfig, }; use alloy_primitives::{Address, Bytes, Log, B256, U256}; -use alloy_signer::LocalWallet; use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; @@ -189,7 +188,6 @@ pub struct InspectorData { pub debug: Option, pub coverage: Option, pub cheatcodes: Option, - pub script_wallets: Vec, pub chisel_state: Option<(Stack, Vec, InstructionResult)>, } @@ -316,12 +314,6 @@ impl InspectorStack { traces: self.tracer.map(|tracer| tracer.get_traces().clone()), debug: self.debugger.map(|debugger| debugger.arena), coverage: self.coverage.map(|coverage| coverage.maps), - #[allow(clippy::useless_asref)] // https://github.com/rust-lang/rust-clippy/issues/12135 - script_wallets: self - .cheatcodes - .as_ref() - .map(|cheatcodes| cheatcodes.script_wallets.clone()) - .unwrap_or_default(), cheatcodes: self.cheatcodes, chisel_state: self.chisel_state.and_then(|state| state.state), } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 7b674138a3b95..9d2bef5e0edf1 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -303,7 +303,7 @@ impl CoverageArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone())) + .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone(), None)) .with_test_options(TestOptions { fuzz: config.fuzz, invariant: config.invariant, diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 77deb356ac25f..8c4752603bdcd 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -11,7 +11,7 @@ use ethers_core::{ TransactionReceipt, TransactionRequest, }, }; -use ethers_middleware::MiddlewareBuilder; +use ethers_middleware::SignerMiddleware; use ethers_providers::Middleware; use eyre::{Context, Result}; use foundry_cli::{ @@ -145,8 +145,8 @@ impl CreateArgs { self.deploy(abi, bin, params, provider, chain_id).await } else { // Deploy with signer - let signer = self.eth.wallet.signer(chain_id).await?; - let provider = provider.with_signer(signer); + let signer = self.eth.wallet.signer().await?; + let provider = SignerMiddleware::new_with_provider_chain(provider, signer).await?; self.deploy(abi, bin, params, provider, chain_id).await } } diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 49717cc9724e8..a7ab056332ad8 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -6,7 +6,7 @@ use super::{ use alloy_primitives::{utils::format_units, Address, TxHash, U256}; use ethers_core::types::transaction::eip2718::TypedTransaction; use ethers_providers::{JsonRpcClient, Middleware, Provider}; -use ethers_signers::{LocalWallet, Signer}; +use ethers_signers::Signer; use eyre::{bail, Context, ContextCompat, Result}; use forge::{inspectors::cheatcodes::BroadcastableTransactions, traces::CallTraceDecoder}; use foundry_cli::{ @@ -38,7 +38,7 @@ impl ScriptArgs { &self, deployment_sequence: &mut ScriptSequence, fork_url: &str, - script_wallets: &[LocalWallet], + signers: &HashMap, ) -> Result<()> { let provider = Arc::new(try_get_http_provider(fork_url)?); let already_broadcasted = deployment_sequence.receipts.len(); @@ -64,12 +64,34 @@ impl ScriptArgs { ); (SendTransactionsKind::Unlocked(senders), chain.as_u64()) } else { - let local_wallets = self - .wallets - .find_all(provider.clone(), required_addresses, script_wallets) - .await?; - let chain = local_wallets.values().last().wrap_err("Error accessing local wallet when trying to send onchain transaction, did you set a private key, mnemonic or keystore?")?.chain_id(); - (SendTransactionsKind::Raw(local_wallets), chain) + let mut missing_addresses = Vec::new(); + + println!("\n###\nFinding wallets for all the necessary addresses..."); + for addr in &required_addresses { + if !signers.contains_key(addr) { + missing_addresses.push(addr); + } + } + + if !missing_addresses.is_empty() { + let mut error_msg = String::new(); + + // This is an actual used address + if required_addresses.contains(&Config::DEFAULT_SENDER) { + error_msg += "\nYou seem to be using Foundry's default sender. Be sure to set your own --sender.\n"; + } + + eyre::bail!( + "{}No associated wallet for addresses: {:?}. Unlocked wallets: {:?}", + error_msg, + missing_addresses, + signers.keys().collect::>() + ); + } + + let chain = provider.get_chainid().await?.as_u64(); + + (SendTransactionsKind::Raw(signers), chain) }; // We only wait for a transaction receipt before sending the next transaction, if there @@ -280,6 +302,7 @@ impl ScriptArgs { decoder: &CallTraceDecoder, mut script_config: ScriptConfig, verify: VerifyBundle, + signers: &HashMap, ) -> Result<()> { if let Some(txs) = result.transactions.take() { script_config.collect_rpcs(&txs); @@ -315,8 +338,8 @@ impl ScriptArgs { multi, libraries, &script_config.config, - result.script_wallets, verify, + signers, ) .await?; } @@ -325,8 +348,8 @@ impl ScriptArgs { deployments.first_mut().expect("missing deployment"), script_config, libraries, - result, verify, + signers, ) .await?; } @@ -347,8 +370,8 @@ impl ScriptArgs { deployment_sequence: &mut ScriptSequence, script_config: ScriptConfig, libraries: Libraries, - result: ScriptResult, verify: VerifyBundle, + signers: &HashMap, ) -> Result<()> { trace!(target: "script", "broadcasting single chain deployment"); @@ -360,7 +383,7 @@ impl ScriptArgs { deployment_sequence.add_libraries(libraries); - self.send_transactions(deployment_sequence, &rpc, &result.script_wallets).await?; + self.send_transactions(deployment_sequence, &rpc, signers).await?; if self.verify { return deployment_sequence.verify_contracts(&script_config.config, verify).await; @@ -639,14 +662,14 @@ enum SendTransactionKind<'a> { } /// Represents how to send _all_ transactions -enum SendTransactionsKind { +enum SendTransactionsKind<'a> { /// Send via `eth_sendTransaction` and rely on the `from` address being unlocked. Unlocked(HashSet
), /// Send a signed transaction via `eth_sendRawTransaction` - Raw(HashMap), + Raw(&'a HashMap), } -impl SendTransactionsKind { +impl SendTransactionsKind<'_> { /// Returns the [`SendTransactionKind`] for the given address /// /// Returns an error if no matching signer is found or the address is not unlocked diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 69032462d3e79..c1e0fefb0de3a 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -17,8 +17,9 @@ use foundry_compilers::{ contracts::ArtifactContracts, }; use foundry_debugger::Debugger; -use foundry_evm::inspectors::cheatcodes::BroadcastableTransaction; -use std::sync::Arc; +use foundry_evm::inspectors::cheatcodes::{BroadcastableTransaction, ScriptWallets}; +use foundry_wallets::WalletSigner; +use std::{collections::HashMap, sync::Arc}; /// Helper alias type for the collection of data changed due to the new sender. type NewSenderChanges = (CallTraceDecoder, Libraries, ArtifactContracts); @@ -38,7 +39,9 @@ impl ScriptArgs { ..Default::default() }; - self.maybe_load_private_key(&mut script_config)?; + if let Some(sender) = self.maybe_load_private_key()? { + script_config.evm_opts.sender = sender; + } if let Some(ref fork_url) = script_config.evm_opts.fork_url { // when forking, override the sender's nonce to the onchain value @@ -72,13 +75,24 @@ impl ScriptArgs { // Execute once with default sender. let sender = script_config.evm_opts.sender; + let multi_wallet = self.wallets.get_multi_wallet().await?; + let script_wallets = ScriptWallets::new(multi_wallet, self.evm_opts.sender); + // We need to execute the script even if just resuming, in case we need to collect private // keys from the execution. - let mut result = - self.execute(&mut script_config, contract, sender, &predeploy_libraries).await?; + let mut result = self + .execute( + &mut script_config, + contract, + sender, + &predeploy_libraries, + script_wallets.clone(), + ) + .await?; if self.resume || (self.verify && !self.broadcast) { - return self.resume_deployment(script_config, linker, libraries, result, verify).await; + let signers = script_wallets.into_multi_wallet().into_signers()?; + return self.resume_deployment(script_config, linker, libraries, verify, &signers).await; } let known_contracts = flatten_contracts(&highlevel_known_contracts, true); @@ -95,7 +109,13 @@ impl ScriptArgs { } if let Some((new_traces, updated_libraries, updated_contracts)) = self - .maybe_prepare_libraries(&mut script_config, linker, predeploy_libraries, &mut result) + .maybe_prepare_libraries( + &mut script_config, + linker, + predeploy_libraries, + &mut result, + script_wallets.clone(), + ) .await? { decoder = new_traces; @@ -112,8 +132,17 @@ impl ScriptArgs { verify.known_contracts = flatten_contracts(&highlevel_known_contracts, false); self.check_contract_sizes(&result, &highlevel_known_contracts)?; - self.handle_broadcastable_transactions(result, libraries, &decoder, script_config, verify) - .await + let signers = script_wallets.into_multi_wallet().into_signers()?; + + self.handle_broadcastable_transactions( + result, + libraries, + &decoder, + script_config, + verify, + &signers, + ) + .await } // In case there are libraries to be deployed, it makes sure that these are added to the list of @@ -124,6 +153,7 @@ impl ScriptArgs { linker: Linker, predeploy_libraries: Vec, result: &mut ScriptResult, + script_wallets: ScriptWallets, ) -> Result> { if let Some(new_sender) = self.maybe_new_sender( &script_config.evm_opts, @@ -131,8 +161,9 @@ impl ScriptArgs { &predeploy_libraries, )? { // We have a new sender, so we need to relink all the predeployed libraries. - let (libraries, highlevel_known_contracts) = - self.rerun_with_new_deployer(script_config, new_sender, result, linker).await?; + let (libraries, highlevel_known_contracts) = self + .rerun_with_new_deployer(script_config, new_sender, result, linker, script_wallets) + .await?; // redo traces for the new addresses let new_traces = self.decode_traces( @@ -171,8 +202,8 @@ impl ScriptArgs { script_config: ScriptConfig, linker: Linker, libraries: Libraries, - result: ScriptResult, verify: VerifyBundle, + signers: &HashMap, ) -> Result<()> { if self.multi { return self @@ -184,16 +215,16 @@ impl ScriptArgs { )?, libraries, &script_config.config, - result.script_wallets, verify, + signers, ) .await; } self.resume_single_deployment( script_config, linker, - result, verify, + signers, ) .await .map_err(|err| { @@ -206,8 +237,8 @@ impl ScriptArgs { &mut self, script_config: ScriptConfig, linker: Linker, - result: ScriptResult, mut verify: VerifyBundle, + signers: &HashMap, ) -> Result<()> { trace!(target: "script", "resuming single deployment"); @@ -249,8 +280,7 @@ impl ScriptArgs { receipts::wait_for_pending(provider, &mut deployment_sequence).await?; if self.resume { - self.send_transactions(&mut deployment_sequence, fork_url, &result.script_wallets) - .await?; + self.send_transactions(&mut deployment_sequence, fork_url, signers).await?; } if self.verify { @@ -287,6 +317,7 @@ impl ScriptArgs { new_sender: Address, first_run_result: &mut ScriptResult, linker: Linker, + script_wallets: ScriptWallets, ) -> Result<(Libraries, ArtifactContracts)> { // if we had a new sender that requires relinking, we need to // get the nonce mainnet for accurate addresses for predeploy libs @@ -318,8 +349,9 @@ impl ScriptArgs { &script_config.evm_opts.fork_url, ); - let result = - self.execute(script_config, contract, new_sender, &predeploy_libraries).await?; + let result = self + .execute(script_config, contract, new_sender, &predeploy_libraries, script_wallets) + .await?; if let Some(new_txs) = &result.transactions { for new_tx in new_txs.iter() { @@ -338,15 +370,12 @@ impl ScriptArgs { /// In case the user has loaded *only* one private-key, we can assume that he's using it as the /// `--sender` - fn maybe_load_private_key(&mut self, script_config: &mut ScriptConfig) -> Result<()> { - if let Some(ref private_key) = self.wallets.private_key { - self.wallets.private_keys = Some(vec![private_key.clone()]); - } - if let Some(wallets) = self.wallets.private_keys()? { - if wallets.len() == 1 { - script_config.evm_opts.sender = wallets.first().unwrap().address().to_alloy() - } - } - Ok(()) + fn maybe_load_private_key(&mut self) -> Result> { + let maybe_sender = self + .wallets + .private_keys()? + .filter(|pks| pks.len() == 1) + .map(|pks| pks.first().unwrap().address().to_alloy()); + Ok(maybe_sender) } } diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index ac86c112a4ead..e0f8ed8ece1bc 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -15,6 +15,7 @@ use forge::{ use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{get_contract_name, provider::ethers::RpcUrl, shell, ContractsByArtifact}; use foundry_compilers::artifacts::ContractBytecodeSome; +use foundry_evm::inspectors::cheatcodes::ScriptWallets; use futures::future::join_all; use parking_lot::RwLock; use std::{ @@ -31,6 +32,7 @@ impl ScriptArgs { contract: ContractBytecodeSome, sender: Address, predeploy_libraries: &[Bytes], + script_wallets: ScriptWallets, ) -> Result { trace!(target: "script", "start executing script"); @@ -42,7 +44,9 @@ impl ScriptArgs { ensure_clean_constructor(&abi)?; - let mut runner = self.prepare_runner(script_config, sender, SimulationStage::Local).await?; + let mut runner = self + .prepare_runner(script_config, sender, SimulationStage::Local, Some(script_wallets)) + .await?; let (address, mut result) = runner.setup( predeploy_libraries, bytecode, @@ -66,7 +70,6 @@ impl ScriptArgs { result.debug = script_result.debug; result.labeled_addresses.extend(script_result.labeled_addresses); result.returned = script_result.returned; - result.script_wallets.extend(script_result.script_wallets); result.breakpoints = script_result.breakpoints; match (&mut result.transactions, script_result.transactions) { @@ -252,7 +255,7 @@ impl ScriptArgs { let mut script_config = script_config.clone(); script_config.evm_opts.fork_url = Some(rpc.clone()); let runner = self - .prepare_runner(&mut script_config, sender, SimulationStage::OnChain) + .prepare_runner(&mut script_config, sender, SimulationStage::OnChain, None) .await?; Ok((rpc.clone(), runner)) }) @@ -267,6 +270,7 @@ impl ScriptArgs { script_config: &mut ScriptConfig, sender: Address, stage: SimulationStage, + script_wallets: Option, ) -> Result { trace!("preparing script runner"); let env = script_config.evm_opts.evm_env().await?; @@ -300,7 +304,12 @@ impl ScriptArgs { if let SimulationStage::Local = stage { builder = builder.inspectors(|stack| { stack.debug(self.debug).cheatcodes( - CheatsConfig::new(&script_config.config, script_config.evm_opts.clone()).into(), + CheatsConfig::new( + &script_config.config, + script_config.evm_opts.clone(), + script_wallets, + ) + .into(), ) }); } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 17ff7e569238e..5df893bb0ed5b 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -6,7 +6,6 @@ use alloy_rpc_types::request::TransactionRequest; use clap::{Parser, ValueHint}; use dialoguer::Confirm; use ethers_providers::{Http, Middleware}; -use ethers_signers::LocalWallet; use eyre::{ContextCompat, Result, WrapErr}; use forge::{ backend::Backend, @@ -43,7 +42,7 @@ use foundry_evm::{ decode::RevertDecoder, inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, }; -use foundry_wallets::MultiWallet; +use foundry_wallets::MultiWalletOpts; use futures::future; use itertools::Itertools; use serde::{Deserialize, Serialize}; @@ -177,7 +176,7 @@ pub struct ScriptArgs { pub opts: BuildArgs, #[clap(flatten)] - pub wallets: MultiWallet, + pub wallets: MultiWalletOpts, #[clap(flatten)] pub evm_opts: EvmArgs, @@ -593,7 +592,6 @@ pub struct ScriptResult { pub transactions: Option, pub returned: Bytes, pub address: Option
, - pub script_wallets: Vec, pub breakpoints: Breakpoints, } diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs index ab8cd64cbb01d..874dd24ba6363 100644 --- a/crates/forge/bin/cmd/script/multi.rs +++ b/crates/forge/bin/cmd/script/multi.rs @@ -4,15 +4,17 @@ use super::{ verify::VerifyBundle, ScriptArgs, }; -use ethers_signers::LocalWallet; +use alloy_primitives::Address; use eyre::{ContextCompat, Report, Result, WrapErr}; use foundry_cli::utils::now; use foundry_common::{fs, provider::ethers::get_http_provider}; use foundry_compilers::{artifacts::Libraries, ArtifactId}; use foundry_config::Config; +use foundry_wallets::WalletSigner; use futures::future::join_all; use serde::{Deserialize, Serialize}; use std::{ + collections::HashMap, io::{BufWriter, Write}, path::{Path, PathBuf}, sync::Arc, @@ -179,8 +181,8 @@ impl ScriptArgs { mut deployments: MultiChainSequence, libraries: Libraries, config: &Config, - script_wallets: Vec, verify: VerifyBundle, + signers: &HashMap, ) -> Result<()> { if !libraries.is_empty() { eyre::bail!("Libraries are currently not supported on multi deployment setups."); @@ -219,7 +221,7 @@ impl ScriptArgs { for sequence in deployments.deployments.iter_mut() { let rpc_url = sequence.rpc_url().unwrap().to_string(); - let result = match self.send_transactions(sequence, &rpc_url, &script_wallets).await { + let result = match self.send_transactions(sequence, &rpc_url, signers).await { Ok(_) if self.verify => sequence.verify_contracts(config, verify.clone()).await, Ok(_) => Ok(()), Err(err) => Err(err), diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 838dcfdf34b74..96937bfdbc972 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -7,7 +7,6 @@ use forge::{ revm::interpreter::{return_ok, InstructionResult}, traces::{TraceKind, Traces}, }; -use foundry_common::types::ToEthers; use foundry_config::Config; use yansi::Paint; @@ -93,17 +92,9 @@ impl ScriptRunner { traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); // Optionally call the `setUp` function - let (success, gas_used, labeled_addresses, transactions, debug, script_wallets) = if !setup - { + let (success, gas_used, labeled_addresses, transactions, debug) = if !setup { self.executor.backend.set_test_contract(address); - ( - true, - 0, - Default::default(), - None, - vec![constructor_debug].into_iter().collect(), - vec![], - ) + (true, 0, Default::default(), None, vec![constructor_debug].into_iter().collect()) } else { match self.executor.setup(Some(self.sender), address) { Ok(CallResult { @@ -114,7 +105,6 @@ impl ScriptRunner { debug, gas_used, transactions, - script_wallets, .. }) => { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); @@ -128,7 +118,6 @@ impl ScriptRunner { labels, transactions, vec![constructor_debug, debug].into_iter().collect(), - script_wallets, ) } Err(EvmError::Execution(err)) => { @@ -140,7 +129,6 @@ impl ScriptRunner { debug, gas_used, transactions, - script_wallets, .. } = *err; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); @@ -154,7 +142,6 @@ impl ScriptRunner { labels, transactions, vec![constructor_debug, debug].into_iter().collect(), - script_wallets, ) } Err(e) => return Err(e.into()), @@ -173,7 +160,6 @@ impl ScriptRunner { traces, debug, address: None, - script_wallets: script_wallets.to_ethers(), ..Default::default() }, )) @@ -279,17 +265,7 @@ impl ScriptRunner { res = self.executor.call_raw_committing(from, to, calldata, value)?; } - let RawCallResult { - result, - reverted, - logs, - traces, - labels, - debug, - transactions, - script_wallets, - .. - } = res; + let RawCallResult { result, reverted, logs, traces, labels, debug, transactions, .. } = res; let breakpoints = res.cheatcodes.map(|cheats| cheats.breakpoints).unwrap_or_default(); Ok(ScriptResult { @@ -308,7 +284,6 @@ impl ScriptRunner { labeled_addresses: labels, transactions, address: None, - script_wallets: script_wallets.to_ethers(), breakpoints, }) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 102f93e31ef17..4f0f9f29940a9 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -195,7 +195,7 @@ impl TestArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone())) + .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone(), None)) .with_test_options(test_options.clone()) .build(project_root, output, env, evm_opts)?; diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 22c01f67e155d..04f58234fcf4f 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -178,7 +178,7 @@ pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { let output = COMPILED.clone(); base_runner() .with_test_options(test_opts()) - .with_cheats_config(CheatsConfig::new(&config, opts.clone())) + .with_cheats_config(CheatsConfig::new(&config, opts.clone(), None)) .sender(config.sender) .build(root, output, env, opts.clone()) .unwrap() diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index f531fd343ce63..501d0777f0fb5 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -32,6 +32,9 @@ serde.workspace = true thiserror = "1" tracing.workspace = true +[dev-dependencies] +tokio = { version = "1", features = ["macros"] } + [features] default = ["rustls"] rustls = ["ethers-providers/rustls", "rusoto_core/rustls"] diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index 788c04db59119..6588f5e22cc17 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -19,6 +19,10 @@ pub enum WalletSignerError { Trezor(#[from] TrezorError), #[error(transparent)] Aws(#[from] AwsSignerError), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error(transparent)] + InvalidHex(#[from] FromHexError), #[error("{0} cannot sign raw hashes")] CannotSignRawHash(&'static str), } diff --git a/crates/wallets/src/lib.rs b/crates/wallets/src/lib.rs index 0e17c4ced3bec..38ff5e7fa91a0 100644 --- a/crates/wallets/src/lib.rs +++ b/crates/wallets/src/lib.rs @@ -4,8 +4,11 @@ extern crate tracing; pub mod error; pub mod multi_wallet; pub mod raw_wallet; +pub mod utils; pub mod wallet; +pub mod wallet_signer; -pub use multi_wallet::MultiWallet; -pub use raw_wallet::RawWallet; -pub use wallet::{Wallet, WalletSigner}; +pub use multi_wallet::MultiWalletOpts; +pub use raw_wallet::RawWalletOpts; +pub use wallet::WalletOpts; +pub use wallet_signer::{PendingSigner, WalletSigner}; diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index 4b7280731e5f8..21692eb047948 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -1,63 +1,80 @@ -use crate::wallet::{WalletSigner, WalletTrait}; +use crate::{ + utils, + wallet_signer::{PendingSigner, WalletSigner}, +}; use alloy_primitives::Address; use clap::Parser; -use ethers_providers::Middleware; -use ethers_signers::{ - AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, Signer, Trezor, TrezorHDPath, -}; -use eyre::{Context, ContextCompat, Result}; -use foundry_common::{provider::ethers::RetryProvider, types::ToAlloy}; +use ethers_signers::Signer; +use eyre::Result; +use foundry_common::types::ToAlloy; use foundry_config::Config; -use itertools::izip; -use rusoto_core::{ - credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, - request::HttpClient as AwsHttpClient, Client as AwsClient, -}; -use rusoto_kms::KmsClient; use serde::Serialize; -use std::{ - collections::{HashMap, HashSet}, - iter::repeat, - sync::Arc, -}; +use std::{collections::HashMap, iter::repeat, path::PathBuf}; -macro_rules! get_wallets { - ($id:ident, [ $($wallets:expr),+ ], $call:expr) => { - $( - if let Some($id) = $wallets { - $call; - } - )+ - }; +/// Container for multiple wallets. +#[derive(Debug, Default)] +pub struct MultiWallet { + /// Vector of wallets that require an action to be unlocked. + /// Those are lazily unlocked on the first access of the signers. + pending_signers: Vec, + /// Contains unlocked signers. + signers: HashMap, +} + +impl MultiWallet { + pub fn new(pending_signers: Vec, signers: Vec) -> Self { + let signers = + signers.into_iter().map(|signer| (signer.address().to_alloy(), signer)).collect(); + Self { pending_signers, signers } + } + + fn maybe_unlock_pending(&mut self) -> Result<()> { + for pending in self.pending_signers.drain(..) { + let signer = pending.unlock()?; + self.signers.insert(signer.address().to_alloy(), signer); + } + Ok(()) + } + + pub fn signers(&mut self) -> Result<&HashMap> { + self.maybe_unlock_pending()?; + Ok(&self.signers) + } + + pub fn into_signers(mut self) -> Result> { + self.maybe_unlock_pending()?; + Ok(self.signers) + } + + pub fn add_signer(&mut self, signer: WalletSigner) { + self.signers.insert(signer.address().to_alloy(), signer); + } } /// A macro that initializes multiple wallets /// /// Should be used with a [`MultiWallet`] instance macro_rules! create_hw_wallets { - ($self:ident, $chain_id:ident ,$get_wallet:ident, $wallets:ident) => { - let mut $wallets = vec![]; + ($self:ident, $create_signer:expr, $signers:ident) => { + let mut $signers = vec![]; if let Some(hd_paths) = &$self.hd_paths { for path in hd_paths { - if let Some(hw) = $self.$get_wallet($chain_id, Some(path), None).await? { - $wallets.push(hw); - } + let hw = $create_signer(Some(path), 0).await?; + $signers.push(hw); } } if let Some(mnemonic_indexes) = &$self.mnemonic_indexes { for index in mnemonic_indexes { - if let Some(hw) = $self.$get_wallet($chain_id, None, Some(*index as usize)).await? { - $wallets.push(hw); - } + let hw = $create_signer(None, *index).await?; + $signers.push(hw); } } - if $wallets.is_empty() { - if let Some(hw) = $self.$get_wallet($chain_id, None, Some(0)).await? { - $wallets.push(hw); - } + if $signers.is_empty() { + let hw = $create_signer(None, 0).await?; + $signers.push(hw); } }; } @@ -72,7 +89,7 @@ macro_rules! create_hw_wallets { /// 7. AWS KMS #[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Wallet options", about = None, long_about = None)] -pub struct MultiWallet { +pub struct MultiWalletOpts { /// The sender accounts. #[clap( long, @@ -197,91 +214,72 @@ pub struct MultiWallet { pub aws: bool, } -impl WalletTrait for MultiWallet { - fn sender(&self) -> Option
{ - self.froms.as_ref()?.first().copied() - } -} +impl MultiWalletOpts { + /// Returns [MultiWallet] container configured with provided options. + pub async fn get_multi_wallet(&self) -> Result { + let mut pending = Vec::new(); + let mut signers: Vec = Vec::new(); -impl MultiWallet { - /// Given a list of addresses, it finds all the associated wallets if they exist. Throws an - /// error, if it can't find all. - pub async fn find_all( - &self, - provider: Arc, - mut addresses: HashSet
, - script_wallets: &[LocalWallet], - ) -> Result> { - println!("\n###\nFinding wallets for all the necessary addresses..."); - let chain = provider.get_chainid().await?.as_u64(); - - let mut local_wallets = HashMap::new(); - let mut unused_wallets = vec![]; - - get_wallets!( - wallets, - [ - self.trezors(chain).await?, - self.ledgers(chain).await?, - self.private_keys()?, - self.interactives()?, - self.mnemonics()?, - self.keystores()?, - self.aws_signers(chain).await?, - (!script_wallets.is_empty()).then(|| script_wallets.to_vec()) - ], - for wallet in wallets.into_iter() { - let address = wallet.address(); - if addresses.contains(&address.to_alloy()) { - addresses.remove(&address.to_alloy()); - - let signer = WalletSigner::from(wallet.with_chain_id(chain)); - local_wallets.insert(address.to_alloy(), signer); - - if addresses.is_empty() { - return Ok(local_wallets); - } - } else { - // Just to show on error. - unused_wallets.push(address.to_alloy()); - } - } - ); - - let mut error_msg = String::new(); - - // This is an actual used address - if addresses.contains(&Config::DEFAULT_SENDER) { - error_msg += "\nYou seem to be using Foundry's default sender. Be sure to set your own --sender.\n"; + if let Some(ledgers) = self.ledgers().await? { + signers.extend(ledgers); + } + if let Some(trezors) = self.trezors().await? { + signers.extend(trezors); + } + if let Some(aws_signers) = self.aws_signers().await? { + signers.extend(aws_signers); + } + if let Some((pending_keystores, unlocked)) = self.keystores()? { + pending.extend(pending_keystores); + signers.extend(unlocked); + } + if let Some(pks) = self.private_keys()? { + signers.extend(pks); + } + if let Some(mnemonics) = self.mnemonics()? { + signers.extend(mnemonics); + } + if self.interactives > 0 { + pending.extend(repeat(PendingSigner::Interactive).take(self.interactives as usize)); } - unused_wallets.extend(local_wallets.into_keys()); - eyre::bail!( - "{}No associated wallet for addresses: {:?}. Unlocked wallets: {:?}", - error_msg, - addresses, - unused_wallets - ) + Ok(MultiWallet::new(pending, signers)) } - pub fn interactives(&self) -> Result>> { - if self.interactives != 0 { - let mut wallets = vec![]; - for _ in 0..self.interactives { - wallets.push(self.get_from_interactive()?); + pub fn private_keys(&self) -> Result>> { + let mut pks = vec![]; + if let Some(private_key) = &self.private_key { + pks.push(private_key); + } + if let Some(private_keys) = &self.private_keys { + for pk in private_keys { + pks.push(pk); } - return Ok(Some(wallets)); } - Ok(None) + if !pks.is_empty() { + let wallets = pks + .into_iter() + .map(|pk| utils::create_private_key_signer(pk)) + .collect::>>()?; + Ok(Some(wallets)) + } else { + Ok(None) + } } - pub fn private_keys(&self) -> Result>> { - if let Some(private_keys) = &self.private_keys { - let mut wallets = vec![]; - for private_key in private_keys.iter() { - wallets.push(self.get_from_private_key(private_key.trim())?); - } - return Ok(Some(wallets)); + fn keystore_paths(&self) -> Result>> { + if let Some(keystore_paths) = &self.keystore_paths { + return Ok(Some(keystore_paths.iter().map(PathBuf::from).collect())); + } + if let Some(keystore_account_names) = &self.keystore_account_names { + let default_keystore_dir = Config::foundry_keystores_dir() + .ok_or_else(|| eyre::eyre!("Could not find the default keystore directory."))?; + return Ok(Some( + keystore_account_names + .iter() + .map(|keystore_name| default_keystore_dir.join(keystore_name)) + .collect(), + )); } Ok(None) } @@ -289,23 +287,10 @@ impl MultiWallet { /// Returns all wallets read from the provided keystores arguments /// /// Returns `Ok(None)` if no keystore provided. - pub fn keystores(&self) -> Result>> { - let default_keystore_dir = Config::foundry_keystores_dir() - .ok_or_else(|| eyre::eyre!("Could not find the default keystore directory."))?; - // If keystore paths are provided, use them, else, use default path + keystore account names - let keystore_paths = self.keystore_paths.clone().or_else(|| { - self.keystore_account_names.as_ref().map(|keystore_names| { - keystore_names - .iter() - .map(|keystore_name| { - default_keystore_dir.join(keystore_name).to_string_lossy().into_owned() - }) - .collect() - }) - }); - - if let Some(keystore_paths) = keystore_paths { - let mut wallets = Vec::with_capacity(keystore_paths.len()); + pub fn keystores(&self) -> Result, Vec)>> { + if let Some(keystore_paths) = self.keystore_paths()? { + let mut pending = Vec::new(); + let mut signers = Vec::new(); let mut passwords_iter = self.keystore_passwords.clone().unwrap_or_default().into_iter(); @@ -313,51 +298,49 @@ impl MultiWallet { let mut password_files_iter = self.keystore_password_files.clone().unwrap_or_default().into_iter(); - for path in keystore_paths { - let wallet = self.get_from_keystore(Some(&path), passwords_iter.next().as_ref(), password_files_iter.next().as_ref())?.wrap_err("Keystore paths do not have the same length as provided passwords or password files.")?; - wallets.push(wallet); + for path in &keystore_paths { + let (maybe_signer, maybe_pending) = utils::create_keystore_signer( + path, + passwords_iter.next().as_deref(), + password_files_iter.next().as_deref(), + )?; + if let Some(pending_signer) = maybe_pending { + pending.push(pending_signer); + } else if let Some(signer) = maybe_signer { + signers.push(signer); + } } - return Ok(Some(wallets)); + return Ok(Some((pending, signers))); } Ok(None) } - pub fn mnemonics(&self) -> Result>> { + pub fn mnemonics(&self) -> Result>> { if let Some(ref mnemonics) = self.mnemonics { let mut wallets = vec![]; - let hd_paths: Vec<_> = if let Some(ref hd_paths) = self.hd_paths { - hd_paths.iter().map(Some).collect() - } else { - repeat(None).take(mnemonics.len()).collect() - }; - let mnemonic_passphrases: Vec<_> = - if let Some(ref mnemonic_passphrases) = self.mnemonic_passphrases { - mnemonic_passphrases.iter().map(Some).collect() - } else { - repeat(None).take(mnemonics.len()).collect() - }; - let mnemonic_indexes: Vec<_> = if let Some(ref mnemonic_indexes) = self.mnemonic_indexes - { - mnemonic_indexes.to_vec() - } else { - repeat(0).take(mnemonics.len()).collect() - }; - for (mnemonic, mnemonic_passphrase, hd_path, mnemonic_index) in - izip!(mnemonics, mnemonic_passphrases, hd_paths, mnemonic_indexes) - { - wallets.push(self.get_from_mnemonic( + + let mut hd_paths_iter = self.hd_paths.clone().unwrap_or_default().into_iter(); + + let mut passphrases_iter = + self.mnemonic_passphrases.clone().unwrap_or_default().into_iter(); + + let mut indexes_iter = self.mnemonic_indexes.clone().unwrap_or_default().into_iter(); + + for mnemonic in mnemonics { + let wallet = utils::create_mnemonic_signer( mnemonic, - mnemonic_passphrase, - hd_path, - mnemonic_index, - )?) + passphrases_iter.next().as_deref(), + hd_paths_iter.next().as_deref(), + indexes_iter.next().unwrap_or(0), + )?; + wallets.push(wallet); } return Ok(Some(wallets)); } Ok(None) } - pub async fn ledgers(&self, chain_id: u64) -> Result>> { + pub async fn ledgers(&self) -> Result>> { if self.ledger { let mut args = self.clone(); @@ -368,34 +351,31 @@ impl MultiWallet { args.mnemonic_indexes = None; } - create_hw_wallets!(args, chain_id, get_from_ledger, wallets); + create_hw_wallets!(args, utils::create_ledger_signer, wallets); return Ok(Some(wallets)); } Ok(None) } - pub async fn trezors(&self, chain_id: u64) -> Result>> { + pub async fn trezors(&self) -> Result>> { if self.trezor { - create_hw_wallets!(self, chain_id, get_from_trezor, wallets); + create_hw_wallets!(self, utils::create_trezor_signer, wallets); return Ok(Some(wallets)); } Ok(None) } - pub async fn aws_signers(&self, chain_id: u64) -> Result>> { + pub async fn aws_signers(&self) -> Result>> { if self.aws { let mut wallets = vec![]; - let client = - AwsClient::new_with(AwsChainProvider::default(), AwsHttpClient::new().unwrap()); - - let kms = KmsClient::new_with_client(client, AwsRegion::default()); - - let env_key_ids = std::env::var("AWS_KMS_KEY_IDS"); - let key_ids = - if env_key_ids.is_ok() { env_key_ids? } else { std::env::var("AWS_KMS_KEY_ID")? }; - - for key in key_ids.split(',') { - let aws_signer = AwsSigner::new(kms.clone(), key, chain_id).await?; + let aws_keys = std::env::var("AWS_KMS_KEY_IDS") + .or(std::env::var("AWS_KMS_KEY_ID"))? + .split(',') + .map(|k| k.to_string()) + .collect::>(); + + for key in aws_keys { + let aws_signer = WalletSigner::from_aws(&key).await?; wallets.push(aws_signer) } @@ -403,50 +383,23 @@ impl MultiWallet { } Ok(None) } - - async fn get_from_trezor( - &self, - chain_id: u64, - hd_path: Option<&str>, - mnemonic_index: Option, - ) -> Result> { - let derivation = match &hd_path { - Some(hd_path) => TrezorHDPath::Other(hd_path.to_string()), - None => TrezorHDPath::TrezorLive(mnemonic_index.unwrap_or(0)), - }; - - Ok(Some(Trezor::new(derivation, chain_id, None).await?)) - } - - async fn get_from_ledger( - &self, - chain_id: u64, - hd_path: Option<&str>, - mnemonic_index: Option, - ) -> Result> { - let derivation = match hd_path { - Some(hd_path) => LedgerHDPath::Other(hd_path.to_string()), - None => LedgerHDPath::LedgerLive(mnemonic_index.unwrap_or(0)), - }; - - trace!(?chain_id, "Creating new ledger signer"); - Ok(Some(Ledger::new(derivation, chain_id).await.wrap_err("Ledger device not available.")?)) - } } #[cfg(test)] mod tests { + use ethers_signers::Signer; + use super::*; use std::path::Path; #[test] fn parse_keystore_args() { - let args: MultiWallet = - MultiWallet::parse_from(["foundry-cli", "--keystores", "my/keystore/path"]); + let args: MultiWalletOpts = + MultiWalletOpts::parse_from(["foundry-cli", "--keystores", "my/keystore/path"]); assert_eq!(args.keystore_paths, Some(vec!["my/keystore/path".to_string()])); std::env::set_var("ETH_KEYSTORE", "MY_KEYSTORE"); - let args: MultiWallet = MultiWallet::parse_from(["foundry-cli"]); + let args: MultiWalletOpts = MultiWalletOpts::parse_from(["foundry-cli"]); assert_eq!(args.keystore_paths, Some(vec!["MY_KEYSTORE".to_string()])); std::env::remove_var("ETH_KEYSTORE"); @@ -461,7 +414,7 @@ mod tests { let keystore_password_file = keystore.join("password-ec554").into_os_string(); - let args: MultiWallet = MultiWallet::parse_from([ + let args: MultiWalletOpts = MultiWalletOpts::parse_from([ "foundry-cli", "--keystores", keystore_file.to_str().unwrap(), @@ -473,10 +426,10 @@ mod tests { Some(vec![keystore_password_file.to_str().unwrap().to_string()]) ); - let wallets = args.keystores().unwrap().unwrap(); - assert_eq!(wallets.len(), 1); + let (_, unlocked) = args.keystores().unwrap().unwrap(); + assert_eq!(unlocked.len(), 1); assert_eq!( - wallets[0].address(), + unlocked[0].address(), "ec554aeafe75601aaab43bd4621a22284db566c2".parse().unwrap() ); } @@ -491,7 +444,7 @@ mod tests { ]; for test_case in wallet_options { - let args: MultiWallet = MultiWallet::parse_from([ + let args: MultiWalletOpts = MultiWalletOpts::parse_from([ "foundry-cli", &format!("--{}", test_case.0), test_case.1, diff --git a/crates/wallets/src/raw_wallet.rs b/crates/wallets/src/raw_wallet.rs index e33dc22876c51..ccb1d6388dc10 100644 --- a/crates/wallets/src/raw_wallet.rs +++ b/crates/wallets/src/raw_wallet.rs @@ -1,4 +1,6 @@ +use crate::{utils, PendingSigner, WalletSigner}; use clap::Parser; +use eyre::Result; use serde::Serialize; /// A wrapper for the raw data options for `Wallet`, extracted to also be used standalone. @@ -8,7 +10,7 @@ use serde::Serialize; /// 3. Mnemonic (via file path) #[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Wallet options - raw", about = None, long_about = None)] -pub struct RawWallet { +pub struct RawWalletOpts { /// Open an interactive prompt to enter your private key. #[clap(long, short)] pub interactive: bool, @@ -37,3 +39,24 @@ pub struct RawWallet { #[clap(long, conflicts_with = "hd_path", default_value_t = 0, value_name = "INDEX")] pub mnemonic_index: u32, } + +impl RawWalletOpts { + /// Returns signer configured by provided parameters. + pub fn signer(&self) -> Result> { + if self.interactive { + return Ok(Some(PendingSigner::Interactive.unlock()?)); + } + if let Some(private_key) = &self.private_key { + return Ok(Some(utils::create_private_key_signer(private_key)?)) + } + if let Some(mnemonic) = &self.mnemonic { + return Ok(Some(utils::create_mnemonic_signer( + mnemonic, + self.mnemonic_passphrase.as_deref(), + self.hd_path.as_deref(), + self.mnemonic_index, + )?)) + } + Ok(None) + } +} diff --git a/crates/wallets/src/utils.rs b/crates/wallets/src/utils.rs new file mode 100644 index 0000000000000..a10903313034f --- /dev/null +++ b/crates/wallets/src/utils.rs @@ -0,0 +1,156 @@ +use crate::{error::PrivateKeyError, PendingSigner, WalletSigner}; +use ethers_signers::{HDPath as LedgerHDPath, LocalWallet, TrezorHDPath, WalletError}; +use eyre::{Context, Result}; +use foundry_config::Config; +use std::{ + fs, + path::{Path, PathBuf}, + str::FromStr, +}; + +/// Validates and sanitizes user inputs, returning configured [WalletSigner]. +pub fn create_private_key_signer(private_key: &str) -> Result { + let privk = private_key.trim().strip_prefix("0x").unwrap_or(private_key); + match LocalWallet::from_str(privk) { + Ok(pk) => Ok(WalletSigner::Local(pk)), + Err(err) => { + // helper closure to check if pk was meant to be an env var, this usually happens if + // `$` is missing + let ensure_not_env = |pk: &str| { + // check if pk was meant to be an env var + if !pk.starts_with("0x") && std::env::var(pk).is_ok() { + // SAFETY: at this point we know the user actually wanted to use an env var + // and most likely forgot the `$` anchor, so the + // `private_key` here is an unresolved env var + return Err(PrivateKeyError::ExistsAsEnvVar(pk.to_string())) + } + Ok(()) + }; + match err { + WalletError::HexError(err) => { + ensure_not_env(private_key)?; + return Err(PrivateKeyError::InvalidHex(err).into()); + } + WalletError::EcdsaError(_) => ensure_not_env(private_key)?, + _ => {} + }; + eyre::bail!("Failed to create wallet from private key: {err}") + } + } +} + +/// Creates [WalletSigner] instance from given mnemonic parameters. +/// +/// Mnemonic can be either a file path or a mnemonic phrase. +pub fn create_mnemonic_signer( + mnemonic: &str, + passphrase: Option<&str>, + hd_path: Option<&str>, + index: u32, +) -> Result { + let mnemonic = if Path::new(mnemonic).is_file() { + fs::read_to_string(mnemonic)?.replace('\n', "") + } else { + mnemonic.to_owned() + }; + + Ok(WalletSigner::from_mnemonic(&mnemonic, passphrase, hd_path, index)?) +} + +/// Creates [WalletSigner] instance from given Ledger parameters. +pub async fn create_ledger_signer( + hd_path: Option<&str>, + mnemonic_index: u32, +) -> Result { + let derivation = if let Some(hd_path) = hd_path { + LedgerHDPath::Other(hd_path.to_owned()) + } else { + LedgerHDPath::LedgerLive(mnemonic_index as usize) + }; + + WalletSigner::from_ledger_path(derivation).await.wrap_err_with(|| { + "\ +Could not connect to Ledger device. +Make sure it's connected and unlocked, with no other desktop wallet apps open." + }) +} + +/// Creates [WalletSigner] instance from given Trezor parameters. +pub async fn create_trezor_signer( + hd_path: Option<&str>, + mnemonic_index: u32, +) -> Result { + let derivation = if let Some(hd_path) = hd_path { + TrezorHDPath::Other(hd_path.to_owned()) + } else { + TrezorHDPath::TrezorLive(mnemonic_index as usize) + }; + + WalletSigner::from_trezor_path(derivation).await.wrap_err_with(|| { + "\ +Could not connect to Trezor device. +Make sure it's connected and unlocked, with no other conflicting desktop wallet apps open." + }) +} + +pub fn maybe_get_keystore_path( + maybe_path: Option<&str>, + maybe_name: Option<&str>, +) -> Result> { + let default_keystore_dir = Config::foundry_keystores_dir() + .ok_or_else(|| eyre::eyre!("Could not find the default keystore directory."))?; + Ok(maybe_path + .map(PathBuf::from) + .or_else(|| maybe_name.map(|name| default_keystore_dir.join(name)))) +} + +/// Creates keystore signer from given parameters. +/// +/// If correct password or password file is provided, the keystore is decrypted and a [WalletSigner] +/// is returned. +/// +/// Otherwise, a [PendingSigner] is returned, which can be used to unlock the keystore later, +/// prompting user for password. +pub fn create_keystore_signer( + path: &PathBuf, + maybe_password: Option<&str>, + maybe_password_file: Option<&str>, +) -> Result<(Option, Option)> { + if !path.exists() { + eyre::bail!("Keystore file `{path:?}` does not exist") + } + + if path.is_dir() { + eyre::bail!( + "Keystore path `{path:?}` is a directory. Please specify the keystore file directly." + ) + } + + let password = match (maybe_password, maybe_password_file) { + (Some(password), _) => Ok(Some(password.to_string())), + (_, Some(password_file)) => { + let password_file = Path::new(password_file); + if !password_file.is_file() { + Err(eyre::eyre!("Keystore password file `{password_file:?}` does not exist")) + } else { + Ok(Some( + fs::read_to_string(password_file) + .wrap_err_with(|| { + format!("Failed to read keystore password file at {password_file:?}") + })? + .trim_end() + .to_string(), + )) + } + } + (None, None) => Ok(None), + }?; + + if let Some(password) = password { + let wallet = LocalWallet::decrypt_keystore(path, password) + .wrap_err_with(|| format!("Failed to decrypt keystore {path:?}"))?; + Ok((Some(WalletSigner::Local(wallet)), None)) + } else { + Ok((None, Some(PendingSigner::Keystore(path.clone())))) + } +} diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 640b7f99ce707..a15f805b93fc8 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -1,31 +1,10 @@ -use crate::{ - error::{PrivateKeyError, WalletSignerError}, - raw_wallet::RawWallet, -}; -use alloy_primitives::{Address, B256}; -use async_trait::async_trait; +use crate::{raw_wallet::RawWalletOpts, utils, wallet_signer::WalletSigner}; +use alloy_primitives::Address; use clap::Parser; -use ethers_core::types::{ - transaction::{eip2718::TypedTransaction, eip712::Eip712}, - Signature, -}; -use ethers_signers::{ - coins_bip39::English, AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, MnemonicBuilder, - Signer, Trezor, TrezorHDPath, WalletError, -}; -use eyre::{bail, Result, WrapErr}; -use foundry_common::{fs, types::ToAlloy}; -use foundry_config::Config; -use rusoto_core::{ - credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, - request::HttpClient as AwsHttpClient, Client as AwsClient, -}; -use rusoto_kms::KmsClient; -use serde::{Deserialize, Serialize}; -use std::{ - path::{Path, PathBuf}, - str::FromStr, -}; +use ethers_signers::Signer; +use eyre::Result; +use foundry_common::types::ToAlloy; +use serde::Serialize; /// The wallet options can either be: /// 1. Raw (via private key / mnemonic file, see `RawWallet`) @@ -35,7 +14,7 @@ use std::{ /// 5. AWS KMS #[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Wallet options", about = None, long_about = None)] -pub struct Wallet { +pub struct WalletOpts { /// The sender account. #[clap( long, @@ -47,7 +26,7 @@ pub struct Wallet { pub from: Option
, #[clap(flatten)] - pub raw: RawWallet, + pub raw: RawWalletOpts, /// Use the keystore in the given folder or file. #[clap( @@ -104,118 +83,40 @@ pub struct Wallet { pub aws: bool, } -impl Wallet { - pub fn interactive(&self) -> Result> { - Ok(if self.raw.interactive { Some(self.get_from_interactive()?) } else { None }) - } - - pub fn private_key(&self) -> Result> { - Ok(if let Some(ref private_key) = self.raw.private_key { - Some(self.get_from_private_key(private_key)?) - } else { - None - }) - } - - pub fn keystore(&self) -> Result> { - let default_keystore_dir = Config::foundry_keystores_dir() - .ok_or_else(|| eyre::eyre!("Could not find the default keystore directory."))?; - // If keystore path is provided, use it, otherwise use default path + keystore account name - let keystore_path: Option = self.keystore_path.clone().or_else(|| { - self.keystore_account_name.as_ref().map(|keystore_name| { - default_keystore_dir.join(keystore_name).to_string_lossy().into_owned() - }) - }); - - self.get_from_keystore( - keystore_path.as_ref(), - self.keystore_password.as_ref(), - self.keystore_password_file.as_ref(), - ) - } - - pub fn mnemonic(&self) -> Result> { - Ok(if let Some(ref mnemonic) = self.raw.mnemonic { - Some(self.get_from_mnemonic( - mnemonic, - self.raw.mnemonic_passphrase.as_ref(), - self.raw.hd_path.as_ref(), - self.raw.mnemonic_index, - )?) - } else { - None - }) - } - - /// Returns the sender address of the signer or `from`. - pub async fn sender(&self) -> Address { - if let Ok(signer) = self.signer(0).await { - signer.address().to_alloy() - } else { - self.from.unwrap_or(Address::ZERO) - } - } - - /// Tries to resolve a local wallet from the provided options. - #[track_caller] - pub fn try_resolve_local_wallet(&self) -> Result> { - self.private_key() - .transpose() - .or_else(|| self.interactive().transpose()) - .or_else(|| self.mnemonic().transpose()) - .or_else(|| self.keystore().transpose()) - .transpose() - } - /// Returns a [Signer] corresponding to the provided private key, mnemonic or hardware signer. - #[instrument(skip(self), level = "trace")] - pub async fn signer(&self, chain_id: u64) -> Result { +impl WalletOpts { + pub async fn signer(&self) -> Result { trace!("start finding signer"); - if self.ledger { - let derivation = match self.raw.hd_path.as_ref() { - Some(hd_path) => LedgerHDPath::Other(hd_path.clone()), - None => LedgerHDPath::LedgerLive(self.raw.mnemonic_index as usize), - }; - let ledger = Ledger::new(derivation, chain_id).await.wrap_err_with(|| { - "\ -Could not connect to Ledger device. -Make sure it's connected and unlocked, with no other desktop wallet apps open." - })?; - - Ok(WalletSigner::Ledger(ledger)) + let signer = if self.ledger { + utils::create_ledger_signer(self.raw.hd_path.as_deref(), self.raw.mnemonic_index) + .await? } else if self.trezor { - let derivation = match self.raw.hd_path.as_ref() { - Some(hd_path) => TrezorHDPath::Other(hd_path.clone()), - None => TrezorHDPath::TrezorLive(self.raw.mnemonic_index as usize), - }; - - // cached to ~/.ethers-rs/trezor/cache/trezor.session - let trezor = Trezor::new(derivation, chain_id, None).await.wrap_err_with(|| { - "\ -Could not connect to Trezor device. -Make sure it's connected and unlocked, with no other conflicting desktop wallet apps open." - })?; - - Ok(WalletSigner::Trezor(trezor)) + utils::create_trezor_signer(self.raw.hd_path.as_deref(), self.raw.mnemonic_index) + .await? } else if self.aws { - let client = - AwsClient::new_with(AwsChainProvider::default(), AwsHttpClient::new().unwrap()); - - let kms = KmsClient::new_with_client(client, AwsRegion::default()); - let key_id = std::env::var("AWS_KMS_KEY_ID")?; - - let aws_signer = AwsSigner::new(kms, key_id, chain_id).await?; - - Ok(WalletSigner::Aws(aws_signer)) + WalletSigner::from_aws(&key_id).await? + } else if let Some(raw_wallet) = self.raw.signer()? { + raw_wallet + } else if let Some(path) = utils::maybe_get_keystore_path( + self.keystore_path.as_deref(), + self.keystore_account_name.as_deref(), + )? { + let (maybe_signer, maybe_pending) = utils::create_keystore_signer( + &path, + self.keystore_password.as_deref(), + self.keystore_password_file.as_deref(), + )?; + if let Some(pending) = maybe_pending { + pending.unlock()? + } else if let Some(signer) = maybe_signer { + signer + } else { + unreachable!() + } } else { - trace!("finding local key"); - - let maybe_local = self.try_resolve_local_wallet()?; - - let local = maybe_local.ok_or_else(|| { - eyre::eyre!( - "\ + eyre::bail!( + "\ Error accessing local wallet. Did you set a private key, mnemonic or keystore? Run `cast send --help` or `forge create --help` and use the corresponding CLI flag to set your key via: @@ -223,282 +124,61 @@ flag to set your key via: Alternatively, if you're using a local node with unlocked accounts, use the --unlocked flag and either set the `ETH_FROM` environment variable to the address of the unlocked account you want to use, or provide the --from flag with the address directly." - ) - })?; - - Ok(WalletSigner::Local(local.with_chain_id(chain_id))) - } - } -} - -pub trait WalletTrait { - /// Returns the configured sender. - fn sender(&self) -> Option
; - - fn get_from_interactive(&self) -> Result { - let private_key = rpassword::prompt_password("Enter private key: ")?; - let private_key = private_key.strip_prefix("0x").unwrap_or(&private_key); - Ok(LocalWallet::from_str(private_key)?) - } - - #[track_caller] - fn get_from_private_key(&self, private_key: &str) -> Result { - let privk = private_key.trim().strip_prefix("0x").unwrap_or(private_key); - match LocalWallet::from_str(privk) { - Ok(pk) => Ok(pk), - Err(err) => { - // helper closure to check if pk was meant to be an env var, this usually happens if - // `$` is missing - let ensure_not_env = |pk: &str| { - // check if pk was meant to be an env var - if !pk.starts_with("0x") && std::env::var(pk).is_ok() { - // SAFETY: at this point we know the user actually wanted to use an env var - // and most likely forgot the `$` anchor, so the - // `private_key` here is an unresolved env var - return Err(PrivateKeyError::ExistsAsEnvVar(pk.to_string())) - } - Ok(()) - }; - match err { - WalletError::HexError(err) => { - ensure_not_env(private_key)?; - return Err(PrivateKeyError::InvalidHex(err).into()) - } - WalletError::EcdsaError(_) => { - ensure_not_env(private_key)?; - } - _ => {} - }; - bail!("Failed to create wallet from private key: {err}") - } - } - } - - fn get_from_mnemonic( - &self, - mnemonic: &String, - passphrase: Option<&String>, - derivation_path: Option<&String>, - index: u32, - ) -> Result { - let mnemonic = if Path::new(mnemonic).is_file() { - fs::read_to_string(mnemonic)?.replace('\n', "") - } else { - mnemonic.to_owned() - }; - let builder = MnemonicBuilder::::default().phrase(mnemonic.as_str()); - let builder = if let Some(passphrase) = passphrase { - builder.password(passphrase.as_str()) - } else { - builder - }; - let builder = if let Some(hd_path) = derivation_path { - builder.derivation_path(hd_path.as_str())? - } else { - builder.index(index)? + ) }; - Ok(builder.build()?) - } - - /// Ensures the path to the keystore exists. - /// - /// if the path is a directory, it bails and asks the user to specify the keystore file - /// directly. - fn find_keystore_file(&self, path: impl AsRef) -> Result { - let path = path.as_ref(); - if !path.exists() { - bail!("Keystore file `{path:?}` does not exist") - } - - if path.is_dir() { - bail!("Keystore path `{path:?}` is a directory. Please specify the keystore file directly.") - } - Ok(path.to_path_buf()) + Ok(signer) } - fn get_from_keystore( - &self, - keystore_path: Option<&String>, - keystore_password: Option<&String>, - keystore_password_file: Option<&String>, - ) -> Result> { - Ok(match (keystore_path, keystore_password, keystore_password_file) { - // Path and password provided - (Some(path), Some(password), _) => { - let path = self.find_keystore_file(path)?; - Some( - LocalWallet::decrypt_keystore(&path, password) - .wrap_err_with(|| format!("Failed to decrypt keystore {path:?}"))?, - ) - } - // Path and password file provided - (Some(path), _, Some(password_file)) => { - let path = self.find_keystore_file(path)?; - Some( - LocalWallet::decrypt_keystore(&path, self.password_from_file(password_file)?) - .wrap_err_with(|| format!("Failed to decrypt keystore {path:?} with password file {password_file:?}"))?, - ) - } - // Only Path provided -> interactive - (Some(path), None, None) => { - let path = self.find_keystore_file(path)?; - let password = rpassword::prompt_password("Enter keystore password:")?; - Some(LocalWallet::decrypt_keystore(path, password)?) - } - // Nothing provided - (None, _, _) => None, - }) - } - - /// Attempts to read the keystore password from the password file. - fn password_from_file(&self, password_file: impl AsRef) -> Result { - let password_file = password_file.as_ref(); - if !password_file.is_file() { - bail!("Keystore password file `{password_file:?}` does not exist") + /// Returns the sender address of the signer or `from`. + pub async fn sender(&self) -> Address { + if let Ok(signer) = self.signer().await { + signer.address().to_alloy() + } else { + self.from.unwrap_or(Address::ZERO) } - - Ok(fs::read_to_string(password_file)?.trim_end().to_string()) } } -impl From for Wallet { - fn from(options: RawWallet) -> Self { +impl From for WalletOpts { + fn from(options: RawWalletOpts) -> Self { Self { raw: options, ..Default::default() } } } -impl WalletTrait for Wallet { - fn sender(&self) -> Option
{ - self.from - } -} - -#[derive(Debug)] -pub enum WalletSigner { - Local(LocalWallet), - Ledger(Ledger), - Trezor(Trezor), - Aws(AwsSigner), -} - -impl From for WalletSigner { - fn from(wallet: LocalWallet) -> Self { - Self::Local(wallet) - } -} - -impl From for WalletSigner { - fn from(hw: Ledger) -> Self { - Self::Ledger(hw) - } -} - -impl From for WalletSigner { - fn from(hw: Trezor) -> Self { - Self::Trezor(hw) - } -} - -impl From for WalletSigner { - fn from(wallet: AwsSigner) -> Self { - Self::Aws(wallet) - } -} - -macro_rules! delegate { - ($s:ident, $inner:ident => $e:expr) => { - match $s { - Self::Local($inner) => $e, - Self::Ledger($inner) => $e, - Self::Trezor($inner) => $e, - Self::Aws($inner) => $e, - } - }; -} - -#[async_trait] -impl Signer for WalletSigner { - type Error = WalletSignerError; - - async fn sign_message>( - &self, - message: S, - ) -> Result { - delegate!(self, inner => inner.sign_message(message).await.map_err(Into::into)) - } - - async fn sign_transaction(&self, message: &TypedTransaction) -> Result { - delegate!(self, inner => inner.sign_transaction(message).await.map_err(Into::into)) - } - - async fn sign_typed_data( - &self, - payload: &T, - ) -> Result { - delegate!(self, inner => inner.sign_typed_data(payload).await.map_err(Into::into)) - } - - fn address(&self) -> ethers_core::types::Address { - delegate!(self, inner => inner.address()) - } - - fn chain_id(&self) -> u64 { - delegate!(self, inner => inner.chain_id()) - } - - fn with_chain_id>(self, chain_id: T) -> Self { - match self { - Self::Local(inner) => Self::Local(inner.with_chain_id(chain_id)), - Self::Ledger(inner) => Self::Ledger(inner.with_chain_id(chain_id)), - Self::Trezor(inner) => Self::Trezor(inner.with_chain_id(chain_id)), - Self::Aws(inner) => Self::Aws(inner.with_chain_id(chain_id)), - } - } -} - -impl WalletSigner { - pub async fn sign_hash(&self, hash: &B256) -> Result { - match self { - // TODO: AWS can sign hashes but utilities aren't exposed in ethers-signers. - // TODO: Implement with alloy-signer. - Self::Aws(_aws) => Err(WalletSignerError::CannotSignRawHash("AWS")), - Self::Ledger(_) => Err(WalletSignerError::CannotSignRawHash("Ledger")), - Self::Local(wallet) => wallet.sign_hash(hash.0.into()).map_err(Into::into), - Self::Trezor(_) => Err(WalletSignerError::CannotSignRawHash("Trezor")), - } - } -} - -/// Excerpt of a keystore file. -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct KeystoreFile { - pub address: Address, -} - #[cfg(test)] mod tests { + use std::{path::Path, str::FromStr}; + use super::*; - #[test] - fn find_keystore() { + #[tokio::test] + async fn find_keystore() { let keystore = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../cast/tests/fixtures/keystore")); let keystore_file = keystore - .join("UTC--2022-10-30T06-51-20.130356000Z--560d246fcddc9ea98a8b032c9a2f474efb493c28"); - let wallet: Wallet = Wallet::parse_from([ + .join("UTC--2022-12-20T10-30-43.591916000Z--ec554aeafe75601aaab43bd4621a22284db566c2"); + let password_file = keystore.join("password-ec554"); + let wallet: WalletOpts = WalletOpts::parse_from([ "foundry-cli", "--from", "560d246fcddc9ea98a8b032c9a2f474efb493c28", + "--keystore", + keystore_file.to_str().unwrap(), + "--password-file", + password_file.to_str().unwrap(), ]); - let file = wallet.find_keystore_file(&keystore_file).unwrap(); - assert_eq!(file, keystore_file); + let signer = wallet.signer().await.unwrap(); + assert_eq!( + signer.address().to_alloy(), + Address::from_str("ec554aeafe75601aaab43bd4621a22284db566c2").unwrap() + ); } - #[test] - fn illformed_private_key_generates_user_friendly_error() { - let wallet = Wallet { - raw: RawWallet { + #[tokio::test] + async fn illformed_private_key_generates_user_friendly_error() { + let wallet = WalletOpts { + raw: RawWalletOpts { interactive: false, private_key: Some("123".to_string()), mnemonic: None, @@ -515,7 +195,7 @@ mod tests { trezor: false, aws: false, }; - match wallet.private_key() { + match wallet.signer().await { Ok(_) => { panic!("illformed private key shouldn't decode") } @@ -527,12 +207,4 @@ mod tests { } } } - - #[test] - fn gets_password_from_file() { - let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../cast/tests/fixtures/keystore/password"); - let wallet: Wallet = Wallet::parse_from(["foundry-cli"]); - let password = wallet.password_from_file(path).unwrap(); - assert_eq!(password, "this is keystore password") - } } diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs new file mode 100644 index 0000000000000..ed7b99a0c5761 --- /dev/null +++ b/crates/wallets/src/wallet_signer.rs @@ -0,0 +1,190 @@ +use crate::error::WalletSignerError; +use alloy_primitives::B256; +use async_trait::async_trait; +use ethers_core::types::{ + transaction::{eip2718::TypedTransaction, eip712::Eip712}, + Signature, +}; +use ethers_signers::{ + coins_bip39::English, AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, MnemonicBuilder, + Signer, Trezor, TrezorHDPath, +}; +use rusoto_core::{ + credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, + request::HttpClient as AwsHttpClient, Client as AwsClient, +}; +use rusoto_kms::KmsClient; +use std::path::PathBuf; + +pub type Result = std::result::Result; + +/// Wrapper enum around different signers. +#[derive(Debug)] +pub enum WalletSigner { + /// Wrapper around local wallet. e.g. private key, mnemonic + Local(LocalWallet), + /// Wrapper around Ledger signer. + Ledger(Ledger), + /// Wrapper around Trezor signer. + Trezor(Trezor), + /// Wrapper around AWS KMS signer. + Aws(AwsSigner), +} + +impl WalletSigner { + pub async fn from_ledger_path(path: LedgerHDPath) -> Result { + let ledger = Ledger::new(path, 1).await?; + Ok(Self::Ledger(ledger)) + } + + pub async fn from_trezor_path(path: TrezorHDPath) -> Result { + // cached to ~/.ethers-rs/trezor/cache/trezor.session + let trezor = Trezor::new(path, 1, None).await?; + Ok(Self::Trezor(trezor)) + } + + pub async fn from_aws(key_id: &str) -> Result { + let client = + AwsClient::new_with(AwsChainProvider::default(), AwsHttpClient::new().unwrap()); + + let kms = KmsClient::new_with_client(client, AwsRegion::default()); + + Ok(Self::Aws(AwsSigner::new(kms, key_id, 1).await?)) + } + + pub fn from_private_key(private_key: impl AsRef<[u8]>) -> Result { + let wallet = LocalWallet::from_bytes(private_key.as_ref())?; + Ok(Self::Local(wallet)) + } + + pub fn from_mnemonic( + mnemonic: &str, + passphrase: Option<&str>, + derivation_path: Option<&str>, + index: u32, + ) -> Result { + let mut builder = MnemonicBuilder::::default().phrase(mnemonic); + + if let Some(passphrase) = passphrase { + builder = builder.password(passphrase) + } + + builder = if let Some(hd_path) = derivation_path { + builder.derivation_path(hd_path)? + } else { + builder.index(index)? + }; + + Ok(Self::Local(builder.build()?)) + } +} + +macro_rules! delegate { + ($s:ident, $inner:ident => $e:expr) => { + match $s { + Self::Local($inner) => $e, + Self::Ledger($inner) => $e, + Self::Trezor($inner) => $e, + Self::Aws($inner) => $e, + } + }; +} + +#[async_trait] +impl Signer for WalletSigner { + type Error = WalletSignerError; + + async fn sign_message>(&self, message: S) -> Result { + delegate!(self, inner => inner.sign_message(message).await.map_err(Into::into)) + } + + async fn sign_transaction(&self, message: &TypedTransaction) -> Result { + delegate!(self, inner => inner.sign_transaction(message).await.map_err(Into::into)) + } + + async fn sign_typed_data(&self, payload: &T) -> Result { + delegate!(self, inner => inner.sign_typed_data(payload).await.map_err(Into::into)) + } + + fn address(&self) -> ethers_core::types::Address { + delegate!(self, inner => inner.address()) + } + + fn chain_id(&self) -> u64 { + delegate!(self, inner => inner.chain_id()) + } + + fn with_chain_id>(self, chain_id: T) -> Self { + match self { + Self::Local(inner) => Self::Local(inner.with_chain_id(chain_id)), + Self::Ledger(inner) => Self::Ledger(inner.with_chain_id(chain_id)), + Self::Trezor(inner) => Self::Trezor(inner.with_chain_id(chain_id)), + Self::Aws(inner) => Self::Aws(inner.with_chain_id(chain_id)), + } + } +} + +#[async_trait] +impl Signer for &WalletSigner { + type Error = WalletSignerError; + + async fn sign_message>(&self, message: S) -> Result { + (*self).sign_message(message).await + } + + async fn sign_transaction(&self, message: &TypedTransaction) -> Result { + (*self).sign_transaction(message).await + } + + async fn sign_typed_data(&self, payload: &T) -> Result { + (*self).sign_typed_data(payload).await + } + + fn address(&self) -> ethers_core::types::Address { + (*self).address() + } + + fn chain_id(&self) -> u64 { + (*self).chain_id() + } + + fn with_chain_id>(self, chain_id: T) -> Self { + let _ = chain_id; + self + } +} + +impl WalletSigner { + pub async fn sign_hash(&self, hash: &B256) -> Result { + match self { + // TODO: AWS can sign hashes but utilities aren't exposed in ethers-signers. + // TODO: Implement with alloy-signer. + Self::Aws(_aws) => Err(WalletSignerError::CannotSignRawHash("AWS")), + Self::Ledger(_) => Err(WalletSignerError::CannotSignRawHash("Ledger")), + Self::Local(wallet) => wallet.sign_hash(hash.0.into()).map_err(Into::into), + Self::Trezor(_) => Err(WalletSignerError::CannotSignRawHash("Trezor")), + } + } +} + +/// Signers that require user action to be obtained. +#[derive(Debug, Clone)] +pub enum PendingSigner { + Keystore(PathBuf), + Interactive, +} + +impl PendingSigner { + pub fn unlock(self) -> Result { + match self { + Self::Keystore(path) => { + let password = rpassword::prompt_password("Enter keystore password:")?; + Ok(WalletSigner::Local(LocalWallet::decrypt_keystore(path, password)?)) + } + Self::Interactive => { + let private_key = rpassword::prompt_password("Enter private key:")?; + Ok(WalletSigner::from_private_key(hex::decode(private_key)?)?) + } + } + } +} From a1cba8367b705256bb282b44dbb4439a39030289 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 21:21:21 +0200 Subject: [PATCH 0660/1963] fix(chisel): min and max for all types (#7192) --- crates/chisel/src/executor.rs | 25 +++++++++++++++++-------- crates/wallets/src/multi_wallet.rs | 2 -- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 0953df29933bb..3b243b7b0ef49 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -769,6 +769,8 @@ impl Type { } /// Handle special expressions like [global variables](https://docs.soliditylang.org/en/latest/cheatsheet.html#global-variables) + /// + /// See: fn map_special(self) -> Self { if !matches!(self, Self::Function(_, _, _) | Self::Access(_, _) | Self::Custom(_)) { return self @@ -818,20 +820,21 @@ impl Type { match name { "block" => match access { "coinbase" => Some(DynSolType::Address), - "basefee" | "chainid" | "difficulty" | "gaslimit" | "number" | - "timestamp" => Some(DynSolType::Uint(256)), + "timestamp" | "difficulty" | "prevrandao" | "number" | "gaslimit" | + "chainid" | "basefee" | "blobbasefee" => Some(DynSolType::Uint(256)), _ => None, }, "msg" => match access { - "data" => Some(DynSolType::Bytes), "sender" => Some(DynSolType::Address), - "sig" => Some(DynSolType::FixedBytes(4)), + "gas" => Some(DynSolType::Uint(256)), "value" => Some(DynSolType::Uint(256)), + "data" => Some(DynSolType::Bytes), + "sig" => Some(DynSolType::FixedBytes(4)), _ => None, }, "tx" => match access { - "gasprice" => Some(DynSolType::Uint(256)), "origin" => Some(DynSolType::Address), + "gasprice" => Some(DynSolType::Uint(256)), _ => None, }, "abi" => match access { @@ -865,7 +868,11 @@ impl Type { "name" => Some(DynSolType::String), "creationCode" | "runtimeCode" => Some(DynSolType::Bytes), "interfaceId" => Some(DynSolType::FixedBytes(4)), - "min" | "max" => Some(DynSolType::Uint(256)), + "min" | "max" => Some( + // Either a builtin or an enum + (|| args?.pop()??.into_builtin())() + .unwrap_or(DynSolType::Uint(256)), + ), _ => None, }, "string" => match access { @@ -1656,9 +1663,11 @@ mod tests { ("type(C).runtimeCode", Bytes), ("type(I).interfaceId", FixedBytes(4)), ("type(uint256).min", Uint(256)), - ("type(int256).min", Uint(256)), + ("type(int128).min", Int(128)), + ("type(int256).min", Int(256)), ("type(uint256).max", Uint(256)), - ("type(int256).max", Uint(256)), + ("type(int128).max", Int(128)), + ("type(int256).max", Int(256)), ("type(Enum1).min", Uint(256)), ("type(Enum1).max", Uint(256)), // function diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index 21692eb047948..956521e357f47 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -387,8 +387,6 @@ impl MultiWalletOpts { #[cfg(test)] mod tests { - use ethers_signers::Signer; - use super::*; use std::path::Path; From 2089f6b95ea53aad171923f03d7967d7ec8e8639 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:52:26 +0200 Subject: [PATCH 0661/1963] feat: host documentation on GitHub Pages (#7195) --- .github/workflows/test.yml | 25 +++++++++++++++++++++++++ README.md | 5 +++++ 2 files changed, 30 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb25172002e74..13e2d43670fac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,6 +91,31 @@ jobs: SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} run: cargo nextest run ${{ matrix.flags }} + docs: + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: write + pages: write + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: cargo doc --workspace --all-features --no-deps --document-private-items + env: + RUSTDOCFLAGS: + --cfg docsrs --show-type-layout --generate-link-to-definition --enable-index-page + -Zunstable-options + - name: Deploy documentation + uses: peaceiris/actions-gh-pages@v3 + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: target/doc + force_orphan: true + doctest: runs-on: ubuntu-latest timeout-minutes: 30 diff --git a/README.md b/README.md index 8f205f13d9222..a3be44ccd06fa 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ [tg-support-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=support&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Ffoundry_support [tg-support-url]: https://t.me/foundry_support +**[Install](https://book.getfoundry.sh/getting-started/installation)** +| [User Book](https://book.getfoundry.sh) +| [Developer Docs](./docs) +| [Crate Docs](https://foundry-rs.github.io/foundry/docs) + **Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** Foundry consists of: From 2f4b5dbe7f04d974bf99625325200d214089ee66 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:59:44 +0200 Subject: [PATCH 0662/1963] docs: fix README links (#7196) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a3be44ccd06fa..b6f4f8640a1ab 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ **[Install](https://book.getfoundry.sh/getting-started/installation)** | [User Book](https://book.getfoundry.sh) -| [Developer Docs](./docs) -| [Crate Docs](https://foundry-rs.github.io/foundry/docs) +| [Developer Docs](./docs/dev/) +| [Crate Docs](https://foundry-rs.github.io/foundry) **Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** From 9b73e06e1fe376738b92ae081107620291d50188 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:37:35 +0200 Subject: [PATCH 0663/1963] issue 6319: copy raw sliced value as tail in new value to be converted (#7194) * issue 6319: copy raw sliced value as tail in new value to be converted * Add #6319 test --- crates/cast/bin/cmd/storage.rs | 8 +++---- crates/cast/tests/cli/main.rs | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 557b68a1e2970..f8f01b7aec7cf 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -198,13 +198,13 @@ impl StorageValue { end = 32; } } - let mut value = [0u8; 32]; // reverse range, because the value is stored in big endian - let offset = 32 - offset; - let end = 32 - end; + let raw_sliced_value = &self.raw_slot_value.as_slice()[32 - end..32 - offset]; - value[end..offset].copy_from_slice(&self.raw_slot_value.as_slice()[end..offset]); + // copy the raw sliced value as tail + let mut value = [0u8; 32]; + value[32 - raw_sliced_value.len()..32].copy_from_slice(raw_sliced_value); B256::from(value) } } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index e4009aa4af9f6..57c5170343c8f 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -583,6 +583,50 @@ casttest!(storage, |_prj, cmd| { assert_eq!(cmd.stdout_lossy().trim(), issued); }); +// +casttest!(storage_layout, |_prj, cmd| { + cmd.cast_fuse().args([ + "storage", + "--rpc-url", + "https://mainnet.optimism.io", + "--block", + "110000000", + "--etherscan-api-key", + "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46", + "0xB67c152E69217b5aCB85A2e19dF13423351b0E27", + ]); + let output = r#"| Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | +|-------------------------------|-----------------------------------------------------------------|------|--------|-------|---------------------------------------------------|--------------------------------------------------------------------|----------------------------------------------------| +| gov | address | 0 | 0 | 20 | 1352965747418285184211909460723571462248744342032 | 0x000000000000000000000000ecfd15165d994c2766fbe0d6bacdc2e8dedfd210 | contracts/perp/PositionManager.sol:PositionManager | +| _status | uint256 | 1 | 0 | 32 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | +| admin | address | 2 | 0 | 20 | 1352965747418285184211909460723571462248744342032 | 0x000000000000000000000000ecfd15165d994c2766fbe0d6bacdc2e8dedfd210 | contracts/perp/PositionManager.sol:PositionManager | +| feeCalculator | address | 3 | 0 | 20 | 1297482016264593221714872710065075000476194625473 | 0x000000000000000000000000e3451b170806aab3e24b5cd03a331c1ccdb4d7c1 | contracts/perp/PositionManager.sol:PositionManager | +| oracle | address | 4 | 0 | 20 | 241116142622541106669066767052022920958068430970 | 0x0000000000000000000000002a3c0592dcb58accd346ccee2bb46e3fb744987a | contracts/perp/PositionManager.sol:PositionManager | +| referralStorage | address | 5 | 0 | 20 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| minExecutionFee | uint256 | 6 | 0 | 32 | 20000 | 0x0000000000000000000000000000000000000000000000000000000000004e20 | contracts/perp/PositionManager.sol:PositionManager | +| minBlockDelayKeeper | uint256 | 7 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| minTimeExecuteDelayPublic | uint256 | 8 | 0 | 32 | 180 | 0x00000000000000000000000000000000000000000000000000000000000000b4 | contracts/perp/PositionManager.sol:PositionManager | +| minTimeCancelDelayPublic | uint256 | 9 | 0 | 32 | 180 | 0x00000000000000000000000000000000000000000000000000000000000000b4 | contracts/perp/PositionManager.sol:PositionManager | +| maxTimeDelay | uint256 | 10 | 0 | 32 | 1800 | 0x0000000000000000000000000000000000000000000000000000000000000708 | contracts/perp/PositionManager.sol:PositionManager | +| isUserExecuteEnabled | bool | 11 | 0 | 1 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | +| isUserCancelEnabled | bool | 11 | 1 | 1 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | +| allowPublicKeeper | bool | 11 | 2 | 1 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| allowUserCloseOnly | bool | 11 | 3 | 1 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | +| openPositionRequestKeys | bytes32[] | 12 | 0 | 32 | 9287 | 0x0000000000000000000000000000000000000000000000000000000000002447 | contracts/perp/PositionManager.sol:PositionManager | +| closePositionRequestKeys | bytes32[] | 13 | 0 | 32 | 5782 | 0x0000000000000000000000000000000000000000000000000000000000001696 | contracts/perp/PositionManager.sol:PositionManager | +| openPositionRequestKeysStart | uint256 | 14 | 0 | 32 | 9287 | 0x0000000000000000000000000000000000000000000000000000000000002447 | contracts/perp/PositionManager.sol:PositionManager | +| closePositionRequestKeysStart | uint256 | 15 | 0 | 32 | 5782 | 0x0000000000000000000000000000000000000000000000000000000000001696 | contracts/perp/PositionManager.sol:PositionManager | +| isPositionKeeper | mapping(address => bool) | 16 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| openPositionsIndex | mapping(address => uint256) | 17 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| openPositionRequests | mapping(bytes32 => struct PositionManager.OpenPositionRequest) | 18 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| closePositionsIndex | mapping(address => uint256) | 19 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| closePositionRequests | mapping(bytes32 => struct PositionManager.ClosePositionRequest) | 20 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| managers | mapping(address => bool) | 21 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +| approvedManagers | mapping(address => mapping(address => bool)) | 22 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | +"#; + assert_eq!(cmd.stdout_lossy(), output); +}); + casttest!(balance, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); let usdt = "0xdac17f958d2ee523a2206206994597c13d831ec7"; From 9fe9a3fc89f46294e38454d2b5106c707d82a31a Mon Sep 17 00:00:00 2001 From: RPate97 Date: Wed, 21 Feb 2024 16:16:37 -0800 Subject: [PATCH 0664/1963] fix(forge): Optionally use create2 factory in tests and non-broadcasting scripts (#6656) * fix(forge): Optionally use create2 factory in tests * Update crates/cheatcodes/src/inspector.rs * Update crates/cheatcodes/src/inspector.rs Co-authored-by: Matthias Seitz --------- Co-authored-by: Enrique Co-authored-by: Matthias Seitz --- crates/cheatcodes/src/config.rs | 4 ++ crates/cheatcodes/src/inspector.rs | 76 +++++++++++++++++++++++------- crates/common/src/evm.rs | 12 +++++ crates/config/README.md | 1 + crates/config/src/lib.rs | 6 +++ crates/evm/core/src/opts.rs | 3 ++ crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/it/repros.rs | 7 +++ testdata/repros/Issue5529.t.sol | 37 +++++++++++++++ 9 files changed, 129 insertions(+), 18 deletions(-) create mode 100644 testdata/repros/Issue5529.t.sol diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 1fdb9d4abc807..eb8f56ab7f6eb 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -20,6 +20,8 @@ use std::{ pub struct CheatsConfig { /// Whether the FFI cheatcode is enabled. pub ffi: bool, + /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. + pub always_use_create_2_factory: bool, /// RPC storage caching settings determines what chains and endpoints to cache pub rpc_storage_caching: StorageCachingConfig, /// All known endpoints and their aliases @@ -52,6 +54,7 @@ impl CheatsConfig { Self { ffi: evm_opts.ffi, + always_use_create_2_factory: evm_opts.always_use_create_2_factory, rpc_storage_caching: config.rpc_storage_caching.clone(), rpc_endpoints, paths: config.project_paths(), @@ -167,6 +170,7 @@ impl Default for CheatsConfig { fn default() -> Self { Self { ffi: false, + always_use_create_2_factory: false, rpc_storage_caching: Default::default(), rpc_endpoints: Default::default(), paths: ProjectPathsConfig::builder().build_with_root("./"), diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 50b5093ba6920..a036ffa597e0d 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1202,18 +1202,12 @@ impl Inspector for Cheatcodes { data.env.tx.caller = broadcast.new_origin; if data.journaled_state.depth() == broadcast.depth { - let (bytecode, to, nonce) = match process_create( + let (bytecode, to, nonce) = process_broadcast_create( broadcast.new_origin, call.init_code.clone(), data, call, - ) { - Ok(val) => val, - Err(err) => { - return (InstructionResult::Revert, None, gas, Error::encode(err)) - } - }; - + ); let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); self.broadcastable_transactions.push_back(BroadcastableTransaction { @@ -1241,6 +1235,14 @@ impl Inspector for Cheatcodes { } } + // Apply the Create2 deployer + if self.broadcast.is_some() || self.config.always_use_create_2_factory { + match apply_create2_deployer(data, call, self.prank.as_ref(), self.broadcast.as_ref()) { + Ok(_) => {} + Err(err) => return (InstructionResult::Revert, None, gas, Error::encode(err)), + }; + } + // allow cheatcodes from the address of the new contract // Compute the address *after* any possible broadcast updates, so it's based on the updated // call inputs @@ -1416,18 +1418,31 @@ fn mstore_revert_string(interpreter: &mut Interpreter<'_>, bytes: &[u8]) { interpreter.return_len = interpreter.shared_memory.len() - starting_offset } -fn process_create( - broadcast_sender: Address, - bytecode: Bytes, +/// Applies the default CREATE2 deployer for contract creation. +/// +/// This function is invoked during the contract creation process and updates the caller of the +/// contract creation transaction to be the `DEFAULT_CREATE2_DEPLOYER` if the `CreateScheme` is +/// `Create2` and the current execution depth matches the depth at which the `prank` or `broadcast` +/// was started, or the default depth of 1 if no prank or broadcast is currently active. +/// +/// Returns a `DatabaseError::MissingCreate2Deployer` if the `DEFAULT_CREATE2_DEPLOYER` account is +/// not found or if it does not have any associated bytecode. +fn apply_create2_deployer( data: &mut EVMData<'_, DB>, call: &mut CreateInputs, -) -> Result<(Bytes, Option
, u64), DB::Error> { - match call.scheme { - CreateScheme::Create => { - call.caller = broadcast_sender; - Ok((bytecode, None, data.journaled_state.account(broadcast_sender).info.nonce)) + prank: Option<&Prank>, + broadcast: Option<&Broadcast>, +) -> Result<(), DB::Error> { + if let CreateScheme::Create2 { salt: _ } = call.scheme { + let mut base_depth = 1; + if let Some(prank) = &prank { + base_depth = prank.depth; + } else if let Some(broadcast) = &broadcast { + base_depth = broadcast.depth; } - CreateScheme::Create2 { salt } => { + // If the create scheme is Create2 and the depth equals the broadcast/prank/default + // depth, then use the default create2 factory as the deployer + if data.journaled_state.depth() == base_depth { // Sanity checks for our CREATE2 deployer let info = &data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?.0.info; @@ -1440,7 +1455,32 @@ fn process_create( } call.caller = DEFAULT_CREATE2_DEPLOYER; + } + } + Ok(()) +} +/// Processes the creation of a new contract when broadcasting, preparing the necessary data for the +/// transaction to deploy the contract. +/// +/// Returns the transaction calldata and the target address. +/// +/// If the CreateScheme is Create, then this function returns the input bytecode without +/// modification and no address since it will be filled in later. If the CreateScheme is Create2, +/// then this function returns the calldata for the call to the create2 deployer which must be the +/// salt and init code concatenated. +fn process_broadcast_create( + broadcast_sender: Address, + bytecode: Bytes, + data: &mut EVMData<'_, DB>, + call: &mut CreateInputs, +) -> (Bytes, Option
, u64) { + match call.scheme { + CreateScheme::Create => { + call.caller = broadcast_sender; + (bytecode, None, data.journaled_state.account(broadcast_sender).info.nonce) + } + CreateScheme::Create2 { salt } => { // We have to increment the nonce of the user address, since this create2 will be done // by the create2_deployer let account = data.journaled_state.state().get_mut(&broadcast_sender).unwrap(); @@ -1450,7 +1490,7 @@ fn process_create( // Proxy deployer requires the data to be `salt ++ init_code` let calldata = [&salt.to_be_bytes::<32>()[..], &bytecode[..]].concat(); - Ok((calldata.into(), Some(DEFAULT_CREATE2_DEPLOYER), prev)) + (calldata.into(), Some(DEFAULT_CREATE2_DEPLOYER), prev) } } } diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 2080951abb4a2..a924fe5251a1d 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -95,6 +95,11 @@ pub struct EvmArgs { #[serde(skip)] pub ffi: bool, + /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. + #[clap(long)] + #[serde(skip)] + pub always_use_create_2_factory: bool, + /// Verbosity of the EVM. /// /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). @@ -161,6 +166,13 @@ impl Provider for EvmArgs { dict.insert("ffi".to_string(), self.ffi.into()); } + if self.always_use_create_2_factory { + dict.insert( + "always_use_create_2_factory".to_string(), + self.always_use_create_2_factory.into(), + ); + } + if self.no_storage_caching { dict.insert("no_storage_caching".to_string(), self.no_storage_caching.into()); } diff --git a/crates/config/README.md b/crates/config/README.md index 2944105d53824..004ade3851b31 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -115,6 +115,7 @@ no_match_contract = "Bar" match_path = "*/Foo*" no_match_path = "*/Bar*" ffi = false +always_use_create_2_factory = false # These are the default callers, generated using `address(uint160(uint256(keccak256("foundry default caller"))))` sender = '0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38' tx_origin = '0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38' diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 879d3ecfb7df1..3c7cc1d5e3768 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -242,6 +242,8 @@ pub struct Config { pub invariant: InvariantConfig, /// Whether to allow ffi cheatcodes in test pub ffi: bool, + /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. + pub always_use_create_2_factory: bool, /// The address which will be executing all tests pub sender: Address, /// The tx.origin value during EVM execution @@ -1842,6 +1844,7 @@ impl Default for Config { path_pattern_inverse: None, fuzz: Default::default(), invariant: Default::default(), + always_use_create_2_factory: false, ffi: false, sender: Config::DEFAULT_SENDER, tx_origin: Config::DEFAULT_SENDER, @@ -3408,6 +3411,7 @@ mod tests { revert_strings = "strip" allow_paths = ["allow", "paths"] build_info_path = "build-info" + always_use_create_2_factory = true [rpc_endpoints] optimism = "https://example.com/" @@ -3459,6 +3463,7 @@ mod tests { ), ]), build_info_path: Some("build-info".into()), + always_use_create_2_factory: true, ..Config::default() } ); @@ -3510,6 +3515,7 @@ mod tests { evm_version = 'london' extra_output = [] extra_output_files = [] + always_use_create_2_factory = false ffi = false force = false gas_limit = 9223372036854775807 diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 094606828dfdc..49aaa0a2e2840 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -52,6 +52,9 @@ pub struct EvmOpts { /// Enables the FFI cheatcode. pub ffi: bool, + /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. + pub always_use_create_2_factory: bool, + /// Verbosity mode of EVM output as number of occurrences. pub verbosity: u8, diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 0c540d65a4fc3..3e87447b7575a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -69,6 +69,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { }, invariant: InvariantConfig { runs: 256, ..Default::default() }, ffi: true, + always_use_create_2_factory: false, sender: "00a329c0648769A73afAc7F9381D08FB43dBEA72".parse().unwrap(), tx_origin: "00a329c0648769A73afAc7F9F81E08FB43dBEA72".parse().unwrap(), initial_balance: U256::from(0xffffffffffffffffffffffffu128), diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 0838ffed019f5..7323d7ef131a4 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -303,3 +303,10 @@ test_repro!(6966); // https://github.com/foundry-rs/foundry/issues/6616 test_repro!(6616); + +// https://github.com/foundry-rs/foundry/issues/5529 +test_repro!(5529; |config| { + let mut cheats_config = config.runner.cheats_config.as_ref().clone(); + cheats_config.always_use_create_2_factory = true; + config.runner.cheats_config = std::sync::Arc::new(cheats_config); +}); diff --git a/testdata/repros/Issue5529.t.sol b/testdata/repros/Issue5529.t.sol new file mode 100644 index 0000000000000..35e7140014ad0 --- /dev/null +++ b/testdata/repros/Issue5529.t.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } +} + +contract Issue5529Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + Counter public counter; + address public constant default_create2_factory = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + + function testCreate2FactoryUsedInTests() public { + address a = vm.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(default_create2_factory)); + address b = address(new Counter{salt: 0}()); + require(a == b, "create2 address mismatch"); + } + + function testCreate2FactoryUsedWhenPranking() public { + vm.startPrank(address(1234)); + address a = vm.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(default_create2_factory)); + address b = address(new Counter{salt: 0}()); + require(a == b, "create2 address mismatch"); + } +} From 57815e060bbf28914b635813c819a8d064ed9002 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:14:28 +0200 Subject: [PATCH 0665/1963] feat(`cast wallet list`) issue #6958: Include HW wallets in cast wallet ls (#7123) * issue #6958: Include HW wallets in cast wallet ls * Changes after review: - use annotations for builder defaults - handle Local signer in available_senders, return Ledger addresses for legacy derivation, add doc - fix condition to list files in keystore dir - simplify creation of keystore default directory * Changes after review: use list_signers macro * Changes after review: - remove help_headings - remove match and use ? as dir already exists - remove async from list_local_senders fn - move Ok(senders) at the bottom of available_senders fn - list_senders doesn't need match as available_senders cannot fail - make max_senders arg for ls command , default 3 * Nit * Remove list_senders fn, move logic in macro * Nit macro --- Cargo.lock | 73 +++++++++++++++++++ crates/cast/bin/cmd/wallet/list.rs | 108 ++++++++++++++++++++++++++++ crates/cast/bin/cmd/wallet/mod.rs | 42 ++--------- crates/cast/tests/cli/main.rs | 23 +++++- crates/wallets/Cargo.toml | 1 + crates/wallets/src/multi_wallet.rs | 13 +++- crates/wallets/src/wallet_signer.rs | 44 ++++++++++++ 7 files changed, 266 insertions(+), 38 deletions(-) create mode 100644 crates/cast/bin/cmd/wallet/list.rs diff --git a/Cargo.lock b/Cargo.lock index 422ebd05ae4f6..ad5908e54e7bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1894,6 +1894,41 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "darling" +version = "0.20.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c376d08ea6aa96aafe61237c7200d1241cb177b7d3a542d791f2d118e9cbb955" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33043dcd19068b8192064c704b3f83eb464f91f1ff527b44a4e2b08d9cdb8855" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 2.0.49", +] + +[[package]] +name = "darling_macro" +version = "0.20.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.49", +] + [[package]] name = "dashmap" version = "5.5.3" @@ -1955,6 +1990,37 @@ dependencies = [ "syn 2.0.49", ] +[[package]] +name = "derive_builder" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.49", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" +dependencies = [ + "derive_builder_core", + "syn 2.0.49", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -3349,6 +3415,7 @@ dependencies = [ "async-trait", "clap", "const-hex", + "derive_builder", "ethers-core", "ethers-providers", "ethers-signers", @@ -4138,6 +4205,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" diff --git a/crates/cast/bin/cmd/wallet/list.rs b/crates/cast/bin/cmd/wallet/list.rs new file mode 100644 index 0000000000000..b0984d4ba861a --- /dev/null +++ b/crates/cast/bin/cmd/wallet/list.rs @@ -0,0 +1,108 @@ +use clap::Parser; +use eyre::Result; + +use foundry_common::{fs, types::ToAlloy}; +use foundry_config::Config; +use foundry_wallets::multi_wallet::MultiWalletOptsBuilder; + +/// CLI arguments for `cast wallet list`. +#[derive(Clone, Debug, Parser)] +pub struct ListArgs { + /// List all the accounts in the keystore directory. + /// Default keystore directory is used if no path provided. + #[clap(long, default_missing_value = "", num_args(0..=1))] + dir: Option, + + /// List accounts from a Ledger hardware wallet. + #[clap(long, short, group = "hw-wallets")] + ledger: bool, + + /// List accounts from a Trezor hardware wallet. + #[clap(long, short, group = "hw-wallets")] + trezor: bool, + + /// List accounts from AWS KMS. + #[clap(long)] + aws: bool, + + /// List all configured accounts. + #[clap(long, group = "hw-wallets")] + all: bool, + + /// Max number of addresses to display from hardware wallets. + #[clap(long, short, default_value = "3", requires = "hw-wallets")] + max_senders: Option, +} + +impl ListArgs { + pub async fn run(self) -> Result<()> { + // list local accounts as files in keystore dir, no need to unlock / provide password + if self.dir.is_some() || self.all || (!self.ledger && !self.trezor && !self.aws) { + let _ = self.list_local_senders(); + } + + // Create options for multi wallet - ledger, trezor and AWS + let list_opts = MultiWalletOptsBuilder::default() + .ledger(self.ledger || self.all) + .mnemonic_indexes(Some(vec![0])) + .trezor(self.trezor || self.all) + .aws(self.aws || self.all) + .interactives(0) + .build() + .expect("build multi wallet"); + + // macro to print senders for a list of signers + macro_rules! list_senders { + ($signers:expr, $label:literal) => { + match $signers.await { + Ok(signers) => { + for signer in signers.unwrap_or_default().iter() { + signer + .available_senders(self.max_senders.unwrap()) + .await? + .iter() + .for_each(|sender| println!("{} ({})", sender.to_alloy(), $label)); + } + } + Err(e) => { + if !self.all { + println!("{}", e) + } + } + } + }; + } + + list_senders!(list_opts.ledgers(), "Ledger"); + list_senders!(list_opts.trezors(), "Trezor"); + list_senders!(list_opts.aws_signers(), "AWS"); + + Ok(()) + } + + fn list_local_senders(&self) -> Result<()> { + let keystore_path = self.dir.clone().unwrap_or_default(); + let keystore_dir = if keystore_path.is_empty() { + // Create the keystore default directory if it doesn't exist + let default_dir = Config::foundry_keystores_dir().unwrap(); + fs::create_dir_all(&default_dir)?; + default_dir + } else { + dunce::canonicalize(keystore_path)? + }; + + // list files within keystore dir + std::fs::read_dir(keystore_dir)?.flatten().for_each(|entry| { + let path = entry.path(); + if path.is_file() && path.extension().is_none() { + if let Some(file_name) = path.file_name() { + if let Some(name) = file_name.to_str() { + println!("{} (Local)", name); + } + } + } + }); + + Ok(()) + } +} diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 5850c523a368d..240134ef933b4 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -18,6 +18,9 @@ use yansi::Paint; pub mod vanity; use vanity::VanityArgs; +pub mod list; +use list::ListArgs; + /// CLI arguments for `cast wallet`. #[derive(Debug, Parser)] pub enum WalletSubcommands { @@ -137,7 +140,7 @@ pub enum WalletSubcommands { }, /// List all the accounts in the keystore default directory #[clap(visible_alias = "ls")] - List, + List(ListArgs), /// Derives private key from mnemonic #[clap(name = "derive-private-key", visible_aliases = &["--derive-private-key"])] @@ -331,41 +334,8 @@ flag to set your key via: ); println!("{}", Paint::green(success_message)); } - WalletSubcommands::List => { - let default_keystore_dir = Config::foundry_keystores_dir() - .ok_or_else(|| eyre::eyre!("Could not find the default keystore directory."))?; - // Create the keystore directory if it doesn't exist - fs::create_dir_all(&default_keystore_dir)?; - // List all files in keystore directory - let keystore_files: Result, eyre::Report> = - std::fs::read_dir(&default_keystore_dir) - .wrap_err("Failed to read the directory")? - .filter_map(|entry| match entry { - Ok(entry) => { - let path = entry.path(); - if path.is_file() && path.extension().is_none() { - Some(Ok(path)) - } else { - None - } - } - Err(e) => Some(Err(e.into())), - }) - .collect::, eyre::Report>>(); - // Print the names of the keystore files - match keystore_files { - Ok(files) => { - // Print the names of the keystore files - for file in files { - if let Some(file_name) = file.file_name() { - if let Some(name) = file_name.to_str() { - println!("{}", name); - } - } - } - } - Err(e) => return Err(e), - } + WalletSubcommands::List(cmd) => { + cmd.run().await?; } WalletSubcommands::DerivePrivateKey { mnemonic, mnemonic_index } => { let phrase = Mnemonic::::new_from_phrase(mnemonic.as_str())?.to_phrase(); diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 57c5170343c8f..91c8b6109c0f8 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -2,7 +2,7 @@ use foundry_common::rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}; use foundry_test_utils::{casttest, util::OutputExt}; -use std::{io::Write, path::Path}; +use std::{fs, io::Write, path::Path}; // tests `--help` is printed to std out casttest!(print_help, |_prj, cmd| { @@ -131,6 +131,27 @@ casttest!(wallet_sign_typed_data_file, |_prj, cmd| { assert_eq!(output.trim(), "0x06c18bdc8163219fddc9afaf5a0550e381326474bb757c86dc32317040cf384e07a2c72ce66c1a0626b6750ca9b6c035bf6f03e7ed67ae2d1134171e9085c0b51b"); }); +// tests that `cast wallet list` outputs the local accounts +casttest!(wallet_list_local_accounts, |prj, cmd| { + let keystore_path = prj.root().join("keystore"); + fs::create_dir_all(keystore_path).unwrap(); + cmd.set_current_dir(prj.root()); + + // empty results + cmd.cast_fuse().args(["wallet", "list", "--dir", "keystore"]); + let list_output = cmd.stdout_lossy(); + assert!(list_output.is_empty()); + + // create 10 wallets + cmd.cast_fuse().args(["wallet", "new", "keystore", "-n", "10", "--unsafe-password", "test"]); + cmd.stdout_lossy(); + + // test list new wallet + cmd.cast_fuse().args(["wallet", "list", "--dir", "keystore"]); + let list_output = cmd.stdout_lossy(); + assert_eq!(list_output.matches('\n').count(), 10); +}); + // tests that `cast estimate` is working correctly. casttest!(estimate_function_gas, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 501d0777f0fb5..1ef26972dbd4f 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -24,6 +24,7 @@ foundry-common.workspace = true async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } +derive_builder = "0.20.0" eyre.workspace = true hex = { workspace = true, features = ["serde"] } itertools.workspace = true diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index 956521e357f47..d3d7c9618f1bb 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -4,6 +4,7 @@ use crate::{ }; use alloy_primitives::Address; use clap::Parser; +use derive_builder::Builder; use ethers_signers::Signer; use eyre::Result; use foundry_common::types::ToAlloy; @@ -87,7 +88,7 @@ macro_rules! create_hw_wallets { /// 5. Private Keys (cleartext in CLI) /// 6. Private Keys (interactively via secure prompt) /// 7. AWS KMS -#[derive(Clone, Debug, Default, Serialize, Parser)] +#[derive(Builder, Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Wallet options", about = None, long_about = None)] pub struct MultiWalletOpts { /// The sender accounts. @@ -99,6 +100,7 @@ pub struct MultiWalletOpts { env = "ETH_FROM", num_args(0..), )] + #[builder(default = "None")] pub froms: Option>, /// Open an interactive prompt to enter your private key. @@ -115,6 +117,7 @@ pub struct MultiWalletOpts { /// Use the provided private keys. #[clap(long, help_heading = "Wallet options - raw", value_name = "RAW_PRIVATE_KEYS")] + #[builder(default = "None")] pub private_keys: Option>, /// Use the provided private key. @@ -124,14 +127,17 @@ pub struct MultiWalletOpts { conflicts_with = "private_keys", value_name = "RAW_PRIVATE_KEY" )] + #[builder(default = "None")] pub private_key: Option, /// Use the mnemonic phrases of mnemonic files at the specified paths. #[clap(long, alias = "mnemonic-paths", help_heading = "Wallet options - raw")] + #[builder(default = "None")] pub mnemonics: Option>, /// Use a BIP39 passphrases for the mnemonic. #[clap(long, help_heading = "Wallet options - raw", value_name = "PASSPHRASE")] + #[builder(default = "None")] pub mnemonic_passphrases: Option>, /// The wallet derivation path. @@ -143,6 +149,7 @@ pub struct MultiWalletOpts { help_heading = "Wallet options - raw", value_name = "PATH" )] + #[builder(default = "None")] pub hd_paths: Option>, /// Use the private key from the given mnemonic index. @@ -165,6 +172,7 @@ pub struct MultiWalletOpts { value_name = "PATHS", env = "ETH_KEYSTORE" )] + #[builder(default = "None")] pub keystore_paths: Option>, /// Use a keystore from the default keystores folder (~/.foundry/keystores) by its filename @@ -176,6 +184,7 @@ pub struct MultiWalletOpts { env = "ETH_KEYSTORE_ACCOUNT", conflicts_with = "keystore_paths" )] + #[builder(default = "None")] pub keystore_account_names: Option>, /// The keystore password. @@ -187,6 +196,7 @@ pub struct MultiWalletOpts { requires = "keystore_paths", value_name = "PASSWORDS" )] + #[builder(default = "None")] pub keystore_passwords: Option>, /// The keystore password file path. @@ -199,6 +209,7 @@ pub struct MultiWalletOpts { value_name = "PATHS", env = "ETH_PASSWORD" )] + #[builder(default = "None")] pub keystore_password_files: Option>, /// Use a Ledger hardware wallet. diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index ed7b99a0c5761..d71fbe1af7ff5 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -57,6 +57,50 @@ impl WalletSigner { Ok(Self::Local(wallet)) } + /// Returns a list of addresses available to use with current signer + /// + /// - for Ledger and Trezor signers the number of addresses to retrieve is specified as argument + /// - the result for Ledger signers includes addresses available for both LedgerLive and Legacy + /// derivation paths + /// - for Local and AWS signers the result contains a single address + pub async fn available_senders(&self, max: usize) -> Result> { + let mut senders = Vec::new(); + match self { + WalletSigner::Local(local) => { + senders.push(local.address()); + } + WalletSigner::Ledger(ledger) => { + for i in 0..max { + if let Ok(address) = + ledger.get_address_with_path(&LedgerHDPath::LedgerLive(i)).await + { + senders.push(address); + } + } + for i in 0..max { + if let Ok(address) = + ledger.get_address_with_path(&LedgerHDPath::Legacy(i)).await + { + senders.push(address); + } + } + } + WalletSigner::Trezor(trezor) => { + for i in 0..max { + if let Ok(address) = + trezor.get_address_with_path(&TrezorHDPath::TrezorLive(i)).await + { + senders.push(address); + } + } + } + WalletSigner::Aws(aws) => { + senders.push(aws.address()); + } + } + Ok(senders) + } + pub fn from_mnemonic( mnemonic: &str, passphrase: Option<&str>, From 6d5de514d2f67d88d088f57f10d28930ced4006e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 22 Feb 2024 18:22:55 +0100 Subject: [PATCH 0666/1963] chore: bump foundry-compilers 0.3.9 (#7210) * chore: bump foundry-compilers 0.3.8 * chore: update test * tmp: pin to git * Revert "chore: update test" This reverts commit 81b35e65f165f731cc7d911f201b4a0d2c0d3b59. * el bumpo * el fixo * Reapply "chore: update test" This reverts commit fff32b2626af14b561d3413381063692c7cfe2d0. --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 4 +-- Cargo.toml | 7 ++--- crates/forge/tests/cli/cmd.rs | 31 +++++-------------- crates/forge/tests/cli/config.rs | 9 ++---- .../fixtures/can_set_yul_optimizer.stderr | 3 +- 5 files changed, 14 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad5908e54e7bf..116f3afd1f08c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3158,9 +3158,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.6" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba64504d49ebda9141869b2ba23db2d685ae4cf17bcddf5e61f0e4bc515ebb25" +checksum = "d1b77c95e79bff02ddaa38426fc6809a3a438dce0e6a2eb212dac97da7c157b4" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 2c650152f1863..cddf4bae26a74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,7 +135,7 @@ foundry-wallets = { path = "crates/wallets" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } -foundry-compilers = { version = "0.3.6", default-features = false } +foundry-compilers = { version = "0.3.9", default-features = false } ## revm # no default features to avoid c-kzg @@ -181,10 +181,7 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" eyre = "0.6" diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index a187169fae98b..e5d7f712d364b 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -536,31 +536,10 @@ contract Greeter { cmd.arg("build"); let output = cmd.stdout_lossy(); - assert!(output.contains( - " -Compiler run successful with warnings: -Warning (5667): Warning: Unused function parameter. Remove or comment out the variable name to silence this warning. -", - )); + assert!(output.contains("Warning"), "{output}"); }); // Tests that direct import paths are handled correctly -// -// NOTE(onbjerg): Disabled for Windows -- for some reason solc fails with a bogus error message -// here: error[9553]: TypeError: Invalid type for argument in function call. Invalid implicit -// conversion from struct Bar memory to struct Bar memory requested. --> src\Foo.sol:12:22: -// | -// 12 | FooLib.check(b); -// | ^ -// -// -// -// error[9553]: TypeError: Invalid type for argument in function call. Invalid implicit conversion -// from contract Foo to contract Foo requested. --> src\Foo.sol:15:23: -// | -// 15 | FooLib.check2(this); -// | ^^^^ -#[cfg(not(target_os = "windows"))] forgetest!(can_handle_direct_imports_into_src, |prj, cmd| { prj.add_source( "Foo", @@ -1572,8 +1551,12 @@ forgetest_init!(can_install_missing_deps_build, |prj, cmd| { cmd.arg("build"); let output = cmd.stdout_lossy(); - assert!(output.contains("Missing dependencies found. Installing now"), "{}", output); - assert!(output.contains("No files changed, compilation skipped"), "{}", output); + assert!(output.contains("Missing dependencies found. Installing now"), "{output}"); + + // re-run + let output = cmd.stdout_lossy(); + assert!(!output.contains("Missing dependencies found. Installing now"), "{output}"); + assert!(output.contains("No files changed, compilation skipped"), "{output}"); }); // checks that extra output works diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 3e87447b7575a..2e4be0c6a8b50 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -381,7 +381,7 @@ contract Foo {} // test to ensure yul optimizer can be set as intended forgetest!(can_set_yul_optimizer, |prj, cmd| { prj.add_source( - "Foo", + "foo.sol", r" contract Foo { function bar() public pure { @@ -406,12 +406,7 @@ contract Foo { ..Default::default() }; prj.write_config(config); - - assert!(cmd.stdout_lossy().ends_with( - " -Compiler run successful! -", - )); + cmd.assert_success(); }); // tests that the lib triple can be parsed diff --git a/crates/forge/tests/fixtures/can_set_yul_optimizer.stderr b/crates/forge/tests/fixtures/can_set_yul_optimizer.stderr index c7c847bf96e18..0dd4db95b6eb7 100644 --- a/crates/forge/tests/fixtures/can_set_yul_optimizer.stderr +++ b/crates/forge/tests/fixtures/can_set_yul_optimizer.stderr @@ -1,9 +1,8 @@ Error: Compiler run failed: -Error (6553): SyntaxError: The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. +Error (6553): The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. --> src/Foo.sol:6:8: | 6 | assembly { | ^ (Relevant source part starts here and spans across multiple lines). - From b5fc4dc705f498241fb0849b4ffcc2671aa8d86a Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Thu, 22 Feb 2024 14:30:12 -1000 Subject: [PATCH 0667/1963] [cast] Fix cast wallet verify (#7215) * Fix cast wallet verify * fmt * fix(cast): use recover_address_from_msg * chore: add test, abstract addr recovery for testing --------- Co-authored-by: Enrique Ortiz --- crates/cast/bin/cmd/wallet/mod.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 240134ef933b4..c5c045b75c80e 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, Signature, B256}; +use alloy_primitives::{Address, Signature}; use alloy_signer::{ coins_bip39::{English, Mnemonic}, LocalWallet, MnemonicBuilder, Signer as AlloySigner, @@ -12,7 +12,7 @@ use foundry_config::Config; use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner}; use rand::thread_rng; use serde_json::json; -use std::{path::Path, str::FromStr}; +use std::path::Path; use yansi::Paint; pub mod vanity; @@ -273,9 +273,8 @@ impl WalletSubcommands { println!("0x{sig}"); } WalletSubcommands::Verify { message, signature, address } => { - let recovered_address = - signature.recover_address_from_prehash(&B256::from_str(&message)?)?; - if recovered_address == address { + let recovered_address = Self::recover_address_from_message(&message, &signature)?; + if address == recovered_address { println!("Validation succeeded. Address {address} signed this message."); } else { println!("Validation failed. Address {address} did not sign this message."); @@ -355,6 +354,11 @@ flag to set your key via: Ok(()) } + /// Recovers an address from the specified message and signature + fn recover_address_from_message(message: &str, signature: &Signature) -> Result
{ + Ok(signature.recover_address_from_msg(message)?) + } + fn hex_str_to_bytes(s: &str) -> Result> { Ok(match s.strip_prefix("0x") { Some(data) => hex::decode(data).wrap_err("Could not decode 0x-prefixed string.")?, @@ -365,6 +369,10 @@ flag to set your key via: #[cfg(test)] mod tests { + use std::str::FromStr; + + use alloy_primitives::address; + use super::*; #[test] @@ -393,6 +401,17 @@ mod tests { } } + #[test] + fn can_verify_signed_hex_message() { + let message = "hello"; + let signature = Signature::from_str("f2dd00eac33840c04b6fc8a5ec8c4a47eff63575c2bc7312ecb269383de0c668045309c423484c8d097df306e690c653f8e1ec92f7f6f45d1f517027771c3e801c").unwrap(); + let address = address!("28A4F420a619974a2393365BCe5a7b560078Cc13"); + let recovered_address = + WalletSubcommands::recover_address_from_message(message, &signature); + assert!(recovered_address.is_ok()); + assert_eq!(address, recovered_address.unwrap()); + } + #[test] fn can_parse_wallet_sign_data() { let args = WalletSubcommands::parse_from(["foundry-cli", "sign", "--data", "{ ... }"]); From ac802618e15039b31e464ae6d1fe3ee39f87cefd Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 23 Feb 2024 19:18:51 +0400 Subject: [PATCH 0668/1963] fix(forge): prefer --from if specified for `cast call` (#7218) * fix(forge): use --from if specified for call * Update crates/wallets/src/wallet.rs Co-authored-by: Enrique * fmt --------- Co-authored-by: Enrique --- crates/wallets/src/wallet.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index a15f805b93fc8..0cb06980df652 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -130,12 +130,18 @@ of the unlocked account you want to use, or provide the --from flag with the add Ok(signer) } - /// Returns the sender address of the signer or `from`. + /// This function prefers the `from` field and may return a different address from the + /// configured signer + /// If from is specified, returns it + /// If from is not specified, but there is a signer configured, returns the signer's address + /// If from is not specified and there is no signer configured, returns zero address pub async fn sender(&self) -> Address { - if let Ok(signer) = self.signer().await { + if let Some(from) = self.from { + from + } else if let Ok(signer) = self.signer().await { signer.address().to_alloy() } else { - self.from.unwrap_or(Address::ZERO) + Address::ZERO } } } From 81af7d3492ecddcb530db468c6b4f77923392e05 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 24 Feb 2024 05:06:23 +0200 Subject: [PATCH 0669/1963] feat: don't request Solc JSON AST unless absolutely necessary (#7197) * feat: don't request Solc JSON AST unless absolutely necessary * fix: don't require AST just for the path of a file * feat: add `--abi` and `abi = ` config values * fmt * fix config * fix: keep AST in build_info --- crates/chisel/src/session_source.rs | 13 ++---- crates/cli/src/opts/build/core.rs | 4 ++ crates/cli/src/opts/build/mod.rs | 5 +++ crates/cli/src/utils/mod.rs | 2 +- crates/common/src/compile.rs | 30 ++++++++++++- crates/common/src/contracts.rs | 10 ++--- crates/config/README.md | 1 + crates/config/src/lib.rs | 53 +++++++++++++--------- crates/forge/bin/cmd/coverage.rs | 67 +++++++++++++--------------- crates/forge/bin/cmd/flatten.rs | 9 ++-- crates/forge/bin/cmd/script/build.rs | 39 +++------------- crates/forge/bin/cmd/script/cmd.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 25 +++-------- crates/forge/tests/cli/config.rs | 3 +- 14 files changed, 130 insertions(+), 133 deletions(-) diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index c827454e97c4a..47660ba091aec 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -318,15 +318,10 @@ impl SessionSource { let mut sources = Sources::new(); sources.insert(self.file_name.clone(), Source::new(self.to_repl_source())); + let remappings = self.config.foundry_config.get_all_remappings().collect::>(); + // Include Vm.sol if forge-std remapping is not available - if !self.config.no_vm && - !self - .config - .foundry_config - .get_all_remappings() - .into_iter() - .any(|r| r.name.starts_with("forge-std")) - { + if !self.config.no_vm && !remappings.iter().any(|r| r.name.starts_with("forge-std")) { sources.insert(PathBuf::from("forge-std/Vm.sol"), Source::new(VM_SOURCE)); } @@ -337,7 +332,7 @@ impl SessionSource { .expect("Solidity source not found"); // get all remappings from the config - compiler_input.settings.remappings = self.config.foundry_config.get_all_remappings(); + compiler_input.settings.remappings = remappings; // We also need to enforce the EVM version that the user has specified. compiler_input.settings.evm_version = Some(self.config.foundry_config.evm_version); diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 02c14a90fa6e7..dd01710bd2f2d 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -216,6 +216,10 @@ impl Provider for CoreBuildArgs { dict.insert("build_info".to_string(), self.build_info.into()); } + if self.compiler.ast { + dict.insert("ast".to_string(), true.into()); + } + if self.compiler.optimize { dict.insert("optimizer".to_string(), self.compiler.optimize.into()); } diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index d502de2d41b95..0b97ed2dfe89a 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -15,6 +15,11 @@ pub use self::paths::ProjectPathsArgs; #[derive(Clone, Debug, Default, Serialize, Parser)] #[clap(next_help_heading = "Compiler options")] pub struct CompilerArgs { + /// Includes the AST as JSON in the compiler output. + #[clap(long, help_heading = "Compiler options")] + #[serde(skip)] + pub ast: bool, + /// The target EVM version. #[clap(long, value_name = "VERSION")] #[serde(skip_serializing_if = "Option::is_none")] diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index f900c50b071d4..99fcceb3e5fd1 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -30,7 +30,7 @@ pub use foundry_config::utils::*; /// Deterministic fuzzer seed used for gas snapshots and coverage reports. /// /// The keccak256 hash of "foundry rulez" -pub static STATIC_FUZZ_SEED: [u8; 32] = [ +pub const STATIC_FUZZ_SEED: [u8; 32] = [ 0x01, 0x00, 0xfa, 0x69, 0xa5, 0xf1, 0x71, 0x0a, 0x95, 0xcd, 0xef, 0x94, 0x88, 0x9b, 0x02, 0x84, 0x5d, 0x64, 0x0b, 0x19, 0xad, 0xf0, 0xe3, 0x57, 0xb8, 0xd4, 0xbe, 0x7d, 0x49, 0xee, 0x70, 0xe6, ]; diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 15debf8a539bd..459ae516e90ef 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -2,10 +2,10 @@ use crate::{compact_to_contract, glob::GlobMatcher, term::SpinnerReporter, TestFunctionExt}; use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Table}; -use eyre::Result; +use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ - artifacts::{BytecodeObject, ContractBytecodeSome}, + artifacts::{BytecodeObject, CompactContractBytecode, ContractBytecodeSome}, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, Artifact, ArtifactId, FileFilter, Graph, Project, ProjectCompileOutput, ProjectPathsConfig, @@ -281,6 +281,32 @@ pub struct ContractSources { } impl ContractSources { + /// Collects the contract sources and artifacts from the project compile output. + pub fn from_project_output( + output: &ProjectCompileOutput, + root: &Path, + ) -> Result { + let mut sources = ContractSources::default(); + for (id, artifact) in output.artifact_ids() { + if let Some(file_id) = artifact.id { + let abs_path = root.join(&id.path); + let source_code = std::fs::read_to_string(abs_path).wrap_err_with(|| { + format!("failed to read artifact source file for `{}`", id.identifier()) + })?; + let compact = CompactContractBytecode { + abi: artifact.abi.clone(), + bytecode: artifact.bytecode.clone(), + deployed_bytecode: artifact.deployed_bytecode.clone(), + }; + let contract = compact_to_contract(compact)?; + sources.insert(&id, file_id, source_code, contract); + } else { + warn!(id = id.identifier(), "source not found"); + } + } + Ok(sources) + } + /// Inserts a contract into the sources. pub fn insert( &mut self, diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index ed6c6ae20f71f..a1b251b768dd7 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -2,6 +2,7 @@ use alloy_json_abi::{Event, Function, JsonAbi}; use alloy_primitives::{hex, Address, Selector, B256}; +use eyre::Result; use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecodeSome}, ArtifactId, ProjectPathsConfig, @@ -33,10 +34,7 @@ impl ContractsByArtifact { /// Finds a contract which has the same contract name or identifier as `id`. If more than one is /// found, return error. - pub fn find_by_name_or_identifier( - &self, - id: &str, - ) -> eyre::Result> { + pub fn find_by_name_or_identifier(&self, id: &str) -> Result> { let contracts = self .iter() .filter(|(artifact, _)| artifact.name == id || artifact.identifier() == id) @@ -203,9 +201,7 @@ pub fn get_artifact_path(paths: &ProjectPathsConfig, path: &str) -> PathBuf { } /// Helper function to convert CompactContractBytecode ~> ContractBytecodeSome -pub fn compact_to_contract( - contract: CompactContractBytecode, -) -> eyre::Result { +pub fn compact_to_contract(contract: CompactContractBytecode) -> Result { Ok(ContractBytecodeSome { abi: contract.abi.ok_or_else(|| eyre::eyre!("No contract abi"))?, bytecode: contract.bytecode.ok_or_else(|| eyre::eyre!("No contract bytecode"))?.into(), diff --git a/crates/config/README.md b/crates/config/README.md index 004ade3851b31..880149f6220d0 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -139,6 +139,7 @@ extra_output_files = [] names = false sizes = false via_ir = false +ast = false # caches storage retrieved locally for certain chains and endpoints # can also be restricted to `chains = ["optimism", "mainnet"]` # by default all endpoints will be cached, alternative options are "remote" for only caching non localhost endpoints and "" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 3c7cc1d5e3768..1aa9841e0de28 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -320,6 +320,8 @@ pub struct Config { /// If set to true, changes compilation pipeline to go through the Yul intermediate /// representation. pub via_ir: bool, + /// Whether to include the AST as JSON in the compiler output. + pub ast: bool, /// RPC storage caching settings determines what chains and endpoints to cache pub rpc_storage_caching: StorageCachingConfig, /// Disables storage caching entirely. This overrides any settings made in @@ -670,7 +672,7 @@ impl Config { .set_auto_detect(self.is_auto_detect()) .set_offline(self.offline) .set_cached(cached) - .set_build_info(cached & self.build_info) + .set_build_info(cached && self.build_info) .set_no_artifacts(no_artifacts) .build()?; @@ -770,7 +772,7 @@ impl Config { .tests(&self.test) .scripts(&self.script) .artifacts(&self.out) - .libs(self.libs.clone()) + .libs(self.libs.iter()) .remappings(self.get_all_remappings()); if let Some(build_info_path) = &self.build_info_path { @@ -798,8 +800,8 @@ impl Config { /// contracts/tokens/token.sol /// contracts/math/math.sol /// ``` - pub fn get_all_remappings(&self) -> Vec { - self.remappings.iter().map(|m| m.clone().into()).collect() + pub fn get_all_remappings(&self) -> impl Iterator + '_ { + self.remappings.iter().map(|m| m.clone().into()) } /// Returns the configured rpc jwt secret @@ -1027,6 +1029,7 @@ impl Config { /// `extra_output` fields pub fn configured_artifacts_handler(&self) -> ConfigurableArtifacts { let mut extra_output = self.extra_output.clone(); + // Sourcify verification requires solc metadata output. Since, it doesn't // affect the UX & performance of the compiler, output the metadata files // by default. @@ -1036,7 +1039,7 @@ impl Config { extra_output.push(ContractOutputSelection::Metadata); } - ConfigurableArtifacts::new(extra_output, self.extra_output_files.clone()) + ConfigurableArtifacts::new(extra_output, self.extra_output_files.iter().cloned()) } /// Parses all libraries in the form of @@ -1045,28 +1048,30 @@ impl Config { Libraries::parse(&self.libraries) } + /// Returns all libraries with applied remappings. Same as `self.solc_settings()?.libraries`. + pub fn libraries_with_remappings(&self) -> Result { + Ok(self.parsed_libraries()?.with_applied_remappings(&self.project_paths())) + } + /// Returns the configured `solc` `Settings` that includes: - /// - all libraries - /// - the optimizer (including details, if configured) - /// - evm version + /// - all libraries + /// - the optimizer (including details, if configured) + /// - evm version pub fn solc_settings(&self) -> Result { - let libraries = self.parsed_libraries()?.with_applied_remappings(&self.project_paths()); - let optimizer = self.optimizer(); - // By default if no targets are specifically selected the model checker uses all targets. // This might be too much here, so only enable assertion checks. // If users wish to enable all options they need to do so explicitly. let mut model_checker = self.model_checker.clone(); - if let Some(ref mut model_checker_settings) = model_checker { + if let Some(model_checker_settings) = &mut model_checker { if model_checker_settings.targets.is_none() { model_checker_settings.targets = Some(vec![ModelCheckerTarget::Assert]); } } let mut settings = Settings { - optimizer, + libraries: self.libraries_with_remappings()?, + optimizer: self.optimizer(), evm_version: Some(self.evm_version), - libraries, metadata: Some(SettingsMetadata { use_literal_content: Some(self.use_literal_content), bytecode_hash: Some(self.bytecode_hash), @@ -1074,16 +1079,23 @@ impl Config { }), debug: self.revert_strings.map(|revert_strings| DebuggingSettings { revert_strings: Some(revert_strings), + // Not used. debug_info: Vec::new(), }), model_checker, - ..Default::default() + via_ir: Some(self.via_ir), + // Not used. + stop_after: None, + // Set in project paths. + remappings: Vec::new(), + // Set with `with_extra_output` below. + output_selection: Default::default(), } - .with_extra_output(self.configured_artifacts_handler().output_selection()) - .with_ast(); + .with_extra_output(self.configured_artifacts_handler().output_selection()); - if self.via_ir { - settings = settings.with_via_ir(); + // We're keeping AST in `--build-info` for backwards compatibility with HardHat. + if self.ast || self.build_info { + settings = settings.with_ast(); } Ok(settings) @@ -1877,6 +1889,7 @@ impl Default for Config { ignored_file_paths: vec![], deny_warnings: false, via_ir: false, + ast: false, rpc_storage_caching: Default::default(), rpc_endpoints: Default::default(), etherscan: Default::default(), @@ -2885,7 +2898,7 @@ mod tests { // contains additional remapping to the source dir assert_eq!( - config.get_all_remappings(), + config.get_all_remappings().collect::>(), vec![ Remapping::from_str("ds-test/=lib/ds-test/src/").unwrap(), Remapping::from_str("env-lib/=lib/env-lib/").unwrap(), diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 9d2bef5e0edf1..3505fc3182471 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -88,6 +88,9 @@ impl CoverageArgs { // Set fuzz seed so coverage reports are deterministic config.fuzz.seed = Some(U256::from_be_bytes(STATIC_FUZZ_SEED)); + // Coverage analysis requires the Solc AST output. + config.ast = true; + let (project, output) = self.build(&config)?; p_println!(!self.opts.silent => "Analysing contracts..."); let report = self.prepare(&config, output.clone())?; @@ -99,47 +102,41 @@ impl CoverageArgs { /// Builds the project. fn build(&self, config: &Config) -> Result<(Project, ProjectCompileOutput)> { // Set up the project - let project = { - let mut project = config.ephemeral_no_artifacts_project()?; - - if self.ir_minimum { - // TODO: How to detect solc version if the user does not specify a solc version in - // config case1: specify local installed solc ? - // case2: multiple solc versions used and auto_detect_solc == true - if let Some(SolcReq::Version(version)) = &config.solc { - if *version < Version::new(0, 8, 13) { - return Err(eyre::eyre!( + let mut project = config.ephemeral_no_artifacts_project()?; + if self.ir_minimum { + // TODO: How to detect solc version if the user does not specify a solc version in + // config case1: specify local installed solc ? + // case2: multiple solc versions used and auto_detect_solc == true + if let Some(SolcReq::Version(version)) = &config.solc { + if *version < Version::new(0, 8, 13) { + return Err(eyre::eyre!( "viaIR with minimum optimization is only available in Solidity 0.8.13 and above." )); - } } + } - // print warning message - p_println!(!self.opts.silent => "{}", - Paint::yellow( - concat!( - "Warning! \"--ir-minimum\" flag enables viaIR with minimum optimization, which can result in inaccurate source mappings.\n", + // print warning message + let msg = Paint::yellow(concat!( + "Warning! \"--ir-minimum\" flag enables viaIR with minimum optimization, \ + which can result in inaccurate source mappings.\n", "Only use this flag as a workaround if you are experiencing \"stack too deep\" errors.\n", "Note that \"viaIR\" is only available in Solidity 0.8.13 and above.\n", - "See more:\n", - "https://github.com/foundry-rs/foundry/issues/3357\n" - ))); - - // Enable viaIR with minimum optimization - // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 - // And also in new releases of solidity: - // https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 - project.solc_config.settings = - project.solc_config.settings.with_via_ir_minimum_optimization() - } else { - project.solc_config.settings.optimizer.disable(); - project.solc_config.settings.optimizer.runs = None; - project.solc_config.settings.optimizer.details = None; - project.solc_config.settings.via_ir = None; - } - - project - }; + "See more: https://github.com/foundry-rs/foundry/issues/3357", + )); + p_println!(!self.opts.silent => "{msg}"); + + // Enable viaIR with minimum optimization + // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 + // And also in new releases of solidity: + // https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 + project.solc_config.settings = + project.solc_config.settings.with_via_ir_minimum_optimization() + } else { + project.solc_config.settings.optimizer.disable(); + project.solc_config.settings.optimizer.runs = None; + project.solc_config.settings.optimizer.details = None; + project.solc_config.settings.via_ir = None; + } let output = ProjectCompiler::default() .compile(&project)? diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 9831e17cecce9..b4c1edcd9c5ee 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -36,13 +36,12 @@ impl FlattenArgs { // flatten is a subset of `BuildArgs` so we can reuse that to get the config let build_args = CoreBuildArgs { project_paths, ..Default::default() }; - - let config = build_args.try_load_config_emit_warnings()?; - - let target_path = dunce::canonicalize(target_path)?; - + let mut config = build_args.try_load_config_emit_warnings()?; + // `Flattener` uses the typed AST for better flattening results. + config.ast = true; let project = config.ephemeral_no_artifacts_project()?; + let target_path = dunce::canonicalize(target_path)?; let compiler_output = ProjectCompiler::new().files([target_path.clone()]).compile(&project); let flattened = match compiler_output { diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index ebd502a92a794..4b188d9553237 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -3,11 +3,7 @@ use alloy_primitives::{Address, Bytes}; use eyre::{Context, ContextCompat, Result}; use forge::link::{LinkOutput, Linker}; use foundry_cli::utils::get_cached_entry_by_name; -use foundry_common::{ - compact_to_contract, - compile::{self, ContractSources, ProjectCompiler}, - fs, -}; +use foundry_common::compile::{self, ContractSources, ProjectCompiler}; use foundry_compilers::{ artifacts::{ContractBytecode, ContractBytecodeSome, Libraries}, cache::SolFilesCache, @@ -28,38 +24,15 @@ impl ScriptArgs { /// Compiles the file with auto-detection and compiler params. pub fn build(&mut self, script_config: &mut ScriptConfig) -> Result { let (project, output) = self.get_project_and_output(script_config)?; - let output = output.with_stripped_file_prefixes(project.root()); - - let mut sources: ContractSources = Default::default(); - - let contracts = output - .into_artifacts() - .map(|(id, artifact)| -> Result<_> { - // Sources are only required for the debugger, but it *might* mean that there's - // something wrong with the build and/or artifacts. - if let Some(source) = artifact.source_file() { - let path = source - .ast - .ok_or_else(|| eyre::eyre!("source from artifact has no AST"))? - .absolute_path; - let abs_path = project.root().join(path); - let source_code = fs::read_to_string(abs_path).wrap_err_with(|| { - format!("failed to read artifact source file for `{}`", id.identifier()) - })?; - let contract = artifact.clone().into_contract_bytecode(); - let source_contract = compact_to_contract(contract)?; - sources.insert(&id, source.id, source_code, source_contract); - } else { - warn!(?id, "source not found"); - } - Ok((id, artifact)) - }) - .collect::>()?; + let root = project.root(); + let output = output.with_stripped_file_prefixes(root); + let sources = ContractSources::from_project_output(&output, root)?; + let contracts = output.into_artifacts().collect(); let target = self.find_target(&project, &contracts)?.clone(); script_config.target_contract = Some(target.clone()); - let libraries = script_config.config.solc_settings()?.libraries; + let libraries = script_config.config.libraries_with_remappings()?; let linker = Linker::new(project.root(), contracts); let (highlevel_known_contracts, libraries, predeploy_libraries) = self.link_script_target( diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index c1e0fefb0de3a..70fce668017f2 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -332,7 +332,7 @@ impl ScriptArgs { script_config.sender_nonce = nonce; let target = script_config.target_contract(); - let libraries = script_config.config.solc_settings()?.libraries; + let libraries = script_config.config.libraries_with_remappings()?; let (highlevel_known_contracts, libraries, predeploy_libraries) = self.link_script_target(&linker, libraries, new_sender, nonce, target.clone())?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 4f0f9f29940a9..d84817659da7a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -18,7 +18,6 @@ use foundry_cli::{ utils::{self, LoadConfig}, }; use foundry_common::{ - compact_to_contract, compile::{ContractSources, ProjectCompiler}, evm::EvmArgs, shell, @@ -33,7 +32,7 @@ use foundry_config::{ }; use foundry_debugger::Debugger; use regex::Regex; -use std::{collections::BTreeMap, fs, sync::mpsc::channel}; +use std::{collections::BTreeMap, sync::mpsc::channel}; use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; @@ -213,28 +212,16 @@ impl TestArgs { let outcome = self.run_tests(runner, config, verbosity, &filter, test_options).await?; if should_debug { - let mut sources = ContractSources::default(); - for (id, artifact) in output_clone.unwrap().into_artifacts() { - // Sources are only required for the debugger, but it *might* mean that there's - // something wrong with the build and/or artifacts. - if let Some(source) = artifact.source_file() { - let path = source - .ast - .ok_or_else(|| eyre::eyre!("Source from artifact has no AST."))? - .absolute_path; - let abs_path = project.root().join(&path); - let source_code = fs::read_to_string(abs_path)?; - let contract = artifact.clone().into_contract_bytecode(); - let source_contract = compact_to_contract(contract)?; - sources.insert(&id, source.id, source_code, source_contract); - } - } - // There is only one test. let Some(test) = outcome.into_tests_cloned().next() else { return Err(eyre::eyre!("no tests were executed")); }; + let sources = ContractSources::from_project_output( + output_clone.as_ref().unwrap(), + project.root(), + )?; + // Run the debugger. let mut builder = Debugger::builder() .debug_arenas(test.result.debug.as_slice()) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 2e4be0c6a8b50..4a2037af87e1c 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -99,6 +99,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { ignored_file_paths: vec![], deny_warnings: false, via_ir: true, + ast: false, rpc_storage_caching: StorageCachingConfig { chains: CachedChains::None, endpoints: CachedEndpoints::Remote, @@ -548,7 +549,7 @@ forgetest_init!( pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); let config = cmd.config(); - let remappings = config.get_all_remappings(); + let remappings = config.get_all_remappings().collect::>(); pretty_assertions::assert_eq!( remappings, vec![ From dacd9cf1ec230f9e5b7cf348f65bab4515906484 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 24 Feb 2024 05:12:22 +0200 Subject: [PATCH 0670/1963] test: move forge-std test to external tests (#7227) --- .github/scripts/matrices.py | 6 ----- crates/config/src/lib.rs | 6 ++--- crates/forge/tests/cli/ext_integration.rs | 8 +++++++ crates/forge/tests/cli/test_cmd.rs | 27 +---------------------- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 0a47c96a21959..3fdcea1154211 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -92,12 +92,6 @@ def __init__( n_partitions=2, pr_cross_platform=False, ), - Case( - name="integration / forge-std", - filter="package(=forge) & test(~forge_std)", - n_partitions=1, - pr_cross_platform=False, - ), Case( name="integration / external", filter="package(=forge) & test(~ext_integration)", diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 1aa9841e0de28..f582322a9ae94 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -354,10 +354,8 @@ pub struct Config { /// included in solc's output selection, see also /// [OutputSelection](foundry_compilers::artifacts::output_selection::OutputSelection) pub sparse_mode: bool, - /// Whether to emit additional build info files - /// - /// If set to `true`, `ethers-solc` will generate additional build info json files for every - /// new build, containing the `CompilerInput` and `CompilerOutput` + /// Generates additional build info json files for every new build, containing the + /// `CompilerInput` and `CompilerOutput`. pub build_info: bool, /// The path to the `build-info` directory that contains the build info json files. pub build_info_path: Option, diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 76c497837be33..3483708f2c37f 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -1,5 +1,13 @@ use foundry_test_utils::util::ExtTester; +#[test] +fn forge_std() { + ExtTester::new("foundry-rs", "forge-std", "1d0766bc5d814f117c7b1e643828f7d85024fb51") + // Skip fork tests. + .args(["--nmc", "Fork"]) + .run(); +} + #[test] fn solmate() { ExtTester::new("transmissions11", "solmate", "c892309933b25c03d32b1b0d674df7ae292ba925").run(); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 25a30a1fd0404..58b9b1eb85de3 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2,7 +2,7 @@ use foundry_common::rpc; use foundry_config::Config; use foundry_test_utils::util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}; -use std::{path::PathBuf, process::Command, str::FromStr}; +use std::{path::PathBuf, str::FromStr}; // tests that test filters are handled correctly forgetest!(can_set_filter_values, |prj, cmd| { @@ -259,31 +259,6 @@ contract ContractTest is DSTest { ); }); -// checks that we can test forge std successfully -// `forgetest_init!` will install with `forge-std` under `lib/forge-std` -forgetest_init!( - #[serial_test::serial] - can_test_forge_std, - |prj, cmd| { - let forge_std_dir = prj.root().join("lib/forge-std"); - let status = Command::new("git") - .current_dir(&forge_std_dir) - .args(["pull", "origin", "master"]) - .status() - .unwrap(); - if !status.success() { - panic!("failed to update forge-std"); - } - - // execute in subdir - cmd.cmd().current_dir(forge_std_dir); - cmd.args(["test", "--root", "."]); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("[PASS]"), "No tests passed:\n{stdout}"); - assert!(!stdout.contains("[FAIL]"), "Tests failed:\n{stdout}"); - } -); - // tests that libraries are handled correctly in multiforking mode forgetest_init!(can_use_libs_in_multi_fork, |prj, cmd| { prj.wipe_contracts(); From eb5d8d46e3f2b70177ef4b2ef24d50373b446faf Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 24 Feb 2024 06:20:47 +0200 Subject: [PATCH 0671/1963] test: remove serial_test from forge tests (#7226) --- Cargo.lock | 9 +- crates/chisel/Cargo.toml | 2 +- crates/forge/Cargo.toml | 1 - crates/forge/tests/cli/cmd.rs | 33 ++- crates/forge/tests/cli/config.rs | 390 ++++++++++++++----------------- crates/forge/tests/cli/create.rs | 312 ++++++++++++------------- crates/forge/tests/cli/script.rs | 343 ++++++++++++--------------- 7 files changed, 502 insertions(+), 588 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 116f3afd1f08c..d86ef66f2dc6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2943,7 +2943,6 @@ dependencies = [ "semver 1.0.21", "serde", "serde_json", - "serial_test", "similar", "solang-parser", "strum 0.26.1", @@ -6884,9 +6883,9 @@ dependencies = [ [[package]] name = "serial_test" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d" +checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" dependencies = [ "dashmap", "futures", @@ -6898,9 +6897,9 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" +checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 22d78e64e6113..589beaa3ef7f9 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -53,7 +53,7 @@ tracing.workspace = true [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } once_cell = "1" -serial_test = "2" +serial_test = "3" tracing-subscriber.workspace = true [features] diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index cf4640bb8ab44..516575ce543f7 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -92,7 +92,6 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -serial_test = "2" svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index e5d7f712d364b..18877265772c3 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -614,15 +614,12 @@ contract Foo { }); // test that `forge snapshot` commands work -forgetest!( - #[serial_test::serial] - can_check_snapshot, - |prj, cmd| { - prj.insert_ds_test(); +forgetest!(can_check_snapshot, |prj, cmd| { + prj.insert_ds_test(); - prj.add_source( - "ATest.t.sol", - r#" + prj.add_source( + "ATest.t.sol", + r#" import "./test.sol"; contract ATest is DSTest { function testExample() public { @@ -630,20 +627,18 @@ contract ATest is DSTest { } } "#, - ) - .unwrap(); + ) + .unwrap(); - cmd.arg("snapshot"); + cmd.arg("snapshot"); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_check_snapshot.stdout"), - ); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_check_snapshot.stdout"), + ); - cmd.arg("--check"); - let _ = cmd.output(); - } -); + cmd.arg("--check"); + let _ = cmd.output(); +}); // test that `forge build` does not print `(with warnings)` if file path is ignored forgetest!(can_compile_without_warnings_ignored_file_paths, |prj, cmd| { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 4a2037af87e1c..f6fe89efb2a05 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -130,195 +130,172 @@ forgetest!(can_extract_config_values, |prj, cmd| { }); // tests config gets printed to std out -forgetest!( - #[serial_test::serial] - can_show_config, - |prj, cmd| { - cmd.arg("config"); - let expected = - Config::load_with_root(prj.root()).to_string_pretty().unwrap().trim().to_string(); - assert_eq!(expected, cmd.stdout_lossy().trim().to_string()); - } -); +forgetest!(can_show_config, |prj, cmd| { + cmd.arg("config"); + let expected = + Config::load_with_root(prj.root()).to_string_pretty().unwrap().trim().to_string(); + assert_eq!(expected, cmd.stdout_lossy().trim().to_string()); +}); // checks that config works // - foundry.toml is properly generated // - paths are resolved properly // - config supports overrides from env, and cli -forgetest_init!( - #[serial_test::serial] - can_override_config, - |prj, cmd| { - cmd.set_current_dir(prj.root()); - let foundry_toml = prj.root().join(Config::FILE_NAME); - assert!(foundry_toml.exists()); - - let profile = Config::load_with_root(prj.root()); - // ensure that the auto-generated internal remapping for forge-std's ds-test exists - assert_eq!(profile.remappings.len(), 2); - assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); - - // ensure remappings contain test - assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); - // the loaded config has resolved, absolute paths - assert_eq!( - "ds-test/=lib/forge-std/lib/ds-test/src/", - Remapping::from(profile.remappings[0].clone()).to_string() - ); - - cmd.arg("config"); - let expected = profile.to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); - - // remappings work - let remappings_txt = - prj.create_file("remappings.txt", "ds-test/=lib/forge-std/lib/ds-test/from-file/"); - let config = forge_utils::load_config_with_root(Some(prj.root().into())); - assert_eq!( - format!( - "ds-test/={}/", - prj.root().join("lib/forge-std/lib/ds-test/from-file").to_slash_lossy() - ), - Remapping::from(config.remappings[0].clone()).to_string() - ); - - // env vars work - std::env::set_var("DAPP_REMAPPINGS", "ds-test/=lib/forge-std/lib/ds-test/from-env/"); - let config = forge_utils::load_config_with_root(Some(prj.root().into())); - assert_eq!( - format!( - "ds-test/={}/", - prj.root().join("lib/forge-std/lib/ds-test/from-env").to_slash_lossy() - ), - Remapping::from(config.remappings[0].clone()).to_string() - ); - - let config = - prj.config_from_output(["--remappings", "ds-test/=lib/forge-std/lib/ds-test/from-cli"]); - assert_eq!( - format!( - "ds-test/={}/", - prj.root().join("lib/forge-std/lib/ds-test/from-cli").to_slash_lossy() - ), - Remapping::from(config.remappings[0].clone()).to_string() - ); - - let config = prj.config_from_output(["--remappings", "other-key/=lib/other/"]); - assert_eq!(config.remappings.len(), 3); - assert_eq!( - format!("other-key/={}/", prj.root().join("lib/other").to_slash_lossy()), - // As CLI has the higher priority, it'll be found at the first slot. - Remapping::from(config.remappings[0].clone()).to_string() - ); - - std::env::remove_var("DAPP_REMAPPINGS"); - pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); - - cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); - let expected = profile.into_basic().to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); - } -); - -forgetest_init!( - #[serial_test::serial] - can_parse_remappings_correctly, - |prj, cmd| { - cmd.set_current_dir(prj.root()); - let foundry_toml = prj.root().join(Config::FILE_NAME); - assert!(foundry_toml.exists()); - - let profile = Config::load_with_root(prj.root()); - // ensure that the auto-generated internal remapping for forge-std's ds-test exists - assert_eq!(profile.remappings.len(), 2); - let [r, _] = &profile.remappings[..] else { unreachable!() }; - assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", r.to_string()); - - // the loaded config has resolved, absolute paths - assert_eq!( - "ds-test/=lib/forge-std/lib/ds-test/src/", - Remapping::from(r.clone()).to_string() - ); - - cmd.arg("config"); - let expected = profile.to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); - - let install = |cmd: &mut TestCommand, dep: &str| { - cmd.forge_fuse().args(["install", dep, "--no-commit"]); - cmd.assert_non_empty_stdout(); - }; - - install(&mut cmd, "transmissions11/solmate"); - let profile = Config::load_with_root(prj.root()); - // remappings work - let remappings_txt = prj.create_file( - "remappings.txt", - "solmate/=lib/solmate/src/\nsolmate-contracts/=lib/solmate/src/", - ); - let config = forge_utils::load_config_with_root(Some(prj.root().into())); - // trailing slashes are removed on windows `to_slash_lossy` - let path = prj.root().join("lib/solmate/src/").to_slash_lossy().into_owned(); - #[cfg(windows)] - let path = path + "/"; - assert_eq!( - format!("solmate/={path}"), - Remapping::from(config.remappings[0].clone()).to_string() - ); - // As this is an user-generated remapping, it is not removed, even if it points to the same - // location. - assert_eq!( - format!("solmate-contracts/={path}"), - Remapping::from(config.remappings[1].clone()).to_string() - ); - pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); - - cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); - let expected = profile.into_basic().to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); - } -); - -forgetest_init!( - #[serial_test::serial] - can_detect_config_vals, - |prj, _cmd| { - let url = "http://127.0.0.1:8545"; - let config = prj.config_from_output(["--no-auto-detect", "--rpc-url", url]); - assert!(!config.auto_detect_solc); - assert_eq!(config.eth_rpc_url, Some(url.to_string())); - - let mut config = Config::load_with_root(prj.root()); - config.eth_rpc_url = Some("http://127.0.0.1:8545".to_string()); - config.auto_detect_solc = false; - // write to `foundry.toml` - prj.create_file( - Config::FILE_NAME, - &config.to_string_pretty().unwrap().replace("eth_rpc_url", "eth-rpc-url"), - ); - let config = prj.config_from_output(["--force"]); - assert!(!config.auto_detect_solc); - assert_eq!(config.eth_rpc_url, Some(url.to_string())); - } -); +forgetest_init!(can_override_config, |prj, cmd| { + cmd.set_current_dir(prj.root()); + let foundry_toml = prj.root().join(Config::FILE_NAME); + assert!(foundry_toml.exists()); + + let profile = Config::load_with_root(prj.root()); + // ensure that the auto-generated internal remapping for forge-std's ds-test exists + assert_eq!(profile.remappings.len(), 2); + assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); + + // ensure remappings contain test + assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); + // the loaded config has resolved, absolute paths + assert_eq!( + "ds-test/=lib/forge-std/lib/ds-test/src/", + Remapping::from(profile.remappings[0].clone()).to_string() + ); + + cmd.arg("config"); + let expected = profile.to_string_pretty().unwrap(); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + + // remappings work + let remappings_txt = + prj.create_file("remappings.txt", "ds-test/=lib/forge-std/lib/ds-test/from-file/"); + let config = forge_utils::load_config_with_root(Some(prj.root().into())); + assert_eq!( + format!( + "ds-test/={}/", + prj.root().join("lib/forge-std/lib/ds-test/from-file").to_slash_lossy() + ), + Remapping::from(config.remappings[0].clone()).to_string() + ); + + // env vars work + std::env::set_var("DAPP_REMAPPINGS", "ds-test/=lib/forge-std/lib/ds-test/from-env/"); + let config = forge_utils::load_config_with_root(Some(prj.root().into())); + assert_eq!( + format!( + "ds-test/={}/", + prj.root().join("lib/forge-std/lib/ds-test/from-env").to_slash_lossy() + ), + Remapping::from(config.remappings[0].clone()).to_string() + ); + + let config = + prj.config_from_output(["--remappings", "ds-test/=lib/forge-std/lib/ds-test/from-cli"]); + assert_eq!( + format!( + "ds-test/={}/", + prj.root().join("lib/forge-std/lib/ds-test/from-cli").to_slash_lossy() + ), + Remapping::from(config.remappings[0].clone()).to_string() + ); + + let config = prj.config_from_output(["--remappings", "other-key/=lib/other/"]); + assert_eq!(config.remappings.len(), 3); + assert_eq!( + format!("other-key/={}/", prj.root().join("lib/other").to_slash_lossy()), + // As CLI has the higher priority, it'll be found at the first slot. + Remapping::from(config.remappings[0].clone()).to_string() + ); + + std::env::remove_var("DAPP_REMAPPINGS"); + pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); + + cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); + let expected = profile.into_basic().to_string_pretty().unwrap(); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); +}); + +forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { + cmd.set_current_dir(prj.root()); + let foundry_toml = prj.root().join(Config::FILE_NAME); + assert!(foundry_toml.exists()); + + let profile = Config::load_with_root(prj.root()); + // ensure that the auto-generated internal remapping for forge-std's ds-test exists + assert_eq!(profile.remappings.len(), 2); + let [r, _] = &profile.remappings[..] else { unreachable!() }; + assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", r.to_string()); + + // the loaded config has resolved, absolute paths + assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", Remapping::from(r.clone()).to_string()); + + cmd.arg("config"); + let expected = profile.to_string_pretty().unwrap(); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + + let install = |cmd: &mut TestCommand, dep: &str| { + cmd.forge_fuse().args(["install", dep, "--no-commit"]); + cmd.assert_non_empty_stdout(); + }; + + install(&mut cmd, "transmissions11/solmate"); + let profile = Config::load_with_root(prj.root()); + // remappings work + let remappings_txt = prj.create_file( + "remappings.txt", + "solmate/=lib/solmate/src/\nsolmate-contracts/=lib/solmate/src/", + ); + let config = forge_utils::load_config_with_root(Some(prj.root().into())); + // trailing slashes are removed on windows `to_slash_lossy` + let path = prj.root().join("lib/solmate/src/").to_slash_lossy().into_owned(); + #[cfg(windows)] + let path = path + "/"; + assert_eq!( + format!("solmate/={path}"), + Remapping::from(config.remappings[0].clone()).to_string() + ); + // As this is an user-generated remapping, it is not removed, even if it points to the same + // location. + assert_eq!( + format!("solmate-contracts/={path}"), + Remapping::from(config.remappings[1].clone()).to_string() + ); + pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); + + cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); + let expected = profile.into_basic().to_string_pretty().unwrap(); + assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); +}); + +forgetest_init!(can_detect_config_vals, |prj, _cmd| { + let url = "http://127.0.0.1:8545"; + let config = prj.config_from_output(["--no-auto-detect", "--rpc-url", url]); + assert!(!config.auto_detect_solc); + assert_eq!(config.eth_rpc_url, Some(url.to_string())); + + let mut config = Config::load_with_root(prj.root()); + config.eth_rpc_url = Some("http://127.0.0.1:8545".to_string()); + config.auto_detect_solc = false; + // write to `foundry.toml` + prj.create_file( + Config::FILE_NAME, + &config.to_string_pretty().unwrap().replace("eth_rpc_url", "eth-rpc-url"), + ); + let config = prj.config_from_output(["--force"]); + assert!(!config.auto_detect_solc); + assert_eq!(config.eth_rpc_url, Some(url.to_string())); +}); // checks that `clean` removes dapptools style paths -forgetest_init!( - #[serial_test::serial] - can_get_evm_opts, - |prj, _cmd| { - let url = "http://127.0.0.1:8545"; - let config = prj.config_from_output(["--rpc-url", url, "--ffi"]); - assert_eq!(config.eth_rpc_url, Some(url.to_string())); - assert!(config.ffi); - - std::env::set_var("FOUNDRY_ETH_RPC_URL", url); - let figment = Config::figment_with_root(prj.root()).merge(("debug", false)); - let evm_opts: EvmOpts = figment.extract().unwrap(); - assert_eq!(evm_opts.fork_url, Some(url.to_string())); - std::env::remove_var("FOUNDRY_ETH_RPC_URL"); - } -); +forgetest_init!(can_get_evm_opts, |prj, _cmd| { + let url = "http://127.0.0.1:8545"; + let config = prj.config_from_output(["--rpc-url", url, "--ffi"]); + assert_eq!(config.eth_rpc_url, Some(url.to_string())); + assert!(config.ffi); + + std::env::set_var("FOUNDRY_ETH_RPC_URL", url); + let figment = Config::figment_with_root(prj.root()).merge(("debug", false)); + let evm_opts: EvmOpts = figment.extract().unwrap(); + assert_eq!(evm_opts.fork_url, Some(url.to_string())); + std::env::remove_var("FOUNDRY_ETH_RPC_URL"); +}); // checks that we can set various config values forgetest_init!(can_set_config_values, |prj, _cmd| { @@ -533,33 +510,28 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { // test remappings with closer paths are prioritised // so that `dep/=lib/a/src` will take precedent over `dep/=lib/a/lib/b/src` -forgetest_init!( - #[serial_test::serial] - can_prioritise_closer_lib_remappings, - |prj, cmd| { - let config = cmd.config(); - - // create a new lib directly in the `lib` folder with conflicting remapping `forge-std/` - let mut config = config; - config.remappings = - vec![Remapping::from_str("forge-std/=lib/forge-std/src/").unwrap().into()]; - let nested = prj.paths().libraries[0].join("dep1"); - pretty_err(&nested, fs::create_dir_all(&nested)); - let toml_file = nested.join("foundry.toml"); - pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); - - let config = cmd.config(); - let remappings = config.get_all_remappings().collect::>(); - pretty_assertions::assert_eq!( - remappings, - vec![ - "dep1/=lib/dep1/src/".parse().unwrap(), - "ds-test/=lib/forge-std/lib/ds-test/src/".parse().unwrap(), - "forge-std/=lib/forge-std/src/".parse().unwrap() - ] - ); - } -); +forgetest_init!(can_prioritise_closer_lib_remappings, |prj, cmd| { + let config = cmd.config(); + + // create a new lib directly in the `lib` folder with conflicting remapping `forge-std/` + let mut config = config; + config.remappings = vec![Remapping::from_str("forge-std/=lib/forge-std/src/").unwrap().into()]; + let nested = prj.paths().libraries[0].join("dep1"); + pretty_err(&nested, fs::create_dir_all(&nested)); + let toml_file = nested.join("foundry.toml"); + pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); + + let config = cmd.config(); + let remappings = config.get_all_remappings().collect::>(); + pretty_assertions::assert_eq!( + remappings, + vec![ + "dep1/=lib/dep1/src/".parse().unwrap(), + "ds-test/=lib/forge-std/lib/ds-test/src/".parse().unwrap(), + "forge-std/=lib/forge-std/src/".parse().unwrap() + ] + ); +}); // test to check that foundry.toml libs section updates on install forgetest!(can_update_libs_section, |prj, cmd| { diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 9cb15954989fe..20f0aa7cca5a4 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -129,98 +129,87 @@ forgetest!(can_create_oracle_on_mumbai, |prj, cmd| { }); // tests that we can deploy the template contract -forgetest_async!( - #[serial_test::serial] - can_create_template_contract, - |prj, cmd| { - foundry_test_utils::util::initialize(prj.root()); - - let (_api, handle) = spawn(NodeConfig::test()).await; - let rpc = handle.http_endpoint(); - let wallet = handle.dev_wallets().next().unwrap(); - let pk = hex::encode(wallet.signer().to_bytes()); - - // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); - - cmd.forge_fuse().args([ - "create", - format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), - "--rpc-url", - rpc.as_str(), - "--private-key", - pk.as_str(), - ]); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_template_contract.stdout"), - ); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_template_contract-2nd.stdout"), - ); - } -); +forgetest_async!(can_create_template_contract, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + let (_api, handle) = spawn(NodeConfig::test()).await; + let rpc = handle.http_endpoint(); + let wallet = handle.dev_wallets().next().unwrap(); + let pk = hex::encode(wallet.signer().to_bytes()); + + // explicitly byte code hash for consistent checks + let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; + prj.write_config(config); + + cmd.forge_fuse().args([ + "create", + format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + ]); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_template_contract.stdout"), + ); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_template_contract-2nd.stdout"), + ); +}); // tests that we can deploy the template contract -forgetest_async!( - #[serial_test::serial] - can_create_using_unlocked, - |prj, cmd| { - foundry_test_utils::util::initialize(prj.root()); - - let (_api, handle) = spawn(NodeConfig::test()).await; - let rpc = handle.http_endpoint(); - let dev = handle.dev_accounts().next().unwrap(); - - // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); - - cmd.forge_fuse().args([ - "create", - format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), - "--rpc-url", - rpc.as_str(), - "--from", - format!("{dev:?}").as_str(), - "--unlocked", - ]); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_using_unlocked.stdout"), - ); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_using_unlocked-2nd.stdout"), - ); - } -); +forgetest_async!(can_create_using_unlocked, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + let (_api, handle) = spawn(NodeConfig::test()).await; + let rpc = handle.http_endpoint(); + let dev = handle.dev_accounts().next().unwrap(); + + // explicitly byte code hash for consistent checks + let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; + prj.write_config(config); + + cmd.forge_fuse().args([ + "create", + format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), + "--rpc-url", + rpc.as_str(), + "--from", + format!("{dev:?}").as_str(), + "--unlocked", + ]); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_using_unlocked.stdout"), + ); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_using_unlocked-2nd.stdout"), + ); +}); // tests that we can deploy with constructor args -forgetest_async!( - #[serial_test::serial] - can_create_with_constructor_args, - |prj, cmd| { - foundry_test_utils::util::initialize(prj.root()); - - let (_api, handle) = spawn(NodeConfig::test()).await; - let rpc = handle.http_endpoint(); - let wallet = handle.dev_wallets().next().unwrap(); - let pk = hex::encode(wallet.signer().to_bytes()); - - // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); - - prj.add_source( - "ConstructorContract", - r#" +forgetest_async!(can_create_with_constructor_args, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + let (_api, handle) = spawn(NodeConfig::test()).await; + let rpc = handle.http_endpoint(); + let wallet = handle.dev_wallets().next().unwrap(); + let pk = hex::encode(wallet.signer().to_bytes()); + + // explicitly byte code hash for consistent checks + let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; + prj.write_config(config); + + prj.add_source( + "ConstructorContract", + r#" contract ConstructorContract { string public name; @@ -229,28 +218,28 @@ contract ConstructorContract { } } "#, - ) - .unwrap(); - - cmd.forge_fuse().args([ - "create", - "./src/ConstructorContract.sol:ConstructorContract", - "--rpc-url", - rpc.as_str(), - "--private-key", - pk.as_str(), - "--constructor-args", - "My Constructor", - ]); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_with_constructor_args.stdout"), - ); - - prj.add_source( - "TupleArrayConstructorContract", - r#" + ) + .unwrap(); + + cmd.forge_fuse().args([ + "create", + "./src/ConstructorContract.sol:ConstructorContract", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + "--constructor-args", + "My Constructor", + ]); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_with_constructor_args.stdout"), + ); + + prj.add_source( + "TupleArrayConstructorContract", + r#" struct Point { uint256 x; uint256 y; @@ -260,46 +249,42 @@ contract TupleArrayConstructorContract { constructor(Point[] memory _points) {} } "#, - ) - .unwrap(); - - cmd.forge_fuse().args([ - "create", - "./src/TupleArrayConstructorContract.sol:TupleArrayConstructorContract", - "--rpc-url", - rpc.as_str(), - "--private-key", - pk.as_str(), - "--constructor-args", - "[(1,2), (2,3), (3,4)]", - ]); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_with_tuple_constructor_args.stdout"), - ); - } -); + ) + .unwrap(); + + cmd.forge_fuse().args([ + "create", + "./src/TupleArrayConstructorContract.sol:TupleArrayConstructorContract", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + "--constructor-args", + "[(1,2), (2,3), (3,4)]", + ]); + + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_create_with_tuple_constructor_args.stdout"), + ); +}); // -forgetest_async!( - #[serial_test::serial] - can_create_and_call, - |prj, cmd| { - foundry_test_utils::util::initialize(prj.root()); - - let (_api, handle) = spawn(NodeConfig::test()).await; - let rpc = handle.http_endpoint(); - let wallet = handle.dev_wallets().next().unwrap(); - let pk = hex::encode(wallet.signer().to_bytes()); - - // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); - - prj.add_source( - "UniswapV2Swap", - r#" +forgetest_async!(can_create_and_call, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + let (_api, handle) = spawn(NodeConfig::test()).await; + let rpc = handle.http_endpoint(); + let wallet = handle.dev_wallets().next().unwrap(); + let pk = hex::encode(wallet.signer().to_bytes()); + + // explicitly byte code hash for consistent checks + let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; + prj.write_config(config); + + prj.add_source( + "UniswapV2Swap", + r#" contract UniswapV2Swap { function pairInfo() public view returns (uint reserveA, uint reserveB, uint totalSupply) { @@ -308,19 +293,18 @@ contract UniswapV2Swap { } "#, - ) - .unwrap(); - - cmd.forge_fuse().args([ - "create", - "./src/UniswapV2Swap.sol:UniswapV2Swap", - "--rpc-url", - rpc.as_str(), - "--private-key", - pk.as_str(), - ]); - - let (stdout, _) = cmd.output_lossy(); - assert!(stdout.contains("Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3")); - } -); + ) + .unwrap(); + + cmd.forge_fuse().args([ + "create", + "./src/UniswapV2Swap.sol:UniswapV2Swap", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + ]); + + let (stdout, _) = cmd.output_lossy(); + assert!(stdout.contains("Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3")); +}); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index bcd53afcf3d07..b45ce52cf4451 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -444,97 +444,75 @@ forgetest_async!(can_deploy_script_with_lib, |prj, cmd| { .await; }); -forgetest_async!( - #[serial_test::serial] - can_deploy_script_private_key, - |prj, cmd| { - let (_api, handle) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - - tester - .load_addresses(&[ - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() - ]) - .await - .add_sig("BroadcastTest", "deployPrivateKey()") - .simulate(ScriptOutcome::OkSimulation) - .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment_addresses(&[( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), - 3, - )]) - .await; - } -); +forgetest_async!(can_deploy_script_private_key, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); -forgetest_async!( - #[serial_test::serial] - can_deploy_unlocked, - |prj, cmd| { - let (_api, handle) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - - tester - .sender("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266".parse().unwrap()) - .unlocked() - .add_sig("BroadcastTest", "deployOther()") - .simulate(ScriptOutcome::OkSimulation) - .broadcast(ScriptOutcome::OkBroadcast); - } -); + tester + .load_addresses(&[Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap()]) + .await + .add_sig("BroadcastTest", "deployPrivateKey()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment_addresses(&[( + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), + 3, + )]) + .await; +}); -forgetest_async!( - #[serial_test::serial] - can_deploy_script_remember_key, - |prj, cmd| { - let (_api, handle) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - - tester - .load_addresses(&[ - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() - ]) - .await - .add_sig("BroadcastTest", "deployRememberKey()") - .simulate(ScriptOutcome::OkSimulation) - .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment_addresses(&[( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), - 2, - )]) - .await; - } -); +forgetest_async!(can_deploy_unlocked, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); -forgetest_async!( - #[serial_test::serial] - can_deploy_script_remember_key_and_resume, - |prj, cmd| { - let (_api, handle) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - - tester - .add_deployer(0) - .load_addresses(&[ - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap() - ]) - .await - .add_sig("BroadcastTest", "deployRememberKeyResume()") - .simulate(ScriptOutcome::OkSimulation) - .resume(ScriptOutcome::MissingWallet) - // load missing wallet - .load_private_keys(&[0]) - .await - .run(ScriptOutcome::OkBroadcast) - .assert_nonce_increment_addresses(&[( - Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), - 1, - )]) - .await - .assert_nonce_increment(&[(0, 2)]) - .await; - } -); + tester + .sender("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266".parse().unwrap()) + .unlocked() + .add_sig("BroadcastTest", "deployOther()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast); +}); + +forgetest_async!(can_deploy_script_remember_key, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + + tester + .load_addresses(&[Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap()]) + .await + .add_sig("BroadcastTest", "deployRememberKey()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment_addresses(&[( + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), + 2, + )]) + .await; +}); + +forgetest_async!(can_deploy_script_remember_key_and_resume, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + + tester + .add_deployer(0) + .load_addresses(&[Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap()]) + .await + .add_sig("BroadcastTest", "deployRememberKeyResume()") + .simulate(ScriptOutcome::OkSimulation) + .resume(ScriptOutcome::MissingWallet) + // load missing wallet + .load_private_keys(&[0]) + .await + .run(ScriptOutcome::OkBroadcast) + .assert_nonce_increment_addresses(&[( + Address::from_str("0x90F79bf6EB2c4f870365E785982E1f101E93b906").unwrap(), + 1, + )]) + .await + .assert_nonce_increment(&[(0, 2)]) + .await; +}); forgetest_async!(can_resume_script, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; @@ -621,41 +599,33 @@ forgetest_async!(can_deploy_with_create2, |prj, cmd| { .run(ScriptOutcome::ScriptFailed); }); -forgetest_async!( - #[serial_test::serial] - can_deploy_and_simulate_25_txes_concurrently, - |prj, cmd| { - let (_api, handle) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - - tester - .load_private_keys(&[0]) - .await - .add_sig("BroadcastTestNoLinking", "deployMany()") - .simulate(ScriptOutcome::OkSimulation) - .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(&[(0, 25)]) - .await; - } -); +forgetest_async!(can_deploy_and_simulate_25_txes_concurrently, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); -forgetest_async!( - #[serial_test::serial] - can_deploy_and_simulate_mixed_broadcast_modes, - |prj, cmd| { - let (_api, handle) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - - tester - .load_private_keys(&[0]) - .await - .add_sig("BroadcastMix", "deployMix()") - .simulate(ScriptOutcome::OkSimulation) - .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(&[(0, 15)]) - .await; - } -); + tester + .load_private_keys(&[0]) + .await + .add_sig("BroadcastTestNoLinking", "deployMany()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(0, 25)]) + .await; +}); + +forgetest_async!(can_deploy_and_simulate_mixed_broadcast_modes, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + + tester + .load_private_keys(&[0]) + .await + .add_sig("BroadcastMix", "deployMix()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(0, 15)]) + .await; +}); forgetest_async!(deploy_with_setup, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; @@ -682,81 +652,76 @@ forgetest_async!(fail_broadcast_staticcall, |prj, cmd| { .simulate(ScriptOutcome::StaticCallNotAllowed); }); -forgetest_async!( - #[serial_test::serial] - check_broadcast_log, - |prj, cmd| { - let (api, handle) = spawn(NodeConfig::test()).await; - let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - - // Prepare CREATE2 Deployer - let addr = Address::from_str("0x4e59b44847b379578588920ca78fbf26c0b4956c").unwrap(); - let code = hex::decode("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3").expect("Could not decode create2 deployer init_code").into(); - api.anvil_set_code(addr, code).await.unwrap(); - - tester - .load_private_keys(&[0]) - .await - .add_sig("BroadcastTestSetup", "run()") - .simulate(ScriptOutcome::OkSimulation) - .broadcast(ScriptOutcome::OkBroadcast) - .assert_nonce_increment(&[(0, 6)]) - .await; - - // Uncomment to recreate the broadcast log - // std::fs::copy( - // "broadcast/Broadcast.t.sol/31337/run-latest.json", - // PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../testdata/fixtures/broadcast. - // log. json" ), ); - - // Check broadcast logs - // Ignore timestamp, blockHash, blockNumber, cumulativeGasUsed, effectiveGasPrice, - // transactionIndex and logIndex values since they can change inbetween runs - let re = Regex::new(r#"((timestamp":).[0-9]*)|((blockHash":).*)|((blockNumber":).*)|((cumulativeGasUsed":).*)|((effectiveGasPrice":).*)|((transactionIndex":).*)|((logIndex":).*)"#).unwrap(); - - let fixtures_log = std::fs::read_to_string( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("../../testdata/fixtures/broadcast.log.json"), - ) - .unwrap(); - let _fixtures_log = re.replace_all(&fixtures_log, ""); +forgetest_async!(check_broadcast_log, |prj, cmd| { + let (api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); - let run_log = - std::fs::read_to_string("broadcast/Broadcast.t.sol/31337/run-latest.json").unwrap(); - let _run_log = re.replace_all(&run_log, ""); + // Prepare CREATE2 Deployer + let addr = Address::from_str("0x4e59b44847b379578588920ca78fbf26c0b4956c").unwrap(); + let code = hex::decode("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3").expect("Could not decode create2 deployer init_code").into(); + api.anvil_set_code(addr, code).await.unwrap(); - // pretty_assertions::assert_eq!(fixtures_log, run_log); + tester + .load_private_keys(&[0]) + .await + .add_sig("BroadcastTestSetup", "run()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(0, 6)]) + .await; - // Uncomment to recreate the sensitive log - // std::fs::copy( - // "cache/Broadcast.t.sol/31337/run-latest.json", - // PathBuf::from(env!("CARGO_MANIFEST_DIR")) - // .join("../../testdata/fixtures/broadcast.sensitive.log.json"), - // ); + // Uncomment to recreate the broadcast log + // std::fs::copy( + // "broadcast/Broadcast.t.sol/31337/run-latest.json", + // PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../testdata/fixtures/broadcast. + // log. json" ), ); - // Check sensitive logs - // Ignore port number since it can change inbetween runs - let re = Regex::new(r":[0-9]+").unwrap(); + // Check broadcast logs + // Ignore timestamp, blockHash, blockNumber, cumulativeGasUsed, effectiveGasPrice, + // transactionIndex and logIndex values since they can change inbetween runs + let re = Regex::new(r#"((timestamp":).[0-9]*)|((blockHash":).*)|((blockNumber":).*)|((cumulativeGasUsed":).*)|((effectiveGasPrice":).*)|((transactionIndex":).*)|((logIndex":).*)"#).unwrap(); - let fixtures_log = std::fs::read_to_string( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("../../testdata/fixtures/broadcast.sensitive.log.json"), - ) - .unwrap(); - let fixtures_log = re.replace_all(&fixtures_log, ""); + let fixtures_log = std::fs::read_to_string( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../testdata/fixtures/broadcast.log.json"), + ) + .unwrap(); + let _fixtures_log = re.replace_all(&fixtures_log, ""); - let run_log = - std::fs::read_to_string("cache/Broadcast.t.sol/31337/run-latest.json").unwrap(); - let run_log = re.replace_all(&run_log, ""); + let run_log = + std::fs::read_to_string("broadcast/Broadcast.t.sol/31337/run-latest.json").unwrap(); + let _run_log = re.replace_all(&run_log, ""); - // Clean up carriage return OS differences - let re = Regex::new(r"\r\n").unwrap(); - let fixtures_log = re.replace_all(&fixtures_log, "\n"); - let run_log = re.replace_all(&run_log, "\n"); + // pretty_assertions::assert_eq!(fixtures_log, run_log); - pretty_assertions::assert_eq!(fixtures_log, run_log); - } -); + // Uncomment to recreate the sensitive log + // std::fs::copy( + // "cache/Broadcast.t.sol/31337/run-latest.json", + // PathBuf::from(env!("CARGO_MANIFEST_DIR")) + // .join("../../testdata/fixtures/broadcast.sensitive.log.json"), + // ); + + // Check sensitive logs + // Ignore port number since it can change inbetween runs + let re = Regex::new(r":[0-9]+").unwrap(); + + let fixtures_log = std::fs::read_to_string( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../testdata/fixtures/broadcast.sensitive.log.json"), + ) + .unwrap(); + let fixtures_log = re.replace_all(&fixtures_log, ""); + + let run_log = std::fs::read_to_string("cache/Broadcast.t.sol/31337/run-latest.json").unwrap(); + let run_log = re.replace_all(&run_log, ""); + + // Clean up carriage return OS differences + let re = Regex::new(r"\r\n").unwrap(); + let fixtures_log = re.replace_all(&fixtures_log, "\n"); + let run_log = re.replace_all(&run_log, "\n"); + + pretty_assertions::assert_eq!(fixtures_log, run_log); +}); forgetest_async!(test_default_sender_balance, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; From 05d89ca01b7a3d7c19198985ea6fbe2afd2ff437 Mon Sep 17 00:00:00 2001 From: RPate97 Date: Sat, 24 Feb 2024 03:24:41 -0800 Subject: [PATCH 0672/1963] fix(cheatcodes): Properly record call to create2 factory in state diff (#7207) --- crates/cheatcodes/src/inspector.rs | 50 ++++++++++++++-- crates/forge/tests/it/repros.rs | 7 +++ testdata/repros/Issue6634.t.sol | 95 ++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 testdata/repros/Issue6634.t.sol diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index a036ffa597e0d..878a037ab9765 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1237,7 +1237,13 @@ impl Inspector for Cheatcodes { // Apply the Create2 deployer if self.broadcast.is_some() || self.config.always_use_create_2_factory { - match apply_create2_deployer(data, call, self.prank.as_ref(), self.broadcast.as_ref()) { + match apply_create2_deployer( + data, + call, + self.prank.as_ref(), + self.broadcast.as_ref(), + self.recorded_account_diffs_stack.as_mut(), + ) { Ok(_) => {} Err(err) => return (InstructionResult::Revert, None, gas, Error::encode(err)), }; @@ -1249,6 +1255,15 @@ impl Inspector for Cheatcodes { let address = self.allow_cheatcodes_on_create(data, call); // If `recordAccountAccesses` has been called, record the create if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + // If the create scheme is create2, and the caller is the DEFAULT_CREATE2_DEPLOYER then + // we must add 1 to the depth to account for the call to the create2 factory. + let mut depth = data.journaled_state.depth(); + if let CreateScheme::Create2 { salt: _ } = call.scheme { + if call.caller == DEFAULT_CREATE2_DEPLOYER { + depth += 1; + } + } + // Record the create context as an account access and create a new vector to record all // subsequent account accesses recorded_account_diffs_stack.push(vec![AccountAccess { @@ -1269,7 +1284,7 @@ impl Inspector for Cheatcodes { deployedCode: vec![], // updated on create_end storageAccesses: vec![], // updated on create_end }, - depth: data.journaled_state.depth(), + depth, }]); } @@ -1432,17 +1447,44 @@ fn apply_create2_deployer( call: &mut CreateInputs, prank: Option<&Prank>, broadcast: Option<&Broadcast>, + diffs_stack: Option<&mut Vec>>, ) -> Result<(), DB::Error> { - if let CreateScheme::Create2 { salt: _ } = call.scheme { + if let CreateScheme::Create2 { salt } = call.scheme { let mut base_depth = 1; if let Some(prank) = &prank { base_depth = prank.depth; } else if let Some(broadcast) = &broadcast { base_depth = broadcast.depth; } + // If the create scheme is Create2 and the depth equals the broadcast/prank/default // depth, then use the default create2 factory as the deployer if data.journaled_state.depth() == base_depth { + // Record the call to the create2 factory in the state diff + if let Some(recorded_account_diffs_stack) = diffs_stack { + let calldata = [&salt.to_be_bytes::<32>()[..], &call.init_code[..]].concat(); + recorded_account_diffs_stack.push(vec![AccountAccess { + access: crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), + }, + accessor: call.caller, + account: DEFAULT_CREATE2_DEPLOYER, + kind: crate::Vm::AccountAccessKind::Call, + initialized: true, + oldBalance: U256::ZERO, // updated on create_end + newBalance: U256::ZERO, // updated on create_end + value: call.value, + data: calldata, + reverted: false, + deployedCode: vec![], // updated on create_end + storageAccesses: vec![], // updated on create_end + }, + depth: data.journaled_state.depth(), + }]) + } + // Sanity checks for our CREATE2 deployer let info = &data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?.0.info; @@ -1475,9 +1517,9 @@ fn process_broadcast_create( data: &mut EVMData<'_, DB>, call: &mut CreateInputs, ) -> (Bytes, Option
, u64) { + call.caller = broadcast_sender; match call.scheme { CreateScheme::Create => { - call.caller = broadcast_sender; (bytecode, None, data.journaled_state.account(broadcast_sender).info.nonce) } CreateScheme::Create2 { salt } => { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 7323d7ef131a4..8506a248de017 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -310,3 +310,10 @@ test_repro!(5529; |config| { cheats_config.always_use_create_2_factory = true; config.runner.cheats_config = std::sync::Arc::new(cheats_config); }); + +// https://github.com/foundry-rs/foundry/issues/6634 +test_repro!(6634; |config| { + let mut cheats_config = config.runner.cheats_config.as_ref().clone(); + cheats_config.always_use_create_2_factory = true; + config.runner.cheats_config = std::sync::Arc::new(cheats_config); +}); diff --git a/testdata/repros/Issue6634.t.sol b/testdata/repros/Issue6634.t.sol new file mode 100644 index 0000000000000..3b1acb9c18aa9 --- /dev/null +++ b/testdata/repros/Issue6634.t.sol @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; +import "../logs/console.sol"; + +contract Box { + uint256 public number; + + constructor(uint256 _number) { + number = _number; + } +} + +// https://github.com/foundry-rs/foundry/issues/6634 +contract Issue6634Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_Create2FactoryCallRecordedInStandardTest() public { + address CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + + vm.startStateDiffRecording(); + Box a = new Box{salt: 0}(1); + + Vm.AccountAccess[] memory called = vm.stopAndReturnStateDiff(); + address addr = vm.computeCreate2Address( + 0, keccak256(abi.encodePacked(type(Box).creationCode, uint256(1))), address(CREATE2_DEPLOYER) + ); + assertEq(addr, called[1].account, "state diff contract address is not correct"); + assertEq(address(a), called[1].account, "returned address is not correct"); + + assertEq(called.length, 2, "incorrect length"); + assertEq(uint256(called[0].kind), uint256(Vm.AccountAccessKind.Call), "first AccountAccess is incorrect kind"); + assertEq(called[0].account, CREATE2_DEPLOYER, "first AccountAccess account is incorrect"); + assertEq(called[0].accessor, address(this), "first AccountAccess accessor is incorrect"); + assertEq( + uint256(called[1].kind), uint256(Vm.AccountAccessKind.Create), "second AccountAccess is incorrect kind" + ); + assertEq(called[1].accessor, CREATE2_DEPLOYER, "second AccountAccess accessor is incorrect"); + assertEq(called[1].account, address(a), "second AccountAccess account is incorrect"); + } + + function test_Create2FactoryCallRecordedWhenPranking() public { + address CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + address accessor = address(0x5555); + + vm.startPrank(accessor); + vm.startStateDiffRecording(); + Box a = new Box{salt: 0}(1); + + Vm.AccountAccess[] memory called = vm.stopAndReturnStateDiff(); + address addr = vm.computeCreate2Address( + 0, keccak256(abi.encodePacked(type(Box).creationCode, uint256(1))), address(CREATE2_DEPLOYER) + ); + assertEq(addr, called[1].account, "state diff contract address is not correct"); + assertEq(address(a), called[1].account, "returned address is not correct"); + + assertEq(called.length, 2, "incorrect length"); + assertEq(uint256(called[0].kind), uint256(Vm.AccountAccessKind.Call), "first AccountAccess is incorrect kind"); + assertEq(called[0].account, CREATE2_DEPLOYER, "first AccountAccess accout is incorrect"); + assertEq(called[0].accessor, accessor, "first AccountAccess accessor is incorrect"); + assertEq( + uint256(called[1].kind), uint256(Vm.AccountAccessKind.Create), "second AccountAccess is incorrect kind" + ); + assertEq(called[1].accessor, CREATE2_DEPLOYER, "second AccountAccess accessor is incorrect"); + assertEq(called[1].account, address(a), "second AccountAccess account is incorrect"); + } + + function test_Create2FactoryCallRecordedWhenBroadcasting() public { + address CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + address accessor = address(0x5555); + + vm.startBroadcast(accessor); + vm.startStateDiffRecording(); + Box a = new Box{salt: 0}(1); + + Vm.AccountAccess[] memory called = vm.stopAndReturnStateDiff(); + address addr = vm.computeCreate2Address( + 0, keccak256(abi.encodePacked(type(Box).creationCode, uint256(1))), address(CREATE2_DEPLOYER) + ); + assertEq(addr, called[1].account, "state diff contract address is not correct"); + assertEq(address(a), called[1].account, "returned address is not correct"); + + assertEq(called.length, 2, "incorrect length"); + assertEq(uint256(called[0].kind), uint256(Vm.AccountAccessKind.Call), "first AccountAccess is incorrect kind"); + assertEq(called[0].account, CREATE2_DEPLOYER, "first AccountAccess accout is incorrect"); + assertEq(called[0].accessor, accessor, "first AccountAccess accessor is incorrect"); + assertEq( + uint256(called[1].kind), uint256(Vm.AccountAccessKind.Create), "second AccountAccess is incorrect kind" + ); + assertEq(called[1].accessor, CREATE2_DEPLOYER, "second AccountAccess accessor is incorrect"); + assertEq(called[1].account, address(a), "second AccountAccess account is incorrect"); + } +} From 43b4e23252b00a871923fb0acff3550519af0e68 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 24 Feb 2024 16:03:30 +0100 Subject: [PATCH 0673/1963] fix: handle rpc error response (#7229) --- crates/anvil/server/src/lib.rs | 2 +- crates/anvil/src/eth/api.rs | 49 +++++------------------- crates/anvil/src/eth/backend/mem/mod.rs | 50 ++++++------------------- crates/anvil/src/eth/error.rs | 11 +++++- crates/anvil/tests/it/fork.rs | 30 ++++++++++++++- 5 files changed, 60 insertions(+), 82 deletions(-) diff --git a/crates/anvil/server/src/lib.rs b/crates/anvil/server/src/lib.rs index 898d3a7659d5d..5ff287c96b3cf 100644 --- a/crates/anvil/server/src/lib.rs +++ b/crates/anvil/server/src/lib.rs @@ -117,7 +117,7 @@ pub trait RpcHandler: Clone + Send + Sync + 'static { /// **Note**: override this function if the expected `Request` deviates from `{ "method" : /// "", "params": "" }` async fn on_call(&self, call: RpcMethodCall) -> RpcResponse { - trace!(target: "rpc", id = ?call.id , method = ?call.method, "received method call"); + trace!(target: "rpc", id = ?call.id , method = ?call.method, params = ?call.params, "received method call"); let RpcMethodCall { method, params, id, .. } = call; let params: serde_json::Value = params.into(); diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 93d705f0bbf20..e9ba3ff84961d 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -602,10 +602,7 @@ impl EthApi { if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { - return fork - .get_balance(address, number) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.get_balance(address, number).await?) } } } @@ -630,9 +627,7 @@ impl EthApi { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { return Ok(B256::from( - fork.storage_at(address, index, Some(BlockNumber::Number(number))) - .await - .map_err(|_| BlockchainError::DataUnavailable)?, + fork.storage_at(address, index, Some(BlockNumber::Number(number))).await?, )); } } @@ -764,10 +759,7 @@ impl EthApi { if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { - return fork - .get_code(address, number) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.get_code(address, number).await?) } } } @@ -792,10 +784,7 @@ impl EthApi { if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return fork - .get_proof(address, keys, Some(number.into())) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.get_proof(address, keys, Some(number.into())).await?) } } } @@ -990,10 +979,7 @@ impl EthApi { "not available on past forked blocks".to_string(), )); } - return fork - .call(&request, Some(number.into())) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.call(&request, Some(number.into())).await?) } } } @@ -1040,10 +1026,7 @@ impl EthApi { if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { - return fork - .create_access_list(&request, Some(number.into())) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.create_access_list(&request, Some(number.into())).await?) } } } @@ -1185,10 +1168,7 @@ impl EthApi { self.backend.ensure_block_number(Some(BlockId::Hash(block_hash.into()))).await?; if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return fork - .uncle_by_block_hash_and_index(block_hash, idx.into()) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.uncle_by_block_hash_and_index(block_hash, idx.into()).await?) } } // It's impossible to have uncles outside of fork mode @@ -1207,10 +1187,7 @@ impl EthApi { let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?; if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return fork - .uncle_by_block_number_and_index(number, idx.into()) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.uncle_by_block_number_and_index(number, idx.into()).await?); } } // It's impossible to have uncles outside of fork mode @@ -2174,10 +2151,7 @@ impl EthApi { "not available on past forked blocks".to_string(), )); } - return fork - .estimate_gas(&request, Some(number.into())) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.estimate_gas(&request, Some(number.into())).await?) } } } @@ -2556,10 +2530,7 @@ impl EthApi { if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return fork - .get_nonce(address, number) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.get_nonce(address, number).await?); } } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f7234d9cd7c02..202cc880e9292 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -393,8 +393,7 @@ impl Backend { let fork_block_number = fork.block_number(); let fork_block = fork .block_by_number(fork_block_number) - .await - .map_err(|_| BlockchainError::DataUnavailable)? + .await? .ok_or(BlockchainError::BlockNotFound)?; // update all settings related to the forked block { @@ -1248,7 +1247,7 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return fork.logs(&filter).await.map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.logs(&filter).await?); } Ok(Vec::new()) @@ -1335,8 +1334,7 @@ impl Backend { if fork.predates_fork(from) { // this data is only available on the forked client let filter = filter.clone().from_block(from).to_block(to_on_fork); - all_logs = - fork.logs(&filter).await.map_err(|_| BlockchainError::DataUnavailable)?; + all_logs = fork.logs(&filter).await?; // update the range from = fork.block_number() + 1; @@ -1379,7 +1377,7 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return fork.block_by_hash(hash).await.map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.block_by_hash(hash).await?); } Ok(None) @@ -1395,10 +1393,7 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return fork - .block_by_hash_full(hash) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.block_by_hash_full(hash).await?) } Ok(None) @@ -1452,10 +1447,7 @@ impl Backend { if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork_inclusive(number) { - return fork - .block_by_number(number) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.block_by_number(number).await?) } } @@ -1474,10 +1466,7 @@ impl Backend { if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork_inclusive(number) { - return fork - .block_by_number_full(number) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.block_by_number_full(number).await?) } } @@ -1891,10 +1880,7 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return fork.debug_trace_transaction(hash, opts).await.map_err(|err| { - warn!(target: "backend", "error delegating debug_traceTransaction: {:?}", err); - BlockchainError::DataUnavailable - }) + return Ok(fork.debug_trace_transaction(hash, opts).await?) } Ok(GethTrace::Default(Default::default())) @@ -1920,10 +1906,7 @@ impl Backend { if let Some(fork) = self.get_fork() { if fork.predates_fork(number) { - return fork.trace_block(number).await.map_err(|err| { - warn!(target: "backend", "error delegating trace_block: {:?}", err); - BlockchainError::DataUnavailable - }) + return Ok(fork.trace_block(number).await?) } } @@ -1939,10 +1922,7 @@ impl Backend { } if let Some(fork) = self.get_fork() { - let receipt = fork - .transaction_receipt(hash) - .await - .map_err(|_| BlockchainError::DataUnavailable)?; + let receipt = fork.transaction_receipt(hash).await?; let number = self.convert_block_number( receipt .clone() @@ -2116,10 +2096,7 @@ impl Backend { if let Some(fork) = self.get_fork() { let number = self.convert_block_number(Some(number)); if fork.predates_fork(number) { - return fork - .transaction_by_block_number_and_index(number, index.into()) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.transaction_by_block_number_and_index(number, index.into()).await?) } } @@ -2136,10 +2113,7 @@ impl Backend { } if let Some(fork) = self.get_fork() { - return fork - .transaction_by_block_hash_and_index(hash, index.into()) - .await - .map_err(|_| BlockchainError::DataUnavailable); + return Ok(fork.transaction_by_block_hash_and_index(hash, index.into()).await?) } Ok(None) diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 37e0fce549201..cc7af40ac5157 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -359,8 +359,15 @@ impl ToRpcResponseResult for Result { "Invalid input: `max_priority_fee_per_gas` greater than `max_fee_per_gas`", ), BlockchainError::AlloyForkProvider(err) => { - error!(%err, "alloy fork provider error"); - RpcError::internal_error_with(format!("Fork Error: {err:?}")) + error!(target: "backend", %err, "fork provider error"); + match err { + TransportError::ErrorResp(err) => RpcError { + code: ErrorCode::from(err.code), + message: err.message.into(), + data: err.data.and_then(|data| serde_json::to_value(data).ok()), + }, + err => RpcError::internal_error_with(format!("Fork Error: {err:?}")), + } } err @ BlockchainError::EvmError(_) => { RpcError::internal_error_with(err.to_string()) diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index ceeeb16e7e1e3..8399dc85ad312 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -4,9 +4,12 @@ use crate::{ abi::*, utils::{self, ethers_http_provider}, }; -use alloy_primitives::U256 as rU256; +use alloy_primitives::{address, U256 as rU256}; use alloy_providers::provider::TempProvider; -use alloy_rpc_types::{request::TransactionRequest as CallRequest, BlockNumberOrTag}; +use alloy_rpc_types::{ + request::{TransactionInput, TransactionRequest as CallRequest}, + BlockNumberOrTag, +}; use alloy_signer::Signer as AlloySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; @@ -1119,3 +1122,26 @@ async fn test_arbitrum_fork_dev_balance() { assert_eq!(balance, rU256::from(100000000000000000000u128)); } } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_execution_reverted() { + let target = 16681681u64; + let (api, _handle) = spawn(fork_config().with_fork_block_number(Some(target + 1))).await; + + let resp = api + .call( + CallRequest { + to: Some(address!("Fd6CC4F251eaE6d02f9F7B41D1e80464D3d2F377")), + input: TransactionInput::new("0x8f283b3c".as_bytes().into()), + ..Default::default() + }, + Some(target.into()), + None, + ) + .await; + + assert!(resp.is_err()); + let err = resp.unwrap_err(); + assert!(err.to_string().contains("execution reverted")); +} From 474591aa1e6922a0d5691ae1e2dcc355d8fcb92d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 25 Feb 2024 13:07:01 +0100 Subject: [PATCH 0674/1963] chore(deps): weekly `cargo update` (#7235) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating ahash v0.8.8 -> v0.8.9 Updating alloy-consensus v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-genesis v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-network v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-providers v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-pubsub v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-rpc-client v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-rpc-trace-types v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-rpc-types v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-signer v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-transport v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-transport-http v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-transport-ipc v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating alloy-transport-ws v0.1.0 (https://github.com/alloy-rs/alloy#5062eaf1) -> #29a7886e Updating anstream v0.6.11 -> v0.6.12 Updating anyhow v1.0.79 -> v1.0.80 Updating bstr v1.9.0 -> v1.9.1 Updating bumpalo v3.15.0 -> v3.15.3 Updating c-kzg v0.4.1 -> v0.4.2 Updating cc v1.0.83 -> v1.0.87 Updating const-hex v1.11.0 -> v1.11.1 Updating darling v0.20.6 -> v0.20.8 Updating darling_core v0.20.6 -> v0.20.8 Updating darling_macro v0.20.6 -> v0.20.8 Updating event-listener v5.0.0 -> v5.1.0 Updating futures-timer v3.0.2 -> v3.0.3 Updating hermit-abi v0.3.6 -> v0.3.8 Removing jobserver v0.1.28 Updating lru v0.12.2 -> v0.12.3 Updating openssl v0.10.63 -> v0.10.64 Updating openssl-sys v0.9.99 -> v0.9.101 Updating ryu v1.0.16 -> v1.0.17 Updating semver v1.0.21 -> v1.0.22 Updating serde v1.0.196 -> v1.0.197 Updating serde_derive v1.0.196 -> v1.0.197 Updating serde_json v1.0.113 -> v1.0.114 Updating socket2 v0.5.5 -> v0.5.6 Updating syn v2.0.49 -> v2.0.50 Updating thread_local v1.1.7 -> v1.1.8 Updating unicode-normalization v0.1.22 -> v0.1.23 Updating windows-targets v0.52.0 -> v0.52.3 Updating windows_aarch64_gnullvm v0.52.0 -> v0.52.3 Updating windows_aarch64_msvc v0.52.0 -> v0.52.3 Updating windows_i686_gnu v0.52.0 -> v0.52.3 Updating windows_i686_msvc v0.52.0 -> v0.52.3 Updating windows_x86_64_gnu v0.52.0 -> v0.52.3 Updating windows_x86_64_gnullvm v0.52.0 -> v0.52.3 Updating windows_x86_64_msvc v0.52.0 -> v0.52.3 Updating winnow v0.6.1 -> v0.6.2 note: pass `--verbose` to see 179 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 322 ++++++++++++++++++++++++++--------------------------- 1 file changed, 156 insertions(+), 166 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d86ef66f2dc6b..55061bbe19f05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" +checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" dependencies = [ "cfg-if", "once_cell", @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -257,13 +257,13 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-network", "alloy-primitives", @@ -335,7 +335,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.49", + "syn 2.0.50", "syn-solidity", "tiny-keccak", ] @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -413,7 +413,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#5062eaf1af2733a7115bc0536c9708a42bfb53ca" +source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -462,9 +462,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" dependencies = [ "anstyle", "anstyle-parse", @@ -631,9 +631,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "arbitrary" @@ -797,7 +797,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 5.0.0", + "event-listener 5.1.0", "event-listener-strategy 0.5.0", "futures-core", "pin-project-lite", @@ -831,7 +831,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -848,7 +848,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -901,7 +901,7 @@ checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -1115,9 +1115,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", "regex-automata 0.4.5", @@ -1141,9 +1141,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.15.0" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "byte-slice-cast" @@ -1195,9 +1195,9 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d8c306be83ec04bf5f73710badd8edf56dea23f2f0d8b7f9fe4644d371c758" +checksum = "94a4bc5367b6284358d2a6a6a1dc2d92ec4b86034561c3b9d3341909752fd848" dependencies = [ "blst", "cc", @@ -1233,7 +1233,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "thiserror", @@ -1291,7 +1291,7 @@ dependencies = [ "rpassword", "rusoto_core", "rusoto_kms", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "tempfile", @@ -1309,11 +1309,10 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "3286b845d0fccbdd15af433f61c5970e711987036cb468f437ff6badd70f4e24" dependencies = [ - "jobserver", "libc", ] @@ -1347,7 +1346,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "serial_test", @@ -1371,7 +1370,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -1464,7 +1463,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -1653,9 +1652,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d59688ad0945eaf6b84cb44fedbe93484c81b48970e98f09db8a22832d7961" +checksum = "efbd12d49ab0eaf8193ba9175e45f56bbc2e4b27d57b8cfe62aa47942a46b9a9" dependencies = [ "cfg-if", "cpufeatures", @@ -1896,9 +1895,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c376d08ea6aa96aafe61237c7200d1241cb177b7d3a542d791f2d118e9cbb955" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" dependencies = [ "darling_core", "darling_macro", @@ -1906,27 +1905,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33043dcd19068b8192064c704b3f83eb464f91f1ff527b44a4e2b08d9cdb8855" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] name = "darling_macro" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -1987,7 +1986,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2008,7 +2007,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2018,7 +2017,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2260,7 +2259,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2468,7 +2467,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.49", + "syn 2.0.50", "toml 0.8.10", "walkdir", ] @@ -2485,7 +2484,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2510,7 +2509,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.49", + "syn 2.0.50", "tempfile", "thiserror", "tiny-keccak", @@ -2525,7 +2524,7 @@ dependencies = [ "chrono", "ethers-core", "reqwest", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "thiserror", @@ -2615,7 +2614,7 @@ dependencies = [ "rand 0.8.5", "rusoto_core", "rusoto_kms", - "semver 1.0.21", + "semver 1.0.22", "sha2 0.10.8", "spki", "thiserror", @@ -2644,7 +2643,7 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "sha2 0.10.8", @@ -2679,9 +2678,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.0.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72557800024fabbaa2449dd4bf24e37b93702d457a4d4f2b0dd1f0f039f20c1" +checksum = "b7ad6fd685ce13acd6d9541a30f6db6567a7a24c9ffd4ba2955d29e3f22c8b27" dependencies = [ "concurrent-queue", "parking", @@ -2704,7 +2703,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" dependencies = [ - "event-listener 5.0.0", + "event-listener 5.1.0", "pin-project-lite", ] @@ -2764,7 +2763,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2940,7 +2939,7 @@ dependencies = [ "regex", "reqwest", "revm-inspectors", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "similar", @@ -3019,7 +3018,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "reqwest", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "thiserror", @@ -3142,7 +3141,7 @@ dependencies = [ "pretty_assertions", "rand 0.8.5", "reqwest", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "tempfile", @@ -3177,7 +3176,7 @@ dependencies = [ "rand 0.8.5", "rayon", "regex", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "sha2 0.10.8", @@ -3213,7 +3212,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "serde_regex", @@ -3317,7 +3316,7 @@ dependencies = [ "foundry-compilers", "foundry-evm-core", "revm", - "semver 1.0.21", + "semver 1.0.22", "tracing", ] @@ -3381,7 +3380,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3548,7 +3547,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3565,9 +3564,9 @@ checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" dependencies = [ "gloo-timers", "send_wrapper 0.4.0", @@ -3974,7 +3973,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.8", + "ahash 0.8.9", "allocator-api2", "serde", ] @@ -3996,9 +3995,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" +checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" [[package]] name = "hex" @@ -4448,15 +4447,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" -[[package]] -name = "jobserver" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.68" @@ -4651,9 +4641,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ "hashbrown 0.14.3", ] @@ -4812,7 +4802,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5078,7 +5068,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5161,9 +5151,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ "bitflags 2.4.2", "cfg-if", @@ -5182,7 +5172,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5193,9 +5183,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" dependencies = [ "cc", "libc", @@ -5392,7 +5382,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5450,7 +5440,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5553,7 +5543,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5591,7 +5581,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5702,7 +5692,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -5797,7 +5787,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", "version_check", "yansi 1.0.0-rc.1", ] @@ -6471,7 +6461,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.21", + "semver 1.0.22", ] [[package]] @@ -6585,9 +6575,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "salsa20" @@ -6758,9 +6748,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" dependencies = [ "serde", ] @@ -6788,22 +6778,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -6819,9 +6809,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "indexmap", "itoa", @@ -6857,7 +6847,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -6903,7 +6893,7 @@ checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7069,12 +7059,12 @@ checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -7200,7 +7190,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7213,7 +7203,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7246,7 +7236,7 @@ dependencies = [ "hex", "once_cell", "reqwest", - "semver 1.0.21", + "semver 1.0.22", "serde", "serde_json", "sha2 0.10.8", @@ -7263,7 +7253,7 @@ checksum = "aa64b5e8eecd3a8af7cfc311e29db31a268a62d5953233d3e8243ec77a71c4e3" dependencies = [ "build_const", "hex", - "semver 1.0.21", + "semver 1.0.22", "serde_json", "svm-rs", ] @@ -7276,7 +7266,7 @@ checksum = "5b8d3c94c4d3337336f58493471b98d712c267c66977b0fbe48efd6cbf69ffd0" dependencies = [ "build_const", "hex", - "semver 1.0.21", + "semver 1.0.22", "serde_json", "svm-rs", ] @@ -7294,9 +7284,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.49" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", @@ -7312,7 +7302,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7434,14 +7424,14 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -7556,7 +7546,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7707,7 +7697,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.1", + "winnow 0.6.2", ] [[package]] @@ -7789,7 +7779,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -7994,9 +7984,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] @@ -8155,7 +8145,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", "wasm-bindgen-shared", ] @@ -8189,7 +8179,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8332,7 +8322,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -8359,7 +8349,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -8394,17 +8384,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", ] [[package]] @@ -8421,9 +8411,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" [[package]] name = "windows_aarch64_msvc" @@ -8439,9 +8429,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" [[package]] name = "windows_i686_gnu" @@ -8457,9 +8447,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" [[package]] name = "windows_i686_msvc" @@ -8475,9 +8465,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" [[package]] name = "windows_x86_64_gnu" @@ -8493,9 +8483,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" [[package]] name = "windows_x86_64_gnullvm" @@ -8511,9 +8501,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" [[package]] name = "windows_x86_64_msvc" @@ -8529,9 +8519,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" [[package]] name = "winnow" @@ -8544,9 +8534,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" +checksum = "7a4191c47f15cc3ec71fcb4913cb83d58def65dd3787610213c649283b5ce178" dependencies = [ "memchr", ] @@ -8624,7 +8614,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -8644,7 +8634,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] From 17215eb2f7205849ea1c9849fafcb96c3c3a85ea Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:59:57 +0200 Subject: [PATCH 0675/1963] fix(forge): total duration is not the sum of individual runs (#7228) * fix(forge): total duration is not the sum of individual runs * updates * update * chore: clippy --- crates/forge/bin/cmd/test/mod.rs | 8 +++-- crates/forge/src/result.rs | 29 ++++++++++----- crates/forge/src/runner.rs | 36 +++++++++---------- .../tests/fixtures/can_check_snapshot.stdout | 2 +- .../can_run_test_in_custom_test_folder.stdout | 2 +- .../tests/fixtures/can_test_repeatedly.stdout | 2 +- .../can_use_libs_in_multi_fork.stdout | 2 +- .../include_custom_types_in_traces.stdout | 2 +- crates/forge/tests/fixtures/repro_6531.stdout | 2 +- ...xactly_once_with_changed_versions.1.stdout | 2 +- ...xactly_once_with_changed_versions.2.stdout | 2 +- crates/test-utils/src/util.rs | 2 +- 12 files changed, 53 insertions(+), 38 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index d84817659da7a..ba928f6ea3134 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -32,7 +32,7 @@ use foundry_config::{ }; use foundry_debugger::Debugger; use regex::Regex; -use std::{collections::BTreeMap, sync::mpsc::channel}; +use std::{sync::mpsc::channel, time::Instant}; use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; @@ -296,6 +296,7 @@ impl TestArgs { // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); + let timer = Instant::now(); let handle = tokio::task::spawn({ let filter = filter.clone(); async move { runner.test(&filter, tx, test_options).await } @@ -419,6 +420,7 @@ impl TestArgs { break; } } + let duration = timer.elapsed(); trace!(target: "forge::test", len=outcome.results.len(), %any_test_failed, "done with results"); @@ -429,7 +431,7 @@ impl TestArgs { } if !outcome.results.is_empty() { - shell::println(outcome.summary())?; + shell::println(outcome.summary(duration))?; if self.summary { let mut summary_table = TestSummaryReporter::new(self.detailed); @@ -515,7 +517,7 @@ fn list( } } } - Ok(TestOutcome::new(BTreeMap::new(), false)) + Ok(TestOutcome::empty(false)) } #[cfg(test)] diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index cb53756551d72..1605f72fe8f97 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -42,7 +42,7 @@ impl TestOutcome { /// Creates a new empty test outcome. pub fn empty(allow_failure: bool) -> Self { - Self { results: BTreeMap::new(), allow_failure, decoder: None } + Self::new(BTreeMap::new(), allow_failure) } /// Returns an iterator over all individual succeeding tests and their names. @@ -112,13 +112,15 @@ impl TestOutcome { self.failures().count() } - /// Calculates the total duration of all test suites. - pub fn duration(&self) -> Duration { + /// Sums up all the durations of all individual test suites. + /// + /// Note that this is not necessarily the wall clock time of the entire test run. + pub fn total_time(&self) -> Duration { self.results.values().map(|suite| suite.duration).sum() } /// Formats the aggregated summary of all test suites into a string (for printing). - pub fn summary(&self) -> String { + pub fn summary(&self, wall_clock_time: Duration) -> String { let num_test_suites = self.results.len(); let suites = if num_test_suites == 1 { "suite" } else { "suites" }; let total_passed = self.passed(); @@ -126,10 +128,11 @@ impl TestOutcome { let total_skipped = self.skipped(); let total_tests = total_passed + total_failed + total_skipped; format!( - "\nRan {} test {} in {:.2?}: {} tests passed, {} failed, {} skipped ({} total tests)", + "\nRan {} test {} in {:.2?} ({:.2?} CPU time): {} tests passed, {} failed, {} skipped ({} total tests)", num_test_suites, suites, - self.duration(), + wall_clock_time, + self.total_time(), Paint::green(total_passed), Paint::red(total_failed), Paint::yellow(total_skipped), @@ -180,7 +183,7 @@ impl TestOutcome { /// A set of test results for a single test suite, which is all the tests in a single contract. #[derive(Clone, Debug, Serialize)] pub struct SuiteResult { - /// Total duration of the test run for this block of tests. + /// Wall clock time it took to execute all tests in this suite. pub duration: Duration, /// Individual test results: `test fn signature -> TestResult`. pub test_results: BTreeMap, @@ -242,17 +245,25 @@ impl SuiteResult { self.test_results.len() } + /// Sums up all the durations of all individual tests in this suite. + /// + /// Note that this is not necessarily the wall clock time of the entire test suite. + pub fn total_time(&self) -> Duration { + self.test_results.values().map(|result| result.duration).sum() + } + /// Returns the summary of a single test suite. pub fn summary(&self) -> String { let failed = self.failed(); let result = if failed == 0 { Paint::green("ok") } else { Paint::red("FAILED") }; format!( - "Test result: {}. {} passed; {} failed; {} skipped; finished in {:.2?}", + "Suite result: {}. {} passed; {} failed; {} skipped; finished in {:.2?} ({:.2?} CPU time)", result, Paint::green(self.passed()), Paint::red(failed), Paint::yellow(self.skipped()), self.duration, + self.total_time(), ) } } @@ -357,6 +368,8 @@ pub struct TestResult { /// The debug nodes of the call pub debug: Option, + pub duration: Duration, + /// pc breakpoint char map pub breakpoints: Breakpoints, } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 912fbb895d20d..356248a61c623 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -386,6 +386,7 @@ impl<'a> ContractRunner<'a> { traces, labeled_addresses, kind: TestKind::Standard(0), + duration: start.elapsed(), ..Default::default() } } @@ -397,6 +398,7 @@ impl<'a> ContractRunner<'a> { traces, labeled_addresses, kind: TestKind::Standard(0), + duration: start.elapsed(), ..Default::default() } } @@ -410,13 +412,8 @@ impl<'a> ContractRunner<'a> { ); // Record test execution time - debug!( - duration = ?start.elapsed(), - gas, - reverted, - should_fail, - success, - ); + let duration = start.elapsed(); + debug!(?duration, gas, reverted, should_fail, success); TestResult { status: match success { @@ -433,6 +430,7 @@ impl<'a> ContractRunner<'a> { labeled_addresses, debug: debug_arena, breakpoints, + duration, } } @@ -452,6 +450,7 @@ impl<'a> ContractRunner<'a> { let TestSetup { address, logs, traces, labeled_addresses, coverage, .. } = setup; // First, run the test normally to see if it needs to be skipped. + let start = Instant::now(); if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<_, _>( self.sender, address, @@ -468,6 +467,7 @@ impl<'a> ContractRunner<'a> { labeled_addresses, kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, coverage, + duration: start.elapsed(), ..Default::default() } }; @@ -495,6 +495,7 @@ impl<'a> ContractRunner<'a> { traces, labeled_addresses, kind: TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }, + duration: start.elapsed(), ..Default::default() } } @@ -542,12 +543,6 @@ impl<'a> ContractRunner<'a> { } } - let kind = TestKind::Invariant { - runs: cases.len(), - calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), - reverts, - }; - TestResult { status: match success { true => TestStatus::Success, @@ -557,10 +552,15 @@ impl<'a> ContractRunner<'a> { counterexample, decoded_logs: decode_console_logs(&logs), logs, - kind, + kind: TestKind::Invariant { + runs: cases.len(), + calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), + reverts, + }, coverage, traces, labeled_addresses: labeled_addresses.clone(), + duration: start.elapsed(), ..Default::default() // TODO collect debug traces on the last run or error } } @@ -612,6 +612,7 @@ impl<'a> ContractRunner<'a> { debug, breakpoints, coverage, + duration: start.elapsed(), ..Default::default() } } @@ -668,10 +669,8 @@ impl<'a> ContractRunner<'a> { coverage = merge_coverages(coverage, result.coverage); // Record test execution time - debug!( - duration = ?start.elapsed(), - success = %result.success - ); + let duration = start.elapsed(); + debug!(?duration, success = %result.success); TestResult { status: match result.success { @@ -688,6 +687,7 @@ impl<'a> ContractRunner<'a> { labeled_addresses, debug, breakpoints, + duration, } } } diff --git a/crates/forge/tests/fixtures/can_check_snapshot.stdout b/crates/forge/tests/fixtures/can_check_snapshot.stdout index 1846bd5778b67..bce1c6972521f 100644 --- a/crates/forge/tests/fixtures/can_check_snapshot.stdout +++ b/crates/forge/tests/fixtures/can_check_snapshot.stdout @@ -4,6 +4,6 @@ Compiler run successful! Ran 1 test for src/ATest.t.sol:ATest [PASS] testExample() (gas: 168) -Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.42ms +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.42ms Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout index 1701d90029b98..cd92d6ebeed8b 100644 --- a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout +++ b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout @@ -4,6 +4,6 @@ Compiler run successful! Ran 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest [PASS] testTrue() (gas: 168) -Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93ms +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93ms Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout index 3d782aa358727..dbab2812511da 100644 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ b/crates/forge/tests/fixtures/can_test_repeatedly.stdout @@ -3,6 +3,6 @@ No files changed, compilation skipped Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) [PASS] test_Increment() (gas: 28379) -Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms +Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms Ran 1 test suite: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout index 5a5b2f621811c..70c72887aaea4 100644 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout @@ -4,6 +4,6 @@ Compiler run successful! Ran 1 test for test/Contract.t.sol:ContractTest [PASS] test() (gas: 70360) -Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout index 19771e0920f58..786679a6736b6 100644 --- a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout +++ b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout @@ -14,7 +14,7 @@ Traces: ├─ emit MyEvent(a: 100) └─ ← () -Test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms +Suite result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms Ran 1 test suite: 1 tests passed, 1 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout index 1dfca09d72ff2..159c6476eb981 100644 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -14,6 +14,6 @@ Traces: │ └─ ← "USD Coin" └─ ← () -Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout index c46d083296faf..c98d9f93e42f4 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout @@ -4,6 +4,6 @@ Compiler run successful! Ran 1 test for src/Contract.t.sol:ContractTest [PASS] testExample() (gas: 190) -Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout index 28dbffcc86c34..abfd712db4c1e 100644 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout +++ b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout @@ -4,6 +4,6 @@ Compiler run successful! Ran 1 test for src/Contract.t.sol:ContractTest [PASS] testExample() (gas: 190) -Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index f5beda7785636..a269364893144 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1054,7 +1054,7 @@ static IGNORE_IN_FIXTURES: Lazy = Lazy::new(|| { // solc runs r"runs: \d+, μ: \d+, ~: \d+", // elapsed time - "(?:finished)? ?in .*?s", + r"(?:finished)? ?in .*?s(?: \(.*?s CPU time\))?", // file paths r"-->.*\.sol", r"Location(.|\n)*\.rs(.|\n)*Backtrace", From 561ea2d7fbb7c5bf3ef1e0b1dcf686521e6de208 Mon Sep 17 00:00:00 2001 From: reptarrat Date: Mon, 26 Feb 2024 07:00:08 -0500 Subject: [PATCH 0676/1963] feat(forge bind): add option to skip json derives (#7233) * chore: bump ethers deps * feat(forge bind): add option to skip json derives --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 54 ++++++++++++++++++------------------ Cargo.toml | 16 +++++------ crates/forge/bin/cmd/bind.rs | 22 +++++++++++---- 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55061bbe19f05..a9ccd381b3bc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1550,9 +1550,9 @@ dependencies = [ [[package]] name = "coins-ledger" -version = "0.9.3" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a3eedd46b3c8c0b9fbe6359078d375008c11824fadc4b7462491bb445e8904" +checksum = "9e076e6e5d9708f0b90afe2dbe5a8ba406b5c794347661e6e44618388c7e3a31" dependencies = [ "async-trait", "byteorder", @@ -2235,9 +2235,9 @@ checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" [[package]] name = "enr" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" +checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" dependencies = [ "base64 0.21.7", "bytes", @@ -2407,8 +2407,8 @@ dependencies = [ [[package]] name = "ethers" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2422,8 +2422,8 @@ dependencies = [ [[package]] name = "ethers-addressbook" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "ethers-core", "once_cell", @@ -2433,8 +2433,8 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2451,8 +2451,8 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "Inflector", "const-hex", @@ -2474,8 +2474,8 @@ dependencies = [ [[package]] name = "ethers-contract-derive" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "Inflector", "const-hex", @@ -2489,8 +2489,8 @@ dependencies = [ [[package]] name = "ethers-core" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "arrayvec", "bytes", @@ -2508,7 +2508,7 @@ dependencies = [ "rlp", "serde", "serde_json", - "strum 0.25.0", + "strum 0.26.1", "syn 2.0.50", "tempfile", "thiserror", @@ -2518,8 +2518,8 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "chrono", "ethers-core", @@ -2533,8 +2533,8 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "async-trait", "auto_impl", @@ -2558,8 +2558,8 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "async-trait", "auto_impl", @@ -2596,8 +2596,8 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "async-trait", "coins-bip32", @@ -2624,8 +2624,8 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.11" -source = "git+https://github.com/gakonst/ethers-rs?rev=f0e5b194f09c533feb10d1a686ddb9e5946ec107#f0e5b194f09c533feb10d1a686ddb9e5946ec107" +version = "2.0.13" +source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" dependencies = [ "cfg-if", "const-hex", diff --git a/Cargo.toml b/Cargo.toml index cddf4bae26a74..fa91bfd440f74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -222,14 +222,14 @@ tower-http = "0.4" #ethers-solc = { path = "../ethers-rs/ethers-solc" } [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" } +ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } +ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } +ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } +ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } +ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } +ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } +ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } +ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index c4fb92bd6e087..93d188260dc8a 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -77,6 +77,10 @@ pub struct BindArgs { #[clap(long)] skip_build: bool, + /// Don't add any additional derives to generated bindings + #[clap(long)] + skip_extra_derives: bool, + #[clap(flatten)] build_args: CoreBuildArgs, } @@ -161,10 +165,13 @@ impl BindArgs { }) .map(|path| { trace!(?path, "parsing Abigen from file"); - Abigen::from_file(&path) - .wrap_err_with(|| format!("failed to parse Abigen from file: {:?}", path))? - .add_derive("serde::Serialize")? - .add_derive("serde::Deserialize") + let abi = Abigen::from_file(&path) + .wrap_err_with(|| format!("failed to parse Abigen from file: {:?}", path)); + if !self.skip_extra_derives { + abi?.add_derive("serde::Serialize")?.add_derive("serde::Deserialize") + } else { + abi + } }) .collect::, _>>()?; let multi = MultiAbigen::from_abigens(abigens).with_filter(self.get_filter()); @@ -207,11 +214,14 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin /// Generate the bindings fn generate_bindings(&self, artifacts: impl AsRef) -> Result<()> { - let bindings = self.get_multi(&artifacts)?.build()?; + let mut bindings = self.get_multi(&artifacts)?.build()?; println!("Generating bindings for {} contracts", bindings.len()); if !self.module { trace!(single_file = self.single_file, "generating crate"); - bindings.dependencies([r#"serde = "1""#]).write_to_crate( + if !self.skip_extra_derives { + bindings = bindings.dependencies([r#"serde = "1""#]) + } + bindings.write_to_crate( &self.crate_name, &self.crate_version, self.bindings_root(&artifacts), From d58ab7f4e0f7f7a53e24f98c250fad2ce2ef1481 Mon Sep 17 00:00:00 2001 From: Carter Carlson Date: Mon, 26 Feb 2024 14:07:24 -0800 Subject: [PATCH 0677/1963] build(cast): fraxtal genesis blocks (#7241) * build(cast): fraxtal genesis blocks * docs(etherscan): chain id example * chore: fmt --- crates/cast/src/lib.rs | 4 ++++ crates/config/README.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 7d701cb5095c9..ca6eb83bec30b 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -436,6 +436,10 @@ where "0x02adc9b449ff5f2467b8c674ece7ff9b21319d76c4ad62a67a70d552655927e5" => { "optimism-kovan" } + "0x521982bd54239dc71269eefb58601762cc15cfb2978e0becb46af7962ed6bfaa" => "fraxtal", + "0x910f5c4084b63fd860d0c2f9a04615115a5a991254700b39ba072290dbd77489" => { + "fraxtal-testnet" + } "0x7ee576b35482195fc49205cec9af72ce14f003b9ae69f6ba0faef4514be8b442" => { "arbitrum-mainnet" } diff --git a/crates/config/README.md b/crates/config/README.md index 880149f6220d0..8e4bdf70ec0ad 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -252,7 +252,7 @@ The optional `url` attribute can be used to explicitly set the Etherscan API url [etherscan] mainnet = { key = "${ETHERSCAN_MAINNET_KEY}" } mainnet2 = { key = "ABCDEFG", chain = "mainnet" } -optimism = { key = "1234576" } +optimism = { key = "1234576", chain = 42 } unknownchain = { key = "ABCDEFG", url = "https://" } ``` From 7b2315c93cd5add61f161c2b10b697089b6fabce Mon Sep 17 00:00:00 2001 From: RPate97 Date: Mon, 26 Feb 2024 22:17:33 -0700 Subject: [PATCH 0678/1963] feat: Add call depth to `vm.stopAndReturnStateDiff()` results (#7234) * Added depth member to AccountAccess * Combine AccountAccess structs --------- Co-authored-by: ercembu --- crates/cheatcodes/assets/cheatcodes.json | 5 + crates/cheatcodes/spec/src/vm.rs | 2 + crates/cheatcodes/src/evm.rs | 1 - crates/cheatcodes/src/inspector.rs | 147 +++++++++----------- testdata/cheats/RecordAccountAccesses.t.sol | 89 ++++++++---- testdata/cheats/Vm.sol | 2 +- 6 files changed, 132 insertions(+), 114 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index c4f6cc8d738b7..8e300ad1a08cc 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -372,6 +372,11 @@ "name": "storageAccesses", "ty": "StorageAccess[]", "description": "An ordered list of storage accesses made during an account access operation." + }, + { + "name": "depth", + "ty": "uint64", + "description": "Call depth traversed during the recording of state differences" } ] }, diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 370c8b27a4cff..f9e0ca51d7052 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -203,6 +203,8 @@ interface Vm { bool reverted; /// An ordered list of storage accesses made during an account access operation. StorageAccess[] storageAccesses; + /// Call depth traversed during the recording of state differences + uint64 depth; } /// The storage accessed during an `AccountAccess`. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 27eb17733ae83..2fec645036cc3 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -543,7 +543,6 @@ fn get_state_diff(state: &mut Cheatcodes) -> Result { .unwrap_or_default() .into_iter() .flatten() - .map(|record| record.access) .collect::>(); Ok(res.abi_encode()) } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 878a037ab9765..889cc2446e727 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -13,6 +13,7 @@ use crate::{ ExpectedRevert, ExpectedRevertKind, }, CheatsConfig, CheatsCtxt, Error, Result, Vm, + Vm::AccountAccess, }; use alloy_primitives::{Address, Bytes, B256, U256, U64}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; @@ -83,14 +84,6 @@ pub struct BroadcastableTransaction { /// List of transactions that can be broadcasted. pub type BroadcastableTransactions = VecDeque; -#[derive(Clone, Debug)] -pub struct AccountAccess { - /// The account access. - pub access: crate::Vm::AccountAccess, - /// The call depth the account was accessed. - pub depth: u64, -} - /// An EVM inspector that handles calls to various cheatcodes, each with their own behavior. /// /// Cheatcodes can be called by contracts during execution to modify the VM environment, such as @@ -434,10 +427,11 @@ impl Inspector for Cheatcodes { reverted: false, deployedCode: vec![], storageAccesses: vec![], + depth: data.journaled_state.depth(), }; // Ensure that we're not selfdestructing a context recording was initiated on if let Some(last) = account_accesses.last_mut() { - last.push(AccountAccess { access, depth: data.journaled_state.depth() }); + last.push(access); } } } @@ -541,18 +535,14 @@ impl Inspector for Cheatcodes { reverted: false, deployedCode: vec![], storageAccesses: vec![], - }; - let access = AccountAccess { - access: account_access, - // use current depth; EXT* opcodes are not creating new contexts depth: data.journaled_state.depth(), }; // Record the EXT* call as an account access at the current depth // (future storage accesses will be recorded in a new "Resume" context) if let Some(last) = recorded_account_diffs_stack.last_mut() { - last.push(access); + last.push(account_access); } else { - recorded_account_diffs_stack.push(vec![access]); + recorded_account_diffs_stack.push(vec![account_access]); } } _ => (), @@ -883,23 +873,21 @@ impl Inspector for Cheatcodes { // updated with the revert status of this call, since the EVM does not mark accounts // as "warm" if the call from which they were accessed is reverted recorded_account_diffs_stack.push(vec![AccountAccess { - access: crate::Vm::AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), - }, - accessor: call.context.caller, - account: call.contract, - kind, - initialized, - oldBalance: old_balance, - newBalance: U256::ZERO, // updated on call_end - value: call.transfer.value, - data: call.input.to_vec(), - reverted: false, - deployedCode: vec![], - storageAccesses: vec![], // updated on step + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), }, + accessor: call.context.caller, + account: call.contract, + kind, + initialized, + oldBalance: old_balance, + newBalance: U256::ZERO, // updated on call_end + value: call.transfer.value, + data: call.input.to_vec(), + reverted: false, + deployedCode: vec![], + storageAccesses: vec![], // updated on step depth: data.journaled_state.depth(), }]); } @@ -1004,9 +992,8 @@ impl Inspector for Cheatcodes { // accordance with EVM behavior if status.is_revert() { last_recorded_depth.iter_mut().for_each(|element| { - element.access.reverted = true; + element.reverted = true; element - .access .storageAccesses .iter_mut() .for_each(|storage_access| storage_access.reverted = true); @@ -1019,8 +1006,8 @@ impl Inspector for Cheatcodes { if call_access.depth == data.journaled_state.depth() { if let Ok((acc, _)) = data.journaled_state.load_account(call.contract, data.db) { - debug_assert!(access_is_call(call_access.access.kind)); - call_access.access.newBalance = acc.info.balance; + debug_assert!(access_is_call(call_access.kind)); + call_access.newBalance = acc.info.balance; } } // Merge the last depth's AccountAccesses into the AccountAccesses at the current @@ -1267,23 +1254,21 @@ impl Inspector for Cheatcodes { // Record the create context as an account access and create a new vector to record all // subsequent account accesses recorded_account_diffs_stack.push(vec![AccountAccess { - access: crate::Vm::AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), - }, - accessor: call.caller, - account: address, - kind: crate::Vm::AccountAccessKind::Create, - initialized: true, - oldBalance: U256::ZERO, // updated on create_end - newBalance: U256::ZERO, // updated on create_end - value: call.value, - data: call.init_code.to_vec(), - reverted: false, - deployedCode: vec![], // updated on create_end - storageAccesses: vec![], // updated on create_end + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), }, + accessor: call.caller, + account: address, + kind: crate::Vm::AccountAccessKind::Create, + initialized: true, + oldBalance: U256::ZERO, // updated on create_end + newBalance: U256::ZERO, // updated on create_end + value: call.value, + data: call.init_code.to_vec(), + reverted: false, + deployedCode: vec![], // updated on create_end + storageAccesses: vec![], // updated on create_end depth, }]); } @@ -1357,9 +1342,8 @@ impl Inspector for Cheatcodes { // accordance with EVM behavior if status.is_revert() { last_depth.iter_mut().for_each(|element| { - element.access.reverted = true; + element.reverted = true; element - .access .storageAccesses .iter_mut() .for_each(|storage_access| storage_access.reverted = true); @@ -1372,15 +1356,15 @@ impl Inspector for Cheatcodes { // percolated up to a higher depth. if create_access.depth == data.journaled_state.depth() { debug_assert_eq!( - create_access.access.kind as u8, + create_access.kind as u8, crate::Vm::AccountAccessKind::Create as u8 ); if let Some(address) = address { if let Ok((created_acc, _)) = data.journaled_state.load_account(address, data.db) { - create_access.access.newBalance = created_acc.info.balance; - create_access.access.deployedCode = created_acc + create_access.newBalance = created_acc.info.balance; + create_access.deployedCode = created_acc .info .code .clone() @@ -1464,23 +1448,21 @@ fn apply_create2_deployer( if let Some(recorded_account_diffs_stack) = diffs_stack { let calldata = [&salt.to_be_bytes::<32>()[..], &call.init_code[..]].concat(); recorded_account_diffs_stack.push(vec![AccountAccess { - access: crate::Vm::AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), - }, - accessor: call.caller, - account: DEFAULT_CREATE2_DEPLOYER, - kind: crate::Vm::AccountAccessKind::Call, - initialized: true, - oldBalance: U256::ZERO, // updated on create_end - newBalance: U256::ZERO, // updated on create_end - value: call.value, - data: calldata, - reverted: false, - deployedCode: vec![], // updated on create_end - storageAccesses: vec![], // updated on create_end + chainInfo: crate::Vm::ChainInfo { + forkId: data.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(data.env.cfg.chain_id), }, + accessor: call.caller, + account: DEFAULT_CREATE2_DEPLOYER, + kind: crate::Vm::AccountAccessKind::Call, + initialized: true, + oldBalance: U256::ZERO, // updated on create_end + newBalance: U256::ZERO, // updated on create_end + value: call.value, + data: calldata, + reverted: false, + deployedCode: vec![], // updated on create_end + storageAccesses: vec![], // updated on create_end depth: data.journaled_state.depth(), }]) } @@ -1589,32 +1571,33 @@ fn append_storage_access( // 2. If there's an existing Resume record, then add the storage access to it. // 3. Otherwise, create a new Resume record based on the current context. if last.len() == 1 { - last.first_mut().unwrap().access.storageAccesses.push(storage_access); + last.first_mut().unwrap().storageAccesses.push(storage_access); } else { let last_record = last.last_mut().unwrap(); - if last_record.access.kind as u8 == crate::Vm::AccountAccessKind::Resume as u8 { - last_record.access.storageAccesses.push(storage_access); + if last_record.kind as u8 == crate::Vm::AccountAccessKind::Resume as u8 { + last_record.storageAccesses.push(storage_access); } else { let entry = last.first().unwrap(); let resume_record = crate::Vm::AccountAccess { chainInfo: crate::Vm::ChainInfo { - forkId: entry.access.chainInfo.forkId, - chainId: entry.access.chainInfo.chainId, + forkId: entry.chainInfo.forkId, + chainId: entry.chainInfo.chainId, }, - accessor: entry.access.accessor, - account: entry.access.account, + accessor: entry.accessor, + account: entry.account, kind: crate::Vm::AccountAccessKind::Resume, - initialized: entry.access.initialized, + initialized: entry.initialized, storageAccesses: vec![storage_access], - reverted: entry.access.reverted, + reverted: entry.reverted, // The remaining fields are defaults oldBalance: U256::ZERO, newBalance: U256::ZERO, value: U256::ZERO, data: vec![], deployedCode: vec![], + depth: entry.depth, }; - last.push(AccountAccess { access: resume_record, depth: entry.depth }); + last.push(resume_record); } } } diff --git a/testdata/cheats/RecordAccountAccesses.t.sol b/testdata/cheats/RecordAccountAccesses.t.sol index 15c1780b1a358..a86361a757eb3 100644 --- a/testdata/cheats/RecordAccountAccesses.t.sol +++ b/testdata/cheats/RecordAccountAccesses.t.sol @@ -348,7 +348,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 0 }) ); @@ -366,7 +367,8 @@ contract RecordAccountAccessesTest is DSTest { value: 1 ether, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 1 }) ); assertEq( @@ -383,7 +385,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: "hello world", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 2 }) ); assertEq( @@ -400,7 +403,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 3 }) ); assertEq( @@ -417,7 +421,8 @@ contract RecordAccountAccessesTest is DSTest { value: 2 ether, data: abi.encodePacked(type(SelfCaller).creationCode, abi.encode("hello2 world2")), reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 3 }) ); assertEq( @@ -434,7 +439,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.2 ether, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 3 }) ); } @@ -461,7 +467,8 @@ contract RecordAccountAccessesTest is DSTest { value: 1 ether, data: abi.encodeCall(this.revertingCall, (address(1234), "")), reverted: true, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 0 }) ); assertEq( @@ -478,7 +485,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.1 ether, data: "", reverted: true, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 1 }) ); } @@ -503,7 +511,7 @@ contract RecordAccountAccessesTest is DSTest { Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 7 + toUint(expectFirstCall), "incorrect length"); - uint256 startingIndex = toUint(expectFirstCall); + uint64 startingIndex = uint64(toUint(expectFirstCall)); if (expectFirstCall) { assertEq( called[0], @@ -519,7 +527,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex }) ); } @@ -551,7 +560,8 @@ contract RecordAccountAccessesTest is DSTest { value: 1 ether, data: abi.encodeCall(NestedRunner.run, (shouldRevert)), reverted: shouldRevert, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex }), false ); @@ -583,7 +593,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.1 ether, data: abi.encodeCall(Reverter.run, ()), reverted: true, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex + 1 }), false ); @@ -615,7 +626,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.01 ether, data: abi.encodeCall(Doer.run, ()), reverted: true, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex + 2 }), false ); @@ -647,7 +659,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.001 ether, data: abi.encodeCall(Doer.doStuff, ()), reverted: true, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex + 3 }), false ); @@ -679,7 +692,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.1 ether, data: abi.encodeCall(Succeeder.run, ()), reverted: shouldRevert, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex + 4 }), false ); @@ -711,7 +725,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.01 ether, data: abi.encodeCall(Doer.run, ()), reverted: shouldRevert, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex + 5 }), false ); @@ -743,7 +758,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0.001 ether, data: abi.encodeCall(Doer.doStuff, ()), reverted: shouldRevert, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: startingIndex + 6 }), false ); @@ -782,7 +798,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: abi.encodeCall(NestedStorer.run, ()), reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 0 }), false ); @@ -826,7 +843,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: abi.encodeCall(NestedStorer.run2, ()), reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 1 }), false ); @@ -858,7 +876,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 2 }), false ); @@ -903,7 +922,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(false)), reverted: false, - storageAccesses: storageAccesses + storageAccesses: storageAccesses, + depth: 0 }) ); @@ -925,7 +945,8 @@ contract RecordAccountAccessesTest is DSTest { (bytes32(0), abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(true))) ), reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 1 }) ); @@ -953,7 +974,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: creationCode, reverted: true, - storageAccesses: storageAccesses + storageAccesses: storageAccesses, + depth: 2 }) ); } @@ -998,7 +1020,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: creationCode, reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 1 }) ); assertEq( @@ -1015,7 +1038,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 2 }) ); } @@ -1044,7 +1068,8 @@ contract RecordAccountAccessesTest is DSTest { value: 1 ether, data: abi.encodePacked(type(SelfDestructor).creationCode, abi.encode(address(this))), reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 1 }) ); assertEq( @@ -1061,7 +1086,8 @@ contract RecordAccountAccessesTest is DSTest { value: 1 ether, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 2 }) ); assertEq( @@ -1078,7 +1104,8 @@ contract RecordAccountAccessesTest is DSTest { value: 1 ether, data: abi.encodePacked(type(SelfDestructor).creationCode, abi.encode(address(bytes20("doesn't exist yet")))), reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 3 }) ); assertEq( @@ -1095,7 +1122,8 @@ contract RecordAccountAccessesTest is DSTest { value: 1 ether, data: "", reverted: false, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 4 }) ); } @@ -1190,7 +1218,8 @@ contract RecordAccountAccessesTest is DSTest { value: 0, data: "", reverted: expected.reverted, - storageAccesses: new Vm.StorageAccess[](0) + storageAccesses: new Vm.StorageAccess[](0), + depth: 0 }), false ); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 4bc85d457ce0c..f28c719231fd0 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -16,7 +16,7 @@ interface Vm { 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; } + 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; } function _expectCheatcodeRevert() external; function _expectCheatcodeRevert(bytes4 revertData) external; From 85b4872377bf85c3180e49956a82fded49daff10 Mon Sep 17 00:00:00 2001 From: malik Date: Tue, 27 Feb 2024 15:50:26 +0100 Subject: [PATCH 0679/1963] test: add more positive fuzz test cases (#7101) * changes * changes * proposed fix * format * fixed * Update crates/forge/tests/it/fuzz.rs Co-authored-by: Oliver Nordbjerg --------- Co-authored-by: Oliver Nordbjerg --- crates/forge/tests/it/fuzz.rs | 35 +++++++++++++++++++++++++++++++- testdata/fuzz/FuzzPositive.t.sol | 18 ++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 testdata/fuzz/FuzzPositive.t.sol diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 66f2b4d38287b..2eefa530d6230 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -13,7 +13,7 @@ async fn test_fuzz() { let suite_result = runner .test_collect( &Filter::new(".*", ".*", ".*fuzz/") - .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)") + .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)|testSuccessChecker\(uint256\)|testSuccessChecker2\(int256\)|testSuccessChecker3\(uint32\)") .exclude_paths("invariant"), test_opts(), ) @@ -46,6 +46,39 @@ async fn test_fuzz() { } } +#[tokio::test(flavor = "multi_thread")] +async fn test_successful_fuzz_cases() { + let mut runner = runner().await; + + let suite_result = runner + .test_collect( + &Filter::new(".*", ".*", ".*fuzz/FuzzPositive") + .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)") + .exclude_paths("invariant"), + test_opts(), + ) + .await; + + assert!(!suite_result.is_empty()); + + for (_, SuiteResult { test_results, .. }) in suite_result { + for (test_name, result) in test_results { + match test_name.as_str() { + "testSuccessChecker(uint256)" | + "testSuccessChecker2(int256)" | + "testSuccessChecker3(uint32)" => assert!( + result.status == TestStatus::Success, + "Test {} did not pass as expected.\nReason: {:?}\nLogs:\n{}", + test_name, + result.reason, + result.decoded_logs.join("\n") + ), + _ => {} + } + } + } +} + /// Test that showcases PUSH collection on normal fuzzing. Ignored until we collect them in a /// smarter way. #[tokio::test(flavor = "multi_thread")] diff --git a/testdata/fuzz/FuzzPositive.t.sol b/testdata/fuzz/FuzzPositive.t.sol new file mode 100644 index 0000000000000..952a3b6992278 --- /dev/null +++ b/testdata/fuzz/FuzzPositive.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +contract FuzzPositive is DSTest { + function testSuccessChecker(uint256 val) public { + assertTrue(true); + } + + function testSuccessChecker2(int256 val) public { + assert(val == val); + } + + function testSuccessChecker3(uint32 val) public { + assert(val + 0 == val); + } +} From 7969c70e3dc96afa3d5a45d76cbb2d8f9eb38d61 Mon Sep 17 00:00:00 2001 From: galois Date: Wed, 28 Feb 2024 12:15:33 +0800 Subject: [PATCH 0680/1963] fix(cast): fix to address reveal problem (#7254) --- crates/common/src/fmt/ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 4c21328cea886..5549f36abc5fb 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -180,7 +180,7 @@ type {}", ); if let Some(to) = to { - pretty.push_str(&format!("\nto {}", to)); + pretty.push_str(&format!("\nto {}", to.pretty())); } // additional captured fields From 551bcb5c84d672670e1e3fd897089e606d808774 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 28 Feb 2024 11:15:05 +0400 Subject: [PATCH 0681/1963] feat(forge): isolated execution (#7186) * [wip] feat(forge): isolated execution * small fixes * don't panic on transaction error + fixture fix * stricter call scheme check * refactor and more fixes * wip * fix * wip * wip * rm cheatcodes check * clippy * update commit logic * opt-in * enable in gas reports * --isolate * isolation tests * smaller diff * fmt * simplify logic * docs * fmt * enable isolation properly for --gas-report * change nonce incrementing * document why we touch --- crates/cheatcodes/src/inspector.rs | 6 +- crates/common/src/evm.rs | 11 + crates/config/src/lib.rs | 6 + crates/evm/core/src/backend/fuzz.rs | 10 +- crates/evm/core/src/opts.rs | 3 + crates/evm/evm/src/inspectors/stack.rs | 337 +++++++++++++++++++++--- crates/forge/bin/cmd/script/executor.rs | 17 +- crates/forge/bin/cmd/test/mod.rs | 6 + crates/forge/src/gas_report.rs | 11 + crates/forge/src/multi_runner.rs | 11 + crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/test_cmd.rs | 83 ++++++ testdata/repros/Issue3653.t.sol | 4 +- 13 files changed, 460 insertions(+), 46 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 889cc2446e727..f6627114f5c9a 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -839,6 +839,9 @@ impl Inspector for Cheatcodes { debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable call"); let prev = account.info.nonce; + + // Touch account to ensure that incremented nonce is committed + account.mark_touch(); account.info.nonce += 1; debug!(target: "cheatcodes", address=%broadcast.new_origin, nonce=prev+1, prev, "incremented nonce"); } else if broadcast.single_call { @@ -1509,9 +1512,10 @@ fn process_broadcast_create( // by the create2_deployer let account = data.journaled_state.state().get_mut(&broadcast_sender).unwrap(); let prev = account.info.nonce; + // Touch account to ensure that incremented nonce is committed + account.mark_touch(); account.info.nonce += 1; debug!(target: "cheatcodes", address=%broadcast_sender, nonce=prev+1, prev, "incremented nonce in create2"); - // Proxy deployer requires the data to be `salt ++ init_code` let calldata = [&salt.to_be_bytes::<32>()[..], &bytecode[..]].concat(); (calldata.into(), Some(DEFAULT_CREATE2_DEPLOYER), prev) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index a924fe5251a1d..2230bd7608743 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -144,6 +144,13 @@ pub struct EvmArgs { #[clap(flatten)] #[serde(flatten)] pub env: EnvArgs, + + /// Whether to enable isolation of calls. + /// In isolation mode all top-level calls are executed as a separate transaction in a separate + /// EVM context, enabling more precise gas accounting and transaction state changes. + #[clap(long)] + #[serde(skip)] + pub isolate: bool, } // Make this set of options a `figment::Provider` so that it can be merged into the `Config` @@ -166,6 +173,10 @@ impl Provider for EvmArgs { dict.insert("ffi".to_string(), self.ffi.into()); } + if self.isolate { + dict.insert("isolate".to_string(), self.isolate.into()); + } + if self.always_use_create_2_factory { dict.insert( "always_use_create_2_factory".to_string(), diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f582322a9ae94..32c713230492e 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -374,6 +374,11 @@ pub struct Config { /// Should be removed once EvmVersion Cancun is supported by solc pub cancun: bool, + /// Whether to enable call isolation. + /// + /// Useful for more correct gas accounting and EVM behavior in general. + pub isolate: bool, + /// Address labels pub labels: HashMap, @@ -1820,6 +1825,7 @@ impl Default for Config { profile: Self::DEFAULT_PROFILE, fs_permissions: FsPermissions::new([PathPermission::read("out")]), cancun: false, + isolate: false, __root: Default::default(), src: "src".into(), test: "test".into(), diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index f4d362ec8d848..11857fa4ab641 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -11,8 +11,8 @@ use alloy_genesis::GenesisAccount; use alloy_primitives::{Address, B256, U256}; use revm::{ db::DatabaseRef, - primitives::{AccountInfo, Bytecode, Env, ResultAndState}, - Database, Inspector, JournaledState, + primitives::{Account, AccountInfo, Bytecode, Env, HashMap as Map, ResultAndState}, + Database, DatabaseCommit, Inspector, JournaledState, }; use std::{borrow::Cow, collections::HashMap}; @@ -279,3 +279,9 @@ impl<'a> Database for FuzzBackendWrapper<'a> { DatabaseRef::block_hash_ref(self, number) } } + +impl<'a> DatabaseCommit for FuzzBackendWrapper<'a> { + fn commit(&mut self, changes: Map) { + self.backend.to_mut().commit(changes) + } +} diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 49aaa0a2e2840..510f14254ad7c 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -61,6 +61,9 @@ pub struct EvmOpts { /// The memory limit per EVM execution in bytes. /// If this limit is exceeded, a `MemoryLimitOOG` result is thrown. pub memory_limit: u64, + + /// Whether to enable isolation of calls. + pub isolate: bool, } impl EvmOpts { diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index a1fc13d706190..2a66ac76280da 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -3,15 +3,21 @@ use super::{ StackSnapshotType, TracePrinter, TracingInspector, TracingInspectorConfig, }; use alloy_primitives::{Address, Bytes, Log, B256, U256}; -use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; +use foundry_evm_core::{ + backend::DatabaseExt, + debug::DebugArena, + utils::{eval_to_instruction_result, halt_to_instruction_result}, +}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ + evm_inner, interpreter::{ - return_revert, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, Stack, + return_revert, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, Interpreter, + Stack, }, - primitives::{BlockEnv, Env}, - EVMData, Inspector, + primitives::{BlockEnv, Env, ExecutionResult, Output, State, TransactTo}, + DatabaseCommit, EVMData, Inspector, }; use std::{collections::HashMap, sync::Arc}; @@ -44,6 +50,10 @@ pub struct InspectorStackBuilder { pub print: Option, /// The chisel state inspector. pub chisel_state: Option, + /// Whether to enable call isolation. + /// In isolation mode all top-level calls are executed as a separate transaction in a separate + /// EVM context, enabling more precise gas accounting and transaction state changes. + pub enable_isolation: bool, } impl InspectorStackBuilder { @@ -123,6 +133,14 @@ impl InspectorStackBuilder { self } + /// Set whether to enable the call isolation. + /// For description of call isolation, see [`InspectorStack::enable_isolation`]. + #[inline] + pub fn enable_isolation(mut self, yes: bool) -> Self { + self.enable_isolation = yes; + self + } + /// Builds the stack of inspectors to use when transacting/committing on the EVM. /// /// See also [`revm::Evm::inspect_ref`] and [`revm::Evm::commit_ref`]. @@ -138,6 +156,7 @@ impl InspectorStackBuilder { coverage, print, chisel_state, + enable_isolation, } = self; let mut stack = InspectorStack::new(); @@ -157,6 +176,8 @@ impl InspectorStackBuilder { stack.print(print.unwrap_or(false)); stack.tracing(trace.unwrap_or(false)); + stack.enable_isolation(enable_isolation); + // environment, must come after all of the inspectors if let Some(block) = block { stack.set_block(&block); @@ -180,6 +201,38 @@ macro_rules! call_inspectors { )+}} } +/// Same as [call_inspectors] macro, but with depth adjustment for isolated execution. +macro_rules! call_inspectors_adjust_depth { + ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { + if $self.in_inner_context { + $data.journaled_state.depth += 1; + } + {$( + if let Some($id) = $inspector { + if let Some(result) = $call { + if $self.in_inner_context { + $data.journaled_state.depth -= 1; + } + return result; + } + } + )+} + if $self.in_inner_context { + $data.journaled_state.depth -= 1; + } + } +} + +/// Helper method which updates data in the state with the data from the database. +fn update_state(state: &mut State, db: &mut DB) { + for (addr, acc) in state.iter_mut() { + acc.info = db.basic(*addr).unwrap().unwrap_or_default(); + for (key, val) in acc.storage.iter_mut() { + val.present_value = db.storage(*addr, *key).unwrap(); + } + } +} + /// The collected results of [`InspectorStack`]. pub struct InspectorData { pub logs: Vec, @@ -191,6 +244,24 @@ pub struct InspectorData { pub chisel_state: Option<(Stack, Vec, InstructionResult)>, } +/// Contains data about the state of outer/main EVM which created and invoked the inner EVM context. +/// Used to adjust EVM state while in inner context. +/// +/// We need this to avoid breaking changes due to EVM behavior differences in isolated vs +/// non-isolated mode. For descriptions and workarounds for those changes see: https://github.com/foundry-rs/foundry/pull/7186#issuecomment-1959102195 +#[derive(Debug, Clone)] +pub struct InnerContextData { + /// The sender of the inner EVM context. + /// It is also an origin of the transaction that created the inner EVM context. + sender: Address, + /// Nonce of the sender before invocation of the inner EVM context. + original_sender_nonce: u64, + /// Origin of the transaction in the outer EVM context. + original_origin: Address, + /// Whether the inner context was created by a CREATE transaction. + is_create: bool, +} + /// An inspector that calls multiple inspectors in sequence. /// /// If a call to an inspector returns a value other than [InstructionResult::Continue] (or @@ -205,6 +276,11 @@ pub struct InspectorStack { pub log_collector: Option, pub printer: Option, pub tracer: Option, + pub enable_isolation: bool, + + /// Flag marking if we are in the inner EVM context. + pub in_inner_context: bool, + pub inner_context_data: Option, } impl InspectorStack { @@ -271,6 +347,12 @@ impl InspectorStack { self.debugger = yes.then(Default::default); } + /// Set whether to enable call isolation. + #[inline] + pub fn enable_isolation(&mut self, yes: bool) { + self.enable_isolation = yes; + } + /// Set whether to enable the log collector. #[inline] pub fn collect_logs(&mut self, yes: bool) { @@ -327,7 +409,7 @@ impl InspectorStack { status: InstructionResult, retdata: Bytes, ) -> (InstructionResult, Gas, Bytes) { - call_inspectors!( + call_inspectors_adjust_depth!( [ &mut self.fuzzer, &mut self.debugger, @@ -346,19 +428,136 @@ impl InspectorStack { if new_status != status || (new_status == InstructionResult::Revert && new_retdata != retdata) { - return (new_status, new_gas, new_retdata); + Some((new_status, new_gas, new_retdata)) + } else { + None } - } + }, + self, + data ); - (status, remaining_gas, retdata) } + + fn transact_inner( + &mut self, + data: &mut EVMData<'_, DB>, + transact_to: TransactTo, + caller: Address, + input: Bytes, + gas_limit: u64, + value: U256, + ) -> (InstructionResult, Option
, Gas, Bytes) { + data.db.commit(data.journaled_state.state.clone()); + + let nonce = data + .journaled_state + .load_account(caller, data.db) + .expect("failed to load caller") + .0 + .info + .nonce; + + let cached_env = data.env.clone(); + + data.env.block.basefee = U256::ZERO; + data.env.tx.caller = caller; + data.env.tx.transact_to = transact_to.clone(); + data.env.tx.data = input; + data.env.tx.value = value; + data.env.tx.nonce = Some(nonce); + // Add 21000 to the gas limit to account for the base cost of transaction. + // We might have modified block gas limit earlier and revm will reject tx with gas limit > + // block gas limit, so we adjust. + data.env.tx.gas_limit = std::cmp::min(gas_limit + 21000, data.env.block.gas_limit.to()); + data.env.tx.gas_price = U256::ZERO; + + self.inner_context_data = Some(InnerContextData { + sender: data.env.tx.caller, + original_origin: cached_env.tx.caller, + original_sender_nonce: nonce, + is_create: matches!(transact_to, TransactTo::Create(_)), + }); + self.in_inner_context = true; + let res = evm_inner(data.env, data.db, Some(self)).transact(); + self.in_inner_context = false; + self.inner_context_data = None; + + data.env.tx = cached_env.tx; + data.env.block.basefee = cached_env.block.basefee; + + let mut gas = Gas::new(gas_limit); + + let Ok(mut res) = res else { + // Should we match, encode and propagate error as a revert reason? + return (InstructionResult::Revert, None, gas, Bytes::new()); + }; + + // Commit changes after transaction + data.db.commit(res.state.clone()); + + // Update both states with new DB data after commit. + update_state(&mut data.journaled_state.state, data.db); + update_state(&mut res.state, data.db); + + // Merge transaction journal into the active journal. + for (addr, acc) in res.state { + if let Some(acc_mut) = data.journaled_state.state.get_mut(&addr) { + acc_mut.status |= acc.status; + for (key, val) in acc.storage { + if !acc_mut.storage.contains_key(&key) { + acc_mut.storage.insert(key, val); + } + } + } else { + data.journaled_state.state.insert(addr, acc); + } + } + + match res.result { + ExecutionResult::Success { reason, gas_used, gas_refunded, logs: _, output } => { + gas.set_refund(gas_refunded as i64); + gas.record_cost(gas_used); + let address = match output { + Output::Create(_, address) => address, + Output::Call(_) => None, + }; + (eval_to_instruction_result(reason), address, gas, output.into_data()) + } + ExecutionResult::Halt { reason, gas_used } => { + gas.record_cost(gas_used); + (halt_to_instruction_result(reason), None, gas, Bytes::new()) + } + ExecutionResult::Revert { gas_used, output } => { + gas.record_cost(gas_used); + (InstructionResult::Revert, None, gas, output) + } + } + } + + /// Adjusts the EVM data for the inner EVM context. + /// Should be called on the top-level call of inner context (depth == 0 && + /// self.in_inner_context) Decreases sender nonce for CALLs to keep backwards compatibility + /// Updates tx.origin to the value before entering inner context + fn adjust_evm_data_for_inner_context(&mut self, data: &mut EVMData<'_, DB>) { + let inner_context_data = + self.inner_context_data.as_ref().expect("should be called in inner context"); + let sender_acc = data + .journaled_state + .state + .get_mut(&inner_context_data.sender) + .expect("failed to load sender"); + if !inner_context_data.is_create { + sender_acc.info.nonce = inner_context_data.original_sender_nonce; + } + data.env.tx.caller = inner_context_data.original_origin; + } } -impl Inspector for InspectorStack { +impl Inspector for InspectorStack { fn initialize_interp(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { let res = interpreter.instruction_result; - call_inspectors!( + call_inspectors_adjust_depth!( [ &mut self.debugger, &mut self.coverage, @@ -372,16 +571,19 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if interpreter.instruction_result != res { - #[allow(clippy::needless_return)] - return; + Some(()) + } else { + None } - } + }, + self, + data ); } fn step(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { let res = interpreter.instruction_result; - call_inspectors!( + call_inspectors_adjust_depth!( [ &mut self.fuzzer, &mut self.debugger, @@ -396,10 +598,13 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if interpreter.instruction_result != res { - #[allow(clippy::needless_return)] - return; + Some(()) + } else { + None } - } + }, + self, + data ); } @@ -410,17 +615,20 @@ impl Inspector for InspectorStack { topics: &[B256], data: &Bytes, ) { - call_inspectors!( + call_inspectors_adjust_depth!( [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], |inspector| { inspector.log(evm_data, address, topics, data); - } + None + }, + self, + evm_data ); } fn step_end(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { let res = interpreter.instruction_result; - call_inspectors!( + call_inspectors_adjust_depth!( [ &mut self.debugger, &mut self.tracer, @@ -434,10 +642,13 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if interpreter.instruction_result != res { - #[allow(clippy::needless_return)] - return; + Some(()) + } else { + None } - } + }, + self, + data ); } @@ -446,7 +657,12 @@ impl Inspector for InspectorStack { data: &mut EVMData<'_, DB>, call: &mut CallInputs, ) -> (InstructionResult, Gas, Bytes) { - call_inspectors!( + if self.in_inner_context && data.journaled_state.depth == 0 { + self.adjust_evm_data_for_inner_context(data); + return (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()); + } + + call_inspectors_adjust_depth!( [ &mut self.fuzzer, &mut self.debugger, @@ -460,13 +676,32 @@ impl Inspector for InspectorStack { let (status, gas, retdata) = inspector.call(data, call); // Allow inspectors to exit early - #[allow(clippy::needless_return)] if status != InstructionResult::Continue { - return (status, gas, retdata); + Some((status, gas, retdata)) + } else { + None } - } + }, + self, + data ); + if self.enable_isolation && + call.context.scheme == CallScheme::Call && + !self.in_inner_context && + data.journaled_state.depth == 1 + { + let (res, _, gas, output) = self.transact_inner( + data, + TransactTo::Call(call.contract), + call.context.caller, + call.input.clone(), + call.gas_limit, + call.transfer.value, + ); + return (res, gas, output); + } + (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) } @@ -478,8 +713,13 @@ impl Inspector for InspectorStack { status: InstructionResult, retdata: Bytes, ) -> (InstructionResult, Gas, Bytes) { - let res = self.do_call_end(data, call, remaining_gas, status, retdata); + // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. + // Avoid processing twice. + if self.in_inner_context && data.journaled_state.depth == 0 { + return (status, remaining_gas, retdata); + } + let res = self.do_call_end(data, call, remaining_gas, status, retdata); if matches!(res.0, return_revert!()) { // Encountered a revert, since cheatcodes may have altered the evm state in such a way // that violates some constraints, e.g. `deal`, we need to manually roll back on revert @@ -497,7 +737,12 @@ impl Inspector for InspectorStack { data: &mut EVMData<'_, DB>, call: &mut CreateInputs, ) -> (InstructionResult, Option
, Gas, Bytes) { - call_inspectors!( + if self.in_inner_context && data.journaled_state.depth == 0 { + self.adjust_evm_data_for_inner_context(data); + return (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()); + } + + call_inspectors_adjust_depth!( [ &mut self.debugger, &mut self.tracer, @@ -511,11 +756,26 @@ impl Inspector for InspectorStack { // Allow inspectors to exit early if status != InstructionResult::Continue { - return (status, addr, gas, retdata); + Some((status, addr, gas, retdata)) + } else { + None } - } + }, + self, + data ); + if self.enable_isolation && !self.in_inner_context && data.journaled_state.depth == 1 { + return self.transact_inner( + data, + TransactTo::Create(call.scheme), + call.caller, + call.init_code.clone(), + call.gas_limit, + call.value, + ); + } + (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()) } @@ -528,7 +788,12 @@ impl Inspector for InspectorStack { remaining_gas: Gas, retdata: Bytes, ) -> (InstructionResult, Option
, Gas, Bytes) { - call_inspectors!( + // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. + // Avoid processing twice. + if self.in_inner_context && data.journaled_state.depth == 0 { + return (status, address, remaining_gas, retdata); + } + call_inspectors_adjust_depth!( [ &mut self.debugger, &mut self.tracer, @@ -548,9 +813,13 @@ impl Inspector for InspectorStack { ); if new_status != status { - return (new_status, new_address, new_gas, new_retdata); + Some((new_status, new_address, new_gas, new_retdata)) + } else { + None } - } + }, + self, + data ); (status, address, remaining_gas, retdata) diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index e0f8ed8ece1bc..071cbcbb219d6 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -303,14 +303,17 @@ impl ScriptArgs { if let SimulationStage::Local = stage { builder = builder.inspectors(|stack| { - stack.debug(self.debug).cheatcodes( - CheatsConfig::new( - &script_config.config, - script_config.evm_opts.clone(), - script_wallets, + stack + .debug(self.debug) + .cheatcodes( + CheatsConfig::new( + &script_config.config, + script_config.evm_opts.clone(), + script_wallets, + ) + .into(), ) - .into(), - ) + .enable_isolation(script_config.evm_opts.isolate) }); } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index ba928f6ea3134..b9ca859b8e5a5 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -142,6 +142,11 @@ impl TestArgs { // Merge all configs let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; + // Explicitly enable isolation for gas reports for more correct gas accounting + if self.gas_report { + evm_opts.isolate = true; + } + // Set up the project. let mut project = config.project()?; @@ -196,6 +201,7 @@ impl TestArgs { .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone(), None)) .with_test_options(test_options.clone()) + .enable_isolation(evm_opts.isolate) .build(project_root, output, env, evm_opts)?; if let Some(debug_test_pattern) = &self.debug { diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index afe41f76dfa51..f6c269d7029ef 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -7,6 +7,7 @@ use crate::{ }; use comfy_table::{presets::ASCII_MARKDOWN, *}; use foundry_common::{calc, TestFunctionExt}; +use foundry_evm::traces::CallKind; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; @@ -75,6 +76,16 @@ impl GasReport { return; } + // Only include top-level calls which accout for calldata and base (21.000) cost. + // Only include Calls and Creates as only these calls are isolated in inspector. + if trace.depth != 1 && + (trace.kind == CallKind::Call || + trace.kind == CallKind::Create || + trace.kind == CallKind::Create2) + { + return; + } + let decoded = decoder.decode_function(&node.trace).await; let Some(name) = &decoded.contract else { return }; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 0651e82d61848..699df0da0566f 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -60,6 +60,8 @@ pub struct MultiContractRunner { pub debug: bool, /// Settings related to fuzz and/or invariant tests pub test_options: TestOptions, + /// Whether to enable call isolation + pub isolation: bool, } impl MultiContractRunner { @@ -179,6 +181,7 @@ impl MultiContractRunner { .trace(self.evm_opts.verbosity >= 3 || self.debug) .debug(self.debug) .coverage(self.coverage) + .enable_isolation(self.isolation) }) .spec(self.evm_spec) .gas_limit(self.evm_opts.gas_limit()) @@ -256,6 +259,8 @@ pub struct MultiContractRunnerBuilder { pub coverage: bool, /// Whether or not to collect debug info pub debug: bool, + /// Whether to enable call isolation + pub isolation: bool, /// Settings related to fuzz and/or invariant tests pub test_options: Option, } @@ -301,6 +306,11 @@ impl MultiContractRunnerBuilder { self } + pub fn enable_isolation(mut self, enable: bool) -> Self { + self.isolation = enable; + self + } + /// Given an EVM, proceeds to return a runner which is able to execute all tests /// against that evm pub fn build( @@ -381,6 +391,7 @@ impl MultiContractRunnerBuilder { coverage: self.coverage, debug: self.debug, test_options: self.test_options.unwrap_or_default(), + isolation: self.isolation, }) } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f6fe89efb2a05..d8f9db3106d9c 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -121,6 +121,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { fs_permissions: Default::default(), labels: Default::default(), cancun: true, + isolate: true, __non_exhaustive: (), __warnings: vec![], }; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 58b9b1eb85de3..61cbab489e777 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -407,3 +407,86 @@ contract CustomTypesTest is Test { .join("tests/fixtures/include_custom_types_in_traces.stdout"), ); }); + +forgetest_init!(can_test_selfdestruct_with_isolation, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "Contract.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract Destructing { + function destruct() public { + selfdestruct(payable(address(0))); + } +} + +contract SelfDestructTest is Test { + function test() public { + Destructing d = new Destructing(); + vm.store(address(d), bytes32(0), bytes32(uint256(1))); + d.destruct(); + assertEq(address(d).code.length, 0); + assertEq(vm.load(address(d), bytes32(0)), bytes32(0)); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "-vvvv", "--isolate"]).assert_success(); +}); + +forgetest_init!(can_test_transient_storage_with_isolation, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "Contract.t.sol", + r#"pragma solidity 0.8.24; +import {Test} from "forge-std/Test.sol"; + +contract TransientTester { + function locked() public view returns (bool isLocked) { + assembly { + isLocked := tload(0) + } + } + + modifier lock() { + require(!locked(), "locked"); + assembly { + tstore(0, 1) + } + _; + } + + function maybeReentrant(address target, bytes memory data) public lock { + (bool success, bytes memory ret) = target.call(data); + if (!success) { + // forwards revert reason + assembly { + let ret_size := mload(ret) + revert(add(32, ret), ret_size) + } + } + } +} + +contract TransientTest is Test { + function test() public { + TransientTester t = new TransientTester(); + vm.expectRevert(bytes("locked")); + t.maybeReentrant(address(t), abi.encodeCall(TransientTester.maybeReentrant, (address(0), new bytes(0)))); + + t.maybeReentrant(address(0), new bytes(0)); + assertEq(t.locked(), false); + } +} + + "#, + ) + .unwrap(); + + cmd.args(["test", "-vvvv", "--isolate", "--evm-version", "cancun"]).assert_success(); +}); diff --git a/testdata/repros/Issue3653.t.sol b/testdata/repros/Issue3653.t.sol index 6e52c49f8aa5c..5022af67859f0 100644 --- a/testdata/repros/Issue3653.t.sol +++ b/testdata/repros/Issue3653.t.sol @@ -11,13 +11,13 @@ contract Issue3653Test is DSTest { Token token; constructor() { - fork = vm.createSelectFork("rpcAlias", 10); + fork = vm.createSelectFork("rpcAlias", 1000000); token = new Token(); vm.makePersistent(address(token)); } function testDummy() public { - assertEq(block.number, 10); + assertEq(block.number, 1000000); } } From b279e5529e269aa5158756bef96520740000afbd Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:25:47 +0200 Subject: [PATCH 0682/1963] invariant (bug): inconsistent shrinked call sequence sometimes (#7256) * When shrinking, recreate call sequence by respecting the order from shrunked call indices * Cover in tests --- .../evm/evm/src/executors/invariant/error.rs | 20 +++++++++++-------- crates/forge/tests/it/invariant.rs | 15 ++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index c8990efb7f7bf..0d619740e698b 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -253,14 +253,18 @@ impl InvariantFuzzError { let shrunk_call_indices = self.try_shrinking_recurse(calls, executor, 0, 0); - // Filter the calls by if the call index is present in `shrunk_call_indices` - calls - .iter() - .enumerate() - .filter_map( - |(i, call)| if shrunk_call_indices.contains(&i) { Some(call) } else { None }, - ) - .collect() + // we recreate the call sequence in the same order as they reproduce the failure + // otherwise we could end up with inverted sequence + // e.g. in a sequence of: + // 1. Alice calls acceptOwnership and reverts + // 2. Bob calls transferOwnership to Alice + // 3. Alice calls acceptOwnership and test fails + // we shrink to indices of [2, 1] and we recreate call sequence in same order + let mut new_calls_sequence = Vec::with_capacity(shrunk_call_indices.len()); + shrunk_call_indices.iter().for_each(|call_index| { + new_calls_sequence.push(calls.get(*call_index).unwrap()); + }); + new_calls_sequence } /// We try to construct a [powerset](https://en.wikipedia.org/wiki/Power_set) of the sequence if diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 333392b29106d..efc4364fcd890 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -241,6 +241,21 @@ async fn test_invariant_shrink() { // `fuzz_seed` at 119 makes this sequence shrinkable from 4 to 2. CounterExample::Sequence(sequence) => { assert_eq!(sequence.len(), 2); + + // call order should always be preserved + let create_fren_sequence = sequence[0].clone(); + assert_eq!( + create_fren_sequence.contract_name.unwrap(), + "fuzz/invariant/common/InvariantInnerContract.t.sol:Jesus" + ); + assert_eq!(create_fren_sequence.signature.unwrap(), "create_fren()"); + + let betray_sequence = sequence[1].clone(); + assert_eq!( + betray_sequence.contract_name.unwrap(), + "fuzz/invariant/common/InvariantInnerContract.t.sol:Judas" + ); + assert_eq!(betray_sequence.signature.unwrap(), "betray()"); } }; } From 19a294b0cc6ff052692d4ef5b27f5bcf720822fa Mon Sep 17 00:00:00 2001 From: Vid Kersic <38610409+Vid201@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:21:14 +0100 Subject: [PATCH 0683/1963] fix(foundryup): use fish_add_path in fish shell (#7258) --- foundryup/install | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/foundryup/install b/foundryup/install index 19bfe573873df..da8156a09fe3f 100755 --- a/foundryup/install +++ b/foundryup/install @@ -45,7 +45,12 @@ esac # Only add foundryup if it isn't already in PATH. if [[ ":$PATH:" != *":${FOUNDRY_BIN_DIR}:"* ]]; then # Add the foundryup directory to the path and ensure the old PATH variables remain. - echo >> "$PROFILE" && echo "export PATH=\"\$PATH:$FOUNDRY_BIN_DIR\"" >> "$PROFILE" + # If the shell is fish, echo fish_add_path instead of export. + if [[ "$PREF_SHELL" == "fish" ]]; then + echo >> "$PROFILE" && echo "fish_add_path -a $FOUNDRY_BIN_DIR" >> "$PROFILE" + else + echo >> "$PROFILE" && echo "export PATH=\"\$PATH:$FOUNDRY_BIN_DIR\"" >> "$PROFILE" + fi fi # Warn MacOS users that they may need to manually install libusb via Homebrew: From 5d572e3f501f8844a3c45dc880debfb315534fe1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:15:09 +0200 Subject: [PATCH 0684/1963] chore: use collect in invariant code (#7259) --- .../evm/evm/src/executors/invariant/error.rs | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 0d619740e698b..917e7732fb49e 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -253,18 +253,14 @@ impl InvariantFuzzError { let shrunk_call_indices = self.try_shrinking_recurse(calls, executor, 0, 0); - // we recreate the call sequence in the same order as they reproduce the failure - // otherwise we could end up with inverted sequence - // e.g. in a sequence of: + // We recreate the call sequence in the same order as they reproduce the failure, + // otherwise we could end up with inverted sequence. + // E.g. in a sequence of: // 1. Alice calls acceptOwnership and reverts // 2. Bob calls transferOwnership to Alice // 3. Alice calls acceptOwnership and test fails - // we shrink to indices of [2, 1] and we recreate call sequence in same order - let mut new_calls_sequence = Vec::with_capacity(shrunk_call_indices.len()); - shrunk_call_indices.iter().for_each(|call_index| { - new_calls_sequence.push(calls.get(*call_index).unwrap()); - }); - new_calls_sequence + // we shrink to indices of [2, 1] and we recreate call sequence in same order. + shrunk_call_indices.iter().map(|idx| &calls[*idx]).collect() } /// We try to construct a [powerset](https://en.wikipedia.org/wiki/Power_set) of the sequence if @@ -341,14 +337,12 @@ impl InvariantFuzzError { ); }); - // SAFETY: there are no more live references to shrunk_call_indices as the parallel - // execution is finished, so it is fine to get the inner value via unwrap & - // into_inner - let shrunk_call_indices = - Arc::>>::try_unwrap(shrunk_call_indices).unwrap().into_inner(); + // There are no more live references to shrunk_call_indices as the parallel execution is + // finished, so it is fine to get the inner value via `Arc::unwrap`. + let shrunk_call_indices = Arc::try_unwrap(shrunk_call_indices).unwrap().into_inner(); if is_powerset { - // a powerset is guaranteed to be smallest local subset, so we return early + // A powerset is guaranteed to be smallest local subset, so we return early. return shrunk_call_indices } From 6af18e4f2cb65fc9eb5a9f25499bacbad4254aad Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:37:43 +0200 Subject: [PATCH 0685/1963] fix(cast): correctly compute mapping indexes (#7261) * fix(cast): correctly compute mapping indexes * chore: better error msg --- crates/cast/src/lib.rs | 57 +++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index ca6eb83bec30b..d8c2e995c123e 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -2,7 +2,7 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; use alloy_json_abi::ContractObject; use alloy_primitives::{ utils::{keccak256, ParseUnits, Unit}, - Address, Bytes, B256, I256, U256, + Address, Bytes, Keccak256, B256, I256, U256, }; use alloy_rlp::Decodable; use base::{Base, NumberWithBase, ToBase}; @@ -1656,16 +1656,20 @@ impl SimpleCast { .collect::>>() } - /// Prints the slot number for the specified mapping type and input data - /// Uses abi_encode to pad the data to 32 bytes. - /// For value types v, slot number of v is keccak256(concat(h(v) , p)) where h is the padding - /// function and p is slot number of the mapping. + /// Prints the slot number for the specified mapping type and input data. + /// + /// For value types `v`, slot number of `v` is `keccak256(concat(h(v), p))` where `h` is the + /// padding function for `v`'s type, and `p` is slot number of the mapping. + /// + /// See [the Solidity documentation](https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#mappings-and-dynamic-arrays) + /// for more details. /// /// # Example /// /// ``` /// # use cast::SimpleCast as Cast; /// + /// // Value types. /// assert_eq!( /// Cast::index("address", "0xD0074F4E6490ae3f888d1d4f7E3E43326bD3f0f5", "2").unwrap().as_str(), /// "0x9525a448a9000053a4d151336329d6563b7e80b24f8e628e95527f218e8ab5fb" @@ -1674,13 +1678,48 @@ impl SimpleCast { /// Cast::index("uint256", "42", "6").unwrap().as_str(), /// "0xfc808b0f31a1e6b9cf25ff6289feae9b51017b392cc8e25620a94a38dcdafcc1" /// ); + /// + /// // Strings and byte arrays. + /// assert_eq!( + /// Cast::index("string", "hello", "1").unwrap().as_str(), + /// "0x8404bb4d805e9ca2bd5dd5c43a107e935c8ec393caa7851b353b3192cd5379ae" + /// ); /// # Ok::<_, eyre::Report>(()) /// ``` pub fn index(from_type: &str, from_value: &str, slot_number: &str) -> Result { - let sig = format!("x({from_type},uint256)"); - let encoded = Self::abi_encode(&sig, &[from_value, slot_number])?; - let location: String = Self::keccak(&encoded)?; - Ok(location) + let mut hasher = Keccak256::new(); + + let v_ty = DynSolType::parse(from_type).wrap_err("Could not parse type")?; + let v = v_ty.coerce_str(from_value).wrap_err("Could not parse value")?; + match v_ty { + // For value types, `h` pads the value to 32 bytes in the same way as when storing the + // value in memory. + DynSolType::Bool | + DynSolType::Int(_) | + DynSolType::Uint(_) | + DynSolType::FixedBytes(_) | + DynSolType::Address | + DynSolType::Function => hasher.update(v.as_word().unwrap()), + + // For strings and byte arrays, `h(k)` is just the unpadded data. + DynSolType::String | DynSolType::Bytes => hasher.update(v.as_packed_seq().unwrap()), + + DynSolType::Array(..) | + DynSolType::FixedArray(..) | + DynSolType::Tuple(..) | + DynSolType::CustomStruct { .. } => { + eyre::bail!("Type `{v_ty}` is not supported as a mapping key") + } + } + + let p = DynSolType::Uint(256) + .coerce_str(slot_number) + .wrap_err("Could not parse slot number")?; + let p = p.as_word().unwrap(); + hasher.update(p); + + let location = hasher.finalize(); + Ok(location.to_string()) } /// Converts ENS names to their namehash representation From fa5e71c91170d26b2b90b804bf910200ef9c5e59 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 28 Feb 2024 14:40:18 +0100 Subject: [PATCH 0686/1963] fix: normalize solc evm if set (#7096) * wip:fix: normalize solc evm if set * feat: normalize evm version for forge config --- crates/config/src/lib.rs | 31 ++++++++++++++++++++++++++----- crates/forge/bin/cmd/config.rs | 5 ++++- crates/forge/tests/cli/config.rs | 8 ++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 32c713230492e..033a6789c17ad 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -580,12 +580,13 @@ impl Config { self.evm_version = self.get_normalized_evm_version(); } - /// Returns the normalized [EvmVersion] if a [SolcReq] is set to a valid version. + /// Returns the normalized [EvmVersion] if a [SolcReq] is set to a valid version or if the solc + /// path is a valid solc binary. /// /// Otherwise it returns the configured [EvmVersion]. pub fn get_normalized_evm_version(&self) -> EvmVersion { - if let Some(SolcReq::Version(version)) = &self.solc { - if let Some(evm_version) = self.evm_version.normalize_version(version) { + if let Some(version) = self.solc.as_ref().and_then(|solc| solc.try_version().ok()) { + if let Some(evm_version) = self.evm_version.normalize_version(&version) { return evm_version; } } @@ -1602,11 +1603,15 @@ impl Config { /// /// See also fn normalize_defaults(&mut self, figment: Figment) -> Figment { - if let Ok(version) = figment.extract_inner::("solc") { + if let Ok(solc) = figment.extract_inner::("solc") { // check if evm_version is set // TODO: add a warning if evm_version is provided but incompatible if figment.find_value("evm_version").is_err() { - if let Some(version) = self.evm_version.normalize_version(&version) { + if let Some(version) = solc + .try_version() + .ok() + .and_then(|version| self.evm_version.normalize_version(&version)) + { // normalize evm_version based on the provided solc version self.evm_version = version; } @@ -1999,6 +2004,22 @@ pub enum SolcReq { Local(PathBuf), } +impl SolcReq { + /// Tries to get the solc version from the `SolcReq` + /// + /// If the `SolcReq` is a `Version` it will return the version, if it's a path to a binary it + /// will try to get the version from the binary. + fn try_version(&self) -> Result { + match self { + SolcReq::Version(version) => Ok(version.clone()), + SolcReq::Local(path) => Solc::new(path).version().map_err(|err| { + warn!("failed to get solc version from {}: {}", path.display(), err); + err + }), + } + } +} + impl> From for SolcReq { fn from(s: T) -> Self { let s = s.as_ref(); diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index 731a545e46100..0758ddf5028bc 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -39,7 +39,10 @@ impl ConfigArgs { return Ok(()) } - let config = self.try_load_config_unsanitized_emit_warnings()?; + let config = self + .try_load_config_unsanitized_emit_warnings()? + // we explicitly normalize the version, so mimic the behavior when invoking solc + .normalized_evm_version(); let s = if self.basic { let config = config.into_basic(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index d8f9db3106d9c..f2dbf22c7aac4 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -673,3 +673,11 @@ forgetest_init!(can_resolve_symlink_fs_permissions, |prj, cmd| { let permission = fs_permissions.find_permission(&config_path.join("config.json")).unwrap(); assert_eq!(permission, FsAccessPermission::Read); }); + +// tests if evm version is normalized for config output +forgetest!(normalize_config_evm_version, |_prj, cmd| { + cmd.args(["config", "--use", "0.8.0", "--json"]); + let output = cmd.stdout_lossy(); + let config: Config = serde_json::from_str(&output).unwrap(); + assert_eq!(config.evm_version, EvmVersion::Istanbul); +}); From 6ca37340f11efe7dec18446aa1b999e98099954a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:40:37 +0200 Subject: [PATCH 0687/1963] invariant shrink #6683: check if test failed instead revert (#7257) * closes #6683: when deciding min seq to shrink to check if test failure instead revert * Fix lint * Changes after review + ensure test shrinked sequence is 3 or less --- .../evm/evm/src/executors/invariant/error.rs | 12 +- crates/forge/tests/it/invariant.rs | 69 ++++++++++- .../common/InvariantShrinkWithAssert.t.sol | 115 ++++++++++++++++++ 3 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 testdata/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 917e7732fb49e..50dedab7c81d9 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -214,12 +214,18 @@ impl InvariantFuzzError { .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) .expect("bad call to evm"); - // Checks the invariant. If we exit before the last call, all the better. + // Checks the invariant. If we revert or fail before the last call, all the better. if let Some(func) = &self.func { - let error_call_result = executor + let mut call_result = executor .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) .expect("bad call to evm"); - if error_call_result.reverted { + let is_success = executor.is_raw_call_success( + self.addr, + call_result.state_changeset.take().unwrap(), + &call_result, + false, + ); + if !is_success { let mut locked = curr_seq.write(); if new_sequence[..=seq_idx].len() < locked.len() { // update the curr_sequence if the new sequence is lower than diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index efc4364fcd890..c41bf6823e268 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -2,7 +2,7 @@ use crate::config::*; use alloy_primitives::U256; -use forge::fuzz::CounterExample; +use forge::{fuzz::CounterExample, result::TestStatus, TestOptions}; use foundry_test_utils::Filter; use std::collections::BTreeMap; @@ -118,6 +118,26 @@ async fn test_invariant() { None, )], ), + ( + "fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithAssert", + vec![( + "invariant_with_assert()", + false, + Some("".into()), + None, + None, + )], + ), + ( + "fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithRequire", + vec![( + "invariant_with_require()", + false, + Some("revert: wrong counter".into()), + None, + None, + )], + ), ]), ); } @@ -259,3 +279,50 @@ async fn test_invariant_shrink() { } }; } + +#[tokio::test(flavor = "multi_thread")] +#[cfg_attr(windows, ignore = "for some reason there's different rng")] +async fn test_invariant_assert_shrink() { + let mut opts = test_opts(); + opts.fuzz.seed = Some(U256::from(119u32)); + + // ensure assert and require shrinks to same sequence of 3 or less + test_shrink(opts.clone(), "InvariantShrinkWithAssert").await; + test_shrink(opts.clone(), "InvariantShrinkWithRequire").await; +} + +async fn test_shrink(opts: TestOptions, contract_pattern: &str) { + let mut runner = runner().await; + runner.test_options = opts.clone(); + let results = runner + .test_collect( + &Filter::new( + ".*", + contract_pattern, + ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol", + ), + opts, + ) + .await; + let results = results.values().last().expect("`InvariantShrinkWithAssert` should be testable."); + + let result = results + .test_results + .values() + .last() + .expect("`InvariantShrinkWithAssert` should be testable."); + + assert_eq!(result.status, TestStatus::Failure); + + let counter = result + .counterexample + .as_ref() + .expect("`InvariantShrinkWithAssert` should have failed with a counterexample."); + + match counter { + CounterExample::Single(_) => panic!("CounterExample should be a sequence."), + CounterExample::Sequence(sequence) => { + assert!(sequence.len() <= 3); + } + }; +} diff --git a/testdata/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol b/testdata/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol new file mode 100644 index 0000000000000..0ba6d61c8b797 --- /dev/null +++ b/testdata/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; +import "../../../cheats/Vm.sol"; + +struct FuzzSelector { + address addr; + bytes4[] selectors; +} + +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } + + function decrement() public { + number--; + } + + function double() public { + number *= 2; + } + + function half() public { + number /= 2; + } + + function triple() public { + number *= 3; + } + + function third() public { + number /= 3; + } + + function quadruple() public { + number *= 4; + } + + function quarter() public { + number /= 4; + } +} + +contract Handler is DSTest { + Counter public counter; + + constructor(Counter _counter) { + counter = _counter; + counter.setNumber(0); + } + + function increment() public { + counter.increment(); + } + + function setNumber(uint256 x) public { + counter.setNumber(x); + } +} + +contract InvariantShrinkWithAssert is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Counter public counter; + Handler handler; + + function setUp() public { + counter = new Counter(); + handler = new Handler(counter); + } + + function targetSelectors() public returns (FuzzSelector[] memory) { + FuzzSelector[] memory targets = new FuzzSelector[](1); + bytes4[] memory selectors = new bytes4[](2); + selectors[0] = handler.increment.selector; + selectors[1] = handler.setNumber.selector; + targets[0] = FuzzSelector(address(handler), selectors); + return targets; + } + + function invariant_with_assert() public { + assertTrue(counter.number() != 3); + } +} + +contract InvariantShrinkWithRequire is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Counter public counter; + Handler handler; + + function setUp() public { + counter = new Counter(); + handler = new Handler(counter); + } + + function targetSelectors() public returns (FuzzSelector[] memory) { + FuzzSelector[] memory targets = new FuzzSelector[](1); + bytes4[] memory selectors = new bytes4[](2); + selectors[0] = handler.increment.selector; + selectors[1] = handler.setNumber.selector; + targets[0] = FuzzSelector(address(handler), selectors); + return targets; + } + + function invariant_with_require() public { + require(counter.number() != 3, "wrong counter"); + } +} From 485a0d67d409e34491de2bbc111f266813802cbb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 28 Feb 2024 16:57:59 +0100 Subject: [PATCH 0688/1963] fix: also try error payload response (#7264) --- crates/common/src/provider/retry.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index 70c5998c73de0..fd8a33e42da5c 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -31,6 +31,10 @@ impl RetryPolicy for RateLimitRetryPolicy { // the start. TransportError::SerError(_) => false, TransportError::DeserError { text, .. } => { + if let Ok(resp) = serde_json::from_str::(text) { + return should_retry_json_rpc_error(&resp) + } + // some providers send invalid JSON RPC in the error case (no `id:u64`), but the // text should be a `JsonRpcError` #[derive(Deserialize)] @@ -41,6 +45,7 @@ impl RetryPolicy for RateLimitRetryPolicy { if let Ok(resp) = serde_json::from_str::(text) { return should_retry_json_rpc_error(&resp.error) } + false } TransportError::ErrorResp(err) => should_retry_json_rpc_error(err), From 165ccc070587805385fa7b5716f5dfa03a68e92b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:06:31 +0200 Subject: [PATCH 0689/1963] Contrib docs: clippy all-targets (#7263) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 859aaa6d6e0dd..98b36e8539a05 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,7 +86,7 @@ Please also make sure that the following commands pass if you have changed the c cargo check --all cargo test --all --all-features cargo +nightly fmt -- --check -cargo +nightly clippy --all --all-features -- -D warnings +cargo +nightly clippy --all --all-targets --all-features -- -D warnings ``` If you are working in VSCode, we recommend you install the [rust-analyzer](https://rust-analyzer.github.io/) extension, and use the following VSCode user settings: From 27357bfe0cfca520780736b02bd1f4ba48205410 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 28 Feb 2024 20:55:51 +0200 Subject: [PATCH 0690/1963] invariant: #6694 add `preserve_state` config (#7219) * - add preserve_state invariant config: useful for handlers that change state (e.g. using cheatcodes like roll, warp), see #6694 - active only in conjunction with fail_on_revert true * Add test from issue 6694 --- crates/config/README.md | 1 + crates/config/src/invariant.rs | 7 +++ crates/evm/evm/src/executors/invariant/mod.rs | 12 +++-- crates/forge/tests/it/config.rs | 1 + crates/forge/tests/it/invariant.rs | 53 +++++++++++++++++++ testdata/foundry.toml | 1 + .../common/InvariantPreserveState.t.sol | 49 +++++++++++++++++ 7 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 testdata/fuzz/invariant/common/InvariantPreserveState.t.sol diff --git a/crates/config/README.md b/crates/config/README.md index 8e4bdf70ec0ad..46fa83e5a3026 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -195,6 +195,7 @@ dictionary_weight = 80 include_storage = true include_push_bytes = true shrink_sequence = true +preserve_state = false [fmt] line_length = 100 diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index e4e2f86a81d4e..d2594c820aab7 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -28,6 +28,11 @@ pub struct InvariantConfig { pub shrink_sequence: bool, /// The maximum number of attempts to shrink the sequence pub shrink_run_limit: usize, + /// If set to true then VM state is committed and available for next call + /// Useful for handlers that use cheatcodes as roll or warp + /// Applies only when `fail_on_revert` set to true. Use it with caution, introduces performance + /// penalty. + pub preserve_state: bool, } impl Default for InvariantConfig { @@ -40,6 +45,7 @@ impl Default for InvariantConfig { dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() }, shrink_sequence: true, shrink_run_limit: 2usize.pow(18_u32), + preserve_state: false, } } } @@ -68,6 +74,7 @@ impl InlineConfigParser for InvariantConfig { "fail-on-revert" => conf_clone.fail_on_revert = parse_config_bool(key, value)?, "call-override" => conf_clone.call_override = parse_config_bool(key, value)?, "shrink-sequence" => conf_clone.shrink_sequence = parse_config_bool(key, value)?, + "preserve-state" => conf_clone.preserve_state = parse_config_bool(key, value)?, _ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?, } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 69e141255db11..316db1320eede 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -156,9 +156,15 @@ impl<'a> InvariantExecutor<'a> { let (sender, (address, calldata)) = inputs.last().expect("no input generated"); // Executes the call from the randomly generated sequence. - let call_result = executor - .call_raw(*sender, *address, calldata.clone(), U256::ZERO) - .expect("could not make raw evm call"); + let call_result = if self.config.fail_on_revert && self.config.preserve_state { + executor + .call_raw_committing(*sender, *address, calldata.clone(), U256::ZERO) + .expect("could not make raw evm call") + } else { + executor + .call_raw(*sender, *address, calldata.clone(), U256::ZERO) + .expect("could not make raw evm call") + }; // Collect data for fuzzing from the state changeset. let mut state_changeset = diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 04f58234fcf4f..542f9a88e3d59 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -139,6 +139,7 @@ pub fn test_opts() -> TestOptions { }, shrink_sequence: true, shrink_run_limit: 2usize.pow(18u32), + preserve_state: false, }) .build(&COMPILED, &PROJECT.paths.root) .expect("Config loaded") diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index c41bf6823e268..5959b0926de73 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -138,6 +138,10 @@ async fn test_invariant() { None, )], ), + ( + "fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", + vec![("invariant_preserve_state()", true, None, None, None)], + ), ]), ); } @@ -326,3 +330,52 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { } }; } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_preserve_state() { + let mut runner = runner().await; + + // should not fail with default options + let mut opts = test_opts(); + opts.invariant.fail_on_revert = true; + runner.test_options = opts.clone(); + let results = runner + .test_collect( + &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"), + opts, + ) + .await; + assert_multiple( + &results, + BTreeMap::from([( + "fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", + vec![("invariant_preserve_state()", true, None, None, None)], + )]), + ); + + // same test should revert when preserve state enabled + let mut opts = test_opts(); + opts.invariant.fail_on_revert = true; + opts.invariant.preserve_state = true; + runner.test_options = opts.clone(); + + let results = runner + .test_collect( + &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"), + opts, + ) + .await; + assert_multiple( + &results, + BTreeMap::from([( + "fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", + vec![( + "invariant_preserve_state()", + false, + Some("EvmError: Revert".into()), + None, + None, + )], + )]), + ); +} diff --git a/testdata/foundry.toml b/testdata/foundry.toml index 94bdeea394937..22df7b3e586a5 100644 --- a/testdata/foundry.toml +++ b/testdata/foundry.toml @@ -17,6 +17,7 @@ force = false invariant_fail_on_revert = false invariant_call_override = false invariant_shrink_sequence = true +invariant_preserve_state = false gas_limit = 9223372036854775807 gas_price = 0 gas_reports = ["*"] diff --git a/testdata/fuzz/invariant/common/InvariantPreserveState.t.sol b/testdata/fuzz/invariant/common/InvariantPreserveState.t.sol new file mode 100644 index 0000000000000..20f34c68dc379 --- /dev/null +++ b/testdata/fuzz/invariant/common/InvariantPreserveState.t.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../../../cheats/Vm.sol"; + +struct FuzzSelector { + address addr; + bytes4[] selectors; +} + +// https://github.com/foundry-rs/foundry/issues/7219 + +contract Handler is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function thisFunctionReverts() external { + if (block.number < 10) {} else { + revert(); + } + } + + function advanceTime(uint256 blocks) external { + blocks = blocks % 10; + vm.roll(block.number + blocks); + vm.warp(block.timestamp + blocks * 12); + } +} + +contract InvariantPreserveState is DSTest { + Handler handler; + + function setUp() public { + handler = new Handler(); + } + + function targetSelectors() public returns (FuzzSelector[] memory) { + FuzzSelector[] memory targets = new FuzzSelector[](1); + bytes4[] memory selectors = new bytes4[](2); + selectors[0] = handler.thisFunctionReverts.selector; + selectors[1] = handler.advanceTime.selector; + targets[0] = FuzzSelector(address(handler), selectors); + return targets; + } + + function invariant_preserve_state() public { + assertTrue(true); + } +} From 2f432fb72e3080c44b1fa472ae050f7e76c42b6d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 28 Feb 2024 22:39:49 +0100 Subject: [PATCH 0691/1963] chore: bump alloy chains (#7269) --- Cargo.lock | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9ccd381b3bc8..a3ec2e6992ede 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146dc3f33a9e282751a62ddd6687292c504605cc285a49500541e5d1e5b7617b" +checksum = "973deb9e9d5db1f28c2a478073aeb435f1c07f72cf5935caa0c421e6b68f2db1" dependencies = [ "num_enum", "serde", @@ -5065,7 +5065,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.50", @@ -5737,15 +5737,6 @@ dependencies = [ "toml_edit 0.20.7", ] -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", -] - [[package]] name = "proc-macro-error" version = "1.0.4" From 576bb59d0e72b4f9c5bf15871ee04745ce39c808 Mon Sep 17 00:00:00 2001 From: "Jongseung (John) Lim" Date: Thu, 29 Feb 2024 05:30:54 -0500 Subject: [PATCH 0692/1963] fix(forge): list cache files that are saved as block numbers for `cache ls` (#7270) * fix: forge cache ls should include blocknumber files * fix: ignore files that are not numeric only * chore: linting --- crates/config/src/lib.rs | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 033a6789c17ad..5c704d6c7bf65 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1521,12 +1521,19 @@ impl Config { if !chain_path.exists() { return Ok(blocks) } - for block in chain_path.read_dir()?.flatten().filter(|x| x.file_type().unwrap().is_dir()) { - let filepath = block.path().join("storage.json"); - blocks.push(( - block.file_name().to_string_lossy().into_owned(), - fs::metadata(filepath)?.len(), - )); + for block in chain_path.read_dir()?.flatten() { + let file_type = block.file_type()?; + let file_name = block.file_name(); + let filepath = if file_type.is_dir() { + block.path().join("storage.json") + } else if file_type.is_file() && + file_name.to_string_lossy().chars().all(char::is_numeric) + { + block.path() + } else { + continue + }; + blocks.push((file_name.to_string_lossy().into_owned(), fs::metadata(filepath)?.len())); } Ok(blocks) } @@ -4559,23 +4566,38 @@ mod tests { writeln!(file, "{}", vec![' '; size_bytes - 1].iter().collect::()).unwrap(); } + fn fake_block_cache_block_path_as_file( + chain_path: &Path, + block_number: &str, + size_bytes: usize, + ) { + let block_path = chain_path.join(block_number); + let mut file = File::create(block_path).unwrap(); + writeln!(file, "{}", vec![' '; size_bytes - 1].iter().collect::()).unwrap(); + } + let chain_dir = tempdir()?; fake_block_cache(chain_dir.path(), "1", 100); fake_block_cache(chain_dir.path(), "2", 500); + fake_block_cache_block_path_as_file(chain_dir.path(), "3", 900); // Pollution file that should not show up in the cached block let mut pol_file = File::create(chain_dir.path().join("pol.txt")).unwrap(); writeln!(pol_file, "{}", [' '; 10].iter().collect::()).unwrap(); let result = Config::get_cached_blocks(chain_dir.path())?; - assert_eq!(result.len(), 2); + assert_eq!(result.len(), 3); let block1 = &result.iter().find(|x| x.0 == "1").unwrap(); let block2 = &result.iter().find(|x| x.0 == "2").unwrap(); + let block3 = &result.iter().find(|x| x.0 == "3").unwrap(); + assert_eq!(block1.0, "1"); assert_eq!(block1.1, 100); assert_eq!(block2.0, "2"); assert_eq!(block2.1, 500); + assert_eq!(block3.0, "3"); + assert_eq!(block3.1, 900); chain_dir.close()?; Ok(()) From eab0390707419cf4866ea82b13e6687dfd5fb387 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:08:07 +0200 Subject: [PATCH 0693/1963] chore(cli): fix clap deprecated warnings (#7274) * chore: #[clap] -> #[command], #[arg] * chore: #[arg(name)] -> #[arg(id)] * chore: remove #[arg(use_value_delimiter)] * fix: update IDs in conflicts_with --- crates/anvil/server/src/config.rs | 7 +- crates/anvil/src/anvil.rs | 12 +- crates/anvil/src/cmd.rs | 100 ++++---- crates/cast/bin/cmd/access_list.rs | 16 +- crates/cast/bin/cmd/bind.rs | 10 +- crates/cast/bin/cmd/call.rs | 24 +- crates/cast/bin/cmd/create2.rs | 22 +- crates/cast/bin/cmd/estimate.rs | 16 +- crates/cast/bin/cmd/find_block.rs | 2 +- crates/cast/bin/cmd/interface.rs | 10 +- crates/cast/bin/cmd/logs.rs | 16 +- crates/cast/bin/cmd/rpc.rs | 4 +- crates/cast/bin/cmd/run.rs | 18 +- crates/cast/bin/cmd/send.rs | 20 +- crates/cast/bin/cmd/storage.rs | 12 +- crates/cast/bin/cmd/wallet/list.rs | 12 +- crates/cast/bin/cmd/wallet/mod.rs | 52 +++-- crates/cast/bin/cmd/wallet/vanity.rs | 8 +- crates/cast/bin/opts.rs | 334 +++++++++++++-------------- crates/chisel/bin/main.rs | 10 +- crates/cli/src/opts/build/core.rs | 34 +-- crates/cli/src/opts/build/mod.rs | 14 +- crates/cli/src/opts/build/paths.rs | 18 +- crates/cli/src/opts/ethereum.rs | 18 +- crates/cli/src/opts/transaction.rs | 14 +- crates/common/src/evm.rs | 58 ++--- crates/forge/bin/cmd/bind.rs | 26 +-- crates/forge/bin/cmd/build.rs | 14 +- crates/forge/bin/cmd/cache.rs | 13 +- crates/forge/bin/cmd/config.rs | 10 +- crates/forge/bin/cmd/coverage.rs | 12 +- crates/forge/bin/cmd/create.rs | 22 +- crates/forge/bin/cmd/debug.rs | 12 +- crates/forge/bin/cmd/doc/mod.rs | 18 +- crates/forge/bin/cmd/flatten.rs | 6 +- crates/forge/bin/cmd/fmt.rs | 8 +- crates/forge/bin/cmd/geiger/mod.rs | 10 +- crates/forge/bin/cmd/generate/mod.rs | 4 +- crates/forge/bin/cmd/init.rs | 14 +- crates/forge/bin/cmd/inspect.rs | 6 +- crates/forge/bin/cmd/install.rs | 14 +- crates/forge/bin/cmd/mod.rs | 4 +- crates/forge/bin/cmd/remappings.rs | 4 +- crates/forge/bin/cmd/remove.rs | 4 +- crates/forge/bin/cmd/retry.rs | 6 +- crates/forge/bin/cmd/script/mod.rs | 46 ++-- crates/forge/bin/cmd/selectors.rs | 18 +- crates/forge/bin/cmd/snapshot.rs | 22 +- crates/forge/bin/cmd/test/filter.rs | 16 +- crates/forge/bin/cmd/test/mod.rs | 32 +-- crates/forge/bin/cmd/tree.rs | 6 +- crates/forge/bin/cmd/update.rs | 6 +- crates/forge/bin/cmd/verify/mod.rs | 42 ++-- crates/forge/bin/cmd/watch.rs | 10 +- crates/forge/bin/opts.rs | 50 ++-- crates/wallets/src/multi_wallet.rs | 32 +-- crates/wallets/src/raw_wallet.rs | 14 +- crates/wallets/src/wallet.rs | 20 +- 58 files changed, 686 insertions(+), 696 deletions(-) diff --git a/crates/anvil/server/src/config.rs b/crates/anvil/server/src/config.rs index 7e23528317b1b..f968a6da39640 100644 --- a/crates/anvil/server/src/config.rs +++ b/crates/anvil/server/src/config.rs @@ -4,16 +4,15 @@ use std::str::FromStr; /// Additional server options. #[derive(Clone, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "clap", derive(clap::Parser), clap(next_help_heading = "Server options"))] +#[cfg_attr(feature = "clap", derive(clap::Parser), command(next_help_heading = "Server options"))] pub struct ServerConfig { /// The cors `allow_origin` header #[cfg_attr( feature = "clap", - clap( + arg( long, help = "Set the CORS allow_origin", default_value = "*", - name = "allow-origin", value_name = "ALLOW_ORIGIN" ) )] @@ -21,7 +20,7 @@ pub struct ServerConfig { /// Whether to enable CORS #[cfg_attr( feature = "clap", - clap(long, help = "Disable CORS", conflicts_with = "allow-origin") + arg(long, help = "Disable CORS", conflicts_with = "allow_origin") )] pub no_cors: bool, } diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 5ff9394821d87..cc60fe722934f 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -4,26 +4,26 @@ use clap::{CommandFactory, Parser, Subcommand}; /// A fast local Ethereum development node. #[derive(Parser)] -#[clap(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] +#[command(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] pub struct Anvil { - #[clap(flatten)] + #[command(flatten)] pub node: NodeArgs, - #[clap(subcommand)] + #[command(subcommand)] pub cmd: Option, } #[derive(Subcommand)] pub enum AnvilSubcommand { /// Generate shell completions script. - #[clap(visible_alias = "com")] + #[command(visible_alias = "com")] Completions { - #[clap(value_enum)] + #[arg(value_enum)] shell: clap_complete::Shell, }, /// Generate Fig autocompletion spec. - #[clap(visible_alias = "fig")] + #[command(visible_alias = "fig")] GenerateFigSpec, } diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index b87da35572ff3..070a974812287 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -30,31 +30,31 @@ use tokio::time::{Instant, Interval}; #[derive(Clone, Debug, Parser)] pub struct NodeArgs { /// Port number to listen on. - #[clap(long, short, default_value = "8545", value_name = "NUM")] + #[arg(long, short, default_value = "8545", value_name = "NUM")] pub port: u16, /// Number of dev accounts to generate and configure. - #[clap(long, short, default_value = "10", value_name = "NUM")] + #[arg(long, short, default_value = "10", value_name = "NUM")] pub accounts: u64, /// The balance of every dev account in Ether. - #[clap(long, default_value = "10000", value_name = "NUM")] + #[arg(long, default_value = "10000", value_name = "NUM")] pub balance: u64, /// The timestamp of the genesis block. - #[clap(long, value_name = "NUM")] + #[arg(long, value_name = "NUM")] pub timestamp: Option, /// BIP39 mnemonic phrase used for generating accounts. /// Cannot be used if `mnemonic_random` or `mnemonic_seed` are used - #[clap(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"])] + #[arg(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"])] pub mnemonic: Option, /// Automatically generates a BIP39 mnemonic phrase, and derives accounts from it. /// Cannot be used with other `mnemonic` options /// You can specify the number of words you want in the mnemonic. /// [default: 12] - #[clap(long, conflicts_with_all = &["mnemonic", "mnemonic_seed"], default_missing_value = "12", num_args(0..=1))] + #[arg(long, conflicts_with_all = &["mnemonic", "mnemonic_seed"], default_missing_value = "12", num_args(0..=1))] pub mnemonic_random: Option, /// Generates a BIP39 mnemonic phrase from a given seed @@ -62,40 +62,40 @@ pub struct NodeArgs { /// /// CAREFUL: this is NOT SAFE and should only be used for testing. /// Never use the private keys generated in production. - #[clap(long = "mnemonic-seed-unsafe", conflicts_with_all = &["mnemonic", "mnemonic_random"])] + #[arg(long = "mnemonic-seed-unsafe", conflicts_with_all = &["mnemonic", "mnemonic_random"])] pub mnemonic_seed: Option, /// Sets the derivation path of the child key to be derived. /// /// [default: m/44'/60'/0'/0/] - #[clap(long)] + #[arg(long)] pub derivation_path: Option, /// Don't print anything on startup and don't print logs - #[clap(long)] + #[arg(long)] pub silent: bool, /// The EVM hardfork to use. /// /// Choose the hardfork by name, e.g. `shanghai`, `paris`, `london`, etc... /// [default: latest] - #[clap(long, value_parser = Hardfork::from_str)] + #[arg(long, value_parser = Hardfork::from_str)] pub hardfork: Option, /// Block time in seconds for interval mining. - #[clap(short, long, visible_alias = "blockTime", name = "block-time", value_name = "SECONDS")] + #[arg(short, long, visible_alias = "blockTime", value_name = "SECONDS")] pub block_time: Option, /// Writes output of `anvil` as json to user-specified file. - #[clap(long, value_name = "OUT_FILE")] + #[arg(long, value_name = "OUT_FILE")] pub config_out: Option, /// Disable auto and interval mining, and mine on demand instead. - #[clap(long, visible_alias = "no-mine", conflicts_with = "block-time")] + #[arg(long, visible_alias = "no-mine", conflicts_with = "block_time")] pub no_mining: bool, /// The hosts the server will listen on. - #[clap( + #[arg( long, value_name = "IP_ADDR", env = "ANVIL_IP_ADDR", @@ -106,18 +106,18 @@ pub struct NodeArgs { pub host: Vec, /// How transactions are sorted in the mempool. - #[clap(long, default_value = "fees")] + #[arg(long, default_value = "fees")] pub order: TransactionOrder, /// Initialize the genesis block with the given `genesis.json` file. - #[clap(long, value_name = "PATH", value_parser= read_genesis_file)] + #[arg(long, value_name = "PATH", value_parser= read_genesis_file)] pub init: Option, /// This is an alias for both --load-state and --dump-state. /// /// It initializes the chain with the state and block environment stored at the file, if it /// exists, and dumps the chain's state on exit. - #[clap( + #[arg( long, value_name = "PATH", value_parser = StateFile::parse, @@ -132,17 +132,17 @@ pub struct NodeArgs { /// Interval in seconds at which the state and block environment is to be dumped to disk. /// /// See --state and --dump-state - #[clap(short, long, value_name = "SECONDS")] + #[arg(short, long, value_name = "SECONDS")] pub state_interval: Option, /// Dump the state and block environment of chain on exit to the given file. /// /// If the value is a directory, the state will be written to `/state.json`. - #[clap(long, value_name = "PATH", conflicts_with = "init")] + #[arg(long, value_name = "PATH", conflicts_with = "init")] pub dump_state: Option, /// Initialize the chain from a previously saved state snapshot. - #[clap( + #[arg( long, value_name = "PATH", value_parser = SerializableState::parse, @@ -150,22 +150,22 @@ pub struct NodeArgs { )] pub load_state: Option, - #[clap(long, help = IPC_HELP, value_name = "PATH", visible_alias = "ipcpath")] + #[arg(long, help = IPC_HELP, value_name = "PATH", visible_alias = "ipcpath")] pub ipc: Option>, /// Don't keep full chain history. /// If a number argument is specified, at most this number of states is kept in memory. - #[clap(long)] + #[arg(long)] pub prune_history: Option>, /// Number of blocks with transactions to keep in memory. - #[clap(long)] + #[arg(long)] pub transaction_block_keeper: Option, - #[clap(flatten)] + #[command(flatten)] pub evm_opts: AnvilEvmArgs, - #[clap(flatten)] + #[command(flatten)] pub server_config: ServerConfig, } @@ -344,12 +344,12 @@ impl NodeArgs { /// Anvil's EVM related arguments. #[derive(Clone, Debug, Parser)] -#[clap(next_help_heading = "EVM options")] +#[command(next_help_heading = "EVM options")] pub struct AnvilEvmArgs { /// Fetch state over a remote endpoint instead of starting from an empty state. /// /// If you want to fetch state from a specific block number, add a block number like `http://localhost:8545@1400000` or use the `--fork-block-number` argument. - #[clap( + #[arg( long, short, visible_alias = "rpc-url", @@ -361,7 +361,7 @@ pub struct AnvilEvmArgs { /// Headers to use for the rpc client, e.g. "User-Agent: test-agent" /// /// See --fork-url. - #[clap( + #[arg( long = "fork-header", value_name = "HEADERS", help_heading = "Fork config", @@ -372,35 +372,25 @@ pub struct AnvilEvmArgs { /// Timeout in ms for requests sent to remote JSON-RPC server in forking mode. /// /// Default value 45000 - #[clap( - long = "timeout", - name = "timeout", - help_heading = "Fork config", - requires = "fork_url" - )] + #[arg(id = "timeout", long = "timeout", help_heading = "Fork config", requires = "fork_url")] pub fork_request_timeout: Option, /// Number of retry requests for spurious networks (timed out requests) /// /// Default value 5 - #[clap( - long = "retries", - name = "retries", - help_heading = "Fork config", - requires = "fork_url" - )] + #[arg(id = "retries", long = "retries", help_heading = "Fork config", requires = "fork_url")] pub fork_request_retries: Option, /// Fetch state from a specific block number over a remote endpoint. /// /// See --fork-url. - #[clap(long, requires = "fork_url", value_name = "BLOCK", help_heading = "Fork config")] + #[arg(long, requires = "fork_url", value_name = "BLOCK", help_heading = "Fork config")] pub fork_block_number: Option, /// Initial retry backoff on encountering errors. /// /// See --fork-url. - #[clap(long, requires = "fork_url", value_name = "BACKOFF", help_heading = "Fork config")] + #[arg(long, requires = "fork_url", value_name = "BACKOFF", help_heading = "Fork config")] pub fork_retry_backoff: Option, /// Specify chain id to skip fetching it from remote endpoint. This enables offline-start mode. @@ -408,7 +398,7 @@ pub struct AnvilEvmArgs { /// You still must pass both `--fork-url` and `--fork-block-number`, and already have your /// required state cached on disk, anything missing locally would be fetched from the /// remote. - #[clap( + #[arg( long, help_heading = "Fork config", value_name = "CHAIN", @@ -422,7 +412,7 @@ pub struct AnvilEvmArgs { /// /// See --fork-url. /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second - #[clap( + #[arg( long, requires = "fork_url", alias = "cups", @@ -437,7 +427,7 @@ pub struct AnvilEvmArgs { /// /// See --fork-url. /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second - #[clap( + #[arg( long, requires = "fork_url", value_name = "NO_RATE_LIMITS", @@ -453,15 +443,15 @@ pub struct AnvilEvmArgs { /// This flag overrides the project's configuration file. /// /// See --fork-url. - #[clap(long, requires = "fork_url", help_heading = "Fork config")] + #[arg(long, requires = "fork_url", help_heading = "Fork config")] pub no_storage_caching: bool, /// The block gas limit. - #[clap(long, alias = "block-gas-limit", help_heading = "Environment config")] + #[arg(long, alias = "block-gas-limit", help_heading = "Environment config")] pub gas_limit: Option, /// Disable the `call.gas_limit <= block.gas_limit` constraint. - #[clap( + #[arg( long, value_name = "DISABLE_GAS_LIMIT", help_heading = "Environment config", @@ -472,15 +462,15 @@ pub struct AnvilEvmArgs { /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. By /// default, it is 0x6000 (~25kb). - #[clap(long, value_name = "CODE_SIZE", help_heading = "Environment config")] + #[arg(long, value_name = "CODE_SIZE", help_heading = "Environment config")] pub code_size_limit: Option, /// The gas price. - #[clap(long, help_heading = "Environment config")] + #[arg(long, help_heading = "Environment config")] pub gas_price: Option, /// The base fee in a block. - #[clap( + #[arg( long, visible_alias = "base-fee", value_name = "FEE", @@ -489,19 +479,19 @@ pub struct AnvilEvmArgs { pub block_base_fee_per_gas: Option, /// The chain ID. - #[clap(long, alias = "chain", help_heading = "Environment config")] + #[arg(long, alias = "chain", help_heading = "Environment config")] pub chain_id: Option, /// Enable steps tracing used for debug calls returning geth-style traces - #[clap(long, visible_alias = "tracing")] + #[arg(long, visible_alias = "tracing")] pub steps_tracing: bool, /// Enable autoImpersonate on startup - #[clap(long, visible_alias = "auto-impersonate")] + #[arg(long, visible_alias = "auto-impersonate")] pub auto_impersonate: bool, /// Run an Optimism chain - #[clap(long, visible_alias = "optimism")] + #[arg(long, visible_alias = "optimism")] pub optimism: bool, } diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index fa31380ff14d5..2ac5a0488468d 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -15,22 +15,22 @@ use std::str::FromStr; #[derive(Debug, Parser)] pub struct AccessListArgs { /// The destination of the transaction. - #[clap( + #[arg( value_name = "TO", value_parser = NameOrAddress::from_str )] to: Option, /// The signature of the function to call. - #[clap(value_name = "SIG")] + #[arg(value_name = "SIG")] sig: Option, /// The arguments of the function to call. - #[clap(value_name = "ARGS")] + #[arg(value_name = "ARGS")] args: Vec, /// The data for the transaction. - #[clap( + #[arg( long, value_name = "DATA", conflicts_with_all = &["sig", "args"] @@ -40,17 +40,17 @@ pub struct AccessListArgs { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, /// Print the access list as JSON. - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] json: bool, - #[clap(flatten)] + #[command(flatten)] tx: TransactionOpts, - #[clap(flatten)] + #[command(flatten)] eth: EthereumOpts, } diff --git a/crates/cast/bin/cmd/bind.rs b/crates/cast/bin/cmd/bind.rs index 2de32e2ff6877..73a62825ae7b4 100644 --- a/crates/cast/bin/cmd/bind.rs +++ b/crates/cast/bin/cmd/bind.rs @@ -18,7 +18,7 @@ pub struct BindArgs { path_or_address: String, /// Path to where bindings will be stored - #[clap( + #[arg( short, long, value_hint = ValueHint::DirPath, @@ -30,7 +30,7 @@ pub struct BindArgs { /// /// This should be a valid crates.io crate name. However, this is currently not validated by /// this command. - #[clap( + #[arg( long, default_value = DEFAULT_CRATE_NAME, value_name = "NAME" @@ -41,7 +41,7 @@ pub struct BindArgs { /// /// This should be a standard semver version string. However, it is not currently validated by /// this command. - #[clap( + #[arg( long, default_value = DEFAULT_CRATE_VERSION, value_name = "VERSION" @@ -49,10 +49,10 @@ pub struct BindArgs { crate_version: String, /// Generate bindings as separate files. - #[clap(long)] + #[arg(long)] separate_files: bool, - #[clap(flatten)] + #[command(flatten)] etherscan: EtherscanOpts, } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 4851e9cf9a6fa..3d8afbfd25b9f 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -22,7 +22,7 @@ type Provider = ethers_providers::Provider; #[derive(Debug, Parser)] pub struct CallArgs { /// The destination of the transaction. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] to: Option, /// The signature of the function to call. @@ -32,51 +32,51 @@ pub struct CallArgs { args: Vec, /// Data for the transaction. - #[clap( + #[arg( long, conflicts_with_all = &["sig", "args"] )] data: Option, /// Forks the remote rpc, executes the transaction locally and prints a trace - #[clap(long, default_value_t = false)] + #[arg(long, default_value_t = false)] trace: bool, /// Opens an interactive debugger. /// Can only be used with `--trace`. - #[clap(long, requires = "trace")] + #[arg(long, requires = "trace")] debug: bool, /// Labels to apply to the traces; format: `address:label`. /// Can only be used with `--trace`. - #[clap(long, requires = "trace")] + #[arg(long, requires = "trace")] labels: Vec, /// The EVM Version to use. /// Can only be used with `--trace`. - #[clap(long, requires = "trace")] + #[arg(long, requires = "trace")] evm_version: Option, /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short)] + #[arg(long, short)] block: Option, - #[clap(subcommand)] + #[command(subcommand)] command: Option, - #[clap(flatten)] + #[command(flatten)] tx: TransactionOpts, - #[clap(flatten)] + #[command(flatten)] eth: EthereumOpts, } #[derive(Debug, Parser)] pub enum CallSubcommands { /// ignores the address field and simulates creating a contract - #[clap(name = "--create")] + #[command(name = "--create")] Create { /// Bytecode of contract. code: String, @@ -92,7 +92,7 @@ pub enum CallSubcommands { /// Either specified in wei, or as a string with a unit type. /// /// Examples: 1ether, 10gwei, 0.01ether - #[clap(long, value_parser = parse_ether_value)] + #[arg(long, value_parser = parse_ether_value)] value: Option, }, } diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index dfe34724df453..6474d52e59cab 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -19,7 +19,7 @@ const DEPLOYER: &str = "0x4e59b44847b379578588920ca78fbf26c0b4956c"; #[derive(Clone, Debug, Parser)] pub struct Create2Args { /// Prefix for the contract address. - #[clap( + #[arg( long, short, required_unless_present_any = &["ends_with", "matching"], @@ -28,19 +28,19 @@ pub struct Create2Args { starts_with: Option, /// Suffix for the contract address. - #[clap(long, short, value_name = "HEX")] + #[arg(long, short, value_name = "HEX")] ends_with: Option, /// Sequence that the address has to match. - #[clap(long, short, value_name = "HEX")] + #[arg(long, short, value_name = "HEX")] matching: Option, /// Case sensitive matching. - #[clap(short, long)] + #[arg(short, long)] case_sensitive: bool, /// Address of the contract deployer. - #[clap( + #[arg( short, long, default_value = DEPLOYER, @@ -49,27 +49,27 @@ pub struct Create2Args { deployer: Address, /// Init code of the contract to be deployed. - #[clap(short, long, value_name = "HEX")] + #[arg(short, long, value_name = "HEX")] init_code: Option, /// Init code hash of the contract to be deployed. - #[clap(alias = "ch", long, value_name = "HASH", required_unless_present = "init_code")] + #[arg(alias = "ch", long, value_name = "HASH", required_unless_present = "init_code")] init_code_hash: Option, /// Number of threads to use. Defaults to and caps at the number of logical cores. - #[clap(short, long)] + #[arg(short, long)] jobs: Option, /// Address of the caller. Used for the first 20 bytes of the salt. - #[clap(long, value_name = "ADDRESS")] + #[arg(long, value_name = "ADDRESS")] caller: Option
, /// The random number generator's seed, used to initialize the salt. - #[clap(long, value_name = "HEX")] + #[arg(long, value_name = "HEX")] seed: Option, /// Don't initialize the salt with a random value, and instead use the default value of 0. - #[clap(long, conflicts_with = "seed")] + #[arg(long, conflicts_with = "seed")] no_random: bool, } diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 6089f0153fd78..56fdc40d336e1 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -14,7 +14,7 @@ use std::str::FromStr; #[derive(Debug, Parser)] pub struct EstimateArgs { /// The destination of the transaction. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] to: Option, /// The signature of the function to call. @@ -24,7 +24,7 @@ pub struct EstimateArgs { args: Vec, /// The sender account. - #[clap( + #[arg( short, long, value_parser = NameOrAddress::from_str, @@ -38,23 +38,23 @@ pub struct EstimateArgs { /// Either specified in wei, or as a string with a unit type: /// /// Examples: 1ether, 10gwei, 0.01ether - #[clap(long, value_parser = parse_ether_value)] + #[arg(long, value_parser = parse_ether_value)] value: Option, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, - #[clap(flatten)] + #[command(flatten)] etherscan: EtherscanOpts, - #[clap(subcommand)] + #[command(subcommand)] command: Option, } #[derive(Debug, Parser)] pub enum EstimateSubcommands { /// Estimate gas cost to deploy a smart contract - #[clap(name = "--create")] + #[command(name = "--create")] Create { /// The bytecode of contract code: String, @@ -70,7 +70,7 @@ pub enum EstimateSubcommands { /// Either specified in wei, or as a string with a unit type: /// /// Examples: 1ether, 10gwei, 0.01ether - #[clap(long, value_parser = parse_ether_value)] + #[arg(long, value_parser = parse_ether_value)] value: Option, }, } diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index 381d52c50cc31..5038ded7b6205 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -14,7 +14,7 @@ pub struct FindBlockArgs { /// The UNIX timestamp to search for, in seconds. timestamp: u64, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, } diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 9d3af767f2e11..14de351f202b7 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -16,17 +16,17 @@ pub struct InterfaceArgs { path_or_address: String, /// The name to use for the generated interface. - #[clap(long, short)] + #[arg(long, short)] name: Option, /// Solidity pragma version. - #[clap(long, short, default_value = "^0.8.4", value_name = "VERSION")] + #[arg(long, short, default_value = "^0.8.4", value_name = "VERSION")] pragma: String, /// The path to the output file. /// /// If not specified, the interface will be output to stdout. - #[clap( + #[arg( short, long, value_hint = clap::ValueHint::FilePath, @@ -35,10 +35,10 @@ pub struct InterfaceArgs { output: Option, /// If specified, the interface will be output as JSON rather than Solidity. - #[clap(long, short)] + #[arg(long, short)] json: bool, - #[clap(flatten)] + #[command(flatten)] etherscan: EtherscanOpts, } diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 752d90dfed6c5..e7816afa38987 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -22,17 +22,17 @@ pub struct LogsArgs { /// The block height to start query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long)] + #[arg(long)] from_block: Option, /// The block height to stop query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long)] + #[arg(long)] to_block: Option, /// The contract address to filter on. - #[clap( + #[arg( long, value_parser = NameOrAddress::from_str )] @@ -40,24 +40,24 @@ pub struct LogsArgs { /// The signature of the event to filter logs by which will be converted to the first topic or /// a topic to filter on. - #[clap(value_name = "SIG_OR_TOPIC")] + #[arg(value_name = "SIG_OR_TOPIC")] sig_or_topic: Option, /// If used with a signature, the indexed fields of the event to filter by. Otherwise, the /// remaining topics of the filter. - #[clap(value_name = "TOPICS_OR_ARGS")] + #[arg(value_name = "TOPICS_OR_ARGS")] topics_or_args: Vec, /// If the RPC type and endpoints supports `eth_subscribe` stream logs instead of printing and /// exiting. Will continue until interrupted or TO_BLOCK is reached. - #[clap(long)] + #[arg(long)] subscribe: bool, /// Print the logs as JSON.s - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] json: bool, - #[clap(flatten)] + #[command(flatten)] eth: EthereumOpts, } diff --git a/crates/cast/bin/cmd/rpc.rs b/crates/cast/bin/cmd/rpc.rs index 44275204adefb..9dffcfd18de53 100644 --- a/crates/cast/bin/cmd/rpc.rs +++ b/crates/cast/bin/cmd/rpc.rs @@ -26,10 +26,10 @@ pub struct RpcArgs { /// /// cast rpc eth_getBlockByNumber '["0x123", false]' --raw /// => {"method": "eth_getBlockByNumber", "params": ["0x123", false] ... } - #[clap(long, short = 'w')] + #[arg(long, short = 'w')] raw: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index ccdd2648095c5..796368c69ae10 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -25,36 +25,36 @@ pub struct RunArgs { tx_hash: String, /// Opens the transaction in the debugger. - #[clap(long, short)] + #[arg(long, short)] debug: bool, /// Print out opcode traces. - #[clap(long, short)] + #[arg(long, short)] trace_printer: bool, /// Executes the transaction only with the state from the previous block. /// /// May result in different results than the live execution! - #[clap(long, short)] + #[arg(long, short)] quick: bool, /// Prints the full address of the contract. - #[clap(long, short)] + #[arg(long, short)] verbose: bool, /// Label addresses in the trace. /// /// Example: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045:vitalik.eth - #[clap(long, short)] + #[arg(long, short)] label: Vec, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, /// The EVM version to use. /// /// Overrides the version specified in the config. - #[clap(long, short)] + #[arg(long, short)] evm_version: Option, /// Sets the number of assumed available compute units per second for this provider @@ -62,7 +62,7 @@ pub struct RunArgs { /// default value: 330 /// /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second - #[clap(long, alias = "cups", value_name = "CUPS")] + #[arg(long, alias = "cups", value_name = "CUPS")] pub compute_units_per_second: Option, /// Disables rate limiting for this node's provider. @@ -70,7 +70,7 @@ pub struct RunArgs { /// default value: false /// /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second - #[clap(long, value_name = "NO_RATE_LIMITS", visible_alias = "no-rpc-rate-limit")] + #[arg(long, value_name = "NO_RATE_LIMITS", visible_alias = "no-rpc-rate-limit")] pub no_rate_limit: bool, } diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index b68ba5c7566d6..22366483c7bea 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -22,7 +22,7 @@ pub struct SendTxArgs { /// The destination of the transaction. /// /// If not provided, you must use cast send --create. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] to: Option, /// The signature of the function to call. @@ -32,39 +32,39 @@ pub struct SendTxArgs { args: Vec, /// Only print the transaction hash and exit immediately. - #[clap(name = "async", long = "async", alias = "cast-async", env = "CAST_ASYNC")] + #[arg(id = "async", long = "async", alias = "cast-async", env = "CAST_ASYNC")] cast_async: bool, /// The number of confirmations until the receipt is fetched. - #[clap(long, default_value = "1")] + #[arg(long, default_value = "1")] confirmations: usize, /// Print the transaction receipt as JSON. - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] json: bool, /// Reuse the latest nonce for the sender account. - #[clap(long, conflicts_with = "nonce")] + #[arg(long, conflicts_with = "nonce")] resend: bool, - #[clap(subcommand)] + #[command(subcommand)] command: Option, /// Send via `eth_sendTransaction using the `--from` argument or $ETH_FROM as sender - #[clap(long, requires = "from")] + #[arg(long, requires = "from")] unlocked: bool, - #[clap(flatten)] + #[command(flatten)] tx: TransactionOpts, - #[clap(flatten)] + #[command(flatten)] eth: EthereumOpts, } #[derive(Debug, Parser)] pub enum SendTxSubcommands { /// Use to deploy raw contract bytecode. - #[clap(name = "--create")] + #[command(name = "--create")] Create { /// The bytecode of the contract to deploy. code: String, diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index f8f01b7aec7cf..397bd07e2b1bb 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -36,26 +36,26 @@ const MIN_SOLC: Version = Version::new(0, 6, 5); #[derive(Clone, Debug, Parser)] pub struct StorageArgs { /// The contract address. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] address: NameOrAddress, /// The storage slot number. - #[clap(value_parser = parse_slot)] + #[arg(value_parser = parse_slot)] slot: Option, /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short)] + #[arg(long, short)] block: Option, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, - #[clap(flatten)] + #[command(flatten)] etherscan: EtherscanOpts, - #[clap(flatten)] + #[command(flatten)] build: CoreBuildArgs, } diff --git a/crates/cast/bin/cmd/wallet/list.rs b/crates/cast/bin/cmd/wallet/list.rs index b0984d4ba861a..2790366a37c71 100644 --- a/crates/cast/bin/cmd/wallet/list.rs +++ b/crates/cast/bin/cmd/wallet/list.rs @@ -10,27 +10,27 @@ use foundry_wallets::multi_wallet::MultiWalletOptsBuilder; pub struct ListArgs { /// List all the accounts in the keystore directory. /// Default keystore directory is used if no path provided. - #[clap(long, default_missing_value = "", num_args(0..=1))] + #[arg(long, default_missing_value = "", num_args(0..=1))] dir: Option, /// List accounts from a Ledger hardware wallet. - #[clap(long, short, group = "hw-wallets")] + #[arg(long, short, group = "hw-wallets")] ledger: bool, /// List accounts from a Trezor hardware wallet. - #[clap(long, short, group = "hw-wallets")] + #[arg(long, short, group = "hw-wallets")] trezor: bool, /// List accounts from AWS KMS. - #[clap(long)] + #[arg(long)] aws: bool, /// List all configured accounts. - #[clap(long, group = "hw-wallets")] + #[arg(long, group = "hw-wallets")] all: bool, /// Max number of addresses to display from hardware wallets. - #[clap(long, short, default_value = "3", requires = "hw-wallets")] + #[arg(long, short, default_value = "3", requires = "hw-wallets")] max_senders: Option, } diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index c5c045b75c80e..9a08984d7ae9b 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -25,7 +25,7 @@ use list::ListArgs; #[derive(Debug, Parser)] pub enum WalletSubcommands { /// Create a new random keypair. - #[clap(visible_alias = "n")] + #[command(visible_alias = "n")] New { /// If provided, then keypair will be written to an encrypted JSON keystore. path: Option, @@ -33,53 +33,53 @@ pub enum WalletSubcommands { /// Triggers a hidden password prompt for the JSON keystore. /// /// Deprecated: prompting for a hidden password is now the default. - #[clap(long, short, requires = "path", conflicts_with = "unsafe_password")] + #[arg(long, short, requires = "path", conflicts_with = "unsafe_password")] password: bool, /// Password for the JSON keystore in cleartext. /// /// This is UNSAFE to use and we recommend using the --password. - #[clap(long, requires = "path", env = "CAST_PASSWORD", value_name = "PASSWORD")] + #[arg(long, requires = "path", env = "CAST_PASSWORD", value_name = "PASSWORD")] unsafe_password: Option, /// Number of wallets to generate. - #[clap(long, short, default_value = "1")] + #[arg(long, short, default_value = "1")] number: u32, /// Output generated wallets as JSON. - #[clap(long, short, default_value = "false")] + #[arg(long, short, default_value = "false")] json: bool, }, /// Generates a random BIP39 mnemonic phrase - #[clap(visible_alias = "nm")] + #[command(visible_alias = "nm")] NewMnemonic { /// Number of words for the mnemonic - #[clap(long, short, default_value = "12")] + #[arg(long, short, default_value = "12")] words: usize, /// Number of accounts to display - #[clap(long, short, default_value = "1")] + #[arg(long, short, default_value = "1")] accounts: u8, }, /// Generate a vanity address. - #[clap(visible_alias = "va")] + #[command(visible_alias = "va")] Vanity(VanityArgs), /// Convert a private key to an address. - #[clap(visible_aliases = &["a", "addr"])] + #[command(visible_aliases = &["a", "addr"])] Address { /// If provided, the address will be derived from the specified private key. - #[clap(value_name = "PRIVATE_KEY")] + #[arg(value_name = "PRIVATE_KEY")] private_key_override: Option, - #[clap(flatten)] + #[command(flatten)] wallet: WalletOpts, }, /// Sign a message or typed data. - #[clap(visible_alias = "s")] + #[command(visible_alias = "s")] Sign { /// The message, typed data, or hash to sign. /// @@ -97,23 +97,23 @@ pub enum WalletSubcommands { message: String, /// Treat the message as JSON typed data. - #[clap(long)] + #[arg(long)] data: bool, /// Treat the message as a file containing JSON typed data. Requires `--data`. - #[clap(long, requires = "data")] + #[arg(long, requires = "data")] from_file: bool, /// Treat the message as a raw 32-byte hash and sign it directly without hashing it again. - #[clap(long, conflicts_with = "data")] + #[arg(long, conflicts_with = "data")] no_hash: bool, - #[clap(flatten)] + #[command(flatten)] wallet: WalletOpts, }, /// Verify the signature of a message. - #[clap(visible_alias = "v")] + #[command(visible_alias = "v")] Verify { /// The original message. message: String, @@ -122,28 +122,30 @@ pub enum WalletSubcommands { signature: Signature, /// The address of the message signer. - #[clap(long, short)] + #[arg(long, short)] address: Address, }, + /// Import a private key into an encrypted keystore. - #[clap(visible_alias = "i")] + #[command(visible_alias = "i")] Import { /// The name for the account in the keystore. - #[clap(value_name = "ACCOUNT_NAME")] + #[arg(value_name = "ACCOUNT_NAME")] account_name: String, /// If provided, keystore will be saved here instead of the default keystores directory /// (~/.foundry/keystores) - #[clap(long, short)] + #[arg(long, short)] keystore_dir: Option, - #[clap(flatten)] + #[command(flatten)] raw_wallet_options: RawWalletOpts, }, + /// List all the accounts in the keystore default directory - #[clap(visible_alias = "ls")] + #[command(visible_alias = "ls")] List(ListArgs), /// Derives private key from mnemonic - #[clap(name = "derive-private-key", visible_aliases = &["--derive-private-key"])] + #[command(name = "derive-private-key", visible_aliases = &["--derive-private-key"])] DerivePrivateKey { mnemonic: String, mnemonic_index: Option }, } diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index a466bbe31cf23..c3485ddfa96f9 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -18,7 +18,7 @@ pub type GeneratedWallet = (SigningKey, Address); #[derive(Clone, Debug, Parser)] pub struct VanityArgs { /// Prefix for the vanity address. - #[clap( + #[arg( long, required_unless_present = "ends_with", value_parser = HexAddressValidator, @@ -27,20 +27,20 @@ pub struct VanityArgs { pub starts_with: Option, /// Suffix for the vanity address. - #[clap(long, value_parser = HexAddressValidator, value_name = "HEX")] + #[arg(long, value_parser = HexAddressValidator, value_name = "HEX")] pub ends_with: Option, // 2^64-1 is max possible nonce per [eip-2681](https://eips.ethereum.org/EIPS/eip-2681). /// Generate a vanity contract address created by the generated keypair with the specified /// nonce. - #[clap(long)] + #[arg(long)] pub nonce: Option, /// Path to save the generated vanity contract address to. /// /// If provided, the generated vanity addresses will appended to a JSON array in the specified /// file. - #[clap( + #[arg( long, value_hint = clap::ValueHint::FilePath, value_name = "PATH", diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 9cce3349474fa..bfb24b01baaed 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -21,53 +21,53 @@ const VERSION_MESSAGE: &str = concat!( /// Perform Ethereum RPC calls from the comfort of your command line. #[derive(Parser)] -#[clap( +#[command( name = "cast", version = VERSION_MESSAGE, after_help = "Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html", next_display_order = None, )] pub struct Cast { - #[clap(subcommand)] + #[command(subcommand)] pub cmd: CastSubcommand, } #[derive(Subcommand)] pub enum CastSubcommand { /// Prints the maximum value of the given integer type. - #[clap(visible_aliases = &["--max-int", "maxi"])] + #[command(visible_aliases = &["--max-int", "maxi"])] MaxInt { /// The integer type to get the maximum value of. - #[clap(default_value = "int256")] + #[arg(default_value = "int256")] r#type: String, }, /// Prints the minimum value of the given integer type. - #[clap(visible_aliases = &["--min-int", "mini"])] + #[command(visible_aliases = &["--min-int", "mini"])] MinInt { /// The integer type to get the minimum value of. - #[clap(default_value = "int256")] + #[arg(default_value = "int256")] r#type: String, }, /// Prints the maximum value of the given integer type. - #[clap(visible_aliases = &["--max-uint", "maxu"])] + #[command(visible_aliases = &["--max-uint", "maxu"])] MaxUint { /// The unsigned integer type to get the maximum value of. - #[clap(default_value = "uint256")] + #[arg(default_value = "uint256")] r#type: String, }, /// Prints the zero address. - #[clap(visible_aliases = &["--address-zero", "az"])] + #[command(visible_aliases = &["--address-zero", "az"])] AddressZero, /// Prints the zero hash. - #[clap(visible_aliases = &["--hash-zero", "hz"])] + #[command(visible_aliases = &["--hash-zero", "hz"])] HashZero, /// Convert UTF8 text to hex. - #[clap( + #[command( visible_aliases = &[ "--from-ascii", "--from-utf8", @@ -81,14 +81,14 @@ pub enum CastSubcommand { }, /// Concatenate hex strings. - #[clap(visible_aliases = &["--concat-hex", "ch"])] + #[command(visible_aliases = &["--concat-hex", "ch"])] ConcatHex { /// The data to concatenate. data: Vec, }, /// Convert binary data into hex data. - #[clap(visible_aliases = &["--from-bin", "from-binx", "fb"])] + #[command(visible_aliases = &["--from-bin", "from-binx", "fb"])] FromBin, /// Normalize the input to lowercase, 0x-prefixed hex. @@ -98,14 +98,14 @@ pub enum CastSubcommand { /// - 0x prefixed hex, concatenated with a ':' /// - an absolute path to file /// - @tag, where the tag is defined in an environment variable - #[clap(visible_aliases = &["--to-hexdata", "thd", "2hd"])] + #[command(visible_aliases = &["--to-hexdata", "thd", "2hd"])] ToHexdata { /// The input to normalize. input: Option, }, /// Convert an address to a checksummed format (EIP-55). - #[clap( + #[command( visible_aliases = &["--to-checksum-address", "--to-checksum", "to-checksum", @@ -118,57 +118,57 @@ pub enum CastSubcommand { }, /// Convert hex data to an ASCII string. - #[clap(visible_aliases = &["--to-ascii", "tas", "2as"])] + #[command(visible_aliases = &["--to-ascii", "tas", "2as"])] ToAscii { /// The hex data to convert. hexdata: Option, }, /// Convert a fixed point number into an integer. - #[clap(visible_aliases = &["--from-fix", "ff"])] + #[command(visible_aliases = &["--from-fix", "ff"])] FromFixedPoint { /// The number of decimals to use. decimals: Option, /// The value to convert. - #[clap(allow_hyphen_values = true)] + #[arg(allow_hyphen_values = true)] value: Option, }, /// Right-pads hex data to 32 bytes. - #[clap(visible_aliases = &["--to-bytes32", "tb", "2b"])] + #[command(visible_aliases = &["--to-bytes32", "tb", "2b"])] ToBytes32 { /// The hex data to convert. bytes: Option, }, /// Convert an integer into a fixed point number. - #[clap(visible_aliases = &["--to-fix", "tf", "2f"])] + #[command(visible_aliases = &["--to-fix", "tf", "2f"])] ToFixedPoint { /// The number of decimals to use. decimals: Option, /// The value to convert. - #[clap(allow_hyphen_values = true)] + #[arg(allow_hyphen_values = true)] value: Option, }, /// Convert a number to a hex-encoded uint256. - #[clap(name = "to-uint256", visible_aliases = &["--to-uint256", "tu", "2u"])] + #[command(name = "to-uint256", visible_aliases = &["--to-uint256", "tu", "2u"])] ToUint256 { /// The value to convert. value: Option, }, /// Convert a number to a hex-encoded int256. - #[clap(name = "to-int256", visible_aliases = &["--to-int256", "ti", "2i"])] + #[command(name = "to-int256", visible_aliases = &["--to-int256", "ti", "2i"])] ToInt256 { /// The value to convert. value: Option, }, /// Perform a left shifting operation - #[clap(name = "shl")] + #[command(name = "shl")] LeftShift { /// The value to shift. value: String, @@ -177,16 +177,16 @@ pub enum CastSubcommand { bits: String, /// The input base. - #[clap(long)] + #[arg(long)] base_in: Option, /// The output base. - #[clap(long, default_value = "16")] + #[arg(long, default_value = "16")] base_out: String, }, /// Perform a right shifting operation - #[clap(name = "shr")] + #[command(name = "shr")] RightShift { /// The value to shift. value: String, @@ -195,11 +195,11 @@ pub enum CastSubcommand { bits: String, /// The input base, - #[clap(long)] + #[arg(long)] base_in: Option, /// The output base, - #[clap(long, default_value = "16")] + #[arg(long, default_value = "16")] base_out: String, }, @@ -211,46 +211,46 @@ pub enum CastSubcommand { /// - 1ether /// - 1 gwei /// - 1gwei ether - #[clap(visible_aliases = &["--to-unit", "tun", "2un"])] + #[command(visible_aliases = &["--to-unit", "tun", "2un"])] ToUnit { /// The value to convert. value: Option, /// The unit to convert to (ether, gwei, wei). - #[clap(default_value = "wei")] + #[arg(default_value = "wei")] unit: String, }, /// Convert an ETH amount to wei. /// /// Consider using --to-unit. - #[clap(visible_aliases = &["--to-wei", "tw", "2w"])] + #[command(visible_aliases = &["--to-wei", "tw", "2w"])] ToWei { /// The value to convert. - #[clap(allow_hyphen_values = true)] + #[arg(allow_hyphen_values = true)] value: Option, /// The unit to convert from (ether, gwei, wei). - #[clap(default_value = "eth")] + #[arg(default_value = "eth")] unit: String, }, /// Convert wei into an ETH amount. /// /// Consider using --to-unit. - #[clap(visible_aliases = &["--from-wei", "fw"])] + #[command(visible_aliases = &["--from-wei", "fw"])] FromWei { /// The value to convert. - #[clap(allow_hyphen_values = true)] + #[arg(allow_hyphen_values = true)] value: Option, /// The unit to convert from (ether, gwei, wei). - #[clap(default_value = "eth")] + #[arg(default_value = "eth")] unit: String, }, - /// RLP encodes hex data, or an array of hex data - #[clap(visible_aliases = &["--to-rlp"])] + /// RLP encodes hex data, or an array of hex data. + #[command(visible_aliases = &["--to-rlp"])] ToRlp { /// The value to convert. value: Option, @@ -259,22 +259,22 @@ pub enum CastSubcommand { /// Decodes RLP encoded data. /// /// Input must be hexadecimal. - #[clap(visible_aliases = &["--from-rlp"])] + #[command(visible_aliases = &["--from-rlp"])] FromRlp { /// The value to convert. value: Option, }, /// Converts a number of one base to another - #[clap(visible_aliases = &["--to-hex", "th", "2h"])] + #[command(visible_aliases = &["--to-hex", "th", "2h"])] ToHex(ToBaseArgs), /// Converts a number of one base to decimal - #[clap(visible_aliases = &["--to-dec", "td", "2d"])] + #[command(visible_aliases = &["--to-dec", "td", "2d"])] ToDec(ToBaseArgs), /// Converts a number of one base to another - #[clap( + #[command( visible_aliases = &["--to-base", "--to-radix", "to-radix", @@ -282,21 +282,21 @@ pub enum CastSubcommand { "2r"] )] ToBase { - #[clap(flatten)] + #[command(flatten)] base: ToBaseArgs, /// The output base. - #[clap(value_name = "BASE")] + #[arg(value_name = "BASE")] base_out: Option, }, /// Create an access list for a transaction. - #[clap(visible_aliases = &["ac", "acl"])] + #[command(visible_aliases = &["ac", "acl"])] AccessList(AccessListArgs), /// Get logs by signature or topic. - #[clap(visible_alias = "l")] + #[command(visible_alias = "l")] Logs(LogsArgs), /// Get information about a block. - #[clap(visible_alias = "bl")] + #[command(visible_alias = "bl")] Block { /// The block height to query at. /// @@ -304,89 +304,89 @@ pub enum CastSubcommand { block: Option, /// If specified, only get the given field of the block. - #[clap(long, short)] + #[arg(long, short)] field: Option, - #[clap(long, env = "CAST_FULL_BLOCK")] + #[arg(long, env = "CAST_FULL_BLOCK")] full: bool, /// Print the block as JSON. - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] json: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the latest block number. - #[clap(visible_alias = "bn")] + #[command(visible_alias = "bn")] BlockNumber { - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Perform a call on an account without publishing a transaction. - #[clap(visible_alias = "c")] + #[command(visible_alias = "c")] Call(CallArgs), /// ABI-encode a function with arguments. - #[clap(name = "calldata", visible_alias = "cd")] + #[command(name = "calldata", visible_alias = "cd")] CalldataEncode { /// The function signature in the format `()()` sig: String, /// The arguments to encode. - #[clap(allow_hyphen_values = true)] + #[arg(allow_hyphen_values = true)] args: Vec, }, /// Get the symbolic name of the current chain. Chain { - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the Ethereum chain ID. - #[clap(visible_aliases = &["ci", "cid"])] + #[command(visible_aliases = &["ci", "cid"])] ChainId { - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the current client version. - #[clap(visible_alias = "cl")] + #[command(visible_alias = "cl")] Client { - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Compute the contract address from a given nonce and deployer address. - #[clap(visible_alias = "ca")] + #[command(visible_alias = "ca")] ComputeAddress { /// The deployer address. address: Option, /// The nonce of the deployer address. - #[clap(long)] + #[arg(long)] nonce: Option, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Disassembles hex encoded bytecode into individual / human readable opcodes - #[clap(visible_alias = "da")] + #[command(visible_alias = "da")] Disassemble { /// The hex encoded bytecode. bytecode: String, }, /// Calculate the ENS namehash of a name. - #[clap(visible_aliases = &["na", "nh"])] + #[command(visible_aliases = &["na", "nh"])] Namehash { name: Option }, /// Get information about a transaction. - #[clap(visible_alias = "t")] + #[command(visible_alias = "t")] Tx { /// The transaction hash. tx_hash: String, @@ -396,19 +396,19 @@ pub enum CastSubcommand { field: Option, /// Print the raw RLP encoded transaction. - #[clap(long, conflicts_with = "field")] + #[arg(long, conflicts_with = "field")] raw: bool, /// Print as JSON. - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] json: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the transaction receipt for a transaction. - #[clap(visible_alias = "re")] + #[command(visible_alias = "re")] Receipt { /// The transaction hash. tx_hash: String, @@ -417,48 +417,48 @@ pub enum CastSubcommand { field: Option, /// The number of confirmations until the receipt is fetched - #[clap(long, default_value = "1")] + #[arg(long, default_value = "1")] confirmations: usize, /// Exit immediately if the transaction was not found. - #[clap(long = "async", env = "CAST_ASYNC", name = "async", alias = "cast-async")] + #[arg(id = "async", long = "async", env = "CAST_ASYNC", alias = "cast-async")] cast_async: bool, /// Print as JSON. - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] json: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Sign and publish a transaction. - #[clap(name = "send", visible_alias = "s")] + #[command(name = "send", visible_alias = "s")] SendTx(SendTxArgs), /// Publish a raw transaction to the network. - #[clap(name = "publish", visible_alias = "p")] + #[command(name = "publish", visible_alias = "p")] PublishTx { /// The raw transaction raw_tx: String, /// Only print the transaction hash and exit immediately. - #[clap(long = "async", env = "CAST_ASYNC", name = "async", alias = "cast-async")] + #[arg(id = "async", long = "async", env = "CAST_ASYNC", alias = "cast-async")] cast_async: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Estimate the gas cost of a transaction. - #[clap(visible_alias = "e")] + #[command(visible_alias = "e")] Estimate(EstimateArgs), /// Decode ABI-encoded input data. /// /// Similar to `abi-decode --input`, but function selector MUST be prefixed in `calldata` /// string - #[clap(visible_aliases = &["--calldata-decode","cdd"])] + #[command(visible_aliases = &["--calldata-decode","cdd"])] CalldataDecode { /// The function signature in the format `()()`. sig: String, @@ -472,7 +472,7 @@ pub enum CastSubcommand { /// Defaults to decoding output data. To decode input data pass --input. /// /// When passing `--input`, function selector must NOT be prefixed in `calldata` string - #[clap(name = "abi-decode", visible_aliases = &["ad", "--abi-decode"])] + #[command(name = "abi-decode", visible_aliases = &["ad", "--abi-decode"])] AbiDecode { /// The function signature in the format `()()`. sig: String, @@ -481,27 +481,27 @@ pub enum CastSubcommand { calldata: String, /// Whether to decode the input or output data. - #[clap(long, short, help_heading = "Decode input data instead of output data")] + #[arg(long, short, help_heading = "Decode input data instead of output data")] input: bool, }, /// ABI encode the given function argument, excluding the selector. - #[clap(visible_alias = "ae")] + #[command(visible_alias = "ae")] AbiEncode { /// The function signature. sig: String, /// Whether to use packed encoding. - #[clap(long)] + #[arg(long)] packed: bool, /// The arguments of the function. - #[clap(allow_hyphen_values = true)] + #[arg(allow_hyphen_values = true)] args: Vec, }, /// Compute the storage slot for an entry in a mapping. - #[clap(visible_alias = "in")] + #[command(visible_alias = "in")] Index { /// The mapping key type. key_type: String, @@ -514,58 +514,58 @@ pub enum CastSubcommand { }, /// Fetch the EIP-1967 implementation account - #[clap(visible_alias = "impl")] + #[command(visible_alias = "impl")] Implementation { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, /// The address to get the nonce for. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Fetch the EIP-1967 admin account - #[clap(visible_alias = "adm")] + #[command(visible_alias = "adm")] Admin { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, /// The address to get the nonce for. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the function signatures for the given selector from https://openchain.xyz. - #[clap(name = "4byte", visible_aliases = &["4", "4b"])] + #[command(name = "4byte", visible_aliases = &["4", "4b"])] FourByte { /// The function selector. selector: Option, }, /// Decode ABI-encoded calldata using https://openchain.xyz. - #[clap(name = "4byte-decode", visible_aliases = &["4d", "4bd"])] + #[command(name = "4byte-decode", visible_aliases = &["4d", "4bd"])] FourByteDecode { /// The ABI-encoded calldata. calldata: Option, }, /// Get the event signature for a given topic 0 from https://openchain.xyz. - #[clap(name = "4byte-event", visible_aliases = &["4e", "4be", "topic0-event", "t0e"])] + #[command(name = "4byte-event", visible_aliases = &["4e", "4be", "topic0-event", "t0e"])] FourByteEvent { /// Topic 0 - #[clap(value_name = "TOPIC_0")] + #[arg(value_name = "TOPIC_0")] topic: Option, }, @@ -576,7 +576,7 @@ pub enum CastSubcommand { /// - "function transfer(address,uint256)" /// - "function transfer(address,uint256)" "event Transfer(address,address,uint256)" /// - "./out/Contract.sol/Contract.json" - #[clap(visible_aliases = &["ups"])] + #[command(visible_aliases = &["ups"])] UploadSignature { /// The signatures to upload. /// @@ -588,228 +588,228 @@ pub enum CastSubcommand { /// Pretty print calldata. /// /// Tries to decode the calldata using https://openchain.xyz unless --offline is passed. - #[clap(visible_alias = "pc")] + #[command(visible_alias = "pc")] PrettyCalldata { /// The calldata. calldata: Option, /// Skip the https://openchain.xyz lookup. - #[clap(long, short)] + #[arg(long, short)] offline: bool, }, /// Get the timestamp of a block. - #[clap(visible_alias = "a")] + #[command(visible_alias = "a")] Age { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. block: Option, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the balance of an account in wei. - #[clap(visible_alias = "b")] + #[command(visible_alias = "b")] Balance { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, /// The account to query. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, /// Format the balance in ether. - #[clap(long, short)] + #[arg(long, short)] ether: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, /// erc20 address to query, with the method `balanceOf(address) return (uint256)`, alias /// with '--erc721' - #[clap(long, alias = "erc721")] + #[arg(long, alias = "erc721")] erc20: Option
, }, /// Get the basefee of a block. - #[clap(visible_aliases = &["ba", "fee", "basefee"])] + #[command(visible_aliases = &["ba", "fee", "basefee"])] BaseFee { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. block: Option, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the runtime bytecode of a contract. - #[clap(visible_alias = "co")] + #[command(visible_alias = "co")] Code { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, /// The contract address. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, /// Disassemble bytecodes into individual opcodes. - #[clap(long, short)] + #[arg(long, short)] disassemble: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the runtime bytecode size of a contract. - #[clap(visible_alias = "cs")] + #[command(visible_alias = "cs")] Codesize { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, /// The contract address. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the current gas price. - #[clap(visible_alias = "g")] + #[command(visible_alias = "g")] GasPrice { - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Generate event signatures from event string. - #[clap(visible_alias = "se")] + #[command(visible_alias = "se")] SigEvent { /// The event string. event_string: Option, }, /// Hash arbitrary data using Keccak-256. - #[clap(visible_alias = "k")] + #[command(visible_alias = "k")] Keccak { /// The data to hash. data: Option, }, /// Perform an ENS lookup. - #[clap(visible_alias = "rn")] + #[command(visible_alias = "rn")] ResolveName { /// The name to lookup. who: Option, /// Perform a reverse lookup to verify that the name is correct. - #[clap(long, short)] + #[arg(long, short)] verify: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Perform an ENS reverse lookup. - #[clap(visible_alias = "la")] + #[command(visible_alias = "la")] LookupAddress { /// The account to perform the lookup for. who: Option
, /// Perform a normal lookup to verify that the address is correct. - #[clap(long, short)] + #[arg(long, short)] verify: bool, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the raw value of a contract's storage slot. - #[clap(visible_alias = "st")] + #[command(visible_alias = "st")] Storage(StorageArgs), /// Generate a storage proof for a given storage slot. - #[clap(visible_alias = "pr")] + #[command(visible_alias = "pr")] Proof { /// The contract address. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] address: NameOrAddress, /// The storage slot numbers (hex or decimal). - #[clap(value_parser = parse_slot)] + #[arg(value_parser = parse_slot)] slots: Vec, /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the nonce for an account. - #[clap(visible_alias = "n")] + #[command(visible_alias = "n")] Nonce { /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. - #[clap(long, short = 'B')] + #[arg(long, short = 'B')] block: Option, /// The address to get the nonce for. - #[clap(value_parser = NameOrAddress::from_str)] + #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, - #[clap(flatten)] + #[command(flatten)] rpc: RpcOpts, }, /// Get the source code of a contract from Etherscan. - #[clap(visible_aliases = &["et", "src"])] + #[command(visible_aliases = &["et", "src"])] EtherscanSource { /// The contract's address. address: String, /// The output directory to expand source tree into. - #[clap(short, value_hint = ValueHint::DirPath)] + #[arg(short, value_hint = ValueHint::DirPath)] directory: Option, - #[clap(flatten)] + #[command(flatten)] etherscan: EtherscanOpts, }, /// Wallet management utilities. - #[clap(visible_alias = "w")] + #[command(visible_alias = "w")] Wallet { - #[clap(subcommand)] + #[command(subcommand)] command: WalletSubcommands, }, /// Generate a Solidity interface from a given ABI. /// /// Currently does not support ABI encoder v2. - #[clap(visible_alias = "i")] + #[command(visible_alias = "i")] Interface(InterfaceArgs), /// Generate a rust binding from a given ABI. - #[clap(visible_alias = "bi")] + #[command(visible_alias = "bi")] Bind(BindArgs), /// Get the selector for a function. - #[clap(visible_alias = "si")] + #[command(visible_alias = "si")] Sig { /// The function signature, e.g. transfer(address,uint256). sig: Option, @@ -819,64 +819,64 @@ pub enum CastSubcommand { }, /// Generate a deterministic contract address using CREATE2. - #[clap(visible_alias = "c2")] + #[command(visible_alias = "c2")] Create2(Create2Args), /// Get the block number closest to the provided timestamp. - #[clap(visible_alias = "f")] + #[command(visible_alias = "f")] FindBlock(FindBlockArgs), /// Generate shell completions script. - #[clap(visible_alias = "com")] + #[command(visible_alias = "com")] Completions { - #[clap(value_enum)] + #[arg(value_enum)] shell: clap_complete::Shell, }, /// Generate Fig autocompletion spec. - #[clap(visible_alias = "fig")] + #[command(visible_alias = "fig")] GenerateFigSpec, /// Runs a published transaction in a local environment and prints the trace. - #[clap(visible_alias = "r")] + #[command(visible_alias = "r")] Run(RunArgs), /// Perform a raw JSON-RPC request. - #[clap(visible_alias = "rp")] + #[command(visible_alias = "rp")] Rpc(RpcArgs), /// Formats a string into bytes32 encoding. - #[clap(name = "format-bytes32-string", visible_aliases = &["--format-bytes32-string"])] + #[command(name = "format-bytes32-string", visible_aliases = &["--format-bytes32-string"])] FormatBytes32String { /// The string to format. string: Option, }, /// Parses a string from bytes32 encoding. - #[clap(name = "parse-bytes32-string", visible_aliases = &["--parse-bytes32-string"])] + #[command(name = "parse-bytes32-string", visible_aliases = &["--parse-bytes32-string"])] ParseBytes32String { /// The string to parse. bytes: Option, }, - #[clap(name = "parse-bytes32-address", visible_aliases = &["--parse-bytes32-address"])] - #[clap(about = "Parses a checksummed address from bytes32 encoding.")] + #[command(name = "parse-bytes32-address", visible_aliases = &["--parse-bytes32-address"])] + #[command(about = "Parses a checksummed address from bytes32 encoding.")] ParseBytes32Address { - #[clap(value_name = "BYTES")] + #[arg(value_name = "BYTES")] bytes: Option, }, /// Decodes a raw signed EIP 2718 typed transaction - #[clap(visible_alias = "dt")] + #[command(visible_alias = "dt")] DecodeTransaction { tx: Option }, /// Extracts function selectors and arguments from bytecode - #[clap(visible_alias = "sel")] + #[command(visible_alias = "sel")] Selectors { /// The hex encoded bytecode. bytecode: String, /// Resolve the function signatures for the extracted selectors using https://openchain.xyz - #[clap(long, short)] + #[arg(long, short)] resolve: bool, }, } @@ -885,11 +885,11 @@ pub enum CastSubcommand { #[derive(Debug, Parser)] pub struct ToBaseArgs { /// The value to convert. - #[clap(allow_hyphen_values = true)] + #[arg(allow_hyphen_values = true)] pub value: Option, /// The input base. - #[clap(long, short = 'i')] + #[arg(long, short = 'i')] pub base_in: Option, } diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 9da885860b62f..43b6a1b21254c 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -41,7 +41,7 @@ const VERSION_MESSAGE: &str = concat!( /// Fast, utilitarian, and verbose Solidity REPL. #[derive(Debug, Parser)] -#[clap(name = "chisel", version = VERSION_MESSAGE)] +#[command(name = "chisel", version = VERSION_MESSAGE)] pub struct Chisel { #[command(subcommand)] pub cmd: Option, @@ -50,21 +50,21 @@ pub struct Chisel { /// /// These files will be evaluated before the top-level of the /// REPL, therefore functioning as a prelude - #[clap(long, help_heading = "REPL options")] + #[arg(long, help_heading = "REPL options")] pub prelude: Option, /// Disable the default `Vm` import. - #[clap(long, help_heading = "REPL options", long_help = format!( + #[arg(long, help_heading = "REPL options", long_help = format!( "Disable the default `Vm` import.\n\n\ The import is disabled by default if the Solc version is less than {}.", chisel::session_source::MIN_VM_VERSION ))] pub no_vm: bool, - #[clap(flatten)] + #[command(flatten)] pub opts: CoreBuildArgs, - #[clap(flatten)] + #[command(flatten)] pub evm_opts: EvmArgs, } diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index dd01710bd2f2d..9ed8f98b3330f 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -19,59 +19,59 @@ use serde::Serialize; use std::path::PathBuf; #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Build options")] +#[command(next_help_heading = "Build options")] pub struct CoreBuildArgs { /// Clear the cache and artifacts folder and recompile. - #[clap(long, help_heading = "Cache options")] + #[arg(long, help_heading = "Cache options")] #[serde(skip)] pub force: bool, /// Disable the cache. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub no_cache: bool, /// Set pre-linked libraries. - #[clap(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")] + #[arg(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")] #[serde(skip_serializing_if = "Vec::is_empty")] pub libraries: Vec, /// Ignore solc warnings by error code. - #[clap(long, help_heading = "Compiler options", value_name = "ERROR_CODES")] + #[arg(long, help_heading = "Compiler options", value_name = "ERROR_CODES")] #[serde(skip_serializing_if = "Vec::is_empty")] pub ignored_error_codes: Vec, /// Warnings will trigger a compiler error - #[clap(long, help_heading = "Compiler options")] + #[arg(long, help_heading = "Compiler options")] #[serde(skip)] pub deny_warnings: bool, /// Do not auto-detect the `solc` version. - #[clap(long, help_heading = "Compiler options")] + #[arg(long, help_heading = "Compiler options")] #[serde(skip)] pub no_auto_detect: bool, /// Specify the solc version, or a path to a local solc, to build with. /// /// Valid values are in the format `x.y.z`, `solc:x.y.z` or `path/to/solc`. - #[clap(long = "use", help_heading = "Compiler options", value_name = "SOLC_VERSION")] + #[arg(long = "use", help_heading = "Compiler options", value_name = "SOLC_VERSION")] #[serde(skip)] pub use_solc: Option, /// Do not access the network. /// /// Missing solc versions will not be installed. - #[clap(help_heading = "Compiler options", long)] + #[arg(help_heading = "Compiler options", long)] #[serde(skip)] pub offline: bool, /// Use the Yul intermediate representation compilation pipeline. - #[clap(long, help_heading = "Compiler options")] + #[arg(long, help_heading = "Compiler options")] #[serde(skip)] pub via_ir: bool, /// The path to the contract artifacts folder. - #[clap( + #[arg( long = "out", short, help_heading = "Project options", @@ -85,22 +85,22 @@ pub struct CoreBuildArgs { /// /// Possible values are "default", "strip" (remove), /// "debug" (Solidity-generated revert strings) and "verboseDebug" - #[clap(long, help_heading = "Project options", value_name = "REVERT")] + #[arg(long, help_heading = "Project options", value_name = "REVERT")] #[serde(skip)] pub revert_strings: Option, /// Don't print anything on startup. - #[clap(long, help_heading = "Compiler options")] + #[arg(long, help_heading = "Compiler options")] #[serde(skip)] pub silent: bool, /// Generate build info files. - #[clap(long, help_heading = "Project options")] + #[arg(long, help_heading = "Project options")] #[serde(skip)] pub build_info: bool, /// Output path to directory that build info files will be written to. - #[clap( + #[arg( long, help_heading = "Project options", value_hint = ValueHint::DirPath, @@ -110,11 +110,11 @@ pub struct CoreBuildArgs { #[serde(skip_serializing_if = "Option::is_none")] pub build_info_path: Option, - #[clap(flatten)] + #[command(flatten)] #[serde(flatten)] pub compiler: CompilerArgs, - #[clap(flatten)] + #[command(flatten)] #[serde(flatten)] pub project_paths: ProjectPathsArgs, } diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index 0b97ed2dfe89a..e752ae53fec68 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -13,25 +13,25 @@ pub use self::paths::ProjectPathsArgs; // // See also `BuildArgs`. #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Compiler options")] +#[command(next_help_heading = "Compiler options")] pub struct CompilerArgs { /// Includes the AST as JSON in the compiler output. - #[clap(long, help_heading = "Compiler options")] + #[arg(long, help_heading = "Compiler options")] #[serde(skip)] pub ast: bool, /// The target EVM version. - #[clap(long, value_name = "VERSION")] + #[arg(long, value_name = "VERSION")] #[serde(skip_serializing_if = "Option::is_none")] pub evm_version: Option, /// Activate the Solidity optimizer. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub optimize: bool, /// The number of optimizer runs. - #[clap(long, value_name = "RUNS")] + #[arg(long, value_name = "RUNS")] #[serde(skip_serializing_if = "Option::is_none")] pub optimizer_runs: Option, @@ -40,14 +40,14 @@ pub struct CompilerArgs { /// Example keys: evm.assembly, ewasm, ir, irOptimized, metadata /// /// For a full description, see https://docs.soliditylang.org/en/v0.8.13/using-the-compiler.html#input-description - #[clap(long, num_args(1..), value_name = "SELECTOR")] + #[arg(long, num_args(1..), value_name = "SELECTOR")] #[serde(skip_serializing_if = "Vec::is_empty")] pub extra_output: Vec, /// Extra output to write to separate files. /// /// Valid values: metadata, ir, irOptimized, ewasm, evm.assembly - #[clap(long, num_args(1..), value_name = "SELECTOR")] + #[arg(long, num_args(1..), value_name = "SELECTOR")] #[serde(skip_serializing_if = "Vec::is_empty")] pub extra_output_files: Vec, } diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index 29f505ee34cf2..692da4588e91c 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -15,50 +15,50 @@ use std::path::PathBuf; /// Common arguments for a project's paths. #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Project options")] +#[command(next_help_heading = "Project options")] pub struct ProjectPathsArgs { /// The project's root path. /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] #[serde(skip)] pub root: Option, /// The contracts source directory. - #[clap(long, short = 'C', value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, short = 'C', value_hint = ValueHint::DirPath, value_name = "PATH")] #[serde(rename = "src", skip_serializing_if = "Option::is_none")] pub contracts: Option, /// The project's remappings. - #[clap(long, short = 'R')] + #[arg(long, short = 'R')] #[serde(skip)] pub remappings: Vec, /// The project's remappings from the environment. - #[clap(long, value_name = "ENV")] + #[arg(long, value_name = "ENV")] #[serde(skip)] pub remappings_env: Option, /// The path to the compiler cache. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] #[serde(skip_serializing_if = "Option::is_none")] pub cache_path: Option, /// The path to the library folder. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] #[serde(rename = "libs", skip_serializing_if = "Vec::is_empty")] pub lib_paths: Vec, /// Use the Hardhat-style project layout. /// /// This is the same as using: `--contracts contracts --lib-paths node_modules`. - #[clap(long, conflicts_with = "contracts", visible_alias = "hh")] + #[arg(long, conflicts_with = "contracts", visible_alias = "hh")] #[serde(skip)] pub hardhat: bool, /// Path to the config file. - #[clap(long, value_hint = ValueHint::FilePath, value_name = "FILE")] + #[arg(long, value_hint = ValueHint::FilePath, value_name = "FILE")] #[serde(skip)] pub config_path: Option, } diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 62cebeaec73f9..272d3a5a2aede 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -18,13 +18,13 @@ const FLASHBOTS_URL: &str = "https://rpc.flashbots.net/fast"; #[derive(Clone, Debug, Default, Parser)] pub struct RpcOpts { /// The RPC endpoint. - #[clap(short = 'r', long = "rpc-url", env = "ETH_RPC_URL")] + #[arg(short = 'r', long = "rpc-url", env = "ETH_RPC_URL")] pub url: Option, /// Use the Flashbots RPC URL with fast mode (https://rpc.flashbots.net/fast). /// This shares the transaction privately with all registered builders. /// https://docs.flashbots.net/flashbots-protect/quick-start#faster-transactions - #[clap(long)] + #[arg(long)] pub flashbots: bool, /// JWT Secret for the RPC endpoint. @@ -36,7 +36,7 @@ pub struct RpcOpts { /// '["0x6bb38c26db65749ab6e472080a3d20a2f35776494e72016d1e339593f21c59bc", /// "0x6bb38c26db65749ab6e472080a3d20a2f35776494e72016d1e339593f21c59bc", /// "0x6bb38c26db65749ab6e472080a3d20a2f35776494e72016d1e339593f21c59bc"]' - #[clap(long, env = "ETH_RPC_JWT_SECRET")] + #[arg(long, env = "ETH_RPC_JWT_SECRET")] pub jwt_secret: Option, } @@ -89,12 +89,12 @@ impl RpcOpts { #[derive(Clone, Debug, Default, Serialize, Parser)] pub struct EtherscanOpts { /// The Etherscan (or equivalent) API key. - #[clap(short = 'e', long = "etherscan-api-key", alias = "api-key", env = "ETHERSCAN_API_KEY")] + #[arg(short = 'e', long = "etherscan-api-key", alias = "api-key", env = "ETHERSCAN_API_KEY")] #[serde(rename = "etherscan_api_key", skip_serializing_if = "Option::is_none")] pub key: Option, /// The chain name or EIP-155 chain ID. - #[clap( + #[arg( short, long, alias = "chain-id", @@ -141,15 +141,15 @@ impl EtherscanOpts { } #[derive(Clone, Debug, Default, Parser)] -#[clap(next_help_heading = "Ethereum options")] +#[command(next_help_heading = "Ethereum options")] pub struct EthereumOpts { - #[clap(flatten)] + #[command(flatten)] pub rpc: RpcOpts, - #[clap(flatten)] + #[command(flatten)] pub etherscan: EtherscanOpts, - #[clap(flatten)] + #[command(flatten)] pub wallet: WalletOpts, } diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index bda2fb02118a1..84173eaaf4b37 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -4,14 +4,14 @@ use clap::Parser; use serde::Serialize; #[derive(Clone, Debug, Serialize, Parser)] -#[clap(next_help_heading = "Transaction options")] +#[command(next_help_heading = "Transaction options")] pub struct TransactionOpts { /// Gas limit for the transaction. - #[clap(long, env = "ETH_GAS_LIMIT")] + #[arg(long, env = "ETH_GAS_LIMIT")] pub gas_limit: Option, /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions. - #[clap( + #[arg( long, env = "ETH_GAS_PRICE", value_parser = parse_ether_value, @@ -20,7 +20,7 @@ pub struct TransactionOpts { pub gas_price: Option, /// Max priority fee per gas for EIP1559 transactions. - #[clap( + #[arg( long, env = "ETH_PRIORITY_GAS_PRICE", value_parser = parse_ether_value, @@ -33,17 +33,17 @@ pub struct TransactionOpts { /// /// /// Examples: 1ether, 10gwei, 0.01ether - #[clap(long, value_parser = parse_ether_value)] + #[arg(long, value_parser = parse_ether_value)] pub value: Option, /// Nonce for the transaction. - #[clap(long)] + #[arg(long)] pub nonce: Option, /// Send a legacy transaction instead of an EIP1559 transaction. /// /// This is automatically enabled for common networks without EIP1559. - #[clap(long)] + #[arg(long)] pub legacy: bool, } diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 2230bd7608743..e23c1da339ecf 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -39,33 +39,33 @@ pub type Breakpoints = HashMap; /// # } /// ``` #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "EVM options", about = None, long_about = None)] // override doc +#[command(next_help_heading = "EVM options", about = None, long_about = None)] // override doc pub struct EvmArgs { /// Fetch state over a remote endpoint instead of starting from an empty state. /// /// If you want to fetch state from a specific block number, see --fork-block-number. - #[clap(long, short, visible_alias = "rpc-url", value_name = "URL")] + #[arg(long, short, visible_alias = "rpc-url", value_name = "URL")] #[serde(rename = "eth_rpc_url", skip_serializing_if = "Option::is_none")] pub fork_url: Option, /// Fetch state from a specific block number over a remote endpoint. /// /// See --fork-url. - #[clap(long, requires = "fork_url", value_name = "BLOCK")] + #[arg(long, requires = "fork_url", value_name = "BLOCK")] #[serde(skip_serializing_if = "Option::is_none")] pub fork_block_number: Option, /// Number of retries. /// /// See --fork-url. - #[clap(long, requires = "fork_url", value_name = "RETRIES")] + #[arg(long, requires = "fork_url", value_name = "RETRIES")] #[serde(skip_serializing_if = "Option::is_none")] pub fork_retries: Option, /// Initial retry backoff on encountering errors. /// /// See --fork-url. - #[clap(long, requires = "fork_url", value_name = "BACKOFF")] + #[arg(long, requires = "fork_url", value_name = "BACKOFF")] #[serde(skip_serializing_if = "Option::is_none")] pub fork_retry_backoff: Option, @@ -76,27 +76,27 @@ pub struct EvmArgs { /// This flag overrides the project's configuration file. /// /// See --fork-url. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub no_storage_caching: bool, /// The initial balance of deployed test contracts. - #[clap(long, value_name = "BALANCE")] + #[arg(long, value_name = "BALANCE")] #[serde(skip_serializing_if = "Option::is_none")] pub initial_balance: Option, /// The address which will be executing tests. - #[clap(long, value_name = "ADDRESS")] + #[arg(long, value_name = "ADDRESS")] #[serde(skip_serializing_if = "Option::is_none")] pub sender: Option
, /// Enable the FFI cheatcode. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub ffi: bool, /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub always_use_create_2_factory: bool, @@ -109,7 +109,7 @@ pub struct EvmArgs { /// - 3: Print execution traces for failing tests /// - 4: Print execution traces for all tests, and setup traces for failing tests /// - 5: Print execution and setup traces for all tests - #[clap(long, short, verbatim_doc_comment, action = ArgAction::Count)] + #[arg(long, short, verbatim_doc_comment, action = ArgAction::Count)] #[serde(skip)] pub verbosity: u8, @@ -118,7 +118,7 @@ pub struct EvmArgs { /// default value: 330 /// /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second - #[clap( + #[arg( long, requires = "fork_url", alias = "cups", @@ -130,7 +130,7 @@ pub struct EvmArgs { /// Disables rate limiting for this node's provider. /// /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second - #[clap( + #[arg( long, requires = "fork_url", value_name = "NO_RATE_LIMITS", @@ -141,14 +141,14 @@ pub struct EvmArgs { pub no_rpc_rate_limit: bool, /// All ethereum environment related arguments - #[clap(flatten)] + #[command(flatten)] #[serde(flatten)] pub env: EnvArgs, /// Whether to enable isolation of calls. /// In isolation mode all top-level calls are executed as a separate transaction in a separate /// EVM context, enabling more precise gas accounting and transaction state changes. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub isolate: bool, } @@ -202,66 +202,66 @@ impl Provider for EvmArgs { /// Configures the executor environment during tests. #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Executor environment config")] +#[command(next_help_heading = "Executor environment config")] pub struct EnvArgs { /// The block gas limit. - #[clap(long, value_name = "GAS_LIMIT")] + #[arg(long, value_name = "GAS_LIMIT")] #[serde(skip_serializing_if = "Option::is_none")] pub gas_limit: Option, /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. By /// default, it is 0x6000 (~25kb). - #[clap(long, value_name = "CODE_SIZE")] + #[arg(long, value_name = "CODE_SIZE")] #[serde(skip_serializing_if = "Option::is_none")] pub code_size_limit: Option, /// The chain name or EIP-155 chain ID. - #[clap(long, visible_alias = "chain-id", value_name = "CHAIN")] + #[arg(long, visible_alias = "chain-id", value_name = "CHAIN")] #[serde(rename = "chain_id", skip_serializing_if = "Option::is_none", serialize_with = "id")] pub chain: Option, /// The gas price. - #[clap(long, value_name = "GAS_PRICE")] + #[arg(long, value_name = "GAS_PRICE")] #[serde(skip_serializing_if = "Option::is_none")] pub gas_price: Option, /// The base fee in a block. - #[clap(long, visible_alias = "base-fee", value_name = "FEE")] + #[arg(long, visible_alias = "base-fee", value_name = "FEE")] #[serde(skip_serializing_if = "Option::is_none")] pub block_base_fee_per_gas: Option, /// The transaction origin. - #[clap(long, value_name = "ADDRESS")] + #[arg(long, value_name = "ADDRESS")] #[serde(skip_serializing_if = "Option::is_none")] pub tx_origin: Option
, /// The coinbase of the block. - #[clap(long, value_name = "ADDRESS")] + #[arg(long, value_name = "ADDRESS")] #[serde(skip_serializing_if = "Option::is_none")] pub block_coinbase: Option
, /// The timestamp of the block. - #[clap(long, value_name = "TIMESTAMP")] + #[arg(long, value_name = "TIMESTAMP")] #[serde(skip_serializing_if = "Option::is_none")] pub block_timestamp: Option, /// The block number. - #[clap(long, value_name = "BLOCK")] + #[arg(long, value_name = "BLOCK")] #[serde(skip_serializing_if = "Option::is_none")] pub block_number: Option, /// The block difficulty. - #[clap(long, value_name = "DIFFICULTY")] + #[arg(long, value_name = "DIFFICULTY")] #[serde(skip_serializing_if = "Option::is_none")] pub block_difficulty: Option, /// The block prevrandao value. NOTE: Before merge this field was mix_hash. - #[clap(long, value_name = "PREVRANDAO")] + #[arg(long, value_name = "PREVRANDAO")] #[serde(skip_serializing_if = "Option::is_none")] pub block_prevrandao: Option, /// The block gas limit. - #[clap(long, value_name = "GAS_LIMIT")] + #[arg(long, value_name = "GAS_LIMIT")] #[serde(skip_serializing_if = "Option::is_none")] pub block_gas_limit: Option, @@ -269,7 +269,7 @@ pub struct EnvArgs { /// If this limit is exceeded, a `MemoryLimitOOG` result is thrown. /// /// The default is 128MiB. - #[clap(long, value_name = "MEMORY_LIMIT")] + #[arg(long, value_name = "MEMORY_LIMIT")] #[serde(skip_serializing_if = "Option::is_none")] pub memory_limit: Option, } diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 93d188260dc8a..ca76aafa0eee7 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -18,7 +18,7 @@ const DEFAULT_CRATE_VERSION: &str = "0.1.0"; #[derive(Clone, Debug, Parser)] pub struct BindArgs { /// Path to where the contract artifacts are stored. - #[clap( + #[arg( long = "bindings-path", short, value_hint = ValueHint::DirPath, @@ -27,61 +27,61 @@ pub struct BindArgs { pub bindings: Option, /// Create bindings only for contracts whose names match the specified filter(s) - #[clap(long)] + #[arg(long)] pub select: Vec, /// Create bindings only for contracts whose names do not match the specified filter(s) - #[clap(long, conflicts_with = "select")] + #[arg(long, conflicts_with = "select")] pub skip: Vec, /// Explicitly generate bindings for all contracts /// /// By default all contracts ending with `Test` or `Script` are excluded. - #[clap(long, conflicts_with_all = &["select", "skip"])] + #[arg(long, conflicts_with_all = &["select", "skip"])] pub select_all: bool, /// The name of the Rust crate to generate. /// /// This should be a valid crates.io crate name, /// however, this is not currently validated by this command. - #[clap(long, default_value = DEFAULT_CRATE_NAME, value_name = "NAME")] + #[arg(long, default_value = DEFAULT_CRATE_NAME, value_name = "NAME")] crate_name: String, /// The version of the Rust crate to generate. /// /// This should be a standard semver version string, /// however, this is not currently validated by this command. - #[clap(long, default_value = DEFAULT_CRATE_VERSION, value_name = "VERSION")] + #[arg(long, default_value = DEFAULT_CRATE_VERSION, value_name = "VERSION")] crate_version: String, /// Generate the bindings as a module instead of a crate. - #[clap(long)] + #[arg(long)] module: bool, /// Overwrite existing generated bindings. /// /// By default, the command will check that the bindings are correct, and then exit. If /// --overwrite is passed, it will instead delete and overwrite the bindings. - #[clap(long)] + #[arg(long)] overwrite: bool, /// Generate bindings as a single file. - #[clap(long)] + #[arg(long)] single_file: bool, /// Skip Cargo.toml consistency checks. - #[clap(long)] + #[arg(long)] skip_cargo_toml: bool, /// Skips running forge build before generating binding - #[clap(long)] + #[arg(long)] skip_build: bool, /// Don't add any additional derives to generated bindings - #[clap(long)] + #[arg(long)] skip_extra_derives: bool, - #[clap(flatten)] + #[command(flatten)] build_args: CoreBuildArgs, } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index a24f84b6925db..66dae630e1b05 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -40,36 +40,36 @@ foundry_config::merge_impl_figment_convert!(BuildArgs, args); /// Some arguments are marked as `#[serde(skip)]` and require manual processing in /// `figment::Provider` implementation #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Build options", about = None, long_about = None)] // override doc +#[command(next_help_heading = "Build options", about = None, long_about = None)] // override doc pub struct BuildArgs { /// Print compiled contract names. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub names: bool, /// Print compiled contract sizes. - #[clap(long)] + #[arg(long)] #[serde(skip)] pub sizes: bool, /// Skip building files whose names contain the given filter. /// /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. - #[clap(long, num_args(1..))] + #[arg(long, num_args(1..))] #[serde(skip)] pub skip: Option>, - #[clap(flatten)] + #[command(flatten)] #[serde(flatten)] pub args: CoreBuildArgs, - #[clap(flatten)] + #[command(flatten)] #[serde(skip)] pub watch: WatchArgs, /// Output the compilation errors in the json format. /// This is useful when you want to use the output in other tools. - #[clap(long, conflicts_with = "silent")] + #[arg(long, conflicts_with = "silent")] #[serde(skip)] pub format_json: bool, } diff --git a/crates/forge/bin/cmd/cache.rs b/crates/forge/bin/cmd/cache.rs index 4ae2056c483fb..ff3117d345f1e 100644 --- a/crates/forge/bin/cmd/cache.rs +++ b/crates/forge/bin/cmd/cache.rs @@ -11,7 +11,7 @@ use strum::VariantNames; /// CLI arguments for `forge cache`. #[derive(Debug, Parser)] pub struct CacheArgs { - #[clap(subcommand)] + #[command(subcommand)] pub sub: CacheSubcommands, } @@ -26,12 +26,12 @@ pub enum CacheSubcommands { /// CLI arguments for `forge clean`. #[derive(Debug, Parser)] -#[clap(group = clap::ArgGroup::new("etherscan-blocks").multiple(false))] +#[command(group = clap::ArgGroup::new("etherscan-blocks").multiple(false))] pub struct CleanArgs { /// The chains to clean the cache for. /// /// Can also be "all" to clean all chains. - #[clap( + #[arg( env = "CHAIN", default_value = "all", value_parser = ChainOrAllValueParser::default(), @@ -39,18 +39,17 @@ pub struct CleanArgs { chains: Vec, /// The blocks to clean the cache for. - #[clap( + #[arg( short, long, num_args(1..), - use_value_delimiter(true), value_delimiter(','), group = "etherscan-blocks" )] blocks: Vec, /// Whether to clean the Etherscan cache. - #[clap(long, group = "etherscan-blocks")] + #[arg(long, group = "etherscan-blocks")] etherscan: bool, } @@ -82,7 +81,7 @@ pub struct LsArgs { /// The chains to list the cache for. /// /// Can also be "all" to list all chains. - #[clap( + #[arg( env = "CHAIN", default_value = "all", value_parser = ChainOrAllValueParser::default(), diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index 0758ddf5028bc..fc325e39d99c9 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -11,22 +11,22 @@ foundry_config::impl_figment_convert!(ConfigArgs, opts, evm_opts); #[derive(Clone, Debug, Parser)] pub struct ConfigArgs { /// Print only a basic set of the currently set config values. - #[clap(long)] + #[arg(long)] basic: bool, /// Print currently set config values as JSON. - #[clap(long)] + #[arg(long)] json: bool, /// Attempt to fix any configuration warnings. - #[clap(long)] + #[arg(long)] fix: bool, // support nested build arguments - #[clap(flatten)] + #[command(flatten)] opts: BuildArgs, - #[clap(flatten)] + #[command(flatten)] evm_opts: EvmArgs, } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 3505fc3182471..0c1232d7a8faf 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -42,20 +42,20 @@ pub struct CoverageArgs { /// The report type to use for coverage. /// /// This flag can be used multiple times. - #[clap(long, value_enum, default_value = "summary")] + #[arg(long, value_enum, default_value = "summary")] report: Vec, /// Enable viaIR with minimum optimization /// /// This can fix most of the "stack too deep" errors while resulting a /// relatively accurate source map. - #[clap(long)] + #[arg(long)] ir_minimum: bool, /// The path to output the report. /// /// If not specified, the report will be stored in the root of the project. - #[clap( + #[arg( long, short, value_hint = ValueHint::FilePath, @@ -63,13 +63,13 @@ pub struct CoverageArgs { )] report_file: Option, - #[clap(flatten)] + #[command(flatten)] filter: FilterArgs, - #[clap(flatten)] + #[command(flatten)] evm_opts: EvmArgs, - #[clap(flatten)] + #[command(flatten)] opts: CoreBuildArgs, } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 8c4752603bdcd..1944281910538 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -35,7 +35,7 @@ pub struct CreateArgs { contract: ContractInfo, /// The constructor arguments. - #[clap( + #[arg( long, num_args(1..), conflicts_with = "constructor_args_path", @@ -44,7 +44,7 @@ pub struct CreateArgs { constructor_args: Vec, /// The path to a file containing the constructor arguments. - #[clap( + #[arg( long, value_hint = ValueHint::FilePath, value_name = "PATH", @@ -52,37 +52,37 @@ pub struct CreateArgs { constructor_args_path: Option, /// Print the deployment information as JSON. - #[clap(long, help_heading = "Display options")] + #[arg(long, help_heading = "Display options")] json: bool, /// Verify contract after creation. - #[clap(long)] + #[arg(long)] verify: bool, /// Send via `eth_sendTransaction` using the `--from` argument or `$ETH_FROM` as sender - #[clap(long, requires = "from")] + #[arg(long, requires = "from")] unlocked: bool, /// Prints the standard json compiler input if `--verify` is provided. /// /// The standard json compiler input can be used to manually submit contract verification in /// the browser. - #[clap(long, requires = "verify")] + #[arg(long, requires = "verify")] show_standard_json_input: bool, - #[clap(flatten)] + #[command(flatten)] opts: CoreBuildArgs, - #[clap(flatten)] + #[command(flatten)] tx: TransactionOpts, - #[clap(flatten)] + #[command(flatten)] eth: EthereumOpts, - #[clap(flatten)] + #[command(flatten)] pub verifier: verify::VerifierArgs, - #[clap(flatten)] + #[command(flatten)] retry: RetryArgs, } diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs index a69c2da3ca9eb..dafbf965a6a94 100644 --- a/crates/forge/bin/cmd/debug.rs +++ b/crates/forge/bin/cmd/debug.rs @@ -14,28 +14,28 @@ pub struct DebugArgs { /// /// If multiple contracts exist in the same file you must specify the target contract with /// --target-contract. - #[clap(value_hint = ValueHint::FilePath)] + #[arg(value_hint = ValueHint::FilePath)] pub path: PathBuf, /// Arguments to pass to the script function. pub args: Vec, /// The name of the contract you want to run. - #[clap(long, visible_alias = "tc", value_name = "CONTRACT_NAME")] + #[arg(long, visible_alias = "tc", value_name = "CONTRACT_NAME")] pub target_contract: Option, /// The signature of the function you want to call in the contract, or raw calldata. - #[clap(long, short, default_value = "run()", value_name = "SIGNATURE")] + #[arg(long, short, default_value = "run()", value_name = "SIGNATURE")] pub sig: String, /// Open the script in the debugger. - #[clap(long)] + #[arg(long)] pub debug: bool, - #[clap(flatten)] + #[command(flatten)] pub opts: CoreBuildArgs, - #[clap(flatten)] + #[command(flatten)] pub evm_opts: EvmArgs, } diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index c3ef50aa2fda1..d594a0e566f6e 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -16,13 +16,13 @@ pub struct DocArgs { /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] pub root: Option, /// The doc's output path. /// /// By default, it is the `docs/` in project root. - #[clap( + #[arg( long, short, value_hint = ValueHint::DirPath, @@ -31,32 +31,32 @@ pub struct DocArgs { out: Option, /// Build the `mdbook` from generated files. - #[clap(long, short)] + #[arg(long, short)] build: bool, /// Serve the documentation. - #[clap(long, short)] + #[arg(long, short)] serve: bool, /// Open the documentation in a browser after serving. - #[clap(long, requires = "serve")] + #[arg(long, requires = "serve")] open: bool, /// Hostname for serving documentation. - #[clap(long, requires = "serve")] + #[arg(long, requires = "serve")] hostname: Option, /// Port for serving documentation. - #[clap(long, short, requires = "serve")] + #[arg(long, short, requires = "serve")] port: Option, /// The relative path to the `hardhat-deploy` or `forge-deploy` artifact directory. Leave blank /// for default. - #[clap(long)] + #[arg(long)] deployments: Option>, /// Whether to create docs for external libraries. - #[clap(long, short)] + #[arg(long, short)] include_libraries: bool, } diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index b4c1edcd9c5ee..c61369320c830 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -12,13 +12,13 @@ use std::path::PathBuf; #[derive(Clone, Debug, Parser)] pub struct FlattenArgs { /// The path to the contract to flatten. - #[clap(value_hint = ValueHint::FilePath, value_name = "PATH")] + #[arg(value_hint = ValueHint::FilePath, value_name = "PATH")] pub target_path: PathBuf, /// The path to output the flattened contract. /// /// If not specified, the flattened contract will be output to stdout. - #[clap( + #[arg( long, short, value_hint = ValueHint::FilePath, @@ -26,7 +26,7 @@ pub struct FlattenArgs { )] pub output: Option, - #[clap(flatten)] + #[command(flatten)] project_paths: ProjectPathsArgs, } diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index a4787ed7ddc30..36c0800008f19 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -18,25 +18,25 @@ use yansi::Color; #[derive(Clone, Debug, Parser)] pub struct FmtArgs { /// Path to the file, directory or '-' to read from stdin. - #[clap(value_hint = ValueHint::FilePath, value_name = "PATH", num_args(1..))] + #[arg(value_hint = ValueHint::FilePath, value_name = "PATH", num_args(1..))] paths: Vec, /// The project's root path. /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] root: Option, /// Run in 'check' mode. /// /// Exits with 0 if input is formatted correctly. /// Exits with 1 if formatting is required. - #[clap(long)] + #[arg(long)] check: bool, /// In 'check' and stdin modes, outputs raw formatted code instead of the diff. - #[clap(long, short)] + #[arg(long, short)] raw: bool, } diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 79d8e25b2eb47..8e3bc6fc56609 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -19,7 +19,7 @@ mod visitor; #[derive(Clone, Debug, Parser)] pub struct GeigerArgs { /// Paths to files or directories to detect. - #[clap( + #[arg( conflicts_with = "root", value_hint = ValueHint::FilePath, value_name = "PATH", @@ -31,17 +31,17 @@ pub struct GeigerArgs { /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] root: Option, /// Run in "check" mode. /// /// The exit code of the program will be the number of unsafe cheatcodes found. - #[clap(long)] + #[arg(long)] pub check: bool, /// Globs to ignore. - #[clap( + #[arg( long, value_hint = ValueHint::FilePath, value_name = "PATH", @@ -50,7 +50,7 @@ pub struct GeigerArgs { ignore: Vec, /// Print a report of all files, even if no unsafe functions are found. - #[clap(long)] + #[arg(long)] full: bool, } diff --git a/crates/forge/bin/cmd/generate/mod.rs b/crates/forge/bin/cmd/generate/mod.rs index 9e25d6532a808..190ea52b7752b 100644 --- a/crates/forge/bin/cmd/generate/mod.rs +++ b/crates/forge/bin/cmd/generate/mod.rs @@ -7,7 +7,7 @@ use yansi::Paint; /// CLI arguments for `forge generate`. #[derive(Debug, Parser)] pub struct GenerateArgs { - #[clap(subcommand)] + #[command(subcommand)] pub sub: GenerateSubcommands, } @@ -20,7 +20,7 @@ pub enum GenerateSubcommands { #[derive(Debug, Parser)] pub struct GenerateTestArgs { /// Contract name for test generation. - #[clap(long, short, value_name = "CONTRACT_NAME")] + #[arg(long, short, value_name = "CONTRACT_NAME")] pub contract_name: String, } diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 9dc1eea1ba831..9c8c3fc90c11d 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -12,32 +12,32 @@ use yansi::Paint; #[derive(Clone, Debug, Parser)] pub struct InitArgs { /// The root directory of the new project. - #[clap(value_hint = ValueHint::DirPath, default_value = ".", value_name = "PATH")] + #[arg(value_hint = ValueHint::DirPath, default_value = ".", value_name = "PATH")] root: PathBuf, /// The template to start from. - #[clap(long, short)] + #[arg(long, short)] template: Option, /// Branch argument that can only be used with template option. /// If not specified, the default branch is used. - #[clap(long, short, requires = "template")] + #[arg(long, short, requires = "template")] branch: Option, /// Do not install dependencies from the network. - #[clap(long, conflicts_with = "template", visible_alias = "no-deps")] + #[arg(long, conflicts_with = "template", visible_alias = "no-deps")] offline: bool, /// Create the project even if the specified root directory is not empty. - #[clap(long, conflicts_with = "template")] + #[arg(long, conflicts_with = "template")] force: bool, /// Create a .vscode/settings.json file with Solidity settings, and generate a remappings.txt /// file. - #[clap(long, conflicts_with = "template")] + #[arg(long, conflicts_with = "template")] vscode: bool, - #[clap(flatten)] + #[command(flatten)] opts: DependencyInstallOpts, } diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index e85fc37b09721..b76ca2878da60 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -23,15 +23,15 @@ pub struct InspectArgs { pub contract: ContractInfo, /// The contract artifact field to inspect. - #[clap(value_enum)] + #[arg(value_enum)] pub field: ContractArtifactField, /// Pretty print the selected field, if supported. - #[clap(long)] + #[arg(long)] pub pretty: bool, /// All build arguments are supported - #[clap(flatten)] + #[command(flatten)] build: CoreBuildArgs, } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index b7690d45845c1..75fdbe3aa2ea0 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -22,7 +22,7 @@ static DEPENDENCY_VERSION_TAG_REGEX: Lazy = /// CLI arguments for `forge install`. #[derive(Clone, Debug, Parser)] -#[clap(override_usage = "forge install [OPTIONS] [DEPENDENCIES]... +#[command(override_usage = "forge install [OPTIONS] [DEPENDENCIES]... forge install [OPTIONS] /@... forge install [OPTIONS] =/@... forge install [OPTIONS] ...")] @@ -46,10 +46,10 @@ pub struct InstallArgs { /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] pub root: Option, - #[clap(flatten)] + #[command(flatten)] opts: DependencyInstallOpts, } @@ -67,19 +67,19 @@ pub struct DependencyInstallOpts { /// Perform shallow clones instead of deep ones. /// /// Improves performance and reduces disk usage, but prevents switching branches or tags. - #[clap(long)] + #[arg(long)] pub shallow: bool, /// Install without adding the dependency as a submodule. - #[clap(long)] + #[arg(long)] pub no_git: bool, /// Do not create a commit. - #[clap(long)] + #[arg(long)] pub no_commit: bool, /// Do not print any messages. - #[clap(short, long)] + #[arg(short, long)] pub quiet: bool, } diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index 97d1887736503..92c80e219fb39 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -23,9 +23,9 @@ //! // A new clap subcommand that accepts both `EvmArgs` and `BuildArgs` //! #[derive(Clone, Debug, Parser)] //! pub struct MyArgs { -//! #[clap(flatten)] +//! #[command(flatten)] //! evm_opts: EvmArgs, -//! #[clap(flatten)] +//! #[command(flatten)] //! opts: BuildArgs, //! } //! diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index 2a0379af2f0e3..6728f0ae1aff7 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -12,10 +12,10 @@ pub struct RemappingArgs { /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] root: Option, /// Pretty-print the remappings, grouping each of them by context. - #[clap(long)] + #[arg(long)] pretty: bool, } impl_figment_convert_basic!(RemappingArgs); diff --git a/crates/forge/bin/cmd/remove.rs b/crates/forge/bin/cmd/remove.rs index 0b77515c86ff2..22343ef7d69d1 100644 --- a/crates/forge/bin/cmd/remove.rs +++ b/crates/forge/bin/cmd/remove.rs @@ -17,11 +17,11 @@ pub struct RemoveArgs { /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] root: Option, /// Override the up-to-date check. - #[clap(short, long)] + #[arg(short, long)] force: bool, } impl_figment_convert_basic!(RemoveArgs); diff --git a/crates/forge/bin/cmd/retry.rs b/crates/forge/bin/cmd/retry.rs index 45305288e89b5..8ffc61b88dc57 100644 --- a/crates/forge/bin/cmd/retry.rs +++ b/crates/forge/bin/cmd/retry.rs @@ -10,10 +10,10 @@ pub const RETRY_VERIFY_ON_CREATE: RetryArgs = RetryArgs { retries: 15, delay: 5 /// Retry arguments for contract verification. #[derive(Clone, Copy, Debug, Parser)] -#[clap(about = "Allows to use retry arguments for contract verification")] // override doc +#[command(about = "Allows to use retry arguments for contract verification")] // override doc pub struct RetryArgs { /// Number of attempts for retrying verification. - #[clap( + #[arg( long, value_parser = RangedU64ValueParser::::new().range(1..), default_value = "5", @@ -21,7 +21,7 @@ pub struct RetryArgs { pub retries: u32, /// Optional delay to apply inbetween verification attempts, in seconds. - #[clap( + #[arg( long, value_parser = RangedU64ValueParser::::new().range(0..=30), default_value = "5", diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 5df893bb0ed5b..8fe66f8396964 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -72,22 +72,22 @@ pub struct ScriptArgs { /// /// If multiple contracts exist in the same file you must specify the target contract with /// --target-contract. - #[clap(value_hint = ValueHint::FilePath)] + #[arg(value_hint = ValueHint::FilePath)] pub path: String, /// Arguments to pass to the script function. pub args: Vec, /// The name of the contract you want to run. - #[clap(long, visible_alias = "tc", value_name = "CONTRACT_NAME")] + #[arg(long, visible_alias = "tc", value_name = "CONTRACT_NAME")] pub target_contract: Option, /// The signature of the function you want to call in the contract, or raw calldata. - #[clap(long, short, default_value = "run()")] + #[arg(long, short, default_value = "run()")] pub sig: String, /// Max priority fee per gas for EIP1559 transactions. - #[clap( + #[arg( long, env = "ETH_PRIORITY_GAS_PRICE", value_parser = foundry_cli::utils::parse_ether_value, @@ -98,23 +98,23 @@ pub struct ScriptArgs { /// Use legacy transactions instead of EIP1559 ones. /// /// This is auto-enabled for common networks without EIP1559. - #[clap(long)] + #[arg(long)] pub legacy: bool, /// Broadcasts the transactions. - #[clap(long)] + #[arg(long)] pub broadcast: bool, /// Skips on-chain simulation. - #[clap(long)] + #[arg(long)] pub skip_simulation: bool, /// Relative percentage to multiply gas estimates by. - #[clap(long, short, default_value = "130")] + #[arg(long, short, default_value = "130")] pub gas_estimate_multiplier: u64, /// Send via `eth_sendTransaction` using the `--from` argument or `$ETH_FROM` as sender - #[clap( + #[arg( long, requires = "sender", conflicts_with_all = &["private_key", "private_keys", "froms", "ledger", "trezor", "aws"], @@ -127,44 +127,44 @@ pub struct ScriptArgs { /// /// Example: If transaction N has a nonce of 22, then the account should have a nonce of 22, /// otherwise it fails. - #[clap(long)] + #[arg(long)] pub resume: bool, /// If present, --resume or --verify will be assumed to be a multi chain deployment. - #[clap(long)] + #[arg(long)] pub multi: bool, /// Open the script in the debugger. /// /// Takes precedence over broadcast. - #[clap(long)] + #[arg(long)] pub debug: bool, /// Makes sure a transaction is sent, /// only after its previous one has been confirmed and succeeded. - #[clap(long)] + #[arg(long)] pub slow: bool, /// Disables interactive prompts that might appear when deploying big contracts. /// /// For more info on the contract size limit, see EIP-170: - #[clap(long)] + #[arg(long)] pub non_interactive: bool, /// The Etherscan (or equivalent) API key - #[clap(long, env = "ETHERSCAN_API_KEY", value_name = "KEY")] + #[arg(long, env = "ETHERSCAN_API_KEY", value_name = "KEY")] pub etherscan_api_key: Option, /// Verifies all the contracts found in the receipts of a script, if any. - #[clap(long)] + #[arg(long)] pub verify: bool, /// Output results in JSON format. - #[clap(long)] + #[arg(long)] pub json: bool, /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions. - #[clap( + #[arg( long, env = "ETH_GAS_PRICE", value_parser = foundry_cli::utils::parse_ether_value, @@ -172,19 +172,19 @@ pub struct ScriptArgs { )] pub with_gas_price: Option, - #[clap(flatten)] + #[command(flatten)] pub opts: BuildArgs, - #[clap(flatten)] + #[command(flatten)] pub wallets: MultiWalletOpts, - #[clap(flatten)] + #[command(flatten)] pub evm_opts: EvmArgs, - #[clap(flatten)] + #[command(flatten)] pub verifier: super::verify::VerifierArgs, - #[clap(flatten)] + #[command(flatten)] pub retry: RetryArgs, } diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 7318fa04fc2ec..1ee251082b376 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -16,7 +16,7 @@ use std::fs::canonicalize; #[derive(Clone, Debug, Parser)] pub enum SelectorsSubcommands { /// Check for selector collisions between contracts - #[clap(visible_alias = "co")] + #[command(visible_alias = "co")] Collision { /// The first of the two contracts for which to look selector collisions for, in the form /// `(:)?`. @@ -26,33 +26,33 @@ pub enum SelectorsSubcommands { /// `(:)?`. second_contract: ContractInfo, - #[clap(flatten)] + #[command(flatten)] build: Box, }, /// Upload selectors to registry - #[clap(visible_alias = "up")] + #[command(visible_alias = "up")] Upload { /// The name of the contract to upload selectors for. - #[clap(required_unless_present = "all")] + #[arg(required_unless_present = "all")] contract: Option, /// Upload selectors for all contracts in the project. - #[clap(long, required_unless_present = "contract")] + #[arg(long, required_unless_present = "contract")] all: bool, - #[clap(flatten)] + #[command(flatten)] project_paths: ProjectPathsArgs, }, /// List selectors from current workspace - #[clap(visible_alias = "ls")] + #[command(visible_alias = "ls")] List { /// The name of the contract to list selectors for. - #[clap(help = "The name of the contract to list selectors for.")] + #[arg(help = "The name of the contract to list selectors for.")] contract: Option, - #[clap(flatten)] + #[command(flatten)] project_paths: ProjectPathsArgs, }, } diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index f60ab01bb01d3..d7147f49b6c14 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -29,7 +29,7 @@ pub struct SnapshotArgs { /// Output a diff against a pre-existing snapshot. /// /// By default, the comparison is done with .gas-snapshot. - #[clap( + #[arg( conflicts_with = "snap", long, value_hint = ValueHint::FilePath, @@ -42,7 +42,7 @@ pub struct SnapshotArgs { /// Outputs a diff if the snapshots do not match. /// /// By default, the comparison is done with .gas-snapshot. - #[clap( + #[arg( conflicts_with = "diff", long, value_hint = ValueHint::FilePath, @@ -52,11 +52,11 @@ pub struct SnapshotArgs { // Hidden because there is only one option /// How to format the output. - #[clap(long, hide(true))] + #[arg(long, hide(true))] format: Option, /// Output file for the snapshot. - #[clap( + #[arg( long, default_value = ".gas-snapshot", value_hint = ValueHint::FilePath, @@ -65,7 +65,7 @@ pub struct SnapshotArgs { snap: PathBuf, /// Tolerates gas deviations up to the specified percentage. - #[clap( + #[arg( long, value_parser = RangedU64ValueParser::::new().range(0..100), value_name = "SNAPSHOT_THRESHOLD" @@ -73,11 +73,11 @@ pub struct SnapshotArgs { tolerance: Option, /// All test arguments are supported - #[clap(flatten)] + #[command(flatten)] pub(crate) test: test::TestArgs, /// Additional configs for test results - #[clap(flatten)] + #[command(flatten)] config: SnapshotConfig, } @@ -141,19 +141,19 @@ impl FromStr for Format { #[derive(Clone, Debug, Default, Parser)] struct SnapshotConfig { /// Sort results by gas used (ascending). - #[clap(long)] + #[arg(long)] asc: bool, /// Sort results by gas used (descending). - #[clap(conflicts_with = "asc", long)] + #[arg(conflicts_with = "asc", long)] desc: bool, /// Only include tests that used more gas that the given amount. - #[clap(long, value_name = "MIN_GAS")] + #[arg(long, value_name = "MIN_GAS")] min: Option, /// Only include tests that used less gas that the given amount. - #[clap(long, value_name = "MAX_GAS")] + #[arg(long, value_name = "MAX_GAS")] max: Option, } diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index 81497ca14fe14..65d3d0ed508d6 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -10,31 +10,31 @@ use std::{fmt, path::Path}; /// /// See also `FileFilter`. #[derive(Clone, Parser)] -#[clap(next_help_heading = "Test filtering")] +#[command(next_help_heading = "Test filtering")] pub struct FilterArgs { /// Only run test functions matching the specified regex pattern. - #[clap(long = "match-test", visible_alias = "mt", value_name = "REGEX")] + #[arg(long = "match-test", visible_alias = "mt", value_name = "REGEX")] pub test_pattern: Option, /// Only run test functions that do not match the specified regex pattern. - #[clap(long = "no-match-test", visible_alias = "nmt", value_name = "REGEX")] + #[arg(long = "no-match-test", visible_alias = "nmt", value_name = "REGEX")] pub test_pattern_inverse: Option, /// Only run tests in contracts matching the specified regex pattern. - #[clap(long = "match-contract", visible_alias = "mc", value_name = "REGEX")] + #[arg(long = "match-contract", visible_alias = "mc", value_name = "REGEX")] pub contract_pattern: Option, /// Only run tests in contracts that do not match the specified regex pattern. - #[clap(long = "no-match-contract", visible_alias = "nmc", value_name = "REGEX")] + #[arg(long = "no-match-contract", visible_alias = "nmc", value_name = "REGEX")] pub contract_pattern_inverse: Option, /// Only run tests in source files matching the specified glob pattern. - #[clap(long = "match-path", visible_alias = "mp", value_name = "GLOB")] + #[arg(long = "match-path", visible_alias = "mp", value_name = "GLOB")] pub path_pattern: Option, /// Only run tests in source files that do not match the specified glob pattern. - #[clap( - name = "no-match-path", + #[arg( + id = "no-match-path", long = "no-match-path", visible_alias = "nmp", value_name = "GLOB" diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index b9ca859b8e5a5..b81a5b362edce 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -48,7 +48,7 @@ foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); /// CLI arguments for `forge test`. #[derive(Clone, Debug, Parser)] -#[clap(next_help_heading = "Test options")] +#[command(next_help_heading = "Test options")] pub struct TestArgs { /// Run a test in the debugger. /// @@ -65,58 +65,58 @@ pub struct TestArgs { /// If the fuzz test does not fail, it will open the debugger on the last fuzz case. /// /// For more fine-grained control of which fuzz case is run, see forge run. - #[clap(long, value_name = "TEST_FUNCTION")] + #[arg(long, value_name = "TEST_FUNCTION")] debug: Option, /// Print a gas report. - #[clap(long, env = "FORGE_GAS_REPORT")] + #[arg(long, env = "FORGE_GAS_REPORT")] gas_report: bool, /// Exit with code 0 even if a test fails. - #[clap(long, env = "FORGE_ALLOW_FAILURE")] + #[arg(long, env = "FORGE_ALLOW_FAILURE")] allow_failure: bool, /// Output test results in JSON format. - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] json: bool, /// Stop running tests after the first failure. - #[clap(long)] + #[arg(long)] pub fail_fast: bool, /// The Etherscan (or equivalent) API key. - #[clap(long, env = "ETHERSCAN_API_KEY", value_name = "KEY")] + #[arg(long, env = "ETHERSCAN_API_KEY", value_name = "KEY")] etherscan_api_key: Option, /// List tests instead of running them. - #[clap(long, short, help_heading = "Display options")] + #[arg(long, short, help_heading = "Display options")] list: bool, /// Set seed used to generate randomness during your fuzz runs. - #[clap(long)] + #[arg(long)] pub fuzz_seed: Option, - #[clap(long, env = "FOUNDRY_FUZZ_RUNS", value_name = "RUNS")] + #[arg(long, env = "FOUNDRY_FUZZ_RUNS", value_name = "RUNS")] pub fuzz_runs: Option, - #[clap(flatten)] + #[command(flatten)] filter: FilterArgs, - #[clap(flatten)] + #[command(flatten)] evm_opts: EvmArgs, - #[clap(flatten)] + #[command(flatten)] opts: CoreBuildArgs, - #[clap(flatten)] + #[command(flatten)] pub watch: WatchArgs, /// Print test summary table. - #[clap(long, help_heading = "Display options")] + #[arg(long, help_heading = "Display options")] pub summary: bool, /// Print detailed test summary table. - #[clap(long, help_heading = "Display options", requires = "summary")] + #[arg(long, help_heading = "Display options", requires = "summary")] pub detailed: bool, } diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index 689d6e4442bdb..8133010253894 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -10,16 +10,16 @@ use foundry_compilers::{ #[derive(Clone, Debug, Parser)] pub struct TreeArgs { /// Do not de-duplicate (repeats all shared dependencies) - #[clap(long)] + #[arg(long)] no_dedupe: bool, /// Character set to use in output. /// /// [possible values: utf8, ascii] - #[clap(long, default_value = "utf8")] + #[arg(long, default_value = "utf8")] charset: Charset, - #[clap(flatten)] + #[command(flatten)] opts: ProjectPathsArgs, } diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index 37e5baccb6622..0cc25b6b6edc5 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -17,15 +17,15 @@ pub struct UpdateArgs { /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] root: Option, /// Override the up-to-date check. - #[clap(short, long)] + #[arg(short, long)] force: bool, /// Recursively update submodules. - #[clap(short, long)] + #[arg(short, long)] recursive: bool, } impl_figment_convert_basic!(UpdateArgs); diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index c598006d9cd6d..f9839d7175bb4 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -21,11 +21,11 @@ mod sourcify; #[derive(Clone, Debug, Parser)] pub struct VerifierArgs { /// The contract verification provider to use. - #[clap(long, help_heading = "Verifier options", default_value = "etherscan", value_enum)] + #[arg(long, help_heading = "Verifier options", default_value = "etherscan", value_enum)] pub verifier: VerificationProviderType, /// The verifier URL, if using a custom provider - #[clap(long, help_heading = "Verifier options", env = "VERIFIER_URL")] + #[arg(long, help_heading = "Verifier options", env = "VERIFIER_URL")] pub verifier_url: Option, } @@ -45,7 +45,7 @@ pub struct VerifyArgs { pub contract: ContractInfo, /// The ABI-encoded constructor arguments. - #[clap( + #[arg( long, conflicts_with = "constructor_args_path", value_name = "ARGS", @@ -54,68 +54,68 @@ pub struct VerifyArgs { pub constructor_args: Option, /// The path to a file containing the constructor arguments. - #[clap(long, value_hint = ValueHint::FilePath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::FilePath, value_name = "PATH")] pub constructor_args_path: Option, /// The `solc` version to use to build the smart contract. - #[clap(long, value_name = "VERSION")] + #[arg(long, value_name = "VERSION")] pub compiler_version: Option, /// The number of optimization runs used to build the smart contract. - #[clap(long, visible_alias = "optimizer-runs", value_name = "NUM")] + #[arg(long, visible_alias = "optimizer-runs", value_name = "NUM")] pub num_of_optimizations: Option, /// Flatten the source code before verifying. - #[clap(long)] + #[arg(long)] pub flatten: bool, /// Do not compile the flattened smart contract before verifying (if --flatten is passed). - #[clap(short, long)] + #[arg(short, long)] pub force: bool, /// Do not check if the contract is already verified before verifying. - #[clap(long)] + #[arg(long)] pub skip_is_verified_check: bool, /// Wait for verification result after submission. - #[clap(long)] + #[arg(long)] pub watch: bool, /// Set pre-linked libraries. - #[clap(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")] + #[arg(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")] pub libraries: Vec, /// The project's root path. /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] pub root: Option, /// Prints the standard json compiler input. /// /// The standard json compiler input can be used to manually submit contract verification in /// the browser. - #[clap(long, conflicts_with = "flatten")] + #[arg(long, conflicts_with = "flatten")] pub show_standard_json_input: bool, /// Use the Yul intermediate representation compilation pipeline. - #[clap(long)] + #[arg(long)] pub via_ir: bool, /// The EVM version to use. /// /// Overrides the version specified in the config. - #[clap(long)] + #[arg(long)] pub evm_version: Option, - #[clap(flatten)] + #[command(flatten)] pub etherscan: EtherscanOpts, - #[clap(flatten)] + #[command(flatten)] pub retry: RetryArgs, - #[clap(flatten)] + #[command(flatten)] pub verifier: VerifierArgs, } @@ -205,13 +205,13 @@ pub struct VerifyCheckArgs { /// For Sourcify - Contract Address. id: String, - #[clap(flatten)] + #[command(flatten)] retry: RetryArgs, - #[clap(flatten)] + #[command(flatten)] etherscan: EtherscanOpts, - #[clap(flatten)] + #[command(flatten)] verifier: VerifierArgs, } diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index f2ca664be30ad..1412cb15e4f66 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -16,12 +16,12 @@ use watchexec::{ }; #[derive(Clone, Debug, Default, Parser)] -#[clap(next_help_heading = "Watch options")] +#[command(next_help_heading = "Watch options")] pub struct WatchArgs { /// Watch the given files or directories for changes. /// /// If no paths are provided, the source and test directories of the project are watched. - #[clap( + #[arg( long, short, num_args(0..), @@ -30,13 +30,13 @@ pub struct WatchArgs { pub watch: Option>, /// Do not restart the command while it's still running. - #[clap(long)] + #[arg(long)] pub no_restart: bool, /// Explicitly re-run all tests when a change is made. /// /// By default, only the tests of the last modified test file are executed. - #[clap(long)] + #[arg(long)] pub run_all: bool, /// File update debounce delay. @@ -52,7 +52,7 @@ pub struct WatchArgs { /// /// When using --poll mode, you'll want a larger duration, or risk /// overloading disk I/O. - #[clap(long, value_name = "DELAY")] + #[arg(long, value_name = "DELAY")] pub watch_delay: Option, } diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index e62ac19083dce..4a72b80fc7c07 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -33,14 +33,14 @@ const VERSION_MESSAGE: &str = concat!( /// Build, test, fuzz, debug and deploy Solidity contracts. #[derive(Parser)] -#[clap( +#[command( name = "forge", version = VERSION_MESSAGE, after_help = "Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html", next_display_order = None, )] pub struct Forge { - #[clap(subcommand)] + #[command(subcommand)] pub cmd: ForgeSubcommand, } @@ -48,7 +48,7 @@ pub struct Forge { #[allow(clippy::large_enum_variant)] pub enum ForgeSubcommand { /// Run the project's tests. - #[clap(visible_alias = "t")] + #[command(visible_alias = "t")] Test(test::TestArgs), /// Run a smart contract as a script, building transactions that can be sent onchain. @@ -58,71 +58,71 @@ pub enum ForgeSubcommand { Coverage(coverage::CoverageArgs), /// Generate Rust bindings for smart contracts. - #[clap(alias = "bi")] + #[command(alias = "bi")] Bind(BindArgs), /// Build the project's smart contracts. - #[clap(visible_aliases = ["b", "compile"])] + #[command(visible_aliases = ["b", "compile"])] Build(BuildArgs), /// Debugs a single smart contract as a script. - #[clap(visible_alias = "d")] + #[command(visible_alias = "d")] Debug(DebugArgs), /// Update one or multiple dependencies. /// /// If no arguments are provided, then all dependencies are updated. - #[clap(visible_alias = "u")] + #[command(visible_alias = "u")] Update(update::UpdateArgs), /// Install one or multiple dependencies. /// /// If no arguments are provided, then existing dependencies will be installed. - #[clap(visible_alias = "i")] + #[command(visible_alias = "i")] Install(InstallArgs), /// Remove one or multiple dependencies. - #[clap(visible_alias = "rm")] + #[command(visible_alias = "rm")] Remove(RemoveArgs), /// Get the automatically inferred remappings for the project. - #[clap(visible_alias = "re")] + #[command(visible_alias = "re")] Remappings(RemappingArgs), /// Verify smart contracts on Etherscan. - #[clap(visible_alias = "v")] + #[command(visible_alias = "v")] VerifyContract(VerifyArgs), /// Check verification status on Etherscan. - #[clap(visible_alias = "vc")] + #[command(visible_alias = "vc")] VerifyCheck(VerifyCheckArgs), /// Deploy a smart contract. - #[clap(visible_alias = "c")] + #[command(visible_alias = "c")] Create(CreateArgs), /// Create a new Forge project. Init(InitArgs), /// Generate shell completions script. - #[clap(visible_alias = "com")] + #[command(visible_alias = "com")] Completions { - #[clap(value_enum)] + #[arg(value_enum)] shell: clap_complete::Shell, }, /// Generate Fig autocompletion spec. - #[clap(visible_alias = "fig")] + #[command(visible_alias = "fig")] GenerateFigSpec, /// Remove the build artifacts and cache directories. - #[clap(visible_alias = "cl")] + #[command(visible_alias = "cl")] Clean { /// The project's root path. /// /// By default root of the Git repository, if in one, /// or the current working directory. - #[clap(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] root: Option, }, @@ -130,26 +130,26 @@ pub enum ForgeSubcommand { Cache(CacheArgs), /// Create a snapshot of each test's gas usage. - #[clap(visible_alias = "s")] + #[command(visible_alias = "s")] Snapshot(snapshot::SnapshotArgs), /// Display the current config. - #[clap(visible_alias = "co")] + #[command(visible_alias = "co")] Config(config::ConfigArgs), /// Flatten a source file and all of its imports into one file. - #[clap(visible_alias = "f")] + #[command(visible_alias = "f")] Flatten(flatten::FlattenArgs), /// Format Solidity source files. Fmt(FmtArgs), /// Get specialized information about a smart contract. - #[clap(visible_alias = "in")] + #[command(visible_alias = "in")] Inspect(inspect::InspectArgs), /// Display a tree visualization of the project's dependency graph. - #[clap(visible_alias = "tr")] + #[command(visible_alias = "tr")] Tree(tree::TreeArgs), /// Detects usage of unsafe cheat codes in a project and its dependencies. @@ -159,9 +159,9 @@ pub enum ForgeSubcommand { Doc(DocArgs), /// Function selector utilities - #[clap(visible_alias = "se")] + #[command(visible_alias = "se")] Selectors { - #[clap(subcommand)] + #[command(subcommand)] command: SelectorsSubcommands, }, diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index d3d7c9618f1bb..d9673985a11f7 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -89,10 +89,10 @@ macro_rules! create_hw_wallets { /// 6. Private Keys (interactively via secure prompt) /// 7. AWS KMS #[derive(Builder, Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Wallet options", about = None, long_about = None)] +#[command(next_help_heading = "Wallet options", about = None, long_about = None)] pub struct MultiWalletOpts { /// The sender accounts. - #[clap( + #[arg( long, short = 'a', help_heading = "Wallet options - raw", @@ -106,7 +106,7 @@ pub struct MultiWalletOpts { /// Open an interactive prompt to enter your private key. /// /// Takes a value for the number of keys to enter. - #[clap( + #[arg( long, short, help_heading = "Wallet options - raw", @@ -116,12 +116,12 @@ pub struct MultiWalletOpts { pub interactives: u32, /// Use the provided private keys. - #[clap(long, help_heading = "Wallet options - raw", value_name = "RAW_PRIVATE_KEYS")] + #[arg(long, help_heading = "Wallet options - raw", value_name = "RAW_PRIVATE_KEYS")] #[builder(default = "None")] pub private_keys: Option>, /// Use the provided private key. - #[clap( + #[arg( long, help_heading = "Wallet options - raw", conflicts_with = "private_keys", @@ -131,19 +131,19 @@ pub struct MultiWalletOpts { pub private_key: Option, /// Use the mnemonic phrases of mnemonic files at the specified paths. - #[clap(long, alias = "mnemonic-paths", help_heading = "Wallet options - raw")] + #[arg(long, alias = "mnemonic-paths", help_heading = "Wallet options - raw")] #[builder(default = "None")] pub mnemonics: Option>, /// Use a BIP39 passphrases for the mnemonic. - #[clap(long, help_heading = "Wallet options - raw", value_name = "PASSPHRASE")] + #[arg(long, help_heading = "Wallet options - raw", value_name = "PASSPHRASE")] #[builder(default = "None")] pub mnemonic_passphrases: Option>, /// The wallet derivation path. /// /// Works with both --mnemonic-path and hardware wallets. - #[clap( + #[arg( long = "mnemonic-derivation-paths", alias = "hd-paths", help_heading = "Wallet options - raw", @@ -155,7 +155,7 @@ pub struct MultiWalletOpts { /// Use the private key from the given mnemonic index. /// /// Can be used with --mnemonics, --ledger, --aws and --trezor. - #[clap( + #[arg( long, conflicts_with = "hd_paths", help_heading = "Wallet options - raw", @@ -165,7 +165,7 @@ pub struct MultiWalletOpts { pub mnemonic_indexes: Option>, /// Use the keystore in the given folder or file. - #[clap( + #[arg( long = "keystore", visible_alias = "keystores", help_heading = "Wallet options - keystore", @@ -176,7 +176,7 @@ pub struct MultiWalletOpts { pub keystore_paths: Option>, /// Use a keystore from the default keystores folder (~/.foundry/keystores) by its filename - #[clap( + #[arg( long = "account", visible_alias = "accounts", help_heading = "Wallet options - keystore", @@ -190,7 +190,7 @@ pub struct MultiWalletOpts { /// The keystore password. /// /// Used with --keystore. - #[clap( + #[arg( long = "password", help_heading = "Wallet options - keystore", requires = "keystore_paths", @@ -202,7 +202,7 @@ pub struct MultiWalletOpts { /// The keystore password file path. /// /// Used with --keystore. - #[clap( + #[arg( long = "password-file", help_heading = "Wallet options - keystore", requires = "keystore_paths", @@ -213,15 +213,15 @@ pub struct MultiWalletOpts { pub keystore_password_files: Option>, /// Use a Ledger hardware wallet. - #[clap(long, short, help_heading = "Wallet options - hardware wallet")] + #[arg(long, short, help_heading = "Wallet options - hardware wallet")] pub ledger: bool, /// Use a Trezor hardware wallet. - #[clap(long, short, help_heading = "Wallet options - hardware wallet")] + #[arg(long, short, help_heading = "Wallet options - hardware wallet")] pub trezor: bool, /// Use AWS Key Management Service. - #[clap(long, help_heading = "Wallet options - remote")] + #[arg(long, help_heading = "Wallet options - remote")] pub aws: bool, } diff --git a/crates/wallets/src/raw_wallet.rs b/crates/wallets/src/raw_wallet.rs index ccb1d6388dc10..f8a9d447cf9de 100644 --- a/crates/wallets/src/raw_wallet.rs +++ b/crates/wallets/src/raw_wallet.rs @@ -9,34 +9,34 @@ use serde::Serialize; /// 2. Private Key (interactively via secure prompt) /// 3. Mnemonic (via file path) #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Wallet options - raw", about = None, long_about = None)] +#[command(next_help_heading = "Wallet options - raw", about = None, long_about = None)] pub struct RawWalletOpts { /// Open an interactive prompt to enter your private key. - #[clap(long, short)] + #[arg(long, short)] pub interactive: bool, /// Use the provided private key. - #[clap(long, value_name = "RAW_PRIVATE_KEY")] + #[arg(long, value_name = "RAW_PRIVATE_KEY")] pub private_key: Option, /// Use the mnemonic phrase of mnemonic file at the specified path. - #[clap(long, alias = "mnemonic-path")] + #[arg(long, alias = "mnemonic-path")] pub mnemonic: Option, /// Use a BIP39 passphrase for the mnemonic. - #[clap(long, value_name = "PASSPHRASE")] + #[arg(long, value_name = "PASSPHRASE")] pub mnemonic_passphrase: Option, /// The wallet derivation path. /// /// Works with both --mnemonic-path and hardware wallets. - #[clap(long = "mnemonic-derivation-path", alias = "hd-path", value_name = "PATH")] + #[arg(long = "mnemonic-derivation-path", alias = "hd-path", value_name = "PATH")] pub hd_path: Option, /// Use the private key from the given mnemonic index. /// /// Used with --mnemonic-path. - #[clap(long, conflicts_with = "hd_path", default_value_t = 0, value_name = "INDEX")] + #[arg(long, conflicts_with = "hd_path", default_value_t = 0, value_name = "INDEX")] pub mnemonic_index: u32, } diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 0cb06980df652..cd7359f2e2ce8 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -13,10 +13,10 @@ use serde::Serialize; /// 4. Keystore (via file path) /// 5. AWS KMS #[derive(Clone, Debug, Default, Serialize, Parser)] -#[clap(next_help_heading = "Wallet options", about = None, long_about = None)] +#[command(next_help_heading = "Wallet options", about = None, long_about = None)] pub struct WalletOpts { /// The sender account. - #[clap( + #[arg( long, short, value_name = "ADDRESS", @@ -25,11 +25,11 @@ pub struct WalletOpts { )] pub from: Option
, - #[clap(flatten)] + #[command(flatten)] pub raw: RawWalletOpts, /// Use the keystore in the given folder or file. - #[clap( + #[arg( long = "keystore", help_heading = "Wallet options - keystore", value_name = "PATH", @@ -38,7 +38,7 @@ pub struct WalletOpts { pub keystore_path: Option, /// Use a keystore from the default keystores folder (~/.foundry/keystores) by its filename - #[clap( + #[arg( long = "account", help_heading = "Wallet options - keystore", value_name = "ACCOUNT_NAME", @@ -50,7 +50,7 @@ pub struct WalletOpts { /// The keystore password. /// /// Used with --keystore. - #[clap( + #[arg( long = "password", help_heading = "Wallet options - keystore", requires = "keystore_path", @@ -61,7 +61,7 @@ pub struct WalletOpts { /// The keystore password file path. /// /// Used with --keystore. - #[clap( + #[arg( long = "password-file", help_heading = "Wallet options - keystore", requires = "keystore_path", @@ -71,15 +71,15 @@ pub struct WalletOpts { pub keystore_password_file: Option, /// Use a Ledger hardware wallet. - #[clap(long, short, help_heading = "Wallet options - hardware wallet")] + #[arg(long, short, help_heading = "Wallet options - hardware wallet")] pub ledger: bool, /// Use a Trezor hardware wallet. - #[clap(long, short, help_heading = "Wallet options - hardware wallet")] + #[arg(long, short, help_heading = "Wallet options - hardware wallet")] pub trezor: bool, /// Use AWS Key Management Service. - #[clap(long, help_heading = "Wallet options - AWS KMS")] + #[arg(long, help_heading = "Wallet options - AWS KMS")] pub aws: bool, } From 5c171f78b5c025f489c809036f69e7883c776bc7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:40:16 +0200 Subject: [PATCH 0694/1963] fix: use ArtifactId.source instead of .path (#7271) --- crates/common/src/compile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 459ae516e90ef..1132e99bb5098 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -289,7 +289,7 @@ impl ContractSources { let mut sources = ContractSources::default(); for (id, artifact) in output.artifact_ids() { if let Some(file_id) = artifact.id { - let abs_path = root.join(&id.path); + let abs_path = root.join(&id.source); let source_code = std::fs::read_to_string(abs_path).wrap_err_with(|| { format!("failed to read artifact source file for `{}`", id.identifier()) })?; From 4a91072e326126cd852b9c43f577e98c8e13f84f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 29 Feb 2024 20:25:53 +0400 Subject: [PATCH 0695/1963] feat(anvil): expose --disable-default-create2-deployer CLI flag (#7282) --- crates/anvil/src/cmd.rs | 5 +++++ crates/anvil/src/config.rs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 070a974812287..fca14e75dca7f 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -229,6 +229,7 @@ impl NodeArgs { .with_init_state(self.load_state.or_else(|| self.state.and_then(|s| s.state))) .with_transaction_block_keeper(self.transaction_block_keeper) .with_optimism(self.evm_opts.optimism) + .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) } fn account_generator(&self) -> AccountGenerator { @@ -493,6 +494,10 @@ pub struct AnvilEvmArgs { /// Run an Optimism chain #[arg(long, visible_alias = "optimism")] pub optimism: bool, + + /// Disable the default create2 deployer + #[arg(long, visible_alias = "no-create2")] + pub disable_default_create2_deployer: bool, } /// Resolves an alias passed as fork-url to the matching url defined in the rpc_endpoints section diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 5f471e32f1148..32db9e25f0312 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -796,6 +796,13 @@ impl NodeConfig { self } + /// Sets whether to disable the default create2 deployer + #[must_use] + pub fn with_disable_default_create2_deployer(mut self, yes: bool) -> Self { + self.disable_default_create2_deployer = yes; + self + } + /// Configures everything related to env, backend and database and returns the /// [Backend](mem::Backend) /// From b671576e738e1dc938ddee50f1fcbd730e381d67 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:14:00 +0200 Subject: [PATCH 0696/1963] chore(forge): simplify run_tests, reduce parallel tasks (#7283) --- crates/forge/src/runner.rs | 90 ++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 356248a61c623..f94da089c536b 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -253,58 +253,62 @@ impl<'a> ContractRunner<'a> { ) } - let functions: Vec<_> = self.contract.functions().collect(); - let mut test_results = functions - .par_iter() - .filter(|&&func| func.is_test() && filter.matches_test(&func.signature())) - .map(|&func| { - let should_fail = func.is_test_fail(); - let res = if func.is_fuzz_test() { - let runner = test_options.fuzz_runner(self.name, &func.name); - let fuzz_config = test_options.fuzz_config(self.name, &func.name); - self.run_fuzz_test(func, should_fail, runner, setup.clone(), *fuzz_config) - } else { - self.run_test(func, should_fail, setup.clone()) - }; - (func.signature(), res) - }) - .collect::>(); + // Filter out functions sequentially since it's very fast and there is no need to do it + // in parallel. + let find_timer = Instant::now(); + let functions = self + .contract + .functions() + .filter(|func| func.is_test() || func.is_invariant_test()) + .map(|func| (func.signature(), func)) + .filter(|(sig, _func)| filter.matches_test(sig)) + .collect::>(); + let find_time = find_timer.elapsed(); + debug!( + "Found {} test functions out of {} in {:?}", + functions.len(), + self.contract.functions().count(), + find_time, + ); - if has_invariants { - let identified_contracts = load_contracts(setup.traces.clone(), known_contracts); - let results: Vec<_> = functions - .par_iter() - .filter(|&&func| func.is_invariant_test() && filter.matches_test(&func.signature())) - .map(|&func| { + let identified_contracts = + has_invariants.then(|| load_contracts(setup.traces.clone(), known_contracts)); + let test_results = functions + .into_par_iter() + .map(|(sig, func)| { + let setup = setup.clone(); + let should_fail = func.is_test_fail(); + let res = if func.is_invariant_test() { let runner = test_options.invariant_runner(self.name, &func.name); let invariant_config = test_options.invariant_config(self.name, &func.name); - let res = self.run_invariant_test( + self.run_invariant_test( runner, - setup.clone(), + setup, *invariant_config, func, known_contracts, - &identified_contracts, - ); - (func.signature(), res) - }) - .collect(); - test_results.extend(results); - } + identified_contracts.as_ref().unwrap(), + ) + } else if func.is_fuzz_test() { + let runner = test_options.fuzz_runner(self.name, &func.name); + let fuzz_config = test_options.fuzz_config(self.name, &func.name); + self.run_fuzz_test(func, should_fail, runner, setup, *fuzz_config) + } else { + self.run_test(func, should_fail, setup) + }; + (sig, res) + }) + .collect::>(); let duration = start.elapsed(); - if !test_results.is_empty() { - let successful = - test_results.iter().filter(|(_, tst)| tst.status == TestStatus::Success).count(); - info!( - duration = ?duration, - "done. {}/{} successful", - successful, - test_results.len() - ); - } - - SuiteResult::new(duration, test_results, warnings) + let suite_result = SuiteResult::new(duration, test_results, warnings); + info!( + duration=?suite_result.duration, + "done. {}/{} successful", + suite_result.passed(), + suite_result.test_results.len() + ); + suite_result } /// Runs a single test From e57e82ce569a2d8abe9f1419ace9ec1f137b56ce Mon Sep 17 00:00:00 2001 From: Alex Y Date: Fri, 1 Mar 2024 01:37:23 -0800 Subject: [PATCH 0697/1963] feat: `cast mktx` (#7056) * feat: `cast mktx` * refactor: similar code in `cast send` and `cast mktx` * update clap --------- Co-authored-by: Matthias Seitz --- crates/cast/bin/cmd/mktx.rs | 109 ++++++++++++++++++++++++++++++++++ crates/cast/bin/cmd/mod.rs | 1 + crates/cast/bin/cmd/send.rs | 62 +++++-------------- crates/cast/bin/main.rs | 2 + crates/cast/bin/opts.rs | 7 ++- crates/cast/bin/tx.rs | 73 +++++++++++++++++++++++ crates/cast/src/lib.rs | 4 +- crates/cast/tests/cli/main.rs | 83 ++++++++++++++++++++++++++ 8 files changed, 290 insertions(+), 51 deletions(-) create mode 100644 crates/cast/bin/cmd/mktx.rs create mode 100644 crates/cast/bin/tx.rs diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs new file mode 100644 index 0000000000000..dc7f78461dd38 --- /dev/null +++ b/crates/cast/bin/cmd/mktx.rs @@ -0,0 +1,109 @@ +use crate::tx; +use clap::Parser; +use ethers_core::types::NameOrAddress; +use ethers_middleware::MiddlewareBuilder; +use ethers_providers::Middleware; +use ethers_signers::Signer; +use eyre::Result; +use foundry_cli::{ + opts::{EthereumOpts, TransactionOpts}, + utils, +}; +use foundry_common::types::ToAlloy; +use foundry_config::Config; +use std::str::FromStr; + +/// CLI arguments for `cast mktx`. +#[derive(Debug, Parser)] +pub struct MakeTxArgs { + /// The destination of the transaction. + /// + /// If not provided, you must use `cast mktx --create`. + #[arg(value_parser = NameOrAddress::from_str)] + to: Option, + + /// The signature of the function to call. + sig: Option, + + /// The arguments of the function to call. + args: Vec, + + /// Reuse the latest nonce for the sender account. + #[arg(long, conflicts_with = "nonce")] + resend: bool, + + #[command(subcommand)] + command: Option, + + #[command(flatten)] + tx: TransactionOpts, + + #[command(flatten)] + eth: EthereumOpts, +} + +#[derive(Debug, Parser)] +pub enum MakeTxSubcommands { + /// Use to deploy raw contract bytecode. + #[clap(name = "--create")] + Create { + /// The initialization bytecode of the contract to deploy. + code: String, + + /// The signature of the constructor. + sig: Option, + + /// The constructor arguments. + args: Vec, + }, +} + +impl MakeTxArgs { + pub async fn run(self) -> Result<()> { + let MakeTxArgs { to, mut sig, mut args, resend, command, mut tx, eth } = self; + + let code = if let Some(MakeTxSubcommands::Create { + code, + sig: constructor_sig, + args: constructor_args, + }) = command + { + sig = constructor_sig; + args = constructor_args; + Some(code) + } else { + None + }; + + tx::validate_to_address(&code, &to)?; + + let config = Config::from(ð); + let provider = utils::get_provider(&config)?; + let chain = utils::get_chain(config.chain, &provider).await?; + let api_key = config.get_etherscan_api_key(Some(chain)); + + // Retrieve the signer, and bail if it can't be constructed. + let signer = eth.wallet.signer().await?; + let from = signer.address(); + + tx::validate_from_address(eth.wallet.from, from.to_alloy())?; + + if resend { + tx.nonce = Some(provider.get_transaction_count(from, None).await?.to_alloy()); + } + + let provider = provider.with_signer(signer); + + let (mut tx, _) = + tx::build_tx(&provider, from, to, code, sig, args, tx, chain, api_key).await?; + + // Fill nonce, gas limit, gas price, and max priority fee per gas if needed + provider.fill_transaction(&mut tx, None).await?; + + let signature = provider.sign_transaction(&tx, from).await?; + let signed_tx = tx.rlp_signed(&signature); + println!("{signed_tx}"); + + Ok(()) + } +} diff --git a/crates/cast/bin/cmd/mod.rs b/crates/cast/bin/cmd/mod.rs index bd1c8ddf6a079..6c904417407c2 100644 --- a/crates/cast/bin/cmd/mod.rs +++ b/crates/cast/bin/cmd/mod.rs @@ -13,6 +13,7 @@ pub mod estimate; pub mod find_block; pub mod interface; pub mod logs; +pub mod mktx; pub mod rpc; pub mod run; pub mod send; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 22366483c7bea..092d759eb022a 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -1,4 +1,5 @@ -use cast::{Cast, TxBuilder}; +use crate::tx; +use cast::Cast; use clap::Parser; use ethers_core::types::NameOrAddress; use ethers_middleware::SignerMiddleware; @@ -82,7 +83,7 @@ impl SendTxArgs { let SendTxArgs { eth, to, - sig, + mut sig, cast_async, mut args, mut tx, @@ -93,24 +94,20 @@ impl SendTxArgs { unlocked, } = self; - let mut sig = sig.unwrap_or_default(); let code = if let Some(SendTxSubcommands::Create { code, sig: constructor_sig, args: constructor_args, }) = command { - sig = constructor_sig.unwrap_or_default(); + sig = constructor_sig; args = constructor_args; Some(code) } else { None }; - // ensure mandatory fields are provided - if code.is_none() && to.is_none() { - eyre::bail!("Must specify a recipient address or contract code to deploy"); - } + tx::validate_to_address(&code, &to)?; let config = Config::from(ð); let provider = utils::get_provider(&config)?; @@ -155,7 +152,8 @@ impl SendTxArgs { config.sender.to_ethers(), to, code, - (sig, args), + sig, + args, tx, chain, api_key, @@ -173,19 +171,7 @@ impl SendTxArgs { let signer = eth.wallet.signer().await?; let from = signer.address(); - // prevent misconfigured hwlib from sending a transaction that defies - // user-specified --from - if let Some(specified_from) = eth.wallet.from { - if specified_from != from.to_alloy() { - eyre::bail!( - "\ -The specified sender via CLI/env vars does not match the sender configured via -the hardware wallet's HD Path. -Please use the `--hd-path ` parameter to specify the BIP32 Path which -corresponds to the sender, or let foundry automatically detect it by not specifying any sender address." - ) - } - } + tx::validate_from_address(eth.wallet.from, from.to_alloy())?; if resend { tx.nonce = Some(provider.get_transaction_count(from, None).await?.to_alloy()); @@ -198,7 +184,8 @@ corresponds to the sender, or let foundry automatically detect it by not specify from, to, code, - (sig, args), + sig, + args, tx, chain, api_key, @@ -217,7 +204,8 @@ async fn cast_send, T: Into from: F, to: Option, code: Option, - args: (String, Vec), + sig: Option, + args: Vec, tx: TransactionOpts, chain: Chain, etherscan_api_key: Option, @@ -228,30 +216,8 @@ async fn cast_send, T: Into where M::Error: 'static, { - let (sig, params) = args; - let params = if !sig.is_empty() { Some((&sig[..], params)) } else { None }; - let mut builder = TxBuilder::new(&provider, from, to, chain, tx.legacy).await?; - builder - .etherscan_api_key(etherscan_api_key) - .gas(tx.gas_limit) - .gas_price(tx.gas_price) - .priority_gas_price(tx.priority_gas_price) - .value(tx.value) - .nonce(tx.nonce); - - if let Some(code) = code { - let mut data = hex::decode(code)?; - - if let Some((sig, args)) = params { - let (mut sigdata, _) = builder.create_args(sig, args).await?; - data.append(&mut sigdata); - } - - builder.set_data(data); - } else { - builder.args(params).await?; - }; - let builder_output = builder.build(); + let builder_output = + tx::build_tx(&provider, from, to, code, sig, args, tx, chain, etherscan_api_key).await?; let cast = Cast::new(provider); diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 93c686cb31e01..9ea81369ee7db 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -26,6 +26,7 @@ use std::time::Instant; pub mod cmd; pub mod opts; +pub mod tx; use opts::{Cast as Opts, CastSubcommand, ToBaseArgs}; @@ -366,6 +367,7 @@ async fn main() -> Result<()> { // Calls & transactions CastSubcommand::Call(cmd) => cmd.run().await?, CastSubcommand::Estimate(cmd) => cmd.run().await?, + CastSubcommand::MakeTx(cmd) => cmd.run().await?, CastSubcommand::PublishTx { raw_tx, cast_async, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index bfb24b01baaed..5a1af1fdc20aa 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -1,7 +1,8 @@ use crate::cmd::{ access_list::AccessListArgs, bind::BindArgs, call::CallArgs, create2::Create2Args, estimate::EstimateArgs, find_block::FindBlockArgs, interface::InterfaceArgs, logs::LogsArgs, - rpc::RpcArgs, run::RunArgs, send::SendTxArgs, storage::StorageArgs, wallet::WalletSubcommands, + mktx::MakeTxArgs, rpc::RpcArgs, run::RunArgs, send::SendTxArgs, storage::StorageArgs, + wallet::WalletSubcommands, }; use alloy_primitives::{Address, B256, U256}; use clap::{Parser, Subcommand, ValueHint}; @@ -381,6 +382,10 @@ pub enum CastSubcommand { bytecode: String, }, + /// Build and sign a transaction. + #[command(name = "mktx", visible_alias = "m")] + MakeTx(MakeTxArgs), + /// Calculate the ENS namehash of a name. #[command(visible_aliases = &["na", "nh"])] Namehash { name: Option }, diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs new file mode 100644 index 0000000000000..cd155de011d26 --- /dev/null +++ b/crates/cast/bin/tx.rs @@ -0,0 +1,73 @@ +use alloy_primitives::Address; +use cast::{TxBuilder, TxBuilderOutput}; +use ethers_core::types::NameOrAddress; +use ethers_providers::Middleware; +use eyre::Result; +use foundry_cli::opts::TransactionOpts; +use foundry_config::Chain; + +/// Prevents a misconfigured hwlib from sending a transaction that defies user-specified --from +pub fn validate_from_address( + specified_from: Option
, + signer_address: Address, +) -> Result<()> { + if let Some(specified_from) = specified_from { + if specified_from != signer_address { + eyre::bail!( + "\ +The specified sender via CLI/env vars does not match the sender configured via +the hardware wallet's HD Path. +Please use the `--hd-path ` parameter to specify the BIP32 Path which +corresponds to the sender, or let foundry automatically detect it by not specifying any sender address." + ) + } + } + Ok(()) +} + +/// Ensures the transaction is either a contract deployment or a recipient address is specified +pub fn validate_to_address(code: &Option, to: &Option) -> Result<()> { + if code.is_none() && to.is_none() { + eyre::bail!("Must specify a recipient address or contract code to deploy"); + } + Ok(()) +} + +#[allow(clippy::too_many_arguments)] +pub async fn build_tx, T: Into>( + provider: &M, + from: F, + to: Option, + code: Option, + sig: Option, + args: Vec, + tx: TransactionOpts, + chain: impl Into, + etherscan_api_key: Option, +) -> Result { + let mut builder = TxBuilder::new(provider, from, to, chain, tx.legacy).await?; + builder + .etherscan_api_key(etherscan_api_key) + .gas(tx.gas_limit) + .gas_price(tx.gas_price) + .priority_gas_price(tx.priority_gas_price) + .value(tx.value) + .nonce(tx.nonce); + + let params = sig.as_deref().map(|sig| (sig, args)); + if let Some(code) = code { + let mut data = hex::decode(code)?; + + if let Some((sig, args)) = params { + let (mut sigdata, _) = builder.create_args(sig, args).await?; + data.append(&mut sigdata); + } + + builder.set_data(data); + } else { + builder.args(params).await?; + } + + let builder_output = builder.build(); + Ok(builder_output) +} diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index d8c2e995c123e..da7453f5204eb 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -34,7 +34,7 @@ use std::{ sync::atomic::{AtomicBool, Ordering}, }; use tokio::signal::ctrl_c; -use tx::{TxBuilderOutput, TxBuilderPeekOutput}; +use tx::TxBuilderPeekOutput; use foundry_common::abi::encode_function_args_packed; pub use foundry_evm::*; @@ -43,7 +43,7 @@ pub use rusoto_core::{ request::HttpClient as AwsHttpClient, Client as AwsClient, }; pub use rusoto_kms::KmsClient; -pub use tx::TxBuilder; +pub use tx::{TxBuilder, TxBuilderOutput}; pub mod base; pub mod errors; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 91c8b6109c0f8..41cef5e616755 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -514,6 +514,89 @@ casttest!(logs_sig_2, |_prj, cmd| { ); }); +casttest!(mktx, |_prj, cmd| { + cmd.args([ + "mktx", + "--private-key", + "0x0000000000000000000000000000000000000000000000000000000000000001", + "--chain", + "1", + "--nonce", + "0", + "--value", + "100", + "--gas-limit", + "21000", + "--gas-price", + "10000000000", + "--priority-gas-price", + "1000000000", + "0x0000000000000000000000000000000000000001", + ]); + let output = cmd.stdout_lossy(); + assert_eq!( + output.trim(), + "0x02f86b0180843b9aca008502540be4008252089400000000000000000000000000000000000000016480c001a070d55e79ed3ac9fc8f51e78eb91fd054720d943d66633f2eb1bc960f0126b0eca052eda05a792680de3181e49bab4093541f75b49d1ecbe443077b3660c836016a" + ); +}); + +// ensure recipient or code is required +casttest!(mktx_requires_to, |_prj, cmd| { + cmd.args([ + "mktx", + "--private-key", + "0x0000000000000000000000000000000000000000000000000000000000000001", + ]); + let output = cmd.stderr_lossy(); + assert_eq!( + output.trim(), + "Error: \nMust specify a recipient address or contract code to deploy" + ); +}); + +casttest!(mktx_signer_from_mismatch, |_prj, cmd| { + cmd.args([ + "mktx", + "--private-key", + "0x0000000000000000000000000000000000000000000000000000000000000001", + "--from", + "0x0000000000000000000000000000000000000001", + "--chain", + "1", + "0x0000000000000000000000000000000000000001", + ]); + let output = cmd.stderr_lossy(); + assert!( + output.contains("The specified sender via CLI/env vars does not match the sender configured via\nthe hardware wallet's HD Path.") + ); +}); + +casttest!(mktx_signer_from_match, |_prj, cmd| { + cmd.args([ + "mktx", + "--private-key", + "0x0000000000000000000000000000000000000000000000000000000000000001", + "--from", + "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf", + "--chain", + "1", + "--nonce", + "0", + "--gas-limit", + "21000", + "--gas-price", + "10000000000", + "--priority-gas-price", + "1000000000", + "0x0000000000000000000000000000000000000001", + ]); + let output = cmd.stdout_lossy(); + assert_eq!( + output.trim(), + "0x02f86b0180843b9aca008502540be4008252089400000000000000000000000000000000000000018080c001a0cce9a61187b5d18a89ecd27ec675e3b3f10d37f165627ef89a15a7fe76395ce8a07537f5bffb358ffbef22cda84b1c92f7211723f9e09ae037e81686805d3e5505" + ); +}); + // tests that the raw encoded transaction is returned casttest!(tx_raw, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); From 9fff5c20c08b235fd6587362c9ff639c093f68c3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:36:40 +0200 Subject: [PATCH 0698/1963] refactor(forge/test): cache initial executor, don't clone options (#7286) * refactor(forge/test): cache initial executor, don't clone options * chore: clippy * fix: don't share Db and state * fix: don't even share the builder (???) * fix: fuzz tests must also start with test * chore: simplify filtering * fix: filter * fix: filter 2 * chore: comment, logs --- crates/common/src/compile.rs | 3 +- crates/evm/evm/src/executors/builder.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 4 +- crates/forge/bin/cmd/test/mod.rs | 14 +-- crates/forge/src/lib.rs | 14 +-- crates/forge/src/multi_runner.rs | 161 +++++++++++------------- crates/forge/src/runner.rs | 24 ++-- crates/forge/tests/it/cheats.rs | 18 +-- crates/forge/tests/it/config.rs | 52 ++------ crates/forge/tests/it/core.rs | 38 +++--- crates/forge/tests/it/fork.rs | 16 +-- crates/forge/tests/it/fuzz.rs | 57 ++++----- crates/forge/tests/it/inline.rs | 13 +- crates/forge/tests/it/invariant.rs | 120 +++++------------- crates/forge/tests/it/test_helpers.rs | 41 +++++- 15 files changed, 242 insertions(+), 335 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 1132e99bb5098..935e098eeefe7 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -19,6 +19,7 @@ use std::{ path::{Path, PathBuf}, result, str::FromStr, + time::Instant, }; /// Builder type to configure how to compile a project. @@ -185,7 +186,7 @@ impl ProjectCompiler { let output = foundry_compilers::report::with_scoped(&reporter, || { tracing::debug!("compiling project"); - let timer = std::time::Instant::now(); + let timer = Instant::now(); let r = f(); let elapsed = timer.elapsed(); diff --git a/crates/evm/evm/src/executors/builder.rs b/crates/evm/evm/src/executors/builder.rs index ab9bd7629b8e7..d7cca61a7f5e3 100644 --- a/crates/evm/evm/src/executors/builder.rs +++ b/crates/evm/evm/src/executors/builder.rs @@ -10,7 +10,7 @@ use revm::primitives::{Env, SpecId}; /// /// [`Cheatcodes`]: super::inspector::Cheatcodes /// [`InspectorStack`]: super::inspector::InspectorStack -#[derive(Debug)] +#[derive(Clone, Debug)] #[must_use = "builders do nothing unless you call `build` on them"] pub struct ExecutorBuilder { /// The configuration used to build an [InspectorStack]. diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 0c1232d7a8faf..718d1079058ad 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -313,9 +313,7 @@ impl CoverageArgs { let known_contracts = runner.known_contracts.clone(); let filter = self.filter; let (tx, rx) = channel::<(String, SuiteResult)>(); - let handle = tokio::task::spawn(async move { - runner.test(&filter, tx, runner.test_options.clone()).await - }); + let handle = tokio::task::spawn(async move { runner.test(&filter, tx).await }); // Add hit data to the coverage report let data = rx diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index b81a5b362edce..0d49b4640671c 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -200,7 +200,7 @@ impl TestArgs { .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone(), None)) - .with_test_options(test_options.clone()) + .with_test_options(test_options) .enable_isolation(evm_opts.isolate) .build(project_root, output, env, evm_opts)?; @@ -215,7 +215,7 @@ impl TestArgs { *test_pattern = Some(debug_test_pattern.clone()); } - let outcome = self.run_tests(runner, config, verbosity, &filter, test_options).await?; + let outcome = self.run_tests(runner, config, verbosity, &filter).await?; if should_debug { // There is only one test. @@ -250,7 +250,6 @@ impl TestArgs { config: Config, verbosity: u8, filter: &ProjectPathsAwareFilter, - test_options: TestOptions, ) -> eyre::Result { if self.list { return list(runner, filter, self.json); @@ -258,7 +257,7 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); - let num_filtered = runner.matching_test_function_count(filter); + let num_filtered = runner.matching_test_functions(filter).count(); if num_filtered == 0 { println!(); if filter.is_empty() { @@ -273,7 +272,8 @@ impl TestArgs { // Try to suggest a test when there's no match if let Some(test_pattern) = &filter.args().test_pattern { let test_name = test_pattern.as_str(); - let candidates = runner.get_tests(filter); + // Filter contracts but not test functions. + let candidates = runner.all_test_functions(filter).map(|f| &f.name); if let Some(suggestion) = utils::did_you_mean(test_name, candidates).pop() { println!("\nDid you mean `{suggestion}`?"); } @@ -289,7 +289,7 @@ impl TestArgs { } if self.json { - let results = runner.test_collect(filter, test_options).await; + let results = runner.test_collect(filter).await; println!("{}", serde_json::to_string(&results)?); return Ok(TestOutcome::new(results, self.allow_failure)); } @@ -305,7 +305,7 @@ impl TestArgs { let timer = Instant::now(); let handle = tokio::task::spawn({ let filter = filter.clone(); - async move { runner.test(&filter, tx, test_options).await } + async move { runner.test(&filter, tx).await } }); let mut gas_report = diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 16343fc096558..00481591e0798 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -1,13 +1,11 @@ #[macro_use] extern crate tracing; -use alloy_primitives::B256; use foundry_compilers::ProjectCompileOutput; use foundry_config::{ validate_profiles, Config, FuzzConfig, InlineConfig, InlineConfigError, InlineConfigParser, InvariantConfig, NatSpec, }; - use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; use std::path::Path; @@ -146,20 +144,20 @@ impl TestOptions { pub fn fuzzer_with_cases(&self, cases: u32) -> TestRunner { // TODO: Add Options to modify the persistence - let cfg = proptest::test_runner::Config { + let config = proptest::test_runner::Config { failure_persistence: None, cases, max_global_rejects: self.fuzz.max_test_rejects, ..Default::default() }; - if let Some(ref fuzz_seed) = self.fuzz.seed { - trace!(target: "forge::test", "building deterministic fuzzer with seed {}", fuzz_seed); - let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &B256::from(*fuzz_seed).0); - TestRunner::new_with_rng(cfg, rng) + if let Some(seed) = &self.fuzz.seed { + trace!(target: "forge::test", %seed, "building deterministic fuzzer"); + let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &seed.to_be_bytes::<32>()); + TestRunner::new_with_rng(config, rng) } else { trace!(target: "forge::test", "building stochastic fuzzer"); - TestRunner::new(cfg) + TestRunner::new(config) } } } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 699df0da0566f..ea6c79c98374a 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -26,6 +26,7 @@ use std::{ fmt::Debug, path::Path, sync::{mpsc, Arc}, + time::Instant, }; pub type DeployableContracts = BTreeMap)>; @@ -65,57 +66,47 @@ pub struct MultiContractRunner { } impl MultiContractRunner { - /// Returns the number of matching tests - pub fn matching_test_function_count(&self, filter: &dyn TestFilter) -> usize { - self.matching_test_functions(filter).count() + /// Returns an iterator over all contracts that match the filter. + pub fn matching_contracts<'a>( + &'a self, + filter: &'a dyn TestFilter, + ) -> impl Iterator))> { + self.contracts.iter().filter(|&(id, (abi, _, _))| matches_contract(id, abi, filter)) } - /// Returns all test functions matching the filter + /// Returns an iterator over all test functions that match the filter. pub fn matching_test_functions<'a>( &'a self, filter: &'a dyn TestFilter, ) -> impl Iterator { - self.contracts - .iter() - .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) - .flat_map(|(_, (abi, _, _))| { - abi.functions().filter(|func| filter.matches_test(&func.signature())) - }) + self.matching_contracts(filter) + .flat_map(|(_, (abi, _, _))| abi.functions()) + .filter(|func| is_matching_test(func, filter)) } - /// Get an iterator over all test contract functions that matches the filter path and contract - /// name - fn filtered_tests<'a>(&'a self, filter: &'a dyn TestFilter) -> impl Iterator { + /// Returns an iterator over all test functions in contracts that match the filter. + pub fn all_test_functions<'a>( + &'a self, + filter: &'a dyn TestFilter, + ) -> impl Iterator { self.contracts .iter() .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) .flat_map(|(_, (abi, _, _))| abi.functions()) - } - - /// Get all test names matching the filter - pub fn get_tests(&self, filter: &dyn TestFilter) -> Vec { - self.filtered_tests(filter) - .map(|func| func.name.clone()) - .filter(|name| name.is_test()) - .collect() + .filter(|func| func.is_test() || func.is_invariant_test()) } /// Returns all matching tests grouped by contract grouped by file (file -> (contract -> tests)) pub fn list(&self, filter: &dyn TestFilter) -> BTreeMap>> { - self.contracts - .iter() - .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) - .filter(|(_, (abi, _, _))| abi.functions().any(|func| filter.matches_test(&func.name))) + self.matching_contracts(filter) .map(|(id, (abi, _, _))| { let source = id.source.as_path().display().to_string(); let name = id.name.clone(); let tests = abi .functions() - .filter(|func| func.name.is_test()) - .filter(|func| filter.matches_test(&func.signature())) + .filter(|func| is_matching_test(func, filter)) .map(|func| func.name.clone()) .collect::>(); - (source, name, tests) }) .fold(BTreeMap::new(), |mut acc, (source, name, tests)| { @@ -129,12 +120,8 @@ impl MultiContractRunner { /// The same as [`test`](Self::test), but returns the results instead of streaming them. /// /// Note that this method returns only when all tests have been executed. - pub async fn test_collect( - &mut self, - filter: &dyn TestFilter, - test_options: TestOptions, - ) -> BTreeMap { - self.test_iter(filter, test_options).await.collect() + pub async fn test_collect(&mut self, filter: &dyn TestFilter) -> BTreeMap { + self.test_iter(filter).await.collect() } /// Executes _all_ tests that match the given `filter`. @@ -145,10 +132,9 @@ impl MultiContractRunner { pub async fn test_iter( &mut self, filter: &dyn TestFilter, - test_options: TestOptions, ) -> impl Iterator { let (tx, rx) = mpsc::channel(); - self.test(filter, tx, test_options).await; + self.test(filter, tx).await; rx.into_iter() } @@ -158,50 +144,40 @@ impl MultiContractRunner { /// before executing all contracts and their tests in _parallel_. /// /// Each Executor gets its own instance of the `Backend`. - pub async fn test( - &mut self, - filter: &dyn TestFilter, - stream_result: mpsc::Sender<(String, SuiteResult)>, - test_options: TestOptions, - ) { + pub async fn test(&mut self, filter: &dyn TestFilter, tx: mpsc::Sender<(String, SuiteResult)>) { trace!("running all tests"); - // the db backend that serves all the data, each contract gets its own instance + // The DB backend that serves all the data. let db = Backend::spawn(self.fork.take()).await; - - self.contracts - .par_iter() - .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) - .filter(|(_, (abi, _, _))| abi.functions().any(|func| filter.matches_test(&func.name))) - .for_each_with(stream_result, |stream_result, (id, (abi, deploy_code, libs))| { - let executor = ExecutorBuilder::new() - .inspectors(|stack| { - stack - .cheatcodes(self.cheats_config.clone()) - .trace(self.evm_opts.verbosity >= 3 || self.debug) - .debug(self.debug) - .coverage(self.coverage) - .enable_isolation(self.isolation) - }) - .spec(self.evm_spec) - .gas_limit(self.evm_opts.gas_limit()) - .build(self.env.clone(), db.clone()); - let identifier = id.identifier(); - trace!(contract=%identifier, "start executing all tests in contract"); - - let result = self.run_tests( - &identifier, - abi, - executor, - deploy_code.clone(), - libs, - filter, - test_options.clone(), - ); - trace!(contract=?identifier, "executed all tests in contract"); - - let _ = stream_result.send((identifier, result)); + let executor = ExecutorBuilder::new() + .inspectors(|stack| { + stack + .cheatcodes(self.cheats_config.clone()) + .trace(self.evm_opts.verbosity >= 3 || self.debug) + .debug(self.debug) + .coverage(self.coverage) + .enable_isolation(self.isolation) }) + .spec(self.evm_spec) + .gas_limit(self.evm_opts.gas_limit()) + .build(self.env.clone(), db); + + let find_timer = Instant::now(); + let contracts = self.matching_contracts(filter).collect::>(); + let find_time = find_timer.elapsed(); + debug!( + "Found {} test contracts out of {} in {:?}", + contracts.len(), + self.contracts.len(), + find_time, + ); + + contracts.par_iter().for_each_with(tx, |tx, &(id, (abi, deploy_code, libs))| { + let identifier = id.identifier(); + let executor = executor.clone(); + let result = self.run_tests(&identifier, abi, executor, deploy_code, libs, filter); + let _ = tx.send((identifier, result)); + }) } #[allow(clippy::too_many_arguments)] @@ -210,20 +186,17 @@ impl MultiContractRunner { name: &str, contract: &JsonAbi, executor: Executor, - deploy_code: Bytes, + deploy_code: &Bytes, libs: &[Bytes], filter: &dyn TestFilter, - test_options: TestOptions, ) -> SuiteResult { - let span = info_span!("run_tests"); - if !span.is_disabled() { - if enabled!(tracing::Level::TRACE) { - span.record("contract", name); - } else { - span.record("contract", get_contract_name(name)); - } + let mut span_name = name; + if !enabled!(tracing::Level::TRACE) { + span_name = get_contract_name(span_name); } - let _guard = span.enter(); + let _guard = info_span!("run_tests", name = span_name).entered(); + + debug!("start executing all tests in contract"); let runner = ContractRunner::new( name, @@ -236,7 +209,11 @@ impl MultiContractRunner { libs, self.debug, ); - runner.run_tests(filter, test_options, Some(&self.known_contracts)) + let r = runner.run_tests(filter, &self.test_options, Some(&self.known_contracts)); + + debug!(duration=?r.duration, "executed all tests in contract"); + + r } } @@ -395,3 +372,13 @@ impl MultiContractRunnerBuilder { }) } } + +fn matches_contract(id: &ArtifactId, abi: &JsonAbi, filter: &dyn TestFilter) -> bool { + (filter.matches_path(&id.source) && filter.matches_contract(&id.name)) && + abi.functions().any(|func| is_matching_test(func, filter)) +} + +/// Returns `true` if the function is a test function that matches the given filter. +pub(crate) fn is_matching_test(func: &Function, filter: &dyn TestFilter) -> bool { + (func.is_test() || func.is_invariant_test()) && filter.matches_test(&func.signature()) +} diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index f94da089c536b..ca3e8362940b1 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -1,6 +1,7 @@ //! The Forge test runner. use crate::{ + multi_runner::is_matching_test, result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, }; @@ -40,7 +41,7 @@ pub struct ContractRunner<'a> { /// Library contracts to be deployed before the test contract pub predeploy_libs: &'a [Bytes], /// The deployed contract's code - pub code: Bytes, + pub code: &'a Bytes, /// The test contract's ABI pub contract: &'a JsonAbi, /// Revert decoder. Contains all known errors. @@ -59,7 +60,7 @@ impl<'a> ContractRunner<'a> { name: &'a str, executor: Executor, contract: &'a JsonAbi, - code: Bytes, + code: &'a Bytes, initial_balance: U256, sender: Option
, revert_decoder: &'a RevertDecoder, @@ -185,7 +186,7 @@ impl<'a> ContractRunner<'a> { pub fn run_tests( mut self, filter: &dyn TestFilter, - test_options: TestOptions, + test_options: &TestOptions, known_contracts: Option<&ContractsByArtifact>, ) -> SuiteResult { info!("starting tests"); @@ -259,9 +260,7 @@ impl<'a> ContractRunner<'a> { let functions = self .contract .functions() - .filter(|func| func.is_test() || func.is_invariant_test()) - .map(|func| (func.signature(), func)) - .filter(|(sig, _func)| filter.matches_test(sig)) + .filter(|func| is_matching_test(func, filter)) .collect::>(); let find_time = find_timer.elapsed(); debug!( @@ -274,8 +273,10 @@ impl<'a> ContractRunner<'a> { let identified_contracts = has_invariants.then(|| load_contracts(setup.traces.clone(), known_contracts)); let test_results = functions - .into_par_iter() - .map(|(sig, func)| { + .par_iter() + .map(|&func| { + let sig = func.signature(); + let setup = setup.clone(); let should_fail = func.is_test_fail(); let res = if func.is_invariant_test() { @@ -290,12 +291,15 @@ impl<'a> ContractRunner<'a> { identified_contracts.as_ref().unwrap(), ) } else if func.is_fuzz_test() { + debug_assert!(func.is_test()); let runner = test_options.fuzz_runner(self.name, &func.name); let fuzz_config = test_options.fuzz_config(self.name, &func.name); self.run_fuzz_test(func, should_fail, runner, setup, *fuzz_config) } else { + debug_assert!(func.is_test()); self.run_test(func, should_fail, setup) }; + (sig, res) }) .collect::>(); @@ -417,7 +421,7 @@ impl<'a> ContractRunner<'a> { // Record test execution time let duration = start.elapsed(); - debug!(?duration, gas, reverted, should_fail, success); + trace!(?duration, gas, reverted, should_fail, success); TestResult { status: match success { @@ -674,7 +678,7 @@ impl<'a> ContractRunner<'a> { // Record test execution time let duration = start.elapsed(); - debug!(?duration, success = %result.success); + trace!(?duration, success = %result.success); TestResult { status: match result.success { diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 078361fab8e04..2959014bc0e14 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -10,15 +10,17 @@ use foundry_test_utils::Filter; /// Executes all cheat code tests but not fork cheat codes #[tokio::test(flavor = "multi_thread")] async fn test_cheats_local() { - let mut config = Config::with_root(PROJECT.root()); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); - let runner = runner_with_config(config); - let filter = + let mut filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}*")).exclude_paths("Fork"); - // on windows exclude ffi tests since no echo and file test that expect a certain file path - #[cfg(windows)] - let filter = filter.exclude_tests("(Ffi|File|Line|Root)"); + // Exclude FFI tests on Windows because no `echo`, and file tests that expect certain file paths + if cfg!(windows) { + filter = filter.exclude_tests("(Ffi|File|Line|Root)"); + } + + let mut config = Config::with_root(PROJECT.root()); + config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); + let runner = runner_with_config(config).await; - TestConfig::with_filter(runner.await, filter).run().await; + TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 542f9a88e3d59..c56a626c49a8d 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -1,13 +1,12 @@ //! Test config. -use crate::test_helpers::{COMPILED, EVM_OPTS, PROJECT}; +use crate::test_helpers::{COMPILED, EVM_OPTS, PROJECT, TEST_OPTS}; use forge::{ result::{SuiteResult, TestStatus}, - MultiContractRunner, MultiContractRunnerBuilder, TestOptions, TestOptionsBuilder, + MultiContractRunner, MultiContractRunnerBuilder, }; use foundry_config::{ - fs_permissions::PathPermission, Config, FsPermissions, FuzzConfig, FuzzDictionaryConfig, - InvariantConfig, RpcEndpoint, RpcEndpoints, + fs_permissions::PathPermission, Config, FsPermissions, RpcEndpoint, RpcEndpoints, }; use foundry_evm::{ decode::decode_console_logs, @@ -25,7 +24,6 @@ pub struct TestConfig { pub runner: MultiContractRunner, pub should_fail: bool, pub filter: Filter, - pub opts: TestOptions, } impl TestConfig { @@ -39,7 +37,7 @@ impl TestConfig { pub fn with_filter(runner: MultiContractRunner, filter: Filter) -> Self { init_tracing(); - Self { runner, should_fail: false, filter, opts: test_opts() } + Self { runner, should_fail: false, filter } } pub fn evm_spec(mut self, spec: SpecId) -> Self { @@ -58,7 +56,7 @@ impl TestConfig { /// Executes the test runner pub async fn test(&mut self) -> BTreeMap { - self.runner.test_collect(&self.filter, self.opts.clone()).await + self.runner.test_collect(&self.filter).await } pub async fn run(&mut self) { @@ -110,41 +108,6 @@ impl TestConfig { } } -/// Returns the [`TestOptions`] used by the tests. -pub fn test_opts() -> TestOptions { - TestOptionsBuilder::default() - .fuzz(FuzzConfig { - runs: 256, - max_test_rejects: 65536, - seed: None, - dictionary: FuzzDictionaryConfig { - include_storage: true, - include_push_bytes: true, - dictionary_weight: 40, - max_fuzz_dictionary_addresses: 10_000, - max_fuzz_dictionary_values: 10_000, - }, - }) - .invariant(InvariantConfig { - runs: 256, - depth: 15, - fail_on_revert: false, - call_override: false, - dictionary: FuzzDictionaryConfig { - dictionary_weight: 80, - include_storage: true, - include_push_bytes: true, - max_fuzz_dictionary_addresses: 10_000, - max_fuzz_dictionary_values: 10_000, - }, - shrink_sequence: true, - shrink_run_limit: 2usize.pow(18u32), - preserve_state: false, - }) - .build(&COMPILED, &PROJECT.paths.root) - .expect("Config loaded") -} - pub fn manifest_root() -> &'static Path { let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); // need to check here where we're executing the test from, if in `forge` we need to also allow @@ -158,7 +121,9 @@ pub fn manifest_root() -> &'static Path { /// Builds a base runner pub fn base_runner() -> MultiContractRunnerBuilder { init_tracing(); - MultiContractRunnerBuilder::default().sender(EVM_OPTS.sender) + MultiContractRunnerBuilder::default() + .sender(EVM_OPTS.sender) + .with_test_options(TEST_OPTS.clone()) } /// Builds a non-tracing runner @@ -178,7 +143,6 @@ pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { let env = opts.evm_env().await.expect("could not instantiate fork environment"); let output = COMPILED.clone(); base_runner() - .with_test_options(test_opts()) .with_cheats_config(CheatsConfig::new(&config, opts.clone(), None)) .sender(config.sender) .build(root, output, env, opts.clone()) diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 660ab06777858..29ce68c9eedff 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -8,8 +8,9 @@ use std::{collections::BTreeMap, env}; #[tokio::test(flavor = "multi_thread")] async fn test_core() { + let filter = Filter::new(".*", ".*", ".*core"); let mut runner = runner().await; - let results = runner.test_collect(&Filter::new(".*", ".*", ".*core"), test_opts()).await; + let results = runner.test_collect(&filter).await; assert_multiple( &results, @@ -77,8 +78,9 @@ async fn test_core() { #[tokio::test(flavor = "multi_thread")] async fn test_linking() { + let filter = Filter::new(".*", ".*", ".*linking"); let mut runner = runner().await; - let results = runner.test_collect(&Filter::new(".*", ".*", ".*linking"), test_opts()).await; + let results = runner.test_collect(&filter).await; assert_multiple( &results, @@ -110,8 +112,9 @@ async fn test_linking() { #[tokio::test(flavor = "multi_thread")] async fn test_logs() { + let filter = Filter::new(".*", ".*", ".*logs"); let mut runner = runner().await; - let results = runner.test_collect(&Filter::new(".*", ".*", ".*logs"), test_opts()).await; + let results = runner.test_collect(&filter).await; assert_multiple( &results, @@ -670,38 +673,31 @@ async fn test_logs() { #[tokio::test(flavor = "multi_thread")] async fn test_env_vars() { - let mut runner = runner().await; - - // test `setEnv` first, and confirm that it can correctly set environment variables, - // so that we can use it in subsequent `env*` tests - let _ = runner.test_collect(&Filter::new("testSetEnv", ".*", ".*"), test_opts()).await; let env_var_key = "_foundryCheatcodeSetEnvTestKey"; let env_var_val = "_foundryCheatcodeSetEnvTestVal"; - let res = env::var(env_var_key); - assert!( - res.is_ok() && res.unwrap() == env_var_val, - "Test `testSetEnv` did not pass as expected. -Reason: `setEnv` failed to set an environment variable `{env_var_key}={env_var_val}`" - ); + env::remove_var(env_var_key); + + let filter = Filter::new("testSetEnv", ".*", ".*"); + let mut runner = runner().await; + let _ = runner.test_collect(&filter).await; + + assert_eq!(env::var(env_var_key).unwrap(), env_var_val); } #[tokio::test(flavor = "multi_thread")] async fn test_doesnt_run_abstract_contract() { + let filter = Filter::new(".*", ".*", ".*Abstract.t.sol".to_string().as_str()); let mut runner = runner().await; - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*Abstract.t.sol".to_string().as_str()), - test_opts(), - ) - .await; + let results = runner.test_collect(&filter).await; assert!(results.get("core/Abstract.t.sol:AbstractTestBase").is_none()); assert!(results.get("core/Abstract.t.sol:AbstractTest").is_some()); } #[tokio::test(flavor = "multi_thread")] async fn test_trace() { + let filter = Filter::new(".*", ".*", ".*trace"); let mut runner = tracing_runner().await; - let suite_result = runner.test_collect(&Filter::new(".*", ".*", ".*trace"), test_opts()).await; + let suite_result = runner.test_collect(&filter).await; // TODO: This trace test is very basic - it is probably a good candidate for snapshot // testing. diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index f34cc59bb3c7c..76a06e57b6707 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -11,17 +11,13 @@ use foundry_test_utils::Filter; /// Executes reverting fork test #[tokio::test(flavor = "multi_thread")] async fn test_cheats_fork_revert() { + let filter = Filter::new( + "testNonExistingContractRevert", + ".*", + &format!(".*cheats{RE_PATH_SEPARATOR}Fork"), + ); let mut runner = runner().await; - let suite_result = runner - .test_collect( - &Filter::new( - "testNonExistingContractRevert", - ".*", - &format!(".*cheats{RE_PATH_SEPARATOR}Fork"), - ), - test_opts(), - ) - .await; + let suite_result = runner.test_collect(&filter).await; assert_eq!(suite_result.len(), 1); for (_, SuiteResult { test_results, .. }) in suite_result { diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 2eefa530d6230..011497f4ce471 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -8,16 +8,11 @@ use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] async fn test_fuzz() { + let filter = Filter::new(".*", ".*", ".*fuzz/") + .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)|testSuccessChecker\(uint256\)|testSuccessChecker2\(int256\)|testSuccessChecker3\(uint32\)") + .exclude_paths("invariant"); let mut runner = runner().await; - - let suite_result = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/") - .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)|testSuccessChecker\(uint256\)|testSuccessChecker2\(int256\)|testSuccessChecker3\(uint32\)") - .exclude_paths("invariant"), - test_opts(), - ) - .await; + let suite_result = runner.test_collect(&filter).await; assert!(!suite_result.is_empty()); @@ -27,15 +22,17 @@ async fn test_fuzz() { "testPositive(uint256)" | "testPositive(int256)" | "testSuccessfulFuzz(uint128,uint128)" | - "testToStringFuzz(bytes32)" => assert!( - result.status == TestStatus::Success, + "testToStringFuzz(bytes32)" => assert_eq!( + result.status, + TestStatus::Success, "Test {} did not pass as expected.\nReason: {:?}\nLogs:\n{}", test_name, result.reason, result.decoded_logs.join("\n") ), - _ => assert!( - result.status == TestStatus::Failure, + _ => assert_eq!( + result.status, + TestStatus::Failure, "Test {} did not fail as expected.\nReason: {:?}\nLogs:\n{}", test_name, result.reason, @@ -48,16 +45,11 @@ async fn test_fuzz() { #[tokio::test(flavor = "multi_thread")] async fn test_successful_fuzz_cases() { + let filter = Filter::new(".*", ".*", ".*fuzz/FuzzPositive") + .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)") + .exclude_paths("invariant"); let mut runner = runner().await; - - let suite_result = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/FuzzPositive") - .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)") - .exclude_paths("invariant"), - test_opts(), - ) - .await; + let suite_result = runner.test_collect(&filter).await; assert!(!suite_result.is_empty()); @@ -66,8 +58,9 @@ async fn test_successful_fuzz_cases() { match test_name.as_str() { "testSuccessChecker(uint256)" | "testSuccessChecker2(int256)" | - "testSuccessChecker3(uint32)" => assert!( - result.status == TestStatus::Success, + "testSuccessChecker3(uint32)" => assert_eq!( + result.status, + TestStatus::Success, "Test {} did not pass as expected.\nReason: {:?}\nLogs:\n{}", test_name, result.reason, @@ -84,17 +77,13 @@ async fn test_successful_fuzz_cases() { #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_fuzz_collection() { + let filter = Filter::new(".*", ".*", ".*fuzz/FuzzCollection.t.sol"); let mut runner = runner().await; - - let mut opts = test_opts(); - opts.invariant.depth = 100; - opts.invariant.runs = 1000; - opts.fuzz.runs = 1000; - opts.fuzz.seed = Some(U256::from(6u32)); - runner.test_options = opts.clone(); - - let results = - runner.test_collect(&Filter::new(".*", ".*", ".*fuzz/FuzzCollection.t.sol"), opts).await; + runner.test_options.invariant.depth = 100; + runner.test_options.invariant.runs = 1000; + runner.test_options.fuzz.runs = 1000; + runner.test_options.fuzz.seed = Some(U256::from(6u32)); + let results = runner.test_collect(&filter).await; assert_multiple( &results, diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 0001bea298da2..3503606d7088b 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -13,14 +13,9 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { - let opts = default_test_options(); - let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - let mut runner = runner().await; - runner.test_options = opts.clone(); - - let result = runner.test_collect(&filter, opts).await; + let result = runner.test_collect(&filter).await; let suite_result: &SuiteResult = result.get("inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); let test_result: &TestResult = @@ -39,12 +34,10 @@ async fn inline_config_run_fuzz() { async fn inline_config_run_invariant() { const ROOT: &str = "inline/InvariantInlineConf.t.sol"; - let opts = default_test_options(); let filter = Filter::new(".*", ".*", ".*inline/InvariantInlineConf.t.sol"); let mut runner = runner().await; - runner.test_options = opts.clone(); - - let result = runner.test_collect(&filter, opts).await; + runner.test_options = default_test_options(); + let result = runner.test_collect(&filter).await; let suite_result_1 = result.get(&format!("{ROOT}:InvariantInlineConf")).expect("Result exists"); let suite_result_2 = diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 5959b0926de73..b5132fefab9fd 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -1,6 +1,6 @@ //! Invariant tests. -use crate::config::*; +use crate::{config::*, test_helpers::TEST_OPTS}; use alloy_primitives::U256; use forge::{fuzz::CounterExample, result::TestStatus, TestOptions}; use foundry_test_utils::Filter; @@ -8,14 +8,9 @@ use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] async fn test_invariant() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"); let mut runner = runner().await; - - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"), - test_opts(), - ) - .await; + let results = runner.test_collect(&filter).await; assert_multiple( &results, @@ -148,18 +143,10 @@ async fn test_invariant() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_override() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantReentrancy.t.sol"); let mut runner = runner().await; - - let mut opts = test_opts(); - opts.invariant.call_override = true; - runner.test_options = opts.clone(); - - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantReentrancy.t.sol"), - opts, - ) - .await; + runner.test_options.invariant.call_override = true; + let results = runner.test_collect(&filter).await; assert_multiple( &results, @@ -172,20 +159,12 @@ async fn test_invariant_override() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_fail_on_revert() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantHandlerFailure.t.sol"); let mut runner = runner().await; - - let mut opts = test_opts(); - opts.invariant.fail_on_revert = true; - opts.invariant.runs = 1; - opts.invariant.depth = 10; - runner.test_options = opts.clone(); - - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantHandlerFailure.t.sol"), - opts, - ) - .await; + runner.test_options.invariant.fail_on_revert = true; + runner.test_options.invariant.runs = 1; + runner.test_options.invariant.depth = 10; + let results = runner.test_collect(&filter).await; assert_multiple( &results, @@ -205,19 +184,11 @@ async fn test_invariant_fail_on_revert() { #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_invariant_storage() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/storage/InvariantStorageTest.t.sol"); let mut runner = runner().await; - - let mut opts = test_opts(); - opts.invariant.depth = 100 + (50 * cfg!(windows) as u32); - opts.fuzz.seed = Some(U256::from(6u32)); - runner.test_options = opts.clone(); - - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/invariant/storage/InvariantStorageTest.t.sol"), - opts, - ) - .await; + runner.test_options.invariant.depth = 100 + (50 * cfg!(windows) as u32); + runner.test_options.fuzz.seed = Some(U256::from(6u32)); + let results = runner.test_collect(&filter).await; assert_multiple( &results, @@ -236,18 +207,10 @@ async fn test_invariant_storage() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_shrink() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); let mut runner = runner().await; - - let mut opts = test_opts(); - opts.fuzz.seed = Some(U256::from(119u32)); - runner.test_options = opts.clone(); - - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"), - opts, - ) - .await; + runner.test_options.fuzz.seed = Some(U256::from(119u32)); + let results = runner.test_collect(&filter).await; let results = results.values().last().expect("`InvariantInnerContract.t.sol` should be testable."); @@ -287,7 +250,7 @@ async fn test_invariant_shrink() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_assert_shrink() { - let mut opts = test_opts(); + let mut opts = TEST_OPTS.clone(); opts.fuzz.seed = Some(U256::from(119u32)); // ensure assert and require shrinks to same sequence of 3 or less @@ -296,18 +259,14 @@ async fn test_invariant_assert_shrink() { } async fn test_shrink(opts: TestOptions, contract_pattern: &str) { + let filter = Filter::new( + ".*", + contract_pattern, + ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol", + ); let mut runner = runner().await; runner.test_options = opts.clone(); - let results = runner - .test_collect( - &Filter::new( - ".*", - contract_pattern, - ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol", - ), - opts, - ) - .await; + let results = runner.test_collect(&filter).await; let results = results.values().last().expect("`InvariantShrinkWithAssert` should be testable."); let result = results @@ -333,18 +292,11 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_preserve_state() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"); let mut runner = runner().await; - - // should not fail with default options - let mut opts = test_opts(); - opts.invariant.fail_on_revert = true; - runner.test_options = opts.clone(); - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"), - opts, - ) - .await; + // Should not fail with default options. + runner.test_options.invariant.fail_on_revert = true; + let results = runner.test_collect(&filter).await; assert_multiple( &results, BTreeMap::from([( @@ -354,17 +306,9 @@ async fn test_invariant_preserve_state() { ); // same test should revert when preserve state enabled - let mut opts = test_opts(); - opts.invariant.fail_on_revert = true; - opts.invariant.preserve_state = true; - runner.test_options = opts.clone(); - - let results = runner - .test_collect( - &Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"), - opts, - ) - .await; + runner.test_options.invariant.fail_on_revert = true; + runner.test_options.invariant.preserve_state = true; + let results = runner.test_collect(&filter).await; assert_multiple( &results, BTreeMap::from([( diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 31a330d2afb05..873e3071f723b 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -1,11 +1,12 @@ //! Test helpers for Forge integration tests. use alloy_primitives::U256; +use forge::{TestOptions, TestOptionsBuilder}; use foundry_compilers::{ artifacts::{Libraries, Settings}, Project, ProjectCompileOutput, ProjectPathsConfig, SolcConfig, }; -use foundry_config::Config; +use foundry_config::{Config, FuzzConfig, FuzzDictionaryConfig, InvariantConfig}; use foundry_evm::{ constants::CALLER, executors::{Executor, FuzzedExecutor}, @@ -53,7 +54,7 @@ pub static COMPILED: Lazy = Lazy::new(|| { write.write_all(b"1").unwrap(); out = project.compile(); drop(write); - }; + } let out = out.unwrap(); if out.has_compiler_errors() { @@ -79,6 +80,40 @@ pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { ..Default::default() }); +pub static TEST_OPTS: Lazy = Lazy::new(|| { + TestOptionsBuilder::default() + .fuzz(FuzzConfig { + runs: 256, + max_test_rejects: 65536, + seed: None, + dictionary: FuzzDictionaryConfig { + include_storage: true, + include_push_bytes: true, + dictionary_weight: 40, + max_fuzz_dictionary_addresses: 10_000, + max_fuzz_dictionary_values: 10_000, + }, + }) + .invariant(InvariantConfig { + runs: 256, + depth: 15, + fail_on_revert: false, + call_override: false, + dictionary: FuzzDictionaryConfig { + dictionary_weight: 80, + include_storage: true, + include_push_bytes: true, + max_fuzz_dictionary_addresses: 10_000, + max_fuzz_dictionary_values: 10_000, + }, + shrink_sequence: true, + shrink_run_limit: 2usize.pow(18u32), + preserve_state: false, + }) + .build(&COMPILED, &PROJECT.paths.root) + .expect("Config loaded") +}); + pub fn fuzz_executor(executor: Executor) -> FuzzedExecutor { let cfg = proptest::test_runner::Config { failure_persistence: None, ..Default::default() }; @@ -86,6 +121,6 @@ pub fn fuzz_executor(executor: Executor) -> FuzzedExecutor { executor, proptest::test_runner::TestRunner::new(cfg), CALLER, - crate::config::test_opts().fuzz, + TEST_OPTS.fuzz, ) } From e78b947a2ab043d9dd29663e6e6c162ec6a0db95 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Mar 2024 18:29:34 +0200 Subject: [PATCH 0699/1963] chore: remove some unnecessary async/await (#7289) --- crates/cast/bin/cmd/call.rs | 8 ++----- crates/cast/bin/cmd/run.rs | 3 +-- crates/chisel/src/executor.rs | 6 ++--- crates/common/src/compile.rs | 2 +- crates/evm/core/src/backend/mod.rs | 16 +++++-------- crates/evm/core/src/fork/backend.rs | 4 ++-- crates/evm/core/src/fork/multi.rs | 2 +- crates/evm/evm/src/executors/tracing.rs | 4 ++-- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/script/executor.rs | 3 +-- crates/forge/bin/cmd/test/mod.rs | 6 ++--- crates/forge/src/multi_runner.rs | 12 +++++----- crates/forge/tests/it/cheats.rs | 2 +- crates/forge/tests/it/config.rs | 27 +++++++++------------- crates/forge/tests/it/core.rs | 24 ++++++++++---------- crates/forge/tests/it/fork.rs | 14 ++++++------ crates/forge/tests/it/fs.rs | 4 ++-- crates/forge/tests/it/fuzz.rs | 12 +++++----- crates/forge/tests/it/inline.rs | 8 +++---- crates/forge/tests/it/invariant.rs | 30 ++++++++++++------------- crates/forge/tests/it/repros.rs | 4 ++-- crates/forge/tests/it/spec.rs | 2 +- crates/test-utils/src/util.rs | 2 +- 23 files changed, 89 insertions(+), 108 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 3d8afbfd25b9f..ece090bf74ae2 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -140,9 +140,7 @@ impl CallArgs { let (env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; - let mut executor = - foundry_evm::executors::TracingExecutor::new(env, fork, evm_version, debug) - .await; + let mut executor = TracingExecutor::new(env, fork, evm_version, debug); let trace = match executor.deploy( sender, @@ -175,9 +173,7 @@ impl CallArgs { let (env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; - let mut executor = - foundry_evm::executors::TracingExecutor::new(env, fork, evm_version, debug) - .await; + let mut executor = TracingExecutor::new(env, fork, evm_version, debug); let (tx, _) = builder.build(); diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 796368c69ae10..ca83c084d07bd 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -121,8 +121,7 @@ impl RunArgs { let (mut env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; - let mut executor = - TracingExecutor::new(env.clone(), fork, self.evm_version, self.debug).await; + let mut executor = TracingExecutor::new(env.clone(), fork, self.evm_version, self.debug); env.block.number = U256::from(tx_block_number); diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 3b243b7b0ef49..6d76d5b0e896b 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -292,10 +292,8 @@ impl SessionSource { let backend = match self.config.backend.take() { Some(backend) => backend, None => { - let backend = Backend::spawn( - self.config.evm_opts.get_fork(&self.config.foundry_config, env.clone()), - ) - .await; + let fork = self.config.evm_opts.get_fork(&self.config.foundry_config, env.clone()); + let backend = Backend::spawn(fork); self.config.backend = Some(backend.clone()); backend } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 935e098eeefe7..96574f460f257 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -26,7 +26,7 @@ use std::{ /// /// This is merely a wrapper for [`Project::compile()`] which also prints to stdout depending on its /// settings. -#[must_use = "this builder does nothing unless you call a `compile*` method"] +#[must_use = "ProjectCompiler does nothing unless you call a `compile*` method"] pub struct ProjectCompiler { /// Whether we are going to verify the contracts after compilation. verify: Option, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 1ea450d2351ac..5e2c8fdadecb3 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -405,8 +405,8 @@ pub struct Backend { impl Backend { /// Creates a new Backend with a spawned multi fork thread. - pub async fn spawn(fork: Option) -> Self { - Self::new(MultiFork::spawn().await, fork) + pub fn spawn(fork: Option) -> Self { + Self::new(MultiFork::spawn(), fork) } /// Creates a new instance of `Backend` @@ -449,16 +449,11 @@ impl Backend { /// Creates a new instance of `Backend` with fork added to the fork database and sets the fork /// as active - pub(crate) async fn new_with_fork( - id: &ForkId, - fork: Fork, - journaled_state: JournaledState, - ) -> Self { - let mut backend = Self::spawn(None).await; + pub(crate) fn new_with_fork(id: &ForkId, fork: Fork, journaled_state: JournaledState) -> Self { + let mut backend = Self::spawn(None); let fork_ids = backend.inner.insert_new_fork(id.clone(), fork.db, journaled_state); backend.inner.launched_with_fork = Some((id.clone(), fork_ids.0, fork_ids.1)); backend.active_fork_ids = Some(fork_ids); - backend } @@ -1885,8 +1880,7 @@ fn commit_transaction>( let fork = fork.clone(); let journaled_state = journaled_state.clone(); - let db = crate::utils::RuntimeOrHandle::new() - .block_on(async move { Backend::new_with_fork(fork_id, fork, journaled_state).await }); + let db = Backend::new_with_fork(fork_id, fork, journaled_state); evm.database(db); match evm.inspect(inspector) { diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index e319069d065ac..ccf64fd10e769 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -74,7 +74,7 @@ enum BackendRequest { /// /// This handler will remain active as long as it is reachable (request channel still open) and /// requests are in progress. -#[must_use = "BackendHandler does nothing unless polled."] +#[must_use = "futures do nothing unless polled"] pub struct BackendHandler

{ provider: P, /// Stores all the data. @@ -759,7 +759,7 @@ mod tests { evm_opts, }; - let backend = Backend::spawn(Some(fork)).await; + let backend = Backend::spawn(Some(fork)); // some rng contract from etherscan let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index deb0e9f551611..f84af067c0200 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -83,7 +83,7 @@ impl MultiFork { } /// Creates a new pair and spawns the `MultiForkHandler` on a background thread. - pub async fn spawn() -> Self { + pub fn spawn() -> Self { trace!(target: "fork::multi", "spawning multifork"); let (fork, mut handler) = Self::new(); diff --git a/crates/evm/evm/src/executors/tracing.rs b/crates/evm/evm/src/executors/tracing.rs index 19db5fc57755d..5beabdd1de0d4 100644 --- a/crates/evm/evm/src/executors/tracing.rs +++ b/crates/evm/evm/src/executors/tracing.rs @@ -11,13 +11,13 @@ pub struct TracingExecutor { } impl TracingExecutor { - pub async fn new( + pub fn new( env: revm::primitives::Env, fork: Option, version: Option, debug: bool, ) -> Self { - let db = Backend::spawn(fork).await; + let db = Backend::spawn(fork); Self { // configures a bare version of the evm executor: no cheatcode inspector is enabled, // tracing will be enabled only for the targeted transaction diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 718d1079058ad..7acfa8fdf3466 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -313,7 +313,7 @@ impl CoverageArgs { let known_contracts = runner.known_contracts.clone(); let filter = self.filter; let (tx, rx) = channel::<(String, SuiteResult)>(); - let handle = tokio::task::spawn(async move { runner.test(&filter, tx).await }); + let handle = tokio::task::spawn_blocking(move || runner.test(&filter, tx)); // Add hit data to the coverage report let data = rx diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 071cbcbb219d6..a78f5b9f451a0 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -281,7 +281,7 @@ impl ScriptArgs { Some(db) => db.clone(), None => { let fork = script_config.evm_opts.get_fork(&script_config.config, env.clone()); - let backend = Backend::spawn(fork).await; + let backend = Backend::spawn(fork); script_config.backends.insert(url.clone(), backend.clone()); backend } @@ -291,7 +291,6 @@ impl ScriptArgs { // no need to cache it, since there won't be any onchain simulation that we'd need // to cache the backend for. Backend::spawn(script_config.evm_opts.get_fork(&script_config.config, env.clone())) - .await } }; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 0d49b4640671c..2a0e7bbdbbfa8 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -289,7 +289,7 @@ impl TestArgs { } if self.json { - let results = runner.test_collect(filter).await; + let results = runner.test_collect(filter); println!("{}", serde_json::to_string(&results)?); return Ok(TestOutcome::new(results, self.allow_failure)); } @@ -303,9 +303,9 @@ impl TestArgs { // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); let timer = Instant::now(); - let handle = tokio::task::spawn({ + let handle = tokio::task::spawn_blocking({ let filter = filter.clone(); - async move { runner.test(&filter, tx).await } + move || runner.test(&filter, tx) }); let mut gas_report = diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index ea6c79c98374a..6a8e821b23a0f 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -120,8 +120,8 @@ impl MultiContractRunner { /// The same as [`test`](Self::test), but returns the results instead of streaming them. /// /// Note that this method returns only when all tests have been executed. - pub async fn test_collect(&mut self, filter: &dyn TestFilter) -> BTreeMap { - self.test_iter(filter).await.collect() + pub fn test_collect(&mut self, filter: &dyn TestFilter) -> BTreeMap { + self.test_iter(filter).collect() } /// Executes _all_ tests that match the given `filter`. @@ -129,12 +129,12 @@ impl MultiContractRunner { /// The same as [`test`](Self::test), but returns the results instead of streaming them. /// /// Note that this method returns only when all tests have been executed. - pub async fn test_iter( + pub fn test_iter( &mut self, filter: &dyn TestFilter, ) -> impl Iterator { let (tx, rx) = mpsc::channel(); - self.test(filter, tx).await; + self.test(filter, tx); rx.into_iter() } @@ -144,11 +144,11 @@ impl MultiContractRunner { /// before executing all contracts and their tests in _parallel_. /// /// Each Executor gets its own instance of the `Backend`. - pub async fn test(&mut self, filter: &dyn TestFilter, tx: mpsc::Sender<(String, SuiteResult)>) { + pub fn test(&mut self, filter: &dyn TestFilter, tx: mpsc::Sender<(String, SuiteResult)>) { trace!("running all tests"); // The DB backend that serves all the data. - let db = Backend::spawn(self.fork.take()).await; + let db = Backend::spawn(self.fork.take()); let executor = ExecutorBuilder::new() .inspectors(|stack| { stack diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 2959014bc0e14..8fa7ae31e4381 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -20,7 +20,7 @@ async fn test_cheats_local() { let mut config = Config::with_root(PROJECT.root()); config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); - let runner = runner_with_config(config).await; + let runner = runner_with_config(config); TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index c56a626c49a8d..bc56b5c1c2ccd 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -31,8 +31,8 @@ impl TestConfig { Self::with_filter(runner, Filter::matches_all()) } - pub async fn filter(filter: Filter) -> Self { - Self::with_filter(runner().await, filter) + pub fn filter(filter: Filter) -> Self { + Self::with_filter(runner(), filter) } pub fn with_filter(runner: MultiContractRunner, filter: Filter) -> Self { @@ -55,8 +55,8 @@ impl TestConfig { } /// Executes the test runner - pub async fn test(&mut self) -> BTreeMap { - self.runner.test_collect(&self.filter).await + pub fn test(&mut self) -> BTreeMap { + self.runner.test_collect(&self.filter) } pub async fn run(&mut self) { @@ -69,7 +69,7 @@ impl TestConfig { /// * filter matched 0 test cases /// * a test results deviates from the configured `should_fail` setting pub async fn try_run(&mut self) -> eyre::Result<()> { - let suite_result = self.test().await; + let suite_result = self.test(); if suite_result.is_empty() { eyre::bail!("empty test result"); } @@ -127,20 +127,20 @@ pub fn base_runner() -> MultiContractRunnerBuilder { } /// Builds a non-tracing runner -pub async fn runner() -> MultiContractRunner { +pub fn runner() -> MultiContractRunner { let mut config = Config::with_root(PROJECT.root()); config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write(manifest_root())]); - runner_with_config(config).await + runner_with_config(config) } /// Builds a non-tracing runner -pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { +pub fn runner_with_config(mut config: Config) -> MultiContractRunner { config.rpc_endpoints = rpc_endpoints(); config.allow_paths.push(manifest_root().to_path_buf()); let root = &PROJECT.paths.root; let opts = &*EVM_OPTS; - let env = opts.evm_env().await.expect("could not instantiate fork environment"); + let env = opts.local_evm_env(); let output = COMPILED.clone(); base_runner() .with_cheats_config(CheatsConfig::new(&config, opts.clone(), None)) @@ -150,16 +150,11 @@ pub async fn runner_with_config(mut config: Config) -> MultiContractRunner { } /// Builds a tracing runner -pub async fn tracing_runner() -> MultiContractRunner { +pub fn tracing_runner() -> MultiContractRunner { let mut opts = EVM_OPTS.clone(); opts.verbosity = 5; base_runner() - .build( - &PROJECT.paths.root, - (*COMPILED).clone(), - EVM_OPTS.evm_env().await.expect("Could not instantiate fork environment"), - opts, - ) + .build(&PROJECT.paths.root, (*COMPILED).clone(), EVM_OPTS.local_evm_env(), opts) .unwrap() } diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 29ce68c9eedff..f581407d573cf 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -9,8 +9,8 @@ use std::{collections::BTreeMap, env}; #[tokio::test(flavor = "multi_thread")] async fn test_core() { let filter = Filter::new(".*", ".*", ".*core"); - let mut runner = runner().await; - let results = runner.test_collect(&filter).await; + let mut runner = runner(); + let results = runner.test_collect(&filter); assert_multiple( &results, @@ -79,8 +79,8 @@ async fn test_core() { #[tokio::test(flavor = "multi_thread")] async fn test_linking() { let filter = Filter::new(".*", ".*", ".*linking"); - let mut runner = runner().await; - let results = runner.test_collect(&filter).await; + let mut runner = runner(); + let results = runner.test_collect(&filter); assert_multiple( &results, @@ -113,8 +113,8 @@ async fn test_linking() { #[tokio::test(flavor = "multi_thread")] async fn test_logs() { let filter = Filter::new(".*", ".*", ".*logs"); - let mut runner = runner().await; - let results = runner.test_collect(&filter).await; + let mut runner = runner(); + let results = runner.test_collect(&filter); assert_multiple( &results, @@ -678,8 +678,8 @@ async fn test_env_vars() { env::remove_var(env_var_key); let filter = Filter::new("testSetEnv", ".*", ".*"); - let mut runner = runner().await; - let _ = runner.test_collect(&filter).await; + let mut runner = runner(); + let _ = runner.test_collect(&filter); assert_eq!(env::var(env_var_key).unwrap(), env_var_val); } @@ -687,8 +687,8 @@ async fn test_env_vars() { #[tokio::test(flavor = "multi_thread")] async fn test_doesnt_run_abstract_contract() { let filter = Filter::new(".*", ".*", ".*Abstract.t.sol".to_string().as_str()); - let mut runner = runner().await; - let results = runner.test_collect(&filter).await; + let mut runner = runner(); + let results = runner.test_collect(&filter); assert!(results.get("core/Abstract.t.sol:AbstractTestBase").is_none()); assert!(results.get("core/Abstract.t.sol:AbstractTest").is_some()); } @@ -696,8 +696,8 @@ async fn test_doesnt_run_abstract_contract() { #[tokio::test(flavor = "multi_thread")] async fn test_trace() { let filter = Filter::new(".*", ".*", ".*trace"); - let mut runner = tracing_runner().await; - let suite_result = runner.test_collect(&filter).await; + let mut runner = tracing_runner(); + let suite_result = runner.test_collect(&filter); // TODO: This trace test is very basic - it is probably a good candidate for snapshot // testing. diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 76a06e57b6707..da103801c0e32 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -16,8 +16,8 @@ async fn test_cheats_fork_revert() { ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork"), ); - let mut runner = runner().await; - let suite_result = runner.test_collect(&filter).await; + let mut runner = runner(); + let suite_result = runner.test_collect(&filter); assert_eq!(suite_result.len(), 1); for (_, SuiteResult { test_results, .. }) in suite_result { @@ -38,7 +38,7 @@ async fn test_cheats_fork() { let runner = runner_with_config(config); let filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); - TestConfig::with_filter(runner.await, filter).run().await; + TestConfig::with_filter(runner, filter).run().await; } /// Executes eth_getLogs cheatcode @@ -49,7 +49,7 @@ async fn test_get_logs_fork() { let runner = runner_with_config(config); let filter = Filter::new("testEthGetLogs", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); - TestConfig::with_filter(runner.await, filter).run().await; + TestConfig::with_filter(runner, filter).run().await; } /// Executes rpc cheatcode @@ -60,7 +60,7 @@ async fn test_rpc_fork() { let runner = runner_with_config(config); let filter = Filter::new("testRpc", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); - TestConfig::with_filter(runner.await, filter).run().await; + TestConfig::with_filter(runner, filter).run().await; } /// Tests that we can launch in forking mode @@ -85,12 +85,12 @@ async fn test_launch_fork_ws() { #[tokio::test(flavor = "multi_thread")] async fn test_transact_fork() { let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Transact")); - TestConfig::filter(filter).await.run().await; + TestConfig::filter(filter).run().await; } /// Tests that we can create the same fork (provider,block) concurretnly in different tests #[tokio::test(flavor = "multi_thread")] async fn test_create_same_fork() { let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}ForkSame")); - TestConfig::filter(filter).await.run().await; + TestConfig::filter(filter).run().await; } diff --git a/crates/forge/tests/it/fs.rs b/crates/forge/tests/it/fs.rs index 29affe05c8519..72ae2cb32fe4f 100644 --- a/crates/forge/tests/it/fs.rs +++ b/crates/forge/tests/it/fs.rs @@ -8,7 +8,7 @@ use foundry_test_utils::Filter; async fn test_fs_disabled() { let mut config = Config::with_root(PROJECT.root()); config.fs_permissions = FsPermissions::new(vec![PathPermission::none("./")]); - let runner = runner_with_config(config).await; + let runner = runner_with_config(config); let filter = Filter::new(".*", ".*", ".*fs/Disabled"); TestConfig::with_filter(runner, filter).run().await; } @@ -19,5 +19,5 @@ async fn test_fs_default() { config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); let runner = runner_with_config(config); let filter = Filter::new(".*", ".*", ".*fs/Default"); - TestConfig::with_filter(runner.await, filter).run().await; + TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 011497f4ce471..14a27d6b442a1 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -11,8 +11,8 @@ async fn test_fuzz() { let filter = Filter::new(".*", ".*", ".*fuzz/") .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)|testSuccessChecker\(uint256\)|testSuccessChecker2\(int256\)|testSuccessChecker3\(uint32\)") .exclude_paths("invariant"); - let mut runner = runner().await; - let suite_result = runner.test_collect(&filter).await; + let mut runner = runner(); + let suite_result = runner.test_collect(&filter); assert!(!suite_result.is_empty()); @@ -48,8 +48,8 @@ async fn test_successful_fuzz_cases() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzPositive") .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)") .exclude_paths("invariant"); - let mut runner = runner().await; - let suite_result = runner.test_collect(&filter).await; + let mut runner = runner(); + let suite_result = runner.test_collect(&filter); assert!(!suite_result.is_empty()); @@ -78,12 +78,12 @@ async fn test_successful_fuzz_cases() { #[ignore] async fn test_fuzz_collection() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzCollection.t.sol"); - let mut runner = runner().await; + let mut runner = runner(); runner.test_options.invariant.depth = 100; runner.test_options.invariant.runs = 1000; runner.test_options.fuzz.runs = 1000; runner.test_options.fuzz.seed = Some(U256::from(6u32)); - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); assert_multiple( &results, diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 3503606d7088b..3e7b4616380a8 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -14,8 +14,8 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - let mut runner = runner().await; - let result = runner.test_collect(&filter).await; + let mut runner = runner(); + let result = runner.test_collect(&filter); let suite_result: &SuiteResult = result.get("inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); let test_result: &TestResult = @@ -35,9 +35,9 @@ async fn inline_config_run_invariant() { const ROOT: &str = "inline/InvariantInlineConf.t.sol"; let filter = Filter::new(".*", ".*", ".*inline/InvariantInlineConf.t.sol"); - let mut runner = runner().await; + let mut runner = runner(); runner.test_options = default_test_options(); - let result = runner.test_collect(&filter).await; + let result = runner.test_collect(&filter); let suite_result_1 = result.get(&format!("{ROOT}:InvariantInlineConf")).expect("Result exists"); let suite_result_2 = diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index b5132fefab9fd..6178893716cd2 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -9,8 +9,8 @@ use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] async fn test_invariant() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"); - let mut runner = runner().await; - let results = runner.test_collect(&filter).await; + let mut runner = runner(); + let results = runner.test_collect(&filter); assert_multiple( &results, @@ -144,9 +144,9 @@ async fn test_invariant() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_override() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantReentrancy.t.sol"); - let mut runner = runner().await; + let mut runner = runner(); runner.test_options.invariant.call_override = true; - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); assert_multiple( &results, @@ -160,11 +160,11 @@ async fn test_invariant_override() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_fail_on_revert() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantHandlerFailure.t.sol"); - let mut runner = runner().await; + let mut runner = runner(); runner.test_options.invariant.fail_on_revert = true; runner.test_options.invariant.runs = 1; runner.test_options.invariant.depth = 10; - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); assert_multiple( &results, @@ -185,10 +185,10 @@ async fn test_invariant_fail_on_revert() { #[ignore] async fn test_invariant_storage() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/storage/InvariantStorageTest.t.sol"); - let mut runner = runner().await; + let mut runner = runner(); runner.test_options.invariant.depth = 100 + (50 * cfg!(windows) as u32); runner.test_options.fuzz.seed = Some(U256::from(6u32)); - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); assert_multiple( &results, @@ -208,9 +208,9 @@ async fn test_invariant_storage() { #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); - let mut runner = runner().await; + let mut runner = runner(); runner.test_options.fuzz.seed = Some(U256::from(119u32)); - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); let results = results.values().last().expect("`InvariantInnerContract.t.sol` should be testable."); @@ -264,9 +264,9 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { contract_pattern, ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol", ); - let mut runner = runner().await; + let mut runner = runner(); runner.test_options = opts.clone(); - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); let results = results.values().last().expect("`InvariantShrinkWithAssert` should be testable."); let result = results @@ -293,10 +293,10 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_preserve_state() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"); - let mut runner = runner().await; + let mut runner = runner(); // Should not fail with default options. runner.test_options.invariant.fail_on_revert = true; - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([( @@ -308,7 +308,7 @@ async fn test_invariant_preserve_state() { // same test should revert when preserve state enabled runner.test_options.invariant.fail_on_revert = true; runner.test_options.invariant.preserve_state = true; - let results = runner.test_collect(&filter).await; + let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([( diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 8506a248de017..d8b4447cfb9eb 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -32,7 +32,7 @@ macro_rules! test_repro { paste::paste! { #[tokio::test(flavor = "multi_thread")] async fn [< issue_ $issue_number >]() { - let mut $res = repro_config($issue_number, $should_fail, $sender.into()).await.test().await; + let mut $res = repro_config($issue_number, $should_fail, $sender.into()).await.test(); $e } } @@ -60,7 +60,7 @@ async fn repro_config(issue: usize, should_fail: bool, sender: Option

) config.sender = sender; } - let runner = runner_with_config(config).await; + let runner = runner_with_config(config); TestConfig::with_filter(runner, filter).set_should_fail(should_fail) } diff --git a/crates/forge/tests/it/spec.rs b/crates/forge/tests/it/spec.rs index 724aaa0ff4ffd..4dd6aeee50b1a 100644 --- a/crates/forge/tests/it/spec.rs +++ b/crates/forge/tests/it/spec.rs @@ -7,5 +7,5 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_shanghai_compat() { let filter = Filter::new("", "ShanghaiCompat", ".*spec"); - TestConfig::filter(filter).await.evm_spec(SpecId::SHANGHAI).run().await; + TestConfig::filter(filter).evm_spec(SpecId::SHANGHAI).run().await; } diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index a269364893144..48b3562b24267 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -51,7 +51,7 @@ pub const OTHER_SOLC_VERSION: &str = "0.8.22"; /// External test builder #[derive(Clone, Debug)] -#[must_use = "call run()"] +#[must_use = "ExtTester does nothing unless you `run` it"] pub struct ExtTester { pub org: &'static str, pub name: &'static str, From de33b6af53005037b463318d2628b5cfcaf39916 Mon Sep 17 00:00:00 2001 From: Steve <1848680+misko9@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:36:07 -0700 Subject: [PATCH 0700/1963] feat: add unsafe-password support to cast wallet import (#6671) * feat: add unsafe-password support to cast wallet import * rustfmt fix * Change env CAST_PASSWORD to CAST_UNSAFE_PASSWORD for `cast wallet import` --------- Co-authored-by: Steve Miskovetz --- crates/cast/bin/cmd/wallet/mod.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 9a08984d7ae9b..931ecefa483a9 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -136,6 +136,10 @@ pub enum WalletSubcommands { /// (~/.foundry/keystores) #[arg(long, short)] keystore_dir: Option, + /// Password for the JSON keystore in cleartext + /// This is unsafe, we recommend using the default hidden password prompt + #[arg(long, env = "CAST_UNSAFE_PASSWORD", value_name = "PASSWORD")] + unsafe_password: Option, #[command(flatten)] raw_wallet_options: RawWalletOpts, }, @@ -282,7 +286,12 @@ impl WalletSubcommands { println!("Validation failed. Address {address} did not sign this message."); } } - WalletSubcommands::Import { account_name, keystore_dir, raw_wallet_options } => { + WalletSubcommands::Import { + account_name, + keystore_dir, + unsafe_password, + raw_wallet_options, + } => { // Set up keystore directory let dir = if let Some(path) = keystore_dir { Path::new(&path).to_path_buf() @@ -318,7 +327,12 @@ flag to set your key via: })?; let private_key = wallet.signer().to_bytes(); - let password = rpassword::prompt_password("Enter password: ")?; + let password = if let Some(password) = unsafe_password { + password + } else { + // if no --unsafe-password was provided read via stdin + rpassword::prompt_password("Enter password: ")? + }; let mut rng = thread_rng(); eth_keystore::encrypt_key( From f6fcfa500c0d0738a78c75de3e133184b9ffca0e Mon Sep 17 00:00:00 2001 From: Enrique Date: Sat, 2 Mar 2024 04:02:51 -0400 Subject: [PATCH 0701/1963] chore: doc fixes and rm unused stuff on common (#7291) --- crates/common/src/provider/alloy.rs | 12 ------------ crates/common/src/provider/retry.rs | 3 ++- crates/common/src/provider/runtime_transport.rs | 5 +---- crates/common/src/provider/tower.rs | 5 ++--- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/crates/common/src/provider/alloy.rs b/crates/common/src/provider/alloy.rs index bb52778145e9f..d51be9f9ac44b 100644 --- a/crates/common/src/provider/alloy.rs +++ b/crates/common/src/provider/alloy.rs @@ -203,18 +203,6 @@ impl ProviderBuilder { self } - /// Same as [`Self:build()`] but also retrieves the `chainId` in order to derive an appropriate - /// interval. - pub async fn connect(self) -> Result { - let provider = self.build()?; - // todo: port poll interval hint - /*if let Some(blocktime) = provider.get_chainid().await.ok().and_then(|id| { - }) { - provider = provider.interval(blocktime / 2); - }*/ - Ok(provider) - } - /// Constructs the `RetryProvider` taking all configs into account. pub fn build(self) -> Result { let ProviderBuilder { diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index fd8a33e42da5c..2137dedbdc68e 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -3,7 +3,7 @@ use alloy_json_rpc::ErrorPayload; use alloy_transport::{TransportError, TransportErrorKind}; use serde::Deserialize; -/// [RetryPolicy] defines logic for which [JsonRpcClient::Error] instances should +/// [RetryPolicy] defines logic for which [TransportError] instances should /// the client retry the request and try to recover from. pub trait RetryPolicy: Send + Sync + std::fmt::Debug { /// Whether to retry the request based on the given `error` @@ -52,6 +52,7 @@ impl RetryPolicy for RateLimitRetryPolicy { } } + /// Provides a backoff hint if the error response contains it fn backoff_hint(&self, error: &TransportError) -> Option { if let TransportError::ErrorResp(resp) = error { let data = resp.try_data_as::(); diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index eab2addb81dda..5c2eededfcb02 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -25,7 +25,6 @@ pub enum InnerTransport { Http(Http), /// WebSocket transport Ws(PubSubFrontend), - // TODO: IPC /// IPC transport Ipc(PubSubFrontend), } @@ -177,7 +176,6 @@ impl RuntimeTransport { let client = client_builder.build().map_err(RuntimeTransportError::HttpConstructionError)?; - // todo: retry tower layer Ok(InnerTransport::Http(Http::with_client(client, self.url.clone()))) } @@ -271,7 +269,7 @@ impl tower::Service for RuntimeTransport { } } -impl Service for &RuntimeTransport { +impl tower::Service for &RuntimeTransport { type Response = ResponsePacket; type Error = TransportError; type Future = TransportFut<'static>; @@ -297,7 +295,6 @@ fn build_auth(jwt: String) -> eyre::Result { let auth = JwtAuth::new(secret, None, None); let token = auth.generate_token()?; - // Essentially unrolled ethers-rs new_with_auth to accommodate the custom timeout let auth = Authorization::Bearer(token); Ok(auth) diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs index 0df22bb01e8cc..2f97d2f8fbd11 100644 --- a/crates/common/src/provider/tower.rs +++ b/crates/common/src/provider/tower.rs @@ -10,7 +10,6 @@ use std::{ use alloy_json_rpc::{RequestPacket, ResponsePacket}; use alloy_transport::{TransportError, TransportErrorKind, TransportFut}; -use tower::Service; use super::{ retry::{RateLimitRetryPolicy, RetryPolicy}, @@ -65,7 +64,7 @@ impl tower::layer::Layer for RetryBackoffLayer { } /// An Alloy Tower Service that is responsible for retrying requests based on the -/// error type. See [TransportError] and [RetryWithPolicyLayer]. +/// error type. See [TransportError] and [RateLimitRetryPolicy]. #[derive(Debug, Clone)] pub struct RetryBackoffService { /// The inner service @@ -85,7 +84,7 @@ pub struct RetryBackoffService { } // impl tower service -impl Service for RetryBackoffService { +impl tower::Service for RetryBackoffService { type Response = ResponsePacket; type Error = TransportError; type Future = TransportFut<'static>; From 1b6d0fab362cf184997c420b96ccc8221a3ab4cb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:15:19 +0200 Subject: [PATCH 0702/1963] test: modify some flaky tests (#7293) --- crates/forge/tests/cli/build.rs | 18 ++---------------- crates/forge/tests/cli/cmd.rs | 5 ++--- crates/test-utils/src/util.rs | 6 ++++++ 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 240b5461442c8..0002ec14529d6 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -28,20 +28,6 @@ contract Dummy { // tests build output is as expected forgetest_init!(exact_build_output, |prj, cmd| { cmd.args(["build", "--force"]); - let (stdout, _) = cmd.unchecked_output_lossy(); - // Expected output from build - let expected = r#"Compiling 24 files with 0.8.23 -Solc 0.8.23 finished in 2.36s -Compiler run successful! -"#; - - // skip all dynamic parts of the output (numbers) - let expected_words = - expected.split(|c: char| c == ' ').filter(|w| !w.chars().next().unwrap().is_numeric()); - let output_words = - stdout.split(|c: char| c == ' ').filter(|w| !w.chars().next().unwrap().is_numeric()); - - for (expected, output) in expected_words.zip(output_words) { - assert_eq!(expected, output, "expected: {}, output: {}", expected, output); - } + let stdout = cmd.stdout_lossy(); + assert!(stdout.contains("Compiling"), "\n{stdout}"); }); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 18877265772c3..48e86d9df7af3 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1556,7 +1556,7 @@ forgetest_init!(can_install_missing_deps_build, |prj, cmd| { // checks that extra output works forgetest_init!(can_build_skip_contracts, |prj, cmd| { - prj.clear_cache(); + prj.clear(); // only builds the single template contract `src/*` cmd.args(["build", "--skip", "tests", "--skip", "scripts"]); @@ -1573,8 +1573,6 @@ forgetest_init!(can_build_skip_contracts, |prj, cmd| { }); forgetest_init!(can_build_skip_glob, |prj, cmd| { - prj.clear_cache(); - prj.add_test( "Foo", r" @@ -1585,6 +1583,7 @@ function test_run() external {} .unwrap(); // only builds the single template contract `src/*` even if `*.t.sol` or `.s.sol` is absent + prj.clear(); cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**"]); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_build_skip_glob.stdout"), diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 48b3562b24267..6a6f15d0f0b15 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -444,6 +444,12 @@ impl TestProject { &self.paths().artifacts } + /// Removes the project's cache and artifacts directory. + pub fn clear(&self) { + self.clear_cache(); + self.clear_artifacts(); + } + /// Removes this project's cache file. pub fn clear_cache(&self) { let _ = fs::remove_file(self.cache()); From 2d54c1fbe83092596ff542d2bec9a70b478031b7 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:54:43 +0200 Subject: [PATCH 0703/1963] feat invariant (#5868) - configure calldata fuzzed addresses dictionary (#7240) * issue #5868 - added `FuzzDictionaryConfig.max_calldata_fuzz_dictionary_addresses` option to specify how many random addresses to generate and to randomly select from when fuzzing calldata. If option is not specified then current behavior applies - to narrow down number of runs / addresses involved in invariant test the `CalldataFuzzDictionaryConfig` is populated with random addresses plus all accounts from db (from `EvmFuzzState`) - added `fuzz_calldata_with_config` fn that accepts `Option` as param. Non invariants tests use existing `fuzz_calldata` fn and pass None as config arg * max_calldata_fuzz_dictionary_addresses usize * Add test from issue 5868 * Changes after review - comments, wrap Arc as CalldataFuzzDictionary.inner, code cleanup --- crates/config/src/fuzz.rs | 5 ++ crates/evm/evm/src/executors/invariant/mod.rs | 20 ++++- crates/evm/fuzz/src/strategies/calldata.rs | 73 +++++++++++++++- crates/evm/fuzz/src/strategies/invariants.rs | 34 ++++++-- crates/evm/fuzz/src/strategies/mod.rs | 4 +- crates/evm/fuzz/src/strategies/param.rs | 52 +++++++++--- crates/forge/tests/it/invariant.rs | 44 ++++++++++ crates/forge/tests/it/test_helpers.rs | 2 + .../common/InvariantCalldataDictionary.t.sol | 84 +++++++++++++++++++ 9 files changed, 291 insertions(+), 27 deletions(-) create mode 100644 testdata/fuzz/invariant/common/InvariantCalldataDictionary.t.sol diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index 1d033b3ef18d5..11d214670488c 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -86,6 +86,10 @@ pub struct FuzzDictionaryConfig { /// Once the fuzzer exceeds this limit, it will start evicting random entries #[serde(deserialize_with = "crate::deserialize_usize_or_max")] pub max_fuzz_dictionary_values: usize, + /// How many random addresses to use and to recycle when fuzzing calldata. + /// If not specified then `max_fuzz_dictionary_addresses` value applies. + #[serde(deserialize_with = "crate::deserialize_usize_or_max")] + pub max_calldata_fuzz_dictionary_addresses: usize, } impl Default for FuzzDictionaryConfig { @@ -98,6 +102,7 @@ impl Default for FuzzDictionaryConfig { max_fuzz_dictionary_addresses: (300 * 1024 * 1024) / 20, // limit this to 200MB max_fuzz_dictionary_values: (200 * 1024 * 1024) / 32, + max_calldata_fuzz_dictionary_addresses: 0, } } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 316db1320eede..79d055eab8c28 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -33,13 +33,18 @@ use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; mod error; pub use error::{InvariantFailures, InvariantFuzzError, InvariantFuzzTestResult}; +use foundry_evm_fuzz::strategies::CalldataFuzzDictionary; mod funcs; pub use funcs::{assert_invariants, replay_run}; /// Alias for (Dictionary for fuzzing, initial contracts to fuzz and an InvariantStrategy). -type InvariantPreparation = - (EvmFuzzState, FuzzRunIdentifiedContracts, BoxedStrategy>); +type InvariantPreparation = ( + EvmFuzzState, + FuzzRunIdentifiedContracts, + BoxedStrategy>, + CalldataFuzzDictionary, +); /// Enriched results of an invariant run check. /// @@ -104,7 +109,8 @@ impl<'a> InvariantExecutor<'a> { return Err(eyre!("Invariant test function should have no inputs")) } - let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract)?; + let (fuzz_state, targeted_contracts, strat, calldata_fuzz_dictionary) = + self.prepare_fuzzing(&invariant_contract)?; // Stores the consumed gas and calldata of every successful fuzz call. let fuzz_cases: RefCell> = RefCell::new(Default::default()); @@ -245,6 +251,7 @@ impl<'a> InvariantExecutor<'a> { Ok(()) }); + trace!(target: "forge::test::invariant::calldata_address_fuzz_dictionary", "{:?}", calldata_fuzz_dictionary.inner.addresses); trace!(target: "forge::test::invariant::dictionary", "{:?}", fuzz_state.read().values().iter().map(hex::encode).collect::>()); let (reverts, error) = failures.into_inner().into_inner(); @@ -283,12 +290,16 @@ impl<'a> InvariantExecutor<'a> { let targeted_contracts: FuzzRunIdentifiedContracts = Arc::new(Mutex::new(targeted_contracts)); + let calldata_fuzz_config = + CalldataFuzzDictionary::new(&self.config.dictionary, fuzz_state.clone()); + // Creates the invariant strategy. let strat = invariant_strat( fuzz_state.clone(), targeted_senders, targeted_contracts.clone(), self.config.dictionary.dictionary_weight, + calldata_fuzz_config.clone(), ) .no_shrink() .boxed(); @@ -306,6 +317,7 @@ impl<'a> InvariantExecutor<'a> { fuzz_state.clone(), targeted_contracts.clone(), target_contract_ref.clone(), + calldata_fuzz_config.clone(), ), target_contract_ref, )); @@ -314,7 +326,7 @@ impl<'a> InvariantExecutor<'a> { self.executor.inspector.fuzzer = Some(Fuzzer { call_generator, fuzz_state: fuzz_state.clone(), collect: true }); - Ok((fuzz_state, targeted_contracts, strat)) + Ok((fuzz_state, targeted_contracts, strat, calldata_fuzz_config)) } /// Fills the `InvariantExecutor` with the artifact identifier filters (in `path:name` string diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index 7a1566243cdea..cb56f3330b0dc 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -1,18 +1,85 @@ -use super::fuzz_param; +use crate::strategies::{fuzz_param, EvmFuzzState}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use alloy_primitives::Bytes; +use alloy_primitives::{Address, Bytes}; +use foundry_config::FuzzDictionaryConfig; +use hashbrown::HashSet; use proptest::prelude::{BoxedStrategy, Strategy}; +use std::{fmt, sync::Arc}; + +/// Clonable wrapper around [CalldataFuzzDictionary]. +#[derive(Debug, Clone)] +pub struct CalldataFuzzDictionary { + pub inner: Arc, +} + +impl CalldataFuzzDictionary { + pub fn new(config: &FuzzDictionaryConfig, state: EvmFuzzState) -> Self { + Self { inner: Arc::new(CalldataFuzzDictionaryConfig::new(config, state)) } + } +} + +#[derive(Clone)] +pub struct CalldataFuzzDictionaryConfig { + /// Addresses that can be used for fuzzing calldata. + pub addresses: Vec
, +} + +impl fmt::Debug for CalldataFuzzDictionaryConfig { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("CalldataFuzzDictionaryConfig").field("addresses", &self.addresses).finish() + } +} + +/// Represents custom configuration for invariant fuzzed calldata strategies. +/// +/// At the moment only the dictionary of addresses to be used for a fuzzed `function(address)` can +/// be configured, but support for other types can be added. +impl CalldataFuzzDictionaryConfig { + /// Creates config with the set of addresses that can be used for fuzzing invariant calldata (if + /// `max_calldata_fuzz_dictionary_addresses` configured). + /// The set of addresses contains a number of `max_calldata_fuzz_dictionary_addresses` random + /// addresses plus all addresses that already had their PUSH bytes collected (retrieved from + /// `EvmFuzzState`, if `include_push_bytes` config enabled). + pub fn new(config: &FuzzDictionaryConfig, state: EvmFuzzState) -> Self { + let mut addresses: HashSet
= HashSet::new(); + let dict_size = config.max_calldata_fuzz_dictionary_addresses; + + if dict_size > 0 { + loop { + if addresses.len() == dict_size { + break + } + addresses.insert(Address::random()); + } + + // Add all addresses that already had their PUSH bytes collected. + let mut state = state.write(); + addresses.extend(state.addresses()); + } + + Self { addresses: Vec::from_iter(addresses) } + } +} /// Given a function, it returns a strategy which generates valid calldata /// for that function's input types. pub fn fuzz_calldata(func: Function) -> BoxedStrategy { + fuzz_calldata_with_config(func, None) +} + +/// Given a function, it returns a strategy which generates valid calldata +/// for that function's input types, following custom configuration rules. +pub fn fuzz_calldata_with_config( + func: Function, + config: Option, +) -> BoxedStrategy { // We need to compose all the strategies generated for each parameter in all // possible combinations let strats = func .inputs .iter() - .map(|input| fuzz_param(&input.selector_type().parse().unwrap())) + .map(|input| fuzz_param(&input.selector_type().parse().unwrap(), config.clone())) .collect::>(); strats diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index d095f10092851..29d868bad44d6 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -1,7 +1,7 @@ -use super::fuzz_param_from_state; +use super::{fuzz_calldata_with_config, fuzz_param_from_state, CalldataFuzzDictionary}; use crate::{ invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, SenderFilters}, - strategies::{fuzz_calldata, fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, + strategies::{fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, }; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes}; @@ -14,6 +14,7 @@ pub fn override_call_strat( fuzz_state: EvmFuzzState, contracts: FuzzRunIdentifiedContracts, target: Arc>, + calldata_fuzz_config: CalldataFuzzDictionary, ) -> SBoxedStrategy<(Address, Bytes)> { let contracts_ref = contracts.clone(); @@ -27,10 +28,16 @@ pub fn override_call_strat( ]) .prop_flat_map(move |target_address| { let fuzz_state = fuzz_state.clone(); + let calldata_fuzz_config = calldata_fuzz_config.clone(); let (_, abi, functions) = contracts.lock().get(&target_address).unwrap().clone(); let func = select_random_function(abi, functions); func.prop_flat_map(move |func| { - fuzz_contract_with_calldata(fuzz_state.clone(), target_address, func) + fuzz_contract_with_calldata( + fuzz_state.clone(), + calldata_fuzz_config.clone(), + target_address, + func, + ) }) }) .sboxed() @@ -51,10 +58,12 @@ pub fn invariant_strat( senders: SenderFilters, contracts: FuzzRunIdentifiedContracts, dictionary_weight: u32, + calldata_fuzz_config: CalldataFuzzDictionary, ) -> impl Strategy> { // We only want to seed the first value, since we want to generate the rest as we mutate the // state - generate_call(fuzz_state, senders, contracts, dictionary_weight).prop_map(|x| vec![x]) + generate_call(fuzz_state, senders, contracts, dictionary_weight, calldata_fuzz_config) + .prop_map(|x| vec![x]) } /// Strategy to generate a transaction where the `sender`, `target` and `calldata` are all generated @@ -64,6 +73,7 @@ fn generate_call( senders: SenderFilters, contracts: FuzzRunIdentifiedContracts, dictionary_weight: u32, + calldata_fuzz_config: CalldataFuzzDictionary, ) -> BoxedStrategy { let random_contract = select_random_contract(contracts); let senders = Rc::new(senders); @@ -72,10 +82,19 @@ fn generate_call( let func = select_random_function(abi, functions); let senders = senders.clone(); let fuzz_state = fuzz_state.clone(); + let calldata_fuzz_config = calldata_fuzz_config.clone(); func.prop_flat_map(move |func| { let sender = select_random_sender(fuzz_state.clone(), senders.clone(), dictionary_weight); - (sender, fuzz_contract_with_calldata(fuzz_state.clone(), contract, func)) + ( + sender, + fuzz_contract_with_calldata( + fuzz_state.clone(), + calldata_fuzz_config.clone(), + contract, + func, + ), + ) }) }) .boxed() @@ -93,7 +112,7 @@ fn select_random_sender( let fuzz_strategy = proptest::strategy::Union::new_weighted(vec![ ( 100 - dictionary_weight, - fuzz_param(&alloy_dyn_abi::DynSolType::Address) + fuzz_param(&alloy_dyn_abi::DynSolType::Address, None) .prop_map(move |addr| addr.as_address().unwrap()) .boxed(), ), @@ -165,6 +184,7 @@ fn select_random_function( /// for that function's input types. pub fn fuzz_contract_with_calldata( fuzz_state: EvmFuzzState, + calldata_fuzz_config: CalldataFuzzDictionary, contract: Address, func: Function, ) -> impl Strategy { @@ -173,7 +193,7 @@ pub fn fuzz_contract_with_calldata( // `prop_oneof!` / `TupleUnion` `Arc`s for cheap cloning #[allow(clippy::arc_with_non_send_sync)] let strats = prop_oneof![ - 60 => fuzz_calldata(func.clone()), + 60 => fuzz_calldata_with_config(func.clone(), Some(calldata_fuzz_config)), 40 => fuzz_calldata_from_state(func, fuzz_state), ]; strats.prop_map(move |calldata| { diff --git a/crates/evm/fuzz/src/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs index a795905de95ac..63e008ec0c96a 100644 --- a/crates/evm/fuzz/src/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -8,7 +8,9 @@ mod param; pub use param::{fuzz_param, fuzz_param_from_state}; mod calldata; -pub use calldata::fuzz_calldata; +pub use calldata::{ + fuzz_calldata, fuzz_calldata_with_config, CalldataFuzzDictionary, CalldataFuzzDictionaryConfig, +}; mod state; pub use state::{ diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 093cb29c8b426..4c8dc03eca9e7 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -1,4 +1,5 @@ use super::state::EvmFuzzState; +use crate::strategies::calldata::CalldataFuzzDictionary; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{Address, FixedBytes, I256, U256}; use arbitrary::Unstructured; @@ -10,12 +11,32 @@ const MAX_ARRAY_LEN: usize = 256; /// Given a parameter type, returns a strategy for generating values for that type. /// /// Works with ABI Encoder v2 tuples. -pub fn fuzz_param(param: &DynSolType) -> BoxedStrategy { +pub fn fuzz_param( + param: &DynSolType, + config: Option, +) -> BoxedStrategy { let param = param.to_owned(); match param { - DynSolType::Address => any::<[u8; 32]>() - .prop_map(|x| DynSolValue::Address(Address::from_word(x.into()))) - .boxed(), + DynSolType::Address => { + if config.is_some() { + let fuzz_config = config.unwrap().inner; + let address_dict_len = fuzz_config.addresses.len(); + if address_dict_len > 0 { + // Create strategy to return random address from configured dictionary. + return any::() + .prop_map(move |index| index.index(address_dict_len)) + .prop_map(move |index| { + DynSolValue::Address(fuzz_config.addresses.get(index).cloned().unwrap()) + }) + .boxed() + } + } + + // If no config for addresses dictionary then create unbounded addresses strategy. + any::<[u8; 32]>() + .prop_map(|x| DynSolValue::Address(Address::from_word(x.into()))) + .boxed() + } DynSolType::Int(n) => { let strat = super::IntStrategy::new(n, vec![]); let strat = strat.prop_map(move |x| DynSolValue::Int(x, n)); @@ -48,15 +69,22 @@ pub fn fuzz_param(param: &DynSolType) -> BoxedStrategy { ) }) .boxed(), - DynSolType::Tuple(params) => { - params.iter().map(fuzz_param).collect::>().prop_map(DynSolValue::Tuple).boxed() - } - DynSolType::FixedArray(param, size) => proptest::collection::vec(fuzz_param(¶m), size) - .prop_map(DynSolValue::FixedArray) - .boxed(), - DynSolType::Array(param) => proptest::collection::vec(fuzz_param(¶m), 0..MAX_ARRAY_LEN) - .prop_map(DynSolValue::Array) + DynSolType::Tuple(params) => params + .iter() + .map(|p| fuzz_param(p, config.clone())) + .collect::>() + .prop_map(DynSolValue::Tuple) .boxed(), + DynSolType::FixedArray(param, size) => { + proptest::collection::vec(fuzz_param(¶m, config), size) + .prop_map(DynSolValue::FixedArray) + .boxed() + } + DynSolType::Array(param) => { + proptest::collection::vec(fuzz_param(¶m, config), 0..MAX_ARRAY_LEN) + .prop_map(DynSolValue::Array) + .boxed() + } DynSolType::CustomStruct { .. } => panic!("unsupported type"), } } diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 6178893716cd2..28ac405cc351a 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -137,6 +137,10 @@ async fn test_invariant() { "fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", vec![("invariant_preserve_state()", true, None, None, None)], ), + ( + "fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", + vec![("invariant_owner_never_changes()", true, None, None, None)], + ), ]), ); } @@ -323,3 +327,43 @@ async fn test_invariant_preserve_state() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_calldata_fuzz_dictionary_addresses() { + // should not fail with default options (address dict not finite) + let mut runner = runner(); + let results = runner.test_collect(&Filter::new( + ".*", + ".*", + ".*fuzz/invariant/common/InvariantCalldataDictionary.t.sol", + )); + assert_multiple( + &results, + BTreeMap::from([( + "fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", + vec![("invariant_owner_never_changes()", true, None, None, None)], + )]), + ); + + // same test should fail when calldata address dict is bounded + // set address dictionary to single entry to fail fast + runner.test_options.invariant.dictionary.max_calldata_fuzz_dictionary_addresses = 1; + let results = runner.test_collect(&Filter::new( + ".*", + ".*", + ".*fuzz/invariant/common/InvariantCalldataDictionary.t.sol", + )); + assert_multiple( + &results, + BTreeMap::from([( + "fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", + vec![( + "invariant_owner_never_changes()", + false, + Some("".into()), + None, + None, + )], + )]), + ); +} diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 873e3071f723b..968a0928070e5 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -92,6 +92,7 @@ pub static TEST_OPTS: Lazy = Lazy::new(|| { dictionary_weight: 40, max_fuzz_dictionary_addresses: 10_000, max_fuzz_dictionary_values: 10_000, + max_calldata_fuzz_dictionary_addresses: 0, }, }) .invariant(InvariantConfig { @@ -105,6 +106,7 @@ pub static TEST_OPTS: Lazy = Lazy::new(|| { include_push_bytes: true, max_fuzz_dictionary_addresses: 10_000, max_fuzz_dictionary_values: 10_000, + max_calldata_fuzz_dictionary_addresses: 0, }, shrink_sequence: true, shrink_run_limit: 2usize.pow(18u32), diff --git a/testdata/fuzz/invariant/common/InvariantCalldataDictionary.t.sol b/testdata/fuzz/invariant/common/InvariantCalldataDictionary.t.sol new file mode 100644 index 0000000000000..c8f87a600b6d0 --- /dev/null +++ b/testdata/fuzz/invariant/common/InvariantCalldataDictionary.t.sol @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../../../cheats/Vm.sol"; + +struct FuzzSelector { + address addr; + bytes4[] selectors; +} + +// https://github.com/foundry-rs/foundry/issues/5868 +contract Owned { + address public owner; + address private ownerCandidate; + + constructor() { + owner = msg.sender; + } + + modifier onlyOwner() { + require(msg.sender == owner); + _; + } + + modifier onlyOwnerCandidate() { + require(msg.sender == ownerCandidate); + _; + } + + function transferOwnership(address candidate) external onlyOwner { + ownerCandidate = candidate; + } + + function acceptOwnership() external onlyOwnerCandidate { + owner = ownerCandidate; + } +} + +contract Handler is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Owned owned; + + constructor(Owned _owned) { + owned = _owned; + } + + function transferOwnership(address sender, address candidate) external { + vm.assume(sender != address(0)); + vm.prank(sender); + owned.transferOwnership(candidate); + } + + function acceptOwnership(address sender) external { + vm.assume(sender != address(0)); + vm.prank(sender); + owned.acceptOwnership(); + } +} + +contract InvariantCalldataDictionary is DSTest { + address owner; + Owned owned; + Handler handler; + + function setUp() public { + owner = address(this); + owned = new Owned(); + handler = new Handler(owned); + } + + function targetSelectors() public returns (FuzzSelector[] memory) { + FuzzSelector[] memory targets = new FuzzSelector[](1); + bytes4[] memory selectors = new bytes4[](2); + selectors[0] = handler.transferOwnership.selector; + selectors[1] = handler.acceptOwnership.selector; + targets[0] = FuzzSelector(address(handler), selectors); + return targets; + } + + function invariant_owner_never_changes() public { + assertEq(owned.owner(), owner); + } +} From acdc57a4eef1660fdacc3c4d56f1186a76a7508d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 3 Mar 2024 12:37:51 +0100 Subject: [PATCH 0704/1963] chore(deps): weekly `cargo update` (#7296) Updating git repository `https://github.com/gakonst/ethers-rs` Updating git repository `https://github.com/bluealloy/revm` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating ahash v0.8.9 -> v0.8.10 Updating alloy-consensus v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-dyn-abi v0.6.3 -> v0.6.4 Updating alloy-eips v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-genesis v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-json-abi v0.6.3 -> v0.6.4 Updating alloy-json-rpc v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-network v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-primitives v0.6.3 -> v0.6.4 Updating alloy-providers v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-pubsub v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-rpc-client v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-rpc-trace-types v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-rpc-types v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-signer v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-sol-macro v0.6.3 -> v0.6.4 Updating alloy-sol-type-parser v0.6.3 -> v0.6.4 Updating alloy-sol-types v0.6.3 -> v0.6.4 Updating alloy-transport v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-transport-http v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-transport-ipc v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating alloy-transport-ws v0.1.0 (https://github.com/alloy-rs/alloy#29a7886e) -> #52bf7125 Updating anstream v0.6.12 -> v0.6.13 Updating auto_impl v1.1.2 -> v1.2.0 Updating cc v1.0.87 -> v1.0.88 Updating crossbeam-channel v0.5.11 -> v0.5.12 Updating dyn-clone v1.0.16 -> v1.0.17 Updating event-listener v5.1.0 -> v5.2.0 Updating evmole v0.3.2 -> v0.3.3 Updating gix-utils v0.1.9 -> v0.1.10 Updating half v2.3.1 -> v2.4.0 Updating hermit-abi v0.3.8 -> v0.3.9 Updating indexmap v2.2.3 -> v2.2.5 Updating lalrpop v0.20.0 -> v0.20.2 Updating lalrpop-util v0.20.0 -> v0.20.2 Updating log v0.4.20 -> v0.4.21 Updating mio v0.8.10 -> v0.8.11 Updating opaque-debug v0.3.0 -> v0.3.1 Updating pest v2.7.7 -> v2.7.8 Updating pest_derive v2.7.7 -> v2.7.8 Updating pest_generator v2.7.7 -> v2.7.8 Updating pest_meta v2.7.7 -> v2.7.8 Adding proc-macro-crate v3.1.0 Updating rayon v1.8.1 -> v1.9.0 Removing regex-syntax v0.7.5 Updating ruint v1.11.1 -> v1.12.0 Updating ruint-macro v1.1.0 -> v1.2.0 Updating syn v2.0.50 -> v2.0.52 Updating syn-solidity v0.6.3 -> v0.6.4 Updating tempfile v3.10.0 -> v3.10.1 Updating walkdir v2.4.0 -> v2.5.0 Updating windows-targets v0.52.3 -> v0.52.4 Updating windows_aarch64_gnullvm v0.52.3 -> v0.52.4 Updating windows_aarch64_msvc v0.52.3 -> v0.52.4 Updating windows_i686_gnu v0.52.3 -> v0.52.4 Updating windows_i686_msvc v0.52.3 -> v0.52.4 Updating windows_x86_64_gnu v0.52.3 -> v0.52.4 Updating windows_x86_64_gnullvm v0.52.3 -> v0.52.4 Updating windows_x86_64_msvc v0.52.3 -> v0.52.4 Updating winnow v0.6.2 -> v0.6.5 note: pass `--verbose` to see 178 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 341 +++++++++++++++++++++++++++-------------------------- 1 file changed, 173 insertions(+), 168 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3ec2e6992ede..c9216e3cfe360 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" +checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" dependencies = [ "cfg-if", "once_cell", @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-eips", "alloy-network", @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13b1a44ed6b4126e4818d20c9e48176ae9d6d4fcbe6c909f8cd0bf050eb56fd8" +checksum = "2919acdad13336bc5dc26b636cdd6892c2f27fb0d4a58320a00c2713cf6a4e9a" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -116,13 +116,13 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.5.40", + "winnow 0.6.5", ] [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c6a6c5140fc762edfe55349f9ddefa821f4b7f2339cef582de911a3f1fb6d3" +checksum = "24ed0f2a6c3a1c947b4508522a53a190dba8f94dcd4e3e1a5af945a498e78f2f" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -177,9 +177,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef197eb250c64962003cb08b90b17f0882c192f4a6f2f544809d424fd7cb0e7d" +checksum = "600d34d8de81e23b6d909c094e23b3d357e01ca36b78a8c5424c501eedbe86f0" dependencies = [ "alloy-rlp", "arbitrary", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -257,13 +257,13 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-network", "alloy-primitives", @@ -322,9 +322,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e92100dee7fd1e44abbe0ef6607f18758cf0ad4e483f4c65ff5c8d85428a6d" +checksum = "e86ec0a47740b20bc5613b8712d0d321d031c4efc58e9645af96085d5cccfc27" dependencies = [ "alloy-json-abi", "const-hex", @@ -335,25 +335,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.50", + "syn 2.0.52", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-type-parser" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d146adca22a853b5aaaa98a6c78bd9d8f1d627ca7b01d170edccf45430e9b2cb" +checksum = "0045cc89524e1451ccf33e8581355b6027ac7c6e494bb02959d4213ad0d8e91d" dependencies = [ - "winnow 0.5.40", + "winnow 0.6.5", ] [[package]] name = "alloy-sol-types" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e7c6a8c492b1d6a4f92a8fc6a13cf39473978dd7d459d7221969ce5a73d97cd" +checksum = "ad09ec5853fa700d12d778ad224dcdec636af424d29fad84fb9a2f16a5b0ef09" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -413,7 +413,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#29a7886e1311062c589a6853a0f21f32901835d9" +source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -462,9 +462,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.12" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ "anstyle", "anstyle-parse", @@ -797,7 +797,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 5.1.0", + "event-listener 5.2.0", "event-listener-strategy 0.5.0", "futures-core", "pin-project-lite", @@ -831,7 +831,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -848,7 +848,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -895,13 +895,13 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -1309,9 +1309,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3286b845d0fccbdd15af433f61c5970e711987036cb468f437ff6badd70f4e24" +checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" dependencies = [ "libc", ] @@ -1370,7 +1370,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.3", + "windows-targets 0.52.4", ] [[package]] @@ -1463,7 +1463,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -1779,9 +1779,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" dependencies = [ "crossbeam-utils", ] @@ -1914,7 +1914,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -1925,7 +1925,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -1986,7 +1986,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -2007,7 +2007,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -2017,7 +2017,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -2147,9 +2147,9 @@ checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "dyn-clone" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "ecdsa" @@ -2259,7 +2259,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -2467,7 +2467,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.50", + "syn 2.0.52", "toml 0.8.10", "walkdir", ] @@ -2484,7 +2484,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -2509,7 +2509,7 @@ dependencies = [ "serde", "serde_json", "strum 0.26.1", - "syn 2.0.50", + "syn 2.0.52", "tempfile", "thiserror", "tiny-keccak", @@ -2678,9 +2678,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.1.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ad6fd685ce13acd6d9541a30f6db6567a7a24c9ffd4ba2955d29e3f22c8b27" +checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" dependencies = [ "concurrent-queue", "parking", @@ -2703,7 +2703,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" dependencies = [ - "event-listener 5.1.0", + "event-listener 5.2.0", "pin-project-lite", ] @@ -2719,9 +2719,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef57dfcf13fc3486c3a760427d88ab0d97cb911f7104fe5a132f2b934d0fe29" +checksum = "cd4e05af4c306bcba507bd358feac33ec73f4314a89bd93758d035c629f2f5fe" dependencies = [ "ruint", ] @@ -2763,7 +2763,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -3380,7 +3380,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -3547,7 +3547,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -3840,9 +3840,9 @@ checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" [[package]] name = "gix-utils" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e839f3d0798b296411263da6bee780a176ef8008a5dfc31287f7eda9266ab8" +checksum = "60157a15b9f14b11af1c6817ad7a93b10b50b4e5136d98a127c46a37ff16eeb6" dependencies = [ "fastrand", "unicode-normalization", @@ -3921,9 +3921,9 @@ dependencies = [ [[package]] name = "half" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" dependencies = [ "cfg-if", "crunchy", @@ -3973,7 +3973,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.9", + "ahash 0.8.10", "allocator-api2", "serde", ] @@ -3995,9 +3995,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -4299,9 +4299,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.3" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -4547,31 +4547,33 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.20.0" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" +checksum = "55cb077ad656299f160924eb2912aa147d7339ea7d69e1b5517326fdcec3c1ca" dependencies = [ "ascii-canvas", "bit-set", - "diff", "ena", - "is-terminal", - "itertools 0.10.5", + "itertools 0.11.0", "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", "string_cache", "term", "tiny-keccak", "unicode-xid", + "walkdir", ] [[package]] name = "lalrpop-util" -version = "0.20.0" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" +checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" +dependencies = [ + "regex-automata 0.4.5", +] [[package]] name = "lazy_static" @@ -4635,9 +4637,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru" @@ -4802,7 +4804,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -4838,9 +4840,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -5065,10 +5067,10 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -5109,9 +5111,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "open-fastrlp" @@ -5172,7 +5174,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -5382,7 +5384,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -5411,9 +5413,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" +checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" dependencies = [ "memchr", "thiserror", @@ -5422,9 +5424,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" +checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" dependencies = [ "pest", "pest_generator", @@ -5432,22 +5434,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" +checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] name = "pest_meta" -version = "2.7.7" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" +checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" dependencies = [ "once_cell", "pest", @@ -5543,7 +5545,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -5581,7 +5583,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -5692,7 +5694,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -5737,6 +5739,15 @@ dependencies = [ "toml_edit 0.20.7", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -5778,7 +5789,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", "version_check", "yansi 1.0.0-rc.1", ] @@ -5994,9 +6005,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -6084,12 +6095,6 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" -[[package]] -name = "regex-syntax" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" - [[package]] name = "regex-syntax" version = "0.8.2" @@ -6303,9 +6308,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608a5726529f2f0ef81b8fde9873c4bb829d6b5b5ca6be4d97345ddf0749c825" +checksum = "49b1d9521f889713d1221270fdd63370feca7e5c71a18745343402fa86e4f04f" dependencies = [ "alloy-rlp", "arbitrary", @@ -6328,9 +6333,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e666a5496a0b2186dbcd0ff6106e29e093c15591bde62c20d3842007c6978a09" +checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" [[package]] name = "rusb" @@ -6784,7 +6789,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -6838,7 +6843,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -6884,7 +6889,7 @@ checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -7181,7 +7186,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -7194,7 +7199,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -7275,9 +7280,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.50" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -7286,14 +7291,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e656cbcef8a77543b5accbd76f60f9e0bc4be364b0aba4263a6f313f8a355511" +checksum = "cb3d0961cd53c23ea94eeec56ba940f636f6394788976e9f16ca5ee0aca7464a" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -7343,9 +7348,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", @@ -7415,7 +7420,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -7537,7 +7542,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -7688,7 +7693,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.2", + "winnow 0.6.5", ] [[package]] @@ -7770,7 +7775,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -8086,9 +8091,9 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -8136,7 +8141,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", "wasm-bindgen-shared", ] @@ -8170,7 +8175,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8313,7 +8318,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.3", + "windows-targets 0.52.4", ] [[package]] @@ -8340,7 +8345,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.3", + "windows-targets 0.52.4", ] [[package]] @@ -8375,17 +8380,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.3", - "windows_aarch64_msvc 0.52.3", - "windows_i686_gnu 0.52.3", - "windows_i686_msvc 0.52.3", - "windows_x86_64_gnu 0.52.3", - "windows_x86_64_gnullvm 0.52.3", - "windows_x86_64_msvc 0.52.3", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -8402,9 +8407,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -8420,9 +8425,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -8438,9 +8443,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -8456,9 +8461,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -8474,9 +8479,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -8492,9 +8497,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -8510,9 +8515,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.3" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winnow" @@ -8525,9 +8530,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4191c47f15cc3ec71fcb4913cb83d58def65dd3787610213c649283b5ce178" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" dependencies = [ "memchr", ] @@ -8605,7 +8610,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] @@ -8625,7 +8630,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.52", ] [[package]] From 3df3e0c0d72dedcba3ea57afd2f57ebd231624dd Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 3 Mar 2024 16:01:24 +0400 Subject: [PATCH 0705/1963] feat(forge verify-contract): `--guess-constructor-args` (#6724) * Add RpcOpts to VerifyArgs * --guess-constructor-args * Add support for CREATE2 deployer * Fix artifact lookup * Update verification tests + Test for --guess-constructor-args * chore: clippy * update compilation + separate function * doc --------- Co-authored-by: Matthias Seitz --- crates/forge/bin/cmd/create.rs | 9 +- crates/forge/bin/cmd/script/verify.rs | 2 + crates/forge/bin/cmd/verify/etherscan/mod.rs | 87 ++++++++++++- crates/forge/bin/cmd/verify/mod.rs | 33 ++++- crates/forge/tests/cli/verify.rs | 123 ++++++++++++++----- 5 files changed, 214 insertions(+), 40 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 1944281910538..ed9a17aadf650 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -176,7 +176,11 @@ impl CreateArgs { constructor_args, constructor_args_path: None, num_of_optimizations: None, - etherscan: EtherscanOpts { key: self.eth.etherscan.key(), chain: Some(chain.into()) }, + etherscan: EtherscanOpts { + key: self.eth.etherscan.key.clone(), + chain: Some(chain.into()), + }, + rpc: Default::default(), flatten: false, force: false, skip_is_verified_check: true, @@ -188,6 +192,7 @@ impl CreateArgs { via_ir: self.opts.via_ir, evm_version: self.opts.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, + guess_constructor_args: false, }; // Check config for Etherscan API Keys to avoid preflight check failing if no @@ -326,6 +331,7 @@ impl CreateArgs { constructor_args_path: None, num_of_optimizations, etherscan: EtherscanOpts { key: self.eth.etherscan.key(), chain: Some(chain.into()) }, + rpc: Default::default(), flatten: false, force: false, skip_is_verified_check: false, @@ -337,6 +343,7 @@ impl CreateArgs { via_ir: self.opts.via_ir, evm_version: self.opts.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, + guess_constructor_args: false, }; println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier); verify.run().await diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 6498b8f8a6dd6..96b778edaf87b 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -105,6 +105,7 @@ impl VerifyBundle { constructor_args_path: None, num_of_optimizations: self.num_of_optimizations, etherscan: self.etherscan.clone(), + rpc: Default::default(), flatten: false, force: false, skip_is_verified_check: true, @@ -116,6 +117,7 @@ impl VerifyBundle { via_ir: self.via_ir, evm_version: None, show_standard_json_input: false, + guess_constructor_args: false, }; return Some(verify) diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 919c83b8fb0ab..f63db1240eb15 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -1,7 +1,8 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use crate::cmd::retry::RETRY_CHECK_ON_VERIFY; use alloy_json_abi::Function; -use eyre::{eyre, Context, Result}; +use ethers_providers::Middleware; +use eyre::{eyre, Context, OptionExt, Result}; use forge::hashbrown::HashSet; use foundry_block_explorers::{ errors::EtherscanError, @@ -9,12 +10,16 @@ use foundry_block_explorers::{ verify::{CodeFormat, VerifyContract}, Client, }; -use foundry_cli::utils::{get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; -use foundry_common::{abi::encode_function_args, retry::Retry}; +use foundry_cli::utils::{self, get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; +use foundry_common::{abi::encode_function_args, retry::Retry, types::ToEthers}; use foundry_compilers::{ - artifacts::CompactContract, cache::CacheEntry, info::ContractInfo, Project, Solc, + artifacts::{BytecodeObject, CompactContract}, + cache::CacheEntry, + info::ContractInfo, + Artifact, Project, Solc, }; use foundry_config::{Chain, Config, SolcReq}; +use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; use futures::FutureExt; use once_cell::sync::Lazy; use regex::Regex; @@ -332,7 +337,7 @@ impl EtherscanVerificationProvider { self.source_provider(args).source(args, &project, &contract_path, &compiler_version)?; let compiler_version = format!("v{}", ensure_solc_build_metadata(compiler_version).await?); - let constructor_args = self.constructor_args(args, &project)?; + let constructor_args = self.constructor_args(args, &project, &config).await?; let mut verify_args = VerifyContract::new(args.address, contract_name, source, compiler_version) .constructor_arguments(constructor_args) @@ -435,7 +440,12 @@ impl EtherscanVerificationProvider { /// Return the optional encoded constructor arguments. If the path to /// constructor arguments was provided, read them and encode. Otherwise, /// return whatever was set in the [VerifyArgs] args. - fn constructor_args(&mut self, args: &VerifyArgs, project: &Project) -> Result> { + async fn constructor_args( + &mut self, + args: &VerifyArgs, + project: &Project, + config: &Config, + ) -> Result> { if let Some(ref constructor_args_path) = args.constructor_args_path { let (_, _, contract) = self.cache_entry(project, &args.contract).wrap_err( "Cache must be enabled in order to use the `--constructor-args-path` option", @@ -459,9 +469,74 @@ impl EtherscanVerificationProvider { let encoded_args = hex::encode(encoded_args); return Ok(Some(encoded_args[8..].into())) } + if args.guess_constructor_args { + return Ok(Some(self.guess_constructor_args(args, project, config).await?)) + } Ok(args.constructor_args.clone()) } + + /// Uses Etherscan API to fetch contract creation transaction. + /// If transaction is a create transaction or a invocation of default CREATE2 deployer, tries to + /// match provided creation code with local bytecode of the target contract. + /// If bytecode match, returns latest bytes of on-chain creation code as constructor arguments. + async fn guess_constructor_args( + &mut self, + args: &VerifyArgs, + project: &Project, + config: &Config, + ) -> Result { + let provider = utils::get_provider(config)?; + let client = self.client( + args.etherscan.chain.unwrap_or_default(), + args.verifier.verifier_url.as_deref(), + args.etherscan.key.as_deref(), + config, + )?; + + let creation_data = client.contract_creation_data(args.address).await?; + let transaction = provider + .get_transaction(creation_data.transaction_hash.to_ethers()) + .await? + .ok_or_eyre("Couldn't fetch transaction data from RPC")?; + let receipt = provider + .get_transaction_receipt(creation_data.transaction_hash.to_ethers()) + .await? + .ok_or_eyre("Couldn't fetch transaction receipt from RPC")?; + + let maybe_creation_code: &[u8]; + + if receipt.contract_address == Some(args.address.to_ethers()) { + maybe_creation_code = &transaction.input; + } else if transaction.to == Some(DEFAULT_CREATE2_DEPLOYER.to_ethers()) { + maybe_creation_code = &transaction.input[32..]; + } else { + eyre::bail!("Fetching of constructor arguments is not supported for contracts created by contracts") + } + + let contract_path = self.contract_path(args, project)?.to_string_lossy().into_owned(); + let output = project.compile()?; + let artifact = output + .find(contract_path, &args.contract.name) + .ok_or_eyre("Contract artifact wasn't found locally")?; + let bytecode = artifact + .get_bytecode_object() + .ok_or_eyre("Contract artifact does not contain bytecode")?; + + let bytecode = match bytecode.as_ref() { + BytecodeObject::Bytecode(bytes) => Ok(bytes), + BytecodeObject::Unlinked(_) => { + Err(eyre!("You have to provide correct libraries to use --guess-constructor-args")) + } + }?; + + if maybe_creation_code.starts_with(bytecode) { + let constructor_args = &maybe_creation_code[bytecode.len()..]; + Ok(hex::encode(constructor_args)) + } else { + eyre::bail!("Local bytecode doesn't match on-chain bytecode") + } + } } /// Given any solc [Version] return a [Version] with build metadata diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/forge/bin/cmd/verify/mod.rs index f9839d7175bb4..eeff2cb83c7a2 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/forge/bin/cmd/verify/mod.rs @@ -2,7 +2,11 @@ use super::retry::RetryArgs; use alloy_primitives::Address; use clap::{Parser, ValueHint}; use eyre::Result; -use foundry_cli::{opts::EtherscanOpts, utils::LoadConfig}; +use foundry_cli::{ + opts::{EtherscanOpts, RpcOpts}, + utils, + utils::LoadConfig, +}; use foundry_compilers::{info::ContractInfo, EvmVersion}; use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config}; use provider::VerificationProviderType; @@ -57,6 +61,10 @@ pub struct VerifyArgs { #[arg(long, value_hint = ValueHint::FilePath, value_name = "PATH")] pub constructor_args_path: Option, + /// Try to extract constructor arguments from on-chain creation code. + #[arg(long)] + pub guess_constructor_args: bool, + /// The `solc` version to use to build the smart contract. #[arg(long, value_name = "VERSION")] pub compiler_version: Option, @@ -112,6 +120,9 @@ pub struct VerifyArgs { #[command(flatten)] pub etherscan: EtherscanOpts, + #[command(flatten)] + pub rpc: RpcOpts, + #[command(flatten)] pub retry: RetryArgs, @@ -130,6 +141,8 @@ impl figment::Provider for VerifyArgs { &self, ) -> Result, figment::Error> { let mut dict = self.etherscan.dict(); + dict.extend(self.rpc.dict()); + if let Some(root) = self.root.as_ref() { dict.insert("root".to_string(), figment::value::Value::serialize(root)?); } @@ -154,7 +167,23 @@ impl VerifyArgs { /// Run the verify command to submit the contract's source code for verification on etherscan pub async fn run(mut self) -> Result<()> { let config = self.load_config_emit_warnings(); - let chain = config.chain.unwrap_or_default(); + + if self.guess_constructor_args && config.get_rpc_url().is_none() { + eyre::bail!( + "You have to provide a valid RPC URL to use --guess-constructor-args feature" + ) + } + + // If chain is not set, we try to get it from the RPC + // If RPC is not set, the default chain is used + let chain = match config.get_rpc_url() { + Some(_) => { + let provider = utils::get_provider(&config)?; + utils::get_chain(config.chain, provider).await? + } + None => config.chain.unwrap_or_default(), + }; + self.etherscan.chain = Some(chain); self.etherscan.key = config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index 8874af9534e7c..deedcc9abf83a 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -55,6 +55,24 @@ function doStuff() external {{}} prj.add_source("Verify.sol", &contract).unwrap(); } +fn add_verify_target_with_constructor(prj: &TestProject) { + prj.add_source( + "Verify.sol", + r#" +import {Unique} from "./unique.sol"; +contract Verify is Unique { + struct SomeStruct { + uint256 a; + string str; + } + + constructor(SomeStruct memory st, address owner) {} +} +"#, + ) + .unwrap(); +} + fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Result<()> { // give etherscan some time to verify the contract let retry = Retry::new(retries, Some(Duration::from_secs(30))); @@ -73,6 +91,39 @@ fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Resul }) } +fn await_verification_response(info: EnvExternalities, mut cmd: TestCommand) { + let guid = { + // give etherscan some time to detect the transaction + let retry = Retry::new(5, Some(Duration::from_secs(60))); + retry + .run(|| -> eyre::Result { + let output = cmd.unchecked_output(); + let out = String::from_utf8_lossy(&output.stdout); + utils::parse_verification_guid(&out).ok_or_else(|| { + eyre::eyre!( + "Failed to get guid, stdout: {}, stderr: {}", + out, + String::from_utf8_lossy(&output.stderr) + ) + }) + }) + .expect("Failed to get verify guid") + }; + + // verify-check + cmd.forge_fuse() + .arg("verify-check") + .arg(guid) + .arg("--chain-id") + .arg(info.chain.to_string()) + .arg("--etherscan-api-key") + .arg(info.etherscan) + .arg("--verifier") + .arg(info.verifier); + + parse_verification_result(&mut cmd, 6).expect("Failed to verify check") +} + fn verify_on_chain(info: Option, prj: TestProject, mut cmd: TestCommand) { // only execute if keys present if let Some(info) = info { @@ -98,37 +149,41 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te info.verifier.to_string(), ]); - // `verify-contract` - let guid = { - // give etherscan some time to detect the transaction - let retry = Retry::new(5, Some(Duration::from_secs(60))); - retry - .run(|| -> eyre::Result { - let output = cmd.unchecked_output(); - let out = String::from_utf8_lossy(&output.stdout); - utils::parse_verification_guid(&out).ok_or_else(|| { - eyre::eyre!( - "Failed to get guid, stdout: {}, stderr: {}", - out, - String::from_utf8_lossy(&output.stderr) - ) - }) - }) - .expect("Failed to get verify guid") - }; - - // verify-check - cmd.forge_fuse() - .arg("verify-check") - .arg(guid) - .arg("--chain-id") - .arg(info.chain.to_string()) - .arg("--etherscan-api-key") - .arg(info.etherscan) - .arg("--verifier") - .arg(info.verifier); - - parse_verification_result(&mut cmd, 6).expect("Failed to verify check") + await_verification_response(info, cmd) + } +} + +fn guess_constructor_args(info: Option, prj: TestProject, mut cmd: TestCommand) { + // only execute if keys present + if let Some(info) = info { + println!("verifying on {}", info.chain); + add_unique(&prj); + add_verify_target_with_constructor(&prj); + + let contract_path = "src/Verify.sol:Verify"; + cmd.arg("create").args(info.create_args()).arg(contract_path).args(vec![ + "--constructor-args", + "(239,SomeString)", + "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", + ]); + + let out = cmd.stdout_lossy(); + let address = utils::parse_deployed_address(out.as_str()) + .unwrap_or_else(|| panic!("Failed to parse deployer {out}")); + + cmd.forge_fuse().arg("verify-contract").root_arg().args([ + "--rpc-url".to_string(), + info.rpc.to_string(), + address, + contract_path.to_string(), + "--etherscan-api-key".to_string(), + info.etherscan.to_string(), + "--verifier".to_string(), + info.verifier.to_string(), + "--guess-constructor-args".to_string(), + ]); + + await_verification_response(info, cmd) } } @@ -174,3 +229,9 @@ forgetest!(can_verify_random_contract_sepolia, |prj, cmd| { forgetest!(can_create_verify_random_contract_sepolia, |prj, cmd| { create_verify_on_chain(EnvExternalities::sepolia(), prj, cmd); }); + +// tests `create && contract-verify --guess-constructor-args && verify-check` on Goerli testnet if +// correct env vars are set +forgetest!(can_guess_constructor_args, |prj, cmd| { + guess_constructor_args(EnvExternalities::goerli(), prj, cmd); +}); From c24933da985419ea143de7e8636d5b0a48d2fab7 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 3 Mar 2024 18:28:02 -0700 Subject: [PATCH 0706/1963] Add transient storage warning to default `ignored_error_codes` (#7299) * add transient-storage error code and add to default ignored * add reverse lookups --- crates/config/src/error.rs | 6 ++++++ crates/config/src/lib.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index b4f7b85aa2918..00692d67dbea8 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -134,6 +134,8 @@ pub enum SolidityErrorCode { Unreachable, /// Missing pragma solidity PragmaSolidity, + /// Uses transient opcodes + TransientStorageUsed, /// All other error codes Other(u64), } @@ -162,6 +164,7 @@ impl SolidityErrorCode { SolidityErrorCode::PragmaSolidity => "pragma-solidity", SolidityErrorCode::Other(code) => return Err(*code), SolidityErrorCode::VisibilityForConstructorIsIgnored => "constructor-visibility", + SolidityErrorCode::TransientStorageUsed => "transient-storage", }; Ok(s) } @@ -185,6 +188,7 @@ impl From for u64 { SolidityErrorCode::PragmaSolidity => 3420, SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes => 3860, SolidityErrorCode::VisibilityForConstructorIsIgnored => 2462, + SolidityErrorCode::TransientStorageUsed => 2394, SolidityErrorCode::Other(code) => code, } } @@ -218,6 +222,7 @@ impl FromStr for SolidityErrorCode { "missing-receive-ether" => SolidityErrorCode::PayableNoReceiveEther, "same-varname" => SolidityErrorCode::DeclarationSameNameAsAnother, "constructor-visibility" => SolidityErrorCode::VisibilityForConstructorIsIgnored, + "transient-storage" => SolidityErrorCode::TransientStorageUsed, _ => return Err(format!("Unknown variant {s}")), }; @@ -243,6 +248,7 @@ impl From for SolidityErrorCode { 3420 => SolidityErrorCode::PragmaSolidity, 5740 => SolidityErrorCode::Unreachable, 2462 => SolidityErrorCode::VisibilityForConstructorIsIgnored, + 2394 => SolidityErrorCode::TransientStorageUsed, other => SolidityErrorCode::Other(other), } } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 5c704d6c7bf65..d9853fae6cfa6 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1901,6 +1901,7 @@ impl Default for Config { SolidityErrorCode::SpdxLicenseNotProvided, SolidityErrorCode::ContractExceeds24576Bytes, SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes, + SolidityErrorCode::TransientStorageUsed, ], ignored_file_paths: vec![], deny_warnings: false, From d176715dbb5193f60008df7c4c78515070aa3d6b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:04:58 +0100 Subject: [PATCH 0707/1963] chore: reduce unnecessary collected fuzz state (#7305) --- crates/evm/fuzz/src/strategies/state.rs | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 2beedb1e75a2d..862b38bca48e1 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -14,7 +14,7 @@ use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, }; -use std::{fmt, io::Write, str::FromStr, sync::Arc}; +use std::{fmt, str::FromStr, sync::Arc}; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// @@ -185,19 +185,20 @@ pub fn collect_state_from_call( } else { return; } + } - // Insert log topics and data - for log in logs { - log.data.topics().iter().for_each(|topic| { - state.values_mut().insert(topic.0); - }); - log.data.data.chunks(32).for_each(|chunk| { - let mut buffer: [u8; 32] = [0; 32]; - let _ = (&mut buffer[..]) - .write(chunk) - .expect("log data chunk was larger than 32 bytes"); - state.values_mut().insert(buffer); - }); + // Insert log topics and data. + for log in logs { + for topic in log.topics() { + state.values_mut().insert(topic.0); + } + let chunks = log.data.data.chunks_exact(32); + let rem = chunks.remainder(); + for chunk in chunks { + state.values_mut().insert(chunk.try_into().unwrap()); + } + if !rem.is_empty() { + state.values_mut().insert(B256::right_padding_from(rem).0); } } } From b8047b7cb94a91358d32aab8290bf4927848c323 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:31:50 +0100 Subject: [PATCH 0708/1963] chore: reduce unnecessary collected fuzz state (#7306) --- crates/evm/fuzz/src/strategies/state.rs | 32 ++++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 862b38bca48e1..cf2f6ec6e8a35 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -150,6 +150,21 @@ pub fn collect_state_from_call( ) { let mut state = state.write(); + // Insert log topics and data. + for log in logs { + for topic in log.topics() { + state.values_mut().insert(topic.0); + } + let chunks = log.data.data.chunks_exact(32); + let rem = chunks.remainder(); + for chunk in chunks { + state.values_mut().insert(chunk.try_into().unwrap()); + } + if !rem.is_empty() { + state.values_mut().insert(B256::right_padding_from(rem).0); + } + } + for (address, account) in state_changeset { // Insert basic account information state.values_mut().insert(address.into_word().into()); @@ -182,23 +197,6 @@ pub fn collect_state_from_call( state.values_mut().insert(B256::from(above_value).0); } } - } else { - return; - } - } - - // Insert log topics and data. - for log in logs { - for topic in log.topics() { - state.values_mut().insert(topic.0); - } - let chunks = log.data.data.chunks_exact(32); - let rem = chunks.remainder(); - for chunk in chunks { - state.values_mut().insert(chunk.try_into().unwrap()); - } - if !rem.is_empty() { - state.values_mut().insert(B256::right_padding_from(rem).0); } } } From 28e80130ad8e802e462bf141350bd209846ff4e3 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 4 Mar 2024 22:06:38 +0400 Subject: [PATCH 0709/1963] feat(forge): --disable-block-gas-limit flag (#7287) * feat(forge): --disable-block-gas-limit flag * test * fix test --- crates/common/src/evm.rs | 4 +++ crates/config/src/lib.rs | 4 +++ crates/evm/core/src/fork/init.rs | 2 ++ crates/evm/core/src/opts.rs | 5 ++++ crates/evm/evm/src/inspectors/stack.rs | 10 ++++--- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/test_cmd.rs | 36 ++++++++++++++++++++++++++ 7 files changed, 59 insertions(+), 3 deletions(-) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index e23c1da339ecf..4b2a94f4377d0 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -272,6 +272,10 @@ pub struct EnvArgs { #[arg(long, value_name = "MEMORY_LIMIT")] #[serde(skip_serializing_if = "Option::is_none")] pub memory_limit: Option, + + /// Whether to disable the block gas limit checks. + #[arg(long, visible_alias = "no-gas-limit")] + pub disable_block_gas_limit: bool, } impl EvmArgs { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d9853fae6cfa6..a076acf77f46c 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -379,6 +379,9 @@ pub struct Config { /// Useful for more correct gas accounting and EVM behavior in general. pub isolate: bool, + /// Whether to disable the block gas limit. + pub disable_block_gas_limit: bool, + /// Address labels pub labels: HashMap, @@ -1889,6 +1892,7 @@ impl Default for Config { block_difficulty: 0, block_prevrandao: Default::default(), block_gas_limit: None, + disable_block_gas_limit: false, memory_limit: 1 << 27, // 2**27 = 128MiB = 134_217_728 bytes eth_rpc_url: None, eth_rpc_jwt: None, diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index 11e65916498d5..84830d5a2b837 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -17,6 +17,7 @@ pub async fn environment( override_chain_id: Option, pin_block: Option, origin: Address, + disable_block_gas_limit: bool, ) -> eyre::Result<(Env, Block)> { let block_number = if let Some(pin_block) = pin_block { pin_block @@ -55,6 +56,7 @@ pub async fn environment( // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the caller // is a contract. So we disable the check by default. cfg.disable_eip3607 = true; + cfg.disable_block_gas_limit = disable_block_gas_limit; let mut env = Env { cfg, diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 510f14254ad7c..2dee3a9b59b3c 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -64,6 +64,9 @@ pub struct EvmOpts { /// Whether to enable isolation of calls. pub isolate: bool, + + /// Whether to disable block gas limit checks. + pub disable_block_gas_limit: bool, } impl EvmOpts { @@ -96,6 +99,7 @@ impl EvmOpts { self.env.chain_id, self.fork_block_number, self.sender, + self.disable_block_gas_limit, ) .await .wrap_err_with(|| { @@ -114,6 +118,7 @@ impl EvmOpts { // If EIP-3607 is enabled it can cause issues during fuzz/invariant tests if the // caller is a contract. So we disable the check by default. cfg.disable_eip3607 = true; + cfg.disable_block_gas_limit = self.disable_block_gas_limit; revm::primitives::Env { block: BlockEnv { diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 2a66ac76280da..94152a444486e 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -467,9 +467,13 @@ impl InspectorStack { data.env.tx.value = value; data.env.tx.nonce = Some(nonce); // Add 21000 to the gas limit to account for the base cost of transaction. - // We might have modified block gas limit earlier and revm will reject tx with gas limit > - // block gas limit, so we adjust. - data.env.tx.gas_limit = std::cmp::min(gas_limit + 21000, data.env.block.gas_limit.to()); + data.env.tx.gas_limit = gas_limit + 21000; + // If we haven't disabled gas limit checks, ensure that transaction gas limit will not + // exceed block gas limit. + if !data.env.cfg.disable_block_gas_limit { + data.env.tx.gas_limit = + std::cmp::min(data.env.tx.gas_limit, data.env.block.gas_limit.to()); + } data.env.tx.gas_price = U256::ZERO; self.inner_context_data = Some(InnerContextData { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f2dbf22c7aac4..20bbb8e1b5968 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -85,6 +85,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { block_difficulty: 10, block_prevrandao: B256::random(), block_gas_limit: Some(100u64.into()), + disable_block_gas_limit: false, memory_limit: 1 << 27, eth_rpc_url: Some("localhost".to_string()), eth_rpc_jwt: None, diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 61cbab489e777..f449a0ac0501a 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -490,3 +490,39 @@ contract TransientTest is Test { cmd.args(["test", "-vvvv", "--isolate", "--evm-version", "cancun"]).assert_success(); }); + +forgetest_init!(can_disable_block_gas_limit, |prj, cmd| { + prj.wipe_contracts(); + + let endpoint = rpc::next_http_archive_rpc_endpoint(); + + prj.add_test( + "Contract.t.sol", + &r#"pragma solidity 0.8.24; +import {Test} from "forge-std/Test.sol"; + +contract C is Test {} + +contract GasWaster { + function waste() public { + for (uint256 i = 0; i < 100; i++) { + new C(); + } + } +} + +contract GasLimitTest is Test { + function test() public { + vm.createSelectFork(""); + + GasWaster waster = new GasWaster(); + waster.waste(); + } +} + "# + .replace("", &endpoint), + ) + .unwrap(); + + cmd.args(["test", "-vvvv", "--isolate", "--disable-block-gas-limit"]).assert_success(); +}); From 5efb5181e5cc40624f3b7b43cfa9f0fbd8c65664 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:08:40 +0200 Subject: [PATCH 0710/1963] closes #7303 - apply invariant preserve_state setting even when fail_on_revert is false (#7304) --- crates/config/src/invariant.rs | 3 +-- crates/evm/evm/src/executors/invariant/mod.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index d2594c820aab7..17994c3e3b302 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -30,8 +30,7 @@ pub struct InvariantConfig { pub shrink_run_limit: usize, /// If set to true then VM state is committed and available for next call /// Useful for handlers that use cheatcodes as roll or warp - /// Applies only when `fail_on_revert` set to true. Use it with caution, introduces performance - /// penalty. + /// Use it with caution, introduces performance penalty. pub preserve_state: bool, } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 79d055eab8c28..7b87c0f066009 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -162,7 +162,7 @@ impl<'a> InvariantExecutor<'a> { let (sender, (address, calldata)) = inputs.last().expect("no input generated"); // Executes the call from the randomly generated sequence. - let call_result = if self.config.fail_on_revert && self.config.preserve_state { + let call_result = if self.config.preserve_state { executor .call_raw_committing(*sender, *address, calldata.clone(), U256::ZERO) .expect("could not make raw evm call") From 3dfa43bf1fa030a6c76c36a12feb4f2fe623b89b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 4 Mar 2024 19:08:54 +0100 Subject: [PATCH 0711/1963] chore: bump alloy-chains (#7307) --- Cargo.lock | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9216e3cfe360..0f30364d0384a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "973deb9e9d5db1f28c2a478073aeb435f1c07f72cf5935caa0c421e6b68f2db1" +checksum = "e96c81b05c893348760f232c4cc6a6a77fd91cfb09885d4eaad25cd03bd7732e" dependencies = [ "num_enum", "serde", @@ -5067,7 +5067,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.52", @@ -5739,15 +5739,6 @@ dependencies = [ "toml_edit 0.20.7", ] -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", -] - [[package]] name = "proc-macro-error" version = "1.0.4" From 381d76cbdbab921f7929c0027c601178a7cdb1e4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 5 Mar 2024 11:31:54 +0100 Subject: [PATCH 0712/1963] chore: add panic message (#7316) --- crates/cli/src/opts/build/paths.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index 692da4588e91c..9497427518f34 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -67,8 +67,14 @@ impl ProjectPathsArgs { /// Returns the root directory to use for configuring the [Project] /// /// This will be the `--root` argument if provided, otherwise see [find_project_root_path()] + /// + /// # Panics + /// + /// If the project root directory cannot be found: [find_project_root_path()] pub fn project_root(&self) -> PathBuf { - self.root.clone().unwrap_or_else(|| find_project_root_path(None).unwrap()) + self.root + .clone() + .unwrap_or_else(|| find_project_root_path(None).expect("Failed to find project root")) } /// Returns the remappings to add to the config From 36440d87bd0f211fd70e78130ac29e2191fbdffe Mon Sep 17 00:00:00 2001 From: risinek Date: Tue, 5 Mar 2024 12:16:59 +0100 Subject: [PATCH 0713/1963] Remove --offline flag from cargo install command (#7315) Otherwise cargo throws error when installing on a clean Rust installation error: failed to load source for dependency `ethers` Caused by: Unable to update https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de21 Caused by: can't checkout from 'https://github.com/gakonst/ethers-rs': you are in the offline mode (--offline) --- crates/anvil/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/README.md b/crates/anvil/README.md index d811bf3cebc4c..cb62354fbc519 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -20,7 +20,7 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** ```sh git clone https://github.com/foundry-rs/foundry cd foundry -cargo install --path ./crates/anvil --profile local --locked --offline --force +cargo install --path ./crates/anvil --profile local --locked --force ``` ## Getting started From ce22450e4d625d12ff88fae347a68e3d3d9d2b61 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 5 Mar 2024 16:38:19 +0400 Subject: [PATCH 0714/1963] fix(invariants): support `vm.assume` in invariant tests (#7309) * fix(invariants): support vm.assume in invariant tests * fix * add .sol file * review fix --- crates/config/src/invariant.rs | 4 + .../evm/evm/src/executors/invariant/error.rs | 26 +++- .../evm/evm/src/executors/invariant/funcs.rs | 7 +- crates/evm/evm/src/executors/invariant/mod.rs | 135 ++++++++++-------- crates/evm/fuzz/src/strategies/invariants.rs | 3 +- crates/forge/src/runner.rs | 38 ++--- crates/forge/tests/it/invariant.rs | 41 ++++++ crates/forge/tests/it/test_helpers.rs | 1 + .../invariant/common/InvariantAssume.t.sol | 23 +++ 9 files changed, 194 insertions(+), 84 deletions(-) create mode 100644 testdata/fuzz/invariant/common/InvariantAssume.t.sol diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 17994c3e3b302..0eb96bdee2a2e 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -32,6 +32,9 @@ pub struct InvariantConfig { /// Useful for handlers that use cheatcodes as roll or warp /// Use it with caution, introduces performance penalty. pub preserve_state: bool, + /// The maximum number of rejects via `vm.assume` which can be encountered during a single + /// invariant run. + pub max_assume_rejects: u32, } impl Default for InvariantConfig { @@ -45,6 +48,7 @@ impl Default for InvariantConfig { shrink_sequence: true, shrink_run_limit: 2usize.pow(18_u32), preserve_state: false, + max_assume_rejects: 65536, } } } diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 50dedab7c81d9..8acc67f6a7834 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -53,7 +53,27 @@ pub struct InvariantFuzzTestResult { } #[derive(Clone, Debug)] -pub struct InvariantFuzzError { +pub enum InvariantFuzzError { + Revert(FailedInvariantCaseData), + BrokenInvariant(FailedInvariantCaseData), + MaxAssumeRejects(u32), +} + +impl InvariantFuzzError { + pub fn revert_reason(&self) -> Option { + match self { + Self::BrokenInvariant(case_data) | Self::Revert(case_data) => { + (!case_data.revert_reason.is_empty()).then(|| case_data.revert_reason.clone()) + } + Self::MaxAssumeRejects(allowed) => Some(format!( + "The `vm.assume` cheatcode rejected too many inputs ({allowed} allowed)" + )), + } + } +} + +#[derive(Clone, Debug)] +pub struct FailedInvariantCaseData { pub logs: Vec, pub traces: Option, /// The proptest error occurred as a result of a test case. @@ -74,7 +94,7 @@ pub struct InvariantFuzzError { pub shrink_run_limit: usize, } -impl InvariantFuzzError { +impl FailedInvariantCaseData { pub fn new( invariant_contract: &InvariantContract<'_>, error_func: Option<&Function>, @@ -93,7 +113,7 @@ impl InvariantFuzzError { .with_abi(invariant_contract.abi) .decode(call_result.result.as_ref(), Some(call_result.exit_reason)); - InvariantFuzzError { + Self { logs: call_result.logs, traces: call_result.traces, test_error: proptest::test_runner::TestError::Fail( diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index 810abb259d0cc..237b4dad84ec5 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -1,4 +1,4 @@ -use super::{InvariantFailures, InvariantFuzzError}; +use super::{error::FailedInvariantCaseData, InvariantFailures, InvariantFuzzError}; use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; @@ -50,7 +50,7 @@ pub fn assert_invariants( if is_err { // We only care about invariants which we haven't broken yet. if invariant_failures.error.is_none() { - invariant_failures.error = Some(InvariantFuzzError::new( + let case_data = FailedInvariantCaseData::new( invariant_contract, Some(func), calldata, @@ -58,7 +58,8 @@ pub fn assert_invariants( &inner_sequence, shrink_sequence, shrink_run_limit, - )); + ); + invariant_failures.error = Some(InvariantFuzzError::BrokenInvariant(case_data)); return None } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 7b87c0f066009..2ec627b11e362 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -9,7 +9,7 @@ use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; use foundry_evm_core::{ - constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, + constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME}, utils::{get_function, StateChangeset}, }; use foundry_evm_fuzz::{ @@ -38,11 +38,13 @@ use foundry_evm_fuzz::strategies::CalldataFuzzDictionary; mod funcs; pub use funcs::{assert_invariants, replay_run}; +use self::error::FailedInvariantCaseData; + /// Alias for (Dictionary for fuzzing, initial contracts to fuzz and an InvariantStrategy). type InvariantPreparation = ( EvmFuzzState, FuzzRunIdentifiedContracts, - BoxedStrategy>, + BoxedStrategy, CalldataFuzzDictionary, ); @@ -143,7 +145,9 @@ impl<'a> InvariantExecutor<'a> { // during the run. We need another proptest runner to query for random // values. let branch_runner = RefCell::new(self.runner.clone()); - let _ = self.runner.run(&strat, |mut inputs| { + let _ = self.runner.run(&strat, |first_input| { + let mut inputs = vec![first_input]; + // We stop the run immediately if we have reverted, and `fail_on_revert` is set. if self.config.fail_on_revert && failures.borrow().reverts > 0 { return Err(TestCaseError::fail("Revert occurred.")) @@ -158,7 +162,10 @@ impl<'a> InvariantExecutor<'a> { // Created contracts during a run. let mut created_contracts = vec![]; - for current_run in 0..self.config.depth { + let mut current_run = 0; + let mut assume_rejects_counter = 0; + + while current_run < self.config.depth { let (sender, (address, calldata)) = inputs.last().expect("no input generated"); // Executes the call from the randomly generated sequence. @@ -172,65 +179,77 @@ impl<'a> InvariantExecutor<'a> { .expect("could not make raw evm call") }; - // Collect data for fuzzing from the state changeset. - let mut state_changeset = - call_result.state_changeset.to_owned().expect("no changesets"); - - collect_data( - &mut state_changeset, - sender, - &call_result, - fuzz_state.clone(), - &self.config.dictionary, - ); + if call_result.result.as_ref() == MAGIC_ASSUME { + inputs.pop(); + assume_rejects_counter += 1; + if assume_rejects_counter > self.config.max_assume_rejects { + failures.borrow_mut().error = Some(InvariantFuzzError::MaxAssumeRejects( + self.config.max_assume_rejects, + )); + return Err(TestCaseError::fail("Max number of vm.assume rejects reached.")) + } + } else { + // Collect data for fuzzing from the state changeset. + let mut state_changeset = + call_result.state_changeset.to_owned().expect("no changesets"); + + collect_data( + &mut state_changeset, + sender, + &call_result, + fuzz_state.clone(), + &self.config.dictionary, + ); - if let Err(error) = collect_created_contracts( - &state_changeset, - self.project_contracts, - self.setup_contracts, - &self.artifact_filters, - targeted_contracts.clone(), - &mut created_contracts, - ) { - warn!(target: "forge::test", "{error}"); - } + if let Err(error) = collect_created_contracts( + &state_changeset, + self.project_contracts, + self.setup_contracts, + &self.artifact_filters, + targeted_contracts.clone(), + &mut created_contracts, + ) { + warn!(target: "forge::test", "{error}"); + } - // Commit changes to the database. - executor.backend.commit(state_changeset.clone()); - - fuzz_runs.push(FuzzCase { - calldata: calldata.clone(), - gas: call_result.gas_used, - stipend: call_result.stipend, - }); - - let RichInvariantResults { success: can_continue, call_result: call_results } = - can_continue( - &invariant_contract, - call_result, - &executor, - &inputs, - &mut failures.borrow_mut(), - &targeted_contracts, - state_changeset, - self.config.fail_on_revert, - self.config.shrink_sequence, - self.config.shrink_run_limit, - ); + // Commit changes to the database. + executor.backend.commit(state_changeset.clone()); + + fuzz_runs.push(FuzzCase { + calldata: calldata.clone(), + gas: call_result.gas_used, + stipend: call_result.stipend, + }); + + let RichInvariantResults { success: can_continue, call_result: call_results } = + can_continue( + &invariant_contract, + call_result, + &executor, + &inputs, + &mut failures.borrow_mut(), + &targeted_contracts, + state_changeset, + self.config.fail_on_revert, + self.config.shrink_sequence, + self.config.shrink_run_limit, + ); + + if !can_continue || current_run == self.config.depth - 1 { + *last_run_calldata.borrow_mut() = inputs.clone(); + } - if !can_continue || current_run == self.config.depth - 1 { - *last_run_calldata.borrow_mut() = inputs.clone(); - } + if !can_continue { + break + } - if !can_continue { - break + *last_call_results.borrow_mut() = call_results; + current_run += 1; } - *last_call_results.borrow_mut() = call_results; - // Generates the next call from the run using the recently updated // dictionary. - inputs.extend( + inputs.push( strat .new_tree(&mut branch_runner.borrow_mut()) .map_err(|_| TestCaseError::Fail("Could not generate case".into()))? @@ -772,7 +791,7 @@ fn can_continue( failures.reverts += 1; // If fail on revert is set, we must return immediately. if fail_on_revert { - let error = InvariantFuzzError::new( + let case_data = FailedInvariantCaseData::new( invariant_contract, None, calldata, @@ -781,8 +800,8 @@ fn can_continue( shrink_sequence, shrink_run_limit, ); - - failures.revert_reason = Some(error.revert_reason.clone()); + failures.revert_reason = Some(case_data.revert_reason.clone()); + let error = InvariantFuzzError::Revert(case_data); failures.error = Some(error); return RichInvariantResults::new(false, None) diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 29d868bad44d6..e6dedc9cd8dd5 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -59,11 +59,10 @@ pub fn invariant_strat( contracts: FuzzRunIdentifiedContracts, dictionary_weight: u32, calldata_fuzz_config: CalldataFuzzDictionary, -) -> impl Strategy> { +) -> impl Strategy { // We only want to seed the first value, since we want to generate the rest as we mutate the // state generate_call(fuzz_state, senders, contracts, dictionary_weight, calldata_fuzz_config) - .prop_map(|x| vec![x]) } /// Strategy to generate a transaction where the `sender`, `target` and `calldata` are all generated diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index ca3e8362940b1..29507de8d5d7a 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -25,7 +25,7 @@ use foundry_evm::{ fuzz::{invariant::InvariantContract, CounterExample}, traces::{load_contracts, TraceKind}, }; -use proptest::test_runner::{TestError, TestRunner}; +use proptest::test_runner::TestRunner; use rayon::prelude::*; use std::{ collections::{BTreeMap, HashMap}, @@ -513,26 +513,28 @@ impl<'a> ContractRunner<'a> { let mut logs = logs.clone(); let mut traces = traces.clone(); let success = error.is_none(); - let reason = error - .as_ref() - .and_then(|err| (!err.revert_reason.is_empty()).then(|| err.revert_reason.clone())); + let reason = error.as_ref().and_then(|err| err.revert_reason()); let mut coverage = coverage.clone(); match error { // If invariants were broken, replay the error to collect logs and traces - Some(error @ InvariantFuzzError { test_error: TestError::Fail(_, _), .. }) => { - match error.replay( - self.executor.clone(), - known_contracts, - identified_contracts.clone(), - &mut logs, - &mut traces, - ) { - Ok(c) => counterexample = c, - Err(err) => { - error!(%err, "Failed to replay invariant error"); - } - }; - } + Some(error) => match error { + InvariantFuzzError::BrokenInvariant(case_data) | + InvariantFuzzError::Revert(case_data) => { + match case_data.replay( + self.executor.clone(), + known_contracts, + identified_contracts.clone(), + &mut logs, + &mut traces, + ) { + Ok(c) => counterexample = c, + Err(err) => { + error!(%err, "Failed to replay invariant error"); + } + }; + } + InvariantFuzzError::MaxAssumeRejects(_) => {} + }, // If invariants ran successfully, replay the last run to collect logs and // traces. diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 28ac405cc351a..99b9ad962783e 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -141,6 +141,10 @@ async fn test_invariant() { "fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", vec![("invariant_owner_never_changes()", true, None, None, None)], ), + ( + "fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", + vec![("invariant_dummy()", true, None, None, None)], + ), ]), ); } @@ -367,3 +371,40 @@ async fn test_invariant_calldata_fuzz_dictionary_addresses() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_assume_does_not_revert() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAssume.t.sol"); + let mut runner = runner(); + // Should not treat vm.assume as revert. + runner.test_options.invariant.fail_on_revert = true; + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", + vec![("invariant_dummy()", true, None, None, None)], + )]), + ); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_assume_respects_restrictions() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAssume.t.sol"); + let mut runner = runner(); + runner.test_options.invariant.max_assume_rejects = 1; + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", + vec![( + "invariant_dummy()", + false, + Some("The `vm.assume` cheatcode rejected too many inputs (1 allowed)".into()), + None, + None, + )], + )]), + ); +} diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 968a0928070e5..609181f1a8e31 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -111,6 +111,7 @@ pub static TEST_OPTS: Lazy = Lazy::new(|| { shrink_sequence: true, shrink_run_limit: 2usize.pow(18u32), preserve_state: false, + max_assume_rejects: 65536, }) .build(&COMPILED, &PROJECT.paths.root) .expect("Config loaded") diff --git a/testdata/fuzz/invariant/common/InvariantAssume.t.sol b/testdata/fuzz/invariant/common/InvariantAssume.t.sol new file mode 100644 index 0000000000000..3065a70a550ee --- /dev/null +++ b/testdata/fuzz/invariant/common/InvariantAssume.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.0; + +import "ds-test/test.sol"; +import "../../../cheats/Vm.sol"; + +contract Handler is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function doSomething(uint256 param) public { + vm.assume(param != 0); + } +} + +contract InvariantAssume is DSTest { + Handler handler; + + function setUp() public { + handler = new Handler(); + } + + function invariant_dummy() public {} +} From 6e0f3919fa6527e72150e0fdc12962970c6a3580 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 6 Mar 2024 19:25:53 +0100 Subject: [PATCH 0715/1963] chore(deps): unpin and bump ethers (#7327) * chore(deps): unpin and bump ethers Hopefully for the last time. * chore: cargo clippo --- Cargo.lock | 71 ++++++++++++--------- Cargo.toml | 37 +++-------- crates/anvil/src/eth/backend/mem/storage.rs | 2 +- crates/config/src/lib.rs | 1 + crates/evm/coverage/src/analysis.rs | 2 +- crates/forge/tests/it/core.rs | 4 +- 6 files changed, 53 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f30364d0384a..ba859dda4e878 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2407,8 +2407,9 @@ dependencies = [ [[package]] name = "ethers" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816841ea989f0c69e459af1cf23a6b0033b19a55424a1ea3a30099becdb8dec0" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2422,8 +2423,9 @@ dependencies = [ [[package]] name = "ethers-addressbook" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5495afd16b4faa556c3bba1f21b98b4983e53c1755022377051a975c3b021759" dependencies = [ "ethers-core", "once_cell", @@ -2433,8 +2435,9 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fceafa3578c836eeb874af87abacfb041f92b4da0a78a5edd042564b8ecdaaa" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2451,8 +2454,9 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" dependencies = [ "Inflector", "const-hex", @@ -2474,8 +2478,9 @@ dependencies = [ [[package]] name = "ethers-contract-derive" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87689dcabc0051cde10caaade298f9e9093d65f6125c14575db3fd8c669a168f" dependencies = [ "Inflector", "const-hex", @@ -2489,8 +2494,9 @@ dependencies = [ [[package]] name = "ethers-core" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" dependencies = [ "arrayvec", "bytes", @@ -2518,8 +2524,9 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" dependencies = [ "chrono", "ethers-core", @@ -2533,8 +2540,9 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48f9fdf09aec667c099909d91908d5eaf9be1bd0e2500ba4172c1d28bfaa43de" dependencies = [ "async-trait", "auto_impl", @@ -2558,8 +2566,9 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" dependencies = [ "async-trait", "auto_impl", @@ -2596,8 +2605,9 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228875491c782ad851773b652dd8ecac62cda8571d3bc32a5853644dd26766c2" dependencies = [ "async-trait", "coins-bip32", @@ -2610,7 +2620,6 @@ dependencies = [ "futures-executor", "futures-util", "home", - "protobuf", "rand 0.8.5", "rusoto_core", "rusoto_kms", @@ -2624,8 +2633,9 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.13" -source = "git+https://github.com/gakonst/ethers-rs?rev=73e5de211c32a1f5777eb5194205bdb31f6a3502#73e5de211c32a1f5777eb5194205bdb31f6a3502" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66244a771d9163282646dbeffe0e6eca4dda4146b6498644e678ac6089b11edd" dependencies = [ "cfg-if", "const-hex", @@ -5067,7 +5077,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.52", @@ -5829,9 +5839,9 @@ dependencies = [ [[package]] name = "protobuf" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55bad9126f378a853655831eb7363b7b01b81d19f8cb1218861086ca4a1a61e" +checksum = "b65f4a8ec18723a734e5dc09c173e0abf9690432da5340285d536edcb4dac190" dependencies = [ "once_cell", "protobuf-support", @@ -5840,9 +5850,9 @@ dependencies = [ [[package]] name = "protobuf-support" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d4d7b8601c814cfb36bcebb79f0e61e45e1e93640cf778837833bbed05c372" +checksum = "6872f4d4f4b98303239a2b5838f5bbbb77b01ffc892d627957f37a22d7cfe69c" dependencies = [ "thiserror", ] @@ -7830,13 +7840,12 @@ dependencies = [ [[package]] name = "trezor-client" -version = "0.1.0" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cddb76a030b141d9639470eca2a236f3057a651bba78227cfa77830037a8286" +checksum = "f62c95b37f6c769bd65a0d0beb8b2b003e72998003b896a616a6777c645c05ed" dependencies = [ "byteorder", "hex", - "primitive-types", "protobuf", "rusb", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index fa91bfd440f74..1fd0d18ef196a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,14 +144,14 @@ revm-primitives = { version = "1", default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "e90052361276aebcdc67cb24d8e2c4d907b6d299", default-features = false } ## ethers -ethers = { version = "2.0", default-features = false } -ethers-core = { version = "2.0", default-features = false } -ethers-contract = { version = "2.0", default-features = false } -ethers-contract-abigen = { version = "2.0", default-features = false } -ethers-providers = { version = "2.0", default-features = false } -ethers-signers = { version = "2.0", default-features = false } -ethers-middleware = { version = "2.0", default-features = false } -ethers-solc = { version = "2.0", default-features = false } +ethers = { version = "2.0.14", default-features = false } +ethers-core = { version = "2.0.14", default-features = false } +ethers-contract = { version = "2.0.14", default-features = false } +ethers-contract-abigen = { version = "2.0.14", default-features = false } +ethers-providers = { version = "2.0.14", default-features = false } +ethers-signers = { version = "2.0.14", default-features = false } +ethers-middleware = { version = "2.0.14", default-features = false } +ethers-solc = { version = "2.0.14", default-features = false } ## alloy alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } @@ -209,28 +209,7 @@ hyper = "0.14" tower = "0.4" tower-http = "0.4" -#[patch."https://github.com/gakonst/ethers-rs"] -#ethers = { path = "../ethers-rs/ethers" } -#ethers-addressbook = { path = "../ethers-rs/ethers-addressbook" } -#ethers-contract = { path = "../ethers-rs/ethers-contract" } -#ethers-contract-abigen = { path = "../ethers-rs/ethers-contract/ethers-contract-abigen" } -#ethers-core = { path = "../ethers-rs/ethers-core" } -#ethers-etherscan = { path = "../ethers-rs/ethers-etherscan" } -#ethers-middleware = { path = "../ethers-rs/ethers-middleware" } -#ethers-providers = { path = "../ethers-rs/ethers-providers" } -#ethers-signers = { path = "../ethers-rs/ethers-signers" } -#ethers-solc = { path = "../ethers-rs/ethers-solc" } - [patch.crates-io] -ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } -ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } -ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } -ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } -ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } -ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } -ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } -ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "73e5de211c32a1f5777eb5194205bdb31f6a3502" } - revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 9e907cff4d6b6..0e2ac2b636ad8 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -471,7 +471,7 @@ mod tests { tokio::time::sleep(std::time::Duration::from_secs(2)).await; assert_eq!(storage.on_disk_states.len(), 1); - assert!(storage.on_disk_states.get(&one).is_some()); + assert!(storage.on_disk_states.contains_key(&one)); let loaded = storage.get(&one).unwrap(); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index a076acf77f46c..f14f446c242d7 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -4525,6 +4525,7 @@ mod tests { } #[test] + #[allow(unknown_lints, non_local_definitions)] fn can_use_impl_figment_macro() { #[derive(Default, Serialize)] struct MyArgs { diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 2ebd1be106365..9af93cb688c49 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -576,7 +576,7 @@ impl SourceAnalyzer { fn analyze_contracts(&mut self) -> eyre::Result<()> { for contract_id in self.contracts.keys() { // Find this contract's coverage items if we haven't already - if self.contract_items.get(contract_id).is_none() { + if !self.contract_items.contains_key(contract_id) { let ContractVisitor { items, base_contract_node_ids, .. } = ContractVisitor::new( contract_id.source_id, self.sources.get(&contract_id.source_id).unwrap_or_else(|| { diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index f581407d573cf..96a0aedce278a 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -689,8 +689,8 @@ async fn test_doesnt_run_abstract_contract() { let filter = Filter::new(".*", ".*", ".*Abstract.t.sol".to_string().as_str()); let mut runner = runner(); let results = runner.test_collect(&filter); - assert!(results.get("core/Abstract.t.sol:AbstractTestBase").is_none()); - assert!(results.get("core/Abstract.t.sol:AbstractTest").is_some()); + assert!(!results.contains_key("core/Abstract.t.sol:AbstractTestBase")); + assert!(results.contains_key("core/Abstract.t.sol:AbstractTest")); } #[tokio::test(flavor = "multi_thread")] From 938f848ec4e94ca81f6c2eb096fcd83be13765a1 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 6 Mar 2024 22:28:06 +0400 Subject: [PATCH 0716/1963] refactor: extract verify to separate crate (#7326) * refactor: extract verify to separate crate * warn unused deps --- Cargo.lock | 31 ++++++++++++++ Cargo.toml | 1 + crates/forge/Cargo.toml | 1 + crates/forge/bin/cmd/create.rs | 8 ++-- crates/forge/bin/cmd/debug.rs | 3 +- crates/forge/bin/cmd/mod.rs | 2 - crates/forge/bin/cmd/script/mod.rs | 5 ++- crates/forge/bin/cmd/script/sequence.rs | 2 +- crates/forge/bin/cmd/script/verify.rs | 5 +-- crates/forge/bin/opts.rs | 24 +++-------- crates/verify/Cargo.toml | 41 +++++++++++++++++++ .../src}/etherscan/flatten.rs | 0 .../verify => verify/src}/etherscan/mod.rs | 5 +-- .../src}/etherscan/standard_json.rs | 0 .../cmd/verify/mod.rs => verify/src/lib.rs} | 9 +++- .../bin/cmd/verify => verify/src}/provider.rs | 0 crates/{forge/bin/cmd => verify/src}/retry.rs | 0 .../bin/cmd/verify => verify/src}/sourcify.rs | 0 18 files changed, 100 insertions(+), 37 deletions(-) create mode 100644 crates/verify/Cargo.toml rename crates/{forge/bin/cmd/verify => verify/src}/etherscan/flatten.rs (100%) rename crates/{forge/bin/cmd/verify => verify/src}/etherscan/mod.rs (99%) rename crates/{forge/bin/cmd/verify => verify/src}/etherscan/standard_json.rs (100%) rename crates/{forge/bin/cmd/verify/mod.rs => verify/src/lib.rs} (98%) rename crates/{forge/bin/cmd/verify => verify/src}/provider.rs (100%) rename crates/{forge/bin/cmd => verify/src}/retry.rs (100%) rename crates/{forge/bin/cmd/verify => verify/src}/sourcify.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index ba859dda4e878..b936a44b1634e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2924,6 +2924,7 @@ dependencies = [ "eyre", "forge-doc", "forge-fmt", + "forge-verify", "foundry-block-explorers", "foundry-cli", "foundry-common", @@ -3008,6 +3009,36 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "forge-verify" +version = "0.2.0" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "async-trait", + "clap", + "const-hex", + "ethers-providers", + "eyre", + "foundry-block-explorers", + "foundry-cli", + "foundry-common", + "foundry-compilers", + "foundry-config", + "foundry-evm", + "foundry-test-utils", + "futures", + "once_cell", + "regex", + "reqwest", + "semver 1.0.22", + "serde", + "serde_json", + "tempfile", + "tokio", + "tracing", +] + [[package]] name = "form_urlencoded" version = "1.2.1" diff --git a/Cargo.toml b/Cargo.toml index 1fd0d18ef196a..ba0cddfa212cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,6 +118,7 @@ forge = { path = "crates/forge" } forge-doc = { path = "crates/doc" } forge-fmt = { path = "crates/fmt" } +forge-verify = { path = "crates/verify" } foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } foundry-cli = { path = "crates/cli" } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 516575ce543f7..29d01b5c55c3d 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -45,6 +45,7 @@ yansi = "0.5" # bin forge-doc.workspace = true forge-fmt.workspace = true +forge-verify.workspace = true foundry-cli.workspace = true foundry-debugger.workspace = true diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index ed9a17aadf650..9dee30675d5ff 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -1,4 +1,3 @@ -use super::{retry::RetryArgs, verify}; use alloy_dyn_abi::{DynSolValue, JsonAbiExt, ResolveSolType}; use alloy_json_abi::{Constructor, JsonAbi}; use alloy_primitives::{Address, Bytes}; @@ -14,6 +13,7 @@ use ethers_core::{ use ethers_middleware::SignerMiddleware; use ethers_providers::Middleware; use eyre::{Context, Result}; +use forge_verify::RetryArgs; use foundry_cli::{ opts::{CoreBuildArgs, EthereumOpts, EtherscanOpts, TransactionOpts}, utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, @@ -80,7 +80,7 @@ pub struct CreateArgs { eth: EthereumOpts, #[command(flatten)] - pub verifier: verify::VerifierArgs, + pub verifier: forge_verify::VerifierArgs, #[command(flatten)] retry: RetryArgs, @@ -169,7 +169,7 @@ impl CreateArgs { ) -> Result<()> { // NOTE: this does not represent the same `VerifyArgs` that would be sent after deployment, // since we don't know the address yet. - let mut verify = verify::VerifyArgs { + let mut verify = forge_verify::VerifyArgs { address: Default::default(), contract: self.contract.clone(), compiler_version: None, @@ -323,7 +323,7 @@ impl CreateArgs { let num_of_optimizations = if self.opts.compiler.optimize { self.opts.compiler.optimizer_runs } else { None }; - let verify = verify::VerifyArgs { + let verify = forge_verify::VerifyArgs { address, contract: self.contract, compiler_version: None, diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs index dafbf965a6a94..75f27da53919d 100644 --- a/crates/forge/bin/cmd/debug.rs +++ b/crates/forge/bin/cmd/debug.rs @@ -1,5 +1,6 @@ -use super::{build::BuildArgs, retry::RETRY_VERIFY_ON_CREATE, script::ScriptArgs}; +use super::{build::BuildArgs, script::ScriptArgs}; use clap::{Parser, ValueHint}; +use forge_verify::retry::RETRY_VERIFY_ON_CREATE; use foundry_cli::opts::CoreBuildArgs; use foundry_common::evm::EvmArgs; use std::path::PathBuf; diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index 92c80e219fb39..1e1a91cbf9c43 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -56,12 +56,10 @@ pub mod inspect; pub mod install; pub mod remappings; pub mod remove; -pub mod retry; pub mod script; pub mod selectors; pub mod snapshot; pub mod test; pub mod tree; pub mod update; -pub mod verify; pub mod watch; diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 8fe66f8396964..79c8f937ff123 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -1,4 +1,4 @@ -use super::{build::BuildArgs, retry::RetryArgs}; +use super::build::BuildArgs; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; use alloy_primitives::{Address, Bytes, Log, U256, U64}; @@ -17,6 +17,7 @@ use forge::{ render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, }; +use forge_verify::RetryArgs; use foundry_common::{ abi::{encode_function_args, get_func}, errors::UnlinkedByteCode, @@ -182,7 +183,7 @@ pub struct ScriptArgs { pub evm_opts: EvmArgs, #[command(flatten)] - pub verifier: super::verify::VerifierArgs, + pub verifier: forge_verify::VerifierArgs, #[command(flatten)] pub retry: RetryArgs, diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/forge/bin/cmd/script/sequence.rs index 6223bd1048485..0e97862bcf101 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/forge/bin/cmd/script/sequence.rs @@ -5,11 +5,11 @@ use crate::cmd::{ transaction::{wrapper, AdditionalContract, TransactionWithMetadata}, verify::VerifyBundle, }, - verify::provider::VerificationProviderType, }; use alloy_primitives::{Address, TxHash}; use ethers_core::types::{transaction::eip2718::TypedTransaction, TransactionReceipt}; use eyre::{ContextCompat, Result, WrapErr}; +use forge_verify::provider::VerificationProviderType; use foundry_cli::utils::now; use foundry_common::{ fs, shell, diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/forge/bin/cmd/script/verify.rs index 96b778edaf87b..43293268d5c1a 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/forge/bin/cmd/script/verify.rs @@ -1,8 +1,5 @@ -use crate::cmd::{ - retry::RetryArgs, - verify::{VerifierArgs, VerifyArgs}, -}; use alloy_primitives::Address; +use forge_verify::{RetryArgs, VerifierArgs, VerifyArgs}; use foundry_cli::opts::{EtherscanOpts, ProjectPathsArgs}; use foundry_common::ContractsByArtifact; use foundry_compilers::{info::ContractInfo, Project}; diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 4a72b80fc7c07..5e5cfda7c8b6f 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -1,25 +1,11 @@ use crate::cmd::{ - bind::BindArgs, - build::BuildArgs, - cache::CacheArgs, - config, coverage, - create::CreateArgs, - debug::DebugArgs, - doc::DocArgs, - flatten, - fmt::FmtArgs, - geiger, generate, - init::InitArgs, - inspect, - install::InstallArgs, - remappings::RemappingArgs, - remove::RemoveArgs, - script::ScriptArgs, - selectors::SelectorsSubcommands, - snapshot, test, tree, update, - verify::{VerifyArgs, VerifyCheckArgs}, + bind::BindArgs, build::BuildArgs, cache::CacheArgs, config, coverage, create::CreateArgs, + debug::DebugArgs, doc::DocArgs, flatten, fmt::FmtArgs, geiger, generate, init::InitArgs, + inspect, install::InstallArgs, remappings::RemappingArgs, remove::RemoveArgs, + script::ScriptArgs, selectors::SelectorsSubcommands, snapshot, test, tree, update, }; use clap::{Parser, Subcommand, ValueHint}; +use forge_verify::{VerifyArgs, VerifyCheckArgs}; use std::path::PathBuf; const VERSION_MESSAGE: &str = concat!( diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml new file mode 100644 index 0000000000000..a735b39af57bd --- /dev/null +++ b/crates/verify/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "forge-verify" +description = "Contract verification tools" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +foundry-config.workspace = true +foundry-cli.workspace = true +foundry-common.workspace = true +foundry-evm.workspace = true + +serde_json.workspace = true +hex.workspace = true +alloy-json-abi.workspace = true +alloy-primitives.workspace = true +serde.workspace = true +eyre.workspace = true +ethers-providers.workspace = true +tracing.workspace = true +foundry-compilers = { workspace = true, features = ["full"] } +foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } + +clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } +reqwest = { version = "0.11", default-features = false, features = ["json"] } +async-trait = "0.1" +futures = "0.3" +semver = "1" +regex = { version = "1", default-features = false } +once_cell = "1" + +[dev-dependencies] +tokio = { version = "1", features = ["macros"] } +foundry-test-utils.workspace = true +tempfile = "3" \ No newline at end of file diff --git a/crates/forge/bin/cmd/verify/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs similarity index 100% rename from crates/forge/bin/cmd/verify/etherscan/flatten.rs rename to crates/verify/src/etherscan/flatten.rs diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs similarity index 99% rename from crates/forge/bin/cmd/verify/etherscan/mod.rs rename to crates/verify/src/etherscan/mod.rs index f63db1240eb15..42986a160b7c5 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -1,9 +1,8 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; -use crate::cmd::retry::RETRY_CHECK_ON_VERIFY; +use crate::retry::RETRY_CHECK_ON_VERIFY; use alloy_json_abi::Function; use ethers_providers::Middleware; use eyre::{eyre, Context, OptionExt, Result}; -use forge::hashbrown::HashSet; use foundry_block_explorers::{ errors::EtherscanError, utils::lookup_compiler_version, @@ -19,7 +18,7 @@ use foundry_compilers::{ Artifact, Project, Solc, }; use foundry_config::{Chain, Config, SolcReq}; -use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; +use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, hashbrown::HashSet}; use futures::FutureExt; use once_cell::sync::Lazy; use regex::Regex; diff --git a/crates/forge/bin/cmd/verify/etherscan/standard_json.rs b/crates/verify/src/etherscan/standard_json.rs similarity index 100% rename from crates/forge/bin/cmd/verify/etherscan/standard_json.rs rename to crates/verify/src/etherscan/standard_json.rs diff --git a/crates/forge/bin/cmd/verify/mod.rs b/crates/verify/src/lib.rs similarity index 98% rename from crates/forge/bin/cmd/verify/mod.rs rename to crates/verify/src/lib.rs index eeff2cb83c7a2..be451d83fbb2f 100644 --- a/crates/forge/bin/cmd/verify/mod.rs +++ b/crates/verify/src/lib.rs @@ -1,4 +1,8 @@ -use super::retry::RetryArgs; +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + +#[macro_use] +extern crate tracing; + use alloy_primitives::Address; use clap::{Parser, ValueHint}; use eyre::Result; @@ -19,8 +23,11 @@ use etherscan::EtherscanVerificationProvider; pub mod provider; use provider::VerificationProvider; +pub mod retry; mod sourcify; +pub use retry::RetryArgs; + /// Verification provider arguments #[derive(Clone, Debug, Parser)] pub struct VerifierArgs { diff --git a/crates/forge/bin/cmd/verify/provider.rs b/crates/verify/src/provider.rs similarity index 100% rename from crates/forge/bin/cmd/verify/provider.rs rename to crates/verify/src/provider.rs diff --git a/crates/forge/bin/cmd/retry.rs b/crates/verify/src/retry.rs similarity index 100% rename from crates/forge/bin/cmd/retry.rs rename to crates/verify/src/retry.rs diff --git a/crates/forge/bin/cmd/verify/sourcify.rs b/crates/verify/src/sourcify.rs similarity index 100% rename from crates/forge/bin/cmd/verify/sourcify.rs rename to crates/verify/src/sourcify.rs From b6e7c8b50a351ec5779c8cf4790854cc0b23ce8c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 7 Mar 2024 01:22:48 +0400 Subject: [PATCH 0717/1963] refactor: extract linking logic to separate crate (#7329) * refactor: extract linking logic to separate crate * fix cargo check --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + crates/forge/Cargo.toml | 1 + crates/forge/bin/cmd/script/build.rs | 2 +- crates/forge/bin/cmd/script/cmd.rs | 3 ++- crates/forge/src/lib.rs | 2 -- crates/forge/src/multi_runner.rs | 7 ++----- crates/linking/Cargo.toml | 17 +++++++++++++++++ .../{forge/src/link.rs => linking/src/lib.rs} | 2 ++ 9 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 crates/linking/Cargo.toml rename crates/{forge/src/link.rs => linking/src/lib.rs} (99%) diff --git a/Cargo.lock b/Cargo.lock index b936a44b1634e..c35e148ff2ba1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2932,6 +2932,7 @@ dependencies = [ "foundry-config", "foundry-debugger", "foundry-evm", + "foundry-linking", "foundry-test-utils", "foundry-wallets", "futures", @@ -3414,6 +3415,16 @@ dependencies = [ "yansi 0.5.1", ] +[[package]] +name = "foundry-linking" +version = "0.2.0" +dependencies = [ + "alloy-primitives", + "foundry-compilers", + "semver 1.0.22", + "thiserror", +] + [[package]] name = "foundry-macros" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index ba0cddfa212cb..e0c94e7466dc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -133,6 +133,7 @@ foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } foundry-wallets = { path = "crates/wallets" } +foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 29d01b5c55c3d..6d4e40f6b97f7 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -25,6 +25,7 @@ foundry-compilers = { workspace = true, features = ["full"] } foundry-config.workspace = true foundry-evm.workspace = true foundry-wallets.workspace = true +foundry-linking.workspace = true ethers-contract.workspace = true ethers-core.workspace = true diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 4b188d9553237..a2bdc1490d4b3 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,7 +1,6 @@ use super::{ScriptArgs, ScriptConfig}; use alloy_primitives::{Address, Bytes}; use eyre::{Context, ContextCompat, Result}; -use forge::link::{LinkOutput, Linker}; use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::compile::{self, ContractSources, ProjectCompiler}; use foundry_compilers::{ @@ -11,6 +10,7 @@ use foundry_compilers::{ info::ContractInfo, ArtifactId, Project, ProjectCompileOutput, }; +use foundry_linking::{LinkOutput, Linker}; use std::str::FromStr; impl ScriptArgs { diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 70fce668017f2..f864f29f8bc0d 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -7,7 +7,7 @@ use alloy_primitives::{Address, Bytes}; use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::{OptionExt, Result}; -use forge::{link::Linker, traces::CallTraceDecoder}; +use forge::traces::CallTraceDecoder; use foundry_cli::utils::LoadConfig; use foundry_common::{ contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy, @@ -18,6 +18,7 @@ use foundry_compilers::{ }; use foundry_debugger::Debugger; use foundry_evm::inspectors::cheatcodes::{BroadcastableTransaction, ScriptWallets}; +use foundry_linking::Linker; use foundry_wallets::WalletSigner; use std::{collections::HashMap, sync::Arc}; diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 00481591e0798..39854abac8a18 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -13,8 +13,6 @@ pub mod coverage; pub mod gas_report; -pub mod link; - mod multi_runner; pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder}; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 6a8e821b23a0f..36d2f2fd897df 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,10 +1,6 @@ //! Forge test runner for multiple contracts. -use crate::{ - link::{LinkOutput, Linker}, - result::SuiteResult, - ContractRunner, TestFilter, TestOptions, -}; +use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; @@ -19,6 +15,7 @@ use foundry_evm::{ opts::EvmOpts, revm, }; +use foundry_linking::{LinkOutput, Linker}; use rayon::prelude::*; use revm::primitives::SpecId; use std::{ diff --git a/crates/linking/Cargo.toml b/crates/linking/Cargo.toml new file mode 100644 index 0000000000000..31edf1c5d1b3f --- /dev/null +++ b/crates/linking/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "foundry-linking" +description = "Smart contract linking tools" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +foundry-compilers = { workspace = true, features = ["full"] } +semver = "1" +alloy-primitives = { workspace = true, features = ["rlp"] } +thiserror = "1" \ No newline at end of file diff --git a/crates/forge/src/link.rs b/crates/linking/src/lib.rs similarity index 99% rename from crates/forge/src/link.rs rename to crates/linking/src/lib.rs index 55f3f5487b3d2..110a6d8f28b5c 100644 --- a/crates/forge/src/link.rs +++ b/crates/linking/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use alloy_primitives::{Address, Bytes}; use foundry_compilers::{ artifacts::{CompactContractBytecode, Libraries}, From f787fed080e42528cae431c49be5ea611d045f90 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 7 Mar 2024 11:22:42 +0100 Subject: [PATCH 0718/1963] perf: mine new blocks on blocking task (#7328) --- crates/anvil/src/service.rs | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/crates/anvil/src/service.rs b/crates/anvil/src/service.rs index 18ee20d998596..71cfdfecbd8d0 100644 --- a/crates/anvil/src/service.rs +++ b/crates/anvil/src/service.rs @@ -18,7 +18,7 @@ use std::{ sync::Arc, task::{Context, Poll}, }; -use tokio::time::Interval; +use tokio::{task::JoinHandle, time::Interval}; /// The type that drives the blockchain's state /// @@ -101,17 +101,13 @@ impl Future for NodeService { } } -// The type of the future that mines a new block -type BlockMiningFuture = - Pin)> + Send + Sync>>; - /// A type that exclusively mines one block at a time #[must_use = "streams do nothing unless polled"] struct BlockProducer { /// Holds the backend if no block is being mined idle_backend: Option>, /// Single active future that mines a new block - block_mining: Option, + block_mining: Option)>>, /// backlog of sets of transactions ready to be mined queued: VecDeque>>, } @@ -133,19 +129,33 @@ impl Stream for BlockProducer { if !pin.queued.is_empty() { if let Some(backend) = pin.idle_backend.take() { let transactions = pin.queued.pop_front().expect("not empty; qed"); - pin.block_mining = Some(Box::pin(async move { - trace!(target: "miner", "creating new block"); - let block = backend.mine_block(transactions).await; - trace!(target: "miner", "created new block: {}", block.block_number); - (block, backend) - })); + + // we spawn this on as blocking task because in this can be blocking for a while in + // forking mode, because of all the rpc calls to fetch the required state + let handle = tokio::runtime::Handle::current(); + let mining = tokio::task::spawn_blocking(move || { + handle.block_on(async move { + trace!(target: "miner", "creating new block"); + let block = backend.mine_block(transactions).await; + trace!(target: "miner", "created new block: {}", block.block_number); + (block, backend) + }) + }); + pin.block_mining = Some(mining); } } if let Some(mut mining) = pin.block_mining.take() { - if let Poll::Ready((outcome, backend)) = mining.poll_unpin(cx) { - pin.idle_backend = Some(backend); - return Poll::Ready(Some(outcome)) + if let Poll::Ready(res) = mining.poll_unpin(cx) { + return match res { + Ok((outcome, backend)) => { + pin.idle_backend = Some(backend); + Poll::Ready(Some(outcome)) + } + Err(err) => { + panic!("miner task failed: {}", err); + } + } } else { pin.block_mining = Some(mining) } From ebb71622b4720908d4b7aa3b82362fbb78984495 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 7 Mar 2024 18:45:36 +0100 Subject: [PATCH 0719/1963] chore: remove fork caches for eth call and call estimate (#7333) --- crates/anvil/src/eth/backend/fork.rs | 44 +++------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 94408756f64da..c763f4c9a68d1 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -172,26 +172,8 @@ impl ClientFork { request: &TransactionRequest, block: Option, ) -> Result { - let request = Arc::new(request.clone()); let block = block.unwrap_or(BlockNumber::Latest); - - if let BlockNumber::Number(num) = block { - // check if this request was already been sent - let key = (request.clone(), num); - if let Some(res) = self.storage_read().eth_call.get(&key).cloned() { - return Ok(res); - } - } - - let block_id: BlockId = block.into(); - - let res: Bytes = self.provider().call((*request).clone(), Some(block_id)).await?; - - if let BlockNumber::Number(num) = block { - // cache result - let mut storage = self.storage_write(); - storage.eth_call.insert((request, num), res.clone()); - } + let res = self.provider().call((*request).clone(), Some(block.into())).await?; Ok(res) } @@ -202,26 +184,8 @@ impl ClientFork { request: &TransactionRequest, block: Option, ) -> Result { - let request = Arc::new(request.clone()); let block = block.unwrap_or(BlockNumber::Latest); - - if let BlockNumber::Number(num) = block { - // check if this request was already been sent - let key = (request.clone(), num); - if let Some(res) = self.storage_read().eth_gas_estimations.get(&key).cloned() { - return Ok(res); - } - } - - let block_id: BlockId = block.into(); - - let res = self.provider().estimate_gas((*request).clone(), Some(block_id)).await?; - - if let BlockNumber::Number(num) = block { - // cache result - let mut storage = self.storage_write(); - storage.eth_gas_estimations.insert((request, num), res); - } + let res = self.provider().estimate_gas(request.clone(), Some(block.into())).await?; Ok(res) } @@ -662,6 +626,8 @@ impl ClientForkConfig { } /// Contains cached state fetched to serve EthApi requests +/// +/// This is used as a cache so repeated requests to the same data are not sent to the remote client #[derive(Clone, Debug, Default)] pub struct ForkedStorage { pub uncles: HashMap>, @@ -674,8 +640,6 @@ pub struct ForkedStorage { pub geth_transaction_traces: HashMap, pub block_traces: HashMap>, pub block_receipts: HashMap>, - pub eth_gas_estimations: HashMap<(Arc, u64), U256>, - pub eth_call: HashMap<(Arc, u64), Bytes>, pub code_at: HashMap<(Address, u64), Bytes>, } From c3a190290a798b0060c9f22d2dfd320fd02c5c0c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:10:53 +0100 Subject: [PATCH 0720/1963] chore(meta): update CODEOWNERS (#7339) --- .github/CODEOWNERS | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 99659760a2b6a..b452279e757e2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,10 @@ -* @danipopes @evalir @mattsse +* @danipopes @mattsse -crates/anvil/ @evalir @mattsse -crates/evm/coverage/ @evalir @onbjerg +crates/anvil/ @danipopes @mattsse +crates/cheatcodes/ @danipopes @mattsse @klkvr +crates/evm/coverage/ @onbjerg crates/fmt/ @rkrasiuk -crates/macros/impls/ @danipopes +crates/linking/ @klkvr +crates/macros/ @danipopes +crates/script/ @danipopes @mattsse @klkvr +crates/wallets/ @klkvr From b253d8475fa1836bb697e76dfa4b9c08ca0856cd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 7 Mar 2024 22:46:31 +0100 Subject: [PATCH 0721/1963] chore: unify etherscan resolve functions (#7340) --- crates/config/src/lib.rs | 47 ++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f14f446c242d7..7a1d4195d73ba 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -918,6 +918,8 @@ impl Config { /// Returns /// - the matching `ResolvedEtherscanConfig` of the `etherscan` table if `etherscan_api_key` is /// an alias + /// - the matching `ResolvedEtherscanConfig` of the `etherscan` table if a `chain` is + /// configured. an alias /// - the Mainnet `ResolvedEtherscanConfig` if `etherscan_api_key` is set, `None` otherwise /// /// # Example @@ -933,18 +935,7 @@ impl Config { pub fn get_etherscan_config( &self, ) -> Option> { - let maybe_alias = self.etherscan_api_key.as_ref().or(self.eth_rpc_url.as_ref())?; - if self.etherscan.contains_key(maybe_alias) { - // etherscan points to an alias in the `etherscan` table, so we try to resolve that - let mut resolved = self.etherscan.clone().resolved(); - return resolved.remove(maybe_alias) - } - - // we treat the `etherscan_api_key` as actual API key - // if no chain provided, we assume mainnet - let chain = self.chain.unwrap_or(Chain::mainnet()); - let api_key = self.etherscan_api_key.as_ref()?; - ResolvedEtherscanConfig::create(api_key, chain).map(Ok) + self.get_etherscan_config_with_chain(None).transpose() } /// Same as [`Self::get_etherscan_config()`] but optionally updates the config with the given @@ -964,8 +955,9 @@ impl Config { } // try to find by comparing chain IDs after resolving - if let Some(res) = - chain.and_then(|chain| self.etherscan.clone().resolved().find_chain(chain)) + if let Some(res) = chain + .or(self.chain) + .and_then(|chain| self.etherscan.clone().resolved().find_chain(chain)) { match (res, self.etherscan_api_key.as_ref()) { (Ok(mut config), Some(key)) => { @@ -992,6 +984,10 @@ impl Config { } /// Helper function to just get the API key + /// + /// Optionally updates the config with the given `chain`. + /// + /// See also [Self::get_etherscan_config_with_chain] pub fn get_etherscan_api_key(&self, chain: Option) -> Option { self.get_etherscan_config_with_chain(chain).ok().flatten().map(|c| c.key) } @@ -3120,6 +3116,29 @@ mod tests { }); } + #[test] + fn test_resolve_etherscan_chain_id() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [profile.default] + chain_id = "sepolia" + + [etherscan] + sepolia = { key = "FX42Z3BBJJEWXWGYV2X1CIPRSCN" } + "#, + )?; + + let config = Config::load(); + let etherscan = config.get_etherscan_config().unwrap().unwrap(); + assert_eq!(etherscan.chain, Some(NamedChain::Sepolia.into())); + assert_eq!(etherscan.key, "FX42Z3BBJJEWXWGYV2X1CIPRSCN"); + + Ok(()) + }); + } + #[test] fn test_resolve_rpc_url() { figment::Jail::expect_with(|jail| { From 5c3b075f6e2adbba6089d15b383450930de283e7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:52:23 +0100 Subject: [PATCH 0722/1963] chore(traces): add a trace identifier stack/builder (#7338) --- crates/chisel/src/dispatcher.rs | 18 +++--- crates/cli/src/utils/cmd.rs | 12 +++- crates/evm/traces/src/decoder/mod.rs | 19 ++++-- crates/evm/traces/src/identifier/etherscan.rs | 62 ++++++++----------- crates/evm/traces/src/identifier/mod.rs | 58 ++++++++++++++++- crates/forge/bin/cmd/script/mod.rs | 27 ++++---- crates/forge/bin/cmd/test/mod.rs | 16 +++-- 7 files changed, 133 insertions(+), 79 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 46086f1dc56da..b6a4411ac9079 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -17,7 +17,7 @@ use foundry_config::{Config, RpcEndpoint}; use foundry_evm::{ decode::decode_console_logs, traces::{ - identifier::{EtherscanIdentifier, SignaturesIdentifier}, + identifier::{SignaturesIdentifier, TraceIdentifiers}, render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, }; @@ -893,11 +893,6 @@ impl ChiselDispatcher { result: &mut ChiselResult, // known_contracts: &ContractsByArtifact, ) -> eyre::Result { - let mut etherscan_identifier = EtherscanIdentifier::new( - &session_config.foundry_config, - session_config.evm_opts.get_remote_chain_id(), - )?; - let mut decoder = CallTraceDecoderBuilder::new() .with_labels(result.labeled_addresses.clone()) .with_signature_identifier(SignaturesIdentifier::new( @@ -906,9 +901,14 @@ impl ChiselDispatcher { )?) .build(); - for (_, trace) in &mut result.traces { - // decoder.identify(trace, &mut local_identifier); - decoder.identify(trace, &mut etherscan_identifier); + let mut identifier = TraceIdentifiers::new().with_etherscan( + &session_config.foundry_config, + session_config.evm_opts.get_remote_chain_id(), + )?; + if !identifier.is_empty() { + for (_, trace) in &mut result.traces { + decoder.identify(trace, &mut identifier); + } } Ok(decoder) } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 00a76002c831f..1ea54d3f6413e 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -397,12 +397,18 @@ pub async fn handle_traces( .build(); let mut etherscan_identifier = EtherscanIdentifier::new(config, chain)?; - for (_, trace) in &mut result.traces { - decoder.identify(trace, &mut etherscan_identifier); + if let Some(etherscan_identifier) = &mut etherscan_identifier { + for (_, trace) in &mut result.traces { + decoder.identify(trace, etherscan_identifier); + } } if debug { - let sources = etherscan_identifier.get_compiled_contracts().await?; + let sources = if let Some(etherscan_identifier) = etherscan_identifier { + etherscan_identifier.get_compiled_contracts().await? + } else { + Default::default() + }; let mut debugger = Debugger::builder() .debug_arena(&result.debug) .decoder(&decoder) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 6b5aaf35deaf9..fbe797a0030b3 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -7,7 +7,9 @@ use crate::{ use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Error, Event, Function, JsonAbi}; use alloy_primitives::{Address, LogData, Selector, B256}; -use foundry_common::{abi::get_indexed_event, fmt::format_token, SELECTOR_LEN}; +use foundry_common::{ + abi::get_indexed_event, fmt::format_token, ContractsByArtifact, SELECTOR_LEN, +}; use foundry_evm_core::{ abi::{Console, HardhatConsole, Vm, HARDHAT_CONSOLE_SELECTOR_PATCHES}, constants::{ @@ -50,17 +52,22 @@ impl CallTraceDecoderBuilder { self } - /// Add known contracts to the decoder from a `LocalTraceIdentifier`. + /// Add known contracts to the decoder. #[inline] - pub fn with_local_identifier_abis(mut self, identifier: &LocalTraceIdentifier<'_>) -> Self { - let contracts = identifier.contracts(); - trace!(target: "evm::traces", len=contracts.len(), "collecting local identifier ABIs"); + pub fn with_known_contracts(mut self, contracts: &ContractsByArtifact) -> Self { + trace!(target: "evm::traces", len=contracts.len(), "collecting known contract ABIs"); for (abi, _) in contracts.values() { self.decoder.collect_abi(abi, None); } self } + /// Add known contracts to the decoder from a `LocalTraceIdentifier`. + #[inline] + pub fn with_local_identifier_abis(self, identifier: &LocalTraceIdentifier<'_>) -> Self { + self.with_known_contracts(identifier.contracts()) + } + /// Sets the verbosity level of the decoder. #[inline] pub fn with_verbosity(mut self, level: u8) -> Self { @@ -225,7 +232,7 @@ impl CallTraceDecoder { fn addresses<'a>( &'a self, arena: &'a CallTraceArena, - ) -> impl Iterator)> + 'a { + ) -> impl Iterator)> + Clone + 'a { arena .nodes() .iter() diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 43552f12b250c..50c273d07b0fe 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -25,10 +25,9 @@ use std::{ use tokio::time::{Duration, Interval}; /// A trace identifier that tries to identify addresses using Etherscan. -#[derive(Default)] pub struct EtherscanIdentifier { /// The Etherscan client - client: Option>, + client: Arc, /// Tracks whether the API key provides was marked as invalid /// /// After the first [EtherscanError::InvalidApiKey] this will get set to true, so we can @@ -40,22 +39,21 @@ pub struct EtherscanIdentifier { impl EtherscanIdentifier { /// Creates a new Etherscan identifier with the given client - pub fn new(config: &Config, chain: Option) -> eyre::Result { + pub fn new(config: &Config, chain: Option) -> eyre::Result> { + // In offline mode, don't use Etherscan. if config.offline { - // offline mode, don't use etherscan - return Ok(Default::default()) - } - if let Some(config) = config.get_etherscan_config_with_chain(chain)? { - trace!(target: "etherscanidentifier", chain=?config.chain, url=?config.api_url, "using etherscan identifier"); - Ok(Self { - client: Some(Arc::new(config.into_client()?)), - invalid_api_key: Arc::new(Default::default()), - contracts: BTreeMap::new(), - sources: BTreeMap::new(), - }) - } else { - Ok(Default::default()) + return Ok(None); } + let Some(config) = config.get_etherscan_config_with_chain(chain)? else { + return Ok(None); + }; + trace!(target: "traces::etherscan", chain=?config.chain, url=?config.api_url, "using etherscan identifier"); + Ok(Some(Self { + client: Arc::new(config.into_client()?), + invalid_api_key: Arc::new(AtomicBool::new(false)), + contracts: BTreeMap::new(), + sources: BTreeMap::new(), + })) } /// Goes over the list of contracts we have pulled from the traces, clones their source from @@ -101,18 +99,13 @@ impl TraceIdentifier for EtherscanIdentifier { { trace!(target: "evm::traces", "identify {:?} addresses", addresses.size_hint().1); - let Some(client) = self.client.clone() else { - // no client was configured - return Vec::new() - }; - if self.invalid_api_key.load(Ordering::Relaxed) { // api key was marked as invalid return Vec::new() } let mut fetcher = EtherscanFetcher::new( - client, + self.client.clone(), Duration::from_secs(1), 5, Arc::clone(&self.invalid_api_key), @@ -191,16 +184,13 @@ impl EtherscanFetcher { fn queue_next_reqs(&mut self) { while self.in_progress.len() < self.concurrency { - if let Some(addr) = self.queue.pop() { - let client = Arc::clone(&self.client); - trace!(target: "etherscanidentifier", "fetching info for {:?}", addr); - self.in_progress.push(Box::pin(async move { - let res = client.contract_source_code(addr).await; - (addr, res) - })); - } else { - break - } + let Some(addr) = self.queue.pop() else { break }; + let client = Arc::clone(&self.client); + self.in_progress.push(Box::pin(async move { + trace!(target: "traces::etherscan", ?addr, "fetching info"); + let res = client.contract_source_code(addr).await; + (addr, res) + })); } } } @@ -234,24 +224,24 @@ impl Stream for EtherscanFetcher { } } Err(EtherscanError::RateLimitExceeded) => { - warn!(target: "etherscanidentifier", "rate limit exceeded on attempt"); + warn!(target: "traces::etherscan", "rate limit exceeded on attempt"); pin.backoff = Some(tokio::time::interval(pin.timeout)); pin.queue.push(addr); } Err(EtherscanError::InvalidApiKey) => { - warn!(target: "etherscanidentifier", "invalid api key"); + warn!(target: "traces::etherscan", "invalid api key"); // mark key as invalid pin.invalid_api_key.store(true, Ordering::Relaxed); return Poll::Ready(None) } Err(EtherscanError::BlockedByCloudflare) => { - warn!(target: "etherscanidentifier", "blocked by cloudflare"); + warn!(target: "traces::etherscan", "blocked by cloudflare"); // mark key as invalid pin.invalid_api_key.store(true, Ordering::Relaxed); return Poll::Ready(None) } Err(err) => { - warn!(target: "etherscanidentifier", "could not get etherscan info: {:?}", err); + warn!(target: "traces::etherscan", "could not get etherscan info: {:?}", err); } } } diff --git a/crates/evm/traces/src/identifier/mod.rs b/crates/evm/traces/src/identifier/mod.rs index 6d86b072abf6e..a16b108d8537f 100644 --- a/crates/evm/traces/src/identifier/mod.rs +++ b/crates/evm/traces/src/identifier/mod.rs @@ -1,6 +1,8 @@ use alloy_json_abi::JsonAbi; use alloy_primitives::Address; +use foundry_common::ContractsByArtifact; use foundry_compilers::ArtifactId; +use foundry_config::{Chain, Config}; use std::borrow::Cow; mod local; @@ -33,5 +35,59 @@ pub trait TraceIdentifier { /// Attempts to identify an address in one or more call traces. fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where - A: Iterator)>; + A: Iterator)> + Clone; +} + +/// A collection of trace identifiers. +pub struct TraceIdentifiers<'a> { + /// The local trace identifier. + pub local: Option>, + /// The optional Etherscan trace identifier. + pub etherscan: Option, +} + +impl Default for TraceIdentifiers<'_> { + fn default() -> Self { + Self::new() + } +} + +impl TraceIdentifier for TraceIdentifiers<'_> { + fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> + where + A: Iterator)> + Clone, + { + let mut identities = Vec::new(); + if let Some(local) = &mut self.local { + identities.extend(local.identify_addresses(addresses.clone())); + } + if let Some(etherscan) = &mut self.etherscan { + identities.extend(etherscan.identify_addresses(addresses)); + } + identities + } +} + +impl<'a> TraceIdentifiers<'a> { + /// Creates a new, empty instance. + pub const fn new() -> Self { + Self { local: None, etherscan: None } + } + + /// Sets the local identifier. + pub fn with_local(mut self, known_contracts: &'a ContractsByArtifact) -> Self { + self.local = Some(LocalTraceIdentifier::new(known_contracts)); + self + } + + /// Sets the etherscan identifier. + pub fn with_etherscan(mut self, config: &Config, chain: Option) -> eyre::Result { + self.etherscan = EtherscanIdentifier::new(config, chain)?; + Ok(self) + } + + /// Returns `true` if there are no set identifiers. + pub fn is_empty(&self) -> bool { + self.local.is_none() && self.etherscan.is_none() + } } diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index 79c8f937ff123..98c3e223db765 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -13,8 +13,8 @@ use forge::{ decode::decode_console_logs, opts::EvmOpts, traces::{ - identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, - render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, + identifier::SignaturesIdentifier, render_trace_arena, CallTraceDecoder, + CallTraceDecoderBuilder, TraceKind, Traces, }, }; use forge_verify::RetryArgs; @@ -42,6 +42,7 @@ use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, decode::RevertDecoder, inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, + traces::identifier::TraceIdentifiers, }; use foundry_wallets::MultiWalletOpts; use futures::future; @@ -198,33 +199,29 @@ impl ScriptArgs { result: &mut ScriptResult, known_contracts: &ContractsByArtifact, ) -> Result { - let verbosity = script_config.evm_opts.verbosity; - let mut etherscan_identifier = EtherscanIdentifier::new( - &script_config.config, - script_config.evm_opts.get_remote_chain_id(), - )?; - - let mut local_identifier = LocalTraceIdentifier::new(known_contracts); let mut decoder = CallTraceDecoderBuilder::new() .with_labels(result.labeled_addresses.clone()) - .with_verbosity(verbosity) - .with_local_identifier_abis(&local_identifier) + .with_verbosity(script_config.evm_opts.verbosity) + .with_known_contracts(known_contracts) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), script_config.config.offline, )?) .build(); + let mut identifier = TraceIdentifiers::new() + .with_local(known_contracts) + .with_etherscan(&script_config.config, script_config.evm_opts.get_remote_chain_id())?; // Decoding traces using etherscan is costly as we run into rate limits, // causing scripts to run for a very long time unnecessarily. // Therefore, we only try and use etherscan if the user has provided an API key. let should_use_etherscan_traces = script_config.config.etherscan_api_key.is_some(); + if !should_use_etherscan_traces { + identifier.etherscan = None; + } for (_, trace) in &mut result.traces { - decoder.identify(trace, &mut local_identifier); - if should_use_etherscan_traces { - decoder.identify(trace, &mut etherscan_identifier); - } + decoder.identify(trace, &mut identifier); } Ok(decoder) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 2a0e7bbdbbfa8..3e7d148484c46 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -7,10 +7,7 @@ use forge::{ gas_report::GasReport, inspectors::CheatsConfig, result::{SuiteResult, TestOutcome, TestStatus}, - traces::{ - identifier::{EtherscanIdentifier, LocalTraceIdentifier, SignaturesIdentifier}, - CallTraceDecoderBuilder, TraceKind, - }, + traces::{identifier::SignaturesIdentifier, CallTraceDecoderBuilder, TraceKind}, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, TestOptionsBuilder, }; use foundry_cli::{ @@ -31,6 +28,7 @@ use foundry_config::{ get_available_profiles, Config, }; use foundry_debugger::Debugger; +use foundry_evm::traces::identifier::TraceIdentifiers; use regex::Regex; use std::{sync::mpsc::channel, time::Instant}; use watchexec::config::{InitConfig, RuntimeConfig}; @@ -296,9 +294,10 @@ impl TestArgs { // Set up trace identifiers. let known_contracts = runner.known_contracts.clone(); - let mut local_identifier = LocalTraceIdentifier::new(&known_contracts); let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - let mut etherscan_identifier = EtherscanIdentifier::new(&config, remote_chain_id)?; + let mut identifier = TraceIdentifiers::new() + .with_local(&known_contracts) + .with_etherscan(&config, remote_chain_id)?; // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); @@ -313,7 +312,7 @@ impl TestArgs { // Build the trace decoder. let mut builder = CallTraceDecoderBuilder::new() - .with_local_identifier_abis(&local_identifier) + .with_known_contracts(&known_contracts) .with_verbosity(verbosity); // Signatures are of no value for gas reports. if !self.gas_report { @@ -379,8 +378,7 @@ impl TestArgs { let mut decoded_traces = Vec::with_capacity(result.traces.len()); for (kind, arena) in &result.traces { if identify_addresses { - decoder.identify(arena, &mut local_identifier); - decoder.identify(arena, &mut etherscan_identifier); + decoder.identify(arena, &mut identifier); } // verbosity: From cab82fbbb431815fdfdf2232f97e7de24d135091 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:59:00 +0100 Subject: [PATCH 0723/1963] Add TOML cheatcode support (#7317) * rough outline, handling value to token conversion - different than JSON * handle all value cases * remove serialization for now, only support read and write for now * serialization is required * reuse in-memory serialized_jsons to allow for toml manipulation and serialization, implement additional serializeToml using serializeJson under the hood - this prevents any breaking changes in the cheatcodes * notes * more notes * run cargo cheats, investigate if we can implement path parsing, like JSON implementation * initial test, it is likely easier to implement a json <> toml and toml <> json representation upon parse and write * use simplified serialization toml <> json * use direct Serde conversions * implement basic parser, default one is insufficient * improve test structure, encoding and decoding works correctly * enhance test suite * add explicit type coercion * implement write tests, fix write step for key swap * add parseTomlKeys * complete feature parity and tests * remove debug lines * clean up * revert solc ignore * fix clippy warning * handle "null" string and dedup convert by using explicit internal methods that handle conversion internally * use direct Serde conversion, had issues with arrays and objects before but turn out to be unrelated * dedup formatting * clean up, work through edge cases and undefined behavior * add keyExistsJson, add TODO for deprecation warning of keyExists and handle TOML in traces - like JSON * add deprecated status flag to keyExists * add comments regarding deprecation of `keyExists` in favor of `keyExistsJson` * simplify `Toml` check * update spec * fix broken JSON test * switch back to custom type conversion due to limitations with built-in Serde and enhance test suite * increase robustness of test suite, better unify inputs outputs * technically empty string is the same as empty bytes but for clarity use bytes(0) * handle number edge case, prefer unwrap * Update crates/cheatcodes/src/toml.rs Co-authored-by: Matthias Seitz * remove implicit string bool translation, it is intended to only be done explicitly by coercion * add explicit checks for bool casting in both JSON and TOML tests --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 1 + crates/cheatcodes/Cargo.toml | 2 +- crates/cheatcodes/assets/cheatcodes.json | 422 +++++++++++++++++- .../cheatcodes/assets/cheatcodes.schema.json | 7 + crates/cheatcodes/spec/src/cheatcode.rs | 8 + crates/cheatcodes/spec/src/vm.rs | 98 +++- crates/cheatcodes/src/evm/fork.rs | 2 +- crates/cheatcodes/src/json.rs | 65 +-- crates/cheatcodes/src/lib.rs | 1 + crates/cheatcodes/src/toml.rs | 243 ++++++++++ crates/evm/traces/src/decoder/mod.rs | 35 +- testdata/cheats/Json.t.sol | 138 ++++-- testdata/cheats/Toml.t.sol | 318 +++++++++++++ testdata/cheats/Vm.sol | 21 + testdata/fixtures/Json/test.json | 33 +- .../Json/{wholeJson.json => whole_json.json} | 0 testdata/fixtures/Toml/test.toml | 50 +++ testdata/fixtures/Toml/whole_toml.toml | 3 + .../fixtures/Toml/write_complex_test.toml | 6 + testdata/fixtures/Toml/write_test.toml | 2 + 20 files changed, 1355 insertions(+), 100 deletions(-) create mode 100644 crates/cheatcodes/src/toml.rs create mode 100644 testdata/cheats/Toml.t.sol rename testdata/fixtures/Json/{wholeJson.json => whole_json.json} (100%) create mode 100644 testdata/fixtures/Toml/test.toml create mode 100644 testdata/fixtures/Toml/whole_toml.toml create mode 100644 testdata/fixtures/Toml/write_complex_test.toml create mode 100644 testdata/fixtures/Toml/write_test.toml diff --git a/Cargo.lock b/Cargo.lock index c35e148ff2ba1..e5ec2d58645d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3096,6 +3096,7 @@ dependencies = [ "revm", "serde_json", "thiserror", + "toml 0.8.10", "tracing", "walkdir", ] diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 00cfaf7c39cf9..7524afb635f3b 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -29,7 +29,6 @@ alloy-rpc-types.workspace = true alloy-signer = { workspace = true, features = ["mnemonic", "keystore"] } parking_lot = "0.12" - eyre.workspace = true hex.workspace = true itertools.workspace = true @@ -37,6 +36,7 @@ jsonpath_lib.workspace = true revm.workspace = true serde_json.workspace = true base64.workspace = true +toml = { workspace = true, features = ["preserve_order"] } tracing.workspace = true k256.workspace = true walkdir = "2" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 8e300ad1a08cc..b086072263d16 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4861,7 +4861,7 @@ { "func": { "id": "keyExists", - "description": "Checks if `key` exists in a JSON object.", + "description": "Checks if `key` exists in a JSON object\n`keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions.", "declaration": "function keyExists(string calldata json, string calldata key) external view returns (bool);", "visibility": "external", "mutability": "view", @@ -4875,6 +4875,46 @@ ] }, "group": "json", + "status": "deprecated", + "safety": "safe" + }, + { + "func": { + "id": "keyExistsJson", + "description": "Checks if `key` exists in a JSON object.", + "declaration": "function keyExistsJson(string calldata json, string calldata key) external view returns (bool);", + "visibility": "external", + "mutability": "view", + "signature": "keyExistsJson(string,string)", + "selector": "0xdb4235f6", + "selectorBytes": [ + 219, + 66, + 53, + 246 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "keyExistsToml", + "description": "Checks if `key` exists in a TOML table.", + "declaration": "function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);", + "visibility": "external", + "mutability": "view", + "signature": "keyExistsToml(string,string)", + "selector": "0x600903ad", + "selectorBytes": [ + 96, + 9, + 3, + 173 + ] + }, + "group": "toml", "status": "stable", "safety": "safe" }, @@ -5538,6 +5578,346 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "parseTomlAddress", + "description": "Parses a string of TOML data at `key` and coerces it to `address`.", + "declaration": "function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlAddress(string,string)", + "selector": "0x65e7c844", + "selectorBytes": [ + 101, + 231, + 200, + 68 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlAddressArray", + "description": "Parses a string of TOML data at `key` and coerces it to `address[]`.", + "declaration": "function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlAddressArray(string,string)", + "selector": "0x65c428e7", + "selectorBytes": [ + 101, + 196, + 40, + 231 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlBool", + "description": "Parses a string of TOML data at `key` and coerces it to `bool`.", + "declaration": "function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlBool(string,string)", + "selector": "0xd30dced6", + "selectorBytes": [ + 211, + 13, + 206, + 214 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlBoolArray", + "description": "Parses a string of TOML data at `key` and coerces it to `bool[]`.", + "declaration": "function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlBoolArray(string,string)", + "selector": "0x127cfe9a", + "selectorBytes": [ + 18, + 124, + 254, + 154 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlBytes", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes`.", + "declaration": "function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlBytes(string,string)", + "selector": "0xd77bfdb9", + "selectorBytes": [ + 215, + 123, + 253, + 185 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlBytes32", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes32`.", + "declaration": "function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlBytes32(string,string)", + "selector": "0x8e214810", + "selectorBytes": [ + 142, + 33, + 72, + 16 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlBytes32Array", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes32[]`.", + "declaration": "function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlBytes32Array(string,string)", + "selector": "0x3e716f81", + "selectorBytes": [ + 62, + 113, + 111, + 129 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlBytesArray", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes[]`.", + "declaration": "function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlBytesArray(string,string)", + "selector": "0xb197c247", + "selectorBytes": [ + 177, + 151, + 194, + 71 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlInt", + "description": "Parses a string of TOML data at `key` and coerces it to `int256`.", + "declaration": "function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlInt(string,string)", + "selector": "0xc1350739", + "selectorBytes": [ + 193, + 53, + 7, + 57 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlIntArray", + "description": "Parses a string of TOML data at `key` and coerces it to `int256[]`.", + "declaration": "function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlIntArray(string,string)", + "selector": "0xd3522ae6", + "selectorBytes": [ + 211, + 82, + 42, + 230 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlKeys", + "description": "Returns an array of all the keys in a TOML table.", + "declaration": "function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlKeys(string,string)", + "selector": "0x812a44b2", + "selectorBytes": [ + 129, + 42, + 68, + 178 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlString", + "description": "Parses a string of TOML data at `key` and coerces it to `string`.", + "declaration": "function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlString(string,string)", + "selector": "0x8bb8dd43", + "selectorBytes": [ + 139, + 184, + 221, + 67 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlStringArray", + "description": "Parses a string of TOML data at `key` and coerces it to `string[]`.", + "declaration": "function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlStringArray(string,string)", + "selector": "0x9f629281", + "selectorBytes": [ + 159, + 98, + 146, + 129 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlUint", + "description": "Parses a string of TOML data at `key` and coerces it to `uint256`.", + "declaration": "function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlUint(string,string)", + "selector": "0xcc7b0487", + "selectorBytes": [ + 204, + 123, + 4, + 135 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlUintArray", + "description": "Parses a string of TOML data at `key` and coerces it to `uint256[]`.", + "declaration": "function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlUintArray(string,string)", + "selector": "0xb5df27c8", + "selectorBytes": [ + 181, + 223, + 39, + 200 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseToml_0", + "description": "ABI-encodes a TOML table.", + "declaration": "function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);", + "visibility": "external", + "mutability": "pure", + "signature": "parseToml(string)", + "selector": "0x592151f0", + "selectorBytes": [ + 89, + 33, + 81, + 240 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseToml_1", + "description": "ABI-encodes a TOML table at `key`.", + "declaration": "function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);", + "visibility": "external", + "mutability": "pure", + "signature": "parseToml(string,string)", + "selector": "0x37736e08", + "selectorBytes": [ + 55, + 115, + 110, + 8 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "parseUint", @@ -7497,6 +7877,46 @@ "group": "filesystem", "status": "stable", "safety": "safe" + }, + { + "func": { + "id": "writeToml_0", + "description": "Takes serialized JSON, converts to TOML and write a serialized TOML to a file.", + "declaration": "function writeToml(string calldata json, string calldata path) external;", + "visibility": "external", + "mutability": "", + "signature": "writeToml(string,string)", + "selector": "0xc0865ba7", + "selectorBytes": [ + 192, + 134, + 91, + 167 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "writeToml_1", + "description": "Takes serialized JSON, converts to TOML and write a serialized TOML table to an **existing** TOML file, replacing a value with key = \nThis is useful to replace a specific value of a TOML file, without having to parse the entire thing.", + "declaration": "function writeToml(string calldata json, string calldata path, string calldata valueKey) external;", + "visibility": "external", + "mutability": "", + "signature": "writeToml(string,string,string)", + "selector": "0x51ac6a33", + "selectorBytes": [ + 81, + 172, + 106, + 51 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" } ] } \ No newline at end of file diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index 31f9a1922f058..cd66ecdc42ba7 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -298,6 +298,13 @@ "json" ] }, + { + "description": "Utility cheatcodes that deal with parsing values from and converting values to TOML.\n\nExamples: `parseToml`, `writeToml`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "toml" + ] + }, { "description": "Generic, uncategorized utilities.\n\nExamples: `toString`, `parse*`, `serialize*`.\n\nSafety: safe.", "type": "string", diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index b78659410b44a..95aa9aa476578 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -108,6 +108,12 @@ pub enum Group { /// /// Safety: safe. Json, + /// Utility cheatcodes that deal with parsing values from and converting values to TOML. + /// + /// Examples: `parseToml`, `writeToml`. + /// + /// Safety: safe. + Toml, /// Generic, uncategorized utilities. /// /// Examples: `toString`, `parse*`, `serialize*`. @@ -130,6 +136,7 @@ impl Group { Self::Environment | Self::String | Self::Json | + Self::Toml | Self::Utilities => Some(Safety::Safe), } } @@ -145,6 +152,7 @@ impl Group { Self::Environment => "environment", Self::String => "string", Self::Json => "json", + Self::Toml => "toml", Self::Utilities => "utilities", } } diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index f9e0ca51d7052..bd6500fb7c81b 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1652,9 +1652,13 @@ interface Vm { // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-json to understand the // limitations and caveats of the JSON parsing cheats. + /// Checks if `key` exists in a JSON object + /// `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions. + #[cheatcode(group = Json, status = Deprecated)] + function keyExists(string calldata json, string calldata key) external view returns (bool); /// Checks if `key` exists in a JSON object. #[cheatcode(group = Json)] - function keyExists(string calldata json, string calldata key) external view returns (bool); + function keyExistsJson(string calldata json, string calldata key) external view returns (bool); /// ABI-encodes a JSON object. #[cheatcode(group = Json)] @@ -1816,6 +1820,98 @@ interface Vm { #[cheatcode(group = Json)] function writeJson(string calldata json, string calldata path, string calldata valueKey) external; + // ======== TOML Parsing and Manipulation ======== + + // -------- Reading -------- + + // NOTE: Please read https://book.getfoundry.sh/cheatcodes/parse-toml to understand the + // limitations and caveats of the TOML parsing cheat. + + /// Checks if `key` exists in a TOML table. + #[cheatcode(group = Toml)] + function keyExistsToml(string calldata toml, string calldata key) external view returns (bool); + + /// ABI-encodes a TOML table. + #[cheatcode(group = Toml)] + function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData); + + /// ABI-encodes a TOML table at `key`. + #[cheatcode(group = Toml)] + function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData); + + // The following parseToml cheatcodes will do type coercion, for the type that they indicate. + // For example, parseTomlUint will coerce all values to a uint256. That includes stringified numbers '12.' + // and hex numbers '0xEF.'. + // Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not + // a TOML table. + + /// Parses a string of TOML data at `key` and coerces it to `uint256`. + #[cheatcode(group = Toml)] + function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256); + /// Parses a string of TOML data at `key` and coerces it to `uint256[]`. + #[cheatcode(group = Toml)] + function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory); + /// Parses a string of TOML data at `key` and coerces it to `int256`. + #[cheatcode(group = Toml)] + function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256); + /// Parses a string of TOML data at `key` and coerces it to `int256[]`. + #[cheatcode(group = Toml)] + function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory); + /// Parses a string of TOML data at `key` and coerces it to `bool`. + #[cheatcode(group = Toml)] + function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool); + /// Parses a string of TOML data at `key` and coerces it to `bool[]`. + #[cheatcode(group = Toml)] + function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory); + /// Parses a string of TOML data at `key` and coerces it to `address`. + #[cheatcode(group = Toml)] + function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address); + /// Parses a string of TOML data at `key` and coerces it to `address[]`. + #[cheatcode(group = Toml)] + function parseTomlAddressArray(string calldata toml, string calldata key) + external + pure + returns (address[] memory); + /// Parses a string of TOML data at `key` and coerces it to `string`. + #[cheatcode(group = Toml)] + function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory); + /// Parses a string of TOML data at `key` and coerces it to `string[]`. + #[cheatcode(group = Toml)] + function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory); + /// Parses a string of TOML data at `key` and coerces it to `bytes`. + #[cheatcode(group = Toml)] + function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory); + /// Parses a string of TOML data at `key` and coerces it to `bytes[]`. + #[cheatcode(group = Toml)] + function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory); + /// Parses a string of TOML data at `key` and coerces it to `bytes32`. + #[cheatcode(group = Toml)] + function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32); + /// Parses a string of TOML data at `key` and coerces it to `bytes32[]`. + #[cheatcode(group = Toml)] + function parseTomlBytes32Array(string calldata toml, string calldata key) + external + pure + returns (bytes32[] memory); + + /// Returns an array of all the keys in a TOML table. + #[cheatcode(group = Toml)] + function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys); + + // -------- Writing -------- + + // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-toml to understand how + // to use the TOML writing cheat. + + /// Takes serialized JSON, converts to TOML and write a serialized TOML to a file. + #[cheatcode(group = Toml)] + function writeToml(string calldata json, string calldata path) external; + + /// Takes serialized JSON, converts to TOML and write a serialized TOML table to an **existing** TOML file, replacing a value with key = + /// This is useful to replace a specific value of a TOML file, without having to parse the entire thing. + #[cheatcode(group = Toml)] + function writeToml(string calldata json, string calldata path, string calldata valueKey) external; + // -------- Key Management -------- /// Derives a private key from the name, labels the account with that name, and returns the wallet. diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 436dd1c6284ed..1d8fc2fe4f24b 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -228,7 +228,7 @@ impl Cheatcode for rpcCall { .block_on(provider.raw_request(method, params_json)) .map_err(|err| fmt_err!("{method:?}: {err}"))?; - let result_as_tokens = crate::json::value_to_token(&result) + let result_as_tokens = crate::json::json_value_to_token(&result) .map_err(|err| fmt_err!("failed to parse result: {err}"))?; Ok(result_as_tokens.abi_encode()) diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index 758d4616088a4..b837c8425051c 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -12,10 +12,14 @@ use std::{borrow::Cow, collections::BTreeMap, fmt::Write}; impl Cheatcode for keyExistsCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - let json = parse_json_str(json)?; - let values = select(&json, key)?; - let exists = !values.is_empty(); - Ok(exists.abi_encode()) + check_json_key_exists(json, key) + } +} + +impl Cheatcode for keyExistsJsonCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key } = self; + check_json_key_exists(json, key) } } @@ -134,16 +138,7 @@ impl Cheatcode for parseJsonBytes32ArrayCall { impl Cheatcode for parseJsonKeysCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - let json = parse_json_str(json)?; - let values = select(&json, key)?; - let [value] = values[..] else { - bail!("key {key:?} must return exactly one JSON object"); - }; - let Value::Object(object) = value else { - bail!("JSON value at {key:?} is not an object"); - }; - let keys = object.keys().collect::>(); - Ok(keys.abi_encode()) + parse_json_keys(json, key) } } @@ -280,14 +275,21 @@ impl Cheatcode for writeJson_1Call { } } -fn parse_json(json: &str, path: &str) -> Result { +pub(super) fn check_json_key_exists(json: &str, key: &str) -> Result { + let json = parse_json_str(json)?; + let values = select(&json, key)?; + let exists = !values.is_empty(); + Ok(exists.abi_encode()) +} + +pub(super) fn parse_json(json: &str, path: &str) -> Result { let value = parse_json_str(json)?; let selected = select(&value, path)?; let sol = json_to_sol(&selected)?; Ok(encode(sol)) } -fn parse_json_coerce(json: &str, path: &str, ty: &DynSolType) -> Result { +pub(super) fn parse_json_coerce(json: &str, path: &str, ty: &DynSolType) -> Result { let value = parse_json_str(json)?; let values = select(&value, path)?; ensure!(!values.is_empty(), "no matching value found at {path:?}"); @@ -311,6 +313,19 @@ fn parse_json_coerce(json: &str, path: &str, ty: &DynSolType) -> Result { } } +pub(super) fn parse_json_keys(json: &str, key: &str) -> Result { + let json = parse_json_str(json)?; + let values = select(&json, key)?; + let [value] = values[..] else { + bail!("key {key:?} must return exactly one JSON object"); + }; + let Value::Object(object) = value else { + bail!("JSON value at {key:?} is not an object"); + }; + let keys = object.keys().collect::>(); + Ok(keys.abi_encode()) +} + fn parse_json_str(json: &str) -> Result { serde_json::from_str(json).map_err(|e| fmt_err!("failed parsing JSON: {e}")) } @@ -318,7 +333,7 @@ fn parse_json_str(json: &str) -> Result { fn json_to_sol(json: &[&Value]) -> Result> { let mut sol = Vec::with_capacity(json.len()); for value in json { - sol.push(value_to_token(value)?); + sol.push(json_value_to_token(value)?); } Ok(sol) } @@ -345,7 +360,7 @@ fn encode(values: Vec) -> Vec { /// Canonicalize a json path key to always start from the root of the document. /// Read more about json path syntax: -fn canonicalize_json_path(path: &str) -> Cow<'_, str> { +pub(super) fn canonicalize_json_path(path: &str) -> Cow<'_, str> { if !path.starts_with('$') { format!("${path}").into() } else { @@ -359,12 +374,12 @@ fn canonicalize_json_path(path: &str) -> Cow<'_, str> { /// it will call itself to convert each of it's value and encode the whole as a /// Tuple #[instrument(target = "cheatcodes", level = "trace", ret)] -pub(super) fn value_to_token(value: &Value) -> Result { +pub(super) fn json_value_to_token(value: &Value) -> Result { match value { Value::Null => Ok(DynSolValue::FixedBytes(B256::ZERO, 32)), Value::Bool(boolean) => Ok(DynSolValue::Bool(*boolean)), Value::Array(array) => { - array.iter().map(value_to_token).collect::>().map(DynSolValue::Array) + array.iter().map(json_value_to_token).collect::>().map(DynSolValue::Array) } value @ Value::Object(_) => { // See: [#3647](https://github.com/foundry-rs/foundry/pull/3647) @@ -372,7 +387,7 @@ pub(super) fn value_to_token(value: &Value) -> Result { serde_json::from_value(value.clone()).unwrap(); ordered_object .values() - .map(value_to_token) + .map(json_value_to_token) .collect::>() .map(DynSolValue::Tuple) } @@ -400,18 +415,18 @@ pub(super) fn value_to_token(value: &Value) -> Result { // used. let fallback_s = f.to_string(); if let Ok(n) = fallback_s.parse() { - return Ok(DynSolValue::Uint(n, 256)) + return Ok(DynSolValue::Uint(n, 256)); } if let Ok(n) = I256::from_dec_str(&fallback_s) { - return Ok(DynSolValue::Int(n, 256)) + return Ok(DynSolValue::Int(n, 256)); } } if let Ok(n) = s.parse() { - return Ok(DynSolValue::Uint(n, 256)) + return Ok(DynSolValue::Uint(n, 256)); } if let Ok(n) = s.parse() { - return Ok(DynSolValue::Int(n, 256)) + return Ok(DynSolValue::Int(n, 256)); } } } diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 86cfb0e5d00b4..a2654e953ae86 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -34,6 +34,7 @@ mod json; mod script; mod string; mod test; +mod toml; mod utils; pub use script::ScriptWallets; diff --git a/crates/cheatcodes/src/toml.rs b/crates/cheatcodes/src/toml.rs new file mode 100644 index 0000000000000..886c38a4a5807 --- /dev/null +++ b/crates/cheatcodes/src/toml.rs @@ -0,0 +1,243 @@ +//! Implementations of [`Toml`](crate::Group::Toml) cheatcodes. + +use crate::{ + json::{ + canonicalize_json_path, check_json_key_exists, parse_json, parse_json_coerce, + parse_json_keys, + }, + Cheatcode, Cheatcodes, Result, + Vm::*, +}; +use alloy_dyn_abi::DynSolType; +use foundry_common::fs; +use foundry_config::fs_permissions::FsAccessKind; +use serde_json::Value as JsonValue; +use toml::Value as TomlValue; + +impl Cheatcode for keyExistsTomlCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + check_json_key_exists(&toml_to_json_string(toml)?, key) + } +} + +impl Cheatcode for parseToml_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml } = self; + parse_toml(toml, "$") + } +} + +impl Cheatcode for parseToml_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml(toml, key) + } +} + +impl Cheatcode for parseTomlUintCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Uint(256)) + } +} + +impl Cheatcode for parseTomlUintArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Uint(256)) + } +} + +impl Cheatcode for parseTomlIntCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Int(256)) + } +} + +impl Cheatcode for parseTomlIntArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Int(256)) + } +} + +impl Cheatcode for parseTomlBoolCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Bool) + } +} + +impl Cheatcode for parseTomlBoolArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Bool) + } +} + +impl Cheatcode for parseTomlAddressCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Address) + } +} + +impl Cheatcode for parseTomlAddressArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Address) + } +} + +impl Cheatcode for parseTomlStringCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::String) + } +} + +impl Cheatcode for parseTomlStringArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::String) + } +} + +impl Cheatcode for parseTomlBytesCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Bytes) + } +} + +impl Cheatcode for parseTomlBytesArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::Bytes) + } +} + +impl Cheatcode for parseTomlBytes32Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::FixedBytes(32)) + } +} + +impl Cheatcode for parseTomlBytes32ArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_coerce(toml, key, &DynSolType::FixedBytes(32)) + } +} + +impl Cheatcode for parseTomlKeysCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key } = self; + parse_toml_keys(toml, key) + } +} + +impl Cheatcode for writeToml_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { json, path } = self; + let value = + serde_json::from_str(json).unwrap_or_else(|_| JsonValue::String(json.to_owned())); + + let toml_string = format_json_to_toml(value)?; + super::fs::write_file(state, path.as_ref(), toml_string.as_bytes()) + } +} + +impl Cheatcode for writeToml_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { json, path, valueKey } = self; + let json = + serde_json::from_str(json).unwrap_or_else(|_| JsonValue::String(json.to_owned())); + + let data_path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; + let toml_data = fs::read_to_string(data_path)?; + let json_data: JsonValue = + toml::from_str(&toml_data).map_err(|e| fmt_err!("failed parsing TOML: {e}"))?; + let value = + jsonpath_lib::replace_with(json_data, &canonicalize_json_path(valueKey), &mut |_| { + Some(json.clone()) + })?; + + let toml_string = format_json_to_toml(value)?; + super::fs::write_file(state, path.as_ref(), toml_string.as_bytes()) + } +} + +/// Parse +fn parse_toml_str(toml: &str) -> Result { + toml::from_str(toml).map_err(|e| fmt_err!("failed parsing TOML: {e}")) +} + +/// Parse a TOML string and return the value at the given path. +fn parse_toml(toml: &str, key: &str) -> Result { + parse_json(&toml_to_json_string(toml)?, key) +} + +/// Parse a TOML string and return the value at the given path, coercing it to the given type. +fn parse_toml_coerce(toml: &str, key: &str, ty: &DynSolType) -> Result { + parse_json_coerce(&toml_to_json_string(toml)?, key, ty) +} + +/// Parse a TOML string and return an array of all keys at the given path. +fn parse_toml_keys(toml: &str, key: &str) -> Result { + parse_json_keys(&toml_to_json_string(toml)?, key) +} + +/// Convert a TOML string to a JSON string. +fn toml_to_json_string(toml: &str) -> Result { + let toml = parse_toml_str(toml)?; + let json = toml_to_json_value(toml); + serde_json::to_string(&json).map_err(|e| fmt_err!("failed to serialize JSON: {e}")) +} + +/// Format a JSON value to a TOML pretty string. +fn format_json_to_toml(json: JsonValue) -> Result { + let toml = json_to_toml_value(json); + toml::to_string_pretty(&toml).map_err(|e| fmt_err!("failed to serialize TOML: {e}")) +} + +/// Convert a TOML value to a JSON value. +fn toml_to_json_value(toml: TomlValue) -> JsonValue { + match toml { + TomlValue::String(s) => match s.as_str() { + "null" => JsonValue::Null, + _ => JsonValue::String(s), + }, + TomlValue::Integer(i) => JsonValue::Number(i.into()), + TomlValue::Float(f) => JsonValue::Number(serde_json::Number::from_f64(f).unwrap()), + TomlValue::Boolean(b) => JsonValue::Bool(b), + TomlValue::Array(a) => JsonValue::Array(a.into_iter().map(toml_to_json_value).collect()), + TomlValue::Table(t) => { + JsonValue::Object(t.into_iter().map(|(k, v)| (k, toml_to_json_value(v))).collect()) + } + TomlValue::Datetime(d) => JsonValue::String(d.to_string()), + } +} + +/// Convert a JSON value to a TOML value. +fn json_to_toml_value(json: JsonValue) -> TomlValue { + match json { + JsonValue::String(s) => TomlValue::String(s), + JsonValue::Number(n) => match n.as_i64() { + Some(i) => TomlValue::Integer(i), + None => match n.as_f64() { + Some(f) => TomlValue::Float(f), + None => TomlValue::String(n.to_string()), + }, + }, + JsonValue::Bool(b) => TomlValue::Boolean(b), + JsonValue::Array(a) => TomlValue::Array(a.into_iter().map(json_to_toml_value).collect()), + JsonValue::Object(o) => { + TomlValue::Table(o.into_iter().map(|(k, v)| (k, json_to_toml_value(v))).collect()) + } + JsonValue::Null => TomlValue::String("null".to_string()), + } +} diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index fbe797a0030b3..78193a5f9cee6 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -436,7 +436,9 @@ impl CallTraceDecoder { "parseJsonBytes32" | "parseJsonBytes32Array" | "writeJson" | - "keyExists" | + // `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions. + "keyExists" | + "keyExistsJson" | "serializeBool" | "serializeUint" | "serializeInt" | @@ -448,12 +450,31 @@ impl CallTraceDecoder { None } else { let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; - let token = - if func.name.as_str() == "parseJson" || func.name.as_str() == "keyExists" { - "" - } else { - "" - }; + let token = if func.name.as_str() == "parseJson" || + // `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions. + func.name.as_str() == "keyExists" || + func.name.as_str() == "keyExistsJson" + { + "" + } else { + "" + }; + decoded[0] = DynSolValue::String(token.to_string()); + Some(decoded.iter().map(format_token).collect()) + } + } + s if s.contains("Toml") => { + if self.verbosity >= 5 { + None + } else { + let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; + let token = if func.name.as_str() == "parseToml" || + func.name.as_str() == "keyExistsToml" + { + "" + } else { + "" + }; decoded[0] = DynSolValue::String(token.to_string()); Some(decoded.iter().map(format_token).collect()) } diff --git a/testdata/cheats/Json.t.sol b/testdata/cheats/Json.t.sol index a43a7be5a6b90..3d44dbd2c68a9 100644 --- a/testdata/cheats/Json.t.sol +++ b/testdata/cheats/Json.t.sol @@ -14,39 +14,25 @@ contract ParseJsonTest is DSTest { json = vm.readFile(path); } - function test_uintArray() public { - bytes memory data = vm.parseJson(json, ".uintArray"); - uint256[] memory decodedData = abi.decode(data, (uint256[])); - assertEq(42, decodedData[0]); - assertEq(43, decodedData[1]); - } - - function test_str() public { - bytes memory data = vm.parseJson(json, ".str"); + function test_basicString() public { + bytes memory data = vm.parseJson(json, ".basicString"); string memory decodedData = abi.decode(data, (string)); assertEq("hai", decodedData); } - function test_strArray() public { - bytes memory data = vm.parseJson(json, ".strArray"); + function test_null() public { + bytes memory data = vm.parseJson(json, ".null"); + bytes memory decodedData = abi.decode(data, (bytes)); + assertEq(new bytes(0), decodedData); + } + + function test_stringArray() public { + bytes memory data = vm.parseJson(json, ".stringArray"); string[] memory decodedData = abi.decode(data, (string[])); assertEq("hai", decodedData[0]); assertEq("there", decodedData[1]); } - function test_bool() public { - bytes memory data = vm.parseJson(json, ".bool"); - bool decodedData = abi.decode(data, (bool)); - assertTrue(decodedData); - } - - function test_boolArray() public { - bytes memory data = vm.parseJson(json, ".boolArray"); - bool[] memory decodedData = abi.decode(data, (bool[])); - assertTrue(decodedData[0]); - assertTrue(!decodedData[1]); - } - function test_address() public { bytes memory data = vm.parseJson(json, ".address"); address decodedData = abi.decode(data, (address)); @@ -65,18 +51,31 @@ contract ParseJsonTest is DSTest { assertEq("0000000000000000000000000000000000001337", data); } - struct Nested { - uint256 number; - string str; + function test_bool() public { + bytes memory data = vm.parseJson(json, ".boolTrue"); + bool decodedData = abi.decode(data, (bool)); + assertTrue(decodedData); + + data = vm.parseJson(json, ".boolFalse"); + decodedData = abi.decode(data, (bool)); + assertTrue(!decodedData); } - function test_nestedObject() public { - bytes memory data = vm.parseJson(json, ".nestedObject"); - Nested memory nested = abi.decode(data, (Nested)); - assertEq(nested.number, 115792089237316195423570985008687907853269984665640564039457584007913129639935); - assertEq(nested.str, "NEST"); + function test_boolArray() public { + bytes memory data = vm.parseJson(json, ".boolArray"); + bool[] memory decodedData = abi.decode(data, (bool[])); + assertTrue(decodedData[0]); + assertTrue(!decodedData[1]); + } + + function test_uintArray() public { + bytes memory data = vm.parseJson(json, ".uintArray"); + uint256[] memory decodedData = abi.decode(data, (uint256[])); + assertEq(42, decodedData[0]); + assertEq(43, decodedData[1]); } + // Object keys are sorted alphabetically, regardless of input. struct Whole { string str; string[] strArray; @@ -85,7 +84,7 @@ contract ParseJsonTest is DSTest { function test_wholeObject() public { // we need to make the path relative to the crate that's running tests for it (forge crate) - string memory path = "fixtures/Json/wholeJson.json"; + string memory path = "fixtures/Json/whole_json.json"; console.log(path); json = vm.readFile(path); bytes memory data = vm.parseJson(json); @@ -99,35 +98,68 @@ contract ParseJsonTest is DSTest { function test_coercionRevert() public { vm._expectCheatcodeRevert("values at \".nestedObject\" must not be JSON objects"); - uint256 number = vm.parseJsonUint(json, ".nestedObject"); + vm.parseJsonUint(json, ".nestedObject"); } function test_coercionUint() public { - uint256 number = vm.parseJsonUint(json, ".hexUint"); + uint256 number = vm.parseJsonUint(json, ".uintHex"); assertEq(number, 1231232); - number = vm.parseJsonUint(json, ".stringUint"); + number = vm.parseJsonUint(json, ".uintString"); assertEq(number, 115792089237316195423570985008687907853269984665640564039457584007913129639935); - number = vm.parseJsonUint(json, ".numberUint"); + number = vm.parseJsonUint(json, ".uintNumber"); assertEq(number, 115792089237316195423570985008687907853269984665640564039457584007913129639935); - uint256[] memory numbers = vm.parseJsonUintArray(json, ".arrayUint"); + uint256[] memory numbers = vm.parseJsonUintArray(json, ".uintArray"); + assertEq(numbers[0], 42); + assertEq(numbers[1], 43); + numbers = vm.parseJsonUintArray(json, ".uintStringArray"); assertEq(numbers[0], 1231232); assertEq(numbers[1], 1231232); assertEq(numbers[2], 1231232); } function test_coercionInt() public { - int256 number = vm.parseJsonInt(json, ".hexInt"); + int256 number = vm.parseJsonInt(json, ".intNumber"); assertEq(number, -12); - number = vm.parseJsonInt(json, ".stringInt"); + number = vm.parseJsonInt(json, ".intString"); + assertEq(number, -12); + number = vm.parseJsonInt(json, ".intHex"); assertEq(number, -12); } function test_coercionBool() public { - bool boolean = vm.parseJsonBool(json, ".booleanString"); + bool boolean = vm.parseJsonBool(json, ".boolTrue"); + assertTrue(boolean); + bool boolFalse = vm.parseJsonBool(json, ".boolFalse"); + assertTrue(!boolFalse); + boolean = vm.parseJsonBool(json, ".boolString"); assertEq(boolean, true); - bool[] memory booleans = vm.parseJsonBoolArray(json, ".booleanArray"); - assert(booleans[0]); - assert(!booleans[1]); + bool[] memory booleans = vm.parseJsonBoolArray(json, ".boolArray"); + assertTrue(booleans[0]); + assertTrue(!booleans[1]); + booleans = vm.parseJsonBoolArray(json, ".boolStringArray"); + assertTrue(booleans[0]); + assertTrue(!booleans[1]); + } + + function test_coercionBytes() public { + bytes memory bytes_ = vm.parseJsonBytes(json, ".bytesString"); + assertEq(bytes_, hex"01"); + + bytes[] memory bytesArray = vm.parseJsonBytesArray(json, ".bytesStringArray"); + assertEq(bytesArray[0], hex"01"); + assertEq(bytesArray[1], hex"02"); + } + + struct Nested { + uint256 number; + string str; + } + + function test_nestedObject() public { + bytes memory data = vm.parseJson(json, ".nestedObject"); + Nested memory nested = abi.decode(data, (Nested)); + assertEq(nested.number, 115792089237316195423570985008687907853269984665640564039457584007913129639935); + assertEq(nested.str, "NEST"); } function test_advancedJsonPath() public { @@ -138,7 +170,7 @@ contract ParseJsonTest is DSTest { } function test_canonicalizePath() public { - bytes memory data = vm.parseJson(json, "$.str"); + bytes memory data = vm.parseJson(json, "$.basicString"); string memory decodedData = abi.decode(data, (string)); assertEq("hai", decodedData); } @@ -286,17 +318,25 @@ contract WriteJsonTest is DSTest { assertEq(decodedData.a, 123); } - function test_checkKeyExists() public { + function test_checkKeyExistsJson() public { string memory path = "fixtures/Json/write_complex_test.json"; string memory json = vm.readFile(path); - bool exists = vm.keyExists(json, ".a"); + bool exists = vm.keyExistsJson(json, ".a"); + assertTrue(exists); + + // TODO: issue deprecation warning + exists = vm.keyExists(json, ".a"); assertTrue(exists); } - function test_checkKeyDoesNotExist() public { + function test_checkKeyDoesNotExistJson() public { string memory path = "fixtures/Json/write_complex_test.json"; string memory json = vm.readFile(path); - bool exists = vm.keyExists(json, ".d"); + bool exists = vm.keyExistsJson(json, ".d"); + assertTrue(!exists); + + // TODO: issue deprecation warning + exists = vm.keyExists(json, ".d"); assertTrue(!exists); } diff --git a/testdata/cheats/Toml.t.sol b/testdata/cheats/Toml.t.sol new file mode 100644 index 0000000000000..ccb73ab87a68d --- /dev/null +++ b/testdata/cheats/Toml.t.sol @@ -0,0 +1,318 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "./Vm.sol"; +import "../logs/console.sol"; + +contract ParseTomlTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + string toml; + + function setUp() public { + string memory path = "fixtures/Toml/test.toml"; + toml = vm.readFile(path); + } + + function test_basicString() public { + bytes memory data = vm.parseToml(toml, ".basicString"); + string memory decodedData = abi.decode(data, (string)); + assertEq("hai", decodedData); + } + + function test_nullString() public { + bytes memory data = vm.parseToml(toml, ".nullString"); + string memory decodedData = abi.decode(data, (string)); + assertEq("", decodedData); + } + + function test_stringMultiline() public { + bytes memory data = vm.parseToml(toml, ".multilineString"); + string memory decodedData = abi.decode(data, (string)); + assertEq("hai\nthere\n", decodedData); + } + + function test_stringArray() public { + bytes memory data = vm.parseToml(toml, ".stringArray"); + string[] memory decodedData = abi.decode(data, (string[])); + assertEq("hai", decodedData[0]); + assertEq("there", decodedData[1]); + } + + function test_address() public { + bytes memory data = vm.parseToml(toml, ".address"); + address decodedData = abi.decode(data, (address)); + assertEq(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, decodedData); + } + + function test_addressArray() public { + bytes memory data = vm.parseToml(toml, ".addressArray"); + address[] memory decodedData = abi.decode(data, (address[])); + assertEq(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, decodedData[0]); + assertEq(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D, decodedData[1]); + } + + function test_H160ButNotaddress() public { + string memory data = abi.decode(vm.parseToml(toml, ".H160NotAddress"), (string)); + assertEq("0000000000000000000000000000000000001337", data); + } + + function test_bool() public { + bytes memory data = vm.parseToml(toml, ".boolTrue"); + bool decodedData = abi.decode(data, (bool)); + assertTrue(decodedData); + + data = vm.parseToml(toml, ".boolFalse"); + decodedData = abi.decode(data, (bool)); + assertTrue(!decodedData); + } + + function test_boolArray() public { + bytes memory data = vm.parseToml(toml, ".boolArray"); + bool[] memory decodedData = abi.decode(data, (bool[])); + assertTrue(decodedData[0]); + assertTrue(!decodedData[1]); + } + + function test_dateTime() public { + bytes memory data = vm.parseToml(toml, ".datetime"); + string memory decodedData = abi.decode(data, (string)); + assertEq(decodedData, "2021-08-10T14:48:00Z"); + } + + function test_dateTimeArray() public { + bytes memory data = vm.parseToml(toml, ".datetimeArray"); + string[] memory decodedData = abi.decode(data, (string[])); + assertEq(decodedData[0], "2021-08-10T14:48:00Z"); + assertEq(decodedData[1], "2021-08-10T14:48:00Z"); + } + + function test_uintArray() public { + bytes memory data = vm.parseToml(toml, ".uintArray"); + uint256[] memory decodedData = abi.decode(data, (uint256[])); + assertEq(42, decodedData[0]); + assertEq(43, decodedData[1]); + } + + // Object keys are sorted alphabetically, regardless of input. + struct Whole { + string str; + string[] strArray; + uint256[] uintArray; + } + + function test_wholeToml() public { + // we need to make the path relative to the crate that's running tests for it (forge crate) + string memory path = "fixtures/Toml/whole_toml.toml"; + console.log(path); + toml = vm.readFile(path); + bytes memory data = vm.parseToml(toml); + Whole memory whole = abi.decode(data, (Whole)); + assertEq(whole.str, "hai"); + assertEq(whole.strArray[0], "hai"); + assertEq(whole.strArray[1], "there"); + assertEq(whole.uintArray[0], 42); + assertEq(whole.uintArray[1], 43); + } + + function test_coercionRevert() public { + vm._expectCheatcodeRevert("values at \".nestedObject\" must not be JSON objects"); + vm.parseTomlUint(toml, ".nestedObject"); + } + + function test_coercionUint() public { + uint256 number = vm.parseTomlUint(toml, ".uintNumber"); + assertEq(number, 9223372036854775807); // TOML is limited to 64-bit integers + number = vm.parseTomlUint(toml, ".uintString"); + assertEq(number, 115792089237316195423570985008687907853269984665640564039457584007913129639935); + number = vm.parseTomlUint(toml, ".uintHex"); + assertEq(number, 1231232); + uint256[] memory numbers = vm.parseTomlUintArray(toml, ".uintArray"); + assertEq(numbers[0], 42); + assertEq(numbers[1], 43); + numbers = vm.parseTomlUintArray(toml, ".uintStringArray"); + assertEq(numbers[0], 1231232); + assertEq(numbers[1], 1231232); + assertEq(numbers[2], 1231232); + } + + function test_coercionInt() public { + int256 number = vm.parseTomlInt(toml, ".intNumber"); + assertEq(number, -12); + number = vm.parseTomlInt(toml, ".intString"); + assertEq(number, -12); + number = vm.parseTomlInt(toml, ".intHex"); + assertEq(number, -12); + } + + function test_coercionBool() public { + bool boolean = vm.parseTomlBool(toml, ".boolTrue"); + assertTrue(boolean); + bool boolFalse = vm.parseTomlBool(toml, ".boolFalse"); + assertTrue(!boolFalse); + boolean = vm.parseTomlBool(toml, ".boolString"); + assertEq(boolean, true); + bool[] memory booleans = vm.parseTomlBoolArray(toml, ".boolArray"); + assertTrue(booleans[0]); + assertTrue(!booleans[1]); + booleans = vm.parseTomlBoolArray(toml, ".boolStringArray"); + assertTrue(booleans[0]); + assertTrue(!booleans[1]); + } + + function test_coercionBytes() public { + bytes memory bytes_ = vm.parseTomlBytes(toml, ".bytesString"); + assertEq(bytes_, hex"01"); + + bytes[] memory bytesArray = vm.parseTomlBytesArray(toml, ".bytesStringArray"); + assertEq(bytesArray[0], hex"01"); + assertEq(bytesArray[1], hex"02"); + } + + struct Nested { + uint256 number; + string str; + } + + function test_nestedObject() public { + bytes memory data = vm.parseToml(toml, ".nestedObject"); + Nested memory nested = abi.decode(data, (Nested)); + assertEq(nested.number, 9223372036854775807); // TOML is limited to 64-bit integers + assertEq(nested.str, "NEST"); + } + + function test_advancedJsonPath() public { + bytes memory data = vm.parseToml(toml, ".advancedJsonPath[*].id"); + uint256[] memory numbers = abi.decode(data, (uint256[])); + assertEq(numbers[0], 1); + assertEq(numbers[1], 2); + } + + function test_canonicalizePath() public { + bytes memory data = vm.parseToml(toml, "$.basicString"); + string memory decodedData = abi.decode(data, (string)); + assertEq("hai", decodedData); + } + + function test_nonExistentKey() public { + bytes memory data = vm.parseToml(toml, ".thisKeyDoesNotExist"); + assertEq(0, data.length); + } + + function test_parseTomlKeys() public { + string memory tomlString = + "some_key_to_value = \"some_value\"\n some_key_to_array = [1, 2, 3]\n [some_key_to_object]\n key1 = \"value1\"\n key2 = 2"; + + string[] memory keys = vm.parseTomlKeys(tomlString, "$"); + string[] memory expected = new string[](3); + expected[0] = "some_key_to_value"; + expected[1] = "some_key_to_array"; + expected[2] = "some_key_to_object"; + assertEq(abi.encode(keys), abi.encode(expected)); + + keys = vm.parseTomlKeys(tomlString, ".some_key_to_object"); + expected = new string[](2); + expected[0] = "key1"; + expected[1] = "key2"; + assertEq(abi.encode(keys), abi.encode(expected)); + + vm._expectCheatcodeRevert("JSON value at \".some_key_to_array\" is not an object"); + vm.parseTomlKeys(tomlString, ".some_key_to_array"); + + vm._expectCheatcodeRevert("JSON value at \".some_key_to_value\" is not an object"); + vm.parseTomlKeys(tomlString, ".some_key_to_value"); + + vm._expectCheatcodeRevert("key \".*\" must return exactly one JSON object"); + vm.parseTomlKeys(tomlString, ".*"); + } +} + +contract WriteTomlTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + string json1; + string json2; + + function setUp() public { + json1 = "example"; + json2 = "example2"; + } + + struct simpleJson { + uint256 a; + string b; + } + + struct notSimpleJson { + uint256 a; + string b; + simpleJson c; + } + + function test_serializeNotSimpleToml() public { + string memory json3 = "json3"; + string memory path = "fixtures/Toml/write_complex_test.toml"; + vm.serializeUint(json3, "a", uint256(123)); + string memory semiFinal = vm.serializeString(json3, "b", "test"); + string memory finalJson = vm.serializeString(json3, "c", semiFinal); + console.log(finalJson); + vm.writeToml(finalJson, path); + string memory toml = vm.readFile(path); + bytes memory data = vm.parseToml(toml); + notSimpleJson memory decodedData = abi.decode(data, (notSimpleJson)); + } + + function test_retrieveEntireToml() public { + string memory path = "fixtures/Toml/write_complex_test.toml"; + string memory toml = vm.readFile(path); + bytes memory data = vm.parseToml(toml, "."); + notSimpleJson memory decodedData = abi.decode(data, (notSimpleJson)); + console.log(decodedData.a); + assertEq(decodedData.a, 123); + } + + function test_checkKeyExists() public { + string memory path = "fixtures/Toml/write_complex_test.toml"; + string memory toml = vm.readFile(path); + bool exists = vm.keyExistsToml(toml, ".a"); + assertTrue(exists); + } + + function test_checkKeyDoesNotExist() public { + string memory path = "fixtures/Toml/write_complex_test.toml"; + string memory toml = vm.readFile(path); + bool exists = vm.keyExistsToml(toml, ".d"); + assertTrue(!exists); + } + + function test_writeToml() public { + string memory json3 = "json3"; + string memory path = "fixtures/Toml/write_test.toml"; + vm.serializeUint(json3, "a", uint256(123)); + string memory finalJson = vm.serializeString(json3, "b", "test"); + vm.writeToml(finalJson, path); + + string memory toml = vm.readFile(path); + bytes memory data = vm.parseToml(toml); + simpleJson memory decodedData = abi.decode(data, (simpleJson)); + assertEq(decodedData.a, 123); + assertEq(decodedData.b, "test"); + + // write json3 to key b + vm.writeToml(finalJson, path, ".b"); + // read again + toml = vm.readFile(path); + data = vm.parseToml(toml, ".b"); + decodedData = abi.decode(data, (simpleJson)); + assertEq(decodedData.a, 123); + assertEq(decodedData.b, "test"); + + // replace a single value to key b + address ex = address(0xBEEF); + vm.writeToml(vm.toString(ex), path, ".b"); + toml = vm.readFile(path); + data = vm.parseToml(toml, ".b"); + address decodedAddress = abi.decode(data, (address)); + assertEq(decodedAddress, ex); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index f28c719231fd0..623ef254bf069 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -241,6 +241,8 @@ interface Vm { function isFile(string calldata path) external returns (bool result); function isPersistent(address account) external view returns (bool persistent); function keyExists(string calldata json, string calldata key) external view returns (bool); + function keyExistsJson(string calldata json, string calldata key) external view returns (bool); + function keyExistsToml(string calldata toml, string calldata key) external view returns (bool); function label(address account, string calldata newLabel) external; function load(address target, bytes32 slot) external view returns (bytes32 data); function loadAllocs(string calldata pathToAllocsJson) external; @@ -274,6 +276,23 @@ interface Vm { 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 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 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 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); + function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData); function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue); function pauseGasMetering() external; function prank(address msgSender) external; @@ -372,4 +391,6 @@ interface Vm { function writeJson(string calldata json, string calldata path) external; function writeJson(string calldata json, string calldata path, string calldata valueKey) external; 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; } diff --git a/testdata/fixtures/Json/test.json b/testdata/fixtures/Json/test.json index 4e4ade7830170..1f59ba456269c 100644 --- a/testdata/fixtures/Json/test.json +++ b/testdata/fixtures/Json/test.json @@ -1,28 +1,31 @@ { - "str": "hai", - "uintArray": [42, 43], - "strArray": ["hai", "there"], - "bool": true, - "boolArray": [true, false], + "basicString": "hai", + "null": null, + "stringArray": ["hai", "there"], "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "addressArray": [ "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D" ], "H160NotAddress": "0000000000000000000000000000000000001337", + "boolTrue": true, + "boolFalse": false, + "boolArray": [true, false], + "boolString": "true", + "boolStringArray": [true, "false"], + "uintNumber": 115792089237316195423570985008687907853269984665640564039457584007913129639935, + "uintString": "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "uintHex": "0x12C980", + "uintArray": [42, 43], + "uintStringArray": [1231232, "0x12C980", "1231232"], + "intNumber": -12, + "intString": "-12", + "intHex": "-0xC", + "bytesString": "0x01", + "bytesStringArray": ["0x01", "0x02"], "nestedObject": { "number": 115792089237316195423570985008687907853269984665640564039457584007913129639935, "str": "NEST" }, - "bytesArray": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000966666920776f726b730000000000000000000000000000000000000000000000", - "hexUint": "0x12C980", - "stringUint": "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "numberUint": 115792089237316195423570985008687907853269984665640564039457584007913129639935, - "arrayUint": [1231232, "0x12C980", "1231232"], - "stringInt": "-12", - "numberInt": -12, - "hexInt": "-0xC", - "booleanString": "true", - "booleanArray": [true, "false"], "advancedJsonPath": [{ "id": 1 }, { "id": 2 }] } diff --git a/testdata/fixtures/Json/wholeJson.json b/testdata/fixtures/Json/whole_json.json similarity index 100% rename from testdata/fixtures/Json/wholeJson.json rename to testdata/fixtures/Json/whole_json.json diff --git a/testdata/fixtures/Toml/test.toml b/testdata/fixtures/Toml/test.toml new file mode 100644 index 0000000000000..ce735b8f18cf9 --- /dev/null +++ b/testdata/fixtures/Toml/test.toml @@ -0,0 +1,50 @@ +basicString = "hai" +nullString = "null" +multilineString = """ +hai +there +""" +stringArray = ["hai", "there"] + +address = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" +addressArray = [ + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "0x7109709ECfa91a80626fF3989D68f67F5b1DD12D", +] +H160NotAddress = "0000000000000000000000000000000000001337" + +boolTrue = true +boolFalse = false +boolArray = [true, false] +boolString = "true" +boolStringArray = ["true", "false"] # Array values can't have mixed types + +datetime = 2021-08-10T14:48:00Z +datetimeArray = [2021-08-10T14:48:00Z, 2021-08-10T14:48:00Z] + +uintNumber = 9223372036854775807 # TOML is limited to 64-bit integers +uintString = "115792089237316195423570985008687907853269984665640564039457584007913129639935" +uintHex = "0x12C980" +uintArray = [42, 43] +uintStringArray = [ + "1231232", + "0x12C980", + "1231232", +] # Array values can't have mixed types + +intNumber = -12 +intString = "-12" +intHex = "-0xC" + +bytesString = "0x01" +bytesStringArray = ["0x01", "0x02"] + +[nestedObject] +number = 9223372036854775807 # TOML is limited to 64-bit integers +str = "NEST" + +[[advancedJsonPath]] +id = 1 + +[[advancedJsonPath]] +id = 2 diff --git a/testdata/fixtures/Toml/whole_toml.toml b/testdata/fixtures/Toml/whole_toml.toml new file mode 100644 index 0000000000000..badbd9fbbe5cd --- /dev/null +++ b/testdata/fixtures/Toml/whole_toml.toml @@ -0,0 +1,3 @@ +str = "hai" +uintArray = [42, 43] +strArray = ["hai", "there"] diff --git a/testdata/fixtures/Toml/write_complex_test.toml b/testdata/fixtures/Toml/write_complex_test.toml new file mode 100644 index 0000000000000..60692bc750201 --- /dev/null +++ b/testdata/fixtures/Toml/write_complex_test.toml @@ -0,0 +1,6 @@ +a = 123 +b = "test" + +[c] +a = 123 +b = "test" diff --git a/testdata/fixtures/Toml/write_test.toml b/testdata/fixtures/Toml/write_test.toml new file mode 100644 index 0000000000000..6c084e370e5a6 --- /dev/null +++ b/testdata/fixtures/Toml/write_test.toml @@ -0,0 +1,2 @@ +a = 123 +b = "0x000000000000000000000000000000000000bEEF" From 18bffa695215c605300788e0e4307a55bd5fd589 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 8 Mar 2024 17:30:42 +0400 Subject: [PATCH 0724/1963] script refactoring (#7247) * [wip] script refactoring * execution refactor * refactor simulation * wip * wip * address #7244 * wip: enum for multi/single sequences * refactor execution + resume * wip: refactor verification * wip: cleaning up * naming * wip: clean up * cleanup ScriptSequence * fmt * better rpc tracking * fix rpc logic + extract states to separate file * fmt * some docs * remove --multi flag mentions * docs * checkpoint saves for multichain sequences * docs + broadcasted renamed into dry_run * fmt * Update crates/forge/bin/cmd/script/resume.rs Co-authored-by: Matthias Seitz * fmt * review fixes * fmt * wip: start extracting to separate crate * Use CoreBuildArgs + skip * fmt * review fixes * review fixes * remove redundant methods --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 41 + Cargo.toml | 1 + crates/common/src/contracts.rs | 17 - crates/forge/Cargo.toml | 24 +- crates/forge/bin/cmd/debug.rs | 4 +- crates/forge/bin/cmd/init.rs | 5 - crates/forge/bin/cmd/mod.rs | 1 - crates/forge/bin/cmd/script/broadcast.rs | 701 ------------------ crates/forge/bin/cmd/script/build.rs | 208 ------ crates/forge/bin/cmd/script/cmd.rs | 382 ---------- crates/forge/bin/cmd/script/executor.rs | 325 -------- crates/forge/bin/cmd/script/multi.rs | 240 ------ crates/forge/bin/main.rs | 2 +- crates/forge/bin/opts.rs | 3 +- crates/forge/src/lib.rs | 20 - crates/forge/tests/cli/multi_script.rs | 1 - crates/forge/tests/cli/script.rs | 22 + crates/script/Cargo.toml | 50 ++ .../cmd/script => script/src}/artifacts.rs | 0 crates/script/src/broadcast.rs | 431 +++++++++++ crates/script/src/build.rs | 248 +++++++ crates/script/src/execute.rs | 522 +++++++++++++ .../cmd/script/mod.rs => script/src/lib.rs} | 520 ++++++------- crates/script/src/multi_sequence.rs | 154 ++++ .../cmd/script => script/src}/providers.rs | 0 .../bin/cmd/script => script/src}/receipts.rs | 0 crates/script/src/resume.rs | 106 +++ .../bin/cmd/script => script/src}/runner.rs | 10 +- .../bin/cmd/script => script/src}/sequence.rs | 223 +++--- crates/script/src/simulate.rs | 455 ++++++++++++ .../cmd/script => script/src}/transaction.rs | 15 +- .../bin/cmd/script => script/src}/verify.rs | 40 + 32 files changed, 2421 insertions(+), 2350 deletions(-) delete mode 100644 crates/forge/bin/cmd/script/broadcast.rs delete mode 100644 crates/forge/bin/cmd/script/build.rs delete mode 100644 crates/forge/bin/cmd/script/cmd.rs delete mode 100644 crates/forge/bin/cmd/script/executor.rs delete mode 100644 crates/forge/bin/cmd/script/multi.rs create mode 100644 crates/script/Cargo.toml rename crates/{forge/bin/cmd/script => script/src}/artifacts.rs (100%) create mode 100644 crates/script/src/broadcast.rs create mode 100644 crates/script/src/build.rs create mode 100644 crates/script/src/execute.rs rename crates/{forge/bin/cmd/script/mod.rs => script/src/lib.rs} (62%) create mode 100644 crates/script/src/multi_sequence.rs rename crates/{forge/bin/cmd/script => script/src}/providers.rs (100%) rename crates/{forge/bin/cmd/script => script/src}/receipts.rs (100%) create mode 100644 crates/script/src/resume.rs rename crates/{forge/bin/cmd/script => script/src}/runner.rs (98%) rename crates/{forge/bin/cmd/script => script/src}/sequence.rs (72%) create mode 100644 crates/script/src/simulate.rs rename crates/{forge/bin/cmd/script => script/src}/transaction.rs (98%) rename crates/{forge/bin/cmd/script => script/src}/verify.rs (80%) diff --git a/Cargo.lock b/Cargo.lock index e5ec2d58645d9..8bea54c235aa7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2924,6 +2924,7 @@ dependencies = [ "eyre", "forge-doc", "forge-fmt", + "forge-script", "forge-verify", "foundry-block-explorers", "foundry-cli", @@ -3010,6 +3011,46 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "forge-script" +version = "0.2.0" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "alloy-rpc-types", + "async-recursion", + "clap", + "const-hex", + "dialoguer", + "dunce", + "ethers-core", + "ethers-providers", + "ethers-signers", + "eyre", + "forge-verify", + "foundry-cheatcodes", + "foundry-cli", + "foundry-common", + "foundry-compilers", + "foundry-config", + "foundry-debugger", + "foundry-evm", + "foundry-linking", + "foundry-wallets", + "futures", + "indicatif", + "itertools 0.11.0", + "parking_lot", + "revm-inspectors", + "semver 1.0.22", + "serde", + "serde_json", + "tempfile", + "tracing", + "yansi 0.5.1", +] + [[package]] name = "forge-verify" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index e0c94e7466dc4..68240fde26577 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,6 +119,7 @@ forge = { path = "crates/forge" } forge-doc = { path = "crates/doc" } forge-fmt = { path = "crates/fmt" } forge-verify = { path = "crates/verify" } +forge-script = { path = "crates/script" } foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } foundry-cli = { path = "crates/cli" } diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index a1b251b768dd7..2687b93e3784a 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -135,23 +135,6 @@ unsafe fn count_different_bytes(a: &[u8], b: &[u8]) -> usize { sum } -/// Flattens the contracts into (`id` -> (`JsonAbi`, `Vec`)) pairs -pub fn flatten_contracts( - contracts: &BTreeMap, - deployed_code: bool, -) -> ContractsByArtifact { - ContractsByArtifact( - contracts - .iter() - .filter_map(|(id, c)| { - let bytecode = - if deployed_code { c.deployed_bytecode.bytes() } else { c.bytecode.bytes() }; - bytecode.cloned().map(|code| (id.clone(), (c.abi.clone(), code.into()))) - }) - .collect(), - ) -} - /// Artifact/Contract identifier can take the following form: /// `:`, the `artifact file name` is the name of the json file of /// the contract's artifact and the contract name is the name of the solidity contract, like diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 6d4e40f6b97f7..0a120f9754083 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,7 +15,11 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # lib @@ -47,6 +51,7 @@ yansi = "0.5" forge-doc.workspace = true forge-fmt.workspace = true forge-verify.workspace = true +forge-script.workspace = true foundry-cli.workspace = true foundry-debugger.workspace = true @@ -94,14 +99,25 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } +svm = { package = "svm-rs", version = "0.3", default-features = false, features = [ + "rustls", +] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } [features] default = ["rustls"] -rustls = ["foundry-cli/rustls", "foundry-wallets/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] -openssl = ["foundry-cli/openssl", "reqwest/default-tls", "foundry-wallets/openssl"] +rustls = [ + "foundry-cli/rustls", + "foundry-wallets/rustls", + "reqwest/rustls-tls", + "reqwest/rustls-tls-native-roots", +] +openssl = [ + "foundry-cli/openssl", + "reqwest/default-tls", + "foundry-wallets/openssl", +] asm-keccak = ["alloy-primitives/asm-keccak"] [[bench]] diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs index 75f27da53919d..8fe1d2e32a258 100644 --- a/crates/forge/bin/cmd/debug.rs +++ b/crates/forge/bin/cmd/debug.rs @@ -1,5 +1,5 @@ -use super::{build::BuildArgs, script::ScriptArgs}; use clap::{Parser, ValueHint}; +use forge_script::ScriptArgs; use forge_verify::retry::RETRY_VERIFY_ON_CREATE; use foundry_cli::opts::CoreBuildArgs; use foundry_common::evm::EvmArgs; @@ -48,7 +48,7 @@ impl DebugArgs { target_contract: self.target_contract, sig: self.sig, gas_estimate_multiplier: 130, - opts: BuildArgs { args: self.opts, ..Default::default() }, + opts: self.opts, evm_opts: self.evm_opts, debug: true, retry: RETRY_VERIFY_ON_CREATE, diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 9c8c3fc90c11d..96144dc63d7e5 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -164,11 +164,6 @@ impl InitArgs { } } -/// Returns the commit hash of the project if it exists -pub fn get_commit_hash(root: &Path) -> Option { - Git::new(root).commit_hash(true, "HEAD").ok() -} - /// Initialises `root` as a git repository, if it isn't one already. /// /// Creates `.gitignore` and `.github/workflows/test.yml`, if they don't exist already. diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index 1e1a91cbf9c43..b01366aa7ce81 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -56,7 +56,6 @@ pub mod inspect; pub mod install; pub mod remappings; pub mod remove; -pub mod script; pub mod selectors; pub mod snapshot; pub mod test; diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs deleted file mode 100644 index a7ab056332ad8..0000000000000 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ /dev/null @@ -1,701 +0,0 @@ -use super::{ - multi::MultiChainSequence, providers::ProvidersManager, receipts::clear_pendings, - sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, - NestedValue, ScriptArgs, ScriptConfig, ScriptResult, -}; -use alloy_primitives::{utils::format_units, Address, TxHash, U256}; -use ethers_core::types::transaction::eip2718::TypedTransaction; -use ethers_providers::{JsonRpcClient, Middleware, Provider}; -use ethers_signers::Signer; -use eyre::{bail, Context, ContextCompat, Result}; -use forge::{inspectors::cheatcodes::BroadcastableTransactions, traces::CallTraceDecoder}; -use foundry_cli::{ - init_progress, update_progress, - utils::{has_batch_support, has_different_gas_calc}, -}; -use foundry_common::{ - provider::{ - alloy::RpcUrl, - ethers::{estimate_eip1559_fees, try_get_http_provider, RetryProvider}, - }, - shell, - types::{ToAlloy, ToEthers}, - ContractsByArtifact, -}; -use foundry_compilers::{artifacts::Libraries, ArtifactId}; -use foundry_config::Config; -use foundry_wallets::WalletSigner; -use futures::StreamExt; -use std::{ - cmp::min, - collections::{HashMap, HashSet, VecDeque}, - sync::Arc, -}; - -impl ScriptArgs { - /// Sends the transactions which haven't been broadcasted yet. - pub async fn send_transactions( - &self, - deployment_sequence: &mut ScriptSequence, - fork_url: &str, - signers: &HashMap, - ) -> Result<()> { - let provider = Arc::new(try_get_http_provider(fork_url)?); - let already_broadcasted = deployment_sequence.receipts.len(); - - if already_broadcasted < deployment_sequence.transactions.len() { - let required_addresses: HashSet
= deployment_sequence - .typed_transactions() - .skip(already_broadcasted) - .map(|tx| (*tx.from().expect("No sender for onchain transaction!")).to_alloy()) - .collect(); - - let (send_kind, chain) = if self.unlocked { - let chain = provider.get_chainid().await?; - let mut senders = HashSet::from([self - .evm_opts - .sender - .wrap_err("--sender must be set with --unlocked")?]); - // also take all additional senders that where set manually via broadcast - senders.extend( - deployment_sequence - .typed_transactions() - .filter_map(|tx| tx.from().copied().map(|addr| addr.to_alloy())), - ); - (SendTransactionsKind::Unlocked(senders), chain.as_u64()) - } else { - let mut missing_addresses = Vec::new(); - - println!("\n###\nFinding wallets for all the necessary addresses..."); - for addr in &required_addresses { - if !signers.contains_key(addr) { - missing_addresses.push(addr); - } - } - - if !missing_addresses.is_empty() { - let mut error_msg = String::new(); - - // This is an actual used address - if required_addresses.contains(&Config::DEFAULT_SENDER) { - error_msg += "\nYou seem to be using Foundry's default sender. Be sure to set your own --sender.\n"; - } - - eyre::bail!( - "{}No associated wallet for addresses: {:?}. Unlocked wallets: {:?}", - error_msg, - missing_addresses, - signers.keys().collect::>() - ); - } - - let chain = provider.get_chainid().await?.as_u64(); - - (SendTransactionsKind::Raw(signers), chain) - }; - - // We only wait for a transaction receipt before sending the next transaction, if there - // is more than one signer. There would be no way of assuring their order - // otherwise. Or if the chain does not support batched transactions (eg. Arbitrum). - let sequential_broadcast = - send_kind.signers_count() != 1 || self.slow || !has_batch_support(chain); - - // Make a one-time gas price estimation - let (gas_price, eip1559_fees) = { - match deployment_sequence.transactions.front().unwrap().typed_tx() { - TypedTransaction::Eip1559(_) => { - let fees = estimate_eip1559_fees(&provider, Some(chain)) - .await - .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; - - (None, Some(fees)) - } - _ => (provider.get_gas_price().await.ok(), None), - } - }; - - // Iterate through transactions, matching the `from` field with the associated - // wallet. Then send the transaction. Panics if we find a unknown `from` - let sequence = deployment_sequence - .transactions - .iter() - .skip(already_broadcasted) - .map(|tx_with_metadata| { - let tx = tx_with_metadata.typed_tx(); - let from = (*tx.from().expect("No sender for onchain transaction!")).to_alloy(); - - let kind = send_kind.for_sender(&from)?; - let is_fixed_gas_limit = tx_with_metadata.is_fixed_gas_limit; - - let mut tx = tx.clone(); - - tx.set_chain_id(chain); - - if let Some(gas_price) = self.with_gas_price { - tx.set_gas_price(gas_price.to_ethers()); - } else { - // fill gas price - match tx { - TypedTransaction::Eip1559(ref mut inner) => { - let eip1559_fees = - eip1559_fees.expect("Could not get eip1559 fee estimation."); - if let Some(priority_gas_price) = self.priority_gas_price { - inner.max_priority_fee_per_gas = - Some(priority_gas_price.to_ethers()); - } else { - inner.max_priority_fee_per_gas = Some(eip1559_fees.1); - } - inner.max_fee_per_gas = Some(eip1559_fees.0); - } - _ => { - tx.set_gas_price(gas_price.expect("Could not get gas_price.")); - } - } - } - - Ok((tx, kind, is_fixed_gas_limit)) - }) - .collect::>>()?; - - let pb = init_progress!(deployment_sequence.transactions, "txes"); - - // We send transactions and wait for receipts in batches of 100, since some networks - // cannot handle more than that. - let batch_size = 100; - let mut index = 0; - - for (batch_number, batch) in sequence.chunks(batch_size).map(|f| f.to_vec()).enumerate() - { - let mut pending_transactions = vec![]; - - shell::println(format!( - "##\nSending transactions [{} - {}].", - batch_number * batch_size, - batch_number * batch_size + min(batch_size, batch.len()) - 1 - ))?; - for (tx, kind, is_fixed_gas_limit) in batch.into_iter() { - let tx_hash = self.send_transaction( - provider.clone(), - tx, - kind, - sequential_broadcast, - fork_url, - is_fixed_gas_limit, - ); - - if sequential_broadcast { - let tx_hash = tx_hash.await?; - deployment_sequence.add_pending(index, tx_hash); - - update_progress!(pb, (index + already_broadcasted)); - index += 1; - - clear_pendings(provider.clone(), deployment_sequence, Some(vec![tx_hash])) - .await?; - } else { - pending_transactions.push(tx_hash); - } - } - - if !pending_transactions.is_empty() { - let mut buffer = futures::stream::iter(pending_transactions).buffered(7); - - while let Some(tx_hash) = buffer.next().await { - let tx_hash = tx_hash?; - deployment_sequence.add_pending(index, tx_hash); - - update_progress!(pb, (index + already_broadcasted)); - index += 1; - } - - // Checkpoint save - deployment_sequence.save()?; - - if !sequential_broadcast { - shell::println("##\nWaiting for receipts.")?; - clear_pendings(provider.clone(), deployment_sequence, None).await?; - } - } - - // Checkpoint save - deployment_sequence.save()?; - } - } - - shell::println("\n\n==========================")?; - shell::println("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; - - let (total_gas, total_gas_price, total_paid) = deployment_sequence.receipts.iter().fold( - (U256::ZERO, U256::ZERO, U256::ZERO), - |acc, receipt| { - let gas_used = receipt.gas_used.unwrap_or_default().to_alloy(); - let gas_price = receipt.effective_gas_price.unwrap_or_default().to_alloy(); - (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used * gas_price) - }, - ); - let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); - let avg_gas_price = - format_units(total_gas_price / U256::from(deployment_sequence.receipts.len()), 9) - .unwrap_or_else(|_| "N/A".to_string()); - shell::println(format!( - "Total Paid: {} ETH ({} gas * avg {} gwei)", - paid.trim_end_matches('0'), - total_gas, - avg_gas_price.trim_end_matches('0').trim_end_matches('.') - ))?; - - Ok(()) - } - - async fn send_transaction( - &self, - provider: Arc, - mut tx: TypedTransaction, - kind: SendTransactionKind<'_>, - sequential_broadcast: bool, - fork_url: &str, - is_fixed_gas_limit: bool, - ) -> Result { - let from = tx.from().expect("no sender"); - - if sequential_broadcast { - let nonce = forge::next_nonce((*from).to_alloy(), fork_url, None) - .await - .map_err(|_| eyre::eyre!("Not able to query the EOA nonce."))?; - - let tx_nonce = tx.nonce().expect("no nonce"); - if let Ok(tx_nonce) = u64::try_from(tx_nonce.to_alloy()) { - if nonce != tx_nonce { - bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") - } - } - } - - match kind { - SendTransactionKind::Unlocked(addr) => { - debug!("sending transaction from unlocked account {:?}: {:?}", addr, tx); - - // Chains which use `eth_estimateGas` are being sent sequentially and require their - // gas to be re-estimated right before broadcasting. - if !is_fixed_gas_limit && - (has_different_gas_calc(provider.get_chainid().await?.as_u64()) || - self.skip_simulation) - { - self.estimate_gas(&mut tx, &provider).await?; - } - - // Submit the transaction - let pending = provider.send_transaction(tx, None).await?; - - Ok(pending.tx_hash().to_alloy()) - } - SendTransactionKind::Raw(signer) => self.broadcast(provider, signer, tx).await, - } - } - - /// Executes the created transactions, and if no error has occurred, broadcasts - /// them. - pub async fn handle_broadcastable_transactions( - &self, - mut result: ScriptResult, - libraries: Libraries, - decoder: &CallTraceDecoder, - mut script_config: ScriptConfig, - verify: VerifyBundle, - signers: &HashMap, - ) -> Result<()> { - if let Some(txs) = result.transactions.take() { - script_config.collect_rpcs(&txs); - script_config.check_multi_chain_constraints(&libraries)?; - script_config.check_shanghai_support().await?; - - if !script_config.missing_rpc { - trace!(target: "script", "creating deployments"); - - let mut deployments = self - .create_script_sequences( - txs, - &result, - &mut script_config, - decoder, - &verify.known_contracts, - ) - .await?; - - if script_config.has_multiple_rpcs() { - trace!(target: "script", "broadcasting multi chain deployment"); - - let multi = MultiChainSequence::new( - deployments.clone(), - &self.sig, - script_config.target_contract(), - &script_config.config, - self.broadcast, - )?; - - if self.broadcast { - self.multi_chain_deployment( - multi, - libraries, - &script_config.config, - verify, - signers, - ) - .await?; - } - } else if self.broadcast { - self.single_deployment( - deployments.first_mut().expect("missing deployment"), - script_config, - libraries, - verify, - signers, - ) - .await?; - } - - if !self.broadcast { - shell::println("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; - } - } else { - shell::println("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; - } - } - Ok(()) - } - - /// Broadcasts a single chain script. - async fn single_deployment( - &self, - deployment_sequence: &mut ScriptSequence, - script_config: ScriptConfig, - libraries: Libraries, - verify: VerifyBundle, - signers: &HashMap, - ) -> Result<()> { - trace!(target: "script", "broadcasting single chain deployment"); - - if self.verify { - deployment_sequence.verify_preflight_check(&script_config.config, &verify)?; - } - - let rpc = script_config.total_rpcs.into_iter().next().expect("exists; qed"); - - deployment_sequence.add_libraries(libraries); - - self.send_transactions(deployment_sequence, &rpc, signers).await?; - - if self.verify { - return deployment_sequence.verify_contracts(&script_config.config, verify).await; - } - Ok(()) - } - - /// Given the collected transactions it creates a list of [`ScriptSequence`]. List length will - /// be higher than 1, if we're dealing with a multi chain deployment. - /// - /// If `--skip-simulation` is not passed, it will make an onchain simulation of the transactions - /// before adding them to [`ScriptSequence`]. - async fn create_script_sequences( - &self, - txs: BroadcastableTransactions, - script_result: &ScriptResult, - script_config: &mut ScriptConfig, - decoder: &CallTraceDecoder, - known_contracts: &ContractsByArtifact, - ) -> Result> { - if !txs.is_empty() { - let gas_filled_txs = self - .fills_transactions_with_gas(txs, script_config, decoder, known_contracts) - .await?; - - let returns = self.get_returns(&*script_config, &script_result.returned)?; - - return self - .bundle_transactions( - gas_filled_txs, - &script_config.target_contract().clone(), - &mut script_config.config, - returns, - ) - .await; - } else if self.broadcast { - eyre::bail!("No onchain transactions generated in script"); - } - - Ok(vec![]) - } - - /// Takes the collected transactions and executes them locally before converting them to - /// [`TransactionWithMetadata`] with the appropriate gas execution estimation. If - /// `--skip-simulation` is passed, then it will skip the execution. - async fn fills_transactions_with_gas( - &self, - txs: BroadcastableTransactions, - script_config: &ScriptConfig, - decoder: &CallTraceDecoder, - known_contracts: &ContractsByArtifact, - ) -> Result> { - let gas_filled_txs = if self.skip_simulation { - shell::println("\nSKIPPING ON CHAIN SIMULATION.")?; - txs.into_iter() - .map(|btx| { - let mut tx = TransactionWithMetadata::from_tx_request(btx.transaction); - tx.rpc = btx.rpc; - tx - }) - .collect() - } else { - self.onchain_simulation( - txs, - script_config, - decoder, - known_contracts, - ) - .await - .wrap_err("\nTransaction failed when running the on-chain simulation. Check the trace above for more information.")? - }; - Ok(gas_filled_txs) - } - - /// Returns all transactions of the [`TransactionWithMetadata`] type in a list of - /// [`ScriptSequence`]. List length will be higher than 1, if we're dealing with a multi - /// chain deployment. - /// - /// Each transaction will be added with the correct transaction type and gas estimation. - async fn bundle_transactions( - &self, - transactions: VecDeque, - target: &ArtifactId, - config: &mut Config, - returns: HashMap, - ) -> Result> { - // User might be using both "in-code" forks and `--fork-url`. - let last_rpc = &transactions.back().expect("exists; qed").rpc; - let is_multi_deployment = transactions.iter().any(|tx| &tx.rpc != last_rpc); - - let mut total_gas_per_rpc: HashMap = HashMap::new(); - - // Batches sequence of transactions from different rpcs. - let mut new_sequence = VecDeque::new(); - let mut manager = ProvidersManager::default(); - let mut deployments = vec![]; - - // Config is used to initialize the sequence chain, so we need to change when handling a new - // sequence. This makes sure we don't lose the original value. - let original_config_chain = config.chain; - - // Peeking is used to check if the next rpc url is different. If so, it creates a - // [`ScriptSequence`] from all the collected transactions up to this point. - let mut txes_iter = transactions.into_iter().peekable(); - - while let Some(mut tx) = txes_iter.next() { - let tx_rpc = match tx.rpc.clone() { - Some(rpc) => rpc, - None => { - let rpc = self.evm_opts.ensure_fork_url()?.clone(); - // Fills the RPC inside the transaction, if missing one. - tx.rpc = Some(rpc.clone()); - rpc - } - }; - - let provider_info = manager.get_or_init_provider(&tx_rpc, self.legacy).await?; - - // Handles chain specific requirements. - tx.change_type(provider_info.is_legacy); - tx.transaction.set_chain_id(provider_info.chain); - - if !self.skip_simulation { - let typed_tx = tx.typed_tx_mut(); - - if has_different_gas_calc(provider_info.chain) { - trace!("estimating with different gas calculation"); - let gas = *typed_tx.gas().expect("gas is set by simulation."); - - // We are trying to show the user an estimation of the total gas usage. - // - // However, some transactions might depend on previous ones. For - // example, tx1 might deploy a contract that tx2 uses. That - // will result in the following `estimate_gas` call to fail, - // since tx1 hasn't been broadcasted yet. - // - // Not exiting here will not be a problem when actually broadcasting, because - // for chains where `has_different_gas_calc` returns true, - // we await each transaction before broadcasting the next - // one. - if let Err(err) = self.estimate_gas(typed_tx, &provider_info.provider).await { - trace!("gas estimation failed: {err}"); - - // Restore gas value, since `estimate_gas` will remove it. - typed_tx.set_gas(gas); - } - } - - let total_gas = total_gas_per_rpc.entry(tx_rpc.clone()).or_insert(U256::ZERO); - *total_gas += (*typed_tx.gas().expect("gas is set")).to_alloy(); - } - - new_sequence.push_back(tx); - // We only create a [`ScriptSequence`] object when we collect all the rpc related - // transactions. - if let Some(next_tx) = txes_iter.peek() { - if next_tx.rpc == Some(tx_rpc) { - continue; - } - } - - config.chain = Some(provider_info.chain.into()); - let sequence = ScriptSequence::new( - new_sequence, - returns.clone(), - &self.sig, - target, - config, - self.broadcast, - is_multi_deployment, - )?; - - deployments.push(sequence); - - new_sequence = VecDeque::new(); - } - - // Restore previous config chain. - config.chain = original_config_chain; - - if !self.skip_simulation { - // Present gas information on a per RPC basis. - for (rpc, total_gas) in total_gas_per_rpc { - let provider_info = manager.get(&rpc).expect("provider is set."); - - // We don't store it in the transactions, since we want the most updated value. - // Right before broadcasting. - let per_gas = if let Some(gas_price) = self.with_gas_price { - gas_price - } else { - provider_info.gas_price()? - }; - - shell::println("\n==========================")?; - shell::println(format!("\nChain {}", provider_info.chain))?; - - shell::println(format!( - "\nEstimated gas price: {} gwei", - format_units(per_gas, 9) - .unwrap_or_else(|_| "[Could not calculate]".to_string()) - .trim_end_matches('0') - .trim_end_matches('.') - ))?; - shell::println(format!("\nEstimated total gas used for script: {total_gas}"))?; - shell::println(format!( - "\nEstimated amount required: {} ETH", - format_units(total_gas.saturating_mul(per_gas), 18) - .unwrap_or_else(|_| "[Could not calculate]".to_string()) - .trim_end_matches('0') - ))?; - shell::println("\n==========================")?; - } - } - Ok(deployments) - } - - /// Uses the signer to submit a transaction to the network. If it fails, it tries to retrieve - /// the transaction hash that can be used on a later run with `--resume`. - async fn broadcast( - &self, - provider: Arc, - signer: &WalletSigner, - mut legacy_or_1559: TypedTransaction, - ) -> Result { - debug!("sending transaction: {:?}", legacy_or_1559); - - // Chains which use `eth_estimateGas` are being sent sequentially and require their gas - // to be re-estimated right before broadcasting. - if has_different_gas_calc(signer.chain_id()) || self.skip_simulation { - // if already set, some RPC endpoints might simply return the gas value that is - // already set in the request and omit the estimate altogether, so - // we remove it here - let _ = legacy_or_1559.gas_mut().take(); - - self.estimate_gas(&mut legacy_or_1559, &provider).await?; - } - - // Signing manually so we skip `fill_transaction` and its `eth_createAccessList` - // request. - let signature = signer - .sign_transaction(&legacy_or_1559) - .await - .wrap_err("Failed to sign transaction")?; - - // Submit the raw transaction - let pending = provider.send_raw_transaction(legacy_or_1559.rlp_signed(&signature)).await?; - - Ok(pending.tx_hash().to_alloy()) - } - - async fn estimate_gas(&self, tx: &mut TypedTransaction, provider: &Provider) -> Result<()> - where - T: JsonRpcClient, - { - // if already set, some RPC endpoints might simply return the gas value that is already - // set in the request and omit the estimate altogether, so we remove it here - let _ = tx.gas_mut().take(); - - tx.set_gas( - provider - .estimate_gas(tx, None) - .await - .wrap_err_with(|| format!("Failed to estimate gas for tx: {:?}", tx.sighash()))? * - self.gas_estimate_multiplier / - 100, - ); - Ok(()) - } -} - -/// How to send a single transaction -#[derive(Clone)] -enum SendTransactionKind<'a> { - Unlocked(Address), - Raw(&'a WalletSigner), -} - -/// Represents how to send _all_ transactions -enum SendTransactionsKind<'a> { - /// Send via `eth_sendTransaction` and rely on the `from` address being unlocked. - Unlocked(HashSet
), - /// Send a signed transaction via `eth_sendRawTransaction` - Raw(&'a HashMap), -} - -impl SendTransactionsKind<'_> { - /// Returns the [`SendTransactionKind`] for the given address - /// - /// Returns an error if no matching signer is found or the address is not unlocked - fn for_sender(&self, addr: &Address) -> Result> { - match self { - SendTransactionsKind::Unlocked(unlocked) => { - if !unlocked.contains(addr) { - bail!("Sender address {:?} is not unlocked", addr) - } - Ok(SendTransactionKind::Unlocked(*addr)) - } - SendTransactionsKind::Raw(wallets) => { - if let Some(wallet) = wallets.get(addr) { - Ok(SendTransactionKind::Raw(wallet)) - } else { - bail!("No matching signer for {:?} found", addr) - } - } - } - } - - /// How many signers are set - fn signers_count(&self) -> usize { - match self { - SendTransactionsKind::Unlocked(addr) => addr.len(), - SendTransactionsKind::Raw(signers) => signers.len(), - } - } -} diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs deleted file mode 100644 index a2bdc1490d4b3..0000000000000 --- a/crates/forge/bin/cmd/script/build.rs +++ /dev/null @@ -1,208 +0,0 @@ -use super::{ScriptArgs, ScriptConfig}; -use alloy_primitives::{Address, Bytes}; -use eyre::{Context, ContextCompat, Result}; -use foundry_cli::utils::get_cached_entry_by_name; -use foundry_common::compile::{self, ContractSources, ProjectCompiler}; -use foundry_compilers::{ - artifacts::{ContractBytecode, ContractBytecodeSome, Libraries}, - cache::SolFilesCache, - contracts::ArtifactContracts, - info::ContractInfo, - ArtifactId, Project, ProjectCompileOutput, -}; -use foundry_linking::{LinkOutput, Linker}; -use std::str::FromStr; - -impl ScriptArgs { - /// Compiles the file or project and the verify metadata. - pub fn compile(&mut self, script_config: &mut ScriptConfig) -> Result { - trace!(target: "script", "compiling script"); - - self.build(script_config) - } - - /// Compiles the file with auto-detection and compiler params. - pub fn build(&mut self, script_config: &mut ScriptConfig) -> Result { - let (project, output) = self.get_project_and_output(script_config)?; - let root = project.root(); - let output = output.with_stripped_file_prefixes(root); - let sources = ContractSources::from_project_output(&output, root)?; - let contracts = output.into_artifacts().collect(); - - let target = self.find_target(&project, &contracts)?.clone(); - script_config.target_contract = Some(target.clone()); - - let libraries = script_config.config.libraries_with_remappings()?; - let linker = Linker::new(project.root(), contracts); - - let (highlevel_known_contracts, libraries, predeploy_libraries) = self.link_script_target( - &linker, - libraries, - script_config.evm_opts.sender, - script_config.sender_nonce, - target.clone(), - )?; - - let contract = highlevel_known_contracts.get(&target).unwrap(); - - Ok(BuildOutput { - project, - linker, - contract: contract.clone(), - highlevel_known_contracts, - libraries, - predeploy_libraries, - sources, - }) - } - - /// Tries to find artifact for the target script contract. - pub fn find_target<'a>( - &self, - project: &Project, - contracts: &'a ArtifactContracts, - ) -> Result<&'a ArtifactId> { - let mut target_fname = dunce::canonicalize(&self.path) - .wrap_err("Couldn't convert contract path to absolute path.")? - .strip_prefix(project.root()) - .wrap_err("Couldn't strip project root from contract path.")? - .to_str() - .wrap_err("Bad path to string.")? - .to_string(); - - let no_target_name = if let Some(target_name) = &self.target_contract { - target_fname = target_fname + ":" + target_name; - false - } else { - true - }; - - let mut target: Option<&ArtifactId> = None; - - for (id, contract) in contracts.iter() { - if no_target_name { - // Match artifact source, and ignore interfaces - if id.source == std::path::Path::new(&target_fname) && - contract.bytecode.as_ref().map_or(false, |b| b.object.bytes_len() > 0) - { - if let Some(target) = target { - // We might have multiple artifacts for the same contract but with different - // solc versions. Their names will have form of {name}.0.X.Y, so we are - // stripping versions off before comparing them. - let target_name = target.name.split('.').next().unwrap(); - let id_name = id.name.split('.').next().unwrap(); - if target_name != id_name { - eyre::bail!("Multiple contracts in the target path. Please specify the contract name with `--tc ContractName`") - } - } - target = Some(id); - } - } else { - let (path, name) = - target_fname.rsplit_once(':').expect("The target specifier is malformed."); - let path = std::path::Path::new(path); - if path == id.source && name == id.name { - target = Some(id); - } - } - } - - target.ok_or_else(|| eyre::eyre!("Could not find target contract: {}", target_fname)) - } - - /// Links script artifact with given libraries or library addresses computed from script sender - /// and nonce. - /// - /// Populates [BuildOutput] with linked target contract, libraries, bytes of libs that need to - /// be predeployed and `highlevel_known_contracts` - set of known fully linked contracts - pub fn link_script_target( - &self, - linker: &Linker, - libraries: Libraries, - sender: Address, - nonce: u64, - target: ArtifactId, - ) -> Result<(ArtifactContracts, Libraries, Vec)> { - let LinkOutput { libs_to_deploy, libraries } = - linker.link_with_nonce_or_address(libraries, sender, nonce, &target)?; - - // Collect all linked contracts with non-empty bytecode - let highlevel_known_contracts = linker - .get_linked_artifacts(&libraries)? - .iter() - .filter_map(|(id, contract)| { - ContractBytecodeSome::try_from(ContractBytecode::from(contract.clone())) - .ok() - .map(|tc| (id.clone(), tc)) - }) - .filter(|(_, tc)| tc.bytecode.object.is_non_empty_bytecode()) - .collect(); - - Ok((highlevel_known_contracts, libraries, libs_to_deploy)) - } - - pub fn get_project_and_output( - &mut self, - script_config: &ScriptConfig, - ) -> Result<(Project, ProjectCompileOutput)> { - let project = script_config.config.project()?; - - let filters = self.opts.skip.clone().unwrap_or_default(); - // We received a valid file path. - // If this file does not exist, `dunce::canonicalize` will - // result in an error and it will be handled below. - if let Ok(target_contract) = dunce::canonicalize(&self.path) { - let output = compile::compile_target_with_filter( - &target_contract, - &project, - self.opts.args.silent, - self.verify, - filters, - )?; - return Ok((project, output)) - } - - if !project.paths.has_input_files() { - eyre::bail!("The project doesn't have any input files. Make sure the `script` directory is configured properly in foundry.toml. Otherwise, provide the path to the file.") - } - - let contract = ContractInfo::from_str(&self.path)?; - self.target_contract = Some(contract.name.clone()); - - // We received `contract_path:contract_name` - if let Some(path) = contract.path { - let path = - dunce::canonicalize(path).wrap_err("Could not canonicalize the target path")?; - let output = compile::compile_target_with_filter( - &path, - &project, - self.opts.args.silent, - self.verify, - filters, - )?; - self.path = path.to_string_lossy().to_string(); - return Ok((project, output)) - } - - // We received `contract_name`, and need to find its file path. - let output = ProjectCompiler::new().compile(&project)?; - let cache = - SolFilesCache::read_joined(&project.paths).wrap_err("Could not open compiler cache")?; - - let (path, _) = get_cached_entry_by_name(&cache, &contract.name) - .wrap_err("Could not find target contract in cache")?; - self.path = path.to_string_lossy().to_string(); - - Ok((project, output)) - } -} - -pub struct BuildOutput { - pub project: Project, - pub contract: ContractBytecodeSome, - pub linker: Linker, - pub highlevel_known_contracts: ArtifactContracts, - pub libraries: Libraries, - pub predeploy_libraries: Vec, - pub sources: ContractSources, -} diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs deleted file mode 100644 index f864f29f8bc0d..0000000000000 --- a/crates/forge/bin/cmd/script/cmd.rs +++ /dev/null @@ -1,382 +0,0 @@ -use super::{ - multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, ScriptArgs, - ScriptConfig, ScriptResult, -}; -use crate::cmd::script::{build::BuildOutput, receipts}; -use alloy_primitives::{Address, Bytes}; -use ethers_providers::Middleware; -use ethers_signers::Signer; -use eyre::{OptionExt, Result}; -use forge::traces::CallTraceDecoder; -use foundry_cli::utils::LoadConfig; -use foundry_common::{ - contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy, -}; -use foundry_compilers::{ - artifacts::{ContractBytecodeSome, Libraries}, - contracts::ArtifactContracts, -}; -use foundry_debugger::Debugger; -use foundry_evm::inspectors::cheatcodes::{BroadcastableTransaction, ScriptWallets}; -use foundry_linking::Linker; -use foundry_wallets::WalletSigner; -use std::{collections::HashMap, sync::Arc}; - -/// Helper alias type for the collection of data changed due to the new sender. -type NewSenderChanges = (CallTraceDecoder, Libraries, ArtifactContracts); - -impl ScriptArgs { - /// Executes the script - pub async fn run_script(mut self) -> Result<()> { - trace!(target: "script", "executing script command"); - - let (config, evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; - let mut script_config = ScriptConfig { - // dapptools compatibility - sender_nonce: 1, - config, - evm_opts, - debug: self.debug, - ..Default::default() - }; - - if let Some(sender) = self.maybe_load_private_key()? { - script_config.evm_opts.sender = sender; - } - - if let Some(ref fork_url) = script_config.evm_opts.fork_url { - // when forking, override the sender's nonce to the onchain value - script_config.sender_nonce = - forge::next_nonce(script_config.evm_opts.sender, fork_url, None).await? - } else { - // if not forking, then ignore any pre-deployed library addresses - script_config.config.libraries = Default::default(); - } - - let build_output = self.compile(&mut script_config)?; - - let mut verify = VerifyBundle::new( - &build_output.project, - &script_config.config, - flatten_contracts(&build_output.highlevel_known_contracts, false), - self.retry, - self.verifier.clone(), - ); - - let BuildOutput { - contract, - mut highlevel_known_contracts, - predeploy_libraries, - linker, - sources, - mut libraries, - .. - } = build_output; - - // Execute once with default sender. - let sender = script_config.evm_opts.sender; - - let multi_wallet = self.wallets.get_multi_wallet().await?; - let script_wallets = ScriptWallets::new(multi_wallet, self.evm_opts.sender); - - // We need to execute the script even if just resuming, in case we need to collect private - // keys from the execution. - let mut result = self - .execute( - &mut script_config, - contract, - sender, - &predeploy_libraries, - script_wallets.clone(), - ) - .await?; - - if self.resume || (self.verify && !self.broadcast) { - let signers = script_wallets.into_multi_wallet().into_signers()?; - return self.resume_deployment(script_config, linker, libraries, verify, &signers).await; - } - - let known_contracts = flatten_contracts(&highlevel_known_contracts, true); - let mut decoder = self.decode_traces(&script_config, &mut result, &known_contracts)?; - - if self.debug { - let mut debugger = Debugger::builder() - .debug_arenas(result.debug.as_deref().unwrap_or_default()) - .decoder(&decoder) - .sources(sources) - .breakpoints(result.breakpoints.clone()) - .build(); - debugger.try_run()?; - } - - if let Some((new_traces, updated_libraries, updated_contracts)) = self - .maybe_prepare_libraries( - &mut script_config, - linker, - predeploy_libraries, - &mut result, - script_wallets.clone(), - ) - .await? - { - decoder = new_traces; - highlevel_known_contracts = updated_contracts; - libraries = updated_libraries; - } - - if self.json { - self.show_json(&script_config, &result)?; - } else { - self.show_traces(&script_config, &decoder, &mut result).await?; - } - - verify.known_contracts = flatten_contracts(&highlevel_known_contracts, false); - self.check_contract_sizes(&result, &highlevel_known_contracts)?; - - let signers = script_wallets.into_multi_wallet().into_signers()?; - - self.handle_broadcastable_transactions( - result, - libraries, - &decoder, - script_config, - verify, - &signers, - ) - .await - } - - // In case there are libraries to be deployed, it makes sure that these are added to the list of - // broadcastable transactions with the appropriate sender. - async fn maybe_prepare_libraries( - &mut self, - script_config: &mut ScriptConfig, - linker: Linker, - predeploy_libraries: Vec, - result: &mut ScriptResult, - script_wallets: ScriptWallets, - ) -> Result> { - if let Some(new_sender) = self.maybe_new_sender( - &script_config.evm_opts, - result.transactions.as_ref(), - &predeploy_libraries, - )? { - // We have a new sender, so we need to relink all the predeployed libraries. - let (libraries, highlevel_known_contracts) = self - .rerun_with_new_deployer(script_config, new_sender, result, linker, script_wallets) - .await?; - - // redo traces for the new addresses - let new_traces = self.decode_traces( - &*script_config, - result, - &flatten_contracts(&highlevel_known_contracts, true), - )?; - - return Ok(Some((new_traces, libraries, highlevel_known_contracts))); - } - - // Add predeploy libraries to the list of broadcastable transactions. - let mut lib_deploy = self.create_deploy_transactions( - script_config.evm_opts.sender, - script_config.sender_nonce, - &predeploy_libraries, - &script_config.evm_opts.fork_url, - ); - - if let Some(txs) = &mut result.transactions { - for tx in txs.iter() { - lib_deploy.push_back(BroadcastableTransaction { - rpc: tx.rpc.clone(), - transaction: tx.transaction.clone(), - }); - } - *txs = lib_deploy; - } - - Ok(None) - } - - /// Resumes the deployment and/or verification of the script. - async fn resume_deployment( - &mut self, - script_config: ScriptConfig, - linker: Linker, - libraries: Libraries, - verify: VerifyBundle, - signers: &HashMap, - ) -> Result<()> { - if self.multi { - return self - .multi_chain_deployment( - MultiChainSequence::load( - &script_config.config, - &self.sig, - script_config.target_contract(), - )?, - libraries, - &script_config.config, - verify, - signers, - ) - .await; - } - self.resume_single_deployment( - script_config, - linker, - verify, - signers, - ) - .await - .map_err(|err| { - eyre::eyre!("{err}\n\nIf you were trying to resume or verify a multi chain deployment, add `--multi` to your command invocation.") - }) - } - - /// Resumes the deployment and/or verification of a single RPC script. - async fn resume_single_deployment( - &mut self, - script_config: ScriptConfig, - linker: Linker, - mut verify: VerifyBundle, - signers: &HashMap, - ) -> Result<()> { - trace!(target: "script", "resuming single deployment"); - - let fork_url = script_config - .evm_opts - .fork_url - .as_deref() - .ok_or_else(|| eyre::eyre!("Missing `--fork-url` field."))?; - let provider = Arc::new(try_get_http_provider(fork_url)?); - - let chain = provider.get_chainid().await?.as_u64(); - verify.set_chain(&script_config.config, chain.into()); - - let broadcasted = self.broadcast || self.resume; - let mut deployment_sequence = match ScriptSequence::load( - &script_config.config, - &self.sig, - script_config.target_contract(), - chain, - broadcasted, - ) { - Ok(seq) => seq, - // If the script was simulated, but there was no attempt to broadcast yet, - // try to read the script sequence from the `dry-run/` folder - Err(_) if broadcasted => ScriptSequence::load( - &script_config.config, - &self.sig, - script_config.target_contract(), - chain, - false, - )?, - Err(err) => eyre::bail!(err), - }; - - if self.verify { - deployment_sequence.verify_preflight_check(&script_config.config, &verify)?; - } - - receipts::wait_for_pending(provider, &mut deployment_sequence).await?; - - if self.resume { - self.send_transactions(&mut deployment_sequence, fork_url, signers).await?; - } - - if self.verify { - let target = script_config.target_contract(); - let libraries = Libraries::parse(&deployment_sequence.libraries)? - .with_stripped_file_prefixes(linker.root.as_path()); - // We might have predeployed libraries from the broadcasting, so we need to - // relink the contracts with them, since their mapping is - // not included in the solc cache files. - let (highlevel_known_contracts, _, predeploy_libraries) = self.link_script_target( - &linker, - libraries, - script_config.config.sender, // irrelevant, since we're not creating any - 0, // irrelevant, since we're not creating any - target.clone(), - )?; - - if !predeploy_libraries.is_empty() { - eyre::bail!("Incomplete set of libraries in deployment artifact."); - } - - verify.known_contracts = flatten_contracts(&highlevel_known_contracts, false); - - deployment_sequence.verify_contracts(&script_config.config, verify).await?; - } - - Ok(()) - } - - /// Reruns the execution with a new sender and relinks the libraries accordingly - async fn rerun_with_new_deployer( - &mut self, - script_config: &mut ScriptConfig, - new_sender: Address, - first_run_result: &mut ScriptResult, - linker: Linker, - script_wallets: ScriptWallets, - ) -> Result<(Libraries, ArtifactContracts)> { - // if we had a new sender that requires relinking, we need to - // get the nonce mainnet for accurate addresses for predeploy libs - let nonce = forge::next_nonce( - new_sender, - script_config.evm_opts.fork_url.as_ref().ok_or_else(|| { - eyre::eyre!("You must provide an RPC URL (see --fork-url) when broadcasting.") - })?, - None, - ) - .await?; - script_config.sender_nonce = nonce; - let target = script_config.target_contract(); - - let libraries = script_config.config.libraries_with_remappings()?; - - let (highlevel_known_contracts, libraries, predeploy_libraries) = - self.link_script_target(&linker, libraries, new_sender, nonce, target.clone())?; - - let contract = highlevel_known_contracts - .get(target) - .ok_or_eyre("target not found in linked artifacts")? - .clone(); - - let mut txs = self.create_deploy_transactions( - new_sender, - nonce, - &predeploy_libraries, - &script_config.evm_opts.fork_url, - ); - - let result = self - .execute(script_config, contract, new_sender, &predeploy_libraries, script_wallets) - .await?; - - if let Some(new_txs) = &result.transactions { - for new_tx in new_txs.iter() { - txs.push_back(BroadcastableTransaction { - rpc: new_tx.rpc.clone(), - transaction: new_tx.transaction.clone(), - }); - } - } - - *first_run_result = result; - first_run_result.transactions = Some(txs); - - Ok((libraries, highlevel_known_contracts)) - } - - /// In case the user has loaded *only* one private-key, we can assume that he's using it as the - /// `--sender` - fn maybe_load_private_key(&mut self) -> Result> { - let maybe_sender = self - .wallets - .private_keys()? - .filter(|pks| pks.len() == 1) - .map(|pks| pks.first().unwrap().address().to_alloy()); - Ok(maybe_sender) - } -} diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs deleted file mode 100644 index a78f5b9f451a0..0000000000000 --- a/crates/forge/bin/cmd/script/executor.rs +++ /dev/null @@ -1,325 +0,0 @@ -use super::{ - artifacts::ArtifactInfo, - runner::{ScriptRunner, SimulationStage}, - transaction::{AdditionalContract, TransactionWithMetadata}, - ScriptArgs, ScriptConfig, ScriptResult, -}; -use alloy_primitives::{Address, Bytes, U256}; -use eyre::{Context, Result}; -use forge::{ - backend::Backend, - executors::ExecutorBuilder, - inspectors::{cheatcodes::BroadcastableTransactions, CheatsConfig}, - traces::{render_trace_arena, CallTraceDecoder}, -}; -use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; -use foundry_common::{get_contract_name, provider::ethers::RpcUrl, shell, ContractsByArtifact}; -use foundry_compilers::artifacts::ContractBytecodeSome; -use foundry_evm::inspectors::cheatcodes::ScriptWallets; -use futures::future::join_all; -use parking_lot::RwLock; -use std::{ - collections::{BTreeMap, HashMap, VecDeque}, - sync::Arc, -}; - -impl ScriptArgs { - /// Locally deploys and executes the contract method that will collect all broadcastable - /// transactions. - pub async fn execute( - &self, - script_config: &mut ScriptConfig, - contract: ContractBytecodeSome, - sender: Address, - predeploy_libraries: &[Bytes], - script_wallets: ScriptWallets, - ) -> Result { - trace!(target: "script", "start executing script"); - - let ContractBytecodeSome { abi, bytecode, .. } = contract; - - let bytecode = bytecode.into_bytes().ok_or_else(|| { - eyre::eyre!("expected fully linked bytecode, found unlinked bytecode") - })?; - - ensure_clean_constructor(&abi)?; - - let mut runner = self - .prepare_runner(script_config, sender, SimulationStage::Local, Some(script_wallets)) - .await?; - let (address, mut result) = runner.setup( - predeploy_libraries, - bytecode, - needs_setup(&abi), - script_config.sender_nonce, - self.broadcast, - script_config.evm_opts.fork_url.is_none(), - )?; - - let (func, calldata) = self.get_method_and_calldata(&abi)?; - script_config.called_function = Some(func); - - // Only call the method if `setUp()` succeeded. - if result.success { - let script_result = runner.script(address, calldata)?; - - result.success &= script_result.success; - result.gas_used = script_result.gas_used; - result.logs.extend(script_result.logs); - result.traces.extend(script_result.traces); - result.debug = script_result.debug; - result.labeled_addresses.extend(script_result.labeled_addresses); - result.returned = script_result.returned; - result.breakpoints = script_result.breakpoints; - - match (&mut result.transactions, script_result.transactions) { - (Some(txs), Some(new_txs)) => { - txs.extend(new_txs); - } - (None, Some(new_txs)) => { - result.transactions = Some(new_txs); - } - _ => {} - } - } - - Ok(result) - } - - /// Simulates onchain state by executing a list of transactions locally and persisting their - /// state. Returns the transactions and any CREATE2 contract address created. - pub async fn onchain_simulation( - &self, - transactions: BroadcastableTransactions, - script_config: &ScriptConfig, - decoder: &CallTraceDecoder, - contracts: &ContractsByArtifact, - ) -> Result> { - trace!(target: "script", "executing onchain simulation"); - - let runners = Arc::new( - self.build_runners(script_config) - .await? - .into_iter() - .map(|(rpc, runner)| (rpc, Arc::new(RwLock::new(runner)))) - .collect::>(), - ); - - if script_config.evm_opts.verbosity > 3 { - println!("=========================="); - println!("Simulated On-chain Traces:\n"); - } - - let address_to_abi: BTreeMap = decoder - .contracts - .iter() - .filter_map(|(addr, contract_id)| { - let contract_name = get_contract_name(contract_id); - if let Ok(Some((_, (abi, code)))) = - contracts.find_by_name_or_identifier(contract_name) - { - let info = ArtifactInfo { - contract_name: contract_name.to_string(), - contract_id: contract_id.to_string(), - abi, - code, - }; - return Some((*addr, info)); - } - None - }) - .collect(); - - let mut final_txs = VecDeque::new(); - - // Executes all transactions from the different forks concurrently. - let futs = transactions - .into_iter() - .map(|transaction| async { - let rpc = transaction.rpc.as_ref().expect("missing broadcastable tx rpc url"); - let mut runner = runners.get(rpc).expect("invalid rpc url").write(); - - let mut tx = transaction.transaction; - let result = runner - .simulate( - tx.from - .expect("transaction doesn't have a `from` address at execution time"), - tx.to, - tx.input.clone().into_input(), - tx.value, - ) - .wrap_err("Internal EVM error during simulation")?; - - if !result.success || result.traces.is_empty() { - return Ok((None, result.traces)); - } - - let created_contracts = result - .traces - .iter() - .flat_map(|(_, traces)| { - traces.nodes().iter().filter_map(|node| { - if node.trace.kind.is_any_create() { - return Some(AdditionalContract { - opcode: node.trace.kind, - address: node.trace.address, - init_code: node.trace.data.clone(), - }); - } - None - }) - }) - .collect(); - - // Simulate mining the transaction if the user passes `--slow`. - if self.slow { - runner.executor.env.block.number += U256::from(1); - } - - let is_fixed_gas_limit = tx.gas.is_some(); - match tx.gas { - // If tx.gas is already set that means it was specified in script - Some(gas) => { - println!("Gas limit was set in script to {gas}"); - } - // We inflate the gas used by the user specified percentage - None => { - let gas = U256::from(result.gas_used * self.gas_estimate_multiplier / 100); - tx.gas = Some(gas); - } - } - - let tx = TransactionWithMetadata::new( - tx, - transaction.rpc, - &result, - &address_to_abi, - decoder, - created_contracts, - is_fixed_gas_limit, - )?; - - eyre::Ok((Some(tx), result.traces)) - }) - .collect::>(); - - let mut abort = false; - for res in join_all(futs).await { - let (tx, traces) = res?; - - // Transaction will be `None`, if execution didn't pass. - if tx.is_none() || script_config.evm_opts.verbosity > 3 { - // Identify all contracts created during the call. - if traces.is_empty() { - eyre::bail!( - "forge script requires tracing enabled to collect created contracts" - ); - } - - for (_, trace) in &traces { - println!("{}", render_trace_arena(trace, decoder).await?); - } - } - - if let Some(tx) = tx { - final_txs.push_back(tx); - } else { - abort = true; - } - } - - if abort { - eyre::bail!("Simulated execution failed.") - } - - Ok(final_txs) - } - - /// Build the multiple runners from different forks. - async fn build_runners( - &self, - script_config: &ScriptConfig, - ) -> Result> { - let sender = script_config.evm_opts.sender; - - if !shell::verbosity().is_silent() { - let n = script_config.total_rpcs.len(); - let s = if n != 1 { "s" } else { "" }; - println!("\n## Setting up {n} EVM{s}."); - } - - let futs = script_config - .total_rpcs - .iter() - .map(|rpc| async { - let mut script_config = script_config.clone(); - script_config.evm_opts.fork_url = Some(rpc.clone()); - let runner = self - .prepare_runner(&mut script_config, sender, SimulationStage::OnChain, None) - .await?; - Ok((rpc.clone(), runner)) - }) - .collect::>(); - - join_all(futs).await.into_iter().collect() - } - - /// Creates the Runner that drives script execution - async fn prepare_runner( - &self, - script_config: &mut ScriptConfig, - sender: Address, - stage: SimulationStage, - script_wallets: Option, - ) -> Result { - trace!("preparing script runner"); - let env = script_config.evm_opts.evm_env().await?; - - // The db backend that serves all the data. - let db = match &script_config.evm_opts.fork_url { - Some(url) => match script_config.backends.get(url) { - Some(db) => db.clone(), - None => { - let fork = script_config.evm_opts.get_fork(&script_config.config, env.clone()); - let backend = Backend::spawn(fork); - script_config.backends.insert(url.clone(), backend.clone()); - backend - } - }, - None => { - // It's only really `None`, when we don't pass any `--fork-url`. And if so, there is - // no need to cache it, since there won't be any onchain simulation that we'd need - // to cache the backend for. - Backend::spawn(script_config.evm_opts.get_fork(&script_config.config, env.clone())) - } - }; - - // We need to enable tracing to decode contract names: local or external. - let mut builder = ExecutorBuilder::new() - .inspectors(|stack| stack.trace(true)) - .spec(script_config.config.evm_spec_id()) - .gas_limit(script_config.evm_opts.gas_limit()); - - if let SimulationStage::Local = stage { - builder = builder.inspectors(|stack| { - stack - .debug(self.debug) - .cheatcodes( - CheatsConfig::new( - &script_config.config, - script_config.evm_opts.clone(), - script_wallets, - ) - .into(), - ) - .enable_isolation(script_config.evm_opts.isolate) - }); - } - - Ok(ScriptRunner::new( - builder.build(env, db), - script_config.evm_opts.initial_balance, - sender, - )) - } -} diff --git a/crates/forge/bin/cmd/script/multi.rs b/crates/forge/bin/cmd/script/multi.rs deleted file mode 100644 index 874dd24ba6363..0000000000000 --- a/crates/forge/bin/cmd/script/multi.rs +++ /dev/null @@ -1,240 +0,0 @@ -use super::{ - receipts, - sequence::{sig_to_file_name, ScriptSequence, SensitiveScriptSequence, DRY_RUN_DIR}, - verify::VerifyBundle, - ScriptArgs, -}; -use alloy_primitives::Address; -use eyre::{ContextCompat, Report, Result, WrapErr}; -use foundry_cli::utils::now; -use foundry_common::{fs, provider::ethers::get_http_provider}; -use foundry_compilers::{artifacts::Libraries, ArtifactId}; -use foundry_config::Config; -use foundry_wallets::WalletSigner; -use futures::future::join_all; -use serde::{Deserialize, Serialize}; -use std::{ - collections::HashMap, - io::{BufWriter, Write}, - path::{Path, PathBuf}, - sync::Arc, -}; - -/// Holds the sequences of multiple chain deployments. -#[derive(Clone, Default, Serialize, Deserialize)] -pub struct MultiChainSequence { - pub deployments: Vec, - #[serde(skip)] - pub path: PathBuf, - #[serde(skip)] - pub sensitive_path: PathBuf, - pub timestamp: u64, -} - -/// Sensitive values from script sequences. -#[derive(Clone, Default, Serialize, Deserialize)] -pub struct SensitiveMultiChainSequence { - pub deployments: Vec, -} - -fn to_sensitive(sequence: &mut MultiChainSequence) -> SensitiveMultiChainSequence { - SensitiveMultiChainSequence { - deployments: sequence.deployments.iter_mut().map(|sequence| sequence.into()).collect(), - } -} - -impl Drop for MultiChainSequence { - fn drop(&mut self) { - self.deployments.iter_mut().for_each(|sequence| sequence.sort_receipts()); - self.save().expect("could not save multi deployment sequence"); - } -} - -impl MultiChainSequence { - pub fn new( - deployments: Vec, - sig: &str, - target: &ArtifactId, - config: &Config, - broadcasted: bool, - ) -> Result { - let (path, sensitive_path) = MultiChainSequence::get_paths( - &config.broadcast, - &config.cache_path, - sig, - target, - broadcasted, - )?; - - Ok(MultiChainSequence { deployments, path, sensitive_path, timestamp: now().as_secs() }) - } - - /// Gets paths in the formats - /// ./broadcast/multi/contract_filename[-timestamp]/sig.json and - /// ./cache/multi/contract_filename[-timestamp]/sig.json - pub fn get_paths( - broadcast: &Path, - cache: &Path, - sig: &str, - target: &ArtifactId, - broadcasted: bool, - ) -> Result<(PathBuf, PathBuf)> { - let mut broadcast = broadcast.to_path_buf(); - let mut cache = cache.to_path_buf(); - let mut common = PathBuf::new(); - - common.push("multi"); - - if !broadcasted { - common.push(DRY_RUN_DIR); - } - - let target_fname = target - .source - .file_name() - .wrap_err_with(|| format!("No filename for {:?}", target.source))? - .to_string_lossy(); - - common.push(format!("{target_fname}-latest")); - - broadcast.push(common.clone()); - cache.push(common); - - fs::create_dir_all(&broadcast)?; - fs::create_dir_all(&cache)?; - - let filename = format!("{}.json", sig_to_file_name(sig)); - - broadcast.push(filename.clone()); - cache.push(filename); - - Ok((broadcast, cache)) - } - - /// Loads the sequences for the multi chain deployment. - pub fn load(config: &Config, sig: &str, target: &ArtifactId) -> Result { - let (path, sensitive_path) = MultiChainSequence::get_paths( - &config.broadcast, - &config.cache_path, - sig, - target, - true, - )?; - let mut sequence: MultiChainSequence = foundry_compilers::utils::read_json_file(&path) - .wrap_err("Multi-chain deployment not found.")?; - let sensitive_sequence: SensitiveMultiChainSequence = - foundry_compilers::utils::read_json_file(&sensitive_path) - .wrap_err("Multi-chain deployment sensitive details not found.")?; - - sequence.deployments.iter_mut().enumerate().for_each(|(i, sequence)| { - sequence.fill_sensitive(&sensitive_sequence.deployments[i]); - }); - - sequence.path = path; - sequence.sensitive_path = sensitive_path; - - Ok(sequence) - } - - /// Saves the transactions as file if it's a standalone deployment. - pub fn save(&mut self) -> Result<()> { - self.timestamp = now().as_secs(); - - let sensitive_sequence: SensitiveMultiChainSequence = to_sensitive(self); - - // broadcast writes - //../Contract-latest/run.json - let mut writer = BufWriter::new(fs::create_file(&self.path)?); - serde_json::to_writer_pretty(&mut writer, &self)?; - writer.flush()?; - - //../Contract-[timestamp]/run.json - let path = self.path.to_string_lossy(); - let file = PathBuf::from(&path.replace("-latest", &format!("-{}", self.timestamp))); - fs::create_dir_all(file.parent().unwrap())?; - fs::copy(&self.path, &file)?; - - // cache writes - //../Contract-latest/run.json - let mut writer = BufWriter::new(fs::create_file(&self.sensitive_path)?); - serde_json::to_writer_pretty(&mut writer, &sensitive_sequence)?; - writer.flush()?; - - //../Contract-[timestamp]/run.json - let path = self.sensitive_path.to_string_lossy(); - let file = PathBuf::from(&path.replace("-latest", &format!("-{}", self.timestamp))); - fs::create_dir_all(file.parent().unwrap())?; - fs::copy(&self.sensitive_path, &file)?; - - println!("\nTransactions saved to: {}\n", self.path.display()); - println!("Sensitive details saved to: {}\n", self.sensitive_path.display()); - - Ok(()) - } -} - -impl ScriptArgs { - /// Given a [`MultiChainSequence`] with multiple sequences of different chains, it executes them - /// all in parallel. Supports `--resume` and `--verify`. - pub async fn multi_chain_deployment( - &self, - mut deployments: MultiChainSequence, - libraries: Libraries, - config: &Config, - verify: VerifyBundle, - signers: &HashMap, - ) -> Result<()> { - if !libraries.is_empty() { - eyre::bail!("Libraries are currently not supported on multi deployment setups."); - } - - if self.verify { - for sequence in &deployments.deployments { - sequence.verify_preflight_check(config, &verify)?; - } - } - - if self.resume { - trace!(target: "script", "resuming multi chain deployment"); - - let futs = deployments - .deployments - .iter_mut() - .map(|sequence| async move { - let rpc_url = sequence.rpc_url().unwrap(); - let provider = Arc::new(get_http_provider(rpc_url)); - receipts::wait_for_pending(provider, sequence).await - }) - .collect::>(); - - let errors = - join_all(futs).await.into_iter().filter(|res| res.is_err()).collect::>(); - - if !errors.is_empty() { - return Err(eyre::eyre!("{errors:?}")); - } - } - - trace!(target: "script", "broadcasting multi chain deployments"); - - let mut results: Vec> = Vec::new(); - - for sequence in deployments.deployments.iter_mut() { - let rpc_url = sequence.rpc_url().unwrap().to_string(); - let result = match self.send_transactions(sequence, &rpc_url, signers).await { - Ok(_) if self.verify => sequence.verify_contracts(config, verify.clone()).await, - Ok(_) => Ok(()), - Err(err) => Err(err), - }; - results.push(result); - } - - let errors = results.into_iter().filter(|res| res.is_err()).collect::>(); - - if !errors.is_empty() { - return Err(eyre::eyre!("{errors:?}")); - } - - Ok(()) - } -} diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 5fdc7c408a830..0743d69e61aa1 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -31,7 +31,7 @@ fn main() -> Result<()> { ForgeSubcommand::Script(cmd) => { // install the shell before executing the command foundry_common::shell::set_shell(foundry_common::shell::Shell::from_args( - cmd.opts.args.silent, + cmd.opts.silent, cmd.json, ))?; utils::block_on(cmd.run_script()) diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 5e5cfda7c8b6f..03ed4d551f4b3 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -2,9 +2,10 @@ use crate::cmd::{ bind::BindArgs, build::BuildArgs, cache::CacheArgs, config, coverage, create::CreateArgs, debug::DebugArgs, doc::DocArgs, flatten, fmt::FmtArgs, geiger, generate, init::InitArgs, inspect, install::InstallArgs, remappings::RemappingArgs, remove::RemoveArgs, - script::ScriptArgs, selectors::SelectorsSubcommands, snapshot, test, tree, update, + selectors::SelectorsSubcommands, snapshot, test, tree, update, }; use clap::{Parser, Subcommand, ValueHint}; +use forge_script::ScriptArgs; use forge_verify::{VerifyArgs, VerifyCheckArgs}; use std::path::PathBuf; diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 39854abac8a18..f6b9a54a8e681 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -207,23 +207,3 @@ impl TestOptionsBuilder { TestOptions::new(output, root, profiles, base_fuzz, base_invariant) } } - -mod utils2 { - use alloy_primitives::Address; - use ethers_core::types::BlockId; - use ethers_providers::{Middleware, Provider}; - use eyre::Context; - use foundry_common::types::{ToAlloy, ToEthers}; - - pub async fn next_nonce( - caller: Address, - provider_url: &str, - block: Option, - ) -> eyre::Result { - let provider = Provider::try_from(provider_url) - .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; - let res = provider.get_transaction_count(caller.to_ethers(), block).await?.to_alloy(); - res.try_into().map_err(Into::into) - } -} -pub use utils2::*; diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index d6f7628da1694..121fa986269a7 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -61,6 +61,5 @@ forgetest_async!(can_resume_multi_chain_script, |prj, cmd| { .broadcast(ScriptOutcome::MissingWallet) .load_private_keys(&[0, 1]) .await - .arg("--multi") .resume(ScriptOutcome::OkBroadcast); }); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index b45ce52cf4451..e212683c1a2b0 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1080,6 +1080,28 @@ interface Interface {} assert!(cmd.stdout_lossy().contains("Script ran successfully.")); }); +forgetest_async!(assert_can_detect_unlinked_target_with_libraries, |prj, cmd| { + let script = prj + .add_script( + "ScriptWithExtLib.s.sol", + r#" +library Lib { + function f() public {} +} + +contract Script { + function run() external { + Lib.f(); + } +} + "#, + ) + .unwrap(); + + cmd.arg("script").arg(script); + assert!(cmd.stdout_lossy().contains("Script ran successfully.")); +}); + forgetest_async!(assert_can_resume_with_additional_contracts, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml new file mode 100644 index 0000000000000..5ae57482200ef --- /dev/null +++ b/crates/script/Cargo.toml @@ -0,0 +1,50 @@ +[package] +name = "forge-script" +description = "Solidity scripting" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +forge-verify.workspace = true +foundry-cli.workspace = true +foundry-config.workspace = true +foundry-common.workspace = true +foundry-evm.workspace = true +foundry-debugger.workspace = true +foundry-cheatcodes.workspace = true +foundry-wallets.workspace = true +foundry-linking.workspace = true + +hex.workspace = true +serde.workspace = true +eyre.workspace = true +serde_json.workspace = true +dunce = "1" +foundry-compilers = { workspace = true, features = ["full"] } +tracing.workspace = true +clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } +semver = "1" +futures = "0.3" +async-recursion = "1.0.5" +alloy-primitives.workspace = true +alloy-dyn-abi.workspace = true +itertools.workspace = true +parking_lot = "0.12" +yansi = "0.5" +ethers-core.workspace = true +ethers-providers.workspace = true +ethers-signers.workspace = true +revm-inspectors.workspace = true +alloy-rpc-types.workspace = true +alloy-json-abi.workspace = true +dialoguer = { version = "0.11", default-features = false } +indicatif = "0.17" + +[dev-dependencies] +tempfile = "3" \ No newline at end of file diff --git a/crates/forge/bin/cmd/script/artifacts.rs b/crates/script/src/artifacts.rs similarity index 100% rename from crates/forge/bin/cmd/script/artifacts.rs rename to crates/script/src/artifacts.rs diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs new file mode 100644 index 0000000000000..fb21276c28380 --- /dev/null +++ b/crates/script/src/broadcast.rs @@ -0,0 +1,431 @@ +use crate::{ + build::LinkedBuildData, + execute::{ExecutionArtifacts, ExecutionData}, + sequence::ScriptSequenceKind, + verify::BroadcastedState, + ScriptArgs, ScriptConfig, +}; + +use super::receipts; +use alloy_primitives::{utils::format_units, Address, TxHash, U256}; +use ethers_core::types::{transaction::eip2718::TypedTransaction, BlockId}; +use ethers_providers::{JsonRpcClient, Middleware, Provider}; +use ethers_signers::Signer; +use eyre::{bail, Context, Result}; +use forge_verify::provider::VerificationProviderType; +use foundry_cheatcodes::ScriptWallets; +use foundry_cli::{ + init_progress, update_progress, + utils::{has_batch_support, has_different_gas_calc}, +}; +use foundry_common::{ + provider::ethers::{ + estimate_eip1559_fees, get_http_provider, try_get_http_provider, RetryProvider, + }, + shell, + types::{ToAlloy, ToEthers}, +}; +use foundry_config::Config; +use foundry_wallets::WalletSigner; +use futures::{future::join_all, StreamExt}; +use itertools::Itertools; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; + +pub async fn estimate_gas( + tx: &mut TypedTransaction, + provider: &Provider, + estimate_multiplier: u64, +) -> Result<()> +where + T: JsonRpcClient, +{ + // if already set, some RPC endpoints might simply return the gas value that is already + // set in the request and omit the estimate altogether, so we remove it here + let _ = tx.gas_mut().take(); + + tx.set_gas( + provider + .estimate_gas(tx, None) + .await + .wrap_err_with(|| format!("Failed to estimate gas for tx: {:?}", tx.sighash()))? * + estimate_multiplier / + 100, + ); + Ok(()) +} + +pub async fn next_nonce( + caller: Address, + provider_url: &str, + block: Option, +) -> eyre::Result { + let provider = Provider::try_from(provider_url) + .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; + let res = provider.get_transaction_count(caller.to_ethers(), block).await?.to_alloy(); + res.try_into().map_err(Into::into) +} + +pub async fn send_transaction( + provider: Arc, + mut tx: TypedTransaction, + kind: SendTransactionKind<'_>, + sequential_broadcast: bool, + is_fixed_gas_limit: bool, + estimate_via_rpc: bool, + estimate_multiplier: u64, +) -> Result { + let from = tx.from().expect("no sender"); + + if sequential_broadcast { + let nonce = provider.get_transaction_count(*from, None).await?; + + let tx_nonce = tx.nonce().expect("no nonce"); + if nonce != *tx_nonce { + bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") + } + } + + // Chains which use `eth_estimateGas` are being sent sequentially and require their + // gas to be re-estimated right before broadcasting. + if !is_fixed_gas_limit && estimate_via_rpc { + estimate_gas(&mut tx, &provider, estimate_multiplier).await?; + } + + let pending = match kind { + SendTransactionKind::Unlocked(addr) => { + debug!("sending transaction from unlocked account {:?}: {:?}", addr, tx); + + // Submit the transaction + provider.send_transaction(tx, None).await? + } + SendTransactionKind::Raw(signer) => { + debug!("sending transaction: {:?}", tx); + + // Signing manually so we skip `fill_transaction` and its `eth_createAccessList` + // request. + let signature = + signer.sign_transaction(&tx).await.wrap_err("Failed to sign transaction")?; + + // Submit the raw transaction + provider.send_raw_transaction(tx.rlp_signed(&signature)).await? + } + }; + + Ok(pending.tx_hash().to_alloy()) +} + +/// How to send a single transaction +#[derive(Clone)] +pub enum SendTransactionKind<'a> { + Unlocked(Address), + Raw(&'a WalletSigner), +} + +/// Represents how to send _all_ transactions +pub enum SendTransactionsKind { + /// Send via `eth_sendTransaction` and rely on the `from` address being unlocked. + Unlocked(HashSet
), + /// Send a signed transaction via `eth_sendRawTransaction` + Raw(HashMap), +} + +impl SendTransactionsKind { + /// Returns the [`SendTransactionKind`] for the given address + /// + /// Returns an error if no matching signer is found or the address is not unlocked + pub fn for_sender(&self, addr: &Address) -> Result> { + match self { + SendTransactionsKind::Unlocked(unlocked) => { + if !unlocked.contains(addr) { + bail!("Sender address {:?} is not unlocked", addr) + } + Ok(SendTransactionKind::Unlocked(*addr)) + } + SendTransactionsKind::Raw(wallets) => { + if let Some(wallet) = wallets.get(addr) { + Ok(SendTransactionKind::Raw(wallet)) + } else { + bail!("No matching signer for {:?} found", addr) + } + } + } + } + + /// How many signers are set + pub fn signers_count(&self) -> usize { + match self { + SendTransactionsKind::Unlocked(addr) => addr.len(), + SendTransactionsKind::Raw(signers) => signers.len(), + } + } +} + +/// State after we have bundled all [TransactionWithMetadata] objects into a single +/// [ScriptSequenceKind] object containing one or more script sequences. +pub struct BundledState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, + pub build_data: LinkedBuildData, + pub execution_data: ExecutionData, + pub execution_artifacts: ExecutionArtifacts, + pub sequence: ScriptSequenceKind, +} + +impl BundledState { + pub async fn wait_for_pending(mut self) -> Result { + let futs = self + .sequence + .sequences_mut() + .iter_mut() + .map(|sequence| async move { + let rpc_url = sequence.rpc_url(); + let provider = Arc::new(get_http_provider(rpc_url)); + receipts::wait_for_pending(provider, sequence).await + }) + .collect::>(); + + let errors = join_all(futs).await.into_iter().filter_map(Result::err).collect::>(); + + self.sequence.save(true, false)?; + + if !errors.is_empty() { + return Err(eyre::eyre!("{}", errors.iter().format("\n"))); + } + + Ok(self) + } + + /// Broadcasts transactions from all sequences. + pub async fn broadcast(mut self) -> Result { + let required_addresses = self + .sequence + .sequences() + .iter() + .flat_map(|sequence| { + sequence + .typed_transactions() + .map(|tx| (*tx.from().expect("No sender for onchain transaction!")).to_alloy()) + }) + .collect::>(); + + if required_addresses.contains(&Config::DEFAULT_SENDER) { + eyre::bail!( + "You seem to be using Foundry's default sender. Be sure to set your own --sender." + ); + } + + let send_kind = if self.args.unlocked { + SendTransactionsKind::Unlocked(required_addresses) + } else { + let signers = self.script_wallets.into_multi_wallet().into_signers()?; + let mut missing_addresses = Vec::new(); + + for addr in &required_addresses { + if !signers.contains_key(addr) { + missing_addresses.push(addr); + } + } + + if !missing_addresses.is_empty() { + eyre::bail!( + "No associated wallet for addresses: {:?}. Unlocked wallets: {:?}", + missing_addresses, + signers.keys().collect::>() + ); + } + + SendTransactionsKind::Raw(signers) + }; + + for i in 0..self.sequence.sequences().len() { + let mut sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); + + let provider = Arc::new(try_get_http_provider(sequence.rpc_url())?); + let already_broadcasted = sequence.receipts.len(); + + if already_broadcasted < sequence.transactions.len() { + // Make a one-time gas price estimation + let (gas_price, eip1559_fees) = match self.args.with_gas_price { + None => match sequence.transactions.front().unwrap().typed_tx() { + TypedTransaction::Eip1559(_) => { + let mut fees = estimate_eip1559_fees(&provider, Some(sequence.chain)) + .await + .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; + + if let Some(priority_gas_price) = self.args.priority_gas_price { + fees.1 = priority_gas_price.to_ethers(); + } + + (None, Some(fees)) + } + _ => (provider.get_gas_price().await.ok(), None), + }, + Some(gas_price) => (Some(gas_price.to_ethers()), None), + }; + + // Iterate through transactions, matching the `from` field with the associated + // wallet. Then send the transaction. Panics if we find a unknown `from` + let transactions = sequence + .transactions + .iter() + .skip(already_broadcasted) + .map(|tx_with_metadata| { + let tx = tx_with_metadata.typed_tx(); + let from = + (*tx.from().expect("No sender for onchain transaction!")).to_alloy(); + + let kind = send_kind.for_sender(&from)?; + let is_fixed_gas_limit = tx_with_metadata.is_fixed_gas_limit; + + let mut tx = tx.clone(); + + tx.set_chain_id(sequence.chain); + + if let Some(gas_price) = gas_price { + tx.set_gas_price(gas_price); + } else { + let eip1559_fees = eip1559_fees.expect("was set above"); + // fill gas price + match tx { + TypedTransaction::Eip1559(ref mut inner) => { + inner.max_priority_fee_per_gas = Some(eip1559_fees.1); + inner.max_fee_per_gas = Some(eip1559_fees.0); + } + _ => { + // If we're here, it means that first transaction of the + // sequence was EIP1559 transaction (see match statement above), + // however, we can only have transactions of the same type in + // the sequence. + unreachable!() + } + } + } + + Ok((tx, kind, is_fixed_gas_limit)) + }) + .collect::>>()?; + + let estimate_via_rpc = + has_different_gas_calc(sequence.chain) || self.args.skip_simulation; + + // We only wait for a transaction receipt before sending the next transaction, if + // there is more than one signer. There would be no way of assuring + // their order otherwise. + // Or if the chain does not support batched transactions (eg. Arbitrum). + // Or if we need to invoke eth_estimateGas before sending transactions. + let sequential_broadcast = estimate_via_rpc || + self.args.slow || + send_kind.signers_count() != 1 || + !has_batch_support(sequence.chain); + + let pb = init_progress!(transactions, "txes"); + + // We send transactions and wait for receipts in batches of 100, since some networks + // cannot handle more than that. + let batch_size = if sequential_broadcast { 1 } else { 100 }; + let mut index = already_broadcasted; + + for (batch_number, batch) in + transactions.chunks(batch_size).map(|f| f.to_vec()).enumerate() + { + let mut pending_transactions = vec![]; + + shell::println(format!( + "##\nSending transactions [{} - {}].", + batch_number * batch_size, + batch_number * batch_size + std::cmp::min(batch_size, batch.len()) - 1 + ))?; + for (tx, kind, is_fixed_gas_limit) in batch.into_iter() { + let tx_hash = send_transaction( + provider.clone(), + tx, + kind, + sequential_broadcast, + is_fixed_gas_limit, + estimate_via_rpc, + self.args.gas_estimate_multiplier, + ); + pending_transactions.push(tx_hash); + } + + if !pending_transactions.is_empty() { + let mut buffer = futures::stream::iter(pending_transactions).buffered(7); + + while let Some(tx_hash) = buffer.next().await { + let tx_hash = tx_hash.wrap_err("Failed to send transaction")?; + sequence.add_pending(index, tx_hash); + + // Checkpoint save + self.sequence.save(true, false)?; + sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); + + update_progress!(pb, index - already_broadcasted); + index += 1; + } + + // Checkpoint save + self.sequence.save(true, false)?; + sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); + + shell::println("##\nWaiting for receipts.")?; + receipts::clear_pendings(provider.clone(), sequence, None).await?; + } + // Checkpoint save + self.sequence.save(true, false)?; + sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); + } + } + + shell::println("\n\n==========================")?; + shell::println("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; + + let (total_gas, total_gas_price, total_paid) = sequence.receipts.iter().fold( + (U256::ZERO, U256::ZERO, U256::ZERO), + |acc, receipt| { + let gas_used = receipt.gas_used.unwrap_or_default().to_alloy(); + let gas_price = receipt.effective_gas_price.unwrap_or_default().to_alloy(); + (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used * gas_price) + }, + ); + let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); + let avg_gas_price = + format_units(total_gas_price / U256::from(sequence.receipts.len()), 9) + .unwrap_or_else(|_| "N/A".to_string()); + + shell::println(format!( + "Total Paid: {} ETH ({} gas * avg {} gwei)", + paid.trim_end_matches('0'), + total_gas, + avg_gas_price.trim_end_matches('0').trim_end_matches('.') + ))?; + } + + Ok(BroadcastedState { + args: self.args, + script_config: self.script_config, + build_data: self.build_data, + execution_data: self.execution_data, + execution_artifacts: self.execution_artifacts, + sequence: self.sequence, + }) + } + + pub fn verify_preflight_check(&self) -> Result<()> { + for sequence in self.sequence.sequences() { + if self.args.verifier.verifier == VerificationProviderType::Etherscan && + self.script_config + .config + .get_etherscan_api_key(Some(sequence.chain.into())) + .is_none() + { + eyre::bail!("Missing etherscan key for chain {}", sequence.chain); + } + } + + Ok(()) + } +} diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs new file mode 100644 index 0000000000000..4dc78b0cdc566 --- /dev/null +++ b/crates/script/src/build.rs @@ -0,0 +1,248 @@ +use crate::{execute::LinkedState, ScriptArgs, ScriptConfig}; + +use alloy_primitives::{Address, Bytes}; +use eyre::{Context, OptionExt, Result}; +use foundry_cheatcodes::ScriptWallets; +use foundry_cli::utils::get_cached_entry_by_name; +use foundry_common::{ + compile::{self, ContractSources, ProjectCompiler}, + ContractsByArtifact, +}; +use foundry_compilers::{ + artifacts::{BytecodeObject, ContractBytecode, ContractBytecodeSome, Libraries}, + cache::SolFilesCache, + contracts::ArtifactContracts, + info::ContractInfo, + ArtifactId, +}; +use foundry_linking::{LinkOutput, Linker}; +use std::str::FromStr; + +/// Container for the compiled contracts. +pub struct BuildData { + /// Linker which can be used to link contracts, owns [ArtifactContracts] map. + pub linker: Linker, + /// Id of target contract artifact. + pub target: ArtifactId, + /// Source files of the contracts. Used by debugger. + pub sources: ContractSources, +} + +impl BuildData { + /// Links the build data with given libraries, using sender and nonce to compute addresses of + /// missing libraries. + pub fn link( + self, + known_libraries: Libraries, + sender: Address, + nonce: u64, + ) -> Result { + let link_output = + self.linker.link_with_nonce_or_address(known_libraries, sender, nonce, &self.target)?; + + LinkedBuildData::new(link_output, self) + } + + /// Links the build data with the given libraries. Expects supplied libraries set being enough + /// to fully link target contract. + pub fn link_with_libraries(self, libraries: Libraries) -> Result { + let link_output = + self.linker.link_with_nonce_or_address(libraries, Address::ZERO, 0, &self.target)?; + + if !link_output.libs_to_deploy.is_empty() { + eyre::bail!("incomplete libraries set"); + } + + LinkedBuildData::new(link_output, self) + } +} + +/// Container for the linked contracts and their dependencies +pub struct LinkedBuildData { + /// Original build data, might be used to relink this object with different libraries. + pub build_data: BuildData, + /// Known fully linked contracts. + pub highlevel_known_contracts: ArtifactContracts, + /// Libraries used to link the contracts. + pub libraries: Libraries, + /// Libraries that need to be deployed by sender before script execution. + pub predeploy_libraries: Vec, +} + +impl LinkedBuildData { + pub fn new(link_output: LinkOutput, build_data: BuildData) -> Result { + let highlevel_known_contracts = build_data + .linker + .get_linked_artifacts(&link_output.libraries)? + .iter() + .filter_map(|(id, contract)| { + ContractBytecodeSome::try_from(ContractBytecode::from(contract.clone())) + .ok() + .map(|tc| (id.clone(), tc)) + }) + .filter(|(_, tc)| tc.bytecode.object.is_non_empty_bytecode()) + .collect(); + + Ok(Self { + build_data, + highlevel_known_contracts, + libraries: link_output.libraries, + predeploy_libraries: link_output.libs_to_deploy, + }) + } + + /// Flattens the contracts into (`id` -> (`JsonAbi`, `Vec`)) pairs + pub fn get_flattened_contracts(&self, deployed_code: bool) -> ContractsByArtifact { + ContractsByArtifact( + self.highlevel_known_contracts + .iter() + .filter_map(|(id, c)| { + let bytecode = if deployed_code { + c.deployed_bytecode.bytes() + } else { + c.bytecode.bytes() + }; + bytecode.cloned().map(|code| (id.clone(), (c.abi.clone(), code.into()))) + }) + .collect(), + ) + } + + /// Fetches target bytecode from linked contracts. + pub fn get_target_contract(&self) -> Result { + self.highlevel_known_contracts + .get(&self.build_data.target) + .cloned() + .ok_or_eyre("target not found in linked artifacts") + } +} + +/// First state basically containing only inputs of the user. +pub struct PreprocessedState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, +} + +impl PreprocessedState { + /// Parses user input and compiles the contracts depending on script target. + /// After compilation, finds exact [ArtifactId] of the target contract. + pub fn compile(self) -> Result { + let Self { args, script_config, script_wallets } = self; + let project = script_config.config.project()?; + let filters = args.skip.clone().unwrap_or_default(); + + let mut target_name = args.target_contract.clone(); + + // If we've received correct path, use it as target_path + // Otherwise, parse input as : and use the path from the contract info, if + // present. + let target_path = if let Ok(path) = dunce::canonicalize(&args.path) { + Some(path) + } else { + let contract = ContractInfo::from_str(&args.path)?; + target_name = Some(contract.name.clone()); + if let Some(path) = contract.path { + Some(dunce::canonicalize(path)?) + } else { + None + } + }; + + // If we've found target path above, only compile it. + // Otherwise, compile everything to match contract by name later. + let output = if let Some(target_path) = target_path.clone() { + compile::compile_target_with_filter( + &target_path, + &project, + args.opts.silent, + args.verify, + filters, + ) + } else if !project.paths.has_input_files() { + Err(eyre::eyre!("The project doesn't have any input files. Make sure the `script` directory is configured properly in foundry.toml. Otherwise, provide the path to the file.")) + } else { + ProjectCompiler::new().compile(&project) + }?; + + // If we still don't have target path, find it by name in the compilation cache. + let target_path = if let Some(target_path) = target_path { + target_path + } else { + let target_name = target_name.clone().expect("was set above"); + let cache = SolFilesCache::read_joined(&project.paths) + .wrap_err("Could not open compiler cache")?; + let (path, _) = get_cached_entry_by_name(&cache, &target_name) + .wrap_err("Could not find target contract in cache")?; + path + }; + + let target_path = project.root().join(target_path); + + let mut target_id: Option = None; + + // Find target artfifact id by name and path in compilation artifacts. + for (id, contract) in output.artifact_ids().filter(|(id, _)| id.source == target_path) { + if let Some(name) = &target_name { + if id.name != *name { + continue; + } + } else if contract.abi.as_ref().map_or(true, |abi| abi.is_empty()) || + contract.bytecode.as_ref().map_or(true, |b| match &b.object { + BytecodeObject::Bytecode(b) => b.is_empty(), + BytecodeObject::Unlinked(_) => false, + }) + { + // Ignore contracts with empty abi or linked bytecode of length 0 which are + // interfaces/abstract contracts/libraries. + continue; + } + + if let Some(target) = target_id { + // We might have multiple artifacts for the same contract but with different + // solc versions. Their names will have form of {name}.0.X.Y, so we are + // stripping versions off before comparing them. + let target_name = target.name.split('.').next().unwrap(); + let id_name = id.name.split('.').next().unwrap(); + if target_name != id_name { + eyre::bail!("Multiple contracts in the target path. Please specify the contract name with `--tc ContractName`") + } + } + target_id = Some(id); + } + + let sources = ContractSources::from_project_output(&output, project.root())?; + let contracts = output.into_artifacts().collect(); + let target = target_id.ok_or_eyre("Could not find target contract")?; + let linker = Linker::new(project.root(), contracts); + + Ok(CompiledState { + args, + script_config, + script_wallets, + build_data: BuildData { linker, target, sources }, + }) + } +} + +/// State after we have determined and compiled target contract to be executed. +pub struct CompiledState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, + pub build_data: BuildData, +} + +impl CompiledState { + /// Uses provided sender address to compute library addresses and link contracts with them. + pub fn link(self) -> Result { + let Self { args, script_config, script_wallets, build_data } = self; + + let sender = script_config.evm_opts.sender; + let nonce = script_config.sender_nonce; + let known_libraries = script_config.config.libraries_with_remappings()?; + let build_data = build_data.link(known_libraries, sender, nonce)?; + + Ok(LinkedState { args, script_config, script_wallets, build_data }) + } +} diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs new file mode 100644 index 0000000000000..cdf4353d38608 --- /dev/null +++ b/crates/script/src/execute.rs @@ -0,0 +1,522 @@ +use crate::{ + build::{CompiledState, LinkedBuildData}, + simulate::PreSimulationState, + ScriptArgs, ScriptConfig, +}; + +use super::{runner::ScriptRunner, JsonResult, NestedValue, ScriptResult}; +use alloy_dyn_abi::FunctionExt; +use alloy_json_abi::{Function, InternalType, JsonAbi}; +use alloy_primitives::{Address, Bytes, U64}; +use alloy_rpc_types::request::TransactionRequest; +use async_recursion::async_recursion; +use ethers_providers::Middleware; +use eyre::Result; +use foundry_cheatcodes::ScriptWallets; +use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; +use foundry_common::{ + fmt::{format_token, format_token_raw}, + provider::ethers::{get_http_provider, RpcUrl}, + shell, ContractsByArtifact, +}; +use foundry_compilers::artifacts::ContractBytecodeSome; +use foundry_config::{Config, NamedChain}; +use foundry_debugger::Debugger; +use foundry_evm::{ + decode::{decode_console_logs, RevertDecoder}, + inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, + traces::{ + identifier::{SignaturesIdentifier, TraceIdentifiers}, + render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, + }, +}; +use futures::future::join_all; +use itertools::Itertools; +use std::collections::{HashMap, HashSet}; +use yansi::Paint; + +/// State after linking, contains the linked build data along with library addresses and optional +/// array of libraries that need to be predeployed. +pub struct LinkedState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, + pub build_data: LinkedBuildData, +} + +/// Container for data we need for execution which can only be obtained after linking stage. +pub struct ExecutionData { + /// Function to call. + pub func: Function, + /// Calldata to pass to the target contract. + pub calldata: Bytes, + /// Bytecode of the target contract. + pub bytecode: Bytes, + /// ABI of the target contract. + pub abi: JsonAbi, +} + +impl LinkedState { + /// Given linked and compiled artifacts, prepares data we need for execution. + /// This includes the function to call and the calldata to pass to it. + pub async fn prepare_execution(self) -> Result { + let Self { args, script_config, script_wallets, build_data } = self; + + let ContractBytecodeSome { abi, bytecode, .. } = build_data.get_target_contract()?; + + let bytecode = bytecode.into_bytes().ok_or_else(|| { + eyre::eyre!("expected fully linked bytecode, found unlinked bytecode") + })?; + + let (func, calldata) = args.get_method_and_calldata(&abi)?; + + ensure_clean_constructor(&abi)?; + + Ok(PreExecutionState { + args, + script_config, + script_wallets, + build_data, + execution_data: ExecutionData { func, calldata, bytecode, abi }, + }) + } +} + +/// Same as [LinkedState], but also contains [ExecutionData]. +pub struct PreExecutionState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, + pub build_data: LinkedBuildData, + pub execution_data: ExecutionData, +} + +impl PreExecutionState { + /// Executes the script and returns the state after execution. + /// Might require executing script twice in cases when we determine sender from execution. + #[async_recursion] + pub async fn execute(mut self) -> Result { + let mut runner = self + .script_config + .get_runner_with_cheatcodes(self.script_wallets.clone(), self.args.debug) + .await?; + let mut result = self.execute_with_runner(&mut runner).await?; + + // If we have a new sender from execution, we need to use it to deploy libraries and relink + // contracts. + if let Some(new_sender) = self.maybe_new_sender(result.transactions.as_ref())? { + self.script_config.update_sender(new_sender).await?; + + // Rollback to rerun linking with the new sender. + let state = CompiledState { + args: self.args, + script_config: self.script_config, + script_wallets: self.script_wallets, + build_data: self.build_data.build_data, + }; + + return state.link()?.prepare_execution().await?.execute().await; + } + + // Add library deployment transactions to broadcastable transactions list. + if let Some(txs) = result.transactions.take() { + result.transactions = Some( + self.build_data + .predeploy_libraries + .iter() + .enumerate() + .map(|(i, bytes)| BroadcastableTransaction { + rpc: self.script_config.evm_opts.fork_url.clone(), + transaction: TransactionRequest { + from: Some(self.script_config.evm_opts.sender), + input: Some(bytes.clone()).into(), + nonce: Some(U64::from(self.script_config.sender_nonce + i as u64)), + ..Default::default() + }, + }) + .chain(txs) + .collect(), + ); + } + + Ok(ExecutedState { + args: self.args, + script_config: self.script_config, + script_wallets: self.script_wallets, + build_data: self.build_data, + execution_data: self.execution_data, + execution_result: result, + }) + } + + /// Executes the script using the provided runner and returns the [ScriptResult]. + pub async fn execute_with_runner(&self, runner: &mut ScriptRunner) -> Result { + let (address, mut setup_result) = runner.setup( + &self.build_data.predeploy_libraries, + self.execution_data.bytecode.clone(), + needs_setup(&self.execution_data.abi), + self.script_config.sender_nonce, + self.args.broadcast, + self.script_config.evm_opts.fork_url.is_none(), + )?; + + if setup_result.success { + let script_result = runner.script(address, self.execution_data.calldata.clone())?; + + setup_result.success &= script_result.success; + setup_result.gas_used = script_result.gas_used; + setup_result.logs.extend(script_result.logs); + setup_result.traces.extend(script_result.traces); + setup_result.debug = script_result.debug; + setup_result.labeled_addresses.extend(script_result.labeled_addresses); + setup_result.returned = script_result.returned; + setup_result.breakpoints = script_result.breakpoints; + + match (&mut setup_result.transactions, script_result.transactions) { + (Some(txs), Some(new_txs)) => { + txs.extend(new_txs); + } + (None, Some(new_txs)) => { + setup_result.transactions = Some(new_txs); + } + _ => {} + } + } + + Ok(setup_result) + } + + /// It finds the deployer from the running script and uses it to predeploy libraries. + /// + /// If there are multiple candidate addresses, it skips everything and lets `--sender` deploy + /// them instead. + fn maybe_new_sender( + &self, + transactions: Option<&BroadcastableTransactions>, + ) -> Result> { + let mut new_sender = None; + + if let Some(txs) = transactions { + // If the user passed a `--sender` don't check anything. + if !self.build_data.predeploy_libraries.is_empty() && + self.args.evm_opts.sender.is_none() + { + for tx in txs.iter() { + if tx.transaction.to.is_none() { + let sender = tx.transaction.from.expect("no sender"); + if let Some(ns) = new_sender { + if sender != ns { + shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; + return Ok(None); + } + } else if sender != self.script_config.evm_opts.sender { + new_sender = Some(sender); + } + } + } + } + } + Ok(new_sender) + } +} + +/// Container for information about RPC-endpoints used during script execution. +pub struct RpcData { + /// Unique list of rpc urls present. + pub total_rpcs: HashSet, + /// If true, one of the transactions did not have a rpc. + pub missing_rpc: bool, +} + +impl RpcData { + /// Iterates over script transactions and collects RPC urls. + fn from_transactions(txs: &BroadcastableTransactions) -> Self { + let missing_rpc = txs.iter().any(|tx| tx.rpc.is_none()); + let total_rpcs = + txs.iter().filter_map(|tx| tx.rpc.as_ref().cloned()).collect::>(); + + Self { total_rpcs, missing_rpc } + } + + /// Returns true if script might be multi-chain. + /// Returns false positive in case when missing rpc is the same as the only rpc present. + pub fn is_multi_chain(&self) -> bool { + self.total_rpcs.len() > 1 || (self.missing_rpc && !self.total_rpcs.is_empty()) + } + + /// Checks if all RPCs support EIP-3855. Prints a warning if not. + async fn check_shanghai_support(&self) -> Result<()> { + let chain_ids = self.total_rpcs.iter().map(|rpc| async move { + let provider = get_http_provider(rpc); + let id = provider.get_chainid().await.ok()?; + let id_u64: u64 = id.try_into().ok()?; + NamedChain::try_from(id_u64).ok() + }); + + let chains = join_all(chain_ids).await; + let iter = chains.iter().flatten().map(|c| (c.supports_shanghai(), c)); + if iter.clone().any(|(s, _)| !s) { + let msg = format!( + "\ +EIP-3855 is not supported in one or more of the RPCs used. +Unsupported Chain IDs: {}. +Contracts deployed with a Solidity version equal or higher than 0.8.20 might not work properly. +For more information, please see https://eips.ethereum.org/EIPS/eip-3855", + iter.filter(|(supported, _)| !supported) + .map(|(_, chain)| *chain as u64) + .format(", ") + ); + shell::println(Paint::yellow(msg))?; + } + Ok(()) + } +} + +/// Container for data being collected after execution. +pub struct ExecutionArtifacts { + /// Mapping from contract to its runtime code. + pub known_contracts: ContractsByArtifact, + /// Trace decoder used to decode traces. + pub decoder: CallTraceDecoder, + /// Return values from the execution result. + pub returns: HashMap, + /// Information about RPC endpoints used during script execution. + pub rpc_data: RpcData, +} + +/// State after the script has been executed. +pub struct ExecutedState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, + pub build_data: LinkedBuildData, + pub execution_data: ExecutionData, + pub execution_result: ScriptResult, +} + +impl ExecutedState { + /// Collects the data we need for simulation and various post-execution tasks. + pub async fn prepare_simulation(self) -> Result { + let returns = self.get_returns()?; + + let known_contracts = self.build_data.get_flattened_contracts(true); + let decoder = self.build_trace_decoder(&known_contracts)?; + + let txs = self.execution_result.transactions.clone().unwrap_or_default(); + let rpc_data = RpcData::from_transactions(&txs); + + if rpc_data.is_multi_chain() { + shell::eprintln(format!( + "{}", + Paint::yellow( + "Multi chain deployment is still under development. Use with caution." + ) + ))?; + if !self.build_data.libraries.is_empty() { + eyre::bail!( + "Multi chain deployment does not support library linking at the moment." + ) + } + } + rpc_data.check_shanghai_support().await?; + + Ok(PreSimulationState { + args: self.args, + script_config: self.script_config, + script_wallets: self.script_wallets, + build_data: self.build_data, + execution_data: self.execution_data, + execution_result: self.execution_result, + execution_artifacts: ExecutionArtifacts { known_contracts, decoder, returns, rpc_data }, + }) + } + + /// Builds [CallTraceDecoder] from the execution result and known contracts. + fn build_trace_decoder( + &self, + known_contracts: &ContractsByArtifact, + ) -> Result { + let mut decoder = CallTraceDecoderBuilder::new() + .with_labels(self.execution_result.labeled_addresses.clone()) + .with_verbosity(self.script_config.evm_opts.verbosity) + .with_known_contracts(known_contracts) + .with_signature_identifier(SignaturesIdentifier::new( + Config::foundry_cache_dir(), + self.script_config.config.offline, + )?) + .build(); + + let mut identifier = TraceIdentifiers::new().with_local(known_contracts).with_etherscan( + &self.script_config.config, + self.script_config.evm_opts.get_remote_chain_id(), + )?; + + // Decoding traces using etherscan is costly as we run into rate limits, + // causing scripts to run for a very long time unnecessarily. + // Therefore, we only try and use etherscan if the user has provided an API key. + let should_use_etherscan_traces = self.script_config.config.etherscan_api_key.is_some(); + if !should_use_etherscan_traces { + identifier.etherscan = None; + } + + for (_, trace) in &self.execution_result.traces { + decoder.identify(trace, &mut identifier); + } + + Ok(decoder) + } + + /// Collects the return values from the execution result. + fn get_returns(&self) -> Result> { + let mut returns = HashMap::new(); + let returned = &self.execution_result.returned; + let func = &self.execution_data.func; + + match func.abi_decode_output(returned, false) { + Ok(decoded) => { + for (index, (token, output)) in decoded.iter().zip(&func.outputs).enumerate() { + let internal_type = + output.internal_type.clone().unwrap_or(InternalType::Other { + contract: None, + ty: "unknown".to_string(), + }); + + let label = if !output.name.is_empty() { + output.name.to_string() + } else { + index.to_string() + }; + + returns.insert( + label, + NestedValue { + internal_type: internal_type.to_string(), + value: format_token_raw(token), + }, + ); + } + } + Err(_) => { + shell::println(format!("{returned:?}"))?; + } + } + + Ok(returns) + } +} + +impl PreSimulationState { + pub fn show_json(&self) -> Result<()> { + let result = &self.execution_result; + + let console_logs = decode_console_logs(&result.logs); + let output = JsonResult { + logs: console_logs, + gas_used: result.gas_used, + returns: self.execution_artifacts.returns.clone(), + }; + let j = serde_json::to_string(&output)?; + shell::println(j)?; + + if !self.execution_result.success { + return Err(eyre::eyre!( + "script failed: {}", + RevertDecoder::new().decode(&self.execution_result.returned[..], None) + )); + } + + Ok(()) + } + + pub async fn show_traces(&self) -> Result<()> { + let verbosity = self.script_config.evm_opts.verbosity; + let func = &self.execution_data.func; + let result = &self.execution_result; + let decoder = &self.execution_artifacts.decoder; + + if !result.success || verbosity > 3 { + if result.traces.is_empty() { + warn!(verbosity, "no traces"); + } + + shell::println("Traces:")?; + for (kind, trace) in &result.traces { + let should_include = match kind { + TraceKind::Setup => verbosity >= 5, + TraceKind::Execution => verbosity > 3, + _ => false, + } || !result.success; + + if should_include { + shell::println(render_trace_arena(trace, decoder).await?)?; + } + } + shell::println(String::new())?; + } + + if result.success { + shell::println(format!("{}", Paint::green("Script ran successfully.")))?; + } + + if self.script_config.evm_opts.fork_url.is_none() { + shell::println(format!("Gas used: {}", result.gas_used))?; + } + + if result.success && !result.returned.is_empty() { + shell::println("\n== Return ==")?; + match func.abi_decode_output(&result.returned, false) { + Ok(decoded) => { + for (index, (token, output)) in decoded.iter().zip(&func.outputs).enumerate() { + let internal_type = + output.internal_type.clone().unwrap_or(InternalType::Other { + contract: None, + ty: "unknown".to_string(), + }); + + let label = if !output.name.is_empty() { + output.name.to_string() + } else { + index.to_string() + }; + shell::println(format!( + "{}: {internal_type} {}", + label.trim_end(), + format_token(token) + ))?; + } + } + Err(_) => { + shell::println(format!("{:x?}", (&result.returned)))?; + } + } + } + + let console_logs = decode_console_logs(&result.logs); + if !console_logs.is_empty() { + shell::println("\n== Logs ==")?; + for log in console_logs { + shell::println(format!(" {log}"))?; + } + } + + if !result.success { + return Err(eyre::eyre!( + "script failed: {}", + RevertDecoder::new().decode(&result.returned[..], None) + )); + } + + Ok(()) + } + + pub fn run_debugger(&self) -> Result<()> { + let mut debugger = Debugger::builder() + .debug_arenas(self.execution_result.debug.as_deref().unwrap_or_default()) + .decoder(&self.execution_artifacts.decoder) + .sources(self.build_data.build_data.sources.clone()) + .breakpoints(self.execution_result.breakpoints.clone()) + .build(); + debugger.try_run()?; + Ok(()) + } +} diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/script/src/lib.rs similarity index 62% rename from crates/forge/bin/cmd/script/mod.rs rename to crates/script/src/lib.rs index 98c3e223db765..6d8fb87b83290 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/script/src/lib.rs @@ -1,67 +1,68 @@ -use super::build::BuildArgs; -use alloy_dyn_abi::FunctionExt; -use alloy_json_abi::{Function, InternalType, JsonAbi}; -use alloy_primitives::{Address, Bytes, Log, U256, U64}; -use alloy_rpc_types::request::TransactionRequest; +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + +#[macro_use] +extern crate tracing; + +use self::transaction::AdditionalContract; +use crate::runner::ScriptRunner; +use alloy_json_abi::{Function, JsonAbi}; +use alloy_primitives::{Address, Bytes, Log, U256}; +use broadcast::next_nonce; +use build::PreprocessedState; use clap::{Parser, ValueHint}; use dialoguer::Confirm; -use ethers_providers::{Http, Middleware}; +use ethers_signers::Signer; use eyre::{ContextCompat, Result, WrapErr}; -use forge::{ - backend::Backend, - debug::DebugArena, - decode::decode_console_logs, - opts::EvmOpts, - traces::{ - identifier::SignaturesIdentifier, render_trace_arena, CallTraceDecoder, - CallTraceDecoderBuilder, TraceKind, Traces, - }, -}; use forge_verify::RetryArgs; +use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ abi::{encode_function_args, get_func}, + compile::SkipBuildFilter, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, - fmt::{format_token, format_token_raw}, provider::ethers::RpcUrl, - shell, ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, -}; -use foundry_compilers::{ - artifacts::{ContractBytecodeSome, Libraries}, - ArtifactId, + shell, + types::ToAlloy, + CONTRACT_MAX_SIZE, SELECTOR_LEN, }; +use foundry_compilers::{artifacts::ContractBytecodeSome, ArtifactId}; use foundry_config::{ figment, figment::{ value::{Dict, Map}, Metadata, Profile, Provider, }, - Config, NamedChain, + Config, }; use foundry_evm::{ + backend::Backend, constants::DEFAULT_CREATE2_DEPLOYER, - decode::RevertDecoder, - inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, - traces::identifier::TraceIdentifiers, + debug::DebugArena, + executors::ExecutorBuilder, + inspectors::{ + cheatcodes::{BroadcastableTransactions, ScriptWallets}, + CheatsConfig, + }, + opts::EvmOpts, + traces::Traces, }; use foundry_wallets::MultiWalletOpts; -use futures::future; -use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{BTreeMap, HashMap}; use yansi::Paint; mod artifacts; mod broadcast; mod build; -mod cmd; -mod executor; -mod multi; +mod execute; +mod multi_sequence; mod providers; mod receipts; +mod resume; mod runner; mod sequence; -pub mod transaction; +mod simulate; +mod transaction; mod verify; // Loads project's figment and merges the build cli arguments into it @@ -174,8 +175,14 @@ pub struct ScriptArgs { )] pub with_gas_price: Option, + /// Skip building files whose names contain the given filter. + /// + /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. + #[arg(long, num_args(1..))] + pub skip: Option>, + #[command(flatten)] - pub opts: BuildArgs, + pub opts: CoreBuildArgs, #[command(flatten)] pub wallets: MultiWalletOpts, @@ -193,235 +200,106 @@ pub struct ScriptArgs { // === impl ScriptArgs === impl ScriptArgs { - fn decode_traces( - &self, - script_config: &ScriptConfig, - result: &mut ScriptResult, - known_contracts: &ContractsByArtifact, - ) -> Result { - let mut decoder = CallTraceDecoderBuilder::new() - .with_labels(result.labeled_addresses.clone()) - .with_verbosity(script_config.evm_opts.verbosity) - .with_known_contracts(known_contracts) - .with_signature_identifier(SignaturesIdentifier::new( - Config::foundry_cache_dir(), - script_config.config.offline, - )?) - .build(); - let mut identifier = TraceIdentifiers::new() - .with_local(known_contracts) - .with_etherscan(&script_config.config, script_config.evm_opts.get_remote_chain_id())?; - - // Decoding traces using etherscan is costly as we run into rate limits, - // causing scripts to run for a very long time unnecessarily. - // Therefore, we only try and use etherscan if the user has provided an API key. - let should_use_etherscan_traces = script_config.config.etherscan_api_key.is_some(); - if !should_use_etherscan_traces { - identifier.etherscan = None; - } + async fn preprocess(self) -> Result { + let script_wallets = + ScriptWallets::new(self.wallets.get_multi_wallet().await?, self.evm_opts.sender); - for (_, trace) in &mut result.traces { - decoder.identify(trace, &mut identifier); - } - Ok(decoder) - } + let (config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; - fn get_returns( - &self, - script_config: &ScriptConfig, - returned: &Bytes, - ) -> Result> { - let func = script_config.called_function.as_ref().expect("There should be a function."); - let mut returns = HashMap::new(); - - match func.abi_decode_output(returned, false) { - Ok(decoded) => { - for (index, (token, output)) in decoded.iter().zip(&func.outputs).enumerate() { - let internal_type = - output.internal_type.clone().unwrap_or(InternalType::Other { - contract: None, - ty: "unknown".to_string(), - }); - - let label = if !output.name.is_empty() { - output.name.to_string() - } else { - index.to_string() - }; - - returns.insert( - label, - NestedValue { - internal_type: internal_type.to_string(), - value: format_token_raw(token), - }, - ); - } - } - Err(_) => { - shell::println(format!("{returned:?}"))?; - } + if let Some(sender) = self.maybe_load_private_key()? { + evm_opts.sender = sender; } - Ok(returns) - } - - async fn show_traces( - &self, - script_config: &ScriptConfig, - decoder: &CallTraceDecoder, - result: &mut ScriptResult, - ) -> Result<()> { - let verbosity = script_config.evm_opts.verbosity; - let func = script_config.called_function.as_ref().expect("There should be a function."); + let script_config = ScriptConfig::new(config, evm_opts).await?; - if !result.success || verbosity > 3 { - if result.traces.is_empty() { - warn!(verbosity, "no traces"); - } - - shell::println("Traces:")?; - for (kind, trace) in &result.traces { - let should_include = match kind { - TraceKind::Setup => verbosity >= 5, - TraceKind::Execution => verbosity > 3, - _ => false, - } || !result.success; + Ok(PreprocessedState { args: self, script_config, script_wallets }) + } - if should_include { - shell::println(render_trace_arena(trace, decoder).await?)?; - } - } - shell::println(String::new())?; + /// Executes the script + pub async fn run_script(self) -> Result<()> { + trace!(target: "script", "executing script command"); + + // Drive state machine to point at which we have everything needed for simulation/resuming. + let pre_simulation = self + .preprocess() + .await? + .compile()? + .link()? + .prepare_execution() + .await? + .execute() + .await? + .prepare_simulation() + .await?; + + if pre_simulation.args.debug { + pre_simulation.run_debugger()?; } - if result.success { - shell::println(format!("{}", Paint::green("Script ran successfully.")))?; + if pre_simulation.args.json { + pre_simulation.show_json()?; + } else { + pre_simulation.show_traces().await?; } - if script_config.evm_opts.fork_url.is_none() { - shell::println(format!("Gas used: {}", result.gas_used))?; + // Ensure that we have transactions to simulate/broadcast, otherwise exit early to avoid + // hard error. + if pre_simulation.execution_result.transactions.as_ref().map_or(true, |txs| txs.is_empty()) + { + return Ok(()); } - if result.success && !result.returned.is_empty() { - shell::println("\n== Return ==")?; - match func.abi_decode_output(&result.returned, false) { - Ok(decoded) => { - for (index, (token, output)) in decoded.iter().zip(&func.outputs).enumerate() { - let internal_type = - output.internal_type.clone().unwrap_or(InternalType::Other { - contract: None, - ty: "unknown".to_string(), - }); - - let label = if !output.name.is_empty() { - output.name.to_string() - } else { - index.to_string() - }; - shell::println(format!( - "{}: {internal_type} {}", - label.trim_end(), - format_token(token) - ))?; - } - } - Err(_) => { - shell::println(format!("{:x?}", (&result.returned)))?; - } - } + // Check if there are any missing RPCs and exit early to avoid hard error. + if pre_simulation.execution_artifacts.rpc_data.missing_rpc { + shell::println("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; + return Ok(()); } - let console_logs = decode_console_logs(&result.logs); - if !console_logs.is_empty() { - shell::println("\n== Logs ==")?; - for log in console_logs { - shell::println(format!(" {log}"))?; - } - } + // Move from `PreSimulationState` to `BundledState` either by resuming or simulating + // transactions. + let bundled = if pre_simulation.args.resume || + (pre_simulation.args.verify && !pre_simulation.args.broadcast) + { + pre_simulation.resume().await? + } else { + pre_simulation.args.check_contract_sizes( + &pre_simulation.execution_result, + &pre_simulation.build_data.highlevel_known_contracts, + )?; - if !result.success { - return Err(eyre::eyre!( - "script failed: {}", - RevertDecoder::new().decode(&result.returned[..], None) - )); - } + pre_simulation.fill_metadata().await?.bundle().await? + }; - Ok(()) - } + // Exit early in case user didn't provide any broadcast/verify related flags. + if !bundled.args.broadcast && !bundled.args.resume && !bundled.args.verify { + shell::println("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; + return Ok(()); + } - fn show_json(&self, script_config: &ScriptConfig, result: &ScriptResult) -> Result<()> { - let returns = self.get_returns(script_config, &result.returned)?; + // Exit early if something is wrong with verification options. + if bundled.args.verify { + bundled.verify_preflight_check()?; + } - let console_logs = decode_console_logs(&result.logs); - let output = JsonResult { logs: console_logs, gas_used: result.gas_used, returns }; - let j = serde_json::to_string(&output)?; - shell::println(j)?; + // Wait for pending txes and broadcast others. + let broadcasted = bundled.wait_for_pending().await?.broadcast().await?; - if !result.success { - return Err(eyre::eyre!( - "script failed: {}", - RevertDecoder::new().decode(&result.returned[..], None) - )); + if broadcasted.args.verify { + broadcasted.verify().await?; } Ok(()) } - /// It finds the deployer from the running script and uses it to predeploy libraries. - /// - /// If there are multiple candidate addresses, it skips everything and lets `--sender` deploy - /// them instead. - fn maybe_new_sender( - &self, - evm_opts: &EvmOpts, - transactions: Option<&BroadcastableTransactions>, - predeploy_libraries: &[Bytes], - ) -> Result> { - let mut new_sender = None; - - if let Some(txs) = transactions { - // If the user passed a `--sender` don't check anything. - if !predeploy_libraries.is_empty() && self.evm_opts.sender.is_none() { - for tx in txs.iter() { - if tx.transaction.to.is_none() { - let sender = tx.transaction.from.expect("no sender"); - if let Some(ns) = new_sender { - if sender != ns { - shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; - return Ok(None); - } - } else if sender != evm_opts.sender { - new_sender = Some(sender); - } - } - } - } - } - Ok(new_sender) - } - - /// Helper for building the transactions for any libraries that need to be deployed ahead of - /// linking - fn create_deploy_transactions( - &self, - from: Address, - nonce: u64, - data: &[Bytes], - fork_url: &Option, - ) -> BroadcastableTransactions { - data.iter() - .enumerate() - .map(|(i, bytes)| BroadcastableTransaction { - rpc: fork_url.clone(), - transaction: TransactionRequest { - from: Some(from), - input: Some(bytes.clone()).into(), - nonce: Some(U64::from(nonce + i as u64)), - ..Default::default() - }, - }) - .collect() + /// In case the user has loaded *only* one private-key, we can assume that he's using it as the + /// `--sender` + fn maybe_load_private_key(&self) -> Result> { + let maybe_sender = self + .wallets + .private_keys()? + .filter(|pks| pks.len() == 1) + .map(|pks| pks.first().unwrap().address().to_alloy()); + Ok(maybe_sender) } /// Returns the Function and calldata based on the signature @@ -593,6 +471,26 @@ pub struct ScriptResult { pub breakpoints: Breakpoints, } +impl ScriptResult { + pub fn get_created_contracts(&self) -> Vec { + self.traces + .iter() + .flat_map(|(_, traces)| { + traces.nodes().iter().filter_map(|node| { + if node.trace.kind.is_any_create() { + return Some(AdditionalContract { + opcode: node.trace.kind, + address: node.trace.address, + init_code: node.trace.data.clone(), + }); + } + None + }) + }) + .collect() + } +} + #[derive(Serialize, Deserialize)] struct JsonResult { logs: Vec, @@ -606,91 +504,101 @@ pub struct NestedValue { pub value: String, } -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct ScriptConfig { pub config: Config, pub evm_opts: EvmOpts, pub sender_nonce: u64, /// Maps a rpc url to a backend pub backends: HashMap, - /// Script target contract - pub target_contract: Option, - /// Function called by the script - pub called_function: Option, - /// Unique list of rpc urls present - pub total_rpcs: HashSet, - /// If true, one of the transactions did not have a rpc - pub missing_rpc: bool, - /// Should return some debug information - pub debug: bool, } impl ScriptConfig { - fn collect_rpcs(&mut self, txs: &BroadcastableTransactions) { - self.missing_rpc = txs.iter().any(|tx| tx.rpc.is_none()); - - self.total_rpcs - .extend(txs.iter().filter_map(|tx| tx.rpc.as_ref().cloned()).collect::>()); - - if let Some(rpc) = &self.evm_opts.fork_url { - self.total_rpcs.insert(rpc.clone()); - } + pub async fn new(config: Config, evm_opts: EvmOpts) -> Result { + let sender_nonce = if let Some(fork_url) = evm_opts.fork_url.as_ref() { + next_nonce(evm_opts.sender, fork_url, None).await? + } else { + // dapptools compatibility + 1 + }; + Ok(Self { config, evm_opts, sender_nonce, backends: HashMap::new() }) } - fn has_multiple_rpcs(&self) -> bool { - self.total_rpcs.len() > 1 + pub async fn update_sender(&mut self, sender: Address) -> Result<()> { + self.sender_nonce = if let Some(fork_url) = self.evm_opts.fork_url.as_ref() { + next_nonce(sender, fork_url, None).await? + } else { + // dapptools compatibility + 1 + }; + self.evm_opts.sender = sender; + Ok(()) } - /// Certain features are disabled for multi chain deployments, and if tried, will return - /// error. [library support] - fn check_multi_chain_constraints(&self, libraries: &Libraries) -> Result<()> { - if self.has_multiple_rpcs() || (self.missing_rpc && !self.total_rpcs.is_empty()) { - shell::eprintln(format!( - "{}", - Paint::yellow( - "Multi chain deployment is still under development. Use with caution." - ) - ))?; - if !libraries.libs.is_empty() { - eyre::bail!( - "Multi chain deployment does not support library linking at the moment." - ) - } - } - Ok(()) + async fn get_runner(&mut self) -> Result { + self._get_runner(None, false).await } - /// Returns the script target contract - fn target_contract(&self) -> &ArtifactId { - self.target_contract.as_ref().expect("should exist after building") + async fn get_runner_with_cheatcodes( + &mut self, + script_wallets: ScriptWallets, + debug: bool, + ) -> Result { + self._get_runner(Some(script_wallets), debug).await } - /// Checks if the RPCs used point to chains that support EIP-3855. - /// If not, warns the user. - async fn check_shanghai_support(&self) -> Result<()> { - let chain_ids = self.total_rpcs.iter().map(|rpc| async move { - let provider = ethers_providers::Provider::::try_from(rpc).ok()?; - let id = provider.get_chainid().await.ok()?; - let id_u64: u64 = id.try_into().ok()?; - NamedChain::try_from(id_u64).ok() - }); + async fn _get_runner( + &mut self, + script_wallets: Option, + debug: bool, + ) -> Result { + trace!("preparing script runner"); + let env = self.evm_opts.evm_env().await?; + + let db = if let Some(fork_url) = self.evm_opts.fork_url.as_ref() { + match self.backends.get(fork_url) { + Some(db) => db.clone(), + None => { + let fork = self.evm_opts.get_fork(&self.config, env.clone()); + let backend = Backend::spawn(fork); + self.backends.insert(fork_url.clone(), backend.clone()); + backend + } + } + } else { + // It's only really `None`, when we don't pass any `--fork-url`. And if so, there is + // no need to cache it, since there won't be any onchain simulation that we'd need + // to cache the backend for. + Backend::spawn(None) + }; - let chains = future::join_all(chain_ids).await; - let iter = chains.iter().flatten().map(|c| (c.supports_shanghai(), c)); - if iter.clone().any(|(s, _)| !s) { - let msg = format!( - "\ -EIP-3855 is not supported in one or more of the RPCs used. -Unsupported Chain IDs: {}. -Contracts deployed with a Solidity version equal or higher than 0.8.20 might not work properly. -For more information, please see https://eips.ethereum.org/EIPS/eip-3855", - iter.filter(|(supported, _)| !supported) - .map(|(_, chain)| *chain as u64) - .format(", ") - ); - shell::println(Paint::yellow(msg))?; + // We need to enable tracing to decode contract names: local or external. + let mut builder = ExecutorBuilder::new() + .inspectors(|stack| stack.trace(true)) + .spec(self.config.evm_spec_id()) + .gas_limit(self.evm_opts.gas_limit()); + + if let Some(script_wallets) = script_wallets { + builder = builder.inspectors(|stack| { + stack + .debug(debug) + .cheatcodes( + CheatsConfig::new( + &self.config, + self.evm_opts.clone(), + Some(script_wallets), + ) + .into(), + ) + .enable_isolation(self.evm_opts.isolate) + }); } - Ok(()) + + Ok(ScriptRunner::new( + builder.build(env, db), + self.evm_opts.initial_balance, + self.evm_opts.sender, + )) } } @@ -698,7 +606,7 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855", mod tests { use super::*; use foundry_cli::utils::LoadConfig; - use foundry_config::UnresolvedEnvVarError; + use foundry_config::{NamedChain, UnresolvedEnvVarError}; use std::fs; use tempfile::tempdir; diff --git a/crates/script/src/multi_sequence.rs b/crates/script/src/multi_sequence.rs new file mode 100644 index 0000000000000..ea6dfd0d4c5fa --- /dev/null +++ b/crates/script/src/multi_sequence.rs @@ -0,0 +1,154 @@ +use super::sequence::{sig_to_file_name, ScriptSequence, SensitiveScriptSequence, DRY_RUN_DIR}; +use eyre::{ContextCompat, Result, WrapErr}; +use foundry_cli::utils::now; +use foundry_common::fs; +use foundry_compilers::ArtifactId; +use foundry_config::Config; +use serde::{Deserialize, Serialize}; +use std::{ + io::{BufWriter, Write}, + path::PathBuf, +}; + +/// Holds the sequences of multiple chain deployments. +#[derive(Clone, Default, Serialize, Deserialize)] +pub struct MultiChainSequence { + pub deployments: Vec, + #[serde(skip)] + pub path: PathBuf, + #[serde(skip)] + pub sensitive_path: PathBuf, + pub timestamp: u64, +} + +/// Sensitive values from script sequences. +#[derive(Clone, Default, Serialize, Deserialize)] +pub struct SensitiveMultiChainSequence { + pub deployments: Vec, +} + +impl SensitiveMultiChainSequence { + fn from_multi_sequence(sequence: MultiChainSequence) -> SensitiveMultiChainSequence { + SensitiveMultiChainSequence { + deployments: sequence.deployments.into_iter().map(|sequence| sequence.into()).collect(), + } + } +} + +impl MultiChainSequence { + pub fn new( + deployments: Vec, + sig: &str, + target: &ArtifactId, + config: &Config, + dry_run: bool, + ) -> Result { + let (path, sensitive_path) = MultiChainSequence::get_paths(config, sig, target, dry_run)?; + + Ok(MultiChainSequence { deployments, path, sensitive_path, timestamp: now().as_secs() }) + } + + /// Gets paths in the formats + /// ./broadcast/multi/contract_filename[-timestamp]/sig.json and + /// ./cache/multi/contract_filename[-timestamp]/sig.json + pub fn get_paths( + config: &Config, + sig: &str, + target: &ArtifactId, + dry_run: bool, + ) -> Result<(PathBuf, PathBuf)> { + let mut broadcast = config.broadcast.to_path_buf(); + let mut cache = config.cache_path.to_path_buf(); + let mut common = PathBuf::new(); + + common.push("multi"); + + if dry_run { + common.push(DRY_RUN_DIR); + } + + let target_fname = target + .source + .file_name() + .wrap_err_with(|| format!("No filename for {:?}", target.source))? + .to_string_lossy(); + + common.push(format!("{target_fname}-latest")); + + broadcast.push(common.clone()); + cache.push(common); + + fs::create_dir_all(&broadcast)?; + fs::create_dir_all(&cache)?; + + let filename = format!("{}.json", sig_to_file_name(sig)); + + broadcast.push(filename.clone()); + cache.push(filename); + + Ok((broadcast, cache)) + } + + /// Loads the sequences for the multi chain deployment. + pub fn load(config: &Config, sig: &str, target: &ArtifactId, dry_run: bool) -> Result { + let (path, sensitive_path) = MultiChainSequence::get_paths(config, sig, target, dry_run)?; + let mut sequence: MultiChainSequence = foundry_compilers::utils::read_json_file(&path) + .wrap_err("Multi-chain deployment not found.")?; + let sensitive_sequence: SensitiveMultiChainSequence = + foundry_compilers::utils::read_json_file(&sensitive_path) + .wrap_err("Multi-chain deployment sensitive details not found.")?; + + sequence.deployments.iter_mut().enumerate().for_each(|(i, sequence)| { + sequence.fill_sensitive(&sensitive_sequence.deployments[i]); + }); + + sequence.path = path; + sequence.sensitive_path = sensitive_path; + + Ok(sequence) + } + + /// Saves the transactions as file if it's a standalone deployment. + pub fn save(&mut self, silent: bool, save_ts: bool) -> Result<()> { + self.deployments.iter_mut().for_each(|sequence| sequence.sort_receipts()); + + self.timestamp = now().as_secs(); + + let sensitive_sequence = SensitiveMultiChainSequence::from_multi_sequence(self.clone()); + + // broadcast writes + //../Contract-latest/run.json + let mut writer = BufWriter::new(fs::create_file(&self.path)?); + serde_json::to_writer_pretty(&mut writer, &self)?; + writer.flush()?; + + if save_ts { + //../Contract-[timestamp]/run.json + let path = self.path.to_string_lossy(); + let file = PathBuf::from(&path.replace("-latest", &format!("-{}", self.timestamp))); + fs::create_dir_all(file.parent().unwrap())?; + fs::copy(&self.path, &file)?; + } + + // cache writes + //../Contract-latest/run.json + let mut writer = BufWriter::new(fs::create_file(&self.sensitive_path)?); + serde_json::to_writer_pretty(&mut writer, &sensitive_sequence)?; + writer.flush()?; + + if save_ts { + //../Contract-[timestamp]/run.json + let path = self.sensitive_path.to_string_lossy(); + let file = PathBuf::from(&path.replace("-latest", &format!("-{}", self.timestamp))); + fs::create_dir_all(file.parent().unwrap())?; + fs::copy(&self.sensitive_path, &file)?; + } + + if !silent { + println!("\nTransactions saved to: {}\n", self.path.display()); + println!("Sensitive details saved to: {}\n", self.sensitive_path.display()); + } + + Ok(()) + } +} diff --git a/crates/forge/bin/cmd/script/providers.rs b/crates/script/src/providers.rs similarity index 100% rename from crates/forge/bin/cmd/script/providers.rs rename to crates/script/src/providers.rs diff --git a/crates/forge/bin/cmd/script/receipts.rs b/crates/script/src/receipts.rs similarity index 100% rename from crates/forge/bin/cmd/script/receipts.rs rename to crates/script/src/receipts.rs diff --git a/crates/script/src/resume.rs b/crates/script/src/resume.rs new file mode 100644 index 0000000000000..4f704ed601fa5 --- /dev/null +++ b/crates/script/src/resume.rs @@ -0,0 +1,106 @@ +use crate::{broadcast::BundledState, simulate::PreSimulationState}; + +use super::{ + multi_sequence::MultiChainSequence, + sequence::{ScriptSequence, ScriptSequenceKind}, +}; +use ethers_providers::Middleware; +use eyre::Result; +use foundry_common::provider::ethers::try_get_http_provider; +use foundry_compilers::artifacts::Libraries; +use std::sync::Arc; + +impl PreSimulationState { + /// Tries loading the resumed state from the cache files, skipping simulation stage. + pub async fn resume(mut self) -> Result { + if self.execution_artifacts.rpc_data.missing_rpc { + eyre::bail!("Missing `--fork-url` field.") + } + + let chain = match self.execution_artifacts.rpc_data.total_rpcs.len() { + 2.. => None, + 1 => { + let fork_url = self.execution_artifacts.rpc_data.total_rpcs.iter().next().unwrap(); + + let provider = Arc::new(try_get_http_provider(fork_url)?); + Some(provider.get_chainid().await?.as_u64()) + } + 0 => eyre::bail!("No RPC URLs"), + }; + + let sequence = match self.try_load_sequence(chain, false) { + Ok(sequence) => sequence, + Err(_) => { + // If the script was simulated, but there was no attempt to broadcast yet, + // try to read the script sequence from the `dry-run/` folder + let mut sequence = self.try_load_sequence(chain, true)?; + + // If sequence was in /dry-run, Update its paths so it is not saved into /dry-run + // this time as we are about to broadcast it. + sequence.update_paths_to_broadcasted( + &self.script_config.config, + &self.args.sig, + &self.build_data.build_data.target, + )?; + + sequence.save(true, true)?; + sequence + } + }; + + match sequence { + ScriptSequenceKind::Single(ref seq) => { + // We might have predeployed libraries from the broadcasting, so we need to + // relink the contracts with them, since their mapping is not included in the solc + // cache files. + self.build_data = self + .build_data + .build_data + .link_with_libraries(Libraries::parse(&seq.libraries)?)?; + } + // Library linking is not supported for multi-chain sequences + ScriptSequenceKind::Multi(_) => {} + } + + let Self { + args, + script_config, + script_wallets, + build_data, + execution_data, + execution_result: _, + execution_artifacts, + } = self; + + Ok(BundledState { + args, + script_config, + script_wallets, + build_data, + execution_data, + execution_artifacts, + sequence, + }) + } + + fn try_load_sequence(&self, chain: Option, dry_run: bool) -> Result { + if let Some(chain) = chain { + let sequence = ScriptSequence::load( + &self.script_config.config, + &self.args.sig, + &self.build_data.build_data.target, + chain, + dry_run, + )?; + Ok(ScriptSequenceKind::Single(sequence)) + } else { + let sequence = MultiChainSequence::load( + &self.script_config.config, + &self.args.sig, + &self.build_data.build_data.target, + dry_run, + )?; + Ok(ScriptSequenceKind::Multi(sequence)) + } + } +} diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/script/src/runner.rs similarity index 98% rename from crates/forge/bin/cmd/script/runner.rs rename to crates/script/src/runner.rs index 96937bfdbc972..59f6402d368ad 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/script/src/runner.rs @@ -1,21 +1,15 @@ use super::ScriptResult; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; -use forge::{ +use foundry_config::Config; +use foundry_evm::{ constants::CALLER, executors::{CallResult, DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, revm::interpreter::{return_ok, InstructionResult}, traces::{TraceKind, Traces}, }; -use foundry_config::Config; use yansi::Paint; -/// Represents which simulation stage is the script execution at. -pub enum SimulationStage { - Local, - OnChain, -} - /// Drives script execution #[derive(Debug)] pub struct ScriptRunner { diff --git a/crates/forge/bin/cmd/script/sequence.rs b/crates/script/src/sequence.rs similarity index 72% rename from crates/forge/bin/cmd/script/sequence.rs rename to crates/script/src/sequence.rs index 0e97862bcf101..6a78d1ac4f584 100644 --- a/crates/forge/bin/cmd/script/sequence.rs +++ b/crates/script/src/sequence.rs @@ -1,22 +1,19 @@ -use super::NestedValue; -use crate::cmd::{ - init::get_commit_hash, - script::{ - transaction::{wrapper, AdditionalContract, TransactionWithMetadata}, - verify::VerifyBundle, - }, +use super::{multi_sequence::MultiChainSequence, NestedValue}; +use crate::{ + transaction::{wrapper, AdditionalContract, TransactionWithMetadata}, + verify::VerifyBundle, }; use alloy_primitives::{Address, TxHash}; use ethers_core::types::{transaction::eip2718::TypedTransaction, TransactionReceipt}; use eyre::{ContextCompat, Result, WrapErr}; use forge_verify::provider::VerificationProviderType; -use foundry_cli::utils::now; +use foundry_cli::utils::{now, Git}; use foundry_common::{ fs, shell, types::{ToAlloy, ToEthers}, SELECTOR_LEN, }; -use foundry_compilers::{artifacts::Libraries, ArtifactId}; +use foundry_compilers::ArtifactId; use foundry_config::Config; use serde::{Deserialize, Serialize}; use std::{ @@ -26,6 +23,67 @@ use std::{ }; use yansi::Paint; +/// Returns the commit hash of the project if it exists +pub fn get_commit_hash(root: &Path) -> Option { + Git::new(root).commit_hash(true, "HEAD").ok() +} + +pub enum ScriptSequenceKind { + Single(ScriptSequence), + Multi(MultiChainSequence), +} + +impl ScriptSequenceKind { + pub fn save(&mut self, silent: bool, save_ts: bool) -> Result<()> { + match self { + ScriptSequenceKind::Single(sequence) => sequence.save(silent, save_ts), + ScriptSequenceKind::Multi(sequence) => sequence.save(silent, save_ts), + } + } + + pub fn sequences(&self) -> &[ScriptSequence] { + match self { + ScriptSequenceKind::Single(sequence) => std::slice::from_ref(sequence), + ScriptSequenceKind::Multi(sequence) => &sequence.deployments, + } + } + + pub fn sequences_mut(&mut self) -> &mut [ScriptSequence] { + match self { + ScriptSequenceKind::Single(sequence) => std::slice::from_mut(sequence), + ScriptSequenceKind::Multi(sequence) => &mut sequence.deployments, + } + } + /// Updates underlying sequence paths to not be under /dry-run directory. + pub fn update_paths_to_broadcasted( + &mut self, + config: &Config, + sig: &str, + target: &ArtifactId, + ) -> Result<()> { + match self { + ScriptSequenceKind::Single(sequence) => { + sequence.paths = + Some(ScriptSequence::get_paths(config, sig, target, sequence.chain, false)?); + } + ScriptSequenceKind::Multi(sequence) => { + (sequence.path, sequence.sensitive_path) = + MultiChainSequence::get_paths(config, sig, target, false)?; + } + }; + + Ok(()) + } +} + +impl Drop for ScriptSequenceKind { + fn drop(&mut self) { + if let Err(err) = self.save(false, true) { + error!(?err, "could not save deployment sequence"); + } + } +} + pub const DRY_RUN_DIR: &str = "dry-run"; /// Helper that saves the transactions sequence and its state on which transactions have been @@ -38,21 +96,19 @@ pub struct ScriptSequence { pub libraries: Vec, pub pending: Vec, #[serde(skip)] - pub path: PathBuf, - #[serde(skip)] - pub sensitive_path: PathBuf, + /// Contains paths to the sequence files + /// None if sequence should not be saved to disk (e.g. part of a multi-chain sequence) + pub paths: Option<(PathBuf, PathBuf)>, pub returns: HashMap, pub timestamp: u64, pub chain: u64, - /// If `True`, the sequence belongs to a `MultiChainSequence` and won't save to disk as usual. - pub multi: bool, pub commit: Option, } /// Sensitive values from the transactions in a script sequence #[derive(Clone, Default, Serialize, Deserialize)] pub struct SensitiveTransactionMetadata { - pub rpc: Option, + pub rpc: String, } /// Sensitive info from the script sequence which is saved into the cache folder @@ -61,8 +117,8 @@ pub struct SensitiveScriptSequence { pub transactions: VecDeque, } -impl From<&mut ScriptSequence> for SensitiveScriptSequence { - fn from(sequence: &mut ScriptSequence) -> Self { +impl From for SensitiveScriptSequence { + fn from(sequence: ScriptSequence) -> Self { SensitiveScriptSequence { transactions: sequence .transactions @@ -74,59 +130,16 @@ impl From<&mut ScriptSequence> for SensitiveScriptSequence { } impl ScriptSequence { - pub fn new( - transactions: VecDeque, - returns: HashMap, - sig: &str, - target: &ArtifactId, - config: &Config, - broadcasted: bool, - is_multi: bool, - ) -> Result { - let chain = config.chain.unwrap_or_default().id(); - - let (path, sensitive_path) = ScriptSequence::get_paths( - &config.broadcast, - &config.cache_path, - sig, - target, - chain, - broadcasted && !is_multi, - )?; - - let commit = get_commit_hash(&config.__root.0); - - Ok(ScriptSequence { - transactions, - returns, - receipts: vec![], - pending: vec![], - path, - sensitive_path, - timestamp: now().as_secs(), - libraries: vec![], - chain, - multi: is_multi, - commit, - }) - } - /// Loads The sequence for the corresponding json file pub fn load( config: &Config, sig: &str, target: &ArtifactId, chain_id: u64, - broadcasted: bool, + dry_run: bool, ) -> Result { - let (path, sensitive_path) = ScriptSequence::get_paths( - &config.broadcast, - &config.cache_path, - sig, - target, - chain_id, - broadcasted, - )?; + let (path, sensitive_path) = + ScriptSequence::get_paths(config, sig, target, chain_id, dry_run)?; let mut script_sequence: Self = foundry_compilers::utils::read_json_file(&path) .wrap_err(format!("Deployment not found for chain `{chain_id}`."))?; @@ -138,41 +151,52 @@ impl ScriptSequence { script_sequence.fill_sensitive(&sensitive_script_sequence); - script_sequence.path = path; - script_sequence.sensitive_path = sensitive_path; + script_sequence.paths = Some((path, sensitive_path)); Ok(script_sequence) } /// Saves the transactions as file if it's a standalone deployment. - pub fn save(&mut self) -> Result<()> { - if self.multi || self.transactions.is_empty() { + /// `save_ts` should be set to true for checkpoint updates, which might happen many times and + /// could result in us saving many identical files. + pub fn save(&mut self, silent: bool, save_ts: bool) -> Result<()> { + self.sort_receipts(); + + if self.transactions.is_empty() { return Ok(()) } + let Some((path, sensitive_path)) = self.paths.clone() else { return Ok(()) }; + self.timestamp = now().as_secs(); let ts_name = format!("run-{}.json", self.timestamp); - let sensitive_script_sequence: SensitiveScriptSequence = self.into(); + let sensitive_script_sequence: SensitiveScriptSequence = self.clone().into(); // broadcast folder writes //../run-latest.json - let mut writer = BufWriter::new(fs::create_file(&self.path)?); + let mut writer = BufWriter::new(fs::create_file(&path)?); serde_json::to_writer_pretty(&mut writer, &self)?; writer.flush()?; - //../run-[timestamp].json - fs::copy(&self.path, self.path.with_file_name(&ts_name))?; + if save_ts { + //../run-[timestamp].json + fs::copy(&path, path.with_file_name(&ts_name))?; + } // cache folder writes //../run-latest.json - let mut writer = BufWriter::new(fs::create_file(&self.sensitive_path)?); + let mut writer = BufWriter::new(fs::create_file(&sensitive_path)?); serde_json::to_writer_pretty(&mut writer, &sensitive_script_sequence)?; writer.flush()?; - //../run-[timestamp].json - fs::copy(&self.sensitive_path, self.sensitive_path.with_file_name(&ts_name))?; + if save_ts { + //../run-[timestamp].json + fs::copy(&sensitive_path, sensitive_path.with_file_name(&ts_name))?; + } - shell::println(format!("\nTransactions saved to: {}\n", self.path.display()))?; - shell::println(format!("Sensitive values saved to: {}\n", self.sensitive_path.display()))?; + if !silent { + shell::println(format!("\nTransactions saved to: {}\n", path.display()))?; + shell::println(format!("Sensitive values saved to: {}\n", sensitive_path.display()))?; + } Ok(()) } @@ -197,36 +221,24 @@ impl ScriptSequence { self.pending.retain(|element| element != &tx_hash); } - pub fn add_libraries(&mut self, libraries: Libraries) { - self.libraries = libraries - .libs - .iter() - .flat_map(|(file, libs)| { - libs.iter() - .map(|(name, address)| format!("{}:{name}:{address}", file.to_string_lossy())) - }) - .collect(); - } - /// Gets paths in the formats /// ./broadcast/[contract_filename]/[chain_id]/[sig]-[timestamp].json and /// ./cache/[contract_filename]/[chain_id]/[sig]-[timestamp].json pub fn get_paths( - broadcast: &Path, - cache: &Path, + config: &Config, sig: &str, target: &ArtifactId, chain_id: u64, - broadcasted: bool, + dry_run: bool, ) -> Result<(PathBuf, PathBuf)> { - let mut broadcast = broadcast.to_path_buf(); - let mut cache = cache.to_path_buf(); + let mut broadcast = config.broadcast.to_path_buf(); + let mut cache = config.cache_path.to_path_buf(); let mut common = PathBuf::new(); let target_fname = target.source.file_name().wrap_err("No filename.")?; common.push(target_fname); common.push(chain_id.to_string()); - if !broadcasted { + if dry_run { common.push(DRY_RUN_DIR); } @@ -245,20 +257,6 @@ impl ScriptSequence { Ok((broadcast, cache)) } - /// Checks that there is an Etherscan key for the chain id of this sequence. - pub fn verify_preflight_check(&self, config: &Config, verify: &VerifyBundle) -> Result<()> { - if config.get_etherscan_api_key(Some(self.chain.into())).is_none() && - verify.verifier.verifier == VerificationProviderType::Etherscan - { - eyre::bail!( - "Etherscan API key wasn't found for chain id {}. On-chain execution aborted", - self.chain - ) - } - - Ok(()) - } - /// Given the broadcast log, it matches transactions with receipts, and tries to verify any /// created contract on etherscan. pub async fn verify_contracts( @@ -354,8 +352,8 @@ impl ScriptSequence { } /// Returns the first RPC URL of this sequence. - pub fn rpc_url(&self) -> Option<&str> { - self.transactions.front().and_then(|tx| tx.rpc.as_deref()) + pub fn rpc_url(&self) -> &str { + self.transactions.front().expect("empty sequence").rpc.as_str() } /// Returns the list of the transactions without the metadata. @@ -371,13 +369,6 @@ impl ScriptSequence { } } -impl Drop for ScriptSequence { - fn drop(&mut self) { - self.sort_receipts(); - self.save().expect("not able to save deployment sequence"); - } -} - /// Converts the `sig` argument into the corresponding file path. /// /// This accepts either the signature of the function or the raw calldata diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs new file mode 100644 index 0000000000000..99bd39ad95155 --- /dev/null +++ b/crates/script/src/simulate.rs @@ -0,0 +1,455 @@ +use super::{ + artifacts::ArtifactInfo, + multi_sequence::MultiChainSequence, + providers::ProvidersManager, + runner::ScriptRunner, + sequence::{ScriptSequence, ScriptSequenceKind}, + transaction::TransactionWithMetadata, +}; +use crate::{ + broadcast::{estimate_gas, BundledState}, + build::LinkedBuildData, + execute::{ExecutionArtifacts, ExecutionData}, + sequence::get_commit_hash, + ScriptArgs, ScriptConfig, ScriptResult, +}; +use alloy_primitives::{utils::format_units, Address, U256}; +use eyre::{Context, Result}; +use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; +use foundry_cli::utils::{has_different_gas_calc, now}; +use foundry_common::{ + get_contract_name, provider::ethers::RpcUrl, shell, types::ToAlloy, ContractsByArtifact, +}; +use foundry_evm::traces::render_trace_arena; +use futures::future::join_all; +use parking_lot::RwLock; +use std::{ + collections::{BTreeMap, HashMap, VecDeque}, + sync::Arc, +}; + +/// Same as [ExecutedState], but also contains [ExecutionArtifacts] which are obtained from +/// [ScriptResult]. +/// +/// Can be either converted directly to [BundledState] via [PreSimulationState::resume] or driven to +/// it through [FilledTransactionsState]. +pub struct PreSimulationState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, + pub build_data: LinkedBuildData, + pub execution_data: ExecutionData, + pub execution_result: ScriptResult, + pub execution_artifacts: ExecutionArtifacts, +} + +impl PreSimulationState { + /// If simulation is enabled, simulates transactions against fork and fills gas estimation and + /// metadata. Otherwise, metadata (e.g. additional contracts, created contract names) is + /// left empty. + /// + /// Both modes will panic if any of the transactions have None for the `rpc` field. + pub async fn fill_metadata(self) -> Result { + let transactions = if let Some(txs) = self.execution_result.transactions.as_ref() { + if self.args.skip_simulation { + shell::println("\nSKIPPING ON CHAIN SIMULATION.")?; + self.no_simulation(txs.clone())? + } else { + self.onchain_simulation(txs.clone()).await? + } + } else { + VecDeque::new() + }; + + Ok(FilledTransactionsState { + args: self.args, + script_config: self.script_config, + script_wallets: self.script_wallets, + build_data: self.build_data, + execution_data: self.execution_data, + execution_artifacts: self.execution_artifacts, + transactions, + }) + } + + /// Builds separate runners and environments for each RPC used in script and executes all + /// transactions in those environments. + /// + /// Collects gas usage and metadata for each transaction. + pub async fn onchain_simulation( + &self, + transactions: BroadcastableTransactions, + ) -> Result> { + trace!(target: "script", "executing onchain simulation"); + + let runners = Arc::new( + self.build_runners() + .await? + .into_iter() + .map(|(rpc, runner)| (rpc, Arc::new(RwLock::new(runner)))) + .collect::>(), + ); + + let contracts = self.build_data.get_flattened_contracts(false); + let address_to_abi: BTreeMap = + self.build_address_to_abi_map(&contracts); + + let mut final_txs = VecDeque::new(); + + // Executes all transactions from the different forks concurrently. + let futs = transactions + .into_iter() + .map(|transaction| async { + let rpc = transaction.rpc.expect("missing broadcastable tx rpc url"); + let mut runner = runners.get(&rpc).expect("invalid rpc url").write(); + + let mut tx = transaction.transaction; + let result = runner + .simulate( + tx.from + .expect("transaction doesn't have a `from` address at execution time"), + tx.to, + tx.input.clone().into_input(), + tx.value, + ) + .wrap_err("Internal EVM error during simulation")?; + + if !result.success { + return Ok((None, result.traces)); + } + + let created_contracts = result.get_created_contracts(); + + // Simulate mining the transaction if the user passes `--slow`. + if self.args.slow { + runner.executor.env.block.number += U256::from(1); + } + + let is_fixed_gas_limit = tx.gas.is_some(); + match tx.gas { + // If tx.gas is already set that means it was specified in script + Some(gas) => { + println!("Gas limit was set in script to {gas}"); + } + // We inflate the gas used by the user specified percentage + None => { + let gas = + U256::from(result.gas_used * self.args.gas_estimate_multiplier / 100); + tx.gas = Some(gas); + } + } + let tx = TransactionWithMetadata::new( + tx, + rpc, + &result, + &address_to_abi, + &self.execution_artifacts.decoder, + created_contracts, + is_fixed_gas_limit, + )?; + + eyre::Ok((Some(tx), result.traces)) + }) + .collect::>(); + + if self.script_config.evm_opts.verbosity > 3 { + println!("=========================="); + println!("Simulated On-chain Traces:\n"); + } + + let mut abort = false; + for res in join_all(futs).await { + let (tx, traces) = res?; + + // Transaction will be `None`, if execution didn't pass. + if tx.is_none() || self.script_config.evm_opts.verbosity > 3 { + for (_, trace) in &traces { + println!( + "{}", + render_trace_arena(trace, &self.execution_artifacts.decoder).await? + ); + } + } + + if let Some(tx) = tx { + final_txs.push_back(tx); + } else { + abort = true; + } + } + + if abort { + eyre::bail!("Simulated execution failed.") + } + + Ok(final_txs) + } + + /// Build mapping from contract address to its ABI, code and contract name. + fn build_address_to_abi_map<'a>( + &self, + contracts: &'a ContractsByArtifact, + ) -> BTreeMap> { + self.execution_artifacts + .decoder + .contracts + .iter() + .filter_map(move |(addr, contract_id)| { + let contract_name = get_contract_name(contract_id); + if let Ok(Some((_, (abi, code)))) = + contracts.find_by_name_or_identifier(contract_name) + { + let info = ArtifactInfo { + contract_name: contract_name.to_string(), + contract_id: contract_id.to_string(), + abi, + code, + }; + return Some((*addr, info)); + } + None + }) + .collect() + } + + /// Build [ScriptRunner] forking given RPC for each RPC used in the script. + async fn build_runners(&self) -> Result> { + let rpcs = self.execution_artifacts.rpc_data.total_rpcs.clone(); + if !shell::verbosity().is_silent() { + let n = rpcs.len(); + let s = if n != 1 { "s" } else { "" }; + println!("\n## Setting up {n} EVM{s}."); + } + + let futs = rpcs + .into_iter() + .map(|rpc| async move { + let mut script_config = self.script_config.clone(); + script_config.evm_opts.fork_url = Some(rpc.clone()); + let runner = script_config.get_runner().await?; + Ok((rpc.clone(), runner)) + }) + .collect::>(); + + join_all(futs).await.into_iter().collect() + } + + /// If simulation is disabled, converts transactions into [TransactionWithMetadata] type + /// skipping metadata filling. + fn no_simulation( + &self, + transactions: BroadcastableTransactions, + ) -> Result> { + Ok(transactions + .into_iter() + .map(|btx| { + let mut tx = TransactionWithMetadata::from_tx_request(btx.transaction); + tx.rpc = btx.rpc.expect("missing broadcastable tx rpc url"); + tx + }) + .collect()) + } +} + +/// At this point we have converted transactions collected during script execution to +/// [TransactionWithMetadata] objects which contain additional metadata needed for broadcasting and +/// verification. +pub struct FilledTransactionsState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub script_wallets: ScriptWallets, + pub build_data: LinkedBuildData, + pub execution_data: ExecutionData, + pub execution_artifacts: ExecutionArtifacts, + pub transactions: VecDeque, +} + +impl FilledTransactionsState { + /// Bundles all transactions of the [`TransactionWithMetadata`] type in a list of + /// [`ScriptSequence`]. List length will be higher than 1, if we're dealing with a multi + /// chain deployment. + /// + /// Each transaction will be added with the correct transaction type and gas estimation. + pub async fn bundle(self) -> Result { + let is_multi_deployment = self.execution_artifacts.rpc_data.total_rpcs.len() > 1; + + if is_multi_deployment && !self.build_data.libraries.is_empty() { + eyre::bail!("Multi-chain deployment is not supported with libraries."); + } + + let mut total_gas_per_rpc: HashMap = HashMap::new(); + + // Batches sequence of transactions from different rpcs. + let mut new_sequence = VecDeque::new(); + let mut manager = ProvidersManager::default(); + let mut sequences = vec![]; + + // Peeking is used to check if the next rpc url is different. If so, it creates a + // [`ScriptSequence`] from all the collected transactions up to this point. + let mut txes_iter = self.transactions.clone().into_iter().peekable(); + + while let Some(mut tx) = txes_iter.next() { + let tx_rpc = tx.rpc.clone(); + let provider_info = manager.get_or_init_provider(&tx.rpc, self.args.legacy).await?; + + // Handles chain specific requirements. + tx.change_type(provider_info.is_legacy); + tx.transaction.set_chain_id(provider_info.chain); + + if !self.args.skip_simulation { + let typed_tx = tx.typed_tx_mut(); + + if has_different_gas_calc(provider_info.chain) { + trace!("estimating with different gas calculation"); + let gas = *typed_tx.gas().expect("gas is set by simulation."); + + // We are trying to show the user an estimation of the total gas usage. + // + // However, some transactions might depend on previous ones. For + // example, tx1 might deploy a contract that tx2 uses. That + // will result in the following `estimate_gas` call to fail, + // since tx1 hasn't been broadcasted yet. + // + // Not exiting here will not be a problem when actually broadcasting, because + // for chains where `has_different_gas_calc` returns true, + // we await each transaction before broadcasting the next + // one. + if let Err(err) = estimate_gas( + typed_tx, + &provider_info.provider, + self.args.gas_estimate_multiplier, + ) + .await + { + trace!("gas estimation failed: {err}"); + + // Restore gas value, since `estimate_gas` will remove it. + typed_tx.set_gas(gas); + } + } + + let total_gas = total_gas_per_rpc.entry(tx_rpc.clone()).or_insert(U256::ZERO); + *total_gas += (*typed_tx.gas().expect("gas is set")).to_alloy(); + } + + new_sequence.push_back(tx); + // We only create a [`ScriptSequence`] object when we collect all the rpc related + // transactions. + if let Some(next_tx) = txes_iter.peek() { + if next_tx.rpc == tx_rpc { + continue; + } + } + + let sequence = + self.create_sequence(is_multi_deployment, provider_info.chain, new_sequence)?; + + sequences.push(sequence); + + new_sequence = VecDeque::new(); + } + + if !self.args.skip_simulation { + // Present gas information on a per RPC basis. + for (rpc, total_gas) in total_gas_per_rpc { + let provider_info = manager.get(&rpc).expect("provider is set."); + + // We don't store it in the transactions, since we want the most updated value. + // Right before broadcasting. + let per_gas = if let Some(gas_price) = self.args.with_gas_price { + gas_price + } else { + provider_info.gas_price()? + }; + + shell::println("\n==========================")?; + shell::println(format!("\nChain {}", provider_info.chain))?; + + shell::println(format!( + "\nEstimated gas price: {} gwei", + format_units(per_gas, 9) + .unwrap_or_else(|_| "[Could not calculate]".to_string()) + .trim_end_matches('0') + .trim_end_matches('.') + ))?; + shell::println(format!("\nEstimated total gas used for script: {total_gas}"))?; + shell::println(format!( + "\nEstimated amount required: {} ETH", + format_units(total_gas.saturating_mul(per_gas), 18) + .unwrap_or_else(|_| "[Could not calculate]".to_string()) + .trim_end_matches('0') + ))?; + shell::println("\n==========================")?; + } + } + + let sequence = if sequences.len() == 1 { + ScriptSequenceKind::Single(sequences.pop().expect("empty sequences")) + } else { + ScriptSequenceKind::Multi(MultiChainSequence::new( + sequences, + &self.args.sig, + &self.build_data.build_data.target, + &self.script_config.config, + !self.args.broadcast, + )?) + }; + + Ok(BundledState { + args: self.args, + script_config: self.script_config, + script_wallets: self.script_wallets, + build_data: self.build_data, + execution_data: self.execution_data, + execution_artifacts: self.execution_artifacts, + sequence, + }) + } + + /// Creates a [ScriptSequence] object from the given transactions. + fn create_sequence( + &self, + multi: bool, + chain: u64, + transactions: VecDeque, + ) -> Result { + // Paths are set to None for multi-chain sequences parts, because they don't need to be + // saved to a separate file. + let paths = if multi { + None + } else { + Some(ScriptSequence::get_paths( + &self.script_config.config, + &self.args.sig, + &self.build_data.build_data.target, + chain, + !self.args.broadcast, + )?) + }; + + let commit = get_commit_hash(&self.script_config.config.__root.0); + + let libraries = self + .build_data + .libraries + .libs + .iter() + .flat_map(|(file, libs)| { + libs.iter() + .map(|(name, address)| format!("{}:{name}:{address}", file.to_string_lossy())) + }) + .collect(); + + Ok(ScriptSequence { + transactions, + returns: self.execution_artifacts.returns.clone(), + receipts: vec![], + pending: vec![], + paths, + timestamp: now().as_secs(), + libraries, + chain, + commit, + }) + } +} diff --git a/crates/forge/bin/cmd/script/transaction.rs b/crates/script/src/transaction.rs similarity index 98% rename from crates/forge/bin/cmd/script/transaction.rs rename to crates/script/src/transaction.rs index fec73b22f001e..3f92e2f31be2d 100644 --- a/crates/forge/bin/cmd/script/transaction.rs +++ b/crates/script/src/transaction.rs @@ -44,7 +44,7 @@ pub struct TransactionWithMetadata { #[serde(default = "default_vec_of_strings")] pub arguments: Option>, #[serde(skip)] - pub rpc: Option, + pub rpc: RpcUrl, pub transaction: TypedTransaction, pub additional_contracts: Vec, pub is_fixed_gas_limit: bool, @@ -80,7 +80,7 @@ impl TransactionWithMetadata { pub fn new( transaction: TransactionRequest, - rpc: Option, + rpc: RpcUrl, result: &ScriptResult, local_contracts: &BTreeMap, decoder: &CallTraceDecoder, @@ -195,6 +195,7 @@ impl TransactionWithMetadata { decoder: &CallTraceDecoder, ) -> Result<()> { self.opcode = CallKind::Call; + self.contract_address = Some(target); let Some(data) = self.transaction.data() else { return Ok(()) }; if data.len() < SELECTOR_LEN { @@ -211,10 +212,6 @@ impl TransactionWithMetadata { decoder.functions.get(selector).and_then(|v| v.first()) }; if let Some(function) = function { - if self.contract_address.is_none() { - self.contract_name = decoder.contracts.get(&target).cloned(); - } - self.function = Some(function.signature()); let values = function.abi_decode_input(data, false).map_err(|e| { @@ -229,15 +226,9 @@ impl TransactionWithMetadata { self.arguments = Some(values.iter().map(format_token_raw).collect()); } - self.contract_address = Some(target); - Ok(()) } - pub fn set_tx(&mut self, tx: TypedTransaction) { - self.transaction = tx; - } - pub fn change_type(&mut self, is_legacy: bool) { self.transaction = if is_legacy { TypedTransaction::Legacy(self.transaction.clone().into()) diff --git a/crates/forge/bin/cmd/script/verify.rs b/crates/script/src/verify.rs similarity index 80% rename from crates/forge/bin/cmd/script/verify.rs rename to crates/script/src/verify.rs index 43293268d5c1a..be5825dfc7e88 100644 --- a/crates/forge/bin/cmd/script/verify.rs +++ b/crates/script/src/verify.rs @@ -1,4 +1,12 @@ +use crate::{ + build::LinkedBuildData, + execute::{ExecutionArtifacts, ExecutionData}, + sequence::ScriptSequenceKind, + ScriptArgs, ScriptConfig, +}; + use alloy_primitives::Address; +use eyre::Result; use forge_verify::{RetryArgs, VerifierArgs, VerifyArgs}; use foundry_cli::opts::{EtherscanOpts, ProjectPathsArgs}; use foundry_common::ContractsByArtifact; @@ -6,6 +14,38 @@ use foundry_compilers::{info::ContractInfo, Project}; use foundry_config::{Chain, Config}; use semver::Version; +/// State after we have broadcasted the script. +/// It is assumed that at this point [BroadcastedState::sequence] contains receipts for all +/// broadcasted transactions. +pub struct BroadcastedState { + pub args: ScriptArgs, + pub script_config: ScriptConfig, + pub build_data: LinkedBuildData, + pub execution_data: ExecutionData, + pub execution_artifacts: ExecutionArtifacts, + pub sequence: ScriptSequenceKind, +} + +impl BroadcastedState { + pub async fn verify(self) -> Result<()> { + let Self { args, script_config, build_data, mut sequence, .. } = self; + + let verify = VerifyBundle::new( + &script_config.config.project()?, + &script_config.config, + build_data.get_flattened_contracts(false), + args.retry, + args.verifier, + ); + + for sequence in sequence.sequences_mut() { + sequence.verify_contracts(&script_config.config, verify.clone()).await?; + } + + Ok(()) + } +} + /// Data struct to help `ScriptSequence` verify contracts on `etherscan`. #[derive(Clone)] pub struct VerifyBundle { From 345858f98af6ab8e4fdb4b92f40d4d67b94d5478 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:36:14 -0500 Subject: [PATCH 0725/1963] feat(anvil): configure slots_in_an_epoch (#7335) * feat(anvil): configure slots_in_an_epoch * Option nit Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * nit: use primitive u64 * nit: semicolon * nits Co-authored-by: Matthias Seitz * nit: anvil config --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Matthias Seitz --- crates/anvil/src/cmd.rs | 5 +++++ crates/anvil/src/config.rs | 10 ++++++++++ crates/anvil/src/eth/backend/mem/mod.rs | 21 ++++++++++----------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index fca14e75dca7f..c16328ee246fb 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -86,6 +86,10 @@ pub struct NodeArgs { #[arg(short, long, visible_alias = "blockTime", value_name = "SECONDS")] pub block_time: Option, + /// Slots in an epoch + #[arg(long, value_name = "SLOTS_IN_AN_EPOCH", default_value_t = 32)] + pub slots_in_an_epoch: u64, + /// Writes output of `anvil` as json to user-specified file. #[arg(long, value_name = "OUT_FILE")] pub config_out: Option, @@ -230,6 +234,7 @@ impl NodeArgs { .with_transaction_block_keeper(self.transaction_block_keeper) .with_optimism(self.evm_opts.optimism) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) + .with_slots_in_an_epoch(self.slots_in_an_epoch) } fn account_generator(&self) -> AccountGenerator { diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 32db9e25f0312..7c1098ec70aff 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -170,6 +170,8 @@ pub struct NodeConfig { pub disable_default_create2_deployer: bool, /// Enable Optimism deposit transaction pub enable_optimism: bool, + /// Slots in an epoch + pub slots_in_an_epoch: u64, } impl NodeConfig { @@ -404,6 +406,7 @@ impl Default for NodeConfig { transaction_block_keeper: None, disable_default_create2_deployer: false, enable_optimism: false, + slots_in_an_epoch: 32, } } } @@ -596,6 +599,13 @@ impl NodeConfig { self } + /// Sets the slots in an epoch + #[must_use] + pub fn with_slots_in_an_epoch(mut self, slots_in_an_epoch: u64) -> Self { + self.slots_in_an_epoch = slots_in_an_epoch; + self + } + /// Sets the port to use #[must_use] pub fn with_port(mut self, port: u16) -> Self { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 202cc880e9292..64e6942550e67 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -168,6 +168,8 @@ pub struct Backend { /// max number of blocks with transactions in memory transaction_block_keeper: Option, node_config: Arc>, + /// Slots in an epoch + slots_in_an_epoch: u64, } impl Backend { @@ -214,6 +216,8 @@ impl Backend { Default::default() }; + let slots_in_an_epoch = node_config.read().await.slots_in_an_epoch; + let backend = Self { db, blockchain, @@ -230,6 +234,7 @@ impl Backend { prune_state_history_config, transaction_block_keeper, node_config, + slots_in_an_epoch, }; if let Some(interval_block_time) = automine_block_time { @@ -1478,7 +1483,7 @@ impl Backend { BlockId::Hash(hash) => hash.block_hash, BlockId::Number(number) => { let storage = self.blockchain.storage.read(); - let slots_in_an_epoch = U64::from(32u64); + let slots_in_an_epoch = U64::from(self.slots_in_an_epoch); match number { BlockNumber::Latest => storage.best_hash, BlockNumber::Earliest => storage.genesis_hash, @@ -1599,7 +1604,6 @@ impl Backend { block_id: Option, ) -> Result { let current = self.best_number(); - let slots_in_an_epoch = 32u64; let requested = match block_id.map(Into::into).unwrap_or(BlockId::Number(BlockNumber::Latest)) { BlockId::Hash(hash) => self @@ -1614,12 +1618,8 @@ impl Backend { BlockNumber::Latest | BlockNumber::Pending => self.best_number(), BlockNumber::Earliest => U64::ZERO.to::(), BlockNumber::Number(num) => num, - BlockNumber::Safe => { - U64::from(current).saturating_sub(U64::from(slots_in_an_epoch)).to::() - } - BlockNumber::Finalized => U64::from(current) - .saturating_sub(U64::from(slots_in_an_epoch) * U64::from(2)) - .to::(), + BlockNumber::Safe => current.saturating_sub(self.slots_in_an_epoch), + BlockNumber::Finalized => current.saturating_sub(self.slots_in_an_epoch * 2), }, }; @@ -1632,13 +1632,12 @@ impl Backend { pub fn convert_block_number(&self, block: Option) -> u64 { let current = self.best_number(); - let slots_in_an_epoch = 32u64; match block.unwrap_or(BlockNumber::Latest) { BlockNumber::Latest | BlockNumber::Pending => current, BlockNumber::Earliest => 0, BlockNumber::Number(num) => num, - BlockNumber::Safe => current.saturating_sub(slots_in_an_epoch), - BlockNumber::Finalized => current.saturating_sub(slots_in_an_epoch * 2), + BlockNumber::Safe => current.saturating_sub(self.slots_in_an_epoch), + BlockNumber::Finalized => current.saturating_sub(self.slots_in_an_epoch * 2), } } From 12cbf67711d312b77a3b895df67d3c733cc6a3e2 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:44:26 +0100 Subject: [PATCH 0726/1963] evaluate .env in Anvil, like we do in other binaries (#7344) --- Cargo.lock | 1 + crates/anvil/Cargo.toml | 13 +++++++++++-- crates/anvil/src/anvil.rs | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8bea54c235aa7..67bca0286b523 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -545,6 +545,7 @@ dependencies = [ "eyre", "fdlimit", "flate2", + "foundry-cli", "foundry-common", "foundry-config", "foundry-evm", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index ff59985f0441b..36607d12608f9 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,13 +16,18 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # foundry internal anvil-core = { path = "core", features = ["serde", "impersonated-tx"] } anvil-rpc = { path = "rpc" } anvil-server = { path = "server" } +foundry-cli.workspace = true foundry-common.workspace = true foundry-config.workspace = true foundry-evm.workspace = true @@ -76,7 +81,11 @@ rand = "0.8" eyre.workspace = true # cli -clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } +clap = { version = "4", features = [ + "derive", + "env", + "wrap_help", +], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index cc60fe722934f..5ac169c3af96f 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -1,6 +1,8 @@ //! The `anvil` cli + use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; +use foundry_cli::utils; /// A fast local Ethereum development node. #[derive(Parser)] @@ -29,6 +31,8 @@ pub enum AnvilSubcommand { #[tokio::main] async fn main() -> Result<(), Box> { + utils::load_dotenv(); + let mut app = Anvil::parse(); app.node.evm_opts.resolve_rpc_alias(); From 7bd5b35885c01a6e2e712b23fdd066100c97d54e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 8 Mar 2024 15:14:30 +0100 Subject: [PATCH 0727/1963] fix: remove constructor when generating interface (#7341) --- crates/cast/src/lib.rs | 12 +- crates/cast/tests/cli/main.rs | 34 ++++++ crates/cast/tests/fixtures/interface.json | 141 ++++++++++++++++++++++ 3 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 crates/cast/tests/fixtures/interface.json diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index da7453f5204eb..8a0e34c946b90 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1609,7 +1609,10 @@ impl SimpleCast { /// Generates an interface in solidity from either a local file ABI or a verified contract on /// Etherscan. It returns a vector of [`InterfaceSource`] structs that contain the source of the /// interface and their name. - /// ```ignore + /// + /// Note: This removes the constructor from the ABI before generating the interface. + /// + /// ```no_run /// use cast::{AbiPath, SimpleCast as Cast}; /// # async fn foo() -> eyre::Result<()> { /// let path = @@ -1620,7 +1623,7 @@ impl SimpleCast { /// # } /// ``` pub async fn generate_interface(address_or_path: AbiPath) -> Result> { - let (contract_abis, contract_names) = match address_or_path { + let (mut contract_abis, contract_names) = match address_or_path { AbiPath::Local { path, name } => { let file = std::fs::read_to_string(&path).wrap_err("unable to read abi file")?; let obj: ContractObject = serde_json::from_str(&file)?; @@ -1643,9 +1646,12 @@ impl SimpleCast { } }; contract_abis - .iter() + .iter_mut() .zip(contract_names) .map(|(contract_abi, name)| { + // need to filter out the constructor + contract_abi.constructor.take(); + let source = foundry_cli::utils::abi_to_solidity(contract_abi, &name)?; Ok(InterfaceSource { name, diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 41cef5e616755..7df9d4b91f6a8 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -757,3 +757,37 @@ casttest!(balance, |_prj, cmd| { assert_ne!(usdt_result, "0x0000000000000000000000000000000000000000000000000000000000000000"); assert_eq!(alias_result, usdt_result); }); + +// tests that `cast interface` excludes the constructor +// +casttest!(interface_no_constructor, |prj, cmd| { + let interface = include_str!("../fixtures/interface.json"); + + let path = prj.root().join("interface.json"); + fs::write(&path, interface).unwrap(); + // Call `cast find-block` + cmd.args(["interface"]).arg(&path); + let output = cmd.stdout_lossy(); + + let s = r#"// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.4; + +interface Interface { + type SpendAssetsHandleType is uint8; + + function getIntegrationManager() external view returns (address integrationManager_); + function lend(address _vaultProxy, bytes memory, bytes memory _assetData) external; + function parseAssetsForAction(address, bytes4 _selector, bytes memory _actionData) + external + view + returns ( + SpendAssetsHandleType spendAssetsHandleType_, + address[] memory spendAssets_, + uint256[] memory spendAssetAmounts_, + address[] memory incomingAssets_, + uint256[] memory minIncomingAssetAmounts_ + ); + function redeem(address _vaultProxy, bytes memory, bytes memory _assetData) external; +}"#; + assert_eq!(output.trim(), s); +}); diff --git a/crates/cast/tests/fixtures/interface.json b/crates/cast/tests/fixtures/interface.json new file mode 100644 index 0000000000000..73e561886a968 --- /dev/null +++ b/crates/cast/tests/fixtures/interface.json @@ -0,0 +1,141 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "_integrationManager", + "type": "address", + "internalType": "address" + }, + { + "name": "_addressListRegistry", + "type": "address", + "internalType": "address" + }, + { + "name": "_aTokenListId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_pool", + "type": "address", + "internalType": "address" + }, + { + "name": "_referralCode", + "type": "uint16", + "internalType": "uint16" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getIntegrationManager", + "inputs": [], + "outputs": [ + { + "name": "integrationManager_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "lend", + "inputs": [ + { + "name": "_vaultProxy", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "_assetData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "parseAssetsForAction", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "_selector", + "type": "bytes4", + "internalType": "bytes4" + }, + { + "name": "_actionData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "spendAssetsHandleType_", + "type": "uint8", + "internalType": "enum IIntegrationManager.SpendAssetsHandleType" + }, + { + "name": "spendAssets_", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "spendAssetAmounts_", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "incomingAssets_", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "minIncomingAssetAmounts_", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "redeem", + "inputs": [ + { + "name": "_vaultProxy", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "_assetData", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } +] \ No newline at end of file From 9fde758a97a828efdcc4937ecfea4369b9850be8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 8 Mar 2024 15:16:13 +0100 Subject: [PATCH 0728/1963] chore(deps): bump revm to 6.0 (#7125) * migrate revm * inspector * more inspectors * port more things * port more * some simplifications * chore: add error variant back * use original bytecode * bump deps * feat: migrate evm backend * chore: port more stuf * fix compile * chore: make compile again * fix * more fixes * fix anvil * fix cast * chore(clippy): make clippy happy * fix: make it fucking compile * nits, clippies * fix: try early return None from inspector * chore: finish data -> context renaming * chore: really finish rename * chore: rename context to ecx Shorter * feat: simpler methods * fix anvil test * fix env bug * chore: rename functions * chore: migrate disallow mem write * Update Cargo.toml Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * fix: update exc env after transact * no clone * no clone --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 62 +-- Cargo.toml | 49 +- crates/anvil/src/config.rs | 25 +- crates/anvil/src/eth/api.rs | 6 +- crates/anvil/src/eth/backend/executor.rs | 81 ++-- crates/anvil/src/eth/backend/mem/inspector.rs | 105 ++--- crates/anvil/src/eth/backend/mem/mod.rs | 147 +++--- crates/anvil/src/eth/backend/validate.rs | 6 +- crates/anvil/src/eth/error.rs | 6 +- crates/anvil/src/eth/util.rs | 33 +- crates/cast/bin/cmd/run.rs | 4 + crates/cheatcodes/src/error.rs | 8 + crates/cheatcodes/src/evm.rs | 92 ++-- crates/cheatcodes/src/evm/fork.rs | 76 +-- crates/cheatcodes/src/evm/mock.rs | 7 +- crates/cheatcodes/src/evm/prank.rs | 4 +- crates/cheatcodes/src/inspector.rs | 436 ++++++++++-------- crates/cheatcodes/src/lib.rs | 25 +- crates/cheatcodes/src/script.rs | 10 +- crates/cheatcodes/src/test.rs | 2 +- crates/cheatcodes/src/test/expect.rs | 48 +- crates/chisel/src/dispatcher.rs | 2 +- crates/chisel/src/executor.rs | 2 +- crates/chisel/src/runner.rs | 4 +- crates/evm/core/Cargo.toml | 1 + crates/evm/core/src/backend/error.rs | 14 + crates/evm/core/src/backend/fuzz.rs | 41 +- crates/evm/core/src/backend/mod.rs | 118 +++-- crates/evm/core/src/opts.rs | 3 +- crates/evm/core/src/utils.rs | 94 ++-- crates/evm/coverage/src/inspector.rs | 21 +- crates/evm/evm/Cargo.toml | 1 - crates/evm/evm/src/executors/builder.rs | 12 +- crates/evm/evm/src/executors/mod.rs | 59 ++- crates/evm/evm/src/executors/tracing.rs | 7 +- crates/evm/evm/src/inspectors/access_list.rs | 79 ---- crates/evm/evm/src/inspectors/chisel_state.rs | 11 +- crates/evm/evm/src/inspectors/debugger.rs | 102 ++-- crates/evm/evm/src/inspectors/logs.rs | 40 +- crates/evm/evm/src/inspectors/mod.rs | 3 +- crates/evm/evm/src/inspectors/printer.rs | 23 +- crates/evm/evm/src/inspectors/stack.rs | 352 +++++++------- crates/evm/fuzz/src/inspector.rs | 35 +- crates/script/src/runner.rs | 2 +- testdata/cheats/MemSafety.t.sol | 27 ++ 45 files changed, 1138 insertions(+), 1147 deletions(-) delete mode 100644 crates/evm/evm/src/inspectors/access_list.rs diff --git a/Cargo.lock b/Cargo.lock index 67bca0286b523..a23a5d778ed2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-network", "alloy-primitives", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-network", "alloy-primitives", @@ -365,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -413,7 +413,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#52bf7125d944e8a389371be503035724dfde5657" +source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -3333,7 +3333,6 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "alloy-rpc-types", "alloy-sol-types", "const-hex", "eyre", @@ -3369,6 +3368,7 @@ dependencies = [ "alloy-rpc-types", "alloy-sol-types", "alloy-transport", + "auto_impl", "const-hex", "derive_more", "eyre", @@ -4578,9 +4578,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -6234,10 +6234,12 @@ dependencies = [ [[package]] name = "revm" -version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d35316fc02d99e42831356c71e882f5d385c77b78f64a44ae82f2f9a4b8b72f" dependencies = [ "auto_impl", + "cfg-if", "revm-interpreter", "revm-precompile", "serde", @@ -6247,20 +6249,23 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=e90052361276aebcdc67cb24d8e2c4d907b6d299#e90052361276aebcdc67cb24d8e2c4d907b6d299" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=5d560be#5d560be4cf022912f4f53f4e5ea71f81253b3c3d" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", "alloy-rpc-types", "alloy-sol-types", + "anstyle", + "colorchoice", "revm", "serde", ] [[package]] name = "revm-interpreter" -version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa10c2dc1e8f4934bdc763a2c09371bcec29e50c22e55e3eb325ee0cba09064" dependencies = [ "revm-primitives", "serde", @@ -6268,8 +6273,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db828d49d329560a70809d9d1fa0c74695edb49f50c5332db3eb24483076deac" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6284,11 +6290,11 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fecd125aad58e135e2ca5771ed6e4e7b1f05fa3a64e0dfb9cc643b7a800a8435" dependencies = [ "alloy-primitives", - "alloy-rlp", "auto_impl", "bitflags 2.4.2", "bitvec", diff --git a/Cargo.toml b/Cargo.toml index 68240fde26577..f14e8d8911b6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,9 +142,11 @@ foundry-compilers = { version = "0.3.9", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "3", default-features = false } -revm-primitives = { version = "1", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "e90052361276aebcdc67cb24d8e2c4d907b6d299", default-features = false } +revm = { version = "6.1", default-features = false } +revm-primitives = { version = "2", default-features = false } +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "5d560be", features = [ + "serde", +] } ## ethers ethers = { version = "2.0.14", default-features = false } @@ -157,22 +159,22 @@ ethers-middleware = { version = "2.0.14", default-features = false } ethers-solc = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy" } -alloy-eips = { git = "https://github.com/alloy-rs/alloy" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy" } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy" } -alloy-network = { git = "https://github.com/alloy-rs/alloy" } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy" } -alloy-providers = { git = "https://github.com/alloy-rs/alloy" } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy" } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy" } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-providers = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } alloy-primitives = { version = "0.6.3", features = ["getrandom"] } alloy-dyn-abi = "0.6.3" alloy-json-abi = "0.6.3" @@ -203,17 +205,10 @@ tracing = "0.1" tracing-subscriber = "0.3" evm-disassembler = "0.4" vergen = { version = "8", default-features = false } -# TODO: bumping to >=0.13.2 breaks ecrecover: https://github.com/foundry-rs/foundry/pull/6969 -# TODO: unpin on next revm release: https://github.com/bluealloy/revm/pull/870 -k256 = "=0.13.1" +k256 = "0.13" axum = "0.6" hyper = "0.14" tower = "0.4" tower-http = "0.4" -[patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } -revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } -revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } -revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 7c1098ec70aff..14021e289e10a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -34,7 +34,7 @@ use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, revm, - revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}, + revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv}, utils::apply_chain_and_block_specific_env_changes, }; use parking_lot::RwLock; @@ -820,8 +820,8 @@ impl NodeConfig { pub(crate) async fn setup(&mut self) -> mem::Backend { // configure the revm environment - let mut cfg = CfgEnv::default(); - cfg.spec_id = self.get_hardfork().into(); + let mut cfg = + CfgEnvWithHandlerCfg::new_with_spec_id(CfgEnv::default(), self.get_hardfork().into()); cfg.chain_id = self.get_chain_id(); cfg.limit_contract_code_size = self.code_size_limit; // EIP-3607 rejects transactions from senders with deployed code. @@ -829,10 +829,10 @@ impl NodeConfig { // caller is a contract. So we disable the check by default. cfg.disable_eip3607 = true; cfg.disable_block_gas_limit = self.disable_block_gas_limit; - cfg.optimism = self.enable_optimism; + cfg.handler_cfg.is_optimism = self.enable_optimism; - let mut env = revm::primitives::Env { - cfg, + let env = revm::primitives::Env { + cfg: cfg.cfg_env, block: BlockEnv { gas_limit: self.gas_limit, basefee: self.get_base_fee(), @@ -840,7 +840,10 @@ impl NodeConfig { }, tx: TxEnv { chain_id: self.get_chain_id().into(), ..Default::default() }, }; - let fees = FeeManager::new(env.cfg.spec_id, self.get_base_fee(), self.get_gas_price()); + let mut env = EnvWithHandlerCfg::new(Box::new(env), cfg.handler_cfg); + + let fees = + FeeManager::new(cfg.handler_cfg.spec_id, self.get_base_fee(), self.get_gas_price()); let (db, fork): (Arc>>, Option) = if let Some(eth_rpc_url) = self.eth_rpc_url.clone() { @@ -910,7 +913,7 @@ impl NodeConfig { pub async fn setup_fork_db( &mut self, eth_rpc_url: String, - env: &mut revm::primitives::Env, + env: &mut EnvWithHandlerCfg, fees: &FeeManager, ) -> (Arc>>, Option) { let (db, config) = self.setup_fork_db_config(eth_rpc_url, env, fees).await; @@ -932,7 +935,7 @@ impl NodeConfig { pub async fn setup_fork_db_config( &mut self, eth_rpc_url: String, - env: &mut revm::primitives::Env, + env: &mut EnvWithHandlerCfg, fees: &FeeManager, ) -> (ForkedDatabase, ClientForkConfig) { // TODO make provider agnostic @@ -961,7 +964,7 @@ impl NodeConfig { provider.get_chain_id().await.expect("Failed to fetch network chain ID"); if alloy_chains::NamedChain::Mainnet == chain_id.to::() { let hardfork: Hardfork = fork_block_number.into(); - env.cfg.spec_id = hardfork.into(); + env.handler_cfg.spec_id = hardfork.into(); self.hardfork = Some(hardfork); } Some(U256::from(chain_id)) @@ -1070,7 +1073,7 @@ latest block number: {latest_block}" }; let override_chain_id = self.chain_id; - let meta = BlockchainDbMeta::new(env.clone(), eth_rpc_url.clone()); + let meta = BlockchainDbMeta::new(*env.env.clone(), eth_rpc_url.clone()); let block_chain_db = if self.fork_chain_id.is_some() { BlockchainDb::new_skip_check(meta, self.block_cache_path(fork_block_number)) } else { diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index e9ba3ff84961d..f129044775e4f 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1733,7 +1733,7 @@ impl EthApi { current_block_number: U64::from(self.backend.best_number()), current_block_timestamp: env.block.timestamp.try_into().unwrap_or(u64::MAX), current_block_hash: self.backend.best_hash(), - hard_fork: env.cfg.spec_id, + hard_fork: env.handler_cfg.spec_id, transaction_order: match *tx_order { TransactionOrder::Fifo => "fifo".to_string(), TransactionOrder::Fees => "fees".to_string(), @@ -2259,7 +2259,7 @@ impl EthApi { return_ok!() => { // succeeded } - InstructionResult::OutOfGas | InstructionResult::OutOfFund => { + InstructionResult::OutOfGas | InstructionResult::OutOfFunds => { return Err(InvalidTransactionError::BasicOutOfGas(gas_limit).into()) } // need to check if the revert was due to lack of gas or unrelated reason @@ -2340,7 +2340,7 @@ impl EthApi { // gas). InstructionResult::Revert | InstructionResult::OutOfGas | - InstructionResult::OutOfFund | + InstructionResult::OutOfFunds | // we're also checking for InvalidFEOpcode here because this can be used to trigger an error common usage in openzeppelin InstructionResult::InvalidFEOpcode => { lowest_gas_limit = mid_gas_limit; diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index d4ba69264ab1f..45fc1f1126a1b 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -16,13 +16,14 @@ use anvil_core::eth::{ use foundry_evm::{ backend::DatabaseError, inspectors::{TracingInspector, TracingInspectorConfig}, - revm, revm::{ interpreter::InstructionResult, - primitives::{BlockEnv, CfgEnv, EVMError, Env, ExecutionResult, Output, SpecId}, + primitives::{ + BlockEnv, CfgEnvWithHandlerCfg, EVMError, EnvWithHandlerCfg, ExecutionResult, Output, + SpecId, + }, }, traces::CallTraceNode, - utils::{eval_to_instruction_result, halt_to_instruction_result}, }; use std::sync::Arc; @@ -108,7 +109,8 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> /// all pending transactions pub pending: std::vec::IntoIter>, pub block_env: BlockEnv, - pub cfg_env: CfgEnv, + /// The configuration environment and spec id + pub cfg_env: CfgEnvWithHandlerCfg, pub parent_hash: B256, /// Cumulative gas used by all executed transactions pub gas_used: U256, @@ -131,7 +133,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let difficulty = self.block_env.difficulty; let beneficiary = self.block_env.coinbase; let timestamp = self.block_env.timestamp.to::(); - let base_fee = if (self.cfg_env.spec_id as u8) >= (SpecId::LONDON as u8) { + let base_fee = if (self.cfg_env.handler_cfg.spec_id as u8) >= (SpecId::LONDON as u8) { Some(self.block_env.basefee) } else { None @@ -220,8 +222,12 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' ExecutedTransactions { block, included, invalid } } - fn env_for(&self, tx: &PendingTransaction) -> Env { - Env { cfg: self.cfg_env.clone(), block: self.block_env.clone(), tx: tx.to_revm_tx_env() } + fn env_for(&self, tx: &PendingTransaction) -> EnvWithHandlerCfg { + EnvWithHandlerCfg::new_with_cfg_env( + self.cfg_env.clone(), + self.block_env.clone(), + tx.to_revm_tx_env(), + ) } } @@ -269,33 +275,40 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator let nonce = account.nonce; - let mut evm = revm::EVM::new(); - evm.env = env; - evm.database(&mut self.db); - // records all call and step traces let mut inspector = Inspector::default().with_tracing(); if self.enable_steps_tracing { inspector = inspector.with_steps_tracing(); } - trace!(target: "backend", "[{:?}] executing", transaction.hash()); - // transact and commit the transaction - let exec_result = match evm.inspect_commit(&mut inspector) { - Ok(exec_result) => exec_result, - Err(err) => { - warn!(target: "backend", "[{:?}] failed to execute: {:?}", transaction.hash(), err); - match err { - EVMError::Database(err) => { - return Some(TransactionExecutionOutcome::DatabaseError(transaction, err)) - } - EVMError::Transaction(err) => { - return Some(TransactionExecutionOutcome::Invalid(transaction, err.into())) - } - // This will correspond to prevrandao not set, and it should never happen. - // If it does, it's a bug. - e => { - panic!("Failed to execute transaction. This is a bug.\n {:?}", e) + let exec_result = { + let mut evm = + foundry_evm::utils::new_evm_with_inspector(&mut *self.db, env, &mut inspector); + + trace!(target: "backend", "[{:?}] executing", transaction.hash()); + // transact and commit the transaction + match evm.transact_commit() { + Ok(exec_result) => exec_result, + Err(err) => { + warn!(target: "backend", "[{:?}] failed to execute: {:?}", transaction.hash(), err); + match err { + EVMError::Database(err) => { + return Some(TransactionExecutionOutcome::DatabaseError( + transaction, + err, + )) + } + EVMError::Transaction(err) => { + return Some(TransactionExecutionOutcome::Invalid( + transaction, + err.into(), + )) + } + // This will correspond to prevrandao not set, and it should never happen. + // If it does, it's a bug. + e => { + panic!("Failed to execute transaction. This is a bug.\n {:?}", e) + } } } } @@ -304,14 +317,12 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator let (exit_reason, gas_used, out, logs) = match exec_result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { - (eval_to_instruction_result(reason), gas_used, Some(output), Some(logs)) + (reason.into(), gas_used, Some(output), Some(logs)) } ExecutionResult::Revert { gas_used, output } => { (InstructionResult::Revert, gas_used, Some(Output::Call(output)), None) } - ExecutionResult::Halt { reason, gas_used } => { - (halt_to_instruction_result(reason), gas_used, None, None) - } + ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None, None), }; if exit_reason == InstructionResult::OutOfGas { @@ -330,11 +341,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator exit_reason, out, gas_used, - logs: logs - .unwrap_or_default() - .into_iter() - .map(|log| Log::new_unchecked(log.address, log.topics, log.data)) - .collect(), + logs: logs.unwrap_or_default(), traces: inspector .tracer .unwrap_or(TracingInspector::new(TracingInspectorConfig::all())) diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 6072e4f938b71..6e38ac61d5b65 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -1,16 +1,16 @@ //! Anvil specific [`revm::Inspector`] implementation use crate::{eth::macros::node_info, revm::Database}; -use alloy_primitives::Log; +use alloy_primitives::{Address, Log}; use foundry_evm::{ call_inspectors, decode::decode_console_logs, inspectors::{LogCollector, TracingInspector}, revm, revm::{ - interpreter::{CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, - primitives::{Address, Bytes, B256}, - EVMData, + interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}, + primitives::U256, + EvmContext, }, traces::TracingInspectorConfig, }; @@ -48,94 +48,91 @@ impl Inspector { impl revm::Inspector for Inspector { #[inline] - fn initialize_interp(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + fn initialize_interp(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors!([&mut self.tracer], |inspector| { - inspector.initialize_interp(interp, data); + inspector.initialize_interp(interp, ecx); }); } #[inline] - fn step(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + fn step(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors!([&mut self.tracer], |inspector| { - inspector.step(interp, data); + inspector.step(interp, ecx); }); } #[inline] - fn log( - &mut self, - evm_data: &mut EVMData<'_, DB>, - address: &Address, - topics: &[B256], - data: &Bytes, - ) { - call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { - inspector.log(evm_data, address, topics, data); + fn step_end(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { + call_inspectors!([&mut self.tracer], |inspector| { + inspector.step_end(interp, ecx); }); } #[inline] - fn step_end(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { - call_inspectors!([&mut self.tracer], |inspector| { - inspector.step_end(interp, data); + fn log(&mut self, ecx: &mut EvmContext, log: &Log) { + call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { + inspector.log(ecx, log); }); } #[inline] - fn call( - &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { + fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { - inspector.call(data, call); + if let Some(outcome) = inspector.call(ecx, inputs) { + return Some(outcome); + } }); - (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) + None } #[inline] fn call_end( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, inputs: &CallInputs, - remaining_gas: Gas, - ret: InstructionResult, - out: Bytes, - ) -> (InstructionResult, Gas, Bytes) { - call_inspectors!([&mut self.tracer], |inspector| { - inspector.call_end(data, inputs, remaining_gas, ret, out.clone()); - }); - (ret, remaining_gas, out) + outcome: CallOutcome, + ) -> CallOutcome { + if let Some(tracer) = &mut self.tracer { + return tracer.call_end(ecx, inputs, outcome); + } + + outcome } #[inline] fn create( &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CreateInputs, - ) -> (InstructionResult, Option
, Gas, Bytes) { - call_inspectors!([&mut self.tracer], |inspector| { - inspector.create(data, call); - }); - - (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()) + ecx: &mut EvmContext, + inputs: &mut CreateInputs, + ) -> Option { + if let Some(tracer) = &mut self.tracer { + if let Some(out) = tracer.create(ecx, inputs) { + return Some(out); + } + } + None } #[inline] fn create_end( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, inputs: &CreateInputs, - status: InstructionResult, - address: Option
, - gas: Gas, - retdata: Bytes, - ) -> (InstructionResult, Option
, Gas, Bytes) { - call_inspectors!([&mut self.tracer], |inspector| { - inspector.create_end(data, inputs, status, address, gas, retdata.clone()); - }); - (status, address, gas, retdata) + outcome: CreateOutcome, + ) -> CreateOutcome { + if let Some(tracer) = &mut self.tracer { + return tracer.create_end(ecx, inputs, outcome); + } + + outcome + } + + #[inline] + fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { + if let Some(tracer) = &mut self.tracer { + revm::Inspector::::selfdestruct(tracer, contract, target, value); + } } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 64e6942550e67..8fb868dcd0e87 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -63,22 +63,22 @@ use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, decode::RevertDecoder, - inspectors::AccessListTracer, + inspectors::AccessListInspector, revm::{ self, db::CacheDB, interpreter::InstructionResult, primitives::{ - BlockEnv, CreateScheme, EVMError, Env, ExecutionResult, InvalidHeader, Output, SpecId, - TransactTo, TxEnv, KECCAK_EMPTY, + BlockEnv, CfgEnvWithHandlerCfg, CreateScheme, EnvWithHandlerCfg, ExecutionResult, + Output, SpecId, TransactTo, TxEnv, KECCAK_EMPTY, }, }, - traces::{TracingInspector, TracingInspectorConfig}, - utils::{eval_to_instruction_result, halt_to_instruction_result}, + utils::new_evm_with_inspector_ref, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; use hash_db::HashDB; use parking_lot::{Mutex, RwLock}; +use revm::primitives::ResultAndState; use std::{ collections::{BTreeMap, HashMap}, io::{Read, Write}, @@ -147,7 +147,7 @@ pub struct Backend { /// Historic states of previous blocks states: Arc>, /// env data of the chain - env: Arc>, + env: Arc>, /// this is set if this is currently forked off another client fork: Arc>>, /// provides time related info, like timestamp @@ -177,7 +177,7 @@ impl Backend { #[allow(clippy::too_many_arguments)] pub async fn with_genesis( db: Arc>>, - env: Arc>, + env: Arc>, genesis: GenesisConfig, fees: FeeManager, fork: Arc>>, @@ -357,7 +357,7 @@ impl Backend { } pub fn precompiles(&self) -> Vec
{ - get_precompiles_for(self.env.read().cfg.spec_id) + get_precompiles_for(self.env.read().handler_cfg.spec_id) } /// Resets the fork to a fresh state @@ -480,7 +480,7 @@ impl Backend { } /// The env data of the blockchain - pub fn env(&self) -> &Arc> { + pub fn env(&self) -> &Arc> { &self.env } @@ -556,7 +556,7 @@ impl Backend { /// Returns the configured specid pub fn spec_id(&self) -> SpecId { - self.env.read().cfg.spec_id + self.env.read().handler_cfg.spec_id } /// Returns true for post London @@ -576,7 +576,7 @@ impl Backend { /// Returns true if op-stack deposits are active pub fn is_optimism(&self) -> bool { - self.env.read().cfg.optimism + self.env.read().handler_cfg.is_optimism } /// Returns an error if EIP1559 is not active (pre Berlin) @@ -771,7 +771,7 @@ impl Backend { } /// Returns the environment for the next block - fn next_env(&self) -> Env { + fn next_env(&self) -> EnvWithHandlerCfg { let mut env = self.env.read().clone(); // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); @@ -793,24 +793,16 @@ impl Backend { let db = self.db.read().await; let mut inspector = Inspector::default(); - let mut evm = revm::EVM::new(); - evm.env = env; - evm.database(&*db); - let result_and_state = match evm.inspect_ref(&mut inspector) { - Ok(res) => res, - Err(e) => return Err(e.into()), - }; - let state = result_and_state.state; - let (exit_reason, gas_used, out, logs) = match result_and_state.result { + let ResultAndState { result, state } = + new_evm_with_inspector_ref(&*db, env, &mut inspector).transact()?; + let (exit_reason, gas_used, out, logs) = match result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { - (eval_to_instruction_result(reason), gas_used, Some(output), Some(logs)) + (reason.into(), gas_used, Some(output), Some(logs)) } ExecutionResult::Revert { gas_used, output } => { (InstructionResult::Revert, gas_used, Some(Output::Call(output)), None) } - ExecutionResult::Halt { reason, gas_used } => { - (halt_to_instruction_result(reason), gas_used, None, None) - } + ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None, None), }; inspector.print_logs(); @@ -843,12 +835,13 @@ impl Backend { let storage = self.blockchain.storage.read(); + let cfg_env = CfgEnvWithHandlerCfg::new(env.cfg.clone(), env.handler_cfg); let executor = TransactionExecutor { db: &mut cache_db, validator: self, pending: pool_transactions.into_iter(), block_env: env.block.clone(), - cfg_env: env.cfg, + cfg_env, parent_hash: storage.best_hash, gas_used: U256::ZERO, enable_steps_tracing: self.enable_steps_tracing, @@ -907,7 +900,7 @@ impl Backend { validator: self, pending: pool_transactions.into_iter(), block_env: env.block.clone(), - cfg_env: env.cfg.clone(), + cfg_env: CfgEnvWithHandlerCfg::new(env.cfg.clone(), env.handler_cfg), parent_hash: best_hash, gas_used: U256::ZERO, enable_steps_tracing: self.enable_steps_tracing, @@ -1049,7 +1042,7 @@ impl Backend { request: TransactionRequest, fee_details: FeeDetails, block_env: BlockEnv, - ) -> Env { + ) -> EnvWithHandlerCfg { let TransactionRequest { from, to, gas, value, input, nonce, access_list, .. } = request; let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = fee_details; @@ -1105,37 +1098,18 @@ impl Backend { D: DatabaseRef, { let mut inspector = Inspector::default(); - let mut evm = revm::EVM::new(); - evm.env = self.build_call_env(request, fee_details, block_env); - evm.database(state); - let result_and_state = match evm.inspect_ref(&mut inspector) { - Ok(result_and_state) => result_and_state, - Err(e) => match e { - EVMError::Transaction(invalid_tx) => { - return Err(BlockchainError::InvalidTransaction(invalid_tx.into())) - } - EVMError::Database(e) => return Err(BlockchainError::DatabaseError(e)), - EVMError::Header(e) => match e { - InvalidHeader::ExcessBlobGasNotSet => { - return Err(BlockchainError::ExcessBlobGasNotSet) - } - InvalidHeader::PrevrandaoNotSet => { - return Err(BlockchainError::PrevrandaoNotSet) - } - }, - }, - }; - let state = result_and_state.state; - let (exit_reason, gas_used, out) = match result_and_state.result { + + let env = self.build_call_env(request, fee_details, block_env); + let ResultAndState { result, state } = + new_evm_with_inspector_ref(state, env, &mut inspector).transact()?; + let (exit_reason, gas_used, out) = match result { ExecutionResult::Success { reason, gas_used, output, .. } => { - (eval_to_instruction_result(reason), gas_used, Some(output)) + (reason.into(), gas_used, Some(output)) } ExecutionResult::Revert { gas_used, output } => { (InstructionResult::Revert, gas_used, Some(Output::Call(output))) } - ExecutionResult::Halt { reason, gas_used } => { - (halt_to_instruction_result(reason), gas_used, None) - } + ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None), }; inspector.print_logs(); Ok((exit_reason, out, gas_used, state)) @@ -1151,30 +1125,23 @@ impl Backend { self.with_database_at(block_request, |state, block| { let mut inspector = Inspector::default().with_steps_tracing(); let block_number = block.number; - let mut evm = revm::EVM::new(); - evm.env = self.build_call_env(request, fee_details, block); - evm.database(state); - let result_and_state = - match evm.inspect_ref(&mut inspector) { - Ok(result_and_state) => result_and_state, - Err(e) => return Err(e.into()), - }; - let (exit_reason, gas_used, out, ) = match result_and_state.result { + + let env = self.build_call_env(request, fee_details, block); + let ResultAndState { result, state: _ } = + new_evm_with_inspector_ref(state, env, &mut inspector).transact()?; + let (exit_reason, gas_used, out) = match result { ExecutionResult::Success { reason, gas_used, output, .. } => { - (eval_to_instruction_result(reason), gas_used, Some(output), ) - }, - ExecutionResult::Revert { gas_used, output} => { + (reason.into(), gas_used, Some(output)) + } + ExecutionResult::Revert { gas_used, output } => { (InstructionResult::Revert, gas_used, Some(Output::Call(output))) - }, - ExecutionResult::Halt { reason, gas_used } => { - (halt_to_instruction_result(reason), gas_used, None) - }, + } + ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None), }; - let res = inspector.tracer.unwrap_or(TracingInspector::new(TracingInspectorConfig::all())).into_geth_builder().geth_traces(gas_used, match &out { - Some(out) => out.data().clone(), - None => Bytes::new() - }, opts); - trace!(target: "backend", "trace call return {:?} out: {:?} gas {} on block {}", exit_reason, out, gas_used, block_number); + let tracer = inspector.tracer.expect("tracer disappeared"); + let return_value = out.as_ref().map(|o| o.data().clone()).unwrap_or_default(); + let res = tracer.into_geth_builder().geth_traces(gas_used, return_value, opts); + trace!(target: "backend", ?exit_reason, ?out, %gas_used, %block_number, "trace call"); Ok(res) }) .await? @@ -1198,32 +1165,26 @@ impl Backend { from.create(nonce) }; - let mut tracer = AccessListTracer::new( + let mut inspector = AccessListInspector::new( request.access_list.clone().unwrap_or_default(), from, to, self.precompiles(), ); - let mut evm = revm::EVM::new(); - evm.env = self.build_call_env(request, fee_details, block_env); - evm.database(state); - let result_and_state = match evm.inspect_ref(&mut tracer) { - Ok(result_and_state) => result_and_state, - Err(e) => return Err(e.into()), - }; - let (exit_reason, gas_used, out) = match result_and_state.result { + let env = self.build_call_env(request, fee_details, block_env); + let ResultAndState { result, state: _ } = + new_evm_with_inspector_ref(state, env, &mut inspector).transact()?; + let (exit_reason, gas_used, out) = match result { ExecutionResult::Success { reason, gas_used, output, .. } => { - (eval_to_instruction_result(reason), gas_used, Some(output)) + (reason.into(), gas_used, Some(output)) } ExecutionResult::Revert { gas_used, output } => { (InstructionResult::Revert, gas_used, Some(Output::Call(output))) } - ExecutionResult::Halt { reason, gas_used } => { - (halt_to_instruction_result(reason), gas_used, None) - } + ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None), }; - let access_list = tracer.access_list(); + let access_list = inspector.access_list(); Ok((exit_reason, out, gas_used, access_list)) } @@ -2320,7 +2281,7 @@ impl TransactionValidator for Backend { &self, pending: &PendingTransaction, account: &AccountInfo, - env: &Env, + env: &EnvWithHandlerCfg, ) -> Result<(), InvalidTransactionError> { let tx = &pending.transaction; @@ -2329,7 +2290,7 @@ impl TransactionValidator for Backend { if chain_id.to::() != tx_chain_id { if let Some(legacy) = tx.as_legacy() { // - if env.cfg.spec_id >= SpecId::SPURIOUS_DRAGON && + if env.handler_cfg.spec_id >= SpecId::SPURIOUS_DRAGON && !meets_eip155(chain_id.to::(), legacy.signature().v()) { warn!(target: "backend", ?chain_id, ?tx_chain_id, "incompatible EIP155-based V"); @@ -2365,7 +2326,7 @@ impl TransactionValidator for Backend { return Err(InvalidTransactionError::NonceTooLow); } - if (env.cfg.spec_id as u8) >= (SpecId::LONDON as u8) { + if (env.handler_cfg.spec_id as u8) >= (SpecId::LONDON as u8) { if tx.gas_price() < env.block.basefee && !is_deposit_tx { warn!(target: "backend", "max fee per gas={}, too low, block basefee={}",tx.gas_price(), env.block.basefee); return Err(InvalidTransactionError::FeeCapTooLow); @@ -2400,7 +2361,7 @@ impl TransactionValidator for Backend { &self, tx: &PendingTransaction, account: &AccountInfo, - env: &Env, + env: &EnvWithHandlerCfg, ) -> Result<(), InvalidTransactionError> { self.validate_pool_transaction_for(tx, account, env)?; if tx.nonce().to::() > account.nonce { diff --git a/crates/anvil/src/eth/backend/validate.rs b/crates/anvil/src/eth/backend/validate.rs index 3ea666f15a156..650ce24a55010 100644 --- a/crates/anvil/src/eth/backend/validate.rs +++ b/crates/anvil/src/eth/backend/validate.rs @@ -2,7 +2,7 @@ use crate::eth::error::{BlockchainError, InvalidTransactionError}; use anvil_core::eth::transaction::PendingTransaction; -use foundry_evm::revm::primitives::{AccountInfo, Env}; +use foundry_evm::revm::primitives::{AccountInfo, EnvWithHandlerCfg}; /// A trait for validating transactions #[async_trait::async_trait] @@ -22,7 +22,7 @@ pub trait TransactionValidator { &self, tx: &PendingTransaction, account: &AccountInfo, - env: &Env, + env: &EnvWithHandlerCfg, ) -> Result<(), InvalidTransactionError>; /// Validates the transaction against a specific account @@ -32,6 +32,6 @@ pub trait TransactionValidator { &self, tx: &PendingTransaction, account: &AccountInfo, - env: &Env, + env: &EnvWithHandlerCfg, ) -> Result<(), InvalidTransactionError>; } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index cc7af40ac5157..39e1f52a42f03 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -85,6 +85,8 @@ pub enum BlockchainError { DepositTransactionUnsupported, #[error("Excess blob gas not set.")] ExcessBlobGasNotSet, + #[error("{0}")] + Message(String), } impl From for BlockchainError { @@ -105,6 +107,7 @@ where InvalidHeader::PrevrandaoNotSet => BlockchainError::PrevrandaoNotSet, }, EVMError::Database(err) => err.into(), + EVMError::Custom(err) => BlockchainError::Message(err), } } } @@ -233,7 +236,7 @@ impl From for InvalidTransactionError { InvalidTransaction::NonceOverflowInTransaction => { InvalidTransactionError::NonceMaxValue } - InvalidTransaction::CreateInitcodeSizeLimit => { + InvalidTransaction::CreateInitCodeSizeLimit => { InvalidTransactionError::MaxInitCodeSizeExceeded } InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh, @@ -411,6 +414,7 @@ impl ToRpcResponseResult for Result { err @ BlockchainError::ExcessBlobGasNotSet => { RpcError::invalid_params(err.to_string()) } + err @ BlockchainError::Message(_) => RpcError::internal_error_with(err.to_string()), } .into(), } diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 5153178f598c0..6bcde67d5ac98 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -1,9 +1,12 @@ use alloy_primitives::Address; -use foundry_evm::revm::{self, precompile::Precompiles, primitives::SpecId}; +use foundry_evm::revm::{ + precompile::{PrecompileSpecId, Precompiles}, + primitives::SpecId, +}; use std::fmt; pub fn get_precompiles_for(spec_id: SpecId) -> Vec
{ - Precompiles::new(to_precompile_id(spec_id)).addresses().into_iter().copied().collect() + Precompiles::new(PrecompileSpecId::from_spec_id(spec_id)).addresses().copied().collect() } /// wrapper type that displays byte as hex @@ -53,29 +56,3 @@ impl<'a> fmt::Debug for HexDisplay<'a> { Ok(()) } } - -pub fn to_precompile_id(spec_id: SpecId) -> revm::precompile::SpecId { - match spec_id { - SpecId::FRONTIER | - SpecId::FRONTIER_THAWING | - SpecId::HOMESTEAD | - SpecId::DAO_FORK | - SpecId::TANGERINE | - SpecId::SPURIOUS_DRAGON => revm::precompile::SpecId::HOMESTEAD, - SpecId::BYZANTIUM | SpecId::CONSTANTINOPLE | SpecId::PETERSBURG => { - revm::precompile::SpecId::BYZANTIUM - } - SpecId::ISTANBUL | SpecId::MUIR_GLACIER => revm::precompile::SpecId::ISTANBUL, - SpecId::BERLIN | - SpecId::LONDON | - SpecId::ARROW_GLACIER | - SpecId::GRAY_GLACIER | - SpecId::MERGE | - SpecId::SHANGHAI | - SpecId::CANCUN | - SpecId::BEDROCK | - SpecId::REGOLITH | - SpecId::CANYON | - SpecId::LATEST => revm::precompile::SpecId::BERLIN, - } -} diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index ca83c084d07bd..a9e0749621842 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,6 +1,7 @@ use alloy_primitives::U256; use alloy_providers::provider::TempProvider; use alloy_rpc_types::BlockTransactions; +use cast::revm::primitives::EnvWithHandlerCfg; use clap::Parser; use eyre::{Result, WrapErr}; use foundry_cli::{ @@ -135,6 +136,9 @@ impl RunArgs { env.block.gas_limit = block.header.gas_limit; } + let mut env = + EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), executor.spec_id()); + // Set the state to the moment right before the transaction if !self.quick { println!("Executing previous transactions from the block."); diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 66796026d5675..8b5f8102d8e33 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -7,6 +7,7 @@ use foundry_config::UnresolvedEnvVarError; use foundry_evm_core::backend::DatabaseError; use foundry_wallets::error::WalletSignerError; use k256::ecdsa::signature::Error as SignatureError; +use revm::primitives::EVMError; use std::{borrow::Cow, fmt}; /// Cheatcode result type. @@ -302,6 +303,13 @@ impl_from!( WalletSignerError, ); +impl From> for Error { + #[inline] + fn from(err: EVMError) -> Self { + Self::display(DatabaseError::from(err)) + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 2fec645036cc3..fd45200f03569 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -12,7 +12,7 @@ use foundry_evm_core::{ }; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, - EVMData, + EvmContext, }; use std::{collections::HashMap, path::Path}; @@ -60,8 +60,8 @@ impl Cheatcode for loadCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, slot } = *self; ensure_not_precompile!(&target, ccx); - ccx.data.journaled_state.load_account(target, ccx.data.db)?; - let (val, _) = ccx.data.journaled_state.sload(target, slot.into(), ccx.data.db)?; + ccx.ecx.load_account(target)?; + let (val, _) = ccx.ecx.sload(target, slot.into())?; Ok(val.abi_encode()) } } @@ -84,9 +84,9 @@ impl Cheatcode for loadAllocsCall { }; // Then, load the allocs into the database. - ccx.data + ccx.ecx .db - .load_allocs(&allocs, &mut ccx.data.journaled_state) + .load_allocs(&allocs, &mut ccx.ecx.journaled_state) .map(|()| Vec::default()) .map_err(|e| fmt_err!("failed to load allocs: {e}")) } @@ -109,7 +109,7 @@ impl Cheatcode for dumpStateCall { }; let alloc = ccx - .data + .ecx .journaled_state .state() .into_iter() @@ -214,7 +214,7 @@ impl Cheatcode for chainIdCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newChainId } = self; ensure!(*newChainId <= U256::from(u64::MAX), "chain ID must be less than 2^64 - 1"); - ccx.data.env.cfg.chain_id = newChainId.to(); + ccx.ecx.env.cfg.chain_id = newChainId.to(); Ok(Default::default()) } } @@ -222,7 +222,7 @@ impl Cheatcode for chainIdCall { impl Cheatcode for coinbaseCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newCoinbase } = self; - ccx.data.env.block.coinbase = *newCoinbase; + ccx.ecx.env.block.coinbase = *newCoinbase; Ok(Default::default()) } } @@ -231,11 +231,11 @@ impl Cheatcode for difficultyCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newDifficulty } = self; ensure!( - ccx.data.env.cfg.spec_id < SpecId::MERGE, + ccx.ecx.spec_id() < SpecId::MERGE, "`difficulty` is not supported after the Paris hard fork, use `prevrandao` instead; \ see EIP-4399: https://eips.ethereum.org/EIPS/eip-4399" ); - ccx.data.env.block.difficulty = *newDifficulty; + ccx.ecx.env.block.difficulty = *newDifficulty; Ok(Default::default()) } } @@ -243,7 +243,7 @@ impl Cheatcode for difficultyCall { impl Cheatcode for feeCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newBasefee } = self; - ccx.data.env.block.basefee = *newBasefee; + ccx.ecx.env.block.basefee = *newBasefee; Ok(Default::default()) } } @@ -252,11 +252,11 @@ impl Cheatcode for prevrandaoCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newPrevrandao } = self; ensure!( - ccx.data.env.cfg.spec_id >= SpecId::MERGE, + ccx.ecx.spec_id() >= SpecId::MERGE, "`prevrandao` is not supported before the Paris hard fork, use `difficulty` instead; \ see EIP-4399: https://eips.ethereum.org/EIPS/eip-4399" ); - ccx.data.env.block.prevrandao = Some(*newPrevrandao); + ccx.ecx.env.block.prevrandao = Some(*newPrevrandao); Ok(Default::default()) } } @@ -264,7 +264,7 @@ impl Cheatcode for prevrandaoCall { impl Cheatcode for rollCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newHeight } = self; - ccx.data.env.block.number = *newHeight; + ccx.ecx.env.block.number = *newHeight; Ok(Default::default()) } } @@ -272,14 +272,14 @@ impl Cheatcode for rollCall { impl Cheatcode for getBlockNumberCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - Ok(ccx.data.env.block.number.abi_encode()) + Ok(ccx.ecx.env.block.number.abi_encode()) } } impl Cheatcode for txGasPriceCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newGasPrice } = self; - ccx.data.env.tx.gas_price = *newGasPrice; + ccx.ecx.env.tx.gas_price = *newGasPrice; Ok(Default::default()) } } @@ -287,7 +287,7 @@ impl Cheatcode for txGasPriceCall { impl Cheatcode for warpCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newTimestamp } = self; - ccx.data.env.block.timestamp = *newTimestamp; + ccx.ecx.env.block.timestamp = *newTimestamp; Ok(Default::default()) } } @@ -295,14 +295,14 @@ impl Cheatcode for warpCall { impl Cheatcode for getBlockTimestampCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - Ok(ccx.data.env.block.timestamp.abi_encode()) + Ok(ccx.ecx.env.block.timestamp.abi_encode()) } } impl Cheatcode for dealCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account: address, newBalance: new_balance } = *self; - let account = journaled_account(ccx.data, address)?; + let account = journaled_account(ccx.ecx, address)?; let old_balance = std::mem::replace(&mut account.info.balance, new_balance); let record = DealRecord { address, old_balance, new_balance }; ccx.state.eth_deals.push(record); @@ -314,9 +314,9 @@ impl Cheatcode for etchCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, newRuntimeBytecode } = self; ensure_not_precompile!(target, ccx); - ccx.data.journaled_state.load_account(*target, ccx.data.db)?; + ccx.ecx.load_account(*target)?; let bytecode = Bytecode::new_raw(Bytes::copy_from_slice(newRuntimeBytecode)).to_checked(); - ccx.data.journaled_state.set_code(*target, bytecode); + ccx.ecx.journaled_state.set_code(*target, bytecode); Ok(Default::default()) } } @@ -324,7 +324,7 @@ impl Cheatcode for etchCall { impl Cheatcode for resetNonceCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; - let account = journaled_account(ccx.data, *account)?; + let account = journaled_account(ccx.ecx, *account)?; // Per EIP-161, EOA nonces start at 0, but contract nonces // start at 1. Comparing by code_hash instead of code // to avoid hitting the case where account's code is None. @@ -339,7 +339,7 @@ impl Cheatcode for resetNonceCall { impl Cheatcode for setNonceCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account, newNonce } = *self; - let account = journaled_account(ccx.data, account)?; + let account = journaled_account(ccx.ecx, account)?; // nonce must increment only let current = account.info.nonce; ensure!( @@ -355,7 +355,7 @@ impl Cheatcode for setNonceCall { impl Cheatcode for setNonceUnsafeCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account, newNonce } = *self; - let account = journaled_account(ccx.data, account)?; + let account = journaled_account(ccx.ecx, account)?; account.info.nonce = newNonce; Ok(Default::default()) } @@ -366,8 +366,8 @@ impl Cheatcode for storeCall { let Self { target, slot, value } = *self; ensure_not_precompile!(&target, ccx); // ensure the account is touched - let _ = journaled_account(ccx.data, target)?; - ccx.data.journaled_state.sstore(target, slot.into(), value.into(), ccx.data.db)?; + let _ = journaled_account(ccx.ecx, target)?; + ccx.ecx.sstore(target, slot.into(), value.into())?; Ok(Default::default()) } } @@ -375,7 +375,7 @@ impl Cheatcode for storeCall { impl Cheatcode for coolCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target } = self; - if let Some(account) = ccx.data.journaled_state.state.get_mut(target) { + if let Some(account) = ccx.ecx.journaled_state.state.get_mut(target) { account.unmark_touch(); account.storage.clear(); } @@ -386,28 +386,28 @@ impl Cheatcode for coolCall { impl Cheatcode for readCallersCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - read_callers(ccx.state, &ccx.data.env.tx.caller) + read_callers(ccx.state, &ccx.ecx.env.tx.caller) } } impl Cheatcode for snapshotCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - Ok(ccx.data.db.snapshot(&ccx.data.journaled_state, ccx.data.env).abi_encode()) + Ok(ccx.ecx.db.snapshot(&ccx.ecx.journaled_state, &ccx.ecx.env).abi_encode()) } } impl Cheatcode for revertToCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; - let result = if let Some(journaled_state) = ccx.data.db.revert( + let result = if let Some(journaled_state) = ccx.ecx.db.revert( *snapshotId, - &ccx.data.journaled_state, - ccx.data.env, + &ccx.ecx.journaled_state, + &mut ccx.ecx.env, RevertSnapshotAction::RevertKeep, ) { // we reset the evm's journaled_state to the state of the snapshot previous state - ccx.data.journaled_state = journaled_state; + ccx.ecx.journaled_state = journaled_state; true } else { false @@ -419,14 +419,14 @@ impl Cheatcode for revertToCall { impl Cheatcode for revertToAndDeleteCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; - let result = if let Some(journaled_state) = ccx.data.db.revert( + let result = if let Some(journaled_state) = ccx.ecx.db.revert( *snapshotId, - &ccx.data.journaled_state, - ccx.data.env, + &ccx.ecx.journaled_state, + &mut ccx.ecx.env, RevertSnapshotAction::RevertRemove, ) { // we reset the evm's journaled_state to the state of the snapshot previous state - ccx.data.journaled_state = journaled_state; + ccx.ecx.journaled_state = journaled_state; true } else { false @@ -438,14 +438,14 @@ impl Cheatcode for revertToAndDeleteCall { impl Cheatcode for deleteSnapshotCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; - let result = ccx.data.db.delete_snapshot(*snapshotId); + let result = ccx.ecx.db.delete_snapshot(*snapshotId); Ok(result.abi_encode()) } } impl Cheatcode for deleteSnapshotsCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - ccx.data.db.delete_snapshots(); + ccx.ecx.db.delete_snapshots(); Ok(Default::default()) } } @@ -467,7 +467,7 @@ impl Cheatcode for stopAndReturnStateDiffCall { pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { super::script::correct_sender_nonce(ccx)?; - let (account, _) = ccx.data.journaled_state.load_account(*address, ccx.data.db)?; + let (account, _) = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?; Ok(account.info.nonce.abi_encode()) } @@ -520,13 +520,13 @@ fn read_callers(state: &Cheatcodes, default_sender: &Address) -> Result { } /// Ensures the `Account` is loaded and touched. -pub(super) fn journaled_account<'a, DB: DatabaseExt>( - data: &'a mut EVMData<'_, DB>, +pub(super) fn journaled_account( + ecx: &mut EvmContext, addr: Address, -) -> Result<&'a mut Account> { - data.journaled_state.load_account(addr, data.db)?; - data.journaled_state.touch(&addr); - Ok(data.journaled_state.state.get_mut(&addr).expect("account is loaded")) +) -> Result<&mut Account> { + ecx.load_account(addr)?; + ecx.journaled_state.touch(&addr); + Ok(ecx.journaled_state.state.get_mut(&addr).expect("account is loaded")) } /// Consumes recorded account accesses and returns them as an abi encoded diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 1d8fc2fe4f24b..4b3fdc6b346bf 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -11,7 +11,7 @@ use foundry_evm_core::fork::CreateFork; impl Cheatcode for activeForkCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - ccx.data + ccx.ecx .db .active_fork_id() .map(|id| id.abi_encode()) @@ -64,7 +64,7 @@ impl Cheatcode for createSelectFork_2Call { impl Cheatcode for rollFork_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { blockNumber } = self; - ccx.data.db.roll_fork(None, *blockNumber, ccx.data.env, &mut ccx.data.journaled_state)?; + ccx.ecx.db.roll_fork(None, *blockNumber, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state)?; Ok(Default::default()) } } @@ -72,11 +72,11 @@ impl Cheatcode for rollFork_0Call { impl Cheatcode for rollFork_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { txHash } = self; - ccx.data.db.roll_fork_to_transaction( + ccx.ecx.db.roll_fork_to_transaction( None, *txHash, - ccx.data.env, - &mut ccx.data.journaled_state, + &mut ccx.ecx.env, + &mut ccx.ecx.journaled_state, )?; Ok(Default::default()) } @@ -85,11 +85,11 @@ impl Cheatcode for rollFork_1Call { impl Cheatcode for rollFork_2Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, blockNumber } = self; - ccx.data.db.roll_fork( + ccx.ecx.db.roll_fork( Some(*forkId), *blockNumber, - ccx.data.env, - &mut ccx.data.journaled_state, + &mut ccx.ecx.env, + &mut ccx.ecx.journaled_state, )?; Ok(Default::default()) } @@ -98,11 +98,11 @@ impl Cheatcode for rollFork_2Call { impl Cheatcode for rollFork_3Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, txHash } = self; - ccx.data.db.roll_fork_to_transaction( + ccx.ecx.db.roll_fork_to_transaction( Some(*forkId), *txHash, - ccx.data.env, - &mut ccx.data.journaled_state, + &mut ccx.ecx.env, + &mut ccx.ecx.journaled_state, )?; Ok(Default::default()) } @@ -117,7 +117,7 @@ impl Cheatcode for selectForkCall { // fork. ccx.state.corrected_nonce = true; - ccx.data.db.select_fork(*forkId, ccx.data.env, &mut ccx.data.journaled_state)?; + ccx.ecx.db.select_fork(*forkId, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state)?; Ok(Default::default()) } } @@ -125,11 +125,11 @@ impl Cheatcode for selectForkCall { impl Cheatcode for transact_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { txHash } = *self; - ccx.data.db.transact( + ccx.ecx.db.transact( None, txHash, - ccx.data.env, - &mut ccx.data.journaled_state, + &mut ccx.ecx.env, + &mut ccx.ecx.journaled_state, ccx.state, )?; Ok(Default::default()) @@ -139,11 +139,11 @@ impl Cheatcode for transact_0Call { impl Cheatcode for transact_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, txHash } = *self; - ccx.data.db.transact( + ccx.ecx.db.transact( Some(forkId), txHash, - ccx.data.env, - &mut ccx.data.journaled_state, + &mut ccx.ecx.env, + &mut ccx.ecx.journaled_state, ccx.state, )?; Ok(Default::default()) @@ -153,7 +153,7 @@ impl Cheatcode for transact_1Call { impl Cheatcode for allowCheatcodesCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; - ccx.data.db.allow_cheatcode_access(*account); + ccx.ecx.db.allow_cheatcode_access(*account); Ok(Default::default()) } } @@ -161,7 +161,7 @@ impl Cheatcode for allowCheatcodesCall { impl Cheatcode for makePersistent_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; - ccx.data.db.add_persistent_account(*account); + ccx.ecx.db.add_persistent_account(*account); Ok(Default::default()) } } @@ -169,8 +169,8 @@ impl Cheatcode for makePersistent_0Call { impl Cheatcode for makePersistent_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account0, account1 } = self; - ccx.data.db.add_persistent_account(*account0); - ccx.data.db.add_persistent_account(*account1); + ccx.ecx.db.add_persistent_account(*account0); + ccx.ecx.db.add_persistent_account(*account1); Ok(Default::default()) } } @@ -178,9 +178,9 @@ impl Cheatcode for makePersistent_1Call { impl Cheatcode for makePersistent_2Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account0, account1, account2 } = self; - ccx.data.db.add_persistent_account(*account0); - ccx.data.db.add_persistent_account(*account1); - ccx.data.db.add_persistent_account(*account2); + ccx.ecx.db.add_persistent_account(*account0); + ccx.ecx.db.add_persistent_account(*account1); + ccx.ecx.db.add_persistent_account(*account2); Ok(Default::default()) } } @@ -188,7 +188,7 @@ impl Cheatcode for makePersistent_2Call { impl Cheatcode for makePersistent_3Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { accounts } = self; - ccx.data.db.extend_persistent_accounts(accounts.iter().copied()); + ccx.ecx.db.extend_persistent_accounts(accounts.iter().copied()); Ok(Default::default()) } } @@ -196,7 +196,7 @@ impl Cheatcode for makePersistent_3Call { impl Cheatcode for revokePersistent_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; - ccx.data.db.remove_persistent_account(account); + ccx.ecx.db.remove_persistent_account(account); Ok(Default::default()) } } @@ -204,7 +204,7 @@ impl Cheatcode for revokePersistent_0Call { impl Cheatcode for revokePersistent_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { accounts } = self; - ccx.data.db.remove_persistent_accounts(accounts.iter().copied()); + ccx.ecx.db.remove_persistent_accounts(accounts.iter().copied()); Ok(Default::default()) } } @@ -212,7 +212,7 @@ impl Cheatcode for revokePersistent_1Call { impl Cheatcode for isPersistentCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; - Ok(ccx.data.db.is_persistent(account).abi_encode()) + Ok(ccx.ecx.db.is_persistent(account).abi_encode()) } } @@ -220,7 +220,7 @@ impl Cheatcode for rpcCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { method, params } = self; let url = - ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; + ccx.ecx.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; let method: &'static str = Box::new(method.clone()).leak(); let params_json: serde_json::Value = serde_json::from_str(params)?; @@ -248,7 +248,7 @@ impl Cheatcode for eth_getLogsCall { } let url = - ccx.data.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; + ccx.ecx.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; let mut filter = Filter::new().address(*target).from_block(from_block).to_block(to_block); for (i, topic) in topics.iter().enumerate() { @@ -302,7 +302,7 @@ fn create_select_fork( ccx.state.corrected_nonce = true; let fork = create_fork_request(ccx, url_or_alias, block)?; - let id = ccx.data.db.create_select_fork(fork, ccx.data.env, &mut ccx.data.journaled_state)?; + let id = ccx.ecx.db.create_select_fork(fork, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state)?; Ok(id.abi_encode()) } @@ -313,7 +313,7 @@ fn create_fork( block: Option, ) -> Result { let fork = create_fork_request(ccx, url_or_alias, block)?; - let id = ccx.data.db.create_fork(fork)?; + let id = ccx.ecx.db.create_fork(fork)?; Ok(id.abi_encode()) } @@ -329,10 +329,10 @@ fn create_select_fork_at_transaction( ccx.state.corrected_nonce = true; let fork = create_fork_request(ccx, url_or_alias, None)?; - let id = ccx.data.db.create_select_fork_at_transaction( + let id = ccx.ecx.db.create_select_fork_at_transaction( fork, - ccx.data.env, - &mut ccx.data.journaled_state, + &mut ccx.ecx.env, + &mut ccx.ecx.journaled_state, *transaction, )?; Ok(id.abi_encode()) @@ -345,7 +345,7 @@ fn create_fork_at_transaction( transaction: &B256, ) -> Result { let fork = create_fork_request(ccx, url_or_alias, None)?; - let id = ccx.data.db.create_fork_at_transaction(fork, *transaction)?; + let id = ccx.ecx.db.create_fork_at_transaction(fork, *transaction)?; Ok(id.abi_encode()) } @@ -361,7 +361,7 @@ fn create_fork_request( let fork = CreateFork { enable_caching: ccx.state.config.rpc_storage_caching.enable_for_endpoint(&url), url, - env: ccx.data.env.clone(), + env: (*ccx.ecx.env).clone(), evm_opts, }; Ok(fork) diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 1fa55539e8bed..645c14c58c82b 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -49,14 +49,15 @@ impl Cheatcode for clearMockedCallsCall { impl Cheatcode for mockCall_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; - let (acc, _) = ccx.data.journaled_state.load_account(*callee, ccx.data.db)?; + // TODO: use ecx.load_account + let (acc, _) = ccx.ecx.journaled_state.load_account(*callee, &mut ccx.ecx.db)?; // Etches a single byte onto the account if it is empty to circumvent the `extcodesize` // check Solidity might perform. let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty); if empty_bytecode { let code = Bytecode::new_raw(Bytes::from_static(&[0u8])).to_checked(); - ccx.data.journaled_state.set_code(*callee, code); + ccx.ecx.journaled_state.set_code(*callee, code); } mock_call(ccx.state, callee, data, None, returnData, InstructionResult::Return); @@ -67,7 +68,7 @@ impl Cheatcode for mockCall_0Call { impl Cheatcode for mockCall_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, msgValue, data, returnData } = self; - ccx.data.journaled_state.load_account(*callee, ccx.data.db)?; + ccx.ecx.load_account(*callee)?; mock_call(ccx.state, callee, data, Some(msgValue), returnData, InstructionResult::Return); Ok(Default::default()) } diff --git a/crates/cheatcodes/src/evm/prank.rs b/crates/cheatcodes/src/evm/prank.rs index 73269b23d11b0..3e1452d4236db 100644 --- a/crates/cheatcodes/src/evm/prank.rs +++ b/crates/cheatcodes/src/evm/prank.rs @@ -96,10 +96,10 @@ fn prank( ) -> Result { let prank = Prank::new( ccx.caller, - ccx.data.env.tx.caller, + ccx.ecx.env.tx.caller, *new_caller, new_origin.copied(), - ccx.data.journaled_state.depth(), + ccx.ecx.journaled_state.depth(), single_call, ); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index f6627114f5c9a..3396fc876e214 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -15,7 +15,7 @@ use crate::{ CheatsConfig, CheatsCtxt, Error, Result, Vm, Vm::AccountAccess, }; -use alloy_primitives::{Address, Bytes, B256, U256, U64}; +use alloy_primitives::{Address, Bytes, Log, B256, U256, U64}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl}; @@ -26,10 +26,11 @@ use foundry_evm_core::{ use itertools::Itertools; use revm::{ interpreter::{ - opcode, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, Interpreter, + opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, + InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, primitives::{BlockEnv, CreateScheme, TransactTo}, - EVMData, Inspector, + EvmContext, Inspector, }; use serde_json::Value; use std::{ @@ -216,7 +217,7 @@ impl Cheatcodes { fn apply_cheatcode( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, call: &CallInputs, ) -> Result { // decode the cheatcode call @@ -225,9 +226,9 @@ impl Cheatcodes { // ensure the caller is allowed to execute cheatcodes, // but only if the backend is in forking mode - data.db.ensure_cheatcode_access_forking_mode(&caller)?; + ecx.db.ensure_cheatcode_access_forking_mode(&caller)?; - apply_dispatch(&decoded, &mut CheatsCtxt { state: self, data, caller }) + apply_dispatch(&decoded, &mut CheatsCtxt { state: self, ecx, caller }) } /// Determines the address of the contract and marks it as allowed @@ -237,10 +238,10 @@ impl Cheatcodes { /// automatically we need to determine the new address fn allow_cheatcodes_on_create( &self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, inputs: &CreateInputs, ) -> Address { - let old_nonce = data + let old_nonce = ecx .journaled_state .state .get(&inputs.caller) @@ -248,13 +249,13 @@ impl Cheatcodes { .unwrap_or_default(); let created_address = inputs.created_address(old_nonce); - if data.journaled_state.depth > 1 && !data.db.has_cheatcode_access(&inputs.caller) { + if ecx.journaled_state.depth > 1 && !ecx.db.has_cheatcode_access(&inputs.caller) { // we only grant cheat code access for new contracts if the caller also has // cheatcode access and the new contract is created in top most call return created_address; } - data.db.allow_cheatcode_access(created_address); + ecx.db.allow_cheatcode_access(created_address); created_address } @@ -263,7 +264,7 @@ impl Cheatcodes { /// /// Cleanup any previously applied cheatcodes that altered the state in such a way that revm's /// revert would run into issues. - pub fn on_revert(&mut self, data: &mut EVMData<'_, DB>) { + pub fn on_revert(&mut self, ecx: &mut EvmContext) { trace!(deals=?self.eth_deals.len(), "rolling back deals"); // Delay revert clean up until expected revert is handled, if set. @@ -272,7 +273,7 @@ impl Cheatcodes { } // we only want to apply cleanup top level - if data.journaled_state.depth() > 0 { + if ecx.journaled_state.depth() > 0 { return; } @@ -280,7 +281,7 @@ impl Cheatcodes { // This will prevent overflow issues in revm's [`JournaledState::journal_revert`] routine // which rolls back any transfers. while let Some(record) = self.eth_deals.pop() { - if let Some(acc) = data.journaled_state.state.get_mut(&record.address) { + if let Some(acc) = ecx.journaled_state.state.get_mut(&record.address) { acc.info.balance = record.old_balance; } } @@ -289,18 +290,18 @@ impl Cheatcodes { impl Inspector for Cheatcodes { #[inline] - fn initialize_interp(&mut self, _: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + fn initialize_interp(&mut self, _: &mut Interpreter, ecx: &mut EvmContext) { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. if let Some(block) = self.block.take() { - data.env.block = block; + ecx.env.block = block; } if let Some(gas_price) = self.gas_price.take() { - data.env.tx.gas_price = gas_price; + ecx.env.tx.gas_price = gas_price; } } - fn step(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { self.pc = interpreter.program_counter(); // reset gas if gas metering is turned off @@ -395,26 +396,25 @@ impl Inspector for Cheatcodes { if interpreter.current_opcode() == opcode::SELFDESTRUCT { let target = try_or_continue!(interpreter.stack().peek(0)); // load balance of this account - let value = if let Ok((account, _)) = - data.journaled_state.load_account(interpreter.contract().address, data.db) + let value = ecx + .balance(interpreter.contract().address) + .map(|(b, _)| b) + .unwrap_or(U256::ZERO); + let account = Address::from_word(B256::from(target)); + // get previous balance and initialized status of the target account + // TODO: use load_account_exists + let (initialized, old_balance) = if let Ok((account, _)) = + ecx.journaled_state.load_account(account, &mut ecx.db) { - account.info.balance + (account.info.exists(), account.info.balance) } else { - U256::ZERO + (false, U256::ZERO) }; - let account = Address::from_word(B256::from(target)); - // get previous balance and initialized status of the target account - let (initialized, old_balance) = - if let Ok((account, _)) = data.journaled_state.load_account(account, data.db) { - (account.info.exists(), account.info.balance) - } else { - (false, U256::ZERO) - }; // register access for the target account let access = crate::Vm::AccountAccess { chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), }, accessor: interpreter.contract().address, account, @@ -427,7 +427,7 @@ impl Inspector for Cheatcodes { reverted: false, deployedCode: vec![], storageAccesses: vec![], - depth: data.journaled_state.depth(), + depth: ecx.journaled_state.depth(), }; // Ensure that we're not selfdestructing a context recording was initiated on if let Some(last) = account_accesses.last_mut() { @@ -447,9 +447,8 @@ impl Inspector for Cheatcodes { // it's not set (zero value) let mut present_value = U256::ZERO; // Try to load the account and the slot's present value - if data.journaled_state.load_account(address, data.db).is_ok() { - if let Ok((previous, _)) = data.journaled_state.sload(address, key, data.db) - { + if ecx.load_account(address).is_ok() { + if let Ok((previous, _)) = ecx.sload(address, key) { present_value = previous; } } @@ -464,7 +463,7 @@ impl Inspector for Cheatcodes { append_storage_access( recorded_account_diffs_stack, access, - data.journaled_state.depth(), + ecx.journaled_state.depth(), ); } opcode::SSTORE => { @@ -474,9 +473,8 @@ impl Inspector for Cheatcodes { // Try to load the account and the slot's previous value, otherwise, assume it's // not set (zero value) let mut previous_value = U256::ZERO; - if data.journaled_state.load_account(address, data.db).is_ok() { - if let Ok((previous, _)) = data.journaled_state.sload(address, key, data.db) - { + if ecx.load_account(address).is_ok() { + if let Ok((previous, _)) = ecx.sload(address, key) { previous_value = previous; } } @@ -492,7 +490,7 @@ impl Inspector for Cheatcodes { append_storage_access( recorded_account_diffs_stack, access, - data.journaled_state.depth(), + ecx.journaled_state.depth(), ); } // Record account accesses via the EXT family of opcodes @@ -512,7 +510,8 @@ impl Inspector for Cheatcodes { .peek(0)))); let balance; let initialized; - if let Ok((acc, _)) = data.journaled_state.load_account(address, data.db) { + // TODO: use ecx.load_account + if let Ok((acc, _)) = ecx.journaled_state.load_account(address, &mut ecx.db) { initialized = acc.info.exists(); balance = acc.info.balance; } else { @@ -521,8 +520,8 @@ impl Inspector for Cheatcodes { } let account_access = crate::Vm::AccountAccess { chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), }, accessor: interpreter.contract().address, account: address, @@ -535,7 +534,7 @@ impl Inspector for Cheatcodes { reverted: false, deployedCode: vec![], storageAccesses: vec![], - depth: data.journaled_state.depth(), + depth: ecx.journaled_state.depth(), }; // Record the EXT* call as an account access at the current depth // (future storage accesses will be recorded in a new "Resume" context) @@ -553,7 +552,7 @@ impl Inspector for Cheatcodes { // if the current opcode can either mutate directly or expand memory. If the opcode at // the current program counter is a match, check if the modified memory lies within the // allowed ranges. If not, revert and fail the test. - if let Some(ranges) = self.allowed_mem_writes.get(&data.journaled_state.depth()) { + if let Some(ranges) = self.allowed_mem_writes.get(&ecx.journaled_state.depth()) { // The `mem_opcode_match` macro is used to match the current opcode against a list of // opcodes that can mutate memory (either directly or expansion via reading). If the // opcode is a match, the memory offsets that are being written to are checked to be @@ -579,7 +578,6 @@ impl Inspector for Cheatcodes { range.contains(&offset) && range.contains(&(offset + 31)) }) { disallowed_mem_write(offset, 32, interpreter, ranges); - interpreter.instruction_result = InstructionResult::Revert; return } } @@ -591,7 +589,6 @@ impl Inspector for Cheatcodes { // unexpectedly mutated. if !ranges.iter().any(|range| range.contains(&offset)) { disallowed_mem_write(offset, 1, interpreter, ranges); - interpreter.instruction_result = InstructionResult::Revert; return } } @@ -611,7 +608,6 @@ impl Inspector for Cheatcodes { range.contains(&offset) && range.contains(&(offset + 31)) }) { disallowed_mem_write(offset, 32, interpreter, ranges); - interpreter.instruction_result = InstructionResult::Revert; return } } @@ -643,7 +639,6 @@ impl Inspector for Cheatcodes { // that gives information about the allowed ranges and revert. if fail_cond { disallowed_mem_write(dest_offset, size, interpreter, ranges); - interpreter.instruction_result = InstructionResult::Revert; return } })* @@ -682,37 +677,47 @@ impl Inspector for Cheatcodes { } } - fn log(&mut self, _: &mut EVMData<'_, DB>, address: &Address, topics: &[B256], data: &Bytes) { + fn log(&mut self, _context: &mut EvmContext, log: &Log) { if !self.expected_emits.is_empty() { - expect::handle_expect_emit(self, address, topics, data); + expect::handle_expect_emit(self, log); } // Stores this log if `recordLogs` has been called if let Some(storage_recorded_logs) = &mut self.recorded_logs { storage_recorded_logs.push(Vm::Log { - topics: topics.to_vec(), - data: data.to_vec(), - emitter: *address, + topics: log.data.topics().to_vec(), + data: log.data.data.to_vec(), + emitter: log.address, }); } } - fn call( - &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { + fn call(&mut self, ecx: &mut EvmContext, call: &mut CallInputs) -> Option { let gas = Gas::new(call.gas_limit); if call.contract == CHEATCODE_ADDRESS { - return match self.apply_cheatcode(data, call) { - Ok(retdata) => (InstructionResult::Return, gas, retdata.into()), - Err(err) => (InstructionResult::Revert, gas, err.abi_encode().into()), + return match self.apply_cheatcode(ecx, call) { + Ok(retdata) => Some(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Return, + output: retdata.into(), + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }), + Err(err) => Some(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: err.abi_encode().into(), + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }), }; } if call.contract == HARDHAT_CONSOLE_ADDRESS { - return (InstructionResult::Continue, gas, Bytes::new()); + return None } // Handle expected calls @@ -755,19 +760,26 @@ impl Inspector for Cheatcodes { }) .map(|(_, v)| v) }) { - return (return_data.ret_type, gas, return_data.data.clone()); + return Some(CallOutcome { + result: InterpreterResult { + result: return_data.ret_type, + output: return_data.data.clone(), + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }) } } // Apply our prank if let Some(prank) = &self.prank { - if data.journaled_state.depth() >= prank.depth && + if ecx.journaled_state.depth() >= prank.depth && call.context.caller == prank.prank_caller { let mut prank_applied = false; // At the target depth we set `msg.sender` - if data.journaled_state.depth() == prank.depth { + if ecx.journaled_state.depth() == prank.depth { call.context.caller = prank.new_caller; call.transfer.source = prank.new_caller; prank_applied = true; @@ -775,7 +787,7 @@ impl Inspector for Cheatcodes { // At the target depth, or deeper, we set `tx.origin` if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = new_origin; + ecx.env.tx.caller = new_origin; prank_applied = true; } @@ -794,13 +806,13 @@ impl Inspector for Cheatcodes { // // We do this because any subsequent contract calls *must* exist on chain and // we only want to grab *this* call, not internal ones - if data.journaled_state.depth() == broadcast.depth && + if ecx.journaled_state.depth() == broadcast.depth && call.context.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 // broadcast.origin. - data.env.tx.caller = broadcast.new_origin; + ecx.env.tx.caller = broadcast.new_origin; call.context.caller = broadcast.new_origin; call.transfer.source = broadcast.new_origin; @@ -809,19 +821,24 @@ impl Inspector for Cheatcodes { // into 1559, in the cli package, relatively easily once we // know the target chain supports EIP-1559. if !call.is_static { - if let Err(err) = - data.journaled_state.load_account(broadcast.new_origin, data.db) - { - return (InstructionResult::Revert, gas, Error::encode(err)); + if let Err(err) = ecx.load_account(broadcast.new_origin) { + return Some(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: Error::encode(err), + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }) } - let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); + let is_fixed_gas_limit = check_if_fixed_gas_limit(ecx, call.gas_limit); let account = - data.journaled_state.state().get_mut(&broadcast.new_origin).unwrap(); + ecx.journaled_state.state().get_mut(&broadcast.new_origin).unwrap(); self.broadcastable_transactions.push_back(BroadcastableTransaction { - rpc: data.db.active_fork_url(), + rpc: ecx.db.active_fork_url(), transaction: TransactionRequest { from: Some(broadcast.new_origin), to: Some(call.contract), @@ -846,7 +863,14 @@ impl Inspector for Cheatcodes { debug!(target: "cheatcodes", address=%broadcast.new_origin, nonce=prev+1, prev, "incremented nonce"); } else if broadcast.single_call { let msg = "`staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead"; - return (InstructionResult::Revert, Gas::new(0), Error::encode(msg)); + return Some(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: Error::encode(msg), + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }) } } } @@ -857,7 +881,8 @@ impl Inspector for Cheatcodes { // nonce, a non-zero KECCAK_EMPTY codehash, or non-empty code let initialized; let old_balance; - if let Ok((acc, _)) = data.journaled_state.load_account(call.contract, data.db) { + // TODO: use ecx.load_account + if let Ok((acc, _)) = ecx.journaled_state.load_account(call.contract, &mut ecx.db) { initialized = acc.info.exists(); old_balance = acc.info.balance; } else { @@ -877,8 +902,8 @@ impl Inspector for Cheatcodes { // as "warm" if the call from which they were accessed is reverted recorded_account_diffs_stack.push(vec![AccountAccess { chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), }, accessor: call.context.caller, account: call.contract, @@ -891,21 +916,19 @@ impl Inspector for Cheatcodes { reverted: false, deployedCode: vec![], storageAccesses: vec![], // updated on step - depth: data.journaled_state.depth(), + depth: ecx.journaled_state.depth(), }]); } - (InstructionResult::Continue, gas, Bytes::new()) + None } fn call_end( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, call: &CallInputs, - remaining_gas: Gas, - status: InstructionResult, - retdata: Bytes, - ) -> (InstructionResult, Gas, Bytes) { + mut outcome: CallOutcome, + ) -> CallOutcome { let cheatcode_call = call.contract == CHEATCODE_ADDRESS || call.contract == HARDHAT_CONSOLE_ADDRESS; @@ -915,8 +938,8 @@ impl Inspector for Cheatcodes { if !cheatcode_call { // Clean up pranks if let Some(prank) = &self.prank { - if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = prank.prank_origin; + if ecx.journaled_state.depth() == prank.depth { + ecx.env.tx.caller = prank.prank_origin; // Clean single-call prank once we have returned to the original depth if prank.single_call { @@ -927,8 +950,8 @@ impl Inspector for Cheatcodes { // Clean up broadcast if let Some(broadcast) = &self.broadcast { - if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = broadcast.original_origin; + if ecx.journaled_state.depth() == broadcast.depth { + ecx.env.tx.caller = broadcast.original_origin; // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { @@ -940,7 +963,7 @@ impl Inspector for Cheatcodes { // Handle expected reverts if let Some(expected_revert) = &self.expected_revert { - if data.journaled_state.depth() <= expected_revert.depth { + if ecx.journaled_state.depth() <= expected_revert.depth { let needs_processing: bool = match expected_revert.kind { ExpectedRevertKind::Default => !cheatcode_call, // `pending_processing` == true means that we're in the `call_end` hook for @@ -955,14 +978,20 @@ impl Inspector for Cheatcodes { return match expect::handle_expect_revert( false, expected_revert.reason.as_deref(), - status, - retdata, + outcome.result.result, + outcome.result.output.clone(), ) { Err(error) => { - trace!(expected=?expected_revert, ?error, ?status, "Expected revert mismatch"); - (InstructionResult::Revert, remaining_gas, error.abi_encode().into()) + trace!(expected=?expected_revert, ?error, status=?outcome.result.result, "Expected revert mismatch"); + outcome.result.result = InstructionResult::Revert; + outcome.result.output = error.abi_encode().into(); + outcome + } + Ok((_, retdata)) => { + outcome.result.result = InstructionResult::Return; + outcome.result.output = retdata; + outcome } - Ok((_, retdata)) => (InstructionResult::Return, remaining_gas, retdata), }; } @@ -981,19 +1010,19 @@ impl Inspector for Cheatcodes { // Exit early for calls to cheatcodes as other logic is not relevant for cheatcode // invocations if cheatcode_call { - return (status, remaining_gas, retdata); + return outcome; } // If `startStateDiffRecording` has been called, update the `reverted` status of the // previous call depth's recorded accesses, if any if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { // The root call cannot be recorded. - if data.journaled_state.depth() > 0 { + if ecx.journaled_state.depth() > 0 { let mut last_recorded_depth = recorded_account_diffs_stack.pop().expect("missing CALL account accesses"); // Update the reverted status of all deeper calls if this call reverted, in // accordance with EVM behavior - if status.is_revert() { + if outcome.result.is_revert() { last_recorded_depth.iter_mut().for_each(|element| { element.reverted = true; element @@ -1006,8 +1035,10 @@ impl Inspector for Cheatcodes { // Assert that we're at the correct depth before recording post-call state changes. // Depending on the depth the cheat was called at, there may not be any pending // calls to update if execution has percolated up to a higher depth. - if call_access.depth == data.journaled_state.depth() { - if let Ok((acc, _)) = data.journaled_state.load_account(call.contract, data.db) + if call_access.depth == ecx.journaled_state.depth() { + // TODO: use ecx.load_account + if let Ok((acc, _)) = + ecx.journaled_state.load_account(call.contract, &mut ecx.db) { debug_assert!(access_is_call(call_access.kind)); call_access.newBalance = acc.info.balance; @@ -1038,17 +1069,15 @@ impl Inspector for Cheatcodes { let should_check_emits = self .expected_emits .iter() - .any(|expected| expected.depth == data.journaled_state.depth()) && + .any(|expected| expected.depth == ecx.journaled_state.depth()) && // Ignore staticcalls !call.is_static; if should_check_emits { // Not all emits were matched. if self.expected_emits.iter().any(|expected| !expected.found) { - return ( - InstructionResult::Revert, - remaining_gas, - "log != expected log".abi_encode().into(), - ); + outcome.result.result = InstructionResult::Revert; + outcome.result.output = "log != expected log".abi_encode().into(); + return outcome } else { // All emits were found, we're good. // Clear the queue, as we expect the user to declare more events for the next call @@ -1063,33 +1092,34 @@ impl Inspector for Cheatcodes { // if there's a revert and a previous call was diagnosed as fork related revert then we can // return a better error here - if status == InstructionResult::Revert { + if outcome.result.is_revert() { if let Some(err) = diag { - return (status, remaining_gas, Error::encode(err.to_error_msg(&self.labels))); + outcome.result.output = Error::encode(err.to_error_msg(&self.labels)); + return outcome } } // try to diagnose reverts in multi-fork mode where a call is made to an address that does // not exist - if let TransactTo::Call(test_contract) = data.env.tx.transact_to { + if let TransactTo::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 data.db.is_forked_mode() && - status == InstructionResult::Stop && + if ecx.db.is_forked_mode() && + outcome.result.result == InstructionResult::Stop && call.contract != test_contract { self.fork_revert_diagnostic = - data.db.diagnose_revert(call.contract, &data.journaled_state); + ecx.db.diagnose_revert(call.contract, &ecx.journaled_state); } } // If the depth is 0, then this is the root call terminating - if data.journaled_state.depth() == 0 { + if ecx.journaled_state.depth() == 0 { // If we already have a revert, we shouldn't run the below logic as it can obfuscate an // earlier error that happened first with unrelated information about // another error when using cheatcodes. - if status == InstructionResult::Revert { - return (status, remaining_gas, retdata); + if outcome.result.is_revert() { + return outcome; } // If there's not a revert, we can continue on to run the last logic for expect* @@ -1121,7 +1151,7 @@ impl Inspector for Cheatcodes { .into_iter() .flatten() .join(", "); - let but = if status.is_ok() { + let but = if outcome.result.is_ok() { let s = if *actual_count == 1 { "" } else { "s" }; format!("was called {actual_count} time{s}") } else { @@ -1134,7 +1164,10 @@ impl Inspector for Cheatcodes { "expected call to {address} with {expected_values} \ to be called {count} time{s}, but {but}" ); - return (InstructionResult::Revert, remaining_gas, Error::encode(msg)); + outcome.result.result = InstructionResult::Revert; + outcome.result.output = Error::encode(msg); + + return outcome; } } } @@ -1144,64 +1177,75 @@ impl Inspector for Cheatcodes { self.expected_emits.retain(|expected| !expected.found); // If not empty, we got mismatched emits if !self.expected_emits.is_empty() { - let msg = if status.is_ok() { + let msg = if outcome.result.is_ok() { "expected an emit, but no logs were emitted afterwards. \ you might have mismatched events or not enough events were emitted" } else { "expected an emit, but the call reverted instead. \ ensure you're testing the happy path when using `expectEmit`" }; - return (InstructionResult::Revert, remaining_gas, Error::encode(msg)); + outcome.result.result = InstructionResult::Revert; + outcome.result.output = Error::encode(msg); + return outcome; } } - (status, remaining_gas, retdata) + outcome } fn create( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, call: &mut CreateInputs, - ) -> (InstructionResult, Option
, Gas, Bytes) { + ) -> Option { let gas = Gas::new(call.gas_limit); // Apply our prank if let Some(prank) = &self.prank { - if data.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { + if ecx.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { // At the target depth we set `msg.sender` - if data.journaled_state.depth() == prank.depth { + if ecx.journaled_state.depth() == prank.depth { call.caller = prank.new_caller; } // At the target depth, or deeper, we set `tx.origin` if let Some(new_origin) = prank.new_origin { - data.env.tx.caller = new_origin; + ecx.env.tx.caller = new_origin; } } } // Apply our broadcast if let Some(broadcast) = &self.broadcast { - if data.journaled_state.depth() >= broadcast.depth && + if ecx.journaled_state.depth() >= broadcast.depth && call.caller == broadcast.original_caller { - if let Err(err) = data.journaled_state.load_account(broadcast.new_origin, data.db) { - return (InstructionResult::Revert, None, gas, Error::encode(err)); + if let Err(err) = + ecx.journaled_state.load_account(broadcast.new_origin, &mut ecx.db) + { + return Some(CreateOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: Error::encode(err), + gas, + }, + address: None, + }) } - data.env.tx.caller = broadcast.new_origin; + ecx.env.tx.caller = broadcast.new_origin; - if data.journaled_state.depth() == broadcast.depth { + if ecx.journaled_state.depth() == broadcast.depth { let (bytecode, to, nonce) = process_broadcast_create( broadcast.new_origin, call.init_code.clone(), - data, + ecx, call, ); - let is_fixed_gas_limit = check_if_fixed_gas_limit(data, call.gas_limit); + let is_fixed_gas_limit = check_if_fixed_gas_limit(ecx, call.gas_limit); self.broadcastable_transactions.push_back(BroadcastableTransaction { - rpc: data.db.active_fork_url(), + rpc: ecx.db.active_fork_url(), transaction: TransactionRequest { from: Some(broadcast.new_origin), to, @@ -1228,26 +1272,35 @@ impl Inspector for Cheatcodes { // Apply the Create2 deployer if self.broadcast.is_some() || self.config.always_use_create_2_factory { match apply_create2_deployer( - data, + ecx, call, self.prank.as_ref(), self.broadcast.as_ref(), self.recorded_account_diffs_stack.as_mut(), ) { Ok(_) => {} - Err(err) => return (InstructionResult::Revert, None, gas, Error::encode(err)), + Err(err) => { + return Some(CreateOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: Error::encode(err), + gas, + }, + address: None, + }) + } }; } // allow cheatcodes from the address of the new contract // Compute the address *after* any possible broadcast updates, so it's based on the updated // call inputs - let address = self.allow_cheatcodes_on_create(data, call); + let address = self.allow_cheatcodes_on_create(ecx, call); // If `recordAccountAccesses` has been called, record the create if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { // If the create scheme is create2, and the caller is the DEFAULT_CREATE2_DEPLOYER then // we must add 1 to the depth to account for the call to the create2 factory. - let mut depth = data.journaled_state.depth(); + let mut depth = ecx.journaled_state.depth(); if let CreateScheme::Create2 { salt: _ } = call.scheme { if call.caller == DEFAULT_CREATE2_DEPLOYER { depth += 1; @@ -1258,8 +1311,8 @@ impl Inspector for Cheatcodes { // subsequent account accesses recorded_account_diffs_stack.push(vec![AccountAccess { chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), }, accessor: call.caller, account: address, @@ -1276,22 +1329,19 @@ impl Inspector for Cheatcodes { }]); } - (InstructionResult::Continue, None, gas, Bytes::new()) + None } fn create_end( &mut self, - data: &mut EVMData<'_, DB>, - _: &CreateInputs, - status: InstructionResult, - address: Option
, - remaining_gas: Gas, - retdata: Bytes, - ) -> (InstructionResult, Option
, Gas, Bytes) { + ecx: &mut EvmContext, + _call: &CreateInputs, + mut outcome: CreateOutcome, + ) -> CreateOutcome { // Clean up pranks if let Some(prank) = &self.prank { - if data.journaled_state.depth() == prank.depth { - data.env.tx.caller = prank.prank_origin; + if ecx.journaled_state.depth() == prank.depth { + ecx.env.tx.caller = prank.prank_origin; // Clean single-call prank once we have returned to the original depth if prank.single_call { @@ -1302,8 +1352,8 @@ impl Inspector for Cheatcodes { // Clean up broadcasts if let Some(broadcast) = &self.broadcast { - if data.journaled_state.depth() == broadcast.depth { - data.env.tx.caller = broadcast.original_origin; + if ecx.journaled_state.depth() == broadcast.depth { + ecx.env.tx.caller = broadcast.original_origin; // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { @@ -1314,21 +1364,26 @@ impl Inspector for Cheatcodes { // Handle expected reverts if let Some(expected_revert) = &self.expected_revert { - if data.journaled_state.depth() <= expected_revert.depth && + if ecx.journaled_state.depth() <= expected_revert.depth && matches!(expected_revert.kind, ExpectedRevertKind::Default) { let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); return match expect::handle_expect_revert( true, expected_revert.reason.as_deref(), - status, - retdata, + outcome.result.result, + outcome.result.output.clone(), ) { Ok((address, retdata)) => { - (InstructionResult::Return, address, remaining_gas, retdata) + outcome.result.result = InstructionResult::Return; + outcome.result.output = retdata; + outcome.address = address; + outcome } Err(err) => { - (InstructionResult::Revert, None, remaining_gas, err.abi_encode().into()) + outcome.result.result = InstructionResult::Revert; + outcome.result.output = err.abi_encode().into(); + outcome } }; } @@ -1338,12 +1393,12 @@ impl Inspector for Cheatcodes { // previous call depth's recorded accesses, if any if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { // The root call cannot be recorded. - if data.journaled_state.depth() > 0 { + if ecx.journaled_state.depth() > 0 { let mut last_depth = recorded_account_diffs_stack.pop().expect("missing CREATE account accesses"); // Update the reverted status of all deeper calls if this call reverted, in // accordance with EVM behavior - if status.is_revert() { + if outcome.result.is_revert() { last_depth.iter_mut().for_each(|element| { element.reverted = true; element @@ -1357,14 +1412,14 @@ impl Inspector for Cheatcodes { // changes. Depending on what depth the cheat was called at, there // may not be any pending calls to update if execution has // percolated up to a higher depth. - if create_access.depth == data.journaled_state.depth() { + if create_access.depth == ecx.journaled_state.depth() { debug_assert_eq!( create_access.kind as u8, crate::Vm::AccountAccessKind::Create as u8 ); - if let Some(address) = address { + if let Some(address) = outcome.address { if let Ok((created_acc, _)) = - data.journaled_state.load_account(address, data.db) + ecx.journaled_state.load_account(address, &mut ecx.db) { create_access.newBalance = created_acc.info.balance; create_access.deployedCode = created_acc @@ -1388,36 +1443,36 @@ impl Inspector for Cheatcodes { } } - (status, address, remaining_gas, retdata) + outcome } } /// Helper that expands memory, stores a revert string pertaining to a disallowed memory write, /// and sets the return range to the revert string's location in memory. +/// +/// This will set the interpreter's next action to a return with the revert string as the output. +/// And trigger a revert. fn disallowed_mem_write( dest_offset: u64, size: u64, - interpreter: &mut Interpreter<'_>, + interpreter: &mut Interpreter, ranges: &[Range], ) { let revert_string = format!( "memory write at offset 0x{:02X} of size 0x{:02X} not allowed; safe range: {}", dest_offset, size, - ranges.iter().map(|r| format!("(0x{:02X}, 0x{:02X}]", r.start, r.end)).join(" ∪ ") - ) - .abi_encode(); - mstore_revert_string(interpreter, &revert_string); -} - -/// Expands memory, stores a revert string, and sets the return range to the revert -/// string's location in memory. -fn mstore_revert_string(interpreter: &mut Interpreter<'_>, bytes: &[u8]) { - let starting_offset = interpreter.shared_memory.len(); - interpreter.shared_memory.resize(starting_offset + bytes.len()); - interpreter.shared_memory.set_data(starting_offset, 0, bytes.len(), bytes); - interpreter.return_offset = starting_offset; - interpreter.return_len = interpreter.shared_memory.len() - starting_offset + ranges.iter().map(|r| format!("(0x{:02X}, 0x{:02X}]", r.start, r.end)).join(" U ") + ); + + interpreter.instruction_result = InstructionResult::Revert; + interpreter.next_action = InterpreterAction::Return { + result: InterpreterResult { + output: Error::encode(revert_string), + gas: interpreter.gas, + result: InstructionResult::Revert, + }, + }; } /// Applies the default CREATE2 deployer for contract creation. @@ -1430,7 +1485,7 @@ fn mstore_revert_string(interpreter: &mut Interpreter<'_>, bytes: &[u8]) { /// Returns a `DatabaseError::MissingCreate2Deployer` if the `DEFAULT_CREATE2_DEPLOYER` account is /// not found or if it does not have any associated bytecode. fn apply_create2_deployer( - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, call: &mut CreateInputs, prank: Option<&Prank>, broadcast: Option<&Broadcast>, @@ -1446,14 +1501,14 @@ fn apply_create2_deployer( // If the create scheme is Create2 and the depth equals the broadcast/prank/default // depth, then use the default create2 factory as the deployer - if data.journaled_state.depth() == base_depth { + if ecx.journaled_state.depth() == base_depth { // Record the call to the create2 factory in the state diff if let Some(recorded_account_diffs_stack) = diffs_stack { let calldata = [&salt.to_be_bytes::<32>()[..], &call.init_code[..]].concat(); recorded_account_diffs_stack.push(vec![AccountAccess { chainInfo: crate::Vm::ChainInfo { - forkId: data.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(data.env.cfg.chain_id), + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), }, accessor: call.caller, account: DEFAULT_CREATE2_DEPLOYER, @@ -1466,16 +1521,17 @@ fn apply_create2_deployer( reverted: false, deployedCode: vec![], // updated on create_end storageAccesses: vec![], // updated on create_end - depth: data.journaled_state.depth(), + depth: ecx.journaled_state.depth(), }]) } // Sanity checks for our CREATE2 deployer + // TODO: use ecx.load_account let info = - &data.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, data.db)?.0.info; + &ecx.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, &mut ecx.db)?.0.info; match &info.code { Some(code) if code.is_empty() => return Err(DatabaseError::MissingCreate2Deployer), - None if data.db.code_by_hash(info.code_hash)?.is_empty() => { + None if ecx.db.code_by_hash(info.code_hash)?.is_empty() => { return Err(DatabaseError::MissingCreate2Deployer) } _ => {} @@ -1499,18 +1555,18 @@ fn apply_create2_deployer( fn process_broadcast_create( broadcast_sender: Address, bytecode: Bytes, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext, call: &mut CreateInputs, ) -> (Bytes, Option
, u64) { call.caller = broadcast_sender; match call.scheme { CreateScheme::Create => { - (bytecode, None, data.journaled_state.account(broadcast_sender).info.nonce) + (bytecode, None, ecx.journaled_state.account(broadcast_sender).info.nonce) } CreateScheme::Create2 { salt } => { // We have to increment the nonce of the user address, since this create2 will be done // by the create2_deployer - let account = data.journaled_state.state().get_mut(&broadcast_sender).unwrap(); + let account = ecx.journaled_state.state().get_mut(&broadcast_sender).unwrap(); let prev = account.info.nonce; // Touch account to ensure that incremented nonce is committed account.mark_touch(); @@ -1525,7 +1581,7 @@ fn process_broadcast_create( // Determines if the gas limit on a given call was manually set in the script and should therefore // not be overwritten by later estimations -fn check_if_fixed_gas_limit(data: &EVMData<'_, DB>, call_gas_limit: u64) -> bool { +fn check_if_fixed_gas_limit(data: &EvmContext, call_gas_limit: u64) -> bool { // If the gas limit was not set in the source code it is set to the estimated gas left at the // time of the call, which should be rather close to configured gas limit. // TODO: Find a way to reliably make this determination. diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index a2654e953ae86..a9dda80f92d99 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -11,25 +11,22 @@ pub extern crate foundry_cheatcodes_spec as spec; extern crate tracing; use alloy_primitives::Address; -use foundry_evm_core::backend::DatabaseExt; -use revm::EVMData; +use revm::EvmContext; +pub use config::CheatsConfig; +pub use error::{Error, ErrorKind, Result}; +use foundry_evm_core::backend::DatabaseExt; +pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; pub use spec::{CheatcodeDef, Vm}; #[macro_use] mod error; -pub use error::{Error, ErrorKind, Result}; - -mod config; -pub use config::CheatsConfig; - -mod inspector; -pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; - mod base64; +mod config; mod env; mod evm; mod fs; +mod inspector; mod json; mod script; mod string; @@ -112,18 +109,18 @@ impl DynCheatcode for T { } /// The cheatcode context, used in [`Cheatcode`]. -pub(crate) struct CheatsCtxt<'a, 'b, 'c, DB: DatabaseExt> { +pub(crate) struct CheatsCtxt<'a, 'b, DB: DatabaseExt> { /// The cheatcodes inspector state. pub(crate) state: &'a mut Cheatcodes, /// The EVM data. - pub(crate) data: &'b mut EVMData<'c, DB>, + pub(crate) ecx: &'b mut EvmContext, /// The original `msg.sender`. pub(crate) caller: Address, } -impl CheatsCtxt<'_, '_, '_, DB> { +impl CheatsCtxt<'_, '_, DB> { #[inline] pub(crate) fn is_precompile(&self, address: &Address) -> bool { - self.data.precompiles.contains(address) + self.ecx.precompiles.contains(address) } } diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 62a7518372579..4b3e6ba484029 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -145,10 +145,10 @@ fn broadcast( } let broadcast = Broadcast { - new_origin: new_origin.unwrap_or(ccx.data.env.tx.caller), + new_origin: new_origin.unwrap_or(ccx.ecx.env.tx.caller), original_caller: ccx.caller, - original_origin: ccx.data.env.tx.caller, - depth: ccx.data.journaled_state.depth(), + original_origin: ccx.ecx.env.tx.caller, + depth: ccx.ecx.journaled_state.depth(), single_call, }; debug!(target: "cheatcodes", ?broadcast, "started"); @@ -181,9 +181,9 @@ fn broadcast_key( /// That leads to its nonce being incremented by `call_raw`. In a `broadcast` scenario this is /// undesirable. Therefore, we make sure to fix the sender's nonce **once**. pub(super) fn correct_sender_nonce(ccx: &mut CheatsCtxt) -> Result<()> { - let sender = ccx.data.env.tx.caller; + let sender = ccx.ecx.env.tx.caller; if !ccx.state.corrected_nonce && sender != Config::DEFAULT_SENDER { - let account = super::evm::journaled_account(ccx.data, sender)?; + let account = super::evm::journaled_account(ccx.ecx, sender)?; let prev = account.info.nonce; account.info.nonce = prev.saturating_sub(1); debug!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 0d557db223291..18487c0aaa82e 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -69,7 +69,7 @@ impl Cheatcode for skipCall { if skipTest { // Skip should not work if called deeper than at test level. // Since we're not returning the magic skip bytes, this will cause a test failure. - ensure!(ccx.data.journaled_state.depth() <= 1, "`skip` can only be used at test level"); + ensure!(ccx.ecx.journaled_state.depth() <= 1, "`skip` can only be used at test level"); Err(MAGIC_SKIP.into()) } else { Ok(Default::default()) diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index e4cc34986f5b0..02c747adb2ffb 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,5 +1,5 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::{address, Address, Bytes, LogData as RawLog, B256, U256}; +use alloy_primitives::{address, Address, Bytes, LogData as RawLog, U256}; use alloy_sol_types::{SolError, SolValue}; use revm::interpreter::{return_ok, InstructionResult}; use spec::Vm; @@ -201,7 +201,7 @@ impl Cheatcode for expectEmit_0Call { let Self { checkTopic1, checkTopic2, checkTopic3, checkData } = *self; expect_emit( ccx.state, - ccx.data.journaled_state.depth(), + ccx.ecx.journaled_state.depth(), [checkTopic1, checkTopic2, checkTopic3, checkData], None, ) @@ -213,7 +213,7 @@ impl Cheatcode for expectEmit_1Call { let Self { checkTopic1, checkTopic2, checkTopic3, checkData, emitter } = *self; expect_emit( ccx.state, - ccx.data.journaled_state.depth(), + ccx.ecx.journaled_state.depth(), [checkTopic1, checkTopic2, checkTopic3, checkData], Some(emitter), ) @@ -223,69 +223,69 @@ impl Cheatcode for expectEmit_1Call { impl Cheatcode for expectEmit_2Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_emit(ccx.state, ccx.data.journaled_state.depth(), [true; 4], None) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 4], None) } } impl Cheatcode for expectEmit_3Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { emitter } = *self; - expect_emit(ccx.state, ccx.data.journaled_state.depth(), [true; 4], Some(emitter)) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 4], Some(emitter)) } } impl Cheatcode for expectRevert_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_revert(ccx.state, None, ccx.data.journaled_state.depth(), false) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false) } } impl Cheatcode for expectRevert_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData.as_ref()), ccx.data.journaled_state.depth(), false) + expect_revert(ccx.state, Some(revertData.as_ref()), ccx.ecx.journaled_state.depth(), false) } } impl Cheatcode for expectRevert_2Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData), ccx.data.journaled_state.depth(), false) + expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), false) } } impl Cheatcode for _expectCheatcodeRevert_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { - expect_revert(ccx.state, None, ccx.data.journaled_state.depth(), true) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true) } } impl Cheatcode for _expectCheatcodeRevert_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData.as_ref()), ccx.data.journaled_state.depth(), true) + expect_revert(ccx.state, Some(revertData.as_ref()), ccx.ecx.journaled_state.depth(), true) } } impl Cheatcode for _expectCheatcodeRevert_2Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData), ccx.data.journaled_state.depth(), true) + expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), true) } } impl Cheatcode for expectSafeMemoryCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { min, max } = *self; - expect_safe_memory(ccx.state, min, max, ccx.data.journaled_state.depth()) + expect_safe_memory(ccx.state, min, max, ccx.ecx.journaled_state.depth()) } } impl Cheatcode for stopExpectSafeMemoryCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - ccx.state.allowed_mem_writes.remove(&ccx.data.journaled_state.depth()); + ccx.state.allowed_mem_writes.remove(&ccx.ecx.journaled_state.depth()); Ok(Default::default()) } } @@ -293,7 +293,7 @@ impl Cheatcode for stopExpectSafeMemoryCall { impl Cheatcode for expectSafeMemoryCallCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { min, max } = *self; - expect_safe_memory(ccx.state, min, max, ccx.data.journaled_state.depth() + 1) + expect_safe_memory(ccx.state, min, max, ccx.ecx.journaled_state.depth() + 1) } } @@ -398,12 +398,7 @@ fn expect_emit( Ok(Default::default()) } -pub(crate) fn handle_expect_emit( - state: &mut Cheatcodes, - address: &Address, - topics: &[B256], - data: &Bytes, -) { +pub(crate) fn handle_expect_emit(state: &mut Cheatcodes, log: &alloy_primitives::Log) { // Fill or check the expected emits. // We expect for emit checks to be filled as they're declared (from oldest to newest), // so we fill them and push them to the back of the queue. @@ -431,20 +426,21 @@ pub(crate) fn handle_expect_emit( let Some(expected) = &event_to_fill_or_check.log else { // Fill the event. - event_to_fill_or_check.log = Some(RawLog::new_unchecked(topics.to_vec(), data.clone())); + event_to_fill_or_check.log = Some(log.data.clone()); state.expected_emits.push_back(event_to_fill_or_check); return }; let expected_topic_0 = expected.topics().first(); - let log_topic_0 = topics.first(); + let log_topic_0 = log.topics().first(); if expected_topic_0 .zip(log_topic_0) - .map_or(false, |(a, b)| a == b && expected.topics().len() == topics.len()) + .map_or(false, |(a, b)| a == b && expected.topics().len() == log.topics().len()) { // Match topics - event_to_fill_or_check.found = topics + event_to_fill_or_check.found = log + .topics() .iter() .skip(1) .enumerate() @@ -453,12 +449,12 @@ pub(crate) fn handle_expect_emit( // Maybe match source address if let Some(addr) = event_to_fill_or_check.address { - event_to_fill_or_check.found &= addr == *address; + event_to_fill_or_check.found &= addr == log.address; } // Maybe match data if event_to_fill_or_check.checks[3] { - event_to_fill_or_check.found &= expected.data == *data; + event_to_fill_or_check.found &= expected.data.as_ref() == log.data.data.as_ref(); } } diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index b6a4411ac9079..cba66f7aa4f70 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -438,7 +438,7 @@ impl ChiselDispatcher { println!( "{}: {}", Paint::yellow(format!("[{}]", stack.len() - i - 1)), - Paint::cyan(format!("0x{:02x}", stack.data()[i])) + Paint::cyan(format!("0x{:02x}", stack[i])) ); }); } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 6d76d5b0e896b..69e35f9477ced 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -236,7 +236,7 @@ impl SessionSource { // the file compiled correctly, thus the last stack item must be the memory offset of // the `bytes memory inspectoor` value - let mut offset = stack.data().last().unwrap().to::(); + let mut offset = stack.last().unwrap().to::(); let mem_offset = &memory[offset..offset + 32]; let len = U256::try_from_be_slice(mem_offset).unwrap().to::(); offset += 32; diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index dfbc301891470..6ffcb6770be45 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -49,7 +49,7 @@ pub struct ChiselResult { /// Called address pub address: Option
, /// EVM State at the final instruction of the `run()` function - pub state: Option<(revm::interpreter::Stack, Vec, InstructionResult)>, + pub state: Option<(Vec, Vec, InstructionResult)>, } /// ChiselRunner implementation @@ -153,7 +153,7 @@ impl ChiselRunner { match res.exit_reason { InstructionResult::Revert | InstructionResult::OutOfGas | - InstructionResult::OutOfFund => { + InstructionResult::OutOfFunds => { lowest_gas_limit = mid_gas_limit; } _ => { diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 04403a9f8c5a5..814a967c9b645 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -39,6 +39,7 @@ revm = { workspace = true, default-features = false, features = [ revm-inspectors.workspace = true derive_more.workspace = true +auto_impl = "1" eyre = "0.6" futures = "0.3" hex.workspace = true diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index a5b3d02861e58..f1f9733d494ee 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -1,6 +1,7 @@ use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types::BlockId; use futures::channel::mpsc::{SendError, TrySendError}; +use revm::primitives::EVMError; use std::{ convert::Infallible, sync::{mpsc::RecvError, Arc}, @@ -46,6 +47,8 @@ pub enum DatabaseError { For a test environment, you can use `etch` to place the required bytecode at that address." )] MissingCreate2Deployer, + #[error("{0}")] + Other(String), } impl DatabaseError { @@ -76,6 +79,7 @@ impl DatabaseError { Self::BlockNotFound(_) | Self::TransactionNotFound(_) | Self::MissingCreate2Deployer => None, + DatabaseError::Other(_) => None, } } @@ -107,3 +111,13 @@ impl From for DatabaseError { match value {} } } + +// Note: this is mostly necessary to use some revm internals that return an [EVMError] +impl From> for DatabaseError { + fn from(err: EVMError) -> Self { + match err { + EVMError::Database(err) => err, + err => DatabaseError::Other(err.to_string()), + } + } +} diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/fuzz.rs index 11857fa4ab641..69bcac72b13fe 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/fuzz.rs @@ -9,9 +9,13 @@ use crate::{ }; use alloy_genesis::GenesisAccount; use alloy_primitives::{Address, B256, U256}; +use eyre::WrapErr; use revm::{ db::DatabaseRef, - primitives::{Account, AccountInfo, Bytecode, Env, HashMap as Map, ResultAndState}, + primitives::{ + Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, HashMap as Map, ResultAndState, + SpecId, + }, Database, DatabaseCommit, Inspector, JournaledState, }; use std::{borrow::Cow, collections::HashMap}; @@ -40,29 +44,35 @@ pub struct FuzzBackendWrapper<'a> { pub backend: Cow<'a, Backend>, /// Keeps track of whether the backed is already initialized is_initialized: bool, + /// The [SpecId] of the current backend. + spec_id: SpecId, } impl<'a> FuzzBackendWrapper<'a> { pub fn new(backend: &'a Backend) -> Self { - Self { backend: Cow::Borrowed(backend), is_initialized: false } + Self { backend: Cow::Borrowed(backend), is_initialized: false, spec_id: SpecId::LATEST } } /// Executes the configured transaction of the `env` without committing state changes - pub fn inspect_ref( - &mut self, - env: &mut Env, - mut inspector: INSP, - ) -> eyre::Result - where - INSP: Inspector, - { + /// + /// Note: in case there are any cheatcodes executed that modify the environment, this will + /// update the given `env` with the new values. + pub fn inspect<'b, I: Inspector<&'b mut Self>>( + &'b mut self, + env: &mut EnvWithHandlerCfg, + inspector: I, + ) -> eyre::Result { // this is a new call to inspect with a new env, so even if we've cloned the backend // already, we reset the initialized state self.is_initialized = false; - match revm::evm_inner::(env, self, Some(&mut inspector)).transact() { - Ok(result) => Ok(result), - Err(e) => eyre::bail!("fuzz: failed to inspect: {e}"), - } + self.spec_id = env.handler_cfg.spec_id; + let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); + + let res = evm.transact().wrap_err("backend: failed while inspecting")?; + + env.env = evm.context.evm.env; + + Ok(res) } /// Returns whether there was a snapshot failure in the fuzz backend. @@ -78,7 +88,8 @@ impl<'a> FuzzBackendWrapper<'a> { fn backend_mut(&mut self, env: &Env) -> &mut Backend { if !self.is_initialized { let backend = self.backend.to_mut(); - backend.initialize(env); + let env = EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), self.spec_id); + backend.initialize(&env); self.is_initialized = true; return backend } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 5e2c8fdadecb3..e3b7ab3392514 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -9,16 +9,17 @@ use crate::{ use alloy_genesis::GenesisAccount; use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; +use eyre::Context; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use revm::{ db::{CacheDB, DatabaseRef}, inspectors::NoOpInspector, - precompile::{Precompiles, SpecId}, + precompile::{PrecompileSpecId, Precompiles}, primitives::{ - Account, AccountInfo, Bytecode, CreateScheme, Env, HashMap as Map, Log, ResultAndState, - StorageSlot, TransactTo, KECCAK_EMPTY, + Account, AccountInfo, Bytecode, CreateScheme, Env, EnvWithHandlerCfg, HashMap as Map, Log, + ResultAndState, SpecId, StorageSlot, TransactTo, KECCAK_EMPTY, }, - Database, DatabaseCommit, Inspector, JournaledState, EVM, + Database, DatabaseCommit, Inspector, JournaledState, }; use std::{ collections::{HashMap, HashSet}, @@ -62,6 +63,7 @@ const GLOBAL_FAILURE_SLOT: B256 = b256!("6661696c65640000000000000000000000000000000000000000000000000000"); /// An extension trait that allows us to easily extend the `revm::Inspector` capabilities +#[auto_impl::auto_impl(&mut)] pub trait DatabaseExt: Database { /// Creates a new snapshot at the current point of execution. /// @@ -193,7 +195,9 @@ pub trait DatabaseExt: Database { env: &mut Env, journaled_state: &mut JournaledState, inspector: &mut I, - ) -> eyre::Result<()>; + ) -> eyre::Result<()> + where + Self: Sized; /// Returns the `ForkId` that's currently used in the database, if fork mode is on fn active_fork_id(&self) -> Option; @@ -272,14 +276,20 @@ pub trait DatabaseExt: Database { fn add_persistent_account(&mut self, account: Address) -> bool; /// Removes persistent status from all given accounts - fn remove_persistent_accounts(&mut self, accounts: impl IntoIterator) { + fn remove_persistent_accounts(&mut self, accounts: impl IntoIterator) + where + Self: Sized, + { for acc in accounts { self.remove_persistent_account(&acc); } } /// Extends the persistent accounts with the accounts the iterator yields. - fn extend_persistent_accounts(&mut self, accounts: impl IntoIterator) { + fn extend_persistent_accounts(&mut self, accounts: impl IntoIterator) + where + Self: Sized, + { for acc in accounts { self.add_persistent_account(acc); } @@ -318,6 +328,8 @@ pub trait DatabaseExt: Database { } } +struct _ObjectSafe(dyn DatabaseExt); + /// Provides the underlying `revm::Database` implementation. /// /// A `Backend` can be initialised in two forms: @@ -545,8 +557,8 @@ impl Backend { /// Sets the current spec id pub fn set_spec_id(&mut self, spec_id: SpecId) -> &mut Self { - trace!("setting precompile id"); - self.inner.precompile_id = spec_id; + trace!(?spec_id, "setting spec ID"); + self.inner.spec_id = spec_id; self } @@ -742,9 +754,9 @@ impl Backend { /// Initializes settings we need to keep track of. /// /// We need to track these mainly to prevent issues when switching between different evms - pub(crate) fn initialize(&mut self, env: &Env) { + pub(crate) fn initialize(&mut self, env: &EnvWithHandlerCfg) { self.set_caller(env.tx.caller); - self.set_spec_id(SpecId::from_spec_id(env.cfg.spec_id)); + self.set_spec_id(env.handler_cfg.spec_id); let test_contract = match env.tx.transact_to { TransactTo::Call(to) => to, @@ -759,21 +771,28 @@ impl Backend { self.set_test_contract(test_contract); } - /// Executes the configured test call of the `env` without committing state changes - pub fn inspect_ref( - &mut self, - env: &mut Env, - mut inspector: INSP, - ) -> eyre::Result - where - INSP: Inspector, - { + /// Returns the `EnvWithHandlerCfg` with the current `spec_id` set. + fn env_with_handler_cfg(&self, env: Env) -> EnvWithHandlerCfg { + EnvWithHandlerCfg::new_with_spec_id(Box::new(env), self.inner.spec_id) + } + + /// Executes the configured test call of the `env` without committing state changes. + /// + /// Note: in case there are any cheatcodes executed that modify the environment, this will + /// update the given `env` with the new values. + pub fn inspect<'a, I: Inspector<&'a mut Self>>( + &'a mut self, + env: &mut EnvWithHandlerCfg, + inspector: I, + ) -> eyre::Result { self.initialize(env); + let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); - match revm::evm_inner::(env, self, Some(&mut inspector)).transact() { - Ok(res) => Ok(res), - Err(e) => eyre::bail!("backend: failed while inspecting: {e}"), - } + let res = evm.transact().wrap_err("backend: failed while inspecting")?; + + env.env = evm.context.evm.env; + + Ok(res) } /// Returns true if the address is a precompile @@ -876,6 +895,7 @@ impl Backend { let fork_id = self.ensure_fork_id(id)?.clone(); + let env = self.env_with_handler_cfg(env); let fork = self.inner.get_fork_by_id_mut(id)?; let full_block = fork.db.db.get_full_block(env.block.number.to::())?; @@ -902,7 +922,7 @@ impl Backend { journaled_state, fork, &fork_id, - NoOpInspector, + &mut NoOpInspector, )?; } } @@ -1232,6 +1252,7 @@ impl DatabaseExt for Backend { let mut env = env.clone(); update_env_block(&mut env, fork_block, &block); + let env = self.env_with_handler_cfg(env); let fork = self.inner.get_fork_by_id_mut(id)?; commit_transaction(tx, env, journaled_state, fork, &fork_id, inspector) } @@ -1551,8 +1572,8 @@ pub struct BackendInner { /// /// See also [`clone_data()`] pub persistent_accounts: HashSet
, - /// The configured precompile spec id - pub precompile_id: revm::precompile::SpecId, + /// The configured spec id + pub spec_id: SpecId, /// All accounts that are allowed to execute cheatcodes pub cheatcode_access_accounts: HashSet
, } @@ -1715,29 +1736,12 @@ impl BackendInner { } pub fn precompiles(&self) -> &'static Precompiles { - Precompiles::new(self.precompile_id) + Precompiles::new(PrecompileSpecId::from_spec_id(self.spec_id)) } /// Returns a new, empty, `JournaledState` with set precompiles pub fn new_journaled_state(&self) -> JournaledState { - /// Helper function to convert from a `revm::precompile::SpecId` into a - /// `revm::primitives::SpecId` This only matters if the spec is Cancun or later, or - /// pre-Spurious Dragon. - fn precompiles_spec_id_to_primitives_spec_id(spec: SpecId) -> revm::primitives::SpecId { - match spec { - SpecId::HOMESTEAD => revm::primitives::SpecId::HOMESTEAD, - SpecId::BYZANTIUM => revm::primitives::SpecId::BYZANTIUM, - SpecId::ISTANBUL => revm::primitives::ISTANBUL, - SpecId::BERLIN => revm::primitives::BERLIN, - SpecId::CANCUN => revm::primitives::CANCUN, - // Point latest to berlin for now, as we don't wanna accidentally point to Cancun. - SpecId::LATEST => revm::primitives::BERLIN, - } - } - JournaledState::new( - precompiles_spec_id_to_primitives_spec_id(self.precompile_id), - self.precompiles().addresses().into_iter().copied().collect(), - ) + JournaledState::new(self.spec_id, self.precompiles().addresses().copied().collect()) } } @@ -1754,7 +1758,7 @@ impl Default for BackendInner { caller: None, next_fork_id: Default::default(), persistent_accounts: Default::default(), - precompile_id: revm::precompile::SpecId::LATEST, + spec_id: SpecId::LATEST, // grant the cheatcode,default test and caller address access to execute cheatcodes // itself cheatcode_access_accounts: HashSet::from([ @@ -1865,32 +1869,26 @@ fn update_env_block(env: &mut Env, fork_block: U64, block: &Block) { /// state, with an optional inspector fn commit_transaction>( tx: Transaction, - mut env: Env, + mut env: EnvWithHandlerCfg, journaled_state: &mut JournaledState, fork: &mut Fork, fork_id: &ForkId, inspector: I, ) -> eyre::Result<()> { - configure_tx_env(&mut env, &tx); + configure_tx_env(&mut env.env, &tx); let now = Instant::now(); - let state = { - let mut evm = EVM::new(); - evm.env = env; - + let res = { let fork = fork.clone(); let journaled_state = journaled_state.clone(); let db = Backend::new_with_fork(fork_id, fork, journaled_state); - evm.database(db); - - match evm.inspect(inspector) { - Ok(res) => res.state, - Err(e) => eyre::bail!("backend: failed committing transaction: {e}"), - } + crate::utils::new_evm_with_inspector(db, env, inspector) + .transact() + .wrap_err("backend: failed committing transaction")? }; trace!(elapsed = ?now.elapsed(), "transacted transaction"); - apply_state_changeset(state, journaled_state, fork); + apply_state_changeset(res.state, journaled_state, fork); Ok(()) } diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 2dee3a9b59b3c..786252bba73af 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -10,7 +10,7 @@ use foundry_common::{ }; use foundry_compilers::utils::RuntimeOrHandle; use foundry_config::{Chain, Config}; -use revm::primitives::{BlockEnv, CfgEnv, SpecId, TxEnv}; +use revm::primitives::{BlockEnv, CfgEnv, TxEnv}; use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -111,7 +111,6 @@ impl EvmOpts { pub fn local_evm_env(&self) -> revm::primitives::Env { let mut cfg = CfgEnv::default(); cfg.chain_id = self.env.chain_id.unwrap_or(foundry_common::DEV_CHAIN_ID); - cfg.spec_id = SpecId::MERGE; cfg.limit_contract_code_size = self.env.code_size_limit.or(Some(usize::MAX)); cfg.memory_limit = self.memory_limit; // EIP-3607 rejects transactions from senders with deployed code. diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index e0f0f1ee80f48..48e8808e4accf 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -4,8 +4,8 @@ use alloy_rpc_types::{Block, Transaction}; use eyre::ContextCompat; use foundry_config::NamedChain; use revm::{ - interpreter::InstructionResult, - primitives::{Eval, Halt, SpecId, TransactTo}, + db::WrapDatabaseRef, + primitives::{SpecId, TransactTo}, }; pub use foundry_compilers::utils::RuntimeOrHandle; @@ -13,43 +13,6 @@ pub use revm::primitives::State as StateChangeset; pub use crate::ic::*; -/// Small helper function to convert an Eval into an InstructionResult -#[inline] -pub fn eval_to_instruction_result(eval: Eval) -> InstructionResult { - match eval { - Eval::Return => InstructionResult::Return, - Eval::Stop => InstructionResult::Stop, - Eval::SelfDestruct => InstructionResult::SelfDestruct, - } -} - -/// Small helper function to convert a Halt into an InstructionResult -#[inline] -pub fn halt_to_instruction_result(halt: Halt) -> InstructionResult { - match halt { - Halt::OutOfGas(_) => InstructionResult::OutOfGas, - Halt::OpcodeNotFound => InstructionResult::OpcodeNotFound, - Halt::InvalidFEOpcode => InstructionResult::InvalidFEOpcode, - Halt::InvalidJump => InstructionResult::InvalidJump, - Halt::NotActivated => InstructionResult::NotActivated, - Halt::StackOverflow => InstructionResult::StackOverflow, - Halt::StackUnderflow => InstructionResult::StackUnderflow, - Halt::OutOfOffset => InstructionResult::OutOfOffset, - Halt::CreateCollision => InstructionResult::CreateCollision, - Halt::PrecompileError => InstructionResult::PrecompileError, - Halt::NonceOverflow => InstructionResult::NonceOverflow, - Halt::CreateContractSizeLimit => InstructionResult::CreateContractSizeLimit, - Halt::CreateContractStartingWithEF => InstructionResult::CreateContractStartingWithEF, - Halt::CreateInitcodeSizeLimit => InstructionResult::CreateInitcodeSizeLimit, - Halt::OverflowPayment => InstructionResult::OverflowPayment, - Halt::StateChangeDuringStaticCall => InstructionResult::StateChangeDuringStaticCall, - Halt::CallNotAllowedInsideStatic => InstructionResult::CallNotAllowedInsideStatic, - Halt::OutOfFund => InstructionResult::OutOfFund, - Halt::CallTooDeep => InstructionResult::CallTooDeep, - Halt::FailedDeposit => InstructionResult::Return, - } -} - /// Depending on the configured chain id and block number this should apply any specific changes /// /// This checks for: @@ -133,3 +96,56 @@ pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 { let refund_quotient = if SpecId::enabled(spec, SpecId::LONDON) { 5 } else { 2 }; spent - (refunded).min(spent / refund_quotient) } + +/// Creates a new EVM with the given inspector. +pub fn new_evm_with_inspector<'a, DB, I>( + db: DB, + env: revm::primitives::EnvWithHandlerCfg, + inspector: I, +) -> revm::Evm<'a, I, DB> +where + DB: revm::Database, + I: revm::Inspector, +{ + // NOTE: We could use `revm::Evm::builder()` here, but on the current patch it has some + // performance issues. + let revm::primitives::EnvWithHandlerCfg { env, handler_cfg } = env; + let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); + let mut handler = revm::Handler::new(handler_cfg); + handler.append_handler_register_plain(revm::inspector_handle_register); + revm::Evm::new(context, handler) +} + +/// Creates a new EVM with the given inspector and wraps the database in a `WrapDatabaseRef`. +pub fn new_evm_with_inspector_ref<'a, DB, I>( + db: DB, + env: revm::primitives::EnvWithHandlerCfg, + inspector: I, +) -> revm::Evm<'a, I, WrapDatabaseRef> +where + DB: revm::DatabaseRef, + I: revm::Inspector>, +{ + new_evm_with_inspector(WrapDatabaseRef(db), env, inspector) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn build_evm() { + let mut db = revm::db::EmptyDB::default(); + + let env = Box::::default(); + let spec = SpecId::LATEST; + let handler_cfg = revm::primitives::HandlerCfg::new(spec); + let cfg = revm::primitives::EnvWithHandlerCfg::new(env, handler_cfg); + + let mut inspector = revm::inspectors::NoOpInspector; + + let mut evm = new_evm_with_inspector(&mut db, cfg, &mut inspector); + let result = evm.transact().unwrap(); + assert!(result.result.is_success()); + } +} diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index 8d75e0e941a08..3c3af1ba21486 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -1,6 +1,5 @@ use crate::{HitMap, HitMaps}; -use alloy_primitives::Bytes; -use revm::{interpreter::Interpreter, Database, EVMData, Inspector}; +use revm::{interpreter::Interpreter, Database, EvmContext, Inspector}; #[derive(Clone, Debug, Default)] pub struct CoverageCollector { @@ -10,18 +9,16 @@ pub struct CoverageCollector { impl Inspector for CoverageCollector { #[inline] - fn initialize_interp(&mut self, interpreter: &mut Interpreter<'_>, _: &mut EVMData<'_, DB>) { - let hash = interpreter.contract.hash; - self.maps.entry(hash).or_insert_with(|| { - HitMap::new(Bytes::copy_from_slice( - interpreter.contract.bytecode.original_bytecode_slice(), - )) - }); + fn initialize_interp(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { + let hash = interp.contract.hash; + self.maps + .entry(hash) + .or_insert_with(|| HitMap::new(interp.contract.bytecode.original_bytecode())); } #[inline] - fn step(&mut self, interpreter: &mut Interpreter<'_>, _: &mut EVMData<'_, DB>) { - let hash = interpreter.contract.hash; - self.maps.entry(hash).and_modify(|map| map.hit(interpreter.program_counter())); + fn step(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { + let hash = interp.contract.hash; + self.maps.entry(hash).and_modify(|map| map.hit(interp.program_counter())); } } diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 33e491e113d70..08b1500b4a4e3 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -24,7 +24,6 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true -alloy-rpc-types.workspace = true hashbrown = { version = "0.14", features = ["serde"] } revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/evm/evm/src/executors/builder.rs b/crates/evm/evm/src/executors/builder.rs index d7cca61a7f5e3..370c3bcf3e1c2 100644 --- a/crates/evm/evm/src/executors/builder.rs +++ b/crates/evm/evm/src/executors/builder.rs @@ -1,7 +1,7 @@ use crate::{executors::Executor, inspectors::InspectorStackBuilder}; use alloy_primitives::U256; use foundry_evm_core::backend::Backend; -use revm::primitives::{Env, SpecId}; +use revm::primitives::{Env, EnvWithHandlerCfg, SpecId}; /// The builder that allows to configure an evm [`Executor`] which a stack of optional /// [`revm::Inspector`]s, such as [`Cheatcodes`]. @@ -63,12 +63,16 @@ impl ExecutorBuilder { /// Builds the executor as configured. #[inline] - pub fn build(self, mut env: Env, db: Backend) -> Executor { + pub fn build(self, env: Env, db: Backend) -> Executor { let Self { mut stack, gas_limit, spec_id } = self; - env.cfg.spec_id = spec_id; stack.block = Some(env.block.clone()); stack.gas_price = Some(env.tx.gas_price); let gas_limit = gas_limit.unwrap_or(env.block.gas_limit); - Executor::new(db, env, stack.build(), gas_limit) + Executor::new( + db, + EnvWithHandlerCfg::new_with_spec_id(Box::new(env), spec_id), + stack.build(), + gas_limit, + ) } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 628bc502ebb68..f1076925fc3f9 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -20,15 +20,16 @@ use foundry_evm_core::{ }, debug::DebugArena, decode::RevertDecoder, - utils::{eval_to_instruction_result, halt_to_instruction_result, StateChangeset}, + utils::StateChangeset, }; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ db::{DatabaseCommit, DatabaseRef}, - interpreter::{return_ok, CreateScheme, InstructionResult, Stack}, + interpreter::{return_ok, CreateScheme, InstructionResult}, primitives::{ - BlockEnv, Bytecode, Env, ExecutionResult, Output, ResultAndState, SpecId, TransactTo, TxEnv, + BlockEnv, Bytecode, Env, EnvWithHandlerCfg, ExecutionResult, Output, ResultAndState, + SpecId, TransactTo, TxEnv, }, }; use std::collections::HashMap; @@ -62,7 +63,7 @@ pub struct Executor { // so the performance difference should be negligible. pub backend: Backend, /// The EVM environment. - pub env: Env, + pub env: EnvWithHandlerCfg, /// The Revm inspector stack. pub inspector: InspectorStack, /// The gas limit for calls and deployments. This is different from the gas limit imposed by @@ -73,7 +74,12 @@ pub struct Executor { impl Executor { #[inline] - pub fn new(mut backend: Backend, env: Env, inspector: InspectorStack, gas_limit: U256) -> Self { + pub fn new( + mut backend: Backend, + env: EnvWithHandlerCfg, + inspector: InspectorStack, + gas_limit: U256, + ) -> Self { // Need to create a non-empty contract on the cheatcodes address so `extcodesize` checks // does not fail backend.insert_account_info( @@ -87,6 +93,11 @@ impl Executor { Executor { backend, env, inspector, gas_limit } } + /// Returns the spec id of the executor + pub fn spec_id(&self) -> SpecId { + self.env.handler_cfg.spec_id + } + /// Creates the default CREATE2 Contract Deployer for local tests and scripts. pub fn deploy_create2_deployer(&mut self) -> eyre::Result<()> { trace!("deploying local create2 deployer"); @@ -299,7 +310,7 @@ impl Executor { // Build VM let mut env = self.build_test_env(from, TransactTo::Call(to), calldata, value); let mut db = FuzzBackendWrapper::new(&self.backend); - let result = db.inspect_ref(&mut env, &mut inspector)?; + let result = db.inspect(&mut env, &mut inspector)?; // Persist the snapshot failure recorded on the fuzz backend wrapper. let has_snapshot_failure = db.has_snapshot_failure(); @@ -307,17 +318,17 @@ impl Executor { } /// Execute the transaction configured in `env.tx` and commit the changes - pub fn commit_tx_with_env(&mut self, env: Env) -> eyre::Result { + pub fn commit_tx_with_env(&mut self, env: EnvWithHandlerCfg) -> eyre::Result { let mut result = self.call_raw_with_env(env)?; self.commit(&mut result); Ok(result) } /// Execute the transaction configured in `env.tx` - pub fn call_raw_with_env(&mut self, mut env: Env) -> eyre::Result { + pub fn call_raw_with_env(&mut self, mut env: EnvWithHandlerCfg) -> eyre::Result { // execute the call let mut inspector = self.inspector.clone(); - let result = self.backend.inspect_ref(&mut env, &mut inspector)?; + let result = self.backend.inspect(&mut env, &mut inspector)?; convert_executed_result(env, inspector, result, self.backend.has_snapshot_failure()) } @@ -349,7 +360,7 @@ impl Executor { /// database pub fn deploy_with_env( &mut self, - env: Env, + env: EnvWithHandlerCfg, rd: Option<&RevertDecoder>, ) -> Result { debug_assert!( @@ -549,8 +560,8 @@ impl Executor { transact_to: TransactTo, data: Bytes, value: U256, - ) -> Env { - Env { + ) -> EnvWithHandlerCfg { + let env = Env { cfg: self.env.cfg.clone(), // We always set the gas price to 0 so we can execute the transaction regardless of // network conditions - the actual gas price is kept in `self.block` and is applied by @@ -571,7 +582,9 @@ impl Executor { gas_limit: self.gas_limit.to(), ..self.env.tx.clone() }, - } + }; + + EnvWithHandlerCfg::new_with_spec_id(Box::new(env), self.env.handler_cfg.spec_id) } } @@ -624,7 +637,7 @@ pub struct DeployResult { /// The debug nodes of the call pub debug: Option, /// The `revm::Env` after deployment - pub env: Env, + pub env: EnvWithHandlerCfg, /// The coverage info collected during the deployment pub coverage: Option, } @@ -661,7 +674,7 @@ pub struct CallResult { /// used `call` and `call_raw` not `call_committing` or `call_raw_committing`). pub state_changeset: Option, /// The `revm::Env` after the call - pub env: Env, + pub env: EnvWithHandlerCfg, /// breakpoints pub breakpoints: Breakpoints, } @@ -704,13 +717,13 @@ pub struct RawCallResult { /// used `call` and `call_raw` not `call_committing` or `call_raw_committing`). pub state_changeset: Option, /// The `revm::Env` after the call - pub env: Env, + pub env: EnvWithHandlerCfg, /// The cheatcode states after execution pub cheatcodes: Option, /// The raw output of the execution pub out: Option, /// The chisel state - pub chisel_state: Option<(Stack, Vec, InstructionResult)>, + pub chisel_state: Option<(Vec, Vec, InstructionResult)>, } impl Default for RawCallResult { @@ -730,7 +743,7 @@ impl Default for RawCallResult { debug: None, transactions: None, state_changeset: None, - env: Default::default(), + env: EnvWithHandlerCfg::new_with_spec_id(Box::default(), SpecId::LATEST), cheatcodes: Default::default(), out: None, chisel_state: None, @@ -746,7 +759,7 @@ fn calc_stipend(calldata: &[u8], spec: SpecId) -> u64 { /// Converts the data aggregated in the `inspector` and `call` to a `RawCallResult` fn convert_executed_result( - env: Env, + env: EnvWithHandlerCfg, inspector: InspectorStack, result: ResultAndState, has_snapshot_failure: bool, @@ -754,17 +767,15 @@ fn convert_executed_result( let ResultAndState { result: exec_result, state: state_changeset } = result; let (exit_reason, gas_refunded, gas_used, out) = match exec_result { ExecutionResult::Success { reason, gas_used, gas_refunded, output, .. } => { - (eval_to_instruction_result(reason), gas_refunded, gas_used, Some(output)) + (reason.into(), gas_refunded, gas_used, Some(output)) } ExecutionResult::Revert { gas_used, output } => { // Need to fetch the unused gas (InstructionResult::Revert, 0_u64, gas_used, Some(Output::Call(output))) } - ExecutionResult::Halt { reason, gas_used } => { - (halt_to_instruction_result(reason), 0_u64, gas_used, None) - } + ExecutionResult::Halt { reason, gas_used } => (reason.into(), 0_u64, gas_used, None), }; - let stipend = calc_stipend(&env.tx.data, env.cfg.spec_id); + let stipend = calc_stipend(&env.tx.data, env.handler_cfg.spec_id); let result = match &out { Some(Output::Call(data)) => data.clone(), diff --git a/crates/evm/evm/src/executors/tracing.rs b/crates/evm/evm/src/executors/tracing.rs index 5beabdd1de0d4..08979bc168669 100644 --- a/crates/evm/evm/src/executors/tracing.rs +++ b/crates/evm/evm/src/executors/tracing.rs @@ -2,7 +2,7 @@ use crate::executors::{Executor, ExecutorBuilder}; use foundry_compilers::EvmVersion; use foundry_config::{utils::evm_spec_id, Chain, Config}; use foundry_evm_core::{backend::Backend, fork::CreateFork, opts::EvmOpts}; -use revm::primitives::Env; +use revm::primitives::{Env, SpecId}; use std::ops::{Deref, DerefMut}; /// A default executor with tracing enabled @@ -28,6 +28,11 @@ impl TracingExecutor { } } + /// Returns the spec id of the executor + pub fn spec_id(&self) -> SpecId { + self.executor.spec_id() + } + /// uses the fork block number from the config pub async fn get_fork_material( config: &Config, diff --git a/crates/evm/evm/src/inspectors/access_list.rs b/crates/evm/evm/src/inspectors/access_list.rs deleted file mode 100644 index ea43336a754ad..0000000000000 --- a/crates/evm/evm/src/inspectors/access_list.rs +++ /dev/null @@ -1,79 +0,0 @@ -use alloy_primitives::{Address, B256}; -use alloy_rpc_types::{AccessList, AccessListItem}; -use hashbrown::{HashMap, HashSet}; -use revm::{ - interpreter::{opcode, Interpreter}, - Database, EVMData, Inspector, -}; - -/// An inspector that collects touched accounts and storage slots. -#[derive(Debug, Default)] -pub struct AccessListTracer { - excluded: HashSet
, - access_list: HashMap>, -} - -impl AccessListTracer { - pub fn new( - access_list: AccessList, - from: Address, - to: Address, - precompiles: Vec
, - ) -> Self { - AccessListTracer { - excluded: [from, to].iter().chain(precompiles.iter()).copied().collect(), - access_list: access_list - .0 - .iter() - .map(|v| (v.address, v.storage_keys.iter().copied().collect())) - .collect(), - } - } - - pub fn access_list(&self) -> AccessList { - AccessList( - self.access_list - .iter() - .map(|(address, slots)| AccessListItem { - address: *address, - storage_keys: slots.iter().copied().collect(), - }) - .collect::>(), - ) - } -} - -impl Inspector for AccessListTracer { - #[inline] - fn step(&mut self, interpreter: &mut Interpreter<'_>, _data: &mut EVMData<'_, DB>) { - match interpreter.current_opcode() { - opcode::SLOAD | opcode::SSTORE => { - if let Ok(slot) = interpreter.stack().peek(0) { - let cur_contract = interpreter.contract.address; - self.access_list.entry(cur_contract).or_default().insert(slot.into()); - } - } - opcode::EXTCODECOPY | - opcode::EXTCODEHASH | - opcode::EXTCODESIZE | - opcode::BALANCE | - opcode::SELFDESTRUCT => { - if let Ok(slot) = interpreter.stack().peek(0) { - let addr: Address = Address::from_word(slot.into()); - if !self.excluded.contains(&addr) { - self.access_list.entry(addr).or_default(); - } - } - } - opcode::DELEGATECALL | opcode::CALL | opcode::STATICCALL | opcode::CALLCODE => { - if let Ok(slot) = interpreter.stack().peek(1) { - let addr: Address = Address::from_word(slot.into()); - if !self.excluded.contains(&addr) { - self.access_list.entry(addr).or_default(); - } - } - } - _ => (), - } - } -} diff --git a/crates/evm/evm/src/inspectors/chisel_state.rs b/crates/evm/evm/src/inspectors/chisel_state.rs index a4d3a1895f24c..9aa933d388681 100644 --- a/crates/evm/evm/src/inspectors/chisel_state.rs +++ b/crates/evm/evm/src/inspectors/chisel_state.rs @@ -1,6 +1,7 @@ +use alloy_primitives::U256; use revm::{ - interpreter::{InstructionResult, Interpreter, Stack}, - Database, Inspector, + interpreter::{InstructionResult, Interpreter}, + Database, EvmContext, Inspector, }; /// An inspector for Chisel @@ -9,7 +10,7 @@ pub struct ChiselState { /// The PC of the final instruction pub final_pc: usize, /// The final state of the REPL contract call - pub state: Option<(Stack, Vec, InstructionResult)>, + pub state: Option<(Vec, Vec, InstructionResult)>, } impl ChiselState { @@ -22,12 +23,12 @@ impl ChiselState { impl Inspector for ChiselState { #[inline] - fn step_end(&mut self, interp: &mut Interpreter<'_>, _: &mut revm::EVMData<'_, DB>) { + fn step_end(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { // If we are at the final pc of the REPL contract execution, set the state. // Subtraction can't overflow because `pc` is always at least 1 in `step_end`. if self.final_pc == interp.program_counter() - 1 { self.state = Some(( - interp.stack().clone(), + interp.stack.data().clone(), interp.shared_memory.context_memory().to_vec(), interp.instruction_result, )) diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index bb327b36e5bee..222e6de3bd04a 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::Address; use foundry_common::{ErrorExt, SELECTOR_LEN}; use foundry_evm_core::{ backend::DatabaseExt, @@ -9,9 +9,10 @@ use foundry_evm_core::{ use revm::{ interpreter::{ opcode::{self, spec_opcode_gas}, - CallInputs, CreateInputs, Gas, InstructionResult, Interpreter, + CallInputs, CallOutcome, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, + InterpreterResult, }, - EVMData, Inspector, + EvmContext, Inspector, }; use revm_inspectors::tracing::types::CallKind; @@ -46,12 +47,12 @@ impl Debugger { impl Inspector for Debugger { #[inline] - fn step(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { - let pc = interpreter.program_counter(); - let op = interpreter.current_opcode(); + fn step(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { + let pc = interp.program_counter(); + let op = interp.current_opcode(); // Get opcode information - let opcode_infos = spec_opcode_gas(data.env.cfg.spec_id); + let opcode_infos = spec_opcode_gas(ecx.spec_id()); let opcode_info = &opcode_infos[op as usize]; // Extract the push bytes @@ -61,22 +62,22 @@ impl Inspector for Debugger { n => { let start = pc + 1; let end = start + n; - Some(interpreter.contract.bytecode.bytecode()[start..end].to_vec()) + Some(interp.contract.bytecode.bytecode()[start..end].to_vec()) } }; let total_gas_used = gas_used( - data.env.cfg.spec_id, - interpreter.gas.limit().saturating_sub(interpreter.gas.remaining()), - interpreter.gas.refunded() as u64, + ecx.spec_id(), + interp.gas.limit().saturating_sub(interp.gas.remaining()), + interp.gas.refunded() as u64, ); self.arena.arena[self.head].steps.push(DebugStep { pc, - stack: interpreter.stack().data().clone(), - memory: interpreter.shared_memory.context_memory().to_vec(), - calldata: interpreter.contract().input.to_vec(), - returndata: interpreter.return_data_buffer.to_vec(), + stack: interp.stack().data().clone(), + memory: interp.shared_memory.context_memory().to_vec(), + calldata: interp.contract().input.to_vec(), + returndata: interp.return_data_buffer.to_vec(), instruction: Instruction::OpCode(op), push_bytes, total_gas_used, @@ -84,19 +85,15 @@ impl Inspector for Debugger { } #[inline] - fn call( - &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { + fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { self.enter( - data.journaled_state.depth() as usize, - call.context.code_address, - call.context.scheme.into(), + ecx.journaled_state.depth() as usize, + inputs.context.code_address, + inputs.context.scheme.into(), ); - if call.contract == CHEATCODE_ADDRESS { - if let Some(selector) = call.input.get(..SELECTOR_LEN) { + if inputs.contract == CHEATCODE_ADDRESS { + if let Some(selector) = inputs.input.get(..SELECTOR_LEN) { self.arena.arena[self.head].steps.push(DebugStep { instruction: Instruction::Cheatcode(selector.try_into().unwrap()), ..Default::default() @@ -104,57 +101,58 @@ impl Inspector for Debugger { } } - (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) + None } #[inline] fn call_end( &mut self, - _: &mut EVMData<'_, DB>, - _: &CallInputs, - gas: Gas, - status: InstructionResult, - retdata: Bytes, - ) -> (InstructionResult, Gas, Bytes) { + _context: &mut EvmContext, + _inputs: &CallInputs, + outcome: CallOutcome, + ) -> CallOutcome { self.exit(); - (status, gas, retdata) + outcome } #[inline] fn create( &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CreateInputs, - ) -> (InstructionResult, Option
, Gas, Bytes) { - // TODO: Does this increase gas cost? - if let Err(err) = data.journaled_state.load_account(call.caller, data.db) { - let gas = Gas::new(call.gas_limit); - return (InstructionResult::Revert, None, gas, err.abi_encode_revert()); + ecx: &mut EvmContext, + inputs: &mut CreateInputs, + ) -> Option { + if let Err(err) = ecx.load_account(inputs.caller) { + let gas = Gas::new(inputs.gas_limit); + return Some(CreateOutcome::new( + InterpreterResult { + result: InstructionResult::Revert, + output: err.abi_encode_revert(), + gas, + }, + None, + )); } - let nonce = data.journaled_state.account(call.caller).info.nonce; + let nonce = ecx.journaled_state.account(inputs.caller).info.nonce; self.enter( - data.journaled_state.depth() as usize, - call.created_address(nonce), + ecx.journaled_state.depth() as usize, + inputs.created_address(nonce), CallKind::Create, ); - (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()) + None } #[inline] fn create_end( &mut self, - _: &mut EVMData<'_, DB>, - _: &CreateInputs, - status: InstructionResult, - address: Option
, - gas: Gas, - retdata: Bytes, - ) -> (InstructionResult, Option
, Gas, Bytes) { + _context: &mut EvmContext, + _inputs: &CreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { self.exit(); - (status, address, gas, retdata) + outcome } } diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index b5324f576a587..a8e4a063c352a 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, Bytes, Log, B256}; +use alloy_primitives::{Address, Bytes, Log}; use alloy_sol_types::{SolEvent, SolInterface, SolValue}; use foundry_common::{fmt::ConsoleFmt, ErrorExt}; use foundry_evm_core::{ @@ -6,8 +6,8 @@ use foundry_evm_core::{ constants::HARDHAT_CONSOLE_ADDRESS, }; use revm::{ - interpreter::{CallInputs, Gas, InstructionResult}, - Database, EVMData, Inspector, + interpreter::{CallInputs, CallOutcome, Gas, InstructionResult, InterpreterResult}, + Database, EvmContext, Inspector, }; /// An inspector that collects logs during execution. @@ -38,23 +38,31 @@ impl LogCollector { } impl Inspector for LogCollector { - fn log(&mut self, _: &mut EVMData<'_, DB>, address: &Address, topics: &[B256], data: &Bytes) { - if let Some(log) = Log::new(*address, topics.to_vec(), data.clone()) { - self.logs.push(log); - } + fn log(&mut self, _context: &mut EvmContext, log: &Log) { + self.logs.push(log.clone()); } + #[inline] fn call( &mut self, - _: &mut EVMData<'_, DB>, - call: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { - let (status, reason) = if call.contract == HARDHAT_CONSOLE_ADDRESS { - self.hardhat_log(call.input.to_vec()) - } else { - (InstructionResult::Continue, Bytes::new()) - }; - (status, Gas::new(call.gas_limit), reason) + _context: &mut EvmContext, + inputs: &mut CallInputs, + ) -> Option { + if inputs.contract == HARDHAT_CONSOLE_ADDRESS { + let (res, out) = self.hardhat_log(inputs.input.to_vec()); + if res != InstructionResult::Continue { + return Some(CallOutcome { + result: InterpreterResult { + result: res, + output: out, + gas: Gas::new(inputs.gas_limit), + }, + memory_offset: inputs.return_memory_offset.clone(), + }) + } + } + + None } } diff --git a/crates/evm/evm/src/inspectors/mod.rs b/crates/evm/evm/src/inspectors/mod.rs index 20dd340d3cda0..059033889c472 100644 --- a/crates/evm/evm/src/inspectors/mod.rs +++ b/crates/evm/evm/src/inspectors/mod.rs @@ -5,8 +5,7 @@ pub use foundry_evm_coverage::CoverageCollector; pub use foundry_evm_fuzz::Fuzzer; pub use foundry_evm_traces::{StackSnapshotType, TracingInspector, TracingInspectorConfig}; -mod access_list; -pub use access_list::AccessListTracer; +pub use revm_inspectors::access_list::AccessListInspector; mod chisel_state; pub use chisel_state::ChiselState; diff --git a/crates/evm/evm/src/inspectors/printer.rs b/crates/evm/evm/src/inspectors/printer.rs index 02a47fda178aa..81110669f2baa 100644 --- a/crates/evm/evm/src/inspectors/printer.rs +++ b/crates/evm/evm/src/inspectors/printer.rs @@ -1,7 +1,6 @@ -use alloy_primitives::{Address, Bytes}; use revm::{ - interpreter::{opcode, CallInputs, CreateInputs, Gas, InstructionResult, Interpreter}, - Database, EVMData, Inspector, + interpreter::{opcode, CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}, + Database, EvmContext, Inspector, }; #[derive(Clone, Debug, Default)] @@ -11,13 +10,13 @@ pub struct TracePrinter; impl Inspector for TracePrinter { // get opcode by calling `interp.contract.opcode(interp.program_counter())`. // all other information can be obtained from interp. - fn step(&mut self, interp: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { + fn step(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { let opcode = interp.current_opcode(); let opcode_str = opcode::OPCODE_JUMPMAP[opcode as usize]; let gas_remaining = interp.gas.remaining(); println!( "depth:{}, PC:{}, gas:{:#x}({}), OPCODE: {:?}({:?}) refund:{:#x}({}) Stack:{:?}, Data size:{}, Data: 0x{}", - data.journaled_state.depth(), + ecx.journaled_state.depth(), interp.program_counter(), gas_remaining, gas_remaining, @@ -31,11 +30,12 @@ impl Inspector for TracePrinter { ); } + #[inline] fn call( &mut self, - _data: &mut EVMData<'_, DB>, + _context: &mut EvmContext, inputs: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { + ) -> Option { println!( "SM CALL: {},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}", inputs.contract, @@ -44,14 +44,15 @@ impl Inspector for TracePrinter { inputs.transfer, inputs.input.len(), ); - (InstructionResult::Continue, Gas::new(0), Bytes::new()) + None } + #[inline] fn create( &mut self, - _data: &mut EVMData<'_, DB>, + _context: &mut EvmContext, inputs: &mut CreateInputs, - ) -> (InstructionResult, Option
, Gas, Bytes) { + ) -> Option { println!( "CREATE CALL: caller:{}, scheme:{:?}, value:{:?}, init_code:{:?}, gas:{:?}", inputs.caller, @@ -60,6 +61,6 @@ impl Inspector for TracePrinter { hex::encode(&inputs.init_code), inputs.gas_limit ); - (InstructionResult::Continue, None, Gas::new(0), Bytes::new()) + None } } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 94152a444486e..c118bcd3dc101 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -2,22 +2,17 @@ use super::{ Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Debugger, Fuzzer, LogCollector, StackSnapshotType, TracePrinter, TracingInspector, TracingInspectorConfig, }; -use alloy_primitives::{Address, Bytes, Log, B256, U256}; -use foundry_evm_core::{ - backend::DatabaseExt, - debug::DebugArena, - utils::{eval_to_instruction_result, halt_to_instruction_result}, -}; +use alloy_primitives::{Address, Bytes, Log, U256}; +use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ - evm_inner, interpreter::{ - return_revert, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, Interpreter, - Stack, + CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, + Interpreter, InterpreterResult, }, - primitives::{BlockEnv, Env, ExecutionResult, Output, State, TransactTo}, - DatabaseCommit, EVMData, Inspector, + primitives::{BlockEnv, Env, EnvWithHandlerCfg, ExecutionResult, Output, State, TransactTo}, + DatabaseCommit, EvmContext, Inspector, }; use std::{collections::HashMap, sync::Arc}; @@ -241,7 +236,7 @@ pub struct InspectorData { pub debug: Option, pub coverage: Option, pub cheatcodes: Option, - pub chisel_state: Option<(Stack, Vec, InstructionResult)>, + pub chisel_state: Option<(Vec, Vec, InstructionResult)>, } /// Contains data about the state of outer/main EVM which created and invoked the inner EVM context. @@ -403,12 +398,11 @@ impl InspectorStack { fn do_call_end( &mut self, - data: &mut EVMData<'_, DB>, - call: &CallInputs, - remaining_gas: Gas, - status: InstructionResult, - retdata: Bytes, - ) -> (InstructionResult, Gas, Bytes) { + ecx: &mut EvmContext<&mut DB>, + inputs: &CallInputs, + outcome: CallOutcome, + ) -> CallOutcome { + let result = outcome.result.result; call_inspectors_adjust_depth!( [ &mut self.fuzzer, @@ -420,93 +414,106 @@ impl InspectorStack { &mut self.printer ], |inspector| { - let (new_status, new_gas, new_retdata) = - inspector.call_end(data, call, remaining_gas, status, retdata.clone()); + let new_outcome = inspector.call_end(ecx, inputs, outcome.clone()); // If the inspector returns a different status or a revert with a non-empty message, // we assume it wants to tell us something - if new_status != status || - (new_status == InstructionResult::Revert && new_retdata != retdata) + if new_outcome.result.result != result || + (new_outcome.result.result == InstructionResult::Revert && + new_outcome.output() != outcome.output()) { - Some((new_status, new_gas, new_retdata)) + Some(new_outcome) } else { None } }, self, - data + ecx ); - (status, remaining_gas, retdata) + + outcome } fn transact_inner( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext<&mut DB>, transact_to: TransactTo, caller: Address, input: Bytes, gas_limit: u64, value: U256, - ) -> (InstructionResult, Option
, Gas, Bytes) { - data.db.commit(data.journaled_state.state.clone()); + ) -> (InterpreterResult, Option
) { + ecx.db.commit(ecx.journaled_state.state.clone()); - let nonce = data + let nonce = ecx .journaled_state - .load_account(caller, data.db) + .load_account(caller, &mut ecx.db) .expect("failed to load caller") .0 .info .nonce; - let cached_env = data.env.clone(); + let cached_env = ecx.env.clone(); - data.env.block.basefee = U256::ZERO; - data.env.tx.caller = caller; - data.env.tx.transact_to = transact_to.clone(); - data.env.tx.data = input; - data.env.tx.value = value; - data.env.tx.nonce = Some(nonce); + ecx.env.block.basefee = U256::ZERO; + ecx.env.tx.caller = caller; + ecx.env.tx.transact_to = transact_to.clone(); + ecx.env.tx.data = input; + ecx.env.tx.value = value; + ecx.env.tx.nonce = Some(nonce); // Add 21000 to the gas limit to account for the base cost of transaction. - data.env.tx.gas_limit = gas_limit + 21000; + ecx.env.tx.gas_limit = gas_limit + 21000; // If we haven't disabled gas limit checks, ensure that transaction gas limit will not // exceed block gas limit. - if !data.env.cfg.disable_block_gas_limit { - data.env.tx.gas_limit = - std::cmp::min(data.env.tx.gas_limit, data.env.block.gas_limit.to()); + if !ecx.env.cfg.disable_block_gas_limit { + ecx.env.tx.gas_limit = + std::cmp::min(ecx.env.tx.gas_limit, ecx.env.block.gas_limit.to()); } - data.env.tx.gas_price = U256::ZERO; + ecx.env.tx.gas_price = U256::ZERO; self.inner_context_data = Some(InnerContextData { - sender: data.env.tx.caller, + sender: ecx.env.tx.caller, original_origin: cached_env.tx.caller, original_sender_nonce: nonce, is_create: matches!(transact_to, TransactTo::Create(_)), }); self.in_inner_context = true; - let res = evm_inner(data.env, data.db, Some(self)).transact(); + + let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); + let res = { + let mut evm = crate::utils::new_evm_with_inspector(&mut *ecx.db, env, &mut *self); + let res = evm.transact(); + + // need to reset the env in case it was modified via cheatcodes during execution + ecx.env = evm.context.evm.env; + res + }; + self.in_inner_context = false; self.inner_context_data = None; - data.env.tx = cached_env.tx; - data.env.block.basefee = cached_env.block.basefee; + ecx.env.tx = cached_env.tx; + ecx.env.block.basefee = cached_env.block.basefee; let mut gas = Gas::new(gas_limit); let Ok(mut res) = res else { // Should we match, encode and propagate error as a revert reason? - return (InstructionResult::Revert, None, gas, Bytes::new()); + let result = + InterpreterResult { result: InstructionResult::Revert, output: Bytes::new(), gas }; + return (result, None) }; // Commit changes after transaction - data.db.commit(res.state.clone()); + ecx.db.commit(res.state.clone()); // Update both states with new DB data after commit. - update_state(&mut data.journaled_state.state, data.db); - update_state(&mut res.state, data.db); + update_state(&mut ecx.journaled_state.state, &mut ecx.db); + update_state(&mut res.state, &mut ecx.db); // Merge transaction journal into the active journal. for (addr, acc) in res.state { - if let Some(acc_mut) = data.journaled_state.state.get_mut(&addr) { + if let Some(acc_mut) = ecx.journaled_state.state.get_mut(&addr) { acc_mut.status |= acc.status; for (key, val) in acc.storage { if !acc_mut.storage.contains_key(&key) { @@ -514,11 +521,11 @@ impl InspectorStack { } } } else { - data.journaled_state.state.insert(addr, acc); + ecx.journaled_state.state.insert(addr, acc); } } - match res.result { + let (result, address, output) = match res.result { ExecutionResult::Success { reason, gas_used, gas_refunded, logs: _, output } => { gas.set_refund(gas_refunded as i64); gas.record_cost(gas_used); @@ -526,27 +533,31 @@ impl InspectorStack { Output::Create(_, address) => address, Output::Call(_) => None, }; - (eval_to_instruction_result(reason), address, gas, output.into_data()) + (reason.into(), address, output.into_data()) } ExecutionResult::Halt { reason, gas_used } => { gas.record_cost(gas_used); - (halt_to_instruction_result(reason), None, gas, Bytes::new()) + (reason.into(), None, Bytes::new()) } ExecutionResult::Revert { gas_used, output } => { gas.record_cost(gas_used); - (InstructionResult::Revert, None, gas, output) + (InstructionResult::Revert, None, output) } - } + }; + (InterpreterResult { result, output, gas }, address) } /// Adjusts the EVM data for the inner EVM context. /// Should be called on the top-level call of inner context (depth == 0 && /// self.in_inner_context) Decreases sender nonce for CALLs to keep backwards compatibility /// Updates tx.origin to the value before entering inner context - fn adjust_evm_data_for_inner_context(&mut self, data: &mut EVMData<'_, DB>) { + fn adjust_evm_data_for_inner_context( + &mut self, + ecx: &mut EvmContext<&mut DB>, + ) { let inner_context_data = self.inner_context_data.as_ref().expect("should be called in inner context"); - let sender_acc = data + let sender_acc = ecx .journaled_state .state .get_mut(&inner_context_data.sender) @@ -554,13 +565,17 @@ impl InspectorStack { if !inner_context_data.is_create { sender_acc.info.nonce = inner_context_data.original_sender_nonce; } - data.env.tx.caller = inner_context_data.original_origin; + ecx.env.tx.caller = inner_context_data.original_origin; } } -impl Inspector for InspectorStack { - fn initialize_interp(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { - let res = interpreter.instruction_result; +// NOTE: `&mut DB` is required because we recurse inside of `transact_inner` and we need to use the +// same reference to the DB, otherwise there's infinite recursion and Rust fails to instatiate this +// implementation. This currently works because internally we only use `&mut DB` anyways, but if +// this ever needs to be changed, this can be reverted back to using just `DB`, and instead using +// dynamic dispatch (`&mut dyn ...`) in `transact_inner`. +impl Inspector<&mut DB> for InspectorStack { + fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( [ &mut self.debugger, @@ -571,22 +586,15 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - inspector.initialize_interp(interpreter, data); - - // Allow inspectors to exit early - if interpreter.instruction_result != res { - Some(()) - } else { - None - } + inspector.initialize_interp(interpreter, ecx); + None::<()> }, self, - data + ecx ); } - fn step(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { - let res = interpreter.instruction_result; + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( [ &mut self.fuzzer, @@ -598,40 +606,15 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - inspector.step(interpreter, data); - - // Allow inspectors to exit early - if interpreter.instruction_result != res { - Some(()) - } else { - None - } - }, - self, - data - ); - } - - fn log( - &mut self, - evm_data: &mut EVMData<'_, DB>, - address: &Address, - topics: &[B256], - data: &Bytes, - ) { - call_inspectors_adjust_depth!( - [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], - |inspector| { - inspector.log(evm_data, address, topics, data); - None + inspector.step(interpreter, ecx); + None::<()> }, self, - evm_data + ecx ); } - fn step_end(&mut self, interpreter: &mut Interpreter<'_>, data: &mut EVMData<'_, DB>) { - let res = interpreter.instruction_result; + fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( [ &mut self.debugger, @@ -642,28 +625,34 @@ impl Inspector for InspectorStack { &mut self.chisel_state ], |inspector| { - inspector.step_end(interpreter, data); + inspector.step_end(interpreter, ecx); + None::<()> + }, + self, + ecx + ); + } - // Allow inspectors to exit early - if interpreter.instruction_result != res { - Some(()) - } else { - None - } + fn log(&mut self, ecx: &mut EvmContext<&mut DB>, log: &Log) { + call_inspectors_adjust_depth!( + [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], + |inspector| { + inspector.log(ecx, log); + None::<()> }, self, - data + ecx ); } fn call( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext<&mut DB>, call: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { - if self.in_inner_context && data.journaled_state.depth == 0 { - self.adjust_evm_data_for_inner_context(data); - return (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()); + ) -> Option { + if self.in_inner_context && ecx.journaled_state.depth == 0 { + self.adjust_evm_data_for_inner_context(ecx); + return None; } call_inspectors_adjust_depth!( @@ -677,73 +666,70 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let (status, gas, retdata) = inspector.call(data, call); - - // Allow inspectors to exit early - if status != InstructionResult::Continue { - Some((status, gas, retdata)) - } else { - None + let mut out = None; + if let Some(output) = inspector.call(ecx, call) { + if output.result.result != InstructionResult::Continue { + out = Some(Some(output)); + } } + out }, self, - data + ecx ); if self.enable_isolation && call.context.scheme == CallScheme::Call && !self.in_inner_context && - data.journaled_state.depth == 1 + ecx.journaled_state.depth == 1 { - let (res, _, gas, output) = self.transact_inner( - data, + let (result, _) = self.transact_inner( + ecx, TransactTo::Call(call.contract), call.context.caller, call.input.clone(), call.gas_limit, call.transfer.value, ); - return (res, gas, output); + return Some(CallOutcome { result, memory_offset: call.return_memory_offset.clone() }) } - (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) + None } fn call_end( &mut self, - data: &mut EVMData<'_, DB>, - call: &CallInputs, - remaining_gas: Gas, - status: InstructionResult, - retdata: Bytes, - ) -> (InstructionResult, Gas, Bytes) { + ecx: &mut EvmContext<&mut DB>, + inputs: &CallInputs, + outcome: CallOutcome, + ) -> CallOutcome { // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. // Avoid processing twice. - if self.in_inner_context && data.journaled_state.depth == 0 { - return (status, remaining_gas, retdata); + if self.in_inner_context && ecx.journaled_state.depth == 0 { + return outcome } - let res = self.do_call_end(data, call, remaining_gas, status, retdata); - if matches!(res.0, return_revert!()) { + let outcome = self.do_call_end(ecx, inputs, outcome); + if outcome.result.is_revert() { // Encountered a revert, since cheatcodes may have altered the evm state in such a way // that violates some constraints, e.g. `deal`, we need to manually roll back on revert // before revm reverts the state itself if let Some(cheats) = self.cheatcodes.as_mut() { - cheats.on_revert(data); + cheats.on_revert(ecx); } } - res + outcome } fn create( &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CreateInputs, - ) -> (InstructionResult, Option
, Gas, Bytes) { - if self.in_inner_context && data.journaled_state.depth == 0 { - self.adjust_evm_data_for_inner_context(data); - return (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()); + ecx: &mut EvmContext<&mut DB>, + create: &mut CreateInputs, + ) -> Option { + if self.in_inner_context && ecx.journaled_state.depth == 0 { + self.adjust_evm_data_for_inner_context(ecx); + return None; } call_inspectors_adjust_depth!( @@ -755,48 +741,40 @@ impl Inspector for InspectorStack { &mut self.cheatcodes, &mut self.printer ], - |inspector| { - let (status, addr, gas, retdata) = inspector.create(data, call); - - // Allow inspectors to exit early - if status != InstructionResult::Continue { - Some((status, addr, gas, retdata)) - } else { - None - } - }, + |inspector| { inspector.create(ecx, create).map(Some) }, self, - data + ecx ); - if self.enable_isolation && !self.in_inner_context && data.journaled_state.depth == 1 { - return self.transact_inner( - data, - TransactTo::Create(call.scheme), - call.caller, - call.init_code.clone(), - call.gas_limit, - call.value, + if self.enable_isolation && !self.in_inner_context && ecx.journaled_state.depth == 1 { + let (result, address) = self.transact_inner( + ecx, + TransactTo::Create(create.scheme), + create.caller, + create.init_code.clone(), + create.gas_limit, + create.value, ); + return Some(CreateOutcome { result, address }) } - (InstructionResult::Continue, None, Gas::new(call.gas_limit), Bytes::new()) + None } fn create_end( &mut self, - data: &mut EVMData<'_, DB>, + ecx: &mut EvmContext<&mut DB>, call: &CreateInputs, - status: InstructionResult, - address: Option
, - remaining_gas: Gas, - retdata: Bytes, - ) -> (InstructionResult, Option
, Gas, Bytes) { + outcome: CreateOutcome, + ) -> CreateOutcome { // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. // Avoid processing twice. - if self.in_inner_context && data.journaled_state.depth == 0 { - return (status, address, remaining_gas, retdata); + if self.in_inner_context && ecx.journaled_state.depth == 0 { + return outcome } + + let result = outcome.result.result; + call_inspectors_adjust_depth!( [ &mut self.debugger, @@ -807,26 +785,24 @@ impl Inspector for InspectorStack { &mut self.printer ], |inspector| { - let (new_status, new_address, new_gas, new_retdata) = inspector.create_end( - data, - call, - status, - address, - remaining_gas, - retdata.clone(), - ); - - if new_status != status { - Some((new_status, new_address, new_gas, new_retdata)) + let new_outcome = inspector.create_end(ecx, call, outcome.clone()); + + // If the inspector returns a different status or a revert with a non-empty message, + // we assume it wants to tell us something + if new_outcome.result.result != result || + (new_outcome.result.result == InstructionResult::Revert && + new_outcome.output() != outcome.output()) + { + Some(new_outcome) } else { None } }, self, - data + ecx ); - (status, address, remaining_gas, retdata) + outcome } fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index 65c6e5ec99c8f..e58afb214feea 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -1,8 +1,7 @@ use crate::{invariant::RandomCallGenerator, strategies::EvmFuzzState}; -use alloy_primitives::Bytes; use revm::{ - interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, - Database, EVMData, Inspector, + interpreter::{CallInputs, CallOutcome, CallScheme, Interpreter}, + Database, EvmContext, Inspector, }; /// An inspector that can fuzz and collect data for that effect. @@ -18,41 +17,35 @@ pub struct Fuzzer { impl Inspector for Fuzzer { #[inline] - fn step(&mut self, interpreter: &mut Interpreter<'_>, _: &mut EVMData<'_, DB>) { + fn step(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { // We only collect `stack` and `memory` data before and after calls. if self.collect { - self.collect_data(interpreter); + self.collect_data(interp); self.collect = false; } } #[inline] - fn call( - &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CallInputs, - ) -> (InstructionResult, Gas, Bytes) { + fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { // We don't want to override the very first call made to the test contract. - if self.call_generator.is_some() && data.env.tx.caller != call.context.caller { - self.override_call(call); + if self.call_generator.is_some() && ecx.env.tx.caller != inputs.context.caller { + self.override_call(inputs); } // We only collect `stack` and `memory` data before and after calls. // this will be turned off on the next `step` self.collect = true; - (InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new()) + None } #[inline] fn call_end( &mut self, - _: &mut EVMData<'_, DB>, - _: &CallInputs, - remaining_gas: Gas, - status: InstructionResult, - retdata: Bytes, - ) -> (InstructionResult, Gas, Bytes) { + _context: &mut EvmContext, + _inputs: &CallInputs, + outcome: CallOutcome, + ) -> CallOutcome { if let Some(ref mut call_generator) = self.call_generator { call_generator.used = false; } @@ -61,13 +54,13 @@ impl Inspector for Fuzzer { // this will be turned off on the next `step` self.collect = true; - (status, remaining_gas, retdata) + outcome } } impl Fuzzer { /// Collects `stack` and `memory` values into the fuzz dictionary. - fn collect_data(&mut self, interpreter: &Interpreter<'_>) { + fn collect_data(&mut self, interpreter: &Interpreter) { let mut state = self.fuzz_state.write(); for slot in interpreter.stack().data() { diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 59f6402d368ad..d91af9dc6c76c 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -311,7 +311,7 @@ impl ScriptRunner { match res.exit_reason { InstructionResult::Revert | InstructionResult::OutOfGas | - InstructionResult::OutOfFund => { + InstructionResult::OutOfFunds => { lowest_gas_limit = mid_gas_limit; } _ => { diff --git a/testdata/cheats/MemSafety.t.sol b/testdata/cheats/MemSafety.t.sol index 48205233b1e34..eb00e77de5619 100644 --- a/testdata/cheats/MemSafety.t.sol +++ b/testdata/cheats/MemSafety.t.sol @@ -411,6 +411,22 @@ contract MemSafetyTest is DSTest { uint256 b = a + 1; } + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `MLOAD` opcode. + function testExpectSafeMemory_MLOAD_REVERT() public { + vm.expectSafeMemory(0x80, 0x100); + + vm.expectRevert(); + + // This should revert. Ugly hack to make sure the mload isn't optimized + // out. + uint256 a; + assembly { + a := mload(0x100) + } + uint256 b = a + 1; + } + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` /// will cause the test to fail while using the `MLOAD` opcode. function testFailExpectSafeMemory_MLOAD() public { @@ -486,6 +502,17 @@ contract MemSafetyTest is DSTest { } } + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `LOG0` opcode. + function testExpectSafeMemory_LOG0_REVERT() public { + vm.expectSafeMemory(0x80, 0x100); + vm.expectRevert(); + // This should revert. + assembly { + log0(0x100, 0x20) + } + } + //////////////////////////////////////////////////////////////// // CREATE/CREATE2 (Read Expansion) // //////////////////////////////////////////////////////////////// From 55c30ddac8d314c16dc3b1f5fa269a84e0a1d046 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 8 Mar 2024 15:17:12 +0100 Subject: [PATCH 0729/1963] fix: insert genesis hash into db (#7325) --- crates/anvil/src/config.rs | 7 ++++++- crates/anvil/src/eth/backend/fork.rs | 12 +++++------- crates/anvil/src/eth/backend/mem/mod.rs | 4 ++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 14021e289e10a..be18d28275927 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1104,7 +1104,12 @@ latest block number: {latest_block}" total_difficulty: block.header.total_difficulty.unwrap_or_default(), }; - (ForkedDatabase::new(backend, block_chain_db), config) + let mut db = ForkedDatabase::new(backend, block_chain_db); + + // need to insert the forked block's hash + db.insert_block_hash(U256::from(config.block_number), config.block_hash); + + (db, config) } } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index c763f4c9a68d1..71dadf40e46c5 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -79,15 +79,13 @@ impl ClientFork { let base_fee = block.header.base_fee_per_gas; let total_difficulty = block.header.total_difficulty.unwrap_or_default(); - self.config.write().update_block( - block.header.number.ok_or(BlockchainError::BlockNotFound)?.to::(), - block_hash, - timestamp, - base_fee, - total_difficulty, - ); + let number = block.header.number.ok_or(BlockchainError::BlockNotFound)?.to::(); + self.config.write().update_block(number, block_hash, timestamp, base_fee, total_difficulty); self.clear_cached_storage(); + + self.database.write().await.insert_block_hash(U256::from(number), block_hash); + Ok(()) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 8fb868dcd0e87..0eba1474d07c4 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -302,6 +302,10 @@ impl Backend { for (account, info) in self.genesis.account_infos() { db.insert_account(account, info); } + + // insert the new genesis hash to the database so it's available for the next block in + // the evm + db.insert_block_hash(U256::from(self.best_number()), self.best_hash()); } let db = self.db.write().await; From 0ab9e3c6fbeaa921c503c2ba1f319834b23f424b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 8 Mar 2024 15:30:34 +0100 Subject: [PATCH 0730/1963] chore: unpin nightly in ci, clippy (#7345) --- .github/workflows/test.yml | 2 -- crates/config/src/lib.rs | 2 +- crates/evm/core/src/backend/snapshot.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 2 +- crates/evm/traces/src/decoder/mod.rs | 2 +- crates/script/src/lib.rs | 1 - crates/script/src/sequence.rs | 2 +- 7 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13e2d43670fac..ffef82ca5edc0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -133,8 +133,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@clippy - with: - toolchain: nightly-2024-02-03 - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 7a1d4195d73ba..cfee46312f417 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -963,7 +963,7 @@ impl Config { (Ok(mut config), Some(key)) => { // we update the key, because if an etherscan_api_key is set, it should take // precedence over the entry, since this is usually set via env var or CLI args. - config.key = key.clone(); + config.key.clone_from(key); return Ok(Some(config)) } (Ok(config), None) => return Ok(Some(config)), diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index 35ca9222b88a6..53ce6f7ddb352 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -39,7 +39,7 @@ impl BackendSnapshot { /// journaled_state includes the same logs, we can simply replace use that See also /// `DatabaseExt::revert` pub fn merge(&mut self, current: &JournaledState) { - self.journaled_state.logs = current.logs.clone(); + self.journaled_state.logs.clone_from(¤t.logs); } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 2ec627b11e362..0a7b81943d830 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -236,7 +236,7 @@ impl<'a> InvariantExecutor<'a> { ); if !can_continue || current_run == self.config.depth - 1 { - *last_run_calldata.borrow_mut() = inputs.clone(); + last_run_calldata.borrow_mut().clone_from(&inputs); } if !can_continue { diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 78193a5f9cee6..2eac34d003a80 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -189,7 +189,7 @@ impl CallTraceDecoder { let default_labels = &Self::new().labels; if self.labels.len() > default_labels.len() { - self.labels = default_labels.clone(); + self.labels.clone_from(default_labels); } self.receive_contracts.clear(); diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 6d8fb87b83290..ef579716f2f6c 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -605,7 +605,6 @@ impl ScriptConfig { #[cfg(test)] mod tests { use super::*; - use foundry_cli::utils::LoadConfig; use foundry_config::{NamedChain, UnresolvedEnvVarError}; use std::fs; use tempfile::tempdir; diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 6a78d1ac4f584..9fdee7b021bf5 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -365,7 +365,7 @@ impl ScriptSequence { self.transactions .iter_mut() .enumerate() - .for_each(|(i, tx)| tx.rpc = sensitive.transactions[i].rpc.clone()); + .for_each(|(i, tx)| tx.rpc.clone_from(&sensitive.transactions[i].rpc)); } } From 2c6955c167ec38ecc8b514b130afb7862951d25f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 8 Mar 2024 19:01:36 +0100 Subject: [PATCH 0731/1963] chore: rename `FuzzBackendWrapper` to `CowBackend` (#7349) Name what it is not what it's used for, or something like that --- .../evm/core/src/backend/{fuzz.rs => cow.rs} | 31 +++++++------------ crates/evm/core/src/backend/mod.rs | 4 +-- crates/evm/evm/src/executors/mod.rs | 21 +++++++------ crates/forge/src/multi_runner.rs | 2 +- 4 files changed, 26 insertions(+), 32 deletions(-) rename crates/evm/core/src/backend/{fuzz.rs => cow.rs} (89%) diff --git a/crates/evm/core/src/backend/fuzz.rs b/crates/evm/core/src/backend/cow.rs similarity index 89% rename from crates/evm/core/src/backend/fuzz.rs rename to crates/evm/core/src/backend/cow.rs index 69bcac72b13fe..d8ea27c0dc813 100644 --- a/crates/evm/core/src/backend/fuzz.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -31,16 +31,16 @@ use std::{borrow::Cow, collections::HashMap}; /// function via immutable raw (no state changes) calls. /// /// **N.B.**: we're assuming cheatcodes that alter the state (like multi fork swapping) are niche. -/// If they executed during fuzzing, it will require a clone of the initial input database. This way -/// we can support these cheatcodes in fuzzing cheaply without adding overhead for fuzz tests that +/// If they executed, it will require a clone of the initial input database. +/// This way we can support these cheatcodes cheaply without adding overhead for tests that /// don't make use of them. Alternatively each test case would require its own `Backend` clone, /// which would add significant overhead for large fuzz sets even if the Database is not big after /// setup. #[derive(Clone, Debug)] -pub struct FuzzBackendWrapper<'a> { - /// The underlying immutable `Backend` +pub struct CowBackend<'a> { + /// The underlying `Backend`. /// - /// No calls on the `FuzzBackendWrapper` will ever persistently modify the `backend`'s state. + /// No calls on the `CowBackend` will ever persistently modify the `backend`'s state. pub backend: Cow<'a, Backend>, /// Keeps track of whether the backed is already initialized is_initialized: bool, @@ -48,7 +48,8 @@ pub struct FuzzBackendWrapper<'a> { spec_id: SpecId, } -impl<'a> FuzzBackendWrapper<'a> { +impl<'a> CowBackend<'a> { + /// Creates a new `CowBackend` with the given `Backend`. pub fn new(backend: &'a Backend) -> Self { Self { backend: Cow::Borrowed(backend), is_initialized: false, spec_id: SpecId::LATEST } } @@ -75,7 +76,7 @@ impl<'a> FuzzBackendWrapper<'a> { Ok(res) } - /// Returns whether there was a snapshot failure in the fuzz backend. + /// Returns whether there was a snapshot failure in the backend. /// /// This is bubbled up from the underlying Copy-On-Write backend when a revert occurs. pub fn has_snapshot_failure(&self) -> bool { @@ -105,9 +106,8 @@ impl<'a> FuzzBackendWrapper<'a> { } } -impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { +impl<'a> DatabaseExt for CowBackend<'a> { fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256 { - trace!("fuzz: create snapshot"); self.backend_mut(env).snapshot(journaled_state, env) } @@ -118,7 +118,6 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { current: &mut Env, action: RevertSnapshotAction, ) -> Option { - trace!(?id, "fuzz: revert snapshot"); self.backend_mut(current).revert(id, journaled_state, current, action) } @@ -137,7 +136,6 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { } fn create_fork(&mut self, fork: CreateFork) -> eyre::Result { - trace!("fuzz: create fork"); self.backend.to_mut().create_fork(fork) } @@ -146,7 +144,6 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { fork: CreateFork, transaction: B256, ) -> eyre::Result { - trace!(?transaction, "fuzz: create fork at"); self.backend.to_mut().create_fork_at_transaction(fork, transaction) } @@ -156,7 +153,6 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()> { - trace!(?id, "fuzz: select fork"); self.backend_mut(env).select_fork(id, env, journaled_state) } @@ -167,7 +163,6 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()> { - trace!(?id, ?block_number, "fuzz: roll fork"); self.backend_mut(env).roll_fork(id, block_number, env, journaled_state) } @@ -178,7 +173,6 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()> { - trace!(?id, ?transaction, "fuzz: roll fork to transaction"); self.backend_mut(env).roll_fork_to_transaction(id, transaction, env, journaled_state) } @@ -190,7 +184,6 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { journaled_state: &mut JournaledState, inspector: &mut I, ) -> eyre::Result<()> { - trace!(?id, ?transaction, "fuzz: execute transaction"); self.backend_mut(env).transact(id, transaction, env, journaled_state, inspector) } @@ -251,7 +244,7 @@ impl<'a> DatabaseExt for FuzzBackendWrapper<'a> { } } -impl<'a> DatabaseRef for FuzzBackendWrapper<'a> { +impl<'a> DatabaseRef for CowBackend<'a> { type Error = DatabaseError; fn basic_ref(&self, address: Address) -> Result, Self::Error> { @@ -271,7 +264,7 @@ impl<'a> DatabaseRef for FuzzBackendWrapper<'a> { } } -impl<'a> Database for FuzzBackendWrapper<'a> { +impl<'a> Database for CowBackend<'a> { type Error = DatabaseError; fn basic(&mut self, address: Address) -> Result, Self::Error> { @@ -291,7 +284,7 @@ impl<'a> Database for FuzzBackendWrapper<'a> { } } -impl<'a> DatabaseCommit for FuzzBackendWrapper<'a> { +impl<'a> DatabaseCommit for CowBackend<'a> { fn commit(&mut self, changes: Map) { self.backend.to_mut().commit(changes) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index e3b7ab3392514..1ad5ec4816de8 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -32,8 +32,8 @@ pub use diagnostic::RevertDiagnostic; mod error; pub use error::{DatabaseError, DatabaseResult}; -mod fuzz; -pub use fuzz::FuzzBackendWrapper; +mod cow; +pub use cow::CowBackend; mod in_memory_db; pub use in_memory_db::{EmptyDBWrapper, FoundryEvmInMemoryDB, MemDb}; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index f1076925fc3f9..a62d070a5ec4a 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -14,7 +14,7 @@ use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log, U256}; use foundry_common::{abi::IntoFunction, evm::Breakpoints}; use foundry_evm_core::{ - backend::{Backend, DatabaseError, DatabaseExt, DatabaseResult, FuzzBackendWrapper}, + backend::{Backend, CowBackend, DatabaseError, DatabaseExt, DatabaseResult}, constants::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, }, @@ -309,7 +309,7 @@ impl Executor { let mut inspector = self.inspector.clone(); // Build VM let mut env = self.build_test_env(from, TransactTo::Call(to), calldata, value); - let mut db = FuzzBackendWrapper::new(&self.backend); + let mut db = CowBackend::new(&self.backend); let result = db.inspect(&mut env, &mut inspector)?; // Persist the snapshot failure recorded on the fuzz backend wrapper. @@ -483,15 +483,16 @@ impl Executor { /// /// ## Background /// - /// Executing and failure checking [Executor::ensure_success] are two steps, for ds-test + /// Executing and failure checking [`Executor::ensure_success`] are two steps, for ds-test /// legacy reasons failures can be stored in a global variables and needs to be called via a - /// solidity call `failed()(bool)`. For fuzz tests we’re using the - /// `FuzzBackendWrapper` which is a Cow of the executor’s backend which lazily clones the - /// backend when it’s mutated via cheatcodes like `snapshot`. Snapshots make it even - /// more complicated because now we also need to keep track of that global variable when we - /// revert to a snapshot (because it is stored in state). Now, the problem is that - /// the `FuzzBackendWrapper` is dropped after every call, so we need to keep track of the - /// snapshot failure in the [RawCallResult] instead. + /// solidity call `failed()(bool)`. + /// + /// For fuzz tests we’re using the `CowBackend` which is a Cow of the executor’s backend which + /// lazily clones the backend when it’s mutated via cheatcodes like `snapshot`. Snapshots + /// make it even more complicated because now we also need to keep track of that global + /// variable when we revert to a snapshot (because it is stored in state). Now, the problem + /// is that the `CowBackend` is dropped after every call, so we need to keep track of the + /// snapshot failure in the [`RawCallResult`] instead. pub fn is_raw_call_success( &self, address: Address, diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 36d2f2fd897df..7712a7ee6a36a 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -345,7 +345,7 @@ impl MultiContractRunnerBuilder { } if let Some(bytes) = linked_contract.get_deployed_bytecode_bytes() { - known_contracts.insert(id.clone(), (abi.clone(), bytes.to_vec())); + known_contracts.insert(id.clone(), (abi.clone(), bytes.into_owned().into())); } } From 9ec42d6f03bafbd3b9bb8e258ca67d7887b1f2e7 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 8 Mar 2024 22:01:47 +0400 Subject: [PATCH 0732/1963] fix(forge): correctly write build info (#7347) fix --- crates/config/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index cfee46312f417..dd0bf98076ffa 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -679,7 +679,7 @@ impl Config { .set_auto_detect(self.is_auto_detect()) .set_offline(self.offline) .set_cached(cached) - .set_build_info(cached && self.build_info) + .set_build_info(!no_artifacts && self.build_info) .set_no_artifacts(no_artifacts) .build()?; From 9f6bb3bb47de9d5a1f2a6c38cbc57e0f4f5508c2 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Sat, 9 Mar 2024 16:28:12 +0100 Subject: [PATCH 0733/1963] fix(cheatcodes): add repro test for once reported issues around empty JSON arrays (#7348) * add repro case, fortunately issue has been resolved over time * revert debug line --- crates/forge/tests/it/repros.rs | 3 ++ testdata/fixtures/Json/Issue4402.json | 4 ++ testdata/fixtures/Toml/Issue4402.toml | 2 + testdata/repros/Issue4402.t.sol | 64 +++++++++++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 testdata/fixtures/Json/Issue4402.json create mode 100644 testdata/fixtures/Toml/Issue4402.toml create mode 100644 testdata/repros/Issue4402.t.sol diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index d8b4447cfb9eb..108434e50823a 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -176,6 +176,9 @@ test_repro!(3753); // https://github.com/foundry-rs/foundry/issues/3792 test_repro!(3792); +// https://github.com/foundry-rs/foundry/issues/4402 +test_repro!(4402); + // https://github.com/foundry-rs/foundry/issues/4586 test_repro!(4586); diff --git a/testdata/fixtures/Json/Issue4402.json b/testdata/fixtures/Json/Issue4402.json new file mode 100644 index 0000000000000..e981817fe9051 --- /dev/null +++ b/testdata/fixtures/Json/Issue4402.json @@ -0,0 +1,4 @@ +{ + "tokens": ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], + "empty": [] +} \ No newline at end of file diff --git a/testdata/fixtures/Toml/Issue4402.toml b/testdata/fixtures/Toml/Issue4402.toml new file mode 100644 index 0000000000000..8f7d110238c89 --- /dev/null +++ b/testdata/fixtures/Toml/Issue4402.toml @@ -0,0 +1,2 @@ +tokens = ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"] +empty = [] diff --git a/testdata/repros/Issue4402.t.sol b/testdata/repros/Issue4402.t.sol new file mode 100644 index 0000000000000..c69285b7f04eb --- /dev/null +++ b/testdata/repros/Issue4402.t.sol @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/4402 +contract Issue4402Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testReadNonEmptyArray() public { + string memory path = "fixtures/Json/Issue4402.json"; + string memory json = vm.readFile(path); + address[] memory tokens = vm.parseJsonAddressArray(json, ".tokens"); + assertEq(tokens.length, 1); + + path = "fixtures/Toml/Issue4402.toml"; + string memory toml = vm.readFile(path); + tokens = vm.parseTomlAddressArray(toml, ".tokens"); + assertEq(tokens.length, 1); + } + + function testReadEmptyArray() public { + string memory path = "fixtures/Json/Issue4402.json"; + string memory json = vm.readFile(path); + + // Every one of these used to causes panic + address[] memory emptyAddressArray = vm.parseJsonAddressArray(json, ".empty"); + bool[] memory emptyBoolArray = vm.parseJsonBoolArray(json, ".empty"); + bytes[] memory emptyBytesArray = vm.parseJsonBytesArray(json, ".empty"); + bytes32[] memory emptyBytes32Array = vm.parseJsonBytes32Array(json, ".empty"); + string[] memory emptyStringArray = vm.parseJsonStringArray(json, ".empty"); + int256[] memory emptyIntArray = vm.parseJsonIntArray(json, ".empty"); + uint256[] memory emptyUintArray = vm.parseJsonUintArray(json, ".empty"); + + assertEq(emptyAddressArray.length, 0); + assertEq(emptyBoolArray.length, 0); + assertEq(emptyBytesArray.length, 0); + assertEq(emptyBytes32Array.length, 0); + assertEq(emptyStringArray.length, 0); + assertEq(emptyIntArray.length, 0); + assertEq(emptyUintArray.length, 0); + + path = "fixtures/Toml/Issue4402.toml"; + string memory toml = vm.readFile(path); + + // Every one of these used to causes panic + emptyAddressArray = vm.parseTomlAddressArray(toml, ".empty"); + emptyBoolArray = vm.parseTomlBoolArray(toml, ".empty"); + emptyBytesArray = vm.parseTomlBytesArray(toml, ".empty"); + emptyBytes32Array = vm.parseTomlBytes32Array(toml, ".empty"); + emptyStringArray = vm.parseTomlStringArray(toml, ".empty"); + emptyIntArray = vm.parseTomlIntArray(toml, ".empty"); + emptyUintArray = vm.parseTomlUintArray(toml, ".empty"); + + assertEq(emptyAddressArray.length, 0); + assertEq(emptyBoolArray.length, 0); + assertEq(emptyBytesArray.length, 0); + assertEq(emptyBytes32Array.length, 0); + assertEq(emptyStringArray.length, 0); + assertEq(emptyIntArray.length, 0); + assertEq(emptyUintArray.length, 0); + } +} From 15c8d119d4af426e4c4369fd08a9676b676d767d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 11 Mar 2024 16:22:53 +0400 Subject: [PATCH 0734/1963] feat(test): include data from fuzz/invariant runs in gas reports (#7324) feat(test): include data from fuzz/invariant runs when building gas reports --- crates/config/src/fuzz.rs | 3 + crates/config/src/invariant.rs | 3 + crates/evm/evm/src/executors/fuzz/mod.rs | 22 +++-- .../evm/evm/src/executors/invariant/error.rs | 3 + crates/evm/evm/src/executors/invariant/mod.rs | 17 ++++ crates/evm/fuzz/src/lib.rs | 4 + crates/forge/bin/cmd/test/mod.rs | 88 ++++++++++++++++++- crates/forge/src/gas_report.rs | 16 ++-- crates/forge/src/result.rs | 12 ++- crates/forge/src/runner.rs | 36 ++++---- crates/forge/tests/it/test_helpers.rs | 2 + 11 files changed, 173 insertions(+), 33 deletions(-) diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index 11d214670488c..13e8d34d3f2f5 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -22,6 +22,8 @@ pub struct FuzzConfig { /// The fuzz dictionary configuration #[serde(flatten)] pub dictionary: FuzzDictionaryConfig, + /// Number of runs to execute and include in the gas report. + pub gas_report_samples: u32, } impl Default for FuzzConfig { @@ -31,6 +33,7 @@ impl Default for FuzzConfig { max_test_rejects: 65536, seed: None, dictionary: FuzzDictionaryConfig::default(), + gas_report_samples: 256, } } } diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 0eb96bdee2a2e..13c203d396fa2 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -35,6 +35,8 @@ pub struct InvariantConfig { /// The maximum number of rejects via `vm.assume` which can be encountered during a single /// invariant run. pub max_assume_rejects: u32, + /// Number of runs to execute and include in the gas report. + pub gas_report_samples: u32, } impl Default for InvariantConfig { @@ -49,6 +51,7 @@ impl Default for InvariantConfig { shrink_run_limit: 2usize.pow(18_u32), preserve_state: false, max_assume_rejects: 65536, + gas_report_samples: 256, } } } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index ab8989f30f02c..ec980c01ae3c1 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -71,8 +71,11 @@ impl FuzzedExecutor { // Stores the result and calldata of the last failed call, if any. let counterexample: RefCell<(Bytes, RawCallResult)> = RefCell::default(); - // Stores the last successful call trace - let traces: RefCell> = RefCell::default(); + // We want to collect at least one trace which will be displayed to user. + let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize; + + // Stores up to `max_traces_to_collect` traces. + let traces: RefCell> = RefCell::default(); // Stores coverage information for all fuzz cases let coverage: RefCell> = RefCell::default(); @@ -103,8 +106,12 @@ impl FuzzedExecutor { if first_case.is_none() { first_case.replace(case.case); } - - traces.replace(case.traces); + if let Some(call_traces) = case.traces { + if traces.borrow().len() == max_traces_to_collect { + traces.borrow_mut().pop(); + } + traces.borrow_mut().push(call_traces); + } if let Some(prev) = coverage.take() { // Safety: If `Option::or` evaluates to `Some`, then `call.coverage` must @@ -137,6 +144,10 @@ impl FuzzedExecutor { }); let (calldata, call) = counterexample.into_inner(); + + let mut traces = traces.into_inner(); + let last_run_traces = if run_result.is_ok() { traces.pop() } else { call.traces.clone() }; + let mut result = FuzzTestResult { first_case: first_case.take().unwrap_or_default(), gas_by_case: gas_by_case.take(), @@ -146,7 +157,8 @@ impl FuzzedExecutor { decoded_logs: decode_console_logs(&call.logs), logs: call.logs, labeled_addresses: call.labels, - traces: if run_result.is_ok() { traces.into_inner() } else { call.traces.clone() }, + traces: last_run_traces, + gas_report_traces: traces, coverage: coverage.into_inner(), }; diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 8acc67f6a7834..da29e657e0ef2 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -50,6 +50,9 @@ pub struct InvariantFuzzTestResult { /// The entire inputs of the last run of the invariant campaign, used for /// replaying the run for collecting traces. pub last_run_inputs: Vec, + + /// Additional traces used for gas report construction. + pub gas_report_traces: Vec>, } #[derive(Clone, Debug)] diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 0a7b81943d830..591fa7cf444df 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -23,6 +23,7 @@ use foundry_evm_fuzz::{ }, FuzzCase, FuzzedCases, }; +use foundry_evm_traces::CallTraceArena; use parking_lot::{Mutex, RwLock}; use proptest::{ strategy::{BoxedStrategy, Strategy, ValueTree}, @@ -123,6 +124,9 @@ impl<'a> InvariantExecutor<'a> { // Stores the calldata in the last run. let last_run_calldata: RefCell> = RefCell::new(vec![]); + // Stores additional traces for gas report. + let gas_report_traces: RefCell>> = RefCell::default(); + // Let's make sure the invariant is sound before actually starting the run: // We'll assert the invariant in its initial state, and if it fails, we'll // already know if we can early exit the invariant run. @@ -162,6 +166,9 @@ impl<'a> InvariantExecutor<'a> { // Created contracts during a run. let mut created_contracts = vec![]; + // Traces of each call of the sequence. + let mut run_traces = Vec::new(); + let mut current_run = 0; let mut assume_rejects_counter = 0; @@ -233,6 +240,7 @@ impl<'a> InvariantExecutor<'a> { self.config.fail_on_revert, self.config.shrink_sequence, self.config.shrink_run_limit, + &mut run_traces, ); if !can_continue || current_run == self.config.depth - 1 { @@ -265,6 +273,9 @@ impl<'a> InvariantExecutor<'a> { } } + if gas_report_traces.borrow().len() < self.config.gas_report_samples as usize { + gas_report_traces.borrow_mut().push(run_traces); + } fuzz_cases.borrow_mut().push(FuzzedCases::new(fuzz_runs)); Ok(()) @@ -280,6 +291,7 @@ impl<'a> InvariantExecutor<'a> { cases: fuzz_cases.into_inner(), reverts, last_run_inputs: last_run_calldata.take(), + gas_report_traces: gas_report_traces.into_inner(), }) } @@ -764,6 +776,7 @@ fn can_continue( fail_on_revert: bool, shrink_sequence: bool, shrink_run_limit: usize, + run_traces: &mut Vec, ) -> RichInvariantResults { let mut call_results = None; @@ -775,6 +788,10 @@ fn can_continue( // Assert invariants IFF the call did not revert and the handlers did not fail. if !call_result.reverted && !handlers_failed { + if let Some(traces) = call_result.traces { + run_traces.push(traces); + } + call_results = assert_invariants( invariant_contract, executor, diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index ed3b50178f574..f8928ea3e13f5 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -150,6 +150,10 @@ pub struct FuzzTestResult { /// `num(fuzz_cases)` traces, one for each run, which is neither helpful nor performant. pub traces: Option, + /// Additional traces used for gas report construction. + /// Those traces should not be displayed. + pub gas_report_traces: Vec, + /// Raw coverage info pub coverage: Option, } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3e7d148484c46..1cea3b818fe0a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -143,6 +143,10 @@ impl TestArgs { // Explicitly enable isolation for gas reports for more correct gas accounting if self.gas_report { evm_opts.isolate = true; + } else { + // Do not collect gas report traces if gas report is not enabled. + config.fuzz.gas_report_samples = 0; + config.invariant.gas_report_samples = 0; } // Set up the project. @@ -409,7 +413,26 @@ impl TestArgs { } if let Some(gas_report) = &mut gas_report { - gas_report.analyze(&result.traces, &decoder).await; + gas_report + .analyze(result.traces.iter().map(|(_, arena)| arena), &decoder) + .await; + + for trace in result.gas_report_traces.iter() { + decoder.clear_addresses(); + + // Re-execute setup and deployment traces to collect identities created in + // setUp and constructor. + for (kind, arena) in &result.traces { + if !matches!(kind, TraceKind::Execution) { + decoder.identify(arena, &mut local_identifier); + } + } + + for arena in trace { + decoder.identify(arena, &mut local_identifier); + gas_report.analyze([arena], &decoder).await; + } + } } } @@ -431,7 +454,9 @@ impl TestArgs { outcome.decoder = Some(decoder); if let Some(gas_report) = gas_report { - shell::println(gas_report.finalize())?; + let finalized = gas_report.finalize(); + shell::println(&finalized)?; + outcome.gas_report = Some(finalized); } if !outcome.results.is_empty() { @@ -528,6 +553,7 @@ fn list( mod tests { use super::*; use foundry_config::Chain; + use foundry_test_utils::forgetest_async; #[test] fn watch_parse() { @@ -561,4 +587,62 @@ mod tests { test("--chain-id=1", Chain::mainnet()); test("--chain-id=42", Chain::from_id(42)); } + + forgetest_async!(gas_report_fuzz_invariant, |prj, _cmd| { + prj.insert_ds_test(); + prj.add_source( + "Contracts.sol", + r#" +//SPDX-license-identifier: MIT + +import "./test.sol"; + +contract Foo { + function foo() public {} +} + +contract Bar { + function bar() public {} +} + + +contract FooBarTest is DSTest { + Foo public targetContract; + + function setUp() public { + targetContract = new Foo(); + } + + function invariant_dummy() public { + assertTrue(true); + } + + function testFuzz_bar(uint256 _val) public { + (new Bar()).bar(); + } +} + "#, + ) + .unwrap(); + + let args = TestArgs::parse_from([ + "foundry-cli", + "--gas-report", + "--root", + &prj.root().to_string_lossy(), + "--silent", + ]); + + let outcome = args.run().await.unwrap(); + let gas_report = outcome.gas_report.unwrap(); + + assert_eq!(gas_report.contracts.len(), 3); + let call_cnts = gas_report + .contracts + .values() + .flat_map(|c| c.functions.values().flat_map(|f| f.values().map(|v| v.calls.len()))) + .collect::>(); + // assert that all functions were called at least 100 times + assert!(call_cnts.iter().all(|c| *c > 100)); + }); } diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index f6c269d7029ef..de36b871cb1ec 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -3,7 +3,7 @@ use crate::{ constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, hashbrown::HashSet, - traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData, TraceKind}, + traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData}, }; use comfy_table::{presets::ASCII_MARKDOWN, *}; use foundry_common::{calc, TestFunctionExt}; @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; /// Represents the gas report for a set of contracts. -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct GasReport { /// Whether to report any contracts. report_any: bool, @@ -22,7 +22,7 @@ pub struct GasReport { ignore: HashSet, /// All contracts that were analyzed grouped by their identifier /// ``test/Counter.t.sol:CounterTest - contracts: BTreeMap, + pub contracts: BTreeMap, } impl GasReport { @@ -61,10 +61,10 @@ impl GasReport { /// Analyzes the given traces and generates a gas report. pub async fn analyze( &mut self, - traces: &[(TraceKind, CallTraceArena)], + arenas: impl IntoIterator, decoder: &CallTraceDecoder, ) { - for node in traces.iter().flat_map(|(_, arena)| arena.nodes()) { + for node in arenas.into_iter().flat_map(|arena| arena.nodes()) { self.analyze_node(node, decoder).await; } } @@ -78,7 +78,7 @@ impl GasReport { // Only include top-level calls which accout for calldata and base (21.000) cost. // Only include Calls and Creates as only these calls are isolated in inspector. - if trace.depth != 1 && + if trace.depth > 1 && (trace.kind == CallKind::Call || trace.kind == CallKind::Create || trace.kind == CallKind::Create2) @@ -186,7 +186,7 @@ impl Display for GasReport { } } -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct ContractInfo { pub gas: u64, pub size: usize, @@ -194,7 +194,7 @@ pub struct ContractInfo { pub functions: BTreeMap>, } -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct GasInfo { pub calls: Vec, pub min: u64, diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 1605f72fe8f97..94c6d58fcd128 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -7,7 +7,7 @@ use foundry_evm::{ debug::DebugArena, executors::EvmError, fuzz::{CounterExample, FuzzCase}, - traces::{CallTraceDecoder, TraceKind, Traces}, + traces::{CallTraceArena, CallTraceDecoder, TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; use std::{ @@ -17,6 +17,8 @@ use std::{ }; use yansi::Paint; +use crate::gas_report::GasReport; + /// The aggregated result of a test run. #[derive(Clone, Debug)] pub struct TestOutcome { @@ -32,12 +34,14 @@ pub struct TestOutcome { /// /// Note that `Address` fields only contain the last executed test case's data. pub decoder: Option, + /// The gas report, if requested. + pub gas_report: Option, } impl TestOutcome { /// Creates a new test outcome with the given results. pub fn new(results: BTreeMap, allow_failure: bool) -> Self { - Self { results, allow_failure, decoder: None } + Self { results, allow_failure, decoder: None, gas_report: None } } /// Creates a new empty test outcome. @@ -358,6 +362,10 @@ pub struct TestResult { #[serde(skip)] pub traces: Traces, + /// Additional traces to use for gas report. + #[serde(skip)] + pub gas_report_traces: Vec>, + /// Raw coverage info #[serde(skip)] pub coverage: Option, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 29507de8d5d7a..0164cd7df0e6b 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -439,6 +439,7 @@ impl<'a> ContractRunner<'a> { debug: debug_arena, breakpoints, duration, + gas_report_traces: Vec::new(), } } @@ -491,23 +492,24 @@ impl<'a> ContractRunner<'a> { let invariant_contract = InvariantContract { address, invariant_function: func, abi: self.contract }; - let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs } = match evm - .invariant_fuzz(invariant_contract.clone()) - { - Ok(x) => x, - Err(e) => { - return TestResult { - status: TestStatus::Failure, - reason: Some(format!("failed to set up invariant testing environment: {e}")), - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - kind: TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }, - duration: start.elapsed(), - ..Default::default() + let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs, gas_report_traces } = + match evm.invariant_fuzz(invariant_contract.clone()) { + Ok(x) => x, + Err(e) => { + return TestResult { + status: TestStatus::Failure, + reason: Some(format!( + "failed to set up invariant testing environment: {e}" + )), + decoded_logs: decode_console_logs(&logs), + traces, + labeled_addresses, + kind: TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }, + duration: start.elapsed(), + ..Default::default() + } } - } - }; + }; let mut counterexample = None; let mut logs = logs.clone(); @@ -571,6 +573,7 @@ impl<'a> ContractRunner<'a> { traces, labeled_addresses: labeled_addresses.clone(), duration: start.elapsed(), + gas_report_traces, ..Default::default() // TODO collect debug traces on the last run or error } } @@ -698,6 +701,7 @@ impl<'a> ContractRunner<'a> { debug, breakpoints, duration, + gas_report_traces: result.gas_report_traces.into_iter().map(|t| vec![t]).collect(), } } } diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 609181f1a8e31..e615e27856955 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -94,6 +94,7 @@ pub static TEST_OPTS: Lazy = Lazy::new(|| { max_fuzz_dictionary_values: 10_000, max_calldata_fuzz_dictionary_addresses: 0, }, + gas_report_samples: 256, }) .invariant(InvariantConfig { runs: 256, @@ -112,6 +113,7 @@ pub static TEST_OPTS: Lazy = Lazy::new(|| { shrink_run_limit: 2usize.pow(18u32), preserve_state: false, max_assume_rejects: 65536, + gas_report_samples: 256, }) .build(&COMPILED, &PROJECT.paths.root) .expect("Config loaded") From e74d6324f74ba7dcdca61364d56bc3241dcd514c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 11 Mar 2024 19:09:40 +0400 Subject: [PATCH 0735/1963] fix: ci (#7363) * fix: ci * fmt --- crates/forge/bin/cmd/test/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1cea3b818fe0a..11ae1aee77e37 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -299,9 +299,12 @@ impl TestArgs { // Set up trace identifiers. let known_contracts = runner.known_contracts.clone(); let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - let mut identifier = TraceIdentifiers::new() - .with_local(&known_contracts) - .with_etherscan(&config, remote_chain_id)?; + let mut identifier = TraceIdentifiers::new().with_local(&known_contracts); + + // Avoid using etherscan for gas report as we decode more traces and this will be expensive. + if !self.gas_report { + identifier = identifier.with_etherscan(&config, remote_chain_id)?; + } // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); @@ -424,12 +427,12 @@ impl TestArgs { // setUp and constructor. for (kind, arena) in &result.traces { if !matches!(kind, TraceKind::Execution) { - decoder.identify(arena, &mut local_identifier); + decoder.identify(arena, &mut identifier); } } for arena in trace { - decoder.identify(arena, &mut local_identifier); + decoder.identify(arena, &mut identifier); gas_report.analyze([arena], &decoder).await; } } From ef81e23259f32b4e221f1a97c4a644dc9ed9950f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 11 Mar 2024 19:23:23 +0400 Subject: [PATCH 0736/1963] fix: disable cache if build-info is requested (#7358) --- crates/config/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index dd0bf98076ffa..00077845530a8 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -678,7 +678,7 @@ impl Config { }) .set_auto_detect(self.is_auto_detect()) .set_offline(self.offline) - .set_cached(cached) + .set_cached(cached && !self.build_info) .set_build_info(!no_artifacts && self.build_info) .set_no_artifacts(no_artifacts) .build()?; From 7545c7a2857a873fa1909ec4174032c4e4702116 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:11:02 +0100 Subject: [PATCH 0737/1963] chore(deps): bump all dependencies, revm 7 (#7365) * chore(deps): bump revm to 7.1 * chore: general cargo update ```text Updating crates.io index Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating ahash v0.8.10 -> v0.8.11 Updating bumpalo v3.15.3 -> v3.15.4 Updating cc v1.0.88 -> v1.0.90 Adding cfg_aliases v0.1.1 (latest: v0.2.0) Updating chrono v0.4.34 -> v0.4.35 Updating clap v4.5.1 -> v4.5.2 Updating clap_builder v4.5.1 -> v4.5.2 Updating const-hex v1.11.1 -> v1.11.2 Updating ctrlc v3.4.2 -> v3.4.4 Updating enr v0.10.0 -> v0.10.1 Updating env_logger v0.11.2 -> v0.11.3 Updating foundry-compilers v0.3.9 -> v0.3.10 Updating http v0.2.11 -> v0.2.12 (latest: v1.1.0) Adding jobserver v0.1.28 Updating js-sys v0.3.68 -> v0.3.69 Updating nix v0.27.1 -> v0.28.0 Updating pin-project v1.1.4 -> v1.1.5 Updating pin-project-internal v1.1.4 -> v1.1.5 Adding proc-macro-crate v3.1.0 Updating regex-automata v0.4.5 -> v0.4.6 Updating reqwest v0.11.24 -> v0.11.25 Updating serde_path_to_error v0.1.15 -> v0.1.16 Updating strum v0.26.1 -> v0.26.2 Updating strum_macros v0.26.1 -> v0.26.2 Updating system-configuration v0.5.1 -> v0.6.0 Updating system-configuration-sys v0.5.0 -> v0.6.0 Updating wasm-bindgen v0.2.91 -> v0.2.92 Updating wasm-bindgen-backend v0.2.91 -> v0.2.92 Updating wasm-bindgen-futures v0.4.41 -> v0.4.42 Updating wasm-bindgen-macro v0.2.91 -> v0.2.92 Updating wasm-bindgen-macro-support v0.2.91 -> v0.2.92 Updating wasm-bindgen-shared v0.2.91 -> v0.2.92 Updating web-sys v0.3.68 -> v0.3.69 Updating yansi v1.0.0-rc.1 -> v1.0.0 ``` * chore: chrono deprecation * chore: no default features --- .gitignore | 1 + Cargo.lock | 279 +++++++++++++++--------- Cargo.toml | 43 ++-- crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/backend/fork.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 6 +- crates/anvil/src/eth/backend/time.rs | 7 +- crates/anvil/src/pubsub.rs | 15 +- crates/anvil/tests/it/api.rs | 2 +- crates/anvil/tests/it/fork.rs | 2 +- crates/anvil/tests/it/genesis.rs | 2 +- crates/anvil/tests/it/wsapi.rs | 2 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/src/lib.rs | 5 +- crates/cheatcodes/src/evm.rs | 4 +- crates/cheatcodes/src/evm/fork.rs | 2 +- crates/cheatcodes/src/inspector.rs | 34 ++- crates/cheatcodes/src/lib.rs | 46 ++-- crates/common/src/provider/alloy.rs | 12 +- crates/evm/core/Cargo.toml | 1 - crates/evm/core/src/backend/cow.rs | 2 +- crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/fork/backend.rs | 2 +- crates/evm/core/src/fork/init.rs | 2 +- crates/evm/core/src/fork/multi.rs | 6 +- crates/evm/core/src/opts.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 5 +- 27 files changed, 291 insertions(+), 199 deletions(-) diff --git a/.gitignore b/.gitignore index 19f666e451bf9..14e811f2d511f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ out/ out.json .idea .vscode +bloat* diff --git a/Cargo.lock b/Cargo.lock index a23a5d778ed2f..113f04de8135a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "once_cell", @@ -84,13 +84,13 @@ checksum = "e96c81b05c893348760f232c4cc6a6a77fd91cfb09885d4eaad25cd03bd7732e" dependencies = [ "num_enum", "serde", - "strum 0.26.1", + "strum 0.26.2", ] [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "serde", @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,17 +214,22 @@ dependencies = [ "alloy-rpc-types", "alloy-transport", "alloy-transport-http", + "async-stream", "async-trait", "auto_impl", + "futures", + "lru", "reqwest", "serde", "thiserror", + "tokio", + "tracing", ] [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -234,6 +239,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "tokio-stream", "tower", "tracing", ] @@ -263,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -271,7 +277,10 @@ dependencies = [ "futures", "pin-project", "reqwest", + "serde", "serde_json", + "tokio", + "tokio-stream", "tower", "tracing", "url", @@ -280,7 +289,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -291,7 +300,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -304,7 +313,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-network", "alloy-primitives", @@ -365,10 +374,10 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-json-rpc", - "base64 0.21.7", + "base64 0.22.0", "futures-util", "serde", "serde_json", @@ -382,7 +391,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -395,7 +404,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -413,7 +422,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=785c667#785c667813a6c76794044b943df58fc6e397734d" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -835,6 +844,28 @@ dependencies = [ "syn 2.0.52", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "async-task" version = "4.7.0" @@ -996,6 +1027,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + [[package]] name = "base64ct" version = "1.6.0" @@ -1121,7 +1158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "serde", ] @@ -1142,9 +1179,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.15.3" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "byte-slice-cast" @@ -1310,10 +1347,11 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.88" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ + "jobserver", "libc", ] @@ -1323,6 +1361,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chisel" version = "0.2.0" @@ -1352,7 +1396,7 @@ dependencies = [ "serde_json", "serial_test", "solang-parser", - "strum 0.26.1", + "strum 0.26.2", "time", "tokio", "tracing", @@ -1363,9 +1407,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1413,9 +1457,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" dependencies = [ "clap_builder", "clap_derive", @@ -1423,9 +1467,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", @@ -1653,9 +1697,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbd12d49ab0eaf8193ba9175e45f56bbc2e4b27d57b8cfe62aa47942a46b9a9" +checksum = "b37dae8c8ded08d5ec72caa1b4204a5344047cd4a2c7387e3d150020abfbc1c9" dependencies = [ "cfg-if", "cpufeatures", @@ -1886,11 +1930,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.2" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" +checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" dependencies = [ - "nix 0.27.1", + "nix 0.28.0", "windows-sys 0.52.0", ] @@ -2236,17 +2280,17 @@ checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" [[package]] name = "enr" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" +checksum = "2dc3eabaca59dc39ea5ed15062e4abc5bba9723b1cff7a4fea3faae0647f04c0" dependencies = [ + "alloy-rlp", "base64 0.21.7", "bytes", "hex", "k256", "log", "rand 0.8.5", - "rlp", "serde", "sha3", "zeroize", @@ -2275,9 +2319,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ "anstream", "anstyle", @@ -2515,7 +2559,7 @@ dependencies = [ "rlp", "serde", "serde_json", - "strum 0.26.1", + "strum 0.26.2", "syn 2.0.52", "tempfile", "thiserror", @@ -2958,7 +3002,7 @@ dependencies = [ "serde_json", "similar", "solang-parser", - "strum 0.26.1", + "strum 0.26.2", "svm-rs", "tempfile", "thiserror", @@ -3179,7 +3223,7 @@ dependencies = [ "regex", "serde", "strsim 0.10.0", - "strum 0.26.1", + "strum 0.26.2", "tempfile", "tokio", "tracing", @@ -3241,9 +3285,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1b77c95e79bff02ddaa38426fc6809a3a438dce0e6a2eb212dac97da7c157b4" +checksum = "7f5a6dffd81de844c96fea0aaf825cd2a9760c4a768ae3f5786d431ef3c57d69" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3367,7 +3411,6 @@ dependencies = [ "alloy-providers", "alloy-rpc-types", "alloy-sol-types", - "alloy-transport", "auto_impl", "const-hex", "derive_more", @@ -3968,7 +4011,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "regex-syntax 0.8.2", ] @@ -4068,7 +4111,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.10", + "ahash 0.8.11", "allocator-api2", "serde", ] @@ -4165,9 +4208,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -4324,7 +4367,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "same-file", "walkdir", "winapi-util", @@ -4542,11 +4585,20 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jobserver" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -4667,7 +4719,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.5", + "regex-automata 0.4.6", ] [[package]] @@ -4993,12 +5045,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.4.2", "cfg-if", + "cfg_aliases", "libc", ] @@ -5162,7 +5215,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.52", @@ -5467,7 +5520,7 @@ checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" dependencies = [ "inlinable_string", "pear_codegen", - "yansi 1.0.0-rc.1", + "yansi 1.0.0", ] [[package]] @@ -5663,18 +5716,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", @@ -5834,6 +5887,15 @@ dependencies = [ "toml_edit 0.20.7", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -5877,7 +5939,7 @@ dependencies = [ "quote", "syn 2.0.52", "version_check", - "yansi 1.0.0-rc.1", + "yansi 1.0.0", ] [[package]] @@ -6151,7 +6213,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.5", + "regex-automata 0.4.6", "regex-syntax 0.8.2", ] @@ -6166,9 +6228,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -6189,9 +6251,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.24" +version = "0.11.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" dependencies = [ "base64 0.21.7", "bytes", @@ -6234,12 +6296,13 @@ dependencies = [ [[package]] name = "revm" -version = "6.1.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d35316fc02d99e42831356c71e882f5d385c77b78f64a44ae82f2f9a4b8b72f" +checksum = "217d21144d329f21d5245b8e6a46e0d6d0a527d9917d7a087f225b161e529169" dependencies = [ "auto_impl", "cfg-if", + "dyn-clone", "revm-interpreter", "revm-precompile", "serde", @@ -6249,7 +6312,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=5d560be#5d560be4cf022912f4f53f4e5ea71f81253b3c3d" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=ba0b6ab#ba0b6ab695802c752601f17f5c941b62a067ad64" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -6259,13 +6322,15 @@ dependencies = [ "colorchoice", "revm", "serde", + "serde_json", + "thiserror", ] [[package]] name = "revm-interpreter" -version = "3.1.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fa10c2dc1e8f4934bdc763a2c09371bcec29e50c22e55e3eb325ee0cba09064" +checksum = "776848391ed76d5103ca1aa1632cd21b521e2870afb30b63723da862d69efd0f" dependencies = [ "revm-primitives", "serde", @@ -6273,9 +6338,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "4.1.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db828d49d329560a70809d9d1fa0c74695edb49f50c5332db3eb24483076deac" +checksum = "e3fd1856a7cb09197a02669d779e1afb5a627b0888a24814ba2b6a1ad4c3ff8d" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6290,9 +6355,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fecd125aad58e135e2ca5771ed6e4e7b1f05fa3a64e0dfb9cc643b7a800a8435" +checksum = "2a4d7d3e793e907dc0797a9d3b43abfdf5226d133855214db9bd27d4cee33ebd" dependencies = [ "alloy-primitives", "auto_impl", @@ -6300,6 +6365,7 @@ dependencies = [ "bitvec", "c-kzg", "cfg-if", + "dyn-clone", "enumn", "hashbrown 0.14.3", "hex", @@ -6909,9 +6975,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd154a240de39fdebcf5775d2675c204d7c13cf39a4c697be6493c8e734337c" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ "itoa", "serde", @@ -7261,11 +7327,11 @@ dependencies = [ [[package]] name = "strum" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros 0.26.1", + "strum_macros 0.26.2", ] [[package]] @@ -7283,9 +7349,9 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ "heck", "proc-macro2", @@ -7413,20 +7479,20 @@ dependencies = [ [[package]] name = "system-configuration" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", @@ -7677,6 +7743,7 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", + "tokio-util", ] [[package]] @@ -8213,9 +8280,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -8223,9 +8290,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -8238,9 +8305,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -8250,9 +8317,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -8260,9 +8327,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -8273,9 +8340,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "watchexec" @@ -8327,9 +8394,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -8680,9 +8747,9 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "yansi" -version = "1.0.0-rc.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" +checksum = "6c2861d76f58ec8fc95708b9b1e417f7b12fd72ad33c01fa6886707092dea0d3" [[package]] name = "zerocopy" diff --git a/Cargo.toml b/Cargo.toml index f14e8d8911b6a..f56a5cfd7847c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,9 +142,9 @@ foundry-compilers = { version = "0.3.9", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "6.1", default-features = false } -revm-primitives = { version = "2", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "5d560be", features = [ +revm = { version = "7.1", default-features = false } +revm-primitives = { version = "3", default-features = false } +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ba0b6ab", features = [ "serde", ] } @@ -159,22 +159,22 @@ ethers-middleware = { version = "2.0.14", default-features = false } ethers-solc = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-providers = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "785c667" } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-providers = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } alloy-primitives = { version = "0.6.3", features = ["getrandom"] } alloy-dyn-abi = "0.6.3" alloy-json-abi = "0.6.3" @@ -212,3 +212,8 @@ hyper = "0.14" tower = "0.4" tower-http = "0.4" +# [patch.crates-io] +# revm = { path = "../../danipopes/revm/crates/revm" } +# revm-interpreter = { path = "../../danipopes/revm/crates/interpreter" } +# revm-primitives = { path = "../../danipopes/revm/crates/primitives" } +# revm-precompile = { path = "../../danipopes/revm/crates/precompile" } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index be18d28275927..5c61c08248bf6 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -17,7 +17,7 @@ use crate::{ }; use alloy_genesis::Genesis; use alloy_primitives::{hex, utils::Unit, U256}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::BlockNumberOrTag; use alloy_signer::{ coins_bip39::{English, Mnemonic}, diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 71dadf40e46c5..04ea0c70f5f15 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -2,7 +2,7 @@ use crate::eth::{backend::db::Db, error::BlockchainError}; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256, U64}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_trace_types::{ geth::{GethDebugTracingOptions, GethTrace}, parity::LocalizedTransactionTrace as Trace, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0eba1474d07c4..2b0bf292f2aa0 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1257,14 +1257,14 @@ impl Backend { }; let mut is_match: bool = true; if !filter.address.is_empty() && filter.has_topics() { - if !params.filter_address(&log) || !params.filter_topics(&log) { + if !params.filter_address(&log.address) || !params.filter_topics(&log.topics) { is_match = false; } } else if !filter.address.is_empty() { - if !params.filter_address(&log) { + if !params.filter_address(&log.address) { is_match = false; } - } else if filter.has_topics() && !params.filter_topics(&log) { + } else if filter.has_topics() && !params.filter_topics(&log.topics) { is_match = false; } diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index f51ff93feac1d..ce6900eb48f90 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -1,16 +1,13 @@ //! Manages the block time use crate::eth::error::BlockchainError; -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::{DateTime, Utc}; use parking_lot::RwLock; use std::{sync::Arc, time::Duration}; /// Returns the `Utc` datetime for the given seconds since unix epoch pub fn utc_from_secs(secs: u64) -> DateTime { - DateTime::::from_naive_utc_and_offset( - NaiveDateTime::from_timestamp_opt(secs as i64, 0).unwrap(), - Utc, - ) + DateTime::from_timestamp(secs as i64, 0).unwrap() } /// Manages block time diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index ce2f7e2450c48..b0b8b33bbecd2 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -152,23 +152,12 @@ pub fn filter_logs( ) -> Vec { /// Determines whether to add this log fn add_log(block_hash: B256, l: &Log, block: &Block, params: &FilteredParams) -> bool { - let log = AlloyLog { - address: l.address, - topics: l.topics().to_vec(), - data: l.data.data.clone(), - block_hash: None, - block_number: None, - transaction_hash: None, - transaction_index: None, - log_index: None, - removed: false, - }; if params.filter.is_some() { let block_number = block.header.number; if !params.filter_block_range(block_number) || !params.filter_block_hash(block_hash) || - !params.filter_address(&log) || - !params.filter_topics(&log) + !params.filter_address(&l.address) || + !params.filter_topics(l.topics()) { return false; } diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index fb3c3742b2e62..216e9581389b9 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -5,7 +5,7 @@ use crate::{ utils::ethers_http_provider, }; use alloy_primitives::{Address as rAddress, B256, U256 as rU256}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::{ request::{TransactionInput as CallInput, TransactionRequest as CallRequest}, state::{AccountOverride, StateOverride}, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 8399dc85ad312..a23cc7052ecd2 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -5,7 +5,7 @@ use crate::{ utils::{self, ethers_http_provider}, }; use alloy_primitives::{address, U256 as rU256}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::{ request::{TransactionInput, TransactionRequest as CallRequest}, BlockNumberOrTag, diff --git a/crates/anvil/tests/it/genesis.rs b/crates/anvil/tests/it/genesis.rs index 9b822aff72074..f5f5fec9cc7db 100644 --- a/crates/anvil/tests/it/genesis.rs +++ b/crates/anvil/tests/it/genesis.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use alloy_genesis::Genesis; use alloy_primitives::{Address, U256, U64}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use anvil::{spawn, NodeConfig}; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index 7d31bdbcab752..c2073f5617f7d 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -1,6 +1,6 @@ //! general eth api tests with websocket provider -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use anvil::{spawn, NodeConfig}; use ethers::types::U256; use foundry_common::types::ToAlloy; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index a9e0749621842..8de966906791f 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,5 +1,5 @@ use alloy_primitives::U256; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::BlockTransactions; use cast::revm::primitives::EnvWithHandlerCfg; use clap::Parser; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 8a0e34c946b90..38498786ea182 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -6,7 +6,7 @@ use alloy_primitives::{ }; use alloy_rlp::Decodable; use base::{Base, NumberWithBase, ToBase}; -use chrono::NaiveDateTime; +use chrono::DateTime; use ethers_core::{ types::{ transaction::eip2718::TypedTransaction, BlockId, BlockNumber, Filter, NameOrAddress, @@ -395,8 +395,7 @@ where pub async fn age>(&self, block: T) -> Result { let timestamp_str = Cast::block_field_as_num(self, block, String::from("timestamp")).await?.to_string(); - let datetime = - NaiveDateTime::from_timestamp_opt(timestamp_str.parse::().unwrap(), 0).unwrap(); + let datetime = DateTime::from_timestamp(timestamp_str.parse::().unwrap(), 0).unwrap(); Ok(datetime.format("%a %b %e %H:%M:%S %Y").to_string()) } diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index fd45200f03569..601c97ad00463 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -12,7 +12,7 @@ use foundry_evm_core::{ }; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, - EvmContext, + InnerEvmContext, }; use std::{collections::HashMap, path::Path}; @@ -521,7 +521,7 @@ fn read_callers(state: &Cheatcodes, default_sender: &Address) -> Result { /// Ensures the `Account` is loaded and touched. pub(super) fn journaled_account( - ecx: &mut EvmContext, + ecx: &mut InnerEvmContext, addr: Address, ) -> Result<&mut Account> { ecx.load_account(addr)?; diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 4b3fdc6b346bf..f5402a0d38d29 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,6 +1,6 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{B256, U256}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::Filter; use alloy_sol_types::SolValue; use eyre::WrapErr; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 3396fc876e214..9b26e77547cf2 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -30,7 +30,7 @@ use revm::{ InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, primitives::{BlockEnv, CreateScheme, TransactTo}, - EvmContext, Inspector, + EvmContext, InnerEvmContext, Inspector, }; use serde_json::Value; use std::{ @@ -228,7 +228,15 @@ impl Cheatcodes { // but only if the backend is in forking mode ecx.db.ensure_cheatcode_access_forking_mode(&caller)?; - apply_dispatch(&decoded, &mut CheatsCtxt { state: self, ecx, caller }) + apply_dispatch( + &decoded, + &mut CheatsCtxt { + state: self, + ecx: &mut ecx.inner, + precompiles: &mut ecx.precompiles, + caller, + }, + ) } /// Determines the address of the contract and marks it as allowed @@ -238,7 +246,7 @@ impl Cheatcodes { /// automatically we need to determine the new address fn allow_cheatcodes_on_create( &self, - ecx: &mut EvmContext, + ecx: &mut InnerEvmContext, inputs: &CreateInputs, ) -> Address { let old_nonce = ecx @@ -302,6 +310,7 @@ impl Inspector for Cheatcodes { } fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + let ecx = &mut ecx.inner; self.pc = interpreter.program_counter(); // reset gas if gas metering is turned off @@ -716,6 +725,8 @@ impl Inspector for Cheatcodes { }; } + let ecx = &mut ecx.inner; + if call.contract == HARDHAT_CONSOLE_ADDRESS { return None } @@ -929,6 +940,7 @@ impl Inspector for Cheatcodes { call: &CallInputs, mut outcome: CallOutcome, ) -> CallOutcome { + let ecx = &mut ecx.inner; let cheatcode_call = call.contract == CHEATCODE_ADDRESS || call.contract == HARDHAT_CONSOLE_ADDRESS; @@ -1198,6 +1210,7 @@ impl Inspector for Cheatcodes { ecx: &mut EvmContext, call: &mut CreateInputs, ) -> Option { + let ecx = &mut ecx.inner; let gas = Gas::new(call.gas_limit); // Apply our prank @@ -1338,6 +1351,8 @@ impl Inspector for Cheatcodes { _call: &CreateInputs, mut outcome: CreateOutcome, ) -> CreateOutcome { + let ecx = &mut ecx.inner; + // Clean up pranks if let Some(prank) = &self.prank { if ecx.journaled_state.depth() == prank.depth { @@ -1485,7 +1500,7 @@ fn disallowed_mem_write( /// Returns a `DatabaseError::MissingCreate2Deployer` if the `DEFAULT_CREATE2_DEPLOYER` account is /// not found or if it does not have any associated bytecode. fn apply_create2_deployer( - ecx: &mut EvmContext, + ecx: &mut InnerEvmContext, call: &mut CreateInputs, prank: Option<&Prank>, broadcast: Option<&Broadcast>, @@ -1555,7 +1570,7 @@ fn apply_create2_deployer( fn process_broadcast_create( broadcast_sender: Address, bytecode: Bytes, - ecx: &mut EvmContext, + ecx: &mut InnerEvmContext, call: &mut CreateInputs, ) -> (Bytes, Option
, u64) { call.caller = broadcast_sender; @@ -1581,13 +1596,16 @@ fn process_broadcast_create( // Determines if the gas limit on a given call was manually set in the script and should therefore // not be overwritten by later estimations -fn check_if_fixed_gas_limit(data: &EvmContext, call_gas_limit: u64) -> bool { +fn check_if_fixed_gas_limit( + ecx: &InnerEvmContext, + call_gas_limit: u64, +) -> bool { // If the gas limit was not set in the source code it is set to the estimated gas left at the // time of the call, which should be rather close to configured gas limit. // TODO: Find a way to reliably make this determination. // For example by generating it in the compilation or EVM simulation process - U256::from(data.env.tx.gas_limit) > data.env.block.gas_limit && - U256::from(call_gas_limit) <= data.env.block.gas_limit + U256::from(ecx.env.tx.gas_limit) > ecx.env.block.gas_limit && + U256::from(call_gas_limit) <= ecx.env.block.gas_limit // Transfers in forge scripts seem to be estimated at 2300 by revm leading to "Intrinsic // gas too low" failure when simulated on chain && call_gas_limit > 2300 diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index a9dda80f92d99..2fa866b1aeac9 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -11,11 +11,11 @@ pub extern crate foundry_cheatcodes_spec as spec; extern crate tracing; use alloy_primitives::Address; -use revm::EvmContext; +use foundry_evm_core::backend::DatabaseExt; +use revm::{ContextPrecompiles, InnerEvmContext}; pub use config::CheatsConfig; pub use error::{Error, ErrorKind, Result}; -use foundry_evm_core::backend::DatabaseExt; pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; pub use spec::{CheatcodeDef, Vm}; @@ -57,15 +57,14 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { #[inline] fn apply_traced(&self, ccx: &mut CheatsCtxt) -> Result { - let span = trace_span(self); - let _enter = span.enter(); - trace_call(); + let _span = trace_span_and_call(self); let result = self.apply_full(ccx); trace_return(&result); return result; // Separate and non-generic functions to avoid inline and monomorphization bloat. - fn trace_span(cheat: &dyn DynCheatcode) -> tracing::Span { + #[inline(never)] + fn trace_span_and_call(cheat: &dyn DynCheatcode) -> tracing::span::EnteredSpan { let span = debug_span!(target: "cheatcodes", "apply"); if !span.is_disabled() { if enabled!(tracing::Level::TRACE) { @@ -74,13 +73,12 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { span.record("id", cheat.cheatcode().func.id); } } - span - } - - fn trace_call() { + let entered = span.entered(); trace!(target: "cheatcodes", "applying"); + entered } + #[inline(never)] fn trace_return(result: &Result) { trace!( target: "cheatcodes", @@ -109,18 +107,36 @@ impl DynCheatcode for T { } /// The cheatcode context, used in [`Cheatcode`]. -pub(crate) struct CheatsCtxt<'a, 'b, DB: DatabaseExt> { +pub(crate) struct CheatsCtxt<'cheats, 'evm, DB: DatabaseExt> { /// The cheatcodes inspector state. - pub(crate) state: &'a mut Cheatcodes, + pub(crate) state: &'cheats mut Cheatcodes, /// The EVM data. - pub(crate) ecx: &'b mut EvmContext, + pub(crate) ecx: &'evm mut InnerEvmContext, + /// The precompiles context. + pub(crate) precompiles: &'evm mut ContextPrecompiles, /// The original `msg.sender`. pub(crate) caller: Address, } -impl CheatsCtxt<'_, '_, DB> { +impl<'cheats, 'evm, DB: DatabaseExt> std::ops::Deref for CheatsCtxt<'cheats, 'evm, DB> { + type Target = InnerEvmContext; + + #[inline(always)] + fn deref(&self) -> &Self::Target { + self.ecx + } +} + +impl<'cheats, 'evm, DB: DatabaseExt> std::ops::DerefMut for CheatsCtxt<'cheats, 'evm, DB> { + #[inline(always)] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut *self.ecx + } +} + +impl<'cheats, 'evm, DB: DatabaseExt> CheatsCtxt<'cheats, 'evm, DB> { #[inline] pub(crate) fn is_precompile(&self, address: &Address) -> bool { - self.ecx.precompiles.contains(address) + self.precompiles.contains_key(address) } } diff --git a/crates/common/src/provider/alloy.rs b/crates/common/src/provider/alloy.rs index d51be9f9ac44b..7208c7953128e 100644 --- a/crates/common/src/provider/alloy.rs +++ b/crates/common/src/provider/alloy.rs @@ -4,9 +4,8 @@ use crate::{ provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, }; use alloy_primitives::U256; -use alloy_providers::provider::{Provider, TempProvider}; +use alloy_providers::tmp::{Provider, TempProvider}; use alloy_rpc_client::ClientBuilder; -use alloy_transport::BoxTransport; use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use eyre::{Result, WrapErr}; use foundry_common::types::ToAlloy; @@ -18,10 +17,13 @@ use std::{ }; use url::ParseError; -use super::tower::RetryBackoffLayer; +use super::{ + runtime_transport::RuntimeTransport, + tower::{RetryBackoffLayer, RetryBackoffService}, +}; /// Helper type alias for a retry provider -pub type RetryProvider = Provider; +pub type RetryProvider = Provider>; /// Helper type alias for a rpc url pub type RpcUrl = String; @@ -232,7 +234,7 @@ impl ProviderBuilder { let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); // todo: provider polling interval - Ok(Provider::new_with_client(client.boxed())) + Ok(Provider::new_with_client(client)) } } diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 814a967c9b645..347d0489cfb73 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -24,7 +24,6 @@ alloy-genesis.workspace = true alloy-providers.workspace = true alloy-rpc-types.workspace = true alloy-sol-types.workspace = true -alloy-transport.workspace = true revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index d8ea27c0dc813..c0ff88ea40a17 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -71,7 +71,7 @@ impl<'a> CowBackend<'a> { let res = evm.transact().wrap_err("backend: failed while inspecting")?; - env.env = evm.context.evm.env; + env.env = evm.context.evm.inner.env; Ok(res) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 1ad5ec4816de8..f55259f4d1e0d 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -790,7 +790,7 @@ impl Backend { let res = evm.transact().wrap_err("backend: failed while inspecting")?; - env.env = evm.context.evm.env; + env.env = evm.context.evm.inner.env; Ok(res) } diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index ccf64fd10e769..6613c0f134977 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -4,7 +4,7 @@ use crate::{ fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }; use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::{Block, BlockId, Transaction}; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index 84830d5a2b837..abde7cb22dea7 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -1,6 +1,6 @@ use crate::utils::apply_chain_and_block_specific_env_changes; use alloy_primitives::{Address, U256}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::{Block, BlockNumberOrTag}; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index f84af067c0200..4e1cb66e5ff4a 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -4,9 +4,7 @@ //! concurrently active pairs at once. use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; -use alloy_providers::provider::Provider; -use alloy_transport::BoxTransport; -use foundry_common::provider::alloy::ProviderBuilder; +use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; use foundry_config::Config; use futures::{ channel::mpsc::{channel, Receiver, Sender}, @@ -169,7 +167,7 @@ impl MultiFork { } } -type Handler = BackendHandler>>; +type Handler = BackendHandler>; type CreateFuture = Pin> + Send>>; diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 786252bba73af..89fdcf4e38693 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,7 +1,7 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; -use alloy_providers::provider::TempProvider; +use alloy_providers::tmp::TempProvider; use alloy_rpc_types::Block; use eyre::WrapErr; use foundry_common::{ diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index c118bcd3dc101..67fbb3fa7d9f1 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -370,7 +370,6 @@ impl InspectorStack { record_stack_snapshots: StackSnapshotType::None, record_state_diff: false, exclude_precompile_calls: false, - record_call_return_data: true, record_logs: true, }) }); @@ -443,6 +442,8 @@ impl InspectorStack { gas_limit: u64, value: U256, ) -> (InterpreterResult, Option
) { + let ecx = &mut ecx.inner; + ecx.db.commit(ecx.journaled_state.state.clone()); let nonce = ecx @@ -485,7 +486,7 @@ impl InspectorStack { let res = evm.transact(); // need to reset the env in case it was modified via cheatcodes during execution - ecx.env = evm.context.evm.env; + ecx.env = evm.context.evm.inner.env; res }; From d75219c55c00f158651feb3cbb8405bf5ad790b8 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Tue, 12 Mar 2024 08:56:28 +0100 Subject: [PATCH 0738/1963] chore: remove repetitive words (#7371) --- crates/cast/bin/cmd/create2.rs | 2 +- crates/fmt/src/string.rs | 2 +- crates/script/src/transaction.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 6474d52e59cab..4494d5d68e18f 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -203,7 +203,7 @@ impl Create2Args { #[allow(clippy::needless_borrows_for_generic_args)] let addr = deployer.create2(&salt.0, init_code_hash); - // Check if the the regex matches the calculated address' checksum. + // Check if the regex matches the calculated address' checksum. let _ = addr.to_checksum_raw(&mut checksum, None); // SAFETY: stripping 2 ASCII bytes ("0x") off of an already valid UTF-8 string // is safe. diff --git a/crates/fmt/src/string.rs b/crates/fmt/src/string.rs index 6ffc0b9598f27..607c890e7c7ca 100644 --- a/crates/fmt/src/string.rs +++ b/crates/fmt/src/string.rs @@ -65,7 +65,7 @@ impl<'a> Iterator for QuoteStateCharIndices<'a> { } } -/// An iterator over the the indices of quoted string locations +/// An iterator over the indices of quoted string locations pub struct QuotedRanges<'a>(QuoteStateCharIndices<'a>); impl<'a> QuotedRanges<'a> { diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 3f92e2f31be2d..80a2814207aa6 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -397,7 +397,7 @@ pub mod wrapper { pub cumulative_gas_used: U256, /// Gas used by this transaction alone. /// - /// Gas used is `None` if the the client is running in light client mode. + /// Gas used is `None` if the client is running in light client mode. #[serde(rename = "gasUsed")] pub gas_used: Option, /// Contract address created, or `None` if not a deployment. From a3cec878c2938f60855ab928acc0c07439e9c7c5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 12 Mar 2024 12:59:07 +0100 Subject: [PATCH 0739/1963] chore: update tests after new forge-std (#7374) --- crates/forge/tests/cli/cmd.rs | 2 +- crates/forge/tests/cli/config.rs | 22 ++++++++----------- .../can_create_template_contract.stdout | 2 +- .../fixtures/can_create_using_unlocked.stdout | 2 +- .../can_create_with_constructor_args.stdout | 2 +- .../tests/fixtures/can_test_repeatedly.stdout | 2 +- .../can_use_libs_in_multi_fork.stdout | 2 +- crates/forge/tests/fixtures/repro_6531.stdout | 4 ++-- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 48e86d9df7af3..e081b3d6138a5 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -393,7 +393,7 @@ forgetest!(can_init_vscode, |prj, cmd| { let remappings = prj.root().join("remappings.txt"); assert!(remappings.is_file()); let content = std::fs::read_to_string(remappings).unwrap(); - assert_eq!(content, "ds-test/=lib/forge-std/lib/ds-test/src/\nforge-std/=lib/forge-std/src/",); + assert_eq!(content, "forge-std/=lib/forge-std/src/",); }); // checks that forge can init with template diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 20bbb8e1b5968..fa57e4077900d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -150,14 +150,14 @@ forgetest_init!(can_override_config, |prj, cmd| { let profile = Config::load_with_root(prj.root()); // ensure that the auto-generated internal remapping for forge-std's ds-test exists - assert_eq!(profile.remappings.len(), 2); - assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); + assert_eq!(profile.remappings.len(), 1); + assert_eq!("forge-std/=lib/forge-std/src/", profile.remappings[0].to_string()); // ensure remappings contain test - assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", profile.remappings[0].to_string()); + assert_eq!("forge-std/=lib/forge-std/src/", profile.remappings[0].to_string()); // the loaded config has resolved, absolute paths assert_eq!( - "ds-test/=lib/forge-std/lib/ds-test/src/", + "forge-std/=lib/forge-std/src/", Remapping::from(profile.remappings[0].clone()).to_string() ); @@ -221,12 +221,12 @@ forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { let profile = Config::load_with_root(prj.root()); // ensure that the auto-generated internal remapping for forge-std's ds-test exists - assert_eq!(profile.remappings.len(), 2); - let [r, _] = &profile.remappings[..] else { unreachable!() }; - assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", r.to_string()); + assert_eq!(profile.remappings.len(), 1); + let r = &profile.remappings[0]; + assert_eq!("forge-std/=lib/forge-std/src/", r.to_string()); // the loaded config has resolved, absolute paths - assert_eq!("ds-test/=lib/forge-std/lib/ds-test/src/", Remapping::from(r.clone()).to_string()); + assert_eq!("forge-std/=lib/forge-std/src/", Remapping::from(r.clone()).to_string()); cmd.arg("config"); let expected = profile.to_string_pretty().unwrap(); @@ -432,11 +432,11 @@ forgetest!(can_set_gas_price, |prj, cmd| { forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); + dbg!(&remappings); pretty_assertions::assert_eq!( remappings, vec![ // global - "ds-test/=lib/forge-std/lib/ds-test/src/".parse().unwrap(), "forge-std/=lib/forge-std/src/".parse().unwrap(), ] ); @@ -455,7 +455,6 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { remappings, vec![ // default - "ds-test/=lib/forge-std/lib/ds-test/src/".parse().unwrap(), "forge-std/=lib/forge-std/src/".parse().unwrap(), // remapping is local to the lib "nested-lib/=lib/nested-lib/src/".parse().unwrap(), @@ -481,7 +480,6 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { // local to the lib "another-lib/=lib/nested-lib/lib/another-lib/src/".parse().unwrap(), // global - "ds-test/=lib/forge-std/lib/ds-test/src/".parse().unwrap(), "forge-std/=lib/forge-std/src/".parse().unwrap(), "nested-lib/=lib/nested-lib/src/".parse().unwrap(), // remappings local to the lib @@ -500,7 +498,6 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { // local to the lib "another-lib/=lib/nested-lib/lib/another-lib/custom-source-dir/".parse().unwrap(), // global - "ds-test/=lib/forge-std/lib/ds-test/src/".parse().unwrap(), "forge-std/=lib/forge-std/src/".parse().unwrap(), "nested-lib/=lib/nested-lib/src/".parse().unwrap(), // remappings local to the lib @@ -529,7 +526,6 @@ forgetest_init!(can_prioritise_closer_lib_remappings, |prj, cmd| { remappings, vec![ "dep1/=lib/dep1/src/".parse().unwrap(), - "ds-test/=lib/forge-std/lib/ds-test/src/".parse().unwrap(), "forge-std/=lib/forge-std/src/".parse().unwrap() ] ); diff --git a/crates/forge/tests/fixtures/can_create_template_contract.stdout b/crates/forge/tests/fixtures/can_create_template_contract.stdout index 622c81ac4a888..adb787a44ee74 100644 --- a/crates/forge/tests/fixtures/can_create_template_contract.stdout +++ b/crates/forge/tests/fixtures/can_create_template_contract.stdout @@ -1,4 +1,4 @@ -Compiling 24 files with 0.8.23 +Compiling 27 files with 0.8.23 Solc 0.8.23 finished in 2.27s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout index a4132c617c0a1..34a5fb9f7a7d3 100644 --- a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout +++ b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout @@ -1,4 +1,4 @@ -Compiling 24 files with 0.8.23 +Compiling 27 files with 0.8.23 Solc 0.8.23 finished in 1.95s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout index 8cb09c22ced0b..0fb83d06fe3ff 100644 --- a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout +++ b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout @@ -1,4 +1,4 @@ -Compiling 25 files with 0.8.23 +Compiling 28 files with 0.8.23 Solc 0.8.23 finished in 2.82s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout index dbab2812511da..d792e809660ad 100644 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ b/crates/forge/tests/fixtures/can_test_repeatedly.stdout @@ -2,7 +2,7 @@ No files changed, compilation skipped Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) -[PASS] test_Increment() (gas: 28379) +[PASS] test_Increment() (gas: 31225) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms Ran 1 test suite: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout index 70c72887aaea4..87a5aa753715e 100644 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout @@ -3,7 +3,7 @@ Solc 0.8.23 finished in 1.95s Compiler run successful! Ran 1 test for test/Contract.t.sol:ContractTest -[PASS] test() (gas: 70360) +[PASS] test() (gas: 70404) Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout index 159c6476eb981..e8e474ba77338 100644 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -3,9 +3,9 @@ Compiling 1 files with 0.8.23 Compiler run successful! Ran 1 test for test/Contract.t.sol:USDCCallingTest -[PASS] test() (gas: 16799) +[PASS] test() (gas: 16821) Traces: - [16799] USDCCallingTest::test() + [16821] USDCCallingTest::test() ├─ [0] VM::createSelectFork("") │ └─ ← 0 ├─ [10350] 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48::name() [staticcall] From dbddd081a59238bb2ffb95ae04a6e2176a721a40 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:01:10 +0200 Subject: [PATCH 0740/1963] fix(anvil): return correct block number for Arbitrum fork (#7360) * fix(anvil): return correct block number for Arbitrum fork * Backward compatibility with existing state files --- crates/anvil/src/config.rs | 5 +- crates/anvil/src/eth/backend/db.rs | 16 ++++-- crates/anvil/src/eth/backend/mem/fork_db.rs | 14 ++++-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 16 ++++-- crates/anvil/src/eth/backend/mem/mod.rs | 16 ++++-- crates/anvil/tests/it/fork.rs | 49 +++++++++++++++++++ crates/evm/core/src/utils.rs | 5 +- 7 files changed, 101 insertions(+), 20 deletions(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 5c61c08248bf6..354bf2c589d9a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1026,9 +1026,6 @@ latest block number: {latest_block}" ..Default::default() }; - // apply changes such as difficulty -> prevrandao - apply_chain_and_block_specific_env_changes(env, &block); - // if not set explicitly we use the base fee of the latest block if self.base_fee.is_none() { if let Some(base_fee) = block.header.base_fee_per_gas { @@ -1072,6 +1069,8 @@ latest block number: {latest_block}" chain_id }; let override_chain_id = self.chain_id; + // apply changes such as difficulty -> prevrandao and chain specifics for current chain id + apply_chain_and_block_specific_env_changes(env, &block); let meta = BlockchainDbMeta::new(*env.env.clone(), eth_rpc_url.clone()); let block_chain_db = if self.fork_chain_id.is_some() { diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 02e7db113a728..2630d19a7663b 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -1,7 +1,7 @@ //! Helper types for working with [revm](foundry_evm::revm) use crate::{mem::state::trie_hash_db, revm::primitives::AccountInfo}; -use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; +use alloy_primitives::{keccak256, Address, Bytes, B256, U256, U64}; use alloy_rpc_types::BlockId; use anvil_core::eth::trie::KeccakHasher; use foundry_common::errors::FsPathError; @@ -126,7 +126,11 @@ pub trait Db: fn insert_block_hash(&mut self, number: U256, hash: B256); /// Write all chain data to serialized bytes buffer - fn dump_state(&self, at: BlockEnv) -> DatabaseResult>; + fn dump_state( + &self, + at: BlockEnv, + best_number: U64, + ) -> DatabaseResult>; /// Deserialize and add all chain data to the backend storage fn load_state(&mut self, state: SerializableState) -> DatabaseResult { @@ -196,7 +200,11 @@ impl + Send + Sync + Clone + fmt::Debug> D self.block_hashes.insert(number, hash); } - fn dump_state(&self, _at: BlockEnv) -> DatabaseResult> { + fn dump_state( + &self, + _at: BlockEnv, + _best_number: U64, + ) -> DatabaseResult> { Ok(None) } @@ -329,6 +337,8 @@ pub struct SerializableState { /// Note: This is an Option for backwards compatibility: pub block: Option, pub accounts: BTreeMap, + /// The best block number of the state, can be different from block number (Arbitrum chain). + pub best_block_number: Option, } // === impl SerializableState === diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 354971ce595b7..7f9262fd6e568 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -5,7 +5,7 @@ use crate::{ }, revm::primitives::AccountInfo, }; -use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::{Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ backend::{DatabaseResult, RevertSnapshotAction, StateSnapshot}, @@ -32,7 +32,11 @@ impl Db for ForkedDatabase { self.inner().block_hashes().write().insert(number, hash); } - fn dump_state(&self, at: BlockEnv) -> DatabaseResult> { + fn dump_state( + &self, + at: BlockEnv, + best_number: U64, + ) -> DatabaseResult> { let mut db = self.database().clone(); let accounts = self .database() @@ -57,7 +61,11 @@ impl Db for ForkedDatabase { )) }) .collect::>()?; - Ok(Some(SerializableState { block: Some(at), accounts })) + Ok(Some(SerializableState { + block: Some(at), + accounts, + best_block_number: Some(best_number), + })) } fn snapshot(&mut self) -> U256 { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index e1c7deb8e9997..c6ebc8a91f97d 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -8,7 +8,7 @@ use crate::{ mem::state::{state_merkle_trie_root, storage_trie_db, trie_hash_db}, revm::primitives::AccountInfo, }; -use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::{Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ backend::{DatabaseResult, StateSnapshot}, @@ -32,7 +32,11 @@ impl Db for MemDb { self.inner.block_hashes.insert(number, hash); } - fn dump_state(&self, at: BlockEnv) -> DatabaseResult> { + fn dump_state( + &self, + at: BlockEnv, + best_number: U64, + ) -> DatabaseResult> { let accounts = self .inner .accounts @@ -57,7 +61,11 @@ impl Db for MemDb { }) .collect::>()?; - Ok(Some(SerializableState { block: Some(at), accounts })) + Ok(Some(SerializableState { + block: Some(at), + accounts, + best_block_number: Some(best_number), + })) } /// Creates a new snapshot @@ -160,7 +168,7 @@ mod tests { dump_db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); - let state = dump_db.dump_state(Default::default()).unwrap().unwrap(); + let state = dump_db.dump_state(Default::default(), U64::ZERO).unwrap().unwrap(); let mut load_db = MemDb::default(); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 2b0bf292f2aa0..709932438a1e1 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -495,7 +495,7 @@ impl Backend { /// Returns the current best number of the chain pub fn best_number(&self) -> u64 { - self.env.read().block.number.try_into().unwrap_or(u64::MAX) + self.blockchain.storage.read().best_number.try_into().unwrap_or(u64::MAX) } /// Sets the block number @@ -721,7 +721,8 @@ impl Backend { /// Get the current state. pub async fn serialized_state(&self) -> Result { let at = self.env.read().block.clone(); - let state = self.db.read().await.dump_state(at)?; + let best_number = self.blockchain.storage.read().best_number; + let state = self.db.read().await.dump_state(at, best_number)?; state.ok_or_else(|| { RpcError::invalid_params("Dumping state not supported with the current configuration") .into() @@ -742,7 +743,12 @@ impl Backend { pub async fn load_state(&self, state: SerializableState) -> Result { // reset the block env if let Some(block) = state.block.clone() { - self.env.write().block = block; + self.env.write().block = block.clone(); + + // Set the current best block number. + // Defaults to block number for compatibility with existing state files. + self.blockchain.storage.write().best_number = + state.best_block_number.unwrap_or(block.number.to::()); } if !self.db.write().await.load_state(state)? { @@ -922,8 +928,9 @@ impl Backend { let ExecutedTransactions { block, included, invalid } = executed_tx; let BlockInfo { block, transactions, receipts } = block; + let mut storage = self.blockchain.storage.write(); let header = block.header.clone(); - let block_number: U64 = env.block.number.to::(); + let block_number = storage.best_number.saturating_add(U64::from(1)); trace!( target: "backend", @@ -933,7 +940,6 @@ impl Backend { transactions.iter().map(|tx| tx.transaction_hash).collect::>() ); - let mut storage = self.blockchain.storage.write(); // update block metadata storage.best_number = block_number; storage.best_hash = block_hash; diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index a23cc7052ecd2..39946383e105d 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1123,6 +1123,55 @@ async fn test_arbitrum_fork_dev_balance() { } } +// +#[tokio::test(flavor = "multi_thread")] +async fn test_arbitrum_fork_block_number() { + // fork to get initial block for test + let (_, handle) = spawn( + fork_config() + .with_fork_block_number(None::) + .with_eth_rpc_url(Some("https://arb1.arbitrum.io/rpc".to_string())), + ) + .await; + let provider = ethers_http_provider(&handle.http_endpoint()); + let initial_block_number = provider.get_block_number().await.unwrap().as_u64(); + + // fork again at block number returned by `eth_blockNumber` + // if wrong block number returned (e.g. L1) then fork will fail with error code -32000: missing + // trie node + let (api, _) = spawn( + fork_config() + .with_fork_block_number(Some(initial_block_number)) + .with_eth_rpc_url(Some("https://arb1.arbitrum.io/rpc".to_string())), + ) + .await; + let block_number = api.block_number().unwrap().to::(); + assert_eq!(block_number, initial_block_number); + + // take snapshot at initial block number + let snapshot = api.evm_snapshot().await.unwrap(); + + // mine new block and check block number returned by `eth_blockNumber` + api.mine_one().await; + let block_number = api.block_number().unwrap().to::(); + assert_eq!(block_number, initial_block_number + 1); + + // revert to recorded snapshot and check block number + assert!(api.evm_revert(snapshot).await.unwrap()); + let block_number = api.block_number().unwrap().to::(); + assert_eq!(block_number, initial_block_number); + + // reset fork to different block number and compare with block returned by `eth_blockNumber` + api.anvil_reset(Some(Forking { + json_rpc_url: Some("https://arb1.arbitrum.io/rpc".to_string()), + block_number: Some(initial_block_number - 2), + })) + .await + .unwrap(); + let block_number = api.block_number().unwrap().to::(); + assert_eq!(block_number, initial_block_number - 2); +} + // #[tokio::test(flavor = "multi_thread")] async fn test_fork_execution_reverted() { diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 48e8808e4accf..7ef8bb47f2d4f 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -15,8 +15,9 @@ pub use crate::ic::*; /// Depending on the configured chain id and block number this should apply any specific changes /// -/// This checks for: -/// - prevrandao mixhash after merge +/// - checks for prevrandao mixhash after merge +/// - applies chain specifics: on Arbitrum `block.number` is the L1 block +/// Should be called with proper chain id (retrieved from provider if not provided). pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::Env, block: &Block) { if let Ok(chain) = NamedChain::try_from(env.cfg.chain_id) { let block_number = block.header.number.unwrap_or_default(); From d3b8d154ef135421c699f3ba8668a2ccbf2d3c26 Mon Sep 17 00:00:00 2001 From: Krishang Shah <93703995+kamuik16@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:47:56 +0530 Subject: [PATCH 0741/1963] fix: compile contracts before generating docs (#7369) * fix: compile before doc * run forge compile silently --------- Co-authored-by: Matthias Seitz --- crates/forge/bin/cmd/doc/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index d594a0e566f6e..30de31e5a2031 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -4,6 +4,7 @@ use forge_doc::{ ContractInheritance, Deployments, DocBuilder, GitSource, InferInlineHyperlinks, Inheritdoc, }; use foundry_cli::opts::GH_REPO_PREFIX_REGEX; +use foundry_common::compile::ProjectCompiler; use foundry_config::{find_project_root_path, load_config_with_root}; use std::{path::PathBuf, process::Command}; @@ -64,6 +65,9 @@ impl DocArgs { pub fn run(self) -> Result<()> { let root = self.root.clone().unwrap_or(find_project_root_path(None)?); let config = load_config_with_root(Some(root.clone())); + let project = config.project()?; + let compiler = ProjectCompiler::new().quiet(true); + let _output = compiler.compile(&project)?; let mut doc_config = config.doc.clone(); if let Some(out) = self.out { From 5fe9143385231ebf67af670a9f001e0f4fab4a33 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:52:28 +0200 Subject: [PATCH 0742/1963] feat(test): add fuzz tests failure persistence (#7336) * feat(forge): add fuzz tests failure persistence * Enable inline file failure config * New config not needed to be Option * Persist failures in proj cache dir * Make persist dirs option, remove foundry_fuzz_cache_dir fn --------- Co-authored-by: Matthias Seitz --- crates/config/src/fuzz.rs | 30 ++++++++++++-- crates/config/src/lib.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 9 +++- crates/forge/src/lib.rs | 29 +++++++++---- crates/forge/src/runner.rs | 10 +++-- crates/forge/tests/cli/config.rs | 2 + crates/forge/tests/it/fuzz.rs | 57 ++++++++++++++++++++++++-- crates/forge/tests/it/test_helpers.rs | 4 +- testdata/fuzz/FuzzFailurePersist.t.sol | 29 +++++++++++++ 9 files changed, 153 insertions(+), 19 deletions(-) create mode 100644 testdata/fuzz/FuzzFailurePersist.t.sol diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index 13e8d34d3f2f5..3b0e13bcd509c 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -5,9 +5,10 @@ use crate::inline::{ }; use alloy_primitives::U256; use serde::{Deserialize, Serialize}; +use std::path::PathBuf; /// Contains for fuzz testing -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct FuzzConfig { /// The number of test cases that must execute for each property test pub runs: u32, @@ -24,6 +25,10 @@ pub struct FuzzConfig { pub dictionary: FuzzDictionaryConfig, /// Number of runs to execute and include in the gas report. pub gas_report_samples: u32, + /// Path where fuzz failures are recorded and replayed. + pub failure_persist_dir: Option, + /// Name of the file to record fuzz failures, defaults to `failures`. + pub failure_persist_file: Option, } impl Default for FuzzConfig { @@ -34,6 +39,23 @@ impl Default for FuzzConfig { seed: None, dictionary: FuzzDictionaryConfig::default(), gas_report_samples: 256, + failure_persist_dir: None, + failure_persist_file: None, + } + } +} + +impl FuzzConfig { + /// Creates fuzz configuration to write failures in `{PROJECT_ROOT}/cache/fuzz` dir. + pub fn new(cache_dir: PathBuf) -> Self { + FuzzConfig { + runs: 256, + max_test_rejects: 65536, + seed: None, + dictionary: FuzzDictionaryConfig::default(), + gas_report_samples: 256, + failure_persist_dir: Some(cache_dir), + failure_persist_file: Some("failures".to_string()), } } } @@ -50,8 +72,7 @@ impl InlineConfigParser for FuzzConfig { return Ok(None) } - // self is Copy. We clone it with dereference. - let mut conf_clone = *self; + let mut conf_clone = self.clone(); for pair in overrides { let key = pair.0; @@ -62,6 +83,7 @@ impl InlineConfigParser for FuzzConfig { "dictionary-weight" => { conf_clone.dictionary.dictionary_weight = parse_config_u32(key, value)? } + "failure-persist-file" => conf_clone.failure_persist_file = Some(value), _ => Err(InlineConfigParserError::InvalidConfigProperty(key))?, } } @@ -130,11 +152,13 @@ mod tests { let configs = &[ "forge-config: default.fuzz.runs = 42424242".to_string(), "forge-config: default.fuzz.dictionary-weight = 42".to_string(), + "forge-config: default.fuzz.failure-persist-file = fuzz-failure".to_string(), ]; let base_config = FuzzConfig::default(); let merged: FuzzConfig = base_config.try_merge(configs).expect("No errors").unwrap(); assert_eq!(merged.runs, 42424242); assert_eq!(merged.dictionary.dictionary_weight, 42); + assert_eq!(merged.failure_persist_file, Some("fuzz-failure".to_string())); } #[test] diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 00077845530a8..4f27b58b8eddf 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1869,7 +1869,7 @@ impl Default for Config { contract_pattern_inverse: None, path_pattern: None, path_pattern_inverse: None, - fuzz: Default::default(), + fuzz: FuzzConfig::new("cache/fuzz".into()), invariant: Default::default(), always_use_create_2_factory: false, ffi: false, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 11ae1aee77e37..dfb1d8cf5941d 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -97,6 +97,10 @@ pub struct TestArgs { #[arg(long, env = "FOUNDRY_FUZZ_RUNS", value_name = "RUNS")] pub fuzz_runs: Option, + /// File to rerun fuzz failures from. + #[arg(long)] + pub fuzz_input_file: Option, + #[command(flatten)] filter: FilterArgs, @@ -176,7 +180,7 @@ impl TestArgs { let profiles = get_available_profiles(toml)?; let test_options: TestOptions = TestOptionsBuilder::default() - .fuzz(config.fuzz) + .fuzz(config.clone().fuzz) .invariant(config.invariant) .profiles(profiles) .build(&output, project_root)?; @@ -518,6 +522,9 @@ impl Provider for TestArgs { if let Some(fuzz_runs) = self.fuzz_runs { fuzz_dict.insert("runs".to_string(), fuzz_runs.into()); } + if let Some(fuzz_input_file) = self.fuzz_input_file.clone() { + fuzz_dict.insert("failure_persist_file".to_string(), fuzz_input_file.into()); + } dict.insert("fuzz".to_string(), fuzz_dict.into()); if let Some(etherscan_api_key) = diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index f6b9a54a8e681..a430204e158d4 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -6,7 +6,9 @@ use foundry_config::{ validate_profiles, Config, FuzzConfig, InlineConfig, InlineConfigError, InlineConfigParser, InvariantConfig, NatSpec, }; -use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; +use proptest::test_runner::{ + FailurePersistence, FileFailurePersistence, RngAlgorithm, TestRng, TestRunner, +}; use std::path::Path; pub mod coverage; @@ -93,8 +95,18 @@ impl TestOptions { where S: Into, { - let fuzz = self.fuzz_config(contract_id, test_fn); - self.fuzzer_with_cases(fuzz.runs) + let fuzz_config = self.fuzz_config(contract_id, test_fn).clone(); + let failure_persist_path = fuzz_config + .failure_persist_dir + .unwrap() + .join(fuzz_config.failure_persist_file.unwrap()) + .into_os_string() + .into_string() + .unwrap(); + self.fuzzer_with_cases( + fuzz_config.runs, + Some(Box::new(FileFailurePersistence::Direct(failure_persist_path.leak()))), + ) } /// Returns an "invariant" test runner instance. Parameters are used to select tight scoped fuzz @@ -109,7 +121,7 @@ impl TestOptions { S: Into, { let invariant = self.invariant_config(contract_id, test_fn); - self.fuzzer_with_cases(invariant.runs) + self.fuzzer_with_cases(invariant.runs, None) } /// Returns a "fuzz" configuration setup. Parameters are used to select tight scoped fuzz @@ -140,10 +152,13 @@ impl TestOptions { self.inline_invariant.get(contract_id, test_fn).unwrap_or(&self.invariant) } - pub fn fuzzer_with_cases(&self, cases: u32) -> TestRunner { - // TODO: Add Options to modify the persistence + pub fn fuzzer_with_cases( + &self, + cases: u32, + file_failure_persistence: Option>, + ) -> TestRunner { let config = proptest::test_runner::Config { - failure_persistence: None, + failure_persistence: file_failure_persistence, cases, max_global_rejects: self.fuzz.max_test_rejects, ..Default::default() diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 0164cd7df0e6b..3b1a1a2071786 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -294,7 +294,7 @@ impl<'a> ContractRunner<'a> { debug_assert!(func.is_test()); let runner = test_options.fuzz_runner(self.name, &func.name); let fuzz_config = test_options.fuzz_config(self.name, &func.name); - self.run_fuzz_test(func, should_fail, runner, setup, *fuzz_config) + self.run_fuzz_test(func, should_fail, runner, setup, fuzz_config.clone()) } else { debug_assert!(func.is_test()); self.run_test(func, should_fail, setup) @@ -604,8 +604,12 @@ impl<'a> ContractRunner<'a> { // Run fuzz test let start = Instant::now(); - let fuzzed_executor = - FuzzedExecutor::new(self.executor.clone(), runner.clone(), self.sender, fuzz_config); + let fuzzed_executor = FuzzedExecutor::new( + self.executor.clone(), + runner.clone(), + self.sender, + fuzz_config.clone(), + ); let state = fuzzed_executor.build_fuzz_state(); let result = fuzzed_executor.fuzz(func, address, should_fail, self.revert_decoder); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index fa57e4077900d..6714df59dd833 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -65,6 +65,8 @@ forgetest!(can_extract_config_values, |prj, cmd| { runs: 1000, max_test_rejects: 100203, seed: Some(U256::from(1000)), + failure_persist_dir: Some("test-cache/fuzz".into()), + failure_persist_file: Some("failures".to_string()), ..Default::default() }, invariant: InvariantConfig { runs: 256, ..Default::default() }, diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 14a27d6b442a1..9f59a7f42fb9c 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -1,10 +1,14 @@ //! Fuzz tests. -use crate::config::*; -use alloy_primitives::U256; +use std::collections::BTreeMap; + +use alloy_primitives::{Bytes, U256}; +use forge::fuzz::CounterExample; + use forge::result::{SuiteResult, TestStatus}; use foundry_test_utils::Filter; -use std::collections::BTreeMap; + +use crate::config::*; #[tokio::test(flavor = "multi_thread")] async fn test_fuzz() { @@ -103,3 +107,50 @@ async fn test_fuzz_collection() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_persist_fuzz_failure() { + let filter = Filter::new(".*", ".*", ".*fuzz/FuzzFailurePersist.t.sol"); + let mut runner = runner(); + runner.test_options.fuzz.runs = 1000; + + macro_rules! get_failure_result { + () => { + runner + .test_collect(&filter) + .get("fuzz/FuzzFailurePersist.t.sol:FuzzFailurePersistTest") + .unwrap() + .test_results + .get("test_persist_fuzzed_failure(uint256,int256,address,bool,string,(address,uint256),address[])") + .unwrap() + .counterexample + .clone() + }; + } + + // record initial counterexample calldata + let intial_counterexample = get_failure_result!(); + let initial_calldata = match intial_counterexample { + Some(CounterExample::Single(counterexample)) => counterexample.calldata, + _ => Bytes::new(), + }; + + // run several times and compare counterexamples calldata + for _ in 0..10 { + let new_calldata = match get_failure_result!() { + Some(CounterExample::Single(counterexample)) => counterexample.calldata, + _ => Bytes::new(), + }; + // calldata should be the same with the initial one + assert_eq!(initial_calldata, new_calldata); + } + + // write new failure in different file + runner.test_options.fuzz.failure_persist_file = Some("failure1".to_string()); + let new_calldata = match get_failure_result!() { + Some(CounterExample::Single(counterexample)) => counterexample.calldata, + _ => Bytes::new(), + }; + // empty file is used to load failure so new calldata is generated + assert_ne!(initial_calldata, new_calldata); +} diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index e615e27856955..969e673579cf8 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -95,6 +95,8 @@ pub static TEST_OPTS: Lazy = Lazy::new(|| { max_calldata_fuzz_dictionary_addresses: 0, }, gas_report_samples: 256, + failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), + failure_persist_file: Some("testfailure".to_string()), }) .invariant(InvariantConfig { runs: 256, @@ -126,6 +128,6 @@ pub fn fuzz_executor(executor: Executor) -> FuzzedExecutor { executor, proptest::test_runner::TestRunner::new(cfg), CALLER, - TEST_OPTS.fuzz, + TEST_OPTS.fuzz.clone(), ) } diff --git a/testdata/fuzz/FuzzFailurePersist.t.sol b/testdata/fuzz/FuzzFailurePersist.t.sol new file mode 100644 index 0000000000000..1f7c4829cdcf8 --- /dev/null +++ b/testdata/fuzz/FuzzFailurePersist.t.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "../cheats/Vm.sol"; + +struct TestTuple { + address user; + uint256 amount; +} + +contract FuzzFailurePersistTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + function test_persist_fuzzed_failure( + uint256 x, + int256 y, + address addr, + bool cond, + string calldata test, + TestTuple calldata tuple, + address[] calldata addresses + ) public { + // dummy assume to trigger runs + vm.assume(x > 1 && x < 1111111111111111111111111111); + vm.assume(y > 1 && y < 1111111111111111111111111111); + require(false); + } +} From f218563dcc1d1f006ef85224403513a139072745 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 12 Mar 2024 19:36:01 +0400 Subject: [PATCH 0743/1963] fix(forge): do not re-execute script on resume when possible (#7361) * fix(forge): do not re-execute script on resume when possible * fmt * skip broadcasted --- crates/cheatcodes/src/script.rs | 5 ++ crates/forge/tests/cli/multi_script.rs | 1 + crates/script/src/broadcast.rs | 11 +-- crates/script/src/build.rs | 112 ++++++++++++++++++++++++- crates/script/src/lib.rs | 79 ++++++++--------- crates/script/src/resume.rs | 106 ----------------------- crates/script/src/simulate.rs | 2 - crates/script/src/verify.rs | 9 +- 8 files changed, 159 insertions(+), 166 deletions(-) delete mode 100644 crates/script/src/resume.rs diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 4b3e6ba484029..ff4e3a14841ab 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -111,6 +111,11 @@ impl ScriptWallets { self.inner.lock().multi_wallet.add_signer(WalletSigner::from_private_key(private_key)?); Ok(Default::default()) } + + /// Locks inner Mutex and returns all signer addresses in the [MultiWallet]. + pub fn signers(&self) -> Result> { + Ok(self.inner.lock().multi_wallet.signers()?.keys().cloned().collect()) + } } /// Sets up broadcasting from a script using `new_origin` as the sender. diff --git a/crates/forge/tests/cli/multi_script.rs b/crates/forge/tests/cli/multi_script.rs index 121fa986269a7..d6f7628da1694 100644 --- a/crates/forge/tests/cli/multi_script.rs +++ b/crates/forge/tests/cli/multi_script.rs @@ -61,5 +61,6 @@ forgetest_async!(can_resume_multi_chain_script, |prj, cmd| { .broadcast(ScriptOutcome::MissingWallet) .load_private_keys(&[0, 1]) .await + .arg("--multi") .resume(ScriptOutcome::OkBroadcast); }); diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index fb21276c28380..224bcc44cf45d 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -1,9 +1,6 @@ use crate::{ - build::LinkedBuildData, - execute::{ExecutionArtifacts, ExecutionData}, - sequence::ScriptSequenceKind, - verify::BroadcastedState, - ScriptArgs, ScriptConfig, + build::LinkedBuildData, sequence::ScriptSequenceKind, verify::BroadcastedState, ScriptArgs, + ScriptConfig, }; use super::receipts; @@ -170,8 +167,6 @@ pub struct BundledState { pub script_config: ScriptConfig, pub script_wallets: ScriptWallets, pub build_data: LinkedBuildData, - pub execution_data: ExecutionData, - pub execution_artifacts: ExecutionArtifacts, pub sequence: ScriptSequenceKind, } @@ -408,8 +403,6 @@ impl BundledState { args: self.args, script_config: self.script_config, build_data: self.build_data, - execution_data: self.execution_data, - execution_artifacts: self.execution_artifacts, sequence: self.sequence, }) } diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 4dc78b0cdc566..41e898d96a72b 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -1,11 +1,20 @@ -use crate::{execute::LinkedState, ScriptArgs, ScriptConfig}; +use crate::{ + broadcast::BundledState, + execute::LinkedState, + multi_sequence::MultiChainSequence, + sequence::{ScriptSequence, ScriptSequenceKind}, + ScriptArgs, ScriptConfig, +}; use alloy_primitives::{Address, Bytes}; +use ethers_providers::Middleware; use eyre::{Context, OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compile::{self, ContractSources, ProjectCompiler}, + provider::ethers::try_get_http_provider, + types::ToAlloy, ContractsByArtifact, }; use foundry_compilers::{ @@ -16,7 +25,7 @@ use foundry_compilers::{ ArtifactId, }; use foundry_linking::{LinkOutput, Linker}; -use std::str::FromStr; +use std::{str::FromStr, sync::Arc}; /// Container for the compiled contracts. pub struct BuildData { @@ -245,4 +254,103 @@ impl CompiledState { Ok(LinkedState { args, script_config, script_wallets, build_data }) } + + /// Tries loading the resumed state from the cache files, skipping simulation stage. + pub async fn resume(self) -> Result { + let chain = if self.args.multi { + None + } else { + let fork_url = self.script_config.evm_opts.fork_url.clone().ok_or_eyre("Missing --fork-url field, if you were trying to broadcast a multi-chain sequence, please use --multi flag")?; + let provider = Arc::new(try_get_http_provider(fork_url)?); + Some(provider.get_chainid().await?.as_u64()) + }; + + let sequence = match self.try_load_sequence(chain, false) { + Ok(sequence) => sequence, + Err(_) => { + // If the script was simulated, but there was no attempt to broadcast yet, + // try to read the script sequence from the `dry-run/` folder + let mut sequence = self.try_load_sequence(chain, true)?; + + // If sequence was in /dry-run, Update its paths so it is not saved into /dry-run + // this time as we are about to broadcast it. + sequence.update_paths_to_broadcasted( + &self.script_config.config, + &self.args.sig, + &self.build_data.target, + )?; + + sequence.save(true, true)?; + sequence + } + }; + + let (args, build_data, script_wallets, script_config) = if !self.args.unlocked { + let mut froms = sequence.sequences().iter().flat_map(|s| { + s.transactions + .iter() + .skip(s.receipts.len()) + .map(|t| t.transaction.from().expect("from is missing in script artifact")) + }); + + let available_signers = self + .script_wallets + .signers() + .map_err(|e| eyre::eyre!("Failed to get available signers: {}", e))?; + + if !froms.all(|from| available_signers.contains(&from.to_alloy())) { + // IF we are missing required signers, execute script as we might need to collect + // private keys from the execution. + let executed = self.link()?.prepare_execution().await?.execute().await?; + ( + executed.args, + executed.build_data.build_data, + executed.script_wallets, + executed.script_config, + ) + } else { + (self.args, self.build_data, self.script_wallets, self.script_config) + } + } else { + (self.args, self.build_data, self.script_wallets, self.script_config) + }; + + // Collect libraries from sequence and link contracts with them. + let libraries = match sequence { + ScriptSequenceKind::Single(ref seq) => Libraries::parse(&seq.libraries)?, + // Library linking is not supported for multi-chain sequences + ScriptSequenceKind::Multi(_) => Libraries::default(), + }; + + let linked_build_data = build_data.link_with_libraries(libraries)?; + + Ok(BundledState { + args, + script_config, + script_wallets, + build_data: linked_build_data, + sequence, + }) + } + + fn try_load_sequence(&self, chain: Option, dry_run: bool) -> Result { + if let Some(chain) = chain { + let sequence = ScriptSequence::load( + &self.script_config.config, + &self.args.sig, + &self.build_data.target, + chain, + dry_run, + )?; + Ok(ScriptSequenceKind::Single(sequence)) + } else { + let sequence = MultiChainSequence::load( + &self.script_config.config, + &self.args.sig, + &self.build_data.target, + dry_run, + )?; + Ok(ScriptSequenceKind::Multi(sequence)) + } + } } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index ef579716f2f6c..010b5bbe970d1 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -58,7 +58,6 @@ mod execute; mod multi_sequence; mod providers; mod receipts; -mod resume; mod runner; mod sequence; mod simulate; @@ -219,49 +218,51 @@ impl ScriptArgs { pub async fn run_script(self) -> Result<()> { trace!(target: "script", "executing script command"); - // Drive state machine to point at which we have everything needed for simulation/resuming. - let pre_simulation = self - .preprocess() - .await? - .compile()? - .link()? - .prepare_execution() - .await? - .execute() - .await? - .prepare_simulation() - .await?; - - if pre_simulation.args.debug { - pre_simulation.run_debugger()?; - } + let compiled = self.preprocess().await?.compile()?; - if pre_simulation.args.json { - pre_simulation.show_json()?; + // Move from `CompiledState` to `BundledState` either by resuming or executing and + // simulating script. + let bundled = if compiled.args.resume || (compiled.args.verify && !compiled.args.broadcast) + { + compiled.resume().await? } else { - pre_simulation.show_traces().await?; - } + // Drive state machine to point at which we have everything needed for simulation. + let pre_simulation = compiled + .link()? + .prepare_execution() + .await? + .execute() + .await? + .prepare_simulation() + .await?; + + if pre_simulation.args.debug { + pre_simulation.run_debugger()?; + } - // Ensure that we have transactions to simulate/broadcast, otherwise exit early to avoid - // hard error. - if pre_simulation.execution_result.transactions.as_ref().map_or(true, |txs| txs.is_empty()) - { - return Ok(()); - } + if pre_simulation.args.json { + pre_simulation.show_json()?; + } else { + pre_simulation.show_traces().await?; + } - // Check if there are any missing RPCs and exit early to avoid hard error. - if pre_simulation.execution_artifacts.rpc_data.missing_rpc { - shell::println("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; - return Ok(()); - } + // Ensure that we have transactions to simulate/broadcast, otherwise exit early to avoid + // hard error. + if pre_simulation + .execution_result + .transactions + .as_ref() + .map_or(true, |txs| txs.is_empty()) + { + return Ok(()); + } + + // Check if there are any missing RPCs and exit early to avoid hard error. + if pre_simulation.execution_artifacts.rpc_data.missing_rpc { + shell::println("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; + return Ok(()); + } - // Move from `PreSimulationState` to `BundledState` either by resuming or simulating - // transactions. - let bundled = if pre_simulation.args.resume || - (pre_simulation.args.verify && !pre_simulation.args.broadcast) - { - pre_simulation.resume().await? - } else { pre_simulation.args.check_contract_sizes( &pre_simulation.execution_result, &pre_simulation.build_data.highlevel_known_contracts, diff --git a/crates/script/src/resume.rs b/crates/script/src/resume.rs deleted file mode 100644 index 4f704ed601fa5..0000000000000 --- a/crates/script/src/resume.rs +++ /dev/null @@ -1,106 +0,0 @@ -use crate::{broadcast::BundledState, simulate::PreSimulationState}; - -use super::{ - multi_sequence::MultiChainSequence, - sequence::{ScriptSequence, ScriptSequenceKind}, -}; -use ethers_providers::Middleware; -use eyre::Result; -use foundry_common::provider::ethers::try_get_http_provider; -use foundry_compilers::artifacts::Libraries; -use std::sync::Arc; - -impl PreSimulationState { - /// Tries loading the resumed state from the cache files, skipping simulation stage. - pub async fn resume(mut self) -> Result { - if self.execution_artifacts.rpc_data.missing_rpc { - eyre::bail!("Missing `--fork-url` field.") - } - - let chain = match self.execution_artifacts.rpc_data.total_rpcs.len() { - 2.. => None, - 1 => { - let fork_url = self.execution_artifacts.rpc_data.total_rpcs.iter().next().unwrap(); - - let provider = Arc::new(try_get_http_provider(fork_url)?); - Some(provider.get_chainid().await?.as_u64()) - } - 0 => eyre::bail!("No RPC URLs"), - }; - - let sequence = match self.try_load_sequence(chain, false) { - Ok(sequence) => sequence, - Err(_) => { - // If the script was simulated, but there was no attempt to broadcast yet, - // try to read the script sequence from the `dry-run/` folder - let mut sequence = self.try_load_sequence(chain, true)?; - - // If sequence was in /dry-run, Update its paths so it is not saved into /dry-run - // this time as we are about to broadcast it. - sequence.update_paths_to_broadcasted( - &self.script_config.config, - &self.args.sig, - &self.build_data.build_data.target, - )?; - - sequence.save(true, true)?; - sequence - } - }; - - match sequence { - ScriptSequenceKind::Single(ref seq) => { - // We might have predeployed libraries from the broadcasting, so we need to - // relink the contracts with them, since their mapping is not included in the solc - // cache files. - self.build_data = self - .build_data - .build_data - .link_with_libraries(Libraries::parse(&seq.libraries)?)?; - } - // Library linking is not supported for multi-chain sequences - ScriptSequenceKind::Multi(_) => {} - } - - let Self { - args, - script_config, - script_wallets, - build_data, - execution_data, - execution_result: _, - execution_artifacts, - } = self; - - Ok(BundledState { - args, - script_config, - script_wallets, - build_data, - execution_data, - execution_artifacts, - sequence, - }) - } - - fn try_load_sequence(&self, chain: Option, dry_run: bool) -> Result { - if let Some(chain) = chain { - let sequence = ScriptSequence::load( - &self.script_config.config, - &self.args.sig, - &self.build_data.build_data.target, - chain, - dry_run, - )?; - Ok(ScriptSequenceKind::Single(sequence)) - } else { - let sequence = MultiChainSequence::load( - &self.script_config.config, - &self.args.sig, - &self.build_data.build_data.target, - dry_run, - )?; - Ok(ScriptSequenceKind::Multi(sequence)) - } - } -} diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 99bd39ad95155..07e962ddff329 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -400,8 +400,6 @@ impl FilledTransactionsState { script_config: self.script_config, script_wallets: self.script_wallets, build_data: self.build_data, - execution_data: self.execution_data, - execution_artifacts: self.execution_artifacts, sequence, }) } diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index be5825dfc7e88..217d880b07b7c 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -1,9 +1,4 @@ -use crate::{ - build::LinkedBuildData, - execute::{ExecutionArtifacts, ExecutionData}, - sequence::ScriptSequenceKind, - ScriptArgs, ScriptConfig, -}; +use crate::{build::LinkedBuildData, sequence::ScriptSequenceKind, ScriptArgs, ScriptConfig}; use alloy_primitives::Address; use eyre::Result; @@ -21,8 +16,6 @@ pub struct BroadcastedState { pub args: ScriptArgs, pub script_config: ScriptConfig, pub build_data: LinkedBuildData, - pub execution_data: ExecutionData, - pub execution_artifacts: ExecutionArtifacts, pub sequence: ScriptSequenceKind, } From edb3a4b125510c1b24e40b69218aada87b73489d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:10:56 +0100 Subject: [PATCH 0744/1963] feat(anvil): support sub-second block time granularity (#7380) --- crates/anvil/src/anvil.rs | 2 +- crates/anvil/src/cmd.rs | 16 ++++++++++++---- crates/config/src/fix.rs | 6 +++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 5ac169c3af96f..8ce75751c7f13 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -30,7 +30,7 @@ pub enum AnvilSubcommand { } #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> eyre::Result<()> { utils::load_dotenv(); let mut app = Anvil::parse(); diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index c16328ee246fb..508c3dc8e1f1c 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -83,8 +83,8 @@ pub struct NodeArgs { pub hardfork: Option, /// Block time in seconds for interval mining. - #[arg(short, long, visible_alias = "blockTime", value_name = "SECONDS")] - pub block_time: Option, + #[arg(short, long, visible_alias = "blockTime", value_name = "SECONDS", value_parser = duration_from_secs_f64)] + pub block_time: Option, /// Slots in an epoch #[arg(long, value_name = "SLOTS_IN_AN_EPOCH", default_value_t = 32)] @@ -198,7 +198,7 @@ impl NodeArgs { .disable_block_gas_limit(self.evm_opts.disable_block_gas_limit) .with_gas_price(self.evm_opts.gas_price.map(U256::from)) .with_hardfork(self.hardfork) - .with_blocktime(self.block_time.map(Duration::from_secs)) + .with_blocktime(self.block_time) .with_no_mining(self.no_mining) .with_account_generator(self.account_generator()) .with_genesis_balance(genesis_balance) @@ -269,7 +269,7 @@ impl NodeArgs { /// Starts the node /// /// See also [crate::spawn()] - pub async fn run(self) -> Result<(), Box> { + pub async fn run(self) -> eyre::Result<()> { let dump_state = self.dump_state_path(); let dump_interval = self.state_interval.map(Duration::from_secs).unwrap_or(DEFAULT_DUMP_INTERVAL); @@ -677,6 +677,14 @@ fn read_genesis_file(path: &str) -> Result { foundry_common::fs::read_json_file(path.as_ref()).map_err(|err| err.to_string()) } +fn duration_from_secs_f64(s: &str) -> Result { + let s = s.parse::().map_err(|e| e.to_string())?; + if s == 0.0 { + return Err("Duration must be greater than 0".to_string()); + } + Duration::try_from_secs_f64(s).map_err(|e| e.to_string()) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/config/src/fix.rs b/crates/config/src/fix.rs index 086fbb7db3055..a0ce9fbc1b0bd 100644 --- a/crates/config/src/fix.rs +++ b/crates/config/src/fix.rs @@ -15,20 +15,24 @@ struct TomlFile { } impl TomlFile { - fn open(path: impl AsRef) -> Result> { + fn open(path: impl AsRef) -> eyre::Result { let path = path.as_ref().to_owned(); let doc = fs::read_to_string(&path)?.parse()?; Ok(Self { doc, path }) } + fn doc(&self) -> &toml_edit::Document { &self.doc } + fn doc_mut(&mut self) -> &mut toml_edit::Document { &mut self.doc } + fn path(&self) -> &Path { self.path.as_ref() } + fn save(&self) -> io::Result<()> { fs::write(self.path(), self.doc().to_string()) } From eef87de35375311f134fb4261c18455ced8022a5 Mon Sep 17 00:00:00 2001 From: Enrique Date: Tue, 12 Mar 2024 13:28:08 -0400 Subject: [PATCH 0745/1963] feat(`anvil`): add support for EIP4844 types (#7202) * feat(anvil-core): EIP4844 variant support * chore: proper support when converting txs * feat: add more type support * chore: lock * feat: missing type conversions, decoding test * use correct eip check * force no blob hashes for eip1559 * feat: support sidecar with 4844 types * fmt * feat: use main branch for consensus, update * chore: rename * lockfile * fmt * fmt --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 4 + crates/anvil/Cargo.toml | 2 +- crates/anvil/core/Cargo.toml | 3 +- crates/anvil/core/src/eth/transaction/mod.rs | 224 ++++++++++++++++++- crates/anvil/src/eth/api.rs | 5 + crates/anvil/src/eth/backend/executor.rs | 8 + crates/anvil/src/eth/backend/mem/mod.rs | 18 ++ crates/anvil/src/eth/error.rs | 5 + crates/anvil/src/eth/fees.rs | 9 + crates/anvil/src/eth/sign.rs | 5 + 10 files changed, 274 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 113f04de8135a..8d5f0d37be901 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,6 +96,9 @@ dependencies = [ "alloy-network", "alloy-primitives", "alloy-rlp", + "c-kzg", + "sha2 0.10.8", + "thiserror", ] [[package]] @@ -595,6 +598,7 @@ dependencies = [ "alloy-rpc-types", "anvil-core", "bytes", + "c-kzg", "foundry-common", "foundry-evm", "hash-db", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 36607d12608f9..430c9e906bdf3 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -40,7 +40,7 @@ trie-db = "0.23" hash-db = "0.15" memory-db = "0.29" alloy-primitives = { workspace = true, features = ["serde"] } -alloy-consensus.workspace = true +alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-network.workspace = true alloy-rlp.workspace = true alloy-signer = { workspace = true, features = ["eip712", "mnemonic"] } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 3b164a9d81207..6b6041ce54ab7 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -20,12 +20,13 @@ alloy-rpc-trace-types.workspace = true alloy-rlp.workspace = true alloy-eips.workspace = true alloy-network = { workspace = true, features = ["k256"] } -alloy-consensus.workspace = true +alloy-consensus = { workspace = true, features = ["k256", "kzg"]} alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } serde = { workspace = true, optional = true } serde_json.workspace = true bytes = "1.4" +c-kzg = { version = "0.4.2", features = ["serde"] } # trie hash-db = { version = "0.15", default-features = false } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index afc16b928f12b..72a88c54712ce 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -4,7 +4,10 @@ use crate::eth::{ transaction::optimism::{DepositTransaction, DepositTransactionRequest}, utils::eip_to_revm_access_list, }; -use alloy_consensus::{ReceiptWithBloom, TxEip1559, TxEip2930, TxLegacy}; +use alloy_consensus::{ + BlobTransactionSidecar, ReceiptWithBloom, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, + TxEip4844WithSidecar, TxLegacy, +}; use alloy_network::{Signed, Transaction, TxKind}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, B256, U128, U256, U64}; use alloy_rlp::{Decodable, Encodable}; @@ -39,11 +42,14 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option Option { + (Some(0), _, None, None, None, None, None, None) | + (None, Some(_), None, None, None, None, None, None) => { Some(TypedTransactionRequest::Legacy(TxLegacy { nonce: nonce.unwrap_or_default().to::(), gas_price: gas_price.unwrap_or_default().to::(), @@ -87,7 +97,8 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { + (Some(1), _, None, None, _, None, None, None) | + (None, _, None, None, Some(_), None, None, None) => { Some(TypedTransactionRequest::EIP2930(TxEip2930 { nonce: nonce.unwrap_or_default().to::(), gas_price: gas_price.unwrap_or_default().to(), @@ -103,10 +114,10 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { + (Some(2), None, _, _, _, _, None, None) | + (None, None, Some(_), _, _, _, None, None) | + (None, None, _, Some(_), _, _, None, None) | + (None, None, None, None, None, _, None, None) => { // Empty fields fall back to the canonical transaction schema. Some(TypedTransactionRequest::EIP1559(TxEip1559 { nonce: nonce.unwrap_or_default().to::(), @@ -123,6 +134,45 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { + let tx = TxEip4844 { + nonce: nonce.unwrap_or_default().to::(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), + max_fee_per_blob_gas: max_fee_per_blob_gas.unwrap_or_default().to::(), + gas_limit: gas.unwrap_or_default().to::(), + value: value.unwrap_or(U256::ZERO), + input: input.into_input().unwrap_or_default(), + to: match to { + Some(to) => TxKind::Call(to), + None => TxKind::Create, + }, + chain_id: 0, + access_list: to_eip_access_list(access_list.unwrap_or_default()), + blob_versioned_hashes: blob_versioned_hashes.unwrap_or_default(), + }; + let blob_sidecar = BlobTransactionSidecar { + blobs: sidecar + .blobs + .into_iter() + .map(|b| c_kzg::Blob::from_bytes(b.as_slice()).unwrap()) + .collect(), + commitments: sidecar + .commitments + .into_iter() + .map(|c| c_kzg::Bytes48::from_bytes(c.as_slice()).unwrap()) + .collect(), + proofs: sidecar + .proofs + .into_iter() + .map(|p| c_kzg::Bytes48::from_bytes(p.as_slice()).unwrap()) + .collect(), + }; + Some(TypedTransactionRequest::EIP4844(TxEip4844Variant::TxEip4844WithSidecar( + TxEip4844WithSidecar::from_tx_and_sidecar(tx, blob_sidecar), + ))) + } _ => None, } } @@ -132,6 +182,7 @@ pub enum TypedTransactionRequest { Legacy(TxLegacy), EIP2930(TxEip2930), EIP1559(TxEip1559), + EIP4844(TxEip4844Variant), Deposit(DepositTransactionRequest), } @@ -316,6 +367,33 @@ pub fn to_alloy_transaction_with_hash_and_sender( blob_versioned_hashes: vec![], other: Default::default(), }, + TypedTransaction::EIP4844(t) => RpcTransaction { + hash, + nonce: U64::from(t.tx().tx().nonce), + block_hash: None, + block_number: None, + transaction_index: None, + from, + to: None, + value: t.tx().tx().value, + gas_price: Some(U128::from(t.tx().tx().max_fee_per_gas)), + max_fee_per_gas: Some(U128::from(t.tx().tx().max_fee_per_gas)), + max_priority_fee_per_gas: Some(U128::from(t.tx().tx().max_priority_fee_per_gas)), + gas: U256::from(t.tx().tx().gas_limit), + input: t.tx().tx().input.clone(), + chain_id: Some(U64::from(t.tx().tx().chain_id)), + signature: Some(RpcSignature { + r: t.signature().r(), + s: t.signature().s(), + v: U256::from(t.signature().v().y_parity_byte()), + y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), + }), + access_list: Some(from_eip_to_alloy_access_list(t.tx().tx().access_list.clone()).0), + transaction_type: Some(U64::from(3)), + max_fee_per_blob_gas: Some(U128::from(t.tx().tx().max_fee_per_blob_gas)), + blob_versioned_hashes: t.tx().tx().blob_versioned_hashes.clone(), + other: Default::default(), + }, TypedTransaction::Deposit(t) => RpcTransaction { hash, nonce: U64::from(t.nonce), @@ -463,6 +541,37 @@ impl PendingTransaction { ..Default::default() } } + TypedTransaction::EIP4844(tx) => { + let TxEip4844 { + chain_id, + nonce, + max_fee_per_blob_gas, + max_fee_per_gas, + max_priority_fee_per_gas, + gas_limit, + to, + value, + input, + access_list, + blob_versioned_hashes, + .. + } = tx.tx().tx(); + TxEnv { + caller, + transact_to: transact_to(to), + data: alloy_primitives::Bytes(input.0.clone()), + chain_id: Some(*chain_id), + nonce: Some(*nonce), + value: *value, + gas_price: U256::from(*max_fee_per_gas), + gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), + max_fee_per_blob_gas: Some(U256::from(*max_fee_per_blob_gas)), + blob_hashes: blob_versioned_hashes.clone(), + gas_limit: *gas_limit, + access_list: eip_to_revm_access_list(access_list.0.clone()), + ..Default::default() + } + } TypedTransaction::Deposit(tx) => { let chain_id = tx.chain_id(); let DepositTransaction { @@ -509,6 +618,8 @@ pub enum TypedTransaction { EIP2930(Signed), /// EIP-1559 transaction EIP1559(Signed), + /// EIP-4844 transaction + EIP4844(Signed), /// op-stack deposit transaction Deposit(DepositTransaction), } @@ -524,6 +635,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.gas_price, TypedTransaction::EIP2930(tx) => tx.gas_price, TypedTransaction::EIP1559(tx) => tx.max_fee_per_gas, + TypedTransaction::EIP4844(tx) => tx.tx().tx().max_fee_per_blob_gas, TypedTransaction::Deposit(_) => 0, }) } @@ -533,6 +645,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.gas_limit, TypedTransaction::EIP2930(tx) => tx.gas_limit, TypedTransaction::EIP1559(tx) => tx.gas_limit, + TypedTransaction::EIP4844(tx) => tx.tx().tx().gas_limit, TypedTransaction::Deposit(tx) => tx.gas_limit.to::(), }) } @@ -542,6 +655,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.value, TypedTransaction::EIP2930(tx) => tx.value, TypedTransaction::EIP1559(tx) => tx.value, + TypedTransaction::EIP4844(tx) => tx.tx().tx().value, TypedTransaction::Deposit(tx) => tx.value, }) } @@ -551,6 +665,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => &tx.input, TypedTransaction::EIP2930(tx) => &tx.input, TypedTransaction::EIP1559(tx) => &tx.input, + TypedTransaction::EIP4844(tx) => &tx.tx().tx().input, TypedTransaction::Deposit(tx) => &tx.input, } } @@ -561,6 +676,7 @@ impl TypedTransaction { TypedTransaction::Legacy(_) => None, TypedTransaction::EIP2930(_) => Some(1), TypedTransaction::EIP1559(_) => Some(2), + TypedTransaction::EIP4844(_) => Some(3), TypedTransaction::Deposit(_) => Some(0x7E), } } @@ -581,6 +697,8 @@ impl TypedTransaction { gas_price: Some(U256::from(t.tx().gas_price)), max_fee_per_gas: None, max_priority_fee_per_gas: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: None, value: t.value, chain_id: t.tx().chain_id, access_list: Default::default(), @@ -593,6 +711,8 @@ impl TypedTransaction { gas_price: Some(U256::from(t.tx().gas_price)), max_fee_per_gas: None, max_priority_fee_per_gas: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: None, value: t.value, chain_id: Some(t.chain_id), access_list: to_alloy_access_list(t.access_list.clone()), @@ -605,10 +725,26 @@ impl TypedTransaction { gas_price: None, max_fee_per_gas: Some(U256::from(t.max_fee_per_gas)), max_priority_fee_per_gas: Some(U256::from(t.max_priority_fee_per_gas)), + max_fee_per_blob_gas: None, + blob_versioned_hashes: None, value: t.value, chain_id: Some(t.chain_id), access_list: to_alloy_access_list(t.access_list.clone()), }, + TypedTransaction::EIP4844(t) => TransactionEssentials { + kind: t.tx().tx().to, + input: t.tx().tx().input.clone(), + nonce: U256::from(t.tx().tx().nonce), + gas_limit: U256::from(t.tx().tx().gas_limit), + gas_price: Some(U256::from(t.tx().tx().max_fee_per_blob_gas)), + max_fee_per_gas: Some(U256::from(t.tx().tx().max_fee_per_gas)), + max_priority_fee_per_gas: Some(U256::from(t.tx().tx().max_priority_fee_per_gas)), + max_fee_per_blob_gas: Some(U256::from(t.tx().tx().max_fee_per_blob_gas)), + blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), + value: t.tx().tx().value, + chain_id: Some(t.tx().tx().chain_id), + access_list: to_alloy_access_list(t.tx().tx().access_list.clone()), + }, TypedTransaction::Deposit(t) => TransactionEssentials { kind: t.kind, input: t.input.clone(), @@ -617,6 +753,8 @@ impl TypedTransaction { gas_price: Some(U256::from(0)), max_fee_per_gas: None, max_priority_fee_per_gas: None, + max_fee_per_blob_gas: None, + blob_versioned_hashes: None, value: t.value, chain_id: t.chain_id(), access_list: Default::default(), @@ -629,6 +767,7 @@ impl TypedTransaction { TypedTransaction::Legacy(t) => U256::from(t.nonce), TypedTransaction::EIP2930(t) => U256::from(t.nonce), TypedTransaction::EIP1559(t) => U256::from(t.nonce), + TypedTransaction::EIP4844(t) => U256::from(t.tx().tx().nonce), TypedTransaction::Deposit(t) => U256::from(t.nonce), } } @@ -638,6 +777,7 @@ impl TypedTransaction { TypedTransaction::Legacy(t) => t.chain_id, TypedTransaction::EIP2930(t) => Some(t.chain_id), TypedTransaction::EIP1559(t) => Some(t.chain_id), + TypedTransaction::EIP4844(t) => Some(t.tx().tx().chain_id), TypedTransaction::Deposit(t) => t.chain_id(), } } @@ -659,6 +799,16 @@ impl TypedTransaction { matches!(self, TypedTransaction::EIP1559(_)) } + /// Returns true whether this tx is a EIP2930 transaction + pub fn is_eip2930(&self) -> bool { + matches!(self, TypedTransaction::EIP2930(_)) + } + + /// Returns true whether this tx is a EIP4844 transaction + pub fn is_eip4844(&self) -> bool { + matches!(self, TypedTransaction::EIP4844(_)) + } + /// Returns the hash of the transaction. /// /// Note: If this transaction has the Impersonated signature then this returns a modified unique @@ -668,6 +818,7 @@ impl TypedTransaction { TypedTransaction::Legacy(t) => *t.hash(), TypedTransaction::EIP2930(t) => *t.hash(), TypedTransaction::EIP1559(t) => *t.hash(), + TypedTransaction::EIP4844(t) => *t.hash(), TypedTransaction::Deposit(t) => t.hash(), } } @@ -695,6 +846,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.recover_signer(), TypedTransaction::EIP2930(tx) => tx.recover_signer(), TypedTransaction::EIP1559(tx) => tx.recover_signer(), + TypedTransaction::EIP4844(tx) => tx.recover_signer(), TypedTransaction::Deposit(tx) => tx.recover(), } } @@ -705,6 +857,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => &tx.to, TypedTransaction::EIP2930(tx) => &tx.to, TypedTransaction::EIP1559(tx) => &tx.to, + TypedTransaction::EIP4844(tx) => &tx.tx().tx().to, TypedTransaction::Deposit(tx) => &tx.kind, } } @@ -720,6 +873,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => *tx.signature(), TypedTransaction::EIP2930(tx) => *tx.signature(), TypedTransaction::EIP1559(tx) => *tx.signature(), + TypedTransaction::EIP4844(tx) => *tx.signature(), TypedTransaction::Deposit(_) => Signature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), @@ -736,6 +890,7 @@ impl Encodable for TypedTransaction { TypedTransaction::Legacy(tx) => tx.encode(out), TypedTransaction::EIP2930(tx) => tx.encode(out), TypedTransaction::EIP1559(tx) => tx.encode(out), + TypedTransaction::EIP4844(tx) => tx.encode(out), TypedTransaction::Deposit(tx) => tx.encode(out), } } @@ -774,6 +929,10 @@ impl Decodable for TypedTransaction { } else if tx_type == 0x02 { buf.advance(1); as Decodable>::decode(buf).map(TypedTransaction::EIP1559) + } else if tx_type == 0x03 { + buf.advance(1); + as Decodable>::decode(buf) + .map(TypedTransaction::EIP4844) } else if tx_type == 0x7E { buf.advance(1); ::decode(buf).map(TypedTransaction::Deposit) @@ -800,6 +959,8 @@ pub struct TransactionEssentials { pub gas_price: Option, pub max_fee_per_gas: Option, pub max_priority_fee_per_gas: Option, + pub max_fee_per_blob_gas: Option, + pub blob_versioned_hashes: Option>, pub value: U256, pub chain_id: Option, pub access_list: AccessList, @@ -826,6 +987,7 @@ pub enum TypedReceipt { Legacy(ReceiptWithBloom), EIP2930(ReceiptWithBloom), EIP1559(ReceiptWithBloom), + EIP4844(ReceiptWithBloom), Deposit(ReceiptWithBloom), } @@ -835,6 +997,7 @@ impl TypedReceipt { TypedReceipt::Legacy(r) | TypedReceipt::EIP1559(r) | TypedReceipt::EIP2930(r) | + TypedReceipt::EIP4844(r) | TypedReceipt::Deposit(r) => U256::from(r.receipt.cumulative_gas_used), } } @@ -844,6 +1007,7 @@ impl TypedReceipt { TypedReceipt::Legacy(r) | TypedReceipt::EIP1559(r) | TypedReceipt::EIP2930(r) | + TypedReceipt::EIP4844(r) | TypedReceipt::Deposit(r) => &r.bloom, } } @@ -855,6 +1019,7 @@ impl From for ReceiptWithBloom { TypedReceipt::Legacy(r) | TypedReceipt::EIP1559(r) | TypedReceipt::EIP2930(r) | + TypedReceipt::EIP4844(r) | TypedReceipt::Deposit(r) => r, } } @@ -870,6 +1035,7 @@ impl Encodable for TypedReceipt { let payload_len = match receipt { TypedReceipt::EIP2930(r) => r.length() + 1, TypedReceipt::EIP1559(r) => r.length() + 1, + TypedReceipt::EIP4844(r) => r.length() + 1, TypedReceipt::Deposit(r) => r.length() + 1, _ => unreachable!("receipt already matched"), }; @@ -885,6 +1051,11 @@ impl Encodable for TypedReceipt { 2u8.encode(out); r.encode(out); } + TypedReceipt::EIP4844(r) => { + Header { list: true, payload_length: payload_len }.encode(out); + 3u8.encode(out); + r.encode(out); + } TypedReceipt::Deposit(r) => { Header { list: true, payload_length: payload_len }.encode(out); 0x7Eu8.encode(out); @@ -923,6 +1094,9 @@ impl Decodable for TypedReceipt { } else if receipt_type == 0x02 { buf.advance(1); ::decode(buf).map(TypedReceipt::EIP1559) + } else if receipt_type == 0x03 { + buf.advance(1); + ::decode(buf).map(TypedReceipt::EIP4844) } else if receipt_type == 0x7E { buf.advance(1); ::decode(buf).map(TypedReceipt::Deposit) @@ -1038,6 +1212,42 @@ mod tests { ); } + // Test vector from https://sepolia.etherscan.io/tx/0x9a22ccb0029bc8b0ddd073be1a1d923b7ae2b2ea52100bae0db4424f9107e9c0 + // Blobscan: https://sepolia.blobscan.com/tx/0x9a22ccb0029bc8b0ddd073be1a1d923b7ae2b2ea52100bae0db4424f9107e9c0 + #[test] + fn test_decode_live_4844_tx() { + use alloy_primitives::{address, b256}; + + // https://sepolia.etherscan.io/getRawTx?tx=0x9a22ccb0029bc8b0ddd073be1a1d923b7ae2b2ea52100bae0db4424f9107e9c0 + let raw_tx = alloy_primitives::hex::decode("0x03f9011d83aa36a7820fa28477359400852e90edd0008252089411e9ca82a3a762b4b5bd264d4173a242e7a770648080c08504a817c800f8a5a0012ec3d6f66766bedb002a190126b3549fce0047de0d4c25cffce0dc1c57921aa00152d8e24762ff22b1cfd9f8c0683786a7ca63ba49973818b3d1e9512cd2cec4a0013b98c6c83e066d5b14af2b85199e3d4fc7d1e778dd53130d180f5077e2d1c7a001148b495d6e859114e670ca54fb6e2657f0cbae5b08063605093a4b3dc9f8f1a0011ac212f13c5dff2b2c6b600a79635103d6f580a4221079951181b25c7e654901a0c8de4cced43169f9aa3d36506363b2d2c44f6c49fc1fd91ea114c86f3757077ea01e11fdd0d1934eda0492606ee0bb80a7bf8f35cc5f86ec60fe5031ba48bfd544").unwrap(); + let res = TypedTransaction::decode(&mut raw_tx.as_slice()).unwrap(); + assert_eq!(res.r#type(), Some(3)); + + let tx = match res { + TypedTransaction::EIP4844(tx) => tx, + _ => unreachable!(), + }; + + assert_eq!( + tx.tx().tx().to, + TxKind::Call(address!("11E9CA82A3a762b4B5bd264d4173a242e7a77064")) + ); + + assert_eq!( + tx.tx().tx().blob_versioned_hashes, + vec![ + b256!("012ec3d6f66766bedb002a190126b3549fce0047de0d4c25cffce0dc1c57921a"), + b256!("0152d8e24762ff22b1cfd9f8c0683786a7ca63ba49973818b3d1e9512cd2cec4"), + b256!("013b98c6c83e066d5b14af2b85199e3d4fc7d1e778dd53130d180f5077e2d1c7"), + b256!("01148b495d6e859114e670ca54fb6e2657f0cbae5b08063605093a4b3dc9f8f1"), + b256!("011ac212f13c5dff2b2c6b600a79635103d6f580a4221079951181b25c7e6549") + ] + ); + + let from = tx.recover_signer().unwrap(); + assert_eq!(from, address!("A83C816D4f9b2783761a22BA6FADB0eB0606D7B2")); + } + #[test] fn can_recover_sender_not_normalized() { let bytes = hex::decode("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap(); diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index f129044775e4f..a9b2cd8abb5ae 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2585,6 +2585,7 @@ impl EthApi { match &tx { TypedTransaction::EIP2930(_) => self.backend.ensure_eip2930_active(), TypedTransaction::EIP1559(_) => self.backend.ensure_eip1559_active(), + TypedTransaction::EIP4844(_) => self.backend.ensure_eip4844_active(), TypedTransaction::Deposit(_) => self.backend.ensure_op_deposits_active(), TypedTransaction::Legacy(_) => Ok(()), } @@ -2674,6 +2675,10 @@ fn determine_base_gas_by_kind(request: &TransactionRequest) -> U256 { TxKind::Call(_) => MIN_TRANSACTION_GAS, TxKind::Create => MIN_CREATE_GAS, }, + TypedTransactionRequest::EIP4844(req) => match req.tx().to { + TxKind::Call(_) => MIN_TRANSACTION_GAS, + TxKind::Create => MIN_CREATE_GAS, + }, TypedTransactionRequest::Deposit(req) => match req.kind { TxKind::Call(_) => MIN_TRANSACTION_GAS, TxKind::Create => MIN_CREATE_GAS, diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 45fc1f1126a1b..320d4688462c1 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -76,6 +76,14 @@ impl ExecutedTransaction { }, bloom, }), + TypedTransaction::EIP4844(_) => TypedReceipt::EIP4844(ReceiptWithBloom { + receipt: Receipt { + success: status_code == 1, + cumulative_gas_used: used_gas.to::(), + logs, + }, + bloom, + }), TypedTransaction::Deposit(_) => TypedReceipt::Deposit(ReceiptWithBloom { receipt: Receipt { success: status_code == 1, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 709932438a1e1..837b6482df165 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -578,6 +578,11 @@ impl Backend { (self.spec_id() as u8) >= (SpecId::BERLIN as u8) } + /// Returns true for post Cancun + pub fn is_eip4844(&self) -> bool { + (self.spec_id() as u8) >= (SpecId::CANCUN as u8) + } + /// Returns true if op-stack deposits are active pub fn is_optimism(&self) -> bool { self.env.read().handler_cfg.is_optimism @@ -599,6 +604,13 @@ impl Backend { Err(BlockchainError::EIP2930TransactionUnsupportedAtHardfork) } + pub fn ensure_eip4844_active(&self) -> Result<(), BlockchainError> { + if self.is_eip4844() { + return Ok(()); + } + Err(BlockchainError::EIP4844TransactionUnsupportedAtHardfork) + } + /// Returns an error if op-stack deposits are not active pub fn ensure_op_deposits_active(&self) -> Result<(), BlockchainError> { if self.is_optimism() { @@ -1972,6 +1984,12 @@ impl Backend { .map_or(self.base_fee().to::(), |b| b as u128) .checked_add(t.max_priority_fee_per_gas) .unwrap_or(u128::MAX), + TypedTransaction::EIP4844(t) => block + .header + .base_fee_per_gas + .map_or(self.base_fee().to::(), |b| b as u128) + .checked_add(t.tx().tx().max_priority_fee_per_gas) + .unwrap_or(u128::MAX), TypedTransaction::Deposit(_) => 0_u128, }; diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 39e1f52a42f03..57436503965d8 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -81,6 +81,8 @@ pub enum BlockchainError { EIP1559TransactionUnsupportedAtHardfork, #[error("Access list received but is not supported by the current hardfork.\n\nYou can use it by running anvil with '--hardfork berlin' or later.")] EIP2930TransactionUnsupportedAtHardfork, + #[error("EIP-4844 fields received but is not supported by the current hardfork.\n\nYou can use it by running anvil with '--hardfork cancun' or later.")] + EIP4844TransactionUnsupportedAtHardfork, #[error("op-stack deposit tx received but is not supported.\n\nYou can use it by running anvil with '--optimism'.")] DepositTransactionUnsupported, #[error("Excess blob gas not set.")] @@ -408,6 +410,9 @@ impl ToRpcResponseResult for Result { err @ BlockchainError::EIP2930TransactionUnsupportedAtHardfork => { RpcError::invalid_params(err.to_string()) } + err @ BlockchainError::EIP4844TransactionUnsupportedAtHardfork => { + RpcError::invalid_params(err.to_string()) + } err @ BlockchainError::DepositTransactionUnsupported => { RpcError::invalid_params(err.to_string()) } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 4f341858b5e30..ef2d38eca87fa 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -259,6 +259,15 @@ impl FeeHistoryService { .min(U256::from(t.max_fee_per_gas).saturating_sub(base_fee)) .to::() } + // TODO: This probably needs to be extended to extract 4844 info. + Some(TypedTransaction::EIP4844(t)) => { + U256::from(t.tx().tx().max_priority_fee_per_gas) + .min( + U256::from(t.tx().tx().max_fee_per_gas) + .saturating_sub(base_fee), + ) + .to::() + } Some(TypedTransaction::Deposit(_)) => 0, None => 0, }; diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index 34b3fa2855626..4886d96f04685 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -107,6 +107,7 @@ impl Signer for DevSigner { TypedTransactionRequest::Legacy(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), TypedTransactionRequest::EIP2930(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), TypedTransactionRequest::EIP1559(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), + TypedTransactionRequest::EIP4844(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), TypedTransactionRequest::Deposit(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), } } @@ -134,6 +135,10 @@ pub fn build_typed_transaction( let sighash = tx.signature_hash(); TypedTransaction::EIP1559(Signed::new_unchecked(tx, signature, sighash)) } + TypedTransactionRequest::EIP4844(tx) => { + let sighash = tx.signature_hash(); + TypedTransaction::EIP4844(Signed::new_unchecked(tx, signature, sighash)) + } TypedTransactionRequest::Deposit(tx) => { let DepositTransactionRequest { from, From 4fa0fa1671d3955984b96dd1fa3eae09233c550f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 12 Mar 2024 22:59:47 +0100 Subject: [PATCH 0746/1963] chore: use Bytes to store calldata (#7383) --- crates/debugger/src/tui/draw.rs | 6 +++--- crates/evm/core/src/debug.rs | 4 ++-- crates/evm/evm/src/inspectors/debugger.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index d06e5c231eb9a..41eca5e76af5f 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -503,9 +503,9 @@ impl DebuggerContext<'_> { fn draw_buffer(&self, f: &mut Frame<'_>, area: Rect) { let step = self.current_step(); let buf = match self.active_buffer { - BufferKind::Memory => &step.memory, - BufferKind::Calldata => &step.calldata, - BufferKind::Returndata => &step.returndata, + BufferKind::Memory => step.memory.as_ref(), + BufferKind::Calldata => step.calldata.as_ref(), + BufferKind::Returndata => step.returndata.as_ref(), }; let min_len = hex_digits(buf.len()); diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index d6f459339c177..3866dfe0c782c 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, U256}; +use alloy_primitives::{Address, Bytes, U256}; use revm::interpreter::OpCode; use revm_inspectors::tracing::types::CallKind; use serde::{Deserialize, Serialize}; @@ -170,7 +170,7 @@ pub struct DebugStep { /// Memory *prior* to running the associated opcode pub memory: Vec, /// Calldata *prior* to running the associated opcode - pub calldata: Vec, + pub calldata: Bytes, /// Returndata *prior* to running the associated opcode pub returndata: Vec, /// Opcode to be executed diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index 222e6de3bd04a..8d7c7b116c5ba 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -76,7 +76,7 @@ impl Inspector for Debugger { pc, stack: interp.stack().data().clone(), memory: interp.shared_memory.context_memory().to_vec(), - calldata: interp.contract().input.to_vec(), + calldata: interp.contract().input.clone(), returndata: interp.return_data_buffer.to_vec(), instruction: Instruction::OpCode(op), push_bytes, From 46889b1ab0fb50a73537c5292df7cdeb22202553 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 12 Mar 2024 23:11:50 +0100 Subject: [PATCH 0747/1963] chore: retry 429 errors (#7384) --- crates/common/src/provider/retry.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index 2137dedbdc68e..e7277bd4b1984 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -79,6 +79,12 @@ fn should_retry_transport_level_error(error: &TransportErrorKind) -> bool { match error { // Missing batch response errors can be retried. TransportErrorKind::MissingBatchResponse(_) => true, + TransportErrorKind::Custom(err) => { + // currently http error responses are not standard in alloy + let msg = err.to_string(); + msg.contains("429 Too Many Requests") + } + // If the backend is gone, or there's a completely custom error, we should assume it's not // retryable. _ => false, From b2f9346ef75810a48f776a36ad1bfb3b873c3514 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 12 Mar 2024 23:37:20 +0100 Subject: [PATCH 0748/1963] chore: reuse unmodified step memory (#7385) * chore: only record changed memory * chore: only record changed memory * chore: use returndata Bytes * clippy * clippy --- crates/evm/core/src/debug.rs | 21 +++++++++++++++++-- crates/evm/core/src/lib.rs | 1 + crates/evm/core/src/opcodes.rs | 25 +++++++++++++++++++++++ crates/evm/evm/src/inspectors/debugger.rs | 20 ++++++++++++++++-- 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 crates/evm/core/src/opcodes.rs diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 3866dfe0c782c..084d36b904cd8 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,3 +1,4 @@ +use crate::opcodes; use alloy_primitives::{Address, Bytes, U256}; use revm::interpreter::OpCode; use revm_inspectors::tracing::types::CallKind; @@ -168,11 +169,11 @@ pub struct DebugStep { /// Stack *prior* to running the associated opcode pub stack: Vec, /// Memory *prior* to running the associated opcode - pub memory: Vec, + pub memory: Bytes, /// Calldata *prior* to running the associated opcode pub calldata: Bytes, /// Returndata *prior* to running the associated opcode - pub returndata: Vec, + pub returndata: Bytes, /// Opcode to be executed pub instruction: Instruction, /// Optional bytes that are being pushed onto the stack @@ -210,6 +211,11 @@ impl DebugStep { self.instruction.to_string() } } + + /// Returns `true` if the opcode modifies memory. + pub fn opcode_modifies_memory(&self) -> bool { + self.instruction.opcode().and_then(OpCode::new).map_or(false, opcodes::modifies_memory) + } } #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] @@ -249,3 +255,14 @@ impl Display for Instruction { } } } + +impl Instruction { + /// Returns the opcode of the instruction, if it is an opcode. + #[inline] + pub fn opcode(&self) -> Option { + match self { + Instruction::OpCode(op) => Some(*op), + _ => None, + } + } +} diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index caafa8e0f4d23..9d26c9421c3fa 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -15,6 +15,7 @@ pub mod constants; pub mod debug; pub mod decode; pub mod fork; +pub mod opcodes; pub mod opts; pub mod snapshot; pub mod utils; diff --git a/crates/evm/core/src/opcodes.rs b/crates/evm/core/src/opcodes.rs new file mode 100644 index 0000000000000..3251036c78f7a --- /dev/null +++ b/crates/evm/core/src/opcodes.rs @@ -0,0 +1,25 @@ +//! Opcode utils + +use revm::interpreter::OpCode; + +/// Returns true if the opcode modifies memory. +/// +/// +#[inline] +pub const fn modifies_memory(opcode: OpCode) -> bool { + matches!( + opcode, + OpCode::EXTCODECOPY | + OpCode::MLOAD | + OpCode::MSTORE | + OpCode::MSTORE8 | + OpCode::MCOPY | + OpCode::CODECOPY | + OpCode::CALLDATACOPY | + OpCode::RETURNDATACOPY | + OpCode::CALL | + OpCode::CALLCODE | + OpCode::DELEGATECALL | + OpCode::STATICCALL + ) +} diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index 8d7c7b116c5ba..5ec952ac26cba 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -72,12 +72,28 @@ impl Inspector for Debugger { interp.gas.refunded() as u64, ); + // if the previous opcode does __not__ modify memory, we can reuse the memory of + // that step + let memory = self.arena.arena[self.head] + .steps + .last() + .and_then(|step| { + if !step.opcode_modifies_memory() { + // reuse the memory from the previous step, because its opcode did not modify + // memory + Some(step.memory.clone()) + } else { + None + } + }) + .unwrap_or_else(|| interp.shared_memory.context_memory().to_vec().into()); + self.arena.arena[self.head].steps.push(DebugStep { pc, stack: interp.stack().data().clone(), - memory: interp.shared_memory.context_memory().to_vec(), + memory, calldata: interp.contract().input.clone(), - returndata: interp.return_data_buffer.to_vec(), + returndata: interp.return_data_buffer.clone(), instruction: Instruction::OpCode(op), push_bytes, total_gas_used, From ed8dec54a0cf4f292ea7ee3e3934443d34cf65d9 Mon Sep 17 00:00:00 2001 From: Krishang Shah <93703995+kamuik16@users.noreply.github.com> Date: Wed, 13 Mar 2024 18:12:50 +0530 Subject: [PATCH 0749/1963] feat: supports socket address as --rpc-url input (#7389) * feat: supports socket address * cargo fmt and clippy --- crates/common/src/provider/alloy.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/common/src/provider/alloy.rs b/crates/common/src/provider/alloy.rs index 7208c7953128e..54c9085a15ee6 100644 --- a/crates/common/src/provider/alloy.rs +++ b/crates/common/src/provider/alloy.rs @@ -12,7 +12,9 @@ use foundry_common::types::ToAlloy; use foundry_config::NamedChain; use reqwest::Url; use std::{ + net::SocketAddr, path::{Path, PathBuf}, + str::FromStr, time::Duration, }; use url::ParseError; @@ -93,12 +95,16 @@ impl ProviderBuilder { let url = Url::parse(url_str) .or_else(|err| match err { ParseError::RelativeUrlWithoutBase => { - let path = Path::new(url_str); - - if let Ok(path) = resolve_path(path) { - Url::parse(&format!("file://{}", path.display())) + if SocketAddr::from_str(url_str).is_ok() { + Url::parse(&format!("http://{}", url_str)) } else { - Err(err) + let path = Path::new(url_str); + + if let Ok(path) = resolve_path(path) { + Url::parse(&format!("file://{}", path.display())) + } else { + Err(err) + } } } _ => Err(err), From bd03d2b9bd082e7b503b855a32a560eddf496399 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 13 Mar 2024 14:52:36 +0100 Subject: [PATCH 0750/1963] chore: simplify get transaction nonce (#7392) * chore: simplify get transaction nonce * chore: rm option * chore: cleanup --- crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 29 ++++++++++--------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index a9b2cd8abb5ae..83754480bb839 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2535,7 +2535,7 @@ impl EthApi { } } - let nonce = self.backend.get_nonce(address, Some(block_request)).await?; + let nonce = self.backend.get_nonce(address, block_request).await?; Ok(nonce) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 837b6482df165..013c303e32851 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1789,19 +1789,19 @@ impl Backend { pub async fn get_nonce( &self, address: Address, - block_request: Option, + block_request: BlockRequest, ) -> Result { - if let Some(BlockRequest::Pending(pool_transactions)) = block_request.as_ref() { + if let BlockRequest::Pending(pool_transactions) = &block_request { if let Some(value) = get_pool_transactions_nonce(pool_transactions, address) { return Ok(value); } } let final_block_request = match block_request { - Some(BlockRequest::Pending(_)) => Some(BlockRequest::Number(self.best_number())), - Some(BlockRequest::Number(bn)) => Some(BlockRequest::Number(bn)), - None => None, + BlockRequest::Pending(_) => BlockRequest::Number(self.best_number()), + BlockRequest::Number(bn) => BlockRequest::Number(bn), }; - self.with_database_at(final_block_request, |db, _| { + + self.with_database_at(Some(final_block_request), |db, _| { trace!(target: "backend", "get nonce for {:?}", address); Ok(U256::from(db.basic_ref(address)?.unwrap_or_default().nonce)) }) @@ -2276,19 +2276,14 @@ fn get_pool_transactions_nonce( pool_transactions: &[Arc], address: Address, ) -> Option { - let highest_nonce_tx = pool_transactions + if let Some(highest_nonce) = pool_transactions .iter() .filter(|tx| *tx.pending_transaction.sender() == address) - .reduce(|accum, item| { - let nonce = item.pending_transaction.nonce(); - if nonce > accum.pending_transaction.nonce() { - item - } else { - accum - } - }); - if let Some(highest_nonce_tx) = highest_nonce_tx { - return Some(highest_nonce_tx.pending_transaction.nonce().saturating_add(U256::from(1))); + .map(|tx| tx.pending_transaction.nonce()) + .max() + { + let tx_count = highest_nonce.saturating_add(U256::from(1)); + return Some(tx_count) } None } From b6d31869344c820515554ed20ee698232f3c42c3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:38:01 +0100 Subject: [PATCH 0751/1963] perf: use fxhash in maps when the key is small (#7393) --- Cargo.lock | 121 +++++++++++++++------------- Cargo.toml | 10 +-- crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/src/inspector.rs | 3 +- crates/common/Cargo.toml | 1 + crates/common/src/compile.rs | 3 +- crates/common/src/evm.rs | 4 +- crates/evm/core/Cargo.toml | 3 +- crates/evm/core/src/fork/backend.rs | 3 +- crates/evm/core/src/ic.rs | 11 +-- crates/evm/coverage/Cargo.toml | 1 + crates/evm/coverage/src/analysis.rs | 9 ++- crates/evm/evm/src/executors/mod.rs | 6 +- crates/forge/Cargo.toml | 17 +--- crates/forge/bin/cmd/coverage.rs | 5 +- crates/forge/src/runner.rs | 2 +- 16 files changed, 104 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d5f0d37be901..5ee659cab83f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,7 +564,7 @@ dependencies = [ "futures", "hash-db", "hyper", - "itertools 0.11.0", + "itertools 0.12.1", "k256", "memory-db", "parking_lot", @@ -645,9 +645,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arbitrary" @@ -1195,9 +1195,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "byteorder" @@ -1326,7 +1326,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.11.0", + "itertools 0.12.1", "rand 0.8.5", "rayon", "regex", @@ -1701,9 +1701,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.2" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b37dae8c8ded08d5ec72caa1b4204a5344047cd4a2c7387e3d150020abfbc1c9" +checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" dependencies = [ "cfg-if", "cpufeatures", @@ -2521,7 +2521,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.52", - "toml 0.8.10", + "toml 0.8.11", "walkdir", ] @@ -2878,7 +2878,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.10", + "toml 0.8.11", "uncased", "version_check", ] @@ -2989,7 +2989,7 @@ dependencies = [ "globset", "hyper", "indicatif", - "itertools 0.11.0", + "itertools 0.12.1", "once_cell", "opener", "parking_lot", @@ -3001,6 +3001,7 @@ dependencies = [ "regex", "reqwest", "revm-inspectors", + "rustc-hash", "semver 1.0.22", "serde", "serde_json", @@ -3031,7 +3032,7 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", - "itertools 0.11.0", + "itertools 0.12.1", "mdbook", "once_cell", "rayon", @@ -3040,7 +3041,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "tracing", ] @@ -3051,11 +3052,11 @@ dependencies = [ "alloy-primitives", "ariadne", "foundry-config", - "itertools 0.11.0", + "itertools 0.12.1", "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "tracing", "tracing-subscriber", ] @@ -3089,7 +3090,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.11.0", + "itertools 0.12.1", "parking_lot", "revm-inspectors", "semver 1.0.22", @@ -3169,7 +3170,7 @@ dependencies = [ "alloy-rpc-types", "alloy-signer", "alloy-sol-types", - "base64 0.21.7", + "base64 0.22.0", "const-hex", "eyre", "foundry-cheatcodes-spec", @@ -3178,15 +3179,16 @@ dependencies = [ "foundry-config", "foundry-evm-core", "foundry-wallets", - "itertools 0.11.0", + "itertools 0.12.1", "jsonpath_lib", "k256", "p256", "parking_lot", "revm", + "rustc-hash", "serde_json", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "tracing", "walkdir", ] @@ -3274,6 +3276,7 @@ dependencies = [ "pretty_assertions", "rand 0.8.5", "reqwest", + "rustc-hash", "semver 1.0.22", "serde", "serde_json", @@ -3289,9 +3292,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f5a6dffd81de844c96fea0aaf825cd2a9760c4a768ae3f5786d431ef3c57d69" +checksum = "1cc03b422b28e49d6dd61b8442bcee16c22edd975be1764de5a39c4037ecb478" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3351,7 +3354,7 @@ dependencies = [ "serde_regex", "tempfile", "thiserror", - "toml 0.8.10", + "toml 0.8.11", "toml_edit 0.21.1", "tracing", "walkdir", @@ -3393,7 +3396,7 @@ dependencies = [ "foundry-evm-fuzz", "foundry-evm-traces", "hashbrown 0.14.3", - "itertools 0.11.0", + "itertools 0.12.1", "parking_lot", "proptest", "rand 0.8.5", @@ -3425,11 +3428,12 @@ dependencies = [ "foundry-config", "foundry-macros", "futures", - "itertools 0.11.0", + "itertools 0.12.1", "once_cell", "parking_lot", "revm", "revm-inspectors", + "rustc-hash", "serde", "serde_json", "thiserror", @@ -3448,6 +3452,7 @@ dependencies = [ "foundry-compilers", "foundry-evm-core", "revm", + "rustc-hash", "semver 1.0.22", "tracing", ] @@ -3468,7 +3473,7 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-traces", "hashbrown 0.14.3", - "itertools 0.11.0", + "itertools 0.12.1", "parking_lot", "proptest", "rand 0.8.5", @@ -3495,7 +3500,7 @@ dependencies = [ "foundry-evm-core", "futures", "hashbrown 0.14.3", - "itertools 0.11.0", + "itertools 0.12.1", "once_cell", "revm-inspectors", "serde", @@ -3562,7 +3567,7 @@ dependencies = [ "eyre", "foundry-common", "foundry-config", - "itertools 0.11.0", + "itertools 0.12.1", "rpassword", "rusoto_core", "rusoto_kms", @@ -5524,7 +5529,7 @@ checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" dependencies = [ "inlinable_string", "pear_codegen", - "yansi 1.0.0", + "yansi 1.0.1", ] [[package]] @@ -5926,9 +5931,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -5943,7 +5948,7 @@ dependencies = [ "quote", "syn 2.0.52", "version_check", - "yansi 1.0.0", + "yansi 1.0.1", ] [[package]] @@ -6255,9 +6260,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" dependencies = [ "base64 0.21.7", "bytes", @@ -6470,9 +6475,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b1d9521f889713d1221270fdd63370feca7e5c71a18745343402fa86e4f04f" +checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" dependencies = [ "alloy-rlp", "arbitrary", @@ -6598,6 +6603,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -6757,9 +6768,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" +checksum = "2ef2175c2907e7c8bc0a9c3f86aeb5ec1f3b275300ad58a44d0c3ae379a5e52e" dependencies = [ "cfg-if", "derive_more", @@ -6769,9 +6780,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" +checksum = "634d9b8eb8fd61c5cdd3390d9b2132300a7e7618955b98b8416f118c1b4e144f" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -7483,20 +7494,20 @@ dependencies = [ [[package]] name = "system-configuration" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.4.2", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -7567,18 +7578,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", @@ -7793,15 +7804,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.6", + "toml_edit 0.22.7", ] [[package]] @@ -7848,9 +7859,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" dependencies = [ "indexmap", "serde", @@ -8751,9 +8762,9 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "yansi" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2861d76f58ec8fc95708b9b1e417f7b12fd72ad33c01fa6886707092dea0d3" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "zerocopy" diff --git a/Cargo.toml b/Cargo.toml index f56a5cfd7847c..1831efc1c4537 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,26 +186,26 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc +base64 = "0.22" chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" +evm-disassembler = "0.4" eyre = "0.6" hex = { package = "const-hex", version = "1.6", features = ["hex"] } -itertools = "0.11" +itertools = "0.12" jsonpath_lib = "0.3" +k256 = "0.13" pretty_assertions = "1.4" -protobuf = "=3.2.0" rand = "0.8" +rustc-hash = "1.1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } -base64 = "0.21" strum = "0.26" toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" -evm-disassembler = "0.4" vergen = { version = "8", default-features = false } -k256 = "0.13" axum = "0.6" hyper = "0.14" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 7524afb635f3b..57b39966e0345 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -42,3 +42,4 @@ k256.workspace = true walkdir = "2" p256 = "0.13.2" thiserror = "1" +rustc-hash.workspace = true diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 9b26e77547cf2..bf39684b4955f 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -32,6 +32,7 @@ use revm::{ primitives::{BlockEnv, CreateScheme, TransactTo}, EvmContext, InnerEvmContext, Inspector, }; +use rustc_hash::FxHashMap; use serde_json::Value; use std::{ collections::{BTreeMap, HashMap, VecDeque}, @@ -154,7 +155,7 @@ pub struct Cheatcodes { pub expected_emits: VecDeque, /// Map of context depths to memory offset ranges that may be written to within the call depth. - pub allowed_mem_writes: HashMap>>, + pub allowed_mem_writes: FxHashMap>>, /// Current broadcasting information pub broadcast: Option, diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 49be9df68407f..cf6e53040b38e 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -57,6 +57,7 @@ tracing.workspace = true url = "2" walkdir = "2" yansi = "0.5" +rustc-hash.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 96574f460f257..3f159f069b0fa 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -11,6 +11,7 @@ use foundry_compilers::{ Artifact, ArtifactId, FileFilter, Graph, Project, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig, }; +use rustc_hash::FxHashMap; use std::{ collections::{BTreeMap, HashMap}, convert::Infallible, @@ -278,7 +279,7 @@ pub struct ContractSources { /// Map over artifacts' contract names -> vector of file IDs pub ids_by_name: HashMap>, /// Map over file_id -> (source code, contract) - pub sources_by_id: HashMap, + pub sources_by_id: FxHashMap, } impl ContractSources { diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 4b2a94f4377d0..7b915891386b5 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -11,11 +11,11 @@ use foundry_config::{ }, Chain, Config, }; +use rustc_hash::FxHashMap; use serde::Serialize; -use std::collections::HashMap; /// Map keyed by breakpoints char to their location (contract address, pc) -pub type Breakpoints = HashMap; +pub type Breakpoints = FxHashMap; /// `EvmArgs` and `EnvArgs` take the highest precedence in the Config/Figment hierarchy. /// All vars are opt-in, their default values are expected to be set by the diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 347d0489cfb73..5e01c91141f55 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -37,14 +37,15 @@ revm = { workspace = true, default-features = false, features = [ ] } revm-inspectors.workspace = true -derive_more.workspace = true auto_impl = "1" +derive_more.workspace = true eyre = "0.6" futures = "0.3" hex.workspace = true itertools.workspace = true once_cell = "1" parking_lot = "0.12" +rustc-hash.workspace = true serde = "1" serde_json = "1" thiserror = "1" diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 6613c0f134977..8e720a2505d22 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -18,6 +18,7 @@ use revm::{ db::DatabaseRef, primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }; +use rustc_hash::FxHashMap; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, pin::Pin, @@ -86,7 +87,7 @@ pub struct BackendHandler

{ /// Listeners that wait for a `get_storage_at` response storage_requests: HashMap<(Address, U256), Vec>, /// Listeners that wait for a `get_block` response - block_requests: HashMap>, + block_requests: FxHashMap>, /// Incoming commands. incoming: Receiver, /// unprocessed queued requests diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index 479a50b0a528d..7bb2179c5e9a4 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -1,20 +1,21 @@ use revm::{ interpreter::{opcode, opcode::spec_opcode_gas}, - primitives::{HashMap, SpecId}, + primitives::SpecId, }; +use rustc_hash::FxHashMap; /// Maps from program counter to instruction counter. /// /// Inverse of [`IcPcMap`]. pub struct PcIcMap { - pub inner: HashMap, + pub inner: FxHashMap, } impl PcIcMap { /// Creates a new `PcIcMap` for the given code. pub fn new(spec: SpecId, code: &[u8]) -> Self { let opcode_infos = spec_opcode_gas(spec); - let mut map = HashMap::new(); + let mut map = FxHashMap::default(); let mut i = 0; let mut cumulative_push_size = 0; @@ -44,14 +45,14 @@ impl PcIcMap { /// /// Inverse of [`PcIcMap`]. pub struct IcPcMap { - pub inner: HashMap, + pub inner: FxHashMap, } impl IcPcMap { /// Creates a new `IcPcMap` for the given code. pub fn new(spec: SpecId, code: &[u8]) -> Self { let opcode_infos = spec_opcode_gas(spec); - let mut map = HashMap::new(); + let mut map = FxHashMap::default(); let mut i = 0; let mut cumulative_push_size = 0; diff --git a/crates/evm/coverage/Cargo.toml b/crates/evm/coverage/Cargo.toml index 4a9a39276abfc..6a3dc92ff3b32 100644 --- a/crates/evm/coverage/Cargo.toml +++ b/crates/evm/coverage/Cargo.toml @@ -20,3 +20,4 @@ eyre = "0.6" revm.workspace = true semver = "1" tracing = "0.1" +rustc-hash.workspace = true diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 9af93cb688c49..1926d2b4ed202 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -1,6 +1,7 @@ use super::{ContractId, CoverageItem, CoverageItemKind, SourceLocation}; use foundry_common::TestFunctionExt; use foundry_compilers::artifacts::ast::{self, Ast, Node, NodeType}; +use rustc_hash::FxHashMap; use semver::Version; use std::collections::{HashMap, HashSet}; @@ -443,9 +444,9 @@ pub struct SourceAnalysis { #[derive(Clone, Debug, Default)] pub struct SourceAnalyzer { /// A map of source IDs to their source code - sources: HashMap, + sources: FxHashMap, /// A map of AST node IDs of contracts to their contract IDs. - contract_ids: HashMap, + contract_ids: FxHashMap, /// A map of contract IDs to their AST nodes. contracts: HashMap, /// A collection of coverage items. @@ -463,8 +464,8 @@ impl SourceAnalyzer { /// (defined by `version`). pub fn new( version: Version, - asts: HashMap, - sources: HashMap, + asts: FxHashMap, + sources: FxHashMap, ) -> eyre::Result { let mut analyzer = SourceAnalyzer { sources, ..Default::default() }; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index a62d070a5ec4a..469d6b6e4a016 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -838,11 +838,7 @@ fn convert_call_result( .. } = call_result; - let breakpoints = if let Some(c) = call_result.cheatcodes { - c.breakpoints - } else { - std::collections::HashMap::new() - }; + let breakpoints = call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); match status { return_ok!() => { diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 0a120f9754083..46e9ffd38a449 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,11 +15,7 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # lib @@ -83,6 +79,7 @@ thiserror = "1" tokio = { version = "1", features = ["time"] } watchexec = "2.3.2" evm-disassembler.workspace = true +rustc-hash.workspace = true # doc server axum = { workspace = true, features = ["ws"] } @@ -99,9 +96,7 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.3", default-features = false, features = [ - "rustls", -] } +svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } @@ -113,11 +108,7 @@ rustls = [ "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots", ] -openssl = [ - "foundry-cli/openssl", - "reqwest/default-tls", - "foundry-wallets/openssl", -] +openssl = ["foundry-cli/openssl", "reqwest/default-tls", "foundry-wallets/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] [[bench]] diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 7acfa8fdf3466..e140b8436aaf5 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -26,6 +26,7 @@ use foundry_compilers::{ Artifact, Project, ProjectCompileOutput, }; use foundry_config::{Config, SolcReq}; +use rustc_hash::FxHashMap; use semver::Version; use std::{collections::HashMap, path::PathBuf, sync::mpsc::channel}; use yansi::Paint; @@ -155,8 +156,8 @@ impl CoverageArgs { let mut report = CoverageReport::default(); // Collect ASTs and sources - let mut versioned_asts: HashMap> = HashMap::new(); - let mut versioned_sources: HashMap> = HashMap::new(); + let mut versioned_asts: HashMap> = HashMap::new(); + let mut versioned_sources: HashMap> = HashMap::new(); for (path, mut source_file, version) in sources.into_sources_with_version() { report.add_source(version.clone(), source_file.id as usize, path.clone()); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 3b1a1a2071786..e8dba45a234c8 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -383,7 +383,7 @@ impl<'a> ContractRunner<'a> { err.stipend, None, err.state_changeset, - HashMap::new(), + Default::default(), ) } Err(EvmError::SkipError) => { From 37ada9673981053a739e557824544082989b9ed4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:15:26 +0100 Subject: [PATCH 0752/1963] chore: factor out common ic-pc code (#7396) --- crates/evm/core/src/ic.rs | 67 +++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index 7bb2179c5e9a4..9f679fc36e50f 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -14,25 +14,7 @@ pub struct PcIcMap { impl PcIcMap { /// Creates a new `PcIcMap` for the given code. pub fn new(spec: SpecId, code: &[u8]) -> Self { - let opcode_infos = spec_opcode_gas(spec); - let mut map = FxHashMap::default(); - - let mut i = 0; - let mut cumulative_push_size = 0; - while i < code.len() { - let op = code[i]; - map.insert(i, i - cumulative_push_size); - if opcode_infos[op as usize].is_push() { - // Skip the push bytes. - // - // For more context on the math, see: https://github.com/bluealloy/revm/blob/007b8807b5ad7705d3cacce4d92b89d880a83301/crates/revm/src/interpreter/contract.rs#L114-L115 - i += (op - opcode::PUSH1 + 1) as usize; - cumulative_push_size += (op - opcode::PUSH1 + 1) as usize; - } - i += 1; - } - - Self { inner: map } + Self { inner: make_map::(spec, code) } } /// Returns the instruction counter for the given program counter. @@ -51,25 +33,7 @@ pub struct IcPcMap { impl IcPcMap { /// Creates a new `IcPcMap` for the given code. pub fn new(spec: SpecId, code: &[u8]) -> Self { - let opcode_infos = spec_opcode_gas(spec); - let mut map = FxHashMap::default(); - - let mut i = 0; - let mut cumulative_push_size = 0; - while i < code.len() { - let op = code[i]; - map.insert(i - cumulative_push_size, i); - if opcode_infos[op as usize].is_push() { - // Skip the push bytes. - // - // For more context on the math, see: https://github.com/bluealloy/revm/blob/007b8807b5ad7705d3cacce4d92b89d880a83301/crates/revm/src/interpreter/contract.rs#L114-L115 - i += (op - opcode::PUSH1 + 1) as usize; - cumulative_push_size += (op - opcode::PUSH1 + 1) as usize; - } - i += 1; - } - - Self { inner: map } + Self { inner: make_map::(spec, code) } } /// Returns the program counter for the given instruction counter. @@ -77,3 +41,30 @@ impl IcPcMap { self.inner.get(&ic).copied() } } + +fn make_map(spec: SpecId, code: &[u8]) -> FxHashMap { + let opcode_infos = spec_opcode_gas(spec); + let mut map = FxHashMap::default(); + + let mut pc = 0; + let mut cumulative_push_size = 0; + while pc < code.len() { + let ic = pc - cumulative_push_size; + if PC_FIRST { + map.insert(pc, ic); + } else { + map.insert(ic, pc); + } + + let op = code[pc]; + if opcode_infos[op as usize].is_push() { + // Skip the push bytes. + let push_size = (op - opcode::PUSH0) as usize; + pc += push_size; + cumulative_push_size += push_size; + } + + pc += 1; + } + map +} From 545cd0bf4cc5979f8f97671012dce54440550181 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:51:22 +0100 Subject: [PATCH 0753/1963] perf: use ArrayVec for collecting push bytes (#7397) * perf: use ArrayVec for collecting push bytes * deps --- Cargo.lock | 2 ++ Cargo.toml | 1 + crates/evm/core/Cargo.toml | 1 + crates/evm/core/src/debug.rs | 22 ++++++++++---- crates/evm/evm/Cargo.toml | 1 + crates/evm/evm/src/inspectors/debugger.rs | 36 ++++++++++------------- 6 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ee659cab83f2..19a9bbbe1e683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3385,6 +3385,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-types", + "arrayvec", "const-hex", "eyre", "foundry-cheatcodes", @@ -3418,6 +3419,7 @@ dependencies = [ "alloy-providers", "alloy-rpc-types", "alloy-sol-types", + "arrayvec", "auto_impl", "const-hex", "derive_more", diff --git a/Cargo.toml b/Cargo.toml index 1831efc1c4537..0c39173402b9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,6 +186,7 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc +arrayvec = "0.7" base64 = "0.22" chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 5e01c91141f55..7e4ea3c218d26 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -37,6 +37,7 @@ revm = { workspace = true, default-features = false, features = [ ] } revm-inspectors.workspace = true +arrayvec.workspace = true auto_impl = "1" derive_more.workspace = true eyre = "0.6" diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 084d36b904cd8..70d94ff9760dd 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,5 +1,6 @@ use crate::opcodes; use alloy_primitives::{Address, Bytes, U256}; +use arrayvec::ArrayVec; use revm::interpreter::OpCode; use revm_inspectors::tracing::types::CallKind; use serde::{Deserialize, Serialize}; @@ -176,8 +177,10 @@ pub struct DebugStep { pub returndata: Bytes, /// Opcode to be executed pub instruction: Instruction, - /// Optional bytes that are being pushed onto the stack - pub push_bytes: Option>, + /// Optional bytes that are being pushed onto the stack. + /// Empty if the opcode is not a push or PUSH0. + #[serde(serialize_with = "hex::serialize", deserialize_with = "deserialize_arrayvec_hex")] + pub push_bytes: ArrayVec, /// The program counter at this step. /// /// Note: To map this step onto source code using a source map, you must convert the program @@ -195,7 +198,7 @@ impl Default for DebugStep { calldata: Default::default(), returndata: Default::default(), instruction: Instruction::OpCode(revm::interpreter::opcode::INVALID), - push_bytes: None, + push_bytes: Default::default(), pc: 0, total_gas_used: 0, } @@ -205,8 +208,8 @@ impl Default for DebugStep { impl DebugStep { /// Pretty print the step's opcode pub fn pretty_opcode(&self) -> String { - if let Some(push_bytes) = &self.push_bytes { - format!("{}(0x{})", self.instruction, hex::encode(push_bytes)) + if !self.push_bytes.is_empty() { + format!("{}(0x{})", self.instruction, hex::encode(&self.push_bytes)) } else { self.instruction.to_string() } @@ -266,3 +269,12 @@ impl Instruction { } } } + +fn deserialize_arrayvec_hex<'de, D: serde::Deserializer<'de>>( + deserializer: D, +) -> Result, D::Error> { + let bytes: Vec = hex::deserialize(deserializer)?; + let mut array = ArrayVec::new(); + array.try_extend_from_slice(&bytes).map_err(serde::de::Error::custom)?; + Ok(array) +} diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 08b1500b4a4e3..a1857b303d3a6 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -38,6 +38,7 @@ revm-inspectors.workspace = true itertools.workspace = true +arrayvec.workspace = true eyre = "0.6" hex.workspace = true parking_lot = "0.12" diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index 5ec952ac26cba..f6232bd475edd 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -1,4 +1,5 @@ use alloy_primitives::Address; +use arrayvec::ArrayVec; use foundry_common::{ErrorExt, SELECTOR_LEN}; use foundry_evm_core::{ backend::DatabaseExt, @@ -56,15 +57,16 @@ impl Inspector for Debugger { let opcode_info = &opcode_infos[op as usize]; // Extract the push bytes - let push_size = if opcode_info.is_push() { (op - opcode::PUSH1 + 1) as usize } else { 0 }; - let push_bytes = match push_size { - 0 => None, - n => { - let start = pc + 1; - let end = start + n; - Some(interp.contract.bytecode.bytecode()[start..end].to_vec()) - } - }; + let push_size = if opcode_info.is_push() { (op - opcode::PUSH0) as usize } else { 0 }; + let push_bytes = (push_size > 0).then(|| { + let start = pc + 1; + let end = start + push_size; + let slice = &interp.contract.bytecode.bytecode()[start..end]; + assert!(slice.len() <= 32); + let mut array = ArrayVec::new(); + array.try_extend_from_slice(slice).unwrap(); + array + }); let total_gas_used = gas_used( ecx.spec_id(), @@ -72,20 +74,12 @@ impl Inspector for Debugger { interp.gas.refunded() as u64, ); - // if the previous opcode does __not__ modify memory, we can reuse the memory of - // that step + // Reuse the memory from the previous step if the previous opcode did not modify it. let memory = self.arena.arena[self.head] .steps .last() - .and_then(|step| { - if !step.opcode_modifies_memory() { - // reuse the memory from the previous step, because its opcode did not modify - // memory - Some(step.memory.clone()) - } else { - None - } - }) + .filter(|step| !step.opcode_modifies_memory()) + .map(|step| step.memory.clone()) .unwrap_or_else(|| interp.shared_memory.context_memory().to_vec().into()); self.arena.arena[self.head].steps.push(DebugStep { @@ -95,7 +89,7 @@ impl Inspector for Debugger { calldata: interp.contract().input.clone(), returndata: interp.return_data_buffer.clone(), instruction: Instruction::OpCode(op), - push_bytes, + push_bytes: push_bytes.unwrap_or_default(), total_gas_used, }); } From 1001c6975906d7fb06f95d8179def04ad4cbd8f0 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Thu, 14 Mar 2024 13:40:46 +0100 Subject: [PATCH 0754/1963] chore: typos (#7403) --- crates/fmt/src/formatter.rs | 2 +- crates/forge/tests/it/fuzz.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 00beb4d8c656a..bf69651003f60 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -820,7 +820,7 @@ impl<'a, W: Write> Formatter<'a, W> { Ok(self.transact(fun)?.buffer) } - /// Turn a chunk and its surrounding comments into a a string + /// Turn a chunk and its surrounding comments into a string fn chunk_to_string(&mut self, chunk: &Chunk) -> Result { self.simulate_to_string(|fmt| fmt.write_chunk(chunk)) } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 9f59a7f42fb9c..47bc7745dff22 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -129,8 +129,8 @@ async fn test_persist_fuzz_failure() { } // record initial counterexample calldata - let intial_counterexample = get_failure_result!(); - let initial_calldata = match intial_counterexample { + let initial_counterexample = get_failure_result!(); + let initial_calldata = match initial_counterexample { Some(CounterExample::Single(counterexample)) => counterexample.calldata, _ => Bytes::new(), }; From 3fa02706ca732c994715ba42d923605692062375 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 14 Mar 2024 18:06:40 +0100 Subject: [PATCH 0755/1963] chore: set cancun block (#7404) --- crates/anvil/src/hardfork.rs | 15 ++++++--------- crates/anvil/tests/it/anvil_api.rs | 2 +- crates/anvil/tests/it/traces.rs | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index a5e92284cb511..8fabace321be5 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -44,10 +44,8 @@ impl Hardfork { Hardfork::ArrowGlacier => 13773000, Hardfork::GrayGlacier => 15050000, Hardfork::Paris => 15537394, - Hardfork::Shanghai | Hardfork::Latest => 17034870, - - // TODO: set block number after activation - Hardfork::Cancun => unreachable!(), + Hardfork::Shanghai => 17034870, + Hardfork::Cancun | Hardfork::Latest => 19426587, } } @@ -94,7 +92,7 @@ impl Hardfork { Hardfork::Paris => ForkId { hash: ForkHash([0x4f, 0xb8, 0xa8, 0x72]), next: 17034870 }, Hardfork::Shanghai | Hardfork::Latest => { // update `next` when another fork block num is known - ForkId { hash: ForkHash([0xc1, 0xfd, 0xf1, 0x81]), next: 0 } + ForkId { hash: ForkHash([0xc1, 0xfd, 0xf1, 0x81]), next: 19426587 } } Hardfork::Cancun => { // TODO: set fork hash once known @@ -152,10 +150,8 @@ impl From for SpecId { Hardfork::ArrowGlacier => SpecId::LONDON, Hardfork::GrayGlacier => SpecId::GRAY_GLACIER, Hardfork::Paris => SpecId::MERGE, - Hardfork::Shanghai | Hardfork::Latest => SpecId::SHANGHAI, - - // TODO: switch to latest after activation - Hardfork::Cancun => SpecId::CANCUN, + Hardfork::Shanghai => SpecId::SHANGHAI, + Hardfork::Cancun | Hardfork::Latest => SpecId::CANCUN, } } } @@ -182,6 +178,7 @@ impl> From for Hardfork { _i if num < 13_773_000 => Hardfork::London, _i if num < 15_050_000 => Hardfork::ArrowGlacier, _i if num < 17_034_870 => Hardfork::Paris, + _i if num < 19_426_587 => Hardfork::Shanghai, _ => Hardfork::Latest, } } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index e487033cc179f..91ba92d771548 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -441,7 +441,7 @@ async fn can_get_node_info() { current_block_number: U64([0]).to_alloy(), current_block_timestamp: 1, current_block_hash: block.hash.unwrap().to_alloy(), - hard_fork: SpecId::SHANGHAI, + hard_fork: SpecId::CANCUN, transaction_order: "fees".to_owned(), environment: NodeEnvironment { base_fee: U256::from_str("0x3b9aca00").unwrap().to_alloy(), diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index e7d42051b1a4f..309621ac5cf1f 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -3,7 +3,7 @@ use crate::{ utils::{ethers_http_provider, ethers_ws_provider}, }; use alloy_primitives::U256; -use anvil::{spawn, NodeConfig}; +use anvil::{spawn, Hardfork, NodeConfig}; use ethers::{ contract::ContractInstance, prelude::{ @@ -76,7 +76,7 @@ contract Contract { let contract = compiled.remove_first("Contract").unwrap(); let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); - let (_api, handle) = spawn(NodeConfig::test()).await; + let (_api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Shanghai))).await; let provider = ethers_ws_provider(&handle.ws_endpoint()); let wallets = handle.dev_wallets().collect::>().to_ethers(); let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); From 42da94276892f63afefd0dc743e862b058a4b4c2 Mon Sep 17 00:00:00 2001 From: christn Date: Fri, 15 Mar 2024 15:46:39 +0100 Subject: [PATCH 0756/1963] Bump evm-disassembler dependency to support Cancun opcodes (#7409) * Bump evm-disassembler dependency to support Cancun opcodes * bump lock --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19a9bbbe1e683..45d72746c5199 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2768,9 +2768,9 @@ dependencies = [ [[package]] name = "evm-disassembler" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6fc9c732a3210153e6aa26746f0abd8773dbf204c64ae3e824309b32b384c5" +checksum = "ded685d9f07315ff689ba56e7d84e6f1e782db19b531a46c34061a733bba7258" dependencies = [ "eyre", "hex", diff --git a/Cargo.toml b/Cargo.toml index 0c39173402b9c..108bbe333c071 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -191,7 +191,7 @@ base64 = "0.22" chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" -evm-disassembler = "0.4" +evm-disassembler = "0.5" eyre = "0.6" hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.12" From 63066ab3389557a81279d7899d5226ea902f2a1e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Mar 2024 11:06:22 +0100 Subject: [PATCH 0757/1963] chore(deps): weekly `cargo update` (#7416) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating async-trait v0.1.77 -> v0.1.78 Updating clap v4.5.2 -> v4.5.3 Updating clap_derive v4.5.0 -> v4.5.3 Updating color-eyre v0.6.2 -> v0.6.3 Updating figment v0.10.14 -> v0.10.15 Updating gix-trace v0.1.7 -> v0.1.8 Updating gix-utils v0.1.10 -> v0.1.11 Updating h2 v0.3.24 -> v0.3.25 (latest: v0.4.3) Adding heck v0.5.0 Updating new_debug_unreachable v1.0.4 -> v1.0.6 Updating syn v2.0.52 -> v2.0.53 Updating tokio-stream v0.1.14 -> v0.1.15 note: pass `--verbose` to see 182 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 140 ++++++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 45d72746c5199..0e3bf6070be02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -266,7 +266,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -341,13 +341,13 @@ dependencies = [ "alloy-json-abi", "const-hex", "dunce", - "heck", + "heck 0.4.1", "indexmap", "proc-macro-error", "proc-macro2", "quote", "serde_json", - "syn 2.0.52", + "syn 2.0.53", "syn-solidity", "tiny-keccak", ] @@ -845,7 +845,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -867,7 +867,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -878,13 +878,13 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -937,7 +937,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1461,9 +1461,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", "clap_derive", @@ -1505,14 +1505,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1622,9 +1622,9 @@ dependencies = [ [[package]] name = "color-eyre" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" dependencies = [ "backtrace", "color-spantrace", @@ -1963,7 +1963,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1974,7 +1974,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2035,7 +2035,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2056,7 +2056,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2066,7 +2066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2308,7 +2308,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2520,7 +2520,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.52", + "syn 2.0.53", "toml 0.8.11", "walkdir", ] @@ -2538,7 +2538,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2564,7 +2564,7 @@ dependencies = [ "serde", "serde_json", "strum 0.26.2", - "syn 2.0.52", + "syn 2.0.53", "tempfile", "thiserror", "tiny-keccak", @@ -2822,7 +2822,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2869,9 +2869,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.14" +version = "0.10.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6e5bc7bd59d60d0d45a6ccab6cf0f4ce28698fb4e81e750ddf229c9b824026" +checksum = "7270677e7067213e04f323b55084586195f18308cd7546cfac9f873344ccceb6" dependencies = [ "atomic", "parking_lot", @@ -3529,7 +3529,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3696,7 +3696,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3983,15 +3983,15 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" +checksum = "9b838b2db8f62c9447d483a4c28d251b67fee32741a82cb4d35e9eb4e9fdc5ab" [[package]] name = "gix-utils" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60157a15b9f14b11af1c6817ad7a93b10b50b4e5136d98a127c46a37ff16eeb6" +checksum = "0066432d4c277f9877f091279a597ea5331f68ca410efc874f0bdfb1cd348f92" dependencies = [ "fastrand", "unicode-normalization", @@ -4051,9 +4051,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ "bytes", "fnv", @@ -4142,6 +4142,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -4962,7 +4968,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5028,9 +5034,9 @@ dependencies = [ [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nibble_vec" @@ -5229,7 +5235,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5333,7 +5339,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5543,7 +5549,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5601,7 +5607,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5704,7 +5710,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5742,7 +5748,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5853,7 +5859,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -5948,7 +5954,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "version_check", "yansi 1.0.1", ] @@ -6964,7 +6970,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7018,7 +7024,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7064,7 +7070,7 @@ checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7357,11 +7363,11 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7370,11 +7376,11 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7455,9 +7461,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote", @@ -7473,7 +7479,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7595,7 +7601,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7717,7 +7723,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -7753,9 +7759,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -7951,7 +7957,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -8316,7 +8322,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-shared", ] @@ -8350,7 +8356,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8785,7 +8791,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -8805,7 +8811,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] From 42a9d349d6f950ffb9d45e2bb9495d4060d68ea7 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 17 Mar 2024 17:07:17 +0400 Subject: [PATCH 0758/1963] chore: fix race condition on test project initialization (#7415) * chore: fix race condition on test initialization * fix for windows * fmt --- crates/test-utils/src/util.rs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 6a6f15d0f0b15..ede7ca8c06227 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -13,9 +13,8 @@ use regex::Regex; use std::{ env, ffi::OsStr, - fs, - fs::File, - io::{BufWriter, IsTerminal, Write}, + fs::{self, File}, + io::{BufWriter, IsTerminal, Read, Seek, Write}, path::{Path, PathBuf}, process::{ChildStdin, Command, Output, Stdio}, sync::{ @@ -237,21 +236,30 @@ pub fn initialize(target: &Path) { // Release the read lock and acquire a write lock, initializing the lock file. _read = None; + let mut write = lock.write().unwrap(); - write.write_all(b"1").unwrap(); - // Initialize and build. - let (prj, mut cmd) = setup_forge("template", foundry_compilers::PathStyle::Dapptools); - eprintln!("- initializing template dir in {}", prj.root().display()); + let mut data = String::new(); + write.read_to_string(&mut data).unwrap(); + + if data != "1" { + write.set_len(0).unwrap(); + write.seek(std::io::SeekFrom::Start(0)).unwrap(); + write.write_all(b"1").unwrap(); - cmd.args(["init", "--force"]).assert_success(); - cmd.forge_fuse().args(["build", "--use", SOLC_VERSION]).assert_success(); + // Initialize and build. + let (prj, mut cmd) = setup_forge("template", foundry_compilers::PathStyle::Dapptools); + eprintln!("- initializing template dir in {}", prj.root().display()); - // Remove the existing template, if any. - let _ = fs::remove_dir_all(tpath); + cmd.args(["init", "--force"]).assert_success(); + cmd.forge_fuse().args(["build", "--use", SOLC_VERSION]).assert_success(); - // Copy the template to the global template path. - pretty_err(tpath, copy_dir(prj.root(), tpath)); + // Remove the existing template, if any. + let _ = fs::remove_dir_all(tpath); + + // Copy the template to the global template path. + pretty_err(tpath, copy_dir(prj.root(), tpath)); + } // Release the write lock and acquire a new read lock. drop(write); From f6863914cab448faabd3be11d092430b325b8812 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 18 Mar 2024 05:43:00 +0400 Subject: [PATCH 0759/1963] chore: fix test project initialization (#7418) fix initialization --- crates/test-utils/src/util.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index ede7ca8c06227..d392b953e6892 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -243,10 +243,6 @@ pub fn initialize(target: &Path) { write.read_to_string(&mut data).unwrap(); if data != "1" { - write.set_len(0).unwrap(); - write.seek(std::io::SeekFrom::Start(0)).unwrap(); - write.write_all(b"1").unwrap(); - // Initialize and build. let (prj, mut cmd) = setup_forge("template", foundry_compilers::PathStyle::Dapptools); eprintln!("- initializing template dir in {}", prj.root().display()); @@ -259,6 +255,11 @@ pub fn initialize(target: &Path) { // Copy the template to the global template path. pretty_err(tpath, copy_dir(prj.root(), tpath)); + + // Update lockfile to mark that template is initialized. + write.set_len(0).unwrap(); + write.seek(std::io::SeekFrom::Start(0)).unwrap(); + write.write_all(b"1").unwrap(); } // Release the write lock and acquire a new read lock. From db8ea58ba607075ce0f39bb975a38da6b4889ea1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Mar 2024 03:45:30 +0100 Subject: [PATCH 0760/1963] test: update fixtures (#7421) --- crates/forge/tests/cli/test_cmd.rs | 4 ++-- .../forge/tests/fixtures/can_test_repeatedly.stdout | 2 +- .../tests/fixtures/can_use_libs_in_multi_fork.stdout | 2 +- crates/forge/tests/fixtures/repro_6531.stdout | 12 +++++------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index f449a0ac0501a..5aad1848a477f 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -358,10 +358,10 @@ interface IERC20 { function name() external view returns (string memory); } -contract USDCCallingTest is Test { +contract USDTCallingTest is Test { function test() public { vm.createSelectFork(""); - IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48).name(); + IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7).name(); } } "# diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout index d792e809660ad..7095a50f0305c 100644 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ b/crates/forge/tests/fixtures/can_test_repeatedly.stdout @@ -2,7 +2,7 @@ No files changed, compilation skipped Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) -[PASS] test_Increment() (gas: 31225) +[PASS] test_Increment() (gas: 31325) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms Ran 1 test suite: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout index 87a5aa753715e..70c72887aaea4 100644 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout @@ -3,7 +3,7 @@ Solc 0.8.23 finished in 1.95s Compiler run successful! Ran 1 test for test/Contract.t.sol:ContractTest -[PASS] test() (gas: 70404) +[PASS] test() (gas: 70360) Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout index e8e474ba77338..01f282bf7cfd2 100644 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -2,16 +2,14 @@ Compiling 1 files with 0.8.23 Compiler run successful! -Ran 1 test for test/Contract.t.sol:USDCCallingTest -[PASS] test() (gas: 16821) +Ran 1 test for test/Contract.t.sol:USDTCallingTest +[PASS] test() (gas: 9559) Traces: - [16821] USDCCallingTest::test() + [9559] USDTCallingTest::test() ├─ [0] VM::createSelectFork("") │ └─ ← 0 - ├─ [10350] 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48::name() [staticcall] - │ ├─ [3061] 0x43506849D7C04F9138D1A2050bbF3A0c054402dd::name() [delegatecall] - │ │ └─ ← "USD Coin" - │ └─ ← "USD Coin" + ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] + │ └─ ← "Tether USD" └─ ← () Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s From a08a7da50b9fcaecb33bd25e927b6777bd768035 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 18 Mar 2024 12:06:28 +0100 Subject: [PATCH 0761/1963] fix: ignore forge-std artifacts in build --sizes (#7414) --- crates/common/src/compile.rs | 12 +++++++++++- crates/forge/tests/cli/build.rs | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 3f159f069b0fa..8272dece32ac3 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -245,7 +245,16 @@ impl ProjectCompiler { } let mut size_report = SizeReport { contracts: BTreeMap::new() }; - let artifacts: BTreeMap<_, _> = output.artifacts().collect(); + + let artifacts: BTreeMap<_, _> = output + .artifact_ids() + .filter(|(id, _)| { + // filter out forge-std specific contracts + !id.source.to_string_lossy().contains("/forge-std/src/") + }) + .map(|(id, artifact)| (id.name, artifact)) + .collect(); + for (name, artifact) in artifacts { let size = deployed_contract_size(artifact).unwrap_or_default(); @@ -381,6 +390,7 @@ impl Display for SizeReport { Cell::new("Margin (kB)").add_attribute(Attribute::Bold).fg(Color::Blue), ]); + // filters out non dev contracts (Test or Script) let contracts = self.contracts.iter().filter(|(_, c)| !c.is_dev_contract && c.size > 0); for (name, contract) in contracts { let margin = CONTRACT_SIZE_LIMIT as isize - contract.size as isize; diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 0002ec14529d6..668e4be5e1deb 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -31,3 +31,12 @@ forgetest_init!(exact_build_output, |prj, cmd| { let stdout = cmd.stdout_lossy(); assert!(stdout.contains("Compiling"), "\n{stdout}"); }); + +// tests build output is as expected +forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { + cmd.args(["build", "--sizes"]); + let stdout = cmd.stdout_lossy(); + assert!(!stdout.contains("console"), "\n{stdout}"); + assert!(!stdout.contains("std"), "\n{stdout}"); + assert!(stdout.contains("Counter"), "\n{stdout}"); +}); From 3865e57a3ba6b8ff3650d45bdd39fbd64e16819a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 18 Mar 2024 16:22:46 +0100 Subject: [PATCH 0762/1963] chore: solc 0.8.25 (#7424) * chore: solc 0.8.25 * replace ethers-solc --- Cargo.lock | 66 +++++++++++++++--------------- Cargo.toml | 3 +- crates/anvil/Cargo.toml | 4 +- crates/anvil/tests/it/ganache.rs | 13 +++--- crates/anvil/tests/it/geth.rs | 11 +++-- crates/anvil/tests/it/otterscan.rs | 20 +++++---- crates/anvil/tests/it/revert.rs | 2 +- crates/anvil/tests/it/traces.rs | 14 ++++--- crates/anvil/tests/it/utils.rs | 53 ++++++++++++++++++++++++ crates/forge/Cargo.toml | 2 +- crates/forge/tests/cli/svm.rs | 2 +- 11 files changed, 128 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e3bf6070be02..dea2c7c4d0ab8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -528,6 +528,7 @@ dependencies = [ "alloy-consensus", "alloy-dyn-abi", "alloy-genesis", + "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-providers", @@ -553,12 +554,12 @@ dependencies = [ "ethereum-forkid", "ethers", "ethers-core", - "ethers-solc", "eyre", "fdlimit", "flate2", "foundry-cli", "foundry-common", + "foundry-compilers", "foundry-config", "foundry-evm", "futures", @@ -2691,25 +2692,19 @@ dependencies = [ "dirs 5.0.1", "dunce", "ethers-core", - "fs_extra", - "futures-util", "glob", "home", "md-5 0.10.6", "num_cpus", "once_cell", "path-slash", - "rand 0.8.5", "rayon", "regex", "semver 1.0.22", "serde", "serde_json", - "sha2 0.10.8", "solang-parser", - "svm-rs", - "svm-rs-builds 0.2.3", - "tempfile", + "svm-rs 0.3.6", "thiserror", "tiny-keccak", "tokio", @@ -3008,7 +3003,7 @@ dependencies = [ "similar", "solang-parser", "strum 0.26.2", - "svm-rs", + "svm-rs 0.4.0", "tempfile", "thiserror", "tokio", @@ -3292,9 +3287,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cc03b422b28e49d6dd61b8442bcee16c22edd975be1764de5a39c4037ecb478" +checksum = "079ada1a2093e0fec67caa15ccf018a2d1b5747c16ba1c11a28df53530eb1a5f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3317,8 +3312,8 @@ dependencies = [ "serde_json", "sha2 0.10.8", "solang-parser", - "svm-rs", - "svm-rs-builds 0.3.5", + "svm-rs 0.4.0", + "svm-rs-builds", "tempfile", "thiserror", "tokio", @@ -3580,13 +3575,13 @@ dependencies = [ ] [[package]] -name = "fs2" -version = "0.4.3" +name = "fs4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +checksum = "29f9df8a11882c4e3335eb2d18a0137c505d9ca927470b0cac9c6f0ae07d28f7" dependencies = [ - "libc", - "winapi", + "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -7404,13 +7399,13 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "svm-rs" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" +checksum = "f9b34cc1af809be8d20575428638da2c6a1eb12b1da06dae79c1b82a4ddf83ac" dependencies = [ + "const-hex", "dirs 5.0.1", - "fs2", - "hex", + "fs4", "once_cell", "reqwest", "semver 1.0.22", @@ -7423,29 +7418,36 @@ dependencies = [ ] [[package]] -name = "svm-rs-builds" -version = "0.2.3" +name = "svm-rs" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa64b5e8eecd3a8af7cfc311e29db31a268a62d5953233d3e8243ec77a71c4e3" +checksum = "cde88464d5718a437e9f6be54cf3771837a111bed305c4f4f9d3497471e96249" dependencies = [ - "build_const", - "hex", + "const-hex", + "dirs 5.0.1", + "fs4", + "once_cell", + "reqwest", "semver 1.0.22", + "serde", "serde_json", - "svm-rs", + "sha2 0.10.8", + "thiserror", + "url", + "zip", ] [[package]] name = "svm-rs-builds" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8d3c94c4d3337336f58493471b98d712c267c66977b0fbe48efd6cbf69ffd0" +checksum = "2ff43323737122457c266fe28a454635edd9cd15f8b6277251eb4703ef54f829" dependencies = [ "build_const", - "hex", + "const-hex", "semver 1.0.22", "serde_json", - "svm-rs", + "svm-rs 0.4.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 108bbe333c071..8601758716798 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,7 +138,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } -foundry-compilers = { version = "0.3.9", default-features = false } +foundry-compilers = { version = "0.3.13", default-features = false } ## revm # no default features to avoid c-kzg @@ -156,7 +156,6 @@ ethers-contract-abigen = { version = "2.0.14", default-features = false } ethers-providers = { version = "2.0.14", default-features = false } ethers-signers = { version = "2.0.14", default-features = false } ethers-middleware = { version = "2.0.14", default-features = false } -ethers-solc = { version = "2.0.14", default-features = false } ## alloy alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 430c9e906bdf3..18682e5d23c48 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -95,9 +95,11 @@ clap_complete_fig = "4" ethereum-forkid = "0.12" [dev-dependencies] +alloy-json-abi.workspace = true ethers = { workspace = true, features = ["abigen"] } ethers-core = { workspace = true, features = ["optimism"] } -ethers-solc = { workspace = true, features = ["project-util", "full"] } +foundry-compilers = { workspace = true, features = ["project-util", "full"] } + pretty_assertions = "1.3.0" tokio = { version = "1", features = ["full"] } crc = "3.0.1" diff --git a/crates/anvil/tests/it/ganache.rs b/crates/anvil/tests/it/ganache.rs index 3ea0e84f508fc..b95b55433ba8b 100644 --- a/crates/anvil/tests/it/ganache.rs +++ b/crates/anvil/tests/it/ganache.rs @@ -1,6 +1,9 @@ //! tests against local ganache for local debug purposes #![allow(unused)] -use crate::init_tracing; +use crate::{ + init_tracing, + utils::{ContractInstanceCompat, DeploymentTxFactoryCompat}, +}; use ethers::{ abi::Address, contract::{Contract, ContractFactory, ContractInstance}, @@ -11,7 +14,7 @@ use ethers::{ types::{BlockNumber, U256}, utils::hex, }; -use ethers_solc::{project_util::TempProject, Artifact}; +use foundry_compilers::{project_util::TempProject, Artifact}; use std::sync::Arc; // the mnemonic used to start the local ganache instance @@ -115,7 +118,7 @@ contract Contract { let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); - let factory = ContractFactory::new(abi.unwrap(), bytecode.unwrap(), Arc::clone(&client)); + let factory = ContractFactory::new_compat(abi.unwrap(), bytecode.unwrap(), Arc::clone(&client)); let contract = factory.deploy(()).unwrap().legacy().send().await; contract.unwrap_err(); } @@ -153,13 +156,13 @@ contract Contract { let client = Arc::new(http_client()); // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); let contract = factory.deploy(()).unwrap().legacy().send().await.unwrap(); let provider = SignerMiddleware::new( Provider::::try_from("http://127.0.0.1:8545").unwrap(), ganache_wallet2(), ); - let contract = ContractInstance::new(contract.address(), abi.unwrap(), provider); + let contract = ContractInstance::new_compat(contract.address(), abi.unwrap(), provider); let resp = contract.method::<_, U256>("getSecret", ()).unwrap().legacy().call().await; resp.unwrap_err(); diff --git a/crates/anvil/tests/it/geth.rs b/crates/anvil/tests/it/geth.rs index 31429d0bd4167..e1c9bc7b88401 100644 --- a/crates/anvil/tests/it/geth.rs +++ b/crates/anvil/tests/it/geth.rs @@ -1,6 +1,9 @@ //! tests against local geth for local debug purposes -use crate::abi::VENDING_MACHINE_CONTRACT; +use crate::{ + abi::VENDING_MACHINE_CONTRACT, + utils::{ContractInstanceCompat, DeploymentTxFactoryCompat}, +}; use ethers::{ abi::Address, contract::{Contract, ContractFactory}, @@ -9,7 +12,7 @@ use ethers::{ types::U256, utils::WEI_IN_ETHER, }; -use ethers_solc::{project_util::TempProject, Artifact}; +use foundry_compilers::{project_util::TempProject, Artifact}; use futures::StreamExt; use std::sync::Arc; use tokio::time::timeout; @@ -52,7 +55,7 @@ async fn test_geth_revert_transaction() { // deploy successfully let factory = - ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), Arc::clone(&client)); + ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), Arc::clone(&client)); let mut tx = factory.deploy(()).unwrap().tx; tx.set_from(account); @@ -60,7 +63,7 @@ async fn test_geth_revert_transaction() { let resp = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let contract = - Contract::>::new(resp.contract_address.unwrap(), abi.unwrap(), client); + Contract::>::new_compat(resp.contract_address.unwrap(), abi.unwrap(), client); let ten = WEI_IN_ETHER.saturating_mul(10u64.into()); let call = contract.method::<_, ()>("buyRevert", ten).unwrap().value(ten).from(account); diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 8dca5f7a2e251..6bbd987a84763 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -1,7 +1,9 @@ //! tests for otterscan endpoints use crate::{ abi::MulticallContract, - utils::{ethers_http_provider, ethers_ws_provider}, + utils::{ + ethers_http_provider, ethers_ws_provider, ContractInstanceCompat, DeploymentTxFactoryCompat, + }, }; use alloy_primitives::U256 as rU256; use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions}; @@ -19,8 +21,8 @@ use ethers::{ types::{Bytes, TransactionRequest}, utils::get_contract_address, }; -use ethers_solc::{project_util::TempProject, Artifact}; use foundry_common::types::{ToAlloy, ToEthers}; +use foundry_compilers::{project_util::TempProject, Artifact}; use std::{collections::VecDeque, str::FromStr, sync::Arc}; #[tokio::test(flavor = "multi_thread")] @@ -136,10 +138,10 @@ contract Contract { let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); let contract = factory.deploy(()).unwrap().send().await.unwrap(); - let contract = ContractInstance::new( + let contract = ContractInstance::new_compat( contract.address(), abi.unwrap(), SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), @@ -194,10 +196,10 @@ contract Contract { let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); let contract = factory.deploy(()).unwrap().send().await.unwrap(); - let contract = ContractInstance::new( + let contract = ContractInstance::new_compat( contract.address(), abi.unwrap(), SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), @@ -307,10 +309,10 @@ contract Contract { let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); let contract = factory.deploy(()).unwrap().send().await.unwrap(); - let contract = ContractInstance::new( + let contract = ContractInstance::new_compat( contract.address(), abi.unwrap(), SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), @@ -397,7 +399,7 @@ contract Contract { let client = Arc::new(SignerMiddleware::new(provider, wallet)); // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); let contract = factory.deploy(()).unwrap().send().await.unwrap(); let call = contract.method::<_, ()>("trigger_revert", ()).unwrap().gas(150_000u64); diff --git a/crates/anvil/tests/it/revert.rs b/crates/anvil/tests/it/revert.rs index 45da5eb2ef63e..6ba4a67f7ec17 100644 --- a/crates/anvil/tests/it/revert.rs +++ b/crates/anvil/tests/it/revert.rs @@ -6,7 +6,7 @@ use ethers::{ types::U256, utils::WEI_IN_ETHER, }; -use ethers_solc::{project_util::TempProject, Artifact}; +use foundry_compilers::{project_util::TempProject, Artifact}; use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 309621ac5cf1f..8b506f3cdb0ce 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,6 +1,8 @@ use crate::{ fork::fork_config, - utils::{ethers_http_provider, ethers_ws_provider}, + utils::{ + ethers_http_provider, ethers_ws_provider, ContractInstanceCompat, DeploymentTxFactoryCompat, + }, }; use alloy_primitives::U256; use anvil::{spawn, Hardfork, NodeConfig}; @@ -13,8 +15,8 @@ use ethers::{ types::{ActionType, Address, GethDebugTracingCallOptions, Trace}, utils::hex, }; -use ethers_solc::{project_util::TempProject, Artifact}; use foundry_common::types::{ToAlloy, ToEthers}; +use foundry_compilers::{project_util::TempProject, Artifact}; use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] @@ -82,10 +84,10 @@ contract Contract { let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); let contract = factory.deploy(()).unwrap().send().await.unwrap(); - let contract = ContractInstance::new( + let contract = ContractInstance::new_compat( contract.address(), abi.unwrap(), SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), @@ -132,10 +134,10 @@ contract Contract { let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); + let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); let contract = factory.deploy(()).unwrap().send().await.unwrap(); - let contract = ContractInstance::new( + let contract = ContractInstance::new_compat( contract.address(), abi.unwrap(), SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), diff --git a/crates/anvil/tests/it/utils.rs b/crates/anvil/tests/it/utils.rs index 7fdd90823a3db..9aa0770949dc4 100644 --- a/crates/anvil/tests/it/utils.rs +++ b/crates/anvil/tests/it/utils.rs @@ -1,8 +1,14 @@ +use alloy_json_abi::JsonAbi; +use alloy_primitives::Bytes; use ethers::{ addressbook::contract, + contract::ContractInstance, + middleware::Middleware, + prelude::DeploymentTxFactory, types::{Address, Chain}, }; use foundry_common::provider::ethers::{ProviderBuilder, RetryProvider}; +use std::borrow::Borrow; /// Returns a set of various contract addresses pub fn contract_addresses(chain: Chain) -> Vec

{ @@ -29,3 +35,50 @@ pub fn ethers_ws_provider(ws_endpoint: &str) -> RetryProvider { pub fn ethers_ipc_provider(ipc_endpoint: Option) -> Option { ProviderBuilder::new(&ipc_endpoint?).build().ok() } + +/// Temporary helper trait for compatibility with ethers +pub trait ContractInstanceCompat +where + B: Borrow, + M: Middleware, +{ + fn new_compat(address: Address, abi: JsonAbi, client: B) -> Self; +} + +impl ContractInstanceCompat for ContractInstance +where + B: Borrow, + M: Middleware, +{ + fn new_compat(address: Address, abi: JsonAbi, client: B) -> Self { + let json = serde_json::to_string(&abi).unwrap(); + ContractInstance::new( + address, + serde_json::from_str::(&json).unwrap(), + client, + ) + } +} + +pub trait DeploymentTxFactoryCompat +where + B: Borrow + Clone, + M: Middleware, +{ + fn new_compat(abi: JsonAbi, bytecode: Bytes, client: B) -> Self; +} + +impl DeploymentTxFactoryCompat for DeploymentTxFactory +where + B: Borrow + Clone, + M: Middleware, +{ + fn new_compat(abi: JsonAbi, bytecode: Bytes, client: B) -> Self { + let json = serde_json::to_string(&abi).unwrap(); + DeploymentTxFactory::new( + serde_json::from_str::(&json).unwrap(), + bytecode.as_ref().to_vec().into(), + client, + ) + } +} diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 46e9ffd38a449..84abd46373e2a 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -96,7 +96,7 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.3", default-features = false, features = ["rustls"] } +svm = { package = "svm-rs", version = "0.4", default-features = false, features = ["rustls"] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 431a36a1c859f..cbdd56f9d787e 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -11,7 +11,7 @@ use svm::Platform; /// 3. svm bumped in foundry-compilers /// 4. foundry-compilers update with any breaking changes /// 5. upgrade the `LATEST_SOLC` -const LATEST_SOLC: Version = Version::new(0, 8, 24); +const LATEST_SOLC: Version = Version::new(0, 8, 25); macro_rules! ensure_svm_releases { ($($test:ident => $platform:ident),* $(,)?) => {$( From 71ad565051ead9bd2a11cbaa6a86b971b9efe6a6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Mar 2024 18:33:09 +0100 Subject: [PATCH 0763/1963] chore: don't create a backend unnecessarily in ensure_success (#7429) * chore: don't create a backend unnecessarily in ensure_success * chore: cow it up --- crates/evm/evm/src/executors/fuzz/mod.rs | 19 +++++---- .../evm/evm/src/executors/invariant/error.rs | 4 +- .../evm/evm/src/executors/invariant/funcs.rs | 15 ++++--- crates/evm/evm/src/executors/invariant/mod.rs | 13 +++--- crates/evm/evm/src/executors/mod.rs | 41 ++++++++++--------- crates/evm/fuzz/src/error.rs | 2 - crates/forge/src/runner.rs | 3 +- 7 files changed, 48 insertions(+), 49 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index ec980c01ae3c1..dfb7b6c6050da 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -18,7 +18,7 @@ use foundry_evm_fuzz::{ }; use foundry_evm_traces::CallTraceArena; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; -use std::cell::RefCell; +use std::{borrow::Cow, cell::RefCell}; mod types; pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; @@ -208,19 +208,16 @@ impl FuzzedExecutor { should_fail: bool, calldata: alloy_primitives::Bytes, ) -> Result { - let call = self + let mut call = self .executor .call_raw(self.sender, address, calldata.clone(), U256::ZERO) .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; - let state_changeset = call - .state_changeset - .as_ref() - .ok_or_else(|| TestCaseError::fail(FuzzError::EmptyChangeset))?; + let state_changeset = call.state_changeset.take().unwrap(); // Build fuzzer state collect_state_from_call( &call.logs, - state_changeset, + &state_changeset, state.clone(), &self.config.dictionary, ); @@ -235,8 +232,12 @@ impl FuzzedExecutor { .as_ref() .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); - let success = - self.executor.is_raw_call_success(address, state_changeset.clone(), &call, should_fail); + let success = self.executor.is_raw_call_success( + address, + Cow::Owned(state_changeset), + &call, + should_fail, + ); if success { Ok(FuzzOutcome::Case(CaseOutcome { diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index da29e657e0ef2..47ebc877687f9 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -13,7 +13,7 @@ use proptest::test_runner::TestError; use rand::{seq, thread_rng, Rng}; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use revm::primitives::U256; -use std::sync::Arc; +use std::{borrow::Cow, sync::Arc}; /// Stores information about failures and reverts of the invariant tests. #[derive(Clone, Default)] @@ -244,7 +244,7 @@ impl FailedInvariantCaseData { .expect("bad call to evm"); let is_success = executor.is_raw_call_success( self.addr, - call_result.state_changeset.take().unwrap(), + Cow::Owned(call_result.state_changeset.take().unwrap()), &call_result, false, ); diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index 237b4dad84ec5..7f4694cdb0cb0 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -9,6 +9,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::invariant::{BasicTxDetails, InvariantContract}; use foundry_evm_traces::{load_contracts, TraceKind, Traces}; use revm::primitives::U256; +use std::borrow::Cow; /// Given the executor state, asserts that no invariant has been broken. Otherwise, it fills the /// external `invariant_failures.failed_invariant` map and returns a generic error. @@ -39,14 +40,12 @@ pub fn assert_invariants( ) .expect("EVM error"); - // This will panic and get caught by the executor - let is_err = call_result.reverted || - !executor.is_raw_call_success( - invariant_contract.address, - call_result.state_changeset.take().expect("we should have a state changeset"), - &call_result, - false, - ); + let is_err = !executor.is_raw_call_success( + invariant_contract.address, + Cow::Owned(call_result.state_changeset.take().unwrap()), + &call_result, + false, + ); if is_err { // We only care about invariants which we haven't broken yet. if invariant_failures.error.is_none() { diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 591fa7cf444df..00877a00dc54e 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -30,7 +30,7 @@ use proptest::{ test_runner::{TestCaseError, TestRunner}, }; use revm::{primitives::HashMap, DatabaseCommit}; -use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; +use std::{borrow::Cow, cell::RefCell, collections::BTreeMap, sync::Arc}; mod error; pub use error::{InvariantFailures, InvariantFuzzError, InvariantFuzzTestResult}; @@ -236,7 +236,7 @@ impl<'a> InvariantExecutor<'a> { &inputs, &mut failures.borrow_mut(), &targeted_contracts, - state_changeset, + &state_changeset, self.config.fail_on_revert, self.config.shrink_sequence, self.config.shrink_run_limit, @@ -772,7 +772,7 @@ fn can_continue( calldata: &[BasicTxDetails], failures: &mut InvariantFailures, targeted_contracts: &FuzzRunIdentifiedContracts, - state_changeset: StateChangeset, + state_changeset: &StateChangeset, fail_on_revert: bool, shrink_sequence: bool, shrink_run_limit: usize, @@ -781,10 +781,9 @@ fn can_continue( let mut call_results = None; // Detect handler assertion failures first. - let handlers_failed = targeted_contracts - .lock() - .iter() - .any(|contract| !executor.is_success(*contract.0, false, state_changeset.clone(), false)); + let handlers_failed = targeted_contracts.lock().iter().any(|contract| { + !executor.is_success(*contract.0, false, Cow::Borrowed(state_changeset), false) + }); // Assert invariants IFF the call did not revert and the handlers did not fail. if !call_result.reverted && !handlers_failed { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 469d6b6e4a016..51048002d49a4 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -32,7 +32,7 @@ use revm::{ SpecId, TransactTo, TxEnv, }, }; -use std::collections::HashMap; +use std::{borrow::Cow, collections::HashMap}; mod builder; pub use builder::ExecutorBuilder; @@ -197,7 +197,7 @@ impl Executor { match res.state_changeset.as_ref() { Some(changeset) => { let success = self - .ensure_success(to, res.reverted, changeset.clone(), false) + .ensure_success(to, res.reverted, Cow::Borrowed(changeset), false) .map_err(|err| EvmError::Eyre(eyre::eyre!(err.to_string())))?; if success { Ok(res) @@ -472,7 +472,7 @@ impl Executor { &self, address: Address, reverted: bool, - state_changeset: StateChangeset, + state_changeset: Cow<'_, StateChangeset>, should_fail: bool, ) -> bool { self.ensure_success(address, reverted, state_changeset, should_fail).unwrap_or_default() @@ -496,7 +496,7 @@ impl Executor { pub fn is_raw_call_success( &self, address: Address, - state_changeset: StateChangeset, + state_changeset: Cow<'_, StateChangeset>, call_result: &RawCallResult, should_fail: bool, ) -> bool { @@ -511,7 +511,7 @@ impl Executor { &self, address: Address, reverted: bool, - state_changeset: StateChangeset, + state_changeset: Cow<'_, StateChangeset>, should_fail: bool, ) -> Result { if self.backend.has_snapshot_failure() { @@ -519,23 +519,24 @@ impl Executor { return Ok(should_fail) } - // Construct a new VM with the state changeset - let mut backend = self.backend.clone_empty(); - - // we only clone the test contract and cheatcode accounts, that's all we need to evaluate - // success - for addr in [address, CHEATCODE_ADDRESS] { - let acc = self.backend.basic_ref(addr)?.unwrap_or_default(); - backend.insert_account_info(addr, acc); - } - - // If this test failed any asserts, then this changeset will contain changes `false -> true` - // for the contract's `failed` variable and the `globalFailure` flag in the state of the - // cheatcode address which are both read when we call `"failed()(bool)"` in the next step - backend.commit(state_changeset); - let mut success = !reverted; if success { + // Construct a new bare-bones backend to evaluate success. + let mut backend = self.backend.clone_empty(); + + // We only clone the test contract and cheatcode accounts, + // that's all we need to evaluate success. + for addr in [address, CHEATCODE_ADDRESS] { + let acc = self.backend.basic_ref(addr)?.unwrap_or_default(); + backend.insert_account_info(addr, acc); + } + + // If this test failed any asserts, then this changeset will contain changes + // `false -> true` for the contract's `failed` variable and the `globalFailure` flag + // in the state of the cheatcode address, + // which are both read when we call `"failed()(bool)"` in the next step. + backend.commit(state_changeset.into_owned()); + // Check if a DSTest assertion failed let executor = Executor::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); diff --git a/crates/evm/fuzz/src/error.rs b/crates/evm/fuzz/src/error.rs index 145afa5e72743..1371f49692adf 100644 --- a/crates/evm/fuzz/src/error.rs +++ b/crates/evm/fuzz/src/error.rs @@ -8,8 +8,6 @@ pub enum FuzzError { UnknownContract, #[error("Failed contract call")] FailedContractCall, - #[error("Empty state changeset")] - EmptyChangeset, #[error("`vm.assume` reject")] AssumeReject, #[error("The `vm.assume` cheatcode rejected too many inputs ({0} allowed)")] diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index e8dba45a234c8..9ee3cf6897a93 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -28,6 +28,7 @@ use foundry_evm::{ use proptest::test_runner::TestRunner; use rayon::prelude::*; use std::{ + borrow::Cow, collections::{BTreeMap, HashMap}, time::Instant, }; @@ -415,7 +416,7 @@ impl<'a> ContractRunner<'a> { let success = executor.is_success( setup.address, reverted, - state_changeset.expect("we should have a state changeset"), + Cow::Owned(state_changeset.unwrap()), should_fail, ); From dfefc0fff0304bfb00b568069fa6c899df8498af Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:54:29 +0100 Subject: [PATCH 0764/1963] feat(cast): print config in create2 (#7427) --- crates/cast/bin/cmd/create2.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 4494d5d68e18f..dae91c6422911 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -135,14 +135,12 @@ impl Create2Args { let regex = RegexSetBuilder::new(regexs).case_insensitive(!case_sensitive).build()?; let init_code_hash = if let Some(init_code_hash) = init_code_hash { - let mut hash: [u8; 32] = [0; 32]; - hex::decode_to_slice(init_code_hash, &mut hash)?; - hash.into() + hex::FromHex::from_hex(init_code_hash) } else if let Some(init_code) = init_code { - keccak256(hex::decode(init_code)?) + hex::decode(init_code).map(keccak256) } else { unreachable!(); - }; + }?; let mut n_threads = std::thread::available_parallelism().map_or(1, |n| n.get()); if let Some(jobs) = jobs { @@ -168,7 +166,11 @@ impl Create2Args { rng.fill_bytes(remaining); } - println!("Starting to generate deterministic contract address..."); + println!("Configuration:"); + println!("Init code hash: {init_code_hash}"); + println!("Regex patterns: {:?}", regex.patterns()); + println!(); + println!("Starting to generate deterministic contract address with {n_threads} threads..."); let mut handles = Vec::with_capacity(n_threads); let found = Arc::new(AtomicBool::new(false)); let timer = Instant::now(); @@ -201,7 +203,7 @@ impl Create2Args { // Calculate the `CREATE2` address. #[allow(clippy::needless_borrows_for_generic_args)] - let addr = deployer.create2(&salt.0, init_code_hash); + let addr = deployer.create2(&salt.0, &init_code_hash); // Check if the regex matches the calculated address' checksum. let _ = addr.to_checksum_raw(&mut checksum, None); @@ -211,7 +213,7 @@ impl Create2Args { if regex.matches(s).into_iter().count() == regex_len { // Notify other threads that we found a result. found.store(true, Ordering::Relaxed); - break Some((salt.0, addr)); + break Some((addr, salt.0)); } // Increment the salt for the next iteration. @@ -221,15 +223,11 @@ impl Create2Args { } let results = handles.into_iter().filter_map(|h| h.join().unwrap()).collect::>(); - println!("Successfully found contract address(es) in {:?}", timer.elapsed()); - for (i, (salt, address)) in results.iter().enumerate() { - if i > 0 { - println!("---"); - } - println!("Address: {address}\nSalt: {salt} ({})", U256::from_be_bytes(salt.0)); - } + let (address, salt) = results.into_iter().next().unwrap(); + println!("Successfully found contract address in {:?}", timer.elapsed()); + println!("Address: {address}"); + println!("Salt: {salt} ({})", U256::from_be_bytes(salt.0)); - let (salt, address) = results.into_iter().next().unwrap(); Ok(Create2Output { address, salt }) } } From 04fca21441a90301f77daae5f54b40c3dfc220a5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:49:36 +0100 Subject: [PATCH 0765/1963] refactor(evm): executor API, merge evm result types (#7422) * refactor(evm): executor API, merge evm result types * chore: MSRV * fix: persist cheatcode state * log * fix: setup revert --- Cargo.toml | 2 +- clippy.toml | 2 +- crates/cli/src/utils/cmd.rs | 7 +- crates/common/src/abi.rs | 35 -- crates/config/src/macros.rs | 18 +- crates/evm/evm/src/executors/invariant/mod.rs | 263 ++++------ crates/evm/evm/src/executors/mod.rs | 456 ++++++++---------- crates/forge/src/result.rs | 6 +- crates/forge/src/runner.rs | 87 ++-- crates/script/src/runner.rs | 48 +- 10 files changed, 381 insertions(+), 543 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8601758716798..54364afa67486 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.75" # Remember to update clippy.toml as well +rust-version = "1.76" # Remember to update clippy.toml as well authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" diff --git a/clippy.toml b/clippy.toml index cc4ad18b1872b..472818efed9bc 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.75" +msrv = "1.76" diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 1ea54d3f6413e..e58fd937d1360 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -13,7 +13,7 @@ use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, use foundry_debugger::Debugger; use foundry_evm::{ debug::DebugArena, - executors::{DeployResult, EvmError, ExecutionErr, RawCallResult}, + executors::{DeployResult, EvmError, RawCallResult}, opts::EvmOpts, traces::{ identifier::{EtherscanIdentifier, SignaturesIdentifier}, @@ -339,8 +339,7 @@ impl From for TraceResult { impl From for TraceResult { fn from(result: DeployResult) -> Self { - let DeployResult { gas_used, traces, debug, .. } = result; - + let RawCallResult { gas_used, traces, debug, .. } = result.raw; Self { success: true, traces: vec![(TraceKind::Execution, traces.expect("traces is None"))], @@ -356,7 +355,7 @@ impl TryFrom for TraceResult { fn try_from(err: EvmError) -> Result { match err { EvmError::Execution(err) => { - let ExecutionErr { reverted, gas_used, traces, debug: run_debug, .. } = *err; + let RawCallResult { reverted, gas_used, traces, debug: run_debug, .. } = err.raw; Ok(TraceResult { success: !reverted, traces: vec![(TraceKind::Execution, traces.expect("traces is None"))], diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 66a7c98910e23..b08620d888d16 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -68,41 +68,6 @@ pub fn abi_decode_calldata( Ok(res) } -/// Helper trait for converting types to Functions. Helpful for allowing the `call` -/// function on the EVM to be generic over `String`, `&str` and `Function`. -pub trait IntoFunction { - /// Consumes self and produces a function - /// - /// # Panics - /// - /// This function does not return a Result, so it is expected that the consumer - /// uses it correctly so that it does not panic. - fn into(self) -> Function; -} - -impl IntoFunction for Function { - fn into(self) -> Function { - self - } -} - -impl IntoFunction for String { - #[track_caller] - fn into(self) -> Function { - IntoFunction::into(self.as_str()) - } -} - -impl<'a> IntoFunction for &'a str { - #[track_caller] - fn into(self) -> Function { - match get_func(self) { - Ok(func) => func, - Err(e) => panic!("could not parse function: {e}"), - } - } -} - /// Given a function signature string, it tries to parse it as a `Function` pub fn get_func(sig: &str) -> Result { Function::parse(sig).wrap_err("could not parse function signature") diff --git a/crates/config/src/macros.rs b/crates/config/src/macros.rs index 95b111bdb9911..b84876b8e571f 100644 --- a/crates/config/src/macros.rs +++ b/crates/config/src/macros.rs @@ -59,12 +59,10 @@ macro_rules! impl_figment_convert { ($name:ty) => { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { - if let Some(root) = args.root.clone() { - $crate::Config::figment_with_root(root) - } else { - $crate::Config::figment_with_root($crate::find_project_root_path(None).unwrap()) - } - .merge(args) + let root = args.root.clone() + .unwrap_or_else(|| $crate::find_project_root_path(None) + .unwrap_or_else(|e| panic!("could not find project root: {e}"))); + $crate::Config::figment_with_root(root).merge(args) } } @@ -79,8 +77,8 @@ macro_rules! impl_figment_convert { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { let mut figment: $crate::figment::Figment = From::from(&args.$start); - $ ( - figment = figment.merge(&args.$more); + $( + figment = figment.merge(&args.$more); )* figment } @@ -97,8 +95,8 @@ macro_rules! impl_figment_convert { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { let mut figment: $crate::figment::Figment = From::from(&args.$start); - $ ( - figment = figment.merge(&args.$more); + $( + figment = figment.merge(&args.$more); )* figment = figment.merge(args); figment diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 00877a00dc54e..622b94bf74989 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -2,9 +2,8 @@ use crate::{ executors::{Executor, RawCallResult}, inspectors::Fuzzer, }; -use alloy_dyn_abi::DynSolValue; -use alloy_json_abi::JsonAbi; use alloy_primitives::{Address, FixedBytes, U256}; +use alloy_sol_types::{sol, SolCall}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; @@ -19,7 +18,7 @@ use foundry_evm_fuzz::{ }, strategies::{ build_initial_state, collect_created_contracts, collect_state_from_call, invariant_strat, - override_call_strat, EvmFuzzState, + override_call_strat, CalldataFuzzDictionary, EvmFuzzState, }, FuzzCase, FuzzedCases, }; @@ -33,13 +32,60 @@ use revm::{primitives::HashMap, DatabaseCommit}; use std::{borrow::Cow, cell::RefCell, collections::BTreeMap, sync::Arc}; mod error; +use self::error::FailedInvariantCaseData; pub use error::{InvariantFailures, InvariantFuzzError, InvariantFuzzTestResult}; -use foundry_evm_fuzz::strategies::CalldataFuzzDictionary; mod funcs; pub use funcs::{assert_invariants, replay_run}; -use self::error::FailedInvariantCaseData; +sol! { + interface IInvariantTest { + #[derive(Default)] + struct FuzzSelector { + address addr; + bytes4[] selectors; + } + + #[derive(Default)] + struct FuzzAbiSelector { + string contract_abi; + bytes4[] selectors; + } + + #[derive(Default)] + struct FuzzInterface { + address addr; + string[] artifacts; + } + + #[derive(Default)] + function excludeArtifacts() public view returns (string[] memory excludedArtifacts); + + #[derive(Default)] + function excludeContracts() public view returns (address[] memory excludedContracts); + + #[derive(Default)] + function excludeSenders() public view returns (address[] memory excludedSenders); + + #[derive(Default)] + function targetArtifacts() public view returns (string[] memory targetedArtifacts); + + #[derive(Default)] + function targetArtifactSelectors() public view returns (FuzzAbiSelector[] memory targetedArtifactSelectors); + + #[derive(Default)] + function targetContracts() public view returns (address[] memory targetedContracts); + + #[derive(Default)] + function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors); + + #[derive(Default)] + function targetSenders() public view returns (address[] memory targetedSenders); + + #[derive(Default)] + function targetInterfaces() public view returns (FuzzInterface[] memory targetedInterfaces); + } +} /// Alias for (Dictionary for fuzzing, initial contracts to fuzz and an InvariantStrategy). type InvariantPreparation = ( @@ -304,9 +350,9 @@ impl<'a> InvariantExecutor<'a> { invariant_contract: &InvariantContract<'_>, ) -> eyre::Result { // Finds out the chosen deployed contracts and/or senders. - self.select_contract_artifacts(invariant_contract.address, invariant_contract.abi)?; + self.select_contract_artifacts(invariant_contract.address)?; let (targeted_senders, targeted_contracts) = - self.select_contracts_and_senders(invariant_contract.address, invariant_contract.abi)?; + self.select_contracts_and_senders(invariant_contract.address)?; if targeted_contracts.is_empty() { eyre::bail!("No contracts to fuzz."); @@ -369,68 +415,25 @@ impl<'a> InvariantExecutor<'a> { /// Priority: /// /// targetArtifactSelectors > excludeArtifacts > targetArtifacts - pub fn select_contract_artifacts( - &mut self, - invariant_address: Address, - abi: &JsonAbi, - ) -> eyre::Result<()> { - // targetArtifactSelectors -> (string, bytes4[])[]. - let targeted_abi = self - .get_list::<(String, Vec>)>( - invariant_address, - abi, - "targetArtifactSelectors", - |v| { - if let Some(list) = v.as_array() { - list.iter().map(|val| { - if let Some((_, _str, elements)) = val.as_custom_struct() { - let name = elements[0].as_str().unwrap().to_string(); - let selectors = elements[1] - .as_array() - .unwrap() - .iter() - .map(|selector| { - FixedBytes::<4>::from_slice(&selector.as_fixed_bytes().unwrap().0[0..4]) - }) - .collect::>(); - (name, selectors) - } else { - panic!("Could not decode inner value of targetArtifactSelectors. This is a bug.") - } - }).collect::>() - } else { - panic!("Could not decode targetArtifactSelectors as array. This is a bug.") - } - }, - ) - .into_iter() - .collect::>(); + pub fn select_contract_artifacts(&mut self, invariant_address: Address) -> eyre::Result<()> { + let result = self + .call_sol_default(invariant_address, &IInvariantTest::targetArtifactSelectorsCall {}); // Insert them into the executor `targeted_abi`. - for (contract, selectors) in targeted_abi { - let identifier = self.validate_selected_contract(contract, &selectors.to_vec())?; - - self.artifact_filters - .targeted - .entry(identifier) - .or_default() - .extend(selectors.to_vec()); + for IInvariantTest::FuzzAbiSelector { contract_abi, selectors } in + result.targetedArtifactSelectors + { + let identifier = self.validate_selected_contract(contract_abi, &selectors)?; + self.artifact_filters.targeted.entry(identifier).or_default().extend(selectors); } - // targetArtifacts -> string[] - // excludeArtifacts -> string[]. - let [selected_abi, excluded_abi] = ["targetArtifacts", "excludeArtifacts"].map(|method| { - self.get_list::(invariant_address, abi, method, |v| { - if let Some(list) = v.as_array() { - list.iter().map(|v| v.as_str().unwrap().to_string()).collect::>() - } else { - panic!("targetArtifacts should be an array") - } - }) - }); + let selected = + self.call_sol_default(invariant_address, &IInvariantTest::targetArtifactsCall {}); + let excluded = + self.call_sol_default(invariant_address, &IInvariantTest::excludeArtifactsCall {}); // Insert `excludeArtifacts` into the executor `excluded_abi`. - for contract in excluded_abi { + for contract in excluded.excludedArtifacts { let identifier = self.validate_selected_contract(contract, &[])?; if !self.artifact_filters.excluded.contains(&identifier) { @@ -459,7 +462,7 @@ impl<'a> InvariantExecutor<'a> { // Insert `targetArtifacts` into the executor `targeted_abi`, if they have not been seen // before. - for contract in selected_abi { + for contract in selected.targetedArtifacts { let identifier = self.validate_selected_contract(contract, &[])?; if !self.artifact_filters.targeted.contains_key(&identifier) && @@ -497,28 +500,23 @@ impl<'a> InvariantExecutor<'a> { /// `targetContracts() -> address[]` and `excludeContracts() -> address[]`. pub fn select_contracts_and_senders( &self, - invariant_address: Address, - abi: &JsonAbi, + to: Address, ) -> eyre::Result<(SenderFilters, TargetedContracts)> { - let [targeted_senders, excluded_senders, selected, excluded] = - ["targetSenders", "excludeSenders", "targetContracts", "excludeContracts"].map( - |method| { - self.get_list::
(invariant_address, abi, method, |v| { - if let Some(list) = v.as_array() { - list.iter().map(|v| v.as_address().unwrap()).collect::>() - } else { - panic!("targetSenders should be an array") - } - }) - }, - ); + let targeted_senders = + self.call_sol_default(to, &IInvariantTest::targetSendersCall {}).targetedSenders; + let excluded_senders = + self.call_sol_default(to, &IInvariantTest::excludeSendersCall {}).excludedSenders; + let selected = + self.call_sol_default(to, &IInvariantTest::targetContractsCall {}).targetedContracts; + let excluded = + self.call_sol_default(to, &IInvariantTest::excludeContractsCall {}).excludedContracts; let mut contracts: TargetedContracts = self .setup_contracts .clone() .into_iter() .filter(|(addr, (identifier, _))| { - *addr != invariant_address && + *addr != to && *addr != CHEATCODE_ADDRESS && *addr != HARDHAT_CONSOLE_ADDRESS && (selected.is_empty() || selected.contains(addr)) && @@ -531,9 +529,9 @@ impl<'a> InvariantExecutor<'a> { .map(|(addr, (identifier, abi))| (addr, (identifier, abi, vec![]))) .collect(); - self.target_interfaces(invariant_address, abi, &mut contracts)?; + self.target_interfaces(to, &mut contracts)?; - self.select_selectors(invariant_address, abi, &mut contracts)?; + self.select_selectors(to, &mut contracts)?; Ok((SenderFilters::new(targeted_senders, excluded_senders), contracts)) } @@ -545,36 +543,11 @@ impl<'a> InvariantExecutor<'a> { pub fn target_interfaces( &self, invariant_address: Address, - abi: &JsonAbi, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { - let interfaces = self.get_list::<(Address, Vec)>( - invariant_address, - abi, - "targetInterfaces", - |v| { - if let Some(l) = v.as_array() { - l.iter() - .map(|v| { - if let Some((_, _names, elements)) = v.as_custom_struct() { - let addr = elements[0].as_address().unwrap(); - let interfaces = elements[1] - .as_array() - .unwrap() - .iter() - .map(|v| v.as_str().unwrap().to_string()) - .collect::>(); - (addr, interfaces) - } else { - panic!("targetInterfaces should be a tuple array") - } - }) - .collect::>() - } else { - panic!("targetInterfaces should be a tuple array") - } - }, - ); + let interfaces = self + .call_sol_default(invariant_address, &IInvariantTest::targetInterfacesCall {}) + .targetedInterfaces; // Since `targetInterfaces` returns a tuple array there is no guarantee // that the addresses are unique this map is used to merge functions of @@ -585,9 +558,9 @@ impl<'a> InvariantExecutor<'a> { // Loop through each address and its associated artifact identifiers. // We're borrowing here to avoid taking full ownership. - for (addr, identifiers) in &interfaces { + for IInvariantTest::FuzzInterface { addr, artifacts } in &interfaces { // Identifiers are specified as an array, so we loop through them. - for identifier in identifiers { + for identifier in artifacts { // Try to find the contract by name or identifier in the project's contracts. if let Some((_, (abi, _))) = self.project_contracts.find_by_name_or_identifier(identifier)? @@ -618,10 +591,8 @@ impl<'a> InvariantExecutor<'a> { pub fn select_selectors( &self, address: Address, - abi: &JsonAbi, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { - // `targetArtifactSelectors() -> (string, bytes4[])[]`. let some_abi_selectors = self .artifact_filters .targeted @@ -639,37 +610,9 @@ impl<'a> InvariantExecutor<'a> { } } - // `targetSelectors() -> (address, bytes4[])[]`. - let selectors = - self.get_list::<(Address, Vec>)>(address, abi, "targetSelectors", |v| { - if let Some(l) = v.as_array() { - l.iter() - .map(|val| { - if let Some((_, _str, elements)) = val.as_custom_struct() { - let name = elements[0].as_address().unwrap(); - let selectors = elements[1] - .as_array() - .unwrap() - .iter() - .map(|selector| { - FixedBytes::<4>::from_slice( - &selector.as_fixed_bytes().unwrap().0[0..4], - ) - }) - .collect::>(); - (name, selectors) - } else { - panic!("targetSelectors should be a tuple array2") - } - }) - .collect::>() - } else { - panic!("targetSelectors should be a tuple array") - } - }); - - for (address, bytes4_array) in selectors.into_iter() { - self.add_address_with_functions(address, bytes4_array, targeted_contracts)?; + let selectors = self.call_sol_default(address, &IInvariantTest::targetSelectorsCall {}); + for IInvariantTest::FuzzSelector { addr, selectors } in selectors.targetedSelectors { + self.add_address_with_functions(addr, selectors, targeted_contracts)?; } Ok(()) } @@ -704,29 +647,15 @@ impl<'a> InvariantExecutor<'a> { Ok(()) } - /// Get the function output by calling the contract `method_name` function, encoded as a - /// [DynSolValue]. - fn get_list( - &self, - address: Address, - abi: &JsonAbi, - method_name: &str, - f: fn(DynSolValue) -> Vec, - ) -> Vec { - if let Some(func) = abi.functions().find(|func| func.name == method_name) { - if let Ok(call_result) = - self.executor.call::<_, _>(CALLER, address, func.clone(), vec![], U256::ZERO, None) - { - return f(call_result.result) - } else { - warn!( - "The function {} was found but there was an error querying its data.", - method_name - ); - } - }; - - Vec::new() + fn call_sol_default(&self, to: Address, args: &C) -> C::Return + where + C::Return: Default, + { + self.executor + .call_sol(CALLER, to, args, U256::ZERO, None) + .map(|c| c.decoded_result) + .inspect_err(|e| warn!(target: "forge::test", "failed calling {:?}: {e}", C::SIGNATURE)) + .unwrap_or_default() } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 51048002d49a4..45abbfc9c823a 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -12,7 +12,7 @@ use crate::inspectors::{ use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log, U256}; -use foundry_common::{abi::IntoFunction, evm::Breakpoints}; +use alloy_sol_types::{sol, SolCall}; use foundry_evm_core::{ backend::{Backend, CowBackend, DatabaseError, DatabaseExt, DatabaseResult}, constants::{ @@ -46,6 +46,13 @@ pub use invariant::InvariantExecutor; mod tracing; pub use tracing::TracingExecutor; +sol! { + interface ITest { + function setUp() external; + function failed() external view returns (bool); + } +} + /// A type that can execute calls /// /// The executor can be configured with various `revm::Inspector`s, like `Cheatcodes`. @@ -182,61 +189,52 @@ impl Executor { /// /// Ayn changes made during the setup call to env's block environment are persistent, for /// example `vm.chainId()` will change the `block.chainId` for all subsequent test calls. - pub fn setup(&mut self, from: Option
, to: Address) -> Result { + pub fn setup( + &mut self, + from: Option
, + to: Address, + rd: Option<&RevertDecoder>, + ) -> Result { trace!(?from, ?to, "setting up contract"); let from = from.unwrap_or(CALLER); self.backend.set_test_contract(to).set_caller(from); - let res = self.call_committing::<_, _>(from, to, "setUp()", vec![], U256::ZERO, None)?; + let calldata = Bytes::from_static(&ITest::setUpCall::SELECTOR); + let mut res = self.call_raw_committing(from, to, calldata, U256::ZERO)?; + res = res.into_result(rd)?; // record any changes made to the block's environment during setup self.env.block = res.env.block.clone(); // and also the chainid, which can be set manually self.env.cfg.chain_id = res.env.cfg.chain_id; - match res.state_changeset.as_ref() { - Some(changeset) => { - let success = self - .ensure_success(to, res.reverted, Cow::Borrowed(changeset), false) - .map_err(|err| EvmError::Eyre(eyre::eyre!(err.to_string())))?; - if success { - Ok(res) - } else { - Err(EvmError::Execution(Box::new(ExecutionErr { - reverted: res.reverted, - reason: "execution error".to_owned(), - traces: res.traces, - gas_used: res.gas_used, - gas_refunded: res.gas_refunded, - stipend: res.stipend, - logs: res.logs, - debug: res.debug, - labels: res.labels, - state_changeset: None, - transactions: None, - }))) - } + if let Some(changeset) = res.state_changeset.as_ref() { + let success = self + .ensure_success(to, res.reverted, Cow::Borrowed(changeset), false) + .map_err(|err| EvmError::Eyre(eyre::eyre!(err)))?; + if !success { + return Err(res.into_execution_error("execution error".to_string()).into()); } - None => Ok(res), } + + Ok(res) } /// Performs a call to an account on the current state of the VM. /// /// The state after the call is persisted. - pub fn call_committing>, F: IntoFunction>( + pub fn call_committing( &mut self, from: Address, to: Address, - func: F, - args: T, + func: &Function, + args: &[DynSolValue], value: U256, rd: Option<&RevertDecoder>, ) -> Result { - let func = func.into(); - let calldata = Bytes::from(func.abi_encode_input(&args.into())?); + let calldata = Bytes::from(func.abi_encode_input(args)?); let result = self.call_raw_committing(from, to, calldata, value)?; - convert_call_result(rd, &func, result) + result.into_decoded_result(func, rd) } /// Performs a raw call to an account on the current state of the VM. @@ -256,40 +254,55 @@ impl Executor { } /// Executes the test function call - pub fn execute_test>, F: IntoFunction>( + pub fn execute_test( &mut self, from: Address, test_contract: Address, - func: F, - args: T, + func: &Function, + args: &[DynSolValue], value: U256, rd: Option<&RevertDecoder>, ) -> Result { - let func = func.into(); - let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); + let calldata = Bytes::from(func.abi_encode_input(args)?); // execute the call let env = self.build_test_env(from, TransactTo::Call(test_contract), calldata, value); - let call_result = self.call_raw_with_env(env)?; - convert_call_result(rd, &func, call_result) + let result = self.call_raw_with_env(env)?; + result.into_decoded_result(func, rd) } /// Performs a call to an account on the current state of the VM. /// /// The state after the call is not persisted. - pub fn call>, F: IntoFunction>( + pub fn call( &self, from: Address, to: Address, - func: F, - args: T, + func: &Function, + args: &[DynSolValue], value: U256, rd: Option<&RevertDecoder>, ) -> Result { - let func = func.into(); - let calldata = Bytes::from(func.abi_encode_input(&args.into())?.to_vec()); - let call_result = self.call_raw(from, to, calldata, value)?; - convert_call_result(rd, &func, call_result) + let calldata = Bytes::from(func.abi_encode_input(args)?); + let result = self.call_raw(from, to, calldata, value)?; + result.into_decoded_result(func, rd) + } + + /// Performs a call to an account on the current state of the VM. + /// + /// The state after the call is not persisted. + pub fn call_sol( + &self, + from: Address, + to: Address, + args: &C, + value: U256, + rd: Option<&RevertDecoder>, + ) -> Result, EvmError> { + let calldata = Bytes::from(args.abi_encode()); + let mut raw = self.call_raw(from, to, calldata, value)?; + raw = raw.into_result(rd)?; + Ok(CallResult { decoded_result: C::abi_decode_returns(&raw.result, false)?, raw }) } /// Performs a raw call to an account on the current state of the VM. @@ -335,12 +348,12 @@ impl Executor { /// Commit the changeset to the database and adjust `self.inspector_config` /// values according to the executed call result fn commit(&mut self, result: &mut RawCallResult) { - // Persist changes to db + // Persist changes to db. if let Some(changes) = &result.state_changeset { self.backend.commit(changes.clone()); } - // Persist cheatcode state + // Persist cheatcode state. let mut cheatcodes = result.cheatcodes.take(); if let Some(cheats) = cheatcodes.as_mut() { // Clear broadcastable transactions @@ -352,96 +365,48 @@ impl Executor { } self.inspector.cheatcodes = cheatcodes; - // Persist the changed environment + // Persist the changed environment. self.inspector.set_env(&result.env); } /// Deploys a contract using the given `env` and commits the new state to the underlying - /// database + /// database. + /// + /// # Panics + /// + /// Panics if `env.tx.transact_to` is not `TransactTo::Create(_)`. pub fn deploy_with_env( &mut self, env: EnvWithHandlerCfg, rd: Option<&RevertDecoder>, ) -> Result { - debug_assert!( + assert!( matches!(env.tx.transact_to, TransactTo::Create(_)), - "Expect create transaction" + "Expected create transaction, got {:?}", + env.tx.transact_to ); - trace!(sender=?env.tx.caller, "deploying contract"); + trace!(sender=%env.tx.caller, "deploying contract"); let mut result = self.call_raw_with_env(env)?; self.commit(&mut result); - - let RawCallResult { - exit_reason, - out, - gas_used, - gas_refunded, - logs, - labels, - traces, - debug, - env, - coverage, - .. - } = result; - - let result = match &out { - Some(Output::Create(data, _)) => data.to_owned(), - _ => Bytes::default(), - }; - - let address = match exit_reason { - return_ok!() => { - if let Some(Output::Create(_, Some(addr))) = out { - addr - } else { - return Err(EvmError::Execution(Box::new(ExecutionErr { - reverted: true, - reason: "Deployment succeeded, but no address was returned. This is a bug, please report it".to_string(), - traces, - gas_used, - gas_refunded: 0, - stipend: 0, - logs, - debug, - labels, - state_changeset: None, - transactions: None, - }))); - } - } - _ => { - let reason = rd.unwrap_or_default().decode(&result, Some(exit_reason)); - return Err(EvmError::Execution(Box::new(ExecutionErr { - reverted: true, - reason, - traces, - gas_used, - gas_refunded, - stipend: 0, - logs, - debug, - labels, - state_changeset: None, - transactions: None, - }))) - } + result = result.into_result(rd)?; + let Some(Output::Create(_, Some(address))) = result.out else { + panic!("Deployment succeeded, but no address was returned: {result:#?}"); }; // also mark this library as persistent, this will ensure that the state of the library is // persistent across fork swaps in forking mode self.backend.add_persistent_account(address); - trace!(address=?address, "deployed contract"); + debug!(%address, "deployed contract"); - Ok(DeployResult { address, gas_used, gas_refunded, logs, traces, debug, env, coverage }) + Ok(DeployResult { raw: result, address }) } /// Deploys a contract and commits the new state to the underlying database. /// /// Executes a CREATE transaction with the contract `code` and persistent database state - /// modifications + /// modifications. pub fn deploy( &mut self, from: Address, @@ -540,10 +505,12 @@ impl Executor { // Check if a DSTest assertion failed let executor = Executor::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); - let call = executor.call(CALLER, address, "failed()(bool)", vec![], U256::ZERO, None); - if let Ok(CallResult { result: failed, .. }) = call { - debug!(?failed, "DSTest"); - success = !failed.as_bool().unwrap(); + let call = executor.call_sol(CALLER, address, &ITest::failedCall {}, U256::ZERO, None); + if let Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { _0: failed } }) = + call + { + debug!(failed, "DSTest::failed()"); + success = !failed; } } @@ -592,26 +559,35 @@ impl Executor { /// Represents the context after an execution error occurred. #[derive(Debug, thiserror::Error)] -#[error("Execution reverted: {reason} (gas: {gas_used})")] +#[error("execution reverted: {reason} (gas: {})", raw.gas_used)] pub struct ExecutionErr { - pub reverted: bool, + /// The raw result of the call. + pub raw: RawCallResult, + /// The revert reason. pub reason: String, - pub gas_used: u64, - pub gas_refunded: u64, - pub stipend: u64, - pub logs: Vec, - pub traces: Option, - pub debug: Option, - pub labels: HashMap, - pub transactions: Option, - pub state_changeset: Option, +} + +impl std::ops::Deref for ExecutionErr { + type Target = RawCallResult; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.raw + } +} + +impl std::ops::DerefMut for ExecutionErr { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.raw + } } #[derive(Debug, thiserror::Error)] pub enum EvmError { /// Error which occurred during execution of a transaction #[error(transparent)] - Execution(Box), + Execution(#[from] Box), /// Error which occurred during ABI encoding/decoding #[error(transparent)] AbiError(#[from] alloy_dyn_abi::Error), @@ -623,62 +599,41 @@ pub enum EvmError { Eyre(#[from] eyre::Error), } +impl From for EvmError { + fn from(err: ExecutionErr) -> Self { + EvmError::Execution(Box::new(err)) + } +} + +impl From for EvmError { + fn from(err: alloy_sol_types::Error) -> Self { + EvmError::AbiError(err.into()) + } +} + /// The result of a deployment. #[derive(Debug)] pub struct DeployResult { + /// The raw result of the deployment. + pub raw: RawCallResult, /// The address of the deployed contract pub address: Address, - /// The gas cost of the deployment - pub gas_used: u64, - /// The refunded gas - pub gas_refunded: u64, - /// The logs emitted during the deployment - pub logs: Vec, - /// The traces of the deployment - pub traces: Option, - /// The debug nodes of the call - pub debug: Option, - /// The `revm::Env` after deployment - pub env: EnvWithHandlerCfg, - /// The coverage info collected during the deployment - pub coverage: Option, } -/// The result of a call. -#[derive(Debug)] -pub struct CallResult { - pub skipped: bool, - /// Whether the call reverted or not - pub reverted: bool, - /// The decoded result of the call - pub result: DynSolValue, - /// The gas used for the call - pub gas_used: u64, - /// The refunded gas for the call - pub gas_refunded: u64, - /// The initial gas stipend for the transaction - pub stipend: u64, - /// The logs emitted during the call - pub logs: Vec, - /// The labels assigned to addresses during the call - pub labels: HashMap, - /// The traces of the call - pub traces: Option, - /// The coverage info collected during the call - pub coverage: Option, - /// The debug nodes of the call - pub debug: Option, - /// Scripted transactions generated from this call - pub transactions: Option, - /// The changeset of the state. - /// - /// This is only present if the changed state was not committed to the database (i.e. if you - /// used `call` and `call_raw` not `call_committing` or `call_raw_committing`). - pub state_changeset: Option, - /// The `revm::Env` after the call - pub env: EnvWithHandlerCfg, - /// breakpoints - pub breakpoints: Breakpoints, +impl std::ops::Deref for DeployResult { + type Target = RawCallResult; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.raw + } +} + +impl std::ops::DerefMut for DeployResult { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.raw + } } /// The result of a raw call. @@ -693,7 +648,7 @@ pub struct RawCallResult { /// This is tracked separately from revert because a snapshot failure can occur without a /// revert, since assert failures are stored in a global variable (ds-test legacy) pub has_snapshot_failure: bool, - /// The raw result of the call + /// The raw result of the call. pub result: Bytes, /// The gas used for the call pub gas_used: u64, @@ -753,6 +708,77 @@ impl Default for RawCallResult { } } +impl RawCallResult { + /// Converts the result of the call into an `EvmError`. + pub fn into_evm_error(self, rd: Option<&RevertDecoder>) -> EvmError { + if self.result[..] == crate::constants::MAGIC_SKIP[..] { + return EvmError::SkipError; + } + let reason = rd.unwrap_or_default().decode(&self.result, Some(self.exit_reason)); + EvmError::Execution(Box::new(self.into_execution_error(reason))) + } + + /// Converts the result of the call into an `ExecutionErr`. + pub fn into_execution_error(self, reason: String) -> ExecutionErr { + ExecutionErr { raw: self, reason } + } + + /// Returns an `EvmError` if the call failed, otherwise returns `self`. + pub fn into_result(self, rd: Option<&RevertDecoder>) -> Result { + if self.exit_reason.is_ok() { + Ok(self) + } else { + Err(self.into_evm_error(rd)) + } + } + + /// Decodes the result of the call with the given function. + pub fn into_decoded_result( + mut self, + func: &Function, + rd: Option<&RevertDecoder>, + ) -> Result { + self = self.into_result(rd)?; + let mut result = func.abi_decode_output(&self.result, false)?; + let decoded_result = if result.len() == 1 { + result.pop().unwrap() + } else { + // combine results into a tuple + DynSolValue::Tuple(result) + }; + Ok(CallResult { raw: self, decoded_result }) + } + + /// Returns the transactions generated from this call. + pub fn transactions(&self) -> Option<&BroadcastableTransactions> { + self.cheatcodes.as_ref().map(|c| &c.broadcastable_transactions) + } +} + +/// The result of a call. +pub struct CallResult { + /// The raw result of the call. + pub raw: RawCallResult, + /// The decoded result of the call. + pub decoded_result: T, +} + +impl std::ops::Deref for CallResult { + type Target = RawCallResult; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.raw + } +} + +impl std::ops::DerefMut for CallResult { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.raw + } +} + /// Calculates the initial gas stipend for a transaction fn calc_stipend(calldata: &[u8], spec: SpecId) -> u64 { let non_zero_data_cost = if SpecId::enabled(spec, SpecId::ISTANBUL) { 16 } else { 68 }; @@ -815,77 +841,3 @@ fn convert_executed_result( chisel_state, }) } - -fn convert_call_result( - rd: Option<&RevertDecoder>, - func: &Function, - call_result: RawCallResult, -) -> Result { - let RawCallResult { - result, - exit_reason: status, - reverted, - gas_used, - gas_refunded, - stipend, - logs, - labels, - traces, - coverage, - debug, - transactions, - state_changeset, - env, - .. - } = call_result; - - let breakpoints = call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); - - match status { - return_ok!() => { - let mut result = func.abi_decode_output(&result, false)?; - let res = if result.len() == 1 { - result.pop().unwrap() - } else { - // combine results into a tuple - DynSolValue::Tuple(result) - }; - Ok(CallResult { - reverted, - result: res, - gas_used, - gas_refunded, - stipend, - logs, - labels, - traces, - coverage, - debug, - transactions, - state_changeset, - env, - breakpoints, - skipped: false, - }) - } - _ => { - if &result == crate::constants::MAGIC_SKIP { - return Err(EvmError::SkipError) - } - let reason = rd.unwrap_or_default().decode(&result, Some(status)); - Err(EvmError::Execution(Box::new(ExecutionErr { - reverted, - reason, - gas_used, - gas_refunded, - stipend, - logs, - traces, - debug, - labels, - transactions, - state_changeset, - }))) - } - } -} diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 94c6d58fcd128..ad1173381c214 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -534,9 +534,9 @@ impl TestSetup { match error { EvmError::Execution(err) => { // force the tracekind to be setup so a trace is shown. - traces.extend(err.traces.map(|traces| (TraceKind::Setup, traces))); - logs.extend(err.logs); - labeled_addresses.extend(err.labels); + traces.extend(err.raw.traces.map(|traces| (TraceKind::Setup, traces))); + logs.extend(err.raw.logs); + labeled_addresses.extend(err.raw.labels); Self::failed_with(logs, traces, labeled_addresses, err.reason) } e => Self::failed_with( diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 9ee3cf6897a93..494a02d8875af 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -20,7 +20,7 @@ use foundry_evm::{ executors::{ fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, invariant::{replay_run, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult}, - CallResult, EvmError, ExecutionErr, Executor, + EvmError, ExecutionErr, Executor, RawCallResult, }, fuzz::{invariant::InvariantContract, CounterExample}, traces::{load_contracts, TraceKind}, @@ -113,8 +113,8 @@ impl<'a> ContractRunner<'a> { Some(self.revert_decoder), ) { Ok(d) => { - logs.extend(d.logs); - traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); + logs.extend(d.raw.logs); + traces.extend(d.raw.traces.map(|traces| (TraceKind::Deployment, traces))); } Err(e) => { return Ok(TestSetup::from_evm_error_with(e, logs, traces, Default::default())) @@ -136,8 +136,8 @@ impl<'a> ContractRunner<'a> { Some(self.revert_decoder), ) { Ok(d) => { - logs.extend(d.logs); - traces.extend(d.traces.map(|traces| (TraceKind::Deployment, traces))); + logs.extend(d.raw.logs); + traces.extend(d.raw.traces.map(|traces| (TraceKind::Deployment, traces))); d.address } Err(e) => { @@ -154,21 +154,20 @@ impl<'a> ContractRunner<'a> { // Optionally call the `setUp` function let setup = if setup { trace!("setting up"); - let (setup_logs, setup_traces, labeled_addresses, reason, coverage) = match self - .executor - .setup(None, address) - { - Ok(CallResult { traces, labels, logs, coverage, .. }) => { + let res = self.executor.setup(None, address, Some(self.revert_decoder)); + let (setup_logs, setup_traces, labeled_addresses, reason, coverage) = match res { + Ok(RawCallResult { traces, labels, logs, coverage, .. }) => { trace!(contract=%address, "successfully setUp test"); (logs, traces, labels, None, coverage) } Err(EvmError::Execution(err)) => { - let ExecutionErr { traces, labels, logs, reason, .. } = *err; - error!(reason=%reason, contract=%address, "setUp failed"); - (logs, traces, labels, Some(format!("setup failed: {reason}")), None) + let ExecutionErr { + raw: RawCallResult { traces, labels, logs, coverage, .. }, + reason, + } = *err; + (logs, traces, labels, Some(format!("setup failed: {reason}")), coverage) } Err(err) => { - error!(reason=%err, contract=%address, "setUp failed"); (Vec::new(), None, HashMap::new(), Some(format!("setup failed: {err}")), None) } }; @@ -343,27 +342,30 @@ impl<'a> ContractRunner<'a> { let start = Instant::now(); let debug_arena; let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = - match executor.execute_test::<_, _>( + match executor.execute_test( self.sender, address, - func.clone(), - vec![], + func, + &[], U256::ZERO, Some(self.revert_decoder), ) { - Ok(CallResult { - reverted, - gas_used: gas, - stipend, - logs: execution_logs, - traces: execution_trace, - coverage: execution_coverage, - labels: new_labels, - state_changeset, - debug, - breakpoints, - .. - }) => { + Ok(res) => { + let RawCallResult { + reverted, + gas_used: gas, + stipend, + logs: execution_logs, + traces: execution_trace, + coverage: execution_coverage, + labels: new_labels, + state_changeset, + debug, + cheatcodes, + .. + } = res.raw; + + let breakpoints = cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); labeled_addresses.extend(new_labels); logs.extend(execution_logs); @@ -373,17 +375,18 @@ impl<'a> ContractRunner<'a> { (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) } Err(EvmError::Execution(err)) => { - traces.extend(err.traces.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(err.labels); - logs.extend(err.logs); - debug_arena = err.debug; + let ExecutionErr { raw, reason } = *err; + traces.extend(raw.traces.map(|traces| (TraceKind::Execution, traces))); + labeled_addresses.extend(raw.labels); + logs.extend(raw.logs); + debug_arena = raw.debug; ( - err.reverted, - Some(err.reason), - err.gas_used, - err.stipend, + raw.reverted, + Some(reason), + raw.gas_used, + raw.stipend, None, - err.state_changeset, + raw.state_changeset, Default::default(), ) } @@ -461,11 +464,11 @@ impl<'a> ContractRunner<'a> { // First, run the test normally to see if it needs to be skipped. let start = Instant::now(); - if let Err(EvmError::SkipError) = self.executor.clone().execute_test::<_, _>( + if let Err(EvmError::SkipError) = self.executor.clone().execute_test( self.sender, address, - func.clone(), - vec![], + func, + &[], U256::ZERO, Some(self.revert_decoder), ) { diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index d91af9dc6c76c..23c25d133dc08 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -4,7 +4,7 @@ use eyre::Result; use foundry_config::Config; use foundry_evm::{ constants::CALLER, - executors::{CallResult, DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, + executors::{DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, revm::interpreter::{return_ok, InstructionResult}, traces::{TraceKind, Traces}, }; @@ -55,12 +55,11 @@ impl ScriptRunner { let mut traces: Traces = libraries .iter() .filter_map(|code| { - let DeployResult { traces, .. } = self - .executor + self.executor .deploy(self.sender, code.clone(), U256::ZERO, None) - .expect("couldn't deploy library"); - - traces + .expect("couldn't deploy library") + .raw + .traces }) .map(|traces| (TraceKind::Deployment, traces)) .collect(); @@ -74,10 +73,8 @@ impl ScriptRunner { // Deploy an instance of the contract let DeployResult { address, - mut logs, - traces: constructor_traces, - debug: constructor_debug, - .. + raw: + RawCallResult { mut logs, traces: constructor_traces, debug: constructor_debug, .. }, } = self .executor .deploy(CALLER, code, U256::ZERO, None) @@ -90,8 +87,8 @@ impl ScriptRunner { self.executor.backend.set_test_contract(address); (true, 0, Default::default(), None, vec![constructor_debug].into_iter().collect()) } else { - match self.executor.setup(Some(self.sender), address) { - Ok(CallResult { + match self.executor.setup(Some(self.sender), address, None) { + Ok(RawCallResult { reverted, traces: setup_traces, labels, @@ -115,7 +112,7 @@ impl ScriptRunner { ) } Err(EvmError::Execution(err)) => { - let ExecutionErr { + let RawCallResult { reverted, traces: setup_traces, labels, @@ -124,7 +121,7 @@ impl ScriptRunner { gas_used, transactions, .. - } = *err; + } = err.raw; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend_from_slice(&setup_logs); @@ -193,20 +190,18 @@ impl ScriptRunner { if let Some(to) = to { self.call(from, to, calldata.unwrap_or_default(), value.unwrap_or(U256::ZERO), true) } else if to.is_none() { - let (address, gas_used, logs, traces, debug) = match self.executor.deploy( + let res = self.executor.deploy( from, calldata.expect("No data for create transaction"), value.unwrap_or(U256::ZERO), None, - ) { - Ok(DeployResult { address, gas_used, logs, traces, debug, .. }) => { - (address, gas_used, logs, traces, debug) - } + ); + let (address, RawCallResult { gas_used, logs, traces, debug, .. }) = match res { + Ok(DeployResult { address, raw }) => (address, raw), Err(EvmError::Execution(err)) => { - let ExecutionErr { reason, traces, gas_used, logs, debug, .. } = *err; + let ExecutionErr { raw, reason } = *err; println!("{}", Paint::red(format!("\nFailed with `{reason}`:\n"))); - - (Address::ZERO, gas_used, logs, traces, debug) + (Address::ZERO, raw) } Err(e) => eyre::bail!("Failed deploying contract: {e:?}"), }; @@ -216,14 +211,11 @@ impl ScriptRunner { success: address != Address::ZERO, gas_used, logs, + // Manually adjust gas for the trace to add back the stipend/real used gas traces: traces - .map(|traces| { - // Manually adjust gas for the trace to add back the stipend/real used gas - - vec![(TraceKind::Execution, traces)] - }) + .map(|traces| vec![(TraceKind::Execution, traces)]) .unwrap_or_default(), - debug: vec![debug].into_iter().collect(), + debug: debug.map(|debug| vec![debug]), address: Some(address), ..Default::default() }) From 6dfc6e7975308f9753acc410250099847efaed14 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:06:36 +0100 Subject: [PATCH 0766/1963] feat: parse inline config with solang (#7431) * feat: parse inline config with solang * fix: multiple single docs are merged * fix: dont merge lines * fix: read absolute path * perf: fast path with src.contains * fix: split on dots * chore: clippy --- Cargo.lock | 1 + Cargo.toml | 1 + crates/config/Cargo.toml | 2 + crates/config/src/inline/mod.rs | 28 +-- crates/config/src/inline/natspec.rs | 310 +++++++++++++++++++++------- crates/forge/src/lib.rs | 20 +- crates/forge/tests/it/inline.rs | 44 ++-- 7 files changed, 267 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dea2c7c4d0ab8..bd7a9fd7808be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3347,6 +3347,7 @@ dependencies = [ "serde", "serde_json", "serde_regex", + "solang-parser", "tempfile", "thiserror", "toml 0.8.11", diff --git a/Cargo.toml b/Cargo.toml index 54364afa67486..ab21bddfc5c06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ debug = 1 # Solc and artifacts foundry-compilers.opt-level = 3 solang-parser.opt-level = 3 +lalrpop-util.opt-level = 3 serde_json.opt-level = 3 # EVM diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index b3f4c514a7660..4f42da66d33e9 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -18,6 +18,8 @@ alloy-chains = { workspace = true, features = ["serde"] } alloy-primitives = { workspace = true, features = ["serde"] } revm-primitives = { workspace = true, default-features = false, features = ["std"] } +solang-parser.workspace = true + dirs-next = "2" dunce = "1" eyre.workspace = true diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index af2cbe7e3cf1d..9989d5b76c554 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -3,7 +3,7 @@ pub use conf_parser::{parse_config_bool, parse_config_u32, validate_profiles, In pub use error::{InlineConfigError, InlineConfigParserError}; pub use natspec::NatSpec; use once_cell::sync::Lazy; -use std::{borrow::Cow, collections::HashMap}; +use std::collections::HashMap; mod conf_parser; mod error; @@ -25,22 +25,14 @@ static INLINE_CONFIG_PREFIX_SELECTED_PROFILE: Lazy = Lazy::new(|| { pub struct InlineConfig { /// Maps a (test-contract, test-function) pair /// to a specific configuration provided by the user. - configs: HashMap, T>, + configs: HashMap<(String, String), T>, } impl InlineConfig { /// Returns an inline configuration, if any, for a test function. /// Configuration is identified by the pair "contract", "function". - pub fn get(&self, contract_id: C, fn_name: F) -> Option<&T> - where - C: Into, - F: Into, - { - // TODO use borrow - let key = InlineConfigKey { - contract: Cow::Owned(contract_id.into()), - function: Cow::Owned(fn_name.into()), - }; + pub fn get(&self, contract_id: &str, fn_name: &str) -> Option<&T> { + let key = (contract_id.to_string(), fn_name.to_string()); self.configs.get(&key) } @@ -51,21 +43,11 @@ impl InlineConfig { C: Into, F: Into, { - let key = InlineConfigKey { - contract: Cow::Owned(contract_id.into()), - function: Cow::Owned(fn_name.into()), - }; + let key = (contract_id.into(), fn_name.into()); self.configs.insert(key, config); } } -/// Represents a (test-contract, test-function) pair -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -struct InlineConfigKey<'a> { - contract: Cow<'a, str>, - function: Cow<'a, str>, -} - pub(crate) fn remove_whitespaces(s: &str) -> String { s.chars().filter(|c| !c.is_whitespace()).collect() } diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 11557fd7a8295..3b62d40cc1c28 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -4,10 +4,11 @@ use foundry_compilers::{ ProjectCompileOutput, }; use serde_json::Value; +use solang_parser::pt; use std::{collections::BTreeMap, path::Path}; /// Convenient struct to hold in-line per-test configurations -#[derive(Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct NatSpec { /// The parent contract of the natspec pub contract: String, @@ -28,14 +29,28 @@ impl NatSpec { pub fn parse(output: &ProjectCompileOutput, root: &Path) -> Vec { let mut natspecs: Vec = vec![]; + let solc = SolcParser::new(); + let solang = SolangParser::new(); for (id, artifact) in output.artifact_ids() { - let Some(ast) = &artifact.ast else { continue }; - let path = id.source.as_path(); - let path = path.strip_prefix(root).unwrap_or(path); - // id.identifier + let abs_path = id.source.as_path(); + let path = abs_path.strip_prefix(root).unwrap_or(abs_path); + let contract_name = id.name.split('.').next().unwrap(); + // `id.identifier` but with the stripped path. let contract = format!("{}:{}", path.display(), id.name); - let Some(node) = contract_root_node(&ast.nodes, &contract) else { continue }; - apply(&mut natspecs, &contract, node) + + let mut used_solc_ast = false; + if let Some(ast) = &artifact.ast { + if let Some(node) = solc.contract_root_node(&ast.nodes, &contract) { + solc.parse(&mut natspecs, &contract, node); + used_solc_ast = true; + } + } + + if !used_solc_ast { + if let Ok(src) = std::fs::read_to_string(abs_path) { + solang.parse(&mut natspecs, &src, &contract, contract_name); + } + } } natspecs @@ -63,89 +78,246 @@ impl NatSpec { /// Returns a list of all the configuration lines available in the natspec pub fn config_lines(&self) -> impl Iterator + '_ { - self.docs.lines().map(remove_whitespaces).filter(|line| line.contains(INLINE_CONFIG_PREFIX)) + self.docs.lines().filter(|line| line.contains(INLINE_CONFIG_PREFIX)).map(remove_whitespaces) } } -/// Given a list of nodes, find a "ContractDefinition" node that matches -/// the provided contract_id. -fn contract_root_node<'a>(nodes: &'a [Node], contract_id: &'a str) -> Option<&'a Node> { - for n in nodes.iter() { - if let NodeType::ContractDefinition = n.node_type { - let contract_data = &n.other; - if let Value::String(contract_name) = contract_data.get("name")? { - if contract_id.ends_with(contract_name) { - return Some(n) +struct SolcParser { + _private: (), +} + +impl SolcParser { + fn new() -> Self { + Self { _private: () } + } + + /// Given a list of nodes, find a "ContractDefinition" node that matches + /// the provided contract_id. + fn contract_root_node<'a>(&self, nodes: &'a [Node], contract_id: &str) -> Option<&'a Node> { + for n in nodes.iter() { + if let NodeType::ContractDefinition = n.node_type { + let contract_data = &n.other; + if let Value::String(contract_name) = contract_data.get("name")? { + if contract_id.ends_with(contract_name) { + return Some(n) + } } } } + None } - None -} -/// Implements a DFS over a compiler output node and its children. -/// If a natspec is found it is added to `natspecs` -fn apply(natspecs: &mut Vec, contract: &str, node: &Node) { - for n in node.nodes.iter() { - if let Some((function, docs, line)) = get_fn_data(n) { - natspecs.push(NatSpec { contract: contract.into(), function, line, docs }) + /// Implements a DFS over a compiler output node and its children. + /// If a natspec is found it is added to `natspecs` + fn parse(&self, natspecs: &mut Vec, contract: &str, node: &Node) { + for n in node.nodes.iter() { + if let Some((function, docs, line)) = self.get_fn_data(n) { + natspecs.push(NatSpec { contract: contract.into(), function, line, docs }) + } + self.parse(natspecs, contract, n); + } + } + + /// Given a compilation output node, if it is a function definition + /// that also contains a natspec then return a tuple of: + /// - Function name + /// - Natspec text + /// - Natspec position with format "row:col:length" + /// + /// Return None otherwise. + fn get_fn_data(&self, node: &Node) -> Option<(String, String, String)> { + if let NodeType::FunctionDefinition = node.node_type { + let fn_data = &node.other; + let fn_name: String = self.get_fn_name(fn_data)?; + let (fn_docs, docs_src_line): (String, String) = self.get_fn_docs(fn_data)?; + return Some((fn_name, fn_docs, docs_src_line)) + } + + None + } + + /// Given a dictionary of function data returns the name of the function. + fn get_fn_name(&self, fn_data: &BTreeMap) -> Option { + match fn_data.get("name")? { + Value::String(fn_name) => Some(fn_name.into()), + _ => None, + } + } + + /// Inspects Solc compiler output for documentation comments. Returns: + /// - `Some((String, String))` in case the function has natspec comments. First item is a + /// textual natspec representation, the second item is the natspec src line, in the form + /// "raw:col:length". + /// - `None` in case the function has not natspec comments. + fn get_fn_docs(&self, fn_data: &BTreeMap) -> Option<(String, String)> { + if let Value::Object(fn_docs) = fn_data.get("documentation")? { + if let Value::String(comment) = fn_docs.get("text")? { + if comment.contains(INLINE_CONFIG_PREFIX) { + let mut src_line = fn_docs + .get("src") + .map(|src| src.to_string()) + .unwrap_or_else(|| String::from("")); + + src_line.retain(|c| c != '"'); + return Some((comment.into(), src_line)) + } + } } - apply(natspecs, contract, n); + None } } -/// Given a compilation output node, if it is a function definition -/// that also contains a natspec then return a tuple of: -/// - Function name -/// - Natspec text -/// - Natspec position with format "row:col:length" -/// -/// Return None otherwise. -fn get_fn_data(node: &Node) -> Option<(String, String, String)> { - if let NodeType::FunctionDefinition = node.node_type { - let fn_data = &node.other; - let fn_name: String = get_fn_name(fn_data)?; - let (fn_docs, docs_src_line): (String, String) = get_fn_docs(fn_data)?; - return Some((fn_name, fn_docs, docs_src_line)) - } - - None +struct SolangParser { + _private: (), } -/// Given a dictionary of function data returns the name of the function. -fn get_fn_name(fn_data: &BTreeMap) -> Option { - match fn_data.get("name")? { - Value::String(fn_name) => Some(fn_name.into()), - _ => None, +impl SolangParser { + fn new() -> Self { + Self { _private: () } } -} -/// Inspects Solc compiler output for documentation comments. Returns: -/// - `Some((String, String))` in case the function has natspec comments. First item is a textual -/// natspec representation, the second item is the natspec src line, in the form "raw:col:length". -/// - `None` in case the function has not natspec comments. -fn get_fn_docs(fn_data: &BTreeMap) -> Option<(String, String)> { - if let Value::Object(fn_docs) = fn_data.get("documentation")? { - if let Value::String(comment) = fn_docs.get("text")? { - if comment.contains(INLINE_CONFIG_PREFIX) { - let mut src_line = fn_docs - .get("src") - .map(|src| src.to_string()) - .unwrap_or_else(|| String::from("")); - - src_line.retain(|c| c != '"'); - return Some((comment.into(), src_line)) + fn parse( + &self, + natspecs: &mut Vec, + src: &str, + contract_id: &str, + contract_name: &str, + ) { + // Fast path to avoid parsing the file. + if !src.contains(INLINE_CONFIG_PREFIX) { + return; + } + + let Ok((pt, comments)) = solang_parser::parse(src, 0) else { return }; + let mut prev_end = 0; + for item in &pt.0 { + let pt::SourceUnitPart::ContractDefinition(c) = item else { continue }; + let Some(id) = c.name.as_ref() else { continue }; + if id.name != contract_name { + continue + }; + for part in &c.parts { + let pt::ContractPart::FunctionDefinition(f) = part else { continue }; + let start = f.loc.start(); + // Parse doc comments in between the previous function and the current one. + let docs = solang_parser::doccomment::parse_doccomments(&comments, prev_end, start); + let docs = docs + .into_iter() + .flat_map(|doc| doc.into_comments()) + .filter(|doc| doc.value.contains(INLINE_CONFIG_PREFIX)); + for doc in docs { + natspecs.push(NatSpec { + contract: contract_id.to_string(), + function: f.name.as_ref().map(|id| id.to_string()).unwrap_or_default(), + line: "0:0:0".to_string(), + docs: doc.value, + }); + } + prev_end = f.loc.end(); } + prev_end = c.loc.end(); } } - None } #[cfg(test)] mod tests { - use crate::{inline::natspec::get_fn_docs, NatSpec}; - use serde_json::{json, Value}; - use std::collections::BTreeMap; + use super::*; + use serde_json::json; + + #[test] + fn parse_solang() { + let src = " +contract C { /// forge-config: default.fuzz.runs = 600 + +\t\t\t\t /// forge-config: default.fuzz.runs = 601 + + function f1() {} + /** forge-config: default.fuzz.runs = 700 */ +function f2() {} /** forge-config: default.fuzz.runs = 800 */ function f3() {} + +/** + * forge-config: default.fuzz.runs = 1024 + * forge-config: default.fuzz.max-test-rejects = 500 + */ + function f4() {} +} +"; + let mut natspecs = vec![]; + let solang = SolangParser::new(); + let id = || "path.sol:C".to_string(); + let default_line = || "0:0:0".to_string(); + solang.parse(&mut natspecs, src, &id(), "C"); + assert_eq!( + natspecs, + [ + // f1 + NatSpec { + contract: id(), + function: "f1".to_string(), + line: default_line(), + docs: "forge-config: default.fuzz.runs = 600\nforge-config: default.fuzz.runs = 601".to_string(), + }, + // f2 + NatSpec { + contract: id(), + function: "f2".to_string(), + line: default_line(), + docs: "forge-config: default.fuzz.runs = 700".to_string(), + }, + // f3 + NatSpec { + contract: id(), + function: "f3".to_string(), + line: default_line(), + docs: "forge-config: default.fuzz.runs = 800".to_string(), + }, + // f4 + NatSpec { + contract: id(), + function: "f4".to_string(), + line: default_line(), + docs: "forge-config: default.fuzz.runs = 1024\nforge-config: default.fuzz.max-test-rejects = 500".to_string(), + }, + ] + ); + } + + #[test] + fn parse_solang_2() { + let src = r#" +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity >=0.8.0; + +import "ds-test/test.sol"; + +contract FuzzInlineConf is DSTest { + /** + * forge-config: default.fuzz.runs = 1024 + * forge-config: default.fuzz.max-test-rejects = 500 + */ + function testInlineConfFuzz(uint8 x) public { + require(true, "this is not going to revert"); + } +} + "#; + let mut natspecs = vec![]; + let solang = SolangParser::new(); + let id = || "inline/FuzzInlineConf.t.sol:FuzzInlineConf".to_string(); + let default_line = || "0:0:0".to_string(); + solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); + assert_eq!( + natspecs, + [ + NatSpec { + contract: id(), + function: "testInlineConfFuzz".to_string(), + line: default_line(), + docs: "forge-config: default.fuzz.runs = 1024\nforge-config: default.fuzz.max-test-rejects = 500".to_string(), + }, + ] + ); + } #[test] fn config_lines() { @@ -195,7 +367,7 @@ mod tests { let mut fn_data: BTreeMap = BTreeMap::new(); let doc_without_src_field = json!({ "text": "forge-config:default.fuzz.runs=600" }); fn_data.insert("documentation".into(), doc_without_src_field); - let (_, src_line) = get_fn_docs(&fn_data).expect("Some docs"); + let (_, src_line) = SolcParser::new().get_fn_docs(&fn_data).expect("Some docs"); assert_eq!(src_line, "".to_string()); } @@ -205,7 +377,7 @@ mod tests { let doc_without_src_field = json!({ "text": "forge-config:default.fuzz.runs=600", "src": "73:21:12" }); fn_data.insert("documentation".into(), doc_without_src_field); - let (_, src_line) = get_fn_docs(&fn_data).expect("Some docs"); + let (_, src_line) = SolcParser::new().get_fn_docs(&fn_data).expect("Some docs"); assert_eq!(src_line, "73:21:12".to_string()); } diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index a430204e158d4..d163f819cc62e 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -91,10 +91,7 @@ impl TestOptions { /// - `contract_id` is the id of the test contract, expressed as a relative path from the /// project root. /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn fuzz_runner(&self, contract_id: S, test_fn: S) -> TestRunner - where - S: Into, - { + pub fn fuzz_runner(&self, contract_id: &str, test_fn: &str) -> TestRunner { let fuzz_config = self.fuzz_config(contract_id, test_fn).clone(); let failure_persist_path = fuzz_config .failure_persist_dir @@ -116,10 +113,7 @@ impl TestOptions { /// - `contract_id` is the id of the test contract, expressed as a relative path from the /// project root. /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn invariant_runner(&self, contract_id: S, test_fn: S) -> TestRunner - where - S: Into, - { + pub fn invariant_runner(&self, contract_id: &str, test_fn: &str) -> TestRunner { let invariant = self.invariant_config(contract_id, test_fn); self.fuzzer_with_cases(invariant.runs, None) } @@ -131,10 +125,7 @@ impl TestOptions { /// - `contract_id` is the id of the test contract, expressed as a relative path from the /// project root. /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn fuzz_config(&self, contract_id: S, test_fn: S) -> &FuzzConfig - where - S: Into, - { + pub fn fuzz_config(&self, contract_id: &str, test_fn: &str) -> &FuzzConfig { self.inline_fuzz.get(contract_id, test_fn).unwrap_or(&self.fuzz) } @@ -145,10 +136,7 @@ impl TestOptions { /// - `contract_id` is the id of the test contract, expressed as a relative path from the /// project root. /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn invariant_config(&self, contract_id: S, test_fn: S) -> &InvariantConfig - where - S: Into, - { + pub fn invariant_config(&self, contract_id: &str, test_fn: &str) -> &InvariantConfig { self.inline_invariant.get(contract_id, test_fn).unwrap_or(&self.invariant) } diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 3e7b4616380a8..0a2f4d59301ea 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -4,10 +4,7 @@ use crate::{ config::runner, test_helpers::{COMPILED, PROJECT}, }; -use forge::{ - result::{SuiteResult, TestKind, TestResult}, - TestOptions, TestOptionsBuilder, -}; +use forge::{result::TestKind, TestOptions, TestOptionsBuilder}; use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_test_utils::Filter; @@ -16,17 +13,11 @@ async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); let mut runner = runner(); let result = runner.test_collect(&filter); - let suite_result: &SuiteResult = - result.get("inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); - let test_result: &TestResult = - suite_result.test_results.get("testInlineConfFuzz(uint8)").unwrap(); - match &test_result.kind { - TestKind::Fuzz { runs, .. } => { - assert_eq!(runs, &1024); - } - _ => { - unreachable!() - } + let suite_result = result.get("inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); + let test_result = suite_result.test_results.get("testInlineConfFuzz(uint8)").unwrap(); + match test_result.kind { + TestKind::Fuzz { runs, .. } => assert_eq!(runs, 1024), + _ => unreachable!(), } } @@ -44,24 +35,15 @@ async fn inline_config_run_invariant() { result.get(&format!("{ROOT}:InvariantInlineConf2")).expect("Result exists"); let test_result_1 = suite_result_1.test_results.get("invariant_neverFalse()").unwrap(); - let test_result_2 = suite_result_2.test_results.get("invariant_neverFalse()").unwrap(); - - match &test_result_1.kind { - TestKind::Invariant { runs, .. } => { - assert_eq!(runs, &333); - } - _ => { - unreachable!() - } + match test_result_1.kind { + TestKind::Invariant { runs, .. } => assert_eq!(runs, 333), + _ => unreachable!(), } - match &test_result_2.kind { - TestKind::Invariant { runs, .. } => { - assert_eq!(runs, &42); - } - _ => { - unreachable!() - } + let test_result_2 = suite_result_2.test_results.get("invariant_neverFalse()").unwrap(); + match test_result_2.kind { + TestKind::Invariant { runs, .. } => assert_eq!(runs, 42), + _ => unreachable!(), } } From bc821ef1530cd006b46446b494e8996c95afbf32 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:06:41 +0100 Subject: [PATCH 0767/1963] chore: don't panic when EVM fails in invariants (#7419) --- .../evm/evm/src/executors/invariant/error.rs | 83 +++++++++---------- .../evm/evm/src/executors/invariant/funcs.rs | 58 ++++++------- crates/evm/evm/src/executors/invariant/mod.rs | 15 ++-- crates/forge/src/runner.rs | 6 +- 4 files changed, 74 insertions(+), 88 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 47ebc877687f9..d46d6da2c289f 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -150,7 +150,7 @@ impl FailedInvariantCaseData { }; if self.shrink { - calls = self.try_shrinking(&calls, &executor).into_iter().cloned().collect(); + calls = self.try_shrinking(&calls, &executor)?.into_iter().cloned().collect(); } else { trace!(target: "forge::test", "Shrinking disabled."); } @@ -162,9 +162,8 @@ impl FailedInvariantCaseData { // Replay each call from the sequence until we break the invariant. for (sender, (addr, bytes)) in calls.iter() { - let call_result = executor - .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) - .expect("bad call to evm"); + let call_result = + executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; logs.extend(call_result.logs); traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); @@ -185,9 +184,8 @@ impl FailedInvariantCaseData { // Checks the invariant. if let Some(func) = &self.func { - let error_call_result = executor - .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) - .expect("bad call to evm"); + let error_call_result = + executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO)?; traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); @@ -210,10 +208,10 @@ impl FailedInvariantCaseData { calls: &[BasicTxDetails], use_calls: &[usize], curr_seq: Arc>>, - ) { + ) -> eyre::Result<()> { if curr_seq.read().len() == 1 { // if current sequence is already the smallest possible, just return - return; + return Ok(()); } let mut new_sequence = Vec::with_capacity(calls.len()); @@ -226,22 +224,19 @@ impl FailedInvariantCaseData { // If the new sequence is already longer than the known best, skip execution if new_sequence.len() >= curr_seq.read().len() { - return + return Ok(()); } } for (seq_idx, call_index) in new_sequence.iter().enumerate() { let (sender, (addr, bytes)) = &calls[*call_index]; - executor - .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) - .expect("bad call to evm"); + executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; // Checks the invariant. If we revert or fail before the last call, all the better. if let Some(func) = &self.func { - let mut call_result = executor - .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) - .expect("bad call to evm"); + let mut call_result = + executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO)?; let is_success = executor.is_raw_call_success( self.addr, Cow::Owned(call_result.state_changeset.take().unwrap()), @@ -257,6 +252,7 @@ impl FailedInvariantCaseData { } } } + Ok(()) } /// Tries to shrink the failure case to its smallest sequence of calls. @@ -266,21 +262,20 @@ impl FailedInvariantCaseData { &self, calls: &'a [BasicTxDetails], executor: &Executor, - ) -> Vec<&'a BasicTxDetails> { + ) -> eyre::Result> { trace!(target: "forge::test", "Shrinking."); // Special case test: the invariant is *unsatisfiable* - it took 0 calls to // break the invariant -- consider emitting a warning. if let Some(func) = &self.func { - let error_call_result = executor - .call_raw(CALLER, self.addr, func.clone(), U256::ZERO) - .expect("bad call to evm"); + let error_call_result = + executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO)?; if error_call_result.reverted { - return vec![]; + return Ok(vec![]); } } - let shrunk_call_indices = self.try_shrinking_recurse(calls, executor, 0, 0); + let shrunk_call_indices = self.try_shrinking_recurse(calls, executor, 0, 0)?; // We recreate the call sequence in the same order as they reproduce the failure, // otherwise we could end up with inverted sequence. @@ -289,7 +284,7 @@ impl FailedInvariantCaseData { // 2. Bob calls transferOwnership to Alice // 3. Alice calls acceptOwnership and test fails // we shrink to indices of [2, 1] and we recreate call sequence in same order. - shrunk_call_indices.iter().map(|idx| &calls[*idx]).collect() + Ok(shrunk_call_indices.iter().map(|idx| &calls[*idx]).collect()) } /// We try to construct a [powerset](https://en.wikipedia.org/wiki/Power_set) of the sequence if @@ -310,7 +305,7 @@ impl FailedInvariantCaseData { executor: &Executor, runs: usize, retries: usize, - ) -> Vec { + ) -> eyre::Result> { // Construct a ArcRwLock vector of indices of `calls` let shrunk_call_indices = Arc::new(RwLock::new((0..calls.len()).collect())); let shrink_limit = self.shrink_run_limit - runs; @@ -319,7 +314,7 @@ impl FailedInvariantCaseData { // We construct either a full powerset (this guarantees we maximally shrunk for the given // calls) or a random subset let (set_of_indices, is_powerset): (Vec<_>, bool) = if calls.len() <= 64 && - 2_usize.pow(calls.len() as u32) <= shrink_limit + (1 << calls.len() as u32) <= shrink_limit { // We add the last tx always because thats ultimately what broke the invariant let powerset = (0..upper_bound) @@ -357,14 +352,17 @@ impl FailedInvariantCaseData { let new_runs = set_of_indices.len(); // just try all of them in parallel - set_of_indices.par_iter().for_each(|use_calls| { - self.set_fails_successfully( - executor.clone(), - calls, - use_calls, - Arc::clone(&shrunk_call_indices), - ); - }); + set_of_indices + .par_iter() + .map(|use_calls| { + self.set_fails_successfully( + executor.clone(), + calls, + use_calls, + Arc::clone(&shrunk_call_indices), + ) + }) + .collect::>()?; // There are no more live references to shrunk_call_indices as the parallel execution is // finished, so it is fine to get the inner value via `Arc::unwrap`. @@ -372,7 +370,7 @@ impl FailedInvariantCaseData { if is_powerset { // A powerset is guaranteed to be smallest local subset, so we return early. - return shrunk_call_indices + return Ok(shrunk_call_indices); } let computation_budget_not_hit = new_runs + runs < self.shrink_run_limit; @@ -399,13 +397,8 @@ impl FailedInvariantCaseData { let new_calls: Vec<_> = calls .iter() .enumerate() - .filter_map(|(i, call)| { - if shrunk_call_indices.contains(&i) { - Some(call.clone()) - } else { - None - } - }) + .filter(|(i, _)| shrunk_call_indices.contains(i)) + .map(|(_, call)| call.clone()) .collect(); // We rerun this algorithm as if the new smaller subset above were the original @@ -415,13 +408,13 @@ impl FailedInvariantCaseData { // returns [1]. This means `call3` is all that is required to break // the invariant. let new_calls_idxs = - self.try_shrinking_recurse(&new_calls, executor, runs + new_runs, 0); + self.try_shrinking_recurse(&new_calls, executor, runs + new_runs, 0)?; // Notably, the indices returned above are relative to `new_calls`, *not* the // originally passed in `calls`. So we map back by filtering // `new_calls` by index if the index was returned above, and finding the position // of the `new_call` in the passed in `call` - new_calls + Ok(new_calls .iter() .enumerate() .filter_map(|(idx, new_call)| { @@ -431,12 +424,12 @@ impl FailedInvariantCaseData { calls.iter().position(|r| r == new_call) } }) - .collect() + .collect()) } _ => { // The computation budget has been hit or no retries remaining, stop trying to make // progress - shrunk_call_indices + Ok(shrunk_call_indices) } } } diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index 7f4694cdb0cb0..218f97e9234da 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -21,7 +21,7 @@ pub fn assert_invariants( invariant_failures: &mut InvariantFailures, shrink_sequence: bool, shrink_run_limit: usize, -) -> Option { +) -> eyre::Result> { let mut inner_sequence = vec![]; if let Some(fuzzer) = &executor.inspector.fuzzer { @@ -31,14 +31,12 @@ pub fn assert_invariants( } let func = invariant_contract.invariant_function; - let mut call_result = executor - .call_raw( - CALLER, - invariant_contract.address, - func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), - U256::ZERO, - ) - .expect("EVM error"); + let mut call_result = executor.call_raw( + CALLER, + invariant_contract.address, + func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), + U256::ZERO, + )?; let is_err = !executor.is_raw_call_success( invariant_contract.address, @@ -59,11 +57,11 @@ pub fn assert_invariants( shrink_run_limit, ); invariant_failures.error = Some(InvariantFuzzError::BrokenInvariant(case_data)); - return None + return Ok(None); } } - Some(call_result) + Ok(Some(call_result)) } /// Replays the provided invariant run for collecting the logs and traces from all depths. @@ -78,7 +76,7 @@ pub fn replay_run( coverage: &mut Option, func: Function, inputs: Vec, -) { +) -> eyre::Result<()> { // We want traces for a failed case. executor.set_tracing(true); @@ -86,25 +84,18 @@ pub fn replay_run( // Replay each call from the sequence until we break the invariant. for (sender, (addr, bytes)) in inputs.iter() { - let call_result = executor - .call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO) - .expect("bad call to evm"); + let call_result = + executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; logs.extend(call_result.logs); traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); - let old_coverage = std::mem::take(coverage); - match (old_coverage, call_result.coverage) { - (Some(old_coverage), Some(call_coverage)) => { - *coverage = Some(old_coverage.merge(call_coverage)); - } - (None, Some(call_coverage)) => { - *coverage = Some(call_coverage); + if let Some(new_coverage) = call_result.coverage { + if let Some(old_coverage) = coverage { + *coverage = Some(std::mem::take(old_coverage).merge(new_coverage)); + } else { + *coverage = Some(new_coverage); } - (Some(old_coverage), None) => { - *coverage = Some(old_coverage); - } - (None, None) => {} } // Identify newly generated contracts, if they exist. @@ -114,17 +105,16 @@ pub fn replay_run( )); // Checks the invariant. - let error_call_result = executor - .call_raw( - CALLER, - invariant_contract.address, - func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), - U256::ZERO, - ) - .expect("bad call to evm"); + let error_call_result = executor.call_raw( + CALLER, + invariant_contract.address, + func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), + U256::ZERO, + )?; traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); logs.extend(error_call_result.logs); } + Ok(()) } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 622b94bf74989..3d3f18200e2eb 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -184,7 +184,7 @@ impl<'a> InvariantExecutor<'a> { &mut failures.borrow_mut(), self.config.shrink_sequence, self.config.shrink_run_limit, - )); + )?); if last_call_results.borrow().is_none() { fuzz_cases.borrow_mut().push(FuzzedCases::new(vec![])); @@ -287,7 +287,8 @@ impl<'a> InvariantExecutor<'a> { self.config.shrink_sequence, self.config.shrink_run_limit, &mut run_traces, - ); + ) + .map_err(|e| TestCaseError::fail(e.to_string()))?; if !can_continue || current_run == self.config.depth - 1 { last_run_calldata.borrow_mut().clone_from(&inputs); @@ -706,7 +707,7 @@ fn can_continue( shrink_sequence: bool, shrink_run_limit: usize, run_traces: &mut Vec, -) -> RichInvariantResults { +) -> eyre::Result { let mut call_results = None; // Detect handler assertion failures first. @@ -727,9 +728,9 @@ fn can_continue( failures, shrink_sequence, shrink_run_limit, - ); + )?; if call_results.is_none() { - return RichInvariantResults::new(false, None) + return Ok(RichInvariantResults::new(false, None)); } } else { // Increase the amount of reverts. @@ -749,8 +750,8 @@ fn can_continue( let error = InvariantFuzzError::Revert(case_data); failures.error = Some(error); - return RichInvariantResults::new(false, None) + return Ok(RichInvariantResults::new(false, None)); } } - RichInvariantResults::new(true, call_results) + Ok(RichInvariantResults::new(true, call_results)) } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 494a02d8875af..3c9eee1ddaf50 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -545,7 +545,7 @@ impl<'a> ContractRunner<'a> { // If invariants ran successfully, replay the last run to collect logs and // traces. _ => { - replay_run( + if let Err(err) = replay_run( &invariant_contract, self.executor.clone(), known_contracts, @@ -555,7 +555,9 @@ impl<'a> ContractRunner<'a> { &mut coverage, func.clone(), last_run_inputs.clone(), - ); + ) { + error!(%err, "Failed to replay last invariant run"); + } } } From 63ea108478cb8372e578c2d6343e8bf243fccebf Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:06:46 +0100 Subject: [PATCH 0768/1963] refactor: simplify fuzzing code (#7420) * refactor: simplify fuzzing code * chore: use shl * chore: unlock earlier --- Cargo.lock | 1 - crates/evm/evm/src/executors/fuzz/mod.rs | 23 +-- crates/evm/evm/src/executors/invariant/mod.rs | 6 +- crates/evm/fuzz/Cargo.toml | 1 - crates/evm/fuzz/src/strategies/calldata.rs | 60 +++--- crates/evm/fuzz/src/strategies/invariants.rs | 151 ++++++--------- crates/evm/fuzz/src/strategies/param.rs | 183 ++++++++---------- crates/evm/fuzz/src/strategies/state.rs | 26 +-- 8 files changed, 185 insertions(+), 266 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd7a9fd7808be..ab4caf50ef2d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3462,7 +3462,6 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "arbitrary", "eyre", "foundry-common", "foundry-compilers", diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index dfb7b6c6050da..41beb7e433176 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -82,19 +82,11 @@ impl FuzzedExecutor { let state = self.build_fuzz_state(); - let mut weights = vec![]; let dictionary_weight = self.config.dictionary.dictionary_weight.min(100); - if self.config.dictionary.dictionary_weight < 100 { - weights.push((100 - dictionary_weight, fuzz_calldata(func.clone()))); - } - if dictionary_weight > 0 { - weights.push(( - self.config.dictionary.dictionary_weight, - fuzz_calldata_from_state(func.clone(), state.clone()), - )); - } - - let strat = proptest::strategy::Union::new_weighted(weights); + let strat = proptest::prop_oneof![ + 100 - dictionary_weight => fuzz_calldata(func.clone()), + dictionary_weight => fuzz_calldata_from_state(func.clone(), &state), + ]; debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(&state, address, should_fail, calldata)?; @@ -215,12 +207,7 @@ impl FuzzedExecutor { let state_changeset = call.state_changeset.take().unwrap(); // Build fuzzer state - collect_state_from_call( - &call.logs, - &state_changeset, - state.clone(), - &self.config.dictionary, - ); + collect_state_from_call(&call.logs, &state_changeset, state, &self.config.dictionary); // When the `assume` cheatcode is called it returns a special string if call.result.as_ref() == MAGIC_ASSUME { diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 3d3f18200e2eb..5ed7998ac3e1a 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -250,7 +250,7 @@ impl<'a> InvariantExecutor<'a> { &mut state_changeset, sender, &call_result, - fuzz_state.clone(), + &fuzz_state, &self.config.dictionary, ); @@ -369,7 +369,7 @@ impl<'a> InvariantExecutor<'a> { Arc::new(Mutex::new(targeted_contracts)); let calldata_fuzz_config = - CalldataFuzzDictionary::new(&self.config.dictionary, fuzz_state.clone()); + CalldataFuzzDictionary::new(&self.config.dictionary, &fuzz_state); // Creates the invariant strategy. let strat = invariant_strat( @@ -667,7 +667,7 @@ fn collect_data( state_changeset: &mut HashMap, sender: &Address, call_result: &RawCallResult, - fuzz_state: EvmFuzzState, + fuzz_state: &EvmFuzzState, config: &FuzzDictionaryConfig, ) { // Verify it has no code. diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 47b5787285149..d8c68428e6bda 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -31,7 +31,6 @@ revm = { workspace = true, default-features = false, features = [ "arbitrary", ] } -arbitrary = "1.3.1" eyre = "0.6" hashbrown = { version = "0.14", features = ["serde"] } itertools.workspace = true diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index cb56f3330b0dc..cf5030203eeaa 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -4,33 +4,27 @@ use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes}; use foundry_config::FuzzDictionaryConfig; use hashbrown::HashSet; -use proptest::prelude::{BoxedStrategy, Strategy}; -use std::{fmt, sync::Arc}; +use proptest::prelude::Strategy; +use std::sync::Arc; /// Clonable wrapper around [CalldataFuzzDictionary]. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct CalldataFuzzDictionary { pub inner: Arc, } impl CalldataFuzzDictionary { - pub fn new(config: &FuzzDictionaryConfig, state: EvmFuzzState) -> Self { + pub fn new(config: &FuzzDictionaryConfig, state: &EvmFuzzState) -> Self { Self { inner: Arc::new(CalldataFuzzDictionaryConfig::new(config, state)) } } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct CalldataFuzzDictionaryConfig { /// Addresses that can be used for fuzzing calldata. pub addresses: Vec
, } -impl fmt::Debug for CalldataFuzzDictionaryConfig { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("CalldataFuzzDictionaryConfig").field("addresses", &self.addresses).finish() - } -} - /// Represents custom configuration for invariant fuzzed calldata strategies. /// /// At the moment only the dictionary of addresses to be used for a fuzzed `function(address)` can @@ -41,30 +35,23 @@ impl CalldataFuzzDictionaryConfig { /// The set of addresses contains a number of `max_calldata_fuzz_dictionary_addresses` random /// addresses plus all addresses that already had their PUSH bytes collected (retrieved from /// `EvmFuzzState`, if `include_push_bytes` config enabled). - pub fn new(config: &FuzzDictionaryConfig, state: EvmFuzzState) -> Self { - let mut addresses: HashSet
= HashSet::new(); - let dict_size = config.max_calldata_fuzz_dictionary_addresses; + pub fn new(config: &FuzzDictionaryConfig, state: &EvmFuzzState) -> Self { + let mut addresses = HashSet::
::new(); + let dict_size = config.max_calldata_fuzz_dictionary_addresses; if dict_size > 0 { - loop { - if addresses.len() == dict_size { - break - } - addresses.insert(Address::random()); - } - + addresses.extend(std::iter::repeat_with(Address::random).take(dict_size)); // Add all addresses that already had their PUSH bytes collected. - let mut state = state.write(); - addresses.extend(state.addresses()); + addresses.extend(state.read().addresses()); } - Self { addresses: Vec::from_iter(addresses) } + Self { addresses: addresses.into_iter().collect() } } } /// Given a function, it returns a strategy which generates valid calldata /// for that function's input types. -pub fn fuzz_calldata(func: Function) -> BoxedStrategy { +pub fn fuzz_calldata(func: Function) -> impl Strategy { fuzz_calldata_with_config(func, None) } @@ -72,20 +59,23 @@ pub fn fuzz_calldata(func: Function) -> BoxedStrategy { /// for that function's input types, following custom configuration rules. pub fn fuzz_calldata_with_config( func: Function, - config: Option, -) -> BoxedStrategy { + config: Option<&CalldataFuzzDictionary>, +) -> impl Strategy { // We need to compose all the strategies generated for each parameter in all // possible combinations let strats = func .inputs .iter() - .map(|input| fuzz_param(&input.selector_type().parse().unwrap(), config.clone())) + .map(|input| fuzz_param(&input.selector_type().parse().unwrap(), config)) .collect::>(); - - strats - .prop_map(move |tokens| { - trace!(input=?tokens); - func.abi_encode_input(&tokens).unwrap().into() - }) - .boxed() + strats.prop_map(move |values| { + func.abi_encode_input(&values) + .unwrap_or_else(|_| { + panic!( + "Fuzzer generated invalid arguments for function `{}` with inputs {:?}: {:?}", + func.name, func.inputs, values + ) + }) + .into() + }) } diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index e6dedc9cd8dd5..5fd766bb4f795 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -17,27 +17,18 @@ pub fn override_call_strat( calldata_fuzz_config: CalldataFuzzDictionary, ) -> SBoxedStrategy<(Address, Bytes)> { let contracts_ref = contracts.clone(); - - let random_contract = any::() - .prop_map(move |selector| *selector.select(contracts_ref.lock().keys())); - let target = any::().prop_map(move |_| *target.read()); - - proptest::strategy::Union::new_weighted(vec![ - (80, target.sboxed()), - (20, random_contract.sboxed()), - ]) + proptest::prop_oneof![ + 80 => proptest::strategy::LazyJust::new(move || *target.read()), + 20 => any::() + .prop_map(move |selector| *selector.select(contracts_ref.lock().keys())), + ] .prop_flat_map(move |target_address| { let fuzz_state = fuzz_state.clone(); let calldata_fuzz_config = calldata_fuzz_config.clone(); - let (_, abi, functions) = contracts.lock().get(&target_address).unwrap().clone(); + let (_, abi, functions) = &contracts.lock()[&target_address]; let func = select_random_function(abi, functions); func.prop_flat_map(move |func| { - fuzz_contract_with_calldata( - fuzz_state.clone(), - calldata_fuzz_config.clone(), - target_address, - func, - ) + fuzz_contract_with_calldata(&fuzz_state, &calldata_fuzz_config, target_address, func) }) }) .sboxed() @@ -74,26 +65,27 @@ fn generate_call( dictionary_weight: u32, calldata_fuzz_config: CalldataFuzzDictionary, ) -> BoxedStrategy { - let random_contract = select_random_contract(contracts); let senders = Rc::new(senders); - random_contract - .prop_flat_map(move |(contract, abi, functions)| { - let func = select_random_function(abi, functions); + any::() + .prop_flat_map(move |selector| { + let (contract, func) = { + let contracts = contracts.lock(); + let contracts = + contracts.iter().filter(|(_, (_, abi, _))| !abi.functions.is_empty()); + let (&contract, (_, abi, functions)) = selector.select(contracts); + + let func = select_random_function(abi, functions); + (contract, func) + }; + let senders = senders.clone(); let fuzz_state = fuzz_state.clone(); let calldata_fuzz_config = calldata_fuzz_config.clone(); func.prop_flat_map(move |func| { - let sender = - select_random_sender(fuzz_state.clone(), senders.clone(), dictionary_weight); - ( - sender, - fuzz_contract_with_calldata( - fuzz_state.clone(), - calldata_fuzz_config.clone(), - contract, - func, - ), - ) + let sender = select_random_sender(&fuzz_state, senders.clone(), dictionary_weight); + let contract = + fuzz_contract_with_calldata(&fuzz_state, &calldata_fuzz_config, contract, func); + (sender, contract) }) }) .boxed() @@ -103,78 +95,55 @@ fn generate_call( /// * If `senders` is empty, then it's either a random address (10%) or from the dictionary (90%). /// * If `senders` is not empty, a random address is chosen from the list of senders. fn select_random_sender( - fuzz_state: EvmFuzzState, + fuzz_state: &EvmFuzzState, senders: Rc, dictionary_weight: u32, ) -> BoxedStrategy
{ - let senders_ref = senders.clone(); - let fuzz_strategy = proptest::strategy::Union::new_weighted(vec![ - ( - 100 - dictionary_weight, - fuzz_param(&alloy_dyn_abi::DynSolType::Address, None) - .prop_map(move |addr| addr.as_address().unwrap()) - .boxed(), - ), - ( - dictionary_weight, - fuzz_param_from_state(&alloy_dyn_abi::DynSolType::Address, fuzz_state) - .prop_map(move |addr| addr.as_address().unwrap()) - .boxed(), - ), - ]) - // Too many exclusions can slow down testing. - .prop_filter("senders not allowed", move |addr| !senders_ref.excluded.contains(addr)) - .boxed(); if !senders.targeted.is_empty() { any::() - .prop_map(move |selector| *selector.select(&*senders.targeted)) + .prop_map(move |selector| *selector.select(&senders.targeted)) .boxed() } else { - fuzz_strategy + proptest::prop_oneof![ + 100 - dictionary_weight => fuzz_param(&alloy_dyn_abi::DynSolType::Address, None) + .prop_map(move |addr| addr.as_address().unwrap()) + .boxed(), + dictionary_weight => fuzz_param_from_state(&alloy_dyn_abi::DynSolType::Address, fuzz_state) + .prop_map(move |addr| addr.as_address().unwrap()) + .boxed(), + ] + // Too many exclusions can slow down testing. + .prop_filter("excluded sender", move |addr| !senders.excluded.contains(addr)) + .boxed() } } -/// Strategy to randomly select a contract from the `contracts` list that has at least 1 function -fn select_random_contract( - contracts: FuzzRunIdentifiedContracts, -) -> impl Strategy)> { - let selectors = any::(); - selectors.prop_map(move |selector| { - let contracts = contracts.lock(); - let (addr, (_, abi, functions)) = - selector.select(contracts.iter().filter(|(_, (_, abi, _))| !abi.functions.is_empty())); - (*addr, abi.clone(), functions.clone()) - }) -} - /// Strategy to select a random mutable function from the abi. /// /// If `targeted_functions` is not empty, select one from it. Otherwise, take any /// of the available abi functions. fn select_random_function( - abi: JsonAbi, - targeted_functions: Vec, + abi: &JsonAbi, + targeted_functions: &[Function], ) -> BoxedStrategy { - let selectors = any::(); - let possible_funcs: Vec = abi - .functions() - .filter(|func| { - !matches!( - func.state_mutability, - alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View - ) - }) - .cloned() - .collect(); - let total_random = selectors.prop_map(move |selector| { - let func = selector.select(&possible_funcs); - func.clone() - }); if !targeted_functions.is_empty() { + let targeted_functions = targeted_functions.to_vec(); let selector = any::() - .prop_map(move |selector| selector.select(targeted_functions.clone())); + .prop_map(move |selector| selector.select(&targeted_functions).clone()); selector.boxed() } else { + let possible_funcs: Vec = abi + .functions() + .filter(|&func| { + !matches!( + func.state_mutability, + alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View + ) + }) + .cloned() + .collect(); + let total_random = any::() + .prop_map(move |selector| selector.select(&possible_funcs).clone()); total_random.boxed() } } @@ -182,20 +151,20 @@ fn select_random_function( /// Given a function, it returns a proptest strategy which generates valid abi-encoded calldata /// for that function's input types. pub fn fuzz_contract_with_calldata( - fuzz_state: EvmFuzzState, - calldata_fuzz_config: CalldataFuzzDictionary, + fuzz_state: &EvmFuzzState, + calldata_fuzz_config: &CalldataFuzzDictionary, contract: Address, func: Function, ) -> impl Strategy { - // We need to compose all the strategies generated for each parameter in all - // possible combinations - // `prop_oneof!` / `TupleUnion` `Arc`s for cheap cloning + // We need to compose all the strategies generated for each parameter in all possible + // combinations. + // `prop_oneof!` / `TupleUnion` `Arc`s for cheap cloning. #[allow(clippy::arc_with_non_send_sync)] - let strats = prop_oneof![ + prop_oneof![ 60 => fuzz_calldata_with_config(func.clone(), Some(calldata_fuzz_config)), 40 => fuzz_calldata_from_state(func, fuzz_state), - ]; - strats.prop_map(move |calldata| { + ] + .prop_map(move |calldata| { trace!(input=?calldata); (contract, calldata) }) diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 4c8dc03eca9e7..f287c75dfde11 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -1,8 +1,7 @@ use super::state::EvmFuzzState; use crate::strategies::calldata::CalldataFuzzDictionary; use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::{Address, FixedBytes, I256, U256}; -use arbitrary::Unstructured; +use alloy_primitives::{Address, B256, I256, U256}; use proptest::prelude::*; /// The max length of arrays we fuzz for is 256. @@ -13,79 +12,67 @@ const MAX_ARRAY_LEN: usize = 256; /// Works with ABI Encoder v2 tuples. pub fn fuzz_param( param: &DynSolType, - config: Option, + config: Option<&CalldataFuzzDictionary>, ) -> BoxedStrategy { - let param = param.to_owned(); - match param { + match *param { DynSolType::Address => { - if config.is_some() { - let fuzz_config = config.unwrap().inner; - let address_dict_len = fuzz_config.addresses.len(); - if address_dict_len > 0 { + if let Some(config) = config { + let len = config.inner.addresses.len(); + if len > 0 { + let dict = config.inner.clone(); // Create strategy to return random address from configured dictionary. return any::() - .prop_map(move |index| index.index(address_dict_len)) .prop_map(move |index| { - DynSolValue::Address(fuzz_config.addresses.get(index).cloned().unwrap()) + let index = index.index(len); + DynSolValue::Address(dict.addresses[index]) }) - .boxed() + .boxed(); } } // If no config for addresses dictionary then create unbounded addresses strategy. - any::<[u8; 32]>() - .prop_map(|x| DynSolValue::Address(Address::from_word(x.into()))) - .boxed() + any::
().prop_map(DynSolValue::Address).boxed() } - DynSolType::Int(n) => { - let strat = super::IntStrategy::new(n, vec![]); - let strat = strat.prop_map(move |x| DynSolValue::Int(x, n)); - strat.boxed() + DynSolType::Int(n @ 8..=256) => { + super::IntStrategy::new(n, vec![]).prop_map(move |x| DynSolValue::Int(x, n)).boxed() } - DynSolType::Uint(n) => { - let strat = super::UintStrategy::new(n, vec![]); - let strat = strat.prop_map(move |x| DynSolValue::Uint(x, n)); - strat.boxed() + DynSolType::Uint(n @ 8..=256) => { + super::UintStrategy::new(n, vec![]).prop_map(move |x| DynSolValue::Uint(x, n)).boxed() } DynSolType::Function | DynSolType::Bool | DynSolType::Bytes => { - DynSolValue::type_strategy(¶m).boxed() + DynSolValue::type_strategy(param).boxed() } - DynSolType::FixedBytes(size) => prop::collection::vec(any::(), size) + DynSolType::FixedBytes(size @ 1..=32) => any::() .prop_map(move |mut v| { - v.reverse(); - while v.len() < 32 { - v.push(0); - } - DynSolValue::FixedBytes(FixedBytes::from_slice(&v), size) + v[size..].fill(0); + DynSolValue::FixedBytes(v, size) }) .boxed(), - DynSolType::String => DynSolValue::type_strategy(¶m) + DynSolType::String => DynSolValue::type_strategy(param) .prop_map(move |value| { DynSolValue::String( - String::from_utf8_lossy(value.as_str().unwrap().as_bytes()) - .trim() - .trim_end_matches('\0') - .to_string(), + value.as_str().unwrap().trim().trim_end_matches('\0').to_string(), ) }) .boxed(), - DynSolType::Tuple(params) => params + + DynSolType::Tuple(ref params) => params .iter() - .map(|p| fuzz_param(p, config.clone())) + .map(|p| fuzz_param(p, config)) .collect::>() .prop_map(DynSolValue::Tuple) .boxed(), - DynSolType::FixedArray(param, size) => { - proptest::collection::vec(fuzz_param(¶m, config), size) + DynSolType::FixedArray(ref param, size) => { + proptest::collection::vec(fuzz_param(param, config), size) .prop_map(DynSolValue::FixedArray) .boxed() } - DynSolType::Array(param) => { - proptest::collection::vec(fuzz_param(¶m, config), 0..MAX_ARRAY_LEN) + DynSolType::Array(ref param) => { + proptest::collection::vec(fuzz_param(param, config), 0..MAX_ARRAY_LEN) .prop_map(DynSolValue::Array) .boxed() } - DynSolType::CustomStruct { .. } => panic!("unsupported type"), + _ => panic!("unsupported fuzz param type: {param}"), } } @@ -95,99 +82,93 @@ pub fn fuzz_param( /// Works with ABI Encoder v2 tuples. pub fn fuzz_param_from_state( param: &DynSolType, - arc_state: EvmFuzzState, + state: &EvmFuzzState, ) -> BoxedStrategy { - // These are to comply with lifetime requirements - let state_len = arc_state.read().values().len(); - - // Select a value from the state - let st = arc_state.clone(); - let value = any::() - .prop_map(move |index| index.index(state_len)) - .prop_map(move |index| *st.read().values().iter().nth(index).unwrap()); - let param = param.to_owned(); + // Value strategy that uses the state. + let value = || { + let state = state.clone(); + // Use `Index` instead of `Selector` to not iterate over the entire dictionary. + any::().prop_map(move |index| { + let state = state.read(); + let values = state.values(); + let index = index.index(values.len()); + *values.iter().nth(index).unwrap() + }) + }; // Convert the value based on the parameter type - match param { - DynSolType::Address => value + match *param { + DynSolType::Address => value() .prop_map(move |value| DynSolValue::Address(Address::from_word(value.into()))) .boxed(), - DynSolType::FixedBytes(size) => value - .prop_map(move |v| { - let mut buf: [u8; 32] = [0; 32]; - - for b in v[..size].iter().enumerate() { - buf[b.0] = *b.1 - } - - let mut unstructured_v = Unstructured::new(v.as_slice()); - DynSolValue::arbitrary_from_type(¶m, &mut unstructured_v) - .unwrap_or(DynSolValue::FixedBytes(FixedBytes::from_slice(&buf), size)) + DynSolType::Function => value() + .prop_map(move |value| { + DynSolValue::Function(alloy_primitives::Function::from_word(value.into())) + }) + .boxed(), + DynSolType::FixedBytes(size @ 1..=32) => value() + .prop_map(move |mut v| { + v[size..].fill(0); + DynSolValue::FixedBytes(B256::from(v), size) }) .boxed(), - DynSolType::Function | DynSolType::Bool => DynSolValue::type_strategy(¶m).boxed(), - DynSolType::String => DynSolValue::type_strategy(¶m) + DynSolType::Bool => DynSolValue::type_strategy(param).boxed(), + DynSolType::String => DynSolValue::type_strategy(param) .prop_map(move |value| { DynSolValue::String( - String::from_utf8_lossy(value.as_str().unwrap().as_bytes()) - .trim() - .trim_end_matches('\0') - .to_string(), + value.as_str().unwrap().trim().trim_end_matches('\0').to_string(), ) }) .boxed(), - DynSolType::Int(n) => match n / 8 { - 32 => value + DynSolType::Bytes => { + value().prop_map(move |value| DynSolValue::Bytes(value.into())).boxed() + } + DynSolType::Int(n @ 8..=256) => match n / 8 { + 32 => value() .prop_map(move |value| { DynSolValue::Int(I256::from_raw(U256::from_be_bytes(value)), 256) }) .boxed(), - y @ 1..=31 => value + 1..=31 => value() .prop_map(move |value| { // Generate a uintN in the correct range, then shift it to the range of intN // by subtracting 2^(N-1) - let uint = - U256::from_be_bytes(value) % U256::from(2usize).pow(U256::from(y * 8)); - let max_int_plus1 = U256::from(2usize).pow(U256::from(y * 8 - 1)); - let num = I256::from_raw(uint.overflowing_sub(max_int_plus1).0); - DynSolValue::Int(num, y * 8) + let uint = U256::from_be_bytes(value) % U256::from(1).wrapping_shl(n); + let max_int_plus1 = U256::from(1).wrapping_shl(n - 1); + let num = I256::from_raw(uint.wrapping_sub(max_int_plus1)); + DynSolValue::Int(num, n) }) .boxed(), - _ => panic!("unsupported solidity type int{n}"), + _ => unreachable!(), }, - DynSolType::Uint(n) => match n / 8 { - 32 => value + DynSolType::Uint(n @ 8..=256) => match n / 8 { + 32 => value() .prop_map(move |value| DynSolValue::Uint(U256::from_be_bytes(value), 256)) .boxed(), - y @ 1..=31 => value + 1..=31 => value() .prop_map(move |value| { - DynSolValue::Uint( - U256::from_be_bytes(value) % U256::from(2).pow(U256::from(y * 8)), - y * 8, - ) + DynSolValue::Uint(U256::from_be_bytes(value) % U256::from(1).wrapping_shl(n), n) }) .boxed(), - _ => panic!("unsupported solidity type uint{n}"), + _ => unreachable!(), }, - DynSolType::Tuple(params) => params + DynSolType::Tuple(ref params) => params .iter() - .map(|p| fuzz_param_from_state(p, arc_state.clone())) + .map(|p| fuzz_param_from_state(p, state)) .collect::>() .prop_map(DynSolValue::Tuple) .boxed(), - DynSolType::Bytes => value.prop_map(move |value| DynSolValue::Bytes(value.into())).boxed(), - DynSolType::FixedArray(param, size) => { - let fixed_size = size; - proptest::collection::vec(fuzz_param_from_state(¶m, arc_state), fixed_size) + DynSolType::FixedArray(ref param, size) => { + proptest::collection::vec(fuzz_param_from_state(param, state), size) .prop_map(DynSolValue::FixedArray) .boxed() } - DynSolType::Array(param) => { - proptest::collection::vec(fuzz_param_from_state(¶m, arc_state), 0..MAX_ARRAY_LEN) + DynSolType::Array(ref param) => { + proptest::collection::vec(fuzz_param_from_state(param, state), 0..MAX_ARRAY_LEN) .prop_map(DynSolValue::Array) .boxed() } - DynSolType::CustomStruct { .. } => panic!("unsupported type"), + _ => panic!("unsupported fuzz param type: {param}"), } } @@ -204,10 +185,10 @@ mod tests { let func = get_func(f).unwrap(); let db = CacheDB::new(EmptyDB::default()); let state = build_initial_state(&db, &FuzzDictionaryConfig::default()); - let strat = proptest::strategy::Union::new_weighted(vec![ - (60, fuzz_calldata(func.clone())), - (40, fuzz_calldata_from_state(func, state)), - ]); + let strat = proptest::prop_oneof![ + 60 => fuzz_calldata(func.clone()), + 40 => fuzz_calldata_from_state(func, &state), + ]; let cfg = proptest::test_runner::Config { failure_persistence: None, ..Default::default() }; let mut runner = proptest::test_runner::TestRunner::new(cfg); let _ = runner.run(&strat, |_| Ok(())); diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index cf2f6ec6e8a35..1d959ccc70010 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,6 +1,6 @@ use super::fuzz_param_from_state; use crate::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}; -use alloy_dyn_abi::{DynSolType, JsonAbiExt}; +use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log, B256, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; @@ -14,7 +14,7 @@ use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::SpecId, }; -use std::{fmt, str::FromStr, sync::Arc}; +use std::{fmt, sync::Arc}; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// @@ -50,7 +50,7 @@ impl FuzzDictionary { } #[inline] - pub fn addresses(&mut self) -> &HashSet
{ + pub fn addresses(&self) -> &HashSet
{ &self.addresses } @@ -62,25 +62,19 @@ impl FuzzDictionary { /// Given a function and some state, it returns a strategy which generated valid calldata for the /// given function's input types, based on state taken from the EVM. -pub fn fuzz_calldata_from_state(func: Function, state: EvmFuzzState) -> BoxedStrategy { +pub fn fuzz_calldata_from_state(func: Function, state: &EvmFuzzState) -> BoxedStrategy { let strats = func .inputs .iter() - .map(|input| { - fuzz_param_from_state( - &DynSolType::from_str(&input.selector_type()).unwrap(), - state.clone(), - ) - }) + .map(|input| fuzz_param_from_state(&input.selector_type().parse().unwrap(), state)) .collect::>(); - strats - .prop_map(move |tokens| { - func.abi_encode_input(&tokens) + .prop_map(move |values| { + func.abi_encode_input(&values) .unwrap_or_else(|_| { panic!( - "Fuzzer generated invalid tokens for function `{}` with inputs {:?}: {:?}", - func.name, func.inputs, tokens + "Fuzzer generated invalid arguments for function `{}` with inputs {:?}: {:?}", + func.name, func.inputs, values ) }) .into() @@ -145,7 +139,7 @@ pub fn build_initial_state( pub fn collect_state_from_call( logs: &[Log], state_changeset: &StateChangeset, - state: EvmFuzzState, + state: &EvmFuzzState, config: &FuzzDictionaryConfig, ) { let mut state = state.write(); From 125988ce28b365eb59c64a032bf3369f90db3a96 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 18 Mar 2024 23:14:07 +0100 Subject: [PATCH 0769/1963] fix: check for cancun in cast run (#7434) --- crates/cast/bin/cmd/run.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 8de966906791f..83cbf5743904c 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -117,16 +117,18 @@ impl RunArgs { .ok_or_else(|| eyre::eyre!("tx may still be pending: {:?}", tx_hash))? .to::(); + // fetch the block the transaction was mined in + let block = provider.get_block(tx_block_number.into(), true).await?; + // we need to fork off the parent block config.fork_block_number = Some(tx_block_number - 1); let (mut env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; - let mut executor = TracingExecutor::new(env.clone(), fork, self.evm_version, self.debug); + let mut evm_version = self.evm_version; env.block.number = U256::from(tx_block_number); - let block = provider.get_block(tx_block_number.into(), true).await?; if let Some(ref block) = block { env.block.timestamp = block.header.timestamp; env.block.coinbase = block.header.miner; @@ -134,8 +136,18 @@ impl RunArgs { env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default(); env.block.gas_limit = block.header.gas_limit; + + // TODO: we need a smarter way to map the block to the corresponding evm_version for + // commonly used chains + if evm_version.is_none() { + // if the block has the excess_blob_gas field, we assume it's a Cancun block + if block.header.excess_blob_gas.is_some() { + evm_version = Some(EvmVersion::Cancun); + } + } } + let mut executor = TracingExecutor::new(env.clone(), fork, evm_version, self.debug); let mut env = EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), executor.spec_id()); From 0026488754512acf0fd902a0d2c90cf8a09367b0 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 18 Mar 2024 23:26:49 +0100 Subject: [PATCH 0770/1963] fix: allow fork related cli args without forkurl (#7432) --- crates/common/src/evm.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 7b915891386b5..a0cc4d4b802f3 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -118,13 +118,7 @@ pub struct EvmArgs { /// default value: 330 /// /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second - #[arg( - long, - requires = "fork_url", - alias = "cups", - value_name = "CUPS", - help_heading = "Fork config" - )] + #[arg(long, alias = "cups", value_name = "CUPS", help_heading = "Fork config")] pub compute_units_per_second: Option, /// Disables rate limiting for this node's provider. @@ -132,7 +126,6 @@ pub struct EvmArgs { /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[arg( long, - requires = "fork_url", value_name = "NO_RATE_LIMITS", help_heading = "Fork config", visible_alias = "no-rate-limit" From af8685f49e8c00f2302875cb5cfbfedf96e50042 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 19 Mar 2024 18:36:29 +0100 Subject: [PATCH 0771/1963] fix: ignore build info in forge bind (#7444) --- crates/forge/bin/cmd/bind.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index ca76aafa0eee7..5be0f262a1a21 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -143,7 +143,7 @@ impl BindArgs { "console[2]?", "CommonBase", "Components", - "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Storage(Safe)?)", + "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Toml|Storage(Safe)?)", "[Vv]m.*", ]) .extend_names(["IMulticall3"]) @@ -155,6 +155,10 @@ impl BindArgs { let abigens = json_files(artifacts.as_ref()) .into_iter() .filter_map(|path| { + if path.to_string_lossy().contains("/build-info/") { + // ignore the build info json + return None + } // we don't want `.metadata.json files let stem = path.file_stem()?; if stem.to_str()?.ends_with(".metadata") { From a064b63e7f7ea6c312a1e8aebf06379b5c2ab9bf Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Mar 2024 19:04:39 +0100 Subject: [PATCH 0772/1963] perf: load TLS certs only for https (#7450) --- .../common/src/provider/runtime_transport.rs | 4 ++- crates/config/src/etherscan.rs | 36 ++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 5c2eededfcb02..48411a321f1d9 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -144,7 +144,9 @@ impl RuntimeTransport { /// Connects to an HTTP [alloy_transport_http::Http] transport. async fn connect_http(&self) -> Result { - let mut client_builder = reqwest::Client::builder().timeout(self.timeout); + let mut client_builder = reqwest::Client::builder() + .timeout(self.timeout) + .tls_built_in_root_certs(self.url.scheme() == "https"); let mut headers = reqwest::header::HeaderMap::new(); // If there's a JWT, add it to the headers if we can decode it. diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 6e2030cb968b0..fb254a6357d8e 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -306,32 +306,29 @@ impl ResolvedEtherscanConfig { let (mainnet_api, mainnet_url) = NamedChain::Mainnet.etherscan_urls().expect("exist; qed"); let cache = chain - .or_else(|| { - if api_url == mainnet_api { - // try to match against mainnet, which is usually the most common target - Some(NamedChain::Mainnet.into()) - } else { - None - } - }) + // try to match against mainnet, which is usually the most common target + .or_else(|| (api_url == mainnet_api).then(Chain::mainnet)) .and_then(Config::foundry_etherscan_chain_cache_dir); - if let Some(ref cache_path) = cache { + if let Some(cache_path) = &cache { // we also create the `sources` sub dir here if let Err(err) = std::fs::create_dir_all(cache_path.join("sources")) { warn!("could not create etherscan cache dir: {:?}", err); } } + let api_url = into_url(&api_url)?; + let client = reqwest::Client::builder() + .user_agent(ETHERSCAN_USER_AGENT) + .tls_built_in_root_certs(api_url.scheme() == "https") + .build()?; foundry_block_explorers::Client::builder() - .with_client(reqwest::Client::builder().user_agent(ETHERSCAN_USER_AGENT).build()?) + .with_client(client) .with_api_key(api_key) - .with_api_url(api_url.as_str())? - .with_url( - // the browser url is not used/required by the client so we can simply set the - // mainnet browser url here - browser_url.as_deref().unwrap_or(mainnet_url), - )? + .with_api_url(api_url)? + // the browser url is not used/required by the client so we can simply set the + // mainnet browser url here + .with_url(browser_url.as_deref().unwrap_or(mainnet_url))? .with_cache(cache, Duration::from_secs(24 * 60 * 60)) .build() } @@ -419,6 +416,13 @@ impl fmt::Display for EtherscanApiKey { } } +/// This is a hack to work around `IntoUrl`'s sealed private functions, which can't be called +/// normally. +#[inline] +fn into_url(url: impl reqwest::IntoUrl) -> std::result::Result { + url.into_url() +} + #[cfg(test)] mod tests { use super::*; From ffed0deb6377f3682c6261fd52f24a6d203d0fa5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Mar 2024 19:13:44 +0100 Subject: [PATCH 0773/1963] chore: provide a better error message for unknown cheatcodes (#7436) --- crates/cheatcodes/src/inspector.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index bf39684b4955f..699840d9325ac 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -222,7 +222,17 @@ impl Cheatcodes { call: &CallInputs, ) -> Result { // decode the cheatcode call - let decoded = Vm::VmCalls::abi_decode(&call.input, false)?; + let decoded = Vm::VmCalls::abi_decode(&call.input, false).map_err(|e| { + if let alloy_sol_types::Error::UnknownSelector { name: _, selector } = e { + let msg = format!( + "unknown cheatcode with selector {selector}; \ + you may have a mismatch between the `Vm` interface (likely in `forge-std`) \ + and the `forge` version" + ); + return alloy_sol_types::Error::Other(std::borrow::Cow::Owned(msg)); + } + e + })?; let caller = call.context.caller; // ensure the caller is allowed to execute cheatcodes, From a527c1c622e6929f67c5c71c082a79957de9103b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Mar 2024 19:50:59 +0100 Subject: [PATCH 0774/1963] chore: abstract away hashbrown (#7395) * chore: abstract away hashbrown * deps * fix * log * fix: use indexset * test * test --- Cargo.lock | 5 ++-- Cargo.toml | 11 ++----- crates/anvil/src/eth/backend/cheats.rs | 3 +- crates/anvil/src/eth/backend/db.rs | 4 +-- crates/anvil/src/eth/backend/mem/state.rs | 13 ++++---- crates/config/Cargo.toml | 2 +- crates/evm/core/src/backend/snapshot.rs | 8 ++--- crates/evm/evm/Cargo.toml | 8 ++--- crates/evm/evm/src/lib.rs | 8 ++++- crates/evm/fuzz/Cargo.toml | 3 +- crates/evm/fuzz/src/strategies/calldata.rs | 3 +- crates/evm/fuzz/src/strategies/state.rs | 18 ++++++----- crates/evm/traces/Cargo.toml | 1 - .../evm/traces/src/identifier/signatures.rs | 7 +++-- crates/forge/bin/cmd/remappings.rs | 9 +++--- crates/forge/src/gas_report.rs | 6 ++-- crates/forge/tests/it/fuzz.rs | 4 +-- crates/forge/tests/it/invariant.rs | 30 ++++++++++--------- crates/verify/src/etherscan/mod.rs | 3 +- 19 files changed, 76 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab4caf50ef2d6..29154610ad228 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3392,7 +3392,6 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-fuzz", "foundry-evm-traces", - "hashbrown 0.14.3", "itertools 0.12.1", "parking_lot", "proptest", @@ -3469,12 +3468,13 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "hashbrown 0.14.3", + "indexmap", "itertools 0.12.1", "parking_lot", "proptest", "rand 0.8.5", "revm", + "rustc-hash", "serde", "thiserror", "tracing", @@ -3496,7 +3496,6 @@ dependencies = [ "foundry-config", "foundry-evm-core", "futures", - "hashbrown 0.14.3", "itertools 0.12.1", "once_cell", "revm-inspectors", diff --git a/Cargo.toml b/Cargo.toml index ab21bddfc5c06..e8dac00dbb350 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -143,8 +143,8 @@ foundry-compilers = { version = "0.3.13", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "7.1", default-features = false } -revm-primitives = { version = "3", default-features = false } +revm = { version = "7.1", default-features = false, features = ["std"] } +revm-primitives = { version = "3", default-features = false, features = ["std"] } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ba0b6ab", features = [ "serde", ] } @@ -207,14 +207,9 @@ toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" vergen = { version = "8", default-features = false } +indexmap = "2.2" axum = "0.6" hyper = "0.14" tower = "0.4" tower-http = "0.4" - -# [patch.crates-io] -# revm = { path = "../../danipopes/revm/crates/revm" } -# revm-interpreter = { path = "../../danipopes/revm/crates/interpreter" } -# revm-primitives = { path = "../../danipopes/revm/crates/primitives" } -# revm-precompile = { path = "../../danipopes/revm/crates/precompile" } diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 949ea10e7a332..0dc3189b07eb4 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -2,9 +2,8 @@ use alloy_primitives::{Address, Signature}; use anvil_core::eth::transaction::impersonated_signature; -use foundry_evm::hashbrown::HashSet; use parking_lot::RwLock; -use std::sync::Arc; +use std::{collections::HashSet, sync::Arc}; /// Manages user modifications that may affect the node's behavior /// diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 2630d19a7663b..31e60ddbe4f50 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -8,10 +8,9 @@ use foundry_common::errors::FsPathError; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot}, fork::BlockchainDb, - hashbrown::HashMap, revm::{ db::{CacheDB, DatabaseRef, DbAccount}, - primitives::{BlockEnv, Bytecode, KECCAK_EMPTY}, + primitives::{BlockEnv, Bytecode, HashMap, KECCAK_EMPTY}, Database, DatabaseCommit, }, }; @@ -225,6 +224,7 @@ impl> MaybeHashDatabase for CacheDB { fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { Some(trie_hash_db(&self.accounts)) } + fn clear_into_snapshot(&mut self) -> StateSnapshot { let db_accounts = std::mem::take(&mut self.accounts); let mut accounts = HashMap::new(); diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index af936578d04a3..29a774f182ee3 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -7,17 +7,16 @@ use alloy_rpc_types::state::StateOverride; use anvil_core::eth::trie::RefSecTrieDBMut; use foundry_evm::{ backend::DatabaseError, - hashbrown::HashMap as Map, revm::{ db::{CacheDB, DatabaseRef, DbAccount}, - primitives::{AccountInfo, Bytecode}, + primitives::{AccountInfo, Bytecode, HashMap}, }, }; use memory_db::HashKey; use trie_db::TrieMut; /// Returns storage trie of an account as `HashDB` -pub fn storage_trie_db(storage: &Map) -> (AsHashDB, B256) { +pub fn storage_trie_db(storage: &HashMap) -> (AsHashDB, B256) { // Populate DB with full trie from entries. let (db, root) = { let mut db = , _>>::default(); @@ -38,7 +37,7 @@ pub fn storage_trie_db(storage: &Map) -> (AsHashDB, B256) { } /// Returns the account data as `HashDB` -pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, B256) { +pub fn trie_hash_db(accounts: &HashMap) -> (AsHashDB, B256) { let accounts = trie_accounts(accounts); // Populate DB with full trie from entries. @@ -58,7 +57,7 @@ pub fn trie_hash_db(accounts: &Map) -> (AsHashDB, B256) { } /// Returns all RLP-encoded Accounts -pub fn trie_accounts(accounts: &Map) -> Vec<(Address, Bytes)> { +pub fn trie_accounts(accounts: &HashMap) -> Vec<(Address, Bytes)> { accounts .iter() .map(|(address, account)| { @@ -68,12 +67,12 @@ pub fn trie_accounts(accounts: &Map) -> Vec<(Address, Bytes) .collect() } -pub fn state_merkle_trie_root(accounts: &Map) -> B256 { +pub fn state_merkle_trie_root(accounts: &HashMap) -> B256 { trie_hash_db(accounts).1 } /// Returns the RLP for this account. -pub fn trie_account_rlp(info: &AccountInfo, storage: &Map) -> Bytes { +pub fn trie_account_rlp(info: &AccountInfo, storage: &HashMap) -> Bytes { let mut out: Vec = Vec::new(); let list: [&dyn Encodable; 4] = [&info.nonce, &info.balance, &storage_trie_db(storage).1, &info.code_hash]; diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 4f42da66d33e9..0504bb369c3d6 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -16,7 +16,7 @@ foundry-compilers = { workspace = true, features = ["svm-solc"] } alloy-chains = { workspace = true, features = ["serde"] } alloy-primitives = { workspace = true, features = ["serde"] } -revm-primitives = { workspace = true, default-features = false, features = ["std"] } +revm-primitives.workspace = true solang-parser.workspace = true diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index 53ce6f7ddb352..4c0c665f299ec 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -1,6 +1,6 @@ use alloy_primitives::{Address, B256, U256}; use revm::{ - primitives::{AccountInfo, Env, HashMap as Map}, + primitives::{AccountInfo, Env, HashMap}, JournaledState, }; use serde::{Deserialize, Serialize}; @@ -8,9 +8,9 @@ use serde::{Deserialize, Serialize}; /// A minimal abstraction of a state at a certain point in time #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct StateSnapshot { - pub accounts: Map, - pub storage: Map>, - pub block_hashes: Map, + pub accounts: HashMap, + pub storage: HashMap>, + pub block_hashes: HashMap, } /// Represents a snapshot taken during evm execution diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index a1857b303d3a6..9336ffff740e1 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -24,7 +24,6 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true -hashbrown = { version = "0.14", features = ["serde"] } revm = { workspace = true, default-features = false, features = [ "std", "serde", @@ -36,14 +35,13 @@ revm = { workspace = true, default-features = false, features = [ ] } revm-inspectors.workspace = true -itertools.workspace = true - arrayvec.workspace = true eyre = "0.6" hex.workspace = true +itertools.workspace = true parking_lot = "0.12" proptest = "1" +rand.workspace = true +rayon = "1" thiserror = "1" tracing = "0.1" -rayon = "1" -rand.workspace = true diff --git a/crates/evm/evm/src/lib.rs b/crates/evm/evm/src/lib.rs index 7c69c1823831d..aa5386b3e047f 100644 --- a/crates/evm/evm/src/lib.rs +++ b/crates/evm/evm/src/lib.rs @@ -17,4 +17,10 @@ pub use foundry_evm_traces as traces; // TODO: We should probably remove these, but it's a pretty big breaking change. #[doc(hidden)] -pub use {hashbrown, revm}; +pub use revm; + +#[doc(hidden)] +#[deprecated = "use `{hash_map, hash_set, HashMap, HashSet}` in `std::collections` or `revm::primitives` instead"] +pub mod hashbrown { + pub use revm::primitives::{hash_map, hash_set, HashMap, HashSet}; +} diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index d8c68428e6bda..3c20b029a6280 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -32,7 +32,6 @@ revm = { workspace = true, default-features = false, features = [ ] } eyre = "0.6" -hashbrown = { version = "0.14", features = ["serde"] } itertools.workspace = true parking_lot = "0.12" proptest = "1" @@ -40,3 +39,5 @@ rand.workspace = true serde = "1" thiserror = "1" tracing = "0.1" +rustc-hash.workspace = true +indexmap.workspace = true diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index cf5030203eeaa..b3d41bfadbbd0 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -3,9 +3,8 @@ use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes}; use foundry_config::FuzzDictionaryConfig; -use hashbrown::HashSet; use proptest::prelude::Strategy; -use std::sync::Arc; +use std::{collections::HashSet, sync::Arc}; /// Clonable wrapper around [CalldataFuzzDictionary]. #[derive(Clone, Debug)] diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 1d959ccc70010..1cf1d37882f1e 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -6,7 +6,6 @@ use alloy_primitives::{Address, Bytes, Log, B256, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; -use hashbrown::HashSet; use parking_lot::RwLock; use proptest::prelude::{BoxedStrategy, Strategy}; use revm::{ @@ -16,6 +15,11 @@ use revm::{ }; use std::{fmt, sync::Arc}; +// We're using `IndexSet` to have a stable element order when restoring persisted state, as well as +// for performance when iterating over the sets. +type FxIndexSet = + indexmap::set::IndexSet>; + /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// /// Wrapped in a shareable container. @@ -24,9 +28,9 @@ pub type EvmFuzzState = Arc>; #[derive(Default)] pub struct FuzzDictionary { /// Collected state values. - state_values: HashSet<[u8; 32]>, + state_values: FxIndexSet<[u8; 32]>, /// Addresses that already had their PUSH bytes collected. - addresses: HashSet
, + addresses: FxIndexSet
, } impl fmt::Debug for FuzzDictionary { @@ -40,22 +44,22 @@ impl fmt::Debug for FuzzDictionary { impl FuzzDictionary { #[inline] - pub fn values(&self) -> &HashSet<[u8; 32]> { + pub fn values(&self) -> &FxIndexSet<[u8; 32]> { &self.state_values } #[inline] - pub fn values_mut(&mut self) -> &mut HashSet<[u8; 32]> { + pub fn values_mut(&mut self) -> &mut FxIndexSet<[u8; 32]> { &mut self.state_values } #[inline] - pub fn addresses(&self) -> &HashSet
{ + pub fn addresses(&self) -> &FxIndexSet
{ &self.addresses } #[inline] - pub fn addresses_mut(&mut self) -> &mut HashSet
{ + pub fn addresses_mut(&mut self) -> &mut FxIndexSet
{ &mut self.addresses } } diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 94dd36b63d28c..be3cecb363832 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -25,7 +25,6 @@ revm-inspectors.workspace = true eyre = "0.6" futures = "0.3" -hashbrown = "0.14" hex.workspace = true itertools.workspace = true once_cell = "1" diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index b1f3124cdf1bd..976e9ea6979cd 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -4,9 +4,12 @@ use foundry_common::{ fs, selectors::{SelectorType, SignEthClient}, }; -use hashbrown::HashSet; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, path::PathBuf, sync::Arc}; +use std::{ + collections::{BTreeMap, HashSet}, + path::PathBuf, + sync::Arc, +}; use tokio::sync::RwLock; pub type SingleSignaturesIdentifier = Arc>; diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index 6728f0ae1aff7..b33f3442cf9be 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -2,8 +2,7 @@ use clap::{Parser, ValueHint}; use eyre::Result; use foundry_cli::utils::LoadConfig; use foundry_config::impl_figment_convert_basic; -use foundry_evm::hashbrown::HashMap; -use std::path::PathBuf; +use std::{collections::BTreeMap, path::PathBuf}; /// CLI arguments for `forge remappings`. #[derive(Clone, Debug, Parser)] @@ -25,7 +24,7 @@ impl RemappingArgs { let config = self.try_load_config_emit_warnings()?; if self.pretty { - let mut groups = HashMap::<_, Vec<_>>::with_capacity(config.remappings.len()); + let mut groups = BTreeMap::<_, Vec<_>>::new(); for remapping in config.remappings { groups.entry(remapping.context.clone()).or_default().push(remapping); } @@ -36,14 +35,14 @@ impl RemappingArgs { println!("Global:"); } - for mut remapping in remappings.into_iter() { + for mut remapping in remappings { remapping.context = None; // avoid writing context twice println!("- {remapping}"); } println!(); } } else { - for remapping in config.remappings.into_iter() { + for remapping in config.remappings { println!("{remapping}"); } } diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index de36b871cb1ec..2bdd6d4daec63 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -2,14 +2,16 @@ use crate::{ constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, - hashbrown::HashSet, traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData}, }; use comfy_table::{presets::ASCII_MARKDOWN, *}; use foundry_common::{calc, TestFunctionExt}; use foundry_evm::traces::CallKind; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, fmt::Display}; +use std::{ + collections::{BTreeMap, HashSet}, + fmt::Display, +}; /// Represents the gas report for a set of contracts. #[derive(Clone, Debug, Default, Serialize, Deserialize)] diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 47bc7745dff22..50ce05d4a8c88 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -136,13 +136,13 @@ async fn test_persist_fuzz_failure() { }; // run several times and compare counterexamples calldata - for _ in 0..10 { + for i in 0..10 { let new_calldata = match get_failure_result!() { Some(CounterExample::Single(counterexample)) => counterexample.calldata, _ => Bytes::new(), }; // calldata should be the same with the initial one - assert_eq!(initial_calldata, new_calldata); + assert_eq!(initial_calldata, new_calldata, "run {i}"); } // write new failure in different file diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 99b9ad962783e..9339a54c30673 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -235,22 +235,24 @@ async fn test_invariant_shrink() { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), // `fuzz_seed` at 119 makes this sequence shrinkable from 4 to 2. CounterExample::Sequence(sequence) => { - assert_eq!(sequence.len(), 2); + assert!(sequence.len() <= 3); - // call order should always be preserved - let create_fren_sequence = sequence[0].clone(); - assert_eq!( - create_fren_sequence.contract_name.unwrap(), - "fuzz/invariant/common/InvariantInnerContract.t.sol:Jesus" - ); - assert_eq!(create_fren_sequence.signature.unwrap(), "create_fren()"); + if sequence.len() == 2 { + // call order should always be preserved + let create_fren_sequence = sequence[0].clone(); + assert_eq!( + create_fren_sequence.contract_name.unwrap(), + "fuzz/invariant/common/InvariantInnerContract.t.sol:Jesus" + ); + assert_eq!(create_fren_sequence.signature.unwrap(), "create_fren()"); - let betray_sequence = sequence[1].clone(); - assert_eq!( - betray_sequence.contract_name.unwrap(), - "fuzz/invariant/common/InvariantInnerContract.t.sol:Judas" - ); - assert_eq!(betray_sequence.signature.unwrap(), "betray()"); + let betray_sequence = sequence[1].clone(); + assert_eq!( + betray_sequence.contract_name.unwrap(), + "fuzz/invariant/common/InvariantInnerContract.t.sol:Judas" + ); + assert_eq!(betray_sequence.signature.unwrap(), "betray()"); + } } }; } diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 42986a160b7c5..7e79321efa4c5 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -18,12 +18,13 @@ use foundry_compilers::{ Artifact, Project, Solc, }; use foundry_config::{Chain, Config, SolcReq}; -use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, hashbrown::HashSet}; +use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; use futures::FutureExt; use once_cell::sync::Lazy; use regex::Regex; use semver::{BuildMetadata, Version}; use std::{ + collections::HashSet, fmt::Debug, path::{Path, PathBuf}, }; From 03b60c9da408aec10ea8a5f20b6d0dc56566bdaa Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:43:20 +0100 Subject: [PATCH 0775/1963] chore(evm): remove trace printer, trim inspector stack (#7437) --- crates/cast/bin/cmd/run.rs | 12 +- crates/evm/evm/src/executors/mod.rs | 6 - crates/evm/evm/src/inspectors/mod.rs | 3 - crates/evm/evm/src/inspectors/printer.rs | 66 --------- crates/evm/evm/src/inspectors/stack.rs | 175 ++++++++--------------- 5 files changed, 64 insertions(+), 198 deletions(-) delete mode 100644 crates/evm/evm/src/inspectors/printer.rs diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 83cbf5743904c..3fc09565cde67 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -30,7 +30,8 @@ pub struct RunArgs { debug: bool, /// Print out opcode traces. - #[arg(long, short)] + #[deprecated] + #[arg(long, short, hide = true)] trace_printer: bool, /// Executes the transaction only with the state from the previous block. @@ -82,6 +83,11 @@ impl RunArgs { /// /// Note: This executes the transaction(s) as is: Cheatcodes are disabled pub async fn run(self) -> Result<()> { + #[allow(deprecated)] + if self.trace_printer { + eprintln!("WARNING: --trace-printer is deprecated and has no effect\n"); + } + let figment = Config::figment_with_root(find_project_root_path(None).unwrap()).merge(self.rpc); let evm_opts = figment.extract::()?; @@ -129,7 +135,7 @@ impl RunArgs { env.block.number = U256::from(tx_block_number); - if let Some(ref block) = block { + if let Some(block) = &block { env.block.timestamp = block.header.timestamp; env.block.coinbase = block.header.miner; env.block.difficulty = block.header.difficulty; @@ -213,8 +219,6 @@ impl RunArgs { // Execute our transaction let result = { - executor.set_trace_printer(self.trace_printer); - configure_tx_env(&mut env, &tx); if let Some(to) = tx.to { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 45abbfc9c823a..76f67abd9aa5f 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -171,12 +171,6 @@ impl Executor { self } - #[inline] - pub fn set_trace_printer(&mut self, trace_printer: bool) -> &mut Self { - self.inspector.print(trace_printer); - self - } - #[inline] pub fn set_gas_limit(&mut self, gas_limit: U256) -> &mut Self { self.gas_limit = gas_limit; diff --git a/crates/evm/evm/src/inspectors/mod.rs b/crates/evm/evm/src/inspectors/mod.rs index 059033889c472..786786b28e926 100644 --- a/crates/evm/evm/src/inspectors/mod.rs +++ b/crates/evm/evm/src/inspectors/mod.rs @@ -16,8 +16,5 @@ pub use debugger::Debugger; mod logs; pub use logs::LogCollector; -mod printer; -pub use printer::TracePrinter; - mod stack; pub use stack::{InspectorData, InspectorStack, InspectorStackBuilder}; diff --git a/crates/evm/evm/src/inspectors/printer.rs b/crates/evm/evm/src/inspectors/printer.rs deleted file mode 100644 index 81110669f2baa..0000000000000 --- a/crates/evm/evm/src/inspectors/printer.rs +++ /dev/null @@ -1,66 +0,0 @@ -use revm::{ - interpreter::{opcode, CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}, - Database, EvmContext, Inspector, -}; - -#[derive(Clone, Debug, Default)] -#[non_exhaustive] -pub struct TracePrinter; - -impl Inspector for TracePrinter { - // get opcode by calling `interp.contract.opcode(interp.program_counter())`. - // all other information can be obtained from interp. - fn step(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { - let opcode = interp.current_opcode(); - let opcode_str = opcode::OPCODE_JUMPMAP[opcode as usize]; - let gas_remaining = interp.gas.remaining(); - println!( - "depth:{}, PC:{}, gas:{:#x}({}), OPCODE: {:?}({:?}) refund:{:#x}({}) Stack:{:?}, Data size:{}, Data: 0x{}", - ecx.journaled_state.depth(), - interp.program_counter(), - gas_remaining, - gas_remaining, - opcode_str.unwrap_or(""), - opcode, - interp.gas.refunded(), - interp.gas.refunded(), - interp.stack.data(), - interp.shared_memory.len(), - hex::encode(interp.shared_memory.context_memory()), - ); - } - - #[inline] - fn call( - &mut self, - _context: &mut EvmContext, - inputs: &mut CallInputs, - ) -> Option { - println!( - "SM CALL: {},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}", - inputs.contract, - inputs.context, - inputs.is_static, - inputs.transfer, - inputs.input.len(), - ); - None - } - - #[inline] - fn create( - &mut self, - _context: &mut EvmContext, - inputs: &mut CreateInputs, - ) -> Option { - println!( - "CREATE CALL: caller:{}, scheme:{:?}, value:{:?}, init_code:{:?}, gas:{:?}", - inputs.caller, - inputs.scheme, - inputs.value, - hex::encode(&inputs.init_code), - inputs.gas_limit - ); - None - } -} diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 67fbb3fa7d9f1..ea0af6bbc8731 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -1,6 +1,6 @@ use super::{ Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Debugger, Fuzzer, LogCollector, - StackSnapshotType, TracePrinter, TracingInspector, TracingInspectorConfig, + StackSnapshotType, TracingInspector, TracingInspectorConfig, }; use alloy_primitives::{Address, Bytes, Log, U256}; use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; @@ -41,8 +41,6 @@ pub struct InspectorStackBuilder { pub logs: Option, /// Whether coverage info should be collected. pub coverage: Option, - /// Whether to print all opcode traces into the console. Useful for debugging the EVM. - pub print: Option, /// The chisel state inspector. pub chisel_state: Option, /// Whether to enable call isolation. @@ -114,13 +112,6 @@ impl InspectorStackBuilder { self } - /// Set whether to enable the trace printer. - #[inline] - pub fn print(mut self, yes: bool) -> Self { - self.print = Some(yes); - self - } - /// Set whether to enable the tracer. #[inline] pub fn trace(mut self, yes: bool) -> Self { @@ -149,7 +140,6 @@ impl InspectorStackBuilder { debug, logs, coverage, - print, chisel_state, enable_isolation, } = self; @@ -168,7 +158,6 @@ impl InspectorStackBuilder { stack.collect_coverage(coverage.unwrap_or(false)); stack.collect_logs(logs.unwrap_or(true)); stack.enable_debugger(debug.unwrap_or(false)); - stack.print(print.unwrap_or(false)); stack.tracing(trace.unwrap_or(false)); stack.enable_isolation(enable_isolation); @@ -198,24 +187,45 @@ macro_rules! call_inspectors { /// Same as [call_inspectors] macro, but with depth adjustment for isolated execution. macro_rules! call_inspectors_adjust_depth { - ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { + (#[no_ret] [$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { if $self.in_inner_context { $data.journaled_state.depth += 1; + $( + if let Some($id) = $inspector { + $call + } + )+ + $data.journaled_state.depth -= 1; + } else { + $( + if let Some($id) = $inspector { + $call + } + )+ } - {$( - if let Some($id) = $inspector { - if let Some(result) = $call { - if $self.in_inner_context { + }; + ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { + if $self.in_inner_context { + $data.journaled_state.depth += 1; + $( + if let Some($id) = $inspector { + if let Some(result) = $call { $data.journaled_state.depth -= 1; + return result; } - return result; } - } - )+} - if $self.in_inner_context { + )+ $data.journaled_state.depth -= 1; + } else { + $( + if let Some($id) = $inspector { + if let Some(result) = $call { + return result; + } + } + )+ } - } + }; } /// Helper method which updates data in the state with the data from the database. @@ -269,7 +279,6 @@ pub struct InspectorStack { pub debugger: Option, pub fuzzer: Option, pub log_collector: Option, - pub printer: Option, pub tracer: Option, pub enable_isolation: bool, @@ -354,12 +363,6 @@ impl InspectorStack { self.log_collector = yes.then(Default::default); } - /// Set whether to enable the trace printer. - #[inline] - pub fn print(&mut self, yes: bool) { - self.printer = yes.then(Default::default); - } - /// Set whether to enable the tracer. #[inline] pub fn tracing(&mut self, yes: bool) { @@ -403,28 +406,16 @@ impl InspectorStack { ) -> CallOutcome { let result = outcome.result.result; call_inspectors_adjust_depth!( - [ - &mut self.fuzzer, - &mut self.debugger, - &mut self.tracer, - &mut self.coverage, - &mut self.log_collector, - &mut self.cheatcodes, - &mut self.printer - ], + [&mut self.fuzzer, &mut self.debugger, &mut self.tracer, &mut self.cheatcodes], |inspector| { let new_outcome = inspector.call_end(ecx, inputs, outcome.clone()); // If the inspector returns a different status or a revert with a non-empty message, // we assume it wants to tell us something - if new_outcome.result.result != result || + let different = new_outcome.result.result != result || (new_outcome.result.result == InstructionResult::Revert && - new_outcome.output() != outcome.output()) - { - Some(new_outcome) - } else { - None - } + new_outcome.output() != outcome.output()); + different.then_some(new_outcome) }, self, ecx @@ -578,18 +569,9 @@ impl InspectorStack { impl Inspector<&mut DB> for InspectorStack { fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( - [ - &mut self.debugger, - &mut self.coverage, - &mut self.tracer, - &mut self.log_collector, - &mut self.cheatcodes, - &mut self.printer - ], - |inspector| { - inspector.initialize_interp(interpreter, ecx); - None::<()> - }, + #[no_ret] + [&mut self.coverage, &mut self.tracer, &mut self.cheatcodes], + |inspector| inspector.initialize_interp(interpreter, ecx), self, ecx ); @@ -597,19 +579,15 @@ impl Inspector<&mut DB> for InspectorStack { fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( + #[no_ret] [ &mut self.fuzzer, &mut self.debugger, &mut self.tracer, &mut self.coverage, - &mut self.log_collector, &mut self.cheatcodes, - &mut self.printer ], - |inspector| { - inspector.step(interpreter, ecx); - None::<()> - }, + |inspector| inspector.step(interpreter, ecx), self, ecx ); @@ -617,18 +595,9 @@ impl Inspector<&mut DB> for InspectorStack { fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( - [ - &mut self.debugger, - &mut self.tracer, - &mut self.log_collector, - &mut self.cheatcodes, - &mut self.printer, - &mut self.chisel_state - ], - |inspector| { - inspector.step_end(interpreter, ecx); - None::<()> - }, + #[no_ret] + [&mut self.tracer, &mut self.cheatcodes, &mut self.chisel_state], + |inspector| inspector.step_end(interpreter, ecx), self, ecx ); @@ -636,11 +605,9 @@ impl Inspector<&mut DB> for InspectorStack { fn log(&mut self, ecx: &mut EvmContext<&mut DB>, log: &Log) { call_inspectors_adjust_depth!( - [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], - |inspector| { - inspector.log(ecx, log); - None::<()> - }, + #[no_ret] + [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes], + |inspector| inspector.log(ecx, log), self, ecx ); @@ -661,10 +628,8 @@ impl Inspector<&mut DB> for InspectorStack { &mut self.fuzzer, &mut self.debugger, &mut self.tracer, - &mut self.coverage, &mut self.log_collector, &mut self.cheatcodes, - &mut self.printer ], |inspector| { let mut out = None; @@ -734,15 +699,8 @@ impl Inspector<&mut DB> for InspectorStack { } call_inspectors_adjust_depth!( - [ - &mut self.debugger, - &mut self.tracer, - &mut self.coverage, - &mut self.log_collector, - &mut self.cheatcodes, - &mut self.printer - ], - |inspector| { inspector.create(ecx, create).map(Some) }, + [&mut self.debugger, &mut self.tracer, &mut self.coverage, &mut self.cheatcodes], + |inspector| inspector.create(ecx, create).map(Some), self, ecx ); @@ -777,27 +735,16 @@ impl Inspector<&mut DB> for InspectorStack { let result = outcome.result.result; call_inspectors_adjust_depth!( - [ - &mut self.debugger, - &mut self.tracer, - &mut self.coverage, - &mut self.log_collector, - &mut self.cheatcodes, - &mut self.printer - ], + [&mut self.debugger, &mut self.tracer, &mut self.cheatcodes], |inspector| { let new_outcome = inspector.create_end(ecx, call, outcome.clone()); // If the inspector returns a different status or a revert with a non-empty message, // we assume it wants to tell us something - if new_outcome.result.result != result || + let different = new_outcome.result.result != result || (new_outcome.result.result == InstructionResult::Revert && - new_outcome.output() != outcome.output()) - { - Some(new_outcome) - } else { - None - } + new_outcome.output() != outcome.output()); + different.then_some(new_outcome) }, self, ecx @@ -807,18 +754,8 @@ impl Inspector<&mut DB> for InspectorStack { } fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { - call_inspectors!( - [ - &mut self.debugger, - &mut self.tracer, - &mut self.log_collector, - &mut self.cheatcodes, - &mut self.printer, - &mut self.chisel_state - ], - |inspector| { - Inspector::::selfdestruct(inspector, contract, target, value); - } - ); + call_inspectors!([&mut self.tracer], |inspector| Inspector::::selfdestruct( + inspector, contract, target, value + )); } } From a7f1b3b907b76454eb9e315992b8140b6d292e00 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 20 Mar 2024 02:05:31 +0200 Subject: [PATCH 0776/1963] fix(fuzz): prevent int strategy to overflow when complicate (#7447) --- crates/evm/fuzz/src/strategies/int.rs | 28 +++++++++++++++++++++++++- crates/evm/fuzz/src/strategies/uint.rs | 16 +++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/crates/evm/fuzz/src/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs index e92c2d4642ca3..f772d97c0c1e8 100644 --- a/crates/evm/fuzz/src/strategies/int.rs +++ b/crates/evm/fuzz/src/strategies/int.rs @@ -67,7 +67,11 @@ impl ValueTree for IntValueTree { return false } - self.lo = self.curr + if self.hi.is_negative() { I256::MINUS_ONE } else { I256::ONE }; + self.lo = if self.curr != I256::MIN && self.curr != I256::MAX { + self.curr + if self.hi.is_negative() { I256::MINUS_ONE } else { I256::ONE } + } else { + self.curr + }; self.reposition() } @@ -192,3 +196,25 @@ impl Strategy for IntStrategy { } } } + +#[cfg(test)] +mod tests { + use crate::strategies::int::IntValueTree; + use alloy_primitives::I256; + use proptest::strategy::ValueTree; + + #[test] + fn test_int_tree_complicate_should_not_overflow() { + let mut int_tree = IntValueTree::new(I256::MAX, false); + assert_eq!(int_tree.hi, I256::MAX); + assert_eq!(int_tree.curr, I256::MAX); + int_tree.complicate(); + assert_eq!(int_tree.lo, I256::MAX); + + let mut int_tree = IntValueTree::new(I256::MIN, false); + assert_eq!(int_tree.hi, I256::MIN); + assert_eq!(int_tree.curr, I256::MIN); + int_tree.complicate(); + assert_eq!(int_tree.lo, I256::MIN); + } +} diff --git a/crates/evm/fuzz/src/strategies/uint.rs b/crates/evm/fuzz/src/strategies/uint.rs index e1d74552612e9..7b9aac1d49ed9 100644 --- a/crates/evm/fuzz/src/strategies/uint.rs +++ b/crates/evm/fuzz/src/strategies/uint.rs @@ -167,3 +167,19 @@ impl Strategy for UintStrategy { } } } + +#[cfg(test)] +mod tests { + use crate::strategies::uint::UintValueTree; + use alloy_primitives::U256; + use proptest::strategy::ValueTree; + + #[test] + fn test_uint_tree_complicate_max() { + let mut uint_tree = UintValueTree::new(U256::MAX, false); + assert_eq!(uint_tree.hi, U256::MAX); + assert_eq!(uint_tree.curr, U256::MAX); + uint_tree.complicate(); + assert_eq!(uint_tree.lo, U256::MIN); + } +} From 1a4960d0d888200d696ea97b2e38f83db8eaee02 Mon Sep 17 00:00:00 2001 From: Darshan Kathiriya <8559992+lakshya-sky@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:05:59 -0400 Subject: [PATCH 0777/1963] use correct deserializer for `ots_getBlockDetails` (#7453) use correct deserializer * block_number in ots_getBlockDetails is a list so appropriate deserializer would be `lenient_block_number_seq`. --- crates/anvil/core/src/eth/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 87c02d9b82990..203e8532a35cb 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -676,7 +676,7 @@ pub enum EthRequest { OtsGetBlockDetails( #[cfg_attr( feature = "serde", - serde(deserialize_with = "lenient_block_number::lenient_block_number", default) + serde(deserialize_with = "lenient_block_number::lenient_block_number_seq", default) )] BlockNumber, ), From 319398fe6e61f1a9e8f88356944dbb1f6179726c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 20 Mar 2024 06:45:07 +0400 Subject: [PATCH 0778/1963] chore: refactor tests layout (#7410) * [wip] chore: refactor tests layout * fix script tests * more path fixes * more fixes + enable ast * fmt * forge fmt * docs * move to ForgeTestData * fix * fix --- .github/workflows/test.yml | 2 +- crates/forge/tests/it/cheats.rs | 8 +- crates/forge/tests/it/config.rs | 92 +---- crates/forge/tests/it/core.rs | 49 +-- crates/forge/tests/it/fork.rs | 28 +- crates/forge/tests/it/fs.rs | 12 +- crates/forge/tests/it/fuzz.rs | 25 +- crates/forge/tests/it/inline.rs | 34 +- crates/forge/tests/it/invariant.rs | 80 ++-- crates/forge/tests/it/repros.rs | 34 +- crates/forge/tests/it/spec.rs | 7 +- crates/forge/tests/it/test_helpers.rs | 343 +++++++++++++----- crates/test-utils/src/script.rs | 14 +- crates/test-utils/src/util.rs | 2 +- testdata/{ => default}/cheats/Addr.t.sol | 2 +- testdata/{ => default}/cheats/Assert.t.sol | 2 +- testdata/{ => default}/cheats/Assume.t.sol | 2 +- testdata/{ => default}/cheats/Bank.t.sol | 2 +- testdata/{ => default}/cheats/Base64.t.sol | 2 +- testdata/{ => default}/cheats/Broadcast.t.sol | 2 +- testdata/{ => default}/cheats/ChainId.t.sol | 2 +- testdata/{ => default}/cheats/Cool.t.sol | 4 +- testdata/{ => default}/cheats/Deal.t.sol | 2 +- testdata/{ => default}/cheats/Derive.t.sol | 2 +- testdata/{ => default}/cheats/Env.t.sol | 2 +- testdata/{ => default}/cheats/Etch.t.sol | 2 +- .../{ => default}/cheats/ExpectCall.t.sol | 2 +- .../{ => default}/cheats/ExpectEmit.t.sol | 2 +- .../{ => default}/cheats/ExpectRevert.t.sol | 2 +- testdata/{ => default}/cheats/Fee.t.sol | 2 +- testdata/{ => default}/cheats/Ffi.t.sol | 2 +- testdata/{ => default}/cheats/Fork.t.sol | 2 +- testdata/{ => default}/cheats/Fork2.t.sol | 2 +- testdata/{ => default}/cheats/Fs.t.sol | 2 +- .../{ => default}/cheats/GasMetering.t.sol | 2 +- .../cheats/GetBlockTimestamp.t.sol | 2 +- testdata/{ => default}/cheats/GetCode.t.sol | 2 +- .../cheats/GetDeployedCode.t.sol | 2 +- testdata/{ => default}/cheats/GetLabel.t.sol | 2 +- testdata/{ => default}/cheats/GetNonce.t.sol | 2 +- testdata/{ => default}/cheats/Json.t.sol | 2 +- testdata/{ => default}/cheats/Label.t.sol | 2 +- testdata/{ => default}/cheats/Load.t.sol | 2 +- testdata/{ => default}/cheats/Mapping.t.sol | 2 +- testdata/{ => default}/cheats/MemSafety.t.sol | 2 +- testdata/{ => default}/cheats/MockCall.t.sol | 2 +- testdata/{ => default}/cheats/Parse.t.sol | 2 +- testdata/{ => default}/cheats/Prank.t.sol | 2 +- .../{ => default}/cheats/Prevrandao.t.sol | 2 +- .../{ => default}/cheats/ProjectRoot.t.sol | 2 +- .../{ => default}/cheats/ReadCallers.t.sol | 2 +- testdata/{ => default}/cheats/Record.t.sol | 2 +- .../cheats/RecordAccountAccesses.t.sol | 2 +- .../{ => default}/cheats/RecordLogs.t.sol | 2 +- testdata/{ => default}/cheats/Remember.t.sol | 2 +- .../{ => default}/cheats/ResetNonce.t.sol | 2 +- testdata/{ => default}/cheats/Roll.t.sol | 2 +- testdata/{ => default}/cheats/RpcUrls.t.sol | 2 +- testdata/{ => default}/cheats/SetNonce.t.sol | 2 +- .../{ => default}/cheats/SetNonceUnsafe.t.sol | 2 +- testdata/{ => default}/cheats/Setup.t.sol | 2 +- testdata/{ => default}/cheats/Sign.t.sol | 2 +- testdata/{ => default}/cheats/SignP256.t.sol | 2 +- testdata/{ => default}/cheats/Skip.t.sol | 2 +- testdata/{ => default}/cheats/Sleep.t.sol | 2 +- testdata/{ => default}/cheats/Snapshots.t.sol | 2 +- testdata/{ => default}/cheats/Store.t.sol | 2 +- .../{ => default}/cheats/StringUtils.t.sol | 2 +- testdata/{ => default}/cheats/ToString.t.sol | 2 +- testdata/{ => default}/cheats/Toml.t.sol | 2 +- testdata/{ => default}/cheats/Travel.t.sol | 2 +- testdata/{ => default}/cheats/TryFfi.sol | 2 +- testdata/{ => default}/cheats/UnixTime.t.sol | 2 +- testdata/{ => default}/cheats/Wallet.t.sol | 2 +- testdata/{ => default}/cheats/Warp.t.sol | 2 +- testdata/{ => default}/cheats/dumpState.t.sol | 2 +- .../{ => default}/cheats/getBlockNumber.t.sol | 2 +- .../{ => default}/cheats/loadAllocs.t.sol | 2 +- testdata/{ => default}/core/Abstract.t.sol | 0 .../core/ContractEnvironment.t.sol | 0 testdata/{ => default}/core/DSStyle.t.sol | 0 .../{ => default}/core/FailingSetup.t.sol | 0 .../core/FailingTestAfterFailedSetup.t.sol | 0 .../{ => default}/core/MultipleSetup.t.sol | 0 .../{ => default}/core/PaymentFailure.t.sol | 2 +- testdata/{ => default}/core/Reverting.t.sol | 0 .../{ => default}/core/SetupConsistency.t.sol | 0 testdata/{ => default}/fork/DssExecLib.sol | 0 testdata/{ => default}/fork/ForkSame_1.t.sol | 2 +- testdata/{ => default}/fork/ForkSame_2.t.sol | 2 +- testdata/{ => default}/fork/LaunchFork.t.sol | 0 testdata/{ => default}/fork/Transact.t.sol | 2 +- testdata/{ => default}/fs/Default.t.sol | 2 +- testdata/{ => default}/fs/Disabled.t.sol | 2 +- testdata/{ => default}/fuzz/Fuzz.t.sol | 0 .../{ => default}/fuzz/FuzzCollection.t.sol | 0 .../fuzz/FuzzFailurePersist.t.sol | 2 +- testdata/{ => default}/fuzz/FuzzInt.t.sol | 0 .../{ => default}/fuzz/FuzzPositive.t.sol | 0 testdata/{ => default}/fuzz/FuzzUint.t.sol | 0 .../invariant/common/InvariantAssume.t.sol | 4 +- .../common/InvariantCalldataDictionary.t.sol | 2 +- .../common/InvariantHandlerFailure.t.sol | 0 .../common/InvariantInnerContract.t.sol | 0 .../common/InvariantPreserveState.t.sol | 2 +- .../common/InvariantReentrancy.t.sol | 0 .../common/InvariantShrinkWithAssert.t.sol | 2 +- .../invariant/common/InvariantTest1.t.sol | 0 .../storage/InvariantStorageTest.t.sol | 0 .../invariant/target/ExcludeContracts.t.sol | 0 .../invariant/target/ExcludeSenders.t.sol | 0 .../invariant/target/TargetContracts.t.sol | 0 .../invariant/target/TargetInterfaces.t.sol | 0 .../invariant/target/TargetSelectors.t.sol | 0 .../fuzz/invariant/target/TargetSenders.t.sol | 0 .../targetAbi/ExcludeArtifacts.t.sol | 2 +- .../targetAbi/TargetArtifactSelectors.t.sol | 2 +- .../targetAbi/TargetArtifactSelectors2.t.sol | 6 +- .../invariant/targetAbi/TargetArtifacts.t.sol | 2 +- .../{ => default}/inline/FuzzInlineConf.t.sol | 0 .../inline/InvariantInlineConf.t.sol | 0 .../{ => default}/linking/cycle/Cycle.t.sol | 0 .../linking/duplicate/Duplicate.t.sol | 0 .../{ => default}/linking/nested/Nested.t.sol | 0 .../{ => default}/linking/simple/Simple.t.sol | 0 testdata/{ => default}/logs/DebugLogs.t.sol | 0 testdata/{ => default}/logs/HardhatLogs.t.sol | 0 testdata/{ => default}/logs/console.sol | 0 testdata/{ => default}/repros/Issue2623.t.sol | 2 +- testdata/{ => default}/repros/Issue2629.t.sol | 2 +- testdata/{ => default}/repros/Issue2723.t.sol | 2 +- testdata/{ => default}/repros/Issue2898.t.sol | 2 +- testdata/{ => default}/repros/Issue2956.t.sol | 2 +- testdata/{ => default}/repros/Issue2984.t.sol | 2 +- testdata/{ => default}/repros/Issue3055.t.sol | 2 +- testdata/{ => default}/repros/Issue3077.t.sol | 2 +- testdata/{ => default}/repros/Issue3110.t.sol | 2 +- testdata/{ => default}/repros/Issue3119.t.sol | 2 +- testdata/{ => default}/repros/Issue3189.t.sol | 2 +- testdata/{ => default}/repros/Issue3190.t.sol | 2 +- testdata/{ => default}/repros/Issue3192.t.sol | 2 +- testdata/{ => default}/repros/Issue3220.t.sol | 2 +- testdata/{ => default}/repros/Issue3221.t.sol | 2 +- testdata/{ => default}/repros/Issue3223.t.sol | 2 +- testdata/{ => default}/repros/Issue3347.t.sol | 2 +- testdata/{ => default}/repros/Issue3437.t.sol | 2 +- testdata/{ => default}/repros/Issue3596.t.sol | 2 +- testdata/{ => default}/repros/Issue3653.t.sol | 2 +- testdata/{ => default}/repros/Issue3661.t.sol | 0 testdata/{ => default}/repros/Issue3674.t.sol | 2 +- testdata/{ => default}/repros/Issue3685.t.sol | 2 +- testdata/{ => default}/repros/Issue3703.t.sol | 2 +- testdata/{ => default}/repros/Issue3708.t.sol | 2 +- testdata/{ => default}/repros/Issue3723.t.sol | 2 +- testdata/{ => default}/repros/Issue3753.t.sol | 2 +- testdata/{ => default}/repros/Issue3792.t.sol | 2 +- testdata/{ => default}/repros/Issue4402.t.sol | 2 +- testdata/{ => default}/repros/Issue4586.t.sol | 2 +- testdata/{ => default}/repros/Issue4630.t.sol | 2 +- testdata/{ => default}/repros/Issue4640.t.sol | 2 +- testdata/{ => default}/repros/Issue4832.t.sol | 2 +- testdata/{ => default}/repros/Issue5038.t.sol | 2 +- testdata/{ => default}/repros/Issue5529.t.sol | 2 +- testdata/{ => default}/repros/Issue5808.t.sol | 2 +- testdata/{ => default}/repros/Issue5929.t.sol | 2 +- testdata/{ => default}/repros/Issue5935.t.sol | 2 +- testdata/{ => default}/repros/Issue5948.t.sol | 2 +- testdata/{ => default}/repros/Issue6006.t.sol | 2 +- testdata/{ => default}/repros/Issue6032.t.sol | 2 +- testdata/{ => default}/repros/Issue6070.t.sol | 2 +- testdata/{ => default}/repros/Issue6115.t.sol | 0 testdata/{ => default}/repros/Issue6170.t.sol | 2 +- testdata/{ => default}/repros/Issue6180.t.sol | 2 +- testdata/{ => default}/repros/Issue6293.t.sol | 2 +- testdata/{ => default}/repros/Issue6355.t.sol | 2 +- testdata/{ => default}/repros/Issue6437.t.sol | 2 +- testdata/{ => default}/repros/Issue6501.t.sol | 0 testdata/{ => default}/repros/Issue6538.t.sol | 2 +- testdata/{ => default}/repros/Issue6554.t.sol | 6 +- testdata/{ => default}/repros/Issue6616.t.sol | 2 +- testdata/{ => default}/repros/Issue6634.t.sol | 2 +- testdata/{ => default}/repros/Issue6759.t.sol | 2 +- testdata/{ => default}/repros/Issue6966.t.sol | 0 .../deploy.sol/31337/run-latest.json | 0 testdata/{ => default}/script/deploy.sol | 4 +- .../{ => default}/spec/ShanghaiCompat.t.sol | 2 +- .../trace/ConflictingSignatures.t.sol | 2 +- testdata/{ => default}/trace/Trace.t.sol | 2 +- 188 files changed, 547 insertions(+), 465 deletions(-) rename testdata/{ => default}/cheats/Addr.t.sol (95%) rename testdata/{ => default}/cheats/Assert.t.sol (99%) rename testdata/{ => default}/cheats/Assume.t.sol (92%) rename testdata/{ => default}/cheats/Bank.t.sol (95%) rename testdata/{ => default}/cheats/Base64.t.sol (96%) rename testdata/{ => default}/cheats/Broadcast.t.sol (99%) rename testdata/{ => default}/cheats/ChainId.t.sol (93%) rename testdata/{ => default}/cheats/Cool.t.sol (95%) rename testdata/{ => default}/cheats/Deal.t.sol (96%) rename testdata/{ => default}/cheats/Derive.t.sol (96%) rename testdata/{ => default}/cheats/Env.t.sol (99%) rename testdata/{ => default}/cheats/Etch.t.sol (96%) rename testdata/{ => default}/cheats/ExpectCall.t.sol (99%) rename testdata/{ => default}/cheats/ExpectEmit.t.sol (99%) rename testdata/{ => default}/cheats/ExpectRevert.t.sol (99%) rename testdata/{ => default}/cheats/Fee.t.sol (94%) rename testdata/{ => default}/cheats/Ffi.t.sol (97%) rename testdata/{ => default}/cheats/Fork.t.sol (99%) rename testdata/{ => default}/cheats/Fork2.t.sol (99%) rename testdata/{ => default}/cheats/Fs.t.sol (99%) rename testdata/{ => default}/cheats/GasMetering.t.sol (98%) rename testdata/{ => default}/cheats/GetBlockTimestamp.t.sol (96%) rename testdata/{ => default}/cheats/GetCode.t.sol (99%) rename testdata/{ => default}/cheats/GetDeployedCode.t.sol (99%) rename testdata/{ => default}/cheats/GetLabel.t.sol (94%) rename testdata/{ => default}/cheats/GetNonce.t.sol (94%) rename testdata/{ => default}/cheats/Json.t.sol (99%) rename testdata/{ => default}/cheats/Label.t.sol (91%) rename testdata/{ => default}/cheats/Load.t.sol (97%) rename testdata/{ => default}/cheats/Mapping.t.sol (99%) rename testdata/{ => default}/cheats/MemSafety.t.sol (99%) rename testdata/{ => default}/cheats/MockCall.t.sol (99%) rename testdata/{ => default}/cheats/Parse.t.sol (99%) rename testdata/{ => default}/cheats/Prank.t.sol (99%) rename testdata/{ => default}/cheats/Prevrandao.t.sol (97%) rename testdata/{ => default}/cheats/ProjectRoot.t.sol (97%) rename testdata/{ => default}/cheats/ReadCallers.t.sol (99%) rename testdata/{ => default}/cheats/Record.t.sol (98%) rename testdata/{ => default}/cheats/RecordAccountAccesses.t.sol (99%) rename testdata/{ => default}/cheats/RecordLogs.t.sol (99%) rename testdata/{ => default}/cheats/Remember.t.sol (96%) rename testdata/{ => default}/cheats/ResetNonce.t.sol (97%) rename testdata/{ => default}/cheats/Roll.t.sol (97%) rename testdata/{ => default}/cheats/RpcUrls.t.sol (98%) rename testdata/{ => default}/cheats/SetNonce.t.sol (96%) rename testdata/{ => default}/cheats/SetNonceUnsafe.t.sol (97%) rename testdata/{ => default}/cheats/Setup.t.sol (97%) rename testdata/{ => default}/cheats/Sign.t.sol (96%) rename testdata/{ => default}/cheats/SignP256.t.sol (96%) rename testdata/{ => default}/cheats/Skip.t.sol (96%) rename testdata/{ => default}/cheats/Sleep.t.sol (98%) rename testdata/{ => default}/cheats/Snapshots.t.sol (99%) rename testdata/{ => default}/cheats/Store.t.sol (98%) rename testdata/{ => default}/cheats/StringUtils.t.sol (98%) rename testdata/{ => default}/cheats/ToString.t.sol (98%) rename testdata/{ => default}/cheats/Toml.t.sol (99%) rename testdata/{ => default}/cheats/Travel.t.sol (95%) rename testdata/{ => default}/cheats/TryFfi.sol (97%) rename testdata/{ => default}/cheats/UnixTime.t.sol (97%) rename testdata/{ => default}/cheats/Wallet.t.sol (99%) rename testdata/{ => default}/cheats/Warp.t.sol (96%) rename testdata/{ => default}/cheats/dumpState.t.sol (99%) rename testdata/{ => default}/cheats/getBlockNumber.t.sol (97%) rename testdata/{ => default}/cheats/loadAllocs.t.sol (99%) rename testdata/{ => default}/core/Abstract.t.sol (100%) rename testdata/{ => default}/core/ContractEnvironment.t.sol (100%) rename testdata/{ => default}/core/DSStyle.t.sol (100%) rename testdata/{ => default}/core/FailingSetup.t.sol (100%) rename testdata/{ => default}/core/FailingTestAfterFailedSetup.t.sol (100%) rename testdata/{ => default}/core/MultipleSetup.t.sol (100%) rename testdata/{ => default}/core/PaymentFailure.t.sol (93%) rename testdata/{ => default}/core/Reverting.t.sol (100%) rename testdata/{ => default}/core/SetupConsistency.t.sol (100%) rename testdata/{ => default}/fork/DssExecLib.sol (100%) rename testdata/{ => default}/fork/ForkSame_1.t.sol (95%) rename testdata/{ => default}/fork/ForkSame_2.t.sol (95%) rename testdata/{ => default}/fork/LaunchFork.t.sol (100%) rename testdata/{ => default}/fork/Transact.t.sol (99%) rename testdata/{ => default}/fs/Default.t.sol (97%) rename testdata/{ => default}/fs/Disabled.t.sol (97%) rename testdata/{ => default}/fuzz/Fuzz.t.sol (100%) rename testdata/{ => default}/fuzz/FuzzCollection.t.sol (100%) rename testdata/{ => default}/fuzz/FuzzFailurePersist.t.sol (96%) rename testdata/{ => default}/fuzz/FuzzInt.t.sol (100%) rename testdata/{ => default}/fuzz/FuzzPositive.t.sol (100%) rename testdata/{ => default}/fuzz/FuzzUint.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/common/InvariantAssume.t.sol (91%) rename testdata/{ => default}/fuzz/invariant/common/InvariantCalldataDictionary.t.sol (98%) rename testdata/{ => default}/fuzz/invariant/common/InvariantHandlerFailure.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/common/InvariantInnerContract.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/common/InvariantPreserveState.t.sol (97%) rename testdata/{ => default}/fuzz/invariant/common/InvariantReentrancy.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol (98%) rename testdata/{ => default}/fuzz/invariant/common/InvariantTest1.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/storage/InvariantStorageTest.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/target/ExcludeContracts.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/target/ExcludeSenders.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/target/TargetContracts.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/target/TargetInterfaces.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/target/TargetSelectors.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/target/TargetSenders.t.sol (100%) rename testdata/{ => default}/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol (91%) rename testdata/{ => default}/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol (87%) rename testdata/{ => default}/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol (84%) rename testdata/{ => default}/fuzz/invariant/targetAbi/TargetArtifacts.t.sol (91%) rename testdata/{ => default}/inline/FuzzInlineConf.t.sol (100%) rename testdata/{ => default}/inline/InvariantInlineConf.t.sol (100%) rename testdata/{ => default}/linking/cycle/Cycle.t.sol (100%) rename testdata/{ => default}/linking/duplicate/Duplicate.t.sol (100%) rename testdata/{ => default}/linking/nested/Nested.t.sol (100%) rename testdata/{ => default}/linking/simple/Simple.t.sol (100%) rename testdata/{ => default}/logs/DebugLogs.t.sol (100%) rename testdata/{ => default}/logs/HardhatLogs.t.sol (100%) rename testdata/{ => default}/logs/console.sol (100%) rename testdata/{ => default}/repros/Issue2623.t.sol (95%) rename testdata/{ => default}/repros/Issue2629.t.sol (96%) rename testdata/{ => default}/repros/Issue2723.t.sol (95%) rename testdata/{ => default}/repros/Issue2898.t.sol (96%) rename testdata/{ => default}/repros/Issue2956.t.sol (97%) rename testdata/{ => default}/repros/Issue2984.t.sol (96%) rename testdata/{ => default}/repros/Issue3055.t.sol (97%) rename testdata/{ => default}/repros/Issue3077.t.sol (97%) rename testdata/{ => default}/repros/Issue3110.t.sol (97%) rename testdata/{ => default}/repros/Issue3119.t.sol (96%) rename testdata/{ => default}/repros/Issue3189.t.sol (96%) rename testdata/{ => default}/repros/Issue3190.t.sol (94%) rename testdata/{ => default}/repros/Issue3192.t.sol (95%) rename testdata/{ => default}/repros/Issue3220.t.sol (97%) rename testdata/{ => default}/repros/Issue3221.t.sol (97%) rename testdata/{ => default}/repros/Issue3223.t.sol (97%) rename testdata/{ => default}/repros/Issue3347.t.sol (91%) rename testdata/{ => default}/repros/Issue3437.t.sol (93%) rename testdata/{ => default}/repros/Issue3596.t.sol (96%) rename testdata/{ => default}/repros/Issue3653.t.sol (95%) rename testdata/{ => default}/repros/Issue3661.t.sol (100%) rename testdata/{ => default}/repros/Issue3674.t.sol (94%) rename testdata/{ => default}/repros/Issue3685.t.sol (97%) rename testdata/{ => default}/repros/Issue3703.t.sol (98%) rename testdata/{ => default}/repros/Issue3708.t.sol (97%) rename testdata/{ => default}/repros/Issue3723.t.sol (93%) rename testdata/{ => default}/repros/Issue3753.t.sol (94%) rename testdata/{ => default}/repros/Issue3792.t.sol (96%) rename testdata/{ => default}/repros/Issue4402.t.sol (99%) rename testdata/{ => default}/repros/Issue4586.t.sol (97%) rename testdata/{ => default}/repros/Issue4630.t.sol (96%) rename testdata/{ => default}/repros/Issue4640.t.sol (94%) rename testdata/{ => default}/repros/Issue4832.t.sol (92%) rename testdata/{ => default}/repros/Issue5038.t.sol (99%) rename testdata/{ => default}/repros/Issue5529.t.sol (97%) rename testdata/{ => default}/repros/Issue5808.t.sol (95%) rename testdata/{ => default}/repros/Issue5929.t.sol (95%) rename testdata/{ => default}/repros/Issue5935.t.sol (97%) rename testdata/{ => default}/repros/Issue5948.t.sol (97%) rename testdata/{ => default}/repros/Issue6006.t.sol (97%) rename testdata/{ => default}/repros/Issue6032.t.sol (98%) rename testdata/{ => default}/repros/Issue6070.t.sol (95%) rename testdata/{ => default}/repros/Issue6115.t.sol (100%) rename testdata/{ => default}/repros/Issue6170.t.sol (95%) rename testdata/{ => default}/repros/Issue6180.t.sol (95%) rename testdata/{ => default}/repros/Issue6293.t.sol (93%) rename testdata/{ => default}/repros/Issue6355.t.sol (96%) rename testdata/{ => default}/repros/Issue6437.t.sol (97%) rename testdata/{ => default}/repros/Issue6501.t.sol (100%) rename testdata/{ => default}/repros/Issue6538.t.sol (95%) rename testdata/{ => default}/repros/Issue6554.t.sol (61%) rename testdata/{ => default}/repros/Issue6616.t.sol (96%) rename testdata/{ => default}/repros/Issue6634.t.sol (99%) rename testdata/{ => default}/repros/Issue6759.t.sol (95%) rename testdata/{ => default}/repros/Issue6966.t.sol (100%) rename testdata/{ => default}/script/broadcast/deploy.sol/31337/run-latest.json (100%) rename testdata/{ => default}/script/deploy.sol (89%) rename testdata/{ => default}/spec/ShanghaiCompat.t.sol (96%) rename testdata/{ => default}/trace/ConflictingSignatures.t.sol (97%) rename testdata/{ => default}/trace/Trace.t.sol (98%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ffef82ca5edc0..2914175065c3d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -166,7 +166,7 @@ jobs: # so running `forge fmt` with `--root testdata` won't actually check anything run: | shopt -s extglob - cargo run --bin forge -- fmt --check testdata/**/!(Vm).sol + cargo run --bin forge -- fmt --check $(find testdata -name '*.sol' ! -name Vm.sol) crate-checks: runs-on: ubuntu-latest diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 8fa7ae31e4381..fd6e9866e61d6 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -2,9 +2,9 @@ use crate::{ config::*, - test_helpers::{PROJECT, RE_PATH_SEPARATOR}, + test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT}, }; -use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_test_utils::Filter; /// Executes all cheat code tests but not fork cheat codes @@ -18,9 +18,9 @@ async fn test_cheats_local() { filter = filter.exclude_tests("(Ffi|File|Line|Root)"); } - let mut config = Config::with_root(PROJECT.root()); + let mut config = TEST_DATA_DEFAULT.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); - let runner = runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with_config(config); TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index bc56b5c1c2ccd..1b2a1398d1f6f 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -1,23 +1,18 @@ //! Test config. -use crate::test_helpers::{COMPILED, EVM_OPTS, PROJECT, TEST_OPTS}; use forge::{ result::{SuiteResult, TestStatus}, - MultiContractRunner, MultiContractRunnerBuilder, -}; -use foundry_config::{ - fs_permissions::PathPermission, Config, FsPermissions, RpcEndpoint, RpcEndpoints, + MultiContractRunner, }; use foundry_evm::{ decode::decode_console_logs, - inspectors::CheatsConfig, revm::primitives::SpecId, traces::{render_trace_arena, CallTraceDecoderBuilder}, }; use foundry_test_utils::{init_tracing, Filter}; use futures::future::join_all; use itertools::Itertools; -use std::{collections::BTreeMap, path::Path}; +use std::collections::BTreeMap; /// How to execute a test run. pub struct TestConfig { @@ -31,10 +26,6 @@ impl TestConfig { Self::with_filter(runner, Filter::matches_all()) } - pub fn filter(filter: Filter) -> Self { - Self::with_filter(runner(), filter) - } - pub fn with_filter(runner: MultiContractRunner, filter: Filter) -> Self { init_tracing(); Self { runner, should_fail: false, filter } @@ -108,85 +99,6 @@ impl TestConfig { } } -pub fn manifest_root() -> &'static Path { - let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); - // need to check here where we're executing the test from, if in `forge` we need to also allow - // `testdata` - if root.ends_with("forge") { - root = root.parent().unwrap(); - } - root -} - -/// Builds a base runner -pub fn base_runner() -> MultiContractRunnerBuilder { - init_tracing(); - MultiContractRunnerBuilder::default() - .sender(EVM_OPTS.sender) - .with_test_options(TEST_OPTS.clone()) -} - -/// Builds a non-tracing runner -pub fn runner() -> MultiContractRunner { - let mut config = Config::with_root(PROJECT.root()); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write(manifest_root())]); - runner_with_config(config) -} - -/// Builds a non-tracing runner -pub fn runner_with_config(mut config: Config) -> MultiContractRunner { - config.rpc_endpoints = rpc_endpoints(); - config.allow_paths.push(manifest_root().to_path_buf()); - - let root = &PROJECT.paths.root; - let opts = &*EVM_OPTS; - let env = opts.local_evm_env(); - let output = COMPILED.clone(); - base_runner() - .with_cheats_config(CheatsConfig::new(&config, opts.clone(), None)) - .sender(config.sender) - .build(root, output, env, opts.clone()) - .unwrap() -} - -/// Builds a tracing runner -pub fn tracing_runner() -> MultiContractRunner { - let mut opts = EVM_OPTS.clone(); - opts.verbosity = 5; - base_runner() - .build(&PROJECT.paths.root, (*COMPILED).clone(), EVM_OPTS.local_evm_env(), opts) - .unwrap() -} - -// Builds a runner that runs against forked state -pub async fn forked_runner(rpc: &str) -> MultiContractRunner { - let mut opts = EVM_OPTS.clone(); - - opts.env.chain_id = None; // clear chain id so the correct one gets fetched from the RPC - opts.fork_url = Some(rpc.to_string()); - - let env = opts.evm_env().await.expect("Could not instantiate fork environment"); - let fork = opts.get_fork(&Default::default(), env.clone()); - - base_runner() - .with_fork(fork) - .build(&PROJECT.paths.root, (*COMPILED).clone(), env, opts) - .unwrap() -} - -/// the RPC endpoints used during tests -pub fn rpc_endpoints() -> RpcEndpoints { - RpcEndpoints::new([ - ( - "rpcAlias", - RpcEndpoint::Url( - "https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf".to_string(), - ), - ), - ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".to_string())), - ]) -} - /// A helper to assert the outcome of multiple tests with helpful assert messages #[track_caller] #[allow(clippy::type_complexity)] diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 96a0aedce278a..34cdc0d179287 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -1,6 +1,6 @@ //! Forge tests for core functionality. -use crate::config::*; +use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use forge::result::SuiteResult; use foundry_evm::traces::TraceKind; use foundry_test_utils::Filter; @@ -9,14 +9,14 @@ use std::{collections::BTreeMap, env}; #[tokio::test(flavor = "multi_thread")] async fn test_core() { let filter = Filter::new(".*", ".*", ".*core"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([ ( - "core/FailingSetup.t.sol:FailingSetupTest", + "default/core/FailingSetup.t.sol:FailingSetupTest", vec![( "setUp()", false, @@ -26,7 +26,7 @@ async fn test_core() { )], ), ( - "core/MultipleSetup.t.sol:MultipleSetup", + "default/core/MultipleSetup.t.sol:MultipleSetup", vec![( "setUp()", false, @@ -36,34 +36,37 @@ async fn test_core() { )], ), ( - "core/Reverting.t.sol:RevertingTest", + "default/core/Reverting.t.sol:RevertingTest", vec![("testFailRevert()", true, None, None, None)], ), ( - "core/SetupConsistency.t.sol:SetupConsistencyCheck", + "default/core/SetupConsistency.t.sol:SetupConsistencyCheck", vec![ ("testAdd()", true, None, None, None), ("testMultiply()", true, None, None, None), ], ), ( - "core/DSStyle.t.sol:DSStyleTest", + "default/core/DSStyle.t.sol:DSStyleTest", vec![("testFailingAssertions()", true, None, None, None)], ), ( - "core/ContractEnvironment.t.sol:ContractEnvironmentTest", + "default/core/ContractEnvironment.t.sol:ContractEnvironmentTest", vec![ ("testAddresses()", true, None, None, None), ("testEnvironment()", true, None, None, None), ], ), ( - "core/PaymentFailure.t.sol:PaymentFailureTest", + "default/core/PaymentFailure.t.sol:PaymentFailureTest", vec![("testCantPay()", false, Some("EvmError: Revert".to_string()), None, None)], ), - ("core/Abstract.t.sol:AbstractTest", vec![("testSomething()", true, None, None, None)]), ( - "core/FailingTestAfterFailedSetup.t.sol:FailingTestAfterFailedSetupTest", + "default/core/Abstract.t.sol:AbstractTest", + vec![("testSomething()", true, None, None, None)], + ), + ( + "default/core/FailingTestAfterFailedSetup.t.sol:FailingTestAfterFailedSetupTest", vec![( "setUp()", false, @@ -79,25 +82,25 @@ async fn test_core() { #[tokio::test(flavor = "multi_thread")] async fn test_linking() { let filter = Filter::new(".*", ".*", ".*linking"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([ ( - "linking/simple/Simple.t.sol:SimpleLibraryLinkingTest", + "default/linking/simple/Simple.t.sol:SimpleLibraryLinkingTest", vec![("testCall()", true, None, None, None)], ), ( - "linking/nested/Nested.t.sol:NestedLibraryLinkingTest", + "default/linking/nested/Nested.t.sol:NestedLibraryLinkingTest", vec![ ("testDirect()", true, None, None, None), ("testNested()", true, None, None, None), ], ), ( - "linking/duplicate/Duplicate.t.sol:DuplicateLibraryLinkingTest", + "default/linking/duplicate/Duplicate.t.sol:DuplicateLibraryLinkingTest", vec![ ("testA()", true, None, None, None), ("testB()", true, None, None, None), @@ -113,14 +116,14 @@ async fn test_linking() { #[tokio::test(flavor = "multi_thread")] async fn test_logs() { let filter = Filter::new(".*", ".*", ".*logs"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([ ( - "logs/DebugLogs.t.sol:DebugLogsTest", + "default/logs/DebugLogs.t.sol:DebugLogsTest", vec![ ( "test1()", @@ -289,7 +292,7 @@ async fn test_logs() { ], ), ( - "logs/HardhatLogs.t.sol:HardhatLogsTest", + "default/logs/HardhatLogs.t.sol:HardhatLogsTest", vec![ ( "testInts()", @@ -678,7 +681,7 @@ async fn test_env_vars() { env::remove_var(env_var_key); let filter = Filter::new("testSetEnv", ".*", ".*"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let _ = runner.test_collect(&filter); assert_eq!(env::var(env_var_key).unwrap(), env_var_val); @@ -687,16 +690,16 @@ async fn test_env_vars() { #[tokio::test(flavor = "multi_thread")] async fn test_doesnt_run_abstract_contract() { let filter = Filter::new(".*", ".*", ".*Abstract.t.sol".to_string().as_str()); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let results = runner.test_collect(&filter); - assert!(!results.contains_key("core/Abstract.t.sol:AbstractTestBase")); - assert!(results.contains_key("core/Abstract.t.sol:AbstractTest")); + assert!(!results.contains_key("default/core/Abstract.t.sol:AbstractTestBase")); + assert!(results.contains_key("default/core/Abstract.t.sol:AbstractTest")); } #[tokio::test(flavor = "multi_thread")] async fn test_trace() { let filter = Filter::new(".*", ".*", ".*trace"); - let mut runner = tracing_runner(); + let mut runner = TEST_DATA_DEFAULT.tracing_runner(); let suite_result = runner.test_collect(&filter); // TODO: This trace test is very basic - it is probably a good candidate for snapshot diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index da103801c0e32..c2751fe91f951 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -2,10 +2,10 @@ use crate::{ config::*, - test_helpers::{PROJECT, RE_PATH_SEPARATOR}, + test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT}, }; use forge::result::SuiteResult; -use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_test_utils::Filter; /// Executes reverting fork test @@ -16,7 +16,7 @@ async fn test_cheats_fork_revert() { ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork"), ); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let suite_result = runner.test_collect(&filter); assert_eq!(suite_result.len(), 1); @@ -33,9 +33,9 @@ async fn test_cheats_fork_revert() { /// Executes all non-reverting fork cheatcodes #[tokio::test(flavor = "multi_thread")] async fn test_cheats_fork() { - let mut config = Config::with_root(PROJECT.root()); + let mut config = TEST_DATA_DEFAULT.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with_config(config); let filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; @@ -44,9 +44,9 @@ async fn test_cheats_fork() { /// Executes eth_getLogs cheatcode #[tokio::test(flavor = "multi_thread")] async fn test_get_logs_fork() { - let mut config = Config::with_root(PROJECT.root()); + let mut config = TEST_DATA_DEFAULT.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with_config(config); let filter = Filter::new("testEthGetLogs", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; @@ -55,9 +55,9 @@ async fn test_get_logs_fork() { /// Executes rpc cheatcode #[tokio::test(flavor = "multi_thread")] async fn test_rpc_fork() { - let mut config = Config::with_root(PROJECT.root()); + let mut config = TEST_DATA_DEFAULT.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with_config(config); let filter = Filter::new("testRpc", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; @@ -67,7 +67,7 @@ async fn test_rpc_fork() { #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork() { let rpc_url = foundry_common::rpc::next_http_archive_rpc_endpoint(); - let runner = forked_runner(&rpc_url).await; + let runner = TEST_DATA_DEFAULT.forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; } @@ -76,7 +76,7 @@ async fn test_launch_fork() { #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork_ws() { let rpc_url = foundry_common::rpc::next_ws_archive_rpc_endpoint(); - let runner = forked_runner(&rpc_url).await; + let runner = TEST_DATA_DEFAULT.forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; } @@ -84,13 +84,15 @@ async fn test_launch_fork_ws() { /// Tests that we can transact transactions in forking mode #[tokio::test(flavor = "multi_thread")] async fn test_transact_fork() { + let runner = TEST_DATA_DEFAULT.runner(); let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Transact")); - TestConfig::filter(filter).run().await; + TestConfig::with_filter(runner, filter).run().await; } /// Tests that we can create the same fork (provider,block) concurretnly in different tests #[tokio::test(flavor = "multi_thread")] async fn test_create_same_fork() { + let runner = TEST_DATA_DEFAULT.runner(); let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}ForkSame")); - TestConfig::filter(filter).run().await; + TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/fs.rs b/crates/forge/tests/it/fs.rs index 72ae2cb32fe4f..5bb0b59fb24b3 100644 --- a/crates/forge/tests/it/fs.rs +++ b/crates/forge/tests/it/fs.rs @@ -1,23 +1,23 @@ //! Filesystem tests. -use crate::{config::*, test_helpers::PROJECT}; -use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; +use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_fs_disabled() { - let mut config = Config::with_root(PROJECT.root()); + let mut config = TEST_DATA_DEFAULT.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::none("./")]); - let runner = runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with_config(config); let filter = Filter::new(".*", ".*", ".*fs/Disabled"); TestConfig::with_filter(runner, filter).run().await; } #[tokio::test(flavor = "multi_thread")] async fn test_fs_default() { - let mut config = Config::with_root(PROJECT.root()); + let mut config = TEST_DATA_DEFAULT.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with_config(config); let filter = Filter::new(".*", ".*", ".*fs/Default"); TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 50ce05d4a8c88..c6369e896615f 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -1,21 +1,20 @@ //! Fuzz tests. -use std::collections::BTreeMap; - +use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_primitives::{Bytes, U256}; -use forge::fuzz::CounterExample; - -use forge::result::{SuiteResult, TestStatus}; +use forge::{ + fuzz::CounterExample, + result::{SuiteResult, TestStatus}, +}; use foundry_test_utils::Filter; - -use crate::config::*; +use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] async fn test_fuzz() { let filter = Filter::new(".*", ".*", ".*fuzz/") .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)|testSuccessChecker\(uint256\)|testSuccessChecker2\(int256\)|testSuccessChecker3\(uint32\)") .exclude_paths("invariant"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let suite_result = runner.test_collect(&filter); assert!(!suite_result.is_empty()); @@ -52,7 +51,7 @@ async fn test_successful_fuzz_cases() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzPositive") .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)") .exclude_paths("invariant"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let suite_result = runner.test_collect(&filter); assert!(!suite_result.is_empty()); @@ -82,7 +81,7 @@ async fn test_successful_fuzz_cases() { #[ignore] async fn test_fuzz_collection() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzCollection.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.invariant.depth = 100; runner.test_options.invariant.runs = 1000; runner.test_options.fuzz.runs = 1000; @@ -92,7 +91,7 @@ async fn test_fuzz_collection() { assert_multiple( &results, BTreeMap::from([( - "fuzz/FuzzCollection.t.sol:SampleContractTest", + "default/fuzz/FuzzCollection.t.sol:SampleContractTest", vec![ ("invariantCounter", false, Some("broken counter.".into()), None, None), ( @@ -111,14 +110,14 @@ async fn test_fuzz_collection() { #[tokio::test(flavor = "multi_thread")] async fn test_persist_fuzz_failure() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzFailurePersist.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.fuzz.runs = 1000; macro_rules! get_failure_result { () => { runner .test_collect(&filter) - .get("fuzz/FuzzFailurePersist.t.sol:FuzzFailurePersistTest") + .get("default/fuzz/FuzzFailurePersist.t.sol:FuzzFailurePersistTest") .unwrap() .test_results .get("test_persist_fuzzed_failure(uint256,int256,address,bool,string,(address,uint256),address[])") diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 0a2f4d59301ea..09d4fb3230339 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -1,19 +1,16 @@ //! Inline configuration tests. -use crate::{ - config::runner, - test_helpers::{COMPILED, PROJECT}, -}; -use forge::{result::TestKind, TestOptions, TestOptionsBuilder}; +use crate::test_helpers::TEST_DATA_DEFAULT; +use forge::{result::TestKind, TestOptionsBuilder}; use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let result = runner.test_collect(&filter); - let suite_result = result.get("inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); + let suite_result = result.get("default/inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); let test_result = suite_result.test_results.get("testInlineConfFuzz(uint8)").unwrap(); match test_result.kind { TestKind::Fuzz { runs, .. } => assert_eq!(runs, 1024), @@ -23,11 +20,10 @@ async fn inline_config_run_fuzz() { #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_invariant() { - const ROOT: &str = "inline/InvariantInlineConf.t.sol"; + const ROOT: &str = "default/inline/InvariantInlineConf.t.sol"; let filter = Filter::new(".*", ".*", ".*inline/InvariantInlineConf.t.sol"); - let mut runner = runner(); - runner.test_options = default_test_options(); + let mut runner = TEST_DATA_DEFAULT.runner(); let result = runner.test_collect(&filter); let suite_result_1 = result.get(&format!("{ROOT}:InvariantInlineConf")).expect("Result exists"); @@ -49,38 +45,28 @@ async fn inline_config_run_invariant() { #[test] fn build_test_options() { - let root = &PROJECT.paths.root; + let root = &TEST_DATA_DEFAULT.project.paths.root; let profiles = vec!["default".to_string(), "ci".to_string()]; let build_result = TestOptionsBuilder::default() .fuzz(FuzzConfig::default()) .invariant(InvariantConfig::default()) .profiles(profiles) - .build(&COMPILED, root); + .build(&TEST_DATA_DEFAULT.output, root); assert!(build_result.is_ok()); } #[test] fn build_test_options_just_one_valid_profile() { - let root = &PROJECT.paths.root; + let root = &TEST_DATA_DEFAULT.project.root(); let valid_profiles = vec!["profile-sheldon-cooper".to_string()]; let build_result = TestOptionsBuilder::default() .fuzz(FuzzConfig::default()) .invariant(InvariantConfig::default()) .profiles(valid_profiles) - .build(&COMPILED, root); + .build(&TEST_DATA_DEFAULT.output, root); // We expect an error, since COMPILED contains in-line // per-test configs for "default" and "ci" profiles assert!(build_result.is_err()); } - -/// Returns the [TestOptions] for the testing [PROJECT]. -pub fn default_test_options() -> TestOptions { - let root = &PROJECT.paths.root; - TestOptionsBuilder::default() - .fuzz(FuzzConfig::default()) - .invariant(InvariantConfig::default()) - .build(&COMPILED, root) - .expect("Config loaded") -} diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 9339a54c30673..e902b6aa9f18b 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -1,6 +1,6 @@ //! Invariant tests. -use crate::{config::*, test_helpers::TEST_OPTS}; +use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_primitives::U256; use forge::{fuzz::CounterExample, result::TestStatus, TestOptions}; use foundry_test_utils::Filter; @@ -9,18 +9,18 @@ use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] async fn test_invariant() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([ ( - "fuzz/invariant/common/InvariantHandlerFailure.t.sol:InvariantHandlerFailure", + "default/fuzz/invariant/common/InvariantHandlerFailure.t.sol:InvariantHandlerFailure", vec![("statefulFuzz_BrokenInvariant()", true, None, None, None)], ), ( - "fuzz/invariant/common/InvariantInnerContract.t.sol:InvariantInnerContract", + "default/fuzz/invariant/common/InvariantInnerContract.t.sol:InvariantInnerContract", vec![( "invariantHideJesus()", false, @@ -30,11 +30,11 @@ async fn test_invariant() { )], ), ( - "fuzz/invariant/common/InvariantReentrancy.t.sol:InvariantReentrancy", + "default/fuzz/invariant/common/InvariantReentrancy.t.sol:InvariantReentrancy", vec![("invariantNotStolen()", true, None, None, None)], ), ( - "fuzz/invariant/common/InvariantTest1.t.sol:InvariantTest", + "default/fuzz/invariant/common/InvariantTest1.t.sol:InvariantTest", vec![ ("invariant_neverFalse()", false, Some("revert: false".into()), None, None), ( @@ -47,15 +47,15 @@ async fn test_invariant() { ], ), ( - "fuzz/invariant/target/ExcludeContracts.t.sol:ExcludeContracts", + "default/fuzz/invariant/target/ExcludeContracts.t.sol:ExcludeContracts", vec![("invariantTrueWorld()", true, None, None, None)], ), ( - "fuzz/invariant/target/TargetContracts.t.sol:TargetContracts", + "default/fuzz/invariant/target/TargetContracts.t.sol:TargetContracts", vec![("invariantTrueWorld()", true, None, None, None)], ), ( - "fuzz/invariant/target/TargetSenders.t.sol:TargetSenders", + "default/fuzz/invariant/target/TargetSenders.t.sol:TargetSenders", vec![( "invariantTrueWorld()", false, @@ -65,7 +65,7 @@ async fn test_invariant() { )], ), ( - "fuzz/invariant/target/TargetInterfaces.t.sol:TargetWorldInterfaces", + "default/fuzz/invariant/target/TargetInterfaces.t.sol:TargetWorldInterfaces", vec![( "invariantTrueWorld()", false, @@ -75,19 +75,19 @@ async fn test_invariant() { )], ), ( - "fuzz/invariant/target/ExcludeSenders.t.sol:ExcludeSenders", + "default/fuzz/invariant/target/ExcludeSenders.t.sol:ExcludeSenders", vec![("invariantTrueWorld()", true, None, None, None)], ), ( - "fuzz/invariant/target/TargetSelectors.t.sol:TargetSelectors", + "default/fuzz/invariant/target/TargetSelectors.t.sol:TargetSelectors", vec![("invariantTrueWorld()", true, None, None, None)], ), ( - "fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol:ExcludeArtifacts", + "default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol:ExcludeArtifacts", vec![("invariantShouldPass()", true, None, None, None)], ), ( - "fuzz/invariant/targetAbi/TargetArtifacts.t.sol:TargetArtifacts", + "default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol:TargetArtifacts", vec![ ("invariantShouldPass()", true, None, None, None), ( @@ -100,11 +100,11 @@ async fn test_invariant() { ], ), ( - "fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:TargetArtifactSelectors", + "default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:TargetArtifactSelectors", vec![("invariantShouldPass()", true, None, None, None)], ), ( - "fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:TargetArtifactSelectors2", + "default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:TargetArtifactSelectors2", vec![( "invariantShouldFail()", false, @@ -114,7 +114,7 @@ async fn test_invariant() { )], ), ( - "fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithAssert", + "default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithAssert", vec![( "invariant_with_assert()", false, @@ -124,7 +124,7 @@ async fn test_invariant() { )], ), ( - "fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithRequire", + "default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithRequire", vec![( "invariant_with_require()", false, @@ -134,15 +134,15 @@ async fn test_invariant() { )], ), ( - "fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", + "default/fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", vec![("invariant_preserve_state()", true, None, None, None)], ), ( - "fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", + "default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", vec![("invariant_owner_never_changes()", true, None, None, None)], ), ( - "fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", + "default/fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", vec![("invariant_dummy()", true, None, None, None)], ), ]), @@ -152,14 +152,14 @@ async fn test_invariant() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_override() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantReentrancy.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.invariant.call_override = true; let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantReentrancy.t.sol:InvariantReentrancy", + "default/fuzz/invariant/common/InvariantReentrancy.t.sol:InvariantReentrancy", vec![("invariantNotStolen()", false, Some("revert: stolen".into()), None, None)], )]), ); @@ -168,7 +168,7 @@ async fn test_invariant_override() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_fail_on_revert() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantHandlerFailure.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.invariant.fail_on_revert = true; runner.test_options.invariant.runs = 1; runner.test_options.invariant.depth = 10; @@ -177,7 +177,7 @@ async fn test_invariant_fail_on_revert() { assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantHandlerFailure.t.sol:InvariantHandlerFailure", + "default/fuzz/invariant/common/InvariantHandlerFailure.t.sol:InvariantHandlerFailure", vec![( "statefulFuzz_BrokenInvariant()", false, @@ -193,7 +193,7 @@ async fn test_invariant_fail_on_revert() { #[ignore] async fn test_invariant_storage() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/storage/InvariantStorageTest.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.invariant.depth = 100 + (50 * cfg!(windows) as u32); runner.test_options.fuzz.seed = Some(U256::from(6u32)); let results = runner.test_collect(&filter); @@ -201,7 +201,7 @@ async fn test_invariant_storage() { assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/storage/InvariantStorageTest.t.sol:InvariantStorageTest", + "default/fuzz/invariant/storage/InvariantStorageTest.t.sol:InvariantStorageTest", vec![ ("invariantChangeAddress()", false, Some("changedAddr".to_string()), None, None), ("invariantChangeString()", false, Some("changedString".to_string()), None, None), @@ -216,7 +216,7 @@ async fn test_invariant_storage() { #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.fuzz.seed = Some(U256::from(119u32)); let results = runner.test_collect(&filter); @@ -260,7 +260,7 @@ async fn test_invariant_shrink() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_assert_shrink() { - let mut opts = TEST_OPTS.clone(); + let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); opts.fuzz.seed = Some(U256::from(119u32)); // ensure assert and require shrinks to same sequence of 3 or less @@ -274,7 +274,7 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { contract_pattern, ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol", ); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options = opts.clone(); let results = runner.test_collect(&filter); let results = results.values().last().expect("`InvariantShrinkWithAssert` should be testable."); @@ -303,14 +303,14 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_preserve_state() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); // Should not fail with default options. runner.test_options.invariant.fail_on_revert = true; let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", + "default/fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", vec![("invariant_preserve_state()", true, None, None, None)], )]), ); @@ -322,7 +322,7 @@ async fn test_invariant_preserve_state() { assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", + "default/fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", vec![( "invariant_preserve_state()", false, @@ -337,7 +337,7 @@ async fn test_invariant_preserve_state() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_calldata_fuzz_dictionary_addresses() { // should not fail with default options (address dict not finite) - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let results = runner.test_collect(&Filter::new( ".*", ".*", @@ -346,7 +346,7 @@ async fn test_invariant_calldata_fuzz_dictionary_addresses() { assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", + "default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", vec![("invariant_owner_never_changes()", true, None, None, None)], )]), ); @@ -362,7 +362,7 @@ async fn test_invariant_calldata_fuzz_dictionary_addresses() { assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", + "default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", vec![( "invariant_owner_never_changes()", false, @@ -377,14 +377,14 @@ async fn test_invariant_calldata_fuzz_dictionary_addresses() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_assume_does_not_revert() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAssume.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); // Should not treat vm.assume as revert. runner.test_options.invariant.fail_on_revert = true; let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", + "default/fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", vec![("invariant_dummy()", true, None, None, None)], )]), ); @@ -393,13 +393,13 @@ async fn test_invariant_assume_does_not_revert() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_assume_respects_restrictions() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAssume.t.sol"); - let mut runner = runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.invariant.max_assume_rejects = 1; let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([( - "fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", + "default/fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", vec![( "invariant_dummy()", false, diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 108434e50823a..38cf76331619a 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -1,11 +1,14 @@ //! Regression tests for previous issues. -use crate::{config::*, test_helpers::PROJECT}; +use crate::{ + config::*, + test_helpers::{ForgeTestData, TEST_DATA_DEFAULT}, +}; use alloy_primitives::{address, Address}; use ethers_core::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; use forge::result::TestStatus; use foundry_common::types::ToEthers; -use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; +use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_evm::{ constants::HARDHAT_CONSOLE_ADDRESS, traces::{CallKind, CallTraceDecoder, DecodedCallData, TraceKind}, @@ -24,7 +27,7 @@ macro_rules! test_repro { paste::paste! { #[tokio::test(flavor = "multi_thread")] async fn [< issue_ $issue_number >]() { - repro_config($issue_number, $should_fail, $sender.into()).await.run().await; + repro_config($issue_number, $should_fail, $sender.into(), &*TEST_DATA_DEFAULT).await.run().await; } } }; @@ -32,7 +35,7 @@ macro_rules! test_repro { paste::paste! { #[tokio::test(flavor = "multi_thread")] async fn [< issue_ $issue_number >]() { - let mut $res = repro_config($issue_number, $should_fail, $sender.into()).await.test(); + let mut $res = repro_config($issue_number, $should_fail, $sender.into(), &*TEST_DATA_DEFAULT).await.test(); $e } } @@ -41,7 +44,7 @@ macro_rules! test_repro { paste::paste! { #[tokio::test(flavor = "multi_thread")] async fn [< issue_ $issue_number >]() { - let mut $config = repro_config($issue_number, false, None).await; + let mut $config = repro_config($issue_number, false, None, &*TEST_DATA_DEFAULT).await; $e $config.run().await; } @@ -49,18 +52,23 @@ macro_rules! test_repro { }; } -async fn repro_config(issue: usize, should_fail: bool, sender: Option
) -> TestConfig { +async fn repro_config( + issue: usize, + should_fail: bool, + sender: Option
, + test_data: &ForgeTestData, +) -> TestConfig { foundry_test_utils::init_tracing(); let filter = Filter::path(&format!(".*repros/Issue{issue}.t.sol")); - let mut config = Config::with_root(PROJECT.root()); + let mut config = test_data.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures"), PathPermission::read("out")]); if let Some(sender) = sender { config.sender = sender; } - let runner = runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with_config(config); TestConfig::with_filter(runner, filter).set_should_fail(should_fail) } @@ -114,7 +122,7 @@ test_repro!(3223, false, address!("F0959944122fb1ed4CfaBA645eA06EED30427BAA")); // https://github.com/foundry-rs/foundry/issues/3347 test_repro!(3347, false, None, |res| { - let mut res = res.remove("repros/Issue3347.t.sol:Issue3347Test").unwrap(); + let mut res = res.remove("default/repros/Issue3347.t.sol:Issue3347Test").unwrap(); let test = res.test_results.remove("test()").unwrap(); assert_eq!(test.logs.len(), 1); let event = Event { @@ -221,7 +229,7 @@ test_repro!(6115); // https://github.com/foundry-rs/foundry/issues/6170 test_repro!(6170, false, None, |res| { - let mut res = res.remove("repros/Issue6170.t.sol:Issue6170Test").unwrap(); + let mut res = res.remove("default/repros/Issue6170.t.sol:Issue6170Test").unwrap(); let test = res.test_results.remove("test()").unwrap(); assert_eq!(test.status, TestStatus::Failure); assert_eq!(test.reason, Some("log != expected log".to_string())); @@ -235,7 +243,7 @@ test_repro!(6180); // https://github.com/foundry-rs/foundry/issues/6355 test_repro!(6355, false, None, |res| { - let mut res = res.remove("repros/Issue6355.t.sol:Issue6355Test").unwrap(); + let mut res = res.remove("default/repros/Issue6355.t.sol:Issue6355Test").unwrap(); let test = res.test_results.remove("test_shouldFail()").unwrap(); assert_eq!(test.status, TestStatus::Failure); @@ -249,7 +257,7 @@ test_repro!(6437); // Test we decode Hardhat console logs AND traces correctly. // https://github.com/foundry-rs/foundry/issues/6501 test_repro!(6501, false, None, |res| { - let mut res = res.remove("repros/Issue6501.t.sol:Issue6501Test").unwrap(); + let mut res = res.remove("default/repros/Issue6501.t.sol:Issue6501Test").unwrap(); let test = res.test_results.remove("test_hhLogs()").unwrap(); assert_eq!(test.status, TestStatus::Success); assert_eq!(test.decoded_logs, ["a".to_string(), "1".to_string(), "b 2".to_string()]); @@ -293,7 +301,7 @@ test_repro!(6538); // https://github.com/foundry-rs/foundry/issues/6554 test_repro!(6554; |config| { let mut cheats_config = config.runner.cheats_config.as_ref().clone(); - let path = cheats_config.root.join("out/Issue6554.t.sol"); + let path = cheats_config.root.join("out/default/Issue6554.t.sol"); cheats_config.fs_permissions.add(PathPermission::read_write(path)); config.runner.cheats_config = std::sync::Arc::new(cheats_config); }); diff --git a/crates/forge/tests/it/spec.rs b/crates/forge/tests/it/spec.rs index 4dd6aeee50b1a..db98a15d1af24 100644 --- a/crates/forge/tests/it/spec.rs +++ b/crates/forge/tests/it/spec.rs @@ -1,11 +1,14 @@ //! Integration tests for EVM specifications. -use crate::config::*; +use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use foundry_evm::revm::primitives::SpecId; use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_shanghai_compat() { let filter = Filter::new("", "ShanghaiCompat", ".*spec"); - TestConfig::filter(filter).evm_spec(SpecId::SHANGHAI).run().await; + TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter) + .evm_spec(SpecId::SHANGHAI) + .run() + .await; } diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 969e673579cf8..3d16487568d5c 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -1,51 +1,250 @@ //! Test helpers for Forge integration tests. use alloy_primitives::U256; -use forge::{TestOptions, TestOptionsBuilder}; +use forge::{ + inspectors::CheatsConfig, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, + TestOptionsBuilder, +}; use foundry_compilers::{ artifacts::{Libraries, Settings}, - Project, ProjectCompileOutput, ProjectPathsConfig, SolcConfig, + EvmVersion, Project, ProjectCompileOutput, SolcConfig, +}; +use foundry_config::{ + fs_permissions::PathPermission, Config, FsPermissions, FuzzConfig, FuzzDictionaryConfig, + InvariantConfig, RpcEndpoint, RpcEndpoints, }; -use foundry_config::{Config, FuzzConfig, FuzzDictionaryConfig, InvariantConfig}; use foundry_evm::{ constants::CALLER, - executors::{Executor, FuzzedExecutor}, opts::{Env, EvmOpts}, - revm::db::DatabaseRef, }; -use foundry_test_utils::fd_lock; +use foundry_test_utils::{fd_lock, init_tracing}; use once_cell::sync::Lazy; -use std::{env, io::Write}; +use std::{ + env, fmt, + io::Write, + path::{Path, PathBuf}, +}; pub const RE_PATH_SEPARATOR: &str = "/"; - const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); -pub static PROJECT: Lazy = Lazy::new(|| { - let paths = ProjectPathsConfig::builder().root(TESTDATA).sources(TESTDATA).build().unwrap(); +/// Profile for the tests group. Used to configure separate configurations for test runs. +pub enum ForgeTestProfile { + Default, + Cancun, +} + +impl fmt::Display for ForgeTestProfile { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ForgeTestProfile::Default => write!(f, "default"), + ForgeTestProfile::Cancun => write!(f, "cancun"), + } + } +} + +impl ForgeTestProfile { + pub fn root(&self) -> PathBuf { + PathBuf::from(TESTDATA) + } + + /// Configures the solc settings for the test profile. + pub fn solc_config(&self) -> SolcConfig { + let libs = + ["fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string()]; - let libs = - ["fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string()]; - let settings = Settings { libraries: Libraries::parse(&libs).unwrap(), ..Default::default() }; - let solc_config = SolcConfig::builder().settings(settings).build(); + let mut settings = + Settings { libraries: Libraries::parse(&libs).unwrap(), ..Default::default() }; - Project::builder().paths(paths).solc_config(solc_config).build().unwrap() -}); + if matches!(self, Self::Cancun) { + settings.evm_version = Some(EvmVersion::Cancun); + } -pub static COMPILED: Lazy = Lazy::new(|| { - const LOCK: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata/.lock"); + SolcConfig::builder().settings(settings).build() + } + + pub fn project(&self) -> Project { + self.config().project().expect("Failed to build project") + } + + pub fn test_opts(&self, output: &ProjectCompileOutput) -> TestOptions { + TestOptionsBuilder::default() + .fuzz(FuzzConfig { + runs: 256, + max_test_rejects: 65536, + seed: None, + dictionary: FuzzDictionaryConfig { + include_storage: true, + include_push_bytes: true, + dictionary_weight: 40, + max_fuzz_dictionary_addresses: 10_000, + max_fuzz_dictionary_values: 10_000, + max_calldata_fuzz_dictionary_addresses: 0, + }, + gas_report_samples: 256, + failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), + failure_persist_file: Some("testfailure".to_string()), + }) + .invariant(InvariantConfig { + runs: 256, + depth: 15, + fail_on_revert: false, + call_override: false, + dictionary: FuzzDictionaryConfig { + dictionary_weight: 80, + include_storage: true, + include_push_bytes: true, + max_fuzz_dictionary_addresses: 10_000, + max_fuzz_dictionary_values: 10_000, + max_calldata_fuzz_dictionary_addresses: 0, + }, + shrink_sequence: true, + shrink_run_limit: 2usize.pow(18u32), + preserve_state: false, + max_assume_rejects: 65536, + gas_report_samples: 256, + }) + .build(output, Path::new(self.project().root())) + .expect("Config loaded") + } + + pub fn evm_opts(&self) -> EvmOpts { + EvmOpts { + env: Env { + gas_limit: u64::MAX, + chain_id: None, + tx_origin: CALLER, + block_number: 1, + block_timestamp: 1, + ..Default::default() + }, + sender: CALLER, + initial_balance: U256::MAX, + ffi: true, + verbosity: 3, + memory_limit: 1 << 26, + ..Default::default() + } + } + + /// Build [Config] for test profile. + /// + /// Project source files are read from testdata/{profile_name} + /// Project output files are written to testdata/out/{profile_name} + /// Cache is written to testdata/cache/{profile_name} + /// + /// AST output is enabled by default to support inline configs. + pub fn config(&self) -> Config { + let mut config = Config::with_root(self.root()); + + config.ast = true; + config.src = self.root().join(self.to_string()); + config.out = self.root().join("out").join(self.to_string()); + config.cache_path = self.root().join("cache").join(self.to_string()); + config.libraries = vec![ + "fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string(), + ]; + + if matches!(self, Self::Cancun) { + config.evm_version = EvmVersion::Cancun; + } + + config + } +} + +/// Container for test data for a specific test profile. +pub struct ForgeTestData { + pub project: Project, + pub output: ProjectCompileOutput, + pub test_opts: TestOptions, + pub evm_opts: EvmOpts, + pub config: Config, +} - let project = &*PROJECT; - assert!(project.cached); +impl ForgeTestData { + /// Builds [ForgeTestData] for the given [ForgeTestProfile]. + /// + /// Uses [get_compiled] to lazily compile the project. + pub fn new(profile: ForgeTestProfile) -> Self { + let project = profile.project(); + let output = get_compiled(&project); + let test_opts = profile.test_opts(&output); + let config = profile.config(); + let evm_opts = profile.evm_opts(); + Self { project, output, test_opts, evm_opts, config } + } + + /// Builds a base runner + pub fn base_runner(&self) -> MultiContractRunnerBuilder { + init_tracing(); + MultiContractRunnerBuilder::default() + .sender(self.evm_opts.sender) + .with_test_options(self.test_opts.clone()) + } + + /// Builds a non-tracing runner + pub fn runner(&self) -> MultiContractRunner { + let mut config = self.config.clone(); + config.fs_permissions = + FsPermissions::new(vec![PathPermission::read_write(manifest_root())]); + self.runner_with_config(config) + } + + /// Builds a non-tracing runner + pub fn runner_with_config(&self, mut config: Config) -> MultiContractRunner { + config.rpc_endpoints = rpc_endpoints(); + config.allow_paths.push(manifest_root().to_path_buf()); + + let root = self.project.root(); + let opts = self.evm_opts.clone(); + let env = opts.local_evm_env(); + let output = self.output.clone(); + self.base_runner() + .with_cheats_config(CheatsConfig::new(&config, opts.clone(), None)) + .sender(config.sender) + .with_test_options(self.test_opts.clone()) + .build(root, output, env, opts.clone()) + .unwrap() + } + + /// Builds a tracing runner + pub fn tracing_runner(&self) -> MultiContractRunner { + let mut opts = self.evm_opts.clone(); + opts.verbosity = 5; + self.base_runner() + .build(self.project.root(), self.output.clone(), opts.local_evm_env(), opts) + .unwrap() + } + + /// Builds a runner that runs against forked state + pub async fn forked_runner(&self, rpc: &str) -> MultiContractRunner { + let mut opts = self.evm_opts.clone(); + + opts.env.chain_id = None; // clear chain id so the correct one gets fetched from the RPC + opts.fork_url = Some(rpc.to_string()); + + let env = opts.evm_env().await.expect("Could not instantiate fork environment"); + let fork = opts.get_fork(&Default::default(), env.clone()); + + self.base_runner() + .with_fork(fork) + .build(self.project.root(), self.output.clone(), env, opts) + .unwrap() + } +} + +pub fn get_compiled(project: &Project) -> ProjectCompileOutput { + let lock_file_path = project.sources_path().join(".lock"); // Compile only once per test run. // We need to use a file lock because `cargo-nextest` runs tests in different processes. // This is similar to [`foundry_test_utils::util::initialize`], see its comments for more // details. - let mut lock = fd_lock::new_lock(LOCK); + let mut lock = fd_lock::new_lock(&lock_file_path); let read = lock.read().unwrap(); let out; - if project.cache_path().exists() && std::fs::read(LOCK).unwrap() == b"1" { + if project.cache_path().exists() && std::fs::read(&lock_file_path).unwrap() == b"1" { out = project.compile(); drop(read); } else { @@ -61,73 +260,35 @@ pub static COMPILED: Lazy = Lazy::new(|| { panic!("Compiled with errors:\n{out}"); } out -}); - -pub static EVM_OPTS: Lazy = Lazy::new(|| EvmOpts { - env: Env { - gas_limit: u64::MAX, - chain_id: None, - tx_origin: Config::DEFAULT_SENDER, - block_number: 1, - block_timestamp: 1, - ..Default::default() - }, - sender: Config::DEFAULT_SENDER, - initial_balance: U256::MAX, - ffi: true, - verbosity: 3, - memory_limit: 1 << 26, - ..Default::default() -}); - -pub static TEST_OPTS: Lazy = Lazy::new(|| { - TestOptionsBuilder::default() - .fuzz(FuzzConfig { - runs: 256, - max_test_rejects: 65536, - seed: None, - dictionary: FuzzDictionaryConfig { - include_storage: true, - include_push_bytes: true, - dictionary_weight: 40, - max_fuzz_dictionary_addresses: 10_000, - max_fuzz_dictionary_values: 10_000, - max_calldata_fuzz_dictionary_addresses: 0, - }, - gas_report_samples: 256, - failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), - failure_persist_file: Some("testfailure".to_string()), - }) - .invariant(InvariantConfig { - runs: 256, - depth: 15, - fail_on_revert: false, - call_override: false, - dictionary: FuzzDictionaryConfig { - dictionary_weight: 80, - include_storage: true, - include_push_bytes: true, - max_fuzz_dictionary_addresses: 10_000, - max_fuzz_dictionary_values: 10_000, - max_calldata_fuzz_dictionary_addresses: 0, - }, - shrink_sequence: true, - shrink_run_limit: 2usize.pow(18u32), - preserve_state: false, - max_assume_rejects: 65536, - gas_report_samples: 256, - }) - .build(&COMPILED, &PROJECT.paths.root) - .expect("Config loaded") -}); - -pub fn fuzz_executor(executor: Executor) -> FuzzedExecutor { - let cfg = proptest::test_runner::Config { failure_persistence: None, ..Default::default() }; - - FuzzedExecutor::new( - executor, - proptest::test_runner::TestRunner::new(cfg), - CALLER, - TEST_OPTS.fuzz.clone(), - ) +} + +/// Default data for the tests group. +pub static TEST_DATA_DEFAULT: Lazy = + Lazy::new(|| ForgeTestData::new(ForgeTestProfile::Default)); + +/// Data for tests requiring Cancun support on Solc and EVM level. +pub static TEST_DATA_CANCUN: Lazy = + Lazy::new(|| ForgeTestData::new(ForgeTestProfile::Cancun)); + +pub fn manifest_root() -> &'static Path { + let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); + // need to check here where we're executing the test from, if in `forge` we need to also allow + // `testdata` + if root.ends_with("forge") { + root = root.parent().unwrap(); + } + root +} + +/// the RPC endpoints used during tests +pub fn rpc_endpoints() -> RpcEndpoints { + RpcEndpoints::new([ + ( + "rpcAlias", + RpcEndpoint::Url( + "https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf".to_string(), + ), + ), + ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".to_string())), + ]) } diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index f4449a7694a82..80b06ae769b20 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -38,6 +38,8 @@ impl ScriptTester { "script", "-R", "ds-test/=lib/", + "-R", + "cheats/=cheats/", target_contract, "--root", project_root.to_str().unwrap(), @@ -75,7 +77,7 @@ impl ScriptTester { // copy the broadcast test fs::copy( - Self::testdata_path().join("cheats/Broadcast.t.sol"), + Self::testdata_path().join("default/cheats/Broadcast.t.sol"), project_root.join(BROADCAST_TEST_PATH), ) .expect("Failed to initialize broadcast contract"); @@ -90,8 +92,11 @@ impl ScriptTester { // copy the broadcast test let testdata = Self::testdata_path(); - fs::copy(testdata.join("cheats/Broadcast.t.sol"), project_root.join(BROADCAST_TEST_PATH)) - .expect("Failed to initialize broadcast contract"); + fs::copy( + testdata.join("default/cheats/Broadcast.t.sol"), + project_root.join(BROADCAST_TEST_PATH), + ) + .expect("Failed to initialize broadcast contract"); Self::new(cmd, None, project_root, &target_contract) } @@ -104,7 +109,8 @@ impl ScriptTester { /// Initialises the test contracts by copying them into the workspace fn copy_testdata(current_dir: &Path) -> Result<()> { let testdata = Self::testdata_path(); - fs::copy(testdata.join("cheats/Vm.sol"), current_dir.join("src/Vm.sol"))?; + fs::create_dir_all(current_dir.join("cheats"))?; + fs::copy(testdata.join("cheats/Vm.sol"), current_dir.join("cheats/Vm.sol"))?; fs::copy(testdata.join("lib/ds-test/src/test.sol"), current_dir.join("lib/test.sol"))?; Ok(()) } diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index d392b953e6892..dbb872d8ace10 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -577,7 +577,7 @@ impl TestProject { /// Adds `console.sol` as a source under "console.sol" pub fn insert_console(&self) -> PathBuf { - let s = include_str!("../../../testdata/logs/console.sol"); + let s = include_str!("../../../testdata/default/logs/console.sol"); self.add_source("console.sol", s).unwrap() } diff --git a/testdata/cheats/Addr.t.sol b/testdata/default/cheats/Addr.t.sol similarity index 95% rename from testdata/cheats/Addr.t.sol rename to testdata/default/cheats/Addr.t.sol index 39f14f6aab572..432c52e698c9b 100644 --- a/testdata/cheats/Addr.t.sol +++ b/testdata/default/cheats/Addr.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract AddrTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Assert.t.sol b/testdata/default/cheats/Assert.t.sol similarity index 99% rename from testdata/cheats/Assert.t.sol rename to testdata/default/cheats/Assert.t.sol index 10015a8502c68..d2b0dcb3589aa 100644 --- a/testdata/cheats/Assert.t.sol +++ b/testdata/default/cheats/Assert.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract AssertionsTest is DSTest { string constant errorMessage = "User provided message"; diff --git a/testdata/cheats/Assume.t.sol b/testdata/default/cheats/Assume.t.sol similarity index 92% rename from testdata/cheats/Assume.t.sol rename to testdata/default/cheats/Assume.t.sol index 7520cfd6d1c2e..de11d6644fe9d 100644 --- a/testdata/cheats/Assume.t.sol +++ b/testdata/default/cheats/Assume.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract AssumeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Bank.t.sol b/testdata/default/cheats/Bank.t.sol similarity index 95% rename from testdata/cheats/Bank.t.sol rename to testdata/default/cheats/Bank.t.sol index 31feed4988107..a02fe1667e653 100644 --- a/testdata/cheats/Bank.t.sol +++ b/testdata/default/cheats/Bank.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract CoinbaseTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Base64.t.sol b/testdata/default/cheats/Base64.t.sol similarity index 96% rename from testdata/cheats/Base64.t.sol rename to testdata/default/cheats/Base64.t.sol index 88b792cb2991f..0d2249395aadf 100644 --- a/testdata/cheats/Base64.t.sol +++ b/testdata/default/cheats/Base64.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; contract Base64Test is DSTest { diff --git a/testdata/cheats/Broadcast.t.sol b/testdata/default/cheats/Broadcast.t.sol similarity index 99% rename from testdata/cheats/Broadcast.t.sol rename to testdata/default/cheats/Broadcast.t.sol index d542c28c0e6c5..d44bc954006f2 100644 --- a/testdata/cheats/Broadcast.t.sol +++ b/testdata/default/cheats/Broadcast.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; library F { function t2() public pure returns (uint256) { diff --git a/testdata/cheats/ChainId.t.sol b/testdata/default/cheats/ChainId.t.sol similarity index 93% rename from testdata/cheats/ChainId.t.sol rename to testdata/default/cheats/ChainId.t.sol index af5312241558c..aa8fa0a131ada 100644 --- a/testdata/cheats/ChainId.t.sol +++ b/testdata/default/cheats/ChainId.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract DealTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Cool.t.sol b/testdata/default/cheats/Cool.t.sol similarity index 95% rename from testdata/cheats/Cool.t.sol rename to testdata/default/cheats/Cool.t.sol index d721a442d0123..82212f1b17fe5 100644 --- a/testdata/cheats/Cool.t.sol +++ b/testdata/default/cheats/Cool.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; -import "../lib/ds-test/src/test.sol"; -import "./Vm.sol"; +import "lib/ds-test/src/test.sol"; +import "cheats/Vm.sol"; contract CoolTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Deal.t.sol b/testdata/default/cheats/Deal.t.sol similarity index 96% rename from testdata/cheats/Deal.t.sol rename to testdata/default/cheats/Deal.t.sol index 2729ac73e8037..ac47764356869 100644 --- a/testdata/cheats/Deal.t.sol +++ b/testdata/default/cheats/Deal.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract DealTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Derive.t.sol b/testdata/default/cheats/Derive.t.sol similarity index 96% rename from testdata/cheats/Derive.t.sol rename to testdata/default/cheats/Derive.t.sol index e2107e80cd998..fb14433334715 100644 --- a/testdata/cheats/Derive.t.sol +++ b/testdata/default/cheats/Derive.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract DeriveTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Env.t.sol b/testdata/default/cheats/Env.t.sol similarity index 99% rename from testdata/cheats/Env.t.sol rename to testdata/default/cheats/Env.t.sol index ae6c89ec9856c..523ab34dc1f59 100644 --- a/testdata/cheats/Env.t.sol +++ b/testdata/default/cheats/Env.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract EnvTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Etch.t.sol b/testdata/default/cheats/Etch.t.sol similarity index 96% rename from testdata/cheats/Etch.t.sol rename to testdata/default/cheats/Etch.t.sol index f93a002b29634..6e58fc13bac28 100644 --- a/testdata/cheats/Etch.t.sol +++ b/testdata/default/cheats/Etch.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract EtchTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/ExpectCall.t.sol b/testdata/default/cheats/ExpectCall.t.sol similarity index 99% rename from testdata/cheats/ExpectCall.t.sol rename to testdata/default/cheats/ExpectCall.t.sol index 3cc9e6c573c07..86a5290a92603 100644 --- a/testdata/cheats/ExpectCall.t.sol +++ b/testdata/default/cheats/ExpectCall.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Contract { function numberA() public pure returns (uint256) { diff --git a/testdata/cheats/ExpectEmit.t.sol b/testdata/default/cheats/ExpectEmit.t.sol similarity index 99% rename from testdata/cheats/ExpectEmit.t.sol rename to testdata/default/cheats/ExpectEmit.t.sol index b232ab36b3d54..cad184355443e 100644 --- a/testdata/cheats/ExpectEmit.t.sol +++ b/testdata/default/cheats/ExpectEmit.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Emitter { uint256 public thing; diff --git a/testdata/cheats/ExpectRevert.t.sol b/testdata/default/cheats/ExpectRevert.t.sol similarity index 99% rename from testdata/cheats/ExpectRevert.t.sol rename to testdata/default/cheats/ExpectRevert.t.sol index 6006f45066a9f..0cc6cac59b5fe 100644 --- a/testdata/cheats/ExpectRevert.t.sol +++ b/testdata/default/cheats/ExpectRevert.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Reverter { error CustomError(); diff --git a/testdata/cheats/Fee.t.sol b/testdata/default/cheats/Fee.t.sol similarity index 94% rename from testdata/cheats/Fee.t.sol rename to testdata/default/cheats/Fee.t.sol index 3d6ea72a8bd01..ad93fed6a4ef3 100644 --- a/testdata/cheats/Fee.t.sol +++ b/testdata/default/cheats/Fee.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract FeeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Ffi.t.sol b/testdata/default/cheats/Ffi.t.sol similarity index 97% rename from testdata/cheats/Ffi.t.sol rename to testdata/default/cheats/Ffi.t.sol index 2aa2175e25117..897783d7ec46f 100644 --- a/testdata/cheats/Ffi.t.sol +++ b/testdata/default/cheats/Ffi.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract FfiTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Fork.t.sol b/testdata/default/cheats/Fork.t.sol similarity index 99% rename from testdata/cheats/Fork.t.sol rename to testdata/default/cheats/Fork.t.sol index 0b64b9eb18699..2ff4a6432099b 100644 --- a/testdata/cheats/Fork.t.sol +++ b/testdata/default/cheats/Fork.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; interface IWETH { function deposit() external payable; diff --git a/testdata/cheats/Fork2.t.sol b/testdata/default/cheats/Fork2.t.sol similarity index 99% rename from testdata/cheats/Fork2.t.sol rename to testdata/default/cheats/Fork2.t.sol index b3c1008b7b73f..4b40533347655 100644 --- a/testdata/cheats/Fork2.t.sol +++ b/testdata/default/cheats/Fork2.t.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "../logs/console.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; struct MyStruct { uint256 value; diff --git a/testdata/cheats/Fs.t.sol b/testdata/default/cheats/Fs.t.sol similarity index 99% rename from testdata/cheats/Fs.t.sol rename to testdata/default/cheats/Fs.t.sol index 13093ede6eff3..c48adefec5a22 100644 --- a/testdata/cheats/Fs.t.sol +++ b/testdata/default/cheats/Fs.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract FsTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/GasMetering.t.sol b/testdata/default/cheats/GasMetering.t.sol similarity index 98% rename from testdata/cheats/GasMetering.t.sol rename to testdata/default/cheats/GasMetering.t.sol index e5616634fac3d..54d0a7422aece 100644 --- a/testdata/cheats/GasMetering.t.sol +++ b/testdata/default/cheats/GasMetering.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract B { function a() public returns (uint256) { diff --git a/testdata/cheats/GetBlockTimestamp.t.sol b/testdata/default/cheats/GetBlockTimestamp.t.sol similarity index 96% rename from testdata/cheats/GetBlockTimestamp.t.sol rename to testdata/default/cheats/GetBlockTimestamp.t.sol index 144d6b56ebf75..383bfa8b0801d 100644 --- a/testdata/cheats/GetBlockTimestamp.t.sol +++ b/testdata/default/cheats/GetBlockTimestamp.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract GetBlockTimestampTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/GetCode.t.sol b/testdata/default/cheats/GetCode.t.sol similarity index 99% rename from testdata/cheats/GetCode.t.sol rename to testdata/default/cheats/GetCode.t.sol index db8841f60dc0b..8f47188d554da 100644 --- a/testdata/cheats/GetCode.t.sol +++ b/testdata/default/cheats/GetCode.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract GetCodeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/GetDeployedCode.t.sol b/testdata/default/cheats/GetDeployedCode.t.sol similarity index 99% rename from testdata/cheats/GetDeployedCode.t.sol rename to testdata/default/cheats/GetDeployedCode.t.sol index 71020af18448b..fc8ed609eda99 100644 --- a/testdata/cheats/GetDeployedCode.t.sol +++ b/testdata/default/cheats/GetDeployedCode.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract GetDeployedCodeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/GetLabel.t.sol b/testdata/default/cheats/GetLabel.t.sol similarity index 94% rename from testdata/cheats/GetLabel.t.sol rename to testdata/default/cheats/GetLabel.t.sol index 784a18cea0d70..dcbe0812c8907 100644 --- a/testdata/cheats/GetLabel.t.sol +++ b/testdata/default/cheats/GetLabel.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract GetLabelTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/GetNonce.t.sol b/testdata/default/cheats/GetNonce.t.sol similarity index 94% rename from testdata/cheats/GetNonce.t.sol rename to testdata/default/cheats/GetNonce.t.sol index 8d3a196466b7d..7eb53f205bd19 100644 --- a/testdata/cheats/GetNonce.t.sol +++ b/testdata/default/cheats/GetNonce.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Foo {} diff --git a/testdata/cheats/Json.t.sol b/testdata/default/cheats/Json.t.sol similarity index 99% rename from testdata/cheats/Json.t.sol rename to testdata/default/cheats/Json.t.sol index 3d44dbd2c68a9..b15292e15c7aa 100644 --- a/testdata/cheats/Json.t.sol +++ b/testdata/default/cheats/Json.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; contract ParseJsonTest is DSTest { diff --git a/testdata/cheats/Label.t.sol b/testdata/default/cheats/Label.t.sol similarity index 91% rename from testdata/cheats/Label.t.sol rename to testdata/default/cheats/Label.t.sol index b8e29d195a05f..d554f637dfbde 100644 --- a/testdata/cheats/Label.t.sol +++ b/testdata/default/cheats/Label.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract LabelTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Load.t.sol b/testdata/default/cheats/Load.t.sol similarity index 97% rename from testdata/cheats/Load.t.sol rename to testdata/default/cheats/Load.t.sol index fa5680d71bed5..37a2c80b298cc 100644 --- a/testdata/cheats/Load.t.sol +++ b/testdata/default/cheats/Load.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Storage { uint256 slot0 = 10; diff --git a/testdata/cheats/Mapping.t.sol b/testdata/default/cheats/Mapping.t.sol similarity index 99% rename from testdata/cheats/Mapping.t.sol rename to testdata/default/cheats/Mapping.t.sol index 4dec4156b7605..6cd141fa85a7e 100644 --- a/testdata/cheats/Mapping.t.sol +++ b/testdata/default/cheats/Mapping.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract RecordMapping { int256 length; diff --git a/testdata/cheats/MemSafety.t.sol b/testdata/default/cheats/MemSafety.t.sol similarity index 99% rename from testdata/cheats/MemSafety.t.sol rename to testdata/default/cheats/MemSafety.t.sol index eb00e77de5619..05444e39a1547 100644 --- a/testdata/cheats/MemSafety.t.sol +++ b/testdata/default/cheats/MemSafety.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract MemSafetyTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/MockCall.t.sol b/testdata/default/cheats/MockCall.t.sol similarity index 99% rename from testdata/cheats/MockCall.t.sol rename to testdata/default/cheats/MockCall.t.sol index fa7d9f31449c8..a70b3572b4a85 100644 --- a/testdata/cheats/MockCall.t.sol +++ b/testdata/default/cheats/MockCall.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Mock { uint256 state = 0; diff --git a/testdata/cheats/Parse.t.sol b/testdata/default/cheats/Parse.t.sol similarity index 99% rename from testdata/cheats/Parse.t.sol rename to testdata/default/cheats/Parse.t.sol index a39d32d084b41..71d49af6f2d0b 100644 --- a/testdata/cheats/Parse.t.sol +++ b/testdata/default/cheats/Parse.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract ParseTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Prank.t.sol b/testdata/default/cheats/Prank.t.sol similarity index 99% rename from testdata/cheats/Prank.t.sol rename to testdata/default/cheats/Prank.t.sol index 0e23ed7b805d9..f7dd9b714f80c 100644 --- a/testdata/cheats/Prank.t.sol +++ b/testdata/default/cheats/Prank.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Victim { function assertCallerAndOrigin( diff --git a/testdata/cheats/Prevrandao.t.sol b/testdata/default/cheats/Prevrandao.t.sol similarity index 97% rename from testdata/cheats/Prevrandao.t.sol rename to testdata/default/cheats/Prevrandao.t.sol index 20bab12c4168b..a356fcd4ef293 100644 --- a/testdata/cheats/Prevrandao.t.sol +++ b/testdata/default/cheats/Prevrandao.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract PrevrandaoTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/ProjectRoot.t.sol b/testdata/default/cheats/ProjectRoot.t.sol similarity index 97% rename from testdata/cheats/ProjectRoot.t.sol rename to testdata/default/cheats/ProjectRoot.t.sol index 1edfb0e0795f5..31e68e1058cba 100644 --- a/testdata/cheats/ProjectRoot.t.sol +++ b/testdata/default/cheats/ProjectRoot.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract ProjectRootTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/ReadCallers.t.sol b/testdata/default/cheats/ReadCallers.t.sol similarity index 99% rename from testdata/cheats/ReadCallers.t.sol rename to testdata/default/cheats/ReadCallers.t.sol index 82210b6c47410..e0da8ed0ddccc 100644 --- a/testdata/cheats/ReadCallers.t.sol +++ b/testdata/default/cheats/ReadCallers.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Target { function consumeNewCaller() external {} diff --git a/testdata/cheats/Record.t.sol b/testdata/default/cheats/Record.t.sol similarity index 98% rename from testdata/cheats/Record.t.sol rename to testdata/default/cheats/Record.t.sol index 6fdfa627d24ae..152a5ccb5d0fc 100644 --- a/testdata/cheats/Record.t.sol +++ b/testdata/default/cheats/Record.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract RecordAccess { function record() public returns (NestedRecordAccess) { diff --git a/testdata/cheats/RecordAccountAccesses.t.sol b/testdata/default/cheats/RecordAccountAccesses.t.sol similarity index 99% rename from testdata/cheats/RecordAccountAccesses.t.sol rename to testdata/default/cheats/RecordAccountAccesses.t.sol index a86361a757eb3..bea20570ae345 100644 --- a/testdata/cheats/RecordAccountAccesses.t.sol +++ b/testdata/default/cheats/RecordAccountAccesses.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; /// @notice Helper contract with a construction that makes a call to itself then /// optionally reverts if zero-length data is passed diff --git a/testdata/cheats/RecordLogs.t.sol b/testdata/default/cheats/RecordLogs.t.sol similarity index 99% rename from testdata/cheats/RecordLogs.t.sol rename to testdata/default/cheats/RecordLogs.t.sol index 25fbfaeba43f8..728acdb9b0e76 100644 --- a/testdata/cheats/RecordLogs.t.sol +++ b/testdata/default/cheats/RecordLogs.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Emitter { event LogAnonymous(bytes data) anonymous; diff --git a/testdata/cheats/Remember.t.sol b/testdata/default/cheats/Remember.t.sol similarity index 96% rename from testdata/cheats/Remember.t.sol rename to testdata/default/cheats/Remember.t.sol index 5592081ea47e0..b5487c3698597 100644 --- a/testdata/cheats/Remember.t.sol +++ b/testdata/default/cheats/Remember.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract RememberTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/ResetNonce.t.sol b/testdata/default/cheats/ResetNonce.t.sol similarity index 97% rename from testdata/cheats/ResetNonce.t.sol rename to testdata/default/cheats/ResetNonce.t.sol index 914577bdcc060..9014336091d21 100644 --- a/testdata/cheats/ResetNonce.t.sol +++ b/testdata/default/cheats/ResetNonce.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Foo { function f() external view returns (uint256) { diff --git a/testdata/cheats/Roll.t.sol b/testdata/default/cheats/Roll.t.sol similarity index 97% rename from testdata/cheats/Roll.t.sol rename to testdata/default/cheats/Roll.t.sol index 50011fe87e127..820cd9887b6b6 100644 --- a/testdata/cheats/Roll.t.sol +++ b/testdata/default/cheats/Roll.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract RollTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/RpcUrls.t.sol b/testdata/default/cheats/RpcUrls.t.sol similarity index 98% rename from testdata/cheats/RpcUrls.t.sol rename to testdata/default/cheats/RpcUrls.t.sol index 282c2adddad34..3d7b298f4cf5d 100644 --- a/testdata/cheats/RpcUrls.t.sol +++ b/testdata/default/cheats/RpcUrls.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract RpcUrlTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/SetNonce.t.sol b/testdata/default/cheats/SetNonce.t.sol similarity index 96% rename from testdata/cheats/SetNonce.t.sol rename to testdata/default/cheats/SetNonce.t.sol index 9285ca7e6293f..7f2e419b946f0 100644 --- a/testdata/cheats/SetNonce.t.sol +++ b/testdata/default/cheats/SetNonce.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Foo { function f() external view returns (uint256) { diff --git a/testdata/cheats/SetNonceUnsafe.t.sol b/testdata/default/cheats/SetNonceUnsafe.t.sol similarity index 97% rename from testdata/cheats/SetNonceUnsafe.t.sol rename to testdata/default/cheats/SetNonceUnsafe.t.sol index 1209a28147b2a..723f66ae2557b 100644 --- a/testdata/cheats/SetNonceUnsafe.t.sol +++ b/testdata/default/cheats/SetNonceUnsafe.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Foo { function f() external view returns (uint256) { diff --git a/testdata/cheats/Setup.t.sol b/testdata/default/cheats/Setup.t.sol similarity index 97% rename from testdata/cheats/Setup.t.sol rename to testdata/default/cheats/Setup.t.sol index 986b232d84410..e94bf34ec2d11 100644 --- a/testdata/cheats/Setup.t.sol +++ b/testdata/default/cheats/Setup.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Victim { function assertSender(address sender) external { diff --git a/testdata/cheats/Sign.t.sol b/testdata/default/cheats/Sign.t.sol similarity index 96% rename from testdata/cheats/Sign.t.sol rename to testdata/default/cheats/Sign.t.sol index 587d80e5fea7b..e46439b58d16d 100644 --- a/testdata/cheats/Sign.t.sol +++ b/testdata/default/cheats/Sign.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract SignTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/SignP256.t.sol b/testdata/default/cheats/SignP256.t.sol similarity index 96% rename from testdata/cheats/SignP256.t.sol rename to testdata/default/cheats/SignP256.t.sol index ee0363e970987..f1b62fe78d886 100644 --- a/testdata/cheats/SignP256.t.sol +++ b/testdata/default/cheats/SignP256.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract SignTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Skip.t.sol b/testdata/default/cheats/Skip.t.sol similarity index 96% rename from testdata/cheats/Skip.t.sol rename to testdata/default/cheats/Skip.t.sol index b5f8a019b340f..fb2deadb4f52a 100644 --- a/testdata/cheats/Skip.t.sol +++ b/testdata/default/cheats/Skip.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract SkipTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Sleep.t.sol b/testdata/default/cheats/Sleep.t.sol similarity index 98% rename from testdata/cheats/Sleep.t.sol rename to testdata/default/cheats/Sleep.t.sol index 37be632cc4592..448d34668bed8 100644 --- a/testdata/cheats/Sleep.t.sol +++ b/testdata/default/cheats/Sleep.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract SleepTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Snapshots.t.sol b/testdata/default/cheats/Snapshots.t.sol similarity index 99% rename from testdata/cheats/Snapshots.t.sol rename to testdata/default/cheats/Snapshots.t.sol index baf82e2e57c1d..8f85fee40e8ce 100644 --- a/testdata/cheats/Snapshots.t.sol +++ b/testdata/default/cheats/Snapshots.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; struct Storage { uint256 slot0; diff --git a/testdata/cheats/Store.t.sol b/testdata/default/cheats/Store.t.sol similarity index 98% rename from testdata/cheats/Store.t.sol rename to testdata/default/cheats/Store.t.sol index 08803b92fde32..059952fca7ff2 100644 --- a/testdata/cheats/Store.t.sol +++ b/testdata/default/cheats/Store.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Storage { uint256 public slot0 = 10; diff --git a/testdata/cheats/StringUtils.t.sol b/testdata/default/cheats/StringUtils.t.sol similarity index 98% rename from testdata/cheats/StringUtils.t.sol rename to testdata/default/cheats/StringUtils.t.sol index 4fe8bba01447a..471d628be0182 100644 --- a/testdata/cheats/StringUtils.t.sol +++ b/testdata/default/cheats/StringUtils.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract StringManipulationTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/ToString.t.sol b/testdata/default/cheats/ToString.t.sol similarity index 98% rename from testdata/cheats/ToString.t.sol rename to testdata/default/cheats/ToString.t.sol index c26fdce4cb2da..835c85242883b 100644 --- a/testdata/cheats/ToString.t.sol +++ b/testdata/default/cheats/ToString.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract ToStringTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Toml.t.sol b/testdata/default/cheats/Toml.t.sol similarity index 99% rename from testdata/cheats/Toml.t.sol rename to testdata/default/cheats/Toml.t.sol index ccb73ab87a68d..40667743f8d65 100644 --- a/testdata/cheats/Toml.t.sol +++ b/testdata/default/cheats/Toml.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; contract ParseTomlTest is DSTest { diff --git a/testdata/cheats/Travel.t.sol b/testdata/default/cheats/Travel.t.sol similarity index 95% rename from testdata/cheats/Travel.t.sol rename to testdata/default/cheats/Travel.t.sol index 297017852d69e..733559b2926a9 100644 --- a/testdata/cheats/Travel.t.sol +++ b/testdata/default/cheats/Travel.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract ChainIdTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/TryFfi.sol b/testdata/default/cheats/TryFfi.sol similarity index 97% rename from testdata/cheats/TryFfi.sol rename to testdata/default/cheats/TryFfi.sol index 745b65ce09e4b..58d93a48b4fea 100644 --- a/testdata/cheats/TryFfi.sol +++ b/testdata/default/cheats/TryFfi.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract TryFfiTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/UnixTime.t.sol b/testdata/default/cheats/UnixTime.t.sol similarity index 97% rename from testdata/cheats/UnixTime.t.sol rename to testdata/default/cheats/UnixTime.t.sol index 66cbcc395004a..e128dad2463b2 100644 --- a/testdata/cheats/UnixTime.t.sol +++ b/testdata/default/cheats/UnixTime.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract UnixTimeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/Wallet.t.sol b/testdata/default/cheats/Wallet.t.sol similarity index 99% rename from testdata/cheats/Wallet.t.sol rename to testdata/default/cheats/Wallet.t.sol index a8ce5cc020179..8ecb707aec920 100644 --- a/testdata/cheats/Wallet.t.sol +++ b/testdata/default/cheats/Wallet.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract Foo {} diff --git a/testdata/cheats/Warp.t.sol b/testdata/default/cheats/Warp.t.sol similarity index 96% rename from testdata/cheats/Warp.t.sol rename to testdata/default/cheats/Warp.t.sol index 0400099f8a3a5..01ebc8e89cbf0 100644 --- a/testdata/cheats/Warp.t.sol +++ b/testdata/default/cheats/Warp.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract WarpTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/dumpState.t.sol b/testdata/default/cheats/dumpState.t.sol similarity index 99% rename from testdata/cheats/dumpState.t.sol rename to testdata/default/cheats/dumpState.t.sol index 387865a1bf9d5..74ebd3071f2ce 100644 --- a/testdata/cheats/dumpState.t.sol +++ b/testdata/default/cheats/dumpState.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract SimpleContract { constructor() { diff --git a/testdata/cheats/getBlockNumber.t.sol b/testdata/default/cheats/getBlockNumber.t.sol similarity index 97% rename from testdata/cheats/getBlockNumber.t.sol rename to testdata/default/cheats/getBlockNumber.t.sol index 77409174711e3..c874e5e2f3899 100644 --- a/testdata/cheats/getBlockNumber.t.sol +++ b/testdata/default/cheats/getBlockNumber.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract GetBlockNumberTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/cheats/loadAllocs.t.sol b/testdata/default/cheats/loadAllocs.t.sol similarity index 99% rename from testdata/cheats/loadAllocs.t.sol rename to testdata/default/cheats/loadAllocs.t.sol index f219d025e1f94..358608860bd5d 100644 --- a/testdata/cheats/loadAllocs.t.sol +++ b/testdata/default/cheats/loadAllocs.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "./Vm.sol"; +import "cheats/Vm.sol"; contract LoadAllocsTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/core/Abstract.t.sol b/testdata/default/core/Abstract.t.sol similarity index 100% rename from testdata/core/Abstract.t.sol rename to testdata/default/core/Abstract.t.sol diff --git a/testdata/core/ContractEnvironment.t.sol b/testdata/default/core/ContractEnvironment.t.sol similarity index 100% rename from testdata/core/ContractEnvironment.t.sol rename to testdata/default/core/ContractEnvironment.t.sol diff --git a/testdata/core/DSStyle.t.sol b/testdata/default/core/DSStyle.t.sol similarity index 100% rename from testdata/core/DSStyle.t.sol rename to testdata/default/core/DSStyle.t.sol diff --git a/testdata/core/FailingSetup.t.sol b/testdata/default/core/FailingSetup.t.sol similarity index 100% rename from testdata/core/FailingSetup.t.sol rename to testdata/default/core/FailingSetup.t.sol diff --git a/testdata/core/FailingTestAfterFailedSetup.t.sol b/testdata/default/core/FailingTestAfterFailedSetup.t.sol similarity index 100% rename from testdata/core/FailingTestAfterFailedSetup.t.sol rename to testdata/default/core/FailingTestAfterFailedSetup.t.sol diff --git a/testdata/core/MultipleSetup.t.sol b/testdata/default/core/MultipleSetup.t.sol similarity index 100% rename from testdata/core/MultipleSetup.t.sol rename to testdata/default/core/MultipleSetup.t.sol diff --git a/testdata/core/PaymentFailure.t.sol b/testdata/default/core/PaymentFailure.t.sol similarity index 93% rename from testdata/core/PaymentFailure.t.sol rename to testdata/default/core/PaymentFailure.t.sol index 21558cf9cfa27..d4751b2d52358 100644 --- a/testdata/core/PaymentFailure.t.sol +++ b/testdata/default/core/PaymentFailure.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract Payable { function pay() public payable {} diff --git a/testdata/core/Reverting.t.sol b/testdata/default/core/Reverting.t.sol similarity index 100% rename from testdata/core/Reverting.t.sol rename to testdata/default/core/Reverting.t.sol diff --git a/testdata/core/SetupConsistency.t.sol b/testdata/default/core/SetupConsistency.t.sol similarity index 100% rename from testdata/core/SetupConsistency.t.sol rename to testdata/default/core/SetupConsistency.t.sol diff --git a/testdata/fork/DssExecLib.sol b/testdata/default/fork/DssExecLib.sol similarity index 100% rename from testdata/fork/DssExecLib.sol rename to testdata/default/fork/DssExecLib.sol diff --git a/testdata/fork/ForkSame_1.t.sol b/testdata/default/fork/ForkSame_1.t.sol similarity index 95% rename from testdata/fork/ForkSame_1.t.sol rename to testdata/default/fork/ForkSame_1.t.sol index 01c89e6e2007c..bff9678f65c0b 100644 --- a/testdata/fork/ForkSame_1.t.sol +++ b/testdata/default/fork/ForkSame_1.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract ForkTest is DSTest { address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; diff --git a/testdata/fork/ForkSame_2.t.sol b/testdata/default/fork/ForkSame_2.t.sol similarity index 95% rename from testdata/fork/ForkSame_2.t.sol rename to testdata/default/fork/ForkSame_2.t.sol index 01c89e6e2007c..bff9678f65c0b 100644 --- a/testdata/fork/ForkSame_2.t.sol +++ b/testdata/default/fork/ForkSame_2.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract ForkTest is DSTest { address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; diff --git a/testdata/fork/LaunchFork.t.sol b/testdata/default/fork/LaunchFork.t.sol similarity index 100% rename from testdata/fork/LaunchFork.t.sol rename to testdata/default/fork/LaunchFork.t.sol diff --git a/testdata/fork/Transact.t.sol b/testdata/default/fork/Transact.t.sol similarity index 99% rename from testdata/fork/Transact.t.sol rename to testdata/default/fork/Transact.t.sol index 79c53fa3fd983..ec803906dd2fa 100644 --- a/testdata/fork/Transact.t.sol +++ b/testdata/default/fork/Transact.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; interface IERC20 { diff --git a/testdata/fs/Default.t.sol b/testdata/default/fs/Default.t.sol similarity index 97% rename from testdata/fs/Default.t.sol rename to testdata/default/fs/Default.t.sol index 7ef8c5bd2ff01..5e776e696fb08 100644 --- a/testdata/fs/Default.t.sol +++ b/testdata/default/fs/Default.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract DefaultAccessTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/fs/Disabled.t.sol b/testdata/default/fs/Disabled.t.sol similarity index 97% rename from testdata/fs/Disabled.t.sol rename to testdata/default/fs/Disabled.t.sol index 4c818d91400d4..4efe9affcc3b5 100644 --- a/testdata/fs/Disabled.t.sol +++ b/testdata/default/fs/Disabled.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract DisabledTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/fuzz/Fuzz.t.sol b/testdata/default/fuzz/Fuzz.t.sol similarity index 100% rename from testdata/fuzz/Fuzz.t.sol rename to testdata/default/fuzz/Fuzz.t.sol diff --git a/testdata/fuzz/FuzzCollection.t.sol b/testdata/default/fuzz/FuzzCollection.t.sol similarity index 100% rename from testdata/fuzz/FuzzCollection.t.sol rename to testdata/default/fuzz/FuzzCollection.t.sol diff --git a/testdata/fuzz/FuzzFailurePersist.t.sol b/testdata/default/fuzz/FuzzFailurePersist.t.sol similarity index 96% rename from testdata/fuzz/FuzzFailurePersist.t.sol rename to testdata/default/fuzz/FuzzFailurePersist.t.sol index 1f7c4829cdcf8..0823f29fb1655 100644 --- a/testdata/fuzz/FuzzFailurePersist.t.sol +++ b/testdata/default/fuzz/FuzzFailurePersist.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; struct TestTuple { address user; diff --git a/testdata/fuzz/FuzzInt.t.sol b/testdata/default/fuzz/FuzzInt.t.sol similarity index 100% rename from testdata/fuzz/FuzzInt.t.sol rename to testdata/default/fuzz/FuzzInt.t.sol diff --git a/testdata/fuzz/FuzzPositive.t.sol b/testdata/default/fuzz/FuzzPositive.t.sol similarity index 100% rename from testdata/fuzz/FuzzPositive.t.sol rename to testdata/default/fuzz/FuzzPositive.t.sol diff --git a/testdata/fuzz/FuzzUint.t.sol b/testdata/default/fuzz/FuzzUint.t.sol similarity index 100% rename from testdata/fuzz/FuzzUint.t.sol rename to testdata/default/fuzz/FuzzUint.t.sol diff --git a/testdata/fuzz/invariant/common/InvariantAssume.t.sol b/testdata/default/fuzz/invariant/common/InvariantAssume.t.sol similarity index 91% rename from testdata/fuzz/invariant/common/InvariantAssume.t.sol rename to testdata/default/fuzz/invariant/common/InvariantAssume.t.sol index 3065a70a550ee..4ac0d085c1800 100644 --- a/testdata/fuzz/invariant/common/InvariantAssume.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantAssume.t.sol @@ -2,11 +2,11 @@ pragma solidity ^0.8.0; import "ds-test/test.sol"; -import "../../../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract Handler is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - + function doSomething(uint256 param) public { vm.assume(param != 0); } diff --git a/testdata/fuzz/invariant/common/InvariantCalldataDictionary.t.sol b/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol similarity index 98% rename from testdata/fuzz/invariant/common/InvariantCalldataDictionary.t.sol rename to testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol index c8f87a600b6d0..e1486f9639e90 100644 --- a/testdata/fuzz/invariant/common/InvariantCalldataDictionary.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../../../cheats/Vm.sol"; +import "cheats/Vm.sol"; struct FuzzSelector { address addr; diff --git a/testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol b/testdata/default/fuzz/invariant/common/InvariantHandlerFailure.t.sol similarity index 100% rename from testdata/fuzz/invariant/common/InvariantHandlerFailure.t.sol rename to testdata/default/fuzz/invariant/common/InvariantHandlerFailure.t.sol diff --git a/testdata/fuzz/invariant/common/InvariantInnerContract.t.sol b/testdata/default/fuzz/invariant/common/InvariantInnerContract.t.sol similarity index 100% rename from testdata/fuzz/invariant/common/InvariantInnerContract.t.sol rename to testdata/default/fuzz/invariant/common/InvariantInnerContract.t.sol diff --git a/testdata/fuzz/invariant/common/InvariantPreserveState.t.sol b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol similarity index 97% rename from testdata/fuzz/invariant/common/InvariantPreserveState.t.sol rename to testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol index 20f34c68dc379..5469801362a98 100644 --- a/testdata/fuzz/invariant/common/InvariantPreserveState.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../../../cheats/Vm.sol"; +import "cheats/Vm.sol"; struct FuzzSelector { address addr; diff --git a/testdata/fuzz/invariant/common/InvariantReentrancy.t.sol b/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol similarity index 100% rename from testdata/fuzz/invariant/common/InvariantReentrancy.t.sol rename to testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol diff --git a/testdata/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol similarity index 98% rename from testdata/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol rename to testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol index 0ba6d61c8b797..c189e2507629d 100644 --- a/testdata/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.13; import "ds-test/test.sol"; -import "../../../cheats/Vm.sol"; +import "cheats/Vm.sol"; struct FuzzSelector { address addr; diff --git a/testdata/fuzz/invariant/common/InvariantTest1.t.sol b/testdata/default/fuzz/invariant/common/InvariantTest1.t.sol similarity index 100% rename from testdata/fuzz/invariant/common/InvariantTest1.t.sol rename to testdata/default/fuzz/invariant/common/InvariantTest1.t.sol diff --git a/testdata/fuzz/invariant/storage/InvariantStorageTest.t.sol b/testdata/default/fuzz/invariant/storage/InvariantStorageTest.t.sol similarity index 100% rename from testdata/fuzz/invariant/storage/InvariantStorageTest.t.sol rename to testdata/default/fuzz/invariant/storage/InvariantStorageTest.t.sol diff --git a/testdata/fuzz/invariant/target/ExcludeContracts.t.sol b/testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol similarity index 100% rename from testdata/fuzz/invariant/target/ExcludeContracts.t.sol rename to testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol diff --git a/testdata/fuzz/invariant/target/ExcludeSenders.t.sol b/testdata/default/fuzz/invariant/target/ExcludeSenders.t.sol similarity index 100% rename from testdata/fuzz/invariant/target/ExcludeSenders.t.sol rename to testdata/default/fuzz/invariant/target/ExcludeSenders.t.sol diff --git a/testdata/fuzz/invariant/target/TargetContracts.t.sol b/testdata/default/fuzz/invariant/target/TargetContracts.t.sol similarity index 100% rename from testdata/fuzz/invariant/target/TargetContracts.t.sol rename to testdata/default/fuzz/invariant/target/TargetContracts.t.sol diff --git a/testdata/fuzz/invariant/target/TargetInterfaces.t.sol b/testdata/default/fuzz/invariant/target/TargetInterfaces.t.sol similarity index 100% rename from testdata/fuzz/invariant/target/TargetInterfaces.t.sol rename to testdata/default/fuzz/invariant/target/TargetInterfaces.t.sol diff --git a/testdata/fuzz/invariant/target/TargetSelectors.t.sol b/testdata/default/fuzz/invariant/target/TargetSelectors.t.sol similarity index 100% rename from testdata/fuzz/invariant/target/TargetSelectors.t.sol rename to testdata/default/fuzz/invariant/target/TargetSelectors.t.sol diff --git a/testdata/fuzz/invariant/target/TargetSenders.t.sol b/testdata/default/fuzz/invariant/target/TargetSenders.t.sol similarity index 100% rename from testdata/fuzz/invariant/target/TargetSenders.t.sol rename to testdata/default/fuzz/invariant/target/TargetSenders.t.sol diff --git a/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol b/testdata/default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol similarity index 91% rename from testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol rename to testdata/default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol index ce81a51cf6bf0..bf457ab1709a5 100644 --- a/testdata/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol @@ -35,7 +35,7 @@ contract ExcludeArtifacts is DSTest { function excludeArtifacts() public returns (string[] memory) { string[] memory abis = new string[](1); - abis[0] = "fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol:Excluded"; + abis[0] = "default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol:Excluded"; return abis; } diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol similarity index 87% rename from testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol rename to testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol index e82e7b1a36e88..d7c8bcdfae4aa 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol @@ -31,7 +31,7 @@ contract TargetArtifactSelectors is DSTest { FuzzAbiSelector[] memory targets = new FuzzAbiSelector[](1); bytes4[] memory selectors = new bytes4[](1); selectors[0] = Hi.no_change.selector; - targets[0] = FuzzAbiSelector("fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:Hi", selectors); + targets[0] = FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:Hi", selectors); return targets; } diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol similarity index 84% rename from testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol rename to testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol index 5592aa84969dd..573350c6e0238 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol @@ -51,11 +51,13 @@ contract TargetArtifactSelectors2 is DSTest { bytes4[] memory selectors_child = new bytes4[](1); selectors_child[0] = Child.change_parent.selector; - targets[0] = FuzzAbiSelector("fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Child", selectors_child); + targets[0] = + FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Child", selectors_child); bytes4[] memory selectors_parent = new bytes4[](1); selectors_parent[0] = Parent.create.selector; - targets[1] = FuzzAbiSelector("fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Parent", selectors_parent); + targets[1] = + FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Parent", selectors_parent); return targets; } diff --git a/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol similarity index 91% rename from testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol rename to testdata/default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol index d3eb2cf9dfa1d..ea86ab135b624 100644 --- a/testdata/fuzz/invariant/targetAbi/TargetArtifacts.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol @@ -30,7 +30,7 @@ contract TargetArtifacts is DSTest { function targetArtifacts() public returns (string[] memory) { string[] memory abis = new string[](1); - abis[0] = "fuzz/invariant/targetAbi/TargetArtifacts.t.sol:Targeted"; + abis[0] = "default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol:Targeted"; return abis; } diff --git a/testdata/inline/FuzzInlineConf.t.sol b/testdata/default/inline/FuzzInlineConf.t.sol similarity index 100% rename from testdata/inline/FuzzInlineConf.t.sol rename to testdata/default/inline/FuzzInlineConf.t.sol diff --git a/testdata/inline/InvariantInlineConf.t.sol b/testdata/default/inline/InvariantInlineConf.t.sol similarity index 100% rename from testdata/inline/InvariantInlineConf.t.sol rename to testdata/default/inline/InvariantInlineConf.t.sol diff --git a/testdata/linking/cycle/Cycle.t.sol b/testdata/default/linking/cycle/Cycle.t.sol similarity index 100% rename from testdata/linking/cycle/Cycle.t.sol rename to testdata/default/linking/cycle/Cycle.t.sol diff --git a/testdata/linking/duplicate/Duplicate.t.sol b/testdata/default/linking/duplicate/Duplicate.t.sol similarity index 100% rename from testdata/linking/duplicate/Duplicate.t.sol rename to testdata/default/linking/duplicate/Duplicate.t.sol diff --git a/testdata/linking/nested/Nested.t.sol b/testdata/default/linking/nested/Nested.t.sol similarity index 100% rename from testdata/linking/nested/Nested.t.sol rename to testdata/default/linking/nested/Nested.t.sol diff --git a/testdata/linking/simple/Simple.t.sol b/testdata/default/linking/simple/Simple.t.sol similarity index 100% rename from testdata/linking/simple/Simple.t.sol rename to testdata/default/linking/simple/Simple.t.sol diff --git a/testdata/logs/DebugLogs.t.sol b/testdata/default/logs/DebugLogs.t.sol similarity index 100% rename from testdata/logs/DebugLogs.t.sol rename to testdata/default/logs/DebugLogs.t.sol diff --git a/testdata/logs/HardhatLogs.t.sol b/testdata/default/logs/HardhatLogs.t.sol similarity index 100% rename from testdata/logs/HardhatLogs.t.sol rename to testdata/default/logs/HardhatLogs.t.sol diff --git a/testdata/logs/console.sol b/testdata/default/logs/console.sol similarity index 100% rename from testdata/logs/console.sol rename to testdata/default/logs/console.sol diff --git a/testdata/repros/Issue2623.t.sol b/testdata/default/repros/Issue2623.t.sol similarity index 95% rename from testdata/repros/Issue2623.t.sol rename to testdata/default/repros/Issue2623.t.sol index cf91d10a54168..8534aeeafabff 100644 --- a/testdata/repros/Issue2623.t.sol +++ b/testdata/default/repros/Issue2623.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2623 contract Issue2623Test is DSTest { diff --git a/testdata/repros/Issue2629.t.sol b/testdata/default/repros/Issue2629.t.sol similarity index 96% rename from testdata/repros/Issue2629.t.sol rename to testdata/default/repros/Issue2629.t.sol index 296ebfc325b2a..a1f430858380e 100644 --- a/testdata/repros/Issue2629.t.sol +++ b/testdata/default/repros/Issue2629.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2629 contract Issue2629Test is DSTest { diff --git a/testdata/repros/Issue2723.t.sol b/testdata/default/repros/Issue2723.t.sol similarity index 95% rename from testdata/repros/Issue2723.t.sol rename to testdata/default/repros/Issue2723.t.sol index 6ecd7df8d3b90..c260f9467252e 100644 --- a/testdata/repros/Issue2723.t.sol +++ b/testdata/default/repros/Issue2723.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2723 contract Issue2723Test is DSTest { diff --git a/testdata/repros/Issue2898.t.sol b/testdata/default/repros/Issue2898.t.sol similarity index 96% rename from testdata/repros/Issue2898.t.sol rename to testdata/default/repros/Issue2898.t.sol index 6f6eb5e35ce55..23de35bcdc059 100644 --- a/testdata/repros/Issue2898.t.sol +++ b/testdata/default/repros/Issue2898.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; // https://github.com/foundry-rs/foundry/issues/2898 diff --git a/testdata/repros/Issue2956.t.sol b/testdata/default/repros/Issue2956.t.sol similarity index 97% rename from testdata/repros/Issue2956.t.sol rename to testdata/default/repros/Issue2956.t.sol index 8e9841e2b5bb9..f77340da4ae21 100644 --- a/testdata/repros/Issue2956.t.sol +++ b/testdata/default/repros/Issue2956.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2956 contract Issue2956Test is DSTest { diff --git a/testdata/repros/Issue2984.t.sol b/testdata/default/repros/Issue2984.t.sol similarity index 96% rename from testdata/repros/Issue2984.t.sol rename to testdata/default/repros/Issue2984.t.sol index 223866926b0bc..8e55d5dae4b17 100644 --- a/testdata/repros/Issue2984.t.sol +++ b/testdata/default/repros/Issue2984.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2984 contract Issue2984Test is DSTest { diff --git a/testdata/repros/Issue3055.t.sol b/testdata/default/repros/Issue3055.t.sol similarity index 97% rename from testdata/repros/Issue3055.t.sol rename to testdata/default/repros/Issue3055.t.sol index 0a94e4d2a50b5..cacf5282f0581 100644 --- a/testdata/repros/Issue3055.t.sol +++ b/testdata/default/repros/Issue3055.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3055 contract Issue3055Test is DSTest { diff --git a/testdata/repros/Issue3077.t.sol b/testdata/default/repros/Issue3077.t.sol similarity index 97% rename from testdata/repros/Issue3077.t.sol rename to testdata/default/repros/Issue3077.t.sol index 36cfb071cad4b..cc76b57b6fb2e 100644 --- a/testdata/repros/Issue3077.t.sol +++ b/testdata/default/repros/Issue3077.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3077 abstract contract ZeroState is DSTest { diff --git a/testdata/repros/Issue3110.t.sol b/testdata/default/repros/Issue3110.t.sol similarity index 97% rename from testdata/repros/Issue3110.t.sol rename to testdata/default/repros/Issue3110.t.sol index 259a467d32946..7a2622427a615 100644 --- a/testdata/repros/Issue3110.t.sol +++ b/testdata/default/repros/Issue3110.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3110 abstract contract ZeroState is DSTest { diff --git a/testdata/repros/Issue3119.t.sol b/testdata/default/repros/Issue3119.t.sol similarity index 96% rename from testdata/repros/Issue3119.t.sol rename to testdata/default/repros/Issue3119.t.sol index 80f539660a3bf..5c94b4c5fde56 100644 --- a/testdata/repros/Issue3119.t.sol +++ b/testdata/default/repros/Issue3119.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3119 contract Issue3119Test is DSTest { diff --git a/testdata/repros/Issue3189.t.sol b/testdata/default/repros/Issue3189.t.sol similarity index 96% rename from testdata/repros/Issue3189.t.sol rename to testdata/default/repros/Issue3189.t.sol index 771b8f514c784..27ea0ac51cfd5 100644 --- a/testdata/repros/Issue3189.t.sol +++ b/testdata/default/repros/Issue3189.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3189 contract MyContract { diff --git a/testdata/repros/Issue3190.t.sol b/testdata/default/repros/Issue3190.t.sol similarity index 94% rename from testdata/repros/Issue3190.t.sol rename to testdata/default/repros/Issue3190.t.sol index b5d5c70e97240..4a9add5f5c616 100644 --- a/testdata/repros/Issue3190.t.sol +++ b/testdata/default/repros/Issue3190.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; // https://github.com/foundry-rs/foundry/issues/3190 diff --git a/testdata/repros/Issue3192.t.sol b/testdata/default/repros/Issue3192.t.sol similarity index 95% rename from testdata/repros/Issue3192.t.sol rename to testdata/default/repros/Issue3192.t.sol index 36841fd081579..0deb22f49e084 100644 --- a/testdata/repros/Issue3192.t.sol +++ b/testdata/default/repros/Issue3192.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3192 contract Issue3192Test is DSTest { diff --git a/testdata/repros/Issue3220.t.sol b/testdata/default/repros/Issue3220.t.sol similarity index 97% rename from testdata/repros/Issue3220.t.sol rename to testdata/default/repros/Issue3220.t.sol index acf75352d3877..b88d997c12051 100644 --- a/testdata/repros/Issue3220.t.sol +++ b/testdata/default/repros/Issue3220.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3220 contract Issue3220Test is DSTest { diff --git a/testdata/repros/Issue3221.t.sol b/testdata/default/repros/Issue3221.t.sol similarity index 97% rename from testdata/repros/Issue3221.t.sol rename to testdata/default/repros/Issue3221.t.sol index cc6f8039e87f9..9fbc51f60f930 100644 --- a/testdata/repros/Issue3221.t.sol +++ b/testdata/default/repros/Issue3221.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3221 contract Issue3221Test is DSTest { diff --git a/testdata/repros/Issue3223.t.sol b/testdata/default/repros/Issue3223.t.sol similarity index 97% rename from testdata/repros/Issue3223.t.sol rename to testdata/default/repros/Issue3223.t.sol index 14d46838e8330..4408d24eee5d4 100644 --- a/testdata/repros/Issue3223.t.sol +++ b/testdata/default/repros/Issue3223.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3223 contract Issue3223Test is DSTest { diff --git a/testdata/repros/Issue3347.t.sol b/testdata/default/repros/Issue3347.t.sol similarity index 91% rename from testdata/repros/Issue3347.t.sol rename to testdata/default/repros/Issue3347.t.sol index 66657ea626e8e..ed9be5f365b8e 100644 --- a/testdata/repros/Issue3347.t.sol +++ b/testdata/default/repros/Issue3347.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3347 contract Issue3347Test is DSTest { diff --git a/testdata/repros/Issue3437.t.sol b/testdata/default/repros/Issue3437.t.sol similarity index 93% rename from testdata/repros/Issue3437.t.sol rename to testdata/default/repros/Issue3437.t.sol index acd02ada74214..69f56ca8283dd 100644 --- a/testdata/repros/Issue3437.t.sol +++ b/testdata/default/repros/Issue3437.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3437 contract Issue3347Test is DSTest { diff --git a/testdata/repros/Issue3596.t.sol b/testdata/default/repros/Issue3596.t.sol similarity index 96% rename from testdata/repros/Issue3596.t.sol rename to testdata/default/repros/Issue3596.t.sol index 9a942d3424bb4..04ee470d70b37 100644 --- a/testdata/repros/Issue3596.t.sol +++ b/testdata/default/repros/Issue3596.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3596 contract Issue3596Test is DSTest { diff --git a/testdata/repros/Issue3653.t.sol b/testdata/default/repros/Issue3653.t.sol similarity index 95% rename from testdata/repros/Issue3653.t.sol rename to testdata/default/repros/Issue3653.t.sol index 5022af67859f0..b86f84c3e735d 100644 --- a/testdata/repros/Issue3653.t.sol +++ b/testdata/default/repros/Issue3653.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3653 contract Issue3653Test is DSTest { diff --git a/testdata/repros/Issue3661.t.sol b/testdata/default/repros/Issue3661.t.sol similarity index 100% rename from testdata/repros/Issue3661.t.sol rename to testdata/default/repros/Issue3661.t.sol diff --git a/testdata/repros/Issue3674.t.sol b/testdata/default/repros/Issue3674.t.sol similarity index 94% rename from testdata/repros/Issue3674.t.sol rename to testdata/default/repros/Issue3674.t.sol index 57216e8054811..f13f7f162b368 100644 --- a/testdata/repros/Issue3674.t.sol +++ b/testdata/default/repros/Issue3674.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3674 contract Issue3674Test is DSTest { diff --git a/testdata/repros/Issue3685.t.sol b/testdata/default/repros/Issue3685.t.sol similarity index 97% rename from testdata/repros/Issue3685.t.sol rename to testdata/default/repros/Issue3685.t.sol index 748367f659821..7e8f886d890cd 100644 --- a/testdata/repros/Issue3685.t.sol +++ b/testdata/default/repros/Issue3685.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; // https://github.com/foundry-rs/foundry/issues/3685 diff --git a/testdata/repros/Issue3703.t.sol b/testdata/default/repros/Issue3703.t.sol similarity index 98% rename from testdata/repros/Issue3703.t.sol rename to testdata/default/repros/Issue3703.t.sol index c941fe223902b..06ce6bcbe92af 100644 --- a/testdata/repros/Issue3703.t.sol +++ b/testdata/default/repros/Issue3703.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3703 contract Issue3703Test is DSTest { diff --git a/testdata/repros/Issue3708.t.sol b/testdata/default/repros/Issue3708.t.sol similarity index 97% rename from testdata/repros/Issue3708.t.sol rename to testdata/default/repros/Issue3708.t.sol index 7cf57cd0e082a..f5bdf48bf76a3 100644 --- a/testdata/repros/Issue3708.t.sol +++ b/testdata/default/repros/Issue3708.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3708 contract Issue3708Test is DSTest { diff --git a/testdata/repros/Issue3723.t.sol b/testdata/default/repros/Issue3723.t.sol similarity index 93% rename from testdata/repros/Issue3723.t.sol rename to testdata/default/repros/Issue3723.t.sol index 0f5d6694b7dfe..9ea3fe733c944 100644 --- a/testdata/repros/Issue3723.t.sol +++ b/testdata/default/repros/Issue3723.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3723 contract Issue3723Test is DSTest { diff --git a/testdata/repros/Issue3753.t.sol b/testdata/default/repros/Issue3753.t.sol similarity index 94% rename from testdata/repros/Issue3753.t.sol rename to testdata/default/repros/Issue3753.t.sol index 1edbb42b8059b..7af774baf49d3 100644 --- a/testdata/repros/Issue3753.t.sol +++ b/testdata/default/repros/Issue3753.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3753 contract Issue3753Test is DSTest { diff --git a/testdata/repros/Issue3792.t.sol b/testdata/default/repros/Issue3792.t.sol similarity index 96% rename from testdata/repros/Issue3792.t.sol rename to testdata/default/repros/Issue3792.t.sol index e01671f37d0fc..723329f937a1e 100644 --- a/testdata/repros/Issue3792.t.sol +++ b/testdata/default/repros/Issue3792.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract Config { address public test = 0xcBa28b38103307Ec8dA98377ffF9816C164f9AFa; diff --git a/testdata/repros/Issue4402.t.sol b/testdata/default/repros/Issue4402.t.sol similarity index 99% rename from testdata/repros/Issue4402.t.sol rename to testdata/default/repros/Issue4402.t.sol index c69285b7f04eb..3bf0f33fb96fc 100644 --- a/testdata/repros/Issue4402.t.sol +++ b/testdata/default/repros/Issue4402.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/4402 contract Issue4402Test is DSTest { diff --git a/testdata/repros/Issue4586.t.sol b/testdata/default/repros/Issue4586.t.sol similarity index 97% rename from testdata/repros/Issue4586.t.sol rename to testdata/default/repros/Issue4586.t.sol index 6eb615c029fa1..a41ba7a0485ea 100644 --- a/testdata/repros/Issue4586.t.sol +++ b/testdata/default/repros/Issue4586.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/4586 contract Issue4586Test is DSTest { diff --git a/testdata/repros/Issue4630.t.sol b/testdata/default/repros/Issue4630.t.sol similarity index 96% rename from testdata/repros/Issue4630.t.sol rename to testdata/default/repros/Issue4630.t.sol index 3979d5072e595..4b9fe9c9b80ba 100644 --- a/testdata/repros/Issue4630.t.sol +++ b/testdata/default/repros/Issue4630.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/4630 contract Issue4630Test is DSTest { diff --git a/testdata/repros/Issue4640.t.sol b/testdata/default/repros/Issue4640.t.sol similarity index 94% rename from testdata/repros/Issue4640.t.sol rename to testdata/default/repros/Issue4640.t.sol index b16f4d071fd36..a875d000de979 100644 --- a/testdata/repros/Issue4640.t.sol +++ b/testdata/default/repros/Issue4640.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/4640 contract Issue4640Test is DSTest { diff --git a/testdata/repros/Issue4832.t.sol b/testdata/default/repros/Issue4832.t.sol similarity index 92% rename from testdata/repros/Issue4832.t.sol rename to testdata/default/repros/Issue4832.t.sol index 72f846873ff1b..192d805c1bc36 100644 --- a/testdata/repros/Issue4832.t.sol +++ b/testdata/default/repros/Issue4832.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/4832 contract Issue4832Test is DSTest { diff --git a/testdata/repros/Issue5038.t.sol b/testdata/default/repros/Issue5038.t.sol similarity index 99% rename from testdata/repros/Issue5038.t.sol rename to testdata/default/repros/Issue5038.t.sol index bee48f0b7fb12..834f8278375a4 100644 --- a/testdata/repros/Issue5038.t.sol +++ b/testdata/default/repros/Issue5038.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; struct Value { uint256 value; diff --git a/testdata/repros/Issue5529.t.sol b/testdata/default/repros/Issue5529.t.sol similarity index 97% rename from testdata/repros/Issue5529.t.sol rename to testdata/default/repros/Issue5529.t.sol index 35e7140014ad0..14ec7cfdbce60 100644 --- a/testdata/repros/Issue5529.t.sol +++ b/testdata/default/repros/Issue5529.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.13; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract Counter { uint256 public number; diff --git a/testdata/repros/Issue5808.t.sol b/testdata/default/repros/Issue5808.t.sol similarity index 95% rename from testdata/repros/Issue5808.t.sol rename to testdata/default/repros/Issue5808.t.sol index 1914264bfe90c..66ea82b30480e 100644 --- a/testdata/repros/Issue5808.t.sol +++ b/testdata/default/repros/Issue5808.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/5808 contract Issue5808Test is DSTest { diff --git a/testdata/repros/Issue5929.t.sol b/testdata/default/repros/Issue5929.t.sol similarity index 95% rename from testdata/repros/Issue5929.t.sol rename to testdata/default/repros/Issue5929.t.sol index 53ca10ae86e2f..f1009f03b93c4 100644 --- a/testdata/repros/Issue5929.t.sol +++ b/testdata/default/repros/Issue5929.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/5929 contract Issue5929Test is DSTest { diff --git a/testdata/repros/Issue5935.t.sol b/testdata/default/repros/Issue5935.t.sol similarity index 97% rename from testdata/repros/Issue5935.t.sol rename to testdata/default/repros/Issue5935.t.sol index 8d6f8687b9339..95b6f8fd5b3a9 100644 --- a/testdata/repros/Issue5935.t.sol +++ b/testdata/default/repros/Issue5935.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0 <0.9.0; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract SimpleStorage { uint256 public value; diff --git a/testdata/repros/Issue5948.t.sol b/testdata/default/repros/Issue5948.t.sol similarity index 97% rename from testdata/repros/Issue5948.t.sol rename to testdata/default/repros/Issue5948.t.sol index b496caf66706d..992099fb1061a 100644 --- a/testdata/repros/Issue5948.t.sol +++ b/testdata/default/repros/Issue5948.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/5948 contract Issue5948Test is DSTest { diff --git a/testdata/repros/Issue6006.t.sol b/testdata/default/repros/Issue6006.t.sol similarity index 97% rename from testdata/repros/Issue6006.t.sol rename to testdata/default/repros/Issue6006.t.sol index 63e2cd5c6232f..dac37cd24b2c1 100644 --- a/testdata/repros/Issue6006.t.sol +++ b/testdata/default/repros/Issue6006.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6006 contract Issue6066Test is DSTest { diff --git a/testdata/repros/Issue6032.t.sol b/testdata/default/repros/Issue6032.t.sol similarity index 98% rename from testdata/repros/Issue6032.t.sol rename to testdata/default/repros/Issue6032.t.sol index c9f82f209d51d..fc230c47e183e 100644 --- a/testdata/repros/Issue6032.t.sol +++ b/testdata/default/repros/Issue6032.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6032 contract Issue6032Test is DSTest { diff --git a/testdata/repros/Issue6070.t.sol b/testdata/default/repros/Issue6070.t.sol similarity index 95% rename from testdata/repros/Issue6070.t.sol rename to testdata/default/repros/Issue6070.t.sol index db330f4b103b1..e699f5ca9f3b2 100644 --- a/testdata/repros/Issue6070.t.sol +++ b/testdata/default/repros/Issue6070.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6070 contract Issue6066Test is DSTest { diff --git a/testdata/repros/Issue6115.t.sol b/testdata/default/repros/Issue6115.t.sol similarity index 100% rename from testdata/repros/Issue6115.t.sol rename to testdata/default/repros/Issue6115.t.sol diff --git a/testdata/repros/Issue6170.t.sol b/testdata/default/repros/Issue6170.t.sol similarity index 95% rename from testdata/repros/Issue6170.t.sol rename to testdata/default/repros/Issue6170.t.sol index 43f2067d6308c..543ca3142c9a8 100644 --- a/testdata/repros/Issue6170.t.sol +++ b/testdata/default/repros/Issue6170.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract Emitter { event Values(uint256 indexed a, uint256 indexed b); diff --git a/testdata/repros/Issue6180.t.sol b/testdata/default/repros/Issue6180.t.sol similarity index 95% rename from testdata/repros/Issue6180.t.sol rename to testdata/default/repros/Issue6180.t.sol index 7ff0684345120..591c60bdf8d0b 100644 --- a/testdata/repros/Issue6180.t.sol +++ b/testdata/default/repros/Issue6180.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6180 contract Issue6180Test is DSTest { diff --git a/testdata/repros/Issue6293.t.sol b/testdata/default/repros/Issue6293.t.sol similarity index 93% rename from testdata/repros/Issue6293.t.sol rename to testdata/default/repros/Issue6293.t.sol index c90f56806203f..303e8fbbe297a 100644 --- a/testdata/repros/Issue6293.t.sol +++ b/testdata/default/repros/Issue6293.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6293 contract Issue6293Test is DSTest { diff --git a/testdata/repros/Issue6355.t.sol b/testdata/default/repros/Issue6355.t.sol similarity index 96% rename from testdata/repros/Issue6355.t.sol rename to testdata/default/repros/Issue6355.t.sol index 7271011c674de..d7830152a60a8 100644 --- a/testdata/repros/Issue6355.t.sol +++ b/testdata/default/repros/Issue6355.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6355 contract Issue6355Test is DSTest { diff --git a/testdata/repros/Issue6437.t.sol b/testdata/default/repros/Issue6437.t.sol similarity index 97% rename from testdata/repros/Issue6437.t.sol rename to testdata/default/repros/Issue6437.t.sol index 529c96d2e5e46..c18af2dfda841 100644 --- a/testdata/repros/Issue6437.t.sol +++ b/testdata/default/repros/Issue6437.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6437 contract Issue6437Test is DSTest { diff --git a/testdata/repros/Issue6501.t.sol b/testdata/default/repros/Issue6501.t.sol similarity index 100% rename from testdata/repros/Issue6501.t.sol rename to testdata/default/repros/Issue6501.t.sol diff --git a/testdata/repros/Issue6538.t.sol b/testdata/default/repros/Issue6538.t.sol similarity index 95% rename from testdata/repros/Issue6538.t.sol rename to testdata/default/repros/Issue6538.t.sol index d174449c787aa..d83bbc850f5e1 100644 --- a/testdata/repros/Issue6538.t.sol +++ b/testdata/default/repros/Issue6538.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6538 contract Issue6538Test is DSTest { diff --git a/testdata/repros/Issue6554.t.sol b/testdata/default/repros/Issue6554.t.sol similarity index 61% rename from testdata/repros/Issue6554.t.sol rename to testdata/default/repros/Issue6554.t.sol index be7af3d9d9ca2..c13ebc4a7d712 100644 --- a/testdata/repros/Issue6554.t.sol +++ b/testdata/default/repros/Issue6554.t.sol @@ -2,15 +2,15 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6554 contract Issue6554Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testPermissions() public { - vm.writeFile("./out/Issue6554.t.sol/cachedFile.txt", "cached data"); - string memory content = vm.readFile("./out/Issue6554.t.sol/cachedFile.txt"); + vm.writeFile("./out/default/Issue6554.t.sol/cachedFile.txt", "cached data"); + string memory content = vm.readFile("./out/default/Issue6554.t.sol/cachedFile.txt"); assertEq(content, "cached data"); } } diff --git a/testdata/repros/Issue6616.t.sol b/testdata/default/repros/Issue6616.t.sol similarity index 96% rename from testdata/repros/Issue6616.t.sol rename to testdata/default/repros/Issue6616.t.sol index 6c9991f0e79b6..24fa00e214eec 100644 --- a/testdata/repros/Issue6616.t.sol +++ b/testdata/default/repros/Issue6616.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6616 contract Issue6616Test is DSTest { diff --git a/testdata/repros/Issue6634.t.sol b/testdata/default/repros/Issue6634.t.sol similarity index 99% rename from testdata/repros/Issue6634.t.sol rename to testdata/default/repros/Issue6634.t.sol index 3b1acb9c18aa9..22294f6df2338 100644 --- a/testdata/repros/Issue6634.t.sol +++ b/testdata/default/repros/Issue6634.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; import "../logs/console.sol"; contract Box { diff --git a/testdata/repros/Issue6759.t.sol b/testdata/default/repros/Issue6759.t.sol similarity index 95% rename from testdata/repros/Issue6759.t.sol rename to testdata/default/repros/Issue6759.t.sol index 45a2f42b0620d..a8039035e99d0 100644 --- a/testdata/repros/Issue6759.t.sol +++ b/testdata/default/repros/Issue6759.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6759 contract Issue6759Test is DSTest { diff --git a/testdata/repros/Issue6966.t.sol b/testdata/default/repros/Issue6966.t.sol similarity index 100% rename from testdata/repros/Issue6966.t.sol rename to testdata/default/repros/Issue6966.t.sol diff --git a/testdata/script/broadcast/deploy.sol/31337/run-latest.json b/testdata/default/script/broadcast/deploy.sol/31337/run-latest.json similarity index 100% rename from testdata/script/broadcast/deploy.sol/31337/run-latest.json rename to testdata/default/script/broadcast/deploy.sol/31337/run-latest.json diff --git a/testdata/script/deploy.sol b/testdata/default/script/deploy.sol similarity index 89% rename from testdata/script/deploy.sol rename to testdata/default/script/deploy.sol index f05afe48706f6..013e009d3eaec 100644 --- a/testdata/script/deploy.sol +++ b/testdata/default/script/deploy.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity 0.8.18; -import {DSTest} from "../lib/ds-test/src/test.sol"; -import {Vm} from "../cheats/Vm.sol"; +import {DSTest} from "lib/ds-test/src/test.sol"; +import {Vm} from "cheats/Vm.sol"; contract Greeter { string name; diff --git a/testdata/spec/ShanghaiCompat.t.sol b/testdata/default/spec/ShanghaiCompat.t.sol similarity index 96% rename from testdata/spec/ShanghaiCompat.t.sol rename to testdata/default/spec/ShanghaiCompat.t.sol index f490441ef5fcd..02856a88fbec9 100644 --- a/testdata/spec/ShanghaiCompat.t.sol +++ b/testdata/default/spec/ShanghaiCompat.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.20; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract ShanghaiCompat is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); diff --git a/testdata/trace/ConflictingSignatures.t.sol b/testdata/default/trace/ConflictingSignatures.t.sol similarity index 97% rename from testdata/trace/ConflictingSignatures.t.sol rename to testdata/default/trace/ConflictingSignatures.t.sol index 896390212db0e..67dfd5d3afcc8 100644 --- a/testdata/trace/ConflictingSignatures.t.sol +++ b/testdata/default/trace/ConflictingSignatures.t.sol @@ -1,7 +1,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract ReturnsNothing { function func() public pure {} diff --git a/testdata/trace/Trace.t.sol b/testdata/default/trace/Trace.t.sol similarity index 98% rename from testdata/trace/Trace.t.sol rename to testdata/default/trace/Trace.t.sol index 2eefba7ba5dd9..d513e8637edd9 100644 --- a/testdata/trace/Trace.t.sol +++ b/testdata/default/trace/Trace.t.sol @@ -1,7 +1,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -import "../cheats/Vm.sol"; +import "cheats/Vm.sol"; contract RecursiveCall { TraceTest factory; From e5318c3054e5f883d1467da9fae5d29567a03d43 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 20 Mar 2024 18:34:30 +0100 Subject: [PATCH 0779/1963] chore: bump svm-rs (#7458) --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29154610ad228..ba462d8890c98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3003,7 +3003,7 @@ dependencies = [ "similar", "solang-parser", "strum 0.26.2", - "svm-rs 0.4.0", + "svm-rs 0.4.1", "tempfile", "thiserror", "tokio", @@ -3312,7 +3312,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "solang-parser", - "svm-rs 0.4.0", + "svm-rs 0.4.1", "svm-rs-builds", "tempfile", "thiserror", @@ -7418,9 +7418,9 @@ dependencies = [ [[package]] name = "svm-rs" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde88464d5718a437e9f6be54cf3771837a111bed305c4f4f9d3497471e96249" +checksum = "9bd5e919f01c9280dce59ab66296449d0e9144b8472b8892fbacf9612998b653" dependencies = [ "const-hex", "dirs 5.0.1", @@ -7438,15 +7438,15 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ff43323737122457c266fe28a454635edd9cd15f8b6277251eb4703ef54f829" +checksum = "5bcf7abc816dd67daf88fccfb835118b0e71cf8cc3e1d0e120893e139799df6c" dependencies = [ "build_const", "const-hex", "semver 1.0.22", "serde_json", - "svm-rs 0.4.0", + "svm-rs 0.4.1", ] [[package]] From db76f71f5c2ba5c1440944a3d01bdcd45ae106b7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:21:37 +0100 Subject: [PATCH 0780/1963] feat: write instruction result when displaying call traces --- crates/evm/traces/src/lib.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index d7d55696f7b2c..26e1aeb2dce41 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -122,23 +122,20 @@ pub async fn render_trace_arena( // Display trace return data let color = trace_color(&node.trace); - write!(s, "{child}{EDGE}{}", color.paint(RETURN))?; - if node.trace.kind.is_any_create() { - match &return_data { - None => { - writeln!(s, "{} bytes of code", node.trace.output.len())?; - } - Some(val) => { - writeln!(s, "{val}")?; - } + write!( + s, + "{child}{EDGE}{}{}", + color.paint(RETURN), + color.paint(format!("[{:?}] ", node.trace.status)) + )?; + match return_data { + Some(val) => writeln!(s, "{val}"), + None if node.trace.kind.is_any_create() => { + writeln!(s, "{} bytes of code", node.trace.output.len()) } - } else { - match &return_data { - None if node.trace.output.is_empty() => writeln!(s, "()")?, - None => writeln!(s, "{}", node.trace.output)?, - Some(val) => writeln!(s, "{val}")?, - } - } + None if node.trace.output.is_empty() => Ok(()), + None => writeln!(s, "{}", node.trace.output), + }?; Ok(()) } From 3e565e88b618c8a78d26537ce9a1adcd6460123d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:22:41 +0100 Subject: [PATCH 0781/1963] Revert "feat: write instruction result when displaying call traces" This reverts commit db76f71f5c2ba5c1440944a3d01bdcd45ae106b7. --- crates/evm/traces/src/lib.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 26e1aeb2dce41..d7d55696f7b2c 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -122,20 +122,23 @@ pub async fn render_trace_arena( // Display trace return data let color = trace_color(&node.trace); - write!( - s, - "{child}{EDGE}{}{}", - color.paint(RETURN), - color.paint(format!("[{:?}] ", node.trace.status)) - )?; - match return_data { - Some(val) => writeln!(s, "{val}"), - None if node.trace.kind.is_any_create() => { - writeln!(s, "{} bytes of code", node.trace.output.len()) + write!(s, "{child}{EDGE}{}", color.paint(RETURN))?; + if node.trace.kind.is_any_create() { + match &return_data { + None => { + writeln!(s, "{} bytes of code", node.trace.output.len())?; + } + Some(val) => { + writeln!(s, "{val}")?; + } } - None if node.trace.output.is_empty() => Ok(()), - None => writeln!(s, "{}", node.trace.output), - }?; + } else { + match &return_data { + None if node.trace.output.is_empty() => writeln!(s, "()")?, + None => writeln!(s, "{}", node.trace.output)?, + Some(val) => writeln!(s, "{val}")?, + } + } Ok(()) } From b342ff2c72e2872c2bb3f8f2d9fcec15d679fb3c Mon Sep 17 00:00:00 2001 From: Yotam Bar-On Date: Thu, 21 Mar 2024 15:11:26 +0200 Subject: [PATCH 0782/1963] feat(cheatcodes) vm.prompt: Prompt user for interactive input (#7012) * Implement vm.prompt cheatcode * chore: speedup prompt test locally * move prompt.sol --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 3 ++ crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 40 +++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 10 +++++ crates/cheatcodes/src/config.rs | 5 +++ crates/cheatcodes/src/fs.rs | 50 ++++++++++++++++++++++++ crates/config/README.md | 1 + crates/config/src/lib.rs | 3 ++ crates/evm/traces/src/decoder/mod.rs | 1 + crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/it/test_helpers.rs | 3 ++ testdata/cheats/Vm.sol | 2 + testdata/default/cheats/Prompt.t.sol | 18 +++++++++ 13 files changed, 138 insertions(+) create mode 100644 testdata/default/cheats/Prompt.t.sol diff --git a/Cargo.lock b/Cargo.lock index ba462d8890c98..87a5f0bea2d96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2091,7 +2091,9 @@ checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" dependencies = [ "console", "shell-words", + "tempfile", "thiserror", + "zeroize", ] [[package]] @@ -3167,6 +3169,7 @@ dependencies = [ "alloy-sol-types", "base64 0.22.0", "const-hex", + "dialoguer", "eyre", "foundry-cheatcodes-spec", "foundry-common", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 57b39966e0345..47315f5ce996a 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -43,3 +43,4 @@ walkdir = "2" p256 = "0.13.2" thiserror = "1" rustc-hash.workspace = true +dialoguer = "0.11.0" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index b086072263d16..9c69772b69f94 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6038,6 +6038,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "prompt", + "description": "Prompts the user for a string value in the terminal.", + "declaration": "function prompt(string calldata promptText) external returns (string memory input);", + "visibility": "external", + "mutability": "", + "signature": "prompt(string)", + "selector": "0x47eaf474", + "selectorBytes": [ + 71, + 234, + 244, + 116 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "promptSecret", + "description": "Prompts the user for a hidden string value in the terminal.", + "declaration": "function promptSecret(string calldata promptText) external returns (string memory input);", + "visibility": "external", + "mutability": "", + "signature": "promptSecret(string)", + "selector": "0x1e279d41", + "selectorBytes": [ + 30, + 39, + 157, + 65 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readCallers", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index bd6500fb7c81b..cdcca3331785c 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1399,6 +1399,16 @@ interface Vm { #[cheatcode(group = Filesystem)] function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result); + // -------- User Interaction -------- + + /// Prompts the user for a string value in the terminal. + #[cheatcode(group = Filesystem)] + function prompt(string calldata promptText) external returns (string memory input); + + /// Prompts the user for a hidden string value in the terminal. + #[cheatcode(group = Filesystem)] + function promptSecret(string calldata promptText) external returns (string memory input); + // ======== Environment Variables ======== /// Sets environment variables. diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index eb8f56ab7f6eb..1048f6b6937d5 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -11,6 +11,7 @@ use foundry_evm_core::opts::EvmOpts; use std::{ collections::HashMap, path::{Path, PathBuf}, + time::Duration, }; /// Additional, configurable context the `Cheatcodes` inspector has access to @@ -22,6 +23,8 @@ pub struct CheatsConfig { pub ffi: bool, /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. pub always_use_create_2_factory: bool, + /// Sets a timeout for vm.prompt cheatcodes + pub prompt_timeout: Duration, /// RPC storage caching settings determines what chains and endpoints to cache pub rpc_storage_caching: StorageCachingConfig, /// All known endpoints and their aliases @@ -55,6 +58,7 @@ impl CheatsConfig { Self { ffi: evm_opts.ffi, always_use_create_2_factory: evm_opts.always_use_create_2_factory, + prompt_timeout: Duration::from_secs(config.prompt_timeout), rpc_storage_caching: config.rpc_storage_caching.clone(), rpc_endpoints, paths: config.project_paths(), @@ -171,6 +175,7 @@ impl Default for CheatsConfig { Self { ffi: false, always_use_create_2_factory: false, + prompt_timeout: Duration::from_secs(120), rpc_storage_caching: Default::default(), rpc_endpoints: Default::default(), paths: ProjectPathsConfig::builder().build_with_root("./"), diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 3e345db94a97b..7789915b56574 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -4,6 +4,7 @@ use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_json_abi::ContractObject; use alloy_primitives::U256; use alloy_sol_types::SolValue; +use dialoguer::{Input, Password}; use foundry_common::{fs, get_artifact_path}; use foundry_config::fs_permissions::FsAccessKind; use std::{ @@ -11,6 +12,8 @@ use std::{ io::{BufRead, BufReader, Write}, path::Path, process::Command, + sync::mpsc, + thread, time::{SystemTime, UNIX_EPOCH}, }; use walkdir::WalkDir; @@ -296,6 +299,20 @@ impl Cheatcode for tryFfiCall { } } +impl Cheatcode for promptCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { promptText: text } = self; + prompt(state, text, prompt_input).map(|res| res.abi_encode()) + } +} + +impl Cheatcode for promptSecretCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { promptText: text } = self; + prompt(state, text, prompt_password).map(|res| res.abi_encode()) + } +} + pub(super) fn write_file(state: &Cheatcodes, path: &Path, contents: &[u8]) -> Result { let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; // write access to foundry.toml is not allowed @@ -370,6 +387,39 @@ fn ffi(state: &Cheatcodes, input: &[String]) -> Result { }) } +fn prompt_input(prompt_text: &str) -> Result { + Input::new().allow_empty(true).with_prompt(prompt_text).interact_text() +} + +fn prompt_password(prompt_text: &str) -> Result { + Password::new().with_prompt(prompt_text).interact() +} + +fn prompt( + state: &Cheatcodes, + prompt_text: &str, + input: fn(&str) -> Result, +) -> Result { + let text_clone = prompt_text.to_string(); + let timeout = state.config.prompt_timeout; + let (send, recv) = mpsc::channel(); + + thread::spawn(move || { + send.send(input(&text_clone)).unwrap(); + }); + + match recv.recv_timeout(timeout) { + Ok(res) => res.map_err(|err| { + println!(); + err.to_string().into() + }), + Err(_) => { + println!(); + Err("Prompt timed out".into()) + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/config/README.md b/crates/config/README.md index 46fa83e5a3026..ffa4cdc750257 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -116,6 +116,7 @@ match_path = "*/Foo*" no_match_path = "*/Bar*" ffi = false always_use_create_2_factory = false +prompt_timeout = 120 # These are the default callers, generated using `address(uint160(uint256(keccak256("foundry default caller"))))` sender = '0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38' tx_origin = '0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38' diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 4f27b58b8eddf..0c53a6c14e3f8 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -244,6 +244,8 @@ pub struct Config { pub ffi: bool, /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. pub always_use_create_2_factory: bool, + /// Sets a timeout in seconds for vm.prompt cheatcodes + pub prompt_timeout: u64, /// The address which will be executing all tests pub sender: Address, /// The tx.origin value during EVM execution @@ -1873,6 +1875,7 @@ impl Default for Config { invariant: Default::default(), always_use_create_2_factory: false, ffi: false, + prompt_timeout: 120, sender: Config::DEFAULT_SENDER, tx_origin: Config::DEFAULT_SENDER, initial_balance: U256::from(0xffffffffffffffffffffffffu128), diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 2eac34d003a80..f53d8b5162580 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -520,6 +520,7 @@ impl CallTraceDecoder { match func.name.as_str() { s if s.starts_with("env") => Some(""), "createWallet" | "deriveKey" => Some(""), + "promptSecret" => Some(""), "parseJson" if self.verbosity < 5 => Some(""), "readFile" if self.verbosity < 5 => Some(""), _ => None, diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 6714df59dd833..81884f3bcd9f4 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -72,6 +72,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { invariant: InvariantConfig { runs: 256, ..Default::default() }, ffi: true, always_use_create_2_factory: false, + prompt_timeout: 0, sender: "00a329c0648769A73afAc7F9381D08FB43dBEA72".parse().unwrap(), tx_origin: "00a329c0648769A73afAc7F9F81E08FB43dBEA72".parse().unwrap(), initial_balance: U256::from(0xffffffffffffffffffffffffu128), diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 3d16487568d5c..bf31842b8e52d 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -197,6 +197,9 @@ impl ForgeTestData { config.rpc_endpoints = rpc_endpoints(); config.allow_paths.push(manifest_root().to_path_buf()); + // no prompt testing + config.prompt_timeout = 0; + let root = self.project.root(); let opts = self.evm_opts.clone(); let env = opts.local_evm_env(); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 623ef254bf069..b5a604e14d963 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -299,6 +299,8 @@ interface Vm { function prank(address msgSender, address txOrigin) external; function prevrandao(bytes32 newPrevrandao) external; function projectRoot() external view returns (string memory path); + function prompt(string calldata promptText) external returns (string memory input); + function promptSecret(string calldata promptText) external returns (string memory input); 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); diff --git a/testdata/default/cheats/Prompt.t.sol b/testdata/default/cheats/Prompt.t.sol new file mode 100644 index 0000000000000..dadfd30a97b2a --- /dev/null +++ b/testdata/default/cheats/Prompt.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract PromptTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testPrompt_revertNotATerminal() public { + // should revert in CI and testing environments either with timout or because no terminal is available + vm._expectCheatcodeRevert(); + vm.prompt("test"); + + vm._expectCheatcodeRevert(); + vm.promptSecret("test"); + } +} From c2233ec9fe61e0920c61c6d779bc707252852037 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:04:46 +0100 Subject: [PATCH 0783/1963] feat: write instruction result when displaying call traces (#7465) * feat: write instruction result when displaying call traces * fix: new line, update tests * space --- crates/evm/traces/src/lib.rs | 30 +++++++++---------- .../include_custom_types_in_traces.stdout | 4 +-- crates/forge/tests/fixtures/repro_6531.stdout | 6 ++-- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index d7d55696f7b2c..2538c03ca5dcc 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -122,23 +122,21 @@ pub async fn render_trace_arena( // Display trace return data let color = trace_color(&node.trace); - write!(s, "{child}{EDGE}{}", color.paint(RETURN))?; - if node.trace.kind.is_any_create() { - match &return_data { - None => { - writeln!(s, "{} bytes of code", node.trace.output.len())?; - } - Some(val) => { - writeln!(s, "{val}")?; - } + write!( + s, + "{child}{EDGE}{}{}", + color.paint(RETURN), + color.paint(format!("[{:?}] ", node.trace.status)) + )?; + match return_data { + Some(val) => write!(s, "{val}"), + None if node.trace.kind.is_any_create() => { + write!(s, "{} bytes of code", node.trace.output.len()) } - } else { - match &return_data { - None if node.trace.output.is_empty() => writeln!(s, "()")?, - None => writeln!(s, "{}", node.trace.output)?, - Some(val) => writeln!(s, "{val}")?, - } - } + None if node.trace.output.is_empty() => Ok(()), + None => write!(s, "{}", node.trace.output), + }?; + writeln!(s)?; Ok(()) } diff --git a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout index 786679a6736b6..571cc69274595 100644 --- a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout +++ b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout @@ -6,13 +6,13 @@ Ran 2 tests for test/Contract.t.sol:CustomTypesTest [FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231) Traces: [231] CustomTypesTest::testErr() - └─ ← PoolNotInitialized() + └─ ← [Revert] PoolNotInitialized() [PASS] testEvent() (gas: 1312) Traces: [1312] CustomTypesTest::testEvent() ├─ emit MyEvent(a: 100) - └─ ← () + └─ ← [Stop] Suite result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout index 01f282bf7cfd2..35c27c9483e17 100644 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -7,10 +7,10 @@ Ran 1 test for test/Contract.t.sol:USDTCallingTest Traces: [9559] USDTCallingTest::test() ├─ [0] VM::createSelectFork("") - │ └─ ← 0 + │ └─ ← [Return] 0 ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] - │ └─ ← "Tether USD" - └─ ← () + │ └─ ← [Return] "Tether USD" + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s From 5ecc1bf6ceae678791ff23f4c233c0bba6757285 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 22 Mar 2024 03:51:49 +0100 Subject: [PATCH 0784/1963] chore: remove Instruction enum in debug steps (#7464) --- crates/debugger/src/tui/draw.rs | 46 ++++++++--------- crates/evm/core/src/debug.rs | 61 +++-------------------- crates/evm/evm/src/inspectors/debugger.rs | 21 ++------ 3 files changed, 29 insertions(+), 99 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 41eca5e76af5f..76e5965130609 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -4,7 +4,6 @@ use super::context::{BufferKind, DebuggerContext}; use crate::op::OpcodeParam; use alloy_primitives::U256; use foundry_compilers::sourcemap::SourceElement; -use foundry_evm_core::debug::Instruction; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, @@ -456,8 +455,7 @@ impl DebuggerContext<'_> { let min_len = decimal_digits(stack.len()).max(2); - let params = - if let Instruction::OpCode(op) = step.instruction { OpcodeParam::of(op) } else { &[] }; + let params = OpcodeParam::of(step.instruction); let text: Vec = stack .iter() @@ -516,20 +514,18 @@ impl DebuggerContext<'_> { let mut write_offset = None; let mut write_size = None; let mut color = None; - if let Instruction::OpCode(op) = step.instruction { - let stack_len = step.stack.len(); - if stack_len > 0 { - if let Some(accesses) = get_buffer_accesses(op, &step.stack) { - if let Some(read_access) = accesses.read { - offset = Some(read_access.1.offset); - size = Some(read_access.1.size); - color = Some(Color::Cyan); - } - if let Some(write_access) = accesses.write { - if self.active_buffer == BufferKind::Memory { - write_offset = Some(write_access.offset); - write_size = Some(write_access.size); - } + let stack_len = step.stack.len(); + if stack_len > 0 { + if let Some(accesses) = get_buffer_accesses(step.instruction, &step.stack) { + if let Some(read_access) = accesses.read { + offset = Some(read_access.1.offset); + size = Some(read_access.1.size); + color = Some(Color::Cyan); + } + if let Some(write_access) = accesses.write { + if self.active_buffer == BufferKind::Memory { + write_offset = Some(write_access.offset); + write_size = Some(write_access.size); } } } @@ -542,15 +538,13 @@ impl DebuggerContext<'_> { if self.current_step > 0 { let prev_step = self.current_step - 1; let prev_step = &self.debug_steps()[prev_step]; - if let Instruction::OpCode(op) = prev_step.instruction { - if let Some(write_access) = - get_buffer_accesses(op, &prev_step.stack).and_then(|a| a.write) - { - if self.active_buffer == BufferKind::Memory { - offset = Some(write_access.offset); - size = Some(write_access.size); - color = Some(Color::Green); - } + if let Some(write_access) = + get_buffer_accesses(prev_step.instruction, &prev_step.stack).and_then(|a| a.write) + { + if self.active_buffer == BufferKind::Memory { + offset = Some(write_access.offset); + size = Some(write_access.size); + color = Some(Color::Green); } } } diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 70d94ff9760dd..056bde54cfc61 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -4,7 +4,6 @@ use arrayvec::ArrayVec; use revm::interpreter::OpCode; use revm_inspectors::tracing::types::CallKind; use serde::{Deserialize, Serialize}; -use std::fmt::Display; /// An arena of [DebugNode]s #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -176,7 +175,7 @@ pub struct DebugStep { /// Returndata *prior* to running the associated opcode pub returndata: Bytes, /// Opcode to be executed - pub instruction: Instruction, + pub instruction: u8, /// Optional bytes that are being pushed onto the stack. /// Empty if the opcode is not a push or PUSH0. #[serde(serialize_with = "hex::serialize", deserialize_with = "deserialize_arrayvec_hex")] @@ -197,7 +196,7 @@ impl Default for DebugStep { memory: Default::default(), calldata: Default::default(), returndata: Default::default(), - instruction: Instruction::OpCode(revm::interpreter::opcode::INVALID), + instruction: revm::interpreter::opcode::INVALID, push_bytes: Default::default(), pc: 0, total_gas_used: 0, @@ -208,65 +207,17 @@ impl Default for DebugStep { impl DebugStep { /// Pretty print the step's opcode pub fn pretty_opcode(&self) -> String { + let instruction = OpCode::new(self.instruction).map_or("INVALID", |op| op.as_str()); if !self.push_bytes.is_empty() { - format!("{}(0x{})", self.instruction, hex::encode(&self.push_bytes)) + format!("{instruction}(0x{})", hex::encode(&self.push_bytes)) } else { - self.instruction.to_string() + instruction.to_string() } } /// Returns `true` if the opcode modifies memory. pub fn opcode_modifies_memory(&self) -> bool { - self.instruction.opcode().and_then(OpCode::new).map_or(false, opcodes::modifies_memory) - } -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub enum Instruction { - OpCode(u8), - Cheatcode([u8; 4]), -} - -impl From for Instruction { - fn from(op: u8) -> Instruction { - Instruction::OpCode(op) - } -} - -impl Display for Instruction { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Instruction::OpCode(op) => write!( - f, - "{}", - OpCode::new(*op).map_or_else( - || format!("UNDEFINED(0x{op:02x})"), - |opcode| opcode.as_str().to_string(), - ) - ), - Instruction::Cheatcode(cheat) => write!( - f, - "VM_{}", - crate::abi::Vm::CHEATCODES - .iter() - .map(|c| &c.func) - .find(|c| c.selector_bytes == *cheat) - .expect("unknown cheatcode found in debugger") - .id - .to_uppercase() - ), - } - } -} - -impl Instruction { - /// Returns the opcode of the instruction, if it is an opcode. - #[inline] - pub fn opcode(&self) -> Option { - match self { - Instruction::OpCode(op) => Some(*op), - _ => None, - } + OpCode::new(self.instruction).map_or(false, opcodes::modifies_memory) } } diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index f6232bd475edd..d68a14bf6dc43 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -1,10 +1,9 @@ use alloy_primitives::Address; use arrayvec::ArrayVec; -use foundry_common::{ErrorExt, SELECTOR_LEN}; +use foundry_common::ErrorExt; use foundry_evm_core::{ backend::DatabaseExt, - constants::CHEATCODE_ADDRESS, - debug::{DebugArena, DebugNode, DebugStep, Instruction}, + debug::{DebugArena, DebugNode, DebugStep}, utils::gas_used, }; use revm::{ @@ -47,7 +46,6 @@ impl Debugger { } impl Inspector for Debugger { - #[inline] fn step(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { let pc = interp.program_counter(); let op = interp.current_opcode(); @@ -88,13 +86,12 @@ impl Inspector for Debugger { memory, calldata: interp.contract().input.clone(), returndata: interp.return_data_buffer.clone(), - instruction: Instruction::OpCode(op), + instruction: op, push_bytes: push_bytes.unwrap_or_default(), total_gas_used, }); } - #[inline] fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { self.enter( ecx.journaled_state.depth() as usize, @@ -102,19 +99,9 @@ impl Inspector for Debugger { inputs.context.scheme.into(), ); - if inputs.contract == CHEATCODE_ADDRESS { - if let Some(selector) = inputs.input.get(..SELECTOR_LEN) { - self.arena.arena[self.head].steps.push(DebugStep { - instruction: Instruction::Cheatcode(selector.try_into().unwrap()), - ..Default::default() - }); - } - } - None } - #[inline] fn call_end( &mut self, _context: &mut EvmContext, @@ -126,7 +113,6 @@ impl Inspector for Debugger { outcome } - #[inline] fn create( &mut self, ecx: &mut EvmContext, @@ -154,7 +140,6 @@ impl Inspector for Debugger { None } - #[inline] fn create_end( &mut self, _context: &mut EvmContext, From 9d2125b013cbcb61dce2546379a79a4d99ba2f78 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:29:29 +0200 Subject: [PATCH 0785/1963] fix(invariant): call override strategy panic (#7469) * fix(invariant): override call strat panic * Add test --- crates/evm/fuzz/src/strategies/invariants.rs | 12 +++++++++++- crates/forge/tests/it/invariant.rs | 1 + .../fuzz/invariant/common/InvariantReentrancy.t.sol | 12 +++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 5fd766bb4f795..1d226b0034781 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -25,7 +25,17 @@ pub fn override_call_strat( .prop_flat_map(move |target_address| { let fuzz_state = fuzz_state.clone(); let calldata_fuzz_config = calldata_fuzz_config.clone(); - let (_, abi, functions) = &contracts.lock()[&target_address]; + + let contracts = &contracts.lock(); + let (_, abi, functions) = contracts.get(&target_address).unwrap_or({ + // Choose a random contract if target selected by lazy strategy is not in fuzz run + // identified contracts. This can happen when contract is created in `setUp` call + // but is not included in targetContracts. + let rand_index = rand::thread_rng().gen_range(0..contracts.iter().len()); + let (_, contract_specs) = contracts.iter().nth(rand_index).unwrap(); + contract_specs + }); + let func = select_random_function(abi, functions); func.prop_flat_map(move |func| { fuzz_contract_with_calldata(&fuzz_state, &calldata_fuzz_config, target_address, func) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index e902b6aa9f18b..82cf4909e7908 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -153,6 +153,7 @@ async fn test_invariant() { async fn test_invariant_override() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantReentrancy.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.fail_on_revert = false; runner.test_options.invariant.call_override = true; let results = runner.test_collect(&filter); diff --git a/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol b/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol index 086d5f99ab9e4..06b4b21d761ff 100644 --- a/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol @@ -5,7 +5,9 @@ import "ds-test/test.sol"; contract Malicious { function world() public { - // Does not matter, since it will get overridden. + // add code so contract is accounted as valid sender + // see https://github.com/foundry-rs/foundry/issues/4245 + payable(msg.sender).transfer(1); } } @@ -39,6 +41,14 @@ contract InvariantReentrancy is DSTest { vuln = new Vulnerable(address(mal)); } + // do not include `mal` in identified contracts + // see https://github.com/foundry-rs/foundry/issues/4245 + function targetContracts() public view returns (address[] memory) { + address[] memory targets = new address[](1); + targets[0] = address(vuln); + return targets; + } + function invariantNotStolen() public { require(vuln.stolen() == false, "stolen"); } From f73d855ff32e94190c8c8b637ae47a73461efdab Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:28:50 +0100 Subject: [PATCH 0786/1963] perf(debugger): don't clone debug info twice (#7468) --- crates/debugger/src/tui/context.rs | 8 +++----- crates/forge/bin/cmd/test/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index 6f8c30939769e..b0da8a0c519f2 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -115,11 +115,9 @@ impl<'a> DebuggerContext<'a> { } fn gen_opcode_list(&mut self) { - self.opcode_list = self.opcode_list(); - } - - fn opcode_list(&self) -> Vec { - self.debug_steps().iter().map(DebugStep::pretty_opcode).collect() + self.opcode_list.clear(); + let debug_steps = &self.debugger.debug_arena[self.draw_memory.inner_call_index].steps; + self.opcode_list.extend(debug_steps.iter().map(DebugStep::pretty_opcode)); } fn active_buffer(&self) -> &[u8] { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index dfb1d8cf5941d..13130d4642f7b 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -225,7 +225,7 @@ impl TestArgs { if should_debug { // There is only one test. - let Some(test) = outcome.into_tests_cloned().next() else { + let Some((_, test_result)) = outcome.tests().next() else { return Err(eyre::eyre!("no tests were executed")); }; @@ -236,9 +236,9 @@ impl TestArgs { // Run the debugger. let mut builder = Debugger::builder() - .debug_arenas(test.result.debug.as_slice()) + .debug_arenas(test_result.debug.as_slice()) .sources(sources) - .breakpoints(test.result.breakpoints); + .breakpoints(test_result.breakpoints.clone()); if let Some(decoder) = &outcome.decoder { builder = builder.decoder(decoder); } From f9da73dff7d089a4a79ba4977419aec06cc10330 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 22 Mar 2024 23:30:34 +0100 Subject: [PATCH 0787/1963] chore(fuzz): improve `override_call_strat` (#7477) --- crates/evm/fuzz/src/strategies/invariants.rs | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 1d226b0034781..c98e84598d1b8 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -26,17 +26,19 @@ pub fn override_call_strat( let fuzz_state = fuzz_state.clone(); let calldata_fuzz_config = calldata_fuzz_config.clone(); - let contracts = &contracts.lock(); - let (_, abi, functions) = contracts.get(&target_address).unwrap_or({ - // Choose a random contract if target selected by lazy strategy is not in fuzz run - // identified contracts. This can happen when contract is created in `setUp` call - // but is not included in targetContracts. - let rand_index = rand::thread_rng().gen_range(0..contracts.iter().len()); - let (_, contract_specs) = contracts.iter().nth(rand_index).unwrap(); - contract_specs - }); + let func = { + let contracts = contracts.lock(); + let (_, abi, functions) = contracts.get(&target_address).unwrap_or_else(|| { + // Choose a random contract if target selected by lazy strategy is not in fuzz run + // identified contracts. This can happen when contract is created in `setUp` call + // but is not included in targetContracts. + let rand_index = rand::thread_rng().gen_range(0..contracts.len()); + let (_, contract_specs) = contracts.iter().nth(rand_index).unwrap(); + contract_specs + }); + select_random_function(abi, functions) + }; - let func = select_random_function(abi, functions); func.prop_flat_map(move |func| { fuzz_contract_with_calldata(&fuzz_state, &calldata_fuzz_config, target_address, func) }) From 0cd972f3f813fcb54d6ba51d8c215d49ebc98a8c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 24 Mar 2024 13:59:14 +0100 Subject: [PATCH 0788/1963] chore(deps): weekly `cargo update` (#7479) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating aho-corasick v1.1.2 -> v1.1.3 Updating async-recursion v1.0.5 -> v1.1.0 Updating backtrace v0.3.69 -> v0.3.71 Updating bitflags v2.4.2 -> v2.5.0 Updating bs58 v0.5.0 -> v0.5.1 Updating bytes v1.5.0 -> v1.6.0 Updating cargo-platform v0.1.7 -> v0.1.8 Downgrading enr v0.10.1 -> v0.10.0 (latest: v0.11.0) Adding fs2 v0.4.3 Updating futures-lite v2.2.0 -> v2.3.0 Updating indexmap v2.2.5 -> v2.2.6 Updating indoc v2.0.4 -> v2.0.5 Updating pear v0.2.8 -> v0.2.9 Updating pear_codegen v0.2.8 -> v0.2.9 Updating regex v1.10.3 -> v1.10.4 Updating reqwest v0.11.26 -> v0.11.27 (latest: v0.12.1) Updating rustix v0.38.31 -> v0.38.32 Updating smallvec v1.13.1 -> v1.13.2 Downgrading svm-rs v0.3.6 -> v0.3.5 (latest: v0.4.1) Updating toml v0.8.11 -> v0.8.12 Updating toml_edit v0.22.7 -> v0.22.9 note: pass `--verbose` to see 190 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 140 ++++++++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87a5f0bea2d96..ca3a63fa4e590 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,9 +63,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -840,9 +840,9 @@ dependencies = [ [[package]] name = "async-recursion" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", @@ -1001,9 +1001,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -1079,9 +1079,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ "arbitrary", "serde", @@ -1148,9 +1148,9 @@ dependencies = [ [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "sha2 0.10.8", "tinyvec", @@ -1208,9 +1208,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -1261,9 +1261,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ "serde", ] @@ -1867,7 +1867,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossterm_winapi", "libc", "mio", @@ -2287,17 +2287,17 @@ checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" [[package]] name = "enr" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc3eabaca59dc39ea5ed15062e4abc5bba9723b1cff7a4fea3faae0647f04c0" +checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" dependencies = [ - "alloy-rlp", "base64 0.21.7", "bytes", "hex", "k256", "log", "rand 0.8.5", + "rlp", "serde", "sha3", "zeroize", @@ -2524,7 +2524,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.53", - "toml 0.8.11", + "toml 0.8.12", "walkdir", ] @@ -2706,7 +2706,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "svm-rs 0.3.6", + "svm-rs 0.3.5", "thiserror", "tiny-keccak", "tokio", @@ -2875,7 +2875,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.11", + "toml 0.8.12", "uncased", "version_check", ] @@ -3038,7 +3038,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.11", + "toml 0.8.12", "tracing", ] @@ -3053,7 +3053,7 @@ dependencies = [ "pretty_assertions", "solang-parser", "thiserror", - "toml 0.8.11", + "toml 0.8.12", "tracing", "tracing-subscriber", ] @@ -3186,7 +3186,7 @@ dependencies = [ "rustc-hash", "serde_json", "thiserror", - "toml 0.8.11", + "toml 0.8.12", "tracing", "walkdir", ] @@ -3353,7 +3353,7 @@ dependencies = [ "solang-parser", "tempfile", "thiserror", - "toml 0.8.11", + "toml 0.8.12", "toml_edit 0.21.1", "tracing", "walkdir", @@ -3576,6 +3576,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "fs4" version = "0.7.0" @@ -3667,9 +3677,9 @@ checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "futures-core", "pin-project-lite", @@ -3828,7 +3838,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bstr", "gix-path", "libc", @@ -3874,7 +3884,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bstr", "gix-features", "gix-path", @@ -3959,7 +3969,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "gix-path", "libc", "windows", @@ -4451,9 +4461,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -4474,9 +4484,9 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "inlinable_string" @@ -4763,7 +4773,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -5063,7 +5073,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "cfg_aliases", "libc", @@ -5319,7 +5329,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -5528,9 +5538,9 @@ dependencies = [ [[package]] name = "pear" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ccca0f6c17acc81df8e242ed473ec144cbf5c98037e69aa6d144780aad103c8" +checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" dependencies = [ "inlinable_string", "pear_codegen", @@ -5539,9 +5549,9 @@ dependencies = [ [[package]] name = "pear_codegen" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e22670e8eb757cff11d6c199ca7b987f352f0346e0be4dd23869ec72cb53c77" +checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147" dependencies = [ "proc-macro2", "proc-macro2-diagnostics", @@ -5975,7 +5985,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.5.0", "lazy_static", "num-traits", "rand 0.8.5", @@ -6024,7 +6034,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dce76ce678ffc8e5675b22aa1405de0b7037e2fdf8913fea40d1926c6fe1e6e7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "memchr", "pulldown-cmark-escape", "unicase", @@ -6153,7 +6163,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cassowary", "crossterm", "indoc", @@ -6221,9 +6231,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -6265,9 +6275,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.26" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.7", "bytes", @@ -6375,7 +6385,7 @@ checksum = "2a4d7d3e793e907dc0797a9d3b43abfdf5226d133855214db9bd27d4cee33ebd" dependencies = [ "alloy-primitives", "auto_impl", - "bitflags 2.4.2", + "bitflags 2.5.0", "bitvec", "c-kzg", "cfg-if", @@ -6640,11 +6650,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -6730,7 +6740,7 @@ version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "clipboard-win", "fd-lock 3.0.13", @@ -7227,9 +7237,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -7401,13 +7411,13 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "svm-rs" -version = "0.3.6" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b34cc1af809be8d20575428638da2c6a1eb12b1da06dae79c1b82a4ddf83ac" +checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" dependencies = [ - "const-hex", "dirs 5.0.1", - "fs4", + "fs2", + "hex", "once_cell", "reqwest", "semver 1.0.22", @@ -7816,15 +7826,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.7", + "toml_edit 0.22.9", ] [[package]] @@ -7871,9 +7881,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.7" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ "indexmap", "serde", @@ -7910,7 +7920,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bytes", "futures-core", "futures-util", From 88e09f6f24a771b8b37def2d437660b13146bef6 Mon Sep 17 00:00:00 2001 From: Panagiotis Ganelis <50522617+PanGan21@users.noreply.github.com> Date: Sun, 24 Mar 2024 14:59:45 +0200 Subject: [PATCH 0789/1963] feat(anvil): remove all txs from tx pool by sender origin (#7480) * feat(anvil): remove all txs from pool by sender origin * refactor(anvil): combine pending and ready transactions iterators in one --- crates/anvil/core/src/eth/mod.rs | 14 ++++++++++ crates/anvil/src/eth/api.rs | 9 ++++++ crates/anvil/src/eth/pool/mod.rs | 44 +++++++++++++++++++++++++++++- crates/anvil/tests/it/anvil_api.rs | 25 +++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 203e8532a35cb..e5a394a8fa4cd 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -717,6 +717,13 @@ pub enum EthRequest { /// contract. #[cfg_attr(feature = "serde", serde(rename = "ots_getContractCreator", with = "sequence"))] OtsGetContractCreator(Address), + + /// Removes transactions from the pool by sender origin. + #[cfg_attr( + feature = "serde", + serde(rename = "anvil_removePoolTransactions", with = "sequence") + )] + RemovePoolTransactions(Address), } /// Represents ethereum JSON-RPC API @@ -1506,4 +1513,11 @@ true}]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } + + #[test] + fn test_remove_pool_transactions() { + let s = r#"{"method": "anvil_removePoolTransactions", "params":["0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6"]}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + } } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 83754480bb839..402bf4b751c7d 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -413,6 +413,9 @@ impl EthApi { EthRequest::OtsGetContractCreator(address) => { self.ots_get_contract_creator(address).await.to_rpc_result() } + EthRequest::RemovePoolTransactions(address) => { + self.anvil_remove_pool_transactions(address).await.to_rpc_result() + } } } @@ -1781,6 +1784,12 @@ impl EthApi { }) } + pub async fn anvil_remove_pool_transactions(&self, address: Address) -> Result<()> { + node_info!("anvil_removePoolTransactions"); + self.pool.remove_transactions_by_address(address); + Ok(()) + } + /// Snapshot the state of the blockchain at the current block. /// /// Handler for RPC call: `evm_snapshot` diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index 8848a954bd376..34a75c205adec 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -36,7 +36,7 @@ use crate::{ }, mem::storage::MinedBlockOutcome, }; -use alloy_primitives::{TxHash, U64}; +use alloy_primitives::{Address, TxHash, U64}; use alloy_rpc_types::txpool::TxpoolStatus; use anvil_core::eth::transaction::PendingTransaction; use futures::channel::mpsc::{channel, Receiver, Sender}; @@ -141,6 +141,11 @@ impl Pool { self.inner.write().remove_invalid(tx_hashes) } + /// Remove transactions by sender + pub fn remove_transactions_by_address(&self, sender: Address) -> Vec> { + self.inner.write().remove_transactions_by_address(sender) + } + /// Removes a single transaction from the pool /// /// This is similar to `[Pool::remove_invalid()]` but for a single transaction. @@ -218,6 +223,24 @@ impl PoolInner { ) } + /// Returns an iterator over all transactions in the pool filtered by the sender + pub fn transactions_by_sender( + &self, + sender: Address, + ) -> impl Iterator> + '_ { + let pending_txs = self + .pending_transactions + .transactions() + .filter(move |tx| tx.pending_transaction.sender().eq(&sender)); + + let ready_txs = self + .ready_transactions + .get_transactions() + .filter(move |tx| tx.pending_transaction.sender().eq(&sender)); + + pending_txs.chain(ready_txs) + } + /// Returns true if this pool already contains the transaction fn contains(&self, tx_hash: &TxHash) -> bool { self.pending_transactions.contains(tx_hash) || self.ready_transactions.contains(tx_hash) @@ -342,6 +365,25 @@ impl PoolInner { removed } + + /// Remove transactions by sender address + pub fn remove_transactions_by_address(&mut self, sender: Address) -> Vec> { + let tx_hashes = + self.transactions_by_sender(sender).map(move |tx| tx.hash()).collect::>(); + + if tx_hashes.is_empty() { + return vec![] + } + + trace!(target: "txpool", "Removing transactions: {:?}", tx_hashes); + + let mut removed = self.ready_transactions.remove_with_markers(tx_hashes.clone(), None); + removed.extend(self.pending_transactions.remove(tx_hashes)); + + trace!(target: "txpool", "Removed transactions: {:?}", removed); + + removed + } } /// Represents the outcome of a prune diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 91ba92d771548..2f37f9b56d108 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -9,6 +9,7 @@ use anvil_core::{ use ethers::{ abi::{ethereum_types::BigEndianHash, AbiDecode}, prelude::{Middleware, SignerMiddleware}, + signers::Signer, types::{ transaction::eip2718::TypedTransaction, Address, BlockNumber, Eip1559TransactionRequest, TransactionRequest, H256, U256, U64, @@ -631,3 +632,27 @@ async fn test_fork_revert_call_latest_block_timestamp() { latest_block.header.miner.to_ethers() ); } + +#[tokio::test(flavor = "multi_thread")] +async fn can_remove_pool_transactions() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let provider = Arc::new(SignerMiddleware::new(provider, wallet.clone())); + + let sender = Address::random(); + let to = Address::random(); + let val = 1337u64; + + let tx = TransactionRequest::new().from(sender).to(to).value(val); + + provider.send_transaction(tx.from(wallet.address()), None).await.unwrap(); + + let initial_txs = provider.txpool_inspect().await.unwrap(); + assert_eq!(initial_txs.pending.len(), 1); + + api.anvil_remove_pool_transactions(wallet.address().to_alloy()).await.unwrap(); + + let final_txs = provider.txpool_inspect().await.unwrap(); + assert_eq!(final_txs.pending.len(), 0); +} From e5acbcfe71d5d6687fcc649e91776454f5c3eb73 Mon Sep 17 00:00:00 2001 From: Lu Zhang <8418040+longbowlu@users.noreply.github.com> Date: Mon, 25 Mar 2024 04:25:35 -0700 Subject: [PATCH 0790/1963] [anvil] correct log index for getTransactionReceipt (#7483) correctly aggregate log index for getTransactionReceipt --- crates/anvil/core/src/eth/transaction/mod.rs | 10 ++++++++ crates/anvil/src/eth/backend/mem/mod.rs | 5 ++-- crates/anvil/tests/it/logs.rs | 26 ++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 72a88c54712ce..10de5f80e7f0a 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1011,6 +1011,16 @@ impl TypedReceipt { TypedReceipt::Deposit(r) => &r.bloom, } } + + pub fn logs(&self) -> &Vec { + match self { + TypedReceipt::Legacy(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::EIP4844(r) | + TypedReceipt::Deposit(r) => &r.receipt.logs, + } + } } impl From for ReceiptWithBloom { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 013c303e32851..a60ba56408fa7 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2009,8 +2009,9 @@ impl Backend { let mut pre_receipts_log_index = None; if !cumulative_receipts.is_empty() { cumulative_receipts.truncate(cumulative_receipts.len() - 1); - pre_receipts_log_index = - Some(cumulative_receipts.iter().map(|_r| logs.len() as u32).sum::()); + pre_receipts_log_index = Some( + cumulative_receipts.iter().map(|r| r.logs().len() as u32).sum::(), + ); } logs.iter() .enumerate() diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index 5fc9cf9f22f16..2f9290f3e7540 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -86,6 +86,32 @@ async fn get_all_events() { let num_logs = num_tx + pre_logs.len(); assert_eq!(logs.len(), num_logs); + + // test that logs returned from get_logs and get_transaction_receipt have + // the same log_index, block_number, and transaction_hash + let mut tasks = vec![]; + let mut seen_tx_hashes = std::collections::HashSet::new(); + for log in &logs { + if seen_tx_hashes.contains(&log.transaction_hash.unwrap()) { + continue; + } + tasks.push(client.get_transaction_receipt(log.transaction_hash.unwrap())); + seen_tx_hashes.insert(log.transaction_hash.unwrap()); + } + let receipt_logs = futures::future::join_all(tasks) + .await + .into_iter() + .collect::, _>>() + .unwrap() + .into_iter() + .flat_map(|receipt| receipt.unwrap().logs) + .collect::>(); + assert_eq!(receipt_logs.len(), logs.len()); + for (receipt_log, log) in receipt_logs.iter().zip(logs.iter()) { + assert_eq!(receipt_log.transaction_hash, log.transaction_hash); + assert_eq!(receipt_log.block_number, log.block_number); + assert_eq!(receipt_log.log_index, log.log_index); + } } #[tokio::test(flavor = "multi_thread")] From bf5bfe0a3af293152f84f965e21856bc740aac0d Mon Sep 17 00:00:00 2001 From: tesseract <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:11:44 -0700 Subject: [PATCH 0791/1963] feat(anvil): Add memery limit to anvil node (#7482) * add memery-limit to anvil node * Update config.rs * use unwrap_or_default * add variable alias * custom value to 100 for memory-limit * Update config.rs * Update config.rs * remove old comment * nightly fmt * fmt * docs --------- Co-authored-by: Matthias Seitz --- crates/anvil/src/cmd.rs | 4 ++++ crates/anvil/src/config.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 508c3dc8e1f1c..2c5e08ba1f571 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -171,6 +171,9 @@ pub struct NodeArgs { #[command(flatten)] pub server_config: ServerConfig, + /// The memory limit per EVM execution in bytes. + #[arg(long)] + pub memory_limit: Option, } #[cfg(windows)] @@ -235,6 +238,7 @@ impl NodeArgs { .with_optimism(self.evm_opts.optimism) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) + .with_memory_limit(self.memory_limit) } fn account_generator(&self) -> AccountGenerator { diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 354bf2c589d9a..039d7779b4404 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -172,6 +172,8 @@ pub struct NodeConfig { pub enable_optimism: bool, /// Slots in an epoch pub slots_in_an_epoch: u64, + /// Memory configuration layer + pub memory_limit: Option, } impl NodeConfig { @@ -407,11 +409,18 @@ impl Default for NodeConfig { disable_default_create2_deployer: false, enable_optimism: false, slots_in_an_epoch: 32, + memory_limit: None, } } } impl NodeConfig { + /// Returns the memory limit of the node + #[must_use] + pub fn with_memory_limit(mut self, mems_value: Option) -> Self { + self.memory_limit = mems_value; + self + } /// Returns the base fee to use pub fn get_base_fee(&self) -> U256 { self.base_fee @@ -831,6 +840,10 @@ impl NodeConfig { cfg.disable_block_gas_limit = self.disable_block_gas_limit; cfg.handler_cfg.is_optimism = self.enable_optimism; + if let Some(value) = self.memory_limit { + cfg.memory_limit = value; + } + let env = revm::primitives::Env { cfg: cfg.cfg_env, block: BlockEnv { From 563e0624ba5a4a317202b4c9bc1d0120ed7c49f0 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 25 Mar 2024 22:27:01 +0100 Subject: [PATCH 0792/1963] chore: move var to evm args (#7492) --- crates/anvil/src/cmd.rs | 9 +++++---- crates/anvil/src/config.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 2c5e08ba1f571..9cde54553120c 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -171,9 +171,6 @@ pub struct NodeArgs { #[command(flatten)] pub server_config: ServerConfig, - /// The memory limit per EVM execution in bytes. - #[arg(long)] - pub memory_limit: Option, } #[cfg(windows)] @@ -238,7 +235,7 @@ impl NodeArgs { .with_optimism(self.evm_opts.optimism) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) - .with_memory_limit(self.memory_limit) + .with_memory_limit(self.evm_opts.memory_limit) } fn account_generator(&self) -> AccountGenerator { @@ -507,6 +504,10 @@ pub struct AnvilEvmArgs { /// Disable the default create2 deployer #[arg(long, visible_alias = "no-create2")] pub disable_default_create2_deployer: bool, + + /// The memory limit per EVM execution in bytes. + #[arg(long)] + pub memory_limit: Option, } /// Resolves an alias passed as fork-url to the matching url defined in the rpc_endpoints section diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 039d7779b4404..96e7896ebc1d6 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -172,7 +172,7 @@ pub struct NodeConfig { pub enable_optimism: bool, /// Slots in an epoch pub slots_in_an_epoch: u64, - /// Memory configuration layer + /// The memory limit per EVM execution in bytes. pub memory_limit: Option, } From b0698bbe0ed8a3d0799845a12e8f1ec3fbc69144 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:37:30 +0200 Subject: [PATCH 0793/1963] fix(config): inline config intermingled (#7496) fix(config): inline config intermingled when multiple contracts in same file --- crates/config/src/inline/natspec.rs | 51 +++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 3b62d40cc1c28..27742eb56e4b9 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -189,13 +189,13 @@ impl SolangParser { } let Ok((pt, comments)) = solang_parser::parse(src, 0) else { return }; - let mut prev_end = 0; for item in &pt.0 { let pt::SourceUnitPart::ContractDefinition(c) = item else { continue }; let Some(id) = c.name.as_ref() else { continue }; if id.name != contract_name { continue }; + let mut prev_end = c.loc.start(); for part in &c.parts { let pt::ContractPart::FunctionDefinition(f) = part else { continue }; let start = f.loc.start(); @@ -215,7 +215,6 @@ impl SolangParser { } prev_end = f.loc.end(); } - prev_end = c.loc.end(); } } } @@ -401,4 +400,52 @@ contract FuzzInlineConf is DSTest { docs: conf.to_string(), } } + + #[test] + fn parse_solang_multiple_contracts_from_same_file() { + let src = r#" +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity >=0.8.0; + +import "ds-test/test.sol"; + +contract FuzzInlineConf is DSTest { + /// forge-config: default.fuzz.runs = 1 + function testInlineConfFuzz1() {} +} + +contract FuzzInlineConf2 is DSTest { + /// forge-config: default.fuzz.runs = 2 + function testInlineConfFuzz2() {} +} + "#; + let mut natspecs = vec![]; + let solang = SolangParser::new(); + let id = || "inline/FuzzInlineConf.t.sol:FuzzInlineConf".to_string(); + let default_line = || "0:0:0".to_string(); + solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); + assert_eq!( + natspecs, + [NatSpec { + contract: id(), + function: "testInlineConfFuzz1".to_string(), + line: default_line(), + docs: "forge-config: default.fuzz.runs = 1".to_string(), + },] + ); + + let mut natspecs = vec![]; + let id = || "inline/FuzzInlineConf2.t.sol:FuzzInlineConf2".to_string(); + solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf2"); + assert_eq!( + natspecs, + [NatSpec { + contract: id(), + function: "testInlineConfFuzz2".to_string(), + line: default_line(), + // should not get config from previous contract + docs: "forge-config: default.fuzz.runs = 2".to_string(), + },] + ); + } } From 157a253f486a20da2df71ef50a1eb76acc038f09 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 26 Mar 2024 19:26:18 +0400 Subject: [PATCH 0794/1963] fix: avoid creating extra journal entries (#7493) * fix: avoid creating extra journal entries * add test * fmt * graceful error handling --- crates/evm/core/src/backend/mod.rs | 33 +++++++++++++---------- crates/evm/evm/src/inspectors/stack.rs | 35 +++++++++++++++---------- crates/forge/tests/it/repros.rs | 2 ++ testdata/default/repros/Issue7481.t.sol | 22 ++++++++++++++++ 4 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 testdata/default/repros/Issue7481.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index f55259f4d1e0d..ca6cbb1ef8bdd 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -17,7 +17,7 @@ use revm::{ precompile::{PrecompileSpecId, Precompiles}, primitives::{ Account, AccountInfo, Bytecode, CreateScheme, Env, EnvWithHandlerCfg, HashMap as Map, Log, - ResultAndState, SpecId, StorageSlot, TransactTo, KECCAK_EMPTY, + ResultAndState, SpecId, State, StorageSlot, TransactTo, KECCAK_EMPTY, }, Database, DatabaseCommit, Inspector, JournaledState, }; @@ -1888,7 +1888,19 @@ fn commit_transaction>( }; trace!(elapsed = ?now.elapsed(), "transacted transaction"); - apply_state_changeset(res.state, journaled_state, fork); + apply_state_changeset(res.state, journaled_state, fork)?; + Ok(()) +} + +/// Helper method which updates data in the state with the data from the database. +pub fn update_state(state: &mut State, db: &mut DB) -> Result<(), DB::Error> { + for (addr, acc) in state.iter_mut() { + acc.info = db.basic(*addr)?.unwrap_or_default(); + for (key, val) in acc.storage.iter_mut() { + val.present_value = db.storage(*addr, *key)?; + } + } + Ok(()) } @@ -1898,19 +1910,12 @@ fn apply_state_changeset( state: Map, journaled_state: &mut JournaledState, fork: &mut Fork, -) { - let changed_accounts = state.keys().copied().collect::>(); +) -> Result<(), DatabaseError> { // commit the state and update the loaded accounts fork.db.commit(state); - for addr in changed_accounts { - // reload all changed accounts by removing them from the journaled state and reloading them - // from the now updated database - if journaled_state.state.remove(&addr).is_some() { - let _ = journaled_state.load_account(addr, &mut fork.db); - } - if fork.journaled_state.state.remove(&addr).is_some() { - let _ = fork.journaled_state.load_account(addr, &mut fork.db); - } - } + update_state(&mut journaled_state.state, &mut fork.db)?; + update_state(&mut fork.journaled_state.state, &mut fork.db)?; + + Ok(()) } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index ea0af6bbc8731..6f83bf43f8678 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -3,7 +3,10 @@ use super::{ StackSnapshotType, TracingInspector, TracingInspectorConfig, }; use alloy_primitives::{Address, Bytes, Log, U256}; -use foundry_evm_core::{backend::DatabaseExt, debug::DebugArena}; +use foundry_evm_core::{ + backend::{update_state, DatabaseExt}, + debug::DebugArena, +}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ @@ -11,7 +14,7 @@ use revm::{ CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, }, - primitives::{BlockEnv, Env, EnvWithHandlerCfg, ExecutionResult, Output, State, TransactTo}, + primitives::{BlockEnv, Env, EnvWithHandlerCfg, ExecutionResult, Output, TransactTo}, DatabaseCommit, EvmContext, Inspector, }; use std::{collections::HashMap, sync::Arc}; @@ -228,16 +231,6 @@ macro_rules! call_inspectors_adjust_depth { }; } -/// Helper method which updates data in the state with the data from the database. -fn update_state(state: &mut State, db: &mut DB) { - for (addr, acc) in state.iter_mut() { - acc.info = db.basic(*addr).unwrap().unwrap_or_default(); - for (key, val) in acc.storage.iter_mut() { - val.present_value = db.storage(*addr, *key).unwrap(); - } - } -} - /// The collected results of [`InspectorStack`]. pub struct InspectorData { pub logs: Vec, @@ -500,8 +493,22 @@ impl InspectorStack { ecx.db.commit(res.state.clone()); // Update both states with new DB data after commit. - update_state(&mut ecx.journaled_state.state, &mut ecx.db); - update_state(&mut res.state, &mut ecx.db); + if let Err(e) = update_state(&mut ecx.journaled_state.state, &mut ecx.db) { + let res = InterpreterResult { + result: InstructionResult::Revert, + output: Bytes::from(e.to_string()), + gas, + }; + return (res, None) + } + if let Err(e) = update_state(&mut res.state, &mut ecx.db) { + let res = InterpreterResult { + result: InstructionResult::Revert, + output: Bytes::from(e.to_string()), + gas, + }; + return (res, None) + } // Merge transaction journal into the active journal. for (addr, acc) in res.state { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 38cf76331619a..02f1aa15eea27 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -328,3 +328,5 @@ test_repro!(6634; |config| { cheats_config.always_use_create_2_factory = true; config.runner.cheats_config = std::sync::Arc::new(cheats_config); }); + +test_repro!(7481); diff --git a/testdata/default/repros/Issue7481.t.sol b/testdata/default/repros/Issue7481.t.sol new file mode 100644 index 0000000000000..eb568dc946668 --- /dev/null +++ b/testdata/default/repros/Issue7481.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/7481 +// This test ensures that we don't panic +contract Issue7481Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testFailTransact() public { + vm.createSelectFork("rpcAlias", 19514903); + + // Transfer some funds to sender of tx being transacted to ensure that it appears in journaled state + payable(address(0x5C60cD7a3D50877Bfebd484750FBeb245D936dAD)).call{value: 1}(""); + vm.transact(0xccfd66fc409a633a99b5b75b0e9a2040fcf562d03d9bee3fefc1a5c0eb49c999); + + // Revert the current call to ensure that revm can revert state journal + revert("HERE"); + } +} From 9148dbc2fe0c72e249669b11d04caae593fa6113 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 26 Mar 2024 20:52:12 +0400 Subject: [PATCH 0795/1963] chore: fix clippy and remove goerli usage from tests (#7501) * clippy * rm goerli tests * fix nonce * fix test * fix test --- crates/anvil/src/eth/backend/executor.rs | 14 ++++++++------ crates/cast/bin/cmd/wallet/mod.rs | 2 +- crates/forge/tests/it/test_helpers.rs | 6 ++++++ crates/script/src/artifacts.rs | 1 - crates/script/src/execute.rs | 4 +--- crates/script/src/simulate.rs | 9 +-------- testdata/default/cheats/RpcUrls.t.sol | 7 +++++-- testdata/default/repros/Issue2956.t.sol | 4 ++-- testdata/default/repros/Issue3221.t.sol | 4 ++-- testdata/default/repros/Issue3223.t.sol | 6 ++---- testdata/default/repros/Issue3674.t.sol | 2 +- 11 files changed, 29 insertions(+), 30 deletions(-) diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 320d4688462c1..5e68924c95c39 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -174,12 +174,14 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let ExecutedTransaction { transaction, logs, out, traces, exit_reason: exit, .. } = tx; logs_bloom(logs.clone(), &mut bloom); - let contract_address = if let Some(Output::Create(_, contract_address)) = out { - trace!(target: "backend", "New contract deployed: at {:?}", contract_address); - contract_address - } else { - None - }; + let contract_address = out.as_ref().and_then(|out| { + if let Output::Create(_, contract_address) = out { + trace!(target: "backend", "New contract deployed: at {:?}", contract_address); + *contract_address + } else { + None + } + }); let transaction_index = transaction_infos.len() as u32; let info = TransactionInfo { diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 931ecefa483a9..50467421c4151 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -356,7 +356,7 @@ flag to set your key via: let phrase = Mnemonic::::new_from_phrase(mnemonic.as_str())?.to_phrase(); let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); let derivation_path = "m/44'/60'/0'/0/"; - let index = if let Some(i) = mnemonic_index { i } else { 0 }; + let index = mnemonic_index.unwrap_or_default(); let wallet = builder .clone() .derivation_path(format!("{derivation_path}{index}"))? diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index bf31842b8e52d..0112d4bb96cca 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -292,6 +292,12 @@ pub fn rpc_endpoints() -> RpcEndpoints { "https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf".to_string(), ), ), + ( + "rpcAliasSepolia", + RpcEndpoint::Url( + "https://eth-sepolia.g.alchemy.com/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf".to_string(), + ), + ), ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".to_string())), ]) } diff --git a/crates/script/src/artifacts.rs b/crates/script/src/artifacts.rs index 0a2bd77dd90da..ebd149f4903cf 100644 --- a/crates/script/src/artifacts.rs +++ b/crates/script/src/artifacts.rs @@ -3,7 +3,6 @@ use alloy_json_abi::JsonAbi; /// Bundles info of an artifact pub struct ArtifactInfo<'a> { pub contract_name: String, - pub contract_id: String, pub abi: &'a JsonAbi, pub code: &'a Vec, } diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index cdf4353d38608..4a3a3485208b9 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -274,8 +274,6 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855", /// Container for data being collected after execution. pub struct ExecutionArtifacts { - /// Mapping from contract to its runtime code. - pub known_contracts: ContractsByArtifact, /// Trace decoder used to decode traces. pub decoder: CallTraceDecoder, /// Return values from the execution result. @@ -327,7 +325,7 @@ impl ExecutedState { build_data: self.build_data, execution_data: self.execution_data, execution_result: self.execution_result, - execution_artifacts: ExecutionArtifacts { known_contracts, decoder, returns, rpc_data }, + execution_artifacts: ExecutionArtifacts { decoder, returns, rpc_data }, }) } diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 07e962ddff329..e63c5efcefeeb 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -66,7 +66,6 @@ impl PreSimulationState { script_config: self.script_config, script_wallets: self.script_wallets, build_data: self.build_data, - execution_data: self.execution_data, execution_artifacts: self.execution_artifacts, transactions, }) @@ -199,12 +198,7 @@ impl PreSimulationState { if let Ok(Some((_, (abi, code)))) = contracts.find_by_name_or_identifier(contract_name) { - let info = ArtifactInfo { - contract_name: contract_name.to_string(), - contract_id: contract_id.to_string(), - abi, - code, - }; + let info = ArtifactInfo { contract_name: contract_name.to_string(), abi, code }; return Some((*addr, info)); } None @@ -259,7 +253,6 @@ pub struct FilledTransactionsState { pub script_config: ScriptConfig, pub script_wallets: ScriptWallets, pub build_data: LinkedBuildData, - pub execution_data: ExecutionData, pub execution_artifacts: ExecutionArtifacts, pub transactions: VecDeque, } diff --git a/testdata/default/cheats/RpcUrls.t.sol b/testdata/default/cheats/RpcUrls.t.sol index 3d7b298f4cf5d..4e3ceba58115c 100644 --- a/testdata/default/cheats/RpcUrls.t.sol +++ b/testdata/default/cheats/RpcUrls.t.sol @@ -33,12 +33,15 @@ contract RpcUrlTest is DSTest { assertEq(url, envUrl); string[2][] memory allUrls = vm.rpcUrls(); - assertEq(allUrls.length, 2); + assertEq(allUrls.length, 3); string[2] memory val = allUrls[0]; assertEq(val[0], "rpcAlias"); string[2] memory env = allUrls[1]; - assertEq(env[0], "rpcEnvAlias"); + assertEq(env[0], "rpcAliasSepolia"); + + string[2] memory env2 = allUrls[2]; + assertEq(env2[0], "rpcEnvAlias"); } } diff --git a/testdata/default/repros/Issue2956.t.sol b/testdata/default/repros/Issue2956.t.sol index f77340da4ae21..9d9e5f9ac5862 100644 --- a/testdata/default/repros/Issue2956.t.sol +++ b/testdata/default/repros/Issue2956.t.sol @@ -11,7 +11,7 @@ contract Issue2956Test is DSTest { uint256 fork2; function setUp() public { - fork1 = vm.createFork("https://goerli.infura.io/v3/b9794ad1ddf84dfb8c34d6bb5dca2001", 7475589); + fork1 = vm.createFork("rpcAliasSepolia", 5565573); fork2 = vm.createFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); } @@ -28,7 +28,7 @@ contract Issue2956Test is DSTest { new Counter(); vm.selectFork(fork1); - assertEq(vm.getNonce(user), 3); + assertEq(vm.getNonce(user), 1); vm.prank(user); new Counter(); } diff --git a/testdata/default/repros/Issue3221.t.sol b/testdata/default/repros/Issue3221.t.sol index 9fbc51f60f930..4a9dd7be40997 100644 --- a/testdata/default/repros/Issue3221.t.sol +++ b/testdata/default/repros/Issue3221.t.sol @@ -11,7 +11,7 @@ contract Issue3221Test is DSTest { uint256 fork2; function setUp() public { - fork1 = vm.createFork("https://goerli.infura.io/v3/b1d3925804e74152b316ca7da97060d3", 7475589); + fork1 = vm.createFork("rpcAliasSepolia", 5565573); fork2 = vm.createFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); } @@ -27,7 +27,7 @@ contract Issue3221Test is DSTest { new Counter(); vm.selectFork(fork1); - assertEq(vm.getNonce(user), 3); + assertEq(vm.getNonce(user), 1); vm.prank(user); new Counter(); } diff --git a/testdata/default/repros/Issue3223.t.sol b/testdata/default/repros/Issue3223.t.sol index 4408d24eee5d4..d4c5da751f26b 100644 --- a/testdata/default/repros/Issue3223.t.sol +++ b/testdata/default/repros/Issue3223.t.sol @@ -11,7 +11,7 @@ contract Issue3223Test is DSTest { uint256 fork2; function setUp() public { - fork1 = vm.createFork("https://goerli.infura.io/v3/b9794ad1ddf84dfb8c34d6bb5dca2001", 7475589); + fork1 = vm.createFork("rpcAliasSepolia", 2362365); fork2 = vm.createFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); } @@ -25,9 +25,7 @@ contract Issue3223Test is DSTest { new Counter(); vm.selectFork(fork1); - assertEq(vm.getNonce(user), 3); - vm.prank(user); - new Counter(); + assertEq(vm.getNonce(user), 1); } } diff --git a/testdata/default/repros/Issue3674.t.sol b/testdata/default/repros/Issue3674.t.sol index f13f7f162b368..813f73b5d8f0b 100644 --- a/testdata/default/repros/Issue3674.t.sol +++ b/testdata/default/repros/Issue3674.t.sol @@ -9,7 +9,7 @@ contract Issue3674Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testNonceCreateSelect() public { - vm.createSelectFork("https://goerli.infura.io/v3/b9794ad1ddf84dfb8c34d6bb5dca2001"); + vm.createSelectFork("rpcAliasSepolia"); vm.createSelectFork("https://api.avax-test.network/ext/bc/C/rpc"); assert(vm.getNonce(msg.sender) > 0x17); From 35a8cce6cefdbf9691c65a9d5497557bc85d8db3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:15:03 +0200 Subject: [PATCH 0796/1963] perf(fuzz): use default std hasher for fuzz dict states (#7505) --- Cargo.lock | 1 - crates/evm/fuzz/Cargo.toml | 1 - crates/evm/fuzz/src/strategies/state.rs | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca3a63fa4e590..665b53187690b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3477,7 +3477,6 @@ dependencies = [ "proptest", "rand 0.8.5", "revm", - "rustc-hash", "serde", "thiserror", "tracing", diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 3c20b029a6280..8a21d96526874 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -39,5 +39,4 @@ rand.workspace = true serde = "1" thiserror = "1" tracing = "0.1" -rustc-hash.workspace = true indexmap.workspace = true diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 1cf1d37882f1e..a01c5566810bb 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -17,8 +17,7 @@ use std::{fmt, sync::Arc}; // We're using `IndexSet` to have a stable element order when restoring persisted state, as well as // for performance when iterating over the sets. -type FxIndexSet = - indexmap::set::IndexSet>; +type FxIndexSet = indexmap::set::IndexSet; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// From 9881e7de5d112c8d602b466a901b83fc99667906 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 27 Mar 2024 22:33:09 +0100 Subject: [PATCH 0797/1963] chore(script): use `try_join_all` in `build_runners` (#7508) --- crates/script/src/simulate.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index e63c5efcefeeb..96b1eaefe2f0f 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -21,7 +21,7 @@ use foundry_common::{ get_contract_name, provider::ethers::RpcUrl, shell, types::ToAlloy, ContractsByArtifact, }; use foundry_evm::traces::render_trace_arena; -use futures::future::join_all; +use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; use std::{ collections::{BTreeMap, HashMap, VecDeque}, @@ -207,7 +207,7 @@ impl PreSimulationState { } /// Build [ScriptRunner] forking given RPC for each RPC used in the script. - async fn build_runners(&self) -> Result> { + async fn build_runners(&self) -> Result> { let rpcs = self.execution_artifacts.rpc_data.total_rpcs.clone(); if !shell::verbosity().is_silent() { let n = rpcs.len(); @@ -215,17 +215,13 @@ impl PreSimulationState { println!("\n## Setting up {n} EVM{s}."); } - let futs = rpcs - .into_iter() - .map(|rpc| async move { - let mut script_config = self.script_config.clone(); - script_config.evm_opts.fork_url = Some(rpc.clone()); - let runner = script_config.get_runner().await?; - Ok((rpc.clone(), runner)) - }) - .collect::>(); - - join_all(futs).await.into_iter().collect() + let futs = rpcs.into_iter().map(|rpc| async move { + let mut script_config = self.script_config.clone(); + script_config.evm_opts.fork_url = Some(rpc.clone()); + let runner = script_config.get_runner().await?; + Ok((rpc.clone(), runner)) + }); + try_join_all(futs).await } /// If simulation is disabled, converts transactions into [TransactionWithMetadata] type From 369597f2b8a83c775fdb37f7c60fe5f0beb573e1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 28 Mar 2024 03:41:39 +0100 Subject: [PATCH 0798/1963] perf: use `jemalloc` as the global allocator on unix (try 2) (#7448) --- .github/workflows/release.yml | 6 ++++-- Cargo.lock | 24 ++++++++++++++++++++++++ Cargo.toml | 2 ++ crates/anvil/Cargo.toml | 18 ++++++++---------- crates/anvil/src/anvil.rs | 6 ++++++ crates/cast/Cargo.toml | 4 ++++ crates/cast/bin/main.rs | 4 ++++ crates/chisel/Cargo.toml | 4 ++++ crates/chisel/bin/main.rs | 4 ++++ crates/forge/Cargo.toml | 4 ++++ crates/forge/bin/main.rs | 8 ++++++-- 11 files changed, 70 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 071b0f6286815..c7422bfb67f88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -135,8 +135,10 @@ jobs: target="${{ matrix.target }}" flags=() - # `keccak-asm` does not support MSVC or aarch64 Linux. - [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]] && flags+=(--features=asm-keccak) + # `jemalloc` and `keccak-asm` are not supported on MSVC or aarch64 Linux. + if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then + flags+=(--features asm-keccak,jemalloc) + fi [[ "$target" == *windows* ]] && exe=".exe" diff --git a/Cargo.lock b/Cargo.lock index 665b53187690b..05a4e79a1617d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -576,6 +576,7 @@ dependencies = [ "serde_repr", "tempfile", "thiserror", + "tikv-jemallocator", "tokio", "tower", "tracing", @@ -1338,6 +1339,7 @@ dependencies = [ "serde", "serde_json", "tempfile", + "tikv-jemallocator", "tokio", "tracing", "vergen", @@ -1402,6 +1404,7 @@ dependencies = [ "serial_test", "solang-parser", "strum 0.26.2", + "tikv-jemallocator", "time", "tokio", "tracing", @@ -3008,6 +3011,7 @@ dependencies = [ "svm-rs 0.4.1", "tempfile", "thiserror", + "tikv-jemallocator", "tokio", "tower-http", "tracing", @@ -7636,6 +7640,26 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.34" diff --git a/Cargo.toml b/Cargo.toml index e8dac00dbb350..640c652aee8b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,7 @@ ruint.opt-level = 3 sha2.opt-level = 3 sha3.opt-level = 3 tiny-keccak.opt-level = 3 +bitvec.opt-level = 3 # fuzzing proptest.opt-level = 3 @@ -208,6 +209,7 @@ tracing = "0.1" tracing-subscriber = "0.3" vergen = { version = "8", default-features = false } indexmap = "2.2" +tikv-jemallocator = "0.5.4" axum = "0.6" hyper = "0.14" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 18682e5d23c48..7a554a02283d2 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,11 +16,7 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # foundry internal @@ -81,11 +77,7 @@ rand = "0.8" eyre.workspace = true # cli -clap = { version = "4", features = [ - "derive", - "env", - "wrap_help", -], optional = true } +clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" @@ -94,6 +86,9 @@ fdlimit = { version = "0.3", optional = true } clap_complete_fig = "4" ethereum-forkid = "0.12" +[target.'cfg(unix)'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] alloy-json-abi.workspace = true ethers = { workspace = true, features = ["abigen"] } @@ -109,3 +104,6 @@ default = ["cli"] cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"] cli = ["tokio/full", "cmd", "fdlimit"] asm-keccak = ["alloy-primitives/asm-keccak"] +# TODO: parity dependencies are not compatible with a different global allocator. +# jemalloc = ["dep:tikv-jemallocator"] +jemalloc = [] diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 8ce75751c7f13..54a5e41cf55ea 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -4,6 +4,12 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; use foundry_cli::utils; +// TODO: parity dependencies are not compatible with a different global allocator. +#[cfg(any())] +#[cfg(all(feature = "jemalloc", unix))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + /// A fast local Ethereum development node. #[derive(Parser)] #[command(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index e97ae59c52414..5361b3dea8b5c 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -75,6 +75,9 @@ tracing.workspace = true yansi = "0.5" evmole = "0.3.1" +[target.'cfg(unix)'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] foundry-test-utils.workspace = true async-trait = "0.1" @@ -85,6 +88,7 @@ default = ["rustls"] rustls = ["foundry-cli/rustls", "foundry-wallets/rustls"] openssl = ["foundry-cli/openssl", "foundry-wallets/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] +jemalloc = ["dep:tikv-jemallocator"] [[bench]] name = "vanity" diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 9ea81369ee7db..a81c1acd8b5a4 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -30,6 +30,10 @@ pub mod tx; use opts::{Cast as Opts, CastSubcommand, ToBaseArgs}; +#[cfg(all(feature = "jemalloc", unix))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + #[tokio::main] async fn main() -> Result<()> { handler::install(); diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 589beaa3ef7f9..9829abb7c475b 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -50,6 +50,9 @@ tokio = { version = "1", features = ["full"] } yansi = "0.5" tracing.workspace = true +[target.'cfg(unix)'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } once_cell = "1" @@ -61,6 +64,7 @@ default = ["rustls"] rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-compilers/openssl", "reqwest/default-tls"] asm-keccak = ["alloy-primitives/asm-keccak"] +jemalloc = ["dep:tikv-jemallocator"] [[bench]] name = "session_source" diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 43b6a1b21254c..0cca09bf98735 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -27,6 +27,10 @@ use std::path::PathBuf; use tracing::debug; use yansi::Paint; +#[cfg(all(feature = "jemalloc", unix))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(Chisel, opts, evm_opts); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 84abd46373e2a..f5a6b27c7911d 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -87,6 +87,9 @@ hyper.workspace = true tower-http = { workspace = true, features = ["fs"] } opener = "0.6" +[target.'cfg(unix)'.dependencies] +tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true @@ -110,6 +113,7 @@ rustls = [ ] openssl = ["foundry-cli/openssl", "reqwest/default-tls", "foundry-wallets/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] +jemalloc = ["dep:tikv-jemallocator"] [[bench]] name = "test" diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 0743d69e61aa1..b5ba3228f2f1e 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -7,11 +7,15 @@ use eyre::Result; use foundry_cli::{handler, utils}; mod cmd; -mod opts; - use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; + +mod opts; use opts::{Forge, ForgeSubcommand}; +#[cfg(all(feature = "jemalloc", unix))] +#[global_allocator] +static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + fn main() -> Result<()> { handler::install(); utils::load_dotenv(); From 39ac1a1b16cb34a64a67df6ba4446f5539eebf2f Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:48:35 +0200 Subject: [PATCH 0799/1963] chore: remove misleading/unneeded FxIndexSet type (#7511) --- crates/evm/fuzz/src/strategies/state.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index a01c5566810bb..df70ba88520a5 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -6,6 +6,7 @@ use alloy_primitives::{Address, Bytes, Log, B256, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; +use indexmap::IndexSet; use parking_lot::RwLock; use proptest::prelude::{BoxedStrategy, Strategy}; use revm::{ @@ -15,21 +16,19 @@ use revm::{ }; use std::{fmt, sync::Arc}; -// We're using `IndexSet` to have a stable element order when restoring persisted state, as well as -// for performance when iterating over the sets. -type FxIndexSet = indexmap::set::IndexSet; - /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// /// Wrapped in a shareable container. pub type EvmFuzzState = Arc>; +// We're using `IndexSet` to have a stable element order when restoring persisted state, as well as +// for performance when iterating over the sets. #[derive(Default)] pub struct FuzzDictionary { /// Collected state values. - state_values: FxIndexSet<[u8; 32]>, + state_values: IndexSet<[u8; 32]>, /// Addresses that already had their PUSH bytes collected. - addresses: FxIndexSet
, + addresses: IndexSet
, } impl fmt::Debug for FuzzDictionary { @@ -43,22 +42,22 @@ impl fmt::Debug for FuzzDictionary { impl FuzzDictionary { #[inline] - pub fn values(&self) -> &FxIndexSet<[u8; 32]> { + pub fn values(&self) -> &IndexSet<[u8; 32]> { &self.state_values } #[inline] - pub fn values_mut(&mut self) -> &mut FxIndexSet<[u8; 32]> { + pub fn values_mut(&mut self) -> &mut IndexSet<[u8; 32]> { &mut self.state_values } #[inline] - pub fn addresses(&self) -> &FxIndexSet
{ + pub fn addresses(&self) -> &IndexSet
{ &self.addresses } #[inline] - pub fn addresses_mut(&mut self) -> &mut FxIndexSet
{ + pub fn addresses_mut(&mut self) -> &mut IndexSet
{ &mut self.addresses } } From 345d000e22e596adfb1171332e5d45cc33d368f1 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 28 Mar 2024 17:18:45 +0400 Subject: [PATCH 0800/1963] feat: `vm.sign` for scripts (#7454) * feat: vm.sign for script wallets * more tests * clippy * if let some else * review fixes --- crates/cheatcodes/assets/cheatcodes.json | 44 ++++++++++++++++++- crates/cheatcodes/spec/src/vm.rs | 32 ++++++++++++-- crates/cheatcodes/src/evm.rs | 14 ++++++ crates/cheatcodes/src/utils.rs | 54 +++++++++++++++++++++--- crates/forge/tests/cli/script.rs | 22 ++++++++++ crates/test-utils/src/script.rs | 5 ++- testdata/cheats/Vm.sol | 2 + testdata/default/cheats/Broadcast.t.sol | 42 ++++++++++++++++++ 8 files changed, 201 insertions(+), 14 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 9c69772b69f94..dea51432227f6 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2941,7 +2941,7 @@ { "func": { "id": "broadcast_0", - "description": "Using the address that calls the test contract, has the next call (at this call depth only)\ncreate a transaction that can later be signed and sent onchain.", + "description": "Has the next call (at this call depth only) create transactions that can later be signed and sent onchain.\nBroadcasting address is determined by checking the following in order:\n1. If `--sender` argument was provided, that address is used.\n2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.\n3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.", "declaration": "function broadcast() external;", "visibility": "external", "mutability": "", @@ -7081,6 +7081,46 @@ { "func": { "id": "sign_1", + "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nIf `--sender` is provided, the signer with provided address is used, otherwise,\nif exactly one signer is provided to the script, that signer is used.\nRaises error if signer passed through `--sender` does not match any unlocked signers or\nif `--sender` is not provided and not exactly one signer is passed to the script.", + "declaration": "function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "pure", + "signature": "sign(bytes32)", + "selector": "0x799cd333", + "selectorBytes": [ + 121, + 156, + 211, + 51 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "sign_2", + "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nRaises error if none of the signers passed into the script have provided address.", + "declaration": "function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "pure", + "signature": "sign(address,bytes32)", + "selector": "0x8c1aa205", + "selectorBytes": [ + 140, + 26, + 162, + 5 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "sign_3", "description": "Signs data with a `Wallet`.", "declaration": "function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);", "visibility": "external", @@ -7181,7 +7221,7 @@ { "func": { "id": "startBroadcast_0", - "description": "Using the address that calls the test contract, has all subsequent calls\n(at this call depth only) create transactions that can later be signed and sent onchain.", + "description": "Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain.\nBroadcasting address is determined by checking the following in order:\n1. If `--sender` argument was provided, that address is used.\n2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.\n3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.", "declaration": "function startBroadcast() external;", "visibility": "external", "mutability": "", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index cdcca3331785c..8f0de363a7fab 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -249,6 +249,22 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// If `--sender` is provided, the signer with provided address is used, otherwise, + /// if exactly one signer is provided to the script, that signer is used. + /// + /// Raises error if signer passed through `--sender` does not match any unlocked signers or + /// if `--sender` is not provided and not exactly one signer is passed to the script. + #[cheatcode(group = Evm, safety = Safe)] + function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// Raises error if none of the signers passed into the script have provided address. + #[cheatcode(group = Evm, safety = Safe)] + function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + /// Signs `digest` with `privateKey` using the secp256r1 curve. #[cheatcode(group = Evm, safety = Safe)] function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); @@ -1563,8 +1579,12 @@ interface Vm { // -------- Broadcasting Transactions -------- - /// Using the address that calls the test contract, has the next call (at this call depth only) - /// create a transaction that can later be signed and sent onchain. + /// Has the next call (at this call depth only) create transactions that can later be signed and sent onchain. + /// + /// Broadcasting address is determined by checking the following in order: + /// 1. If `--sender` argument was provided, that address is used. + /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used. + /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used. #[cheatcode(group = Scripting)] function broadcast() external; @@ -1578,8 +1598,12 @@ interface Vm { #[cheatcode(group = Scripting)] function broadcast(uint256 privateKey) external; - /// Using the address that calls the test contract, has all subsequent calls - /// (at this call depth only) create transactions that can later be signed and sent onchain. + /// Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain. + /// + /// Broadcasting address is determined by checking the following in order: + /// 1. If `--sender` argument was provided, that address is used. + /// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used. + /// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used. #[cheatcode(group = Scripting)] function startBroadcast() external; diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 601c97ad00463..2f3dafedefe6e 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -145,6 +145,20 @@ impl Cheatcode for sign_0Call { } } +impl Cheatcode for sign_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { digest } = self; + super::utils::sign_with_wallet(ccx, None, digest) + } +} + +impl Cheatcode for sign_2Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { signer, digest } = self; + super::utils::sign_with_wallet(ccx, Some(*signer), digest) + } +} + impl Cheatcode for signP256Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey, digest } = self; diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 525120d7de8f0..f9edc8e40d7c5 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -1,7 +1,7 @@ //! Implementations of [`Utils`](crate::Group::Utils) cheatcodes. use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::{keccak256, B256, U256}; +use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_signer::{ coins_bip39::{ ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, @@ -10,7 +10,8 @@ use alloy_signer::{ LocalWallet, MnemonicBuilder, Signer, SignerSync, }; use alloy_sol_types::SolValue; -use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; +use foundry_common::types::{ToAlloy, ToEthers}; +use foundry_evm_core::{constants::DEFAULT_CREATE2_DEPLOYER, utils::RuntimeOrHandle}; use k256::{ ecdsa::SigningKey, elliptic_curve::{sec1::ToEncodedPoint, Curve}, @@ -49,7 +50,7 @@ impl Cheatcode for getNonce_1Call { } } -impl Cheatcode for sign_1Call { +impl Cheatcode for sign_3Call { fn apply_full(&self, _: &mut CheatsCtxt) -> Result { let Self { wallet, digest } = self; sign(&wallet.privateKey, digest) @@ -156,6 +157,10 @@ fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes .abi_encode()) } +fn encode_vrs(v: u8, r: U256, s: U256) -> Vec { + (U256::from(v), B256::from(r), B256::from(s)).abi_encode() +} + pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. let wallet = parse_wallet(private_key)?; @@ -165,11 +170,46 @@ pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { assert_eq!(recovered, wallet.address()); - let v = U256::from(sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte())); - let r = B256::from(sig.r()); - let s = B256::from(sig.s()); + let v = sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte()); + + Ok(encode_vrs(v, sig.r(), sig.s())) +} - Ok((v, r, s).abi_encode()) +pub(super) fn sign_with_wallet( + ccx: &mut CheatsCtxt, + signer: Option
, + digest: &B256, +) -> Result { + let Some(script_wallets) = &ccx.state.script_wallets else { + return Err("no wallets are available".into()); + }; + + let mut script_wallets = script_wallets.inner.lock(); + let maybe_provided_sender = script_wallets.provided_sender; + let signers = script_wallets.multi_wallet.signers()?; + + let signer = if let Some(signer) = signer { + signer + } else if let Some(provided_sender) = maybe_provided_sender { + provided_sender + } else if signers.len() == 1 { + *signers.keys().next().unwrap() + } else { + return Err("could not determine signer".into()); + }; + + let wallet = signers + .get(&signer) + .ok_or_else(|| fmt_err!("signer with address {signer} is not available"))?; + + let sig = RuntimeOrHandle::new() + .block_on(wallet.sign_hash(digest)) + .map_err(|err| fmt_err!("{err}"))?; + + let recovered = sig.recover(digest.to_ethers()).map_err(|err| fmt_err!("{err}"))?; + assert_eq!(recovered.to_alloy(), signer); + + Ok(encode_vrs(sig.v as u8, sig.r.to_alloy(), sig.s.to_alloy())) } pub(super) fn sign_p256(private_key: &U256, digest: &B256, _state: &mut Cheatcodes) -> Result { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index e212683c1a2b0..ff03a6b57e887 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1157,3 +1157,25 @@ contract ScriptC {} tester.cmd.forge_fuse().args(["script", "script/B.sol"]); tester.simulate(ScriptOutcome::OkNoEndpoint); }); + +forgetest_async!(can_sign_with_script_wallet_single, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); + tester + .add_sig("ScriptSign", "run()") + .load_private_keys(&[0]) + .await + .simulate(ScriptOutcome::OkNoEndpoint); +}); + +forgetest_async!(can_sign_with_script_wallet_multiple, |prj, cmd| { + let mut tester = ScriptTester::new_broadcast_without_endpoint(cmd, prj.root()); + let acc = tester.accounts_pub[0].to_checksum(None); + tester + .add_sig("ScriptSign", "run(address)") + .arg(&acc) + .load_private_keys(&[0, 1, 2]) + .await + .simulate(ScriptOutcome::OkRun); +}); diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 80b06ae769b20..b60723d9d8d2c 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -264,6 +264,7 @@ pub enum ScriptOutcome { ScriptFailed, UnsupportedLibraries, ErrorSelectForkOnBroadcast, + OkRun, } impl ScriptOutcome { @@ -279,6 +280,7 @@ impl ScriptOutcome { Self::ScriptFailed => "script failed: ", Self::UnsupportedLibraries => "Multi chain deployment does not support library linking at the moment.", Self::ErrorSelectForkOnBroadcast => "cannot select forks during a broadcast", + Self::OkRun => "Script ran successfully", } } @@ -287,7 +289,8 @@ impl ScriptOutcome { ScriptOutcome::OkNoEndpoint | ScriptOutcome::OkSimulation | ScriptOutcome::OkBroadcast | - ScriptOutcome::WarnSpecifyDeployer => false, + ScriptOutcome::WarnSpecifyDeployer | + ScriptOutcome::OkRun => false, ScriptOutcome::MissingSender | ScriptOutcome::MissingWallet | ScriptOutcome::StaticCallNotAllowed | diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index b5a604e14d963..2116acf2b8ffe 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -351,6 +351,8 @@ interface Vm { function setNonceUnsafe(address account, uint64 newNonce) external; function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); function skip(bool skipTest) external; function sleep(uint256 duration) external; diff --git a/testdata/default/cheats/Broadcast.t.sol b/testdata/default/cheats/Broadcast.t.sol index d44bc954006f2..6a099dc6ed54b 100644 --- a/testdata/default/cheats/Broadcast.t.sol +++ b/testdata/default/cheats/Broadcast.t.sol @@ -528,3 +528,45 @@ contract ScriptAdditionalContracts is DSTest { new Parent(); } } + +contract SignatureTester { + address public immutable owner; + + constructor() { + owner = msg.sender; + } + + function verifySignature(bytes32 digest, uint8 v, bytes32 r, bytes32 s) public view returns (bool) { + require(ecrecover(digest, v, r, s) == owner, "Invalid signature"); + } +} + +contract ScriptSign is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + bytes32 digest = keccak256("something"); + + function run() external { + vm.startBroadcast(); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(digest); + + vm._expectCheatcodeRevert( + bytes(string.concat("signer with address ", vm.toString(address(this)), " is not available")) + ); + vm.sign(address(this), digest); + + SignatureTester tester = new SignatureTester(); + (, address caller,) = vm.readCallers(); + assertEq(tester.owner(), caller); + tester.verifySignature(digest, v, r, s); + } + + function run(address sender) external { + vm._expectCheatcodeRevert(bytes("could not determine signer")); + vm.sign(digest); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(sender, digest); + address actual = ecrecover(digest, v, r, s); + + assertEq(actual, sender); + } +} From 617dfc28cb8206a0003edcf73a6f1058adaef740 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 29 Mar 2024 03:03:24 +0400 Subject: [PATCH 0801/1963] fix(anvil): clean up `eth_estimateGas` (#7515) * fix(anvil): clean up eth_estimateGas * fix doc * fix doc * fix doc * review fixes --- crates/anvil/src/eth/api.rs | 229 ++++++++++++++---------------------- 1 file changed, 88 insertions(+), 141 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 402bf4b751c7d..aee9670849df1 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1,5 +1,5 @@ use super::{ - backend::mem::{state, BlockRequest}, + backend::mem::{state, BlockRequest, State}, sign::build_typed_transaction, }; use crate::{ @@ -2214,10 +2214,10 @@ impl EthApi { // configured gas limit let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit); - // check with the funds of the sender - if let Some(from) = request.from { - let gas_price = fees.gas_price.unwrap_or_default(); - if gas_price > U256::ZERO { + let gas_price = fees.gas_price.unwrap_or_default(); + // If we have non-zero gas price, cap gas limit by sender balance + if !gas_price.is_zero() { + if let Some(from) = request.from { let mut available_funds = self.backend.get_balance_with_state(&state, from)?; if let Some(value) = request.value { if value > available_funds { @@ -2228,86 +2228,42 @@ impl EthApi { } // amount of gas the sender can afford with the `gas_price` let allowance = available_funds.checked_div(gas_price).unwrap_or_default(); - if highest_gas_limit > allowance { - trace!(target: "node", "eth_estimateGas capped by limited user funds"); - highest_gas_limit = allowance; - } + highest_gas_limit = std::cmp::min(highest_gas_limit, allowance); } } - // if the provided gas limit is less than computed cap, use that - let gas_limit = std::cmp::min(request.gas.unwrap_or(highest_gas_limit), highest_gas_limit); let mut call_to_estimate = request.clone(); - call_to_estimate.gas = Some(gas_limit); + call_to_estimate.gas = Some(highest_gas_limit); // execute the call without writing to db let ethres = self.backend.call_with_state(&state, call_to_estimate, fees.clone(), block_env.clone()); - // Exceptional case: init used too much gas, we need to increase the gas limit and try - // again - if let Err(BlockchainError::InvalidTransaction(InvalidTransactionError::GasTooHigh(_))) = - ethres - { - // if price or limit was included in the request then we can execute the request - // again with the block's gas limit to check if revert is gas related or not - if request.gas.is_some() || request.gas_price.is_some() { - return Err(map_out_of_gas_err( - request, - state, - self.backend.clone(), - block_env, - fees, - gas_limit, - )); + let gas_used = match ethres.try_into()? { + GasEstimationCallResult::Success(gas) => Ok(U256::from(gas)), + GasEstimationCallResult::OutOfGas => { + Err(InvalidTransactionError::BasicOutOfGas(highest_gas_limit).into()) } - } - - let (exit, out, gas, _) = ethres?; - match exit { - return_ok!() => { - // succeeded - } - InstructionResult::OutOfGas | InstructionResult::OutOfFunds => { - return Err(InvalidTransactionError::BasicOutOfGas(gas_limit).into()) - } - // need to check if the revert was due to lack of gas or unrelated reason - // we're also checking for InvalidFEOpcode here because this can be used to trigger an error common usage in openzeppelin - return_revert!() | InstructionResult::InvalidFEOpcode => { - // if price or limit was included in the request then we can execute the request - // again with the max gas limit to check if revert is gas related or not - return if request.gas.is_some() || request.gas_price.is_some() { - Err(map_out_of_gas_err( - request, - state, - self.backend.clone(), - block_env, - fees, - gas_limit, - )) - } else { - // the transaction did fail due to lack of gas from the user - Err(InvalidTransactionError::Revert(Some(convert_transact_out(&out).0.into())) - .into()) - }; + GasEstimationCallResult::Revert(output) => { + Err(InvalidTransactionError::Revert(output).into()) } - reason => { - warn!(target: "node", "estimation failed due to {:?}", reason); - return Err(BlockchainError::EvmError(reason)); + GasEstimationCallResult::EvmError(err) => { + warn!(target: "node", "estimation failed due to {:?}", err); + Err(BlockchainError::EvmError(err)) } - } + }?; // at this point we know the call succeeded but want to find the _best_ (lowest) gas the // transaction succeeds with. we find this by doing a binary search over the // possible range NOTE: this is the gas the transaction used, which is less than the // transaction requires to succeed - let gas: U256 = U256::from(gas); + // Get the starting lowest gas needed depending on the transaction kind. let mut lowest_gas_limit = determine_base_gas_by_kind(&request); // pick a point that's close to the estimated gas let mut mid_gas_limit = std::cmp::min( - gas * U256::from(3), + gas_used * U256::from(3), (highest_gas_limit + lowest_gas_limit) / U256::from(2), ); @@ -2321,52 +2277,25 @@ impl EthApi { block_env.clone(), ); - // Exceptional case: init used too much gas, we need to increase the gas limit and try - // again - if let Err(BlockchainError::InvalidTransaction(InvalidTransactionError::GasTooHigh( - _, - ))) = ethres - { - // increase the lowest gas limit - lowest_gas_limit = mid_gas_limit; - - // new midpoint - mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / U256::from(2); - continue; - } - - match ethres { - Ok((exit, _, _gas, _)) => match exit { + match ethres.try_into()? { + GasEstimationCallResult::Success(_) => { // If the transaction succeeded, we can set a ceiling for the highest gas limit // at the current midpoint, as spending any more gas would // make no sense (as the TX would still succeed). - return_ok!() => { - highest_gas_limit = mid_gas_limit; - } - // If the transaction failed due to lack of gas, we can set a floor for the - // lowest gas limit at the current midpoint, as spending any - // less gas would make no sense (as the TX would still revert due to lack of - // gas). - InstructionResult::Revert | - InstructionResult::OutOfGas | - InstructionResult::OutOfFunds | - // we're also checking for InvalidFEOpcode here because this can be used to trigger an error common usage in openzeppelin - InstructionResult::InvalidFEOpcode => { - lowest_gas_limit = mid_gas_limit; - } - // The tx failed for some other reason. - reason => { - warn!(target: "node", "estimation failed due to {:?}", reason); - return Err(BlockchainError::EvmError(reason)) - } - }, - // We've already checked for the exceptional GasTooHigh case above, so this is a - // real error. - Err(reason) => { - warn!(target: "node", "estimation failed due to {:?}", reason); - return Err(reason); + highest_gas_limit = mid_gas_limit; } - } + GasEstimationCallResult::OutOfGas | + GasEstimationCallResult::Revert(_) | + GasEstimationCallResult::EvmError(_) => { + // If the transaction failed, we can set a floor for the lowest gas limit at the + // current midpoint, as spending any less gas would make no + // sense (as the TX would still revert due to lack of gas). + // + // We don't care about the reason here, as we known that trasaction is correct + // as it succeeded earlier + lowest_gas_limit = mid_gas_limit; + } + }; // new midpoint mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / U256::from(2); } @@ -2631,42 +2560,6 @@ fn ensure_return_ok(exit: InstructionResult, out: &Option) -> Result( - mut request: TransactionRequest, - state: D, - backend: Arc, - block_env: BlockEnv, - fees: FeeDetails, - gas_limit: U256, -) -> BlockchainError -where - D: DatabaseRef, -{ - request.gas = Some(backend.gas_limit()); - let (exit, out, _, _) = match backend.call_with_state(&state, request, fees, block_env) { - Ok(res) => res, - Err(err) => return err, - }; - match exit { - return_ok!() => { - // transaction succeeded by manually increasing the gas limit to - // highest, which means the caller lacks funds to pay for the tx - InvalidTransactionError::BasicOutOfGas(gas_limit).into() - } - return_revert!() => { - // reverted again after bumping the limit - InvalidTransactionError::Revert(Some(convert_transact_out(&out).0.into())).into() - } - reason => { - warn!(target: "node", "estimation failed due to {:?}", reason); - BlockchainError::EvmError(reason) - } - } -} - /// Determines the minimum gas needed for a transaction depending on the transaction kind. #[inline] fn determine_base_gas_by_kind(request: &TransactionRequest) -> U256 { @@ -2698,3 +2591,57 @@ fn determine_base_gas_by_kind(request: &TransactionRequest) -> U256 { _ => MIN_CREATE_GAS, } } + +/// Keeps result of a call to revm EVM used for gas estimation +enum GasEstimationCallResult { + Success(u64), + OutOfGas, + Revert(Option), + EvmError(InstructionResult), +} + +/// Converts the result of a call to revm EVM into a [GasEstimationCallRes]. +impl TryFrom, u64, State)>> for GasEstimationCallResult { + type Error = BlockchainError; + + fn try_from(res: Result<(InstructionResult, Option, u64, State)>) -> Result { + match res { + // Exceptional case: init used too much gas, treated as out of gas error + Err(BlockchainError::InvalidTransaction(InvalidTransactionError::GasTooHigh(_))) => { + Ok(Self::OutOfGas) + } + Err(err) => Err(err), + Ok((exit, output, gas, _)) => match exit { + return_ok!() | InstructionResult::CallOrCreate => Ok(Self::Success(gas)), + + InstructionResult::Revert => Ok(Self::Revert(output.map(|o| o.into_data()))), + + InstructionResult::OutOfGas | + InstructionResult::MemoryOOG | + InstructionResult::MemoryLimitOOG | + InstructionResult::PrecompileOOG | + InstructionResult::InvalidOperandOOG => Ok(Self::OutOfGas), + + InstructionResult::OpcodeNotFound | + InstructionResult::CallNotAllowedInsideStatic | + InstructionResult::StateChangeDuringStaticCall | + InstructionResult::InvalidFEOpcode | + InstructionResult::InvalidJump | + InstructionResult::NotActivated | + InstructionResult::StackUnderflow | + InstructionResult::StackOverflow | + InstructionResult::OutOfOffset | + InstructionResult::CreateCollision | + InstructionResult::OverflowPayment | + InstructionResult::PrecompileError | + InstructionResult::NonceOverflow | + InstructionResult::CreateContractSizeLimit | + InstructionResult::CreateContractStartingWithEF | + InstructionResult::CreateInitCodeSizeLimit | + InstructionResult::FatalExternalError | + InstructionResult::OutOfFunds | + InstructionResult::CallTooDeep => Ok(Self::EvmError(exit)), + }, + } + } +} From 452956fe491c5ba10264cf78801ab24481face34 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 29 Mar 2024 17:34:24 +0400 Subject: [PATCH 0802/1963] fix: coverage for libraries (#7510) * fix: coverage for internal libraries * optimize * optimize * doc * rm tests * clippy * clippy + fmt * clean up * for loop * review fixes --- crates/evm/coverage/src/analysis.rs | 205 ++++------------------------ crates/evm/coverage/src/anchors.rs | 17 ++- crates/forge/bin/cmd/coverage.rs | 18 ++- 3 files changed, 56 insertions(+), 184 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 1926d2b4ed202..a136f2d79cd20 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -3,7 +3,7 @@ use foundry_common::TestFunctionExt; use foundry_compilers::artifacts::ast::{self, Ast, Node, NodeType}; use rustc_hash::FxHashMap; use semver::Version; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; /// A visitor that walks the AST of a single contract and finds coverage items. #[derive(Clone, Debug)] @@ -23,36 +23,14 @@ pub struct ContractVisitor<'a> { /// Coverage items pub items: Vec, - - /// Node IDs of this contract's base contracts, as well as IDs for referenced contracts such as - /// libraries - pub base_contract_node_ids: HashSet, } impl<'a> ContractVisitor<'a> { pub fn new(source_id: usize, source: &'a str, contract_name: String) -> Self { - Self { - source_id, - source, - contract_name, - branch_id: 0, - last_line: 0, - items: Vec::new(), - base_contract_node_ids: HashSet::new(), - } + Self { source_id, source, contract_name, branch_id: 0, last_line: 0, items: Vec::new() } } pub fn visit(mut self, contract_ast: Node) -> eyre::Result { - let linearized_base_contracts: Vec = - contract_ast.attribute("linearizedBaseContracts").ok_or_else(|| { - eyre::eyre!( - "The contract's AST node is missing a list of linearized base contracts" - ) - })?; - - // We skip the first ID because that's the ID of the contract itself - self.base_contract_node_ids.extend(&linearized_base_contracts[1..]); - // Find all functions and walk their AST for node in contract_ast.nodes { if node.node_type == NodeType::FunctionDefinition { @@ -318,25 +296,13 @@ impl<'a> ContractVisitor<'a> { }); let expr: Option = node.attribute("expression"); - match expr.as_ref().map(|expr| &expr.node_type) { + if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { // Might be a require/assert call - Some(NodeType::Identifier) => { - let name: Option = expr.and_then(|expr| expr.attribute("name")); - if let Some("assert" | "require") = name.as_deref() { - self.push_branches(&node.src, self.branch_id); - self.branch_id += 1; - } - } - // Might be a call to a library - Some(NodeType::MemberAccess) => { - let referenced_declaration_id = expr - .and_then(|expr| expr.attribute("expression")) - .and_then(|subexpr: Node| subexpr.attribute("referencedDeclaration")); - if let Some(id) = referenced_declaration_id { - self.base_contract_node_ids.insert(id); - } + let name: Option = expr.and_then(|expr| expr.attribute("name")); + if let Some("assert" | "require") = name.as_deref() { + self.push_branches(&node.src, self.branch_id); + self.branch_id += 1; } - _ => (), } Ok(()) @@ -435,9 +401,6 @@ impl<'a> ContractVisitor<'a> { pub struct SourceAnalysis { /// A collection of coverage items. pub items: Vec, - /// A mapping of contract IDs to item IDs relevant to the contract (including items in base - /// contracts). - pub contract_items: HashMap>, } /// Analyzes a set of sources to find coverage items. @@ -445,16 +408,10 @@ pub struct SourceAnalysis { pub struct SourceAnalyzer { /// A map of source IDs to their source code sources: FxHashMap, - /// A map of AST node IDs of contracts to their contract IDs. - contract_ids: FxHashMap, /// A map of contract IDs to their AST nodes. contracts: HashMap, /// A collection of coverage items. items: Vec, - /// A map of contract IDs to item IDs. - contract_items: HashMap>, - /// A map of contracts to their base contracts - contract_bases: HashMap>, } impl SourceAnalyzer { @@ -476,8 +433,6 @@ impl SourceAnalyzer { continue } - let node_id = - child.id.ok_or_else(|| eyre::eyre!("The contract's AST node has no ID"))?; let contract_id = ContractId { version: version.clone(), source_id, @@ -485,7 +440,6 @@ impl SourceAnalyzer { .attribute("name") .ok_or_else(|| eyre::eyre!("Contract has no name"))?, }; - analyzer.contract_ids.insert(node_id, contract_id.clone()); analyzer.contracts.insert(contract_id, child); } } @@ -497,11 +451,7 @@ impl SourceAnalyzer { /// /// Coverage items are found by: /// - Walking the AST of each contract (except interfaces) - /// - Recording the items and base contracts of each contract - /// - /// Finally, the item IDs of each contract and its base contracts are flattened, and the return - /// value represents all coverage items in the project, along with a mapping of contract IDs to - /// item IDs. + /// - Recording the items of each contract /// /// Each coverage item contains relevant information to find opcodes corresponding to them: the /// source ID the item is in, the source code range of the item, and the contract name the item @@ -511,127 +461,32 @@ impl SourceAnalyzer { /// two different solc versions will produce overlapping source IDs if the compiler version is /// not taken into account. pub fn analyze(mut self) -> eyre::Result { - // Analyze the contracts - self.analyze_contracts()?; - - // Flatten the data - let mut flattened: HashMap> = HashMap::new(); - for contract_id in self.contract_items.keys() { - let mut item_ids: Vec = Vec::new(); - - // - // for a specific contract (id == contract_id): - // - // self.contract_bases.get(contract_id) includes the following contracts: - // 1. all the ancestors of this contract (including parent, grandparent, ... - // contracts) - // 2. the libraries **directly** used by this contract - // - // The missing contracts are: - // 1. libraries used in ancestors of this contracts - // 2. libraries used in libraries (i.e libs indirectly used by this contract) - // - // We want to find out all the above contracts and libraries related to this contract. - - for contract_or_lib in { - // A set of contracts and libraries related to this contract (will include "this" - // contract itself) - let mut contracts_libraries: HashSet<&ContractId> = HashSet::new(); - - // we use a stack for depth-first search. - let mut stack: Vec<&ContractId> = Vec::new(); - - // push "this" contract onto the stack - stack.push(contract_id); - - while let Some(contract_or_lib) = stack.pop() { - // whenever a contract_or_lib is removed from the stack, it is added to the set - contracts_libraries.insert(contract_or_lib); - - // push all ancestors of contract_or_lib and libraries used by contract_or_lib - // onto the stack - if let Some(bases) = self.contract_bases.get(contract_or_lib) { - stack.extend( - bases.iter().filter(|base| !contracts_libraries.contains(base)), - ); - } - } - - contracts_libraries - } { - // get items of each contract or library - if let Some(items) = self.contract_items.get(contract_or_lib) { - item_ids.extend(items.iter()); - } - } - - // If there are no items for this contract, then it was most likely filtered - if !item_ids.is_empty() { - flattened.insert(contract_id.clone(), item_ids); - } - } - - Ok(SourceAnalysis { items: self.items.clone(), contract_items: flattened }) - } - - fn analyze_contracts(&mut self) -> eyre::Result<()> { - for contract_id in self.contracts.keys() { - // Find this contract's coverage items if we haven't already - if !self.contract_items.contains_key(contract_id) { - let ContractVisitor { items, base_contract_node_ids, .. } = ContractVisitor::new( - contract_id.source_id, - self.sources.get(&contract_id.source_id).unwrap_or_else(|| { - panic!( - "We should have the source code for source ID {}", - contract_id.source_id - ) - }), - contract_id.contract_name.clone(), - ) - .visit( - self.contracts - .get(contract_id) - .unwrap_or_else(|| { - panic!("We should have the AST of contract: {contract_id:?}") - }) - .clone(), - )?; - - let is_test = items.iter().any(|item| { - if let CoverageItemKind::Function { name } = &item.kind { - name.is_test() - } else { - false - } - }); - - // Record this contract's base contracts - // We don't do this for test contracts because we don't care about them - if !is_test { - self.contract_bases.insert( - contract_id.clone(), - base_contract_node_ids - .iter() - .filter_map(|base_contract_node_id| { - self.contract_ids.get(base_contract_node_id).cloned() - }) - .collect(), - ); - } - - // For tests and contracts with no items we still record an empty Vec so we don't - // end up here again - if items.is_empty() || is_test { - self.contract_items.insert(contract_id.clone(), Vec::new()); + for (contract_id, ast) in self.contracts { + let ContractVisitor { items, .. } = ContractVisitor::new( + contract_id.source_id, + self.sources.get(&contract_id.source_id).ok_or_else(|| { + eyre::eyre!( + "We should have the source code for source ID {}", + contract_id.source_id + ) + })?, + contract_id.contract_name.clone(), + ) + .visit(ast)?; + + let is_test = items.iter().any(|item| { + if let CoverageItemKind::Function { name } = &item.kind { + name.is_test() } else { - let item_ids: Vec = - (self.items.len()..self.items.len() + items.len()).collect(); - self.items.extend(items); - self.contract_items.insert(contract_id.clone(), item_ids.clone()); + false } + }); + + if !is_test { + self.items.extend(items); } } - Ok(()) + Ok(SourceAnalysis { items: self.items }) } } diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index 237d941d1a3d0..d45fdae57dca3 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -1,10 +1,12 @@ +use std::collections::HashMap; + use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; use alloy_primitives::Bytes; use foundry_compilers::sourcemap::{SourceElement, SourceMap}; use foundry_evm_core::utils::IcPcMap; use revm::{ interpreter::opcode::{self, spec_opcode_gas}, - primitives::SpecId, + primitives::{HashSet, SpecId}, }; /// Attempts to find anchors for the given items using the given source map and bytecode. @@ -12,13 +14,20 @@ pub fn find_anchors( bytecode: &Bytes, source_map: &SourceMap, ic_pc_map: &IcPcMap, - item_ids: &[usize], items: &[CoverageItem], + items_by_source_id: &HashMap>, ) -> Vec { - item_ids + // Prepare coverage items from all sources referenced in the source map + let potential_item_ids = source_map .iter() + .filter_map(|element| items_by_source_id.get(&(element.index? as usize))) + .flatten() + .collect::>(); + + potential_item_ids + .into_iter() .filter_map(|item_id| { - let item = items.get(*item_id)?; + let item = &items[*item_id]; match item.kind { CoverageItemKind::Branch { path_id, .. } => { diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index e140b8436aaf5..c59a54ade72f4 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -257,19 +257,27 @@ impl CoverageArgs { })?, )? .analyze()?; - let anchors: HashMap> = source_analysis - .contract_items + + // Build helper mapping used by `find_anchors` + let mut items_by_source_id: HashMap<_, Vec<_>> = + HashMap::with_capacity(source_analysis.items.len()); + + for (item_id, item) in source_analysis.items.iter().enumerate() { + items_by_source_id.entry(item.loc.source_id).or_default().push(item_id); + } + + let anchors: HashMap> = source_maps .iter() - .filter_map(|(contract_id, item_ids)| { + .filter_map(|(contract_id, (_, deployed_source_map))| { // TODO: Creation source map/bytecode as well Some(( contract_id.clone(), find_anchors( &bytecodes.get(contract_id)?.1, - &source_maps.get(contract_id)?.1, + deployed_source_map, &ic_pc_maps.get(contract_id)?.1, - item_ids, &source_analysis.items, + &items_by_source_id, ), )) }) From d1ab09d080db9341eded80231e001ad191b0b706 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Fri, 29 Mar 2024 16:48:02 +0100 Subject: [PATCH 0803/1963] chore: upgrade nix deps & migrate to stable (#7517) --- flake.lock | 24 ++++++++++++------------ flake.nix | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/flake.lock b/flake.lock index a0330581343f0..9ad80af8be7a5 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1700538105, - "narHash": "sha256-uZhOCmwv8VupEmPZm3erbr9XXmyg7K67Ul3+Rx2XMe0=", + "lastModified": 1711655175, + "narHash": "sha256-1xiaYhC3ul4y+i3eicYxeERk8ZkrNjLkrFSb/UW36Zw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "51a01a7e5515b469886c120e38db325c96694c2f", + "rev": "64c81edb4b97a51c5bbc54c191763ac71a6517ee", "type": "github" }, "original": { @@ -52,11 +52,11 @@ ] }, "locked": { - "lastModified": 1700705722, - "narHash": "sha256-cFfTFToYTeRQtdNqo53+E+G5RxPiTbWusGq+MpZSpbA=", + "lastModified": 1711678273, + "narHash": "sha256-7lIB0hMRnfzx/9oSIwTnwXmVnbvVGRoadOCW+1HI5zY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "67998ae1cabcf683cb115c5ab01ae4ff067e3d60", + "rev": "42a168449605950935f15ea546f6f770e5f7f629", "type": "github" }, "original": { @@ -75,11 +75,11 @@ ] }, "locked": { - "lastModified": 1700417764, - "narHash": "sha256-ssdwqKWkYUd/Nr6P9veR4D/PrtlwGJkPoUQoEgVJVpo=", + "lastModified": 1711538161, + "narHash": "sha256-rETVdEIQ2PyEcNgzXXFSiYAYl0koCeGDIWp9XYBTxoQ=", "owner": "hellwolf", "repo": "solc.nix", - "rev": "80d2e38e98e589872b0dc3770f838c4be847305e", + "rev": "a995838545a7383a0b37776e969743b1346d5479", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5abae8e648bea..46ddb920c2064 100644 --- a/flake.nix +++ b/flake.nix @@ -27,9 +27,9 @@ overlays = [ rust-overlay.overlays.default solc.overlay ]; }; lib = pkgs.lib; - toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + toolchain = pkgs.rust-bin.stable.latest.default.override { extensions = [ "rustfmt" "clippy" "rust-src" ]; - }); + }; in { devShells.default = pkgs.mkShell { From a16714ed40f733013d7a80f4f969564175c3318e Mon Sep 17 00:00:00 2001 From: Enrique Date: Sat, 30 Mar 2024 06:49:54 -0400 Subject: [PATCH 0804/1963] chore: re-add evalir to codeowners (#7521) --- .github/CODEOWNERS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b452279e757e2..4eea49b388b79 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,7 +1,7 @@ -* @danipopes @mattsse +* @danipopes @evalir @mattsse -crates/anvil/ @danipopes @mattsse -crates/cheatcodes/ @danipopes @mattsse @klkvr +crates/anvil/ @danipopes @mattsse @evalir +crates/cheatcodes/ @danipopes @mattsse @klkvr @evalir crates/evm/coverage/ @onbjerg crates/fmt/ @rkrasiuk crates/linking/ @klkvr From d94e3c631e2da7756af46c70f8f58b75563b7013 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 30 Mar 2024 23:33:00 +0400 Subject: [PATCH 0805/1963] feat: allow supplying function name via `forge script --sig` (#7518) * feat: allow supplying fn name via forge script --sig * fmt * clippy * add test --- crates/forge/tests/cli/script.rs | 18 +++++++++++ crates/script/src/lib.rs | 52 ++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index ff03a6b57e887..a2d4dc4fb625f 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1179,3 +1179,21 @@ forgetest_async!(can_sign_with_script_wallet_multiple, |prj, cmd| { .await .simulate(ScriptOutcome::OkRun); }); + +forgetest_async!(fails_with_function_name_and_overloads, |prj, cmd| { + let script = prj + .add_script( + "Sctipt.s.sol", + r#" +contract Script { + function run() external {} + + function run(address,uint256) external {} +} + "#, + ) + .unwrap(); + + cmd.arg("script").args([&script.to_string_lossy(), "--sig", "run"]); + assert!(cmd.stderr_lossy().contains("Multiple functions with the same name")); +}); diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 010b5bbe970d1..fd4ba66f6c0eb 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -12,7 +12,7 @@ use build::PreprocessedState; use clap::{Parser, ValueHint}; use dialoguer::Confirm; use ethers_signers::Signer; -use eyre::{ContextCompat, Result, WrapErr}; +use eyre::{ContextCompat, Result}; use forge_verify::RetryArgs; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ @@ -311,30 +311,38 @@ impl ScriptArgs { /// /// Note: We assume that the `sig` is already stripped of its prefix, See [`ScriptArgs`] fn get_method_and_calldata(&self, abi: &JsonAbi) -> Result<(Function, Bytes)> { - let (func, data) = if let Ok(func) = get_func(&self.sig) { - ( - abi.functions().find(|&abi_func| abi_func.selector() == func.selector()).wrap_err( - format!("Function `{}` is not implemented in your script.", self.sig), - )?, - encode_function_args(&func, &self.args)?.into(), - ) - } else { - let decoded = hex::decode(&self.sig).wrap_err("Invalid hex calldata")?; + if let Ok(decoded) = hex::decode(&self.sig) { let selector = &decoded[..SELECTOR_LEN]; - ( - abi.functions().find(|&func| selector == &func.selector()[..]).ok_or_else( - || { - eyre::eyre!( - "Function selector `{}` not found in the ABI", - hex::encode(selector) - ) - }, - )?, - decoded.into(), - ) + let func = + abi.functions().find(|func| selector == &func.selector()[..]).ok_or_else(|| { + eyre::eyre!( + "Function selector `{}` not found in the ABI", + hex::encode(selector) + ) + })?; + return Ok((func.clone(), decoded.into())); + } + + let func = if self.sig.contains('(') { + let func = get_func(&self.sig)?; + abi.functions() + .find(|&abi_func| abi_func.selector() == func.selector()) + .wrap_err(format!("Function `{}` is not implemented in your script.", self.sig))? + } else { + let matching_functions = + abi.functions().filter(|func| func.name == self.sig).collect::>(); + match matching_functions.len() { + 0 => eyre::bail!("Function `{}` not found in the ABI", self.sig), + 1 => matching_functions[0], + 2.. => eyre::bail!( + "Multiple functions with the same name `{}` found in the ABI", + self.sig + ), + } }; + let data = encode_function_args(func, &self.args)?; - Ok((func.clone(), data)) + Ok((func.clone(), data.into())) } /// Checks if the transaction is a deployment with either a size above the `CONTRACT_MAX_SIZE` From bd56eef59fff9d9597ab0aff4bf4fd6f0a9e399e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:01:21 +0300 Subject: [PATCH 0806/1963] fix(bench): avoid panic if test benchmark execution not success (#7535) fix(bench): avoid panic if execution not success --- crates/forge/benches/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/benches/test.rs b/crates/forge/benches/test.rs index 7650077b116ac..7646a3c214a33 100644 --- a/crates/forge/benches/test.rs +++ b/crates/forge/benches/test.rs @@ -15,7 +15,7 @@ fn forge_test_benchmark(c: &mut Criterion) { let mut cmd = prj.forge_command(); cmd.arg("test"); b.iter(|| { - cmd.ensure_execute_success().unwrap(); + cmd.print_output(); }); }); } From 0578aaecc478411113a6434fc432c765306d7e00 Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:12:36 +0530 Subject: [PATCH 0807/1963] feat: print IPC path (#7526) * feat: print ipc path * moved if check * moved println --- crates/anvil/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 23a328d7a8b9f..afc600a3b34de 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -237,6 +237,9 @@ impl NodeHandle { pub(crate) fn print(&self, fork: Option<&ClientFork>) { self.config.print(fork); if !self.config.silent { + if let Some(ipc_path) = self.ipc_path() { + println!("IPC path: {}", ipc_path); + } println!( "Listening on {}", self.addresses @@ -244,7 +247,7 @@ impl NodeHandle { .map(|addr| { addr.to_string() }) .collect::>() .join(", ") - ) + ); } } From f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 2 Apr 2024 01:51:24 +0400 Subject: [PATCH 0808/1963] fix: coverage bug (#7532) fix --- crates/forge/bin/cmd/coverage.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index c59a54ade72f4..9b6d19e74bee7 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -268,6 +268,7 @@ impl CoverageArgs { let anchors: HashMap> = source_maps .iter() + .filter(|(contract_id, _)| contract_id.version == version) .filter_map(|(contract_id, (_, deployed_source_map))| { // TODO: Creation source map/bytecode as well Some(( From 85cb9fbcd0cf1b7a4d0a831048ba0dc4800da30e Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 2 Apr 2024 21:11:20 +0400 Subject: [PATCH 0809/1963] fix: debugger doesn't work with external libraries (#7504) * add TestContract * use TestContract * wip * fix * clippy + fmt * smaller diff --- Cargo.lock | 1 + crates/common/Cargo.toml | 1 + crates/common/src/compile.rs | 14 +++---- crates/forge/bin/cmd/test/mod.rs | 10 ++++- crates/forge/src/multi_runner.rs | 49 ++++++++++++++-------- crates/forge/src/result.rs | 6 ++- crates/forge/src/runner.rs | 41 ++++++++---------- crates/linking/src/lib.rs | 72 ++++++++++++++++++-------------- crates/script/src/build.rs | 46 +++++++++++++------- crates/script/src/execute.rs | 2 +- 10 files changed, 144 insertions(+), 98 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05a4e79a1617d..54f207db05bb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3271,6 +3271,7 @@ dependencies = [ "foundry-block-explorers", "foundry-compilers", "foundry-config", + "foundry-linking", "foundry-macros", "glob", "globset", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index cf6e53040b38e..fb161da6127ed 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -13,6 +13,7 @@ repository.workspace = true foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-compilers.workspace = true foundry-config.workspace = true +foundry-linking.workspace = true ethers-core.workspace = true ethers-middleware.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 8272dece32ac3..af91a0176be60 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -5,12 +5,13 @@ use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Table}; use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ - artifacts::{BytecodeObject, CompactContractBytecode, ContractBytecodeSome}, + artifacts::{BytecodeObject, ContractBytecodeSome, Libraries}, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, Artifact, ArtifactId, FileFilter, Graph, Project, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig, }; +use foundry_linking::Linker; use rustc_hash::FxHashMap; use std::{ collections::{BTreeMap, HashMap}, @@ -296,7 +297,10 @@ impl ContractSources { pub fn from_project_output( output: &ProjectCompileOutput, root: &Path, + libraries: &Libraries, ) -> Result { + let linker = Linker::new(root, output.artifact_ids().collect()); + let mut sources = ContractSources::default(); for (id, artifact) in output.artifact_ids() { if let Some(file_id) = artifact.id { @@ -304,12 +308,8 @@ impl ContractSources { let source_code = std::fs::read_to_string(abs_path).wrap_err_with(|| { format!("failed to read artifact source file for `{}`", id.identifier()) })?; - let compact = CompactContractBytecode { - abi: artifact.abi.clone(), - bytecode: artifact.bytecode.clone(), - deployed_bytecode: artifact.deployed_bytecode.clone(), - }; - let contract = compact_to_contract(compact)?; + let linked = linker.link(&id, libraries)?; + let contract = compact_to_contract(linked)?; sources.insert(&id, file_id, source_code, contract); } else { warn!(id = id.identifier(), "source not found"); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 13130d4642f7b..78000de618711 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -224,14 +224,20 @@ impl TestArgs { let outcome = self.run_tests(runner, config, verbosity, &filter).await?; if should_debug { - // There is only one test. - let Some((_, test_result)) = outcome.tests().next() else { + // Get first non-empty suite result. We will have only one such entry + let Some((suite_result, test_result)) = outcome + .results + .iter() + .find(|(_, r)| !r.test_results.is_empty()) + .map(|(_, r)| (r, r.test_results.values().next().unwrap())) + else { return Err(eyre::eyre!("no tests were executed")); }; let sources = ContractSources::from_project_output( output_clone.as_ref().unwrap(), project.root(), + &suite_result.libraries, )?; // Run the debugger. diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 7712a7ee6a36a..d545d773d8201 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -5,7 +5,9 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput}; +use foundry_compilers::{ + artifacts::Libraries, contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput, +}; use foundry_evm::{ backend::Backend, decode::RevertDecoder, @@ -26,7 +28,15 @@ use std::{ time::Instant, }; -pub type DeployableContracts = BTreeMap)>; +#[derive(Debug, Clone)] +pub struct TestContract { + pub abi: JsonAbi, + pub bytecode: Bytes, + pub libs_to_deploy: Vec, + pub libraries: Libraries, +} + +pub type DeployableContracts = BTreeMap; /// A multi contract runner receives a set of contracts deployed in an EVM instance and proceeds /// to run all test functions in these contracts. @@ -67,8 +77,10 @@ impl MultiContractRunner { pub fn matching_contracts<'a>( &'a self, filter: &'a dyn TestFilter, - ) -> impl Iterator))> { - self.contracts.iter().filter(|&(id, (abi, _, _))| matches_contract(id, abi, filter)) + ) -> impl Iterator { + self.contracts + .iter() + .filter(|&(id, TestContract { abi, .. })| matches_contract(id, abi, filter)) } /// Returns an iterator over all test functions that match the filter. @@ -77,7 +89,7 @@ impl MultiContractRunner { filter: &'a dyn TestFilter, ) -> impl Iterator { self.matching_contracts(filter) - .flat_map(|(_, (abi, _, _))| abi.functions()) + .flat_map(|(_, TestContract { abi, .. })| abi.functions()) .filter(|func| is_matching_test(func, filter)) } @@ -89,14 +101,14 @@ impl MultiContractRunner { self.contracts .iter() .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) - .flat_map(|(_, (abi, _, _))| abi.functions()) + .flat_map(|(_, TestContract { abi, .. })| abi.functions()) .filter(|func| func.is_test() || func.is_invariant_test()) } /// Returns all matching tests grouped by contract grouped by file (file -> (contract -> tests)) pub fn list(&self, filter: &dyn TestFilter) -> BTreeMap>> { self.matching_contracts(filter) - .map(|(id, (abi, _, _))| { + .map(|(id, TestContract { abi, .. })| { let source = id.source.as_path().display().to_string(); let name = id.name.clone(); let tests = abi @@ -169,22 +181,19 @@ impl MultiContractRunner { find_time, ); - contracts.par_iter().for_each_with(tx, |tx, &(id, (abi, deploy_code, libs))| { + contracts.par_iter().for_each_with(tx, |tx, &(id, contract)| { let identifier = id.identifier(); let executor = executor.clone(); - let result = self.run_tests(&identifier, abi, executor, deploy_code, libs, filter); + let result = self.run_tests(&identifier, contract, executor, filter); let _ = tx.send((identifier, result)); }) } - #[allow(clippy::too_many_arguments)] fn run_tests( &self, name: &str, - contract: &JsonAbi, + contract: &TestContract, executor: Executor, - deploy_code: &Bytes, - libs: &[Bytes], filter: &dyn TestFilter, ) -> SuiteResult { let mut span_name = name; @@ -199,11 +208,9 @@ impl MultiContractRunner { name, executor, contract, - deploy_code, self.evm_opts.initial_balance, self.sender, &self.revert_decoder, - libs, self.debug, ); let r = runner.run_tests(filter, &self.test_options, Some(&self.known_contracts)); @@ -307,14 +314,17 @@ impl MultiContractRunnerBuilder { .map(|(i, _)| (i.identifier(), root.join(&i.source).to_string_lossy().into())) .collect::>(); - let linker = Linker::new(root, contracts); + let linker = Linker::new( + root, + contracts.iter().map(|(id, artifact)| (id.clone(), artifact)).collect(), + ); // Create a mapping of name => (abi, deployment code, Vec) let mut deployable_contracts = DeployableContracts::default(); let mut known_contracts = ContractsByArtifact::default(); - for (id, contract) in &linker.contracts.0 { + for (id, contract) in contracts.iter() { let Some(abi) = contract.abi.as_ref() else { continue; }; @@ -341,7 +351,10 @@ impl MultiContractRunnerBuilder { if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && abi.functions().any(|func| func.name.is_test() || func.name.is_invariant_test()) { - deployable_contracts.insert(id.clone(), (abi.clone(), bytecode, libs_to_deploy)); + deployable_contracts.insert( + id.clone(), + TestContract { abi: abi.clone(), bytecode, libs_to_deploy, libraries }, + ); } if let Some(bytes) = linked_contract.get_deployed_bytecode_bytes() { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index ad1173381c214..a50e59b9515ab 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -2,6 +2,7 @@ use alloy_primitives::{Address, Log}; use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; +use foundry_compilers::artifacts::Libraries; use foundry_evm::{ coverage::HitMaps, debug::DebugArena, @@ -193,6 +194,8 @@ pub struct SuiteResult { pub test_results: BTreeMap, /// Generated warnings. pub warnings: Vec, + /// Libraries used to link test contract. + pub libraries: Libraries, } impl SuiteResult { @@ -200,8 +203,9 @@ impl SuiteResult { duration: Duration, test_results: BTreeMap, warnings: Vec, + libraries: Libraries, ) -> Self { - Self { duration, test_results, warnings } + Self { duration, test_results, warnings, libraries } } /// Returns an iterator over all individual succeeding tests and their names. diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 3c9eee1ddaf50..7f3258e359fa0 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -1,12 +1,12 @@ //! The Forge test runner. use crate::{ - multi_runner::is_matching_test, + multi_runner::{is_matching_test, TestContract}, result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, }; -use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_json_abi::Function; +use alloy_primitives::{Address, U256}; use eyre::Result; use foundry_common::{ contracts::{ContractsByAddress, ContractsByArtifact}, @@ -37,14 +37,10 @@ use std::{ #[derive(Clone, Debug)] pub struct ContractRunner<'a> { pub name: &'a str, + /// The data of the contract being ran. + pub contract: &'a TestContract, /// The executor used by the runner. pub executor: Executor, - /// Library contracts to be deployed before the test contract - pub predeploy_libs: &'a [Bytes], - /// The deployed contract's code - pub code: &'a Bytes, - /// The test contract's ABI - pub contract: &'a JsonAbi, /// Revert decoder. Contains all known errors. pub revert_decoder: &'a RevertDecoder, /// The initial balance of the test contract @@ -56,27 +52,22 @@ pub struct ContractRunner<'a> { } impl<'a> ContractRunner<'a> { - #[allow(clippy::too_many_arguments)] pub fn new( name: &'a str, executor: Executor, - contract: &'a JsonAbi, - code: &'a Bytes, + contract: &'a TestContract, initial_balance: U256, sender: Option
, revert_decoder: &'a RevertDecoder, - predeploy_libs: &'a [Bytes], debug: bool, ) -> Self { Self { name, executor, contract, - code, initial_balance, sender: sender.unwrap_or_default(), revert_decoder, - predeploy_libs, debug, } } @@ -104,8 +95,8 @@ impl<'a> ContractRunner<'a> { // Deploy libraries let mut logs = Vec::new(); - let mut traces = Vec::with_capacity(self.predeploy_libs.len()); - for code in self.predeploy_libs.iter() { + let mut traces = Vec::with_capacity(self.contract.libs_to_deploy.len()); + for code in self.contract.libs_to_deploy.iter() { match self.executor.deploy( self.sender, code.clone(), @@ -131,7 +122,7 @@ impl<'a> ContractRunner<'a> { // Deploy the test contract match self.executor.deploy( self.sender, - self.code.clone(), + self.contract.bytecode.clone(), U256::ZERO, Some(self.revert_decoder), ) { @@ -194,7 +185,7 @@ impl<'a> ContractRunner<'a> { let mut warnings = Vec::new(); let setup_fns: Vec<_> = - self.contract.functions().filter(|func| func.name.is_setup()).collect(); + self.contract.abi.functions().filter(|func| func.name.is_setup()).collect(); let needs_setup = setup_fns.len() == 1 && setup_fns[0].name == "setUp"; @@ -215,10 +206,11 @@ impl<'a> ContractRunner<'a> { [("setUp()".to_string(), TestResult::fail("multiple setUp functions".to_string()))] .into(), warnings, + self.contract.libraries.clone(), ) } - let has_invariants = self.contract.functions().any(|func| func.is_invariant_test()); + let has_invariants = self.contract.abi.functions().any(|func| func.is_invariant_test()); // Invariant testing requires tracing to figure out what contracts were created. let tmp_tracing = self.executor.inspector.tracer.is_none() && has_invariants && needs_setup; @@ -251,6 +243,7 @@ impl<'a> ContractRunner<'a> { )] .into(), warnings, + self.contract.libraries.clone(), ) } @@ -259,6 +252,7 @@ impl<'a> ContractRunner<'a> { let find_timer = Instant::now(); let functions = self .contract + .abi .functions() .filter(|func| is_matching_test(func, filter)) .collect::>(); @@ -266,7 +260,7 @@ impl<'a> ContractRunner<'a> { debug!( "Found {} test functions out of {} in {:?}", functions.len(), - self.contract.functions().count(), + self.contract.abi.functions().count(), find_time, ); @@ -305,7 +299,8 @@ impl<'a> ContractRunner<'a> { .collect::>(); let duration = start.elapsed(); - let suite_result = SuiteResult::new(duration, test_results, warnings); + let suite_result = + SuiteResult::new(duration, test_results, warnings, self.contract.libraries.clone()); info!( duration=?suite_result.duration, "done. {}/{} successful", @@ -494,7 +489,7 @@ impl<'a> ContractRunner<'a> { ); let invariant_contract = - InvariantContract { address, invariant_function: func, abi: self.contract }; + InvariantContract { address, invariant_function: func, abi: &self.contract.abi }; let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs, gas_report_traces } = match evm.invariant_fuzz(invariant_contract.clone()) { diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index 110a6d8f28b5c..869a18e64b34d 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -2,13 +2,13 @@ use alloy_primitives::{Address, Bytes}; use foundry_compilers::{ - artifacts::{CompactContractBytecode, Libraries}, + artifacts::{CompactContractBytecode, CompactContractBytecodeCow, Libraries}, contracts::ArtifactContracts, Artifact, ArtifactId, }; use semver::Version; use std::{ - collections::BTreeSet, + collections::{BTreeMap, BTreeSet}, path::{Path, PathBuf}, str::FromStr, }; @@ -24,11 +24,11 @@ pub enum LinkerError { InvalidAddress(
::Err), } -pub struct Linker { +pub struct Linker<'a> { /// Root of the project, used to determine whether artifact/library path can be stripped. pub root: PathBuf, /// Compilation artifacts. - pub contracts: ArtifactContracts, + pub contracts: ArtifactContracts>, } /// Output of the `link_with_nonce_or_address` @@ -41,8 +41,11 @@ pub struct LinkOutput { pub libs_to_deploy: Vec, } -impl Linker { - pub fn new(root: impl Into, contracts: ArtifactContracts) -> Self { +impl<'a> Linker<'a> { + pub fn new( + root: impl Into, + contracts: ArtifactContracts>, + ) -> Linker<'a> { Linker { root: root.into(), contracts } } @@ -62,7 +65,7 @@ impl Linker { /// library path in the form of "./path/to/Lib.sol:Lib" /// /// Optionally accepts solc version, and if present, only compares artifacts with given version. - fn find_artifact_id_by_library_path<'a>( + fn find_artifact_id_by_library_path( &'a self, file: &str, name: &str, @@ -85,16 +88,23 @@ impl Linker { } /// Performs DFS on the graph of link references, and populates `deps` with all found libraries. - fn collect_dependencies<'a>( + fn collect_dependencies( &'a self, target: &'a ArtifactId, deps: &mut BTreeSet<&'a ArtifactId>, ) -> Result<(), LinkerError> { - let references = self - .contracts - .get(target) - .ok_or(LinkerError::MissingTargetArtifact)? - .all_link_references(); + let contract = self.contracts.get(target).ok_or(LinkerError::MissingTargetArtifact)?; + + let mut references = BTreeMap::new(); + if let Some(bytecode) = &contract.bytecode { + references.extend(bytecode.link_references.clone()); + } + if let Some(deployed_bytecode) = &contract.deployed_bytecode { + if let Some(bytecode) = &deployed_bytecode.bytecode { + references.extend(bytecode.link_references.clone()); + } + } + for (file, libs) in &references { for contract in libs.keys() { let id = self @@ -121,7 +131,7 @@ impl Linker { /// When calling for `target` being an external library itself, you should check that `target` /// does not appear in `libs_to_deploy` to avoid deploying it twice. It may happen in cases /// when there is a dependency cycle including `target`. - pub fn link_with_nonce_or_address<'a>( + pub fn link_with_nonce_or_address( &'a self, libraries: Libraries, sender: Address, @@ -174,16 +184,21 @@ impl Linker { for (name, address) in libs { let address = Address::from_str(address).map_err(LinkerError::InvalidAddress)?; if let Some(bytecode) = contract.bytecode.as_mut() { - bytecode.link(file.to_string_lossy(), name, address); + bytecode.to_mut().link(file.to_string_lossy(), name, address); } if let Some(deployed_bytecode) = - contract.deployed_bytecode.as_mut().and_then(|b| b.bytecode.as_mut()) + contract.deployed_bytecode.as_mut().and_then(|b| b.to_mut().bytecode.as_mut()) { deployed_bytecode.link(file.to_string_lossy(), name, address); } } } - Ok(contract) + + Ok(CompactContractBytecode { + abi: contract.abi.map(|a| a.into_owned()), + bytecode: contract.bytecode.map(|b| b.into_owned()), + deployed_bytecode: contract.deployed_bytecode.map(|b| b.into_owned()), + }) } pub fn get_linked_artifacts( @@ -197,12 +212,12 @@ impl Linker { #[cfg(test)] mod tests { use super::*; - use foundry_compilers::{Project, ProjectPathsConfig}; + use foundry_compilers::{Project, ProjectCompileOutput, ProjectPathsConfig}; use std::collections::HashMap; struct LinkerTest { project: Project, - linker: Linker, + output: ProjectCompileOutput, dependency_assertions: HashMap>, } @@ -220,20 +235,13 @@ mod tests { let project = Project::builder().paths(paths).ephemeral().no_artifacts().build().unwrap(); - let mut contracts = project.compile().unwrap(); + let mut output = project.compile().unwrap(); if strip_prefixes { - contracts = contracts.with_stripped_file_prefixes(project.root()); + output = output.with_stripped_file_prefixes(project.root()); } - let contracts = contracts - .into_artifacts() - .map(|(id, c)| (id, c.into_contract_bytecode())) - .collect::(); - - let linker = Linker::new(project.root(), contracts); - - Self { project, linker, dependency_assertions: HashMap::new() } + Self { project, output, dependency_assertions: HashMap::new() } } fn assert_dependencies( @@ -246,7 +254,8 @@ mod tests { } fn test_with_sender_and_nonce(self, sender: Address, initial_nonce: u64) { - for id in self.linker.contracts.keys() { + let linker = Linker::new(self.project.root(), self.output.artifact_ids().collect()); + for id in linker.contracts.keys() { // If we didn't strip paths, artifacts will have absolute paths. // That's expected and we want to ensure that only `libraries` object has relative // paths, artifacts should be kept as is. @@ -263,8 +272,7 @@ mod tests { continue; } - let LinkOutput { libs_to_deploy, libraries, .. } = self - .linker + let LinkOutput { libs_to_deploy, libraries, .. } = linker .link_with_nonce_or_address(Default::default(), sender, initial_nonce, id) .expect("Linking failed"); diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 41e898d96a72b..b0aba755e8f8c 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -22,22 +22,26 @@ use foundry_compilers::{ cache::SolFilesCache, contracts::ArtifactContracts, info::ContractInfo, - ArtifactId, + ArtifactId, ProjectCompileOutput, }; use foundry_linking::{LinkOutput, Linker}; -use std::{str::FromStr, sync::Arc}; +use std::{path::PathBuf, str::FromStr, sync::Arc}; /// Container for the compiled contracts. pub struct BuildData { + /// Root of the project + pub project_root: PathBuf, /// Linker which can be used to link contracts, owns [ArtifactContracts] map. - pub linker: Linker, + pub output: ProjectCompileOutput, /// Id of target contract artifact. pub target: ArtifactId, - /// Source files of the contracts. Used by debugger. - pub sources: ContractSources, } impl BuildData { + pub fn get_linker(&self) -> Linker { + Linker::new(self.project_root.clone(), self.output.artifact_ids().collect()) + } + /// Links the build data with given libraries, using sender and nonce to compute addresses of /// missing libraries. pub fn link( @@ -46,8 +50,12 @@ impl BuildData { sender: Address, nonce: u64, ) -> Result { - let link_output = - self.linker.link_with_nonce_or_address(known_libraries, sender, nonce, &self.target)?; + let link_output = self.get_linker().link_with_nonce_or_address( + known_libraries, + sender, + nonce, + &self.target, + )?; LinkedBuildData::new(link_output, self) } @@ -55,8 +63,12 @@ impl BuildData { /// Links the build data with the given libraries. Expects supplied libraries set being enough /// to fully link target contract. pub fn link_with_libraries(self, libraries: Libraries) -> Result { - let link_output = - self.linker.link_with_nonce_or_address(libraries, Address::ZERO, 0, &self.target)?; + let link_output = self.get_linker().link_with_nonce_or_address( + libraries, + Address::ZERO, + 0, + &self.target, + )?; if !link_output.libs_to_deploy.is_empty() { eyre::bail!("incomplete libraries set"); @@ -76,12 +88,20 @@ pub struct LinkedBuildData { pub libraries: Libraries, /// Libraries that need to be deployed by sender before script execution. pub predeploy_libraries: Vec, + /// Source files of the contracts. Used by debugger. + pub sources: ContractSources, } impl LinkedBuildData { pub fn new(link_output: LinkOutput, build_data: BuildData) -> Result { + let sources = ContractSources::from_project_output( + &build_data.output, + &build_data.project_root, + &link_output.libraries, + )?; + let highlevel_known_contracts = build_data - .linker + .get_linker() .get_linked_artifacts(&link_output.libraries)? .iter() .filter_map(|(id, contract)| { @@ -97,6 +117,7 @@ impl LinkedBuildData { highlevel_known_contracts, libraries: link_output.libraries, predeploy_libraries: link_output.libs_to_deploy, + sources, }) } @@ -220,16 +241,13 @@ impl PreprocessedState { target_id = Some(id); } - let sources = ContractSources::from_project_output(&output, project.root())?; - let contracts = output.into_artifacts().collect(); let target = target_id.ok_or_eyre("Could not find target contract")?; - let linker = Linker::new(project.root(), contracts); Ok(CompiledState { args, script_config, script_wallets, - build_data: BuildData { linker, target, sources }, + build_data: BuildData { output, target, project_root: project.root().clone() }, }) } } diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 4a3a3485208b9..b2fab7154b25d 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -511,7 +511,7 @@ impl PreSimulationState { let mut debugger = Debugger::builder() .debug_arenas(self.execution_result.debug.as_deref().unwrap_or_default()) .decoder(&self.execution_artifacts.decoder) - .sources(self.build_data.build_data.sources.clone()) + .sources(self.build_data.sources.clone()) .breakpoints(self.execution_result.breakpoints.clone()) .build(); debugger.try_run()?; From dbc48ead1044066a3e12c796fca9dc077f5913fe Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:23:14 -0400 Subject: [PATCH 0810/1963] feat(verify): multichain verification for etherscan (#7537) * feat(verify): multichain verification for etherscan * fix: bump reqwest * fix: ci cargo deny --- Cargo.lock | 531 ++++++++++++++++++++--------- Cargo.toml | 13 +- crates/config/Cargo.toml | 6 +- crates/verify/src/etherscan/mod.rs | 5 +- 4 files changed, 381 insertions(+), 174 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54f207db05bb9..d929efd322ca0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,7 +222,7 @@ dependencies = [ "auto_impl", "futures", "lru", - "reqwest", + "reqwest 0.11.27", "serde", "thiserror", "tokio", @@ -266,7 +266,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -279,7 +279,7 @@ dependencies = [ "alloy-transport-http", "futures", "pin-project", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "tokio", @@ -347,7 +347,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.53", + "syn 2.0.57", "syn-solidity", "tiny-keccak", ] @@ -398,7 +398,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61 dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest", + "reqwest 0.11.27", "serde_json", "tower", "url", @@ -430,7 +430,7 @@ dependencies = [ "alloy-pubsub", "alloy-transport", "futures", - "http", + "http 0.2.12", "serde_json", "tokio", "tokio-tungstenite", @@ -564,7 +564,7 @@ dependencies = [ "foundry-evm", "futures", "hash-db", - "hyper", + "hyper 0.14.28", "itertools 0.12.1", "k256", "memory-db", @@ -633,7 +633,7 @@ dependencies = [ "bytes", "clap", "futures", - "hyper", + "hyper 0.14.28", "parity-tokio-ipc", "parking_lot", "pin-project", @@ -814,7 +814,7 @@ checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", "event-listener 5.2.0", - "event-listener-strategy 0.5.0", + "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", ] @@ -847,7 +847,7 @@ checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -869,7 +869,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -880,13 +880,13 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.78" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -939,14 +939,14 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "axum" @@ -960,9 +960,9 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "itoa", "matchit", "memchr", @@ -992,8 +992,8 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "mime", "rustversion", "tower-layer", @@ -1395,7 +1395,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest", + "reqwest 0.11.27", "revm", "rustyline", "semver 1.0.22", @@ -1415,9 +1415,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1465,9 +1465,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -1509,14 +1509,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.3" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -1919,9 +1919,9 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" dependencies = [ "generic-array", "subtle", @@ -1967,7 +1967,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -1978,7 +1978,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -2002,9 +2002,9 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "pem-rfc7468", @@ -2039,7 +2039,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -2060,7 +2060,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -2070,7 +2070,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -2314,7 +2314,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -2523,10 +2523,10 @@ dependencies = [ "proc-macro2", "quote", "regex", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.53", + "syn 2.0.57", "toml 0.8.12", "walkdir", ] @@ -2544,7 +2544,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -2570,7 +2570,7 @@ dependencies = [ "serde", "serde_json", "strum 0.26.2", - "syn 2.0.53", + "syn 2.0.57", "tempfile", "thiserror", "tiny-keccak", @@ -2585,7 +2585,7 @@ checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" dependencies = [ "chrono", "ethers-core", - "reqwest", + "reqwest 0.11.27", "semver 1.0.22", "serde", "serde_json", @@ -2609,7 +2609,7 @@ dependencies = [ "futures-locks", "futures-util", "instant", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "thiserror", @@ -2637,12 +2637,12 @@ dependencies = [ "futures-timer", "futures-util", "hashers", - "http", + "http 0.2.12", "instant", "jsonwebtoken", "once_cell", "pin-project", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "thiserror", @@ -2758,9 +2758,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ "event-listener 5.2.0", "pin-project-lite", @@ -2797,9 +2797,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fastrlp" @@ -2822,7 +2822,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -2987,7 +2987,7 @@ dependencies = [ "foundry-wallets", "futures", "globset", - "hyper", + "hyper 0.14.28", "indicatif", "itertools 0.12.1", "once_cell", @@ -2999,7 +2999,7 @@ dependencies = [ "proptest", "rayon", "regex", - "reqwest", + "reqwest 0.11.27", "revm-inspectors", "rustc-hash", "semver 1.0.22", @@ -3123,7 +3123,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest", + "reqwest 0.11.27", "semver 1.0.22", "serde", "serde_json", @@ -3143,15 +3143,15 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a056d4aa33a639c0aa1e9e473c25b9b191be30cbea94b31445fac5c272418ae" +checksum = "3e88929768c22f9912694c634db053cfd480c3f7bd7eb39223e29f4fb40b64b7" dependencies = [ "alloy-chains", "alloy-json-abi", "alloy-primitives", "foundry-compilers", - "reqwest", + "reqwest 0.12.2", "semver 1.0.22", "serde", "serde_json", @@ -3278,7 +3278,7 @@ dependencies = [ "once_cell", "pretty_assertions", "rand 0.8.5", - "reqwest", + "reqwest 0.11.27", "rustc-hash", "semver 1.0.22", "serde", @@ -3349,7 +3349,7 @@ dependencies = [ "path-slash", "pretty_assertions", "regex", - "reqwest", + "reqwest 0.12.2", "revm-primitives", "semver 1.0.22", "serde", @@ -3530,7 +3530,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -3707,7 +3707,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -4034,7 +4034,7 @@ dependencies = [ "bstr", "log", "regex-automata 0.4.6", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -4071,7 +4071,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", "indexmap", "slab", "tokio", @@ -4091,9 +4091,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "5.1.0" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab283476b99e66691dee3f1640fea91487a8d81f50fb5ecc75538f8f8879a1e4" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" dependencies = [ "log", "pest", @@ -4245,6 +4245,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -4252,7 +4263,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", "pin-project-lite", ] @@ -4291,8 +4325,8 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -4304,17 +4338,36 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "log", "rustls 0.20.9", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.23.4", ] @@ -4326,13 +4379,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "rustls 0.21.10", "tokio", "tokio-rustls 0.24.1", ] +[[package]] +name = "hyper-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.2.0", + "hyper-util", + "rustls 0.22.3", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.25.0", + "tower-service", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -4340,12 +4410,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.28", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.2.0", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -4609,9 +4699,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" @@ -4733,7 +4823,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", "string_cache", "term", "tiny-keccak", @@ -4773,13 +4863,12 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -4917,9 +5006,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memmap2" @@ -4979,7 +5068,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -5246,7 +5335,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -5350,7 +5439,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -5361,9 +5450,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -5560,7 +5649,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -5589,9 +5678,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" dependencies = [ "memchr", "thiserror", @@ -5600,9 +5689,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" dependencies = [ "pest", "pest_generator", @@ -5610,22 +5699,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] name = "pest_meta" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" dependencies = [ "once_cell", "pest", @@ -5721,7 +5810,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -5759,14 +5848,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -5865,12 +5954,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -5965,7 +6054,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", "version_check", "yansi 1.0.1", ] @@ -5995,7 +6084,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", "rusty-fork", "tempfile", "unarray", @@ -6181,9 +6270,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -6210,9 +6299,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom 0.2.12", "libredox", @@ -6242,7 +6331,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.6", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -6262,7 +6351,7 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -6273,9 +6362,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "reqwest" @@ -6289,9 +6378,9 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls 0.24.2", "hyper-tls", "ipnet", @@ -6303,8 +6392,8 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.10", - "rustls-native-certs", - "rustls-pemfile", + "rustls-native-certs 0.6.3", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -6322,6 +6411,47 @@ dependencies = [ "winreg", ] +[[package]] +name = "reqwest" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" +dependencies = [ + "base64 0.21.7", + "bytes", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-rustls 0.26.0", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls 0.22.3", + "rustls-native-certs 0.7.0", + "rustls-pemfile 1.0.4", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls 0.25.0", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "revm" version = "7.1.0" @@ -6544,8 +6674,8 @@ dependencies = [ "bytes", "crc32fast", "futures", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "hyper-rustls 0.23.2", "lazy_static", "log", @@ -6568,7 +6698,7 @@ dependencies = [ "chrono", "dirs-next", "futures", - "hyper", + "hyper 0.14.28", "serde", "serde_json", "shlex", @@ -6603,8 +6733,8 @@ dependencies = [ "futures", "hex", "hmac 0.11.0", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "log", "md-5 0.9.1", "percent-encoding", @@ -6685,10 +6815,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring 0.17.8", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +dependencies = [ + "log", + "ring 0.17.8", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -6696,7 +6840,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.1", + "rustls-pki-types", "schannel", "security-framework", ] @@ -6710,6 +6867,22 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab" +dependencies = [ + "base64 0.21.7", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -6720,6 +6893,17 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring 0.17.8", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -6787,9 +6971,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef2175c2907e7c8bc0a9c3f86aeb5ec1f3b275300ad58a44d0c3ae379a5e52e" +checksum = "788745a868b0e751750388f4e6546eb921ef714a4317fa6954f7cde114eb2eb7" dependencies = [ "cfg-if", "derive_more", @@ -6799,9 +6983,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b8eb8fd61c5cdd3390d9b2132300a7e7618955b98b8416f118c1b4e144f" +checksum = "7dc2f4e8bc344b9fc3d5f74f72c2e55bfc38d28dc2ebc69c194a3df424e4d9ac" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -6904,9 +7088,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -6917,9 +7101,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -6981,7 +7165,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -6997,9 +7181,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "indexmap", "itoa", @@ -7035,7 +7219,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -7081,7 +7265,7 @@ checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -7208,9 +7392,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" +checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" [[package]] name = "simple_asn1" @@ -7378,7 +7562,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -7391,7 +7575,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -7409,9 +7593,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "svm-rs" @@ -7423,7 +7607,7 @@ dependencies = [ "fs2", "hex", "once_cell", - "reqwest", + "reqwest 0.11.27", "semver 1.0.22", "serde", "serde_json", @@ -7443,7 +7627,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "once_cell", - "reqwest", + "reqwest 0.11.27", "semver 1.0.22", "serde", "serde_json", @@ -7479,9 +7663,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" dependencies = [ "proc-macro2", "quote", @@ -7497,7 +7681,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -7619,7 +7803,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -7736,9 +7920,9 @@ checksum = "c7c4ceeeca15c8384bbc3e011dbd8fccb7f068a440b752b7d9b32ceb0ca0e2e8" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -7761,7 +7945,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -7795,6 +7979,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.3", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -7948,8 +8143,8 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "http-range-header", "httpdate", "mime", @@ -7995,7 +8190,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -8118,7 +8313,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.12", "httparse", "log", "native-tls", @@ -8360,7 +8555,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", "wasm-bindgen-shared", ] @@ -8394,7 +8589,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8796,9 +8991,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "yansi" @@ -8829,7 +9024,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -8849,7 +9044,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.57", ] [[package]] @@ -8893,9 +9088,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.9+zstd.1.5.5" +version = "2.0.10+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index 640c652aee8b0..a7804cc453e4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.76" # Remember to update clippy.toml as well +rust-version = "1.76" # Remember to update clippy.toml as well authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" @@ -139,13 +139,15 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.2.3", default-features = false } +foundry-block-explorers = { version = "0.2.4", default-features = false } foundry-compilers = { version = "0.3.13", default-features = false } ## revm # no default features to avoid c-kzg revm = { version = "7.1", default-features = false, features = ["std"] } -revm-primitives = { version = "3", default-features = false, features = ["std"] } +revm-primitives = { version = "3", default-features = false, features = [ + "std", +] } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ba0b6ab", features = [ "serde", ] } @@ -189,7 +191,10 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 0504bb369c3d6..7e43c22761d4b 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -29,7 +29,7 @@ Inflector = "0.11" number_prefix = "0.4" once_cell = "1" regex = "1" -reqwest = { version = "0.11", default-features = false } +reqwest = { version = "0.12", default-features = false } semver = { version = "1", features = ["serde"] } serde_json.workspace = true serde_regex = "1" @@ -47,3 +47,7 @@ path-slash = "0.2.1" pretty_assertions.workspace = true figment = { version = "0.10", features = ["test"] } tempfile = "3" + +[features] +default = ["rustls"] +rustls = ["reqwest/rustls-tls-native-roots"] diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 7e79321efa4c5..5922f64add1a7 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -304,7 +304,10 @@ impl EtherscanVerificationProvider { builder = if let Some(api_url) = api_url { // we don't want any trailing slashes because this can cause cloudflare issues: let api_url = api_url.trim_end_matches('/'); - builder.with_api_url(api_url)?.with_url(base_url.unwrap_or(api_url))? + builder + .with_chain_id(chain) + .with_api_url(api_url)? + .with_url(base_url.unwrap_or(api_url))? } else { builder.chain(chain)? }; From f6208d8db68f9acbe4ff8cd76958309efb61ea0b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 3 Apr 2024 15:22:55 +0400 Subject: [PATCH 0811/1963] fix: debugger breaks when source file has multiple contract definitions (#7550) * fix contracts sources Co-authored-by: lazymio * fix doc * fmt --------- Co-authored-by: lazymio --- crates/common/src/compile.rs | 51 ++++++++++++++++++++++----------- crates/debugger/src/tui/draw.rs | 4 +-- crates/debugger/src/tui/mod.rs | 4 +-- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index af91a0176be60..654ddd6938ad6 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -288,8 +288,10 @@ impl ProjectCompiler { pub struct ContractSources { /// Map over artifacts' contract names -> vector of file IDs pub ids_by_name: HashMap>, - /// Map over file_id -> (source code, contract) - pub sources_by_id: FxHashMap, + /// Map over file_id -> source code + pub sources_by_id: FxHashMap, + /// Map over file_id -> contract name -> bytecode + pub artifacts_by_id: FxHashMap>, } impl ContractSources { @@ -327,30 +329,45 @@ impl ContractSources { bytecode: ContractBytecodeSome, ) { self.ids_by_name.entry(artifact_id.name.clone()).or_default().push(file_id); - self.sources_by_id.insert(file_id, (source, bytecode)); + self.sources_by_id.insert(file_id, source); + self.artifacts_by_id.entry(file_id).or_default().insert(artifact_id.name.clone(), bytecode); } /// Returns the source for a contract by file ID. - pub fn get(&self, id: u32) -> Option<&(String, ContractBytecodeSome)> { + pub fn get(&self, id: u32) -> Option<&String> { self.sources_by_id.get(&id) } /// Returns all sources for a contract by name. - pub fn get_sources( - &self, - name: &str, - ) -> Option> { - self.ids_by_name - .get(name) - .map(|ids| ids.iter().filter_map(|id| Some((*id, self.sources_by_id.get(id)?)))) - } - - /// Returns all (name, source) pairs. - pub fn entries(&self) -> impl Iterator { - self.ids_by_name.iter().flat_map(|(name, ids)| { - ids.iter().filter_map(|id| self.sources_by_id.get(id).map(|s| (name.clone(), s))) + pub fn get_sources<'a>( + &'a self, + name: &'a str, + ) -> Option> { + self.ids_by_name.get(name).map(|ids| { + ids.iter().filter_map(|id| { + Some(( + *id, + self.sources_by_id.get(id)?.as_ref(), + self.artifacts_by_id.get(id)?.get(name)?, + )) + }) }) } + + /// Returns all (name, source, bytecode) sets. + pub fn entries(&self) -> impl Iterator { + self.artifacts_by_id + .iter() + .filter_map(|(id, artifacts)| { + let source = self.sources_by_id.get(id)?; + Some( + artifacts + .iter() + .map(move |(name, bytecode)| (name.as_ref(), source.as_ref(), bytecode)), + ) + }) + .flatten() + } } // https://eips.ethereum.org/EIPS/eip-170 diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 76e5965130609..8d91f2803f0c6 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -346,7 +346,7 @@ impl DebuggerContext<'_> { let is_create = matches!(self.call_kind(), CallKind::Create | CallKind::Create2); let pc = self.current_step().pc; let Some((source_element, source_code)) = - files_source_code.find_map(|(file_id, (source_code, contract_source))| { + files_source_code.find_map(|(file_id, source_code, contract_source)| { let bytecode = if is_create { &contract_source.bytecode } else { @@ -369,7 +369,7 @@ impl DebuggerContext<'_> { .contracts_sources .sources_by_id .get(&(source_element.index?)) - .map(|(source_code, _)| (source_element.clone(), source_code)) + .map(|source_code| (source_element.clone(), source_code.as_ref())) }) }) else { diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index d9543fc58a8d8..16964e7688b61 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -67,9 +67,9 @@ impl Debugger { ) -> Self { let pc_ic_maps = contracts_sources .entries() - .filter_map(|(contract_name, (_, contract))| { + .filter_map(|(contract_name, _, contract)| { Some(( - contract_name.clone(), + contract_name.to_owned(), ( PcIcMap::new(SpecId::LATEST, contract.bytecode.bytes()?), PcIcMap::new(SpecId::LATEST, contract.deployed_bytecode.bytes()?), From 0875a834de77fbafa933bebbd51839de3841e10e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:33:28 +0300 Subject: [PATCH 0812/1963] fix(fmt): fix indent closing parenthesis enclosed in { } (#7557) * fix(fmt): fix indent closing parenthesis enclosed in { } * Fix testdata bad formatting --- crates/fmt/src/formatter.rs | 2 +- crates/fmt/testdata/Repros/fmt.sol | 12 ++++++++++++ crates/fmt/testdata/Repros/original.sol | 12 ++++++++++++ testdata/default/cheats/RecordAccountAccesses.t.sol | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index bf69651003f60..d10cf4b382359 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -895,7 +895,7 @@ impl<'a, W: Write> Formatter<'a, W> { write_chunk!(fmt, "{}", stringified.trim_start()) })?; if !last.content.trim_start().is_empty() { - self.write_whitespace_separator(true)?; + self.indented(1, |fmt| fmt.write_whitespace_separator(true))?; } let last_chunk = self.chunk_at(last.loc_before(), last.loc_next(), last.spaced, &last.content); diff --git a/crates/fmt/testdata/Repros/fmt.sol b/crates/fmt/testdata/Repros/fmt.sol index 8439563ab4e76..dc1ac24eb3a05 100644 --- a/crates/fmt/testdata/Repros/fmt.sol +++ b/crates/fmt/testdata/Repros/fmt.sol @@ -5,3 +5,15 @@ function errorIdentifier() { bytes memory error = bytes(""); if (error.length > 0) {} } + +// https://github.com/foundry-rs/foundry/issues/7549 +function one() external { + this.other({ + data: abi.encodeCall( + this.other, + ( + "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla" + ) + ) + }); +} diff --git a/crates/fmt/testdata/Repros/original.sol b/crates/fmt/testdata/Repros/original.sol index 8439563ab4e76..cee4fc97a6af8 100644 --- a/crates/fmt/testdata/Repros/original.sol +++ b/crates/fmt/testdata/Repros/original.sol @@ -5,3 +5,15 @@ function errorIdentifier() { bytes memory error = bytes(""); if (error.length > 0) {} } + +// https://github.com/foundry-rs/foundry/issues/7549 +function one() external { + this.other({ + data: abi.encodeCall( + this.other, + ( + "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla" + ) + ) + }); +} diff --git a/testdata/default/cheats/RecordAccountAccesses.t.sol b/testdata/default/cheats/RecordAccountAccesses.t.sol index bea20570ae345..a0aa2cb5332df 100644 --- a/testdata/default/cheats/RecordAccountAccesses.t.sol +++ b/testdata/default/cheats/RecordAccountAccesses.t.sol @@ -943,7 +943,7 @@ contract RecordAccountAccessesTest is DSTest { data: abi.encodeCall( Create2or.create2, (bytes32(0), abi.encodePacked(type(ConstructorStorer).creationCode, abi.encode(true))) - ), + ), reverted: false, storageAccesses: new Vm.StorageAccess[](0), depth: 1 From c10f32a34d5f1d552432a25015c23d6b6ee9b8d4 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 4 Apr 2024 22:35:45 +0400 Subject: [PATCH 0813/1963] feat(test): only compile files needed for tests (#7334) * feat(forge test): only compile files needed for tests * remove comment * clippy * update fixtures * getCode + getDeployedCode updates * fixes * fix path matching * clippy * add config flag * fix * docs * fmt * patch compilers * fix Cargo.toml * update patch * update patch * doc * rm space * cargo cheats * new output selection fn * log compiler errors on failure * fixes --- Cargo.lock | 5 +- crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 4 +- crates/cheatcodes/spec/src/vm.rs | 6 +- crates/cheatcodes/src/config.rs | 20 ++- crates/cheatcodes/src/fs.rs | 69 ++++++++++- crates/chisel/src/executor.rs | 1 + crates/common/src/contracts.rs | 16 +-- crates/config/src/lib.rs | 8 +- crates/forge/bin/cmd/coverage.rs | 9 +- crates/forge/bin/cmd/test/mod.rs | 115 +++++++++++++----- crates/forge/src/lib.rs | 2 +- crates/forge/src/multi_runner.rs | 2 +- crates/forge/tests/cli/config.rs | 1 + .../suggest_when_no_tests_match.stdout | 4 - .../forge/tests/fixtures/warn_no_tests.stdout | 4 - .../tests/fixtures/warn_no_tests_match.stdout | 4 - crates/forge/tests/it/test_helpers.rs | 3 +- crates/script/src/build.rs | 12 +- crates/script/src/execute.rs | 6 +- crates/script/src/lib.rs | 8 +- testdata/default/cheats/GetCode.t.sol | 10 ++ testdata/default/cheats/GetDeployedCode.t.sol | 12 ++ 23 files changed, 244 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d929efd322ca0..87931fb8f2516 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3188,6 +3188,7 @@ dependencies = [ "parking_lot", "revm", "rustc-hash", + "semver 1.0.22", "serde_json", "thiserror", "toml 0.8.12", @@ -4062,9 +4063,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 47315f5ce996a..8006867f4c50f 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -42,5 +42,6 @@ k256.workspace = true walkdir = "2" p256 = "0.13.2" thiserror = "1" +semver = "1" rustc-hash.workspace = true dialoguer = "0.11.0" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index dea51432227f6..0245890f9c3f5 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4621,7 +4621,7 @@ { "func": { "id": "getCode", - "description": "Gets the creation bytecode from an artifact file. Takes in the relative path to the json file.", + "description": "Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.", "declaration": "function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);", "visibility": "external", "mutability": "view", @@ -4641,7 +4641,7 @@ { "func": { "id": "getDeployedCode", - "description": "Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file.", + "description": "Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.", "declaration": "function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);", "visibility": "external", "mutability": "view", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 8f0de363a7fab..42bc15678e5e4 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1397,11 +1397,13 @@ interface Vm { #[cheatcode(group = Filesystem)] function writeLine(string calldata path, string calldata data) external; - /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file. + /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the + /// artifact in the form of :: where and parts are optional. #[cheatcode(group = Filesystem)] function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); - /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file. + /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the + /// artifact in the form of :: where and parts are optional. #[cheatcode(group = Filesystem)] function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 1048f6b6937d5..9d0ca2ea460d7 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -2,7 +2,7 @@ use super::Result; use crate::{script::ScriptWallets, Vm::Rpc}; use alloy_primitives::Address; use foundry_common::fs::normalize_path; -use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; +use foundry_compilers::{utils::canonicalize, ArtifactId, ProjectPathsConfig}; use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, ResolvedRpcEndpoints, @@ -43,11 +43,20 @@ pub struct CheatsConfig { pub labels: HashMap, /// Script wallets pub script_wallets: Option, + /// Artifacts which are guaranteed to be fresh (either recompiled or cached). + /// If Some, `vm.getDeployedCode` invocations are validated to be in scope of this list. + /// If None, no validation is performed. + pub available_artifacts: Option>, } impl CheatsConfig { /// Extracts the necessary settings from the Config - pub fn new(config: &Config, evm_opts: EvmOpts, script_wallets: Option) -> Self { + pub fn new( + config: &Config, + evm_opts: EvmOpts, + available_artifacts: Option>, + script_wallets: Option, + ) -> Self { let mut allowed_paths = vec![config.__root.0.clone()]; allowed_paths.extend(config.libs.clone()); allowed_paths.extend(config.allow_paths.clone()); @@ -55,6 +64,10 @@ impl CheatsConfig { let rpc_endpoints = config.rpc_endpoints.clone().resolved(); trace!(?rpc_endpoints, "using resolved rpc endpoints"); + // If user explicitly disabled safety checks, do not set available_artifacts + let available_artifacts = + if config.unchecked_cheatcode_artifacts { None } else { available_artifacts }; + Self { ffi: evm_opts.ffi, always_use_create_2_factory: evm_opts.always_use_create_2_factory, @@ -68,6 +81,7 @@ impl CheatsConfig { evm_opts, labels: config.labels.clone(), script_wallets, + available_artifacts, } } @@ -185,6 +199,7 @@ impl Default for CheatsConfig { evm_opts: Default::default(), labels: Default::default(), script_wallets: None, + available_artifacts: Default::default(), } } } @@ -199,6 +214,7 @@ mod tests { &Config { __root: PathBuf::from(root).into(), fs_permissions, ..Default::default() }, Default::default(), None, + None, ) } diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 7789915b56574..9760b4f162c1e 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -5,12 +5,13 @@ use alloy_json_abi::ContractObject; use alloy_primitives::U256; use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; -use foundry_common::{fs, get_artifact_path}; +use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; +use semver::Version; use std::{ collections::hash_map::Entry, io::{BufRead, BufReader, Write}, - path::Path, + path::{Path, PathBuf}, process::Command, sync::mpsc, thread, @@ -269,9 +270,69 @@ impl Cheatcode for getDeployedCodeCall { } } +/// Returns the path to the json artifact depending on the input +fn get_artifact_path(state: &Cheatcodes, path: &str) -> Result { + if path.ends_with(".json") { + Ok(PathBuf::from(path)) + } else { + let mut parts = path.split(':'); + let file = PathBuf::from(parts.next().unwrap()); + let contract_name = parts.next(); + let version = parts.next(); + + let version = if let Some(version) = version { + Some(Version::parse(version).map_err(|_| fmt_err!("Error parsing version"))?) + } else { + None + }; + + // Use available artifacts list if available + if let Some(available_ids) = &state.config.available_artifacts { + let mut artifact = None; + + for id in available_ids.iter() { + // name might be in the form of "Counter.0.8.23" + let id_name = id.name.split('.').next().unwrap(); + + if !id.source.ends_with(&file) { + continue; + } + if let Some(name) = contract_name { + if id_name != name { + continue; + } + } + if let Some(ref version) = version { + if id.version.minor != version.minor || + id.version.major != version.major || + id.version.patch != version.patch + { + continue; + } + } + if artifact.is_some() { + return Err(fmt_err!("Multiple matching artifacts found")); + } + artifact = Some(id); + } + + let artifact = artifact.ok_or_else(|| fmt_err!("No matching artifact found"))?; + Ok(artifact.path.clone()) + } else { + let file = file.to_string_lossy(); + let contract_name = if let Some(contract_name) = contract_name { + contract_name.to_owned() + } else { + file.replace(".sol", "") + }; + Ok(state.config.paths.artifacts.join(format!("{file}/{contract_name}.json"))) + } + } +} + /// Reads the bytecode object(s) from the matching artifact fn read_bytecode(state: &Cheatcodes, path: &str) -> Result { - let path = get_artifact_path(&state.config.paths, path); + let path = get_artifact_path(state, path)?; let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; let data = fs::read_to_string(path)?; serde_json::from_str::(&data).map_err(Into::into) @@ -424,7 +485,7 @@ fn prompt( mod tests { use super::*; use crate::CheatsConfig; - use std::{path::PathBuf, sync::Arc}; + use std::sync::Arc; fn cheats() -> Cheatcodes { let config = CheatsConfig { diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 69e35f9477ced..b5b440959a5c5 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -307,6 +307,7 @@ impl SessionSource { &self.config.foundry_config, self.config.evm_opts.clone(), None, + None, ) .into(), ) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 2687b93e3784a..c406d0e45172a 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -5,13 +5,12 @@ use alloy_primitives::{hex, Address, Selector, B256}; use eyre::Result; use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecodeSome}, - ArtifactId, ProjectPathsConfig, + ArtifactId, }; use std::{ collections::BTreeMap, fmt, ops::{Deref, DerefMut}, - path::PathBuf, }; type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a (JsonAbi, Vec)); @@ -170,19 +169,6 @@ pub fn get_file_name(id: &str) -> &str { id.split(':').next().unwrap_or(id) } -/// Returns the path to the json artifact depending on the input -pub fn get_artifact_path(paths: &ProjectPathsConfig, path: &str) -> PathBuf { - if path.ends_with(".json") { - PathBuf::from(path) - } else { - let parts: Vec<&str> = path.split(':').collect(); - let file = parts[0]; - let contract_name = - if parts.len() == 1 { parts[0].replace(".sol", "") } else { parts[1].to_string() }; - paths.artifacts.join(format!("{file}/{contract_name}.json")) - } -} - /// Helper function to convert CompactContractBytecode ~> ContractBytecodeSome pub fn compact_to_contract(contract: CompactContractBytecode) -> Result { Ok(ContractBytecodeSome { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 0c53a6c14e3f8..88671dce194aa 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -387,6 +387,10 @@ pub struct Config { /// Address labels pub labels: HashMap, + /// Whether to enable safety checks for `vm.getCode` and `vm.getDeployedCode` invocations. + /// If disabled, it is possible to access artifacts which were not recompiled or cached. + pub unchecked_cheatcode_artifacts: bool, + /// The root path where the config detection started from, `Config::with_root` #[doc(hidden)] // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] @@ -662,7 +666,8 @@ impl Config { self.create_project(false, true) } - fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { + /// Creates a [Project] with the given `cached` and `no_artifacts` flags + pub fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { let mut project = Project::builder() .artifacts(self.configured_artifacts_handler()) .paths(self.project_paths()) @@ -1925,6 +1930,7 @@ impl Default for Config { fmt: Default::default(), doc: Default::default(), labels: Default::default(), + unchecked_cheatcode_artifacts: false, __non_exhaustive: (), __warnings: vec![], } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 9b6d19e74bee7..8dc4629b9f7ed 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -303,6 +303,8 @@ impl CoverageArgs { ) -> Result<()> { let root = project.paths.root; + let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); + // Build the contract runner let env = evm_opts.evm_env().await?; let mut runner = MultiContractRunnerBuilder::default() @@ -310,7 +312,12 @@ impl CoverageArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone(), None)) + .with_cheats_config(CheatsConfig::new( + &config, + evm_opts.clone(), + Some(artifact_ids), + None, + )) .with_test_options(TestOptions { fuzz: config.fuzz, invariant: config.invariant, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 78000de618711..b4c26e7ee1759 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -6,9 +6,10 @@ use forge::{ decode::decode_console_logs, gas_report::GasReport, inspectors::CheatsConfig, + multi_runner::matches_contract, result::{SuiteResult, TestOutcome, TestStatus}, traces::{identifier::SignaturesIdentifier, CallTraceDecoderBuilder, TraceKind}, - MultiContractRunner, MultiContractRunnerBuilder, TestOptions, TestOptionsBuilder, + MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, TestOptionsBuilder, }; use foundry_cli::{ opts::CoreBuildArgs, @@ -19,6 +20,7 @@ use foundry_common::{ evm::EvmArgs, shell, }; +use foundry_compilers::artifacts::output_selection::OutputSelection; use foundry_config::{ figment, figment::{ @@ -30,7 +32,12 @@ use foundry_config::{ use foundry_debugger::Debugger; use foundry_evm::traces::identifier::TraceIdentifiers; use regex::Regex; -use std::{sync::mpsc::channel, time::Instant}; +use std::{ + collections::{BTreeMap, BTreeSet}, + path::PathBuf, + sync::mpsc::channel, + time::Instant, +}; use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; @@ -134,6 +141,69 @@ impl TestArgs { self.execute_tests().await } + /// Returns sources which include any tests to be executed. + /// If no filters are provided, sources are filtered by existence of test/invariant methods in + /// them, If filters are provided, sources are additionaly filtered by them. + pub fn get_sources_to_compile( + &self, + config: &Config, + filter: &ProjectPathsAwareFilter, + ) -> Result> { + let mut project = config.create_project(true, true)?; + project.solc_config.settings.output_selection = + OutputSelection::common_output_selection(["abi".to_string()]); + let output = project.compile()?; + + if output.has_compiler_errors() { + println!("{}", output); + eyre::bail!("Compilation failed"); + } + + // ABIs of all sources + let abis = output + .into_artifacts() + .filter_map(|(id, artifact)| artifact.abi.map(|abi| (id, abi))) + .collect::>(); + + // Filter sources by their abis and contract names. + let sources = abis + .iter() + .filter(|(id, abi)| matches_contract(id, abi, filter)) + .map(|(id, _)| id.source.clone()) + .collect::>(); + + if sources.is_empty() { + if filter.is_empty() { + println!( + "No tests found in project! \ + Forge looks for functions that starts with `test`." + ); + } else { + println!("No tests match the provided pattern:"); + print!("{filter}"); + + // Try to suggest a test when there's no match + if let Some(test_pattern) = &filter.args().test_pattern { + let test_name = test_pattern.as_str(); + let candidates = abis + .into_iter() + .filter(|(id, _)| { + filter.matches_path(&id.source) && filter.matches_contract(&id.name) + }) + .flat_map(|(_, abi)| abi.functions.into_keys()) + .collect::>(); + if let Some(suggestion) = utils::did_you_mean(test_name, candidates).pop() { + println!("\nDid you mean `{suggestion}`?"); + } + } + } + + eyre::bail!("No tests to run"); + } + + Ok(sources) + } + /// Executes all the tests in the project. /// /// This will trigger the build process first. On success all test contracts that match the @@ -168,10 +238,12 @@ impl TestArgs { let mut filter = self.filter(&config); trace!(target: "forge::test", ?filter, "using filter"); - let mut compiler = ProjectCompiler::new().quiet_if(self.json || self.opts.silent); - if config.sparse_mode { - compiler = compiler.filter(Box::new(filter.clone())); - } + let sources_to_compile = self.get_sources_to_compile(&config, &filter)?; + + let compiler = ProjectCompiler::new() + .quiet_if(self.json || self.opts.silent) + .files(sources_to_compile); + let output = compiler.compile(&project)?; // Create test options from general project settings and compiler output. @@ -199,13 +271,20 @@ impl TestArgs { // Clone the output only if we actually need it later for the debugger. let output_clone = should_debug.then(|| output.clone()); + let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); + let runner = MultiContractRunnerBuilder::default() .set_debug(should_debug) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new(&config, evm_opts.clone(), None)) + .with_cheats_config(CheatsConfig::new( + &config, + evm_opts.clone(), + Some(artifact_ids), + None, + )) .with_test_options(test_options) .enable_isolation(evm_opts.isolate) .build(project_root, output, env, evm_opts)?; @@ -270,28 +349,6 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); let num_filtered = runner.matching_test_functions(filter).count(); - if num_filtered == 0 { - println!(); - if filter.is_empty() { - println!( - "No tests found in project! \ - Forge looks for functions that starts with `test`." - ); - } else { - println!("No tests match the provided pattern:"); - print!("{filter}"); - - // Try to suggest a test when there's no match - if let Some(test_pattern) = &filter.args().test_pattern { - let test_name = test_pattern.as_str(); - // Filter contracts but not test functions. - let candidates = runner.all_test_functions(filter).map(|f| &f.name); - if let Some(suggestion) = utils::did_you_mean(test_name, candidates).pop() { - println!("\nDid you mean `{suggestion}`?"); - } - } - } - } if self.debug.is_some() && num_filtered != 1 { eyre::bail!( "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n\n\ diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index d163f819cc62e..98dc0aa4783ef 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -15,7 +15,7 @@ pub mod coverage; pub mod gas_report; -mod multi_runner; +pub mod multi_runner; pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder}; mod runner; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index d545d773d8201..94d0b0155a8ee 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -383,7 +383,7 @@ impl MultiContractRunnerBuilder { } } -fn matches_contract(id: &ArtifactId, abi: &JsonAbi, filter: &dyn TestFilter) -> bool { +pub fn matches_contract(id: &ArtifactId, abi: &JsonAbi, filter: &dyn TestFilter) -> bool { (filter.matches_path(&id.source) && filter.matches_contract(&id.name)) && abi.functions().any(|func| is_matching_test(func, filter)) } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 81884f3bcd9f4..22d885af49314 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -126,6 +126,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { labels: Default::default(), cancun: true, isolate: true, + unchecked_cheatcode_artifacts: false, __non_exhaustive: (), __warnings: vec![], }; diff --git a/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout b/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout index 1c27d8005cdcd..1cf6ad73f8952 100644 --- a/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout +++ b/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout @@ -1,7 +1,3 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 185.25ms -Compiler run successful! - No tests match the provided pattern: match-test: `testA.*` no-match-test: `testB.*` diff --git a/crates/forge/tests/fixtures/warn_no_tests.stdout b/crates/forge/tests/fixtures/warn_no_tests.stdout index 9b2b8bff47481..a9a7e7fc67111 100644 --- a/crates/forge/tests/fixtures/warn_no_tests.stdout +++ b/crates/forge/tests/fixtures/warn_no_tests.stdout @@ -1,5 +1 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 -Compiler run successful! - No tests found in project! Forge looks for functions that starts with `test`. diff --git a/crates/forge/tests/fixtures/warn_no_tests_match.stdout b/crates/forge/tests/fixtures/warn_no_tests_match.stdout index 56f068238d266..4b4080f15faec 100644 --- a/crates/forge/tests/fixtures/warn_no_tests_match.stdout +++ b/crates/forge/tests/fixtures/warn_no_tests_match.stdout @@ -1,7 +1,3 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 -Compiler run successful! - No tests match the provided pattern: match-test: `testA.*` no-match-test: `testB.*` diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 0112d4bb96cca..8d54976cc7865 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -204,8 +204,9 @@ impl ForgeTestData { let opts = self.evm_opts.clone(); let env = opts.local_evm_env(); let output = self.output.clone(); + let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); self.base_runner() - .with_cheats_config(CheatsConfig::new(&config, opts.clone(), None)) + .with_cheats_config(CheatsConfig::new(&config, opts.clone(), Some(artifact_ids), None)) .sender(config.sender) .with_test_options(self.test_opts.clone()) .build(root, output, env, opts.clone()) diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index b0aba755e8f8c..ab17a95a9b936 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -35,6 +35,9 @@ pub struct BuildData { pub output: ProjectCompileOutput, /// Id of target contract artifact. pub target: ArtifactId, + /// Artifact ids of the contracts. Passed to cheatcodes to enable usage of + /// `vm.getDeployedCode`. + pub artifact_ids: Vec, } impl BuildData { @@ -211,6 +214,8 @@ impl PreprocessedState { let mut target_id: Option = None; + let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); + // Find target artfifact id by name and path in compilation artifacts. for (id, contract) in output.artifact_ids().filter(|(id, _)| id.source == target_path) { if let Some(name) = &target_name { @@ -247,7 +252,12 @@ impl PreprocessedState { args, script_config, script_wallets, - build_data: BuildData { output, target, project_root: project.root().clone() }, + build_data: BuildData { + output, + target, + project_root: project.root().clone(), + artifact_ids, + }, }) } } diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index b2fab7154b25d..d89461c9e9f15 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -98,7 +98,11 @@ impl PreExecutionState { pub async fn execute(mut self) -> Result { let mut runner = self .script_config - .get_runner_with_cheatcodes(self.script_wallets.clone(), self.args.debug) + .get_runner_with_cheatcodes( + self.build_data.build_data.artifact_ids.clone(), + self.script_wallets.clone(), + self.args.debug, + ) .await?; let mut result = self.execute_with_runner(&mut runner).await?; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index fd4ba66f6c0eb..fc8678b41e7f5 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -550,15 +550,16 @@ impl ScriptConfig { async fn get_runner_with_cheatcodes( &mut self, + artifact_ids: Vec, script_wallets: ScriptWallets, debug: bool, ) -> Result { - self._get_runner(Some(script_wallets), debug).await + self._get_runner(Some((artifact_ids, script_wallets)), debug).await } async fn _get_runner( &mut self, - script_wallets: Option, + cheats_data: Option<(Vec, ScriptWallets)>, debug: bool, ) -> Result { trace!("preparing script runner"); @@ -587,7 +588,7 @@ impl ScriptConfig { .spec(self.config.evm_spec_id()) .gas_limit(self.evm_opts.gas_limit()); - if let Some(script_wallets) = script_wallets { + if let Some((artifact_ids, script_wallets)) = cheats_data { builder = builder.inspectors(|stack| { stack .debug(debug) @@ -595,6 +596,7 @@ impl ScriptConfig { CheatsConfig::new( &self.config, self.evm_opts.clone(), + Some(artifact_ids), Some(script_wallets), ) .into(), diff --git a/testdata/default/cheats/GetCode.t.sol b/testdata/default/cheats/GetCode.t.sol index 8f47188d554da..d308712e9d6b4 100644 --- a/testdata/default/cheats/GetCode.t.sol +++ b/testdata/default/cheats/GetCode.t.sol @@ -4,6 +4,8 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; +contract TestContract {} + contract GetCodeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); @@ -70,4 +72,12 @@ contract GetCodeTest is DSTest { function testFailGetUnlinked() public { vm.getCode("UnlinkedContract.sol"); } + + function testWithVersion() public { + bytes memory code = vm.getCode("cheats/GetCode.t.sol:TestContract:0.8.18"); + assertEq(type(TestContract).creationCode, code); + + vm._expectCheatcodeRevert("No matching artifact found"); + vm.getCode("cheats/GetCode.t.sol:TestContract:0.8.19"); + } } diff --git a/testdata/default/cheats/GetDeployedCode.t.sol b/testdata/default/cheats/GetDeployedCode.t.sol index fc8ed609eda99..8d95b243ce564 100644 --- a/testdata/default/cheats/GetDeployedCode.t.sol +++ b/testdata/default/cheats/GetDeployedCode.t.sol @@ -4,6 +4,8 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; +contract TestContract {} + contract GetDeployedCodeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); @@ -36,6 +38,16 @@ contract GetDeployedCodeTest is DSTest { emit Payload(address(this), address(0), "hello"); over.emitPayload(address(0), "hello"); } + + function testWithVersion() public { + TestContract test = new TestContract(); + bytes memory code = vm.getDeployedCode("cheats/GetDeployedCode.t.sol:TestContract:0.8.18"); + + assertEq(address(test).code, code); + + vm._expectCheatcodeRevert("No matching artifact found"); + vm.getDeployedCode("cheats/GetDeployedCode.t.sol:TestContract:0.8.19"); + } } interface Override { From 1631c5ca8a17d546fc4b5f6ee7de7b230c2dddcb Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 4 Apr 2024 22:43:20 +0400 Subject: [PATCH 0814/1963] fix: do not flood dictionary with data dependent on fuzz inputs (#7552) * fix dictionary * clippy + fmt * fix --- crates/evm/evm/src/executors/fuzz/mod.rs | 15 +- crates/evm/evm/src/executors/invariant/mod.rs | 24 +- crates/evm/fuzz/src/inspector.rs | 7 +- crates/evm/fuzz/src/strategies/calldata.rs | 2 +- crates/evm/fuzz/src/strategies/mod.rs | 3 +- crates/evm/fuzz/src/strategies/param.rs | 4 +- crates/evm/fuzz/src/strategies/state.rs | 230 +++++++++++------- crates/forge/src/runner.rs | 14 +- 8 files changed, 170 insertions(+), 129 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 41beb7e433176..ae63d2386bae4 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -10,10 +10,7 @@ use foundry_evm_core::{ }; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ - strategies::{ - build_initial_state, collect_state_from_call, fuzz_calldata, fuzz_calldata_from_state, - EvmFuzzState, - }, + strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, BaseCounterExample, CounterExample, FuzzCase, FuzzError, FuzzTestResult, }; use foundry_evm_traces::CallTraceArena; @@ -89,7 +86,7 @@ impl FuzzedExecutor { ]; debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { - let fuzz_res = self.single_fuzz(&state, address, should_fail, calldata)?; + let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; match fuzz_res { FuzzOutcome::Case(case) => { @@ -195,7 +192,6 @@ impl FuzzedExecutor { /// or a `CounterExampleOutcome` pub fn single_fuzz( &self, - state: &EvmFuzzState, address: Address, should_fail: bool, calldata: alloy_primitives::Bytes, @@ -206,9 +202,6 @@ impl FuzzedExecutor { .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; let state_changeset = call.state_changeset.take().unwrap(); - // Build fuzzer state - collect_state_from_call(&call.logs, &state_changeset, state, &self.config.dictionary); - // When the `assume` cheatcode is called it returns a special string if call.result.as_ref() == MAGIC_ASSUME { return Err(TestCaseError::reject(FuzzError::AssumeReject)) @@ -247,9 +240,9 @@ impl FuzzedExecutor { /// Stores fuzz state for use with [fuzz_calldata_from_state] pub fn build_fuzz_state(&self) -> EvmFuzzState { if let Some(fork_db) = self.executor.backend.active_fork_db() { - build_initial_state(fork_db, &self.config.dictionary) + build_initial_state(fork_db, self.config.dictionary) } else { - build_initial_state(self.executor.backend.mem_db(), &self.config.dictionary) + build_initial_state(self.executor.backend.mem_db(), self.config.dictionary) } } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 5ed7998ac3e1a..835a2bc877bfd 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -6,7 +6,7 @@ use alloy_primitives::{Address, FixedBytes, U256}; use alloy_sol_types::{sol, SolCall}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; -use foundry_config::{FuzzDictionaryConfig, InvariantConfig}; +use foundry_config::InvariantConfig; use foundry_evm_core::{ constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME}, utils::{get_function, StateChangeset}, @@ -17,8 +17,8 @@ use foundry_evm_fuzz::{ RandomCallGenerator, SenderFilters, TargetedContracts, }, strategies::{ - build_initial_state, collect_created_contracts, collect_state_from_call, invariant_strat, - override_call_strat, CalldataFuzzDictionary, EvmFuzzState, + build_initial_state, collect_created_contracts, invariant_strat, override_call_strat, + CalldataFuzzDictionary, EvmFuzzState, }, FuzzCase, FuzzedCases, }; @@ -246,13 +246,7 @@ impl<'a> InvariantExecutor<'a> { let mut state_changeset = call_result.state_changeset.to_owned().expect("no changesets"); - collect_data( - &mut state_changeset, - sender, - &call_result, - &fuzz_state, - &self.config.dictionary, - ); + collect_data(&mut state_changeset, sender, &call_result, &fuzz_state); if let Err(error) = collect_created_contracts( &state_changeset, @@ -325,11 +319,14 @@ impl<'a> InvariantExecutor<'a> { } fuzz_cases.borrow_mut().push(FuzzedCases::new(fuzz_runs)); + // Revert state to not persist values between runs. + fuzz_state.revert(); + Ok(()) }); trace!(target: "forge::test::invariant::calldata_address_fuzz_dictionary", "{:?}", calldata_fuzz_dictionary.inner.addresses); - trace!(target: "forge::test::invariant::dictionary", "{:?}", fuzz_state.read().values().iter().map(hex::encode).collect::>()); + trace!(target: "forge::test::invariant::dictionary", "{:?}", fuzz_state.dictionary_read().values().iter().map(hex::encode).collect::>()); let (reverts, error) = failures.into_inner().into_inner(); @@ -361,7 +358,7 @@ impl<'a> InvariantExecutor<'a> { // Stores fuzz state for use with [fuzz_calldata_from_state]. let fuzz_state: EvmFuzzState = - build_initial_state(self.executor.backend.mem_db(), &self.config.dictionary); + build_initial_state(self.executor.backend.mem_db(), self.config.dictionary); // During execution, any newly created contract is added here and used through the rest of // the fuzz run. @@ -668,7 +665,6 @@ fn collect_data( sender: &Address, call_result: &RawCallResult, fuzz_state: &EvmFuzzState, - config: &FuzzDictionaryConfig, ) { // Verify it has no code. let mut has_code = false; @@ -683,7 +679,7 @@ fn collect_data( sender_changeset = state_changeset.remove(sender); } - collect_state_from_call(&call_result.logs, &*state_changeset, fuzz_state, config); + fuzz_state.collect_state_from_call(&call_result.logs, &*state_changeset); // Re-add changes if let Some(changed) = sender_changeset { diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index e58afb214feea..5e7e644b11d60 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -1,4 +1,5 @@ use crate::{invariant::RandomCallGenerator, strategies::EvmFuzzState}; +use alloy_primitives::U256; use revm::{ interpreter::{CallInputs, CallOutcome, CallScheme, Interpreter}, Database, EvmContext, Inspector, @@ -61,11 +62,7 @@ impl Inspector for Fuzzer { impl Fuzzer { /// Collects `stack` and `memory` values into the fuzz dictionary. fn collect_data(&mut self, interpreter: &Interpreter) { - let mut state = self.fuzz_state.write(); - - for slot in interpreter.stack().data() { - state.values_mut().insert(slot.to_be_bytes()); - } + self.fuzz_state.collect_values(interpreter.stack().data().iter().map(U256::to_be_bytes)); // TODO: disabled for now since it's flooding the dictionary // for index in 0..interpreter.shared_memory.len() / 32 { diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index b3d41bfadbbd0..ff3bb57134469 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -41,7 +41,7 @@ impl CalldataFuzzDictionaryConfig { if dict_size > 0 { addresses.extend(std::iter::repeat_with(Address::random).take(dict_size)); // Add all addresses that already had their PUSH bytes collected. - addresses.extend(state.read().addresses()); + addresses.extend(state.dictionary_read().addresses()); } Self { addresses: addresses.into_iter().collect() } diff --git a/crates/evm/fuzz/src/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs index 63e008ec0c96a..0e82a4d4b8d69 100644 --- a/crates/evm/fuzz/src/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -14,8 +14,7 @@ pub use calldata::{ mod state; pub use state::{ - build_initial_state, collect_created_contracts, collect_state_from_call, - fuzz_calldata_from_state, EvmFuzzState, + build_initial_state, collect_created_contracts, fuzz_calldata_from_state, EvmFuzzState, }; mod invariants; diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index f287c75dfde11..20e69a27e7255 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -89,7 +89,7 @@ pub fn fuzz_param_from_state( let state = state.clone(); // Use `Index` instead of `Selector` to not iterate over the entire dictionary. any::().prop_map(move |index| { - let state = state.read(); + let state = state.dictionary_read(); let values = state.values(); let index = index.index(values.len()); *values.iter().nth(index).unwrap() @@ -184,7 +184,7 @@ mod tests { let f = "testArray(uint64[2] calldata values)"; let func = get_func(f).unwrap(); let db = CacheDB::new(EmptyDB::default()); - let state = build_initial_state(&db, &FuzzDictionaryConfig::default()); + let state = build_initial_state(&db, FuzzDictionaryConfig::default()); let strat = proptest::prop_oneof![ 60 => fuzz_calldata(func.clone()), 40 => fuzz_calldata_from_state(func, &state), diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index df70ba88520a5..3c8f490f3a1e4 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -7,7 +7,7 @@ use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; use indexmap::IndexSet; -use parking_lot::RwLock; +use parking_lot::{lock_api::RwLockReadGuard, RawRwLock, RwLock}; use proptest::prelude::{BoxedStrategy, Strategy}; use revm::{ db::{CacheDB, DatabaseRef}, @@ -19,16 +19,103 @@ use std::{fmt, sync::Arc}; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// /// Wrapped in a shareable container. -pub type EvmFuzzState = Arc>; +#[derive(Clone, Debug)] +pub struct EvmFuzzState { + inner: Arc>, +} + +impl EvmFuzzState { + pub fn new(dictionary: FuzzDictionary) -> Self { + Self { inner: Arc::new(RwLock::new(dictionary)) } + } + + pub fn collect_values(&self, values: impl IntoIterator) { + let mut dict = self.inner.write(); + for value in values { + dict.insert_value(value); + } + } + + /// Collects state changes from a [StateChangeset] and logs into an [EvmFuzzState] according to + /// the given [FuzzDictionaryConfig]. + pub fn collect_state_from_call(&self, logs: &[Log], state_changeset: &StateChangeset) { + let mut dict = self.inner.write(); + + // Insert log topics and data. + for log in logs { + for topic in log.topics() { + dict.insert_value(topic.0); + } + let chunks = log.data.data.chunks_exact(32); + let rem = chunks.remainder(); + for chunk in chunks { + dict.insert_value(chunk.try_into().unwrap()); + } + if !rem.is_empty() { + dict.insert_value(B256::right_padding_from(rem).0); + } + } + + for (address, account) in state_changeset { + // Insert basic account information + dict.insert_value(address.into_word().into()); + + if dict.config.include_push_bytes { + // Insert push bytes + if let Some(code) = &account.info.code { + dict.insert_address(*address); + for push_byte in collect_push_bytes(code.bytes()) { + dict.insert_value(push_byte); + } + } + } + + if dict.config.include_storage { + // Insert storage + for (slot, value) in &account.storage { + let value = value.present_value; + dict.insert_value(B256::from(*slot).0); + dict.insert_value(B256::from(value).0); + // also add the value below and above the storage value to the dictionary. + if value != U256::ZERO { + let below_value = value - U256::from(1); + dict.insert_value(B256::from(below_value).0); + } + if value != U256::MAX { + let above_value = value + U256::from(1); + dict.insert_value(B256::from(above_value).0); + } + } + } + } + } + + /// Removes all newly added entries from the dictionary. + /// + /// Should be called between fuzz/invariant runs to avoid accumumlating data derived from fuzz + /// inputs. + pub fn revert(&self) { + self.inner.write().revert(); + } + + pub fn dictionary_read(&self) -> RwLockReadGuard<'_, RawRwLock, FuzzDictionary> { + self.inner.read() + } +} // We're using `IndexSet` to have a stable element order when restoring persisted state, as well as // for performance when iterating over the sets. -#[derive(Default)] pub struct FuzzDictionary { /// Collected state values. state_values: IndexSet<[u8; 32]>, /// Addresses that already had their PUSH bytes collected. addresses: IndexSet
, + /// Configuration for the dictionary. + config: FuzzDictionaryConfig, + /// New keys added to the dictionary since container initialization. + new_values: IndexSet<[u8; 32]>, + /// New addresses added to the dictionary since container initialization. + new_addreses: IndexSet
, } impl fmt::Debug for FuzzDictionary { @@ -41,14 +128,39 @@ impl fmt::Debug for FuzzDictionary { } impl FuzzDictionary { - #[inline] - pub fn values(&self) -> &IndexSet<[u8; 32]> { - &self.state_values + pub fn new( + initial_values: IndexSet<[u8; 32]>, + initial_addresses: IndexSet
, + config: FuzzDictionaryConfig, + ) -> Self { + Self { + state_values: initial_values, + addresses: initial_addresses, + config, + new_values: IndexSet::new(), + new_addreses: IndexSet::new(), + } + } + + pub fn insert_value(&mut self, value: [u8; 32]) { + if self.state_values.len() < self.config.max_fuzz_dictionary_values && + self.state_values.insert(value) + { + self.new_values.insert(value); + } + } + + pub fn insert_address(&mut self, address: Address) { + if self.addresses.len() < self.config.max_fuzz_dictionary_addresses && + self.addresses.insert(address) + { + self.new_addreses.insert(address); + } } #[inline] - pub fn values_mut(&mut self) -> &mut IndexSet<[u8; 32]> { - &mut self.state_values + pub fn values(&self) -> &IndexSet<[u8; 32]> { + &self.state_values } #[inline] @@ -56,9 +168,16 @@ impl FuzzDictionary { &self.addresses } - #[inline] - pub fn addresses_mut(&mut self) -> &mut IndexSet
{ - &mut self.addresses + pub fn revert(&mut self) { + for key in self.new_values.iter() { + self.state_values.swap_remove(key); + } + for address in self.new_addreses.iter() { + self.addresses.swap_remove(address); + } + + self.new_values.clear(); + self.new_addreses.clear(); } } @@ -88,22 +207,22 @@ pub fn fuzz_calldata_from_state(func: Function, state: &EvmFuzzState) -> BoxedSt /// Builds the initial [EvmFuzzState] from a database. pub fn build_initial_state( db: &CacheDB, - config: &FuzzDictionaryConfig, + config: FuzzDictionaryConfig, ) -> EvmFuzzState { - let mut state = FuzzDictionary::default(); + let mut values = IndexSet::new(); + let mut addresses = IndexSet::new(); for (address, account) in db.accounts.iter() { let address: Address = *address; // Insert basic account information - state.values_mut().insert(address.into_word().into()); + values.insert(address.into_word().into()); // Insert push bytes if config.include_push_bytes { if let Some(code) = &account.info.code { - if state.addresses_mut().insert(address) { - for push_byte in collect_push_bytes(code.bytes()) { - state.values_mut().insert(push_byte); - } + addresses.insert(address); + for push_byte in collect_push_bytes(code.bytes()) { + values.insert(push_byte); } } } @@ -111,16 +230,16 @@ pub fn build_initial_state( if config.include_storage { // Insert storage for (slot, value) in &account.storage { - state.values_mut().insert(B256::from(*slot).0); - state.values_mut().insert(B256::from(*value).0); + values.insert(B256::from(*slot).0); + values.insert(B256::from(*value).0); // also add the value below and above the storage value to the dictionary. if *value != U256::ZERO { let below_value = value - U256::from(1); - state.values_mut().insert(B256::from(below_value).0); + values.insert(B256::from(below_value).0); } if *value != U256::MAX { let above_value = value + U256::from(1); - state.values_mut().insert(B256::from(above_value).0); + values.insert(B256::from(above_value).0); } } } @@ -128,73 +247,12 @@ pub fn build_initial_state( // need at least some state data if db is empty otherwise we can't select random data for state // fuzzing - if state.values().is_empty() { + if values.is_empty() { // prefill with a random addresses - state.values_mut().insert(Address::random().into_word().into()); + values.insert(Address::random().into_word().into()); } - Arc::new(RwLock::new(state)) -} - -/// Collects state changes from a [StateChangeset] and logs into an [EvmFuzzState] according to the -/// given [FuzzDictionaryConfig]. -pub fn collect_state_from_call( - logs: &[Log], - state_changeset: &StateChangeset, - state: &EvmFuzzState, - config: &FuzzDictionaryConfig, -) { - let mut state = state.write(); - - // Insert log topics and data. - for log in logs { - for topic in log.topics() { - state.values_mut().insert(topic.0); - } - let chunks = log.data.data.chunks_exact(32); - let rem = chunks.remainder(); - for chunk in chunks { - state.values_mut().insert(chunk.try_into().unwrap()); - } - if !rem.is_empty() { - state.values_mut().insert(B256::right_padding_from(rem).0); - } - } - - for (address, account) in state_changeset { - // Insert basic account information - state.values_mut().insert(address.into_word().into()); - - if config.include_push_bytes && state.addresses.len() < config.max_fuzz_dictionary_addresses - { - // Insert push bytes - if let Some(code) = &account.info.code { - if state.addresses_mut().insert(*address) { - for push_byte in collect_push_bytes(code.bytes()) { - state.values_mut().insert(push_byte); - } - } - } - } - - if config.include_storage && state.state_values.len() < config.max_fuzz_dictionary_values { - // Insert storage - for (slot, value) in &account.storage { - let value = value.present_value; - state.values_mut().insert(B256::from(*slot).0); - state.values_mut().insert(B256::from(value).0); - // also add the value below and above the storage value to the dictionary. - if value != U256::ZERO { - let below_value = value - U256::from(1); - state.values_mut().insert(B256::from(below_value).0); - } - if value != U256::MAX { - let above_value = value + U256::from(1); - state.values_mut().insert(B256::from(above_value).0); - } - } - } - } + EvmFuzzState::new(FuzzDictionary::new(values, addresses, config)) } /// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 7f3258e359fa0..508ee9234423f 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -611,7 +611,6 @@ impl<'a> ContractRunner<'a> { self.sender, fuzz_config.clone(), ); - let state = fuzzed_executor.build_fuzz_state(); let result = fuzzed_executor.fuzz(func, address, should_fail, self.revert_decoder); let mut debug = Default::default(); @@ -650,13 +649,12 @@ impl<'a> ContractRunner<'a> { result.first_case.calldata.clone() }; // rerun the last relevant test with traces - let debug_result = FuzzedExecutor::new( - debug_executor, - runner, - self.sender, - fuzz_config, - ) - .single_fuzz(&state, address, should_fail, calldata); + let debug_result = + FuzzedExecutor::new(debug_executor, runner, self.sender, fuzz_config).single_fuzz( + address, + should_fail, + calldata, + ); (debug, breakpoints) = match debug_result { Ok(fuzz_outcome) => match fuzz_outcome { From 1281421e04144a8de0341f9cad9b623a012a74bf Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:34:59 +0530 Subject: [PATCH 0815/1963] Feat: Index cheatcode for Strings (#7539) * feat: index cheatcode * some nits to make it work * nit: use as_str() * final changes * chore: reviewed changes --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 5 +++++ crates/cheatcodes/src/string.rs | 9 +++++++++ testdata/cheats/Vm.sol | 1 + testdata/default/cheats/StringUtils.t.sol | 12 ++++++++++++ 5 files changed, 47 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 0245890f9c3f5..360d5de1c442c 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4798,6 +4798,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "indexOf", + "description": "Returns the index of the first occurrence of a `key` in an `input` string.\nReturns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.\nReturns 0 in case of an empty `key`.", + "declaration": "function indexOf(string memory input, string memory key) external pure returns (uint256);", + "visibility": "external", + "mutability": "pure", + "signature": "indexOf(string,string)", + "selector": "0x8a0807b7", + "selectorBytes": [ + 138, + 8, + 7, + 183 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "isDir", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 42bc15678e5e4..93042c1991ff1 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1680,6 +1680,11 @@ interface Vm { /// Splits the given `string` into an array of strings divided by the `delimiter`. #[cheatcode(group = String)] function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs); + /// Returns the index of the first occurrence of a `key` in an `input` string. + /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found. + /// Returns 0 in case of an empty `key`. + #[cheatcode(group = String)] + function indexOf(string memory input, string memory key) external pure returns (uint256); // ======== JSON Parsing and Manipulation ======== diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index b7992b9450fd3..c98560a72f068 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -2,6 +2,7 @@ use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_primitives::U256; use alloy_sol_types::SolValue; // address @@ -135,6 +136,14 @@ impl Cheatcode for splitCall { } } +// indexOf +impl Cheatcode for indexOfCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { input, key } = self; + Ok(input.find(key).map(U256::from).unwrap_or(U256::MAX).abi_encode()) + } +} + pub(super) fn parse(s: &str, ty: &DynSolType) -> Result { parse_value(s, ty).map(|v| v.abi_encode()) } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 2116acf2b8ffe..aff05c278740c 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -237,6 +237,7 @@ interface Vm { function getNonce(address account) external view returns (uint64 nonce); function getNonce(Wallet calldata wallet) external returns (uint64 nonce); function getRecordedLogs() external returns (Log[] memory logs); + function indexOf(string memory input, string memory key) external pure returns (uint256); function isDir(string calldata path) external returns (bool result); function isFile(string calldata path) external returns (bool result); function isPersistent(address account) external view returns (bool persistent); diff --git a/testdata/default/cheats/StringUtils.t.sol b/testdata/default/cheats/StringUtils.t.sol index 471d628be0182..136164a413d7d 100644 --- a/testdata/default/cheats/StringUtils.t.sol +++ b/testdata/default/cheats/StringUtils.t.sol @@ -39,4 +39,16 @@ contract StringManipulationTest is DSTest { assertEq("World", splitResult[1]); assertEq("Reth", splitResult[2]); } + + function testIndexOf() public { + string memory input = "Hello, World!"; + string memory key1 = "Hello,"; + string memory key2 = "World!"; + string memory key3 = ""; + string memory key4 = "foundry"; + assertEq(vm.indexOf(input, key1), 0); + assertEq(vm.indexOf(input, key2), 7); + assertEq(vm.indexOf(input, key3), 0); + assertEq(vm.indexOf(input, key4), type(uint256).max); + } } From b994a65719a36a4a5a775ee8a7f4b580f888babd Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:07:35 +0200 Subject: [PATCH 0816/1963] chore: reduce logs in tests (#7566) --- crates/chisel/src/executor.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index b5b440959a5c5..e0774a2b6878a 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1782,9 +1782,6 @@ mod tests { } fn init_tracing() { - if std::env::var_os("RUST_LOG").is_none() { - std::env::set_var("RUST_LOG", "debug"); - } let _ = tracing_subscriber::FmtSubscriber::builder() .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .try_init(); From dfab23e52e09ed6495d8c9eb861fe19a22b230a5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:30:25 +0300 Subject: [PATCH 0817/1963] fix(script): decode custom error in script fail message (#7563) --- crates/forge/tests/cli/script.rs | 34 ++++++++++++++++++++++++++++++++ crates/script/src/execute.rs | 6 +++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index a2d4dc4fb625f..8af676efd0ddc 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1197,3 +1197,37 @@ contract Script { cmd.arg("script").args([&script.to_string_lossy(), "--sig", "run"]); assert!(cmd.stderr_lossy().contains("Multiple functions with the same name")); }); + +forgetest_async!(can_decode_custom_errors, |prj, cmd| { + cmd.args(["init", "--force"]).arg(prj.root()); + cmd.assert_non_empty_stdout(); + cmd.forge_fuse(); + + let script = prj + .add_script( + "CustomErrorScript.s.sol", + r#" +import { Script } from "forge-std/Script.sol"; + +contract ContractWithCustomError { + error CustomError(); + + constructor() { + revert CustomError(); + } +} + +contract CustomErrorScript is Script { + ContractWithCustomError test; + + function run() public { + test = new ContractWithCustomError(); + } +} +"#, + ) + .unwrap(); + + cmd.arg("script").arg(script).args(["--tc", "CustomErrorScript"]); + assert!(cmd.stderr_lossy().contains("script failed: CustomError()")); +}); diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index d89461c9e9f15..7a2546ec822c3 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -23,7 +23,7 @@ use foundry_compilers::artifacts::ContractBytecodeSome; use foundry_config::{Config, NamedChain}; use foundry_debugger::Debugger; use foundry_evm::{ - decode::{decode_console_logs, RevertDecoder}, + decode::decode_console_logs, inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, traces::{ identifier::{SignaturesIdentifier, TraceIdentifiers}, @@ -423,7 +423,7 @@ impl PreSimulationState { if !self.execution_result.success { return Err(eyre::eyre!( "script failed: {}", - RevertDecoder::new().decode(&self.execution_result.returned[..], None) + &self.execution_artifacts.decoder.revert_decoder.decode(&result.returned[..], None) )); } @@ -504,7 +504,7 @@ impl PreSimulationState { if !result.success { return Err(eyre::eyre!( "script failed: {}", - RevertDecoder::new().decode(&result.returned[..], None) + &self.execution_artifacts.decoder.revert_decoder.decode(&result.returned[..], None) )); } From c2162e2d69bcdc8c06522816e5a4064c49026d14 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 6 Apr 2024 02:17:32 +0400 Subject: [PATCH 0818/1963] fix: always compile sources when running tests (#7572) --- crates/forge/bin/cmd/test/mod.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index b4c26e7ee1759..104fa4c486e0b 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -20,7 +20,7 @@ use foundry_common::{ evm::EvmArgs, shell, }; -use foundry_compilers::artifacts::output_selection::OutputSelection; +use foundry_compilers::{artifacts::output_selection::OutputSelection, utils::source_files_iter}; use foundry_config::{ figment, figment::{ @@ -166,13 +166,13 @@ impl TestArgs { .collect::>(); // Filter sources by their abis and contract names. - let sources = abis + let mut test_sources = abis .iter() .filter(|(id, abi)| matches_contract(id, abi, filter)) .map(|(id, _)| id.source.clone()) .collect::>(); - if sources.is_empty() { + if test_sources.is_empty() { if filter.is_empty() { println!( "No tests found in project! \ @@ -201,7 +201,10 @@ impl TestArgs { eyre::bail!("No tests to run"); } - Ok(sources) + // Always recompile all sources to ensure that `getCode` cheatcode can use any artifact. + test_sources.extend(source_files_iter(project.paths.sources)); + + Ok(test_sources) } /// Executes all the tests in the project. From 5b0dc8c7fa99e4e4fd1fd6f1a4b6535fdc075555 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 6 Apr 2024 02:21:48 +0400 Subject: [PATCH 0819/1963] fix: `--match-path` is broken (#7579) * fix: --match-path is broken * rm docs --- crates/forge/bin/cmd/test/filter.rs | 6 ++++-- crates/forge/tests/cli/test_cmd.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index 65d3d0ed508d6..eb8baea4620f4 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -196,7 +196,8 @@ impl FileFilter for ProjectPathsAwareFilter { /// /// If no file regex is set this returns true if the file ends with `.t.sol`, see /// [FoundryPathExr::is_sol_test()] - fn is_match(&self, file: &Path) -> bool { + fn is_match(&self, mut file: &Path) -> bool { + file = file.strip_prefix(&self.paths.root).unwrap_or(file); self.args_filter.is_match(file) } } @@ -210,8 +211,9 @@ impl TestFilter for ProjectPathsAwareFilter { self.args_filter.matches_contract(contract_name) } - fn matches_path(&self, path: &Path) -> bool { + fn matches_path(&self, mut path: &Path) -> bool { // we don't want to test files that belong to a library + path = path.strip_prefix(&self.paths.root).unwrap_or(path); self.args_filter.matches_path(path) && !self.paths.has_library_ancestor(path) } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 5aad1848a477f..5872cc72e9245 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -526,3 +526,18 @@ contract GasLimitTest is Test { cmd.args(["test", "-vvvv", "--isolate", "--disable-block-gas-limit"]).assert_success(); }); + +forgetest!(test_match_path, |prj, cmd| { + prj.add_source( + "dummy", + r" +contract Dummy { + function testDummy() public {} +} +", + ) + .unwrap(); + + cmd.args(["test", "--match-path", "src/dummy.sol"]); + cmd.assert_success() +}); From 0c961f742a0a567edf4618b9e6f12d286bc3a51c Mon Sep 17 00:00:00 2001 From: Hoa Lee - Icetea <95201916+hoaleee@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:18:33 +0700 Subject: [PATCH 0820/1963] Make batch size as a option (#7540) * batch size as a option * Update crates/script/src/broadcast.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/script/src/broadcast.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/script/src/lib.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/script/src/lib.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/script/src/lib.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/script/src/broadcast.rs | 3 ++- crates/script/src/lib.rs | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 224bcc44cf45d..04329891d28f6 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -321,7 +321,8 @@ impl BundledState { // We send transactions and wait for receipts in batches of 100, since some networks // cannot handle more than that. - let batch_size = if sequential_broadcast { 1 } else { 100 }; + let valid_batch_size = self.args.batch_size.min(100); + let batch_size = if sequential_broadcast { 1 } else { valid_batch_size }; let mut index = already_broadcasted; for (batch_number, batch) in diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index fc8678b41e7f5..1f002d4bbc6e7 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -107,6 +107,10 @@ pub struct ScriptArgs { #[arg(long)] pub broadcast: bool, + /// Batch size of transactions. + #[arg(long, default_value = "100")] + pub batch_size: usize, + /// Skips on-chain simulation. #[arg(long)] pub skip_simulation: bool, From 72bc4f4e616c6e2b79ee3582301fbb1d38660857 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 7 Apr 2024 10:48:16 +0200 Subject: [PATCH 0821/1963] chore: improve script tx batch size logic (#7583) --- crates/script/src/broadcast.rs | 22 +++++++++------------- crates/script/src/lib.rs | 2 ++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 04329891d28f6..983c02374fb61 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -319,15 +319,11 @@ impl BundledState { let pb = init_progress!(transactions, "txes"); - // We send transactions and wait for receipts in batches of 100, since some networks - // cannot handle more than that. - let valid_batch_size = self.args.batch_size.min(100); - let batch_size = if sequential_broadcast { 1 } else { valid_batch_size }; + // We send transactions and wait for receipts in batches. + let batch_size = if sequential_broadcast { 1 } else { self.args.batch_size }; let mut index = already_broadcasted; - for (batch_number, batch) in - transactions.chunks(batch_size).map(|f| f.to_vec()).enumerate() - { + for (batch_number, batch) in transactions.chunks(batch_size).enumerate() { let mut pending_transactions = vec![]; shell::println(format!( @@ -335,17 +331,17 @@ impl BundledState { batch_number * batch_size, batch_number * batch_size + std::cmp::min(batch_size, batch.len()) - 1 ))?; - for (tx, kind, is_fixed_gas_limit) in batch.into_iter() { - let tx_hash = send_transaction( + for (tx, kind, is_fixed_gas_limit) in batch { + let fut = send_transaction( provider.clone(), - tx, - kind, + tx.clone(), + kind.clone(), sequential_broadcast, - is_fixed_gas_limit, + *is_fixed_gas_limit, estimate_via_rpc, self.args.gas_estimate_multiplier, ); - pending_transactions.push(tx_hash); + pending_transactions.push(fut); } if !pending_transactions.is_empty() { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 1f002d4bbc6e7..5b27a5ff420eb 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -108,6 +108,8 @@ pub struct ScriptArgs { pub broadcast: bool, /// Batch size of transactions. + /// + /// This is ignored and set to 1 if batching is not available or `--slow` is enabled. #[arg(long, default_value = "100")] pub batch_size: usize, From 61f046d528966d5fa97157c11b84795bb611a6e4 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 8 Apr 2024 12:54:07 +0400 Subject: [PATCH 0822/1963] fix: use `alloy-trie` for `eth_getProof` (#7546) * use alloy-trie for eth_getProof * fmt * collect proofs via single pass * fixes and test * tests * add files * ordered_trie_root * clippy * move to workspace --- Cargo.lock | 189 +++-------- Cargo.toml | 1 + crates/anvil/Cargo.toml | 4 +- crates/anvil/core/Cargo.toml | 10 +- crates/anvil/core/src/eth/trie.rs | 48 ++- crates/anvil/src/config.rs | 10 + crates/anvil/src/eth/backend/db.rs | 49 +-- crates/anvil/src/eth/backend/genesis.rs | 8 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 6 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 25 +- crates/anvil/src/eth/backend/mem/mod.rs | 150 ++++----- crates/anvil/src/eth/backend/mem/state.rs | 90 +++--- crates/anvil/src/eth/backend/mem/storage.rs | 2 +- crates/anvil/test-data/storage_sample.json | 33 ++ crates/anvil/tests/it/proof.rs | 134 ++++++++ crates/anvil/tests/it/proof/eip1186.rs | 297 ------------------ crates/anvil/tests/it/proof/mod.rs | 76 ----- 17 files changed, 367 insertions(+), 765 deletions(-) create mode 100644 crates/anvil/test-data/storage_sample.json create mode 100644 crates/anvil/tests/it/proof.rs delete mode 100644 crates/anvil/tests/it/proof/eip1186.rs delete mode 100644 crates/anvil/tests/it/proof/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 87931fb8f2516..6e48a7bc30f81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,17 +38,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom 0.2.12", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.11" @@ -438,6 +427,22 @@ dependencies = [ "ws_stream_wasm", ] +[[package]] +name = "alloy-trie" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b9e1498416f7e7f09af8061970e14936846b6271e153aa5ba539a22a7eb414d" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "derive_more", + "hashbrown", + "nybbles", + "serde", + "smallvec", + "tracing", +] + [[package]] name = "ammonia" version = "3.3.0" @@ -538,6 +543,7 @@ dependencies = [ "alloy-signer", "alloy-sol-types", "alloy-transport", + "alloy-trie", "anvil-core", "anvil-rpc", "anvil-server", @@ -563,11 +569,9 @@ dependencies = [ "foundry-config", "foundry-evm", "futures", - "hash-db", "hyper 0.14.28", "itertools 0.12.1", "k256", - "memory-db", "parking_lot", "pretty_assertions", "rand 0.8.5", @@ -581,7 +585,6 @@ dependencies = [ "tower", "tracing", "tracing-subscriber", - "trie-db", "vergen", "yansi 0.5.1", ] @@ -598,20 +601,16 @@ dependencies = [ "alloy-rlp", "alloy-rpc-trace-types", "alloy-rpc-types", + "alloy-trie", "anvil-core", "bytes", "c-kzg", "foundry-common", "foundry-evm", - "hash-db", - "hash256-std-hasher", - "keccak-hasher", "rand 0.8.5", - "reference-trie", "revm", "serde", "serde_json", - "triehash", ] [[package]] @@ -1988,7 +1987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.3", + "hashbrown", "lock_api", "once_cell", "parking_lot_core", @@ -4104,37 +4103,13 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - -[[package]] -name = "hash256-std-hasher" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] - [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.11", + "ahash", "allocator-api2", "serde", ] @@ -4561,7 +4536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown", ] [[package]] @@ -4780,17 +4755,6 @@ dependencies = [ "sha3-asm", ] -[[package]] -name = "keccak-hasher" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711adba9940a039f4374fc5724c0a5eaca84a2d558cce62256bfe26f0dbef05e" -dependencies = [ - "hash-db", - "hash256-std-hasher", - "tiny-keccak", -] - [[package]] name = "kqueue" version = "1.0.8" @@ -4912,7 +4876,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.14.3", + "hashbrown", ] [[package]] @@ -5038,17 +5002,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memory-db" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a" -dependencies = [ - "hash-db", - "hashbrown 0.12.3", - "parity-util-mem", -] - [[package]] name = "miette" version = "5.10.0" @@ -5354,6 +5307,19 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" +[[package]] +name = "nybbles" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95f06be0417d97f81fe4e5c86d7d01b392655a9cac9c19a848aa033e18937b23" +dependencies = [ + "alloy-rlp", + "const-hex", + "proptest", + "serde", + "smallvec", +] + [[package]] name = "object" version = "0.32.2" @@ -5531,31 +5497,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "parity-util-mem" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f" -dependencies = [ - "cfg-if", - "hashbrown 0.12.3", - "impl-trait-for-tuples", - "parity-util-mem-derive", - "parking_lot", - "winapi", -] - -[[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "parking" version = "2.2.0" @@ -6309,20 +6250,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "reference-trie" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f63dfce83d1e0e80cf2dc5222df5c2bc30992b30c44d1e66e7c9793d3a418e4" -dependencies = [ - "hash-db", - "hash256-std-hasher", - "keccak-hasher", - "parity-scale-codec", - "trie-db", - "trie-root", -] - [[package]] name = "regex" version = "1.10.4" @@ -6526,7 +6453,7 @@ dependencies = [ "cfg-if", "dyn-clone", "enumn", - "hashbrown 0.14.3", + "hashbrown", "hex", "serde", ] @@ -7691,18 +7618,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "system-configuration" version = "0.5.1" @@ -8267,38 +8182,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "trie-db" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" -dependencies = [ - "hash-db", - "hashbrown 0.12.3", - "log", - "rustc-hex", - "smallvec", -] - -[[package]] -name = "trie-root" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a36c5ca3911ed3c9a5416ee6c679042064b93fc637ded67e25f92e68d783891" -dependencies = [ - "hash-db", -] - -[[package]] -name = "triehash" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" -dependencies = [ - "hash-db", - "rlp", -] - [[package]] name = "try-lock" version = "0.2.5" diff --git a/Cargo.toml b/Cargo.toml index a7804cc453e4d..661bcb128ce0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,6 +184,7 @@ alloy-json-abi = "0.6.3" alloy-sol-types = "0.6.3" syn-solidity = "0.6.3" alloy-chains = "0.1" +alloy-trie = "0.3" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 7a554a02283d2..4ccbfadddafb7 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -32,9 +32,6 @@ foundry-evm.workspace = true bytes = "1.4.0" k256.workspace = true ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } -trie-db = "0.23" -hash-db = "0.15" -memory-db = "0.29" alloy-primitives = { workspace = true, features = ["serde"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-network.workspace = true @@ -48,6 +45,7 @@ alloy-providers.workspace = true alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true +alloy-trie.workspace = true # axum related axum.workspace = true diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 6b6041ce54ab7..999c606899831 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -20,21 +20,15 @@ alloy-rpc-trace-types.workspace = true alloy-rlp.workspace = true alloy-eips.workspace = true alloy-network = { workspace = true, features = ["k256"] } -alloy-consensus = { workspace = true, features = ["k256", "kzg"]} +alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } +alloy-trie.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true bytes = "1.4" c-kzg = { version = "0.4.2", features = ["serde"] } -# trie -hash-db = { version = "0.15", default-features = false } -hash256-std-hasher = { version = "0.15", default-features = false } -triehash = { version = "0.8", default-features = false } -reference-trie = "0.25" -keccak-hasher = "0.15" - # misc rand = "0.8" diff --git a/crates/anvil/core/src/eth/trie.rs b/crates/anvil/core/src/eth/trie.rs index 5d144a5db13ca..bcc86ac8ba36b 100644 --- a/crates/anvil/core/src/eth/trie.rs +++ b/crates/anvil/core/src/eth/trie.rs @@ -1,36 +1,12 @@ //! Utility functions for Ethereum adapted from https://github.dev/rust-blockchain/ethereum/blob/755dffaa4903fbec1269f50cde9863cf86269a14/src/util.rs -use alloy_primitives::B256; +use std::collections::BTreeMap; -pub use keccak_hasher::KeccakHasher; - -// reexport some trie types -pub use reference_trie::*; +use alloy_primitives::{fixed_bytes, B256}; +use alloy_trie::{HashBuilder, Nibbles}; /// The KECCAK of the RLP encoding of empty data. -pub const KECCAK_NULL_RLP: B256 = B256::new([ - 0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, - 0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21, -]); - -/// Generates a trie root hash for a vector of key-value tuples -pub fn trie_root(input: I) -> B256 -where - I: IntoIterator, - K: AsRef<[u8]> + Ord, - V: AsRef<[u8]>, -{ - B256::from(triehash::trie_root::(input)) -} - -/// Generates a key-hashed (secure) trie root hash for a vector of key-value tuples. -pub fn sec_trie_root(input: I) -> B256 -where - I: IntoIterator, - K: AsRef<[u8]>, - V: AsRef<[u8]>, -{ - B256::from(triehash::sec_trie_root::(input)) -} +pub const KECCAK_NULL_RLP: B256 = + fixed_bytes!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); /// Generates a trie root hash for a vector of values pub fn ordered_trie_root(input: I) -> B256 @@ -38,5 +14,17 @@ where I: IntoIterator, V: AsRef<[u8]>, { - B256::from(triehash::ordered_trie_root::(input)) + let mut builder = HashBuilder::default(); + + let input = input + .into_iter() + .enumerate() + .map(|(i, v)| (alloy_rlp::encode(i), v)) + .collect::>(); + + for (key, value) in input { + builder.add_leaf(Nibbles::unpack(key), value.as_ref()); + } + + builder.root() } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 96e7896ebc1d6..a1e736619250f 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -358,6 +358,16 @@ impl NodeConfig { pub fn test() -> Self { Self { enable_tracing: true, silent: true, port: 0, ..Default::default() } } + + /// Returns a new config which does not initialize any accounts on node startup. + pub fn empty_state() -> Self { + Self { + genesis_accounts: vec![], + signer_accounts: vec![], + disable_default_create2_deployer: true, + ..Default::default() + } + } } impl Default for NodeConfig { diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 31e60ddbe4f50..6149c01080f6b 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -1,9 +1,8 @@ //! Helper types for working with [revm](foundry_evm::revm) -use crate::{mem::state::trie_hash_db, revm::primitives::AccountInfo}; +use crate::revm::primitives::AccountInfo; use alloy_primitives::{keccak256, Address, Bytes, B256, U256, U64}; use alloy_rpc_types::BlockId; -use anvil_core::eth::trie::KeccakHasher; use foundry_common::errors::FsPathError; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot}, @@ -14,22 +13,13 @@ use foundry_evm::{ Database, DatabaseCommit, }, }; -use hash_db::HashDB; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt, path::Path}; -/// Type alias for the `HashDB` representation of the Database -pub type AsHashDB = Box>>; - -/// Helper trait get access to the data in `HashDb` form +/// Helper trait get access to the full state data of the database #[auto_impl::auto_impl(Box)] -pub trait MaybeHashDatabase: DatabaseRef { - /// Return the DB as read-only hashdb and the root key - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { - None - } - /// Return the storage DB as read-only hashdb and the storage root of the account - fn maybe_account_db(&self, _addr: Address) -> Option<(AsHashDB, B256)> { +pub trait MaybeFullDatabase: DatabaseRef { + fn maybe_as_full_db(&self) -> Option<&HashMap> { None } @@ -43,15 +33,12 @@ pub trait MaybeHashDatabase: DatabaseRef { fn init_from_snapshot(&mut self, snapshot: StateSnapshot); } -impl<'a, T: 'a + MaybeHashDatabase + ?Sized> MaybeHashDatabase for &'a T +impl<'a, T: 'a + MaybeFullDatabase + ?Sized> MaybeFullDatabase for &'a T where &'a T: DatabaseRef, { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { - T::maybe_as_hash_db(self) - } - fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, B256)> { - T::maybe_account_db(self, addr) + fn maybe_as_full_db(&self) -> Option<&HashMap> { + T::maybe_as_full_db(self) } fn clear_into_snapshot(&mut self) -> StateSnapshot { @@ -79,7 +66,7 @@ pub trait Db: DatabaseRef + Database + DatabaseCommit - + MaybeHashDatabase + + MaybeFullDatabase + MaybeForkedDatabase + fmt::Debug + Send @@ -220,9 +207,9 @@ impl + Send + Sync + Clone + fmt::Debug> D } } -impl> MaybeHashDatabase for CacheDB { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { - Some(trie_hash_db(&self.accounts)) +impl> MaybeFullDatabase for CacheDB { + fn maybe_as_full_db(&self) -> Option<&HashMap> { + Some(&self.accounts) } fn clear_into_snapshot(&mut self) -> StateSnapshot { @@ -279,12 +266,12 @@ impl> MaybeForkedDatabase for CacheDB { } /// Represents a state at certain point -pub struct StateDb(pub(crate) Box); +pub struct StateDb(pub(crate) Box); // === impl StateDB === impl StateDb { - pub fn new(db: impl MaybeHashDatabase + Send + Sync + 'static) -> Self { + pub fn new(db: impl MaybeFullDatabase + Send + Sync + 'static) -> Self { Self(Box::new(db)) } } @@ -308,13 +295,9 @@ impl DatabaseRef for StateDb { } } -impl MaybeHashDatabase for StateDb { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { - self.0.maybe_as_hash_db() - } - - fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, B256)> { - self.0.maybe_account_db(addr) +impl MaybeFullDatabase for StateDb { + fn maybe_as_full_db(&self) -> Option<&HashMap> { + self.0.maybe_as_full_db() } fn clear_into_snapshot(&mut self) -> StateSnapshot { diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 14197b63d9bab..bbfbda55edc8d 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -1,6 +1,6 @@ //! Genesis settings -use crate::eth::backend::db::{Db, MaybeHashDatabase}; +use crate::eth::backend::db::{Db, MaybeFullDatabase}; use alloy_genesis::{Genesis, GenesisAccount}; use alloy_primitives::{Address, B256, U256}; use foundry_evm::{ @@ -84,7 +84,7 @@ impl GenesisConfig { /// [AccountInfo] pub(crate) fn state_db_at_genesis<'a>( &self, - db: Box, + db: Box, ) -> AtGenesisStateDb<'a> { AtGenesisStateDb { genesis: self.genesis_init.clone(), @@ -103,7 +103,7 @@ impl GenesisConfig { pub(crate) struct AtGenesisStateDb<'a> { genesis: Option, accounts: HashMap, - db: Box, + db: Box, } impl<'a> DatabaseRef for AtGenesisStateDb<'a> { @@ -138,7 +138,7 @@ impl<'a> DatabaseRef for AtGenesisStateDb<'a> { } } -impl<'a> MaybeHashDatabase for AtGenesisStateDb<'a> { +impl<'a> MaybeFullDatabase for AtGenesisStateDb<'a> { fn clear_into_snapshot(&mut self) -> StateSnapshot { self.db.clear_into_snapshot() } diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 7f9262fd6e568..d99aeb5ed415b 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -1,6 +1,6 @@ use crate::{ eth::backend::db::{ - Db, MaybeForkedDatabase, MaybeHashDatabase, SerializableAccountRecord, SerializableState, + Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableState, StateDb, }, revm::primitives::AccountInfo, @@ -81,7 +81,7 @@ impl Db for ForkedDatabase { } } -impl MaybeHashDatabase for ForkedDatabase { +impl MaybeFullDatabase for ForkedDatabase { fn clear_into_snapshot(&mut self) -> StateSnapshot { let db = self.inner().db(); let accounts = std::mem::take(&mut *db.accounts.write()); @@ -104,7 +104,7 @@ impl MaybeHashDatabase for ForkedDatabase { } } -impl MaybeHashDatabase for ForkDbSnapshot { +impl MaybeFullDatabase for ForkDbSnapshot { fn clear_into_snapshot(&mut self) -> StateSnapshot { std::mem::take(&mut self.snapshot) } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index c6ebc8a91f97d..1c96a0eb585f6 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -2,17 +2,18 @@ use crate::{ eth::backend::db::{ - AsHashDB, Db, MaybeForkedDatabase, MaybeHashDatabase, SerializableAccountRecord, - SerializableState, StateDb, + Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableState, + StateDb, }, - mem::state::{state_merkle_trie_root, storage_trie_db, trie_hash_db}, - revm::primitives::AccountInfo, + mem::state::state_root, + revm::{db::DbAccount, primitives::AccountInfo}, }; use alloy_primitives::{Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ backend::{DatabaseResult, StateSnapshot}, fork::BlockchainDb, + hashbrown::HashMap, }; // reexport for convenience @@ -90,7 +91,7 @@ impl Db for MemDb { } fn maybe_state_root(&self) -> Option { - Some(state_merkle_trie_root(&self.inner.accounts)) + Some(state_root(&self.inner.accounts)) } fn current_state(&self) -> StateDb { @@ -98,17 +99,9 @@ impl Db for MemDb { } } -impl MaybeHashDatabase for MemDb { - fn maybe_as_hash_db(&self) -> Option<(AsHashDB, B256)> { - Some(trie_hash_db(&self.inner.accounts)) - } - - fn maybe_account_db(&self, addr: Address) -> Option<(AsHashDB, B256)> { - if let Some(acc) = self.inner.accounts.get(&addr) { - Some(storage_trie_db(&acc.storage)) - } else { - Some(storage_trie_db(&Default::default())) - } +impl MaybeFullDatabase for MemDb { + fn maybe_as_full_db(&self) -> Option<&HashMap> { + Some(&self.inner.accounts) } fn clear_into_snapshot(&mut self) -> StateSnapshot { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index a60ba56408fa7..da49d8d35eecb 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1,14 +1,18 @@ //! In memory blockchain backend +use self::state::trie_storage; use crate::{ config::PruneStateHistoryConfig, eth::{ backend::{ cheats::CheatsManager, - db::{AsHashDB, Db, MaybeHashDatabase, SerializableState}, + db::{Db, MaybeFullDatabase, SerializableState}, executor::{ExecutedTransactions, TransactionExecutor}, fork::ClientFork, genesis::GenesisConfig, - mem::storage::MinedTransactionReceipt, + mem::{ + state::{storage_root, trie_accounts}, + storage::MinedTransactionReceipt, + }, notifications::{NewBlockNotification, NewBlockNotifications}, time::{utc_from_secs, TimeManager}, validate::TransactionValidator, @@ -32,7 +36,6 @@ use crate::{ use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; use alloy_network::Sealable; use alloy_primitives::{keccak256, Address, Bytes, TxHash, B256, B64, U128, U256, U64, U8}; -use alloy_rlp::Decodable; use alloy_rpc_trace_types::{ geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, @@ -40,18 +43,17 @@ use alloy_rpc_trace_types::{ use alloy_rpc_types::{ request::TransactionRequest, state::StateOverride, AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, EIP1186AccountProofResponse as AccountProof, - EIP1186StorageProof as StorageProof, Filter, FilteredParams, Header as AlloyHeader, Log, - Transaction, TransactionReceipt, + EIP1186StorageProof as StorageProof, Filter, FilteredParams, Header as AlloyHeader, + JsonStorageKey, Log, Transaction, TransactionReceipt, }; +use alloy_trie::{HashBuilder, Nibbles}; use anvil_core::{ eth::{ block::{Block, BlockInfo}, - proof::BasicAccount, transaction::{ MaybeImpersonatedTransaction, PendingTransaction, TransactionInfo, TypedReceipt, TypedTransaction, }, - trie::RefTrieDB, utils::{alloy_to_revm_access_list, meets_eip155}, }, types::{Forking, Index}, @@ -76,19 +78,16 @@ use foundry_evm::{ utils::new_evm_with_inspector_ref, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; -use hash_db::HashDB; use parking_lot::{Mutex, RwLock}; -use revm::primitives::ResultAndState; +use revm::primitives::{HashMap, ResultAndState}; use std::{ - collections::{BTreeMap, HashMap}, + collections::BTreeMap, io::{Read, Write}, - ops::Deref, sync::Arc, time::Duration, }; use storage::{Blockchain, MinedTransaction}; use tokio::sync::RwLock as AsyncRwLock; -use trie_db::{Recorder, Trie}; pub mod cache; pub mod fork_db; @@ -848,7 +847,7 @@ impl Backend { f: F, ) -> T where - F: FnOnce(Box, BlockInfo) -> T, + F: FnOnce(Box, BlockInfo) -> T, { let db = self.db.read().await; let env = self.next_env(); @@ -1631,7 +1630,7 @@ impl Backend { f: F, ) -> Result where - F: FnOnce(Box, BlockEnv) -> T, + F: FnOnce(Box, BlockEnv) -> T, { let block_number = match block_request { Some(BlockRequest::Pending(pool_transactions)) => { @@ -2175,74 +2174,41 @@ impl Backend { keys: Vec, block_request: Option, ) -> Result { - let account_key = B256::from(alloy_primitives::utils::keccak256(address)); let block_number = block_request.as_ref().map(|r| r.block_number()); self.with_database_at(block_request, |block_db, _| { trace!(target: "backend", "get proof for {:?} at {:?}", address, block_number); - let (db, root) = block_db.maybe_as_hash_db().ok_or(BlockchainError::DataUnavailable)?; + let db = block_db.maybe_as_full_db().ok_or(BlockchainError::DataUnavailable)?; + let account = db.get(&address).cloned().unwrap_or_default(); - let data: &dyn HashDB<_, _> = db.deref(); - let mut recorder = Recorder::new(); - let trie = RefTrieDB::new(&data, &root.0) - .map_err(|err| BlockchainError::TrieError(err.to_string()))?; + let mut builder = HashBuilder::default() + .with_proof_retainer(vec![Nibbles::unpack(keccak256(address))]); - let maybe_account: Option = { - let acc_decoder = |mut bytes: &[u8]| { - BasicAccount::decode(&mut bytes).unwrap_or_else(|_| { - panic!("prove_account_at, could not query trie for account={:?}", &address) - }) - }; - let query = (&mut recorder, acc_decoder); - trie.get_with(account_key.as_slice(), query) - .map_err(|err| BlockchainError::TrieError(err.to_string()))? - }; - let account = maybe_account.unwrap_or_default(); - - let proof = recorder - .drain() - .into_iter() - .map(|r| r.data) - .map(|record| { - // proof is rlp encoded: - // - // - alloy_rlp::encode(record).to_vec().into() - }) - .collect::>(); - - let account_db = - block_db.maybe_account_db(address).ok_or(BlockchainError::DataUnavailable)?; + for (key, account) in trie_accounts(db) { + builder.add_leaf(key, &account); + } + + let _ = builder.root(); + + let proof = builder.take_proofs().values().cloned().collect::>(); + let storage_proofs = prove_storage(&account.storage, &keys); let account_proof = AccountProof { address, - balance: account.balance, - nonce: account.nonce.to::(), - code_hash: account.code_hash, - storage_hash: account.storage_root, + balance: account.info.balance, + nonce: U64::from(account.info.nonce), + code_hash: account.info.code_hash, + storage_hash: storage_root(&account.storage), account_proof: proof, storage_proof: keys .into_iter() - .map(|storage_key| { - // the key that should be proofed is the keccak256 of the storage key - let key = B256::from(keccak256(storage_key)); - prove_storage(&account, &account_db.0, key).map( - |(storage_proof, storage_value)| StorageProof { - key: alloy_rpc_types::JsonStorageKey(storage_key), - value: U256::from_be_bytes(storage_value.0), - proof: storage_proof - .into_iter() - .map(|proof| { - // proof is rlp encoded: - // - // - alloy_rlp::encode(proof).to_vec().into() - }) - .collect(), - }, - ) + .zip(storage_proofs) + .map(|(key, proof)| { + let storage_key: U256 = key.into(); + let value = account.storage.get(&storage_key).cloned().unwrap_or_default(); + StorageProof { key: JsonStorageKey(key), value, proof } }) - .collect::, _>>()?, + .collect(), }; Ok(account_proof) @@ -2464,25 +2430,29 @@ pub fn transaction_build( /// `storage_key` is the hash of the desired storage key, meaning /// this will only work correctly under a secure trie. /// `storage_key` == keccak(key) -pub fn prove_storage( - acc: &BasicAccount, - data: &AsHashDB, - storage_key: B256, -) -> Result<(Vec>, B256), BlockchainError> { - let data: &dyn HashDB<_, _> = data.deref(); - let mut recorder = Recorder::new(); - let trie = RefTrieDB::new(&data, &acc.storage_root.0) - .map_err(|err| BlockchainError::TrieError(err.to_string())) - .unwrap(); - - let item: U256 = { - let decode_value = - |mut bytes: &[u8]| U256::decode(&mut bytes).expect("decoding db value failed"); - let query = (&mut recorder, decode_value); - trie.get_with(storage_key.as_slice(), query) - .map_err(|err| BlockchainError::TrieError(err.to_string()))? - .unwrap_or(U256::ZERO) - }; - - Ok((recorder.drain().into_iter().map(|r| r.data).collect(), B256::from(item))) +pub fn prove_storage(storage: &HashMap, keys: &[B256]) -> Vec> { + let keys: Vec<_> = keys.iter().map(|key| Nibbles::unpack(keccak256(key))).collect(); + + let mut builder = HashBuilder::default().with_proof_retainer(keys.clone()); + + for (key, value) in trie_storage(storage) { + builder.add_leaf(key, &value); + } + + let _ = builder.root(); + + let mut proofs = Vec::new(); + let all_proof_nodes = builder.take_proofs(); + + for proof_key in keys { + // Iterate over all proof nodes and find the matching ones. + // The filtered results are guaranteed to be in order. + let matching_proof_nodes = all_proof_nodes + .iter() + .filter(|(path, _)| proof_key.starts_with(path)) + .map(|(_, node)| node.clone()); + proofs.push(matching_proof_nodes.collect()); + } + + proofs } diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index 29a774f182ee3..fb8be9b99cdc3 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -1,10 +1,10 @@ //! Support for generating the state root for memdb storage -use crate::eth::{backend::db::AsHashDB, error::BlockchainError}; -use alloy_primitives::{Address, Bytes, B256, U256}; +use crate::eth::error::BlockchainError; +use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_rlp::Encodable; use alloy_rpc_types::state::StateOverride; -use anvil_core::eth::trie::RefSecTrieDBMut; +use alloy_trie::{HashBuilder, Nibbles}; use foundry_evm::{ backend::DatabaseError, revm::{ @@ -12,74 +12,62 @@ use foundry_evm::{ primitives::{AccountInfo, Bytecode, HashMap}, }, }; -use memory_db::HashKey; -use trie_db::TrieMut; -/// Returns storage trie of an account as `HashDB` -pub fn storage_trie_db(storage: &HashMap) -> (AsHashDB, B256) { - // Populate DB with full trie from entries. - let (db, root) = { - let mut db = , _>>::default(); - let mut root = Default::default(); - { - let mut trie = RefSecTrieDBMut::new(&mut db, &mut root); - for (k, v) in storage.iter().filter(|(_k, v)| *v != &U256::from(0)) { - let key = B256::from(*k); - let mut value: Vec = Vec::new(); - U256::encode(v, &mut value); - trie.insert(key.as_slice(), value.as_ref()).unwrap(); - } - } - (db, root) - }; +pub fn build_root(values: impl IntoIterator)>) -> B256 { + let mut builder = HashBuilder::default(); + for (key, value) in values { + builder.add_leaf(key, value.as_ref()); + } + builder.root() +} - (Box::new(db), B256::from(root)) +/// Builds state root from the given accounts +pub fn state_root(accounts: &HashMap) -> B256 { + build_root(trie_accounts(accounts)) } -/// Returns the account data as `HashDB` -pub fn trie_hash_db(accounts: &HashMap) -> (AsHashDB, B256) { - let accounts = trie_accounts(accounts); +/// Builds storage root from the given storage +pub fn storage_root(storage: &HashMap) -> B256 { + build_root(trie_storage(storage)) +} - // Populate DB with full trie from entries. - let (db, root) = { - let mut db = , _>>::default(); - let mut root = Default::default(); - { - let mut trie = RefSecTrieDBMut::new(&mut db, &mut root); - for (address, value) in accounts { - trie.insert(address.as_ref(), value.as_ref()).unwrap(); - } - } - (db, root) - }; +/// Builds iterator over stored key-value pairs ready for storage trie root calculation. +pub fn trie_storage(storage: &HashMap) -> Vec<(Nibbles, Vec)> { + let mut storage = storage + .iter() + .map(|(key, value)| { + let data = alloy_rlp::encode(value); + (Nibbles::unpack(keccak256(key.to_be_bytes::<32>())), data) + }) + .collect::>(); + storage.sort_by(|(key1, _), (key2, _)| key1.cmp(key2)); - (Box::new(db), B256::from(root)) + storage } -/// Returns all RLP-encoded Accounts -pub fn trie_accounts(accounts: &HashMap) -> Vec<(Address, Bytes)> { - accounts +/// Builds iterator over stored key-value pairs ready for account trie root calculation. +pub fn trie_accounts(accounts: &HashMap) -> Vec<(Nibbles, Vec)> { + let mut accounts = accounts .iter() .map(|(address, account)| { - let storage_root = trie_account_rlp(&account.info, &account.storage); - (*address, storage_root) + let data = trie_account_rlp(&account.info, &account.storage); + (Nibbles::unpack(keccak256(*address)), data) }) - .collect() -} + .collect::>(); + accounts.sort_by(|(key1, _), (key2, _)| key1.cmp(key2)); -pub fn state_merkle_trie_root(accounts: &HashMap) -> B256 { - trie_hash_db(accounts).1 + accounts } /// Returns the RLP for this account. -pub fn trie_account_rlp(info: &AccountInfo, storage: &HashMap) -> Bytes { +pub fn trie_account_rlp(info: &AccountInfo, storage: &HashMap) -> Vec { let mut out: Vec = Vec::new(); let list: [&dyn Encodable; 4] = - [&info.nonce, &info.balance, &storage_trie_db(storage).1, &info.code_hash]; + [&info.nonce, &info.balance, &storage_root(storage), &info.code_hash]; alloy_rlp::encode_list::<_, dyn Encodable>(&list, &mut out); - out.into() + out } /// Applies the given state overrides to the state, returning a new CacheDB state diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 0e2ac2b636ad8..8d72b30f1299b 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -1,7 +1,7 @@ //! In-memory blockchain storage use crate::eth::{ backend::{ - db::{MaybeHashDatabase, StateDb}, + db::{MaybeFullDatabase, StateDb}, mem::cache::DiskStateCache, }, pool::transactions::PoolTransaction, diff --git a/crates/anvil/test-data/storage_sample.json b/crates/anvil/test-data/storage_sample.json new file mode 100644 index 0000000000000..7e2daf48f45b6 --- /dev/null +++ b/crates/anvil/test-data/storage_sample.json @@ -0,0 +1,33 @@ +{ + "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", + "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", + "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", + "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", + "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", + "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", + "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", + "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", + "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", + "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", + "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", + "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", + "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", + "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", + "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", + "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", + "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", + "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", + "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", + "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", + "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", + "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", + "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", + "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", + "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", + "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", + "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", + "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", + "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", + "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", + "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" +} \ No newline at end of file diff --git a/crates/anvil/tests/it/proof.rs b/crates/anvil/tests/it/proof.rs new file mode 100644 index 0000000000000..d5a09e8ad9e2a --- /dev/null +++ b/crates/anvil/tests/it/proof.rs @@ -0,0 +1,134 @@ +//! tests for `eth_getProof` + +use std::{collections::BTreeMap, str::FromStr}; + +use alloy_primitives::{address, fixed_bytes, Address, Bytes, B256, U256}; +use anvil::{eth::EthApi, spawn, NodeConfig}; + +async fn verify_account_proof( + api: &EthApi, + address: Address, + proof: impl IntoIterator, +) { + let expected_proof = + proof.into_iter().map(Bytes::from_str).collect::, _>>().unwrap(); + let proof = api.get_proof(address, Vec::new(), None).await.unwrap(); + + assert_eq!(proof.account_proof, expected_proof); +} + +async fn verify_storage_proof( + api: &EthApi, + address: Address, + slot: B256, + proof: impl IntoIterator, +) { + let expected_proof = + proof.into_iter().map(Bytes::from_str).collect::, _>>().unwrap(); + let proof = api.get_proof(address, vec![slot], None).await.unwrap(); + + assert_eq!(proof.storage_proof[0].proof, expected_proof); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_account_proof() { + let (api, _handle) = spawn(NodeConfig::empty_state()).await; + + api.anvil_set_balance( + address!("2031f89b3ea8014eb51a78c316e42af3e0d7695f"), + U256::from(45000000000000000000_u128), + ) + .await + .unwrap(); + api.anvil_set_balance(address!("33f0fc440b8477fcfbe9d0bf8649e7dea9baedb2"), U256::from(1)) + .await + .unwrap(); + api.anvil_set_balance( + address!("62b0dd4aab2b1a0a04e279e2b828791a10755528"), + U256::from(1100000000000000000_u128), + ) + .await + .unwrap(); + api.anvil_set_balance( + address!("1ed9b1dd266b607ee278726d324b855a093394a6"), + U256::from(120000000000000000_u128), + ) + .await + .unwrap(); + + verify_account_proof(&api, address!("2031f89b3ea8014eb51a78c316e42af3e0d7695f"), [ + "0xe48200a7a040f916999be583c572cc4dd369ec53b0a99f7de95f13880cf203d98f935ed1b3", + "0xf87180a04fb9bab4bb88c062f32452b7c94c8f64d07b5851d44a39f1e32ba4b1829fdbfb8080808080a0b61eeb2eb82808b73c4ad14140a2836689f4ab8445d69dd40554eaf1fce34bc080808080808080a0dea230ff2026e65de419288183a340125b04b8405cc61627b3b4137e2260a1e880", + "0xf8719f31355ec1c8f7e26bb3ccbcb0b75d870d15846c0b98e5cc452db46c37faea40b84ff84d80890270801d946c940000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" + ]).await; + + verify_account_proof(&api, address!("33f0fc440b8477fcfbe9d0bf8649e7dea9baedb2"), [ + "0xe48200a7a040f916999be583c572cc4dd369ec53b0a99f7de95f13880cf203d98f935ed1b3", + "0xf87180a04fb9bab4bb88c062f32452b7c94c8f64d07b5851d44a39f1e32ba4b1829fdbfb8080808080a0b61eeb2eb82808b73c4ad14140a2836689f4ab8445d69dd40554eaf1fce34bc080808080808080a0dea230ff2026e65de419288183a340125b04b8405cc61627b3b4137e2260a1e880", + "0xe48200d3a0ef957210bca5b9b402d614eb8408c88cfbf4913eb6ab83ca233c8b8f0e626b54", + "0xf851808080a02743a5addaf4cf9b8c0c073e1eaa555deaaf8c41cb2b41958e88624fa45c2d908080808080a0bfbf6937911dfb88113fecdaa6bde822e4e99dae62489fcf61a91cb2f36793d680808080808080", + "0xf8679e207781e762f3577784bab7491fcc43e291ce5a356b9bc517ac52eed3a37ab846f8448001a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + ]).await; + + verify_account_proof(&api, address!("62b0dd4aab2b1a0a04e279e2b828791a10755528"), [ + "0xe48200a7a040f916999be583c572cc4dd369ec53b0a99f7de95f13880cf203d98f935ed1b3", + "0xf87180a04fb9bab4bb88c062f32452b7c94c8f64d07b5851d44a39f1e32ba4b1829fdbfb8080808080a0b61eeb2eb82808b73c4ad14140a2836689f4ab8445d69dd40554eaf1fce34bc080808080808080a0dea230ff2026e65de419288183a340125b04b8405cc61627b3b4137e2260a1e880", + "0xf8709f3936599f93b769acf90c7178fd2ddcac1b5b4bc9949ee5a04b7e0823c2446eb84ef84c80880f43fc2c04ee0000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + ]).await; + + verify_account_proof(&api, address!("1ed9b1dd266b607ee278726d324b855a093394a6"), [ + "0xe48200a7a040f916999be583c572cc4dd369ec53b0a99f7de95f13880cf203d98f935ed1b3", + "0xf87180a04fb9bab4bb88c062f32452b7c94c8f64d07b5851d44a39f1e32ba4b1829fdbfb8080808080a0b61eeb2eb82808b73c4ad14140a2836689f4ab8445d69dd40554eaf1fce34bc080808080808080a0dea230ff2026e65de419288183a340125b04b8405cc61627b3b4137e2260a1e880", + "0xe48200d3a0ef957210bca5b9b402d614eb8408c88cfbf4913eb6ab83ca233c8b8f0e626b54", + "0xf851808080a02743a5addaf4cf9b8c0c073e1eaa555deaaf8c41cb2b41958e88624fa45c2d908080808080a0bfbf6937911dfb88113fecdaa6bde822e4e99dae62489fcf61a91cb2f36793d680808080808080", + "0xf86f9e207a32b8ab5eb4b043c65b1f00c93f517bc8883c5cd31baf8e8a279475e3b84ef84c808801aa535d3d0c0000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" + ]).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_storage_proof() { + let target = address!("1ed9b1dd266b607ee278726d324b855a093394a6"); + + let (api, _handle) = spawn(NodeConfig::empty_state()).await; + let storage: BTreeMap = + serde_json::from_str(include_str!("../../test-data/storage_sample.json")).unwrap(); + + for (key, value) in storage { + api.anvil_set_storage_at(target, key, value).await.unwrap(); + } + + verify_storage_proof(&api, target, fixed_bytes!("0000000000000000000000000000000000000000000000000000000000000022"), [ + "0xf9019180a0aafd5b14a6edacd149e110ba6776a654f2dbffca340902be933d011113f2750380a0a502c93b1918c4c6534d4593ae03a5a23fa10ebc30ffb7080b297bff2446e42da02eb2bf45fd443bd1df8b6f9c09726a4c6252a0f7896a131a081e39a7f644b38980a0a9cf7f673a0bce76fd40332afe8601542910b48dea44e93933a3e5e930da5d19a0ddf79db0a36d0c8134ba143bcb541cd4795a9a2bae8aca0ba24b8d8963c2a77da0b973ec0f48f710bf79f63688485755cbe87f9d4c68326bb83c26af620802a80ea0f0855349af6bf84afc8bca2eda31c8ef8c5139be1929eeb3da4ba6b68a818cb0a0c271e189aeeb1db5d59d7fe87d7d6327bbe7cfa389619016459196497de3ccdea0e7503ba5799e77aa31bbe1310c312ca17b2c5bcc8fa38f266675e8f154c2516ba09278b846696d37213ab9d20a5eb42b03db3173ce490a2ef3b2f3b3600579fc63a0e9041059114f9c910adeca12dbba1fef79b2e2c8899f2d7213cd22dfe4310561a047c59da56bb2bf348c9dd2a2e8f5538a92b904b661cfe54a4298b85868bbe4858080", + "0xf85180a0776aa456ba9c5008e03b82b841a9cf2fc1e8578cfacd5c9015804eae315f17fb80808080808080808080808080a072e3e284d47badbb0a5ca1421e1179d3ea90cc10785b26b74fb8a81f0f9e841880", + "0xf843a020035b26e3e9eee00e0d72fd1ee8ddca6894550dca6916ea2ac6baa90d11e510a1a0f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b" + ]).await; + + verify_storage_proof(&api, target, fixed_bytes!("0000000000000000000000000000000000000000000000000000000000000023"), [ + "0xf9019180a0aafd5b14a6edacd149e110ba6776a654f2dbffca340902be933d011113f2750380a0a502c93b1918c4c6534d4593ae03a5a23fa10ebc30ffb7080b297bff2446e42da02eb2bf45fd443bd1df8b6f9c09726a4c6252a0f7896a131a081e39a7f644b38980a0a9cf7f673a0bce76fd40332afe8601542910b48dea44e93933a3e5e930da5d19a0ddf79db0a36d0c8134ba143bcb541cd4795a9a2bae8aca0ba24b8d8963c2a77da0b973ec0f48f710bf79f63688485755cbe87f9d4c68326bb83c26af620802a80ea0f0855349af6bf84afc8bca2eda31c8ef8c5139be1929eeb3da4ba6b68a818cb0a0c271e189aeeb1db5d59d7fe87d7d6327bbe7cfa389619016459196497de3ccdea0e7503ba5799e77aa31bbe1310c312ca17b2c5bcc8fa38f266675e8f154c2516ba09278b846696d37213ab9d20a5eb42b03db3173ce490a2ef3b2f3b3600579fc63a0e9041059114f9c910adeca12dbba1fef79b2e2c8899f2d7213cd22dfe4310561a047c59da56bb2bf348c9dd2a2e8f5538a92b904b661cfe54a4298b85868bbe4858080", + "0xf8518080808080a0d546c4ca227a267d29796643032422374624ed109b3d94848c5dc06baceaee76808080808080a027c48e210ccc6e01686be2d4a199d35f0e1e8df624a8d3a17c163be8861acd6680808080", + "0xf843a0207b2b5166478fd4318d2acc6cc2c704584312bdd8781b32d5d06abda57f4230a1a0db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71" + ]).await; + + verify_storage_proof(&api, target, fixed_bytes!("0000000000000000000000000000000000000000000000000000000000000024"), [ + "0xf9019180a0aafd5b14a6edacd149e110ba6776a654f2dbffca340902be933d011113f2750380a0a502c93b1918c4c6534d4593ae03a5a23fa10ebc30ffb7080b297bff2446e42da02eb2bf45fd443bd1df8b6f9c09726a4c6252a0f7896a131a081e39a7f644b38980a0a9cf7f673a0bce76fd40332afe8601542910b48dea44e93933a3e5e930da5d19a0ddf79db0a36d0c8134ba143bcb541cd4795a9a2bae8aca0ba24b8d8963c2a77da0b973ec0f48f710bf79f63688485755cbe87f9d4c68326bb83c26af620802a80ea0f0855349af6bf84afc8bca2eda31c8ef8c5139be1929eeb3da4ba6b68a818cb0a0c271e189aeeb1db5d59d7fe87d7d6327bbe7cfa389619016459196497de3ccdea0e7503ba5799e77aa31bbe1310c312ca17b2c5bcc8fa38f266675e8f154c2516ba09278b846696d37213ab9d20a5eb42b03db3173ce490a2ef3b2f3b3600579fc63a0e9041059114f9c910adeca12dbba1fef79b2e2c8899f2d7213cd22dfe4310561a047c59da56bb2bf348c9dd2a2e8f5538a92b904b661cfe54a4298b85868bbe4858080", + "0xf85180808080a030263404acfee103d0b1019053ff3240fce433c69b709831673285fa5887ce4c80808080808080a0f8f1fbb1f7b482d9860480feebb83ff54a8b6ec1ead61cc7d2f25d7c01659f9c80808080", + "0xf843a020d332d19b93bcabe3cce7ca0c18a052f57e5fd03b4758a09f30f5ddc4b22ec4a1a0c78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", + ]).await; + + verify_storage_proof(&api, target, fixed_bytes!("0000000000000000000000000000000000000000000000000000000000000100"), [ + "0xf9019180a0aafd5b14a6edacd149e110ba6776a654f2dbffca340902be933d011113f2750380a0a502c93b1918c4c6534d4593ae03a5a23fa10ebc30ffb7080b297bff2446e42da02eb2bf45fd443bd1df8b6f9c09726a4c6252a0f7896a131a081e39a7f644b38980a0a9cf7f673a0bce76fd40332afe8601542910b48dea44e93933a3e5e930da5d19a0ddf79db0a36d0c8134ba143bcb541cd4795a9a2bae8aca0ba24b8d8963c2a77da0b973ec0f48f710bf79f63688485755cbe87f9d4c68326bb83c26af620802a80ea0f0855349af6bf84afc8bca2eda31c8ef8c5139be1929eeb3da4ba6b68a818cb0a0c271e189aeeb1db5d59d7fe87d7d6327bbe7cfa389619016459196497de3ccdea0e7503ba5799e77aa31bbe1310c312ca17b2c5bcc8fa38f266675e8f154c2516ba09278b846696d37213ab9d20a5eb42b03db3173ce490a2ef3b2f3b3600579fc63a0e9041059114f9c910adeca12dbba1fef79b2e2c8899f2d7213cd22dfe4310561a047c59da56bb2bf348c9dd2a2e8f5538a92b904b661cfe54a4298b85868bbe4858080", + "0xf891a090bacef44b189ddffdc5f22edc70fe298c58e5e523e6e1dfdf7dbc6d657f7d1b80a026eed68746028bc369eb456b7d3ee475aa16f34e5eaa0c98fdedb9c59ebc53b0808080a09ce86197173e14e0633db84ce8eea32c5454eebe954779255644b45b717e8841808080a0328c7afb2c58ef3f8c4117a8ebd336f1a61d24591067ed9c5aae94796cac987d808080808080", + ]).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_get_random_account_proofs() { + let (api, _handle) = spawn(NodeConfig::test()).await; + + for acc in std::iter::repeat_with(Address::random).take(10) { + let _ = api + .get_proof(acc, Vec::new(), None) + .await + .unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}")); + } +} diff --git a/crates/anvil/tests/it/proof/eip1186.rs b/crates/anvil/tests/it/proof/eip1186.rs deleted file mode 100644 index c83cdf4f8e061..0000000000000 --- a/crates/anvil/tests/it/proof/eip1186.rs +++ /dev/null @@ -1,297 +0,0 @@ -/// Taken from https://github.com/paritytech/trie/blob/aa3168d6de01793e71ebd906d3a82ae4b363db59/trie-eip1186/src/eip1186.rs -use hash_db::Hasher; -use trie_db::{ - node::{decode_hash, Node, NodeHandle, Value}, - CError, NibbleSlice, NodeCodec, TrieHash, TrieLayout, -}; - -/// Errors that may occur during proof verification. Most of the errors types simply indicate that -/// the proof is invalid with respect to the statement being verified, and the exact error type can -/// be used for debugging. -#[derive(Debug, PartialEq, Eq)] -pub enum VerifyError<'a, HO, CE> { - /// The proof does not contain any value for the given key - /// the error carries the nibbles left after traversing the trie - NonExistingValue(NibbleSlice<'a>), - /// The proof contains a value for the given key - /// while we were expecting to find a non-existence proof - ExistingValue(Vec), - /// The proof indicates that the trie contains a different value. - /// the error carries the value contained in the trie - ValueMismatch(Vec), - /// The proof is missing trie nodes required to verify. - IncompleteProof, - /// The node hash computed from the proof is not matching. - HashMismatch(HO), - /// One of the proof nodes could not be decoded. - DecodeError(CE), - /// Error in converting a plain hash into a HO - HashDecodeError(&'a [u8]), -} - -#[cfg(feature = "std")] -impl<'a, HO: std::fmt::Debug, CE: std::error::Error> std::fmt::Display for VerifyError<'a, HO, CE> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - match self { - VerifyError::NonExistingValue(key) => { - write!(f, "Key does not exist in trie: reaming key={:?}", key) - } - VerifyError::ExistingValue(value) => { - write!(f, "trie contains a value for given key value={:?}", value) - } - VerifyError::ValueMismatch(key) => { - write!(f, "Expected value was not found in the trie: key={:?}", key) - } - VerifyError::IncompleteProof => write!(f, "Proof is incomplete -- expected more nodes"), - VerifyError::HashMismatch(hash) => write!(f, "hash mismatch found: hash={:?}", hash), - VerifyError::DecodeError(err) => write!(f, "Unable to decode proof node: {}", err), - VerifyError::HashDecodeError(plain_hash) => { - write!(f, "Unable to decode hash value plain_hash: {:?}", plain_hash) - } - } - } -} - -#[cfg(feature = "std")] -impl<'a, HO: std::fmt::Debug, CE: std::error::Error + 'static> std::error::Error - for VerifyError<'a, HO, CE> -{ - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - VerifyError::DecodeError(err) => Some(err), - _ => None, - } - } -} - -/// Verify a compact proof for key-value pairs in a trie given a root hash. -pub fn verify_proof<'a, L>( - root: &::Out, - proof: &'a [Vec], - raw_key: &'a [u8], - expected_value: Option<&[u8]>, -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - if proof.is_empty() { - return Err(VerifyError::IncompleteProof) - } - let key = NibbleSlice::new(raw_key); - process_node::(Some(root), &proof[0], key, expected_value, &proof[1..]) -} - -fn process_node<'a, L>( - expected_node_hash: Option<&::Out>, - encoded_node: &'a [u8], - key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - proof: &'a [Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - if let Some(value) = expected_value { - if encoded_node == value { - return Ok(()) - } - } - if let Some(expected) = expected_node_hash { - let calculated_node_hash = ::hash(encoded_node); - if calculated_node_hash != *expected { - return Err(VerifyError::HashMismatch(calculated_node_hash)) - } - } - let node = ::decode(encoded_node).map_err(VerifyError::DecodeError)?; - match node { - Node::Empty => process_empty::(key, expected_value, proof), - Node::Leaf(nib, data) => process_leaf::(nib, data, key, expected_value, proof), - Node::Extension(nib, handle) => { - process_extension::(&nib, handle, key, expected_value, proof) - } - Node::Branch(children, maybe_data) => { - process_branch::(children, maybe_data, key, expected_value, proof) - } - Node::NibbledBranch(nib, children, maybe_data) => { - process_nibbledbranch::(nib, children, maybe_data, key, expected_value, proof) - } - } -} - -fn process_empty<'a, L>( - key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - _: &[Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - if expected_value.is_none() { - Ok(()) - } else { - Err(VerifyError::NonExistingValue(key)) - } -} - -fn process_leaf<'a, L>( - nib: NibbleSlice, - data: Value<'a>, - key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - proof: &'a [Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - if key != nib && expected_value.is_none() { - return Ok(()) - } else if key != nib { - return Err(VerifyError::NonExistingValue(key)) - } - match_value::(Some(data), key, expected_value, proof) -} -fn process_extension<'a, L>( - nib: &NibbleSlice, - handle: NodeHandle<'a>, - mut key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - proof: &'a [Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - if !key.starts_with(nib) && expected_value.is_none() { - return Ok(()) - } else if !key.starts_with(nib) { - return Err(VerifyError::NonExistingValue(key)) - } - key.advance(nib.len()); - - match handle { - NodeHandle::Inline(encoded_node) => { - process_node::(None, encoded_node, key, expected_value, proof) - } - NodeHandle::Hash(plain_hash) => { - let new_root = decode_hash::(plain_hash) - .ok_or_else(|| VerifyError::HashDecodeError(plain_hash))?; - process_node::(Some(&new_root), &proof[0], key, expected_value, &proof[1..]) - } - } -} - -fn process_nibbledbranch<'a, L>( - nib: NibbleSlice, - children: [Option>; 16], - maybe_data: Option>, - mut key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - proof: &'a [Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - if !key.starts_with(&nib) && expected_value.is_none() { - return Ok(()) - } else if !key.starts_with(&nib) && expected_value.is_some() { - return Err(VerifyError::NonExistingValue(key)) - } - key.advance(nib.len()); - - if key.is_empty() { - match_value::(maybe_data, key, expected_value, proof) - } else { - match_children::(children, key, expected_value, proof) - } -} - -fn process_branch<'a, L>( - children: [Option>; 16], - maybe_data: Option>, - key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - proof: &'a [Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - if key.is_empty() { - match_value::(maybe_data, key, expected_value, proof) - } else { - match_children::(children, key, expected_value, proof) - } -} -fn match_children<'a, L>( - children: [Option>; 16], - mut key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - proof: &'a [Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - match children.get(key.at(0) as usize) { - Some(Some(NodeHandle::Hash(hash))) => { - if proof.is_empty() { - Err(VerifyError::IncompleteProof) - } else { - key.advance(1); - let new_root = decode_hash::(hash) - .ok_or_else(|| VerifyError::HashDecodeError(hash))?; - process_node::(Some(&new_root), &proof[0], key, expected_value, &proof[1..]) - } - } - Some(Some(NodeHandle::Inline(encoded_node))) => { - key.advance(1); - process_node::(None, encoded_node, key, expected_value, proof) - } - Some(None) => { - if expected_value.is_none() { - Ok(()) - } else { - Err(VerifyError::NonExistingValue(key)) - } - } - None => panic!("key index is out of range in children array"), - } -} - -fn match_value<'a, L>( - maybe_data: Option>, - key: NibbleSlice<'a>, - expected_value: Option<&[u8]>, - proof: &'a [Vec], -) -> Result<(), VerifyError<'a, TrieHash, CError>> -where - L: TrieLayout, -{ - match (maybe_data, proof.first(), expected_value) { - (None, _, None) => Ok(()), - (None, _, Some(_)) => Err(VerifyError::NonExistingValue(key)), - (Some(Value::Inline(inline_data)), _, Some(value)) => { - if inline_data == value { - Ok(()) - } else { - Err(VerifyError::ValueMismatch(inline_data.to_vec())) - } - } - (Some(Value::Inline(inline_data)), _, None) => { - Err(VerifyError::ExistingValue(inline_data.to_vec())) - } - (Some(Value::Node(plain_hash, _)), Some(next_proof_item), Some(value)) => { - let value_hash = L::Hash::hash(value); - let node_hash = decode_hash::(plain_hash) - .ok_or_else(|| VerifyError::HashDecodeError(plain_hash))?; - if node_hash != value_hash { - Err(VerifyError::HashMismatch(node_hash)) - } else if next_proof_item != value { - Err(VerifyError::ValueMismatch(next_proof_item.to_vec())) - } else { - Ok(()) - } - } - (Some(Value::Node(_, _)), None, _) => Err(VerifyError::IncompleteProof), - (Some(Value::Node(_, _)), Some(proof_item), None) => { - Err(VerifyError::ExistingValue(proof_item.to_vec())) - } - } -} diff --git a/crates/anvil/tests/it/proof/mod.rs b/crates/anvil/tests/it/proof/mod.rs deleted file mode 100644 index 85e8c630f7d56..0000000000000 --- a/crates/anvil/tests/it/proof/mod.rs +++ /dev/null @@ -1,76 +0,0 @@ -//! tests for `eth_getProof` - -use crate::proof::eip1186::verify_proof; -use alloy_primitives::{keccak256, Address, B256, U256}; -use alloy_rlp::Decodable; -use alloy_rpc_types::EIP1186AccountProofResponse; -use anvil::{spawn, NodeConfig}; -use anvil_core::eth::{proof::BasicAccount, trie::ExtensionLayout}; -use foundry_evm::revm::primitives::KECCAK_EMPTY; - -mod eip1186; - -#[tokio::test(flavor = "multi_thread")] -async fn can_get_proof() { - let (api, _handle) = spawn(NodeConfig::test()).await; - - let acc: Address = "0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa".parse().unwrap(); - - let key = U256::ZERO; - let value = U256::from(1); - - api.anvil_set_storage_at(acc, key, B256::from(value)).await.unwrap(); - - let proof: EIP1186AccountProofResponse = - api.get_proof(acc, vec![B256::from(key)], None).await.unwrap(); - - let account = BasicAccount { - nonce: U256::from(0), - balance: U256::from(0), - storage_root: proof.storage_hash, - code_hash: KECCAK_EMPTY, - }; - - let rlp_account = alloy_rlp::encode(&account); - - let root: B256 = api.state_root().await.unwrap(); - let acc_proof: Vec> = proof - .account_proof - .into_iter() - .map(|node| Vec::::decode(&mut &node[..]).unwrap()) - .collect(); - - verify_proof::( - &root.0, - &acc_proof, - &keccak256(acc.as_slice())[..], - Some(rlp_account.as_ref()), - ) - .unwrap(); - - assert_eq!(proof.storage_proof.len(), 1); - let expected_value = alloy_rlp::encode(value); - let proof = proof.storage_proof[0].clone(); - let storage_proof: Vec> = - proof.proof.into_iter().map(|node| Vec::::decode(&mut &node[..]).unwrap()).collect(); - let key = B256::from(keccak256(proof.key.0 .0)); - verify_proof::( - &account.storage_root.0, - &storage_proof, - key.as_slice(), - Some(expected_value.as_ref()), - ) - .unwrap(); -} - -#[tokio::test(flavor = "multi_thread")] -async fn can_get_random_account_proofs() { - let (api, _handle) = spawn(NodeConfig::test()).await; - - for acc in std::iter::repeat_with(Address::random).take(10) { - let _ = api - .get_proof(acc, Vec::new(), None) - .await - .unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}")); - } -} From 5274799a98395d2104be27d50e1852868ca118a1 Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:40:22 +0530 Subject: [PATCH 0823/1963] chore(forge): kB to B in build --sizes (#7588) --- crates/common/src/compile.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 654ddd6938ad6..bba5e15d27753 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -403,8 +403,8 @@ impl Display for SizeReport { table.load_preset(ASCII_MARKDOWN); table.set_header([ Cell::new("Contract").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Size (kB)").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Margin (kB)").add_attribute(Attribute::Bold).fg(Color::Blue), + Cell::new("Size (B)").add_attribute(Attribute::Bold).fg(Color::Blue), + Cell::new("Margin (B)").add_attribute(Attribute::Bold).fg(Color::Blue), ]); // filters out non dev contracts (Test or Script) @@ -419,8 +419,8 @@ impl Display for SizeReport { table.add_row([ Cell::new(name).fg(color), - Cell::new(contract.size as f64 / 1000.0).fg(color), - Cell::new(margin as f64 / 1000.0).fg(color), + Cell::new(contract.size).fg(color), + Cell::new(margin).fg(color), ]); } From 04e2263ff8ffcd7bfd2b705a0f7af08209f800e4 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 8 Apr 2024 19:13:41 +0400 Subject: [PATCH 0824/1963] fix: smarter `getCode` validation (#7597) * fix: smarter getCode validation * clippy + doc fix * fix * multi-version profile and tests * fmt * add more parsing options * clippy + fmt --- crates/cheatcodes/src/config.rs | 7 + crates/cheatcodes/src/fs.rs | 122 +++++++++++++----- crates/chisel/src/executor.rs | 1 + crates/forge/bin/cmd/coverage.rs | 1 + crates/forge/bin/cmd/test/mod.rs | 1 + crates/forge/src/multi_runner.rs | 55 ++++---- crates/forge/tests/it/cheats.rs | 19 ++- crates/forge/tests/it/test_helpers.rs | 14 +- crates/script/src/execute.rs | 1 + crates/script/src/lib.rs | 8 +- testdata/default/cheats/GetCode.t.sol | 12 ++ testdata/multi-version/Counter.sol | 11 ++ testdata/multi-version/Importer.sol | 7 + testdata/multi-version/cheats/GetCode.t.sol | 25 ++++ testdata/multi-version/cheats/GetCode17.t.sol | 26 ++++ 15 files changed, 238 insertions(+), 72 deletions(-) create mode 100644 testdata/multi-version/Counter.sol create mode 100644 testdata/multi-version/Importer.sol create mode 100644 testdata/multi-version/cheats/GetCode.t.sol create mode 100644 testdata/multi-version/cheats/GetCode17.t.sol diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 9d0ca2ea460d7..f93ab4f5867cd 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -8,6 +8,7 @@ use foundry_config::{ ResolvedRpcEndpoints, }; use foundry_evm_core::opts::EvmOpts; +use semver::Version; use std::{ collections::HashMap, path::{Path, PathBuf}, @@ -47,6 +48,8 @@ pub struct CheatsConfig { /// If Some, `vm.getDeployedCode` invocations are validated to be in scope of this list. /// If None, no validation is performed. pub available_artifacts: Option>, + /// Version of the script/test contract which is currently running. + pub running_version: Option, } impl CheatsConfig { @@ -56,6 +59,7 @@ impl CheatsConfig { evm_opts: EvmOpts, available_artifacts: Option>, script_wallets: Option, + running_version: Option, ) -> Self { let mut allowed_paths = vec![config.__root.0.clone()]; allowed_paths.extend(config.libs.clone()); @@ -82,6 +86,7 @@ impl CheatsConfig { labels: config.labels.clone(), script_wallets, available_artifacts, + running_version, } } @@ -200,6 +205,7 @@ impl Default for CheatsConfig { labels: Default::default(), script_wallets: None, available_artifacts: Default::default(), + running_version: Default::default(), } } } @@ -215,6 +221,7 @@ mod tests { Default::default(), None, None, + None, ) } diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 9760b4f162c1e..54335a5e529b0 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -271,14 +271,40 @@ impl Cheatcode for getDeployedCodeCall { } /// Returns the path to the json artifact depending on the input +/// +/// Can parse following input formats: +/// - `path/to/artifact.json` +/// - `path/to/contract.sol` +/// - `path/to/contract.sol:ContractName` +/// - `path/to/contract.sol:ContractName:0.8.23` +/// - `path/to/contract.sol:0.8.23` +/// - `ContractName` +/// - `ContractName:0.8.23` fn get_artifact_path(state: &Cheatcodes, path: &str) -> Result { if path.ends_with(".json") { Ok(PathBuf::from(path)) } else { let mut parts = path.split(':'); - let file = PathBuf::from(parts.next().unwrap()); - let contract_name = parts.next(); - let version = parts.next(); + + let mut file = None; + let mut contract_name = None; + let mut version = None; + + let path_or_name = parts.next().unwrap(); + if path_or_name.ends_with(".sol") { + file = Some(PathBuf::from(path_or_name)); + if let Some(name_or_version) = parts.next() { + if name_or_version.contains('.') { + version = Some(name_or_version); + } else { + contract_name = Some(name_or_version); + version = parts.next(); + } + } + } else { + contract_name = Some(path_or_name); + version = parts.next(); + } let version = if let Some(version) = version { Some(Version::parse(version).map_err(|_| fmt_err!("Error parsing version"))?) @@ -288,44 +314,70 @@ fn get_artifact_path(state: &Cheatcodes, path: &str) -> Result { // Use available artifacts list if available if let Some(available_ids) = &state.config.available_artifacts { - let mut artifact = None; - - for id in available_ids.iter() { - // name might be in the form of "Counter.0.8.23" - let id_name = id.name.split('.').next().unwrap(); - - if !id.source.ends_with(&file) { - continue; - } - if let Some(name) = contract_name { - if id_name != name { - continue; + let filtered = available_ids + .iter() + .filter(|id| { + // name might be in the form of "Counter.0.8.23" + let id_name = id.name.split('.').next().unwrap(); + + if let Some(path) = &file { + if !id.source.ends_with(path) { + return false; + } } - } - if let Some(ref version) = version { - if id.version.minor != version.minor || - id.version.major != version.major || - id.version.patch != version.patch - { - continue; + if let Some(name) = contract_name { + if id_name != name { + return false; + } } + if let Some(ref version) = version { + if id.version.minor != version.minor || + id.version.major != version.major || + id.version.patch != version.patch + { + return false; + } + } + true + }) + .collect::>(); + + let artifact = match filtered.len() { + 0 => Err(fmt_err!("No matching artifact found")), + 1 => Ok(filtered[0]), + _ => { + // If we know the current script/test contract solc version, try to filter by it + state + .config + .running_version + .as_ref() + .and_then(|version| { + let filtered = filtered + .into_iter() + .filter(|id| id.version == *version) + .collect::>(); + + (filtered.len() == 1).then_some(filtered[0]) + }) + .ok_or_else(|| fmt_err!("Multiple matching artifacts found")) } - if artifact.is_some() { - return Err(fmt_err!("Multiple matching artifacts found")); - } - artifact = Some(id); - } + }?; - let artifact = artifact.ok_or_else(|| fmt_err!("No matching artifact found"))?; Ok(artifact.path.clone()) } else { - let file = file.to_string_lossy(); - let contract_name = if let Some(contract_name) = contract_name { - contract_name.to_owned() - } else { - file.replace(".sol", "") - }; - Ok(state.config.paths.artifacts.join(format!("{file}/{contract_name}.json"))) + let path_in_artifacts = + match (file.map(|f| f.to_string_lossy().to_string()), contract_name) { + (Some(file), Some(contract_name)) => Ok(format!("{file}/{contract_name}.json")), + (None, Some(contract_name)) => { + Ok(format!("{contract_name}.sol/{contract_name}.json")) + } + (Some(file), None) => { + let name = file.replace(".sol", ""); + Ok(format!("{file}/{name}.json")) + } + _ => Err(fmt_err!("Invalid artifact path")), + }?; + Ok(state.config.paths.artifacts.join(path_in_artifacts)) } } } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index e0774a2b6878a..6343013b18bab 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -308,6 +308,7 @@ impl SessionSource { self.config.evm_opts.clone(), None, None, + self.solc.version().ok(), ) .into(), ) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 8dc4629b9f7ed..29538164b84ab 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -317,6 +317,7 @@ impl CoverageArgs { evm_opts.clone(), Some(artifact_ids), None, + None, )) .with_test_options(TestOptions { fuzz: config.fuzz, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 104fa4c486e0b..16f5ec5166339 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -287,6 +287,7 @@ impl TestArgs { evm_opts.clone(), Some(artifact_ids), None, + None, // populated separately for each test contract )) .with_test_options(test_options) .enable_isolation(evm_opts.isolate) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 94d0b0155a8ee..f19e67d22ec3e 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -9,13 +9,8 @@ use foundry_compilers::{ artifacts::Libraries, contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput, }; use foundry_evm::{ - backend::Backend, - decode::RevertDecoder, - executors::{Executor, ExecutorBuilder}, - fork::CreateFork, - inspectors::CheatsConfig, - opts::EvmOpts, - revm, + backend::Backend, decode::RevertDecoder, executors::ExecutorBuilder, fork::CreateFork, + inspectors::CheatsConfig, opts::EvmOpts, revm, }; use foundry_linking::{LinkOutput, Linker}; use rayon::prelude::*; @@ -158,18 +153,6 @@ impl MultiContractRunner { // The DB backend that serves all the data. let db = Backend::spawn(self.fork.take()); - let executor = ExecutorBuilder::new() - .inspectors(|stack| { - stack - .cheatcodes(self.cheats_config.clone()) - .trace(self.evm_opts.verbosity >= 3 || self.debug) - .debug(self.debug) - .coverage(self.coverage) - .enable_isolation(self.isolation) - }) - .spec(self.evm_spec) - .gas_limit(self.evm_opts.gas_limit()) - .build(self.env.clone(), db); let find_timer = Instant::now(); let contracts = self.matching_contracts(filter).collect::>(); @@ -182,30 +165,46 @@ impl MultiContractRunner { ); contracts.par_iter().for_each_with(tx, |tx, &(id, contract)| { - let identifier = id.identifier(); - let executor = executor.clone(); - let result = self.run_tests(&identifier, contract, executor, filter); - let _ = tx.send((identifier, result)); + let result = self.run_tests(id, contract, db.clone(), filter); + let _ = tx.send((id.identifier(), result)); }) } fn run_tests( &self, - name: &str, + artifact_id: &ArtifactId, contract: &TestContract, - executor: Executor, + db: Backend, filter: &dyn TestFilter, ) -> SuiteResult { - let mut span_name = name; + let identifier = artifact_id.identifier(); + let mut span_name = identifier.as_str(); + + let mut cheats_config = self.cheats_config.as_ref().clone(); + cheats_config.running_version = Some(artifact_id.version.clone()); + + let executor = ExecutorBuilder::new() + .inspectors(|stack| { + stack + .cheatcodes(Arc::new(cheats_config)) + .trace(self.evm_opts.verbosity >= 3 || self.debug) + .debug(self.debug) + .coverage(self.coverage) + .enable_isolation(self.isolation) + }) + .spec(self.evm_spec) + .gas_limit(self.evm_opts.gas_limit()) + .build(self.env.clone(), db); + if !enabled!(tracing::Level::TRACE) { - span_name = get_contract_name(span_name); + span_name = get_contract_name(&identifier); } let _guard = info_span!("run_tests", name = span_name).entered(); debug!("start executing all tests in contract"); let runner = ContractRunner::new( - name, + &identifier, executor, contract, self.evm_opts.initial_balance, diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index fd6e9866e61d6..920dd8f2d2c1b 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -2,14 +2,13 @@ use crate::{ config::*, - test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT}, + test_helpers::{ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_DEFAULT, TEST_DATA_MULTI_VERSION}, }; use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_test_utils::Filter; /// Executes all cheat code tests but not fork cheat codes -#[tokio::test(flavor = "multi_thread")] -async fn test_cheats_local() { +async fn test_cheats_local(test_data: &ForgeTestData) { let mut filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}*")).exclude_paths("Fork"); @@ -18,9 +17,19 @@ async fn test_cheats_local() { filter = filter.exclude_tests("(Ffi|File|Line|Root)"); } - let mut config = TEST_DATA_DEFAULT.config.clone(); + let mut config = test_data.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); - let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let runner = test_data.runner_with_config(config); TestConfig::with_filter(runner, filter).run().await; } + +#[tokio::test(flavor = "multi_thread")] +async fn test_cheats_local_default() { + test_cheats_local(&TEST_DATA_DEFAULT).await +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_cheats_local_multi_version() { + test_cheats_local(&TEST_DATA_MULTI_VERSION).await +} diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 8d54976cc7865..a8ab8229c4bfe 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -32,6 +32,7 @@ const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); pub enum ForgeTestProfile { Default, Cancun, + MultiVersion, } impl fmt::Display for ForgeTestProfile { @@ -39,6 +40,7 @@ impl fmt::Display for ForgeTestProfile { match self { ForgeTestProfile::Default => write!(f, "default"), ForgeTestProfile::Cancun => write!(f, "cancun"), + ForgeTestProfile::MultiVersion => write!(f, "multi-version"), } } } @@ -206,7 +208,13 @@ impl ForgeTestData { let output = self.output.clone(); let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); self.base_runner() - .with_cheats_config(CheatsConfig::new(&config, opts.clone(), Some(artifact_ids), None)) + .with_cheats_config(CheatsConfig::new( + &config, + opts.clone(), + Some(artifact_ids), + None, + None, + )) .sender(config.sender) .with_test_options(self.test_opts.clone()) .build(root, output, env, opts.clone()) @@ -274,6 +282,10 @@ pub static TEST_DATA_DEFAULT: Lazy = pub static TEST_DATA_CANCUN: Lazy = Lazy::new(|| ForgeTestData::new(ForgeTestProfile::Cancun)); +/// Data for tests requiring Cancun support on Solc and EVM level. +pub static TEST_DATA_MULTI_VERSION: Lazy = + Lazy::new(|| ForgeTestData::new(ForgeTestProfile::MultiVersion)); + pub fn manifest_root() -> &'static Path { let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); // need to check here where we're executing the test from, if in `forge` we need to also allow diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 7a2546ec822c3..7b811a67cd91b 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -102,6 +102,7 @@ impl PreExecutionState { self.build_data.build_data.artifact_ids.clone(), self.script_wallets.clone(), self.args.debug, + self.build_data.build_data.target.clone(), ) .await?; let mut result = self.execute_with_runner(&mut runner).await?; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 5b27a5ff420eb..530c84d36c7bc 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -559,13 +559,14 @@ impl ScriptConfig { artifact_ids: Vec, script_wallets: ScriptWallets, debug: bool, + target: ArtifactId, ) -> Result { - self._get_runner(Some((artifact_ids, script_wallets)), debug).await + self._get_runner(Some((artifact_ids, script_wallets, target)), debug).await } async fn _get_runner( &mut self, - cheats_data: Option<(Vec, ScriptWallets)>, + cheats_data: Option<(Vec, ScriptWallets, ArtifactId)>, debug: bool, ) -> Result { trace!("preparing script runner"); @@ -594,7 +595,7 @@ impl ScriptConfig { .spec(self.config.evm_spec_id()) .gas_limit(self.evm_opts.gas_limit()); - if let Some((artifact_ids, script_wallets)) = cheats_data { + if let Some((artifact_ids, script_wallets, target)) = cheats_data { builder = builder.inspectors(|stack| { stack .debug(debug) @@ -604,6 +605,7 @@ impl ScriptConfig { self.evm_opts.clone(), Some(artifact_ids), Some(script_wallets), + Some(target.version), ) .into(), ) diff --git a/testdata/default/cheats/GetCode.t.sol b/testdata/default/cheats/GetCode.t.sol index d308712e9d6b4..73980d7b29810 100644 --- a/testdata/default/cheats/GetCode.t.sol +++ b/testdata/default/cheats/GetCode.t.sol @@ -6,6 +6,8 @@ import "cheats/Vm.sol"; contract TestContract {} +contract TestContractGetCode {} + contract GetCodeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); @@ -80,4 +82,14 @@ contract GetCodeTest is DSTest { vm._expectCheatcodeRevert("No matching artifact found"); vm.getCode("cheats/GetCode.t.sol:TestContract:0.8.19"); } + + function testByName() public { + bytes memory code = vm.getCode("TestContractGetCode"); + assertEq(type(TestContractGetCode).creationCode, code); + } + + function testByNameAndVersion() public { + bytes memory code = vm.getCode("TestContractGetCode:0.8.18"); + assertEq(type(TestContractGetCode).creationCode, code); + } } diff --git a/testdata/multi-version/Counter.sol b/testdata/multi-version/Counter.sol new file mode 100644 index 0000000000000..4f0c350335f8e --- /dev/null +++ b/testdata/multi-version/Counter.sol @@ -0,0 +1,11 @@ +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } +} diff --git a/testdata/multi-version/Importer.sol b/testdata/multi-version/Importer.sol new file mode 100644 index 0000000000000..d8e274e8f5447 --- /dev/null +++ b/testdata/multi-version/Importer.sol @@ -0,0 +1,7 @@ +pragma solidity 0.8.17; + +import "./Counter.sol"; + +// Please do not remove or change version pragma for this file. +// If you need to ensure that some of the files are compiled with +// solc 0.8.17, you should add imports of them to this file. diff --git a/testdata/multi-version/cheats/GetCode.t.sol b/testdata/multi-version/cheats/GetCode.t.sol new file mode 100644 index 0000000000000..e4a7bd14ae4e9 --- /dev/null +++ b/testdata/multi-version/cheats/GetCode.t.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; +import "../Counter.sol"; + +contract GetCodeTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testGetCodeMultiVersion() public { + assertEq(vm.getCode("Counter.sol"), type(Counter).creationCode); + require( + keccak256(vm.getCode("Counter.sol")) != keccak256(vm.getCode("Counter.sol:Counter:0.8.17")), + "Invalid artifact" + ); + assertEq(vm.getCode("Counter.sol"), vm.getCode("Counter.sol:Counter:0.8.18")); + } + + function testGetCodeByNameMultiVersion() public { + assertEq(vm.getCode("Counter"), type(Counter).creationCode); + require(keccak256(vm.getCode("Counter")) != keccak256(vm.getCode("Counter:0.8.17")), "Invalid artifact"); + assertEq(vm.getCode("Counter"), vm.getCode("Counter:0.8.18")); + } +} diff --git a/testdata/multi-version/cheats/GetCode17.t.sol b/testdata/multi-version/cheats/GetCode17.t.sol new file mode 100644 index 0000000000000..068a910cf7b65 --- /dev/null +++ b/testdata/multi-version/cheats/GetCode17.t.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.17; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; +import "../Counter.sol"; + +// Same as GetCode.t.sol but for 0.8.17 version +contract GetCodeTest17 is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testGetCodeMultiVersion() public { + assertEq(vm.getCode("Counter.sol"), type(Counter).creationCode); + require( + keccak256(vm.getCode("Counter.sol")) != keccak256(vm.getCode("Counter.sol:Counter:0.8.18")), + "Invalid artifact" + ); + assertEq(vm.getCode("Counter.sol"), vm.getCode("Counter.sol:Counter:0.8.17")); + } + + function testGetCodeByNameMultiVersion() public { + assertEq(vm.getCode("Counter"), type(Counter).creationCode); + require(keccak256(vm.getCode("Counter")) != keccak256(vm.getCode("Counter:0.8.18")), "Invalid artifact"); + assertEq(vm.getCode("Counter.sol"), vm.getCode("Counter:0.8.17")); + } +} From b88d167bbbd203d97fd9e06121da87bdacbca3a5 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:51:42 +0200 Subject: [PATCH 0825/1963] feat(forge): add `vm.lastCallGas` cheatcode (#7573) * add `gasUsed and lastGasUsed methods to Vm * reorder * basic sketching of idea, planning to use Gas struct to deliver as much gas related information rather than a uint256 * add transformation * to prevent recording gas by default, only enable after recordGas is enabled * update struct layout, implementation builds, now connecting to cheatcodes * fix cheatcodes * refactor to use simple u64 as Gas struct doesnt have a default * change from Gas struct to simple u64 as I ran into issues with cache being reset to 0 * it appears cheatcodes are resolved before the actual function calls are therefore it doesnt actually remember the correct value from the previous execution but only of the previous executed cheatcode * still not working * finally works, stupid me didnt realize i had to cross call frames * emit gas record * test convenient single field access * add gas record struct back * pass down isolate bool, only enable gas tracing if enabled * raise error if cheatcode is used outside of isolation mode * mark as view * show gas refund and memory expansion * improve example * add isolation test, currently does not run as expected * fix fmt * avoid formatting changes * avoid commiting formatting changes, editor now configured correctly * lastGasUsed -> lastCallGas * small name fix * remove separate isolation profile, just configure on the runner * fix forge fmt * note on why path should never happen * remove separate isolated param, inherit from config * add support for non-isolation mode * remove isolate standalone, create additional entry in cheats and document subset of cheats that require to be tested in isolation mode as well * improve tests, use asserts and add option to exclude contracts from test filter, not just individual tests or paths * typo, no need to define path exclusion of forks in isolated tests as it is not relevant --- crates/cheatcodes/assets/cheatcodes.json | 51 +++++++++ crates/cheatcodes/spec/src/lib.rs | 1 + crates/cheatcodes/spec/src/vm.rs | 52 ++++++--- crates/cheatcodes/src/evm.rs | 13 +++ crates/cheatcodes/src/inspector.rs | 22 +++- crates/forge/tests/it/cheats.rs | 23 +++- crates/forge/tests/it/test_helpers.rs | 8 +- crates/test-utils/src/filter.rs | 17 +++ testdata/cheats/Vm.sol | 2 + testdata/default/cheats/LastCallGas.t.sol | 125 ++++++++++++++++++++++ 10 files changed, 293 insertions(+), 21 deletions(-) create mode 100644 testdata/default/cheats/LastCallGas.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 360d5de1c442c..3b4d071d7589a 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -415,6 +415,37 @@ "description": "If the access was reverted." } ] + }, + { + "name": "Gas", + "description": "", + "fields": [ + { + "name": "gasLimit", + "ty": "uint64", + "description": "" + }, + { + "name": "gasTotalUsed", + "ty": "uint64", + "description": "" + }, + { + "name": "gasMemoryUsed", + "ty": "uint64", + "description": "" + }, + { + "name": "gasRefunded", + "ty": "int64", + "description": "" + }, + { + "name": "gasRemaining", + "ty": "uint64", + "description": "" + } + ] } ], "cheatcodes": [ @@ -4958,6 +4989,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "lastCallGas", + "description": "Gets the gas used in the last call.", + "declaration": "function lastCallGas() external view returns (Gas memory gas);", + "visibility": "external", + "mutability": "view", + "signature": "lastCallGas()", + "selector": "0x2b589b28", + "selectorBytes": [ + 43, + 88, + 155, + 40 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "load", diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index 10a53e18d8741..16bb60834068e 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -83,6 +83,7 @@ impl Cheatcodes<'static> { Vm::ChainInfo::STRUCT.clone(), Vm::AccountAccess::STRUCT.clone(), Vm::StorageAccess::STRUCT.clone(), + Vm::Gas::STRUCT.clone(), ]), enums: Cow::Owned(vec![ Vm::CallerMode::ENUM.clone(), diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 93042c1991ff1..c350690fcc266 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -73,6 +73,19 @@ interface Vm { address emitter; } + struct Gas { + // The gas limit of the call. + uint64 gasLimit; + // The total gas used. + uint64 gasTotalUsed; + // The amount of gas used for memory expansion. + uint64 gasMemoryUsed; + // The amount of gas refunded. + int64 gasRefunded; + // The amount of gas remaining. + uint64 gasRemaining; + } + /// An RPC URL and its alias. Returned by `rpcUrlStructs`. struct Rpc { /// The alias of the RPC URL. @@ -169,6 +182,22 @@ interface Vm { uint256 chainId; } + /// The storage accessed during an `AccountAccess`. + struct StorageAccess { + /// The account whose storage was accessed. + address account; + /// The slot that was accessed. + bytes32 slot; + /// If the access was a write. + bool isWrite; + /// The previous value of the slot. + bytes32 previousValue; + /// The new value of the slot. + bytes32 newValue; + /// If the access was reverted. + bool reverted; + } + /// The result of a `stopAndReturnStateDiff` call. struct AccountAccess { /// The chain and fork the access occurred. @@ -207,22 +236,6 @@ interface Vm { uint64 depth; } - /// The storage accessed during an `AccountAccess`. - struct StorageAccess { - /// The account whose storage was accessed. - address account; - /// The slot that was accessed. - bytes32 slot; - /// If the access was a write. - bool isWrite; - /// The previous value of the slot. - bytes32 previousValue; - /// The new value of the slot. - bytes32 newValue; - /// If the access was reverted. - bool reverted; - } - // ======== EVM ======== /// Gets the address for a given private key. @@ -594,6 +607,7 @@ interface Vm { function getRecordedLogs() external returns (Log[] memory logs); // -------- Gas Metering -------- + // It's recommend to use the `noGasMetering` modifier included with forge-std, instead of // using these functions directly. @@ -605,6 +619,12 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function resumeGasMetering() external; + // -------- Gas Measurement -------- + + /// Gets the gas used in the last call. + #[cheatcode(group = Evm, safety = Safe)] + function lastCallGas() external view returns (Gas memory gas); + // ======== Test Assertions and Utilities ======== /// If the condition is false, discard this run's fuzz inputs and generate new ones. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 2f3dafedefe6e..d7328fcc0ea76 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -224,6 +224,19 @@ impl Cheatcode for resumeGasMeteringCall { } } +impl Cheatcode for lastCallGasCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + ensure!(state.last_call_gas.is_some(), "`lastCallGas` is only available after a call"); + Ok(state + .last_call_gas + .as_ref() + // This should never happen, as we ensure `last_call_gas` is `Some` above. + .expect("`lastCallGas` is only available after a call") + .abi_encode()) + } +} + impl Cheatcode for chainIdCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newChainId } = self; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 699840d9325ac..934cae0c75d96 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -145,6 +145,10 @@ pub struct Cheatcodes { /// Recorded logs pub recorded_logs: Option>, + /// Cache of the amount of gas used in previous call. + /// This is used by the `lastCallGas` cheatcode. + pub last_call_gas: Option, + /// Mocked calls // **Note**: inner must a BTreeMap because of special `Ord` impl for `MockCallDataContext` pub mocked_calls: HashMap>, @@ -1033,9 +1037,25 @@ impl Inspector for Cheatcodes { // Exit early for calls to cheatcodes as other logic is not relevant for cheatcode // invocations if cheatcode_call { - return outcome; + return outcome } + // Record the gas usage of the call, this allows the `lastCallGas` cheatcode to + // retrieve the gas usage of the last call. + let gas = outcome.result.gas; + self.last_call_gas = Some(crate::Vm::Gas { + // The gas limit of the call. + gasLimit: gas.limit(), + // The total gas used. + gasTotalUsed: gas.spend(), + // The amount of gas used for memory expansion. + gasMemoryUsed: gas.memory(), + // The amount of gas refunded. + gasRefunded: gas.refunded(), + // The amount of gas remaining. + gasRemaining: gas.remaining(), + }); + // If `startStateDiffRecording` has been called, update the `reverted` status of the // previous call depth's recorded accesses, if any if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 920dd8f2d2c1b..42113cdc770dc 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -7,10 +7,11 @@ use crate::{ use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_test_utils::Filter; -/// Executes all cheat code tests but not fork cheat codes +/// Executes all cheat code tests but not fork cheat codes or tests that require isolation mode async fn test_cheats_local(test_data: &ForgeTestData) { - let mut filter = - Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}*")).exclude_paths("Fork"); + let mut filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}*")) + .exclude_paths("Fork") + .exclude_contracts("Isolated"); // Exclude FFI tests on Windows because no `echo`, and file tests that expect certain file paths if cfg!(windows) { @@ -24,11 +25,27 @@ async fn test_cheats_local(test_data: &ForgeTestData) { TestConfig::with_filter(runner, filter).run().await; } +/// Executes subset of all cheat code tests in isolation mode +async fn test_cheats_local_isolated(test_data: &ForgeTestData) { + let filter = Filter::new(".*", ".*(Isolated)", &format!(".*cheats{RE_PATH_SEPARATOR}*")); + + let mut config = test_data.config.clone(); + config.isolate = true; + let runner = test_data.runner_with_config(config); + + TestConfig::with_filter(runner, filter).run().await; +} + #[tokio::test(flavor = "multi_thread")] async fn test_cheats_local_default() { test_cheats_local(&TEST_DATA_DEFAULT).await } +#[tokio::test(flavor = "multi_thread")] +async fn test_cheats_local_default_isolated() { + test_cheats_local_isolated(&TEST_DATA_DEFAULT).await +} + #[tokio::test(flavor = "multi_thread")] async fn test_cheats_local_multi_version() { test_cheats_local(&TEST_DATA_MULTI_VERSION).await diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index a8ab8229c4bfe..6fc8a3745f152 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -203,7 +203,12 @@ impl ForgeTestData { config.prompt_timeout = 0; let root = self.project.root(); - let opts = self.evm_opts.clone(); + let mut opts = self.evm_opts.clone(); + + if config.isolate { + opts.isolate = true; + } + let env = opts.local_evm_env(); let output = self.output.clone(); let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); @@ -215,6 +220,7 @@ impl ForgeTestData { None, None, )) + .enable_isolation(opts.isolate) .sender(config.sender) .with_test_options(self.test_opts.clone()) .build(root, output, env, opts.clone()) diff --git a/crates/test-utils/src/filter.rs b/crates/test-utils/src/filter.rs index fb07237f22af2..e24f87c17523c 100644 --- a/crates/test-utils/src/filter.rs +++ b/crates/test-utils/src/filter.rs @@ -7,6 +7,7 @@ pub struct Filter { contract_regex: Regex, path_regex: Regex, exclude_tests: Option, + exclude_contracts: Option, exclude_paths: Option, } @@ -21,6 +22,7 @@ impl Filter { path_regex: Regex::new(path_pattern) .unwrap_or_else(|_| panic!("Failed to parse path pattern: `{path_pattern}`")), exclude_tests: None, + exclude_contracts: None, exclude_paths: None, } } @@ -41,6 +43,14 @@ impl Filter { self } + /// All contracts to also exclude + /// + /// This is a workaround since regex does not support negative look aheads + pub fn exclude_contracts(mut self, pattern: &str) -> Self { + self.exclude_contracts = Some(Regex::new(pattern).unwrap()); + self + } + /// All paths to also exclude /// /// This is a workaround since regex does not support negative look aheads @@ -55,6 +65,7 @@ impl Filter { contract_regex: Regex::new(".*").unwrap(), path_regex: Regex::new(".*").unwrap(), exclude_tests: None, + exclude_contracts: None, exclude_paths: None, } } @@ -71,6 +82,12 @@ impl TestFilter for Filter { } fn matches_contract(&self, contract_name: &str) -> bool { + if let Some(exclude) = &self.exclude_contracts { + if exclude.is_match(contract_name) { + return false; + } + } + self.contract_regex.is_match(contract_name) } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index aff05c278740c..1d7c819738479 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -18,6 +18,7 @@ interface Vm { 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; } function _expectCheatcodeRevert() external; function _expectCheatcodeRevert(bytes4 revertData) external; function _expectCheatcodeRevert(bytes calldata revertData) external; @@ -245,6 +246,7 @@ interface Vm { function keyExistsJson(string calldata json, string calldata key) external view returns (bool); function keyExistsToml(string calldata toml, string calldata key) external view returns (bool); function label(address account, string calldata newLabel) external; + function lastCallGas() external view returns (Gas memory gas); function load(address target, bytes32 slot) external view returns (bytes32 data); function loadAllocs(string calldata pathToAllocsJson) external; function makePersistent(address account) external; diff --git a/testdata/default/cheats/LastCallGas.t.sol b/testdata/default/cheats/LastCallGas.t.sol new file mode 100644 index 0000000000000..ec8c6ba0aad5a --- /dev/null +++ b/testdata/default/cheats/LastCallGas.t.sol @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Target { + uint256 public slot0; + + function expandMemory(uint256 n) public pure returns (uint256) { + uint256[] memory arr = new uint256[](n); + + for (uint256 i = 0; i < n; i++) { + arr[i] = i; + } + + return arr.length; + } + + function setValue(uint256 value) public { + slot0 = value; + } + + function resetValue() public { + slot0 = 0; + } + + fallback() external {} +} + +abstract contract LastCallGasFixture is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Target public target; + + struct Gas { + uint64 gasTotalUsed; + uint64 gasMemoryUsed; + int64 gasRefunded; + } + + function testRevertNoCachedLastCallGas() public { + vm.expectRevert(); + vm.lastCallGas(); + } + + function _setup() internal { + // Cannot be set in `setUp` due to `testRevertNoCachedLastCallGas` + // relying on no calls being made before `lastCallGas` is called. + target = new Target(); + } + + function _performCall() internal returns (bool success) { + (success,) = address(target).call(""); + } + + function _performExpandMemory() internal view { + target.expandMemory(1000); + } + + function _performRefund() internal { + target.setValue(1); + target.resetValue(); + } + + function _assertGas(Vm.Gas memory lhs, Gas memory rhs) internal { + assertGt(lhs.gasLimit, 0); + assertGt(lhs.gasRemaining, 0); + assertEq(lhs.gasTotalUsed, rhs.gasTotalUsed); + assertEq(lhs.gasMemoryUsed, rhs.gasMemoryUsed); + assertEq(lhs.gasRefunded, rhs.gasRefunded); + } +} + +contract LastCallGasIsolatedTest is LastCallGasFixture { + function testRecordLastCallGas() public { + _setup(); + _performCall(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); + + _performCall(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); + + _performCall(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); + } + + function testRecordGasMemory() public { + _setup(); + _performExpandMemory(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 186470, gasMemoryUsed: 4994, gasRefunded: 0})); + } + + function testRecordGasRefund() public { + _setup(); + _performRefund(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21380, gasMemoryUsed: 0, gasRefunded: 4800})); + } +} + +// Without isolation mode enabled the gas usage will be incorrect. +contract LastCallGasDefaultTest is LastCallGasFixture { + function testRecordLastCallGas() public { + _setup(); + _performCall(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 9, gasRefunded: 0})); + + _performCall(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 9, gasRefunded: 0})); + + _performCall(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 9, gasRefunded: 0})); + } + + function testRecordGasMemory() public { + _setup(); + _performExpandMemory(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 186470, gasMemoryUsed: 4994, gasRefunded: 0})); + } + + function testRecordGasRefund() public { + _setup(); + _performRefund(); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 216, gasMemoryUsed: 9, gasRefunded: 19900})); + } +} From 14daacfe40565b19bdfc3b78c6cf1775f54529da Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 9 Apr 2024 01:19:16 +0300 Subject: [PATCH 0826/1963] fix(invariant): decode custom error with target contract abis (#7559) * fix(invariant): decode custom error with target contract abis * Changes after review: don't collect --- .../evm/evm/src/executors/invariant/error.rs | 16 +++++++-- .../evm/evm/src/executors/invariant/funcs.rs | 4 ++- crates/evm/evm/src/executors/invariant/mod.rs | 5 ++- crates/forge/tests/it/invariant.rs | 25 +++++++++++++ .../common/InvariantCustomError.t.sol | 35 +++++++++++++++++++ 5 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 testdata/default/fuzz/invariant/common/InvariantCustomError.t.sol diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index d46d6da2c289f..98977b539fd54 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -5,7 +5,9 @@ use alloy_primitives::{Address, Bytes, Log}; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::{constants::CALLER, decode::RevertDecoder}; -use foundry_evm_fuzz::{BaseCounterExample, CounterExample, FuzzedCases, Reason}; +use foundry_evm_fuzz::{ + invariant::FuzzRunIdentifiedContracts, BaseCounterExample, CounterExample, FuzzedCases, Reason, +}; use foundry_evm_traces::{load_contracts, CallTraceArena, TraceKind, Traces}; use itertools::Itertools; use parking_lot::RwLock; @@ -98,8 +100,10 @@ pub struct FailedInvariantCaseData { } impl FailedInvariantCaseData { + #[allow(clippy::too_many_arguments)] pub fn new( invariant_contract: &InvariantContract<'_>, + targeted_contracts: &FuzzRunIdentifiedContracts, error_func: Option<&Function>, calldata: &[BasicTxDetails], call_result: RawCallResult, @@ -112,8 +116,16 @@ impl FailedInvariantCaseData { } else { (None, "Revert") }; + + // Collect abis of fuzzed and invariant contracts to decode custom error. + let targets = targeted_contracts.lock(); + let abis = targets + .iter() + .map(|contract| &contract.1 .1) + .chain(std::iter::once(invariant_contract.abi)); + let revert_reason = RevertDecoder::new() - .with_abi(invariant_contract.abi) + .with_abis(abis) .decode(call_result.result.as_ref(), Some(call_result.exit_reason)); Self { diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index 218f97e9234da..daa326b0c9f63 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -6,7 +6,7 @@ use alloy_primitives::Log; use foundry_common::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CALLER; use foundry_evm_coverage::HitMaps; -use foundry_evm_fuzz::invariant::{BasicTxDetails, InvariantContract}; +use foundry_evm_fuzz::invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract}; use foundry_evm_traces::{load_contracts, TraceKind, Traces}; use revm::primitives::U256; use std::borrow::Cow; @@ -16,6 +16,7 @@ use std::borrow::Cow; /// Either returns the call result if successful, or nothing if there was an error. pub fn assert_invariants( invariant_contract: &InvariantContract<'_>, + targeted_contracts: &FuzzRunIdentifiedContracts, executor: &Executor, calldata: &[BasicTxDetails], invariant_failures: &mut InvariantFailures, @@ -49,6 +50,7 @@ pub fn assert_invariants( if invariant_failures.error.is_none() { let case_data = FailedInvariantCaseData::new( invariant_contract, + targeted_contracts, Some(func), calldata, call_result, diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 835a2bc877bfd..8f1d3ca57e38e 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -179,6 +179,7 @@ impl<'a> InvariantExecutor<'a> { // This does not count as a fuzz run. It will just register the revert. let last_call_results = RefCell::new(assert_invariants( &invariant_contract, + &targeted_contracts, &self.executor, &[], &mut failures.borrow_mut(), @@ -711,7 +712,7 @@ fn can_continue( !executor.is_success(*contract.0, false, Cow::Borrowed(state_changeset), false) }); - // Assert invariants IFF the call did not revert and the handlers did not fail. + // Assert invariants IF the call did not revert and the handlers did not fail. if !call_result.reverted && !handlers_failed { if let Some(traces) = call_result.traces { run_traces.push(traces); @@ -719,6 +720,7 @@ fn can_continue( call_results = assert_invariants( invariant_contract, + targeted_contracts, executor, calldata, failures, @@ -735,6 +737,7 @@ fn can_continue( if fail_on_revert { let case_data = FailedInvariantCaseData::new( invariant_contract, + targeted_contracts, None, calldata, call_result, diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 82cf4909e7908..4de3d3dcc3018 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -145,6 +145,10 @@ async fn test_invariant() { "default/fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", vec![("invariant_dummy()", true, None, None, None)], ), + ( + "default/fuzz/invariant/common/InvariantCustomError.t.sol:InvariantCustomError", + vec![("invariant_decode_error()", true, None, None, None)], + ), ]), ); } @@ -411,3 +415,24 @@ async fn test_invariant_assume_respects_restrictions() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_decode_custom_error() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantCustomError.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.fail_on_revert = true; + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantCustomError.t.sol:InvariantCustomError", + vec![( + "invariant_decode_error()", + false, + Some("InvariantCustomError(111, \"custom\")".into()), + None, + None, + )], + )]), + ); +} diff --git a/testdata/default/fuzz/invariant/common/InvariantCustomError.t.sol b/testdata/default/fuzz/invariant/common/InvariantCustomError.t.sol new file mode 100644 index 0000000000000..737cf5ba9dd05 --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantCustomError.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.0; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract ContractWithCustomError { + error InvariantCustomError(uint256, string); + + function revertWithInvariantCustomError() external { + revert InvariantCustomError(111, "custom"); + } +} + +contract Handler is DSTest { + ContractWithCustomError target; + + constructor() { + target = new ContractWithCustomError(); + } + + function revertTarget() external { + target.revertWithInvariantCustomError(); + } +} + +contract InvariantCustomError is DSTest { + Handler handler; + + function setUp() external { + handler = new Handler(); + } + + function invariant_decode_error() public {} +} From bbdb034e8d700703534a892c838bf0310372f83c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:44:48 +0200 Subject: [PATCH 0827/1963] feat: right-align and prettify --sizes output (#7601) --- Cargo.lock | 11 +++++++++++ Cargo.toml | 13 +++++-------- crates/cheatcodes/assets/cheatcodes.json | 12 ++++++------ crates/cheatcodes/spec/src/vm.rs | 11 ++++++----- crates/common/Cargo.toml | 1 + crates/common/src/compile.rs | 12 +++++++++--- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e48a7bc30f81..532cd24cfc5ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3275,6 +3275,7 @@ dependencies = [ "foundry-macros", "glob", "globset", + "num-format", "once_cell", "pretty_assertions", "rand 0.8.5", @@ -5219,6 +5220,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec", + "itoa", +] + [[package]] name = "num-integer" version = "0.1.46" diff --git a/Cargo.toml b/Cargo.toml index 661bcb128ce0b..ad300a085c8f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,8 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.76" # Remember to update clippy.toml as well +# Remember to update clippy.toml as well +rust-version = "1.76" authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" @@ -145,9 +146,7 @@ foundry-compilers = { version = "0.3.13", default-features = false } ## revm # no default features to avoid c-kzg revm = { version = "7.1", default-features = false, features = ["std"] } -revm-primitives = { version = "3", default-features = false, features = [ - "std", -] } +revm-primitives = { version = "3", default-features = false, features = ["std"] } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ba0b6ab", features = [ "serde", ] } @@ -192,10 +191,7 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" @@ -216,6 +212,7 @@ tracing-subscriber = "0.3" vergen = { version = "8", default-features = false } indexmap = "2.2" tikv-jemallocator = "0.5.4" +num-format = "0.4.4" axum = "0.6" hyper = "0.14" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 3b4d071d7589a..102c810cdac2a 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -418,32 +418,32 @@ }, { "name": "Gas", - "description": "", + "description": "Gas used. Returned by `lastCallGas`.", "fields": [ { "name": "gasLimit", "ty": "uint64", - "description": "" + "description": "The gas limit of the call." }, { "name": "gasTotalUsed", "ty": "uint64", - "description": "" + "description": "The total gas used." }, { "name": "gasMemoryUsed", "ty": "uint64", - "description": "" + "description": "The amount of gas used for memory expansion." }, { "name": "gasRefunded", "ty": "int64", - "description": "" + "description": "The amount of gas refunded." }, { "name": "gasRemaining", "ty": "uint64", - "description": "" + "description": "The amount of gas remaining." } ] } diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index c350690fcc266..7fb3e29227694 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -73,16 +73,17 @@ interface Vm { address emitter; } + /// Gas used. Returned by `lastCallGas`. struct Gas { - // The gas limit of the call. + /// The gas limit of the call. uint64 gasLimit; - // The total gas used. + /// The total gas used. uint64 gasTotalUsed; - // The amount of gas used for memory expansion. + /// The amount of gas used for memory expansion. uint64 gasMemoryUsed; - // The amount of gas refunded. + /// The amount of gas refunded. int64 gasRefunded; - // The amount of gas remaining. + /// The amount of gas remaining. uint64 gasRemaining; } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index fb161da6127ed..d458786f97b15 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -59,6 +59,7 @@ url = "2" walkdir = "2" yansi = "0.5" rustc-hash.workspace = true +num-format.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index bba5e15d27753..baf73c992abdb 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,7 +1,7 @@ //! Support for compiling [foundry_compilers::Project] use crate::{compact_to_contract, glob::GlobMatcher, term::SpinnerReporter, TestFunctionExt}; -use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Table}; +use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, Table}; use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ @@ -12,6 +12,7 @@ use foundry_compilers::{ Solc, SolcConfig, }; use foundry_linking::Linker; +use num_format::{Locale, ToFormattedString}; use rustc_hash::FxHashMap; use std::{ collections::{BTreeMap, HashMap}, @@ -417,10 +418,15 @@ impl Display for SizeReport { _ => Color::Red, }; + let locale = &Locale::en; table.add_row([ Cell::new(name).fg(color), - Cell::new(contract.size).fg(color), - Cell::new(margin).fg(color), + Cell::new(contract.size.to_formatted_string(locale)) + .set_alignment(CellAlignment::Right) + .fg(color), + Cell::new(margin.to_formatted_string(locale)) + .set_alignment(CellAlignment::Right) + .fg(color), ]); } From a5104477dcf483da2f1f9fe7008178db8a51112a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:22:23 +0300 Subject: [PATCH 0828/1963] fix(invariant): honor targetContract setting, don't update targets if any (#7595) * fix(invariant): respect targetContract setup * Fix test fmt * Check identified contracts after collecting `targetInterfaces` --- .../evm/evm/src/executors/invariant/error.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 50 +++++++------- crates/evm/fuzz/src/invariant/mod.rs | 18 ++++- crates/evm/fuzz/src/strategies/invariants.rs | 6 +- crates/evm/fuzz/src/strategies/state.rs | 4 +- crates/forge/tests/it/invariant.rs | 35 ++++++++++ .../target/FuzzedTargetContracts.t.sol | 66 +++++++++++++++++++ 7 files changed, 150 insertions(+), 31 deletions(-) create mode 100644 testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 98977b539fd54..0695ad6c4effe 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -118,7 +118,7 @@ impl FailedInvariantCaseData { }; // Collect abis of fuzzed and invariant contracts to decode custom error. - let targets = targeted_contracts.lock(); + let targets = targeted_contracts.targets.lock(); let abis = targets .iter() .map(|contract| &contract.1 .1) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 8f1d3ca57e38e..eb4cecb3851e2 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -23,7 +23,7 @@ use foundry_evm_fuzz::{ FuzzCase, FuzzedCases, }; use foundry_evm_traces::CallTraceArena; -use parking_lot::{Mutex, RwLock}; +use parking_lot::RwLock; use proptest::{ strategy::{BoxedStrategy, Strategy, ValueTree}, test_runner::{TestCaseError, TestRunner}, @@ -249,17 +249,20 @@ impl<'a> InvariantExecutor<'a> { collect_data(&mut state_changeset, sender, &call_result, &fuzz_state); - if let Err(error) = collect_created_contracts( - &state_changeset, - self.project_contracts, - self.setup_contracts, - &self.artifact_filters, - targeted_contracts.clone(), - &mut created_contracts, - ) { - warn!(target: "forge::test", "{error}"); + // Collect created contracts and add to fuzz targets only if targeted contracts + // are updatable. + if targeted_contracts.is_updatable { + if let Err(error) = collect_created_contracts( + &state_changeset, + self.project_contracts, + self.setup_contracts, + &self.artifact_filters, + &targeted_contracts, + &mut created_contracts, + ) { + warn!(target: "forge::test", "{error}"); + } } - // Commit changes to the database. executor.backend.commit(state_changeset.clone()); @@ -309,7 +312,7 @@ impl<'a> InvariantExecutor<'a> { // We clear all the targeted contracts created during this run. if !created_contracts.is_empty() { - let mut writable_targeted = targeted_contracts.lock(); + let mut writable_targeted = targeted_contracts.targets.lock(); for addr in created_contracts.iter() { writable_targeted.remove(addr); } @@ -353,19 +356,10 @@ impl<'a> InvariantExecutor<'a> { let (targeted_senders, targeted_contracts) = self.select_contracts_and_senders(invariant_contract.address)?; - if targeted_contracts.is_empty() { - eyre::bail!("No contracts to fuzz."); - } - // Stores fuzz state for use with [fuzz_calldata_from_state]. let fuzz_state: EvmFuzzState = build_initial_state(self.executor.backend.mem_db(), self.config.dictionary); - // During execution, any newly created contract is added here and used through the rest of - // the fuzz run. - let targeted_contracts: FuzzRunIdentifiedContracts = - Arc::new(Mutex::new(targeted_contracts)); - let calldata_fuzz_config = CalldataFuzzDictionary::new(&self.config.dictionary, &fuzz_state); @@ -500,7 +494,7 @@ impl<'a> InvariantExecutor<'a> { pub fn select_contracts_and_senders( &self, to: Address, - ) -> eyre::Result<(SenderFilters, TargetedContracts)> { + ) -> eyre::Result<(SenderFilters, FuzzRunIdentifiedContracts)> { let targeted_senders = self.call_sol_default(to, &IInvariantTest::targetSendersCall {}).targetedSenders; let excluded_senders = @@ -532,7 +526,15 @@ impl<'a> InvariantExecutor<'a> { self.select_selectors(to, &mut contracts)?; - Ok((SenderFilters::new(targeted_senders, excluded_senders), contracts)) + // There should be at least one contract identified as target for fuzz runs. + if contracts.is_empty() { + eyre::bail!("No contracts to fuzz."); + } + + Ok(( + SenderFilters::new(targeted_senders, excluded_senders), + FuzzRunIdentifiedContracts::new(contracts, selected.is_empty()), + )) } /// Extends the contracts and selectors to fuzz with the addresses and ABIs specified in @@ -708,7 +710,7 @@ fn can_continue( let mut call_results = None; // Detect handler assertion failures first. - let handlers_failed = targeted_contracts.lock().iter().any(|contract| { + let handlers_failed = targeted_contracts.targets.lock().iter().any(|contract| { !executor.is_success(*contract.0, false, Cow::Borrowed(state_changeset), false) }); diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index 6dfcd8248739b..d682041e97065 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -10,7 +10,23 @@ mod filters; pub use filters::{ArtifactFilters, SenderFilters}; pub type TargetedContracts = BTreeMap)>; -pub type FuzzRunIdentifiedContracts = Arc>; + +/// Contracts identified as targets during a fuzz run. +/// During execution, any newly created contract is added as target and used through the rest of +/// the fuzz run if the collection is updatable (no `targetContract` specified in `setUp`). +#[derive(Clone, Debug)] +pub struct FuzzRunIdentifiedContracts { + /// Contracts identified as targets during a fuzz run. + pub targets: Arc>, + /// Whether target contracts are updatable or not. + pub is_updatable: bool, +} + +impl FuzzRunIdentifiedContracts { + pub fn new(targets: TargetedContracts, is_updatable: bool) -> Self { + Self { targets: Arc::new(Mutex::new(targets)), is_updatable } + } +} /// (Sender, (TargetContract, Calldata)) pub type BasicTxDetails = (Address, (Address, Bytes)); diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index c98e84598d1b8..137e708523662 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -16,7 +16,7 @@ pub fn override_call_strat( target: Arc>, calldata_fuzz_config: CalldataFuzzDictionary, ) -> SBoxedStrategy<(Address, Bytes)> { - let contracts_ref = contracts.clone(); + let contracts_ref = contracts.targets.clone(); proptest::prop_oneof![ 80 => proptest::strategy::LazyJust::new(move || *target.read()), 20 => any::() @@ -27,7 +27,7 @@ pub fn override_call_strat( let calldata_fuzz_config = calldata_fuzz_config.clone(); let func = { - let contracts = contracts.lock(); + let contracts = contracts.targets.lock(); let (_, abi, functions) = contracts.get(&target_address).unwrap_or_else(|| { // Choose a random contract if target selected by lazy strategy is not in fuzz run // identified contracts. This can happen when contract is created in `setUp` call @@ -81,7 +81,7 @@ fn generate_call( any::() .prop_flat_map(move |selector| { let (contract, func) = { - let contracts = contracts.lock(); + let contracts = contracts.targets.lock(); let contracts = contracts.iter().filter(|(_, (_, abi, _))| !abi.functions.is_empty()); let (&contract, (_, abi, functions)) = selector.select(contracts); diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 3c8f490f3a1e4..3a3b17ed641e5 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -304,10 +304,10 @@ pub fn collect_created_contracts( project_contracts: &ContractsByArtifact, setup_contracts: &ContractsByAddress, artifact_filters: &ArtifactFilters, - targeted_contracts: FuzzRunIdentifiedContracts, + targeted_contracts: &FuzzRunIdentifiedContracts, created_contracts: &mut Vec
, ) -> eyre::Result<()> { - let mut writable_targeted = targeted_contracts.lock(); + let mut writable_targeted = targeted_contracts.targets.lock(); for (address, account) in state_changeset { if !setup_contracts.contains_key(address) { if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 4de3d3dcc3018..49cbce5db7f2d 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -149,6 +149,14 @@ async fn test_invariant() { "default/fuzz/invariant/common/InvariantCustomError.t.sol:InvariantCustomError", vec![("invariant_decode_error()", true, None, None, None)], ), + ( + "default/fuzz/invariant/target/FuzzedTargetContracts.t.sol:ExplicitTargetContract", + vec![("invariant_explicit_target()", true, None, None, None)], + ), + ( + "default/fuzz/invariant/target/FuzzedTargetContracts.t.sol:DynamicTargetContract", + vec![("invariant_dynamic_targets()", true, None, None, None)], + ), ]), ); } @@ -436,3 +444,30 @@ async fn test_invariant_decode_custom_error() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_fuzzed_selected_targets() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/target/FuzzedTargetContracts.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.fail_on_revert = true; + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([ + ( + "default/fuzz/invariant/target/FuzzedTargetContracts.t.sol:ExplicitTargetContract", + vec![("invariant_explicit_target()", true, None, None, None)], + ), + ( + "default/fuzz/invariant/target/FuzzedTargetContracts.t.sol:DynamicTargetContract", + vec![( + "invariant_dynamic_targets()", + false, + Some("revert: wrong target selector called".into()), + None, + None, + )], + ), + ]), + ); +} diff --git a/testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol b/testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol new file mode 100644 index 0000000000000..7988d5c8a2c38 --- /dev/null +++ b/testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +interface Vm { + function etch(address target, bytes calldata newRuntimeBytecode) external; +} + +// https://github.com/foundry-rs/foundry/issues/5625 +// https://github.com/foundry-rs/foundry/issues/6166 +// `Target.wrongSelector` is not called when handler added as `targetContract` +// `Target.wrongSelector` is called (and test fails) when no `targetContract` set +contract Target { + uint256 count; + + function wrongSelector() external { + revert("wrong target selector called"); + } + + function goodSelector() external { + count++; + } +} + +contract Handler is DSTest { + function increment() public { + Target(0x6B175474E89094C44Da98b954EedeAC495271d0F).goodSelector(); + } +} + +contract ExplicitTargetContract is DSTest { + Vm vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); + Handler handler; + + function setUp() public { + Target target = new Target(); + bytes memory targetCode = address(target).code; + vm.etch(address(0x6B175474E89094C44Da98b954EedeAC495271d0F), targetCode); + + handler = new Handler(); + } + + function targetContracts() public returns (address[] memory) { + address[] memory addrs = new address[](1); + addrs[0] = address(handler); + return addrs; + } + + function invariant_explicit_target() public {} +} + +contract DynamicTargetContract is DSTest { + Vm vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); + Handler handler; + + function setUp() public { + Target target = new Target(); + bytes memory targetCode = address(target).code; + vm.etch(address(0x6B175474E89094C44Da98b954EedeAC495271d0F), targetCode); + + handler = new Handler(); + } + + function invariant_dynamic_targets() public {} +} From a6d6a3a8f0442adb0162082fdd8e5aaa69287c80 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:21:20 +0300 Subject: [PATCH 0829/1963] feat(cheatcodes): forge execution context check (#7377) * feat(cheatcodes): forge execution context check * Add tests for test and snapshot contexts * Add isTestContext, isScriptContext cheatcodes * Add script dry run and broadcast tests * Proper enum in cheatcodes schema, alphabetical order * Single isContext cheatcode in env group, taking enum as param. remove context group * Changes after review: remove discriminant calls, use OnceLock * Review changes: tests should not be async * Review changes: implement PartialEq for ForgeContext, remove is_forge_context fn * Properly add new ForgeContext enum --- crates/cheatcodes/assets/cheatcodes.json | 62 ++++++++++++++++++ crates/cheatcodes/spec/src/lib.rs | 1 + crates/cheatcodes/spec/src/vm.rs | 54 ++++++++++++++++ crates/cheatcodes/src/env.rs | 18 +++++- crates/cheatcodes/src/lib.rs | 2 + crates/forge/bin/main.rs | 25 ++++++++ crates/forge/tests/cli/context.rs | 81 ++++++++++++++++++++++++ crates/forge/tests/cli/main.rs | 1 + testdata/cheats/Vm.sol | 2 + 9 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 crates/forge/tests/cli/context.rs diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 102c810cdac2a..26d9dd2e17bc3 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -83,6 +83,48 @@ "description": "The account's code was copied." } ] + }, + { + "name": "ForgeContext", + "description": "Forge execution contexts.", + "variants": [ + { + "name": "TestGroup", + "description": "Test group execution context (test, coverage or snapshot)." + }, + { + "name": "Test", + "description": "`forge test` execution context." + }, + { + "name": "Coverage", + "description": "`forge coverage` execution context." + }, + { + "name": "Snapshot", + "description": "`forge snapshot` execution context." + }, + { + "name": "ScriptGroup", + "description": "Script group execution context (dry run, broadcast or resume)." + }, + { + "name": "ScriptDryRun", + "description": "`forge script` execution context." + }, + { + "name": "ScriptBroadcast", + "description": "`forge script --broadcast` execution context." + }, + { + "name": "ScriptResume", + "description": "`forge script --resume` execution context." + }, + { + "name": "Unknown", + "description": "Unknown `forge` execution context." + } + ] } ], "structs": [ @@ -4849,6 +4891,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "isContext", + "description": "Returns true if `forge` command was executed in given context.", + "declaration": "function isContext(ForgeContext context) external view returns (bool isContext);", + "visibility": "external", + "mutability": "view", + "signature": "isContext(uint8)", + "selector": "0x64af255d", + "selectorBytes": [ + 100, + 175, + 37, + 93 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "isDir", diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index 16bb60834068e..b2a267f8d716a 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -88,6 +88,7 @@ impl Cheatcodes<'static> { enums: Cow::Owned(vec![ Vm::CallerMode::ENUM.clone(), Vm::AccountAccessKind::ENUM.clone(), + Vm::ForgeContext::ENUM.clone(), ]), errors: Vm::VM_ERRORS.iter().map(|&x| x.clone()).collect(), events: Cow::Borrowed(&[]), diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 7fb3e29227694..e7ac87da11a1f 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -3,6 +3,7 @@ #![allow(missing_docs)] use super::*; +use crate::Vm::ForgeContext; use alloy_sol_types::sol; use foundry_macros::Cheatcode; @@ -63,6 +64,28 @@ interface Vm { Extcodecopy, } + /// Forge execution contexts. + enum ForgeContext { + /// Test group execution context (test, coverage or snapshot). + TestGroup, + /// `forge test` execution context. + Test, + /// `forge coverage` execution context. + Coverage, + /// `forge snapshot` execution context. + Snapshot, + /// Script group execution context (dry run, broadcast or resume). + ScriptGroup, + /// `forge script` execution context. + ScriptDryRun, + /// `forge script --broadcast` execution context. + ScriptBroadcast, + /// `forge script --resume` execution context. + ScriptResume, + /// Unknown `forge` execution context. + Unknown, + } + /// An Ethereum log. Returned by `getRecordedLogs`. struct Log { /// The topics of the log, including the signature, if any. @@ -1598,6 +1621,10 @@ interface Vm { external view returns (bytes[] memory value); + /// Returns true if `forge` command was executed in given context. + #[cheatcode(group = Environment)] + function isContext(ForgeContext context) external view returns (bool isContext); + // ======== Scripts ======== // -------- Broadcasting Transactions -------- @@ -2065,3 +2092,30 @@ interface Vm { function toBase64URL(string calldata data) external pure returns (string memory); } } + +impl PartialEq for ForgeContext { + // Handles test group case (any of test, coverage or snapshot) + // and script group case (any of dry run, broadcast or resume). + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (_, &ForgeContext::TestGroup) => { + self == &ForgeContext::Test || + self == &ForgeContext::Snapshot || + self == &ForgeContext::Coverage + } + (_, &ForgeContext::ScriptGroup) => { + self == &ForgeContext::ScriptDryRun || + self == &ForgeContext::ScriptBroadcast || + self == &ForgeContext::ScriptResume + } + (&ForgeContext::Test, &ForgeContext::Test) | + (&ForgeContext::Snapshot, &ForgeContext::Snapshot) | + (&ForgeContext::Coverage, &ForgeContext::Coverage) | + (&ForgeContext::ScriptDryRun, &ForgeContext::ScriptDryRun) | + (&ForgeContext::ScriptBroadcast, &ForgeContext::ScriptBroadcast) | + (&ForgeContext::ScriptResume, &ForgeContext::ScriptResume) | + (&ForgeContext::Unknown, &ForgeContext::Unknown) => true, + _ => false, + } + } +} diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index d6aaea149ee3c..231b47c97eef1 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -4,7 +4,10 @@ use crate::{string, Cheatcode, Cheatcodes, Error, Result, Vm::*}; use alloy_dyn_abi::DynSolType; use alloy_primitives::Bytes; use alloy_sol_types::SolValue; -use std::env; +use std::{env, sync::OnceLock}; + +/// Stores the forge execution context for the duration of the program. +static FORGE_CONTEXT: OnceLock = OnceLock::new(); impl Cheatcode for setEnvCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { @@ -235,6 +238,19 @@ impl Cheatcode for envOr_13Call { } } +impl Cheatcode for isContextCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { context } = self; + Ok((FORGE_CONTEXT.get() == Some(context)).abi_encode()) + } +} + +/// Set `forge` command current execution context for the duration of the program. +/// Execution context is immutable, subsequent calls of this function won't change the context. +pub fn set_execution_context(context: ForgeContext) { + let _ = FORGE_CONTEXT.set(context); +} + fn env(key: &str, ty: &DynSolType) -> Result { get_env(key).and_then(|val| string::parse(&val, ty).map_err(map_env_err(key, &val))) } diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 2fa866b1aeac9..01695fa707006 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -34,8 +34,10 @@ mod test; mod toml; mod utils; +pub use env::set_execution_context; pub use script::ScriptWallets; pub use test::expect::ExpectedCallTracker; +pub use Vm::ForgeContext; /// Cheatcode implementation. pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index b5ba3228f2f1e..acbe80d819cab 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -5,6 +5,7 @@ use clap::{CommandFactory, Parser}; use clap_complete::generate; use eyre::Result; use foundry_cli::{handler, utils}; +use foundry_evm::inspectors::cheatcodes::{set_execution_context, ForgeContext}; mod cmd; use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; @@ -23,6 +24,8 @@ fn main() -> Result<()> { utils::enable_paint(); let opts = Forge::parse(); + init_execution_context(&opts.cmd); + match opts.cmd { ForgeSubcommand::Test(cmd) => { if cmd.is_watch() { @@ -107,3 +110,25 @@ fn main() -> Result<()> { }, } } + +/// Set the program execution context based on `forge` subcommand used. +/// The execution context can be set only once per program, and it can be checked by using +/// cheatcodes. +fn init_execution_context(subcommand: &ForgeSubcommand) { + let context = match subcommand { + ForgeSubcommand::Test(_) => ForgeContext::Test, + ForgeSubcommand::Coverage(_) => ForgeContext::Coverage, + ForgeSubcommand::Snapshot(_) => ForgeContext::Snapshot, + ForgeSubcommand::Script(cmd) => { + if cmd.broadcast { + ForgeContext::ScriptBroadcast + } else if cmd.resume { + ForgeContext::ScriptResume + } else { + ForgeContext::ScriptDryRun + } + } + _ => ForgeContext::Unknown, + }; + set_execution_context(context); +} diff --git a/crates/forge/tests/cli/context.rs b/crates/forge/tests/cli/context.rs new file mode 100644 index 0000000000000..34a7598a37cd9 --- /dev/null +++ b/crates/forge/tests/cli/context.rs @@ -0,0 +1,81 @@ +//! Contains tests for checking forge execution context cheatcodes +const FORGE_TEST_CONTEXT_CONTRACT: &str = r#" +import "./test.sol"; +interface Vm { + enum ForgeContext { TestGroup, Test, Coverage, Snapshot, ScriptGroup, ScriptDryRun, ScriptBroadcast, ScriptResume, Unknown } + function isContext(ForgeContext context) external view returns (bool isContext); +} + +contract ForgeContextTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testForgeTestContext() external view { + require(vm.isContext(Vm.ForgeContext.TestGroup) && !vm.isContext(Vm.ForgeContext.ScriptGroup), "wrong context"); + require(vm.isContext(Vm.ForgeContext.Test), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.Coverage), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.Snapshot), "wrong context"); + } + function testForgeSnapshotContext() external view { + require(vm.isContext(Vm.ForgeContext.TestGroup) && !vm.isContext(Vm.ForgeContext.ScriptGroup), "wrong context"); + require(vm.isContext(Vm.ForgeContext.Snapshot), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.Test), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.Coverage), "wrong context"); + } + function testForgeCoverageContext() external view { + require(vm.isContext(Vm.ForgeContext.TestGroup) && !vm.isContext(Vm.ForgeContext.ScriptGroup), "wrong context"); + require(vm.isContext(Vm.ForgeContext.Coverage), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.Test), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.Snapshot), "wrong context"); + } + + function runDryRun() external view { + require(vm.isContext(Vm.ForgeContext.ScriptGroup) && !vm.isContext(Vm.ForgeContext.TestGroup), "wrong context"); + require(vm.isContext(Vm.ForgeContext.ScriptDryRun), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.ScriptBroadcast), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.ScriptResume), "wrong context"); + } + function runBroadcast() external view { + require(vm.isContext(Vm.ForgeContext.ScriptGroup) && !vm.isContext(Vm.ForgeContext.TestGroup), "wrong context"); + require(vm.isContext(Vm.ForgeContext.ScriptBroadcast), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.ScriptDryRun), "wrong context"); + require(!vm.isContext(Vm.ForgeContext.ScriptResume), "wrong context"); + } +} + "#; + +// tests that context properly set for `forge test` command +forgetest!(can_set_forge_test_standard_context, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source("ForgeContextTest.t.sol", FORGE_TEST_CONTEXT_CONTRACT).unwrap(); + cmd.args(["test", "--match-test", "testForgeTestContext"]).assert_success(); +}); + +// tests that context properly set for `forge snapshot` command +forgetest!(can_set_forge_test_snapshot_context, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source("ForgeContextTest.t.sol", FORGE_TEST_CONTEXT_CONTRACT).unwrap(); + cmd.args(["snapshot", "--match-test", "testForgeSnapshotContext"]).assert_success(); +}); + +// tests that context properly set for `forge coverage` command +forgetest!(can_set_forge_test_coverage_context, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source("ForgeContextTest.t.sol", FORGE_TEST_CONTEXT_CONTRACT).unwrap(); + cmd.args(["coverage", "--match-test", "testForgeCoverageContext"]).assert_success(); +}); + +// tests that context properly set for `forge script` command +forgetest!(can_set_forge_script_dry_run_context, |prj, cmd| { + prj.insert_ds_test(); + let script = + prj.add_source("ForgeScriptContextTest.s.sol", FORGE_TEST_CONTEXT_CONTRACT).unwrap(); + cmd.arg("script").arg(script).args(["--sig", "runDryRun()"]).assert_success(); +}); + +// tests that context properly set for `forge script --broadcast` command +forgetest!(can_set_forge_script_broadcast_context, |prj, cmd| { + prj.insert_ds_test(); + let script = + prj.add_source("ForgeScriptContextTest.s.sol", FORGE_TEST_CONTEXT_CONTRACT).unwrap(); + cmd.arg("script").arg(script).args(["--broadcast", "--sig", "runBroadcast()"]).assert_success(); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index e9dab70f7d1ad..543b84dc7d9c0 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -8,6 +8,7 @@ mod build; mod cache; mod cmd; mod config; +mod context; mod coverage; mod create; mod debug; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 1d7c819738479..8f799c9f69362 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -8,6 +8,7 @@ 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 } 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; } @@ -239,6 +240,7 @@ interface Vm { function getNonce(Wallet calldata wallet) external returns (uint64 nonce); function getRecordedLogs() external returns (Log[] memory logs); function indexOf(string memory input, string memory key) external pure returns (uint256); + function isContext(ForgeContext context) external view returns (bool isContext); function isDir(string calldata path) external returns (bool result); function isFile(string calldata path) external returns (bool result); function isPersistent(address account) external view returns (bool persistent); From f840dbd930f8d7765652ba671a997a414a4bae78 Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 9 Apr 2024 22:52:53 +0200 Subject: [PATCH 0830/1963] [wip] feat: provider alloy migration (#7106) * chore: make cast use an alloy provider * move initial methods to alloy * feat(`foundry-common`): NameOrAddress ENS util (#7122) * feat(foundry-common): NameOrAddress ENS util * chore: rename err * chore: remove from impl for str * chore: unrelated fix from alloy upgrade * nit * feat(`cast`): Move non `tx` methods to alloy (#7129) * chore: add alloy contract * feat(cast): migrate most methods to alloy * chore: leave todo for converting a tx envelope into an rpc tx * fix: use proper type for storage * readd decodetx for now * chore: extend txbuilder to build an alloy tx request * feat: migrate most methods bar send/decode raw tx * fix: include tx data * simplify txbuilder * chore: simplify back access_list * chore: remove unnecesary conversion * fmt * doctests * fmt * do not use trait * Update crates/cast/bin/main.rs Co-authored-by: Matthias Seitz * cleanup builder * clippy * fix doc comments --------- Co-authored-by: Matthias Seitz * DocumentMut * wip * wip * wip: bump alloy * wip * wip * wip * [wip] migrate to alloy providers and signers (#7425) wip * fix wallets after alloy bump * clean up deps * use serde on consensus types * update TypedTransaction for anvil * make anvil compile * wip: make script compile * fix script * make forge compile * fix: anvil tests * bump alloy * fix tests * fix tx builder * fix cargo.toml * fix cargo.toml * fix script gas price logic * remove ethers from anvil * clippy * rm all_derives * deps * fmt * fix tests * configure clippy * clippy * add feature * fix cargo deny * fix persist * fix doctests * fmt * fix clap * review fixes * fmt * bump alloy * Update cargo.toml * fmt * fixes * ethers clean-up * fix(fmt): fix indent closing parenthesis enclosed in { } (#7557) * fix(fmt): fix indent closing parenthesis enclosed in { } * Fix testdata bad formatting * feat(test): only compile files needed for tests (#7334) * feat(forge test): only compile files needed for tests * remove comment * clippy * update fixtures * getCode + getDeployedCode updates * fixes * fix path matching * clippy * add config flag * fix * docs * fmt * patch compilers * fix Cargo.toml * update patch * update patch * doc * rm space * cargo cheats * new output selection fn * log compiler errors on failure * fixes * fix: do not flood dictionary with data dependent on fuzz inputs (#7552) * fix dictionary * clippy + fmt * fix * Feat: Index cheatcode for Strings (#7539) * feat: index cheatcode * some nits to make it work * nit: use as_str() * final changes * chore: reviewed changes * chore: reduce logs in tests (#7566) * fix(script): decode custom error in script fail message (#7563) * clippy * bump alloy * AnyNetwork * bump alloy * add comment * clippy * bump alloy * fixes * refactor cast logs to use alloy (#7594) * refactor cast logs to use alloy * fmt * make clippy happy * cleanup * doc nits --------- Co-authored-by: evalir --------- Co-authored-by: Matthias Seitz Co-authored-by: Arsenii Kulikov Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> Co-authored-by: Krishang <93703995+kamuik16@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: bernard-wagner --- Cargo.lock | 1108 +++++++++++------ Cargo.toml | 65 +- clippy.toml | 3 + crates/anvil/Cargo.toml | 21 +- crates/anvil/core/Cargo.toml | 10 +- crates/anvil/core/src/eth/block.rs | 37 +- crates/anvil/core/src/eth/mod.rs | 18 +- crates/anvil/core/src/eth/transaction/mod.rs | 739 ++++++----- .../core/src/eth/transaction/optimism.rs | 131 +- crates/anvil/core/src/types.rs | 6 +- crates/anvil/src/cmd.rs | 14 +- crates/anvil/src/config.rs | 66 +- crates/anvil/src/eth/api.rs | 222 ++-- crates/anvil/src/eth/backend/executor.rs | 103 +- crates/anvil/src/eth/backend/fork.rs | 107 +- crates/anvil/src/eth/backend/mem/mod.rs | 420 +++---- crates/anvil/src/eth/backend/mem/storage.rs | 25 +- crates/anvil/src/eth/error.rs | 9 +- crates/anvil/src/eth/fees.rs | 135 +- crates/anvil/src/eth/otterscan/api.rs | 12 +- crates/anvil/src/eth/otterscan/types.rs | 34 +- crates/anvil/src/eth/pool/transactions.rs | 10 +- crates/anvil/src/eth/sign.rs | 18 +- crates/anvil/src/lib.rs | 4 +- crates/anvil/src/pubsub.rs | 50 +- crates/anvil/src/tasks/mod.rs | 67 +- crates/anvil/tests/it/anvil_api.rs | 16 +- crates/anvil/tests/it/api.rs | 12 +- crates/anvil/tests/it/fork.rs | 57 +- crates/anvil/tests/it/gas.rs | 27 +- crates/anvil/tests/it/genesis.rs | 6 +- crates/anvil/tests/it/otterscan.rs | 11 +- crates/anvil/tests/it/transaction.rs | 44 +- crates/anvil/tests/it/wsapi.rs | 2 +- crates/cast/Cargo.toml | 28 +- crates/cast/bin/cmd/access_list.rs | 91 +- crates/cast/bin/cmd/call.rs | 141 +-- crates/cast/bin/cmd/estimate.rs | 42 +- crates/cast/bin/cmd/find_block.rs | 34 +- crates/cast/bin/cmd/logs.rs | 278 ++--- crates/cast/bin/cmd/mktx.rs | 30 +- crates/cast/bin/cmd/run.rs | 21 +- crates/cast/bin/cmd/send.rs | 66 +- crates/cast/bin/cmd/storage.rs | 43 +- crates/cast/bin/cmd/wallet/list.rs | 4 +- crates/cast/bin/cmd/wallet/mod.rs | 26 +- crates/cast/bin/cmd/wallet/vanity.rs | 3 +- crates/cast/bin/main.rs | 74 +- crates/cast/bin/opts.rs | 27 +- crates/cast/bin/tx.rs | 97 +- crates/cast/src/lib.rs | 353 +++--- crates/cast/src/tx.rs | 402 ------ crates/cheatcodes/Cargo.toml | 5 +- crates/cheatcodes/src/env.rs | 3 +- crates/cheatcodes/src/error.rs | 3 +- crates/cheatcodes/src/evm.rs | 10 +- crates/cheatcodes/src/evm/fork.rs | 38 +- crates/cheatcodes/src/evm/mock.rs | 4 +- crates/cheatcodes/src/fs.rs | 9 +- crates/cheatcodes/src/inspector.rs | 51 +- crates/cheatcodes/src/script.rs | 2 +- crates/cheatcodes/src/test/expect.rs | 6 +- crates/cheatcodes/src/utils.rs | 24 +- crates/cli/Cargo.toml | 12 +- crates/cli/src/opts/transaction.rs | 4 +- crates/cli/src/utils/abi.rs | 61 + crates/cli/src/utils/mod.rs | 71 +- crates/common/Cargo.toml | 19 +- crates/common/src/abi.rs | 2 +- crates/common/src/constants.rs | 2 +- crates/common/src/ens.rs | 193 +++ crates/common/src/fmt/ui.rs | 295 +++-- crates/common/src/lib.rs | 1 + crates/common/src/provider/alloy.rs | 28 +- crates/common/src/provider/ethers.rs | 40 - crates/common/src/provider/retry.rs | 3 + crates/common/src/runtime_client.rs | 8 +- crates/common/src/transactions.rs | 84 +- crates/common/src/types.rs | 96 +- crates/config/Cargo.toml | 2 +- crates/config/src/fix.rs | 8 +- crates/config/src/lib.rs | 6 +- crates/config/src/utils.rs | 6 +- crates/evm/core/Cargo.toml | 10 +- crates/evm/core/src/backend/cow.rs | 6 +- crates/evm/core/src/backend/mod.rs | 56 +- crates/evm/core/src/fork/backend.rs | 59 +- crates/evm/core/src/fork/init.rs | 23 +- crates/evm/core/src/fork/multi.rs | 10 +- crates/evm/core/src/opts.rs | 6 +- crates/evm/core/src/utils.rs | 11 +- crates/evm/evm/src/inspectors/stack.rs | 4 +- crates/evm/fuzz/src/strategies/state.rs | 6 +- crates/forge/Cargo.toml | 15 +- crates/forge/bin/cmd/create.rs | 261 ++-- crates/forge/tests/cli/utils.rs | 5 +- crates/forge/tests/it/invariant.rs | 4 +- crates/forge/tests/it/repros.rs | 32 +- crates/script/Cargo.toml | 15 +- crates/script/src/broadcast.rs | 162 ++- crates/script/src/build.rs | 11 +- crates/script/src/execute.rs | 13 +- crates/script/src/lib.rs | 14 +- crates/script/src/providers.rs | 36 +- crates/script/src/receipts.rs | 78 +- crates/script/src/sequence.rs | 27 +- crates/script/src/simulate.rs | 34 +- crates/script/src/transaction.rs | 260 +--- crates/test-utils/Cargo.toml | 4 +- crates/test-utils/src/script.rs | 47 +- crates/verify/Cargo.toml | 2 +- crates/verify/src/etherscan/mod.rs | 15 +- crates/wallets/Cargo.toml | 22 +- crates/wallets/src/error.rs | 8 +- crates/wallets/src/multi_wallet.rs | 16 +- crates/wallets/src/utils.rs | 42 +- crates/wallets/src/wallet.rs | 11 +- crates/wallets/src/wallet_signer.rs | 133 +- 118 files changed, 3842 insertions(+), 4081 deletions(-) delete mode 100644 crates/cast/src/tx.rs create mode 100644 crates/cli/src/utils/abi.rs create mode 100644 crates/common/src/ens.rs diff --git a/Cargo.lock b/Cargo.lock index 532cd24cfc5ae..770e28567edda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,22 +79,41 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-eips", - "alloy-network", "alloy-primitives", "alloy-rlp", + "alloy-serde", "c-kzg", - "sha2 0.10.8", + "serde", + "sha2", + "thiserror", +] + +[[package]] +name = "alloy-contract" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-network", + "alloy-primitives", + "alloy-provider", + "alloy-rpc-types", + "alloy-sol-types", + "alloy-transport", + "futures", + "futures-util", "thiserror", ] [[package]] name = "alloy-dyn-abi" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2919acdad13336bc5dc26b636cdd6892c2f27fb0d4a58320a00c2713cf6a4e9a" +checksum = "872f239c15befa27cc4f0d3d82a70b3365c2d0202562bf906eb93b299fa31882" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -114,29 +133,32 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-primitives", "alloy-rlp", + "alloy-serde", + "c-kzg", + "derive_more", + "once_cell", "serde", - "thiserror", ] [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-primitives", - "alloy-rpc-types", + "alloy-serde", "serde", ] [[package]] name = "alloy-json-abi" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ed0f2a6c3a1c947b4508522a53a190dba8f94dcd4e3e1a5af945a498e78f2f" +checksum = "83a35ddfd27576474322a5869e4c123e5f3e7b2177297c18e4e82ea501cb125b" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -147,7 +169,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-primitives", "serde", @@ -158,20 +180,24 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-primitives", - "alloy-rlp", - "serde", + "alloy-rpc-types", + "alloy-signer", + "async-trait", + "futures-utils-wasm", + "thiserror", ] [[package]] name = "alloy-primitives" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600d34d8de81e23b6d909c094e23b3d357e01ca36b78a8c5424c501eedbe86f0" +checksum = "99bbad0a6b588ef4aec1b5ddbbfdacd9ef04e00b979617765b03174318ee1f3a" dependencies = [ "alloy-rlp", "arbitrary", @@ -195,25 +221,27 @@ dependencies = [ ] [[package]] -name = "alloy-providers" +name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ + "alloy-eips", + "alloy-json-rpc", "alloy-network", "alloy-primitives", + "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-trace-types", "alloy-rpc-types", + "alloy-rpc-types-trace", "alloy-transport", - "alloy-transport-http", "async-stream", "async-trait", "auto_impl", + "dashmap", "futures", + "futures-utils-wasm", "lru", - "reqwest 0.11.27", - "serde", - "thiserror", + "serde_json", "tokio", "tracing", ] @@ -221,7 +249,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -255,63 +283,144 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-json-rpc", + "alloy-primitives", + "alloy-pubsub", "alloy-transport", "alloy-transport-http", "futures", "pin-project", - "reqwest 0.11.27", "serde", "serde_json", "tokio", "tokio-stream", "tower", "tracing", - "url", ] [[package]] -name = "alloy-rpc-trace-types" +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-genesis", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "alloy-sol-types", + "itertools 0.12.1", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-primitives", "alloy-rpc-types", + "alloy-serde", "serde", "serde_json", ] [[package]] -name = "alloy-rpc-types" +name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-primitives", - "alloy-rlp", - "itertools 0.12.1", "serde", "serde_json", - "thiserror", ] [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ - "alloy-network", + "alloy-dyn-abi", "alloy-primitives", "alloy-sol-types", "async-trait", "auto_impl", + "elliptic-curve", + "k256", + "thiserror", +] + +[[package]] +name = "alloy-signer-aws" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", + "aws-sdk-kms", + "k256", + "spki", + "thiserror", + "tracing", +] + +[[package]] +name = "alloy-signer-ledger" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", + "coins-ledger", + "futures-util", + "semver 1.0.22", + "thiserror", + "tracing", +] + +[[package]] +name = "alloy-signer-trezor" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", + "semver 1.0.22", + "thiserror", + "tracing", + "trezor-client", +] + +[[package]] +name = "alloy-signer-wallet" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", "coins-bip32", "coins-bip39", "elliptic-curve", @@ -323,38 +432,54 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86ec0a47740b20bc5613b8712d0d321d031c4efc58e9645af96085d5cccfc27" +checksum = "452d929748ac948a10481fff4123affead32c553cf362841c5103dd508bdfc16" dependencies = [ "alloy-json-abi", + "alloy-sol-macro-input", "const-hex", - "dunce", "heck 0.4.1", "indexmap", "proc-macro-error", "proc-macro2", "quote", - "serde_json", - "syn 2.0.57", + "syn 2.0.58", "syn-solidity", "tiny-keccak", ] +[[package]] +name = "alloy-sol-macro-input" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df64e094f6d2099339f9e82b5b38440b159757b6920878f28316243f8166c8d1" +dependencies = [ + "alloy-json-abi", + "const-hex", + "dunce", + "heck 0.5.0", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.58", + "syn-solidity", +] + [[package]] name = "alloy-sol-type-parser" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0045cc89524e1451ccf33e8581355b6027ac7c6e494bb02959d4213ad0d8e91d" +checksum = "715f4d09a330cc181fc7c361b5c5c2766408fa59a0bac60349dcb7baabd404cc" dependencies = [ "winnow 0.6.5", ] [[package]] name = "alloy-sol-types" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad09ec5853fa700d12d778ad224dcdec636af424d29fad84fb9a2f16a5b0ef09" +checksum = "43bc2d6dfc2a19fd56644494479510f98b1ee929e04cf0d4aa45e98baa3e545b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -366,11 +491,12 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-json-rpc", "base64 0.22.0", "futures-util", + "futures-utils-wasm", "serde", "serde_json", "thiserror", @@ -383,11 +509,11 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.11.27", + "reqwest 0.12.2", "serde_json", "tower", "url", @@ -396,7 +522,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -414,7 +540,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" +source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -429,9 +555,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b9e1498416f7e7f09af8061970e14936846b6271e153aa5ba539a22a7eb414d" +checksum = "beb28aa4ecd32fdfa1b1bdd111ff7357dd562c6b2372694cf9e613434fcba659" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -536,11 +662,12 @@ dependencies = [ "alloy-json-abi", "alloy-network", "alloy-primitives", - "alloy-providers", + "alloy-provider", "alloy-rlp", - "alloy-rpc-trace-types", "alloy-rpc-types", + "alloy-rpc-types-trace", "alloy-signer", + "alloy-signer-wallet", "alloy-sol-types", "alloy-transport", "alloy-trie", @@ -599,8 +726,8 @@ dependencies = [ "alloy-network", "alloy-primitives", "alloy-rlp", - "alloy-rpc-trace-types", "alloy-rpc-types", + "alloy-rpc-types-trace", "alloy-trie", "anvil-core", "bytes", @@ -846,7 +973,7 @@ checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -868,7 +995,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -885,7 +1012,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -938,7 +1065,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -947,6 +1074,324 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "aws-config" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297b64446175a73987cedc3c438d79b2a654d0fff96f65ff530fbe039347644c" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-sdk-sso", + "aws-sdk-ssooidc", + "aws-sdk-sts", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "hex", + "http 0.2.12", + "hyper 0.14.28", + "ring 0.17.8", + "time", + "tokio", + "tracing", + "url", + "zeroize", +] + +[[package]] +name = "aws-credential-types" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8587ae17c8e967e4b05a62d495be2fb7701bec52a97f7acfe8a29f938384c8" +dependencies = [ + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "zeroize", +] + +[[package]] +name = "aws-runtime" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b13dc54b4b49f8288532334bba8f87386a40571c47c37b1304979b556dc613c8" +dependencies = [ + "aws-credential-types", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "http 0.2.12", + "http-body 0.4.6", + "percent-encoding", + "pin-project-lite", + "tracing", + "uuid 1.8.0", +] + +[[package]] +name = "aws-sdk-kms" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a4e610d67363f6846c903ebca4ce65439033d5ec2a5d8effc96d5eaa53355" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-sso" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "019a07902c43b03167ea5df0182f0cb63fae89f9a9682c44d18cf2e4a042cb34" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-ssooidc" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04c46ee08a48a7f4eaa4ad201dcc1dd537b49c50859d14d4510e00ad9d3f9af2" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-sts" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f752ac730125ca6017f72f9db5ec1772c9ecc664f87aa7507a7d81b023c23713" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-query", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sigv4" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d6f29688a4be9895c0ba8bef861ad0c0dac5c15e9618b9b7a6c233990fc263" +dependencies = [ + "aws-credential-types", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "form_urlencoded", + "hex", + "hmac", + "http 0.2.12", + "http 1.1.0", + "once_cell", + "percent-encoding", + "sha2", + "time", + "tracing", +] + +[[package]] +name = "aws-smithy-async" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" +dependencies = [ + "futures-util", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "aws-smithy-http" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f10fa66956f01540051b0aa7ad54574640f748f9839e843442d99b970d3aff9" +dependencies = [ + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tracing", +] + +[[package]] +name = "aws-smithy-json" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4683df9469ef09468dad3473d129960119a0d3593617542b7d52086c8486f2d6" +dependencies = [ + "aws-smithy-types", +] + +[[package]] +name = "aws-smithy-query" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fbd61ceb3fe8a1cb7352e42689cec5335833cd9f94103a61e98f9bb61c64bb" +dependencies = [ + "aws-smithy-types", + "urlencoding", +] + +[[package]] +name = "aws-smithy-runtime" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c53572b4cd934ee5e8461ad53caa36e9d246aaef42166e3ac539e206a925d330" +dependencies = [ + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "fastrand", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "http-body 1.0.0", + "hyper 0.14.28", + "hyper-rustls 0.24.2", + "once_cell", + "pin-project-lite", + "pin-utils", + "rustls 0.21.10", + "tokio", + "tracing", +] + +[[package]] +name = "aws-smithy-runtime-api" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccb2b3a7030dc9a3c9a08ce0b25decea5130e9db19619d4dffbbff34f75fe850" +dependencies = [ + "aws-smithy-async", + "aws-smithy-types", + "bytes", + "http 0.2.12", + "http 1.1.0", + "pin-project-lite", + "tokio", + "tracing", + "zeroize", +] + +[[package]] +name = "aws-smithy-types" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe14dceea1e70101d38fbf2a99e6a34159477c0fb95e68e05c66bd7ae4c3729" +dependencies = [ + "base64-simd", + "bytes", + "bytes-utils", + "http 0.2.12", + "http 1.1.0", + "http-body 0.4.6", + "http-body 1.0.0", + "http-body-util", + "itoa", + "num-integer", + "pin-project-lite", + "pin-utils", + "ryu", + "serde", + "time", +] + +[[package]] +name = "aws-smithy-xml" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872c68cf019c0e4afc5de7753c4f7288ce4b71663212771bf5e4542eb9346ca9" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "aws-types" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dbf2f3da841a8930f159163175cf6a3d16ddde517c1b0fba7aa776822800f40" +dependencies = [ + "aws-credential-types", + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "http 0.2.12", + "rustc_version 0.4.0", + "tracing", +] + [[package]] name = "axum" version = "0.6.20" @@ -1038,6 +1483,16 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" +dependencies = [ + "outref", + "vsimd", +] + [[package]] name = "base64ct" version = "1.6.0" @@ -1094,19 +1549,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", - "radium", - "serde", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", + "radium", + "serde", + "tap", + "wyz", ] [[package]] @@ -1152,7 +1598,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ - "sha2 0.10.8", + "sha2", "tinyvec", ] @@ -1215,6 +1661,16 @@ dependencies = [ "serde", ] +[[package]] +name = "bytes-utils" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35" +dependencies = [ + "bytes", + "either", +] + [[package]] name = "bzip2" version = "0.4.4" @@ -1238,9 +1694,9 @@ dependencies = [ [[package]] name = "c-kzg" -version = "0.4.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a4bc5367b6284358d2a6a6a1dc2d92ec4b86034561c3b9d3341909752fd848" +checksum = "3130f3d8717cc02e668a896af24984d5d5d4e8bf12e278e982e0f1bd88a0f9af" dependencies = [ "blst", "cc", @@ -1292,14 +1748,23 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" name = "cast" version = "0.2.0" dependencies = [ + "alloy-chains", + "alloy-consensus", + "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", + "alloy-json-rpc", + "alloy-network", "alloy-primitives", - "alloy-providers", + "alloy-provider", "alloy-rlp", "alloy-rpc-types", "alloy-signer", + "alloy-signer-wallet", + "alloy-sol-types", + "alloy-transport", "async-trait", + "aws-sdk-kms", "chrono", "clap", "clap_complete", @@ -1308,12 +1773,8 @@ dependencies = [ "const-hex", "criterion", "dunce", - "eth-keystore", "ethers-contract", "ethers-core", - "ethers-middleware", - "ethers-providers", - "ethers-signers", "evm-disassembler", "evmole", "eyre", @@ -1332,8 +1793,6 @@ dependencies = [ "rayon", "regex", "rpassword", - "rusoto_core", - "rusoto_kms", "semver 1.0.22", "serde", "serde_json", @@ -1421,7 +1880,6 @@ dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "serde", "windows-targets 0.52.4", ] @@ -1481,7 +1939,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", "terminal_size", "unicase", "unicode-width", @@ -1515,7 +1973,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -1557,10 +2015,10 @@ dependencies = [ "bs58", "coins-core", "digest 0.10.7", - "hmac 0.12.1", + "hmac", "k256", "serde", - "sha2 0.10.8", + "sha2", "thiserror", ] @@ -1572,11 +2030,11 @@ checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" dependencies = [ "bitvec", "coins-bip32", - "hmac 0.12.1", + "hmac", "once_cell", "pbkdf2 0.12.2", "rand 0.8.5", - "sha2 0.10.8", + "sha2", "thiserror", ] @@ -1595,7 +2053,7 @@ dependencies = [ "ripemd", "serde", "serde_derive", - "sha2 0.10.8", + "sha2", "sha3", "thiserror", ] @@ -1916,16 +2374,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "ctr" version = "0.9.2" @@ -1966,7 +2414,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -1977,7 +2425,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -2038,7 +2486,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -2059,7 +2507,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -2069,7 +2517,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -2119,7 +2567,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "const-oid", "crypto-common", "subtle", @@ -2313,7 +2761,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -2375,16 +2823,16 @@ dependencies = [ "ctr", "digest 0.10.7", "hex", - "hmac 0.12.1", + "hmac", "pbkdf2 0.11.0", "rand 0.8.5", "scrypt", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "sha3", "thiserror", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -2525,7 +2973,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.57", + "syn 2.0.58", "toml 0.8.12", "walkdir", ] @@ -2543,7 +2991,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -2569,7 +3017,7 @@ dependencies = [ "serde", "serde_json", "strum 0.26.2", - "syn 2.0.57", + "syn 2.0.58", "tempfile", "thiserror", "tiny-keccak", @@ -2666,23 +3114,14 @@ dependencies = [ "async-trait", "coins-bip32", "coins-bip39", - "coins-ledger", "const-hex", "elliptic-curve", "eth-keystore", "ethers-core", - "futures-executor", - "futures-util", - "home", "rand 0.8.5", - "rusoto_core", - "rusoto_kms", - "semver 1.0.22", - "sha2 0.10.8", - "spki", + "sha2", "thiserror", "tracing", - "trezor-client", ] [[package]] @@ -2698,7 +3137,7 @@ dependencies = [ "ethers-core", "glob", "home", - "md-5 0.10.6", + "md-5", "num_cpus", "once_cell", "path-slash", @@ -2821,7 +3260,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -2948,10 +3387,17 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" name = "forge" version = "0.2.0" dependencies = [ + "alloy-chains", + "alloy-consensus", "alloy-dyn-abi", "alloy-json-abi", + "alloy-network", "alloy-primitives", + "alloy-provider", "alloy-rpc-types", + "alloy-signer", + "alloy-signer-wallet", + "alloy-transport", "anvil", "async-trait", "axum", @@ -2965,9 +3411,6 @@ dependencies = [ "dunce", "ethers-contract", "ethers-core", - "ethers-middleware", - "ethers-providers", - "ethers-signers", "evm-disassembler", "eyre", "forge-doc", @@ -3065,18 +3508,21 @@ dependencies = [ name = "forge-script" version = "0.2.0" dependencies = [ + "alloy-chains", "alloy-dyn-abi", + "alloy-eips", "alloy-json-abi", + "alloy-network", "alloy-primitives", + "alloy-provider", "alloy-rpc-types", + "alloy-signer", + "alloy-transport", "async-recursion", "clap", "const-hex", "dialoguer", "dunce", - "ethers-core", - "ethers-providers", - "ethers-signers", "eyre", "forge-verify", "foundry-cheatcodes", @@ -3107,10 +3553,10 @@ version = "0.2.0" dependencies = [ "alloy-json-abi", "alloy-primitives", + "alloy-provider", "async-trait", "clap", "const-hex", - "ethers-providers", "eyre", "foundry-block-explorers", "foundry-cli", @@ -3142,9 +3588,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e88929768c22f9912694c634db053cfd480c3f7bd7eb39223e29f4fb40b64b7" +checksum = "ee75d972291181ae98bd1b48647ca8d8832159012b240ca1b7225085d4a63f00" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3166,9 +3612,10 @@ dependencies = [ "alloy-genesis", "alloy-json-abi", "alloy-primitives", - "alloy-providers", + "alloy-provider", "alloy-rpc-types", "alloy-signer", + "alloy-signer-wallet", "alloy-sol-types", "base64 0.22.0", "const-hex", @@ -3210,14 +3657,16 @@ dependencies = [ name = "foundry-cli" version = "0.2.0" dependencies = [ + "alloy-chains", "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", + "alloy-provider", + "alloy-transport", "clap", "color-eyre", + "const-hex", "dotenvy", - "ethers-core", - "ethers-providers", "eyre", "forge-fmt", "foundry-common", @@ -3226,6 +3675,7 @@ dependencies = [ "foundry-debugger", "foundry-evm", "foundry-wallets", + "futures", "indicatif", "once_cell", "regex", @@ -3244,15 +3694,17 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ + "alloy-consensus", + "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", "alloy-json-rpc", "alloy-primitives", - "alloy-providers", + "alloy-provider", "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", - "alloy-signer", + "alloy-signer-wallet", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3280,6 +3732,7 @@ dependencies = [ "pretty_assertions", "rand 0.8.5", "reqwest 0.11.27", + "reqwest 0.12.2", "rustc-hash", "semver 1.0.22", "serde", @@ -3296,9 +3749,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079ada1a2093e0fec67caa15ccf018a2d1b5747c16ba1c11a28df53530eb1a5f" +checksum = "dd3323f90e9f256a2c359dbb1cc7e1b7e4fef9e04e5a82693895e959a6efe010" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3309,7 +3762,7 @@ dependencies = [ "futures-util", "home", "itertools 0.12.1", - "md-5 0.10.6", + "md-5", "memmap2 0.9.4", "once_cell", "path-slash", @@ -3319,7 +3772,7 @@ dependencies = [ "semver 1.0.22", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "solang-parser", "svm-rs 0.4.1", "svm-rs-builds", @@ -3360,7 +3813,7 @@ dependencies = [ "tempfile", "thiserror", "toml 0.8.12", - "toml_edit 0.21.1", + "toml_edit 0.22.9", "tracing", "walkdir", ] @@ -3420,9 +3873,10 @@ dependencies = [ "alloy-genesis", "alloy-json-abi", "alloy-primitives", - "alloy-providers", + "alloy-provider", "alloy-rpc-types", "alloy-sol-types", + "alloy-transport", "arrayvec", "auto_impl", "const-hex", @@ -3531,7 +3985,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -3539,8 +3993,7 @@ name = "foundry-test-utils" version = "0.2.0" dependencies = [ "alloy-primitives", - "ethers-core", - "ethers-providers", + "alloy-provider", "eyre", "fd-lock 4.0.2", "foundry-common", @@ -3560,21 +4013,27 @@ dependencies = [ name = "foundry-wallets" version = "0.2.0" dependencies = [ + "alloy-consensus", + "alloy-dyn-abi", + "alloy-network", "alloy-primitives", + "alloy-signer", + "alloy-signer-aws", + "alloy-signer-ledger", + "alloy-signer-trezor", + "alloy-signer-wallet", + "alloy-sol-types", "async-trait", + "aws-config", + "aws-sdk-kms", "clap", "const-hex", "derive_builder", - "ethers-core", - "ethers-providers", - "ethers-signers", "eyre", "foundry-common", "foundry-config", "itertools 0.12.1", "rpassword", - "rusoto_core", - "rusoto_kms", "serde", "thiserror", "tokio", @@ -3708,7 +4167,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -3751,6 +4210,12 @@ dependencies = [ "slab", ] +[[package]] +name = "futures-utils-wasm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" + [[package]] name = "fxhash" version = "0.2.1" @@ -4169,16 +4634,6 @@ dependencies = [ "rusb", ] -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "hmac" version = "0.12.1" @@ -4334,21 +4789,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" -dependencies = [ - "http 0.2.12", - "hyper 0.14.28", - "log", - "rustls 0.20.9", - "rustls-native-certs 0.6.3", - "tokio", - "tokio-rustls 0.23.4", -] - [[package]] name = "hyper-rustls" version = "0.24.2" @@ -4358,7 +4798,9 @@ dependencies = [ "futures-util", "http 0.2.12", "hyper 0.14.28", + "log", "rustls 0.21.10", + "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", ] @@ -4733,7 +5175,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2 0.10.8", + "sha2", "signature", ] @@ -4921,17 +5363,6 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" -[[package]] -name = "md-5" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "md-5" version = "0.10.6" @@ -5023,7 +5454,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5300,7 +5731,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5352,12 +5783,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "open-fastrlp" version = "0.1.4" @@ -5417,7 +5842,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5444,6 +5869,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "outref" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" + [[package]] name = "overload" version = "0.1.1" @@ -5465,7 +5896,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.8", + "sha2", ] [[package]] @@ -5567,9 +5998,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest 0.10.7", - "hmac 0.12.1", + "hmac", "password-hash", - "sha2 0.10.8", + "sha2", ] [[package]] @@ -5579,7 +6010,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ "digest 0.10.7", - "hmac 0.12.1", + "hmac", ] [[package]] @@ -5602,7 +6033,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5660,7 +6091,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5671,7 +6102,7 @@ checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" dependencies = [ "once_cell", "pest", - "sha2 0.10.8", + "sha2", ] [[package]] @@ -5763,7 +6194,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5801,7 +6232,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5912,7 +6343,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -6007,7 +6438,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", "version_check", "yansi 1.0.1", ] @@ -6076,9 +6507,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce76ce678ffc8e5675b22aa1405de0b7037e2fdf8913fea40d1926c6fe1e6e7" +checksum = "5f0530d13d87d1f549b66a3e8d0c688952abe5994e204ed62615baaf25dc029c" dependencies = [ "bitflags 2.5.0", "memchr", @@ -6293,6 +6724,12 @@ dependencies = [ "regex-syntax 0.8.3", ] +[[package]] +name = "regex-lite" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -6346,7 +6783,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots", + "webpki-roots 0.25.4", "winreg", ] @@ -6388,14 +6825,15 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.26.1", "winreg", ] [[package]] name = "revm" -version = "7.1.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "217d21144d329f21d5245b8e6a46e0d6d0a527d9917d7a087f225b161e529169" +checksum = "72a454c1c650b2b2e23f0c461af09e6c31e1d15e1cbebe905a701c46b8a50afc" dependencies = [ "auto_impl", "cfg-if", @@ -6409,11 +6847,11 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=ba0b6ab#ba0b6ab695802c752601f17f5c941b62a067ad64" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=510d4d0#510d4d0d06130d52ee996fa8aebd32cdc8267905" dependencies = [ "alloy-primitives", - "alloy-rpc-trace-types", "alloy-rpc-types", + "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "colorchoice", @@ -6425,9 +6863,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "3.3.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "776848391ed76d5103ca1aa1632cd21b521e2870afb30b63723da862d69efd0f" +checksum = "d322f2730cd300e99d271a1704a2dfb8973d832428f5aa282aaa40e2473b5eec" dependencies = [ "revm-primitives", "serde", @@ -6435,9 +6873,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "5.0.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3fd1856a7cb09197a02669d779e1afb5a627b0888a24814ba2b6a1ad4c3ff8d" +checksum = "931f692f3f4fc72ec39d5d270f8e9d208c4a6008de7590ee96cf948e3b6d3f8d" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6446,15 +6884,15 @@ dependencies = [ "revm-primitives", "ripemd", "secp256k1", - "sha2 0.10.8", + "sha2", "substrate-bn", ] [[package]] name = "revm-primitives" -version = "3.0.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a4d7d3e793e907dc0797a9d3b43abfdf5226d133855214db9bd27d4cee33ebd" +checksum = "cbbc9640790cebcb731289afb7a7d96d16ad94afeb64b5d0b66443bd151e79d6" dependencies = [ "alloy-primitives", "auto_impl", @@ -6475,7 +6913,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "hmac 0.12.1", + "hmac", "subtle", ] @@ -6602,89 +7040,6 @@ dependencies = [ "libusb1-sys", ] -[[package]] -name = "rusoto_core" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db30db44ea73551326269adcf7a2169428a054f14faf9e1768f2163494f2fa2" -dependencies = [ - "async-trait", - "base64 0.13.1", - "bytes", - "crc32fast", - "futures", - "http 0.2.12", - "hyper 0.14.28", - "hyper-rustls 0.23.2", - "lazy_static", - "log", - "rusoto_credential", - "rusoto_signature", - "rustc_version 0.4.0", - "serde", - "serde_json", - "tokio", - "xml-rs", -] - -[[package]] -name = "rusoto_credential" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee0a6c13db5aad6047b6a44ef023dbbc21a056b6dab5be3b79ce4283d5c02d05" -dependencies = [ - "async-trait", - "chrono", - "dirs-next", - "futures", - "hyper 0.14.28", - "serde", - "serde_json", - "shlex", - "tokio", - "zeroize", -] - -[[package]] -name = "rusoto_kms" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e1fc19cfcfd9f6b2f96e36d5b0dddda9004d2cbfc2d17543e3b9f10cc38fce8" -dependencies = [ - "async-trait", - "bytes", - "futures", - "rusoto_core", - "serde", - "serde_json", -] - -[[package]] -name = "rusoto_signature" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ae95491c8b4847931e291b151127eccd6ff8ca13f33603eb3d0035ecb05272" -dependencies = [ - "base64 0.13.1", - "bytes", - "chrono", - "digest 0.9.0", - "futures", - "hex", - "hmac 0.11.0", - "http 0.2.12", - "hyper 0.14.28", - "log", - "md-5 0.9.1", - "percent-encoding", - "pin-project-lite", - "rusoto_credential", - "rustc_version 0.4.0", - "serde", - "sha2 0.9.9", - "tokio", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -6734,18 +7089,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.20.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" -dependencies = [ - "log", - "ring 0.16.20", - "sct", - "webpki", -] - [[package]] name = "rustls" version = "0.21.10" @@ -6977,10 +7320,10 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" dependencies = [ - "hmac 0.12.1", + "hmac", "pbkdf2 0.11.0", "salsa20", - "sha2 0.10.8", + "sha2", ] [[package]] @@ -7013,6 +7356,7 @@ version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ + "rand 0.8.5", "secp256k1-sys", ] @@ -7104,7 +7448,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7158,7 +7502,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7204,7 +7548,7 @@ checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7224,19 +7568,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.8" @@ -7469,9 +7800,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -7501,7 +7832,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7514,7 +7845,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7550,7 +7881,7 @@ dependencies = [ "semver 1.0.22", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "thiserror", "url", "zip", @@ -7570,7 +7901,7 @@ dependencies = [ "semver 1.0.22", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "thiserror", "url", "zip", @@ -7602,9 +7933,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.57" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -7613,14 +7944,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3d0961cd53c23ea94eeec56ba940f636f6394788976e9f16ca5ee0aca7464a" +checksum = "4497156948bd342b52038035a6fa514a89626e37af9d2c52a5e8d8ebcc7ee479" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7730,7 +8061,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7872,7 +8203,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7885,17 +8216,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls 0.20.9", - "tokio", - "webpki", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -7937,13 +8257,11 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "native-tls", "rustls 0.21.10", "tokio", - "tokio-native-tls", "tokio-rustls 0.24.1", "tungstenite", - "webpki-roots", + "webpki-roots 0.25.4", ] [[package]] @@ -8117,7 +8435,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -8211,7 +8529,6 @@ dependencies = [ "http 0.2.12", "httparse", "log", - "native-tls", "rand 0.8.5", "rustls 0.21.10", "sha1", @@ -8337,6 +8654,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf-8" version = "0.7.6" @@ -8359,6 +8682,12 @@ dependencies = [ "serde", ] +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" + [[package]] name = "valuable" version = "0.1.0" @@ -8389,6 +8718,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + [[package]] name = "wait-timeout" version = "0.2.0" @@ -8450,7 +8785,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -8484,7 +8819,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8554,20 +8889,19 @@ dependencies = [ ] [[package]] -name = "webpki" -version = "0.22.4" +name = "webpki-roots" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" -dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", -] +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "which" @@ -8885,10 +9219,10 @@ dependencies = [ ] [[package]] -name = "xml-rs" -version = "0.8.20" +name = "xmlparser" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" +checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" [[package]] name = "yansi" @@ -8919,7 +9253,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -8939,7 +9273,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -8955,7 +9289,7 @@ dependencies = [ "crc32fast", "crossbeam-utils", "flate2", - "hmac 0.12.1", + "hmac", "pbkdf2 0.11.0", "sha1", "time", diff --git a/Cargo.toml b/Cargo.toml index ad300a085c8f3..1bc2329a50937 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,9 +107,6 @@ codegen-units = 1 [profile.release.package] mdbook.opt-level = 1 protobuf.opt-level = 1 -rusoto_core.opt-level = 1 -rusoto_credential.opt-level = 1 -rusoto_kms.opt-level = 1 toml_edit.opt-level = 1 trezor-client.opt-level = 1 @@ -140,16 +137,16 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.2.4", default-features = false } -foundry-compilers = { version = "0.3.13", default-features = false } +foundry-block-explorers = { version = "0.2.5", default-features = false } +foundry-compilers = { version = "0.3.14", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "7.1", default-features = false, features = ["std"] } -revm-primitives = { version = "3", default-features = false, features = ["std"] } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ba0b6ab", features = [ +revm = { version = "8", default-features = false } +revm-primitives = { version = "3", default-features = false } +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "510d4d0", features = [ "serde", -] } +] } ## ethers ethers = { version = "2.0.14", default-features = false } @@ -161,30 +158,34 @@ ethers-signers = { version = "2.0.14", default-features = false } ethers-middleware = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-providers = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90", default-features = false } -alloy-primitives = { version = "0.6.3", features = ["getrandom"] } -alloy-dyn-abi = "0.6.3" -alloy-json-abi = "0.6.3" -alloy-sol-types = "0.6.3" -syn-solidity = "0.6.3" +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-primitives = { version = "0.7.0", features = ["getrandom"] } +alloy-dyn-abi = "0.7.0" +alloy-json-abi = "0.7.0" +alloy-sol-types = "0.7.0" +syn-solidity = "0.7.0" alloy-chains = "0.1" -alloy-trie = "0.3" - +alloy-trie = "0.3.1" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" diff --git a/clippy.toml b/clippy.toml index 472818efed9bc..09acb653d14ac 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1,4 @@ msrv = "1.76" +# bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, +# so it is safe to ignore it as well +ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 4ccbfadddafb7..99bf00081b2c7 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,7 +16,11 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # foundry internal @@ -36,12 +40,13 @@ alloy-primitives = { workspace = true, features = ["serde"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-network.workspace = true alloy-rlp.workspace = true -alloy-signer = { workspace = true, features = ["eip712", "mnemonic"] } +alloy-signer = { workspace = true, features = ["eip712"] } +alloy-signer-wallet = { workspace = true, features = ["mnemonic"] } alloy-sol-types = { workspace = true, features = ["std"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-rpc-types.workspace = true -alloy-rpc-trace-types.workspace = true -alloy-providers.workspace = true +alloy-rpc-types-trace.workspace = true +alloy-provider = { workspace = true, features = ["pubsub"] } alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true @@ -75,7 +80,11 @@ rand = "0.8" eyre.workspace = true # cli -clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } +clap = { version = "4", features = [ + "derive", + "env", + "wrap_help", +], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" @@ -89,7 +98,7 @@ tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] alloy-json-abi.workspace = true -ethers = { workspace = true, features = ["abigen"] } +ethers = { workspace = true, features = ["abigen", "optimism"] } ethers-core = { workspace = true, features = ["optimism"] } foundry-compilers = { workspace = true, features = ["project-util", "full"] } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 999c606899831..feddead952123 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -12,11 +12,15 @@ repository.workspace = true [dependencies] foundry-common.workspace = true foundry-evm.workspace = true -revm = { workspace = true, default-features = false, features = ["std", "serde", "memory_limit"] } +revm = { workspace = true, default-features = false, features = [ + "std", + "serde", + "memory_limit", +] } alloy-primitives = { workspace = true, features = ["serde"] } alloy-rpc-types = { workspace = true } -alloy-rpc-trace-types.workspace = true +alloy-rpc-types-trace.workspace = true alloy-rlp.workspace = true alloy-eips.workspace = true alloy-network = { workspace = true, features = ["k256"] } @@ -27,7 +31,7 @@ alloy-trie.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true bytes = "1.4" -c-kzg = { version = "0.4.2", features = ["serde"] } +c-kzg = { version = "1", features = ["serde"] } # misc rand = "0.8" diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index c304eefa4a10a..462d16c8209cf 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -3,7 +3,7 @@ use super::{ trie, }; use alloy_consensus::Header; -use alloy_primitives::{Address, Bloom, Bytes, B256, U256}; +use alloy_primitives::{Address, Bloom, Bytes, B256, B64, U256}; use alloy_rlp::{RlpDecodable, RlpEncodable}; // Type alias to optionally support impersonated transactions @@ -88,13 +88,13 @@ pub struct PartialHeader { pub logs_bloom: Bloom, pub difficulty: U256, pub number: u64, - pub gas_limit: u64, - pub gas_used: u64, + pub gas_limit: u128, + pub gas_used: u128, pub timestamp: u64, pub extra_data: Bytes, pub mix_hash: B256, - pub nonce: u64, - pub base_fee: Option, + pub nonce: B64, + pub base_fee: Option, } impl From
for PartialHeader { @@ -120,7 +120,6 @@ impl From
for PartialHeader { #[cfg(test)] mod tests { - use alloy_network::Sealable; use alloy_primitives::{ b256, hex::{self, FromHex}, @@ -143,11 +142,11 @@ mod tests { difficulty: Default::default(), number: 124u64, gas_limit: Default::default(), - gas_used: 1337u64, + gas_used: 1337u128, timestamp: 0, extra_data: Default::default(), mix_hash: Default::default(), - nonce: 99u64, + nonce: B64::with_last_byte(99), withdrawals_root: Default::default(), blob_gas_used: Default::default(), excess_blob_gas: Default::default(), @@ -159,7 +158,7 @@ mod tests { let decoded: Header = Header::decode(&mut encoded.as_ref()).unwrap(); assert_eq!(header, decoded); - header.base_fee_per_gas = Some(12345u64); + header.base_fee_per_gas = Some(12345u128); let encoded = alloy_rlp::encode(&header); let decoded: Header = Header::decode(&mut encoded.as_ref()).unwrap(); @@ -182,8 +181,8 @@ mod tests { logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), difficulty: U256::from(2222), number: 0xd05u64, - gas_limit: 0x115cu64, - gas_used: 0x15b3u64, + gas_limit: 0x115cu128, + gas_used: 0x15b3u128, timestamp: 0x1a0au64, extra_data: hex::decode("7788").unwrap().into(), mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), @@ -191,7 +190,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - nonce: 0, + nonce: B64::ZERO, base_fee_per_gas: None, }; @@ -214,12 +213,12 @@ mod tests { logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), difficulty: U256::from(2222), number: 0xd05u64, - gas_limit: 0x115cu64, - gas_used: 0x15b3u64, + gas_limit: 0x115cu128, + gas_used: 0x15b3u128, timestamp: 0x1a0au64, extra_data: hex::decode("7788").unwrap().into(), mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: 0, + nonce: B64::ZERO, withdrawals_root: None, blob_gas_used: None, excess_blob_gas: None, @@ -245,19 +244,19 @@ mod tests { logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), difficulty: U256::from(0x020000), number: 1u64, - gas_limit: U256::from(0x016345785d8a0000u128).to::(), - gas_used: U256::from(0x015534).to::(), + gas_limit: U256::from(0x016345785d8a0000u128).to::(), + gas_used: U256::from(0x015534).to::(), timestamp: 0x079e, extra_data: hex::decode("42").unwrap().into(), mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), - nonce: 0, + nonce: B64::ZERO, base_fee_per_gas: Some(875), withdrawals_root: None, blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, }; - assert_eq!(header.hash(), expected_hash); + assert_eq!(header.hash_slow(), expected_hash); } #[test] diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index e5a394a8fa4cd..7a2a153e8ed89 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -3,13 +3,13 @@ use crate::{ types::{EvmMineOptions, Forking, Index}, }; use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256}; -use alloy_rpc_trace_types::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}; use alloy_rpc_types::{ pubsub::{Params as SubscriptionParams, SubscriptionKind}, request::TransactionRequest, state::StateOverride, - BlockId, BlockNumberOrTag as BlockNumber, Filter, + BlockId, BlockNumberOrTag as BlockNumber, Filter, WithOtherFields, }; +use alloy_rpc_types_trace::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}; pub mod block; pub mod proof; @@ -143,7 +143,7 @@ pub enum EthRequest { EthSign(Address, Bytes), #[cfg_attr(feature = "serde", serde(rename = "eth_signTransaction"))] - EthSignTransaction(Box), + EthSignTransaction(Box>), /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md). #[cfg_attr(feature = "serde", serde(rename = "eth_signTypedData"))] @@ -158,27 +158,27 @@ pub enum EthRequest { EthSignTypedDataV4(Address, alloy_dyn_abi::TypedData), #[cfg_attr(feature = "serde", serde(rename = "eth_sendTransaction", with = "sequence"))] - EthSendTransaction(Box), + EthSendTransaction(Box>), #[cfg_attr(feature = "serde", serde(rename = "eth_sendRawTransaction", with = "sequence"))] EthSendRawTransaction(Bytes), #[cfg_attr(feature = "serde", serde(rename = "eth_call"))] EthCall( - TransactionRequest, + WithOtherFields, #[cfg_attr(feature = "serde", serde(default))] Option, #[cfg_attr(feature = "serde", serde(default))] Option, ), #[cfg_attr(feature = "serde", serde(rename = "eth_createAccessList"))] EthCreateAccessList( - TransactionRequest, + WithOtherFields, #[cfg_attr(feature = "serde", serde(default))] Option, ), #[cfg_attr(feature = "serde", serde(rename = "eth_estimateGas"))] EthEstimateGas( - TransactionRequest, + WithOtherFields, #[cfg_attr(feature = "serde", serde(default))] Option, #[cfg_attr(feature = "serde", serde(default))] Option, ), @@ -272,7 +272,7 @@ pub enum EthRequest { /// geth's `debug_traceCall` endpoint #[cfg_attr(feature = "serde", serde(rename = "debug_traceCall"))] DebugTraceCall( - TransactionRequest, + WithOtherFields, #[cfg_attr(feature = "serde", serde(default))] Option, #[cfg_attr(feature = "serde", serde(default))] GethDefaultTracingOptions, ), @@ -597,7 +597,7 @@ pub enum EthRequest { feature = "serde", serde(rename = "eth_sendUnsignedTransaction", with = "sequence") )] - EthSendUnsignedTransaction(Box), + EthSendUnsignedTransaction(Box>), /// Turn on call traces for transactions that are returned to the user when they execute a /// transaction (instead of just txhash/receipt) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 10de5f80e7f0a..84e236f92f8bc 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -5,21 +5,24 @@ use crate::eth::{ utils::eip_to_revm_access_list, }; use alloy_consensus::{ - BlobTransactionSidecar, ReceiptWithBloom, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, - TxEip4844WithSidecar, TxLegacy, + AnyReceiptEnvelope, BlobTransactionSidecar, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, + TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, + TxReceipt, }; -use alloy_network::{Signed, Transaction, TxKind}; -use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, B256, U128, U256, U64}; -use alloy_rlp::{Decodable, Encodable}; +use alloy_eips::eip2718::Decodable2718; +use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256}; +use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ - request::TransactionRequest, AccessList, Signature as RpcSignature, - Transaction as RpcTransaction, + request::TransactionRequest, AccessList, AnyTransactionReceipt, Signature as RpcSignature, + Transaction as RpcTransaction, TransactionReceipt, WithOtherFields, }; +use bytes::BufMut; use foundry_evm::traces::CallTraceNode; use revm::{ interpreter::InstructionResult, primitives::{CreateScheme, OptimismFields, TransactTo, TxEnv}, }; +use serde::{Deserialize, Serialize}; use std::ops::Deref; use super::utils::from_eip_to_alloy_access_list; @@ -35,26 +38,30 @@ pub fn impersonated_signature() -> Signature { /// Converts a [TransactionRequest] into a [TypedTransactionRequest]. /// Should be removed once the call builder abstraction for providers is in place. -pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { - let TransactionRequest { - from, - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - max_fee_per_blob_gas, - mut blob_versioned_hashes, - gas, - value, - input, - nonce, - mut access_list, - sidecar, - transaction_type, +pub fn transaction_request_to_typed( + tx: WithOtherFields, +) -> Option { + let WithOtherFields:: { + inner: + TransactionRequest { + from, + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + max_fee_per_blob_gas, + mut blob_versioned_hashes, + gas, + value, + input, + nonce, + mut access_list, + sidecar, + transaction_type, + .. + }, other, - .. } = tx; - let transaction_type = transaction_type.map(|id| id.to::()); // Special case: OP-stack deposit tx if transaction_type == Some(126) { @@ -79,14 +86,15 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { + (Some(0), _, None, None, None, None, None, None, _) | + (None, Some(_), None, None, None, None, None, None, _) => { Some(TypedTransactionRequest::Legacy(TxLegacy { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), + nonce: nonce.unwrap_or_default(), + gas_price: gas_price.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), to: match to { @@ -97,12 +105,12 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option { + (Some(1), _, None, None, _, None, None, None, _) | + (None, _, None, None, Some(_), None, None, None, _) => { Some(TypedTransactionRequest::EIP2930(TxEip2930 { - nonce: nonce.unwrap_or_default().to::(), - gas_price: gas_price.unwrap_or_default().to(), - gas_limit: gas.unwrap_or_default().to::(), + nonce: nonce.unwrap_or_default(), + gas_price: gas_price.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), to: match to { @@ -110,20 +118,20 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option TxKind::Create, }, chain_id: 0, - access_list: to_eip_access_list(access_list.unwrap_or_default()), + access_list: access_list.unwrap_or_default(), })) } // EIP1559 - (Some(2), None, _, _, _, _, None, None) | - (None, None, Some(_), _, _, _, None, None) | - (None, None, _, Some(_), _, _, None, None) | - (None, None, None, None, None, _, None, None) => { + (Some(2), None, _, _, _, _, None, None, _) | + (None, None, Some(_), _, _, _, None, None, _) | + (None, None, _, Some(_), _, _, None, None, _) | + (None, None, None, None, None, _, None, None, _) => { // Empty fields fall back to the canonical transaction schema. Some(TypedTransactionRequest::EIP1559(TxEip1559 { - nonce: nonce.unwrap_or_default().to::(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), + nonce: nonce.unwrap_or_default(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), to: match to { @@ -131,25 +139,22 @@ pub fn transaction_request_to_typed(tx: TransactionRequest) -> Option TxKind::Create, }, chain_id: 0, - access_list: to_eip_access_list(access_list.unwrap_or_default()), + access_list: access_list.unwrap_or_default(), })) } // EIP4844 - (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar)) => { + (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), Some(to)) => { let tx = TxEip4844 { - nonce: nonce.unwrap_or_default().to::(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default().to::(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default().to::(), - max_fee_per_blob_gas: max_fee_per_blob_gas.unwrap_or_default().to::(), - gas_limit: gas.unwrap_or_default().to::(), + nonce: nonce.unwrap_or_default(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(), + max_fee_per_blob_gas: max_fee_per_blob_gas.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, + to, chain_id: 0, - access_list: to_eip_access_list(access_list.unwrap_or_default()), + access_list: access_list.unwrap_or_default(), blob_versioned_hashes: blob_versioned_hashes.unwrap_or_default(), }; let blob_sidecar = BlobTransactionSidecar { @@ -288,19 +293,19 @@ pub fn to_alloy_transaction_with_hash_and_sender( match transaction { TypedTransaction::Legacy(t) => RpcTransaction { hash, - nonce: U64::from(t.nonce), + nonce: t.tx().nonce, block_hash: None, block_number: None, transaction_index: None, from, to: None, - value: t.value, - gas_price: Some(U128::from(t.gas_price)), - max_fee_per_gas: Some(U128::from(t.gas_price)), - max_priority_fee_per_gas: Some(U128::from(t.gas_price)), - gas: U256::from(t.gas_limit), - input: t.input.clone(), - chain_id: t.chain_id.map(U64::from), + value: t.tx().value, + gas_price: Some(t.tx().gas_price), + max_fee_per_gas: Some(t.tx().gas_price), + max_priority_fee_per_gas: Some(t.tx().gas_price), + gas: t.tx().gas_limit, + input: t.tx().input.clone(), + chain_id: t.tx().chain_id, signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), @@ -310,93 +315,93 @@ pub fn to_alloy_transaction_with_hash_and_sender( access_list: None, transaction_type: None, max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], + blob_versioned_hashes: None, other: Default::default(), }, TypedTransaction::EIP2930(t) => RpcTransaction { hash, - nonce: U64::from(t.nonce), + nonce: t.tx().nonce, block_hash: None, block_number: None, transaction_index: None, from, to: None, - value: t.value, - gas_price: Some(U128::from(t.gas_price)), - max_fee_per_gas: Some(U128::from(t.gas_price)), - max_priority_fee_per_gas: Some(U128::from(t.gas_price)), - gas: U256::from(t.gas_limit), - input: t.input.clone(), - chain_id: Some(U64::from(t.chain_id)), + value: t.tx().value, + gas_price: Some(t.tx().gas_price), + max_fee_per_gas: Some(t.tx().gas_price), + max_priority_fee_per_gas: Some(t.tx().gas_price), + gas: t.tx().gas_limit, + input: t.tx().input.clone(), + chain_id: Some(t.tx().chain_id), signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), v: U256::from(t.signature().v().y_parity_byte()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), - access_list: Some(from_eip_to_alloy_access_list(t.access_list.clone()).0), - transaction_type: Some(U64::from(1)), + access_list: Some(t.tx().access_list.clone()), + transaction_type: Some(1), max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], + blob_versioned_hashes: None, other: Default::default(), }, TypedTransaction::EIP1559(t) => RpcTransaction { hash, - nonce: U64::from(t.nonce), + nonce: t.tx().nonce, block_hash: None, block_number: None, transaction_index: None, from, to: None, - value: t.value, + value: t.tx().value, gas_price: None, - max_fee_per_gas: Some(U128::from(t.max_fee_per_gas)), - max_priority_fee_per_gas: Some(U128::from(t.max_priority_fee_per_gas)), - gas: U256::from(t.gas_limit), - input: t.input.clone(), - chain_id: Some(U64::from(t.chain_id)), + max_fee_per_gas: Some(t.tx().max_fee_per_gas), + max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas), + gas: t.tx().gas_limit, + input: t.tx().input.clone(), + chain_id: Some(t.tx().chain_id), signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), v: U256::from(t.signature().v().y_parity_byte()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), - access_list: Some(from_eip_to_alloy_access_list(t.access_list.clone()).0), - transaction_type: Some(U64::from(2)), + access_list: Some(t.tx().access_list.clone()), + transaction_type: Some(2), max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], + blob_versioned_hashes: None, other: Default::default(), }, TypedTransaction::EIP4844(t) => RpcTransaction { hash, - nonce: U64::from(t.tx().tx().nonce), + nonce: t.tx().tx().nonce, block_hash: None, block_number: None, transaction_index: None, from, to: None, value: t.tx().tx().value, - gas_price: Some(U128::from(t.tx().tx().max_fee_per_gas)), - max_fee_per_gas: Some(U128::from(t.tx().tx().max_fee_per_gas)), - max_priority_fee_per_gas: Some(U128::from(t.tx().tx().max_priority_fee_per_gas)), - gas: U256::from(t.tx().tx().gas_limit), + gas_price: Some(t.tx().tx().max_fee_per_gas), + max_fee_per_gas: Some(t.tx().tx().max_fee_per_gas), + max_priority_fee_per_gas: Some(t.tx().tx().max_priority_fee_per_gas), + gas: t.tx().tx().gas_limit, input: t.tx().tx().input.clone(), - chain_id: Some(U64::from(t.tx().tx().chain_id)), + chain_id: Some(t.tx().tx().chain_id), signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), v: U256::from(t.signature().v().y_parity_byte()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), - access_list: Some(from_eip_to_alloy_access_list(t.tx().tx().access_list.clone()).0), - transaction_type: Some(U64::from(3)), - max_fee_per_blob_gas: Some(U128::from(t.tx().tx().max_fee_per_blob_gas)), - blob_versioned_hashes: t.tx().tx().blob_versioned_hashes.clone(), + access_list: Some(from_eip_to_alloy_access_list(t.tx().tx().access_list.clone())), + transaction_type: Some(3), + max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas), + blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), other: Default::default(), }, TypedTransaction::Deposit(t) => RpcTransaction { hash, - nonce: U64::from(t.nonce), + nonce: t.nonce, block_hash: None, block_number: None, transaction_index: None, @@ -406,14 +411,14 @@ pub fn to_alloy_transaction_with_hash_and_sender( gas_price: None, max_fee_per_gas: None, max_priority_fee_per_gas: None, - gas: U256::from(t.gas_limit), + gas: t.gas_limit, input: t.input.clone().0.into(), - chain_id: t.chain_id().map(U64::from), + chain_id: t.chain_id().map(u64::from), signature: None, access_list: None, transaction_type: None, max_fee_per_blob_gas: None, - blob_versioned_hashes: vec![], + blob_versioned_hashes: None, other: Default::default(), }, } @@ -447,7 +452,7 @@ impl PendingTransaction { } } - pub fn nonce(&self) -> U256 { + pub fn nonce(&self) -> u64 { self.transaction.nonce() } @@ -472,7 +477,7 @@ impl PendingTransaction { let caller = *self.sender(); match &self.transaction.transaction { TypedTransaction::Legacy(tx) => { - let chain_id = tx.chain_id(); + let chain_id = tx.tx().chain_id; let TxLegacy { nonce, gas_price, gas_limit, value, to, input, .. } = tx.tx(); TxEnv { caller, @@ -483,7 +488,7 @@ impl PendingTransaction { value: (*value), gas_price: U256::from(*gas_price), gas_priority_fee: None, - gas_limit: *gas_limit, + gas_limit: *gas_limit as u64, access_list: vec![], ..Default::default() } @@ -509,7 +514,7 @@ impl PendingTransaction { value: *value, gas_price: U256::from(*gas_price), gas_priority_fee: None, - gas_limit: *gas_limit, + gas_limit: *gas_limit as u64, access_list: eip_to_revm_access_list(access_list.0.clone()), ..Default::default() } @@ -536,7 +541,7 @@ impl PendingTransaction { value: *value, gas_price: U256::from(*max_fee_per_gas), gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), - gas_limit: *gas_limit, + gas_limit: *gas_limit as u64, access_list: eip_to_revm_access_list(access_list.0.clone()), ..Default::default() } @@ -558,7 +563,7 @@ impl PendingTransaction { } = tx.tx().tx(); TxEnv { caller, - transact_to: transact_to(to), + transact_to: TransactTo::call(*to), data: alloy_primitives::Bytes(input.0.clone()), chain_id: Some(*chain_id), nonce: Some(*nonce), @@ -567,7 +572,7 @@ impl PendingTransaction { gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), max_fee_per_blob_gas: Some(U256::from(*max_fee_per_blob_gas)), blob_hashes: blob_versioned_hashes.clone(), - gas_limit: *gas_limit, + gas_limit: *gas_limit as u64, access_list: eip_to_revm_access_list(access_list.0.clone()), ..Default::default() } @@ -590,11 +595,11 @@ impl PendingTransaction { transact_to: transact_to(kind), data: alloy_primitives::Bytes(input.0.clone()), chain_id, - nonce: Some(nonce.to::()), + nonce: Some(*nonce), value: *value, gas_price: U256::ZERO, gas_priority_fee: None, - gas_limit: gas_limit.to::(), + gas_limit: *gas_limit as u64, access_list: vec![], optimism: OptimismFields { source_hash: Some(*source_hash), @@ -630,31 +635,31 @@ impl TypedTransaction { matches!(self, TypedTransaction::EIP1559(_)) } - pub fn gas_price(&self) -> U256 { - U256::from(match self { - TypedTransaction::Legacy(tx) => tx.gas_price, - TypedTransaction::EIP2930(tx) => tx.gas_price, - TypedTransaction::EIP1559(tx) => tx.max_fee_per_gas, + pub fn gas_price(&self) -> u128 { + match self { + TypedTransaction::Legacy(tx) => tx.tx().gas_price, + TypedTransaction::EIP2930(tx) => tx.tx().gas_price, + TypedTransaction::EIP1559(tx) => tx.tx().max_fee_per_gas, TypedTransaction::EIP4844(tx) => tx.tx().tx().max_fee_per_blob_gas, TypedTransaction::Deposit(_) => 0, - }) + } } - pub fn gas_limit(&self) -> U256 { - U256::from(match self { - TypedTransaction::Legacy(tx) => tx.gas_limit, - TypedTransaction::EIP2930(tx) => tx.gas_limit, - TypedTransaction::EIP1559(tx) => tx.gas_limit, + pub fn gas_limit(&self) -> u128 { + match self { + TypedTransaction::Legacy(tx) => tx.tx().gas_limit, + TypedTransaction::EIP2930(tx) => tx.tx().gas_limit, + TypedTransaction::EIP1559(tx) => tx.tx().gas_limit, TypedTransaction::EIP4844(tx) => tx.tx().tx().gas_limit, - TypedTransaction::Deposit(tx) => tx.gas_limit.to::(), - }) + TypedTransaction::Deposit(tx) => tx.gas_limit, + } } pub fn value(&self) -> U256 { U256::from(match self { - TypedTransaction::Legacy(tx) => tx.value, - TypedTransaction::EIP2930(tx) => tx.value, - TypedTransaction::EIP1559(tx) => tx.value, + TypedTransaction::Legacy(tx) => tx.tx().value, + TypedTransaction::EIP2930(tx) => tx.tx().value, + TypedTransaction::EIP1559(tx) => tx.tx().value, TypedTransaction::EIP4844(tx) => tx.tx().tx().value, TypedTransaction::Deposit(tx) => tx.value, }) @@ -662,9 +667,9 @@ impl TypedTransaction { pub fn data(&self) -> &Bytes { match self { - TypedTransaction::Legacy(tx) => &tx.input, - TypedTransaction::EIP2930(tx) => &tx.input, - TypedTransaction::EIP1559(tx) => &tx.input, + TypedTransaction::Legacy(tx) => &tx.tx().input, + TypedTransaction::EIP2930(tx) => &tx.tx().input, + TypedTransaction::EIP1559(tx) => &tx.tx().input, TypedTransaction::EIP4844(tx) => &tx.tx().tx().input, TypedTransaction::Deposit(tx) => &tx.input, } @@ -682,7 +687,7 @@ impl TypedTransaction { } /// Max cost of the transaction - pub fn max_cost(&self) -> U256 { + pub fn max_cost(&self) -> u128 { self.gas_limit().saturating_mul(self.gas_price()) } @@ -691,51 +696,51 @@ impl TypedTransaction { match self { TypedTransaction::Legacy(t) => TransactionEssentials { kind: t.tx().to, - input: t.input.clone(), - nonce: U256::from(t.tx().nonce), - gas_limit: U256::from(t.tx().gas_limit), + input: t.tx().input.clone(), + nonce: t.tx().nonce, + gas_limit: t.tx().gas_limit, gas_price: Some(U256::from(t.tx().gas_price)), max_fee_per_gas: None, max_priority_fee_per_gas: None, max_fee_per_blob_gas: None, blob_versioned_hashes: None, - value: t.value, + value: t.tx().value, chain_id: t.tx().chain_id, access_list: Default::default(), }, TypedTransaction::EIP2930(t) => TransactionEssentials { kind: t.tx().to, - input: t.input.clone(), - nonce: U256::from(t.tx().nonce), - gas_limit: U256::from(t.tx().gas_limit), + input: t.tx().input.clone(), + nonce: t.tx().nonce, + gas_limit: t.tx().gas_limit, gas_price: Some(U256::from(t.tx().gas_price)), max_fee_per_gas: None, max_priority_fee_per_gas: None, max_fee_per_blob_gas: None, blob_versioned_hashes: None, - value: t.value, - chain_id: Some(t.chain_id), - access_list: to_alloy_access_list(t.access_list.clone()), + value: t.tx().value, + chain_id: Some(t.tx().chain_id), + access_list: t.tx().access_list.clone(), }, TypedTransaction::EIP1559(t) => TransactionEssentials { - kind: t.to, - input: t.input.clone(), - nonce: U256::from(t.nonce), - gas_limit: U256::from(t.gas_limit), + kind: t.tx().to, + input: t.tx().input.clone(), + nonce: t.tx().nonce, + gas_limit: t.tx().gas_limit, gas_price: None, - max_fee_per_gas: Some(U256::from(t.max_fee_per_gas)), - max_priority_fee_per_gas: Some(U256::from(t.max_priority_fee_per_gas)), + max_fee_per_gas: Some(U256::from(t.tx().max_fee_per_gas)), + max_priority_fee_per_gas: Some(U256::from(t.tx().max_priority_fee_per_gas)), max_fee_per_blob_gas: None, blob_versioned_hashes: None, - value: t.value, - chain_id: Some(t.chain_id), - access_list: to_alloy_access_list(t.access_list.clone()), + value: t.tx().value, + chain_id: Some(t.tx().chain_id), + access_list: t.tx().access_list.clone(), }, TypedTransaction::EIP4844(t) => TransactionEssentials { - kind: t.tx().tx().to, + kind: TxKind::Call(t.tx().tx().to), input: t.tx().tx().input.clone(), - nonce: U256::from(t.tx().tx().nonce), - gas_limit: U256::from(t.tx().tx().gas_limit), + nonce: t.tx().tx().nonce, + gas_limit: t.tx().tx().gas_limit, gas_price: Some(U256::from(t.tx().tx().max_fee_per_blob_gas)), max_fee_per_gas: Some(U256::from(t.tx().tx().max_fee_per_gas)), max_priority_fee_per_gas: Some(U256::from(t.tx().tx().max_priority_fee_per_gas)), @@ -743,7 +748,7 @@ impl TypedTransaction { blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), value: t.tx().tx().value, chain_id: Some(t.tx().tx().chain_id), - access_list: to_alloy_access_list(t.tx().tx().access_list.clone()), + access_list: t.tx().tx().access_list.clone(), }, TypedTransaction::Deposit(t) => TransactionEssentials { kind: t.kind, @@ -762,21 +767,21 @@ impl TypedTransaction { } } - pub fn nonce(&self) -> U256 { + pub fn nonce(&self) -> u64 { match self { - TypedTransaction::Legacy(t) => U256::from(t.nonce), - TypedTransaction::EIP2930(t) => U256::from(t.nonce), - TypedTransaction::EIP1559(t) => U256::from(t.nonce), - TypedTransaction::EIP4844(t) => U256::from(t.tx().tx().nonce), - TypedTransaction::Deposit(t) => U256::from(t.nonce), + TypedTransaction::Legacy(t) => t.tx().nonce, + TypedTransaction::EIP2930(t) => t.tx().nonce, + TypedTransaction::EIP1559(t) => t.tx().nonce, + TypedTransaction::EIP4844(t) => t.tx().tx().nonce, + TypedTransaction::Deposit(t) => t.nonce, } } pub fn chain_id(&self) -> Option { match self { - TypedTransaction::Legacy(t) => t.chain_id, - TypedTransaction::EIP2930(t) => Some(t.chain_id), - TypedTransaction::EIP1559(t) => Some(t.chain_id), + TypedTransaction::Legacy(t) => t.tx().chain_id, + TypedTransaction::EIP2930(t) => Some(t.tx().chain_id), + TypedTransaction::EIP1559(t) => Some(t.tx().chain_id), TypedTransaction::EIP4844(t) => Some(t.tx().tx().chain_id), TypedTransaction::Deposit(t) => t.chain_id(), } @@ -852,19 +857,19 @@ impl TypedTransaction { } /// Returns what kind of transaction this is - pub fn kind(&self) -> &TxKind { + pub fn kind(&self) -> TxKind { match self { - TypedTransaction::Legacy(tx) => &tx.to, - TypedTransaction::EIP2930(tx) => &tx.to, - TypedTransaction::EIP1559(tx) => &tx.to, - TypedTransaction::EIP4844(tx) => &tx.tx().tx().to, - TypedTransaction::Deposit(tx) => &tx.kind, + TypedTransaction::Legacy(tx) => tx.tx().to, + TypedTransaction::EIP2930(tx) => tx.tx().to, + TypedTransaction::EIP1559(tx) => tx.tx().to, + TypedTransaction::EIP4844(tx) => TxKind::Call(tx.tx().tx().to), + TypedTransaction::Deposit(tx) => tx.kind, } } /// Returns the callee if this transaction is a call pub fn to(&self) -> Option
{ - self.kind().to() + self.kind().to().copied() } /// Returns the Signature of the transaction @@ -887,65 +892,72 @@ impl TypedTransaction { impl Encodable for TypedTransaction { fn encode(&self, out: &mut dyn bytes::BufMut) { match self { - TypedTransaction::Legacy(tx) => tx.encode(out), - TypedTransaction::EIP2930(tx) => tx.encode(out), - TypedTransaction::EIP1559(tx) => tx.encode(out), - TypedTransaction::EIP4844(tx) => tx.encode(out), - TypedTransaction::Deposit(tx) => tx.encode(out), + TypedTransaction::Legacy(tx) => TxEnvelope::from(tx.clone()).encode(out), + TypedTransaction::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode(out), + TypedTransaction::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode(out), + TypedTransaction::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode(out), + TypedTransaction::Deposit(tx) => { + let tx_payload_len = tx.fields_len(); + let tx_header_len = Header { list: false, payload_length: tx_payload_len }.length(); + Header { list: false, payload_length: 1 + tx_payload_len + tx_header_len } + .encode(out); + out.put_u8(0x7E); + tx.encode(out); + } } } } impl Decodable for TypedTransaction { fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - use bytes::Buf; - use std::cmp::Ordering; + let mut h_decode_copy = *buf; + let header = alloy_rlp::Header::decode(&mut h_decode_copy)?; - let first = *buf.first().ok_or(alloy_rlp::Error::Custom("empty slice"))?; + // Legacy TX + if header.list { + return Ok(TxEnvelope::decode(buf)?.into()) + } - // a signed transaction is either encoded as a string (non legacy) or a list (legacy). - // We should not consume the buffer if we are decoding a legacy transaction, so let's - // check if the first byte is between 0x80 and 0xbf. - match first.cmp(&alloy_rlp::EMPTY_LIST_CODE) { - Ordering::Less => { - // strip out the string header - // NOTE: typed transaction encodings either contain a "rlp header" which contains - // the type of the payload and its length, or they do not contain a header and - // start with the tx type byte. - // - // This line works for both types of encodings because byte slices starting with - // 0x01 and 0x02 return a Header { list: false, payload_length: 1 } when input to - // Header::decode. - // If the encoding includes a header, the header will be properly decoded and - // consumed. - // Otherwise, header decoding will succeed but nothing is consumed. - let _header = alloy_rlp::Header::decode(buf)?; - let tx_type = *buf.first().ok_or(alloy_rlp::Error::Custom( - "typed tx cannot be decoded from an empty slice", - ))?; - if tx_type == 0x01 { - buf.advance(1); - as Decodable>::decode(buf).map(TypedTransaction::EIP2930) - } else if tx_type == 0x02 { - buf.advance(1); - as Decodable>::decode(buf).map(TypedTransaction::EIP1559) - } else if tx_type == 0x03 { - buf.advance(1); - as Decodable>::decode(buf) - .map(TypedTransaction::EIP4844) - } else if tx_type == 0x7E { - buf.advance(1); - ::decode(buf).map(TypedTransaction::Deposit) - } else { - Err(alloy_rlp::Error::Custom("invalid tx type")) - } - } - Ordering::Equal => { - Err(alloy_rlp::Error::Custom("an empty list is not a valid transaction encoding")) - } - Ordering::Greater => { - as Decodable>::decode(buf).map(TypedTransaction::Legacy) - } + // Check byte after header + let ty = *h_decode_copy.first().ok_or(alloy_rlp::Error::Custom("empty slice"))?; + + if ty != 0x7E { + Ok(TxEnvelope::decode(buf)?.into()) + } else { + Ok(Self::Deposit(DepositTransaction::decode(&mut h_decode_copy)?)) + } + } +} + +impl Decodable2718 for TypedTransaction { + fn typed_decode(ty: u8, buf: &mut &[u8]) -> alloy_rlp::Result { + if ty == 0x7E { + return Ok(Self::Deposit(DepositTransaction::decode(buf)?)) + } + match TxEnvelope::typed_decode(ty, buf)? { + TxEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)), + TxEnvelope::Eip1559(tx) => Ok(Self::EIP1559(tx)), + TxEnvelope::Eip4844(tx) => Ok(Self::EIP4844(tx)), + _ => unreachable!(), + } + } + + fn fallback_decode(buf: &mut &[u8]) -> alloy_rlp::Result { + match TxEnvelope::fallback_decode(buf)? { + TxEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)), + _ => unreachable!(), + } + } +} + +impl From for TypedTransaction { + fn from(value: TxEnvelope) -> Self { + match value { + TxEnvelope::Legacy(tx) => TypedTransaction::Legacy(tx), + TxEnvelope::Eip2930(tx) => TypedTransaction::EIP2930(tx), + TxEnvelope::Eip1559(tx) => TypedTransaction::EIP1559(tx), + TxEnvelope::Eip4844(tx) => TypedTransaction::EIP4844(tx), + _ => unreachable!(), } } } @@ -954,8 +966,8 @@ impl Decodable for TypedTransaction { pub struct TransactionEssentials { pub kind: TxKind, pub input: Bytes, - pub nonce: U256, - pub gas_limit: U256, + pub nonce: u64, + pub gas_limit: u128, pub gas_price: Option, pub max_fee_per_gas: Option, pub max_priority_fee_per_gas: Option, @@ -970,75 +982,168 @@ pub struct TransactionEssentials { #[derive(Clone, Debug, PartialEq, Eq)] pub struct TransactionInfo { pub transaction_hash: B256, - pub transaction_index: u32, + pub transaction_index: u64, pub from: Address, pub to: Option
, pub contract_address: Option
, - pub logs: Vec, - pub logs_bloom: Bloom, pub traces: Vec, pub exit: InstructionResult, pub out: Option, pub nonce: u64, + pub gas_used: u128, } -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum TypedReceipt { - Legacy(ReceiptWithBloom), - EIP2930(ReceiptWithBloom), - EIP1559(ReceiptWithBloom), - EIP4844(ReceiptWithBloom), - Deposit(ReceiptWithBloom), +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub struct DepositReceipt { + #[serde(flatten)] + pub inner: ReceiptWithBloom, + pub deposit_nonce: Option, + pub deposit_nonce_version: Option, } -impl TypedReceipt { - pub fn gas_used(&self) -> U256 { - match self { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::EIP4844(r) | - TypedReceipt::Deposit(r) => U256::from(r.receipt.cumulative_gas_used), +impl DepositReceipt { + fn payload_len(&self) -> usize { + self.inner.receipt.status.length() + + self.inner.receipt.cumulative_gas_used.length() + + self.inner.logs_bloom.length() + + self.inner.receipt.logs.length() + + self.deposit_nonce.map_or(0, |n| n.length()) + + self.deposit_nonce_version.map_or(0, |n| n.length()) + } + + /// Returns the rlp header for the receipt payload. + fn receipt_rlp_header(&self) -> alloy_rlp::Header { + alloy_rlp::Header { list: true, payload_length: self.payload_len() } + } + + /// Encodes the receipt data. + fn encode_fields(&self, out: &mut dyn BufMut) { + self.receipt_rlp_header().encode(out); + self.inner.receipt.status.encode(out); + self.inner.receipt.cumulative_gas_used.encode(out); + self.inner.logs_bloom.encode(out); + self.inner.receipt.logs.encode(out); + if let Some(n) = self.deposit_nonce { + n.encode(out); + } + if let Some(n) = self.deposit_nonce_version { + n.encode(out); } } - pub fn logs_bloom(&self) -> &Bloom { - match self { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::EIP4844(r) | - TypedReceipt::Deposit(r) => &r.bloom, + /// Decodes the receipt payload + fn decode_receipt(buf: &mut &[u8]) -> alloy_rlp::Result { + let b: &mut &[u8] = &mut &**buf; + let rlp_head = alloy_rlp::Header::decode(b)?; + if !rlp_head.list { + return Err(alloy_rlp::Error::UnexpectedString); + } + let started_len = b.len(); + let remaining = |b: &[u8]| rlp_head.payload_length - (started_len - b.len()) > 0; + + let status = Decodable::decode(b)?; + let cumulative_gas_used = Decodable::decode(b)?; + let logs_bloom = Decodable::decode(b)?; + let logs = Decodable::decode(b)?; + let deposit_nonce = remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?; + let deposit_nonce_version = + remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?; + + let this = Self { + inner: ReceiptWithBloom { + receipt: Receipt { status, cumulative_gas_used, logs }, + logs_bloom, + }, + deposit_nonce, + deposit_nonce_version, + }; + + let consumed = started_len - b.len(); + if consumed != rlp_head.payload_length { + return Err(alloy_rlp::Error::ListLengthMismatch { + expected: rlp_head.payload_length, + got: consumed, + }); } + + *buf = *b; + Ok(this) + } +} + +impl alloy_rlp::Encodable for DepositReceipt { + fn encode(&self, out: &mut dyn BufMut) { + self.encode_fields(out); + } + + fn length(&self) -> usize { + let payload_length = self.payload_len(); + payload_length + length_of_length(payload_length) } +} - pub fn logs(&self) -> &Vec { +impl alloy_rlp::Decodable for DepositReceipt { + fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { + Self::decode_receipt(buf) + } +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(tag = "type")] +pub enum TypedReceipt { + #[serde(rename = "0x0", alias = "0x00")] + Legacy(ReceiptWithBloom), + #[serde(rename = "0x1", alias = "0x01")] + EIP2930(ReceiptWithBloom), + #[serde(rename = "0x2", alias = "0x02")] + EIP1559(ReceiptWithBloom), + #[serde(rename = "0x3", alias = "0x03")] + EIP4844(ReceiptWithBloom), + #[serde(rename = "0x7E", alias = "0x7e")] + Deposit(DepositReceipt), +} + +impl TypedReceipt { + pub fn as_receipt_with_bloom(&self) -> &ReceiptWithBloom { match self { TypedReceipt::Legacy(r) | TypedReceipt::EIP1559(r) | TypedReceipt::EIP2930(r) | - TypedReceipt::EIP4844(r) | - TypedReceipt::Deposit(r) => &r.receipt.logs, + TypedReceipt::EIP4844(r) => r, + TypedReceipt::Deposit(r) => &r.inner, } } } -impl From for ReceiptWithBloom { - fn from(val: TypedReceipt) -> Self { - match val { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::EIP4844(r) | - TypedReceipt::Deposit(r) => r, +impl TypedReceipt { + pub fn cumulative_gas_used(&self) -> u128 { + self.as_receipt_with_bloom().cumulative_gas_used() + } + + pub fn logs_bloom(&self) -> &Bloom { + &self.as_receipt_with_bloom().logs_bloom + } + + pub fn logs(&self) -> &[Log] { + self.as_receipt_with_bloom().logs() + } +} + +impl From> for TypedReceipt { + fn from(value: ReceiptEnvelope) -> Self { + match value { + ReceiptEnvelope::Legacy(r) => TypedReceipt::Legacy(r), + ReceiptEnvelope::Eip2930(r) => TypedReceipt::EIP2930(r), + ReceiptEnvelope::Eip1559(r) => TypedReceipt::EIP1559(r), + ReceiptEnvelope::Eip4844(r) => TypedReceipt::EIP4844(r), + _ => unreachable!(), } } } impl Encodable for TypedReceipt { fn encode(&self, out: &mut dyn bytes::BufMut) { - use alloy_rlp::Header; - match self { TypedReceipt::Legacy(r) => r.encode(out), receipt => { @@ -1080,7 +1185,6 @@ impl Encodable for TypedReceipt { impl Decodable for TypedReceipt { fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - use alloy_rlp::Header; use bytes::Buf; use std::cmp::Ordering; @@ -1109,7 +1213,7 @@ impl Decodable for TypedReceipt { ::decode(buf).map(TypedReceipt::EIP4844) } else if receipt_type == 0x7E { buf.advance(1); - ::decode(buf).map(TypedReceipt::Deposit) + ::decode(buf).map(TypedReceipt::Deposit) } else { Err(alloy_rlp::Error::Custom("invalid receipt type")) } @@ -1124,41 +1228,59 @@ impl Decodable for TypedReceipt { } } -/// Translates an EIP-2930 access list to an alloy-rpc-types access list. -pub fn to_alloy_access_list( - access_list: alloy_eips::eip2930::AccessList, -) -> alloy_rpc_types::AccessList { - alloy_rpc_types::AccessList( - access_list - .0 - .into_iter() - .map(|item| alloy_rpc_types::AccessListItem { - address: item.address, - storage_keys: item.storage_keys, - }) - .collect(), - ) -} - -/// Translates an alloy-rpc-types access list to an EIP-2930 access list. -pub fn to_eip_access_list( - access_list: alloy_rpc_types::AccessList, -) -> alloy_eips::eip2930::AccessList { - alloy_eips::eip2930::AccessList( - access_list - .0 - .into_iter() - .map(|item| alloy_eips::eip2930::AccessListItem { - address: item.address, - storage_keys: item.storage_keys, - }) - .collect(), - ) +pub type ReceiptResponse = TransactionReceipt>; + +pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option { + let WithOtherFields { + inner: + TransactionReceipt { + transaction_hash, + transaction_index, + block_hash, + block_number, + gas_used, + contract_address, + effective_gas_price, + from, + to, + blob_gas_price, + blob_gas_used, + state_root, + inner: AnyReceiptEnvelope { inner: receipt_with_bloom, r#type }, + }, + other, + } = receipt; + + Some(TransactionReceipt { + transaction_hash, + transaction_index, + block_hash, + block_number, + gas_used, + contract_address, + effective_gas_price, + from, + to, + blob_gas_price, + blob_gas_used, + state_root, + inner: match r#type { + 0x00 => TypedReceipt::Legacy(receipt_with_bloom), + 0x01 => TypedReceipt::EIP2930(receipt_with_bloom), + 0x02 => TypedReceipt::EIP1559(receipt_with_bloom), + 0x03 => TypedReceipt::EIP4844(receipt_with_bloom), + 0x7E => TypedReceipt::Deposit(DepositReceipt { + inner: receipt_with_bloom, + deposit_nonce: other.get("depositNonce").and_then(|v| v.as_u64()), + deposit_nonce_version: other.get("depositNonceVersion").and_then(|v| v.as_u64()), + }), + _ => return None, + }, + }) } #[cfg(test)] mod tests { - use alloy_consensus::Receipt; use alloy_primitives::{b256, hex, LogData}; use std::str::FromStr; @@ -1171,8 +1293,8 @@ mod tests { let tx = TxLegacy { nonce: 2u64, - gas_price: 1000000000u64.into(), - gas_limit: 100000u64, + gas_price: 1000000000u128, + gas_limit: 100000u128, to: TxKind::Call(Address::from_slice( &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], )), @@ -1238,10 +1360,7 @@ mod tests { _ => unreachable!(), }; - assert_eq!( - tx.tx().tx().to, - TxKind::Call(address!("11E9CA82A3a762b4B5bd264d4173a242e7a77064")) - ); + assert_eq!(tx.tx().tx().to, address!("11E9CA82A3a762b4B5bd264d4173a242e7a77064")); assert_eq!( tx.tx().tx().blob_versioned_hashes, @@ -1266,11 +1385,11 @@ mod tests { panic!("decoding TypedTransaction failed"); }; - assert_eq!(tx.input, Bytes::from(b"")); - assert_eq!(tx.gas_price, 1); - assert_eq!(tx.gas_limit, 21000); - assert_eq!(tx.nonce, 0); - if let TxKind::Call(to) = tx.to { + assert_eq!(tx.tx().input, Bytes::from(b"")); + assert_eq!(tx.tx().gas_price, 1); + assert_eq!(tx.tx().gas_limit, 21000); + assert_eq!(tx.tx().nonce, 0); + if let TxKind::Call(to) = tx.tx().to { assert_eq!( to, "0x095e7baea6a6c7c4c2dfeb977efac326af552d87".parse::
().unwrap() @@ -1278,7 +1397,7 @@ mod tests { } else { panic!("expected a call transaction"); } - assert_eq!(tx.value, U256::from(0x0au64)); + assert_eq!(tx.tx().value, U256::from(0x0au64)); assert_eq!( tx.recover_signer().unwrap(), "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse::
().unwrap() @@ -1292,8 +1411,8 @@ mod tests { let mut data = vec![]; let receipt = TypedReceipt::Legacy(ReceiptWithBloom { receipt: Receipt { - success: false, - cumulative_gas_used: 0x1u64, + status: false, + cumulative_gas_used: 0x1u128, logs: vec![Log { address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), data: LogData::new_unchecked( @@ -1311,7 +1430,7 @@ mod tests { ), }], }, - bloom: [0; 256].into(), + logs_bloom: [0; 256].into(), }); receipt.encode(&mut data); @@ -1327,8 +1446,8 @@ mod tests { let expected = TypedReceipt::Legacy(ReceiptWithBloom { receipt: Receipt { - success: false, - cumulative_gas_used: 0x1u64, + status: false, + cumulative_gas_used: 0x1u128, logs: vec![Log { address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), data: LogData::new_unchecked( @@ -1346,7 +1465,7 @@ mod tests { ), }], }, - bloom: [0; 256].into(), + logs_bloom: [0; 256].into(), }); let receipt = TypedReceipt::decode(&mut &data[..]).unwrap(); diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 86edc810a537f..dedaffaf34589 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -1,6 +1,5 @@ -use alloy_consensus::TxType; -use alloy_network::{Transaction, TxKind}; -use alloy_primitives::{Address, Bytes, ChainId, Signature, B256, U256}; +use alloy_consensus::{SignableTransaction, Signed, Transaction, TxType}; +use alloy_primitives::{keccak256, Address, Bytes, ChainId, Signature, TxKind, B256, U256}; use alloy_rlp::{ length_of_length, Decodable, Encodable, Error as DecodeError, Header as RlpHeader, }; @@ -13,7 +12,7 @@ pub struct DepositTransactionRequest { pub kind: TxKind, pub mint: U256, pub value: U256, - pub gas_limit: U256, + pub gas_limit: u128, pub is_system_tx: bool, pub input: Bytes, } @@ -134,108 +133,74 @@ impl DepositTransactionRequest { 1 + length_of_length(payload_length) + payload_length } - /// Outputs the signature hash of the transaction by first encoding without a signature, then - /// hashing. - pub(crate) fn signature_hash(&self) -> B256 { - let mut buf = Vec::with_capacity(self.payload_len_for_signature()); - self.encode_for_signing(&mut buf); - alloy_primitives::utils::keccak256(&buf) + fn encoded_len_with_signature(&self, signature: &Signature) -> usize { + // this counts the tx fields and signature fields + let payload_length = self.fields_len() + signature.rlp_vrs_len(); + + // this counts: + // * tx type byte + // * inner header length + // * inner payload length + 1 + alloy_rlp::Header { list: true, payload_length }.length() + payload_length } } impl Transaction for DepositTransactionRequest { - type Signature = Signature; - - fn chain_id(&self) -> Option { - None - } - - fn gas_limit(&self) -> u64 { - self.gas_limit.to::() - } - - fn nonce(&self) -> u64 { - u64::MAX + fn input(&self) -> &[u8] { + &self.input } - fn decode_signed(buf: &mut &[u8]) -> alloy_rlp::Result> - where - Self: Sized, - { - let header = alloy_rlp::Header::decode(buf)?; - if !header.list { - return Err(alloy_rlp::Error::UnexpectedString); - } - - let tx = Self::decode_inner(buf)?; - let signature = Signature::decode_rlp_vrs(buf)?; - - Ok(tx.into_signed(signature)) + /// Get `to`. + fn to(&self) -> TxKind { + self.kind } - fn encode_signed(&self, signature: &Signature, out: &mut dyn bytes::BufMut) { - self.encode_with_signature(signature, out) + /// Get `value`. + fn value(&self) -> U256 { + self.value } - fn gas_price(&self) -> Option { + /// Get `chain_id`. + fn chain_id(&self) -> Option { None } - fn input(&self) -> &[u8] { - &self.input + /// Get `nonce`. + fn nonce(&self) -> u64 { + u64::MAX } - fn input_mut(&mut self) -> &mut Bytes { - &mut self.input + /// Get `gas_limit`. + fn gas_limit(&self) -> u128 { + self.gas_limit } - fn into_signed(self, signature: Signature) -> alloy_network::Signed - where - Self: Sized, - { - alloy_network::Signed::new_unchecked(self.clone(), signature, self.signature_hash()) + /// Get `gas_price`. + fn gas_price(&self) -> Option { + None } +} +impl SignableTransaction for DepositTransactionRequest { fn set_chain_id(&mut self, _chain_id: ChainId) {} - fn set_gas_limit(&mut self, limit: u64) { - self.gas_limit = U256::from(limit); - } - - fn set_gas_price(&mut self, _price: U256) {} - - fn set_input(&mut self, data: Bytes) { - self.input = data; - } - - fn set_nonce(&mut self, _nonce: u64) {} - - fn set_to(&mut self, to: TxKind) { - self.kind = to; - } - - fn set_value(&mut self, value: U256) { - self.value = value; - } - - fn signature_hash(&self) -> B256 { - self.signature_hash() + fn payload_len_for_signature(&self) -> usize { + self.payload_len_for_signature() } - fn to(&self) -> TxKind { - self.kind - } + fn into_signed(self, signature: Signature) -> Signed { + let mut buf = Vec::with_capacity(self.encoded_len_with_signature(&signature)); + self.encode_with_signature(&signature, &mut buf); + let hash = keccak256(&buf); - fn value(&self) -> U256 { - self.value + // Drop any v chain id value to ensure the signature format is correct at the time of + // combination for an EIP-4844 transaction. V should indicate the y-parity of the + // signature. + Signed::new_unchecked(self, signature.with_parity_bool(), hash) } fn encode_for_signing(&self, out: &mut dyn alloy_rlp::BufMut) { - self.encode_for_signing(out) - } - - fn payload_len_for_signature(&self) -> usize { - self.payload_len_for_signature() + self.encode_for_signing(out); } } @@ -265,19 +230,19 @@ impl Encodable for DepositTransactionRequest { /// See #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct DepositTransaction { - pub nonce: U256, + pub nonce: u64, pub source_hash: B256, pub from: Address, pub kind: TxKind, pub mint: U256, pub value: U256, - pub gas_limit: U256, + pub gas_limit: u128, pub is_system_tx: bool, pub input: Bytes, } impl DepositTransaction { - pub fn nonce(&self) -> &U256 { + pub fn nonce(&self) -> &u64 { &self.nonce } @@ -336,7 +301,7 @@ impl DepositTransaction { /// - `input` pub fn decode_inner(buf: &mut &[u8]) -> Result { Ok(Self { - nonce: U256::ZERO, + nonce: 0, source_hash: Decodable::decode(buf)?, from: Decodable::decode(buf)?, kind: Decodable::decode(buf)?, diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index db966d956d206..2e0c63b13485f 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -190,10 +190,10 @@ pub struct NodeInfo { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct NodeEnvironment { - pub base_fee: U256, + pub base_fee: u128, pub chain_id: u64, - pub gas_limit: U256, - pub gas_price: U256, + pub gas_limit: u128, + pub gas_price: u128, } #[derive(Clone, Debug, Default, PartialEq, Eq)] diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 9cde54553120c..8e29152410eee 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -5,7 +5,7 @@ use crate::{ }; use alloy_genesis::Genesis; use alloy_primitives::{utils::Unit, U256}; -use alloy_signer::coins_bip39::{English, Mnemonic}; +use alloy_signer_wallet::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; use clap::Parser; use core::fmt; @@ -194,9 +194,9 @@ impl NodeArgs { }; NodeConfig::default() - .with_gas_limit(self.evm_opts.gas_limit.map(U256::from)) + .with_gas_limit(self.evm_opts.gas_limit) .disable_block_gas_limit(self.evm_opts.disable_block_gas_limit) - .with_gas_price(self.evm_opts.gas_price.map(U256::from)) + .with_gas_price(self.evm_opts.gas_price) .with_hardfork(self.hardfork) .with_blocktime(self.block_time) .with_no_mining(self.no_mining) @@ -216,7 +216,7 @@ impl NodeArgs { .fork_retry_backoff(self.evm_opts.fork_retry_backoff.map(Duration::from_millis)) .fork_compute_units_per_second(compute_units_per_second) .with_eth_rpc_url(self.evm_opts.fork_url.map(|fork| fork.url)) - .with_base_fee(self.evm_opts.block_base_fee_per_gas.map(U256::from)) + .with_base_fee(self.evm_opts.block_base_fee_per_gas) .with_storage_caching(self.evm_opts.no_storage_caching) .with_server_config(self.server_config) .with_host(self.host) @@ -455,7 +455,7 @@ pub struct AnvilEvmArgs { /// The block gas limit. #[arg(long, alias = "block-gas-limit", help_heading = "Environment config")] - pub gas_limit: Option, + pub gas_limit: Option, /// Disable the `call.gas_limit <= block.gas_limit` constraint. #[arg( @@ -474,7 +474,7 @@ pub struct AnvilEvmArgs { /// The gas price. #[arg(long, help_heading = "Environment config")] - pub gas_price: Option, + pub gas_price: Option, /// The base fee in a block. #[arg( @@ -483,7 +483,7 @@ pub struct AnvilEvmArgs { value_name = "FEE", help_heading = "Environment config" )] - pub block_base_fee_per_gas: Option, + pub block_base_fee_per_gas: Option, /// The chain ID. #[arg(long, alias = "chain", help_heading = "Environment config")] diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index a1e736619250f..58de505ed011a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -16,14 +16,16 @@ use crate::{ FeeManager, Hardfork, }; use alloy_genesis::Genesis; +use alloy_network::AnyNetwork; use alloy_primitives::{hex, utils::Unit, U256}; -use alloy_providers::tmp::TempProvider; +use alloy_provider::Provider; use alloy_rpc_types::BlockNumberOrTag; -use alloy_signer::{ +use alloy_signer::Signer; +use alloy_signer_wallet::{ coins_bip39::{English, Mnemonic}, - LocalWallet, MnemonicBuilder, Signer as AlloySigner, + LocalWallet, MnemonicBuilder, }; -use alloy_transport::TransportError; +use alloy_transport::{Transport, TransportError}; use anvil_server::ServerConfig; use foundry_common::{ provider::alloy::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, @@ -91,13 +93,13 @@ pub struct NodeConfig { /// Chain ID of the EVM chain pub chain_id: Option, /// Default gas limit for all txs - pub gas_limit: U256, + pub gas_limit: u128, /// If set to `true`, disables the block gas limit pub disable_block_gas_limit: bool, /// Default gas price for all txs - pub gas_price: Option, + pub gas_price: Option, /// Default base fee - pub base_fee: Option, + pub base_fee: Option, /// The hardfork to use pub hardfork: Option, /// Signer accounts that will be initialised with `genesis_balance` in the genesis block @@ -376,7 +378,7 @@ impl Default for NodeConfig { let genesis_accounts = AccountGenerator::new(10).phrase(DEFAULT_MNEMONIC).gen(); Self { chain_id: None, - gas_limit: U256::from(30_000_000), + gas_limit: 30_000_000, disable_block_gas_limit: false, gas_price: None, hardfork: None, @@ -432,15 +434,15 @@ impl NodeConfig { self } /// Returns the base fee to use - pub fn get_base_fee(&self) -> U256 { + pub fn get_base_fee(&self) -> u128 { self.base_fee - .or_else(|| self.genesis.as_ref().and_then(|g| g.base_fee_per_gas.map(U256::from))) - .unwrap_or_else(|| U256::from(INITIAL_BASE_FEE)) + .or_else(|| self.genesis.as_ref().and_then(|g| g.base_fee_per_gas)) + .unwrap_or(INITIAL_BASE_FEE) } /// Returns the base fee to use - pub fn get_gas_price(&self) -> U256 { - self.gas_price.unwrap_or_else(|| U256::from(INITIAL_GAS_PRICE)) + pub fn get_gas_price(&self) -> u128 { + self.gas_price.unwrap_or(INITIAL_GAS_PRICE) } /// Returns the base fee to use @@ -497,7 +499,7 @@ impl NodeConfig { /// Sets the gas limit #[must_use] - pub fn with_gas_limit(mut self, gas_limit: Option) -> Self { + pub fn with_gas_limit(mut self, gas_limit: Option) -> Self { if let Some(gas_limit) = gas_limit { self.gas_limit = gas_limit; } @@ -515,8 +517,8 @@ impl NodeConfig { /// Sets the gas price #[must_use] - pub fn with_gas_price(mut self, gas_price: Option) -> Self { - self.gas_price = gas_price.map(Into::into); + pub fn with_gas_price(mut self, gas_price: Option) -> Self { + self.gas_price = gas_price; self } @@ -539,8 +541,8 @@ impl NodeConfig { /// Sets the base fee #[must_use] - pub fn with_base_fee(mut self, base_fee: Option) -> Self { - self.base_fee = base_fee.map(Into::into); + pub fn with_base_fee(mut self, base_fee: Option) -> Self { + self.base_fee = base_fee; self } @@ -857,8 +859,8 @@ impl NodeConfig { let env = revm::primitives::Env { cfg: cfg.cfg_env, block: BlockEnv { - gas_limit: self.gas_limit, - basefee: self.get_base_fee(), + gas_limit: U256::from(self.gas_limit), + basefee: U256::from(self.get_base_fee()), ..Default::default() }, tx: TxEnv { chain_id: self.get_chain_id().into(), ..Default::default() }, @@ -985,7 +987,7 @@ impl NodeConfig { // but only if we're forking mainnet let chain_id = provider.get_chain_id().await.expect("Failed to fetch network chain ID"); - if alloy_chains::NamedChain::Mainnet == chain_id.to::() { + if alloy_chains::NamedChain::Mainnet == chain_id { let hardfork: Hardfork = fork_block_number.into(); env.handler_cfg.spec_id = hardfork.into(); self.hardfork = Some(hardfork); @@ -1030,19 +1032,19 @@ latest block number: {latest_block}" // we only use the gas limit value of the block if it is non-zero and the block gas // limit is enabled, since there are networks where this is not used and is always // `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also - let gas_limit = if self.disable_block_gas_limit || block.header.gas_limit.is_zero() { - U256::from(u64::MAX) + let gas_limit = if self.disable_block_gas_limit || block.header.gas_limit == 0 { + u128::MAX } else { block.header.gas_limit }; env.block = BlockEnv { number: U256::from(fork_block_number), - timestamp: block.header.timestamp, + timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, // ensures prevrandao is set prevrandao: Some(block.header.mix_hash.unwrap_or_default()), - gas_limit, + gas_limit: U256::from(gas_limit), // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, @@ -1053,7 +1055,7 @@ latest block number: {latest_block}" if self.base_fee.is_none() { if let Some(base_fee) = block.header.base_fee_per_gas { self.base_fee = Some(base_fee); - env.block.basefee = base_fee; + env.block.basefee = U256::from(base_fee); // this is the base fee of the current block, but we need the base fee of // the next block let next_block_base_fee = fees.get_next_block_base_fee_per_gas( @@ -1062,7 +1064,7 @@ latest block number: {latest_block}" block.header.base_fee_per_gas.unwrap_or_default(), ); // update next base fee - fees.set_base_fee(U256::from(next_block_base_fee)); + fees.set_base_fee(next_block_base_fee); } } @@ -1080,9 +1082,9 @@ latest block number: {latest_block}" chain_id } else { let chain_id = if let Some(fork_chain_id) = fork_chain_id { - fork_chain_id.to::() + fork_chain_id.to() } else { - provider.get_chain_id().await.unwrap().to::() + provider.get_chain_id().await.unwrap() }; // need to update the dev signers and env with the chain id @@ -1117,7 +1119,7 @@ latest block number: {latest_block}" provider, chain_id, override_chain_id, - timestamp: block.header.timestamp.to::(), + timestamp: block.header.timestamp, base_fee: block.header.base_fee_per_gas, timeout: self.fork_request_timeout, retries: self.fork_request_retries, @@ -1241,7 +1243,9 @@ pub fn anvil_tmp_dir() -> Option { /// /// This fetches the "latest" block and checks whether the `Block` is fully populated (`hash` field /// is present). This prevents edge cases where anvil forks the "latest" block but `eth_getBlockByNumber` still returns a pending block, -async fn find_latest_fork_block(provider: P) -> Result { +async fn find_latest_fork_block, T: Transport + Clone>( + provider: P, +) -> Result { let mut num = provider.get_block_number().await?; // walk back from the head of the chain, but at most 2 blocks, which should be more than enough diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index aee9670849df1..d21ed852feee7 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -31,29 +31,27 @@ use crate::{ revm::primitives::Output, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; -use alloy_consensus::TxLegacy; use alloy_dyn_abi::TypedData; -use alloy_network::{Signed, TxKind}; -use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256, U64}; -use alloy_rlp::Decodable; -use alloy_rpc_trace_types::{ - geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, - parity::LocalizedTransactionTrace, -}; +use alloy_network::eip2718::Decodable2718; +use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, B64, U256, U64}; use alloy_rpc_types::{ request::TransactionRequest, state::StateOverride, txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, AccessList, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Log, - Transaction, TransactionReceipt, + Transaction, WithOtherFields, +}; +use alloy_rpc_types_trace::{ + geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace, }; use alloy_transport::TransportErrorKind; use anvil_core::{ eth::{ block::BlockInfo, transaction::{ - transaction_request_to_typed, PendingTransaction, TypedTransaction, + transaction_request_to_typed, PendingTransaction, ReceiptResponse, TypedTransaction, TypedTransactionRequest, }, EthRequest, @@ -447,11 +445,6 @@ impl EthApi { Err(BlockchainError::NoSignerAvailable) } - /// Queries the current gas limit - fn current_gas_limit(&self) -> Result { - Ok(self.backend.gas_limit()) - } - async fn block_request(&self, block_number: Option) -> Result { let block_request = match block_number { Some(BlockId::Number(BlockNumber::Pending)) => { @@ -550,7 +543,7 @@ impl EthApi { /// Returns the current gas price pub fn gas_price(&self) -> Result { - Ok(self.backend.gas_price()) + Ok(U256::from(self.backend.gas_price())) } /// Returns a fee per gas that is an estimate of how much you can pay as a priority fee, or @@ -558,12 +551,12 @@ impl EthApi { /// /// Handler for ETH RPC call: `eth_maxPriorityFeePerGas` pub fn gas_max_priority_fee_per_gas(&self) -> Result { - Ok(self.backend.max_priority_fee_per_gas()) + Ok(U256::from(self.backend.max_priority_fee_per_gas())) } /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { - self.backend.gas_limit() + U256::from(self.backend.gas_limit()) } /// Returns the accounts list @@ -690,7 +683,7 @@ impl EthApi { block_number: Option, ) -> Result { node_info!("eth_getTransactionCount"); - self.get_transaction_count(address, block_number).await + self.get_transaction_count(address, block_number).await.map(U256::from) } /// Returns the number of transactions in a block with given hash. @@ -845,7 +838,10 @@ impl EthApi { /// Signs a transaction /// /// Handler for ETH RPC call: `eth_signTransaction` - pub async fn sign_transaction(&self, mut request: TransactionRequest) -> Result { + pub async fn sign_transaction( + &self, + mut request: WithOtherFields, + ) -> Result { node_info!("eth_signTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { @@ -857,7 +853,7 @@ impl EthApi { if request.gas.is_none() { // estimate if not provided if let Ok(gas) = self.estimate_gas(request.clone(), None, None).await { - request.gas = Some(gas); + request.gas = Some(gas.to()); } } @@ -872,7 +868,10 @@ impl EthApi { /// Sends a transaction /// /// Handler for ETH RPC call: `eth_sendTransaction` - pub async fn send_transaction(&self, mut request: TransactionRequest) -> Result { + pub async fn send_transaction( + &self, + mut request: WithOtherFields, + ) -> Result { node_info!("eth_sendTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { @@ -883,7 +882,7 @@ impl EthApi { if request.gas.is_none() { // estimate if not provided if let Ok(gas) = self.estimate_gas(request.clone(), None, None).await { - request.gas = Some(gas); + request.gas = Some(gas.to()); } } @@ -904,7 +903,7 @@ impl EthApi { self.backend.validate_pool_transaction(&pending_transaction).await?; let requires = required_marker(nonce, on_chain_nonce, from); - let provides = vec![to_marker(nonce.to::(), from)]; + let provides = vec![to_marker(nonce, from)]; debug_assert!(requires != provides); self.add_pending_transaction(pending_transaction, requires, provides) @@ -919,26 +918,11 @@ impl EthApi { if data.is_empty() { return Err(BlockchainError::EmptyRawTransactionData); } - let transaction = if data[0] > 0x7f { - // legacy transaction - match Signed::::decode(&mut data) { - Ok(transaction) => TypedTransaction::Legacy(transaction), - Err(_) => return Err(BlockchainError::FailedToDecodeSignedTransaction), - } - } else { - // the [TypedTransaction] requires a valid rlp input, - // but EIP-1559 prepends a version byte, so we need to encode the data first to get a - // valid rlp and then rlp decode impl of `TypedTransaction` will remove and check the - // version byte - let extend = alloy_rlp::encode(data); - let tx = match TypedTransaction::decode(&mut &extend[..]) { - Ok(transaction) => transaction, - Err(_) => return Err(BlockchainError::FailedToDecodeSignedTransaction), - }; + let transaction = TypedTransaction::decode_2718(&mut data) + .map_err(|_| BlockchainError::FailedToDecodeSignedTransaction)?; + + self.ensure_typed_transaction_supported(&transaction)?; - self.ensure_typed_transaction_supported(&tx)?; - tx - }; let pending_transaction = PendingTransaction::new(transaction)?; // pre-validate @@ -952,7 +936,7 @@ impl EthApi { let priority = self.transaction_priority(&pending_transaction.transaction); let pool_transaction = PoolTransaction { requires, - provides: vec![to_marker(nonce.to::(), *pending_transaction.sender())], + provides: vec![to_marker(nonce, *pending_transaction.sender())], pending_transaction, priority, }; @@ -967,7 +951,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_call` pub async fn call( &self, - request: TransactionRequest, + request: WithOtherFields, block_number: Option, overrides: Option, ) -> Result { @@ -1020,7 +1004,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_createAccessList` pub async fn create_access_list( &self, - mut request: TransactionRequest, + mut request: WithOtherFields, block_number: Option, ) -> Result { node_info!("eth_createAccessList"); @@ -1069,7 +1053,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_estimateGas` pub async fn estimate_gas( &self, - request: TransactionRequest, + request: WithOtherFields, block_number: Option, overrides: Option, ) -> Result { @@ -1080,6 +1064,7 @@ impl EthApi { overrides, ) .await + .map(U256::from) } /// Get transaction by its hash. @@ -1088,7 +1073,10 @@ impl EthApi { /// this will also scan the mempool for a matching pending transaction /// /// Handler for ETH RPC call: `eth_getTransactionByHash` - pub async fn transaction_by_hash(&self, hash: B256) -> Result> { + pub async fn transaction_by_hash( + &self, + hash: B256, + ) -> Result>> { node_info!("eth_getTransactionByHash"); let mut tx = self.pool.get_transaction(hash).map(|pending| { let from = *pending.sender(); @@ -1118,7 +1106,7 @@ impl EthApi { &self, hash: B256, index: Index, - ) -> Result> { + ) -> Result>> { node_info!("eth_getTransactionByBlockHashAndIndex"); self.backend.transaction_by_block_hash_and_index(hash, index).await } @@ -1130,7 +1118,7 @@ impl EthApi { &self, block: BlockNumber, idx: Index, - ) -> Result> { + ) -> Result>> { node_info!("eth_getTransactionByBlockNumberAndIndex"); self.backend.transaction_by_block_number_and_index(block, idx).await } @@ -1138,7 +1126,7 @@ impl EthApi { /// Returns transaction receipt by transaction hash. /// /// Handler for ETH RPC call: `eth_getTransactionReceipt` - pub async fn transaction_receipt(&self, hash: B256) -> Result> { + pub async fn transaction_receipt(&self, hash: B256) -> Result> { node_info!("eth_getTransactionReceipt"); let tx = self.pool.get_transaction(hash); if tx.is_some() { @@ -1153,7 +1141,7 @@ impl EthApi { pub async fn block_receipts( &self, number: BlockNumber, - ) -> Result>> { + ) -> Result>> { node_info!("eth_getBlockReceipts"); self.backend.block_receipts(number).await } @@ -1266,7 +1254,7 @@ impl EthApi { // efficiently, instead we fetch it from the fork if fork.predates_fork_inclusive(number) { return fork - .fee_history(block_count, BlockNumber::Number(number), &reward_percentiles) + .fee_history(block_count.to(), BlockNumber::Number(number), &reward_percentiles) .await .map_err(BlockchainError::AlloyForkProvider); } @@ -1285,7 +1273,7 @@ impl EthApi { } let mut response = FeeHistory { - oldest_block: U256::from(lowest), + oldest_block: lowest, base_fee_per_gas: Vec::new(), gas_used_ratio: Vec::new(), reward: Some(Default::default()), @@ -1301,7 +1289,7 @@ impl EthApi { for n in lowest..=highest { // if let Some(block) = fee_history.get(&n) { - response.base_fee_per_gas.push(U256::from(block.base_fee)); + response.base_fee_per_gas.push(block.base_fee); response.gas_used_ratio.push(block.gas_used_ratio); // requested percentiles @@ -1311,11 +1299,7 @@ impl EthApi { for p in &reward_percentiles { let p = p.clamp(0.0, 100.0); let index = ((p.round() / 2f64) * 2f64) * resolution_per_percentile; - let reward = if let Some(r) = block.rewards.get(index as usize) { - U256::from(*r) - } else { - U256::ZERO - }; + let reward = block.rewards.get(index as usize).map_or(0, |r| *r); block_rewards.push(reward); } rewards.push(block_rewards); @@ -1334,20 +1318,20 @@ impl EthApi { (response.gas_used_ratio.last(), response.base_fee_per_gas.last()) { let elasticity = self.backend.elasticity(); - let last_fee_per_gas = last_fee_per_gas.to::() as f64; + let last_fee_per_gas = *last_fee_per_gas as f64; if last_gas_used > &0.5 { // increase base gas let increase = ((last_gas_used - 0.5) * 2f64) * elasticity; - let new_base_fee = (last_fee_per_gas + (last_fee_per_gas * increase)) as u64; - response.base_fee_per_gas.push(U256::from(new_base_fee)); + let new_base_fee = (last_fee_per_gas + (last_fee_per_gas * increase)) as u128; + response.base_fee_per_gas.push(new_base_fee); } else if last_gas_used < &0.5 { // decrease gas let increase = ((0.5 - last_gas_used) * 2f64) * elasticity; - let new_base_fee = (last_fee_per_gas - (last_fee_per_gas * increase)) as u64; - response.base_fee_per_gas.push(U256::from(new_base_fee)); + let new_base_fee = (last_fee_per_gas - (last_fee_per_gas * increase)) as u128; + response.base_fee_per_gas.push(new_base_fee); } else { // same base gas - response.base_fee_per_gas.push(U256::from(last_fee_per_gas as u64)); + response.base_fee_per_gas.push(last_fee_per_gas as u128); } } @@ -1362,7 +1346,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_maxPriorityFeePerGas` pub fn max_priority_fee_per_gas(&self) -> Result { node_info!("eth_maxPriorityFeePerGas"); - Ok(self.backend.max_priority_fee_per_gas()) + Ok(U256::from(self.backend.max_priority_fee_per_gas())) } /// Creates a filter object, based on filter options, to notify when the state changes (logs). @@ -1447,7 +1431,7 @@ impl EthApi { /// Handler for RPC call: `debug_traceCall` pub async fn debug_trace_call( &self, - request: TransactionRequest, + request: WithOtherFields, block_number: Option, opts: GethDefaultTracingOptions, ) -> Result { @@ -1671,7 +1655,7 @@ impl EthApi { ) .into()); } - self.backend.set_gas_price(gas); + self.backend.set_gas_price(gas.to()); Ok(()) } @@ -1686,7 +1670,7 @@ impl EthApi { ) .into()); } - self.backend.set_base_fee(basefee); + self.backend.set_base_fee(basefee.to()); Ok(()) } @@ -1842,7 +1826,7 @@ impl EthApi { /// Handler for RPC call: `evm_setBlockGasLimit` pub fn evm_set_block_gas_limit(&self, gas_limit: U256) -> Result { node_info!("evm_setBlockGasLimit"); - self.backend.set_gas_limit(gas_limit); + self.backend.set_gas_limit(gas_limit.to()); Ok(true) } @@ -1907,7 +1891,7 @@ impl EthApi { if let Some(receipt) = self.backend.mined_transaction_receipt(tx.hash) { if let Some(output) = receipt.out { // insert revert reason if failure - if receipt.inner.status_code.unwrap_or_default().to::() == 0 { + if !receipt.inner.inner.as_receipt_with_bloom().receipt.status { if let Some(reason) = RevertDecoder::new().maybe_decode(&output, None) { @@ -1980,7 +1964,7 @@ impl EthApi { /// Handler for ETH RPC call: `eth_sendUnsignedTransaction` pub async fn eth_send_unsigned_transaction( &self, - request: TransactionRequest, + request: WithOtherFields, ) -> Result { node_info!("eth_sendUnsignedTransaction"); // either use the impersonated account of the request's `from` field @@ -2001,7 +1985,7 @@ impl EthApi { self.backend.validate_pool_transaction(&pending_transaction).await?; let requires = required_marker(nonce, on_chain_nonce, from); - let provides = vec![to_marker(nonce.to::(), from)]; + let provides = vec![to_marker(nonce, from)]; self.add_pending_transaction(pending_transaction, requires, provides) } @@ -2029,9 +2013,9 @@ impl EthApi { fn convert(tx: Arc) -> TxpoolInspectSummary { let tx = &tx.pending_transaction.transaction; let to = tx.to(); - let gas_price = tx.gas_price(); + let gas_price = U256::from(tx.gas_price()); let value = tx.value(); - let gas = tx.gas_limit(); + let gas = U256::from(tx.gas_limit()); TxpoolInspectSummary { to, value, gas, gas_price } } @@ -2076,7 +2060,7 @@ impl EthApi { // we set the from field here explicitly to the set sender of the pending transaction, // in case the transaction is impersonated. tx.from = from; - tx + tx.inner } for pending in self.pool.ready_transactions() { @@ -2146,10 +2130,10 @@ impl EthApi { async fn do_estimate_gas( &self, - request: TransactionRequest, + request: WithOtherFields, block_number: Option, overrides: Option, - ) -> Result { + ) -> Result { let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode if let BlockRequest::Number(number) = block_request { @@ -2183,10 +2167,10 @@ impl EthApi { /// This will execute the [CallRequest] and find the best gas limit via binary search fn do_estimate_gas_with_state( &self, - mut request: TransactionRequest, + mut request: WithOtherFields, state: D, block_env: BlockEnv, - ) -> Result + ) -> Result where D: DatabaseRef, { @@ -2212,11 +2196,11 @@ impl EthApi { // get the highest possible gas limit, either the request's set value or the currently // configured gas limit - let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit); + let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit.to()); let gas_price = fees.gas_price.unwrap_or_default(); // If we have non-zero gas price, cap gas limit by sender balance - if !gas_price.is_zero() { + if gas_price > 0 { if let Some(from) = request.from { let mut available_funds = self.backend.get_balance_with_state(&state, from)?; if let Some(value) = request.value { @@ -2227,7 +2211,8 @@ impl EthApi { available_funds -= value; } // amount of gas the sender can afford with the `gas_price` - let allowance = available_funds.checked_div(gas_price).unwrap_or_default(); + let allowance = + available_funds.to::().checked_div(gas_price).unwrap_or_default(); highest_gas_limit = std::cmp::min(highest_gas_limit, allowance); } } @@ -2240,7 +2225,7 @@ impl EthApi { self.backend.call_with_state(&state, call_to_estimate, fees.clone(), block_env.clone()); let gas_used = match ethres.try_into()? { - GasEstimationCallResult::Success(gas) => Ok(U256::from(gas)), + GasEstimationCallResult::Success(gas) => Ok(gas), GasEstimationCallResult::OutOfGas => { Err(InvalidTransactionError::BasicOutOfGas(highest_gas_limit).into()) } @@ -2262,13 +2247,11 @@ impl EthApi { let mut lowest_gas_limit = determine_base_gas_by_kind(&request); // pick a point that's close to the estimated gas - let mut mid_gas_limit = std::cmp::min( - gas_used * U256::from(3), - (highest_gas_limit + lowest_gas_limit) / U256::from(2), - ); + let mut mid_gas_limit = + std::cmp::min(gas_used * 3, (highest_gas_limit + lowest_gas_limit) / 2); // Binary search for the ideal gas limit - while (highest_gas_limit - lowest_gas_limit) > U256::from(1) { + while (highest_gas_limit - lowest_gas_limit) > 1 { request.gas = Some(mid_gas_limit); let ethres = self.backend.call_with_state( &state, @@ -2297,7 +2280,7 @@ impl EthApi { } }; // new midpoint - mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / U256::from(2); + mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; } trace!(target : "node", "Estimated Gas for call {:?}", highest_gas_limit); @@ -2398,7 +2381,7 @@ impl EthApi { Some(info), Some(base_fee), ); - block_transactions.push(tx); + block_transactions.push(tx.inner); } Some(partial_block.into_full_block(block_transactions)) @@ -2406,40 +2389,40 @@ impl EthApi { fn build_typed_tx_request( &self, - request: TransactionRequest, - nonce: U256, + request: WithOtherFields, + nonce: u64, ) -> Result { - let chain_id = request.chain_id.map(|c| c.to::()).unwrap_or_else(|| self.chain_id()); + let chain_id = request.chain_id.unwrap_or_else(|| self.chain_id()); let max_fee_per_gas = request.max_fee_per_gas; let gas_price = request.gas_price; - let gas_limit = request.gas.map(Ok).unwrap_or_else(|| self.current_gas_limit())?; + let gas_limit = request.gas.unwrap_or(self.backend.gas_limit()); let request = match transaction_request_to_typed(request) { Some(TypedTransactionRequest::Legacy(mut m)) => { - m.nonce = nonce.to::(); + m.nonce = nonce; m.chain_id = Some(chain_id); - m.gas_limit = gas_limit.to::(); + m.gas_limit = gas_limit; if gas_price.is_none() { - m.gas_price = self.gas_price().unwrap_or_default().to::(); + m.gas_price = self.backend.gas_price() } TypedTransactionRequest::Legacy(m) } Some(TypedTransactionRequest::EIP2930(mut m)) => { - m.nonce = nonce.to::(); + m.nonce = nonce; m.chain_id = chain_id; - m.gas_limit = gas_limit.to::(); + m.gas_limit = gas_limit; if gas_price.is_none() { - m.gas_price = self.gas_price().unwrap_or_default().to::(); + m.gas_price = self.backend.gas_price(); } TypedTransactionRequest::EIP2930(m) } Some(TypedTransactionRequest::EIP1559(mut m)) => { - m.nonce = nonce.to::(); + m.nonce = nonce; m.chain_id = chain_id; - m.gas_limit = gas_limit.to::(); + m.gas_limit = gas_limit; if max_fee_per_gas.is_none() { - m.max_fee_per_gas = self.gas_price().unwrap_or_default().to::(); + m.max_fee_per_gas = self.backend.gas_price(); } TypedTransactionRequest::EIP1559(m) } @@ -2462,7 +2445,7 @@ impl EthApi { &self, address: Address, block_number: Option, - ) -> Result { + ) -> Result { let block_request = self.block_request(block_number).await?; if let BlockRequest::Number(number) = block_request { @@ -2473,9 +2456,7 @@ impl EthApi { } } - let nonce = self.backend.get_nonce(address, block_request).await?; - - Ok(nonce) + self.backend.get_nonce(address, block_request).await } /// Returns the nonce for this request @@ -2489,10 +2470,10 @@ impl EthApi { &self, request: &TransactionRequest, from: Address, - ) -> Result<(U256, U256)> { + ) -> Result<(u64, u64)> { let highest_nonce = self.get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))).await?; - let nonce = request.nonce.map(|n| n.to::()).unwrap_or(highest_nonce); + let nonce = request.nonce.unwrap_or(highest_nonce); Ok((nonce, highest_nonce)) } @@ -2530,13 +2511,13 @@ impl EthApi { } } -fn required_marker(provided_nonce: U256, on_chain_nonce: U256, from: Address) -> Vec { +fn required_marker(provided_nonce: u64, on_chain_nonce: u64, from: Address) -> Vec { if provided_nonce == on_chain_nonce { return Vec::new(); } - let prev_nonce = provided_nonce.saturating_sub(U256::from(1)); + let prev_nonce = provided_nonce.saturating_sub(1); if on_chain_nonce <= prev_nonce { - vec![to_marker(prev_nonce.to::(), from)] + vec![to_marker(prev_nonce, from)] } else { Vec::new() } @@ -2562,7 +2543,7 @@ fn ensure_return_ok(exit: InstructionResult, out: &Option) -> Result U256 { +fn determine_base_gas_by_kind(request: &WithOtherFields) -> u128 { match transaction_request_to_typed(request.clone()) { Some(request) => match request { TypedTransactionRequest::Legacy(req) => match req.to { @@ -2577,10 +2558,7 @@ fn determine_base_gas_by_kind(request: &TransactionRequest) -> U256 { TxKind::Call(_) => MIN_TRANSACTION_GAS, TxKind::Create => MIN_CREATE_GAS, }, - TypedTransactionRequest::EIP4844(req) => match req.tx().to { - TxKind::Call(_) => MIN_TRANSACTION_GAS, - TxKind::Create => MIN_CREATE_GAS, - }, + TypedTransactionRequest::EIP4844(_) => MIN_TRANSACTION_GAS, TypedTransactionRequest::Deposit(req) => match req.kind { TxKind::Call(_) => MIN_TRANSACTION_GAS, TxKind::Create => MIN_CREATE_GAS, @@ -2594,17 +2572,17 @@ fn determine_base_gas_by_kind(request: &TransactionRequest) -> U256 { /// Keeps result of a call to revm EVM used for gas estimation enum GasEstimationCallResult { - Success(u64), + Success(u128), OutOfGas, Revert(Option), EvmError(InstructionResult), } /// Converts the result of a call to revm EVM into a [GasEstimationCallRes]. -impl TryFrom, u64, State)>> for GasEstimationCallResult { +impl TryFrom, u128, State)>> for GasEstimationCallResult { type Error = BlockchainError; - fn try_from(res: Result<(InstructionResult, Option, u64, State)>) -> Result { + fn try_from(res: Result<(InstructionResult, Option, u128, State)>) -> Result { match res { // Exceptional case: init used too much gas, treated as out of gas error Err(BlockchainError::InvalidTransaction(InvalidTransactionError::GasTooHigh(_))) => { diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 5e68924c95c39..80a72beedc641 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -7,10 +7,12 @@ use crate::{ mem::inspector::Inspector, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; -use alloy_primitives::{Bloom, BloomInput, Log, B256, U256}; +use alloy_primitives::{Bloom, BloomInput, Log, B256}; use anvil_core::eth::{ block::{Block, BlockInfo, PartialHeader}, - transaction::{PendingTransaction, TransactionInfo, TypedReceipt, TypedTransaction}, + transaction::{ + DepositReceipt, PendingTransaction, TransactionInfo, TypedReceipt, TypedTransaction, + }, trie, }; use foundry_evm::{ @@ -33,7 +35,7 @@ pub struct ExecutedTransaction { transaction: Arc, exit_reason: InstructionResult, out: Option, - gas_used: u64, + gas_used: u128, logs: Vec, traces: Vec, nonce: u64, @@ -43,54 +45,25 @@ pub struct ExecutedTransaction { impl ExecutedTransaction { /// Creates the receipt for the transaction - fn create_receipt(&self) -> TypedReceipt { - let used_gas = U256::from(self.gas_used); - let mut bloom = Bloom::default(); - logs_bloom(self.logs.clone(), &mut bloom); + fn create_receipt(&self, cumulative_gas_used: &mut u128) -> TypedReceipt { let logs = self.logs.clone(); + *cumulative_gas_used = cumulative_gas_used.saturating_add(self.gas_used); // successful return see [Return] let status_code = u8::from(self.exit_reason as u8 <= InstructionResult::SelfDestruct as u8); + let receipt_with_bloom: ReceiptWithBloom = + Receipt { status: status_code == 1, cumulative_gas_used: *cumulative_gas_used, logs } + .into(); + match &self.transaction.pending_transaction.transaction.transaction { - TypedTransaction::Legacy(_) => TypedReceipt::Legacy(ReceiptWithBloom { - receipt: Receipt { - success: status_code == 1, - cumulative_gas_used: used_gas.to::(), - logs, - }, - bloom, - }), - TypedTransaction::EIP2930(_) => TypedReceipt::EIP2930(ReceiptWithBloom { - receipt: Receipt { - success: status_code == 1, - cumulative_gas_used: used_gas.to::(), - logs, - }, - bloom, - }), - TypedTransaction::EIP1559(_) => TypedReceipt::EIP1559(ReceiptWithBloom { - receipt: Receipt { - success: status_code == 1, - cumulative_gas_used: used_gas.to::(), - logs, - }, - bloom, - }), - TypedTransaction::EIP4844(_) => TypedReceipt::EIP4844(ReceiptWithBloom { - receipt: Receipt { - success: status_code == 1, - cumulative_gas_used: used_gas.to::(), - logs, - }, - bloom, - }), - TypedTransaction::Deposit(_) => TypedReceipt::Deposit(ReceiptWithBloom { - receipt: Receipt { - success: status_code == 1, - cumulative_gas_used: used_gas.to::(), - logs, - }, - bloom, + TypedTransaction::Legacy(_) => TypedReceipt::Legacy(receipt_with_bloom), + TypedTransaction::EIP2930(_) => TypedReceipt::EIP2930(receipt_with_bloom), + TypedTransaction::EIP1559(_) => TypedReceipt::EIP1559(receipt_with_bloom), + TypedTransaction::EIP4844(_) => TypedReceipt::EIP4844(receipt_with_bloom), + TypedTransaction::Deposit(tx) => TypedReceipt::Deposit(DepositReceipt { + inner: receipt_with_bloom, + deposit_nonce: Some(tx.nonce), + deposit_nonce_version: Some(1), }), } } @@ -121,7 +94,7 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> pub cfg_env: CfgEnvWithHandlerCfg, pub parent_hash: B256, /// Cumulative gas used by all executed transactions - pub gas_used: U256, + pub gas_used: u128, pub enable_steps_tracing: bool, } @@ -132,17 +105,17 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let mut transaction_infos = Vec::new(); let mut receipts = Vec::new(); let mut bloom = Bloom::default(); - let mut cumulative_gas_used = U256::ZERO; + let mut cumulative_gas_used: u128 = 0; let mut invalid = Vec::new(); let mut included = Vec::new(); - let gas_limit = self.block_env.gas_limit; + let gas_limit = self.block_env.gas_limit.to::(); let parent_hash = self.parent_hash; - let block_number = self.block_env.number; + let block_number = self.block_env.number.to::(); let difficulty = self.block_env.difficulty; let beneficiary = self.block_env.coinbase; let timestamp = self.block_env.timestamp.to::(); let base_fee = if (self.cfg_env.handler_cfg.spec_id as u8) >= (SpecId::LONDON as u8) { - Some(self.block_env.basefee) + Some(self.block_env.basefee.to::()) } else { None }; @@ -169,10 +142,9 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' continue } }; - let receipt = tx.create_receipt(); - cumulative_gas_used = cumulative_gas_used.saturating_add(receipt.gas_used()); + let receipt = tx.create_receipt(&mut cumulative_gas_used); let ExecutedTransaction { transaction, logs, out, traces, exit_reason: exit, .. } = tx; - logs_bloom(logs.clone(), &mut bloom); + build_logs_bloom(logs.clone(), &mut bloom); let contract_address = out.as_ref().and_then(|out| { if let Output::Create(_, contract_address) = out { @@ -183,15 +155,13 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' } }); - let transaction_index = transaction_infos.len() as u32; + let transaction_index = transaction_infos.len() as u64; let info = TransactionInfo { transaction_hash: transaction.hash(), transaction_index, from: *transaction.pending_transaction.sender(), to: transaction.pending_transaction.transaction.to(), contract_address, - logs, - logs_bloom: *receipt.logs_bloom(), traces, exit, out: match out { @@ -200,6 +170,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' _ => None, }, nonce: tx.nonce, + gas_used: tx.gas_used, }; transaction_infos.push(info); @@ -217,14 +188,14 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' receipts_root, logs_bloom: bloom, difficulty, - number: block_number.to::(), - gas_limit: gas_limit.to::(), - gas_used: cumulative_gas_used.to::(), + number: block_number, + gas_limit, + gas_used: cumulative_gas_used, timestamp, extra_data: Default::default(), mix_hash: Default::default(), nonce: Default::default(), - base_fee: base_fee.map(|b| b.to::()), + base_fee, }; let block = Block::new(partial_header, transactions.clone(), ommers); @@ -268,8 +239,8 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator }; let env = self.env_for(&transaction.pending_transaction); // check that we comply with the block's gas limit - let max_gas = self.gas_used.saturating_add(U256::from(env.tx.gas_limit)); - if max_gas > env.block.gas_limit { + let max_gas = self.gas_used.saturating_add(env.tx.gas_limit as u128); + if max_gas > env.block.gas_limit.to::() { return Some(TransactionExecutionOutcome::Exhausted(transaction)) } @@ -342,7 +313,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator trace!(target: "backend", ?exit_reason, ?gas_used, "[{:?}] executed with out={:?}", transaction.hash(), out); - self.gas_used = self.gas_used.saturating_add(U256::from(gas_used)); + self.gas_used = self.gas_used.saturating_add(gas_used as u128); trace!(target: "backend::executor", "transacted [{:?}], result: {:?} gas {}", transaction.hash(), exit_reason, gas_used); @@ -350,7 +321,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator transaction, exit_reason, out, - gas_used, + gas_used: gas_used as u128, logs: logs.unwrap_or_default(), traces: inspector .tracer @@ -366,7 +337,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator } /// Inserts all logs into the bloom -fn logs_bloom(logs: Vec, bloom: &mut Bloom) { +fn build_logs_bloom(logs: Vec, bloom: &mut Bloom) { for log in logs { bloom.accrue(BloomInput::Raw(&log.address[..])); for topic in log.topics() { diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 04ea0c70f5f15..3727740cd51a7 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -2,17 +2,18 @@ use crate::eth::{backend::db::Db, error::BlockchainError}; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256, U64}; -use alloy_providers::tmp::TempProvider; -use alloy_rpc_trace_types::{ - geth::{GethDebugTracingOptions, GethTrace}, - parity::LocalizedTransactionTrace as Trace, -}; +use alloy_provider::Provider; use alloy_rpc_types::{ request::TransactionRequest, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, - Filter, Log, Transaction, TransactionReceipt, + Filter, Log, Transaction, WithOtherFields, +}; +use alloy_rpc_types_trace::{ + geth::{GethDebugTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace as Trace, }; use alloy_transport::TransportError; +use anvil_core::eth::transaction::{convert_to_anvil_receipt, ReceiptResponse}; use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; use parking_lot::{ lock_api::{RwLockReadGuard, RwLockWriteGuard}, @@ -66,7 +67,7 @@ impl ClientFork { let chain_id = if let Some(chain_id) = override_chain_id { chain_id } else { - self.provider().get_chain_id().await?.to::() + self.provider().get_chain_id().await? }; self.config.write().chain_id = chain_id; } @@ -75,11 +76,11 @@ impl ClientFork { let block = provider.get_block(block_number, false).await?.ok_or(BlockchainError::BlockNotFound)?; let block_hash = block.header.hash.ok_or(BlockchainError::BlockNotFound)?; - let timestamp = block.header.timestamp.to::(); + let timestamp = block.header.timestamp; let base_fee = block.header.base_fee_per_gas; let total_difficulty = block.header.total_difficulty.unwrap_or_default(); - let number = block.header.number.ok_or(BlockchainError::BlockNotFound)?.to::(); + let number = block.header.number.ok_or(BlockchainError::BlockNotFound)?; self.config.write().update_block(number, block_hash, timestamp, base_fee, total_difficulty); self.clear_cached_storage(); @@ -116,7 +117,7 @@ impl ClientFork { self.config.read().total_difficulty } - pub fn base_fee(&self) -> Option { + pub fn base_fee(&self) -> Option { self.config.read().base_fee } @@ -147,7 +148,7 @@ impl ClientFork { /// Returns the fee history `eth_feeHistory` pub async fn fee_history( &self, - block_count: U256, + block_count: u64, newest_block: BlockNumber, reward_percentiles: &[f64], ) -> Result { @@ -167,11 +168,11 @@ impl ClientFork { /// Sends `eth_call` pub async fn call( &self, - request: &TransactionRequest, + request: &WithOtherFields, block: Option, ) -> Result { let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().call((*request).clone(), Some(block.into())).await?; + let res = self.provider().call(request, Some(block.into())).await?; Ok(res) } @@ -179,11 +180,11 @@ impl ClientFork { /// Sends `eth_call` pub async fn estimate_gas( &self, - request: &TransactionRequest, + request: &WithOtherFields, block: Option, - ) -> Result { + ) -> Result { let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().estimate_gas(request.clone(), Some(block.into())).await?; + let res = self.provider().estimate_gas(request, Some(block.into())).await?; Ok(res) } @@ -191,10 +192,10 @@ impl ClientFork { /// Sends `eth_createAccessList` pub async fn create_access_list( &self, - request: &TransactionRequest, + request: &WithOtherFields, block: Option, ) -> Result { - self.provider().create_access_list(request.clone(), block.map(|b| b.into())).await + self.provider().create_access_list(request, block.map(|b| b.into())).await } pub async fn storage_at( @@ -211,7 +212,7 @@ impl ClientFork { return Ok(logs); } - let logs = self.provider().get_logs(filter.clone()).await?; + let logs = self.provider().get_logs(filter).await?; let mut storage = self.storage_write(); storage.logs.insert(filter.clone(), logs.clone()); @@ -230,7 +231,7 @@ impl ClientFork { let block_id = BlockId::Number(blocknumber.into()); - let code = self.provider().get_code_at(address, Some(block_id)).await?; + let code = self.provider().get_code_at(address, block_id).await?; let mut storage = self.storage_write(); storage.code_at.insert((address, blocknumber), code.clone().0.into()); @@ -247,25 +248,21 @@ impl ClientFork { self.provider().get_balance(address, Some(blocknumber.into())).await } - pub async fn get_nonce( - &self, - address: Address, - blocknumber: u64, - ) -> Result { + pub async fn get_nonce(&self, address: Address, block: u64) -> Result { trace!(target: "backend::fork", "get_nonce={:?}", address); - self.provider().get_transaction_count(address, Some(blocknumber.into())).await + self.provider().get_transaction_count(address, Some(block.into())).await } pub async fn transaction_by_block_number_and_index( &self, number: u64, index: usize, - ) -> Result, TransportError> { + ) -> Result>, TransportError> { if let Some(block) = self.block_by_number(number).await? { match block.transactions { BlockTransactions::Full(txs) => { if let Some(tx) = txs.get(index) { - return Ok(Some(tx.clone())); + return Ok(Some(WithOtherFields::new(tx.clone()))); } } BlockTransactions::Hashes(hashes) => { @@ -284,12 +281,12 @@ impl ClientFork { &self, hash: B256, index: usize, - ) -> Result, TransportError> { + ) -> Result>, TransportError> { if let Some(block) = self.block_by_hash(hash).await? { match block.transactions { BlockTransactions::Full(txs) => { if let Some(tx) = txs.get(index) { - return Ok(Some(tx.clone())); + return Ok(Some(WithOtherFields::new(tx.clone()))); } } BlockTransactions::Hashes(hashes) => { @@ -307,7 +304,7 @@ impl ClientFork { pub async fn transaction_by_hash( &self, hash: B256, - ) -> Result, TransportError> { + ) -> Result>, TransportError> { trace!(target: "backend::fork", "transaction_by_hash={:?}", hash); if let tx @ Some(_) = self.storage_read().transactions.get(&hash).cloned() { return Ok(tx); @@ -367,12 +364,14 @@ impl ClientFork { pub async fn transaction_receipt( &self, hash: B256, - ) -> Result, TransportError> { + ) -> Result, BlockchainError> { if let Some(receipt) = self.storage_read().transaction_receipts.get(&hash).cloned() { return Ok(Some(receipt)); } if let Some(receipt) = self.provider().get_transaction_receipt(hash).await? { + let receipt = + convert_to_anvil_receipt(receipt).ok_or(BlockchainError::FailedToDecodeReceipt)?; let mut storage = self.storage_write(); storage.transaction_receipts.insert(hash, receipt.clone()); return Ok(Some(receipt)); @@ -384,7 +383,7 @@ impl ClientFork { pub async fn block_receipts( &self, number: u64, - ) -> Result>, TransportError> { + ) -> Result>, BlockchainError> { if let receipts @ Some(_) = self.storage_read().block_receipts.get(&number).cloned() { return Ok(receipts); } @@ -394,6 +393,16 @@ impl ClientFork { // this is being temporarily implemented in anvil. if self.predates_fork_inclusive(number) { let receipts = self.provider().get_block_receipts(BlockNumber::Number(number)).await?; + let receipts = receipts + .map(|r| { + r.into_iter() + .map(|r| { + convert_to_anvil_receipt(r) + .ok_or(BlockchainError::FailedToDecodeReceipt) + }) + .collect::, _>>() + }) + .transpose()?; if let Some(receipts) = receipts.clone() { let mut storage = self.storage_write(); @@ -469,14 +478,16 @@ impl ClientFork { ) -> Result, TransportError> { if let Some(block) = self.provider().get_block(block_id.into(), true).await? { let hash = block.header.hash.unwrap(); - let block_number = block.header.number.unwrap().to::(); + let block_number = block.header.number.unwrap(); let mut storage = self.storage_write(); // also insert all transactions let block_txs = match block.clone().transactions { BlockTransactions::Full(txs) => txs, _ => vec![], }; - storage.transactions.extend(block_txs.iter().map(|tx| (tx.hash, tx.clone()))); + storage + .transactions + .extend(block_txs.iter().map(|tx| (tx.hash, WithOtherFields::new(tx.clone())))); storage.hashes.insert(block_number, hash); storage.blocks.insert(hash, block.clone()); return Ok(Some(block)); @@ -520,14 +531,11 @@ impl ClientFork { let mut uncles = Vec::with_capacity(block.uncles.len()); for (uncle_idx, _) in block.uncles.iter().enumerate() { - let uncle = match self - .provider() - .get_uncle(block_number.to::().into(), U64::from(uncle_idx)) - .await? - { - Some(u) => u, - None => return Ok(None), - }; + let uncle = + match self.provider().get_uncle(block_number.into(), U64::from(uncle_idx)).await? { + Some(u) => u, + None => return Ok(None), + }; uncles.push(uncle); } self.storage_write().uncles.insert(block_hash, uncles.clone()); @@ -546,9 +554,10 @@ impl ClientFork { let mut transactions = Vec::with_capacity(block_txs_len); for tx in block.transactions.hashes() { if let Some(tx) = storage.transactions.get(tx).cloned() { - transactions.push(tx); + transactions.push(tx.inner); } } + // TODO: fix once blocks have generic transactions block.into_full_block(transactions) } } @@ -568,7 +577,7 @@ pub struct ClientForkConfig { /// The timestamp for the forked block pub timestamp: u64, /// The basefee of the forked block - pub base_fee: Option, + pub base_fee: Option, /// request timeout pub timeout: Duration, /// request retries for spurious networks @@ -611,7 +620,7 @@ impl ClientForkConfig { block_number: u64, block_hash: B256, timestamp: u64, - base_fee: Option, + base_fee: Option, total_difficulty: U256, ) { self.block_number = block_number; @@ -631,13 +640,13 @@ pub struct ForkedStorage { pub uncles: HashMap>, pub blocks: HashMap, pub hashes: HashMap, - pub transactions: HashMap, - pub transaction_receipts: HashMap, + pub transactions: HashMap>, + pub transaction_receipts: HashMap, pub transaction_traces: HashMap>, pub logs: HashMap>, pub geth_transaction_traces: HashMap, pub block_traces: HashMap>, - pub block_receipts: HashMap>, + pub block_receipts: HashMap>, pub code_at: HashMap<(Address, u64), Bytes>, } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index da49d8d35eecb..939913b842a81 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -34,25 +34,24 @@ use crate::{ NodeConfig, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; -use alloy_network::Sealable; -use alloy_primitives::{keccak256, Address, Bytes, TxHash, B256, B64, U128, U256, U64, U8}; -use alloy_rpc_trace_types::{ +use alloy_primitives::{keccak256, Address, Bytes, TxHash, B256, U256, U64}; +use alloy_rpc_types::{ + request::TransactionRequest, serde_helpers::JsonStorageKey, state::StateOverride, AccessList, + Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, + EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, + FilteredParams, Header as AlloyHeader, Log, Transaction, TransactionReceipt, WithOtherFields, +}; +use alloy_rpc_types_trace::{ geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, }; -use alloy_rpc_types::{ - request::TransactionRequest, state::StateOverride, AccessList, Block as AlloyBlock, BlockId, - BlockNumberOrTag as BlockNumber, EIP1186AccountProofResponse as AccountProof, - EIP1186StorageProof as StorageProof, Filter, FilteredParams, Header as AlloyHeader, - JsonStorageKey, Log, Transaction, TransactionReceipt, -}; use alloy_trie::{HashBuilder, Nibbles}; use anvil_core::{ eth::{ block::{Block, BlockInfo}, transaction::{ - MaybeImpersonatedTransaction, PendingTransaction, TransactionInfo, TypedReceipt, - TypedTransaction, + DepositReceipt, MaybeImpersonatedTransaction, PendingTransaction, ReceiptResponse, + TransactionInfo, TypedReceipt, TypedTransaction, }, utils::{alloy_to_revm_access_list, meets_eip155}, }, @@ -97,9 +96,9 @@ pub mod state; pub mod storage; // Gas per transaction not creating a contract. -pub const MIN_TRANSACTION_GAS: U256 = U256::from_limbs([21_000, 0, 0, 0]); +pub const MIN_TRANSACTION_GAS: u128 = 21000; // Gas per transaction creating a contract. -pub const MIN_CREATE_GAS: U256 = U256::from_limbs([53_000, 0, 0, 0]); +pub const MIN_CREATE_GAS: u128 = 53000; pub type State = foundry_evm::utils::StateChangeset; @@ -410,8 +409,8 @@ impl Backend { env.block = BlockEnv { number: rU256::from(fork_block_number), - timestamp: fork_block.header.timestamp, - gas_limit: fork_block.header.gas_limit, + timestamp: U256::from(fork_block.header.timestamp), + gas_limit: U256::from(fork_block.header.gas_limit), difficulty: fork_block.header.difficulty, prevrandao: Some(fork_block.header.mix_hash.unwrap_or_default()), // Keep previous `coinbase` and `basefee` value @@ -430,7 +429,7 @@ impl Backend { fork_block.header.base_fee_per_gas.unwrap_or_default(), ); - self.fees.set_base_fee(U256::from(next_block_base_fee)); + self.fees.set_base_fee(next_block_base_fee); // also reset the total difficulty self.blockchain.storage.write().total_difficulty = fork.total_difficulty(); @@ -523,8 +522,8 @@ impl Backend { } /// Returns balance of the given account. - pub async fn current_nonce(&self, address: Address) -> DatabaseResult { - Ok(U256::from(self.get_account(address).await?.nonce)) + pub async fn current_nonce(&self, address: Address) -> DatabaseResult { + Ok(self.get_account(address).await?.nonce) } /// Sets the coinbase address @@ -619,37 +618,37 @@ impl Backend { } /// Returns the block gas limit - pub fn gas_limit(&self) -> U256 { - self.env.read().block.gas_limit + pub fn gas_limit(&self) -> u128 { + self.env.read().block.gas_limit.to() } /// Sets the block gas limit - pub fn set_gas_limit(&self, gas_limit: U256) { - self.env.write().block.gas_limit = gas_limit; + pub fn set_gas_limit(&self, gas_limit: u128) { + self.env.write().block.gas_limit = U256::from(gas_limit); } /// Returns the current base fee - pub fn base_fee(&self) -> U256 { + pub fn base_fee(&self) -> u128 { self.fees.base_fee() } /// Sets the current basefee - pub fn set_base_fee(&self, basefee: U256) { + pub fn set_base_fee(&self, basefee: u128) { self.fees.set_base_fee(basefee) } /// Returns the current gas price - pub fn gas_price(&self) -> U256 { + pub fn gas_price(&self) -> u128 { self.fees.gas_price() } /// Returns the suggested fee cap - pub fn max_priority_fee_per_gas(&self) -> U256 { + pub fn max_priority_fee_per_gas(&self) -> u128 { self.fees.max_priority_fee_per_gas() } /// Sets the gas price - pub fn set_gas_price(&self, price: U256) { + pub fn set_gas_price(&self, price: u128) { self.fees.set_gas_price(price) } @@ -705,17 +704,17 @@ impl Backend { let block = self.block_by_hash(best_block_hash).await?.ok_or(BlockchainError::BlockNotFound)?; - let reset_time = block.header.timestamp.to::(); + let reset_time = block.header.timestamp; self.time.reset(reset_time); let mut env = self.env.write(); env.block = BlockEnv { number: rU256::from(num), - timestamp: block.header.timestamp, + timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, // ensures prevrandao is set prevrandao: Some(block.header.mix_hash.unwrap_or_default()), - gas_limit: block.header.gas_limit, + gas_limit: U256::from(block.header.gas_limit), // Keep previous `coinbase` and `basefee` value coinbase: env.block.coinbase, basefee: env.block.basefee, @@ -795,9 +794,9 @@ impl Backend { fn next_env(&self) -> EnvWithHandlerCfg { let mut env = self.env.read().clone(); // increase block number for this block - env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = self.base_fee(); - env.block.timestamp = rU256::from(self.time.current_call_timestamp()); + env.block.number = env.block.number.saturating_add(U256::from(1)); + env.block.basefee = U256::from(self.base_fee()); + env.block.timestamp = U256::from(self.time.current_call_timestamp()); env } @@ -864,7 +863,7 @@ impl Backend { block_env: env.block.clone(), cfg_env, parent_hash: storage.best_hash, - gas_used: U256::ZERO, + gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, }; @@ -903,7 +902,7 @@ impl Backend { // increase block number for this block env.block.number = env.block.number.saturating_add(rU256::from(1)); - env.block.basefee = current_base_fee; + env.block.basefee = U256::from(current_base_fee); env.block.timestamp = rU256::from(self.time.next_timestamp()); let best_hash = self.blockchain.storage.read().best_hash; @@ -923,13 +922,13 @@ impl Backend { block_env: env.block.clone(), cfg_env: CfgEnvWithHandlerCfg::new(env.cfg.clone(), env.handler_cfg), parent_hash: best_hash, - gas_used: U256::ZERO, + gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, }; let executed_tx = executor.execute(); // we also need to update the new blockhash in the db itself - let block_hash = executed_tx.block.block.header.hash(); + let block_hash = executed_tx.block.block.header.hash_slow(); db.insert_block_hash(U256::from(executed_tx.block.block.header.number), block_hash); (executed_tx, block_hash) @@ -972,7 +971,7 @@ impl Backend { if let Some(contract) = &info.contract_address { node_info!(" Contract created: {contract:?}"); } - node_info!(" Gas used: {}", receipt.gas_used()); + node_info!(" Gas used: {}", receipt.cumulative_gas_used()); if !info.exit.is_ok() { let r = RevertDecoder::new().decode( info.out.as_ref().map(|b| &b[..]).unwrap_or_default(), @@ -1018,16 +1017,16 @@ impl Backend { (outcome, header, block_hash) }; let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( - U256::from(header.gas_used), - U256::from(header.gas_limit), - U256::from(header.base_fee_per_gas.unwrap_or_default()), + header.gas_used, + header.gas_limit, + header.base_fee_per_gas.unwrap_or_default(), ); // notify all listeners self.notify_on_new_block(header, block_hash); // update next base fee - self.fees.set_base_fee(U256::from(next_block_base_fee)); + self.fees.set_base_fee(next_block_base_fee); outcome } @@ -1039,11 +1038,11 @@ impl Backend { /// Returns an error if the `block_number` is greater than the current height pub async fn call( &self, - request: TransactionRequest, + request: WithOtherFields, fee_details: FeeDetails, block_request: Option, overrides: Option, - ) -> Result<(InstructionResult, Option, u64, State), BlockchainError> { + ) -> Result<(InstructionResult, Option, u128, State), BlockchainError> { self.with_database_at(block_request, |state, block| { let block_number = block.number.to::(); let (exit, out, gas, state) = match overrides { @@ -1060,15 +1059,18 @@ impl Backend { fn build_call_env( &self, - request: TransactionRequest, + request: WithOtherFields, fee_details: FeeDetails, block_env: BlockEnv, ) -> EnvWithHandlerCfg { - let TransactionRequest { from, to, gas, value, input, nonce, access_list, .. } = request; + let WithOtherFields:: { + inner: TransactionRequest { from, to, gas, value, input, nonce, access_list, .. }, + .. + } = request; let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = fee_details; - let gas_limit = gas.unwrap_or(block_env.gas_limit); + let gas_limit = gas.unwrap_or(block_env.gas_limit.to()); let mut env = self.env.read().clone(); env.block = block_env; // we want to disable this in eth_call, since this is common practice used by other node @@ -1076,7 +1078,7 @@ impl Backend { env.cfg.disable_block_gas_limit = true; if let Some(base) = max_fee_per_gas { - env.block.basefee = base; + env.block.basefee = U256::from(base); } let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); @@ -1084,9 +1086,9 @@ impl Backend { env.tx = TxEnv { caller, - gas_limit: gas_limit.to::(), - gas_price, - gas_priority_fee: max_priority_fee_per_gas, + gas_limit: gas_limit as u64, + gas_price: U256::from(gas_price), + gas_priority_fee: max_priority_fee_per_gas.map(U256::from), transact_to: match to { Some(addr) => TransactTo::Call(addr), None => TransactTo::Create(CreateScheme::Create), @@ -1094,7 +1096,7 @@ impl Backend { value: value.unwrap_or_default(), data: input.into_input().unwrap_or_default(), chain_id: None, - nonce: nonce.map(|n| n.to::()), + nonce, access_list: alloy_to_revm_access_list(access_list.unwrap_or_default().0), ..Default::default() }; @@ -1111,10 +1113,10 @@ impl Backend { pub fn call_with_state( &self, state: D, - request: TransactionRequest, + request: WithOtherFields, fee_details: FeeDetails, block_env: BlockEnv, - ) -> Result<(InstructionResult, Option, u64, State), BlockchainError> + ) -> Result<(InstructionResult, Option, u128, State), BlockchainError> where D: DatabaseRef, { @@ -1133,12 +1135,12 @@ impl Backend { ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None), }; inspector.print_logs(); - Ok((exit_reason, out, gas_used, state)) + Ok((exit_reason, out, gas_used as u128, state)) } pub async fn call_with_tracing( &self, - request: TransactionRequest, + request: WithOtherFields, fee_details: FeeDetails, block_request: Option, opts: GethDefaultTracingOptions, @@ -1171,7 +1173,7 @@ impl Backend { pub fn build_access_list_with_state( &self, state: D, - request: TransactionRequest, + request: WithOtherFields, fee_details: FeeDetails, block_env: BlockEnv, ) -> Result<(InstructionResult, Option, u64, AccessList), BlockchainError> @@ -1244,53 +1246,43 @@ impl Backend { fn mined_logs_for_block(&self, filter: Filter, block: Block) -> Vec { let params = FilteredParams::new(Some(filter.clone())); let mut all_logs = Vec::new(); - let block_hash = block.header.hash(); + let block_hash = block.header.hash_slow(); let mut block_log_index = 0u32; - let transactions: Vec<_> = { - let storage = self.blockchain.storage.read(); - block - .transactions - .iter() - .filter_map(|tx| storage.transactions.get(&tx.hash()).map(|tx| tx.info.clone())) - .collect() - }; + let storage = self.blockchain.storage.read(); - for transaction in transactions { - let logs = transaction.logs.clone(); - let transaction_hash = transaction.transaction_hash; - - for log in logs.into_iter() { - let mut log = Log { - address: log.address, - topics: log.topics().to_vec(), - data: log.data.data, - block_hash: None, - block_number: None, - transaction_hash: None, - transaction_index: None, - log_index: None, - removed: false, - }; + for tx in block.transactions { + let Some(tx) = storage.transactions.get(&tx.hash()) else { + continue; + }; + let logs = tx.receipt.logs(); + let transaction_hash = tx.info.transaction_hash; + + for log in logs { let mut is_match: bool = true; if !filter.address.is_empty() && filter.has_topics() { - if !params.filter_address(&log.address) || !params.filter_topics(&log.topics) { + if !params.filter_address(&log.address) || !params.filter_topics(log.topics()) { is_match = false; } } else if !filter.address.is_empty() { if !params.filter_address(&log.address) { is_match = false; } - } else if filter.has_topics() && !params.filter_topics(&log.topics) { + } else if filter.has_topics() && !params.filter_topics(log.topics()) { is_match = false; } if is_match { - log.block_hash = Some(block_hash); - log.block_number = Some(block.header.number.to_alloy()); - log.transaction_hash = Some(transaction_hash); - log.transaction_index = Some(U256::from(transaction.transaction_index)); - log.log_index = Some(U256::from(block_log_index)); + let log = Log { + inner: log.clone(), + block_hash: Some(block_hash), + block_number: Some(block.header.number), + block_timestamp: Some(block.header.timestamp), + transaction_hash: Some(transaction_hash), + transaction_index: Some(tx.info.transaction_index), + log_index: Some(block_log_index as u64), + removed: false, + }; all_logs.push(log); } block_log_index += 1; @@ -1394,7 +1386,7 @@ impl Backend { pub(crate) async fn mined_transactions_by_block_number( &self, number: BlockNumber, - ) -> Option> { + ) -> Option>> { if let Some(block) = self.get_block(number) { return self.mined_transactions_in_block(&block); } @@ -1402,7 +1394,10 @@ impl Backend { } /// Returns all transactions given a block - pub(crate) fn mined_transactions_in_block(&self, block: &Block) -> Option> { + pub(crate) fn mined_transactions_in_block( + &self, + block: &Block, + ) -> Option>> { let mut transactions = Vec::with_capacity(block.transactions.len()); let base_fee = block.header.base_fee_per_gas; let storage = self.blockchain.storage.read(); @@ -1410,13 +1405,7 @@ impl Backend { let info = storage.transactions.get(&hash)?.info.clone(); let tx = block.transactions.get(info.transaction_index as usize)?.clone(); - let tx = transaction_build( - Some(hash), - tx, - Some(block), - Some(info), - base_fee.map(|f| f.to_alloy()), - ); + let tx = transaction_build(Some(hash), tx, Some(block), Some(info), base_fee); transactions.push(tx); } Some(transactions) @@ -1508,7 +1497,7 @@ impl Backend { let block = self.get_block(id)?; let transactions = self.mined_transactions_in_block(&block)?; let block = self.convert_block(block); - Some(block.into_full_block(transactions)) + Some(block.into_full_block(transactions.into_iter().map(|t| t.inner).collect())) } /// Takes a block as it's stored internally and returns the eth api conform block format @@ -1517,7 +1506,7 @@ impl Backend { let Block { header, transactions, .. } = block; - let hash = header.hash(); + let hash = header.hash_slow(); let Header { parent_hash, ommers_hash, @@ -1550,17 +1539,17 @@ impl Backend { state_root, transactions_root, receipts_root, - number: Some(number.to_alloy()), - gas_used: gas_used.to_alloy(), - gas_limit: gas_limit.to_alloy(), + number: Some(number), + gas_used, + gas_limit, extra_data: extra_data.0.into(), logs_bloom, - timestamp: U256::from(timestamp), + timestamp, total_difficulty: Some(self.total_difficulty()), difficulty, mix_hash: Some(mix_hash), - nonce: Some(B64::from(nonce)), - base_fee_per_gas: base_fee_per_gas.map(|f| f.to_alloy()), + nonce: Some(nonce), + base_fee_per_gas, withdrawals_root: None, blob_gas_used: None, excess_blob_gas: None, @@ -1594,8 +1583,7 @@ impl Backend { .ok_or(BlockchainError::BlockNotFound)? .header .number - .ok_or(BlockchainError::BlockNotFound)? - .to::(), + .ok_or(BlockchainError::BlockNotFound)?, BlockId::Number(num) => match num { BlockNumber::Latest | BlockNumber::Pending => self.best_number(), BlockNumber::Earliest => U64::ZERO.to::(), @@ -1640,11 +1628,11 @@ impl Backend { let block = BlockEnv { number: block.header.number.to_alloy(), coinbase: block.header.beneficiary, - timestamp: rU256::from(block.header.timestamp), + timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, prevrandao: Some(block.header.mix_hash), - basefee: block.header.base_fee_per_gas.unwrap_or_default().to_alloy(), - gas_limit: block.header.gas_limit.to_alloy(), + basefee: U256::from(block.header.base_fee_per_gas.unwrap_or_default()), + gas_limit: U256::from(block.header.gas_limit), ..Default::default() }; f(state, block) @@ -1663,7 +1651,7 @@ impl Backend { if let Some((state, block)) = self .get_block(block_number.to::()) - .and_then(|block| Some((states.get(&block.header.hash())?, block))) + .and_then(|block| Some((states.get(&block.header.hash_slow())?, block))) { let block = BlockEnv { number: block.header.number.to_alloy(), @@ -1671,8 +1659,8 @@ impl Backend { timestamp: rU256::from(block.header.timestamp), difficulty: block.header.difficulty, prevrandao: Some(block.header.mix_hash), - basefee: block.header.base_fee_per_gas.unwrap_or_default().to_alloy(), - gas_limit: block.header.gas_limit.to_alloy(), + basefee: U256::from(block.header.base_fee_per_gas.unwrap_or_default()), + gas_limit: U256::from(block.header.gas_limit), ..Default::default() }; return Ok(f(Box::new(state), block)); @@ -1692,7 +1680,7 @@ impl Backend { block.number = block_number; block.timestamp = rU256::from(fork.timestamp()); - block.basefee = fork.base_fee().unwrap_or_default(); + block.basefee = rU256::from(fork.base_fee().unwrap_or_default()); return Ok(f(Box::new(&gen_db), block)); } @@ -1789,7 +1777,7 @@ impl Backend { &self, address: Address, block_request: BlockRequest, - ) -> Result { + ) -> Result { if let BlockRequest::Pending(pool_transactions) = &block_request { if let Some(value) = get_pool_transactions_nonce(pool_transactions, address) { return Ok(value); @@ -1802,7 +1790,7 @@ impl Backend { self.with_database_at(Some(final_block_request), |db, _| { trace!(target: "backend", "get nonce for {:?}", address); - Ok(U256::from(db.basic_ref(address)?.unwrap_or_default().nonce)) + Ok(db.basic_ref(address)?.unwrap_or_default().nonce) }) .await? } @@ -1897,7 +1885,7 @@ impl Backend { pub async fn transaction_receipt( &self, hash: B256, - ) -> Result, BlockchainError> { + ) -> Result, BlockchainError> { if let Some(receipt) = self.mined_transaction_receipt(hash) { return Ok(Some(receipt.inner)); } @@ -1905,10 +1893,7 @@ impl Backend { if let Some(fork) = self.get_fork() { let receipt = fork.transaction_receipt(hash).await?; let number = self.convert_block_number( - receipt - .clone() - .and_then(|r| r.block_number) - .map(|n| BlockNumber::from(n.to::())), + receipt.clone().and_then(|r| r.block_number).map(BlockNumber::from), ); if fork.predates_fork_inclusive(number) { @@ -1932,7 +1917,7 @@ impl Backend { } /// Returns all transaction receipts of the block - pub fn mined_block_receipts(&self, id: impl Into) -> Option> { + pub fn mined_block_receipts(&self, id: impl Into) -> Option> { let mut receipts = Vec::new(); let block = self.get_block(id)?; @@ -1946,104 +1931,83 @@ impl Backend { /// Returns the transaction receipt for the given hash pub(crate) fn mined_transaction_receipt(&self, hash: B256) -> Option { - let MinedTransaction { info, receipt, block_hash, .. } = + let MinedTransaction { info, receipt: tx_receipt, block_hash, .. } = self.blockchain.get_transaction_by_hash(&hash)?; - let ReceiptWithBloom { receipt, bloom } = receipt.into(); - let Receipt { success, cumulative_gas_used: _, logs } = receipt; - let logs_bloom = bloom; - let index = info.transaction_index as usize; - let block = self.blockchain.get_block_by_hash(&block_hash)?; - - // TODO store cumulative gas used in receipt instead - let receipts = self.get_receipts(block.transactions.iter().map(|tx| tx.hash())); - - let mut cumulative_gas_used = U256::ZERO; - for receipt in receipts.iter().take(index + 1) { - cumulative_gas_used = cumulative_gas_used.saturating_add(receipt.gas_used()); - } - - // cumulative_gas_used = cumulative_gas_used.saturating_sub(gas_used); - - let mut cumulative_receipts = receipts; - cumulative_receipts.truncate(index + 1); - let transaction = block.transactions[index].clone(); - let transaction_type = transaction.transaction.r#type(); - let effective_gas_price = match transaction.transaction { - TypedTransaction::Legacy(t) => t.gas_price, - TypedTransaction::EIP2930(t) => t.gas_price, + TypedTransaction::Legacy(t) => t.tx().gas_price, + TypedTransaction::EIP2930(t) => t.tx().gas_price, TypedTransaction::EIP1559(t) => block .header .base_fee_per_gas - .map_or(self.base_fee().to::(), |b| b as u128) - .checked_add(t.max_priority_fee_per_gas) - .unwrap_or(u128::MAX), + .unwrap_or_else(|| self.base_fee()) + .saturating_add(t.tx().max_priority_fee_per_gas), TypedTransaction::EIP4844(t) => block .header .base_fee_per_gas - .map_or(self.base_fee().to::(), |b| b as u128) - .checked_add(t.tx().tx().max_priority_fee_per_gas) - .unwrap_or(u128::MAX), + .unwrap_or_else(|| self.base_fee()) + .saturating_add(t.tx().tx().max_priority_fee_per_gas), TypedTransaction::Deposit(_) => 0_u128, }; - let deposit_nonce = transaction_type.and_then(|x| (x == 0x7E).then_some(info.nonce)); + let receipts = self.get_receipts(block.transactions.iter().map(|tx| tx.hash())); + let next_log_index = receipts[..index].iter().map(|r| r.logs().len()).sum::(); + + let receipt = tx_receipt.as_receipt_with_bloom().receipt.clone(); + let receipt = Receipt { + status: receipt.status, + cumulative_gas_used: receipt.cumulative_gas_used, + logs: receipt + .logs + .into_iter() + .enumerate() + .map(|(index, log)| alloy_rpc_types::Log { + inner: log, + block_hash: Some(block_hash), + block_number: Some(block.header.number), + block_timestamp: Some(block.header.timestamp), + transaction_hash: Some(info.transaction_hash), + transaction_index: Some(info.transaction_index), + log_index: Some((next_log_index + index) as u64), + removed: false, + }) + .collect(), + }; + let receipt_with_bloom = + ReceiptWithBloom { receipt, logs_bloom: tx_receipt.as_receipt_with_bloom().logs_bloom }; + + let inner = match tx_receipt { + TypedReceipt::EIP1559(_) => TypedReceipt::EIP1559(receipt_with_bloom), + TypedReceipt::Legacy(_) => TypedReceipt::Legacy(receipt_with_bloom), + TypedReceipt::EIP2930(_) => TypedReceipt::EIP2930(receipt_with_bloom), + TypedReceipt::EIP4844(_) => TypedReceipt::EIP4844(receipt_with_bloom), + TypedReceipt::Deposit(r) => TypedReceipt::Deposit(DepositReceipt { + inner: receipt_with_bloom, + deposit_nonce: r.deposit_nonce, + deposit_nonce_version: r.deposit_nonce_version, + }), + }; - let mut inner = TransactionReceipt { - transaction_hash: Some(info.transaction_hash), - transaction_index: U64::from(info.transaction_index), + let inner = TransactionReceipt { + inner, + transaction_hash: info.transaction_hash, + transaction_index: info.transaction_index, + block_number: Some(block.header.number), + gas_used: info.gas_used, + contract_address: info.contract_address, + effective_gas_price, block_hash: Some(block_hash), - block_number: Some(U256::from(block.header.number)), from: info.from, to: info.to, - cumulative_gas_used, - gas_used: Some(cumulative_gas_used), - contract_address: info.contract_address, - logs: { - let mut pre_receipts_log_index = None; - if !cumulative_receipts.is_empty() { - cumulative_receipts.truncate(cumulative_receipts.len() - 1); - pre_receipts_log_index = Some( - cumulative_receipts.iter().map(|r| r.logs().len() as u32).sum::(), - ); - } - logs.iter() - .enumerate() - .map(|(i, log)| Log { - address: log.address, - topics: log.topics().to_vec(), - data: log.data.data.clone(), - block_hash: Some(block_hash), - block_number: Some(U256::from(block.header.number)), - transaction_hash: Some(info.transaction_hash), - transaction_index: Some(U256::from(info.transaction_index)), - log_index: Some(U256::from( - (pre_receipts_log_index.unwrap_or(0)) + i as u32, - )), - removed: false, - }) - .collect() - }, - status_code: Some(U64::from(success)), - state_root: None, - logs_bloom, - transaction_type: transaction_type.map(U8::from).unwrap_or_default(), - effective_gas_price: U128::from(effective_gas_price), + state_root: Some(block.header.state_root), blob_gas_price: None, blob_gas_used: None, - other: Default::default(), }; - inner.other.insert( - "depositNonce".to_string(), - serde_json::to_value(deposit_nonce).expect("Infallible"), - ); - Some(MinedTransactionReceipt { inner, out: info.out.map(|o| o.0.into()) }) } @@ -2051,7 +2015,7 @@ impl Backend { pub async fn block_receipts( &self, number: BlockNumber, - ) -> Result>, BlockchainError> { + ) -> Result>, BlockchainError> { if let Some(receipts) = self.mined_block_receipts(number) { return Ok(Some(receipts)); } @@ -2060,10 +2024,7 @@ impl Backend { let number = self.convert_block_number(Some(number)); if fork.predates_fork_inclusive(number) { - let receipts = fork - .block_receipts(number) - .await - .map_err(BlockchainError::AlloyForkProvider)?; + let receipts = fork.block_receipts(number).await?; return Ok(receipts); } @@ -2076,7 +2037,7 @@ impl Backend { &self, number: BlockNumber, index: Index, - ) -> Result, BlockchainError> { + ) -> Result>, BlockchainError> { if let Some(hash) = self.mined_block_by_number(number).and_then(|b| b.header.hash) { return Ok(self.mined_transaction_by_block_hash_and_index(hash, index)); } @@ -2095,7 +2056,7 @@ impl Backend { &self, hash: B256, index: Index, - ) -> Result, BlockchainError> { + ) -> Result>, BlockchainError> { if let tx @ Some(_) = self.mined_transaction_by_block_hash_and_index(hash, index) { return Ok(tx); } @@ -2111,7 +2072,7 @@ impl Backend { &self, block_hash: B256, index: Index, - ) -> Option { + ) -> Option> { let (info, block, tx) = { let storage = self.blockchain.storage.read(); let block = storage.blocks.get(&block_hash).cloned()?; @@ -2126,14 +2087,14 @@ impl Backend { tx, Some(&block), Some(info), - block.header.base_fee_per_gas.map(|g| g.to_alloy()), + block.header.base_fee_per_gas, )) } pub async fn transaction_by_hash( &self, hash: B256, - ) -> Result, BlockchainError> { + ) -> Result>, BlockchainError> { trace!(target: "backend", "transaction_by_hash={:?}", hash); if let tx @ Some(_) = self.mined_transaction_by_hash(hash) { return Ok(tx); @@ -2146,7 +2107,7 @@ impl Backend { Ok(None) } - fn mined_transaction_by_hash(&self, hash: B256) -> Option { + fn mined_transaction_by_hash(&self, hash: B256) -> Option> { let (info, block) = { let storage = self.blockchain.storage.read(); let MinedTransaction { info, block_hash, .. } = @@ -2161,7 +2122,7 @@ impl Backend { tx, Some(&block), Some(info), - block.header.base_fee_per_gas.map(|g| g.to_alloy()), + block.header.base_fee_per_gas, )) } @@ -2242,14 +2203,14 @@ impl Backend { fn get_pool_transactions_nonce( pool_transactions: &[Arc], address: Address, -) -> Option { +) -> Option { if let Some(highest_nonce) = pool_transactions .iter() .filter(|tx| *tx.pending_transaction.sender() == address) .map(|tx| tx.pending_transaction.nonce()) .max() { - let tx_count = highest_nonce.saturating_add(U256::from(1)); + let tx_count = highest_nonce.saturating_add(1); return Some(tx_count) } None @@ -2299,7 +2260,7 @@ impl TransactionValidator for Backend { } // Check gas limit, iff block gas limit is set. - if !env.cfg.disable_block_gas_limit && tx.gas_limit() > env.block.gas_limit { + if !env.cfg.disable_block_gas_limit && tx.gas_limit() > env.block.gas_limit.to() { warn!(target: "backend", "[{:?}] gas too high", tx.hash()); return Err(InvalidTransactionError::GasTooHigh(ErrDetail { detail: String::from("tx.gas_limit > env.block.gas_limit"), @@ -2309,15 +2270,14 @@ impl TransactionValidator for Backend { // check nonce let is_deposit_tx = matches!(&pending.transaction.transaction, TypedTransaction::Deposit(_)); - let nonce: u64 = - tx.nonce().try_into().map_err(|_| InvalidTransactionError::NonceMaxValue)?; + let nonce = tx.nonce(); if nonce < account.nonce && !is_deposit_tx { warn!(target: "backend", "[{:?}] nonce too low", tx.hash()); return Err(InvalidTransactionError::NonceTooLow); } if (env.handler_cfg.spec_id as u8) >= (SpecId::LONDON as u8) { - if tx.gas_price() < env.block.basefee && !is_deposit_tx { + if tx.gas_price() < env.block.basefee.to() && !is_deposit_tx { warn!(target: "backend", "max fee per gas={}, too low, block basefee={}",tx.gas_price(), env.block.basefee); return Err(InvalidTransactionError::FeeCapTooLow); } @@ -2335,12 +2295,12 @@ impl TransactionValidator for Backend { let max_cost = tx.max_cost(); let value = tx.value(); // check sufficient funds: `gas * price + value` - let req_funds = max_cost.checked_add(value).ok_or_else(|| { + let req_funds = max_cost.checked_add(value.to()).ok_or_else(|| { warn!(target: "backend", "[{:?}] cost too high", tx.hash()); InvalidTransactionError::InsufficientFunds })?; - if account.balance < req_funds { + if account.balance < U256::from(req_funds) { warn!(target: "backend", "[{:?}] insufficient allowance={}, required={} account={:?}", tx.hash(), account.balance, req_funds, *pending.sender()); return Err(InvalidTransactionError::InsufficientFunds); } @@ -2354,7 +2314,7 @@ impl TransactionValidator for Backend { env: &EnvWithHandlerCfg, ) -> Result<(), InvalidTransactionError> { self.validate_pool_transaction_for(tx, account, env)?; - if tx.nonce().to::() > account.nonce { + if tx.nonce() > account.nonce { return Err(InvalidTransactionError::NonceTooHigh); } Ok(()) @@ -2368,11 +2328,11 @@ pub fn transaction_build( eth_transaction: MaybeImpersonatedTransaction, block: Option<&Block>, info: Option, - base_fee: Option, -) -> Transaction { + base_fee: Option, +) -> WithOtherFields { let mut transaction: Transaction = eth_transaction.clone().into(); - if info.is_some() && transaction.transaction_type.unwrap_or(U64::ZERO).to::() == 0x7E { - transaction.nonce = U64::from(info.as_ref().unwrap().nonce); + if info.is_some() && transaction.transaction_type == Some(0x7E) { + transaction.nonce = info.as_ref().unwrap().nonce; } if eth_transaction.is_dynamic_fee() { @@ -2382,12 +2342,9 @@ pub fn transaction_build( } else { // if transaction is already mined, gas price is considered base fee + priority fee: the // effective gas price. - let base_fee = base_fee.unwrap_or(U256::ZERO); - let max_priority_fee_per_gas = - transaction.max_priority_fee_per_gas.map(|g| g.to::()).unwrap_or(U256::ZERO); - transaction.gas_price = Some( - base_fee.checked_add(max_priority_fee_per_gas).unwrap_or(U256::MAX).to::(), - ); + let base_fee = base_fee.unwrap_or(0); + let max_priority_fee_per_gas = transaction.max_priority_fee_per_gas.unwrap_or(0); + transaction.gas_price = Some(base_fee.saturating_add(max_priority_fee_per_gas)); } } else { transaction.max_fee_per_gas = None; @@ -2397,10 +2354,9 @@ pub fn transaction_build( transaction.block_hash = block.as_ref().map(|block| B256::from(keccak256(alloy_rlp::encode(&block.header)))); - transaction.block_number = block.as_ref().map(|block| U256::from(block.header.number)); + transaction.block_number = block.as_ref().map(|block| block.header.number); - transaction.transaction_index = - info.as_ref().map(|status| U256::from(status.transaction_index)); + transaction.transaction_index = info.as_ref().map(|info| info.transaction_index); // need to check if the signature of the transaction is impersonated, if so then we // can't recover the sender, instead we use the sender from the executed transaction and set the @@ -2422,7 +2378,7 @@ pub fn transaction_build( } transaction.to = info.as_ref().map_or(eth_transaction.to(), |status| status.to); - transaction + WithOtherFields::new(transaction) } /// Prove a storage key's existence or nonexistence in the account's storage diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 8d72b30f1299b..434490de575a1 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -6,18 +6,15 @@ use crate::eth::{ }, pool::transactions::PoolTransaction, }; -use alloy_network::Sealable; use alloy_primitives::{Bytes, TxHash, B256, U256, U64}; -use alloy_rpc_trace_types::{ +use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionInfo as RethTransactionInfo}; +use alloy_rpc_types_trace::{ geth::{DefaultFrame, GethDefaultTracingOptions}, parity::LocalizedTransactionTrace, }; -use alloy_rpc_types::{ - BlockId, BlockNumberOrTag, TransactionInfo as RethTransactionInfo, TransactionReceipt, -}; use anvil_core::eth::{ block::{Block, PartialHeader}, - transaction::{MaybeImpersonatedTransaction, TransactionInfo, TypedReceipt}, + transaction::{MaybeImpersonatedTransaction, ReceiptResponse, TransactionInfo, TypedReceipt}, }; use foundry_evm::{ revm::primitives::Env, @@ -228,18 +225,18 @@ pub struct BlockchainStorage { impl BlockchainStorage { /// Creates a new storage with a genesis block - pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { + pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { // create a dummy genesis block let partial_header = PartialHeader { timestamp, - base_fee: base_fee.map(|b| b.to::()), - gas_limit: env.block.gas_limit.to::(), + base_fee, + gas_limit: env.block.gas_limit.to::(), beneficiary: env.block.coinbase, difficulty: env.block.difficulty, ..Default::default() }; let block = Block::new::(partial_header, vec![], vec![]); - let genesis_hash = block.header.hash(); + let genesis_hash = block.header.hash_slow(); let best_hash = genesis_hash; let best_number: U64 = U64::from(0u64); @@ -339,7 +336,7 @@ pub struct Blockchain { impl Blockchain { /// Creates a new storage with a genesis block - pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { + pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { Self { storage: Arc::new(RwLock::new(BlockchainStorage::new(env, base_fee, timestamp))) } } @@ -408,7 +405,7 @@ impl MinedTransaction { ) .into_localized_transaction_traces(RethTransactionInfo { hash: Some(self.info.transaction_hash), - index: Some(self.info.transaction_index as u64), + index: Some(self.info.transaction_index), block_hash: Some(self.block_hash), block_number: Some(self.block_number), base_fee: None, @@ -418,7 +415,7 @@ impl MinedTransaction { pub fn geth_trace(&self, opts: GethDefaultTracingOptions) -> DefaultFrame { GethTraceBuilder::new(self.info.traces.clone(), TracingInspectorConfig::default_geth()) .geth_traces( - self.receipt.gas_used().to::(), + self.receipt.cumulative_gas_used() as u64, self.info.out.clone().unwrap_or_default().0.into(), opts, ) @@ -429,7 +426,7 @@ impl MinedTransaction { #[derive(Clone, Debug)] pub struct MinedTransactionReceipt { /// The actual json rpc receipt object - pub inner: TransactionReceipt, + pub inner: ReceiptResponse, /// Output data fo the transaction pub out: Option, } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 57436503965d8..9bd3d64a4beea 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -1,7 +1,7 @@ //! Aggregated error type for this module use crate::eth::pool::transactions::PoolTransaction; -use alloy_primitives::{Bytes, SignatureError as AlloySignatureError, U256}; +use alloy_primitives::{Bytes, SignatureError as AlloySignatureError}; use alloy_signer::Error as AlloySignerError; use alloy_transport::TransportError; use anvil_rpc::{ @@ -37,6 +37,8 @@ pub enum BlockchainError { FailedToDecodeSignedTransaction, #[error("Failed to decode transaction")] FailedToDecodeTransaction, + #[error("Failed to decode receipt")] + FailedToDecodeReceipt, #[error("Failed to decode state")] FailedToDecodeStateDump, #[error("Prevrandao not in th EVM's environment after merge")] @@ -180,7 +182,7 @@ pub enum InvalidTransactionError { FeeCapTooLow, /// Thrown during estimate if caller has insufficient funds to cover the tx. #[error("Out of gas: gas required exceeds allowance: {0:?}")] - BasicOutOfGas(U256), + BasicOutOfGas(u128), /// Thrown if executing a transaction failed during estimate/call #[error("execution reverted: {0:?}")] Revert(Option), @@ -348,6 +350,9 @@ impl ToRpcResponseResult for Result { BlockchainError::FailedToDecodeTransaction => { RpcError::invalid_params("Failed to decode transaction") } + BlockchainError::FailedToDecodeReceipt => { + RpcError::invalid_params("Failed to decode receipt") + } BlockchainError::FailedToDecodeStateDump => { RpcError::invalid_params("Failed to decode state dump") } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index ef2d38eca87fa..2b070b281d75f 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -2,7 +2,7 @@ use crate::eth::{ backend::{info::StorageInfo, notifications::NewBlockNotifications}, error::BlockchainError, }; -use alloy_primitives::{B256, U256}; +use alloy_primitives::B256; use anvil_core::eth::transaction::TypedTransaction; use foundry_evm::revm::primitives::SpecId; use futures::StreamExt; @@ -20,16 +20,16 @@ use std::{ pub const MAX_FEE_HISTORY_CACHE_SIZE: u64 = 2048u64; /// Initial base fee for EIP-1559 blocks. -pub const INITIAL_BASE_FEE: u64 = 1_000_000_000; +pub const INITIAL_BASE_FEE: u128 = 1_000_000_000; /// Initial default gas price for the first block -pub const INITIAL_GAS_PRICE: u64 = 1_875_000_000; +pub const INITIAL_GAS_PRICE: u128 = 1_875_000_000; /// Bounds the amount the base fee can change between blocks. -pub const BASE_FEE_CHANGE_DENOMINATOR: u64 = 8; +pub const BASE_FEE_CHANGE_DENOMINATOR: u128 = 8; /// Elasticity multiplier as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) -pub const EIP1559_ELASTICITY_MULTIPLIER: u64 = 2; +pub const EIP1559_ELASTICITY_MULTIPLIER: u128 = 2; pub fn default_elasticity() -> f64 { 1f64 / BASE_FEE_CHANGE_DENOMINATOR as f64 @@ -43,18 +43,18 @@ pub struct FeeManager { /// Tracks the base fee for the next block post London /// /// This value will be updated after a new block was mined - base_fee: Arc>, + base_fee: Arc>, /// The base price to use Pre London /// /// This will be constant value unless changed manually - gas_price: Arc>, + gas_price: Arc>, elasticity: Arc>, } // === impl FeeManager === impl FeeManager { - pub fn new(spec_id: SpecId, base_fee: U256, gas_price: U256) -> Self { + pub fn new(spec_id: SpecId, base_fee: u128, gas_price: u128) -> Self { Self { spec_id, base_fee: Arc::new(RwLock::new(base_fee)), @@ -73,7 +73,7 @@ impl FeeManager { } /// Calculates the current gas price - pub fn gas_price(&self) -> U256 { + pub fn gas_price(&self) -> u128 { if self.is_eip1559() { self.base_fee().saturating_add(self.suggested_priority_fee()) } else { @@ -82,33 +82,33 @@ impl FeeManager { } /// Suggested priority fee to add to the base fee - pub fn suggested_priority_fee(&self) -> U256 { - U256::from(1e9 as u64) + pub fn suggested_priority_fee(&self) -> u128 { + 1e9 as u128 } - pub fn base_fee(&self) -> U256 { + pub fn base_fee(&self) -> u128 { if self.is_eip1559() { *self.base_fee.read() } else { - U256::ZERO + 0 } } /// Returns the suggested fee cap /// /// Note: This currently returns a constant value: [Self::suggested_priority_fee] - pub fn max_priority_fee_per_gas(&self) -> U256 { + pub fn max_priority_fee_per_gas(&self) -> u128 { self.suggested_priority_fee() } /// Returns the current gas price - pub fn set_gas_price(&self, price: U256) { + pub fn set_gas_price(&self, price: u128) { let mut gas = self.gas_price.write(); *gas = price; } /// Returns the current base fee - pub fn set_base_fee(&self, fee: U256) { + pub fn set_base_fee(&self, fee: u128) { trace!(target: "backend::fees", "updated base fee {:?}", fee); let mut base = self.base_fee.write(); *base = fee; @@ -117,26 +117,22 @@ impl FeeManager { /// Calculates the base fee for the next block pub fn get_next_block_base_fee_per_gas( &self, - gas_used: U256, - gas_limit: U256, - last_fee_per_gas: U256, - ) -> u64 { + gas_used: u128, + gas_limit: u128, + last_fee_per_gas: u128, + ) -> u128 { // It's naturally impossible for base fee to be 0; // It means it was set by the user deliberately and therefore we treat it as a constant. // Therefore, we skip the base fee calculation altogether and we return 0. - if self.base_fee().is_zero() { + if self.base_fee() == 0 { return 0 } - calculate_next_block_base_fee( - gas_used.to::(), - gas_limit.to::(), - last_fee_per_gas.to::(), - ) + calculate_next_block_base_fee(gas_used, gas_limit, last_fee_per_gas) } } /// Calculate base fee for next block. [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) spec -pub fn calculate_next_block_base_fee(gas_used: u64, gas_limit: u64, base_fee: u64) -> u64 { +pub fn calculate_next_block_base_fee(gas_used: u128, gas_limit: u128, base_fee: u128) -> u128 { let gas_target = gas_limit / EIP1559_ELASTICITY_MULTIPLIER; if gas_used == gas_target { @@ -144,20 +140,15 @@ pub fn calculate_next_block_base_fee(gas_used: u64, gas_limit: u64, base_fee: u6 } if gas_used > gas_target { let gas_used_delta = gas_used - gas_target; - let base_fee_delta = std::cmp::max( - 1, - base_fee as u128 * gas_used_delta as u128 / - gas_target as u128 / - BASE_FEE_CHANGE_DENOMINATOR as u128, - ); - base_fee + (base_fee_delta as u64) + let base_fee_delta = + std::cmp::max(1, base_fee * gas_used_delta / gas_target / BASE_FEE_CHANGE_DENOMINATOR); + base_fee + base_fee_delta } else { let gas_used_delta = gas_target - gas_used; - let base_fee_per_gas_delta = base_fee as u128 * gas_used_delta as u128 / - gas_target as u128 / - BASE_FEE_CHANGE_DENOMINATOR as u128; + let base_fee_per_gas_delta = + base_fee * gas_used_delta / gas_target / BASE_FEE_CHANGE_DENOMINATOR; - base_fee.saturating_sub(base_fee_per_gas_delta as u64) + base_fee.saturating_sub(base_fee_per_gas_delta) } } @@ -222,11 +213,7 @@ impl FeeHistoryService { let mut block_number: Option = None; let base_fee = self.fees.base_fee(); - let mut item = FeeHistoryCacheItem { - base_fee: base_fee.to::(), - gas_used_ratio: 0f64, - rewards: Vec::new(), - }; + let mut item = FeeHistoryCacheItem { base_fee, gas_used_ratio: 0f64, rewards: Vec::new() }; let current_block = self.storage_info.block(hash); let current_receipts = self.storage_info.receipts(hash); @@ -241,38 +228,34 @@ impl FeeHistoryService { item.gas_used_ratio = gas_used / (gas_target * elasticity); // extract useful tx info (gas_used, effective_reward) - let mut transactions: Vec<(u64, u64)> = receipts + let mut transactions: Vec<(u128, u128)> = receipts .iter() .enumerate() .map(|(i, receipt)| { - let gas_used = receipt.gas_used(); + let gas_used = receipt.cumulative_gas_used(); let effective_reward = match block.transactions.get(i).map(|tx| &tx.transaction) { Some(TypedTransaction::Legacy(t)) => { - U256::from(t.gas_price).saturating_sub(base_fee).to::() + t.tx().gas_price.saturating_sub(base_fee) } Some(TypedTransaction::EIP2930(t)) => { - U256::from(t.gas_price).saturating_sub(base_fee).to::() - } - Some(TypedTransaction::EIP1559(t)) => { - U256::from(t.max_priority_fee_per_gas) - .min(U256::from(t.max_fee_per_gas).saturating_sub(base_fee)) - .to::() + t.tx().gas_price.saturating_sub(base_fee) } + Some(TypedTransaction::EIP1559(t)) => t + .tx() + .max_priority_fee_per_gas + .min(t.tx().max_fee_per_gas.saturating_sub(base_fee)), // TODO: This probably needs to be extended to extract 4844 info. - Some(TypedTransaction::EIP4844(t)) => { - U256::from(t.tx().tx().max_priority_fee_per_gas) - .min( - U256::from(t.tx().tx().max_fee_per_gas) - .saturating_sub(base_fee), - ) - .to::() - } + Some(TypedTransaction::EIP4844(t)) => t + .tx() + .tx() + .max_priority_fee_per_gas + .min(t.tx().tx().max_fee_per_gas.saturating_sub(base_fee)), Some(TypedTransaction::Deposit(_)) => 0, None => 0, }; - (gas_used.to::(), effective_reward) + (gas_used, effective_reward) }) .collect(); @@ -283,7 +266,7 @@ impl FeeHistoryService { item.rewards = reward_percentiles .into_iter() .filter_map(|p| { - let target_gas = (p * gas_used / 100f64) as u64; + let target_gas = (p * gas_used / 100f64) as u128; let mut sum_gas = 0; for (gas_used, effective_reward) in transactions.iter().cloned() { sum_gas += gas_used; @@ -341,26 +324,22 @@ pub type FeeHistoryCache = Arc>>; /// A single item in the whole fee history cache #[derive(Clone, Debug)] pub struct FeeHistoryCacheItem { - pub base_fee: u64, + pub base_fee: u128, pub gas_used_ratio: f64, - pub rewards: Vec, + pub rewards: Vec, } #[derive(Clone, Default)] pub struct FeeDetails { - pub gas_price: Option, - pub max_fee_per_gas: Option, - pub max_priority_fee_per_gas: Option, + pub gas_price: Option, + pub max_fee_per_gas: Option, + pub max_priority_fee_per_gas: Option, } impl FeeDetails { /// All values zero pub fn zero() -> Self { - Self { - gas_price: Some(U256::ZERO), - max_fee_per_gas: Some(U256::ZERO), - max_priority_fee_per_gas: Some(U256::ZERO), - } + Self { gas_price: Some(0), max_fee_per_gas: Some(0), max_priority_fee_per_gas: Some(0) } } /// If neither `gas_price` nor `max_fee_per_gas` is `Some`, this will set both to `0` @@ -368,23 +347,23 @@ impl FeeDetails { let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = self; let no_fees = gas_price.is_none() && max_fee_per_gas.is_none(); - let gas_price = if no_fees { Some(U256::ZERO) } else { gas_price }; - let max_fee_per_gas = if no_fees { Some(U256::ZERO) } else { max_fee_per_gas }; + let gas_price = if no_fees { Some(0) } else { gas_price }; + let max_fee_per_gas = if no_fees { Some(0) } else { max_fee_per_gas }; Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas } } /// Turns this type into a tuple - pub fn split(self) -> (Option, Option, Option) { + pub fn split(self) -> (Option, Option, Option) { let Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = self; (gas_price, max_fee_per_gas, max_priority_fee_per_gas) } /// Creates a new instance from the request's gas related values pub fn new( - request_gas_price: Option, - request_max_fee: Option, - request_priority: Option, + request_gas_price: Option, + request_max_fee: Option, + request_priority: Option, ) -> Result { match (request_gas_price, request_max_fee, request_priority) { (gas_price, None, None) => { diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index ac092f36c7f74..636140f13ffea 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -7,11 +7,13 @@ use crate::eth::{ macros::node_info, EthApi, }; -use alloy_primitives::{Address, Bytes, B256, U256, U64}; -use alloy_rpc_trace_types::parity::{ +use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_rpc_types::{ + Block, BlockId, BlockNumberOrTag as BlockNumber, Transaction, WithOtherFields, +}; +use alloy_rpc_types_trace::parity::{ Action, CallAction, CreateAction, CreateOutput, RewardAction, TraceOutput, }; -use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag as BlockNumber, Transaction}; use itertools::Itertools; impl EthApi { @@ -68,7 +70,7 @@ impl EthApi { node_info!("ots_getTransactionError"); if let Some(receipt) = self.backend.mined_transaction_receipt(hash) { - if receipt.inner.status_code == Some(U64::ZERO) { + if !receipt.inner.inner.as_receipt_with_bloom().receipt.status { return Ok(receipt.out.map(|b| b.0.into())) } } @@ -238,7 +240,7 @@ impl EthApi { &self, address: Address, nonce: U256, - ) -> Result> { + ) -> Result>> { node_info!("ots_getTransactionBySenderAndNonce"); let from = self.get_fork().map(|f| f.block_number() + 1).unwrap_or_default(); diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index ff1f99ce5d136..d7e75c02c7e4f 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -3,8 +3,9 @@ use crate::eth::{ error::{BlockchainError, Result}, }; use alloy_primitives::{Address, Bytes, B256, U256 as rU256, U256}; -use alloy_rpc_trace_types::parity::{Action, CallType, LocalizedTransactionTrace}; -use alloy_rpc_types::{Block, BlockTransactions, Transaction, TransactionReceipt}; +use alloy_rpc_types::{Block, BlockTransactions, Transaction, WithOtherFields}; +use alloy_rpc_types_trace::parity::{Action, CallType, LocalizedTransactionTrace}; +use anvil_core::eth::transaction::ReceiptResponse; use foundry_evm::{revm::interpreter::InstructionResult, traces::CallKind}; use futures::future::join_all; use serde::Serialize; @@ -40,7 +41,7 @@ pub struct Issuance { #[derive(Clone, Serialize, Debug)] pub struct OtsBlockTransactions { pub fullblock: OtsBlock, - pub receipts: Vec, + pub receipts: Vec, } /// Patched Receipt struct, to include the additional `timestamp` field expected by Otterscan @@ -48,7 +49,7 @@ pub struct OtsBlockTransactions { #[serde(rename_all = "camelCase")] pub struct OtsTransactionReceipt { #[serde(flatten)] - receipt: TransactionReceipt, + receipt: ReceiptResponse, timestamp: u64, } @@ -63,7 +64,7 @@ pub struct OtsContractCreator { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct OtsSearchTransactions { - pub txs: Vec, + pub txs: Vec>, pub receipts: Vec, pub first_page: bool, pub last_page: bool, @@ -132,22 +133,22 @@ impl OtsBlockDetails { block_txs.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); // fetch all receipts - let receipts: Vec = join_all(receipts_futs) + let receipts = join_all(receipts_futs) .await .into_iter() .map(|r| match r { Ok(Some(r)) => Ok(r), _ => Err(BlockchainError::DataUnavailable), }) - .collect::>()?; + .collect::>>()?; - let total_fees = receipts.iter().fold(U256::ZERO, |acc, receipt| { - acc + receipt.gas_used.unwrap() * (U256::from(receipt.effective_gas_price)) - }); + let total_fees = receipts + .iter() + .fold(0, |acc, receipt| acc + receipt.gas_used * receipt.effective_gas_price); Ok(Self { block: block.into(), - total_fees, + total_fees: U256::from(total_fees), // issuance has no meaningful value in anvil's backend. just default to 0 issuance: Default::default(), }) @@ -198,7 +199,7 @@ impl OtsBlockTransactions { let receipt_futs = block_txs.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); - let receipts: Vec = join_all(receipt_futs) + let receipts = join_all(receipt_futs) .await .into_iter() .map(|r| match r { @@ -225,7 +226,7 @@ impl OtsSearchTransactions { ) -> Result { let txs_futs = hashes.iter().map(|hash| async { backend.transaction_by_hash(*hash).await }); - let txs: Vec = join_all(txs_futs) + let txs: Vec<_> = join_all(txs_futs) .await .into_iter() .map(|t| match t { @@ -237,11 +238,8 @@ impl OtsSearchTransactions { join_all(hashes.iter().map(|hash| async { match backend.transaction_receipt(*hash).await { Ok(Some(receipt)) => { - let timestamp = backend - .get_block(receipt.block_number.unwrap().to::()) - .unwrap() - .header - .timestamp; + let timestamp = + backend.get_block(receipt.block_number.unwrap()).unwrap().header.timestamp; Ok(OtsTransactionReceipt { receipt, timestamp }) } Ok(None) => Err(BlockchainError::DataUnavailable), diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 312bde4818bff..a88bc369cd94c 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -1,5 +1,5 @@ use crate::eth::{error::PoolError, util::hex_fmt_many}; -use alloy_primitives::{Address, TxHash, U256}; +use alloy_primitives::{Address, TxHash}; use anvil_core::eth::transaction::{PendingTransaction, TypedTransaction}; use parking_lot::RwLock; use std::{ @@ -65,10 +65,10 @@ impl FromStr for TransactionOrder { /// Metric value for the priority of a transaction. /// -/// The `TransactionPriority` determines the ordering of two transactions that have all their +/// The `TransactionPriority` determines the ordering of two transactions that have all their /// markers satisfied. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] -pub struct TransactionPriority(pub U256); +pub struct TransactionPriority(pub u128); /// Internal Transaction type #[derive(Clone, PartialEq, Eq)] @@ -92,7 +92,7 @@ impl PoolTransaction { } /// Returns the gas pric of this transaction - pub fn gas_price(&self) -> U256 { + pub fn gas_price(&self) -> u128 { self.pending_transaction.transaction.gas_price() } } @@ -679,7 +679,7 @@ impl ReadyTransaction { &self.transaction.transaction.provides } - pub fn gas_price(&self) -> U256 { + pub fn gas_price(&self) -> u128 { self.transaction.transaction.gas_price() } } diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index 4886d96f04685..949a517fa7690 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -1,8 +1,10 @@ use crate::eth::error::BlockchainError; +use alloy_consensus::{SignableTransaction, Signed}; use alloy_dyn_abi::TypedData; -use alloy_network::{Signed, Transaction}; -use alloy_primitives::{Address, Signature, B256, U256}; -use alloy_signer::{LocalWallet, Signer as AlloySigner, SignerSync as AlloySignerSync}; +use alloy_network::TxSignerSync; +use alloy_primitives::{Address, Signature, B256}; +use alloy_signer::Signer as AlloySigner; +use alloy_signer_wallet::LocalWallet; use anvil_core::eth::transaction::{ optimism::{DepositTransaction, DepositTransactionRequest}, TypedTransaction, TypedTransactionRequest, @@ -84,17 +86,13 @@ impl Signer for DevSigner { // typed data. signer.set_chain_id(None); - Ok(signer - .sign_hash( - payload.eip712_signing_hash().map_err(|_| BlockchainError::NoSignerAvailable)?, - ) - .await?) + Ok(signer.sign_dynamic_typed_data(payload).await?) } async fn sign_hash(&self, address: Address, hash: B256) -> Result { let signer = self.accounts.get(&address).ok_or(BlockchainError::NoSignerAvailable)?; - Ok(signer.sign_hash(hash).await?) + Ok(signer.sign_hash(&hash).await?) } fn sign_transaction( @@ -160,7 +158,7 @@ pub fn build_typed_transaction( source_hash, mint, is_system_tx, - nonce: U256::ZERO, + nonce: 0, }) } }; diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index afc600a3b34de..11a860bc385b4 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -17,7 +17,7 @@ use crate::{ tasks::TaskManager, }; use alloy_primitives::{Address, U256}; -use alloy_signer::{LocalWallet, Signer as AlloySigner}; +use alloy_signer_wallet::LocalWallet; use eth::backend::fork::ClientFork; use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; @@ -311,7 +311,7 @@ impl NodeHandle { } /// Default gas price for all txs - pub fn gas_price(&self) -> U256 { + pub fn gas_price(&self) -> u128 { self.config.get_gas_price() } diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index b0b8b33bbecd2..a063ee6697b2f 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -2,10 +2,8 @@ use crate::{ eth::{backend::notifications::NewBlockNotifications, error::to_rpc_result}, StorageInfo, }; -use alloy_consensus::ReceiptWithBloom; -use alloy_network::Sealable; -use alloy_primitives::{Log, TxHash, B256, U256}; -use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log as AlloyLog}; +use alloy_primitives::{TxHash, B256}; +use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log}; use anvil_core::eth::{block::Block, subscription::SubscriptionId, transaction::TypedReceipt}; use anvil_rpc::{request::Version, response::ResponseResult}; use futures::{channel::mpsc::Receiver, ready, Stream, StreamExt}; @@ -22,7 +20,7 @@ pub struct LogsSubscription { pub blocks: NewBlockNotifications, pub storage: StorageInfo, pub filter: FilteredParams, - pub queued: VecDeque, + pub queued: VecDeque, pub id: SubscriptionId, } @@ -145,13 +143,14 @@ impl Stream for EthSubscription { } /// Returns all the logs that match the given filter -pub fn filter_logs( - block: Block, - receipts: Vec, - filter: &FilteredParams, -) -> Vec { +pub fn filter_logs(block: Block, receipts: Vec, filter: &FilteredParams) -> Vec { /// Determines whether to add this log - fn add_log(block_hash: B256, l: &Log, block: &Block, params: &FilteredParams) -> bool { + fn add_log( + block_hash: B256, + l: &alloy_primitives::Log, + block: &Block, + params: &FilteredParams, + ) -> bool { if params.filter.is_some() { let block_number = block.header.number; if !params.filter_block_range(block_number) || @@ -165,29 +164,22 @@ pub fn filter_logs( true } - let block_hash = block.header.hash(); + let block_hash = block.header.hash_slow(); let mut logs = vec![]; let mut log_index: u32 = 0; for (receipt_index, receipt) in receipts.into_iter().enumerate() { - let receipt: ReceiptWithBloom = receipt.into(); - let receipt_logs = receipt.receipt.logs; - let transaction_hash: Option = if !receipt_logs.is_empty() { - Some(block.transactions[receipt_index].hash()) - } else { - None - }; - for log in receipt_logs.into_iter() { - if add_log(block_hash, &log, &block, filter) { - logs.push(AlloyLog { - address: log.address, - topics: log.topics().to_vec(), - data: log.data.data, + let transaction_hash = block.transactions[receipt_index].hash(); + for log in receipt.logs() { + if add_log(block_hash, log, &block, filter) { + logs.push(Log { + inner: log.clone(), block_hash: Some(block_hash), - block_number: Some(U256::from(block.header.number)), - transaction_hash, - transaction_index: Some(U256::from(receipt_index)), - log_index: Some(U256::from(log_index)), + block_number: Some(block.header.number), + transaction_hash: Some(transaction_hash), + transaction_index: Some(receipt_index as u64), + log_index: Some(log_index as u64), removed: false, + block_timestamp: Some(block.header.timestamp), }); } log_index += 1; diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index 429f8d5d32919..e42b0437ca68a 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -1,12 +1,13 @@ //! Task management support use crate::{shutdown::Shutdown, tasks::block_listener::BlockListener, EthApi}; +use alloy_network::AnyNetwork; +use alloy_primitives::B256; +use alloy_provider::Provider; +use alloy_rpc_types::Block; +use alloy_transport::Transport; use anvil_core::types::Forking; -use ethers::{ - prelude::Middleware, - providers::{JsonRpcClient, PubsubClient}, - types::{Block, H256}, -}; +use futures::StreamExt; use std::{fmt, future::Future}; use tokio::{runtime::Handle, task::JoinHandle}; @@ -51,32 +52,33 @@ impl TaskManager { /// block /// /// ``` + /// use alloy_network::Ethereum; + /// use alloy_provider::RootProvider; /// use anvil::{spawn, NodeConfig}; - /// use ethers::providers::Provider; - /// use std::sync::Arc; + /// /// # async fn t() { /// let endpoint = "http://...."; /// let (api, handle) = spawn(NodeConfig::default().with_eth_rpc_url(Some(endpoint))).await; /// - /// let provider = Arc::new(Provider::try_from(endpoint).unwrap()); + /// let provider = RootProvider::connect_builtin(endpoint).await.unwrap(); /// /// handle.task_manager().spawn_reset_on_new_polled_blocks(provider, api); /// # } /// ``` - pub fn spawn_reset_on_new_polled_blocks

(&self, provider: P, api: EthApi) + pub fn spawn_reset_on_new_polled_blocks(&self, provider: P, api: EthApi) where - P: Middleware + Clone + Unpin + 'static + Send + Sync, -

::Provider: JsonRpcClient, + P: Provider + Clone + Unpin + 'static, + T: Transport + Clone, { self.spawn_block_poll_listener(provider.clone(), move |hash| { let provider = provider.clone(); let api = api.clone(); async move { - if let Ok(Some(block)) = provider.get_block(hash).await { + if let Ok(Some(block)) = provider.get_block(hash.into(), false).await { let _ = api .anvil_reset(Some(Forking { json_rpc_url: None, - block_number: block.number.map(|b| b.as_u64()), + block_number: block.header.number, })) .await; } @@ -87,16 +89,21 @@ impl TaskManager { /// Spawns a new [`BlockListener`] task that listens for new blocks (poll-based) See also /// [`Provider::watch_blocks`] and executes the future the `task_factory` returns for the new /// block hash - pub fn spawn_block_poll_listener(&self, provider: P, task_factory: F) + pub fn spawn_block_poll_listener(&self, provider: P, task_factory: F) where - P: Middleware + Unpin + 'static, -

::Provider: JsonRpcClient, - F: Fn(H256) -> Fut + Unpin + Send + Sync + 'static, + P: Provider + 'static, + T: Transport + Clone, + F: Fn(B256) -> Fut + Unpin + Send + Sync + 'static, Fut: Future + Send, { let shutdown = self.on_shutdown.clone(); self.spawn(async move { - let blocks = provider.watch_blocks().await.unwrap(); + let blocks = provider + .watch_blocks() + .await + .unwrap() + .into_stream() + .flat_map(futures::stream::iter); BlockListener::new(shutdown, blocks, task_factory).await; }); } @@ -105,21 +112,23 @@ impl TaskManager { /// block /// /// ``` + /// use alloy_network::Ethereum; + /// use alloy_provider::RootProvider; /// use anvil::{spawn, NodeConfig}; - /// use ethers::providers::Provider; + /// /// # async fn t() { /// let (api, handle) = spawn(NodeConfig::default().with_eth_rpc_url(Some("http://...."))).await; /// - /// let provider = Provider::connect("ws://...").await.unwrap(); + /// let provider = RootProvider::connect_builtin("ws://...").await.unwrap(); /// /// handle.task_manager().spawn_reset_on_subscribed_blocks(provider, api); /// /// # } /// ``` - pub fn spawn_reset_on_subscribed_blocks

(&self, provider: P, api: EthApi) + pub fn spawn_reset_on_subscribed_blocks(&self, provider: P, api: EthApi) where - P: Middleware + Unpin + 'static + Send + Sync, -

::Provider: PubsubClient, + P: Provider + 'static, + T: Transport + Clone, { self.spawn_block_subscription(provider, move |block| { let api = api.clone(); @@ -127,7 +136,7 @@ impl TaskManager { let _ = api .anvil_reset(Some(Forking { json_rpc_url: None, - block_number: block.number.map(|b| b.as_u64()), + block_number: block.header.number, })) .await; } @@ -137,16 +146,16 @@ impl TaskManager { /// Spawns a new [`BlockListener`] task that listens for new blocks (via subscription) See also /// [`Provider::subscribe_blocks()`] and executes the future the `task_factory` returns for the /// new block hash - pub fn spawn_block_subscription(&self, provider: P, task_factory: F) + pub fn spawn_block_subscription(&self, provider: P, task_factory: F) where - P: Middleware + Unpin + 'static, -

::Provider: PubsubClient, - F: Fn(Block) -> Fut + Unpin + Send + Sync + 'static, + P: Provider + 'static, + T: Transport + Clone, + F: Fn(Block) -> Fut + Unpin + Send + Sync + 'static, Fut: Future + Send, { let shutdown = self.on_shutdown.clone(); self.spawn(async move { - let blocks = provider.subscribe_blocks().await.unwrap(); + let blocks = provider.subscribe_blocks().await.unwrap().into_stream(); BlockListener::new(shutdown, blocks, task_factory).await; }); } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 2f37f9b56d108..d2826b9ed0a7a 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -44,7 +44,7 @@ async fn can_set_block_gas_limit() { api.mine_one().await; let latest_block = api.block_by_number(alloy_rpc_types::BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert_eq!(block_gas_limit.to_alloy(), latest_block.header.gas_limit); + assert_eq!(block_gas_limit.as_u128(), latest_block.header.gas_limit); } // Ref @@ -445,10 +445,10 @@ async fn can_get_node_info() { hard_fork: SpecId::CANCUN, transaction_order: "fees".to_owned(), environment: NodeEnvironment { - base_fee: U256::from_str("0x3b9aca00").unwrap().to_alloy(), + base_fee: alloy_primitives::U256::from_str("0x3b9aca00").unwrap().to(), chain_id: 0x7a69, - gas_limit: U256::from_str("0x1c9c380").unwrap().to_alloy(), - gas_price: U256::from_str("0x77359400").unwrap().to_alloy(), + gas_limit: alloy_primitives::U256::from_str("0x1c9c380").unwrap().to(), + gas_price: alloy_primitives::U256::from_str("0x77359400").unwrap().to(), }, fork_config: NodeForkConfig { fork_url: None, @@ -616,16 +616,16 @@ async fn test_fork_revert_call_latest_block_timestamp() { ); assert_eq!( - multicall.get_current_block_timestamp().await.unwrap(), - latest_block.header.timestamp.to_ethers() + multicall.get_current_block_timestamp().await.unwrap().as_u64(), + latest_block.header.timestamp ); assert_eq!( multicall.get_current_block_difficulty().await.unwrap(), latest_block.header.difficulty.to_ethers() ); assert_eq!( - multicall.get_current_block_gas_limit().await.unwrap(), - latest_block.header.gas_limit.to_ethers() + multicall.get_current_block_gas_limit().await.unwrap().as_u128(), + latest_block.header.gas_limit ); assert_eq!( multicall.get_current_block_coinbase().await.unwrap(), diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 216e9581389b9..acf9a0f9834a3 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -5,12 +5,12 @@ use crate::{ utils::ethers_http_provider, }; use alloy_primitives::{Address as rAddress, B256, U256 as rU256}; -use alloy_providers::tmp::TempProvider; +use alloy_provider::Provider; use alloy_rpc_types::{ request::{TransactionInput as CallInput, TransactionRequest as CallRequest}, state::{AccountOverride, StateOverride}, + WithOtherFields, }; -use alloy_signer::Signer as AlloySigner; use anvil::{ eth::{api::CLIENT_VERSION, EthApi}, spawn, NodeConfig, CHAIN_ID, @@ -213,7 +213,7 @@ async fn can_call_on_pending_block() { .call() .await .unwrap(); - assert_eq!(block.header.timestamp, block_timestamp.to_alloy()); + assert_eq!(block.header.timestamp, block_timestamp.as_u64()); let block_gas_limit = pending_contract .get_current_block_gas_limit() @@ -221,7 +221,7 @@ async fn can_call_on_pending_block() { .call() .await .unwrap(); - assert_eq!(block.header.gas_limit, block_gas_limit.to_alloy()); + assert_eq!(block.header.gas_limit, block_gas_limit.as_u128()); let block_coinbase = pending_contract .get_current_block_coinbase() @@ -244,11 +244,11 @@ where { let result = api .call( - CallRequest { + WithOtherFields::new(CallRequest { input: CallInput::maybe_input(call.tx.data().cloned().map(|b| b.0.into())), to: Some(to.to_alloy()), ..Default::default() - }, + }), None, Some(overrides), ) diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 39946383e105d..5f94a95aefba1 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -5,12 +5,11 @@ use crate::{ utils::{self, ethers_http_provider}, }; use alloy_primitives::{address, U256 as rU256}; -use alloy_providers::tmp::TempProvider; +use alloy_provider::Provider as AlloyProvider; use alloy_rpc_types::{ request::{TransactionInput, TransactionRequest as CallRequest}, - BlockNumberOrTag, + BlockNumberOrTag, WithOtherFields, }; -use alloy_signer::Signer as AlloySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; use ethers::{ @@ -23,7 +22,7 @@ use ethers::{ }, }; use foundry_common::{ - provider::ethers::get_http_provider, + provider::alloy::get_http_provider, rpc, rpc::next_http_rpc_endpoint, types::{ToAlloy, ToEthers}, @@ -290,7 +289,7 @@ async fn test_fork_snapshotting() { let provider = handle.http_provider(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + rU256::from(1)); + assert_eq!(nonce, initial_nonce + 1); let to_balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); @@ -329,7 +328,7 @@ async fn test_fork_snapshotting_repeated() { let _ = tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + rU256::from(1)); + assert_eq!(nonce, initial_nonce + 1); let to_balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); @@ -383,7 +382,7 @@ async fn test_fork_snapshotting_blocks() { assert_eq!(block_number_after, block_number + 1); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + rU256::from(1)); + assert_eq!(nonce, initial_nonce + 1); let to_balance = provider.get_balance(to, None).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); @@ -397,12 +396,12 @@ async fn test_fork_snapshotting_blocks() { // repeat transaction let _ = tx_provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + rU256::from(1)); + assert_eq!(nonce, initial_nonce + 1); // revert again: nothing to revert since snapshot gone assert!(!api.evm_revert(snapshot).await.unwrap()); let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert_eq!(nonce, initial_nonce + rU256::from(1)); + assert_eq!(nonce, initial_nonce + 1); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); } @@ -468,8 +467,8 @@ async fn can_reset_properly() { let (origin_api, origin_handle) = spawn(NodeConfig::test()).await; let account = origin_handle.dev_accounts().next().unwrap(); let origin_provider = origin_handle.http_provider(); - let origin_nonce = rU256::from(1u64); - origin_api.anvil_set_nonce(account, origin_nonce).await.unwrap(); + let origin_nonce = 1u64; + origin_api.anvil_set_nonce(account, rU256::from(origin_nonce)).await.unwrap(); assert_eq!(origin_nonce, origin_provider.get_transaction_count(account, None).await.unwrap()); @@ -486,10 +485,7 @@ async fn can_reset_properly() { let tx = fork_tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); // nonce incremented by 1 - assert_eq!( - origin_nonce + rU256::from(1), - fork_provider.get_transaction_count(account, None).await.unwrap() - ); + assert_eq!(origin_nonce + 1, fork_provider.get_transaction_count(account, None).await.unwrap()); // resetting to origin state fork_api.anvil_reset(Some(Forking::default())).await.unwrap(); @@ -754,13 +750,19 @@ async fn test_reset_fork_on_new_blocks() { let anvil_provider = ethers_http_provider(&handle.http_endpoint()); let endpoint = next_http_rpc_endpoint(); - let provider = Arc::new(get_http_provider(&endpoint).interval(Duration::from_secs(2))); + let provider = Arc::new(get_http_provider(&endpoint)); let current_block = anvil_provider.get_block_number().await.unwrap(); handle.task_manager().spawn_reset_on_new_polled_blocks(provider.clone(), api); - let mut stream = provider.watch_blocks().await.unwrap(); + let mut stream = provider + .watch_blocks() + .await + .unwrap() + .with_poll_interval(Duration::from_secs(2)) + .into_stream() + .flat_map(futures::stream::iter); // the http watcher may fetch multiple blocks at once, so we set a timeout here to offset edge // cases where the stream immediately returns a block tokio::time::sleep(Chain::Mainnet.average_blocktime_hint().unwrap()).await; @@ -788,11 +790,11 @@ async fn test_fork_call() { let res1 = api .call( - CallRequest { + WithOtherFields::new(CallRequest { to: Some(to.to_alloy()), input: input.to_alloy().into(), ..Default::default() - }, + }), None, None, ) @@ -810,7 +812,7 @@ async fn test_fork_block_timestamp() { api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert!(initial_block.header.timestamp.to::() < latest_block.header.timestamp.to::()); + assert!(initial_block.header.timestamp < latest_block.header.timestamp); } #[tokio::test(flavor = "multi_thread")] @@ -821,14 +823,11 @@ async fn test_fork_snapshot_block_timestamp() { api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); let initial_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); api.evm_revert(snapshot_id).await.unwrap(); - api.evm_set_next_block_timestamp(initial_block.header.timestamp.to::()).unwrap(); + api.evm_set_next_block_timestamp(initial_block.header.timestamp).unwrap(); api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert_eq!( - initial_block.header.timestamp.to::(), - latest_block.header.timestamp.to::() - ); + assert_eq!(initial_block.header.timestamp, latest_block.header.timestamp); } #[tokio::test(flavor = "multi_thread")] @@ -1092,7 +1091,7 @@ async fn test_fork_reset_basefee() { let latest = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); // basefee of +1 block: - assert_eq!(latest.header.base_fee_per_gas.unwrap(), rU256::from(59455969592u64)); + assert_eq!(latest.header.base_fee_per_gas.unwrap(), 59455969592u128); // now reset to block 18835000 -1 api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(18835000u64 - 1) })) @@ -1103,7 +1102,7 @@ async fn test_fork_reset_basefee() { let latest = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); // basefee of the forked block: - assert_eq!(latest.header.base_fee_per_gas.unwrap(), rU256::from(59017001138u64)); + assert_eq!(latest.header.base_fee_per_gas.unwrap(), 59017001138u128); } // @@ -1180,11 +1179,11 @@ async fn test_fork_execution_reverted() { let resp = api .call( - CallRequest { + WithOtherFields::new(CallRequest { to: Some(address!("Fd6CC4F251eaE6d02f9F7B41D1e80464D3d2F377")), input: TransactionInput::new("0x8f283b3c".as_bytes().into()), ..Default::default() - }, + }), Some(target.into()), None, ) diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index 4f6098bfb2df0..e2d194340c57b 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -1,7 +1,6 @@ //! Gas related tests use crate::utils::ethers_http_provider; -use alloy_primitives::U256; use anvil::{eth::fees::INITIAL_BASE_FEE, spawn, NodeConfig}; use ethers::{ prelude::Middleware, @@ -10,16 +9,13 @@ use ethers::{ TransactionRequest, }, }; -use foundry_common::types::ToAlloy; -const GAS_TRANSFER: u64 = 21_000u64; +const GAS_TRANSFER: u128 = 21_000; #[tokio::test(flavor = "multi_thread")] async fn test_basefee_full_block() { let (_api, handle) = spawn( - NodeConfig::test() - .with_base_fee(Some(INITIAL_BASE_FEE.to_alloy())) - .with_gas_limit(Some(GAS_TRANSFER.to_alloy())), + NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE)).with_gas_limit(Some(GAS_TRANSFER)), ) .await; let provider = ethers_http_provider(&handle.http_endpoint()); @@ -34,15 +30,15 @@ async fn test_basefee_full_block() { assert!(next_base_fee > base_fee); // max increase, full block - assert_eq!(next_base_fee.as_u64(), INITIAL_BASE_FEE + 125_000_000); + assert_eq!(next_base_fee.as_u128(), INITIAL_BASE_FEE + 125_000_000); } #[tokio::test(flavor = "multi_thread")] async fn test_basefee_half_block() { let (_api, handle) = spawn( NodeConfig::test() - .with_base_fee(Some(INITIAL_BASE_FEE.to_alloy())) - .with_gas_limit(Some(GAS_TRANSFER.to_alloy() * U256::from(2))), + .with_base_fee(Some(INITIAL_BASE_FEE)) + .with_gas_limit(Some(GAS_TRANSFER * 2)), ) .await; let provider = ethers_http_provider(&handle.http_endpoint()); @@ -54,12 +50,11 @@ async fn test_basefee_half_block() { provider.get_block(BlockNumber::Latest).await.unwrap().unwrap().base_fee_per_gas.unwrap(); // unchanged, half block - assert_eq!(next_base_fee.as_u64(), INITIAL_BASE_FEE); + assert_eq!(next_base_fee.as_u128(), INITIAL_BASE_FEE); } #[tokio::test(flavor = "multi_thread")] async fn test_basefee_empty_block() { - let (api, handle) = - spawn(NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE.to_alloy()))).await; + let (api, handle) = spawn(NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE))).await; let provider = ethers_http_provider(&handle.http_endpoint()); let tx = TransactionRequest::new().to(Address::random()).value(1337u64); @@ -79,8 +74,8 @@ async fn test_basefee_empty_block() { #[tokio::test(flavor = "multi_thread")] async fn test_respect_base_fee() { - let base_fee = 50u64; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee.to_alloy()))).await; + let base_fee = 50u128; + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; let provider = ethers_http_provider(&handle.http_endpoint()); let mut tx = TypedTransaction::default(); tx.set_value(100u64); @@ -99,8 +94,8 @@ async fn test_respect_base_fee() { #[tokio::test(flavor = "multi_thread")] async fn test_tip_above_fee_cap() { - let base_fee = 50u64; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee.to_alloy()))).await; + let base_fee = 50u128; + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; let provider = ethers_http_provider(&handle.http_endpoint()); let tx = TypedTransaction::Eip1559( Eip1559TransactionRequest::new() diff --git a/crates/anvil/tests/it/genesis.rs b/crates/anvil/tests/it/genesis.rs index f5f5fec9cc7db..0b243db3edb9c 100644 --- a/crates/anvil/tests/it/genesis.rs +++ b/crates/anvil/tests/it/genesis.rs @@ -3,8 +3,8 @@ use std::str::FromStr; use alloy_genesis::Genesis; -use alloy_primitives::{Address, U256, U64}; -use alloy_providers::tmp::TempProvider; +use alloy_primitives::{Address, U256}; +use alloy_provider::Provider; use anvil::{spawn, NodeConfig}; #[tokio::test(flavor = "multi_thread")] @@ -41,7 +41,7 @@ async fn can_apply_genesis() { let provider = handle.http_provider(); - assert_eq!(provider.get_chain_id().await.unwrap(), U64::from(19763u64)); + assert_eq!(provider.get_chain_id().await.unwrap(), 19763u64); let addr: Address = Address::from_str("71562b71999873db5b286df957af199ec94617f7").unwrap(); let balance = provider.get_balance(addr, None).await.unwrap(); diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 6bbd987a84763..4c344264034c2 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -7,7 +7,6 @@ use crate::{ }; use alloy_primitives::U256 as rU256; use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions}; -use alloy_signer::Signer as AlloySigner; use anvil::{ eth::otterscan::types::{ OtsInternalOperation, OtsInternalOperationType, OtsTrace, OtsTraceType, @@ -33,8 +32,8 @@ async fn can_call_erigon_get_header_by_number() { let res0 = api.erigon_get_header_by_number(0.into()).await.unwrap().unwrap(); let res1 = api.erigon_get_header_by_number(1.into()).await.unwrap().unwrap(); - assert_eq!(res0.header.number, Some(rU256::from(0))); - assert_eq!(res1.header.number, Some(rU256::from(1))); + assert_eq!(res0.header.number, Some(0)); + assert_eq!(res1.header.number, Some(1)); } #[tokio::test(flavor = "multi_thread")] @@ -487,7 +486,7 @@ async fn can_call_ots_get_block_transactions() { result.receipts.iter().enumerate().for_each(|(i, receipt)| { let expected = hashes.pop_front(); - assert_eq!(expected, receipt.transaction_hash.map(|h| h.to_ethers())); + assert_eq!(expected, Some(receipt.transaction_hash.to_ethers())); assert_eq!( expected.map(|h| h.to_alloy()), result.fullblock.block.transactions.hashes().nth(i).copied(), @@ -528,7 +527,7 @@ async fn can_call_ots_search_transactions_before() { assert_eq!(hashes.pop(), Some(tx.hash.to_ethers())); }); - block = result.txs.last().unwrap().block_number.unwrap().to::() - 1; + block = result.txs.last().unwrap().block_number.unwrap() - 1; } assert!(hashes.is_empty()); @@ -564,7 +563,7 @@ async fn can_call_ots_search_transactions_after() { assert_eq!(hashes.pop_back(), Some(tx.hash.to_ethers())); }); - block = result.txs.last().unwrap().block_number.unwrap().to::() + 1; + block = result.txs.last().unwrap().block_number.unwrap() + 1; } assert!(hashes.is_empty()); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 18a74e1a9d8ae..46c059374c602 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -2,13 +2,12 @@ use crate::{ abi::*, utils::{ethers_http_provider, ethers_ws_provider}, }; -use alloy_primitives::U256 as rU256; +use alloy_primitives::{Bytes, U256 as rU256}; use alloy_rpc_types::{ request::TransactionRequest as AlloyTransactionRequest, state::{AccountOverride, StateOverride}, - BlockNumberOrTag, + BlockNumberOrTag, WithOtherFields, }; -use alloy_signer::Signer as AlloySigner; use anvil::{spawn, Hardfork, NodeConfig}; use ethers::{ abi::ethereum_types::BigEndianHash, @@ -21,7 +20,7 @@ use ethers::{ Address, BlockNumber, Transaction, TransactionReceipt, H256, U256, }, }; -use foundry_common::types::{to_call_request_from_tx_request, ToAlloy, ToEthers}; +use foundry_common::types::{ToAlloy, ToEthers}; use futures::{future::join_all, FutureExt, StreamExt}; use std::{collections::HashSet, sync::Arc, time::Duration}; use tokio::time::timeout; @@ -434,11 +433,11 @@ async fn get_blocktimestamp_works() { api.block_by_number(alloy_rpc_types::BlockNumberOrTag::Latest).await.unwrap().unwrap(); let timestamp = contract.get_current_block_timestamp().call().await.unwrap(); - assert_eq!(timestamp, latest_block.header.timestamp.to_ethers()); + assert_eq!(timestamp.as_u64(), latest_block.header.timestamp); // repeat call same result let timestamp = contract.get_current_block_timestamp().call().await.unwrap(); - assert_eq!(timestamp, latest_block.header.timestamp.to_ethers()); + assert_eq!(timestamp.as_u64(), latest_block.header.timestamp); // mock timestamp let next_timestamp = timestamp.as_u64() + 1337; @@ -962,9 +961,12 @@ async fn estimates_gas_on_pending_by_default() { let tx = TransactionRequest::new().from(sender).to(recipient).value(1e18 as u64); client.send_transaction(tx, None).await.unwrap(); - let tx = - TransactionRequest::new().from(recipient).to(sender).value(1e10 as u64).data(vec![0x42]); - api.estimate_gas(to_call_request_from_tx_request(tx), None, None).await.unwrap(); + let tx = AlloyTransactionRequest::default() + .from(recipient.to_alloy()) + .to(Some(sender.to_alloy())) + .value(rU256::from(1e10)) + .input(Bytes::from(vec![0x42]).into()); + api.estimate_gas(WithOtherFields::new(tx), None, None).await.unwrap(); } #[tokio::test(flavor = "multi_thread")] @@ -975,11 +977,13 @@ async fn test_estimate_gas() { let sender = wallet.address(); let recipient = Address::random(); - let tx = - TransactionRequest::new().from(recipient).to(sender).value(1e10 as u64).data(vec![0x42]); + let tx = AlloyTransactionRequest::default() + .from(recipient.to_alloy()) + .to(Some(sender.to_alloy())) + .value(rU256::from(1e10)) + .input(Bytes::from(vec![0x42]).into()); // Expect the gas estimation to fail due to insufficient funds. - let error_result = - api.estimate_gas(to_call_request_from_tx_request(tx.clone()), None, None).await; + let error_result = api.estimate_gas(WithOtherFields::new(tx.clone()), None, None).await; assert!(error_result.is_err(), "Expected an error due to insufficient funds"); let error_message = error_result.unwrap_err().to_string(); @@ -998,15 +1002,12 @@ async fn test_estimate_gas() { // Estimate gas with state override implying sufficient funds. let gas_estimate = api - .estimate_gas(to_call_request_from_tx_request(tx), None, Some(state_override)) + .estimate_gas(WithOtherFields::new(tx), None, Some(state_override)) .await .expect("Failed to estimate gas with state override"); // Assert the gas estimate meets the expected minimum. - assert!( - gas_estimate >= alloy_primitives::U256::from(21000), - "Gas estimate is lower than expected minimum" - ); + assert!(gas_estimate >= rU256::from(21000), "Gas estimate is lower than expected minimum"); } #[tokio::test(flavor = "multi_thread")] @@ -1032,8 +1033,7 @@ async fn test_reject_gas_too_low() { // #[tokio::test(flavor = "multi_thread")] async fn can_call_with_high_gas_limit() { - let (_api, handle) = - spawn(NodeConfig::test().with_gas_limit(Some(U256::from(100_000_000).to_alloy()))).await; + let (_api, handle) = spawn(NodeConfig::test().with_gas_limit(Some(100_000_000))).await; let provider = ethers_http_provider(&handle.http_endpoint()); let wallet = handle.dev_wallets().next().unwrap().to_ethers(); @@ -1094,8 +1094,8 @@ async fn can_mine_multiple_in_block() { }; // broadcast it via the eth_sendTransaction API - let first = api.send_transaction(tx.clone()).await.unwrap(); - let second = api.send_transaction(tx.clone()).await.unwrap(); + let first = api.send_transaction(WithOtherFields::new(tx.clone())).await.unwrap(); + let second = api.send_transaction(WithOtherFields::new(tx.clone())).await.unwrap(); api.anvil_mine(Some(rU256::from(1)), Some(rU256::ZERO)).await.unwrap(); diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index c2073f5617f7d..ce0c4d6a43877 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -1,6 +1,6 @@ //! general eth api tests with websocket provider -use alloy_providers::tmp::TempProvider; +use alloy_provider::Provider; use anvil::{spawn, NodeConfig}; use ethers::types::U256; use foundry_common::types::ToAlloy; diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 5361b3dea8b5c..6b6dbae5197c3 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -15,7 +15,11 @@ name = "cast" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # lib @@ -30,12 +34,20 @@ alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-rlp.workspace = true -alloy-providers.workspace = true +alloy-provider = { workspace = true, features = ["pubsub"] } +alloy-transport.workspace = true alloy-rpc-types.workspace = true +alloy-json-rpc.workspace = true alloy-signer.workspace = true +alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } +alloy-contract.workspace = true +alloy-consensus = { workspace = true, features = ["serde"] } +alloy-network.workspace = true +alloy-sol-types.workspace = true +alloy-chains.workspace = true ethers-core.workspace = true -ethers-providers.workspace = true +ethers-contract.workspace = true chrono.workspace = true evm-disassembler.workspace = true @@ -48,17 +60,11 @@ serde_json.workspace = true serde.workspace = true # aws -rusoto_core = { version = "0.48", default-features = false } -rusoto_kms = { version = "0.48", default-features = false } +aws-sdk-kms = { version = "1", default-features = false } # bin foundry-cli.workspace = true -ethers-contract.workspace = true -ethers-middleware.workspace = true -ethers-signers.workspace = true -eth-keystore = "0.5" - clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" @@ -86,7 +92,7 @@ criterion = "0.5" [features] default = ["rustls"] rustls = ["foundry-cli/rustls", "foundry-wallets/rustls"] -openssl = ["foundry-cli/openssl", "foundry-wallets/openssl"] +openssl = ["foundry-cli/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 2ac5a0488468d..ed572628de66f 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -1,13 +1,16 @@ -use cast::{Cast, TxBuilder}; +use alloy_network::{AnyNetwork, TransactionBuilder}; +use alloy_primitives::Address; +use alloy_provider::Provider; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_transport::Transport; +use cast::Cast; use clap::Parser; -use ethers_core::types::{BlockId, NameOrAddress}; -use ethers_providers::Middleware; -use eyre::{Result, WrapErr}; +use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils, + utils::{self, parse_function_args}, }; -use foundry_common::types::ToEthers; +use foundry_common::ens::NameOrAddress; use foundry_config::{Chain, Config}; use std::str::FromStr; @@ -62,18 +65,37 @@ impl AccessListArgs { let provider = utils::get_provider(&config)?; let chain = utils::get_chain(config.chain, &provider).await?; let sender = eth.wallet.sender().await; - - access_list(&provider, sender.to_ethers(), to, sig, args, data, tx, chain, block, to_json) - .await?; + let etherscan_api_key = config.get_etherscan_api_key(Some(chain)); + + let to = match to { + Some(to) => Some(to.resolve(&provider).await?), + None => None, + }; + + access_list( + &provider, + etherscan_api_key.as_deref(), + sender, + to, + sig, + args, + data, + tx, + chain, + block, + to_json, + ) + .await?; Ok(()) } } #[allow(clippy::too_many_arguments)] -async fn access_list, T: Into>( - provider: M, - from: F, - to: Option, +async fn access_list, T: Transport + Clone>( + provider: P, + etherscan_api_key: Option<&str>, + from: Address, + to: Option

, sig: Option, args: Vec, data: Option, @@ -81,32 +103,35 @@ async fn access_list, T: Into, to_json: bool, -) -> Result<()> -where - M::Error: 'static, -{ - let mut builder = TxBuilder::new(&provider, from, to, chain, tx.legacy).await?; - builder - .gas(tx.gas_limit) - .gas_price(tx.gas_price) - .priority_gas_price(tx.priority_gas_price) - .nonce(tx.nonce); - - builder.value(tx.value); - - if let Some(sig) = sig { - builder.set_args(sig.as_str(), args).await?; +) -> Result<()> { + let mut req = WithOtherFields::::default() + .with_to(to.into()) + .with_from(from) + .with_value(tx.value.unwrap_or_default()) + .with_chain_id(chain.id()); + + if let Some(gas_limit) = tx.gas_limit { + req.set_gas_limit(gas_limit.to()); } - if let Some(data) = data { - // Note: `sig+args` and `data` are mutually exclusive - builder.set_data(hex::decode(data).wrap_err("Expected hex encoded function data")?); + + if let Some(nonce) = tx.nonce { + req.set_nonce(nonce.to()); } - let builder_output = builder.peek(); + let data = if let Some(sig) = sig { + parse_function_args(&sig, args, to, chain, &provider, etherscan_api_key).await?.0 + } else if let Some(data) = data { + // Note: `sig+args` and `data` are mutually exclusive + hex::decode(data)? + } else { + Vec::new() + }; + + req.set_input(data.into()); let cast = Cast::new(&provider); - let access_list: String = cast.access_list(builder_output, block, to_json).await?; + let access_list: String = cast.access_list(&req, block, to_json).await?; println!("{}", access_list); diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index ece090bf74ae2..eeb09d5c0442e 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,23 +1,19 @@ +use alloy_network::TransactionBuilder; use alloy_primitives::U256; -use cast::{Cast, TxBuilder}; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use cast::Cast; use clap::Parser; -use ethers_core::types::{BlockId, NameOrAddress}; -use eyre::{Result, WrapErr}; +use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils::{self, handle_traces, parse_ether_value, TraceResult}, -}; -use foundry_common::{ - runtime_client::RuntimeClient, - types::{ToAlloy, ToEthers}, + utils::{self, handle_traces, parse_ether_value, parse_function_args, TraceResult}, }; +use foundry_common::ens::NameOrAddress; use foundry_compilers::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{executors::TracingExecutor, opts::EvmOpts}; use std::str::FromStr; -type Provider = ethers_providers::Provider; - /// CLI arguments for `cast call`. #[derive(Debug, Parser)] pub struct CallArgs { @@ -118,19 +114,43 @@ impl CallArgs { let provider = utils::get_provider(&config)?; let chain = utils::get_chain(config.chain, &provider).await?; let sender = eth.wallet.sender().await; + let etherscan_api_key = config.get_etherscan_api_key(Some(chain)); + + let to = match to { + Some(to) => Some(to.resolve(&provider).await?), + None => None, + }; - let mut builder: TxBuilder<'_, Provider> = - TxBuilder::new(&provider, sender.to_ethers(), to, chain, tx.legacy).await?; + let mut req = WithOtherFields::::default() + .with_to(to.into()) + .with_from(sender) + .with_value(tx.value.unwrap_or_default()); - builder - .gas(tx.gas_limit) - .etherscan_api_key(config.get_etherscan_api_key(Some(chain))) - .gas_price(tx.gas_price) - .priority_gas_price(tx.priority_gas_price) - .nonce(tx.nonce); + if let Some(nonce) = tx.nonce { + req.set_nonce(nonce.to()); + } - match command { + let (data, func) = match command { Some(CallSubcommands::Create { code, sig, args, value }) => { + if let Some(value) = value { + req.set_value(value); + } + + let mut data = hex::decode(code)?; + + if let Some(s) = sig { + let (mut constructor_args, _) = parse_function_args( + &s, + args, + None, + chain, + &provider, + etherscan_api_key.as_deref(), + ) + .await?; + data.append(&mut constructor_args); + } + if trace { let figment = Config::figment_with_root(find_project_root_path(None).unwrap()) .merge(eth.rpc); @@ -144,8 +164,8 @@ impl CallArgs { let trace = match executor.deploy( sender, - code.into_bytes().into(), - value.unwrap_or(U256::ZERO), + data.into(), + req.value.unwrap_or_default(), None, ) { Ok(deploy_result) => TraceResult::from(deploy_result), @@ -157,12 +177,26 @@ impl CallArgs { return Ok(()); } - // fill the builder after the conditional so we dont move values - fill_create(&mut builder, value, code, sig, args).await?; + (data, None) } _ => { // fill first here because we need to use the builder in the conditional - fill_tx(&mut builder, tx.value, sig, args, data).await?; + let (data, func) = if let Some(sig) = sig { + parse_function_args( + &sig, + args, + to, + chain, + &provider, + etherscan_api_key.as_deref(), + ) + .await? + } else if let Some(data) = data { + // Note: `sig+args` and `data` are mutually exclusive + (hex::decode(data)?, None) + } else { + (Vec::new(), None) + }; if trace { let figment = Config::figment_with_root(find_project_root_path(None).unwrap()) @@ -175,71 +209,28 @@ impl CallArgs { let mut executor = TracingExecutor::new(env, fork, evm_version, debug); - let (tx, _) = builder.build(); - let trace = TraceResult::from(executor.call_raw_committing( sender, - tx.to_addr().copied().expect("an address to be here").to_alloy(), - tx.data().cloned().unwrap_or_default().to_vec().into(), - tx.value().copied().unwrap_or_default().to_alloy(), + req.to.expect("an address to be here"), + data.into(), + req.value.unwrap_or_default(), )?); handle_traces(trace, &config, chain, labels, debug).await?; return Ok(()); } + + (data, func) } }; - let builder_output = builder.build(); - println!("{}", Cast::new(provider).call(builder_output, block).await?); - - Ok(()) - } -} - -/// fills the builder from create arg -async fn fill_create( - builder: &mut TxBuilder<'_, Provider>, - value: Option, - code: String, - sig: Option, - args: Vec, -) -> Result<()> { - builder.value(value); - - let mut data = hex::decode(code)?; - - if let Some(s) = sig { - let (mut sigdata, _func) = builder.create_args(&s, args).await?; - data.append(&mut sigdata); - } - - builder.set_data(data); - - Ok(()) -} - -/// fills the builder from args -async fn fill_tx( - builder: &mut TxBuilder<'_, Provider>, - value: Option, - sig: Option, - args: Vec, - data: Option, -) -> Result<()> { - builder.value(value); + req.set_input(data.into()); - if let Some(sig) = sig { - builder.set_args(sig.as_str(), args).await?; - } + println!("{}", Cast::new(provider).call(&req, func.as_ref(), block).await?); - if let Some(data) = data { - // Note: `sig+args` and `data` are mutually exclusive - builder.set_data(hex::decode(data).wrap_err("Expected hex encoded function data")?); + Ok(()) } - - Ok(()) } #[cfg(test)] diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 56fdc40d336e1..55149937b8a6c 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,12 +1,14 @@ +use alloy_network::TransactionBuilder; use alloy_primitives::U256; -use cast::{Cast, TxBuilder}; +use alloy_provider::Provider; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use clap::Parser; -use ethers_core::types::NameOrAddress; use eyre::Result; use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, - utils::{self, parse_ether_value}, + utils::{self, parse_ether_value, parse_function_args}, }; +use foundry_common::ens::NameOrAddress; use foundry_config::{figment::Figment, Config}; use std::str::FromStr; @@ -81,35 +83,47 @@ impl EstimateArgs { let figment = Figment::from(Config::figment()).merge(etherscan).merge(rpc); let config = Config::try_from(figment)?; - let provider = utils::get_provider(&config)?; let chain = utils::get_chain(config.chain, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)); - let mut builder = TxBuilder::new(&provider, from, to, chain, false).await?; - builder.etherscan_api_key(api_key); + let from = from.resolve(&provider).await?; + let to = match to { + Some(to) => Some(to.resolve(&provider).await?), + None => None, + }; + + let mut req = WithOtherFields::::default() + .with_to(to.into()) + .with_from(from) + .with_value(value.unwrap_or_default()); - match command { + let data = match command { Some(EstimateSubcommands::Create { code, sig, args, value }) => { - builder.value(value); + if let Some(value) = value { + req.set_value(value); + } let mut data = hex::decode(code)?; if let Some(s) = sig { - let (mut sigdata, _func) = builder.create_args(&s, args).await?; - data.append(&mut sigdata); + let (mut constructor_args, _) = + parse_function_args(&s, args, to, chain, &provider, api_key.as_deref()) + .await?; + data.append(&mut constructor_args); } - builder.set_data(data); + data } _ => { let sig = sig.ok_or_else(|| eyre::eyre!("Function signature must be provided."))?; - builder.value(value).set_args(sig.as_str(), args).await?; + parse_function_args(&sig, args, to, chain, &provider, api_key.as_deref()).await?.0 } }; - let builder_output = builder.peek(); - let gas = Cast::new(&provider).estimate(builder_output).await?; + req.set_input(data.into()); + + let gas = provider.estimate_gas(&req, None).await?; println!("{gas}"); Ok(()) } diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index 5038ded7b6205..f75f2c82f2634 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -1,10 +1,8 @@ -use alloy_primitives::{U256, U64}; +use alloy_provider::Provider; use cast::Cast; use clap::Parser; -use ethers_providers::Middleware; use eyre::Result; use foundry_cli::{opts::RpcOpts, utils}; -use foundry_common::types::{ToAlloy, ToEthers}; use foundry_config::Config; use futures::join; @@ -22,7 +20,7 @@ impl FindBlockArgs { pub async fn run(self) -> Result<()> { let FindBlockArgs { timestamp, rpc } = self; - let ts_target = U256::from(timestamp); + let ts_target = timestamp; let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; @@ -30,43 +28,43 @@ impl FindBlockArgs { let cast_provider = Cast::new(provider); let res = join!(cast_provider.timestamp(last_block_num), cast_provider.timestamp(1)); - let ts_block_latest = res.0?; - let ts_block_1 = res.1?; + let ts_block_latest: u64 = res.0?.to(); + let ts_block_1: u64 = res.1?.to(); let block_num = if ts_block_latest < ts_target { // If the most recent block's timestamp is below the target, return it - last_block_num.to_alloy() + last_block_num } else if ts_block_1 > ts_target { // If the target timestamp is below block 1's timestamp, return that - U64::from(1_u64) + 1 } else { // Otherwise, find the block that is closest to the timestamp - let mut low_block = U64::from(1_u64); // block 0 has a timestamp of 0: https://github.com/ethereum/go-ethereum/issues/17042#issuecomment-559414137 - let mut high_block = last_block_num.to_alloy(); - let mut matching_block: Option = None; + let mut low_block = 1_u64; // block 0 has a timestamp of 0: https://github.com/ethereum/go-ethereum/issues/17042#issuecomment-559414137 + let mut high_block = last_block_num; + let mut matching_block = None; while high_block > low_block && matching_block.is_none() { // Get timestamp of middle block (this approach approach to avoids overflow) let high_minus_low_over_2 = high_block .checked_sub(low_block) .ok_or_else(|| eyre::eyre!("unexpected underflow")) .unwrap() - .checked_div(U64::from(2_u64)) + .checked_div(2_u64) .unwrap(); let mid_block = high_block.checked_sub(high_minus_low_over_2).unwrap(); - let ts_mid_block = cast_provider.timestamp(mid_block.to_ethers()).await?; + let ts_mid_block = cast_provider.timestamp(mid_block).await?.to::(); // Check if we've found a match or should keep searching if ts_mid_block == ts_target { matching_block = Some(mid_block) - } else if high_block.checked_sub(low_block).unwrap() == U64::from(1_u64) { + } else if high_block.checked_sub(low_block).unwrap() == 1_u64 { // The target timestamp is in between these blocks. This rounds to the // highest block if timestamp is equidistant between blocks let res = join!( - cast_provider.timestamp(high_block.to_ethers()), - cast_provider.timestamp(low_block.to_ethers()) + cast_provider.timestamp(high_block), + cast_provider.timestamp(low_block) ); - let ts_high = res.0.unwrap(); - let ts_low = res.1.unwrap(); + let ts_high: u64 = res.0.unwrap().to(); + let ts_low: u64 = res.1.unwrap().to(); let high_diff = ts_high.checked_sub(ts_target).unwrap(); let low_diff = ts_target.checked_sub(ts_low).unwrap(); let is_low = low_diff < high_diff; diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index e7816afa38987..e97521fe92df4 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -1,18 +1,14 @@ +use alloy_dyn_abi::{DynSolType, DynSolValue, Specifier}; +use alloy_json_abi::Event; +use alloy_primitives::{Address, B256}; +use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, FilterBlockOption, FilterSet, Topic}; use cast::Cast; use clap::Parser; -use ethers_core::{ - abi::{ - token::{LenientTokenizer, StrictTokenizer, Tokenizer}, - Address, Event, HumanReadableParser, ParamType, RawTopicFilter, Token, Topic, TopicFilter, - }, - types::{ - BlockId, BlockNumber, Filter, FilterBlockOption, NameOrAddress, ValueOrArray, H256, U256, - }, -}; -use ethers_providers::Middleware; -use eyre::{Result, WrapErr}; +use eyre::Result; use foundry_cli::{opts::EthereumOpts, utils}; +use foundry_common::ens::NameOrAddress; use foundry_config::Config; +use hex::FromHex; use itertools::Itertools; use std::{io, str::FromStr}; @@ -80,13 +76,7 @@ impl LogsArgs { let cast = Cast::new(&provider); let address = match address { - Some(address) => { - let address = match address { - NameOrAddress::Name(name) => provider.resolve_name(&name).await?, - NameOrAddress::Address(address) => address, - }; - Some(address) - } + Some(address) => Some(address.resolve(&provider).await?), None => None, }; @@ -114,47 +104,36 @@ impl LogsArgs { /// successful, `topics_or_args` is parsed as indexed inputs and converted to topics. Otherwise, /// `sig_or_topic` is prepended to `topics_or_args` and used as raw topics. fn build_filter( - from_block: Option, - to_block: Option, + from_block: Option, + to_block: Option, address: Option
, sig_or_topic: Option, topics_or_args: Vec, ) -> Result { let block_option = FilterBlockOption::Range { from_block, to_block }; - let topic_filter = match sig_or_topic { + let filter = match sig_or_topic { // Try and parse the signature as an event signature - Some(sig_or_topic) => match HumanReadableParser::parse_event(sig_or_topic.as_str()) { + Some(sig_or_topic) => match foundry_common::abi::get_event(sig_or_topic.as_str()) { Ok(event) => build_filter_event_sig(event, topics_or_args)?, Err(_) => { let topics = [vec![sig_or_topic], topics_or_args].concat(); build_filter_topics(topics)? } }, - None => TopicFilter::default(), + None => Filter::default(), }; - // Convert from TopicFilter to Filter - let topics = - vec![topic_filter.topic0, topic_filter.topic1, topic_filter.topic2, topic_filter.topic3] - .into_iter() - .map(|topic| match topic { - Topic::Any => None, - Topic::This(topic) => Some(ValueOrArray::Value(Some(topic))), - _ => unreachable!(), - }) - .collect::>(); - - let filter = Filter { - block_option, - address: address.map(ValueOrArray::Value), - topics: [topics[0].clone(), topics[1].clone(), topics[2].clone(), topics[3].clone()], - }; + let mut filter = filter.select(block_option); + + if let Some(address) = address { + filter = filter.address(address) + } Ok(filter) } -/// Creates a TopicFilter from the given event signature and arguments. -fn build_filter_event_sig(event: Event, args: Vec) -> Result { +/// Creates a [Filter] from the given event signature and arguments. +fn build_filter_event_sig(event: Event, args: Vec) -> Result { let args = args.iter().map(|arg| arg.as_str()).collect::>(); // Match the args to indexed inputs. Enumerate so that the ordering can be restored @@ -164,128 +143,75 @@ fn build_filter_event_sig(event: Event, args: Vec) -> Result>>()? + .into_iter() .enumerate() .partition(|(_, (_, arg))| !arg.is_empty()); // Only parse the inputs with arguments - let indexed_tokens = parse_params(with_args.iter().map(|(_, p)| *p), true)?; + let indexed_tokens = with_args + .iter() + .map(|(_, (kind, arg))| kind.coerce_str(arg)) + .collect::, _>>()?; // Merge the inputs restoring the original ordering - let mut tokens = with_args + let mut topics = with_args .into_iter() .zip(indexed_tokens) .map(|((i, _), t)| (i, Some(t))) .chain(without_args.into_iter().map(|(i, _)| (i, None))) .sorted_by(|(i1, _), (i2, _)| i1.cmp(i2)) - .map(|(_, token)| token) - .collect::>(); + .map(|(_, token)| { + token + .map(|token| Topic::from(B256::from_slice(token.abi_encode().as_slice()))) + .unwrap_or(Topic::default()) + }) + .collect::>(); - tokens.resize(3, None); + topics.resize(3, Topic::default()); - let raw = RawTopicFilter { - topic0: tokens[0].clone().map_or(Topic::Any, Topic::This), - topic1: tokens[1].clone().map_or(Topic::Any, Topic::This), - topic2: tokens[2].clone().map_or(Topic::Any, Topic::This), - }; + let filter = Filter::new() + .event_signature(event.selector()) + .topic1(topics[0].clone()) + .topic2(topics[1].clone()) + .topic3(topics[2].clone()); - // Let filter do the hardwork of converting arguments to topics - Ok(event.filter(raw)?) + Ok(filter) } -/// Creates a TopicFilter from raw topic hashes. -fn build_filter_topics(topics: Vec) -> Result { +/// Creates a [Filter] from raw topic hashes. +fn build_filter_topics(topics: Vec) -> Result { let mut topics = topics .into_iter() - .map(|topic| if topic.is_empty() { Ok(None) } else { H256::from_str(&topic).map(Some) }) - .collect::, _>>()?; - - topics.resize(4, None); - - Ok(TopicFilter { - topic0: topics[0].map_or(Topic::Any, Topic::This), - topic1: topics[1].map_or(Topic::Any, Topic::This), - topic2: topics[2].map_or(Topic::Any, Topic::This), - topic3: topics[3].map_or(Topic::Any, Topic::This), - }) -} - -fn parse_params<'a, I: IntoIterator>( - params: I, - lenient: bool, -) -> eyre::Result> { - let mut tokens = Vec::new(); - - for (param, value) in params { - let mut token = if lenient { - LenientTokenizer::tokenize(param, value) - } else { - StrictTokenizer::tokenize(param, value) - }; - if token.is_err() && value.starts_with("0x") { - match param { - ParamType::FixedBytes(32) => { - if value.len() < 66 { - let padded_value = [value, &"0".repeat(66 - value.len())].concat(); - token = if lenient { - LenientTokenizer::tokenize(param, &padded_value) - } else { - StrictTokenizer::tokenize(param, &padded_value) - }; - } - } - ParamType::Uint(_) => { - // try again if value is hex - if let Ok(value) = U256::from_str(value).map(|v| v.to_string()) { - token = if lenient { - LenientTokenizer::tokenize(param, &value) - } else { - StrictTokenizer::tokenize(param, &value) - }; - } - } - // TODO: Not sure what to do here. Put the no effect in for now, but that is not - // ideal. We could attempt massage for every value type? - _ => {} + .map(|topic| { + if topic.is_empty() { + Ok(Topic::default()) + } else { + Ok(Topic::from(B256::from_hex(topic.as_str())?)) } - } + }) + .collect::>>>()?; - let token = token.map(sanitize_token).wrap_err_with(|| { - format!("Failed to parse `{value}`, expected value of type: {param}") - })?; - tokens.push(token); - } - Ok(tokens) -} + topics.resize(4, Topic::default()); -pub fn sanitize_token(token: Token) -> Token { - match token { - Token::Array(tokens) => { - let mut sanitized = Vec::with_capacity(tokens.len()); - for token in tokens { - let token = match token { - Token::String(val) => { - let val = match val.as_str() { - // this is supposed to be an empty string - "\"\"" | "''" => String::new(), - _ => val, - }; - Token::String(val) - } - _ => sanitize_token(token), - }; - sanitized.push(token) - } - Token::Array(sanitized) - } - _ => token, - } + let filter = Filter::new() + .event_signature(topics[0].clone()) + .topic1(topics[1].clone()) + .topic2(topics[2].clone()) + .topic3(topics[3].clone()); + + Ok(filter) } #[cfg(test)] mod tests { use super::*; - use ethers_core::types::H160; + use alloy_primitives::{U160, U256 as rU256}; + use alloy_rpc_types::ValueOrArray; const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"; const TRANSFER_SIG: &str = "Transfer(address indexed,address indexed,uint256)"; @@ -294,13 +220,13 @@ mod tests { #[test] fn test_build_filter_basic() { - let from_block = Some(BlockNumber::from(1337)); - let to_block = Some(BlockNumber::Latest); + let from_block = Some(BlockNumberOrTag::from(1337)); + let to_block = Some(BlockNumberOrTag::Latest); let address = Address::from_str(ADDRESS).ok(); let expected = Filter { block_option: FilterBlockOption::Range { from_block, to_block }, - address: Some(ValueOrArray::Value(address.unwrap())), - topics: [None, None, None, None], + address: ValueOrArray::Value(address.unwrap()).into(), + topics: [vec![].into(), vec![].into(), vec![].into(), vec![].into()], }; let filter = build_filter(from_block, to_block, address, None, vec![]).unwrap(); assert_eq!(filter, expected) @@ -310,8 +236,13 @@ mod tests { fn test_build_filter_sig() { let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, - address: None, - topics: [Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), None, None, None], + address: vec![].into(), + topics: [ + B256::from_str(TRANSFER_TOPIC).unwrap().into(), + vec![].into(), + vec![].into(), + vec![].into(), + ], }; let filter = build_filter(None, None, None, Some(TRANSFER_SIG.to_string()), vec![]).unwrap(); @@ -322,8 +253,13 @@ mod tests { fn test_build_filter_mismatch() { let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, - address: None, - topics: [Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), None, None, None], + address: vec![].into(), + topics: [ + B256::from_str(TRANSFER_TOPIC).unwrap().into(), + vec![].into(), + vec![].into(), + vec![].into(), + ], }; let filter = build_filter( None, @@ -338,14 +274,16 @@ mod tests { #[test] fn test_build_filter_sig_with_arguments() { + let addr = Address::from_str(ADDRESS).unwrap(); + let addr = rU256::from(U160::from_be_bytes(addr.0 .0)); let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, - address: None, + address: vec![].into(), topics: [ - Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), - Some(H160::from_str(ADDRESS).unwrap().into()), - None, - None, + B256::from_str(TRANSFER_TOPIC).unwrap().into(), + addr.into(), + vec![].into(), + vec![].into(), ], }; let filter = build_filter( @@ -361,14 +299,16 @@ mod tests { #[test] fn test_build_filter_sig_with_skipped_arguments() { + let addr = Address::from_str(ADDRESS).unwrap(); + let addr = rU256::from(U160::from_be_bytes(addr.0 .0)); let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, - address: None, + address: vec![].into(), topics: [ - Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), - None, - Some(H160::from_str(ADDRESS).unwrap().into()), - None, + vec![B256::from_str(TRANSFER_TOPIC).unwrap()].into(), + vec![].into(), + addr.into(), + vec![].into(), ], }; let filter = build_filter( @@ -386,12 +326,12 @@ mod tests { fn test_build_filter_with_topics() { let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, - address: None, + address: vec![].into(), topics: [ - Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), - Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), - None, - None, + vec![B256::from_str(TRANSFER_TOPIC).unwrap()].into(), + vec![B256::from_str(TRANSFER_TOPIC).unwrap()].into(), + vec![].into(), + vec![].into(), ], }; let filter = build_filter( @@ -410,12 +350,12 @@ mod tests { fn test_build_filter_with_skipped_topic() { let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, - address: None, + address: vec![].into(), topics: [ - Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), - None, - Some(H256::from_str(TRANSFER_TOPIC).unwrap().into()), - None, + vec![B256::from_str(TRANSFER_TOPIC).unwrap()].into(), + vec![].into(), + vec![B256::from_str(TRANSFER_TOPIC).unwrap()].into(), + vec![].into(), ], }; let filter = build_filter( @@ -443,7 +383,7 @@ mod tests { .unwrap() .to_string(); - assert_eq!(err, "Failed to parse `1234`, expected value of type: address"); + assert_eq!(err, "parser error:\n1234\n^\nInvalid string length"); } #[test] @@ -453,7 +393,7 @@ mod tests { .unwrap() .to_string(); - assert_eq!(err, "Invalid character 's' at position 1"); + assert_eq!(err, "Odd number of digits"); } #[test] @@ -463,7 +403,7 @@ mod tests { .unwrap() .to_string(); - assert_eq!(err, "Invalid input length"); + assert_eq!(err, "Invalid string length"); } #[test] @@ -479,6 +419,6 @@ mod tests { .unwrap() .to_string(); - assert_eq!(err, "Invalid input length"); + assert_eq!(err, "Invalid string length"); } } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index dc7f78461dd38..def6d46f4b27d 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -1,15 +1,15 @@ use crate::tx; +use alloy_network::{eip2718::Encodable2718, EthereumSigner, TransactionBuilder}; +use alloy_primitives::U64; +use alloy_provider::Provider; +use alloy_signer::Signer; use clap::Parser; -use ethers_core::types::NameOrAddress; -use ethers_middleware::MiddlewareBuilder; -use ethers_providers::Middleware; -use ethers_signers::Signer; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils, + utils::{self, get_provider}, }; -use foundry_common::types::ToAlloy; +use foundry_common::ens::NameOrAddress; use foundry_config::Config; use std::str::FromStr; @@ -45,7 +45,7 @@ pub struct MakeTxArgs { #[derive(Debug, Parser)] pub enum MakeTxSubcommands { /// Use to deploy raw contract bytecode. - #[clap(name = "--create")] + #[command(name = "--create")] Create { /// The initialization bytecode of the contract to deploy. code: String, @@ -86,23 +86,21 @@ impl MakeTxArgs { let signer = eth.wallet.signer().await?; let from = signer.address(); - tx::validate_from_address(eth.wallet.from, from.to_alloy())?; + tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = Some(provider.get_transaction_count(from, None).await?.to_alloy()); + tx.nonce = Some(U64::from(provider.get_transaction_count(from, None).await?)); } - let provider = provider.with_signer(signer); + let provider = get_provider(&config)?; - let (mut tx, _) = + let (tx, _) = tx::build_tx(&provider, from, to, code, sig, args, tx, chain, api_key).await?; - // Fill nonce, gas limit, gas price, and max priority fee per gas if needed - provider.fill_transaction(&mut tx, None).await?; + let tx = tx.build(&EthereumSigner::new(signer)).await?; - let signature = provider.sign_transaction(&tx, from).await?; - let signed_tx = tx.rlp_signed(&signature); - println!("{signed_tx}"); + let signed_tx = hex::encode(tx.encoded_2718()); + println!("0x{signed_tx}"); Ok(()) } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 3fc09565cde67..33c26e2a907b1 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,5 +1,5 @@ use alloy_primitives::U256; -use alloy_providers::tmp::TempProvider; +use alloy_provider::Provider; use alloy_rpc_types::BlockTransactions; use cast::revm::primitives::EnvWithHandlerCfg; use clap::Parser; @@ -109,19 +109,15 @@ impl RunArgs { .wrap_err_with(|| format!("tx not found: {:?}", tx_hash))?; // check if the tx is a system transaction - if is_known_system_sender(tx.from) || - tx.transaction_type.map(|ty| ty.to::()) == Some(SYSTEM_TRANSACTION_TYPE) - { + if is_known_system_sender(tx.from) || tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) { return Err(eyre::eyre!( "{:?} is a system transaction.\nReplaying system transactions is currently not supported.", tx.hash )); } - let tx_block_number = tx - .block_number - .ok_or_else(|| eyre::eyre!("tx may still be pending: {:?}", tx_hash))? - .to::(); + let tx_block_number = + tx.block_number.ok_or_else(|| eyre::eyre!("tx may still be pending: {:?}", tx_hash))?; // fetch the block the transaction was mined in let block = provider.get_block(tx_block_number.into(), true).await?; @@ -136,12 +132,12 @@ impl RunArgs { env.block.number = U256::from(tx_block_number); if let Some(block) = &block { - env.block.timestamp = block.header.timestamp; + env.block.timestamp = U256::from(block.header.timestamp); env.block.coinbase = block.header.miner; env.block.difficulty = block.header.difficulty; env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); - env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default(); - env.block.gas_limit = block.header.gas_limit; + env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); + env.block.gas_limit = U256::from(block.header.gas_limit); // TODO: we need a smarter way to map the block to the corresponding evm_version for // commonly used chains @@ -174,8 +170,7 @@ impl RunArgs { // we skip them otherwise this would cause // reverts if is_known_system_sender(tx.from) || - tx.transaction_type.map(|ty| ty.to::()) == - Some(SYSTEM_TRANSACTION_TYPE) + tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) { update_progress!(pb, index); continue; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 092d759eb022a..b24de5fba2948 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -1,19 +1,17 @@ use crate::tx; +use alloy_network::{AnyNetwork, EthereumSigner}; +use alloy_primitives::{Address, U64}; +use alloy_provider::{Provider, ProviderBuilder}; +use alloy_signer::Signer; +use alloy_transport::Transport; use cast::Cast; use clap::Parser; -use ethers_core::types::NameOrAddress; -use ethers_middleware::SignerMiddleware; -use ethers_providers::Middleware; -use ethers_signers::Signer; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils, }; -use foundry_common::{ - cli_warn, - types::{ToAlloy, ToEthers}, -}; +use foundry_common::{cli_warn, ens::NameOrAddress}; use foundry_config::{Chain, Config}; use std::str::FromStr; @@ -38,7 +36,7 @@ pub struct SendTxArgs { /// The number of confirmations until the receipt is fetched. #[arg(long, default_value = "1")] - confirmations: usize, + confirmations: u64, /// Print the transaction receipt as JSON. #[arg(long, short, help_heading = "Display options")] @@ -114,6 +112,11 @@ impl SendTxArgs { let chain = utils::get_chain(config.chain, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)); + let to = match to { + Some(to) => Some(to.resolve(&provider).await?), + None => None, + }; + // Case 1: // Default to sending via eth_sendTransaction if the --unlocked flag is passed. // This should be the only way this RPC method is used as it requires a local node @@ -121,15 +124,15 @@ impl SendTxArgs { if unlocked { // only check current chain id if it was specified in the config if let Some(config_chain) = config.chain { - let current_chain_id = provider.get_chainid().await?.as_u64(); + let current_chain_id = provider.get_chain_id().await?; let config_chain_id = config_chain.id(); // switch chain if current chain id is not the same as the one specified in the // config if config_chain_id != current_chain_id { cli_warn!("Switching to chain {}", config_chain); provider - .request( - "wallet_switchEthereumChain", + .raw_request( + "wallet_switchEthereumChain".into(), [serde_json::json!({ "chainId": format!("0x{:x}", config_chain_id), })], @@ -139,17 +142,13 @@ impl SendTxArgs { } if resend { - tx.nonce = Some( - provider - .get_transaction_count(config.sender.to_ethers(), None) - .await? - .to_alloy(), - ); + tx.nonce = + Some(U64::from(provider.get_transaction_count(config.sender, None).await?)); } cast_send( provider, - config.sender.to_ethers(), + config.sender, to, code, sig, @@ -171,13 +170,15 @@ impl SendTxArgs { let signer = eth.wallet.signer().await?; let from = signer.address(); - tx::validate_from_address(eth.wallet.from, from.to_alloy())?; + tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = Some(provider.get_transaction_count(from, None).await?.to_alloy()); + tx.nonce = Some(U64::from(provider.get_transaction_count(from, None).await?)); } - let provider = SignerMiddleware::new_with_provider_chain(provider, signer).await?; + let signer = EthereumSigner::from(signer); + let provider = + ProviderBuilder::<_, _, AnyNetwork>::default().signer(signer).on_provider(provider); cast_send( provider, @@ -199,10 +200,10 @@ impl SendTxArgs { } #[allow(clippy::too_many_arguments)] -async fn cast_send, T: Into>( - provider: M, - from: F, - to: Option, +async fn cast_send, T: Transport + Clone>( + provider: P, + from: Address, + to: Option
, code: Option, sig: Option, args: Vec, @@ -210,19 +211,16 @@ async fn cast_send, T: Into chain: Chain, etherscan_api_key: Option, cast_async: bool, - confs: usize, + confs: u64, to_json: bool, -) -> Result<()> -where - M::Error: 'static, -{ - let builder_output = +) -> Result<()> { + let (tx, _) = tx::build_tx(&provider, from, to, code, sig, args, tx, chain, etherscan_api_key).await?; let cast = Cast::new(provider); - let pending_tx = cast.send(builder_output).await?; - let tx_hash = *pending_tx; + let pending_tx = cast.send(tx).await?; + let tx_hash = pending_tx.inner().tx_hash(); if cast_async { println!("{tx_hash:#x}"); diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 397bd07e2b1bb..0bf041b8a9cff 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -1,10 +1,12 @@ use crate::opts::parse_slot; -use alloy_primitives::{B256, U256}; +use alloy_network::AnyNetwork; +use alloy_primitives::{Address, B256, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::BlockId; +use alloy_transport::Transport; use cast::Cast; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; -use ethers_core::types::{BlockId, NameOrAddress}; -use ethers_providers::Middleware; use eyre::Result; use foundry_block_explorers::Client; use foundry_cli::{ @@ -14,8 +16,7 @@ use foundry_cli::{ use foundry_common::{ abi::find_source, compile::{etherscan_project, ProjectCompiler}, - provider::ethers::RetryProvider, - types::{ToAlloy, ToEthers}, + ens::NameOrAddress, }; use foundry_compilers::{ artifacts::StorageLayout, Artifact, ConfigurableContractArtifact, Project, Solc, @@ -80,19 +81,19 @@ impl StorageArgs { let config = Config::from(&self); let Self { address, slot, block, build, .. } = self; - let provider = utils::get_provider(&config)?; + let address = address.resolve(&provider).await?; // Slot was provided, perform a simple RPC call if let Some(slot) = slot { let cast = Cast::new(provider); - println!("{}", cast.storage(address, slot.to_ethers(), block).await?); + println!("{}", cast.storage(address, slot, block).await?); return Ok(()); } // No slot was provided // Get deployed bytecode at given address - let address_code = provider.get_code(address.clone(), block).await?.to_alloy(); + let address_code = provider.get_code_at(address, block.unwrap_or_default()).await?; if address_code.is_empty() { eyre::bail!("Provided address has no deployed code and thus no storage"); } @@ -107,8 +108,7 @@ impl StorageArgs { artifact.get_deployed_bytecode_bytes().is_some_and(|b| *b == address_code) }); if let Some((_, artifact)) = artifact { - return fetch_and_print_storage(provider, address.clone(), block, artifact, true) - .await; + return fetch_and_print_storage(provider, address, block, artifact, true).await; } } @@ -123,11 +123,7 @@ impl StorageArgs { let chain = utils::get_chain(config.chain, &provider).await?; let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); let client = Client::new(chain, api_key)?; - let addr = address - .as_address() - .ok_or_else(|| eyre::eyre!("Could not resolve address"))? - .to_alloy(); - let source = find_source(client, addr).await?; + let source = find_source(client, address).await?; let metadata = source.items.first().unwrap(); if metadata.is_vyper() { eyre::bail!("Contract at provided address is not a valid Solidity contract") @@ -209,9 +205,9 @@ impl StorageValue { } } -async fn fetch_and_print_storage( - provider: RetryProvider, - address: NameOrAddress, +async fn fetch_and_print_storage, T: Transport + Clone>( + provider: P, + address: Address, block: Option, artifact: &ConfigurableContractArtifact, pretty: bool, @@ -226,18 +222,17 @@ async fn fetch_and_print_storage( } } -async fn fetch_storage_slots( - provider: RetryProvider, - address: NameOrAddress, +async fn fetch_storage_slots, T: Transport + Clone>( + provider: P, + address: Address, block: Option, layout: &StorageLayout, ) -> Result> { let requests = layout.storage.iter().map(|storage_slot| async { let slot = B256::from(U256::from_str(&storage_slot.slot)?); - let raw_slot_value = - provider.get_storage_at(address.clone(), slot.to_ethers(), block).await?.to_alloy(); + let raw_slot_value = provider.get_storage_at(address, slot.into(), block).await?; - let value = StorageValue { slot, raw_slot_value }; + let value = StorageValue { slot, raw_slot_value: raw_slot_value.into() }; Ok(value) }); diff --git a/crates/cast/bin/cmd/wallet/list.rs b/crates/cast/bin/cmd/wallet/list.rs index 2790366a37c71..d4ca3f0134371 100644 --- a/crates/cast/bin/cmd/wallet/list.rs +++ b/crates/cast/bin/cmd/wallet/list.rs @@ -1,7 +1,7 @@ use clap::Parser; use eyre::Result; -use foundry_common::{fs, types::ToAlloy}; +use foundry_common::fs; use foundry_config::Config; use foundry_wallets::multi_wallet::MultiWalletOptsBuilder; @@ -61,7 +61,7 @@ impl ListArgs { .available_senders(self.max_senders.unwrap()) .await? .iter() - .for_each(|sender| println!("{} ({})", sender.to_alloy(), $label)); + .for_each(|sender| println!("{} ({})", sender, $label)); } } Err(e) => { diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 50467421c4151..60e21a2fb7327 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,13 +1,13 @@ +use alloy_dyn_abi::TypedData; use alloy_primitives::{Address, Signature}; -use alloy_signer::{ +use alloy_signer::Signer; +use alloy_signer_wallet::{ coins_bip39::{English, Mnemonic}, - LocalWallet, MnemonicBuilder, Signer as AlloySigner, + LocalWallet, MnemonicBuilder, }; use clap::Parser; -use ethers_core::types::transaction::eip712::TypedData; -use ethers_signers::Signer; use eyre::{Context, Result}; -use foundry_common::{fs, types::ToAlloy}; +use foundry_common::fs; use foundry_config::Config; use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner}; use rand::thread_rng; @@ -258,7 +258,7 @@ impl WalletSubcommands { .signer() .await?; let addr = wallet.address(); - println!("{}", addr.to_alloy().to_checksum(None)); + println!("{}", addr.to_checksum(None)); } WalletSubcommands::Sign { message, data, from_file, no_hash, wallet } => { let wallet = wallet.signer().await?; @@ -270,13 +270,13 @@ impl WalletSubcommands { // data is a json string serde_json::from_str(&message)? }; - wallet.sign_typed_data(&typed_data).await? + wallet.sign_dynamic_typed_data(&typed_data).await? } else if no_hash { - wallet.sign_hash(&message.parse()?).await? + wallet.sign_hash(&hex::decode(&message)?[..].try_into()?).await? } else { - wallet.sign_message(Self::hex_str_to_bytes(&message)?).await? + wallet.sign_message(&Self::hex_str_to_bytes(&message)?).await? }; - println!("0x{sig}"); + println!("0x{}", hex::encode(sig.as_bytes())); } WalletSubcommands::Verify { message, signature, address } => { let recovered_address = Self::recover_address_from_message(&message, &signature)?; @@ -335,11 +335,11 @@ flag to set your key via: }; let mut rng = thread_rng(); - eth_keystore::encrypt_key( - &dir, + let (wallet, _) = LocalWallet::encrypt_keystore( + dir, &mut rng, private_key, - &password, + password, Some(&account_name), )?; let address = wallet.address(); diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index c3485ddfa96f9..28ada95b11cb4 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,5 +1,6 @@ use alloy_primitives::Address; -use alloy_signer::{k256::ecdsa::SigningKey, utils::secret_key_to_address, LocalWallet, Signer}; +use alloy_signer::{k256::ecdsa::SigningKey, utils::secret_key_to_address}; +use alloy_signer_wallet::LocalWallet; use clap::{builder::TypedValueParser, Parser}; use eyre::Result; use rayon::iter::{self, ParallelIterator}; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index a81c1acd8b5a4..8c0181367b70f 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -2,24 +2,23 @@ extern crate tracing; use alloy_primitives::{keccak256, Address, B256}; -use cast::{Cast, SimpleCast, TxBuilder}; +use alloy_provider::Provider; +use alloy_rpc_types::{BlockId, BlockNumberOrTag::Latest}; +use cast::{Cast, SimpleCast}; use clap::{CommandFactory, Parser}; use clap_complete::generate; -use ethers_core::types::{BlockId, BlockNumber::Latest, NameOrAddress}; -use ethers_providers::{Middleware, Provider}; use eyre::Result; use foundry_cli::{handler, prompt, stdin, utils}; use foundry_common::{ abi::get_event, - fmt::format_tokens, + ens::ProviderEnsExt, + fmt::{format_tokens, format_uint_exp}, fs, - runtime_client::RuntimeClient, selectors::{ decode_calldata, decode_event_topic, decode_function_selector, decode_selectors, import_selectors, parse_signatures, pretty_calldata, ParsedSignatures, SelectorImportData, SelectorType, }, - types::{ToAlloy, ToEthers}, }; use foundry_config::Config; use std::time::Instant; @@ -214,35 +213,16 @@ async fn main() -> Result<()> { CastSubcommand::Balance { block, who, ether, rpc, erc20 } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let account_addr = who.resolve(&provider).await?; match erc20 { Some(token) => { - let chain = utils::get_chain(config.chain, &provider).await?; - let mut builder: TxBuilder<'_, Provider> = TxBuilder::new( - &provider, - NameOrAddress::Address(Address::ZERO.to_ethers()), - Some(NameOrAddress::Address(token.to_ethers())), - chain, - true, - ) - .await?; - - let account_addr = match who { - NameOrAddress::Name(ens_name) => provider.resolve_name(&ens_name).await?, - NameOrAddress::Address(addr) => addr, - }; - - builder - .set_args( - "balanceOf(address) returns (uint256)", - vec![format!("{account_addr:#x}")], - ) - .await?; - let builder_output = builder.build(); - println!("{}", Cast::new(provider).call(builder_output, block).await?); + let balance = + Cast::new(&provider).erc20_balance(token, account_addr, block).await?; + println!("{}", format_uint_exp(balance)); } None => { - let value = Cast::new(provider).balance(who, block).await?; + let value = Cast::new(&provider).balance(account_addr, block).await?; if ether { println!("{}", SimpleCast::from_wei(&value.to_string(), "eth")?); } else { @@ -287,16 +267,18 @@ async fn main() -> Result<()> { CastSubcommand::Client { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!("{}", provider.client_version().await?); + println!("{}", provider.get_client_version().await?); } CastSubcommand::Code { block, who, disassemble, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let who = who.resolve(&provider).await?; println!("{}", Cast::new(provider).code(who, block, disassemble).await?); } CastSubcommand::Codesize { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let who = who.resolve(&provider).await?; println!("{}", Cast::new(provider).codesize(who, block).await?); } CastSubcommand::ComputeAddress { address, nonce, rpc } => { @@ -304,7 +286,7 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let address: Address = stdin::unwrap_line(address)?.parse()?; - let computed = Cast::new(&provider).compute_address(address, nonce).await?; + let computed = Cast::new(provider).compute_address(address, nonce).await?; println!("Computed Address: {}", computed.to_checksum(None)); } CastSubcommand::Disassemble { bytecode } => { @@ -345,24 +327,26 @@ async fn main() -> Result<()> { CastSubcommand::Implementation { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let who = who.resolve(&provider).await?; println!("{}", Cast::new(provider).implementation(who, block).await?); } CastSubcommand::Admin { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let who = who.resolve(&provider).await?; println!("{}", Cast::new(provider).admin(who, block).await?); } CastSubcommand::Nonce { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let who = who.resolve(&provider).await?; println!("{}", Cast::new(provider).nonce(who, block).await?); } CastSubcommand::Proof { address, slots, rpc, block } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - let value = provider - .get_proof(address, slots.into_iter().map(|s| s.to_ethers()).collect(), block) - .await?; + let address = address.resolve(&provider).await?; + let value = provider.get_proof(address, slots.into_iter().collect(), block).await?; println!("{}", serde_json::to_string(&value)?); } CastSubcommand::Rpc(cmd) => cmd.run().await?, @@ -377,13 +361,12 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let cast = Cast::new(&provider); let pending_tx = cast.publish(raw_tx).await?; - let tx_hash = *pending_tx; + let tx_hash = pending_tx.inner().tx_hash(); if cast_async { println!("{tx_hash:#x}"); } else { - let receipt = - pending_tx.await?.ok_or_else(|| eyre::eyre!("tx {tx_hash} not found"))?; + let receipt = pending_tx.get_receipt().await?; println!("{}", serde_json::json!(receipt)); } } @@ -470,9 +453,9 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let who = stdin::unwrap_line(who)?; - let name = provider.lookup_address(who.to_ethers()).await?; + let name = provider.lookup_address(who).await?; if verify { - let address = provider.resolve_name(&name).await?.to_alloy(); + let address = provider.resolve_name(&name).await?; eyre::ensure!( address == who, "Forward lookup verification failed: got `{name:?}`, expected `{who:?}`" @@ -493,7 +476,7 @@ async fn main() -> Result<()> { "forward lookup verification failed. got {name}, expected {who}" ); } - println!("{}", address.to_alloy().to_checksum(None)); + println!("{}", address.to_checksum(None)); } // Misc @@ -555,14 +538,7 @@ async fn main() -> Result<()> { CastSubcommand::Logs(cmd) => cmd.run().await?, CastSubcommand::DecodeTransaction { tx } => { let tx = stdin::unwrap_line(tx)?; - let (tx, sig) = SimpleCast::decode_raw_transaction(&tx)?; - - // Serialize tx, sig and constructed a merged json string - let mut tx = serde_json::to_value(&tx)?; - let tx_map = tx.as_object_mut().unwrap(); - serde_json::to_value(sig)?.as_object().unwrap().iter().for_each(|(k, v)| { - tx_map.entry(k).or_insert(v.clone()); - }); + let tx = SimpleCast::decode_raw_transaction(&tx)?; println!("{}", serde_json::to_string_pretty(&tx)?); } diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 5a1af1fdc20aa..51f32b145c838 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -5,10 +5,11 @@ use crate::cmd::{ wallet::WalletSubcommands, }; use alloy_primitives::{Address, B256, U256}; +use alloy_rpc_types::BlockId; use clap::{Parser, Subcommand, ValueHint}; -use ethers_core::types::{BlockId, NameOrAddress}; use eyre::Result; use foundry_cli::opts::{EtherscanOpts, RpcOpts}; +use foundry_common::ens::NameOrAddress; use std::{path::PathBuf, str::FromStr}; const VERSION_MESSAGE: &str = concat!( @@ -423,7 +424,7 @@ pub enum CastSubcommand { /// The number of confirmations until the receipt is fetched #[arg(long, default_value = "1")] - confirmations: usize, + confirmations: u64, /// Exit immediately if the transaction was not found. #[arg(id = "async", long = "async", env = "CAST_ASYNC", alias = "cast-async")] @@ -906,9 +907,9 @@ pub fn parse_slot(s: &str) -> Result { #[cfg(test)] mod tests { use super::*; + use alloy_rpc_types::{BlockNumberOrTag, RpcBlockHash}; use cast::SimpleCast; use clap::CommandFactory; - use ethers_core::types::BlockNumber; #[test] fn verify_cli() { @@ -997,30 +998,34 @@ mod tests { let test_cases = [ TestCase { input: "0".to_string(), - expect: BlockId::Number(BlockNumber::Number(0u64.into())), + expect: BlockId::Number(BlockNumberOrTag::Number(0u64)), }, TestCase { input: "0x56462c47c03df160f66819f0a79ea07def1569f8aac0fe91bb3a081159b61b4a" .to_string(), - expect: BlockId::Hash( + expect: BlockId::Hash(RpcBlockHash::from_hash( "0x56462c47c03df160f66819f0a79ea07def1569f8aac0fe91bb3a081159b61b4a" .parse() .unwrap(), - ), + None, + )), + }, + TestCase { + input: "latest".to_string(), + expect: BlockId::Number(BlockNumberOrTag::Latest), }, - TestCase { input: "latest".to_string(), expect: BlockId::Number(BlockNumber::Latest) }, TestCase { input: "earliest".to_string(), - expect: BlockId::Number(BlockNumber::Earliest), + expect: BlockId::Number(BlockNumberOrTag::Earliest), }, TestCase { input: "pending".to_string(), - expect: BlockId::Number(BlockNumber::Pending), + expect: BlockId::Number(BlockNumberOrTag::Pending), }, - TestCase { input: "safe".to_string(), expect: BlockId::Number(BlockNumber::Safe) }, + TestCase { input: "safe".to_string(), expect: BlockId::Number(BlockNumberOrTag::Safe) }, TestCase { input: "finalized".to_string(), - expect: BlockId::Number(BlockNumber::Finalized), + expect: BlockId::Number(BlockNumberOrTag::Finalized), }, ]; diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index cd155de011d26..98f7bf67e4c4d 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,9 +1,12 @@ -use alloy_primitives::Address; -use cast::{TxBuilder, TxBuilderOutput}; -use ethers_core::types::NameOrAddress; -use ethers_providers::Middleware; +use alloy_json_abi::Function; +use alloy_network::{AnyNetwork, TransactionBuilder}; +use alloy_primitives::{Address, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_transport::Transport; use eyre::Result; -use foundry_cli::opts::TransactionOpts; +use foundry_cli::{opts::TransactionOpts, utils::parse_function_args}; +use foundry_common::ens::NameOrAddress; use foundry_config::Chain; /// Prevents a misconfigured hwlib from sending a transaction that defies user-specified --from @@ -34,40 +37,86 @@ pub fn validate_to_address(code: &Option, to: &Option) -> } #[allow(clippy::too_many_arguments)] -pub async fn build_tx, T: Into>( - provider: &M, +pub async fn build_tx< + P: Provider, + T: Transport + Clone, + F: Into, + TO: Into, +>( + provider: &P, from: F, - to: Option, + to: Option, code: Option, sig: Option, args: Vec, tx: TransactionOpts, chain: impl Into, etherscan_api_key: Option, -) -> Result { - let mut builder = TxBuilder::new(provider, from, to, chain, tx.legacy).await?; - builder - .etherscan_api_key(etherscan_api_key) - .gas(tx.gas_limit) - .gas_price(tx.gas_price) - .priority_gas_price(tx.priority_gas_price) - .value(tx.value) - .nonce(tx.nonce); +) -> Result<(WithOtherFields, Option)> { + let chain = chain.into(); + + let from = from.into().resolve(provider).await?; + let to = if let Some(to) = to { Some(to.into().resolve(provider).await?) } else { None }; + + let mut req = WithOtherFields::new(TransactionRequest::default()) + .with_to(to.into()) + .with_from(from) + .with_value(tx.value.unwrap_or_default()) + .with_chain_id(chain.id()); + + req.set_nonce(if let Some(nonce) = tx.nonce { + nonce.to() + } else { + provider.get_transaction_count(from, None).await? + }); + + if tx.legacy || chain.is_legacy() { + req.set_gas_price(if let Some(gas_price) = tx.gas_price { + gas_price.to() + } else { + provider.get_gas_price().await? + }); + } else { + let (max_fee, priority_fee) = match (tx.gas_price, tx.priority_gas_price) { + (Some(gas_price), Some(priority_gas_price)) => (gas_price, priority_gas_price), + (_, _) => { + let estimate = provider.estimate_eip1559_fees(None).await?; + ( + tx.gas_price.unwrap_or(U256::from(estimate.max_fee_per_gas)), + tx.priority_gas_price.unwrap_or(U256::from(estimate.max_priority_fee_per_gas)), + ) + } + }; + + req.set_max_fee_per_gas(max_fee.to()); + req.set_max_priority_fee_per_gas(priority_fee.to()); + } let params = sig.as_deref().map(|sig| (sig, args)); - if let Some(code) = code { + let (data, func) = if let Some(code) = code { let mut data = hex::decode(code)?; if let Some((sig, args)) = params { - let (mut sigdata, _) = builder.create_args(sig, args).await?; + let (mut sigdata, _) = + parse_function_args(sig, args, None, chain, provider, etherscan_api_key.as_deref()) + .await?; data.append(&mut sigdata); } - builder.set_data(data); + (data, None) + } else if let Some((sig, args)) = params { + parse_function_args(sig, args, None, chain, provider, etherscan_api_key.as_deref()).await? } else { - builder.args(params).await?; - } + (Vec::new(), None) + }; + + req.set_input(data.into()); + + req.set_gas_limit(if let Some(gas_limit) = tx.gas_limit { + gas_limit.to() + } else { + provider.estimate_gas(&req, None).await? + }); - let builder_output = builder.build(); - Ok(builder_output) + Ok((req, func)) } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 38498786ea182..338510eb94199 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1,66 +1,70 @@ +use alloy_consensus::TxEnvelope; use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; -use alloy_json_abi::ContractObject; +use alloy_json_abi::{ContractObject, Function}; +use alloy_network::AnyNetwork; use alloy_primitives::{ utils::{keccak256, ParseUnits, Unit}, - Address, Bytes, Keccak256, B256, I256, U256, + Address, Keccak256, TxHash, B256, I256, U256, +}; +use alloy_provider::{ + network::eip2718::{Decodable2718, Encodable2718}, + PendingTransactionBuilder, Provider, }; use alloy_rlp::Decodable; +use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, TransactionRequest, WithOtherFields}; +use alloy_sol_types::sol; +use alloy_transport::Transport; use base::{Base, NumberWithBase, ToBase}; use chrono::DateTime; -use ethers_core::{ - types::{ - transaction::eip2718::TypedTransaction, BlockId, BlockNumber, Filter, NameOrAddress, - Signature, H160, H256, U64, - }, - utils::rlp, -}; -use ethers_providers::{Middleware, PendingTransaction, PubsubClient}; use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::Client; use foundry_common::{ abi::{encode_function_args, get_func}, fmt::*, - types::{ToAlloy, ToEthers}, TransactionReceiptWithRevertReason, }; use foundry_config::Chain; use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; use std::{ + borrow::Cow, io, + marker::PhantomData, path::PathBuf, str::FromStr, sync::atomic::{AtomicBool, Ordering}, }; use tokio::signal::ctrl_c; -use tx::TxBuilderPeekOutput; use foundry_common::abi::encode_function_args_packed; pub use foundry_evm::*; -pub use rusoto_core::{ - credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, - request::HttpClient as AwsHttpClient, Client as AwsClient, -}; -pub use rusoto_kms::KmsClient; -pub use tx::{TxBuilder, TxBuilderOutput}; pub mod base; pub mod errors; mod rlp_converter; -mod tx; use rlp_converter::Item; // TODO: CastContract with common contract initializers? Same for CastProviders? -pub struct Cast { - provider: M, +sol! { + #[sol(rpc)] + interface IERC20 { + #[derive(Debug)] + function balanceOf(address owner) external view returns (uint256); + } } -impl Cast +pub struct Cast { + provider: P, + transport: PhantomData, +} + +impl Cast where - M::Error: 'static, + T: Transport + Clone, + P: Provider, { /// Creates a new Cast instance from the provided client /// @@ -68,16 +72,16 @@ where /// /// ``` /// use cast::Cast; - /// use ethers_providers::{Http, Provider}; + /// use foundry_common::provider::alloy::get_http_provider; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = get_http_provider("http://localhost:8545"); /// let cast = Cast::new(provider); /// # Ok(()) /// # } /// ``` - pub fn new(provider: M) -> Self { - Self { provider } + pub fn new(provider: P) -> Self { + Self { provider, transport: PhantomData } } /// Makes a read-only call to the specified address @@ -88,10 +92,12 @@ where /// use cast::{Cast, TxBuilder}; /// use ethers_core::types::Address; /// use ethers_providers::{Http, Provider}; + /// use foundry_common::provider::alloy::get_http_provider; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let alloy_provider = get_http_provider("http://localhost:8545"); /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; /// let sig = "function greeting(uint256 i) public returns (string)"; /// let args = vec!["5".to_owned()]; @@ -99,7 +105,7 @@ where /// TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; /// builder.set_args(sig, args).await?; /// let builder_output = builder.build(); - /// let cast = Cast::new(provider); + /// let cast = Cast::new(provider, alloy_provider); /// let data = cast.call(builder_output, None).await?; /// println!("{}", data); /// # Ok(()) @@ -107,11 +113,11 @@ where /// ``` pub async fn call<'a>( &self, - builder_output: TxBuilderOutput, + req: &WithOtherFields, + func: Option<&Function>, block: Option, ) -> Result { - let (tx, func) = builder_output; - let res = self.provider.call(&tx, block).await?; + let res = self.provider.call(req, block).await?; let mut decoded = vec![]; @@ -123,8 +129,10 @@ where // ensure the address is a contract if res.is_empty() { // check that the recipient is a contract that can be called - if let Some(NameOrAddress::Address(addr)) = tx.to() { - if let Ok(code) = self.provider.get_code(*addr, block).await { + if let Some(addr) = req.to { + if let Ok(code) = + self.provider.get_code_at(addr, block.unwrap_or_default()).await + { if code.is_empty() { eyre::bail!("contract {addr:?} does not have any code") } @@ -174,19 +182,18 @@ where /// ``` pub async fn access_list( &self, - builder_output: TxBuilderPeekOutput<'_>, + req: &WithOtherFields, block: Option, to_json: bool, ) -> Result { - let (tx, _) = builder_output; - let access_list = self.provider.create_access_list(tx, block).await?; + let access_list = self.provider.create_access_list(req, block).await?; let res = if to_json { serde_json::to_string(&access_list)? } else { let mut s = vec![format!("gas used: {}", access_list.gas_used), "access list:".to_string()]; for al in access_list.access_list.0 { - s.push(format!("- address: {}", &al.address.to_alloy().to_checksum(None))); + s.push(format!("- address: {}", &al.address.to_checksum(None))); if !al.storage_keys.is_empty() { s.push(" keys:".to_string()); for key in al.storage_keys { @@ -200,12 +207,8 @@ where Ok(res) } - pub async fn balance + Send + Sync>( - &self, - who: T, - block: Option, - ) -> Result { - Ok(self.provider.get_balance(who, block).await?.to_alloy()) + pub async fn balance(&self, who: Address, block: Option) -> Result { + Ok(self.provider.get_balance(who, block).await?) } /// Sends a transaction to the specified address @@ -236,14 +239,13 @@ where /// # Ok(()) /// # } /// ``` - pub async fn send<'a>( + pub async fn send( &self, - builder_output: TxBuilderOutput, - ) -> Result> { - let (tx, _) = builder_output; - let res = self.provider.send_transaction(tx, None).await?; + tx: WithOtherFields, + ) -> Result> { + let res = self.provider.send_transaction(tx).await?; - Ok::<_, eyre::Error>(res) + Ok(res) } /// Publishes a raw transaction to the network @@ -262,50 +264,18 @@ where /// # Ok(()) /// # } /// ``` - pub async fn publish(&self, mut raw_tx: String) -> Result> { + pub async fn publish( + &self, + mut raw_tx: String, + ) -> Result> { raw_tx = match raw_tx.strip_prefix("0x") { Some(s) => s.to_string(), None => raw_tx, }; - let tx = Bytes::from(hex::decode(raw_tx)?); - let res = self.provider.send_raw_transaction(tx.0.into()).await?; - - Ok::<_, eyre::Error>(res) - } - - /// Estimates the gas cost of a transaction - /// - /// # Example - /// - /// ```ignore - /// use alloy_primitives::U256; - /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; - /// use std::str::FromStr; - /// - /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; - /// let from = Address::from_str("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")?; - /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; - /// let sig = "greet(string)()"; - /// let args = vec!["5".to_owned()]; - /// let value = U256::from_str("1").unwrap(); - /// let mut builder = TxBuilder::new(&provider, from, Some(to), Chain::Mainnet, false).await?; - /// builder.set_value(value).set_args(sig, args).await?; - /// let builder_output = builder.peek(); - /// let cast = Cast::new(&provider); - /// let data = cast.estimate(builder_output).await?; - /// println!("{}", data); - /// # Ok(()) - /// # } - /// ``` - pub async fn estimate(&self, builder_output: TxBuilderPeekOutput<'_>) -> Result { - let (tx, _) = builder_output; + let tx = hex::decode(raw_tx)?; + let res = self.provider.send_raw_transaction(&tx).await?; - let res = self.provider.estimate_gas(tx, None).await?; - - Ok::<_, eyre::Error>(res.to_alloy()) + Ok(res) } /// # Example @@ -322,53 +292,39 @@ where /// # Ok(()) /// # } /// ``` - pub async fn block>( + pub async fn block>( &self, - block: T, + block: B, full: bool, field: Option, to_json: bool, ) -> Result { let block = block.into(); - let block = if full { - let block = self - .provider - .get_block_with_txs(block) - .await? - .ok_or_else(|| eyre::eyre!("block {:?} not found", block))?; - if let Some(ref field) = field { - get_pretty_block_attr(&block, field) - .unwrap_or_else(|| format!("{field} is not a valid block field")) - } else if to_json { - serde_json::to_value(&block).unwrap().to_string() - } else { - block.pretty() + if let Some(ref field) = field { + if field == "transactions" && !full { + eyre::bail!("use --full to view transactions") } + } + + let block = self + .provider + .get_block(block, full) + .await? + .ok_or_else(|| eyre::eyre!("block {:?} not found", block))?; + + let block = if let Some(ref field) = field { + get_pretty_block_attr(&block, field) + .unwrap_or_else(|| format!("{field} is not a valid block field")) + } else if to_json { + serde_json::to_value(&block).unwrap().to_string() } else { - let block = self - .provider - .get_block(block) - .await? - .ok_or_else(|| eyre::eyre!("block {:?} not found", block))?; - - if let Some(ref field) = field { - if field == "transactions" { - "use --full to view transactions".to_string() - } else { - get_pretty_block_attr(&block, field) - .unwrap_or_else(|| format!("{field} is not a valid block field")) - } - } else if to_json { - serde_json::to_value(&block).unwrap().to_string() - } else { - block.pretty() - } + block.pretty() }; Ok(block) } - async fn block_field_as_num>(&self, block: T, field: String) -> Result { + async fn block_field_as_num>(&self, block: B, field: String) -> Result { let block = block.into(); let block_field = Cast::block( self, @@ -388,18 +344,18 @@ where Ok(ret) } - pub async fn base_fee>(&self, block: T) -> Result { + pub async fn base_fee>(&self, block: B) -> Result { Cast::block_field_as_num(self, block, String::from("baseFeePerGas")).await } - pub async fn age>(&self, block: T) -> Result { + pub async fn age>(&self, block: B) -> Result { let timestamp_str = Cast::block_field_as_num(self, block, String::from("timestamp")).await?.to_string(); let datetime = DateTime::from_timestamp(timestamp_str.parse::().unwrap(), 0).unwrap(); Ok(datetime.format("%a %b %e %H:%M:%S %Y").to_string()) } - pub async fn timestamp>(&self, block: T) -> Result { + pub async fn timestamp>(&self, block: B) -> Result { Cast::block_field_as_num(self, block, "timestamp".to_string()).await } @@ -466,16 +422,16 @@ where }) } - pub async fn chain_id(&self) -> Result { - Ok(self.provider.get_chainid().await?.to_alloy()) + pub async fn chain_id(&self) -> Result { + Ok(self.provider.get_chain_id().await?) } - pub async fn block_number(&self) -> Result { + pub async fn block_number(&self) -> Result { Ok(self.provider.get_block_number().await?) } - pub async fn gas_price(&self) -> Result { - Ok(self.provider.get_gas_price().await?.to_alloy()) + pub async fn gas_price(&self) -> Result { + Ok(self.provider.get_gas_price().await?) } /// # Example @@ -495,12 +451,8 @@ where /// # Ok(()) /// # } /// ``` - pub async fn nonce + Send + Sync>( - &self, - who: T, - block: Option, - ) -> Result { - Ok(self.provider.get_transaction_count(who, block).await?.to_alloy().to()) + pub async fn nonce(&self, who: Address, block: Option) -> Result { + Ok(self.provider.get_transaction_count(who, block).await?) } /// # Example @@ -520,15 +472,11 @@ where /// # Ok(()) /// # } /// ``` - pub async fn implementation + Send + Sync>( - &self, - who: T, - block: Option, - ) -> Result { + pub async fn implementation(&self, who: Address, block: Option) -> Result { let slot = - H256::from_str("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")?; - let value = self.provider.get_storage_at(who, slot, block).await?; - let addr: H160 = value.into(); + B256::from_str("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")?; + let value = self.provider.get_storage_at(who, slot.into(), block).await?; + let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) } @@ -549,15 +497,11 @@ where /// # Ok(()) /// # } /// ``` - pub async fn admin + Send + Sync>( - &self, - who: T, - block: Option, - ) -> Result { + pub async fn admin(&self, who: Address, block: Option) -> Result { let slot = - H256::from_str("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")?; - let value = self.provider.get_storage_at(who, slot, block).await?; - let addr: H160 = value.into(); + B256::from_str("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")?; + let value = self.provider.get_storage_at(who, slot.into(), block).await?; + let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) } @@ -579,8 +523,7 @@ where /// # } /// ``` pub async fn compute_address(&self, address: Address, nonce: Option) -> Result
{ - let unpacked = - if let Some(n) = nonce { n } else { self.nonce(address.to_ethers(), None).await? }; + let unpacked = if let Some(n) = nonce { n } else { self.nonce(address, None).await? }; Ok(address.create(unpacked)) } @@ -601,17 +544,17 @@ where /// # Ok(()) /// # } /// ``` - pub async fn code + Send + Sync>( + pub async fn code( &self, - who: T, + who: Address, block: Option, disassemble: bool, ) -> Result { if disassemble { - let code = self.provider.get_code(who, block).await?.to_vec(); + let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); Ok(format_operations(disassemble_bytes(code)?)?) } else { - Ok(format!("{}", self.provider.get_code(who, block).await?)) + Ok(format!("{}", self.provider.get_code_at(who, block.unwrap_or_default()).await?)) } } @@ -632,12 +575,8 @@ where /// # Ok(()) /// # } /// ``` - pub async fn codesize + Send + Sync>( - &self, - who: T, - block: Option, - ) -> Result { - let code = self.provider.get_code(who, block).await?.to_vec(); + pub async fn codesize(&self, who: Address, block: Option) -> Result { + let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); Ok(format!("{}", code.len())) } @@ -663,15 +602,11 @@ where raw: bool, to_json: bool, ) -> Result { - let tx_hash = H256::from_str(&tx_hash).wrap_err("invalid tx hash")?; - let tx = self - .provider - .get_transaction(tx_hash) - .await? - .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; + let tx_hash = TxHash::from_str(&tx_hash).wrap_err("invalid tx hash")?; + let tx = self.provider.get_transaction_by_hash(tx_hash).await?; Ok(if raw { - format!("0x{}", hex::encode(tx.rlp())) + format!("0x{}", hex::encode(TxEnvelope::try_from(tx.inner)?.encoded_2718())) } else if let Some(field) = field { get_pretty_tx_attr(&tx, field.as_str()) .ok_or_else(|| eyre::eyre!("invalid tx field: {}", field.to_string()))? @@ -702,11 +637,11 @@ where &self, tx_hash: String, field: Option, - confs: usize, + confs: u64, cast_async: bool, to_json: bool, ) -> Result { - let tx_hash = H256::from_str(&tx_hash).wrap_err("invalid tx hash")?; + let tx_hash = TxHash::from_str(&tx_hash).wrap_err("invalid tx hash")?; let mut receipt: TransactionReceiptWithRevertReason = match self.provider.get_transaction_receipt(tx_hash).await? { @@ -717,13 +652,10 @@ where if cast_async { eyre::bail!("tx not found: {:?}", tx_hash) } else { - let tx = PendingTransaction::new(tx_hash, self.provider.provider()); - tx.confirmations(confs).await?.ok_or_else(|| { - eyre::eyre!( - "tx not found, might have been dropped from mempool: {:?}", - tx_hash - ) - })? + PendingTransactionBuilder::new(self.provider.root(), tx_hash) + .with_required_confirmations(confs) + .get_receipt() + .await? } } } @@ -761,11 +693,14 @@ where /// # Ok(()) /// # } /// ``` - pub async fn rpc(&self, method: &str, params: T) -> Result + pub async fn rpc(&self, method: &str, params: V) -> Result where - T: std::fmt::Debug + serde::Serialize + Send + Sync, + V: alloy_json_rpc::RpcParam, { - let res = self.provider.provider().request::(method, params).await?; + let res = self + .provider + .raw_request::(Cow::Owned(method.to_string()), params) + .await?; Ok(serde_json::to_string(&res)?) } @@ -789,13 +724,16 @@ where /// # Ok(()) /// # } /// ``` - pub async fn storage + Send + Sync>( + pub async fn storage( &self, - from: T, - slot: H256, + from: Address, + slot: B256, block: Option, ) -> Result { - Ok(format!("{:?}", self.provider.get_storage_at(from, slot, block).await?)) + Ok(format!( + "{:?}", + B256::from(self.provider.get_storage_at(from, slot.into(), block).await?) + )) } pub async fn filter_logs(&self, filter: Filter, to_json: bool) -> Result { @@ -851,13 +789,13 @@ where pub async fn convert_block_number( &self, block: Option, - ) -> Result, eyre::Error> { + ) -> Result, eyre::Error> { match block { Some(block) => match block { BlockId::Number(block_number) => Ok(Some(block_number)), BlockId::Hash(hash) => { - let block = self.provider.get_block(hash).await?; - Ok(block.map(|block| block.number.unwrap()).map(BlockNumber::from)) + let block = self.provider.get_block_by_hash(hash.block_hash, false).await?; + Ok(block.map(|block| block.header.number.unwrap()).map(BlockNumberOrTag::from)) } }, None => Ok(None), @@ -890,16 +828,13 @@ where filter: Filter, output: &mut dyn io::Write, to_json: bool, - ) -> Result<()> - where - ::Provider: PubsubClient, - { + ) -> Result<()> { // Initialize the subscription stream for logs - let mut subscription = self.provider.subscribe_logs(&filter).await?; + let mut subscription = self.provider.subscribe_logs(&filter).await?.into_stream(); // Check if a to_block is specified, if so, subscribe to blocks let mut block_subscription = if filter.get_to_block().is_some() { - Some(self.provider.subscribe_blocks().await?) + Some(self.provider.subscribe_blocks().await?.into_stream()) } else { None }; @@ -922,7 +857,7 @@ where Either::Right(futures::future::pending()) } => { if let (Some(block), Some(to_block)) = (block, to_block_number) { - if block.number.map_or(false, |bn| bn > to_block) { + if block.header.number.map_or(false, |bn| bn > to_block) { break; } } @@ -958,6 +893,20 @@ where Ok(()) } + + pub async fn erc20_balance( + &self, + token: Address, + owner: Address, + block: Option, + ) -> Result { + Ok(IERC20::new(token, &self.provider) + .balanceOf(owner) + .block(block.unwrap_or_default()) + .call() + .await? + ._0) + } } pub struct InterfaceSource { @@ -2027,13 +1976,13 @@ impl SimpleCast { /// ``` /// use cast::SimpleCast as Cast; /// - /// let tx = "0x02f8f582a86a82058d8459682f008508351050808303fd84948e42f2f4101563bf679975178e880fd87d3efd4e80b884659ac74b00000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000000000000000000000000000000000000007ff4e20000000000000000000000000000000000000000000000000000000000000064c001a05d429597befe2835396206781b199122f2e8297327ed4a05483339e7a8b2022aa04c23a7f70fb29dda1b4ee342fb10a625e9b8ddc6a603fb4e170d4f6f37700cb8"; - /// let (tx, sig) = Cast::decode_raw_transaction(&tx)?; + /// let tx = "0x02f8f582a86a82058d8459682f008508351050808303fd84948e42f2f4101563bf679975178e880fd87d3efd4e80b884659ac74b00000000000000000000000080f0c1c49891dcfdd40b6e0f960f84e6042bcb6f000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000000000000000000000000000000000000007ff4e20000000000000000000000000000000000000000000000000000000000000064c001a05d429597befe2835396206781b199122f2e8297327ed4a05483339e7a8b2022aa04c23a7f70fb29dda1b4ee342fb10a625e9b8ddc6a603fb4e170d4f6f37700cb8"; + /// let tx_envelope = Cast::decode_raw_transaction(&tx)?; /// # Ok::<(), eyre::Report>(()) - pub fn decode_raw_transaction(tx: &str) -> Result<(TypedTransaction, Signature)> { + pub fn decode_raw_transaction(tx: &str) -> Result { let tx_hex = hex::decode(strip_0x(tx))?; - let tx_rlp = rlp::Rlp::new(tx_hex.as_slice()); - Ok(TypedTransaction::decode_signed(&tx_rlp)?) + let tx = TxEnvelope::decode_2718(&mut tx_hex.as_slice())?; + Ok(tx) } } diff --git a/crates/cast/src/tx.rs b/crates/cast/src/tx.rs deleted file mode 100644 index 1bfd0c40ff67c..0000000000000 --- a/crates/cast/src/tx.rs +++ /dev/null @@ -1,402 +0,0 @@ -use crate::errors::FunctionSignatureError; -use alloy_json_abi::Function; -use alloy_primitives::{Address, U256}; -use ethers_core::types::{ - transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, NameOrAddress, - TransactionRequest, -}; -use ethers_providers::Middleware; -use eyre::{eyre, Result}; -use foundry_common::{ - abi::{encode_function_args, get_func, get_func_etherscan}, - types::{ToAlloy, ToEthers}, -}; -use foundry_config::Chain; -use futures::future::join_all; - -pub type TxBuilderOutput = (TypedTransaction, Option); -pub type TxBuilderPeekOutput<'a> = (&'a TypedTransaction, &'a Option); - -/// Transaction builder -/// -/// # Examples -/// -/// ``` -/// # async fn foo() -> eyre::Result<()> { -/// # use alloy_primitives::U256; -/// # use cast::TxBuilder; -/// # use foundry_config::NamedChain; -/// let provider = ethers_providers::test_provider::MAINNET.provider(); -/// let mut builder = -/// TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false).await?; -/// builder.gas(Some(U256::from(1))); -/// let (tx, _) = builder.build(); -/// # Ok(()) -/// # } -/// ``` -pub struct TxBuilder<'a, M: Middleware> { - to: Option
, - chain: Chain, - tx: TypedTransaction, - func: Option, - etherscan_api_key: Option, - provider: &'a M, -} - -impl<'a, M: Middleware> TxBuilder<'a, M> { - /// Create a new TxBuilder - /// `provider` - provider to use - /// `from` - 'from' field. Could be an ENS name - /// `to` - `to`. Could be a ENS - /// `chain` - chain to construct the tx for - /// `legacy` - use type 1 transaction - pub async fn new, T: Into>( - provider: &'a M, - from: F, - to: Option, - chain: impl Into, - legacy: bool, - ) -> Result> { - let chain = chain.into(); - let from_addr = resolve_ens(provider, from).await?; - - let mut tx: TypedTransaction = if chain.is_legacy() || legacy { - TransactionRequest::new().from(from_addr.to_ethers()).chain_id(chain.id()).into() - } else { - Eip1559TransactionRequest::new().from(from_addr.to_ethers()).chain_id(chain.id()).into() - }; - - let to_addr = if let Some(to) = to { - let addr = resolve_ens(provider, to).await?; - tx.set_to(addr.to_ethers()); - Some(addr) - } else { - None - }; - Ok(Self { to: to_addr, chain, tx, func: None, etherscan_api_key: None, provider }) - } - - /// Set gas for tx - pub fn set_gas(&mut self, v: U256) -> &mut Self { - self.tx.set_gas(v.to_ethers()); - self - } - - /// Set gas for tx, if `v` is not None - pub fn gas(&mut self, v: Option) -> &mut Self { - if let Some(value) = v { - self.set_gas(value); - } - self - } - - /// Set gas price - pub fn set_gas_price(&mut self, v: U256) -> &mut Self { - self.tx.set_gas_price(v.to_ethers()); - self - } - - /// Set gas price, if `v` is not None - pub fn gas_price(&mut self, v: Option) -> &mut Self { - if let Some(value) = v { - self.set_gas_price(value); - } - self - } - - /// Set priority gas price - pub fn set_priority_gas_price(&mut self, v: U256) -> &mut Self { - if let TypedTransaction::Eip1559(tx) = &mut self.tx { - tx.max_priority_fee_per_gas = Some(v.to_ethers()) - } - self - } - - /// Set priority gas price, if `v` is not None - pub fn priority_gas_price(&mut self, v: Option) -> &mut Self { - if let Some(value) = v { - self.set_priority_gas_price(value); - } - self - } - - /// Set value - pub fn set_value(&mut self, v: U256) -> &mut Self { - self.tx.set_value(v.to_ethers()); - self - } - - /// Set value, if `v` is not None - pub fn value(&mut self, v: Option) -> &mut Self { - if let Some(value) = v { - self.set_value(value); - } - self - } - - /// Set nonce - pub fn set_nonce(&mut self, v: U256) -> &mut Self { - self.tx.set_nonce(v.to_ethers()); - self - } - - /// Set nonce, if `v` is not None - pub fn nonce(&mut self, v: Option) -> &mut Self { - if let Some(value) = v { - self.set_nonce(value); - } - self - } - - /// Set etherscan API key. Used to look up function signature buy name - pub fn set_etherscan_api_key(&mut self, v: String) -> &mut Self { - self.etherscan_api_key = Some(v); - self - } - - /// Set etherscan API key, if `v` is not None - pub fn etherscan_api_key(&mut self, v: Option) -> &mut Self { - if let Some(value) = v { - self.set_etherscan_api_key(value); - } - self - } - - pub fn set_data(&mut self, v: Vec) -> &mut Self { - self.tx.set_data(v.into()); - self - } - - pub async fn create_args( - &mut self, - sig: &str, - args: Vec, - ) -> Result<(Vec, Function)> { - if sig.trim().is_empty() { - return Err(FunctionSignatureError::MissingSignature.into()) - } - - let args = resolve_name_args(&args, self.provider).await; - - let func = if sig.contains('(') { - // a regular function signature with parentheses - get_func(sig)? - } else if sig.starts_with("0x") { - // if only calldata is provided, returning a dummy function - get_func("x()")? - } else { - get_func_etherscan( - sig, - self.to.ok_or(FunctionSignatureError::MissingToAddress)?, - &args, - self.chain, - self.etherscan_api_key.as_ref().ok_or_else(|| { - FunctionSignatureError::MissingEtherscan { sig: sig.to_string() } - })?, - ) - .await? - }; - - if sig.starts_with("0x") { - Ok((hex::decode(sig)?, func)) - } else { - Ok((encode_function_args(&func, &args)?, func)) - } - } - - /// Set function arguments - /// `sig` can be: - /// * a fragment (`do(uint32,string)`) - /// * selector + abi-encoded calldata - /// (`0xcdba2fd40000000000000000000000000000000000000000000000000000000000007a69`) - /// * only function name (`do`) - in this case, etherscan lookup is performed on `tx.to`'s - /// contract - pub async fn set_args( - &mut self, - sig: &str, - args: Vec, - ) -> Result<&mut TxBuilder<'a, M>> { - let (data, func) = self.create_args(sig, args).await?; - self.tx.set_data(data.into()); - self.func = Some(func); - Ok(self) - } - - /// Set function arguments, if `value` is not None - pub async fn args( - &mut self, - value: Option<(&str, Vec)>, - ) -> Result<&mut TxBuilder<'a, M>> { - if let Some((sig, args)) = value { - return self.set_args(sig, args).await - } - Ok(self) - } - - /// Consuming build: returns typed transaction and optional function call - pub fn build(self) -> TxBuilderOutput { - (self.tx, self.func) - } - - /// Non-consuming build: peek into the tx content - pub fn peek(&self) -> TxBuilderPeekOutput { - (&self.tx, &self.func) - } -} - -async fn resolve_ens>( - provider: &M, - addr: T, -) -> Result
{ - let from_addr = match addr.into() { - NameOrAddress::Name(ref ens_name) => provider.resolve_name(ens_name).await, - NameOrAddress::Address(addr) => Ok(addr), - } - .map_err(|x| eyre!("Failed to resolve ENS name: {x}"))?; - Ok(from_addr.to_alloy()) -} - -async fn resolve_name_args(args: &[String], provider: &M) -> Vec { - join_all(args.iter().map(|arg| async { - if arg.contains('.') { - let addr = provider.resolve_name(arg).await; - match addr { - Ok(addr) => format!("{addr:?}"), - Err(_) => arg.to_string(), - } - } else { - arg.to_string() - } - })) - .await -} - -#[cfg(test)] -mod tests { - use crate::TxBuilder; - use alloy_primitives::{Address, U256}; - use async_trait::async_trait; - use ethers_core::types::{transaction::eip2718::TypedTransaction, NameOrAddress, H160}; - use ethers_providers::{JsonRpcClient, Middleware, ProviderError}; - use foundry_common::types::ToEthers; - use foundry_config::NamedChain; - use serde::{de::DeserializeOwned, Serialize}; - use std::str::FromStr; - - const ADDR_1: &str = "0000000000000000000000000000000000000001"; - const ADDR_2: &str = "0000000000000000000000000000000000000002"; - - #[derive(Debug)] - struct MyProvider {} - - #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] - #[cfg_attr(not(target_arch = "wasm32"), async_trait)] - impl JsonRpcClient for MyProvider { - type Error = ProviderError; - - async fn request( - &self, - _method: &str, - _params: T, - ) -> Result { - Err(ProviderError::CustomError("There is no request".to_string())) - } - } - #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] - #[cfg_attr(not(target_arch = "wasm32"), async_trait)] - impl Middleware for MyProvider { - type Error = ProviderError; - type Provider = MyProvider; - type Inner = MyProvider; - - fn inner(&self) -> &Self::Inner { - self - } - - async fn resolve_name(&self, ens_name: &str) -> Result { - match ens_name { - "a.eth" => Ok(H160::from_str(ADDR_1).unwrap()), - "b.eth" => Ok(H160::from_str(ADDR_2).unwrap()), - _ => unreachable!("don't know how to resolve {ens_name}"), - } - } - } - #[tokio::test(flavor = "multi_thread")] - async fn builder_new_non_legacy() -> eyre::Result<()> { - let provider = MyProvider {}; - let builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false).await?; - let (tx, args) = builder.build(); - assert_eq!(*tx.from().unwrap(), Address::from_str(ADDR_1).unwrap().to_ethers()); - assert_eq!( - *tx.to().unwrap(), - NameOrAddress::Address(Address::from_str(ADDR_2).unwrap().to_ethers()) - ); - assert_eq!(args, None); - - match tx { - TypedTransaction::Eip1559(_) => {} - _ => { - panic!("Wrong tx type"); - } - } - Ok(()) - } - - #[tokio::test(flavor = "multi_thread")] - async fn builder_new_legacy() -> eyre::Result<()> { - let provider = MyProvider {}; - let builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, true).await?; - // don't check anything other than the tx type - the rest is covered in the non-legacy case - let (tx, _) = builder.build(); - match tx { - TypedTransaction::Legacy(_) => {} - _ => { - panic!("Wrong tx type"); - } - } - Ok(()) - } - - #[tokio::test(flavor = "multi_thread")] - async fn builder_fields() -> eyre::Result<()> { - let provider = MyProvider {}; - let mut builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false) - .await - .unwrap(); - builder - .gas(Some(U256::from(12u32))) - .gas_price(Some(U256::from(34u32))) - .value(Some(U256::from(56u32))) - .nonce(Some(U256::from(78u32))); - - builder.etherscan_api_key(Some(String::from("what a lovely day"))); // not testing for this :-/ - let (tx, _) = builder.build(); - - assert_eq!(tx.gas().unwrap().as_u32(), 12); - assert_eq!(tx.gas_price().unwrap().as_u32(), 34); - assert_eq!(tx.value().unwrap().as_u32(), 56); - assert_eq!(tx.nonce().unwrap().as_u32(), 78); - assert_eq!(tx.chain_id().unwrap().as_u32(), 1); - Ok(()) - } - - #[tokio::test(flavor = "multi_thread")] - async fn builder_args() -> eyre::Result<()> { - let provider = MyProvider {}; - let mut builder = - TxBuilder::new(&provider, "a.eth", Some("b.eth"), NamedChain::Mainnet, false) - .await - .unwrap(); - builder.args(Some(("what_a_day(int)", vec![String::from("31337")]))).await?; - let (_, function_maybe) = builder.build(); - - assert_ne!(function_maybe, None); - let function = function_maybe.unwrap(); - assert_eq!(function.name, String::from("what_a_day")); - // could test function.inputs() but that should be covered by utils's unit test - Ok(()) - } -} diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 8006867f4c50f..17cddc6076c2e 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -24,9 +24,10 @@ alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-genesis.workspace = true alloy-sol-types.workspace = true -alloy-providers.workspace = true +alloy-provider.workspace = true alloy-rpc-types.workspace = true -alloy-signer = { workspace = true, features = ["mnemonic", "keystore"] } +alloy-signer.workspace = true +alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } parking_lot = "0.12" eyre.workspace = true diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index 231b47c97eef1..d9022d1b3f086 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -2,7 +2,6 @@ use crate::{string, Cheatcode, Cheatcodes, Error, Result, Vm::*}; use alloy_dyn_abi::DynSolType; -use alloy_primitives::Bytes; use alloy_sol_types::SolValue; use std::{env, sync::OnceLock}; @@ -233,7 +232,7 @@ impl Cheatcode for envOr_12Call { impl Cheatcode for envOr_13Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name, delim, defaultValue } = self; - let default = defaultValue.iter().map(|vec| vec.clone().into()).collect::>(); + let default = defaultValue.to_vec(); env_array_default(name, delim, &default, &DynSolType::Bytes) } } diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 8b5f8102d8e33..508e7173ee770 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -1,6 +1,7 @@ use crate::Vm; use alloy_primitives::{Address, Bytes}; -use alloy_signer::{Error as SignerError, WalletError}; +use alloy_signer::Error as SignerError; +use alloy_signer_wallet::WalletError; use alloy_sol_types::SolError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index d7328fcc0ea76..b8f55b37c2f77 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -3,7 +3,6 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_genesis::{Genesis, GenesisAccount}; use alloy_primitives::{Address, Bytes, B256, U256}; -use alloy_signer::Signer; use alloy_sol_types::SolValue; use foundry_common::fs::{read_json_file, write_json_file}; use foundry_evm_core::{ @@ -14,7 +13,10 @@ use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, InnerEvmContext, }; -use std::{collections::HashMap, path::Path}; +use std::{ + collections::{BTreeMap, HashMap}, + path::Path, +}; mod fork; pub(crate) mod mapping; @@ -74,7 +76,7 @@ impl Cheatcode for loadAllocsCall { ensure!(path.exists(), "allocs file does not exist: {pathToAllocsJson}"); // Let's first assume we're reading a file with only the allocs. - let allocs: HashMap = match read_json_file(path) { + let allocs: BTreeMap = match read_json_file(path) { Ok(allocs) => allocs, Err(_) => { // Let's try and read from a genesis file, and extract allocs. @@ -112,7 +114,7 @@ impl Cheatcode for dumpStateCall { .ecx .journaled_state .state() - .into_iter() + .iter_mut() .filter(|(key, val)| !skip(key, val)) .map(|(key, val)| { ( diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index f5402a0d38d29..d2a8ff4ebbeba 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,10 +1,10 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{B256, U256}; -use alloy_providers::tmp::TempProvider; +use alloy_provider::Provider; use alloy_rpc_types::Filter; use alloy_sol_types::SolValue; use eyre::WrapErr; -use foundry_common::{provider::alloy::ProviderBuilder, types::ToEthers}; +use foundry_common::provider::alloy::ProviderBuilder; use foundry_compilers::utils::RuntimeOrHandle; use foundry_evm_core::fork::CreateFork; @@ -64,7 +64,12 @@ impl Cheatcode for createSelectFork_2Call { impl Cheatcode for rollFork_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { blockNumber } = self; - ccx.ecx.db.roll_fork(None, *blockNumber, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state)?; + ccx.ecx.db.roll_fork( + None, + (*blockNumber).to(), + &mut ccx.ecx.env, + &mut ccx.ecx.journaled_state, + )?; Ok(Default::default()) } } @@ -87,7 +92,7 @@ impl Cheatcode for rollFork_2Call { let Self { forkId, blockNumber } = self; ccx.ecx.db.roll_fork( Some(*forkId), - *blockNumber, + (*blockNumber).to(), &mut ccx.ecx.env, &mut ccx.ecx.journaled_state, )?; @@ -225,7 +230,7 @@ impl Cheatcode for rpcCall { let method: &'static str = Box::new(method.clone()).leak(); let params_json: serde_json::Value = serde_json::from_str(params)?; let result = RuntimeOrHandle::new() - .block_on(provider.raw_request(method, params_json)) + .block_on(provider.raw_request(method.into(), params_json)) .map_err(|err| fmt_err!("{method:?}: {err}"))?; let result_as_tokens = crate::json::json_value_to_token(&result) @@ -252,36 +257,35 @@ impl Cheatcode for eth_getLogsCall { let provider = ProviderBuilder::new(&url).build()?; let mut filter = Filter::new().address(*target).from_block(from_block).to_block(to_block); for (i, topic) in topics.iter().enumerate() { - let topic = topic.to_ethers(); // todo: needed because rust wants to convert FixedBytes<32> to U256 to convert it back // to FixedBytes<32> and then to Topic for some reason removing the // From impl in alloy does not fix the situation, and it is not possible to impl // From> either because of a conflicting impl match i { - 0 => filter = filter.event_signature(U256::from_be_bytes(topic.to_fixed_bytes())), - 1 => filter = filter.topic1(U256::from_be_bytes(topic.to_fixed_bytes())), - 2 => filter = filter.topic2(U256::from_be_bytes(topic.to_fixed_bytes())), - 3 => filter = filter.topic3(U256::from_be_bytes(topic.to_fixed_bytes())), + 0 => filter = filter.event_signature(*topic), + 1 => filter = filter.topic1(*topic), + 2 => filter = filter.topic2(*topic), + 3 => filter = filter.topic3(*topic), _ => unreachable!(), }; } // todo: handle the errors somehow let logs = RuntimeOrHandle::new() - .block_on(provider.get_logs(filter)) + .block_on(provider.get_logs(&filter)) .wrap_err("failed to get logs")?; let eth_logs = logs .into_iter() .map(|log| EthGetLogs { - emitter: log.address, - topics: log.topics.into_iter().collect(), - data: log.data.0.into(), + emitter: log.address(), + topics: log.topics().to_vec(), + data: log.inner.data.data, blockHash: log.block_hash.unwrap_or_default(), - blockNumber: log.block_number.unwrap_or_default().to(), + blockNumber: log.block_number.unwrap_or_default(), transactionHash: log.transaction_hash.unwrap_or_default(), - transactionIndex: log.transaction_index.unwrap_or_default().to(), - logIndex: log.log_index.unwrap_or_default(), + transactionIndex: log.transaction_index.unwrap_or_default(), + logIndex: U256::from(log.log_index.unwrap_or_default()), removed: log.removed, }) .collect::>(); diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 645c14c58c82b..6a266a4108fb7 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -94,9 +94,9 @@ impl Cheatcode for mockCallRevert_1Call { fn mock_call( state: &mut Cheatcodes, callee: &Address, - cdata: &Vec, + cdata: &Bytes, value: Option<&U256>, - rdata: &Vec, + rdata: &Bytes, ret_type: InstructionResult, ) { state.mocked_calls.entry(*callee).or_default().insert( diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 54335a5e529b0..3ba07b5b6cd2a 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -495,8 +495,8 @@ fn ffi(state: &Cheatcodes, input: &[String]) -> Result { }; Ok(FfiResult { exitCode: output.status.code().unwrap_or(69), - stdout: encoded_stdout, - stderr: output.stderr, + stdout: encoded_stdout.into(), + stderr: output.stderr.into(), }) } @@ -537,6 +537,7 @@ fn prompt( mod tests { use super::*; use crate::CheatsConfig; + use alloy_primitives::Bytes; use std::sync::Arc; fn cheats() -> Cheatcodes { @@ -554,7 +555,7 @@ mod tests { let cheats = cheats(); let args = ["echo".to_string(), hex::encode(msg)]; let output = ffi(&cheats, &args).unwrap(); - assert_eq!(output.stdout, msg); + assert_eq!(output.stdout, Bytes::from(msg)); } #[test] @@ -563,7 +564,7 @@ mod tests { let cheats = cheats(); let args = ["echo".to_string(), msg.to_string()]; let output = ffi(&cheats, &args).unwrap(); - assert_eq!(output.stdout, msg.as_bytes()); + assert_eq!(output.stdout, Bytes::from(msg.as_bytes())); } #[test] diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 934cae0c75d96..cd2d49ba63073 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -15,7 +15,7 @@ use crate::{ CheatsConfig, CheatsCtxt, Error, Result, Vm, Vm::AccountAccess, }; -use alloy_primitives::{Address, Bytes, Log, B256, U256, U64}; +use alloy_primitives::{Address, Bytes, Log, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl}; @@ -447,9 +447,9 @@ impl Inspector for Cheatcodes { oldBalance: old_balance, newBalance: old_balance + value, value, - data: vec![], + data: Bytes::new(), reverted: false, - deployedCode: vec![], + deployedCode: Bytes::new(), storageAccesses: vec![], depth: ecx.journaled_state.depth(), }; @@ -554,9 +554,9 @@ impl Inspector for Cheatcodes { oldBalance: balance, newBalance: balance, value: U256::ZERO, - data: vec![], + data: Bytes::new(), reverted: false, - deployedCode: vec![], + deployedCode: Bytes::new(), storageAccesses: vec![], depth: ecx.journaled_state.depth(), }; @@ -710,7 +710,7 @@ impl Inspector for Cheatcodes { if let Some(storage_recorded_logs) = &mut self.recorded_logs { storage_recorded_logs.push(Vm::Log { topics: log.data.topics().to_vec(), - data: log.data.data.to_vec(), + data: log.data.data.clone(), emitter: log.address, }); } @@ -870,9 +870,9 @@ impl Inspector for Cheatcodes { to: Some(call.contract), value: Some(call.transfer.value), input: TransactionInput::new(call.input.clone()), - nonce: Some(U64::from(account.info.nonce)), + nonce: Some(account.info.nonce), gas: if is_fixed_gas_limit { - Some(U256::from(call.gas_limit)) + Some(call.gas_limit as u128) } else { None }, @@ -938,9 +938,9 @@ impl Inspector for Cheatcodes { oldBalance: old_balance, newBalance: U256::ZERO, // updated on call_end value: call.transfer.value, - data: call.input.to_vec(), + data: call.input.clone(), reverted: false, - deployedCode: vec![], + deployedCode: Bytes::new(), storageAccesses: vec![], // updated on step depth: ecx.journaled_state.depth(), }]); @@ -1047,7 +1047,7 @@ impl Inspector for Cheatcodes { // The gas limit of the call. gasLimit: gas.limit(), // The total gas used. - gasTotalUsed: gas.spend(), + gasTotalUsed: gas.spent(), // The amount of gas used for memory expansion. gasMemoryUsed: gas.memory(), // The amount of gas refunded. @@ -1295,9 +1295,9 @@ impl Inspector for Cheatcodes { to, value: Some(call.value), input: TransactionInput::new(bytecode), - nonce: Some(U64::from(nonce)), + nonce: Some(nonce), gas: if is_fixed_gas_limit { - Some(U256::from(call.gas_limit)) + Some(call.gas_limit as u128) } else { None }, @@ -1365,10 +1365,10 @@ impl Inspector for Cheatcodes { oldBalance: U256::ZERO, // updated on create_end newBalance: U256::ZERO, // updated on create_end value: call.value, - data: call.init_code.to_vec(), + data: call.init_code.clone(), reverted: false, - deployedCode: vec![], // updated on create_end - storageAccesses: vec![], // updated on create_end + deployedCode: Bytes::new(), // updated on create_end + storageAccesses: vec![], // updated on create_end depth, }]); } @@ -1468,13 +1468,8 @@ impl Inspector for Cheatcodes { ecx.journaled_state.load_account(address, &mut ecx.db) { create_access.newBalance = created_acc.info.balance; - create_access.deployedCode = created_acc - .info - .code - .clone() - .unwrap_or_default() - .original_bytes() - .into(); + create_access.deployedCode = + created_acc.info.code.clone().unwrap_or_default().original_bytes(); } } } @@ -1563,10 +1558,10 @@ fn apply_create2_deployer( oldBalance: U256::ZERO, // updated on create_end newBalance: U256::ZERO, // updated on create_end value: call.value, - data: calldata, + data: calldata.into(), reverted: false, - deployedCode: vec![], // updated on create_end - storageAccesses: vec![], // updated on create_end + deployedCode: Bytes::new(), // updated on create_end + storageAccesses: vec![], // updated on create_end depth: ecx.journaled_state.depth(), }]) } @@ -1702,8 +1697,8 @@ fn append_storage_access( oldBalance: U256::ZERO, newBalance: U256::ZERO, value: U256::ZERO, - data: vec![], - deployedCode: vec![], + data: Bytes::new(), + deployedCode: Bytes::new(), depth: entry.depth, }; last.push(resume_record); diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index ff4e3a14841ab..a28a8be490ca2 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -2,7 +2,7 @@ use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, U256}; -use alloy_signer::{LocalWallet, Signer}; +use alloy_signer_wallet::LocalWallet; use foundry_config::Config; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; use parking_lot::Mutex; diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 02c747adb2ffb..2fdc99476e4bd 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -25,7 +25,7 @@ const DUMMY_CREATE_ADDRESS: Address = address!("00000000000000000000000000000000 /// This then allows us to customize the matching behavior for each call data on the /// `ExpectedCallData` struct and track how many times we've actually seen the call on the second /// element of the tuple. -pub type ExpectedCallTracker = HashMap, (ExpectedCallData, u64)>>; +pub type ExpectedCallTracker = HashMap>; #[derive(Clone, Debug)] pub struct ExpectedCallData { @@ -318,7 +318,7 @@ impl Cheatcode for expectSafeMemoryCallCall { fn expect_call( state: &mut Cheatcodes, target: &Address, - calldata: &Vec, + calldata: &Bytes, value: Option<&U256>, mut gas: Option, mut min_gas: Option, @@ -351,7 +351,7 @@ fn expect_call( "counted expected calls can only bet set once" ); expecteds.insert( - calldata.to_vec(), + calldata.clone(), (ExpectedCallData { value: value.copied(), gas, min_gas, count, call_type }, 0), ); } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index f9edc8e40d7c5..7544abc0a624b 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -2,15 +2,15 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{keccak256, Address, B256, U256}; -use alloy_signer::{ +use alloy_signer::{Signer, SignerSync}; +use alloy_signer_wallet::{ coins_bip39::{ ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, Portuguese, Spanish, Wordlist, }, - LocalWallet, MnemonicBuilder, Signer, SignerSync, + LocalWallet, MnemonicBuilder, }; use alloy_sol_types::SolValue; -use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm_core::{constants::DEFAULT_CREATE2_DEPLOYER, utils::RuntimeOrHandle}; use k256::{ ecdsa::SigningKey, @@ -157,22 +157,22 @@ fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes .abi_encode()) } -fn encode_vrs(v: u8, r: U256, s: U256) -> Vec { - (U256::from(v), B256::from(r), B256::from(s)).abi_encode() +fn encode_vrs(sig: alloy_primitives::Signature) -> Vec { + let v = sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte()); + + (U256::from(v), B256::from(sig.r()), B256::from(sig.s())).abi_encode() } pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. let wallet = parse_wallet(private_key)?; - let sig = wallet.sign_hash_sync(*digest)?; + let sig = wallet.sign_hash_sync(digest)?; let recovered = sig.recover_address_from_prehash(digest)?; assert_eq!(recovered, wallet.address()); - let v = sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte()); - - Ok(encode_vrs(v, sig.r(), sig.s())) + Ok(encode_vrs(sig)) } pub(super) fn sign_with_wallet( @@ -206,10 +206,10 @@ pub(super) fn sign_with_wallet( .block_on(wallet.sign_hash(digest)) .map_err(|err| fmt_err!("{err}"))?; - let recovered = sig.recover(digest.to_ethers()).map_err(|err| fmt_err!("{err}"))?; - assert_eq!(recovered.to_alloy(), signer); + let recovered = sig.recover_address_from_prehash(digest).map_err(|err| fmt_err!("{err}"))?; + assert_eq!(recovered, signer); - Ok(encode_vrs(sig.v as u8, sig.r.to_alloy(), sig.s.to_alloy())) + Ok(encode_vrs(sig)) } pub(super) fn sign_p256(private_key: &U256, digest: &B256, _state: &mut Cheatcodes) -> Result { diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index aad365bb52b09..fcc95d55e822d 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -22,9 +22,9 @@ foundry-compilers = { workspace = true, features = ["full"] } alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true - -ethers-core.workspace = true -ethers-providers.workspace = true +alloy-provider.workspace = true +alloy-transport.workspace = true +alloy-chains.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } color-eyre.workspace = true @@ -41,11 +41,13 @@ tracing-error = "0.2" tracing-subscriber = { workspace = true, features = ["registry", "env-filter", "fmt"] } tracing.workspace = true yansi = "0.5" +hex.workspace = true +futures = "0.3" [dev-dependencies] tempfile = "3.7" [features] default = ["rustls"] -rustls = ["ethers-providers/rustls", "foundry-wallets/rustls"] -openssl = ["ethers-providers/openssl", "foundry-compilers/openssl", "foundry-wallets/openssl"] +rustls = ["foundry-wallets/rustls"] +openssl = ["foundry-compilers/openssl"] diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index 84173eaaf4b37..81d6107bdea03 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -1,5 +1,5 @@ use crate::utils::parse_ether_value; -use alloy_primitives::U256; +use alloy_primitives::{U256, U64}; use clap::Parser; use serde::Serialize; @@ -38,7 +38,7 @@ pub struct TransactionOpts { /// Nonce for the transaction. #[arg(long)] - pub nonce: Option, + pub nonce: Option, /// Send a legacy transaction instead of an EIP1559 transaction. /// diff --git a/crates/cli/src/utils/abi.rs b/crates/cli/src/utils/abi.rs new file mode 100644 index 0000000000000..634b889ca7110 --- /dev/null +++ b/crates/cli/src/utils/abi.rs @@ -0,0 +1,61 @@ +use alloy_chains::Chain; +use alloy_json_abi::Function; +use alloy_primitives::Address; +use alloy_provider::{network::AnyNetwork, Provider}; +use alloy_transport::Transport; +use eyre::{OptionExt, Result}; +use foundry_common::{ + abi::{encode_function_args, get_func, get_func_etherscan}, + ens::NameOrAddress, +}; +use futures::future::join_all; + +async fn resolve_name_args>( + args: &[String], + provider: &P, +) -> Vec { + join_all(args.iter().map(|arg| async { + if arg.contains('.') { + let addr = NameOrAddress::Name(arg.to_string()).resolve(provider).await; + match addr { + Ok(addr) => addr.to_string(), + Err(_) => arg.to_string(), + } + } else { + arg.to_string() + } + })) + .await +} + +pub async fn parse_function_args>( + sig: &str, + args: Vec, + to: Option
, + chain: Chain, + provider: &P, + etherscan_api_key: Option<&str>, +) -> Result<(Vec, Option)> { + if sig.trim().is_empty() { + eyre::bail!("Function signature or calldata must be provided.") + } + + let args = resolve_name_args(&args, provider).await; + + if sig.starts_with("0x") { + return Ok((hex::decode(sig)?, None)); + } + + let func = if sig.contains('(') { + // a regular function signature with parentheses + get_func(sig)? + } else { + let etherscan_api_key = etherscan_api_key.ok_or_eyre( + "If you wish to fetch function data from EtherScan, please provide an API key.", + )?; + let to = to.ok_or_eyre("A 'to' address must be provided to fetch function data.")?; + get_func_etherscan(sig, to, &args, chain, etherscan_api_key).await? + }; + + Ok((encode_function_args(&func, &args)?, Some(func))) +} diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 99fcceb3e5fd1..015ce2145af68 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -1,14 +1,12 @@ use alloy_json_abi::JsonAbi; -use alloy_primitives::{utils::format_units, U256}; -use ethers_core::types::TransactionReceipt; -use ethers_providers::Middleware; +use alloy_primitives::U256; +use alloy_provider::{network::AnyNetwork, Provider}; +use alloy_transport::Transport; use eyre::{ContextCompat, Result}; -use foundry_common::types::ToAlloy; use foundry_config::{Chain, Config}; use std::{ ffi::OsStr, future::Future, - ops::Mul, path::{Path, PathBuf}, process::{Command, Output, Stdio}, time::{Duration, SystemTime, UNIX_EPOCH}, @@ -23,6 +21,9 @@ pub use cmd::*; mod suggestions; pub use suggestions::*; +mod abi; +pub use abi::*; + // reexport all `foundry_config::utils` #[doc(hidden)] pub use foundry_config::utils::*; @@ -76,28 +77,26 @@ pub fn subscriber() { } pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { - let s = abi.to_sol(name); + let s = abi.to_sol(name, None); let s = forge_fmt::format(&s)?; Ok(s) } -/// Returns a [RetryProvider](foundry_common::RetryProvider) instantiated using [Config]'s RPC URL -/// and chain. -/// -/// Defaults to `http://localhost:8545` and `Mainnet`. -pub fn get_provider(config: &Config) -> Result { +/// Returns a [RetryProvider](foundry_common::alloy::RetryProvider) instantiated using [Config]'s +/// RPC +pub fn get_provider(config: &Config) -> Result { get_provider_builder(config)?.build() } -/// Returns a [ProviderBuilder](foundry_common::ProviderBuilder) instantiated using [Config]'s RPC -/// URL and chain. +/// Returns a [ProviderBuilder](foundry_common::provider::alloy::ProviderBuilder) instantiated using +/// [Config] values. /// /// Defaults to `http://localhost:8545` and `Mainnet`. pub fn get_provider_builder( config: &Config, -) -> Result { +) -> Result { let url = config.get_rpc_url_or_localhost_http()?; - let mut builder = foundry_common::provider::ethers::ProviderBuilder::new(url.as_ref()); + let mut builder = foundry_common::provider::alloy::ProviderBuilder::new(url.as_ref()); if let Ok(chain) = config.chain.unwrap_or_default().try_into() { builder = builder.chain(chain); @@ -111,14 +110,14 @@ pub fn get_provider_builder( Ok(builder) } -pub async fn get_chain(chain: Option, provider: M) -> Result +pub async fn get_chain(chain: Option, provider: P) -> Result where - M: Middleware, - M::Error: 'static, + P: Provider, + T: Transport + Clone, { match chain { Some(chain) => Ok(chain), - None => Ok(Chain::from_id(provider.get_chainid().await?.as_u64())), + None => Ok(Chain::from_id(provider.get_chain_id().await?)), } } @@ -221,40 +220,6 @@ pub fn enable_paint() { } } -/// Prints parts of the receipt to stdout -pub fn print_receipt(chain: Chain, receipt: &TransactionReceipt) { - let gas_used = receipt.gas_used.unwrap_or_default(); - let gas_price = receipt.effective_gas_price.unwrap_or_default(); - foundry_common::shell::println(format!( - "\n##### {chain}\n{status}Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n", - status = if receipt.status.map_or(true, |s| s.is_zero()) { - "❌ [Failed]" - } else { - "✅ [Success]" - }, - tx_hash = receipt.transaction_hash, - caddr = if let Some(addr) = &receipt.contract_address { - format!("\nContract Address: {}", addr.to_alloy().to_checksum(None)) - } else { - String::new() - }, - bn = receipt.block_number.unwrap_or_default(), - gas = if gas_price.is_zero() { - format!("Gas Used: {gas_used}") - } else { - let paid = format_units(gas_used.mul(gas_price).to_alloy(), 18) - .unwrap_or_else(|_| "N/A".into()); - let gas_price = format_units(gas_price.to_alloy(), 9).unwrap_or_else(|_| "N/A".into()); - format!( - "Paid: {} ETH ({gas_used} gas * {} gwei)", - paid.trim_end_matches('0'), - gas_price.trim_end_matches('0').trim_end_matches('.') - ) - }, - )) - .expect("could not print receipt"); -} - /// Useful extensions to [`std::process::Command`]. pub trait CommandUtils { /// Returns the command's output if execution is successful, otherwise, throws an error. diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index d458786f97b15..5e7eebf829c58 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -19,21 +19,30 @@ ethers-core.workspace = true ethers-middleware.workspace = true ethers-providers = { workspace = true, features = ["ws", "ipc"] } ethers-signers.workspace = true +# should be removed along with ethers +reqwest_ethers = { package = "reqwest", version = "0.11", default-features = false } alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } alloy-rpc-types.workspace = true alloy-rpc-client.workspace = true -alloy-providers.workspace = true +alloy-provider.workspace = true alloy-transport.workspace = true -alloy-signer.workspace = true -alloy-transport-http.workspace = true +alloy-signer-wallet.workspace = true +alloy-transport-http = { workspace = true, features = ["reqwest", "reqwest-rustls-tls"] } alloy-transport-ws.workspace = true alloy-transport-ipc.workspace = true alloy-json-rpc.workspace = true alloy-pubsub.workspace = true alloy-sol-types.workspace = true +alloy-contract.workspace = true +alloy-consensus.workspace = true tower.workspace = true @@ -47,7 +56,7 @@ globset = "0.4" hex.workspace = true once_cell = "1" rand.workspace = true -reqwest = { version = "0.11", default-features = false } +reqwest = { version = "0.12", default-features = false } semver = "1" serde_json.workspace = true serde.workspace = true diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index b08620d888d16..6b7615b39c9f2 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -159,7 +159,7 @@ pub fn find_source( } /// Helper function to coerce a value to a [DynSolValue] given a type string -fn coerce_value(ty: &str, arg: &str) -> Result { +pub fn coerce_value(ty: &str, arg: &str) -> Result { let ty = DynSolType::parse(ty)?; Ok(DynSolType::coerce_str(&ty, arg)?) } diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 23ca0abab43f2..0ba0514c2b87b 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -38,7 +38,7 @@ pub const ARBITRUM_SENDER: Address = address!("000000000000000000000000000000000 pub const OPTIMISM_SYSTEM_ADDRESS: Address = address!("deaddeaddeaddeaddeaddeaddeaddeaddead0001"); /// Transaction identifier of System transaction types -pub const SYSTEM_TRANSACTION_TYPE: u64 = 126u64; +pub const SYSTEM_TRANSACTION_TYPE: u8 = 126; /// Returns whether the sender is a known L2 system sender that is the first tx in every block. /// diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs new file mode 100644 index 0000000000000..cb10583841319 --- /dev/null +++ b/crates/common/src/ens.rs @@ -0,0 +1,193 @@ +//! ENS Name resolving utilities. +#![allow(missing_docs)] +use alloy_primitives::{address, keccak256, Address, B256}; +use alloy_provider::{Network, Provider}; +use alloy_sol_types::sol; +use alloy_transport::Transport; +use async_trait::async_trait; +use std::str::FromStr; + +use self::EnsResolver::EnsResolverInstance; + +// ENS Registry and Resolver contracts. +sol! { + #[sol(rpc)] + // ENS Registry contract. + contract EnsRegistry { + /// Returns the resolver for the specified node. + function resolver(bytes32 node) view returns (address); + } + + #[sol(rpc)] + // ENS Resolver interface. + contract EnsResolver { + // Returns the address associated with the specified node. + function addr(bytes32 node) view returns (address); + + // Returns the name associated with an ENS node, for reverse records. + function name(bytes32 node) view returns (string); + } +} + +/// ENS registry address (`0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e`) +pub const ENS_ADDRESS: Address = address!("00000000000C2E074eC69A0dFb2997BA6C7d2e1e"); + +pub const ENS_REVERSE_REGISTRAR_DOMAIN: &str = "addr.reverse"; + +/// Error type for ENS resolution. +#[derive(Debug, thiserror::Error)] +pub enum EnsResolutionError { + /// Failed to resolve ENS registry. + #[error("Failed to get resolver from ENS registry: {0}")] + EnsRegistryResolutionFailed(String), + /// Failed to resolve ENS name to an address. + #[error("Failed to resolve ENS name to an address: {0}")] + EnsResolutionFailed(String), +} + +/// ENS name or Ethereum Address. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum NameOrAddress { + /// An ENS Name (format does not get checked) + Name(String), + /// An Ethereum Address + Address(Address), +} + +impl NameOrAddress { + /// Resolves the name to an Ethereum Address. + pub async fn resolve>( + &self, + provider: &P, + ) -> Result { + match self { + NameOrAddress::Name(name) => provider.resolve_name(name).await, + NameOrAddress::Address(addr) => Ok(*addr), + } + } +} + +impl From for NameOrAddress { + fn from(name: String) -> Self { + NameOrAddress::Name(name) + } +} + +impl From<&String> for NameOrAddress { + fn from(name: &String) -> Self { + NameOrAddress::Name(name.clone()) + } +} + +impl From
for NameOrAddress { + fn from(addr: Address) -> Self { + NameOrAddress::Address(addr) + } +} + +impl FromStr for NameOrAddress { + type Err =
::Err; + + fn from_str(s: &str) -> Result { + if let Ok(addr) = Address::from_str(s) { + Ok(NameOrAddress::Address(addr)) + } else { + Ok(NameOrAddress::Name(s.to_string())) + } + } +} + +#[async_trait] +pub trait ProviderEnsExt> { + async fn get_resolver(&self) -> Result, EnsResolutionError>; + + async fn resolve_name(&self, name: &str) -> Result { + let node = namehash(name); + let addr = self + .get_resolver() + .await? + .addr(node) + .call() + .await + .map_err(|err| EnsResolutionError::EnsResolutionFailed(err.to_string()))? + ._0; + + Ok(addr) + } + + async fn lookup_address(&self, address: Address) -> Result { + let node = namehash(&reverse_address(address)); + let name = self + .get_resolver() + .await? + .name(node) + .call() + .await + .map_err(|err| EnsResolutionError::EnsResolutionFailed(err.to_string()))? + ._0; + + Ok(name) + } +} + +#[async_trait] +impl ProviderEnsExt for P +where + P: Provider, + N: Network, + T: Transport + Clone, +{ + async fn get_resolver(&self) -> Result, EnsResolutionError> { + let registry = EnsRegistry::new(ENS_ADDRESS, self); + let address = registry + .resolver(namehash("eth")) + .call() + .await + .map_err(|err| EnsResolutionError::EnsRegistryResolutionFailed(err.to_string()))? + ._0; + + Ok(EnsResolverInstance::new(address, self)) + } +} + +/// Returns the ENS namehash as specified in [EIP-137](https://eips.ethereum.org/EIPS/eip-137) +pub fn namehash(name: &str) -> B256 { + if name.is_empty() { + return B256::ZERO + } + + // Remove the variation selector U+FE0F + let name = name.replace('\u{fe0f}', ""); + + // Generate the node starting from the right + name.rsplit('.') + .fold([0u8; 32], |node, label| *keccak256([node, *keccak256(label.as_bytes())].concat())) + .into() +} + +/// Returns the reverse-registrar name of an address. +pub fn reverse_address(addr: Address) -> String { + format!("{addr:?}.{ENS_REVERSE_REGISTRAR_DOMAIN}")[2..].to_string() +} + +#[cfg(test)] +mod test { + use super::*; + + fn assert_hex(hash: B256, val: &str) { + assert_eq!(hash.0.to_vec(), hex::decode(val).unwrap()); + } + + #[test] + fn test_namehash() { + for (name, expected) in &[ + ("", "0000000000000000000000000000000000000000000000000000000000000000"), + ("foo.eth", "de9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f"), + ("eth", "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae"), + ("alice.eth", "0x787192fc5378cc32aa956ddfdedbf26b24e8d78e40109add0eea2c1a012c3dec"), + ("ret↩️rn.eth", "0x3de5f4c02db61b221e7de7f1c40e29b6e2f07eb48d65bf7e304715cd9ed33b24"), + ] { + assert_hex(namehash(name), expected); + } + } +} diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 5549f36abc5fb..c5bdf6c130e04 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -1,8 +1,12 @@ //! Helper trait and functions to format Ethereum types. use crate::TransactionReceiptWithRevertReason; +use alloy_consensus::{AnyReceiptEnvelope, Receipt, ReceiptWithBloom, TxType}; use alloy_primitives::*; -use ethers_core::types::{Block, Log, OtherFields, Transaction, TransactionReceipt, TxHash}; +use alloy_rpc_types::{ + other::OtherFields, AnyTransactionReceipt, Block, BlockTransactions, Log, Transaction, + TransactionReceipt, +}; use serde::Deserialize; /// length of the name column for pretty formatting `{:>20}{value}` @@ -23,6 +27,12 @@ pub trait UIfmt { fn pretty(&self) -> String; } +impl UIfmt for &T { + fn pretty(&self) -> String { + (*self).pretty() + } +} + impl UIfmt for Option { fn pretty(&self) -> String { if let Some(ref inner) = self { @@ -33,7 +43,7 @@ impl UIfmt for Option { } } -impl UIfmt for Vec { +impl UIfmt for [T] { fn pretty(&self) -> String { if !self.is_empty() { let mut s = String::with_capacity(self.len() * 64); @@ -59,13 +69,25 @@ impl UIfmt for String { } } +impl UIfmt for u64 { + fn pretty(&self) -> String { + self.to_string() + } +} + +impl UIfmt for u128 { + fn pretty(&self) -> String { + self.to_string() + } +} + impl UIfmt for bool { fn pretty(&self) -> String { self.to_string() } } -impl UIfmt for U256 { +impl UIfmt for Uint { fn pretty(&self) -> String { self.to_string() } @@ -89,6 +111,12 @@ impl UIfmt for Bloom { } } +impl UIfmt for TxType { + fn pretty(&self) -> String { + (*self as u8).to_string() + } +} + impl UIfmt for Vec { fn pretty(&self) -> String { self[..].pretty() @@ -119,32 +147,34 @@ impl UIfmt for [u8] { } } -impl UIfmt for U64 { - fn pretty(&self) -> String { - self.to_string() - } -} - -impl UIfmt for TransactionReceipt { +impl UIfmt for AnyTransactionReceipt { fn pretty(&self) -> String { let Self { - transaction_hash, - transaction_index, - block_hash, - block_number, - from, - to, - cumulative_gas_used, - gas_used, - contract_address, - logs, - status, - root, - logs_bloom, - transaction_type, - effective_gas_price, + inner: + TransactionReceipt { + transaction_hash, + transaction_index, + block_hash, + block_number, + from, + to, + gas_used, + contract_address, + state_root, + effective_gas_price, + inner: + AnyReceiptEnvelope { + r#type: transaction_type, + inner: + ReceiptWithBloom { + receipt: Receipt { status, cumulative_gas_used, logs }, + logs_bloom, + }, + }, + blob_gas_price, + blob_gas_used, + }, other, - .. } = self; let mut pretty = format!( @@ -162,7 +192,9 @@ root {} status {} transactionHash {} transactionIndex {} -type {}", +type {} +blobGasPrice {} +blobGasUsed {}", block_hash.pretty(), block_number.pretty(), contract_address.pretty(), @@ -170,13 +202,15 @@ type {}", effective_gas_price.pretty(), from.pretty(), gas_used.pretty(), - serde_json::to_string(logs).unwrap(), + serde_json::to_string(&logs).unwrap(), logs_bloom.pretty(), - root.pretty(), + state_root.pretty(), status.pretty(), transaction_hash.pretty(), transaction_index.pretty(), - transaction_type.pretty() + transaction_type, + blob_gas_price.pretty(), + blob_gas_used.pretty(), ); if let Some(to) = to { @@ -205,40 +239,38 @@ removed: {} topics: {} transactionHash: {} transactionIndex: {}", - self.address.pretty(), + self.address().pretty(), self.block_hash.pretty(), self.block_number.pretty(), - self.data.pretty(), + self.data().data.pretty(), self.log_index.pretty(), self.removed.pretty(), - self.topics.pretty(), + self.topics().pretty(), self.transaction_hash.pretty(), self.transaction_index.pretty(), ) } } -impl UIfmt for Block { +impl UIfmt for Block { fn pretty(&self) -> String { format!( " {} -transactions {}", +transactions: {}", pretty_block_basics(self), self.transactions.pretty() ) } } -impl UIfmt for Block { +impl UIfmt for BlockTransactions { fn pretty(&self) -> String { - format!( - " -{} -transactions: {}", - pretty_block_basics(self), - self.transactions.pretty() - ) + match self { + BlockTransactions::Hashes(hashes) => hashes.pretty(), + BlockTransactions::Full(transactions) => transactions.pretty(), + BlockTransactions::Uncle => String::new(), + } } } @@ -285,12 +317,12 @@ value {}{}", self.gas_price.pretty(), self.hash.pretty(), self.input.pretty(), - self.nonce.pretty(), - to_bytes(self.r).pretty(), - to_bytes(self.s).pretty(), + self.nonce, + self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), + self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), self.to.pretty(), self.transaction_index.pretty(), - self.v.pretty(), + self.signature.map(|s| s.v).pretty(), self.value.pretty(), self.other.pretty() ) @@ -367,13 +399,6 @@ mod temp_ethers { with_alloy!(Address, Bloom, H64, H256, I256, U256, U64); } -/// Convert a U256 to bytes -pub fn to_bytes(uint: ethers_core::types::U256) -> [u8; 32] { - let mut buffer: [u8; 32] = [0; 32]; - uint.to_big_endian(&mut buffer); - buffer -} - /// Returns the `UiFmt::pretty()` formatted attribute of the transactions pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option { match attr { @@ -384,12 +409,12 @@ pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option Some(transaction.gas_price.pretty()), "hash" => Some(transaction.hash.pretty()), "input" => Some(transaction.input.pretty()), - "nonce" => Some(transaction.nonce.pretty()), - "s" => Some(to_bytes(transaction.s).pretty()), - "r" => Some(to_bytes(transaction.r).pretty()), + "nonce" => Some(transaction.nonce.to_string()), + "s" => transaction.signature.map(|s| B256::from(s.s).pretty()), + "r" => transaction.signature.map(|s| B256::from(s.r).pretty()), "to" => Some(transaction.to.pretty()), "transactionIndex" | "transaction_index" => Some(transaction.transaction_index.pretty()), - "v" => Some(transaction.v.pretty()), + "v" => transaction.signature.map(|s| s.v.pretty()), "value" => Some(transaction.value.pretty()), other => { if let Some(value) = transaction.other.get(other) { @@ -410,49 +435,50 @@ pub fn get_pretty_tx_receipt_attr( "blockNumber" | "block_number" => Some(receipt.receipt.block_number.pretty()), "contractAddress" | "contract_address" => Some(receipt.receipt.contract_address.pretty()), "cumulativeGasUsed" | "cumulative_gas_used" => { - Some(receipt.receipt.cumulative_gas_used.pretty()) + Some(receipt.receipt.inner.inner.inner.receipt.cumulative_gas_used.pretty()) } "effectiveGasPrice" | "effective_gas_price" => { - Some(receipt.receipt.effective_gas_price.pretty()) + Some(receipt.receipt.effective_gas_price.to_string()) + } + "gasUsed" | "gas_used" => Some(receipt.receipt.gas_used.to_string()), + "logs" => Some(receipt.receipt.inner.inner.inner.receipt.logs.as_slice().pretty()), + "logsBloom" | "logs_bloom" => Some(receipt.receipt.inner.inner.inner.logs_bloom.pretty()), + "root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root.pretty()), + "status" | "statusCode" | "status_code" => { + Some(receipt.receipt.inner.inner.inner.receipt.status.pretty()) } - "gasUsed" | "gas_used" => Some(receipt.receipt.gas_used.pretty()), - "logs" => Some(receipt.receipt.logs.pretty()), - "logsBloom" | "logs_bloom" => Some(receipt.receipt.logs_bloom.pretty()), - "root" => Some(receipt.receipt.root.pretty()), - "status" => Some(receipt.receipt.status.pretty()), "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), "transactionIndex" | "transaction_index" => { - Some(receipt.receipt.transaction_index.pretty()) + Some(receipt.receipt.transaction_index.to_string()) } - "type" | "transaction_type" => Some(receipt.receipt.transaction_type.pretty()), + "type" | "transaction_type" => Some(receipt.receipt.inner.inner.r#type.to_string()), "revertReason" | "revert_reason" => Some(receipt.revert_reason.pretty()), _ => None, } } /// Returns the `UiFmt::pretty()` formatted attribute of the given block -pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option { +pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option { match attr { - "baseFeePerGas" | "base_fee_per_gas" => Some(block.base_fee_per_gas.pretty()), - "difficulty" => Some(block.difficulty.pretty()), - "extraData" | "extra_data" => Some(block.extra_data.pretty()), - "gasLimit" | "gas_limit" => Some(block.gas_limit.pretty()), - "gasUsed" | "gas_used" => Some(block.gas_used.pretty()), - "hash" => Some(block.hash.pretty()), - "logsBloom" | "logs_bloom" => Some(block.logs_bloom.pretty()), - "miner" | "author" => Some(block.author.pretty()), - "mixHash" | "mix_hash" => Some(block.mix_hash.pretty()), - "nonce" => Some(block.nonce.pretty()), - "number" => Some(block.number.pretty()), - "parentHash" | "parent_hash" => Some(block.parent_hash.pretty()), - "transactionsRoot" | "transactions_root" => Some(block.transactions_root.pretty()), - "receiptsRoot" | "receipts_root" => Some(block.receipts_root.pretty()), - "sealFields" | "seal_fields" => Some(block.seal_fields.pretty()), - "sha3Uncles" | "sha_3_uncles" => Some(block.uncles_hash.pretty()), + "baseFeePerGas" | "base_fee_per_gas" => Some(block.header.base_fee_per_gas.pretty()), + "difficulty" => Some(block.header.difficulty.pretty()), + "extraData" | "extra_data" => Some(block.header.extra_data.pretty()), + "gasLimit" | "gas_limit" => Some(block.header.gas_limit.pretty()), + "gasUsed" | "gas_used" => Some(block.header.gas_used.pretty()), + "hash" => Some(block.header.hash.pretty()), + "logsBloom" | "logs_bloom" => Some(block.header.logs_bloom.pretty()), + "miner" | "author" => Some(block.header.miner.pretty()), + "mixHash" | "mix_hash" => Some(block.header.mix_hash.pretty()), + "nonce" => Some(block.header.nonce.pretty()), + "number" => Some(block.header.number.pretty()), + "parentHash" | "parent_hash" => Some(block.header.parent_hash.pretty()), + "transactionsRoot" | "transactions_root" => Some(block.header.transactions_root.pretty()), + "receiptsRoot" | "receipts_root" => Some(block.header.receipts_root.pretty()), + "sha3Uncles" | "sha_3_uncles" => Some(block.header.uncles_hash.pretty()), "size" => Some(block.size.pretty()), - "stateRoot" | "state_root" => Some(block.state_root.pretty()), - "timestamp" => Some(block.timestamp.pretty()), - "totalDifficulty" | "total_difficult" => Some(block.total_difficulty.pretty()), + "stateRoot" | "state_root" => Some(block.header.state_root.pretty()), + "timestamp" => Some(block.header.timestamp.pretty()), + "totalDifficulty" | "total_difficult" => Some(block.header.total_difficulty.pretty()), other => { if let Some(value) = block.other.get(other) { let val = EthValue::from(value.clone()); @@ -463,7 +489,7 @@ pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option(block: &Block) -> String { +fn pretty_block_basics(block: &Block) -> String { format!( " baseFeePerGas {} @@ -480,34 +506,32 @@ number {} parentHash {} transactionsRoot {} receiptsRoot {} -sealFields {} sha3Uncles {} size {} stateRoot {} timestamp {} withdrawalsRoot {} totalDifficulty {}{}", - block.base_fee_per_gas.pretty(), - block.difficulty.pretty(), - block.extra_data.pretty(), - block.gas_limit.pretty(), - block.gas_used.pretty(), - block.hash.pretty(), - block.logs_bloom.pretty(), - block.author.pretty(), - block.mix_hash.pretty(), - block.nonce.pretty(), - block.number.pretty(), - block.parent_hash.pretty(), - block.transactions_root.pretty(), - block.receipts_root.pretty(), - block.seal_fields.pretty(), - block.uncles_hash.pretty(), + block.header.base_fee_per_gas.pretty(), + block.header.difficulty.pretty(), + block.header.extra_data.pretty(), + block.header.gas_limit.pretty(), + block.header.gas_used.pretty(), + block.header.hash.pretty(), + block.header.logs_bloom.pretty(), + block.header.miner.pretty(), + block.header.mix_hash.pretty(), + block.header.nonce.pretty(), + block.header.number.pretty(), + block.header.parent_hash.pretty(), + block.header.transactions_root.pretty(), + block.header.receipts_root.pretty(), + block.header.uncles_hash.pretty(), block.size.pretty(), - block.state_root.pretty(), - block.timestamp.pretty(), - block.withdrawals_root.pretty(), - block.total_difficulty.pretty(), + block.header.state_root.pretty(), + block.header.timestamp.pretty(), + block.header.withdrawals_root.pretty(), + block.header.total_difficulty.pretty(), block.other.pretty() ) } @@ -594,7 +618,7 @@ txType 0 #[test] fn print_block_w_txs() { let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":[{"hash":"0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067","nonce":"0x2","blockHash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","blockNumber":"0x3","transactionIndex":"0x0","from":"0xfdcedc3bfca10ecb0890337fbdd1977aba84807a","to":"0xdca8ce283150ab773bcbeb8d38289bdb5661de1e","value":"0x0","gas":"0x15f90","gasPrice":"0x4a817c800","input":"0x","v":"0x25","r":"0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88","s":"0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e"}],"uncles":[]}"#; - let block: Block = serde_json::from_str(block).unwrap(); + let block: Block = serde_json::from_str(block).unwrap(); let output ="\nblockHash 0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972 blockNumber 3 from 0xFdCeDC3bFca10eCb0890337fbdD1977aba84807a @@ -609,7 +633,11 @@ to 0xdca8ce283150AB773BCbeB8d38289bdB5661dE1e transactionIndex 0 v 37 value 0".to_string(); - let generated = block.transactions[0].pretty(); + let txs = match block.transactions { + BlockTransactions::Full(txs) => txs, + _ => panic!("not full transactions"), + }; + let generated = txs[0].pretty(); assert_eq!(generated.as_str(), output.as_str()); } @@ -657,45 +685,40 @@ value 0".to_string(); #[test] fn test_pretty_tx_attr() { let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":[{"hash":"0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067","nonce":"0x2","blockHash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","blockNumber":"0x3","transactionIndex":"0x0","from":"0xfdcedc3bfca10ecb0890337fbdd1977aba84807a","to":"0xdca8ce283150ab773bcbeb8d38289bdb5661de1e","value":"0x0","gas":"0x15f90","gasPrice":"0x4a817c800","input":"0x","v":"0x25","r":"0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88","s":"0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e"}],"uncles":[]}"#; - let block: Block = serde_json::from_str(block).unwrap(); - assert_eq!(None, get_pretty_tx_attr(&block.transactions[0], "")); - assert_eq!( - Some("3".to_string()), - get_pretty_tx_attr(&block.transactions[0], "blockNumber") - ); + let block: Block = serde_json::from_str(block).unwrap(); + let txs = match block.transactions { + BlockTransactions::Full(txes) => txes, + _ => panic!("not full transactions"), + }; + assert_eq!(None, get_pretty_tx_attr(&txs[0], "")); + assert_eq!(Some("3".to_string()), get_pretty_tx_attr(&txs[0], "blockNumber")); assert_eq!( Some("0xFdCeDC3bFca10eCb0890337fbdD1977aba84807a".to_string()), - get_pretty_tx_attr(&block.transactions[0], "from") - ); - assert_eq!(Some("90000".to_string()), get_pretty_tx_attr(&block.transactions[0], "gas")); - assert_eq!( - Some("20000000000".to_string()), - get_pretty_tx_attr(&block.transactions[0], "gasPrice") + get_pretty_tx_attr(&txs[0], "from") ); + assert_eq!(Some("90000".to_string()), get_pretty_tx_attr(&txs[0], "gas")); + assert_eq!(Some("20000000000".to_string()), get_pretty_tx_attr(&txs[0], "gasPrice")); assert_eq!( Some("0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067".to_string()), - get_pretty_tx_attr(&block.transactions[0], "hash") + get_pretty_tx_attr(&txs[0], "hash") ); - assert_eq!(Some("0x".to_string()), get_pretty_tx_attr(&block.transactions[0], "input")); - assert_eq!(Some("2".to_string()), get_pretty_tx_attr(&block.transactions[0], "nonce")); + assert_eq!(Some("0x".to_string()), get_pretty_tx_attr(&txs[0], "input")); + assert_eq!(Some("2".to_string()), get_pretty_tx_attr(&txs[0], "nonce")); assert_eq!( Some("0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88".to_string()), - get_pretty_tx_attr(&block.transactions[0], "r") + get_pretty_tx_attr(&txs[0], "r") ); assert_eq!( Some("0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e".to_string()), - get_pretty_tx_attr(&block.transactions[0], "s") + get_pretty_tx_attr(&txs[0], "s") ); assert_eq!( Some("0xdca8ce283150AB773BCbeB8d38289bdB5661dE1e".into()), - get_pretty_tx_attr(&block.transactions[0], "to") - ); - assert_eq!( - Some("0".to_string()), - get_pretty_tx_attr(&block.transactions[0], "transactionIndex") + get_pretty_tx_attr(&txs[0], "to") ); - assert_eq!(Some("37".to_string()), get_pretty_tx_attr(&block.transactions[0], "v")); - assert_eq!(Some("0".to_string()), get_pretty_tx_attr(&block.transactions[0], "value")); + assert_eq!(Some("0".to_string()), get_pretty_tx_attr(&txs[0], "transactionIndex")); + assert_eq!(Some("37".to_string()), get_pretty_tx_attr(&txs[0], "v")); + assert_eq!(Some("0".to_string()), get_pretty_tx_attr(&txs[0], "value")); } #[test] @@ -731,7 +754,7 @@ value 0".to_string(); } ); - let block: Block<()> = serde_json::from_value(json).unwrap(); + let block: Block = serde_json::from_value(json).unwrap(); assert_eq!(None, get_pretty_block_attr(&block, "")); assert_eq!(Some("7".to_string()), get_pretty_block_attr(&block, "baseFeePerGas")); diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index c2825ac2f9977..36298ae8fe768 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -12,6 +12,7 @@ pub mod calc; pub mod compile; pub mod constants; pub mod contracts; +pub mod ens; pub mod errors; pub mod evm; pub mod fmt; diff --git a/crates/common/src/provider/alloy.rs b/crates/common/src/provider/alloy.rs index 54c9085a15ee6..e76a898bd8144 100644 --- a/crates/common/src/provider/alloy.rs +++ b/crates/common/src/provider/alloy.rs @@ -3,9 +3,12 @@ use crate::{ provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, }; -use alloy_primitives::U256; -use alloy_providers::tmp::{Provider, TempProvider}; +use alloy_provider::{ + network::AnyNetwork, utils::Eip1559Estimation, Provider, + ProviderBuilder as AlloyProviderBuilder, RootProvider, +}; use alloy_rpc_client::ClientBuilder; +use alloy_transport::Transport; use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use eyre::{Result, WrapErr}; use foundry_common::types::ToAlloy; @@ -25,7 +28,7 @@ use super::{ }; /// Helper type alias for a retry provider -pub type RetryProvider = Provider>; +pub type RetryProvider = RootProvider, N>; /// Helper type alias for a rpc url pub type RpcUrl = String; @@ -239,8 +242,10 @@ impl ProviderBuilder { .build(); let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); - // todo: provider polling interval - Ok(Provider::new_with_client(client)) + let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() + .on_provider(RootProvider::new(client)); + + Ok(provider) } } @@ -250,14 +255,14 @@ impl ProviderBuilder { /// - polygon /// /// Fallback is the default [`Provider::estimate_eip1559_fees`] implementation -pub async fn estimate_eip1559_fees( +pub async fn estimate_eip1559_fees, T: Transport + Clone>( provider: &P, chain: Option, -) -> Result<(U256, U256)> { +) -> Result { let chain = if let Some(chain) = chain { chain } else { - provider.get_chain_id().await.wrap_err("Failed to get chain id")?.to() + provider.get_chain_id().await.wrap_err("Failed to get chain id")? }; if let Ok(chain) = NamedChain::try_from(chain) { @@ -272,7 +277,12 @@ pub async fn estimate_eip1559_fees( }; let estimator = Polygon::new(chain)?.category(GasCategory::Standard); let (a, b) = estimator.estimate_eip1559_fees().await?; - return Ok((a.to_alloy(), b.to_alloy())); + + let estimation = Eip1559Estimation { + max_fee_per_gas: a.to_alloy().to(), + max_priority_fee_per_gas: b.to_alloy().to(), + }; + return Ok(estimation) } _ => {} } diff --git a/crates/common/src/provider/ethers.rs b/crates/common/src/provider/ethers.rs index 0d4acd2ce3776..7d99763de3211 100644 --- a/crates/common/src/provider/ethers.rs +++ b/crates/common/src/provider/ethers.rs @@ -4,8 +4,6 @@ use crate::{ runtime_client::{RuntimeClient, RuntimeClientBuilder}, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, }; -use ethers_core::types::U256; -use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; use ethers_providers::{is_local_endpoint, Middleware, Provider, DEFAULT_LOCAL_POLL_INTERVAL}; use eyre::{Result, WrapErr}; use foundry_config::NamedChain; @@ -251,44 +249,6 @@ impl ProviderBuilder { } } -/// Estimates EIP1559 fees depending on the chain -/// -/// Uses custom gas oracles for -/// - polygon -/// -/// Fallback is the default [`Provider::estimate_eip1559_fees`] implementation -pub async fn estimate_eip1559_fees( - provider: &M, - chain: Option, -) -> Result<(U256, U256)> -where - M::Error: 'static, -{ - let chain = if let Some(chain) = chain { - chain - } else { - provider.get_chainid().await.wrap_err("Failed to get chain id")?.as_u64() - }; - - if let Ok(chain) = NamedChain::try_from(chain) { - // handle chains that deviate from `eth_feeHistory` and have their own oracle - match chain { - NamedChain::Polygon | NamedChain::PolygonMumbai => { - // TODO: phase this out somehow - let chain = match chain { - NamedChain::Polygon => ethers_core::types::Chain::Polygon, - NamedChain::PolygonMumbai => ethers_core::types::Chain::PolygonMumbai, - _ => unreachable!(), - }; - let estimator = Polygon::new(chain)?.category(GasCategory::Standard); - return Ok(estimator.estimate_eip1559_fees().await?); - } - _ => {} - } - } - provider.estimate_eip1559_fees(None).await.wrap_err("Failed fetch EIP1559 fees") -} - #[cfg(not(windows))] fn resolve_path(path: &Path) -> Result { if path.is_absolute() { diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index e7277bd4b1984..b6adfb646be86 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -49,6 +49,9 @@ impl RetryPolicy for RateLimitRetryPolicy { false } TransportError::ErrorResp(err) => should_retry_json_rpc_error(err), + TransportError::NullResp => true, + TransportError::UnsupportedFeature(_) => false, + TransportError::LocalUsageError(_) => false, } } diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs index ea0fe593830c4..3bb1631d5fb73 100644 --- a/crates/common/src/runtime_client.rs +++ b/crates/common/src/runtime_client.rs @@ -7,7 +7,7 @@ use ethers_providers::{ JsonRpcError, JwtAuth, JwtKey, ProviderError, PubsubClient, RetryClient, RetryClientBuilder, RpcError, Ws, }; -use reqwest::{ +use reqwest_ethers::{ header::{HeaderName, HeaderValue}, Url, }; @@ -128,10 +128,10 @@ impl RuntimeClient { async fn connect(&self) -> Result { match self.url.scheme() { "http" | "https" => { - let mut client_builder = reqwest::Client::builder() + let mut client_builder = reqwest_ethers::Client::builder() .timeout(self.timeout) .tls_built_in_root_certs(self.url.scheme() == "https"); - let mut headers = reqwest::header::HeaderMap::new(); + let mut headers = reqwest_ethers::header::HeaderMap::new(); if let Some(jwt) = self.jwt.as_ref() { let auth = build_auth(jwt.clone()).map_err(|err| { @@ -144,7 +144,7 @@ impl RuntimeClient { .expect("Header should be valid string"); auth_value.set_sensitive(true); - headers.insert(reqwest::header::AUTHORIZATION, auth_value); + headers.insert(reqwest_ethers::header::AUTHORIZATION, auth_value); }; for header in self.headers.iter() { diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index b337147d6171f..cf3f5a89a75a9 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -1,15 +1,16 @@ //! wrappers for transactions -use ethers_core::types::{BlockId, TransactionReceipt}; -use ethers_providers::Middleware; +use alloy_provider::{network::AnyNetwork, Provider}; +use alloy_rpc_types::{AnyTransactionReceipt, BlockId, WithOtherFields}; +use alloy_transport::Transport; use eyre::Result; use serde::{Deserialize, Serialize}; /// Helper type to carry a transaction along with an optional revert reason -#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct TransactionReceiptWithRevertReason { /// The underlying transaction receipt #[serde(flatten)] - pub receipt: TransactionReceipt, + pub receipt: AnyTransactionReceipt, /// The revert reason string if the transaction status is failed #[serde(skip_serializing_if = "Option::is_none", rename = "revertReason")] @@ -18,68 +19,67 @@ pub struct TransactionReceiptWithRevertReason { impl TransactionReceiptWithRevertReason { /// Returns if the status of the transaction is 0 (failure) - pub fn is_failure(&self) -> Option { - self.receipt.status.map(|status| status.as_u64() == 0) + pub fn is_failure(&self) -> bool { + !self.receipt.inner.inner.inner.receipt.status } /// Updates the revert reason field using `eth_call` and returns an Err variant if the revert /// reason was not successfully updated - pub async fn update_revert_reason(&mut self, provider: &M) -> Result<()> { + pub async fn update_revert_reason>( + &mut self, + provider: &P, + ) -> Result<()> { self.revert_reason = self.fetch_revert_reason(provider).await?; Ok(()) } - async fn fetch_revert_reason(&self, provider: &M) -> Result> { - if let Some(false) | None = self.is_failure() { + async fn fetch_revert_reason>( + &self, + provider: &P, + ) -> Result> { + if !self.is_failure() { return Ok(None) } - if let Some(ref transaction) = provider - .get_transaction(self.receipt.transaction_hash) + let transaction = provider + .get_transaction_by_hash(self.receipt.transaction_hash) .await - .map_err(|_| eyre::eyre!("unable to fetch transaction"))? - { - if let Some(block_hash) = self.receipt.block_hash { - match provider.call(&transaction.into(), Some(BlockId::Hash(block_hash))).await { - Err(e) => return Ok(extract_revert_reason(e.to_string())), - Ok(_) => eyre::bail!("no revert reason as transaction succeeded"), - } + .map_err(|_| eyre::eyre!("unable to fetch transaction"))?; + + if let Some(block_hash) = self.receipt.block_hash { + match provider + .call( + &WithOtherFields::new(transaction.inner.into()), + Some(BlockId::Hash(block_hash.into())), + ) + .await + { + Err(e) => return Ok(extract_revert_reason(e.to_string())), + Ok(_) => eyre::bail!("no revert reason as transaction succeeded"), } - eyre::bail!("unable to fetch block_hash") } - Err(eyre::eyre!("transaction does not exist")) + eyre::bail!("unable to fetch block_hash") } } -impl From for TransactionReceiptWithRevertReason { - fn from(receipt: TransactionReceipt) -> Self { +impl From for TransactionReceiptWithRevertReason { + fn from(receipt: AnyTransactionReceipt) -> Self { Self { receipt, revert_reason: None } } } -impl From for TransactionReceipt { +impl From for AnyTransactionReceipt { fn from(receipt_with_reason: TransactionReceiptWithRevertReason) -> Self { receipt_with_reason.receipt } } fn extract_revert_reason>(error_string: S) -> Option { - let message_substr = "message: execution reverted: "; - - let mut temp = ""; - + let message_substr = "execution reverted: "; error_string .as_ref() .find(message_substr) - .and_then(|index| { - let (_, rest) = error_string.as_ref().split_at(index + message_substr.len()); - temp = rest; - rest.rfind(", ") - }) - .map(|index| { - let (reason, _) = temp.split_at(index); - reason.to_string() - }) + .map(|index| error_string.as_ref().split_at(index + message_substr.len()).1.to_string()) } #[cfg(test)] @@ -88,16 +88,10 @@ mod tests { #[test] fn test_extract_revert_reason() { - let error_string_1 = "(code: 3, message: execution reverted: Transaction too old, data: Some(String(\"0x08c379a0\")))"; - let error_string_2 = "(code: 3, message: execution reverted: missing data: amountIn, amountOut, data: Some(String(\"0x08c379a0\")))"; - let error_string_3 = - "(code: 4, message: invalid signature, data: Some(String(\"0x08c379a0\")))"; + let error_string_1 = "server returned an error response: error code 3: execution reverted: Transaction too old"; + let error_string_2 = "server returned an error response: error code 3: Invalid signature"; assert_eq!(extract_revert_reason(error_string_1), Some("Transaction too old".to_string())); - assert_eq!( - extract_revert_reason(error_string_2), - Some("missing data: amountIn, amountOut".to_string()) - ); - assert_eq!(extract_revert_reason(error_string_3), None); + assert_eq!(extract_revert_reason(error_string_2), None); } } diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index 6f4284b324104..bcfed539ff000 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -1,18 +1,14 @@ //! Temporary utility conversion traits between ethers-rs and alloy types. -use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U128, U256, U64}; -use alloy_rpc_types::{ - other::OtherFields, - request::{TransactionInput, TransactionRequest as CallRequest}, - AccessList, AccessListItem, Signature, Transaction, -}; -use alloy_signer::{LocalWallet, Signer}; +use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U256, U64}; +use alloy_rpc_types::{AccessList, AccessListItem, BlockNumberOrTag}; +use alloy_signer_wallet::LocalWallet; use ethers_core::types::{ transaction::eip2930::{ AccessList as EthersAccessList, AccessListItem as EthersAccessListItem, }, - Bloom as EthersBloom, Bytes as EthersBytes, TransactionRequest, H160, H256, H64, - I256 as EthersI256, U256 as EthersU256, U64 as EthersU64, + BlockNumber, Bloom as EthersBloom, Bytes as EthersBytes, H160, H256, H64, I256 as EthersI256, + U256 as EthersU256, U64 as EthersU64, }; /// Conversion trait to easily convert from Ethers types to Alloy types. @@ -105,43 +101,7 @@ impl ToAlloy for u64 { } } -impl ToAlloy for ethers_core::types::Transaction { - type To = Transaction; - - fn to_alloy(self) -> Self::To { - Transaction { - hash: self.hash.to_alloy(), - nonce: U64::from(self.nonce.as_u64()), - block_hash: self.block_hash.map(ToAlloy::to_alloy), - block_number: self.block_number.map(|b| U256::from(b.as_u64())), - transaction_index: self.transaction_index.map(|b| U256::from(b.as_u64())), - from: self.from.to_alloy(), - to: self.to.map(ToAlloy::to_alloy), - value: self.value.to_alloy(), - gas_price: self.gas_price.map(|a| U128::from(a.as_u128())), - gas: self.gas.to_alloy(), - max_fee_per_gas: self.max_fee_per_gas.map(|f| U128::from(f.as_u128())), - max_priority_fee_per_gas: self - .max_priority_fee_per_gas - .map(|f| U128::from(f.as_u128())), - max_fee_per_blob_gas: None, - input: self.input.0.into(), - signature: Some(Signature { - r: self.r.to_alloy(), - s: self.s.to_alloy(), - v: U256::from(self.v.as_u64()), - y_parity: None, - }), - chain_id: self.chain_id.map(|c| U64::from(c.as_u64())), - blob_versioned_hashes: Vec::new(), - access_list: self.access_list.map(|a| a.0.into_iter().map(ToAlloy::to_alloy).collect()), - transaction_type: self.transaction_type.map(|t| t.to_alloy()), - other: Default::default(), - } - } -} - -impl ToEthers for alloy_signer::LocalWallet { +impl ToEthers for alloy_signer_wallet::LocalWallet { type To = ethers_signers::LocalWallet; fn to_ethers(self) -> Self::To { @@ -161,34 +121,6 @@ impl ToEthers for Vec { } } -/// Converts from a [TransactionRequest] to a [CallRequest]. -pub fn to_call_request_from_tx_request(tx: TransactionRequest) -> CallRequest { - CallRequest { - from: tx.from.map(|f| f.to_alloy()), - to: match tx.to { - Some(to) => match to { - ethers_core::types::NameOrAddress::Address(addr) => Some(addr.to_alloy()), - ethers_core::types::NameOrAddress::Name(_) => None, - }, - None => None, - }, - gas_price: tx.gas_price.map(|g| g.to_alloy()), - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - gas: tx.gas.map(|g| g.to_alloy()), - value: tx.value.map(|v| v.to_alloy()), - input: TransactionInput::maybe_input(tx.data.map(|b| b.0.into())), - nonce: tx.nonce.map(|n| U64::from(n.as_u64())), - chain_id: tx.chain_id.map(|c| c.to_alloy()), - access_list: None, - max_fee_per_blob_gas: None, - blob_versioned_hashes: None, - transaction_type: None, - sidecar: None, - other: OtherFields::default(), - } -} - impl ToAlloy for EthersAccessList { type To = AccessList; fn to_alloy(self) -> Self::To { @@ -260,3 +192,19 @@ impl ToEthers for Bytes { EthersBytes(self.0) } } + +impl ToEthers for BlockNumberOrTag { + type To = BlockNumber; + + #[inline(always)] + fn to_ethers(self) -> Self::To { + match self { + BlockNumberOrTag::Number(n) => BlockNumber::Number(n.into()), + BlockNumberOrTag::Earliest => BlockNumber::Earliest, + BlockNumberOrTag::Latest => BlockNumber::Latest, + BlockNumberOrTag::Pending => BlockNumber::Pending, + BlockNumberOrTag::Finalized => BlockNumber::Finalized, + BlockNumberOrTag::Safe => BlockNumber::Safe, + } + } +} diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 7e43c22761d4b..da1371c75bd47 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -36,7 +36,7 @@ serde_regex = "1" serde.workspace = true thiserror = "1" toml = { version = "0.8", features = ["preserve_order"] } -toml_edit = "0.21" +toml_edit = "0.22.4" tracing.workspace = true walkdir = "2" diff --git a/crates/config/src/fix.rs b/crates/config/src/fix.rs index a0ce9fbc1b0bd..dc43fd25500b5 100644 --- a/crates/config/src/fix.rs +++ b/crates/config/src/fix.rs @@ -10,7 +10,7 @@ use std::{ /// A convenience wrapper around a TOML document and the path it was read from struct TomlFile { - doc: toml_edit::Document, + doc: toml_edit::DocumentMut, path: PathBuf, } @@ -21,11 +21,11 @@ impl TomlFile { Ok(Self { doc, path }) } - fn doc(&self) -> &toml_edit::Document { + fn doc(&self) -> &toml_edit::DocumentMut { &self.doc } - fn doc_mut(&mut self) -> &mut toml_edit::Document { + fn doc_mut(&mut self) -> &mut toml_edit::DocumentMut { &mut self.doc } @@ -39,7 +39,7 @@ impl TomlFile { } impl Deref for TomlFile { - type Target = toml_edit::Document; + type Target = toml_edit::DocumentMut; fn deref(&self) -> &Self::Target { self.doc() } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 88671dce194aa..51769ab314a08 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1222,7 +1222,7 @@ impl Config { /// [Self::get_config_path()] and if the closure returns `true`. pub fn update_at(root: impl Into, f: F) -> eyre::Result<()> where - F: FnOnce(&Config, &mut toml_edit::Document) -> bool, + F: FnOnce(&Config, &mut toml_edit::DocumentMut) -> bool, { let config = Self::load_with_root(root).sanitized(); config.update(|doc| f(&config, doc)) @@ -1234,14 +1234,14 @@ impl Config { /// [Self::get_config_path()] and if the closure returns `true` pub fn update(&self, f: F) -> eyre::Result<()> where - F: FnOnce(&mut toml_edit::Document) -> bool, + F: FnOnce(&mut toml_edit::DocumentMut) -> bool, { let file_path = self.get_config_path(); if !file_path.exists() { return Ok(()) } let contents = fs::read_to_string(&file_path)?; - let mut doc = contents.parse::()?; + let mut doc = contents.parse::()?; if f(&mut doc) { fs::write(file_path, doc.to_string())?; } diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index d0d6f8e06663f..cb23500088b4e 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -14,7 +14,7 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -use toml_edit::{Document, Item}; +use toml_edit::{DocumentMut, Item}; /// Loads the config for the current project workspace pub fn load_config() -> Config { @@ -216,9 +216,9 @@ pub fn get_available_profiles(toml_path: impl AsRef) -> eyre::Result) -> eyre::Result { +fn read_toml(path: impl AsRef) -> eyre::Result { let path = path.as_ref().to_owned(); - let doc: Document = std::fs::read_to_string(path)?.parse()?; + let doc: DocumentMut = std::fs::read_to_string(path)?.parse()?; Ok(doc) } diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 7e4ea3c218d26..cf922cbce4925 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -19,9 +19,15 @@ foundry-macros.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } alloy-genesis.workspace = true -alloy-providers.workspace = true +alloy-provider.workspace = true +alloy-transport.workspace = true alloy-rpc-types.workspace = true alloy-sol-types.workspace = true diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index c0ff88ea40a17..59410541a7374 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -18,7 +18,7 @@ use revm::{ }, Database, DatabaseCommit, Inspector, JournaledState, }; -use std::{borrow::Cow, collections::HashMap}; +use std::{borrow::Cow, collections::BTreeMap}; /// A wrapper around `Backend` that ensures only `revm::DatabaseRef` functions are called. /// @@ -159,7 +159,7 @@ impl<'a> DatabaseExt for CowBackend<'a> { fn roll_fork( &mut self, id: Option, - block_number: U256, + block_number: u64, env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()> { @@ -213,7 +213,7 @@ impl<'a> DatabaseExt for CowBackend<'a> { fn load_allocs( &mut self, - allocs: &HashMap, + allocs: &BTreeMap, journaled_state: &mut JournaledState, ) -> Result<(), DatabaseError> { self.backend_mut(&Env::default()).load_allocs(allocs, journaled_state) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index ca6cbb1ef8bdd..dbd5071eed60b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -7,8 +7,8 @@ use crate::{ utils::configure_tx_env, }; use alloy_genesis::GenesisAccount; -use alloy_primitives::{b256, keccak256, Address, B256, U256, U64}; -use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; +use alloy_primitives::{b256, keccak256, Address, B256, U256}; +use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction, WithOtherFields}; use eyre::Context; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use revm::{ @@ -22,7 +22,7 @@ use revm::{ Database, DatabaseCommit, Inspector, JournaledState, }; use std::{ - collections::{HashMap, HashSet}, + collections::{BTreeMap, HashMap, HashSet}, time::Instant, }; @@ -166,7 +166,7 @@ pub trait DatabaseExt: Database { fn roll_fork( &mut self, id: Option, - block_number: U256, + block_number: u64, env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()>; @@ -262,7 +262,7 @@ pub trait DatabaseExt: Database { /// Returns [Ok] if all accounts were successfully inserted into the journal, [Err] otherwise. fn load_allocs( &mut self, - allocs: &HashMap, + allocs: &BTreeMap, journaled_state: &mut JournaledState, ) -> Result<(), DatabaseError>; @@ -857,18 +857,18 @@ impl Backend { &self, id: LocalForkId, transaction: B256, - ) -> eyre::Result<(U64, Block)> { + ) -> eyre::Result<(u64, Block)> { let fork = self.inner.get_fork_by_id(id)?; let tx = fork.db.db.get_transaction(transaction)?; // get the block number we need to fork if let Some(tx_block) = tx.block_number { - let block = fork.db.db.get_full_block(tx_block.to::())?; + let block = fork.db.db.get_full_block(tx_block)?; // we need to subtract 1 here because we want the state before the transaction // was mined - let fork_block = tx_block.to::() - 1; - Ok((U64::from(fork_block), block)) + let fork_block = tx_block - 1; + Ok((fork_block, block)) } else { let block = fork.db.db.get_full_block(BlockNumberOrTag::Latest)?; @@ -877,7 +877,7 @@ impl Backend { .number .ok_or_else(|| DatabaseError::BlockNotFound(BlockNumberOrTag::Latest.into()))?; - Ok((number.to::(), block)) + Ok((number, block)) } } @@ -904,7 +904,7 @@ impl Backend { // System transactions such as on L2s don't contain any pricing info so we skip them // otherwise this would cause reverts if is_known_system_sender(tx.from) || - tx.transaction_type.map(|ty| ty.to::()) == Some(SYSTEM_TRANSACTION_TYPE) + tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) { trace!(tx=?tx.hash, "skipping system transaction"); continue; @@ -917,7 +917,7 @@ impl Backend { trace!(tx=?tx.hash, "committing transaction"); commit_transaction( - tx, + WithOtherFields::new(tx), env.clone(), journaled_state, fork, @@ -976,7 +976,7 @@ impl DatabaseExt for Backend { // another caller, so we need to ensure the caller account is present in the // journaled state and database let caller = current.tx.caller; - if !journaled_state.state.contains_key(&caller) { + journaled_state.state.entry(caller).or_insert_with(|| { let caller_account = current_state .state .get(&caller) @@ -987,8 +987,8 @@ impl DatabaseExt for Backend { // update the caller account which is required by the evm fork.db.insert_account_info(caller, caller_account.clone()); } - journaled_state.state.insert(caller, caller_account.into()); - } + caller_account.into() + }); self.inner.revert_snapshot(id, fork_id, idx, *fork); self.active_fork_ids = Some((id, idx)) } @@ -1115,7 +1115,7 @@ impl DatabaseExt for Backend { // necessarily the same caller as for the test, however we must always // ensure that fork's state contains the current sender let caller = env.tx.caller; - if !fork.journaled_state.state.contains_key(&caller) { + fork.journaled_state.state.entry(caller).or_insert_with(|| { let caller_account = active_journaled_state .state .get(&env.tx.caller) @@ -1126,8 +1126,8 @@ impl DatabaseExt for Backend { // update the caller account which is required by the evm fork.db.insert_account_info(caller, caller_account.clone()); } - fork.journaled_state.state.insert(caller, caller_account.into()); - } + caller_account.into() + }); self.update_fork_db(active_journaled_state, &mut fork); @@ -1147,14 +1147,14 @@ impl DatabaseExt for Backend { fn roll_fork( &mut self, id: Option, - block_number: U256, + block_number: u64, env: &mut Env, journaled_state: &mut JournaledState, ) -> eyre::Result<()> { trace!(?id, ?block_number, "roll fork"); let id = self.ensure_fork(id)?; let (fork_id, backend, fork_env) = - self.forks.roll_fork(self.inner.ensure_fork_id(id).cloned()?, block_number.to())?; + self.forks.roll_fork(self.inner.ensure_fork_id(id).cloned()?, block_number)?; // this will update the local mapping self.inner.roll_fork(id, fork_id, backend)?; @@ -1216,7 +1216,7 @@ impl DatabaseExt for Backend { self.get_block_number_and_block_for_transaction(id, transaction)?; // roll the fork to the transaction's block or latest if it's pending - self.roll_fork(Some(id), fork_block.to(), env, journaled_state)?; + self.roll_fork(Some(id), fork_block, env, journaled_state)?; update_env_block(env, fork_block, &block); @@ -1332,7 +1332,7 @@ impl DatabaseExt for Backend { /// Returns [Ok] if all accounts were successfully inserted into the journal, [Err] otherwise. fn load_allocs( &mut self, - allocs: &HashMap, + allocs: &BTreeMap, journaled_state: &mut JournaledState, ) -> Result<(), DatabaseError> { // Loop through all of the allocs defined in the map and commit them to the journal. @@ -1855,20 +1855,20 @@ fn is_contract_in_state(journaled_state: &JournaledState, acc: Address) -> bool } /// Updates the env's block with the block's data -fn update_env_block(env: &mut Env, fork_block: U64, block: &Block) { - env.block.timestamp = block.header.timestamp; +fn update_env_block(env: &mut Env, fork_block: u64, block: &Block) { + env.block.timestamp = U256::from(block.header.timestamp); env.block.coinbase = block.header.miner; env.block.difficulty = block.header.difficulty; env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); - env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default(); - env.block.gas_limit = block.header.gas_limit; - env.block.number = block.header.number.map(|n| n.to()).unwrap_or(fork_block.to()); + env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); + env.block.gas_limit = U256::from(block.header.gas_limit); + env.block.number = U256::from(block.header.number.unwrap_or(fork_block)); } /// Executes the given transaction and commits state changes to the database _and_ the journaled /// state, with an optional inspector fn commit_transaction>( - tx: Transaction, + tx: WithOtherFields, mut env: EnvWithHandlerCfg, journaled_state: &mut JournaledState, fork: &mut Fork, diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 8e720a2505d22..f6da76fc5c429 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -4,8 +4,9 @@ use crate::{ fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, }; use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; -use alloy_providers::tmp::TempProvider; -use alloy_rpc_types::{Block, BlockId, Transaction}; +use alloy_provider::{network::AnyNetwork, Provider}; +use alloy_rpc_types::{Block, BlockId, Transaction, WithOtherFields}; +use alloy_transport::Transport; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; use futures::{ @@ -21,6 +22,7 @@ use revm::{ use rustc_hash::FxHashMap; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, + marker::PhantomData, pin::Pin, sync::{ mpsc::{channel as oneshot_channel, Sender as OneshotSender}, @@ -31,19 +33,23 @@ use std::{ // Various future/request type aliases type AccountFuture = - Pin, Address)> + Send>>; + Pin, Address)> + Send>>; type StorageFuture = Pin, Address, U256)> + Send>>; type BlockHashFuture = Pin, u64)> + Send>>; type FullBlockFuture = Pin, Err>, BlockId)> + Send>>; -type TransactionFuture = - Pin, B256)> + Send>>; +type TransactionFuture = Pin< + Box< + dyn Future, Err>, B256)> + + Send, + >, +>; type AccountInfoSender = OneshotSender>; type StorageSender = OneshotSender>; type BlockHashSender = OneshotSender>; type FullBlockSender = OneshotSender>; -type TransactionSender = OneshotSender>; +type TransactionSender = OneshotSender>>; /// Request variants that are executed by the provider enum ProviderRequest { @@ -76,8 +82,9 @@ enum BackendRequest { /// This handler will remain active as long as it is reachable (request channel still open) and /// requests are in progress. #[must_use = "futures do nothing unless polled"] -pub struct BackendHandler

{ +pub struct BackendHandler { provider: P, + transport: PhantomData, /// Stores all the data. db: BlockchainDb, /// Requests currently in progress @@ -97,9 +104,10 @@ pub struct BackendHandler

{ block_id: Option, } -impl

BackendHandler

+impl BackendHandler where - P: TempProvider + Clone + 'static, + T: Transport + Clone, + P: Provider + Clone + Unpin + 'static, { fn new( provider: P, @@ -117,6 +125,7 @@ where queued_requests: Default::default(), incoming: rx, block_id, + transport: PhantomData, } } @@ -197,7 +206,7 @@ where let fut = Box::pin(async move { let balance = provider.get_balance(address, block_id); let nonce = provider.get_transaction_count(address, block_id); - let code = provider.get_code_at(address, block_id); + let code = provider.get_code_at(address, block_id.unwrap_or_default()); let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); (resp, address) }); @@ -283,9 +292,10 @@ where } } -impl

Future for BackendHandler

+impl Future for BackendHandler where - P: TempProvider + Clone + Unpin + 'static, + T: Transport + Clone + Unpin, + P: Provider + Clone + Unpin + 'static, { type Output = (); @@ -343,7 +353,7 @@ where // update the cache let acc = AccountInfo { - nonce: nonce.to(), + nonce, balance, code: Some(Bytecode::new_raw(code).to_checked()), code_hash, @@ -512,9 +522,14 @@ impl SharedBackend { /// dropped. /// /// NOTE: this should be called with `Arc` - pub async fn spawn_backend

(provider: P, db: BlockchainDb, pin_block: Option) -> Self + pub async fn spawn_backend( + provider: P, + db: BlockchainDb, + pin_block: Option, + ) -> Self where - P: TempProvider + Unpin + 'static + Clone, + T: Transport + Clone + Unpin, + P: Provider + Unpin + 'static + Clone, { let (shared, handler) = Self::new(provider, db, pin_block); // spawn the provider handler to a task @@ -525,13 +540,14 @@ impl SharedBackend { /// Same as `Self::spawn_backend` but spawns the `BackendHandler` on a separate `std::thread` in /// its own `tokio::Runtime` - pub fn spawn_backend_thread

( + pub fn spawn_backend_thread( provider: P, db: BlockchainDb, pin_block: Option, ) -> Self where - P: TempProvider + Unpin + 'static + Clone, + T: Transport + Clone + Unpin, + P: Provider + Unpin + 'static + Clone, { let (shared, handler) = Self::new(provider, db, pin_block); @@ -554,13 +570,14 @@ impl SharedBackend { } /// Returns a new `SharedBackend` and the `BackendHandler` - pub fn new

( + pub fn new( provider: P, db: BlockchainDb, pin_block: Option, - ) -> (Self, BackendHandler

) + ) -> (Self, BackendHandler) where - P: TempProvider + Clone + 'static, + T: Transport + Clone + Unpin, + P: Provider + Unpin + 'static + Clone, { let (backend, backend_rx) = channel(1); let cache = Arc::new(FlushJsonBlockCacheDB(Arc::clone(db.cache()))); @@ -585,7 +602,7 @@ impl SharedBackend { } /// Returns the transaction for the hash - pub fn get_transaction(&self, tx: B256) -> DatabaseResult { + pub fn get_transaction(&self, tx: B256) -> DatabaseResult> { tokio::task::block_in_place(|| { let (sender, rx) = oneshot_channel(); let req = BackendRequest::Transaction(tx, sender); diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index abde7cb22dea7..b69e02aad9db2 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -1,7 +1,8 @@ use crate::utils::apply_chain_and_block_specific_env_changes; use alloy_primitives::{Address, U256}; -use alloy_providers::tmp::TempProvider; +use alloy_provider::{Network, Provider}; use alloy_rpc_types::{Block, BlockNumberOrTag}; +use alloy_transport::Transport; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; @@ -10,10 +11,10 @@ use revm::primitives::{BlockEnv, CfgEnv, Env, TxEnv}; /// Initializes a REVM block environment based on a forked /// ethereum provider. // todo(onbjerg): these bounds needed cus of the bounds in `Provider`, can simplify? -pub async fn environment( +pub async fn environment>( provider: &P, memory_limit: u64, - gas_price: Option, + gas_price: Option, override_chain_id: Option, pin_block: Option, origin: Address, @@ -49,7 +50,7 @@ pub async fn environment( }; let mut cfg = CfgEnv::default(); - cfg.chain_id = override_chain_id.unwrap_or(rpc_chain_id.to::()); + cfg.chain_id = override_chain_id.unwrap_or(rpc_chain_id); cfg.memory_limit = memory_limit; cfg.limit_contract_code_size = Some(usize::MAX); // EIP-3607 rejects transactions from senders with deployed code. @@ -61,20 +62,20 @@ pub async fn environment( let mut env = Env { cfg, block: BlockEnv { - number: block.header.number.expect("block number not found"), - timestamp: block.header.timestamp, + number: U256::from(block.header.number.expect("block number not found")), + timestamp: U256::from(block.header.timestamp), coinbase: block.header.miner, difficulty: block.header.difficulty, prevrandao: Some(block.header.mix_hash.unwrap_or_default()), - basefee: block.header.base_fee_per_gas.unwrap_or_default(), - gas_limit: block.header.gas_limit, + basefee: U256::from(block.header.base_fee_per_gas.unwrap_or_default()), + gas_limit: U256::from(block.header.gas_limit), ..Default::default() }, tx: TxEnv { caller: origin, - gas_price: gas_price.map(U256::from).unwrap_or(fork_gas_price), - chain_id: Some(override_chain_id.unwrap_or(rpc_chain_id.to::())), - gas_limit: block.header.gas_limit.to::(), + gas_price: U256::from(gas_price.unwrap_or(fork_gas_price)), + chain_id: Some(override_chain_id.unwrap_or(rpc_chain_id)), + gas_limit: block.header.gas_limit as u64, ..Default::default() }, }; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 4e1cb66e5ff4a..60096784c60e9 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -4,7 +4,11 @@ //! concurrently active pairs at once. use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; -use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; +use foundry_common::provider::{ + alloy::{ProviderBuilder, RetryProvider}, + runtime_transport::RuntimeTransport, + tower::RetryBackoffService, +}; use foundry_config::Config; use futures::{ channel::mpsc::{channel, Receiver, Sender}, @@ -167,7 +171,7 @@ impl MultiFork { } } -type Handler = BackendHandler>; +type Handler = BackendHandler, Arc>; type CreateFuture = Pin> + Send>>; @@ -498,7 +502,7 @@ async fn create_fork(mut fork: CreateFork) -> eyre::Result<(ForkId, CreatedFork, // we need to use the block number from the block because the env's number can be different on // some L2s (e.g. Arbitrum). - let number = block.header.number.unwrap_or(meta.block_env.number).to::(); + let number = block.header.number.unwrap_or(meta.block_env.number.to()); // determine the cache path if caching is enabled let cache_path = if fork.enable_caching { diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 89fdcf4e38693..fcd92dd6adf37 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,7 +1,7 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; -use alloy_providers::tmp::TempProvider; +use alloy_provider::Provider; use alloy_rpc_types::Block; use eyre::WrapErr; use foundry_common::{ @@ -95,7 +95,7 @@ impl EvmOpts { environment( &provider, self.memory_limit, - self.env.gas_price, + self.env.gas_price.map(|v| v as u128), self.env.chain_id, self.fork_block_number, self.sender, @@ -205,7 +205,7 @@ impl EvmOpts { .unwrap_or_else(|| panic!("Failed to establish provider to {url}")); if let Ok(id) = RuntimeOrHandle::new().block_on(provider.get_chain_id()) { - return Some(Chain::from(id.to::())); + return Some(Chain::from(id)); } } diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 7ef8bb47f2d4f..ee8a8a4d47587 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -25,7 +25,7 @@ pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::En match chain { NamedChain::Mainnet => { // after merge difficulty is supplanted with prevrandao EIP-4399 - if block_number.to::() >= 15_537_351u64 { + if block_number >= 15_537_351u64 { env.block.difficulty = env.block.prevrandao.unwrap_or_default().into(); } @@ -68,14 +68,15 @@ pub fn get_function( /// Configures the env for the transaction pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { env.tx.caller = tx.from; - env.tx.gas_limit = tx.gas.to(); - env.tx.gas_price = tx.gas_price.unwrap_or_default().to(); - env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(|g| g.to()); - env.tx.nonce = Some(tx.nonce.to()); + env.tx.gas_limit = tx.gas as u64; + env.tx.gas_price = U256::from(tx.gas_price.unwrap_or_default()); + env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); + env.tx.nonce = Some(tx.nonce); env.tx.access_list = tx .access_list .clone() .unwrap_or_default() + .0 .into_iter() .map(|item| { ( diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 6f83bf43f8678..a38bf0eeeeaf8 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -515,9 +515,7 @@ impl InspectorStack { if let Some(acc_mut) = ecx.journaled_state.state.get_mut(&addr) { acc_mut.status |= acc.status; for (key, val) in acc.storage { - if !acc_mut.storage.contains_key(&key) { - acc_mut.storage.insert(key, val); - } + acc_mut.storage.entry(key).or_insert(val); } } else { ecx.journaled_state.state.insert(addr, acc); diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 3a3b17ed641e5..f432154b9f9b2 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -212,7 +212,11 @@ pub fn build_initial_state( let mut values = IndexSet::new(); let mut addresses = IndexSet::new(); - for (address, account) in db.accounts.iter() { + // Sort accounts to ensure deterministic dictionary generation from the same setUp state. + let mut accs = db.accounts.iter().collect::>(); + accs.sort_by_key(|(address, _)| *address); + + for (address, account) in accs { let address: Address = *address; // Insert basic account information values.insert(address.into_word().into()); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index f5a6b27c7911d..b7508ae4b27a9 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -28,10 +28,6 @@ foundry-wallets.workspace = true foundry-linking.workspace = true ethers-contract.workspace = true -ethers-core.workspace = true -ethers-middleware.workspace = true -ethers-providers.workspace = true -ethers-signers.workspace = true revm-inspectors.workspace = true @@ -55,6 +51,12 @@ alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde"] } alloy-rpc-types.workspace = true +alloy-provider.workspace = true +alloy-network.workspace = true +alloy-transport.workspace = true +alloy-signer.workspace = true +alloy-consensus.workspace = true +alloy-chains.workspace = true async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } @@ -103,6 +105,9 @@ svm = { package = "svm-rs", version = "0.4", default-features = false, features tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } +ethers-core.workspace = true +alloy-signer-wallet.workspace = true + [features] default = ["rustls"] rustls = [ @@ -111,7 +116,7 @@ rustls = [ "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots", ] -openssl = ["foundry-cli/openssl", "reqwest/default-tls", "foundry-wallets/openssl"] +openssl = ["foundry-cli/openssl", "reqwest/default-tls"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 9dee30675d5ff..e42a17057bdba 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -1,17 +1,13 @@ -use alloy_dyn_abi::{DynSolValue, JsonAbiExt, ResolveSolType}; +use alloy_chains::Chain; +use alloy_dyn_abi::{DynSolValue, JsonAbiExt, Specifier}; use alloy_json_abi::{Constructor, JsonAbi}; +use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; use alloy_primitives::{Address, Bytes}; +use alloy_provider::{Provider, ProviderBuilder}; +use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest, WithOtherFields}; +use alloy_signer::Signer; +use alloy_transport::{Transport, TransportError}; use clap::{Parser, ValueHint}; -use ethers_contract::ContractError; -use ethers_core::{ - abi::InvalidOutputType, - types::{ - transaction::eip2718::TypedTransaction, BlockNumber, Chain, Eip1559TransactionRequest, - TransactionReceipt, TransactionRequest, - }, -}; -use ethers_middleware::SignerMiddleware; -use ethers_providers::Middleware; use eyre::{Context, Result}; use forge_verify::RetryArgs; use foundry_cli::{ @@ -19,10 +15,7 @@ use foundry_cli::{ utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; use foundry_common::{ - compile::ProjectCompiler, - fmt::parse_tokens, - provider::ethers::estimate_eip1559_fees, - types::{ToAlloy, ToEthers}, + compile::ProjectCompiler, fmt::parse_tokens, provider::alloy::estimate_eip1559_fees, }; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalized}; use serde_json::json; @@ -136,18 +129,20 @@ impl CreateArgs { let chain_id = if let Some(chain_id) = self.chain_id() { chain_id } else { - provider.get_chainid().await?.as_u64() + provider.get_chain_id().await? }; if self.unlocked { // Deploy with unlocked account let sender = self.eth.wallet.from.expect("required"); - let provider = provider.with_sender(sender.to_ethers()); - self.deploy(abi, bin, params, provider, chain_id).await + self.deploy(abi, bin, params, provider, chain_id, sender).await } else { // Deploy with signer let signer = self.eth.wallet.signer().await?; - let provider = SignerMiddleware::new_with_provider_chain(provider, signer).await?; - self.deploy(abi, bin, params, provider, chain_id).await + let deployer = signer.address(); + let provider = ProviderBuilder::<_, _, AnyNetwork>::default() + .signer(EthereumSigner::new(signer)) + .on_provider(provider); + self.deploy(abi, bin, params, provider, chain_id, deployer).await } } @@ -206,16 +201,15 @@ impl CreateArgs { } /// Deploys the contract - async fn deploy( + async fn deploy, T: Transport + Clone>( self, abi: JsonAbi, bin: BytecodeObject, args: Vec, - provider: M, + provider: P, chain: u64, + deployer_address: Address, ) -> Result<()> { - let deployer_address = - provider.default_sender().expect("no sender address set for provider"); let bin = bin.into_bytes().unwrap_or_else(|| { panic!("no bytecode found in bin object for {}", self.contract.name) }); @@ -223,7 +217,7 @@ impl CreateArgs { let factory = ContractFactory::new(abi.clone(), bin.clone(), provider.clone()); let is_args_empty = args.is_empty(); - let deployer = + let mut deployer = factory.deploy_tokens(args.clone()).context("failed to deploy contract").map_err(|e| { if is_args_empty { e.wrap_err("no arguments provided for contract constructor; consider --constructor-args or --constructor-args-path") @@ -231,57 +225,52 @@ impl CreateArgs { e } })?; - let is_legacy = self.tx.legacy || - Chain::try_from(chain).map(|x| Chain::is_legacy(&x)).unwrap_or_default(); - let mut deployer = if is_legacy { deployer.legacy() } else { deployer }; + let is_legacy = self.tx.legacy || Chain::from(chain).is_legacy(); + + deployer.tx.set_from(deployer_address); + deployer.tx.set_chain_id(chain); + + deployer.tx.set_nonce(if let Some(nonce) = self.tx.nonce { + Ok(nonce.to()) + } else { + provider.get_transaction_count(deployer_address, None).await + }?); + + deployer.tx.set_gas_limit(if let Some(gas_limit) = self.tx.gas_limit { + Ok(gas_limit.to()) + } else { + provider.estimate_gas(&deployer.tx, None).await + }?); // set tx value if specified if let Some(value) = self.tx.value { - deployer.tx.set_value(value.to_ethers()); + deployer.tx.set_value(value); } - // fill tx first because if you target a lower gas than current base, eth_estimateGas - // will fail and create will fail - provider.fill_transaction(&mut deployer.tx, None).await?; - - // the max - let mut priority_fee = self.tx.priority_gas_price; - - // set gas price if specified - if let Some(gas_price) = self.tx.gas_price { - deployer.tx.set_gas_price(gas_price.to_ethers()); - } else if !is_legacy { - // estimate EIP1559 fees - let (max_fee, max_priority_fee) = estimate_eip1559_fees(&provider, Some(chain)) + if is_legacy { + let gas_price = if let Some(gas_price) = self.tx.gas_price { + gas_price.to() + } else { + provider.get_gas_price().await? + }; + deployer.tx.set_gas_price(gas_price); + } else { + let estimate = estimate_eip1559_fees(&provider, Some(chain)) .await .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; - deployer.tx.set_gas_price(max_fee); - if priority_fee.is_none() { - priority_fee = Some(max_priority_fee.to_alloy()); - } - } - - // set gas limit if specified - if let Some(gas_limit) = self.tx.gas_limit { - deployer.tx.set_gas(gas_limit.to_ethers()); - } - - // set nonce if specified - if let Some(nonce) = self.tx.nonce { - deployer.tx.set_nonce(nonce.to_ethers()); - } - - // set priority fee if specified - if let Some(priority_fee) = priority_fee { - if is_legacy { - eyre::bail!("there is no priority fee for legacy txs"); - } - deployer.tx = match deployer.tx { - TypedTransaction::Eip1559(eip1559_tx_request) => TypedTransaction::Eip1559( - eip1559_tx_request.max_priority_fee_per_gas(priority_fee.to_ethers()), - ), - _ => deployer.tx, + let priority_fee = if let Some(priority_fee) = self.tx.priority_gas_price { + priority_fee.to() + } else { + estimate.max_priority_fee_per_gas }; + let max_fee = if let Some(max_fee) = self.tx.gas_price { + max_fee.to() + } else { + estimate.max_fee_per_gas + }; + + deployer.tx.set_max_fee_per_gas(max_fee); + deployer.tx.set_max_priority_fee_per_gas(priority_fee); } // Before we actually deploy the contract we try check if the verify settings are valid @@ -304,13 +293,13 @@ impl CreateArgs { let address = deployed_contract; if self.json { let output = json!({ - "deployer": deployer_address.to_alloy().to_string(), + "deployer": deployer_address.to_string(), "deployedTo": address.to_string(), "transactionHash": receipt.transaction_hash }); println!("{output}"); } else { - println!("Deployer: {}", deployer_address.to_alloy()); + println!("Deployer: {deployer_address}"); println!("Deployed to: {address}"); println!("Transaction hash: {:?}", receipt.transaction_hash); }; @@ -376,7 +365,7 @@ impl CreateArgs { /// compatibility with less-abstract Contracts. /// /// For full usage docs, see [`DeploymentTxFactory`]. -pub type ContractFactory = DeploymentTxFactory, M>; +pub type ContractFactory = DeploymentTxFactory, P, T>; /// Helper which manages the deployment transaction of a smart contract. It /// wraps a deployment transaction, and retrieves the contract address output @@ -385,16 +374,16 @@ pub type ContractFactory = DeploymentTxFactory, M>; /// Currently, we recommend using the [`ContractDeployer`] type alias. #[derive(Debug)] #[must_use = "ContractDeploymentTx does nothing unless you `send` it"] -pub struct ContractDeploymentTx { +pub struct ContractDeploymentTx { /// the actual deployer, exposed for overriding the defaults - pub deployer: Deployer, + pub deployer: Deployer, /// marker for the `Contract` type to create afterwards /// /// this type will be used to construct it via `From::from(Contract)` _contract: PhantomData, } -impl Clone for ContractDeploymentTx +impl Clone for ContractDeploymentTx where B: Clone, { @@ -403,8 +392,8 @@ where } } -impl From> for ContractDeploymentTx { - fn from(deployer: Deployer) -> Self { +impl From> for ContractDeploymentTx { + fn from(deployer: Deployer) -> Self { Self { deployer, _contract: PhantomData } } } @@ -412,17 +401,17 @@ impl From> for ContractDeploymentTx { /// Helper which manages the deployment transaction of a smart contract #[derive(Debug)] #[must_use = "Deployer does nothing unless you `send` it"] -pub struct Deployer { +pub struct Deployer { /// The deployer's transaction, exposed for overriding the defaults - pub tx: TypedTransaction, + pub tx: WithOtherFields, abi: JsonAbi, client: B, confs: usize, - block: BlockNumber, - _m: PhantomData, + _p: PhantomData

, + _t: PhantomData, } -impl Clone for Deployer +impl Clone for Deployer where B: Clone, { @@ -432,53 +421,38 @@ where abi: self.abi.clone(), client: self.client.clone(), confs: self.confs, - block: self.block, - _m: PhantomData, + _p: PhantomData, + _t: PhantomData, } } } -impl Deployer +impl Deployer where - B: Borrow + Clone, - M: Middleware, + B: Borrow

+ Clone, + P: Provider, + T: Transport + Clone, { - /// Uses a Legacy transaction instead of an EIP-1559 one to do the deployment - pub fn legacy(mut self) -> Self { - self.tx = match self.tx { - TypedTransaction::Eip1559(inner) => { - let tx: TransactionRequest = inner.into(); - TypedTransaction::Legacy(tx) - } - other => other, - }; - self - } - /// Broadcasts the contract deployment transaction and after waiting for it to /// be sufficiently confirmed (default: 1), it returns a tuple with /// the [`Contract`](crate::Contract) struct at the deployed contract's address - /// and the corresponding [`TransactionReceipt`]. + /// and the corresponding [`AnyReceipt`]. pub async fn send_with_receipt( self, - ) -> Result<(Address, TransactionReceipt), ContractError> { - let pending_tx = self + ) -> Result<(Address, AnyTransactionReceipt), ContractDeploymentError> { + let receipt = self .client .borrow() - .send_transaction(self.tx, Some(self.block.into())) - .await - .map_err(ContractError::from_middleware_error)?; - - // TODO: Should this be calculated "optimistically" by address/nonce? - let receipt = pending_tx - .confirmations(self.confs) - .await - .ok() - .flatten() - .ok_or(ContractError::ContractNotDeployed)?; - let address = receipt.contract_address.ok_or(ContractError::ContractNotDeployed)?; - - Ok((address.to_alloy(), receipt)) + .send_transaction(self.tx) + .await? + .with_required_confirmations(self.confs as u64) + .get_receipt() + .await?; + + let address = + receipt.contract_address.ok_or(ContractDeploymentError::ContractNotDeployed)?; + + Ok((address, receipt)) } } @@ -519,14 +493,15 @@ where /// # Ok(()) /// # } #[derive(Debug)] -pub struct DeploymentTxFactory { +pub struct DeploymentTxFactory { client: B, abi: JsonAbi, bytecode: Bytes, - _m: PhantomData, + _p: PhantomData

, + _t: PhantomData, } -impl Clone for DeploymentTxFactory +impl Clone for DeploymentTxFactory where B: Clone, { @@ -535,39 +510,42 @@ where client: self.client.clone(), abi: self.abi.clone(), bytecode: self.bytecode.clone(), - _m: PhantomData, + _p: PhantomData, + _t: PhantomData, } } } -impl DeploymentTxFactory +impl DeploymentTxFactory where - B: Borrow + Clone, - M: Middleware, + B: Borrow

+ Clone, + P: Provider, + T: Transport + Clone, { /// Creates a factory for deployment of the Contract with bytecode, and the /// constructor defined in the abi. The client will be used to send any deployment /// transaction. pub fn new(abi: JsonAbi, bytecode: Bytes, client: B) -> Self { - Self { client, abi, bytecode, _m: PhantomData } + Self { client, abi, bytecode, _p: PhantomData, _t: PhantomData } } /// Create a deployment tx using the provided tokens as constructor /// arguments - pub fn deploy_tokens(self, params: Vec) -> Result, ContractError> + pub fn deploy_tokens( + self, + params: Vec, + ) -> Result, ContractDeploymentError> where B: Clone, { // Encode the constructor args & concatenate with the bytecode if necessary let data: Bytes = match (self.abi.constructor(), params.is_empty()) { - (None, false) => return Err(ContractError::ConstructorError), + (None, false) => return Err(ContractDeploymentError::ConstructorError), (None, true) => self.bytecode.clone(), (Some(constructor), _) => { let input: Bytes = constructor .abi_encode_input(¶ms) - .map_err(|f| { - ContractError::DetokenizationError(InvalidOutputType(f.to_string())) - })? + .map_err(ContractDeploymentError::DetokenizationError)? .into(); // Concatenate the bytecode and abi-encoded constructor call. self.bytecode.iter().copied().chain(input).collect() @@ -575,27 +553,32 @@ where }; // create the tx object. Since we're deploying a contract, `to` is `None` - // We default to EIP1559 transactions, but the sender can convert it back - // to a legacy one. - let tx = Eip1559TransactionRequest { - to: None, - data: Some(data.to_ethers()), - ..Default::default() - }; - - let tx = tx.into(); + let tx = WithOtherFields::new(TransactionRequest::default().input(data.into()).to(None)); Ok(Deployer { client: self.client.clone(), abi: self.abi, tx, confs: 1, - block: BlockNumber::Latest, - _m: PhantomData, + _p: PhantomData, + _t: PhantomData, }) } } +#[derive(thiserror::Error, Debug)] +/// An Error which is thrown when interacting with a smart contract +pub enum ContractDeploymentError { + #[error("constructor is not defined in the ABI")] + ConstructorError, + #[error(transparent)] + DetokenizationError(#[from] alloy_dyn_abi::Error), + #[error("contract was not deployed")] + ContractNotDeployed, + #[error(transparent)] + RpcError(#[from] TransportError), +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/tests/cli/utils.rs b/crates/forge/tests/cli/utils.rs index 12b0fe13470f4..e8e79fa688720 100644 --- a/crates/forge/tests/cli/utils.rs +++ b/crates/forge/tests/cli/utils.rs @@ -1,7 +1,8 @@ //! Various helper functions +use alloy_signer_wallet::LocalWallet; use ethers_core::types::{Address, Chain}; -use ethers_signers::{LocalWallet, Signer}; +use foundry_common::types::ToEthers; /// Returns the current millis since unix epoch. /// @@ -46,7 +47,7 @@ pub struct EnvExternalities { impl EnvExternalities { pub fn address(&self) -> Option

{ let pk: LocalWallet = self.pk.parse().ok()?; - Some(pk.address()) + Some(pk.address().to_ethers()) } pub fn goerli() -> Option { diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 49cbce5db7f2d..efbd95d7103ea 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -255,14 +255,14 @@ async fn test_invariant_shrink() { let create_fren_sequence = sequence[0].clone(); assert_eq!( create_fren_sequence.contract_name.unwrap(), - "fuzz/invariant/common/InvariantInnerContract.t.sol:Jesus" + "default/fuzz/invariant/common/InvariantInnerContract.t.sol:Jesus" ); assert_eq!(create_fren_sequence.signature.unwrap(), "create_fren()"); let betray_sequence = sequence[1].clone(); assert_eq!( betray_sequence.contract_name.unwrap(), - "fuzz/invariant/common/InvariantInnerContract.t.sol:Judas" + "default/fuzz/invariant/common/InvariantInnerContract.t.sol:Judas" ); assert_eq!(betray_sequence.signature.unwrap(), "betray()"); } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 02f1aa15eea27..b1f8efc491622 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -4,10 +4,10 @@ use crate::{ config::*, test_helpers::{ForgeTestData, TEST_DATA_DEFAULT}, }; -use alloy_primitives::{address, Address}; -use ethers_core::abi::{Event, EventParam, Log, LogParam, ParamType, RawLog, Token}; +use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; +use alloy_json_abi::Event; +use alloy_primitives::{address, Address, U256}; use forge::result::TestStatus; -use foundry_common::types::ToEthers; use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_evm::{ constants::HARDHAT_CONSOLE_ADDRESS, @@ -125,25 +125,15 @@ test_repro!(3347, false, None, |res| { let mut res = res.remove("default/repros/Issue3347.t.sol:Issue3347Test").unwrap(); let test = res.test_results.remove("test()").unwrap(); assert_eq!(test.logs.len(), 1); - let event = Event { - name: "log2".to_string(), - inputs: vec![ - EventParam { name: "x".to_string(), kind: ParamType::Uint(256), indexed: false }, - EventParam { name: "y".to_string(), kind: ParamType::Uint(256), indexed: false }, - ], - anonymous: false, - }; - let raw_log = RawLog { - topics: test.logs[0].data.topics().iter().map(|t| t.to_ethers()).collect(), - data: test.logs[0].data.data.clone().to_vec(), - }; - let log = event.parse_log(raw_log).unwrap(); + let event = Event::parse("event log2(uint256, uint256)").unwrap(); + let decoded = event.decode_log(&test.logs[0].data, false).unwrap(); assert_eq!( - log, - Log { - params: vec![ - LogParam { name: "x".to_string(), value: Token::Uint(1u64.into()) }, - LogParam { name: "y".to_string(), value: Token::Uint(2u64.into()) } + decoded, + DecodedEvent { + indexed: vec![], + body: vec![ + DynSolValue::Uint(U256::from(1), 256), + DynSolValue::Uint(U256::from(2), 256) ] } ); diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 5ae57482200ef..e62e054bfadb8 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -32,19 +32,24 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } semver = "1" futures = "0.3" async-recursion = "1.0.5" -alloy-primitives.workspace = true -alloy-dyn-abi.workspace = true + itertools.workspace = true parking_lot = "0.12" yansi = "0.5" -ethers-core.workspace = true -ethers-providers.workspace = true -ethers-signers.workspace = true revm-inspectors.workspace = true alloy-rpc-types.workspace = true alloy-json-abi.workspace = true dialoguer = { version = "0.11", default-features = false } indicatif = "0.17" +alloy-signer.workspace = true +alloy-network.workspace = true +alloy-provider.workspace = true +alloy-chains.workspace = true +alloy-dyn-abi.workspace = true +alloy-primitives.workspace = true +alloy-eips.workspace = true +alloy-transport.workspace = true + [dev-dependencies] tempfile = "3" \ No newline at end of file diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 983c02374fb61..0cb5b0c9c5299 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -1,13 +1,15 @@ +use super::receipts; use crate::{ build::LinkedBuildData, sequence::ScriptSequenceKind, verify::BroadcastedState, ScriptArgs, ScriptConfig, }; - -use super::receipts; -use alloy_primitives::{utils::format_units, Address, TxHash, U256}; -use ethers_core::types::{transaction::eip2718::TypedTransaction, BlockId}; -use ethers_providers::{JsonRpcClient, Middleware, Provider}; -use ethers_signers::Signer; +use alloy_chains::Chain; +use alloy_eips::eip2718::Encodable2718; +use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; +use alloy_primitives::{utils::format_units, Address, TxHash}; +use alloy_provider::{utils::Eip1559Estimation, Provider}; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_transport::Transport; use eyre::{bail, Context, Result}; use forge_verify::provider::VerificationProviderType; use foundry_cheatcodes::ScriptWallets; @@ -16,14 +18,12 @@ use foundry_cli::{ utils::{has_batch_support, has_different_gas_calc}, }; use foundry_common::{ - provider::ethers::{ + provider::alloy::{ estimate_eip1559_fees, get_http_provider, try_get_http_provider, RetryProvider, }, shell, - types::{ToAlloy, ToEthers}, }; use foundry_config::Config; -use foundry_wallets::WalletSigner; use futures::{future::join_all, StreamExt}; use itertools::Itertools; use std::{ @@ -31,56 +31,49 @@ use std::{ sync::Arc, }; -pub async fn estimate_gas( - tx: &mut TypedTransaction, - provider: &Provider, +pub async fn estimate_gas( + tx: &mut WithOtherFields, + provider: &P, estimate_multiplier: u64, ) -> Result<()> where - T: JsonRpcClient, + P: Provider, + T: Transport + Clone, { // if already set, some RPC endpoints might simply return the gas value that is already // set in the request and omit the estimate altogether, so we remove it here - let _ = tx.gas_mut().take(); - - tx.set_gas( - provider - .estimate_gas(tx, None) - .await - .wrap_err_with(|| format!("Failed to estimate gas for tx: {:?}", tx.sighash()))? * - estimate_multiplier / + tx.gas = None; + + tx.set_gas_limit( + provider.estimate_gas(tx, None).await.wrap_err("Failed to estimate gas for tx")? * + estimate_multiplier as u128 / 100, ); Ok(()) } -pub async fn next_nonce( - caller: Address, - provider_url: &str, - block: Option, -) -> eyre::Result { - let provider = Provider::try_from(provider_url) +pub async fn next_nonce(caller: Address, provider_url: &str) -> eyre::Result { + let provider = try_get_http_provider(provider_url) .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; - let res = provider.get_transaction_count(caller.to_ethers(), block).await?.to_alloy(); - res.try_into().map_err(Into::into) + Ok(provider.get_transaction_count(caller, None).await?) } pub async fn send_transaction( provider: Arc, - mut tx: TypedTransaction, + mut tx: WithOtherFields, kind: SendTransactionKind<'_>, sequential_broadcast: bool, is_fixed_gas_limit: bool, estimate_via_rpc: bool, estimate_multiplier: u64, ) -> Result { - let from = tx.from().expect("no sender"); + let from = tx.from.expect("no sender"); if sequential_broadcast { - let nonce = provider.get_transaction_count(*from, None).await?; + let nonce = provider.get_transaction_count(from, None).await?; - let tx_nonce = tx.nonce().expect("no nonce"); - if nonce != *tx_nonce { + let tx_nonce = tx.nonce.expect("no nonce"); + if nonce != tx_nonce { bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") } } @@ -96,29 +89,26 @@ pub async fn send_transaction( debug!("sending transaction from unlocked account {:?}: {:?}", addr, tx); // Submit the transaction - provider.send_transaction(tx, None).await? + provider.send_transaction(tx).await? } SendTransactionKind::Raw(signer) => { debug!("sending transaction: {:?}", tx); - // Signing manually so we skip `fill_transaction` and its `eth_createAccessList` - // request. - let signature = - signer.sign_transaction(&tx).await.wrap_err("Failed to sign transaction")?; + let signed = tx.build(signer).await?; // Submit the raw transaction - provider.send_raw_transaction(tx.rlp_signed(&signature)).await? + provider.send_raw_transaction(signed.encoded_2718().as_ref()).await? } }; - Ok(pending.tx_hash().to_alloy()) + Ok(*pending.tx_hash()) } /// How to send a single transaction #[derive(Clone)] pub enum SendTransactionKind<'a> { Unlocked(Address), - Raw(&'a WalletSigner), + Raw(&'a EthereumSigner), } /// Represents how to send _all_ transactions @@ -126,7 +116,7 @@ pub enum SendTransactionsKind { /// Send via `eth_sendTransaction` and rely on the `from` address being unlocked. Unlocked(HashSet
), /// Send a signed transaction via `eth_sendRawTransaction` - Raw(HashMap), + Raw(HashMap), } impl SendTransactionsKind { @@ -202,8 +192,8 @@ impl BundledState { .iter() .flat_map(|sequence| { sequence - .typed_transactions() - .map(|tx| (*tx.from().expect("No sender for onchain transaction!")).to_alloy()) + .transactions() + .map(|tx| (tx.from().expect("No sender for onchain transaction!"))) }) .collect::>(); @@ -233,6 +223,11 @@ impl BundledState { ); } + let signers = signers + .into_iter() + .map(|(addr, signer)| (addr, EthereumSigner::new(signer))) + .collect(); + SendTransactionsKind::Raw(signers) }; @@ -243,23 +238,37 @@ impl BundledState { let already_broadcasted = sequence.receipts.len(); if already_broadcasted < sequence.transactions.len() { + let is_legacy = Chain::from(sequence.chain).is_legacy() || self.args.legacy; // Make a one-time gas price estimation - let (gas_price, eip1559_fees) = match self.args.with_gas_price { - None => match sequence.transactions.front().unwrap().typed_tx() { - TypedTransaction::Eip1559(_) => { - let mut fees = estimate_eip1559_fees(&provider, Some(sequence.chain)) + let (gas_price, eip1559_fees) = match ( + is_legacy, + self.args.with_gas_price, + self.args.priority_gas_price, + ) { + (true, Some(gas_price), _) => (Some(gas_price.to()), None), + (true, None, _) => (Some(provider.get_gas_price().await?), None), + (false, Some(max_fee_per_gas), Some(max_priority_fee_per_gas)) => ( + None, + Some(Eip1559Estimation { + max_fee_per_gas: max_fee_per_gas.to(), + max_priority_fee_per_gas: max_priority_fee_per_gas.to(), + }), + ), + (false, _, _) => { + let mut fees = estimate_eip1559_fees(&provider, Some(sequence.chain)) .await - .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; + .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; - if let Some(priority_gas_price) = self.args.priority_gas_price { - fees.1 = priority_gas_price.to_ethers(); - } + if let Some(gas_price) = self.args.with_gas_price { + fees.max_fee_per_gas = gas_price.to(); + } - (None, Some(fees)) + if let Some(priority_gas_price) = self.args.priority_gas_price { + fees.max_priority_fee_per_gas = priority_gas_price.to(); } - _ => (provider.get_gas_price().await.ok(), None), - }, - Some(gas_price) => (Some(gas_price.to_ethers()), None), + + (None, Some(fees)) + } }; // Iterate through transactions, matching the `from` field with the associated @@ -269,35 +278,21 @@ impl BundledState { .iter() .skip(already_broadcasted) .map(|tx_with_metadata| { - let tx = tx_with_metadata.typed_tx(); - let from = - (*tx.from().expect("No sender for onchain transaction!")).to_alloy(); + let tx = tx_with_metadata.tx(); + let from = tx.from().expect("No sender for onchain transaction!"); let kind = send_kind.for_sender(&from)?; let is_fixed_gas_limit = tx_with_metadata.is_fixed_gas_limit; let mut tx = tx.clone(); - tx.set_chain_id(sequence.chain); if let Some(gas_price) = gas_price { tx.set_gas_price(gas_price); } else { let eip1559_fees = eip1559_fees.expect("was set above"); - // fill gas price - match tx { - TypedTransaction::Eip1559(ref mut inner) => { - inner.max_priority_fee_per_gas = Some(eip1559_fees.1); - inner.max_fee_per_gas = Some(eip1559_fees.0); - } - _ => { - // If we're here, it means that first transaction of the - // sequence was EIP1559 transaction (see match statement above), - // however, we can only have transactions of the same type in - // the sequence. - unreachable!() - } - } + tx.set_max_priority_fee_per_gas(eip1559_fees.max_priority_fee_per_gas); + tx.set_max_fee_per_gas(eip1559_fees.max_fee_per_gas); } Ok((tx, kind, is_fixed_gas_limit)) @@ -375,18 +370,15 @@ impl BundledState { shell::println("\n\n==========================")?; shell::println("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; - let (total_gas, total_gas_price, total_paid) = sequence.receipts.iter().fold( - (U256::ZERO, U256::ZERO, U256::ZERO), - |acc, receipt| { - let gas_used = receipt.gas_used.unwrap_or_default().to_alloy(); - let gas_price = receipt.effective_gas_price.unwrap_or_default().to_alloy(); + let (total_gas, total_gas_price, total_paid) = + sequence.receipts.iter().fold((0, 0, 0), |acc, receipt| { + let gas_used = receipt.gas_used; + let gas_price = receipt.effective_gas_price; (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used * gas_price) - }, - ); + }); let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); - let avg_gas_price = - format_units(total_gas_price / U256::from(sequence.receipts.len()), 9) - .unwrap_or_else(|_| "N/A".to_string()); + let avg_gas_price = format_units(total_gas_price / sequence.receipts.len() as u128, 9) + .unwrap_or_else(|_| "N/A".to_string()); shell::println(format!( "Total Paid: {} ETH ({} gas * avg {} gwei)", diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index ab17a95a9b936..51fde33adafd9 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -7,14 +7,13 @@ use crate::{ }; use alloy_primitives::{Address, Bytes}; -use ethers_providers::Middleware; +use alloy_provider::Provider; use eyre::{Context, OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compile::{self, ContractSources, ProjectCompiler}, - provider::ethers::try_get_http_provider, - types::ToAlloy, + provider::alloy::try_get_http_provider, ContractsByArtifact, }; use foundry_compilers::{ @@ -290,7 +289,7 @@ impl CompiledState { } else { let fork_url = self.script_config.evm_opts.fork_url.clone().ok_or_eyre("Missing --fork-url field, if you were trying to broadcast a multi-chain sequence, please use --multi flag")?; let provider = Arc::new(try_get_http_provider(fork_url)?); - Some(provider.get_chainid().await?.as_u64()) + Some(provider.get_chain_id().await?) }; let sequence = match self.try_load_sequence(chain, false) { @@ -318,7 +317,7 @@ impl CompiledState { s.transactions .iter() .skip(s.receipts.len()) - .map(|t| t.transaction.from().expect("from is missing in script artifact")) + .map(|t| t.transaction.from.expect("from is missing in script artifact")) }); let available_signers = self @@ -326,7 +325,7 @@ impl CompiledState { .signers() .map_err(|e| eyre::eyre!("Failed to get available signers: {}", e))?; - if !froms.all(|from| available_signers.contains(&from.to_alloy())) { + if !froms.all(|from| available_signers.contains(&from)) { // IF we are missing required signers, execute script as we might need to collect // private keys from the execution. let executed = self.link()?.prepare_execution().await?.execute().await?; diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 7b811a67cd91b..03ac8bc9e44d5 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -7,16 +7,16 @@ use crate::{ use super::{runner::ScriptRunner, JsonResult, NestedValue, ScriptResult}; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; -use alloy_primitives::{Address, Bytes, U64}; +use alloy_primitives::{Address, Bytes}; +use alloy_provider::Provider; use alloy_rpc_types::request::TransactionRequest; use async_recursion::async_recursion; -use ethers_providers::Middleware; use eyre::Result; use foundry_cheatcodes::ScriptWallets; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ fmt::{format_token, format_token_raw}, - provider::ethers::{get_http_provider, RpcUrl}, + provider::alloy::{get_http_provider, RpcUrl}, shell, ContractsByArtifact, }; use foundry_compilers::artifacts::ContractBytecodeSome; @@ -135,7 +135,7 @@ impl PreExecutionState { transaction: TransactionRequest { from: Some(self.script_config.evm_opts.sender), input: Some(bytes.clone()).into(), - nonce: Some(U64::from(self.script_config.sender_nonce + i as u64)), + nonce: Some(self.script_config.sender_nonce + i as u64), ..Default::default() }, }) @@ -253,9 +253,8 @@ impl RpcData { async fn check_shanghai_support(&self) -> Result<()> { let chain_ids = self.total_rpcs.iter().map(|rpc| async move { let provider = get_http_provider(rpc); - let id = provider.get_chainid().await.ok()?; - let id_u64: u64 = id.try_into().ok()?; - NamedChain::try_from(id_u64).ok() + let id = provider.get_chain_id().await.ok()?; + NamedChain::try_from(id).ok() }); let chains = join_all(chain_ids).await; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 530c84d36c7bc..8973dc1260c36 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -7,11 +7,11 @@ use self::transaction::AdditionalContract; use crate::runner::ScriptRunner; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_signer::Signer; use broadcast::next_nonce; use build::PreprocessedState; use clap::{Parser, ValueHint}; use dialoguer::Confirm; -use ethers_signers::Signer; use eyre::{ContextCompat, Result}; use forge_verify::RetryArgs; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; @@ -20,10 +20,8 @@ use foundry_common::{ compile::SkipBuildFilter, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, - provider::ethers::RpcUrl, - shell, - types::ToAlloy, - CONTRACT_MAX_SIZE, SELECTOR_LEN, + provider::alloy::RpcUrl, + shell, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::{artifacts::ContractBytecodeSome, ArtifactId}; use foundry_config::{ @@ -305,7 +303,7 @@ impl ScriptArgs { .wallets .private_keys()? .filter(|pks| pks.len() == 1) - .map(|pks| pks.first().unwrap().address().to_alloy()); + .map(|pks| pks.first().unwrap().address()); Ok(maybe_sender) } @@ -531,7 +529,7 @@ pub struct ScriptConfig { impl ScriptConfig { pub async fn new(config: Config, evm_opts: EvmOpts) -> Result { let sender_nonce = if let Some(fork_url) = evm_opts.fork_url.as_ref() { - next_nonce(evm_opts.sender, fork_url, None).await? + next_nonce(evm_opts.sender, fork_url).await? } else { // dapptools compatibility 1 @@ -541,7 +539,7 @@ impl ScriptConfig { pub async fn update_sender(&mut self, sender: Address) -> Result<()> { self.sender_nonce = if let Some(fork_url) = self.evm_opts.fork_url.as_ref() { - next_nonce(sender, fork_url, None).await? + next_nonce(sender, fork_url).await? } else { // dapptools compatibility 1 diff --git a/crates/script/src/providers.rs b/crates/script/src/providers.rs index f29a72629320a..ab2ee99112f9b 100644 --- a/crates/script/src/providers.rs +++ b/crates/script/src/providers.rs @@ -1,11 +1,6 @@ -use alloy_primitives::U256; -use ethers_providers::{Middleware, Provider}; +use alloy_provider::{utils::Eip1559Estimation, Provider}; use eyre::{Result, WrapErr}; -use foundry_common::{ - provider::ethers::{get_http_provider, RpcUrl}, - runtime_client::RuntimeClient, - types::ToAlloy, -}; +use foundry_common::provider::alloy::{get_http_provider, RetryProvider, RpcUrl}; use foundry_config::Chain; use std::{ collections::{hash_map::Entry, HashMap}, @@ -47,23 +42,22 @@ impl Deref for ProvidersManager { /// Holds related metadata to each provider RPC. #[derive(Debug)] pub struct ProviderInfo { - pub provider: Arc>, + pub provider: Arc, pub chain: u64, pub gas_price: GasPrice, - pub is_legacy: bool, } /// Represents the outcome of a gas price request #[derive(Debug)] pub enum GasPrice { - Legacy(Result), - EIP1559(Result<(U256, U256)>), + Legacy(Result), + EIP1559(Result), } impl ProviderInfo { pub async fn new(rpc: &str, mut is_legacy: bool) -> Result { let provider = Arc::new(get_http_provider(rpc)); - let chain = provider.get_chainid().await?.as_u64(); + let chain = provider.get_chain_id().await?; if let Some(chain) = Chain::from(chain).named() { is_legacy |= chain.is_legacy(); @@ -71,30 +65,22 @@ impl ProviderInfo { let gas_price = if is_legacy { GasPrice::Legacy( - provider - .get_gas_price() - .await - .wrap_err("Failed to get legacy gas price") - .map(|p| p.to_alloy()), + provider.get_gas_price().await.wrap_err("Failed to get legacy gas price"), ) } else { GasPrice::EIP1559( - provider - .estimate_eip1559_fees(None) - .await - .wrap_err("Failed to get EIP-1559 fees") - .map(|p| (p.0.to_alloy(), p.1.to_alloy())), + provider.estimate_eip1559_fees(None).await.wrap_err("Failed to get EIP-1559 fees"), ) }; - Ok(ProviderInfo { provider, chain, gas_price, is_legacy }) + Ok(ProviderInfo { provider, chain, gas_price }) } /// Returns the gas price to use - pub fn gas_price(&self) -> Result { + pub fn gas_price(&self) -> Result { let res = match &self.gas_price { GasPrice::Legacy(res) => res.as_ref(), - GasPrice::EIP1559(res) => res.as_ref().map(|res| &res.0), + GasPrice::EIP1559(res) => res.as_ref().map(|res| &res.max_fee_per_gas), }; match res { Ok(val) => Ok(*val), diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 29848aad35647..3bdc228f05755 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -1,27 +1,24 @@ use super::sequence::ScriptSequence; -use alloy_primitives::TxHash; -use ethers_core::types::TransactionReceipt; -use ethers_providers::{Middleware, PendingTransaction}; +use alloy_chains::Chain; +use alloy_primitives::{utils::format_units, TxHash, U256}; +use alloy_provider::{PendingTransactionBuilder, Provider}; +use alloy_rpc_types::AnyTransactionReceipt; use eyre::Result; -use foundry_cli::{init_progress, update_progress, utils::print_receipt}; -use foundry_common::{ - provider::ethers::RetryProvider, - types::{ToAlloy, ToEthers}, -}; +use foundry_cli::{init_progress, update_progress}; +use foundry_common::provider::alloy::RetryProvider; use futures::StreamExt; use std::sync::Arc; /// Convenience enum for internal signalling of transaction status enum TxStatus { Dropped, - Success(TransactionReceipt), - Revert(TransactionReceipt), + Success(AnyTransactionReceipt), + Revert(AnyTransactionReceipt), } -impl From for TxStatus { - fn from(receipt: TransactionReceipt) -> Self { - let status = receipt.status.expect("receipt is from an ancient, pre-EIP658 block"); - if status.is_zero() { +impl From for TxStatus { + fn from(receipt: AnyTransactionReceipt) -> Self { + if !receipt.inner.inner.inner.receipt.status { TxStatus::Revert(receipt) } else { TxStatus::Success(receipt) @@ -68,7 +65,7 @@ pub async fn clear_pendings( let mut tasks = futures::stream::iter(futs).buffer_unordered(10); let mut errors: Vec = vec![]; - let mut receipts = Vec::::with_capacity(count); + let mut receipts = Vec::::with_capacity(count); // set up progress bar let mut pos = 0; @@ -87,7 +84,7 @@ pub async fn clear_pendings( } Ok(TxStatus::Success(receipt)) => { trace!(tx_hash=?tx_hash, "received tx receipt"); - deployment_sequence.remove_pending(receipt.transaction_hash.to_alloy()); + deployment_sequence.remove_pending(receipt.transaction_hash); receipts.push(receipt); } Ok(TxStatus::Revert(receipt)) => { @@ -95,7 +92,7 @@ pub async fn clear_pendings( // if this is not removed from pending, then the script becomes // un-resumable. Is this desirable on reverts? warn!(tx_hash=?tx_hash, "Transaction Failure"); - deployment_sequence.remove_pending(receipt.transaction_hash.to_alloy()); + deployment_sequence.remove_pending(receipt.transaction_hash); errors.push(format!("Transaction Failure: {:?}", receipt.transaction_hash)); } } @@ -105,7 +102,7 @@ pub async fn clear_pendings( } // sort receipts by blocks asc and index - receipts.sort_unstable(); + receipts.sort_by_key(|r| (r.block_number, r.transaction_index)); // print all receipts for receipt in receipts { @@ -136,20 +133,53 @@ async fn check_tx_status( // still neatly return the tuple let result = async move { // First check if there's a receipt - let receipt_opt = provider.get_transaction_receipt(hash.to_ethers()).await?; + let receipt_opt = provider.get_transaction_receipt(hash).await?; if let Some(receipt) = receipt_opt { return Ok(receipt.into()); } // If the tx is present in the mempool, run the pending tx future, and // assume the next drop is really really real - let pending_res = PendingTransaction::new(hash.to_ethers(), provider).await?; - match pending_res { - Some(receipt) => Ok(receipt.into()), - None => Ok(TxStatus::Dropped), - } + Ok(PendingTransactionBuilder::new(provider, hash) + .get_receipt() + .await + .map_or(TxStatus::Dropped, |r| r.into())) } .await; (hash, result) } + +/// Prints parts of the receipt to stdout +pub fn print_receipt(chain: Chain, receipt: &AnyTransactionReceipt) { + let gas_used = receipt.gas_used; + let gas_price = receipt.effective_gas_price; + foundry_common::shell::println(format!( + "\n##### {chain}\n{status}Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n", + status = if !receipt.inner.inner.inner.receipt.status { + "❌ [Failed]" + } else { + "✅ [Success]" + }, + tx_hash = receipt.transaction_hash, + caddr = if let Some(addr) = &receipt.contract_address { + format!("\nContract Address: {}", addr.to_checksum(None)) + } else { + String::new() + }, + bn = receipt.block_number.unwrap_or_default(), + gas = if gas_price == 0 { + format!("Gas Used: {gas_used}") + } else { + let paid = format_units(gas_used.saturating_mul(gas_price), 18) + .unwrap_or_else(|_| "N/A".into()); + let gas_price = format_units(U256::from(gas_price), 9).unwrap_or_else(|_| "N/A".into()); + format!( + "Paid: {} ETH ({gas_used} gas * {} gwei)", + paid.trim_end_matches('0'), + gas_price.trim_end_matches('0').trim_end_matches('.') + ) + }, + )) + .expect("could not print receipt"); +} diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 9fdee7b021bf5..2d39c12923dbd 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -1,18 +1,14 @@ use super::{multi_sequence::MultiChainSequence, NestedValue}; use crate::{ - transaction::{wrapper, AdditionalContract, TransactionWithMetadata}, + transaction::{AdditionalContract, TransactionWithMetadata}, verify::VerifyBundle, }; use alloy_primitives::{Address, TxHash}; -use ethers_core::types::{transaction::eip2718::TypedTransaction, TransactionReceipt}; +use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest, WithOtherFields}; use eyre::{ContextCompat, Result, WrapErr}; use forge_verify::provider::VerificationProviderType; use foundry_cli::utils::{now, Git}; -use foundry_common::{ - fs, shell, - types::{ToAlloy, ToEthers}, - SELECTOR_LEN, -}; +use foundry_common::{fs, shell, SELECTOR_LEN}; use foundry_compilers::ArtifactId; use foundry_config::Config; use serde::{Deserialize, Serialize}; @@ -91,8 +87,7 @@ pub const DRY_RUN_DIR: &str = "dry-run"; #[derive(Clone, Default, Serialize, Deserialize)] pub struct ScriptSequence { pub transactions: VecDeque, - #[serde(serialize_with = "wrapper::serialize_receipts")] - pub receipts: Vec, + pub receipts: Vec, pub libraries: Vec, pub pending: Vec, #[serde(skip)] @@ -201,13 +196,13 @@ impl ScriptSequence { Ok(()) } - pub fn add_receipt(&mut self, receipt: TransactionReceipt) { + pub fn add_receipt(&mut self, receipt: AnyTransactionReceipt) { self.receipts.push(receipt); } /// Sorts all receipts with ascending transaction index pub fn sort_receipts(&mut self) { - self.receipts.sort_unstable() + self.receipts.sort_by_key(|r| (r.block_number, r.transaction_index)); } pub fn add_pending(&mut self, index: usize, tx_hash: TxHash) { @@ -284,13 +279,13 @@ impl ScriptSequence { let mut offset = 0; if tx.is_create2() { - receipt.contract_address = tx.contract_address.map(|a| a.to_ethers()); + receipt.contract_address = tx.contract_address; offset = 32; } // Verify contract created directly from the transaction if let (Some(address), Some(data)) = - (receipt.contract_address.map(|h| h.to_alloy()), tx.typed_tx().data()) + (receipt.contract_address, tx.tx().input.input()) { match verify.get_verify_args(address, offset, &data.0, &self.libraries) { Some(verify) => future_verifications.push(verify.run()), @@ -300,7 +295,7 @@ impl ScriptSequence { // Verify potential contracts created during the transaction execution for AdditionalContract { address, init_code, .. } in &tx.additional_contracts { - match verify.get_verify_args(*address, 0, init_code, &self.libraries) { + match verify.get_verify_args(*address, 0, init_code.as_ref(), &self.libraries) { Some(verify) => future_verifications.push(verify.run()), None => unverifiable_contracts.push(*address), }; @@ -357,8 +352,8 @@ impl ScriptSequence { } /// Returns the list of the transactions without the metadata. - pub fn typed_transactions(&self) -> impl Iterator { - self.transactions.iter().map(|tx| tx.typed_tx()) + pub fn transactions(&self) -> impl Iterator> { + self.transactions.iter().map(|tx| tx.tx()) } pub fn fill_sensitive(&mut self, sensitive: &SensitiveScriptSequence) { diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 96b1eaefe2f0f..c740e59a4735b 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -13,13 +13,12 @@ use crate::{ sequence::get_commit_hash, ScriptArgs, ScriptConfig, ScriptResult, }; +use alloy_network::TransactionBuilder; use alloy_primitives::{utils::format_units, Address, U256}; use eyre::{Context, Result}; use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; use foundry_cli::utils::{has_different_gas_calc, now}; -use foundry_common::{ - get_contract_name, provider::ethers::RpcUrl, shell, types::ToAlloy, ContractsByArtifact, -}; +use foundry_common::{get_contract_name, provider::alloy::RpcUrl, shell, ContractsByArtifact}; use foundry_evm::traces::render_trace_arena; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; @@ -132,9 +131,8 @@ impl PreSimulationState { } // We inflate the gas used by the user specified percentage None => { - let gas = - U256::from(result.gas_used * self.args.gas_estimate_multiplier / 100); - tx.gas = Some(gas); + let gas = result.gas_used * self.args.gas_estimate_multiplier / 100; + tx.gas = Some(gas as u128); } } let tx = TransactionWithMetadata::new( @@ -266,7 +264,7 @@ impl FilledTransactionsState { eyre::bail!("Multi-chain deployment is not supported with libraries."); } - let mut total_gas_per_rpc: HashMap = HashMap::new(); + let mut total_gas_per_rpc: HashMap = HashMap::new(); // Batches sequence of transactions from different rpcs. let mut new_sequence = VecDeque::new(); @@ -282,15 +280,14 @@ impl FilledTransactionsState { let provider_info = manager.get_or_init_provider(&tx.rpc, self.args.legacy).await?; // Handles chain specific requirements. - tx.change_type(provider_info.is_legacy); tx.transaction.set_chain_id(provider_info.chain); if !self.args.skip_simulation { - let typed_tx = tx.typed_tx_mut(); + let tx = tx.tx_mut(); if has_different_gas_calc(provider_info.chain) { trace!("estimating with different gas calculation"); - let gas = *typed_tx.gas().expect("gas is set by simulation."); + let gas = tx.gas.expect("gas is set by simulation."); // We are trying to show the user an estimation of the total gas usage. // @@ -303,22 +300,19 @@ impl FilledTransactionsState { // for chains where `has_different_gas_calc` returns true, // we await each transaction before broadcasting the next // one. - if let Err(err) = estimate_gas( - typed_tx, - &provider_info.provider, - self.args.gas_estimate_multiplier, - ) - .await + if let Err(err) = + estimate_gas(tx, &provider_info.provider, self.args.gas_estimate_multiplier) + .await { trace!("gas estimation failed: {err}"); // Restore gas value, since `estimate_gas` will remove it. - typed_tx.set_gas(gas); + tx.set_gas_limit(gas); } } - let total_gas = total_gas_per_rpc.entry(tx_rpc.clone()).or_insert(U256::ZERO); - *total_gas += (*typed_tx.gas().expect("gas is set")).to_alloy(); + let total_gas = total_gas_per_rpc.entry(tx_rpc.clone()).or_insert(0); + *total_gas += tx.gas.expect("gas is set"); } new_sequence.push_back(tx); @@ -346,7 +340,7 @@ impl FilledTransactionsState { // We don't store it in the transactions, since we want the most updated value. // Right before broadcasting. let per_gas = if let Some(gas_price) = self.args.with_gas_price { - gas_price + gas_price.to() } else { provider_info.gas_price()? }; diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 80a2814207aa6..e74699e749137 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,18 +1,9 @@ use super::{artifacts::ArtifactInfo, ScriptResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_primitives::{Address, Bytes, B256}; -use alloy_rpc_types::request::TransactionRequest; -use ethers_core::types::{ - transaction::eip2718::TypedTransaction, NameOrAddress, - TransactionRequest as EthersTransactionRequest, -}; +use alloy_rpc_types::{request::TransactionRequest, WithOtherFields}; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{ - fmt::format_token_raw, - provider::ethers::RpcUrl, - types::{ToAlloy, ToEthers}, - SELECTOR_LEN, -}; +use foundry_common::{fmt::format_token_raw, provider::alloy::RpcUrl, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; use itertools::Itertools; use revm_inspectors::tracing::types::CallKind; @@ -24,7 +15,6 @@ use std::collections::BTreeMap; pub struct AdditionalContract { #[serde(rename = "transactionType")] pub opcode: CallKind, - #[serde(serialize_with = "wrapper::serialize_addr")] pub address: Address, pub init_code: Bytes, } @@ -37,7 +27,7 @@ pub struct TransactionWithMetadata { pub opcode: CallKind, #[serde(default = "default_string")] pub contract_name: Option, - #[serde(default = "default_address", serialize_with = "wrapper::serialize_opt_addr")] + #[serde(default = "default_address")] pub contract_address: Option
, #[serde(default = "default_string")] pub function: Option, @@ -45,7 +35,7 @@ pub struct TransactionWithMetadata { pub arguments: Option>, #[serde(skip)] pub rpc: RpcUrl, - pub transaction: TypedTransaction, + pub transaction: WithOtherFields, pub additional_contracts: Vec, pub is_fixed_gas_limit: bool, } @@ -64,18 +54,7 @@ fn default_vec_of_strings() -> Option> { impl TransactionWithMetadata { pub fn from_tx_request(transaction: TransactionRequest) -> Self { - Self { - transaction: TypedTransaction::Legacy(EthersTransactionRequest { - from: transaction.from.map(ToEthers::to_ethers), - to: transaction.to.map(ToEthers::to_ethers).map(Into::into), - value: transaction.value.map(ToEthers::to_ethers), - data: transaction.input.into_input().map(ToEthers::to_ethers), - nonce: transaction.nonce.map(|n| n.to::().into()), - gas: transaction.gas.map(ToEthers::to_ethers), - ..Default::default() - }), - ..Default::default() - } + Self { transaction: WithOtherFields::new(transaction), ..Default::default() } } pub fn new( @@ -92,8 +71,8 @@ impl TransactionWithMetadata { metadata.is_fixed_gas_limit = is_fixed_gas_limit; // Specify if any contract was directly created with this transaction - if let Some(NameOrAddress::Address(to)) = metadata.transaction.to().cloned() { - if to.to_alloy() == DEFAULT_CREATE2_DEPLOYER { + if let Some(to) = metadata.transaction.to { + if to == DEFAULT_CREATE2_DEPLOYER { metadata.set_create( true, Address::from_slice(&result.returned), @@ -101,10 +80,10 @@ impl TransactionWithMetadata { )?; } else { metadata - .set_call(to.to_alloy(), local_contracts, decoder) + .set_call(to, local_contracts, decoder) .wrap_err("Could not decode transaction type.")?; } - } else if metadata.transaction.to().is_none() { + } else { metadata.set_create( false, result.address.wrap_err("There should be a contract address from CREATE.")?, @@ -150,7 +129,7 @@ impl TransactionWithMetadata { self.contract_name = info.map(|info| info.contract_name.clone()); self.contract_address = Some(address); - let Some(data) = self.transaction.data() else { return Ok(()) }; + let Some(data) = self.transaction.input.input() else { return Ok(()) }; let Some(info) = info else { return Ok(()) }; // `create2` transactions are prefixed by a 32 byte salt. @@ -197,7 +176,7 @@ impl TransactionWithMetadata { self.opcode = CallKind::Call; self.contract_address = Some(target); - let Some(data) = self.transaction.data() else { return Ok(()) }; + let Some(data) = self.transaction.input.input() else { return Ok(()) }; if data.len() < SELECTOR_LEN { return Ok(()); } @@ -229,19 +208,11 @@ impl TransactionWithMetadata { Ok(()) } - pub fn change_type(&mut self, is_legacy: bool) { - self.transaction = if is_legacy { - TypedTransaction::Legacy(self.transaction.clone().into()) - } else { - TypedTransaction::Eip1559(self.transaction.clone().into()) - }; - } - - pub fn typed_tx(&self) -> &TypedTransaction { + pub fn tx(&self) -> &WithOtherFields { &self.transaction } - pub fn typed_tx_mut(&mut self) -> &mut TypedTransaction { + pub fn tx_mut(&mut self) -> &mut WithOtherFields { &mut self.transaction } @@ -249,208 +220,3 @@ impl TransactionWithMetadata { self.opcode == CallKind::Create2 } } - -// wrapper for modifying ethers-rs type serialization -pub mod wrapper { - pub use super::*; - use ethers_core::{ - types::{Bloom, Bytes, Log, TransactionReceipt, H256, U256, U64}, - utils::to_checksum, - }; - - pub fn serialize_addr(addr: &Address, serializer: S) -> Result - where - S: serde::Serializer, - { - serializer.serialize_str(&to_checksum(&addr.to_ethers(), None)) - } - - pub fn serialize_opt_addr(opt: &Option
, serializer: S) -> Result - where - S: serde::Serializer, - { - match opt { - Some(addr) => serialize_addr(addr, serializer), - None => serializer.serialize_none(), - } - } - - pub fn serialize_vec_with_wrapped( - vec: &[T], - serializer: S, - ) -> Result - where - S: serde::Serializer, - T: Clone, - WrappedType: serde::Serialize + From, - { - serializer.collect_seq(vec.iter().cloned().map(WrappedType::from)) - } - - // copied from https://github.com/gakonst/ethers-rs - #[derive(Serialize, Deserialize)] - struct WrappedLog { - /// The contract address that emitted the log. - #[serde(serialize_with = "serialize_addr")] - pub address: Address, - - /// Array of 0 to 4 32 Bytes of indexed log arguments. - /// - /// (In solidity: The first topic is the hash of the signature of the event - /// (e.g. `Deposit(address,bytes32,uint256)`), except you declared the event - /// with the anonymous specifier.) - pub topics: Vec, - - /// Data - pub data: Bytes, - - /// Block Hash - #[serde(rename = "blockHash")] - #[serde(skip_serializing_if = "Option::is_none")] - pub block_hash: Option, - - /// Block Number - #[serde(rename = "blockNumber")] - #[serde(skip_serializing_if = "Option::is_none")] - pub block_number: Option, - - /// Transaction Hash - #[serde(rename = "transactionHash")] - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_hash: Option, - - /// Transaction Index - #[serde(rename = "transactionIndex")] - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_index: Option, - - /// Integer of the log index position in the block. None if it's a pending log. - #[serde(rename = "logIndex")] - #[serde(skip_serializing_if = "Option::is_none")] - pub log_index: Option, - - /// Integer of the transactions index position log was created from. - /// None when it's a pending log. - #[serde(rename = "transactionLogIndex")] - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_log_index: Option, - - /// Log Type - #[serde(rename = "logType")] - #[serde(skip_serializing_if = "Option::is_none")] - pub log_type: Option, - - /// True when the log was removed, due to a chain reorganization. - /// false if it's a valid log. - #[serde(skip_serializing_if = "Option::is_none")] - pub removed: Option, - } - impl From for WrappedLog { - fn from(log: Log) -> Self { - Self { - address: log.address.to_alloy(), - topics: log.topics, - data: log.data, - block_hash: log.block_hash, - block_number: log.block_number, - transaction_hash: log.transaction_hash, - transaction_index: log.transaction_index, - log_index: log.log_index, - transaction_log_index: log.transaction_log_index, - log_type: log.log_type, - removed: log.removed, - } - } - } - - fn serialize_logs( - logs: &[Log], - serializer: S, - ) -> Result { - serialize_vec_with_wrapped::(logs, serializer) - } - - // "Receipt" of an executed transaction: details of its execution. - // copied from https://github.com/gakonst/ethers-rs - #[derive(Clone, Default, Serialize, Deserialize)] - pub struct WrappedTransactionReceipt { - /// Transaction hash. - #[serde(rename = "transactionHash")] - pub transaction_hash: H256, - /// Index within the block. - #[serde(rename = "transactionIndex")] - pub transaction_index: U64, - /// Hash of the block this transaction was included within. - #[serde(rename = "blockHash")] - pub block_hash: Option, - /// Number of the block this transaction was included within. - #[serde(rename = "blockNumber")] - pub block_number: Option, - /// The address of the sender. - #[serde(serialize_with = "serialize_addr")] - pub from: Address, - // The address of the receiver. `None` when its a contract creation transaction. - #[serde(serialize_with = "serialize_opt_addr")] - pub to: Option
, - /// Cumulative gas used within the block after this was executed. - #[serde(rename = "cumulativeGasUsed")] - pub cumulative_gas_used: U256, - /// Gas used by this transaction alone. - /// - /// Gas used is `None` if the client is running in light client mode. - #[serde(rename = "gasUsed")] - pub gas_used: Option, - /// Contract address created, or `None` if not a deployment. - #[serde(rename = "contractAddress", serialize_with = "serialize_opt_addr")] - pub contract_address: Option
, - /// Logs generated within this transaction. - #[serde(serialize_with = "serialize_logs")] - pub logs: Vec, - /// Status: either 1 (success) or 0 (failure). Only present after activation of [EIP-658](https://eips.ethereum.org/EIPS/eip-658) - pub status: Option, - /// State root. Only present before activation of [EIP-658](https://eips.ethereum.org/EIPS/eip-658) - #[serde(default, skip_serializing_if = "Option::is_none")] - pub root: Option, - /// Logs bloom - #[serde(rename = "logsBloom")] - pub logs_bloom: Bloom, - /// Transaction type, Some(1) for AccessList transaction, None for Legacy - #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")] - pub transaction_type: Option, - /// The price paid post-execution by the transaction (i.e. base fee + priority fee). - /// Both fields in 1559-style transactions are *maximums* (max fee + max priority fee), the - /// amount that's actually paid by users can only be determined post-execution - #[serde(rename = "effectiveGasPrice", default, skip_serializing_if = "Option::is_none")] - pub effective_gas_price: Option, - } - impl From for WrappedTransactionReceipt { - fn from(receipt: TransactionReceipt) -> Self { - Self { - transaction_hash: receipt.transaction_hash, - transaction_index: receipt.transaction_index, - block_hash: receipt.block_hash, - block_number: receipt.block_number, - from: receipt.from.to_alloy(), - to: receipt.to.map(|addr| addr.to_alloy()), - cumulative_gas_used: receipt.cumulative_gas_used, - gas_used: receipt.gas_used, - contract_address: receipt.contract_address.map(|addr| addr.to_alloy()), - logs: receipt.logs, - status: receipt.status, - root: receipt.root, - logs_bloom: receipt.logs_bloom, - transaction_type: receipt.transaction_type, - effective_gas_price: receipt.effective_gas_price, - } - } - } - - pub fn serialize_receipts( - receipts: &[TransactionReceipt], - serializer: S, - ) -> Result { - serialize_vec_with_wrapped::( - receipts, serializer, - ) - } -} diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 8e2b75931734b..09025e27c6f38 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -17,9 +17,7 @@ foundry-compilers = { workspace = true, features = ["project-util"] } foundry-config.workspace = true alloy-primitives.workspace = true - -ethers-core.workspace = true -ethers-providers.workspace = true +alloy-provider.workspace = true eyre.workspace = true fd-lock = "4.0.0" diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index b60723d9d8d2c..fecbc9f5f07f8 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,12 +1,8 @@ use crate::{init_tracing, TestCommand}; -use alloy_primitives::{Address, U256}; -use ethers_core::types::NameOrAddress; -use ethers_providers::Middleware; +use alloy_primitives::Address; +use alloy_provider::Provider; use eyre::Result; -use foundry_common::{ - provider::ethers::{get_http_provider, RetryProvider}, - types::{ToAlloy, ToEthers}, -}; +use foundry_common::provider::alloy::{get_http_provider, RetryProvider}; use std::{collections::BTreeMap, fs, path::Path, str::FromStr}; const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; @@ -17,8 +13,8 @@ pub struct ScriptTester { pub accounts_pub: Vec
, pub accounts_priv: Vec, pub provider: Option, - pub nonces: BTreeMap, - pub address_nonces: BTreeMap, + pub nonces: BTreeMap, + pub address_nonces: BTreeMap, pub cmd: TestCommand, } @@ -121,13 +117,10 @@ impl ScriptTester { if let Some(provider) = &self.provider { let nonce = provider - .get_transaction_count( - NameOrAddress::Address(self.accounts_pub[index as usize].to_ethers()), - None, - ) + .get_transaction_count(self.accounts_pub[index as usize], None) .await .unwrap(); - self.nonces.insert(index, nonce.to_alloy()); + self.nonces.insert(index, nonce); } } self @@ -135,14 +128,9 @@ impl ScriptTester { pub async fn load_addresses(&mut self, addresses: &[Address]) -> &mut Self { for &address in addresses { - let nonce = self - .provider - .as_ref() - .unwrap() - .get_transaction_count(NameOrAddress::Address(address.to_ethers()), None) - .await - .unwrap(); - self.address_nonces.insert(address, nonce.to_alloy()); + let nonce = + self.provider.as_ref().unwrap().get_transaction_count(address, None).await.unwrap(); + self.address_nonces.insert(address, nonce); } self } @@ -181,18 +169,13 @@ impl ScriptTester { pub async fn assert_nonce_increment(&mut self, keys_indexes: &[(u32, u32)]) -> &mut Self { for &(private_key_slot, expected_increment) in keys_indexes { let addr = self.accounts_pub[private_key_slot as usize]; - let nonce = self - .provider - .as_ref() - .unwrap() - .get_transaction_count(NameOrAddress::Address(addr.to_ethers()), None) - .await - .unwrap(); + let nonce = + self.provider.as_ref().unwrap().get_transaction_count(addr, None).await.unwrap(); let prev_nonce = self.nonces.get(&private_key_slot).unwrap(); assert_eq!( nonce, - (prev_nonce + U256::from(expected_increment)).to_ethers(), + (*prev_nonce + expected_increment as u64), "nonce not incremented correctly for {addr}: \ {prev_nonce} + {expected_increment} != {nonce}" ); @@ -210,12 +193,12 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(NameOrAddress::Address(address.to_ethers()), None) + .get_transaction_count(*address, None) .await .unwrap(); let prev_nonce = self.address_nonces.get(address).unwrap(); - assert_eq!(nonce, (prev_nonce + U256::from(*expected_increment)).to_ethers()); + assert_eq!(nonce, *prev_nonce + *expected_increment as u64); } self } diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index a735b39af57bd..832cf1c6b39c6 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -22,7 +22,7 @@ alloy-json-abi.workspace = true alloy-primitives.workspace = true serde.workspace = true eyre.workspace = true -ethers-providers.workspace = true +alloy-provider.workspace = true tracing.workspace = true foundry-compilers = { workspace = true, features = ["full"] } foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 5922f64add1a7..ec218e714e90d 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -1,7 +1,7 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use crate::retry::RETRY_CHECK_ON_VERIFY; use alloy_json_abi::Function; -use ethers_providers::Middleware; +use alloy_provider::Provider; use eyre::{eyre, Context, OptionExt, Result}; use foundry_block_explorers::{ errors::EtherscanError, @@ -10,7 +10,7 @@ use foundry_block_explorers::{ Client, }; use foundry_cli::utils::{self, get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; -use foundry_common::{abi::encode_function_args, retry::Retry, types::ToEthers}; +use foundry_common::{abi::encode_function_args, retry::Retry}; use foundry_compilers::{ artifacts::{BytecodeObject, CompactContract}, cache::CacheEntry, @@ -498,20 +498,17 @@ impl EtherscanVerificationProvider { )?; let creation_data = client.contract_creation_data(args.address).await?; - let transaction = provider - .get_transaction(creation_data.transaction_hash.to_ethers()) - .await? - .ok_or_eyre("Couldn't fetch transaction data from RPC")?; + let transaction = provider.get_transaction_by_hash(creation_data.transaction_hash).await?; let receipt = provider - .get_transaction_receipt(creation_data.transaction_hash.to_ethers()) + .get_transaction_receipt(creation_data.transaction_hash) .await? .ok_or_eyre("Couldn't fetch transaction receipt from RPC")?; let maybe_creation_code: &[u8]; - if receipt.contract_address == Some(args.address.to_ethers()) { + if receipt.contract_address == Some(args.address) { maybe_creation_code = &transaction.input; - } else if transaction.to == Some(DEFAULT_CREATE2_DEPLOYER.to_ethers()) { + } else if transaction.to == Some(DEFAULT_CREATE2_DEPLOYER) { maybe_creation_code = &transaction.input[32..]; } else { eyre::bail!("Fetching of constructor arguments is not supported for contracts created by contracts") diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 1ef26972dbd4f..31ea5607ce964 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -11,13 +11,18 @@ repository.workspace = true [dependencies] alloy-primitives.workspace = true - -ethers-core.workspace = true -ethers-providers.workspace = true -ethers-signers = { workspace = true, features = ["aws", "ledger", "trezor"] } - -rusoto_core = { version = "0.48", default-features = false } -rusoto_kms = { version = "0.48", default-features = false } +alloy-signer = { workspace = true, features = ["eip712"] } +alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } +alloy-signer-aws.workspace = true +alloy-signer-ledger.workspace = true +alloy-signer-trezor.workspace = true +alloy-network.workspace = true +alloy-consensus.workspace = true +alloy-sol-types.workspace = true +alloy-dyn-abi.workspace = true + +aws-sdk-kms = { version = "1", default-features = false } +aws-config = "1" foundry-config.workspace = true foundry-common.workspace = true @@ -38,5 +43,4 @@ tokio = { version = "1", features = ["macros"] } [features] default = ["rustls"] -rustls = ["ethers-providers/rustls", "rusoto_core/rustls"] -openssl = ["ethers-providers/openssl"] +rustls = ["aws-sdk-kms/rustls"] diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index 6588f5e22cc17..b9a5e34f592ab 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -1,4 +1,8 @@ -use ethers_signers::{AwsSignerError, LedgerError, TrezorError, WalletError}; +use alloy_signer::k256::ecdsa; +use alloy_signer_aws::AwsSignerError; +use alloy_signer_ledger::LedgerError; +use alloy_signer_trezor::TrezorError; +use alloy_signer_wallet::WalletError; use hex::FromHexError; #[derive(Debug, thiserror::Error)] @@ -23,6 +27,8 @@ pub enum WalletSignerError { Io(#[from] std::io::Error), #[error(transparent)] InvalidHex(#[from] FromHexError), + #[error(transparent)] + Ecdsa(#[from] ecdsa::Error), #[error("{0} cannot sign raw hashes")] CannotSignRawHash(&'static str), } diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index d9673985a11f7..c95bb8d0e2ae0 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -3,11 +3,10 @@ use crate::{ wallet_signer::{PendingSigner, WalletSigner}, }; use alloy_primitives::Address; +use alloy_signer::Signer; use clap::Parser; use derive_builder::Builder; -use ethers_signers::Signer; use eyre::Result; -use foundry_common::types::ToAlloy; use foundry_config::Config; use serde::Serialize; use std::{collections::HashMap, iter::repeat, path::PathBuf}; @@ -24,15 +23,14 @@ pub struct MultiWallet { impl MultiWallet { pub fn new(pending_signers: Vec, signers: Vec) -> Self { - let signers = - signers.into_iter().map(|signer| (signer.address().to_alloy(), signer)).collect(); + let signers = signers.into_iter().map(|signer| (signer.address(), signer)).collect(); Self { pending_signers, signers } } fn maybe_unlock_pending(&mut self) -> Result<()> { for pending in self.pending_signers.drain(..) { let signer = pending.unlock()?; - self.signers.insert(signer.address().to_alloy(), signer); + self.signers.insert(signer.address(), signer); } Ok(()) } @@ -48,7 +46,7 @@ impl MultiWallet { } pub fn add_signer(&mut self, signer: WalletSigner) { - self.signers.insert(signer.address().to_alloy(), signer); + self.signers.insert(signer.address(), signer); } } @@ -386,7 +384,7 @@ impl MultiWalletOpts { .collect::>(); for key in aws_keys { - let aws_signer = WalletSigner::from_aws(&key).await?; + let aws_signer = WalletSigner::from_aws(key).await?; wallets.push(aws_signer) } @@ -399,7 +397,7 @@ impl MultiWalletOpts { #[cfg(test)] mod tests { use super::*; - use std::path::Path; + use std::{path::Path, str::FromStr}; #[test] fn parse_keystore_args() { @@ -439,7 +437,7 @@ mod tests { assert_eq!(unlocked.len(), 1); assert_eq!( unlocked[0].address(), - "ec554aeafe75601aaab43bd4621a22284db566c2".parse().unwrap() + Address::from_str("0xec554aeafe75601aaab43bd4621a22284db566c2").unwrap() ); } diff --git a/crates/wallets/src/utils.rs b/crates/wallets/src/utils.rs index a10903313034f..08c95242af332 100644 --- a/crates/wallets/src/utils.rs +++ b/crates/wallets/src/utils.rs @@ -1,39 +1,35 @@ use crate::{error::PrivateKeyError, PendingSigner, WalletSigner}; -use ethers_signers::{HDPath as LedgerHDPath, LocalWallet, TrezorHDPath, WalletError}; +use alloy_primitives::B256; +use alloy_signer_ledger::HDPath as LedgerHDPath; +use alloy_signer_trezor::HDPath as TrezorHDPath; +use alloy_signer_wallet::LocalWallet; use eyre::{Context, Result}; use foundry_config::Config; use std::{ fs, path::{Path, PathBuf}, - str::FromStr, }; +fn ensure_pk_not_env(pk: &str) -> Result<()> { + if !pk.starts_with("0x") && std::env::var(pk).is_ok() { + return Err(PrivateKeyError::ExistsAsEnvVar(pk.to_string()).into()); + } + Ok(()) +} + /// Validates and sanitizes user inputs, returning configured [WalletSigner]. pub fn create_private_key_signer(private_key: &str) -> Result { let privk = private_key.trim().strip_prefix("0x").unwrap_or(private_key); - match LocalWallet::from_str(privk) { + + let Ok(private_key) = hex::decode(privk) else { + ensure_pk_not_env(privk)?; + eyre::bail!("Failed to decode private key") + }; + + match LocalWallet::from_bytes(&B256::from_slice(&private_key)) { Ok(pk) => Ok(WalletSigner::Local(pk)), Err(err) => { - // helper closure to check if pk was meant to be an env var, this usually happens if - // `$` is missing - let ensure_not_env = |pk: &str| { - // check if pk was meant to be an env var - if !pk.starts_with("0x") && std::env::var(pk).is_ok() { - // SAFETY: at this point we know the user actually wanted to use an env var - // and most likely forgot the `$` anchor, so the - // `private_key` here is an unresolved env var - return Err(PrivateKeyError::ExistsAsEnvVar(pk.to_string())) - } - Ok(()) - }; - match err { - WalletError::HexError(err) => { - ensure_not_env(private_key)?; - return Err(PrivateKeyError::InvalidHex(err).into()); - } - WalletError::EcdsaError(_) => ensure_not_env(private_key)?, - _ => {} - }; + ensure_pk_not_env(privk)?; eyre::bail!("Failed to create wallet from private key: {err}") } } diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index cd7359f2e2ce8..5773e57d80b6c 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -1,9 +1,8 @@ use crate::{raw_wallet::RawWalletOpts, utils, wallet_signer::WalletSigner}; use alloy_primitives::Address; +use alloy_signer::Signer; use clap::Parser; -use ethers_signers::Signer; use eyre::Result; -use foundry_common::types::ToAlloy; use serde::Serialize; /// The wallet options can either be: @@ -95,7 +94,7 @@ impl WalletOpts { .await? } else if self.aws { let key_id = std::env::var("AWS_KMS_KEY_ID")?; - WalletSigner::from_aws(&key_id).await? + WalletSigner::from_aws(key_id).await? } else if let Some(raw_wallet) = self.raw.signer()? { raw_wallet } else if let Some(path) = utils::maybe_get_keystore_path( @@ -139,7 +138,7 @@ of the unlocked account you want to use, or provide the --from flag with the add if let Some(from) = self.from { from } else if let Ok(signer) = self.signer().await { - signer.address().to_alloy() + signer.address() } else { Address::ZERO } @@ -176,7 +175,7 @@ mod tests { ]); let signer = wallet.signer().await.unwrap(); assert_eq!( - signer.address().to_alloy(), + signer.address(), Address::from_str("ec554aeafe75601aaab43bd4621a22284db566c2").unwrap() ); } @@ -207,7 +206,7 @@ mod tests { } Err(x) => { assert!( - x.to_string().contains("Failed to create wallet"), + x.to_string().contains("Failed to decode private key"), "Error message is not user-friendly" ); } diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index d71fbe1af7ff5..9cf4478e2d8b2 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -1,19 +1,17 @@ use crate::error::WalletSignerError; -use alloy_primitives::B256; +use alloy_consensus::SignableTransaction; +use alloy_dyn_abi::TypedData; +use alloy_network::TxSigner; +use alloy_primitives::{Address, ChainId, B256}; +use alloy_signer::{Signature, Signer}; +use alloy_signer_aws::AwsSigner; +use alloy_signer_ledger::{HDPath as LedgerHDPath, LedgerSigner}; +use alloy_signer_trezor::{HDPath as TrezorHDPath, TrezorSigner}; +use alloy_signer_wallet::{coins_bip39::English, LocalWallet, MnemonicBuilder}; +use alloy_sol_types::{Eip712Domain, SolStruct}; use async_trait::async_trait; -use ethers_core::types::{ - transaction::{eip2718::TypedTransaction, eip712::Eip712}, - Signature, -}; -use ethers_signers::{ - coins_bip39::English, AwsSigner, HDPath as LedgerHDPath, Ledger, LocalWallet, MnemonicBuilder, - Signer, Trezor, TrezorHDPath, -}; -use rusoto_core::{ - credential::ChainProvider as AwsChainProvider, region::Region as AwsRegion, - request::HttpClient as AwsHttpClient, Client as AwsClient, -}; -use rusoto_kms::KmsClient; +use aws_config::BehaviorVersion; +use aws_sdk_kms::Client as AwsClient; use std::path::PathBuf; pub type Result = std::result::Result; @@ -24,36 +22,34 @@ pub enum WalletSigner { /// Wrapper around local wallet. e.g. private key, mnemonic Local(LocalWallet), /// Wrapper around Ledger signer. - Ledger(Ledger), + Ledger(LedgerSigner), /// Wrapper around Trezor signer. - Trezor(Trezor), + Trezor(TrezorSigner), /// Wrapper around AWS KMS signer. Aws(AwsSigner), } impl WalletSigner { pub async fn from_ledger_path(path: LedgerHDPath) -> Result { - let ledger = Ledger::new(path, 1).await?; + let ledger = LedgerSigner::new(path, None).await?; Ok(Self::Ledger(ledger)) } pub async fn from_trezor_path(path: TrezorHDPath) -> Result { // cached to ~/.ethers-rs/trezor/cache/trezor.session - let trezor = Trezor::new(path, 1, None).await?; + let trezor = TrezorSigner::new(path, None).await?; Ok(Self::Trezor(trezor)) } - pub async fn from_aws(key_id: &str) -> Result { - let client = - AwsClient::new_with(AwsChainProvider::default(), AwsHttpClient::new().unwrap()); + pub async fn from_aws(key_id: String) -> Result { + let config = aws_config::load_defaults(BehaviorVersion::latest()).await; + let client = AwsClient::new(&config); - let kms = KmsClient::new_with_client(client, AwsRegion::default()); - - Ok(Self::Aws(AwsSigner::new(kms, key_id, 1).await?)) + Ok(Self::Aws(AwsSigner::new(client, key_id, None).await?)) } pub fn from_private_key(private_key: impl AsRef<[u8]>) -> Result { - let wallet = LocalWallet::from_bytes(private_key.as_ref())?; + let wallet = LocalWallet::from_bytes(&B256::from_slice(private_key.as_ref()))?; Ok(Self::Local(wallet)) } @@ -63,7 +59,7 @@ impl WalletSigner { /// - the result for Ledger signers includes addresses available for both LedgerLive and Legacy /// derivation paths /// - for Local and AWS signers the result contains a single address - pub async fn available_senders(&self, max: usize) -> Result> { + pub async fn available_senders(&self, max: usize) -> Result> { let mut senders = Vec::new(); match self { WalletSigner::Local(local) => { @@ -136,78 +132,53 @@ macro_rules! delegate { #[async_trait] impl Signer for WalletSigner { - type Error = WalletSignerError; - - async fn sign_message>(&self, message: S) -> Result { - delegate!(self, inner => inner.sign_message(message).await.map_err(Into::into)) - } - - async fn sign_transaction(&self, message: &TypedTransaction) -> Result { - delegate!(self, inner => inner.sign_transaction(message).await.map_err(Into::into)) + /// Signs the given hash. + async fn sign_hash(&self, hash: &B256) -> alloy_signer::Result { + delegate!(self, inner => inner.sign_hash(hash)).await } - async fn sign_typed_data(&self, payload: &T) -> Result { - delegate!(self, inner => inner.sign_typed_data(payload).await.map_err(Into::into)) + async fn sign_message(&self, message: &[u8]) -> alloy_signer::Result { + delegate!(self, inner => inner.sign_message(message)).await } - fn address(&self) -> ethers_core::types::Address { + fn address(&self) -> Address { delegate!(self, inner => inner.address()) } - fn chain_id(&self) -> u64 { + fn chain_id(&self) -> Option { delegate!(self, inner => inner.chain_id()) } - fn with_chain_id>(self, chain_id: T) -> Self { - match self { - Self::Local(inner) => Self::Local(inner.with_chain_id(chain_id)), - Self::Ledger(inner) => Self::Ledger(inner.with_chain_id(chain_id)), - Self::Trezor(inner) => Self::Trezor(inner.with_chain_id(chain_id)), - Self::Aws(inner) => Self::Aws(inner.with_chain_id(chain_id)), - } - } -} - -#[async_trait] -impl Signer for &WalletSigner { - type Error = WalletSignerError; - - async fn sign_message>(&self, message: S) -> Result { - (*self).sign_message(message).await + fn set_chain_id(&mut self, chain_id: Option) { + delegate!(self, inner => inner.set_chain_id(chain_id)) } - async fn sign_transaction(&self, message: &TypedTransaction) -> Result { - (*self).sign_transaction(message).await + async fn sign_typed_data( + &self, + payload: &T, + domain: &Eip712Domain, + ) -> alloy_signer::Result + where + Self: Sized, + { + delegate!(self, inner => inner.sign_typed_data(payload, domain)).await } - async fn sign_typed_data(&self, payload: &T) -> Result { - (*self).sign_typed_data(payload).await - } - - fn address(&self) -> ethers_core::types::Address { - (*self).address() - } - - fn chain_id(&self) -> u64 { - (*self).chain_id() - } - - fn with_chain_id>(self, chain_id: T) -> Self { - let _ = chain_id; - self + async fn sign_dynamic_typed_data( + &self, + payload: &TypedData, + ) -> alloy_signer::Result { + delegate!(self, inner => inner.sign_dynamic_typed_data(payload)).await } } -impl WalletSigner { - pub async fn sign_hash(&self, hash: &B256) -> Result { - match self { - // TODO: AWS can sign hashes but utilities aren't exposed in ethers-signers. - // TODO: Implement with alloy-signer. - Self::Aws(_aws) => Err(WalletSignerError::CannotSignRawHash("AWS")), - Self::Ledger(_) => Err(WalletSignerError::CannotSignRawHash("Ledger")), - Self::Local(wallet) => wallet.sign_hash(hash.0.into()).map_err(Into::into), - Self::Trezor(_) => Err(WalletSignerError::CannotSignRawHash("Trezor")), - } +#[async_trait] +impl TxSigner for WalletSigner { + async fn sign_transaction( + &self, + tx: &mut dyn SignableTransaction, + ) -> alloy_signer::Result { + delegate!(self, inner => inner.sign_transaction(tx)).await } } From 1610c138dd79491232ffda95f0b6742f1ffea520 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 9 Apr 2024 23:29:05 +0200 Subject: [PATCH 0831/1963] chore: use alloy calc next block base fee (#7614) --- Cargo.lock | 1 + crates/anvil/Cargo.toml | 1 + crates/anvil/src/eth/fees.rs | 29 +++-------------------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 770e28567edda..47bbf198c972a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -658,6 +658,7 @@ dependencies = [ "alloy-chains", "alloy-consensus", "alloy-dyn-abi", + "alloy-eips", "alloy-genesis", "alloy-json-abi", "alloy-network", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 99bf00081b2c7..76611fc804db3 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -39,6 +39,7 @@ ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } alloy-primitives = { workspace = true, features = ["serde"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-network.workspace = true +alloy-eips.workspace = true alloy-rlp.workspace = true alloy-signer = { workspace = true, features = ["eip712"] } alloy-signer-wallet = { workspace = true, features = ["mnemonic"] } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 2b070b281d75f..142a6a4af38c2 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -2,6 +2,7 @@ use crate::eth::{ backend::{info::StorageInfo, notifications::NewBlockNotifications}, error::BlockchainError, }; +use alloy_eips::{calc_next_block_base_fee, eip1559::BaseFeeParams}; use alloy_primitives::B256; use anvil_core::eth::transaction::TypedTransaction; use foundry_evm::revm::primitives::SpecId; @@ -28,11 +29,8 @@ pub const INITIAL_GAS_PRICE: u128 = 1_875_000_000; /// Bounds the amount the base fee can change between blocks. pub const BASE_FEE_CHANGE_DENOMINATOR: u128 = 8; -/// Elasticity multiplier as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) -pub const EIP1559_ELASTICITY_MULTIPLIER: u128 = 2; - pub fn default_elasticity() -> f64 { - 1f64 / BASE_FEE_CHANGE_DENOMINATOR as f64 + 1f64 / BaseFeeParams::ethereum().elasticity_multiplier as f64 } /// Stores the fee related information @@ -127,28 +125,7 @@ impl FeeManager { if self.base_fee() == 0 { return 0 } - calculate_next_block_base_fee(gas_used, gas_limit, last_fee_per_gas) - } -} - -/// Calculate base fee for next block. [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) spec -pub fn calculate_next_block_base_fee(gas_used: u128, gas_limit: u128, base_fee: u128) -> u128 { - let gas_target = gas_limit / EIP1559_ELASTICITY_MULTIPLIER; - - if gas_used == gas_target { - return base_fee - } - if gas_used > gas_target { - let gas_used_delta = gas_used - gas_target; - let base_fee_delta = - std::cmp::max(1, base_fee * gas_used_delta / gas_target / BASE_FEE_CHANGE_DENOMINATOR); - base_fee + base_fee_delta - } else { - let gas_used_delta = gas_target - gas_used; - let base_fee_per_gas_delta = - base_fee * gas_used_delta / gas_target / BASE_FEE_CHANGE_DENOMINATOR; - - base_fee.saturating_sub(base_fee_per_gas_delta) + calc_next_block_base_fee(gas_used, gas_limit, last_fee_per_gas, BaseFeeParams::ethereum()) } } From 0df7fb19e9718e5c63a07842d2a039accfb0d627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Gonz=C3=A1lez?= Date: Tue, 9 Apr 2024 23:40:53 +0200 Subject: [PATCH 0832/1963] feat(anvil): add support for injecting precompiles (#7589) * feat(anvil): add support for injecting precompiles * test: check precompiles get injected * feat(docs): add a few doc comments * feat(docs): document with_extra_precompiles * ref: localize changes to the anvil crate * ref: rename with_extra_precompiles -> with_precompile_factory * lint(fmt): fix formatting * ref: fix invalid comment * ref: remove unnecessary generic bound * ref: revert formatting change * ref: extract evm creation to a method * fix: inject precompiles to the executor * lint(fmt): fix formatting * chore: add doc * nit --------- Co-authored-by: Matthias Seitz --- crates/anvil/src/config.rs | 15 +++- crates/anvil/src/eth/backend/executor.rs | 7 ++ crates/anvil/src/eth/backend/mem/mod.rs | 59 +++++++++++---- crates/anvil/src/evm.rs | 92 ++++++++++++++++++++++++ crates/anvil/src/lib.rs | 3 + 5 files changed, 161 insertions(+), 15 deletions(-) create mode 100644 crates/anvil/src/evm.rs diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 58de505ed011a..7c35f0c9d7c93 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -11,9 +11,8 @@ use crate::{ fees::{INITIAL_BASE_FEE, INITIAL_GAS_PRICE}, pool::transactions::TransactionOrder, }, - mem, - mem::in_memory_db::MemDb, - FeeManager, Hardfork, + mem::{self, in_memory_db::MemDb}, + FeeManager, Hardfork, PrecompileFactory, }; use alloy_genesis::Genesis; use alloy_network::AnyNetwork; @@ -176,6 +175,8 @@ pub struct NodeConfig { pub slots_in_an_epoch: u64, /// The memory limit per EVM execution in bytes. pub memory_limit: Option, + /// Factory used by `anvil` to extend the EVM's precompiles. + pub precompile_factory: Option>, } impl NodeConfig { @@ -422,6 +423,7 @@ impl Default for NodeConfig { enable_optimism: false, slots_in_an_epoch: 32, memory_limit: None, + precompile_factory: None, } } } @@ -834,6 +836,13 @@ impl NodeConfig { self } + /// Injects precompiles to `anvil`'s EVM. + #[must_use] + pub fn with_precompile_factory(mut self, factory: impl PrecompileFactory + 'static) -> Self { + self.precompile_factory = Some(Arc::new(factory)); + self + } + /// Configures everything related to env, backend and database and returns the /// [Backend](mem::Backend) /// diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 80a72beedc641..d3b54be15355a 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -4,7 +4,9 @@ use crate::{ error::InvalidTransactionError, pool::transactions::PoolTransaction, }, + inject_precompiles, mem::inspector::Inspector, + PrecompileFactory, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; use alloy_primitives::{Bloom, BloomInput, Log, B256}; @@ -96,6 +98,8 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> /// Cumulative gas used by all executed transactions pub gas_used: u128, pub enable_steps_tracing: bool, + /// Precompiles to inject to the EVM. + pub precompile_factory: Option>, } impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<'a, DB, Validator> { @@ -265,6 +269,9 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator let exec_result = { let mut evm = foundry_evm::utils::new_evm_with_inspector(&mut *self.db, env, &mut inspector); + if let Some(ref factory) = self.precompile_factory { + inject_precompiles(&mut evm, factory.precompiles()); + } trace!(target: "backend", "[{:?}] executing", transaction.hash()); // transact and commit the transaction diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 939913b842a81..93b45377b78d5 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -23,6 +23,7 @@ use crate::{ pool::transactions::PoolTransaction, util::get_precompiles_for, }, + inject_precompiles, mem::{ inspector::Inspector, storage::{BlockchainStorage, InMemoryBlockStates, MinedBlockOutcome}, @@ -31,7 +32,7 @@ use crate::{ db::DatabaseRef, primitives::{AccountInfo, U256 as rU256}, }, - NodeConfig, + NodeConfig, PrecompileFactory, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; use alloy_primitives::{keccak256, Address, Bytes, TxHash, B256, U256, U64}; @@ -78,7 +79,10 @@ use foundry_evm::{ }; use futures::channel::mpsc::{unbounded, UnboundedSender}; use parking_lot::{Mutex, RwLock}; -use revm::primitives::{HashMap, ResultAndState}; +use revm::{ + db::WrapDatabaseRef, + primitives::{HashMap, ResultAndState}, +}; use std::{ collections::BTreeMap, io::{Read, Write}, @@ -168,6 +172,8 @@ pub struct Backend { node_config: Arc>, /// Slots in an epoch slots_in_an_epoch: u64, + /// Precompiles to inject to the EVM. + precompile_factory: Option>, } impl Backend { @@ -214,7 +220,10 @@ impl Backend { Default::default() }; - let slots_in_an_epoch = node_config.read().await.slots_in_an_epoch; + let (slots_in_an_epoch, precompile_factory) = { + let cfg = node_config.read().await; + (cfg.slots_in_an_epoch, cfg.precompile_factory.clone()) + }; let backend = Self { db, @@ -233,6 +242,7 @@ impl Backend { transaction_block_keeper, node_config, slots_in_an_epoch, + precompile_factory, }; if let Some(interval_block_time) = automine_block_time { @@ -800,6 +810,24 @@ impl Backend { env } + /// Creates an EVM instance with optionally injected precompiles. + fn new_evm_with_inspector_ref( + &self, + db: DB, + env: EnvWithHandlerCfg, + inspector: I, + ) -> revm::Evm<'_, I, WrapDatabaseRef> + where + DB: revm::DatabaseRef, + I: revm::Inspector>, + { + let mut evm = new_evm_with_inspector_ref(db, env, inspector); + if let Some(ref factory) = self.precompile_factory { + inject_precompiles(&mut evm, factory.precompiles()); + } + evm + } + /// executes the transactions without writing to the underlying database pub async fn inspect_tx( &self, @@ -812,9 +840,8 @@ impl Backend { env.tx = tx.pending_transaction.to_revm_tx_env(); let db = self.db.read().await; let mut inspector = Inspector::default(); - - let ResultAndState { result, state } = - new_evm_with_inspector_ref(&*db, env, &mut inspector).transact()?; + let mut evm = self.new_evm_with_inspector_ref(&*db, env, &mut inspector); + let ResultAndState { result, state } = evm.transact()?; let (exit_reason, gas_used, out, logs) = match result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { (reason.into(), gas_used, Some(output), Some(logs)) @@ -825,6 +852,7 @@ impl Backend { ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None, None), }; + drop(evm); inspector.print_logs(); Ok((exit_reason, out, gas_used, state, logs.unwrap_or_default())) @@ -865,6 +893,7 @@ impl Backend { parent_hash: storage.best_hash, gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, + precompile_factory: self.precompile_factory.clone(), }; // create a new pending block @@ -924,6 +953,7 @@ impl Backend { parent_hash: best_hash, gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, + precompile_factory: self.precompile_factory.clone(), }; let executed_tx = executor.execute(); @@ -1123,8 +1153,8 @@ impl Backend { let mut inspector = Inspector::default(); let env = self.build_call_env(request, fee_details, block_env); - let ResultAndState { result, state } = - new_evm_with_inspector_ref(state, env, &mut inspector).transact()?; + let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); + let ResultAndState { result, state } = evm.transact()?; let (exit_reason, gas_used, out) = match result { ExecutionResult::Success { reason, gas_used, output, .. } => { (reason.into(), gas_used, Some(output)) @@ -1134,6 +1164,7 @@ impl Backend { } ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None), }; + drop(evm); inspector.print_logs(); Ok((exit_reason, out, gas_used as u128, state)) } @@ -1150,8 +1181,9 @@ impl Backend { let block_number = block.number; let env = self.build_call_env(request, fee_details, block); - let ResultAndState { result, state: _ } = - new_evm_with_inspector_ref(state, env, &mut inspector).transact()?; + let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); + let ResultAndState { result, state: _ } = evm.transact()?; + let (exit_reason, gas_used, out) = match result { ExecutionResult::Success { reason, gas_used, output, .. } => { (reason.into(), gas_used, Some(output)) @@ -1161,6 +1193,8 @@ impl Backend { } ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None), }; + + drop(evm); let tracer = inspector.tracer.expect("tracer disappeared"); let return_value = out.as_ref().map(|o| o.data().clone()).unwrap_or_default(); let res = tracer.into_geth_builder().geth_traces(gas_used, return_value, opts); @@ -1196,8 +1230,8 @@ impl Backend { ); let env = self.build_call_env(request, fee_details, block_env); - let ResultAndState { result, state: _ } = - new_evm_with_inspector_ref(state, env, &mut inspector).transact()?; + let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); + let ResultAndState { result, state: _ } = evm.transact()?; let (exit_reason, gas_used, out) = match result { ExecutionResult::Success { reason, gas_used, output, .. } => { (reason.into(), gas_used, Some(output)) @@ -1207,6 +1241,7 @@ impl Backend { } ExecutionResult::Halt { reason, gas_used } => (reason.into(), gas_used, None), }; + drop(evm); let access_list = inspector.access_list(); Ok((exit_reason, out, gas_used, access_list)) } diff --git a/crates/anvil/src/evm.rs b/crates/anvil/src/evm.rs new file mode 100644 index 0000000000000..de1dfbd51e2a9 --- /dev/null +++ b/crates/anvil/src/evm.rs @@ -0,0 +1,92 @@ +use std::{fmt::Debug, sync::Arc}; + +use alloy_primitives::Address; +use foundry_evm::revm::{self, precompile::Precompile, ContextPrecompile, ContextPrecompiles}; + +/// Object-safe trait that enables injecting extra precompiles when using +/// `anvil` as a library. +pub trait PrecompileFactory: Send + Sync + Unpin + Debug { + /// Returns a set of precompiles to extend the EVM with. + fn precompiles(&self) -> Vec<(Address, Precompile)>; +} + +/// Appends a handler register to `evm` that injects the given `precompiles`. +/// +/// This will add an additional handler that extends the default precompiles with the given set of +/// precompiles. +pub fn inject_precompiles( + evm: &mut revm::Evm<'_, I, DB>, + precompiles: Vec<(Address, Precompile)>, +) where + DB: revm::Database, +{ + evm.handler.append_handler_register_box(Box::new(move |handler| { + let precompiles = precompiles.clone(); + let loaded_precompiles = handler.pre_execution().load_precompiles(); + handler.pre_execution.load_precompiles = Arc::new(move || { + let mut loaded_precompiles = loaded_precompiles.clone(); + loaded_precompiles.extend( + precompiles + .clone() + .into_iter() + .map(|(addr, p)| (addr, ContextPrecompile::Ordinary(p))), + ); + let mut default_precompiles = ContextPrecompiles::default(); + default_precompiles.extend(loaded_precompiles); + default_precompiles + }); + })); +} + +#[cfg(test)] +mod tests { + use crate::{evm::inject_precompiles, PrecompileFactory}; + use alloy_primitives::Address; + use foundry_evm::revm::{ + self, + primitives::{address, Bytes, Precompile, PrecompileResult, SpecId}, + }; + + #[test] + fn build_evm_with_extra_precompiles() { + const PRECOMPILE_ADDR: Address = address!("0000000000000000000000000000000000000071"); + fn my_precompile(_bytes: &Bytes, _gas_limit: u64) -> PrecompileResult { + Ok((0, Bytes::new())) + } + + #[derive(Debug)] + struct CustomPrecompileFactory; + + impl PrecompileFactory for CustomPrecompileFactory { + fn precompiles(&self) -> Vec<(Address, Precompile)> { + vec![(PRECOMPILE_ADDR, Precompile::Standard(my_precompile))] + } + } + + let db = revm::db::EmptyDB::default(); + let env = Box::::default(); + let spec = SpecId::LATEST; + let handler_cfg = revm::primitives::HandlerCfg::new(spec); + let inspector = revm::inspectors::NoOpInspector; + let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); + let handler = revm::Handler::new(handler_cfg); + let mut evm = revm::Evm::new(context, handler); + assert!(!evm + .handler + .pre_execution() + .load_precompiles() + .addresses() + .any(|&addr| addr == PRECOMPILE_ADDR)); + + inject_precompiles(&mut evm, CustomPrecompileFactory.precompiles()); + assert!(evm + .handler + .pre_execution() + .load_precompiles() + .addresses() + .any(|&addr| addr == PRECOMPILE_ADDR)); + + let result = evm.transact().unwrap(); + assert!(result.result.is_success()); + } +} diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 11a860bc385b4..31c635990b11a 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -50,6 +50,9 @@ pub use hardfork::Hardfork; /// ethereum related implementations pub mod eth; +/// Evm related abstractions +mod evm; +pub use evm::{inject_precompiles, PrecompileFactory}; /// support for polling filters pub mod filter; /// commandline output From 7bb2b207f939da2bfcb0a6eea366eee414ea47a2 Mon Sep 17 00:00:00 2001 From: L Date: Tue, 9 Apr 2024 14:53:55 -0700 Subject: [PATCH 0833/1963] feat(cast): pretty print tx status in `cast receipt` (#7534) * feat(cast): pretty print tx status in `cast receipt` * pretty status --------- Co-authored-by: Matthias Seitz --- crates/common/src/fmt/ui.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index c5bdf6c130e04..1607b6d104dce 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -147,6 +147,10 @@ impl UIfmt for [u8] { } } +pub fn pretty_status(status: bool) -> String { + if status { "1 (success)" } else { "0 (failed)" }.to_string() +} + impl UIfmt for AnyTransactionReceipt { fn pretty(&self) -> String { let Self { @@ -205,7 +209,7 @@ blobGasUsed {}", serde_json::to_string(&logs).unwrap(), logs_bloom.pretty(), state_root.pretty(), - status.pretty(), + pretty_status(*status), transaction_hash.pretty(), transaction_index.pretty(), transaction_type, @@ -445,7 +449,7 @@ pub fn get_pretty_tx_receipt_attr( "logsBloom" | "logs_bloom" => Some(receipt.receipt.inner.inner.inner.logs_bloom.pretty()), "root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root.pretty()), "status" | "statusCode" | "status_code" => { - Some(receipt.receipt.inner.inner.inner.receipt.status.pretty()) + Some(pretty_status(receipt.receipt.inner.inner.inner.receipt.status)) } "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), "transactionIndex" | "transaction_index" => { From c62a3cc307ce119aa5b85c2a7afdbedcdf9bdef9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 10 Apr 2024 00:08:32 +0200 Subject: [PATCH 0834/1963] chore: bump alloy --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- Cargo.toml | 44 ++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47bbf198c972a..2ed89363d6b64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-eips", "alloy-primitives", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-primitives", "alloy-serde", @@ -169,7 +169,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-primitives", "serde", @@ -180,7 +180,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-consensus", "alloy-eips", @@ -223,7 +223,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -249,7 +249,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -289,7 +289,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -309,7 +309,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-consensus", "alloy-eips", @@ -327,7 +327,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -339,7 +339,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-primitives", "serde", @@ -349,7 +349,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-consensus", "alloy-network", @@ -381,7 +381,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-consensus", "alloy-network", @@ -398,7 +398,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-consensus", "alloy-network", @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-consensus", "alloy-network", @@ -491,7 +491,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-json-rpc", "base64 0.22.0", @@ -509,7 +509,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -522,7 +522,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -540,7 +540,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5f74d4e#5f74d4e7a417662489e4165236c1251fee8e6078" +source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -6848,7 +6848,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=510d4d0#510d4d0d06130d52ee996fa8aebd32cdc8267905" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=21f8f3d#21f8f3d266b05d1084e06f0c5331f2f1f4ed0905" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 1bc2329a50937..93a4f245509e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.3.14", default-features = false } # no default features to avoid c-kzg revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "510d4d0", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "21f8f3d", features = [ "serde", ] } @@ -158,27 +158,27 @@ ethers-signers = { version = "2.0.14", default-features = false } ethers-middleware = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "5f74d4e", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } alloy-primitives = { version = "0.7.0", features = ["getrandom"] } alloy-dyn-abi = "0.7.0" alloy-json-abi = "0.7.0" From 460319558e455611be1de64be8364c65c6896d15 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 10 Apr 2024 00:38:34 +0200 Subject: [PATCH 0835/1963] chore: rm outdated utils (#7616) --- crates/anvil/core/src/eth/transaction/mod.rs | 25 ++++++--------- crates/anvil/core/src/eth/utils.rs | 33 +------------------- crates/anvil/src/eth/backend/mem/mod.rs | 4 +-- 3 files changed, 13 insertions(+), 49 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 84e236f92f8bc..e42300d6a59c4 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1,9 +1,6 @@ //! Transaction related types -use crate::eth::{ - transaction::optimism::{DepositTransaction, DepositTransactionRequest}, - utils::eip_to_revm_access_list, -}; +use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest}; use alloy_consensus::{ AnyReceiptEnvelope, BlobTransactionSidecar, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, @@ -25,8 +22,6 @@ use revm::{ use serde::{Deserialize, Serialize}; use std::ops::Deref; -use super::utils::from_eip_to_alloy_access_list; - pub mod optimism; /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC @@ -393,7 +388,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( v: U256::from(t.signature().v().y_parity_byte()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), - access_list: Some(from_eip_to_alloy_access_list(t.tx().tx().access_list.clone())), + access_list: Some(t.tx().tx().access_list.clone()), transaction_type: Some(3), max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas), blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), @@ -482,7 +477,7 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id, nonce: Some(*nonce), value: (*value), @@ -508,14 +503,14 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), value: *value, gas_price: U256::from(*gas_price), gas_priority_fee: None, gas_limit: *gas_limit as u64, - access_list: eip_to_revm_access_list(access_list.0.clone()), + access_list: access_list.flattened(), ..Default::default() } } @@ -535,14 +530,14 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), value: *value, gas_price: U256::from(*max_fee_per_gas), gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), gas_limit: *gas_limit as u64, - access_list: eip_to_revm_access_list(access_list.0.clone()), + access_list: access_list.flattened(), ..Default::default() } } @@ -564,7 +559,7 @@ impl PendingTransaction { TxEnv { caller, transact_to: TransactTo::call(*to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), value: *value, @@ -573,7 +568,7 @@ impl PendingTransaction { max_fee_per_blob_gas: Some(U256::from(*max_fee_per_blob_gas)), blob_hashes: blob_versioned_hashes.clone(), gas_limit: *gas_limit as u64, - access_list: eip_to_revm_access_list(access_list.0.clone()), + access_list: access_list.flattened(), ..Default::default() } } @@ -593,7 +588,7 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(kind), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id, nonce: Some(*nonce), value: *value, diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index 27bb46523da4d..a604392801238 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,35 +1,4 @@ -use alloy_eips::eip2930::{ - AccessList as AlloyEipAccessList, AccessListItem as AlloyEipAccessListItem, -}; -use alloy_primitives::{Address, Parity, U256}; -use alloy_rpc_types::{AccessList as AlloyAccessList, AccessListItem as AlloyAccessListItem}; - -pub fn alloy_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { - list.into_iter() - .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) - .collect() -} - -/// Translates a vec of [AlloyEipAccessListItem] to a [AlloyAccessList], translating from internal -/// type to rpc type. -pub fn from_eip_to_alloy_access_list(list: AlloyEipAccessList) -> AlloyAccessList { - AlloyAccessList( - list.0 - .into_iter() - .map(|item| AlloyAccessListItem { - address: item.address, - storage_keys: item.storage_keys.into_iter().collect(), - }) - .collect(), - ) -} - -/// Translates a vec of [AlloyEipAccessListItem] to a revm style Access List. -pub fn eip_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { - list.into_iter() - .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) - .collect() -} +use alloy_primitives::Parity; /// See /// > If you do, then the v of the signature MUST be set to {0,1} + CHAIN_ID * 2 + 35 where diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 93b45377b78d5..d1fa2007d04ff 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -54,7 +54,7 @@ use anvil_core::{ DepositReceipt, MaybeImpersonatedTransaction, PendingTransaction, ReceiptResponse, TransactionInfo, TypedReceipt, TypedTransaction, }, - utils::{alloy_to_revm_access_list, meets_eip155}, + utils::meets_eip155, }, types::{Forking, Index}, }; @@ -1127,7 +1127,7 @@ impl Backend { data: input.into_input().unwrap_or_default(), chain_id: None, nonce, - access_list: alloy_to_revm_access_list(access_list.unwrap_or_default().0), + access_list: access_list.unwrap_or_default().flattened(), ..Default::default() }; From f0ea57a49fa1bc24185b91ab63017aa3f55871b6 Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:40:07 +0530 Subject: [PATCH 0836/1963] feat(forge): blobbasefee cheatcode (#7598) * feat(forge): blobbasefee cheatcode * updated comments * nits * moved test * chore: add cancun test --------- Co-authored-by: Matthias Seitz --- crates/cheatcodes/assets/cheatcodes.json | 40 ++++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 11 +++++++ crates/cheatcodes/src/evm.rs | 20 ++++++++++++ crates/forge/tests/it/cheats.rs | 10 +++++- crates/forge/tests/it/test_helpers.rs | 23 ++++++++++---- testdata/cancun/cheats/BlobBaseFee.t.sol | 14 +++++++++ testdata/cheats/Vm.sol | 2 ++ 7 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 testdata/cancun/cheats/BlobBaseFee.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 26d9dd2e17bc3..7a02c6ad64fa5 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2971,6 +2971,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "blobBaseFee", + "description": "Sets `block.blobbasefee`", + "declaration": "function blobBaseFee(uint256 newBlobBaseFee) external;", + "visibility": "external", + "mutability": "", + "signature": "blobBaseFee(uint256)", + "selector": "0x6d315d7e", + "selectorBytes": [ + 109, + 49, + 93, + 126 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "breakpoint_0", @@ -4651,6 +4671,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getBlobBaseFee", + "description": "Gets the current `block.blobbasefee`.\nYou should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", + "declaration": "function getBlobBaseFee() external view returns (uint256 blobBaseFee);", + "visibility": "external", + "mutability": "view", + "signature": "getBlobBaseFee()", + "selector": "0x1f6d6ef7", + "selectorBytes": [ + 31, + 109, + 110, + 247 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "getBlockNumber", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index e7ac87da11a1f..ae93475b2bf36 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -402,6 +402,17 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function getBlockTimestamp() external view returns (uint256 timestamp); + /// Sets `block.blobbasefee` + #[cheatcode(group = Evm, safety = Unsafe)] + function blobBaseFee(uint256 newBlobBaseFee) external; + + /// Gets the current `block.blobbasefee`. + /// You should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction, + /// and as a result will get optimized out by the compiler. + /// See https://github.com/foundry-rs/foundry/issues/6180 + #[cheatcode(group = Evm, safety = Safe)] + function getBlobBaseFee() external view returns (uint256 blobBaseFee); + // -------- Account State -------- /// Sets an address' balance. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index b8f55b37c2f77..d9c0f5cff09eb 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -328,6 +328,26 @@ impl Cheatcode for getBlockTimestampCall { } } +impl Cheatcode for blobBaseFeeCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newBlobBaseFee } = self; + ensure!( + ccx.ecx.spec_id() >= SpecId::CANCUN, + "`blobBaseFee` is not supported before the Cancun hard fork; \ + see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844" + ); + ccx.ecx.env.block.set_blob_excess_gas_and_price((*newBlobBaseFee).to()); + Ok(Default::default()) + } +} + +impl Cheatcode for getBlobBaseFeeCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + Ok(ccx.ecx.env.block.get_blob_excess_gas().unwrap_or(0).abi_encode()) + } +} + impl Cheatcode for dealCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account: address, newBalance: new_balance } = *self; diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 42113cdc770dc..47d6ebbb9ec5b 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -2,7 +2,10 @@ use crate::{ config::*, - test_helpers::{ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_DEFAULT, TEST_DATA_MULTI_VERSION}, + test_helpers::{ + ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_CANCUN, TEST_DATA_DEFAULT, + TEST_DATA_MULTI_VERSION, + }, }; use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_test_utils::Filter; @@ -50,3 +53,8 @@ async fn test_cheats_local_default_isolated() { async fn test_cheats_local_multi_version() { test_cheats_local(&TEST_DATA_MULTI_VERSION).await } + +#[tokio::test(flavor = "multi_thread")] +async fn test_cheats_local_cancun() { + test_cheats_local(&TEST_DATA_CANCUN).await +} diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 6fc8a3745f152..204df223b860f 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -2,8 +2,8 @@ use alloy_primitives::U256; use forge::{ - inspectors::CheatsConfig, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, - TestOptionsBuilder, + inspectors::CheatsConfig, revm::primitives::SpecId, MultiContractRunner, + MultiContractRunnerBuilder, TestOptions, TestOptionsBuilder, }; use foundry_compilers::{ artifacts::{Libraries, Settings}, @@ -46,6 +46,11 @@ impl fmt::Display for ForgeTestProfile { } impl ForgeTestProfile { + /// Returns true if the profile is Cancun. + pub fn is_cancun(&self) -> bool { + matches!(self, Self::Cancun) + } + pub fn root(&self) -> PathBuf { PathBuf::from(TESTDATA) } @@ -147,7 +152,7 @@ impl ForgeTestProfile { "fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string(), ]; - if matches!(self, Self::Cancun) { + if self.is_cancun() { config.evm_version = EvmVersion::Cancun; } @@ -162,6 +167,7 @@ pub struct ForgeTestData { pub test_opts: TestOptions, pub evm_opts: EvmOpts, pub config: Config, + pub profile: ForgeTestProfile, } impl ForgeTestData { @@ -175,15 +181,20 @@ impl ForgeTestData { let config = profile.config(); let evm_opts = profile.evm_opts(); - Self { project, output, test_opts, evm_opts, config } + Self { project, output, test_opts, evm_opts, config, profile } } /// Builds a base runner pub fn base_runner(&self) -> MultiContractRunnerBuilder { init_tracing(); - MultiContractRunnerBuilder::default() + let mut runner = MultiContractRunnerBuilder::default() .sender(self.evm_opts.sender) - .with_test_options(self.test_opts.clone()) + .with_test_options(self.test_opts.clone()); + if self.profile.is_cancun() { + runner = runner.evm_spec(SpecId::CANCUN); + } + + runner } /// Builds a non-tracing runner diff --git a/testdata/cancun/cheats/BlobBaseFee.t.sol b/testdata/cancun/cheats/BlobBaseFee.t.sol new file mode 100644 index 0000000000000..54fbc8f7f0616 --- /dev/null +++ b/testdata/cancun/cheats/BlobBaseFee.t.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.25; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract BlobBaseFeeTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_blob_base_fee() public { + vm.blobBaseFee(6969); + assertEq(vm.getBlobBaseFee(), 6969); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 8f799c9f69362..1d0b6118b1a3a 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -144,6 +144,7 @@ interface Vm { function assertTrue(bool condition) external pure; function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; + function blobBaseFee(uint256 newBlobBaseFee) external; function breakpoint(string calldata char) external; function breakpoint(string calldata char, bool value) external; function broadcast() external; @@ -228,6 +229,7 @@ interface Vm { function fee(uint256 newBasefee) external; function ffi(string[] calldata commandInput) external returns (bytes memory result); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); + function getBlobBaseFee() external view returns (uint256 blobBaseFee); function getBlockNumber() external view returns (uint256 height); function getBlockTimestamp() external view returns (uint256 timestamp); function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); From 9a0f0c23ac8e9a96b9f36b5eab486d0579c12ffe Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:33:51 +0530 Subject: [PATCH 0837/1963] feat(forge): prompt address and uint cheatcodes (#7600) * feat: prompt address and uint cheatcode * nits * chore: change test to pass ci --- crates/cheatcodes/assets/cheatcodes.json | 40 ++++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 8 +++++ crates/cheatcodes/src/fs.rs | 16 ++++++++++ testdata/cheats/Vm.sol | 2 ++ testdata/default/cheats/Prompt.t.sol | 11 +++++++ 5 files changed, 77 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 7a02c6ad64fa5..c8b5d3d2affe6 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6231,6 +6231,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "promptAddress", + "description": "Prompts the user for an address in the terminal.", + "declaration": "function promptAddress(string calldata promptText) external returns (address);", + "visibility": "external", + "mutability": "", + "signature": "promptAddress(string)", + "selector": "0x62ee05f4", + "selectorBytes": [ + 98, + 238, + 5, + 244 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "promptSecret", @@ -6251,6 +6271,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "promptUint", + "description": "Prompts the user for uint256 in the terminal.", + "declaration": "function promptUint(string calldata promptText) external returns (uint256);", + "visibility": "external", + "mutability": "", + "signature": "promptUint(string)", + "selector": "0x652fd489", + "selectorBytes": [ + 101, + 47, + 212, + 137 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readCallers", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index ae93475b2bf36..03a2cd090b856 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1482,6 +1482,14 @@ interface Vm { #[cheatcode(group = Filesystem)] function promptSecret(string calldata promptText) external returns (string memory input); + /// Prompts the user for an address in the terminal. + #[cheatcode(group = Filesystem)] + function promptAddress(string calldata promptText) external returns (address); + + /// Prompts the user for uint256 in the terminal. + #[cheatcode(group = Filesystem)] + function promptUint(string calldata promptText) external returns (uint256); + // ======== Environment Variables ======== /// Sets environment variables. diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 3ba07b5b6cd2a..9b22c4d8d2ae5 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -1,6 +1,8 @@ //! Implementations of [`Filesystem`](crate::Group::Filesystem) cheatcodes. +use super::string::parse; use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use alloy_dyn_abi::DynSolType; use alloy_json_abi::ContractObject; use alloy_primitives::U256; use alloy_sol_types::SolValue; @@ -426,6 +428,20 @@ impl Cheatcode for promptSecretCall { } } +impl Cheatcode for promptAddressCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { promptText: text } = self; + parse(&prompt(state, text, prompt_input)?, &DynSolType::Address) + } +} + +impl Cheatcode for promptUintCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { promptText: text } = self; + parse(&prompt(state, text, prompt_input)?, &DynSolType::Uint(256)) + } +} + pub(super) fn write_file(state: &Cheatcodes, path: &Path, contents: &[u8]) -> Result { let path = state.config.ensure_path_allowed(path, FsAccessKind::Write)?; // write access to foundry.toml is not allowed diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 1d0b6118b1a3a..44f0d52ac423f 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -307,7 +307,9 @@ interface Vm { function prevrandao(bytes32 newPrevrandao) external; function projectRoot() external view returns (string memory path); function prompt(string calldata promptText) external returns (string memory input); + function promptAddress(string calldata promptText) external returns (address); function promptSecret(string calldata promptText) external returns (string memory input); + function promptUint(string calldata promptText) external returns (uint256); 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); diff --git a/testdata/default/cheats/Prompt.t.sol b/testdata/default/cheats/Prompt.t.sol index dadfd30a97b2a..9e461c2b527e0 100644 --- a/testdata/default/cheats/Prompt.t.sol +++ b/testdata/default/cheats/Prompt.t.sol @@ -3,6 +3,7 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; +import "../logs/console.sol"; contract PromptTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); @@ -15,4 +16,14 @@ contract PromptTest is DSTest { vm._expectCheatcodeRevert(); vm.promptSecret("test"); } + + function testPrompt_Address() public { + vm._expectCheatcodeRevert(); + address test = vm.promptAddress("test"); + } + + function testPrompt_Uint() public { + vm._expectCheatcodeRevert(); + uint256 test = vm.promptUint("test"); + } } From d8a162581aa2f674e581a57daf1aba24acc26206 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 10 Apr 2024 15:50:21 +0200 Subject: [PATCH 0838/1963] fix: dont set withdrawals root (#7626) --- crates/anvil/core/src/eth/block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 462d16c8209cf..44fe1c517383e 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -65,7 +65,7 @@ impl Block { timestamp: partial_header.timestamp, extra_data: partial_header.extra_data, mix_hash: partial_header.mix_hash, - withdrawals_root: Some(partial_header.mix_hash), + withdrawals_root: None, blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, From 43fb17bbaf5b4c8ff36f2b21da425b0fc81a7b94 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:05:29 -0400 Subject: [PATCH 0839/1963] forge `verify-bytecode` (#7319) * verify bytecode boilerplate * wip(verify-bytecode): fetch creation code and constructor args * nit: todo comment * verify-bytecode: integrate build args and compile project * nits: use env eth_rpc_url * verify-bytecode: try_match * createFork * deploy contract on fork * verify-bytecode: cmp runtime code * constructor_args_range in bytecode * fix: NonceTooHigh issue and append constructor_args to local_bytecode * pretty print * verify-bytecode: pinpoint compiler settings match * verify-bytecode: cross check provided constructor args * handle revm changes * rm ethers_core as dep * nits * nit: is_runtime param * remove constructor args range check * nit * notify user on args mismatch, use args from etherscan by default. * fix: handle create2 deployments * add: checks for code at address and name mismatch * nits * add(verify-bytecode): check for bytecode hash config details and notify accordingly * use cache * nits * use verification type enum * nits * add(verify-bytecode): `--json` feature * fmt nits Co-authored-by: evalir * control flow nits * select cache version * nits and cleanup * use etherscan compiler version * smol nits * nit * fix(verify-bytecode): integrate alloy provider --------- Co-authored-by: evalir --- Cargo.lock | 3 + crates/forge/bin/main.rs | 1 + crates/forge/bin/opts.rs | 6 +- crates/verify/Cargo.toml | 6 +- crates/verify/src/bytecode.rs | 647 ++++++++++++++++++++++++++++++++++ crates/verify/src/lib.rs | 1 + 6 files changed, 661 insertions(+), 3 deletions(-) create mode 100644 crates/verify/src/bytecode.rs diff --git a/Cargo.lock b/Cargo.lock index 2ed89363d6b64..28a029aa48440 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3555,6 +3555,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-provider", + "alloy-rpc-types", "async-trait", "clap", "const-hex", @@ -3570,12 +3571,14 @@ dependencies = [ "once_cell", "regex", "reqwest 0.11.27", + "revm-primitives", "semver 1.0.22", "serde", "serde_json", "tempfile", "tokio", "tracing", + "yansi 0.5.1", ] [[package]] diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index acbe80d819cab..05589f84a2df8 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -108,6 +108,7 @@ fn main() -> Result<()> { ForgeSubcommand::Generate(cmd) => match cmd.sub { GenerateSubcommands::Test(cmd) => cmd.run(), }, + ForgeSubcommand::VerifyBytecode(cmd) => utils::block_on(cmd.run()), } } diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 03ed4d551f4b3..56308e167c5a8 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -6,7 +6,7 @@ use crate::cmd::{ }; use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; -use forge_verify::{VerifyArgs, VerifyCheckArgs}; +use forge_verify::{bytecode::VerifyBytecodeArgs, VerifyArgs, VerifyCheckArgs}; use std::path::PathBuf; const VERSION_MESSAGE: &str = concat!( @@ -154,6 +154,10 @@ pub enum ForgeSubcommand { /// Generate scaffold files. Generate(generate::GenerateArgs), + + /// Verify the deployed bytecode against its source. + #[clap(visible_alias = "vb")] + VerifyBytecode(VerifyBytecodeArgs), } #[cfg(test)] diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 832cf1c6b39c6..16efe68881d7f 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -15,11 +15,12 @@ foundry-config.workspace = true foundry-cli.workspace = true foundry-common.workspace = true foundry-evm.workspace = true - serde_json.workspace = true hex.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true +alloy-rpc-types.workspace = true +revm-primitives.workspace = true serde.workspace = true eyre.workspace = true alloy-provider.workspace = true @@ -34,8 +35,9 @@ futures = "0.3" semver = "1" regex = { version = "1", default-features = false } once_cell = "1" +yansi = "0.5" [dev-dependencies] tokio = { version = "1", features = ["macros"] } foundry-test-utils.workspace = true -tempfile = "3" \ No newline at end of file +tempfile = "3" diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs new file mode 100644 index 0000000000000..f801ff7715e5f --- /dev/null +++ b/crates/verify/src/bytecode.rs @@ -0,0 +1,647 @@ +use alloy_primitives::{Address, Bytes, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{BlockId, BlockNumberOrTag}; +use clap::{Parser, ValueHint}; +use eyre::{OptionExt, Result}; +use foundry_block_explorers::{contract::Metadata, Client}; +use foundry_cli::{ + opts::EtherscanOpts, + utils::{self, read_constructor_args_file, LoadConfig}, +}; +use foundry_common::{ + compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}, + provider::alloy::ProviderBuilder, +}; +use foundry_compilers::{ + artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode}, + info::ContractInfo, + Artifact, EvmVersion, +}; +use foundry_config::{figment, impl_figment_convert, Chain, Config}; +use foundry_evm::{ + constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, utils::configure_tx_env, +}; +use revm_primitives::{db::Database, EnvWithHandlerCfg, HandlerCfg, SpecId}; +use semver::Version; +use serde::{Deserialize, Serialize}; +use std::{fmt, path::PathBuf, str::FromStr}; +use yansi::Paint; + +impl_figment_convert!(VerifyBytecodeArgs); + +/// CLI arguments for `forge verify-bytecode`. +#[derive(Clone, Debug, Parser)] +pub struct VerifyBytecodeArgs { + /// The address of the contract to verify. + pub address: Address, + + /// The contract identifier in the form `:`. + pub contract: ContractInfo, + + /// The block at which the bytecode should be verified. + #[clap(long, value_name = "BLOCK")] + pub block: Option, + + /// The constructor args to generate the creation code. + #[clap( + long, + conflicts_with = "constructor_args_path", + value_name = "ARGS", + visible_alias = "encoded-constructor-args" + )] + pub constructor_args: Option, + + /// The path to a file containing the constructor arguments. + #[clap(long, value_hint = ValueHint::FilePath, value_name = "PATH")] + pub constructor_args_path: Option, + + /// The rpc url to use for verification. + #[clap(short = 'r', long, value_name = "RPC_URL", env = "ETH_RPC_URL")] + pub rpc_url: Option, + + /// Verfication Type: `full` or `partial`. Ref: https://docs.sourcify.dev/docs/full-vs-partial-match/ + #[clap(long, default_value = "full", value_name = "TYPE")] + pub verification_type: VerificationType, + + #[clap(flatten)] + pub etherscan_opts: EtherscanOpts, + + /// Skip building files whose names contain the given filter. + /// + /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. + #[arg(long, num_args(1..))] + pub skip: Option>, + + /// The path to the project's root directory. + pub root: Option, + + /// Suppress logs and emit json results to stdout + #[clap(long, default_value = "false")] + pub json: bool, +} + +impl figment::Provider for VerifyBytecodeArgs { + fn metadata(&self) -> figment::Metadata { + figment::Metadata::named("Verify Bytecode Provider") + } + + fn data( + &self, + ) -> Result, figment::Error> { + let mut dict = figment::value::Dict::new(); + if let Some(block) = &self.block { + dict.insert("block".into(), figment::value::Value::serialize(block)?); + } + if let Some(rpc_url) = &self.rpc_url { + dict.insert("eth_rpc_url".into(), rpc_url.to_string().into()); + } + dict.insert("verification_type".into(), self.verification_type.to_string().into()); + + Ok(figment::value::Map::from([(Config::selected_profile(), dict)])) + } +} + +impl VerifyBytecodeArgs { + /// Run the `verify-bytecode` command to verify the bytecode onchain against the locally built + /// bytecode. + pub async fn run(mut self) -> Result<()> { + // Setup + let config = self.load_config_emit_warnings(); + let provider = ProviderBuilder::new(&config.get_rpc_url_or_localhost_http()?).build()?; + + let code = provider.get_code_at(self.address, BlockId::latest()).await?; + if code.is_empty() { + eyre::bail!("No bytecode found at address {}", self.address); + } + + if !self.json { + println!( + "Verifying bytecode for contract {} at address {}", + Paint::green(self.contract.name.clone()), + Paint::green(self.address.to_string()) + ); + } + + // If chain is not set, we try to get it from the RPC + // If RPC is not set, the default chain is used + let chain = if config.get_rpc_url().is_some() { + let chain_id = provider.get_chain_id().await?; + Chain::from(chain_id) + } else { + config.chain.unwrap_or_default() + }; + + // Set Etherscan options + self.etherscan_opts.chain = Some(chain); + self.etherscan_opts.key = + config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); + // Create etherscan client + let etherscan = Client::new(chain, self.etherscan_opts.key.clone().unwrap())?; + + // Get the constructor args using `source_code` endpoint + let source_code = etherscan.contract_source_code(self.address).await?; + + // Check if the contract name matches + let name = source_code.items.first().map(|item| item.contract_name.to_owned()); + if name.as_ref() != Some(&self.contract.name) { + eyre::bail!("Contract name mismatch"); + } + + // Get the constructor args from etherscan + let constructor_args = if let Some(args) = source_code.items.first() { + args.constructor_arguments.clone() + } else { + eyre::bail!("No constructor arguments found for contract at address {}", self.address); + }; + + // Get user provided constructor args + let provided_constructor_args = if let Some(args) = self.constructor_args.to_owned() { + args + } else if let Some(path) = self.constructor_args_path.to_owned() { + // Read from file + let res = read_constructor_args_file(path)?; + // Convert res to Bytes + res.join("") + } else { + constructor_args.to_string() + }; + + // Constructor args mismatch + if provided_constructor_args != constructor_args.to_string() && !self.json { + println!( + "{}", + Paint::red("The provider constructor args do not match the constructor args from etherscan. This will result in a mismatch - Using the args from etherscan").bold(), + ); + } + + // Get creation tx hash + let creation_data = etherscan.contract_creation_data(self.address).await?; + + let mut transaction = provider + .get_transaction_by_hash(creation_data.transaction_hash) + .await + .or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))?; + let receipt = provider + .get_transaction_receipt(creation_data.transaction_hash) + .await + .or_else(|e| eyre::bail!("Couldn't fetch transacrion receipt from RPC: {:?}", e))?; + + let receipt = if let Some(receipt) = receipt { + receipt + } else { + eyre::bail!( + "Receipt not found for transaction hash {}", + creation_data.transaction_hash + ); + }; + // Extract creation code + let maybe_creation_code = if receipt.contract_address == Some(self.address) { + &transaction.input + } else if transaction.to == Some(DEFAULT_CREATE2_DEPLOYER) { + &transaction.input[32..] + } else { + eyre::bail!( + "Could not extract the creation code for contract at address {}", + self.address + ); + }; + + // If bytecode_hash is disabled then its always partial verification + let (verification_type, has_metadata) = + match (&self.verification_type, config.bytecode_hash) { + (VerificationType::Full, BytecodeHash::None) => (VerificationType::Partial, false), + (VerificationType::Partial, BytecodeHash::None) => { + (VerificationType::Partial, false) + } + (VerificationType::Full, _) => (VerificationType::Full, true), + (VerificationType::Partial, _) => (VerificationType::Partial, true), + }; + + // Etherscan compilation metadata + let etherscan_metadata = source_code.items.first().unwrap(); + + let local_bytecode = + if let Some(local_bytecode) = self.build_using_cache(etherscan_metadata, &config) { + local_bytecode + } else { + self.build_project(&config)? + }; + + // Append constructor args to the local_bytecode + let mut local_bytecode_vec = local_bytecode.to_vec(); + local_bytecode_vec.extend_from_slice(&constructor_args); + + // Cmp creation code with locally built bytecode and maybe_creation_code + let (did_match, with_status) = try_match( + local_bytecode_vec.as_slice(), + maybe_creation_code, + &constructor_args, + &verification_type, + false, + has_metadata, + )?; + + let mut json_results: Vec = vec![]; + self.print_result( + (did_match, with_status), + BytecodeType::Creation, + &mut json_results, + etherscan_metadata, + &config, + ); + + // Get contract creation block + let simulation_block = match self.block { + Some(BlockId::Number(BlockNumberOrTag::Number(block))) => block, + Some(_) => eyre::bail!("Invalid block number"), + None => { + let provider = utils::get_provider(&config)?; + provider + .get_transaction_by_hash(creation_data.transaction_hash) + .await.or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))? + .block_number.ok_or_else(|| { + eyre::eyre!("Failed to get block number of the contract creation tx, specify using the --block flag") + })? + } + }; + + // Fork the chain at `simulation_block` + + let (mut fork_config, evm_opts) = config.clone().load_config_and_evm_opts()?; + fork_config.fork_block_number = Some(simulation_block - 1); + fork_config.evm_version = + etherscan_metadata.evm_version()?.unwrap_or(EvmVersion::default()); + let (mut env, fork, _chain) = + TracingExecutor::get_fork_material(&fork_config, evm_opts).await?; + + let mut executor = + TracingExecutor::new(env.clone(), fork, Some(fork_config.evm_version), false); + env.block.number = U256::from(simulation_block); + let block = provider.get_block(simulation_block.into(), true).await?; + + // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same + // block. + let prev_block_id = BlockId::Number(BlockNumberOrTag::Number(simulation_block - 1)); + let prev_block_nonce = provider + .get_transaction_count(creation_data.contract_creator, Some(prev_block_id)) + .await?; + transaction.nonce = prev_block_nonce; + + if let Some(ref block) = block { + env.block.timestamp = U256::from(block.header.timestamp); + env.block.coinbase = block.header.miner; + env.block.difficulty = block.header.difficulty; + env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); + env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); + env.block.gas_limit = U256::from(block.header.gas_limit); + } + + configure_tx_env(&mut env, &transaction); + + let env_with_handler = + EnvWithHandlerCfg::new(Box::new(env.clone()), HandlerCfg::new(SpecId::LATEST)); + + let contract_address = if let Some(to) = transaction.to { + if to != DEFAULT_CREATE2_DEPLOYER { + eyre::bail!("Transaction `to` address is not the default create2 deployer i.e the tx is not a contract creation tx."); + } + let result = executor.commit_tx_with_env(env_with_handler.to_owned())?; + + if result.result.len() > 20 { + eyre::bail!("Failed to deploy contract using commit_tx_with_env on fork at block {} | Err: Call result is greater than 20 bytes, cannot be converted to Address", simulation_block); + } + + Address::from_slice(&result.result) + } else { + let deploy_result = executor.deploy_with_env(env_with_handler, None)?; + deploy_result.address + }; + + // State commited using deploy_with_env, now get the runtime bytecode from the db. + let fork_runtime_code = executor + .backend + .basic(contract_address)? + .ok_or_else(|| { + eyre::eyre!( + "Failed to get runtime code for contract deployed on fork at address {}", + contract_address + ) + })? + .code + .ok_or_else(|| { + eyre::eyre!( + "Bytecode does not exist for contract deployed on fork at address {}", + contract_address + ) + })?; + + let onchain_runtime_code = provider + .get_code_at(self.address, BlockId::Number(BlockNumberOrTag::Number(simulation_block))) + .await?; + + // Compare the runtime bytecode with the locally built bytecode + let (did_match, with_status) = try_match( + &fork_runtime_code.bytecode, + &onchain_runtime_code, + &constructor_args, + &verification_type, + true, + has_metadata, + )?; + + self.print_result( + (did_match, with_status), + BytecodeType::Runtime, + &mut json_results, + etherscan_metadata, + &config, + ); + + if self.json { + println!("{}", serde_json::to_string(&json_results)?); + } + Ok(()) + } + + fn build_project(&self, config: &Config) -> Result { + let project = config.project()?; + let mut compiler = ProjectCompiler::new(); + + if let Some(skip) = &self.skip { + if !skip.is_empty() { + compiler = compiler.filter(Box::new(SkipBuildFilters::new(skip.to_owned())?)); + } + } + let output = compiler.compile(&project)?; + + let artifact = output + .find_contract(&self.contract) + .ok_or_eyre("Build Error: Contract artifact not found locally")?; + + let local_bytecode = artifact + .get_bytecode_object() + .ok_or_eyre("Contract artifact does not have bytecode")?; + + let local_bytecode = match local_bytecode.as_ref() { + BytecodeObject::Bytecode(bytes) => bytes, + BytecodeObject::Unlinked(_) => { + eyre::bail!("Unlinked bytecode is not supported for verification") + } + }; + + Ok(local_bytecode.to_owned()) + } + + fn build_using_cache(&self, etherscan_settings: &Metadata, config: &Config) -> Option { + let project = config.project().ok()?; + let cache = project.read_cache_file().ok()?; + let cached_artifacts = cache.read_artifacts::().ok()?; + + for (key, value) in cached_artifacts { + let name = self.contract.name.to_owned() + ".sol"; + let version = etherscan_settings.compiler_version.to_owned(); + if version.starts_with("vyper:") { + return None; + } + // Parse etherscan version string + let version = + version.split('+').next().unwrap_or("").trim_start_matches('v').to_string(); + if key.ends_with(name.as_str()) { + if let Some(artifact) = value.into_iter().next() { + if let Ok(version) = Version::parse(&version) { + if let Some(artifact) = artifact.1.iter().find(|a| { + a.version.major == version.major && + a.version.minor == version.minor && + a.version.patch == version.patch + }) { + return artifact + .artifact + .bytecode + .as_ref() + .and_then(|bytes| bytes.bytes().to_owned()) + .cloned(); + } + } + let artifact = artifact.1.first().unwrap(); // Get the first artifact + let local_bytecode = if let Some(local_bytecode) = &artifact.artifact.bytecode { + local_bytecode.bytes() + } else { + None + }; + + return local_bytecode.map(|bytes| bytes.to_owned()); + } + } + } + + None + } + + fn print_result( + &self, + res: (bool, Option), + bytecode_type: BytecodeType, + json_results: &mut Vec, + etherscan_config: &Metadata, + config: &Config, + ) { + if res.0 { + if !self.json { + println!( + "{} with status {}", + Paint::green(format!("{:?} code matched", bytecode_type)).bold(), + Paint::green(res.1.unwrap()).bold() + ); + } else { + let json_res = JsonResult { + bytecode_type, + matched: true, + verification_type: res.1.unwrap(), + message: None, + }; + json_results.push(json_res); + } + } else if !res.0 && !self.json { + println!( + "{}", + Paint::red(format!( + "{:?} code did not match - this may be due to varying compiler settings", + bytecode_type + )) + .bold() + ); + let mismatches = find_mismatch_in_settings(etherscan_config, config); + for mismatch in mismatches { + println!("{}", Paint::red(mismatch).bold()); + } + } else if !res.0 && self.json { + let json_res = JsonResult { + bytecode_type, + matched: false, + verification_type: self.verification_type, + message: Some(format!( + "{:?} code did not match - this may be due to varying compiler settings", + bytecode_type + )), + }; + json_results.push(json_res); + } + } +} + +/// Enum to represent the type of verification: `full` or `partial`. Ref: https://docs.sourcify.dev/docs/full-vs-partial-match/ +#[derive(Debug, Clone, clap::ValueEnum, Default, PartialEq, Eq, Serialize, Deserialize, Copy)] +pub enum VerificationType { + #[default] + #[serde(rename = "full")] + Full, + #[serde(rename = "partial")] + Partial, +} + +impl FromStr for VerificationType { + type Err = eyre::Error; + + fn from_str(s: &str) -> Result { + match s { + "full" => Ok(VerificationType::Full), + "partial" => Ok(VerificationType::Partial), + _ => eyre::bail!("Invalid verification type"), + } + } +} + +impl From for String { + fn from(v: VerificationType) -> Self { + match v { + VerificationType::Full => "full".to_string(), + VerificationType::Partial => "partial".to_string(), + } + } +} + +impl fmt::Display for VerificationType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + VerificationType::Full => write!(f, "full"), + VerificationType::Partial => write!(f, "partial"), + } + } +} + +/// Enum to represent the type of bytecode being verified +#[derive(Debug, Serialize, Deserialize, Clone, Copy)] +pub enum BytecodeType { + #[serde(rename = "creation")] + Creation, + #[serde(rename = "runtime")] + Runtime, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct JsonResult { + pub bytecode_type: BytecodeType, + pub matched: bool, + pub verification_type: VerificationType, + #[serde(skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +fn try_match( + local_bytecode: &[u8], + bytecode: &[u8], + constructor_args: &[u8], + match_type: &VerificationType, + is_runtime: bool, + has_metadata: bool, +) -> Result<(bool, Option)> { + // 1. Try full match + if *match_type == VerificationType::Full && local_bytecode.starts_with(bytecode) { + Ok((true, Some(VerificationType::Full))) + } else { + try_partial_match(local_bytecode, bytecode, constructor_args, is_runtime, has_metadata) + .map(|matched| (matched, matched.then_some(VerificationType::Partial))) + } +} + +fn try_partial_match( + mut local_bytecode: &[u8], + mut bytecode: &[u8], + constructor_args: &[u8], + is_runtime: bool, + has_metadata: bool, +) -> Result { + // 1. Check length of constructor args + if constructor_args.is_empty() { + // Assume metadata is at the end of the bytecode + if has_metadata { + local_bytecode = extract_metadata_hash(local_bytecode)?; + bytecode = extract_metadata_hash(bytecode)?; + } + + // Now compare the creation code and bytecode + return Ok(local_bytecode.starts_with(bytecode)); + } + + if is_runtime { + if has_metadata { + local_bytecode = extract_metadata_hash(local_bytecode)?; + bytecode = extract_metadata_hash(bytecode)?; + } + + // Now compare the local code and bytecode + return Ok(local_bytecode.starts_with(bytecode)); + } + + // If not runtime, extract constructor args from the end of the bytecode + bytecode = &bytecode[..bytecode.len() - constructor_args.len()]; + local_bytecode = &local_bytecode[..local_bytecode.len() - constructor_args.len()]; + + if has_metadata { + local_bytecode = extract_metadata_hash(local_bytecode)?; + bytecode = extract_metadata_hash(bytecode)?; + } + + Ok(local_bytecode.starts_with(bytecode)) +} + +/// @dev This assumes that the metadata is at the end of the bytecode +fn extract_metadata_hash(bytecode: &[u8]) -> Result<&[u8]> { + // Get the last two bytes of the bytecode to find the length of CBOR metadata + let metadata_len = &bytecode[bytecode.len() - 2..]; + let metadata_len = u16::from_be_bytes([metadata_len[0], metadata_len[1]]); + + // Now discard the metadata from the bytecode + Ok(&bytecode[..bytecode.len() - 2 - metadata_len as usize]) +} + +fn find_mismatch_in_settings( + etherscan_settings: &Metadata, + local_settings: &Config, +) -> Vec { + let mut mismatches: Vec = vec![]; + if etherscan_settings.evm_version != local_settings.evm_version.to_string().to_lowercase() { + let str = format!( + "EVM version mismatch: local={}, onchain={}", + local_settings.evm_version, etherscan_settings.evm_version + ); + mismatches.push(str); + } + let local_optimizer: u64 = if local_settings.optimizer { 1 } else { 0 }; + if etherscan_settings.optimization_used != local_optimizer { + let str = format!( + "Optimizer mismatch: local={}, onchain={}", + local_settings.optimizer, etherscan_settings.optimization_used + ); + mismatches.push(str); + } + if etherscan_settings.runs != local_settings.optimizer_runs as u64 { + let str = format!( + "Optimizer runs mismatch: local={}, onchain={}", + local_settings.optimizer_runs, etherscan_settings.runs + ); + mismatches.push(str); + } + + mismatches +} diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rs index be451d83fbb2f..ee6dd13f63fce 100644 --- a/crates/verify/src/lib.rs +++ b/crates/verify/src/lib.rs @@ -23,6 +23,7 @@ use etherscan::EtherscanVerificationProvider; pub mod provider; use provider::VerificationProvider; +pub mod bytecode; pub mod retry; mod sourcify; From 440ec525deb00b4dca138794865c27d1e8ea4d01 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 10 Apr 2024 23:30:07 +0400 Subject: [PATCH 0840/1963] fix: `assertApproxEqRel` edge case (#7630) fix: assertApproxEqRel edge case --- crates/cheatcodes/src/test/assert.rs | 36 +++++++++++++++++----------- testdata/default/cheats/Assert.t.sol | 2 ++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index d727626ca48cb..3c1ab22f3c859 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -1122,13 +1122,17 @@ fn uint_assert_approx_eq_rel( right: U256, max_delta: U256, ) -> Result, EqRelAssertionError> { - if right.is_zero() && !left.is_zero() { - return Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { - left, - right, - max_delta, - real_delta: EqRelDelta::Undefined, - }))) + if right.is_zero() { + if left.is_zero() { + return Ok(Default::default()) + } else { + return Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { + left, + right, + max_delta, + real_delta: EqRelDelta::Undefined, + }))) + }; } let delta = get_delta_uint(left, right) @@ -1153,13 +1157,17 @@ fn int_assert_approx_eq_rel( right: I256, max_delta: U256, ) -> Result, EqRelAssertionError> { - if right.is_zero() && !left.is_zero() { - return Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { - left, - right, - max_delta, - real_delta: EqRelDelta::Undefined, - }))) + if right.is_zero() { + if left.is_zero() { + return Ok(Default::default()) + } else { + return Err(EqRelAssertionError::Failure(Box::new(EqRelAssertionFailure { + left, + right, + max_delta, + real_delta: EqRelDelta::Undefined, + }))) + } } let (_, abs_right) = right.into_sign_and_abs(); diff --git a/testdata/default/cheats/Assert.t.sol b/testdata/default/cheats/Assert.t.sol index d2b0dcb3589aa..b33af6292ce31 100644 --- a/testdata/default/cheats/Assert.t.sol +++ b/testdata/default/cheats/Assert.t.sol @@ -823,5 +823,7 @@ contract AssertionsTest is DSTest { bytes("assertion failed: 1 !~= 0 (max delta: 0.0000000000000000%, real delta: undefined)") ); vm.assertApproxEqRel(uint256(1), uint256(0), uint256(0)); + + vm.assertApproxEqRel(uint256(0), uint256(0), uint256(0)); } } From a622e0fe4374287441ebca3470351d78d7da4479 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 11 Apr 2024 19:52:16 +0400 Subject: [PATCH 0841/1963] fix: use correct estimator (#7638) --- Cargo.lock | 45 +++++++++++++------------ Cargo.toml | 44 ++++++++++++------------ crates/forge/tests/cli/script.rs | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28a029aa48440..6471888fd57d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-eips", "alloy-primitives", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "alloy-serde", @@ -169,18 +169,19 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "serde", "serde_json", "thiserror", + "tracing", ] [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -223,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -249,7 +250,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -289,7 +290,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -309,7 +310,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -327,7 +328,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -339,7 +340,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-primitives", "serde", @@ -349,7 +350,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -364,7 +365,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -381,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -398,7 +399,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -414,7 +415,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-consensus", "alloy-network", @@ -491,7 +492,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "base64 0.22.0", @@ -509,7 +510,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -522,7 +523,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -540,7 +541,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=987b393#987b3936f78c067baedcf811620975d3a4a26443" +source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -6851,7 +6852,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=21f8f3d#21f8f3d266b05d1084e06f0c5331f2f1f4ed0905" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=413b892#413b892dd936d117c52d47ba07d195b09a7f1216" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 93a4f245509e2..82e29e6f248d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.3.14", default-features = false } # no default features to avoid c-kzg revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "21f8f3d", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "413b892", features = [ "serde", ] } @@ -158,27 +158,27 @@ ethers-signers = { version = "2.0.14", default-features = false } ethers-middleware = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "987b393", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } alloy-primitives = { version = "0.7.0", features = ["getrandom"] } alloy-dyn-abi = "0.7.0" alloy-json-abi = "0.7.0" diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 8af676efd0ddc..e56ae08ef51e0 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1231,3 +1231,61 @@ contract CustomErrorScript is Script { cmd.arg("script").arg(script).args(["--tc", "CustomErrorScript"]); assert!(cmd.stderr_lossy().contains("script failed: CustomError()")); }); + +// https://github.com/foundry-rs/foundry/issues/7620 +forgetest_async!(can_run_zero_base_fee, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function run() external { + vm.startBroadcast(); + address(0).call(""); + } +} + "#, + ) + .unwrap(); + + let node_config = NodeConfig::test().with_base_fee(Some(0)); + let (_api, handle) = spawn(node_config).await; + let dev = handle.dev_accounts().next().unwrap(); + + // Firstly run script with non-zero gas prices to ensure that eth_feeHistory contains non-zero + // values. + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--sender", + format!("{dev:?}").as_str(), + "--broadcast", + "--unlocked", + "--with-gas-price", + "2000000", + "--priority-gas-price", + "100000", + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); + + // Ensure that we can correctly estimate gas when base fee is zero but priority fee is not. + cmd.forge_fuse().args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--sender", + format!("{dev:?}").as_str(), + "--broadcast", + "--unlocked", + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +}); From bdc04c278f8ac716ed5fd3994bc0da841807b5cf Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 11 Apr 2024 22:45:48 +0400 Subject: [PATCH 0842/1963] fix: state diff for broadcasted CREATE2 deployments (#7632) fix: fix state diff for broadcasted CREATE2 deployments --- crates/cheatcodes/src/inspector.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index cd2d49ba63073..34a3d92607b15 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1342,15 +1342,6 @@ impl Inspector for Cheatcodes { let address = self.allow_cheatcodes_on_create(ecx, call); // If `recordAccountAccesses` has been called, record the create if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { - // If the create scheme is create2, and the caller is the DEFAULT_CREATE2_DEPLOYER then - // we must add 1 to the depth to account for the call to the create2 factory. - let mut depth = ecx.journaled_state.depth(); - if let CreateScheme::Create2 { salt: _ } = call.scheme { - if call.caller == DEFAULT_CREATE2_DEPLOYER { - depth += 1; - } - } - // Record the create context as an account access and create a new vector to record all // subsequent account accesses recorded_account_diffs_stack.push(vec![AccountAccess { @@ -1369,7 +1360,7 @@ impl Inspector for Cheatcodes { reverted: false, deployedCode: Bytes::new(), // updated on create_end storageAccesses: vec![], // updated on create_end - depth, + depth: ecx.journaled_state.depth(), }]); } From 89f0fb923773cf0f8f966290e579bae92f505077 Mon Sep 17 00:00:00 2001 From: Mihir Wadekar Date: Fri, 12 Apr 2024 13:48:36 -0700 Subject: [PATCH 0843/1963] Adds rpc method for anvil to drop all pending transactions (#7643) * feat: Adds rpc method for anvil to drop all pending transactions * fix: drop_all_transactions will now drop both pending and ready txs * fix: moved internal drop_all_transactions to clear, and modified logic to clear transaction internals + be more performant * rustfmt --------- Co-authored-by: Matthias Seitz --- crates/anvil/core/src/eth/mod.rs | 11 +++++++++++ crates/anvil/src/eth/api.rs | 12 ++++++++++++ crates/anvil/src/eth/pool/mod.rs | 12 ++++++++++++ crates/anvil/src/eth/pool/transactions.rs | 14 ++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 7a2a153e8ed89..a8a07ba928d5e 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -371,6 +371,17 @@ pub enum EthRequest { )] DropTransaction(B256), + /// Removes transactions from the pool + #[cfg_attr( + feature = "serde", + serde( + rename = "anvil_dropAllTransactions", + alias = "hardhat_dropAllTransactions", + with = "empty_params" + ) + )] + DropAllTransactions(), + /// Reset the fork to a fresh forked state, and optionally update the fork config #[cfg_attr(feature = "serde", serde(rename = "anvil_reset", alias = "hardhat_reset"))] Reset(#[cfg_attr(feature = "serde", serde(default))] Option>>), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index d21ed852feee7..1ed664a349b51 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -296,6 +296,9 @@ impl EthApi { EthRequest::DropTransaction(tx) => { self.anvil_drop_transaction(tx).await.to_rpc_result() } + EthRequest::DropAllTransactions() => { + self.anvil_drop_all_transactions().await.to_rpc_result() + } EthRequest::Reset(fork) => { self.anvil_reset(fork.and_then(|p| p.params)).await.to_rpc_result() } @@ -1572,6 +1575,15 @@ impl EthApi { Ok(self.pool.drop_transaction(tx_hash).map(|tx| tx.hash())) } + /// Removes all transactions from the pool + /// + /// Handler for RPC call: `anvil_dropAllTransactions` + pub async fn anvil_drop_all_transactions(&self) -> Result<()> { + node_info!("anvil_dropAllTransactions"); + self.pool.clear(); + Ok(()) + } + /// Reset the fork to a fresh forked state, and optionally update the fork config. /// /// If `forking` is `None` then this will disable forking entirely. diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index 34a75c205adec..6748855008c3a 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -166,6 +166,12 @@ impl Pool { dropped } + /// Removes all transactions from the pool + pub fn clear(&self) { + let mut pool = self.inner.write(); + pool.clear(); + } + /// notifies all listeners about the transaction fn notify_listener(&self, hash: TxHash) { let mut listener = self.transaction_listener.lock(); @@ -211,6 +217,12 @@ impl PoolInner { self.ready_transactions.get_transactions() } + /// Clears + fn clear(&mut self) { + self.ready_transactions.clear(); + self.pending_transactions.clear(); + } + /// checks both pools for the matching transaction /// /// Returns `None` if the transaction does not exist in the pool diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index a88bc369cd94c..9a229001d4054 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -134,6 +134,13 @@ impl PendingTransactions { self.waiting_queue.is_empty() } + /// Clears internal state + pub fn clear(&mut self) { + self.required_markers.clear(); + self.waiting_markers.clear(); + self.waiting_queue.clear(); + } + /// Returns an iterator over all transactions in the waiting pool pub fn transactions(&self) -> impl Iterator> + '_ { self.waiting_queue.values().map(|tx| tx.transaction.clone()) @@ -377,6 +384,13 @@ impl ReadyTransactions { } } + /// Clears the internal state + pub fn clear(&mut self) { + self.provided_markers.clear(); + self.ready_tx.write().clear(); + self.independent_transactions.clear(); + } + /// Returns true if the transaction is part of the queue. pub fn contains(&self, hash: &TxHash) -> bool { self.ready_tx.read().contains_key(hash) From 1ca9b854ef261d167b802da4a11665f6c3e26c4b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:37:03 +0200 Subject: [PATCH 0844/1963] chore(deps): weekly `cargo update` (#7655) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Updating allocator-api2 v0.2.16 -> v0.2.18 Updating alloy-chains v0.1.15 -> v0.1.16 Updating anyhow v1.0.81 -> v1.0.82 Updating async-trait v0.1.79 -> v0.1.80 Updating aws-config v1.1.9 -> v1.2.0 Updating aws-credential-types v1.1.8 -> v1.2.0 Updating aws-runtime v1.1.8 -> v1.2.0 Updating aws-sdk-kms v1.19.0 -> v1.21.0 Updating aws-sdk-sso v1.18.0 -> v1.20.0 Updating aws-sdk-ssooidc v1.18.0 -> v1.20.0 Updating aws-sdk-sts v1.18.0 -> v1.20.0 Updating aws-smithy-runtime v1.2.1 -> v1.3.0 Updating aws-smithy-runtime-api v1.3.0 -> v1.4.0 Updating aws-types v1.1.8 -> v1.2.0 Updating bumpalo v3.15.4 -> v3.16.0 Updating cc v1.0.90 -> v1.0.94 Updating clap_complete v4.5.1 -> v4.5.2 Adding cmake v0.1.50 Updating comfy-table v7.1.0 -> v7.1.1 Adding constant_time_eq v0.3.0 Updating crc v3.0.1 -> v3.2.1 Adding deflate64 v0.1.8 Updating either v1.10.0 -> v1.11.0 Updating encoding_rs v0.8.33 -> v0.8.34 Updating event-listener v5.2.0 -> v5.3.0 Updating figment v0.10.15 -> v0.10.16 Updating foundry-compilers v0.3.14 -> v0.3.15 Adding fs4 v0.8.2 Updating getrandom v0.2.12 -> v0.2.14 Updating gix-trace v0.1.8 -> v0.1.9 Updating gix-utils v0.1.11 -> v0.1.12 Updating half v2.4.0 -> v2.4.1 Adding hyper-tls v0.6.0 Updating jobserver v0.1.28 -> v0.1.30 Adding libz-ng-sys v1.1.15 Updating num v0.4.1 -> v0.4.2 Updating quote v1.0.35 -> v1.0.36 Updating reqwest v0.12.2 -> v0.12.3 Updating rustls-pemfile v2.1.1 -> v2.1.2 Updating rustversion v1.0.14 -> v1.0.15 Updating scale-info v2.11.1 -> v2.11.2 Updating scale-info-derive v2.11.1 -> v2.11.2 Updating serde_repr v0.1.18 -> v0.1.19 Adding simd-adler32 v0.3.7 Adding svm-rs v0.5.1 Updating svm-rs-builds v0.4.1 -> v0.5.1 Updating time v0.3.34 -> v0.3.36 Updating time-macros v0.2.17 -> v0.2.18 Adding typed-arena v2.0.2 Updating windows-targets v0.52.4 -> v0.52.5 Updating windows_aarch64_gnullvm v0.52.4 -> v0.52.5 Updating windows_aarch64_msvc v0.52.4 -> v0.52.5 Updating windows_i686_gnu v0.52.4 -> v0.52.5 Adding windows_i686_gnullvm v0.52.5 Updating windows_i686_msvc v0.52.4 -> v0.52.5 Updating windows_x86_64_gnu v0.52.4 -> v0.52.5 Updating windows_x86_64_gnullvm v0.52.4 -> v0.52.5 Updating windows_x86_64_msvc v0.52.4 -> v0.52.5 Updating winnow v0.6.5 -> v0.6.6 Adding winreg v0.52.0 Adding zip_next v1.0.1 Adding zopfli v0.8.0 Adding zstd v0.13.1 Adding zstd-safe v7.1.0 note: pass `--verbose` to see 179 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 445 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 306 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6471888fd57d3..a7b888b0392f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,15 +61,15 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96c81b05c893348760f232c4cc6a6a77fd91cfb09885d4eaad25cd03bd7732e" +checksum = "40646aa7f01e396139cf0d6c3a7475eeb8094a0f41d8199f10860c8aef09d2f1" dependencies = [ "num_enum", "serde", @@ -127,7 +127,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.5", + "winnow 0.6.6", ] [[package]] @@ -208,7 +208,7 @@ dependencies = [ "derive_arbitrary", "derive_more", "ethereum_ssz", - "getrandom 0.2.12", + "getrandom 0.2.14", "hex-literal", "itoa", "k256", @@ -473,7 +473,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "715f4d09a330cc181fc7c361b5c5c2766408fa59a0bac60349dcb7baabd404cc" dependencies = [ - "winnow 0.6.5", + "winnow 0.6.6", ] [[package]] @@ -514,7 +514,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be9 dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.2", + "reqwest 0.12.3", "serde_json", "tower", "url", @@ -684,7 +684,7 @@ dependencies = [ "clap", "clap_complete", "clap_complete_fig", - "crc 3.0.1", + "crc 3.2.1", "ctrlc", "ethereum-forkid", "ethers", @@ -775,15 +775,18 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arbitrary" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] [[package]] name = "ariadne" @@ -941,7 +944,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 5.2.0", + "event-listener 5.3.0", "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", @@ -1008,9 +1011,9 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", @@ -1078,9 +1081,9 @@ checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "aws-config" -version = "1.1.9" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297b64446175a73987cedc3c438d79b2a654d0fff96f65ff530fbe039347644c" +checksum = "e2a89e0000cde82447155d64eeb71720b933b4396a6fbbebad3f8b4f88ca7b54" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1109,9 +1112,9 @@ dependencies = [ [[package]] name = "aws-credential-types" -version = "1.1.8" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8587ae17c8e967e4b05a62d495be2fb7701bec52a97f7acfe8a29f938384c8" +checksum = "e16838e6c9e12125face1c1eff1343c75e3ff540de98ff7ebd61874a89bcfeb9" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -1121,9 +1124,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.1.8" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13dc54b4b49f8288532334bba8f87386a40571c47c37b1304979b556dc613c8" +checksum = "f4963ac9ff2d33a4231b3806c1c69f578f221a9cabb89ad2bde62ce2b442c8a7" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1144,9 +1147,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.19.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a4e610d67363f6846c903ebca4ce65439033d5ec2a5d8effc96d5eaa53355" +checksum = "d1747213c6bb8fae0f388157e07e144fd442c1e28cfd9c4e257b1b6ee26c4a54" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1166,9 +1169,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.18.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "019a07902c43b03167ea5df0182f0cb63fae89f9a9682c44d18cf2e4a042cb34" +checksum = "32fcc572fd5c58489ec205ec3e4e5f7d63018898a485cbf922a462af496bc300" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1188,9 +1191,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.18.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04c46ee08a48a7f4eaa4ad201dcc1dd537b49c50859d14d4510e00ad9d3f9af2" +checksum = "5b6275fa8684a1192754221173b1f7a7c1260d6b0571cc2b8af09468eb0cffe5" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1210,9 +1213,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.18.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f752ac730125ca6017f72f9db5ec1772c9ecc664f87aa7507a7d81b023c23713" +checksum = "30acd58272fd567e4853c5075d838be1626b59057e0249c9be5a1a7eb13bf70f" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1306,9 +1309,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c53572b4cd934ee5e8461ad53caa36e9d246aaef42166e3ac539e206a925d330" +checksum = "de34bcfa1fb3c82a80e252a753db34a6658e07f23d3a5b3fc96919518fa7a3f5" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1332,9 +1335,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb2b3a7030dc9a3c9a08ce0b25decea5130e9db19619d4dffbbff34f75fe850" +checksum = "4cc56a5c96ec741de6c5e6bf1ce6948be969d6506dfa9c39cffc284e31e4979b" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1381,9 +1384,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.1.8" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dbf2f3da841a8930f159163175cf6a3d16ddde517c1b0fba7aa776822800f40" +checksum = "5a43b56df2c529fe44cb4d92bd64d0479883fb9608ff62daede4df5405381814" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1632,9 +1635,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byte-slice-cast" @@ -1814,9 +1817,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" dependencies = [ "jobserver", "libc", @@ -1882,7 +1885,7 @@ dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -1949,9 +1952,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c" +checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e" dependencies = [ "clap", ] @@ -2008,6 +2011,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "coins-bip32" version = "0.8.7" @@ -2069,7 +2081,7 @@ dependencies = [ "async-trait", "byteorder", "cfg-if", - "getrandom 0.2.12", + "getrandom 0.2.14", "hex", "hidapi-rusb", "js-sys", @@ -2118,13 +2130,13 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.1.0" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" +checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ "crossterm", - "strum 0.25.0", - "strum_macros 0.25.3", + "strum 0.26.2", + "strum_macros 0.26.2", "unicode-width", ] @@ -2187,6 +2199,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + [[package]] name = "convert_case" version = "0.4.0" @@ -2229,9 +2247,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.0.1" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" dependencies = [ "crc-catalog", ] @@ -2449,6 +2467,12 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +[[package]] +name = "deflate64" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83ace6c86376be0b6cdcf3fb41882e81d94b31587573d1cfa9d01cd06bba210d" + [[package]] name = "der" version = "0.7.9" @@ -2671,9 +2695,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "elasticlunr-rs" @@ -2724,9 +2748,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -3177,9 +3201,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" dependencies = [ "concurrent-queue", "parking", @@ -3202,7 +3226,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ - "event-listener 5.2.0", + "event-listener 5.3.0", "pin-project-lite", ] @@ -3309,9 +3333,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.15" +version = "0.10.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7270677e7067213e04f323b55084586195f18308cd7546cfac9f873344ccceb6" +checksum = "fdefe49ed1057d124dc81a0681c30dd07de56ad96e32adc7b64e8f28eaab31c4" dependencies = [ "atomic", "parking_lot", @@ -3361,6 +3385,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", + "libz-ng-sys", "miniz_oxide", ] @@ -3601,7 +3626,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers", - "reqwest 0.12.2", + "reqwest 0.12.3", "semver 1.0.22", "serde", "serde_json", @@ -3737,7 +3762,7 @@ dependencies = [ "pretty_assertions", "rand 0.8.5", "reqwest 0.11.27", - "reqwest 0.12.2", + "reqwest 0.12.3", "rustc-hash", "semver 1.0.22", "serde", @@ -3754,9 +3779,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd3323f90e9f256a2c359dbb1cc7e1b7e4fef9e04e5a82693895e959a6efe010" +checksum = "2c1990477446ea72d80da26951cf7ba68652f9e5b481e3a469f09c4b120f647f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3779,7 +3804,7 @@ dependencies = [ "serde_json", "sha2", "solang-parser", - "svm-rs 0.4.1", + "svm-rs 0.5.1", "svm-rs-builds", "tempfile", "thiserror", @@ -3808,7 +3833,7 @@ dependencies = [ "path-slash", "pretty_assertions", "regex", - "reqwest 0.12.2", + "reqwest 0.12.3", "revm-primitives", "semver 1.0.22", "serde", @@ -4065,6 +4090,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "fs4" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21dabded2e32cd57ded879041205c60a4a4c4bab47bd0fd2fa8b01f30849f02b" +dependencies = [ + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "fs_extra" version = "1.3.0" @@ -4254,9 +4289,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -4465,15 +4500,15 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b838b2db8f62c9447d483a4c28d251b67fee32741a82cb4d35e9eb4e9fdc5ab" +checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e" [[package]] name = "gix-utils" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066432d4c277f9877f091279a597ea5331f68ca410efc874f0bdfb1cd348f92" +checksum = "35192df7fd0fa112263bad8021e2df7167df4cc2a6e6d15892e1e55621d3d4dc" dependencies = [ "fastrand", "unicode-normalization", @@ -4552,9 +4587,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -4840,6 +4875,22 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.2.0", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.3" @@ -5129,9 +5180,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" dependencies = [ "libc", ] @@ -5296,6 +5347,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libz-ng-sys" +version = "1.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6409efc61b12687963e602df8ecf70e8ddacf95bc6576bcf16e3ac6328083c5" +dependencies = [ + "cmake", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -5618,9 +5679,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" dependencies = [ "num-bigint", "num-complex", @@ -6536,9 +6597,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -6618,7 +6679,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.14", ] [[package]] @@ -6692,7 +6753,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.14", "libredox", "thiserror", ] @@ -6763,7 +6824,7 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.28", "hyper-rustls 0.24.2", - "hyper-tls", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", @@ -6789,17 +6850,18 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.25.4", - "winreg", + "winreg 0.50.0", ] [[package]] name = "reqwest" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" +checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "bytes", + "futures-channel", "futures-core", "futures-util", "http 1.1.0", @@ -6807,23 +6869,26 @@ dependencies = [ "http-body-util", "hyper 1.2.0", "hyper-rustls 0.26.0", + "hyper-tls 0.6.0", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", "rustls 0.22.3", "rustls-native-certs 0.7.0", - "rustls-pemfile 1.0.4", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", + "tokio-native-tls", "tokio-rustls 0.25.0", "tower-service", "url", @@ -6831,7 +6896,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.26.1", - "winreg", + "winreg 0.52.0", ] [[package]] @@ -6945,7 +7010,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.12", + "getrandom 0.2.14", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -7139,7 +7204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "schannel", "security-framework", @@ -7156,11 +7221,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "rustls-pki-types", ] @@ -7193,9 +7258,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "rusty-fork" @@ -7258,9 +7323,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.1" +version = "2.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "788745a868b0e751750388f4e6546eb921ef714a4317fa6954f7cde114eb2eb7" +checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" dependencies = [ "cfg-if", "derive_more", @@ -7270,9 +7335,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.1" +version = "2.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dc2f4e8bc344b9fc3d5f74f72c2e55bfc38d28dc2ebc69c194a3df424e4d9ac" +checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -7501,9 +7566,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", @@ -7665,6 +7730,12 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "similar" version = "2.5.0" @@ -7900,7 +7971,7 @@ checksum = "9bd5e919f01c9280dce59ab66296449d0e9144b8472b8892fbacf9612998b653" dependencies = [ "const-hex", "dirs 5.0.1", - "fs4", + "fs4 0.7.0", "once_cell", "reqwest 0.11.27", "semver 1.0.22", @@ -7912,17 +7983,37 @@ dependencies = [ "zip", ] +[[package]] +name = "svm-rs" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912d2f0dfbf9d8ba683b3181c4bd6d042bac9279d5c062346c253c1eadf46e2" +dependencies = [ + "const-hex", + "dirs 5.0.1", + "fs4 0.8.2", + "once_cell", + "reqwest 0.12.3", + "semver 1.0.22", + "serde", + "serde_json", + "sha2", + "thiserror", + "url", + "zip_next", +] + [[package]] name = "svm-rs-builds" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bcf7abc816dd67daf88fccfb835118b0e71cf8cc3e1d0e120893e139799df6c" +checksum = "ddc1e420b6e969cb161e3b1758ea50cbde308c82fbfcb322979eae71c5cc947a" dependencies = [ "build_const", "const-hex", "semver 1.0.22", "serde_json", - "svm-rs 0.4.1", + "svm-rs 0.5.1", ] [[package]] @@ -8110,9 +8201,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -8133,9 +8224,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -8358,7 +8449,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.5", + "winnow 0.6.6", ] [[package]] @@ -8542,6 +8633,12 @@ dependencies = [ "utf-8", ] +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" version = "1.17.0" @@ -8683,7 +8780,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.14", "serde", ] @@ -8966,7 +9063,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -8993,7 +9090,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -9028,17 +9125,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -9055,9 +9153,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -9073,9 +9171,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -9091,9 +9189,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -9109,9 +9213,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -9127,9 +9231,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -9145,9 +9249,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -9163,9 +9267,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" @@ -9178,9 +9282,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" dependencies = [ "memchr", ] @@ -9195,6 +9299,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -9290,7 +9404,7 @@ dependencies = [ "aes", "byteorder", "bzip2", - "constant_time_eq", + "constant_time_eq 0.1.5", "crc32fast", "crossbeam-utils", "flate2", @@ -9298,7 +9412,42 @@ dependencies = [ "pbkdf2 0.11.0", "sha1", "time", - "zstd", + "zstd 0.11.2+zstd.1.5.2", +] + +[[package]] +name = "zip_next" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658758d431446f97e25f129b30c97646db8799b30f00aaf10379b4fa343d4ded" +dependencies = [ + "aes", + "arbitrary", + "byteorder", + "bzip2", + "constant_time_eq 0.3.0", + "crc32fast", + "crossbeam-utils", + "deflate64", + "flate2", + "hmac", + "pbkdf2 0.12.2", + "sha1", + "time", + "zopfli", + "zstd 0.13.1", +] + +[[package]] +name = "zopfli" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1f48f3508a3a3f2faee01629564400bc12260f6214a056d06a3aaaa6ef0736" +dependencies = [ + "crc32fast", + "log", + "simd-adler32", + "typed-arena", ] [[package]] @@ -9307,7 +9456,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +dependencies = [ + "zstd-safe 7.1.0", ] [[package]] @@ -9320,6 +9478,15 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "7.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" +dependencies = [ + "zstd-sys", +] + [[package]] name = "zstd-sys" version = "2.0.10+zstd.1.5.6" From 1122df5450f2b2577f4a054dc10a3d986dfadf3a Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 15 Apr 2024 15:32:38 +0400 Subject: [PATCH 0845/1963] chore: enable rustls for foundry-common (#7664) --- crates/common/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 5e7eebf829c58..7dc6fa3ba666d 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -74,3 +74,7 @@ num-format.workspace = true foundry-macros.workspace = true pretty_assertions.workspace = true tokio = { version = "1", features = ["rt-multi-thread", "macros"] } + +[features] +default = ["rustls"] +rustls = ["reqwest_ethers/rustls-tls-native-roots"] From 43587e2ba2c95c489476d55e9c6a928be40333cc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 15 Apr 2024 13:34:01 +0200 Subject: [PATCH 0846/1963] fix: set OP enveloped tx field (#7649) * fix: set OP enveloped tx field * use is enabled * fix * fmt --------- Co-authored-by: Arsenii Kulikov --- crates/anvil/src/eth/backend/executor.rs | 14 ++++++++------ crates/anvil/src/eth/backend/mem/mod.rs | 9 ++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index d3b54be15355a..2d5d55500a2fc 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -118,7 +118,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' let difficulty = self.block_env.difficulty; let beneficiary = self.block_env.coinbase; let timestamp = self.block_env.timestamp.to::(); - let base_fee = if (self.cfg_env.handler_cfg.spec_id as u8) >= (SpecId::LONDON as u8) { + let base_fee = if self.cfg_env.handler_cfg.spec_id.is_enabled_in(SpecId::LONDON) { Some(self.block_env.basefee.to::()) } else { None @@ -208,11 +208,13 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' } fn env_for(&self, tx: &PendingTransaction) -> EnvWithHandlerCfg { - EnvWithHandlerCfg::new_with_cfg_env( - self.cfg_env.clone(), - self.block_env.clone(), - tx.to_revm_tx_env(), - ) + let mut tx_env = tx.to_revm_tx_env(); + if self.cfg_env.handler_cfg.is_optimism { + tx_env.optimism.enveloped_tx = + Some(alloy_rlp::encode(&tx.transaction.transaction).into()); + } + + EnvWithHandlerCfg::new_with_cfg_env(self.cfg_env.clone(), self.block_env.clone(), tx_env) } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d1fa2007d04ff..86d946f2dba62 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -81,7 +81,7 @@ use futures::channel::mpsc::{unbounded, UnboundedSender}; use parking_lot::{Mutex, RwLock}; use revm::{ db::WrapDatabaseRef, - primitives::{HashMap, ResultAndState}, + primitives::{HashMap, OptimismFields, ResultAndState}, }; use std::{ collections::BTreeMap, @@ -838,6 +838,12 @@ impl Backend { > { let mut env = self.next_env(); env.tx = tx.pending_transaction.to_revm_tx_env(); + + if env.handler_cfg.is_optimism { + env.tx.optimism.enveloped_tx = + Some(alloy_rlp::encode(&tx.pending_transaction.transaction.transaction).into()); + } + let db = self.db.read().await; let mut inspector = Inspector::default(); let mut evm = self.new_evm_with_inspector_ref(&*db, env, &mut inspector); @@ -1128,6 +1134,7 @@ impl Backend { chain_id: None, nonce, access_list: access_list.unwrap_or_default().flattened(), + optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, ..Default::default() }; From 94e940c5e2bdeb07e6083e899d2bac04948bdc5c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 15 Apr 2024 20:22:34 +0400 Subject: [PATCH 0847/1963] fix: simplify `run_test` (#7670) fix: simplify run_test --- crates/forge/src/runner.rs | 129 ++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 74 deletions(-) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 508ee9234423f..26af217870aea 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -334,82 +334,63 @@ impl<'a> ContractRunner<'a> { // Run unit test let mut executor = self.executor.clone(); - let start = Instant::now(); - let debug_arena; - let (reverted, reason, gas, stipend, coverage, state_changeset, breakpoints) = - match executor.execute_test( - self.sender, - address, - func, - &[], - U256::ZERO, - Some(self.revert_decoder), - ) { - Ok(res) => { - let RawCallResult { - reverted, - gas_used: gas, - stipend, - logs: execution_logs, - traces: execution_trace, - coverage: execution_coverage, - labels: new_labels, - state_changeset, - debug, - cheatcodes, - .. - } = res.raw; - - let breakpoints = cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); - traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(new_labels); - logs.extend(execution_logs); - debug_arena = debug; - coverage = merge_coverages(coverage, execution_coverage); - - (reverted, None, gas, stipend, coverage, state_changeset, breakpoints) - } - Err(EvmError::Execution(err)) => { - let ExecutionErr { raw, reason } = *err; - traces.extend(raw.traces.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(raw.labels); - logs.extend(raw.logs); - debug_arena = raw.debug; - ( - raw.reverted, - Some(reason), - raw.gas_used, - raw.stipend, - None, - raw.state_changeset, - Default::default(), - ) - } - Err(EvmError::SkipError) => { - return TestResult { - status: TestStatus::Skipped, - reason: None, - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - kind: TestKind::Standard(0), - duration: start.elapsed(), - ..Default::default() - } + let start: Instant = Instant::now(); + let (raw_call_result, reason) = match executor.execute_test( + self.sender, + address, + func, + &[], + U256::ZERO, + Some(self.revert_decoder), + ) { + Ok(res) => (res.raw, None), + Err(EvmError::Execution(err)) => (err.raw, Some(err.reason)), + Err(EvmError::SkipError) => { + return TestResult { + status: TestStatus::Skipped, + reason: None, + decoded_logs: decode_console_logs(&logs), + traces, + labeled_addresses, + kind: TestKind::Standard(0), + duration: start.elapsed(), + ..Default::default() } - Err(err) => { - return TestResult { - status: TestStatus::Failure, - reason: Some(err.to_string()), - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - kind: TestKind::Standard(0), - duration: start.elapsed(), - ..Default::default() - } + } + Err(err) => { + return TestResult { + status: TestStatus::Failure, + reason: Some(err.to_string()), + decoded_logs: decode_console_logs(&logs), + traces, + labeled_addresses, + kind: TestKind::Standard(0), + duration: start.elapsed(), + ..Default::default() } - }; + } + }; + + let RawCallResult { + reverted, + gas_used: gas, + stipend, + logs: execution_logs, + traces: execution_trace, + coverage: execution_coverage, + labels: new_labels, + state_changeset, + debug, + cheatcodes, + .. + } = raw_call_result; + + let breakpoints = cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); + let debug_arena = debug; + traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); + labeled_addresses.extend(new_labels); + logs.extend(execution_logs); + coverage = merge_coverages(coverage, execution_coverage); let success = executor.is_success( setup.address, From 46f51c9b8c48124d3e92ec590b654cb76e628dd5 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 15 Apr 2024 20:22:55 +0400 Subject: [PATCH 0848/1963] feat: allow including libraries into coverage report (#7663) --- crates/forge/bin/cmd/coverage.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 29538164b84ab..7e119fe47e64a 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -64,6 +64,10 @@ pub struct CoverageArgs { )] report_file: Option, + /// Whether to include libraries in the coverage report. + #[arg(long)] + include_libs: bool, + #[command(flatten)] filter: FilterArgs, @@ -162,7 +166,8 @@ impl CoverageArgs { report.add_source(version.clone(), source_file.id as usize, path.clone()); // Filter out dependencies - if project_paths.has_library_ancestor(std::path::Path::new(&path)) { + if !self.include_libs && project_paths.has_library_ancestor(std::path::Path::new(&path)) + { continue } From 8e00b6670349e67334cb05c898625bdf0df60be2 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:42:08 +0200 Subject: [PATCH 0849/1963] Upgrade `foundry-block-explorers` to `0.2.6` (#7672) bump foundry-block-explorers version to include https://github.com/foundry-rs/block-explorers/pull/40 --- Cargo.lock | 4 ++-- Cargo.toml | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7b888b0392f1..6f24466027310 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3618,9 +3618,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee75d972291181ae98bd1b48647ca8d8832159012b240ca1b7225085d4a63f00" +checksum = "b64cb03e297eb85b9f84a195fec7390a5e9805d9b82b11b2af57f65fc6d4ceb7" dependencies = [ "alloy-chains", "alloy-json-abi", diff --git a/Cargo.toml b/Cargo.toml index 82e29e6f248d4..6c19cff94a411 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,7 +137,7 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.2.5", default-features = false } +foundry-block-explorers = { version = "0.2.6", default-features = false } foundry-compilers = { version = "0.3.14", default-features = false } ## revm @@ -146,7 +146,7 @@ revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "413b892", features = [ "serde", -] } +] } ## ethers ethers = { version = "2.0.14", default-features = false } @@ -192,7 +192,10 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" From 9bce256dc6f7894c34eb5e2ae39729e20fc0dbae Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:08:47 -0400 Subject: [PATCH 0850/1963] fix(verify): improve err handling for unset etherscan api key (#7673) * fix(verify): improve err handling for unset etherscan api key * use: if let Some * nits --- crates/verify/src/bytecode.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index f801ff7715e5f..d84acbccc9985 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -135,8 +135,12 @@ impl VerifyBytecodeArgs { self.etherscan_opts.chain = Some(chain); self.etherscan_opts.key = config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); - // Create etherscan client - let etherscan = Client::new(chain, self.etherscan_opts.key.clone().unwrap())?; + + // If etherscan key is not set, we can't proceed with etherscan verification + let Some(key) = self.etherscan_opts.key.clone() else { + eyre::bail!("Etherscan API key is required for verification"); + }; + let etherscan = Client::new(chain, key)?; // Get the constructor args using `source_code` endpoint let source_code = etherscan.contract_source_code(self.address).await?; @@ -170,7 +174,7 @@ impl VerifyBytecodeArgs { if provided_constructor_args != constructor_args.to_string() && !self.json { println!( "{}", - Paint::red("The provider constructor args do not match the constructor args from etherscan. This will result in a mismatch - Using the args from etherscan").bold(), + Paint::red("The provided constructor args do not match the constructor args from etherscan. This will result in a mismatch - Using the args from etherscan").bold(), ); } From ee47bb01ee8aa042639cc9ae86a2a3cf6ab9d037 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 15 Apr 2024 21:48:39 +0200 Subject: [PATCH 0851/1963] chore: add tracing to signature client (#7674) --- crates/common/src/selectors.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index cda4ccb6c9219..2537b2c0cdecd 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -56,6 +56,7 @@ impl SignEthClient { } async fn get_text(&self, url: &str) -> reqwest::Result { + trace!(%url, "GET"); self.inner .get(url) .send() @@ -73,11 +74,12 @@ impl SignEthClient { } /// Sends a new post request - async fn post_json( + async fn post_json( &self, url: &str, body: &T, ) -> reqwest::Result { + trace!(%url, body=?serde_json::to_string(body), "POST"); self.inner .post(url) .json(body) @@ -146,7 +148,7 @@ impl SignEthClient { .await? .pop() // Not returning on the previous line ensures a vector with exactly 1 element .unwrap() - .ok_or(eyre::eyre!("No signature found")) + .ok_or_else(|| eyre::eyre!("No signature found")) } /// Decodes the given function or event selectors using https://api.openchain.xyz @@ -166,6 +168,9 @@ impl SignEthClient { return Ok(vec![]); } + debug!(len = selectors.len(), "decoding selectors"); + trace!(?selectors, "decoding selectors"); + // exit early if spurious connection self.ensure_not_spurious()?; From 1535a699a425d558cd80a9c9c079c9a828494c07 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:00:58 +0200 Subject: [PATCH 0852/1963] fix(traces): Etherscan traces are only resolved for first instance of test run (#7675) * handle resolved contracts * inline resolved into initial for-loop --- crates/evm/traces/src/identifier/etherscan.rs | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 50c273d07b0fe..11996be3a5d65 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -104,6 +104,7 @@ impl TraceIdentifier for EtherscanIdentifier { return Vec::new() } + let mut identities = Vec::new(); let mut fetcher = EtherscanFetcher::new( self.client.clone(), Duration::from_secs(1), @@ -112,28 +113,42 @@ impl TraceIdentifier for EtherscanIdentifier { ); for (addr, _) in addresses { - if !self.contracts.contains_key(addr) { - fetcher.push(*addr); - } - } - - let fut = fetcher - .map(|(address, metadata)| { + if let Some(metadata) = self.contracts.get(addr) { let label = metadata.contract_name.clone(); let abi = metadata.abi().ok().map(Cow::Owned); - self.contracts.insert(address, metadata); - AddressIdentity { - address, + identities.push(AddressIdentity { + address: *addr, label: Some(label.clone()), contract: Some(label), abi, artifact_id: None, - } - }) - .collect(); + }); + } else { + fetcher.push(*addr); + } + } + + let fetched_identities = RuntimeOrHandle::new().block_on( + fetcher + .map(|(address, metadata)| { + let label = metadata.contract_name.clone(); + let abi = metadata.abi().ok().map(Cow::Owned); + self.contracts.insert(address, metadata); + + AddressIdentity { + address, + label: Some(label.clone()), + contract: Some(label), + abi, + artifact_id: None, + } + }) + .collect::>>(), + ); - RuntimeOrHandle::new().block_on(fut) + identities.extend(fetched_identities); + identities } } From f8a9d5e4151e6f9f22a277f7213a20d6f7a68472 Mon Sep 17 00:00:00 2001 From: Trevor Johnson <27569194+trevorgjohnson@users.noreply.github.com> Date: Tue, 16 Apr 2024 05:01:38 -0500 Subject: [PATCH 0853/1963] chore(fork): adjust `chain_id` when updating local env with fork (#7679) * chore: adjust "chain_id" when updating local env with fork * test: add test to check that 'chainId' is updated automatically after fork switch --- crates/evm/core/src/backend/mod.rs | 1 + testdata/default/cheats/Fork.t.sol | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index dbd5071eed60b..e924d19efc85d 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1774,6 +1774,7 @@ impl Default for BackendInner { pub(crate) fn update_current_env_with_fork_env(current: &mut Env, fork: Env) { current.block = fork.block; current.cfg = fork.cfg; + current.tx.chain_id = fork.tx.chain_id; } /// Clones the data of the given `accounts` from the `active` database into the `fork_db` diff --git a/testdata/default/cheats/Fork.t.sol b/testdata/default/cheats/Fork.t.sol index 2ff4a6432099b..950865eacca91 100644 --- a/testdata/default/cheats/Fork.t.sol +++ b/testdata/default/cheats/Fork.t.sol @@ -111,4 +111,10 @@ contract ForkTest is DSTest { uint256 expected = block.chainid; assertEq(newChainId, expected); } + + // ensures forks change chain ids automatically + function testCanAutoUpdateChainId() public { + vm.createSelectFork("https://polygon-pokt.nodies.app"); // Polygon mainnet RPC URL + assertEq(block.chainid, 137); + } } From 958a850026bf3dddbf934e76d989c1a541503ffc Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 16 Apr 2024 19:49:08 +0400 Subject: [PATCH 0854/1963] feat: coverage for constructors (#7661) * wip * better naming --- crates/common/src/contracts.rs | 50 ++++++++++------ crates/evm/coverage/src/analysis.rs | 5 +- crates/evm/coverage/src/lib.rs | 15 ++++- crates/evm/evm/src/executors/invariant/mod.rs | 17 +++--- crates/evm/fuzz/src/strategies/state.rs | 12 ++-- crates/evm/traces/src/decoder/mod.rs | 4 +- crates/evm/traces/src/identifier/local.rs | 16 +++--- crates/evm/traces/src/lib.rs | 4 +- crates/forge/bin/cmd/coverage.rs | 47 +++++++++------ crates/forge/src/coverage.rs | 32 +++++++---- crates/forge/src/multi_runner.rs | 33 +++++++++-- crates/script/src/artifacts.rs | 8 --- crates/script/src/build.rs | 57 +++++++------------ crates/script/src/execute.rs | 12 +--- crates/script/src/lib.rs | 31 ++++------ crates/script/src/simulate.rs | 19 ++----- crates/script/src/transaction.rs | 18 +++--- crates/script/src/verify.rs | 9 +-- 18 files changed, 211 insertions(+), 178 deletions(-) delete mode 100644 crates/script/src/artifacts.rs diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index c406d0e45172a..d400e0a0824e8 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -1,7 +1,7 @@ //! Commonly used contract types and functions. use alloy_json_abi::{Event, Function, JsonAbi}; -use alloy_primitives::{hex, Address, Selector, B256}; +use alloy_primitives::{Address, Bytes, Selector, B256}; use eyre::Result; use foundry_compilers::{ artifacts::{CompactContractBytecode, ContractBytecodeSome}, @@ -9,26 +9,40 @@ use foundry_compilers::{ }; use std::{ collections::BTreeMap, - fmt, ops::{Deref, DerefMut}, }; -type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a (JsonAbi, Vec)); +/// Container for commonly used contract data. +#[derive(Debug, Clone)] +pub struct ContractData { + /// Contract name. + pub name: String, + /// Contract ABI. + pub abi: JsonAbi, + /// Contract creation code. + pub bytecode: Bytes, + /// Contract runtime code. + pub deployed_bytecode: Bytes, +} -/// Wrapper type that maps an artifact to a contract ABI and bytecode. -#[derive(Clone, Default)] -pub struct ContractsByArtifact(pub BTreeMap)>); +type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a ContractData); -impl fmt::Debug for ContractsByArtifact { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_map().entries(self.iter().map(|(k, (v1, v2))| (k, (v1, hex::encode(v2))))).finish() - } -} +/// Wrapper type that maps an artifact to a contract ABI and bytecode. +#[derive(Clone, Default, Debug)] +pub struct ContractsByArtifact(pub BTreeMap); impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. - pub fn find_by_code(&self, code: &[u8]) -> Option { - self.iter().find(|(_, (_, known_code))| bytecode_diff_score(known_code, code) <= 0.1) + pub fn find_by_creation_code(&self, code: &[u8]) -> Option { + self.iter() + .find(|(_, contract)| bytecode_diff_score(contract.bytecode.as_ref(), code) <= 0.1) + } + + /// Finds a contract which has a similar deployed bytecode as `code`. + pub fn find_by_deployed_code(&self, code: &[u8]) -> Option { + self.iter().find(|(_, contract)| { + bytecode_diff_score(contract.deployed_bytecode.as_ref(), code) <= 0.1 + }) } /// Finds a contract which has the same contract name or identifier as `id`. If more than one is @@ -51,14 +65,14 @@ impl ContractsByArtifact { let mut funcs = BTreeMap::new(); let mut events = BTreeMap::new(); let mut errors_abi = JsonAbi::new(); - for (_name, (abi, _code)) in self.iter() { - for func in abi.functions() { + for (_name, contract) in self.iter() { + for func in contract.abi.functions() { funcs.insert(func.selector(), func.clone()); } - for event in abi.events() { + for event in contract.abi.events() { events.insert(event.selector(), event.clone()); } - for error in abi.errors() { + for error in contract.abi.errors() { errors_abi.errors.entry(error.name.clone()).or_default().push(error.clone()); } } @@ -67,7 +81,7 @@ impl ContractsByArtifact { } impl Deref for ContractsByArtifact { - type Target = BTreeMap)>; + type Target = BTreeMap; fn deref(&self) -> &Self::Target { &self.0 diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index a136f2d79cd20..fad5b65768d27 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -45,13 +45,10 @@ impl<'a> ContractVisitor<'a> { let name: String = node.attribute("name").ok_or_else(|| eyre::eyre!("Function has no name"))?; - // TODO(onbjerg): Re-enable constructor parsing when we walk both the deployment and runtime - // sourcemaps. Currently this fails because we are trying to look for anchors in the runtime - // sourcemap. // TODO(onbjerg): Figure out why we cannot find anchors for the receive function let kind: String = node.attribute("kind").ok_or_else(|| eyre::eyre!("Function has no kind"))?; - if kind == "constructor" || kind == "receive" { + if kind == "receive" { return Ok(()) } diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 04ecaf948b81b..7a8f51c2e969f 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -37,7 +37,7 @@ pub struct CoverageReport { /// All coverage items for the codebase, keyed by the compiler version. pub items: HashMap>, /// All item anchors for the codebase, keyed by their contract ID. - pub anchors: HashMap>, + pub anchors: HashMap, Vec)>, /// All the bytecode hits for the codebase pub bytecode_hits: HashMap, /// The bytecode -> source mappings @@ -70,7 +70,10 @@ impl CoverageReport { } /// Add anchors to this report - pub fn add_anchors(&mut self, anchors: HashMap>) { + pub fn add_anchors( + &mut self, + anchors: HashMap, Vec)>, + ) { self.anchors.extend(anchors); } @@ -124,7 +127,12 @@ impl CoverageReport { /// /// This function should only be called *after* all the relevant sources have been processed and /// added to the map (see [add_source]). - pub fn add_hit_map(&mut self, contract_id: &ContractId, hit_map: &HitMap) -> Result<()> { + pub fn add_hit_map( + &mut self, + contract_id: &ContractId, + hit_map: &HitMap, + is_deployed_code: bool, + ) -> Result<()> { // Add bytecode level hits let e = self .bytecode_hits @@ -139,6 +147,7 @@ impl CoverageReport { // Add source level hits if let Some(anchors) = self.anchors.get(contract_id) { + let anchors = if is_deployed_code { &anchors.1 } else { &anchors.0 }; for anchor in anchors { if let Some(hits) = hit_map.hits.get(&anchor.instruction) { self.items diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index eb4cecb3851e2..2a7000ec1a782 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -435,8 +435,9 @@ impl<'a> InvariantExecutor<'a> { } // Exclude any artifact without mutable functions. - for (artifact, (abi, _)) in self.project_contracts.iter() { - if abi + for (artifact, contract) in self.project_contracts.iter() { + if contract + .abi .functions() .filter(|func| { !matches!( @@ -474,12 +475,14 @@ impl<'a> InvariantExecutor<'a> { contract: String, selectors: &[FixedBytes<4>], ) -> eyre::Result { - if let Some((artifact, (abi, _))) = + if let Some((artifact, contract_data)) = self.project_contracts.find_by_name_or_identifier(&contract)? { // Check that the selectors really exist for this contract. for selector in selectors { - abi.functions() + contract_data + .abi + .functions() .find(|func| func.selector().as_slice() == selector.as_slice()) .wrap_err(format!("{contract} does not have the selector {selector:?}"))?; } @@ -563,7 +566,7 @@ impl<'a> InvariantExecutor<'a> { // Identifiers are specified as an array, so we loop through them. for identifier in artifacts { // Try to find the contract by name or identifier in the project's contracts. - if let Some((_, (abi, _))) = + if let Some((_, contract)) = self.project_contracts.find_by_name_or_identifier(identifier)? { combined @@ -574,10 +577,10 @@ impl<'a> InvariantExecutor<'a> { let (_, contract_abi, _) = entry; // Extend the ABI's function list with the new functions. - contract_abi.functions.extend(abi.functions.clone()); + contract_abi.functions.extend(contract.abi.functions.clone()); }) // Otherwise insert it into the map. - .or_insert_with(|| (identifier.to_string(), abi.clone(), vec![])); + .or_insert_with(|| (identifier.to_string(), contract.abi.clone(), vec![])); } } } diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index f432154b9f9b2..2c5e98d9c39af 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -316,15 +316,17 @@ pub fn collect_created_contracts( if !setup_contracts.contains_key(address) { if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { if !code.is_empty() { - if let Some((artifact, (abi, _))) = - project_contracts.find_by_code(&code.original_bytes()) + if let Some((artifact, contract)) = + project_contracts.find_by_deployed_code(&code.original_bytes()) { if let Some(functions) = - artifact_filters.get_targeted_functions(artifact, abi)? + artifact_filters.get_targeted_functions(artifact, &contract.abi)? { created_contracts.push(*address); - writable_targeted - .insert(*address, (artifact.name.clone(), abi.clone(), functions)); + writable_targeted.insert( + *address, + (artifact.name.clone(), contract.abi.clone(), functions), + ); } } } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index f53d8b5162580..ad4e161cf9544 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -56,8 +56,8 @@ impl CallTraceDecoderBuilder { #[inline] pub fn with_known_contracts(mut self, contracts: &ContractsByArtifact) -> Self { trace!(target: "evm::traces", len=contracts.len(), "collecting known contract ABIs"); - for (abi, _) in contracts.values() { - self.decoder.collect_abi(abi, None); + for contract in contracts.values() { + self.decoder.collect_abi(&contract.abi, None); } self } diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index 193a8c526183c..175414a7caeee 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -9,7 +9,7 @@ use std::borrow::Cow; pub struct LocalTraceIdentifier<'a> { /// Known contracts to search through. known_contracts: &'a ContractsByArtifact, - /// Vector of pairs of artifact ID and the code length of the given artifact. + /// Vector of pairs of artifact ID and the runtime code length of the given artifact. ordered_ids: Vec<(&'a ArtifactId, usize)>, } @@ -17,8 +17,10 @@ impl<'a> LocalTraceIdentifier<'a> { /// Creates a new local trace identifier. #[inline] pub fn new(known_contracts: &'a ContractsByArtifact) -> Self { - let mut ordered_ids = - known_contracts.iter().map(|(id, contract)| (id, contract.1.len())).collect::>(); + let mut ordered_ids = known_contracts + .iter() + .map(|(id, contract)| (id, contract.deployed_bytecode.len())) + .collect::>(); ordered_ids.sort_by_key(|(_, len)| *len); Self { known_contracts, ordered_ids } } @@ -37,15 +39,15 @@ impl<'a> LocalTraceIdentifier<'a> { let mut min_score_id = None; let mut check = |id| { - let (abi, known_code) = self.known_contracts.get(id)?; - let score = bytecode_diff_score(known_code, code); + let contract = self.known_contracts.get(id)?; + let score = bytecode_diff_score(&contract.deployed_bytecode, code); if score == 0.0 { trace!(target: "evm::traces", "found exact match"); - return Some((id, abi)); + return Some((id, &contract.abi)); } if score < min_score { min_score = score; - min_score_id = Some((id, abi)); + min_score_id = Some((id, &contract.abi)); } None }; diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 2538c03ca5dcc..81f13f95a230e 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -308,8 +308,8 @@ pub fn load_contracts( .contracts .iter() .filter_map(|(addr, name)| { - if let Ok(Some((_, (abi, _)))) = contracts.find_by_name_or_identifier(name) { - return Some((*addr, (name.clone(), abi.clone()))); + if let Ok(Some((_, contract))) = contracts.find_by_name_or_identifier(name) { + return Some((*addr, (name.clone(), contract.abi.clone()))); } None }) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 7e119fe47e64a..bbd99de331e2f 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -5,7 +5,7 @@ use eyre::{Context, Result}; use forge::{ coverage::{ analysis::SourceAnalyzer, anchors::find_anchors, BytecodeReporter, ContractId, - CoverageReport, CoverageReporter, DebugReporter, ItemAnchor, LcovReporter, SummaryReporter, + CoverageReport, CoverageReporter, DebugReporter, LcovReporter, SummaryReporter, }, inspectors::CheatsConfig, opts::EvmOpts, @@ -271,21 +271,26 @@ impl CoverageArgs { items_by_source_id.entry(item.loc.source_id).or_default().push(item_id); } - let anchors: HashMap> = source_maps + let anchors = source_maps .iter() .filter(|(contract_id, _)| contract_id.version == version) - .filter_map(|(contract_id, (_, deployed_source_map))| { + .filter_map(|(contract_id, (creation_source_map, deployed_source_map))| { + let creation_code_anchors = find_anchors( + &bytecodes.get(contract_id)?.0, + creation_source_map, + &ic_pc_maps.get(contract_id)?.0, + &source_analysis.items, + &items_by_source_id, + ); + let deployed_code_anchors = find_anchors( + &bytecodes.get(contract_id)?.1, + deployed_source_map, + &ic_pc_maps.get(contract_id)?.1, + &source_analysis.items, + &items_by_source_id, + ); // TODO: Creation source map/bytecode as well - Some(( - contract_id.clone(), - find_anchors( - &bytecodes.get(contract_id)?.1, - deployed_source_map, - &ic_pc_maps.get(contract_id)?.1, - &source_analysis.items, - &items_by_source_id, - ), - )) + Some((contract_id.clone(), (creation_code_anchors, deployed_code_anchors))) }) .collect(); report.add_items(version, source_analysis.items); @@ -345,17 +350,26 @@ impl CoverageArgs { .filter_map(|mut result| result.coverage.take()) .flat_map(|hit_maps| { hit_maps.0.into_values().filter_map(|map| { - Some((known_contracts.find_by_code(map.bytecode.as_ref())?.0, map)) + if let Some((id, _)) = + known_contracts.find_by_deployed_code(map.bytecode.as_ref()) + { + Some((id, map, true)) + } else if let Some((id, _)) = + known_contracts.find_by_creation_code(map.bytecode.as_ref()) + { + Some((id, map, false)) + } else { + None + } }) }); - for (artifact_id, hits) in data { + for (artifact_id, hits, is_deployed_code) in data { // TODO: Note down failing tests if let Some(source_id) = report.get_source_id( artifact_id.version.clone(), artifact_id.source.to_string_lossy().to_string(), ) { let source_id = *source_id; - // TODO: Distinguish between creation/runtime in a smart way report.add_hit_map( &ContractId { version: artifact_id.version.clone(), @@ -363,6 +377,7 @@ impl CoverageArgs { contract_name: artifact_id.name.clone(), }, &hits, + is_deployed_code, )?; } } diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 1c79c0e33ec40..19724bc2fa9a4 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -161,17 +161,27 @@ impl CoverageReporter for DebugReporter { for (contract_id, anchors) in &report.anchors { println!("Anchors for {contract_id}:"); - anchors.iter().for_each(|anchor| { - println!("- {anchor}"); - println!( - " - Refers to item: {}", - report - .items - .get(&contract_id.version) - .and_then(|items| items.get(anchor.item_id)) - .map_or("None".to_owned(), |item| item.to_string()) - ); - }); + anchors + .0 + .iter() + .map(|anchor| (false, anchor)) + .chain(anchors.1.iter().map(|anchor| (true, anchor))) + .for_each(|(is_deployed, anchor)| { + println!("- {anchor}"); + if is_deployed { + println!("- Creation code"); + } else { + println!("- Runtime code"); + } + println!( + " - Refers to item: {}", + report + .items + .get(&contract_id.version) + .and_then(|items| items.get(anchor.item_id)) + .map_or("None".to_owned(), |item| item.to_string()) + ); + }); println!(); } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index f19e67d22ec3e..8bfb1477b4e00 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -4,7 +4,7 @@ use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; -use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; +use foundry_common::{get_contract_name, ContractData, ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{ artifacts::Libraries, contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput, }; @@ -328,6 +328,8 @@ impl MultiContractRunnerBuilder { continue; }; + let name = id.name.clone(); + let LinkOutput { libs_to_deploy, libraries } = linker.link_with_nonce_or_address(Default::default(), evm_opts.sender, 1, id)?; @@ -342,7 +344,15 @@ impl MultiContractRunnerBuilder { .map(|b| b.into_owned()) .filter(|b| !b.is_empty()) else { - known_contracts.insert(id.clone(), (abi.clone(), vec![])); + known_contracts.insert( + id.clone(), + ContractData { + abi: abi.clone(), + bytecode: Bytes::new(), + deployed_bytecode: Bytes::new(), + name, + }, + ); continue; }; @@ -352,17 +362,30 @@ impl MultiContractRunnerBuilder { { deployable_contracts.insert( id.clone(), - TestContract { abi: abi.clone(), bytecode, libs_to_deploy, libraries }, + TestContract { + abi: abi.clone(), + bytecode: bytecode.clone(), + libs_to_deploy, + libraries, + }, ); } if let Some(bytes) = linked_contract.get_deployed_bytecode_bytes() { - known_contracts.insert(id.clone(), (abi.clone(), bytes.into_owned().into())); + known_contracts.insert( + id.clone(), + ContractData { + abi: abi.clone(), + bytecode, + deployed_bytecode: bytes.into_owned(), + name, + }, + ); } } let revert_decoder = - RevertDecoder::new().with_abis(known_contracts.values().map(|(abi, _)| abi)); + RevertDecoder::new().with_abis(known_contracts.values().map(|c| &c.abi)); Ok(MultiContractRunner { contracts: deployable_contracts, known_contracts, diff --git a/crates/script/src/artifacts.rs b/crates/script/src/artifacts.rs deleted file mode 100644 index ebd149f4903cf..0000000000000 --- a/crates/script/src/artifacts.rs +++ /dev/null @@ -1,8 +0,0 @@ -use alloy_json_abi::JsonAbi; - -/// Bundles info of an artifact -pub struct ArtifactInfo<'a> { - pub contract_name: String, - pub abi: &'a JsonAbi, - pub code: &'a Vec, -} diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 51fde33adafd9..4fb88719b13bc 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -14,12 +14,11 @@ use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ compile::{self, ContractSources, ProjectCompiler}, provider::alloy::try_get_http_provider, - ContractsByArtifact, + ContractData, ContractsByArtifact, }; use foundry_compilers::{ - artifacts::{BytecodeObject, ContractBytecode, ContractBytecodeSome, Libraries}, + artifacts::{BytecodeObject, Libraries}, cache::SolFilesCache, - contracts::ArtifactContracts, info::ContractInfo, ArtifactId, ProjectCompileOutput, }; @@ -85,7 +84,7 @@ pub struct LinkedBuildData { /// Original build data, might be used to relink this object with different libraries. pub build_data: BuildData, /// Known fully linked contracts. - pub highlevel_known_contracts: ArtifactContracts, + pub known_contracts: ContractsByArtifact, /// Libraries used to link the contracts. pub libraries: Libraries, /// Libraries that need to be deployed by sender before script execution. @@ -102,47 +101,35 @@ impl LinkedBuildData { &link_output.libraries, )?; - let highlevel_known_contracts = build_data - .get_linker() - .get_linked_artifacts(&link_output.libraries)? - .iter() - .filter_map(|(id, contract)| { - ContractBytecodeSome::try_from(ContractBytecode::from(contract.clone())) - .ok() - .map(|tc| (id.clone(), tc)) - }) - .filter(|(_, tc)| tc.bytecode.object.is_non_empty_bytecode()) - .collect(); + let known_contracts = ContractsByArtifact( + build_data + .get_linker() + .get_linked_artifacts(&link_output.libraries)? + .into_iter() + .filter_map(|(id, contract)| { + let name = id.name.clone(); + let bytecode = contract.bytecode.and_then(|b| b.into_bytes())?; + let deployed_bytecode = + contract.deployed_bytecode.and_then(|b| b.into_bytes())?; + let abi = contract.abi?; + + Some((id, ContractData { name, abi, bytecode, deployed_bytecode })) + }) + .collect(), + ); Ok(Self { build_data, - highlevel_known_contracts, + known_contracts, libraries: link_output.libraries, predeploy_libraries: link_output.libs_to_deploy, sources, }) } - /// Flattens the contracts into (`id` -> (`JsonAbi`, `Vec`)) pairs - pub fn get_flattened_contracts(&self, deployed_code: bool) -> ContractsByArtifact { - ContractsByArtifact( - self.highlevel_known_contracts - .iter() - .filter_map(|(id, c)| { - let bytecode = if deployed_code { - c.deployed_bytecode.bytes() - } else { - c.bytecode.bytes() - }; - bytecode.cloned().map(|code| (id.clone(), (c.abi.clone(), code.into()))) - }) - .collect(), - ) - } - /// Fetches target bytecode from linked contracts. - pub fn get_target_contract(&self) -> Result { - self.highlevel_known_contracts + pub fn get_target_contract(&self) -> Result { + self.known_contracts .get(&self.build_data.target) .cloned() .ok_or_eyre("target not found in linked artifacts") diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 03ac8bc9e44d5..9e76955914e4d 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -17,9 +17,8 @@ use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ fmt::{format_token, format_token_raw}, provider::alloy::{get_http_provider, RpcUrl}, - shell, ContractsByArtifact, + shell, ContractData, ContractsByArtifact, }; -use foundry_compilers::artifacts::ContractBytecodeSome; use foundry_config::{Config, NamedChain}; use foundry_debugger::Debugger; use foundry_evm::{ @@ -62,11 +61,7 @@ impl LinkedState { pub async fn prepare_execution(self) -> Result { let Self { args, script_config, script_wallets, build_data } = self; - let ContractBytecodeSome { abi, bytecode, .. } = build_data.get_target_contract()?; - - let bytecode = bytecode.into_bytes().ok_or_else(|| { - eyre::eyre!("expected fully linked bytecode, found unlinked bytecode") - })?; + let ContractData { abi, bytecode, .. } = build_data.get_target_contract()?; let (func, calldata) = args.get_method_and_calldata(&abi)?; @@ -301,8 +296,7 @@ impl ExecutedState { pub async fn prepare_simulation(self) -> Result { let returns = self.get_returns()?; - let known_contracts = self.build_data.get_flattened_contracts(true); - let decoder = self.build_trace_decoder(&known_contracts)?; + let decoder = self.build_trace_decoder(&self.build_data.known_contracts)?; let txs = self.execution_result.transactions.clone().unwrap_or_default(); let rpc_data = RpcData::from_transactions(&txs); diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 8973dc1260c36..17f70387acc5b 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -18,12 +18,11 @@ use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ abi::{encode_function_args, get_func}, compile::SkipBuildFilter, - errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, provider::alloy::RpcUrl, - shell, CONTRACT_MAX_SIZE, SELECTOR_LEN, + shell, ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; -use foundry_compilers::{artifacts::ContractBytecodeSome, ArtifactId}; +use foundry_compilers::ArtifactId; use foundry_config::{ figment, figment::{ @@ -46,10 +45,9 @@ use foundry_evm::{ }; use foundry_wallets::MultiWalletOpts; use serde::{Deserialize, Serialize}; -use std::collections::{BTreeMap, HashMap}; +use std::collections::HashMap; use yansi::Paint; -mod artifacts; mod broadcast; mod build; mod execute; @@ -269,7 +267,7 @@ impl ScriptArgs { pre_simulation.args.check_contract_sizes( &pre_simulation.execution_result, - &pre_simulation.build_data.highlevel_known_contracts, + &pre_simulation.build_data.known_contracts, )?; pre_simulation.fill_metadata().await?.bundle().await? @@ -357,25 +355,18 @@ impl ScriptArgs { fn check_contract_sizes( &self, result: &ScriptResult, - known_contracts: &BTreeMap, + known_contracts: &ContractsByArtifact, ) -> Result<()> { // (name, &init, &deployed)[] let mut bytecodes: Vec<(String, &[u8], &[u8])> = vec![]; // From artifacts - for (artifact, bytecode) in known_contracts.iter() { - if bytecode.bytecode.object.is_unlinked() { - return Err(UnlinkedByteCode::Bytecode(artifact.identifier()).into()); - } - let init_code = bytecode.bytecode.object.as_bytes().unwrap(); - // Ignore abstract contracts - if let Some(ref deployed_code) = bytecode.deployed_bytecode.bytecode { - if deployed_code.object.is_unlinked() { - return Err(UnlinkedByteCode::DeployedBytecode(artifact.identifier()).into()); - } - let deployed_code = deployed_code.object.as_bytes().unwrap(); - bytecodes.push((artifact.name.clone(), init_code, deployed_code)); - } + for (artifact, contract) in known_contracts.iter() { + bytecodes.push(( + artifact.name.clone(), + &contract.bytecode, + &contract.deployed_bytecode, + )); } // From traces diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index c740e59a4735b..87f9b3515fb22 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -1,5 +1,4 @@ use super::{ - artifacts::ArtifactInfo, multi_sequence::MultiChainSequence, providers::ProvidersManager, runner::ScriptRunner, @@ -18,7 +17,7 @@ use alloy_primitives::{utils::format_units, Address, U256}; use eyre::{Context, Result}; use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; use foundry_cli::utils::{has_different_gas_calc, now}; -use foundry_common::{get_contract_name, provider::alloy::RpcUrl, shell, ContractsByArtifact}; +use foundry_common::{get_contract_name, provider::alloy::RpcUrl, shell, ContractData}; use foundry_evm::traces::render_trace_arena; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; @@ -88,9 +87,7 @@ impl PreSimulationState { .collect::>(), ); - let contracts = self.build_data.get_flattened_contracts(false); - let address_to_abi: BTreeMap = - self.build_address_to_abi_map(&contracts); + let address_to_abi = self.build_address_to_abi_map(); let mut final_txs = VecDeque::new(); @@ -183,21 +180,17 @@ impl PreSimulationState { } /// Build mapping from contract address to its ABI, code and contract name. - fn build_address_to_abi_map<'a>( - &self, - contracts: &'a ContractsByArtifact, - ) -> BTreeMap> { + fn build_address_to_abi_map(&self) -> BTreeMap { self.execution_artifacts .decoder .contracts .iter() .filter_map(move |(addr, contract_id)| { let contract_name = get_contract_name(contract_id); - if let Ok(Some((_, (abi, code)))) = - contracts.find_by_name_or_identifier(contract_name) + if let Ok(Some((_, data))) = + self.build_data.known_contracts.find_by_name_or_identifier(contract_name) { - let info = ArtifactInfo { contract_name: contract_name.to_string(), abi, code }; - return Some((*addr, info)); + return Some((*addr, data)); } None }) diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index e74699e749137..cf392129055ee 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,9 +1,9 @@ -use super::{artifacts::ArtifactInfo, ScriptResult}; +use super::ScriptResult; use alloy_dyn_abi::JsonAbiExt; use alloy_primitives::{Address, Bytes, B256}; use alloy_rpc_types::{request::TransactionRequest, WithOtherFields}; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{fmt::format_token_raw, provider::alloy::RpcUrl, SELECTOR_LEN}; +use foundry_common::{fmt::format_token_raw, provider::alloy::RpcUrl, ContractData, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; use itertools::Itertools; use revm_inspectors::tracing::types::CallKind; @@ -61,7 +61,7 @@ impl TransactionWithMetadata { transaction: TransactionRequest, rpc: RpcUrl, result: &ScriptResult, - local_contracts: &BTreeMap, + local_contracts: &BTreeMap, decoder: &CallTraceDecoder, additional_contracts: Vec, is_fixed_gas_limit: bool, @@ -117,7 +117,7 @@ impl TransactionWithMetadata { &mut self, is_create2: bool, address: Address, - contracts: &BTreeMap, + contracts: &BTreeMap, ) -> Result<()> { if is_create2 { self.opcode = CallKind::Create2; @@ -126,7 +126,7 @@ impl TransactionWithMetadata { } let info = contracts.get(&address); - self.contract_name = info.map(|info| info.contract_name.clone()); + self.contract_name = info.map(|info| info.name.clone()); self.contract_address = Some(address); let Some(data) = self.transaction.input.input() else { return Ok(()) }; @@ -143,11 +143,11 @@ impl TransactionWithMetadata { }; // The constructor args start after bytecode. - let contains_constructor_args = creation_code.len() > info.code.len(); + let contains_constructor_args = creation_code.len() > info.bytecode.len(); if !contains_constructor_args { return Ok(()); } - let constructor_args = &creation_code[info.code.len()..]; + let constructor_args = &creation_code[info.bytecode.len()..]; let Some(constructor) = info.abi.constructor() else { return Ok(()) }; let values = constructor.abi_decode_input(constructor_args, false).map_err(|e| { @@ -170,7 +170,7 @@ impl TransactionWithMetadata { fn set_call( &mut self, target: Address, - local_contracts: &BTreeMap, + local_contracts: &BTreeMap, decoder: &CallTraceDecoder, ) -> Result<()> { self.opcode = CallKind::Call; @@ -184,7 +184,7 @@ impl TransactionWithMetadata { let function = if let Some(info) = local_contracts.get(&target) { // This CALL is made to a local contract. - self.contract_name = Some(info.contract_name.clone()); + self.contract_name = Some(info.name.clone()); info.abi.functions().find(|function| function.selector() == selector) } else { // This CALL is made to an external contract; try to decode it from the given decoder. diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 217d880b07b7c..c9e10200437d2 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -26,7 +26,7 @@ impl BroadcastedState { let verify = VerifyBundle::new( &script_config.config.project()?, &script_config.config, - build_data.get_flattened_contracts(false), + build_data.known_contracts, args.retry, args.verifier, ); @@ -105,11 +105,12 @@ impl VerifyBundle { data: &[u8], libraries: &[String], ) -> Option { - for (artifact, (_contract, bytecode)) in self.known_contracts.iter() { + for (artifact, contract) in self.known_contracts.iter() { // If it's a CREATE2, the tx.data comes with a 32-byte salt in the beginning // of the transaction - if data.split_at(create2_offset).1.starts_with(bytecode) { - let constructor_args = data.split_at(create2_offset + bytecode.len()).1.to_vec(); + if data.split_at(create2_offset).1.starts_with(&contract.bytecode) { + let constructor_args = + data.split_at(create2_offset + contract.bytecode.len()).1.to_vec(); let contract = ContractInfo { path: Some( From b56176ebf26e17603abe67be38219fd99455f1fb Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 16 Apr 2024 18:37:06 +0200 Subject: [PATCH 0855/1963] feat(forge-cli): Add `--no-metadata` as CLI compiler option (#7684) * add `no_metadata`, equivalent to adding `bytecode_hash = "none" and cbor_metadata = false` * add basic smoke test for --no-metadata setting cbor_metadata to false, bytecode_hash to none * Update core.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cli/src/opts/build/core.rs | 13 +++++++++++++ crates/forge/tests/cli/config.rs | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 9ed8f98b3330f..99caaea354542 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -70,6 +70,13 @@ pub struct CoreBuildArgs { #[serde(skip)] pub via_ir: bool, + /// Do not append any metadata to the bytecode. + /// + /// This is equivalent to setting `bytecode_hash` to `none` and `cbor_metadata` to `false`. + #[arg(long, help_heading = "Compiler options")] + #[serde(skip)] + pub no_metadata: bool, + /// The path to the contract artifacts folder. #[arg( long = "out", @@ -204,9 +211,15 @@ impl Provider for CoreBuildArgs { dict.insert("via_ir".to_string(), true.into()); } + if self.no_metadata { + dict.insert("bytecode_hash".to_string(), "none".into()); + dict.insert("cbor_metadata".to_string(), false.into()); + } + if self.force { dict.insert("force".to_string(), self.force.into()); } + // we need to ensure no_cache set accordingly if self.no_cache { dict.insert("cache".to_string(), false.into()); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 22d885af49314..8c69fcc4f84ea 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -2,7 +2,7 @@ use alloy_primitives::{Address, B256, U256}; use foundry_cli::utils as forge_utils; -use foundry_compilers::artifacts::{OptimizerDetails, RevertStrings, YulDetails}; +use foundry_compilers::artifacts::{BytecodeHash, OptimizerDetails, RevertStrings, YulDetails}; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, fs_permissions::{FsAccessPermission, PathPermission}, @@ -305,8 +305,10 @@ forgetest_init!(can_get_evm_opts, |prj, _cmd| { // checks that we can set various config values forgetest_init!(can_set_config_values, |prj, _cmd| { - let config = prj.config_from_output(["--via-ir"]); + let config = prj.config_from_output(["--via-ir", "--no-metadata"]); assert!(config.via_ir); + assert_eq!(config.cbor_metadata, false); + assert_eq!(config.bytecode_hash, BytecodeHash::None); }); // tests that solc can be explicitly set From 9207b93b4338e587d522f81007f6989717c99708 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:01:00 +0200 Subject: [PATCH 0856/1963] feat(debugger): update ratatui, use `List` (#7676) * feat(debugger): update ratatui, use `List` * refactor(debugger): event handlers * fmt --- Cargo.lock | 80 +++++---- crates/debugger/Cargo.toml | 2 +- crates/debugger/src/tui/context.rs | 274 ++++++++++++++--------------- crates/debugger/src/tui/draw.rs | 133 +++++--------- crates/debugger/src/tui/mod.rs | 5 +- 5 files changed, 227 insertions(+), 267 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f24466027310..e550e31f824aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,7 +73,7 @@ checksum = "40646aa7f01e396139cf0d6c3a7475eeb8094a0f41d8199f10860c8aef09d2f1" dependencies = [ "num_enum", "serde", - "strum 0.26.2", + "strum", ] [[package]] @@ -1815,6 +1815,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" +[[package]] +name = "castaway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" +dependencies = [ + "rustversion", +] + [[package]] name = "cc" version = "1.0.94" @@ -1866,7 +1875,7 @@ dependencies = [ "serde_json", "serial_test", "solang-parser", - "strum 0.26.2", + "strum", "tikv-jemallocator", "time", "tokio", @@ -2135,8 +2144,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ "crossterm", - "strum 0.26.2", - "strum_macros 0.26.2", + "strum", + "strum_macros", "unicode-width", ] @@ -2152,6 +2161,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "compact_str" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "ryu", + "static_assertions", +] + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -3042,7 +3064,7 @@ dependencies = [ "rlp", "serde", "serde_json", - "strum 0.26.2", + "strum", "syn 2.0.58", "tempfile", "thiserror", @@ -3476,7 +3498,7 @@ dependencies = [ "serde_json", "similar", "solang-parser", - "strum 0.26.2", + "strum", "svm-rs 0.4.1", "tempfile", "thiserror", @@ -3711,7 +3733,7 @@ dependencies = [ "regex", "serde", "strsim 0.10.0", - "strum 0.26.2", + "strum", "tempfile", "tokio", "tracing", @@ -6702,18 +6724,20 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.24.0" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" +checksum = "a564a852040e82671dc50a37d88f3aa83bbc690dfc6844cfe7a2591620206a80" dependencies = [ "bitflags 2.5.0", "cassowary", + "compact_str", "crossterm", "indoc", - "itertools 0.11.0", + "itertools 0.12.1", "lru", "paste", - "strum 0.25.0", + "stability", + "strum", "unicode-segmentation", "unicode-width", ] @@ -7830,6 +7854,16 @@ dependencies = [ "der", ] +[[package]] +name = "stability" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" +dependencies = [ + "quote", + "syn 2.0.58", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -7880,35 +7914,13 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" -dependencies = [ - "strum_macros 0.25.3", -] - [[package]] name = "strum" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros 0.26.2", -] - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.58", + "strum_macros", ] [[package]] diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index 3c1fe8480116e..bc3c746e3d859 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -20,6 +20,6 @@ alloy-primitives.workspace = true crossterm = "0.27" eyre.workspace = true -ratatui = { version = "0.24.0", default-features = false, features = ["crossterm"] } +ratatui = { version = "0.26", default-features = false, features = ["crossterm"] } revm.workspace = true tracing.workspace = true diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index b0da8a0c519f2..58a8e57f42751 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -5,13 +5,11 @@ use alloy_primitives::Address; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; use foundry_evm_core::debug::{DebugNodeFlat, DebugStep}; use revm_inspectors::tracing::types::CallKind; -use std::{cell::RefCell, ops::ControlFlow}; +use std::ops::ControlFlow; /// This is currently used to remember last scroll position so screen doesn't wiggle as much. #[derive(Default)] pub(crate) struct DrawMemory { - // TODO - pub(crate) current_startline: RefCell, pub(crate) inner_call_index: usize, pub(crate) current_buf_startline: usize, pub(crate) current_stack_startline: usize, @@ -120,6 +118,13 @@ impl<'a> DebuggerContext<'a> { self.opcode_list.extend(debug_steps.iter().map(DebugStep::pretty_opcode)); } + fn gen_opcode_list_if_necessary(&mut self) { + if self.last_index != self.draw_memory.inner_call_index { + self.gen_opcode_list(); + self.last_index = self.draw_memory.inner_call_index; + } + } + fn active_buffer(&self) -> &[u8] { match self.active_buffer { BufferKind::Memory => &self.current_step().memory, @@ -131,19 +136,18 @@ impl<'a> DebuggerContext<'a> { impl DebuggerContext<'_> { pub(crate) fn handle_event(&mut self, event: Event) -> ControlFlow { - if self.last_index != self.draw_memory.inner_call_index { - self.gen_opcode_list(); - self.last_index = self.draw_memory.inner_call_index; - } - - match event { + let ret = match event { Event::Key(event) => self.handle_key_event(event), Event::Mouse(event) => self.handle_mouse_event(event), _ => ControlFlow::Continue(()), - } + }; + // Generate the list after the event has been handled. + self.gen_opcode_list_if_necessary(); + ret } fn handle_key_event(&mut self, event: KeyEvent) -> ControlFlow { + // Breakpoints if let KeyCode::Char(c) = event.code { if c.is_alphabetic() && self.key_buffer.starts_with('\'') { self.handle_breakpoint(c); @@ -151,154 +155,130 @@ impl DebuggerContext<'_> { } } + let control = event.modifiers.contains(KeyModifiers::CONTROL); + match event.code { // Exit KeyCode::Char('q') => return ControlFlow::Break(ExitReason::CharExit), - // Move down - KeyCode::Char('j') | KeyCode::Down => { - // Grab number of times to do it - for _ in 0..buffer_as_number(&self.key_buffer, 1) { - if event.modifiers.contains(KeyModifiers::CONTROL) { - let max_buf = (self.active_buffer().len() / 32).saturating_sub(1); - if self.draw_memory.current_buf_startline < max_buf { - self.draw_memory.current_buf_startline += 1; - } - } else if self.current_step < self.opcode_list.len() - 1 { - self.current_step += 1; - } else if self.draw_memory.inner_call_index < self.debug_arena().len() - 1 { - self.draw_memory.inner_call_index += 1; - self.current_step = 0; - } - } - self.key_buffer.clear(); - } - KeyCode::Char('J') => { - for _ in 0..buffer_as_number(&self.key_buffer, 1) { - let max_stack = self.current_step().stack.len().saturating_sub(1); - if self.draw_memory.current_stack_startline < max_stack { - self.draw_memory.current_stack_startline += 1; - } + + // Scroll up the memory buffer + KeyCode::Char('k') | KeyCode::Up if control => self.repeat(|this| { + this.draw_memory.current_buf_startline = + this.draw_memory.current_buf_startline.saturating_sub(1); + }), + // Scroll down the memory buffer + KeyCode::Char('j') | KeyCode::Down if control => self.repeat(|this| { + let max_buf = (this.active_buffer().len() / 32).saturating_sub(1); + if this.draw_memory.current_buf_startline < max_buf { + this.draw_memory.current_buf_startline += 1; } - self.key_buffer.clear(); - } + }), + // Move up - KeyCode::Char('k') | KeyCode::Up => { - for _ in 0..buffer_as_number(&self.key_buffer, 1) { - if event.modifiers.contains(KeyModifiers::CONTROL) { - self.draw_memory.current_buf_startline = - self.draw_memory.current_buf_startline.saturating_sub(1); - } else if self.current_step > 0 { - self.current_step -= 1; - } else if self.draw_memory.inner_call_index > 0 { - self.draw_memory.inner_call_index -= 1; - self.current_step = self.debug_steps().len() - 1; - } - } - self.key_buffer.clear(); - } - KeyCode::Char('K') => { - for _ in 0..buffer_as_number(&self.key_buffer, 1) { - self.draw_memory.current_stack_startline = - self.draw_memory.current_stack_startline.saturating_sub(1); + KeyCode::Char('k') | KeyCode::Up => self.repeat(Self::step_back), + // Move down + KeyCode::Char('j') | KeyCode::Down => self.repeat(Self::step), + + // Scroll up the stack + KeyCode::Char('K') => self.repeat(|this| { + this.draw_memory.current_stack_startline = + this.draw_memory.current_stack_startline.saturating_sub(1); + }), + // Scroll down the stack + KeyCode::Char('J') => self.repeat(|this| { + let max_stack = this.current_step().stack.len().saturating_sub(1); + if this.draw_memory.current_stack_startline < max_stack { + this.draw_memory.current_stack_startline += 1; } - self.key_buffer.clear(); - } + }), + + // Cycle buffers KeyCode::Char('b') => { self.active_buffer = self.active_buffer.next(); self.draw_memory.current_buf_startline = 0; } + // Go to top of file KeyCode::Char('g') => { self.draw_memory.inner_call_index = 0; self.current_step = 0; - self.key_buffer.clear(); } + // Go to bottom of file KeyCode::Char('G') => { self.draw_memory.inner_call_index = self.debug_arena().len() - 1; - self.current_step = self.debug_steps().len() - 1; - self.key_buffer.clear(); + self.current_step = self.n_steps() - 1; } + // Go to previous call KeyCode::Char('c') => { self.draw_memory.inner_call_index = self.draw_memory.inner_call_index.saturating_sub(1); - self.current_step = self.debug_steps().len() - 1; - self.key_buffer.clear(); + self.current_step = self.n_steps() - 1; } + // Go to next call KeyCode::Char('C') => { if self.debug_arena().len() > self.draw_memory.inner_call_index + 1 { self.draw_memory.inner_call_index += 1; self.current_step = 0; } - self.key_buffer.clear(); } + // Step forward - KeyCode::Char('s') => { - for _ in 0..buffer_as_number(&self.key_buffer, 1) { - let remaining_ops = self.opcode_list[self.current_step..].to_vec(); - self.current_step += remaining_ops - .iter() - .enumerate() - .find_map(|(i, op)| { - if i < remaining_ops.len() - 1 { - match ( - op.contains("JUMP") && op != "JUMPDEST", - &*remaining_ops[i + 1], - ) { - (true, "JUMPDEST") => Some(i + 1), - _ => None, - } - } else { - None - } - }) - .unwrap_or(self.opcode_list.len() - 1); - if self.current_step > self.opcode_list.len() { - self.current_step = self.opcode_list.len() - 1 - }; + KeyCode::Char('s') => self.repeat(|this| { + let remaining_ops = &this.opcode_list[this.current_step..]; + if let Some((i, _)) = remaining_ops.iter().enumerate().skip(1).find(|&(i, op)| { + let prev = &remaining_ops[i - 1]; + let prev_is_jump = prev.contains("JUMP") && prev != "JUMPDEST"; + let is_jumpdest = op == "JUMPDEST"; + prev_is_jump && is_jumpdest + }) { + this.current_step += i; } - self.key_buffer.clear(); - } + }), + // Step backwards - KeyCode::Char('a') => { - for _ in 0..buffer_as_number(&self.key_buffer, 1) { - let prev_ops = self.opcode_list[..self.current_step].to_vec(); - self.current_step = prev_ops - .iter() - .enumerate() - .rev() - .find_map(|(i, op)| { - if i > 0 { - match ( - prev_ops[i - 1].contains("JUMP") && - prev_ops[i - 1] != "JUMPDEST", - &**op, - ) { - (true, "JUMPDEST") => Some(i - 1), - _ => None, - } - } else { - None - } - }) - .unwrap_or_default(); - } - self.key_buffer.clear(); - } - // toggle stack labels + KeyCode::Char('a') => self.repeat(|this| { + let ops = &this.opcode_list[..this.current_step]; + this.current_step = ops + .iter() + .enumerate() + .skip(1) + .rev() + .find(|&(i, op)| { + let prev = &ops[i - 1]; + let prev_is_jump = prev.contains("JUMP") && prev != "JUMPDEST"; + let is_jumpdest = op == "JUMPDEST"; + prev_is_jump && is_jumpdest + }) + .map(|(i, _)| i) + .unwrap_or_default(); + }), + + // Toggle stack labels KeyCode::Char('t') => self.stack_labels = !self.stack_labels, - // toggle memory utf8 decoding + + // Toggle memory UTF-8 decoding KeyCode::Char('m') => self.buf_utf = !self.buf_utf, - // toggle help notice + + // Toggle help notice KeyCode::Char('h') => self.show_shortcuts = !self.show_shortcuts, + + // Numbers for repeating commands or breakpoints KeyCode::Char( other @ ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '\''), - ) => self.key_buffer.push(other), - _ => self.key_buffer.clear(), + ) => { + // Early return to not clear the buffer. + self.key_buffer.push(other); + return ControlFlow::Continue(()); + } + + // Unknown/unhandled key code + _ => {} }; + self.key_buffer.clear(); ControlFlow::Continue(()) } @@ -321,37 +301,47 @@ impl DebuggerContext<'_> { fn handle_mouse_event(&mut self, event: MouseEvent) -> ControlFlow { match event.kind { - MouseEventKind::ScrollUp => { - if self.current_step > 0 { - self.current_step -= 1; - } else if self.draw_memory.inner_call_index > 0 { - self.draw_memory.inner_call_index -= 1; - self.draw_memory.current_buf_startline = 0; - self.draw_memory.current_stack_startline = 0; - self.current_step = self.debug_steps().len() - 1; - } - } - MouseEventKind::ScrollDown => { - if self.current_step < self.opcode_list.len() - 1 { - self.current_step += 1; - } else if self.draw_memory.inner_call_index < self.debug_arena().len() - 1 { - self.draw_memory.inner_call_index += 1; - self.draw_memory.current_buf_startline = 0; - self.draw_memory.current_stack_startline = 0; - self.current_step = 0; - } - } + MouseEventKind::ScrollUp => self.step_back(), + MouseEventKind::ScrollDown => self.step(), _ => {} } ControlFlow::Continue(()) } + + fn step_back(&mut self) { + if self.current_step > 0 { + self.current_step -= 1; + } else if self.draw_memory.inner_call_index > 0 { + self.draw_memory.inner_call_index -= 1; + self.current_step = self.n_steps() - 1; + } + } + + fn step(&mut self) { + if self.current_step < self.n_steps() - 1 { + self.current_step += 1; + } else if self.draw_memory.inner_call_index < self.debug_arena().len() - 1 { + self.draw_memory.inner_call_index += 1; + self.current_step = 0; + } + } + + /// Calls a closure `f` the number of times specified in the key buffer, and at least once. + fn repeat(&mut self, mut f: impl FnMut(&mut Self)) { + for _ in 0..buffer_as_number(&self.key_buffer) { + f(self); + } + } + + fn n_steps(&self) -> usize { + self.debug_steps().len() + } } /// Grab number from buffer. Used for something like '10k' to move up 10 operations -fn buffer_as_number(s: &str, default_value: usize) -> usize { - match s.parse() { - Ok(num) if num >= 1 => num, - _ => default_value, - } +fn buffer_as_number(s: &str) -> usize { + const MIN: usize = 1; + const MAX: usize = 100_000; + s.parse().unwrap_or(MIN).clamp(MIN, MAX) } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 8d91f2803f0c6..b80a8a77a1079 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -9,11 +9,11 @@ use ratatui::{ style::{Color, Modifier, Style}, terminal::Frame, text::{Line, Span, Text}, - widgets::{Block, Borders, Paragraph, Wrap}, + widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap}, }; use revm::interpreter::opcode; use revm_inspectors::tracing::types::CallKind; -use std::{cmp, collections::VecDeque, fmt::Write, io}; +use std::{collections::VecDeque, fmt::Write, io}; impl DebuggerContext<'_> { /// Draws the TUI layout and subcomponents to the given terminal. @@ -91,25 +91,25 @@ impl DebuggerContext<'_> { // constraints, so the `else` branch is unreachable. // Split off footer. - let [app, footer] = Layout::new() - .constraints([Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)]) - .direction(Direction::Vertical) - .split(area)[..] - else { + let [app, footer] = Layout::new( + Direction::Vertical, + [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)], + ) + .split(area)[..] else { unreachable!() }; // Split the app in 4 vertically to construct all the panes. - let [op_pane, stack_pane, memory_pane, src_pane] = Layout::new() - .direction(Direction::Vertical) - .constraints([ + let [op_pane, stack_pane, memory_pane, src_pane] = Layout::new( + Direction::Vertical, + [ Constraint::Ratio(1, 6), Constraint::Ratio(1, 6), Constraint::Ratio(1, 6), Constraint::Ratio(3, 6), - ]) - .split(app)[..] - else { + ], + ) + .split(app)[..] else { unreachable!() }; @@ -138,37 +138,34 @@ impl DebuggerContext<'_> { let h_height = if self.show_shortcuts { 4 } else { 0 }; // Split off footer. - let [app, footer] = Layout::new() - .direction(Direction::Vertical) - .constraints([Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)]) - .split(area)[..] - else { + let [app, footer] = Layout::new( + Direction::Vertical, + [Constraint::Ratio(100 - h_height, 100), Constraint::Ratio(h_height, 100)], + ) + .split(area)[..] else { unreachable!() }; // Split app in 2 horizontally. - let [app_left, app_right] = Layout::new() - .direction(Direction::Horizontal) - .constraints([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)]) - .split(app)[..] + let [app_left, app_right] = + Layout::new(Direction::Horizontal, [Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)]) + .split(app)[..] else { unreachable!() }; // Split left pane in 2 vertically to opcode list and source. - let [op_pane, src_pane] = Layout::new() - .direction(Direction::Vertical) - .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)]) - .split(app_left)[..] + let [op_pane, src_pane] = + Layout::new(Direction::Vertical, [Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)]) + .split(app_left)[..] else { unreachable!() }; // Split right pane horizontally to construct stack and memory. - let [stack_pane, memory_pane] = Layout::new() - .direction(Direction::Vertical) - .constraints([Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)]) - .split(app_right)[..] + let [stack_pane, memory_pane] = + Layout::new(Direction::Vertical, [Constraint::Ratio(1, 4), Constraint::Ratio(3, 4)]) + .split(app_right)[..] else { unreachable!() }; @@ -380,63 +377,22 @@ impl DebuggerContext<'_> { } fn draw_op_list(&self, f: &mut Frame<'_>, area: Rect) { - let height = area.height as i32; - let extra_top_lines = height / 2; - // Absolute minimum start line - let abs_min_start = 0; - // Adjust for weird scrolling for max top line - let abs_max_start = (self.opcode_list.len() as i32 - 1) - (height / 2); - // actual minimum start line - let mut min_start = - cmp::max(self.current_step as i32 - height + extra_top_lines, abs_min_start) as usize; - - // actual max start line - let mut max_start = cmp::max( - cmp::min(self.current_step as i32 - extra_top_lines, abs_max_start), - abs_min_start, - ) as usize; - - // Sometimes, towards end of file, maximum and minim lines have swapped values. Swap if the - // case - if min_start > max_start { - std::mem::swap(&mut min_start, &mut max_start); - } - - let prev_start = *self.draw_memory.current_startline.borrow(); - let display_start = prev_start.clamp(min_start, max_start); - *self.draw_memory.current_startline.borrow_mut() = display_start; - - let max_pc = self.debug_steps().iter().map(|step| step.pc).max().unwrap_or(0); + let debug_steps = self.debug_steps(); + let max_pc = debug_steps.iter().map(|step| step.pc).max().unwrap_or(0); let max_pc_len = hex_digits(max_pc); - let debug_steps = self.debug_steps(); - let mut lines = Vec::new(); - let mut add_new_line = |line_number: usize| { - let mut line = String::with_capacity(64); - - let is_current_step = line_number == self.current_step; - if line_number < self.debug_steps().len() { - let step = &debug_steps[line_number]; - write!(line, "{:0>max_pc_len$x}|", step.pc).unwrap(); - line.push_str(if is_current_step { "▶" } else { " " }); - if let Some(op) = self.opcode_list.get(line_number) { - line.push_str(op); + let items = debug_steps + .iter() + .enumerate() + .map(|(i, step)| { + let mut content = String::with_capacity(64); + write!(content, "{:0>max_pc_len$x}|", step.pc).unwrap(); + if let Some(op) = self.opcode_list.get(i) { + content.push_str(op); } - } else { - line.push_str("END CALL"); - } - - let bg_color = if is_current_step { Color::DarkGray } else { Color::Reset }; - let style = Style::new().fg(Color::White).bg(bg_color); - lines.push(Line::from(Span::styled(line, style))); - }; - - for number in display_start..self.opcode_list.len() { - add_new_line(number); - } - - // Add one more "phantom" line so we see line where current segment execution ends - add_new_line(self.opcode_list.len()); + ListItem::new(Span::styled(content, Style::new().fg(Color::White))) + }) + .collect::>(); let title = format!( "Address: {} | PC: {} | Gas used in call: {}", @@ -445,8 +401,13 @@ impl DebuggerContext<'_> { self.current_step().total_gas_used, ); let block = Block::default().title(title).borders(Borders::ALL); - let paragraph = Paragraph::new(lines).block(block).wrap(Wrap { trim: true }); - f.render_widget(paragraph, area); + let list = List::new(items) + .block(block) + .highlight_symbol("▶") + .highlight_style(Style::new().fg(Color::White).bg(Color::DarkGray)) + .scroll_padding(1); + let mut state = ListState::default().with_selected(Some(self.current_step)); + f.render_stateful_widget(list, area, &mut state); } fn draw_stack(&self, f: &mut Frame<'_>, area: Rect) { diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 16964e7688b61..1fac3d051de2e 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -115,16 +115,13 @@ impl Debugger { .spawn(move || Self::event_listener(tx)) .expect("failed to spawn thread"); - // Draw the initial state. - cx.draw(terminal)?; - // Start the event loop. loop { + cx.draw(terminal)?; match cx.handle_event(rx.recv()?) { ControlFlow::Continue(()) => {} ControlFlow::Break(reason) => return Ok(reason), } - cx.draw(terminal)?; } } From 8466c09c2402030f6d7e73d8490d3987bec847c6 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 16 Apr 2024 22:01:27 +0400 Subject: [PATCH 0857/1963] feat: coverage for modifiers (#7669) --- crates/evm/coverage/src/analysis.rs | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index fad5b65768d27..040da5a0f4fa9 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -33,8 +33,14 @@ impl<'a> ContractVisitor<'a> { pub fn visit(mut self, contract_ast: Node) -> eyre::Result { // Find all functions and walk their AST for node in contract_ast.nodes { - if node.node_type == NodeType::FunctionDefinition { - self.visit_function_definition(node.clone())?; + match &node.node_type { + NodeType::FunctionDefinition => { + self.visit_function_definition(node)?; + } + NodeType::ModifierDefinition => { + self.visit_modifier_definition(node)?; + } + _ => {} } } @@ -65,6 +71,23 @@ impl<'a> ContractVisitor<'a> { } } + fn visit_modifier_definition(&mut self, mut node: Node) -> eyre::Result<()> { + let name: String = + node.attribute("name").ok_or_else(|| eyre::eyre!("Modifier has no name"))?; + + match node.body.take() { + Some(body) => { + self.push_item(CoverageItem { + kind: CoverageItemKind::Function { name }, + loc: self.source_location_for(&node.src), + hits: 0, + }); + self.visit_block(*body) + } + _ => Ok(()), + } + } + fn visit_block(&mut self, node: Node) -> eyre::Result<()> { let statements: Vec = node.attribute("statements").unwrap_or_default(); @@ -90,7 +113,6 @@ impl<'a> ContractVisitor<'a> { NodeType::Break | NodeType::Continue | NodeType::EmitStatement | - NodeType::PlaceholderStatement | NodeType::RevertStatement | NodeType::YulAssignment | NodeType::YulBreak | @@ -104,6 +126,9 @@ impl<'a> ContractVisitor<'a> { Ok(()) } + // Skip placeholder statements as they are never referenced in source maps. + NodeType::PlaceholderStatement => Ok(()), + // Return with eventual subcall NodeType::Return => { self.push_item(CoverageItem { @@ -338,12 +363,13 @@ impl<'a> ContractVisitor<'a> { NodeType::ForStatement | NodeType::IfStatement | NodeType::InlineAssembly | - NodeType::PlaceholderStatement | NodeType::Return | NodeType::RevertStatement | NodeType::TryStatement | NodeType::VariableDeclarationStatement | NodeType::WhileStatement => self.visit_statement(node), + // Skip placeholder statements as they are never referenced in source maps. + NodeType::PlaceholderStatement => Ok(()), _ => { warn!("unexpected node type, expected block or statement: {:?}", node.node_type); Ok(()) From 24536cd778ddaa39a50d765f411b2b7668b6d3cb Mon Sep 17 00:00:00 2001 From: clabby Date: Tue, 16 Apr 2024 14:53:43 -0400 Subject: [PATCH 0858/1963] fix(cheatcodes): `expectSafeMemory` + `stopExpectSafeMemory` (#7686) * fix(cheatcodes): `expectSafeMemory` w/ new `forge-std` Fixes the `stopExpectSafeMemory` by allowing for the memory allocation of the `stopExpectSafeMemory` selector as well as the potentially out-of-bounds read performed in the `CALL` operation. Currently, forge reports incorrectly that memory safety was violated in a memory safe region of a test, if the free memory pointer was updated to `[exclusiveUpperBound-31, exclusiveUpperBound]`. To fix this, we allow for `MSTORE` operations that store the selector bytes for `stopExpectSafeMemory` outside of the allowed region, as well as `CALL` operations that are to the cheatcode address and contain the `stopExpectSafeMemory` selector in the first 4 bytes of the call arguments. * use `SELECTOR_LEN` const --- crates/cheatcodes/src/inspector.rs | 57 ++++++++++++++++++++++--- testdata/default/cheats/MemSafety.t.sol | 18 ++++++++ 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 34a3d92607b15..ed6aa5cf4fccf 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -12,14 +12,15 @@ use crate::{ self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, ExpectedRevert, ExpectedRevertKind, }, - CheatsConfig, CheatsCtxt, Error, Result, Vm, + CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, Vm, Vm::AccountAccess, }; use alloy_primitives::{Address, Bytes, Log, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolInterface, SolValue}; -use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl}; +use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, SELECTOR_LEN}; use foundry_evm_core::{ + abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS}, }; @@ -601,6 +602,16 @@ impl Inspector for Cheatcodes { if !ranges.iter().any(|range| { range.contains(&offset) && range.contains(&(offset + 31)) }) { + // SPECIAL CASE: When the compiler attempts to store the selector for + // `stopExpectSafeMemory`, this is allowed. It will do so at the current free memory + // pointer, which could have been updated to the exclusive upper bound during + // execution. + let value = try_or_continue!(interpreter.stack().peek(1)).to_be_bytes::<32>(); + let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; + if value[0..SELECTOR_LEN] == selector { + return + } + disallowed_mem_write(offset, 32, interpreter, ranges); return } @@ -640,11 +651,48 @@ impl Inspector for Cheatcodes { // OPERATIONS WITH OFFSET AND SIZE ON STACK // //////////////////////////////////////////////////////////////// + opcode::CALL => { + // The destination offset of the operation is the fifth element on the stack. + let dest_offset = try_or_continue!(interpreter.stack().peek(5)).saturating_to::(); + + // The size of the data that will be copied is the sixth element on the stack. + let size = try_or_continue!(interpreter.stack().peek(6)).saturating_to::(); + + // If none of the allowed ranges contain [dest_offset, dest_offset + size), + // memory outside of the expected ranges has been touched. If the opcode + // only reads from memory, this is okay as long as the memory is not expanded. + let fail_cond = !ranges.iter().any(|range| { + range.contains(&dest_offset) && + range.contains(&(dest_offset + size.saturating_sub(1))) + }); + + // If the failure condition is met, set the output buffer to a revert string + // that gives information about the allowed ranges and revert. + if fail_cond { + // SPECIAL CASE: When a call to `stopExpectSafeMemory` is performed, this is allowed. + // It allocated calldata at the current free memory pointer, and will attempt to read + // from this memory region to perform the call. + let to = Address::from_word(try_or_continue!(interpreter.stack().peek(1)).to_be_bytes::<32>().into()); + if to == CHEATCODE_ADDRESS { + let args_offset = try_or_continue!(interpreter.stack().peek(3)).saturating_to::(); + let args_size = try_or_continue!(interpreter.stack().peek(4)).saturating_to::(); + let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; + let memory_word = interpreter.shared_memory.slice(args_offset, args_size); + if memory_word[0..SELECTOR_LEN] == selector { + return + } + } + + disallowed_mem_write(dest_offset, size, interpreter, ranges); + return + } + } + $(opcode::$opcode => { - // The destination offset of the operation is at the top of the stack. + // The destination offset of the operation. let dest_offset = try_or_continue!(interpreter.stack().peek($offset_depth)).saturating_to::(); - // The size of the data that will be copied is the third item on the stack. + // The size of the data that will be copied. let size = try_or_continue!(interpreter.stack().peek($size_depth)).saturating_to::(); // If none of the allowed ranges contain [dest_offset, dest_offset + size), @@ -678,7 +726,6 @@ impl Inspector for Cheatcodes { (CODECOPY, 0, 2, true), (RETURNDATACOPY, 0, 2, true), (EXTCODECOPY, 1, 3, true), - (CALL, 5, 6, true), (CALLCODE, 5, 6, true), (STATICCALL, 4, 5, true), (DELEGATECALL, 4, 5, true), diff --git a/testdata/default/cheats/MemSafety.t.sol b/testdata/default/cheats/MemSafety.t.sol index 05444e39a1547..096d8ac471823 100644 --- a/testdata/default/cheats/MemSafety.t.sol +++ b/testdata/default/cheats/MemSafety.t.sol @@ -738,6 +738,24 @@ contract MemSafetyTest is DSTest { vm.stopExpectSafeMemory(); } + /// @dev Tests that the `stopExpectSafeMemory` cheatcode can still be called if the free memory pointer was + /// updated to the exclusive upper boundary during execution. + function testStopExpectSafeMemory_freeMemUpdate() public { + uint64 initPtr; + assembly { + initPtr := mload(0x40) + } + + vm.expectSafeMemory(initPtr, initPtr + 0x20); + assembly { + // write outside of allowed range, this should revert + mstore(initPtr, 0x01) + mstore(0x40, add(initPtr, 0x20)) + } + + vm.stopExpectSafeMemory(); + } + //////////////////////////////////////////////////////////////// // HELPERS // //////////////////////////////////////////////////////////////// From 8513f619ca6781fe62d59b1bf2a8bb1bbab19927 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 16 Apr 2024 21:29:09 +0200 Subject: [PATCH 0859/1963] fix: hotfix cast logs subscribe (#7688) * fix: hotfix cast logs subscribe * fix features --- Cargo.lock | 9 +++++++++ crates/anvil/Cargo.toml | 2 +- crates/cast/Cargo.toml | 2 +- crates/cast/bin/cmd/logs.rs | 9 +++++++++ crates/forge/Cargo.toml | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e550e31f824aa..748783a370db2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -235,6 +235,9 @@ dependencies = [ "alloy-rpc-types", "alloy-rpc-types-trace", "alloy-transport", + "alloy-transport-http", + "alloy-transport-ipc", + "alloy-transport-ws", "async-stream", "async-trait", "auto_impl", @@ -242,9 +245,11 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", + "reqwest 0.12.3", "serde_json", "tokio", "tracing", + "url", ] [[package]] @@ -297,14 +302,18 @@ dependencies = [ "alloy-pubsub", "alloy-transport", "alloy-transport-http", + "alloy-transport-ipc", + "alloy-transport-ws", "futures", "pin-project", + "reqwest 0.12.3", "serde", "serde_json", "tokio", "tokio-stream", "tower", "tracing", + "url", ] [[package]] diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 76611fc804db3..cdf7c2f9b1882 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -47,7 +47,7 @@ alloy-sol-types = { workspace = true, features = ["std"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-rpc-types.workspace = true alloy-rpc-types-trace.workspace = true -alloy-provider = { workspace = true, features = ["pubsub"] } +alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 6b6dbae5197c3..04160fa3ffeb3 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -34,7 +34,7 @@ alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-rlp.workspace = true -alloy-provider = { workspace = true, features = ["pubsub"] } +alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } alloy-transport.workspace = true alloy-rpc-types.workspace = true alloy-json-rpc.workspace = true diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index e97521fe92df4..dd66176e8edc3 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -1,5 +1,6 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, Specifier}; use alloy_json_abi::Event; +use alloy_network::AnyNetwork; use alloy_primitives::{Address, B256}; use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, FilterBlockOption, FilterSet, Topic}; use cast::Cast; @@ -93,6 +94,14 @@ impl LogsArgs { return Ok(()) } + // FIXME: this is a hotfix for + // currently the alloy `eth_subscribe` impl does not work with all transports, so we use + // the builtin transport here for now + let url = config.get_rpc_url_or_localhost_http()?; + let provider = alloy_provider::ProviderBuilder::<_, _, AnyNetwork>::default() + .on_builtin(url.as_ref()) + .await?; + let cast = Cast::new(&provider); let mut stdout = io::stdout(); cast.subscribe(filter, &mut stdout, json).await?; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index b7508ae4b27a9..039b956cc37b3 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -51,7 +51,7 @@ alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde"] } alloy-rpc-types.workspace = true -alloy-provider.workspace = true +alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } alloy-network.workspace = true alloy-transport.workspace = true alloy-signer.workspace = true From 424a95e36e53a340b5f6def7ae5a52df846d861e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 16 Apr 2024 22:33:58 +0200 Subject: [PATCH 0860/1963] feat: add alias for personal_sign (#7687) --- crates/anvil/core/src/eth/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index a8a07ba928d5e..4c485f56be07d 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -139,7 +139,7 @@ pub enum EthRequest { EthGetProof(Address, Vec, Option), /// The sign method calculates an Ethereum specific signature with: - #[cfg_attr(feature = "serde", serde(rename = "eth_sign"))] + #[cfg_attr(feature = "serde", serde(rename = "eth_sign", alias = "personal_sign"))] EthSign(Address, Bytes), #[cfg_attr(feature = "serde", serde(rename = "eth_signTransaction"))] @@ -1518,6 +1518,18 @@ true}]}"#; let _req = serde_json::from_value::(value).unwrap(); } + #[test] + fn test_eth_sign() { + let s = r#"{"method": "eth_sign", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", "0x00"]}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + let s = r#"{"method": "personal_sign", "params": +["0xd84de507f3fada7df80908082d3239466db55a71", "0x00"]}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + } + #[test] fn test_eth_sign_typed_data() { let s = r#"{"method":"eth_signTypedData_v4","params":["0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", {"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":1,"verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","wallet":"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},"contents":"Hello, Bob!"}}]}"#; From 9079fb66e9483e8af6d3eff6d69e4b036d7c9691 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 16 Apr 2024 22:34:05 +0200 Subject: [PATCH 0861/1963] fix: always set optimizer details (#7690) --- crates/config/src/lib.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 51769ab314a08..39408326eeef1 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1028,11 +1028,18 @@ impl Config { } /// Returns the `Optimizer` based on the configured settings + /// + /// Note: optimizer details can be set independently of `enabled` + /// See also: + /// and pub fn optimizer(&self) -> Optimizer { - // only configure optimizer settings if optimizer is enabled - let details = if self.optimizer { self.optimizer_details.clone() } else { None }; - - Optimizer { enabled: Some(self.optimizer), runs: Some(self.optimizer_runs), details } + Optimizer { + enabled: Some(self.optimizer), + runs: Some(self.optimizer_runs), + // we always set the details because `enabled` is effectively a specific details profile + // that can still be modified + details: self.optimizer_details.clone(), + } } /// returns the [`foundry_compilers::ConfigurableArtifacts`] for this config, that includes the From e4ab9f460e92586fc4d4f6c9e00d8cda0c2dabf0 Mon Sep 17 00:00:00 2001 From: Matt Solomon Date: Tue, 16 Apr 2024 16:59:23 -0700 Subject: [PATCH 0862/1963] build(foundryup): allow caller to override rust flags (#7691) --- foundryup/foundryup | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 8143c3e23ac91..f1e40b648f477 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -8,7 +8,7 @@ FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1" BINS=(forge cast anvil chisel) -export RUSTFLAGS="-C target-cpu=native" +export RUSTFLAGS="${RUSTFLAGS:--C target-cpu=native}" main() { need_cmd git @@ -292,21 +292,21 @@ download() { fi } -# Banner Function for Foundry +# Banner Function for Foundry banner() { printf ' .xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx - + ╔═╗ ╔═╗ ╦ ╦ ╔╗╔ ╔╦╗ ╦═╗ ╦ ╦ Portable and modular toolkit - ╠╣ ║ ║ ║ ║ ║║║ ║║ ╠╦╝ ╚╦╝ for Ethereum Application Development + ╠╣ ║ ║ ║ ║ ║║║ ║║ ╠╦╝ ╚╦╝ for Ethereum Application Development ╚ ╚═╝ ╚═╝ ╝╚╝ ═╩╝ ╩╚═ ╩ written in Rust. .xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx Repo : https://github.com/foundry-rs/ -Book : https://book.getfoundry.sh/ -Chat : https://t.me/foundry_rs/ +Book : https://book.getfoundry.sh/ +Chat : https://t.me/foundry_rs/ Support : https://t.me/foundry_support/ Contribute : https://github.com/orgs/foundry-rs/projects/2/ From 46abc420efd68d289ed809bc53fb41159f3b13e9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 17 Apr 2024 12:41:47 +0300 Subject: [PATCH 0863/1963] chore(cheatcodes): solc 0.6.2 compatibility (#7694) --- crates/cheatcodes/assets/cheatcodes.json | 4 ++-- crates/cheatcodes/spec/src/vm.rs | 4 ++-- testdata/cheats/Vm.sol | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index c8b5d3d2affe6..1f25182261e53 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4915,7 +4915,7 @@ "func": { "id": "indexOf", "description": "Returns the index of the first occurrence of a `key` in an `input` string.\nReturns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.\nReturns 0 in case of an empty `key`.", - "declaration": "function indexOf(string memory input, string memory key) external pure returns (uint256);", + "declaration": "function indexOf(string calldata input, string calldata key) external pure returns (uint256);", "visibility": "external", "mutability": "pure", "signature": "indexOf(string,string)", @@ -4935,7 +4935,7 @@ "func": { "id": "isContext", "description": "Returns true if `forge` command was executed in given context.", - "declaration": "function isContext(ForgeContext context) external view returns (bool isContext);", + "declaration": "function isContext(ForgeContext context) external view returns (bool result);", "visibility": "external", "mutability": "view", "signature": "isContext(uint8)", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 03a2cd090b856..01d1290a68c08 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1642,7 +1642,7 @@ interface Vm { /// Returns true if `forge` command was executed in given context. #[cheatcode(group = Environment)] - function isContext(ForgeContext context) external view returns (bool isContext); + function isContext(ForgeContext context) external view returns (bool result); // ======== Scripts ======== @@ -1751,7 +1751,7 @@ interface Vm { /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found. /// Returns 0 in case of an empty `key`. #[cheatcode(group = String)] - function indexOf(string memory input, string memory key) external pure returns (uint256); + function indexOf(string calldata input, string calldata key) external pure returns (uint256); // ======== JSON Parsing and Manipulation ======== diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 44f0d52ac423f..65c65784399b3 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -241,8 +241,8 @@ interface Vm { function getNonce(address account) external view returns (uint64 nonce); function getNonce(Wallet calldata wallet) external returns (uint64 nonce); function getRecordedLogs() external returns (Log[] memory logs); - function indexOf(string memory input, string memory key) external pure returns (uint256); - function isContext(ForgeContext context) external view returns (bool isContext); + function indexOf(string calldata input, string calldata key) external pure returns (uint256); + function isContext(ForgeContext context) external view returns (bool result); function isDir(string calldata path) external returns (bool result); function isFile(string calldata path) external returns (bool result); function isPersistent(address account) external view returns (bool persistent); From 0a4d246261bc51e3f9c4f0b0c90938f3d3c659bf Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 17 Apr 2024 18:36:15 +0400 Subject: [PATCH 0864/1963] feat: optimize compilation by reading AST (#7599) * feat: optimize compiler runs by reading AST * clippy * fallback to solc * fmt * clippy * update fixtures * fix for windows * wip * bump compilers * clippy + fmt * fix --- Cargo.lock | 4 +- Cargo.toml | 2 +- crates/cli/src/utils/cmd.rs | 24 ++++++----- crates/common/src/compile.rs | 23 ++-------- crates/config/src/lib.rs | 1 + crates/forge/bin/cmd/create.rs | 22 ++++++---- crates/forge/bin/cmd/flatten.rs | 4 +- crates/forge/bin/cmd/selectors.rs | 9 +++- .../can_create_template_contract.stdout | 2 +- .../fixtures/can_create_using_unlocked.stdout | 2 +- .../can_create_with_constructor_args.stdout | 2 +- crates/script/src/build.rs | 43 +++---------------- 12 files changed, 53 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 748783a370db2..5095c7b0d7797 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3810,9 +3810,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1990477446ea72d80da26951cf7ba68652f9e5b481e3a469f09c4b120f647f" +checksum = "8caca67f174741b05c2f4188d3ee93420342130eb2a768abb9b885bb8b918df2" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 6c19cff94a411..622b2cf3f6349 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,7 +138,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.6", default-features = false } -foundry-compilers = { version = "0.3.14", default-features = false } +foundry-compilers = { version = "0.3.17", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index e58fd937d1360..475fae2ed2e43 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -5,7 +5,6 @@ use foundry_common::{cli_warn, fs, TestFunctionExt}; use foundry_compilers::{ artifacts::{CompactBytecode, CompactDeployedBytecode}, cache::{CacheEntry, SolFilesCache}, - info::ContractInfo, utils::read_json_file, Artifact, ProjectCompileOutput, }; @@ -20,7 +19,11 @@ use foundry_evm::{ render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, }; -use std::{fmt::Write, path::PathBuf, str::FromStr}; +use std::{ + fmt::Write, + path::{Path, PathBuf}, + str::FromStr, +}; use yansi::Paint; /// Given a `Project`'s output, removes the matching ABI, Bytecode and @@ -28,16 +31,17 @@ use yansi::Paint; #[track_caller] pub fn remove_contract( output: &mut ProjectCompileOutput, - info: &ContractInfo, + path: &Path, + name: &str, ) -> Result<(JsonAbi, CompactBytecode, CompactDeployedBytecode)> { - let contract = if let Some(contract) = output.remove_contract(info) { + let contract = if let Some(contract) = output.remove(path.to_string_lossy(), name) { contract } else { - let mut err = format!("could not find artifact: `{}`", info.name); + let mut err = format!("could not find artifact: `{}`", name); if let Some(suggestion) = - super::did_you_mean(&info.name, output.artifacts().map(|(name, _)| name)).pop() + super::did_you_mean(name, output.artifacts().map(|(name, _)| name)).pop() { - if suggestion != info.name { + if suggestion != name { err = format!( r#"{err} @@ -50,17 +54,17 @@ pub fn remove_contract( let abi = contract .get_abi() - .ok_or_else(|| eyre::eyre!("contract {} does not contain abi", info))? + .ok_or_else(|| eyre::eyre!("contract {} does not contain abi", name))? .into_owned(); let bin = contract .get_bytecode() - .ok_or_else(|| eyre::eyre!("contract {} does not contain bytecode", info))? + .ok_or_else(|| eyre::eyre!("contract {} does not contain bytecode", name))? .into_owned(); let runtime = contract .get_deployed_bytecode() - .ok_or_else(|| eyre::eyre!("contract {} does not contain deployed bytecode", info))? + .ok_or_else(|| eyre::eyre!("contract {} does not contain deployed bytecode", name))? .into_owned(); Ok((abi, bin, runtime)) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index baf73c992abdb..a498a61b34a73 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -8,8 +8,8 @@ use foundry_compilers::{ artifacts::{BytecodeObject, ContractBytecodeSome, Libraries}, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, - Artifact, ArtifactId, FileFilter, Graph, Project, ProjectCompileOutput, ProjectPathsConfig, - Solc, SolcConfig, + Artifact, ArtifactId, FileFilter, Project, ProjectCompileOutput, ProjectPathsConfig, Solc, + SolcConfig, }; use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; @@ -470,27 +470,12 @@ pub struct ContractInfo { /// If `verify` and it's a standalone script, throw error. Only allowed for projects. /// /// **Note:** this expects the `target_path` to be absolute -pub fn compile_target_with_filter( +pub fn compile_target( target_path: &Path, project: &Project, quiet: bool, - verify: bool, - skip: Vec, ) -> Result { - let graph = Graph::resolve(&project.paths)?; - - // Checking if it's a standalone script, or part of a project. - let mut compiler = ProjectCompiler::new().quiet(quiet); - if !skip.is_empty() { - compiler = compiler.filter(Box::new(SkipBuildFilters::new(skip)?)); - } - if !graph.files().contains_key(target_path) { - if verify { - eyre::bail!("You can only verify deployments from inside a project! Make sure it exists with `forge tree`."); - } - compiler = compiler.files([target_path.into()]); - } - compiler.compile(project) + ProjectCompiler::new().quiet(quiet).files([target_path.into()]).compile(project) } /// Compiles an Etherscan source from metadata by creating a project. diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 39408326eeef1..12a588d1ce0f1 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -4553,6 +4553,7 @@ mod tests { stack_allocation: None, optimizer_steps: Some("dhfoDgvulfnTUtnIf".to_string()), }), + simple_counter_for_loop_unchecked_increment: None, }), ..Default::default() }; diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index e42a17057bdba..2212c4e9861f4 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -15,9 +15,11 @@ use foundry_cli::{ utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; use foundry_common::{ - compile::ProjectCompiler, fmt::parse_tokens, provider::alloy::estimate_eip1559_fees, + compile::{self}, + fmt::parse_tokens, + provider::alloy::estimate_eip1559_fees, }; -use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalized}; +use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalize}; use serde_json::json; use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc}; @@ -84,15 +86,17 @@ impl CreateArgs { pub async fn run(mut self) -> Result<()> { // Find Project & Compile let project = self.opts.project()?; - let mut output = - ProjectCompiler::new().quiet_if(self.json || self.opts.silent).compile(&project)?; - if let Some(ref mut path) = self.contract.path { - // paths are absolute in the project's output - *path = canonicalized(project.root().join(&path)).to_string_lossy().to_string(); - } + let target_path = if let Some(ref mut path) = self.contract.path { + canonicalize(project.root().join(path))? + } else { + project.find_contract_path(&self.contract.name)? + }; + + let mut output = + compile::compile_target(&target_path, &project, self.json || self.opts.silent)?; - let (abi, bin, _) = remove_contract(&mut output, &self.contract)?; + let (abi, bin, _) = remove_contract(&mut output, &target_path, &self.contract.name)?; let bin = match bin.object { BytecodeObject::Bytecode(_) => bin.object, diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index c61369320c830..c1351d06d95a9 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -4,7 +4,7 @@ use foundry_cli::{ opts::{CoreBuildArgs, ProjectPathsArgs}, utils::LoadConfig, }; -use foundry_common::{compile::ProjectCompiler, fs}; +use foundry_common::{compile::compile_target, fs}; use foundry_compilers::{error::SolcError, flatten::Flattener}; use std::path::PathBuf; @@ -42,7 +42,7 @@ impl FlattenArgs { let project = config.ephemeral_no_artifacts_project()?; let target_path = dunce::canonicalize(target_path)?; - let compiler_output = ProjectCompiler::new().files([target_path.clone()]).compile(&project); + let compiler_output = compile_target(&target_path, &project, false); let flattened = match compiler_output { Ok(compiler_output) => { diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 1ee251082b376..8e07fb1f61caf 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -6,7 +6,7 @@ use foundry_cli::{ utils::FoundryPathExt, }; use foundry_common::{ - compile::ProjectCompiler, + compile::{compile_target, ProjectCompiler}, selectors::{import_selectors, SelectorImportData}, }; use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, info::ContractInfo}; @@ -71,7 +71,12 @@ impl SelectorsSubcommands { }; let project = build_args.project()?; - let output = ProjectCompiler::new().quiet(true).compile(&project)?; + let output = if let Some(name) = &contract { + let target_path = project.find_contract_path(name)?; + compile_target(&target_path, &project, false)? + } else { + ProjectCompiler::new().compile(&project)? + }; let artifacts = if all { output .into_artifacts_with_files() diff --git a/crates/forge/tests/fixtures/can_create_template_contract.stdout b/crates/forge/tests/fixtures/can_create_template_contract.stdout index adb787a44ee74..533c927275012 100644 --- a/crates/forge/tests/fixtures/can_create_template_contract.stdout +++ b/crates/forge/tests/fixtures/can_create_template_contract.stdout @@ -1,4 +1,4 @@ -Compiling 27 files with 0.8.23 +Compiling 1 files with 0.8.23 Solc 0.8.23 finished in 2.27s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout index 34a5fb9f7a7d3..1f8b60d6f40e1 100644 --- a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout +++ b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout @@ -1,4 +1,4 @@ -Compiling 27 files with 0.8.23 +Compiling 1 files with 0.8.23 Solc 0.8.23 finished in 1.95s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout index 0fb83d06fe3ff..299ad2f2d85f9 100644 --- a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout +++ b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout @@ -1,4 +1,4 @@ -Compiling 28 files with 0.8.23 +Compiling 1 files with 0.8.23 Solc 0.8.23 finished in 2.82s Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 4fb88719b13bc..ea00dc5920fff 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -8,17 +8,15 @@ use crate::{ use alloy_primitives::{Address, Bytes}; use alloy_provider::Provider; -use eyre::{Context, OptionExt, Result}; +use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; -use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::{ - compile::{self, ContractSources, ProjectCompiler}, + compile::{self, ContractSources}, provider::alloy::try_get_http_provider, ContractData, ContractsByArtifact, }; use foundry_compilers::{ artifacts::{BytecodeObject, Libraries}, - cache::SolFilesCache, info::ContractInfo, ArtifactId, ProjectCompileOutput, }; @@ -149,7 +147,6 @@ impl PreprocessedState { pub fn compile(self) -> Result { let Self { args, script_config, script_wallets } = self; let project = script_config.config.project()?; - let filters = args.skip.clone().unwrap_or_default(); let mut target_name = args.target_contract.clone(); @@ -157,46 +154,18 @@ impl PreprocessedState { // Otherwise, parse input as : and use the path from the contract info, if // present. let target_path = if let Ok(path) = dunce::canonicalize(&args.path) { - Some(path) + path } else { let contract = ContractInfo::from_str(&args.path)?; target_name = Some(contract.name.clone()); if let Some(path) = contract.path { - Some(dunce::canonicalize(path)?) + dunce::canonicalize(path)? } else { - None + project.find_contract_path(contract.name.as_str())? } }; - // If we've found target path above, only compile it. - // Otherwise, compile everything to match contract by name later. - let output = if let Some(target_path) = target_path.clone() { - compile::compile_target_with_filter( - &target_path, - &project, - args.opts.silent, - args.verify, - filters, - ) - } else if !project.paths.has_input_files() { - Err(eyre::eyre!("The project doesn't have any input files. Make sure the `script` directory is configured properly in foundry.toml. Otherwise, provide the path to the file.")) - } else { - ProjectCompiler::new().compile(&project) - }?; - - // If we still don't have target path, find it by name in the compilation cache. - let target_path = if let Some(target_path) = target_path { - target_path - } else { - let target_name = target_name.clone().expect("was set above"); - let cache = SolFilesCache::read_joined(&project.paths) - .wrap_err("Could not open compiler cache")?; - let (path, _) = get_cached_entry_by_name(&cache, &target_name) - .wrap_err("Could not find target contract in cache")?; - path - }; - - let target_path = project.root().join(target_path); + let output = compile::compile_target(&target_path, &project, args.opts.silent)?; let mut target_id: Option = None; From 19871fcde773659568a141f0755dc8658f117536 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 18 Apr 2024 00:34:45 +0400 Subject: [PATCH 0865/1963] fix: better artifacts management for `getCode` (#7685) * fix: better artifacts management * simplify * Update crates/common/src/contracts.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Arc --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/src/config.rs | 9 +- crates/cheatcodes/src/fs.rs | 74 ++++----- crates/common/src/contracts.rs | 21 +++ .../evm/evm/src/executors/invariant/error.rs | 2 +- .../evm/evm/src/executors/invariant/funcs.rs | 2 +- crates/evm/traces/src/lib.rs | 12 +- crates/forge/bin/cmd/coverage.rs | 55 +++--- crates/forge/bin/cmd/test/mod.rs | 76 ++++----- crates/forge/src/multi_runner.rs | 157 ++++++++---------- crates/forge/src/result.rs | 15 +- crates/forge/src/runner.rs | 24 ++- crates/forge/tests/it/repros.rs | 28 ++-- crates/forge/tests/it/test_helpers.rs | 24 ++- crates/script/src/build.rs | 29 +--- crates/script/src/execute.rs | 2 +- crates/script/src/lib.rs | 12 +- 16 files changed, 258 insertions(+), 284 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index f93ab4f5867cd..a2b9a5f5b091f 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -1,8 +1,8 @@ use super::Result; use crate::{script::ScriptWallets, Vm::Rpc}; use alloy_primitives::Address; -use foundry_common::fs::normalize_path; -use foundry_compilers::{utils::canonicalize, ArtifactId, ProjectPathsConfig}; +use foundry_common::{fs::normalize_path, ContractsByArtifact}; +use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, ResolvedRpcEndpoints, @@ -12,6 +12,7 @@ use semver::Version; use std::{ collections::HashMap, path::{Path, PathBuf}, + sync::Arc, time::Duration, }; @@ -47,7 +48,7 @@ pub struct CheatsConfig { /// Artifacts which are guaranteed to be fresh (either recompiled or cached). /// If Some, `vm.getDeployedCode` invocations are validated to be in scope of this list. /// If None, no validation is performed. - pub available_artifacts: Option>, + pub available_artifacts: Option>, /// Version of the script/test contract which is currently running. pub running_version: Option, } @@ -57,7 +58,7 @@ impl CheatsConfig { pub fn new( config: &Config, evm_opts: EvmOpts, - available_artifacts: Option>, + available_artifacts: Option>, script_wallets: Option, running_version: Option, ) -> Self { diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 9b22c4d8d2ae5..cecfc88221779 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -4,7 +4,7 @@ use super::string::parse; use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::DynSolType; use alloy_json_abi::ContractObject; -use alloy_primitives::U256; +use alloy_primitives::{Bytes, U256}; use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; use foundry_common::fs; @@ -251,24 +251,14 @@ impl Cheatcode for writeLineCall { impl Cheatcode for getCodeCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { artifactPath: path } = self; - let object = read_bytecode(state, path)?; - if let Some(bin) = object.bytecode { - Ok(bin.abi_encode()) - } else { - Err(fmt_err!("No bytecode for contract. Is it abstract or unlinked?")) - } + Ok(get_artifact_code(state, path, false)?.abi_encode()) } } impl Cheatcode for getDeployedCodeCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { artifactPath: path } = self; - let object = read_bytecode(state, path)?; - if let Some(bin) = object.deployed_bytecode { - Ok(bin.abi_encode()) - } else { - Err(fmt_err!("No deployed bytecode for contract. Is it abstract or unlinked?")) - } + Ok(get_artifact_code(state, path, true)?.abi_encode()) } } @@ -282,9 +272,9 @@ impl Cheatcode for getDeployedCodeCall { /// - `path/to/contract.sol:0.8.23` /// - `ContractName` /// - `ContractName:0.8.23` -fn get_artifact_path(state: &Cheatcodes, path: &str) -> Result { - if path.ends_with(".json") { - Ok(PathBuf::from(path)) +fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result { + let path = if path.ends_with(".json") { + PathBuf::from(path) } else { let mut parts = path.split(':'); @@ -314,11 +304,11 @@ fn get_artifact_path(state: &Cheatcodes, path: &str) -> Result { None }; - // Use available artifacts list if available - if let Some(available_ids) = &state.config.available_artifacts { - let filtered = available_ids + // Use available artifacts list if present + if let Some(artifacts) = &state.config.available_artifacts { + let filtered = artifacts .iter() - .filter(|id| { + .filter(|(id, _)| { // name might be in the form of "Counter.0.8.23" let id_name = id.name.split('.').next().unwrap(); @@ -356,7 +346,7 @@ fn get_artifact_path(state: &Cheatcodes, path: &str) -> Result { .and_then(|version| { let filtered = filtered .into_iter() - .filter(|id| id.version == *version) + .filter(|(id, _)| id.version == *version) .collect::>(); (filtered.len() == 1).then_some(filtered[0]) @@ -365,31 +355,33 @@ fn get_artifact_path(state: &Cheatcodes, path: &str) -> Result { } }?; - Ok(artifact.path.clone()) + if deployed { + return Ok(artifact.1.deployed_bytecode.clone()) + } else { + return Ok(artifact.1.bytecode.clone()) + } } else { - let path_in_artifacts = - match (file.map(|f| f.to_string_lossy().to_string()), contract_name) { - (Some(file), Some(contract_name)) => Ok(format!("{file}/{contract_name}.json")), - (None, Some(contract_name)) => { - Ok(format!("{contract_name}.sol/{contract_name}.json")) - } - (Some(file), None) => { - let name = file.replace(".sol", ""); - Ok(format!("{file}/{name}.json")) - } - _ => Err(fmt_err!("Invalid artifact path")), - }?; - Ok(state.config.paths.artifacts.join(path_in_artifacts)) + match (file.map(|f| f.to_string_lossy().to_string()), contract_name) { + (Some(file), Some(contract_name)) => { + PathBuf::from(format!("{file}/{contract_name}.json")) + } + (None, Some(contract_name)) => { + PathBuf::from(format!("{contract_name}.sol/{contract_name}.json")) + } + (Some(file), None) => { + let name = file.replace(".sol", ""); + PathBuf::from(format!("{file}/{name}.json")) + } + _ => return Err(fmt_err!("Invalid artifact path")), + } } - } -} + }; -/// Reads the bytecode object(s) from the matching artifact -fn read_bytecode(state: &Cheatcodes, path: &str) -> Result { - let path = get_artifact_path(state, path)?; let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?; let data = fs::read_to_string(path)?; - serde_json::from_str::(&data).map_err(Into::into) + let artifact = serde_json::from_str::(&data)?; + let maybe_bytecode = if deployed { artifact.deployed_bytecode } else { artifact.bytecode }; + maybe_bytecode.ok_or_else(|| fmt_err!("No bytecode for contract. Is it abstract or unlinked?")) } impl Cheatcode for ffiCall { diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index d400e0a0824e8..561d7229b5281 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -32,6 +32,27 @@ type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a ContractData); pub struct ContractsByArtifact(pub BTreeMap); impl ContractsByArtifact { + /// Creates a new instance by collecting all artifacts with present bytecode from an iterator. + /// + /// It is recommended to use this method with an output of + /// [foundry_linking::Linker::get_linked_artifacts]. + pub fn new(artifacts: impl IntoIterator) -> Self { + Self( + artifacts + .into_iter() + .filter_map(|(id, artifact)| { + let name = id.name.clone(); + let bytecode = artifact.bytecode.and_then(|b| b.into_bytes())?; + let deployed_bytecode = + artifact.deployed_bytecode.and_then(|b| b.into_bytes())?; + let abi = artifact.abi?; + + Some((id, ContractData { name, abi, bytecode, deployed_bytecode })) + }) + .collect(), + ) + } + /// Finds a contract which has a similar bytecode as `code`. pub fn find_by_creation_code(&self, code: &[u8]) -> Option { self.iter() diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 0695ad6c4effe..ae122d0fa7be8 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -149,7 +149,7 @@ impl FailedInvariantCaseData { pub fn replay( &self, mut executor: Executor, - known_contracts: Option<&ContractsByArtifact>, + known_contracts: &ContractsByArtifact, mut ided_contracts: ContractsByAddress, logs: &mut Vec, traces: &mut Traces, diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index daa326b0c9f63..b3a913fb3e65f 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -71,7 +71,7 @@ pub fn assert_invariants( pub fn replay_run( invariant_contract: &InvariantContract<'_>, mut executor: Executor, - known_contracts: Option<&ContractsByArtifact>, + known_contracts: &ContractsByArtifact, mut ided_contracts: ContractsByAddress, logs: &mut Vec, traces: &mut Traces, diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 81f13f95a230e..a52fd3b42eaaf 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -12,7 +12,7 @@ use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CHEATCODE_ADDRESS; use futures::{future::BoxFuture, FutureExt}; use serde::{Deserialize, Serialize}; -use std::{collections::BTreeMap, fmt::Write}; +use std::fmt::Write; use yansi::{Color, Paint}; /// Call trace address identifiers. @@ -293,12 +293,8 @@ fn trace_color(trace: &CallTrace) -> Color { } /// Given a list of traces and artifacts, it returns a map connecting address to abi -pub fn load_contracts( - traces: Traces, - known_contracts: Option<&ContractsByArtifact>, -) -> ContractsByAddress { - let Some(contracts) = known_contracts else { return BTreeMap::new() }; - let mut local_identifier = LocalTraceIdentifier::new(contracts); +pub fn load_contracts(traces: Traces, known_contracts: &ContractsByArtifact) -> ContractsByAddress { + let mut local_identifier = LocalTraceIdentifier::new(known_contracts); let mut decoder = CallTraceDecoderBuilder::new().build(); for (_, trace) in &traces { decoder.identify(trace, &mut local_identifier); @@ -308,7 +304,7 @@ pub fn load_contracts( .contracts .iter() .filter_map(|(addr, name)| { - if let Ok(Some((_, contract))) = contracts.find_by_name_or_identifier(name) { + if let Ok(Some((_, contract))) = known_contracts.find_by_name_or_identifier(name) { return Some((*addr, (name.clone(), contract.abi.clone()))); } None diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index bbd99de331e2f..fc919934f0378 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -7,7 +7,6 @@ use forge::{ analysis::SourceAnalyzer, anchors::find_anchors, BytecodeReporter, ContractId, CoverageReport, CoverageReporter, DebugReporter, LcovReporter, SummaryReporter, }, - inspectors::CheatsConfig, opts::EvmOpts, result::SuiteResult, revm::primitives::SpecId, @@ -28,7 +27,11 @@ use foundry_compilers::{ use foundry_config::{Config, SolcReq}; use rustc_hash::FxHashMap; use semver::Version; -use std::{collections::HashMap, path::PathBuf, sync::mpsc::channel}; +use std::{ + collections::HashMap, + path::PathBuf, + sync::{mpsc::channel, Arc}, +}; use yansi::Paint; /// A map, keyed by contract ID, to a tuple of the deployment source map and the runtime source map. @@ -101,7 +104,7 @@ impl CoverageArgs { let report = self.prepare(&config, output.clone())?; p_println!(!self.opts.silent => "Running tests..."); - self.collect(project, output, report, config, evm_opts).await + self.collect(project, output, report, Arc::new(config), evm_opts).await } /// Builds the project. @@ -308,29 +311,20 @@ impl CoverageArgs { project: Project, output: ProjectCompileOutput, mut report: CoverageReport, - config: Config, + config: Arc, evm_opts: EvmOpts, ) -> Result<()> { let root = project.paths.root; - let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); - // Build the contract runner let env = evm_opts.evm_env().await?; - let mut runner = MultiContractRunnerBuilder::default() + let mut runner = MultiContractRunnerBuilder::new(config.clone()) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new( - &config, - evm_opts.clone(), - Some(artifact_ids), - None, - None, - )) .with_test_options(TestOptions { - fuzz: config.fuzz, + fuzz: config.fuzz.clone(), invariant: config.invariant, ..Default::default() }) @@ -338,31 +332,32 @@ impl CoverageArgs { .build(&root, output, env, evm_opts)?; // Run tests - let known_contracts = runner.known_contracts.clone(); let filter = self.filter; let (tx, rx) = channel::<(String, SuiteResult)>(); let handle = tokio::task::spawn_blocking(move || runner.test(&filter, tx)); // Add hit data to the coverage report - let data = rx - .into_iter() - .flat_map(|(_, suite)| suite.test_results.into_values()) - .filter_map(|mut result| result.coverage.take()) - .flat_map(|hit_maps| { - hit_maps.0.into_values().filter_map(|map| { + let data = rx.into_iter().flat_map(|(_, suite)| { + let mut hits = Vec::new(); + for (_, mut result) in suite.test_results { + let Some(hit_maps) = result.coverage.take() else { continue }; + + for map in hit_maps.0.into_values() { if let Some((id, _)) = - known_contracts.find_by_deployed_code(map.bytecode.as_ref()) + suite.known_contracts.find_by_deployed_code(map.bytecode.as_ref()) { - Some((id, map, true)) + hits.push((id.clone(), map, true)); } else if let Some((id, _)) = - known_contracts.find_by_creation_code(map.bytecode.as_ref()) + suite.known_contracts.find_by_creation_code(map.bytecode.as_ref()) { - Some((id, map, false)) - } else { - None + hits.push((id.clone(), map, false)); } - }) - }); + } + } + + hits + }); + for (artifact_id, hits, is_deployed_code) in data { // TODO: Note down failing tests if let Some(source_id) = report.get_source_id( diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 16f5ec5166339..4a120adc73555 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -5,7 +5,6 @@ use eyre::Result; use forge::{ decode::decode_console_logs, gas_report::GasReport, - inspectors::CheatsConfig, multi_runner::matches_contract, result::{SuiteResult, TestOutcome, TestStatus}, traces::{identifier::SignaturesIdentifier, CallTraceDecoderBuilder, TraceKind}, @@ -35,7 +34,7 @@ use regex::Regex; use std::{ collections::{BTreeMap, BTreeSet}, path::PathBuf, - sync::mpsc::channel, + sync::{mpsc::channel, Arc}, time::Instant, }; use watchexec::config::{InitConfig, RuntimeConfig}; @@ -274,21 +273,14 @@ impl TestArgs { // Clone the output only if we actually need it later for the debugger. let output_clone = should_debug.then(|| output.clone()); - let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); + let config = Arc::new(config); - let runner = MultiContractRunnerBuilder::default() + let runner = MultiContractRunnerBuilder::new(config.clone()) .set_debug(should_debug) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_cheats_config(CheatsConfig::new( - &config, - evm_opts.clone(), - Some(artifact_ids), - None, - None, // populated separately for each test contract - )) .with_test_options(test_options) .enable_isolation(evm_opts.isolate) .build(project_root, output, env, evm_opts)?; @@ -328,7 +320,7 @@ impl TestArgs { .debug_arenas(test_result.debug.as_slice()) .sources(sources) .breakpoints(test_result.breakpoints.clone()); - if let Some(decoder) = &outcome.decoder { + if let Some(decoder) = &outcome.last_run_decoder { builder = builder.decoder(decoder); } let mut debugger = builder.build(); @@ -342,7 +334,7 @@ impl TestArgs { pub async fn run_tests( &self, mut runner: MultiContractRunner, - config: Config, + config: Arc, verbosity: u8, filter: &ProjectPathsAwareFilter, ) -> eyre::Result { @@ -367,15 +359,7 @@ impl TestArgs { return Ok(TestOutcome::new(results, self.allow_failure)); } - // Set up trace identifiers. - let known_contracts = runner.known_contracts.clone(); let remote_chain_id = runner.evm_opts.get_remote_chain_id(); - let mut identifier = TraceIdentifiers::new().with_local(&known_contracts); - - // Avoid using etherscan for gas report as we decode more traces and this will be expensive. - if !self.gas_report { - identifier = identifier.with_etherscan(&config, remote_chain_id)?; - } // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); @@ -385,24 +369,9 @@ impl TestArgs { move || runner.test(&filter, tx) }); - let mut gas_report = - self.gas_report.then(|| GasReport::new(config.gas_reports, config.gas_reports_ignore)); - - // Build the trace decoder. - let mut builder = CallTraceDecoderBuilder::new() - .with_known_contracts(&known_contracts) - .with_verbosity(verbosity); - // Signatures are of no value for gas reports. - if !self.gas_report { - builder = builder.with_signature_identifier(SignaturesIdentifier::new( - Config::foundry_cache_dir(), - config.offline, - )?); - } - let mut decoder = builder.build(); - - // We identify addresses if we're going to print *any* trace or gas report. - let identify_addresses = verbosity >= 3 || self.gas_report || self.debug.is_some(); + let mut gas_report = self + .gas_report + .then(|| GasReport::new(config.gas_reports.clone(), config.gas_reports_ignore.clone())); let mut outcome = TestOutcome::empty(self.allow_failure); @@ -410,6 +379,32 @@ impl TestArgs { for (contract_name, suite_result) in rx { let tests = &suite_result.test_results; + // Set up trace identifiers. + let known_contracts = suite_result.known_contracts.clone(); + let mut identifier = TraceIdentifiers::new().with_local(&known_contracts); + + // Avoid using etherscan for gas report as we decode more traces and this will be + // expensive. + if !self.gas_report { + identifier = identifier.with_etherscan(&config, remote_chain_id)?; + } + + // Build the trace decoder. + let mut builder = CallTraceDecoderBuilder::new() + .with_known_contracts(&known_contracts) + .with_verbosity(verbosity); + // Signatures are of no value for gas reports. + if !self.gas_report { + builder = builder.with_signature_identifier(SignaturesIdentifier::new( + Config::foundry_cache_dir(), + config.offline, + )?); + } + let mut decoder = builder.build(); + + // We identify addresses if we're going to print *any* trace or gas report. + let identify_addresses = verbosity >= 3 || self.gas_report || self.debug.is_some(); + // Print suite header. println!(); for warning in suite_result.warnings.iter() { @@ -515,6 +510,7 @@ impl TestArgs { // Add the suite result to the outcome. outcome.results.insert(contract_name, suite_result); + outcome.last_run_decoder = Some(decoder); // Stop processing the remaining suites if any test failed and `fail_fast` is set. if self.fail_fast && any_test_failed { @@ -525,8 +521,6 @@ impl TestArgs { trace!(target: "forge::test", len=outcome.results.len(), %any_test_failed, "done with results"); - outcome.decoder = Some(decoder); - if let Some(gas_report) = gas_report { let finalized = gas_report.finalize(); shell::println(&finalized)?; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 8bfb1477b4e00..9fed56982a8b8 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -4,10 +4,9 @@ use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; -use foundry_common::{get_contract_name, ContractData, ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{ - artifacts::Libraries, contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput, -}; +use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; +use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput}; +use foundry_config::Config; use foundry_evm::{ backend::Backend, decode::RevertDecoder, executors::ExecutorBuilder, fork::CreateFork, inspectors::CheatsConfig, opts::EvmOpts, revm, @@ -16,6 +15,7 @@ use foundry_linking::{LinkOutput, Linker}; use rayon::prelude::*; use revm::primitives::SpecId; use std::{ + borrow::Borrow, collections::BTreeMap, fmt::Debug, path::Path, @@ -39,8 +39,6 @@ pub struct MultiContractRunner { /// Mapping of contract name to JsonAbi, creation bytecode and library bytecode which /// needs to be deployed & linked against pub contracts: DeployableContracts, - /// Compiled contracts by name that have an JsonAbi and runtime bytecode - pub known_contracts: ContractsByArtifact, /// The EVM instance used in the test runner pub evm_opts: EvmOpts, /// The configured evm @@ -51,12 +49,10 @@ pub struct MultiContractRunner { pub revert_decoder: RevertDecoder, /// The address which will be used as the `from` field in all EVM calls pub sender: Option
, - /// A map of contract names to absolute source file paths - pub source_paths: BTreeMap, /// The fork to use at launch pub fork: Option, - /// Additional cheatcode inspector related settings derived from the `Config` - pub cheats_config: Arc, + /// Project config. + pub config: Arc, /// Whether to collect coverage info pub coverage: bool, /// Whether to collect debug info @@ -65,6 +61,8 @@ pub struct MultiContractRunner { pub test_options: TestOptions, /// Whether to enable call isolation pub isolation: bool, + /// Output of the project compilation + pub output: ProjectCompileOutput, } impl MultiContractRunner { @@ -180,8 +178,18 @@ impl MultiContractRunner { let identifier = artifact_id.identifier(); let mut span_name = identifier.as_str(); - let mut cheats_config = self.cheats_config.as_ref().clone(); - cheats_config.running_version = Some(artifact_id.version.clone()); + let linker = + Linker::new(self.config.project_paths().root, self.output.artifact_ids().collect()); + let linked_contracts = linker.get_linked_artifacts(&contract.libraries).unwrap_or_default(); + let known_contracts = Arc::new(ContractsByArtifact::new(linked_contracts)); + + let cheats_config = CheatsConfig::new( + &self.config, + self.evm_opts.clone(), + Some(known_contracts.clone()), + None, + Some(artifact_id.version.clone()), + ); let executor = ExecutorBuilder::new() .inspectors(|stack| { @@ -212,7 +220,7 @@ impl MultiContractRunner { &self.revert_decoder, self.debug, ); - let r = runner.run_tests(filter, &self.test_options, Some(&self.known_contracts)); + let r = runner.run_tests(filter, &self.test_options, known_contracts); debug!(duration=?r.duration, "executed all tests in contract"); @@ -221,7 +229,7 @@ impl MultiContractRunner { } /// Builder used for instantiating the multi-contract runner -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] #[must_use = "builders do nothing unless you call `build` on them"] pub struct MultiContractRunnerBuilder { /// The address which will be used to deploy the initial contracts and send all @@ -233,8 +241,8 @@ pub struct MultiContractRunnerBuilder { pub evm_spec: Option, /// The fork to use at launch pub fork: Option, - /// Additional cheatcode inspector related settings derived from the `Config` - pub cheats_config: Option, + /// Project config. + pub config: Arc, /// Whether or not to collect coverage info pub coverage: bool, /// Whether or not to collect debug info @@ -246,6 +254,20 @@ pub struct MultiContractRunnerBuilder { } impl MultiContractRunnerBuilder { + pub fn new(config: Arc) -> Self { + Self { + config, + sender: Default::default(), + initial_balance: Default::default(), + evm_spec: Default::default(), + fork: Default::default(), + coverage: Default::default(), + debug: Default::default(), + isolation: Default::default(), + test_options: Default::default(), + } + } + pub fn sender(mut self, sender: Address) -> Self { self.sender = Some(sender); self @@ -266,11 +288,6 @@ impl MultiContractRunnerBuilder { self } - pub fn with_cheats_config(mut self, cheats_config: CheatsConfig) -> Self { - self.cheats_config = Some(cheats_config); - self - } - pub fn with_test_options(mut self, test_options: TestOptions) -> Self { self.test_options = Some(test_options); self @@ -300,107 +317,71 @@ impl MultiContractRunnerBuilder { env: revm::primitives::Env, evm_opts: EvmOpts, ) -> Result { - // This is just the contracts compiled, but we need to merge this with the read cached - // artifacts. - let contracts = output - .with_stripped_file_prefixes(root) - .into_artifacts() - .map(|(i, c)| (i, c.into_contract_bytecode())) - .collect::(); - - let source_paths = contracts - .iter() - .map(|(i, _)| (i.identifier(), root.join(&i.source).to_string_lossy().into())) - .collect::>(); + let output = output.with_stripped_file_prefixes(root); + let linker = Linker::new(root, output.artifact_ids().collect()); - let linker = Linker::new( - root, - contracts.iter().map(|(id, artifact)| (id.clone(), artifact)).collect(), - ); + // Build revert decoder from ABIs of all artifacts. + let abis = linker + .contracts + .iter() + .filter_map(|(_, contract)| contract.abi.as_ref().map(|abi| abi.borrow())); + let revert_decoder = RevertDecoder::new().with_abis(abis); // Create a mapping of name => (abi, deployment code, Vec) let mut deployable_contracts = DeployableContracts::default(); - let mut known_contracts = ContractsByArtifact::default(); - - for (id, contract) in contracts.iter() { + for (id, contract) in linker.contracts.iter() { let Some(abi) = contract.abi.as_ref() else { continue; }; - let name = id.name.clone(); - - let LinkOutput { libs_to_deploy, libraries } = - linker.link_with_nonce_or_address(Default::default(), evm_opts.sender, 1, id)?; - - let linked_contract = linker.link(id, &libraries)?; - - // get bytes if deployable, else add to known contracts and continue. - // interfaces and abstract contracts should be known to enable fuzzing of their ABI - // but they should not be deployable and their source code should be skipped by the - // debugger and linker. - let Some(bytecode) = linked_contract - .get_bytecode_bytes() - .map(|b| b.into_owned()) - .filter(|b| !b.is_empty()) - else { - known_contracts.insert( - id.clone(), - ContractData { - abi: abi.clone(), - bytecode: Bytes::new(), - deployed_bytecode: Bytes::new(), - name, - }, - ); - continue; - }; - - // if it's a test, add it to deployable contracts + // if it's a test, link it and add to deployable contracts if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && abi.functions().any(|func| func.name.is_test() || func.name.is_invariant_test()) { + let LinkOutput { libs_to_deploy, libraries } = linker.link_with_nonce_or_address( + Default::default(), + evm_opts.sender, + 1, + id, + )?; + + let linked_contract = linker.link(id, &libraries)?; + + let Some(bytecode) = linked_contract + .get_bytecode_bytes() + .map(|b| b.into_owned()) + .filter(|b| !b.is_empty()) + else { + continue; + }; + deployable_contracts.insert( id.clone(), TestContract { - abi: abi.clone(), - bytecode: bytecode.clone(), + abi: abi.clone().into_owned(), + bytecode, libs_to_deploy, libraries, }, ); } - - if let Some(bytes) = linked_contract.get_deployed_bytecode_bytes() { - known_contracts.insert( - id.clone(), - ContractData { - abi: abi.clone(), - bytecode, - deployed_bytecode: bytes.into_owned(), - name, - }, - ); - } } - let revert_decoder = - RevertDecoder::new().with_abis(known_contracts.values().map(|c| &c.abi)); Ok(MultiContractRunner { contracts: deployable_contracts, - known_contracts, evm_opts, env, evm_spec: self.evm_spec.unwrap_or(SpecId::MERGE), sender: self.sender, revert_decoder, - source_paths, fork: self.fork, - cheats_config: self.cheats_config.unwrap_or_default().into(), + config: self.config, coverage: self.coverage, debug: self.debug, test_options: self.test_options.unwrap_or_default(), isolation: self.isolation, + output, }) } } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index a50e59b9515ab..09c3661dc7194 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,7 +1,9 @@ //! Test outcomes. use alloy_primitives::{Address, Log}; -use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; +use foundry_common::{ + evm::Breakpoints, get_contract_name, get_file_name, shell, ContractsByArtifact, +}; use foundry_compilers::artifacts::Libraries; use foundry_evm::{ coverage::HitMaps, @@ -14,6 +16,7 @@ use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashMap}, fmt::{self, Write}, + sync::Arc, time::Duration, }; use yansi::Paint; @@ -34,7 +37,7 @@ pub struct TestOutcome { /// This is `None` if traces and logs were not decoded. /// /// Note that `Address` fields only contain the last executed test case's data. - pub decoder: Option, + pub last_run_decoder: Option, /// The gas report, if requested. pub gas_report: Option, } @@ -42,7 +45,7 @@ pub struct TestOutcome { impl TestOutcome { /// Creates a new test outcome with the given results. pub fn new(results: BTreeMap, allow_failure: bool) -> Self { - Self { results, allow_failure, decoder: None, gas_report: None } + Self { results, allow_failure, last_run_decoder: None, gas_report: None } } /// Creates a new empty test outcome. @@ -196,6 +199,9 @@ pub struct SuiteResult { pub warnings: Vec, /// Libraries used to link test contract. pub libraries: Libraries, + /// Contracts linked with correct libraries. + #[serde(skip)] + pub known_contracts: Arc, } impl SuiteResult { @@ -204,8 +210,9 @@ impl SuiteResult { test_results: BTreeMap, warnings: Vec, libraries: Libraries, + known_contracts: Arc, ) -> Self { - Self { duration, test_results, warnings, libraries } + Self { duration, test_results, warnings, libraries, known_contracts } } /// Returns an iterator over all individual succeeding tests and their names. diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 26af217870aea..ad335e7674808 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -30,6 +30,7 @@ use rayon::prelude::*; use std::{ borrow::Cow, collections::{BTreeMap, HashMap}, + sync::Arc, time::Instant, }; @@ -178,7 +179,7 @@ impl<'a> ContractRunner<'a> { mut self, filter: &dyn TestFilter, test_options: &TestOptions, - known_contracts: Option<&ContractsByArtifact>, + known_contracts: Arc, ) -> SuiteResult { info!("starting tests"); let start = Instant::now(); @@ -207,6 +208,7 @@ impl<'a> ContractRunner<'a> { .into(), warnings, self.contract.libraries.clone(), + known_contracts, ) } @@ -244,6 +246,7 @@ impl<'a> ContractRunner<'a> { .into(), warnings, self.contract.libraries.clone(), + known_contracts, ) } @@ -265,7 +268,7 @@ impl<'a> ContractRunner<'a> { ); let identified_contracts = - has_invariants.then(|| load_contracts(setup.traces.clone(), known_contracts)); + has_invariants.then(|| load_contracts(setup.traces.clone(), &known_contracts)); let test_results = functions .par_iter() .map(|&func| { @@ -281,7 +284,7 @@ impl<'a> ContractRunner<'a> { setup, *invariant_config, func, - known_contracts, + &known_contracts, identified_contracts.as_ref().unwrap(), ) } else if func.is_fuzz_test() { @@ -299,8 +302,13 @@ impl<'a> ContractRunner<'a> { .collect::>(); let duration = start.elapsed(); - let suite_result = - SuiteResult::new(duration, test_results, warnings, self.contract.libraries.clone()); + let suite_result = SuiteResult::new( + duration, + test_results, + warnings, + self.contract.libraries.clone(), + known_contracts, + ); info!( duration=?suite_result.duration, "done. {}/{} successful", @@ -430,12 +438,10 @@ impl<'a> ContractRunner<'a> { setup: TestSetup, invariant_config: InvariantConfig, func: &Function, - known_contracts: Option<&ContractsByArtifact>, + known_contracts: &ContractsByArtifact, identified_contracts: &ContractsByAddress, ) -> TestResult { trace!(target: "forge::test::fuzz", "executing invariant test for {:?}", func.name); - let empty = ContractsByArtifact::default(); - let project_contracts = known_contracts.unwrap_or(&empty); let TestSetup { address, logs, traces, labeled_addresses, coverage, .. } = setup; // First, run the test normally to see if it needs to be skipped. @@ -466,7 +472,7 @@ impl<'a> ContractRunner<'a> { runner, invariant_config, identified_contracts, - project_contracts, + known_contracts, ); let invariant_contract = diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index b1f8efc491622..6f95767653857 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -1,5 +1,7 @@ //! Regression tests for previous issues. +use std::sync::Arc; + use crate::{ config::*, test_helpers::{ForgeTestData, TEST_DATA_DEFAULT}, @@ -8,7 +10,7 @@ use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; use alloy_json_abi::Event; use alloy_primitives::{address, Address, U256}; use forge::result::TestStatus; -use foundry_config::{fs_permissions::PathPermission, FsPermissions}; +use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_evm::{ constants::HARDHAT_CONSOLE_ADDRESS, traces::{CallKind, CallTraceDecoder, DecodedCallData, TraceKind}, @@ -290,10 +292,12 @@ test_repro!(6538); // https://github.com/foundry-rs/foundry/issues/6554 test_repro!(6554; |config| { - let mut cheats_config = config.runner.cheats_config.as_ref().clone(); - let path = cheats_config.root.join("out/default/Issue6554.t.sol"); - cheats_config.fs_permissions.add(PathPermission::read_write(path)); - config.runner.cheats_config = std::sync::Arc::new(cheats_config); + let path = config.runner.config.__root.0.join("out/default/Issue6554.t.sol"); + + let mut prj_config = Config::clone(&config.runner.config); + prj_config.fs_permissions.add(PathPermission::read_write(path)); + config.runner.config = Arc::new(prj_config); + }); // https://github.com/foundry-rs/foundry/issues/6759 @@ -307,16 +311,18 @@ test_repro!(6616); // https://github.com/foundry-rs/foundry/issues/5529 test_repro!(5529; |config| { - let mut cheats_config = config.runner.cheats_config.as_ref().clone(); - cheats_config.always_use_create_2_factory = true; - config.runner.cheats_config = std::sync::Arc::new(cheats_config); + let mut prj_config = Config::clone(&config.runner.config); + prj_config.always_use_create_2_factory = true; + config.runner.evm_opts.always_use_create_2_factory = true; + config.runner.config = Arc::new(prj_config); }); // https://github.com/foundry-rs/foundry/issues/6634 test_repro!(6634; |config| { - let mut cheats_config = config.runner.cheats_config.as_ref().clone(); - cheats_config.always_use_create_2_factory = true; - config.runner.cheats_config = std::sync::Arc::new(cheats_config); + let mut prj_config = Config::clone(&config.runner.config); + prj_config.always_use_create_2_factory = true; + config.runner.evm_opts.always_use_create_2_factory = true; + config.runner.config = Arc::new(prj_config); }); test_repro!(7481); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 204df223b860f..f65a3c116222e 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -2,8 +2,8 @@ use alloy_primitives::U256; use forge::{ - inspectors::CheatsConfig, revm::primitives::SpecId, MultiContractRunner, - MultiContractRunnerBuilder, TestOptions, TestOptionsBuilder, + revm::primitives::SpecId, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, + TestOptionsBuilder, }; use foundry_compilers::{ artifacts::{Libraries, Settings}, @@ -23,6 +23,7 @@ use std::{ env, fmt, io::Write, path::{Path, PathBuf}, + sync::Arc, }; pub const RE_PATH_SEPARATOR: &str = "/"; @@ -187,7 +188,7 @@ impl ForgeTestData { /// Builds a base runner pub fn base_runner(&self) -> MultiContractRunnerBuilder { init_tracing(); - let mut runner = MultiContractRunnerBuilder::default() + let mut runner = MultiContractRunnerBuilder::new(Arc::new(self.config.clone())) .sender(self.evm_opts.sender) .with_test_options(self.test_opts.clone()); if self.profile.is_cancun() { @@ -222,17 +223,14 @@ impl ForgeTestData { let env = opts.local_evm_env(); let output = self.output.clone(); - let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); - self.base_runner() - .with_cheats_config(CheatsConfig::new( - &config, - opts.clone(), - Some(artifact_ids), - None, - None, - )) + + let sender = config.sender; + + let mut builder = self.base_runner(); + builder.config = Arc::new(config); + builder .enable_isolation(opts.isolate) - .sender(config.sender) + .sender(sender) .with_test_options(self.test_opts.clone()) .build(root, output, env, opts.clone()) .unwrap() diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index ea00dc5920fff..bdc940097a896 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -31,9 +31,6 @@ pub struct BuildData { pub output: ProjectCompileOutput, /// Id of target contract artifact. pub target: ArtifactId, - /// Artifact ids of the contracts. Passed to cheatcodes to enable usage of - /// `vm.getDeployedCode`. - pub artifact_ids: Vec, } impl BuildData { @@ -99,21 +96,8 @@ impl LinkedBuildData { &link_output.libraries, )?; - let known_contracts = ContractsByArtifact( - build_data - .get_linker() - .get_linked_artifacts(&link_output.libraries)? - .into_iter() - .filter_map(|(id, contract)| { - let name = id.name.clone(); - let bytecode = contract.bytecode.and_then(|b| b.into_bytes())?; - let deployed_bytecode = - contract.deployed_bytecode.and_then(|b| b.into_bytes())?; - let abi = contract.abi?; - - Some((id, ContractData { name, abi, bytecode, deployed_bytecode })) - }) - .collect(), + let known_contracts = ContractsByArtifact::new( + build_data.get_linker().get_linked_artifacts(&link_output.libraries)?, ); Ok(Self { @@ -169,8 +153,6 @@ impl PreprocessedState { let mut target_id: Option = None; - let artifact_ids = output.artifact_ids().map(|(id, _)| id).collect(); - // Find target artfifact id by name and path in compilation artifacts. for (id, contract) in output.artifact_ids().filter(|(id, _)| id.source == target_path) { if let Some(name) = &target_name { @@ -207,12 +189,7 @@ impl PreprocessedState { args, script_config, script_wallets, - build_data: BuildData { - output, - target, - project_root: project.root().clone(), - artifact_ids, - }, + build_data: BuildData { output, target, project_root: project.root().clone() }, }) } } diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 9e76955914e4d..1239cda1f3bcd 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -94,7 +94,7 @@ impl PreExecutionState { let mut runner = self .script_config .get_runner_with_cheatcodes( - self.build_data.build_data.artifact_ids.clone(), + self.build_data.known_contracts.clone(), self.script_wallets.clone(), self.args.debug, self.build_data.build_data.target.clone(), diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 17f70387acc5b..dc4e05e1a0bf9 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -45,7 +45,7 @@ use foundry_evm::{ }; use foundry_wallets::MultiWalletOpts; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; +use std::{collections::HashMap, sync::Arc}; use yansi::Paint; mod broadcast; @@ -545,17 +545,17 @@ impl ScriptConfig { async fn get_runner_with_cheatcodes( &mut self, - artifact_ids: Vec, + known_contracts: ContractsByArtifact, script_wallets: ScriptWallets, debug: bool, target: ArtifactId, ) -> Result { - self._get_runner(Some((artifact_ids, script_wallets, target)), debug).await + self._get_runner(Some((known_contracts, script_wallets, target)), debug).await } async fn _get_runner( &mut self, - cheats_data: Option<(Vec, ScriptWallets, ArtifactId)>, + cheats_data: Option<(ContractsByArtifact, ScriptWallets, ArtifactId)>, debug: bool, ) -> Result { trace!("preparing script runner"); @@ -584,7 +584,7 @@ impl ScriptConfig { .spec(self.config.evm_spec_id()) .gas_limit(self.evm_opts.gas_limit()); - if let Some((artifact_ids, script_wallets, target)) = cheats_data { + if let Some((known_contracts, script_wallets, target)) = cheats_data { builder = builder.inspectors(|stack| { stack .debug(debug) @@ -592,7 +592,7 @@ impl ScriptConfig { CheatsConfig::new( &self.config, self.evm_opts.clone(), - Some(artifact_ids), + Some(Arc::new(known_contracts)), Some(script_wallets), Some(target.version), ) From 63072bec5225654001a83fac44f789bd958ce491 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 18 Apr 2024 00:38:32 +0400 Subject: [PATCH 0866/1963] refactor: inject call to CREATE2 factory through custom revm handler (#7653) * wip * wip * add docs * clippy * update doc * simplify logic * review fixes * doc * review fixes * fix --- crates/anvil/src/eth/backend/mem/inspector.rs | 5 +- crates/anvil/src/eth/backend/mem/mod.rs | 3 +- crates/cheatcodes/src/inspector.rs | 171 ++++-------------- crates/evm/core/src/backend/cow.rs | 7 +- crates/evm/core/src/backend/mod.rs | 11 +- crates/evm/core/src/lib.rs | 24 +++ crates/evm/core/src/utils.rs | 148 ++++++++++++++- crates/evm/evm/src/inspectors/stack.rs | 18 ++ crates/evm/evm/src/lib.rs | 2 +- 9 files changed, 231 insertions(+), 158 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 6e38ac61d5b65..6ea16a34057e2 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -6,13 +6,14 @@ use foundry_evm::{ call_inspectors, decode::decode_console_logs, inspectors::{LogCollector, TracingInspector}, - revm, revm::{ + self, interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}, primitives::U256, EvmContext, }, traces::TracingInspectorConfig, + InspectorExt, }; /// The [`revm::Inspector`] used when transacting in the evm @@ -136,6 +137,8 @@ impl revm::Inspector for Inspector { } } +impl InspectorExt for Inspector {} + /// Prints all the logs #[inline] pub fn print_logs(logs: &[Log]) { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 86d946f2dba62..3b5fdc73f577a 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -76,6 +76,7 @@ use foundry_evm::{ }, }, utils::new_evm_with_inspector_ref, + InspectorExt, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; use parking_lot::{Mutex, RwLock}; @@ -819,7 +820,7 @@ impl Backend { ) -> revm::Evm<'_, I, WrapDatabaseRef> where DB: revm::DatabaseRef, - I: revm::Inspector>, + I: InspectorExt>, { let mut evm = new_evm_with_inspector_ref(db, env, inspector); if let Some(ref factory) = self.precompile_factory { diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index ed6aa5cf4fccf..64d2e70a4f986 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -21,8 +21,9 @@ use alloy_sol_types::{SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, SELECTOR_LEN}; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, - backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, - constants::{CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS}, + backend::{DatabaseExt, RevertDiagnostic}, + constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, + InspectorExt, }; use itertools::Itertools; use revm::{ @@ -1327,22 +1328,19 @@ impl Inspector for Cheatcodes { ecx.env.tx.caller = broadcast.new_origin; if ecx.journaled_state.depth() == broadcast.depth { - let (bytecode, to, nonce) = process_broadcast_create( - broadcast.new_origin, - call.init_code.clone(), - ecx, - call, - ); + call.caller = broadcast.new_origin; let is_fixed_gas_limit = check_if_fixed_gas_limit(ecx, call.gas_limit); + let account = &ecx.journaled_state.state()[&broadcast.new_origin]; + self.broadcastable_transactions.push_back(BroadcastableTransaction { rpc: ecx.db.active_fork_url(), transaction: TransactionRequest { from: Some(broadcast.new_origin), - to, + to: None, value: Some(call.value), - input: TransactionInput::new(bytecode), - nonce: Some(nonce), + input: TransactionInput::new(call.init_code.clone()), + nonce: Some(account.info.nonce), gas: if is_fixed_gas_limit { Some(call.gas_limit as u128) } else { @@ -1351,6 +1349,7 @@ impl Inspector for Cheatcodes { ..Default::default() }, }); + let kind = match call.scheme { CreateScheme::Create => "create", CreateScheme::Create2 { .. } => "create2", @@ -1360,29 +1359,6 @@ impl Inspector for Cheatcodes { } } - // Apply the Create2 deployer - if self.broadcast.is_some() || self.config.always_use_create_2_factory { - match apply_create2_deployer( - ecx, - call, - self.prank.as_ref(), - self.broadcast.as_ref(), - self.recorded_account_diffs_stack.as_mut(), - ) { - Ok(_) => {} - Err(err) => { - return Some(CreateOutcome { - result: InterpreterResult { - result: InstructionResult::Revert, - output: Error::encode(err), - gas, - }, - address: None, - }) - } - }; - } - // allow cheatcodes from the address of the new contract // Compute the address *after* any possible broadcast updates, so it's based on the updated // call inputs @@ -1526,6 +1502,29 @@ impl Inspector for Cheatcodes { } } +impl InspectorExt for Cheatcodes { + fn should_use_create2_factory( + &mut self, + ecx: &mut EvmContext, + inputs: &mut CreateInputs, + ) -> bool { + if let CreateScheme::Create2 { .. } = inputs.scheme { + let target_depth = if let Some(prank) = &self.prank { + prank.depth + } else if let Some(broadcast) = &self.broadcast { + broadcast.depth + } else { + 1 + }; + + ecx.journaled_state.depth() == target_depth && + (self.broadcast.is_some() || self.config.always_use_create_2_factory) + } else { + false + } + } +} + /// Helper that expands memory, stores a revert string pertaining to a disallowed memory write, /// and sets the return range to the revert string's location in memory. /// @@ -1554,110 +1553,6 @@ fn disallowed_mem_write( }; } -/// Applies the default CREATE2 deployer for contract creation. -/// -/// This function is invoked during the contract creation process and updates the caller of the -/// contract creation transaction to be the `DEFAULT_CREATE2_DEPLOYER` if the `CreateScheme` is -/// `Create2` and the current execution depth matches the depth at which the `prank` or `broadcast` -/// was started, or the default depth of 1 if no prank or broadcast is currently active. -/// -/// Returns a `DatabaseError::MissingCreate2Deployer` if the `DEFAULT_CREATE2_DEPLOYER` account is -/// not found or if it does not have any associated bytecode. -fn apply_create2_deployer( - ecx: &mut InnerEvmContext, - call: &mut CreateInputs, - prank: Option<&Prank>, - broadcast: Option<&Broadcast>, - diffs_stack: Option<&mut Vec>>, -) -> Result<(), DB::Error> { - if let CreateScheme::Create2 { salt } = call.scheme { - let mut base_depth = 1; - if let Some(prank) = &prank { - base_depth = prank.depth; - } else if let Some(broadcast) = &broadcast { - base_depth = broadcast.depth; - } - - // If the create scheme is Create2 and the depth equals the broadcast/prank/default - // depth, then use the default create2 factory as the deployer - if ecx.journaled_state.depth() == base_depth { - // Record the call to the create2 factory in the state diff - if let Some(recorded_account_diffs_stack) = diffs_stack { - let calldata = [&salt.to_be_bytes::<32>()[..], &call.init_code[..]].concat(); - recorded_account_diffs_stack.push(vec![AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: ecx.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(ecx.env.cfg.chain_id), - }, - accessor: call.caller, - account: DEFAULT_CREATE2_DEPLOYER, - kind: crate::Vm::AccountAccessKind::Call, - initialized: true, - oldBalance: U256::ZERO, // updated on create_end - newBalance: U256::ZERO, // updated on create_end - value: call.value, - data: calldata.into(), - reverted: false, - deployedCode: Bytes::new(), // updated on create_end - storageAccesses: vec![], // updated on create_end - depth: ecx.journaled_state.depth(), - }]) - } - - // Sanity checks for our CREATE2 deployer - // TODO: use ecx.load_account - let info = - &ecx.journaled_state.load_account(DEFAULT_CREATE2_DEPLOYER, &mut ecx.db)?.0.info; - match &info.code { - Some(code) if code.is_empty() => return Err(DatabaseError::MissingCreate2Deployer), - None if ecx.db.code_by_hash(info.code_hash)?.is_empty() => { - return Err(DatabaseError::MissingCreate2Deployer) - } - _ => {} - } - - call.caller = DEFAULT_CREATE2_DEPLOYER; - } - } - Ok(()) -} - -/// Processes the creation of a new contract when broadcasting, preparing the necessary data for the -/// transaction to deploy the contract. -/// -/// Returns the transaction calldata and the target address. -/// -/// If the CreateScheme is Create, then this function returns the input bytecode without -/// modification and no address since it will be filled in later. If the CreateScheme is Create2, -/// then this function returns the calldata for the call to the create2 deployer which must be the -/// salt and init code concatenated. -fn process_broadcast_create( - broadcast_sender: Address, - bytecode: Bytes, - ecx: &mut InnerEvmContext, - call: &mut CreateInputs, -) -> (Bytes, Option
, u64) { - call.caller = broadcast_sender; - match call.scheme { - CreateScheme::Create => { - (bytecode, None, ecx.journaled_state.account(broadcast_sender).info.nonce) - } - CreateScheme::Create2 { salt } => { - // We have to increment the nonce of the user address, since this create2 will be done - // by the create2_deployer - let account = ecx.journaled_state.state().get_mut(&broadcast_sender).unwrap(); - let prev = account.info.nonce; - // Touch account to ensure that incremented nonce is committed - account.mark_touch(); - account.info.nonce += 1; - debug!(target: "cheatcodes", address=%broadcast_sender, nonce=prev+1, prev, "incremented nonce in create2"); - // Proxy deployer requires the data to be `salt ++ init_code` - let calldata = [&salt.to_be_bytes::<32>()[..], &bytecode[..]].concat(); - (calldata.into(), Some(DEFAULT_CREATE2_DEPLOYER), prev) - } - } -} - // Determines if the gas limit on a given call was manually set in the script and should therefore // not be overwritten by later estimations fn check_if_fixed_gas_limit( diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 59410541a7374..9b53fb4ee29aa 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -6,6 +6,7 @@ use crate::{ RevertSnapshotAction, }, fork::{CreateFork, ForkId}, + InspectorExt, }; use alloy_genesis::GenesisAccount; use alloy_primitives::{Address, B256, U256}; @@ -16,7 +17,7 @@ use revm::{ Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, HashMap as Map, ResultAndState, SpecId, }, - Database, DatabaseCommit, Inspector, JournaledState, + Database, DatabaseCommit, JournaledState, }; use std::{borrow::Cow, collections::BTreeMap}; @@ -58,7 +59,7 @@ impl<'a> CowBackend<'a> { /// /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. - pub fn inspect<'b, I: Inspector<&'b mut Self>>( + pub fn inspect<'b, I: InspectorExt<&'b mut Self>>( &'b mut self, env: &mut EnvWithHandlerCfg, inspector: I, @@ -176,7 +177,7 @@ impl<'a> DatabaseExt for CowBackend<'a> { self.backend_mut(env).roll_fork_to_transaction(id, transaction, env, journaled_state) } - fn transact>( + fn transact>( &mut self, id: Option, transaction: B256, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index e924d19efc85d..90e27444b2227 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -5,6 +5,7 @@ use crate::{ fork::{CreateFork, ForkId, MultiFork, SharedBackend}, snapshot::Snapshots, utils::configure_tx_env, + InspectorExt, }; use alloy_genesis::GenesisAccount; use alloy_primitives::{b256, keccak256, Address, B256, U256}; @@ -19,7 +20,7 @@ use revm::{ Account, AccountInfo, Bytecode, CreateScheme, Env, EnvWithHandlerCfg, HashMap as Map, Log, ResultAndState, SpecId, State, StorageSlot, TransactTo, KECCAK_EMPTY, }, - Database, DatabaseCommit, Inspector, JournaledState, + Database, DatabaseCommit, JournaledState, }; use std::{ collections::{BTreeMap, HashMap, HashSet}, @@ -188,7 +189,7 @@ pub trait DatabaseExt: Database { ) -> eyre::Result<()>; /// Fetches the given transaction for the fork and executes it, committing the state in the DB - fn transact>( + fn transact>( &mut self, id: Option, transaction: B256, @@ -780,7 +781,7 @@ impl Backend { /// /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. - pub fn inspect<'a, I: Inspector<&'a mut Self>>( + pub fn inspect<'a, I: InspectorExt<&'a mut Self>>( &'a mut self, env: &mut EnvWithHandlerCfg, inspector: I, @@ -1228,7 +1229,7 @@ impl DatabaseExt for Backend { Ok(()) } - fn transact>( + fn transact>( &mut self, maybe_id: Option, transaction: B256, @@ -1868,7 +1869,7 @@ fn update_env_block(env: &mut Env, fork_block: u64, block: &Block) { /// Executes the given transaction and commits state changes to the database _and_ the journaled /// state, with an optional inspector -fn commit_transaction>( +fn commit_transaction>( tx: WithOtherFields, mut env: EnvWithHandlerCfg, journaled_state: &mut JournaledState, diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 9d26c9421c3fa..ef28ad9223adb 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -4,6 +4,10 @@ #![warn(unused_crate_dependencies)] +use auto_impl::auto_impl; +use revm::{inspectors::NoOpInspector, interpreter::CreateInputs, Database, EvmContext, Inspector}; +use revm_inspectors::access_list::AccessListInspector; + #[macro_use] extern crate tracing; @@ -19,3 +23,23 @@ pub mod opcodes; pub mod opts; pub mod snapshot; pub mod utils; + +/// An extension trait that allows us to add additional hooks to Inspector for later use in +/// handlers. +#[auto_impl(&mut, Box)] +pub trait InspectorExt: Inspector { + /// Determines whether the `DEFAULT_CREATE2_DEPLOYER` should be used for a CREATE2 frame. + /// + /// If this function returns true, we'll replace CREATE2 frame with a CALL frame to CREATE2 + /// factory. + fn should_use_create2_factory( + &mut self, + _context: &mut EvmContext, + _inputs: &mut CreateInputs, + ) -> bool { + false + } +} + +impl InspectorExt for NoOpInspector {} +impl InspectorExt for AccessListInspector {} diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index ee8a8a4d47587..d1e73a1fa9024 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,17 +1,23 @@ +pub use crate::ic::*; +use crate::{constants::DEFAULT_CREATE2_DEPLOYER, InspectorExt}; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{FixedBytes, U256}; +use alloy_primitives::{Address, FixedBytes, U256}; use alloy_rpc_types::{Block, Transaction}; use eyre::ContextCompat; +pub use foundry_compilers::utils::RuntimeOrHandle; use foundry_config::NamedChain; +pub use revm::primitives::State as StateChangeset; use revm::{ db::WrapDatabaseRef, - primitives::{SpecId, TransactTo}, + handler::register::EvmHandler, + interpreter::{ + return_ok, CallContext, CallInputs, CallScheme, CreateInputs, CreateOutcome, Gas, + InstructionResult, InterpreterResult, Transfer, + }, + primitives::{CreateScheme, EVMError, SpecId, TransactTo, KECCAK_EMPTY}, + FrameOrResult, FrameResult, }; - -pub use foundry_compilers::utils::RuntimeOrHandle; -pub use revm::primitives::State as StateChangeset; - -pub use crate::ic::*; +use std::{cell::RefCell, rc::Rc, sync::Arc}; /// Depending on the configured chain id and block number this should apply any specific changes /// @@ -99,6 +105,129 @@ pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 { spent - (refunded).min(spent / refund_quotient) } +fn get_create2_factory_call_inputs(salt: U256, inputs: CreateInputs) -> CallInputs { + let calldata = [&salt.to_be_bytes::<32>()[..], &inputs.init_code[..]].concat(); + CallInputs { + contract: DEFAULT_CREATE2_DEPLOYER, + transfer: Transfer { + source: inputs.caller, + target: DEFAULT_CREATE2_DEPLOYER, + value: inputs.value, + }, + input: calldata.into(), + gas_limit: inputs.gas_limit, + context: CallContext { + caller: inputs.caller, + address: DEFAULT_CREATE2_DEPLOYER, + code_address: DEFAULT_CREATE2_DEPLOYER, + apparent_value: inputs.value, + scheme: CallScheme::Call, + }, + is_static: false, + return_memory_offset: 0..0, + } +} + +/// Used for routing certain CREATE2 invocations through [DEFAULT_CREATE2_DEPLOYER]. +/// +/// Overrides create hook with CALL frame if [InspectorExt::should_use_create2_factory] returns +/// true. Keeps track of overriden frames and handles outcome in the overriden insert_call_outcome +/// hook by inserting decoded address directly into interpreter. +/// +/// Should be installed after [revm::inspector_handle_register] and before any other registers. +pub fn create2_handler_register>( + handler: &mut EvmHandler<'_, I, DB>, +) { + let create2_overrides = Rc::>>::new(RefCell::new(Vec::new())); + + let create2_overrides_inner = create2_overrides.clone(); + let old_handle = handler.execution.create.clone(); + handler.execution.create = + Arc::new(move |ctx, mut inputs| -> Result> { + let CreateScheme::Create2 { salt } = inputs.scheme else { + return old_handle(ctx, inputs); + }; + if !ctx.external.should_use_create2_factory(&mut ctx.evm, &mut inputs) { + return old_handle(ctx, inputs); + } + + // Sanity check that CREATE2 deployer exists. + let code_hash = ctx.evm.load_account(DEFAULT_CREATE2_DEPLOYER)?.0.info.code_hash; + if code_hash == KECCAK_EMPTY { + return Ok(FrameOrResult::Result(FrameResult::Create(CreateOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: "missing CREATE2 deployer".into(), + gas: Gas::new(inputs.gas_limit), + }, + address: None, + }))) + } + + // Generate call inputs for CREATE2 factory. + let mut call_inputs = get_create2_factory_call_inputs(salt, *inputs); + + // Call inspector to change input or return outcome. + if let Some(outcome) = ctx.external.call(&mut ctx.evm, &mut call_inputs) { + create2_overrides_inner + .borrow_mut() + .push((ctx.evm.journaled_state.depth(), call_inputs.clone())); + return Ok(FrameOrResult::Result(FrameResult::Call(outcome))); + } + + // Push data about current override to the stack. + create2_overrides_inner + .borrow_mut() + .push((ctx.evm.journaled_state.depth(), call_inputs.clone())); + + let mut frame_or_result = ctx.evm.make_call_frame(&call_inputs); + + if let Ok(FrameOrResult::Frame(frame)) = &mut frame_or_result { + ctx.external + .initialize_interp(&mut frame.frame_data_mut().interpreter, &mut ctx.evm) + } + frame_or_result + }); + + let create2_overrides_inner = create2_overrides.clone(); + let old_handle = handler.execution.insert_call_outcome.clone(); + + handler.execution.insert_call_outcome = + Arc::new(move |ctx, frame, shared_memory, mut outcome| { + // If we are on the depth of the latest override, handle the outcome. + if create2_overrides_inner + .borrow() + .last() + .map_or(false, |(depth, _)| *depth == ctx.evm.journaled_state.depth()) + { + let (_, call_inputs) = create2_overrides_inner.borrow_mut().pop().unwrap(); + outcome = ctx.external.call_end(&mut ctx.evm, &call_inputs, outcome); + + // Decode address from output. + let address = match outcome.instruction_result() { + return_ok!() => Address::try_from(outcome.output().as_ref()) + .map_err(|_| { + outcome.result = InterpreterResult { + result: InstructionResult::Revert, + output: "invalid CREATE2 factory output".into(), + gas: Gas::new(call_inputs.gas_limit), + }; + }) + .ok(), + _ => None, + }; + frame + .frame_data_mut() + .interpreter + .insert_create_outcome(CreateOutcome { address, result: outcome.result }); + + Ok(()) + } else { + old_handle(ctx, frame, shared_memory, outcome) + } + }); +} + /// Creates a new EVM with the given inspector. pub fn new_evm_with_inspector<'a, DB, I>( db: DB, @@ -107,7 +236,7 @@ pub fn new_evm_with_inspector<'a, DB, I>( ) -> revm::Evm<'a, I, DB> where DB: revm::Database, - I: revm::Inspector, + I: InspectorExt, { // NOTE: We could use `revm::Evm::builder()` here, but on the current patch it has some // performance issues. @@ -115,6 +244,7 @@ where let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); let mut handler = revm::Handler::new(handler_cfg); handler.append_handler_register_plain(revm::inspector_handle_register); + handler.append_handler_register_plain(create2_handler_register); revm::Evm::new(context, handler) } @@ -126,7 +256,7 @@ pub fn new_evm_with_inspector_ref<'a, DB, I>( ) -> revm::Evm<'a, I, WrapDatabaseRef> where DB: revm::DatabaseRef, - I: revm::Inspector>, + I: InspectorExt>, { new_evm_with_inspector(WrapDatabaseRef(db), env, inspector) } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index a38bf0eeeeaf8..627ca2438de45 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -6,6 +6,7 @@ use alloy_primitives::{Address, Bytes, Log, U256}; use foundry_evm_core::{ backend::{update_state, DatabaseExt}, debug::DebugArena, + InspectorExt, }; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; @@ -764,3 +765,20 @@ impl Inspector<&mut DB> for InspectorStack { )); } } + +impl InspectorExt<&mut DB> for InspectorStack { + fn should_use_create2_factory( + &mut self, + ecx: &mut EvmContext<&mut DB>, + inputs: &mut CreateInputs, + ) -> bool { + call_inspectors_adjust_depth!( + [&mut self.cheatcodes], + |inspector| { inspector.should_use_create2_factory(ecx, inputs).then_some(true) }, + self, + ecx + ); + + false + } +} diff --git a/crates/evm/evm/src/lib.rs b/crates/evm/evm/src/lib.rs index aa5386b3e047f..a699b6bf80447 100644 --- a/crates/evm/evm/src/lib.rs +++ b/crates/evm/evm/src/lib.rs @@ -10,7 +10,7 @@ extern crate tracing; pub mod executors; pub mod inspectors; -pub use foundry_evm_core::{backend, constants, debug, decode, fork, opts, utils}; +pub use foundry_evm_core::{backend, constants, debug, decode, fork, opts, utils, InspectorExt}; pub use foundry_evm_coverage as coverage; pub use foundry_evm_fuzz as fuzz; pub use foundry_evm_traces as traces; From e5b8fc98eed13e0ffa93c41c712a16054c044b33 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:37:20 +0300 Subject: [PATCH 0867/1963] chore: fix test clippy (#7700) --- crates/cheatcodes/src/fs.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index cecfc88221779..a729d53bb8432 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -545,7 +545,6 @@ fn prompt( mod tests { use super::*; use crate::CheatsConfig; - use alloy_primitives::Bytes; use std::sync::Arc; fn cheats() -> Cheatcodes { From 1c59fcc03b08d6672d49209da7854fd68bf17b57 Mon Sep 17 00:00:00 2001 From: William Cheung Date: Thu, 18 Apr 2024 11:18:42 -0400 Subject: [PATCH 0868/1963] feat(forge): clone verified contracts as a foundry project (#7576) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat:support forge clone * feat: update configuration based on metadate from EtherScan 👷 * doc: update the documenation for * add dump_sources function * fix: add existing remapping into remappings.txt * apply remapping on libraries * add tests * feat: update remappings in config file * add two more test cases * fix library remapping bug * test: add e2e test cases for forge clone * test: fix rate limit issue for forge clone tests * feat: disable git by default for forge clone * dump clone.toml metadata in cloned projects * add storage layout to the clone metadata * dump clone metadata in a hidden, readonly, compact json file * add constructor arguments in clone metadata * fix: typo field name * fix: bug in remapping * fix: remapping disorder for verified foundry contracts * fix clippy and fmt warnings * fmt in the foundry way * chore: restore files to be consistent with foundry fmt style * cherry pick bug fixes from tweak branch * fix: remove the dependency of Etherscan in tests * chore: move mockall to dev dependency, only mock in test build * feat: use camelCase in .clone.meta * doc: add comments to explain forge clone * fix: import file not found error * chore: remove uncessary dependency fix: fix a foundry config bug regarding generating project_paths * chore: refactor the test code a bit * Update crates/forge/bin/cmd/clone.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/forge/bin/cmd/clone.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * chore: change string as address in CloneArg * test: add one basic forgetest for clone * feat: dump remappings into remappings.txt by default chore: break a large function into multiple small one to improve readability * feat: improve UX and make --quiet true quiet * test: add one more forgetest! for clone * fix minor issues suggested in code review * fix: incorrect assertion for project paths * test: add default etherscan api keys and remove sleep in tests * test: add more etherscan api keys * fix: revoke the unnecessary changes in config.rs * feat: bump foundry-compilers to 0.3.16 * chore: refactor code and clean some comments * fix: path disorder on windows * touchups --------- Co-authored-by: Zhuo Zhang Co-authored-by: Zhuo Zhang <14835483+ZhangZhuoSJTU@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Matthias Seitz --- Cargo.lock | 74 ++ crates/common/src/rpc.rs | 22 + crates/config/src/lib.rs | 2 +- crates/forge/Cargo.toml | 3 + crates/forge/bin/cmd/clone.rs | 726 ++++++++++++++++++ crates/forge/bin/cmd/init.rs | 16 +- crates/forge/bin/cmd/mod.rs | 1 + crates/forge/bin/main.rs | 1 + crates/forge/bin/opts.rs | 9 +- crates/forge/tests/cli/cmd.rs | 36 + .../creation_data.json | 5 + .../metadata.json | 78 ++ .../creation_data.json | 5 + .../metadata.json | 16 + .../creation_data.json | 5 + .../metadata.json | 193 +++++ .../creation_data.json | 5 + .../metadata.json | 129 ++++ .../creation_data.json | 5 + .../metadata.json | 63 ++ .../creation_data.json | 5 + .../metadata.json | 69 ++ .../creation_data.json | 5 + .../metadata.json | 148 ++++ 24 files changed, 1609 insertions(+), 12 deletions(-) create mode 100644 crates/forge/bin/cmd/clone.rs create mode 100644 testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json create mode 100644 testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json create mode 100644 testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json create mode 100644 testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json create mode 100644 testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json create mode 100644 testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json create mode 100644 testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json create mode 100644 testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json create mode 100644 testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json create mode 100644 testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json create mode 100644 testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json create mode 100644 testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json create mode 100644 testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json create mode 100644 testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json diff --git a/Cargo.lock b/Cargo.lock index 5095c7b0d7797..3d2f8c7d3c6d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2698,6 +2698,12 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + [[package]] name = "dunce" version = "1.0.4" @@ -3490,6 +3496,7 @@ dependencies = [ "hyper 0.14.28", "indicatif", "itertools 0.12.1", + "mockall", "once_cell", "opener", "parking_lot", @@ -3513,6 +3520,8 @@ dependencies = [ "thiserror", "tikv-jemallocator", "tokio", + "toml 0.8.12", + "toml_edit 0.22.9", "tower-http", "tracing", "tracing-subscriber", @@ -4101,6 +4110,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + [[package]] name = "fs2" version = "0.4.3" @@ -5597,6 +5612,33 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mockall" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43766c2b5203b10de348ffe19f7e54564b64f3d6018ff7648d1e2d6d3a0f0a48" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cbce79ec385a1d4f54baa90a76401eb15d9cab93685f62e7e9f942aa00ae2" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -6423,6 +6465,32 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "predicates" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" +dependencies = [ + "anstyle", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "pretty_assertions" version = "1.4.0" @@ -8161,6 +8229,12 @@ dependencies = [ "phf_codegen 0.11.2", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + [[package]] name = "thiserror" version = "1.0.58" diff --git a/crates/common/src/rpc.rs b/crates/common/src/rpc.rs index eb53213353056..63a701a4f82fc 100644 --- a/crates/common/src/rpc.rs +++ b/crates/common/src/rpc.rs @@ -51,6 +51,22 @@ static ALCHEMY_MAINNET_KEYS: Lazy> = Lazy::new(|| { keys }); +// List of etherscan keys for mainnet +static ETHERSCAN_MAINNET_KEYS: Lazy> = Lazy::new(|| { + let mut keys = vec![ + "MCAUM7WPE9XP5UQMZPCKIBUJHPM1C24FP6", + "JW6RWCG2C5QF8TANH4KC7AYIF1CX7RB5D1", + "ZSMDY6BI2H55MBE3G9CUUQT4XYUDBB6ZSK", + "4FYHTY429IXYMJNS4TITKDMUKW5QRYDX61", + "QYKNT5RHASZ7PGQE68FNQWH99IXVTVVD2I", + "VXMQ117UN58Y4RHWUB8K1UGCEA7UQEWK55", + ]; + + keys.shuffle(&mut rand::thread_rng()); + + keys +}); + /// counts how many times a rpc endpoint was requested for _mainnet_ static NEXT_RPC_ENDPOINT: AtomicUsize = AtomicUsize::new(0); @@ -111,6 +127,12 @@ pub fn next_ws_archive_rpc_endpoint() -> String { format!("wss://eth-mainnet.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) } +/// Returns the next etherscan api key +pub fn next_etherscan_api_key() -> String { + let idx = next() % ETHERSCAN_MAINNET_KEYS.len(); + ETHERSCAN_MAINNET_KEYS[idx].to_string() +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 12a588d1ce0f1..65923ced798a6 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -767,7 +767,7 @@ impl Config { self.rpc_storage_caching.enable_for_endpoint(endpoint) } - /// Returns the `ProjectPathsConfig` sub set of the config. + /// Returns the `ProjectPathsConfig` sub set of the config. /// /// **NOTE**: this uses the paths as they are and does __not__ modify them, see /// `[Self::sanitized]` diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 039b956cc37b3..30b5975768c76 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -79,6 +79,8 @@ solang-parser.workspace = true strum = { workspace = true, features = ["derive"] } thiserror = "1" tokio = { version = "1", features = ["time"] } +toml = { version = "0.8", features = ["preserve_order"] } +toml_edit = "0.22.4" watchexec = "2.3.2" evm-disassembler.workspace = true rustc-hash.workspace = true @@ -96,6 +98,7 @@ tikv-jemallocator = { workspace = true, optional = true } anvil.workspace = true foundry-test-utils.workspace = true +mockall = "0.12" criterion = "0.5" globset = "0.4" paste = "1.0" diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs new file mode 100644 index 0000000000000..a15418d1d7a12 --- /dev/null +++ b/crates/forge/bin/cmd/clone.rs @@ -0,0 +1,726 @@ +use super::{init::InitArgs, install::DependencyInstallOpts}; +use alloy_primitives::{Address, Bytes, ChainId, TxHash}; +use clap::{Parser, ValueHint}; +use eyre::Result; +use foundry_block_explorers::{ + contract::{ContractCreationData, ContractMetadata, Metadata}, + errors::EtherscanError, + Client, +}; +use foundry_cli::{opts::EtherscanOpts, p_println, utils::Git}; +use foundry_common::{compile::ProjectCompiler, fs}; +use foundry_compilers::{ + artifacts::{output_selection::ContractOutputSelection, Settings, StorageLayout}, + remappings::{RelativeRemapping, Remapping}, + ConfigurableContractArtifact, ProjectCompileOutput, ProjectPathsConfig, +}; +use foundry_config::{Chain, Config}; +use std::{ + fs::read_dir, + path::{Path, PathBuf}, + time::Duration, +}; + +/// CloneMetadata stores the metadata that are not included by `foundry.toml` but necessary for a +/// cloned contract. The metadata can be serialized to a metadata file in the cloned project root. +#[derive(Debug, Clone, serde::Serialize)] +#[serde(rename_all = "camelCase")] +pub struct CloneMetadata { + /// The path to the source file that contains the contract declaration. + /// The path is relative to the root directory of the project. + pub path: PathBuf, + /// The name of the contract in the file. + pub target_contract: String, + /// The address of the contract on the blockchian. + pub address: Address, + /// The chain id. + pub chain_id: ChainId, + /// The transaction hash of the creation transaction. + pub creation_transaction: TxHash, + /// The address of the deployer, i.e., sender of the creation transaction. + pub deployer: Address, + /// The constructor arguments of the contract on chain. + pub constructor_arguments: Bytes, + /// The storage layout of the contract on chain. + pub storage_layout: StorageLayout, +} + +/// CLI arguments for `forge clone`. +/// +/// `forge clone` clones an on-chain contract from block explorers (e.g., Etherscan) in the +/// following steps: +/// 1. Fetch the contract source code from the block explorer. +/// 2. Initialize a empty foundry project at the `root` directory specified in `CloneArgs`. +/// 3. Dump the contract sources to the source directory. +/// 4. Update the `foundry.toml` configuration file with the compiler settings from Etherscan. +/// 5. Try compile the cloned contract, so that we can get the original storage layout. This +/// original storage layout is preserved in the `CloneMetadata` so that if the user later +/// modifies the contract, it is possible to quickly check the storage layout compatibility with +/// the original on-chain contract. +/// 6. Dump the `CloneMetadata` to the root directory of the cloned project as `.clone.meta` file. +#[derive(Clone, Debug, Parser)] +pub struct CloneArgs { + /// The contract address to clone. + pub address: Address, + + /// The root directory of the cloned project. + #[arg(value_hint = ValueHint::DirPath, default_value = ".", value_name = "PATH")] + pub root: PathBuf, + + /// Do not generaet the remappings.txt file. Instead, keep the remappings in the configuration. + #[arg(long)] + pub no_remappings_txt: bool, + + #[command(flatten)] + pub etherscan: EtherscanOpts, + + #[command(flatten)] + pub opts: DependencyInstallOpts, +} + +impl CloneArgs { + pub async fn run(self) -> Result<()> { + let CloneArgs { address, root, opts, etherscan, no_remappings_txt } = self; + + // step 0. get the chain and api key from the config + let config = Config::from(ðerscan); + let chain = config.chain.unwrap_or_default(); + let etherscan_api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); + let client = Client::new(chain, etherscan_api_key.clone())?; + + // step 1. get the metadata from client + p_println!(!opts.quiet => "Downloading the source code of {} from Etherscan...", address); + let meta = Self::collect_metadata_from_client(address, &client).await?; + + // step 2. initialize an empty project + Self::init_an_empty_project(&root, opts)?; + // canonicalize the root path + // note that at this point, the root directory must have been created + let root = dunce::canonicalize(&root)?; + + // step 3. parse the metadata + Self::parse_metadata(&meta, chain, &root, no_remappings_txt).await?; + + // step 4. collect the compilation metadata + // if the etherscan api key is not set, we need to wait for 3 seconds between calls + p_println!(!opts.quiet => "Collecting the creation information of {} from Etherscan...", address); + if etherscan_api_key.is_empty() { + p_println!(!opts.quiet => "Waiting for 5 seconds to avoid rate limit..."); + tokio::time::sleep(Duration::from_secs(5)).await; + } + Self::collect_compilation_metadata(&meta, chain, address, &root, &client, opts.quiet) + .await?; + + // step 5. git add and commit the changes if needed + if !opts.no_commit { + let git = Git::new(&root).quiet(opts.quiet); + git.add(Some("--all"))?; + let msg = format!("chore: forge clone {}", address); + git.commit(&msg)?; + } + + Ok(()) + } + + /// Collect the metadata of the contract from the block explorer. + /// + /// * `address` - the address of the contract to be cloned. + /// * `client` - the client of the block explorer. + pub(crate) async fn collect_metadata_from_client( + address: Address, + client: &C, + ) -> Result { + let mut meta = client.contract_source_code(address).await?; + eyre::ensure!(meta.items.len() == 1, "contract not found or ill-formed"); + let meta = meta.items.remove(0); + eyre::ensure!(!meta.is_vyper(), "Vyper contracts are not supported"); + Ok(meta) + } + + /// Initialize an empty project at the root directory. + /// + /// * `root` - the root directory of the project. + /// * `enable_git` - whether to enable git for the project. + /// * `quiet` - whether to print messages. + pub(crate) fn init_an_empty_project(root: &Path, opts: DependencyInstallOpts) -> Result<()> { + // let's try to init the project with default init args + let init_args = InitArgs { root: root.to_path_buf(), opts, ..Default::default() }; + init_args.run().map_err(|e| eyre::eyre!("Project init error: {:?}", e))?; + + // remove the unnecessary example contracts + // XXX (ZZ): this is a temporary solution until we have a proper way to remove contracts, + // e.g., add a field in the InitArgs to control the example contract generation + fs::remove_file(root.join("src/Counter.sol"))?; + fs::remove_file(root.join("test/Counter.t.sol"))?; + fs::remove_file(root.join("script/Counter.s.sol"))?; + + Ok(()) + } + + /// Collect the compilation metadata of the cloned contract. + /// This function compiles the cloned contract and collects the compilation metadata. + /// + /// * `meta` - the metadata of the contract (from Etherscam). + /// * `chain` - the chain where the contract to be cloned locates. + /// * `address` - the address of the contract to be cloned. + /// * `root` - the root directory of the cloned project. + /// * `client` - the client of the block explorer. + pub(crate) async fn collect_compilation_metadata( + meta: &Metadata, + chain: Chain, + address: Address, + root: &PathBuf, + client: &C, + quiet: bool, + ) -> Result<()> { + // compile the cloned contract + let compile_output = compile_project(root, quiet)?; + let (main_file, main_artifact) = find_main_contract(&compile_output, &meta.contract_name)?; + let main_file = main_file.strip_prefix(root)?.to_path_buf(); + let storage_layout = + main_artifact.storage_layout.to_owned().expect("storage layout not found"); + + // dump the metadata to the root directory + let creation_tx = client.contract_creation_data(address).await?; + let clone_meta = CloneMetadata { + path: main_file, + target_contract: meta.contract_name.clone(), + address, + chain_id: chain.id(), + creation_transaction: creation_tx.transaction_hash, + deployer: creation_tx.contract_creator, + constructor_arguments: meta.constructor_arguments.clone(), + storage_layout, + }; + let metadata_content = serde_json::to_string(&clone_meta)?; + let metadata_file = root.join(".clone.meta"); + fs::write(&metadata_file, metadata_content)?; + let mut perms = std::fs::metadata(&metadata_file)?.permissions(); + perms.set_readonly(true); + std::fs::set_permissions(&metadata_file, perms)?; + + Ok(()) + } + + /// Download and parse the source code from Etherscan. + /// + /// * `chain` - the chain where the contract to be cloned locates. + /// * `address` - the address of the contract to be cloned. + /// * `root` - the root directory to clone the contract into as a foundry project. + /// * `client` - the client of the block explorer. + /// * `no_remappings_txt` - whether to generate the remappings.txt file. + pub(crate) async fn parse_metadata( + meta: &Metadata, + chain: Chain, + root: &PathBuf, + no_remappings_txt: bool, + ) -> Result<()> { + // dump sources and update the remapping in configuration + let Settings { remappings: original_remappings, .. } = meta.settings()?; + let (remappings, strip_old_src) = dump_sources(meta, root)?; + Config::update_at(root, |config, doc| { + let profile = config.profile.as_str().as_str(); + let mut remapping_array = toml_edit::Array::new(); + // original remappings + for r in original_remappings.iter() { + // we should update its remapped path in the same way as we dump sources + // i.e., remove prefix `contracts` (if any) and add prefix `src` + let mut r = r.to_owned(); + if strip_old_src { + let new_path = PathBuf::from(r.path.clone()) + .strip_prefix("contracts") + .map(|p| p.to_path_buf()) + .unwrap_or(PathBuf::from(r.path)); + r.path = PathBuf::from("src").join(new_path).to_string_lossy().to_string(); + } + remapping_array.push(r.to_string()); + } + // new remappings + for r in remappings { + remapping_array.push(r.to_string()); + } + doc[Config::PROFILE_SECTION][profile]["remappings"] = toml_edit::value(remapping_array); + + true + })?; + + // update configuration + Config::update_at(root, |config, doc| { + update_config_by_metadata(config, doc, meta, chain).is_ok() + })?; + + // write remappings to remappings.txt if necessary + if !no_remappings_txt { + let remappings_txt = root.join("remappings.txt"); + eyre::ensure!( + !remappings_txt.exists(), + "remappings.txt already exists, please remove it first" + ); + + Config::update_at(root, |config, doc| { + let remappings_txt_content = + config.remappings.iter().map(|r| r.to_string()).collect::>().join("\n"); + if fs::write(&remappings_txt, remappings_txt_content).is_err() { + return false + } + + let profile = config.profile.as_str().as_str(); + if let Some(elem) = doc[Config::PROFILE_SECTION][profile].as_table_mut() { + elem.remove_entry("remappings"); + true + } else { + false + } + })?; + } + + Ok(()) + } +} + +/// Update the configuration file with the metadata. +/// This function will update the configuration file with the metadata from the contract. +/// It will update the following fields: +/// - `auto_detect_solc` to `false` +/// - `solc_version` to the value from the metadata +/// - `evm_version` to the value from the metadata +/// - `via_ir` to the value from the metadata +/// - `libraries` to the value from the metadata +/// - `metadata` to the value from the metadata +/// - `cbor_metadata`, `use_literal_content`, and `bytecode_hash` +/// - `optimizer` to the value from the metadata +/// - `optimizer_runs` to the value from the metadata +/// - `optimizer_details` to the value from the metadata +/// - `yul_details`, `yul`, etc. +/// - `simpleCounterForLoopUncheckedIncrement` is ignored for now +/// - `remappings` and `stop_after` are pre-validated to be empty and None, respectively +/// - `model_checker`, `debug`, and `output_selection` are ignored for now +/// +/// Detailed information can be found from the following link: +/// - https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options +/// - https://docs.soliditylang.org/en/latest/using-the-compiler.html#compiler-input-and-output-json-description +fn update_config_by_metadata( + config: &Config, + doc: &mut toml_edit::DocumentMut, + meta: &Metadata, + chain: Chain, +) -> Result<()> { + let profile = config.profile.as_str().as_str(); + + // macro to update the config if the value exists + macro_rules! update_if_needed { + ([$($key:expr),+], $value:expr) => { + { + if let Some(value) = $value { + let mut current = &mut doc[Config::PROFILE_SECTION][profile]; + $( + if let Some(nested_doc) = current.get_mut(&$key) { + current = nested_doc; + } else { + return Err(eyre::eyre!("cannot find the key: {}", $key)); + } + )+ + *current = toml_edit::value(value); + } + } + }; + } + + // update the chain id + doc[Config::PROFILE_SECTION][profile]["chain_id"] = toml_edit::value(chain.id() as i64); + + // disable auto detect solc and set the solc version + doc[Config::PROFILE_SECTION][profile]["auto_detect_solc"] = toml_edit::value(false); + let version = meta.compiler_version()?; + doc[Config::PROFILE_SECTION][profile]["solc_version"] = + toml_edit::value(format!("{}.{}.{}", version.major, version.minor, version.patch)); + + // get optimizer settings + // we ignore `model_checker`, `debug`, and `output_selection` for now, + // it seems they do not have impacts on the actual compilation + let Settings { optimizer, libraries, evm_version, via_ir, stop_after, metadata, .. } = + meta.settings()?; + eyre::ensure!(stop_after.is_none(), "stop_after should be None"); + + update_if_needed!(["evm_version"], evm_version.map(|v| v.to_string())); + update_if_needed!(["via_ir"], via_ir); + + // update metadata if needed + if let Some(metadata) = metadata { + update_if_needed!(["cbor_metadata"], metadata.cbor_metadata); + update_if_needed!(["use_literal_content"], metadata.use_literal_content); + update_if_needed!(["bytecode_hash"], metadata.bytecode_hash.map(|v| v.to_string())); + } + + // update optimizer settings if needed + update_if_needed!(["optimizer"], optimizer.enabled); + update_if_needed!(["optimizer_runs"], optimizer.runs.map(|v| v as i64)); + // update optimizer details if needed + if let Some(detail) = optimizer.details { + doc[Config::PROFILE_SECTION][profile]["optimizer_details"] = toml_edit::table(); + + update_if_needed!(["optimizer_details", "peephole"], detail.peephole); + update_if_needed!(["optimizer_details", "inliner"], detail.inliner); + update_if_needed!(["optimizer_details", "jumpdestRemover"], detail.jumpdest_remover); + update_if_needed!(["optimizer_details", "orderLiterals"], detail.order_literals); + update_if_needed!(["optimizer_details", "deduplicate"], detail.deduplicate); + update_if_needed!(["optimizer_details", "cse"], detail.cse); + update_if_needed!(["optimizer_details", "constantOptimizer"], detail.constant_optimizer); + update_if_needed!( + ["optimizer_details", "simpleCounterForLoopUncheckedIncrement"], + detail.simple_counter_for_loop_unchecked_increment + ); + update_if_needed!(["optimizer_details", "yul"], detail.yul); + + if let Some(yul_detail) = detail.yul_details { + doc[Config::PROFILE_SECTION][profile]["optimizer_details"]["yulDetails"] = + toml_edit::table(); + update_if_needed!( + ["optimizer_details", "yulDetails", "stackAllocation"], + yul_detail.stack_allocation + ); + update_if_needed!( + ["optimizer_details", "yulDetails", "optimizerSteps"], + yul_detail.optimizer_steps + ); + } + } + + // apply remapping on libraries + let path_config = config.project_paths(); + let libraries = libraries + .with_applied_remappings(&path_config) + .with_stripped_file_prefixes(&path_config.root); + + // update libraries + let mut lib_array = toml_edit::Array::new(); + for (path_to_lib, info) in libraries.libs { + for (lib_name, address) in info { + lib_array.push(format!("{}:{}:{}", path_to_lib.to_str().unwrap(), lib_name, address)); + } + } + doc[Config::PROFILE_SECTION][profile]["libraries"] = toml_edit::value(lib_array); + + Ok(()) +} + +/// Dump the contract sources to the root directory. +/// The sources are dumped to the `src` directory. +/// IO errors may be returned. +/// A list of remappings is returned, as well as a boolean indicating whether the old `contract` +/// or `src` directories are stripped. +fn dump_sources(meta: &Metadata, root: &PathBuf) -> Result<(Vec, bool)> { + // get config + let path_config = ProjectPathsConfig::builder().build_with_root(root); + // we will canonicalize the sources directory later + let src_dir = &path_config.sources; + let contract_name = &meta.contract_name; + let source_tree = meta.source_tree(); + + // then we move the sources to the correct directories + // we will first load existing remappings if necessary + // make sure this happens before dumping sources + let mut remappings: Vec = Remapping::find_many(root); + // we also load the original remappings from the metadata + remappings.extend(meta.settings()?.remappings); + + // first we dump the sources to a temporary directory + let tmp_dump_dir = root.join("raw_sources"); + source_tree + .write_to(&tmp_dump_dir) + .map_err(|e| eyre::eyre!("failed to dump sources: {}", e))?; + + // check whether we need to strip the `contract` or `src` directories in the original sources. + // They are the source directories in foundry or hardhat projects. We do not want to preserve + // them in the cloned project. + // If there is any other directory other than `src` `contracts` or `lib`, we should not strip. + let strip_old_src = std::fs::read_dir(tmp_dump_dir.join(contract_name))?.all(|e| { + let Ok(e) = e else { return false }; + let folder_name = e.file_name().to_string_lossy().to_string(); + ["contracts", "src", "lib"].contains(&folder_name.as_str()) + }); + // move contract sources to the `src` directory + for entry in std::fs::read_dir(tmp_dump_dir.join(contract_name))? { + if std::fs::metadata(root.join(src_dir)).is_err() { + std::fs::create_dir(root.join(src_dir))?; + } + let entry = entry?; + let folder_name = entry.file_name().to_string_lossy().to_string(); + // special handling for contracts and src directories: we flatten them. + if strip_old_src && (folder_name.as_str() == "contracts" || folder_name.as_str() == "src") { + // move all sub folders in contracts to src + for e in read_dir(entry.path())? { + let e = e?; + let dest = src_dir.join(e.file_name()); + std::fs::rename(e.path(), &dest)?; + remappings.push(Remapping { + context: None, + name: format!("{}/{}", folder_name, e.file_name().to_string_lossy()), + path: dest.to_string_lossy().to_string(), + }); + } + } else { + // move the other folders to src + let dest = src_dir.join(entry.file_name()); + std::fs::rename(entry.path(), &dest)?; + remappings.push(Remapping { + context: None, + name: entry.file_name().to_string_lossy().to_string(), + path: dest.to_string_lossy().to_string(), + }); + } + } + + // remove the temporary directory + std::fs::remove_dir_all(tmp_dump_dir)?; + + Ok((remappings.into_iter().map(|r| r.into_relative(root)).collect(), strip_old_src)) +} + +/// Compile the project in the root directory, and return the compilation result. +pub fn compile_project(root: &PathBuf, quiet: bool) -> Result { + let mut config = Config::load_with_root(root).sanitized(); + config.extra_output.push(ContractOutputSelection::StorageLayout); + let project = config.project()?; + let compiler = ProjectCompiler::new().quiet_if(quiet); + compiler.compile(&project) +} + +/// Find the artifact of the contract with the specified name. +/// This function returns the path to the source file and the artifact. +pub fn find_main_contract<'a>( + compile_output: &'a ProjectCompileOutput, + contract: &str, +) -> Result<(PathBuf, &'a ConfigurableContractArtifact)> { + let mut rv = None; + for (f, c, a) in compile_output.artifacts_with_files() { + if contract == c { + // it is possible that we have multiple contracts with the same name + // in different files + // instead of throwing an error, we should handle this case in the future + if rv.is_some() { + return Err(eyre::eyre!("multiple contracts with the same name found")); + } + rv = Some((PathBuf::from(f), a)); + } + } + rv.ok_or(eyre::eyre!("contract not found")) +} + +#[cfg(test)] +use mockall::automock; +/// EtherscanClient is a trait that defines the methods to interact with Etherscan. +/// It is defined as a wrapper of the `foundry_block_explorers::Client` to allow mocking. +#[cfg_attr(test, automock)] +pub(crate) trait EtherscanClient { + async fn contract_source_code( + &self, + address: Address, + ) -> std::result::Result; + async fn contract_creation_data( + &self, + address: Address, + ) -> std::result::Result; +} + +impl EtherscanClient for Client { + #[inline] + async fn contract_source_code( + &self, + address: Address, + ) -> std::result::Result { + self.contract_source_code(address).await + } + + #[inline] + async fn contract_creation_data( + &self, + address: Address, + ) -> std::result::Result { + self.contract_creation_data(address).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + use foundry_common::rpc::next_etherscan_api_key; + use foundry_compilers::Artifact; + use hex::ToHex; + use std::collections::BTreeMap; + + fn assert_successful_compilation(root: &PathBuf) -> ProjectCompileOutput { + println!("project_root: {:#?}", root); + compile_project(root, false).expect("compilation failure") + } + + fn assert_compilation_result( + compiled: ProjectCompileOutput, + contract_name: &str, + stripped_creation_code: &str, + ) { + compiled.compiled_contracts_by_compiler_version().iter().for_each(|(_, contracts)| { + contracts.iter().for_each(|(name, contract)| { + if name == contract_name { + let compiled_creation_code = + contract.get_bytecode_object().expect("creation code not found"); + let compiled_creation_code: String = compiled_creation_code.encode_hex(); + assert!( + compiled_creation_code.starts_with(stripped_creation_code), + "inconsistent creation code" + ); + } + }); + }); + } + + fn mock_etherscan(address: Address) -> impl super::EtherscanClient { + // load mock data + let mut mocked_data = BTreeMap::new(); + let data_folder = + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../testdata/etherscan"); + // iterate each sub folder + for entry in std::fs::read_dir(data_folder).expect("failed to read test data folder") { + let entry = entry.expect("failed to read test data entry"); + let addr: Address = entry.file_name().to_string_lossy().parse().unwrap(); + let contract_data_dir = entry.path(); + // the metadata.json file contains the metadata of the contract + let metadata_file = contract_data_dir.join("metadata.json"); + let metadata: ContractMetadata = + serde_json::from_str(&std::fs::read_to_string(metadata_file).unwrap()) + .expect("failed to parse metadata.json"); + // the creation_data.json file contains the creation data of the contract + let creation_data_file = contract_data_dir.join("creation_data.json"); + let creation_data: ContractCreationData = + serde_json::from_str(&std::fs::read_to_string(creation_data_file).unwrap()) + .expect("failed to parse creation_data.json"); + // insert the data to the map + mocked_data.insert(addr, (metadata, creation_data)); + } + + let (metadata, creation_data) = mocked_data.get(&address).unwrap(); + let metadata = metadata.clone(); + let creation_data = *creation_data; + let mut mocked_client = super::MockEtherscanClient::new(); + mocked_client + .expect_contract_source_code() + .times(1) + .returning(move |_| Ok(metadata.clone())); + mocked_client + .expect_contract_creation_data() + .times(1) + .returning(move |_| Ok(creation_data)); + mocked_client + } + + /// Fetch the metadata and creation data from Etherscan and dump them to the testdata folder. + #[tokio::test(flavor = "multi_thread")] + #[ignore = "this test is used to dump mock data from Etherscan"] + async fn test_dump_mock_data() { + let address: Address = "0x9ab6b21cdf116f611110b048987e58894786c244".parse().unwrap(); + let data_folder = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../testdata/etherscan") + .join(address.to_string()); + // create folder if not exists + std::fs::create_dir_all(&data_folder).unwrap(); + // create metadata.json and creation_data.json + let client = Client::new(Chain::mainnet(), next_etherscan_api_key()).unwrap(); + let meta = client.contract_source_code(address).await.unwrap(); + // dump json + let json = serde_json::to_string_pretty(&meta).unwrap(); + // write to metadata.json + std::fs::write(data_folder.join("metadata.json"), json).unwrap(); + let creation_data = client.contract_creation_data(address).await.unwrap(); + // dump json + let json = serde_json::to_string_pretty(&creation_data).unwrap(); + // write to creation_data.json + std::fs::write(data_folder.join("creation_data.json"), json).unwrap(); + } + + /// Run the clone command with the specified contract address and assert the compilation. + async fn one_test_case(address: Address, check_compilation_result: bool) { + let mut project_root = tempfile::tempdir().unwrap().path().to_path_buf(); + let client = mock_etherscan(address); + let meta = CloneArgs::collect_metadata_from_client(address, &client).await.unwrap(); + CloneArgs::init_an_empty_project(&project_root, DependencyInstallOpts::default()).unwrap(); + project_root = dunce::canonicalize(&project_root).unwrap(); + CloneArgs::parse_metadata(&meta, Chain::mainnet(), &project_root, false).await.unwrap(); + CloneArgs::collect_compilation_metadata( + &meta, + Chain::mainnet(), + address, + &project_root, + &client, + false, + ) + .await + .unwrap(); + let rv = assert_successful_compilation(&project_root); + if check_compilation_result { + let (contract_name, stripped_creation_code) = + pick_creation_info(&address.to_string()).expect("creation code not found"); + assert_compilation_result(rv, contract_name, stripped_creation_code); + } + std::fs::remove_dir_all(project_root).unwrap(); + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_clone_single_file_contract() { + let address = "0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193".parse().unwrap(); + one_test_case(address, true).await + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_clone_contract_with_optimization_details() { + let address = "0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545".parse().unwrap(); + one_test_case(address, true).await + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_clone_contract_with_libraries() { + let address = "0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec".parse().unwrap(); + one_test_case(address, true).await + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_clone_contract_with_metadata() { + let address = "0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05".parse().unwrap(); + one_test_case(address, true).await + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_clone_contract_with_relative_import() { + let address = "0x3a23F943181408EAC424116Af7b7790c94Cb97a5".parse().unwrap(); + one_test_case(address, false).await + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_clone_contract_with_original_remappings() { + let address = "0x9ab6b21cdf116f611110b048987e58894786c244".parse().unwrap(); + one_test_case(address, false).await + } + + #[tokio::test(flavor = "multi_thread")] + async fn test_clone_contract_with_relative_import2() { + let address = "0x044b75f554b886A065b9567891e45c79542d7357".parse().unwrap(); + one_test_case(address, false).await + } + + fn pick_creation_info(address: &str) -> Option<(&'static str, &'static str)> { + for (addr, contract_name, creation_code) in CREATION_ARRAY.iter() { + if address == *addr { + return Some((contract_name, creation_code)); + } + } + + None + } + + // remember to remove CBOR metadata from the creation code + const CREATION_ARRAY: [(&str, &str, &str); 4] = [ + ("0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193", "BearXNFTStaking", "608060405234801561001057600080fd5b50613000806100206000396000f3fe608060405234801561001057600080fd5b50600436106102265760003560e01c80638129fc1c11610130578063bca35a71116100b8578063dada55011161007c578063dada550114610458578063f2fde38b1461046b578063f83d08ba1461047e578063fbb0022714610486578063fccd7f721461048e57600080fd5b8063bca35a71146103fa578063bf9befb11461040d578063c89d5b8b14610416578063d5d423001461041e578063d976e09f1461042657600080fd5b8063b1c92f95116100ff578063b1c92f95146103c5578063b549445c146103ce578063b81f8e89146103d6578063b9ade5b7146103de578063ba0848db146103e757600080fd5b80638129fc1c146103905780638da5cb5b14610398578063aaed083b146103a9578063b10dcc93146103b257600080fd5b8063367c164e116101b35780635923489b116101825780635923489b146103245780636e2751211461034f578063706ce3e114610362578063715018a614610375578063760a2e8a1461037d57600080fd5b8063367c164e146102bd57806338ff8a85146102d05780633a17f4f0146102f1578063426233601461030457600080fd5b8063206635e7116101fa578063206635e71461026d5780632afe761a146102805780632bd30f1114610289578063305f839a146102ab57806333ddacd1146102b457600080fd5b8062944f621461022b5780630d00368b146102405780630e8feed41461025c578063120957fd14610264575b600080fd5b61023e610239366004612aa4565b6104bc565b005b61024960735481565b6040519081526020015b60405180910390f35b61023e61053a565b610249606d5481565b61023e61027b366004612b2c565b61057e565b610249606f5481565b60785461029b90610100900460ff1681565b6040519015158152602001610253565b61024960715481565b61024960765481565b61023e6102cb366004612bc2565b6105d1565b6102e36102de366004612aa4565b610829565b604051610253929190612c16565b61023e6102ff366004612aa4565b6109e1565b610317610312366004612aa4565b610a56565b6040516102539190612c2f565b606a54610337906001600160a01b031681565b6040516001600160a01b039091168152602001610253565b6102e361035d366004612aa4565b610b4c565b606b54610337906001600160a01b031681565b61023e610cf8565b61029b61038b366004612aa4565b610d2e565b61023e610dc2565b6033546001600160a01b0316610337565b61024960705481565b61023e6103c0366004612b2c565b610fc0565b610249606e5481565b61023e611236565b61023e6112bb565b61024960725481565b6102e36103f5366004612aa4565b6112ef565b61023e610408366004612aa4565b61149b565b610249606c5481565b610249611510565b606f54610249565b610439610434366004612aa4565b611594565b6040805192151583526001600160a01b03909116602083015201610253565b606954610337906001600160a01b031681565b61023e610479366004612aa4565b6115cf565b61023e611667565b61023e6116a0565b6104a161049c366004612aa4565b6116e1565b60408051938452602084019290925290820152606001610253565b6033546001600160a01b031633146104ef5760405162461bcd60e51b81526004016104e690612c42565b60405180910390fd5b606b546001600160a01b03163b6105185760405162461bcd60e51b81526004016104e690612c77565b606b80546001600160a01b0319166001600160a01b0392909216919091179055565b600061054533611594565b509050806105655760405162461bcd60e51b81526004016104e690612cae565b61056e33610d2e565b61057b5761057b33611c73565b50565b610587336116e1565b505060765560005b81518110156105cd576105bb8282815181106105ad576105ad612cda565b602002602001015133611d7b565b806105c581612d06565b91505061058f565b5050565b606a54604051636eb1769f60e11b815233600482015273871770e3e03bfaefa3597056e540a1a9c9ac7f6b602482015282916001600160a01b03169063dd62ed3e90604401602060405180830381865afa158015610633573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106579190612d21565b10156106bb5760405162461bcd60e51b815260206004820152602d60248201527f596f75206861766520746f20617070726f766520726f6f747820746f2073746160448201526c1ada5b99c818dbdb9d1c9858dd609a1b60648201526084016104e6565b606a546040516323b872dd60e01b815233600482015273871770e3e03bfaefa3597056e540a1a9c9ac7f6b6024820152604481018390526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015610726573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074a9190612d3a565b50606a546040516326c7e79d60e21b8152600481018390526001600160a01b0390911690639b1f9e7490602401600060405180830381600087803b15801561079157600080fd5b505af11580156107a5573d6000803e3d6000fd5b5050606b546001600160a01b031691506379c650689050336107c88460056120a1565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561080e57600080fd5b505af1158015610822573d6000803e3d6000fd5b5050505050565b600060606000805b6001600160a01b0385166000908152607460205260409020548110156108bc576001600160a01b0385166000908152607460205260409020805461089791908390811061088057610880612cda565b906000526020600020906005020160000154612129565b156108aa576108a7600183612d5c565b91505b806108b481612d06565b915050610831565b5060008167ffffffffffffffff8111156108d8576108d8612ac1565b604051908082528060200260200182016040528015610901578160200160208202803683370190505b5090506000805b6001600160a01b0387166000908152607460205260409020548110156109d5576001600160a01b0387166000908152607460205260409020805461095791908390811061088057610880612cda565b156109c3576001600160a01b038716600090815260746020526040902080548290811061098657610986612cda565b9060005260206000209060050201600001548383815181106109aa576109aa612cda565b60209081029190910101526109c0826001612154565b91505b806109cd81612d06565b915050610908565b50919590945092505050565b6033546001600160a01b03163314610a0b5760405162461bcd60e51b81526004016104e690612c42565b6069546001600160a01b03163b610a345760405162461bcd60e51b81526004016104e690612c77565b606980546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152607460205260408120546060919067ffffffffffffffff811115610a8b57610a8b612ac1565b604051908082528060200260200182016040528015610ab4578160200160208202803683370190505b50905060005b6001600160a01b038416600090815260746020526040902054811015610b45576001600160a01b0384166000908152607460205260409020805482908110610b0457610b04612cda565b906000526020600020906005020160000154828281518110610b2857610b28612cda565b602090810291909101015280610b3d81612d06565b915050610aba565b5092915050565b600060606000805b6001600160a01b038516600090815260746020526040902054811015610bdf576001600160a01b03851660009081526074602052604090208054610bba919083908110610ba357610ba3612cda565b9060005260206000209060050201600001546121b3565b15610bcd57610bca826001612154565b91505b80610bd781612d06565b915050610b54565b5060008167ffffffffffffffff811115610bfb57610bfb612ac1565b604051908082528060200260200182016040528015610c24578160200160208202803683370190505b5090506000805b6001600160a01b0387166000908152607460205260409020548110156109d5576001600160a01b03871660009081526074602052604090208054610c7a919083908110610ba357610ba3612cda565b15610ce6576001600160a01b0387166000908152607460205260409020805482908110610ca957610ca9612cda565b906000526020600020906005020160000154838381518110610ccd57610ccd612cda565b6020908102919091010152610ce3826001612154565b91505b80610cf081612d06565b915050610c2b565b6033546001600160a01b03163314610d225760405162461bcd60e51b81526004016104e690612c42565b610d2c60006121d0565b565b60006001815b6001600160a01b038416600090815260746020526040902054811015610b45576001600160a01b03841660009081526074602052604081208054610d9a919084908110610d8357610d83612cda565b906000526020600020906005020160010154612222565b9050603c8111610daa5750610db0565b60009250505b80610dba81612d06565b915050610d34565b600054610100900460ff16610ddd5760005460ff1615610de1565b303b155b610e445760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104e6565b600054610100900460ff16158015610e66576000805461ffff19166101011790555b610e6e61223c565b606580546001600160a01b0319908116737a250d5630b4cf539739df2c5dacb4c659f2488d1790915560668054821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2179055620151806067556312cc030060685560698054821673e22e1e620dffb03065cd77db0162249c0c91bf01179055606a8054821673d718ad25285d65ef4d79262a6cd3aea6a8e01023179055606b80549091167399cfdf48d0ba4885a73786148a2f89d86c7021701790556000606c5568056bc75e2d63100000606d556802b5e3af16b1880000606e55690257058e269742680000606f819055681b1ae4d6e2ef5000006070819055610bb8607181905591610f709190612d74565b610f7a9190612d8b565b607255607154606e54606d54610f909190612d74565b610f9a9190612d8b565b60735560006076556078805460ff19169055801561057b576000805461ff001916905550565b6000610fcb33611594565b50905080610feb5760405162461bcd60e51b81526004016104e690612cae565b607854610100900460ff161561102c5760405162461bcd60e51b8152602060048201526006602482015265131bd8dad95960d21b60448201526064016104e6565b600061103733610a56565b90508051835111156110775760405162461bcd60e51b81526020600482015260096024820152684964206572726f727360b81b60448201526064016104e6565b6000805b84518110156110fd5760005b83518110156110ea578381815181106110a2576110a2612cda565b60200260200101518683815181106110bc576110bc612cda565b602002602001015114156110d8576110d5836001612154565b92505b806110e281612d06565b915050611087565b50806110f581612d06565b91505061107b565b50835181141561123057835161112761111e82678ac7230489e800006120a1565b606f5490612154565b606f55611132612273565b600060768190555b855181101561122d5760695486516001600160a01b03909116906323b872dd90309033908a908690811061117057611170612cda565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b1580156111ca57600080fd5b505af11580156111de573d6000803e3d6000fd5b5050606c80549250905060006111f383612dad565b919050555061121b3387838151811061120e5761120e612cda565b602002602001015161229b565b8061122581612d06565b91505061113a565b50505b50505050565b60785460ff166112ac5760005b60755481101561057b576001607760006075848154811061126657611266612cda565b6000918252602080832091909101546001600160a01b031683528201929092526040019020805460ff1916911515919091179055806112a481612d06565b915050611243565b6078805460ff19166001179055565b60006112c633611594565b509050806112e65760405162461bcd60e51b81526004016104e690612cae565b61057b33612470565b600060606000805b6001600160a01b038516600090815260746020526040902054811015611382576001600160a01b0385166000908152607460205260409020805461135d91908390811061134657611346612cda565b906000526020600020906005020160000154612574565b156113705761136d600183612d5c565b91505b8061137a81612d06565b9150506112f7565b5060008167ffffffffffffffff81111561139e5761139e612ac1565b6040519080825280602002602001820160405280156113c7578160200160208202803683370190505b5090506000805b6001600160a01b0387166000908152607460205260409020548110156109d5576001600160a01b0387166000908152607460205260409020805461141d91908390811061134657611346612cda565b15611489576001600160a01b038716600090815260746020526040902080548290811061144c5761144c612cda565b90600052602060002090600502016000015483838151811061147057611470612cda565b6020908102919091010152611486826001612154565b91505b8061149381612d06565b9150506113ce565b6033546001600160a01b031633146114c55760405162461bcd60e51b81526004016104e690612c42565b606a546001600160a01b03163b6114ee5760405162461bcd60e51b81526004016104e690612c77565b606a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000806064606f5460016115249190612dc4565b61152e9190612d8b565b611539906001612d5c565b606d546115469190612dc4565b90506000606d54826115589190612d74565b905060006001606d548361156c9190612d8b565b6115769190612d8b565b611581906001612dc4565b61158c906064612dc4565b949350505050565b6001600160a01b038116600090815260776020526040812054819060ff161515600114156115c457506001929050565b506000928392509050565b6033546001600160a01b031633146115f95760405162461bcd60e51b81526004016104e690612c42565b6001600160a01b03811661165e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104e6565b61057b816121d0565b73d0d725208fd36be1561050fc1dd6a651d7ea7c89331415610d2c576078805461ff001981166101009182900460ff1615909102179055565b60006116ab33611594565b509050806116cb5760405162461bcd60e51b81526004016104e690612cae565b6116d433610d2e565b61057b5761057b336125aa565b600080808080808087816116f482610829565b509050600061170283610b4c565b50905060058110611a3b57600160005b6001600160a01b038516600090815260746020526040902054811015611a0e576001600160a01b0385166000908152607460205260408120805461177891908490811061176157611761612cda565b906000526020600020906005020160040154612222565b6001600160a01b038716600090815260746020526040902080549192506117a99184908110610ba357610ba3612cda565b806117de57506001600160a01b038616600090815260746020526040902080546117de91908490811061088057610880612cda565b80156117ea5750600181105b156117f457600092505b82801561181857506001600160a01b03861660009081526074602052604090205415155b156118715761186a8561182c83600a612dc4565b6118369190612dc4565b6118648661184585600a612dc4565b61184f9190612dc4565b60765461186490670de0b6b3a7640000612798565b90612154565b995061188e565b8261188e5760765461188b90670de0b6b3a7640000612798565b99505b6001600160a01b038616600090815260746020526040902080546118bd91908490811061088057610880612cda565b15611950576001600160a01b038616600090815260746020526040812080546119089190859081106118f1576118f1612cda565b906000526020600020906005020160020154612222565b90508061192861192182680ad78ebc5ac6200000612dc4565b8c90612154565b9a5061194761194082680ad78ebc5ac6200000612dc4565b8b90612154565b995050506119fb565b6001600160a01b0386166000908152607460205260409020805461197f919084908110610ba357610ba3612cda565b156119fb576001600160a01b038616600090815260746020526040812080546119b39190859081106118f1576118f1612cda565b905060008190506119d76002606d54846119cd9190612dc4565b6119219190612d8b565b9a506119f66002606d54836119ec9190612dc4565b6119409190612d8b565b995050505b5080611a0681612d06565b915050611712565b508515611a3557606b54606654611a32916001600160a01b039081169116886127da565b94505b50611c4f565b60005b6001600160a01b038416600090815260746020526040902054811015611c28576001600160a01b03841660009081526074602052604090208054611a8d91908390811061088057610880612cda565b15611b9f576001600160a01b03841660009081526074602052604081208054611ac191908490811061176157611761612cda565b9050611ad8611ad182600a612dc4565b8a90612154565b98506000611b1560746000886001600160a01b03166001600160a01b0316815260200190815260200160002084815481106118f1576118f1612cda565b9050611b2d611ad182680ad78ebc5ac6200000612dc4565b98506000611b8160746000896001600160a01b03166001600160a01b031681526020019081526020016000208581548110611b6a57611b6a612cda565b906000526020600020906005020160030154612222565b9050611b99611ad182680ad78ebc5ac6200000612dc4565b98505050505b6001600160a01b03841660009081526074602052604090208054611bce919083908110610ba357610ba3612cda565b15611c16576001600160a01b03841660009081526074602052604081208054611c0291908490811061176157611761612cda565b9050611c12611ad182600a612dc4565b9850505b80611c2081612d06565b915050611a3e565b508415611c4f57606b54606654611c4c916001600160a01b039081169116876127da565b93505b611c6187670de0b6b3a7640000612dc4565b9b959a50929850939650505050505050565b6000611c7e826116e1565b5091505080156105cd57606b5460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb906044016020604051808303816000875af1158015611cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cff9190612d3a565b5060005b6001600160a01b038316600090815260746020526040902054811015611d76576001600160a01b0383166000908152607460205260409020805442919083908110611d5057611d50612cda565b600091825260209091206002600590920201015580611d6e81612d06565b915050611d03565b505050565b607054606f5410611db857607354606d6000828254611d9a9190612d74565b9091555050606f54611db490678ac7230489e80000612905565b606f555b6069546040516331a9108f60e11b8152600481018490526001600160a01b03838116921690636352211e90602401602060405180830381865afa158015611e03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e279190612de3565b6001600160a01b031614611e7d5760405162461bcd60e51b815260206004820152601e60248201527f596f7520617265206e6f742061206f776e6572206f6620746865206e6674000060448201526064016104e6565b60695460405163e985e9c560e01b81523360048201523060248201526001600160a01b039091169063e985e9c590604401602060405180830381865afa158015611ecb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eef9190612d3a565b1515600114611f575760405162461bcd60e51b815260206004820152602e60248201527f596f752073686f756c6420617070726f7665206e667420746f2074686520737460448201526d185ada5b99c818dbdb9d1c9858dd60921b60648201526084016104e6565b6069546040516323b872dd60e01b81526001600160a01b03838116600483015230602483015260448201859052909116906323b872dd90606401600060405180830381600087803b158015611fab57600080fd5b505af1158015611fbf573d6000803e3d6000fd5b505050506000611fce82611594565b50905060006040518060a001604052808581526020014281526020014281526020014281526020014281525090506120126001606c5461215490919063ffffffff16565b606c556001600160a01b03831660009081526074602090815260408083208054600181810183559185529383902085516005909502019384559184015191830191909155820151600282015560608201516003820155608082015160049091015581611230576001600160a01b0383166000908152607760205260409020805460ff1916600117905550505050565b6000826120b057506000612123565b60006120bc8385612dc4565b9050826120c98583612d8b565b146121205760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016104e6565b90505b92915050565b60008064e8d4a510008310158015612146575064e8d4a510058311155b156121235750600192915050565b6000806121618385612d5c565b9050838110156121205760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016104e6565b600080610e7483116121c757506001612123565b50600092915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6067546000906122328342612d74565b6121239190612d8b565b600054610100900460ff166122635760405162461bcd60e51b81526004016104e690612e00565b61226b612947565b610d2c61296e565b61227c33612470565b61228533610d2e565b610d2c5761229233611c73565b610d2c336125aa565b60005b6001600160a01b038316600090815260746020526040902054811015612428576001600160a01b03831660009081526074602052604090208054839190839081106122eb576122eb612cda565b9060005260206000209060050201600001541415612416576001600160a01b0383166000908152607460205260409020805461232990600190612d74565b8154811061233957612339612cda565b906000526020600020906005020160746000856001600160a01b03166001600160a01b03168152602001908152602001600020828154811061237d5761237d612cda565b60009182526020808320845460059093020191825560018085015490830155600280850154908301556003808501549083015560049384015493909101929092556001600160a01b03851681526074909152604090208054806123e2576123e2612e4b565b6000828152602081206005600019909301928302018181556001810182905560028101829055600381018290556004015590555b8061242081612d06565b91505061229e565b506001600160a01b0382166000908152607460205260409020546105cd576001600160a01b038216600090815260746020526040812061246791612a3f565b6105cd8261299e565b600061247b826116e1565b509091505080156105cd57606a5460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb906044016020604051808303816000875af11580156124d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fd9190612d3a565b5060005b6001600160a01b038316600090815260746020526040902054811015611d76576001600160a01b038316600090815260746020526040902080544291908390811061254e5761254e612cda565b60009182526020909120600460059092020101558061256c81612d06565b915050612501565b60006509184e72a00682101561258c57506000919050565b6509184e72b4b38211156125a257506000919050565b506001919050565b60006125b5826116e1565b5091505080156105cd57606b5460655460405163095ea7b360e01b81526001600160a01b0391821660048201526024810184905291169063095ea7b3906044016020604051808303816000875af1158015612614573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126389190612d3a565b5060408051600280825260608083018452926020830190803683375050606b5482519293506001600160a01b03169183915060009061267957612679612cda565b6001600160a01b0392831660209182029290920101526066548251911690829060019081106126aa576126aa612cda565b6001600160a01b03928316602091820292909201015260655460405163791ac94760e01b815291169063791ac947906126f0908590600090869089904290600401612e9a565b600060405180830381600087803b15801561270a57600080fd5b505af115801561271e573d6000803e3d6000fd5b5050505060005b6001600160a01b038416600090815260746020526040902054811015611230576001600160a01b038416600090815260746020526040902080544291908390811061277257612772612cda565b60009182526020909120600360059092020101558061279081612d06565b915050612725565b600061212083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506129d7565b6040805160028082526060808301845260009390929190602083019080368337019050509050848160008151811061281457612814612cda565b60200260200101906001600160a01b031690816001600160a01b031681525050838160018151811061284857612848612cda565b6001600160a01b03928316602091820292909201015260655460405163d06ca61f60e01b8152600092919091169063d06ca61f9061288c9087908690600401612ed6565b600060405180830381865afa1580156128a9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526128d19190810190612eef565b905080600183516128e29190612d74565b815181106128f2576128f2612cda565b6020026020010151925050509392505050565b600061212083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612a0e565b600054610100900460ff16610d2c5760405162461bcd60e51b81526004016104e690612e00565b600054610100900460ff166129955760405162461bcd60e51b81526004016104e690612e00565b610d2c336121d0565b6000806129aa83611594565b915091508115611d76576001600160a01b03166000908152607760205260409020805460ff191690555050565b600081836129f85760405162461bcd60e51b81526004016104e69190612f75565b506000612a058486612d8b565b95945050505050565b60008184841115612a325760405162461bcd60e51b81526004016104e69190612f75565b506000612a058486612d74565b508054600082556005029060005260206000209081019061057b91905b80821115612a8b5760008082556001820181905560028201819055600382018190556004820155600501612a5c565b5090565b6001600160a01b038116811461057b57600080fd5b600060208284031215612ab657600080fd5b813561212081612a8f565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612b0057612b00612ac1565b604052919050565b600067ffffffffffffffff821115612b2257612b22612ac1565b5060051b60200190565b60006020808385031215612b3f57600080fd5b823567ffffffffffffffff811115612b5657600080fd5b8301601f81018513612b6757600080fd5b8035612b7a612b7582612b08565b612ad7565b81815260059190911b82018301908381019087831115612b9957600080fd5b928401925b82841015612bb757833582529284019290840190612b9e565b979650505050505050565b600060208284031215612bd457600080fd5b5035919050565b600081518084526020808501945080840160005b83811015612c0b57815187529582019590820190600101612bef565b509495945050505050565b82815260406020820152600061158c6040830184612bdb565b6020815260006121206020830184612bdb565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526017908201527f41646472657373206973206e6f7420636f6e7472616374000000000000000000604082015260600190565b6020808252601290820152712cb7ba9030b932903737ba1039ba30b5b2b960711b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415612d1a57612d1a612cf0565b5060010190565b600060208284031215612d3357600080fd5b5051919050565b600060208284031215612d4c57600080fd5b8151801515811461212057600080fd5b60008219821115612d6f57612d6f612cf0565b500190565b600082821015612d8657612d86612cf0565b500390565b600082612da857634e487b7160e01b600052601260045260246000fd5b500490565b600081612dbc57612dbc612cf0565b506000190190565b6000816000190483118215151615612dde57612dde612cf0565b500290565b600060208284031215612df557600080fd5b815161212081612a8f565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fd5b600081518084526020808501945080840160005b83811015612c0b5781516001600160a01b031687529582019590820190600101612e75565b85815284602082015260a060408201526000612eb960a0830186612e61565b6001600160a01b0394909416606083015250608001529392505050565b82815260406020820152600061158c6040830184612e61565b60006020808385031215612f0257600080fd5b825167ffffffffffffffff811115612f1957600080fd5b8301601f81018513612f2a57600080fd5b8051612f38612b7582612b08565b81815260059190911b82018301908381019087831115612f5757600080fd5b928401925b82841015612bb757835182529284019290840190612f5c565b600060208083528351808285015260005b81811015612fa257858101830151858201604001528201612f86565b81811115612fb4576000604083870101525b50601f01601f191692909201604001939250505056fe"), + ("0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545", "GovernorCharlieDelegate", "608060405234801561001057600080fd5b50613e45806100206000396000f3fe60806040526004361061031a5760003560e01c80637b3c71d3116101ab578063d50572ee116100f7578063f0843ba811610095578063fc176c041161006f578063fc176c0414610b82578063fc4eee4214610ba2578063fc66ff1414610bb8578063fe0d94c114610bd857600080fd5b8063f0843ba814610b12578063f2b0653714610b32578063f682e04c14610b6257600080fd5b8063de7bc127116100d1578063de7bc127146109ec578063deaaa7cc14610a02578063e23a9a5214610a36578063e837159c14610afc57600080fd5b8063d50572ee146109a0578063da35c664146109b6578063ddf0b009146109cc57600080fd5b8063a6d8784a11610164578063c1a287e21161013e578063c1a287e214610933578063c4d66de81461094a578063c5a8425d1461096a578063c9fb9e871461098a57600080fd5b8063a6d8784a146108e7578063abaac6a8146108fd578063b58131b01461091d57600080fd5b80637b3c71d31461083c5780637bdbe4d01461085c5780637cae57bb14610871578063806bd5811461088757806386d37e8b146108a757806399533365146108c757600080fd5b80632fedff591161026a5780633e4f49e61161022357806350442098116101fd578063504420981461074657806356781388146107665780635c60da1b1461078657806366176743146107be57600080fd5b80633e4f49e6146106d957806340e58ee5146107065780634d6733d21461072657600080fd5b80632fedff59146105ee578063328dd9821461060e57806338bd0dda1461063e5780633932abb11461066b5780633af32abf146106815780633bccf4fd146106b957600080fd5b8063158ef93e116102d757806318b62629116102b157806318b626291461056e5780631dfb1b5a1461058457806320606b70146105a457806324bc1a64146105d857600080fd5b8063158ef93e146104f757806317977c611461052157806317ba1b8b1461054e57600080fd5b8063013cf08b1461031f57806302a251a31461042857806306fdde031461044c5780630825f38f146104a25780630ea2d98c146104b7578063140499ea146104d7575b600080fd5b34801561032b57600080fd5b506103b361033a3660046132ee565b60096020819052600091825260409091208054600182015460028301546007840154600885015495850154600a860154600b870154600c880154600d890154600e9099015497996001600160a01b0390971698959794969593949293919260ff808316936101008404821693620100009004909116918d565b604080519d8e526001600160a01b03909c1660208e01529a8c019990995260608b019790975260808a019590955260a089019390935260c088019190915260e08701521515610100860152151561012085015215156101408401526101608301526101808201526101a0015b60405180910390f35b34801561043457600080fd5b5061043e60045481565b60405190815260200161041f565b34801561045857600080fd5b506104956040518060400160405280601a81526020017f496e7465726573742050726f746f636f6c20476f7665726e6f7200000000000081525081565b60405161041f9190613363565b6104b56104b0366004613450565b610beb565b005b3480156104c357600080fd5b506104b56104d23660046132ee565b610e61565b3480156104e357600080fd5b506104b56104f23660046134d6565b610ec6565b34801561050357600080fd5b506012546105119060ff1681565b604051901515815260200161041f565b34801561052d57600080fd5b5061043e61053c3660046134d6565b600a6020526000908152604090205481565b34801561055a57600080fd5b506104b56105693660046132ee565b610f07565b34801561057a57600080fd5b5061043e600f5481565b34801561059057600080fd5b506104b561059f3660046132ee565b610f64565b3480156105b057600080fd5b5061043e7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b3480156105e457600080fd5b5061043e60015481565b3480156105fa57600080fd5b506104b56106093660046132ee565b610fc1565b34801561061a57600080fd5b5061062e6106293660046132ee565b61101e565b60405161041f94939291906135ba565b34801561064a57600080fd5b5061043e6106593660046134d6565b600d6020526000908152604090205481565b34801561067757600080fd5b5061043e60035481565b34801561068d57600080fd5b5061051161069c3660046134d6565b6001600160a01b03166000908152600d6020526040902054421090565b3480156106c557600080fd5b506104b56106d4366004613623565b6112af565b3480156106e557600080fd5b506106f96106f43660046132ee565b611516565b60405161041f9190613687565b34801561071257600080fd5b506104b56107213660046132ee565b61169e565b34801561073257600080fd5b506104b56107413660046136af565b611b80565b34801561075257600080fd5b506104b56107613660046132ee565b611c45565b34801561077257600080fd5b506104b56107813660046136d9565b611ca2565b34801561079257600080fd5b506000546107a6906001600160a01b031681565b6040516001600160a01b03909116815260200161041f565b3480156107ca57600080fd5b506108146107d9366004613705565b601160209081526000928352604080842090915290825290205460ff808216916101008104909116906201000090046001600160601b031683565b60408051931515845260ff90921660208401526001600160601b03169082015260600161041f565b34801561084857600080fd5b506104b5610857366004613728565b611d09565b34801561086857600080fd5b5061043e600a81565b34801561087d57600080fd5b5061043e600c5481565b34801561089357600080fd5b506104b56108a23660046132ee565b611d58565b3480156108b357600080fd5b506104b56108c23660046132ee565b611db5565b3480156108d357600080fd5b506104b56108e23660046134d6565b611e12565b3480156108f357600080fd5b5061043e60155481565b34801561090957600080fd5b506104b56109183660046132ee565b611e8b565b34801561092957600080fd5b5061043e60055481565b34801561093f57600080fd5b5061043e6212750081565b34801561095657600080fd5b506104b56109653660046134d6565b611ee8565b34801561097657600080fd5b50600e546107a6906001600160a01b031681565b34801561099657600080fd5b5061043e60135481565b3480156109ac57600080fd5b5061043e60025481565b3480156109c257600080fd5b5061043e60075481565b3480156109d857600080fd5b506104b56109e73660046132ee565b611fd9565b3480156109f857600080fd5b5061043e60105481565b348015610a0e57600080fd5b5061043e7f150214d74d59b7d1e90c73fc22ef3d991dd0a76b046543d4d80ab92d2a50328f81565b348015610a4257600080fd5b50610acc610a51366004613705565b60408051606081018252600080825260208201819052918101919091525060009182526011602090815260408084206001600160a01b03939093168452918152918190208151606081018352905460ff8082161515835261010082041693820193909352620100009092046001600160601b03169082015290565b6040805182511515815260208084015160ff1690820152918101516001600160601b03169082015260600161041f565b348015610b0857600080fd5b5061043e60145481565b348015610b1e57600080fd5b506104b5610b2d3660046132ee565b61238f565b348015610b3e57600080fd5b50610511610b4d3660046132ee565b600b6020526000908152604090205460ff1681565b348015610b6e57600080fd5b5061043e610b7d3660046139b0565b6123ec565b348015610b8e57600080fd5b506104b5610b9d3660046132ee565b612a48565b348015610bae57600080fd5b5061043e60065481565b348015610bc457600080fd5b506008546107a6906001600160a01b031681565b6104b5610be63660046132ee565b612aa5565b60008585858585604051602001610c06959493929190613a91565b60408051601f1981840301815291815281516020928301206000818152600b90935291205490915060ff16610c7b5760405162461bcd60e51b81526020600482015260166024820152753a3c103430b9b713ba103132b2b71038bab2bab2b21760511b60448201526064015b60405180910390fd5b81421015610ccb5760405162461bcd60e51b815260206004820152601d60248201527f7478206861736e2774207375727061737365642074696d656c6f636b2e0000006044820152606401610c72565b610cd86212750083613af3565b421115610d165760405162461bcd60e51b815260206004820152600c60248201526b3a3c1034b99039ba30b6329760a11b6044820152606401610c72565b6000818152600b60205260409020805460ff191690558351606090610d3c575082610d68565b848051906020012084604051602001610d56929190613b0b565b60405160208183030381529060405290505b6000876001600160a01b03168783604051610d839190613b3c565b60006040518083038185875af1925050503d8060008114610dc0576040519150601f19603f3d011682016040523d82523d6000602084013e610dc5565b606091505b5050905080610e0f5760405162461bcd60e51b81526020600482015260166024820152753a3c1032bc32b1baba34b7b7103932bb32b93a32b21760511b6044820152606401610c72565b876001600160a01b0316837fa560e3198060a2f10670c1ec5b403077ea6ae93ca8de1c32b451dc1a943cd6e789898989604051610e4f9493929190613b58565b60405180910390a35050505050505050565b333014610e805760405162461bcd60e51b8152600401610c7290613b95565b600480549082905560408051828152602081018490527f7e3f7f0708a84de9203036abaa450dccc85ad5ff52f78c170f3edb55cf5e882891015b60405180910390a15050565b333014610ee55760405162461bcd60e51b8152600401610c7290613b95565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b333014610f265760405162461bcd60e51b8152600401610c7290613b95565b600580549082905560408051828152602081018490527fccb45da8d5717e6c4544694297c4ba5cf151d455c9bb0ed4fc7a38411bc054619101610eba565b333014610f835760405162461bcd60e51b8152600401610c7290613b95565b600380549082905560408051828152602081018490527fc565b045403dc03c2eea82b81a0465edad9e2e7fc4d97e11421c209da93d7a939101610eba565b333014610fe05760405162461bcd60e51b8152600401610c7290613b95565b601480549082905560408051828152602081018490527f519a192fe8db9e38785eb494c69f530ddb21b9e34322f8d08fe29bd3849749889101610eba565b606080606080600060096000878152602001908152602001600020905080600301816004018260050183600601838054806020026020016040519081016040528092919081815260200182805480156110a057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611082575b50505050509350828054806020026020016040519081016040528092919081815260200182805480156110f257602002820191906000526020600020905b8154815260200190600101908083116110de575b5050505050925081805480602002602001604051908101604052809291908181526020016000905b828210156111c657838290600052602060002001805461113990613bcc565b80601f016020809104026020016040519081016040528092919081815260200182805461116590613bcc565b80156111b25780601f10611187576101008083540402835291602001916111b2565b820191906000526020600020905b81548152906001019060200180831161119557829003601f168201915b50505050508152602001906001019061111a565b50505050915080805480602002602001604051908101604052809291908181526020016000905b8282101561129957838290600052602060002001805461120c90613bcc565b80601f016020809104026020016040519081016040528092919081815260200182805461123890613bcc565b80156112855780601f1061125a57610100808354040283529160200191611285565b820191906000526020600020905b81548152906001019060200180831161126857829003601f168201915b5050505050815260200190600101906111ed565b5050505090509450945094509450509193509193565b604080518082018252601a81527f496e7465726573742050726f746f636f6c20476f7665726e6f7200000000000060209182015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527f75a838dcd8ee5903cc7f4a5799344d0080864f57a6e9911f8bdfb4c8ddce9b5481840152466060820152306080808301919091528351808303909101815260a0820184528051908301207f150214d74d59b7d1e90c73fc22ef3d991dd0a76b046543d4d80ab92d2a50328f60c083015260e0820189905260ff8816610100808401919091528451808403909101815261012083019094528351939092019290922061190160f01b6101408401526101428301829052610162830181905290916000906101820160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa15801561143c573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661149f5760405162461bcd60e51b815260206004820181905260248201527f63617374566f746542795369673a20696e76616c6964207369676e61747572656044820152606401610c72565b88816001600160a01b03167fb8e138887d0aa13bab447e82de9d5c1777041ecd21ca36ba824ff1e6c07ddda48a6114d7858e8e612c90565b6040805160ff90931683526001600160601b039091166020830152606090820181905260009082015260800160405180910390a3505050505050505050565b6000816007541015801561152b575060065482115b6115775760405162461bcd60e51b815260206004820152601a60248201527f73746174653a20696e76616c69642070726f706f73616c2069640000000000006044820152606401610c72565b600082815260096020908152604080832060018101546001600160a01b03168452600d90925290912054600c82015442919091109060ff16156115be575060029392505050565b816007015443116115d3575060009392505050565b816008015443116115e8575060019392505050565b8080156115fc575081600d015482600a0154115b80611618575080158015611618575081600a0154826009015411155b80611633575080158015611633575081600d01548260090154105b15611642575060039392505050565b6002820154611655575060049392505050565b600c820154610100900460ff1615611671575060079392505050565b6212750082600201546116849190613af3565b4210611694575060069392505050565b5060059392505050565b60076116a982611516565b60078111156116ba576116ba613671565b14156117085760405162461bcd60e51b815260206004820152601d60248201527f63616e742063616e63656c2065786563757465642070726f706f73616c0000006044820152606401610c72565b600081815260096020526040902060018101546001600160a01b0316336001600160a01b0316146119755760018101546001600160a01b03166000908152600d6020526040902054421015611878576005546008546001838101546001600160a01b039283169263782d6fe1929116906117829043613c07565b6040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440160206040518083038186803b1580156117c657600080fd5b505afa1580156117da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fe9190613c1e565b6001600160601b03161080156118275750600e546001600160a01b0316336001600160a01b0316145b6118735760405162461bcd60e51b815260206004820152601c60248201527f63616e63656c3a2077686974656c69737465642070726f706f736572000000006044820152606401610c72565b611975565b6005546008546001838101546001600160a01b039283169263782d6fe1929116906118a39043613c07565b6040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440160206040518083038186803b1580156118e757600080fd5b505afa1580156118fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191f9190613c1e565b6001600160601b0316106119755760405162461bcd60e51b815260206004820181905260248201527f63616e63656c3a2070726f706f7365722061626f7665207468726573686f6c646044820152606401610c72565b600c8101805460ff1916600117905560005b6003820154811015611b5057611b3e8260030182815481106119ab576119ab613c47565b6000918252602090912001546004840180546001600160a01b0390921691849081106119d9576119d9613c47565b90600052602060002001548460050184815481106119f9576119f9613c47565b906000526020600020018054611a0e90613bcc565b80601f0160208091040260200160405190810160405280929190818152602001828054611a3a90613bcc565b8015611a875780601f10611a5c57610100808354040283529160200191611a87565b820191906000526020600020905b815481529060010190602001808311611a6a57829003601f168201915b5050505050856006018581548110611aa157611aa1613c47565b906000526020600020018054611ab690613bcc565b80601f0160208091040260200160405190810160405280929190818152602001828054611ae290613bcc565b8015611b2f5780601f10611b0457610100808354040283529160200191611b2f565b820191906000526020600020905b815481529060010190602001808311611b1257829003601f168201915b50505050508660020154612f12565b80611b4881613c5d565b915050611987565b5060405182907f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c90600090a25050565b333014611b9f5760405162461bcd60e51b8152600401610c7290613b95565b42601554611bad9190613af3565b8110611bf45760405162461bcd60e51b81526020600482015260166024820152750caf0e0d2e4c2e8d2dedc40caf0c6cacac8e640dac2f60531b6044820152606401610c72565b6001600160a01b0382166000818152600d6020908152604091829020849055815192835282018390527f4e7b7545bc5744d0e30425959f4687475774b6c7edad77d24cb51c7d967d45159101610eba565b333014611c645760405162461bcd60e51b8152600401610c7290613b95565b601080549082905560408051828152602081018490527f2a61b867418a359864adca8bb250ea65ee8bd41dbfd0279198d8e7552d4a27c29101610eba565b81337fb8e138887d0aa13bab447e82de9d5c1777041ecd21ca36ba824ff1e6c07ddda483611cd1838583612c90565b6040805160ff90931683526001600160601b039091166020830152606090820181905260009082015260800160405180910390a35050565b83337fb8e138887d0aa13bab447e82de9d5c1777041ecd21ca36ba824ff1e6c07ddda485611d38838583612c90565b8686604051611d4a9493929190613c78565b60405180910390a350505050565b333014611d775760405162461bcd60e51b8152600401610c7290613b95565b601380549082905560408051828152602081018490527f8cb5451eee8feb516cec9cd600201bbc31a30886d70c841a085a3fa69a4294d19101610eba565b333014611dd45760405162461bcd60e51b8152600401610c7290613b95565b600180549082905560408051828152602081018490527fa74554b0f53da47d07ec571d712428b3720460f54f81375fbcf78f6b5f72e7ed9101610eba565b333014611e315760405162461bcd60e51b8152600401610c7290613b95565b600e80546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f80a07e73e552148844a9c216d9724212d609cfa54e9c1a2e97203bdd2c4ad3419101610eba565b333014611eaa5760405162461bcd60e51b8152600401610c7290613b95565b600f80549082905560408051828152602081018490527f80a384652af83fc00bfd40ef94edda7ede83e7db39931b2c889821573f314e239101610eba565b60125460ff1615611f3b5760405162461bcd60e51b815260206004820152601860248201527f616c7265616479206265656e20696e697469616c697a656400000000000000006044820152606401610c72565b600880546001600160a01b0319166001600160a01b0392909216919091179055619d8060045561335460035569d3c21bcecceda10000006005556202a300600c5560006007556a084595161401484a00000060019081556a21165458500521280000006002556119aa600f5561a8c06010556a01a784379d99db420000006013556146506014556301e133806015556012805460ff19169091179055565b6004611fe482611516565b6007811115611ff557611ff5613671565b146120425760405162461bcd60e51b815260206004820152601f60248201527f63616e206f6e6c792062652071756575656420696620737563636565646564006044820152606401610c72565b6000818152600960205260408120600e8101549091906120629042613af3565b905060005b600383015481101561234d57600b600084600301838154811061208c5761208c613c47565b6000918252602090912001546004860180546001600160a01b0390921691859081106120ba576120ba613c47565b90600052602060002001548660050185815481106120da576120da613c47565b906000526020600020018760060186815481106120f9576120f9613c47565b9060005260206000200187604051602001612118959493929190613d62565b60408051601f198184030181529181528151602092830120835290820192909252016000205460ff161561218e5760405162461bcd60e51b815260206004820152601760248201527f70726f706f73616c20616c7265616479207175657565640000000000000000006044820152606401610c72565b61233a8360030182815481106121a6576121a6613c47565b6000918252602090912001546004850180546001600160a01b0390921691849081106121d4576121d4613c47565b90600052602060002001548560050184815481106121f4576121f4613c47565b90600052602060002001805461220990613bcc565b80601f016020809104026020016040519081016040528092919081815260200182805461223590613bcc565b80156122825780601f1061225757610100808354040283529160200191612282565b820191906000526020600020905b81548152906001019060200180831161226557829003601f168201915b505050505086600601858154811061229c5761229c613c47565b9060005260206000200180546122b190613bcc565b80601f01602080910402602001604051908101604052809291908181526020018280546122dd90613bcc565b801561232a5780601f106122ff5761010080835404028352916020019161232a565b820191906000526020600020905b81548152906001019060200180831161230d57829003601f168201915b50505050508688600e0154612fac565b508061234581613c5d565b915050612067565b506002820181905560405181815283907f9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda28929060200160405180910390a2505050565b3330146123ae5760405162461bcd60e51b8152600401610c7290613b95565b600280549082905560408051828152602081018490527fc2adf06da6765dba7faaccde4c0ce3f91c35dd3390e7f0b6bc2844202c9fa9529101610eba565b6000600154600014156124365760405162461bcd60e51b8152602060048201526012602482015271436861726c6965206e6f742061637469766560701b6044820152606401610c72565b6005546008546001600160a01b031663782d6fe133612456600143613c07565b6040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440160206040518083038186803b15801561249a57600080fd5b505afa1580156124ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124d29190613c1e565b6001600160601b03161015806124ec57506124ec3361069c565b6125385760405162461bcd60e51b815260206004820152601e60248201527f766f7465732062656c6f772070726f706f73616c207468726573686f6c6400006044820152606401610c72565b8551875114801561254a575084518751145b8015612557575083518751145b6125a35760405162461bcd60e51b815260206004820152601a60248201527f696e666f726d6174696f6e206172697479206d69736d617463680000000000006044820152606401610c72565b86516125e85760405162461bcd60e51b81526020600482015260146024820152736d7573742070726f7669646520616374696f6e7360601b6044820152606401610c72565b600a8751111561262d5760405162461bcd60e51b815260206004820152601060248201526f746f6f206d616e7920616374696f6e7360801b6044820152606401610c72565b336000908152600a6020526040902054801561271657600061264e82611516565b9050600181600781111561266457612664613671565b14156126b25760405162461bcd60e51b815260206004820152601e60248201527f6f6e65206c6976652070726f706f73616c207065722070726f706f73657200006044820152606401610c72565b60008160078111156126c6576126c6613671565b14156127145760405162461bcd60e51b815260206004820152601e60248201527f6f6e65206c6976652070726f706f73616c207065722070726f706f73657200006044820152606401610c72565b505b6007805490600061272683613c5d565b9190505550600060405180610220016040528060075481526020016127483390565b6001600160a01b03168152602001600081526020018a8152602001898152602001888152602001878152602001600354436127839190613af3565b8152602001600454600354436127999190613af3565b6127a39190613af3565b815260200160008152602001600081526020016000815260200160001515815260200160001515815260200185151581526020016001548152602001600c5481525090508380156127fa57506127f83361069c565b155b1561282c574360e08201819052600f5461281391613af3565b6101008201526002546101e08201526010546102008201525b6128353361069c565b15612876576013546101e08201526014546128509043613af3565b60e08201526004546014546128659043613af3565b61286f9190613af3565b6101008201525b805160009081526009602090815260409182902083518155818401516001820180546001600160a01b0319166001600160a01b03909216919091179055918301516002830155606083015180518493926128d792600385019291019061309d565b50608082015180516128f3916004840191602090910190613102565b5060a0820151805161290f91600584019160209091019061313d565b5060c0820151805161292b916006840191602090910190613196565b5060e08281015160078301556101008084015160088401556101208401516009840155610140840151600a80850191909155610160850151600b850155610180850151600c850180546101a08801516101c089015161ffff1990921693151561ff0019169390931792151585029290921762ff0000191662010000921515929092029190911790556101e0850151600d85015561020090940151600e9093019290925583516020808601516001600160a01b0316600090815294905260409384902055830151835191840151925190923392917f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e091612a33918f918f918f918f918f90613d9b565b60405180910390a45198975050505050505050565b333014612a675760405162461bcd60e51b8152600401610c7290613b95565b600c80549082905560408051828152602081018490527fed0229422af39d4d7d33f7a27d31d6f5cb20ec628293da58dd6e8a528ed466be9101610eba565b6005612ab082611516565b6007811115612ac157612ac1613671565b14612b0e5760405162461bcd60e51b815260206004820152601c60248201527f63616e206f6e6c792062652065786563276420696620717565756564000000006044820152606401610c72565b6000818152600960205260408120600c8101805461ff001916610100179055905b6003820154811015612c6057306001600160a01b0316630825f38f836004018381548110612b5f57612b5f613c47565b9060005260206000200154846003018481548110612b7f57612b7f613c47565b6000918252602090912001546004860180546001600160a01b039092169186908110612bad57612bad613c47565b9060005260206000200154866005018681548110612bcd57612bcd613c47565b90600052602060002001876006018781548110612bec57612bec613c47565b9060005260206000200188600201546040518763ffffffff1660e01b8152600401612c1b959493929190613d62565b6000604051808303818588803b158015612c3457600080fd5b505af1158015612c48573d6000803e3d6000fd5b50505050508080612c5890613c5d565b915050612b2f565b5060405182907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050565b60006001612c9d84611516565b6007811115612cae57612cae613671565b14612cee5760405162461bcd60e51b815260206004820152601060248201526f1d9bdd1a5b99c81a5cc818db1bdcd95960821b6044820152606401610c72565b60028260ff161115612d365760405162461bcd60e51b8152602060048201526011602482015270696e76616c696420766f7465207479706560781b6044820152606401610c72565b6000838152600960209081526040808320601183528184206001600160a01b0389168552909252909120805460ff1615612da85760405162461bcd60e51b81526020600482015260136024820152721d9bdd195c88185b1c9958591e481d9bdd1959606a1b6044820152606401610c72565b600854600783015460405163782d6fe160e01b81526000926001600160a01b03169163782d6fe191612df2918b916004016001600160a01b03929092168252602082015260400190565b60206040518083038186803b158015612e0a57600080fd5b505afa158015612e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e429190613c1e565b905060ff8516612e6f57806001600160601b031683600a0154612e659190613af3565b600a840155612ec9565b8460ff1660011415612e9e57806001600160601b03168360090154612e949190613af3565b6009840155612ec9565b8460ff1660021415612ec957806001600160601b031683600b0154612ec39190613af3565b600b8401555b81546001600160601b03821662010000026dffffffffffffffffffffffff00001960ff88166101000261ffff199093169290921760011791909116179091559150509392505050565b60008585858585604051602001612f2d959493929190613a91565b60408051601f1981840301815282825280516020918201206000818152600b909252919020805460ff1916905591506001600160a01b0387169082907f2fffc091a501fd91bfbff27141450d3acb40fb8e6d8382b243ec7a812a3aaf8790612f9c908990899089908990613b58565b60405180910390a3505050505050565b6000612fb88242613af3565b831015612ffd5760405162461bcd60e51b815260206004820152601360248201527236bab9ba1039b0ba34b9b33c903232b630bc9760691b6044820152606401610c72565b60008787878787604051602001613018959493929190613a91565b60408051601f1981840301815282825280516020918201206000818152600b909252919020805460ff1916600117905591506001600160a01b0389169082907f76e2796dc3a81d57b0e8504b647febcbeeb5f4af818e164f11eef8131a6a763f9061308a908b908b908b908b90613b58565b60405180910390a3979650505050505050565b8280548282559060005260206000209081019282156130f2579160200282015b828111156130f257825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906130bd565b506130fe9291506131ef565b5090565b8280548282559060005260206000209081019282156130f2579160200282015b828111156130f2578251825591602001919060010190613122565b82805482825590600052602060002090810192821561318a579160200282015b8281111561318a578251805161317a918491602090910190613204565b509160200191906001019061315d565b506130fe929150613277565b8280548282559060005260206000209081019282156131e3579160200282015b828111156131e357825180516131d3918491602090910190613204565b50916020019190600101906131b6565b506130fe929150613294565b5b808211156130fe57600081556001016131f0565b82805461321090613bcc565b90600052602060002090601f01602090048101928261323257600085556130f2565b82601f1061324b57805160ff19168380011785556130f2565b828001600101855582156130f257918201828111156130f2578251825591602001919060010190613122565b808211156130fe57600061328b82826132b1565b50600101613277565b808211156130fe5760006132a882826132b1565b50600101613294565b5080546132bd90613bcc565b6000825580601f106132cd575050565b601f0160209004906000526020600020908101906132eb91906131ef565b50565b60006020828403121561330057600080fd5b5035919050565b60005b8381101561332257818101518382015260200161330a565b83811115613331576000848401525b50505050565b6000815180845261334f816020860160208601613307565b601f01601f19169290920160200192915050565b6020815260006133766020830184613337565b9392505050565b80356001600160a01b038116811461339457600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156133d8576133d8613399565b604052919050565b600082601f8301126133f157600080fd5b813567ffffffffffffffff81111561340b5761340b613399565b61341e601f8201601f19166020016133af565b81815284602083860101111561343357600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561346857600080fd5b6134718661337d565b945060208601359350604086013567ffffffffffffffff8082111561349557600080fd5b6134a189838a016133e0565b945060608801359150808211156134b757600080fd5b506134c4888289016133e0565b95989497509295608001359392505050565b6000602082840312156134e857600080fd5b6133768261337d565b600081518084526020808501945080840160005b8381101561352a5781516001600160a01b031687529582019590820190600101613505565b509495945050505050565b600081518084526020808501945080840160005b8381101561352a57815187529582019590820190600101613549565b600081518084526020808501808196508360051b8101915082860160005b858110156135ad57828403895261359b848351613337565b98850198935090840190600101613583565b5091979650505050505050565b6080815260006135cd60808301876134f1565b82810360208401526135df8187613535565b905082810360408401526135f38186613565565b905082810360608401526136078185613565565b979650505050505050565b803560ff8116811461339457600080fd5b600080600080600060a0868803121561363b57600080fd5b8535945061364b60208701613612565b935061365960408701613612565b94979396509394606081013594506080013592915050565b634e487b7160e01b600052602160045260246000fd5b60208101600883106136a957634e487b7160e01b600052602160045260246000fd5b91905290565b600080604083850312156136c257600080fd5b6136cb8361337d565b946020939093013593505050565b600080604083850312156136ec57600080fd5b823591506136fc60208401613612565b90509250929050565b6000806040838503121561371857600080fd5b823591506136fc6020840161337d565b6000806000806060858703121561373e57600080fd5b8435935061374e60208601613612565b9250604085013567ffffffffffffffff8082111561376b57600080fd5b818701915087601f83011261377f57600080fd5b81358181111561378e57600080fd5b8860208285010111156137a057600080fd5b95989497505060200194505050565b600067ffffffffffffffff8211156137c9576137c9613399565b5060051b60200190565b600082601f8301126137e457600080fd5b813560206137f96137f4836137af565b6133af565b82815260059290921b8401810191818101908684111561381857600080fd5b8286015b8481101561383a5761382d8161337d565b835291830191830161381c565b509695505050505050565b600082601f83011261385657600080fd5b813560206138666137f4836137af565b82815260059290921b8401810191818101908684111561388557600080fd5b8286015b8481101561383a5780358352918301918301613889565b600082601f8301126138b157600080fd5b813560206138c16137f4836137af565b82815260059290921b840181019181810190868411156138e057600080fd5b8286015b8481101561383a57803567ffffffffffffffff8111156139045760008081fd5b6139128986838b01016133e0565b8452509183019183016138e4565b600082601f83011261393157600080fd5b813560206139416137f4836137af565b82815260059290921b8401810191818101908684111561396057600080fd5b8286015b8481101561383a57803567ffffffffffffffff8111156139845760008081fd5b6139928986838b01016133e0565b845250918301918301613964565b8035801515811461339457600080fd5b60008060008060008060c087890312156139c957600080fd5b863567ffffffffffffffff808211156139e157600080fd5b6139ed8a838b016137d3565b97506020890135915080821115613a0357600080fd5b613a0f8a838b01613845565b96506040890135915080821115613a2557600080fd5b613a318a838b016138a0565b95506060890135915080821115613a4757600080fd5b613a538a838b01613920565b94506080890135915080821115613a6957600080fd5b50613a7689828a016133e0565b925050613a8560a088016139a0565b90509295509295509295565b60018060a01b038616815284602082015260a060408201526000613ab860a0830186613337565b8281036060840152613aca8186613337565b9150508260808301529695505050505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115613b0657613b06613add565b500190565b6001600160e01b0319831681528151600090613b2e816004850160208701613307565b919091016004019392505050565b60008251613b4e818460208701613307565b9190910192915050565b848152608060208201526000613b716080830186613337565b8281036040840152613b838186613337565b91505082606083015295945050505050565b60208082526017908201527f6d75737420636f6d652066726f6d2074686520676f762e000000000000000000604082015260600190565b600181811c90821680613be057607f821691505b60208210811415613c0157634e487b7160e01b600052602260045260246000fd5b50919050565b600082821015613c1957613c19613add565b500390565b600060208284031215613c3057600080fd5b81516001600160601b038116811461337657600080fd5b634e487b7160e01b600052603260045260246000fd5b6000600019821415613c7157613c71613add565b5060010190565b60ff851681526001600160601b038416602082015260606040820152816060820152818360808301376000818301608090810191909152601f909201601f191601019392505050565b8054600090600181811c9080831680613cdb57607f831692505b6020808410821415613cfd57634e487b7160e01b600052602260045260246000fd5b838852818015613d145760018114613d2857613d56565b60ff19861689830152604089019650613d56565b876000528160002060005b86811015613d4e5781548b8201850152908501908301613d33565b8a0183019750505b50505050505092915050565b60018060a01b038616815284602082015260a060408201526000613d8960a0830186613cc1565b8281036060840152613aca8186613cc1565b60c081526000613dae60c08301896134f1565b8281036020840152613dc08189613535565b90508281036040840152613dd48188613565565b90508281036060840152613de88187613565565b905084608084015282810360a0840152613e028185613337565b999850505050505050505056fe"), + ("0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec", "PoolExercise", "6101c06040523480156200001257600080fd5b50604051620030713803806200307183398101604081905262000035916200016a565b6001600160a01b038681166101005285811660805284811660a05283811660c052821660e052600f81900b61012052858585858585620000846000808062000101602090811b6200011917901c565b6101408181525050620000a660016000806200010160201b620001191760201c565b6101608181525050620000c860026000806200010160201b620001191760201c565b6101808181525050620000ea60036000806200010160201b620001191760201c565b6101a05250620002319a5050505050505050505050565b600081600f0b6080846001600160401b0316901b60f88660078111156200012c576200012c620001f4565b6200013992911b6200020a565b6200014591906200020a565b949350505050565b80516001600160a01b03811681146200016557600080fd5b919050565b60008060008060008060c087890312156200018457600080fd5b6200018f876200014d565b95506200019f602088016200014d565b9450620001af604088016200014d565b9350620001bf606088016200014d565b9250620001cf608088016200014d565b915060a087015180600f0b8114620001e657600080fd5b809150509295509295509295565b634e487b7160e01b600052602160045260246000fd5b600082198211156200022c57634e487b7160e01b600052601160045260246000fd5b500190565b60805160a05160c05160e05161010051610120516101405161016051610180516101a051612d6f6200030260003960008181610e1c015261137b015260008181610e420152818161135101526113f4015260008181611327015281816114b801526122c90152600081816112fe015281816113cb0152818161148f015281816114e101526122ef0152600081816103a8015281816107ed0152610cda0152600050506000818161176601526117b201526000610485015260008181611964015261212c015260005050612d6f6000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063477130981461003b578063b50e7ee314610050575b600080fd5b61004e610049366004612986565b610063565b005b61004e61005e3660046129c7565b610109565b336001600160a01b038416146100f9576001600160a01b03831660009081527f1799cf914cb0cb442ca7c7ac709ee40d0cb89e87351dc08d517fbda27d50c68c6020908152604080832033845290915290205460ff166100f95760405162461bcd60e51b815260206004820152600c60248201526b1b9bdd08185c1c1c9bdd995960a21b60448201526064015b60405180910390fd5b61010483838361015f565b505050565b6101156000838361015f565b5050565b600081600f0b60808467ffffffffffffffff16901b60f8866007811115610142576101426129e9565b61014d92911b612a15565b6101579190612a15565b949350505050565b608082901c8260006001600160a01b0386161560f883901c600481600781111561018b5761018b6129e9565b14806101a8575060068160078111156101a6576101a66129e9565b145b6101e35760405162461bcd60e51b815260206004820152600c60248201526b696e76616c6964207479706560a01b60448201526064016100f0565b8115806101f95750428567ffffffffffffffff16105b6102335760405162461bcd60e51b815260206004820152600b60248201526a1b9bdd08195e1c1a5c995960aa1b60448201526064016100f0565b6004816007811115610247576102476129e9565b149250506000610262600080516020612d1a83398151915290565b9050600061026f826104c0565b9050428667ffffffffffffffff16101561029a576102978267ffffffffffffffff8816610526565b90505b82806102be5750836102b45784600f0b81600f0b126102be565b84600f0b81600f0b135b6102f45760405162461bcd60e51b81526020600482015260076024820152666e6f742049544d60c81b60448201526064016100f0565b6000841561033a5785600f0b82600f0b1315610335576103328861032984610320600f82900b8b61061e565b600f0b90610659565b600f0b906106b1565b90505b610367565b85600f0b82600f0b12156103675761036461035d89610329600f8a900b8661061e565b8490610719565b90505b6000841561038c5761037b89838c89610754565b6103859082612a15565b9050610454565b6103978b8b8b6108cb565b600082156103ff576103d58c6103d07f0000000000000000000000000000000000000000000000000000000000000000600f0b866106b1565b610a5d565b90506103e18183612a15565b91506103ff8c6103f089610a8c565b6103fa8487612a2d565b610ae1565b604080518c8152602081018c9052908101849052606081018290526001600160a01b038d16907f31939b125e073bbdbf69ac6eb0cb59489894a9bea509d658589af5917b53cca19060800160405180910390a2505b610474898361046e6104678a6000610bb1565b8c8c610119565b89610be4565b61047e9082612a15565b90506104b37f00000000000000000000000000000000000000000000000000000000000000006104ad88610e13565b83610e67565b5050505050505050505050565b60004282600c015414156104de576104d88242610e82565b92915050565b6104e782610eb0565b90506104f38242610e82565b600f0b61050557610505824283610fd3565b42600c830155610516826001611051565b610521826000611051565b919050565b600080610535610e1084612a5a565b600881901c6000818152601287016020526040812054929350909160ff84169190821b821c90610568620e100042612a5a565b90505b811580156105795750808411155b156105a65760128801600061058d86612a7c565b955085815260200190815260200160002054915061056b565b600060805b80156105d25783811c156105ca576105c38183612a15565b93811c9391505b60011c6105ab565b5060118901600060018360086105e88a84612a15565b6105f392911b612a2d565b6105fd9190612a2d565b8152602081019190915260400160002054600f0b9998505050505050505050565b6000600f82810b9084900b0360016001607f1b03198112801590610649575060016001607f1b038113155b61065257600080fd5b9392505050565b600081600f0b6000141561066c57600080fd5b600082600f0b604085600f0b901b8161068757610687612a44565b05905060016001607f1b03198112801590610649575060016001607f1b0381131561065257600080fd5b6000816106c0575060006104d8565b600083600f0b12156106d157600080fd5b600f83900b6001600160801b038316810260401c90608084901c026001600160c01b0381111561070057600080fd5b60401b811981111561071157600080fd5b019392505050565b600080610737838560030160149054906101000a900460ff166110e1565b9050610157818560030160159054906101000a900460ff166110f7565b60008281527fb31c2c74f86ca3ce94d901f5f5bbe66f7161eec2f7b5aa0b75a86371436424eb602052604081205b85156108c25760006107a9600161079884611112565b6107a29190612a2d565b839061111c565b905060006107b78287611128565b9050878111156107c45750865b600080881561084657896107d8848b612a97565b6107e29190612a5a565b9150610815846103d07f0000000000000000000000000000000000000000000000000000000000000000600f0b856106b1565b90506108218187612a15565b955061082d828a612a2d565b98506108468461083c89610a8c565b6103fa8486612a2d565b610850838b612a2d565b99506001600160a01b0384167f31939b125e073bbdbf69ac6eb0cb59489894a9bea509d658589af5917b53cca189856108898587612a2d565b604080519384526020840192909252908201526060810184905260800160405180910390a26108b98489856108cb565b50505050610782565b50949350505050565b6001600160a01b03831661092d5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b60648201526084016100f0565b61095b3384600061093d866111db565b610946866111db565b60405180602001604052806000815250611226565b60008281527f1799cf914cb0cb442ca7c7ac709ee40d0cb89e87351dc08d517fbda27d50c68b602090815260408083206001600160a01b038716845291829052909120548211156109fc5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015264616e63657360d81b60648201526084016100f0565b6001600160a01b03841660008181526020838152604080832080548790039055805187815291820186905291929133917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a450505050565b600080610a6984611762565b9050612710610a788285612a97565b610a829190612a5a565b6101579084612a2d565b600081610ab157600080516020612d1a833981519152546001600160a01b03166104d8565b50507fbbd6af8edd89d04327b00c29df7f272b9b1ae01bf6d9c54a784f935706df52ec546001600160a01b031690565b80610aeb57505050565b60405163a9059cbb60e01b81526001600160a01b0384811660048301526024820183905283169063a9059cbb90604401602060405180830381600087803b158015610b3557600080fd5b505af1158015610b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6d9190612ab6565b6101045760405162461bcd60e51b8152602060048201526015602482015274115490cc8c081d1c985b9cd9995c8819985a5b1959605a1b60448201526064016100f0565b60008215610bcf5781610bc5576005610bc8565b60045b90506104d8565b81610bdb576007610652565b60069392505050565b60008281527fb31c2c74f86ca3ce94d901f5f5bbe66f7161eec2f7b5aa0b75a86371436424eb60205260408120835b8615610e09576000610c3a6001610c2985611112565b610c339190612a2d565b849061111c565b90506000610c488288611128565b905088811115610c555750875b600089610c62838b612a97565b610c6c9190612a5a565b9050610c78818a612a2d565b9850610c84828b612a2d565b9950600087610cc35781610cb4610c9f600f88900b866106b1565b600080516020612d1a83398151915290610719565b610cbe9190612a2d565b610ccd565b610ccd8284612a2d565b90506000610d02856103d07f0000000000000000000000000000000000000000000000000000000000000000600f0b856106b1565b9050610d0e8189612a15565b975082610d2a600080516020612d1a833981519152878c61182c565b15610d5457610d4386610d3d8486612a2d565b8c611869565b610d4d8282612a15565b9050610d7d565b610d7086610d618c610e13565b610d6b8587612a2d565b610e67565b610d7a8382612a15565b90505b610d97600080516020612d1a833981519152878c8461192c565b610da2868c876108cb565b6001600160a01b0386167f69a2ef6bf9e7ff92cbf1b71963ba1751b1abe8f99e3b3aae2ab99e416df614938c610dd88587612a2d565b60408051928352602083019190915281018890526060810185905260800160405180910390a2505050505050610c13565b5050949350505050565b600081610e40577f00000000000000000000000000000000000000000000000000000000000000006104d8565b7f000000000000000000000000000000000000000000000000000000000000000092915050565b61010483838360405180602001604052806000815250611a6c565b60006011830181610e95610e1085612a5a565b8152602081019190915260400160002054600f0b9392505050565b6000808260030160009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0357600080fd5b505afa158015610f17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3b9190612ad8565b905060008360020160009054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f8f57600080fd5b505afa158015610fa3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc79190612ad8565b90506101578282611b93565b6000610fe1610e1084612a5a565b6000818152601186016020526040902080546001600160801b0319166001600160801b038516179055905061101a60ff80831690612a2d565b6001901b846012016000600884901c815260200190815260200160002060008282546110469190612a15565b909155505050505050565b80151560009081526013830160205260409020805415806110725750805442105b1561107c57505050565b60006110888484611c2e565b90506110c384826110bd6110b286600101546110ad898b611c9890919063ffffffff16565b6110e1565b600f86900b90611cc6565b86611cf9565b50501515600090815260139091016020526040812081815560010155565b6000610652836110f284600a612bd5565b611d76565b600061065261110783600a612bd5565b600f85900b906106b1565b60006104d8825490565b60006106528383611dad565b60006001600160a01b0383166111945760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084016100f0565b7f1799cf914cb0cb442ca7c7ac709ee40d0cb89e87351dc08d517fbda27d50c68b6000928352602090815260408084206001600160a01b0395909516845293905250205490565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061121557611215612be4565b602090810291909101015292915050565b611234868686868686611e33565b600080516020612d1a83398151915260005b845181101561175857600085828151811061126357611263612be4565b60200260200101519050600085838151811061128157611281612be4565b60200260200101519050806000141561129b575050611746565b6001600160a01b0389166112b8576112b66015850183612011565b505b6001600160a01b0388161580156112e857506000828152600080516020612cfa8339815191526020526040902054155b156112fc576112fa601585018361201d565b505b7f000000000000000000000000000000000000000000000000000000000000000082148061134957507f000000000000000000000000000000000000000000000000000000000000000082145b8061137357507f000000000000000000000000000000000000000000000000000000000000000082145b8061139d57507f000000000000000000000000000000000000000000000000000000000000000082145b1561148d576001600160a01b038916158015906113c257506001600160a01b03881615155b1561148d5760007f000000000000000000000000000000000000000000000000000000000000000083148061141657507f000000000000000000000000000000000000000000000000000000000000000083145b6001600160a01b038b166000908152600d870160209081526040808320841515845290915290205490915042906114509062015180612a15565b1061148b5760405162461bcd60e51b815260206004820152600b60248201526a1b1a5c481b1bd8dac80c5960aa1b60448201526064016100f0565b505b7f00000000000000000000000000000000000000000000000000000000000000008214806114da57507f000000000000000000000000000000000000000000000000000000000000000082145b15611682577f00000000000000000000000000000000000000000000000000000000000000008214600061150e8683612029565b90506001600160a01b038b161561163857600061152b8c86611128565b9050818111801561154557506115418285612a15565b8111155b156115dd576001600160a01b038c166000908152601488016020908152604080832086151580855260138c01845282852054855290835281842090845290915290205484906115949083612a2d565b10156115d25760405162461bcd60e51b815260206004820152600d60248201526c496e7375662062616c616e636560981b60448201526064016100f0565b6115dd878d85612043565b6001600160a01b038b161561163657611611878d858c8a8151811061160457611604612be4565b602002602001015161192c565b611636878c858c8a8151811061162957611629612be4565b60200260200101516120f4565b505b6001600160a01b038a161561167f5760006116538b86611128565b905081811115801561166d57508161166b8583612a15565b115b1561167d5761167d878c85612218565b505b50505b60f882901c826001600160a01b038b16158015906116a857506001600160a01b038a1615155b80156116e0575060058260078111156116c3576116c36129e9565b14806116e0575060078260078111156116de576116de6129e9565b145b1561174157600060058360078111156116fb576116fb6129e9565b1490506000816117225761171d611716600f85900b876106b1565b8990610719565b611724565b845b9050611732888e848461192c565b61173e888d84846120f4565b50505b505050505b8061175081612a7c565b915050611246565b5050505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031615610521576040516303793c8d60e11b81526001600160a01b0383811660048301527f000000000000000000000000000000000000000000000000000000000000000016906306f2791a9060240160206040518083038186803b1580156117f457600080fd5b505afa158015611808573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d89190612ad8565b6001600160a01b0382166000908152600e840160209081526040808320841515845290915281205480158061186057504281115b95945050505050565b600080516020612d1a83398151915261188b84611885846122c0565b85610e67565b60006101048061189b8142612a5a565b6118a59190612a97565b6118af9190612a15565b6001600160a01b03861660009081526014840160209081526040808320848452825280832087151584529091528120805492935086929091906118f3908490612a15565b90915550508215156000908152601383016020526040812060018101805491928792611920908490612a15565b90915550505550505050565b6001600160a01b03808416600090815260178601602090815260408083208615158452825280832054601889019092529091205490917f00000000000000000000000000000000000000000000000000000000000000001663edaf7d5b863087866119978982612a2d565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015290151560448401526064830152608482015260a4810184905260c401600060405180830381600087803b1580156119fa57600080fd5b505af1158015611a0e573d6000803e3d6000fd5b505050508282611a1e9190612a2d565b6001600160a01b038616600090815260178801602090815260408083208815158452909152902055611a508382612a2d565b9315156000908152601890960160205250506040909320555050565b6001600160a01b038416611acc5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016100f0565b611aeb33600086611adc876111db565b611ae5876111db565b86611226565b60008381527f1799cf914cb0cb442ca7c7ac709ee40d0cb89e87351dc08d517fbda27d50c68b602090815260408083206001600160a01b0388168452918290528220805491928592611b3e908490612a15565b909155505060408051858152602081018590526001600160a01b0387169160009133917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45050505050565b600081611b9f57600080fd5b600080841215611bb457836000039350600190505b6000831215611bc65760009290920391155b6000611bd28585612314565b90508115611c00576001607f1b816001600160801b03161115611bf457600080fd5b60000391506104d89050565b60016001607f1b03816001600160801b03161115611c1d57600080fd5b91506104d89050565b505092915050565b600080611c4b83611c40576001611c43565b60005b600080610119565b831515600090815260138601602052604090206001015490915061015790600080516020612cfa83398151915260008481526020919091526040902054611c929190612a2d565b6110ad86865b600081611cb3576003830154600160a81b900460ff16610652565b505060030154600160a01b900460ff1690565b6000600f83810b9083900b0160016001607f1b03198112801590610649575060016001607f1b0381131561065257600080fd5b6000611d058583612476565b90506000611d16868387878761248f565b9050611d23868285612595565b60408051600f83810b825287810b602083015286900b818301529051841515917f4e23621c6f591f14bf9505cb8326b45af9dc6c5569fd608de2a7a2ddd6146b2e919081900360600190a2505050505050565b600081611d8257600080fd5b6000611d8e8484612314565b905060016001607f1b036001600160801b038216111561065257600080fd5b81546000908210611e0b5760405162461bcd60e51b815260206004820152602260248201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604482015261647360f01b60648201526084016100f0565b826000018281548110611e2057611e20612be4565b9060005260206000200154905092915050565b836001600160a01b0316856001600160a01b031614612009576001600160a01b0385811660009081527fb31c2c74f86ca3ce94d901f5f5bbe66f7161eec2f7b5aa0b75a86371436424ec602052604080822092871682528120600080516020612cfa833981519152927fb31c2c74f86ca3ce94d901f5f5bbe66f7161eec2f7b5aa0b75a86371436424eb929091905b87518110156104b3576000878281518110611edf57611edf612be4565b602002602001015190506000811115611ff6576000898381518110611f0657611f06612be4565b6020026020010151905060006001600160a01b03168c6001600160a01b03161415611f545760008181526020889052604081208054849290611f49908490612a15565b90915550611f8a9050565b81611f5f8d83611128565b1415611f8a576000818152602087905260409020611f7d908d6125ec565b50611f88858261201d565b505b6001600160a01b038b16611fc15760008181526020889052604081208054849290611fb6908490612a2d565b90915550611ff49050565b611fcb8b82611128565b611ff4576000818152602087905260409020611fe7908c612601565b50611ff28482612011565b505b505b508061200181612a7c565b915050611ec2565b505050505050565b60006106528383612612565b60006106528383612661565b60008161203a578260040154610652565b50506005015490565b6001600160a01b03821661205657600080fd5b8015156000908152600f8401602090815260408083206010870190925290912061208184838361274c565b61208c575050505050565b6001600160a01b0393841660008181526020838152604080832080549683528184208054978a16808652838620805499909b166001600160a01b0319998a168117909b5599855295909252822080548616909717909655528054821690558254169091555050565b6001600160a01b03808416600090815260178601602090815260408083208615158452825280832054601889019092529091205490917f00000000000000000000000000000000000000000000000000000000000000001663edaf7d5b8630878661215f8982612a15565b6040516001600160e01b031960e088901b1681526001600160a01b03958616600482015294909316602485015290151560448401526064830152608482015260a4810184905260c401600060405180830381600087803b1580156121c257600080fd5b505af11580156121d6573d6000803e3d6000fd5b5050505082826121e69190612a15565b6001600160a01b038616600090815260178801602090815260408083208815158452909152902055611a508382612a15565b6001600160a01b03821661222b57600080fd5b8015156000908152600f8401602090815260408083206010870190925290912061225684838361274c565b15612262575050505050565b60008080526020828152604080832080546001600160a01b0390811680865296845282852080546001600160a01b03199081169a909216998a1790558885529490925282208054841690941790935580528154169092179091555050565b6000816122ed577f00000000000000000000000000000000000000000000000000000000000000006104d8565b7f000000000000000000000000000000000000000000000000000000000000000092915050565b60008161232057600080fd5b60006001600160c01b03841161234b5782604085901b8161234357612343612a44565b049050612462565b60c084811c6401000000008110612364576020918201911c5b620100008110612376576010918201911c5b6101008110612387576008918201911c5b60108110612397576004918201911c5b600481106123a7576002918201911c5b600281106123b6576001820191505b60bf820360018603901c6001018260ff0387901b816123d7576123d7612a44565b0492506001600160801b038311156123ee57600080fd5b608085901c83026001600160801b038616840260c088901c604089901b8281101561241a576001820391505b608084901b92900382811015612431576001820391505b829003608084901c821461244757612447612bfa565b88818161245657612456612a44565b04870196505050505050505b6001600160801b0381111561065257600080fd5b60006124828383612798565b90506106528382846127bf565b600080826124a4576019870154600f0b6124b4565b6019870154600160801b9004600f0b5b905080600f0b600014156124cc57506008860154600f0b5b60405163e101a89b60e01b8152600f87810b600483015286810b602483015285810b604483015282900b6064820152730f6e8ef18fb5bb61d545fee60f779d8aed60408f9063e101a89b9060840160206040518083038186803b15801561253257600080fd5b505af4158015612546573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256a9190612c10565b915067b33333333333333382600f0b121561258b5767b33333333333333391505b5095945050505050565b80156125c5576009830180546001600160801b0384166001600160801b031990911617905542600b840155505050565b6008830180546001600160801b03808516600160801b02911617905542600a840155505050565b6000610652836001600160a01b038416612661565b6000610652836001600160a01b0384165b6000818152600183016020526040812054612659575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104d8565b5060006104d8565b60008181526001830160205260408120548015612742576000612685600183612a2d565b8554909150600090869061269b90600190612a2d565b815481106126ab576126ab612be4565b90600052602060002001549050808660000183815481106126ce576126ce612be4565b6000918252602090912001556126e5826001612a15565b6000828152600188016020526040902055855486908061270757612707612c33565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506104d8565b60009150506104d8565b6001600160a01b0383811660009081526020849052604081205490911615158061015757506000808052602083905260409020546001600160a01b039081169085161490509392505050565b6000816127b3576008830154600160801b9004600f0b610652565b505060090154600f0b90565b600080826127d15784600a01546127d7565b84600b01545b6127e19042612a2d565b905061a8c0811115612800576127f961a8c082612a2d565b9050612809565b83915050610652565b600061281782613840611d76565b9050600061282a85611c40576001611c43565b851515600090815260188901602090815260408083205460138c01835281842060010154858552600080516020612cfa83398151915290935290832054939450926128889161287891612a2d565b6128829084612a2d565b83611d76565b6040805161012081018252600f87810b82528b810b602083015283900b8183015267b333333333333333606082015267e666666666666666608082018190526801000000000000000060a0830181905260c083015260e082015268056fc2a2c515da32ea6101008201529051634916d70d60e01b8152919250730f6e8ef18fb5bb61d545fee60f779d8aed60408f91634916d70d9161292991600401612c49565b60206040518083038186803b15801561294157600080fd5b505af4158015612955573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129799190612c10565b9998505050505050505050565b60008060006060848603121561299b57600080fd5b83356001600160a01b03811681146129b257600080fd5b95602085013595506040909401359392505050565b600080604083850312156129da57600080fd5b50508035926020909101359150565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115612a2857612a286129ff565b500190565b600082821015612a3f57612a3f6129ff565b500390565b634e487b7160e01b600052601260045260246000fd5b600082612a7757634e487b7160e01b600052601260045260246000fd5b500490565b6000600019821415612a9057612a906129ff565b5060010190565b6000816000190483118215151615612ab157612ab16129ff565b500290565b600060208284031215612ac857600080fd5b8151801515811461065257600080fd5b600060208284031215612aea57600080fd5b5051919050565b600181815b80851115612b2c578160001904821115612b1257612b126129ff565b80851615612b1f57918102915b93841c9390800290612af6565b509250929050565b600082612b43575060016104d8565b81612b50575060006104d8565b8160018114612b665760028114612b7057612b8c565b60019150506104d8565b60ff841115612b8157612b816129ff565b50506001821b6104d8565b5060208310610133831016604e8410600b8410161715612baf575081810a6104d8565b612bb98383612af1565b8060001904821115612bcd57612bcd6129ff565b029392505050565b600061065260ff841683612b34565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052600160045260246000fd5b600060208284031215612c2257600080fd5b815180600f0b811461065257600080fd5b634e487b7160e01b600052603160045260246000fd5b6000610120820190508251600f0b82526020830151600f0b60208301526040830151612c7a6040840182600f0b9052565b506060830151612c8f6060840182600f0b9052565b506080830151612ca46080840182600f0b9052565b5060a0830151612cb960a0840182600f0b9052565b5060c0830151612cce60c0840182600f0b9052565b5060e0830151612ce360e0840182600f0b9052565b5061010080840151611c2682850182600f0b905256feb31c2c74f86ca3ce94d901f5f5bbe66f7161eec2f7b5aa0b75a86371436424eabbd6af8edd89d04327b00c29df7f272b9b1ae01bf6d9c54a784f935706df52eb"), + ("0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05", "MainchainGatewayV2", "608060405234801561001057600080fd5b506000805460ff1916905561582e806200002b6000396000f3fe60806040526004361061032d5760003560e01c80639157921c116101a5578063b2975794116100ec578063d547741f11610095578063dafae4081161006f578063dafae4081461096e578063dff525e11461098e578063e400327c146109ae578063e75235b8146109ce5761033c565b8063d547741f14610901578063d55ed10314610921578063d64af2a61461094e5761033c565b8063cdb67444116100c6578063cdb674441461089c578063cdf64a76146108b4578063d19773d2146108d45761033c565b8063b29757941461082f578063b9c362091461085c578063ca15c8731461087c5761033c565b8063a3912ec81161014e578063affed0e011610128578063affed0e0146107cc578063b1a2567e146107e2578063b1d08a03146108025761033c565b8063a3912ec81461033a578063ab7965661461077f578063ac78dfe8146107ac5761033c565b8063994390891161017f57806399439089146107155780639dcc4da314610735578063a217fddf1461076a5761033c565b80639157921c1461068f57806391d14854146106af57806393c5678f146106f55761033c565b806336568abe116102745780635c975abb1161021d5780637de5dedd116101f75780637de5dedd146106115780638456cb59146106265780638f34e3471461063b5780639010d07c1461066f5761033c565b80635c975abb146105ac5780636932be98146105c45780636c1ce670146105f15761033c565b80634d0d66731161024e5780634d0d66731461052f5780634d493f4e1461054f57806359122f6b1461057f5761033c565b806336568abe146104e75780633f4ba83a146105075780634b14557e1461051c5761033c565b80631d4a7210116102d65780632f2ff15d116102b05780632f2ff15d1461049b578063302d12db146104bb5780633644e515146104d25761033c565b80631d4a721014610428578063248a9ca3146104555780632dfdf0b5146104855761033c565b8063180ff1e911610307578063180ff1e9146103d55780631a8e55b0146103e85780631b6e7594146104085761033c565b806301ffc9a71461034457806317ce2dd41461037957806317fcb39b1461039d5761033c565b3661033c5761033a6109e6565b005b61033a6109e6565b34801561035057600080fd5b5061036461035f366004614843565b610a69565b60405190151581526020015b60405180910390f35b34801561038557600080fd5b5061038f60755481565b604051908152602001610370565b3480156103a957600080fd5b506074546103bd906001600160a01b031681565b6040516001600160a01b039091168152602001610370565b61033a6103e33660046148f4565b610aad565b3480156103f457600080fd5b5061033a6104033660046149e6565b610dbd565b34801561041457600080fd5b5061033a610423366004614a52565b610e8f565b34801561043457600080fd5b5061038f610443366004614aec565b603e6020526000908152604090205481565b34801561046157600080fd5b5061038f610470366004614b09565b60009081526072602052604090206001015490565b34801561049157600080fd5b5061038f60765481565b3480156104a757600080fd5b5061033a6104b6366004614b22565b610f64565b3480156104c757600080fd5b5061038f620f424081565b3480156104de57600080fd5b5060775461038f565b3480156104f357600080fd5b5061033a610502366004614b22565b610f8f565b34801561051357600080fd5b5061033a61101b565b61033a61052a366004614b52565b611083565b34801561053b57600080fd5b5061036461054a366004614b7d565b6110e1565b34801561055b57600080fd5b5061036461056a366004614b09565b607a6020526000908152604090205460ff1681565b34801561058b57600080fd5b5061038f61059a366004614aec565b603a6020526000908152604090205481565b3480156105b857600080fd5b5060005460ff16610364565b3480156105d057600080fd5b5061038f6105df366004614b09565b60796020526000908152604090205481565b3480156105fd57600080fd5b5061036461060c366004614c06565b61118c565b34801561061d57600080fd5b5061038f61119f565b34801561063257600080fd5b5061033a611234565b34801561064757600080fd5b5061038f7f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e481565b34801561067b57600080fd5b506103bd61068a366004614c32565b61129c565b34801561069b57600080fd5b5061033a6106aa366004614c54565b6112b4565b3480156106bb57600080fd5b506103646106ca366004614b22565b60009182526072602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561070157600080fd5b5061033a6107103660046149e6565b6115ca565b34801561072157600080fd5b506003546103bd906001600160a01b031681565b34801561074157600080fd5b50610755610750366004614c32565b611696565b60408051928352602083019190915201610370565b34801561077657600080fd5b5061038f600081565b34801561078b57600080fd5b5061038f61079a366004614aec565b603c6020526000908152604090205481565b3480156107b857600080fd5b506103646107c7366004614b09565b61172f565b3480156107d857600080fd5b5061038f60045481565b3480156107ee57600080fd5b5061033a6107fd3660046149e6565b6117ce565b34801561080e57600080fd5b5061038f61081d366004614aec565b60396020526000908152604090205481565b34801561083b57600080fd5b5061084f61084a366004614aec565b61189a565b6040516103709190614ca5565b34801561086857600080fd5b50610755610877366004614c32565b611992565b34801561088857600080fd5b5061038f610897366004614b09565b611a17565b3480156108a857600080fd5b50603754603854610755565b3480156108c057600080fd5b5061033a6108cf366004614aec565b611a2e565b3480156108e057600080fd5b5061038f6108ef366004614aec565b603b6020526000908152604090205481565b34801561090d57600080fd5b5061033a61091c366004614b22565b611a97565b34801561092d57600080fd5b5061038f61093c366004614aec565b603d6020526000908152604090205481565b34801561095a57600080fd5b5061033a610969366004614aec565b611abd565b34801561097a57600080fd5b50610364610989366004614b09565b611b26565b34801561099a57600080fd5b5061033a6109a9366004614cd2565b611bbd565b3480156109ba57600080fd5b5061033a6109c93660046149e6565b611cc7565b3480156109da57600080fd5b50600154600254610755565b60005460ff1615610a315760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064015b60405180910390fd5b6074546001600160a01b03163314610a6757610a4b614802565b338152604080820151349101528051610a65908290611d93565b505b565b60006001600160e01b031982167f5a05180f000000000000000000000000000000000000000000000000000000001480610aa75750610aa78261210a565b92915050565b607154610100900460ff16610ac85760715460ff1615610acc565b303b155b610b3e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610a28565b607154610100900460ff16158015610b60576071805461ffff19166101011790555b610b6b60008d612171565b6075899055610b798b61217b565b610b828a6121dd565b610c29604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b918101919091527fad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a560608201524660808201523060a082015260c00160408051601f198184030181529190528051602090910120607755565b610c338887612238565b5050610c3f87876122f8565b5050610c496123d3565b6000610c558680614da6565b90501115610d1657610c7e610c6a8680614da6565b610c776020890189614da6565b8787612467565b610ca4610c8b8680614da6565b8660005b602002810190610c9f9190614da6565b612666565b610cca610cb18680614da6565b8660015b602002810190610cc59190614da6565b612779565b610cf0610cd78680614da6565b8660025b602002810190610ceb9190614da6565b61288c565b610d16610cfd8680614da6565b8660035b602002810190610d119190614da6565b612a30565b60005b610d266040870187614da6565b9050811015610d9c57610d8a7f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e4610d606040890189614da6565b84818110610d7057610d70614d90565b9050602002016020810190610d859190614aec565b612b43565b80610d9481614e06565b915050610d19565b508015610daf576071805461ff00191690555b505050505050505050505050565b6000805160206157b9833981519152546001600160a01b03163314610e1d5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b82610e7d5760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b610e8984848484612779565b50505050565b6000805160206157b9833981519152546001600160a01b03163314610eef5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b84610f4e5760405162461bcd60e51b815260206004820152602960248201527f4d61696e636861696e4761746577617956323a20717565727920666f7220656d60448201526870747920617272617960b81b6064820152608401610a28565b610f5c868686868686612467565b505050505050565b600082815260726020526040902060010154610f808133612b65565b610f8a8383612b43565b505050565b6001600160a01b038116331461100d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610a28565b6110178282612be5565b5050565b6000805160206157b9833981519152546001600160a01b0316331461107b5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b610a67612c07565b60005460ff16156110c95760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a28565b610a656110db36839003830183614ec0565b33611d93565b6000805460ff16156111285760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a28565b611184848484808060200260200160405190810160405280939291908181526020016000905b8282101561117a5761116b60608302860136819003810190614f13565b8152602001906001019061114e565b5050505050612ca3565b949350505050565b600061119883836133bc565b9392505050565b600061122f600360009054906101000a90046001600160a01b03166001600160a01b031663926323d56040518163ffffffff1660e01b815260040160206040518083038186803b1580156111f257600080fd5b505afa158015611206573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122a9190614f89565b613480565b905090565b6000805160206157b9833981519152546001600160a01b031633146112945760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b610a676134b6565b60008281526073602052604081206111989083613531565b7f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e46112df8133612b65565b60006112f86112f336859003850185614ff0565b61353d565b905061130c6112f336859003850185614ff0565b8335600090815260796020526040902054146113765760405162461bcd60e51b815260206004820152602360248201527f4d61696e636861696e4761746577617956323a20696e76616c696420726563656044820152621a5c1d60ea1b6064820152608401610a28565b82356000908152607a602052604090205460ff166113fc5760405162461bcd60e51b815260206004820152603160248201527f4d61696e636861696e4761746577617956323a20717565727920666f7220617060448201527f70726f766564207769746864726177616c0000000000000000000000000000006064820152608401610a28565b82356000908152607a602052604090819020805460ff19169055517fd639511b37b3b002cca6cfe6bca0d833945a5af5a045578a0627fc43b79b26309061144690839086906150c4565b60405180910390a160006114606080850160608601614aec565b9050600061147661012086016101008701615151565b600181111561148757611487614c71565b141561154f5760006114a2368690038601610100870161516e565b6001600160a01b0383166000908152603b60205260409020549091506114ce90610140870135906135c6565b604082015260006114e8368790038701610100880161516e565b60408301519091506114ff9061014088013561518a565b604082015260745461151f908390339086906001600160a01b03166135e0565b6115486115326060880160408901614aec565b60745483919086906001600160a01b03166135e0565b505061158b565b61158b6115626060860160408701614aec565b60745483906001600160a01b03166115833689900389016101008a0161516e565b9291906135e0565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d82856040516115bc9291906150c4565b60405180910390a150505050565b6000805160206157b9833981519152546001600160a01b0316331461162a5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b8261168a5760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b610e8984848484612666565b6000806116b86000805160206157b9833981519152546001600160a01b031690565b6001600160a01b0316336001600160a01b0316146117115760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b61171b84846122f8565b90925090506117286123d3565b9250929050565b6003546040805163926323d560e01b815290516000926001600160a01b03169163926323d5916004808301926020929190829003018186803b15801561177457600080fd5b505afa158015611788573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ac9190614f89565b6037546117b991906151a1565b6038546117c690846151a1565b101592915050565b6000805160206157b9833981519152546001600160a01b0316331461182e5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b8261188e5760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b610e898484848461288c565b60408051808201909152600080825260208201526001600160a01b0382166000908152607860205260409081902081518083019092528054829060ff1660018111156118e8576118e8614c71565b60018111156118f9576118f9614c71565b815290546001600160a01b036101009091048116602092830152908201519192501661198d5760405162461bcd60e51b815260206004820152602560248201527f4d61696e636861696e4761746577617956323a20756e737570706f727465642060448201527f746f6b656e0000000000000000000000000000000000000000000000000000006064820152608401610a28565b919050565b6000806119b46000805160206157b9833981519152546001600160a01b031690565b6001600160a01b0316336001600160a01b031614611a0d5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b61171b8484612238565b6000818152607360205260408120610aa790613a13565b6000805160206157b9833981519152546001600160a01b03163314611a8e5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b610a65816121dd565b600082815260726020526040902060010154611ab38133612b65565b610f8a8383612be5565b6000805160206157b9833981519152546001600160a01b03163314611b1d5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b610a658161217b565b6003546040805163926323d560e01b815290516000926001600160a01b03169163926323d5916004808301926020929190829003018186803b158015611b6b57600080fd5b505afa158015611b7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba39190614f89565b600154611bb091906151a1565b6002546117c690846151a1565b6000805160206157b9833981519152546001600160a01b03163314611c1d5760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b85611c7c5760405162461bcd60e51b815260206004820152602960248201527f4d61696e636861696e4761746577617956323a20717565727920666f7220656d60448201526870747920617272617960b81b6064820152608401610a28565b611c8a878787878787612467565b611c978787836000610c8f565b611ca48787836001610cb5565b611cb18787836002610cdb565b611cbe8787836003610d01565b50505050505050565b6000805160206157b9833981519152546001600160a01b03163314611d275760405162461bcd60e51b815260206004820152602260248201526000805160206157d983398151915260448201526132b960f11b6064820152608401610a28565b82611d875760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b610e8984848484612a30565b604080518082018252600080825260208201526074549184015190916001600160a01b031690611dc290613a1d565b60208401516001600160a01b0316611ee1573484604001516040015114611e375760405162461bcd60e51b815260206004820152602360248201527f4d61696e636861696e4761746577617956323a20696e76616c69642072657175604482015262195cdd60ea1b6064820152608401610a28565b611e408161189a565b6040850151519092506001811115611e5a57611e5a614c71565b82516001811115611e6d57611e6d614c71565b14611ecd5760405162461bcd60e51b815260206004820152602a60248201527f4d61696e636861696e4761746577617956323a20696e76616c696420746f6b656044820152691b881cdd185b99185c9960b21b6064820152608401610a28565b6001600160a01b0381166020850152612087565b3415611f3b5760405162461bcd60e51b815260206004820152602360248201527f4d61696e636861696e4761746577617956323a20696e76616c69642072657175604482015262195cdd60ea1b6064820152608401610a28565b611f48846020015161189a565b6040850151519092506001811115611f6257611f62614c71565b82516001811115611f7557611f75614c71565b14611fd55760405162461bcd60e51b815260206004820152602a60248201527f4d61696e636861696e4761746577617956323a20696e76616c696420746f6b656044820152691b881cdd185b99185c9960b21b6064820152608401610a28565b60208401516040850151611fec9185903090613ac7565b83602001516001600160a01b0316816001600160a01b031614156120875760408481015181015190517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101919091526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b15801561206e57600080fd5b505af1158015612082573d6000803e3d6000fd5b505050505b607680546000918261209883614e06565b91905055905060006120bf858386602001516075548a613ce190949392919063ffffffff16565b90507fd7b25068d9dc8d00765254cfb7f5070f98d263c8d68931d937c7362fa738048b6120eb8261353d565b826040516120fa9291906151c0565b60405180910390a1505050505050565b60006001600160e01b031982167f7965db0b000000000000000000000000000000000000000000000000000000001480610aa757507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b0319831614610aa7565b6110178282612b43565b6074805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040519081527f9d2334c23be647e994f27a72c5eee42a43d5bdcfe15bb88e939103c2b114cbaf906020015b60405180910390a150565b6003805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040519081527fef40dc07567635f84f5edbd2f8dbc16b40d9d282dd8e7e6f4ff58236b6836169906020016121d2565b6000808284111561228b5760405162461bcd60e51b815260206004820152601c60248201527f4761746577617956323a20696e76616c6964207468726573686f6c64000000006044820152606401610a28565b505060018054600280549285905583905560048054919291849186919060006122b383614e06565b9091555060408051868152602081018690527f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f891015b60405180910390a49250929050565b600080828411156123715760405162461bcd60e51b815260206004820152602760248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c696420746860448201527f726573686f6c64000000000000000000000000000000000000000000000000006064820152608401610a28565b5050603780546038805492859055839055600480549192918491869190600061239983614e06565b9091555060408051868152602081018690527f31312c97b89cc751b832d98fd459b967a2c3eef3b49757d1cf5ebaa12bb6eee191016122e9565b6002546037546123e391906151a1565b6038546001546123f391906151a1565b1115610a675760405162461bcd60e51b815260206004820152602860248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c696420746860448201527f726573686f6c64730000000000000000000000000000000000000000000000006064820152608401610a28565b848314801561247557508481145b6124e75760405162461bcd60e51b815260206004820152602860248201527f4d61696e636861696e4761746577617956323a20696e76616c6964206172726160448201527f79206c656e6774680000000000000000000000000000000000000000000000006064820152608401610a28565b60005b8581101561262c5784848281811061250457612504614d90565b90506020020160208101906125199190614aec565b6078600089898581811061252f5761252f614d90565b90506020020160208101906125449190614aec565b6001600160a01b039081168252602082019290925260400160002080547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1661010093909216929092021790558282828181106125a3576125a3614d90565b90506020020160208101906125b89190615151565b607860008989858181106125ce576125ce614d90565b90506020020160208101906125e39190614aec565b6001600160a01b031681526020810191909152604001600020805460ff19166001838181111561261557612615614c71565b02179055508061262481614e06565b9150506124ea565b507fa4f03cc9c0e0aeb5b71b4ec800702753f65748c2cf3064695ba8e8b46be704448686868686866040516120fa969594939291906152c1565b8281146126c85760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b60005b83811015612743578282828181106126e5576126e5614d90565b905060200201356039600087878581811061270257612702614d90565b90506020020160208101906127179190614aec565b6001600160a01b031681526020810191909152604001600020558061273b81614e06565b9150506126cb565b507f80bc635c452ae67f12f9b6f12ad4daa6dbbc04eeb9ebb87d354ce10c0e210dc0848484846040516115bc9493929190615339565b8281146127db5760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b60005b83811015612856578282828181106127f8576127f8614d90565b90506020020135603a600087878581811061281557612815614d90565b905060200201602081019061282a9190614aec565b6001600160a01b031681526020810191909152604001600020558061284e81614e06565b9150506127de565b507f64557254143204d91ba2d95acb9fda1e5fea55f77efd028685765bc1e94dd4b5848484846040516115bc9493929190615339565b8281146128ee5760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b60005b838110156129fa57620f424083838381811061290f5761290f614d90565b90506020020135111561298a5760405162461bcd60e51b815260206004820152602860248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c696420706560448201527f7263656e746167650000000000000000000000000000000000000000000000006064820152608401610a28565b82828281811061299c5761299c614d90565b90506020020135603b60008787858181106129b9576129b9614d90565b90506020020160208101906129ce9190614aec565b6001600160a01b03168152602081019190915260400160002055806129f281614e06565b9150506128f1565b507fb05f5de88ae0294ebb6f67c5af2fcbbd593cc6bdfe543e2869794a4c8ce3ea50848484846040516115bc9493929190615339565b828114612a925760405162461bcd60e51b815260206004820152602a60248201527f5769746864726177616c4c696d69746174696f6e3a20696e76616c69642061726044820152690e4c2f240d8cadccee8d60b31b6064820152608401610a28565b60005b83811015612b0d57828282818110612aaf57612aaf614d90565b90506020020135603c6000878785818110612acc57612acc614d90565b9050602002016020810190612ae19190614aec565b6001600160a01b0316815260208101919091526040016000205580612b0581614e06565b915050612a95565b507fb5d2963614d72181b4df1f993d45b83edf42fa19710f0204217ba1b3e183bb73848484846040516115bc9493929190615339565b612b4d8282613db6565b6000828152607360205260409020610f8a9082613e58565b60008281526072602090815260408083206001600160a01b038516845290915290205460ff1661101757612ba3816001600160a01b03166014613e6d565b612bae836020613e6d565b604051602001612bbf9291906153d0565b60408051601f198184030181529082905262461bcd60e51b8252610a2891600401615451565b612bef828261404e565b6000828152607360205260409020610f8a90826140d1565b60005460ff16612c595760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610a28565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000823561014084013582612cbe6080870160608801614aec565b9050612cdb612cd6368890038801610100890161516e565b613a1d565b6001612ced6040880160208901615151565b6001811115612cfe57612cfe614c71565b14612d715760405162461bcd60e51b815260206004820152602860248201527f4d61696e636861696e4761746577617956323a20696e76616c6964207265636560448201527f697074206b696e640000000000000000000000000000000000000000000000006064820152608401610a28565b60808601354614612de95760405162461bcd60e51b8152602060048201526024808201527f4d61696e636861696e4761746577617956323a20696e76616c6964206368616960448201527f6e206964000000000000000000000000000000000000000000000000000000006064820152608401610a28565b6000612dfe61084a6080890160608a01614aec565b9050612e1261012088016101008901615151565b6001811115612e2357612e23614c71565b81516001811115612e3657612e36614c71565b148015612e675750612e4e60e0880160c08901614aec565b6001600160a01b031681602001516001600160a01b0316145b612ebf5760405162461bcd60e51b815260206004820152602360248201527f4d61696e636861696e4761746577617956323a20696e76616c696420726563656044820152621a5c1d60ea1b6064820152608401610a28565b60008481526079602052604090205415612f415760405162461bcd60e51b815260206004820152603260248201527f4d61696e636861696e4761746577617956323a20717565727920666f7220707260448201527f6f636573736564207769746864726177616c00000000000000000000000000006064820152608401610a28565b6001612f5561012089016101008a01615151565b6001811115612f6657612f66614c71565b1480612f795750612f7782846133bc565b155b612feb5760405162461bcd60e51b815260206004820152603260248201527f4d61696e636861696e4761746577617956323a2072656163686564206461696c60448201527f79207769746864726177616c206c696d697400000000000000000000000000006064820152608401610a28565b6000612fff6112f3368a90038a018a614ff0565b9050600061300f607754836140e6565b6003549091506001600160a01b0316600061303d6130356101208d016101008e01615151565b878985614142565b60408051606081018252600080825260208201819052918101829052919b50919250819081906000805b8f5181101561323c578f818151811061308257613082614d90565b6020908102919091018101518051818301516040808401518151600081529586018083528f905260ff9093169085015260608401526080830152935060019060a0016020604051602081039080840390855afa1580156130e6573d6000803e3d6000fd5b505050602060405103519450846001600160a01b0316846001600160a01b0316106131795760405162461bcd60e51b815260206004820152602160248201527f4d61696e636861696e4761746577617956323a20696e76616c6964206f72646560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610a28565b6040517f953865650000000000000000000000000000000000000000000000000000000081526001600160a01b03808716600483015286955089169063953865659060240160206040518083038186803b1580156131d657600080fd5b505afa1580156131ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061320e9190614f89565b6132189083615484565b915086821061322a576001955061323c565b8061323481614e06565b915050613067565b50846132b05760405162461bcd60e51b815260206004820152603660248201527f4d61696e636861696e4761746577617956323a20717565727920666f7220696e60448201527f73756666696369656e7420766f746520776569676874000000000000000000006064820152608401610a28565b50505060008a81526079602052604090208690555050881561332c576000888152607a602052604090819020805460ff19166001179055517f89e52969465b1f1866fc5d46fd62de953962e9cb33552443cd999eba05bd20dc906133179086908e906150c4565b60405180910390a15050505050505050610aa7565b6133368688614233565b61337561334960608d0160408e01614aec565b87607460009054906101000a90046001600160a01b03168e61010001803603810190611583919061516e565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d848c6040516133a69291906150c4565b60405180910390a1505050505050505092915050565b6001600160a01b0382166000908152603a602052604081205482106133e357506000610aa7565b60006133f2620151804261549c565b6001600160a01b0385166000908152603e60205260409020549091508111156134385750506001600160a01b0382166000908152603c6020526040902054811015610aa7565b6001600160a01b0384166000908152603d602052604090205461345c908490615484565b6001600160a01b0385166000908152603c602052604090205411159150610aa79050565b600060025460016002548460015461349891906151a1565b6134a29190615484565b6134ac919061518a565b610aa7919061549c565b60005460ff16156134fc5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a28565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612c863390565b600061119883836142c3565b60007fb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea60001b8260000151836020015161357a85604001516142ed565b61358786606001516142ed565b6135948760800151614350565b6040516020016135a9969594939291906154be565b604051602081830303815290604052805190602001209050919050565b6000620f42406135d683856151a1565b611198919061549c565b6000816001600160a01b0316836001600160a01b031614156136905760408086015190516001600160a01b0386169180156108fc02916000818181858888f1935050505061368b57816001600160a01b031663d0e30db086604001516040518263ffffffff1660e01b81526004016000604051808303818588803b15801561366757600080fd5b505af115801561367b573d6000803e3d6000fd5b505050505061368b858585614393565b613a0c565b6000855160018111156136a5576136a5614c71565b1415613866576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b15801561370657600080fd5b505afa15801561371a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061373e9190614f89565b9050856040015181101561385557836001600160a01b03166340c10f193083896040015161376c919061518a565b6040516001600160a01b03909216602483015260448201526064016040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516137c091906154f8565b6000604051808303816000865af19150503d80600081146137fd576040519150601f19603f3d011682016040523d82523d6000602084013e613802565b606091505b505080925050816138555760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e3a204552433230206d696e74696e67206661696c656400000000006044820152606401610a28565b613860868686614393565b50613a0c565b60018551600181111561387b5761387b614c71565b141561399e5761389083858760200151614437565b61368b57602085810151604080516001600160a01b038881166024830152604480830194909452825180830390940184526064909101825292820180516001600160e01b03167f40c10f1900000000000000000000000000000000000000000000000000000000179052519185169161390991906154f8565b6000604051808303816000865af19150503d8060008114613946576040519150601f19603f3d011682016040523d82523d6000602084013e61394b565b606091505b5050809150508061368b5760405162461bcd60e51b815260206004820152601c60248201527f546f6b656e3a20455243373231206d696e74696e67206661696c6564000000006044820152606401610a28565b60405162461bcd60e51b815260206004820152602160248201527f546f6b656e3a20756e737570706f7274656420746f6b656e207374616e64617260448201527f64000000000000000000000000000000000000000000000000000000000000006064820152608401610a28565b5050505050565b6000610aa7825490565b600081516001811115613a3257613a32614c71565b148015613a43575060008160400151115b8015613a5157506020810151155b80613a7b5750600181516001811115613a6c57613a6c614c71565b148015613a7b57506040810151155b610a655760405162461bcd60e51b815260206004820152601360248201527f546f6b656e3a20696e76616c696420696e666f000000000000000000000000006044820152606401610a28565b600060608186516001811115613adf57613adf614c71565b1415613bbd5760408681015181516001600160a01b038881166024830152878116604483015260648083019390935283518083039093018352608490910183526020820180516001600160e01b03166323b872dd60e01b179052915191851691613b4991906154f8565b6000604051808303816000865af19150503d8060008114613b86576040519150601f19603f3d011682016040523d82523d6000602084013e613b8b565b606091505b509092509050818015613bb6575080511580613bb6575080806020019051810190613bb69190615514565b9150613c84565b600186516001811115613bd257613bd2614c71565b141561399e57602086810151604080516001600160a01b0389811660248301528881166044830152606480830194909452825180830390940184526084909101825292820180516001600160e01b03166323b872dd60e01b1790525191851691613c3c91906154f8565b6000604051808303816000865af19150503d8060008114613c79576040519150601f19603f3d011682016040523d82523d6000602084013e613c7e565b606091505b50909250505b81610f5c57613c92866144e2565b613ca6866001600160a01b03166014613e6d565b613cba866001600160a01b03166014613e6d565b613cce866001600160a01b03166014613e6d565b604051602001612bbf9493929190615536565b613d516040805160a08101825260008082526020808301829052835160608082018652838252818301849052818601849052848601919091528451808201865283815280830184905280860184905281850152845190810185528281529081018290529283015290608082015290565b83815260006020820181905250604080820180516001600160a01b039788169052602080890151825190891690820152905146908301528751606084018051918916909152805195909716940193909352935182015292909201516080820152919050565b60008281526072602090815260408083206001600160a01b038516845290915290205460ff166110175760008281526072602090815260408083206001600160a01b03851684529091529020805460ff19166001179055613e143390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611198836001600160a01b03841661454f565b60606000613e7c8360026151a1565b613e87906002615484565b67ffffffffffffffff811115613e9f57613e9f614e21565b6040519080825280601f01601f191660200182016040528015613ec9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110613f0057613f00614d90565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110613f4b57613f4b614d90565b60200101906001600160f81b031916908160001a9053506000613f6f8460026151a1565b613f7a906001615484565b90505b6001811115613fff577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613fbb57613fbb614d90565b1a60f81b828281518110613fd157613fd1614d90565b60200101906001600160f81b031916908160001a90535060049490941c93613ff881615606565b9050613f7d565b5083156111985760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a28565b60008281526072602090815260408083206001600160a01b038516845290915290205460ff16156110175760008281526072602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611198836001600160a01b03841661459e565b604080517f19010000000000000000000000000000000000000000000000000000000000006020808301919091526022820185905260428083018590528351808403909101815260629092019092528051910120600090611198565b6000806000836001600160a01b031663926323d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561418057600080fd5b505afa158015614194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141b89190614f89565b90506141c381613480565b925060008760018111156141d9576141d9614c71565b1415614229576001600160a01b038616600090815260396020526040902054851061420a5761420781614691565b92505b6001600160a01b0386166000908152603a602052604090205485101591505b5094509492505050565b6000614242620151804261549c565b6001600160a01b0384166000908152603e6020526040902054909150811115614291576001600160a01b03929092166000908152603e6020908152604080832094909455603d90529190912055565b6001600160a01b0383166000908152603d6020526040812080548492906142b9908490615484565b9091555050505050565b60008260000182815481106142da576142da614d90565b9060005260206000200154905092915050565b805160208083015160408085015190516000946135a9947f353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e87649491939192019384526001600160a01b03928316602085015291166040830152606082015260800190565b805160208083015160408085015190516000946135a9947f1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d94919391920161561d565b600080845160018111156143a9576143a9614c71565b14156143c5576143be828486604001516146a9565b90506143ef565b6001845160018111156143da576143da614c71565b141561399e576143be82848660200151614437565b80610e89576143fd846144e2565b614411846001600160a01b03166014613e6d565b614425846001600160a01b03166014613e6d565b604051602001612bbf93929190615648565b604080513060248201526001600160a01b038481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092861691614495916154f8565b6000604051808303816000865af19150503d80600081146144d2576040519150601f19603f3d011682016040523d82523d6000602084013e6144d7565b606091505b509095945050505050565b606061450d826000015160018111156144fd576144fd614c71565b6001600160a01b03166001613e6d565b61451a8360200151614795565b6145278460400151614795565b604051602001614539939291906156d9565b6040516020818303038152906040529050919050565b600081815260018301602052604081205461459657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610aa7565b506000610aa7565b600081815260018301602052604081205480156146875760006145c260018361518a565b85549091506000906145d69060019061518a565b905081811461463b5760008660000182815481106145f6576145f6614d90565b906000526020600020015490508087600001848154811061461957614619614d90565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061464c5761464c6157a2565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610aa7565b6000915050610aa7565b600060385460016038548460375461349891906151a1565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000926060929087169161471f91906154f8565b6000604051808303816000865af19150503d806000811461475c576040519150601f19603f3d011682016040523d82523d6000602084013e614761565b606091505b50909250905081801561478c57508051158061478c57508080602001905181019061478c9190615514565b95945050505050565b6060816147d557505060408051808201909152600481527f3078303000000000000000000000000000000000000000000000000000000000602082015290565b8160005b81156147f857806147e981614e06565b915050600882901c91506147d9565b6111848482613e6d565b604080516060810182526000808252602082015290810161483e6040805160608101909152806000815260200160008152602001600081525090565b905290565b60006020828403121561485557600080fd5b81356001600160e01b03198116811461119857600080fd5b6001600160a01b0381168114610a6557600080fd5b803561198d8161486d565b8060608101831015610aa757600080fd5b8060808101831015610aa757600080fd5b60008083601f8401126148c157600080fd5b50813567ffffffffffffffff8111156148d957600080fd5b6020830191508360208260051b850101111561172857600080fd5b60008060008060008060008060008060006101408c8e03121561491657600080fd5b61491f8c614882565b9a5061492d60208d01614882565b995061493b60408d01614882565b985060608c0135975060808c0135965060a08c0135955060c08c0135945067ffffffffffffffff8060e08e0135111561497357600080fd5b6149838e60e08f01358f0161488d565b9450806101008e0135111561499757600080fd5b6149a88e6101008f01358f0161489e565b9350806101208e013511156149bc57600080fd5b506149ce8d6101208e01358e016148af565b81935080925050509295989b509295989b9093969950565b600080600080604085870312156149fc57600080fd5b843567ffffffffffffffff80821115614a1457600080fd5b614a20888389016148af565b90965094506020870135915080821115614a3957600080fd5b50614a46878288016148af565b95989497509550505050565b60008060008060008060608789031215614a6b57600080fd5b863567ffffffffffffffff80821115614a8357600080fd5b614a8f8a838b016148af565b90985096506020890135915080821115614aa857600080fd5b614ab48a838b016148af565b90965094506040890135915080821115614acd57600080fd5b50614ada89828a016148af565b979a9699509497509295939492505050565b600060208284031215614afe57600080fd5b81356111988161486d565b600060208284031215614b1b57600080fd5b5035919050565b60008060408385031215614b3557600080fd5b823591506020830135614b478161486d565b809150509250929050565b600060a08284031215614b6457600080fd5b50919050565b60006101608284031215614b6457600080fd5b60008060006101808486031215614b9357600080fd5b614b9d8585614b6a565b925061016084013567ffffffffffffffff80821115614bbb57600080fd5b818601915086601f830112614bcf57600080fd5b813581811115614bde57600080fd5b876020606083028501011115614bf357600080fd5b6020830194508093505050509250925092565b60008060408385031215614c1957600080fd5b8235614c248161486d565b946020939093013593505050565b60008060408385031215614c4557600080fd5b50508035926020909101359150565b60006101608284031215614c6757600080fd5b6111988383614b6a565b634e487b7160e01b600052602160045260246000fd5b60028110610a6557634e487b7160e01b600052602160045260246000fd5b81516040820190614cb581614c87565b808352506001600160a01b03602084015116602083015292915050565b60008060008060008060006080888a031215614ced57600080fd5b873567ffffffffffffffff80821115614d0557600080fd5b614d118b838c016148af565b909950975060208a0135915080821115614d2a57600080fd5b614d368b838c016148af565b909750955060408a0135915080821115614d4f57600080fd5b614d5b8b838c016148af565b909550935060608a0135915080821115614d7457600080fd5b50614d818a828b0161489e565b91505092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112614dbd57600080fd5b83018035915067ffffffffffffffff821115614dd857600080fd5b6020019150600581901b360382131561172857600080fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415614e1a57614e1a614df0565b5060010190565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715614e6857634e487b7160e01b600052604160045260246000fd5b60405290565b60028110610a6557600080fd5b600060608284031215614e8d57600080fd5b614e95614e37565b90508135614ea281614e6e565b80825250602082013560208201526040820135604082015292915050565b600060a08284031215614ed257600080fd5b614eda614e37565b8235614ee58161486d565b81526020830135614ef58161486d565b6020820152614f078460408501614e7b565b60408201529392505050565b600060608284031215614f2557600080fd5b6040516060810181811067ffffffffffffffff82111715614f5657634e487b7160e01b600052604160045260246000fd5b604052823560ff81168114614f6a57600080fd5b8152602083810135908201526040928301359281019290925250919050565b600060208284031215614f9b57600080fd5b5051919050565b600060608284031215614fb457600080fd5b614fbc614e37565b90508135614fc98161486d565b81526020820135614fd98161486d565b806020830152506040820135604082015292915050565b6000610160828403121561500357600080fd5b60405160a0810181811067ffffffffffffffff8211171561503457634e487b7160e01b600052604160045260246000fd5b60405282358152602083013561504981614e6e565b602082015261505b8460408501614fa2565b604082015261506d8460a08501614fa2565b6060820152615080846101008501614e7b565b60808201529392505050565b80356150978161486d565b6001600160a01b0390811683526020820135906150b38261486d565b166020830152604090810135910152565b6000610180820190508382528235602083015260208301356150e581614e6e565b6150ee81614c87565b80604084015250615105606083016040850161508c565b61511560c0830160a0850161508c565b61012061010084013561512781614e6e565b61513081614c87565b81840152830135610140808401919091529092013561016090910152919050565b60006020828403121561516357600080fd5b813561119881614e6e565b60006060828403121561518057600080fd5b6111988383614e7b565b60008282101561519c5761519c614df0565b500390565b60008160001904831182151516156151bb576151bb614df0565b500290565b6000610180820190508382528251602083015260208301516151e181614c87565b6040838101919091528381015180516001600160a01b03908116606086015260208201511660808501529081015160a084015250606083015180516001600160a01b0390811660c085015260208201511660e08401526040810151610100840152506080830151805161525381614c87565b6101208401526020810151610140840152604001516101609092019190915292915050565b8183526000602080850194508260005b858110156152b657813561529b8161486d565b6001600160a01b031687529582019590820190600101615288565b509495945050505050565b6060815260006152d560608301888a615278565b6020838203818501526152e982888a615278565b8481036040860152858152869250810160005b8681101561532a57833561530f81614e6e565b61531881614c87565b825292820192908201906001016152fc565b509a9950505050505050505050565b60408152600061534d604083018688615278565b82810360208401528381527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84111561538557600080fd5b8360051b80866020840137600091016020019081529695505050505050565b60005b838110156153bf5781810151838201526020016153a7565b83811115610e895750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516154088160178501602088016153a4565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516154458160288401602088016153a4565b01602801949350505050565b60208152600082518060208401526154708160408501602087016153a4565b601f01601f19169190910160400192915050565b6000821982111561549757615497614df0565b500190565b6000826154b957634e487b7160e01b600052601260045260246000fd5b500490565b8681526020810186905260c081016154d586614c87565b8560408301528460608301528360808301528260a0830152979650505050505050565b6000825161550a8184602087016153a4565b9190910192915050565b60006020828403121561552657600080fd5b8151801515811461119857600080fd5b7f546f6b656e3a20636f756c64206e6f74207472616e7366657220000000000000815260008551602061556f82601a8601838b016153a4565b7f2066726f6d200000000000000000000000000000000000000000000000000000601a9285019283015286516155aa81838501848b016153a4565b630103a37960e51b92018181019290925285516155cd81602485018985016153a4565b660103a37b5b2b7160cd1b6024939091019283015284516155f481602b85018489016153a4565b91909101602b01979650505050505050565b60008161561557615615614df0565b506000190190565b8481526080810161562d85614c87565b84602083015283604083015282606083015295945050505050565b7f546f6b656e3a20636f756c64206e6f74207472616e736665722000000000000081526000845161568081601a8501602089016153a4565b630103a37960e51b601a9184019182015284516156a481601e8401602089016153a4565b660103a37b5b2b7160cd1b601e929091019182015283516156cc8160258401602088016153a4565b0160250195945050505050565b7f546f6b656e496e666f280000000000000000000000000000000000000000000081526000845161571181600a8501602089016153a4565b80830190507f2c0000000000000000000000000000000000000000000000000000000000000080600a830152855161575081600b850160208a016153a4565b600b920191820152835161576b81600c8401602088016153a4565b7f2900000000000000000000000000000000000000000000000000000000000000600c9290910191820152600d0195945050505050565b634e487b7160e01b600052603160045260246000fdfeb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610348617350726f787941646d696e3a20756e617574686f72697a65642073656e64") + ]; +} diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 96144dc63d7e5..d05c8a7bd472d 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -9,36 +9,36 @@ use std::path::{Path, PathBuf}; use yansi::Paint; /// CLI arguments for `forge init`. -#[derive(Clone, Debug, Parser)] +#[derive(Clone, Debug, Default, Parser)] pub struct InitArgs { /// The root directory of the new project. #[arg(value_hint = ValueHint::DirPath, default_value = ".", value_name = "PATH")] - root: PathBuf, + pub root: PathBuf, /// The template to start from. #[arg(long, short)] - template: Option, + pub template: Option, /// Branch argument that can only be used with template option. /// If not specified, the default branch is used. #[arg(long, short, requires = "template")] - branch: Option, + pub branch: Option, /// Do not install dependencies from the network. #[arg(long, conflicts_with = "template", visible_alias = "no-deps")] - offline: bool, + pub offline: bool, /// Create the project even if the specified root directory is not empty. #[arg(long, conflicts_with = "template")] - force: bool, + pub force: bool, /// Create a .vscode/settings.json file with Solidity settings, and generate a remappings.txt /// file. #[arg(long, conflicts_with = "template")] - vscode: bool, + pub vscode: bool, #[command(flatten)] - opts: DependencyInstallOpts, + pub opts: DependencyInstallOpts, } impl InitArgs { diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index b01366aa7ce81..c8d1dbb0e0064 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -42,6 +42,7 @@ pub mod bind; pub mod build; pub mod cache; +pub mod clone; pub mod config; pub mod coverage; pub mod create; diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 05589f84a2df8..1c7095026e294 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -55,6 +55,7 @@ fn main() -> Result<()> { ForgeSubcommand::Debug(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::VerifyContract(args) => utils::block_on(args.run()), ForgeSubcommand::VerifyCheck(args) => utils::block_on(args.run()), + ForgeSubcommand::Clone(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Cache(cmd) => match cmd.sub { CacheSubcommands::Clean(cmd) => cmd.run(), CacheSubcommands::Ls(cmd) => cmd.run(), diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 56308e167c5a8..6ca78da0f44e1 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -1,7 +1,7 @@ use crate::cmd::{ - bind::BindArgs, build::BuildArgs, cache::CacheArgs, config, coverage, create::CreateArgs, - debug::DebugArgs, doc::DocArgs, flatten, fmt::FmtArgs, geiger, generate, init::InitArgs, - inspect, install::InstallArgs, remappings::RemappingArgs, remove::RemoveArgs, + bind::BindArgs, build::BuildArgs, cache::CacheArgs, clone::CloneArgs, config, coverage, + create::CreateArgs, debug::DebugArgs, doc::DocArgs, flatten, fmt::FmtArgs, geiger, generate, + init::InitArgs, inspect, install::InstallArgs, remappings::RemappingArgs, remove::RemoveArgs, selectors::SelectorsSubcommands, snapshot, test, tree, update, }; use clap::{Parser, Subcommand, ValueHint}; @@ -52,6 +52,9 @@ pub enum ForgeSubcommand { #[command(visible_aliases = ["b", "compile"])] Build(BuildArgs), + /// Clone a contract from Etherscan. + Clone(CloneArgs), + /// Debugs a single smart contract as a script. #[command(visible_alias = "d")] Debug(DebugArgs), diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index e081b3d6138a5..b42d93cfdea3f 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1,6 +1,7 @@ //! Contains various tests for checking forge's commands use crate::constants::*; +use foundry_common::rpc::next_etherscan_api_key; use foundry_compilers::{artifacts::Metadata, remappings::Remapping, ConfigurableContractArtifact}; use foundry_config::{parse_with_profile, BasicConfig, Chain, Config, SolidityErrorCode}; use foundry_test_utils::{ @@ -432,6 +433,41 @@ forgetest!(fail_init_nonexistent_template, |prj, cmd| { cmd.assert_non_empty_stderr(); }); +// checks that clone works +forgetest!(can_clone, |prj, cmd| { + prj.wipe(); + + let foundry_toml = prj.root().join(Config::FILE_NAME); + assert!(!foundry_toml.exists()); + + cmd.args([ + "clone", + "--etherscan-api-key", + next_etherscan_api_key().as_str(), + "0x044b75f554b886A065b9567891e45c79542d7357", + ]) + .arg(prj.root()); + cmd.assert_non_empty_stdout(); + + let s = read_string(&foundry_toml); + let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; +}); + +// Checks that quiet mode does not print anything for clone +forgetest!(can_clone_quiet, |prj, cmd| { + prj.wipe(); + + cmd.args([ + "clone", + "--etherscan-api-key", + next_etherscan_api_key().as_str(), + "--quiet", + "0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec", + ]) + .arg(prj.root()); + cmd.assert_empty_stdout(); +}); + // checks that `clean` removes dapptools style paths forgetest!(can_clean, |prj, cmd| { prj.assert_create_dirs_exists(); diff --git a/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json new file mode 100644 index 0000000000000..d709187b8b9b8 --- /dev/null +++ b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0x044b75f554b886a065b9567891e45c79542d7357", + "contractCreator": "0xf87bc5535602077d340806d71f805ea9907a843d", + "txHash": "0x9a89d2f5528bf07661e92f3f78a3311396f11f15da19e3ec4d880be1ad1a4bec" +} \ No newline at end of file diff --git a/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json new file mode 100644 index 0000000000000..12f7f6a3bfcb7 --- /dev/null +++ b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json @@ -0,0 +1,78 @@ +[ + { + "SourceCode": { + "language": "Solidity", + "sources": { + "contracts/InputStream.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity 0.8.10;\n\nlibrary InputStream {\n function createStream(bytes memory data) internal pure returns (uint256 stream) {\n assembly {\n stream := mload(0x40)\n mstore(0x40, add(stream, 64))\n mstore(stream, data)\n let length := mload(data)\n mstore(add(stream, 32), add(data, length))\n }\n }\n\n function isNotEmpty(uint256 stream) internal pure returns (bool) {\n uint256 pos;\n uint256 finish;\n assembly {\n pos := mload(stream)\n finish := mload(add(stream, 32))\n }\n return pos < finish;\n }\n\n function readUint8(uint256 stream) internal pure returns (uint8 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 1)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint16(uint256 stream) internal pure returns (uint16 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 2)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint32(uint256 stream) internal pure returns (uint32 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 4)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint(uint256 stream) internal pure returns (uint256 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 32)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readAddress(uint256 stream) internal pure returns (address res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 20)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readBytes(uint256 stream) internal pure returns (bytes memory res) {\n assembly {\n let pos := mload(stream)\n res := add(pos, 32)\n let length := mload(res)\n mstore(stream, add(res, length))\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "interfaces/IBentoBoxMinimal.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity >=0.8.0;\n\nstruct Rebase {\n uint128 elastic;\n uint128 base;\n}\n\nstruct StrategyData {\n uint64 strategyStartDate;\n uint64 targetPercentage;\n uint128 balance; // the balance of the strategy that BentoBox thinks is in there\n}\n\n/// @notice A rebasing library\nlibrary RebaseLibrary {\n /// @notice Calculates the base value in relationship to `elastic` and `total`.\n function toBase(Rebase memory total, uint256 elastic) internal pure returns (uint256 base) {\n if (total.elastic == 0) {\n base = elastic;\n } else {\n base = (elastic * total.base) / total.elastic;\n }\n }\n\n /// @notice Calculates the elastic value in relationship to `base` and `total`.\n function toElastic(Rebase memory total, uint256 base) internal pure returns (uint256 elastic) {\n if (total.base == 0) {\n elastic = base;\n } else {\n elastic = (base * total.elastic) / total.base;\n }\n }\n}\n\n/// @notice Minimal BentoBox vault interface.\n/// @dev `token` is aliased as `address` from `IERC20` for simplicity.\ninterface IBentoBoxMinimal {\n /// @notice Balance per ERC-20 token per account in shares.\n function balanceOf(address, address) external view returns (uint256);\n\n /// @dev Helper function to represent an `amount` of `token` in shares.\n /// @param token The ERC-20 token.\n /// @param amount The `token` amount.\n /// @param roundUp If the result `share` should be rounded up.\n /// @return share The token amount represented in shares.\n function toShare(\n address token,\n uint256 amount,\n bool roundUp\n ) external view returns (uint256 share);\n\n /// @dev Helper function to represent shares back into the `token` amount.\n /// @param token The ERC-20 token.\n /// @param share The amount of shares.\n /// @param roundUp If the result should be rounded up.\n /// @return amount The share amount back into native representation.\n function toAmount(\n address token,\n uint256 share,\n bool roundUp\n ) external view returns (uint256 amount);\n\n /// @notice Registers this contract so that users can approve it for BentoBox.\n function registerProtocol() external;\n\n /// @notice Deposit an amount of `token` represented in either `amount` or `share`.\n /// @param token The ERC-20 token to deposit.\n /// @param from which account to pull the tokens.\n /// @param to which account to push the tokens.\n /// @param amount Token amount in native representation to deposit.\n /// @param share Token amount represented in shares to deposit. Takes precedence over `amount`.\n /// @return amountOut The amount deposited.\n /// @return shareOut The deposited amount represented in shares.\n function deposit(\n address token,\n address from,\n address to,\n uint256 amount,\n uint256 share\n ) external payable returns (uint256 amountOut, uint256 shareOut);\n\n /// @notice Withdraws an amount of `token` from a user account.\n /// @param token_ The ERC-20 token to withdraw.\n /// @param from which user to pull the tokens.\n /// @param to which user to push the tokens.\n /// @param amount of tokens. Either one of `amount` or `share` needs to be supplied.\n /// @param share Like above, but `share` takes precedence over `amount`.\n function withdraw(\n address token_,\n address from,\n address to,\n uint256 amount,\n uint256 share\n ) external returns (uint256 amountOut, uint256 shareOut);\n\n /// @notice Transfer shares from a user account to another one.\n /// @param token The ERC-20 token to transfer.\n /// @param from which user to pull the tokens.\n /// @param to which user to push the tokens.\n /// @param share The amount of `token` in shares.\n function transfer(\n address token,\n address from,\n address to,\n uint256 share\n ) external;\n\n /// @dev Reads the Rebase `totals`from storage for a given token\n function totals(address token) external view returns (Rebase memory total);\n\n function strategyData(address token) external view returns (StrategyData memory total);\n\n /// @dev Approves users' BentoBox assets to a \"master\" contract.\n function setMasterContractApproval(\n address user,\n address masterContract,\n bool approved,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n function harvest(\n address token,\n bool balance,\n uint256 maxChangeAmount\n ) external;\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "interfaces/IPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity >=0.5.0;\npragma experimental ABIEncoderV2;\n\n/// @notice Trident pool interface.\ninterface IPool {\n /// @notice Executes a swap from one token to another.\n /// @dev The input tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that were sent to the user.\n function swap(bytes calldata data) external returns (uint256 finalAmountOut);\n\n /// @notice Executes a swap from one token to another with a callback.\n /// @dev This function allows borrowing the output tokens and sending the input tokens in the callback.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that were sent to the user.\n function flashSwap(bytes calldata data) external returns (uint256 finalAmountOut);\n\n /// @notice Mints liquidity tokens.\n /// @param data ABI-encoded params that the pool requires.\n /// @return liquidity The amount of liquidity tokens that were minted for the user.\n function mint(bytes calldata data) external returns (uint256 liquidity);\n\n /// @notice Burns liquidity tokens.\n /// @dev The input LP tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return withdrawnAmounts The amount of various output tokens that were sent to the user.\n function burn(bytes calldata data) external returns (TokenAmount[] memory withdrawnAmounts);\n\n /// @notice Burns liquidity tokens for a single output token.\n /// @dev The input LP tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return amountOut The amount of output tokens that were sent to the user.\n function burnSingle(bytes calldata data) external returns (uint256 amountOut);\n\n /// @return A unique identifier for the pool type.\n function poolIdentifier() external pure returns (bytes32);\n\n /// @return An array of tokens supported by the pool.\n function getAssets() external view returns (address[] memory);\n\n /// @notice Simulates a trade and returns the expected output.\n /// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that will be sent to the user if the trade is executed.\n function getAmountOut(bytes calldata data) external view returns (uint256 finalAmountOut);\n\n /// @notice Simulates a trade and returns the expected output.\n /// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountIn The amount of input tokens that are required from the user if the trade is executed.\n function getAmountIn(bytes calldata data) external view returns (uint256 finalAmountIn);\n\n /// @dev This event must be emitted on all swaps.\n event Swap(address indexed recipient, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut);\n\n /// @dev This struct frames output tokens for burns.\n struct TokenAmount {\n address token;\n uint256 amount;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "contracts/RouteProcessor2.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity 0.8.10;\n\nimport '../interfaces/IUniswapV2Pair.sol';\nimport '../interfaces/IUniswapV3Pool.sol';\nimport '../interfaces/ITridentCLPool.sol';\nimport '../interfaces/IBentoBoxMinimal.sol';\nimport '../interfaces/IPool.sol';\nimport '../interfaces/IWETH.sol';\nimport './InputStream.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\naddress constant NATIVE_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\naddress constant IMPOSSIBLE_POOL_ADDRESS = 0x0000000000000000000000000000000000000001;\n\n/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\nuint160 constant MIN_SQRT_RATIO = 4295128739;\n/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\nuint160 constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n/// @title A route processor for the Sushi Aggregator\n/// @author Ilya Lyalin\ncontract RouteProcessor2 {\n using SafeERC20 for IERC20;\n using InputStream for uint256;\n\n IBentoBoxMinimal public immutable bentoBox;\n address private lastCalledPool;\n\n uint private unlocked = 1;\n modifier lock() {\n require(unlocked == 1, 'RouteProcessor is locked');\n unlocked = 2;\n _;\n unlocked = 1;\n }\n\n constructor(address _bentoBox) {\n bentoBox = IBentoBoxMinimal(_bentoBox);\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n }\n\n /// @notice For native unwrapping\n receive() external payable {}\n\n /// @notice Processes the route generated off-chain. Has a lock\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function processRoute(\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) external payable lock returns (uint256 amountOut) {\n return processRouteInternal(tokenIn, amountIn, tokenOut, amountOutMin, to, route);\n }\n\n /// @notice Transfers some value to and then processes the route\n /// @param transferValueTo Address where the value should be transferred\n /// @param amountValueTransfer How much value to transfer\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function transferValueAndprocessRoute(\n address payable transferValueTo,\n uint256 amountValueTransfer,\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) external payable lock returns (uint256 amountOut) {\n (bool success, bytes memory returnBytes) = transferValueTo.call{value: amountValueTransfer}('');\n require(success, string(abi.encodePacked(returnBytes)));\n return processRouteInternal(tokenIn, amountIn, tokenOut, amountOutMin, to, route);\n }\n\n /// @notice Processes the route generated off-chain\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function processRouteInternal(\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) private returns (uint256 amountOut) {\n uint256 balanceInInitial = tokenIn == NATIVE_ADDRESS ? address(this).balance : IERC20(tokenIn).balanceOf(msg.sender);\n uint256 balanceOutInitial = tokenOut == NATIVE_ADDRESS ? address(to).balance : IERC20(tokenOut).balanceOf(to);\n\n uint256 stream = InputStream.createStream(route);\n while (stream.isNotEmpty()) {\n uint8 commandCode = stream.readUint8();\n if (commandCode == 1) processMyERC20(stream);\n else if (commandCode == 2) processUserERC20(stream, amountIn);\n else if (commandCode == 3) processNative(stream);\n else if (commandCode == 4) processOnePool(stream);\n else if (commandCode == 5) processInsideBento(stream);\n else revert('RouteProcessor: Unknown command code');\n }\n\n uint256 balanceInFinal = tokenIn == NATIVE_ADDRESS ? address(this).balance : IERC20(tokenIn).balanceOf(msg.sender);\n require(balanceInFinal + amountIn >= balanceInInitial, 'RouteProcessor: Minimal imput balance violation');\n\n uint256 balanceOutFinal = tokenOut == NATIVE_ADDRESS ? address(to).balance : IERC20(tokenOut).balanceOf(to);\n require(balanceOutFinal >= balanceOutInitial + amountOutMin, 'RouteProcessor: Minimal ouput balance violation');\n\n amountOut = balanceOutFinal - balanceOutInitial;\n }\n\n /// @notice Processes native coin: call swap for all pools that swap from native coin\n /// @param stream Streamed process program\n function processNative(uint256 stream) private {\n uint256 amountTotal = address(this).balance;\n distributeAndSwap(stream, address(this), NATIVE_ADDRESS, amountTotal);\n }\n\n /// @notice Processes ERC20 token from this contract balance:\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processMyERC20(uint256 stream) private {\n address token = stream.readAddress();\n uint256 amountTotal = IERC20(token).balanceOf(address(this));\n unchecked {\n if (amountTotal > 0) amountTotal -= 1; // slot undrain protection\n }\n distributeAndSwap(stream, address(this), token, amountTotal);\n }\n \n /// @notice Processes ERC20 token from msg.sender balance:\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n /// @param amountTotal Amount of tokens to take from msg.sender\n function processUserERC20(uint256 stream, uint256 amountTotal) private {\n address token = stream.readAddress();\n distributeAndSwap(stream, msg.sender, token, amountTotal);\n }\n\n /// @notice Distributes amountTotal to several pools according to their shares and calls swap for each pool\n /// @param stream Streamed process program\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountTotal Total amount of tokenIn for swaps \n function distributeAndSwap(uint256 stream, address from, address tokenIn, uint256 amountTotal) private {\n uint8 num = stream.readUint8();\n unchecked {\n for (uint256 i = 0; i < num; ++i) {\n uint16 share = stream.readUint16();\n uint256 amount = (amountTotal * share) / 65535;\n amountTotal -= amount;\n swap(stream, from, tokenIn, amount);\n }\n }\n }\n\n /// @notice Processes ERC20 token for cases when the token has only one output pool\n /// @notice In this case liquidity is already at pool balance. This is an optimization\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processOnePool(uint256 stream) private {\n address token = stream.readAddress();\n swap(stream, address(this), token, 0);\n }\n\n /// @notice Processes Bento tokens \n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processInsideBento(uint256 stream) private {\n address token = stream.readAddress();\n uint8 num = stream.readUint8();\n\n uint256 amountTotal = bentoBox.balanceOf(token, address(this));\n unchecked {\n if (amountTotal > 0) amountTotal -= 1; // slot undrain protection\n for (uint256 i = 0; i < num; ++i) {\n uint16 share = stream.readUint16();\n uint256 amount = (amountTotal * share) / 65535;\n amountTotal -= amount;\n swap(stream, address(this), token, amount);\n }\n }\n }\n\n /// @notice Makes swap\n /// @param stream Streamed process program\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swap(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 poolType = stream.readUint8();\n if (poolType == 0) swapUniV2(stream, from, tokenIn, amountIn);\n else if (poolType == 1) swapUniV3(stream, from, tokenIn, amountIn);\n else if (poolType == 2) wrapNative(stream, from, tokenIn, amountIn);\n else if (poolType == 3) bentoBridge(stream, from, tokenIn, amountIn);\n else if (poolType == 4) swapTrident(stream, from, tokenIn, amountIn);\n else if (poolType == 5) swapTridentCL(stream, from, tokenIn, amountIn);\n else revert('RouteProcessor: Unknown pool type');\n }\n\n /// @notice Wraps/unwraps native token\n /// @param stream [direction & fake, recipient, wrapToken?]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function wrapNative(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 directionAndFake = stream.readUint8();\n address to = stream.readAddress();\n\n if (directionAndFake & 1 == 1) { // wrap native\n address wrapToken = stream.readAddress();\n if (directionAndFake & 2 == 0) IWETH(wrapToken).deposit{value: amountIn}();\n if (to != address(this)) IERC20(wrapToken).safeTransfer(to, amountIn);\n } else { // unwrap native\n if (directionAndFake & 2 == 0) {\n if (from != address(this)) IERC20(tokenIn).safeTransferFrom(from, address(this), amountIn);\n IWETH(tokenIn).withdraw(amountIn);\n }\n payable(to).transfer(address(this).balance);\n }\n }\n\n /// @notice Bridge/unbridge tokens to/from Bento\n /// @param stream [direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function bentoBridge(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 direction = stream.readUint8();\n address to = stream.readAddress();\n\n if (direction > 0) { // outside to Bento\n // deposit to arbitrary recipient is possible only from address(bentoBox)\n if (amountIn != 0) {\n if (from == address(this)) IERC20(tokenIn).safeTransfer(address(bentoBox), amountIn);\n else IERC20(tokenIn).safeTransferFrom(from, address(bentoBox), amountIn);\n } else {\n // tokens already are at address(bentoBox)\n amountIn = IERC20(tokenIn).balanceOf(address(bentoBox)) +\n bentoBox.strategyData(tokenIn).balance -\n bentoBox.totals(tokenIn).elastic;\n }\n bentoBox.deposit(tokenIn, address(bentoBox), to, amountIn, 0);\n } else { // Bento to outside\n if (amountIn > 0) {\n bentoBox.transfer(tokenIn, from, address(this), amountIn);\n } else amountIn = bentoBox.balanceOf(tokenIn, address(this));\n bentoBox.withdraw(tokenIn, address(this), to, 0, amountIn);\n }\n }\n\n /// @notice UniswapV2 pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapUniV2(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n uint8 direction = stream.readUint8();\n address to = stream.readAddress();\n\n (uint256 r0, uint256 r1, ) = IUniswapV2Pair(pool).getReserves();\n require(r0 > 0 && r1 > 0, 'Wrong pool reserves');\n (uint256 reserveIn, uint256 reserveOut) = direction == 1 ? (r0, r1) : (r1, r0);\n\n if (amountIn != 0) {\n if (from == address(this)) IERC20(tokenIn).safeTransfer(pool, amountIn);\n else IERC20(tokenIn).safeTransferFrom(from, pool, amountIn);\n } else amountIn = IERC20(tokenIn).balanceOf(pool) - reserveIn; // tokens already were transferred\n\n uint256 amountInWithFee = amountIn * 997;\n uint256 amountOut = (amountInWithFee * reserveOut) / (reserveIn * 1000 + amountInWithFee);\n (uint256 amount0Out, uint256 amount1Out) = direction == 1 ? (uint256(0), amountOut) : (amountOut, uint256(0));\n IUniswapV2Pair(pool).swap(amount0Out, amount1Out, to, new bytes(0));\n }\n\n /// @notice Trident pool swap\n /// @param stream [pool, swapData]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapTrident(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bytes memory swapData = stream.readBytes();\n\n if (amountIn != 0) {\n bentoBox.transfer(tokenIn, from, pool, amountIn);\n }\n \n IPool(pool).swap(swapData);\n }\n\n /// @notice UniswapV3 pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapUniV3(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bool zeroForOne = stream.readUint8() > 0;\n address recipient = stream.readAddress();\n\n lastCalledPool = pool;\n IUniswapV3Pool(pool).swap(\n recipient,\n zeroForOne,\n int256(amountIn),\n zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,\n abi.encode(tokenIn, from)\n );\n require(lastCalledPool == IMPOSSIBLE_POOL_ADDRESS, 'RouteProcessor.swapUniV3: unexpected'); // Just to be sure\n }\n\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external {\n require(msg.sender == lastCalledPool, 'RouteProcessor.uniswapV3SwapCallback: call from unknown source');\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n (address tokenIn, address from) = abi.decode(data, (address, address));\n int256 amount = amount0Delta > 0 ? amount0Delta : amount1Delta;\n require(amount > 0, 'RouteProcessor.uniswapV3SwapCallback: not positive amount');\n\n if (from == address(this)) IERC20(tokenIn).safeTransfer(msg.sender, uint256(amount));\n else IERC20(tokenIn).safeTransferFrom(from, msg.sender, uint256(amount));\n }\n\n /// @notice TridentCL pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapTridentCL(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bool zeroForOne = stream.readUint8() > 0;\n address recipient = stream.readAddress();\n\n lastCalledPool = pool;\n ITridentCLPool(pool).swap(\n recipient,\n zeroForOne,\n int256(amountIn),\n zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,\n false,\n abi.encode(tokenIn, from)\n );\n require(lastCalledPool == IMPOSSIBLE_POOL_ADDRESS, 'RouteProcessor.swapTridentCL: unexpected'); // Just to be sure\n }\n\n /// @notice Called to `msg.sender` after executing a swap via ITridentCLPool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a TridentCLPool deployed by the canonical TridentCLFactory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the ITridentCLPoolActions#swap call\n function tridentCLSwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external {\n require(msg.sender == lastCalledPool, 'RouteProcessor.TridentCLSwapCallback: call from unknown source');\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n (address tokenIn, address from) = abi.decode(data, (address, address));\n int256 amount = amount0Delta > 0 ? amount0Delta : amount1Delta;\n require(amount > 0, 'RouteProcessor.TridentCLSwapCallback: not positive amount');\n\n if (from == address(this)) IERC20(tokenIn).safeTransfer(msg.sender, uint256(amount));\n else IERC20(tokenIn).safeTransferFrom(from, msg.sender, uint256(amount));\n }\n}\n" + }, + "interfaces/ITridentCLPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface ITridentCLPool {\n function token0() external returns (address);\n function token1() external returns (address);\n\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool unwrapBento,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "interfaces/IUniswapV2Pair.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n function name() external pure returns (string memory);\n function symbol() external pure returns (string memory);\n function decimals() external pure returns (uint8);\n function totalSupply() external view returns (uint);\n function balanceOf(address owner) external view returns (uint);\n function allowance(address owner, address spender) external view returns (uint);\n\n function approve(address spender, uint value) external returns (bool);\n function transfer(address to, uint value) external returns (bool);\n function transferFrom(address from, address to, uint value) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n function nonces(address owner) external view returns (uint);\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n event Mint(address indexed sender, uint amount0, uint amount1);\n event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint amount0In,\n uint amount1In,\n uint amount0Out,\n uint amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint);\n function factory() external view returns (address);\n function token0() external view returns (address);\n function token1() external view returns (address);\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n function price0CumulativeLast() external view returns (uint);\n function price1CumulativeLast() external view returns (uint);\n function kLast() external view returns (uint);\n\n function mint(address to) external returns (uint liquidity);\n function burn(address to) external returns (uint amount0, uint amount1);\n function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n function skim(address to) external;\n function sync() external;\n\n function initialize(address, address) external;\n}" + }, + "interfaces/IUniswapV3Pool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface IUniswapV3Pool {\n function token0() external returns (address);\n function token1() external returns (address);\n\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n}\n" + }, + "interfaces/IWETH.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface IWETH {\n function deposit() external payable;\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function withdraw(uint256) external;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 10000000 + }, + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + }, + "metadata": { + "useLiteralContent": true + }, + "libraries": {} + } + }, + "ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bentoBox\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"bentoBox\",\"outputs\":[{\"internalType\":\"contract IBentoBoxMinimal\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"route\",\"type\":\"bytes\"}],\"name\":\"processRoute\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"transferValueTo\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountValueTransfer\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"route\",\"type\":\"bytes\"}],\"name\":\"transferValueAndprocessRoute\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"amount0Delta\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1Delta\",\"type\":\"int256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"tridentCLSwapCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"amount0Delta\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1Delta\",\"type\":\"int256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"uniswapV3SwapCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + "ContractName": "RouteProcessor2", + "CompilerVersion": "v0.8.10+commit.fc410830", + "OptimizationUsed": 1, + "Runs": 10000000, + "ConstructorArguments": "0x000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd643966", + "EVMVersion": "Default", + "Library": "", + "LicenseType": "", + "Proxy": 0, + "SwarmSource": "" + } +] \ No newline at end of file diff --git a/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json new file mode 100644 index 0000000000000..2c31353535865 --- /dev/null +++ b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0x35fb958109b70799a8f9bc2a8b1ee4cc62034193", + "contractCreator": "0x3e32324277e96b69750bc6f7c4ba27e122413e07", + "txHash": "0x41e3517f8262b55e1eb1707ba0760b603a70e89ea4a86eff56072fcc80c3d0a1" +} \ No newline at end of file diff --git a/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json new file mode 100644 index 0000000000000..7601e4d6ee1e7 --- /dev/null +++ b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json @@ -0,0 +1,16 @@ +[ + { + "SourceCode": "/**\r\n *Submitted for verification at Etherscan.io on 2022-02-19\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-18\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-14\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-10\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-09\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-08\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-05\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-01-22\r\n*/\r\n\r\n// SPDX-License-Identifier: UNLICENSED\r\n/*\r\nmade by cty0312\r\n2022.01.22\r\n**/\r\n\r\npragma solidity >=0.7.0 <0.9.0;\r\n\r\nlibrary StringsUpgradeable {\r\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n // Inspired by OraclizeAPI's implementation - MIT licence\r\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\r\n\r\n if (value == 0) {\r\n return \"0\";\r\n }\r\n uint256 temp = value;\r\n uint256 digits;\r\n while (temp != 0) {\r\n digits++;\r\n temp /= 10;\r\n }\r\n bytes memory buffer = new bytes(digits);\r\n while (value != 0) {\r\n digits -= 1;\r\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\r\n value /= 10;\r\n }\r\n return string(buffer);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(uint256 value) internal pure returns (string memory) {\r\n if (value == 0) {\r\n return \"0x00\";\r\n }\r\n uint256 temp = value;\r\n uint256 length = 0;\r\n while (temp != 0) {\r\n length++;\r\n temp >>= 8;\r\n }\r\n return toHexString(value, length);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\r\n */\r\n function toHexString(uint256 value, uint256 length)\r\n internal\r\n pure\r\n returns (string memory)\r\n {\r\n bytes memory buffer = new bytes(2 * length + 2);\r\n buffer[0] = \"0\";\r\n buffer[1] = \"x\";\r\n for (uint256 i = 2 * length + 1; i > 1; --i) {\r\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\r\n value >>= 4;\r\n }\r\n require(value == 0, \"Strings: hex length insufficient\");\r\n return string(buffer);\r\n }\r\n}\r\n\r\nlibrary AddressUpgradeable {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize, which returns 0 for contracts in\r\n // construction, since the code is only stored at the end of the\r\n // constructor execution.\r\n\r\n uint256 size;\r\n assembly {\r\n size := extcodesize(account)\r\n }\r\n return size > 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(\r\n address(this).balance >= amount,\r\n \"Address: insufficient balance\"\r\n );\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(\r\n success,\r\n \"Address: unable to send value, recipient may have reverted\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data)\r\n internal\r\n returns (bytes memory)\r\n {\r\n return functionCall(target, data, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value\r\n ) internal returns (bytes memory) {\r\n return\r\n functionCallWithValue(\r\n target,\r\n data,\r\n value,\r\n \"Address: low-level call with value failed\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(\r\n address(this).balance >= value,\r\n \"Address: insufficient balance for call\"\r\n );\r\n require(isContract(target), \"Address: call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.call{value: value}(\r\n data\r\n );\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data)\r\n internal\r\n view\r\n returns (bytes memory)\r\n {\r\n return\r\n functionStaticCall(\r\n target,\r\n data,\r\n \"Address: low-level static call failed\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n require(isContract(target), \"Address: static call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\r\n * revert reason using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length > 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n }\r\n}\r\n\r\nlibrary SafeMathUpgradeable {\r\n /**\r\n * @dev Returns the addition of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `+` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Addition cannot overflow.\r\n */\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n uint256 c = a + b;\r\n require(c >= a, \"SafeMath: addition overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity's `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return sub(a, b, \"SafeMath: subtraction overflow\");\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity's `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b <= a, errorMessage);\r\n uint256 c = a - b;\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the multiplication of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `*` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Multiplication cannot overflow.\r\n */\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r\n // benefit is lost if 'b' is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 c = a * b;\r\n require(c / a == b, \"SafeMath: multiplication overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return div(a, b, \"SafeMath: division by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b > 0, errorMessage);\r\n uint256 c = a / b;\r\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts when dividing by zero.\r\n *\r\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return mod(a, b, \"SafeMath: modulo by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts with custom message when dividing by zero.\r\n *\r\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b != 0, errorMessage);\r\n return a % b;\r\n }\r\n}\r\n\r\nabstract contract Initializable {\r\n /**\r\n * @dev Indicates that the contract has been initialized.\r\n */\r\n bool private _initialized;\r\n\r\n /**\r\n * @dev Indicates that the contract is in the process of being initialized.\r\n */\r\n bool private _initializing;\r\n\r\n /**\r\n * @dev Modifier to protect an initializer function from being invoked twice.\r\n */\r\n modifier initializer() {\r\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\r\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\r\n // contract may have been reentered.\r\n require(\r\n _initializing ? _isConstructor() : !_initialized,\r\n \"Initializable: contract is already initialized\"\r\n );\r\n\r\n bool isTopLevelCall = !_initializing;\r\n if (isTopLevelCall) {\r\n _initializing = true;\r\n _initialized = true;\r\n }\r\n\r\n _;\r\n\r\n if (isTopLevelCall) {\r\n _initializing = false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\r\n * {initializer} modifier, directly or indirectly.\r\n */\r\n modifier onlyInitializing() {\r\n require(_initializing, \"Initializable: contract is not initializing\");\r\n _;\r\n }\r\n\r\n function _isConstructor() private view returns (bool) {\r\n return !AddressUpgradeable.isContract(address(this));\r\n }\r\n}\r\n\r\nabstract contract ContextUpgradeable is Initializable {\r\n function __Context_init() internal onlyInitializing {\r\n __Context_init_unchained();\r\n }\r\n\r\n function __Context_init_unchained() internal onlyInitializing {}\r\n\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n\r\n uint256[50] private __gap;\r\n}\r\n\r\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(\r\n address indexed previousOwner,\r\n address indexed newOwner\r\n );\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n function __Ownable_init() internal onlyInitializing {\r\n __Context_init_unchained();\r\n __Ownable_init_unchained();\r\n }\r\n\r\n function __Ownable_init_unchained() internal onlyInitializing {\r\n _transferOwnership(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _transferOwnership(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(\r\n newOwner != address(0),\r\n \"Ownable: new owner is the zero address\"\r\n );\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n\r\n uint256[49] private __gap;\r\n}\r\n\r\ninterface IERC165Upgradeable {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n\r\ninterface IERC721Upgradeable is IERC165Upgradeable {\r\n /**\r\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\r\n */\r\n event Transfer(\r\n address indexed from,\r\n address indexed to,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed approved,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(\r\n address indexed owner,\r\n address indexed operator,\r\n bool approved\r\n );\r\n\r\n /**\r\n * @dev Returns the number of tokens in ``owner``'s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Transfers `tokenId` token from `from` to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId)\r\n external\r\n view\r\n returns (address operator);\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool _approved) external;\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}\r\n */\r\n function isApprovedForAll(address owner, address operator)\r\n external\r\n view\r\n returns (bool);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external;\r\n}\r\n\r\ninterface IERC20Upgradeable {\r\n /**\r\n * @dev Returns the amount of tokens in existence.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns the amount of tokens owned by `account`.\r\n */\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transfer(address recipient, uint256 amount)\r\n external\r\n returns (bool);\r\n\r\n /**\r\n * @dev Returns the remaining number of tokens that `spender` will be\r\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\r\n * zero by default.\r\n *\r\n * This value changes when {approve} or {transferFrom} are called.\r\n */\r\n function allowance(address owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\r\n * that someone may use both the old and the new allowance by unfortunate\r\n * transaction ordering. One possible solution to mitigate this race\r\n * condition is to first reduce the spender's allowance to 0 and set the\r\n * desired value afterwards:\r\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\r\n * allowance mechanism. `amount` is then deducted from the caller's\r\n * allowance.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) external returns (bool);\r\n\r\n\r\n function mintToken(address _address, uint256 _amount) external;\r\n /**\r\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\r\n * another (`to`).\r\n *\r\n * Note that `value` may be zero.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n /**\r\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\r\n * a call to {approve}. `value` is the new allowance.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n}\r\n\r\ninterface IUniswapV2Factory {\r\n event PairCreated(\r\n address indexed token0,\r\n address indexed token1,\r\n address pair,\r\n uint256\r\n );\r\n\r\n function feeTo() external view returns (address);\r\n\r\n function feeToSetter() external view returns (address);\r\n\r\n function getPair(address tokenA, address tokenB)\r\n external\r\n view\r\n returns (address pair);\r\n\r\n function allPairs(uint256) external view returns (address pair);\r\n\r\n function allPairsLength() external view returns (uint256);\r\n\r\n function createPair(address tokenA, address tokenB)\r\n external\r\n returns (address pair);\r\n\r\n function setFeeTo(address) external;\r\n\r\n function setFeeToSetter(address) external;\r\n}\r\n\r\ninterface IUniswapV2Pair {\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n function name() external pure returns (string memory);\r\n\r\n function symbol() external pure returns (string memory);\r\n\r\n function decimals() external pure returns (uint8);\r\n\r\n function totalSupply() external view returns (uint256);\r\n\r\n function balanceOf(address owner) external view returns (uint256);\r\n\r\n function allowance(address owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function approve(address spender, uint256 value) external returns (bool);\r\n\r\n function transfer(address to, uint256 value) external returns (bool);\r\n\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 value\r\n ) external returns (bool);\r\n\r\n function DOMAIN_SEPARATOR() external view returns (bytes32);\r\n\r\n function PERMIT_TYPEHASH() external pure returns (bytes32);\r\n\r\n function nonces(address owner) external view returns (uint256);\r\n\r\n function permit(\r\n address owner,\r\n address spender,\r\n uint256 value,\r\n uint256 deadline,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external;\r\n\r\n event Mint(address indexed sender, uint256 amount0, uint256 amount1);\r\n event Burn(\r\n address indexed sender,\r\n uint256 amount0,\r\n uint256 amount1,\r\n address indexed to\r\n );\r\n event Swap(\r\n address indexed sender,\r\n uint256 amount0In,\r\n uint256 amount1In,\r\n uint256 amount0Out,\r\n uint256 amount1Out,\r\n address indexed to\r\n );\r\n event Sync(uint112 reserve0, uint112 reserve1);\r\n\r\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\r\n\r\n function factory() external view returns (address);\r\n\r\n function token0() external view returns (address);\r\n\r\n function token1() external view returns (address);\r\n\r\n function getReserves()\r\n external\r\n view\r\n returns (\r\n uint112 reserve0,\r\n uint112 reserve1,\r\n uint32 blockTimestampLast\r\n );\r\n\r\n function price0CumulativeLast() external view returns (uint256);\r\n\r\n function price1CumulativeLast() external view returns (uint256);\r\n\r\n function kLast() external view returns (uint256);\r\n\r\n function mint(address to) external returns (uint256 liquidity);\r\n\r\n function burn(address to)\r\n external\r\n returns (uint256 amount0, uint256 amount1);\r\n\r\n function swap(\r\n uint256 amount0Out,\r\n uint256 amount1Out,\r\n address to,\r\n bytes calldata data\r\n ) external;\r\n\r\n function skim(address to) external;\r\n\r\n function sync() external;\r\n\r\n function initialize(address, address) external;\r\n}\r\n\r\ninterface IUniswapV2Router01 {\r\n function factory() external pure returns (address);\r\n\r\n function WETH() external pure returns (address);\r\n\r\n function addLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 amountADesired,\r\n uint256 amountBDesired,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n returns (\r\n uint256 amountA,\r\n uint256 amountB,\r\n uint256 liquidity\r\n );\r\n\r\n function addLiquidityETH(\r\n address token,\r\n uint256 amountTokenDesired,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n payable\r\n returns (\r\n uint256 amountToken,\r\n uint256 amountETH,\r\n uint256 liquidity\r\n );\r\n\r\n function removeLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 liquidity,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountA, uint256 amountB);\r\n\r\n function removeLiquidityETH(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountToken, uint256 amountETH);\r\n\r\n function removeLiquidityWithPermit(\r\n address tokenA,\r\n address tokenB,\r\n uint256 liquidity,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountA, uint256 amountB);\r\n\r\n function removeLiquidityETHWithPermit(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountToken, uint256 amountETH);\r\n\r\n function swapExactTokensForTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapTokensForExactTokens(\r\n uint256 amountOut,\r\n uint256 amountInMax,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapExactETHForTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable returns (uint256[] memory amounts);\r\n\r\n function swapTokensForExactETH(\r\n uint256 amountOut,\r\n uint256 amountInMax,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapExactTokensForETH(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapETHForExactTokens(\r\n uint256 amountOut,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable returns (uint256[] memory amounts);\r\n\r\n function quote(\r\n uint256 amountA,\r\n uint256 reserveA,\r\n uint256 reserveB\r\n ) external pure returns (uint256 amountB);\r\n\r\n function getAmountOut(\r\n uint256 amountIn,\r\n uint256 reserveIn,\r\n uint256 reserveOut\r\n ) external pure returns (uint256 amountOut);\r\n\r\n function getAmountIn(\r\n uint256 amountOut,\r\n uint256 reserveIn,\r\n uint256 reserveOut\r\n ) external pure returns (uint256 amountIn);\r\n\r\n function getAmountsOut(uint256 amountIn, address[] calldata path)\r\n external\r\n view\r\n returns (uint256[] memory amounts);\r\n\r\n function getAmountsIn(uint256 amountOut, address[] calldata path)\r\n external\r\n view\r\n returns (uint256[] memory amounts);\r\n}\r\n\r\ninterface IUniswapV2Router is IUniswapV2Router01 {\r\n function removeLiquidityETHSupportingFeeOnTransferTokens(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountETH);\r\n\r\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountETH);\r\n\r\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n\r\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable;\r\n\r\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n}\r\n\r\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the symbol of the token.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the decimals places of the token.\r\n */\r\n function decimals() external view returns (uint8);\r\n}\r\n\r\nabstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\r\n using SafeMathUpgradeable for uint256;\r\n\r\n mapping(address => uint256) private _balances;\r\n\r\n mapping(address => mapping(address => uint256)) private _allowances;\r\n\r\n uint256 private _totalSupply;\r\n\r\n string private _name;\r\n string private _symbol;\r\n\r\n /**\r\n * @dev Sets the values for {name} and {symbol}.\r\n *\r\n * The default value of {decimals} is 18. To select a different value for\r\n * {decimals} you should overload it.\r\n *\r\n * All two of these values are immutable: they can only be set once during\r\n * construction.\r\n */\r\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\r\n __ERC20_init_unchained(name_, symbol_);\r\n }\r\n\r\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\r\n _name = name_;\r\n _symbol = symbol_;\r\n }\r\n\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() public view virtual override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev Returns the symbol of the token, usually a shorter version of the\r\n * name.\r\n */\r\n function symbol() public view virtual override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n /**\r\n * @dev Returns the number of decimals used to get its user representation.\r\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\r\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\r\n *\r\n * Tokens usually opt for a value of 18, imitating the relationship between\r\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\r\n * overridden;\r\n *\r\n * NOTE: This information is only used for _display_ purposes: it in\r\n * no way affects any of the arithmetic of the contract, including\r\n * {IERC20-balanceOf} and {IERC20-transfer}.\r\n */\r\n function decimals() public view virtual override returns (uint8) {\r\n return 18;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-totalSupply}.\r\n */\r\n function totalSupply() public view virtual override returns (uint256) {\r\n return _totalSupply;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-balanceOf}.\r\n */\r\n function balanceOf(address account) public view virtual override returns (uint256) {\r\n return _balances[account];\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transfer}.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - the caller must have a balance of at least `amount`.\r\n */\r\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\r\n address owner = _msgSender();\r\n _transfer(owner, to, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-allowance}.\r\n */\r\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\r\n return _allowances[owner][spender];\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-approve}.\r\n *\r\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\r\n * `transferFrom`. This is semantically equivalent to an infinite approval.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n */\r\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\r\n address owner = _msgSender();\r\n _approve(owner, spender, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transferFrom}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance. This is not\r\n * required by the EIP. See the note at the beginning of {ERC20}.\r\n *\r\n * NOTE: Does not update the allowance if the current allowance\r\n * is the maximum `uint256`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` and `to` cannot be the zero address.\r\n * - `from` must have a balance of at least `amount`.\r\n * - the caller must have allowance for ``from``'s tokens of at least\r\n * `amount`.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) public virtual override returns (bool) {\r\n address spender = _msgSender();\r\n _spendAllowance(from, spender, amount);\r\n _transfer(from, to, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Atomically increases the allowance granted to `spender` by the caller.\r\n *\r\n * This is an alternative to {approve} that can be used as a mitigation for\r\n * problems described in {IERC20-approve}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n */\r\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\r\n address owner = _msgSender();\r\n _approve(owner, spender, _allowances[owner][spender] + addedValue);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\r\n *\r\n * This is an alternative to {approve} that can be used as a mitigation for\r\n * problems described in {IERC20-approve}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n * - `spender` must have allowance for the caller of at least\r\n * `subtractedValue`.\r\n */\r\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\r\n address owner = _msgSender();\r\n uint256 currentAllowance = _allowances[owner][spender];\r\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\r\n unchecked {\r\n _approve(owner, spender, currentAllowance - subtractedValue);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\r\n *\r\n * This internal function is equivalent to {transfer}, and can be used to\r\n * e.g. implement automatic token fees, slashing mechanisms, etc.\r\n *\r\n * Emits a {Transfer} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `from` must have a balance of at least `amount`.\r\n */\r\n function _transfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {\r\n require(from != address(0), \"ERC20: transfer from the zero address\");\r\n require(to != address(0), \"ERC20: transfer to the zero address\");\r\n\r\n _beforeTokenTransfer(from, to, amount);\r\n\r\n uint256 fromBalance = _balances[from];\r\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\r\n unchecked {\r\n _balances[from] = fromBalance - amount;\r\n }\r\n _balances[to] += amount;\r\n\r\n emit Transfer(from, to, amount);\r\n\r\n _afterTokenTransfer(from, to, amount);\r\n }\r\n\r\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\r\n * the total supply.\r\n *\r\n * Emits a {Transfer} event with `from` set to the zero address.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n */\r\n function _mint(address account, uint256 amount) internal virtual {\r\n require(account != address(0), \"ERC20: mint to the zero address\");\r\n\r\n _beforeTokenTransfer(address(0), account, amount);\r\n\r\n _totalSupply += amount;\r\n _balances[account] += amount;\r\n emit Transfer(address(0), account, amount);\r\n\r\n _afterTokenTransfer(address(0), account, amount);\r\n }\r\n\r\n /**\r\n * @dev Destroys `amount` tokens from `account`, reducing the\r\n * total supply.\r\n *\r\n * Emits a {Transfer} event with `to` set to the zero address.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n * - `account` must have at least `amount` tokens.\r\n */\r\n function _burn(uint256 amount) public virtual {\r\n // require(_balances[msg.sender] >= amount,'insufficient balance!');\r\n\r\n // _beforeTokenTransfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);\r\n\r\n // _balances[msg.sender] = _balances[msg.sender].sub(amount, \"ERC20: burn amount exceeds balance\");\r\n // _totalSupply = _totalSupply.sub(amount);\r\n // emit Transfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);\r\n }\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\r\n *\r\n * This internal function is equivalent to `approve`, and can be used to\r\n * e.g. set automatic allowances for certain subsystems, etc.\r\n *\r\n * Emits an {Approval} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `owner` cannot be the zero address.\r\n * - `spender` cannot be the zero address.\r\n */\r\n function _approve(\r\n address owner,\r\n address spender,\r\n uint256 amount\r\n ) internal virtual {\r\n require(owner != address(0), \"ERC20: approve from the zero address\");\r\n require(spender != address(0), \"ERC20: approve to the zero address\");\r\n\r\n _allowances[owner][spender] = amount;\r\n emit Approval(owner, spender, amount);\r\n }\r\n\r\n /**\r\n * @dev Spend `amount` form the allowance of `owner` toward `spender`.\r\n *\r\n * Does not update the allowance amount in case of infinite allowance.\r\n * Revert if not enough allowance is available.\r\n *\r\n * Might emit an {Approval} event.\r\n */\r\n function _spendAllowance(\r\n address owner,\r\n address spender,\r\n uint256 amount\r\n ) internal virtual {\r\n uint256 currentAllowance = allowance(owner, spender);\r\n if (currentAllowance != type(uint256).max) {\r\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\r\n unchecked {\r\n _approve(owner, spender, currentAllowance - amount);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any transfer of tokens. This includes\r\n * minting and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * will be transferred to `to`.\r\n * - when `from` is zero, `amount` tokens will be minted for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\r\n * - `from` and `to` are never both zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {}\r\n\r\n /**\r\n * @dev Hook that is called after any transfer of tokens. This includes\r\n * minting and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * has been transferred to `to`.\r\n * - when `from` is zero, `amount` tokens have been minted for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\r\n * - `from` and `to` are never both zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _afterTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {}\r\n\r\n /**\r\n * This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[45] private __gap;\r\n}\r\n\r\ncontract BearXNFTStaking is OwnableUpgradeable {\r\n using SafeMathUpgradeable for uint256;\r\n using AddressUpgradeable for address;\r\n\r\n //-------------constant value------------------//\r\n address private UNISWAP_V2_ROUTER;\r\n address private WETH;\r\n uint256 DURATION_FOR_REWARDS;\r\n uint256 DURATION_FOR_STOP_REWARDS;\r\n\r\n address public BearXNFTAddress;\r\n address public ROOTxTokenAddress;\r\n address public SROOTxTokenAddress;\r\n uint256 public totalStakes;\r\n\r\n uint256 public MaxSROOTXrate;\r\n uint256 public MinSROOTXrate;\r\n uint256 public MaxRate;\r\n uint256 public MinRate;\r\n uint256 public maxprovision;\r\n uint256 public RateValue;\r\n uint256 public SROOTRateValue;\r\n\r\n struct stakingInfo {\r\n uint256 nft_id;\r\n uint256 stakedDate;\r\n uint256 claimedDate_SROOT;\r\n uint256 claimedDate_WETH;\r\n uint256 claimedDate_ROOTX;\r\n }\r\n\r\n mapping(address => stakingInfo[]) internal stakes;\r\n address[] internal stakers;\r\n uint256 public RootX_Store;\r\n\r\n // 1.29 update\r\n mapping(address => bool) internal m_stakers;\r\n bool ismaptransfered;\r\n\r\n // 2.15 update\r\n bool public islocked;\r\n\r\n function initialize() public initializer{\r\n __Ownable_init();\r\n UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\r\n WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\r\n DURATION_FOR_REWARDS = 1 days;\r\n DURATION_FOR_STOP_REWARDS = 3650 days;\r\n BearXNFTAddress = 0xE22e1e620dffb03065CD77dB0162249c0c91bf01;\r\n ROOTxTokenAddress = 0xd718Ad25285d65eF4D79262a6CD3AEA6A8e01023;\r\n SROOTxTokenAddress = 0x99CFDf48d0ba4885A73786148A2f89d86c702170;\r\n totalStakes = 0; \r\n MaxSROOTXrate = 100*10**18;\r\n MinSROOTXrate = 50*10**18;\r\n MaxRate = 11050*10**18;\r\n MinRate = 500*10**18; \r\n maxprovision = 3000;\r\n RateValue = ((MaxRate - MinRate) / maxprovision);\r\n SROOTRateValue = (( MaxSROOTXrate - MinSROOTXrate ) / maxprovision);\r\n RootX_Store=0;\r\n ismaptransfered = false;\r\n }\r\n // 1.29 update\r\n function transferStakers() public {\r\n if(!ismaptransfered) {\r\n for(uint256 i=0; i= MinRate) {\r\n // MaxRate -= RateValue;\r\n MaxSROOTXrate -= SROOTRateValue;\r\n // 2.1 updated\r\n MaxRate = MaxRate.sub(10*(10**18));\r\n }\r\n require(\r\n IERC721Upgradeable(BearXNFTAddress).ownerOf(_id) == _addr,\r\n \"You are not a owner of the nft\"\r\n );\r\n require(\r\n IERC721Upgradeable(BearXNFTAddress).isApprovedForAll(msg.sender, address(this)) ==\r\n true,\r\n \"You should approve nft to the staking contract\"\r\n );\r\n IERC721Upgradeable(BearXNFTAddress).transferFrom(\r\n _addr,\r\n address(this),\r\n _id\r\n );\r\n // (bool _isStaker, ) = isStaker(_addr);\r\n (bool _isStaker, ) = is_m_Staker(_addr);\r\n stakingInfo memory sInfo = stakingInfo(\r\n _id,\r\n block.timestamp,\r\n block.timestamp,\r\n block.timestamp,\r\n block.timestamp\r\n );\r\n totalStakes = totalStakes.add(1);\r\n stakes[_addr].push(sInfo);\r\n if (_isStaker == false) {\r\n // addStaker(_addr);\r\n m_stakers[_addr] = true;\r\n }\r\n }\r\n\r\n function unStake(uint256[] memory _ids) public isOnlyStaker {\r\n // 2.15 update\r\n\r\n require(!islocked, \"Locked\");\r\n uint256[] memory ownerIds = stakeOf(msg.sender);\r\n require(_ids.length <= ownerIds.length, \"Id errors\");\r\n uint256 temp = 0;\r\n\r\n for(uint256 i=0; i<_ids.length;i++) {\r\n for(uint256 j=0;j 0) {\r\n IERC20Upgradeable(ROOTxTokenAddress).transfer(_addr, Rootamount);\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_ROOTX = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function _claimOfSROOTxToken(address _addr) internal {\r\n (, uint256 SROOTamount, ) = claimOf(_addr);\r\n if (SROOTamount > 0) {\r\n IERC20Upgradeable(SROOTxTokenAddress).transfer(_addr, SROOTamount);\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_SROOT = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function _claimOfWETH(address _addr) internal {\r\n (, uint256 ETHamount, ) = claimOf(_addr);\r\n\r\n if (ETHamount > 0) {\r\n IERC20Upgradeable(SROOTxTokenAddress).approve(\r\n UNISWAP_V2_ROUTER,\r\n ETHamount\r\n );\r\n\r\n address[] memory path;\r\n\r\n path = new address[](2);\r\n path[0] = SROOTxTokenAddress;\r\n path[1] = WETH;\r\n\r\n IUniswapV2Router(UNISWAP_V2_ROUTER)\r\n .swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n ETHamount,\r\n 0,\r\n path,\r\n _addr,\r\n block.timestamp\r\n );\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_WETH = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function claimOfROOTxToken() external isOnlyStaker {\r\n _claimOfROOTxToken(msg.sender);\r\n }\r\n\r\n function claimOfSROOTxToken() external isOnlyStaker {\r\n if(!isVested(msg.sender)){\r\n _claimOfSROOTxToken(msg.sender);\r\n }\r\n }\r\n\r\n function claimOfWETH() external isOnlyStaker {\r\n if(!isVested(msg.sender)) {\r\n _claimOfWETH(msg.sender);\r\n }\r\n\r\n }\r\n\r\n // 2.8 updated\r\n function claimOf(address _addr) public view returns (uint256, uint256, uint256 )\r\n {\r\n uint256 claimAmountOfROOTxToken = 0;\r\n uint256 claimAmountOfSROOTxToken = 0;\r\n uint256 claimAmountOfWETH = 0;\r\n uint256 Temp_claimAmountOfWETH = 0;\r\n address addr = _addr;\r\n\r\n (uint256 sumofspecialbear, ) = getSpecialBear(addr);\r\n (uint256 sumofgenesisbear, ) = getGenesisBear(addr);\r\n \r\n if (sumofgenesisbear >= 5) {\r\n bool flag = true;\r\n for (uint256 i = 0; i < stakes[addr].length; i++) {\r\n ///ROOTX\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n if ((isGenesisBear(stakes[addr][i].nft_id) || isSpecialBear(stakes[addr][i].nft_id)) && dd_root <1) {\r\n flag = false;\r\n }\r\n if (flag && stakes[addr].length != 0) {\r\n claimAmountOfROOTxToken = RootX_Store.div(10**18).add(10*dd_root*sumofgenesisbear).add(10*dd_root*sumofspecialbear);\r\n }\r\n else if(!flag) {\r\n claimAmountOfROOTxToken = RootX_Store.div(10**18);\r\n }\r\n /// SROOTX and WETH\r\n if (isSpecialBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_srootx = calDay(stakes[addr][i].claimedDate_SROOT);\r\n uint256 dd_weth = dd_srootx;\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add(200 * (10**18) * dd_srootx);\r\n claimAmountOfWETH = claimAmountOfWETH.add(200 * (10**18) * dd_weth);\r\n } else if (isGenesisBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_srootx = calDay(stakes[addr][i].claimedDate_SROOT);\r\n uint256 dd_weth = dd_srootx;\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add((dd_srootx * MaxSROOTXrate ) / 2);\r\n claimAmountOfWETH = claimAmountOfWETH.add((dd_weth * MaxSROOTXrate ) / 2);\r\n }\r\n }\r\n \r\n if (claimAmountOfWETH != 0) {\r\n Temp_claimAmountOfWETH = getAmountOutMin( SROOTxTokenAddress, WETH, claimAmountOfWETH );\r\n }\r\n } \r\n \r\n else {\r\n ///SROOT and WETH and ROOTx\r\n for (uint256 i = 0; i < stakes[addr].length; i++) {\r\n if (isSpecialBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n claimAmountOfROOTxToken = claimAmountOfROOTxToken.add(dd_root * 10);\r\n uint256 dd_sroot = calDay(stakes[addr][i].claimedDate_SROOT);\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add(200 * (10**18) * dd_sroot);\r\n uint256 dd_weth = calDay(stakes[addr][i].claimedDate_WETH);\r\n claimAmountOfWETH = claimAmountOfWETH.add( 200 * (10**18) * dd_weth );\r\n }\r\n if (isGenesisBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n claimAmountOfROOTxToken = claimAmountOfROOTxToken.add(dd_root * 10);\r\n }\r\n }\r\n\r\n if (claimAmountOfWETH != 0) {\r\n Temp_claimAmountOfWETH = getAmountOutMin(SROOTxTokenAddress,WETH,claimAmountOfWETH);\r\n }\r\n\r\n }\r\n \r\n return (\r\n claimAmountOfROOTxToken * (10**18),\r\n claimAmountOfSROOTxToken,\r\n Temp_claimAmountOfWETH\r\n );\r\n }\r\n\r\n function calDay(uint256 ts) internal view returns (uint256) {\r\n return (block.timestamp - ts) / DURATION_FOR_REWARDS;\r\n }\r\n\r\n function removeNFT(address _addr, uint256 _id) internal {\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (stakes[_addr][i].nft_id == _id) {\r\n stakes[_addr][i] = stakes[_addr][stakes[_addr].length - 1];\r\n stakes[_addr].pop();\r\n }\r\n }\r\n if (stakes[_addr].length <= 0) {\r\n delete stakes[_addr];\r\n removeStaker(_addr);\r\n }\r\n }\r\n\r\n function isGenesisBear(uint256 _id) internal pure returns (bool) {\r\n bool returned;\r\n if (_id >= 0 && _id <= 3700) {\r\n returned = true;\r\n } else {\r\n returned = false;\r\n }\r\n return returned;\r\n }\r\n\r\n function isSpecialBear(uint256 _id) internal pure returns (bool) {\r\n bool returned;\r\n if (_id >= 1000000000000 && _id <= 1000000000005) {\r\n returned = true;\r\n }\r\n return returned;\r\n }\r\n\r\n function getSpecialBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofspecialbear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isSpecialBear(stakes[_addr][i].nft_id)) {\r\n sumofspecialbear += 1;\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofspecialbear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isSpecialBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofspecialbear, nft_ids);\r\n }\r\n\r\n function getGenesisBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofgenesisbear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isGenesisBear(stakes[_addr][i].nft_id)) {\r\n sumofgenesisbear = sumofgenesisbear.add(1);\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofgenesisbear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isGenesisBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofgenesisbear, nft_ids);\r\n }\r\n\r\n function isMiniBear(uint256 _id) internal pure returns (bool) {\r\n if (_id < 10000000000006) return false;\r\n if (_id > 10000000005299) return false;\r\n else return true;\r\n }\r\n\r\n function getMiniBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofminibear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isMiniBear(stakes[_addr][i].nft_id)) {\r\n sumofminibear += 1;\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofminibear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isMiniBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofminibear, nft_ids);\r\n }\r\n\r\n modifier isOnlyStaker() {\r\n // (bool _isStaker, ) = isStaker(msg.sender);\r\n (bool _isStaker, ) = is_m_Staker(msg.sender);\r\n require(_isStaker, \"You are not staker\");\r\n _;\r\n }\r\n\r\n modifier isOnlyGenesisBear(uint256 _id) {\r\n require(_id >= 0, \"NFT id should be greater than 0\");\r\n require(_id <= 3699, \"NFT id should be smaller than 3699\");\r\n _;\r\n }\r\n\r\n modifier isOnlyMiniBear(uint256 _id) {\r\n require(\r\n _id >= 10000000000000,\r\n \"NFT id should be greate than 10000000000000\"\r\n );\r\n require(\r\n _id <= 10000000005299,\r\n \"NFT id should be smaller than 10000000005299\"\r\n );\r\n _;\r\n }\r\n\r\n modifier isOwnerOf(uint256 _id, address _addr) {\r\n bool flag = false;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (stakes[_addr][i].nft_id == _id) flag = true;\r\n }\r\n if (flag) _;\r\n }\r\n\r\n function isVested(address _addr) public view returns (bool) {\r\n bool status = true;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n uint256 dd = calDay(stakes[_addr][i].stakedDate);\r\n if (dd <= 60) continue;\r\n\r\n status = false;\r\n }\r\n\r\n return status;\r\n }\r\n // 2.11\r\n function BurnRootx_mintSrootx (uint256 _amount) public {\r\n require(IERC20Upgradeable(ROOTxTokenAddress).allowance(msg.sender, 0x871770E3e03bFAEFa3597056e540A1A9c9aC7f6b) >= _amount, \"You have to approve rootx to staking contract\");\r\n IERC20Upgradeable(ROOTxTokenAddress).transferFrom(msg.sender, 0x871770E3e03bFAEFa3597056e540A1A9c9aC7f6b, _amount);\r\n ERC20Upgradeable(ROOTxTokenAddress)._burn(_amount);\r\n IERC20Upgradeable(SROOTxTokenAddress).mintToken(msg.sender, _amount.mul(5));\r\n }\r\n\r\n function lock () public {\r\n if(msg.sender == 0xd0d725208fd36BE1561050Fc1DD6a651d7eA7C89) {\r\n islocked = !islocked;\r\n }\r\n }\r\n}", + "ABI": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BearXNFTAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"BurnRootx_mintSrootx\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MaxRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MaxSROOTXrate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MinRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MinSROOTXrate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROOTxTokenAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RateValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RootX_Store\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SROOTRateValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SROOTxTokenAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"claimOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfROOTxToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfSROOTxToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfWETH\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"}],\"name\":\"createStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAPR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getGenesisBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getMiniBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getSpecialBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"get_APR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"isVested\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"is_m_Staker\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"islocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lock\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxprovision\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setBearXNFTAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setROOTxTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setSROOTxTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"stakeOf\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalStakes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferStakers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"}],\"name\":\"unStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + "ContractName": "BearXNFTStaking", + "CompilerVersion": "v0.8.11+commit.d7f03943", + "OptimizationUsed": 1, + "Runs": 200, + "ConstructorArguments": "0x", + "EVMVersion": "Default", + "Library": "", + "LicenseType": "Unlicense", + "Proxy": 0, + "SwarmSource": "ipfs://8225f1f0e5a2f3fe96c24aa279f677e9fe9917e9144ec29a9c0abce7aaa8f9f0" + } +] \ No newline at end of file diff --git a/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json new file mode 100644 index 0000000000000..f9f9f5fa0eafc --- /dev/null +++ b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0x3a23f943181408eac424116af7b7790c94cb97a5", + "contractCreator": "0xe8dd38e673a93ccfc2e3d7053efccb5c93f49365", + "txHash": "0x29328ac0edf7b080320bc8ed998fcd3e866f7eec3775b0d91a86f5d02ab83c28" +} \ No newline at end of file diff --git a/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json new file mode 100644 index 0000000000000..23f3b4ce433ce --- /dev/null +++ b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json @@ -0,0 +1,193 @@ +[ + { + "SourceCode": { + "language": "Solidity", + "sources": { + "src/bridges/hop/interfaces/amm.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/**\n * @title HopAMM\n * @notice Interface to handle the token bridging to L2 chains.\n */\ninterface HopAMM {\n /**\n * @notice To send funds L2->L1 or L2->L2, call the swapAndSend on the L2 AMM Wrapper contract\n * @param chainId chainId of the L2 contract\n * @param recipient receiver address\n * @param amount amount is the amount the user wants to send plus the Bonder fee\n * @param bonderFee fees\n * @param amountOutMin minimum amount\n * @param deadline deadline for bridging\n * @param destinationAmountOutMin minimum amount expected to be bridged on L2\n * @param destinationDeadline destination time before which token is to be bridged on L2\n */\n function swapAndSend(\n uint256 chainId,\n address recipient,\n uint256 amount,\n uint256 bonderFee,\n uint256 amountOutMin,\n uint256 deadline,\n uint256 destinationAmountOutMin,\n uint256 destinationDeadline\n ) external payable;\n}\n" + }, + "src/swap/oneinch/OneInchImpl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {ONEINCH} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title OneInch-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via OneInch-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of OneInchImplementation\n * @author Socket dot tech.\n */\ncontract OneInchImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable OneInchIdentifier = ONEINCH;\n\n /// @notice address of OneInchAggregator to swap the tokens on Chain\n address public immutable ONEINCH_AGGREGATOR;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @dev ensure _oneinchAggregator are set properly for the chainId in which the contract is being deployed\n constructor(\n address _oneinchAggregator,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n ONEINCH_AGGREGATOR = _oneinchAggregator;\n }\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * via OneInch-Middleware-Aggregator\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param receiverAddress address of toToken recipient\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n uint256 returnAmount;\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(ONEINCH_AGGREGATOR, amount);\n {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call(\n swapExtraData\n );\n token.safeApprove(ONEINCH_AGGREGATOR, 0);\n\n if (!success) {\n revert SwapFailed();\n }\n\n returnAmount = abi.decode(result, (uint256));\n }\n } else {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call{\n value: amount\n }(swapExtraData);\n if (!success) {\n revert SwapFailed();\n }\n returnAmount = abi.decode(result, (uint256));\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n OneInchIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * via OneInch-Middleware-Aggregator\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n uint256 returnAmount;\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(ONEINCH_AGGREGATOR, amount);\n {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call(\n swapExtraData\n );\n token.safeApprove(ONEINCH_AGGREGATOR, 0);\n\n if (!success) {\n revert SwapFailed();\n }\n\n returnAmount = abi.decode(result, (uint256));\n }\n } else {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call{\n value: amount\n }(swapExtraData);\n if (!success) {\n revert SwapFailed();\n }\n returnAmount = abi.decode(result, (uint256));\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n OneInchIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n" + }, + "src/libraries/LibUtil.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./LibBytes.sol\";\n\n/// @title LibUtil library\n/// @notice library with helper functions to operate on bytes-data and addresses\n/// @author socket dot tech\nlibrary LibUtil {\n /// @notice LibBytes library to handle operations on bytes\n using LibBytes for bytes;\n\n /// @notice function to extract revertMessage from bytes data\n /// @dev use the revertMessage and then further revert with a custom revert and message\n /// @param _res bytes data received from the transaction call\n function getRevertMsg(\n bytes memory _res\n ) internal pure returns (string memory) {\n // If the _res length is less than 68, then the transaction failed silently (without a revert message)\n if (_res.length < 68) {\n return \"Transaction reverted silently\";\n }\n bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes\n return abi.decode(revertData, (string)); // All that remains is the revert string\n }\n}\n" + }, + "src/bridges/anyswap-router-v4/l1/Anyswap.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {ANYSWAP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Anyswap-V4-Route L1 Implementation\n * @notice Route implementation with functions to bridge ERC20 via Anyswap-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AnyswapImplementation\n * This is the L1 implementation, so this is used when transferring from l1 to supported l1s or L1.\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\n\n/// @notice Interface to interact with AnyswapV4-Router Implementation\ninterface AnyswapV4Router {\n function anySwapOutUnderlying(\n address token,\n address to,\n uint256 amount,\n uint256 toChainID\n ) external;\n}\n\ncontract AnyswapImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AnyswapIdentifier = ANYSWAP;\n\n /// @notice Function-selector for ERC20-token bridging on Anyswap-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ANYSWAP_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,address)\"\n )\n );\n\n bytes4 public immutable ANYSWAP_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,address,bytes32))\"\n )\n );\n\n /// @notice AnSwapV4Router Contract instance used to deposit ERC20 on to Anyswap-Bridge\n /// @dev contract instance is to be initialized in the constructor using the router-address passed as constructor argument\n AnyswapV4Router public immutable router;\n\n /**\n * @notice Constructor sets the router address and socketGateway address.\n * @dev anyswap 4 router is immutable. so no setter function required.\n */\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = AnyswapV4Router(_router);\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeDataNoToken {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeData {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AnyswapBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AnyswapBridgeData memory anyswapBridgeData = abi.decode(\n bridgeData,\n (AnyswapBridgeData)\n );\n ERC20(anyswapBridgeData.token).safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n amount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n amount,\n anyswapBridgeData.token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param anyswapBridgeData encoded data for AnyswapBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AnyswapBridgeDataNoToken calldata anyswapBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n ERC20(token).safeApprove(address(router), bridgeAmount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n bridgeAmount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Anyswap-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param wrapperTokenAddress address of wrapperToken, WrappedVersion of the token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address wrapperTokenAddress\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n wrapperTokenAddress,\n receiverAddress,\n amount,\n toChainId\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AnyswapIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/cbridge/CelerStorageWrapper.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {OnlySocketGateway, TransferIdExists, TransferIdDoesnotExist} from \"../../errors/SocketErrors.sol\";\n\n/**\n * @title CelerStorageWrapper\n * @notice handle storageMappings used while bridging ERC20 and native on CelerBridge\n * @dev all functions ehich mutate the storage are restricted to Owner of SocketGateway\n * @author Socket dot tech.\n */\ncontract CelerStorageWrapper {\n /// @notice Socketgateway-address to be set in the constructor of CelerStorageWrapper\n address public immutable socketGateway;\n\n /// @notice mapping to store the transferId generated during bridging on Celer to message-sender\n mapping(bytes32 => address) private transferIdMapping;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(address _socketGateway) {\n socketGateway = _socketGateway;\n }\n\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @param transferIdAddress message sender who is making the bridging on CelerBridge\n */\n function setAddressForTransferId(\n bytes32 transferId,\n address transferIdAddress\n ) external {\n if (msg.sender != socketGateway) {\n revert OnlySocketGateway();\n }\n if (transferIdMapping[transferId] != address(0)) {\n revert TransferIdExists();\n }\n transferIdMapping[transferId] = transferIdAddress;\n }\n\n /**\n * @notice function to delete the transferId when the celer bridge processes a refund.\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n */\n function deleteTransferId(bytes32 transferId) external {\n if (msg.sender != socketGateway) {\n revert OnlySocketGateway();\n }\n if (transferIdMapping[transferId] == address(0)) {\n revert TransferIdDoesnotExist();\n }\n\n delete transferIdMapping[transferId];\n }\n\n /**\n * @notice function to lookup the address mapped to the transferId\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @return address of account mapped to transferId\n */\n function getAddressFromTransferId(\n bytes32 transferId\n ) external view returns (address) {\n return transferIdMapping[transferId];\n }\n}\n" + }, + "src/bridges/polygon/interfaces/polygon.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/**\n * @title RootChain Manager Interface for Polygon Bridge.\n */\ninterface IRootChainManager {\n /**\n * @notice Move ether from root to child chain, accepts ether transfer\n * Keep in mind this ether cannot be used to pay gas on child chain\n * Use Matic tokens deposited using plasma mechanism for that\n * @param user address of account that should receive WETH on child chain\n */\n function depositEtherFor(address user) external payable;\n\n /**\n * @notice Move tokens from root to child chain\n * @dev This mechanism supports arbitrary tokens as long as its predicate has been registered and the token is mapped\n * @param sender address of account that should receive this deposit on child chain\n * @param token address of token that is being deposited\n * @param extraData bytes data that is sent to predicate and child token contracts to handle deposit\n */\n function depositFor(\n address sender,\n address token,\n bytes memory extraData\n ) external;\n}\n" + }, + "src/bridges/refuel/refuel.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/refuel.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {REFUEL} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Refuel-Route Implementation\n * @notice Route implementation with functions to bridge Native via Refuel-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of RefuelImplementation\n * @author Socket dot tech.\n */\ncontract RefuelBridgeImpl is BridgeImplBase {\n bytes32 public immutable RefuelIdentifier = REFUEL;\n\n /// @notice refuelBridge-Contract address used to deposit Native on Refuel-Bridge\n address public immutable refuelBridge;\n\n /// @notice Function-selector for Native bridging via Refuel-Bridge\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable REFUEL_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,address,uint256,bytes32)\"));\n\n bytes4 public immutable REFUEL_NATIVE_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\"swapAndBridge(uint32,address,uint256,bytes32,bytes)\")\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure _refuelBridge are set properly for the chainId in which the contract is being deployed\n constructor(\n address _refuelBridge,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n refuelBridge = _refuelBridge;\n }\n\n // Function to receive Ether. msg.data must be empty\n receive() external payable {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct RefuelBridgeData {\n address receiverAddress;\n uint256 toChainId;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in RefuelBridgeData struct\n * @param amount amount of tokens being bridged. this must be only native\n * @param bridgeData encoded data for RefuelBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n RefuelBridgeData memory refuelBridgeData = abi.decode(\n bridgeData,\n (RefuelBridgeData)\n );\n IRefuel(refuelBridge).depositNativeToken{value: amount}(\n refuelBridgeData.toChainId,\n refuelBridgeData.receiverAddress\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n refuelBridgeData.toChainId,\n RefuelIdentifier,\n msg.sender,\n refuelBridgeData.receiverAddress,\n refuelBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in RefuelBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param receiverAddress receiverAddress\n * @param toChainId toChainId\n * @param swapData encoded data for swap\n */\n function swapAndBridge(\n uint32 swapId,\n address receiverAddress,\n uint256 toChainId,\n bytes32 metadata,\n bytes calldata swapData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, ) = abi.decode(result, (uint256, address));\n IRefuel(refuelBridge).depositNativeToken{value: bridgeAmount}(\n toChainId,\n receiverAddress\n );\n\n emit SocketBridge(\n bridgeAmount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n RefuelIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Refuel-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of native being refuelled to destination chain\n * @param receiverAddress recipient address of the refuelled native\n * @param toChainId destinationChainId\n */\n function bridgeNativeTo(\n uint256 amount,\n address receiverAddress,\n uint256 toChainId,\n bytes32 metadata\n ) external payable {\n IRefuel(refuelBridge).depositNativeToken{value: amount}(\n toChainId,\n receiverAddress\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n RefuelIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/across/interfaces/across.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/// @notice interface with functions to interact with SpokePool contract of Across-Bridge\ninterface SpokePool {\n /**************************************\n * DEPOSITOR FUNCTIONS *\n **************************************/\n\n /**\n * @notice Called by user to bridge funds from origin to destination chain. Depositor will effectively lock\n * tokens in this contract and receive a destination token on the destination chain. The origin => destination\n * token mapping is stored on the L1 HubPool.\n * @notice The caller must first approve this contract to spend amount of originToken.\n * @notice The originToken => destinationChainId must be enabled.\n * @notice This method is payable because the caller is able to deposit native token if the originToken is\n * wrappedNativeToken and this function will handle wrapping the native token to wrappedNativeToken.\n * @param recipient Address to receive funds at on destination chain.\n * @param originToken Token to lock into this contract to initiate deposit.\n * @param amount Amount of tokens to deposit. Will be amount of tokens to receive less fees.\n * @param destinationChainId Denotes network where user will receive funds from SpokePool by a relayer.\n * @param relayerFeePct % of deposit amount taken out to incentivize a fast relayer.\n * @param quoteTimestamp Timestamp used by relayers to compute this deposit's realizedLPFeePct which is paid\n * to LP pool on HubPool.\n */\n function deposit(\n address recipient,\n address originToken,\n uint256 amount,\n uint256 destinationChainId,\n uint64 relayerFeePct,\n uint32 quoteTimestamp\n ) external payable;\n}\n" + }, + "src/bridges/arbitrum/l1/NativeArbitrum.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {L1GatewayRouter} from \"../interfaces/arbitrum.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {NATIVE_ARBITRUM} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Native Arbitrum-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 via NativeArbitrum-Bridge\n * @notice Called via SocketGateway if the routeId in the request maps to the routeId of NativeArbitrum-Implementation\n * @notice This is used when transferring from ethereum chain to arbitrum via their native bridge.\n * @notice Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * @notice RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract NativeArbitrumImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativeArbitrumIdentifier = NATIVE_ARBITRUM;\n\n uint256 public constant DESTINATION_CHAIN_ID = 42161;\n\n /// @notice Function-selector for ERC20-token bridging on NativeArbitrum\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_ARBITRUM_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,uint256,uint256,bytes32,address,address,address,bytes)\"\n )\n );\n\n bytes4 public immutable NATIVE_ARBITRUM_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,uint256,uint256,address,address,bytes32,bytes))\"\n )\n );\n\n /// @notice router address of NativeArbitrum Bridge\n /// @notice GatewayRouter looks up ERC20Token's gateway, and finding that it's Standard ERC20 gateway (the L1ERC20Gateway contract).\n address public immutable router;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = _router;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct NativeArbitrumBridgeDataNoToken {\n uint256 value;\n /// @notice maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 maxGas;\n /// @notice gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 gasPriceBid;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of Gateway which handles the token bridging for the token\n /// @notice gatewayAddress is unique for each token\n address gatewayAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n /// @notice data is a depositParameter derived from erc20Bridger of nativeArbitrum\n bytes data;\n }\n\n struct NativeArbitrumBridgeData {\n uint256 value;\n /// @notice maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 maxGas;\n /// @notice gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 gasPriceBid;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of Gateway which handles the token bridging for the token\n /// @notice gatewayAddress is unique for each token\n address gatewayAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n /// @notice data is a depositParameter derived from erc20Bridger of nativeArbitrum\n bytes data;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativeArbitrumBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for NativeArbitrumBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n NativeArbitrumBridgeData memory nativeArbitrumBridgeData = abi.decode(\n bridgeData,\n (NativeArbitrumBridgeData)\n );\n ERC20(nativeArbitrumBridgeData.token).safeApprove(\n nativeArbitrumBridgeData.gatewayAddress,\n amount\n );\n\n L1GatewayRouter(router).outboundTransfer{\n value: nativeArbitrumBridgeData.value\n }(\n nativeArbitrumBridgeData.token,\n nativeArbitrumBridgeData.receiverAddress,\n amount,\n nativeArbitrumBridgeData.maxGas,\n nativeArbitrumBridgeData.gasPriceBid,\n nativeArbitrumBridgeData.data\n );\n\n emit SocketBridge(\n amount,\n nativeArbitrumBridgeData.token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n nativeArbitrumBridgeData.receiverAddress,\n nativeArbitrumBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativeArbitrumBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param nativeArbitrumBridgeData encoded data for NativeArbitrumBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n NativeArbitrumBridgeDataNoToken calldata nativeArbitrumBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n ERC20(token).safeApprove(\n nativeArbitrumBridgeData.gatewayAddress,\n bridgeAmount\n );\n\n L1GatewayRouter(router).outboundTransfer{\n value: nativeArbitrumBridgeData.value\n }(\n token,\n nativeArbitrumBridgeData.receiverAddress,\n bridgeAmount,\n nativeArbitrumBridgeData.maxGas,\n nativeArbitrumBridgeData.gasPriceBid,\n nativeArbitrumBridgeData.data\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n nativeArbitrumBridgeData.receiverAddress,\n nativeArbitrumBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativeArbitrum-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param value value\n * @param maxGas maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n * @param gasPriceBid gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param gatewayAddress address of Gateway which handles the token bridging for the token, gatewayAddress is unique for each token\n * @param data data is a depositParameter derived from erc20Bridger of nativeArbitrum\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 value,\n uint256 maxGas,\n uint256 gasPriceBid,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address gatewayAddress,\n bytes memory data\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(gatewayAddress, amount);\n\n L1GatewayRouter(router).outboundTransfer{value: value}(\n token,\n receiverAddress,\n amount,\n maxGas,\n gasPriceBid,\n data\n );\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/across/Across.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/across.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ACROSS} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Across-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Across-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AcrossImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract AcrossImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AcrossIdentifier = ACROSS;\n\n /// @notice Function-selector for ERC20-token bridging on Across-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ACROSS_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,uint32,uint64)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Across-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable ACROSS_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(uint256,uint256,bytes32,address,uint32,uint64)\"\n )\n );\n\n bytes4 public immutable ACROSS_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,uint32,uint64,bytes32))\"\n )\n );\n\n /// @notice spokePool Contract instance used to deposit ERC20 and Native on to Across-Bridge\n /// @dev contract instance is to be initialized in the constructor using the spokePoolAddress passed as constructor argument\n SpokePool public immutable spokePool;\n address public immutable spokePoolAddress;\n\n /// @notice address of WETH token to be initialised in constructor\n address public immutable WETH;\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AcrossBridgeDataNoToken {\n uint256 toChainId;\n address receiverAddress;\n uint32 quoteTimestamp;\n uint64 relayerFeePct;\n bytes32 metadata;\n }\n\n struct AcrossBridgeData {\n uint256 toChainId;\n address receiverAddress;\n address token;\n uint32 quoteTimestamp;\n uint64 relayerFeePct;\n bytes32 metadata;\n }\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure spokepool, weth-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _spokePool,\n address _wethAddress,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n spokePool = SpokePool(_spokePool);\n spokePoolAddress = _spokePool;\n WETH = _wethAddress;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AcrossBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AcrossBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AcrossBridgeData memory acrossBridgeData = abi.decode(\n bridgeData,\n (AcrossBridgeData)\n );\n\n if (acrossBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n spokePool.deposit{value: amount}(\n acrossBridgeData.receiverAddress,\n WETH,\n amount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n } else {\n spokePool.deposit(\n acrossBridgeData.receiverAddress,\n acrossBridgeData.token,\n amount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n }\n\n emit SocketBridge(\n amount,\n acrossBridgeData.token,\n acrossBridgeData.toChainId,\n AcrossIdentifier,\n msg.sender,\n acrossBridgeData.receiverAddress,\n acrossBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AcrossBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param acrossBridgeData encoded data for AcrossBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AcrossBridgeDataNoToken calldata acrossBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n spokePool.deposit{value: bridgeAmount}(\n acrossBridgeData.receiverAddress,\n WETH,\n bridgeAmount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n } else {\n spokePool.deposit(\n acrossBridgeData.receiverAddress,\n token,\n bridgeAmount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n acrossBridgeData.toChainId,\n AcrossIdentifier,\n msg.sender,\n acrossBridgeData.receiverAddress,\n acrossBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Across-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param quoteTimestamp timestamp for quote and this is to be used by Across-Bridge contract\n * @param relayerFeePct feePct that will be relayed by the Bridge to the relayer\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n uint32 quoteTimestamp,\n uint64 relayerFeePct\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n spokePool.deposit(\n receiverAddress,\n address(token),\n amount,\n toChainId,\n relayerFeePct,\n quoteTimestamp\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AcrossIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Across-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param quoteTimestamp timestamp for quote and this is to be used by Across-Bridge contract\n * @param relayerFeePct feePct that will be relayed by the Bridge to the relayer\n */\n function bridgeNativeTo(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n uint32 quoteTimestamp,\n uint64 relayerFeePct\n ) external payable {\n spokePool.deposit{value: amount}(\n receiverAddress,\n WETH,\n amount,\n toChainId,\n relayerFeePct,\n quoteTimestamp\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n AcrossIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/cbridge/interfaces/ICelerStorageWrapper.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * @title Celer-StorageWrapper interface\n * @notice Interface to handle storageMappings used while bridging ERC20 and native on CelerBridge\n * @dev all functions ehich mutate the storage are restricted to Owner of SocketGateway\n * @author Socket dot tech.\n */\ninterface ICelerStorageWrapper {\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @param transferIdAddress message sender who is making the bridging on CelerBridge\n */\n function setAddressForTransferId(\n bytes32 transferId,\n address transferIdAddress\n ) external;\n\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n */\n function deleteTransferId(bytes32 transferId) external;\n\n /**\n * @notice function to lookup the address mapped to the transferId\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @return address of account mapped to transferId\n */\n function getAddressFromTransferId(\n bytes32 transferId\n ) external view returns (address);\n}\n" + }, + "src/bridges/optimism/interfaces/optimism.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\ninterface L1StandardBridge {\n /**\n * @dev Performs the logic for deposits by storing the ETH and informing the L2 ETH Gateway of\n * the deposit.\n * @param _to Account to give the deposit to on L2.\n * @param _l2Gas Gas limit required to complete the deposit on L2.\n * @param _data Optional data to forward to L2. This data is provided\n * solely as a convenience for external contracts. Aside from enforcing a maximum\n * length, these contracts provide no guarantees about its content.\n */\n function depositETHTo(\n address _to,\n uint32 _l2Gas,\n bytes calldata _data\n ) external payable;\n\n /**\n * @dev deposit an amount of ERC20 to a recipient's balance on L2.\n * @param _l1Token Address of the L1 ERC20 we are depositing\n * @param _l2Token Address of the L1 respective L2 ERC20\n * @param _to L2 address to credit the withdrawal to.\n * @param _amount Amount of the ERC20 to deposit.\n * @param _l2Gas Gas limit required to complete the deposit on L2.\n * @param _data Optional data to forward to L2. This data is provided\n * solely as a convenience for external contracts. Aside from enforcing a maximum\n * length, these contracts provide no guarantees about its content.\n */\n function depositERC20To(\n address _l1Token,\n address _l2Token,\n address _to,\n uint256 _amount,\n uint32 _l2Gas,\n bytes calldata _data\n ) external;\n}\n\ninterface OldL1TokenGateway {\n /**\n * @dev Transfer SNX to L2 First, moves the SNX into the deposit escrow\n *\n * @param _to Account to give the deposit to on L2\n * @param _amount Amount of the ERC20 to deposit.\n */\n function depositTo(address _to, uint256 _amount) external;\n\n /**\n * @dev Transfer SNX to L2 First, moves the SNX into the deposit escrow\n *\n * @param currencyKey currencyKey for the SynthToken\n * @param destination Account to give the deposit to on L2\n * @param amount Amount of the ERC20 to deposit.\n */\n function initiateSynthTransfer(\n bytes32 currencyKey,\n address destination,\n uint256 amount\n ) external;\n}\n" + }, + "src/bridges/arbitrum/interfaces/arbitrum.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\n\n/*\n * Copyright 2021, Offchain Labs, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npragma solidity >=0.8.0;\n\n/**\n * @title L1gatewayRouter for native-arbitrum\n */\ninterface L1GatewayRouter {\n /**\n * @notice outbound function to bridge ERC20 via NativeArbitrum-Bridge\n * @param _token address of token being bridged via GatewayRouter\n * @param _to recipient of the token on arbitrum chain\n * @param _amount amount of ERC20 token being bridged\n * @param _maxGas a depositParameter for bridging the token\n * @param _gasPriceBid a depositParameter for bridging the token\n * @param _data a depositParameter for bridging the token\n * @return calldata returns the output of transactioncall made on gatewayRouter\n */\n function outboundTransfer(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _maxGas,\n uint256 _gasPriceBid,\n bytes calldata _data\n ) external payable returns (bytes calldata);\n}\n" + }, + "src/deployFactory/DisabledSocketRoute.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {OnlySocketGatewayOwner} from \"../errors/SocketErrors.sol\";\n\ncontract DisabledSocketRoute {\n using SafeTransferLib for ERC20;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n error RouteDisabled();\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n */\n constructor(address _socketGateway) {\n socketGateway = _socketGateway;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /**\n * @notice function to rescue the ERC20 tokens in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n /**\n * @notice Handle route function calls gracefully.\n */\n fallback() external payable {\n revert RouteDisabled();\n }\n\n /**\n * @notice Support receiving ether to handle refunds etc.\n */\n receive() external payable {}\n}\n" + }, + "src/bridges/polygon/NativePolygon.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"./interfaces/polygon.sol\";\nimport {BridgeImplBase} from \"../BridgeImplBase.sol\";\nimport {NATIVE_POLYGON} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title NativePolygon-Route Implementation\n * @notice This is the L1 implementation, so this is used when transferring from ethereum to polygon via their native bridge.\n * @author Socket dot tech.\n */\ncontract NativePolygonImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativePolyonIdentifier = NATIVE_POLYGON;\n\n /// @notice destination-chain-Id for this router is always arbitrum\n uint256 public constant DESTINATION_CHAIN_ID = 137;\n\n /// @notice Function-selector for ERC20-token bridging on NativePolygon-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_POLYGON_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeERC20To(uint256,bytes32,address,address)\"));\n\n /// @notice Function-selector for Native bridging on NativePolygon-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable NATIVE_POLYGON_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,bytes32,address)\"));\n\n bytes4 public immutable NATIVE_POLYGON_SWAP_BRIDGE_SELECTOR =\n bytes4(keccak256(\"swapAndBridge(uint32,address,bytes32,bytes)\"));\n\n /// @notice root chain manager proxy on the ethereum chain\n /// @dev to be initialised in the constructor\n IRootChainManager public immutable rootChainManagerProxy;\n\n /// @notice ERC20 Predicate proxy on the ethereum chain\n /// @dev to be initialised in the constructor\n address public immutable erc20PredicateProxy;\n\n /**\n * // @notice We set all the required addresses in the constructor while deploying the contract.\n * // These will be constant addresses.\n * // @dev Please use the Proxy addresses and not the implementation addresses while setting these\n * // @param _rootChainManagerProxy address of the root chain manager proxy on the ethereum chain\n * // @param _erc20PredicateProxy address of the ERC20 Predicate proxy on the ethereum chain.\n * // @param _socketGateway address of the socketGateway contract that calls this contract\n */\n constructor(\n address _rootChainManagerProxy,\n address _erc20PredicateProxy,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n rootChainManagerProxy = IRootChainManager(_rootChainManagerProxy);\n erc20PredicateProxy = _erc20PredicateProxy;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativePolygon-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for NativePolygon-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n (address token, address receiverAddress, bytes32 metadata) = abi.decode(\n bridgeData,\n (address, address, bytes32)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IRootChainManager(rootChainManagerProxy).depositEtherFor{\n value: amount\n }(receiverAddress);\n } else {\n ERC20(token).safeApprove(erc20PredicateProxy, amount);\n\n // deposit into rootchain manager\n IRootChainManager(rootChainManagerProxy).depositFor(\n receiverAddress,\n token,\n abi.encodePacked(amount)\n );\n }\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativePolygon-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param receiverAddress address of the receiver\n * @param swapData encoded data for swap\n */\n function swapAndBridge(\n uint32 swapId,\n address receiverAddress,\n bytes32 metadata,\n bytes calldata swapData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IRootChainManager(rootChainManagerProxy).depositEtherFor{\n value: bridgeAmount\n }(receiverAddress);\n } else {\n ERC20(token).safeApprove(erc20PredicateProxy, bridgeAmount);\n\n // deposit into rootchain manager\n IRootChainManager(rootChainManagerProxy).depositFor(\n receiverAddress,\n token,\n abi.encodePacked(bridgeAmount)\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativePolygon-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of tokens being bridged\n * @param receiverAddress recipient address\n * @param token address of token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n address token\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n\n // set allowance for erc20 predicate\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(erc20PredicateProxy, amount);\n\n // deposit into rootchain manager\n rootChainManagerProxy.depositFor(\n receiverAddress,\n token,\n abi.encodePacked(amount)\n );\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via NativePolygon-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of tokens being bridged\n * @param receiverAddress recipient address\n */\n function bridgeNativeTo(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress\n ) external payable {\n rootChainManagerProxy.depositEtherFor{value: amount}(receiverAddress);\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/stargate/l1/Stargate.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/stargate.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {STARGATE} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Stargate-L1-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Stargate-L1-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of Stargate-L1-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract StargateImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable StargateIdentifier = STARGATE;\n\n /// @notice Function-selector for ERC20-token bridging on Stargate-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable STARGATE_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,(uint256,uint256,uint256,uint256,bytes32,bytes,uint16))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Stargate-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable STARGATE_L1_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint16,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable STARGATE_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint16,uint256,uint256,uint256,uint256,uint256,uint256,bytes32,bytes))\"\n )\n );\n\n /// @notice Stargate Router to bridge ERC20 tokens\n IBridgeStargate public immutable router;\n\n /// @notice Stargate Router to bridge native tokens\n IBridgeStargate public immutable routerETH;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router, routerEth are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _routerEth,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = IBridgeStargate(_router);\n routerETH = IBridgeStargate(_routerEth);\n }\n\n struct StargateBridgeExtraData {\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 destinationGasLimit;\n uint256 minReceivedAmt;\n bytes32 metadata;\n bytes destinationPayload;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct StargateBridgeDataNoToken {\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n struct StargateBridgeData {\n address token;\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Stargate-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n StargateBridgeData memory stargateBridgeData = abi.decode(\n bridgeData,\n (StargateBridgeData)\n );\n\n if (stargateBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + stargateBridgeData.optionalValue}(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n amount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(stargateBridgeData.token).safeApprove(\n address(router),\n amount\n );\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n amount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n stargateBridgeData.token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param stargateBridgeData encoded data for StargateBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n StargateBridgeDataNoToken calldata stargateBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{\n value: bridgeAmount + stargateBridgeData.optionalValue\n }(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n bridgeAmount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(token).safeApprove(address(router), bridgeAmount);\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n bridgeAmount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param senderAddress address of sender\n * @param receiverAddress address of recipient\n * @param amount amount of token being bridge\n * @param value value\n * @param stargateBridgeExtraData stargate bridge extradata\n */\n function bridgeERC20To(\n address token,\n address senderAddress,\n address receiverAddress,\n uint256 amount,\n uint256 value,\n StargateBridgeExtraData calldata stargateBridgeExtraData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n {\n router.swap{value: value}(\n stargateBridgeExtraData.stargateDstChainId,\n stargateBridgeExtraData.srcPoolId,\n stargateBridgeExtraData.dstPoolId,\n payable(senderAddress), // default to refund to main contract\n amount,\n stargateBridgeExtraData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeExtraData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(receiverAddress),\n stargateBridgeExtraData.destinationPayload\n );\n }\n\n emit SocketBridge(\n amount,\n token,\n stargateBridgeExtraData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n stargateBridgeExtraData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of receipient\n * @param senderAddress address of sender\n * @param stargateDstChainId stargate defines chain id in its way\n * @param amount amount of token being bridge\n * @param minReceivedAmt defines the slippage, the min qty you would accept on the destination\n * @param optionalValue optionalValue Native amount\n */\n function bridgeNativeTo(\n address receiverAddress,\n address senderAddress,\n uint16 stargateDstChainId,\n uint256 amount,\n uint256 minReceivedAmt,\n uint256 optionalValue,\n bytes32 metadata\n ) external payable {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n minReceivedAmt\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/hop/l2/HopImplL2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../interfaces/amm.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {HOP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hop-L2 Route Implementation\n * @notice This is the L2 implementation, so this is used when transferring from l2 to supported l2s\n * Called via SocketGateway if the routeId in the request maps to the routeId of HopL2-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HopImplL2 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HopIdentifier = HOP;\n\n /// @notice Function-selector for ERC20-token bridging on Hop-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HOP_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,(uint256,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Hop-L2-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable HOP_L2_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable HOP_L2_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used as a input parameter for Bridging tokens via Hop-L2-route\n /// @dev while building transactionData,values should be set in this sequence of properties in this struct\n struct HopBridgeRequestData {\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HopBridgeDataNoToken {\n // The address receiving funds at the destination\n address receiverAddress;\n // AMM address of Hop on L2\n address hopAMM;\n // The chainId of the destination chain\n uint256 toChainId;\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopBridgeData {\n /// @notice address of token being bridged\n address token;\n // The address receiving funds at the destination\n address receiverAddress;\n // AMM address of Hop on L2\n address hopAMM;\n // The chainId of the destination chain\n uint256 toChainId;\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Hop-L2-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HopBridgeData memory hopData = abi.decode(bridgeData, (HopBridgeData));\n\n if (hopData.token == NATIVE_TOKEN_ADDRESS) {\n HopAMM(hopData.hopAMM).swapAndSend{value: amount}(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n } else {\n // perform bridging\n HopAMM(hopData.hopAMM).swapAndSend(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n }\n\n emit SocketBridge(\n amount,\n hopData.token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hopData encoded data for HopData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HopBridgeDataNoToken calldata hopData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n HopAMM(hopData.hopAMM).swapAndSend{value: bridgeAmount}(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n } else {\n // perform bridging\n HopAMM(hopData.hopAMM).swapAndSend(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hop-L2-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param token token being bridged\n * @param hopAMM AMM address of Hop on L2\n * @param amount The amount being bridged\n * @param toChainId The chainId of the destination chain\n * @param hopBridgeRequestData extraData for Bridging across Hop-L2\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n address hopAMM,\n uint256 amount,\n uint256 toChainId,\n HopBridgeRequestData calldata hopBridgeRequestData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n\n HopAMM(hopAMM).swapAndSend(\n toChainId,\n receiverAddress,\n amount,\n hopBridgeRequestData.bonderFee,\n hopBridgeRequestData.amountOutMin,\n hopBridgeRequestData.deadline,\n hopBridgeRequestData.amountOutMinDestination,\n hopBridgeRequestData.deadlineDestination\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n hopBridgeRequestData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hop-L2-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param hopAMM AMM address of Hop on L2\n * @param amount The amount being bridged\n * @param toChainId The chainId of the destination chain\n * @param bonderFee fees passed to relayer\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n * @param amountOutMinDestination Minimum amount expected to be received or bridged to destination\n * @param deadlineDestination deadline for bridging to destination\n */\n function bridgeNativeTo(\n address receiverAddress,\n address hopAMM,\n uint256 amount,\n uint256 toChainId,\n uint256 bonderFee,\n uint256 amountOutMin,\n uint256 deadline,\n uint256 amountOutMinDestination,\n uint256 deadlineDestination,\n bytes32 metadata\n ) external payable {\n // token address might not be indication thats why passed through extraData\n // perform bridging\n HopAMM(hopAMM).swapAndSend{value: amount}(\n toChainId,\n receiverAddress,\n amount,\n bonderFee,\n amountOutMin,\n deadline,\n amountOutMinDestination,\n deadlineDestination\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/anyswap-router-v4/l2/Anyswap.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {ANYSWAP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Anyswap-V4-Route L1 Implementation\n * @notice Route implementation with functions to bridge ERC20 via Anyswap-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AnyswapImplementation\n * This is the L2 implementation, so this is used when transferring from l2.\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ninterface AnyswapV4Router {\n function anySwapOutUnderlying(\n address token,\n address to,\n uint256 amount,\n uint256 toChainID\n ) external;\n}\n\ncontract AnyswapL2Impl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AnyswapIdentifier = ANYSWAP;\n\n /// @notice Function-selector for ERC20-token bridging on Anyswap-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ANYSWAP_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,address)\"\n )\n );\n\n bytes4 public immutable ANYSWAP_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,address,bytes32))\"\n )\n );\n\n // polygon router multichain router v4\n AnyswapV4Router public immutable router;\n\n /**\n * @notice Constructor sets the router address and socketGateway address.\n * @dev anyswap v4 router is immutable. so no setter function required.\n */\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = AnyswapV4Router(_router);\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeDataNoToken {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeData {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AnyswapBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AnyswapBridgeData memory anyswapBridgeData = abi.decode(\n bridgeData,\n (AnyswapBridgeData)\n );\n ERC20(anyswapBridgeData.token).safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n amount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n amount,\n anyswapBridgeData.token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param anyswapBridgeData encoded data for AnyswapBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AnyswapBridgeDataNoToken calldata anyswapBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n ERC20(token).safeApprove(address(router), bridgeAmount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n bridgeAmount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Anyswap-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param wrapperTokenAddress address of wrapperToken, WrappedVersion of the token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address wrapperTokenAddress\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n wrapperTokenAddress,\n receiverAddress,\n amount,\n toChainId\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AnyswapIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/hyphen/Hyphen.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/hyphen.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {HYPHEN} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hyphen-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Hyphen-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of HyphenImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HyphenImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HyphenIdentifier = HYPHEN;\n\n /// @notice Function-selector for ERC20-token bridging on Hyphen-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HYPHEN_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"bridgeERC20To(uint256,bytes32,address,address,uint256)\")\n );\n\n /// @notice Function-selector for Native bridging on Hyphen-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable HYPHEN_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,bytes32,address,uint256)\"));\n\n bytes4 public immutable HYPHEN_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\"swapAndBridge(uint32,bytes,(address,uint256,bytes32))\")\n );\n\n /// @notice liquidityPoolManager - liquidityPool Manager of Hyphen used to bridge ERC20 and native\n /// @dev this is to be initialized in constructor with a valid deployed address of hyphen-liquidityPoolManager\n HyphenLiquidityPoolManager public immutable liquidityPoolManager;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure liquidityPoolManager-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _liquidityPoolManager,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n liquidityPoolManager = HyphenLiquidityPoolManager(\n _liquidityPoolManager\n );\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HyphenData {\n /// @notice address of token being bridged\n address token;\n /// @notice address of receiver\n address receiverAddress;\n /// @notice chainId of destination\n uint256 toChainId;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n struct HyphenDataNoToken {\n /// @notice address of receiver\n address receiverAddress;\n /// @notice chainId of destination\n uint256 toChainId;\n /// @notice chainId of destination\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HyphenBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for HyphenBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HyphenData memory hyphenData = abi.decode(bridgeData, (HyphenData));\n\n if (hyphenData.token == NATIVE_TOKEN_ADDRESS) {\n liquidityPoolManager.depositNative{value: amount}(\n hyphenData.receiverAddress,\n hyphenData.toChainId,\n \"SOCKET\"\n );\n } else {\n ERC20(hyphenData.token).safeApprove(\n address(liquidityPoolManager),\n amount\n );\n liquidityPoolManager.depositErc20(\n hyphenData.toChainId,\n hyphenData.token,\n hyphenData.receiverAddress,\n amount,\n \"SOCKET\"\n );\n }\n\n emit SocketBridge(\n amount,\n hyphenData.token,\n hyphenData.toChainId,\n HyphenIdentifier,\n msg.sender,\n hyphenData.receiverAddress,\n hyphenData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HyphenBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hyphenData encoded data for hyphenData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HyphenDataNoToken calldata hyphenData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n liquidityPoolManager.depositNative{value: bridgeAmount}(\n hyphenData.receiverAddress,\n hyphenData.toChainId,\n \"SOCKET\"\n );\n } else {\n ERC20(token).safeApprove(\n address(liquidityPoolManager),\n bridgeAmount\n );\n liquidityPoolManager.depositErc20(\n hyphenData.toChainId,\n token,\n hyphenData.receiverAddress,\n bridgeAmount,\n \"SOCKET\"\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hyphenData.toChainId,\n HyphenIdentifier,\n msg.sender,\n hyphenData.receiverAddress,\n hyphenData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hyphen-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount to be sent\n * @param receiverAddress address of the token to bridged to the destination chain.\n * @param token address of token being bridged\n * @param toChainId chainId of destination\n */\n function bridgeERC20To(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n address token,\n uint256 toChainId\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(liquidityPoolManager), amount);\n liquidityPoolManager.depositErc20(\n toChainId,\n token,\n receiverAddress,\n amount,\n \"SOCKET\"\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HyphenIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hyphen-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount to be sent\n * @param receiverAddress address of the token to bridged to the destination chain.\n * @param toChainId chainId of destination\n */\n function bridgeNativeTo(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n uint256 toChainId\n ) external payable {\n liquidityPoolManager.depositNative{value: amount}(\n receiverAddress,\n toChainId,\n \"SOCKET\"\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HyphenIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/bridges/optimism/l1/NativeOptimism.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/optimism.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {UnsupportedInterfaceId} from \"../../../errors/SocketErrors.sol\";\nimport {NATIVE_OPTIMISM} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title NativeOptimism-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via NativeOptimism-Bridge\n * Tokens are bridged from Ethereum to Optimism Chain.\n * Called via SocketGateway if the routeId in the request maps to the routeId of NativeOptimism-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract NativeOptimismImpl is BridgeImplBase {\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativeOptimismIdentifier = NATIVE_OPTIMISM;\n\n uint256 public constant DESTINATION_CHAIN_ID = 10;\n\n /// @notice Function-selector for ERC20-token bridging on Native-Optimism-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_OPTIMISM_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint32,(bytes32,bytes32),uint256,uint256,address,bytes)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Native-Optimism-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native balance\n bytes4\n public immutable NATIVE_OPTIMISM_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint32,uint256,bytes32,bytes)\"\n )\n );\n\n bytes4 public immutable NATIVE_OPTIMISM_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,bytes32,bytes32,address,address,uint32,address,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct OptimismBridgeDataNoToken {\n // interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n uint256 interfaceId;\n // currencyKey of the token beingBridged\n bytes32 currencyKey;\n // socket offchain created hash\n bytes32 metadata;\n // address of receiver of bridged tokens\n address receiverAddress;\n /**\n * OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n */\n address customBridgeAddress;\n // Gas limit required to complete the deposit on L2.\n uint32 l2Gas;\n // Address of the L1 respective L2 ERC20\n address l2Token;\n // additional data , for ll contracts this will be 0x data or empty data\n bytes data;\n }\n\n struct OptimismBridgeData {\n // interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n uint256 interfaceId;\n // currencyKey of the token beingBridged\n bytes32 currencyKey;\n // socket offchain created hash\n bytes32 metadata;\n // address of receiver of bridged tokens\n address receiverAddress;\n /**\n * OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n */\n address customBridgeAddress;\n /// @notice address of token being bridged\n address token;\n // Gas limit required to complete the deposit on L2.\n uint32 l2Gas;\n // Address of the L1 respective L2 ERC20\n address l2Token;\n // additional data , for ll contracts this will be 0x data or empty data\n bytes data;\n }\n\n struct OptimismERC20Data {\n bytes32 currencyKey;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in OptimismBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Optimism-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n OptimismBridgeData memory optimismBridgeData = abi.decode(\n bridgeData,\n (OptimismBridgeData)\n );\n\n emit SocketBridge(\n amount,\n optimismBridgeData.token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n optimismBridgeData.receiverAddress,\n optimismBridgeData.metadata\n );\n if (optimismBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositETHTo{value: amount}(\n optimismBridgeData.receiverAddress,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n } else {\n if (optimismBridgeData.interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20(optimismBridgeData.token).safeApprove(\n optimismBridgeData.customBridgeAddress,\n amount\n );\n\n if (optimismBridgeData.interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositERC20To(\n optimismBridgeData.token,\n optimismBridgeData.l2Token,\n optimismBridgeData.receiverAddress,\n amount,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (optimismBridgeData.interfaceId == 2) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .depositTo(optimismBridgeData.receiverAddress, amount);\n return;\n }\n\n if (optimismBridgeData.interfaceId == 3) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .initiateSynthTransfer(\n optimismBridgeData.currencyKey,\n optimismBridgeData.receiverAddress,\n amount\n );\n return;\n }\n }\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in OptimismBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param optimismBridgeData encoded data for OptimismBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n OptimismBridgeDataNoToken calldata optimismBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n optimismBridgeData.receiverAddress,\n optimismBridgeData.metadata\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositETHTo{value: bridgeAmount}(\n optimismBridgeData.receiverAddress,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n } else {\n if (optimismBridgeData.interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20(token).safeApprove(\n optimismBridgeData.customBridgeAddress,\n bridgeAmount\n );\n\n if (optimismBridgeData.interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositERC20To(\n token,\n optimismBridgeData.l2Token,\n optimismBridgeData.receiverAddress,\n bridgeAmount,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (optimismBridgeData.interfaceId == 2) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .depositTo(\n optimismBridgeData.receiverAddress,\n bridgeAmount\n );\n return;\n }\n\n if (optimismBridgeData.interfaceId == 3) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .initiateSynthTransfer(\n optimismBridgeData.currencyKey,\n optimismBridgeData.receiverAddress,\n bridgeAmount\n );\n return;\n }\n }\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativeOptimism-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param receiverAddress address of receiver of bridged tokens\n * @param customBridgeAddress OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n * @param l2Gas Gas limit required to complete the deposit on L2.\n * @param optimismData extra data needed for optimism bridge\n * @param amount amount being bridged\n * @param interfaceId interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n * @param l2Token Address of the L1 respective L2 ERC20\n * @param data additional data , for ll contracts this will be 0x data or empty data\n */\n function bridgeERC20To(\n address token,\n address receiverAddress,\n address customBridgeAddress,\n uint32 l2Gas,\n OptimismERC20Data calldata optimismData,\n uint256 amount,\n uint256 interfaceId,\n address l2Token,\n bytes calldata data\n ) external payable {\n if (interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(customBridgeAddress, amount);\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n receiverAddress,\n optimismData.metadata\n );\n if (interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(customBridgeAddress).depositERC20To(\n token,\n l2Token,\n receiverAddress,\n amount,\n l2Gas,\n data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (interfaceId == 2) {\n OldL1TokenGateway(customBridgeAddress).depositTo(\n receiverAddress,\n amount\n );\n return;\n }\n\n if (interfaceId == 3) {\n OldL1TokenGateway(customBridgeAddress).initiateSynthTransfer(\n optimismData.currencyKey,\n receiverAddress,\n amount\n );\n return;\n }\n }\n\n /**\n * @notice function to handle native balance bridging to receipent via NativeOptimism-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of receiver of bridged tokens\n * @param customBridgeAddress OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n * @param l2Gas Gas limit required to complete the deposit on L2.\n * @param amount amount being bridged\n * @param data additional data , for ll contracts this will be 0x data or empty data\n */\n function bridgeNativeTo(\n address receiverAddress,\n address customBridgeAddress,\n uint32 l2Gas,\n uint256 amount,\n bytes32 metadata,\n bytes calldata data\n ) external payable {\n L1StandardBridge(customBridgeAddress).depositETHTo{value: amount}(\n receiverAddress,\n l2Gas,\n data\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/deployFactory/SocketDeployFactory.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketBridgeBase} from \"../interfaces/ISocketBridgeBase.sol\";\n\n/**\n * @dev In the constructor, set up the initialization code for socket\n * contracts as well as the keccak256 hash of the given initialization code.\n * that will be used to deploy any transient contracts, which will deploy any\n * socket contracts that require the use of a constructor.\n *\n * Socket contract initialization code (29 bytes):\n *\n * 0x5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\n *\n * Description:\n *\n * pc|op|name | [stack] | \n *\n * ** set the first stack item to zero - used later **\n * 00 58 getpc [0] <>\n *\n * ** set second stack item to 32, length of word returned from staticcall **\n * 01 60 push1\n * 02 20 outsize [0, 32] <>\n *\n * ** set third stack item to 0, position of word returned from staticcall **\n * 03 81 dup2 [0, 32, 0] <>\n *\n * ** set fourth stack item to 4, length of selector given to staticcall **\n * 04 58 getpc [0, 32, 0, 4] <>\n *\n * ** set fifth stack item to 28, position of selector given to staticcall **\n * 05 60 push1\n * 06 1c inpos [0, 32, 0, 4, 28] <>\n *\n * ** set the sixth stack item to msg.sender, target address for staticcall **\n * 07 33 caller [0, 32, 0, 4, 28, caller] <>\n *\n * ** set the seventh stack item to msg.gas, gas to forward for staticcall **\n * 08 5a gas [0, 32, 0, 4, 28, caller, gas] <>\n *\n * ** set the eighth stack item to selector, \"what\" to store via mstore **\n * 09 63 push4\n * 10 aaf10f42 selector [0, 32, 0, 4, 28, caller, gas, 0xaaf10f42] <>\n *\n * ** set the ninth stack item to 0, \"where\" to store via mstore ***\n * 11 87 dup8 [0, 32, 0, 4, 28, caller, gas, 0xaaf10f42, 0] <>\n *\n * ** call mstore, consume 8 and 9 from the stack, place selector in memory **\n * 12 52 mstore [0, 32, 0, 4, 0, caller, gas] <0xaaf10f42>\n *\n * ** call staticcall, consume items 2 through 7, place address in memory **\n * 13 fa staticcall [0, 1 (if successful)]
\n *\n * ** flip success bit in second stack item to set to 0 **\n * 14 15 iszero [0, 0]
\n *\n * ** push a third 0 to the stack, position of address in memory **\n * 15 81 dup2 [0, 0, 0]
\n *\n * ** place address from position in memory onto third stack item **\n * 16 51 mload [0, 0, address] <>\n *\n * ** place address to fourth stack item for extcodesize to consume **\n * 17 80 dup1 [0, 0, address, address] <>\n *\n * ** get extcodesize on fourth stack item for extcodecopy **\n * 18 3b extcodesize [0, 0, address, size] <>\n *\n * ** dup and swap size for use by return at end of init code **\n * 19 80 dup1 [0, 0, address, size, size] <>\n * 20 93 swap4 [size, 0, address, size, 0] <>\n *\n * ** push code position 0 to stack and reorder stack items for extcodecopy **\n * 21 80 dup1 [size, 0, address, size, 0, 0] <>\n * 22 91 swap2 [size, 0, address, 0, 0, size] <>\n * 23 92 swap3 [size, 0, size, 0, 0, address] <>\n *\n * ** call extcodecopy, consume four items, clone runtime code to memory **\n * 24 3c extcodecopy [size, 0] \n *\n * ** return to deploy final code in memory **\n * 25 f3 return [] *deployed!*\n */\ncontract SocketDeployFactory is Ownable {\n using SafeTransferLib for ERC20;\n address public immutable disabledRouteAddress;\n\n mapping(address => address) _implementations;\n mapping(uint256 => bool) isDisabled;\n mapping(uint256 => bool) isRouteDeployed;\n mapping(address => bool) canDisableRoute;\n\n event Deployed(address _addr);\n event DisabledRoute(address _addr);\n event Destroyed(address _addr);\n error ContractAlreadyDeployed();\n error NothingToDestroy();\n error AlreadyDisabled();\n error CannotBeDisabled();\n error OnlyDisabler();\n\n constructor(address _owner, address disabledRoute) Ownable(_owner) {\n disabledRouteAddress = disabledRoute;\n canDisableRoute[_owner] = true;\n }\n\n modifier onlyDisabler() {\n if (!canDisableRoute[msg.sender]) {\n revert OnlyDisabler();\n }\n _;\n }\n\n function addDisablerAddress(address disabler) external onlyOwner {\n canDisableRoute[disabler] = true;\n }\n\n function removeDisablerAddress(address disabler) external onlyOwner {\n canDisableRoute[disabler] = false;\n }\n\n /**\n * @notice Deploys a route contract at predetermined location\n * @notice Caller must first deploy the route contract at another location and pass its address as implementation.\n * @param routeId route identifier\n * @param implementationContract address of deployed route contract. Its byte code will be copied to predetermined location.\n */\n function deploy(\n uint256 routeId,\n address implementationContract\n ) external onlyOwner returns (address) {\n // assign the initialization code for the socket contract.\n\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (isRouteDeployed[routeId]) {\n revert ContractAlreadyDeployed();\n }\n\n isRouteDeployed[routeId] = true;\n\n //first we deploy the code we want to deploy on a separate address\n // store the implementation to be retrieved by the socket contract.\n _implementations[routeContractAddress] = implementationContract;\n address addr;\n assembly {\n let encoded_data := add(0x20, initCode) // load initialization code.\n let encoded_size := mload(initCode) // load init code's length.\n addr := create2(0, encoded_data, encoded_size, routeId) // routeId is used as salt\n }\n require(\n addr == routeContractAddress,\n \"Failed to deploy the new socket contract.\"\n );\n emit Deployed(addr);\n return addr;\n }\n\n /**\n * @notice Destroy the route deployed at a location.\n * @param routeId route identifier to be destroyed.\n */\n function destroy(uint256 routeId) external onlyDisabler {\n // determine the address of the socket contract.\n _destroy(routeId);\n }\n\n /**\n * @notice Deploy a disabled contract at destroyed route to handle it gracefully.\n * @param routeId route identifier to be disabled.\n */\n function disableRoute(\n uint256 routeId\n ) external onlyDisabler returns (address) {\n return _disableRoute(routeId);\n }\n\n /**\n * @notice Destroy a list of routeIds\n * @param routeIds array of routeIds to be destroyed.\n */\n function multiDestroy(uint256[] calldata routeIds) external onlyDisabler {\n for (uint32 index = 0; index < routeIds.length; ) {\n _destroy(routeIds[index]);\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Deploy a disabled contract at list of routeIds.\n * @param routeIds array of routeIds to be disabled.\n */\n function multiDisableRoute(\n uint256[] calldata routeIds\n ) external onlyDisabler {\n for (uint32 index = 0; index < routeIds.length; ) {\n _disableRoute(routeIds[index]);\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @dev External view function for calculating a socket contract address\n * given a particular routeId.\n */\n function getContractAddress(\n uint256 routeId\n ) external view returns (address) {\n // determine the address of the socket contract.\n return _getContractAddress(routeId);\n }\n\n //those two functions are getting called by the socket Contract\n function getImplementation()\n external\n view\n returns (address implementation)\n {\n return _implementations[msg.sender];\n }\n\n function _disableRoute(uint256 routeId) internal returns (address) {\n // assign the initialization code for the socket contract.\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (!isRouteDeployed[routeId]) {\n revert CannotBeDisabled();\n }\n\n if (isDisabled[routeId]) {\n revert AlreadyDisabled();\n }\n\n isDisabled[routeId] = true;\n\n //first we deploy the code we want to deploy on a separate address\n // store the implementation to be retrieved by the socket contract.\n _implementations[routeContractAddress] = disabledRouteAddress;\n address addr;\n assembly {\n let encoded_data := add(0x20, initCode) // load initialization code.\n let encoded_size := mload(initCode) // load init code's length.\n addr := create2(0, encoded_data, encoded_size, routeId) // routeId is used as salt.\n }\n require(\n addr == routeContractAddress,\n \"Failed to deploy the new socket contract.\"\n );\n emit Deployed(addr);\n return addr;\n }\n\n function _destroy(uint256 routeId) internal {\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (!isRouteDeployed[routeId]) {\n revert NothingToDestroy();\n }\n ISocketBridgeBase(routeContractAddress).killme();\n emit Destroyed(routeContractAddress);\n }\n\n /**\n * @dev Internal view function for calculating a socket contract address\n * given a particular routeId.\n */\n function _getContractAddress(\n uint256 routeId\n ) internal view returns (address) {\n // determine the address of the socket contract.\n\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n return\n address(\n uint160( // downcast to match the address type.\n uint256( // convert to uint to truncate upper digits.\n keccak256( // compute the CREATE2 hash using 4 inputs.\n abi.encodePacked( // pack all inputs to the hash together.\n hex\"ff\", // start with 0xff to distinguish from RLP.\n address(this), // this contract will be the caller.\n routeId, // the routeId is used as salt.\n keccak256(abi.encodePacked(initCode)) // the init code hash.\n )\n )\n )\n )\n );\n }\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n}\n" + }, + "src/interfaces/ISocketController.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketController\n * @notice Interface for SocketController functions.\n * @dev functions can be added here for invocation from external contracts or off-chain\n * only restriction is that this should have functions to manage controllers\n * @author Socket dot tech.\n */\ninterface ISocketController {\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param _controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address _controllerAddress\n ) external returns (uint32);\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param _controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 _controllerId) external;\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param _controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 _controllerId) external returns (address);\n}\n" + }, + "lib/solmate/src/utils/SafeTransferLib.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n" + }, + "src/controllers/BaseController.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\n\n/// @title BaseController Controller\n/// @notice Base contract for all controller contracts\nabstract contract BaseController {\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice Address used to identify if it is a Zero address\n address public immutable NULL_ADDRESS = address(0);\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGatewayAddress;\n\n /// @notice immutable variable with instance of SocketRoute to access route functions\n ISocketRoute public immutable socketRoute;\n\n /**\n * @notice Construct the base for all controllers.\n * @param _socketGatewayAddress Socketgateway address, an immutable variable to set.\n * @notice initialize the immutable variables of SocketRoute, SocketGateway\n */\n constructor(address _socketGatewayAddress) {\n socketGatewayAddress = _socketGatewayAddress;\n socketRoute = ISocketRoute(_socketGatewayAddress);\n }\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param routeId routeId mapped to the routrImplementation\n * @param data transactionData generated with arguments of bridgeRequest (offchain or by caller)\n * @return returns the bytes response of the route execution (bridging, refuel or swap executions)\n */\n function _executeRoute(\n uint32 routeId,\n bytes memory data\n ) internal returns (bytes memory) {\n (bool success, bytes memory result) = socketRoute\n .getRoute(routeId)\n .delegatecall(data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n}\n" + }, + "src/interfaces/ISocketRoute.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketRoute\n * @notice Interface for routeManagement functions in SocketGateway.\n * @author Socket dot tech.\n */\ninterface ISocketRoute {\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(address routeAddress) external returns (uint256);\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external;\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) external view returns (address);\n}\n" + }, + "src/SocketGatewayDeployment.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\npragma experimental ABIEncoderV2;\n\nimport \"./utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {LibUtil} from \"./libraries/LibUtil.sol\";\nimport \"./libraries/LibBytes.sol\";\nimport {ISocketRoute} from \"./interfaces/ISocketRoute.sol\";\nimport {ISocketRequest} from \"./interfaces/ISocketRequest.sol\";\nimport {ISocketGateway} from \"./interfaces/ISocketGateway.sol\";\nimport {IncorrectBridgeRatios, ZeroAddressNotAllowed, ArrayLengthMismatch} from \"./errors/SocketErrors.sol\";\n\n/// @title SocketGatewayContract\n/// @notice Socketgateway is a contract with entrypoint functions for all interactions with socket liquidity layer\n/// @author Socket Team\ncontract SocketGateway is Ownable {\n using LibBytes for bytes;\n using LibBytes for bytes4;\n using SafeTransferLib for ERC20;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice storage variable to keep track of total number of routes registered in socketgateway\n uint32 public routesCount = 385;\n\n /// @notice storage variable to keep track of total number of controllers registered in socketgateway\n uint32 public controllerCount;\n\n address public immutable disabledRouteAddress;\n\n uint256 public constant CENT_PERCENT = 100e18;\n\n /// @notice storage mapping for route implementation addresses\n mapping(uint32 => address) public routes;\n\n /// storage mapping for controller implemenation addresses\n mapping(uint32 => address) public controllers;\n\n // Events ------------------------------------------------------------------------------------------------------->\n\n /// @notice Event emitted when a router is added to socketgateway\n event NewRouteAdded(uint32 indexed routeId, address indexed route);\n\n /// @notice Event emitted when a route is disabled\n event RouteDisabled(uint32 indexed routeId);\n\n /// @notice Event emitted when ownership transfer is requested by socket-gateway-owner\n event OwnershipTransferRequested(\n address indexed _from,\n address indexed _to\n );\n\n /// @notice Event emitted when a controller is added to socketgateway\n event ControllerAdded(\n uint32 indexed controllerId,\n address indexed controllerAddress\n );\n\n /// @notice Event emitted when a controller is disabled\n event ControllerDisabled(uint32 indexed controllerId);\n\n constructor(address _owner, address _disabledRoute) Ownable(_owner) {\n disabledRouteAddress = _disabledRoute;\n }\n\n // Able to receive ether\n // solhint-disable-next-line no-empty-blocks\n receive() external payable {}\n\n /*******************************************\n * EXTERNAL AND PUBLIC FUNCTIONS *\n *******************************************/\n\n /**\n * @notice executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in routeData to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeId route identifier\n * @param routeData functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoute(\n uint32 routeId,\n bytes calldata routeData\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = addressAt(routeId).delegatecall(\n routeData\n );\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice swaps a token on sourceChain and split it across multiple bridge-recipients\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being swapped\n * @dev ensure the swap-data and bridge-data is generated using the function-selector defined as a constant in the implementation address\n * @param swapMultiBridgeRequest request\n */\n function swapAndMultiBridge(\n ISocketRequest.SwapMultiBridgeRequest calldata swapMultiBridgeRequest\n ) external payable {\n uint256 requestLength = swapMultiBridgeRequest.bridgeRouteIds.length;\n\n if (\n requestLength != swapMultiBridgeRequest.bridgeImplDataItems.length\n ) {\n revert ArrayLengthMismatch();\n }\n uint256 ratioAggregate;\n for (uint256 index = 0; index < requestLength; ) {\n ratioAggregate += swapMultiBridgeRequest.bridgeRatios[index];\n }\n\n if (ratioAggregate != CENT_PERCENT) {\n revert IncorrectBridgeRatios();\n }\n\n (bool swapSuccess, bytes memory swapResult) = addressAt(\n swapMultiBridgeRequest.swapRouteId\n ).delegatecall(swapMultiBridgeRequest.swapImplData);\n\n if (!swapSuccess) {\n assembly {\n revert(add(swapResult, 32), mload(swapResult))\n }\n }\n\n uint256 amountReceivedFromSwap = abi.decode(swapResult, (uint256));\n\n uint256 bridgedAmount;\n\n for (uint256 index = 0; index < requestLength; ) {\n uint256 bridgingAmount;\n\n // if it is the last bridge request, bridge the remaining amount\n if (index == requestLength - 1) {\n bridgingAmount = amountReceivedFromSwap - bridgedAmount;\n } else {\n // bridging amount is the multiplication of bridgeRatio and amountReceivedFromSwap\n bridgingAmount =\n (amountReceivedFromSwap *\n swapMultiBridgeRequest.bridgeRatios[index]) /\n (CENT_PERCENT);\n }\n\n // update the bridged amount, this would be used for computation for last bridgeRequest\n bridgedAmount += bridgingAmount;\n\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n bridgingAmount,\n swapMultiBridgeRequest.bridgeImplDataItems[index]\n );\n\n (bool bridgeSuccess, bytes memory bridgeResult) = addressAt(\n swapMultiBridgeRequest.bridgeRouteIds[index]\n ).delegatecall(bridgeImpldata);\n\n if (!bridgeSuccess) {\n assembly {\n revert(add(bridgeResult, 32), mload(bridgeResult))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice sequentially executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each dataItem to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeIds a list of route identifiers\n * @param dataItems a list of functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoutes(\n uint32[] calldata routeIds,\n bytes[] calldata dataItems\n ) external payable {\n uint256 routeIdslength = routeIds.length;\n if (routeIdslength != dataItems.length) revert ArrayLengthMismatch();\n for (uint256 index = 0; index < routeIdslength; ) {\n (bool success, bytes memory result) = addressAt(routeIds[index])\n .delegatecall(dataItems[index]);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice execute a controller function identified using the controllerId in the request\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param socketControllerRequest socketControllerRequest with controllerId to identify the\n * controllerAddress and byteData constructed using functionSelector\n * of the function being invoked\n * @return bytes data received from the call delegated to controller\n */\n function executeController(\n ISocketGateway.SocketControllerRequest calldata socketControllerRequest\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = controllers[\n socketControllerRequest.controllerId\n ].delegatecall(socketControllerRequest.data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice sequentially executes all controller requests\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each controller-request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param controllerRequests a list of socketControllerRequest\n * Each controllerRequest contains controllerId to identify the controllerAddress and\n * byteData constructed using functionSelector of the function being invoked\n */\n function executeControllers(\n ISocketGateway.SocketControllerRequest[] calldata controllerRequests\n ) external payable {\n for (uint32 index = 0; index < controllerRequests.length; ) {\n (bool success, bytes memory result) = controllers[\n controllerRequests[index].controllerId\n ].delegatecall(controllerRequests[index].data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**************************************\n * ADMIN FUNCTIONS *\n **************************************/\n\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(\n address routeAddress\n ) external onlyOwner returns (uint32) {\n uint32 routeId = routesCount;\n routes[routeId] = routeAddress;\n\n routesCount += 1;\n\n emit NewRouteAdded(routeId, routeAddress);\n\n return routeId;\n }\n\n /**\n * @notice Give Infinite or 0 approval to bridgeRoute for the tokenAddress\n This is a restricted function to be called by only socketGatewayOwner\n */\n\n function setApprovalForRouters(\n address[] memory routeAddresses,\n address[] memory tokenAddresses,\n bool isMax\n ) external onlyOwner {\n for (uint32 index = 0; index < routeAddresses.length; ) {\n ERC20(tokenAddresses[index]).approve(\n routeAddresses[index],\n isMax ? type(uint256).max : 0\n );\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address controllerAddress\n ) external onlyOwner returns (uint32) {\n uint32 controllerId = controllerCount;\n\n controllers[controllerId] = controllerAddress;\n\n controllerCount += 1;\n\n emit ControllerAdded(controllerId, controllerAddress);\n\n return controllerId;\n }\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 controllerId) public onlyOwner {\n controllers[controllerId] = disabledRouteAddress;\n emit ControllerDisabled(controllerId);\n }\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external onlyOwner {\n routes[routeId] = disabledRouteAddress;\n emit RouteDisabled(routeId);\n }\n\n /*******************************************\n * RESTRICTED RESCUE FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n\n /*******************************************\n * VIEW FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) public view returns (address) {\n return addressAt(routeId);\n }\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 controllerId) public view returns (address) {\n return controllers[controllerId];\n }\n\n function addressAt(uint32 routeId) public view returns (address) {\n if (routeId < 385) {\n if (routeId < 257) {\n if (routeId < 129) {\n if (routeId < 65) {\n if (routeId < 33) {\n if (routeId < 17) {\n if (routeId < 9) {\n if (routeId < 5) {\n if (routeId < 3) {\n if (routeId == 1) {\n return\n 0x8cd6BaCDAe46B449E2e5B34e348A4eD459c84D50;\n } else {\n return\n 0x31524750Cd865fF6A3540f232754Fb974c18585C;\n }\n } else {\n if (routeId == 3) {\n return\n 0xEd9b37342BeC8f3a2D7b000732ec87498aA6EC6a;\n } else {\n return\n 0xE8704Ef6211F8988Ccbb11badC89841808d66890;\n }\n }\n } else {\n if (routeId < 7) {\n if (routeId == 5) {\n return\n 0x9aFF58C460a461578C433e11C4108D1c4cF77761;\n } else {\n return\n 0x2D1733886cFd465B0B99F1492F40847495f334C5;\n }\n } else {\n if (routeId == 7) {\n return\n 0x715497Be4D130F04B8442F0A1F7a9312D4e54FC4;\n } else {\n return\n 0x90C8a40c38E633B5B0e0d0585b9F7FA05462CaaF;\n }\n }\n }\n } else {\n if (routeId < 13) {\n if (routeId < 11) {\n if (routeId == 9) {\n return\n 0xa402b70FCfF3F4a8422B93Ef58E895021eAdE4F6;\n } else {\n return\n 0xc1B718522E15CD42C4Ac385a929fc2B51f5B892e;\n }\n } else {\n if (routeId == 11) {\n return\n 0xa97bf2f7c26C43c010c349F52f5eA5dC49B2DD38;\n } else {\n return\n 0x969423d71b62C81d2f28d707364c9Dc4a0764c53;\n }\n }\n } else {\n if (routeId < 15) {\n if (routeId == 13) {\n return\n 0xF86729934C083fbEc8C796068A1fC60701Ea1207;\n } else {\n return\n 0xD7cC2571F5823caCA26A42690D2BE7803DD5393f;\n }\n } else {\n if (routeId == 15) {\n return\n 0x7c8837a279bbbf7d8B93413763176de9F65d5bB9;\n } else {\n return\n 0x13b81C27B588C07D04458ed7dDbdbD26D1e39bcc;\n }\n }\n }\n }\n } else {\n if (routeId < 25) {\n if (routeId < 21) {\n if (routeId < 19) {\n if (routeId == 17) {\n return\n 0x52560Ac678aFA1345D15474287d16Dc1eA3F78aE;\n } else {\n return\n 0x1E31e376551459667cd7643440c1b21CE69065A0;\n }\n } else {\n if (routeId == 19) {\n return\n 0xc57D822CB3288e7b97EF8f8af0EcdcD1B783529B;\n } else {\n return\n 0x2197A1D9Af24b4d6a64Bff95B4c29Fcd3Ff28C30;\n }\n }\n } else {\n if (routeId < 23) {\n if (routeId == 21) {\n return\n 0xE3700feAa5100041Bf6b7AdBA1f72f647809Fd00;\n } else {\n return\n 0xc02E8a0Fdabf0EeFCEA025163d90B5621E2b9948;\n }\n } else {\n if (routeId == 23) {\n return\n 0xF5144235E2926cAb3c69b30113254Fa632f72d62;\n } else {\n return\n 0xBa3F92313B00A1f7Bc53b2c24EB195c8b2F57682;\n }\n }\n }\n } else {\n if (routeId < 29) {\n if (routeId < 27) {\n if (routeId == 25) {\n return\n 0x77a6856fe1fFA5bEB55A1d2ED86E27C7c482CB76;\n } else {\n return\n 0x4826Ff4e01E44b1FCEFBfb38cd96687Eb7786b44;\n }\n } else {\n if (routeId == 27) {\n return\n 0x55FF3f5493cf5e80E76DEA7E327b9Cd8440Af646;\n } else {\n return\n 0xF430Db544bE9770503BE4aa51997aA19bBd5BA4f;\n }\n }\n } else {\n if (routeId < 31) {\n if (routeId == 29) {\n return\n 0x0f166446ce1484EE3B0663E7E67DF10F5D240115;\n } else {\n return\n 0x6365095D92537f242Db5EdFDd572745E72aC33d9;\n }\n } else {\n if (routeId == 31) {\n return\n 0x5c7BC93f06ce3eAe75ADf55E10e23d2c1dE5Bc65;\n } else {\n return\n 0xe46383bAD90d7A08197ccF08972e9DCdccCE9BA4;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 49) {\n if (routeId < 41) {\n if (routeId < 37) {\n if (routeId < 35) {\n if (routeId == 33) {\n return\n 0xf0f21710c071E3B728bdc4654c3c0b873aAaa308;\n } else {\n return\n 0x63Bc9ed3AcAAeB0332531C9fB03b0a2352E9Ff25;\n }\n } else {\n if (routeId == 35) {\n return\n 0xd1CE808625CB4007a1708824AE82CdB0ece57De9;\n } else {\n return\n 0x57BbB148112f4ba224841c3FE018884171004661;\n }\n }\n } else {\n if (routeId < 39) {\n if (routeId == 37) {\n return\n 0x037f7d6933036F34DFabd40Ff8e4D789069f92e3;\n } else {\n return\n 0xeF978c280915CfF3Dca4EDfa8932469e40ADA1e1;\n }\n } else {\n if (routeId == 39) {\n return\n 0x92ee9e071B13f7ecFD62B7DED404A16CBc223CD3;\n } else {\n return\n 0x94Ae539c186e41ed762271338Edf140414D1E442;\n }\n }\n }\n } else {\n if (routeId < 45) {\n if (routeId < 43) {\n if (routeId == 41) {\n return\n 0x30A64BBe4DdBD43dA2368EFd1eB2d80C10d84DAb;\n } else {\n return\n 0x3aEABf81c1Dc4c1b73d5B2a95410f126426FB596;\n }\n } else {\n if (routeId == 43) {\n return\n 0x25b08aB3D0C8ea4cC9d967b79688C6D98f3f563a;\n } else {\n return\n 0xea40cB15C9A3BBd27af6474483886F7c0c9AE406;\n }\n }\n } else {\n if (routeId < 47) {\n if (routeId == 45) {\n return\n 0x9580113Cc04e5a0a03359686304EF3A80b936Dd3;\n } else {\n return\n 0xD211c826d568957F3b66a3F4d9c5f68cCc66E619;\n }\n } else {\n if (routeId == 47) {\n return\n 0xCEE24D0635c4C56315d133b031984d4A6f509476;\n } else {\n return\n 0x3922e6B987983229798e7A20095EC372744d4D4c;\n }\n }\n }\n }\n } else {\n if (routeId < 57) {\n if (routeId < 53) {\n if (routeId < 51) {\n if (routeId == 49) {\n return\n 0x2d92D03413d296e1F31450479349757187F2a2b7;\n } else {\n return\n 0x0fe5308eE90FC78F45c89dB6053eA859097860CA;\n }\n } else {\n if (routeId == 51) {\n return\n 0x08Ba68e067C0505bAF0C1311E0cFB2B1B59b969c;\n } else {\n return\n 0x9bee5DdDF75C24897374f92A534B7A6f24e97f4a;\n }\n }\n } else {\n if (routeId < 55) {\n if (routeId == 53) {\n return\n 0x1FC5A90B232208704B930c1edf82FFC6ACc02734;\n } else {\n return\n 0x5b1B0417cb44c761C2a23ee435d011F0214b3C85;\n }\n } else {\n if (routeId == 55) {\n return\n 0x9d70cDaCA12A738C283020760f449D7816D592ec;\n } else {\n return\n 0x95a23b9CB830EcCFDDD5dF56A4ec665e3381Fa12;\n }\n }\n }\n } else {\n if (routeId < 61) {\n if (routeId < 59) {\n if (routeId == 57) {\n return\n 0x483a957Cf1251c20e096C35c8399721D1200A3Fc;\n } else {\n return\n 0xb4AD39Cb293b0Ec7FEDa743442769A7FF04987CD;\n }\n } else {\n if (routeId == 59) {\n return\n 0x4C543AD78c1590D81BAe09Fc5B6Df4132A2461d0;\n } else {\n return\n 0x471d5E5195c563902781734cfe1FF3981F8B6c86;\n }\n }\n } else {\n if (routeId < 63) {\n if (routeId == 61) {\n return\n 0x1B12a54B5E606D95B8B8D123c9Cb09221Ee37584;\n } else {\n return\n 0xE4127cC550baC433646a7D998775a84daC16c7f3;\n }\n } else {\n if (routeId == 63) {\n return\n 0xecb1b55AB12E7dd788D585c6C5cD61B5F87be836;\n } else {\n return\n 0xf91ef487C5A1579f70601b6D347e19756092eEBf;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 97) {\n if (routeId < 81) {\n if (routeId < 73) {\n if (routeId < 69) {\n if (routeId < 67) {\n if (routeId == 65) {\n return\n 0x34a16a7e9BADEEFD4f056310cbE0b1423Fa1b760;\n } else {\n return\n 0x60E10E80c7680f429dBbC232830BEcd3D623c4CF;\n }\n } else {\n if (routeId == 67) {\n return\n 0x66465285B8D65362A1d86CE00fE2bE949Fd6debF;\n } else {\n return\n 0x5aB231B7e1A3A74a48f67Ab7bde5Cdd4267022E0;\n }\n }\n } else {\n if (routeId < 71) {\n if (routeId == 69) {\n return\n 0x3A1C3633eE79d43366F5c67802a746aFD6b162Ba;\n } else {\n return\n 0x0C4BfCbA8dC3C811437521a80E81e41DAF479039;\n }\n } else {\n if (routeId == 71) {\n return\n 0x6caf25d2e139C5431a1FA526EAf8d73ff2e6252C;\n } else {\n return\n 0x74ad21e09FDa68638CE14A3009A79B6D16574257;\n }\n }\n }\n } else {\n if (routeId < 77) {\n if (routeId < 75) {\n if (routeId == 73) {\n return\n 0xD4923A61008894b99cc1CD3407eF9524f02aA0Ca;\n } else {\n return\n 0x6F159b5EB823BD415886b9271aA2A723a00a1987;\n }\n } else {\n if (routeId == 75) {\n return\n 0x742a8aA42E7bfB4554dE30f4Fb07FFb6f2068863;\n } else {\n return\n 0x4AE9702d3360400E47B446e76DE063ACAb930101;\n }\n }\n } else {\n if (routeId < 79) {\n if (routeId == 77) {\n return\n 0x0E19a0a44ddA7dAD854ec5Cc867d16869c4E80F4;\n } else {\n return\n 0xE021A51968f25148F726E326C88d2556c5647557;\n }\n } else {\n if (routeId == 79) {\n return\n 0x64287BDDDaeF4d94E4599a3D882bed29E6Ada4B6;\n } else {\n return\n 0xcBB57Fd2e19cc7e9D444d5b4325A2F1047d0C73f;\n }\n }\n }\n }\n } else {\n if (routeId < 89) {\n if (routeId < 85) {\n if (routeId < 83) {\n if (routeId == 81) {\n return\n 0x373DE80DF7D82cFF6D76F29581b360C56331e957;\n } else {\n return\n 0x0466356E131AD61596a51F86BAd1C03A328960D8;\n }\n } else {\n if (routeId == 83) {\n return\n 0x01726B960992f1b74311b248E2a922fC707d43A6;\n } else {\n return\n 0x2E21bdf9A4509b89795BCE7E132f248a75814CEc;\n }\n }\n } else {\n if (routeId < 87) {\n if (routeId == 85) {\n return\n 0x769512b23aEfF842379091d3B6E4B5456F631D42;\n } else {\n return\n 0xe7eD9be946a74Ec19325D39C6EEb57887ccB2B0D;\n }\n } else {\n if (routeId == 87) {\n return\n 0xc4D01Ec357c2b511d10c15e6b6974380F0E62e67;\n } else {\n return\n 0x5bC49CC9dD77bECF2fd3A3C55611e84E69AFa3AE;\n }\n }\n }\n } else {\n if (routeId < 93) {\n if (routeId < 91) {\n if (routeId == 89) {\n return\n 0x48bcD879954fA14e7DbdAeb56F79C1e9DDcb69ec;\n } else {\n return\n 0xE929bDde21b462572FcAA4de6F49B9D3246688D0;\n }\n } else {\n if (routeId == 91) {\n return\n 0x85Aae300438222f0e3A9Bc870267a5633A9438bd;\n } else {\n return\n 0x51f72E1096a81C55cd142d66d39B688C657f9Be8;\n }\n }\n } else {\n if (routeId < 95) {\n if (routeId == 93) {\n return\n 0x3A8a05BF68ac54B01E6C0f492abF97465F3d15f9;\n } else {\n return\n 0x145aA67133F0c2C36b9771e92e0B7655f0D59040;\n }\n } else {\n if (routeId == 95) {\n return\n 0xa030315d7DB11F9892758C9e7092D841e0ADC618;\n } else {\n return\n 0xdF1f8d81a3734bdDdEfaC6Ca1596E081e57c3044;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 113) {\n if (routeId < 105) {\n if (routeId < 101) {\n if (routeId < 99) {\n if (routeId == 97) {\n return\n 0xFF2833123B58aa05d04D7fb99f5FB768B2b435F8;\n } else {\n return\n 0xc8f09c1fD751C570233765f71b0e280d74e6e743;\n }\n } else {\n if (routeId == 99) {\n return\n 0x3026DA6Ceca2E5A57A05153653D9212FFAaA49d8;\n } else {\n return\n 0xdE68Ee703dE0D11f67B0cE5891cB4a903de6D160;\n }\n }\n } else {\n if (routeId < 103) {\n if (routeId == 101) {\n return\n 0xE23a7730e81FB4E87A6D0bd9f63EE77ac86C3DA4;\n } else {\n return\n 0x8b1DBe04aD76a7d8bC079cACd3ED4D99B897F4a0;\n }\n } else {\n if (routeId == 103) {\n return\n 0xBB227240FA459b69C6889B2b8cb1BE76F118061f;\n } else {\n return\n 0xC062b9b3f0dB28BB8afAfcD4d075729344114ffe;\n }\n }\n }\n } else {\n if (routeId < 109) {\n if (routeId < 107) {\n if (routeId == 105) {\n return\n 0x553188Aa45f5FDB83EC4Ca485982F8fC082480D1;\n } else {\n return\n 0x0109d83D746EaCb6d4014953D9E12d6ca85e330b;\n }\n } else {\n if (routeId == 107) {\n return\n 0x45B1bEd29812F5bf6711074ACD180B2aeB783AD9;\n } else {\n return\n 0xdA06eC8c19aea31D77F60299678Cba40E743e1aD;\n }\n }\n } else {\n if (routeId < 111) {\n if (routeId == 109) {\n return\n 0x3cC5235c97d975a9b4FD4501B3446c981ea3D855;\n } else {\n return\n 0xa1827267d6Bd989Ff38580aE3d9deff6Acf19163;\n }\n } else {\n if (routeId == 111) {\n return\n 0x3663CAA0433A3D4171b3581Cf2410702840A735A;\n } else {\n return\n 0x7575D0a7614F655BA77C74a72a43bbd4fA6246a3;\n }\n }\n }\n }\n } else {\n if (routeId < 121) {\n if (routeId < 117) {\n if (routeId < 115) {\n if (routeId == 113) {\n return\n 0x2516Defc18bc07089c5dAFf5eafD7B0EF64611E2;\n } else {\n return\n 0xfec5FF08E20fbc107a97Af2D38BD0025b84ee233;\n }\n } else {\n if (routeId == 115) {\n return\n 0x0FB5763a87242B25243e23D73f55945fE787523A;\n } else {\n return\n 0xe4C00db89678dBf8391f430C578Ca857Dd98aDE1;\n }\n }\n } else {\n if (routeId < 119) {\n if (routeId == 117) {\n return\n 0x8F2A22061F9F35E64f14523dC1A5f8159e6a21B7;\n } else {\n return\n 0x18e4b838ae966917E20E9c9c5Ad359cDD38303bB;\n }\n } else {\n if (routeId == 119) {\n return\n 0x61ACb1d3Dcb3e3429832A164Cc0fC9849fb75A4a;\n } else {\n return\n 0x7681e3c8e7A41DCA55C257cc0d1Ae757f5530E65;\n }\n }\n }\n } else {\n if (routeId < 125) {\n if (routeId < 123) {\n if (routeId == 121) {\n return\n 0x806a2AB9748C3D1DB976550890E3f528B7E8Faec;\n } else {\n return\n 0xBDb8A5DD52C2c239fbC31E9d43B763B0197028FF;\n }\n } else {\n if (routeId == 123) {\n return\n 0x474EC9203706010B9978D6bD0b105D36755e4848;\n } else {\n return\n 0x8dfd0D829b303F2239212E591a0F92a32880f36E;\n }\n }\n } else {\n if (routeId < 127) {\n if (routeId == 125) {\n return\n 0xad4BcE9745860B1adD6F1Bd34a916f050E4c82C2;\n } else {\n return\n 0xBC701115b9fe14bC8CC5934cdC92517173e308C4;\n }\n } else {\n if (routeId == 127) {\n return\n 0x0D1918d786Db8546a11aDeD475C98370E06f255E;\n } else {\n return\n 0xee44f57cD6936DB55B99163f3Df367B01EdA785a;\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 193) {\n if (routeId < 161) {\n if (routeId < 145) {\n if (routeId < 137) {\n if (routeId < 133) {\n if (routeId < 131) {\n if (routeId == 129) {\n return\n 0x63044521fe5a1e488D7eD419cD0e35b7C24F2aa7;\n } else {\n return\n 0x410085E73BD85e90d97b84A68C125aDB9F91f85b;\n }\n } else {\n if (routeId == 131) {\n return\n 0x7913fe97E07C7A397Ec274Ab1d4E2622C88EC5D1;\n } else {\n return\n 0x977f9fE93c064DCf54157406DaABC3a722e8184C;\n }\n }\n } else {\n if (routeId < 135) {\n if (routeId == 133) {\n return\n 0xCD2236468722057cFbbABad2db3DEA9c20d5B01B;\n } else {\n return\n 0x17c7287A491cf5Ff81E2678cF2BfAE4333F6108c;\n }\n } else {\n if (routeId == 135) {\n return\n 0x354D9a5Dbf96c71B79a265F03B595C6Fdc04dadd;\n } else {\n return\n 0xb4e409EB8e775eeFEb0344f9eee884cc7ed21c69;\n }\n }\n }\n } else {\n if (routeId < 141) {\n if (routeId < 139) {\n if (routeId == 137) {\n return\n 0xa1a3c4670Ad69D9be4ab2D39D1231FEC2a63b519;\n } else {\n return\n 0x4589A22199870729C1be5CD62EE93BeD858113E6;\n }\n } else {\n if (routeId == 139) {\n return\n 0x8E7b864dB26Bd6C798C38d4Ba36EbA0d6602cF11;\n } else {\n return\n 0xA2D17C7260a4CB7b9854e89Fc367E80E87872a2d;\n }\n }\n } else {\n if (routeId < 143) {\n if (routeId == 141) {\n return\n 0xC7F0EDf0A1288627b0432304918A75e9084CBD46;\n } else {\n return\n 0xE4B4EF1f9A4aBFEdB371fA7a6143993B15d4df25;\n }\n } else {\n if (routeId == 143) {\n return\n 0xfe3D84A2Ef306FEBb5452441C9BDBb6521666F6A;\n } else {\n return\n 0x8A12B6C64121920110aE58F7cd67DfEc21c6a4C3;\n }\n }\n }\n }\n } else {\n if (routeId < 153) {\n if (routeId < 149) {\n if (routeId < 147) {\n if (routeId == 145) {\n return\n 0x76c4d9aFC4717a2BAac4e5f26CccF02351f7a3DA;\n } else {\n return\n 0xd4719BA550E397aeAcca1Ad2201c1ba69024FAAf;\n }\n } else {\n if (routeId == 147) {\n return\n 0x9646126Ce025224d1682C227d915a386efc0A1Fb;\n } else {\n return\n 0x4DD8Af2E3F2044842f0247920Bc4BABb636915ea;\n }\n }\n } else {\n if (routeId < 151) {\n if (routeId == 149) {\n return\n 0x8e8a327183Af0cf8C2ece9F0ed547C42A160D409;\n } else {\n return\n 0x9D49614CaE1C685C71678CA6d8CDF7584bfd0740;\n }\n } else {\n if (routeId == 151) {\n return\n 0x5a00ef257394cbc31828d48655E3d39e9c11c93d;\n } else {\n return\n 0xC9a2751b38d3dDD161A41Ca0135C5C6c09EC1d56;\n }\n }\n }\n } else {\n if (routeId < 157) {\n if (routeId < 155) {\n if (routeId == 153) {\n return\n 0x7e1c261640a525C94Ca4f8c25b48CF754DD83590;\n } else {\n return\n 0x409Fe24ba6F6BD5aF31C1aAf8059b986A3158233;\n }\n } else {\n if (routeId == 155) {\n return\n 0x704Cf5BFDADc0f55fDBb53B6ed8B582E018A72A2;\n } else {\n return\n 0x3982bF65d7d6E77E3b6661cd6F6468c247512737;\n }\n }\n } else {\n if (routeId < 159) {\n if (routeId == 157) {\n return\n 0x3982b9f26FFD67a13Ee371e2C0a9Da338BA70E7f;\n } else {\n return\n 0x6D834AB385900c1f49055D098e90264077FbC4f2;\n }\n } else {\n if (routeId == 159) {\n return\n 0x11FE5F70779A094B7166B391e1Fb73d422eF4e4d;\n } else {\n return\n 0xD347e4E47280d21F13B73D89c6d16f867D50DD13;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 177) {\n if (routeId < 169) {\n if (routeId < 165) {\n if (routeId < 163) {\n if (routeId == 161) {\n return\n 0xb6035eDD53DDA28d8B69b4ae9836E40C80306CD7;\n } else {\n return\n 0x54c884e6f5C7CcfeCA990396c520C858c922b6CA;\n }\n } else {\n if (routeId == 163) {\n return\n 0x5eA93E240b083d686558Ed607BC013d88057cE46;\n } else {\n return\n 0x4C7131eE812De685cBe4e2cCb033d46ecD46612E;\n }\n }\n } else {\n if (routeId < 167) {\n if (routeId == 165) {\n return\n 0xc1a5Be9F0c33D8483801D702111068669f81fF91;\n } else {\n return\n 0x9E5fAb91455Be5E5b2C05967E73F456c8118B1Fc;\n }\n } else {\n if (routeId == 167) {\n return\n 0x3d9A05927223E0DC2F382831770405885e22F0d8;\n } else {\n return\n 0x6303A011fB6063f5B1681cb5a9938EA278dc6128;\n }\n }\n }\n } else {\n if (routeId < 173) {\n if (routeId < 171) {\n if (routeId == 169) {\n return\n 0xe9c60795c90C66797e4c8E97511eA07CdAda32bE;\n } else {\n return\n 0xD56cC98e69A1e13815818b466a8aA6163d84234A;\n }\n } else {\n if (routeId == 171) {\n return\n 0x47EbB9D36a6e40895316cD894E4860D774E2c531;\n } else {\n return\n 0xA5EB293629410065d14a7B1663A67829b0618292;\n }\n }\n } else {\n if (routeId < 175) {\n if (routeId == 173) {\n return\n 0x1b3B4C8146F939cE00899db8B3ddeF0062b7E023;\n } else {\n return\n 0x257Bbc11653625EbfB6A8587eF4f4FBe49828EB3;\n }\n } else {\n if (routeId == 175) {\n return\n 0x44cc979C01b5bB1eAC21301E73C37200dFD06F59;\n } else {\n return\n 0x2972fDF43352225D82754C0174Ff853819D1ef2A;\n }\n }\n }\n }\n } else {\n if (routeId < 185) {\n if (routeId < 181) {\n if (routeId < 179) {\n if (routeId == 177) {\n return\n 0x3e54144f032648A04D62d79f7B4b93FF3aC2333b;\n } else {\n return\n 0x444016102dB8adbE73C3B6703a1ea7F2f75A510D;\n }\n } else {\n if (routeId == 179) {\n return\n 0xac079143f98a6eb744Fde34541ebF243DF5B5dED;\n } else {\n return\n 0xAe9010767Fb112d29d35CEdfba2b372Ad7A308d3;\n }\n }\n } else {\n if (routeId < 183) {\n if (routeId == 181) {\n return\n 0xfE0BCcF9cCC2265D5fB3450743f17DfE57aE1e56;\n } else {\n return\n 0x04ED8C0545716119437a45386B1d691C63234C7D;\n }\n } else {\n if (routeId == 183) {\n return\n 0x636c14013e531A286Bc4C848da34585f0bB73d59;\n } else {\n return\n 0x2Fa67fc7ECC5cAA01C653d3BFeA98ecc5db9C42A;\n }\n }\n }\n } else {\n if (routeId < 189) {\n if (routeId < 187) {\n if (routeId == 185) {\n return\n 0x23e9a0FC180818aA872D2079a985217017E97bd9;\n } else {\n return\n 0x79A95c3Ef81b3ae64ee03A9D5f73e570495F164E;\n }\n } else {\n if (routeId == 187) {\n return\n 0xa7EA0E88F04a84ba0ad1E396cb07Fa3fDAD7dF6D;\n } else {\n return\n 0xd23cA1278a2B01a3C0Ca1a00d104b11c1Ebe6f42;\n }\n }\n } else {\n if (routeId < 191) {\n if (routeId == 189) {\n return\n 0x707bc4a9FA2E349AED5df4e9f5440C15aA9D14Bd;\n } else {\n return\n 0x7E290F2dd539Ac6CE58d8B4C2B944931a1fD3612;\n }\n } else {\n if (routeId == 191) {\n return\n 0x707AA5503088Ce06Ba450B6470A506122eA5c8eF;\n } else {\n return\n 0xFbB3f7BF680deeb149f4E7BC30eA3DDfa68F3C3f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 225) {\n if (routeId < 209) {\n if (routeId < 201) {\n if (routeId < 197) {\n if (routeId < 195) {\n if (routeId == 193) {\n return\n 0xDE74aD8cCC3dbF14992f49Cf24f36855912f4934;\n } else {\n return\n 0x409BA83df7777F070b2B50a10a41DE2468d2a3B3;\n }\n } else {\n if (routeId == 195) {\n return\n 0x5CB7Be90A5DD7CfDa54e87626e254FE8C18255B4;\n } else {\n return\n 0x0A684fE12BC64fb72B59d0771a566F49BC090356;\n }\n }\n } else {\n if (routeId < 199) {\n if (routeId == 197) {\n return\n 0xDf30048d91F8FA2bCfC54952B92bFA8e161D3360;\n } else {\n return\n 0x050825Fff032a547C47061CF0696FDB0f65AEa5D;\n }\n } else {\n if (routeId == 199) {\n return\n 0xd55e671dAC1f03d366d8535073ada5DB2Aab1Ea2;\n } else {\n return\n 0x9470C704A9616c8Cd41c595Fcd2181B6fe2183C2;\n }\n }\n }\n } else {\n if (routeId < 205) {\n if (routeId < 203) {\n if (routeId == 201) {\n return\n 0x2D9ffD275181F5865d5e11CbB4ced1521C4dF9f1;\n } else {\n return\n 0x816d28Dec10ec95DF5334f884dE85cA6215918d8;\n }\n } else {\n if (routeId == 203) {\n return\n 0xd1f87267c4A43835E666dd69Df077e578A3b6299;\n } else {\n return\n 0x39E89Bde9DACbe5468C025dE371FbDa12bDeBAB1;\n }\n }\n } else {\n if (routeId < 207) {\n if (routeId == 205) {\n return\n 0x7b40A3207956ecad6686E61EfcaC48912FcD0658;\n } else {\n return\n 0x090cF10D793B1Efba9c7D76115878814B663859A;\n }\n } else {\n if (routeId == 207) {\n return\n 0x312A59c06E41327878F2063eD0e9c282C1DA3AfC;\n } else {\n return\n 0x4F1188f46236DD6B5de11Ebf2a9fF08716E7DeB6;\n }\n }\n }\n }\n } else {\n if (routeId < 217) {\n if (routeId < 213) {\n if (routeId < 211) {\n if (routeId == 209) {\n return\n 0x0A6F9a3f4fA49909bBfb4339cbE12B42F53BbBeD;\n } else {\n return\n 0x01d13d7aCaCbB955B81935c80ffF31e14BdFa71f;\n }\n } else {\n if (routeId == 211) {\n return\n 0x691a14Fa6C7360422EC56dF5876f84d4eDD7f00A;\n } else {\n return\n 0x97Aad18d886d181a9c726B3B6aE15a0A69F5aF73;\n }\n }\n } else {\n if (routeId < 215) {\n if (routeId == 213) {\n return\n 0x2917241371D2099049Fa29432DC46735baEC33b4;\n } else {\n return\n 0x5F20F20F7890c2e383E29D4147C9695A371165f5;\n }\n } else {\n if (routeId == 215) {\n return\n 0xeC0a60e639958335662C5219A320cCEbb56C6077;\n } else {\n return\n 0x96d63CF5062975C09845d17ec672E10255866053;\n }\n }\n }\n } else {\n if (routeId < 221) {\n if (routeId < 219) {\n if (routeId == 217) {\n return\n 0xFF57429e57D383939CAB50f09ABBfB63C0e6c9AD;\n } else {\n return\n 0x18E393A7c8578fb1e235C242076E50013cDdD0d7;\n }\n } else {\n if (routeId == 219) {\n return\n 0xE7E5238AF5d61f52E9B4ACC025F713d1C0216507;\n } else {\n return\n 0x428401D4d0F25A2EE1DA4d5366cB96Ded425D9bD;\n }\n }\n } else {\n if (routeId < 223) {\n if (routeId == 221) {\n return\n 0x42E5733551ff1Ee5B48Aa9fc2B61Af9b58C812E6;\n } else {\n return\n 0x64Df9c7A0551B056d860Bc2419Ca4c1EF75320bE;\n }\n } else {\n if (routeId == 223) {\n return\n 0x46006925506145611bBf0263243D8627dAf26B0F;\n } else {\n return\n 0x8D64BE884314662804eAaB884531f5C50F4d500c;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 241) {\n if (routeId < 233) {\n if (routeId < 229) {\n if (routeId < 227) {\n if (routeId == 225) {\n return\n 0x157a62D92D07B5ce221A5429645a03bBaCE85373;\n } else {\n return\n 0xaF037D33e1F1F2F87309B425fe8a9d895Ef3722B;\n }\n } else {\n if (routeId == 227) {\n return\n 0x921D1154E494A2f7218a37ad7B17701f94b4B40e;\n } else {\n return\n 0xF282b4555186d8Dea51B8b3F947E1E0568d09bc4;\n }\n }\n } else {\n if (routeId < 231) {\n if (routeId == 229) {\n return\n 0xa794E2E1869765a4600b3DFd8a4ebcF16350f6B6;\n } else {\n return\n 0xFEFb048e20c5652F7940A49B1980E0125Ec4D358;\n }\n } else {\n if (routeId == 231) {\n return\n 0x220104b641971e9b25612a8F001bf48AbB23f1cF;\n } else {\n return\n 0xcB9D373Bb54A501B35dd3be5bF4Ba43cA31F7035;\n }\n }\n }\n } else {\n if (routeId < 237) {\n if (routeId < 235) {\n if (routeId == 233) {\n return\n 0x37D627F56e3FF36aC316372109ea82E03ac97DAc;\n } else {\n return\n 0x4E81355FfB4A271B4EA59ff78da2b61c7833161f;\n }\n } else {\n if (routeId == 235) {\n return\n 0xADd8D65cAF6Cc9ad73127B49E16eA7ac29d91e87;\n } else {\n return\n 0x630F9b95626487dfEAe3C97A44DB6C59cF35d996;\n }\n }\n } else {\n if (routeId < 239) {\n if (routeId == 237) {\n return\n 0x78CE2BC8238B679680A67FCB98C5A60E4ec17b2D;\n } else {\n return\n 0xA38D776028eD1310b9A6b086f67F788201762E21;\n }\n } else {\n if (routeId == 239) {\n return\n 0x7Bb5178827B76B86753Ed62a0d662c72cEcb1bD3;\n } else {\n return\n 0x4faC26f61C76eC5c3D43b43eDfAFF0736Ae0e3da;\n }\n }\n }\n }\n } else {\n if (routeId < 249) {\n if (routeId < 245) {\n if (routeId < 243) {\n if (routeId == 241) {\n return\n 0x791Bb49bfFA7129D6889FDB27744422Ac4571A85;\n } else {\n return\n 0x26766fFEbb5fa564777913A6f101dF019AB32afa;\n }\n } else {\n if (routeId == 243) {\n return\n 0x05e98E5e95b4ECBbbAf3258c3999Cc81ed8048Be;\n } else {\n return\n 0xC5c4621e52f1D6A1825A5ed4F95855401a3D9C6b;\n }\n }\n } else {\n if (routeId < 247) {\n if (routeId == 245) {\n return\n 0xfcb15f909BA7FC7Ea083503Fb4c1020203c107EB;\n } else {\n return\n 0xbD27603279d969c74f2486ad14E71080829DFd38;\n }\n } else {\n if (routeId == 247) {\n return\n 0xff2f756BcEcC1A55BFc09a30cc5F64720458cFCB;\n } else {\n return\n 0x3bfB968FEbC12F4e8420B2d016EfcE1E615f7246;\n }\n }\n }\n } else {\n if (routeId < 253) {\n if (routeId < 251) {\n if (routeId == 249) {\n return\n 0x982EE9Ffe23051A2ec945ed676D864fa8345222b;\n } else {\n return\n 0xe101899100785E74767d454FFF0131277BaD48d9;\n }\n } else {\n if (routeId == 251) {\n return\n 0x4F730C0c6b3B5B7d06ca511379f4Aa5BfB2E9525;\n } else {\n return\n 0x5499c36b365795e4e0Ef671aF6C2ce26D7c78265;\n }\n }\n } else {\n if (routeId < 255) {\n if (routeId == 253) {\n return\n 0x8AF51F7237Fc8fB2fc3E700488a94a0aC6Ad8b5a;\n } else {\n return\n 0xda8716df61213c0b143F2849785FB85928084857;\n }\n } else {\n if (routeId == 255) {\n return\n 0xF040Cf9b1ebD11Bf28e04e80740DF3DDe717e4f5;\n } else {\n return\n 0xB87ba32f759D14023C7520366B844dF7f0F036C2;\n }\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 321) {\n if (routeId < 289) {\n if (routeId < 273) {\n if (routeId < 265) {\n if (routeId < 261) {\n if (routeId < 259) {\n if (routeId == 257) {\n return\n 0x0Edde681b8478F0c3194f468EdD2dB5e75c65CDD;\n } else {\n return\n 0x59C70900Fca06eE2aCE1BDd5A8D0Af0cc3BBA720;\n }\n } else {\n if (routeId == 259) {\n return\n 0x8041F0f180D17dD07087199632c45E17AeB0BAd5;\n } else {\n return\n 0x4fB4727064BA595995DD516b63b5921Df9B93aC6;\n }\n }\n } else {\n if (routeId < 263) {\n if (routeId == 261) {\n return\n 0x86e98b594565857eD098864F560915C0dAfd6Ea1;\n } else {\n return\n 0x70f8818E8B698EFfeCd86A513a4c87c0c380Bef6;\n }\n } else {\n if (routeId == 263) {\n return\n 0x78Ed227c8A897A21Da2875a752142dd80d865158;\n } else {\n return\n 0xd02A30BB5C3a8C51d2751A029a6fcfDE2Af9fbc6;\n }\n }\n }\n } else {\n if (routeId < 269) {\n if (routeId < 267) {\n if (routeId == 265) {\n return\n 0x0F00d5c5acb24e975e2a56730609f7F40aa763b8;\n } else {\n return\n 0xC3e2091edc2D3D9D98ba09269138b617B536834A;\n }\n } else {\n if (routeId == 267) {\n return\n 0xa6FbaF7F30867C9633908998ea8C3da28920E75C;\n } else {\n return\n 0xE6dDdcD41E2bBe8122AE32Ac29B8fbAB79CD21d9;\n }\n }\n } else {\n if (routeId < 271) {\n if (routeId == 269) {\n return\n 0x537aa8c1Ef6a8Eaf039dd6e1Eb67694a48195cE4;\n } else {\n return\n 0x96ABAC485fd2D0B03CF4a10df8BD58b8dED28300;\n }\n } else {\n if (routeId == 271) {\n return\n 0xda8e7D46d04Bd4F62705Cd80355BDB6d441DafFD;\n } else {\n return\n 0xbE50018E7a5c67E2e5f5414393e971CC96F293f2;\n }\n }\n }\n }\n } else {\n if (routeId < 281) {\n if (routeId < 277) {\n if (routeId < 275) {\n if (routeId == 273) {\n return\n 0xa1b3907D6CB542a4cbe2eE441EfFAA909FAb62C3;\n } else {\n return\n 0x6d08ee8511C0237a515013aC389e7B3968Cb1753;\n }\n } else {\n if (routeId == 275) {\n return\n 0x22faa5B5Fe43eAdbB52745e35a5cdA8bD5F96bbA;\n } else {\n return\n 0x7a673eB74D79e4868D689E7852abB5f93Ec2fD4b;\n }\n }\n } else {\n if (routeId < 279) {\n if (routeId == 277) {\n return\n 0x0b8531F8AFD4190b76F3e10deCaDb84c98b4d419;\n } else {\n return\n 0x78eABC743A93583DeE403D6b84795490e652216B;\n }\n } else {\n if (routeId == 279) {\n return\n 0x3A95D907b2a7a8604B59BccA08585F58Afe0Aa64;\n } else {\n return\n 0xf4271f0C8c9Af0F06A80b8832fa820ccE64FAda8;\n }\n }\n }\n } else {\n if (routeId < 285) {\n if (routeId < 283) {\n if (routeId == 281) {\n return\n 0x74b2DF841245C3748c0d31542e1335659a25C33b;\n } else {\n return\n 0xdFC99Fd0Ad7D16f30f295a5EEFcE029E04d0fa65;\n }\n } else {\n if (routeId == 283) {\n return\n 0xE992416b6aC1144eD8148a9632973257839027F6;\n } else {\n return\n 0x54ce55ba954E981BB1fd9399054B35Ce1f2C0816;\n }\n }\n } else {\n if (routeId < 287) {\n if (routeId == 285) {\n return\n 0xD4AB52f9e7E5B315Bd7471920baD04F405Ab1c38;\n } else {\n return\n 0x3670C990994d12837e95eE127fE2f06FD3E2104B;\n }\n } else {\n if (routeId == 287) {\n return\n 0xDcf190B09C47E4f551E30BBb79969c3FdEA1e992;\n } else {\n return\n 0xa65057B967B59677237e57Ab815B209744b9bc40;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 305) {\n if (routeId < 297) {\n if (routeId < 293) {\n if (routeId < 291) {\n if (routeId == 289) {\n return\n 0x6Efc86B40573e4C7F28659B13327D55ae955C483;\n } else {\n return\n 0x06BcC25CF8e0E72316F53631b3aA7134E9f73Ae0;\n }\n } else {\n if (routeId == 291) {\n return\n 0x710b6414E1D53882b1FCD3A168aD5Ccd435fc6D0;\n } else {\n return\n 0x5Ebb2C3d78c4e9818074559e7BaE7FCc99781DC1;\n }\n }\n } else {\n if (routeId < 295) {\n if (routeId == 293) {\n return\n 0xAf0a409c3AEe0bD08015cfb29D89E90b6e89A88F;\n } else {\n return\n 0x522559d8b99773C693B80cE06DF559036295Ce44;\n }\n } else {\n if (routeId == 295) {\n return\n 0xB65290A5Bae838aaa7825c9ECEC68041841a1B64;\n } else {\n return\n 0x801b8F2068edd5Bcb659E6BDa0c425909043C420;\n }\n }\n }\n } else {\n if (routeId < 301) {\n if (routeId < 299) {\n if (routeId == 297) {\n return\n 0x29b5F00515d093627E0B7bd0b5c8E84F6b4cDb87;\n } else {\n return\n 0x652839Ae74683cbF9f1293F1019D938F87464D3E;\n }\n } else {\n if (routeId == 299) {\n return\n 0x5Bc95dCebDDE9B79F2b6DC76121BC7936eF8D666;\n } else {\n return\n 0x90db359CEA62E53051158Ab5F99811C0a07Fe686;\n }\n }\n } else {\n if (routeId < 303) {\n if (routeId == 301) {\n return\n 0x2c3625EedadbDcDbB5330eb0d17b3C39ff269807;\n } else {\n return\n 0xC3f0324471b5c9d415acD625b8d8694a4e48e001;\n }\n } else {\n if (routeId == 303) {\n return\n 0x8C60e7E05fa0FfB6F720233736f245134685799d;\n } else {\n return\n 0x98fAF2c09aa4EBb995ad0B56152993E7291a500e;\n }\n }\n }\n }\n } else {\n if (routeId < 313) {\n if (routeId < 309) {\n if (routeId < 307) {\n if (routeId == 305) {\n return\n 0x802c1063a861414dFAEc16bacb81429FC0d40D6e;\n } else {\n return\n 0x11C4AeFCC0dC156f64195f6513CB1Fb3Be0Ae056;\n }\n } else {\n if (routeId == 307) {\n return\n 0xEff1F3258214E31B6B4F640b4389d55715C3Be2B;\n } else {\n return\n 0x47e379Abe8DDFEA4289aBa01235EFF7E93758fd7;\n }\n }\n } else {\n if (routeId < 311) {\n if (routeId == 309) {\n return\n 0x3CC26384c3eA31dDc8D9789e8872CeA6F20cD3ff;\n } else {\n return\n 0xEdd9EFa6c69108FAA4611097d643E20Ba0Ed1634;\n }\n } else {\n if (routeId == 311) {\n return\n 0xCb93525CA5f3D371F74F3D112bC19526740717B8;\n } else {\n return\n 0x7071E0124EB4438137e60dF1b8DD8Af1BfB362cF;\n }\n }\n }\n } else {\n if (routeId < 317) {\n if (routeId < 315) {\n if (routeId == 313) {\n return\n 0x4691096EB0b78C8F4b4A8091E5B66b18e1835c10;\n } else {\n return\n 0x8d953c9b2d1C2137CF95992079f3A77fCd793272;\n }\n } else {\n if (routeId == 315) {\n return\n 0xbdCc2A3Bf6e3Ba49ff86595e6b2b8D70d8368c92;\n } else {\n return\n 0x95E6948aB38c61b2D294E8Bd896BCc4cCC0713cf;\n }\n }\n } else {\n if (routeId < 319) {\n if (routeId == 317) {\n return\n 0x607b27C881fFEE4Cb95B1c5862FaE7224ccd0b4A;\n } else {\n return\n 0x09D28aFA166e566A2Ee1cB834ea8e78C7E627eD2;\n }\n } else {\n if (routeId == 319) {\n return\n 0x9c01449b38bDF0B263818401044Fb1401B29fDfA;\n } else {\n return\n 0x1F7723599bbB658c051F8A39bE2688388d22ceD6;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 353) {\n if (routeId < 337) {\n if (routeId < 329) {\n if (routeId < 325) {\n if (routeId < 323) {\n if (routeId == 321) {\n return\n 0x52B71603f7b8A5d15B4482e965a0619aa3210194;\n } else {\n return\n 0x01c0f072CB210406653752FecFA70B42dA9173a2;\n }\n } else {\n if (routeId == 323) {\n return\n 0x3021142f021E943e57fc1886cAF58D06147D09A6;\n } else {\n return\n 0xe6f2AF38e76AB09Db59225d97d3E770942D3D842;\n }\n }\n } else {\n if (routeId < 327) {\n if (routeId == 325) {\n return\n 0x06a25554e5135F08b9e2eD1DEC1fc3CEd52e0B48;\n } else {\n return\n 0x71d75e670EE3511C8290C705E0620126B710BF8D;\n }\n } else {\n if (routeId == 327) {\n return\n 0x8b9cE142b80FeA7c932952EC533694b1DF9B3c54;\n } else {\n return\n 0xd7Be24f32f39231116B3fDc483C2A12E1521f73B;\n }\n }\n }\n } else {\n if (routeId < 333) {\n if (routeId < 331) {\n if (routeId == 329) {\n return\n 0xb40cafBC4797d4Ff64087E087F6D2e661f954CbE;\n } else {\n return\n 0xBdDCe7771EfEe81893e838f62204A4c76D72757e;\n }\n } else {\n if (routeId == 331) {\n return\n 0x5d3D299EA7Fd4F39AcDb336E26631Dfee41F9287;\n } else {\n return\n 0x6BfEE09E1Fc0684e0826A9A0dC1352a14B136FAC;\n }\n }\n } else {\n if (routeId < 335) {\n if (routeId == 333) {\n return\n 0xd0001bB8E2Cb661436093f96458a4358B5156E3c;\n } else {\n return\n 0x1867c6485CfD1eD448988368A22bfB17a7747293;\n }\n } else {\n if (routeId == 335) {\n return\n 0x8997EF9F95dF24aB67703AB6C262aABfeEBE33bD;\n } else {\n return\n 0x1e39E9E601922deD91BCFc8F78836302133465e2;\n }\n }\n }\n }\n } else {\n if (routeId < 345) {\n if (routeId < 341) {\n if (routeId < 339) {\n if (routeId == 337) {\n return\n 0x8A8ec6CeacFf502a782216774E5AF3421562C6ff;\n } else {\n return\n 0x3B8FC561df5415c8DC01e97Ee6E38435A8F9C40A;\n }\n } else {\n if (routeId == 339) {\n return\n 0xD5d5f5B37E67c43ceA663aEDADFFc3a93a2065B0;\n } else {\n return\n 0xCC8F55EC43B4f25013CE1946FBB740c43Be5B96D;\n }\n }\n } else {\n if (routeId < 343) {\n if (routeId == 341) {\n return\n 0x18f586E816eEeDbb57B8011239150367561B58Fb;\n } else {\n return\n 0xd0CD802B19c1a52501cb2f07d656e3Cd7B0Ce124;\n }\n } else {\n if (routeId == 343) {\n return\n 0xe0AeD899b39C6e4f2d83e4913a1e9e0cf6368abE;\n } else {\n return\n 0x0606e1b6c0f1A398C38825DCcc4678a7Cbc2737c;\n }\n }\n }\n } else {\n if (routeId < 349) {\n if (routeId < 347) {\n if (routeId == 345) {\n return\n 0x2d188e85b27d18EF80f16686EA1593ABF7Ed2A63;\n } else {\n return\n 0x64412292fA4A135a3300E24366E99ff59Db2eAc1;\n }\n } else {\n if (routeId == 347) {\n return\n 0x38b74c173f3733E8b90aAEf0e98B89791266149F;\n } else {\n return\n 0x36DAA49A79aaEF4E7a217A11530D3cCD84414124;\n }\n }\n } else {\n if (routeId < 351) {\n if (routeId == 349) {\n return\n 0x10f088FE2C88F90270E4449c46c8B1b232511d58;\n } else {\n return\n 0x4FeDbd25B58586838ABD17D10272697dF1dC3087;\n }\n } else {\n if (routeId == 351) {\n return\n 0x685278209248CB058E5cEe93e37f274A80Faf6eb;\n } else {\n return\n 0xDd9F8F1eeC3955f78168e2Fb2d1e808fa8A8f15b;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 369) {\n if (routeId < 361) {\n if (routeId < 357) {\n if (routeId < 355) {\n if (routeId == 353) {\n return\n 0x7392aEeFD5825aaC28817031dEEBbFaAA20983D9;\n } else {\n return\n 0x0Cc182555E00767D6FB8AD161A10d0C04C476d91;\n }\n } else {\n if (routeId == 355) {\n return\n 0x90E52837d56715c79FD592E8D58bFD20365798b2;\n } else {\n return\n 0x6F4451DE14049B6770ad5BF4013118529e68A40C;\n }\n }\n } else {\n if (routeId < 359) {\n if (routeId == 357) {\n return\n 0x89B97ef2aFAb9ed9c7f0FDb095d02E6840b52d9c;\n } else {\n return\n 0x92A5cC5C42d94d3e23aeB1214fFf43Db2B97759E;\n }\n } else {\n if (routeId == 359) {\n return\n 0x63ddc52F135A1dcBA831EAaC11C63849F018b739;\n } else {\n return\n 0x692A691533B571C2c54C1D7F8043A204b3d8120E;\n }\n }\n }\n } else {\n if (routeId < 365) {\n if (routeId < 363) {\n if (routeId == 361) {\n return\n 0x97c7492CF083969F61C6f302d45c8270391b921c;\n } else {\n return\n 0xDeFD2B8643553dAd19548eB14fd94A57F4B9e543;\n }\n } else {\n if (routeId == 363) {\n return\n 0x30645C04205cA3f670B67b02F971B088930ACB8C;\n } else {\n return\n 0xA6f80ed2d607Cd67aEB4109B64A0BEcc4D7d03CF;\n }\n }\n } else {\n if (routeId < 367) {\n if (routeId == 365) {\n return\n 0xBbbbC6c276eB3F7E674f2D39301509236001c42f;\n } else {\n return\n 0xC20E77d349FB40CE88eB01824e2873ad9f681f3C;\n }\n } else {\n if (routeId == 367) {\n return\n 0x5fCfD9a962De19294467C358C1FA55082285960b;\n } else {\n return\n 0x4D87BD6a0E4E5cc6332923cb3E85fC71b287F58A;\n }\n }\n }\n }\n } else {\n if (routeId < 377) {\n if (routeId < 373) {\n if (routeId < 371) {\n if (routeId == 369) {\n return\n 0x3AA5B757cd6Dde98214E56D57Dde7fcF0F7aB04E;\n } else {\n return\n 0xe28eFCE7192e11a2297f44059113C1fD6967b2d4;\n }\n } else {\n if (routeId == 371) {\n return\n 0x3251cAE10a1Cf246e0808D76ACC26F7B5edA0eE5;\n } else {\n return\n 0xbA2091cc9357Cf4c4F25D64F30d1b4Ba3A5a174B;\n }\n }\n } else {\n if (routeId < 375) {\n if (routeId == 373) {\n return\n 0x49c8e1Da9693692096F63C82D11b52d738566d55;\n } else {\n return\n 0xA0731615aB5FFF451031E9551367A4F7dB27b39c;\n }\n } else {\n if (routeId == 375) {\n return\n 0xFb214541888671AE1403CecC1D59763a12fc1609;\n } else {\n return\n 0x1D6bCB17642E2336405df73dF22F07688cAec020;\n }\n }\n }\n } else {\n if (routeId < 381) {\n if (routeId < 379) {\n if (routeId == 377) {\n return\n 0xfC9c0C7bfe187120fF7f4E21446161794A617a9e;\n } else {\n return\n 0xBa5bF37678EeE2dAB17AEf9D898153258252250E;\n }\n } else {\n if (routeId == 379) {\n return\n 0x7c55690bd2C9961576A32c02f8EB29ed36415Ec7;\n } else {\n return\n 0xcA40073E868E8Bc611aEc8Fe741D17E68Fe422f6;\n }\n }\n } else {\n if (routeId < 383) {\n if (routeId == 381) {\n return\n 0x31641bAFb87E9A58f78835050a7BE56921986339;\n } else {\n return\n 0xA54766424f6dA74b45EbCc5Bf0Bd1D74D2CCcaAB;\n }\n } else {\n if (routeId == 383) {\n return\n 0xc7bBa57F8C179EDDBaa62117ddA360e28f3F8252;\n } else {\n return\n 0x5e663ED97ea77d393B8858C90d0683bF180E0ffd;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n if (routes[routeId] == address(0)) revert ZeroAddressNotAllowed();\n return routes[routeId];\n }\n\n /// @notice fallback function to handle swap, bridge execution\n /// @dev ensure routeId is converted to bytes4 and sent as msg.sig in the transaction\n fallback() external payable {\n address routeAddress = addressAt(uint32(msg.sig));\n\n bytes memory result;\n\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 4, sub(calldatasize(), 4))\n // execute function call using the facet\n result := delegatecall(\n gas(),\n routeAddress,\n 0,\n sub(calldatasize(), 4),\n 0,\n 0\n )\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "src/bridges/hop/interfaces/IHopL1Bridge.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title L1Bridge Hop Interface\n * @notice L1 Hop Bridge, Used to transfer from L1 to L2s.\n */\ninterface IHopL1Bridge {\n /**\n * @notice `amountOutMin` and `deadline` should be 0 when no swap is intended at the destination.\n * @notice `amount` is the total amount the user wants to send including the relayer fee\n * @dev Send tokens to a supported layer-2 to mint hToken and optionally swap the hToken in the\n * AMM at the destination.\n * @param chainId The chainId of the destination chain\n * @param recipient The address receiving funds at the destination\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination\n * AMM market. 0 if no swap is intended.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no\n * swap is intended.\n * @param relayer The address of the relayer at the destination.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n */\n function sendToL2(\n uint256 chainId,\n address recipient,\n uint256 amount,\n uint256 amountOutMin,\n uint256 deadline,\n address relayer,\n uint256 relayerFee\n ) external payable;\n}\n" + }, + "src/bridges/refuel/interfaces/refuel.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/// @notice interface with functions to interact with Refuel contract\ninterface IRefuel {\n /**\n * @notice function to deposit nativeToken to Destination-address on destinationChain\n * @param destinationChainId chainId of the Destination chain\n * @param _to recipient address\n */\n function depositNativeToken(\n uint256 destinationChainId,\n address _to\n ) external payable;\n}\n" + }, + "src/bridges/stargate/interfaces/stargate.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\n/**\n * @title IBridgeStargate Interface Contract.\n * @notice Interface used by Stargate-L1 and L2 Router implementations\n * @dev router and routerETH addresses will be distinct for L1 and L2\n */\ninterface IBridgeStargate {\n // @notice Struct to hold the additional-data for bridging ERC20 token\n struct lzTxObj {\n // gas limit to bridge the token in Stargate to destinationChain\n uint256 dstGasForCall;\n // destination nativeAmount, this is always set as 0\n uint256 dstNativeAmount;\n // destination nativeAddress, this is always set as 0x\n bytes dstNativeAddr;\n }\n\n /// @notice function in stargate bridge which is used to bridge ERC20 tokens to recipient on destinationChain\n function swap(\n uint16 _dstChainId,\n uint256 _srcPoolId,\n uint256 _dstPoolId,\n address payable _refundAddress,\n uint256 _amountLD,\n uint256 _minAmountLD,\n lzTxObj memory _lzTxParams,\n bytes calldata _to,\n bytes calldata _payload\n ) external payable;\n\n /// @notice function in stargate bridge which is used to bridge native tokens to recipient on destinationChain\n function swapETH(\n uint16 _dstChainId, // destination Stargate chainId\n address payable _refundAddress, // refund additional messageFee to this address\n bytes calldata _toAddress, // the receiver of the destination ETH\n uint256 _amountLD, // the amount, in Local Decimals, to be swapped\n uint256 _minAmountLD // the minimum amount accepted out on destination\n ) external payable;\n}\n" + }, + "src/controllers/FeesTakerController.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BaseController} from \"./BaseController.sol\";\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\n\n/**\n * @title FeesTaker-Controller Implementation\n * @notice Controller with composed actions to deduct-fees followed by Refuel, Swap and Bridge\n * to be executed Sequentially and this is atomic\n * @author Socket dot tech.\n */\ncontract FeesTakerController is BaseController {\n using SafeTransferLib for ERC20;\n\n /// @notice event emitted upon fee-deduction to fees-taker address\n event SocketFeesDeducted(\n uint256 fees,\n address feesToken,\n address feesTaker\n );\n\n /// @notice Function-selector to invoke deduct-fees and swap token\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_SWAP_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"takeFeesAndSwap((address,address,uint256,uint32,bytes))\")\n );\n\n /// @notice Function-selector to invoke deduct-fees and bridge token\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeesAndBridge((address,address,uint256,uint32,bytes))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees and bridge multiple tokens\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_MULTI_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeesAndMultiBridge((address,address,uint256,uint32[],bytes[]))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees followed by swapping of a token and bridging the swapped bridge\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeeAndSwapAndBridge((address,address,uint256,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees refuel\n /// @notice followed by swapping of a token and bridging the swapped bridge\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeeAndRefuelAndSwapAndBridge((address,address,uint256,uint32,bytes,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BaseController\n constructor(\n address _socketGatewayAddress\n ) BaseController(_socketGatewayAddress) {}\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and swap token\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftsRequest feesTakerSwapRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_SWAP_FUNCTION_SELECTOR\n * @return output bytes from the swap operation (last operation in the composed actions)\n */\n function takeFeesAndSwap(\n ISocketRequest.FeesTakerSwapRequest calldata ftsRequest\n ) external payable returns (bytes memory) {\n if (ftsRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftsRequest.feesTakerAddress).transfer(\n ftsRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftsRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftsRequest.feesTakerAddress,\n ftsRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftsRequest.feesAmount,\n ftsRequest.feesTakerAddress,\n ftsRequest.feesToken\n );\n\n //call bridge function (executeRoute for the swapRequestData)\n return _executeRoute(ftsRequest.routeId, ftsRequest.swapRequestData);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and bridge amount to destinationChain\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftbRequest feesTakerBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_BRIDGE_FUNCTION_SELECTOR\n * @return output bytes from the bridge operation (last operation in the composed actions)\n */\n function takeFeesAndBridge(\n ISocketRequest.FeesTakerBridgeRequest calldata ftbRequest\n ) external payable returns (bytes memory) {\n if (ftbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftbRequest.feesTakerAddress).transfer(\n ftbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftbRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftbRequest.feesTakerAddress,\n ftbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftbRequest.feesAmount,\n ftbRequest.feesTakerAddress,\n ftbRequest.feesToken\n );\n\n //call bridge function (executeRoute for the bridgeData)\n return _executeRoute(ftbRequest.routeId, ftbRequest.bridgeRequestData);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and bridge amount to destinationChain\n * @notice multiple bridge-requests are to be generated and sequence and number of routeIds should match with the bridgeData array\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftmbRequest feesTakerMultiBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_MULTI_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeesAndMultiBridge(\n ISocketRequest.FeesTakerMultiBridgeRequest calldata ftmbRequest\n ) external payable {\n if (ftmbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftmbRequest.feesTakerAddress).transfer(\n ftmbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftmbRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftmbRequest.feesTakerAddress,\n ftmbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftmbRequest.feesAmount,\n ftmbRequest.feesTakerAddress,\n ftmbRequest.feesToken\n );\n\n // multiple bridge-requests are to be generated and sequence and number of routeIds should match with the bridgeData array\n for (\n uint256 index = 0;\n index < ftmbRequest.bridgeRouteIds.length;\n ++index\n ) {\n //call bridge function (executeRoute for the bridgeData)\n _executeRoute(\n ftmbRequest.bridgeRouteIds[index],\n ftmbRequest.bridgeRequestDataItems[index]\n );\n }\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain followed by swap the amount on sourceChain followed by\n * bridging the swapped amount to destinationChain\n * @dev while generating implData for swap and bridgeRequests, ensure correct function selector is used\n * bridge action corresponds to the bridgeAfterSwap function of the bridgeImplementation\n * @param fsbRequest feesTakerSwapBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_SWAP_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeeAndSwapAndBridge(\n ISocketRequest.FeesTakerSwapBridgeRequest calldata fsbRequest\n ) external payable returns (bytes memory) {\n if (fsbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(fsbRequest.feesTakerAddress).transfer(\n fsbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(fsbRequest.feesToken).safeTransferFrom(\n msg.sender,\n fsbRequest.feesTakerAddress,\n fsbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n fsbRequest.feesAmount,\n fsbRequest.feesTakerAddress,\n fsbRequest.feesToken\n );\n\n // execute swap operation\n bytes memory swapResponseData = _executeRoute(\n fsbRequest.swapRouteId,\n fsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n // swapped amount is to be bridged to the recipient on destinationChain\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n fsbRequest.bridgeData\n );\n\n // execute bridge operation and return the byte-data from response of bridge operation\n return _executeRoute(fsbRequest.bridgeRouteId, bridgeImpldata);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain followed by refuel followed by\n * swap the amount on sourceChain followed by bridging the swapped amount to destinationChain\n * @dev while generating implData for refuel, swap and bridge Requests, ensure correct function selector is used\n * bridge action corresponds to the bridgeAfterSwap function of the bridgeImplementation\n * @param frsbRequest feesTakerRefuelSwapBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeeAndRefuelAndSwapAndBridge(\n ISocketRequest.FeesTakerRefuelSwapBridgeRequest calldata frsbRequest\n ) external payable returns (bytes memory) {\n if (frsbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(frsbRequest.feesTakerAddress).transfer(\n frsbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(frsbRequest.feesToken).safeTransferFrom(\n msg.sender,\n frsbRequest.feesTakerAddress,\n frsbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n frsbRequest.feesAmount,\n frsbRequest.feesTakerAddress,\n frsbRequest.feesToken\n );\n\n // refuel is also done via bridge execution via refuelRouteImplementation identified by refuelRouteId\n _executeRoute(frsbRequest.refuelRouteId, frsbRequest.refuelData);\n\n // execute swap operation\n bytes memory swapResponseData = _executeRoute(\n frsbRequest.swapRouteId,\n frsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n // swapped amount is to be bridged to the recipient on destinationChain\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n frsbRequest.bridgeData\n );\n\n // execute bridge operation and return the byte-data from response of bridge operation\n return _executeRoute(frsbRequest.bridgeRouteId, bridgeImpldata);\n }\n}\n" + }, + "src/errors/SocketErrors.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nerror CelerRefundNotReady();\nerror OnlySocketDeployer();\nerror OnlySocketGatewayOwner();\nerror OnlySocketGateway();\nerror OnlyOwner();\nerror OnlyNominee();\nerror TransferIdExists();\nerror TransferIdDoesnotExist();\nerror Address0Provided();\nerror SwapFailed();\nerror UnsupportedInterfaceId();\nerror InvalidCelerRefund();\nerror CelerAlreadyRefunded();\nerror IncorrectBridgeRatios();\nerror ZeroAddressNotAllowed();\nerror ArrayLengthMismatch();\n" + }, + "src/bridges/hop/l1/HopImplL1.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"../interfaces/IHopL1Bridge.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {HOP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hop-L1 Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Hop-Bridge from L1 to Supported L2s\n * Called via SocketGateway if the routeId in the request maps to the routeId of HopImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HopImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HopIdentifier = HOP;\n\n /// @notice Function-selector for ERC20-token bridging on Hop-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HOP_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,address,uint256,uint256,uint256,uint256,(uint256,bytes32))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Hop-L1-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable HOP_L1_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,address,uint256,uint256,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable HOP_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,address,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HopDataNoToken {\n // The address receiving funds at the destination\n address receiverAddress;\n // address of the Hop-L1-Bridge to handle bridging the tokens\n address l1bridgeAddr;\n // relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n address relayer;\n // The chainId of the destination chain\n uint256 toChainId;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n uint256 relayerFee;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopData {\n /// @notice address of token being bridged\n address token;\n // The address receiving funds at the destination\n address receiverAddress;\n // address of the Hop-L1-Bridge to handle bridging the tokens\n address l1bridgeAddr;\n // relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n address relayer;\n // The chainId of the destination chain\n uint256 toChainId;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n uint256 relayerFee;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopERC20Data {\n uint256 deadline;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Hop-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HopData memory hopData = abi.decode(bridgeData, (HopData));\n\n if (hopData.token == NATIVE_TOKEN_ADDRESS) {\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2{value: amount}(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n } else {\n ERC20(hopData.token).safeApprove(hopData.l1bridgeAddr, amount);\n\n // perform bridging\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n }\n\n emit SocketBridge(\n amount,\n hopData.token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hopData encoded data for HopData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HopDataNoToken calldata hopData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2{value: bridgeAmount}(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n } else {\n ERC20(token).safeApprove(hopData.l1bridgeAddr, bridgeAmount);\n\n // perform bridging\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hop-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param token token being bridged\n * @param l1bridgeAddr address of the Hop-L1-Bridge to handle bridging the tokens\n * @param relayer The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n * @param toChainId The chainId of the destination chain\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n * @param hopData extra data needed to build the tx\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n address l1bridgeAddr,\n address relayer,\n uint256 toChainId,\n uint256 amount,\n uint256 amountOutMin,\n uint256 relayerFee,\n HopERC20Data calldata hopData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(l1bridgeAddr, amount);\n\n // perform bridging\n IHopL1Bridge(l1bridgeAddr).sendToL2(\n toChainId,\n receiverAddress,\n amount,\n amountOutMin,\n hopData.deadline,\n relayer,\n relayerFee\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hop-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param l1bridgeAddr address of the Hop-L1-Bridge to handle bridging the tokens\n * @param relayer The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n * @param toChainId The chainId of the destination chain\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n */\n function bridgeNativeTo(\n address receiverAddress,\n address l1bridgeAddr,\n address relayer,\n uint256 toChainId,\n uint256 amount,\n uint256 amountOutMin,\n uint256 relayerFee,\n uint256 deadline,\n bytes32 metadata\n ) external payable {\n IHopL1Bridge(l1bridgeAddr).sendToL2{value: amount}(\n toChainId,\n receiverAddress,\n amount,\n amountOutMin,\n deadline,\n relayer,\n relayerFee\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + }, + "src/static/RouteIdentifiers.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\nbytes32 constant ACROSS = keccak256(\"Across\");\n\nbytes32 constant ANYSWAP = keccak256(\"Anyswap\");\n\nbytes32 constant CBRIDGE = keccak256(\"CBridge\");\n\nbytes32 constant HOP = keccak256(\"Hop\");\n\nbytes32 constant HYPHEN = keccak256(\"Hyphen\");\n\nbytes32 constant NATIVE_OPTIMISM = keccak256(\"NativeOptimism\");\n\nbytes32 constant NATIVE_ARBITRUM = keccak256(\"NativeArbitrum\");\n\nbytes32 constant NATIVE_POLYGON = keccak256(\"NativePolygon\");\n\nbytes32 constant REFUEL = keccak256(\"Refuel\");\n\nbytes32 constant STARGATE = keccak256(\"Stargate\");\n\nbytes32 constant ONEINCH = keccak256(\"OneInch\");\n\nbytes32 constant ZEROX = keccak256(\"Zerox\");\n\nbytes32 constant RAINBOW = keccak256(\"Rainbow\");\n" + }, + "src/SocketGateway.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\npragma experimental ABIEncoderV2;\n\nimport \"./utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {LibUtil} from \"./libraries/LibUtil.sol\";\nimport \"./libraries/LibBytes.sol\";\nimport {ISocketRoute} from \"./interfaces/ISocketRoute.sol\";\nimport {ISocketRequest} from \"./interfaces/ISocketRequest.sol\";\nimport {ISocketGateway} from \"./interfaces/ISocketGateway.sol\";\nimport {IncorrectBridgeRatios, ZeroAddressNotAllowed, ArrayLengthMismatch} from \"./errors/SocketErrors.sol\";\n\n/// @title SocketGatewayContract\n/// @notice Socketgateway is a contract with entrypoint functions for all interactions with socket liquidity layer\n/// @author Socket Team\ncontract SocketGatewayTemplate is Ownable {\n using LibBytes for bytes;\n using LibBytes for bytes4;\n using SafeTransferLib for ERC20;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice storage variable to keep track of total number of routes registered in socketgateway\n uint32 public routesCount = 385;\n\n /// @notice storage variable to keep track of total number of controllers registered in socketgateway\n uint32 public controllerCount;\n\n address public immutable disabledRouteAddress;\n\n uint256 public constant CENT_PERCENT = 100e18;\n\n /// @notice storage mapping for route implementation addresses\n mapping(uint32 => address) public routes;\n\n /// storage mapping for controller implemenation addresses\n mapping(uint32 => address) public controllers;\n\n // Events ------------------------------------------------------------------------------------------------------->\n\n /// @notice Event emitted when a router is added to socketgateway\n event NewRouteAdded(uint32 indexed routeId, address indexed route);\n\n /// @notice Event emitted when a route is disabled\n event RouteDisabled(uint32 indexed routeId);\n\n /// @notice Event emitted when ownership transfer is requested by socket-gateway-owner\n event OwnershipTransferRequested(\n address indexed _from,\n address indexed _to\n );\n\n /// @notice Event emitted when a controller is added to socketgateway\n event ControllerAdded(\n uint32 indexed controllerId,\n address indexed controllerAddress\n );\n\n /// @notice Event emitted when a controller is disabled\n event ControllerDisabled(uint32 indexed controllerId);\n\n constructor(address _owner, address _disabledRoute) Ownable(_owner) {\n disabledRouteAddress = _disabledRoute;\n }\n\n // Able to receive ether\n // solhint-disable-next-line no-empty-blocks\n receive() external payable {}\n\n /*******************************************\n * EXTERNAL AND PUBLIC FUNCTIONS *\n *******************************************/\n\n /**\n * @notice executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in routeData to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeId route identifier\n * @param routeData functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoute(\n uint32 routeId,\n bytes calldata routeData\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = addressAt(routeId).delegatecall(\n routeData\n );\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice swaps a token on sourceChain and split it across multiple bridge-recipients\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being swapped\n * @dev ensure the swap-data and bridge-data is generated using the function-selector defined as a constant in the implementation address\n * @param swapMultiBridgeRequest request\n */\n function swapAndMultiBridge(\n ISocketRequest.SwapMultiBridgeRequest calldata swapMultiBridgeRequest\n ) external payable {\n uint256 requestLength = swapMultiBridgeRequest.bridgeRouteIds.length;\n\n if (\n requestLength != swapMultiBridgeRequest.bridgeImplDataItems.length\n ) {\n revert ArrayLengthMismatch();\n }\n uint256 ratioAggregate;\n for (uint256 index = 0; index < requestLength; ) {\n ratioAggregate += swapMultiBridgeRequest.bridgeRatios[index];\n }\n\n if (ratioAggregate != CENT_PERCENT) {\n revert IncorrectBridgeRatios();\n }\n\n (bool swapSuccess, bytes memory swapResult) = addressAt(\n swapMultiBridgeRequest.swapRouteId\n ).delegatecall(swapMultiBridgeRequest.swapImplData);\n\n if (!swapSuccess) {\n assembly {\n revert(add(swapResult, 32), mload(swapResult))\n }\n }\n\n uint256 amountReceivedFromSwap = abi.decode(swapResult, (uint256));\n\n uint256 bridgedAmount;\n\n for (uint256 index = 0; index < requestLength; ) {\n uint256 bridgingAmount;\n\n // if it is the last bridge request, bridge the remaining amount\n if (index == requestLength - 1) {\n bridgingAmount = amountReceivedFromSwap - bridgedAmount;\n } else {\n // bridging amount is the multiplication of bridgeRatio and amountReceivedFromSwap\n bridgingAmount =\n (amountReceivedFromSwap *\n swapMultiBridgeRequest.bridgeRatios[index]) /\n (CENT_PERCENT);\n }\n\n // update the bridged amount, this would be used for computation for last bridgeRequest\n bridgedAmount += bridgingAmount;\n\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n bridgingAmount,\n swapMultiBridgeRequest.bridgeImplDataItems[index]\n );\n\n (bool bridgeSuccess, bytes memory bridgeResult) = addressAt(\n swapMultiBridgeRequest.bridgeRouteIds[index]\n ).delegatecall(bridgeImpldata);\n\n if (!bridgeSuccess) {\n assembly {\n revert(add(bridgeResult, 32), mload(bridgeResult))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice sequentially executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each dataItem to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeIds a list of route identifiers\n * @param dataItems a list of functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoutes(\n uint32[] calldata routeIds,\n bytes[] calldata dataItems\n ) external payable {\n uint256 routeIdslength = routeIds.length;\n if (routeIdslength != dataItems.length) revert ArrayLengthMismatch();\n for (uint256 index = 0; index < routeIdslength; ) {\n (bool success, bytes memory result) = addressAt(routeIds[index])\n .delegatecall(dataItems[index]);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice execute a controller function identified using the controllerId in the request\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param socketControllerRequest socketControllerRequest with controllerId to identify the\n * controllerAddress and byteData constructed using functionSelector\n * of the function being invoked\n * @return bytes data received from the call delegated to controller\n */\n function executeController(\n ISocketGateway.SocketControllerRequest calldata socketControllerRequest\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = controllers[\n socketControllerRequest.controllerId\n ].delegatecall(socketControllerRequest.data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice sequentially executes all controller requests\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each controller-request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param controllerRequests a list of socketControllerRequest\n * Each controllerRequest contains controllerId to identify the controllerAddress and\n * byteData constructed using functionSelector of the function being invoked\n */\n function executeControllers(\n ISocketGateway.SocketControllerRequest[] calldata controllerRequests\n ) external payable {\n for (uint32 index = 0; index < controllerRequests.length; ) {\n (bool success, bytes memory result) = controllers[\n controllerRequests[index].controllerId\n ].delegatecall(controllerRequests[index].data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**************************************\n * ADMIN FUNCTIONS *\n **************************************/\n\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(\n address routeAddress\n ) external onlyOwner returns (uint32) {\n uint32 routeId = routesCount;\n routes[routeId] = routeAddress;\n\n routesCount += 1;\n\n emit NewRouteAdded(routeId, routeAddress);\n\n return routeId;\n }\n\n /**\n * @notice Give Infinite or 0 approval to bridgeRoute for the tokenAddress\n This is a restricted function to be called by only socketGatewayOwner\n */\n\n function setApprovalForRouters(\n address[] memory routeAddresses,\n address[] memory tokenAddresses,\n bool isMax\n ) external onlyOwner {\n for (uint32 index = 0; index < routeAddresses.length; ) {\n ERC20(tokenAddresses[index]).approve(\n routeAddresses[index],\n isMax ? type(uint256).max : 0\n );\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address controllerAddress\n ) external onlyOwner returns (uint32) {\n uint32 controllerId = controllerCount;\n\n controllers[controllerId] = controllerAddress;\n\n controllerCount += 1;\n\n emit ControllerAdded(controllerId, controllerAddress);\n\n return controllerId;\n }\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 controllerId) public onlyOwner {\n controllers[controllerId] = disabledRouteAddress;\n emit ControllerDisabled(controllerId);\n }\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external onlyOwner {\n routes[routeId] = disabledRouteAddress;\n emit RouteDisabled(routeId);\n }\n\n /*******************************************\n * RESTRICTED RESCUE FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n\n /*******************************************\n * VIEW FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) public view returns (address) {\n return addressAt(routeId);\n }\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 controllerId) public view returns (address) {\n return controllers[controllerId];\n }\n\n function addressAt(uint32 routeId) public view returns (address) {\n if (routeId < 385) {\n if (routeId < 257) {\n if (routeId < 129) {\n if (routeId < 65) {\n if (routeId < 33) {\n if (routeId < 17) {\n if (routeId < 9) {\n if (routeId < 5) {\n if (routeId < 3) {\n if (routeId == 1) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 3) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 7) {\n if (routeId == 5) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 7) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 13) {\n if (routeId < 11) {\n if (routeId == 9) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 11) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 15) {\n if (routeId == 13) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 15) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 25) {\n if (routeId < 21) {\n if (routeId < 19) {\n if (routeId == 17) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 19) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 23) {\n if (routeId == 21) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 23) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 29) {\n if (routeId < 27) {\n if (routeId == 25) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 27) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 31) {\n if (routeId == 29) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 31) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 49) {\n if (routeId < 41) {\n if (routeId < 37) {\n if (routeId < 35) {\n if (routeId == 33) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 35) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 39) {\n if (routeId == 37) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 39) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 45) {\n if (routeId < 43) {\n if (routeId == 41) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 43) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 47) {\n if (routeId == 45) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 47) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 57) {\n if (routeId < 53) {\n if (routeId < 51) {\n if (routeId == 49) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 51) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 55) {\n if (routeId == 53) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 55) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 61) {\n if (routeId < 59) {\n if (routeId == 57) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 59) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 63) {\n if (routeId == 61) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 63) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 97) {\n if (routeId < 81) {\n if (routeId < 73) {\n if (routeId < 69) {\n if (routeId < 67) {\n if (routeId == 65) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 67) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 71) {\n if (routeId == 69) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 71) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 77) {\n if (routeId < 75) {\n if (routeId == 73) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 75) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 79) {\n if (routeId == 77) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 79) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 89) {\n if (routeId < 85) {\n if (routeId < 83) {\n if (routeId == 81) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 83) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 87) {\n if (routeId == 85) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 87) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 93) {\n if (routeId < 91) {\n if (routeId == 89) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 91) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 95) {\n if (routeId == 93) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 95) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 113) {\n if (routeId < 105) {\n if (routeId < 101) {\n if (routeId < 99) {\n if (routeId == 97) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 99) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 103) {\n if (routeId == 101) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 103) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 109) {\n if (routeId < 107) {\n if (routeId == 105) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 107) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 111) {\n if (routeId == 109) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 111) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 121) {\n if (routeId < 117) {\n if (routeId < 115) {\n if (routeId == 113) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 115) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 119) {\n if (routeId == 117) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 119) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 125) {\n if (routeId < 123) {\n if (routeId == 121) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 123) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 127) {\n if (routeId == 125) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 127) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 193) {\n if (routeId < 161) {\n if (routeId < 145) {\n if (routeId < 137) {\n if (routeId < 133) {\n if (routeId < 131) {\n if (routeId == 129) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 131) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 135) {\n if (routeId == 133) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 135) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 141) {\n if (routeId < 139) {\n if (routeId == 137) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 139) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 143) {\n if (routeId == 141) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 143) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 153) {\n if (routeId < 149) {\n if (routeId < 147) {\n if (routeId == 145) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 147) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 151) {\n if (routeId == 149) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 151) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 157) {\n if (routeId < 155) {\n if (routeId == 153) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 155) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 159) {\n if (routeId == 157) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 159) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 177) {\n if (routeId < 169) {\n if (routeId < 165) {\n if (routeId < 163) {\n if (routeId == 161) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 163) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 167) {\n if (routeId == 165) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 167) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 173) {\n if (routeId < 171) {\n if (routeId == 169) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 171) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 175) {\n if (routeId == 173) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 175) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 185) {\n if (routeId < 181) {\n if (routeId < 179) {\n if (routeId == 177) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 179) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 183) {\n if (routeId == 181) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 183) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 189) {\n if (routeId < 187) {\n if (routeId == 185) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 187) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 191) {\n if (routeId == 189) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 191) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 225) {\n if (routeId < 209) {\n if (routeId < 201) {\n if (routeId < 197) {\n if (routeId < 195) {\n if (routeId == 193) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 195) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 199) {\n if (routeId == 197) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 199) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 205) {\n if (routeId < 203) {\n if (routeId == 201) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 203) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 207) {\n if (routeId == 205) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 207) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 217) {\n if (routeId < 213) {\n if (routeId < 211) {\n if (routeId == 209) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 211) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 215) {\n if (routeId == 213) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 215) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 221) {\n if (routeId < 219) {\n if (routeId == 217) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 219) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 223) {\n if (routeId == 221) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 223) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 241) {\n if (routeId < 233) {\n if (routeId < 229) {\n if (routeId < 227) {\n if (routeId == 225) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 227) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 231) {\n if (routeId == 229) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 231) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 237) {\n if (routeId < 235) {\n if (routeId == 233) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 235) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 239) {\n if (routeId == 237) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 239) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 249) {\n if (routeId < 245) {\n if (routeId < 243) {\n if (routeId == 241) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 243) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 247) {\n if (routeId == 245) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 247) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 253) {\n if (routeId < 251) {\n if (routeId == 249) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 251) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 255) {\n if (routeId == 253) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 255) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 321) {\n if (routeId < 289) {\n if (routeId < 273) {\n if (routeId < 265) {\n if (routeId < 261) {\n if (routeId < 259) {\n if (routeId == 257) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 259) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 263) {\n if (routeId == 261) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 263) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 269) {\n if (routeId < 267) {\n if (routeId == 265) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 267) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 271) {\n if (routeId == 269) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 271) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 281) {\n if (routeId < 277) {\n if (routeId < 275) {\n if (routeId == 273) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 275) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 279) {\n if (routeId == 277) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 279) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 285) {\n if (routeId < 283) {\n if (routeId == 281) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 283) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 287) {\n if (routeId == 285) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 287) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 305) {\n if (routeId < 297) {\n if (routeId < 293) {\n if (routeId < 291) {\n if (routeId == 289) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 291) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 295) {\n if (routeId == 293) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 295) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 301) {\n if (routeId < 299) {\n if (routeId == 297) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 299) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 303) {\n if (routeId == 301) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 303) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 313) {\n if (routeId < 309) {\n if (routeId < 307) {\n if (routeId == 305) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 307) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 311) {\n if (routeId == 309) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 311) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 317) {\n if (routeId < 315) {\n if (routeId == 313) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 315) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 319) {\n if (routeId == 317) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 319) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 353) {\n if (routeId < 337) {\n if (routeId < 329) {\n if (routeId < 325) {\n if (routeId < 323) {\n if (routeId == 321) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 323) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 327) {\n if (routeId == 325) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 327) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 333) {\n if (routeId < 331) {\n if (routeId == 329) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 331) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 335) {\n if (routeId == 333) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 335) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 345) {\n if (routeId < 341) {\n if (routeId < 339) {\n if (routeId == 337) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 339) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 343) {\n if (routeId == 341) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 343) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 349) {\n if (routeId < 347) {\n if (routeId == 345) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 347) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 351) {\n if (routeId == 349) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 351) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 369) {\n if (routeId < 361) {\n if (routeId < 357) {\n if (routeId < 355) {\n if (routeId == 353) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 355) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 359) {\n if (routeId == 357) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 359) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 365) {\n if (routeId < 363) {\n if (routeId == 361) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 363) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 367) {\n if (routeId == 365) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 367) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 377) {\n if (routeId < 373) {\n if (routeId < 371) {\n if (routeId == 369) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 371) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 375) {\n if (routeId == 373) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 375) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 381) {\n if (routeId < 379) {\n if (routeId == 377) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 379) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 383) {\n if (routeId == 381) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 383) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n if (routes[routeId] == address(0)) revert ZeroAddressNotAllowed();\n return routes[routeId];\n }\n\n /// @notice fallback function to handle swap, bridge execution\n /// @dev ensure routeId is converted to bytes4 and sent as msg.sig in the transaction\n fallback() external payable {\n address routeAddress = addressAt(uint32(msg.sig));\n\n bytes memory result;\n\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 4, sub(calldatasize(), 4))\n // execute function call using the facet\n result := delegatecall(\n gas(),\n routeAddress,\n 0,\n sub(calldatasize(), 4),\n 0,\n 0\n )\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" + }, + "src/swap/rainbow/Rainbow.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {Address0Provided, SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {RAINBOW} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Rainbow-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via Rainbow-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of RainbowImplementation\n * @author Socket dot tech.\n */\ncontract RainbowSwapImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable RainbowIdentifier = RAINBOW;\n\n /// @notice unique name to identify the router, used to emit event upon successful bridging\n bytes32 public immutable NAME = keccak256(\"Rainbow-Router\");\n\n /// @notice address of rainbow-swap-aggregator to swap the tokens on Chain\n address payable public immutable rainbowSwapAggregator;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @notice rainbow swap aggregator contract is payable to allow ethereum swaps\n /// @dev ensure _rainbowSwapAggregator are set properly for the chainId in which the contract is being deployed\n constructor(\n address _rainbowSwapAggregator,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n rainbowSwapAggregator = payable(_rainbowSwapAggregator);\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * @notice This method is payable because the caller is doing token transfer and swap operation\n * @param fromToken address of token being Swapped\n * @param toToken address of token that recipient will receive after swap\n * @param amount amount of fromToken being swapped\n * @param receiverAddress recipient-address\n * @param swapExtraData additional Data to perform Swap via Rainbow-Aggregator\n * @return swapped amount (in toToken Address)\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 toTokenERC20 = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(rainbowSwapAggregator, amount);\n\n // solhint-disable-next-line\n (bool success, ) = rainbowSwapAggregator.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(rainbowSwapAggregator, 0);\n } else {\n (bool success, ) = rainbowSwapAggregator.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n if (toToken == NATIVE_TOKEN_ADDRESS) {\n payable(receiverAddress).transfer(returnAmount);\n } else {\n toTokenERC20.transfer(receiverAddress, returnAmount);\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n RainbowIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 toTokenERC20 = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(rainbowSwapAggregator, amount);\n\n // solhint-disable-next-line\n (bool success, ) = rainbowSwapAggregator.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(rainbowSwapAggregator, 0);\n } else {\n (bool success, ) = rainbowSwapAggregator.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n RainbowIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n" + }, + "src/interfaces/ISocketBridgeBase.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface ISocketBridgeBase {\n function killme() external;\n}\n" + }, + "src/interfaces/ISocketRequest.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketRoute\n * @notice Interface with Request DataStructures to invoke controller functions.\n * @author Socket dot tech.\n */\ninterface ISocketRequest {\n struct SwapMultiBridgeRequest {\n uint32 swapRouteId;\n bytes swapImplData;\n uint32[] bridgeRouteIds;\n bytes[] bridgeImplDataItems;\n uint256[] bridgeRatios;\n bytes[] eventDataItems;\n }\n\n // Datastructure for Refuel-Swap-Bridge function\n struct RefuelSwapBridgeRequest {\n uint32 refuelRouteId;\n bytes refuelData;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n\n // Datastructure for DeductFees-Swap function\n struct FeesTakerSwapRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 routeId;\n bytes swapRequestData;\n }\n\n // Datastructure for DeductFees-Bridge function\n struct FeesTakerBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 routeId;\n bytes bridgeRequestData;\n }\n\n // Datastructure for DeductFees-MultiBridge function\n struct FeesTakerMultiBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32[] bridgeRouteIds;\n bytes[] bridgeRequestDataItems;\n }\n\n // Datastructure for DeductFees-Swap-Bridge function\n struct FeesTakerSwapBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n\n // Datastructure for DeductFees-Refuel-Swap-Bridge function\n struct FeesTakerRefuelSwapBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 refuelRouteId;\n bytes refuelData;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n}\n" + }, + "src/utils/Ownable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.4;\n\nimport {OnlyOwner, OnlyNominee} from \"../errors/SocketErrors.sol\";\n\nabstract contract Ownable {\n address private _owner;\n address private _nominee;\n\n event OwnerNominated(address indexed nominee);\n event OwnerClaimed(address indexed claimer);\n\n constructor(address owner_) {\n _claimOwner(owner_);\n }\n\n modifier onlyOwner() {\n if (msg.sender != _owner) {\n revert OnlyOwner();\n }\n _;\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n function nominee() public view returns (address) {\n return _nominee;\n }\n\n function nominateOwner(address nominee_) external {\n if (msg.sender != _owner) {\n revert OnlyOwner();\n }\n _nominee = nominee_;\n emit OwnerNominated(_nominee);\n }\n\n function claimOwner() external {\n if (msg.sender != _nominee) {\n revert OnlyNominee();\n }\n _claimOwner(msg.sender);\n }\n\n function _claimOwner(address claimer_) internal {\n _owner = claimer_;\n _nominee = address(0);\n emit OwnerClaimed(claimer_);\n }\n}\n" + }, + "lib/solmate/src/tokens/ERC20.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n" + }, + "src/controllers/RefuelSwapAndBridgeController.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\nimport {BaseController} from \"./BaseController.sol\";\n\n/**\n * @title RefuelSwapAndBridge Controller Implementation\n * @notice Controller with composed actions for Refuel,Swap and Bridge to be executed Sequentially and this is atomic\n * @author Socket dot tech.\n */\ncontract RefuelSwapAndBridgeController is BaseController {\n /// @notice Function-selector to invoke refuel-swap-bridge function\n /// @dev This function selector is to be used while buidling transaction-data\n bytes4 public immutable REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"refuelAndSwapAndBridge((uint32,bytes,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BaseController\n constructor(\n address _socketGatewayAddress\n ) BaseController(_socketGatewayAddress) {}\n\n /**\n * @notice function to handle refuel followed by Swap and Bridge actions\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param rsbRequest Request with data to execute refuel followed by swap and bridge\n * @return output data from bridging operation\n */\n function refuelAndSwapAndBridge(\n ISocketRequest.RefuelSwapBridgeRequest calldata rsbRequest\n ) public payable returns (bytes memory) {\n _executeRoute(rsbRequest.refuelRouteId, rsbRequest.refuelData);\n\n // refuel is also a bridging activity via refuel-route-implementation\n bytes memory swapResponseData = _executeRoute(\n rsbRequest.swapRouteId,\n rsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n //sequence of arguments for implData: amount, token, data\n // Bridging the swapAmount received in the preceeding step\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n rsbRequest.bridgeData\n );\n\n return _executeRoute(rsbRequest.bridgeRouteId, bridgeImpldata);\n }\n}\n" + }, + "src/interfaces/ISocketGateway.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketGateway\n * @notice Interface for SocketGateway functions.\n * @dev functions can be added here for invocation from external contracts or off-chain\n * @author Socket dot tech.\n */\ninterface ISocketGateway {\n /**\n * @notice Request-struct for controllerRequests\n * @dev ensure the value for data is generated using the function-selectors defined in the controllerImplementation contracts\n */\n struct SocketControllerRequest {\n // controllerId is the id mapped to the controllerAddress\n uint32 controllerId;\n // transactionImplData generated off-chain or by caller using function-selector of the controllerContract\n bytes data;\n }\n\n // @notice view to get owner-address\n function owner() external view returns (address);\n}\n" + }, + "src/libraries/Pb.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.4;\n\n// runtime proto sol library\nlibrary Pb {\n enum WireType {\n Varint,\n Fixed64,\n LengthDelim,\n StartGroup,\n EndGroup,\n Fixed32\n }\n\n struct Buffer {\n uint256 idx; // the start index of next read. when idx=b.length, we're done\n bytes b; // hold serialized proto msg, readonly\n }\n\n // create a new in-memory Buffer object from raw msg bytes\n function fromBytes(\n bytes memory raw\n ) internal pure returns (Buffer memory buf) {\n buf.b = raw;\n buf.idx = 0;\n }\n\n // whether there are unread bytes\n function hasMore(Buffer memory buf) internal pure returns (bool) {\n return buf.idx < buf.b.length;\n }\n\n // decode current field number and wiretype\n function decKey(\n Buffer memory buf\n ) internal pure returns (uint256 tag, WireType wiretype) {\n uint256 v = decVarint(buf);\n tag = v / 8;\n wiretype = WireType(v & 7);\n }\n\n // read varint from current buf idx, move buf.idx to next read, return the int value\n function decVarint(Buffer memory buf) internal pure returns (uint256 v) {\n bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)\n bytes memory bb = buf.b; // get buf.b mem addr to use in assembly\n v = buf.idx; // use v to save one additional uint variable\n assembly {\n tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp\n }\n uint256 b; // store current byte content\n v = 0; // reset to 0 for return value\n for (uint256 i = 0; i < 10; i++) {\n assembly {\n b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra\n }\n v |= (b & 0x7F) << (i * 7);\n if (b & 0x80 == 0) {\n buf.idx += i + 1;\n return v;\n }\n }\n revert(); // i=10, invalid varint stream\n }\n\n // read length delimited field and return bytes\n function decBytes(\n Buffer memory buf\n ) internal pure returns (bytes memory b) {\n uint256 len = decVarint(buf);\n uint256 end = buf.idx + len;\n require(end <= buf.b.length); // avoid overflow\n b = new bytes(len);\n bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly\n uint256 bStart;\n uint256 bufBStart = buf.idx;\n assembly {\n bStart := add(b, 32)\n bufBStart := add(add(bufB, 32), bufBStart)\n }\n for (uint256 i = 0; i < len; i += 32) {\n assembly {\n mstore(add(bStart, i), mload(add(bufBStart, i)))\n }\n }\n buf.idx = end;\n }\n\n // move idx pass current value field, to beginning of next tag or msg end\n function skipValue(Buffer memory buf, WireType wire) internal pure {\n if (wire == WireType.Varint) {\n decVarint(buf);\n } else if (wire == WireType.LengthDelim) {\n uint256 len = decVarint(buf);\n buf.idx += len; // skip len bytes value data\n require(buf.idx <= buf.b.length); // avoid overflow\n } else {\n revert();\n } // unsupported wiretype\n }\n\n function _uint256(bytes memory b) internal pure returns (uint256 v) {\n require(b.length <= 32); // b's length must be smaller than or equal to 32\n assembly {\n v := mload(add(b, 32))\n } // load all 32bytes to v\n v = v >> (8 * (32 - b.length)); // only first b.length is valid\n }\n\n function _address(bytes memory b) internal pure returns (address v) {\n v = _addressPayable(b);\n }\n\n function _addressPayable(\n bytes memory b\n ) internal pure returns (address payable v) {\n require(b.length == 20);\n //load 32bytes then shift right 12 bytes\n assembly {\n v := div(mload(add(b, 32)), 0x1000000000000000000000000)\n }\n }\n\n function _bytes32(bytes memory b) internal pure returns (bytes32 v) {\n require(b.length == 32);\n assembly {\n v := mload(add(b, 32))\n }\n }\n}\n" + }, + "src/bridges/BridgeImplBase.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\nimport {OnlySocketGatewayOwner, OnlySocketDeployer} from \"../errors/SocketErrors.sol\";\n\n/**\n * @title Abstract Implementation Contract.\n * @notice All Bridge Implementation will follow this interface.\n */\nabstract contract BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketDeployFactory;\n\n /// @notice immutable variable with instance of SocketRoute to access route functions\n ISocketRoute public immutable socketRoute;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /****************************************\n * EVENTS *\n ****************************************/\n\n event SocketBridge(\n uint256 amount,\n address token,\n uint256 toChainId,\n bytes32 bridgeName,\n address sender,\n address receiver,\n bytes32 metadata\n );\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n * @param _socketDeployFactory Socket Deploy Factory address, an immutable variable to set.\n */\n constructor(address _socketGateway, address _socketDeployFactory) {\n socketGateway = _socketGateway;\n socketDeployFactory = _socketDeployFactory;\n socketRoute = ISocketRoute(_socketGateway);\n }\n\n /****************************************\n * MODIFIERS *\n ****************************************/\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketDeployFactory() {\n if (msg.sender != socketDeployFactory) {\n revert OnlySocketDeployer();\n }\n _;\n }\n\n /****************************************\n * RESTRICTED FUNCTIONS *\n ****************************************/\n\n /**\n * @notice function to rescue the ERC20 tokens in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n function killme() external isSocketDeployFactory {\n selfdestruct(payable(msg.sender));\n }\n\n /******************************\n * VIRTUAL FUNCTIONS *\n *****************************/\n\n /**\n * @notice function to bridge which is succeeding the swap function\n * @notice this function is to be used only when bridging as a succeeding step\n * @notice All bridge implementation contracts must implement this function\n * @notice bridge-implementations will have a bridge specific struct with properties used in bridging\n * @param bridgeData encoded value of properties in the bridgeData Struct\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable virtual;\n}\n" + }, + "src/bridges/cbridge/CelerImpl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../../libraries/Pb.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"./interfaces/cbridge.sol\";\nimport \"./interfaces/ICelerStorageWrapper.sol\";\nimport {TransferIdExists, InvalidCelerRefund, CelerAlreadyRefunded, CelerRefundNotReady} from \"../../errors/SocketErrors.sol\";\nimport {BridgeImplBase} from \"../BridgeImplBase.sol\";\nimport {CBRIDGE} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Celer-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Celer-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of CelerImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract CelerImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable CBridgeIdentifier = CBRIDGE;\n\n /// @notice Utility to perform operation on Buffer\n using Pb for Pb.Buffer;\n\n /// @notice Function-selector for ERC20-token bridging on Celer-Route\n /// @dev This function selector is to be used while building transaction-data to bridge ERC20 tokens\n bytes4 public immutable CELER_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,uint256,bytes32,uint64,uint64,uint32)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Celer-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable CELER_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,uint256,bytes32,uint64,uint64,uint32)\"\n )\n );\n\n bytes4 public immutable CELER_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,uint64,uint32,uint64,bytes32))\"\n )\n );\n\n /// @notice router Contract instance used to deposit ERC20 and Native on to Celer-Bridge\n /// @dev contract instance is to be initialized in the constructor using the routerAddress passed as constructor argument\n ICBridge public immutable router;\n\n /// @notice celerStorageWrapper Contract instance used to store the transferId generated during ERC20 and Native bridge on to Celer-Bridge\n /// @dev contract instance is to be initialized in the constructor using the celerStorageWrapperAddress passed as constructor argument\n ICelerStorageWrapper public immutable celerStorageWrapper;\n\n /// @notice WETH token address\n address public immutable weth;\n\n /// @notice chainId used during generation of transferId generated while bridging ERC20 and Native on to Celer-Bridge\n /// @dev this is to be initialised in the constructor\n uint64 public immutable chainId;\n\n struct WithdrawMsg {\n uint64 chainid; // tag: 1\n uint64 seqnum; // tag: 2\n address receiver; // tag: 3\n address token; // tag: 4\n uint256 amount; // tag: 5\n bytes32 refid; // tag: 6\n }\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure routerAddress, weth-address, celerStorageWrapperAddress are set properly for the chainId in which the contract is being deployed\n constructor(\n address _routerAddress,\n address _weth,\n address _celerStorageWrapperAddress,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = ICBridge(_routerAddress);\n celerStorageWrapper = ICelerStorageWrapper(_celerStorageWrapperAddress);\n weth = _weth;\n chainId = uint64(block.chainid);\n }\n\n // Function to receive Ether. msg.data must be empty\n receive() external payable {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct CelerBridgeDataNoToken {\n address receiverAddress;\n uint64 toChainId;\n uint32 maxSlippage;\n uint64 nonce;\n bytes32 metadata;\n }\n\n struct CelerBridgeData {\n address token;\n address receiverAddress;\n uint64 toChainId;\n uint32 maxSlippage;\n uint64 nonce;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for CelerBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n CelerBridgeData memory celerBridgeData = abi.decode(\n bridgeData,\n (CelerBridgeData)\n );\n\n if (celerBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n weth,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: amount}(\n celerBridgeData.receiverAddress,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n } else {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n celerBridgeData.token,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n router.send(\n celerBridgeData.receiverAddress,\n celerBridgeData.token,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n }\n\n emit SocketBridge(\n amount,\n celerBridgeData.token,\n celerBridgeData.toChainId,\n CBridgeIdentifier,\n msg.sender,\n celerBridgeData.receiverAddress,\n celerBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param celerBridgeData encoded data for CelerBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n CelerBridgeDataNoToken calldata celerBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n weth,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: bridgeAmount}(\n celerBridgeData.receiverAddress,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n } else {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n token,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n router.send(\n celerBridgeData.receiverAddress,\n token,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n celerBridgeData.toChainId,\n CBridgeIdentifier,\n msg.sender,\n celerBridgeData.receiverAddress,\n celerBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Celer-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of recipient\n * @param token address of token being bridged\n * @param amount amount of token for bridging\n * @param toChainId destination ChainId\n * @param nonce nonce of the sender-account address\n * @param maxSlippage maximum Slippage for the bridging\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n uint256 amount,\n bytes32 metadata,\n uint64 toChainId,\n uint64 nonce,\n uint32 maxSlippage\n ) external payable {\n /// @notice transferId is generated using the request-params and nonce of the account\n /// @notice transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n receiverAddress,\n token,\n amount,\n toChainId,\n nonce,\n chainId\n )\n );\n\n /// @notice stored in the CelerStorageWrapper contract\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n router.send(\n receiverAddress,\n token,\n amount,\n toChainId,\n nonce,\n maxSlippage\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n CBridgeIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Celer-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of recipient\n * @param amount amount of token for bridging\n * @param toChainId destination ChainId\n * @param nonce nonce of the sender-account address\n * @param maxSlippage maximum Slippage for the bridging\n */\n function bridgeNativeTo(\n address receiverAddress,\n uint256 amount,\n bytes32 metadata,\n uint64 toChainId,\n uint64 nonce,\n uint32 maxSlippage\n ) external payable {\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n receiverAddress,\n weth,\n amount,\n toChainId,\n nonce,\n chainId\n )\n );\n\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: amount}(\n receiverAddress,\n amount,\n toChainId,\n nonce,\n maxSlippage\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n CBridgeIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle refund from CelerBridge-Router\n * @param _request request data generated offchain using the celer-SDK\n * @param _sigs generated offchain using the celer-SDK\n * @param _signers generated offchain using the celer-SDK\n * @param _powers generated offchain using the celer-SDK\n */\n function refundCelerUser(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable {\n WithdrawMsg memory request = decWithdrawMsg(_request);\n bytes32 transferId = keccak256(\n abi.encodePacked(\n request.chainid,\n request.seqnum,\n request.receiver,\n request.token,\n request.amount\n )\n );\n uint256 _initialNativeBalance = address(this).balance;\n uint256 _initialTokenBalance = ERC20(request.token).balanceOf(\n address(this)\n );\n if (!router.withdraws(transferId)) {\n router.withdraw(_request, _sigs, _signers, _powers);\n }\n\n if (request.receiver != socketGateway) {\n revert InvalidCelerRefund();\n }\n\n address _receiver = celerStorageWrapper.getAddressFromTransferId(\n request.refid\n );\n celerStorageWrapper.deleteTransferId(request.refid);\n\n if (_receiver == address(0)) {\n revert CelerAlreadyRefunded();\n }\n\n uint256 _nativeBalanceAfter = address(this).balance;\n uint256 _tokenBalanceAfter = ERC20(request.token).balanceOf(\n address(this)\n );\n if (_nativeBalanceAfter > _initialNativeBalance) {\n if ((_nativeBalanceAfter - _initialNativeBalance) != request.amount)\n revert CelerRefundNotReady();\n payable(_receiver).transfer(request.amount);\n return;\n }\n\n if (_tokenBalanceAfter > _initialTokenBalance) {\n if ((_tokenBalanceAfter - _initialTokenBalance) != request.amount)\n revert CelerRefundNotReady();\n ERC20(request.token).safeTransfer(_receiver, request.amount);\n return;\n }\n\n revert CelerRefundNotReady();\n }\n\n function decWithdrawMsg(\n bytes memory raw\n ) internal pure returns (WithdrawMsg memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.chainid = uint64(buf.decVarint());\n } else if (tag == 2) {\n m.seqnum = uint64(buf.decVarint());\n } else if (tag == 3) {\n m.receiver = Pb._address(buf.decBytes());\n } else if (tag == 4) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 5) {\n m.amount = Pb._uint256(buf.decBytes());\n } else if (tag == 6) {\n m.refid = Pb._bytes32(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder WithdrawMsg\n}\n" + }, + "src/libraries/LibBytes.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n// Functions taken out from https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol\nlibrary LibBytes {\n // solhint-disable no-inline-assembly\n\n // LibBytes specific errors\n error SliceOverflow();\n error SliceOutOfBounds();\n error AddressOutOfBounds();\n error UintOutOfBounds();\n\n // -------------------------\n\n function concat(\n bytes memory _preBytes,\n bytes memory _postBytes\n ) internal pure returns (bytes memory) {\n bytes memory tempBytes;\n\n assembly {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // Store the length of the first bytes array at the beginning of\n // the memory for tempBytes.\n let length := mload(_preBytes)\n mstore(tempBytes, length)\n\n // Maintain a memory counter for the current write location in the\n // temp bytes array by adding the 32 bytes for the array length to\n // the starting location.\n let mc := add(tempBytes, 0x20)\n // Stop copying when the memory counter reaches the length of the\n // first bytes array.\n let end := add(mc, length)\n\n for {\n // Initialize a copy counter to the start of the _preBytes data,\n // 32 bytes into its memory.\n let cc := add(_preBytes, 0x20)\n } lt(mc, end) {\n // Increase both counters by 32 bytes each iteration.\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // Write the _preBytes data into the tempBytes memory 32 bytes\n // at a time.\n mstore(mc, mload(cc))\n }\n\n // Add the length of _postBytes to the current length of tempBytes\n // and store it as the new length in the first 32 bytes of the\n // tempBytes memory.\n length := mload(_postBytes)\n mstore(tempBytes, add(length, mload(tempBytes)))\n\n // Move the memory counter back from a multiple of 0x20 to the\n // actual end of the _preBytes data.\n mc := end\n // Stop copying when the memory counter reaches the new combined\n // length of the arrays.\n end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n // Update the free-memory pointer by padding our last write location\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\n // next 32 byte block, then round down to the nearest multiple of\n // 32. If the sum of the length of the two arrays is zero then add\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\n mstore(\n 0x40,\n and(\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\n not(31) // Round down to the nearest 32 bytes.\n )\n )\n }\n\n return tempBytes;\n }\n\n function slice(\n bytes memory _bytes,\n uint256 _start,\n uint256 _length\n ) internal pure returns (bytes memory) {\n if (_length + 31 < _length) {\n revert SliceOverflow();\n }\n if (_bytes.length < _start + _length) {\n revert SliceOutOfBounds();\n }\n\n bytes memory tempBytes;\n\n assembly {\n switch iszero(_length)\n case 0 {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // The first word of the slice result is potentially a partial\n // word read from the original array. To read it, we calculate\n // the length of that partial word and start copying that many\n // bytes into the array. The first word we copy will start with\n // data we don't care about, but the last `lengthmod` bytes will\n // land at the beginning of the contents of the new array. When\n // we're done copying, we overwrite the full first word with\n // the actual length of the slice.\n let lengthmod := and(_length, 31)\n\n // The multiplication in the next line is necessary\n // because when slicing multiples of 32 bytes (lengthmod == 0)\n // the following copy loop was copying the origin's length\n // and then ending prematurely not copying everything it should.\n let mc := add(\n add(tempBytes, lengthmod),\n mul(0x20, iszero(lengthmod))\n )\n let end := add(mc, _length)\n\n for {\n // The multiplication in the next line has the same exact purpose\n // as the one above.\n let cc := add(\n add(\n add(_bytes, lengthmod),\n mul(0x20, iszero(lengthmod))\n ),\n _start\n )\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n mstore(tempBytes, _length)\n\n //update free-memory pointer\n //allocating the array padded to 32 bytes like the compiler does now\n mstore(0x40, and(add(mc, 31), not(31)))\n }\n //if we want a zero-length slice let's just return a zero-length array\n default {\n tempBytes := mload(0x40)\n //zero out the 32 bytes slice we are about to return\n //we need to do it because Solidity does not garbage collect\n mstore(tempBytes, 0)\n\n mstore(0x40, add(tempBytes, 0x20))\n }\n }\n\n return tempBytes;\n }\n}\n" + }, + "src/bridges/hyphen/interfaces/hyphen.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * @title HyphenLiquidityPoolManager\n * @notice interface with functions to bridge ERC20 and Native via Hyphen-Bridge\n * @author Socket dot tech.\n */\ninterface HyphenLiquidityPoolManager {\n /**\n * @dev Function used to deposit tokens into pool to initiate a cross chain token transfer.\n * @param toChainId Chain id where funds needs to be transfered\n * @param tokenAddress ERC20 Token address that needs to be transfered\n * @param receiver Address on toChainId where tokens needs to be transfered\n * @param amount Amount of token being transfered\n */\n function depositErc20(\n uint256 toChainId,\n address tokenAddress,\n address receiver,\n uint256 amount,\n string calldata tag\n ) external;\n\n /**\n * @dev Function used to deposit native token into pool to initiate a cross chain token transfer.\n * @param receiver Address on toChainId where tokens needs to be transfered\n * @param toChainId Chain id where funds needs to be transfered\n */\n function depositNative(\n address receiver,\n uint256 toChainId,\n string calldata tag\n ) external payable;\n}\n" + }, + "src/swap/SwapImplBase.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {OnlySocketGatewayOwner, OnlySocketDeployer} from \"../errors/SocketErrors.sol\";\n\n/**\n * @title Abstract Implementation Contract.\n * @notice All Swap Implementation will follow this interface.\n * @author Socket dot tech.\n */\nabstract contract SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketDeployFactory;\n\n /// @notice FunctionSelector used to delegatecall to the performAction function of swap-router-implementation\n bytes4 public immutable SWAP_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"performAction(address,address,uint256,address,bytes)\")\n );\n\n /// @notice FunctionSelector used to delegatecall to the performActionWithIn function of swap-router-implementation\n bytes4 public immutable SWAP_WITHIN_FUNCTION_SELECTOR =\n bytes4(keccak256(\"performActionWithIn(address,address,uint256,bytes)\"));\n\n /****************************************\n * EVENTS *\n ****************************************/\n\n event SocketSwapTokens(\n address fromToken,\n address toToken,\n uint256 buyAmount,\n uint256 sellAmount,\n bytes32 routeName,\n address receiver\n );\n\n /**\n * @notice Construct the base for all SwapImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n */\n constructor(address _socketGateway, address _socketDeployFactory) {\n socketGateway = _socketGateway;\n socketDeployFactory = _socketDeployFactory;\n }\n\n /****************************************\n * MODIFIERS *\n ****************************************/\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketDeployFactory() {\n if (msg.sender != socketDeployFactory) {\n revert OnlySocketDeployer();\n }\n _;\n }\n\n /****************************************\n * RESTRICTED FUNCTIONS *\n ****************************************/\n\n /**\n * @notice function to rescue the ERC20 tokens in the Swap-Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the Swap-Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n function killme() external isSocketDeployFactory {\n selfdestruct(payable(msg.sender));\n }\n\n /******************************\n * VIRTUAL FUNCTIONS *\n *****************************/\n\n /**\n * @notice function to swap tokens on the chain\n * All swap implementation contracts must implement this function\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param receiverAddress recipient address of toToken\n * @param data encoded value of properties in the swapData Struct\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes memory data\n ) external payable virtual returns (uint256);\n\n /**\n * @notice function to swapWith - swaps tokens on the chain to socketGateway as recipient\n * All swap implementation contracts must implement this function\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes memory swapExtraData\n ) external payable virtual returns (uint256, address);\n}\n" + }, + "src/swap/zerox/ZeroXSwapImpl.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {Address0Provided, SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {ZEROX} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title ZeroX-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via ZeroX-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of ZeroX-Swap-Implementation\n * @author Socket dot tech.\n */\ncontract ZeroXSwapImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable ZeroXIdentifier = ZEROX;\n\n /// @notice unique name to identify the router, used to emit event upon successful bridging\n bytes32 public immutable NAME = keccak256(\"Zerox-Router\");\n\n /// @notice address of ZeroX-Exchange-Proxy to swap the tokens on Chain\n address payable public immutable zeroXExchangeProxy;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @notice ZeroXExchangeProxy contract is payable to allow ethereum swaps\n /// @dev ensure _zeroXExchangeProxy are set properly for the chainId in which the contract is being deployed\n constructor(\n address _zeroXExchangeProxy,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n zeroXExchangeProxy = payable(_zeroXExchangeProxy);\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * @dev This is called only when there is a request for a swap.\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken is to be swapped\n * @param amount amount to be swapped\n * @param receiverAddress address of toToken recipient\n * @param swapExtraData data required for zeroX Exchange to get the swap done\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 erc20ToToken = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, address(this), amount);\n token.safeApprove(zeroXExchangeProxy, amount);\n\n // solhint-disable-next-line\n (bool success, ) = zeroXExchangeProxy.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(zeroXExchangeProxy, 0);\n } else {\n (bool success, ) = zeroXExchangeProxy.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n if (toToken == NATIVE_TOKEN_ADDRESS) {\n payable(receiverAddress).transfer(returnAmount);\n } else {\n erc20ToToken.transfer(receiverAddress, returnAmount);\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n ZeroXIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 erc20ToToken = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, address(this), amount);\n token.safeApprove(zeroXExchangeProxy, amount);\n\n // solhint-disable-next-line\n (bool success, ) = zeroXExchangeProxy.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(zeroXExchangeProxy, 0);\n } else {\n (bool success, ) = zeroXExchangeProxy.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n ZeroXIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n" + }, + "src/bridges/cbridge/interfaces/cbridge.sol": { + "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\ninterface ICBridge {\n function send(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChinId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external;\n\n function sendNative(\n address _receiver,\n uint256 _amount,\n uint64 _dstChinId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external payable;\n\n function withdraws(bytes32 withdrawId) external view returns (bool);\n\n function withdraw(\n bytes calldata _wdmsg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n}\n" + }, + "src/bridges/stargate/l2/Stargate.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/stargate.sol\";\nimport \"../../../errors/SocketErrors.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {STARGATE} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Stargate-L2-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Stargate-L2-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of Stargate-L2-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract StargateImplL2 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable StargateIdentifier = STARGATE;\n\n /// @notice Function-selector for ERC20-token bridging on Stargate-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable STARGATE_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,uint256,(uint256,uint256,uint256,uint256,bytes32,bytes,uint16))\"\n )\n );\n\n bytes4 public immutable STARGATE_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint16,uint256,uint256,uint256,uint256,uint256,uint256,bytes32,bytes))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Stargate-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable STARGATE_L2_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint16,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n /// @notice Stargate Router to bridge ERC20 tokens\n IBridgeStargate public immutable router;\n\n /// @notice Stargate Router to bridge native tokens\n IBridgeStargate public immutable routerETH;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router, routerEth are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _routerEth,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = IBridgeStargate(_router);\n routerETH = IBridgeStargate(_routerEth);\n }\n\n /// @notice Struct to be used as a input parameter for Bridging tokens via Stargate-L2-route\n /// @dev while building transactionData,values should be set in this sequence of properties in this struct\n struct StargateBridgeExtraData {\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 destinationGasLimit;\n uint256 minReceivedAmt;\n bytes32 metadata;\n bytes destinationPayload;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct StargateBridgeDataNoToken {\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n struct StargateBridgeData {\n address token;\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Stargate-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n StargateBridgeData memory stargateBridgeData = abi.decode(\n bridgeData,\n (StargateBridgeData)\n );\n\n if (stargateBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + stargateBridgeData.optionalValue}(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n amount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(stargateBridgeData.token).safeApprove(\n address(router),\n amount\n );\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n amount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n stargateBridgeData.token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swapping.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param stargateBridgeData encoded data for StargateBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n StargateBridgeDataNoToken calldata stargateBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n routerETH.swapETH{\n value: bridgeAmount + stargateBridgeData.optionalValue\n }(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n bridgeAmount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(token).safeApprove(address(router), bridgeAmount);\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n bridgeAmount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0,\n \"0x\"\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param senderAddress address of sender\n * @param receiverAddress address of recipient\n * @param amount amount of token being bridge\n * @param value value\n * @param optionalValue optionalValue\n * @param stargateBridgeExtraData stargate bridge extradata\n */\n function bridgeERC20To(\n address token,\n address senderAddress,\n address receiverAddress,\n uint256 amount,\n uint256 value,\n uint256 optionalValue,\n StargateBridgeExtraData calldata stargateBridgeExtraData\n ) external payable {\n // token address might not be indication thats why passed through extraData\n if (token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateBridgeExtraData.stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n stargateBridgeExtraData.minReceivedAmt\n );\n } else {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n {\n router.swap{value: value}(\n stargateBridgeExtraData.stargateDstChainId,\n stargateBridgeExtraData.srcPoolId,\n stargateBridgeExtraData.dstPoolId,\n payable(senderAddress), // default to refund to main contract\n amount,\n stargateBridgeExtraData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeExtraData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(receiverAddress),\n stargateBridgeExtraData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n token,\n stargateBridgeExtraData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n stargateBridgeExtraData.metadata\n );\n }\n\n function bridgeNativeTo(\n address receiverAddress,\n address senderAddress,\n uint16 stargateDstChainId,\n uint256 amount,\n uint256 minReceivedAmt,\n uint256 optionalValue,\n bytes32 metadata\n ) external payable {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n minReceivedAmt\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + }, + "metadata": { + "useLiteralContent": true + }, + "libraries": {} + } + }, + "ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_disabledRoute\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ArrayLengthMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectBridgeRatios\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyNominee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddressNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"controllerAddress\",\"type\":\"address\"}],\"name\":\"ControllerAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"ControllerDisabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"route\",\"type\":\"address\"}],\"name\":\"NewRouteAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"claimer\",\"type\":\"address\"}],\"name\":\"OwnerClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nominee\",\"type\":\"address\"}],\"name\":\"OwnerNominated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"RouteDisabled\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"BRIDGE_AFTER_SWAP_SELECTOR\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"CENT_PERCENT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"controllerAddress\",\"type\":\"address\"}],\"name\":\"addController\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"routeAddress\",\"type\":\"address\"}],\"name\":\"addRoute\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"addressAt\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controllerCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"controllers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"disableController\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"disableRoute\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"disabledRouteAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct ISocketGateway.SocketControllerRequest\",\"name\":\"socketControllerRequest\",\"type\":\"tuple\"}],\"name\":\"executeController\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct ISocketGateway.SocketControllerRequest[]\",\"name\":\"controllerRequests\",\"type\":\"tuple[]\"}],\"name\":\"executeControllers\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"routeData\",\"type\":\"bytes\"}],\"name\":\"executeRoute\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32[]\",\"name\":\"routeIds\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes[]\",\"name\":\"dataItems\",\"type\":\"bytes[]\"}],\"name\":\"executeRoutes\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"getController\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"getRoute\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nominee_\",\"type\":\"address\"}],\"name\":\"nominateOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nominee\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"rescueEther\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"rescueFunds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"routes\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"routesCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"routeAddresses\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"tokenAddresses\",\"type\":\"address[]\"},{\"internalType\":\"bool\",\"name\":\"isMax\",\"type\":\"bool\"}],\"name\":\"setApprovalForRouters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"swapRouteId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"swapImplData\",\"type\":\"bytes\"},{\"internalType\":\"uint32[]\",\"name\":\"bridgeRouteIds\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes[]\",\"name\":\"bridgeImplDataItems\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256[]\",\"name\":\"bridgeRatios\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"eventDataItems\",\"type\":\"bytes[]\"}],\"internalType\":\"struct ISocketRequest.SwapMultiBridgeRequest\",\"name\":\"swapMultiBridgeRequest\",\"type\":\"tuple\"}],\"name\":\"swapAndMultiBridge\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + "ContractName": "SocketGateway", + "CompilerVersion": "v0.8.7+commit.e28d00a7", + "OptimizationUsed": 1, + "Runs": 1000000, + "ConstructorArguments": "0x000000000000000000000000e8dd38e673a93ccfc2e3d7053efccb5c93f493650000000000000000000000000f34a522ff82151c90679b73211955068fd854f1", + "EVMVersion": "Default", + "Library": "", + "LicenseType": "", + "Proxy": 1, + "Implementation": "0xa3c4e32af0da5efaddb20cc9fb26159f55c8c42f", + "SwarmSource": "" + } +] \ No newline at end of file diff --git a/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json new file mode 100644 index 0000000000000..b3976447f2486 --- /dev/null +++ b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0x71356e37e0368bd10bfdbf41dc052fe5fa24cd05", + "contractCreator": "0xaa1d342354d755ec515f40e7d5e83cb4184bb9ee", + "txHash": "0x1c800c2c2d5230823602cae6896a8db1ab7d1341ca697c6c64d9f0edf11dabe2" +} \ No newline at end of file diff --git a/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json new file mode 100644 index 0000000000000..cc890a5711229 --- /dev/null +++ b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json @@ -0,0 +1,129 @@ +[ + { + "SourceCode": { + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "contracts/v0.8/extensions/GatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"../interfaces/IQuorum.sol\";\nimport \"../interfaces/IWeightedValidator.sol\";\nimport \"./HasProxyAdmin.sol\";\n\nabstract contract GatewayV2 is HasProxyAdmin, Pausable, IQuorum {\n /// @dev Emitted when the validator contract address is updated.\n event ValidatorContractUpdated(IWeightedValidator);\n\n uint256 internal _num;\n uint256 internal _denom;\n\n IWeightedValidator public validatorContract;\n uint256 public nonce;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev See {IQuorum-getThreshold}.\n */\n function getThreshold() external view virtual returns (uint256, uint256) {\n return (_num, _denom);\n }\n\n /**\n * @dev See {IQuorum-checkThreshold}.\n */\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _denom >= _num * validatorContract.totalWeights();\n }\n\n /**\n * @dev See {IQuorum-setThreshold}.\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n onlyAdmin\n returns (uint256, uint256)\n {\n return _setThreshold(_numerator, _denominator);\n }\n\n /**\n * @dev Triggers paused state.\n */\n function pause() external onlyAdmin {\n _pause();\n }\n\n /**\n * @dev Triggers unpaused state.\n */\n function unpause() external onlyAdmin {\n _unpause();\n }\n\n /**\n * @dev Sets validator contract address.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ValidatorContractUpdated` event.\n *\n */\n function setValidatorContract(IWeightedValidator _validatorContract) external virtual onlyAdmin {\n _setValidatorContract(_validatorContract);\n }\n\n /**\n * @dev See {IQuorum-minimumVoteWeight}.\n */\n function minimumVoteWeight() public view virtual returns (uint256) {\n return _minimumVoteWeight(validatorContract.totalWeights());\n }\n\n /**\n * @dev Sets validator contract address.\n *\n * Emits the `ValidatorContractUpdated` event.\n *\n */\n function _setValidatorContract(IWeightedValidator _validatorContract) internal virtual {\n validatorContract = _validatorContract;\n emit ValidatorContractUpdated(_validatorContract);\n }\n\n /**\n * @dev Sets threshold and returns the old one.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function _setThreshold(uint256 _numerator, uint256 _denominator)\n internal\n virtual\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n require(_numerator <= _denominator, \"GatewayV2: invalid threshold\");\n _previousNum = _num;\n _previousDenom = _denom;\n _num = _numerator;\n _denom = _denominator;\n emit ThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n\n /**\n * @dev Returns minimum vote weight.\n */\n function _minimumVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_num * _totalWeight + _denom - 1) / _denom;\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n // contract may have been reentered.\n require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} modifier, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n function _isConstructor() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" + }, + "contracts/v0.8/extensions/WithdrawalLimitation.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./GatewayV2.sol\";\n\nabstract contract WithdrawalLimitation is GatewayV2 {\n /// @dev Emitted when the high-tier vote weight threshold is updated\n event HighTierVoteWeightThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n /// @dev Emitted when the thresholds for high-tier withdrawals that requires high-tier vote weights are updated\n event HighTierThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the thresholds for locked withdrawals are updated\n event LockedThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the fee percentages to unlock withdraw are updated\n event UnlockFeePercentagesUpdated(address[] tokens, uint256[] percentages);\n /// @dev Emitted when the daily limit thresholds are updated\n event DailyWithdrawalLimitsUpdated(address[] tokens, uint256[] limits);\n\n uint256 public constant _MAX_PERCENTAGE = 1_000_000;\n\n uint256 internal _highTierVWNum;\n uint256 internal _highTierVWDenom;\n\n /// @dev Mapping from mainchain token => the amount thresholds for high-tier withdrawals that requires high-tier vote weights\n mapping(address => uint256) public highTierThreshold;\n /// @dev Mapping from mainchain token => the amount thresholds to lock withdrawal\n mapping(address => uint256) public lockedThreshold;\n /// @dev Mapping from mainchain token => unlock fee percentages for unlocker\n /// @notice Values 0-1,000,000 map to 0%-100%\n mapping(address => uint256) public unlockFeePercentages;\n /// @dev Mapping from mainchain token => daily limit amount for withdrawal\n mapping(address => uint256) public dailyWithdrawalLimit;\n /// @dev Mapping from token address => today withdrawal amount\n mapping(address => uint256) public lastSyncedWithdrawal;\n /// @dev Mapping from token address => last date synced to record the `lastSyncedWithdrawal`\n mapping(address => uint256) public lastDateSynced;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev Override {GatewayV2-setThreshold}.\n *\n * Requirements:\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n override\n onlyAdmin\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n (_previousNum, _previousDenom) = _setThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Returns the high-tier vote weight threshold.\n */\n function getHighTierVoteWeightThreshold() external view virtual returns (uint256, uint256) {\n return (_highTierVWNum, _highTierVWDenom);\n }\n\n /**\n * @dev Checks whether the `_voteWeight` passes the high-tier vote weight threshold.\n */\n function checkHighTierVoteWeightThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _highTierVWDenom >= _highTierVWNum * validatorContract.totalWeights();\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Requirements:\n * - The method caller is admin.\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n onlyAdmin\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n (_previousNum, _previousDenom) = _setHighTierVoteWeightThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds)\n external\n virtual\n onlyAdmin\n {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setHighTierThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyAdmin {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setLockedThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages)\n external\n virtual\n onlyAdmin\n {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setUnlockFeePercentages(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) external virtual onlyAdmin {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setDailyWithdrawalLimits(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the limitation.\n */\n function reachedWithdrawalLimit(address _token, uint256 _quantity) external view virtual returns (bool) {\n return _reachedWithdrawalLimit(_token, _quantity);\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function _setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator)\n internal\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n require(_numerator <= _denominator, \"WithdrawalLimitation: invalid threshold\");\n _previousNum = _highTierVWNum;\n _previousDenom = _highTierVWDenom;\n _highTierVWNum = _numerator;\n _highTierVWDenom = _denominator;\n emit HighTierVoteWeightThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function _setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n require(_tokens.length == _thresholds.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n highTierThreshold[_tokens[_i]] = _thresholds[_i];\n }\n emit HighTierThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function _setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n require(_tokens.length == _thresholds.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n lockedThreshold[_tokens[_i]] = _thresholds[_i];\n }\n emit LockedThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n * - The percentage is equal to or less than 100_000.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function _setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) internal virtual {\n require(_tokens.length == _percentages.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n require(_percentages[_i] <= _MAX_PERCENTAGE, \"WithdrawalLimitation: invalid percentage\");\n unlockFeePercentages[_tokens[_i]] = _percentages[_i];\n }\n emit UnlockFeePercentagesUpdated(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function _setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) internal virtual {\n require(_tokens.length == _limits.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n dailyWithdrawalLimit[_tokens[_i]] = _limits[_i];\n }\n emit DailyWithdrawalLimitsUpdated(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the daily limitation.\n *\n * Requirements:\n * - The daily withdrawal threshold should not apply for locked withdrawals.\n *\n */\n function _reachedWithdrawalLimit(address _token, uint256 _quantity) internal view virtual returns (bool) {\n if (_lockedWithdrawalRequest(_token, _quantity)) {\n return false;\n }\n\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n return dailyWithdrawalLimit[_token] <= _quantity;\n } else {\n return dailyWithdrawalLimit[_token] <= lastSyncedWithdrawal[_token] + _quantity;\n }\n }\n\n /**\n * @dev Record withdrawal token.\n */\n function _recordWithdrawal(address _token, uint256 _quantity) internal virtual {\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n lastDateSynced[_token] = _currentDate;\n lastSyncedWithdrawal[_token] = _quantity;\n } else {\n lastSyncedWithdrawal[_token] += _quantity;\n }\n }\n\n /**\n * @dev Returns whether the withdrawal request is locked or not.\n */\n function _lockedWithdrawalRequest(address _token, uint256 _quantity) internal view virtual returns (bool) {\n return lockedThreshold[_token] <= _quantity;\n }\n\n /**\n * @dev Computes fee percentage.\n */\n function _computeFeePercentage(uint256 _amount, uint256 _percentage) internal view virtual returns (uint256) {\n return (_amount * _percentage) / _MAX_PERCENTAGE;\n }\n\n /**\n * @dev Returns high-tier vote weight.\n */\n function _highTierVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_highTierVWNum * _totalWeight + _highTierVWDenom - 1) / _highTierVWDenom;\n }\n\n /**\n * @dev Validates whether the high-tier vote weight threshold is larger than the normal threshold.\n */\n function _verifyThresholds() internal view {\n require(_num * _highTierVWDenom <= _highTierVWNum * _denom, \"WithdrawalLimitation: invalid thresholds\");\n }\n}\n" + }, + "contracts/v0.8/interfaces/MappedTokenConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../library/Token.sol\";\n\ninterface MappedTokenConsumer {\n struct MappedToken {\n Token.Standard erc;\n address tokenAddr;\n }\n}\n" + }, + "contracts/v0.8/library/Token.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nlibrary Token {\n enum Standard {\n ERC20,\n ERC721\n }\n struct Info {\n Standard erc;\n // For ERC20: the id must be 0 and the quantity is larger than 0.\n // For ERC721: the quantity must be 0.\n uint256 id;\n uint256 quantity;\n }\n\n // keccak256(\"TokenInfo(uint8 erc,uint256 id,uint256 quantity)\");\n bytes32 public constant INFO_TYPE_HASH = 0x1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Info memory _info) internal pure returns (bytes32) {\n return keccak256(abi.encode(INFO_TYPE_HASH, _info.erc, _info.id, _info.quantity));\n }\n\n /**\n * @dev Validates the token info.\n */\n function validate(Info memory _info) internal pure {\n require(\n (_info.erc == Standard.ERC20 && _info.quantity > 0 && _info.id == 0) ||\n (_info.erc == Standard.ERC721 && _info.quantity == 0),\n \"Token: invalid info\"\n );\n }\n\n /**\n * @dev Transfer asset from.\n *\n * Requirements:\n * - The `_from` address must approve for the contract using this library.\n *\n */\n function transferFrom(\n Info memory _info,\n address _from,\n address _to,\n address _token\n ) internal {\n bool _success;\n bytes memory _data;\n if (_info.erc == Standard.ERC20) {\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, _from, _to, _info.quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n } else if (_info.erc == Standard.ERC721) {\n // bytes4(keccak256(\"transferFrom(address,address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x23b872dd, _from, _to, _info.id));\n } else {\n revert(\"Token: unsupported token standard\");\n }\n\n if (!_success) {\n revert(\n string(\n abi.encodePacked(\n \"Token: could not transfer \",\n toString(_info),\n \" from \",\n Strings.toHexString(uint160(_from), 20),\n \" to \",\n Strings.toHexString(uint160(_to), 20),\n \" token \",\n Strings.toHexString(uint160(_token), 20)\n )\n )\n );\n }\n }\n\n /**\n * @dev Transfers ERC721 token and returns the result.\n */\n function tryTransferERC721(\n address _token,\n address _to,\n uint256 _id\n ) internal returns (bool _success) {\n (_success, ) = _token.call(abi.encodeWithSelector(IERC721.transferFrom.selector, address(this), _to, _id));\n }\n\n /**\n * @dev Transfers ERC20 token and returns the result.\n */\n function tryTransferERC20(\n address _token,\n address _to,\n uint256 _quantity\n ) internal returns (bool _success) {\n bytes memory _data;\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transfer.selector, _to, _quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n }\n\n /**\n * @dev Transfer assets from current address to `_to` address.\n */\n function transfer(\n Info memory _info,\n address _to,\n address _token\n ) internal {\n bool _success;\n if (_info.erc == Standard.ERC20) {\n _success = tryTransferERC20(_token, _to, _info.quantity);\n } else if (_info.erc == Standard.ERC721) {\n _success = tryTransferERC721(_token, _to, _info.id);\n } else {\n revert(\"Token: unsupported token standard\");\n }\n\n if (!_success) {\n revert(\n string(\n abi.encodePacked(\n \"Token: could not transfer \",\n toString(_info),\n \" to \",\n Strings.toHexString(uint160(_to), 20),\n \" token \",\n Strings.toHexString(uint160(_token), 20)\n )\n )\n );\n }\n }\n\n /**\n * @dev Tries minting and transfering assets.\n *\n * @notice Prioritizes transfer native token if the token is wrapped.\n *\n */\n function handleAssetTransfer(\n Info memory _info,\n address payable _to,\n address _token,\n IWETH _wrappedNativeToken\n ) internal {\n bool _success;\n if (_token == address(_wrappedNativeToken)) {\n // Try sending the native token before transferring the wrapped token\n if (!_to.send(_info.quantity)) {\n _wrappedNativeToken.deposit{ value: _info.quantity }();\n transfer(_info, _to, _token);\n }\n } else if (_info.erc == Token.Standard.ERC20) {\n uint256 _balance = IERC20(_token).balanceOf(address(this));\n\n if (_balance < _info.quantity) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, address(this), _info.quantity - _balance));\n require(_success, \"Token: ERC20 minting failed\");\n }\n\n transfer(_info, _to, _token);\n } else if (_info.erc == Token.Standard.ERC721) {\n if (!tryTransferERC721(_token, _to, _info.id)) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, _to, _info.id));\n require(_success, \"Token: ERC721 minting failed\");\n }\n } else {\n revert(\"Token: unsupported token standard\");\n }\n }\n\n /**\n * @dev Returns readable string.\n */\n function toString(Info memory _info) internal pure returns (string memory) {\n return\n string(\n abi.encodePacked(\n \"TokenInfo(\",\n Strings.toHexString(uint160(_info.erc), 1),\n \",\",\n Strings.toHexString(_info.id),\n \",\",\n Strings.toHexString(_info.quantity),\n \")\"\n )\n );\n }\n\n struct Owner {\n address addr;\n address tokenAddr;\n uint256 chainId;\n }\n\n // keccak256(\"TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant OWNER_TYPE_HASH = 0x353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764;\n\n /**\n * @dev Returns ownership struct hash.\n */\n function hash(Owner memory _owner) internal pure returns (bytes32) {\n return keccak256(abi.encode(OWNER_TYPE_HASH, _owner.addr, _owner.tokenAddr, _owner.chainId));\n }\n}\n" + }, + "contracts/v0.8/mainchain/IMainchainGatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../interfaces/IWETH.sol\";\nimport \"../library/Transfer.sol\";\nimport \"../interfaces/SignatureConsumer.sol\";\nimport \"../interfaces/MappedTokenConsumer.sol\";\n\ninterface IMainchainGatewayV2 is SignatureConsumer, MappedTokenConsumer {\n /// @dev Emitted when the deposit is requested\n event DepositRequested(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the assets are withdrawn\n event Withdrew(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the tokens are mapped\n event TokenMapped(address[] mainchainTokens, address[] roninTokens, Token.Standard[] standards);\n /// @dev Emitted when the wrapped native token contract is updated\n event WrappedNativeTokenContractUpdated(IWETH weth);\n /// @dev Emitted when the withdrawal is locked\n event WithdrawalLocked(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the withdrawal is unlocked\n event WithdrawalUnlocked(bytes32 receiptHash, Transfer.Receipt receipt);\n\n /**\n * @dev Returns the domain seperator.\n */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /**\n * @dev Returns deposit count.\n */\n function depositCount() external view returns (uint256);\n\n /**\n * @dev Sets the wrapped native token contract.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external;\n\n /**\n * @dev Returns whether the withdrawal is locked.\n */\n function withdrawalLocked(uint256 withdrawalId) external view returns (bool);\n\n /**\n * @dev Returns the withdrawal hash.\n */\n function withdrawalHash(uint256 withdrawalId) external view returns (bytes32);\n\n /**\n * @dev Locks the assets and request deposit.\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable;\n\n /**\n * @dev Withdraws based on the receipt and the validator signatures.\n * Returns whether the withdrawal is locked.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function submitWithdrawal(Transfer.Receipt memory _receipt, Signature[] memory _signatures)\n external\n returns (bool _locked);\n\n /**\n * @dev Approves a specific withdrawal.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network and sets thresholds.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n uint256[][4] calldata _thresholds\n ) external;\n\n /**\n * @dev Returns token address on Ronin network.\n * @notice Reverts for unsupported token.\n */\n function getRoninToken(address _mainchainToken) external view returns (MappedToken memory _token);\n}\n" + }, + "contracts/v0.8/mainchain/MainchainGatewayV2.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../extensions/GatewayV2.sol\";\nimport \"../extensions/WithdrawalLimitation.sol\";\nimport \"../library/Transfer.sol\";\nimport \"./IMainchainGatewayV2.sol\";\n\ncontract MainchainGatewayV2 is WithdrawalLimitation, Initializable, AccessControlEnumerable, IMainchainGatewayV2 {\n using Token for Token.Info;\n using Transfer for Transfer.Request;\n using Transfer for Transfer.Receipt;\n\n /// @dev Withdrawal unlocker role hash\n bytes32 public constant WITHDRAWAL_UNLOCKER_ROLE = keccak256(\"WITHDRAWAL_UNLOCKER_ROLE\");\n\n /// @dev Wrapped native token address\n IWETH public wrappedNativeToken;\n /// @dev Ronin network id\n uint256 public roninChainId;\n /// @dev Total deposit\n uint256 public depositCount;\n /// @dev Domain seperator\n bytes32 internal _domainSeparator;\n /// @dev Mapping from mainchain token => token address on Ronin network\n mapping(address => MappedToken) internal _roninToken;\n /// @dev Mapping from withdrawal id => withdrawal hash\n mapping(uint256 => bytes32) public withdrawalHash;\n /// @dev Mapping from withdrawal id => locked\n mapping(uint256 => bool) public withdrawalLocked;\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n /**\n * @dev Initializes contract storage.\n */\n function initialize(\n address _roleSetter,\n IWETH _wrappedToken,\n IWeightedValidator _validatorContract,\n uint256 _roninChainId,\n uint256 _numerator,\n uint256 _highTierVWNumerator,\n uint256 _denominator,\n // _addresses[0]: mainchainTokens\n // _addresses[1]: roninTokens\n // _addresses[2]: withdrawalUnlockers\n address[][3] calldata _addresses,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds,\n Token.Standard[] calldata _standards\n ) external payable virtual initializer {\n _setupRole(DEFAULT_ADMIN_ROLE, _roleSetter);\n roninChainId = _roninChainId;\n\n _setWrappedNativeTokenContract(_wrappedToken);\n _setValidatorContract(_validatorContract);\n _updateDomainSeparator();\n _setThreshold(_numerator, _denominator);\n _setHighTierVoteWeightThreshold(_highTierVWNumerator, _denominator);\n _verifyThresholds();\n\n if (_addresses[0].length > 0) {\n // Map mainchain tokens to ronin tokens\n _mapTokens(_addresses[0], _addresses[1], _standards);\n // Sets thresholds based on the mainchain tokens\n _setHighTierThresholds(_addresses[0], _thresholds[0]);\n _setLockedThresholds(_addresses[0], _thresholds[1]);\n _setUnlockFeePercentages(_addresses[0], _thresholds[2]);\n _setDailyWithdrawalLimits(_addresses[0], _thresholds[3]);\n }\n\n // Grant role for withdrawal unlocker\n for (uint256 _i; _i < _addresses[2].length; _i++) {\n _grantRole(WITHDRAWAL_UNLOCKER_ROLE, _addresses[2][_i]);\n }\n }\n\n /**\n * @dev Receives ether without doing anything. Use this function to topup native token.\n */\n function receiveEther() external payable {}\n\n /**\n * @dev See {IMainchainGatewayV2-DOMAIN_SEPARATOR}.\n */\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparator;\n }\n\n /**\n * @dev See {IMainchainGatewayV2-setWrappedNativeTokenContract}.\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external virtual onlyAdmin {\n _setWrappedNativeTokenContract(_wrappedToken);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-requestDepositFor}.\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable virtual whenNotPaused {\n _requestDepositFor(_request, msg.sender);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-submitWithdrawal}.\n */\n function submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] calldata _signatures)\n external\n virtual\n whenNotPaused\n returns (bool _locked)\n {\n return _submitWithdrawal(_receipt, _signatures);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-unlockWithdrawal}.\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external onlyRole(WITHDRAWAL_UNLOCKER_ROLE) {\n bytes32 _receiptHash = _receipt.hash();\n require(withdrawalHash[_receipt.id] == _receipt.hash(), \"MainchainGatewayV2: invalid receipt\");\n require(withdrawalLocked[_receipt.id], \"MainchainGatewayV2: query for approved withdrawal\");\n delete withdrawalLocked[_receipt.id];\n emit WithdrawalUnlocked(_receiptHash, _receipt);\n\n address _token = _receipt.mainchain.tokenAddr;\n if (_receipt.info.erc == Token.Standard.ERC20) {\n Token.Info memory _feeInfo = _receipt.info;\n _feeInfo.quantity = _computeFeePercentage(_receipt.info.quantity, unlockFeePercentages[_token]);\n Token.Info memory _withdrawInfo = _receipt.info;\n _withdrawInfo.quantity = _receipt.info.quantity - _feeInfo.quantity;\n\n _feeInfo.handleAssetTransfer(payable(msg.sender), _token, wrappedNativeToken);\n _withdrawInfo.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n } else {\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n }\n\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-mapTokens}.\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external virtual onlyAdmin {\n require(_mainchainTokens.length > 0, \"MainchainGatewayV2: query for empty array\");\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-mapTokensAndThresholds}.\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds\n ) external virtual onlyAdmin {\n require(_mainchainTokens.length > 0, \"MainchainGatewayV2: query for empty array\");\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n _setHighTierThresholds(_mainchainTokens, _thresholds[0]);\n _setLockedThresholds(_mainchainTokens, _thresholds[1]);\n _setUnlockFeePercentages(_mainchainTokens, _thresholds[2]);\n _setDailyWithdrawalLimits(_mainchainTokens, _thresholds[3]);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-getRoninToken}.\n */\n function getRoninToken(address _mainchainToken) public view returns (MappedToken memory _token) {\n _token = _roninToken[_mainchainToken];\n require(_token.tokenAddr != address(0), \"MainchainGatewayV2: unsupported token\");\n }\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The arrays have the same length.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function _mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) internal virtual {\n require(\n _mainchainTokens.length == _roninTokens.length && _mainchainTokens.length == _standards.length,\n \"MainchainGatewayV2: invalid array length\"\n );\n\n for (uint256 _i; _i < _mainchainTokens.length; _i++) {\n _roninToken[_mainchainTokens[_i]].tokenAddr = _roninTokens[_i];\n _roninToken[_mainchainTokens[_i]].erc = _standards[_i];\n }\n\n emit TokenMapped(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @dev Submits withdrawal receipt.\n *\n * Requirements:\n * - The receipt kind is withdrawal.\n * - The receipt is to withdraw on this chain.\n * - The receipt is not used to withdraw before.\n * - The withdrawal is not reached the limit threshold.\n * - The signer weight total is larger than or equal to the minimum threshold.\n * - The signature signers are in order.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function _submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] memory _signatures)\n internal\n virtual\n returns (bool _locked)\n {\n uint256 _id = _receipt.id;\n uint256 _quantity = _receipt.info.quantity;\n address _tokenAddr = _receipt.mainchain.tokenAddr;\n\n _receipt.info.validate();\n require(_receipt.kind == Transfer.Kind.Withdrawal, \"MainchainGatewayV2: invalid receipt kind\");\n require(_receipt.mainchain.chainId == block.chainid, \"MainchainGatewayV2: invalid chain id\");\n MappedToken memory _token = getRoninToken(_receipt.mainchain.tokenAddr);\n require(\n _token.erc == _receipt.info.erc && _token.tokenAddr == _receipt.ronin.tokenAddr,\n \"MainchainGatewayV2: invalid receipt\"\n );\n require(withdrawalHash[_id] == bytes32(0), \"MainchainGatewayV2: query for processed withdrawal\");\n require(\n _receipt.info.erc == Token.Standard.ERC721 || !_reachedWithdrawalLimit(_tokenAddr, _quantity),\n \"MainchainGatewayV2: reached daily withdrawal limit\"\n );\n\n bytes32 _receiptHash = _receipt.hash();\n bytes32 _receiptDigest = Transfer.receiptDigest(_domainSeparator, _receiptHash);\n IWeightedValidator _validatorContract = validatorContract;\n\n uint256 _minimumVoteWeight;\n (_minimumVoteWeight, _locked) = _computeMinVoteWeight(_receipt.info.erc, _tokenAddr, _quantity, _validatorContract);\n\n {\n bool _passed;\n address _signer;\n address _lastSigner;\n Signature memory _sig;\n uint256 _weight;\n for (uint256 _i; _i < _signatures.length; _i++) {\n _sig = _signatures[_i];\n _signer = ecrecover(_receiptDigest, _sig.v, _sig.r, _sig.s);\n require(_lastSigner < _signer, \"MainchainGatewayV2: invalid order\");\n _lastSigner = _signer;\n\n _weight += _validatorContract.getValidatorWeight(_signer);\n if (_weight >= _minimumVoteWeight) {\n _passed = true;\n break;\n }\n }\n require(_passed, \"MainchainGatewayV2: query for insufficient vote weight\");\n withdrawalHash[_id] = _receiptHash;\n }\n\n if (_locked) {\n withdrawalLocked[_id] = true;\n emit WithdrawalLocked(_receiptHash, _receipt);\n return _locked;\n }\n\n _recordWithdrawal(_tokenAddr, _quantity);\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _tokenAddr, wrappedNativeToken);\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @dev Requests deposit made by `_requester` address.\n *\n * Requirements:\n * - The token info is valid.\n * - The `msg.value` is 0 while depositing ERC20 token.\n * - The `msg.value` is equal to deposit quantity while depositing native token.\n *\n * Emits the `DepositRequested` event.\n *\n */\n function _requestDepositFor(Transfer.Request memory _request, address _requester) internal virtual {\n MappedToken memory _token;\n address _weth = address(wrappedNativeToken);\n\n _request.info.validate();\n if (_request.tokenAddr == address(0)) {\n require(_request.info.quantity == msg.value, \"MainchainGatewayV2: invalid request\");\n _token = getRoninToken(_weth);\n require(_token.erc == _request.info.erc, \"MainchainGatewayV2: invalid token standard\");\n _request.tokenAddr = _weth;\n } else {\n require(msg.value == 0, \"MainchainGatewayV2: invalid request\");\n _token = getRoninToken(_request.tokenAddr);\n require(_token.erc == _request.info.erc, \"MainchainGatewayV2: invalid token standard\");\n _request.info.transferFrom(_requester, address(this), _request.tokenAddr);\n // Withdraw if token is WETH\n if (_weth == _request.tokenAddr) {\n IWETH(_weth).withdraw(_request.info.quantity);\n }\n }\n\n uint256 _depositId = depositCount++;\n Transfer.Receipt memory _receipt = _request.into_deposit_receipt(\n _requester,\n _depositId,\n _token.tokenAddr,\n roninChainId\n );\n\n emit DepositRequested(_receipt.hash(), _receipt);\n }\n\n /**\n * @dev Returns the minimum vote weight for the token.\n */\n function _computeMinVoteWeight(\n Token.Standard _erc,\n address _token,\n uint256 _quantity,\n IWeightedValidator _validatorContract\n ) internal virtual returns (uint256 _weight, bool _locked) {\n uint256 _totalWeights = _validatorContract.totalWeights();\n _weight = _minimumVoteWeight(_totalWeights);\n if (_erc == Token.Standard.ERC20) {\n if (highTierThreshold[_token] <= _quantity) {\n _weight = _highTierVoteWeight(_totalWeights);\n }\n _locked = _lockedWithdrawalRequest(_token, _quantity);\n }\n }\n\n /**\n * @dev Update domain seperator.\n */\n function _updateDomainSeparator() internal {\n _domainSeparator = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(\"MainchainGatewayV2\"),\n keccak256(\"2\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /**\n * @dev Sets the WETH contract.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function _setWrappedNativeTokenContract(IWETH _wrapedToken) internal {\n wrappedNativeToken = _wrapedToken;\n emit WrappedNativeTokenContractUpdated(_wrapedToken);\n }\n\n /**\n * @dev Receives ETH from WETH or creates deposit request.\n */\n function _fallback() internal virtual whenNotPaused {\n if (msg.sender != address(wrappedNativeToken)) {\n Transfer.Request memory _request;\n _request.recipientAddr = msg.sender;\n _request.info.quantity = msg.value;\n _requestDepositFor(_request, _request.recipientAddr);\n }\n }\n}\n" + }, + "contracts/v0.8/interfaces/IWeightedValidator.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./IQuorum.sol\";\n\ninterface IWeightedValidator is IQuorum {\n struct WeightedValidator {\n address validator;\n address governor;\n uint256 weight;\n }\n\n /// @dev Emitted when the validators are added\n event ValidatorsAdded(uint256 indexed nonce, WeightedValidator[] validators);\n /// @dev Emitted when the validators are updated\n event ValidatorsUpdated(uint256 indexed nonce, WeightedValidator[] validators);\n /// @dev Emitted when the validators are removed\n event ValidatorsRemoved(uint256 indexed nonce, address[] validators);\n\n /**\n * @dev Returns validator weight of the validator.\n */\n function getValidatorWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns governor weight of the governor.\n */\n function getGovernorWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns total validator weights of the address list.\n */\n function sumValidatorWeights(address[] calldata _addrList) external view returns (uint256 _weight);\n\n /**\n * @dev Returns total governor weights of the address list.\n */\n function sumGovernorWeights(address[] calldata _addrList) external view returns (uint256 _weight);\n\n /**\n * @dev Returns the validator list attached with governor address and weight.\n */\n function getValidatorInfo() external view returns (WeightedValidator[] memory _list);\n\n /**\n * @dev Returns the validator list.\n */\n function getValidators() external view returns (address[] memory _validators);\n\n /**\n * @dev Returns the validator at `_index` position.\n */\n function validators(uint256 _index) external view returns (WeightedValidator memory);\n\n /**\n * @dev Returns total of validators.\n */\n function totalValidators() external view returns (uint256);\n\n /**\n * @dev Returns total weights.\n */\n function totalWeights() external view returns (uint256);\n\n /**\n * @dev Adds validators.\n *\n * Requirements:\n * - The weights are larger than 0.\n * - The validators are not added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsAdded` event.\n *\n */\n function addValidators(WeightedValidator[] calldata _validators) external;\n\n /**\n * @dev Updates validators.\n *\n * Requirements:\n * - The weights are larger than 0.\n * - The validators are added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsUpdated` event.\n *\n */\n function updateValidators(WeightedValidator[] calldata _validators) external;\n\n /**\n * @dev Removes validators.\n *\n * Requirements:\n * - The validators are added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsRemoved` event.\n *\n */\n function removeValidators(address[] calldata _validators) external;\n}\n" + }, + "contracts/v0.8/extensions/HasProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\nabstract contract HasProxyAdmin {\n // bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n modifier onlyAdmin() {\n require(msg.sender == _getAdmin(), \"HasProxyAdmin: unauthorized sender\");\n _;\n }\n\n /**\n * @dev Returns proxy admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "contracts/v0.8/interfaces/SignatureConsumer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface SignatureConsumer {\n struct Signature {\n uint8 v;\n bytes32 r;\n bytes32 s;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" + }, + "contracts/v0.8/library/Transfer.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./Token.sol\";\n\nlibrary Transfer {\n using ECDSA for bytes32;\n\n enum Kind {\n Deposit,\n Withdrawal\n }\n\n struct Request {\n // For deposit request: Recipient address on Ronin network\n // For withdrawal request: Recipient address on mainchain network\n address recipientAddr;\n // Token address to deposit/withdraw\n // Value 0: native token\n address tokenAddr;\n Token.Info info;\n }\n\n /**\n * @dev Converts the transfer request into the deposit receipt.\n */\n function into_deposit_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _roninTokenAddr,\n uint256 _roninChainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Deposit;\n _receipt.mainchain.addr = _requester;\n _receipt.mainchain.tokenAddr = _request.tokenAddr;\n _receipt.mainchain.chainId = block.chainid;\n _receipt.ronin.addr = _request.recipientAddr;\n _receipt.ronin.tokenAddr = _roninTokenAddr;\n _receipt.ronin.chainId = _roninChainId;\n _receipt.info = _request.info;\n }\n\n /**\n * @dev Converts the transfer request into the withdrawal receipt.\n */\n function into_withdrawal_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _mainchainTokenAddr,\n uint256 _mainchainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Withdrawal;\n _receipt.ronin.addr = _requester;\n _receipt.ronin.tokenAddr = _request.tokenAddr;\n _receipt.ronin.chainId = block.chainid;\n _receipt.mainchain.addr = _request.recipientAddr;\n _receipt.mainchain.tokenAddr = _mainchainTokenAddr;\n _receipt.mainchain.chainId = _mainchainId;\n _receipt.info = _request.info;\n }\n\n struct Receipt {\n uint256 id;\n Kind kind;\n Token.Owner mainchain;\n Token.Owner ronin;\n Token.Info info;\n }\n\n // keccak256(\"Receipt(uint256 id,uint8 kind,TokenOwner mainchain,TokenOwner ronin,TokenInfo info)TokenInfo(uint8 erc,uint256 id,uint256 quantity)TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant TYPE_HASH = 0xb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Receipt memory _receipt) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encode(\n TYPE_HASH,\n _receipt.id,\n _receipt.kind,\n Token.hash(_receipt.mainchain),\n Token.hash(_receipt.ronin),\n Token.hash(_receipt.info)\n )\n );\n }\n\n /**\n * @dev Returns the receipt digest.\n */\n function receiptDigest(bytes32 _domainSeparator, bytes32 _receiptHash) internal pure returns (bytes32) {\n return _domainSeparator.toTypedDataHash(_receiptHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/security/Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "contracts/v0.8/interfaces/IQuorum.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IQuorum {\n /// @dev Emitted when the threshold is updated\n event ThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n\n /**\n * @dev Returns the threshold.\n */\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\n\n /**\n * @dev Checks whether the `_voteWeight` passes the threshold.\n */\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\n\n /**\n * @dev Returns the minimum vote weight to pass the threshold.\n */\n function minimumVoteWeight() external view returns (uint256);\n\n /**\n * @dev Sets the threshold.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n returns (uint256 _previousNum, uint256 _previousDenom);\n}\n" + }, + "contracts/v0.8/interfaces/IWETH.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IWETH {\n function deposit() external payable;\n\n function withdraw(uint256 _wad) external;\n\n function balanceOf(address) external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" + } + }, + "settings": { + "evmVersion": "london", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs", + "useLiteralContent": true + }, + "optimizer": { + "enabled": true, + "runs": 1000 + }, + "remappings": [], + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + } + } + }, + "ABI": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"limits\",\"type\":\"uint256[]\"}],\"name\":\"DailyWithdrawalLimitsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"DepositRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"thresholds\",\"type\":\"uint256[]\"}],\"name\":\"HighTierThresholdsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"HighTierVoteWeightThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"thresholds\",\"type\":\"uint256[]\"}],\"name\":\"LockedThresholdsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"ThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"mainchainTokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"roninTokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"enum Token.Standard[]\",\"name\":\"standards\",\"type\":\"uint8[]\"}],\"name\":\"TokenMapped\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"percentages\",\"type\":\"uint256[]\"}],\"name\":\"UnlockFeePercentagesUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IWeightedValidator\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"ValidatorContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"WithdrawalLocked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"WithdrawalUnlocked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"Withdrew\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IWETH\",\"name\":\"weth\",\"type\":\"address\"}],\"name\":\"WrappedNativeTokenContractUpdated\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WITHDRAWAL_UNLOCKER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_MAX_PERCENTAGE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"dailyWithdrawalLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_mainchainToken\",\"type\":\"address\"}],\"name\":\"getRoninToken\",\"outputs\":[{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"}],\"internalType\":\"struct MappedTokenConsumer.MappedToken\",\"name\":\"_token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"highTierThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_roleSetter\",\"type\":\"address\"},{\"internalType\":\"contract IWETH\",\"name\":\"_wrappedToken\",\"type\":\"address\"},{\"internalType\":\"contract IWeightedValidator\",\"name\":\"_validatorContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_roninChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_highTierVWNumerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"},{\"internalType\":\"address[][3]\",\"name\":\"_addresses\",\"type\":\"address[][3]\"},{\"internalType\":\"uint256[][4]\",\"name\":\"_thresholds\",\"type\":\"uint256[][4]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastDateSynced\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastSyncedWithdrawal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lockedThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_mainchainTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_roninTokens\",\"type\":\"address[]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"}],\"name\":\"mapTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_mainchainTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_roninTokens\",\"type\":\"address[]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"},{\"internalType\":\"uint256[][4]\",\"name\":\"_thresholds\",\"type\":\"uint256[][4]\"}],\"name\":\"mapTokensAndThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimumVoteWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_quantity\",\"type\":\"uint256\"}],\"name\":\"reachedWithdrawalLimit\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"receiveEther\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Request\",\"name\":\"_request\",\"type\":\"tuple\"}],\"name\":\"requestDepositFor\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"roninChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_limits\",\"type\":\"uint256[]\"}],\"name\":\"setDailyWithdrawalLimits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setHighTierThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_previousNum\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_previousDenom\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setLockedThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_previousNum\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_previousDenom\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_percentages\",\"type\":\"uint256[]\"}],\"name\":\"setUnlockFeePercentages\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IWeightedValidator\",\"name\":\"_validatorContract\",\"type\":\"address\"}],\"name\":\"setValidatorContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IWETH\",\"name\":\"_wrappedToken\",\"type\":\"address\"}],\"name\":\"setWrappedNativeTokenContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Receipt\",\"name\":\"_receipt\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct SignatureConsumer.Signature[]\",\"name\":\"_signatures\",\"type\":\"tuple[]\"}],\"name\":\"submitWithdrawal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_locked\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"unlockFeePercentages\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Receipt\",\"name\":\"_receipt\",\"type\":\"tuple\"}],\"name\":\"unlockWithdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"validatorContract\",\"outputs\":[{\"internalType\":\"contract IWeightedValidator\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"withdrawalHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"withdrawalLocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedNativeToken\",\"outputs\":[{\"internalType\":\"contract IWETH\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + "ContractName": "MainchainGatewayV2", + "CompilerVersion": "v0.8.9+commit.e5eed63a", + "OptimizationUsed": 1, + "Runs": 1000, + "ConstructorArguments": "0x", + "EVMVersion": "Default", + "Library": "", + "LicenseType": "MIT", + "Proxy": 0, + "SwarmSource": "" + } +] \ No newline at end of file diff --git a/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json new file mode 100644 index 0000000000000..fa26d9cad4256 --- /dev/null +++ b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0x8b3d32cf2bb4d0d16656f4c0b04fa546274f1545", + "contractCreator": "0x958892b4a0512b28aaac890fc938868bbd42f064", + "txHash": "0x79820495643caf5a1e7e96578361c9ddba0e0735cd684ada7450254f6fd58f51" +} \ No newline at end of file diff --git a/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json new file mode 100644 index 0000000000000..5921b5b303ee9 --- /dev/null +++ b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json @@ -0,0 +1,63 @@ +[ + { + "SourceCode": { + "language": "Solidity", + "sources": { + "contracts/governance/governor/GovernorStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./IIpt.sol\";\nimport \"./Structs.sol\";\n\ncontract GovernorCharlieDelegatorStorage {\n /// @notice Active brains of Governor\n address public implementation;\n}\n\n/**\n * @title Storage for Governor Charlie Delegate\n * @notice For future upgrades, do not change GovernorCharlieDelegateStorage. Create a new\n * contract which implements GovernorCharlieDelegateStorage and following the naming convention\n * GovernorCharlieDelegateStorageVX.\n */\n//solhint-disable-next-line max-states-count\ncontract GovernorCharlieDelegateStorage is GovernorCharlieDelegatorStorage {\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed\n uint256 public quorumVotes;\n\n /// @notice The number of votes in support of a proposal required in order for an emergency quorum to be reached and for a vote to succeed\n uint256 public emergencyQuorumVotes;\n\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint256 public votingDelay;\n\n /// @notice The duration of voting on a proposal, in blocks\n uint256 public votingPeriod;\n\n /// @notice The number of votes required in order for a voter to become a proposer\n uint256 public proposalThreshold;\n\n /// @notice Initial proposal id set at become\n uint256 public initialProposalId;\n\n /// @notice The total number of proposals\n uint256 public proposalCount;\n\n /// @notice The address of the Interest Protocol governance token\n IIpt public ipt;\n\n /// @notice The official record of all proposals ever proposed\n mapping(uint256 => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping(address => uint256) public latestProposalIds;\n\n /// @notice The latest proposal for each proposer\n mapping(bytes32 => bool) public queuedTransactions;\n\n /// @notice The proposal holding period\n uint256 public proposalTimelockDelay;\n\n /// @notice Stores the expiration of account whitelist status as a timestamp\n mapping(address => uint256) public whitelistAccountExpirations;\n\n /// @notice Address which manages whitelisted proposals and whitelist accounts\n address public whitelistGuardian;\n\n /// @notice The duration of the voting on a emergency proposal, in blocks\n uint256 public emergencyVotingPeriod;\n\n /// @notice The emergency proposal holding period\n uint256 public emergencyTimelockDelay;\n\n /// all receipts for proposal\n mapping(uint256 => mapping(address => Receipt)) public proposalReceipts;\n\n /// @notice The emergency proposal holding period\n bool public initialized;\n\n /// @notice The number of votes to reject an optimistic proposal\n uint256 public optimisticQuorumVotes; \n\n /// @notice The delay period before voting begins\n uint256 public optimisticVotingDelay; \n\n /// @notice The maximum number of seconds an address can be whitelisted for\n uint256 public maxWhitelistPeriod; \n}\n" + }, + "hardhat/console.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >= 0.4.22 <0.9.0;\n\nlibrary console {\n\taddress constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n\tfunction _sendLogPayload(bytes memory payload) private view {\n\t\tuint256 payloadLength = payload.length;\n\t\taddress consoleAddress = CONSOLE_ADDRESS;\n\t\tassembly {\n\t\t\tlet payloadStart := add(payload, 32)\n\t\t\tlet r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n\t\t}\n\t}\n\n\tfunction log() internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log()\"));\n\t}\n\n\tfunction logInt(int p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(int)\", p0));\n\t}\n\n\tfunction logUint(uint p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n\t}\n\n\tfunction logString(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction logBool(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction logAddress(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction logBytes(bytes memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n\t}\n\n\tfunction logBytes1(bytes1 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n\t}\n\n\tfunction logBytes2(bytes2 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n\t}\n\n\tfunction logBytes3(bytes3 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n\t}\n\n\tfunction logBytes4(bytes4 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n\t}\n\n\tfunction logBytes5(bytes5 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n\t}\n\n\tfunction logBytes6(bytes6 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n\t}\n\n\tfunction logBytes7(bytes7 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n\t}\n\n\tfunction logBytes8(bytes8 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n\t}\n\n\tfunction logBytes9(bytes9 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n\t}\n\n\tfunction logBytes10(bytes10 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n\t}\n\n\tfunction logBytes11(bytes11 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n\t}\n\n\tfunction logBytes12(bytes12 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n\t}\n\n\tfunction logBytes13(bytes13 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n\t}\n\n\tfunction logBytes14(bytes14 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n\t}\n\n\tfunction logBytes15(bytes15 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n\t}\n\n\tfunction logBytes16(bytes16 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n\t}\n\n\tfunction logBytes17(bytes17 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n\t}\n\n\tfunction logBytes18(bytes18 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n\t}\n\n\tfunction logBytes19(bytes19 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n\t}\n\n\tfunction logBytes20(bytes20 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n\t}\n\n\tfunction logBytes21(bytes21 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n\t}\n\n\tfunction logBytes22(bytes22 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n\t}\n\n\tfunction logBytes23(bytes23 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n\t}\n\n\tfunction logBytes24(bytes24 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n\t}\n\n\tfunction logBytes25(bytes25 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n\t}\n\n\tfunction logBytes26(bytes26 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n\t}\n\n\tfunction logBytes27(bytes27 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n\t}\n\n\tfunction logBytes28(bytes28 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n\t}\n\n\tfunction logBytes29(bytes29 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n\t}\n\n\tfunction logBytes30(bytes30 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n\t}\n\n\tfunction logBytes31(bytes31 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n\t}\n\n\tfunction logBytes32(bytes32 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n\t}\n\n\tfunction log(uint p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n\t}\n\n\tfunction log(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction log(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction log(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction log(uint p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n\t}\n\n\tfunction log(address p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint)\", p0, p1));\n\t}\n\n\tfunction log(address p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n\t}\n\n\tfunction log(address p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n\t}\n\n\tfunction log(address p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n}\n" + }, + "contracts/governance/governor/IGovernor.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./Structs.sol\";\n\n/// @title interface to interact with TokenDelgator\ninterface IGovernorCharlieDelegator {\n function _setImplementation(address implementation_) external;\n\n fallback() external payable;\n\n receive() external payable;\n}\n\n/// @title interface to interact with TokenDelgate\ninterface IGovernorCharlieDelegate {\n function initialize(\n address ipt_\n ) external;\n\n function propose(\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n bool emergency\n ) external returns (uint256);\n\n function queue(uint256 proposalId) external;\n\n function execute(uint256 proposalId) external payable;\n\n function executeTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) external payable;\n\n function cancel(uint256 proposalId) external;\n\n function getActions(uint256 proposalId)\n external\n view\n returns (\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas\n );\n\n function getReceipt(uint256 proposalId, address voter) external view returns (Receipt memory);\n\n function state(uint256 proposalId) external view returns (ProposalState);\n\n function castVote(uint256 proposalId, uint8 support) external;\n\n function castVoteWithReason(\n uint256 proposalId,\n uint8 support,\n string calldata reason\n ) external;\n\n function castVoteBySig(\n uint256 proposalId,\n uint8 support,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n function isWhitelisted(address account) external view returns (bool);\n\n function _setDelay(uint256 proposalTimelockDelay_) external;\n\n function _setEmergencyDelay(uint256 emergencyTimelockDelay_) external;\n\n function _setVotingDelay(uint256 newVotingDelay) external;\n\n function _setVotingPeriod(uint256 newVotingPeriod) external;\n\n function _setEmergencyVotingPeriod(uint256 newEmergencyVotingPeriod) external;\n\n function _setProposalThreshold(uint256 newProposalThreshold) external;\n\n function _setQuorumVotes(uint256 newQuorumVotes) external;\n\n function _setEmergencyQuorumVotes(uint256 newEmergencyQuorumVotes) external;\n\n function _setWhitelistAccountExpiration(address account, uint256 expiration) external;\n\n function _setWhitelistGuardian(address account) external;\n\n function _setOptimisticDelay(uint256 newOptimisticVotingDelay) external;\n\n function _setOptimisticQuorumVotes(uint256 newOptimisticQuorumVotes) external;\n}\n\n/// @title interface which contains all events emitted by delegator & delegate\ninterface GovernorCharlieEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(\n uint256 indexed id,\n address indexed proposer,\n address[] targets,\n uint256[] values,\n string[] signatures,\n bytes[] calldatas,\n uint256 indexed startBlock,\n uint256 endBlock,\n string description\n );\n\n /// @notice An event emitted when a vote has been cast on a proposal\n /// @param voter The address which casted a vote\n /// @param proposalId The proposal id which was voted on\n /// @param support Support value for the vote. 0=against, 1=for, 2=abstain\n /// @param votes Number of votes which were cast by the voter\n /// @param reason The reason given for the vote by the voter\n event VoteCast(address indexed voter, uint256 indexed proposalId, uint8 support, uint256 votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint256 indexed id);\n\n /// @notice An event emitted when a proposal has been queued in the Timelock\n event ProposalQueued(uint256 indexed id, uint256 eta);\n\n /// @notice An event emitted when a proposal has been executed in the Timelock\n event ProposalExecuted(uint256 indexed id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod);\n\n /// @notice An event emitted when the emergency voting period is set\n event EmergencyVotingPeriodSet(uint256 oldEmergencyVotingPeriod, uint256 emergencyVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold is set\n event ProposalThresholdSet(uint256 oldProposalThreshold, uint256 newProposalThreshold);\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Emitted when pendingAdmin is accepted, which means admin is updated\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /// @notice Emitted when whitelist account expiration is set\n event WhitelistAccountExpirationSet(address account, uint256 expiration);\n\n /// @notice Emitted when the whitelistGuardian is set\n event WhitelistGuardianSet(address oldGuardian, address newGuardian);\n\n /// @notice Emitted when the a new delay is set\n event NewDelay(uint256 oldTimelockDelay, uint256 proposalTimelockDelay);\n\n /// @notice Emitted when the a new emergency delay is set\n event NewEmergencyDelay(uint256 oldEmergencyTimelockDelay, uint256 emergencyTimelockDelay);\n\n /// @notice Emitted when the quorum is updated\n event NewQuorum(uint256 oldQuorumVotes, uint256 quorumVotes);\n\n /// @notice Emitted when the emergency quorum is updated\n event NewEmergencyQuorum(uint256 oldEmergencyQuorumVotes, uint256 emergencyQuorumVotes);\n\n /// @notice An event emitted when the optimistic voting delay is set\n event OptimisticVotingDelaySet(uint256 oldOptimisticVotingDelay, uint256 optimisticVotingDelay);\n\n /// @notice Emitted when the optimistic quorum is updated\n event OptimisticQuorumVotesSet(uint256 oldOptimisticQuorumVotes, uint256 optimisticQuorumVotes);\n\n /// @notice Emitted when a transaction is canceled\n event CancelTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n\n /// @notice Emitted when a transaction is executed\n event ExecuteTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n\n /// @notice Emitted when a transaction is queued\n event QueueTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n}\n" + }, + "contracts/governance/governor/Structs.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nstruct Proposal {\n /// @notice Unique id for looking up a proposal\n uint256 id;\n /// @notice Creator of the proposal\n address proposer;\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint256 eta;\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint256[] values;\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint256 startBlock;\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint256 endBlock;\n /// @notice Current number of votes in favor of this proposal\n uint256 forVotes;\n /// @notice Current number of votes in opposition to this proposal\n uint256 againstVotes;\n /// @notice Current number of votes for abstaining for this proposal\n uint256 abstainVotes;\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n /// @notice Whether the proposal is an emergency proposal\n bool emergency;\n /// @notice quorum votes requires\n uint256 quorumVotes;\n /// @notice time delay\n uint256 delay;\n}\n\n/// @notice Ballot receipt record for a voter\nstruct Receipt {\n /// @notice Whether or not a vote has been cast\n bool hasVoted;\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n /// @notice The number of votes the voter had, which were cast\n uint96 votes;\n}\n\n/// @notice Possible states that a proposal may be in\nenum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed\n}\n" + }, + "contracts/governance/governor/IIpt.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\ninterface IIpt {\n function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96);\n}\n" + }, + "contracts/governance/governor/GovernorDelegate.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\npragma experimental ABIEncoderV2;\nimport \"hardhat/console.sol\";\n\nimport \"./IGovernor.sol\";\nimport \"./GovernorStorage.sol\";\n\ncontract GovernorCharlieDelegate is GovernorCharlieDelegateStorage, GovernorCharlieEvents, IGovernorCharlieDelegate {\n /// @notice The name of this contract\n string public constant name = \"Interest Protocol Governor\";\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint256 public constant proposalMaxOperations = 10;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the ballot struct used by the contract\n bytes32 public constant BALLOT_TYPEHASH = keccak256(\"Ballot(uint256 proposalId,uint8 support)\");\n\n /// @notice The time for a proposal to be executed after passing\n uint256 public constant GRACE_PERIOD = 14 days;\n\n /**\n * @notice Used to initialize the contract during delegator contructor\n * @param ipt_ The address of the IPT token\n */\n function initialize(\n address ipt_\n ) external override {\n require(!initialized, \"already been initialized\");\n ipt = IIpt(ipt_);\n votingPeriod = 40320;\n votingDelay = 13140;\n proposalThreshold = 1000000000000000000000000;\n proposalTimelockDelay = 172800;\n proposalCount = 0;\n quorumVotes = 10000000000000000000000000;\n emergencyQuorumVotes = 40000000000000000000000000;\n emergencyVotingPeriod = 6570;\n emergencyTimelockDelay = 43200;\n optimisticQuorumVotes = 2000000000000000000000000;\n optimisticVotingDelay = 18000;\n maxWhitelistPeriod = 31536000;\n\n initialized = true;\n }\n\n /// @notice any function with this modifier will call the pay_interest() function before\n modifier onlyGov() {\n require(_msgSender() == address(this), \"must come from the gov.\");\n _;\n }\n\n /**\n * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold\n * @param targets Target addresses for proposal calls\n * @param values Eth values for proposal calls\n * @param signatures Function signatures for proposal calls\n * @param calldatas Calldatas for proposal calls\n * @param description String description of the proposal\n * @return Proposal id of new proposal\n */\n function propose(\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n bool emergency\n ) public override returns (uint256) {\n // Reject proposals before initiating as Governor\n require(quorumVotes != 0, \"Charlie not active\");\n // Allow addresses above proposal threshold and whitelisted addresses to propose\n require(\n ipt.getPriorVotes(_msgSender(), (block.number - 1)) >= proposalThreshold || isWhitelisted(_msgSender()),\n \"votes below proposal threshold\"\n );\n require(\n targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length,\n \"information arity mismatch\"\n );\n require(targets.length != 0, \"must provide actions\");\n require(targets.length <= proposalMaxOperations, \"too many actions\");\n\n uint256 latestProposalId = latestProposalIds[_msgSender()];\n if (latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(latestProposalId);\n require(proposersLatestProposalState != ProposalState.Active, \"one live proposal per proposer\");\n require(proposersLatestProposalState != ProposalState.Pending, \"one live proposal per proposer\");\n }\n\n proposalCount++;\n Proposal memory newProposal = Proposal({\n id: proposalCount,\n proposer: _msgSender(),\n eta: 0,\n targets: targets,\n values: values,\n signatures: signatures,\n calldatas: calldatas,\n startBlock: block.number + votingDelay,\n endBlock: block.number + votingDelay + votingPeriod,\n forVotes: 0,\n againstVotes: 0,\n abstainVotes: 0,\n canceled: false,\n executed: false,\n emergency: emergency,\n quorumVotes: quorumVotes,\n delay: proposalTimelockDelay\n });\n\n //whitelist can't make emergency\n if (emergency && !isWhitelisted(_msgSender())) {\n newProposal.startBlock = block.number;\n newProposal.endBlock = block.number + emergencyVotingPeriod;\n newProposal.quorumVotes = emergencyQuorumVotes;\n newProposal.delay = emergencyTimelockDelay;\n }\n\n //whitelist can only make optimistic proposals\n if (isWhitelisted(_msgSender())) {\n newProposal.quorumVotes = optimisticQuorumVotes;\n newProposal.startBlock = block.number + optimisticVotingDelay;\n newProposal.endBlock = block.number + optimisticVotingDelay + votingPeriod;\n }\n\n proposals[newProposal.id] = newProposal;\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n emit ProposalCreated(\n newProposal.id,\n _msgSender(),\n targets,\n values,\n signatures,\n calldatas,\n newProposal.startBlock,\n newProposal.endBlock,\n description\n );\n return newProposal.id;\n }\n\n /**\n * @notice Queues a proposal of state succeeded\n * @param proposalId The id of the proposal to queue\n */\n function queue(uint256 proposalId) external override {\n require(state(proposalId) == ProposalState.Succeeded, \"can only be queued if succeeded\");\n Proposal storage proposal = proposals[proposalId];\n uint256 eta = block.timestamp + proposal.delay;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n require(\n !queuedTransactions[\n keccak256(\n abi.encode(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta)\n )\n ],\n \"proposal already queued\"\n );\n queueTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n eta,\n proposal.delay\n );\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta,\n uint256 delay\n ) internal returns (bytes32) {\n require(eta >= (getBlockTimestamp() + delay), \"must satisfy delay.\");\n\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = true;\n\n emit QueueTransaction(txHash, target, value, signature, data, eta);\n return txHash;\n }\n\n /**\n * @notice Executes a queued proposal if eta has passed\n * @param proposalId The id of the proposal to execute\n */\n function execute(uint256 proposalId) external payable override {\n require(state(proposalId) == ProposalState.Queued, \"can only be exec'd if queued\");\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n this.executeTransaction{value: proposal.values[i]}(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n emit ProposalExecuted(proposalId);\n }\n\n function executeTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) external payable override {\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n require(queuedTransactions[txHash], \"tx hasn't been queued.\");\n require(getBlockTimestamp() >= eta, \"tx hasn't surpassed timelock.\");\n require(getBlockTimestamp() <= eta + GRACE_PERIOD, \"tx is stale.\");\n\n queuedTransactions[txHash] = false;\n\n bytes memory callData;\n\n if (bytes(signature).length == 0) {\n callData = data;\n } else {\n callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data);\n }\n\n // solhint-disable-next-line avoid-low-level-calls\n (\n bool success, /*bytes memory returnData*/\n\n ) = target.call{value: value}(callData);\n require(success, \"tx execution reverted.\");\n\n emit ExecuteTransaction(txHash, target, value, signature, data, eta);\n }\n\n /**\n * @notice Cancels a proposal only if sender is the proposer, or proposer delegates dropped below proposal threshold\n * @param proposalId The id of the proposal to cancel\n */\n function cancel(uint256 proposalId) external override {\n require(state(proposalId) != ProposalState.Executed, \"cant cancel executed proposal\");\n\n Proposal storage proposal = proposals[proposalId];\n\n // Proposer can cancel\n if (_msgSender() != proposal.proposer) {\n // Whitelisted proposers can't be canceled for falling below proposal threshold\n if (isWhitelisted(proposal.proposer)) {\n require(\n (ipt.getPriorVotes(proposal.proposer, (block.number - 1)) < proposalThreshold) &&\n _msgSender() == whitelistGuardian,\n \"cancel: whitelisted proposer\"\n );\n } else {\n require(\n (ipt.getPriorVotes(proposal.proposer, (block.number - 1)) < proposalThreshold),\n \"cancel: proposer above threshold\"\n );\n }\n }\n\n proposal.canceled = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n function cancelTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) internal {\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = false;\n\n emit CancelTransaction(txHash, target, value, signature, data, eta);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets proposal targets\n * @return values proposal values\n * @return signatures proposal signatures\n * @return calldatas proposal calldatae\n */\n function getActions(uint256 proposalId)\n external\n view\n override\n returns (\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas\n )\n {\n Proposal storage p = proposals[proposalId];\n return (p.targets, p.values, p.signatures, p.calldatas);\n }\n\n /**\n * @notice Gets the receipt for a voter on a given proposal\n * @param proposalId the id of proposal\n * @param voter The address of the voter\n * @return The voting receipt\n */\n function getReceipt(uint256 proposalId, address voter) external view override returns (Receipt memory) {\n return proposalReceipts[proposalId][voter];\n }\n\n /**\n * @notice Gets the state of a proposal\n * @param proposalId The id of the proposal\n * @return Proposal state\n */\n // solhint-disable-next-line code-complexity\n function state(uint256 proposalId) public view override returns (ProposalState) {\n require(proposalCount >= proposalId && proposalId > initialProposalId, \"state: invalid proposal id\");\n Proposal storage proposal = proposals[proposalId];\n bool whitelisted = isWhitelisted(proposal.proposer);\n if (proposal.canceled) {\n return ProposalState.Canceled;\n } else if (block.number <= proposal.startBlock) {\n return ProposalState.Pending;\n } else if (block.number <= proposal.endBlock) {\n return ProposalState.Active;\n } else if (\n (whitelisted && proposal.againstVotes > proposal.quorumVotes) ||\n (!whitelisted && proposal.forVotes <= proposal.againstVotes) ||\n (!whitelisted && proposal.forVotes < proposal.quorumVotes)\n ) {\n return ProposalState.Defeated;\n } else if (proposal.eta == 0) {\n return ProposalState.Succeeded;\n } else if (proposal.executed) {\n return ProposalState.Executed;\n } else if (block.timestamp >= (proposal.eta + GRACE_PERIOD)) {\n return ProposalState.Expired;\n }\n return ProposalState.Queued;\n }\n\n /**\n * @notice Cast a vote for a proposal\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n */\n function castVote(uint256 proposalId, uint8 support) external override {\n emit VoteCast(_msgSender(), proposalId, support, castVoteInternal(_msgSender(), proposalId, support), \"\");\n }\n\n /**\n * @notice Cast a vote for a proposal with a reason\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param reason The reason given for the vote by the voter\n */\n function castVoteWithReason(\n uint256 proposalId,\n uint8 support,\n string calldata reason\n ) external override {\n emit VoteCast(_msgSender(), proposalId, support, castVoteInternal(_msgSender(), proposalId, support), reason);\n }\n\n /**\n * @notice Cast a vote for a proposal by signature\n * @dev external override function that accepts EIP-712 signatures for voting on proposals.\n */\n function castVoteBySig(\n uint256 proposalId,\n uint8 support,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"castVoteBySig: invalid signature\");\n emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), \"\");\n }\n\n /**\n * @notice Internal function that caries out voting logic\n * @param voter The voter that is casting their vote\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @return The number of votes cast\n */\n function castVoteInternal(\n address voter,\n uint256 proposalId,\n uint8 support\n ) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, \"voting is closed\");\n require(support <= 2, \"invalid vote type\");\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposalReceipts[proposalId][voter];\n require(receipt.hasVoted == false, \"voter already voted\");\n uint96 votes = ipt.getPriorVotes(voter, proposal.startBlock);\n\n if (support == 0) {\n proposal.againstVotes = proposal.againstVotes + votes;\n } else if (support == 1) {\n proposal.forVotes = proposal.forVotes + votes;\n } else if (support == 2) {\n proposal.abstainVotes = proposal.abstainVotes + votes;\n }\n\n receipt.hasVoted = true;\n receipt.support = support;\n receipt.votes = votes;\n\n return votes;\n }\n\n /**\n * @notice View function which returns if an account is whitelisted\n * @param account Account to check white list status of\n * @return If the account is whitelisted\n */\n function isWhitelisted(address account) public view override returns (bool) {\n return (whitelistAccountExpirations[account] > block.timestamp);\n }\n\n /**\n * @notice Governance function for setting the governance token\n * @param token_ new token addr\n */\n function _setNewToken(address token_) external onlyGov {\n ipt = IIpt(token_);\n }\n\n /**\n * @notice Used to update the timelock period\n * @param proposalTimelockDelay_ The proposal holding period\n */\n function _setDelay(uint256 proposalTimelockDelay_) public override onlyGov {\n uint256 oldTimelockDelay = proposalTimelockDelay;\n proposalTimelockDelay = proposalTimelockDelay_;\n\n emit NewDelay(oldTimelockDelay, proposalTimelockDelay);\n }\n\n /**\n * @notice Used to update the emergency timelock period\n * @param emergencyTimelockDelay_ The proposal holding period\n */\n function _setEmergencyDelay(uint256 emergencyTimelockDelay_) public override onlyGov {\n uint256 oldEmergencyTimelockDelay = emergencyTimelockDelay;\n emergencyTimelockDelay = emergencyTimelockDelay_;\n\n emit NewEmergencyDelay(oldEmergencyTimelockDelay, emergencyTimelockDelay);\n }\n\n /**\n * @notice Governance function for setting the voting delay\n * @param newVotingDelay new voting delay, in blocks\n */\n function _setVotingDelay(uint256 newVotingDelay) external override onlyGov {\n uint256 oldVotingDelay = votingDelay;\n votingDelay = newVotingDelay;\n\n emit VotingDelaySet(oldVotingDelay, votingDelay);\n }\n\n /**\n * @notice Governance function for setting the voting period\n * @param newVotingPeriod new voting period, in blocks\n */\n function _setVotingPeriod(uint256 newVotingPeriod) external override onlyGov {\n uint256 oldVotingPeriod = votingPeriod;\n votingPeriod = newVotingPeriod;\n\n emit VotingPeriodSet(oldVotingPeriod, votingPeriod);\n }\n\n /**\n * @notice Governance function for setting the emergency voting period\n * @param newEmergencyVotingPeriod new voting period, in blocks\n */\n function _setEmergencyVotingPeriod(uint256 newEmergencyVotingPeriod) external override onlyGov {\n uint256 oldEmergencyVotingPeriod = emergencyVotingPeriod;\n emergencyVotingPeriod = newEmergencyVotingPeriod;\n\n emit EmergencyVotingPeriodSet(oldEmergencyVotingPeriod, emergencyVotingPeriod);\n }\n\n /**\n * @notice Governance function for setting the proposal threshold\n * @param newProposalThreshold new proposal threshold\n */\n function _setProposalThreshold(uint256 newProposalThreshold) external override onlyGov {\n uint256 oldProposalThreshold = proposalThreshold;\n proposalThreshold = newProposalThreshold;\n\n emit ProposalThresholdSet(oldProposalThreshold, proposalThreshold);\n }\n\n /**\n * @notice Governance function for setting the quorum\n * @param newQuorumVotes new proposal quorum\n */\n function _setQuorumVotes(uint256 newQuorumVotes) external override onlyGov {\n uint256 oldQuorumVotes = quorumVotes;\n quorumVotes = newQuorumVotes;\n\n emit NewQuorum(oldQuorumVotes, quorumVotes);\n }\n\n /**\n * @notice Governance function for setting the emergency quorum\n * @param newEmergencyQuorumVotes new proposal quorum\n */\n function _setEmergencyQuorumVotes(uint256 newEmergencyQuorumVotes) external override onlyGov {\n uint256 oldEmergencyQuorumVotes = emergencyQuorumVotes;\n emergencyQuorumVotes = newEmergencyQuorumVotes;\n\n emit NewEmergencyQuorum(oldEmergencyQuorumVotes, emergencyQuorumVotes);\n }\n\n /**\n * @notice Governance function for setting the whitelist expiration as a timestamp\n * for an account. Whitelist status allows accounts to propose without meeting threshold\n * @param account Account address to set whitelist expiration for\n * @param expiration Expiration for account whitelist status as timestamp (if now < expiration, whitelisted)\n */\n function _setWhitelistAccountExpiration(address account, uint256 expiration) external override onlyGov {\n require (expiration < (maxWhitelistPeriod + block.timestamp), \"expiration exceeds max\");\n whitelistAccountExpirations[account] = expiration;\n\n emit WhitelistAccountExpirationSet(account, expiration);\n }\n\n /**\n * @notice Governance function for setting the whitelistGuardian. WhitelistGuardian can cancel proposals from whitelisted addresses\n * @param account Account to set whitelistGuardian to (0x0 to remove whitelistGuardian)\n */\n function _setWhitelistGuardian(address account) external override onlyGov {\n address oldGuardian = whitelistGuardian;\n whitelistGuardian = account;\n\n emit WhitelistGuardianSet(oldGuardian, whitelistGuardian);\n }\n\n /**\n * @notice Governance function for setting the optimistic voting delay\n * @param newOptimisticVotingDelay new optimistic voting delay, in blocks\n */\n function _setOptimisticDelay(uint256 newOptimisticVotingDelay) external override onlyGov {\n uint256 oldOptimisticVotingDelay = optimisticVotingDelay;\n optimisticVotingDelay = newOptimisticVotingDelay;\n\n emit OptimisticVotingDelaySet(oldOptimisticVotingDelay, optimisticVotingDelay);\n }\n\n /**\n * @notice Governance function for setting the optimistic quorum\n * @param newOptimisticQuorumVotes new optimistic quorum votes, in blocks\n */\n function _setOptimisticQuorumVotes(uint256 newOptimisticQuorumVotes) external override onlyGov {\n uint256 oldOptimisticQuorumVotes = optimisticQuorumVotes;\n optimisticQuorumVotes = newOptimisticQuorumVotes;\n\n emit OptimisticQuorumVotesSet(oldOptimisticQuorumVotes, optimisticQuorumVotes);\n }\n\n function getChainIdInternal() internal view returns (uint256) {\n return block.chainid;\n }\n\n function getBlockTimestamp() internal view returns (uint256) {\n // solium-disable-next-line security/no-block-members\n return block.timestamp;\n }\n\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200, + "details": { + "orderLiterals": true, + "deduplicate": true, + "cse": true, + "yul": true + } + }, + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + }, + "libraries": {} + } + }, + "ABI": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"CancelTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyVotingPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"EmergencyVotingPeriodSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"ExecuteTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"NewAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimelockDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"proposalTimelockDelay\",\"type\":\"uint256\"}],\"name\":\"NewDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyTimelockDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyTimelockDelay\",\"type\":\"uint256\"}],\"name\":\"NewEmergencyDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"NewEmergencyQuorum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"NewImplementation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"NewPendingAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"quorumVotes\",\"type\":\"uint256\"}],\"name\":\"NewQuorum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOptimisticQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"OptimisticQuorumVotesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOptimisticVotingDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticVotingDelay\",\"type\":\"uint256\"}],\"name\":\"OptimisticVotingDelaySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"ProposalCanceled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"proposer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"indexed\":false,\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"startBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"endBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"}],\"name\":\"ProposalCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"ProposalExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"ProposalQueued\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldProposalThreshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newProposalThreshold\",\"type\":\"uint256\"}],\"name\":\"ProposalThresholdSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"QueueTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"voter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"votes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"VoteCast\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldVotingDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newVotingDelay\",\"type\":\"uint256\"}],\"name\":\"VotingDelaySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldVotingPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"VotingPeriodSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"expiration\",\"type\":\"uint256\"}],\"name\":\"WhitelistAccountExpirationSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldGuardian\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGuardian\",\"type\":\"address\"}],\"name\":\"WhitelistGuardianSet\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BALLOT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalTimelockDelay_\",\"type\":\"uint256\"}],\"name\":\"_setDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"emergencyTimelockDelay_\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newEmergencyQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newEmergencyVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyVotingPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"_setNewToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newOptimisticVotingDelay\",\"type\":\"uint256\"}],\"name\":\"_setOptimisticDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newOptimisticQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setOptimisticQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newProposalThreshold\",\"type\":\"uint256\"}],\"name\":\"_setProposalThreshold\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newVotingDelay\",\"type\":\"uint256\"}],\"name\":\"_setVotingDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"_setVotingPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"expiration\",\"type\":\"uint256\"}],\"name\":\"_setWhitelistAccountExpiration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"_setWhitelistGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"cancel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"}],\"name\":\"castVote\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"castVoteBySig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"castVoteWithReason\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyQuorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyTimelockDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyVotingPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"execute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"executeTransaction\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"getActions\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"voter\",\"type\":\"address\"}],\"name\":\"getReceipt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"hasVoted\",\"type\":\"bool\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"internalType\":\"struct Receipt\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialProposalId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ipt_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ipt\",\"outputs\":[{\"internalType\":\"contract IIpt\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"latestProposalIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxWhitelistPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticQuorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticVotingDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalMaxOperations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"proposalReceipts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"hasVoted\",\"type\":\"bool\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalTimelockDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"proposals\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"proposer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"startBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"endBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"forVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"againstVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"abstainVotes\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"canceled\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"executed\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"emergency\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"quorumVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"emergency\",\"type\":\"bool\"}],\"name\":\"propose\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"queue\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"queuedTransactions\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"quorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"state\",\"outputs\":[{\"internalType\":\"enum ProposalState\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"whitelistAccountExpirations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"whitelistGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + "ContractName": "GovernorCharlieDelegate", + "CompilerVersion": "v0.8.9+commit.e5eed63a", + "OptimizationUsed": 1, + "Runs": 200, + "ConstructorArguments": "0x", + "EVMVersion": "Default", + "Library": "", + "LicenseType": "", + "Proxy": 0, + "SwarmSource": "" + } +] \ No newline at end of file diff --git a/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json new file mode 100644 index 0000000000000..d145e56aa8881 --- /dev/null +++ b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0x9ab6b21cdf116f611110b048987e58894786c244", + "contractCreator": "0x603d50bad151da8becf405e51a8c4abc8ba1c95e", + "txHash": "0x72be611ae1ade09242d9fc9c950a73d076f6c23514564a7b9ac730400dbaf2c0" +} \ No newline at end of file diff --git a/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json new file mode 100644 index 0000000000000..ab133f38ff7a1 --- /dev/null +++ b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json @@ -0,0 +1,69 @@ +[ + { + "SourceCode": { + "language": "Solidity", + "sources": { + "contracts/InterestRates/InterestRatePositionManager.f.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n/// Parameters for ERC20Permit.permit call\nstruct ERC20PermitSignature {\n IERC20Permit token;\n uint256 value;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\nlibrary PermitHelper {\n function applyPermit(\n ERC20PermitSignature calldata p,\n address owner,\n address spender\n ) internal {\n p.token.permit(owner, spender, p.value, p.deadline, p.v, p.r, p.s);\n }\n\n function applyPermits(\n ERC20PermitSignature[] calldata permits,\n address owner,\n address spender\n ) internal {\n for (uint256 i = 0; i < permits.length; i++) {\n applyPermit(permits[i], owner, spender);\n }\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashLender.sol)\n\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol)\n\n/**\n * @dev Interface of the ERC3156 FlashBorrower, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashBorrower {\n /**\n * @dev Receive a flash loan.\n * @param initiator The initiator of the loan.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @param fee The additional amount of tokens to repay.\n * @param data Arbitrary data structure, intended to contain user-defined parameters.\n * @return The keccak256 hash of \"IERC3156FlashBorrower.onFlashLoan\"\n */\n function onFlashLoan(\n address initiator,\n address token,\n uint256 amount,\n uint256 fee,\n bytes calldata data\n ) external returns (bytes32);\n}\n\n/**\n * @dev Interface of the ERC3156 FlashLender, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashLender {\n /**\n * @dev The amount of currency available to be lended.\n * @param token The loan currency.\n * @return The amount of `token` that can be borrowed.\n */\n function maxFlashLoan(address token) external view returns (uint256);\n\n /**\n * @dev The fee to be charged for a given loan.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @return The amount of `token` to be charged for the loan, on top of the returned principal.\n */\n function flashFee(address token, uint256 amount) external view returns (uint256);\n\n /**\n * @dev Initiate a flash loan.\n * @param receiver The receiver of the tokens in the loan, and the receiver of the callback.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @param data Arbitrary data structure, intended to contain user-defined parameters.\n */\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n ) external returns (bool);\n}\n\n/// @dev Interface to be used by contracts that collect fees. Contains fee recipient that can be changed by owner.\ninterface IFeeCollector {\n // --- Events ---\n\n /// @dev Fee Recipient is changed to @param feeRecipient address.\n /// @param feeRecipient New fee recipient address.\n event FeeRecipientChanged(address feeRecipient);\n\n // --- Errors ---\n\n /// @dev Invalid fee recipient.\n error InvalidFeeRecipient();\n\n // --- Functions ---\n\n /// @return Address of the current fee recipient.\n function feeRecipient() external view returns (address);\n\n /// @dev Sets new fee recipient address\n /// @param newFeeRecipient Address of the new fee recipient.\n function setFeeRecipient(address newFeeRecipient) external;\n}\n\ninterface IPositionManagerDependent {\n // --- Errors ---\n\n /// @dev Position Manager cannot be zero.\n error PositionManagerCannotBeZero();\n\n /// @dev Caller is not Position Manager.\n error CallerIsNotPositionManager(address caller);\n\n // --- Functions ---\n\n /// @dev Returns address of the PositionManager contract.\n function positionManager() external view returns (address);\n}\n\n/// @dev Interface of R stablecoin token. Implements some standards like IERC20, IERC20Permit, and IERC3156FlashLender.\n/// Raft's specific implementation contains IFeeCollector and IPositionManagerDependent.\n/// PositionManager can mint and burn R when particular actions happen with user's position.\ninterface IRToken is IERC20, IERC20Permit, IERC3156FlashLender, IFeeCollector, IPositionManagerDependent {\n // --- Events ---\n\n /// @dev New R token is deployed\n /// @param positionManager Address of the PositionManager contract that is authorized to mint and burn new tokens.\n /// @param flashMintFeeRecipient Address of flash mint fee recipient.\n event RDeployed(address positionManager, address flashMintFeeRecipient);\n\n /// @dev The Flash Mint Fee Percentage has been changed.\n /// @param flashMintFeePercentage The new Flash Mint Fee Percentage value.\n event FlashMintFeePercentageChanged(uint256 flashMintFeePercentage);\n\n /// --- Errors ---\n\n /// @dev Proposed flash mint fee percentage is too big.\n /// @param feePercentage Proposed flash mint fee percentage.\n error FlashFeePercentageTooBig(uint256 feePercentage);\n\n // --- Functions ---\n\n /// @return Number representing 100 percentage.\n function PERCENTAGE_BASE() external view returns (uint256);\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param to Address that will receive newly minted tokens.\n /// @param amount Amount of tokens to mint.\n function mint(address to, uint256 amount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param from Address of user whose tokens are burnt.\n /// @param amount Amount of tokens to burn.\n function burn(address from, uint256 amount) external;\n\n /// @return Maximum flash mint fee percentage that can be set by owner.\n function MAX_FLASH_MINT_FEE_PERCENTAGE() external view returns (uint256);\n\n /// @return Current flash mint fee percentage.\n function flashMintFeePercentage() external view returns (uint256);\n\n /// @dev Sets new flash mint fee percentage. Callable only by owner.\n /// @notice The proposed flash mint fee percentage cannot exceed `MAX_FLASH_MINT_FEE_PERCENTAGE`.\n /// @param feePercentage New flash fee percentage.\n function setFlashMintFeePercentage(uint256 feePercentage) external;\n}\n\ninterface IPriceOracle {\n // --- Errors ---\n\n /// @dev Contract initialized with an invalid deviation parameter.\n error InvalidDeviation();\n\n // --- Types ---\n\n struct PriceOracleResponse {\n bool isBrokenOrFrozen;\n bool priceChangeAboveMax;\n uint256 price;\n }\n\n // --- Functions ---\n\n /// @dev Return price oracle response which consists the following information: oracle is broken or frozen, the\n /// price change between two rounds is more than max, and the price.\n function getPriceOracleResponse() external returns (PriceOracleResponse memory);\n\n /// @dev Maximum time period allowed since oracle latest round data timestamp, beyond which oracle is considered\n /// frozen.\n function timeout() external view returns (uint256);\n\n /// @dev Used to convert a price answer to an 18-digit precision uint.\n function TARGET_DIGITS() external view returns (uint256);\n\n /// @dev price deviation for the oracle in percentage.\n function DEVIATION() external view returns (uint256);\n}\n\ninterface IPriceFeed {\n // --- Events ---\n\n /// @dev Last good price has been updated.\n event LastGoodPriceUpdated(uint256 lastGoodPrice);\n\n /// @dev Price difference between oracles has been updated.\n /// @param priceDifferenceBetweenOracles New price difference between oracles.\n event PriceDifferenceBetweenOraclesUpdated(uint256 priceDifferenceBetweenOracles);\n\n /// @dev Primary oracle has been updated.\n /// @param primaryOracle New primary oracle.\n event PrimaryOracleUpdated(IPriceOracle primaryOracle);\n\n /// @dev Secondary oracle has been updated.\n /// @param secondaryOracle New secondary oracle.\n event SecondaryOracleUpdated(IPriceOracle secondaryOracle);\n\n // --- Errors ---\n\n /// @dev Invalid primary oracle.\n error InvalidPrimaryOracle();\n\n /// @dev Invalid secondary oracle.\n error InvalidSecondaryOracle();\n\n /// @dev Primary oracle is broken or frozen or has bad result.\n error PrimaryOracleBrokenOrFrozenOrBadResult();\n\n /// @dev Invalid price difference between oracles.\n error InvalidPriceDifferenceBetweenOracles();\n\n // --- Functions ---\n\n /// @dev Return primary oracle address.\n function primaryOracle() external returns (IPriceOracle);\n\n /// @dev Return secondary oracle address\n function secondaryOracle() external returns (IPriceOracle);\n\n /// @dev The last good price seen from an oracle by Raft.\n function lastGoodPrice() external returns (uint256);\n\n /// @dev The maximum relative price difference between two oracle responses.\n function priceDifferenceBetweenOracles() external returns (uint256);\n\n /// @dev Set primary oracle address.\n /// @param newPrimaryOracle Primary oracle address.\n function setPrimaryOracle(IPriceOracle newPrimaryOracle) external;\n\n /// @dev Set secondary oracle address.\n /// @param newSecondaryOracle Secondary oracle address.\n function setSecondaryOracle(IPriceOracle newSecondaryOracle) external;\n\n /// @dev Set the maximum relative price difference between two oracle responses.\n /// @param newPriceDifferenceBetweenOracles The maximum relative price difference between two oracle responses.\n function setPriceDifferenceBetweenOracles(uint256 newPriceDifferenceBetweenOracles) external;\n\n /// @dev Returns the latest price obtained from the Oracle. Called by Raft functions that require a current price.\n ///\n /// Also callable by anyone externally.\n /// Non-view function - it stores the last good price seen by Raft.\n ///\n /// Uses a primary oracle and a fallback oracle in case primary fails. If both fail,\n /// it uses the last good price seen by Raft.\n ///\n /// @return currentPrice Returned price.\n /// @return deviation Deviation of the reported price in percentage.\n /// @notice Actual returned price is in range `currentPrice` +/- `currentPrice * deviation / ONE`\n function fetchPrice() external returns (uint256 currentPrice, uint256 deviation);\n}\n\ninterface IERC20Indexable is IERC20, IPositionManagerDependent {\n // --- Events ---\n\n /// @dev New token is deployed.\n /// @param positionManager Address of the PositionManager contract that is authorized to mint and burn new tokens.\n event ERC20IndexableDeployed(address positionManager);\n\n /// @dev New index has been set.\n /// @param newIndex Value of the new index.\n event IndexUpdated(uint256 newIndex);\n\n // --- Errors ---\n\n /// @dev Unsupported action for ERC20Indexable contract.\n error NotSupported();\n\n // --- Functions ---\n\n /// @return Precision for token index. Represents index that is equal to 1.\n function INDEX_PRECISION() external view returns (uint256);\n\n /// @return Current index value.\n function currentIndex() external view returns (uint256);\n\n /// @dev Sets new token index. Callable only by PositionManager contract.\n /// @param backingAmount Amount of backing token that is covered by total supply.\n function setIndex(uint256 backingAmount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param to Address that will receive newly minted tokens.\n /// @param amount Amount of tokens to mint.\n function mint(address to, uint256 amount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param from Address of user whose tokens are burnt.\n /// @param amount Amount of tokens to burn.\n function burn(address from, uint256 amount) external;\n}\n\ninterface ISplitLiquidationCollateral {\n // --- Functions ---\n\n /// @dev Returns lowest total debt that will be split.\n function LOW_TOTAL_DEBT() external view returns (uint256);\n\n /// @dev Minimum collateralization ratio for position\n function MCR() external view returns (uint256);\n\n /// @dev Splits collateral between protocol and liquidator.\n /// @param totalCollateral Amount of collateral to split.\n /// @param totalDebt Amount of debt to split.\n /// @param price Price of collateral.\n /// @param isRedistribution True if this is a redistribution.\n /// @return collateralToSendToProtocol Amount of collateral to send to protocol.\n /// @return collateralToSentToLiquidator Amount of collateral to send to liquidator.\n function split(\n uint256 totalCollateral,\n uint256 totalDebt,\n uint256 price,\n bool isRedistribution\n )\n external\n view\n returns (uint256 collateralToSendToProtocol, uint256 collateralToSentToLiquidator);\n}\n\n/// @dev Common interface for the Position Manager.\ninterface IPositionManager is IFeeCollector {\n // --- Types ---\n\n /// @dev Information for a Raft indexable collateral token.\n /// @param collateralToken The Raft indexable collateral token.\n /// @param debtToken Corresponding Raft indexable debt token.\n /// @param priceFeed The contract that provides a price for the collateral token.\n /// @param splitLiquidation The contract that calculates collateral split in case of liquidation.\n /// @param isEnabled Whether the token can be used as collateral or not.\n /// @param lastFeeOperationTime Timestamp of the last operation for the collateral token.\n /// @param borrowingSpread The current borrowing spread.\n /// @param baseRate The current base rate.\n /// @param redemptionSpread The current redemption spread.\n /// @param redemptionRebate Percentage of the redemption fee returned to redeemed positions.\n struct CollateralTokenInfo {\n IERC20Indexable collateralToken;\n IERC20Indexable debtToken;\n IPriceFeed priceFeed;\n ISplitLiquidationCollateral splitLiquidation;\n bool isEnabled;\n uint256 lastFeeOperationTime;\n uint256 borrowingSpread;\n uint256 baseRate;\n uint256 redemptionSpread;\n uint256 redemptionRebate;\n }\n\n // --- Events ---\n\n /// @dev New position manager has been token deployed.\n /// @param rToken The R token used by the position manager.\n /// @param feeRecipient The address of fee recipient.\n event PositionManagerDeployed(IRToken rToken, address feeRecipient);\n\n /// @dev New collateral token has been added added to the system.\n /// @param collateralToken The token used as collateral.\n /// @param raftCollateralToken The Raft indexable collateral token for the given collateral token.\n /// @param raftDebtToken The Raft indexable debt token for given collateral token.\n /// @param priceFeed The contract that provides price for the collateral token.\n event CollateralTokenAdded(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n IPriceFeed priceFeed\n );\n\n /// @dev Collateral token has been enabled or disabled.\n /// @param collateralToken The token used as collateral.\n /// @param isEnabled True if the token is enabled, false otherwise.\n event CollateralTokenModified(IERC20 collateralToken, bool isEnabled);\n\n /// @dev A delegate has been whitelisted for a certain position.\n /// @param position The position for which the delegate was whitelisted.\n /// @param delegate The delegate which was whitelisted.\n /// @param whitelisted Specifies whether the delegate whitelisting has been enabled (true) or disabled (false).\n event DelegateWhitelisted(address indexed position, address indexed delegate, bool whitelisted);\n\n /// @dev New position has been created.\n /// @param position The address of the user opening new position.\n /// @param collateralToken The token used as collateral for the created position.\n event PositionCreated(address indexed position, IERC20 indexed collateralToken);\n\n /// @dev The position has been closed by either repayment, liquidation, or redemption.\n /// @param position The address of the user whose position is closed.\n event PositionClosed(address indexed position);\n\n /// @dev Collateral amount for the position has been changed.\n /// @param position The address of the user that has opened the position.\n /// @param collateralToken The address of the collateral token being added to position.\n /// @param collateralAmount The amount of collateral added or removed.\n /// @param isCollateralIncrease Whether the collateral is added to the position or removed from it.\n event CollateralChanged(\n address indexed position, IERC20 indexed collateralToken, uint256 collateralAmount, bool isCollateralIncrease\n );\n\n /// @dev Debt amount for position has been changed.\n /// @param position The address of the user that has opened the position.\n /// @param collateralToken The address of the collateral token backing the debt.\n /// @param debtAmount The amount of debt added or removed.\n /// @param isDebtIncrease Whether the debt is added to the position or removed from it.\n event DebtChanged(\n address indexed position, IERC20 indexed collateralToken, uint256 debtAmount, bool isDebtIncrease\n );\n\n /// @dev Borrowing fee has been paid. Emitted only if the actual fee was paid - doesn't happen with no fees are\n /// paid.\n /// @param collateralToken Collateral token used to mint R.\n /// @param position The address of position's owner that triggered the fee payment.\n /// @param feeAmount The amount of tokens paid as the borrowing fee.\n event RBorrowingFeePaid(IERC20 collateralToken, address indexed position, uint256 feeAmount);\n\n /// @dev Liquidation has been executed.\n /// @param liquidator The liquidator that executed the liquidation.\n /// @param position The address of position's owner whose position was liquidated.\n /// @param collateralToken The collateral token used for the liquidation.\n /// @param debtLiquidated The total debt that was liquidated or redistributed.\n /// @param collateralLiquidated The total collateral liquidated.\n /// @param collateralSentToLiquidator The collateral amount sent to the liquidator.\n /// @param collateralLiquidationFeePaid The total collateral paid as the liquidation fee to the fee recipient.\n /// @param isRedistribution Whether the executed liquidation was redistribution or not.\n event Liquidation(\n address indexed liquidator,\n address indexed position,\n IERC20 indexed collateralToken,\n uint256 debtLiquidated,\n uint256 collateralLiquidated,\n uint256 collateralSentToLiquidator,\n uint256 collateralLiquidationFeePaid,\n bool isRedistribution\n );\n\n /// @dev Redemption has been executed.\n /// @param redeemer User that redeemed R.\n /// @param amount Amount of R that was redeemed.\n /// @param collateralSent The amount of collateral sent to the redeemer.\n /// @param fee The amount of fee paid to the fee recipient.\n /// @param rebate Redemption rebate amount.\n event Redemption(address indexed redeemer, uint256 amount, uint256 collateralSent, uint256 fee, uint256 rebate);\n\n /// @dev Borrowing spread has been updated.\n /// @param borrowingSpread The new borrowing spread.\n event BorrowingSpreadUpdated(uint256 borrowingSpread);\n\n /// @dev Redemption rebate has been updated.\n /// @param redemptionRebate The new redemption rebate.\n event RedemptionRebateUpdated(uint256 redemptionRebate);\n\n /// @dev Redemption spread has been updated.\n /// @param collateralToken Collateral token that the spread was set for.\n /// @param redemptionSpread The new redemption spread.\n event RedemptionSpreadUpdated(IERC20 collateralToken, uint256 redemptionSpread);\n\n /// @dev Base rate has been updated.\n /// @param collateralToken Collateral token that the baser rate was updated for.\n /// @param baseRate The new base rate.\n event BaseRateUpdated(IERC20 collateralToken, uint256 baseRate);\n\n /// @dev Last fee operation time has been updated.\n /// @param collateralToken Collateral token that the baser rate was updated for.\n /// @param lastFeeOpTime The new operation time.\n event LastFeeOpTimeUpdated(IERC20 collateralToken, uint256 lastFeeOpTime);\n\n /// @dev Split liquidation collateral has been changed.\n /// @param collateralToken Collateral token whose split liquidation collateral contract is set.\n /// @param newSplitLiquidationCollateral New value that was set to be split liquidation collateral.\n event SplitLiquidationCollateralChanged(\n IERC20 collateralToken, ISplitLiquidationCollateral indexed newSplitLiquidationCollateral\n );\n\n // --- Errors ---\n\n /// @dev Max fee percentage must be between borrowing spread and 100%.\n error InvalidMaxFeePercentage();\n\n /// @dev Max fee percentage must be between 0.5% and 100%.\n error MaxFeePercentageOutOfRange();\n\n /// @dev Amount is zero.\n error AmountIsZero();\n\n /// @dev Nothing to liquidate.\n error NothingToLiquidate();\n\n /// @dev Cannot liquidate last position.\n error CannotLiquidateLastPosition();\n\n /// @dev Cannot redeem collateral below minimum debt threshold.\n /// @param collateralToken Collateral token used to redeem.\n /// @param newTotalDebt New total debt backed by collateral, which is lower than minimum debt.\n error TotalDebtCannotBeLowerThanMinDebt(IERC20 collateralToken, uint256 newTotalDebt);\n\n /// @dev Cannot redeem collateral\n /// @param collateralToken Collateral token used to redeem.\n /// @param newTotalCollateral New total collateral, which is lower than minimum collateral.\n /// @param minimumCollateral Minimum collateral required to complete redeem\n error TotalCollateralCannotBeLowerThanMinCollateral(\n IERC20 collateralToken, uint256 newTotalCollateral, uint256 minimumCollateral\n );\n\n /// @dev Fee would eat up all returned collateral.\n error FeeEatsUpAllReturnedCollateral();\n\n /// @dev Borrowing spread exceeds maximum.\n error BorrowingSpreadExceedsMaximum();\n\n /// @dev Redemption rebate exceeds maximum.\n error RedemptionRebateExceedsMaximum();\n\n /// @dev Redemption spread is out of allowed range.\n error RedemptionSpreadOutOfRange();\n\n /// @dev There must be either a collateral change or a debt change.\n error NoCollateralOrDebtChange();\n\n /// @dev There is some collateral for position that doesn't have debt.\n error InvalidPosition();\n\n /// @dev An operation that would result in ICR < MCR is not permitted.\n /// @param newICR Resulting ICR that is below MCR.\n error NewICRLowerThanMCR(uint256 newICR);\n\n /// @dev Position's net debt must be greater than minimum.\n /// @param netDebt Net debt amount that is below minimum.\n error NetDebtBelowMinimum(uint256 netDebt);\n\n /// @dev The provided delegate address is invalid.\n error InvalidDelegateAddress();\n\n /// @dev A non-whitelisted delegate cannot adjust positions.\n error DelegateNotWhitelisted();\n\n /// @dev Fee exceeded provided maximum fee percentage.\n /// @param fee The fee amount.\n /// @param amount The amount of debt or collateral.\n /// @param maxFeePercentage The maximum fee percentage.\n error FeeExceedsMaxFee(uint256 fee, uint256 amount, uint256 maxFeePercentage);\n\n /// @dev Borrower uses a different collateral token already.\n error PositionCollateralTokenMismatch();\n\n /// @dev Collateral token address cannot be zero.\n error CollateralTokenAddressCannotBeZero();\n\n /// @dev Price feed address cannot be zero.\n error PriceFeedAddressCannotBeZero();\n\n /// @dev Collateral token already added.\n error CollateralTokenAlreadyAdded();\n\n /// @dev Collateral token is not added.\n error CollateralTokenNotAdded();\n\n /// @dev Collateral token is not enabled.\n error CollateralTokenDisabled();\n\n /// @dev Split liquidation collateral cannot be zero.\n error SplitLiquidationCollateralCannotBeZero();\n\n /// @dev Cannot change collateral in case of repaying the whole debt.\n error WrongCollateralParamsForFullRepayment();\n\n // --- Functions ---\n\n /// @return The R token used by position manager.\n function rToken() external view returns (IRToken);\n\n /// @dev Retrieves information about certain collateral type.\n /// @param collateralToken The token used as collateral.\n /// @return raftCollateralToken The Raft indexable collateral token.\n /// @return raftDebtToken The Raft indexable debt token.\n /// @return priceFeed The contract that provides a price for the collateral token.\n /// @return splitLiquidation The contract that calculates collateral split in case of liquidation.\n /// @return isEnabled Whether the collateral token can be used as collateral or not.\n /// @return lastFeeOperationTime Timestamp of the last operation for the collateral token.\n /// @return borrowingSpread The current borrowing spread.\n /// @return baseRate The current base rate.\n /// @return redemptionSpread The current redemption spread.\n /// @return redemptionRebate Percentage of the redemption fee returned to redeemed positions.\n function collateralInfo(IERC20 collateralToken)\n external\n view\n returns (\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral splitLiquidation,\n bool isEnabled,\n uint256 lastFeeOperationTime,\n uint256 borrowingSpread,\n uint256 baseRate,\n uint256 redemptionSpread,\n uint256 redemptionRebate\n );\n\n /// @param collateralToken Collateral token whose raft collateral indexable token is being queried.\n /// @return Raft collateral token address for given collateral token.\n function raftCollateralToken(IERC20 collateralToken) external view returns (IERC20Indexable);\n\n /// @param collateralToken Collateral token whose raft collateral indexable token is being queried.\n /// @return Raft debt token address for given collateral token.\n function raftDebtToken(IERC20 collateralToken) external view returns (IERC20Indexable);\n\n /// @param collateralToken Collateral token whose price feed contract is being queried.\n /// @return Price feed contract address for given collateral token.\n function priceFeed(IERC20 collateralToken) external view returns (IPriceFeed);\n\n /// @param collateralToken Collateral token whose split liquidation collateral is being queried.\n /// @return Returns address of the split liquidation collateral contract.\n function splitLiquidationCollateral(IERC20 collateralToken) external view returns (ISplitLiquidationCollateral);\n\n /// @param collateralToken Collateral token whose split liquidation collateral is being queried.\n /// @return Returns whether collateral is enabled or nor.\n function collateralEnabled(IERC20 collateralToken) external view returns (bool);\n\n /// @param collateralToken Collateral token we query last operation time fee for.\n /// @return The timestamp of the latest fee operation (redemption or new R issuance).\n function lastFeeOperationTime(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query borrowing spread for.\n /// @return The current borrowing spread.\n function borrowingSpread(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query base rate for.\n /// @return rate The base rate.\n function baseRate(IERC20 collateralToken) external view returns (uint256 rate);\n\n /// @param collateralToken Collateral token we query redemption spread for.\n /// @return The current redemption spread for collateral token.\n function redemptionSpread(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query redemption rebate for.\n /// @return rebate Percentage of the redemption fee returned to redeemed positions.\n function redemptionRebate(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query redemption rate for.\n /// @return rate The current redemption rate for collateral token.\n function getRedemptionRate(IERC20 collateralToken) external view returns (uint256 rate);\n\n /// @dev Returns the collateral token that a given position used for their position.\n /// @param position The address of the borrower.\n /// @return collateralToken The collateral token of the borrower's position.\n function collateralTokenForPosition(address position) external view returns (IERC20 collateralToken);\n\n /// @dev Adds a new collateral token to the protocol.\n /// @param collateralToken The new collateral token.\n /// @param priceFeed The price feed for the collateral token.\n /// @param newSplitLiquidationCollateral split liquidation collateral contract address.\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n external;\n\n /// @dev Adds a new collateral token to the protocol.\n /// @param collateralToken The new collateral token.\n /// @param priceFeed The price feed for the collateral token.\n /// @param newSplitLiquidationCollateral split liquidation collateral contract address.\n /// @param raftCollateralToken_ Address of raft collateral token.\n /// @param raftDebtToken_ Address of raft debt token.\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral,\n IERC20Indexable raftCollateralToken_,\n IERC20Indexable raftDebtToken_\n )\n external;\n\n /// @dev Enables or disables a collateral token. Reverts if the collateral token has not been added.\n /// @param collateralToken The collateral token.\n /// @param isEnabled Whether the collateral token can be used as collateral or not.\n function setCollateralEnabled(IERC20 collateralToken, bool isEnabled) external;\n\n /// @dev Sets the new split liquidation collateral contract.\n /// @param collateralToken Collateral token whose split liquidation collateral is being set.\n /// @param newSplitLiquidationCollateral New split liquidation collateral contract address.\n function setSplitLiquidationCollateral(\n IERC20 collateralToken,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n external;\n\n /// @dev Liquidates the borrower if its position's ICR is lower than the minimum collateral ratio.\n /// @param position The address of the borrower.\n function liquidate(address position) external;\n\n /// @dev Redeems the collateral token for a given debt amount. It sends @param debtAmount R to the system and\n /// redeems the corresponding amount of collateral from as many positions as are needed to fill the redemption\n /// request.\n /// @param collateralToken The token used as collateral.\n /// @param debtAmount The amount of debt to be redeemed. Must be greater than zero.\n /// @param maxFeePercentage The maximum fee percentage to pay for the redemption.\n function redeemCollateral(IERC20 collateralToken, uint256 debtAmount, uint256 maxFeePercentage) external;\n\n /// @dev Manages the position on behalf of a given borrower.\n /// @param collateralToken The token the borrower used as collateral.\n /// @param position The address of the borrower.\n /// @param collateralChange The amount of collateral to add or remove.\n /// @param isCollateralIncrease True if the collateral is being increased, false otherwise.\n /// @param debtChange The amount of R to add or remove. In case of repayment (isDebtIncrease = false)\n /// `type(uint256).max` value can be used to repay the whole outstanding loan.\n /// @param isDebtIncrease True if the debt is being increased, false otherwise.\n /// @param maxFeePercentage The maximum fee percentage to pay for the position management.\n /// @param permitSignature Optional permit signature for tokens that support IERC20Permit interface.\n /// @notice `permitSignature` it is ignored if permit signature is not for `collateralToken`.\n /// @notice In case of full debt repayment, `isCollateralIncrease` is ignored and `collateralChange` must be 0.\n /// These values are set to `false`(collateral decrease), and the whole collateral balance of the user.\n /// @return actualCollateralChange Actual amount of collateral added/removed.\n /// Can be different to `collateralChange` in case of full repayment.\n /// @return actualDebtChange Actual amount of debt added/removed.\n /// Can be different to `debtChange` in case of passing type(uint256).max as `debtChange`.\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n external\n returns (uint256 actualCollateralChange, uint256 actualDebtChange);\n\n /// @return The max borrowing spread.\n function MAX_BORROWING_SPREAD() external view returns (uint256);\n\n /// @return The max borrowing rate.\n function MAX_BORROWING_RATE() external view returns (uint256);\n\n /// @dev Sets the new borrowing spread.\n /// @param collateralToken Collateral token we set borrowing spread for.\n /// @param newBorrowingSpread New borrowing spread to be used.\n function setBorrowingSpread(IERC20 collateralToken, uint256 newBorrowingSpread) external;\n\n /// @param collateralToken Collateral token we query borrowing rate for.\n /// @return The current borrowing rate.\n function getBorrowingRate(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query borrowing rate with decay for.\n /// @return The current borrowing rate with decay.\n function getBorrowingRateWithDecay(IERC20 collateralToken) external view returns (uint256);\n\n /// @dev Returns the borrowing fee for a given debt amount.\n /// @param collateralToken Collateral token we query borrowing fee for.\n /// @param debtAmount The amount of debt.\n /// @return The borrowing fee.\n function getBorrowingFee(IERC20 collateralToken, uint256 debtAmount) external view returns (uint256);\n\n /// @dev Sets the new redemption spread.\n /// @param newRedemptionSpread New redemption spread to be used.\n function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) external;\n\n /// @dev Sets new redemption rebate percentage.\n /// @param newRedemptionRebate Value that is being set as a redemption rebate percentage.\n function setRedemptionRebate(IERC20 collateralToken, uint256 newRedemptionRebate) external;\n\n /// @param collateralToken Collateral token we query redemption rate with decay for.\n /// @return The current redemption rate with decay.\n function getRedemptionRateWithDecay(IERC20 collateralToken) external view returns (uint256);\n\n /// @dev Returns the redemption fee for a given collateral amount.\n /// @param collateralToken Collateral token we query redemption fee for.\n /// @param collateralAmount The amount of collateral.\n /// @param priceDeviation Deviation for the reported price by oracle in percentage.\n /// @return The redemption fee.\n function getRedemptionFee(\n IERC20 collateralToken,\n uint256 collateralAmount,\n uint256 priceDeviation\n )\n external\n view\n returns (uint256);\n\n /// @dev Returns the redemption fee with decay for a given collateral amount.\n /// @param collateralToken Collateral token we query redemption fee with decay for.\n /// @param collateralAmount The amount of collateral.\n /// @return The redemption fee with decay.\n function getRedemptionFeeWithDecay(\n IERC20 collateralToken,\n uint256 collateralAmount\n )\n external\n view\n returns (uint256);\n\n /// @return Half-life of 12h (720 min).\n /// @dev (1/2) = d^720 => d = (1/2)^(1/720)\n function MINUTE_DECAY_FACTOR() external view returns (uint256);\n\n /// @dev Returns if a given delegate is whitelisted for a given borrower.\n /// @param position The address of the borrower.\n /// @param delegate The address of the delegate.\n /// @return isWhitelisted True if the delegate is whitelisted for a given borrower, false otherwise.\n function isDelegateWhitelisted(address position, address delegate) external view returns (bool isWhitelisted);\n\n /// @dev Whitelists a delegate.\n /// @param delegate The address of the delegate.\n /// @param whitelisted True if delegate is being whitelisted, false otherwise.\n function whitelistDelegate(address delegate, bool whitelisted) external;\n\n /// @return Parameter by which to divide the redeemed fraction, in order to calc the new base rate from a\n /// redemption. Corresponds to (1 / ALPHA) in the white paper.\n function BETA() external view returns (uint256);\n}\n\n/// @dev Common interface for the Position Manager.\ninterface IInterestRatePositionManager is IPositionManager {\n // --- Events ---\n\n /// @dev Fees coming from accrued interest are minted.\n /// @param collateralToken Collateral token that fees are paid for.\n /// @param amount Amount of R minted.\n event MintedFees(IERC20 collateralToken, uint256 amount);\n\n // --- Errors ---\n\n /// @dev Only registered debt token can be caller.\n /// @param sender Actual caller.\n error InvalidDebtToken(address sender);\n\n // --- Functions ---\n\n /// @dev Mints fees coming from accrued interest. Can be called only from matching debt token.\n /// @param collateralToken Collateral token to mint fees for.\n /// @param amount Amount of R to mint.\n function mintFees(IERC20 collateralToken, uint256 amount) external;\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n\nlibrary Fixed256x18 {\n uint256 internal constant ONE = 1e18; // 18 decimal places\n\n function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a * b) / ONE;\n }\n\n function mulUp(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 product = a * b;\n\n if (product == 0) {\n return 0;\n } else {\n return ((product - 1) / ONE) + 1;\n }\n }\n\n function divDown(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a * ONE) / b;\n }\n\n function divUp(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n } else {\n return (((a * ONE) - 1) / b) + 1;\n }\n }\n\n function complement(uint256 x) internal pure returns (uint256) {\n return (x < ONE) ? (ONE - x) : 0;\n }\n}\n\nlibrary MathUtils {\n // --- Constants ---\n\n /// @notice Represents 100%.\n /// @dev 1e18 is the scaling factor (100% == 1e18).\n uint256 public constant _100_PERCENT = Fixed256x18.ONE;\n\n /// @notice Precision for Nominal ICR (independent of price).\n /// @dev Rationale for the value:\n /// - Making it “too high” could lead to overflows.\n /// - Making it “too low” could lead to an ICR equal to zero, due to truncation from floor division.\n ///\n /// This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 collateralToken,\n /// and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.\n uint256 internal constant _NICR_PRECISION = 1e20;\n\n /// @notice Number of minutes in 1000 years.\n uint256 internal constant _MINUTES_IN_1000_YEARS = 1000 * 365 days / 1 minutes;\n\n // --- Functions ---\n\n /// @notice Multiplies two decimal numbers and use normal rounding rules:\n /// - round product up if 19'th mantissa digit >= 5\n /// - round product down if 19'th mantissa digit < 5.\n /// @param x First number.\n /// @param y Second number.\n function _decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {\n decProd = (x * y + Fixed256x18.ONE / 2) / Fixed256x18.ONE;\n }\n\n /// @notice Exponentiation function for 18-digit decimal base, and integer exponent n.\n ///\n /// @dev Uses the efficient \"exponentiation by squaring\" algorithm. O(log(n)) complexity. The exponent is capped to\n /// avoid reverting due to overflow.\n ///\n /// If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be\n /// negligibly different from just passing the cap, since the decayed base rate will be 0 for 1000 years or > 1000\n /// years.\n /// @param base The decimal base.\n /// @param exponent The exponent.\n /// @return The result of the exponentiation.\n function _decPow(uint256 base, uint256 exponent) internal pure returns (uint256) {\n if (exponent == 0) {\n return Fixed256x18.ONE;\n }\n\n uint256 y = Fixed256x18.ONE;\n uint256 x = base;\n uint256 n = Math.min(exponent, _MINUTES_IN_1000_YEARS); // cap to avoid overflow\n\n // Exponentiation-by-squaring\n while (n > 1) {\n if (n % 2 != 0) {\n y = _decMul(x, y);\n }\n x = _decMul(x, x);\n n /= 2;\n }\n\n return _decMul(x, y);\n }\n\n /// @notice Computes the Nominal Individual Collateral Ratio (NICR) for given collateral and debt. If debt is zero,\n /// it returns the maximal value for uint256 (represents \"infinite\" CR).\n /// @param collateral Collateral amount.\n /// @param debt Debt amount.\n /// @return NICR.\n function _computeNominalCR(uint256 collateral, uint256 debt) internal pure returns (uint256) {\n return debt > 0 ? collateral * _NICR_PRECISION / debt : type(uint256).max;\n }\n\n /// @notice Computes the Collateral Ratio for given collateral, debt and price. If debt is zero, it returns the\n /// maximal value for uint256 (represents \"infinite\" CR).\n /// @param collateral Collateral amount.\n /// @param debt Debt amount.\n /// @param price Collateral price.\n /// @return Collateral ratio.\n function _computeCR(uint256 collateral, uint256 debt, uint256 price) internal pure returns (uint256) {\n return debt > 0 ? collateral * price / debt : type(uint256).max;\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\n\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n}\n\n/**\n * @dev Extension of {ERC20} that adds a cap to the supply of tokens.\n */\nabstract contract ERC20Capped is ERC20, Ownable2Step {\n uint256 public cap;\n\n /**\n * @dev Total supply cap has been exceeded.\n */\n error ERC20ExceededCap();\n\n /**\n * @dev The supplied cap is not a valid cap.\n */\n error ERC20InvalidCap(uint256 cap);\n\n constructor(uint256 cap_) {\n setCap(cap_);\n }\n\n /**\n * @dev Sets the value of the `cap`.\n */\n function setCap(uint256 cap_) public onlyOwner {\n if (cap_ == 0) {\n revert ERC20InvalidCap(0);\n }\n cap = cap_;\n }\n\n /**\n * @dev See {ERC20-_mint}.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n if (totalSupply() + amount > cap) {\n revert ERC20ExceededCap();\n }\n super._mint(account, amount);\n }\n}\n\nabstract contract PositionManagerDependent is IPositionManagerDependent {\n // --- Immutable variables ---\n\n address public immutable override positionManager;\n\n // --- Modifiers ---\n\n modifier onlyPositionManager() {\n if (msg.sender != positionManager) {\n revert CallerIsNotPositionManager(msg.sender);\n }\n _;\n }\n\n // --- Constructor ---\n\n constructor(address positionManager_) {\n if (positionManager_ == address(0)) {\n revert PositionManagerCannotBeZero();\n }\n positionManager = positionManager_;\n }\n}\n\ncontract ERC20Indexable is IERC20Indexable, ERC20Capped, PositionManagerDependent {\n // --- Types ---\n\n using Fixed256x18 for uint256;\n\n // --- Constants ---\n\n uint256 public constant override INDEX_PRECISION = Fixed256x18.ONE;\n\n // --- Variables ---\n\n uint256 internal storedIndex;\n\n // --- Constructor ---\n\n constructor(\n address positionManager_,\n string memory name_,\n string memory symbol_,\n uint256 cap_\n )\n ERC20(name_, symbol_)\n ERC20Capped(cap_)\n PositionManagerDependent(positionManager_)\n {\n storedIndex = INDEX_PRECISION;\n emit ERC20IndexableDeployed(positionManager_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) public virtual override onlyPositionManager {\n _mint(to, amount.divUp(storedIndex));\n }\n\n function burn(address from, uint256 amount) public virtual override onlyPositionManager {\n _burn(from, amount == type(uint256).max ? ERC20.balanceOf(from) : amount.divUp(storedIndex));\n }\n\n function setIndex(uint256 backingAmount) external override onlyPositionManager {\n uint256 supply = ERC20.totalSupply();\n uint256 newIndex = (backingAmount == 0 && supply == 0) ? INDEX_PRECISION : backingAmount.divUp(supply);\n storedIndex = newIndex;\n emit IndexUpdated(newIndex);\n }\n\n function currentIndex() public view virtual override returns (uint256) {\n return storedIndex;\n }\n\n function totalSupply() public view virtual override(IERC20, ERC20) returns (uint256) {\n return ERC20.totalSupply().mulDown(currentIndex());\n }\n\n function balanceOf(address account) public view virtual override(IERC20, ERC20) returns (uint256) {\n return ERC20.balanceOf(account).mulDown(currentIndex());\n }\n\n function transfer(address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function allowance(address, address) public view virtual override(IERC20, ERC20) returns (uint256) {\n revert NotSupported();\n }\n\n function approve(address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function transferFrom(address, address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function increaseAllowance(address, uint256) public virtual override returns (bool) {\n revert NotSupported();\n }\n\n function decreaseAllowance(address, uint256) public virtual override returns (bool) {\n revert NotSupported();\n }\n}\n\nabstract contract FeeCollector is Ownable2Step, IFeeCollector {\n // --- Variables ---\n\n address public override feeRecipient;\n\n // --- Constructor ---\n\n /// @param feeRecipient_ Address of the fee recipient to initialize contract with.\n constructor(address feeRecipient_) {\n if (feeRecipient_ == address(0)) {\n revert InvalidFeeRecipient();\n }\n\n feeRecipient = feeRecipient_;\n }\n\n // --- Functions ---\n\n function setFeeRecipient(address newFeeRecipient) external onlyOwner {\n if (newFeeRecipient == address(0)) {\n revert InvalidFeeRecipient();\n }\n\n feeRecipient = newFeeRecipient;\n emit FeeRecipientChanged(newFeeRecipient);\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/ERC20FlashMint.sol)\n\n/**\n * @dev Implementation of the ERC3156 Flash loans extension, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * Adds the {flashLoan} method, which provides flash loan support at the token\n * level. By default there is no fee, but this can be changed by overriding {flashFee}.\n *\n * _Available since v4.1._\n */\nabstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {\n bytes32 private constant _RETURN_VALUE = keccak256(\"ERC3156FlashBorrower.onFlashLoan\");\n\n /**\n * @dev Returns the maximum amount of tokens available for loan.\n * @param token The address of the token that is requested.\n * @return The amount of token that can be loaned.\n */\n function maxFlashLoan(address token) public view virtual override returns (uint256) {\n return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;\n }\n\n /**\n * @dev Returns the fee applied when doing flash loans. This function calls\n * the {_flashFee} function which returns the fee applied when doing flash\n * loans.\n * @param token The token to be flash loaned.\n * @param amount The amount of tokens to be loaned.\n * @return The fees applied to the corresponding flash loan.\n */\n function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {\n require(token == address(this), \"ERC20FlashMint: wrong token\");\n return _flashFee(token, amount);\n }\n\n /**\n * @dev Returns the fee applied when doing flash loans. By default this\n * implementation has 0 fees. This function can be overloaded to make\n * the flash loan mechanism deflationary.\n * @param token The token to be flash loaned.\n * @param amount The amount of tokens to be loaned.\n * @return The fees applied to the corresponding flash loan.\n */\n function _flashFee(address token, uint256 amount) internal view virtual returns (uint256) {\n // silence warning about unused variable without the addition of bytecode.\n token;\n amount;\n return 0;\n }\n\n /**\n * @dev Returns the receiver address of the flash fee. By default this\n * implementation returns the address(0) which means the fee amount will be burnt.\n * This function can be overloaded to change the fee receiver.\n * @return The address for which the flash fee will be sent to.\n */\n function _flashFeeReceiver() internal view virtual returns (address) {\n return address(0);\n }\n\n /**\n * @dev Performs a flash loan. New tokens are minted and sent to the\n * `receiver`, who is required to implement the {IERC3156FlashBorrower}\n * interface. By the end of the flash loan, the receiver is expected to own\n * amount + fee tokens and have them approved back to the token contract itself so\n * they can be burned.\n * @param receiver The receiver of the flash loan. Should implement the\n * {IERC3156FlashBorrower-onFlashLoan} interface.\n * @param token The token to be flash loaned. Only `address(this)` is\n * supported.\n * @param amount The amount of tokens to be loaned.\n * @param data An arbitrary datafield that is passed to the receiver.\n * @return `true` if the flash loan was successful.\n */\n // This function can reenter, but it doesn't pose a risk because it always preserves the property that the amount\n // minted at the beginning is always recovered and burned at the end, or else the entire function will revert.\n // slither-disable-next-line reentrancy-no-eth\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n ) public virtual override returns (bool) {\n require(amount <= maxFlashLoan(token), \"ERC20FlashMint: amount exceeds maxFlashLoan\");\n uint256 fee = flashFee(token, amount);\n _mint(address(receiver), amount);\n require(\n receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,\n \"ERC20FlashMint: invalid return value\"\n );\n address flashFeeReceiver = _flashFeeReceiver();\n _spendAllowance(address(receiver), address(this), amount + fee);\n if (fee == 0 || flashFeeReceiver == address(0)) {\n _burn(address(receiver), amount + fee);\n } else {\n _burn(address(receiver), amount);\n _transfer(address(receiver), flashFeeReceiver, fee);\n }\n return true;\n }\n}\n\ncontract RToken is ReentrancyGuard, ERC20Permit, ERC20FlashMint, PositionManagerDependent, FeeCollector, IRToken {\n // --- Constants ---\n\n uint256 public constant override PERCENTAGE_BASE = 10_000;\n uint256 public constant override MAX_FLASH_MINT_FEE_PERCENTAGE = 500;\n\n // --- Variables ---\n\n uint256 public override flashMintFeePercentage;\n\n // --- Constructor ---\n\n /// @dev Deploys new R token. Sets flash mint fee percentage to 0. Transfers ownership to @param feeRecipient_.\n /// @param positionManager_ Address of the PositionManager contract that is authorized to mint and burn new tokens.\n /// @param feeRecipient_ Address of flash mint fee recipient.\n constructor(\n address positionManager_,\n address feeRecipient_\n )\n ERC20Permit(\"R Stablecoin\")\n ERC20(\"R Stablecoin\", \"R\")\n PositionManagerDependent(positionManager_)\n FeeCollector(feeRecipient_)\n {\n setFlashMintFeePercentage(PERCENTAGE_BASE / 200); // 0.5%\n\n transferOwnership(feeRecipient_);\n\n emit RDeployed(positionManager_, feeRecipient_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) external override onlyPositionManager {\n _mint(to, amount);\n }\n\n function burn(address from, uint256 amount) external override onlyPositionManager {\n _burn(from, amount);\n }\n\n function setFlashMintFeePercentage(uint256 feePercentage) public override onlyOwner {\n if (feePercentage > MAX_FLASH_MINT_FEE_PERCENTAGE) {\n revert FlashFeePercentageTooBig(feePercentage);\n }\n\n flashMintFeePercentage = feePercentage;\n emit FlashMintFeePercentageChanged(flashMintFeePercentage);\n }\n\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n )\n public\n override(ERC20FlashMint, IERC3156FlashLender)\n nonReentrant\n returns (bool)\n {\n return super.flashLoan(receiver, token, amount, data);\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines maximum size of the flash mint.\n /// @param token Token to be flash minted. Returns 0 amount in case of token != address(this).\n function maxFlashLoan(address token)\n public\n view\n virtual\n override(ERC20FlashMint, IERC3156FlashLender)\n returns (uint256)\n {\n return token == address(this) ? Math.min(totalSupply() / 10, ERC20FlashMint.maxFlashLoan(address(this))) : 0;\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines flash mint fee for the flash mint of @param amount tokens.\n /// @param token Token to be flash minted. Returns 0 fee in case of token != address(this).\n /// @param amount Size of the flash mint.\n function _flashFee(address token, uint256 amount) internal view virtual override returns (uint256) {\n return token == address(this) ? amount * flashMintFeePercentage / PERCENTAGE_BASE : 0;\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines flash mint fee receiver.\n /// @return Address that will receive flash mint fees.\n function _flashFeeReceiver() internal view virtual override returns (address) {\n return feeRecipient;\n }\n}\n\n/// @dev Implementation of Position Manager. Current implementation does not support rebasing tokens as collateral.\ncontract PositionManager is FeeCollector, IPositionManager {\n // --- Types ---\n\n using SafeERC20 for IERC20;\n using Fixed256x18 for uint256;\n\n // --- Constants ---\n\n uint256 public constant override MINUTE_DECAY_FACTOR = 999_037_758_833_783_000;\n\n uint256 public constant override MAX_BORROWING_SPREAD = MathUtils._100_PERCENT / 100; // 1%\n uint256 public constant override MAX_BORROWING_RATE = MathUtils._100_PERCENT / 100 * 5; // 5%\n\n uint256 public constant override BETA = 2;\n\n // --- Immutables ---\n\n IRToken public immutable override rToken;\n\n // --- Variables ---\n\n mapping(address position => IERC20 collateralToken) public override collateralTokenForPosition;\n\n mapping(address position => mapping(address delegate => bool isWhitelisted)) public override isDelegateWhitelisted;\n\n mapping(IERC20 collateralToken => CollateralTokenInfo collateralTokenInfo) public override collateralInfo;\n\n // --- Modifiers ---\n\n /// @dev Checks if the collateral token has been added to the position manager, or reverts otherwise.\n /// @param collateralToken The collateral token to check.\n modifier collateralTokenExists(IERC20 collateralToken) {\n if (address(collateralInfo[collateralToken].collateralToken) == address(0)) {\n revert CollateralTokenNotAdded();\n }\n _;\n }\n\n /// @dev Checks if the collateral token has enabled, or reverts otherwise. When the condition is false, the check\n /// is skipped.\n /// @param collateralToken The collateral token to check.\n /// @param condition If true, the check will be performed.\n modifier onlyEnabledCollateralTokenWhen(IERC20 collateralToken, bool condition) {\n if (condition && !collateralInfo[collateralToken].isEnabled) {\n revert CollateralTokenDisabled();\n }\n _;\n }\n\n /// @dev Checks if the borrower has a position with the collateral token or doesn't have a position at all, or\n /// reverts otherwise.\n /// @param position The borrower to check.\n /// @param collateralToken The collateral token to check.\n modifier onlyDepositedCollateralTokenOrNew(address position, IERC20 collateralToken) {\n if (\n collateralTokenForPosition[position] != IERC20(address(0))\n && collateralTokenForPosition[position] != collateralToken\n ) {\n revert PositionCollateralTokenMismatch();\n }\n _;\n }\n\n /// @dev Checks if the max fee percentage is between the borrowing spread and 100%, or reverts otherwise. When the\n /// condition is false, the check is skipped.\n /// @param maxFeePercentage The max fee percentage to check.\n /// @param condition If true, the check will be performed.\n modifier validMaxFeePercentageWhen(uint256 maxFeePercentage, bool condition) {\n if (condition && maxFeePercentage > MathUtils._100_PERCENT) {\n revert InvalidMaxFeePercentage();\n }\n _;\n }\n\n // --- Constructor ---\n\n /// @dev Initializes the position manager.\n constructor(address rToken_) FeeCollector(msg.sender) {\n rToken = rToken_ == address(0) ? new RToken(address(this), msg.sender) : IRToken(rToken_);\n emit PositionManagerDeployed(rToken, msg.sender);\n }\n\n // --- External functions ---\n\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n public\n virtual\n override\n collateralTokenExists(collateralToken)\n validMaxFeePercentageWhen(maxFeePercentage, isDebtIncrease)\n onlyDepositedCollateralTokenOrNew(position, collateralToken)\n onlyEnabledCollateralTokenWhen(collateralToken, isDebtIncrease && debtChange > 0)\n returns (uint256 actualCollateralChange, uint256 actualDebtChange)\n {\n if (position != msg.sender && !isDelegateWhitelisted[position][msg.sender]) {\n revert DelegateNotWhitelisted();\n }\n if (collateralChange == 0 && debtChange == 0) {\n revert NoCollateralOrDebtChange();\n }\n if (address(permitSignature.token) == address(collateralToken)) {\n PermitHelper.applyPermit(permitSignature, msg.sender, address(this));\n }\n\n CollateralTokenInfo storage collateralTokenInfo = collateralInfo[collateralToken];\n IERC20Indexable raftCollateralToken = collateralTokenInfo.collateralToken;\n IERC20Indexable raftDebtToken = collateralTokenInfo.debtToken;\n\n uint256 debtBefore = raftDebtToken.balanceOf(position);\n if (!isDebtIncrease && (debtChange == type(uint256).max || (debtBefore != 0 && debtChange == debtBefore))) {\n if (collateralChange != 0 || isCollateralIncrease) {\n revert WrongCollateralParamsForFullRepayment();\n }\n collateralChange = raftCollateralToken.balanceOf(position);\n debtChange = debtBefore;\n }\n\n _adjustDebt(position, collateralToken, raftDebtToken, debtChange, isDebtIncrease, maxFeePercentage);\n _adjustCollateral(collateralToken, raftCollateralToken, position, collateralChange, isCollateralIncrease);\n\n uint256 positionDebt = raftDebtToken.balanceOf(position);\n uint256 positionCollateral = raftCollateralToken.balanceOf(position);\n\n if (positionDebt == 0) {\n if (positionCollateral != 0) {\n revert InvalidPosition();\n }\n // position was closed, remove it\n _closePosition(raftCollateralToken, raftDebtToken, position, false);\n } else {\n _checkValidPosition(collateralToken, positionDebt, positionCollateral);\n\n if (debtBefore == 0) {\n collateralTokenForPosition[position] = collateralToken;\n emit PositionCreated(position, collateralToken);\n }\n }\n return (collateralChange, debtChange);\n }\n\n function liquidate(address position) external override {\n IERC20 collateralToken = collateralTokenForPosition[position];\n CollateralTokenInfo storage collateralTokenInfo = collateralInfo[collateralToken];\n IERC20Indexable raftCollateralToken = collateralTokenInfo.collateralToken;\n IERC20Indexable raftDebtToken = collateralTokenInfo.debtToken;\n ISplitLiquidationCollateral splitLiquidation = collateralTokenInfo.splitLiquidation;\n\n if (address(collateralToken) == address(0)) {\n revert NothingToLiquidate();\n }\n (uint256 price,) = collateralTokenInfo.priceFeed.fetchPrice();\n uint256 entireCollateral = raftCollateralToken.balanceOf(position);\n uint256 entireDebt = raftDebtToken.balanceOf(position);\n uint256 icr = MathUtils._computeCR(entireCollateral, entireDebt, price);\n\n if (icr >= splitLiquidation.MCR()) {\n revert NothingToLiquidate();\n }\n\n uint256 totalDebt = raftDebtToken.totalSupply();\n if (entireDebt == totalDebt) {\n revert CannotLiquidateLastPosition();\n }\n bool isRedistribution = icr <= MathUtils._100_PERCENT;\n\n // prettier: ignore\n (uint256 collateralLiquidationFee, uint256 collateralToSendToLiquidator) =\n splitLiquidation.split(entireCollateral, entireDebt, price, isRedistribution);\n\n if (!isRedistribution) {\n _burnRTokens(msg.sender, entireDebt);\n totalDebt -= entireDebt;\n\n // Collateral is sent to protocol as a fee only in case of liquidation\n collateralToken.safeTransfer(feeRecipient, collateralLiquidationFee);\n }\n\n collateralToken.safeTransfer(msg.sender, collateralToSendToLiquidator);\n\n _closePosition(raftCollateralToken, raftDebtToken, position, true);\n\n _updateDebtAndCollateralIndex(collateralToken, raftCollateralToken, raftDebtToken, totalDebt);\n\n emit Liquidation(\n msg.sender,\n position,\n collateralToken,\n entireDebt,\n entireCollateral,\n collateralToSendToLiquidator,\n collateralLiquidationFee,\n isRedistribution\n );\n }\n\n function redeemCollateral(\n IERC20 collateralToken,\n uint256 debtAmount,\n uint256 maxFeePercentage\n )\n public\n virtual\n override\n {\n if (maxFeePercentage > MathUtils._100_PERCENT) {\n revert MaxFeePercentageOutOfRange();\n }\n if (debtAmount == 0) {\n revert AmountIsZero();\n }\n IERC20Indexable raftDebtToken = collateralInfo[collateralToken].debtToken;\n\n uint256 newTotalDebt = raftDebtToken.totalSupply() - debtAmount;\n uint256 lowTotalDebt = collateralInfo[collateralToken].splitLiquidation.LOW_TOTAL_DEBT();\n if (newTotalDebt < lowTotalDebt) {\n revert TotalDebtCannotBeLowerThanMinDebt(collateralToken, newTotalDebt);\n }\n\n (uint256 price, uint256 deviation) = collateralInfo[collateralToken].priceFeed.fetchPrice();\n uint256 collateralToRedeem = debtAmount.divDown(price);\n uint256 totalCollateral = collateralToken.balanceOf(address(this));\n if (\n totalCollateral - collateralToRedeem == 0\n || totalCollateral - collateralToRedeem < lowTotalDebt.divDown(price)\n ) {\n revert TotalCollateralCannotBeLowerThanMinCollateral(\n collateralToken, totalCollateral - collateralToRedeem, lowTotalDebt.divDown(price)\n );\n }\n\n // Decay the baseRate due to time passed, and then increase it according to the size of this redemption.\n // Use the saved total R supply value, from before it was reduced by the redemption.\n _updateBaseRateFromRedemption(collateralToken, collateralToRedeem, price, rToken.totalSupply());\n\n // Calculate the redemption fee\n uint256 redemptionFee = getRedemptionFee(collateralToken, collateralToRedeem, deviation);\n uint256 rebate = redemptionFee.mulDown(collateralInfo[collateralToken].redemptionRebate);\n\n _checkValidFee(redemptionFee, collateralToRedeem, maxFeePercentage);\n\n // Send the redemption fee to the recipient\n collateralToken.safeTransfer(feeRecipient, redemptionFee - rebate);\n\n // Burn the total R that is cancelled with debt, and send the redeemed collateral to msg.sender\n _burnRTokens(msg.sender, debtAmount);\n\n // Send collateral to account\n collateralToken.safeTransfer(msg.sender, collateralToRedeem - redemptionFee);\n\n _updateDebtAndCollateralIndex(\n collateralToken, collateralInfo[collateralToken].collateralToken, raftDebtToken, newTotalDebt\n );\n\n emit Redemption(msg.sender, debtAmount, collateralToRedeem, redemptionFee, rebate);\n }\n\n function whitelistDelegate(address delegate, bool whitelisted) external override {\n if (delegate == address(0)) {\n revert InvalidDelegateAddress();\n }\n isDelegateWhitelisted[msg.sender][delegate] = whitelisted;\n\n emit DelegateWhitelisted(msg.sender, delegate, whitelisted);\n }\n\n function setBorrowingSpread(IERC20 collateralToken, uint256 newBorrowingSpread) external override onlyOwner {\n if (newBorrowingSpread > MAX_BORROWING_SPREAD) {\n revert BorrowingSpreadExceedsMaximum();\n }\n collateralInfo[collateralToken].borrowingSpread = newBorrowingSpread;\n emit BorrowingSpreadUpdated(newBorrowingSpread);\n }\n\n function setRedemptionRebate(IERC20 collateralToken, uint256 newRedemptionRebate) public override onlyOwner {\n if (newRedemptionRebate > MathUtils._100_PERCENT) {\n revert RedemptionRebateExceedsMaximum();\n }\n collateralInfo[collateralToken].redemptionRebate = newRedemptionRebate;\n emit RedemptionRebateUpdated(newRedemptionRebate);\n }\n\n function getRedemptionFeeWithDecay(\n IERC20 collateralToken,\n uint256 collateralAmount\n )\n external\n view\n override\n returns (uint256 redemptionFee)\n {\n redemptionFee = getRedemptionRateWithDecay(collateralToken).mulDown(collateralAmount);\n if (redemptionFee >= collateralAmount) {\n revert FeeEatsUpAllReturnedCollateral();\n }\n }\n\n // --- Public functions ---\n\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n public\n virtual\n override\n {\n addCollateralToken(\n collateralToken,\n priceFeed,\n newSplitLiquidationCollateral,\n new ERC20Indexable(\n address(this),\n string(bytes.concat(\"Raft \", bytes(IERC20Metadata(address(collateralToken)).name()), \" collateral\")),\n string(bytes.concat(\"r\", bytes(IERC20Metadata(address(collateralToken)).symbol()), \"-c\")),\n type(uint256).max\n ),\n new ERC20Indexable(\n address(this),\n string(bytes.concat(\"Raft \", bytes(IERC20Metadata(address(collateralToken)).name()), \" debt\")),\n string(bytes.concat(\"r\", bytes(IERC20Metadata(address(collateralToken)).symbol()), \"-d\")),\n type(uint256).max\n )\n );\n }\n\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral,\n IERC20Indexable raftCollateralToken_,\n IERC20Indexable raftDebtToken_\n )\n public\n override\n onlyOwner\n {\n if (address(collateralToken) == address(0)) {\n revert CollateralTokenAddressCannotBeZero();\n }\n if (address(priceFeed) == address(0)) {\n revert PriceFeedAddressCannotBeZero();\n }\n if (address(collateralInfo[collateralToken].collateralToken) != address(0)) {\n revert CollateralTokenAlreadyAdded();\n }\n\n CollateralTokenInfo memory raftCollateralTokenInfo;\n raftCollateralTokenInfo.collateralToken = raftCollateralToken_;\n raftCollateralTokenInfo.debtToken = raftDebtToken_;\n raftCollateralTokenInfo.isEnabled = true;\n raftCollateralTokenInfo.priceFeed = priceFeed;\n\n collateralInfo[collateralToken] = raftCollateralTokenInfo;\n\n setRedemptionSpread(collateralToken, MathUtils._100_PERCENT);\n setRedemptionRebate(collateralToken, MathUtils._100_PERCENT);\n\n setSplitLiquidationCollateral(collateralToken, newSplitLiquidationCollateral);\n\n emit CollateralTokenAdded(\n collateralToken, raftCollateralTokenInfo.collateralToken, raftCollateralTokenInfo.debtToken, priceFeed\n );\n }\n\n function setCollateralEnabled(\n IERC20 collateralToken,\n bool isEnabled\n )\n public\n override\n onlyOwner\n collateralTokenExists(collateralToken)\n {\n bool previousIsEnabled = collateralInfo[collateralToken].isEnabled;\n collateralInfo[collateralToken].isEnabled = isEnabled;\n\n if (previousIsEnabled != isEnabled) {\n emit CollateralTokenModified(collateralToken, isEnabled);\n }\n }\n\n function setSplitLiquidationCollateral(\n IERC20 collateralToken,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n public\n override\n onlyOwner\n {\n if (address(newSplitLiquidationCollateral) == address(0)) {\n revert SplitLiquidationCollateralCannotBeZero();\n }\n collateralInfo[collateralToken].splitLiquidation = newSplitLiquidationCollateral;\n emit SplitLiquidationCollateralChanged(collateralToken, newSplitLiquidationCollateral);\n }\n\n function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) public override onlyOwner {\n if (newRedemptionSpread > MathUtils._100_PERCENT) {\n revert RedemptionSpreadOutOfRange();\n }\n collateralInfo[collateralToken].redemptionSpread = newRedemptionSpread;\n emit RedemptionSpreadUpdated(collateralToken, newRedemptionSpread);\n }\n\n function getRedemptionRateWithDecay(IERC20 collateralToken) public view override returns (uint256) {\n return _calcRedemptionRate(collateralToken, _calcDecayedBaseRate(collateralToken));\n }\n\n function raftCollateralToken(IERC20 collateralToken) external view override returns (IERC20Indexable) {\n return collateralInfo[collateralToken].collateralToken;\n }\n\n function raftDebtToken(IERC20 collateralToken) external view override returns (IERC20Indexable) {\n return collateralInfo[collateralToken].debtToken;\n }\n\n function priceFeed(IERC20 collateralToken) external view override returns (IPriceFeed) {\n return collateralInfo[collateralToken].priceFeed;\n }\n\n function splitLiquidationCollateral(IERC20 collateralToken) external view returns (ISplitLiquidationCollateral) {\n return collateralInfo[collateralToken].splitLiquidation;\n }\n\n function collateralEnabled(IERC20 collateralToken) external view override returns (bool) {\n return collateralInfo[collateralToken].isEnabled;\n }\n\n function lastFeeOperationTime(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].lastFeeOperationTime;\n }\n\n function borrowingSpread(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].borrowingSpread;\n }\n\n function baseRate(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].baseRate;\n }\n\n function redemptionSpread(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].redemptionSpread;\n }\n\n function redemptionRebate(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].redemptionRebate;\n }\n\n function getRedemptionRate(IERC20 collateralToken) public view override returns (uint256) {\n return _calcRedemptionRate(collateralToken, collateralInfo[collateralToken].baseRate);\n }\n\n function getRedemptionFee(\n IERC20 collateralToken,\n uint256 collateralAmount,\n uint256 priceDeviation\n )\n public\n view\n override\n returns (uint256)\n {\n return Math.min(getRedemptionRate(collateralToken) + priceDeviation, MathUtils._100_PERCENT).mulDown(\n collateralAmount\n );\n }\n\n function getBorrowingRate(IERC20 collateralToken) public view override returns (uint256) {\n return _calcBorrowingRate(collateralToken, collateralInfo[collateralToken].baseRate);\n }\n\n function getBorrowingRateWithDecay(IERC20 collateralToken) public view override returns (uint256) {\n return _calcBorrowingRate(collateralToken, _calcDecayedBaseRate(collateralToken));\n }\n\n function getBorrowingFee(IERC20 collateralToken, uint256 debtAmount) public view override returns (uint256) {\n return getBorrowingRate(collateralToken).mulDown(debtAmount);\n }\n\n // --- Helper functions ---\n\n /// @dev Adjusts the debt of a given borrower by burning or minting the corresponding amount of R and the Raft\n /// debt token. If the debt is being increased, the borrowing fee is also triggered.\n /// @param position The address of the borrower.\n /// @param debtChange The amount of R to add or remove. Must be positive.\n /// @param isDebtIncrease True if the debt is being increased, false otherwise.\n /// @param maxFeePercentage The maximum fee percentage.\n function _adjustDebt(\n address position,\n IERC20 collateralToken,\n IERC20Indexable raftDebtToken,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage\n )\n internal\n {\n if (debtChange == 0) {\n return;\n }\n\n if (isDebtIncrease) {\n uint256 totalDebtChange =\n debtChange + _triggerBorrowingFee(collateralToken, position, debtChange, maxFeePercentage);\n raftDebtToken.mint(position, totalDebtChange);\n _mintRTokens(msg.sender, debtChange);\n } else {\n raftDebtToken.burn(position, debtChange);\n _burnRTokens(msg.sender, debtChange);\n }\n\n emit DebtChanged(position, collateralToken, debtChange, isDebtIncrease);\n }\n\n /// @dev Mints R tokens\n function _mintRTokens(address to, uint256 amount) internal virtual {\n rToken.mint(to, amount);\n }\n\n /// @dev Burns R tokens\n function _burnRTokens(address from, uint256 amount) internal virtual {\n rToken.burn(from, amount);\n }\n\n /// @dev Adjusts the collateral of a given borrower by burning or minting the corresponding amount of Raft\n /// collateral token and transferring the corresponding amount of collateral token.\n /// @param collateralToken The token the borrower used as collateral.\n /// @param position The address of the borrower.\n /// @param collateralChange The amount of collateral to add or remove. Must be positive.\n /// @param isCollateralIncrease True if the collateral is being increased, false otherwise.\n function _adjustCollateral(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease\n )\n internal\n {\n if (collateralChange == 0) {\n return;\n }\n\n if (isCollateralIncrease) {\n raftCollateralToken.mint(position, collateralChange);\n collateralToken.safeTransferFrom(msg.sender, address(this), collateralChange);\n } else {\n raftCollateralToken.burn(position, collateralChange);\n collateralToken.safeTransfer(msg.sender, collateralChange);\n }\n\n emit CollateralChanged(position, collateralToken, collateralChange, isCollateralIncrease);\n }\n\n /// @dev Updates debt and collateral indexes for a given collateral token.\n /// @param collateralToken The collateral token for which to update the indexes.\n /// @param raftCollateralToken The raft collateral indexable token.\n /// @param raftDebtToken The raft debt indexable token.\n /// @param totalDebtForCollateral Totam amount of debt backed by collateral token.\n function _updateDebtAndCollateralIndex(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n uint256 totalDebtForCollateral\n )\n internal\n {\n raftDebtToken.setIndex(totalDebtForCollateral);\n raftCollateralToken.setIndex(collateralToken.balanceOf(address(this)));\n }\n\n function _closePosition(\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n address position,\n bool burnTokens\n )\n internal\n {\n collateralTokenForPosition[position] = IERC20(address(0));\n\n if (burnTokens) {\n raftDebtToken.burn(position, type(uint256).max);\n raftCollateralToken.burn(position, type(uint256).max);\n }\n emit PositionClosed(position);\n }\n\n // --- Borrowing & redemption fee helper functions ---\n\n /// @dev Updates the base rate from a redemption operation. Impacts on the base rate:\n /// 1. decays the base rate based on time passed since last redemption or R borrowing operation,\n /// 2. increases the base rate based on the amount redeemed, as a proportion of total supply.\n function _updateBaseRateFromRedemption(\n IERC20 collateralToken,\n uint256 collateralDrawn,\n uint256 price,\n uint256 totalDebtSupply\n )\n internal\n returns (uint256)\n {\n uint256 decayedBaseRate = _calcDecayedBaseRate(collateralToken);\n\n /* Convert the drawn collateral back to R at face value rate (1 R:1 USD), in order to get\n * the fraction of total supply that was redeemed at face value. */\n uint256 redeemedFraction = collateralDrawn * price / totalDebtSupply;\n\n uint256 newBaseRate = decayedBaseRate + redeemedFraction / BETA;\n newBaseRate = Math.min(newBaseRate, MathUtils._100_PERCENT); // cap baseRate at a maximum of 100%\n assert(newBaseRate > 0); // Base rate is always non-zero after redemption\n\n // Update the baseRate state variable\n collateralInfo[collateralToken].baseRate = newBaseRate;\n emit BaseRateUpdated(collateralToken, newBaseRate);\n\n _updateLastFeeOpTime(collateralToken);\n\n return newBaseRate;\n }\n\n function _calcRedemptionRate(IERC20 collateralToken, uint256 baseRate_) internal view returns (uint256) {\n return baseRate_ + collateralInfo[collateralToken].redemptionSpread;\n }\n\n function _calcBorrowingRate(IERC20 collateralToken, uint256 baseRate_) internal view returns (uint256) {\n return Math.min(collateralInfo[collateralToken].borrowingSpread + baseRate_, MAX_BORROWING_RATE);\n }\n\n /// @dev Updates the base rate based on time elapsed since the last redemption or R borrowing operation.\n function _decayBaseRateFromBorrowing(IERC20 collateralToken) internal {\n uint256 decayedBaseRate = _calcDecayedBaseRate(collateralToken);\n assert(decayedBaseRate <= MathUtils._100_PERCENT); // The baseRate can decay to 0\n\n collateralInfo[collateralToken].baseRate = decayedBaseRate;\n emit BaseRateUpdated(collateralToken, decayedBaseRate);\n\n _updateLastFeeOpTime(collateralToken);\n }\n\n /// @dev Update the last fee operation time only if time passed >= decay interval. This prevents base rate\n /// griefing.\n function _updateLastFeeOpTime(IERC20 collateralToken) internal {\n uint256 timePassed = block.timestamp - collateralInfo[collateralToken].lastFeeOperationTime;\n\n if (timePassed >= 1 minutes) {\n collateralInfo[collateralToken].lastFeeOperationTime = block.timestamp;\n emit LastFeeOpTimeUpdated(collateralToken, block.timestamp);\n }\n }\n\n function _calcDecayedBaseRate(IERC20 collateralToken) internal view returns (uint256) {\n uint256 minutesPassed = (block.timestamp - collateralInfo[collateralToken].lastFeeOperationTime) / 1 minutes;\n uint256 decayFactor = MathUtils._decPow(MINUTE_DECAY_FACTOR, minutesPassed);\n\n return collateralInfo[collateralToken].baseRate.mulDown(decayFactor);\n }\n\n function _triggerBorrowingFee(\n IERC20 collateralToken,\n address position,\n uint256 debtAmount,\n uint256 maxFeePercentage\n )\n internal\n virtual\n returns (uint256 borrowingFee)\n {\n _decayBaseRateFromBorrowing(collateralToken); // decay the baseRate state variable\n borrowingFee = getBorrowingFee(collateralToken, debtAmount);\n\n _checkValidFee(borrowingFee, debtAmount, maxFeePercentage);\n\n if (borrowingFee > 0) {\n _mintRTokens(feeRecipient, borrowingFee);\n emit RBorrowingFeePaid(collateralToken, position, borrowingFee);\n }\n }\n\n // --- Validation check helper functions ---\n\n function _checkValidPosition(IERC20 collateralToken, uint256 positionDebt, uint256 positionCollateral) internal {\n ISplitLiquidationCollateral splitCollateral = collateralInfo[collateralToken].splitLiquidation;\n if (positionDebt < splitCollateral.LOW_TOTAL_DEBT()) {\n revert NetDebtBelowMinimum(positionDebt);\n }\n\n (uint256 price,) = collateralInfo[collateralToken].priceFeed.fetchPrice();\n uint256 newICR = MathUtils._computeCR(positionCollateral, positionDebt, price);\n if (newICR < splitCollateral.MCR()) {\n revert NewICRLowerThanMCR(newICR);\n }\n }\n\n function _checkValidFee(uint256 fee, uint256 amount, uint256 maxFeePercentage) internal pure {\n uint256 feePercentage = fee.divDown(amount);\n\n if (feePercentage > maxFeePercentage) {\n revert FeeExceedsMaxFee(fee, amount, maxFeePercentage);\n }\n }\n}\n\ninterface IRMinter {\n /// @dev Emitted when tokens are recovered from the contract.\n /// @param token The address of the token being recovered.\n /// @param to The address receiving the recovered tokens.\n /// @param amount The amount of tokens recovered.\n event TokensRecovered(IERC20 token, address to, uint256 amount);\n\n /// @return Address of the R token.\n function r() external view returns (IRToken);\n\n /// @return Address of the Position manager contract responsible for minting R.\n function positionManager() external view returns (IPositionManager);\n\n /// @dev Recover accidentally sent tokens to the contract\n /// @param token Address of the token contract.\n /// @param to Address of the receiver of the tokens.\n /// @param amount Number of tokens to recover.\n function recoverTokens(IERC20 token, address to, uint256 amount) external;\n}\n\ninterface ILock {\n /// @dev Thrown when contract usage is locked.\n error ContractLocked();\n\n /// @dev Unauthorized call to lock/unlock.\n error Unauthorized();\n\n /// @dev Retrieves if contract is currently locked or not.\n function locked() external view returns (bool);\n\n /// @dev Retrieves address of the locker who can unlock contract.\n function locker() external view returns (address);\n\n /// @dev Unlcoks the usage of the contract.\n function unlock() external;\n\n /// @dev Locks the usage of the contract.\n function lock() external;\n}\n\nabstract contract ERC20RMinter is IRMinter, ERC20, Ownable2Step {\n using SafeERC20 for IERC20;\n\n IRToken public immutable override r;\n IPositionManager public immutable override positionManager;\n\n constructor(IRToken rToken_, string memory name_, string memory symbol_) ERC20(name_, symbol_) {\n r = rToken_;\n positionManager = IPositionManager(rToken_.positionManager());\n\n _approve(address(this), address(positionManager), type(uint256).max);\n }\n\n modifier unlockCall() {\n ILock lockContract = ILock(address(positionManager.priceFeed(IERC20(this))));\n lockContract.unlock();\n _;\n lockContract.lock();\n }\n\n function recoverTokens(IERC20 token, address to, uint256 amount) external override onlyOwner {\n token.safeTransfer(to, amount);\n emit TokensRecovered(token, to, amount);\n }\n\n function _mintR(address to, uint256 amount) internal unlockCall {\n _mint(address(this), amount);\n ERC20PermitSignature memory emptySignature;\n positionManager.managePosition(\n IERC20(address(this)),\n address(this),\n amount,\n true, // collateral increase\n amount,\n true, // debt increase\n 1e18, // 100%\n emptySignature\n );\n r.transfer(to, amount);\n }\n\n function _burnR(address from, uint256 amount) internal unlockCall {\n r.transferFrom(from, address(this), amount);\n ERC20PermitSignature memory emptySignature;\n positionManager.managePosition(\n IERC20(address(this)),\n address(this),\n amount,\n false, // collateral decrease\n amount,\n false, // debt decrease\n 1e18, // 100%\n emptySignature\n );\n _burn(address(this), amount);\n }\n}\n\ncontract InterestRateDebtToken is ERC20Indexable {\n // --- Types ---\n\n using Fixed256x18 for uint256;\n\n // --- Events ---\n\n event IndexIncreasePerSecondSet(uint256 indexIncreasePerSecond);\n\n // --- Immutables ---\n\n IERC20 immutable collateralToken;\n\n // --- Variables ---\n\n uint256 internal storedIndexUpdatedAt;\n\n uint256 public indexIncreasePerSecond;\n\n // --- Constructor ---\n\n constructor(\n address positionManager_,\n string memory name_,\n string memory symbol_,\n IERC20 collateralToken_,\n uint256 cap_,\n uint256 indexIncreasePerSecond_\n )\n ERC20Indexable(positionManager_, name_, symbol_, cap_)\n {\n storedIndexUpdatedAt = block.timestamp;\n collateralToken = collateralToken_;\n setIndexIncreasePerSecond(indexIncreasePerSecond_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) public virtual override {\n updateIndexAndPayFees();\n super.mint(to, amount);\n }\n\n function burn(address from, uint256 amount) public virtual override {\n updateIndexAndPayFees();\n super.burn(from, amount);\n }\n\n function currentIndex() public view virtual override returns (uint256) {\n return storedIndex.mulUp(INDEX_PRECISION + indexIncreasePerSecond * (block.timestamp - storedIndexUpdatedAt));\n }\n\n function updateIndexAndPayFees() public {\n uint256 currentIndex_ = currentIndex();\n _payFees(currentIndex_);\n storedIndexUpdatedAt = block.timestamp;\n storedIndex = currentIndex_;\n emit IndexUpdated(currentIndex_);\n }\n\n function setIndexIncreasePerSecond(uint256 indexIncreasePerSecond_) public onlyOwner {\n updateIndexAndPayFees();\n indexIncreasePerSecond = indexIncreasePerSecond_;\n emit IndexIncreasePerSecondSet(indexIncreasePerSecond_);\n }\n\n function unpaidFees() external view returns (uint256) {\n return _unpaidFees(currentIndex());\n }\n\n function _unpaidFees(uint256 currentIndex_) private view returns (uint256) {\n return totalSupply().mulDown(currentIndex_ - storedIndex);\n }\n\n function _payFees(uint256 currentIndex_) private {\n uint256 unpaidFees = _unpaidFees(currentIndex_);\n if (unpaidFees > 0) {\n IInterestRatePositionManager(positionManager).mintFees(collateralToken, unpaidFees);\n }\n }\n}\n\n/// @dev Implementation of Position Manager. Current implementation does not support rebasing tokens as collateral.\ncontract InterestRatePositionManager is ERC20RMinter, PositionManager, IInterestRatePositionManager {\n // --- Errors ---\n\n error Unsupported();\n\n // --- Constructor ---\n\n /// @dev Initializes the position manager.\n constructor(IRToken rToken_)\n PositionManager(address(rToken_))\n ERC20RMinter(rToken_, \"Interest Rate Posman\", \"IRPM\")\n { }\n\n // --- External functions ---\n\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n public\n virtual\n override(IPositionManager, PositionManager)\n returns (uint256 actualCollateralChange, uint256 actualDebtChange)\n {\n if (address(permitSignature.token) == address(r)) {\n PermitHelper.applyPermit(permitSignature, msg.sender, address(this));\n }\n return super.managePosition(\n collateralToken,\n position,\n collateralChange,\n isCollateralIncrease,\n debtChange,\n isDebtIncrease,\n maxFeePercentage,\n permitSignature\n );\n }\n\n function mintFees(IERC20 collateralToken, uint256 amount) external {\n if (msg.sender != address(collateralInfo[collateralToken].debtToken)) {\n revert InvalidDebtToken(msg.sender);\n }\n _mintR(feeRecipient, amount);\n\n emit MintedFees(collateralToken, amount);\n }\n\n function redeemCollateral(IERC20, uint256, uint256) public virtual override(IPositionManager, PositionManager) {\n revert Unsupported();\n }\n\n function addCollateralToken(\n IERC20,\n IPriceFeed,\n ISplitLiquidationCollateral\n )\n public\n override(IPositionManager, PositionManager)\n {\n revert Unsupported();\n }\n\n // --- Helper functions ---\n\n function _mintRTokens(address to, uint256 amount) internal virtual override {\n _mintR(to, amount);\n }\n\n function _burnRTokens(address from, uint256 amount) internal virtual override {\n _burnR(from, amount);\n }\n\n function _triggerBorrowingFee(\n IERC20,\n address,\n uint256,\n uint256\n )\n internal\n pure\n virtual\n override\n returns (uint256)\n {\n return 0;\n }\n}\n" + } + }, + "settings": { + "remappings": [ + "@balancer-labs/=node_modules/@balancer-labs/", + "@balancer-labs/v2-interfaces/contracts/=lib/balancer-v2-monorepo/pkg/interfaces/contracts/", + "@chainlink/=node_modules/@chainlink/", + "@eth-optimism/=node_modules/@eth-optimism/", + "@openzeppelin/=node_modules/@openzeppelin/", + "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", + "@redstone-finance/=node_modules/@redstone-finance/", + "@smartcontractkit/chainlink/=lib/chainlink/contracts/src/v0.8/", + "@tempusfinance/=node_modules/@tempusfinance/", + "@tempusfinance/tempus-utils/contracts/=lib/tempus-utils/contracts/", + "balancer-v2-monorepo/=lib/balancer-v2-monorepo/", + "chainlink/=lib/chainlink/", + "ds-test/=lib/forge-std/lib/ds-test/src/", + "erc4626-tests/=lib/chainlink/contracts/foundry-lib/openzeppelin-contracts/lib/erc4626-tests/", + "eth-gas-reporter/=node_modules/eth-gas-reporter/", + "forge-std/=lib/forge-std/src/", + "hardhat/=node_modules/hardhat/", + "openzeppelin-contracts/=lib/openzeppelin-contracts/", + "tempus-utils/=lib/tempus-utils/contracts/" + ], + "optimizer": { + "enabled": true, + "runs": 200000 + }, + "metadata": { + "bytecodeHash": "ipfs", + "appendCBOR": true + }, + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + }, + "evmVersion": "london", + "viaIR": true, + "libraries": {} + } + }, + "ABI": "[{\"inputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"rToken_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AmountIsZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BorrowingSpreadExceedsMaximum\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotLiquidateLastPosition\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenDisabled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DelegateNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FeeEatsUpAllReturnedCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePercentage\",\"type\":\"uint256\"}],\"name\":\"FeeExceedsMaxFee\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"InvalidDebtToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidDelegateAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFeeRecipient\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidMaxFeePercentage\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidPosition\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MaxFeePercentageOutOfRange\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"netDebt\",\"type\":\"uint256\"}],\"name\":\"NetDebtBelowMinimum\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newICR\",\"type\":\"uint256\"}],\"name\":\"NewICRLowerThanMCR\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NoCollateralOrDebtChange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NothingToLiquidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PositionCollateralTokenMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PriceFeedAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RedemptionRebateExceedsMaximum\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RedemptionSpreadOutOfRange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SplitLiquidationCollateralCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newTotalCollateral\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minimumCollateral\",\"type\":\"uint256\"}],\"name\":\"TotalCollateralCannotBeLowerThanMinCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newTotalDebt\",\"type\":\"uint256\"}],\"name\":\"TotalDebtCannotBeLowerThanMinDebt\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unsupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WrongCollateralParamsForFullRepayment\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseRate\",\"type\":\"uint256\"}],\"name\":\"BaseRateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowingSpread\",\"type\":\"uint256\"}],\"name\":\"BorrowingSpreadUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCollateralIncrease\",\"type\":\"bool\"}],\"name\":\"CollateralChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftCollateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftDebtToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"}],\"name\":\"CollateralTokenAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"}],\"name\":\"CollateralTokenModified\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isDebtIncrease\",\"type\":\"bool\"}],\"name\":\"DebtChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"DelegateWhitelisted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"FeeRecipientChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastFeeOpTime\",\"type\":\"uint256\"}],\"name\":\"LastFeeOpTimeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtLiquidated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralLiquidated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralSentToLiquidator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralLiquidationFeePaid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isRedistribution\",\"type\":\"bool\"}],\"name\":\"Liquidation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintedFees\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"PositionClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"PositionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IRToken\",\"name\":\"rToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"PositionManagerDeployed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"RBorrowingFeePaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralSent\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rebate\",\"type\":\"uint256\"}],\"name\":\"Redemption\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redemptionRebate\",\"type\":\"uint256\"}],\"name\":\"RedemptionRebateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redemptionSpread\",\"type\":\"uint256\"}],\"name\":\"RedemptionSpreadUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"}],\"name\":\"SplitLiquidationCollateralChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokensRecovered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BETA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_BORROWING_RATE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_BORROWING_SPREAD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINUTE_DECAY_FACTOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftCollateralToken_\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftDebtToken_\",\"type\":\"address\"}],\"name\":\"addCollateralToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"addCollateralToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"baseRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"borrowingSpread\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"collateralEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"collateralInfo\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"debtToken\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"splitLiquidation\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"lastFeeOperationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowingSpread\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"redemptionSpread\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"redemptionRebate\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"collateralTokenForPosition\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeRecipient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"}],\"name\":\"getBorrowingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getBorrowingRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getBorrowingRateWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"priceDeviation\",\"type\":\"uint256\"}],\"name\":\"getRedemptionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"}],\"name\":\"getRedemptionFeeWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"redemptionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getRedemptionRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getRedemptionRateWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"}],\"name\":\"isDelegateWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isWhitelisted\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"lastFeeOperationTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"liquidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralChange\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isCollateralIncrease\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"debtChange\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isDebtIncrease\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePercentage\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"contract IERC20Permit\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct ERC20PermitSignature\",\"name\":\"permitSignature\",\"type\":\"tuple\"}],\"name\":\"managePosition\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"actualCollateralChange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actualDebtChange\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"positionManager\",\"outputs\":[{\"internalType\":\"contract IPositionManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"priceFeed\",\"outputs\":[{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"r\",\"outputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rToken\",\"outputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"raftCollateralToken\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"raftDebtToken\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"redeemCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"redemptionRebate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"redemptionSpread\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newBorrowingSpread\",\"type\":\"uint256\"}],\"name\":\"setBorrowingSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"}],\"name\":\"setCollateralEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newFeeRecipient\",\"type\":\"address\"}],\"name\":\"setFeeRecipient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newRedemptionRebate\",\"type\":\"uint256\"}],\"name\":\"setRedemptionRebate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newRedemptionSpread\",\"type\":\"uint256\"}],\"name\":\"setRedemptionSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"}],\"name\":\"setSplitLiquidationCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"splitLiquidationCollateral\",\"outputs\":[{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"whitelistDelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + "ContractName": "InterestRatePositionManager", + "CompilerVersion": "v0.8.19+commit.7dd6d404", + "OptimizationUsed": 1, + "Runs": 200000, + "ConstructorArguments": "0x000000000000000000000000183015a9ba6ff60230fdeadc3f43b3d788b13e21", + "EVMVersion": "london", + "Library": "", + "LicenseType": "", + "Proxy": 0, + "SwarmSource": "" + } +] \ No newline at end of file diff --git a/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json new file mode 100644 index 0000000000000..6a1311bb42585 --- /dev/null +++ b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0xdb53f47ac61fe54f456a4eb3e09832d08dd7beec", + "contractCreator": "0xc7f8d87734ab2cbf70030ac8aa82abfe3e8126cb", + "txHash": "0x196898c69f6b1944f1011120b15c0903329d46259c8cdc0fbcad71da1fe58245" +} \ No newline at end of file diff --git a/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json new file mode 100644 index 0000000000000..83c1a063596fa --- /dev/null +++ b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json @@ -0,0 +1,148 @@ +[ + { + "SourceCode": { + "language": "Solidity", + "sources": { + "@solidstate/contracts/token/ERC1155/base/ERC1155Base.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC1155 } from '../IERC1155.sol';\nimport { IERC1155Receiver } from '../IERC1155Receiver.sol';\nimport { ERC1155BaseInternal, ERC1155BaseStorage } from './ERC1155BaseInternal.sol';\n\n/**\n * @title Base ERC1155 contract\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)\n */\nabstract contract ERC1155Base is IERC1155, ERC1155BaseInternal {\n /**\n * @inheritdoc IERC1155\n */\n function balanceOf(address account, uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return _balanceOf(account, id);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function balanceOfBatch(address[] memory accounts, uint256[] memory ids)\n public\n view\n virtual\n override\n returns (uint256[] memory)\n {\n require(\n accounts.length == ids.length,\n 'ERC1155: accounts and ids length mismatch'\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n uint256[] memory batchBalances = new uint256[](accounts.length);\n\n unchecked {\n for (uint256 i; i < accounts.length; i++) {\n require(\n accounts[i] != address(0),\n 'ERC1155: batch balance query for the zero address'\n );\n batchBalances[i] = balances[ids[i]][accounts[i]];\n }\n }\n\n return batchBalances;\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function isApprovedForAll(address account, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n return ERC1155BaseStorage.layout().operatorApprovals[account][operator];\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function setApprovalForAll(address operator, bool status)\n public\n virtual\n override\n {\n require(\n msg.sender != operator,\n 'ERC1155: setting approval status for self'\n );\n ERC1155BaseStorage.layout().operatorApprovals[msg.sender][\n operator\n ] = status;\n emit ApprovalForAll(msg.sender, operator, status);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) public virtual override {\n require(\n from == msg.sender || isApprovedForAll(from, msg.sender),\n 'ERC1155: caller is not owner nor approved'\n );\n _safeTransfer(msg.sender, from, to, id, amount, data);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) public virtual override {\n require(\n from == msg.sender || isApprovedForAll(from, msg.sender),\n 'ERC1155: caller is not owner nor approved'\n );\n _safeTransferBatch(msg.sender, from, to, ids, amounts, data);\n }\n}\n" + }, + "@solidstate/contracts/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC165 interface registration interface\n * @dev see https://eips.ethereum.org/EIPS/eip-165\n */\ninterface IERC165 {\n /**\n * @notice query whether contract has registered support for given interface\n * @param interfaceId interface id\n * @return bool whether interface is supported\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "abdk-libraries-solidity/ABDKMath64x64.sol": { + "content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov \n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x8) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n" + }, + "@solidstate/contracts/token/ERC20/metadata/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC20 metadata interface\n */\ninterface IERC20Metadata {\n /**\n * @notice return token name\n * @return token name\n */\n function name() external view returns (string memory);\n\n /**\n * @notice return token symbol\n * @return token symbol\n */\n function symbol() external view returns (string memory);\n\n /**\n * @notice return token decimals, generally used only for display purposes\n * @return token decimals\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "contracts/staking/FeeDiscountStorage.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nlibrary FeeDiscountStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.staking.PremiaFeeDiscount\");\r\n\r\n struct UserInfo {\r\n uint256 balance; // Balance staked by user\r\n uint64 stakePeriod; // Stake period selected by user\r\n uint64 lockedUntil; // Timestamp at which the lock ends\r\n }\r\n\r\n struct Layout {\r\n // User data with xPREMIA balance staked and date at which lock ends\r\n mapping(address => UserInfo) userInfo;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n}\r\n" + }, + "contracts/libraries/OptionMath.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\n\r\nlibrary OptionMath {\r\n using ABDKMath64x64 for int128;\r\n\r\n struct QuoteArgs {\r\n int128 varianceAnnualized64x64; // 64x64 fixed point representation of annualized variance\r\n int128 strike64x64; // 64x64 fixed point representation of strike price\r\n int128 spot64x64; // 64x64 fixed point representation of spot price\r\n int128 timeToMaturity64x64; // 64x64 fixed point representation of duration of option contract (in years)\r\n int128 oldCLevel64x64; // 64x64 fixed point representation of C-Level of Pool before purchase\r\n int128 oldPoolState; // 64x64 fixed point representation of current state of the pool\r\n int128 newPoolState; // 64x64 fixed point representation of state of the pool after trade\r\n int128 steepness64x64; // 64x64 fixed point representation of Pool state delta multiplier\r\n int128 minAPY64x64; // 64x64 fixed point representation of minimum APY for capital locked up to underwrite options\r\n bool isCall; // whether to price \"call\" or \"put\" option\r\n }\r\n\r\n struct CalculateCLevelDecayArgs {\r\n int128 timeIntervalsElapsed64x64; // 64x64 fixed point representation of quantity of discrete arbitrary intervals elapsed since last update\r\n int128 oldCLevel64x64; // 64x64 fixed point representation of C-Level prior to accounting for decay\r\n int128 utilization64x64; // 64x64 fixed point representation of pool capital utilization rate\r\n int128 utilizationLowerBound64x64;\r\n int128 utilizationUpperBound64x64;\r\n int128 cLevelLowerBound64x64;\r\n int128 cLevelUpperBound64x64;\r\n int128 cConvergenceULowerBound64x64;\r\n int128 cConvergenceUUpperBound64x64;\r\n }\r\n\r\n // 64x64 fixed point integer constants\r\n int128 internal constant ONE_64x64 = 0x10000000000000000;\r\n int128 internal constant THREE_64x64 = 0x30000000000000000;\r\n\r\n // 64x64 fixed point constants used in Choudhury’s approximation of the Black-Scholes CDF\r\n int128 private constant CDF_CONST_0 = 0x09109f285df452394; // 2260 / 3989\r\n int128 private constant CDF_CONST_1 = 0x19abac0ea1da65036; // 6400 / 3989\r\n int128 private constant CDF_CONST_2 = 0x0d3c84b78b749bd6b; // 3300 / 3989\r\n\r\n /**\r\n * @notice recalculate C-Level based on change in liquidity\r\n * @param initialCLevel64x64 64x64 fixed point representation of C-Level of Pool before update\r\n * @param oldPoolState64x64 64x64 fixed point representation of liquidity in pool before update\r\n * @param newPoolState64x64 64x64 fixed point representation of liquidity in pool after update\r\n * @param steepness64x64 64x64 fixed point representation of steepness coefficient\r\n * @return 64x64 fixed point representation of new C-Level\r\n */\r\n function calculateCLevel(\r\n int128 initialCLevel64x64,\r\n int128 oldPoolState64x64,\r\n int128 newPoolState64x64,\r\n int128 steepness64x64\r\n ) external pure returns (int128) {\r\n return\r\n newPoolState64x64\r\n .sub(oldPoolState64x64)\r\n .div(\r\n oldPoolState64x64 > newPoolState64x64\r\n ? oldPoolState64x64\r\n : newPoolState64x64\r\n )\r\n .mul(steepness64x64)\r\n .neg()\r\n .exp()\r\n .mul(initialCLevel64x64);\r\n }\r\n\r\n /**\r\n * @notice calculate the price of an option using the Premia Finance model\r\n * @param args arguments of quotePrice\r\n * @return premiaPrice64x64 64x64 fixed point representation of Premia option price\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level of Pool after purchase\r\n */\r\n function quotePrice(QuoteArgs memory args)\r\n external\r\n pure\r\n returns (\r\n int128 premiaPrice64x64,\r\n int128 cLevel64x64,\r\n int128 slippageCoefficient64x64\r\n )\r\n {\r\n int128 deltaPoolState64x64 = args\r\n .newPoolState\r\n .sub(args.oldPoolState)\r\n .div(args.oldPoolState)\r\n .mul(args.steepness64x64);\r\n int128 tradingDelta64x64 = deltaPoolState64x64.neg().exp();\r\n\r\n int128 blackScholesPrice64x64 = _blackScholesPrice(\r\n args.varianceAnnualized64x64,\r\n args.strike64x64,\r\n args.spot64x64,\r\n args.timeToMaturity64x64,\r\n args.isCall\r\n );\r\n\r\n cLevel64x64 = tradingDelta64x64.mul(args.oldCLevel64x64);\r\n slippageCoefficient64x64 = ONE_64x64.sub(tradingDelta64x64).div(\r\n deltaPoolState64x64\r\n );\r\n\r\n premiaPrice64x64 = blackScholesPrice64x64.mul(cLevel64x64).mul(\r\n slippageCoefficient64x64\r\n );\r\n\r\n int128 intrinsicValue64x64;\r\n\r\n if (args.isCall && args.strike64x64 < args.spot64x64) {\r\n intrinsicValue64x64 = args.spot64x64.sub(args.strike64x64);\r\n } else if (!args.isCall && args.strike64x64 > args.spot64x64) {\r\n intrinsicValue64x64 = args.strike64x64.sub(args.spot64x64);\r\n }\r\n\r\n int128 collateralValue64x64 = args.isCall\r\n ? args.spot64x64\r\n : args.strike64x64;\r\n\r\n int128 minPrice64x64 = intrinsicValue64x64.add(\r\n collateralValue64x64.mul(args.minAPY64x64).mul(\r\n args.timeToMaturity64x64\r\n )\r\n );\r\n\r\n if (minPrice64x64 > premiaPrice64x64) {\r\n premiaPrice64x64 = minPrice64x64;\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate the decay of C-Level based on heat diffusion function\r\n * @param args structured CalculateCLevelDecayArgs\r\n * @return cLevelDecayed64x64 C-Level after accounting for decay\r\n */\r\n function calculateCLevelDecay(CalculateCLevelDecayArgs memory args)\r\n external\r\n pure\r\n returns (int128 cLevelDecayed64x64)\r\n {\r\n int128 convFHighU64x64 = (args.utilization64x64 >=\r\n args.utilizationUpperBound64x64 &&\r\n args.oldCLevel64x64 <= args.cLevelLowerBound64x64)\r\n ? ONE_64x64\r\n : int128(0);\r\n\r\n int128 convFLowU64x64 = (args.utilization64x64 <=\r\n args.utilizationLowerBound64x64 &&\r\n args.oldCLevel64x64 >= args.cLevelUpperBound64x64)\r\n ? ONE_64x64\r\n : int128(0);\r\n\r\n cLevelDecayed64x64 = args\r\n .oldCLevel64x64\r\n .sub(args.cConvergenceULowerBound64x64.mul(convFLowU64x64))\r\n .sub(args.cConvergenceUUpperBound64x64.mul(convFHighU64x64))\r\n .mul(\r\n convFLowU64x64\r\n .mul(ONE_64x64.sub(args.utilization64x64))\r\n .add(convFHighU64x64.mul(args.utilization64x64))\r\n .mul(args.timeIntervalsElapsed64x64)\r\n .neg()\r\n .exp()\r\n )\r\n .add(\r\n args.cConvergenceULowerBound64x64.mul(convFLowU64x64).add(\r\n args.cConvergenceUUpperBound64x64.mul(convFHighU64x64)\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate the exponential decay coefficient for a given interval\r\n * @param oldTimestamp timestamp of previous update\r\n * @param newTimestamp current timestamp\r\n * @return 64x64 fixed point representation of exponential decay coefficient\r\n */\r\n function _decay(uint256 oldTimestamp, uint256 newTimestamp)\r\n internal\r\n pure\r\n returns (int128)\r\n {\r\n return\r\n ONE_64x64.sub(\r\n (-ABDKMath64x64.divu(newTimestamp - oldTimestamp, 7 days)).exp()\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate Choudhury’s approximation of the Black-Scholes CDF\r\n * @param input64x64 64x64 fixed point representation of random variable\r\n * @return 64x64 fixed point representation of the approximated CDF of x\r\n */\r\n function _N(int128 input64x64) internal pure returns (int128) {\r\n // squaring via mul is cheaper than via pow\r\n int128 inputSquared64x64 = input64x64.mul(input64x64);\r\n\r\n int128 value64x64 = (-inputSquared64x64 >> 1).exp().div(\r\n CDF_CONST_0.add(CDF_CONST_1.mul(input64x64.abs())).add(\r\n CDF_CONST_2.mul(inputSquared64x64.add(THREE_64x64).sqrt())\r\n )\r\n );\r\n\r\n return input64x64 > 0 ? ONE_64x64.sub(value64x64) : value64x64;\r\n }\r\n\r\n /**\r\n * @notice calculate the price of an option using the Black-Scholes model\r\n * @param varianceAnnualized64x64 64x64 fixed point representation of annualized variance\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param spot64x64 64x64 fixed point representation of spot price\r\n * @param timeToMaturity64x64 64x64 fixed point representation of duration of option contract (in years)\r\n * @param isCall whether to price \"call\" or \"put\" option\r\n * @return 64x64 fixed point representation of Black-Scholes option price\r\n */\r\n function _blackScholesPrice(\r\n int128 varianceAnnualized64x64,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) internal pure returns (int128) {\r\n int128 cumulativeVariance64x64 = timeToMaturity64x64.mul(\r\n varianceAnnualized64x64\r\n );\r\n int128 cumulativeVarianceSqrt64x64 = cumulativeVariance64x64.sqrt();\r\n\r\n int128 d1_64x64 = spot64x64\r\n .div(strike64x64)\r\n .ln()\r\n .add(cumulativeVariance64x64 >> 1)\r\n .div(cumulativeVarianceSqrt64x64);\r\n int128 d2_64x64 = d1_64x64.sub(cumulativeVarianceSqrt64x64);\r\n\r\n if (isCall) {\r\n return\r\n spot64x64.mul(_N(d1_64x64)).sub(strike64x64.mul(_N(d2_64x64)));\r\n } else {\r\n return\r\n -spot64x64.mul(_N(-d1_64x64)).sub(\r\n strike64x64.mul(_N(-d2_64x64))\r\n );\r\n }\r\n }\r\n}\r\n" + }, + "@solidstate/contracts/access/IERC173.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Contract ownership standard interface\n * @dev see https://eips.ethereum.org/EIPS/eip-173\n */\ninterface IERC173 {\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n /**\n * @notice get the ERC173 contract owner\n * @return conract owner\n */\n function owner() external view returns (address);\n\n /**\n * @notice transfer contract ownership to new account\n * @param account address of new owner\n */\n function transferOwnership(address account) external;\n}\n" + }, + "contracts/libraries/ABDKMath64x64Token.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\n\r\nlibrary ABDKMath64x64Token {\r\n using ABDKMath64x64 for int128;\r\n\r\n /**\r\n * @notice convert 64x64 fixed point representation of token amount to decimal\r\n * @param value64x64 64x64 fixed point representation of token amount\r\n * @param decimals token display decimals\r\n * @return value decimal representation of token amount\r\n */\r\n function toDecimals(int128 value64x64, uint8 decimals)\r\n internal\r\n pure\r\n returns (uint256 value)\r\n {\r\n value = value64x64.mulu(10**decimals);\r\n }\r\n\r\n /**\r\n * @notice convert decimal representation of token amount to 64x64 fixed point\r\n * @param value decimal representation of token amount\r\n * @param decimals token display decimals\r\n * @return value64x64 64x64 fixed point representation of token amount\r\n */\r\n function fromDecimals(uint256 value, uint8 decimals)\r\n internal\r\n pure\r\n returns (int128 value64x64)\r\n {\r\n value64x64 = ABDKMath64x64.divu(value, 10**decimals);\r\n }\r\n\r\n /**\r\n * @notice convert 64x64 fixed point representation of token amount to wei (18 decimals)\r\n * @param value64x64 64x64 fixed point representation of token amount\r\n * @return value wei representation of token amount\r\n */\r\n function toWei(int128 value64x64) internal pure returns (uint256 value) {\r\n value = toDecimals(value64x64, 18);\r\n }\r\n\r\n /**\r\n * @notice convert wei representation (18 decimals) of token amount to 64x64 fixed point\r\n * @param value wei representation of token amount\r\n * @return value64x64 64x64 fixed point representation of token amount\r\n */\r\n function fromWei(uint256 value) internal pure returns (int128 value64x64) {\r\n value64x64 = fromDecimals(value, 18);\r\n }\r\n}\r\n" + }, + "@solidstate/contracts/token/ERC1155/IERC1155.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC1155Internal } from './IERC1155Internal.sol';\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @notice ERC1155 interface\n * @dev see https://github.com/ethereum/EIPs/issues/1155\n */\ninterface IERC1155 is IERC1155Internal, IERC165 {\n /**\n * @notice query the balance of given token held by given address\n * @param account address to query\n * @param id token to query\n * @return token balance\n */\n function balanceOf(address account, uint256 id)\n external\n view\n returns (uint256);\n\n /**\n * @notice query the balances of given tokens held by given addresses\n * @param accounts addresss to query\n * @param ids tokens to query\n * @return token balances\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @notice query approval status of given operator with respect to given address\n * @param account address to query for approval granted\n * @param operator address to query for approval received\n * @return whether operator is approved to spend tokens held by account\n */\n function isApprovedForAll(address account, address operator)\n external\n view\n returns (bool);\n\n /**\n * @notice grant approval to or revoke approval from given operator to spend held tokens\n * @param operator address whose approval status to update\n * @param status whether operator should be considered approved\n */\n function setApprovalForAll(address operator, bool status) external;\n\n /**\n * @notice transfer tokens between given addresses, checking for ERC1155Receiver implementation if applicable\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @notice transfer batch of tokens between given addresses, checking for ERC1155Receiver implementation if applicable\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to transfer\n * @param data data payload\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n" + }, + "contracts/staking/IFeeDiscount.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {FeeDiscountStorage} from \"./FeeDiscountStorage.sol\";\r\n\r\ninterface IFeeDiscount {\r\n event Staked(\r\n address indexed user,\r\n uint256 amount,\r\n uint256 stakePeriod,\r\n uint256 lockedUntil\r\n );\r\n event Unstaked(address indexed user, uint256 amount);\r\n\r\n struct StakeLevel {\r\n uint256 amount; // Amount to stake\r\n uint256 discount; // Discount when amount is reached\r\n }\r\n\r\n /**\r\n * @notice Stake using IERC2612 permit\r\n * @param amount The amount of xPremia to stake\r\n * @param period The lockup period (in seconds)\r\n * @param deadline Deadline after which permit will fail\r\n * @param v V\r\n * @param r R\r\n * @param s S\r\n */\r\n function stakeWithPermit(\r\n uint256 amount,\r\n uint256 period,\r\n uint256 deadline,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external;\r\n\r\n /**\r\n * @notice Lockup xPremia for protocol fee discounts\r\n * Longer period of locking will apply a multiplier on the amount staked, in the fee discount calculation\r\n * @param amount The amount of xPremia to stake\r\n * @param period The lockup period (in seconds)\r\n */\r\n function stake(uint256 amount, uint256 period) external;\r\n\r\n /**\r\n * @notice Unstake xPremia (If lockup period has ended)\r\n * @param amount The amount of xPremia to unstake\r\n */\r\n function unstake(uint256 amount) external;\r\n\r\n //////////\r\n // View //\r\n //////////\r\n\r\n /**\r\n * Calculate the stake amount of a user, after applying the bonus from the lockup period chosen\r\n * @param user The user from which to query the stake amount\r\n * @return The user stake amount after applying the bonus\r\n */\r\n function getStakeAmountWithBonus(address user)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n /**\r\n * @notice Calculate the % of fee discount for user, based on his stake\r\n * @param user The _user for which the discount is for\r\n * @return Percentage of protocol fee discount (in basis point)\r\n * Ex : 1000 = 10% fee discount\r\n */\r\n function getDiscount(address user) external view returns (uint256);\r\n\r\n /**\r\n * @notice Get stake levels\r\n * @return Stake levels\r\n * Ex : 2500 = -25%\r\n */\r\n function getStakeLevels() external returns (StakeLevel[] memory);\r\n\r\n /**\r\n * @notice Get stake period multiplier\r\n * @param period The duration (in seconds) for which tokens are locked\r\n * @return The multiplier for this staking period\r\n * Ex : 20000 = x2\r\n */\r\n function getStakePeriodMultiplier(uint256 period)\r\n external\r\n returns (uint256);\r\n\r\n /**\r\n * @notice Get staking infos of a user\r\n * @param user The user address for which to get staking infos\r\n * @return The staking infos of the user\r\n */\r\n function getUserInfo(address user)\r\n external\r\n view\r\n returns (FeeDiscountStorage.UserInfo memory);\r\n}\r\n" + }, + "@solidstate/contracts/token/ERC1155/base/ERC1155BaseInternal.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { AddressUtils } from '../../../utils/AddressUtils.sol';\nimport { IERC1155Internal } from '../IERC1155Internal.sol';\nimport { IERC1155Receiver } from '../IERC1155Receiver.sol';\nimport { ERC1155BaseStorage } from './ERC1155BaseStorage.sol';\n\n/**\n * @title Base ERC1155 internal functions\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)\n */\nabstract contract ERC1155BaseInternal is IERC1155Internal {\n using AddressUtils for address;\n\n /**\n * @notice query the balance of given token held by given address\n * @param account address to query\n * @param id token to query\n * @return token balance\n */\n function _balanceOf(address account, uint256 id)\n internal\n view\n virtual\n returns (uint256)\n {\n require(\n account != address(0),\n 'ERC1155: balance query for the zero address'\n );\n return ERC1155BaseStorage.layout().balances[id][account];\n }\n\n /**\n * @notice mint given quantity of tokens for given address\n * @dev ERC1155Receiver implementation is not checked\n * @param account beneficiary of minting\n * @param id token ID\n * @param amount quantity of tokens to mint\n * @param data data payload\n */\n function _mint(\n address account,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(account != address(0), 'ERC1155: mint to the zero address');\n\n _beforeTokenTransfer(\n msg.sender,\n address(0),\n account,\n _asSingletonArray(id),\n _asSingletonArray(amount),\n data\n );\n\n mapping(address => uint256) storage balances = ERC1155BaseStorage\n .layout()\n .balances[id];\n balances[account] += amount;\n\n emit TransferSingle(msg.sender, address(0), account, id, amount);\n }\n\n /**\n * @notice mint given quantity of tokens for given address\n * @param account beneficiary of minting\n * @param id token ID\n * @param amount quantity of tokens to mint\n * @param data data payload\n */\n function _safeMint(\n address account,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n _mint(account, id, amount, data);\n\n _doSafeTransferAcceptanceCheck(\n msg.sender,\n address(0),\n account,\n id,\n amount,\n data\n );\n }\n\n /**\n * @notice mint batch of tokens for given address\n * @dev ERC1155Receiver implementation is not checked\n * @param account beneficiary of minting\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to mint\n * @param data data payload\n */\n function _mintBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(account != address(0), 'ERC1155: mint to the zero address');\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(\n msg.sender,\n address(0),\n account,\n ids,\n amounts,\n data\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n for (uint256 i; i < ids.length; i++) {\n balances[ids[i]][account] += amounts[i];\n }\n\n emit TransferBatch(msg.sender, address(0), account, ids, amounts);\n }\n\n /**\n * @notice mint batch of tokens for given address\n * @param account beneficiary of minting\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to mint\n * @param data data payload\n */\n function _safeMintBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _mintBatch(account, ids, amounts, data);\n\n _doSafeBatchTransferAcceptanceCheck(\n msg.sender,\n address(0),\n account,\n ids,\n amounts,\n data\n );\n }\n\n /**\n * @notice burn given quantity of tokens held by given address\n * @param account holder of tokens to burn\n * @param id token ID\n * @param amount quantity of tokens to burn\n */\n function _burn(\n address account,\n uint256 id,\n uint256 amount\n ) internal virtual {\n require(account != address(0), 'ERC1155: burn from the zero address');\n\n _beforeTokenTransfer(\n msg.sender,\n account,\n address(0),\n _asSingletonArray(id),\n _asSingletonArray(amount),\n ''\n );\n\n mapping(address => uint256) storage balances = ERC1155BaseStorage\n .layout()\n .balances[id];\n\n unchecked {\n require(\n balances[account] >= amount,\n 'ERC1155: burn amount exceeds balances'\n );\n balances[account] -= amount;\n }\n\n emit TransferSingle(msg.sender, account, address(0), id, amount);\n }\n\n /**\n * @notice burn given batch of tokens held by given address\n * @param account holder of tokens to burn\n * @param ids token IDs\n * @param amounts quantities of tokens to burn\n */\n function _burnBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal virtual {\n require(account != address(0), 'ERC1155: burn from the zero address');\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(msg.sender, account, address(0), ids, amounts, '');\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n unchecked {\n for (uint256 i; i < ids.length; i++) {\n uint256 id = ids[i];\n require(\n balances[id][account] >= amounts[i],\n 'ERC1155: burn amount exceeds balance'\n );\n balances[id][account] -= amounts[i];\n }\n }\n\n emit TransferBatch(msg.sender, account, address(0), ids, amounts);\n }\n\n /**\n * @notice transfer tokens between given addresses\n * @dev ERC1155Receiver implementation is not checked\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _transfer(\n address operator,\n address sender,\n address recipient,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(\n recipient != address(0),\n 'ERC1155: transfer to the zero address'\n );\n\n _beforeTokenTransfer(\n operator,\n sender,\n recipient,\n _asSingletonArray(id),\n _asSingletonArray(amount),\n data\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n unchecked {\n uint256 senderBalance = balances[id][sender];\n require(\n senderBalance >= amount,\n 'ERC1155: insufficient balances for transfer'\n );\n balances[id][sender] = senderBalance - amount;\n }\n\n balances[id][recipient] += amount;\n\n emit TransferSingle(operator, sender, recipient, id, amount);\n }\n\n /**\n * @notice transfer tokens between given addresses\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _safeTransfer(\n address operator,\n address sender,\n address recipient,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n _transfer(operator, sender, recipient, id, amount, data);\n\n _doSafeTransferAcceptanceCheck(\n operator,\n sender,\n recipient,\n id,\n amount,\n data\n );\n }\n\n /**\n * @notice transfer batch of tokens between given addresses\n * @dev ERC1155Receiver implementation is not checked\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _transferBatch(\n address operator,\n address sender,\n address recipient,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(\n recipient != address(0),\n 'ERC1155: transfer to the zero address'\n );\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(operator, sender, recipient, ids, amounts, data);\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n for (uint256 i; i < ids.length; i++) {\n uint256 token = ids[i];\n uint256 amount = amounts[i];\n\n unchecked {\n uint256 senderBalance = balances[token][sender];\n require(\n senderBalance >= amount,\n 'ERC1155: insufficient balances for transfer'\n );\n balances[token][sender] = senderBalance - amount;\n }\n\n balances[token][recipient] += amount;\n }\n\n emit TransferBatch(operator, sender, recipient, ids, amounts);\n }\n\n /**\n * @notice transfer batch of tokens between given addresses\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _safeTransferBatch(\n address operator,\n address sender,\n address recipient,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _transferBatch(operator, sender, recipient, ids, amounts, data);\n\n _doSafeBatchTransferAcceptanceCheck(\n operator,\n sender,\n recipient,\n ids,\n amounts,\n data\n );\n }\n\n /**\n * @notice wrap given element in array of length 1\n * @param element element to wrap\n * @return singleton array\n */\n function _asSingletonArray(uint256 element)\n private\n pure\n returns (uint256[] memory)\n {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n /**\n * @notice revert if applicable transfer recipient is not valid ERC1155Receiver\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _doSafeTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try\n IERC1155Receiver(to).onERC1155Received(\n operator,\n from,\n id,\n amount,\n data\n )\n returns (bytes4 response) {\n require(\n response == IERC1155Receiver.onERC1155Received.selector,\n 'ERC1155: ERC1155Receiver rejected tokens'\n );\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert('ERC1155: transfer to non ERC1155Receiver implementer');\n }\n }\n }\n\n /**\n * @notice revert if applicable transfer recipient is not valid ERC1155Receiver\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _doSafeBatchTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try\n IERC1155Receiver(to).onERC1155BatchReceived(\n operator,\n from,\n ids,\n amounts,\n data\n )\n returns (bytes4 response) {\n require(\n response ==\n IERC1155Receiver.onERC1155BatchReceived.selector,\n 'ERC1155: ERC1155Receiver rejected tokens'\n );\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert('ERC1155: transfer to non ERC1155Receiver implementer');\n }\n }\n }\n\n /**\n * @notice ERC1155 hook, called before all transfers including mint and burn\n * @dev function should be overridden and new implementation must call super\n * @dev called for both single and batch transfers\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n}\n" + }, + "@solidstate/contracts/token/ERC20/IERC20Internal.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Partial ERC20 interface needed by internal functions\n */\ninterface IERC20Internal {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer()\n external\n view\n returns (\n int256\n );\n \n function latestTimestamp()\n external\n view\n returns (\n uint256\n );\n\n function latestRound()\n external\n view\n returns (\n uint256\n );\n\n function getAnswer(\n uint256 roundId\n )\n external\n view\n returns (\n int256\n );\n\n function getTimestamp(\n uint256 roundId\n )\n external\n view\n returns (\n uint256\n );\n\n event AnswerUpdated(\n int256 indexed current,\n uint256 indexed roundId,\n uint256 updatedAt\n );\n\n event NewRound(\n uint256 indexed roundId,\n address indexed startedBy,\n uint256 startedAt\n );\n}\n" + }, + "contracts/pool/PoolExercise.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ERC1155BaseStorage} from \"@solidstate/contracts/token/ERC1155/base/ERC1155BaseStorage.sol\";\r\n\r\nimport {PoolInternal} from \"./PoolInternal.sol\";\r\nimport {IPoolExercise} from \"./IPoolExercise.sol\";\r\n\r\n/**\r\n * @title Premia option pool\r\n * @dev deployed standalone and referenced by PoolProxy\r\n */\r\ncontract PoolExercise is IPoolExercise, PoolInternal {\r\n constructor(\r\n address ivolOracle,\r\n address weth,\r\n address premiaMining,\r\n address feeReceiver,\r\n address feeDiscountAddress,\r\n int128 fee64x64\r\n )\r\n PoolInternal(\r\n ivolOracle,\r\n weth,\r\n premiaMining,\r\n feeReceiver,\r\n feeDiscountAddress,\r\n fee64x64\r\n )\r\n {}\r\n\r\n /**\r\n * @inheritdoc IPoolExercise\r\n */\r\n function exerciseFrom(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) external override {\r\n if (msg.sender != holder) {\r\n require(\r\n ERC1155BaseStorage.layout().operatorApprovals[holder][\r\n msg.sender\r\n ],\r\n \"not approved\"\r\n );\r\n }\r\n\r\n _exercise(holder, longTokenId, contractSize);\r\n }\r\n\r\n /**\r\n * @inheritdoc IPoolExercise\r\n */\r\n function processExpired(uint256 longTokenId, uint256 contractSize)\r\n external\r\n override\r\n {\r\n _exercise(address(0), longTokenId, contractSize);\r\n }\r\n}\r\n" + }, + "contracts/pool/IPoolExercise.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @notice Pool interface for exercising and processing of expired options\r\n */\r\ninterface IPoolExercise {\r\n /**\r\n * @notice exercise option on behalf of holder\r\n * @param holder owner of long option tokens to exercise\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to exercise\r\n */\r\n function exerciseFrom(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) external;\r\n\r\n /**\r\n * @notice process expired option, freeing liquidity and distributing profits\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to process\r\n */\r\n function processExpired(uint256 longTokenId, uint256 contractSize) external;\r\n}\r\n" + }, + "contracts/pool/PoolStorage.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {AggregatorInterface} from \"@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol\";\r\nimport {AggregatorV3Interface} from \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\r\nimport {EnumerableSet, ERC1155EnumerableStorage} from \"@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableStorage.sol\";\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\nimport {ABDKMath64x64Token} from \"../libraries/ABDKMath64x64Token.sol\";\r\nimport {OptionMath} from \"../libraries/OptionMath.sol\";\r\n\r\nlibrary PoolStorage {\r\n using ABDKMath64x64 for int128;\r\n using PoolStorage for PoolStorage.Layout;\r\n\r\n enum TokenType {\r\n UNDERLYING_FREE_LIQ,\r\n BASE_FREE_LIQ,\r\n UNDERLYING_RESERVED_LIQ,\r\n BASE_RESERVED_LIQ,\r\n LONG_CALL,\r\n SHORT_CALL,\r\n LONG_PUT,\r\n SHORT_PUT\r\n }\r\n\r\n struct PoolSettings {\r\n address underlying;\r\n address base;\r\n address underlyingOracle;\r\n address baseOracle;\r\n }\r\n\r\n struct QuoteArgsInternal {\r\n address feePayer; // address of the fee payer\r\n uint64 maturity; // timestamp of option maturity\r\n int128 strike64x64; // 64x64 fixed point representation of strike price\r\n int128 spot64x64; // 64x64 fixed point representation of spot price\r\n uint256 contractSize; // size of option contract\r\n bool isCall; // true for call, false for put\r\n }\r\n\r\n struct QuoteResultInternal {\r\n int128 baseCost64x64; // 64x64 fixed point representation of option cost denominated in underlying currency (without fee)\r\n int128 feeCost64x64; // 64x64 fixed point representation of option fee cost denominated in underlying currency for call, or base currency for put\r\n int128 cLevel64x64; // 64x64 fixed point representation of C-Level of Pool after purchase\r\n int128 slippageCoefficient64x64; // 64x64 fixed point representation of slippage coefficient for given order size\r\n }\r\n\r\n struct BatchData {\r\n uint256 eta;\r\n uint256 totalPendingDeposits;\r\n }\r\n\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.Pool\");\r\n\r\n uint256 private constant C_DECAY_BUFFER = 12 hours;\r\n uint256 private constant C_DECAY_INTERVAL = 4 hours;\r\n\r\n struct Layout {\r\n // ERC20 token addresses\r\n address base;\r\n address underlying;\r\n // AggregatorV3Interface oracle addresses\r\n address baseOracle;\r\n address underlyingOracle;\r\n // token metadata\r\n uint8 underlyingDecimals;\r\n uint8 baseDecimals;\r\n // minimum amounts\r\n uint256 baseMinimum;\r\n uint256 underlyingMinimum;\r\n // deposit caps\r\n uint256 basePoolCap;\r\n uint256 underlyingPoolCap;\r\n // market state\r\n int128 _deprecated_steepness64x64;\r\n int128 cLevelBase64x64;\r\n int128 cLevelUnderlying64x64;\r\n uint256 cLevelBaseUpdatedAt;\r\n uint256 cLevelUnderlyingUpdatedAt;\r\n uint256 updatedAt;\r\n // User -> isCall -> depositedAt\r\n mapping(address => mapping(bool => uint256)) depositedAt;\r\n mapping(address => mapping(bool => uint256)) divestmentTimestamps;\r\n // doubly linked list of free liquidity intervals\r\n // isCall -> User -> User\r\n mapping(bool => mapping(address => address)) liquidityQueueAscending;\r\n mapping(bool => mapping(address => address)) liquidityQueueDescending;\r\n // minimum resolution price bucket => price\r\n mapping(uint256 => int128) bucketPrices64x64;\r\n // sequence id (minimum resolution price bucket / 256) => price update sequence\r\n mapping(uint256 => uint256) priceUpdateSequences;\r\n // isCall -> batch data\r\n mapping(bool => BatchData) nextDeposits;\r\n // user -> batch timestamp -> isCall -> pending amount\r\n mapping(address => mapping(uint256 => mapping(bool => uint256))) pendingDeposits;\r\n EnumerableSet.UintSet tokenIds;\r\n // user -> isCallPool -> total value locked of user (Used for liquidity mining)\r\n mapping(address => mapping(bool => uint256)) userTVL;\r\n // isCallPool -> total value locked\r\n mapping(bool => uint256) totalTVL;\r\n // steepness values\r\n int128 steepnessBase64x64;\r\n int128 steepnessUnderlying64x64;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate ERC1155 token id for given option parameters\r\n * @param tokenType TokenType enum\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @return tokenId token id\r\n */\r\n function formatTokenId(\r\n TokenType tokenType,\r\n uint64 maturity,\r\n int128 strike64x64\r\n ) internal pure returns (uint256 tokenId) {\r\n tokenId =\r\n (uint256(tokenType) << 248) +\r\n (uint256(maturity) << 128) +\r\n uint256(int256(strike64x64));\r\n }\r\n\r\n /**\r\n * @notice derive option maturity and strike price from ERC1155 token id\r\n * @param tokenId token id\r\n * @return tokenType TokenType enum\r\n * @return maturity timestamp of option maturity\r\n * @return strike64x64 option strike price\r\n */\r\n function parseTokenId(uint256 tokenId)\r\n internal\r\n pure\r\n returns (\r\n TokenType tokenType,\r\n uint64 maturity,\r\n int128 strike64x64\r\n )\r\n {\r\n assembly {\r\n tokenType := shr(248, tokenId)\r\n maturity := shr(128, tokenId)\r\n strike64x64 := tokenId\r\n }\r\n }\r\n\r\n function getTokenDecimals(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint8 decimals)\r\n {\r\n decimals = isCall ? l.underlyingDecimals : l.baseDecimals;\r\n }\r\n\r\n /**\r\n * @notice get the total supply of free liquidity tokens, minus pending deposits\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return 64x64 fixed point representation of total free liquidity\r\n */\r\n function totalFreeLiquiditySupply64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n uint256 tokenId = formatTokenId(\r\n isCall ? TokenType.UNDERLYING_FREE_LIQ : TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n return\r\n ABDKMath64x64Token.fromDecimals(\r\n ERC1155EnumerableStorage.layout().totalSupply[tokenId] -\r\n l.nextDeposits[isCall].totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n );\r\n }\r\n\r\n function getReinvestmentStatus(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal view returns (bool) {\r\n uint256 timestamp = l.divestmentTimestamps[account][isCallPool];\r\n return timestamp == 0 || timestamp > block.timestamp;\r\n }\r\n\r\n function addUnderwriter(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal {\r\n require(account != address(0));\r\n\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n if (_isInQueue(account, asc, desc)) return;\r\n\r\n address last = desc[address(0)];\r\n\r\n asc[last] = account;\r\n desc[account] = last;\r\n desc[address(0)] = account;\r\n }\r\n\r\n function removeUnderwriter(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal {\r\n require(account != address(0));\r\n\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n if (!_isInQueue(account, asc, desc)) return;\r\n\r\n address prev = desc[account];\r\n address next = asc[account];\r\n asc[prev] = next;\r\n desc[next] = prev;\r\n delete asc[account];\r\n delete desc[account];\r\n }\r\n\r\n function isInQueue(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal view returns (bool) {\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n return _isInQueue(account, asc, desc);\r\n }\r\n\r\n function _isInQueue(\r\n address account,\r\n mapping(address => address) storage asc,\r\n mapping(address => address) storage desc\r\n ) private view returns (bool) {\r\n return asc[account] != address(0) || desc[address(0)] == account;\r\n }\r\n\r\n /**\r\n * @notice get current C-Level, without accounting for pending adjustments\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function getRawCLevel64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128 cLevel64x64)\r\n {\r\n cLevel64x64 = isCall ? l.cLevelUnderlying64x64 : l.cLevelBase64x64;\r\n }\r\n\r\n /**\r\n * @notice get current C-Level, accounting for unrealized decay\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function getDecayAdjustedCLevel64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128 cLevel64x64)\r\n {\r\n // get raw C-Level from storage\r\n cLevel64x64 = l.getRawCLevel64x64(isCall);\r\n\r\n // account for C-Level decay\r\n cLevel64x64 = l.applyCLevelDecayAdjustment(cLevel64x64, isCall);\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for unrealized decay\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for decay\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level of Pool after accounting for decay\r\n */\r\n function applyCLevelDecayAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n bool isCall\r\n ) internal view returns (int128 cLevel64x64) {\r\n uint256 timeElapsed = block.timestamp -\r\n (isCall ? l.cLevelUnderlyingUpdatedAt : l.cLevelBaseUpdatedAt);\r\n\r\n // do not apply C decay if less than 24 hours have elapsed\r\n\r\n if (timeElapsed > C_DECAY_BUFFER) {\r\n timeElapsed -= C_DECAY_BUFFER;\r\n } else {\r\n return oldCLevel64x64;\r\n }\r\n\r\n int128 timeIntervalsElapsed64x64 = ABDKMath64x64.divu(\r\n timeElapsed,\r\n C_DECAY_INTERVAL\r\n );\r\n\r\n uint256 tokenId = formatTokenId(\r\n isCall ? TokenType.UNDERLYING_FREE_LIQ : TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n uint256 tvl = l.totalTVL[isCall];\r\n\r\n int128 utilization = ABDKMath64x64.divu(\r\n tvl -\r\n (ERC1155EnumerableStorage.layout().totalSupply[tokenId] -\r\n l.nextDeposits[isCall].totalPendingDeposits),\r\n tvl\r\n );\r\n\r\n return\r\n OptionMath.calculateCLevelDecay(\r\n OptionMath.CalculateCLevelDecayArgs(\r\n timeIntervalsElapsed64x64,\r\n oldCLevel64x64,\r\n utilization,\r\n 0xb333333333333333, // 0.7\r\n 0xe666666666666666, // 0.9\r\n 0x10000000000000000, // 1.0\r\n 0x10000000000000000, // 1.0\r\n 0xe666666666666666, // 0.9\r\n 0x56fc2a2c515da32ea // 2e\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for pending deposits\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for liquidity change\r\n * @param oldLiquidity64x64 64x64 fixed point representation of previous liquidity\r\n * @param isCall whether to update C-Level for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n * @return liquidity64x64 64x64 fixed point representation of new liquidity amount\r\n */\r\n function applyCLevelPendingDepositAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n int128 oldLiquidity64x64,\r\n bool isCall\r\n ) internal view returns (int128 cLevel64x64, int128 liquidity64x64) {\r\n PoolStorage.BatchData storage batchData = l.nextDeposits[isCall];\r\n int128 pendingDeposits64x64;\r\n\r\n if (\r\n batchData.totalPendingDeposits > 0 &&\r\n batchData.eta != 0 &&\r\n block.timestamp >= batchData.eta\r\n ) {\r\n pendingDeposits64x64 = ABDKMath64x64Token.fromDecimals(\r\n batchData.totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n liquidity64x64 = oldLiquidity64x64.add(pendingDeposits64x64);\r\n\r\n cLevel64x64 = l.applyCLevelLiquidityChangeAdjustment(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n liquidity64x64,\r\n isCall\r\n );\r\n } else {\r\n cLevel64x64 = oldCLevel64x64;\r\n liquidity64x64 = oldLiquidity64x64;\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for change in liquidity\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for liquidity change\r\n * @param oldLiquidity64x64 64x64 fixed point representation of previous liquidity\r\n * @param newLiquidity64x64 64x64 fixed point representation of current liquidity\r\n * @param isCallPool whether to update C-Level for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function applyCLevelLiquidityChangeAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64,\r\n bool isCallPool\r\n ) internal view returns (int128 cLevel64x64) {\r\n int128 steepness64x64 = isCallPool\r\n ? l.steepnessUnderlying64x64\r\n : l.steepnessBase64x64;\r\n\r\n // fallback to deprecated storage value if side-specific value is not set\r\n if (steepness64x64 == 0) steepness64x64 = l._deprecated_steepness64x64;\r\n\r\n cLevel64x64 = OptionMath.calculateCLevel(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64,\r\n steepness64x64\r\n );\r\n\r\n if (cLevel64x64 < 0xb333333333333333) {\r\n cLevel64x64 = int128(0xb333333333333333); // 64x64 fixed point representation of 0.7\r\n }\r\n }\r\n\r\n /**\r\n * @notice set C-Level to arbitrary pre-calculated value\r\n * @param cLevel64x64 new C-Level of pool\r\n * @param isCallPool whether to update C-Level for call or put pool\r\n */\r\n function setCLevel(\r\n Layout storage l,\r\n int128 cLevel64x64,\r\n bool isCallPool\r\n ) internal {\r\n if (isCallPool) {\r\n l.cLevelUnderlying64x64 = cLevel64x64;\r\n l.cLevelUnderlyingUpdatedAt = block.timestamp;\r\n } else {\r\n l.cLevelBase64x64 = cLevel64x64;\r\n l.cLevelBaseUpdatedAt = block.timestamp;\r\n }\r\n }\r\n\r\n function setOracles(\r\n Layout storage l,\r\n address baseOracle,\r\n address underlyingOracle\r\n ) internal {\r\n require(\r\n AggregatorV3Interface(baseOracle).decimals() ==\r\n AggregatorV3Interface(underlyingOracle).decimals(),\r\n \"Pool: oracle decimals must match\"\r\n );\r\n\r\n l.baseOracle = baseOracle;\r\n l.underlyingOracle = underlyingOracle;\r\n }\r\n\r\n function fetchPriceUpdate(Layout storage l)\r\n internal\r\n view\r\n returns (int128 price64x64)\r\n {\r\n int256 priceUnderlying = AggregatorInterface(l.underlyingOracle)\r\n .latestAnswer();\r\n int256 priceBase = AggregatorInterface(l.baseOracle).latestAnswer();\r\n\r\n return ABDKMath64x64.divi(priceUnderlying, priceBase);\r\n }\r\n\r\n /**\r\n * @notice set price update for hourly bucket corresponding to given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to update\r\n * @param price64x64 64x64 fixed point representation of price\r\n */\r\n function setPriceUpdate(\r\n Layout storage l,\r\n uint256 timestamp,\r\n int128 price64x64\r\n ) internal {\r\n uint256 bucket = timestamp / (1 hours);\r\n l.bucketPrices64x64[bucket] = price64x64;\r\n l.priceUpdateSequences[bucket >> 8] += 1 << (255 - (bucket & 255));\r\n }\r\n\r\n /**\r\n * @notice get price update for hourly bucket corresponding to given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to query\r\n * @return 64x64 fixed point representation of price\r\n */\r\n function getPriceUpdate(Layout storage l, uint256 timestamp)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n return l.bucketPrices64x64[timestamp / (1 hours)];\r\n }\r\n\r\n /**\r\n * @notice get first price update available following given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to query\r\n * @return 64x64 fixed point representation of price\r\n */\r\n function getPriceUpdateAfter(Layout storage l, uint256 timestamp)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n // price updates are grouped into hourly buckets\r\n uint256 bucket = timestamp / (1 hours);\r\n // divide by 256 to get the index of the relevant price update sequence\r\n uint256 sequenceId = bucket >> 8;\r\n\r\n // get position within sequence relevant to current price update\r\n\r\n uint256 offset = bucket & 255;\r\n // shift to skip buckets from earlier in sequence\r\n uint256 sequence = (l.priceUpdateSequences[sequenceId] << offset) >>\r\n offset;\r\n\r\n // iterate through future sequences until a price update is found\r\n // sequence corresponding to current timestamp used as upper bound\r\n\r\n uint256 currentPriceUpdateSequenceId = block.timestamp / (256 hours);\r\n\r\n while (sequence == 0 && sequenceId <= currentPriceUpdateSequenceId) {\r\n sequence = l.priceUpdateSequences[++sequenceId];\r\n }\r\n\r\n // if no price update is found (sequence == 0) function will return 0\r\n // this should never occur, as each relevant external function triggers a price update\r\n\r\n // the most significant bit of the sequence corresponds to the offset of the relevant bucket\r\n\r\n uint256 msb;\r\n\r\n for (uint256 i = 128; i > 0; i >>= 1) {\r\n if (sequence >> i > 0) {\r\n msb += i;\r\n sequence >>= i;\r\n }\r\n }\r\n\r\n return l.bucketPrices64x64[((sequenceId + 1) << 8) - msb - 1];\r\n }\r\n\r\n function fromBaseToUnderlyingDecimals(Layout storage l, uint256 value)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n int128 valueFixed64x64 = ABDKMath64x64Token.fromDecimals(\r\n value,\r\n l.baseDecimals\r\n );\r\n return\r\n ABDKMath64x64Token.toDecimals(\r\n valueFixed64x64,\r\n l.underlyingDecimals\r\n );\r\n }\r\n\r\n function fromUnderlyingToBaseDecimals(Layout storage l, uint256 value)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n int128 valueFixed64x64 = ABDKMath64x64Token.fromDecimals(\r\n value,\r\n l.underlyingDecimals\r\n );\r\n return ABDKMath64x64Token.toDecimals(valueFixed64x64, l.baseDecimals);\r\n }\r\n}\r\n" + }, + "@solidstate/contracts/utils/AddressUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary AddressUtils {\n function toString(address account) internal pure returns (string memory) {\n bytes32 value = bytes32(uint256(uint160(account)));\n bytes memory alphabet = '0123456789abcdef';\n bytes memory chars = new bytes(42);\n\n chars[0] = '0';\n chars[1] = 'x';\n\n for (uint256 i = 0; i < 20; i++) {\n chars[2 + i * 2] = alphabet[uint8(value[i + 12] >> 4)];\n chars[3 + i * 2] = alphabet[uint8(value[i + 12] & 0x0f)];\n }\n\n return string(chars);\n }\n\n function isContract(address account) internal view returns (bool) {\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n function sendValue(address payable account, uint256 amount) internal {\n (bool success, ) = account.call{ value: amount }('');\n require(success, 'AddressUtils: failed to send value');\n }\n\n function functionCall(address target, bytes memory data)\n internal\n returns (bytes memory)\n {\n return\n functionCall(target, data, 'AddressUtils: failed low-level call');\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory error\n ) internal returns (bytes memory) {\n return _functionCallWithValue(target, data, 0, error);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n 'AddressUtils: failed low-level call with value'\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory error\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n 'AddressUtils: insufficient balance for call'\n );\n return _functionCallWithValue(target, data, value, error);\n }\n\n function _functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory error\n ) private returns (bytes memory) {\n require(\n isContract(target),\n 'AddressUtils: function call to non-contract'\n );\n\n (bool success, bytes memory returnData) = target.call{ value: value }(\n data\n );\n\n if (success) {\n return returnData;\n } else if (returnData.length > 0) {\n assembly {\n let returnData_size := mload(returnData)\n revert(add(32, returnData), returnData_size)\n }\n } else {\n revert(error);\n }\n }\n}\n" + }, + "@solidstate/contracts/token/ERC1155/enumerable/ERC1155Enumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\nimport { ERC1155Base, ERC1155BaseInternal } from '../base/ERC1155Base.sol';\nimport { IERC1155Enumerable } from './IERC1155Enumerable.sol';\nimport { ERC1155EnumerableInternal, ERC1155EnumerableStorage } from './ERC1155EnumerableInternal.sol';\n\n/**\n * @title ERC1155 implementation including enumerable and aggregate functions\n */\nabstract contract ERC1155Enumerable is\n IERC1155Enumerable,\n ERC1155Base,\n ERC1155EnumerableInternal\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function totalSupply(uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return ERC1155EnumerableStorage.layout().totalSupply[id];\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function totalHolders(uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return ERC1155EnumerableStorage.layout().accountsByToken[id].length();\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function accountsByToken(uint256 id)\n public\n view\n virtual\n override\n returns (address[] memory)\n {\n EnumerableSet.AddressSet storage accounts = ERC1155EnumerableStorage\n .layout()\n .accountsByToken[id];\n\n address[] memory addresses = new address[](accounts.length());\n\n for (uint256 i; i < accounts.length(); i++) {\n addresses[i] = accounts.at(i);\n }\n\n return addresses;\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function tokensByAccount(address account)\n public\n view\n virtual\n override\n returns (uint256[] memory)\n {\n EnumerableSet.UintSet storage tokens = ERC1155EnumerableStorage\n .layout()\n .tokensByAccount[account];\n\n uint256[] memory ids = new uint256[](tokens.length());\n\n for (uint256 i; i < tokens.length(); i++) {\n ids[i] = tokens.at(i);\n }\n\n return ids;\n }\n\n /**\n * @notice ERC1155 hook: update aggregate values\n * @inheritdoc ERC1155EnumerableInternal\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n )\n internal\n virtual\n override(ERC1155BaseInternal, ERC1155EnumerableInternal)\n {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n }\n}\n" + }, + "@solidstate/contracts/token/ERC1155/IERC1155Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @title ERC1155 transfer receiver interface\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @notice validate receipt of ERC1155 transfer\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param id token ID received\n * @param value quantity of tokens received\n * @param data data payload\n * @return function's own selector if transfer is accepted\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @notice validate receipt of ERC1155 batch transfer\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param ids token IDs received\n * @param values quantities of tokens received\n * @param data data payload\n * @return function's own selector if transfer is accepted\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "contracts/pool/IPoolEvents.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\ninterface IPoolEvents {\r\n event Purchase(\r\n address indexed user,\r\n uint256 longTokenId,\r\n uint256 contractSize,\r\n uint256 baseCost,\r\n uint256 feeCost,\r\n int128 spot64x64\r\n );\r\n\r\n event Exercise(\r\n address indexed user,\r\n uint256 longTokenId,\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 fee\r\n );\r\n\r\n event Underwrite(\r\n address indexed underwriter,\r\n address indexed longReceiver,\r\n uint256 shortTokenId,\r\n uint256 intervalContractSize,\r\n uint256 intervalPremium,\r\n bool isManualUnderwrite\r\n );\r\n\r\n event AssignExercise(\r\n address indexed underwriter,\r\n uint256 shortTokenId,\r\n uint256 freedAmount,\r\n uint256 intervalContractSize,\r\n uint256 fee\r\n );\r\n\r\n event Deposit(address indexed user, bool isCallPool, uint256 amount);\r\n\r\n event Withdrawal(\r\n address indexed user,\r\n bool isCallPool,\r\n uint256 depositedAt,\r\n uint256 amount\r\n );\r\n\r\n event FeeWithdrawal(bool indexed isCallPool, uint256 amount);\r\n\r\n event Annihilate(uint256 shortTokenId, uint256 amount);\r\n\r\n event UpdateCLevel(\r\n bool indexed isCall,\r\n int128 cLevel64x64,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64\r\n );\r\n\r\n event UpdateSteepness(int128 steepness64x64, bool isCallPool);\r\n}\r\n" + }, + "contracts/oracle/VolatilitySurfaceOracleStorage.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {EnumerableSet} from \"@solidstate/contracts/utils/EnumerableSet.sol\";\r\n\r\nlibrary VolatilitySurfaceOracleStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.VolatilitySurfaceOracle\");\r\n\r\n uint256 internal constant COEFF_BITS = 51;\r\n uint256 internal constant COEFF_BITS_MINUS_ONE = 50;\r\n uint256 internal constant COEFF_AMOUNT = 5;\r\n // START_BIT = COEFF_BITS * (COEFF_AMOUNT - 1)\r\n uint256 internal constant START_BIT = 204;\r\n\r\n struct Update {\r\n uint256 updatedAt;\r\n bytes32 callCoefficients;\r\n bytes32 putCoefficients;\r\n }\r\n\r\n struct Layout {\r\n // Base token -> Underlying token -> Update\r\n mapping(address => mapping(address => Update)) volatilitySurfaces;\r\n // Relayer addresses which can be trusted to provide accurate option trades\r\n EnumerableSet.AddressSet whitelistedRelayers;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n\r\n function getCoefficients(\r\n Layout storage l,\r\n address baseToken,\r\n address underlyingToken,\r\n bool isCall\r\n ) internal view returns (bytes32) {\r\n Update storage u = l.volatilitySurfaces[baseToken][underlyingToken];\r\n return isCall ? u.callCoefficients : u.putCoefficients;\r\n }\r\n\r\n function parseVolatilitySurfaceCoefficients(bytes32 input)\r\n internal\r\n pure\r\n returns (int256[] memory coefficients)\r\n {\r\n coefficients = new int256[](COEFF_AMOUNT);\r\n\r\n // Value to add to negative numbers to cast them to int256\r\n int256 toAdd = (int256(-1) >> COEFF_BITS) << COEFF_BITS;\r\n\r\n assembly {\r\n let i := 0\r\n // Value equal to -1\r\n let mid := shl(COEFF_BITS_MINUS_ONE, 1)\r\n\r\n for {\r\n\r\n } lt(i, COEFF_AMOUNT) {\r\n\r\n } {\r\n let offset := sub(START_BIT, mul(COEFF_BITS, i))\r\n let coeff := shr(\r\n offset,\r\n sub(\r\n input,\r\n shl(\r\n add(offset, COEFF_BITS),\r\n shr(add(offset, COEFF_BITS), input)\r\n )\r\n )\r\n )\r\n\r\n // Check if value is a negative number and needs casting\r\n if or(eq(coeff, mid), gt(coeff, mid)) {\r\n coeff := add(coeff, toAdd)\r\n }\r\n\r\n // Store result in the coefficients array\r\n mstore(add(coefficients, add(0x20, mul(0x20, i))), coeff)\r\n\r\n i := add(i, 1)\r\n }\r\n }\r\n }\r\n\r\n function formatVolatilitySurfaceCoefficients(int256[5] memory coefficients)\r\n internal\r\n pure\r\n returns (bytes32 result)\r\n {\r\n for (uint256 i = 0; i < COEFF_AMOUNT; i++) {\r\n int256 max = int256(1 << COEFF_BITS_MINUS_ONE);\r\n require(\r\n coefficients[i] < max && coefficients[i] > -max,\r\n \"Out of bounds\"\r\n );\r\n }\r\n\r\n assembly {\r\n let i := 0\r\n\r\n for {\r\n\r\n } lt(i, COEFF_AMOUNT) {\r\n\r\n } {\r\n let offset := sub(START_BIT, mul(COEFF_BITS, i))\r\n let coeff := mload(add(coefficients, mul(0x20, i)))\r\n\r\n result := add(\r\n result,\r\n shl(\r\n offset,\r\n sub(coeff, shl(COEFF_BITS, shr(COEFF_BITS, coeff)))\r\n )\r\n )\r\n\r\n i := add(i, 1)\r\n }\r\n }\r\n }\r\n}\r\n" + }, + "@solidstate/contracts/token/ERC1155/enumerable/IERC1155Enumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC1155 enumerable and aggregate function interface\n */\ninterface IERC1155Enumerable {\n /**\n * @notice query total minted supply of given token\n * @param id token id to query\n * @return token supply\n */\n function totalSupply(uint256 id) external view returns (uint256);\n\n /**\n * @notice query total number of holders for given token\n * @param id token id to query\n * @return quantity of holders\n */\n function totalHolders(uint256 id) external view returns (uint256);\n\n /**\n * @notice query holders of given token\n * @param id token id to query\n * @return list of holder addresses\n */\n function accountsByToken(uint256 id)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice query tokens held by given address\n * @param account address to query\n * @return list of token ids\n */\n function tokensByAccount(address account)\n external\n view\n returns (uint256[] memory);\n}\n" + }, + "@solidstate/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20Internal } from './IERC20Internal.sol';\n\n/**\n * @title ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/20\n */\ninterface IERC20 is IERC20Internal {\n /**\n * @notice query the total minted token supply\n * @return token supply\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice query the token balance of given account\n * @param account address to query\n * @return token balance\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @notice query the allowance granted from given holder to given spender\n * @param holder approver of allowance\n * @param spender recipient of allowance\n * @return token allowance\n */\n function allowance(address holder, address spender)\n external\n view\n returns (uint256);\n\n /**\n * @notice grant approval to spender to spend tokens\n * @dev prefer ERC20Extended functions to avoid transaction-ordering vulnerability (see https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729)\n * @param spender recipient of allowance\n * @param amount quantity of tokens approved for spending\n * @return success status (always true; otherwise function should revert)\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @notice transfer tokens to given recipient\n * @param recipient beneficiary of token transfer\n * @param amount quantity of tokens to transfer\n * @return success status (always true; otherwise function should revert)\n */\n function transfer(address recipient, uint256 amount)\n external\n returns (bool);\n\n /**\n * @notice transfer tokens to given recipient on behalf of given holder\n * @param holder holder of tokens prior to transfer\n * @param recipient beneficiary of token transfer\n * @param amount quantity of tokens to transfer\n * @return success status (always true; otherwise function should revert)\n */\n function transferFrom(\n address holder,\n address recipient,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "contracts/mining/IPremiaMining.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {PremiaMiningStorage} from \"./PremiaMiningStorage.sol\";\r\n\r\ninterface IPremiaMining {\r\n function addPremiaRewards(uint256 _amount) external;\r\n\r\n function premiaRewardsAvailable() external view returns (uint256);\r\n\r\n function getTotalAllocationPoints() external view returns (uint256);\r\n\r\n function getPoolInfo(address pool, bool isCallPool)\r\n external\r\n view\r\n returns (PremiaMiningStorage.PoolInfo memory);\r\n\r\n function getPremiaPerYear() external view returns (uint256);\r\n\r\n function addPool(address _pool, uint256 _allocPoints) external;\r\n\r\n function setPoolAllocPoints(\r\n address[] memory _pools,\r\n uint256[] memory _allocPoints\r\n ) external;\r\n\r\n function pendingPremia(\r\n address _pool,\r\n bool _isCallPool,\r\n address _user\r\n ) external view returns (uint256);\r\n\r\n function updatePool(\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _totalTVL\r\n ) external;\r\n\r\n function allocatePending(\r\n address _user,\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _userTVLOld,\r\n uint256 _userTVLNew,\r\n uint256 _totalTVL\r\n ) external;\r\n\r\n function claim(\r\n address _user,\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _userTVLOld,\r\n uint256 _userTVLNew,\r\n uint256 _totalTVL\r\n ) external;\r\n}\r\n" + }, + "@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\n\nlibrary ERC1155EnumerableStorage {\n struct Layout {\n mapping(uint256 => uint256) totalSupply;\n mapping(uint256 => EnumerableSet.AddressSet) accountsByToken;\n mapping(address => EnumerableSet.UintSet) tokensByAccount;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.ERC1155Enumerable');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n" + }, + "@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableInternal.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\nimport { ERC1155BaseInternal, ERC1155BaseStorage } from '../base/ERC1155BaseInternal.sol';\nimport { ERC1155EnumerableStorage } from './ERC1155EnumerableStorage.sol';\n\n/**\n * @title ERC1155Enumerable internal functions\n */\nabstract contract ERC1155EnumerableInternal is ERC1155BaseInternal {\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /**\n * @notice ERC1155 hook: update aggregate values\n * @inheritdoc ERC1155BaseInternal\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n\n if (from != to) {\n ERC1155EnumerableStorage.Layout storage l = ERC1155EnumerableStorage\n .layout();\n mapping(uint256 => EnumerableSet.AddressSet)\n storage tokenAccounts = l.accountsByToken;\n EnumerableSet.UintSet storage fromTokens = l.tokensByAccount[from];\n EnumerableSet.UintSet storage toTokens = l.tokensByAccount[to];\n\n for (uint256 i; i < ids.length; i++) {\n uint256 amount = amounts[i];\n\n if (amount > 0) {\n uint256 id = ids[i];\n\n if (from == address(0)) {\n l.totalSupply[id] += amount;\n } else if (_balanceOf(from, id) == amount) {\n tokenAccounts[id].remove(from);\n fromTokens.remove(id);\n }\n\n if (to == address(0)) {\n l.totalSupply[id] -= amount;\n } else if (_balanceOf(to, id) == 0) {\n tokenAccounts[id].add(to);\n toTokens.add(id);\n }\n }\n }\n }\n }\n}\n" + }, + "contracts/oracle/IVolatilitySurfaceOracle.sol": { + "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {VolatilitySurfaceOracleStorage} from \"./VolatilitySurfaceOracleStorage.sol\";\r\n\r\ninterface IVolatilitySurfaceOracle {\r\n function getWhitelistedRelayers() external view returns (address[] memory);\r\n\r\n function getVolatilitySurface(address baseToken, address underlyingToken)\r\n external\r\n view\r\n returns (VolatilitySurfaceOracleStorage.Update memory);\r\n\r\n function getVolatilitySurfaceCoefficientsUnpacked(\r\n address baseToken,\r\n address underlyingToken,\r\n bool isCall\r\n ) external view returns (int256[] memory);\r\n\r\n function getTimeToMaturity64x64(uint64 maturity)\r\n external\r\n view\r\n returns (int128);\r\n\r\n function getAnnualizedVolatility64x64(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 spot64x64,\r\n int128 strike64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (int128);\r\n\r\n function getBlackScholesPrice64x64(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (int128);\r\n\r\n function getBlackScholesPrice(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (uint256);\r\n}\r\n" + }, + "contracts/pool/PoolInternal.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {IERC173} from \"@solidstate/contracts/access/IERC173.sol\";\r\nimport {OwnableStorage} from \"@solidstate/contracts/access/OwnableStorage.sol\";\r\nimport {IERC20} from \"@solidstate/contracts/token/ERC20/IERC20.sol\";\r\nimport {ERC1155EnumerableInternal, ERC1155EnumerableStorage, EnumerableSet} from \"@solidstate/contracts/token/ERC1155/enumerable/ERC1155Enumerable.sol\";\r\nimport {IWETH} from \"@solidstate/contracts/utils/IWETH.sol\";\r\n\r\nimport {PoolStorage} from \"./PoolStorage.sol\";\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\nimport {ABDKMath64x64Token} from \"../libraries/ABDKMath64x64Token.sol\";\r\nimport {OptionMath} from \"../libraries/OptionMath.sol\";\r\nimport {IFeeDiscount} from \"../staking/IFeeDiscount.sol\";\r\nimport {IPoolEvents} from \"./IPoolEvents.sol\";\r\nimport {IPremiaMining} from \"../mining/IPremiaMining.sol\";\r\nimport {IVolatilitySurfaceOracle} from \"../oracle/IVolatilitySurfaceOracle.sol\";\r\n\r\n/**\r\n * @title Premia option pool\r\n * @dev deployed standalone and referenced by PoolProxy\r\n */\r\ncontract PoolInternal is IPoolEvents, ERC1155EnumerableInternal {\r\n using ABDKMath64x64 for int128;\r\n using EnumerableSet for EnumerableSet.AddressSet;\r\n using EnumerableSet for EnumerableSet.UintSet;\r\n using PoolStorage for PoolStorage.Layout;\r\n\r\n address internal immutable WETH_ADDRESS;\r\n address internal immutable PREMIA_MINING_ADDRESS;\r\n address internal immutable FEE_RECEIVER_ADDRESS;\r\n address internal immutable FEE_DISCOUNT_ADDRESS;\r\n address internal immutable IVOL_ORACLE_ADDRESS;\r\n\r\n int128 internal immutable FEE_64x64;\r\n\r\n uint256 internal immutable UNDERLYING_FREE_LIQ_TOKEN_ID;\r\n uint256 internal immutable BASE_FREE_LIQ_TOKEN_ID;\r\n\r\n uint256 internal immutable UNDERLYING_RESERVED_LIQ_TOKEN_ID;\r\n uint256 internal immutable BASE_RESERVED_LIQ_TOKEN_ID;\r\n\r\n uint256 internal constant INVERSE_BASIS_POINT = 1e4;\r\n uint256 internal constant BATCHING_PERIOD = 260;\r\n\r\n // Minimum APY for capital locked up to underwrite options.\r\n // The quote will return a minimum price corresponding to this APY\r\n int128 internal constant MIN_APY_64x64 = 0x4ccccccccccccccd; // 0.3\r\n\r\n constructor(\r\n address ivolOracle,\r\n address weth,\r\n address premiaMining,\r\n address feeReceiver,\r\n address feeDiscountAddress,\r\n int128 fee64x64\r\n ) {\r\n IVOL_ORACLE_ADDRESS = ivolOracle;\r\n WETH_ADDRESS = weth;\r\n PREMIA_MINING_ADDRESS = premiaMining;\r\n FEE_RECEIVER_ADDRESS = feeReceiver;\r\n // PremiaFeeDiscount contract address\r\n FEE_DISCOUNT_ADDRESS = feeDiscountAddress;\r\n FEE_64x64 = fee64x64;\r\n\r\n UNDERLYING_FREE_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.UNDERLYING_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n BASE_FREE_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n UNDERLYING_RESERVED_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.UNDERLYING_RESERVED_LIQ,\r\n 0,\r\n 0\r\n );\r\n BASE_RESERVED_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.BASE_RESERVED_LIQ,\r\n 0,\r\n 0\r\n );\r\n }\r\n\r\n modifier onlyProtocolOwner() {\r\n require(\r\n msg.sender == IERC173(OwnableStorage.layout().owner).owner(),\r\n \"Not protocol owner\"\r\n );\r\n _;\r\n }\r\n\r\n function _getFeeDiscount(address feePayer)\r\n internal\r\n view\r\n returns (uint256 discount)\r\n {\r\n if (FEE_DISCOUNT_ADDRESS != address(0)) {\r\n discount = IFeeDiscount(FEE_DISCOUNT_ADDRESS).getDiscount(feePayer);\r\n }\r\n }\r\n\r\n function _getFeeWithDiscount(address feePayer, uint256 fee)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n uint256 discount = _getFeeDiscount(feePayer);\r\n return fee - ((fee * discount) / INVERSE_BASIS_POINT);\r\n }\r\n\r\n function _withdrawFees(bool isCall) internal returns (uint256 amount) {\r\n uint256 tokenId = _getReservedLiquidityTokenId(isCall);\r\n amount = _balanceOf(FEE_RECEIVER_ADDRESS, tokenId);\r\n\r\n if (amount > 0) {\r\n _burn(FEE_RECEIVER_ADDRESS, tokenId, amount);\r\n emit FeeWithdrawal(isCall, amount);\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate price of option contract\r\n * @param args structured quote arguments\r\n * @return result quote result\r\n */\r\n function _quote(PoolStorage.QuoteArgsInternal memory args)\r\n internal\r\n view\r\n returns (PoolStorage.QuoteResultInternal memory result)\r\n {\r\n require(\r\n args.strike64x64 > 0 && args.spot64x64 > 0 && args.maturity > 0,\r\n \"invalid args\"\r\n );\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n int128 contractSize64x64 = ABDKMath64x64Token.fromDecimals(\r\n args.contractSize,\r\n l.underlyingDecimals\r\n );\r\n bool isCall = args.isCall;\r\n\r\n (int128 adjustedCLevel64x64, int128 oldLiquidity64x64) = l\r\n .applyCLevelPendingDepositAdjustment(\r\n l.getDecayAdjustedCLevel64x64(isCall),\r\n l.totalFreeLiquiditySupply64x64(isCall),\r\n isCall\r\n );\r\n\r\n require(oldLiquidity64x64 > 0, \"no liq\");\r\n\r\n int128 timeToMaturity64x64 = ABDKMath64x64.divu(\r\n args.maturity - block.timestamp,\r\n 365 days\r\n );\r\n\r\n int128 annualizedVolatility64x64 = IVolatilitySurfaceOracle(\r\n IVOL_ORACLE_ADDRESS\r\n ).getAnnualizedVolatility64x64(\r\n l.base,\r\n l.underlying,\r\n args.spot64x64,\r\n args.strike64x64,\r\n timeToMaturity64x64,\r\n isCall\r\n );\r\n\r\n require(annualizedVolatility64x64 > 0, \"vol = 0\");\r\n\r\n (\r\n int128 price64x64,\r\n int128 cLevel64x64,\r\n int128 slippageCoefficient64x64\r\n ) = OptionMath.quotePrice(\r\n OptionMath.QuoteArgs(\r\n annualizedVolatility64x64.mul(annualizedVolatility64x64),\r\n args.strike64x64,\r\n args.spot64x64,\r\n timeToMaturity64x64,\r\n adjustedCLevel64x64,\r\n oldLiquidity64x64,\r\n oldLiquidity64x64.sub(contractSize64x64),\r\n 0x10000000000000000, // 64x64 fixed point representation of 1\r\n MIN_APY_64x64,\r\n isCall\r\n )\r\n );\r\n\r\n result.baseCost64x64 = isCall\r\n ? price64x64.mul(contractSize64x64).div(args.spot64x64)\r\n : price64x64.mul(contractSize64x64);\r\n result.feeCost64x64 = result.baseCost64x64.mul(FEE_64x64);\r\n result.cLevel64x64 = cLevel64x64;\r\n result.slippageCoefficient64x64 = slippageCoefficient64x64;\r\n\r\n int128 discount = ABDKMath64x64.divu(\r\n _getFeeDiscount(args.feePayer),\r\n INVERSE_BASIS_POINT\r\n );\r\n result.feeCost64x64 -= result.feeCost64x64.mul(discount);\r\n }\r\n\r\n /**\r\n * @notice burn corresponding long and short option tokens\r\n * @param account holder of tokens to annihilate\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize quantity of option contract tokens to annihilate\r\n */\r\n function _annihilate(\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize\r\n ) internal {\r\n uint256 longTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, true),\r\n maturity,\r\n strike64x64\r\n );\r\n uint256 shortTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n _burn(account, longTokenId, contractSize);\r\n _burn(account, shortTokenId, contractSize);\r\n\r\n emit Annihilate(shortTokenId, contractSize);\r\n }\r\n\r\n /**\r\n * @notice purchase option\r\n * @param l storage layout struct\r\n * @param account recipient of purchased option\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize size of option contract\r\n * @param newPrice64x64 64x64 fixed point representation of current spot price\r\n * @return baseCost quantity of tokens required to purchase long position\r\n * @return feeCost quantity of tokens required to pay fees\r\n */\r\n function _purchase(\r\n PoolStorage.Layout storage l,\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize,\r\n int128 newPrice64x64\r\n ) internal returns (uint256 baseCost, uint256 feeCost) {\r\n require(maturity > block.timestamp, \"expired\");\r\n require(contractSize >= l.underlyingMinimum, \"too small\");\r\n\r\n {\r\n uint256 size = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(\r\n strike64x64.mulu(contractSize)\r\n );\r\n\r\n require(\r\n size <=\r\n ERC1155EnumerableStorage.layout().totalSupply[\r\n _getFreeLiquidityTokenId(isCall)\r\n ] -\r\n l.nextDeposits[isCall].totalPendingDeposits,\r\n \"insuf liq\"\r\n );\r\n }\r\n\r\n PoolStorage.QuoteResultInternal memory quote = _quote(\r\n PoolStorage.QuoteArgsInternal(\r\n account,\r\n maturity,\r\n strike64x64,\r\n newPrice64x64,\r\n contractSize,\r\n isCall\r\n )\r\n );\r\n\r\n baseCost = ABDKMath64x64Token.toDecimals(\r\n quote.baseCost64x64,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n feeCost = ABDKMath64x64Token.toDecimals(\r\n quote.feeCost64x64,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n uint256 longTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, true),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n uint256 shortTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n // mint long option token for buyer\r\n _mint(account, longTokenId, contractSize);\r\n\r\n int128 oldLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n // burn free liquidity tokens from other underwriters\r\n _mintShortTokenLoop(\r\n l,\r\n account,\r\n contractSize,\r\n baseCost,\r\n shortTokenId,\r\n isCall\r\n );\r\n int128 newLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n\r\n _setCLevel(l, oldLiquidity64x64, newLiquidity64x64, isCall);\r\n\r\n // mint reserved liquidity tokens for fee receiver\r\n _mint(\r\n FEE_RECEIVER_ADDRESS,\r\n _getReservedLiquidityTokenId(isCall),\r\n feeCost\r\n );\r\n\r\n emit Purchase(\r\n account,\r\n longTokenId,\r\n contractSize,\r\n baseCost,\r\n feeCost,\r\n newPrice64x64\r\n );\r\n }\r\n\r\n /**\r\n * @notice reassign short position to new underwriter\r\n * @param l storage layout struct\r\n * @param account holder of positions to be reassigned\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize quantity of option contract tokens to reassign\r\n * @param newPrice64x64 64x64 fixed point representation of current spot price\r\n * @return baseCost quantity of tokens required to reassign short position\r\n * @return feeCost quantity of tokens required to pay fees\r\n * @return amountOut quantity of liquidity freed\r\n */\r\n function _reassign(\r\n PoolStorage.Layout storage l,\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize,\r\n int128 newPrice64x64\r\n )\r\n internal\r\n returns (\r\n uint256 baseCost,\r\n uint256 feeCost,\r\n uint256 amountOut\r\n )\r\n {\r\n (baseCost, feeCost) = _purchase(\r\n l,\r\n account,\r\n maturity,\r\n strike64x64,\r\n isCall,\r\n contractSize,\r\n newPrice64x64\r\n );\r\n\r\n _annihilate(account, maturity, strike64x64, isCall, contractSize);\r\n\r\n uint256 annihilateAmount = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(contractSize));\r\n\r\n amountOut = annihilateAmount - baseCost - feeCost;\r\n }\r\n\r\n /**\r\n * @notice exercise option on behalf of holder\r\n * @dev used for processing of expired options if passed holder is zero address\r\n * @param holder owner of long option tokens to exercise\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to exercise\r\n */\r\n function _exercise(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) internal {\r\n uint64 maturity;\r\n int128 strike64x64;\r\n bool isCall;\r\n\r\n bool onlyExpired = holder == address(0);\r\n\r\n {\r\n PoolStorage.TokenType tokenType;\r\n (tokenType, maturity, strike64x64) = PoolStorage.parseTokenId(\r\n longTokenId\r\n );\r\n require(\r\n tokenType == PoolStorage.TokenType.LONG_CALL ||\r\n tokenType == PoolStorage.TokenType.LONG_PUT,\r\n \"invalid type\"\r\n );\r\n require(!onlyExpired || maturity < block.timestamp, \"not expired\");\r\n isCall = tokenType == PoolStorage.TokenType.LONG_CALL;\r\n }\r\n\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n int128 spot64x64 = _update(l);\r\n\r\n if (maturity < block.timestamp) {\r\n spot64x64 = l.getPriceUpdateAfter(maturity);\r\n }\r\n\r\n require(\r\n onlyExpired ||\r\n (\r\n isCall\r\n ? (spot64x64 > strike64x64)\r\n : (spot64x64 < strike64x64)\r\n ),\r\n \"not ITM\"\r\n );\r\n\r\n uint256 exerciseValue;\r\n // option has a non-zero exercise value\r\n if (isCall) {\r\n if (spot64x64 > strike64x64) {\r\n exerciseValue = spot64x64.sub(strike64x64).div(spot64x64).mulu(\r\n contractSize\r\n );\r\n }\r\n } else {\r\n if (spot64x64 < strike64x64) {\r\n exerciseValue = l.fromUnderlyingToBaseDecimals(\r\n strike64x64.sub(spot64x64).mulu(contractSize)\r\n );\r\n }\r\n }\r\n\r\n uint256 totalFee;\r\n\r\n if (onlyExpired) {\r\n totalFee += _burnLongTokenLoop(\r\n contractSize,\r\n exerciseValue,\r\n longTokenId,\r\n isCall\r\n );\r\n } else {\r\n // burn long option tokens from sender\r\n _burn(holder, longTokenId, contractSize);\r\n\r\n uint256 fee;\r\n\r\n if (exerciseValue > 0) {\r\n fee = _getFeeWithDiscount(\r\n holder,\r\n FEE_64x64.mulu(exerciseValue)\r\n );\r\n totalFee += fee;\r\n\r\n _pushTo(holder, _getPoolToken(isCall), exerciseValue - fee);\r\n }\r\n\r\n emit Exercise(\r\n holder,\r\n longTokenId,\r\n contractSize,\r\n exerciseValue,\r\n fee\r\n );\r\n }\r\n\r\n totalFee += _burnShortTokenLoop(\r\n contractSize,\r\n exerciseValue,\r\n PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n ),\r\n isCall\r\n );\r\n\r\n _mint(\r\n FEE_RECEIVER_ADDRESS,\r\n _getReservedLiquidityTokenId(isCall),\r\n totalFee\r\n );\r\n }\r\n\r\n function _mintShortTokenLoop(\r\n PoolStorage.Layout storage l,\r\n address buyer,\r\n uint256 contractSize,\r\n uint256 premium,\r\n uint256 shortTokenId,\r\n bool isCall\r\n ) internal {\r\n uint256 freeLiqTokenId = _getFreeLiquidityTokenId(isCall);\r\n (, , int128 strike64x64) = PoolStorage.parseTokenId(shortTokenId);\r\n\r\n uint256 toPay = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(contractSize));\r\n\r\n while (toPay > 0) {\r\n address underwriter = l.liquidityQueueAscending[isCall][address(0)];\r\n uint256 balance = _balanceOf(underwriter, freeLiqTokenId);\r\n\r\n // If dust left, we remove underwriter and skip to next\r\n if (balance < _getMinimumAmount(l, isCall)) {\r\n l.removeUnderwriter(underwriter, isCall);\r\n continue;\r\n }\r\n\r\n if (!l.getReinvestmentStatus(underwriter, isCall)) {\r\n _burn(underwriter, freeLiqTokenId, balance);\r\n _mint(\r\n underwriter,\r\n _getReservedLiquidityTokenId(isCall),\r\n balance\r\n );\r\n _subUserTVL(l, underwriter, isCall, balance);\r\n continue;\r\n }\r\n\r\n // amount of liquidity provided by underwriter, accounting for reinvested premium\r\n uint256 intervalContractSize = ((balance -\r\n l.pendingDeposits[underwriter][l.nextDeposits[isCall].eta][\r\n isCall\r\n ]) * (toPay + premium)) / toPay;\r\n if (intervalContractSize == 0) continue;\r\n if (intervalContractSize > toPay) intervalContractSize = toPay;\r\n\r\n // amount of premium paid to underwriter\r\n uint256 intervalPremium = (premium * intervalContractSize) / toPay;\r\n premium -= intervalPremium;\r\n toPay -= intervalContractSize;\r\n _addUserTVL(l, underwriter, isCall, intervalPremium);\r\n\r\n // burn free liquidity tokens from underwriter\r\n _burn(\r\n underwriter,\r\n freeLiqTokenId,\r\n intervalContractSize - intervalPremium\r\n );\r\n\r\n if (isCall == false) {\r\n // For PUT, conversion to contract amount is done here (Prior to this line, it is token amount)\r\n intervalContractSize = l.fromBaseToUnderlyingDecimals(\r\n strike64x64.inv().mulu(intervalContractSize)\r\n );\r\n }\r\n\r\n // mint short option tokens for underwriter\r\n // toPay == 0 ? contractSize : intervalContractSize : To prevent minting less than amount,\r\n // because of rounding (Can happen for put, because of fixed point precision)\r\n _mint(\r\n underwriter,\r\n shortTokenId,\r\n toPay == 0 ? contractSize : intervalContractSize\r\n );\r\n\r\n emit Underwrite(\r\n underwriter,\r\n buyer,\r\n shortTokenId,\r\n toPay == 0 ? contractSize : intervalContractSize,\r\n intervalPremium,\r\n false\r\n );\r\n\r\n contractSize -= intervalContractSize;\r\n }\r\n }\r\n\r\n function _burnLongTokenLoop(\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 longTokenId,\r\n bool isCall\r\n ) internal returns (uint256 totalFee) {\r\n EnumerableSet.AddressSet storage holders = ERC1155EnumerableStorage\r\n .layout()\r\n .accountsByToken[longTokenId];\r\n\r\n while (contractSize > 0) {\r\n address longTokenHolder = holders.at(holders.length() - 1);\r\n\r\n uint256 intervalContractSize = _balanceOf(\r\n longTokenHolder,\r\n longTokenId\r\n );\r\n if (intervalContractSize > contractSize)\r\n intervalContractSize = contractSize;\r\n\r\n uint256 intervalExerciseValue;\r\n\r\n uint256 fee;\r\n if (exerciseValue > 0) {\r\n intervalExerciseValue =\r\n (exerciseValue * intervalContractSize) /\r\n contractSize;\r\n\r\n fee = _getFeeWithDiscount(\r\n longTokenHolder,\r\n FEE_64x64.mulu(intervalExerciseValue)\r\n );\r\n totalFee += fee;\r\n\r\n exerciseValue -= intervalExerciseValue;\r\n _pushTo(\r\n longTokenHolder,\r\n _getPoolToken(isCall),\r\n intervalExerciseValue - fee\r\n );\r\n }\r\n\r\n contractSize -= intervalContractSize;\r\n\r\n emit Exercise(\r\n longTokenHolder,\r\n longTokenId,\r\n intervalContractSize,\r\n intervalExerciseValue - fee,\r\n fee\r\n );\r\n\r\n _burn(longTokenHolder, longTokenId, intervalContractSize);\r\n }\r\n }\r\n\r\n function _burnShortTokenLoop(\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 shortTokenId,\r\n bool isCall\r\n ) internal returns (uint256 totalFee) {\r\n EnumerableSet.AddressSet storage underwriters = ERC1155EnumerableStorage\r\n .layout()\r\n .accountsByToken[shortTokenId];\r\n (, , int128 strike64x64) = PoolStorage.parseTokenId(shortTokenId);\r\n\r\n while (contractSize > 0) {\r\n address underwriter = underwriters.at(underwriters.length() - 1);\r\n\r\n // amount of liquidity provided by underwriter\r\n uint256 intervalContractSize = _balanceOf(\r\n underwriter,\r\n shortTokenId\r\n );\r\n if (intervalContractSize > contractSize)\r\n intervalContractSize = contractSize;\r\n\r\n // amount of value claimed by buyer\r\n uint256 intervalExerciseValue = (exerciseValue *\r\n intervalContractSize) / contractSize;\r\n exerciseValue -= intervalExerciseValue;\r\n contractSize -= intervalContractSize;\r\n\r\n uint256 freeLiq = isCall\r\n ? intervalContractSize - intervalExerciseValue\r\n : PoolStorage.layout().fromUnderlyingToBaseDecimals(\r\n strike64x64.mulu(intervalContractSize)\r\n ) - intervalExerciseValue;\r\n\r\n uint256 fee = _getFeeWithDiscount(\r\n underwriter,\r\n FEE_64x64.mulu(freeLiq)\r\n );\r\n totalFee += fee;\r\n\r\n uint256 tvlToSubtract = intervalExerciseValue;\r\n\r\n // mint free liquidity tokens for underwriter\r\n if (\r\n PoolStorage.layout().getReinvestmentStatus(underwriter, isCall)\r\n ) {\r\n _addToDepositQueue(underwriter, freeLiq - fee, isCall);\r\n tvlToSubtract += fee;\r\n } else {\r\n _mint(\r\n underwriter,\r\n _getReservedLiquidityTokenId(isCall),\r\n freeLiq - fee\r\n );\r\n tvlToSubtract += freeLiq;\r\n }\r\n\r\n _subUserTVL(\r\n PoolStorage.layout(),\r\n underwriter,\r\n isCall,\r\n tvlToSubtract\r\n );\r\n\r\n // burn short option tokens from underwriter\r\n _burn(underwriter, shortTokenId, intervalContractSize);\r\n\r\n emit AssignExercise(\r\n underwriter,\r\n shortTokenId,\r\n freeLiq - fee,\r\n intervalContractSize,\r\n fee\r\n );\r\n }\r\n }\r\n\r\n function _addToDepositQueue(\r\n address account,\r\n uint256 amount,\r\n bool isCallPool\r\n ) internal {\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n _mint(account, _getFreeLiquidityTokenId(isCallPool), amount);\r\n\r\n uint256 nextBatch = (block.timestamp / BATCHING_PERIOD) *\r\n BATCHING_PERIOD +\r\n BATCHING_PERIOD;\r\n l.pendingDeposits[account][nextBatch][isCallPool] += amount;\r\n\r\n PoolStorage.BatchData storage batchData = l.nextDeposits[isCallPool];\r\n batchData.totalPendingDeposits += amount;\r\n batchData.eta = nextBatch;\r\n }\r\n\r\n function _processPendingDeposits(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n {\r\n PoolStorage.BatchData storage data = l.nextDeposits[isCall];\r\n\r\n if (data.eta == 0 || block.timestamp < data.eta) return;\r\n\r\n int128 oldLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n\r\n _setCLevel(\r\n l,\r\n oldLiquidity64x64,\r\n oldLiquidity64x64.add(\r\n ABDKMath64x64Token.fromDecimals(\r\n data.totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n )\r\n ),\r\n isCall\r\n );\r\n\r\n delete l.nextDeposits[isCall];\r\n }\r\n\r\n function _getFreeLiquidityTokenId(bool isCall)\r\n internal\r\n view\r\n returns (uint256 freeLiqTokenId)\r\n {\r\n freeLiqTokenId = isCall\r\n ? UNDERLYING_FREE_LIQ_TOKEN_ID\r\n : BASE_FREE_LIQ_TOKEN_ID;\r\n }\r\n\r\n function _getReservedLiquidityTokenId(bool isCall)\r\n internal\r\n view\r\n returns (uint256 reservedLiqTokenId)\r\n {\r\n reservedLiqTokenId = isCall\r\n ? UNDERLYING_RESERVED_LIQ_TOKEN_ID\r\n : BASE_RESERVED_LIQ_TOKEN_ID;\r\n }\r\n\r\n function _getPoolToken(bool isCall) internal view returns (address token) {\r\n token = isCall\r\n ? PoolStorage.layout().underlying\r\n : PoolStorage.layout().base;\r\n }\r\n\r\n function _getTokenType(bool isCall, bool isLong)\r\n internal\r\n pure\r\n returns (PoolStorage.TokenType tokenType)\r\n {\r\n if (isCall) {\r\n tokenType = isLong\r\n ? PoolStorage.TokenType.LONG_CALL\r\n : PoolStorage.TokenType.SHORT_CALL;\r\n } else {\r\n tokenType = isLong\r\n ? PoolStorage.TokenType.LONG_PUT\r\n : PoolStorage.TokenType.SHORT_PUT;\r\n }\r\n }\r\n\r\n function _getMinimumAmount(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint256 minimumAmount)\r\n {\r\n minimumAmount = isCall ? l.underlyingMinimum : l.baseMinimum;\r\n }\r\n\r\n function _getPoolCapAmount(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint256 poolCapAmount)\r\n {\r\n poolCapAmount = isCall ? l.underlyingPoolCap : l.basePoolCap;\r\n }\r\n\r\n function _setCLevel(\r\n PoolStorage.Layout storage l,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64,\r\n bool isCallPool\r\n ) internal {\r\n int128 oldCLevel64x64 = l.getDecayAdjustedCLevel64x64(isCallPool);\r\n\r\n int128 cLevel64x64 = l.applyCLevelLiquidityChangeAdjustment(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64,\r\n isCallPool\r\n );\r\n\r\n l.setCLevel(cLevel64x64, isCallPool);\r\n\r\n emit UpdateCLevel(\r\n isCallPool,\r\n cLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate and store updated market state\r\n * @param l storage layout struct\r\n * @return newPrice64x64 64x64 fixed point representation of current spot price\r\n */\r\n function _update(PoolStorage.Layout storage l)\r\n internal\r\n returns (int128 newPrice64x64)\r\n {\r\n if (l.updatedAt == block.timestamp) {\r\n return (l.getPriceUpdate(block.timestamp));\r\n }\r\n\r\n newPrice64x64 = l.fetchPriceUpdate();\r\n\r\n if (l.getPriceUpdate(block.timestamp) == 0) {\r\n l.setPriceUpdate(block.timestamp, newPrice64x64);\r\n }\r\n\r\n l.updatedAt = block.timestamp;\r\n\r\n _processPendingDeposits(l, true);\r\n _processPendingDeposits(l, false);\r\n }\r\n\r\n /**\r\n * @notice transfer ERC20 tokens to message sender\r\n * @param token ERC20 token address\r\n * @param amount quantity of token to transfer\r\n */\r\n function _pushTo(\r\n address to,\r\n address token,\r\n uint256 amount\r\n ) internal {\r\n if (amount == 0) return;\r\n\r\n require(IERC20(token).transfer(to, amount), \"ERC20 transfer failed\");\r\n }\r\n\r\n /**\r\n * @notice transfer ERC20 tokens from message sender\r\n * @param from address from which tokens are pulled from\r\n * @param token ERC20 token address\r\n * @param amount quantity of token to transfer\r\n * @param skipWethDeposit if false, will not try to deposit weth from attach eth\r\n */\r\n function _pullFrom(\r\n address from,\r\n address token,\r\n uint256 amount,\r\n bool skipWethDeposit\r\n ) internal {\r\n if (!skipWethDeposit) {\r\n if (token == WETH_ADDRESS) {\r\n if (msg.value > 0) {\r\n if (msg.value > amount) {\r\n IWETH(WETH_ADDRESS).deposit{value: amount}();\r\n\r\n (bool success, ) = payable(msg.sender).call{\r\n value: msg.value - amount\r\n }(\"\");\r\n\r\n require(success, \"ETH refund failed\");\r\n\r\n amount = 0;\r\n } else {\r\n unchecked {\r\n amount -= msg.value;\r\n }\r\n\r\n IWETH(WETH_ADDRESS).deposit{value: msg.value}();\r\n }\r\n }\r\n } else {\r\n require(msg.value == 0, \"not WETH deposit\");\r\n }\r\n }\r\n\r\n if (amount > 0) {\r\n require(\r\n IERC20(token).transferFrom(from, address(this), amount),\r\n \"ERC20 transfer failed\"\r\n );\r\n }\r\n }\r\n\r\n function _mint(\r\n address account,\r\n uint256 tokenId,\r\n uint256 amount\r\n ) internal {\r\n _mint(account, tokenId, amount, \"\");\r\n }\r\n\r\n function _addUserTVL(\r\n PoolStorage.Layout storage l,\r\n address user,\r\n bool isCallPool,\r\n uint256 amount\r\n ) internal {\r\n uint256 userTVL = l.userTVL[user][isCallPool];\r\n uint256 totalTVL = l.totalTVL[isCallPool];\r\n\r\n IPremiaMining(PREMIA_MINING_ADDRESS).allocatePending(\r\n user,\r\n address(this),\r\n isCallPool,\r\n userTVL,\r\n userTVL + amount,\r\n totalTVL\r\n );\r\n\r\n l.userTVL[user][isCallPool] = userTVL + amount;\r\n l.totalTVL[isCallPool] = totalTVL + amount;\r\n }\r\n\r\n function _subUserTVL(\r\n PoolStorage.Layout storage l,\r\n address user,\r\n bool isCallPool,\r\n uint256 amount\r\n ) internal {\r\n uint256 userTVL = l.userTVL[user][isCallPool];\r\n uint256 totalTVL = l.totalTVL[isCallPool];\r\n\r\n IPremiaMining(PREMIA_MINING_ADDRESS).allocatePending(\r\n user,\r\n address(this),\r\n isCallPool,\r\n userTVL,\r\n userTVL - amount,\r\n totalTVL\r\n );\r\n l.userTVL[user][isCallPool] = userTVL - amount;\r\n l.totalTVL[isCallPool] = totalTVL - amount;\r\n }\r\n\r\n /**\r\n * @notice ERC1155 hook: track eligible underwriters\r\n * @param operator transaction sender\r\n * @param from token sender\r\n * @param to token receiver\r\n * @param ids token ids transferred\r\n * @param amounts token quantities transferred\r\n * @param data data payload\r\n */\r\n function _beforeTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual override {\r\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n for (uint256 i; i < ids.length; i++) {\r\n uint256 id = ids[i];\r\n uint256 amount = amounts[i];\r\n\r\n if (amount == 0) continue;\r\n\r\n if (from == address(0)) {\r\n l.tokenIds.add(id);\r\n }\r\n\r\n if (\r\n to == address(0) &&\r\n ERC1155EnumerableStorage.layout().totalSupply[id] == 0\r\n ) {\r\n l.tokenIds.remove(id);\r\n }\r\n\r\n // prevent transfer of free and reserved liquidity during waiting period\r\n\r\n if (\r\n id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == BASE_FREE_LIQ_TOKEN_ID ||\r\n id == UNDERLYING_RESERVED_LIQ_TOKEN_ID ||\r\n id == BASE_RESERVED_LIQ_TOKEN_ID\r\n ) {\r\n if (from != address(0) && to != address(0)) {\r\n bool isCallPool = id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == UNDERLYING_RESERVED_LIQ_TOKEN_ID;\r\n\r\n require(\r\n l.depositedAt[from][isCallPool] + (1 days) <\r\n block.timestamp,\r\n \"liq lock 1d\"\r\n );\r\n }\r\n }\r\n\r\n if (\r\n id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == BASE_FREE_LIQ_TOKEN_ID\r\n ) {\r\n bool isCallPool = id == UNDERLYING_FREE_LIQ_TOKEN_ID;\r\n uint256 minimum = _getMinimumAmount(l, isCallPool);\r\n\r\n if (from != address(0)) {\r\n uint256 balance = _balanceOf(from, id);\r\n\r\n if (balance > minimum && balance <= amount + minimum) {\r\n require(\r\n balance -\r\n l.pendingDeposits[from][\r\n l.nextDeposits[isCallPool].eta\r\n ][isCallPool] >=\r\n amount,\r\n \"Insuf balance\"\r\n );\r\n l.removeUnderwriter(from, isCallPool);\r\n }\r\n\r\n if (to != address(0)) {\r\n _subUserTVL(l, from, isCallPool, amounts[i]);\r\n _addUserTVL(l, to, isCallPool, amounts[i]);\r\n }\r\n }\r\n\r\n if (to != address(0)) {\r\n uint256 balance = _balanceOf(to, id);\r\n\r\n if (balance <= minimum && balance + amount > minimum) {\r\n l.addUnderwriter(to, isCallPool);\r\n }\r\n }\r\n }\r\n\r\n // Update userTVL on SHORT options transfers\r\n (\r\n PoolStorage.TokenType tokenType,\r\n ,\r\n int128 strike64x64\r\n ) = PoolStorage.parseTokenId(id);\r\n\r\n if (\r\n (from != address(0) && to != address(0)) &&\r\n (tokenType == PoolStorage.TokenType.SHORT_CALL ||\r\n tokenType == PoolStorage.TokenType.SHORT_PUT)\r\n ) {\r\n bool isCall = tokenType == PoolStorage.TokenType.SHORT_CALL;\r\n uint256 collateral = isCall\r\n ? amount\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(amount));\r\n\r\n _subUserTVL(l, from, isCall, collateral);\r\n _addUserTVL(l, to, isCall, collateral);\r\n }\r\n }\r\n }\r\n}\r\n" + }, + "@solidstate/contracts/token/ERC1155/base/ERC1155BaseStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary ERC1155BaseStorage {\n struct Layout {\n mapping(uint256 => mapping(address => uint256)) balances;\n mapping(address => mapping(address => bool)) operatorApprovals;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.ERC1155Base');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n" + }, + "@solidstate/contracts/utils/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Set implementation with enumeration functions\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts (MIT license)\n */\nlibrary EnumerableSet {\n struct Set {\n bytes32[] _values;\n // 1-indexed to allow 0 to signify nonexistence\n mapping(bytes32 => uint256) _indexes;\n }\n\n struct Bytes32Set {\n Set _inner;\n }\n\n struct AddressSet {\n Set _inner;\n }\n\n struct UintSet {\n Set _inner;\n }\n\n function at(Bytes32Set storage set, uint256 index)\n internal\n view\n returns (bytes32)\n {\n return _at(set._inner, index);\n }\n\n function at(AddressSet storage set, uint256 index)\n internal\n view\n returns (address)\n {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n function at(UintSet storage set, uint256 index)\n internal\n view\n returns (uint256)\n {\n return uint256(_at(set._inner, index));\n }\n\n function contains(Bytes32Set storage set, bytes32 value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, value);\n }\n\n function contains(AddressSet storage set, address value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function contains(UintSet storage set, uint256 value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, bytes32(value));\n }\n\n function indexOf(Bytes32Set storage set, bytes32 value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, value);\n }\n\n function indexOf(AddressSet storage set, address value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function indexOf(UintSet storage set, uint256 value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, bytes32(value));\n }\n\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function add(Bytes32Set storage set, bytes32 value)\n internal\n returns (bool)\n {\n return _add(set._inner, value);\n }\n\n function add(AddressSet storage set, address value)\n internal\n returns (bool)\n {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n function remove(Bytes32Set storage set, bytes32 value)\n internal\n returns (bool)\n {\n return _remove(set._inner, value);\n }\n\n function remove(AddressSet storage set, address value)\n internal\n returns (bool)\n {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function remove(UintSet storage set, uint256 value)\n internal\n returns (bool)\n {\n return _remove(set._inner, bytes32(value));\n }\n\n function _at(Set storage set, uint256 index)\n private\n view\n returns (bytes32)\n {\n require(\n set._values.length > index,\n 'EnumerableSet: index out of bounds'\n );\n return set._values[index];\n }\n\n function _contains(Set storage set, bytes32 value)\n private\n view\n returns (bool)\n {\n return set._indexes[value] != 0;\n }\n\n function _indexOf(Set storage set, bytes32 value)\n private\n view\n returns (uint256)\n {\n unchecked {\n return set._indexes[value] - 1;\n }\n }\n\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n uint256 index = valueIndex - 1;\n bytes32 last = set._values[set._values.length - 1];\n\n // move last value to now-vacant index\n\n set._values[index] = last;\n set._indexes[last] = index + 1;\n\n // clear last index\n\n set._values.pop();\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n}\n" + }, + "contracts/mining/PremiaMiningStorage.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nlibrary PremiaMiningStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.PremiaMining\");\r\n\r\n // Info of each pool.\r\n struct PoolInfo {\r\n uint256 allocPoint; // How many allocation points assigned to this pool. PREMIA to distribute per block.\r\n uint256 lastRewardTimestamp; // Last timestamp that PREMIA distribution occurs\r\n uint256 accPremiaPerShare; // Accumulated PREMIA per share, times 1e12. See below.\r\n }\r\n\r\n // Info of each user.\r\n struct UserInfo {\r\n uint256 reward; // Total allocated unclaimed reward\r\n uint256 rewardDebt; // Reward debt. See explanation below.\r\n //\r\n // We do some fancy math here. Basically, any point in time, the amount of PREMIA\r\n // entitled to a user but is pending to be distributed is:\r\n //\r\n // pending reward = (user.amount * pool.accPremiaPerShare) - user.rewardDebt\r\n //\r\n // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:\r\n // 1. The pool's `accPremiaPerShare` (and `lastRewardBlock`) gets updated.\r\n // 2. User receives the pending reward sent to his/her address.\r\n // 3. User's `amount` gets updated.\r\n // 4. User's `rewardDebt` gets updated.\r\n }\r\n\r\n struct Layout {\r\n // Total PREMIA left to distribute\r\n uint256 premiaAvailable;\r\n // Amount of premia distributed per year\r\n uint256 premiaPerYear;\r\n // pool -> isCallPool -> PoolInfo\r\n mapping(address => mapping(bool => PoolInfo)) poolInfo;\r\n // pool -> isCallPool -> user -> UserInfo\r\n mapping(address => mapping(bool => mapping(address => UserInfo))) userInfo;\r\n // Total allocation points. Must be the sum of all allocation points in all pools.\r\n uint256 totalAllocPoint;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n}\r\n" + }, + "@solidstate/contracts/utils/IWETH.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from '../token/ERC20/IERC20.sol';\nimport { IERC20Metadata } from '../token/ERC20/metadata/IERC20Metadata.sol';\n\n/**\n * @title WETH (Wrapped ETH) interface\n */\ninterface IWETH is IERC20, IERC20Metadata {\n /**\n * @notice convert ETH to WETH\n */\n function deposit() external payable;\n\n /**\n * @notice convert WETH to ETH\n * @dev if caller is a contract, it should have a fallback or receive function\n * @param amount quantity of WETH to convert, denominated in wei\n */\n function withdraw(uint256 amount) external;\n}\n" + }, + "@solidstate/contracts/token/ERC1155/IERC1155Internal.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @notice Partial ERC1155 interface needed by internal functions\n */\ninterface IERC1155Internal {\n event TransferSingle(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256 id,\n uint256 value\n );\n\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n event ApprovalForAll(\n address indexed account,\n address indexed operator,\n bool approved\n );\n}\n" + }, + "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n\n function decimals()\n external\n view\n returns (\n uint8\n );\n\n function description()\n external\n view\n returns (\n string memory\n );\n\n function version()\n external\n view\n returns (\n uint256\n );\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n}\n" + }, + "@solidstate/contracts/access/OwnableStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary OwnableStorage {\n struct Layout {\n address owner;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.Ownable');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n\n function setOwner(Layout storage l, address owner) internal {\n l.owner = owner;\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + }, + "libraries": { + "contracts/libraries/OptionMath.sol": { + "OptionMath": "0x0f6e8ef18fb5bb61d545fee60f779d8aed60408f" + } + } + } + }, + "ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ivolOracle\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"weth\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"premiaMining\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeReceiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeDiscountAddress\",\"type\":\"address\"},{\"internalType\":\"int128\",\"name\":\"fee64x64\",\"type\":\"int128\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Annihilate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"freedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalContractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"AssignExercise\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"exerciseValue\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"Exercise\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseCost\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeCost\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"spot64x64\",\"type\":\"int128\"}],\"name\":\"Purchase\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"longReceiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalContractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalPremium\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isManualUnderwrite\",\"type\":\"bool\"}],\"name\":\"Underwrite\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"isCall\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"cLevel64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"oldLiquidity64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"newLiquidity64x64\",\"type\":\"int128\"}],\"name\":\"UpdateCLevel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"steepness64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"}],\"name\":\"UpdateSteepness\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositedAt\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"holder\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"}],\"name\":\"exerciseFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"}],\"name\":\"processExpired\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + "ContractName": "PoolExercise", + "CompilerVersion": "v0.8.9+commit.e5eed63a", + "OptimizationUsed": 1, + "Runs": 200, + "ConstructorArguments": "0x0000000000000000000000003a87bb29b984d672664aa1dd2d19d2e8b24f0f2a000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009abb27581c2e46a114f8c367355851e0580e9703000000000000000000000000c4b2c51f969e0713e799de73b7f130fb7bb604cf000000000000000000000000f1bb87563a122211d40d393ebf1c633c330377f900000000000000000000000000000000000000000000000007ae147ae147ae14", + "EVMVersion": "Default", + "Library": "", + "LicenseType": "", + "Proxy": 0, + "SwarmSource": "" + } +] \ No newline at end of file From d1d04787bf5e5aa90955d497f71522569cbe9991 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:39:06 +0200 Subject: [PATCH 0869/1963] chore: move `foundry_common::rpc` to `foundry_test_utils` (#7707) --- Cargo.lock | 4 +++- crates/anvil/Cargo.toml | 15 ++++----------- crates/anvil/tests/it/fork.rs | 3 +-- crates/cast/tests/cli/main.rs | 7 +++++-- crates/common/Cargo.toml | 8 +------- crates/common/src/lib.rs | 1 - crates/evm/core/Cargo.toml | 10 ++++------ crates/evm/core/src/fork/database.rs | 2 +- crates/forge/bin/cmd/clone.rs | 2 +- crates/forge/tests/cli/cmd.rs | 4 ++-- crates/forge/tests/cli/script.rs | 5 ++--- crates/forge/tests/cli/test_cmd.rs | 9 ++++++--- crates/forge/tests/it/fork.rs | 4 ++-- crates/test-utils/Cargo.toml | 1 + crates/test-utils/src/lib.rs | 2 ++ crates/{common => test-utils}/src/rpc.rs | 0 crates/test-utils/src/util.rs | 3 +-- 17 files changed, 36 insertions(+), 44 deletions(-) rename crates/{common => test-utils}/src/rpc.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 3d2f8c7d3c6d5..c7dcd51e06731 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -706,6 +706,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm", + "foundry-test-utils", "futures", "hyper 0.14.28", "itertools 0.12.1", @@ -3800,7 +3801,6 @@ dependencies = [ "num-format", "once_cell", "pretty_assertions", - "rand 0.8.5", "reqwest 0.11.27", "reqwest 0.12.3", "rustc-hash", @@ -3957,6 +3957,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-macros", + "foundry-test-utils", "futures", "itertools 0.12.1", "once_cell", @@ -4072,6 +4073,7 @@ dependencies = [ "once_cell", "parking_lot", "pretty_assertions", + "rand 0.8.5", "regex", "serde_json", "tracing", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index cdf7c2f9b1882..d9d443643f679 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,11 +16,7 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # foundry internal @@ -81,11 +77,7 @@ rand = "0.8" eyre.workspace = true # cli -clap = { version = "4", features = [ - "derive", - "env", - "wrap_help", -], optional = true } +clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" @@ -102,8 +94,9 @@ alloy-json-abi.workspace = true ethers = { workspace = true, features = ["abigen", "optimism"] } ethers-core = { workspace = true, features = ["optimism"] } foundry-compilers = { workspace = true, features = ["project-util", "full"] } +foundry-test-utils.workspace = true -pretty_assertions = "1.3.0" +pretty_assertions.workspace = true tokio = { version = "1", features = ["full"] } crc = "3.0.1" diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 5f94a95aefba1..717e0c57828c4 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -23,11 +23,10 @@ use ethers::{ }; use foundry_common::{ provider::alloy::get_http_provider, - rpc, - rpc::next_http_rpc_endpoint, types::{ToAlloy, ToEthers}, }; use foundry_config::Config; +use foundry_test_utils::rpc::{self, next_http_rpc_endpoint}; use futures::StreamExt; use std::{sync::Arc, time::Duration}; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 7df9d4b91f6a8..bdc17a2fa9101 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,7 +1,10 @@ //! Contains various tests for checking cast commands -use foundry_common::rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}; -use foundry_test_utils::{casttest, util::OutputExt}; +use foundry_test_utils::{ + casttest, + rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}, + util::OutputExt, +}; use std::{fs, io::Write, path::Path}; // tests `--help` is printed to std out diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 7dc6fa3ba666d..cafa1938a5ece 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -24,12 +24,7 @@ reqwest_ethers = { package = "reqwest", version = "0.11", default-features = fal alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = [ - "serde", - "getrandom", - "arbitrary", - "rlp", -] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-rpc-types.workspace = true alloy-rpc-client.workspace = true alloy-provider.workspace = true @@ -55,7 +50,6 @@ glob = "0.3" globset = "0.4" hex.workspace = true once_cell = "1" -rand.workspace = true reqwest = { version = "0.12", default-features = false } semver = "1" serde_json.workspace = true diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 36298ae8fe768..484bc89d273bb 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -20,7 +20,6 @@ pub mod fs; pub mod glob; pub mod provider; pub mod retry; -pub mod rpc; pub mod runtime_client; pub mod selectors; pub mod serde_helpers; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index cf922cbce4925..ff106a406543f 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -19,12 +19,7 @@ foundry-macros.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = [ - "serde", - "getrandom", - "arbitrary", - "rlp", -] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-genesis.workspace = true alloy-provider.workspace = true alloy-transport.workspace = true @@ -59,3 +54,6 @@ thiserror = "1" tokio = { version = "1", features = ["time", "macros"] } tracing = "0.1" url = "2" + +[dev-dependencies] +foundry-test-utils.workspace = true diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index fdc34dbafa7de..649291a0435cb 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -274,7 +274,7 @@ mod tests { /// `AccountInfo` #[tokio::test(flavor = "multi_thread")] async fn fork_db_insert_basic_default() { - let rpc = foundry_common::rpc::next_http_rpc_endpoint(); + let rpc = foundry_test_utils::rpc::next_http_rpc_endpoint(); let provider = get_http_provider(rpc.clone()); let meta = BlockchainDbMeta { cfg_env: Default::default(), diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index a15418d1d7a12..86ef41539a048 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -544,8 +544,8 @@ impl EtherscanClient for Client { #[cfg(test)] mod tests { use super::*; - use foundry_common::rpc::next_etherscan_api_key; use foundry_compilers::Artifact; + use foundry_test_utils::rpc::next_etherscan_api_key; use hex::ToHex; use std::collections::BTreeMap; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index b42d93cfdea3f..0da6191b0e600 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1,11 +1,11 @@ //! Contains various tests for checking forge's commands use crate::constants::*; -use foundry_common::rpc::next_etherscan_api_key; use foundry_compilers::{artifacts::Metadata, remappings::Remapping, ConfigurableContractArtifact}; use foundry_config::{parse_with_profile, BasicConfig, Chain, Config, SolidityErrorCode}; use foundry_test_utils::{ foundry_compilers::PathStyle, + rpc::next_etherscan_api_key, util::{pretty_err, read_string, OutputExt, TestCommand}, }; use semver::Version; @@ -796,7 +796,7 @@ forgetest!( .to_string(); println!("project root: \"{root}\""); - let eth_rpc_url = foundry_common::rpc::next_http_archive_rpc_endpoint(); + let eth_rpc_url = foundry_test_utils::rpc::next_http_archive_rpc_endpoint(); let dss_exec_lib = "src/DssSpell.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4"; cmd.args([ diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index e56ae08ef51e0..21b5837bb1bcb 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3,8 +3,7 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{Address, Bytes}; use anvil::{spawn, NodeConfig}; -use foundry_common::rpc; -use foundry_test_utils::{util::OutputExt, ScriptOutcome, ScriptTester}; +use foundry_test_utils::{rpc, util::OutputExt, ScriptOutcome, ScriptTester}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; @@ -32,7 +31,7 @@ contract ContractScript is Script { ) .unwrap(); - let rpc = foundry_common::rpc::next_http_rpc_endpoint(); + let rpc = foundry_test_utils::rpc::next_http_rpc_endpoint(); cmd.arg("script").arg(script).args(["--fork-url", rpc.as_str(), "-vvvvv"]).assert_success(); } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 5872cc72e9245..2b0784d6a27d0 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,7 +1,10 @@ -//! Contains various tests for checking `forge test` -use foundry_common::rpc; +//! Contains various tests for `forge test`. + use foundry_config::Config; -use foundry_test_utils::util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}; +use foundry_test_utils::{ + rpc, + util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, +}; use std::{path::PathBuf, str::FromStr}; // tests that test filters are handled correctly diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index c2751fe91f951..d3f81ff67ea13 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -66,7 +66,7 @@ async fn test_rpc_fork() { /// Tests that we can launch in forking mode #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork() { - let rpc_url = foundry_common::rpc::next_http_archive_rpc_endpoint(); + let rpc_url = foundry_test_utils::rpc::next_http_archive_rpc_endpoint(); let runner = TEST_DATA_DEFAULT.forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; @@ -75,7 +75,7 @@ async fn test_launch_fork() { /// Smoke test that forking workings with websockets #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork_ws() { - let rpc_url = foundry_common::rpc::next_ws_archive_rpc_endpoint(); + let rpc_url = foundry_test_utils::rpc::next_ws_archive_rpc_endpoint(); let runner = TEST_DATA_DEFAULT.forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 09025e27c6f38..1950487117798 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -29,6 +29,7 @@ serde_json.workspace = true tracing = "0.1" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } walkdir = "2" +rand.workspace = true [features] # feature for integration tests that test external projects diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 042ff4aba1cb1..a4b70f493c5ca 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -6,6 +6,8 @@ extern crate tracing; // Macros useful for testing. mod macros; +pub mod rpc; + pub mod fd_lock; mod filter; diff --git a/crates/common/src/rpc.rs b/crates/test-utils/src/rpc.rs similarity index 100% rename from crates/common/src/rpc.rs rename to crates/test-utils/src/rpc.rs diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index dbb872d8ace10..9d9905d1ce789 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -194,8 +194,7 @@ impl ExtTester { test_cmd.envs(self.envs.iter().map(|(k, v)| (k, v))); if let Some(fork_block) = self.fork_block { - test_cmd - .env("FOUNDRY_ETH_RPC_URL", foundry_common::rpc::next_http_archive_rpc_endpoint()); + test_cmd.env("FOUNDRY_ETH_RPC_URL", crate::rpc::next_http_archive_rpc_endpoint()); test_cmd.env("FOUNDRY_FORK_BLOCK_NUMBER", fork_block.to_string()); } From dcea2837571ab8c263aeabaae7c888d173764e2a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:39:37 +0200 Subject: [PATCH 0870/1963] chore: minify JSON (#7706) --- crates/anvil/test-data/SimpleStorage.json | 118 +----- crates/anvil/test-data/emit_logs.json | 68 +-- crates/anvil/test-data/greeter.json | 45 +- crates/anvil/test-data/multicall.json | 145 +------ crates/anvil/test-data/storage_sample.json | 34 +- crates/cast/tests/fixtures/ERC20Artifact.json | 386 +----------------- crates/cast/tests/fixtures/interface.json | 142 +------ .../cast/tests/fixtures/sign_typed_data.json | 39 +- crates/evm/core/src/abi/HardhatConsole.json | 2 +- crates/evm/core/test-data/storage.json | 2 +- .../deploy.sol/31337/run-latest.json | 64 +-- .../creation_data.json | 6 +- .../metadata.json | 79 +--- .../creation_data.json | 6 +- .../metadata.json | 17 +- .../creation_data.json | 6 +- .../metadata.json | 194 +-------- .../creation_data.json | 6 +- .../metadata.json | 130 +----- .../creation_data.json | 6 +- .../metadata.json | 64 +-- .../creation_data.json | 6 +- .../metadata.json | 70 +--- .../creation_data.json | 6 +- .../metadata.json | 149 +------ 25 files changed, 25 insertions(+), 1765 deletions(-) diff --git a/crates/anvil/test-data/SimpleStorage.json b/crates/anvil/test-data/SimpleStorage.json index 3d4a8b81aa5b9..8ff4ab3812fe3 100644 --- a/crates/anvil/test-data/SimpleStorage.json +++ b/crates/anvil/test-data/SimpleStorage.json @@ -1,117 +1 @@ -{ - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "value", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "author", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "oldAuthor", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "oldValue", - "type": "string" - }, - { - "indexed": false, - "internalType": "string", - "name": "newValue", - "type": "string" - } - ], - "name": "ValueChanged", - "type": "event" - }, - { - "inputs": [], - "name": "_hashPuzzle", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getValue", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastSender", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "value", - "type": "string" - } - ], - "name": "setValue", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "value", - "type": "string" - }, - { - "internalType": "string", - "name": "value2", - "type": "string" - } - ], - "name": "setValues", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bin": "60806040523480156200001157600080fd5b5060405162000d6a38038062000d6a83398181016040528101906200003791906200030f565b600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f999b6d464c4e3383c341bdd3a22b02dda8a7e1d69c069d252e35cb2ee2f4a3c36001846040516200009a929190620004c3565b60405180910390a38060019080519060200190620000ba929190620000c2565b5050620004fe565b828054620000d0906200038f565b90600052602060002090601f016020900481019282620000f4576000855562000140565b82601f106200010f57805160ff191683800117855562000140565b8280016001018555821562000140579182015b828111156200013f57825182559160200191906001019062000122565b5b5090506200014f919062000153565b5090565b5b808211156200016e57600081600090555060010162000154565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620001db8262000190565b810181811067ffffffffffffffff82111715620001fd57620001fc620001a1565b5b80604052505050565b60006200021262000172565b9050620002208282620001d0565b919050565b600067ffffffffffffffff821115620002435762000242620001a1565b5b6200024e8262000190565b9050602081019050919050565b60005b838110156200027b5780820151818401526020810190506200025e565b838111156200028b576000848401525b50505050565b6000620002a8620002a28462000225565b62000206565b905082815260208101848484011115620002c757620002c66200018b565b5b620002d48482856200025b565b509392505050565b600082601f830112620002f457620002f362000186565b5b81516200030684826020860162000291565b91505092915050565b6000602082840312156200032857620003276200017c565b5b600082015167ffffffffffffffff81111562000349576200034862000181565b5b6200035784828501620002dc565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620003a857607f821691505b60208210811415620003bf57620003be62000360565b5b50919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b60008154620003fa816200038f565b620004068186620003c5565b9450600182166000811462000424576001811462000437576200046e565b60ff19831686526020860193506200046e565b6200044285620003d6565b60005b83811015620004665781548189015260018201915060208101905062000445565b808801955050505b50505092915050565b600081519050919050565b60006200048f8262000477565b6200049b8185620003c5565b9350620004ad8185602086016200025b565b620004b88162000190565b840191505092915050565b60006040820190508181036000830152620004df8185620003eb565b90508181036020830152620004f5818462000482565b90509392505050565b61085c806200050e6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063018ba9911461005c578063209652551461007a578063256fec88146100985780637ffaa4b6146100b657806393a09352146100d2575b600080fd5b6100646100ee565b60405161007191906103bd565b60405180910390f35b6100826100f7565b60405161008f9190610471565b60405180910390f35b6100a0610189565b6040516100ad91906104d4565b60405180910390f35b6100d060048036038101906100cb9190610638565b6101ad565b005b6100ec60048036038101906100e791906106b0565b61021f565b005b60006064905090565b60606001805461010690610728565b80601f016020809104026020016040519081016040528092919081815260200182805461013290610728565b801561017f5780601f106101545761010080835404028352916020019161017f565b820191906000526020600020905b81548152906001019060200180831161016257829003601f168201915b5050505050905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b81600190805190602001906101c3929190610301565b5080600290805190602001906101da929190610301565b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f999b6d464c4e3383c341bdd3a22b02dda8a7e1d69c069d252e35cb2ee2f4a3c360018460405161029f9291906107ef565b60405180910390a380600190805190602001906102bd929190610301565b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b82805461030d90610728565b90600052602060002090601f01602090048101928261032f5760008555610376565b82601f1061034857805160ff1916838001178555610376565b82800160010185558215610376579182015b8281111561037557825182559160200191906001019061035a565b5b5090506103839190610387565b5090565b5b808211156103a0576000816000905550600101610388565b5090565b6000819050919050565b6103b7816103a4565b82525050565b60006020820190506103d260008301846103ae565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156104125780820151818401526020810190506103f7565b83811115610421576000848401525b50505050565b6000601f19601f8301169050919050565b6000610443826103d8565b61044d81856103e3565b935061045d8185602086016103f4565b61046681610427565b840191505092915050565b6000602082019050818103600083015261048b8184610438565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104be82610493565b9050919050565b6104ce816104b3565b82525050565b60006020820190506104e960008301846104c5565b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61054582610427565b810181811067ffffffffffffffff821117156105645761056361050d565b5b80604052505050565b60006105776104ef565b9050610583828261053c565b919050565b600067ffffffffffffffff8211156105a3576105a261050d565b5b6105ac82610427565b9050602081019050919050565b82818337600083830152505050565b60006105db6105d684610588565b61056d565b9050828152602081018484840111156105f7576105f6610508565b5b6106028482856105b9565b509392505050565b600082601f83011261061f5761061e610503565b5b813561062f8482602086016105c8565b91505092915050565b6000806040838503121561064f5761064e6104f9565b5b600083013567ffffffffffffffff81111561066d5761066c6104fe565b5b6106798582860161060a565b925050602083013567ffffffffffffffff81111561069a576106996104fe565b5b6106a68582860161060a565b9150509250929050565b6000602082840312156106c6576106c56104f9565b5b600082013567ffffffffffffffff8111156106e4576106e36104fe565b5b6106f08482850161060a565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061074057607f821691505b60208210811415610754576107536106f9565b5b50919050565b60008190508160005260206000209050919050565b6000815461077c81610728565b61078681866103e3565b945060018216600081146107a157600181146107b3576107e6565b60ff19831686526020860193506107e6565b6107bc8561075a565b60005b838110156107de578154818901526001820191506020810190506107bf565b808801955050505b50505092915050565b60006040820190508181036000830152610809818561076f565b9050818103602083015261081d8184610438565b9050939250505056fea2646970667358221220e37ed4b56859ad0b3a3773f57ff7b4e7a99406933fc4ff9f8ae053c52cdf3e3264736f6c63430008090033" -} \ No newline at end of file +{"abi":[{"inputs":[{"internalType":"string","name":"value","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":true,"internalType":"address","name":"oldAuthor","type":"address"},{"indexed":false,"internalType":"string","name":"oldValue","type":"string"},{"indexed":false,"internalType":"string","name":"newValue","type":"string"}],"name":"ValueChanged","type":"event"},{"inputs":[],"name":"_hashPuzzle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getValue","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastSender","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"value","type":"string"}],"name":"setValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"value","type":"string"},{"internalType":"string","name":"value2","type":"string"}],"name":"setValues","outputs":[],"stateMutability":"nonpayable","type":"function"}],"bin":"60806040523480156200001157600080fd5b5060405162000d6a38038062000d6a83398181016040528101906200003791906200030f565b600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f999b6d464c4e3383c341bdd3a22b02dda8a7e1d69c069d252e35cb2ee2f4a3c36001846040516200009a929190620004c3565b60405180910390a38060019080519060200190620000ba929190620000c2565b5050620004fe565b828054620000d0906200038f565b90600052602060002090601f016020900481019282620000f4576000855562000140565b82601f106200010f57805160ff191683800117855562000140565b8280016001018555821562000140579182015b828111156200013f57825182559160200191906001019062000122565b5b5090506200014f919062000153565b5090565b5b808211156200016e57600081600090555060010162000154565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620001db8262000190565b810181811067ffffffffffffffff82111715620001fd57620001fc620001a1565b5b80604052505050565b60006200021262000172565b9050620002208282620001d0565b919050565b600067ffffffffffffffff821115620002435762000242620001a1565b5b6200024e8262000190565b9050602081019050919050565b60005b838110156200027b5780820151818401526020810190506200025e565b838111156200028b576000848401525b50505050565b6000620002a8620002a28462000225565b62000206565b905082815260208101848484011115620002c757620002c66200018b565b5b620002d48482856200025b565b509392505050565b600082601f830112620002f457620002f362000186565b5b81516200030684826020860162000291565b91505092915050565b6000602082840312156200032857620003276200017c565b5b600082015167ffffffffffffffff81111562000349576200034862000181565b5b6200035784828501620002dc565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620003a857607f821691505b60208210811415620003bf57620003be62000360565b5b50919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b60008154620003fa816200038f565b620004068186620003c5565b9450600182166000811462000424576001811462000437576200046e565b60ff19831686526020860193506200046e565b6200044285620003d6565b60005b83811015620004665781548189015260018201915060208101905062000445565b808801955050505b50505092915050565b600081519050919050565b60006200048f8262000477565b6200049b8185620003c5565b9350620004ad8185602086016200025b565b620004b88162000190565b840191505092915050565b60006040820190508181036000830152620004df8185620003eb565b90508181036020830152620004f5818462000482565b90509392505050565b61085c806200050e6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063018ba9911461005c578063209652551461007a578063256fec88146100985780637ffaa4b6146100b657806393a09352146100d2575b600080fd5b6100646100ee565b60405161007191906103bd565b60405180910390f35b6100826100f7565b60405161008f9190610471565b60405180910390f35b6100a0610189565b6040516100ad91906104d4565b60405180910390f35b6100d060048036038101906100cb9190610638565b6101ad565b005b6100ec60048036038101906100e791906106b0565b61021f565b005b60006064905090565b60606001805461010690610728565b80601f016020809104026020016040519081016040528092919081815260200182805461013290610728565b801561017f5780601f106101545761010080835404028352916020019161017f565b820191906000526020600020905b81548152906001019060200180831161016257829003601f168201915b5050505050905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b81600190805190602001906101c3929190610301565b5080600290805190602001906101da929190610301565b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f999b6d464c4e3383c341bdd3a22b02dda8a7e1d69c069d252e35cb2ee2f4a3c360018460405161029f9291906107ef565b60405180910390a380600190805190602001906102bd929190610301565b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b82805461030d90610728565b90600052602060002090601f01602090048101928261032f5760008555610376565b82601f1061034857805160ff1916838001178555610376565b82800160010185558215610376579182015b8281111561037557825182559160200191906001019061035a565b5b5090506103839190610387565b5090565b5b808211156103a0576000816000905550600101610388565b5090565b6000819050919050565b6103b7816103a4565b82525050565b60006020820190506103d260008301846103ae565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156104125780820151818401526020810190506103f7565b83811115610421576000848401525b50505050565b6000601f19601f8301169050919050565b6000610443826103d8565b61044d81856103e3565b935061045d8185602086016103f4565b61046681610427565b840191505092915050565b6000602082019050818103600083015261048b8184610438565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104be82610493565b9050919050565b6104ce816104b3565b82525050565b60006020820190506104e960008301846104c5565b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61054582610427565b810181811067ffffffffffffffff821117156105645761056361050d565b5b80604052505050565b60006105776104ef565b9050610583828261053c565b919050565b600067ffffffffffffffff8211156105a3576105a261050d565b5b6105ac82610427565b9050602081019050919050565b82818337600083830152505050565b60006105db6105d684610588565b61056d565b9050828152602081018484840111156105f7576105f6610508565b5b6106028482856105b9565b509392505050565b600082601f83011261061f5761061e610503565b5b813561062f8482602086016105c8565b91505092915050565b6000806040838503121561064f5761064e6104f9565b5b600083013567ffffffffffffffff81111561066d5761066c6104fe565b5b6106798582860161060a565b925050602083013567ffffffffffffffff81111561069a576106996104fe565b5b6106a68582860161060a565b9150509250929050565b6000602082840312156106c6576106c56104f9565b5b600082013567ffffffffffffffff8111156106e4576106e36104fe565b5b6106f08482850161060a565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061074057607f821691505b60208210811415610754576107536106f9565b5b50919050565b60008190508160005260206000209050919050565b6000815461077c81610728565b61078681866103e3565b945060018216600081146107a157600181146107b3576107e6565b60ff19831686526020860193506107e6565b6107bc8561075a565b60005b838110156107de578154818901526001820191506020810190506107bf565b808801955050505b50505092915050565b60006040820190508181036000830152610809818561076f565b9050818103602083015261081d8184610438565b9050939250505056fea2646970667358221220e37ed4b56859ad0b3a3773f57ff7b4e7a99406933fc4ff9f8ae053c52cdf3e3264736f6c63430008090033"} \ No newline at end of file diff --git a/crates/anvil/test-data/emit_logs.json b/crates/anvil/test-data/emit_logs.json index 0113e1c49d926..635019ae3ab33 100644 --- a/crates/anvil/test-data/emit_logs.json +++ b/crates/anvil/test-data/emit_logs.json @@ -1,67 +1 @@ -{ - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "value", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "author", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "oldValue", - "type": "string" - }, - { - "indexed": false, - "internalType": "string", - "name": "newValue", - "type": "string" - } - ], - "name": "ValueChanged", - "type": "event" - }, - { - "inputs": [], - "name": "getValue", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "value", - "type": "string" - } - ], - "name": "setValue", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bin": "608060405234801561001057600080fd5b506040516105a63803806105a68339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052505081516100f6915060009060208401906100fd565b505061019e565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826101335760008555610179565b82601f1061014c57805160ff1916838001178555610179565b82800160010185558215610179579182015b8281111561017957825182559160200191906001019061015e565b50610185929150610189565b5090565b5b80821115610185576000815560010161018a565b6103f9806101ad6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063209652551461003b57806393a09352146100b8575b600080fd5b610043610160565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561007d578181015183820152602001610065565b50505050905090810190601f1680156100aa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61015e600480360360208110156100ce57600080fd5b8101906020810181356401000000008111156100e957600080fd5b8201836020820111156100fb57600080fd5b8035906020019184600183028401116401000000008311171561011d57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101f6945050505050565b005b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ec5780601f106101c1576101008083540402835291602001916101ec565b820191906000526020600020905b8154815290600101906020018083116101cf57829003601f168201915b5050505050905090565b60408051818152600080546002600019610100600184161502019091160492820183905233927fe826f71647b8486f2bae59832124c70792fba044036720a54ec8dacdd5df4fcb9285918190602082019060608301908690801561029b5780601f106102705761010080835404028352916020019161029b565b820191906000526020600020905b81548152906001019060200180831161027e57829003601f168201915b5050838103825284518152845160209182019186019080838360005b838110156102cf5781810151838201526020016102b7565b50505050905090810190601f1680156102fc5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a2805161031e906000906020840190610322565b5050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282610358576000855561039e565b82601f1061037157805160ff191683800117855561039e565b8280016001018555821561039e579182015b8281111561039e578251825591602001919060010190610383565b506103aa9291506103ae565b5090565b5b808211156103aa57600081556001016103af56fea2646970667358221220c1367a0db85dfe60814cdfc5141a8fe8b95c9d051a6824343085c3ba9697244a64736f6c63430007060033" -} \ No newline at end of file +{"abi":[{"inputs":[{"internalType":"string","name":"value","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":false,"internalType":"string","name":"oldValue","type":"string"},{"indexed":false,"internalType":"string","name":"newValue","type":"string"}],"name":"ValueChanged","type":"event"},{"inputs":[],"name":"getValue","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"value","type":"string"}],"name":"setValue","outputs":[],"stateMutability":"nonpayable","type":"function"}],"bin":"608060405234801561001057600080fd5b506040516105a63803806105a68339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052505081516100f6915060009060208401906100fd565b505061019e565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826101335760008555610179565b82601f1061014c57805160ff1916838001178555610179565b82800160010185558215610179579182015b8281111561017957825182559160200191906001019061015e565b50610185929150610189565b5090565b5b80821115610185576000815560010161018a565b6103f9806101ad6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063209652551461003b57806393a09352146100b8575b600080fd5b610043610160565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561007d578181015183820152602001610065565b50505050905090810190601f1680156100aa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61015e600480360360208110156100ce57600080fd5b8101906020810181356401000000008111156100e957600080fd5b8201836020820111156100fb57600080fd5b8035906020019184600183028401116401000000008311171561011d57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101f6945050505050565b005b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101ec5780601f106101c1576101008083540402835291602001916101ec565b820191906000526020600020905b8154815290600101906020018083116101cf57829003601f168201915b5050505050905090565b60408051818152600080546002600019610100600184161502019091160492820183905233927fe826f71647b8486f2bae59832124c70792fba044036720a54ec8dacdd5df4fcb9285918190602082019060608301908690801561029b5780601f106102705761010080835404028352916020019161029b565b820191906000526020600020905b81548152906001019060200180831161027e57829003601f168201915b5050838103825284518152845160209182019186019080838360005b838110156102cf5781810151838201526020016102b7565b50505050905090810190601f1680156102fc5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a2805161031e906000906020840190610322565b5050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282610358576000855561039e565b82601f1061037157805160ff191683800117855561039e565b8280016001018555821561039e579182015b8281111561039e578251825591602001919060010190610383565b506103aa9291506103ae565b5090565b5b808211156103aa57600081556001016103af56fea2646970667358221220c1367a0db85dfe60814cdfc5141a8fe8b95c9d051a6824343085c3ba9697244a64736f6c63430007060033"} \ No newline at end of file diff --git a/crates/anvil/test-data/greeter.json b/crates/anvil/test-data/greeter.json index 0892e4d43f920..93c50f01edb8f 100644 --- a/crates/anvil/test-data/greeter.json +++ b/crates/anvil/test-data/greeter.json @@ -1,44 +1 @@ -{ - "bytecode": { - "object": "608060405234801561001057600080fd5b506040516104913803806104918339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052505081516100f6915060009060208401906100fd565b505061019e565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826101335760008555610179565b82601f1061014c57805160ff1916838001178555610179565b82800160010185558215610179579182015b8281111561017957825182559160200191906001019061015e565b50610185929150610189565b5090565b5b80821115610185576000815560010161018a565b6102e4806101ad6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063a41368621461003b578063cfae3217146100e3575b600080fd5b6100e16004803603602081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610160945050505050565b005b6100eb610177565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012557818101518382015260200161010d565b50505050905090810190601f1680156101525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b805161017390600090602084019061020d565b5050565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156102035780601f106101d857610100808354040283529160200191610203565b820191906000526020600020905b8154815290600101906020018083116101e657829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826102435760008555610289565b82601f1061025c57805160ff1916838001178555610289565b82800160010185558215610289579182015b8281111561028957825182559160200191906001019061026e565b50610295929150610299565b5090565b5b80821115610295576000815560010161029a56fea26469706673582212208b9161dfd195d53618942a72a3b481d61a7b142de919925a0b34f9c986e5707e64736f6c63430007060033" - }, - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "_greeting", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "greet", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_greeting", - "type": "string" - } - ], - "name": "setGreeting", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ] -} \ No newline at end of file +{"bytecode":{"object":"608060405234801561001057600080fd5b506040516104913803806104918339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b50604052505081516100f6915060009060208401906100fd565b505061019e565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826101335760008555610179565b82601f1061014c57805160ff1916838001178555610179565b82800160010185558215610179579182015b8281111561017957825182559160200191906001019061015e565b50610185929150610189565b5090565b5b80821115610185576000815560010161018a565b6102e4806101ad6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063a41368621461003b578063cfae3217146100e3575b600080fd5b6100e16004803603602081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610160945050505050565b005b6100eb610177565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012557818101518382015260200161010d565b50505050905090810190601f1680156101525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b805161017390600090602084019061020d565b5050565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156102035780601f106101d857610100808354040283529160200191610203565b820191906000526020600020905b8154815290600101906020018083116101e657829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826102435760008555610289565b82601f1061025c57805160ff1916838001178555610289565b82800160010185558215610289579182015b8281111561028957825182559160200191906001019061026e565b50610295929150610299565b5090565b5b80821115610295576000815560010161029a56fea26469706673582212208b9161dfd195d53618942a72a3b481d61a7b142de919925a0b34f9c986e5707e64736f6c63430007060033"},"abi":[{"inputs":[{"internalType":"string","name":"_greeting","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"greet","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_greeting","type":"string"}],"name":"setGreeting","outputs":[],"stateMutability":"nonpayable","type":"function"}]} \ No newline at end of file diff --git a/crates/anvil/test-data/multicall.json b/crates/anvil/test-data/multicall.json index e0be8fc5df4e2..e7f7d9f1138f7 100644 --- a/crates/anvil/test-data/multicall.json +++ b/crates/anvil/test-data/multicall.json @@ -1,144 +1 @@ -{ - "abi": [ - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" - } - ], - "internalType": "struct Multicall.Call[]", - "name": "calls", - "type": "tuple[]" - } - ], - "name": "aggregate", - "outputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - }, - { - "internalType": "bytes[]", - "name": "returnData", - "type": "bytes[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - } - ], - "name": "getBlockHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockCoinbase", - "outputs": [ - { - "internalType": "address", - "name": "coinbase", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockDifficulty", - "outputs": [ - { - "internalType": "uint256", - "name": "difficulty", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockGasLimit", - "outputs": [ - { - "internalType": "uint256", - "name": "gaslimit", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentBlockTimestamp", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "getEthBalance", - "outputs": [ - { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastBlockHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "blockHash", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "bin": "608060405234801561001057600080fd5b50610abb806100206000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806372425d9d1161005b57806372425d9d1461012a57806386d516e814610148578063a8b0574e14610166578063ee82ac5e1461018457610088565b80630f28c97d1461008d578063252dba42146100ab57806327e86d6e146100dc5780634d2301cc146100fa575b600080fd5b6100956101b4565b6040516100a29190610381565b60405180910390f35b6100c560048036038101906100c091906106b0565b6101bc565b6040516100d3929190610843565b60405180910390f35b6100e461030f565b6040516100f1919061088c565b60405180910390f35b610114600480360381019061010f91906108a7565b610324565b6040516101219190610381565b60405180910390f35b610132610345565b60405161013f9190610381565b60405180910390f35b61015061034d565b60405161015d9190610381565b60405180910390f35b61016e610355565b60405161017b91906108e3565b60405180910390f35b61019e6004803603810190610199919061092a565b61035d565b6040516101ab919061088c565b60405180910390f35b600042905090565b60006060439150825167ffffffffffffffff8111156101de576101dd6103c6565b5b60405190808252806020026020018201604052801561021157816020015b60608152602001906001900390816101fc5790505b50905060005b83518110156103095760008085838151811061023657610235610957565b5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1686848151811061026b5761026a610957565b5b60200260200101516020015160405161028491906109c2565b6000604051808303816000865af19150503d80600081146102c1576040519150601f19603f3d011682016040523d82523d6000602084013e6102c6565b606091505b5091509150816102d557600080fd5b808484815181106102e9576102e8610957565b5b60200260200101819052505050808061030190610a08565b915050610217565b50915091565b600060014361031e9190610a51565b40905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b600045905090565b600041905090565b600081409050919050565b6000819050919050565b61037b81610368565b82525050565b60006020820190506103966000830184610372565b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6103fe826103b5565b810181811067ffffffffffffffff8211171561041d5761041c6103c6565b5b80604052505050565b600061043061039c565b905061043c82826103f5565b919050565b600067ffffffffffffffff82111561045c5761045b6103c6565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104a78261047c565b9050919050565b6104b78161049c565b81146104c257600080fd5b50565b6000813590506104d4816104ae565b92915050565b600080fd5b600067ffffffffffffffff8211156104fa576104f96103c6565b5b610503826103b5565b9050602081019050919050565b82818337600083830152505050565b600061053261052d846104df565b610426565b90508281526020810184848401111561054e5761054d6104da565b5b610559848285610510565b509392505050565b600082601f830112610576576105756103b0565b5b813561058684826020860161051f565b91505092915050565b6000604082840312156105a5576105a4610472565b5b6105af6040610426565b905060006105bf848285016104c5565b600083015250602082013567ffffffffffffffff8111156105e3576105e2610477565b5b6105ef84828501610561565b60208301525092915050565b600061060e61060984610441565b610426565b905080838252602082019050602084028301858111156106315761063061046d565b5b835b8181101561067857803567ffffffffffffffff811115610656576106556103b0565b5b808601610663898261058f565b85526020850194505050602081019050610633565b5050509392505050565b600082601f830112610697576106966103b0565b5b81356106a78482602086016105fb565b91505092915050565b6000602082840312156106c6576106c56103a6565b5b600082013567ffffffffffffffff8111156106e4576106e36103ab565b5b6106f084828501610682565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561075f578082015181840152602081019050610744565b8381111561076e576000848401525b50505050565b600061077f82610725565b6107898185610730565b9350610799818560208601610741565b6107a2816103b5565b840191505092915050565b60006107b98383610774565b905092915050565b6000602082019050919050565b60006107d9826106f9565b6107e38185610704565b9350836020820285016107f585610715565b8060005b85811015610831578484038952815161081285826107ad565b945061081d836107c1565b925060208a019950506001810190506107f9565b50829750879550505050505092915050565b60006040820190506108586000830185610372565b818103602083015261086a81846107ce565b90509392505050565b6000819050919050565b61088681610873565b82525050565b60006020820190506108a1600083018461087d565b92915050565b6000602082840312156108bd576108bc6103a6565b5b60006108cb848285016104c5565b91505092915050565b6108dd8161049c565b82525050565b60006020820190506108f860008301846108d4565b92915050565b61090781610368565b811461091257600080fd5b50565b600081359050610924816108fe565b92915050565b6000602082840312156109405761093f6103a6565b5b600061094e84828501610915565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081905092915050565b600061099c82610725565b6109a68185610986565b93506109b6818560208601610741565b80840191505092915050565b60006109ce8284610991565b915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a1382610368565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610a4657610a456109d9565b5b600182019050919050565b6000610a5c82610368565b9150610a6783610368565b925082821015610a7a57610a796109d9565b5b82820390509291505056fea2646970667358221220e5023d90063e0939116a41565414721ba1350cd3e98b12e7b65983a039644df964736f6c634300080a0033" -} \ No newline at end of file +{"abi":[{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall.Call[]","name":"calls","type":"tuple[]"}],"name":"aggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes[]","name":"returnData","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockCoinbase","outputs":[{"internalType":"address","name":"coinbase","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockDifficulty","outputs":[{"internalType":"uint256","name":"difficulty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockGasLimit","outputs":[{"internalType":"uint256","name":"gaslimit","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockTimestamp","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getEthBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"stateMutability":"view","type":"function"}],"bin":"608060405234801561001057600080fd5b50610abb806100206000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806372425d9d1161005b57806372425d9d1461012a57806386d516e814610148578063a8b0574e14610166578063ee82ac5e1461018457610088565b80630f28c97d1461008d578063252dba42146100ab57806327e86d6e146100dc5780634d2301cc146100fa575b600080fd5b6100956101b4565b6040516100a29190610381565b60405180910390f35b6100c560048036038101906100c091906106b0565b6101bc565b6040516100d3929190610843565b60405180910390f35b6100e461030f565b6040516100f1919061088c565b60405180910390f35b610114600480360381019061010f91906108a7565b610324565b6040516101219190610381565b60405180910390f35b610132610345565b60405161013f9190610381565b60405180910390f35b61015061034d565b60405161015d9190610381565b60405180910390f35b61016e610355565b60405161017b91906108e3565b60405180910390f35b61019e6004803603810190610199919061092a565b61035d565b6040516101ab919061088c565b60405180910390f35b600042905090565b60006060439150825167ffffffffffffffff8111156101de576101dd6103c6565b5b60405190808252806020026020018201604052801561021157816020015b60608152602001906001900390816101fc5790505b50905060005b83518110156103095760008085838151811061023657610235610957565b5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1686848151811061026b5761026a610957565b5b60200260200101516020015160405161028491906109c2565b6000604051808303816000865af19150503d80600081146102c1576040519150601f19603f3d011682016040523d82523d6000602084013e6102c6565b606091505b5091509150816102d557600080fd5b808484815181106102e9576102e8610957565b5b60200260200101819052505050808061030190610a08565b915050610217565b50915091565b600060014361031e9190610a51565b40905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b600045905090565b600041905090565b600081409050919050565b6000819050919050565b61037b81610368565b82525050565b60006020820190506103966000830184610372565b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6103fe826103b5565b810181811067ffffffffffffffff8211171561041d5761041c6103c6565b5b80604052505050565b600061043061039c565b905061043c82826103f5565b919050565b600067ffffffffffffffff82111561045c5761045b6103c6565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104a78261047c565b9050919050565b6104b78161049c565b81146104c257600080fd5b50565b6000813590506104d4816104ae565b92915050565b600080fd5b600067ffffffffffffffff8211156104fa576104f96103c6565b5b610503826103b5565b9050602081019050919050565b82818337600083830152505050565b600061053261052d846104df565b610426565b90508281526020810184848401111561054e5761054d6104da565b5b610559848285610510565b509392505050565b600082601f830112610576576105756103b0565b5b813561058684826020860161051f565b91505092915050565b6000604082840312156105a5576105a4610472565b5b6105af6040610426565b905060006105bf848285016104c5565b600083015250602082013567ffffffffffffffff8111156105e3576105e2610477565b5b6105ef84828501610561565b60208301525092915050565b600061060e61060984610441565b610426565b905080838252602082019050602084028301858111156106315761063061046d565b5b835b8181101561067857803567ffffffffffffffff811115610656576106556103b0565b5b808601610663898261058f565b85526020850194505050602081019050610633565b5050509392505050565b600082601f830112610697576106966103b0565b5b81356106a78482602086016105fb565b91505092915050565b6000602082840312156106c6576106c56103a6565b5b600082013567ffffffffffffffff8111156106e4576106e36103ab565b5b6106f084828501610682565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561075f578082015181840152602081019050610744565b8381111561076e576000848401525b50505050565b600061077f82610725565b6107898185610730565b9350610799818560208601610741565b6107a2816103b5565b840191505092915050565b60006107b98383610774565b905092915050565b6000602082019050919050565b60006107d9826106f9565b6107e38185610704565b9350836020820285016107f585610715565b8060005b85811015610831578484038952815161081285826107ad565b945061081d836107c1565b925060208a019950506001810190506107f9565b50829750879550505050505092915050565b60006040820190506108586000830185610372565b818103602083015261086a81846107ce565b90509392505050565b6000819050919050565b61088681610873565b82525050565b60006020820190506108a1600083018461087d565b92915050565b6000602082840312156108bd576108bc6103a6565b5b60006108cb848285016104c5565b91505092915050565b6108dd8161049c565b82525050565b60006020820190506108f860008301846108d4565b92915050565b61090781610368565b811461091257600080fd5b50565b600081359050610924816108fe565b92915050565b6000602082840312156109405761093f6103a6565b5b600061094e84828501610915565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081905092915050565b600061099c82610725565b6109a68185610986565b93506109b6818560208601610741565b80840191505092915050565b60006109ce8284610991565b915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a1382610368565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610a4657610a456109d9565b5b600182019050919050565b6000610a5c82610368565b9150610a6783610368565b925082821015610a7a57610a796109d9565b5b82820390509291505056fea2646970667358221220e5023d90063e0939116a41565414721ba1350cd3e98b12e7b65983a039644df964736f6c634300080a0033"} \ No newline at end of file diff --git a/crates/anvil/test-data/storage_sample.json b/crates/anvil/test-data/storage_sample.json index 7e2daf48f45b6..5241cb08e8f77 100644 --- a/crates/anvil/test-data/storage_sample.json +++ b/crates/anvil/test-data/storage_sample.json @@ -1,33 +1 @@ -{ - "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", - "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", - "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", - "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", - "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", - "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", - "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", - "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", - "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", - "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", - "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", - "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", - "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", - "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", - "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", - "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", - "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", - "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", - "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", - "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", - "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", - "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", - "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", - "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", - "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", - "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", - "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", - "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", - "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", - "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", - "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" -} \ No newline at end of file +{"0x0000000000000000000000000000000000000000000000000000000000000022":"0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b","0x0000000000000000000000000000000000000000000000000000000000000023":"0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71","0x0000000000000000000000000000000000000000000000000000000000000024":"0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c","0x0000000000000000000000000000000000000000000000000000000000000025":"0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c","0x0000000000000000000000000000000000000000000000000000000000000026":"0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30","0x0000000000000000000000000000000000000000000000000000000000000027":"0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1","0x0000000000000000000000000000000000000000000000000000000000000028":"0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c","0x0000000000000000000000000000000000000000000000000000000000000029":"0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193","0x000000000000000000000000000000000000000000000000000000000000002a":"0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1","0x000000000000000000000000000000000000000000000000000000000000002b":"0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b","0x000000000000000000000000000000000000000000000000000000000000002c":"0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220","0x000000000000000000000000000000000000000000000000000000000000002d":"0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f","0x000000000000000000000000000000000000000000000000000000000000002e":"0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e","0x000000000000000000000000000000000000000000000000000000000000002f":"0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784","0x0000000000000000000000000000000000000000000000000000000000000030":"0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb","0x0000000000000000000000000000000000000000000000000000000000000031":"0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb","0x0000000000000000000000000000000000000000000000000000000000000032":"0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab","0x0000000000000000000000000000000000000000000000000000000000000033":"0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4","0x0000000000000000000000000000000000000000000000000000000000000034":"0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f","0x0000000000000000000000000000000000000000000000000000000000000035":"0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa","0x0000000000000000000000000000000000000000000000000000000000000036":"0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c","0x0000000000000000000000000000000000000000000000000000000000000037":"0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167","0x0000000000000000000000000000000000000000000000000000000000000038":"0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7","0x0000000000000000000000000000000000000000000000000000000000000039":"0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0","0x000000000000000000000000000000000000000000000000000000000000003a":"0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544","0x000000000000000000000000000000000000000000000000000000000000003b":"0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765","0x000000000000000000000000000000000000000000000000000000000000003c":"0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4","0x000000000000000000000000000000000000000000000000000000000000003d":"0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1","0x000000000000000000000000000000000000000000000000000000000000003e":"0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636","0x000000000000000000000000000000000000000000000000000000000000003f":"0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c","0x0000000000000000000000000000000000000000000000000000000000000040":"0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7"} \ No newline at end of file diff --git a/crates/cast/tests/fixtures/ERC20Artifact.json b/crates/cast/tests/fixtures/ERC20Artifact.json index 4f4fd6e61fa33..508464c246ada 100644 --- a/crates/cast/tests/fixtures/ERC20Artifact.json +++ b/crates/cast/tests/fixtures/ERC20Artifact.json @@ -1,385 +1 @@ -{ - "abi": [ - { - "inputs": [ - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "symbol", - "type": "string" - }, - { - "internalType": "uint8", - "name": "decimals", - "type": "uint8" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "permit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "bytecode": { - "object": "0x60e06040523480156200001157600080fd5b5060405162000f7738038062000f7783398101604081905262000034916200029a565b82828282600090805190602001906200004f92919062000127565b5081516200006590600190602085019062000127565b5060ff81166080524660a0526200007b6200008b565b60c0525062000400945050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6000604051620000bf91906200035c565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b82805462000135906200031f565b90600052602060002090601f016020900481019282620001595760008555620001a4565b82601f106200017457805160ff1916838001178555620001a4565b82800160010185558215620001a4579182015b82811115620001a457825182559160200191906001019062000187565b50620001b2929150620001b6565b5090565b5b80821115620001b25760008155600101620001b7565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f557600080fd5b81516001600160401b0380821115620002125762000212620001cd565b604051601f8301601f19908116603f011681019082821181831017156200023d576200023d620001cd565b816040528381526020925086838588010111156200025a57600080fd5b600091505b838210156200027e57858201830151818301840152908201906200025f565b83821115620002905760008385830101525b9695505050505050565b600080600060608486031215620002b057600080fd5b83516001600160401b0380821115620002c857600080fd5b620002d687838801620001e3565b94506020860151915080821115620002ed57600080fd5b50620002fc86828701620001e3565b925050604084015160ff811681146200031457600080fd5b809150509250925092565b600181811c908216806200033457607f821691505b602082108114156200035657634e487b7160e01b600052602260045260246000fd5b50919050565b600080835481600182811c9150808316806200037957607f831692505b60208084108214156200039a57634e487b7160e01b86526022600452602486fd5b818015620003b15760018114620003c357620003f2565b60ff19861689528489019650620003f2565b60008a81526020902060005b86811015620003ea5781548b820152908501908301620003cf565b505084890196505b509498975050505050505050565b60805160a05160c051610b476200043060003960006104530152600061041e015260006101440152610b476000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c806340c10f191161008c57806395d89b411161006657806395d89b41146101d5578063a9059cbb146101dd578063d505accf146101f0578063dd62ed3e1461020357600080fd5b806340c10f191461018057806370a08231146101955780637ecebe00146101b557600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd1461012c578063313ce5671461013f5780633644e51514610178575b600080fd5b6100dc61022e565b6040516100e99190610856565b60405180910390f35b6101056101003660046108c7565b6102bc565b60405190151581526020016100e9565b61011e60025481565b6040519081526020016100e9565b61010561013a3660046108f1565b610328565b6101667f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016100e9565b61011e61041a565b61019361018e3660046108c7565b610475565b005b61011e6101a336600461092d565b60036020526000908152604090205481565b61011e6101c336600461092d565b60056020526000908152604090205481565b6100dc610483565b6101056101eb3660046108c7565b610490565b6101936101fe36600461094f565b610508565b61011e6102113660046109c2565b600460209081526000928352604080842090915290825290205481565b6000805461023b906109f5565b80601f0160208091040260200160405190810160405280929190818152602001828054610267906109f5565b80156102b45780601f10610289576101008083540402835291602001916102b4565b820191906000526020600020905b81548152906001019060200180831161029757829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906103179086815260200190565b60405180910390a350600192915050565b6001600160a01b038316600090815260046020908152604080832033845290915281205460001981146103845761035f8382610a46565b6001600160a01b03861660009081526004602090815260408083203384529091529020555b6001600160a01b038516600090815260036020526040812080548592906103ac908490610a46565b90915550506001600160a01b03808516600081815260036020526040908190208054870190555190918716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906104079087815260200190565b60405180910390a3506001949350505050565b60007f000000000000000000000000000000000000000000000000000000000000000046146104505761044b610751565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b61047f82826107eb565b5050565b6001805461023b906109f5565b336000908152600360205260408120805483919083906104b1908490610a46565b90915550506001600160a01b038316600081815260036020526040908190208054850190555133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906103179086815260200190565b4284101561055d5760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f4558504952454400000000000000000060448201526064015b60405180910390fd5b6000600161056961041a565b6001600160a01b038a811660008181526005602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e08301909152805192019190912061190160f01b6101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015610675573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906106ab5750876001600160a01b0316816001600160a01b0316145b6106e85760405162461bcd60e51b815260206004820152600e60248201526d24a72b20a624a22fa9a4a3a722a960911b6044820152606401610554565b6001600160a01b0390811660009081526004602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516107839190610a5d565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b80600260008282546107fd9190610af9565b90915550506001600160a01b0382166000818152600360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600060208083528351808285015260005b8181101561088357858101830151858201604001528201610867565b81811115610895576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b03811681146108c257600080fd5b919050565b600080604083850312156108da57600080fd5b6108e3836108ab565b946020939093013593505050565b60008060006060848603121561090657600080fd5b61090f846108ab565b925061091d602085016108ab565b9150604084013590509250925092565b60006020828403121561093f57600080fd5b610948826108ab565b9392505050565b600080600080600080600060e0888a03121561096a57600080fd5b610973886108ab565b9650610981602089016108ab565b95506040880135945060608801359350608088013560ff811681146109a557600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156109d557600080fd5b6109de836108ab565b91506109ec602084016108ab565b90509250929050565b600181811c90821680610a0957607f821691505b60208210811415610a2a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015610a5857610a58610a30565b500390565b600080835481600182811c915080831680610a7957607f831692505b6020808410821415610a9957634e487b7160e01b86526022600452602486fd5b818015610aad5760018114610abe57610aeb565b60ff19861689528489019650610aeb565b60008a81526020902060005b86811015610ae35781548b820152908501908301610aca565b505084890196505b509498975050505050505050565b60008219821115610b0c57610b0c610a30565b50019056fea26469706673582212209ca55739676d094f8ef4b3b5cfcc08f600b805843c4c3027beb2b4159a02f63664736f6c634300080a0033", - "sourceMap": "113:230:22:-:0;;;148:102;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;224:4;230:6;238:8;2098:5:10;2091:4;:12;;;;;;;;;;;;:::i;:::-;-1:-1:-1;2113:16:10;;;;:6;;:16;;;;;:::i;:::-;-1:-1:-1;2139:20:10;;;;;2189:13;2170:32;;2239:24;:22;:24::i;:::-;2212:51;;-1:-1:-1;113:230:22;;-1:-1:-1;;;;;113:230:22;5507:446:10;5572:7;5669:95;5802:4;5786:22;;;;;;:::i;:::-;;;;;;;;;;5637:295;;;3635:25:23;;;;3676:18;;3669:34;;;;5830:14:10;3719:18:23;;;3712:34;5866:13:10;3762:18:23;;;3755:34;5909:4:10;3805:19:23;;;3798:61;3607:19;;5637:295:10;;;;;;;;;;;;5610:336;;;;;;5591:355;;5507:446;:::o;113:230:22:-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;113:230:22;;;-1:-1:-1;113:230:22;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;14:127:23;75:10;70:3;66:20;63:1;56:31;106:4;103:1;96:15;130:4;127:1;120:15;146:885;200:5;253:3;246:4;238:6;234:17;230:27;220:55;;271:1;268;261:12;220:55;294:13;;-1:-1:-1;;;;;356:10:23;;;353:36;;;369:18;;:::i;:::-;444:2;438:9;412:2;498:13;;-1:-1:-1;;494:22:23;;;518:2;490:31;486:40;474:53;;;542:18;;;562:22;;;539:46;536:72;;;588:18;;:::i;:::-;628:10;624:2;617:22;663:2;655:6;648:18;685:4;675:14;;730:3;725:2;720;712:6;708:15;704:24;701:33;698:53;;;747:1;744;737:12;698:53;769:1;760:10;;779:133;793:2;790:1;787:9;779:133;;;881:14;;;877:23;;871:30;850:14;;;846:23;;839:63;804:10;;;;779:133;;;930:2;927:1;924:9;921:80;;;989:1;984:2;979;971:6;967:15;963:24;956:35;921:80;1019:6;146:885;-1:-1:-1;;;;;;146:885:23:o;1036:712::-;1142:6;1150;1158;1211:2;1199:9;1190:7;1186:23;1182:32;1179:52;;;1227:1;1224;1217:12;1179:52;1254:16;;-1:-1:-1;;;;;1319:14:23;;;1316:34;;;1346:1;1343;1336:12;1316:34;1369:61;1422:7;1413:6;1402:9;1398:22;1369:61;:::i;:::-;1359:71;;1476:2;1465:9;1461:18;1455:25;1439:41;;1505:2;1495:8;1492:16;1489:36;;;1521:1;1518;1511:12;1489:36;;1544:63;1599:7;1588:8;1577:9;1573:24;1544:63;:::i;:::-;1534:73;;;1650:2;1639:9;1635:18;1629:25;1694:4;1687:5;1683:16;1676:5;1673:27;1663:55;;1714:1;1711;1704:12;1663:55;1737:5;1727:15;;;1036:712;;;;;:::o;1753:380::-;1832:1;1828:12;;;;1875;;;1896:61;;1950:4;1942:6;1938:17;1928:27;;1896:61;2003:2;1995:6;1992:14;1972:18;1969:38;1966:161;;;2049:10;2044:3;2040:20;2037:1;2030:31;2084:4;2081:1;2074:15;2112:4;2109:1;2102:15;1966:161;;1753:380;;;:::o;2267:1104::-;2397:3;2426:1;2459:6;2453:13;2489:3;2511:1;2539:9;2535:2;2531:18;2521:28;;2599:2;2588:9;2584:18;2621;2611:61;;2665:4;2657:6;2653:17;2643:27;;2611:61;2691:2;2739;2731:6;2728:14;2708:18;2705:38;2702:165;;;-1:-1:-1;;;2766:33:23;;2822:4;2819:1;2812:15;2852:4;2773:3;2840:17;2702:165;2883:18;2910:104;;;;3028:1;3023:323;;;;2876:470;;2910:104;-1:-1:-1;;2943:24:23;;2931:37;;2988:16;;;;-1:-1:-1;2910:104:23;;3023:323;2214:1;2207:14;;;2251:4;2238:18;;3121:1;3135:165;3149:6;3146:1;3143:13;3135:165;;;3227:14;;3214:11;;;3207:35;3270:16;;;;3164:10;;3135:165;;;3139:3;;3329:6;3324:3;3320:16;3313:23;;2876:470;-1:-1:-1;3362:3:23;;2267:1104;-1:-1:-1;;;;;;;;2267:1104:23:o;3376:489::-;113:230:22;;;;;;;;;;;;;;;;;;;;;;;;", - "linkReferences": {} - }, - "deployedBytecode": { - "object": "0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806340c10f191161008c57806395d89b411161006657806395d89b41146101d5578063a9059cbb146101dd578063d505accf146101f0578063dd62ed3e1461020357600080fd5b806340c10f191461018057806370a08231146101955780637ecebe00146101b557600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd1461012c578063313ce5671461013f5780633644e51514610178575b600080fd5b6100dc61022e565b6040516100e99190610856565b60405180910390f35b6101056101003660046108c7565b6102bc565b60405190151581526020016100e9565b61011e60025481565b6040519081526020016100e9565b61010561013a3660046108f1565b610328565b6101667f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016100e9565b61011e61041a565b61019361018e3660046108c7565b610475565b005b61011e6101a336600461092d565b60036020526000908152604090205481565b61011e6101c336600461092d565b60056020526000908152604090205481565b6100dc610483565b6101056101eb3660046108c7565b610490565b6101936101fe36600461094f565b610508565b61011e6102113660046109c2565b600460209081526000928352604080842090915290825290205481565b6000805461023b906109f5565b80601f0160208091040260200160405190810160405280929190818152602001828054610267906109f5565b80156102b45780601f10610289576101008083540402835291602001916102b4565b820191906000526020600020905b81548152906001019060200180831161029757829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906103179086815260200190565b60405180910390a350600192915050565b6001600160a01b038316600090815260046020908152604080832033845290915281205460001981146103845761035f8382610a46565b6001600160a01b03861660009081526004602090815260408083203384529091529020555b6001600160a01b038516600090815260036020526040812080548592906103ac908490610a46565b90915550506001600160a01b03808516600081815260036020526040908190208054870190555190918716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906104079087815260200190565b60405180910390a3506001949350505050565b60007f000000000000000000000000000000000000000000000000000000000000000046146104505761044b610751565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b61047f82826107eb565b5050565b6001805461023b906109f5565b336000908152600360205260408120805483919083906104b1908490610a46565b90915550506001600160a01b038316600081815260036020526040908190208054850190555133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906103179086815260200190565b4284101561055d5760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f4558504952454400000000000000000060448201526064015b60405180910390fd5b6000600161056961041a565b6001600160a01b038a811660008181526005602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e08301909152805192019190912061190160f01b6101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015610675573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906106ab5750876001600160a01b0316816001600160a01b0316145b6106e85760405162461bcd60e51b815260206004820152600e60248201526d24a72b20a624a22fa9a4a3a722a960911b6044820152606401610554565b6001600160a01b0390811660009081526004602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516107839190610a5d565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b80600260008282546107fd9190610af9565b90915550506001600160a01b0382166000818152600360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600060208083528351808285015260005b8181101561088357858101830151858201604001528201610867565b81811115610895576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b03811681146108c257600080fd5b919050565b600080604083850312156108da57600080fd5b6108e3836108ab565b946020939093013593505050565b60008060006060848603121561090657600080fd5b61090f846108ab565b925061091d602085016108ab565b9150604084013590509250925092565b60006020828403121561093f57600080fd5b610948826108ab565b9392505050565b600080600080600080600060e0888a03121561096a57600080fd5b610973886108ab565b9650610981602089016108ab565b95506040880135945060608801359350608088013560ff811681146109a557600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156109d557600080fd5b6109de836108ab565b91506109ec602084016108ab565b90509250929050565b600181811c90821680610a0957607f821691505b60208210811415610a2a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015610a5857610a58610a30565b500390565b600080835481600182811c915080831680610a7957607f831692505b6020808410821415610a9957634e487b7160e01b86526022600452602486fd5b818015610aad5760018114610abe57610aeb565b60ff19861689528489019650610aeb565b60008a81526020902060005b86811015610ae35781548b820152908501908301610aca565b505084890196505b509498975050505050505050565b60008219821115610b0c57610b0c610a30565b50019056fea26469706673582212209ca55739676d094f8ef4b3b5cfcc08f600b805843c4c3027beb2b4159a02f63664736f6c634300080a0033", - "sourceMap": "113:230:22:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1028:18:10;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;2458:211;;;;;;:::i;:::-;;:::i;:::-;;;1218:14:23;;1211:22;1193:41;;1181:2;1166:18;2458:211:10;1053:187:23;1301:26:10;;;;;;;;;1391:25:23;;;1379:2;1364:18;1301:26:10;1245:177:23;3054:592:10;;;;;;:::i;:::-;;:::i;1080:31::-;;;;;;;;1932:4:23;1920:17;;;1902:36;;1890:2;1875:18;1080:31:10;1760:184:23;5324:177:10;;;:::i;256:85:22:-;;;;;;:::i;:::-;;:::i;:::-;;1334:44:10;;;;;;:::i;:::-;;;;;;;;;;;;;;1748:41;;;;;;:::i;:::-;;;;;;;;;;;;;;1053:20;;;:::i;2675:373::-;;;;;;:::i;:::-;;:::i;3835:1483::-;;;;;;:::i;:::-;;:::i;1385:64::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;1028:18;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;2458:211::-;2558:10;2532:4;2548:21;;;:9;:21;;;;;;;;-1:-1:-1;;;;;2548:30:10;;;;;;;;;;:39;;;2603:37;2532:4;;2548:30;;2603:37;;;;2581:6;1391:25:23;;1379:2;1364:18;;1245:177;2603:37:10;;;;;;;;-1:-1:-1;2658:4:10;2458:211;;;;:::o;3054:592::-;-1:-1:-1;;;;;3206:15:10;;3172:4;3206:15;;;:9;:15;;;;;;;;3222:10;3206:27;;;;;;;;-1:-1:-1;;3284:28:10;;3280:80;;3344:16;3354:6;3344:7;:16;:::i;:::-;-1:-1:-1;;;;;3314:15:10;;;;;;:9;:15;;;;;;;;3330:10;3314:27;;;;;;;:46;3280:80;-1:-1:-1;;;;;3371:15:10;;;;;;:9;:15;;;;;:25;;3390:6;;3371:15;:25;;3390:6;;3371:25;:::i;:::-;;;;-1:-1:-1;;;;;;;3542:13:10;;;;;;;:9;:13;;;;;;;:23;;;;;;3591:26;3542:13;;3591:26;;;;;;;3559:6;1391:25:23;;1379:2;1364:18;;1245:177;3591:26:10;;;;;;;;-1:-1:-1;3635:4:10;;3054:592;-1:-1:-1;;;;3054:592:10:o;5324:177::-;5381:7;5424:16;5407:13;:33;:87;;5470:24;:22;:24::i;:::-;5400:94;;5324:177;:::o;5407:87::-;-1:-1:-1;5443:24:10;;5324:177::o;256:85:22:-;317:17;323:2;327:6;317:5;:17::i;:::-;256:85;;:::o;1053:20:10:-;;;;;;;:::i;2675:373::-;2771:10;2745:4;2761:21;;;:9;:21;;;;;:31;;2786:6;;2761:21;2745:4;;2761:31;;2786:6;;2761:31;:::i;:::-;;;;-1:-1:-1;;;;;;;2938:13:10;;;;;;:9;:13;;;;;;;:23;;;;;;2987:32;2996:10;;2987:32;;;;2955:6;1391:25:23;;1379:2;1364:18;;1245:177;3835:1483:10;4054:15;4042:8;:27;;4034:63;;;;-1:-1:-1;;;4034:63:10;;4134:2:23;4034:63:10;;;4116:21:23;4173:2;4153:18;;;4146:30;4212:25;4192:18;;;4185:53;4255:18;;4034:63:10;;;;;;;;;4262:24;4289:805;4425:18;:16;:18::i;:::-;-1:-1:-1;;;;;4870:13:10;;;;;;;:6;:13;;;;;;;;;:15;;;;;;;;4508:449;;4552:165;4508:449;;;4571:25:23;4650:18;;;4643:43;;;;4722:15;;;4702:18;;;4695:43;4754:18;;;4747:34;;;4797:19;;;4790:35;;;;4841:19;;;;4834:35;;;4508:449:10;;;;;;;;;;4543:19:23;;;4508:449:10;;;4469:514;;;;;;;;-1:-1:-1;;;4347:658:10;;;5138:27:23;5181:11;;;5174:27;;;;5217:12;;;5210:28;;;;5254:12;;4347:658:10;;;-1:-1:-1;;4347:658:10;;;;;;;;;4316:707;;4347:658;4316:707;;;;4289:805;;;;;;;;;5504:25:23;5577:4;5565:17;;5545:18;;;5538:45;5599:18;;;5592:34;;;5642:18;;;5635:34;;;5476:19;;4289:805:10;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;4289:805:10;;-1:-1:-1;;4289:805:10;;;-1:-1:-1;;;;;;;5117:30:10;;;;;;:59;;;5171:5;-1:-1:-1;;;;;5151:25:10;:16;-1:-1:-1;;;;;5151:25:10;;5117:59;5109:86;;;;-1:-1:-1;;;5109:86:10;;5882:2:23;5109:86:10;;;5864:21:23;5921:2;5901:18;;;5894:30;-1:-1:-1;;;5940:18:23;;;5933:44;5994:18;;5109:86:10;5680:338:23;5109:86:10;-1:-1:-1;;;;;5210:27:10;;;;;;;:9;:27;;;;;;;;:36;;;;;;;;;;;;;:44;;;5280:31;1391:25:23;;;5210:36:10;;5280:31;;;;;1364:18:23;5280:31:10;;;;;;;3835:1483;;;;;;;:::o;5507:446::-;5572:7;5669:95;5802:4;5786:22;;;;;;:::i;:::-;;;;;;;;;;5637:295;;;7520:25:23;;;;7561:18;;7554:34;;;;5830:14:10;7604:18:23;;;7597:34;5866:13:10;7647:18:23;;;7640:34;5909:4:10;7690:19:23;;;7683:61;7492:19;;5637:295:10;;;;;;;;;;;;5610:336;;;;;;5591:355;;5507:446;:::o;6147:325::-;6232:6;6217:11;;:21;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;6384:13:10;;;;;;:9;:13;;;;;;;;:23;;;;;;6433:32;1391:25:23;;;6433:32:10;;1364:18:23;6433:32:10;;;;;;;6147:325;;:::o;14:597:23:-;126:4;155:2;184;173:9;166:21;216:6;210:13;259:6;254:2;243:9;239:18;232:34;284:1;294:140;308:6;305:1;302:13;294:140;;;403:14;;;399:23;;393:30;369:17;;;388:2;365:26;358:66;323:10;;294:140;;;452:6;449:1;446:13;443:91;;;522:1;517:2;508:6;497:9;493:22;489:31;482:42;443:91;-1:-1:-1;595:2:23;574:15;-1:-1:-1;;570:29:23;555:45;;;;602:2;551:54;;14:597;-1:-1:-1;;;14:597:23:o;616:173::-;684:20;;-1:-1:-1;;;;;733:31:23;;723:42;;713:70;;779:1;776;769:12;713:70;616:173;;;:::o;794:254::-;862:6;870;923:2;911:9;902:7;898:23;894:32;891:52;;;939:1;936;929:12;891:52;962:29;981:9;962:29;:::i;:::-;952:39;1038:2;1023:18;;;;1010:32;;-1:-1:-1;;;794:254:23:o;1427:328::-;1504:6;1512;1520;1573:2;1561:9;1552:7;1548:23;1544:32;1541:52;;;1589:1;1586;1579:12;1541:52;1612:29;1631:9;1612:29;:::i;:::-;1602:39;;1660:38;1694:2;1683:9;1679:18;1660:38;:::i;:::-;1650:48;;1745:2;1734:9;1730:18;1717:32;1707:42;;1427:328;;;;;:::o;2131:186::-;2190:6;2243:2;2231:9;2222:7;2218:23;2214:32;2211:52;;;2259:1;2256;2249:12;2211:52;2282:29;2301:9;2282:29;:::i;:::-;2272:39;2131:186;-1:-1:-1;;;2131:186:23:o;2322:693::-;2433:6;2441;2449;2457;2465;2473;2481;2534:3;2522:9;2513:7;2509:23;2505:33;2502:53;;;2551:1;2548;2541:12;2502:53;2574:29;2593:9;2574:29;:::i;:::-;2564:39;;2622:38;2656:2;2645:9;2641:18;2622:38;:::i;:::-;2612:48;;2707:2;2696:9;2692:18;2679:32;2669:42;;2758:2;2747:9;2743:18;2730:32;2720:42;;2812:3;2801:9;2797:19;2784:33;2857:4;2850:5;2846:16;2839:5;2836:27;2826:55;;2877:1;2874;2867:12;2826:55;2322:693;;;;-1:-1:-1;2322:693:23;;;;2900:5;2952:3;2937:19;;2924:33;;-1:-1:-1;3004:3:23;2989:19;;;2976:33;;2322:693;-1:-1:-1;;2322:693:23:o;3020:260::-;3088:6;3096;3149:2;3137:9;3128:7;3124:23;3120:32;3117:52;;;3165:1;3162;3155:12;3117:52;3188:29;3207:9;3188:29;:::i;:::-;3178:39;;3236:38;3270:2;3259:9;3255:18;3236:38;:::i;:::-;3226:48;;3020:260;;;;;:::o;3285:380::-;3364:1;3360:12;;;;3407;;;3428:61;;3482:4;3474:6;3470:17;3460:27;;3428:61;3535:2;3527:6;3524:14;3504:18;3501:38;3498:161;;;3581:10;3576:3;3572:20;3569:1;3562:31;3616:4;3613:1;3606:15;3644:4;3641:1;3634:15;3498:161;;3285:380;;;:::o;3670:127::-;3731:10;3726:3;3722:20;3719:1;3712:31;3762:4;3759:1;3752:15;3786:4;3783:1;3776:15;3802:125;3842:4;3870:1;3867;3864:8;3861:34;;;3875:18;;:::i;:::-;-1:-1:-1;3912:9:23;;3802:125::o;6152:1104::-;6282:3;6311:1;6344:6;6338:13;6374:3;6396:1;6424:9;6420:2;6416:18;6406:28;;6484:2;6473:9;6469:18;6506;6496:61;;6550:4;6542:6;6538:17;6528:27;;6496:61;6576:2;6624;6616:6;6613:14;6593:18;6590:38;6587:165;;;-1:-1:-1;;;6651:33:23;;6707:4;6704:1;6697:15;6737:4;6658:3;6725:17;6587:165;6768:18;6795:104;;;;6913:1;6908:323;;;;6761:470;;6795:104;-1:-1:-1;;6828:24:23;;6816:37;;6873:16;;;;-1:-1:-1;6795:104:23;;6908:323;6099:1;6092:14;;;6136:4;6123:18;;7006:1;7020:165;7034:6;7031:1;7028:13;7020:165;;;7112:14;;7099:11;;;7092:35;7155:16;;;;7049:10;;7020:165;;;7024:3;;7214:6;7209:3;7205:16;7198:23;;6761:470;-1:-1:-1;7247:3:23;;6152:1104;-1:-1:-1;;;;;;;;6152:1104:23:o;7755:128::-;7795:3;7826:1;7822:6;7819:1;7816:13;7813:39;;;7832:18;;:::i;:::-;-1:-1:-1;7868:9:23;;7755:128::o", - "linkReferences": {}, - "immutableReferences": { - "3499": [ - { - "start": 324, - "length": 32 - } - ], - "3513": [ - { - "start": 1054, - "length": 32 - } - ], - "3515": [ - { - "start": 1107, - "length": 32 - } - ] - } - }, - "methodIdentifiers": { - "DOMAIN_SEPARATOR()": "3644e515", - "allowance(address,address)": "dd62ed3e", - "approve(address,uint256)": "095ea7b3", - "balanceOf(address)": "70a08231", - "decimals()": "313ce567", - "mint(address,uint256)": "40c10f19", - "name()": "06fdde03", - "nonces(address)": "7ecebe00", - "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": "d505accf", - "symbol()": "95d89b41", - "totalSupply()": "18160ddd", - "transfer(address,uint256)": "a9059cbb", - "transferFrom(address,address,uint256)": "23b872dd" - } -} +{"abi":[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"bytecode":{"object":"0x60e06040523480156200001157600080fd5b5060405162000f7738038062000f7783398101604081905262000034916200029a565b82828282600090805190602001906200004f92919062000127565b5081516200006590600190602085019062000127565b5060ff81166080524660a0526200007b6200008b565b60c0525062000400945050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6000604051620000bf91906200035c565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b82805462000135906200031f565b90600052602060002090601f016020900481019282620001595760008555620001a4565b82601f106200017457805160ff1916838001178555620001a4565b82800160010185558215620001a4579182015b82811115620001a457825182559160200191906001019062000187565b50620001b2929150620001b6565b5090565b5b80821115620001b25760008155600101620001b7565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f557600080fd5b81516001600160401b0380821115620002125762000212620001cd565b604051601f8301601f19908116603f011681019082821181831017156200023d576200023d620001cd565b816040528381526020925086838588010111156200025a57600080fd5b600091505b838210156200027e57858201830151818301840152908201906200025f565b83821115620002905760008385830101525b9695505050505050565b600080600060608486031215620002b057600080fd5b83516001600160401b0380821115620002c857600080fd5b620002d687838801620001e3565b94506020860151915080821115620002ed57600080fd5b50620002fc86828701620001e3565b925050604084015160ff811681146200031457600080fd5b809150509250925092565b600181811c908216806200033457607f821691505b602082108114156200035657634e487b7160e01b600052602260045260246000fd5b50919050565b600080835481600182811c9150808316806200037957607f831692505b60208084108214156200039a57634e487b7160e01b86526022600452602486fd5b818015620003b15760018114620003c357620003f2565b60ff19861689528489019650620003f2565b60008a81526020902060005b86811015620003ea5781548b820152908501908301620003cf565b505084890196505b509498975050505050505050565b60805160a05160c051610b476200043060003960006104530152600061041e015260006101440152610b476000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c806340c10f191161008c57806395d89b411161006657806395d89b41146101d5578063a9059cbb146101dd578063d505accf146101f0578063dd62ed3e1461020357600080fd5b806340c10f191461018057806370a08231146101955780637ecebe00146101b557600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd1461012c578063313ce5671461013f5780633644e51514610178575b600080fd5b6100dc61022e565b6040516100e99190610856565b60405180910390f35b6101056101003660046108c7565b6102bc565b60405190151581526020016100e9565b61011e60025481565b6040519081526020016100e9565b61010561013a3660046108f1565b610328565b6101667f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016100e9565b61011e61041a565b61019361018e3660046108c7565b610475565b005b61011e6101a336600461092d565b60036020526000908152604090205481565b61011e6101c336600461092d565b60056020526000908152604090205481565b6100dc610483565b6101056101eb3660046108c7565b610490565b6101936101fe36600461094f565b610508565b61011e6102113660046109c2565b600460209081526000928352604080842090915290825290205481565b6000805461023b906109f5565b80601f0160208091040260200160405190810160405280929190818152602001828054610267906109f5565b80156102b45780601f10610289576101008083540402835291602001916102b4565b820191906000526020600020905b81548152906001019060200180831161029757829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906103179086815260200190565b60405180910390a350600192915050565b6001600160a01b038316600090815260046020908152604080832033845290915281205460001981146103845761035f8382610a46565b6001600160a01b03861660009081526004602090815260408083203384529091529020555b6001600160a01b038516600090815260036020526040812080548592906103ac908490610a46565b90915550506001600160a01b03808516600081815260036020526040908190208054870190555190918716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906104079087815260200190565b60405180910390a3506001949350505050565b60007f000000000000000000000000000000000000000000000000000000000000000046146104505761044b610751565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b61047f82826107eb565b5050565b6001805461023b906109f5565b336000908152600360205260408120805483919083906104b1908490610a46565b90915550506001600160a01b038316600081815260036020526040908190208054850190555133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906103179086815260200190565b4284101561055d5760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f4558504952454400000000000000000060448201526064015b60405180910390fd5b6000600161056961041a565b6001600160a01b038a811660008181526005602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e08301909152805192019190912061190160f01b6101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015610675573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906106ab5750876001600160a01b0316816001600160a01b0316145b6106e85760405162461bcd60e51b815260206004820152600e60248201526d24a72b20a624a22fa9a4a3a722a960911b6044820152606401610554565b6001600160a01b0390811660009081526004602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516107839190610a5d565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b80600260008282546107fd9190610af9565b90915550506001600160a01b0382166000818152600360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600060208083528351808285015260005b8181101561088357858101830151858201604001528201610867565b81811115610895576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b03811681146108c257600080fd5b919050565b600080604083850312156108da57600080fd5b6108e3836108ab565b946020939093013593505050565b60008060006060848603121561090657600080fd5b61090f846108ab565b925061091d602085016108ab565b9150604084013590509250925092565b60006020828403121561093f57600080fd5b610948826108ab565b9392505050565b600080600080600080600060e0888a03121561096a57600080fd5b610973886108ab565b9650610981602089016108ab565b95506040880135945060608801359350608088013560ff811681146109a557600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156109d557600080fd5b6109de836108ab565b91506109ec602084016108ab565b90509250929050565b600181811c90821680610a0957607f821691505b60208210811415610a2a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015610a5857610a58610a30565b500390565b600080835481600182811c915080831680610a7957607f831692505b6020808410821415610a9957634e487b7160e01b86526022600452602486fd5b818015610aad5760018114610abe57610aeb565b60ff19861689528489019650610aeb565b60008a81526020902060005b86811015610ae35781548b820152908501908301610aca565b505084890196505b509498975050505050505050565b60008219821115610b0c57610b0c610a30565b50019056fea26469706673582212209ca55739676d094f8ef4b3b5cfcc08f600b805843c4c3027beb2b4159a02f63664736f6c634300080a0033","sourceMap":"113:230:22:-:0;;;148:102;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;224:4;230:6;238:8;2098:5:10;2091:4;:12;;;;;;;;;;;;:::i;:::-;-1:-1:-1;2113:16:10;;;;:6;;:16;;;;;:::i;:::-;-1:-1:-1;2139:20:10;;;;;2189:13;2170:32;;2239:24;:22;:24::i;:::-;2212:51;;-1:-1:-1;113:230:22;;-1:-1:-1;;;;;113:230:22;5507:446:10;5572:7;5669:95;5802:4;5786:22;;;;;;:::i;:::-;;;;;;;;;;5637:295;;;3635:25:23;;;;3676:18;;3669:34;;;;5830:14:10;3719:18:23;;;3712:34;5866:13:10;3762:18:23;;;3755:34;5909:4:10;3805:19:23;;;3798:61;3607:19;;5637:295:10;;;;;;;;;;;;5610:336;;;;;;5591:355;;5507:446;:::o;113:230:22:-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;113:230:22;;;-1:-1:-1;113:230:22;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;14:127:23;75:10;70:3;66:20;63:1;56:31;106:4;103:1;96:15;130:4;127:1;120:15;146:885;200:5;253:3;246:4;238:6;234:17;230:27;220:55;;271:1;268;261:12;220:55;294:13;;-1:-1:-1;;;;;356:10:23;;;353:36;;;369:18;;:::i;:::-;444:2;438:9;412:2;498:13;;-1:-1:-1;;494:22:23;;;518:2;490:31;486:40;474:53;;;542:18;;;562:22;;;539:46;536:72;;;588:18;;:::i;:::-;628:10;624:2;617:22;663:2;655:6;648:18;685:4;675:14;;730:3;725:2;720;712:6;708:15;704:24;701:33;698:53;;;747:1;744;737:12;698:53;769:1;760:10;;779:133;793:2;790:1;787:9;779:133;;;881:14;;;877:23;;871:30;850:14;;;846:23;;839:63;804:10;;;;779:133;;;930:2;927:1;924:9;921:80;;;989:1;984:2;979;971:6;967:15;963:24;956:35;921:80;1019:6;146:885;-1:-1:-1;;;;;;146:885:23:o;1036:712::-;1142:6;1150;1158;1211:2;1199:9;1190:7;1186:23;1182:32;1179:52;;;1227:1;1224;1217:12;1179:52;1254:16;;-1:-1:-1;;;;;1319:14:23;;;1316:34;;;1346:1;1343;1336:12;1316:34;1369:61;1422:7;1413:6;1402:9;1398:22;1369:61;:::i;:::-;1359:71;;1476:2;1465:9;1461:18;1455:25;1439:41;;1505:2;1495:8;1492:16;1489:36;;;1521:1;1518;1511:12;1489:36;;1544:63;1599:7;1588:8;1577:9;1573:24;1544:63;:::i;:::-;1534:73;;;1650:2;1639:9;1635:18;1629:25;1694:4;1687:5;1683:16;1676:5;1673:27;1663:55;;1714:1;1711;1704:12;1663:55;1737:5;1727:15;;;1036:712;;;;;:::o;1753:380::-;1832:1;1828:12;;;;1875;;;1896:61;;1950:4;1942:6;1938:17;1928:27;;1896:61;2003:2;1995:6;1992:14;1972:18;1969:38;1966:161;;;2049:10;2044:3;2040:20;2037:1;2030:31;2084:4;2081:1;2074:15;2112:4;2109:1;2102:15;1966:161;;1753:380;;;:::o;2267:1104::-;2397:3;2426:1;2459:6;2453:13;2489:3;2511:1;2539:9;2535:2;2531:18;2521:28;;2599:2;2588:9;2584:18;2621;2611:61;;2665:4;2657:6;2653:17;2643:27;;2611:61;2691:2;2739;2731:6;2728:14;2708:18;2705:38;2702:165;;;-1:-1:-1;;;2766:33:23;;2822:4;2819:1;2812:15;2852:4;2773:3;2840:17;2702:165;2883:18;2910:104;;;;3028:1;3023:323;;;;2876:470;;2910:104;-1:-1:-1;;2943:24:23;;2931:37;;2988:16;;;;-1:-1:-1;2910:104:23;;3023:323;2214:1;2207:14;;;2251:4;2238:18;;3121:1;3135:165;3149:6;3146:1;3143:13;3135:165;;;3227:14;;3214:11;;;3207:35;3270:16;;;;3164:10;;3135:165;;;3139:3;;3329:6;3324:3;3320:16;3313:23;;2876:470;-1:-1:-1;3362:3:23;;2267:1104;-1:-1:-1;;;;;;;;2267:1104:23:o;3376:489::-;113:230:22;;;;;;;;;;;;;;;;;;;;;;;;","linkReferences":{}},"deployedBytecode":{"object":"0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806340c10f191161008c57806395d89b411161006657806395d89b41146101d5578063a9059cbb146101dd578063d505accf146101f0578063dd62ed3e1461020357600080fd5b806340c10f191461018057806370a08231146101955780637ecebe00146101b557600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd1461012c578063313ce5671461013f5780633644e51514610178575b600080fd5b6100dc61022e565b6040516100e99190610856565b60405180910390f35b6101056101003660046108c7565b6102bc565b60405190151581526020016100e9565b61011e60025481565b6040519081526020016100e9565b61010561013a3660046108f1565b610328565b6101667f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016100e9565b61011e61041a565b61019361018e3660046108c7565b610475565b005b61011e6101a336600461092d565b60036020526000908152604090205481565b61011e6101c336600461092d565b60056020526000908152604090205481565b6100dc610483565b6101056101eb3660046108c7565b610490565b6101936101fe36600461094f565b610508565b61011e6102113660046109c2565b600460209081526000928352604080842090915290825290205481565b6000805461023b906109f5565b80601f0160208091040260200160405190810160405280929190818152602001828054610267906109f5565b80156102b45780601f10610289576101008083540402835291602001916102b4565b820191906000526020600020905b81548152906001019060200180831161029757829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906103179086815260200190565b60405180910390a350600192915050565b6001600160a01b038316600090815260046020908152604080832033845290915281205460001981146103845761035f8382610a46565b6001600160a01b03861660009081526004602090815260408083203384529091529020555b6001600160a01b038516600090815260036020526040812080548592906103ac908490610a46565b90915550506001600160a01b03808516600081815260036020526040908190208054870190555190918716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906104079087815260200190565b60405180910390a3506001949350505050565b60007f000000000000000000000000000000000000000000000000000000000000000046146104505761044b610751565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b61047f82826107eb565b5050565b6001805461023b906109f5565b336000908152600360205260408120805483919083906104b1908490610a46565b90915550506001600160a01b038316600081815260036020526040908190208054850190555133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906103179086815260200190565b4284101561055d5760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f4558504952454400000000000000000060448201526064015b60405180910390fd5b6000600161056961041a565b6001600160a01b038a811660008181526005602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e08301909152805192019190912061190160f01b6101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015610675573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906106ab5750876001600160a01b0316816001600160a01b0316145b6106e85760405162461bcd60e51b815260206004820152600e60248201526d24a72b20a624a22fa9a4a3a722a960911b6044820152606401610554565b6001600160a01b0390811660009081526004602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516107839190610a5d565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b80600260008282546107fd9190610af9565b90915550506001600160a01b0382166000818152600360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600060208083528351808285015260005b8181101561088357858101830151858201604001528201610867565b81811115610895576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b03811681146108c257600080fd5b919050565b600080604083850312156108da57600080fd5b6108e3836108ab565b946020939093013593505050565b60008060006060848603121561090657600080fd5b61090f846108ab565b925061091d602085016108ab565b9150604084013590509250925092565b60006020828403121561093f57600080fd5b610948826108ab565b9392505050565b600080600080600080600060e0888a03121561096a57600080fd5b610973886108ab565b9650610981602089016108ab565b95506040880135945060608801359350608088013560ff811681146109a557600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156109d557600080fd5b6109de836108ab565b91506109ec602084016108ab565b90509250929050565b600181811c90821680610a0957607f821691505b60208210811415610a2a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015610a5857610a58610a30565b500390565b600080835481600182811c915080831680610a7957607f831692505b6020808410821415610a9957634e487b7160e01b86526022600452602486fd5b818015610aad5760018114610abe57610aeb565b60ff19861689528489019650610aeb565b60008a81526020902060005b86811015610ae35781548b820152908501908301610aca565b505084890196505b509498975050505050505050565b60008219821115610b0c57610b0c610a30565b50019056fea26469706673582212209ca55739676d094f8ef4b3b5cfcc08f600b805843c4c3027beb2b4159a02f63664736f6c634300080a0033","sourceMap":"113:230:22:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1028:18:10;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;2458:211;;;;;;:::i;:::-;;:::i;:::-;;;1218:14:23;;1211:22;1193:41;;1181:2;1166:18;2458:211:10;1053:187:23;1301:26:10;;;;;;;;;1391:25:23;;;1379:2;1364:18;1301:26:10;1245:177:23;3054:592:10;;;;;;:::i;:::-;;:::i;1080:31::-;;;;;;;;1932:4:23;1920:17;;;1902:36;;1890:2;1875:18;1080:31:10;1760:184:23;5324:177:10;;;:::i;256:85:22:-;;;;;;:::i;:::-;;:::i;:::-;;1334:44:10;;;;;;:::i;:::-;;;;;;;;;;;;;;1748:41;;;;;;:::i;:::-;;;;;;;;;;;;;;1053:20;;;:::i;2675:373::-;;;;;;:::i;:::-;;:::i;3835:1483::-;;;;;;:::i;:::-;;:::i;1385:64::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;1028:18;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;2458:211::-;2558:10;2532:4;2548:21;;;:9;:21;;;;;;;;-1:-1:-1;;;;;2548:30:10;;;;;;;;;;:39;;;2603:37;2532:4;;2548:30;;2603:37;;;;2581:6;1391:25:23;;1379:2;1364:18;;1245:177;2603:37:10;;;;;;;;-1:-1:-1;2658:4:10;2458:211;;;;:::o;3054:592::-;-1:-1:-1;;;;;3206:15:10;;3172:4;3206:15;;;:9;:15;;;;;;;;3222:10;3206:27;;;;;;;;-1:-1:-1;;3284:28:10;;3280:80;;3344:16;3354:6;3344:7;:16;:::i;:::-;-1:-1:-1;;;;;3314:15:10;;;;;;:9;:15;;;;;;;;3330:10;3314:27;;;;;;;:46;3280:80;-1:-1:-1;;;;;3371:15:10;;;;;;:9;:15;;;;;:25;;3390:6;;3371:15;:25;;3390:6;;3371:25;:::i;:::-;;;;-1:-1:-1;;;;;;;3542:13:10;;;;;;;:9;:13;;;;;;;:23;;;;;;3591:26;3542:13;;3591:26;;;;;;;3559:6;1391:25:23;;1379:2;1364:18;;1245:177;3591:26:10;;;;;;;;-1:-1:-1;3635:4:10;;3054:592;-1:-1:-1;;;;3054:592:10:o;5324:177::-;5381:7;5424:16;5407:13;:33;:87;;5470:24;:22;:24::i;:::-;5400:94;;5324:177;:::o;5407:87::-;-1:-1:-1;5443:24:10;;5324:177::o;256:85:22:-;317:17;323:2;327:6;317:5;:17::i;:::-;256:85;;:::o;1053:20:10:-;;;;;;;:::i;2675:373::-;2771:10;2745:4;2761:21;;;:9;:21;;;;;:31;;2786:6;;2761:21;2745:4;;2761:31;;2786:6;;2761:31;:::i;:::-;;;;-1:-1:-1;;;;;;;2938:13:10;;;;;;:9;:13;;;;;;;:23;;;;;;2987:32;2996:10;;2987:32;;;;2955:6;1391:25:23;;1379:2;1364:18;;1245:177;3835:1483:10;4054:15;4042:8;:27;;4034:63;;;;-1:-1:-1;;;4034:63:10;;4134:2:23;4034:63:10;;;4116:21:23;4173:2;4153:18;;;4146:30;4212:25;4192:18;;;4185:53;4255:18;;4034:63:10;;;;;;;;;4262:24;4289:805;4425:18;:16;:18::i;:::-;-1:-1:-1;;;;;4870:13:10;;;;;;;:6;:13;;;;;;;;;:15;;;;;;;;4508:449;;4552:165;4508:449;;;4571:25:23;4650:18;;;4643:43;;;;4722:15;;;4702:18;;;4695:43;4754:18;;;4747:34;;;4797:19;;;4790:35;;;;4841:19;;;;4834:35;;;4508:449:10;;;;;;;;;;4543:19:23;;;4508:449:10;;;4469:514;;;;;;;;-1:-1:-1;;;4347:658:10;;;5138:27:23;5181:11;;;5174:27;;;;5217:12;;;5210:28;;;;5254:12;;4347:658:10;;;-1:-1:-1;;4347:658:10;;;;;;;;;4316:707;;4347:658;4316:707;;;;4289:805;;;;;;;;;5504:25:23;5577:4;5565:17;;5545:18;;;5538:45;5599:18;;;5592:34;;;5642:18;;;5635:34;;;5476:19;;4289:805:10;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;4289:805:10;;-1:-1:-1;;4289:805:10;;;-1:-1:-1;;;;;;;5117:30:10;;;;;;:59;;;5171:5;-1:-1:-1;;;;;5151:25:10;:16;-1:-1:-1;;;;;5151:25:10;;5117:59;5109:86;;;;-1:-1:-1;;;5109:86:10;;5882:2:23;5109:86:10;;;5864:21:23;5921:2;5901:18;;;5894:30;-1:-1:-1;;;5940:18:23;;;5933:44;5994:18;;5109:86:10;5680:338:23;5109:86:10;-1:-1:-1;;;;;5210:27:10;;;;;;;:9;:27;;;;;;;;:36;;;;;;;;;;;;;:44;;;5280:31;1391:25:23;;;5210:36:10;;5280:31;;;;;1364:18:23;5280:31:10;;;;;;;3835:1483;;;;;;;:::o;5507:446::-;5572:7;5669:95;5802:4;5786:22;;;;;;:::i;:::-;;;;;;;;;;5637:295;;;7520:25:23;;;;7561:18;;7554:34;;;;5830:14:10;7604:18:23;;;7597:34;5866:13:10;7647:18:23;;;7640:34;5909:4:10;7690:19:23;;;7683:61;7492:19;;5637:295:10;;;;;;;;;;;;5610:336;;;;;;5591:355;;5507:446;:::o;6147:325::-;6232:6;6217:11;;:21;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;6384:13:10;;;;;;:9;:13;;;;;;;;:23;;;;;;6433:32;1391:25:23;;;6433:32:10;;1364:18:23;6433:32:10;;;;;;;6147:325;;:::o;14:597:23:-;126:4;155:2;184;173:9;166:21;216:6;210:13;259:6;254:2;243:9;239:18;232:34;284:1;294:140;308:6;305:1;302:13;294:140;;;403:14;;;399:23;;393:30;369:17;;;388:2;365:26;358:66;323:10;;294:140;;;452:6;449:1;446:13;443:91;;;522:1;517:2;508:6;497:9;493:22;489:31;482:42;443:91;-1:-1:-1;595:2:23;574:15;-1:-1:-1;;570:29:23;555:45;;;;602:2;551:54;;14:597;-1:-1:-1;;;14:597:23:o;616:173::-;684:20;;-1:-1:-1;;;;;733:31:23;;723:42;;713:70;;779:1;776;769:12;713:70;616:173;;;:::o;794:254::-;862:6;870;923:2;911:9;902:7;898:23;894:32;891:52;;;939:1;936;929:12;891:52;962:29;981:9;962:29;:::i;:::-;952:39;1038:2;1023:18;;;;1010:32;;-1:-1:-1;;;794:254:23:o;1427:328::-;1504:6;1512;1520;1573:2;1561:9;1552:7;1548:23;1544:32;1541:52;;;1589:1;1586;1579:12;1541:52;1612:29;1631:9;1612:29;:::i;:::-;1602:39;;1660:38;1694:2;1683:9;1679:18;1660:38;:::i;:::-;1650:48;;1745:2;1734:9;1730:18;1717:32;1707:42;;1427:328;;;;;:::o;2131:186::-;2190:6;2243:2;2231:9;2222:7;2218:23;2214:32;2211:52;;;2259:1;2256;2249:12;2211:52;2282:29;2301:9;2282:29;:::i;:::-;2272:39;2131:186;-1:-1:-1;;;2131:186:23:o;2322:693::-;2433:6;2441;2449;2457;2465;2473;2481;2534:3;2522:9;2513:7;2509:23;2505:33;2502:53;;;2551:1;2548;2541:12;2502:53;2574:29;2593:9;2574:29;:::i;:::-;2564:39;;2622:38;2656:2;2645:9;2641:18;2622:38;:::i;:::-;2612:48;;2707:2;2696:9;2692:18;2679:32;2669:42;;2758:2;2747:9;2743:18;2730:32;2720:42;;2812:3;2801:9;2797:19;2784:33;2857:4;2850:5;2846:16;2839:5;2836:27;2826:55;;2877:1;2874;2867:12;2826:55;2322:693;;;;-1:-1:-1;2322:693:23;;;;2900:5;2952:3;2937:19;;2924:33;;-1:-1:-1;3004:3:23;2989:19;;;2976:33;;2322:693;-1:-1:-1;;2322:693:23:o;3020:260::-;3088:6;3096;3149:2;3137:9;3128:7;3124:23;3120:32;3117:52;;;3165:1;3162;3155:12;3117:52;3188:29;3207:9;3188:29;:::i;:::-;3178:39;;3236:38;3270:2;3259:9;3255:18;3236:38;:::i;:::-;3226:48;;3020:260;;;;;:::o;3285:380::-;3364:1;3360:12;;;;3407;;;3428:61;;3482:4;3474:6;3470:17;3460:27;;3428:61;3535:2;3527:6;3524:14;3504:18;3501:38;3498:161;;;3581:10;3576:3;3572:20;3569:1;3562:31;3616:4;3613:1;3606:15;3644:4;3641:1;3634:15;3498:161;;3285:380;;;:::o;3670:127::-;3731:10;3726:3;3722:20;3719:1;3712:31;3762:4;3759:1;3752:15;3786:4;3783:1;3776:15;3802:125;3842:4;3870:1;3867;3864:8;3861:34;;;3875:18;;:::i;:::-;-1:-1:-1;3912:9:23;;3802:125::o;6152:1104::-;6282:3;6311:1;6344:6;6338:13;6374:3;6396:1;6424:9;6420:2;6416:18;6406:28;;6484:2;6473:9;6469:18;6506;6496:61;;6550:4;6542:6;6538:17;6528:27;;6496:61;6576:2;6624;6616:6;6613:14;6593:18;6590:38;6587:165;;;-1:-1:-1;;;6651:33:23;;6707:4;6704:1;6697:15;6737:4;6658:3;6725:17;6587:165;6768:18;6795:104;;;;6913:1;6908:323;;;;6761:470;;6795:104;-1:-1:-1;;6828:24:23;;6816:37;;6873:16;;;;-1:-1:-1;6795:104:23;;6908:323;6099:1;6092:14;;;6136:4;6123:18;;7006:1;7020:165;7034:6;7031:1;7028:13;7020:165;;;7112:14;;7099:11;;;7092:35;7155:16;;;;7049:10;;7020:165;;;7024:3;;7214:6;7209:3;7205:16;7198:23;;6761:470;-1:-1:-1;7247:3:23;;6152:1104;-1:-1:-1;;;;;;;;6152:1104:23:o;7755:128::-;7795:3;7826:1;7822:6;7819:1;7816:13;7813:39;;;7832:18;;:::i;:::-;-1:-1:-1;7868:9:23;;7755:128::o","linkReferences":{},"immutableReferences":{"3499":[{"start":324,"length":32}],"3513":[{"start":1054,"length":32}],"3515":[{"start":1107,"length":32}]}},"methodIdentifiers":{"DOMAIN_SEPARATOR()":"3644e515","allowance(address,address)":"dd62ed3e","approve(address,uint256)":"095ea7b3","balanceOf(address)":"70a08231","decimals()":"313ce567","mint(address,uint256)":"40c10f19","name()":"06fdde03","nonces(address)":"7ecebe00","permit(address,address,uint256,uint256,uint8,bytes32,bytes32)":"d505accf","symbol()":"95d89b41","totalSupply()":"18160ddd","transfer(address,uint256)":"a9059cbb","transferFrom(address,address,uint256)":"23b872dd"}} \ No newline at end of file diff --git a/crates/cast/tests/fixtures/interface.json b/crates/cast/tests/fixtures/interface.json index 73e561886a968..26163abeec0d9 100644 --- a/crates/cast/tests/fixtures/interface.json +++ b/crates/cast/tests/fixtures/interface.json @@ -1,141 +1 @@ -[ - { - "type": "constructor", - "inputs": [ - { - "name": "_integrationManager", - "type": "address", - "internalType": "address" - }, - { - "name": "_addressListRegistry", - "type": "address", - "internalType": "address" - }, - { - "name": "_aTokenListId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_pool", - "type": "address", - "internalType": "address" - }, - { - "name": "_referralCode", - "type": "uint16", - "internalType": "uint16" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "getIntegrationManager", - "inputs": [], - "outputs": [ - { - "name": "integrationManager_", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "lend", - "inputs": [ - { - "name": "_vaultProxy", - "type": "address", - "internalType": "address" - }, - { - "name": "", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "_assetData", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "parseAssetsForAction", - "inputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - }, - { - "name": "_selector", - "type": "bytes4", - "internalType": "bytes4" - }, - { - "name": "_actionData", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [ - { - "name": "spendAssetsHandleType_", - "type": "uint8", - "internalType": "enum IIntegrationManager.SpendAssetsHandleType" - }, - { - "name": "spendAssets_", - "type": "address[]", - "internalType": "address[]" - }, - { - "name": "spendAssetAmounts_", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "incomingAssets_", - "type": "address[]", - "internalType": "address[]" - }, - { - "name": "minIncomingAssetAmounts_", - "type": "uint256[]", - "internalType": "uint256[]" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "redeem", - "inputs": [ - { - "name": "_vaultProxy", - "type": "address", - "internalType": "address" - }, - { - "name": "", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "_assetData", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - } -] \ No newline at end of file +[{"type":"constructor","inputs":[{"name":"_integrationManager","type":"address","internalType":"address"},{"name":"_addressListRegistry","type":"address","internalType":"address"},{"name":"_aTokenListId","type":"uint256","internalType":"uint256"},{"name":"_pool","type":"address","internalType":"address"},{"name":"_referralCode","type":"uint16","internalType":"uint16"}],"stateMutability":"nonpayable"},{"type":"function","name":"getIntegrationManager","inputs":[],"outputs":[{"name":"integrationManager_","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"lend","inputs":[{"name":"_vaultProxy","type":"address","internalType":"address"},{"name":"","type":"bytes","internalType":"bytes"},{"name":"_assetData","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"parseAssetsForAction","inputs":[{"name":"","type":"address","internalType":"address"},{"name":"_selector","type":"bytes4","internalType":"bytes4"},{"name":"_actionData","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"spendAssetsHandleType_","type":"uint8","internalType":"enum IIntegrationManager.SpendAssetsHandleType"},{"name":"spendAssets_","type":"address[]","internalType":"address[]"},{"name":"spendAssetAmounts_","type":"uint256[]","internalType":"uint256[]"},{"name":"incomingAssets_","type":"address[]","internalType":"address[]"},{"name":"minIncomingAssetAmounts_","type":"uint256[]","internalType":"uint256[]"}],"stateMutability":"view"},{"type":"function","name":"redeem","inputs":[{"name":"_vaultProxy","type":"address","internalType":"address"},{"name":"","type":"bytes","internalType":"bytes"},{"name":"_assetData","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"}] \ No newline at end of file diff --git a/crates/cast/tests/fixtures/sign_typed_data.json b/crates/cast/tests/fixtures/sign_typed_data.json index a6002810a6ee5..8dc45f2e74097 100644 --- a/crates/cast/tests/fixtures/sign_typed_data.json +++ b/crates/cast/tests/fixtures/sign_typed_data.json @@ -1,38 +1 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - }, - { - "name": "verifyingContract", - "type": "address" - } - ], - "Message": [ - { - "name": "data", - "type": "string" - } - ] - }, - "primaryType": "Message", - "domain": { - "name": "example.metamask.io", - "version": "1", - "chainId": "1", - "verifyingContract": "0x0000000000000000000000000000000000000000" - }, - "message": { - "data": "Hello!" - } -} \ No newline at end of file +{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Message":[{"name":"data","type":"string"}]},"primaryType":"Message","domain":{"name":"example.metamask.io","version":"1","chainId":"1","verifyingContract":"0x0000000000000000000000000000000000000000"},"message":{"data":"Hello!"}} \ No newline at end of file diff --git a/crates/evm/core/src/abi/HardhatConsole.json b/crates/evm/core/src/abi/HardhatConsole.json index c1b1b46cf4fb4..4013d875357ea 100644 --- a/crates/evm/core/src/abi/HardhatConsole.json +++ b/crates/evm/core/src/abi/HardhatConsole.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"}],"name":"logAddress","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"}],"name":"logBool","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"p0","type":"bytes"}],"name":"logBytes","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes1","name":"p0","type":"bytes1"}],"name":"logBytes1","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes10","name":"p0","type":"bytes10"}],"name":"logBytes10","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes11","name":"p0","type":"bytes11"}],"name":"logBytes11","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes12","name":"p0","type":"bytes12"}],"name":"logBytes12","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes13","name":"p0","type":"bytes13"}],"name":"logBytes13","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes14","name":"p0","type":"bytes14"}],"name":"logBytes14","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes15","name":"p0","type":"bytes15"}],"name":"logBytes15","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16","name":"p0","type":"bytes16"}],"name":"logBytes16","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes17","name":"p0","type":"bytes17"}],"name":"logBytes17","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes18","name":"p0","type":"bytes18"}],"name":"logBytes18","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes19","name":"p0","type":"bytes19"}],"name":"logBytes19","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes2","name":"p0","type":"bytes2"}],"name":"logBytes2","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes20","name":"p0","type":"bytes20"}],"name":"logBytes20","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes21","name":"p0","type":"bytes21"}],"name":"logBytes21","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes22","name":"p0","type":"bytes22"}],"name":"logBytes22","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes23","name":"p0","type":"bytes23"}],"name":"logBytes23","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes24","name":"p0","type":"bytes24"}],"name":"logBytes24","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes25","name":"p0","type":"bytes25"}],"name":"logBytes25","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes26","name":"p0","type":"bytes26"}],"name":"logBytes26","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes27","name":"p0","type":"bytes27"}],"name":"logBytes27","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes28","name":"p0","type":"bytes28"}],"name":"logBytes28","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes29","name":"p0","type":"bytes29"}],"name":"logBytes29","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes3","name":"p0","type":"bytes3"}],"name":"logBytes3","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes30","name":"p0","type":"bytes30"}],"name":"logBytes30","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes31","name":"p0","type":"bytes31"}],"name":"logBytes31","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"p0","type":"bytes32"}],"name":"logBytes32","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"p0","type":"bytes4"}],"name":"logBytes4","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes5","name":"p0","type":"bytes5"}],"name":"logBytes5","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes6","name":"p0","type":"bytes6"}],"name":"logBytes6","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes7","name":"p0","type":"bytes7"}],"name":"logBytes7","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes8","name":"p0","type":"bytes8"}],"name":"logBytes8","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes9","name":"p0","type":"bytes9"}],"name":"logBytes9","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"p0","type":"int256"}],"name":"logInt","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"}],"name":"logString","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"}],"name":"logUint","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"p0","type":"int256"}],"outputs":[],"stateMutability":"view","type":"function","name":"log"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"int256","name":"p1","type":"int256"}],"outputs":[],"stateMutability":"view","type":"function","name":"log"}] +[{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"}],"name":"logAddress","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"}],"name":"logBool","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"p0","type":"bytes"}],"name":"logBytes","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes1","name":"p0","type":"bytes1"}],"name":"logBytes1","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes10","name":"p0","type":"bytes10"}],"name":"logBytes10","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes11","name":"p0","type":"bytes11"}],"name":"logBytes11","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes12","name":"p0","type":"bytes12"}],"name":"logBytes12","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes13","name":"p0","type":"bytes13"}],"name":"logBytes13","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes14","name":"p0","type":"bytes14"}],"name":"logBytes14","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes15","name":"p0","type":"bytes15"}],"name":"logBytes15","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16","name":"p0","type":"bytes16"}],"name":"logBytes16","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes17","name":"p0","type":"bytes17"}],"name":"logBytes17","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes18","name":"p0","type":"bytes18"}],"name":"logBytes18","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes19","name":"p0","type":"bytes19"}],"name":"logBytes19","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes2","name":"p0","type":"bytes2"}],"name":"logBytes2","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes20","name":"p0","type":"bytes20"}],"name":"logBytes20","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes21","name":"p0","type":"bytes21"}],"name":"logBytes21","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes22","name":"p0","type":"bytes22"}],"name":"logBytes22","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes23","name":"p0","type":"bytes23"}],"name":"logBytes23","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes24","name":"p0","type":"bytes24"}],"name":"logBytes24","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes25","name":"p0","type":"bytes25"}],"name":"logBytes25","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes26","name":"p0","type":"bytes26"}],"name":"logBytes26","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes27","name":"p0","type":"bytes27"}],"name":"logBytes27","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes28","name":"p0","type":"bytes28"}],"name":"logBytes28","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes29","name":"p0","type":"bytes29"}],"name":"logBytes29","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes3","name":"p0","type":"bytes3"}],"name":"logBytes3","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes30","name":"p0","type":"bytes30"}],"name":"logBytes30","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes31","name":"p0","type":"bytes31"}],"name":"logBytes31","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"p0","type":"bytes32"}],"name":"logBytes32","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"p0","type":"bytes4"}],"name":"logBytes4","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes5","name":"p0","type":"bytes5"}],"name":"logBytes5","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes6","name":"p0","type":"bytes6"}],"name":"logBytes6","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes7","name":"p0","type":"bytes7"}],"name":"logBytes7","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes8","name":"p0","type":"bytes8"}],"name":"logBytes8","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes9","name":"p0","type":"bytes9"}],"name":"logBytes9","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"p0","type":"int256"}],"name":"logInt","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"}],"name":"logString","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"}],"name":"logUint","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"p0","type":"int256"}],"outputs":[],"stateMutability":"view","type":"function","name":"log"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"int256","name":"p1","type":"int256"}],"outputs":[],"stateMutability":"view","type":"function","name":"log"}] \ No newline at end of file diff --git a/crates/evm/core/test-data/storage.json b/crates/evm/core/test-data/storage.json index 4f25625919b23..6a602f7a642ab 100644 --- a/crates/evm/core/test-data/storage.json +++ b/crates/evm/core/test-data/storage.json @@ -1 +1 @@ -{"meta":{"cfg_env":{"chain_id":1,"spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295, "perf_analyse_created_bytecodes":"Analyse", "limit_contract_code_size": 24576, "disable_coinbase_tip": false},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} \ No newline at end of file +{"meta":{"cfg_env":{"chain_id":1,"spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295,"perf_analyse_created_bytecodes":"Analyse","limit_contract_code_size":24576,"disable_coinbase_tip":false},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} \ No newline at end of file diff --git a/testdata/default/script/broadcast/deploy.sol/31337/run-latest.json b/testdata/default/script/broadcast/deploy.sol/31337/run-latest.json index 9a05e1cb7ac2f..1a8bccb392489 100644 --- a/testdata/default/script/broadcast/deploy.sol/31337/run-latest.json +++ b/testdata/default/script/broadcast/deploy.sol/31337/run-latest.json @@ -1,63 +1 @@ -{ - "transactions": [ - { - "hash": null, - "type": "CREATE", - "contractName": null, - "contractAddress": "0x731a10897d267e19b34503ad902d0a29173ba4b1", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x00a329c0648769a73afac7f9381e08fb43dbea72", - "gas": "0x54653", - "value": "0x0", - "data": "0x608060405234801561001057600080fd5b506103d9806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063d5dcf1271461003b578063f8194e4814610050575b600080fd5b61004e6100493660046100e9565b600155565b005b61006361005e366004610118565b610079565b60405161007091906101f9565b60405180910390f35b6060600061008783826102b5565b5060008260405160200161009b9190610375565b60405160208183030381529060405290507fefdeaaf566f7751d16a12c7fa8909eb74120f42cba334d07dd5246c48f1fba81816040516100db91906101f9565b60405180910390a192915050565b6000602082840312156100fb57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561012a57600080fd5b813567ffffffffffffffff8082111561014257600080fd5b818401915084601f83011261015657600080fd5b81358181111561016857610168610102565b604051601f8201601f19908116603f0116810190838211818310171561019057610190610102565b816040528281528760208487010111156101a957600080fd5b826020860160208301376000928101602001929092525095945050505050565b60005b838110156101e45781810151838201526020016101cc565b838111156101f3576000848401525b50505050565b60208152600082518060208401526102188160408501602087016101c9565b601f01601f19169190910160400192915050565b600181811c9082168061024057607f821691505b60208210810361026057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156102b057600081815260208120601f850160051c8101602086101561028d5750805b601f850160051c820191505b818110156102ac57828155600101610299565b5050505b505050565b815167ffffffffffffffff8111156102cf576102cf610102565b6102e3816102dd845461022c565b84610266565b602080601f83116001811461031857600084156103005750858301515b600019600386901b1c1916600185901b1785556102ac565b600085815260208120601f198616915b8281101561034757888601518255948401946001909101908401610328565b50858210156103655787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6502432b63637960d51b8152600082516103968160068501602087016101c9565b919091016006019291505056fea2646970667358221220a380cb042b6ca762a5a0f97e497c4cffa21c45dc21e2dab4107e5415921a704a64736f6c634300080f0033", - "nonce": "0x0", - "accessList": [] - } - }, - { - "hash": null, - "type": "CALL", - "contractName": null, - "contractAddress": "0x731a10897d267e19b34503ad902d0a29173ba4b1", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x00a329c0648769a73afac7f9381e08fb43dbea72", - "to": "0x731a10897d267e19b34503ad902d0a29173ba4b1", - "gas": "0xef15", - "value": "0x0", - "data": "0xf8194e48000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046a6f686e00000000000000000000000000000000000000000000000000000000", - "nonce": "0x1", - "accessList": [] - } - }, - { - "hash": null, - "type": "CALL", - "contractName": null, - "contractAddress": "0x731a10897d267e19b34503ad902d0a29173ba4b1", - "function": null, - "arguments": null, - "transaction": { - "type": "0x02", - "from": "0x00a329c0648769a73afac7f9381e08fb43dbea72", - "to": "0x731a10897d267e19b34503ad902d0a29173ba4b1", - "gas": "0xdcde", - "value": "0x0", - "data": "0xd5dcf127000000000000000000000000000000000000000000000000000000000000007b", - "nonce": "0x2", - "accessList": [] - } - } - ], - "receipts": [], - "libraries": [], - "pending": [], - "path": "broadcast/deploy.sol/31337/run-latest.json", - "returns": {}, - "timestamp": 1658913881 -} \ No newline at end of file +{"transactions":[{"hash":null,"type":"CREATE","contractName":null,"contractAddress":"0x731a10897d267e19b34503ad902d0a29173ba4b1","function":null,"arguments":null,"transaction":{"type":"0x02","from":"0x00a329c0648769a73afac7f9381e08fb43dbea72","gas":"0x54653","value":"0x0","data":"0x608060405234801561001057600080fd5b506103d9806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063d5dcf1271461003b578063f8194e4814610050575b600080fd5b61004e6100493660046100e9565b600155565b005b61006361005e366004610118565b610079565b60405161007091906101f9565b60405180910390f35b6060600061008783826102b5565b5060008260405160200161009b9190610375565b60405160208183030381529060405290507fefdeaaf566f7751d16a12c7fa8909eb74120f42cba334d07dd5246c48f1fba81816040516100db91906101f9565b60405180910390a192915050565b6000602082840312156100fb57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561012a57600080fd5b813567ffffffffffffffff8082111561014257600080fd5b818401915084601f83011261015657600080fd5b81358181111561016857610168610102565b604051601f8201601f19908116603f0116810190838211818310171561019057610190610102565b816040528281528760208487010111156101a957600080fd5b826020860160208301376000928101602001929092525095945050505050565b60005b838110156101e45781810151838201526020016101cc565b838111156101f3576000848401525b50505050565b60208152600082518060208401526102188160408501602087016101c9565b601f01601f19169190910160400192915050565b600181811c9082168061024057607f821691505b60208210810361026057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156102b057600081815260208120601f850160051c8101602086101561028d5750805b601f850160051c820191505b818110156102ac57828155600101610299565b5050505b505050565b815167ffffffffffffffff8111156102cf576102cf610102565b6102e3816102dd845461022c565b84610266565b602080601f83116001811461031857600084156103005750858301515b600019600386901b1c1916600185901b1785556102ac565b600085815260208120601f198616915b8281101561034757888601518255948401946001909101908401610328565b50858210156103655787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6502432b63637960d51b8152600082516103968160068501602087016101c9565b919091016006019291505056fea2646970667358221220a380cb042b6ca762a5a0f97e497c4cffa21c45dc21e2dab4107e5415921a704a64736f6c634300080f0033","nonce":"0x0","accessList":[]}},{"hash":null,"type":"CALL","contractName":null,"contractAddress":"0x731a10897d267e19b34503ad902d0a29173ba4b1","function":null,"arguments":null,"transaction":{"type":"0x02","from":"0x00a329c0648769a73afac7f9381e08fb43dbea72","to":"0x731a10897d267e19b34503ad902d0a29173ba4b1","gas":"0xef15","value":"0x0","data":"0xf8194e48000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046a6f686e00000000000000000000000000000000000000000000000000000000","nonce":"0x1","accessList":[]}},{"hash":null,"type":"CALL","contractName":null,"contractAddress":"0x731a10897d267e19b34503ad902d0a29173ba4b1","function":null,"arguments":null,"transaction":{"type":"0x02","from":"0x00a329c0648769a73afac7f9381e08fb43dbea72","to":"0x731a10897d267e19b34503ad902d0a29173ba4b1","gas":"0xdcde","value":"0x0","data":"0xd5dcf127000000000000000000000000000000000000000000000000000000000000007b","nonce":"0x2","accessList":[]}}],"receipts":[],"libraries":[],"pending":[],"path":"broadcast/deploy.sol/31337/run-latest.json","returns":{},"timestamp":1658913881} \ No newline at end of file diff --git a/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json index d709187b8b9b8..899a44c1514b7 100644 --- a/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json +++ b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json @@ -1,5 +1 @@ -{ - "contractAddress": "0x044b75f554b886a065b9567891e45c79542d7357", - "contractCreator": "0xf87bc5535602077d340806d71f805ea9907a843d", - "txHash": "0x9a89d2f5528bf07661e92f3f78a3311396f11f15da19e3ec4d880be1ad1a4bec" -} \ No newline at end of file +{"contractAddress":"0x044b75f554b886a065b9567891e45c79542d7357","contractCreator":"0xf87bc5535602077d340806d71f805ea9907a843d","txHash":"0x9a89d2f5528bf07661e92f3f78a3311396f11f15da19e3ec4d880be1ad1a4bec"} \ No newline at end of file diff --git a/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json index 12f7f6a3bfcb7..54aec7d6a61f2 100644 --- a/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json +++ b/testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/metadata.json @@ -1,78 +1 @@ -[ - { - "SourceCode": { - "language": "Solidity", - "sources": { - "contracts/InputStream.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity 0.8.10;\n\nlibrary InputStream {\n function createStream(bytes memory data) internal pure returns (uint256 stream) {\n assembly {\n stream := mload(0x40)\n mstore(0x40, add(stream, 64))\n mstore(stream, data)\n let length := mload(data)\n mstore(add(stream, 32), add(data, length))\n }\n }\n\n function isNotEmpty(uint256 stream) internal pure returns (bool) {\n uint256 pos;\n uint256 finish;\n assembly {\n pos := mload(stream)\n finish := mload(add(stream, 32))\n }\n return pos < finish;\n }\n\n function readUint8(uint256 stream) internal pure returns (uint8 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 1)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint16(uint256 stream) internal pure returns (uint16 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 2)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint32(uint256 stream) internal pure returns (uint32 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 4)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint(uint256 stream) internal pure returns (uint256 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 32)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readAddress(uint256 stream) internal pure returns (address res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 20)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readBytes(uint256 stream) internal pure returns (bytes memory res) {\n assembly {\n let pos := mload(stream)\n res := add(pos, 32)\n let length := mload(res)\n mstore(stream, add(res, length))\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "interfaces/IBentoBoxMinimal.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity >=0.8.0;\n\nstruct Rebase {\n uint128 elastic;\n uint128 base;\n}\n\nstruct StrategyData {\n uint64 strategyStartDate;\n uint64 targetPercentage;\n uint128 balance; // the balance of the strategy that BentoBox thinks is in there\n}\n\n/// @notice A rebasing library\nlibrary RebaseLibrary {\n /// @notice Calculates the base value in relationship to `elastic` and `total`.\n function toBase(Rebase memory total, uint256 elastic) internal pure returns (uint256 base) {\n if (total.elastic == 0) {\n base = elastic;\n } else {\n base = (elastic * total.base) / total.elastic;\n }\n }\n\n /// @notice Calculates the elastic value in relationship to `base` and `total`.\n function toElastic(Rebase memory total, uint256 base) internal pure returns (uint256 elastic) {\n if (total.base == 0) {\n elastic = base;\n } else {\n elastic = (base * total.elastic) / total.base;\n }\n }\n}\n\n/// @notice Minimal BentoBox vault interface.\n/// @dev `token` is aliased as `address` from `IERC20` for simplicity.\ninterface IBentoBoxMinimal {\n /// @notice Balance per ERC-20 token per account in shares.\n function balanceOf(address, address) external view returns (uint256);\n\n /// @dev Helper function to represent an `amount` of `token` in shares.\n /// @param token The ERC-20 token.\n /// @param amount The `token` amount.\n /// @param roundUp If the result `share` should be rounded up.\n /// @return share The token amount represented in shares.\n function toShare(\n address token,\n uint256 amount,\n bool roundUp\n ) external view returns (uint256 share);\n\n /// @dev Helper function to represent shares back into the `token` amount.\n /// @param token The ERC-20 token.\n /// @param share The amount of shares.\n /// @param roundUp If the result should be rounded up.\n /// @return amount The share amount back into native representation.\n function toAmount(\n address token,\n uint256 share,\n bool roundUp\n ) external view returns (uint256 amount);\n\n /// @notice Registers this contract so that users can approve it for BentoBox.\n function registerProtocol() external;\n\n /// @notice Deposit an amount of `token` represented in either `amount` or `share`.\n /// @param token The ERC-20 token to deposit.\n /// @param from which account to pull the tokens.\n /// @param to which account to push the tokens.\n /// @param amount Token amount in native representation to deposit.\n /// @param share Token amount represented in shares to deposit. Takes precedence over `amount`.\n /// @return amountOut The amount deposited.\n /// @return shareOut The deposited amount represented in shares.\n function deposit(\n address token,\n address from,\n address to,\n uint256 amount,\n uint256 share\n ) external payable returns (uint256 amountOut, uint256 shareOut);\n\n /// @notice Withdraws an amount of `token` from a user account.\n /// @param token_ The ERC-20 token to withdraw.\n /// @param from which user to pull the tokens.\n /// @param to which user to push the tokens.\n /// @param amount of tokens. Either one of `amount` or `share` needs to be supplied.\n /// @param share Like above, but `share` takes precedence over `amount`.\n function withdraw(\n address token_,\n address from,\n address to,\n uint256 amount,\n uint256 share\n ) external returns (uint256 amountOut, uint256 shareOut);\n\n /// @notice Transfer shares from a user account to another one.\n /// @param token The ERC-20 token to transfer.\n /// @param from which user to pull the tokens.\n /// @param to which user to push the tokens.\n /// @param share The amount of `token` in shares.\n function transfer(\n address token,\n address from,\n address to,\n uint256 share\n ) external;\n\n /// @dev Reads the Rebase `totals`from storage for a given token\n function totals(address token) external view returns (Rebase memory total);\n\n function strategyData(address token) external view returns (StrategyData memory total);\n\n /// @dev Approves users' BentoBox assets to a \"master\" contract.\n function setMasterContractApproval(\n address user,\n address masterContract,\n bool approved,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n function harvest(\n address token,\n bool balance,\n uint256 maxChangeAmount\n ) external;\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "interfaces/IPool.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity >=0.5.0;\npragma experimental ABIEncoderV2;\n\n/// @notice Trident pool interface.\ninterface IPool {\n /// @notice Executes a swap from one token to another.\n /// @dev The input tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that were sent to the user.\n function swap(bytes calldata data) external returns (uint256 finalAmountOut);\n\n /// @notice Executes a swap from one token to another with a callback.\n /// @dev This function allows borrowing the output tokens and sending the input tokens in the callback.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that were sent to the user.\n function flashSwap(bytes calldata data) external returns (uint256 finalAmountOut);\n\n /// @notice Mints liquidity tokens.\n /// @param data ABI-encoded params that the pool requires.\n /// @return liquidity The amount of liquidity tokens that were minted for the user.\n function mint(bytes calldata data) external returns (uint256 liquidity);\n\n /// @notice Burns liquidity tokens.\n /// @dev The input LP tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return withdrawnAmounts The amount of various output tokens that were sent to the user.\n function burn(bytes calldata data) external returns (TokenAmount[] memory withdrawnAmounts);\n\n /// @notice Burns liquidity tokens for a single output token.\n /// @dev The input LP tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return amountOut The amount of output tokens that were sent to the user.\n function burnSingle(bytes calldata data) external returns (uint256 amountOut);\n\n /// @return A unique identifier for the pool type.\n function poolIdentifier() external pure returns (bytes32);\n\n /// @return An array of tokens supported by the pool.\n function getAssets() external view returns (address[] memory);\n\n /// @notice Simulates a trade and returns the expected output.\n /// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that will be sent to the user if the trade is executed.\n function getAmountOut(bytes calldata data) external view returns (uint256 finalAmountOut);\n\n /// @notice Simulates a trade and returns the expected output.\n /// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountIn The amount of input tokens that are required from the user if the trade is executed.\n function getAmountIn(bytes calldata data) external view returns (uint256 finalAmountIn);\n\n /// @dev This event must be emitted on all swaps.\n event Swap(address indexed recipient, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut);\n\n /// @dev This struct frames output tokens for burns.\n struct TokenAmount {\n address token;\n uint256 amount;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "contracts/RouteProcessor2.sol": { - "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity 0.8.10;\n\nimport '../interfaces/IUniswapV2Pair.sol';\nimport '../interfaces/IUniswapV3Pool.sol';\nimport '../interfaces/ITridentCLPool.sol';\nimport '../interfaces/IBentoBoxMinimal.sol';\nimport '../interfaces/IPool.sol';\nimport '../interfaces/IWETH.sol';\nimport './InputStream.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\naddress constant NATIVE_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\naddress constant IMPOSSIBLE_POOL_ADDRESS = 0x0000000000000000000000000000000000000001;\n\n/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\nuint160 constant MIN_SQRT_RATIO = 4295128739;\n/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\nuint160 constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n/// @title A route processor for the Sushi Aggregator\n/// @author Ilya Lyalin\ncontract RouteProcessor2 {\n using SafeERC20 for IERC20;\n using InputStream for uint256;\n\n IBentoBoxMinimal public immutable bentoBox;\n address private lastCalledPool;\n\n uint private unlocked = 1;\n modifier lock() {\n require(unlocked == 1, 'RouteProcessor is locked');\n unlocked = 2;\n _;\n unlocked = 1;\n }\n\n constructor(address _bentoBox) {\n bentoBox = IBentoBoxMinimal(_bentoBox);\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n }\n\n /// @notice For native unwrapping\n receive() external payable {}\n\n /// @notice Processes the route generated off-chain. Has a lock\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function processRoute(\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) external payable lock returns (uint256 amountOut) {\n return processRouteInternal(tokenIn, amountIn, tokenOut, amountOutMin, to, route);\n }\n\n /// @notice Transfers some value to and then processes the route\n /// @param transferValueTo Address where the value should be transferred\n /// @param amountValueTransfer How much value to transfer\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function transferValueAndprocessRoute(\n address payable transferValueTo,\n uint256 amountValueTransfer,\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) external payable lock returns (uint256 amountOut) {\n (bool success, bytes memory returnBytes) = transferValueTo.call{value: amountValueTransfer}('');\n require(success, string(abi.encodePacked(returnBytes)));\n return processRouteInternal(tokenIn, amountIn, tokenOut, amountOutMin, to, route);\n }\n\n /// @notice Processes the route generated off-chain\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function processRouteInternal(\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) private returns (uint256 amountOut) {\n uint256 balanceInInitial = tokenIn == NATIVE_ADDRESS ? address(this).balance : IERC20(tokenIn).balanceOf(msg.sender);\n uint256 balanceOutInitial = tokenOut == NATIVE_ADDRESS ? address(to).balance : IERC20(tokenOut).balanceOf(to);\n\n uint256 stream = InputStream.createStream(route);\n while (stream.isNotEmpty()) {\n uint8 commandCode = stream.readUint8();\n if (commandCode == 1) processMyERC20(stream);\n else if (commandCode == 2) processUserERC20(stream, amountIn);\n else if (commandCode == 3) processNative(stream);\n else if (commandCode == 4) processOnePool(stream);\n else if (commandCode == 5) processInsideBento(stream);\n else revert('RouteProcessor: Unknown command code');\n }\n\n uint256 balanceInFinal = tokenIn == NATIVE_ADDRESS ? address(this).balance : IERC20(tokenIn).balanceOf(msg.sender);\n require(balanceInFinal + amountIn >= balanceInInitial, 'RouteProcessor: Minimal imput balance violation');\n\n uint256 balanceOutFinal = tokenOut == NATIVE_ADDRESS ? address(to).balance : IERC20(tokenOut).balanceOf(to);\n require(balanceOutFinal >= balanceOutInitial + amountOutMin, 'RouteProcessor: Minimal ouput balance violation');\n\n amountOut = balanceOutFinal - balanceOutInitial;\n }\n\n /// @notice Processes native coin: call swap for all pools that swap from native coin\n /// @param stream Streamed process program\n function processNative(uint256 stream) private {\n uint256 amountTotal = address(this).balance;\n distributeAndSwap(stream, address(this), NATIVE_ADDRESS, amountTotal);\n }\n\n /// @notice Processes ERC20 token from this contract balance:\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processMyERC20(uint256 stream) private {\n address token = stream.readAddress();\n uint256 amountTotal = IERC20(token).balanceOf(address(this));\n unchecked {\n if (amountTotal > 0) amountTotal -= 1; // slot undrain protection\n }\n distributeAndSwap(stream, address(this), token, amountTotal);\n }\n \n /// @notice Processes ERC20 token from msg.sender balance:\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n /// @param amountTotal Amount of tokens to take from msg.sender\n function processUserERC20(uint256 stream, uint256 amountTotal) private {\n address token = stream.readAddress();\n distributeAndSwap(stream, msg.sender, token, amountTotal);\n }\n\n /// @notice Distributes amountTotal to several pools according to their shares and calls swap for each pool\n /// @param stream Streamed process program\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountTotal Total amount of tokenIn for swaps \n function distributeAndSwap(uint256 stream, address from, address tokenIn, uint256 amountTotal) private {\n uint8 num = stream.readUint8();\n unchecked {\n for (uint256 i = 0; i < num; ++i) {\n uint16 share = stream.readUint16();\n uint256 amount = (amountTotal * share) / 65535;\n amountTotal -= amount;\n swap(stream, from, tokenIn, amount);\n }\n }\n }\n\n /// @notice Processes ERC20 token for cases when the token has only one output pool\n /// @notice In this case liquidity is already at pool balance. This is an optimization\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processOnePool(uint256 stream) private {\n address token = stream.readAddress();\n swap(stream, address(this), token, 0);\n }\n\n /// @notice Processes Bento tokens \n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processInsideBento(uint256 stream) private {\n address token = stream.readAddress();\n uint8 num = stream.readUint8();\n\n uint256 amountTotal = bentoBox.balanceOf(token, address(this));\n unchecked {\n if (amountTotal > 0) amountTotal -= 1; // slot undrain protection\n for (uint256 i = 0; i < num; ++i) {\n uint16 share = stream.readUint16();\n uint256 amount = (amountTotal * share) / 65535;\n amountTotal -= amount;\n swap(stream, address(this), token, amount);\n }\n }\n }\n\n /// @notice Makes swap\n /// @param stream Streamed process program\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swap(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 poolType = stream.readUint8();\n if (poolType == 0) swapUniV2(stream, from, tokenIn, amountIn);\n else if (poolType == 1) swapUniV3(stream, from, tokenIn, amountIn);\n else if (poolType == 2) wrapNative(stream, from, tokenIn, amountIn);\n else if (poolType == 3) bentoBridge(stream, from, tokenIn, amountIn);\n else if (poolType == 4) swapTrident(stream, from, tokenIn, amountIn);\n else if (poolType == 5) swapTridentCL(stream, from, tokenIn, amountIn);\n else revert('RouteProcessor: Unknown pool type');\n }\n\n /// @notice Wraps/unwraps native token\n /// @param stream [direction & fake, recipient, wrapToken?]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function wrapNative(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 directionAndFake = stream.readUint8();\n address to = stream.readAddress();\n\n if (directionAndFake & 1 == 1) { // wrap native\n address wrapToken = stream.readAddress();\n if (directionAndFake & 2 == 0) IWETH(wrapToken).deposit{value: amountIn}();\n if (to != address(this)) IERC20(wrapToken).safeTransfer(to, amountIn);\n } else { // unwrap native\n if (directionAndFake & 2 == 0) {\n if (from != address(this)) IERC20(tokenIn).safeTransferFrom(from, address(this), amountIn);\n IWETH(tokenIn).withdraw(amountIn);\n }\n payable(to).transfer(address(this).balance);\n }\n }\n\n /// @notice Bridge/unbridge tokens to/from Bento\n /// @param stream [direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function bentoBridge(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 direction = stream.readUint8();\n address to = stream.readAddress();\n\n if (direction > 0) { // outside to Bento\n // deposit to arbitrary recipient is possible only from address(bentoBox)\n if (amountIn != 0) {\n if (from == address(this)) IERC20(tokenIn).safeTransfer(address(bentoBox), amountIn);\n else IERC20(tokenIn).safeTransferFrom(from, address(bentoBox), amountIn);\n } else {\n // tokens already are at address(bentoBox)\n amountIn = IERC20(tokenIn).balanceOf(address(bentoBox)) +\n bentoBox.strategyData(tokenIn).balance -\n bentoBox.totals(tokenIn).elastic;\n }\n bentoBox.deposit(tokenIn, address(bentoBox), to, amountIn, 0);\n } else { // Bento to outside\n if (amountIn > 0) {\n bentoBox.transfer(tokenIn, from, address(this), amountIn);\n } else amountIn = bentoBox.balanceOf(tokenIn, address(this));\n bentoBox.withdraw(tokenIn, address(this), to, 0, amountIn);\n }\n }\n\n /// @notice UniswapV2 pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapUniV2(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n uint8 direction = stream.readUint8();\n address to = stream.readAddress();\n\n (uint256 r0, uint256 r1, ) = IUniswapV2Pair(pool).getReserves();\n require(r0 > 0 && r1 > 0, 'Wrong pool reserves');\n (uint256 reserveIn, uint256 reserveOut) = direction == 1 ? (r0, r1) : (r1, r0);\n\n if (amountIn != 0) {\n if (from == address(this)) IERC20(tokenIn).safeTransfer(pool, amountIn);\n else IERC20(tokenIn).safeTransferFrom(from, pool, amountIn);\n } else amountIn = IERC20(tokenIn).balanceOf(pool) - reserveIn; // tokens already were transferred\n\n uint256 amountInWithFee = amountIn * 997;\n uint256 amountOut = (amountInWithFee * reserveOut) / (reserveIn * 1000 + amountInWithFee);\n (uint256 amount0Out, uint256 amount1Out) = direction == 1 ? (uint256(0), amountOut) : (amountOut, uint256(0));\n IUniswapV2Pair(pool).swap(amount0Out, amount1Out, to, new bytes(0));\n }\n\n /// @notice Trident pool swap\n /// @param stream [pool, swapData]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapTrident(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bytes memory swapData = stream.readBytes();\n\n if (amountIn != 0) {\n bentoBox.transfer(tokenIn, from, pool, amountIn);\n }\n \n IPool(pool).swap(swapData);\n }\n\n /// @notice UniswapV3 pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapUniV3(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bool zeroForOne = stream.readUint8() > 0;\n address recipient = stream.readAddress();\n\n lastCalledPool = pool;\n IUniswapV3Pool(pool).swap(\n recipient,\n zeroForOne,\n int256(amountIn),\n zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,\n abi.encode(tokenIn, from)\n );\n require(lastCalledPool == IMPOSSIBLE_POOL_ADDRESS, 'RouteProcessor.swapUniV3: unexpected'); // Just to be sure\n }\n\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external {\n require(msg.sender == lastCalledPool, 'RouteProcessor.uniswapV3SwapCallback: call from unknown source');\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n (address tokenIn, address from) = abi.decode(data, (address, address));\n int256 amount = amount0Delta > 0 ? amount0Delta : amount1Delta;\n require(amount > 0, 'RouteProcessor.uniswapV3SwapCallback: not positive amount');\n\n if (from == address(this)) IERC20(tokenIn).safeTransfer(msg.sender, uint256(amount));\n else IERC20(tokenIn).safeTransferFrom(from, msg.sender, uint256(amount));\n }\n\n /// @notice TridentCL pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapTridentCL(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bool zeroForOne = stream.readUint8() > 0;\n address recipient = stream.readAddress();\n\n lastCalledPool = pool;\n ITridentCLPool(pool).swap(\n recipient,\n zeroForOne,\n int256(amountIn),\n zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,\n false,\n abi.encode(tokenIn, from)\n );\n require(lastCalledPool == IMPOSSIBLE_POOL_ADDRESS, 'RouteProcessor.swapTridentCL: unexpected'); // Just to be sure\n }\n\n /// @notice Called to `msg.sender` after executing a swap via ITridentCLPool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a TridentCLPool deployed by the canonical TridentCLFactory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the ITridentCLPoolActions#swap call\n function tridentCLSwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external {\n require(msg.sender == lastCalledPool, 'RouteProcessor.TridentCLSwapCallback: call from unknown source');\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n (address tokenIn, address from) = abi.decode(data, (address, address));\n int256 amount = amount0Delta > 0 ? amount0Delta : amount1Delta;\n require(amount > 0, 'RouteProcessor.TridentCLSwapCallback: not positive amount');\n\n if (from == address(this)) IERC20(tokenIn).safeTransfer(msg.sender, uint256(amount));\n else IERC20(tokenIn).safeTransferFrom(from, msg.sender, uint256(amount));\n }\n}\n" - }, - "interfaces/ITridentCLPool.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface ITridentCLPool {\n function token0() external returns (address);\n function token1() external returns (address);\n\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool unwrapBento,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "interfaces/IUniswapV2Pair.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n function name() external pure returns (string memory);\n function symbol() external pure returns (string memory);\n function decimals() external pure returns (uint8);\n function totalSupply() external view returns (uint);\n function balanceOf(address owner) external view returns (uint);\n function allowance(address owner, address spender) external view returns (uint);\n\n function approve(address spender, uint value) external returns (bool);\n function transfer(address to, uint value) external returns (bool);\n function transferFrom(address from, address to, uint value) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n function nonces(address owner) external view returns (uint);\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n event Mint(address indexed sender, uint amount0, uint amount1);\n event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint amount0In,\n uint amount1In,\n uint amount0Out,\n uint amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint);\n function factory() external view returns (address);\n function token0() external view returns (address);\n function token1() external view returns (address);\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n function price0CumulativeLast() external view returns (uint);\n function price1CumulativeLast() external view returns (uint);\n function kLast() external view returns (uint);\n\n function mint(address to) external returns (uint liquidity);\n function burn(address to) external returns (uint amount0, uint amount1);\n function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n function skim(address to) external;\n function sync() external;\n\n function initialize(address, address) external;\n}" - }, - "interfaces/IUniswapV3Pool.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface IUniswapV3Pool {\n function token0() external returns (address);\n function token1() external returns (address);\n\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n}\n" - }, - "interfaces/IWETH.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface IWETH {\n function deposit() external payable;\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function withdraw(uint256) external;\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 10000000 - }, - "outputSelection": { - "*": { - "*": [ - "evm.bytecode", - "evm.deployedBytecode", - "devdoc", - "userdoc", - "metadata", - "abi" - ] - } - }, - "metadata": { - "useLiteralContent": true - }, - "libraries": {} - } - }, - "ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bentoBox\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"bentoBox\",\"outputs\":[{\"internalType\":\"contract IBentoBoxMinimal\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"route\",\"type\":\"bytes\"}],\"name\":\"processRoute\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"transferValueTo\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountValueTransfer\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"route\",\"type\":\"bytes\"}],\"name\":\"transferValueAndprocessRoute\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"amount0Delta\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1Delta\",\"type\":\"int256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"tridentCLSwapCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"amount0Delta\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1Delta\",\"type\":\"int256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"uniswapV3SwapCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - "ContractName": "RouteProcessor2", - "CompilerVersion": "v0.8.10+commit.fc410830", - "OptimizationUsed": 1, - "Runs": 10000000, - "ConstructorArguments": "0x000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd643966", - "EVMVersion": "Default", - "Library": "", - "LicenseType": "", - "Proxy": 0, - "SwarmSource": "" - } -] \ No newline at end of file +[{"SourceCode":{"language":"Solidity","sources":{"contracts/InputStream.sol":{"content":"// SPDX-License-Identifier: UNLICENSED\n\npragma solidity 0.8.10;\n\nlibrary InputStream {\n function createStream(bytes memory data) internal pure returns (uint256 stream) {\n assembly {\n stream := mload(0x40)\n mstore(0x40, add(stream, 64))\n mstore(stream, data)\n let length := mload(data)\n mstore(add(stream, 32), add(data, length))\n }\n }\n\n function isNotEmpty(uint256 stream) internal pure returns (bool) {\n uint256 pos;\n uint256 finish;\n assembly {\n pos := mload(stream)\n finish := mload(add(stream, 32))\n }\n return pos < finish;\n }\n\n function readUint8(uint256 stream) internal pure returns (uint8 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 1)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint16(uint256 stream) internal pure returns (uint16 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 2)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint32(uint256 stream) internal pure returns (uint32 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 4)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readUint(uint256 stream) internal pure returns (uint256 res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 32)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readAddress(uint256 stream) internal pure returns (address res) {\n assembly {\n let pos := mload(stream)\n pos := add(pos, 20)\n res := mload(pos)\n mstore(stream, pos)\n }\n }\n\n function readBytes(uint256 stream) internal pure returns (bytes memory res) {\n assembly {\n let pos := mload(stream)\n res := add(pos, 32)\n let length := mload(res)\n mstore(stream, add(res, length))\n }\n }\n}\n"},"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n"},"interfaces/IBentoBoxMinimal.sol":{"content":"// SPDX-License-Identifier: UNLICENSED\n\npragma solidity >=0.8.0;\n\nstruct Rebase {\n uint128 elastic;\n uint128 base;\n}\n\nstruct StrategyData {\n uint64 strategyStartDate;\n uint64 targetPercentage;\n uint128 balance; // the balance of the strategy that BentoBox thinks is in there\n}\n\n/// @notice A rebasing library\nlibrary RebaseLibrary {\n /// @notice Calculates the base value in relationship to `elastic` and `total`.\n function toBase(Rebase memory total, uint256 elastic) internal pure returns (uint256 base) {\n if (total.elastic == 0) {\n base = elastic;\n } else {\n base = (elastic * total.base) / total.elastic;\n }\n }\n\n /// @notice Calculates the elastic value in relationship to `base` and `total`.\n function toElastic(Rebase memory total, uint256 base) internal pure returns (uint256 elastic) {\n if (total.base == 0) {\n elastic = base;\n } else {\n elastic = (base * total.elastic) / total.base;\n }\n }\n}\n\n/// @notice Minimal BentoBox vault interface.\n/// @dev `token` is aliased as `address` from `IERC20` for simplicity.\ninterface IBentoBoxMinimal {\n /// @notice Balance per ERC-20 token per account in shares.\n function balanceOf(address, address) external view returns (uint256);\n\n /// @dev Helper function to represent an `amount` of `token` in shares.\n /// @param token The ERC-20 token.\n /// @param amount The `token` amount.\n /// @param roundUp If the result `share` should be rounded up.\n /// @return share The token amount represented in shares.\n function toShare(\n address token,\n uint256 amount,\n bool roundUp\n ) external view returns (uint256 share);\n\n /// @dev Helper function to represent shares back into the `token` amount.\n /// @param token The ERC-20 token.\n /// @param share The amount of shares.\n /// @param roundUp If the result should be rounded up.\n /// @return amount The share amount back into native representation.\n function toAmount(\n address token,\n uint256 share,\n bool roundUp\n ) external view returns (uint256 amount);\n\n /// @notice Registers this contract so that users can approve it for BentoBox.\n function registerProtocol() external;\n\n /// @notice Deposit an amount of `token` represented in either `amount` or `share`.\n /// @param token The ERC-20 token to deposit.\n /// @param from which account to pull the tokens.\n /// @param to which account to push the tokens.\n /// @param amount Token amount in native representation to deposit.\n /// @param share Token amount represented in shares to deposit. Takes precedence over `amount`.\n /// @return amountOut The amount deposited.\n /// @return shareOut The deposited amount represented in shares.\n function deposit(\n address token,\n address from,\n address to,\n uint256 amount,\n uint256 share\n ) external payable returns (uint256 amountOut, uint256 shareOut);\n\n /// @notice Withdraws an amount of `token` from a user account.\n /// @param token_ The ERC-20 token to withdraw.\n /// @param from which user to pull the tokens.\n /// @param to which user to push the tokens.\n /// @param amount of tokens. Either one of `amount` or `share` needs to be supplied.\n /// @param share Like above, but `share` takes precedence over `amount`.\n function withdraw(\n address token_,\n address from,\n address to,\n uint256 amount,\n uint256 share\n ) external returns (uint256 amountOut, uint256 shareOut);\n\n /// @notice Transfer shares from a user account to another one.\n /// @param token The ERC-20 token to transfer.\n /// @param from which user to pull the tokens.\n /// @param to which user to push the tokens.\n /// @param share The amount of `token` in shares.\n function transfer(\n address token,\n address from,\n address to,\n uint256 share\n ) external;\n\n /// @dev Reads the Rebase `totals`from storage for a given token\n function totals(address token) external view returns (Rebase memory total);\n\n function strategyData(address token) external view returns (StrategyData memory total);\n\n /// @dev Approves users' BentoBox assets to a \"master\" contract.\n function setMasterContractApproval(\n address user,\n address masterContract,\n bool approved,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n function harvest(\n address token,\n bool balance,\n uint256 maxChangeAmount\n ) external;\n}\n"},"@openzeppelin/contracts/utils/Address.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"},"interfaces/IPool.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity >=0.5.0;\npragma experimental ABIEncoderV2;\n\n/// @notice Trident pool interface.\ninterface IPool {\n /// @notice Executes a swap from one token to another.\n /// @dev The input tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that were sent to the user.\n function swap(bytes calldata data) external returns (uint256 finalAmountOut);\n\n /// @notice Executes a swap from one token to another with a callback.\n /// @dev This function allows borrowing the output tokens and sending the input tokens in the callback.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that were sent to the user.\n function flashSwap(bytes calldata data) external returns (uint256 finalAmountOut);\n\n /// @notice Mints liquidity tokens.\n /// @param data ABI-encoded params that the pool requires.\n /// @return liquidity The amount of liquidity tokens that were minted for the user.\n function mint(bytes calldata data) external returns (uint256 liquidity);\n\n /// @notice Burns liquidity tokens.\n /// @dev The input LP tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return withdrawnAmounts The amount of various output tokens that were sent to the user.\n function burn(bytes calldata data) external returns (TokenAmount[] memory withdrawnAmounts);\n\n /// @notice Burns liquidity tokens for a single output token.\n /// @dev The input LP tokens must've already been sent to the pool.\n /// @param data ABI-encoded params that the pool requires.\n /// @return amountOut The amount of output tokens that were sent to the user.\n function burnSingle(bytes calldata data) external returns (uint256 amountOut);\n\n /// @return A unique identifier for the pool type.\n function poolIdentifier() external pure returns (bytes32);\n\n /// @return An array of tokens supported by the pool.\n function getAssets() external view returns (address[] memory);\n\n /// @notice Simulates a trade and returns the expected output.\n /// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountOut The amount of output tokens that will be sent to the user if the trade is executed.\n function getAmountOut(bytes calldata data) external view returns (uint256 finalAmountOut);\n\n /// @notice Simulates a trade and returns the expected output.\n /// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.\n /// @param data ABI-encoded params that the pool requires.\n /// @return finalAmountIn The amount of input tokens that are required from the user if the trade is executed.\n function getAmountIn(bytes calldata data) external view returns (uint256 finalAmountIn);\n\n /// @dev This event must be emitted on all swaps.\n event Swap(address indexed recipient, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut);\n\n /// @dev This struct frames output tokens for burns.\n struct TokenAmount {\n address token;\n uint256 amount;\n }\n}\n"},"@openzeppelin/contracts/token/ERC20/IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"},"contracts/RouteProcessor2.sol":{"content":"// SPDX-License-Identifier: UNLICENSED\n\npragma solidity 0.8.10;\n\nimport '../interfaces/IUniswapV2Pair.sol';\nimport '../interfaces/IUniswapV3Pool.sol';\nimport '../interfaces/ITridentCLPool.sol';\nimport '../interfaces/IBentoBoxMinimal.sol';\nimport '../interfaces/IPool.sol';\nimport '../interfaces/IWETH.sol';\nimport './InputStream.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\naddress constant NATIVE_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\naddress constant IMPOSSIBLE_POOL_ADDRESS = 0x0000000000000000000000000000000000000001;\n\n/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\nuint160 constant MIN_SQRT_RATIO = 4295128739;\n/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\nuint160 constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n/// @title A route processor for the Sushi Aggregator\n/// @author Ilya Lyalin\ncontract RouteProcessor2 {\n using SafeERC20 for IERC20;\n using InputStream for uint256;\n\n IBentoBoxMinimal public immutable bentoBox;\n address private lastCalledPool;\n\n uint private unlocked = 1;\n modifier lock() {\n require(unlocked == 1, 'RouteProcessor is locked');\n unlocked = 2;\n _;\n unlocked = 1;\n }\n\n constructor(address _bentoBox) {\n bentoBox = IBentoBoxMinimal(_bentoBox);\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n }\n\n /// @notice For native unwrapping\n receive() external payable {}\n\n /// @notice Processes the route generated off-chain. Has a lock\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function processRoute(\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) external payable lock returns (uint256 amountOut) {\n return processRouteInternal(tokenIn, amountIn, tokenOut, amountOutMin, to, route);\n }\n\n /// @notice Transfers some value to and then processes the route\n /// @param transferValueTo Address where the value should be transferred\n /// @param amountValueTransfer How much value to transfer\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function transferValueAndprocessRoute(\n address payable transferValueTo,\n uint256 amountValueTransfer,\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) external payable lock returns (uint256 amountOut) {\n (bool success, bytes memory returnBytes) = transferValueTo.call{value: amountValueTransfer}('');\n require(success, string(abi.encodePacked(returnBytes)));\n return processRouteInternal(tokenIn, amountIn, tokenOut, amountOutMin, to, route);\n }\n\n /// @notice Processes the route generated off-chain\n /// @param tokenIn Address of the input token\n /// @param amountIn Amount of the input token\n /// @param tokenOut Address of the output token\n /// @param amountOutMin Minimum amount of the output token\n /// @return amountOut Actual amount of the output token\n function processRouteInternal(\n address tokenIn,\n uint256 amountIn,\n address tokenOut,\n uint256 amountOutMin,\n address to,\n bytes memory route\n ) private returns (uint256 amountOut) {\n uint256 balanceInInitial = tokenIn == NATIVE_ADDRESS ? address(this).balance : IERC20(tokenIn).balanceOf(msg.sender);\n uint256 balanceOutInitial = tokenOut == NATIVE_ADDRESS ? address(to).balance : IERC20(tokenOut).balanceOf(to);\n\n uint256 stream = InputStream.createStream(route);\n while (stream.isNotEmpty()) {\n uint8 commandCode = stream.readUint8();\n if (commandCode == 1) processMyERC20(stream);\n else if (commandCode == 2) processUserERC20(stream, amountIn);\n else if (commandCode == 3) processNative(stream);\n else if (commandCode == 4) processOnePool(stream);\n else if (commandCode == 5) processInsideBento(stream);\n else revert('RouteProcessor: Unknown command code');\n }\n\n uint256 balanceInFinal = tokenIn == NATIVE_ADDRESS ? address(this).balance : IERC20(tokenIn).balanceOf(msg.sender);\n require(balanceInFinal + amountIn >= balanceInInitial, 'RouteProcessor: Minimal imput balance violation');\n\n uint256 balanceOutFinal = tokenOut == NATIVE_ADDRESS ? address(to).balance : IERC20(tokenOut).balanceOf(to);\n require(balanceOutFinal >= balanceOutInitial + amountOutMin, 'RouteProcessor: Minimal ouput balance violation');\n\n amountOut = balanceOutFinal - balanceOutInitial;\n }\n\n /// @notice Processes native coin: call swap for all pools that swap from native coin\n /// @param stream Streamed process program\n function processNative(uint256 stream) private {\n uint256 amountTotal = address(this).balance;\n distributeAndSwap(stream, address(this), NATIVE_ADDRESS, amountTotal);\n }\n\n /// @notice Processes ERC20 token from this contract balance:\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processMyERC20(uint256 stream) private {\n address token = stream.readAddress();\n uint256 amountTotal = IERC20(token).balanceOf(address(this));\n unchecked {\n if (amountTotal > 0) amountTotal -= 1; // slot undrain protection\n }\n distributeAndSwap(stream, address(this), token, amountTotal);\n }\n \n /// @notice Processes ERC20 token from msg.sender balance:\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n /// @param amountTotal Amount of tokens to take from msg.sender\n function processUserERC20(uint256 stream, uint256 amountTotal) private {\n address token = stream.readAddress();\n distributeAndSwap(stream, msg.sender, token, amountTotal);\n }\n\n /// @notice Distributes amountTotal to several pools according to their shares and calls swap for each pool\n /// @param stream Streamed process program\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountTotal Total amount of tokenIn for swaps \n function distributeAndSwap(uint256 stream, address from, address tokenIn, uint256 amountTotal) private {\n uint8 num = stream.readUint8();\n unchecked {\n for (uint256 i = 0; i < num; ++i) {\n uint16 share = stream.readUint16();\n uint256 amount = (amountTotal * share) / 65535;\n amountTotal -= amount;\n swap(stream, from, tokenIn, amount);\n }\n }\n }\n\n /// @notice Processes ERC20 token for cases when the token has only one output pool\n /// @notice In this case liquidity is already at pool balance. This is an optimization\n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processOnePool(uint256 stream) private {\n address token = stream.readAddress();\n swap(stream, address(this), token, 0);\n }\n\n /// @notice Processes Bento tokens \n /// @notice Call swap for all pools that swap from this token\n /// @param stream Streamed process program\n function processInsideBento(uint256 stream) private {\n address token = stream.readAddress();\n uint8 num = stream.readUint8();\n\n uint256 amountTotal = bentoBox.balanceOf(token, address(this));\n unchecked {\n if (amountTotal > 0) amountTotal -= 1; // slot undrain protection\n for (uint256 i = 0; i < num; ++i) {\n uint16 share = stream.readUint16();\n uint256 amount = (amountTotal * share) / 65535;\n amountTotal -= amount;\n swap(stream, address(this), token, amount);\n }\n }\n }\n\n /// @notice Makes swap\n /// @param stream Streamed process program\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swap(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 poolType = stream.readUint8();\n if (poolType == 0) swapUniV2(stream, from, tokenIn, amountIn);\n else if (poolType == 1) swapUniV3(stream, from, tokenIn, amountIn);\n else if (poolType == 2) wrapNative(stream, from, tokenIn, amountIn);\n else if (poolType == 3) bentoBridge(stream, from, tokenIn, amountIn);\n else if (poolType == 4) swapTrident(stream, from, tokenIn, amountIn);\n else if (poolType == 5) swapTridentCL(stream, from, tokenIn, amountIn);\n else revert('RouteProcessor: Unknown pool type');\n }\n\n /// @notice Wraps/unwraps native token\n /// @param stream [direction & fake, recipient, wrapToken?]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function wrapNative(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 directionAndFake = stream.readUint8();\n address to = stream.readAddress();\n\n if (directionAndFake & 1 == 1) { // wrap native\n address wrapToken = stream.readAddress();\n if (directionAndFake & 2 == 0) IWETH(wrapToken).deposit{value: amountIn}();\n if (to != address(this)) IERC20(wrapToken).safeTransfer(to, amountIn);\n } else { // unwrap native\n if (directionAndFake & 2 == 0) {\n if (from != address(this)) IERC20(tokenIn).safeTransferFrom(from, address(this), amountIn);\n IWETH(tokenIn).withdraw(amountIn);\n }\n payable(to).transfer(address(this).balance);\n }\n }\n\n /// @notice Bridge/unbridge tokens to/from Bento\n /// @param stream [direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function bentoBridge(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n uint8 direction = stream.readUint8();\n address to = stream.readAddress();\n\n if (direction > 0) { // outside to Bento\n // deposit to arbitrary recipient is possible only from address(bentoBox)\n if (amountIn != 0) {\n if (from == address(this)) IERC20(tokenIn).safeTransfer(address(bentoBox), amountIn);\n else IERC20(tokenIn).safeTransferFrom(from, address(bentoBox), amountIn);\n } else {\n // tokens already are at address(bentoBox)\n amountIn = IERC20(tokenIn).balanceOf(address(bentoBox)) +\n bentoBox.strategyData(tokenIn).balance -\n bentoBox.totals(tokenIn).elastic;\n }\n bentoBox.deposit(tokenIn, address(bentoBox), to, amountIn, 0);\n } else { // Bento to outside\n if (amountIn > 0) {\n bentoBox.transfer(tokenIn, from, address(this), amountIn);\n } else amountIn = bentoBox.balanceOf(tokenIn, address(this));\n bentoBox.withdraw(tokenIn, address(this), to, 0, amountIn);\n }\n }\n\n /// @notice UniswapV2 pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapUniV2(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n uint8 direction = stream.readUint8();\n address to = stream.readAddress();\n\n (uint256 r0, uint256 r1, ) = IUniswapV2Pair(pool).getReserves();\n require(r0 > 0 && r1 > 0, 'Wrong pool reserves');\n (uint256 reserveIn, uint256 reserveOut) = direction == 1 ? (r0, r1) : (r1, r0);\n\n if (amountIn != 0) {\n if (from == address(this)) IERC20(tokenIn).safeTransfer(pool, amountIn);\n else IERC20(tokenIn).safeTransferFrom(from, pool, amountIn);\n } else amountIn = IERC20(tokenIn).balanceOf(pool) - reserveIn; // tokens already were transferred\n\n uint256 amountInWithFee = amountIn * 997;\n uint256 amountOut = (amountInWithFee * reserveOut) / (reserveIn * 1000 + amountInWithFee);\n (uint256 amount0Out, uint256 amount1Out) = direction == 1 ? (uint256(0), amountOut) : (amountOut, uint256(0));\n IUniswapV2Pair(pool).swap(amount0Out, amount1Out, to, new bytes(0));\n }\n\n /// @notice Trident pool swap\n /// @param stream [pool, swapData]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapTrident(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bytes memory swapData = stream.readBytes();\n\n if (amountIn != 0) {\n bentoBox.transfer(tokenIn, from, pool, amountIn);\n }\n \n IPool(pool).swap(swapData);\n }\n\n /// @notice UniswapV3 pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapUniV3(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bool zeroForOne = stream.readUint8() > 0;\n address recipient = stream.readAddress();\n\n lastCalledPool = pool;\n IUniswapV3Pool(pool).swap(\n recipient,\n zeroForOne,\n int256(amountIn),\n zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,\n abi.encode(tokenIn, from)\n );\n require(lastCalledPool == IMPOSSIBLE_POOL_ADDRESS, 'RouteProcessor.swapUniV3: unexpected'); // Just to be sure\n }\n\n /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external {\n require(msg.sender == lastCalledPool, 'RouteProcessor.uniswapV3SwapCallback: call from unknown source');\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n (address tokenIn, address from) = abi.decode(data, (address, address));\n int256 amount = amount0Delta > 0 ? amount0Delta : amount1Delta;\n require(amount > 0, 'RouteProcessor.uniswapV3SwapCallback: not positive amount');\n\n if (from == address(this)) IERC20(tokenIn).safeTransfer(msg.sender, uint256(amount));\n else IERC20(tokenIn).safeTransferFrom(from, msg.sender, uint256(amount));\n }\n\n /// @notice TridentCL pool swap\n /// @param stream [pool, direction, recipient]\n /// @param from Where to take liquidity for swap\n /// @param tokenIn Input token\n /// @param amountIn Amount of tokenIn to take for swap\n function swapTridentCL(uint256 stream, address from, address tokenIn, uint256 amountIn) private {\n address pool = stream.readAddress();\n bool zeroForOne = stream.readUint8() > 0;\n address recipient = stream.readAddress();\n\n lastCalledPool = pool;\n ITridentCLPool(pool).swap(\n recipient,\n zeroForOne,\n int256(amountIn),\n zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,\n false,\n abi.encode(tokenIn, from)\n );\n require(lastCalledPool == IMPOSSIBLE_POOL_ADDRESS, 'RouteProcessor.swapTridentCL: unexpected'); // Just to be sure\n }\n\n /// @notice Called to `msg.sender` after executing a swap via ITridentCLPool#swap.\n /// @dev In the implementation you must pay the pool tokens owed for the swap.\n /// The caller of this method must be checked to be a TridentCLPool deployed by the canonical TridentCLFactory.\n /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n /// @param data Any data passed through by the caller via the ITridentCLPoolActions#swap call\n function tridentCLSwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external {\n require(msg.sender == lastCalledPool, 'RouteProcessor.TridentCLSwapCallback: call from unknown source');\n lastCalledPool = IMPOSSIBLE_POOL_ADDRESS;\n (address tokenIn, address from) = abi.decode(data, (address, address));\n int256 amount = amount0Delta > 0 ? amount0Delta : amount1Delta;\n require(amount > 0, 'RouteProcessor.TridentCLSwapCallback: not positive amount');\n\n if (from == address(this)) IERC20(tokenIn).safeTransfer(msg.sender, uint256(amount));\n else IERC20(tokenIn).safeTransferFrom(from, msg.sender, uint256(amount));\n }\n}\n"},"interfaces/ITridentCLPool.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface ITridentCLPool {\n function token0() external returns (address);\n function token1() external returns (address);\n\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bool unwrapBento,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n}\n"},"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"},"interfaces/IUniswapV2Pair.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n function name() external pure returns (string memory);\n function symbol() external pure returns (string memory);\n function decimals() external pure returns (uint8);\n function totalSupply() external view returns (uint);\n function balanceOf(address owner) external view returns (uint);\n function allowance(address owner, address spender) external view returns (uint);\n\n function approve(address spender, uint value) external returns (bool);\n function transfer(address to, uint value) external returns (bool);\n function transferFrom(address from, address to, uint value) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n function nonces(address owner) external view returns (uint);\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n event Mint(address indexed sender, uint amount0, uint amount1);\n event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint amount0In,\n uint amount1In,\n uint amount0Out,\n uint amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint);\n function factory() external view returns (address);\n function token0() external view returns (address);\n function token1() external view returns (address);\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n function price0CumulativeLast() external view returns (uint);\n function price1CumulativeLast() external view returns (uint);\n function kLast() external view returns (uint);\n\n function mint(address to) external returns (uint liquidity);\n function burn(address to) external returns (uint amount0, uint amount1);\n function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n function skim(address to) external;\n function sync() external;\n\n function initialize(address, address) external;\n}"},"interfaces/IUniswapV3Pool.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface IUniswapV3Pool {\n function token0() external returns (address);\n function token1() external returns (address);\n\n function swap(\n address recipient,\n bool zeroForOne,\n int256 amountSpecified,\n uint160 sqrtPriceLimitX96,\n bytes calldata data\n ) external returns (int256 amount0, int256 amount1);\n}\n"},"interfaces/IWETH.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity 0.8.10;\n\ninterface IWETH {\n function deposit() external payable;\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function withdraw(uint256) external;\n}\n"}},"settings":{"optimizer":{"enabled":true,"runs":10000000},"outputSelection":{"*":{"*":["evm.bytecode","evm.deployedBytecode","devdoc","userdoc","metadata","abi"]}},"metadata":{"useLiteralContent":true},"libraries":{}}},"ABI":"[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bentoBox\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"bentoBox\",\"outputs\":[{\"internalType\":\"contract IBentoBoxMinimal\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"route\",\"type\":\"bytes\"}],\"name\":\"processRoute\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"transferValueTo\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountValueTransfer\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"route\",\"type\":\"bytes\"}],\"name\":\"transferValueAndprocessRoute\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"amount0Delta\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1Delta\",\"type\":\"int256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"tridentCLSwapCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"amount0Delta\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1Delta\",\"type\":\"int256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"uniswapV3SwapCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]","ContractName":"RouteProcessor2","CompilerVersion":"v0.8.10+commit.fc410830","OptimizationUsed":1,"Runs":10000000,"ConstructorArguments":"0x000000000000000000000000f5bce5077908a1b7370b9ae04adc565ebd643966","EVMVersion":"Default","Library":"","LicenseType":"","Proxy":0,"SwarmSource":""}] \ No newline at end of file diff --git a/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json index 2c31353535865..e3433ef20019a 100644 --- a/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json +++ b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json @@ -1,5 +1 @@ -{ - "contractAddress": "0x35fb958109b70799a8f9bc2a8b1ee4cc62034193", - "contractCreator": "0x3e32324277e96b69750bc6f7c4ba27e122413e07", - "txHash": "0x41e3517f8262b55e1eb1707ba0760b603a70e89ea4a86eff56072fcc80c3d0a1" -} \ No newline at end of file +{"contractAddress":"0x35fb958109b70799a8f9bc2a8b1ee4cc62034193","contractCreator":"0x3e32324277e96b69750bc6f7c4ba27e122413e07","txHash":"0x41e3517f8262b55e1eb1707ba0760b603a70e89ea4a86eff56072fcc80c3d0a1"} \ No newline at end of file diff --git a/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json index 7601e4d6ee1e7..bd48a2efbea4c 100644 --- a/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json +++ b/testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/metadata.json @@ -1,16 +1 @@ -[ - { - "SourceCode": "/**\r\n *Submitted for verification at Etherscan.io on 2022-02-19\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-18\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-14\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-10\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-09\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-08\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-05\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-01-22\r\n*/\r\n\r\n// SPDX-License-Identifier: UNLICENSED\r\n/*\r\nmade by cty0312\r\n2022.01.22\r\n**/\r\n\r\npragma solidity >=0.7.0 <0.9.0;\r\n\r\nlibrary StringsUpgradeable {\r\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n // Inspired by OraclizeAPI's implementation - MIT licence\r\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\r\n\r\n if (value == 0) {\r\n return \"0\";\r\n }\r\n uint256 temp = value;\r\n uint256 digits;\r\n while (temp != 0) {\r\n digits++;\r\n temp /= 10;\r\n }\r\n bytes memory buffer = new bytes(digits);\r\n while (value != 0) {\r\n digits -= 1;\r\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\r\n value /= 10;\r\n }\r\n return string(buffer);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(uint256 value) internal pure returns (string memory) {\r\n if (value == 0) {\r\n return \"0x00\";\r\n }\r\n uint256 temp = value;\r\n uint256 length = 0;\r\n while (temp != 0) {\r\n length++;\r\n temp >>= 8;\r\n }\r\n return toHexString(value, length);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\r\n */\r\n function toHexString(uint256 value, uint256 length)\r\n internal\r\n pure\r\n returns (string memory)\r\n {\r\n bytes memory buffer = new bytes(2 * length + 2);\r\n buffer[0] = \"0\";\r\n buffer[1] = \"x\";\r\n for (uint256 i = 2 * length + 1; i > 1; --i) {\r\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\r\n value >>= 4;\r\n }\r\n require(value == 0, \"Strings: hex length insufficient\");\r\n return string(buffer);\r\n }\r\n}\r\n\r\nlibrary AddressUpgradeable {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize, which returns 0 for contracts in\r\n // construction, since the code is only stored at the end of the\r\n // constructor execution.\r\n\r\n uint256 size;\r\n assembly {\r\n size := extcodesize(account)\r\n }\r\n return size > 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(\r\n address(this).balance >= amount,\r\n \"Address: insufficient balance\"\r\n );\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(\r\n success,\r\n \"Address: unable to send value, recipient may have reverted\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data)\r\n internal\r\n returns (bytes memory)\r\n {\r\n return functionCall(target, data, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value\r\n ) internal returns (bytes memory) {\r\n return\r\n functionCallWithValue(\r\n target,\r\n data,\r\n value,\r\n \"Address: low-level call with value failed\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(\r\n address(this).balance >= value,\r\n \"Address: insufficient balance for call\"\r\n );\r\n require(isContract(target), \"Address: call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.call{value: value}(\r\n data\r\n );\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data)\r\n internal\r\n view\r\n returns (bytes memory)\r\n {\r\n return\r\n functionStaticCall(\r\n target,\r\n data,\r\n \"Address: low-level static call failed\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n require(isContract(target), \"Address: static call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\r\n * revert reason using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length > 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n }\r\n}\r\n\r\nlibrary SafeMathUpgradeable {\r\n /**\r\n * @dev Returns the addition of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `+` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Addition cannot overflow.\r\n */\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n uint256 c = a + b;\r\n require(c >= a, \"SafeMath: addition overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity's `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return sub(a, b, \"SafeMath: subtraction overflow\");\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity's `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b <= a, errorMessage);\r\n uint256 c = a - b;\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the multiplication of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `*` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Multiplication cannot overflow.\r\n */\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r\n // benefit is lost if 'b' is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 c = a * b;\r\n require(c / a == b, \"SafeMath: multiplication overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return div(a, b, \"SafeMath: division by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b > 0, errorMessage);\r\n uint256 c = a / b;\r\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts when dividing by zero.\r\n *\r\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return mod(a, b, \"SafeMath: modulo by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts with custom message when dividing by zero.\r\n *\r\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b != 0, errorMessage);\r\n return a % b;\r\n }\r\n}\r\n\r\nabstract contract Initializable {\r\n /**\r\n * @dev Indicates that the contract has been initialized.\r\n */\r\n bool private _initialized;\r\n\r\n /**\r\n * @dev Indicates that the contract is in the process of being initialized.\r\n */\r\n bool private _initializing;\r\n\r\n /**\r\n * @dev Modifier to protect an initializer function from being invoked twice.\r\n */\r\n modifier initializer() {\r\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\r\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\r\n // contract may have been reentered.\r\n require(\r\n _initializing ? _isConstructor() : !_initialized,\r\n \"Initializable: contract is already initialized\"\r\n );\r\n\r\n bool isTopLevelCall = !_initializing;\r\n if (isTopLevelCall) {\r\n _initializing = true;\r\n _initialized = true;\r\n }\r\n\r\n _;\r\n\r\n if (isTopLevelCall) {\r\n _initializing = false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\r\n * {initializer} modifier, directly or indirectly.\r\n */\r\n modifier onlyInitializing() {\r\n require(_initializing, \"Initializable: contract is not initializing\");\r\n _;\r\n }\r\n\r\n function _isConstructor() private view returns (bool) {\r\n return !AddressUpgradeable.isContract(address(this));\r\n }\r\n}\r\n\r\nabstract contract ContextUpgradeable is Initializable {\r\n function __Context_init() internal onlyInitializing {\r\n __Context_init_unchained();\r\n }\r\n\r\n function __Context_init_unchained() internal onlyInitializing {}\r\n\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n\r\n uint256[50] private __gap;\r\n}\r\n\r\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(\r\n address indexed previousOwner,\r\n address indexed newOwner\r\n );\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n function __Ownable_init() internal onlyInitializing {\r\n __Context_init_unchained();\r\n __Ownable_init_unchained();\r\n }\r\n\r\n function __Ownable_init_unchained() internal onlyInitializing {\r\n _transferOwnership(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _transferOwnership(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(\r\n newOwner != address(0),\r\n \"Ownable: new owner is the zero address\"\r\n );\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n\r\n uint256[49] private __gap;\r\n}\r\n\r\ninterface IERC165Upgradeable {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n\r\ninterface IERC721Upgradeable is IERC165Upgradeable {\r\n /**\r\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\r\n */\r\n event Transfer(\r\n address indexed from,\r\n address indexed to,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed approved,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(\r\n address indexed owner,\r\n address indexed operator,\r\n bool approved\r\n );\r\n\r\n /**\r\n * @dev Returns the number of tokens in ``owner``'s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Transfers `tokenId` token from `from` to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId)\r\n external\r\n view\r\n returns (address operator);\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool _approved) external;\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}\r\n */\r\n function isApprovedForAll(address owner, address operator)\r\n external\r\n view\r\n returns (bool);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external;\r\n}\r\n\r\ninterface IERC20Upgradeable {\r\n /**\r\n * @dev Returns the amount of tokens in existence.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns the amount of tokens owned by `account`.\r\n */\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transfer(address recipient, uint256 amount)\r\n external\r\n returns (bool);\r\n\r\n /**\r\n * @dev Returns the remaining number of tokens that `spender` will be\r\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\r\n * zero by default.\r\n *\r\n * This value changes when {approve} or {transferFrom} are called.\r\n */\r\n function allowance(address owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\r\n * that someone may use both the old and the new allowance by unfortunate\r\n * transaction ordering. One possible solution to mitigate this race\r\n * condition is to first reduce the spender's allowance to 0 and set the\r\n * desired value afterwards:\r\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\r\n * allowance mechanism. `amount` is then deducted from the caller's\r\n * allowance.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) external returns (bool);\r\n\r\n\r\n function mintToken(address _address, uint256 _amount) external;\r\n /**\r\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\r\n * another (`to`).\r\n *\r\n * Note that `value` may be zero.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n /**\r\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\r\n * a call to {approve}. `value` is the new allowance.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n}\r\n\r\ninterface IUniswapV2Factory {\r\n event PairCreated(\r\n address indexed token0,\r\n address indexed token1,\r\n address pair,\r\n uint256\r\n );\r\n\r\n function feeTo() external view returns (address);\r\n\r\n function feeToSetter() external view returns (address);\r\n\r\n function getPair(address tokenA, address tokenB)\r\n external\r\n view\r\n returns (address pair);\r\n\r\n function allPairs(uint256) external view returns (address pair);\r\n\r\n function allPairsLength() external view returns (uint256);\r\n\r\n function createPair(address tokenA, address tokenB)\r\n external\r\n returns (address pair);\r\n\r\n function setFeeTo(address) external;\r\n\r\n function setFeeToSetter(address) external;\r\n}\r\n\r\ninterface IUniswapV2Pair {\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n function name() external pure returns (string memory);\r\n\r\n function symbol() external pure returns (string memory);\r\n\r\n function decimals() external pure returns (uint8);\r\n\r\n function totalSupply() external view returns (uint256);\r\n\r\n function balanceOf(address owner) external view returns (uint256);\r\n\r\n function allowance(address owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function approve(address spender, uint256 value) external returns (bool);\r\n\r\n function transfer(address to, uint256 value) external returns (bool);\r\n\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 value\r\n ) external returns (bool);\r\n\r\n function DOMAIN_SEPARATOR() external view returns (bytes32);\r\n\r\n function PERMIT_TYPEHASH() external pure returns (bytes32);\r\n\r\n function nonces(address owner) external view returns (uint256);\r\n\r\n function permit(\r\n address owner,\r\n address spender,\r\n uint256 value,\r\n uint256 deadline,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external;\r\n\r\n event Mint(address indexed sender, uint256 amount0, uint256 amount1);\r\n event Burn(\r\n address indexed sender,\r\n uint256 amount0,\r\n uint256 amount1,\r\n address indexed to\r\n );\r\n event Swap(\r\n address indexed sender,\r\n uint256 amount0In,\r\n uint256 amount1In,\r\n uint256 amount0Out,\r\n uint256 amount1Out,\r\n address indexed to\r\n );\r\n event Sync(uint112 reserve0, uint112 reserve1);\r\n\r\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\r\n\r\n function factory() external view returns (address);\r\n\r\n function token0() external view returns (address);\r\n\r\n function token1() external view returns (address);\r\n\r\n function getReserves()\r\n external\r\n view\r\n returns (\r\n uint112 reserve0,\r\n uint112 reserve1,\r\n uint32 blockTimestampLast\r\n );\r\n\r\n function price0CumulativeLast() external view returns (uint256);\r\n\r\n function price1CumulativeLast() external view returns (uint256);\r\n\r\n function kLast() external view returns (uint256);\r\n\r\n function mint(address to) external returns (uint256 liquidity);\r\n\r\n function burn(address to)\r\n external\r\n returns (uint256 amount0, uint256 amount1);\r\n\r\n function swap(\r\n uint256 amount0Out,\r\n uint256 amount1Out,\r\n address to,\r\n bytes calldata data\r\n ) external;\r\n\r\n function skim(address to) external;\r\n\r\n function sync() external;\r\n\r\n function initialize(address, address) external;\r\n}\r\n\r\ninterface IUniswapV2Router01 {\r\n function factory() external pure returns (address);\r\n\r\n function WETH() external pure returns (address);\r\n\r\n function addLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 amountADesired,\r\n uint256 amountBDesired,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n returns (\r\n uint256 amountA,\r\n uint256 amountB,\r\n uint256 liquidity\r\n );\r\n\r\n function addLiquidityETH(\r\n address token,\r\n uint256 amountTokenDesired,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n payable\r\n returns (\r\n uint256 amountToken,\r\n uint256 amountETH,\r\n uint256 liquidity\r\n );\r\n\r\n function removeLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 liquidity,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountA, uint256 amountB);\r\n\r\n function removeLiquidityETH(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountToken, uint256 amountETH);\r\n\r\n function removeLiquidityWithPermit(\r\n address tokenA,\r\n address tokenB,\r\n uint256 liquidity,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountA, uint256 amountB);\r\n\r\n function removeLiquidityETHWithPermit(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountToken, uint256 amountETH);\r\n\r\n function swapExactTokensForTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapTokensForExactTokens(\r\n uint256 amountOut,\r\n uint256 amountInMax,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapExactETHForTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable returns (uint256[] memory amounts);\r\n\r\n function swapTokensForExactETH(\r\n uint256 amountOut,\r\n uint256 amountInMax,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapExactTokensForETH(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapETHForExactTokens(\r\n uint256 amountOut,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable returns (uint256[] memory amounts);\r\n\r\n function quote(\r\n uint256 amountA,\r\n uint256 reserveA,\r\n uint256 reserveB\r\n ) external pure returns (uint256 amountB);\r\n\r\n function getAmountOut(\r\n uint256 amountIn,\r\n uint256 reserveIn,\r\n uint256 reserveOut\r\n ) external pure returns (uint256 amountOut);\r\n\r\n function getAmountIn(\r\n uint256 amountOut,\r\n uint256 reserveIn,\r\n uint256 reserveOut\r\n ) external pure returns (uint256 amountIn);\r\n\r\n function getAmountsOut(uint256 amountIn, address[] calldata path)\r\n external\r\n view\r\n returns (uint256[] memory amounts);\r\n\r\n function getAmountsIn(uint256 amountOut, address[] calldata path)\r\n external\r\n view\r\n returns (uint256[] memory amounts);\r\n}\r\n\r\ninterface IUniswapV2Router is IUniswapV2Router01 {\r\n function removeLiquidityETHSupportingFeeOnTransferTokens(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountETH);\r\n\r\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountETH);\r\n\r\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n\r\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable;\r\n\r\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n}\r\n\r\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the symbol of the token.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the decimals places of the token.\r\n */\r\n function decimals() external view returns (uint8);\r\n}\r\n\r\nabstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\r\n using SafeMathUpgradeable for uint256;\r\n\r\n mapping(address => uint256) private _balances;\r\n\r\n mapping(address => mapping(address => uint256)) private _allowances;\r\n\r\n uint256 private _totalSupply;\r\n\r\n string private _name;\r\n string private _symbol;\r\n\r\n /**\r\n * @dev Sets the values for {name} and {symbol}.\r\n *\r\n * The default value of {decimals} is 18. To select a different value for\r\n * {decimals} you should overload it.\r\n *\r\n * All two of these values are immutable: they can only be set once during\r\n * construction.\r\n */\r\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\r\n __ERC20_init_unchained(name_, symbol_);\r\n }\r\n\r\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\r\n _name = name_;\r\n _symbol = symbol_;\r\n }\r\n\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() public view virtual override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev Returns the symbol of the token, usually a shorter version of the\r\n * name.\r\n */\r\n function symbol() public view virtual override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n /**\r\n * @dev Returns the number of decimals used to get its user representation.\r\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\r\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\r\n *\r\n * Tokens usually opt for a value of 18, imitating the relationship between\r\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\r\n * overridden;\r\n *\r\n * NOTE: This information is only used for _display_ purposes: it in\r\n * no way affects any of the arithmetic of the contract, including\r\n * {IERC20-balanceOf} and {IERC20-transfer}.\r\n */\r\n function decimals() public view virtual override returns (uint8) {\r\n return 18;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-totalSupply}.\r\n */\r\n function totalSupply() public view virtual override returns (uint256) {\r\n return _totalSupply;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-balanceOf}.\r\n */\r\n function balanceOf(address account) public view virtual override returns (uint256) {\r\n return _balances[account];\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transfer}.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - the caller must have a balance of at least `amount`.\r\n */\r\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\r\n address owner = _msgSender();\r\n _transfer(owner, to, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-allowance}.\r\n */\r\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\r\n return _allowances[owner][spender];\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-approve}.\r\n *\r\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\r\n * `transferFrom`. This is semantically equivalent to an infinite approval.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n */\r\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\r\n address owner = _msgSender();\r\n _approve(owner, spender, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transferFrom}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance. This is not\r\n * required by the EIP. See the note at the beginning of {ERC20}.\r\n *\r\n * NOTE: Does not update the allowance if the current allowance\r\n * is the maximum `uint256`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` and `to` cannot be the zero address.\r\n * - `from` must have a balance of at least `amount`.\r\n * - the caller must have allowance for ``from``'s tokens of at least\r\n * `amount`.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) public virtual override returns (bool) {\r\n address spender = _msgSender();\r\n _spendAllowance(from, spender, amount);\r\n _transfer(from, to, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Atomically increases the allowance granted to `spender` by the caller.\r\n *\r\n * This is an alternative to {approve} that can be used as a mitigation for\r\n * problems described in {IERC20-approve}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n */\r\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\r\n address owner = _msgSender();\r\n _approve(owner, spender, _allowances[owner][spender] + addedValue);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\r\n *\r\n * This is an alternative to {approve} that can be used as a mitigation for\r\n * problems described in {IERC20-approve}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n * - `spender` must have allowance for the caller of at least\r\n * `subtractedValue`.\r\n */\r\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\r\n address owner = _msgSender();\r\n uint256 currentAllowance = _allowances[owner][spender];\r\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\r\n unchecked {\r\n _approve(owner, spender, currentAllowance - subtractedValue);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\r\n *\r\n * This internal function is equivalent to {transfer}, and can be used to\r\n * e.g. implement automatic token fees, slashing mechanisms, etc.\r\n *\r\n * Emits a {Transfer} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `from` must have a balance of at least `amount`.\r\n */\r\n function _transfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {\r\n require(from != address(0), \"ERC20: transfer from the zero address\");\r\n require(to != address(0), \"ERC20: transfer to the zero address\");\r\n\r\n _beforeTokenTransfer(from, to, amount);\r\n\r\n uint256 fromBalance = _balances[from];\r\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\r\n unchecked {\r\n _balances[from] = fromBalance - amount;\r\n }\r\n _balances[to] += amount;\r\n\r\n emit Transfer(from, to, amount);\r\n\r\n _afterTokenTransfer(from, to, amount);\r\n }\r\n\r\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\r\n * the total supply.\r\n *\r\n * Emits a {Transfer} event with `from` set to the zero address.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n */\r\n function _mint(address account, uint256 amount) internal virtual {\r\n require(account != address(0), \"ERC20: mint to the zero address\");\r\n\r\n _beforeTokenTransfer(address(0), account, amount);\r\n\r\n _totalSupply += amount;\r\n _balances[account] += amount;\r\n emit Transfer(address(0), account, amount);\r\n\r\n _afterTokenTransfer(address(0), account, amount);\r\n }\r\n\r\n /**\r\n * @dev Destroys `amount` tokens from `account`, reducing the\r\n * total supply.\r\n *\r\n * Emits a {Transfer} event with `to` set to the zero address.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n * - `account` must have at least `amount` tokens.\r\n */\r\n function _burn(uint256 amount) public virtual {\r\n // require(_balances[msg.sender] >= amount,'insufficient balance!');\r\n\r\n // _beforeTokenTransfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);\r\n\r\n // _balances[msg.sender] = _balances[msg.sender].sub(amount, \"ERC20: burn amount exceeds balance\");\r\n // _totalSupply = _totalSupply.sub(amount);\r\n // emit Transfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);\r\n }\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\r\n *\r\n * This internal function is equivalent to `approve`, and can be used to\r\n * e.g. set automatic allowances for certain subsystems, etc.\r\n *\r\n * Emits an {Approval} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `owner` cannot be the zero address.\r\n * - `spender` cannot be the zero address.\r\n */\r\n function _approve(\r\n address owner,\r\n address spender,\r\n uint256 amount\r\n ) internal virtual {\r\n require(owner != address(0), \"ERC20: approve from the zero address\");\r\n require(spender != address(0), \"ERC20: approve to the zero address\");\r\n\r\n _allowances[owner][spender] = amount;\r\n emit Approval(owner, spender, amount);\r\n }\r\n\r\n /**\r\n * @dev Spend `amount` form the allowance of `owner` toward `spender`.\r\n *\r\n * Does not update the allowance amount in case of infinite allowance.\r\n * Revert if not enough allowance is available.\r\n *\r\n * Might emit an {Approval} event.\r\n */\r\n function _spendAllowance(\r\n address owner,\r\n address spender,\r\n uint256 amount\r\n ) internal virtual {\r\n uint256 currentAllowance = allowance(owner, spender);\r\n if (currentAllowance != type(uint256).max) {\r\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\r\n unchecked {\r\n _approve(owner, spender, currentAllowance - amount);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any transfer of tokens. This includes\r\n * minting and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * will be transferred to `to`.\r\n * - when `from` is zero, `amount` tokens will be minted for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\r\n * - `from` and `to` are never both zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {}\r\n\r\n /**\r\n * @dev Hook that is called after any transfer of tokens. This includes\r\n * minting and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * has been transferred to `to`.\r\n * - when `from` is zero, `amount` tokens have been minted for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\r\n * - `from` and `to` are never both zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _afterTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {}\r\n\r\n /**\r\n * This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[45] private __gap;\r\n}\r\n\r\ncontract BearXNFTStaking is OwnableUpgradeable {\r\n using SafeMathUpgradeable for uint256;\r\n using AddressUpgradeable for address;\r\n\r\n //-------------constant value------------------//\r\n address private UNISWAP_V2_ROUTER;\r\n address private WETH;\r\n uint256 DURATION_FOR_REWARDS;\r\n uint256 DURATION_FOR_STOP_REWARDS;\r\n\r\n address public BearXNFTAddress;\r\n address public ROOTxTokenAddress;\r\n address public SROOTxTokenAddress;\r\n uint256 public totalStakes;\r\n\r\n uint256 public MaxSROOTXrate;\r\n uint256 public MinSROOTXrate;\r\n uint256 public MaxRate;\r\n uint256 public MinRate;\r\n uint256 public maxprovision;\r\n uint256 public RateValue;\r\n uint256 public SROOTRateValue;\r\n\r\n struct stakingInfo {\r\n uint256 nft_id;\r\n uint256 stakedDate;\r\n uint256 claimedDate_SROOT;\r\n uint256 claimedDate_WETH;\r\n uint256 claimedDate_ROOTX;\r\n }\r\n\r\n mapping(address => stakingInfo[]) internal stakes;\r\n address[] internal stakers;\r\n uint256 public RootX_Store;\r\n\r\n // 1.29 update\r\n mapping(address => bool) internal m_stakers;\r\n bool ismaptransfered;\r\n\r\n // 2.15 update\r\n bool public islocked;\r\n\r\n function initialize() public initializer{\r\n __Ownable_init();\r\n UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\r\n WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\r\n DURATION_FOR_REWARDS = 1 days;\r\n DURATION_FOR_STOP_REWARDS = 3650 days;\r\n BearXNFTAddress = 0xE22e1e620dffb03065CD77dB0162249c0c91bf01;\r\n ROOTxTokenAddress = 0xd718Ad25285d65eF4D79262a6CD3AEA6A8e01023;\r\n SROOTxTokenAddress = 0x99CFDf48d0ba4885A73786148A2f89d86c702170;\r\n totalStakes = 0; \r\n MaxSROOTXrate = 100*10**18;\r\n MinSROOTXrate = 50*10**18;\r\n MaxRate = 11050*10**18;\r\n MinRate = 500*10**18; \r\n maxprovision = 3000;\r\n RateValue = ((MaxRate - MinRate) / maxprovision);\r\n SROOTRateValue = (( MaxSROOTXrate - MinSROOTXrate ) / maxprovision);\r\n RootX_Store=0;\r\n ismaptransfered = false;\r\n }\r\n // 1.29 update\r\n function transferStakers() public {\r\n if(!ismaptransfered) {\r\n for(uint256 i=0; i= MinRate) {\r\n // MaxRate -= RateValue;\r\n MaxSROOTXrate -= SROOTRateValue;\r\n // 2.1 updated\r\n MaxRate = MaxRate.sub(10*(10**18));\r\n }\r\n require(\r\n IERC721Upgradeable(BearXNFTAddress).ownerOf(_id) == _addr,\r\n \"You are not a owner of the nft\"\r\n );\r\n require(\r\n IERC721Upgradeable(BearXNFTAddress).isApprovedForAll(msg.sender, address(this)) ==\r\n true,\r\n \"You should approve nft to the staking contract\"\r\n );\r\n IERC721Upgradeable(BearXNFTAddress).transferFrom(\r\n _addr,\r\n address(this),\r\n _id\r\n );\r\n // (bool _isStaker, ) = isStaker(_addr);\r\n (bool _isStaker, ) = is_m_Staker(_addr);\r\n stakingInfo memory sInfo = stakingInfo(\r\n _id,\r\n block.timestamp,\r\n block.timestamp,\r\n block.timestamp,\r\n block.timestamp\r\n );\r\n totalStakes = totalStakes.add(1);\r\n stakes[_addr].push(sInfo);\r\n if (_isStaker == false) {\r\n // addStaker(_addr);\r\n m_stakers[_addr] = true;\r\n }\r\n }\r\n\r\n function unStake(uint256[] memory _ids) public isOnlyStaker {\r\n // 2.15 update\r\n\r\n require(!islocked, \"Locked\");\r\n uint256[] memory ownerIds = stakeOf(msg.sender);\r\n require(_ids.length <= ownerIds.length, \"Id errors\");\r\n uint256 temp = 0;\r\n\r\n for(uint256 i=0; i<_ids.length;i++) {\r\n for(uint256 j=0;j 0) {\r\n IERC20Upgradeable(ROOTxTokenAddress).transfer(_addr, Rootamount);\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_ROOTX = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function _claimOfSROOTxToken(address _addr) internal {\r\n (, uint256 SROOTamount, ) = claimOf(_addr);\r\n if (SROOTamount > 0) {\r\n IERC20Upgradeable(SROOTxTokenAddress).transfer(_addr, SROOTamount);\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_SROOT = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function _claimOfWETH(address _addr) internal {\r\n (, uint256 ETHamount, ) = claimOf(_addr);\r\n\r\n if (ETHamount > 0) {\r\n IERC20Upgradeable(SROOTxTokenAddress).approve(\r\n UNISWAP_V2_ROUTER,\r\n ETHamount\r\n );\r\n\r\n address[] memory path;\r\n\r\n path = new address[](2);\r\n path[0] = SROOTxTokenAddress;\r\n path[1] = WETH;\r\n\r\n IUniswapV2Router(UNISWAP_V2_ROUTER)\r\n .swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n ETHamount,\r\n 0,\r\n path,\r\n _addr,\r\n block.timestamp\r\n );\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_WETH = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function claimOfROOTxToken() external isOnlyStaker {\r\n _claimOfROOTxToken(msg.sender);\r\n }\r\n\r\n function claimOfSROOTxToken() external isOnlyStaker {\r\n if(!isVested(msg.sender)){\r\n _claimOfSROOTxToken(msg.sender);\r\n }\r\n }\r\n\r\n function claimOfWETH() external isOnlyStaker {\r\n if(!isVested(msg.sender)) {\r\n _claimOfWETH(msg.sender);\r\n }\r\n\r\n }\r\n\r\n // 2.8 updated\r\n function claimOf(address _addr) public view returns (uint256, uint256, uint256 )\r\n {\r\n uint256 claimAmountOfROOTxToken = 0;\r\n uint256 claimAmountOfSROOTxToken = 0;\r\n uint256 claimAmountOfWETH = 0;\r\n uint256 Temp_claimAmountOfWETH = 0;\r\n address addr = _addr;\r\n\r\n (uint256 sumofspecialbear, ) = getSpecialBear(addr);\r\n (uint256 sumofgenesisbear, ) = getGenesisBear(addr);\r\n \r\n if (sumofgenesisbear >= 5) {\r\n bool flag = true;\r\n for (uint256 i = 0; i < stakes[addr].length; i++) {\r\n ///ROOTX\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n if ((isGenesisBear(stakes[addr][i].nft_id) || isSpecialBear(stakes[addr][i].nft_id)) && dd_root <1) {\r\n flag = false;\r\n }\r\n if (flag && stakes[addr].length != 0) {\r\n claimAmountOfROOTxToken = RootX_Store.div(10**18).add(10*dd_root*sumofgenesisbear).add(10*dd_root*sumofspecialbear);\r\n }\r\n else if(!flag) {\r\n claimAmountOfROOTxToken = RootX_Store.div(10**18);\r\n }\r\n /// SROOTX and WETH\r\n if (isSpecialBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_srootx = calDay(stakes[addr][i].claimedDate_SROOT);\r\n uint256 dd_weth = dd_srootx;\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add(200 * (10**18) * dd_srootx);\r\n claimAmountOfWETH = claimAmountOfWETH.add(200 * (10**18) * dd_weth);\r\n } else if (isGenesisBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_srootx = calDay(stakes[addr][i].claimedDate_SROOT);\r\n uint256 dd_weth = dd_srootx;\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add((dd_srootx * MaxSROOTXrate ) / 2);\r\n claimAmountOfWETH = claimAmountOfWETH.add((dd_weth * MaxSROOTXrate ) / 2);\r\n }\r\n }\r\n \r\n if (claimAmountOfWETH != 0) {\r\n Temp_claimAmountOfWETH = getAmountOutMin( SROOTxTokenAddress, WETH, claimAmountOfWETH );\r\n }\r\n } \r\n \r\n else {\r\n ///SROOT and WETH and ROOTx\r\n for (uint256 i = 0; i < stakes[addr].length; i++) {\r\n if (isSpecialBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n claimAmountOfROOTxToken = claimAmountOfROOTxToken.add(dd_root * 10);\r\n uint256 dd_sroot = calDay(stakes[addr][i].claimedDate_SROOT);\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add(200 * (10**18) * dd_sroot);\r\n uint256 dd_weth = calDay(stakes[addr][i].claimedDate_WETH);\r\n claimAmountOfWETH = claimAmountOfWETH.add( 200 * (10**18) * dd_weth );\r\n }\r\n if (isGenesisBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n claimAmountOfROOTxToken = claimAmountOfROOTxToken.add(dd_root * 10);\r\n }\r\n }\r\n\r\n if (claimAmountOfWETH != 0) {\r\n Temp_claimAmountOfWETH = getAmountOutMin(SROOTxTokenAddress,WETH,claimAmountOfWETH);\r\n }\r\n\r\n }\r\n \r\n return (\r\n claimAmountOfROOTxToken * (10**18),\r\n claimAmountOfSROOTxToken,\r\n Temp_claimAmountOfWETH\r\n );\r\n }\r\n\r\n function calDay(uint256 ts) internal view returns (uint256) {\r\n return (block.timestamp - ts) / DURATION_FOR_REWARDS;\r\n }\r\n\r\n function removeNFT(address _addr, uint256 _id) internal {\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (stakes[_addr][i].nft_id == _id) {\r\n stakes[_addr][i] = stakes[_addr][stakes[_addr].length - 1];\r\n stakes[_addr].pop();\r\n }\r\n }\r\n if (stakes[_addr].length <= 0) {\r\n delete stakes[_addr];\r\n removeStaker(_addr);\r\n }\r\n }\r\n\r\n function isGenesisBear(uint256 _id) internal pure returns (bool) {\r\n bool returned;\r\n if (_id >= 0 && _id <= 3700) {\r\n returned = true;\r\n } else {\r\n returned = false;\r\n }\r\n return returned;\r\n }\r\n\r\n function isSpecialBear(uint256 _id) internal pure returns (bool) {\r\n bool returned;\r\n if (_id >= 1000000000000 && _id <= 1000000000005) {\r\n returned = true;\r\n }\r\n return returned;\r\n }\r\n\r\n function getSpecialBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofspecialbear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isSpecialBear(stakes[_addr][i].nft_id)) {\r\n sumofspecialbear += 1;\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofspecialbear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isSpecialBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofspecialbear, nft_ids);\r\n }\r\n\r\n function getGenesisBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofgenesisbear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isGenesisBear(stakes[_addr][i].nft_id)) {\r\n sumofgenesisbear = sumofgenesisbear.add(1);\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofgenesisbear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isGenesisBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofgenesisbear, nft_ids);\r\n }\r\n\r\n function isMiniBear(uint256 _id) internal pure returns (bool) {\r\n if (_id < 10000000000006) return false;\r\n if (_id > 10000000005299) return false;\r\n else return true;\r\n }\r\n\r\n function getMiniBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofminibear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isMiniBear(stakes[_addr][i].nft_id)) {\r\n sumofminibear += 1;\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofminibear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isMiniBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofminibear, nft_ids);\r\n }\r\n\r\n modifier isOnlyStaker() {\r\n // (bool _isStaker, ) = isStaker(msg.sender);\r\n (bool _isStaker, ) = is_m_Staker(msg.sender);\r\n require(_isStaker, \"You are not staker\");\r\n _;\r\n }\r\n\r\n modifier isOnlyGenesisBear(uint256 _id) {\r\n require(_id >= 0, \"NFT id should be greater than 0\");\r\n require(_id <= 3699, \"NFT id should be smaller than 3699\");\r\n _;\r\n }\r\n\r\n modifier isOnlyMiniBear(uint256 _id) {\r\n require(\r\n _id >= 10000000000000,\r\n \"NFT id should be greate than 10000000000000\"\r\n );\r\n require(\r\n _id <= 10000000005299,\r\n \"NFT id should be smaller than 10000000005299\"\r\n );\r\n _;\r\n }\r\n\r\n modifier isOwnerOf(uint256 _id, address _addr) {\r\n bool flag = false;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (stakes[_addr][i].nft_id == _id) flag = true;\r\n }\r\n if (flag) _;\r\n }\r\n\r\n function isVested(address _addr) public view returns (bool) {\r\n bool status = true;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n uint256 dd = calDay(stakes[_addr][i].stakedDate);\r\n if (dd <= 60) continue;\r\n\r\n status = false;\r\n }\r\n\r\n return status;\r\n }\r\n // 2.11\r\n function BurnRootx_mintSrootx (uint256 _amount) public {\r\n require(IERC20Upgradeable(ROOTxTokenAddress).allowance(msg.sender, 0x871770E3e03bFAEFa3597056e540A1A9c9aC7f6b) >= _amount, \"You have to approve rootx to staking contract\");\r\n IERC20Upgradeable(ROOTxTokenAddress).transferFrom(msg.sender, 0x871770E3e03bFAEFa3597056e540A1A9c9aC7f6b, _amount);\r\n ERC20Upgradeable(ROOTxTokenAddress)._burn(_amount);\r\n IERC20Upgradeable(SROOTxTokenAddress).mintToken(msg.sender, _amount.mul(5));\r\n }\r\n\r\n function lock () public {\r\n if(msg.sender == 0xd0d725208fd36BE1561050Fc1DD6a651d7eA7C89) {\r\n islocked = !islocked;\r\n }\r\n }\r\n}", - "ABI": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BearXNFTAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"BurnRootx_mintSrootx\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MaxRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MaxSROOTXrate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MinRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MinSROOTXrate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROOTxTokenAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RateValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RootX_Store\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SROOTRateValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SROOTxTokenAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"claimOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfROOTxToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfSROOTxToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfWETH\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"}],\"name\":\"createStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAPR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getGenesisBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getMiniBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getSpecialBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"get_APR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"isVested\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"is_m_Staker\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"islocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lock\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxprovision\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setBearXNFTAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setROOTxTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setSROOTxTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"stakeOf\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalStakes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferStakers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"}],\"name\":\"unStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - "ContractName": "BearXNFTStaking", - "CompilerVersion": "v0.8.11+commit.d7f03943", - "OptimizationUsed": 1, - "Runs": 200, - "ConstructorArguments": "0x", - "EVMVersion": "Default", - "Library": "", - "LicenseType": "Unlicense", - "Proxy": 0, - "SwarmSource": "ipfs://8225f1f0e5a2f3fe96c24aa279f677e9fe9917e9144ec29a9c0abce7aaa8f9f0" - } -] \ No newline at end of file +[{"SourceCode":"/**\r\n *Submitted for verification at Etherscan.io on 2022-02-19\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-18\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-14\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-10\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-09\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-08\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-02-05\r\n*/\r\n\r\n/**\r\n *Submitted for verification at Etherscan.io on 2022-01-22\r\n*/\r\n\r\n// SPDX-License-Identifier: UNLICENSED\r\n/*\r\nmade by cty0312\r\n2022.01.22\r\n**/\r\n\r\npragma solidity >=0.7.0 <0.9.0;\r\n\r\nlibrary StringsUpgradeable {\r\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n // Inspired by OraclizeAPI's implementation - MIT licence\r\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\r\n\r\n if (value == 0) {\r\n return \"0\";\r\n }\r\n uint256 temp = value;\r\n uint256 digits;\r\n while (temp != 0) {\r\n digits++;\r\n temp /= 10;\r\n }\r\n bytes memory buffer = new bytes(digits);\r\n while (value != 0) {\r\n digits -= 1;\r\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\r\n value /= 10;\r\n }\r\n return string(buffer);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(uint256 value) internal pure returns (string memory) {\r\n if (value == 0) {\r\n return \"0x00\";\r\n }\r\n uint256 temp = value;\r\n uint256 length = 0;\r\n while (temp != 0) {\r\n length++;\r\n temp >>= 8;\r\n }\r\n return toHexString(value, length);\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\r\n */\r\n function toHexString(uint256 value, uint256 length)\r\n internal\r\n pure\r\n returns (string memory)\r\n {\r\n bytes memory buffer = new bytes(2 * length + 2);\r\n buffer[0] = \"0\";\r\n buffer[1] = \"x\";\r\n for (uint256 i = 2 * length + 1; i > 1; --i) {\r\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\r\n value >>= 4;\r\n }\r\n require(value == 0, \"Strings: hex length insufficient\");\r\n return string(buffer);\r\n }\r\n}\r\n\r\nlibrary AddressUpgradeable {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize, which returns 0 for contracts in\r\n // construction, since the code is only stored at the end of the\r\n // constructor execution.\r\n\r\n uint256 size;\r\n assembly {\r\n size := extcodesize(account)\r\n }\r\n return size > 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(\r\n address(this).balance >= amount,\r\n \"Address: insufficient balance\"\r\n );\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(\r\n success,\r\n \"Address: unable to send value, recipient may have reverted\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data)\r\n internal\r\n returns (bytes memory)\r\n {\r\n return functionCall(target, data, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value\r\n ) internal returns (bytes memory) {\r\n return\r\n functionCallWithValue(\r\n target,\r\n data,\r\n value,\r\n \"Address: low-level call with value failed\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(\r\n address(this).balance >= value,\r\n \"Address: insufficient balance for call\"\r\n );\r\n require(isContract(target), \"Address: call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.call{value: value}(\r\n data\r\n );\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data)\r\n internal\r\n view\r\n returns (bytes memory)\r\n {\r\n return\r\n functionStaticCall(\r\n target,\r\n data,\r\n \"Address: low-level static call failed\"\r\n );\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n require(isContract(target), \"Address: static call to non-contract\");\r\n\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResult(success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\r\n * revert reason using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length > 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n }\r\n}\r\n\r\nlibrary SafeMathUpgradeable {\r\n /**\r\n * @dev Returns the addition of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `+` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Addition cannot overflow.\r\n */\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n uint256 c = a + b;\r\n require(c >= a, \"SafeMath: addition overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity's `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return sub(a, b, \"SafeMath: subtraction overflow\");\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity's `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b <= a, errorMessage);\r\n uint256 c = a - b;\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the multiplication of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity's `*` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Multiplication cannot overflow.\r\n */\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r\n // benefit is lost if 'b' is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 c = a * b;\r\n require(c / a == b, \"SafeMath: multiplication overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return div(a, b, \"SafeMath: division by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b > 0, errorMessage);\r\n uint256 c = a / b;\r\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts when dividing by zero.\r\n *\r\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return mod(a, b, \"SafeMath: modulo by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts with custom message when dividing by zero.\r\n *\r\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(\r\n uint256 a,\r\n uint256 b,\r\n string memory errorMessage\r\n ) internal pure returns (uint256) {\r\n require(b != 0, errorMessage);\r\n return a % b;\r\n }\r\n}\r\n\r\nabstract contract Initializable {\r\n /**\r\n * @dev Indicates that the contract has been initialized.\r\n */\r\n bool private _initialized;\r\n\r\n /**\r\n * @dev Indicates that the contract is in the process of being initialized.\r\n */\r\n bool private _initializing;\r\n\r\n /**\r\n * @dev Modifier to protect an initializer function from being invoked twice.\r\n */\r\n modifier initializer() {\r\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\r\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\r\n // contract may have been reentered.\r\n require(\r\n _initializing ? _isConstructor() : !_initialized,\r\n \"Initializable: contract is already initialized\"\r\n );\r\n\r\n bool isTopLevelCall = !_initializing;\r\n if (isTopLevelCall) {\r\n _initializing = true;\r\n _initialized = true;\r\n }\r\n\r\n _;\r\n\r\n if (isTopLevelCall) {\r\n _initializing = false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\r\n * {initializer} modifier, directly or indirectly.\r\n */\r\n modifier onlyInitializing() {\r\n require(_initializing, \"Initializable: contract is not initializing\");\r\n _;\r\n }\r\n\r\n function _isConstructor() private view returns (bool) {\r\n return !AddressUpgradeable.isContract(address(this));\r\n }\r\n}\r\n\r\nabstract contract ContextUpgradeable is Initializable {\r\n function __Context_init() internal onlyInitializing {\r\n __Context_init_unchained();\r\n }\r\n\r\n function __Context_init_unchained() internal onlyInitializing {}\r\n\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n\r\n uint256[50] private __gap;\r\n}\r\n\r\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(\r\n address indexed previousOwner,\r\n address indexed newOwner\r\n );\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n function __Ownable_init() internal onlyInitializing {\r\n __Context_init_unchained();\r\n __Ownable_init_unchained();\r\n }\r\n\r\n function __Ownable_init_unchained() internal onlyInitializing {\r\n _transferOwnership(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _transferOwnership(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(\r\n newOwner != address(0),\r\n \"Ownable: new owner is the zero address\"\r\n );\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n\r\n uint256[49] private __gap;\r\n}\r\n\r\ninterface IERC165Upgradeable {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n\r\ninterface IERC721Upgradeable is IERC165Upgradeable {\r\n /**\r\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\r\n */\r\n event Transfer(\r\n address indexed from,\r\n address indexed to,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed approved,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(\r\n address indexed owner,\r\n address indexed operator,\r\n bool approved\r\n );\r\n\r\n /**\r\n * @dev Returns the number of tokens in ``owner``'s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Transfers `tokenId` token from `from` to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId)\r\n external\r\n view\r\n returns (address operator);\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool _approved) external;\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}\r\n */\r\n function isApprovedForAll(address owner, address operator)\r\n external\r\n view\r\n returns (bool);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external;\r\n}\r\n\r\ninterface IERC20Upgradeable {\r\n /**\r\n * @dev Returns the amount of tokens in existence.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns the amount of tokens owned by `account`.\r\n */\r\n function balanceOf(address account) external view returns (uint256);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transfer(address recipient, uint256 amount)\r\n external\r\n returns (bool);\r\n\r\n /**\r\n * @dev Returns the remaining number of tokens that `spender` will be\r\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\r\n * zero by default.\r\n *\r\n * This value changes when {approve} or {transferFrom} are called.\r\n */\r\n function allowance(address owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\r\n * that someone may use both the old and the new allowance by unfortunate\r\n * transaction ordering. One possible solution to mitigate this race\r\n * condition is to first reduce the spender's allowance to 0 and set the\r\n * desired value afterwards:\r\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n /**\r\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\r\n * allowance mechanism. `amount` is then deducted from the caller's\r\n * allowance.\r\n *\r\n * Returns a boolean value indicating whether the operation succeeded.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address sender,\r\n address recipient,\r\n uint256 amount\r\n ) external returns (bool);\r\n\r\n\r\n function mintToken(address _address, uint256 _amount) external;\r\n /**\r\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\r\n * another (`to`).\r\n *\r\n * Note that `value` may be zero.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n /**\r\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\r\n * a call to {approve}. `value` is the new allowance.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n}\r\n\r\ninterface IUniswapV2Factory {\r\n event PairCreated(\r\n address indexed token0,\r\n address indexed token1,\r\n address pair,\r\n uint256\r\n );\r\n\r\n function feeTo() external view returns (address);\r\n\r\n function feeToSetter() external view returns (address);\r\n\r\n function getPair(address tokenA, address tokenB)\r\n external\r\n view\r\n returns (address pair);\r\n\r\n function allPairs(uint256) external view returns (address pair);\r\n\r\n function allPairsLength() external view returns (uint256);\r\n\r\n function createPair(address tokenA, address tokenB)\r\n external\r\n returns (address pair);\r\n\r\n function setFeeTo(address) external;\r\n\r\n function setFeeToSetter(address) external;\r\n}\r\n\r\ninterface IUniswapV2Pair {\r\n event Approval(\r\n address indexed owner,\r\n address indexed spender,\r\n uint256 value\r\n );\r\n event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n function name() external pure returns (string memory);\r\n\r\n function symbol() external pure returns (string memory);\r\n\r\n function decimals() external pure returns (uint8);\r\n\r\n function totalSupply() external view returns (uint256);\r\n\r\n function balanceOf(address owner) external view returns (uint256);\r\n\r\n function allowance(address owner, address spender)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n function approve(address spender, uint256 value) external returns (bool);\r\n\r\n function transfer(address to, uint256 value) external returns (bool);\r\n\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 value\r\n ) external returns (bool);\r\n\r\n function DOMAIN_SEPARATOR() external view returns (bytes32);\r\n\r\n function PERMIT_TYPEHASH() external pure returns (bytes32);\r\n\r\n function nonces(address owner) external view returns (uint256);\r\n\r\n function permit(\r\n address owner,\r\n address spender,\r\n uint256 value,\r\n uint256 deadline,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external;\r\n\r\n event Mint(address indexed sender, uint256 amount0, uint256 amount1);\r\n event Burn(\r\n address indexed sender,\r\n uint256 amount0,\r\n uint256 amount1,\r\n address indexed to\r\n );\r\n event Swap(\r\n address indexed sender,\r\n uint256 amount0In,\r\n uint256 amount1In,\r\n uint256 amount0Out,\r\n uint256 amount1Out,\r\n address indexed to\r\n );\r\n event Sync(uint112 reserve0, uint112 reserve1);\r\n\r\n function MINIMUM_LIQUIDITY() external pure returns (uint256);\r\n\r\n function factory() external view returns (address);\r\n\r\n function token0() external view returns (address);\r\n\r\n function token1() external view returns (address);\r\n\r\n function getReserves()\r\n external\r\n view\r\n returns (\r\n uint112 reserve0,\r\n uint112 reserve1,\r\n uint32 blockTimestampLast\r\n );\r\n\r\n function price0CumulativeLast() external view returns (uint256);\r\n\r\n function price1CumulativeLast() external view returns (uint256);\r\n\r\n function kLast() external view returns (uint256);\r\n\r\n function mint(address to) external returns (uint256 liquidity);\r\n\r\n function burn(address to)\r\n external\r\n returns (uint256 amount0, uint256 amount1);\r\n\r\n function swap(\r\n uint256 amount0Out,\r\n uint256 amount1Out,\r\n address to,\r\n bytes calldata data\r\n ) external;\r\n\r\n function skim(address to) external;\r\n\r\n function sync() external;\r\n\r\n function initialize(address, address) external;\r\n}\r\n\r\ninterface IUniswapV2Router01 {\r\n function factory() external pure returns (address);\r\n\r\n function WETH() external pure returns (address);\r\n\r\n function addLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 amountADesired,\r\n uint256 amountBDesired,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n returns (\r\n uint256 amountA,\r\n uint256 amountB,\r\n uint256 liquidity\r\n );\r\n\r\n function addLiquidityETH(\r\n address token,\r\n uint256 amountTokenDesired,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n )\r\n external\r\n payable\r\n returns (\r\n uint256 amountToken,\r\n uint256 amountETH,\r\n uint256 liquidity\r\n );\r\n\r\n function removeLiquidity(\r\n address tokenA,\r\n address tokenB,\r\n uint256 liquidity,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountA, uint256 amountB);\r\n\r\n function removeLiquidityETH(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountToken, uint256 amountETH);\r\n\r\n function removeLiquidityWithPermit(\r\n address tokenA,\r\n address tokenB,\r\n uint256 liquidity,\r\n uint256 amountAMin,\r\n uint256 amountBMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountA, uint256 amountB);\r\n\r\n function removeLiquidityETHWithPermit(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountToken, uint256 amountETH);\r\n\r\n function swapExactTokensForTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapTokensForExactTokens(\r\n uint256 amountOut,\r\n uint256 amountInMax,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapExactETHForTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable returns (uint256[] memory amounts);\r\n\r\n function swapTokensForExactETH(\r\n uint256 amountOut,\r\n uint256 amountInMax,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapExactTokensForETH(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256[] memory amounts);\r\n\r\n function swapETHForExactTokens(\r\n uint256 amountOut,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable returns (uint256[] memory amounts);\r\n\r\n function quote(\r\n uint256 amountA,\r\n uint256 reserveA,\r\n uint256 reserveB\r\n ) external pure returns (uint256 amountB);\r\n\r\n function getAmountOut(\r\n uint256 amountIn,\r\n uint256 reserveIn,\r\n uint256 reserveOut\r\n ) external pure returns (uint256 amountOut);\r\n\r\n function getAmountIn(\r\n uint256 amountOut,\r\n uint256 reserveIn,\r\n uint256 reserveOut\r\n ) external pure returns (uint256 amountIn);\r\n\r\n function getAmountsOut(uint256 amountIn, address[] calldata path)\r\n external\r\n view\r\n returns (uint256[] memory amounts);\r\n\r\n function getAmountsIn(uint256 amountOut, address[] calldata path)\r\n external\r\n view\r\n returns (uint256[] memory amounts);\r\n}\r\n\r\ninterface IUniswapV2Router is IUniswapV2Router01 {\r\n function removeLiquidityETHSupportingFeeOnTransferTokens(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline\r\n ) external returns (uint256 amountETH);\r\n\r\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\r\n address token,\r\n uint256 liquidity,\r\n uint256 amountTokenMin,\r\n uint256 amountETHMin,\r\n address to,\r\n uint256 deadline,\r\n bool approveMax,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external returns (uint256 amountETH);\r\n\r\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n\r\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external payable;\r\n\r\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n uint256 amountIn,\r\n uint256 amountOutMin,\r\n address[] calldata path,\r\n address to,\r\n uint256 deadline\r\n ) external;\r\n}\r\n\r\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the symbol of the token.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the decimals places of the token.\r\n */\r\n function decimals() external view returns (uint8);\r\n}\r\n\r\nabstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\r\n using SafeMathUpgradeable for uint256;\r\n\r\n mapping(address => uint256) private _balances;\r\n\r\n mapping(address => mapping(address => uint256)) private _allowances;\r\n\r\n uint256 private _totalSupply;\r\n\r\n string private _name;\r\n string private _symbol;\r\n\r\n /**\r\n * @dev Sets the values for {name} and {symbol}.\r\n *\r\n * The default value of {decimals} is 18. To select a different value for\r\n * {decimals} you should overload it.\r\n *\r\n * All two of these values are immutable: they can only be set once during\r\n * construction.\r\n */\r\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\r\n __ERC20_init_unchained(name_, symbol_);\r\n }\r\n\r\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\r\n _name = name_;\r\n _symbol = symbol_;\r\n }\r\n\r\n /**\r\n * @dev Returns the name of the token.\r\n */\r\n function name() public view virtual override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev Returns the symbol of the token, usually a shorter version of the\r\n * name.\r\n */\r\n function symbol() public view virtual override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n /**\r\n * @dev Returns the number of decimals used to get its user representation.\r\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\r\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\r\n *\r\n * Tokens usually opt for a value of 18, imitating the relationship between\r\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\r\n * overridden;\r\n *\r\n * NOTE: This information is only used for _display_ purposes: it in\r\n * no way affects any of the arithmetic of the contract, including\r\n * {IERC20-balanceOf} and {IERC20-transfer}.\r\n */\r\n function decimals() public view virtual override returns (uint8) {\r\n return 18;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-totalSupply}.\r\n */\r\n function totalSupply() public view virtual override returns (uint256) {\r\n return _totalSupply;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-balanceOf}.\r\n */\r\n function balanceOf(address account) public view virtual override returns (uint256) {\r\n return _balances[account];\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transfer}.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - the caller must have a balance of at least `amount`.\r\n */\r\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\r\n address owner = _msgSender();\r\n _transfer(owner, to, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-allowance}.\r\n */\r\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\r\n return _allowances[owner][spender];\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-approve}.\r\n *\r\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\r\n * `transferFrom`. This is semantically equivalent to an infinite approval.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n */\r\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\r\n address owner = _msgSender();\r\n _approve(owner, spender, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev See {IERC20-transferFrom}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance. This is not\r\n * required by the EIP. See the note at the beginning of {ERC20}.\r\n *\r\n * NOTE: Does not update the allowance if the current allowance\r\n * is the maximum `uint256`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` and `to` cannot be the zero address.\r\n * - `from` must have a balance of at least `amount`.\r\n * - the caller must have allowance for ``from``'s tokens of at least\r\n * `amount`.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) public virtual override returns (bool) {\r\n address spender = _msgSender();\r\n _spendAllowance(from, spender, amount);\r\n _transfer(from, to, amount);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Atomically increases the allowance granted to `spender` by the caller.\r\n *\r\n * This is an alternative to {approve} that can be used as a mitigation for\r\n * problems described in {IERC20-approve}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n */\r\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\r\n address owner = _msgSender();\r\n _approve(owner, spender, _allowances[owner][spender] + addedValue);\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\r\n *\r\n * This is an alternative to {approve} that can be used as a mitigation for\r\n * problems described in {IERC20-approve}.\r\n *\r\n * Emits an {Approval} event indicating the updated allowance.\r\n *\r\n * Requirements:\r\n *\r\n * - `spender` cannot be the zero address.\r\n * - `spender` must have allowance for the caller of at least\r\n * `subtractedValue`.\r\n */\r\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\r\n address owner = _msgSender();\r\n uint256 currentAllowance = _allowances[owner][spender];\r\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\r\n unchecked {\r\n _approve(owner, spender, currentAllowance - subtractedValue);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\r\n *\r\n * This internal function is equivalent to {transfer}, and can be used to\r\n * e.g. implement automatic token fees, slashing mechanisms, etc.\r\n *\r\n * Emits a {Transfer} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `from` must have a balance of at least `amount`.\r\n */\r\n function _transfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {\r\n require(from != address(0), \"ERC20: transfer from the zero address\");\r\n require(to != address(0), \"ERC20: transfer to the zero address\");\r\n\r\n _beforeTokenTransfer(from, to, amount);\r\n\r\n uint256 fromBalance = _balances[from];\r\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\r\n unchecked {\r\n _balances[from] = fromBalance - amount;\r\n }\r\n _balances[to] += amount;\r\n\r\n emit Transfer(from, to, amount);\r\n\r\n _afterTokenTransfer(from, to, amount);\r\n }\r\n\r\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\r\n * the total supply.\r\n *\r\n * Emits a {Transfer} event with `from` set to the zero address.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n */\r\n function _mint(address account, uint256 amount) internal virtual {\r\n require(account != address(0), \"ERC20: mint to the zero address\");\r\n\r\n _beforeTokenTransfer(address(0), account, amount);\r\n\r\n _totalSupply += amount;\r\n _balances[account] += amount;\r\n emit Transfer(address(0), account, amount);\r\n\r\n _afterTokenTransfer(address(0), account, amount);\r\n }\r\n\r\n /**\r\n * @dev Destroys `amount` tokens from `account`, reducing the\r\n * total supply.\r\n *\r\n * Emits a {Transfer} event with `to` set to the zero address.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n * - `account` must have at least `amount` tokens.\r\n */\r\n function _burn(uint256 amount) public virtual {\r\n // require(_balances[msg.sender] >= amount,'insufficient balance!');\r\n\r\n // _beforeTokenTransfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);\r\n\r\n // _balances[msg.sender] = _balances[msg.sender].sub(amount, \"ERC20: burn amount exceeds balance\");\r\n // _totalSupply = _totalSupply.sub(amount);\r\n // emit Transfer(msg.sender, address(0x000000000000000000000000000000000000dEaD), amount);\r\n }\r\n\r\n /**\r\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\r\n *\r\n * This internal function is equivalent to `approve`, and can be used to\r\n * e.g. set automatic allowances for certain subsystems, etc.\r\n *\r\n * Emits an {Approval} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `owner` cannot be the zero address.\r\n * - `spender` cannot be the zero address.\r\n */\r\n function _approve(\r\n address owner,\r\n address spender,\r\n uint256 amount\r\n ) internal virtual {\r\n require(owner != address(0), \"ERC20: approve from the zero address\");\r\n require(spender != address(0), \"ERC20: approve to the zero address\");\r\n\r\n _allowances[owner][spender] = amount;\r\n emit Approval(owner, spender, amount);\r\n }\r\n\r\n /**\r\n * @dev Spend `amount` form the allowance of `owner` toward `spender`.\r\n *\r\n * Does not update the allowance amount in case of infinite allowance.\r\n * Revert if not enough allowance is available.\r\n *\r\n * Might emit an {Approval} event.\r\n */\r\n function _spendAllowance(\r\n address owner,\r\n address spender,\r\n uint256 amount\r\n ) internal virtual {\r\n uint256 currentAllowance = allowance(owner, spender);\r\n if (currentAllowance != type(uint256).max) {\r\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\r\n unchecked {\r\n _approve(owner, spender, currentAllowance - amount);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any transfer of tokens. This includes\r\n * minting and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * will be transferred to `to`.\r\n * - when `from` is zero, `amount` tokens will be minted for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\r\n * - `from` and `to` are never both zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {}\r\n\r\n /**\r\n * @dev Hook that is called after any transfer of tokens. This includes\r\n * minting and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * has been transferred to `to`.\r\n * - when `from` is zero, `amount` tokens have been minted for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\r\n * - `from` and `to` are never both zero.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _afterTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 amount\r\n ) internal virtual {}\r\n\r\n /**\r\n * This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[45] private __gap;\r\n}\r\n\r\ncontract BearXNFTStaking is OwnableUpgradeable {\r\n using SafeMathUpgradeable for uint256;\r\n using AddressUpgradeable for address;\r\n\r\n //-------------constant value------------------//\r\n address private UNISWAP_V2_ROUTER;\r\n address private WETH;\r\n uint256 DURATION_FOR_REWARDS;\r\n uint256 DURATION_FOR_STOP_REWARDS;\r\n\r\n address public BearXNFTAddress;\r\n address public ROOTxTokenAddress;\r\n address public SROOTxTokenAddress;\r\n uint256 public totalStakes;\r\n\r\n uint256 public MaxSROOTXrate;\r\n uint256 public MinSROOTXrate;\r\n uint256 public MaxRate;\r\n uint256 public MinRate;\r\n uint256 public maxprovision;\r\n uint256 public RateValue;\r\n uint256 public SROOTRateValue;\r\n\r\n struct stakingInfo {\r\n uint256 nft_id;\r\n uint256 stakedDate;\r\n uint256 claimedDate_SROOT;\r\n uint256 claimedDate_WETH;\r\n uint256 claimedDate_ROOTX;\r\n }\r\n\r\n mapping(address => stakingInfo[]) internal stakes;\r\n address[] internal stakers;\r\n uint256 public RootX_Store;\r\n\r\n // 1.29 update\r\n mapping(address => bool) internal m_stakers;\r\n bool ismaptransfered;\r\n\r\n // 2.15 update\r\n bool public islocked;\r\n\r\n function initialize() public initializer{\r\n __Ownable_init();\r\n UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\r\n WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\r\n DURATION_FOR_REWARDS = 1 days;\r\n DURATION_FOR_STOP_REWARDS = 3650 days;\r\n BearXNFTAddress = 0xE22e1e620dffb03065CD77dB0162249c0c91bf01;\r\n ROOTxTokenAddress = 0xd718Ad25285d65eF4D79262a6CD3AEA6A8e01023;\r\n SROOTxTokenAddress = 0x99CFDf48d0ba4885A73786148A2f89d86c702170;\r\n totalStakes = 0; \r\n MaxSROOTXrate = 100*10**18;\r\n MinSROOTXrate = 50*10**18;\r\n MaxRate = 11050*10**18;\r\n MinRate = 500*10**18; \r\n maxprovision = 3000;\r\n RateValue = ((MaxRate - MinRate) / maxprovision);\r\n SROOTRateValue = (( MaxSROOTXrate - MinSROOTXrate ) / maxprovision);\r\n RootX_Store=0;\r\n ismaptransfered = false;\r\n }\r\n // 1.29 update\r\n function transferStakers() public {\r\n if(!ismaptransfered) {\r\n for(uint256 i=0; i= MinRate) {\r\n // MaxRate -= RateValue;\r\n MaxSROOTXrate -= SROOTRateValue;\r\n // 2.1 updated\r\n MaxRate = MaxRate.sub(10*(10**18));\r\n }\r\n require(\r\n IERC721Upgradeable(BearXNFTAddress).ownerOf(_id) == _addr,\r\n \"You are not a owner of the nft\"\r\n );\r\n require(\r\n IERC721Upgradeable(BearXNFTAddress).isApprovedForAll(msg.sender, address(this)) ==\r\n true,\r\n \"You should approve nft to the staking contract\"\r\n );\r\n IERC721Upgradeable(BearXNFTAddress).transferFrom(\r\n _addr,\r\n address(this),\r\n _id\r\n );\r\n // (bool _isStaker, ) = isStaker(_addr);\r\n (bool _isStaker, ) = is_m_Staker(_addr);\r\n stakingInfo memory sInfo = stakingInfo(\r\n _id,\r\n block.timestamp,\r\n block.timestamp,\r\n block.timestamp,\r\n block.timestamp\r\n );\r\n totalStakes = totalStakes.add(1);\r\n stakes[_addr].push(sInfo);\r\n if (_isStaker == false) {\r\n // addStaker(_addr);\r\n m_stakers[_addr] = true;\r\n }\r\n }\r\n\r\n function unStake(uint256[] memory _ids) public isOnlyStaker {\r\n // 2.15 update\r\n\r\n require(!islocked, \"Locked\");\r\n uint256[] memory ownerIds = stakeOf(msg.sender);\r\n require(_ids.length <= ownerIds.length, \"Id errors\");\r\n uint256 temp = 0;\r\n\r\n for(uint256 i=0; i<_ids.length;i++) {\r\n for(uint256 j=0;j 0) {\r\n IERC20Upgradeable(ROOTxTokenAddress).transfer(_addr, Rootamount);\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_ROOTX = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function _claimOfSROOTxToken(address _addr) internal {\r\n (, uint256 SROOTamount, ) = claimOf(_addr);\r\n if (SROOTamount > 0) {\r\n IERC20Upgradeable(SROOTxTokenAddress).transfer(_addr, SROOTamount);\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_SROOT = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function _claimOfWETH(address _addr) internal {\r\n (, uint256 ETHamount, ) = claimOf(_addr);\r\n\r\n if (ETHamount > 0) {\r\n IERC20Upgradeable(SROOTxTokenAddress).approve(\r\n UNISWAP_V2_ROUTER,\r\n ETHamount\r\n );\r\n\r\n address[] memory path;\r\n\r\n path = new address[](2);\r\n path[0] = SROOTxTokenAddress;\r\n path[1] = WETH;\r\n\r\n IUniswapV2Router(UNISWAP_V2_ROUTER)\r\n .swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n ETHamount,\r\n 0,\r\n path,\r\n _addr,\r\n block.timestamp\r\n );\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n stakes[_addr][i].claimedDate_WETH = block.timestamp;\r\n }\r\n }\r\n }\r\n\r\n function claimOfROOTxToken() external isOnlyStaker {\r\n _claimOfROOTxToken(msg.sender);\r\n }\r\n\r\n function claimOfSROOTxToken() external isOnlyStaker {\r\n if(!isVested(msg.sender)){\r\n _claimOfSROOTxToken(msg.sender);\r\n }\r\n }\r\n\r\n function claimOfWETH() external isOnlyStaker {\r\n if(!isVested(msg.sender)) {\r\n _claimOfWETH(msg.sender);\r\n }\r\n\r\n }\r\n\r\n // 2.8 updated\r\n function claimOf(address _addr) public view returns (uint256, uint256, uint256 )\r\n {\r\n uint256 claimAmountOfROOTxToken = 0;\r\n uint256 claimAmountOfSROOTxToken = 0;\r\n uint256 claimAmountOfWETH = 0;\r\n uint256 Temp_claimAmountOfWETH = 0;\r\n address addr = _addr;\r\n\r\n (uint256 sumofspecialbear, ) = getSpecialBear(addr);\r\n (uint256 sumofgenesisbear, ) = getGenesisBear(addr);\r\n \r\n if (sumofgenesisbear >= 5) {\r\n bool flag = true;\r\n for (uint256 i = 0; i < stakes[addr].length; i++) {\r\n ///ROOTX\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n if ((isGenesisBear(stakes[addr][i].nft_id) || isSpecialBear(stakes[addr][i].nft_id)) && dd_root <1) {\r\n flag = false;\r\n }\r\n if (flag && stakes[addr].length != 0) {\r\n claimAmountOfROOTxToken = RootX_Store.div(10**18).add(10*dd_root*sumofgenesisbear).add(10*dd_root*sumofspecialbear);\r\n }\r\n else if(!flag) {\r\n claimAmountOfROOTxToken = RootX_Store.div(10**18);\r\n }\r\n /// SROOTX and WETH\r\n if (isSpecialBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_srootx = calDay(stakes[addr][i].claimedDate_SROOT);\r\n uint256 dd_weth = dd_srootx;\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add(200 * (10**18) * dd_srootx);\r\n claimAmountOfWETH = claimAmountOfWETH.add(200 * (10**18) * dd_weth);\r\n } else if (isGenesisBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_srootx = calDay(stakes[addr][i].claimedDate_SROOT);\r\n uint256 dd_weth = dd_srootx;\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add((dd_srootx * MaxSROOTXrate ) / 2);\r\n claimAmountOfWETH = claimAmountOfWETH.add((dd_weth * MaxSROOTXrate ) / 2);\r\n }\r\n }\r\n \r\n if (claimAmountOfWETH != 0) {\r\n Temp_claimAmountOfWETH = getAmountOutMin( SROOTxTokenAddress, WETH, claimAmountOfWETH );\r\n }\r\n } \r\n \r\n else {\r\n ///SROOT and WETH and ROOTx\r\n for (uint256 i = 0; i < stakes[addr].length; i++) {\r\n if (isSpecialBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n claimAmountOfROOTxToken = claimAmountOfROOTxToken.add(dd_root * 10);\r\n uint256 dd_sroot = calDay(stakes[addr][i].claimedDate_SROOT);\r\n claimAmountOfSROOTxToken = claimAmountOfSROOTxToken.add(200 * (10**18) * dd_sroot);\r\n uint256 dd_weth = calDay(stakes[addr][i].claimedDate_WETH);\r\n claimAmountOfWETH = claimAmountOfWETH.add( 200 * (10**18) * dd_weth );\r\n }\r\n if (isGenesisBear(stakes[addr][i].nft_id)) {\r\n uint256 dd_root = calDay(stakes[addr][i].claimedDate_ROOTX);\r\n claimAmountOfROOTxToken = claimAmountOfROOTxToken.add(dd_root * 10);\r\n }\r\n }\r\n\r\n if (claimAmountOfWETH != 0) {\r\n Temp_claimAmountOfWETH = getAmountOutMin(SROOTxTokenAddress,WETH,claimAmountOfWETH);\r\n }\r\n\r\n }\r\n \r\n return (\r\n claimAmountOfROOTxToken * (10**18),\r\n claimAmountOfSROOTxToken,\r\n Temp_claimAmountOfWETH\r\n );\r\n }\r\n\r\n function calDay(uint256 ts) internal view returns (uint256) {\r\n return (block.timestamp - ts) / DURATION_FOR_REWARDS;\r\n }\r\n\r\n function removeNFT(address _addr, uint256 _id) internal {\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (stakes[_addr][i].nft_id == _id) {\r\n stakes[_addr][i] = stakes[_addr][stakes[_addr].length - 1];\r\n stakes[_addr].pop();\r\n }\r\n }\r\n if (stakes[_addr].length <= 0) {\r\n delete stakes[_addr];\r\n removeStaker(_addr);\r\n }\r\n }\r\n\r\n function isGenesisBear(uint256 _id) internal pure returns (bool) {\r\n bool returned;\r\n if (_id >= 0 && _id <= 3700) {\r\n returned = true;\r\n } else {\r\n returned = false;\r\n }\r\n return returned;\r\n }\r\n\r\n function isSpecialBear(uint256 _id) internal pure returns (bool) {\r\n bool returned;\r\n if (_id >= 1000000000000 && _id <= 1000000000005) {\r\n returned = true;\r\n }\r\n return returned;\r\n }\r\n\r\n function getSpecialBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofspecialbear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isSpecialBear(stakes[_addr][i].nft_id)) {\r\n sumofspecialbear += 1;\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofspecialbear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isSpecialBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofspecialbear, nft_ids);\r\n }\r\n\r\n function getGenesisBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofgenesisbear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isGenesisBear(stakes[_addr][i].nft_id)) {\r\n sumofgenesisbear = sumofgenesisbear.add(1);\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofgenesisbear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isGenesisBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofgenesisbear, nft_ids);\r\n }\r\n\r\n function isMiniBear(uint256 _id) internal pure returns (bool) {\r\n if (_id < 10000000000006) return false;\r\n if (_id > 10000000005299) return false;\r\n else return true;\r\n }\r\n\r\n function getMiniBear(address _addr)\r\n public\r\n view\r\n returns (uint256, uint256[] memory)\r\n {\r\n uint256 sumofminibear = 0;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isMiniBear(stakes[_addr][i].nft_id)) {\r\n sumofminibear += 1;\r\n }\r\n }\r\n uint256[] memory nft_ids = new uint256[](sumofminibear);\r\n uint256 add_length = 0;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (isMiniBear(stakes[_addr][i].nft_id)) {\r\n nft_ids[add_length] = (stakes[_addr][i].nft_id);\r\n add_length = add_length.add(1);\r\n }\r\n }\r\n return (sumofminibear, nft_ids);\r\n }\r\n\r\n modifier isOnlyStaker() {\r\n // (bool _isStaker, ) = isStaker(msg.sender);\r\n (bool _isStaker, ) = is_m_Staker(msg.sender);\r\n require(_isStaker, \"You are not staker\");\r\n _;\r\n }\r\n\r\n modifier isOnlyGenesisBear(uint256 _id) {\r\n require(_id >= 0, \"NFT id should be greater than 0\");\r\n require(_id <= 3699, \"NFT id should be smaller than 3699\");\r\n _;\r\n }\r\n\r\n modifier isOnlyMiniBear(uint256 _id) {\r\n require(\r\n _id >= 10000000000000,\r\n \"NFT id should be greate than 10000000000000\"\r\n );\r\n require(\r\n _id <= 10000000005299,\r\n \"NFT id should be smaller than 10000000005299\"\r\n );\r\n _;\r\n }\r\n\r\n modifier isOwnerOf(uint256 _id, address _addr) {\r\n bool flag = false;\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n if (stakes[_addr][i].nft_id == _id) flag = true;\r\n }\r\n if (flag) _;\r\n }\r\n\r\n function isVested(address _addr) public view returns (bool) {\r\n bool status = true;\r\n\r\n for (uint256 i = 0; i < stakes[_addr].length; i++) {\r\n uint256 dd = calDay(stakes[_addr][i].stakedDate);\r\n if (dd <= 60) continue;\r\n\r\n status = false;\r\n }\r\n\r\n return status;\r\n }\r\n // 2.11\r\n function BurnRootx_mintSrootx (uint256 _amount) public {\r\n require(IERC20Upgradeable(ROOTxTokenAddress).allowance(msg.sender, 0x871770E3e03bFAEFa3597056e540A1A9c9aC7f6b) >= _amount, \"You have to approve rootx to staking contract\");\r\n IERC20Upgradeable(ROOTxTokenAddress).transferFrom(msg.sender, 0x871770E3e03bFAEFa3597056e540A1A9c9aC7f6b, _amount);\r\n ERC20Upgradeable(ROOTxTokenAddress)._burn(_amount);\r\n IERC20Upgradeable(SROOTxTokenAddress).mintToken(msg.sender, _amount.mul(5));\r\n }\r\n\r\n function lock () public {\r\n if(msg.sender == 0xd0d725208fd36BE1561050Fc1DD6a651d7eA7C89) {\r\n islocked = !islocked;\r\n }\r\n }\r\n}","ABI":"[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BearXNFTAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"BurnRootx_mintSrootx\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MaxRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MaxSROOTXrate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MinRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MinSROOTXrate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROOTxTokenAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RateValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RootX_Store\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SROOTRateValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SROOTxTokenAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"claimOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfROOTxToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfSROOTxToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOfWETH\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"}],\"name\":\"createStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAPR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getGenesisBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getMiniBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"getSpecialBear\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"get_APR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"isVested\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"is_m_Staker\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"islocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lock\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxprovision\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setBearXNFTAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setROOTxTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"setSROOTxTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"stakeOf\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalStakes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferStakers\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"_ids\",\"type\":\"uint256[]\"}],\"name\":\"unStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]","ContractName":"BearXNFTStaking","CompilerVersion":"v0.8.11+commit.d7f03943","OptimizationUsed":1,"Runs":200,"ConstructorArguments":"0x","EVMVersion":"Default","Library":"","LicenseType":"Unlicense","Proxy":0,"SwarmSource":"ipfs://8225f1f0e5a2f3fe96c24aa279f677e9fe9917e9144ec29a9c0abce7aaa8f9f0"}] \ No newline at end of file diff --git a/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json index f9f9f5fa0eafc..ba804703e9e2c 100644 --- a/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json +++ b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json @@ -1,5 +1 @@ -{ - "contractAddress": "0x3a23f943181408eac424116af7b7790c94cb97a5", - "contractCreator": "0xe8dd38e673a93ccfc2e3d7053efccb5c93f49365", - "txHash": "0x29328ac0edf7b080320bc8ed998fcd3e866f7eec3775b0d91a86f5d02ab83c28" -} \ No newline at end of file +{"contractAddress":"0x3a23f943181408eac424116af7b7790c94cb97a5","contractCreator":"0xe8dd38e673a93ccfc2e3d7053efccb5c93f49365","txHash":"0x29328ac0edf7b080320bc8ed998fcd3e866f7eec3775b0d91a86f5d02ab83c28"} \ No newline at end of file diff --git a/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json index 23f3b4ce433ce..d82efef5a707e 100644 --- a/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json +++ b/testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/metadata.json @@ -1,193 +1 @@ -[ - { - "SourceCode": { - "language": "Solidity", - "sources": { - "src/bridges/hop/interfaces/amm.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/**\n * @title HopAMM\n * @notice Interface to handle the token bridging to L2 chains.\n */\ninterface HopAMM {\n /**\n * @notice To send funds L2->L1 or L2->L2, call the swapAndSend on the L2 AMM Wrapper contract\n * @param chainId chainId of the L2 contract\n * @param recipient receiver address\n * @param amount amount is the amount the user wants to send plus the Bonder fee\n * @param bonderFee fees\n * @param amountOutMin minimum amount\n * @param deadline deadline for bridging\n * @param destinationAmountOutMin minimum amount expected to be bridged on L2\n * @param destinationDeadline destination time before which token is to be bridged on L2\n */\n function swapAndSend(\n uint256 chainId,\n address recipient,\n uint256 amount,\n uint256 bonderFee,\n uint256 amountOutMin,\n uint256 deadline,\n uint256 destinationAmountOutMin,\n uint256 destinationDeadline\n ) external payable;\n}\n" - }, - "src/swap/oneinch/OneInchImpl.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {ONEINCH} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title OneInch-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via OneInch-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of OneInchImplementation\n * @author Socket dot tech.\n */\ncontract OneInchImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable OneInchIdentifier = ONEINCH;\n\n /// @notice address of OneInchAggregator to swap the tokens on Chain\n address public immutable ONEINCH_AGGREGATOR;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @dev ensure _oneinchAggregator are set properly for the chainId in which the contract is being deployed\n constructor(\n address _oneinchAggregator,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n ONEINCH_AGGREGATOR = _oneinchAggregator;\n }\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * via OneInch-Middleware-Aggregator\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param receiverAddress address of toToken recipient\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n uint256 returnAmount;\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(ONEINCH_AGGREGATOR, amount);\n {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call(\n swapExtraData\n );\n token.safeApprove(ONEINCH_AGGREGATOR, 0);\n\n if (!success) {\n revert SwapFailed();\n }\n\n returnAmount = abi.decode(result, (uint256));\n }\n } else {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call{\n value: amount\n }(swapExtraData);\n if (!success) {\n revert SwapFailed();\n }\n returnAmount = abi.decode(result, (uint256));\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n OneInchIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * via OneInch-Middleware-Aggregator\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n uint256 returnAmount;\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(ONEINCH_AGGREGATOR, amount);\n {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call(\n swapExtraData\n );\n token.safeApprove(ONEINCH_AGGREGATOR, 0);\n\n if (!success) {\n revert SwapFailed();\n }\n\n returnAmount = abi.decode(result, (uint256));\n }\n } else {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call{\n value: amount\n }(swapExtraData);\n if (!success) {\n revert SwapFailed();\n }\n returnAmount = abi.decode(result, (uint256));\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n OneInchIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n" - }, - "src/libraries/LibUtil.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./LibBytes.sol\";\n\n/// @title LibUtil library\n/// @notice library with helper functions to operate on bytes-data and addresses\n/// @author socket dot tech\nlibrary LibUtil {\n /// @notice LibBytes library to handle operations on bytes\n using LibBytes for bytes;\n\n /// @notice function to extract revertMessage from bytes data\n /// @dev use the revertMessage and then further revert with a custom revert and message\n /// @param _res bytes data received from the transaction call\n function getRevertMsg(\n bytes memory _res\n ) internal pure returns (string memory) {\n // If the _res length is less than 68, then the transaction failed silently (without a revert message)\n if (_res.length < 68) {\n return \"Transaction reverted silently\";\n }\n bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes\n return abi.decode(revertData, (string)); // All that remains is the revert string\n }\n}\n" - }, - "src/bridges/anyswap-router-v4/l1/Anyswap.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {ANYSWAP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Anyswap-V4-Route L1 Implementation\n * @notice Route implementation with functions to bridge ERC20 via Anyswap-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AnyswapImplementation\n * This is the L1 implementation, so this is used when transferring from l1 to supported l1s or L1.\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\n\n/// @notice Interface to interact with AnyswapV4-Router Implementation\ninterface AnyswapV4Router {\n function anySwapOutUnderlying(\n address token,\n address to,\n uint256 amount,\n uint256 toChainID\n ) external;\n}\n\ncontract AnyswapImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AnyswapIdentifier = ANYSWAP;\n\n /// @notice Function-selector for ERC20-token bridging on Anyswap-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ANYSWAP_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,address)\"\n )\n );\n\n bytes4 public immutable ANYSWAP_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,address,bytes32))\"\n )\n );\n\n /// @notice AnSwapV4Router Contract instance used to deposit ERC20 on to Anyswap-Bridge\n /// @dev contract instance is to be initialized in the constructor using the router-address passed as constructor argument\n AnyswapV4Router public immutable router;\n\n /**\n * @notice Constructor sets the router address and socketGateway address.\n * @dev anyswap 4 router is immutable. so no setter function required.\n */\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = AnyswapV4Router(_router);\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeDataNoToken {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeData {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AnyswapBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AnyswapBridgeData memory anyswapBridgeData = abi.decode(\n bridgeData,\n (AnyswapBridgeData)\n );\n ERC20(anyswapBridgeData.token).safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n amount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n amount,\n anyswapBridgeData.token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param anyswapBridgeData encoded data for AnyswapBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AnyswapBridgeDataNoToken calldata anyswapBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n ERC20(token).safeApprove(address(router), bridgeAmount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n bridgeAmount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Anyswap-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param wrapperTokenAddress address of wrapperToken, WrappedVersion of the token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address wrapperTokenAddress\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n wrapperTokenAddress,\n receiverAddress,\n amount,\n toChainId\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AnyswapIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/cbridge/CelerStorageWrapper.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {OnlySocketGateway, TransferIdExists, TransferIdDoesnotExist} from \"../../errors/SocketErrors.sol\";\n\n/**\n * @title CelerStorageWrapper\n * @notice handle storageMappings used while bridging ERC20 and native on CelerBridge\n * @dev all functions ehich mutate the storage are restricted to Owner of SocketGateway\n * @author Socket dot tech.\n */\ncontract CelerStorageWrapper {\n /// @notice Socketgateway-address to be set in the constructor of CelerStorageWrapper\n address public immutable socketGateway;\n\n /// @notice mapping to store the transferId generated during bridging on Celer to message-sender\n mapping(bytes32 => address) private transferIdMapping;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(address _socketGateway) {\n socketGateway = _socketGateway;\n }\n\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @param transferIdAddress message sender who is making the bridging on CelerBridge\n */\n function setAddressForTransferId(\n bytes32 transferId,\n address transferIdAddress\n ) external {\n if (msg.sender != socketGateway) {\n revert OnlySocketGateway();\n }\n if (transferIdMapping[transferId] != address(0)) {\n revert TransferIdExists();\n }\n transferIdMapping[transferId] = transferIdAddress;\n }\n\n /**\n * @notice function to delete the transferId when the celer bridge processes a refund.\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n */\n function deleteTransferId(bytes32 transferId) external {\n if (msg.sender != socketGateway) {\n revert OnlySocketGateway();\n }\n if (transferIdMapping[transferId] == address(0)) {\n revert TransferIdDoesnotExist();\n }\n\n delete transferIdMapping[transferId];\n }\n\n /**\n * @notice function to lookup the address mapped to the transferId\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @return address of account mapped to transferId\n */\n function getAddressFromTransferId(\n bytes32 transferId\n ) external view returns (address) {\n return transferIdMapping[transferId];\n }\n}\n" - }, - "src/bridges/polygon/interfaces/polygon.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/**\n * @title RootChain Manager Interface for Polygon Bridge.\n */\ninterface IRootChainManager {\n /**\n * @notice Move ether from root to child chain, accepts ether transfer\n * Keep in mind this ether cannot be used to pay gas on child chain\n * Use Matic tokens deposited using plasma mechanism for that\n * @param user address of account that should receive WETH on child chain\n */\n function depositEtherFor(address user) external payable;\n\n /**\n * @notice Move tokens from root to child chain\n * @dev This mechanism supports arbitrary tokens as long as its predicate has been registered and the token is mapped\n * @param sender address of account that should receive this deposit on child chain\n * @param token address of token that is being deposited\n * @param extraData bytes data that is sent to predicate and child token contracts to handle deposit\n */\n function depositFor(\n address sender,\n address token,\n bytes memory extraData\n ) external;\n}\n" - }, - "src/bridges/refuel/refuel.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/refuel.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {REFUEL} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Refuel-Route Implementation\n * @notice Route implementation with functions to bridge Native via Refuel-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of RefuelImplementation\n * @author Socket dot tech.\n */\ncontract RefuelBridgeImpl is BridgeImplBase {\n bytes32 public immutable RefuelIdentifier = REFUEL;\n\n /// @notice refuelBridge-Contract address used to deposit Native on Refuel-Bridge\n address public immutable refuelBridge;\n\n /// @notice Function-selector for Native bridging via Refuel-Bridge\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable REFUEL_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,address,uint256,bytes32)\"));\n\n bytes4 public immutable REFUEL_NATIVE_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\"swapAndBridge(uint32,address,uint256,bytes32,bytes)\")\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure _refuelBridge are set properly for the chainId in which the contract is being deployed\n constructor(\n address _refuelBridge,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n refuelBridge = _refuelBridge;\n }\n\n // Function to receive Ether. msg.data must be empty\n receive() external payable {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct RefuelBridgeData {\n address receiverAddress;\n uint256 toChainId;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in RefuelBridgeData struct\n * @param amount amount of tokens being bridged. this must be only native\n * @param bridgeData encoded data for RefuelBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n RefuelBridgeData memory refuelBridgeData = abi.decode(\n bridgeData,\n (RefuelBridgeData)\n );\n IRefuel(refuelBridge).depositNativeToken{value: amount}(\n refuelBridgeData.toChainId,\n refuelBridgeData.receiverAddress\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n refuelBridgeData.toChainId,\n RefuelIdentifier,\n msg.sender,\n refuelBridgeData.receiverAddress,\n refuelBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in RefuelBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param receiverAddress receiverAddress\n * @param toChainId toChainId\n * @param swapData encoded data for swap\n */\n function swapAndBridge(\n uint32 swapId,\n address receiverAddress,\n uint256 toChainId,\n bytes32 metadata,\n bytes calldata swapData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, ) = abi.decode(result, (uint256, address));\n IRefuel(refuelBridge).depositNativeToken{value: bridgeAmount}(\n toChainId,\n receiverAddress\n );\n\n emit SocketBridge(\n bridgeAmount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n RefuelIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Refuel-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of native being refuelled to destination chain\n * @param receiverAddress recipient address of the refuelled native\n * @param toChainId destinationChainId\n */\n function bridgeNativeTo(\n uint256 amount,\n address receiverAddress,\n uint256 toChainId,\n bytes32 metadata\n ) external payable {\n IRefuel(refuelBridge).depositNativeToken{value: amount}(\n toChainId,\n receiverAddress\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n RefuelIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/across/interfaces/across.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/// @notice interface with functions to interact with SpokePool contract of Across-Bridge\ninterface SpokePool {\n /**************************************\n * DEPOSITOR FUNCTIONS *\n **************************************/\n\n /**\n * @notice Called by user to bridge funds from origin to destination chain. Depositor will effectively lock\n * tokens in this contract and receive a destination token on the destination chain. The origin => destination\n * token mapping is stored on the L1 HubPool.\n * @notice The caller must first approve this contract to spend amount of originToken.\n * @notice The originToken => destinationChainId must be enabled.\n * @notice This method is payable because the caller is able to deposit native token if the originToken is\n * wrappedNativeToken and this function will handle wrapping the native token to wrappedNativeToken.\n * @param recipient Address to receive funds at on destination chain.\n * @param originToken Token to lock into this contract to initiate deposit.\n * @param amount Amount of tokens to deposit. Will be amount of tokens to receive less fees.\n * @param destinationChainId Denotes network where user will receive funds from SpokePool by a relayer.\n * @param relayerFeePct % of deposit amount taken out to incentivize a fast relayer.\n * @param quoteTimestamp Timestamp used by relayers to compute this deposit's realizedLPFeePct which is paid\n * to LP pool on HubPool.\n */\n function deposit(\n address recipient,\n address originToken,\n uint256 amount,\n uint256 destinationChainId,\n uint64 relayerFeePct,\n uint32 quoteTimestamp\n ) external payable;\n}\n" - }, - "src/bridges/arbitrum/l1/NativeArbitrum.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {L1GatewayRouter} from \"../interfaces/arbitrum.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {NATIVE_ARBITRUM} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Native Arbitrum-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 via NativeArbitrum-Bridge\n * @notice Called via SocketGateway if the routeId in the request maps to the routeId of NativeArbitrum-Implementation\n * @notice This is used when transferring from ethereum chain to arbitrum via their native bridge.\n * @notice Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * @notice RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract NativeArbitrumImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativeArbitrumIdentifier = NATIVE_ARBITRUM;\n\n uint256 public constant DESTINATION_CHAIN_ID = 42161;\n\n /// @notice Function-selector for ERC20-token bridging on NativeArbitrum\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_ARBITRUM_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,uint256,uint256,bytes32,address,address,address,bytes)\"\n )\n );\n\n bytes4 public immutable NATIVE_ARBITRUM_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,uint256,uint256,address,address,bytes32,bytes))\"\n )\n );\n\n /// @notice router address of NativeArbitrum Bridge\n /// @notice GatewayRouter looks up ERC20Token's gateway, and finding that it's Standard ERC20 gateway (the L1ERC20Gateway contract).\n address public immutable router;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = _router;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct NativeArbitrumBridgeDataNoToken {\n uint256 value;\n /// @notice maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 maxGas;\n /// @notice gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 gasPriceBid;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of Gateway which handles the token bridging for the token\n /// @notice gatewayAddress is unique for each token\n address gatewayAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n /// @notice data is a depositParameter derived from erc20Bridger of nativeArbitrum\n bytes data;\n }\n\n struct NativeArbitrumBridgeData {\n uint256 value;\n /// @notice maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 maxGas;\n /// @notice gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 gasPriceBid;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of Gateway which handles the token bridging for the token\n /// @notice gatewayAddress is unique for each token\n address gatewayAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n /// @notice data is a depositParameter derived from erc20Bridger of nativeArbitrum\n bytes data;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativeArbitrumBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for NativeArbitrumBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n NativeArbitrumBridgeData memory nativeArbitrumBridgeData = abi.decode(\n bridgeData,\n (NativeArbitrumBridgeData)\n );\n ERC20(nativeArbitrumBridgeData.token).safeApprove(\n nativeArbitrumBridgeData.gatewayAddress,\n amount\n );\n\n L1GatewayRouter(router).outboundTransfer{\n value: nativeArbitrumBridgeData.value\n }(\n nativeArbitrumBridgeData.token,\n nativeArbitrumBridgeData.receiverAddress,\n amount,\n nativeArbitrumBridgeData.maxGas,\n nativeArbitrumBridgeData.gasPriceBid,\n nativeArbitrumBridgeData.data\n );\n\n emit SocketBridge(\n amount,\n nativeArbitrumBridgeData.token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n nativeArbitrumBridgeData.receiverAddress,\n nativeArbitrumBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativeArbitrumBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param nativeArbitrumBridgeData encoded data for NativeArbitrumBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n NativeArbitrumBridgeDataNoToken calldata nativeArbitrumBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n ERC20(token).safeApprove(\n nativeArbitrumBridgeData.gatewayAddress,\n bridgeAmount\n );\n\n L1GatewayRouter(router).outboundTransfer{\n value: nativeArbitrumBridgeData.value\n }(\n token,\n nativeArbitrumBridgeData.receiverAddress,\n bridgeAmount,\n nativeArbitrumBridgeData.maxGas,\n nativeArbitrumBridgeData.gasPriceBid,\n nativeArbitrumBridgeData.data\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n nativeArbitrumBridgeData.receiverAddress,\n nativeArbitrumBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativeArbitrum-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param value value\n * @param maxGas maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n * @param gasPriceBid gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param gatewayAddress address of Gateway which handles the token bridging for the token, gatewayAddress is unique for each token\n * @param data data is a depositParameter derived from erc20Bridger of nativeArbitrum\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 value,\n uint256 maxGas,\n uint256 gasPriceBid,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address gatewayAddress,\n bytes memory data\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(gatewayAddress, amount);\n\n L1GatewayRouter(router).outboundTransfer{value: value}(\n token,\n receiverAddress,\n amount,\n maxGas,\n gasPriceBid,\n data\n );\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/across/Across.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/across.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ACROSS} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Across-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Across-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AcrossImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract AcrossImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AcrossIdentifier = ACROSS;\n\n /// @notice Function-selector for ERC20-token bridging on Across-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ACROSS_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,uint32,uint64)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Across-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable ACROSS_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(uint256,uint256,bytes32,address,uint32,uint64)\"\n )\n );\n\n bytes4 public immutable ACROSS_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,uint32,uint64,bytes32))\"\n )\n );\n\n /// @notice spokePool Contract instance used to deposit ERC20 and Native on to Across-Bridge\n /// @dev contract instance is to be initialized in the constructor using the spokePoolAddress passed as constructor argument\n SpokePool public immutable spokePool;\n address public immutable spokePoolAddress;\n\n /// @notice address of WETH token to be initialised in constructor\n address public immutable WETH;\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AcrossBridgeDataNoToken {\n uint256 toChainId;\n address receiverAddress;\n uint32 quoteTimestamp;\n uint64 relayerFeePct;\n bytes32 metadata;\n }\n\n struct AcrossBridgeData {\n uint256 toChainId;\n address receiverAddress;\n address token;\n uint32 quoteTimestamp;\n uint64 relayerFeePct;\n bytes32 metadata;\n }\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure spokepool, weth-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _spokePool,\n address _wethAddress,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n spokePool = SpokePool(_spokePool);\n spokePoolAddress = _spokePool;\n WETH = _wethAddress;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AcrossBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AcrossBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AcrossBridgeData memory acrossBridgeData = abi.decode(\n bridgeData,\n (AcrossBridgeData)\n );\n\n if (acrossBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n spokePool.deposit{value: amount}(\n acrossBridgeData.receiverAddress,\n WETH,\n amount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n } else {\n spokePool.deposit(\n acrossBridgeData.receiverAddress,\n acrossBridgeData.token,\n amount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n }\n\n emit SocketBridge(\n amount,\n acrossBridgeData.token,\n acrossBridgeData.toChainId,\n AcrossIdentifier,\n msg.sender,\n acrossBridgeData.receiverAddress,\n acrossBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AcrossBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param acrossBridgeData encoded data for AcrossBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AcrossBridgeDataNoToken calldata acrossBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n spokePool.deposit{value: bridgeAmount}(\n acrossBridgeData.receiverAddress,\n WETH,\n bridgeAmount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n } else {\n spokePool.deposit(\n acrossBridgeData.receiverAddress,\n token,\n bridgeAmount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n acrossBridgeData.toChainId,\n AcrossIdentifier,\n msg.sender,\n acrossBridgeData.receiverAddress,\n acrossBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Across-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param quoteTimestamp timestamp for quote and this is to be used by Across-Bridge contract\n * @param relayerFeePct feePct that will be relayed by the Bridge to the relayer\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n uint32 quoteTimestamp,\n uint64 relayerFeePct\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n spokePool.deposit(\n receiverAddress,\n address(token),\n amount,\n toChainId,\n relayerFeePct,\n quoteTimestamp\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AcrossIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Across-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param quoteTimestamp timestamp for quote and this is to be used by Across-Bridge contract\n * @param relayerFeePct feePct that will be relayed by the Bridge to the relayer\n */\n function bridgeNativeTo(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n uint32 quoteTimestamp,\n uint64 relayerFeePct\n ) external payable {\n spokePool.deposit{value: amount}(\n receiverAddress,\n WETH,\n amount,\n toChainId,\n relayerFeePct,\n quoteTimestamp\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n AcrossIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/cbridge/interfaces/ICelerStorageWrapper.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * @title Celer-StorageWrapper interface\n * @notice Interface to handle storageMappings used while bridging ERC20 and native on CelerBridge\n * @dev all functions ehich mutate the storage are restricted to Owner of SocketGateway\n * @author Socket dot tech.\n */\ninterface ICelerStorageWrapper {\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @param transferIdAddress message sender who is making the bridging on CelerBridge\n */\n function setAddressForTransferId(\n bytes32 transferId,\n address transferIdAddress\n ) external;\n\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n */\n function deleteTransferId(bytes32 transferId) external;\n\n /**\n * @notice function to lookup the address mapped to the transferId\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @return address of account mapped to transferId\n */\n function getAddressFromTransferId(\n bytes32 transferId\n ) external view returns (address);\n}\n" - }, - "src/bridges/optimism/interfaces/optimism.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\ninterface L1StandardBridge {\n /**\n * @dev Performs the logic for deposits by storing the ETH and informing the L2 ETH Gateway of\n * the deposit.\n * @param _to Account to give the deposit to on L2.\n * @param _l2Gas Gas limit required to complete the deposit on L2.\n * @param _data Optional data to forward to L2. This data is provided\n * solely as a convenience for external contracts. Aside from enforcing a maximum\n * length, these contracts provide no guarantees about its content.\n */\n function depositETHTo(\n address _to,\n uint32 _l2Gas,\n bytes calldata _data\n ) external payable;\n\n /**\n * @dev deposit an amount of ERC20 to a recipient's balance on L2.\n * @param _l1Token Address of the L1 ERC20 we are depositing\n * @param _l2Token Address of the L1 respective L2 ERC20\n * @param _to L2 address to credit the withdrawal to.\n * @param _amount Amount of the ERC20 to deposit.\n * @param _l2Gas Gas limit required to complete the deposit on L2.\n * @param _data Optional data to forward to L2. This data is provided\n * solely as a convenience for external contracts. Aside from enforcing a maximum\n * length, these contracts provide no guarantees about its content.\n */\n function depositERC20To(\n address _l1Token,\n address _l2Token,\n address _to,\n uint256 _amount,\n uint32 _l2Gas,\n bytes calldata _data\n ) external;\n}\n\ninterface OldL1TokenGateway {\n /**\n * @dev Transfer SNX to L2 First, moves the SNX into the deposit escrow\n *\n * @param _to Account to give the deposit to on L2\n * @param _amount Amount of the ERC20 to deposit.\n */\n function depositTo(address _to, uint256 _amount) external;\n\n /**\n * @dev Transfer SNX to L2 First, moves the SNX into the deposit escrow\n *\n * @param currencyKey currencyKey for the SynthToken\n * @param destination Account to give the deposit to on L2\n * @param amount Amount of the ERC20 to deposit.\n */\n function initiateSynthTransfer(\n bytes32 currencyKey,\n address destination,\n uint256 amount\n ) external;\n}\n" - }, - "src/bridges/arbitrum/interfaces/arbitrum.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\n\n/*\n * Copyright 2021, Offchain Labs, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npragma solidity >=0.8.0;\n\n/**\n * @title L1gatewayRouter for native-arbitrum\n */\ninterface L1GatewayRouter {\n /**\n * @notice outbound function to bridge ERC20 via NativeArbitrum-Bridge\n * @param _token address of token being bridged via GatewayRouter\n * @param _to recipient of the token on arbitrum chain\n * @param _amount amount of ERC20 token being bridged\n * @param _maxGas a depositParameter for bridging the token\n * @param _gasPriceBid a depositParameter for bridging the token\n * @param _data a depositParameter for bridging the token\n * @return calldata returns the output of transactioncall made on gatewayRouter\n */\n function outboundTransfer(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _maxGas,\n uint256 _gasPriceBid,\n bytes calldata _data\n ) external payable returns (bytes calldata);\n}\n" - }, - "src/deployFactory/DisabledSocketRoute.sol": { - "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {OnlySocketGatewayOwner} from \"../errors/SocketErrors.sol\";\n\ncontract DisabledSocketRoute {\n using SafeTransferLib for ERC20;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n error RouteDisabled();\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n */\n constructor(address _socketGateway) {\n socketGateway = _socketGateway;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /**\n * @notice function to rescue the ERC20 tokens in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n /**\n * @notice Handle route function calls gracefully.\n */\n fallback() external payable {\n revert RouteDisabled();\n }\n\n /**\n * @notice Support receiving ether to handle refunds etc.\n */\n receive() external payable {}\n}\n" - }, - "src/bridges/polygon/NativePolygon.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"./interfaces/polygon.sol\";\nimport {BridgeImplBase} from \"../BridgeImplBase.sol\";\nimport {NATIVE_POLYGON} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title NativePolygon-Route Implementation\n * @notice This is the L1 implementation, so this is used when transferring from ethereum to polygon via their native bridge.\n * @author Socket dot tech.\n */\ncontract NativePolygonImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativePolyonIdentifier = NATIVE_POLYGON;\n\n /// @notice destination-chain-Id for this router is always arbitrum\n uint256 public constant DESTINATION_CHAIN_ID = 137;\n\n /// @notice Function-selector for ERC20-token bridging on NativePolygon-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_POLYGON_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeERC20To(uint256,bytes32,address,address)\"));\n\n /// @notice Function-selector for Native bridging on NativePolygon-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable NATIVE_POLYGON_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,bytes32,address)\"));\n\n bytes4 public immutable NATIVE_POLYGON_SWAP_BRIDGE_SELECTOR =\n bytes4(keccak256(\"swapAndBridge(uint32,address,bytes32,bytes)\"));\n\n /// @notice root chain manager proxy on the ethereum chain\n /// @dev to be initialised in the constructor\n IRootChainManager public immutable rootChainManagerProxy;\n\n /// @notice ERC20 Predicate proxy on the ethereum chain\n /// @dev to be initialised in the constructor\n address public immutable erc20PredicateProxy;\n\n /**\n * // @notice We set all the required addresses in the constructor while deploying the contract.\n * // These will be constant addresses.\n * // @dev Please use the Proxy addresses and not the implementation addresses while setting these\n * // @param _rootChainManagerProxy address of the root chain manager proxy on the ethereum chain\n * // @param _erc20PredicateProxy address of the ERC20 Predicate proxy on the ethereum chain.\n * // @param _socketGateway address of the socketGateway contract that calls this contract\n */\n constructor(\n address _rootChainManagerProxy,\n address _erc20PredicateProxy,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n rootChainManagerProxy = IRootChainManager(_rootChainManagerProxy);\n erc20PredicateProxy = _erc20PredicateProxy;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativePolygon-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for NativePolygon-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n (address token, address receiverAddress, bytes32 metadata) = abi.decode(\n bridgeData,\n (address, address, bytes32)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IRootChainManager(rootChainManagerProxy).depositEtherFor{\n value: amount\n }(receiverAddress);\n } else {\n ERC20(token).safeApprove(erc20PredicateProxy, amount);\n\n // deposit into rootchain manager\n IRootChainManager(rootChainManagerProxy).depositFor(\n receiverAddress,\n token,\n abi.encodePacked(amount)\n );\n }\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativePolygon-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param receiverAddress address of the receiver\n * @param swapData encoded data for swap\n */\n function swapAndBridge(\n uint32 swapId,\n address receiverAddress,\n bytes32 metadata,\n bytes calldata swapData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IRootChainManager(rootChainManagerProxy).depositEtherFor{\n value: bridgeAmount\n }(receiverAddress);\n } else {\n ERC20(token).safeApprove(erc20PredicateProxy, bridgeAmount);\n\n // deposit into rootchain manager\n IRootChainManager(rootChainManagerProxy).depositFor(\n receiverAddress,\n token,\n abi.encodePacked(bridgeAmount)\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativePolygon-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of tokens being bridged\n * @param receiverAddress recipient address\n * @param token address of token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n address token\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n\n // set allowance for erc20 predicate\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(erc20PredicateProxy, amount);\n\n // deposit into rootchain manager\n rootChainManagerProxy.depositFor(\n receiverAddress,\n token,\n abi.encodePacked(amount)\n );\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via NativePolygon-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of tokens being bridged\n * @param receiverAddress recipient address\n */\n function bridgeNativeTo(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress\n ) external payable {\n rootChainManagerProxy.depositEtherFor{value: amount}(receiverAddress);\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/stargate/l1/Stargate.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/stargate.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {STARGATE} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Stargate-L1-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Stargate-L1-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of Stargate-L1-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract StargateImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable StargateIdentifier = STARGATE;\n\n /// @notice Function-selector for ERC20-token bridging on Stargate-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable STARGATE_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,(uint256,uint256,uint256,uint256,bytes32,bytes,uint16))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Stargate-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable STARGATE_L1_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint16,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable STARGATE_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint16,uint256,uint256,uint256,uint256,uint256,uint256,bytes32,bytes))\"\n )\n );\n\n /// @notice Stargate Router to bridge ERC20 tokens\n IBridgeStargate public immutable router;\n\n /// @notice Stargate Router to bridge native tokens\n IBridgeStargate public immutable routerETH;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router, routerEth are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _routerEth,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = IBridgeStargate(_router);\n routerETH = IBridgeStargate(_routerEth);\n }\n\n struct StargateBridgeExtraData {\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 destinationGasLimit;\n uint256 minReceivedAmt;\n bytes32 metadata;\n bytes destinationPayload;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct StargateBridgeDataNoToken {\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n struct StargateBridgeData {\n address token;\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Stargate-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n StargateBridgeData memory stargateBridgeData = abi.decode(\n bridgeData,\n (StargateBridgeData)\n );\n\n if (stargateBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + stargateBridgeData.optionalValue}(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n amount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(stargateBridgeData.token).safeApprove(\n address(router),\n amount\n );\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n amount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n stargateBridgeData.token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param stargateBridgeData encoded data for StargateBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n StargateBridgeDataNoToken calldata stargateBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{\n value: bridgeAmount + stargateBridgeData.optionalValue\n }(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n bridgeAmount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(token).safeApprove(address(router), bridgeAmount);\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n bridgeAmount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param senderAddress address of sender\n * @param receiverAddress address of recipient\n * @param amount amount of token being bridge\n * @param value value\n * @param stargateBridgeExtraData stargate bridge extradata\n */\n function bridgeERC20To(\n address token,\n address senderAddress,\n address receiverAddress,\n uint256 amount,\n uint256 value,\n StargateBridgeExtraData calldata stargateBridgeExtraData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n {\n router.swap{value: value}(\n stargateBridgeExtraData.stargateDstChainId,\n stargateBridgeExtraData.srcPoolId,\n stargateBridgeExtraData.dstPoolId,\n payable(senderAddress), // default to refund to main contract\n amount,\n stargateBridgeExtraData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeExtraData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(receiverAddress),\n stargateBridgeExtraData.destinationPayload\n );\n }\n\n emit SocketBridge(\n amount,\n token,\n stargateBridgeExtraData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n stargateBridgeExtraData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of receipient\n * @param senderAddress address of sender\n * @param stargateDstChainId stargate defines chain id in its way\n * @param amount amount of token being bridge\n * @param minReceivedAmt defines the slippage, the min qty you would accept on the destination\n * @param optionalValue optionalValue Native amount\n */\n function bridgeNativeTo(\n address receiverAddress,\n address senderAddress,\n uint16 stargateDstChainId,\n uint256 amount,\n uint256 minReceivedAmt,\n uint256 optionalValue,\n bytes32 metadata\n ) external payable {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n minReceivedAmt\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/hop/l2/HopImplL2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../interfaces/amm.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {HOP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hop-L2 Route Implementation\n * @notice This is the L2 implementation, so this is used when transferring from l2 to supported l2s\n * Called via SocketGateway if the routeId in the request maps to the routeId of HopL2-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HopImplL2 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HopIdentifier = HOP;\n\n /// @notice Function-selector for ERC20-token bridging on Hop-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HOP_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,(uint256,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Hop-L2-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable HOP_L2_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable HOP_L2_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used as a input parameter for Bridging tokens via Hop-L2-route\n /// @dev while building transactionData,values should be set in this sequence of properties in this struct\n struct HopBridgeRequestData {\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HopBridgeDataNoToken {\n // The address receiving funds at the destination\n address receiverAddress;\n // AMM address of Hop on L2\n address hopAMM;\n // The chainId of the destination chain\n uint256 toChainId;\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopBridgeData {\n /// @notice address of token being bridged\n address token;\n // The address receiving funds at the destination\n address receiverAddress;\n // AMM address of Hop on L2\n address hopAMM;\n // The chainId of the destination chain\n uint256 toChainId;\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Hop-L2-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HopBridgeData memory hopData = abi.decode(bridgeData, (HopBridgeData));\n\n if (hopData.token == NATIVE_TOKEN_ADDRESS) {\n HopAMM(hopData.hopAMM).swapAndSend{value: amount}(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n } else {\n // perform bridging\n HopAMM(hopData.hopAMM).swapAndSend(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n }\n\n emit SocketBridge(\n amount,\n hopData.token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hopData encoded data for HopData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HopBridgeDataNoToken calldata hopData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n HopAMM(hopData.hopAMM).swapAndSend{value: bridgeAmount}(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n } else {\n // perform bridging\n HopAMM(hopData.hopAMM).swapAndSend(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hop-L2-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param token token being bridged\n * @param hopAMM AMM address of Hop on L2\n * @param amount The amount being bridged\n * @param toChainId The chainId of the destination chain\n * @param hopBridgeRequestData extraData for Bridging across Hop-L2\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n address hopAMM,\n uint256 amount,\n uint256 toChainId,\n HopBridgeRequestData calldata hopBridgeRequestData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n\n HopAMM(hopAMM).swapAndSend(\n toChainId,\n receiverAddress,\n amount,\n hopBridgeRequestData.bonderFee,\n hopBridgeRequestData.amountOutMin,\n hopBridgeRequestData.deadline,\n hopBridgeRequestData.amountOutMinDestination,\n hopBridgeRequestData.deadlineDestination\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n hopBridgeRequestData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hop-L2-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param hopAMM AMM address of Hop on L2\n * @param amount The amount being bridged\n * @param toChainId The chainId of the destination chain\n * @param bonderFee fees passed to relayer\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n * @param amountOutMinDestination Minimum amount expected to be received or bridged to destination\n * @param deadlineDestination deadline for bridging to destination\n */\n function bridgeNativeTo(\n address receiverAddress,\n address hopAMM,\n uint256 amount,\n uint256 toChainId,\n uint256 bonderFee,\n uint256 amountOutMin,\n uint256 deadline,\n uint256 amountOutMinDestination,\n uint256 deadlineDestination,\n bytes32 metadata\n ) external payable {\n // token address might not be indication thats why passed through extraData\n // perform bridging\n HopAMM(hopAMM).swapAndSend{value: amount}(\n toChainId,\n receiverAddress,\n amount,\n bonderFee,\n amountOutMin,\n deadline,\n amountOutMinDestination,\n deadlineDestination\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/anyswap-router-v4/l2/Anyswap.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {ANYSWAP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Anyswap-V4-Route L1 Implementation\n * @notice Route implementation with functions to bridge ERC20 via Anyswap-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AnyswapImplementation\n * This is the L2 implementation, so this is used when transferring from l2.\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ninterface AnyswapV4Router {\n function anySwapOutUnderlying(\n address token,\n address to,\n uint256 amount,\n uint256 toChainID\n ) external;\n}\n\ncontract AnyswapL2Impl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AnyswapIdentifier = ANYSWAP;\n\n /// @notice Function-selector for ERC20-token bridging on Anyswap-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ANYSWAP_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,address)\"\n )\n );\n\n bytes4 public immutable ANYSWAP_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,address,bytes32))\"\n )\n );\n\n // polygon router multichain router v4\n AnyswapV4Router public immutable router;\n\n /**\n * @notice Constructor sets the router address and socketGateway address.\n * @dev anyswap v4 router is immutable. so no setter function required.\n */\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = AnyswapV4Router(_router);\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeDataNoToken {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeData {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AnyswapBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AnyswapBridgeData memory anyswapBridgeData = abi.decode(\n bridgeData,\n (AnyswapBridgeData)\n );\n ERC20(anyswapBridgeData.token).safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n amount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n amount,\n anyswapBridgeData.token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param anyswapBridgeData encoded data for AnyswapBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AnyswapBridgeDataNoToken calldata anyswapBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n ERC20(token).safeApprove(address(router), bridgeAmount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n bridgeAmount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Anyswap-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param wrapperTokenAddress address of wrapperToken, WrappedVersion of the token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address wrapperTokenAddress\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n wrapperTokenAddress,\n receiverAddress,\n amount,\n toChainId\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AnyswapIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/hyphen/Hyphen.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/hyphen.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {HYPHEN} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hyphen-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Hyphen-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of HyphenImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HyphenImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HyphenIdentifier = HYPHEN;\n\n /// @notice Function-selector for ERC20-token bridging on Hyphen-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HYPHEN_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"bridgeERC20To(uint256,bytes32,address,address,uint256)\")\n );\n\n /// @notice Function-selector for Native bridging on Hyphen-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable HYPHEN_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,bytes32,address,uint256)\"));\n\n bytes4 public immutable HYPHEN_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\"swapAndBridge(uint32,bytes,(address,uint256,bytes32))\")\n );\n\n /// @notice liquidityPoolManager - liquidityPool Manager of Hyphen used to bridge ERC20 and native\n /// @dev this is to be initialized in constructor with a valid deployed address of hyphen-liquidityPoolManager\n HyphenLiquidityPoolManager public immutable liquidityPoolManager;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure liquidityPoolManager-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _liquidityPoolManager,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n liquidityPoolManager = HyphenLiquidityPoolManager(\n _liquidityPoolManager\n );\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HyphenData {\n /// @notice address of token being bridged\n address token;\n /// @notice address of receiver\n address receiverAddress;\n /// @notice chainId of destination\n uint256 toChainId;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n struct HyphenDataNoToken {\n /// @notice address of receiver\n address receiverAddress;\n /// @notice chainId of destination\n uint256 toChainId;\n /// @notice chainId of destination\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HyphenBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for HyphenBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HyphenData memory hyphenData = abi.decode(bridgeData, (HyphenData));\n\n if (hyphenData.token == NATIVE_TOKEN_ADDRESS) {\n liquidityPoolManager.depositNative{value: amount}(\n hyphenData.receiverAddress,\n hyphenData.toChainId,\n \"SOCKET\"\n );\n } else {\n ERC20(hyphenData.token).safeApprove(\n address(liquidityPoolManager),\n amount\n );\n liquidityPoolManager.depositErc20(\n hyphenData.toChainId,\n hyphenData.token,\n hyphenData.receiverAddress,\n amount,\n \"SOCKET\"\n );\n }\n\n emit SocketBridge(\n amount,\n hyphenData.token,\n hyphenData.toChainId,\n HyphenIdentifier,\n msg.sender,\n hyphenData.receiverAddress,\n hyphenData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HyphenBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hyphenData encoded data for hyphenData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HyphenDataNoToken calldata hyphenData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n liquidityPoolManager.depositNative{value: bridgeAmount}(\n hyphenData.receiverAddress,\n hyphenData.toChainId,\n \"SOCKET\"\n );\n } else {\n ERC20(token).safeApprove(\n address(liquidityPoolManager),\n bridgeAmount\n );\n liquidityPoolManager.depositErc20(\n hyphenData.toChainId,\n token,\n hyphenData.receiverAddress,\n bridgeAmount,\n \"SOCKET\"\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hyphenData.toChainId,\n HyphenIdentifier,\n msg.sender,\n hyphenData.receiverAddress,\n hyphenData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hyphen-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount to be sent\n * @param receiverAddress address of the token to bridged to the destination chain.\n * @param token address of token being bridged\n * @param toChainId chainId of destination\n */\n function bridgeERC20To(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n address token,\n uint256 toChainId\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(liquidityPoolManager), amount);\n liquidityPoolManager.depositErc20(\n toChainId,\n token,\n receiverAddress,\n amount,\n \"SOCKET\"\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HyphenIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hyphen-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount to be sent\n * @param receiverAddress address of the token to bridged to the destination chain.\n * @param toChainId chainId of destination\n */\n function bridgeNativeTo(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n uint256 toChainId\n ) external payable {\n liquidityPoolManager.depositNative{value: amount}(\n receiverAddress,\n toChainId,\n \"SOCKET\"\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HyphenIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/bridges/optimism/l1/NativeOptimism.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/optimism.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {UnsupportedInterfaceId} from \"../../../errors/SocketErrors.sol\";\nimport {NATIVE_OPTIMISM} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title NativeOptimism-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via NativeOptimism-Bridge\n * Tokens are bridged from Ethereum to Optimism Chain.\n * Called via SocketGateway if the routeId in the request maps to the routeId of NativeOptimism-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract NativeOptimismImpl is BridgeImplBase {\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativeOptimismIdentifier = NATIVE_OPTIMISM;\n\n uint256 public constant DESTINATION_CHAIN_ID = 10;\n\n /// @notice Function-selector for ERC20-token bridging on Native-Optimism-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_OPTIMISM_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint32,(bytes32,bytes32),uint256,uint256,address,bytes)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Native-Optimism-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native balance\n bytes4\n public immutable NATIVE_OPTIMISM_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint32,uint256,bytes32,bytes)\"\n )\n );\n\n bytes4 public immutable NATIVE_OPTIMISM_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,bytes32,bytes32,address,address,uint32,address,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct OptimismBridgeDataNoToken {\n // interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n uint256 interfaceId;\n // currencyKey of the token beingBridged\n bytes32 currencyKey;\n // socket offchain created hash\n bytes32 metadata;\n // address of receiver of bridged tokens\n address receiverAddress;\n /**\n * OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n */\n address customBridgeAddress;\n // Gas limit required to complete the deposit on L2.\n uint32 l2Gas;\n // Address of the L1 respective L2 ERC20\n address l2Token;\n // additional data , for ll contracts this will be 0x data or empty data\n bytes data;\n }\n\n struct OptimismBridgeData {\n // interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n uint256 interfaceId;\n // currencyKey of the token beingBridged\n bytes32 currencyKey;\n // socket offchain created hash\n bytes32 metadata;\n // address of receiver of bridged tokens\n address receiverAddress;\n /**\n * OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n */\n address customBridgeAddress;\n /// @notice address of token being bridged\n address token;\n // Gas limit required to complete the deposit on L2.\n uint32 l2Gas;\n // Address of the L1 respective L2 ERC20\n address l2Token;\n // additional data , for ll contracts this will be 0x data or empty data\n bytes data;\n }\n\n struct OptimismERC20Data {\n bytes32 currencyKey;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in OptimismBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Optimism-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n OptimismBridgeData memory optimismBridgeData = abi.decode(\n bridgeData,\n (OptimismBridgeData)\n );\n\n emit SocketBridge(\n amount,\n optimismBridgeData.token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n optimismBridgeData.receiverAddress,\n optimismBridgeData.metadata\n );\n if (optimismBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositETHTo{value: amount}(\n optimismBridgeData.receiverAddress,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n } else {\n if (optimismBridgeData.interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20(optimismBridgeData.token).safeApprove(\n optimismBridgeData.customBridgeAddress,\n amount\n );\n\n if (optimismBridgeData.interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositERC20To(\n optimismBridgeData.token,\n optimismBridgeData.l2Token,\n optimismBridgeData.receiverAddress,\n amount,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (optimismBridgeData.interfaceId == 2) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .depositTo(optimismBridgeData.receiverAddress, amount);\n return;\n }\n\n if (optimismBridgeData.interfaceId == 3) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .initiateSynthTransfer(\n optimismBridgeData.currencyKey,\n optimismBridgeData.receiverAddress,\n amount\n );\n return;\n }\n }\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in OptimismBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param optimismBridgeData encoded data for OptimismBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n OptimismBridgeDataNoToken calldata optimismBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n optimismBridgeData.receiverAddress,\n optimismBridgeData.metadata\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositETHTo{value: bridgeAmount}(\n optimismBridgeData.receiverAddress,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n } else {\n if (optimismBridgeData.interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20(token).safeApprove(\n optimismBridgeData.customBridgeAddress,\n bridgeAmount\n );\n\n if (optimismBridgeData.interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositERC20To(\n token,\n optimismBridgeData.l2Token,\n optimismBridgeData.receiverAddress,\n bridgeAmount,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (optimismBridgeData.interfaceId == 2) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .depositTo(\n optimismBridgeData.receiverAddress,\n bridgeAmount\n );\n return;\n }\n\n if (optimismBridgeData.interfaceId == 3) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .initiateSynthTransfer(\n optimismBridgeData.currencyKey,\n optimismBridgeData.receiverAddress,\n bridgeAmount\n );\n return;\n }\n }\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativeOptimism-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param receiverAddress address of receiver of bridged tokens\n * @param customBridgeAddress OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n * @param l2Gas Gas limit required to complete the deposit on L2.\n * @param optimismData extra data needed for optimism bridge\n * @param amount amount being bridged\n * @param interfaceId interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n * @param l2Token Address of the L1 respective L2 ERC20\n * @param data additional data , for ll contracts this will be 0x data or empty data\n */\n function bridgeERC20To(\n address token,\n address receiverAddress,\n address customBridgeAddress,\n uint32 l2Gas,\n OptimismERC20Data calldata optimismData,\n uint256 amount,\n uint256 interfaceId,\n address l2Token,\n bytes calldata data\n ) external payable {\n if (interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(customBridgeAddress, amount);\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n receiverAddress,\n optimismData.metadata\n );\n if (interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(customBridgeAddress).depositERC20To(\n token,\n l2Token,\n receiverAddress,\n amount,\n l2Gas,\n data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (interfaceId == 2) {\n OldL1TokenGateway(customBridgeAddress).depositTo(\n receiverAddress,\n amount\n );\n return;\n }\n\n if (interfaceId == 3) {\n OldL1TokenGateway(customBridgeAddress).initiateSynthTransfer(\n optimismData.currencyKey,\n receiverAddress,\n amount\n );\n return;\n }\n }\n\n /**\n * @notice function to handle native balance bridging to receipent via NativeOptimism-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of receiver of bridged tokens\n * @param customBridgeAddress OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n * @param l2Gas Gas limit required to complete the deposit on L2.\n * @param amount amount being bridged\n * @param data additional data , for ll contracts this will be 0x data or empty data\n */\n function bridgeNativeTo(\n address receiverAddress,\n address customBridgeAddress,\n uint32 l2Gas,\n uint256 amount,\n bytes32 metadata,\n bytes calldata data\n ) external payable {\n L1StandardBridge(customBridgeAddress).depositETHTo{value: amount}(\n receiverAddress,\n l2Gas,\n data\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/deployFactory/SocketDeployFactory.sol": { - "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketBridgeBase} from \"../interfaces/ISocketBridgeBase.sol\";\n\n/**\n * @dev In the constructor, set up the initialization code for socket\n * contracts as well as the keccak256 hash of the given initialization code.\n * that will be used to deploy any transient contracts, which will deploy any\n * socket contracts that require the use of a constructor.\n *\n * Socket contract initialization code (29 bytes):\n *\n * 0x5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\n *\n * Description:\n *\n * pc|op|name | [stack] | \n *\n * ** set the first stack item to zero - used later **\n * 00 58 getpc [0] <>\n *\n * ** set second stack item to 32, length of word returned from staticcall **\n * 01 60 push1\n * 02 20 outsize [0, 32] <>\n *\n * ** set third stack item to 0, position of word returned from staticcall **\n * 03 81 dup2 [0, 32, 0] <>\n *\n * ** set fourth stack item to 4, length of selector given to staticcall **\n * 04 58 getpc [0, 32, 0, 4] <>\n *\n * ** set fifth stack item to 28, position of selector given to staticcall **\n * 05 60 push1\n * 06 1c inpos [0, 32, 0, 4, 28] <>\n *\n * ** set the sixth stack item to msg.sender, target address for staticcall **\n * 07 33 caller [0, 32, 0, 4, 28, caller] <>\n *\n * ** set the seventh stack item to msg.gas, gas to forward for staticcall **\n * 08 5a gas [0, 32, 0, 4, 28, caller, gas] <>\n *\n * ** set the eighth stack item to selector, \"what\" to store via mstore **\n * 09 63 push4\n * 10 aaf10f42 selector [0, 32, 0, 4, 28, caller, gas, 0xaaf10f42] <>\n *\n * ** set the ninth stack item to 0, \"where\" to store via mstore ***\n * 11 87 dup8 [0, 32, 0, 4, 28, caller, gas, 0xaaf10f42, 0] <>\n *\n * ** call mstore, consume 8 and 9 from the stack, place selector in memory **\n * 12 52 mstore [0, 32, 0, 4, 0, caller, gas] <0xaaf10f42>\n *\n * ** call staticcall, consume items 2 through 7, place address in memory **\n * 13 fa staticcall [0, 1 (if successful)]
\n *\n * ** flip success bit in second stack item to set to 0 **\n * 14 15 iszero [0, 0]
\n *\n * ** push a third 0 to the stack, position of address in memory **\n * 15 81 dup2 [0, 0, 0]
\n *\n * ** place address from position in memory onto third stack item **\n * 16 51 mload [0, 0, address] <>\n *\n * ** place address to fourth stack item for extcodesize to consume **\n * 17 80 dup1 [0, 0, address, address] <>\n *\n * ** get extcodesize on fourth stack item for extcodecopy **\n * 18 3b extcodesize [0, 0, address, size] <>\n *\n * ** dup and swap size for use by return at end of init code **\n * 19 80 dup1 [0, 0, address, size, size] <>\n * 20 93 swap4 [size, 0, address, size, 0] <>\n *\n * ** push code position 0 to stack and reorder stack items for extcodecopy **\n * 21 80 dup1 [size, 0, address, size, 0, 0] <>\n * 22 91 swap2 [size, 0, address, 0, 0, size] <>\n * 23 92 swap3 [size, 0, size, 0, 0, address] <>\n *\n * ** call extcodecopy, consume four items, clone runtime code to memory **\n * 24 3c extcodecopy [size, 0] \n *\n * ** return to deploy final code in memory **\n * 25 f3 return [] *deployed!*\n */\ncontract SocketDeployFactory is Ownable {\n using SafeTransferLib for ERC20;\n address public immutable disabledRouteAddress;\n\n mapping(address => address) _implementations;\n mapping(uint256 => bool) isDisabled;\n mapping(uint256 => bool) isRouteDeployed;\n mapping(address => bool) canDisableRoute;\n\n event Deployed(address _addr);\n event DisabledRoute(address _addr);\n event Destroyed(address _addr);\n error ContractAlreadyDeployed();\n error NothingToDestroy();\n error AlreadyDisabled();\n error CannotBeDisabled();\n error OnlyDisabler();\n\n constructor(address _owner, address disabledRoute) Ownable(_owner) {\n disabledRouteAddress = disabledRoute;\n canDisableRoute[_owner] = true;\n }\n\n modifier onlyDisabler() {\n if (!canDisableRoute[msg.sender]) {\n revert OnlyDisabler();\n }\n _;\n }\n\n function addDisablerAddress(address disabler) external onlyOwner {\n canDisableRoute[disabler] = true;\n }\n\n function removeDisablerAddress(address disabler) external onlyOwner {\n canDisableRoute[disabler] = false;\n }\n\n /**\n * @notice Deploys a route contract at predetermined location\n * @notice Caller must first deploy the route contract at another location and pass its address as implementation.\n * @param routeId route identifier\n * @param implementationContract address of deployed route contract. Its byte code will be copied to predetermined location.\n */\n function deploy(\n uint256 routeId,\n address implementationContract\n ) external onlyOwner returns (address) {\n // assign the initialization code for the socket contract.\n\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (isRouteDeployed[routeId]) {\n revert ContractAlreadyDeployed();\n }\n\n isRouteDeployed[routeId] = true;\n\n //first we deploy the code we want to deploy on a separate address\n // store the implementation to be retrieved by the socket contract.\n _implementations[routeContractAddress] = implementationContract;\n address addr;\n assembly {\n let encoded_data := add(0x20, initCode) // load initialization code.\n let encoded_size := mload(initCode) // load init code's length.\n addr := create2(0, encoded_data, encoded_size, routeId) // routeId is used as salt\n }\n require(\n addr == routeContractAddress,\n \"Failed to deploy the new socket contract.\"\n );\n emit Deployed(addr);\n return addr;\n }\n\n /**\n * @notice Destroy the route deployed at a location.\n * @param routeId route identifier to be destroyed.\n */\n function destroy(uint256 routeId) external onlyDisabler {\n // determine the address of the socket contract.\n _destroy(routeId);\n }\n\n /**\n * @notice Deploy a disabled contract at destroyed route to handle it gracefully.\n * @param routeId route identifier to be disabled.\n */\n function disableRoute(\n uint256 routeId\n ) external onlyDisabler returns (address) {\n return _disableRoute(routeId);\n }\n\n /**\n * @notice Destroy a list of routeIds\n * @param routeIds array of routeIds to be destroyed.\n */\n function multiDestroy(uint256[] calldata routeIds) external onlyDisabler {\n for (uint32 index = 0; index < routeIds.length; ) {\n _destroy(routeIds[index]);\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Deploy a disabled contract at list of routeIds.\n * @param routeIds array of routeIds to be disabled.\n */\n function multiDisableRoute(\n uint256[] calldata routeIds\n ) external onlyDisabler {\n for (uint32 index = 0; index < routeIds.length; ) {\n _disableRoute(routeIds[index]);\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @dev External view function for calculating a socket contract address\n * given a particular routeId.\n */\n function getContractAddress(\n uint256 routeId\n ) external view returns (address) {\n // determine the address of the socket contract.\n return _getContractAddress(routeId);\n }\n\n //those two functions are getting called by the socket Contract\n function getImplementation()\n external\n view\n returns (address implementation)\n {\n return _implementations[msg.sender];\n }\n\n function _disableRoute(uint256 routeId) internal returns (address) {\n // assign the initialization code for the socket contract.\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (!isRouteDeployed[routeId]) {\n revert CannotBeDisabled();\n }\n\n if (isDisabled[routeId]) {\n revert AlreadyDisabled();\n }\n\n isDisabled[routeId] = true;\n\n //first we deploy the code we want to deploy on a separate address\n // store the implementation to be retrieved by the socket contract.\n _implementations[routeContractAddress] = disabledRouteAddress;\n address addr;\n assembly {\n let encoded_data := add(0x20, initCode) // load initialization code.\n let encoded_size := mload(initCode) // load init code's length.\n addr := create2(0, encoded_data, encoded_size, routeId) // routeId is used as salt.\n }\n require(\n addr == routeContractAddress,\n \"Failed to deploy the new socket contract.\"\n );\n emit Deployed(addr);\n return addr;\n }\n\n function _destroy(uint256 routeId) internal {\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (!isRouteDeployed[routeId]) {\n revert NothingToDestroy();\n }\n ISocketBridgeBase(routeContractAddress).killme();\n emit Destroyed(routeContractAddress);\n }\n\n /**\n * @dev Internal view function for calculating a socket contract address\n * given a particular routeId.\n */\n function _getContractAddress(\n uint256 routeId\n ) internal view returns (address) {\n // determine the address of the socket contract.\n\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n return\n address(\n uint160( // downcast to match the address type.\n uint256( // convert to uint to truncate upper digits.\n keccak256( // compute the CREATE2 hash using 4 inputs.\n abi.encodePacked( // pack all inputs to the hash together.\n hex\"ff\", // start with 0xff to distinguish from RLP.\n address(this), // this contract will be the caller.\n routeId, // the routeId is used as salt.\n keccak256(abi.encodePacked(initCode)) // the init code hash.\n )\n )\n )\n )\n );\n }\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n}\n" - }, - "src/interfaces/ISocketController.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketController\n * @notice Interface for SocketController functions.\n * @dev functions can be added here for invocation from external contracts or off-chain\n * only restriction is that this should have functions to manage controllers\n * @author Socket dot tech.\n */\ninterface ISocketController {\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param _controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address _controllerAddress\n ) external returns (uint32);\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param _controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 _controllerId) external;\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param _controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 _controllerId) external returns (address);\n}\n" - }, - "lib/solmate/src/utils/SafeTransferLib.sol": { - "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n" - }, - "src/controllers/BaseController.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\n\n/// @title BaseController Controller\n/// @notice Base contract for all controller contracts\nabstract contract BaseController {\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice Address used to identify if it is a Zero address\n address public immutable NULL_ADDRESS = address(0);\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGatewayAddress;\n\n /// @notice immutable variable with instance of SocketRoute to access route functions\n ISocketRoute public immutable socketRoute;\n\n /**\n * @notice Construct the base for all controllers.\n * @param _socketGatewayAddress Socketgateway address, an immutable variable to set.\n * @notice initialize the immutable variables of SocketRoute, SocketGateway\n */\n constructor(address _socketGatewayAddress) {\n socketGatewayAddress = _socketGatewayAddress;\n socketRoute = ISocketRoute(_socketGatewayAddress);\n }\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param routeId routeId mapped to the routrImplementation\n * @param data transactionData generated with arguments of bridgeRequest (offchain or by caller)\n * @return returns the bytes response of the route execution (bridging, refuel or swap executions)\n */\n function _executeRoute(\n uint32 routeId,\n bytes memory data\n ) internal returns (bytes memory) {\n (bool success, bytes memory result) = socketRoute\n .getRoute(routeId)\n .delegatecall(data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n}\n" - }, - "src/interfaces/ISocketRoute.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketRoute\n * @notice Interface for routeManagement functions in SocketGateway.\n * @author Socket dot tech.\n */\ninterface ISocketRoute {\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(address routeAddress) external returns (uint256);\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external;\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) external view returns (address);\n}\n" - }, - "src/SocketGatewayDeployment.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\npragma experimental ABIEncoderV2;\n\nimport \"./utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {LibUtil} from \"./libraries/LibUtil.sol\";\nimport \"./libraries/LibBytes.sol\";\nimport {ISocketRoute} from \"./interfaces/ISocketRoute.sol\";\nimport {ISocketRequest} from \"./interfaces/ISocketRequest.sol\";\nimport {ISocketGateway} from \"./interfaces/ISocketGateway.sol\";\nimport {IncorrectBridgeRatios, ZeroAddressNotAllowed, ArrayLengthMismatch} from \"./errors/SocketErrors.sol\";\n\n/// @title SocketGatewayContract\n/// @notice Socketgateway is a contract with entrypoint functions for all interactions with socket liquidity layer\n/// @author Socket Team\ncontract SocketGateway is Ownable {\n using LibBytes for bytes;\n using LibBytes for bytes4;\n using SafeTransferLib for ERC20;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice storage variable to keep track of total number of routes registered in socketgateway\n uint32 public routesCount = 385;\n\n /// @notice storage variable to keep track of total number of controllers registered in socketgateway\n uint32 public controllerCount;\n\n address public immutable disabledRouteAddress;\n\n uint256 public constant CENT_PERCENT = 100e18;\n\n /// @notice storage mapping for route implementation addresses\n mapping(uint32 => address) public routes;\n\n /// storage mapping for controller implemenation addresses\n mapping(uint32 => address) public controllers;\n\n // Events ------------------------------------------------------------------------------------------------------->\n\n /// @notice Event emitted when a router is added to socketgateway\n event NewRouteAdded(uint32 indexed routeId, address indexed route);\n\n /// @notice Event emitted when a route is disabled\n event RouteDisabled(uint32 indexed routeId);\n\n /// @notice Event emitted when ownership transfer is requested by socket-gateway-owner\n event OwnershipTransferRequested(\n address indexed _from,\n address indexed _to\n );\n\n /// @notice Event emitted when a controller is added to socketgateway\n event ControllerAdded(\n uint32 indexed controllerId,\n address indexed controllerAddress\n );\n\n /// @notice Event emitted when a controller is disabled\n event ControllerDisabled(uint32 indexed controllerId);\n\n constructor(address _owner, address _disabledRoute) Ownable(_owner) {\n disabledRouteAddress = _disabledRoute;\n }\n\n // Able to receive ether\n // solhint-disable-next-line no-empty-blocks\n receive() external payable {}\n\n /*******************************************\n * EXTERNAL AND PUBLIC FUNCTIONS *\n *******************************************/\n\n /**\n * @notice executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in routeData to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeId route identifier\n * @param routeData functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoute(\n uint32 routeId,\n bytes calldata routeData\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = addressAt(routeId).delegatecall(\n routeData\n );\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice swaps a token on sourceChain and split it across multiple bridge-recipients\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being swapped\n * @dev ensure the swap-data and bridge-data is generated using the function-selector defined as a constant in the implementation address\n * @param swapMultiBridgeRequest request\n */\n function swapAndMultiBridge(\n ISocketRequest.SwapMultiBridgeRequest calldata swapMultiBridgeRequest\n ) external payable {\n uint256 requestLength = swapMultiBridgeRequest.bridgeRouteIds.length;\n\n if (\n requestLength != swapMultiBridgeRequest.bridgeImplDataItems.length\n ) {\n revert ArrayLengthMismatch();\n }\n uint256 ratioAggregate;\n for (uint256 index = 0; index < requestLength; ) {\n ratioAggregate += swapMultiBridgeRequest.bridgeRatios[index];\n }\n\n if (ratioAggregate != CENT_PERCENT) {\n revert IncorrectBridgeRatios();\n }\n\n (bool swapSuccess, bytes memory swapResult) = addressAt(\n swapMultiBridgeRequest.swapRouteId\n ).delegatecall(swapMultiBridgeRequest.swapImplData);\n\n if (!swapSuccess) {\n assembly {\n revert(add(swapResult, 32), mload(swapResult))\n }\n }\n\n uint256 amountReceivedFromSwap = abi.decode(swapResult, (uint256));\n\n uint256 bridgedAmount;\n\n for (uint256 index = 0; index < requestLength; ) {\n uint256 bridgingAmount;\n\n // if it is the last bridge request, bridge the remaining amount\n if (index == requestLength - 1) {\n bridgingAmount = amountReceivedFromSwap - bridgedAmount;\n } else {\n // bridging amount is the multiplication of bridgeRatio and amountReceivedFromSwap\n bridgingAmount =\n (amountReceivedFromSwap *\n swapMultiBridgeRequest.bridgeRatios[index]) /\n (CENT_PERCENT);\n }\n\n // update the bridged amount, this would be used for computation for last bridgeRequest\n bridgedAmount += bridgingAmount;\n\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n bridgingAmount,\n swapMultiBridgeRequest.bridgeImplDataItems[index]\n );\n\n (bool bridgeSuccess, bytes memory bridgeResult) = addressAt(\n swapMultiBridgeRequest.bridgeRouteIds[index]\n ).delegatecall(bridgeImpldata);\n\n if (!bridgeSuccess) {\n assembly {\n revert(add(bridgeResult, 32), mload(bridgeResult))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice sequentially executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each dataItem to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeIds a list of route identifiers\n * @param dataItems a list of functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoutes(\n uint32[] calldata routeIds,\n bytes[] calldata dataItems\n ) external payable {\n uint256 routeIdslength = routeIds.length;\n if (routeIdslength != dataItems.length) revert ArrayLengthMismatch();\n for (uint256 index = 0; index < routeIdslength; ) {\n (bool success, bytes memory result) = addressAt(routeIds[index])\n .delegatecall(dataItems[index]);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice execute a controller function identified using the controllerId in the request\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param socketControllerRequest socketControllerRequest with controllerId to identify the\n * controllerAddress and byteData constructed using functionSelector\n * of the function being invoked\n * @return bytes data received from the call delegated to controller\n */\n function executeController(\n ISocketGateway.SocketControllerRequest calldata socketControllerRequest\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = controllers[\n socketControllerRequest.controllerId\n ].delegatecall(socketControllerRequest.data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice sequentially executes all controller requests\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each controller-request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param controllerRequests a list of socketControllerRequest\n * Each controllerRequest contains controllerId to identify the controllerAddress and\n * byteData constructed using functionSelector of the function being invoked\n */\n function executeControllers(\n ISocketGateway.SocketControllerRequest[] calldata controllerRequests\n ) external payable {\n for (uint32 index = 0; index < controllerRequests.length; ) {\n (bool success, bytes memory result) = controllers[\n controllerRequests[index].controllerId\n ].delegatecall(controllerRequests[index].data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**************************************\n * ADMIN FUNCTIONS *\n **************************************/\n\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(\n address routeAddress\n ) external onlyOwner returns (uint32) {\n uint32 routeId = routesCount;\n routes[routeId] = routeAddress;\n\n routesCount += 1;\n\n emit NewRouteAdded(routeId, routeAddress);\n\n return routeId;\n }\n\n /**\n * @notice Give Infinite or 0 approval to bridgeRoute for the tokenAddress\n This is a restricted function to be called by only socketGatewayOwner\n */\n\n function setApprovalForRouters(\n address[] memory routeAddresses,\n address[] memory tokenAddresses,\n bool isMax\n ) external onlyOwner {\n for (uint32 index = 0; index < routeAddresses.length; ) {\n ERC20(tokenAddresses[index]).approve(\n routeAddresses[index],\n isMax ? type(uint256).max : 0\n );\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address controllerAddress\n ) external onlyOwner returns (uint32) {\n uint32 controllerId = controllerCount;\n\n controllers[controllerId] = controllerAddress;\n\n controllerCount += 1;\n\n emit ControllerAdded(controllerId, controllerAddress);\n\n return controllerId;\n }\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 controllerId) public onlyOwner {\n controllers[controllerId] = disabledRouteAddress;\n emit ControllerDisabled(controllerId);\n }\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external onlyOwner {\n routes[routeId] = disabledRouteAddress;\n emit RouteDisabled(routeId);\n }\n\n /*******************************************\n * RESTRICTED RESCUE FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n\n /*******************************************\n * VIEW FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) public view returns (address) {\n return addressAt(routeId);\n }\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 controllerId) public view returns (address) {\n return controllers[controllerId];\n }\n\n function addressAt(uint32 routeId) public view returns (address) {\n if (routeId < 385) {\n if (routeId < 257) {\n if (routeId < 129) {\n if (routeId < 65) {\n if (routeId < 33) {\n if (routeId < 17) {\n if (routeId < 9) {\n if (routeId < 5) {\n if (routeId < 3) {\n if (routeId == 1) {\n return\n 0x8cd6BaCDAe46B449E2e5B34e348A4eD459c84D50;\n } else {\n return\n 0x31524750Cd865fF6A3540f232754Fb974c18585C;\n }\n } else {\n if (routeId == 3) {\n return\n 0xEd9b37342BeC8f3a2D7b000732ec87498aA6EC6a;\n } else {\n return\n 0xE8704Ef6211F8988Ccbb11badC89841808d66890;\n }\n }\n } else {\n if (routeId < 7) {\n if (routeId == 5) {\n return\n 0x9aFF58C460a461578C433e11C4108D1c4cF77761;\n } else {\n return\n 0x2D1733886cFd465B0B99F1492F40847495f334C5;\n }\n } else {\n if (routeId == 7) {\n return\n 0x715497Be4D130F04B8442F0A1F7a9312D4e54FC4;\n } else {\n return\n 0x90C8a40c38E633B5B0e0d0585b9F7FA05462CaaF;\n }\n }\n }\n } else {\n if (routeId < 13) {\n if (routeId < 11) {\n if (routeId == 9) {\n return\n 0xa402b70FCfF3F4a8422B93Ef58E895021eAdE4F6;\n } else {\n return\n 0xc1B718522E15CD42C4Ac385a929fc2B51f5B892e;\n }\n } else {\n if (routeId == 11) {\n return\n 0xa97bf2f7c26C43c010c349F52f5eA5dC49B2DD38;\n } else {\n return\n 0x969423d71b62C81d2f28d707364c9Dc4a0764c53;\n }\n }\n } else {\n if (routeId < 15) {\n if (routeId == 13) {\n return\n 0xF86729934C083fbEc8C796068A1fC60701Ea1207;\n } else {\n return\n 0xD7cC2571F5823caCA26A42690D2BE7803DD5393f;\n }\n } else {\n if (routeId == 15) {\n return\n 0x7c8837a279bbbf7d8B93413763176de9F65d5bB9;\n } else {\n return\n 0x13b81C27B588C07D04458ed7dDbdbD26D1e39bcc;\n }\n }\n }\n }\n } else {\n if (routeId < 25) {\n if (routeId < 21) {\n if (routeId < 19) {\n if (routeId == 17) {\n return\n 0x52560Ac678aFA1345D15474287d16Dc1eA3F78aE;\n } else {\n return\n 0x1E31e376551459667cd7643440c1b21CE69065A0;\n }\n } else {\n if (routeId == 19) {\n return\n 0xc57D822CB3288e7b97EF8f8af0EcdcD1B783529B;\n } else {\n return\n 0x2197A1D9Af24b4d6a64Bff95B4c29Fcd3Ff28C30;\n }\n }\n } else {\n if (routeId < 23) {\n if (routeId == 21) {\n return\n 0xE3700feAa5100041Bf6b7AdBA1f72f647809Fd00;\n } else {\n return\n 0xc02E8a0Fdabf0EeFCEA025163d90B5621E2b9948;\n }\n } else {\n if (routeId == 23) {\n return\n 0xF5144235E2926cAb3c69b30113254Fa632f72d62;\n } else {\n return\n 0xBa3F92313B00A1f7Bc53b2c24EB195c8b2F57682;\n }\n }\n }\n } else {\n if (routeId < 29) {\n if (routeId < 27) {\n if (routeId == 25) {\n return\n 0x77a6856fe1fFA5bEB55A1d2ED86E27C7c482CB76;\n } else {\n return\n 0x4826Ff4e01E44b1FCEFBfb38cd96687Eb7786b44;\n }\n } else {\n if (routeId == 27) {\n return\n 0x55FF3f5493cf5e80E76DEA7E327b9Cd8440Af646;\n } else {\n return\n 0xF430Db544bE9770503BE4aa51997aA19bBd5BA4f;\n }\n }\n } else {\n if (routeId < 31) {\n if (routeId == 29) {\n return\n 0x0f166446ce1484EE3B0663E7E67DF10F5D240115;\n } else {\n return\n 0x6365095D92537f242Db5EdFDd572745E72aC33d9;\n }\n } else {\n if (routeId == 31) {\n return\n 0x5c7BC93f06ce3eAe75ADf55E10e23d2c1dE5Bc65;\n } else {\n return\n 0xe46383bAD90d7A08197ccF08972e9DCdccCE9BA4;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 49) {\n if (routeId < 41) {\n if (routeId < 37) {\n if (routeId < 35) {\n if (routeId == 33) {\n return\n 0xf0f21710c071E3B728bdc4654c3c0b873aAaa308;\n } else {\n return\n 0x63Bc9ed3AcAAeB0332531C9fB03b0a2352E9Ff25;\n }\n } else {\n if (routeId == 35) {\n return\n 0xd1CE808625CB4007a1708824AE82CdB0ece57De9;\n } else {\n return\n 0x57BbB148112f4ba224841c3FE018884171004661;\n }\n }\n } else {\n if (routeId < 39) {\n if (routeId == 37) {\n return\n 0x037f7d6933036F34DFabd40Ff8e4D789069f92e3;\n } else {\n return\n 0xeF978c280915CfF3Dca4EDfa8932469e40ADA1e1;\n }\n } else {\n if (routeId == 39) {\n return\n 0x92ee9e071B13f7ecFD62B7DED404A16CBc223CD3;\n } else {\n return\n 0x94Ae539c186e41ed762271338Edf140414D1E442;\n }\n }\n }\n } else {\n if (routeId < 45) {\n if (routeId < 43) {\n if (routeId == 41) {\n return\n 0x30A64BBe4DdBD43dA2368EFd1eB2d80C10d84DAb;\n } else {\n return\n 0x3aEABf81c1Dc4c1b73d5B2a95410f126426FB596;\n }\n } else {\n if (routeId == 43) {\n return\n 0x25b08aB3D0C8ea4cC9d967b79688C6D98f3f563a;\n } else {\n return\n 0xea40cB15C9A3BBd27af6474483886F7c0c9AE406;\n }\n }\n } else {\n if (routeId < 47) {\n if (routeId == 45) {\n return\n 0x9580113Cc04e5a0a03359686304EF3A80b936Dd3;\n } else {\n return\n 0xD211c826d568957F3b66a3F4d9c5f68cCc66E619;\n }\n } else {\n if (routeId == 47) {\n return\n 0xCEE24D0635c4C56315d133b031984d4A6f509476;\n } else {\n return\n 0x3922e6B987983229798e7A20095EC372744d4D4c;\n }\n }\n }\n }\n } else {\n if (routeId < 57) {\n if (routeId < 53) {\n if (routeId < 51) {\n if (routeId == 49) {\n return\n 0x2d92D03413d296e1F31450479349757187F2a2b7;\n } else {\n return\n 0x0fe5308eE90FC78F45c89dB6053eA859097860CA;\n }\n } else {\n if (routeId == 51) {\n return\n 0x08Ba68e067C0505bAF0C1311E0cFB2B1B59b969c;\n } else {\n return\n 0x9bee5DdDF75C24897374f92A534B7A6f24e97f4a;\n }\n }\n } else {\n if (routeId < 55) {\n if (routeId == 53) {\n return\n 0x1FC5A90B232208704B930c1edf82FFC6ACc02734;\n } else {\n return\n 0x5b1B0417cb44c761C2a23ee435d011F0214b3C85;\n }\n } else {\n if (routeId == 55) {\n return\n 0x9d70cDaCA12A738C283020760f449D7816D592ec;\n } else {\n return\n 0x95a23b9CB830EcCFDDD5dF56A4ec665e3381Fa12;\n }\n }\n }\n } else {\n if (routeId < 61) {\n if (routeId < 59) {\n if (routeId == 57) {\n return\n 0x483a957Cf1251c20e096C35c8399721D1200A3Fc;\n } else {\n return\n 0xb4AD39Cb293b0Ec7FEDa743442769A7FF04987CD;\n }\n } else {\n if (routeId == 59) {\n return\n 0x4C543AD78c1590D81BAe09Fc5B6Df4132A2461d0;\n } else {\n return\n 0x471d5E5195c563902781734cfe1FF3981F8B6c86;\n }\n }\n } else {\n if (routeId < 63) {\n if (routeId == 61) {\n return\n 0x1B12a54B5E606D95B8B8D123c9Cb09221Ee37584;\n } else {\n return\n 0xE4127cC550baC433646a7D998775a84daC16c7f3;\n }\n } else {\n if (routeId == 63) {\n return\n 0xecb1b55AB12E7dd788D585c6C5cD61B5F87be836;\n } else {\n return\n 0xf91ef487C5A1579f70601b6D347e19756092eEBf;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 97) {\n if (routeId < 81) {\n if (routeId < 73) {\n if (routeId < 69) {\n if (routeId < 67) {\n if (routeId == 65) {\n return\n 0x34a16a7e9BADEEFD4f056310cbE0b1423Fa1b760;\n } else {\n return\n 0x60E10E80c7680f429dBbC232830BEcd3D623c4CF;\n }\n } else {\n if (routeId == 67) {\n return\n 0x66465285B8D65362A1d86CE00fE2bE949Fd6debF;\n } else {\n return\n 0x5aB231B7e1A3A74a48f67Ab7bde5Cdd4267022E0;\n }\n }\n } else {\n if (routeId < 71) {\n if (routeId == 69) {\n return\n 0x3A1C3633eE79d43366F5c67802a746aFD6b162Ba;\n } else {\n return\n 0x0C4BfCbA8dC3C811437521a80E81e41DAF479039;\n }\n } else {\n if (routeId == 71) {\n return\n 0x6caf25d2e139C5431a1FA526EAf8d73ff2e6252C;\n } else {\n return\n 0x74ad21e09FDa68638CE14A3009A79B6D16574257;\n }\n }\n }\n } else {\n if (routeId < 77) {\n if (routeId < 75) {\n if (routeId == 73) {\n return\n 0xD4923A61008894b99cc1CD3407eF9524f02aA0Ca;\n } else {\n return\n 0x6F159b5EB823BD415886b9271aA2A723a00a1987;\n }\n } else {\n if (routeId == 75) {\n return\n 0x742a8aA42E7bfB4554dE30f4Fb07FFb6f2068863;\n } else {\n return\n 0x4AE9702d3360400E47B446e76DE063ACAb930101;\n }\n }\n } else {\n if (routeId < 79) {\n if (routeId == 77) {\n return\n 0x0E19a0a44ddA7dAD854ec5Cc867d16869c4E80F4;\n } else {\n return\n 0xE021A51968f25148F726E326C88d2556c5647557;\n }\n } else {\n if (routeId == 79) {\n return\n 0x64287BDDDaeF4d94E4599a3D882bed29E6Ada4B6;\n } else {\n return\n 0xcBB57Fd2e19cc7e9D444d5b4325A2F1047d0C73f;\n }\n }\n }\n }\n } else {\n if (routeId < 89) {\n if (routeId < 85) {\n if (routeId < 83) {\n if (routeId == 81) {\n return\n 0x373DE80DF7D82cFF6D76F29581b360C56331e957;\n } else {\n return\n 0x0466356E131AD61596a51F86BAd1C03A328960D8;\n }\n } else {\n if (routeId == 83) {\n return\n 0x01726B960992f1b74311b248E2a922fC707d43A6;\n } else {\n return\n 0x2E21bdf9A4509b89795BCE7E132f248a75814CEc;\n }\n }\n } else {\n if (routeId < 87) {\n if (routeId == 85) {\n return\n 0x769512b23aEfF842379091d3B6E4B5456F631D42;\n } else {\n return\n 0xe7eD9be946a74Ec19325D39C6EEb57887ccB2B0D;\n }\n } else {\n if (routeId == 87) {\n return\n 0xc4D01Ec357c2b511d10c15e6b6974380F0E62e67;\n } else {\n return\n 0x5bC49CC9dD77bECF2fd3A3C55611e84E69AFa3AE;\n }\n }\n }\n } else {\n if (routeId < 93) {\n if (routeId < 91) {\n if (routeId == 89) {\n return\n 0x48bcD879954fA14e7DbdAeb56F79C1e9DDcb69ec;\n } else {\n return\n 0xE929bDde21b462572FcAA4de6F49B9D3246688D0;\n }\n } else {\n if (routeId == 91) {\n return\n 0x85Aae300438222f0e3A9Bc870267a5633A9438bd;\n } else {\n return\n 0x51f72E1096a81C55cd142d66d39B688C657f9Be8;\n }\n }\n } else {\n if (routeId < 95) {\n if (routeId == 93) {\n return\n 0x3A8a05BF68ac54B01E6C0f492abF97465F3d15f9;\n } else {\n return\n 0x145aA67133F0c2C36b9771e92e0B7655f0D59040;\n }\n } else {\n if (routeId == 95) {\n return\n 0xa030315d7DB11F9892758C9e7092D841e0ADC618;\n } else {\n return\n 0xdF1f8d81a3734bdDdEfaC6Ca1596E081e57c3044;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 113) {\n if (routeId < 105) {\n if (routeId < 101) {\n if (routeId < 99) {\n if (routeId == 97) {\n return\n 0xFF2833123B58aa05d04D7fb99f5FB768B2b435F8;\n } else {\n return\n 0xc8f09c1fD751C570233765f71b0e280d74e6e743;\n }\n } else {\n if (routeId == 99) {\n return\n 0x3026DA6Ceca2E5A57A05153653D9212FFAaA49d8;\n } else {\n return\n 0xdE68Ee703dE0D11f67B0cE5891cB4a903de6D160;\n }\n }\n } else {\n if (routeId < 103) {\n if (routeId == 101) {\n return\n 0xE23a7730e81FB4E87A6D0bd9f63EE77ac86C3DA4;\n } else {\n return\n 0x8b1DBe04aD76a7d8bC079cACd3ED4D99B897F4a0;\n }\n } else {\n if (routeId == 103) {\n return\n 0xBB227240FA459b69C6889B2b8cb1BE76F118061f;\n } else {\n return\n 0xC062b9b3f0dB28BB8afAfcD4d075729344114ffe;\n }\n }\n }\n } else {\n if (routeId < 109) {\n if (routeId < 107) {\n if (routeId == 105) {\n return\n 0x553188Aa45f5FDB83EC4Ca485982F8fC082480D1;\n } else {\n return\n 0x0109d83D746EaCb6d4014953D9E12d6ca85e330b;\n }\n } else {\n if (routeId == 107) {\n return\n 0x45B1bEd29812F5bf6711074ACD180B2aeB783AD9;\n } else {\n return\n 0xdA06eC8c19aea31D77F60299678Cba40E743e1aD;\n }\n }\n } else {\n if (routeId < 111) {\n if (routeId == 109) {\n return\n 0x3cC5235c97d975a9b4FD4501B3446c981ea3D855;\n } else {\n return\n 0xa1827267d6Bd989Ff38580aE3d9deff6Acf19163;\n }\n } else {\n if (routeId == 111) {\n return\n 0x3663CAA0433A3D4171b3581Cf2410702840A735A;\n } else {\n return\n 0x7575D0a7614F655BA77C74a72a43bbd4fA6246a3;\n }\n }\n }\n }\n } else {\n if (routeId < 121) {\n if (routeId < 117) {\n if (routeId < 115) {\n if (routeId == 113) {\n return\n 0x2516Defc18bc07089c5dAFf5eafD7B0EF64611E2;\n } else {\n return\n 0xfec5FF08E20fbc107a97Af2D38BD0025b84ee233;\n }\n } else {\n if (routeId == 115) {\n return\n 0x0FB5763a87242B25243e23D73f55945fE787523A;\n } else {\n return\n 0xe4C00db89678dBf8391f430C578Ca857Dd98aDE1;\n }\n }\n } else {\n if (routeId < 119) {\n if (routeId == 117) {\n return\n 0x8F2A22061F9F35E64f14523dC1A5f8159e6a21B7;\n } else {\n return\n 0x18e4b838ae966917E20E9c9c5Ad359cDD38303bB;\n }\n } else {\n if (routeId == 119) {\n return\n 0x61ACb1d3Dcb3e3429832A164Cc0fC9849fb75A4a;\n } else {\n return\n 0x7681e3c8e7A41DCA55C257cc0d1Ae757f5530E65;\n }\n }\n }\n } else {\n if (routeId < 125) {\n if (routeId < 123) {\n if (routeId == 121) {\n return\n 0x806a2AB9748C3D1DB976550890E3f528B7E8Faec;\n } else {\n return\n 0xBDb8A5DD52C2c239fbC31E9d43B763B0197028FF;\n }\n } else {\n if (routeId == 123) {\n return\n 0x474EC9203706010B9978D6bD0b105D36755e4848;\n } else {\n return\n 0x8dfd0D829b303F2239212E591a0F92a32880f36E;\n }\n }\n } else {\n if (routeId < 127) {\n if (routeId == 125) {\n return\n 0xad4BcE9745860B1adD6F1Bd34a916f050E4c82C2;\n } else {\n return\n 0xBC701115b9fe14bC8CC5934cdC92517173e308C4;\n }\n } else {\n if (routeId == 127) {\n return\n 0x0D1918d786Db8546a11aDeD475C98370E06f255E;\n } else {\n return\n 0xee44f57cD6936DB55B99163f3Df367B01EdA785a;\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 193) {\n if (routeId < 161) {\n if (routeId < 145) {\n if (routeId < 137) {\n if (routeId < 133) {\n if (routeId < 131) {\n if (routeId == 129) {\n return\n 0x63044521fe5a1e488D7eD419cD0e35b7C24F2aa7;\n } else {\n return\n 0x410085E73BD85e90d97b84A68C125aDB9F91f85b;\n }\n } else {\n if (routeId == 131) {\n return\n 0x7913fe97E07C7A397Ec274Ab1d4E2622C88EC5D1;\n } else {\n return\n 0x977f9fE93c064DCf54157406DaABC3a722e8184C;\n }\n }\n } else {\n if (routeId < 135) {\n if (routeId == 133) {\n return\n 0xCD2236468722057cFbbABad2db3DEA9c20d5B01B;\n } else {\n return\n 0x17c7287A491cf5Ff81E2678cF2BfAE4333F6108c;\n }\n } else {\n if (routeId == 135) {\n return\n 0x354D9a5Dbf96c71B79a265F03B595C6Fdc04dadd;\n } else {\n return\n 0xb4e409EB8e775eeFEb0344f9eee884cc7ed21c69;\n }\n }\n }\n } else {\n if (routeId < 141) {\n if (routeId < 139) {\n if (routeId == 137) {\n return\n 0xa1a3c4670Ad69D9be4ab2D39D1231FEC2a63b519;\n } else {\n return\n 0x4589A22199870729C1be5CD62EE93BeD858113E6;\n }\n } else {\n if (routeId == 139) {\n return\n 0x8E7b864dB26Bd6C798C38d4Ba36EbA0d6602cF11;\n } else {\n return\n 0xA2D17C7260a4CB7b9854e89Fc367E80E87872a2d;\n }\n }\n } else {\n if (routeId < 143) {\n if (routeId == 141) {\n return\n 0xC7F0EDf0A1288627b0432304918A75e9084CBD46;\n } else {\n return\n 0xE4B4EF1f9A4aBFEdB371fA7a6143993B15d4df25;\n }\n } else {\n if (routeId == 143) {\n return\n 0xfe3D84A2Ef306FEBb5452441C9BDBb6521666F6A;\n } else {\n return\n 0x8A12B6C64121920110aE58F7cd67DfEc21c6a4C3;\n }\n }\n }\n }\n } else {\n if (routeId < 153) {\n if (routeId < 149) {\n if (routeId < 147) {\n if (routeId == 145) {\n return\n 0x76c4d9aFC4717a2BAac4e5f26CccF02351f7a3DA;\n } else {\n return\n 0xd4719BA550E397aeAcca1Ad2201c1ba69024FAAf;\n }\n } else {\n if (routeId == 147) {\n return\n 0x9646126Ce025224d1682C227d915a386efc0A1Fb;\n } else {\n return\n 0x4DD8Af2E3F2044842f0247920Bc4BABb636915ea;\n }\n }\n } else {\n if (routeId < 151) {\n if (routeId == 149) {\n return\n 0x8e8a327183Af0cf8C2ece9F0ed547C42A160D409;\n } else {\n return\n 0x9D49614CaE1C685C71678CA6d8CDF7584bfd0740;\n }\n } else {\n if (routeId == 151) {\n return\n 0x5a00ef257394cbc31828d48655E3d39e9c11c93d;\n } else {\n return\n 0xC9a2751b38d3dDD161A41Ca0135C5C6c09EC1d56;\n }\n }\n }\n } else {\n if (routeId < 157) {\n if (routeId < 155) {\n if (routeId == 153) {\n return\n 0x7e1c261640a525C94Ca4f8c25b48CF754DD83590;\n } else {\n return\n 0x409Fe24ba6F6BD5aF31C1aAf8059b986A3158233;\n }\n } else {\n if (routeId == 155) {\n return\n 0x704Cf5BFDADc0f55fDBb53B6ed8B582E018A72A2;\n } else {\n return\n 0x3982bF65d7d6E77E3b6661cd6F6468c247512737;\n }\n }\n } else {\n if (routeId < 159) {\n if (routeId == 157) {\n return\n 0x3982b9f26FFD67a13Ee371e2C0a9Da338BA70E7f;\n } else {\n return\n 0x6D834AB385900c1f49055D098e90264077FbC4f2;\n }\n } else {\n if (routeId == 159) {\n return\n 0x11FE5F70779A094B7166B391e1Fb73d422eF4e4d;\n } else {\n return\n 0xD347e4E47280d21F13B73D89c6d16f867D50DD13;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 177) {\n if (routeId < 169) {\n if (routeId < 165) {\n if (routeId < 163) {\n if (routeId == 161) {\n return\n 0xb6035eDD53DDA28d8B69b4ae9836E40C80306CD7;\n } else {\n return\n 0x54c884e6f5C7CcfeCA990396c520C858c922b6CA;\n }\n } else {\n if (routeId == 163) {\n return\n 0x5eA93E240b083d686558Ed607BC013d88057cE46;\n } else {\n return\n 0x4C7131eE812De685cBe4e2cCb033d46ecD46612E;\n }\n }\n } else {\n if (routeId < 167) {\n if (routeId == 165) {\n return\n 0xc1a5Be9F0c33D8483801D702111068669f81fF91;\n } else {\n return\n 0x9E5fAb91455Be5E5b2C05967E73F456c8118B1Fc;\n }\n } else {\n if (routeId == 167) {\n return\n 0x3d9A05927223E0DC2F382831770405885e22F0d8;\n } else {\n return\n 0x6303A011fB6063f5B1681cb5a9938EA278dc6128;\n }\n }\n }\n } else {\n if (routeId < 173) {\n if (routeId < 171) {\n if (routeId == 169) {\n return\n 0xe9c60795c90C66797e4c8E97511eA07CdAda32bE;\n } else {\n return\n 0xD56cC98e69A1e13815818b466a8aA6163d84234A;\n }\n } else {\n if (routeId == 171) {\n return\n 0x47EbB9D36a6e40895316cD894E4860D774E2c531;\n } else {\n return\n 0xA5EB293629410065d14a7B1663A67829b0618292;\n }\n }\n } else {\n if (routeId < 175) {\n if (routeId == 173) {\n return\n 0x1b3B4C8146F939cE00899db8B3ddeF0062b7E023;\n } else {\n return\n 0x257Bbc11653625EbfB6A8587eF4f4FBe49828EB3;\n }\n } else {\n if (routeId == 175) {\n return\n 0x44cc979C01b5bB1eAC21301E73C37200dFD06F59;\n } else {\n return\n 0x2972fDF43352225D82754C0174Ff853819D1ef2A;\n }\n }\n }\n }\n } else {\n if (routeId < 185) {\n if (routeId < 181) {\n if (routeId < 179) {\n if (routeId == 177) {\n return\n 0x3e54144f032648A04D62d79f7B4b93FF3aC2333b;\n } else {\n return\n 0x444016102dB8adbE73C3B6703a1ea7F2f75A510D;\n }\n } else {\n if (routeId == 179) {\n return\n 0xac079143f98a6eb744Fde34541ebF243DF5B5dED;\n } else {\n return\n 0xAe9010767Fb112d29d35CEdfba2b372Ad7A308d3;\n }\n }\n } else {\n if (routeId < 183) {\n if (routeId == 181) {\n return\n 0xfE0BCcF9cCC2265D5fB3450743f17DfE57aE1e56;\n } else {\n return\n 0x04ED8C0545716119437a45386B1d691C63234C7D;\n }\n } else {\n if (routeId == 183) {\n return\n 0x636c14013e531A286Bc4C848da34585f0bB73d59;\n } else {\n return\n 0x2Fa67fc7ECC5cAA01C653d3BFeA98ecc5db9C42A;\n }\n }\n }\n } else {\n if (routeId < 189) {\n if (routeId < 187) {\n if (routeId == 185) {\n return\n 0x23e9a0FC180818aA872D2079a985217017E97bd9;\n } else {\n return\n 0x79A95c3Ef81b3ae64ee03A9D5f73e570495F164E;\n }\n } else {\n if (routeId == 187) {\n return\n 0xa7EA0E88F04a84ba0ad1E396cb07Fa3fDAD7dF6D;\n } else {\n return\n 0xd23cA1278a2B01a3C0Ca1a00d104b11c1Ebe6f42;\n }\n }\n } else {\n if (routeId < 191) {\n if (routeId == 189) {\n return\n 0x707bc4a9FA2E349AED5df4e9f5440C15aA9D14Bd;\n } else {\n return\n 0x7E290F2dd539Ac6CE58d8B4C2B944931a1fD3612;\n }\n } else {\n if (routeId == 191) {\n return\n 0x707AA5503088Ce06Ba450B6470A506122eA5c8eF;\n } else {\n return\n 0xFbB3f7BF680deeb149f4E7BC30eA3DDfa68F3C3f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 225) {\n if (routeId < 209) {\n if (routeId < 201) {\n if (routeId < 197) {\n if (routeId < 195) {\n if (routeId == 193) {\n return\n 0xDE74aD8cCC3dbF14992f49Cf24f36855912f4934;\n } else {\n return\n 0x409BA83df7777F070b2B50a10a41DE2468d2a3B3;\n }\n } else {\n if (routeId == 195) {\n return\n 0x5CB7Be90A5DD7CfDa54e87626e254FE8C18255B4;\n } else {\n return\n 0x0A684fE12BC64fb72B59d0771a566F49BC090356;\n }\n }\n } else {\n if (routeId < 199) {\n if (routeId == 197) {\n return\n 0xDf30048d91F8FA2bCfC54952B92bFA8e161D3360;\n } else {\n return\n 0x050825Fff032a547C47061CF0696FDB0f65AEa5D;\n }\n } else {\n if (routeId == 199) {\n return\n 0xd55e671dAC1f03d366d8535073ada5DB2Aab1Ea2;\n } else {\n return\n 0x9470C704A9616c8Cd41c595Fcd2181B6fe2183C2;\n }\n }\n }\n } else {\n if (routeId < 205) {\n if (routeId < 203) {\n if (routeId == 201) {\n return\n 0x2D9ffD275181F5865d5e11CbB4ced1521C4dF9f1;\n } else {\n return\n 0x816d28Dec10ec95DF5334f884dE85cA6215918d8;\n }\n } else {\n if (routeId == 203) {\n return\n 0xd1f87267c4A43835E666dd69Df077e578A3b6299;\n } else {\n return\n 0x39E89Bde9DACbe5468C025dE371FbDa12bDeBAB1;\n }\n }\n } else {\n if (routeId < 207) {\n if (routeId == 205) {\n return\n 0x7b40A3207956ecad6686E61EfcaC48912FcD0658;\n } else {\n return\n 0x090cF10D793B1Efba9c7D76115878814B663859A;\n }\n } else {\n if (routeId == 207) {\n return\n 0x312A59c06E41327878F2063eD0e9c282C1DA3AfC;\n } else {\n return\n 0x4F1188f46236DD6B5de11Ebf2a9fF08716E7DeB6;\n }\n }\n }\n }\n } else {\n if (routeId < 217) {\n if (routeId < 213) {\n if (routeId < 211) {\n if (routeId == 209) {\n return\n 0x0A6F9a3f4fA49909bBfb4339cbE12B42F53BbBeD;\n } else {\n return\n 0x01d13d7aCaCbB955B81935c80ffF31e14BdFa71f;\n }\n } else {\n if (routeId == 211) {\n return\n 0x691a14Fa6C7360422EC56dF5876f84d4eDD7f00A;\n } else {\n return\n 0x97Aad18d886d181a9c726B3B6aE15a0A69F5aF73;\n }\n }\n } else {\n if (routeId < 215) {\n if (routeId == 213) {\n return\n 0x2917241371D2099049Fa29432DC46735baEC33b4;\n } else {\n return\n 0x5F20F20F7890c2e383E29D4147C9695A371165f5;\n }\n } else {\n if (routeId == 215) {\n return\n 0xeC0a60e639958335662C5219A320cCEbb56C6077;\n } else {\n return\n 0x96d63CF5062975C09845d17ec672E10255866053;\n }\n }\n }\n } else {\n if (routeId < 221) {\n if (routeId < 219) {\n if (routeId == 217) {\n return\n 0xFF57429e57D383939CAB50f09ABBfB63C0e6c9AD;\n } else {\n return\n 0x18E393A7c8578fb1e235C242076E50013cDdD0d7;\n }\n } else {\n if (routeId == 219) {\n return\n 0xE7E5238AF5d61f52E9B4ACC025F713d1C0216507;\n } else {\n return\n 0x428401D4d0F25A2EE1DA4d5366cB96Ded425D9bD;\n }\n }\n } else {\n if (routeId < 223) {\n if (routeId == 221) {\n return\n 0x42E5733551ff1Ee5B48Aa9fc2B61Af9b58C812E6;\n } else {\n return\n 0x64Df9c7A0551B056d860Bc2419Ca4c1EF75320bE;\n }\n } else {\n if (routeId == 223) {\n return\n 0x46006925506145611bBf0263243D8627dAf26B0F;\n } else {\n return\n 0x8D64BE884314662804eAaB884531f5C50F4d500c;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 241) {\n if (routeId < 233) {\n if (routeId < 229) {\n if (routeId < 227) {\n if (routeId == 225) {\n return\n 0x157a62D92D07B5ce221A5429645a03bBaCE85373;\n } else {\n return\n 0xaF037D33e1F1F2F87309B425fe8a9d895Ef3722B;\n }\n } else {\n if (routeId == 227) {\n return\n 0x921D1154E494A2f7218a37ad7B17701f94b4B40e;\n } else {\n return\n 0xF282b4555186d8Dea51B8b3F947E1E0568d09bc4;\n }\n }\n } else {\n if (routeId < 231) {\n if (routeId == 229) {\n return\n 0xa794E2E1869765a4600b3DFd8a4ebcF16350f6B6;\n } else {\n return\n 0xFEFb048e20c5652F7940A49B1980E0125Ec4D358;\n }\n } else {\n if (routeId == 231) {\n return\n 0x220104b641971e9b25612a8F001bf48AbB23f1cF;\n } else {\n return\n 0xcB9D373Bb54A501B35dd3be5bF4Ba43cA31F7035;\n }\n }\n }\n } else {\n if (routeId < 237) {\n if (routeId < 235) {\n if (routeId == 233) {\n return\n 0x37D627F56e3FF36aC316372109ea82E03ac97DAc;\n } else {\n return\n 0x4E81355FfB4A271B4EA59ff78da2b61c7833161f;\n }\n } else {\n if (routeId == 235) {\n return\n 0xADd8D65cAF6Cc9ad73127B49E16eA7ac29d91e87;\n } else {\n return\n 0x630F9b95626487dfEAe3C97A44DB6C59cF35d996;\n }\n }\n } else {\n if (routeId < 239) {\n if (routeId == 237) {\n return\n 0x78CE2BC8238B679680A67FCB98C5A60E4ec17b2D;\n } else {\n return\n 0xA38D776028eD1310b9A6b086f67F788201762E21;\n }\n } else {\n if (routeId == 239) {\n return\n 0x7Bb5178827B76B86753Ed62a0d662c72cEcb1bD3;\n } else {\n return\n 0x4faC26f61C76eC5c3D43b43eDfAFF0736Ae0e3da;\n }\n }\n }\n }\n } else {\n if (routeId < 249) {\n if (routeId < 245) {\n if (routeId < 243) {\n if (routeId == 241) {\n return\n 0x791Bb49bfFA7129D6889FDB27744422Ac4571A85;\n } else {\n return\n 0x26766fFEbb5fa564777913A6f101dF019AB32afa;\n }\n } else {\n if (routeId == 243) {\n return\n 0x05e98E5e95b4ECBbbAf3258c3999Cc81ed8048Be;\n } else {\n return\n 0xC5c4621e52f1D6A1825A5ed4F95855401a3D9C6b;\n }\n }\n } else {\n if (routeId < 247) {\n if (routeId == 245) {\n return\n 0xfcb15f909BA7FC7Ea083503Fb4c1020203c107EB;\n } else {\n return\n 0xbD27603279d969c74f2486ad14E71080829DFd38;\n }\n } else {\n if (routeId == 247) {\n return\n 0xff2f756BcEcC1A55BFc09a30cc5F64720458cFCB;\n } else {\n return\n 0x3bfB968FEbC12F4e8420B2d016EfcE1E615f7246;\n }\n }\n }\n } else {\n if (routeId < 253) {\n if (routeId < 251) {\n if (routeId == 249) {\n return\n 0x982EE9Ffe23051A2ec945ed676D864fa8345222b;\n } else {\n return\n 0xe101899100785E74767d454FFF0131277BaD48d9;\n }\n } else {\n if (routeId == 251) {\n return\n 0x4F730C0c6b3B5B7d06ca511379f4Aa5BfB2E9525;\n } else {\n return\n 0x5499c36b365795e4e0Ef671aF6C2ce26D7c78265;\n }\n }\n } else {\n if (routeId < 255) {\n if (routeId == 253) {\n return\n 0x8AF51F7237Fc8fB2fc3E700488a94a0aC6Ad8b5a;\n } else {\n return\n 0xda8716df61213c0b143F2849785FB85928084857;\n }\n } else {\n if (routeId == 255) {\n return\n 0xF040Cf9b1ebD11Bf28e04e80740DF3DDe717e4f5;\n } else {\n return\n 0xB87ba32f759D14023C7520366B844dF7f0F036C2;\n }\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 321) {\n if (routeId < 289) {\n if (routeId < 273) {\n if (routeId < 265) {\n if (routeId < 261) {\n if (routeId < 259) {\n if (routeId == 257) {\n return\n 0x0Edde681b8478F0c3194f468EdD2dB5e75c65CDD;\n } else {\n return\n 0x59C70900Fca06eE2aCE1BDd5A8D0Af0cc3BBA720;\n }\n } else {\n if (routeId == 259) {\n return\n 0x8041F0f180D17dD07087199632c45E17AeB0BAd5;\n } else {\n return\n 0x4fB4727064BA595995DD516b63b5921Df9B93aC6;\n }\n }\n } else {\n if (routeId < 263) {\n if (routeId == 261) {\n return\n 0x86e98b594565857eD098864F560915C0dAfd6Ea1;\n } else {\n return\n 0x70f8818E8B698EFfeCd86A513a4c87c0c380Bef6;\n }\n } else {\n if (routeId == 263) {\n return\n 0x78Ed227c8A897A21Da2875a752142dd80d865158;\n } else {\n return\n 0xd02A30BB5C3a8C51d2751A029a6fcfDE2Af9fbc6;\n }\n }\n }\n } else {\n if (routeId < 269) {\n if (routeId < 267) {\n if (routeId == 265) {\n return\n 0x0F00d5c5acb24e975e2a56730609f7F40aa763b8;\n } else {\n return\n 0xC3e2091edc2D3D9D98ba09269138b617B536834A;\n }\n } else {\n if (routeId == 267) {\n return\n 0xa6FbaF7F30867C9633908998ea8C3da28920E75C;\n } else {\n return\n 0xE6dDdcD41E2bBe8122AE32Ac29B8fbAB79CD21d9;\n }\n }\n } else {\n if (routeId < 271) {\n if (routeId == 269) {\n return\n 0x537aa8c1Ef6a8Eaf039dd6e1Eb67694a48195cE4;\n } else {\n return\n 0x96ABAC485fd2D0B03CF4a10df8BD58b8dED28300;\n }\n } else {\n if (routeId == 271) {\n return\n 0xda8e7D46d04Bd4F62705Cd80355BDB6d441DafFD;\n } else {\n return\n 0xbE50018E7a5c67E2e5f5414393e971CC96F293f2;\n }\n }\n }\n }\n } else {\n if (routeId < 281) {\n if (routeId < 277) {\n if (routeId < 275) {\n if (routeId == 273) {\n return\n 0xa1b3907D6CB542a4cbe2eE441EfFAA909FAb62C3;\n } else {\n return\n 0x6d08ee8511C0237a515013aC389e7B3968Cb1753;\n }\n } else {\n if (routeId == 275) {\n return\n 0x22faa5B5Fe43eAdbB52745e35a5cdA8bD5F96bbA;\n } else {\n return\n 0x7a673eB74D79e4868D689E7852abB5f93Ec2fD4b;\n }\n }\n } else {\n if (routeId < 279) {\n if (routeId == 277) {\n return\n 0x0b8531F8AFD4190b76F3e10deCaDb84c98b4d419;\n } else {\n return\n 0x78eABC743A93583DeE403D6b84795490e652216B;\n }\n } else {\n if (routeId == 279) {\n return\n 0x3A95D907b2a7a8604B59BccA08585F58Afe0Aa64;\n } else {\n return\n 0xf4271f0C8c9Af0F06A80b8832fa820ccE64FAda8;\n }\n }\n }\n } else {\n if (routeId < 285) {\n if (routeId < 283) {\n if (routeId == 281) {\n return\n 0x74b2DF841245C3748c0d31542e1335659a25C33b;\n } else {\n return\n 0xdFC99Fd0Ad7D16f30f295a5EEFcE029E04d0fa65;\n }\n } else {\n if (routeId == 283) {\n return\n 0xE992416b6aC1144eD8148a9632973257839027F6;\n } else {\n return\n 0x54ce55ba954E981BB1fd9399054B35Ce1f2C0816;\n }\n }\n } else {\n if (routeId < 287) {\n if (routeId == 285) {\n return\n 0xD4AB52f9e7E5B315Bd7471920baD04F405Ab1c38;\n } else {\n return\n 0x3670C990994d12837e95eE127fE2f06FD3E2104B;\n }\n } else {\n if (routeId == 287) {\n return\n 0xDcf190B09C47E4f551E30BBb79969c3FdEA1e992;\n } else {\n return\n 0xa65057B967B59677237e57Ab815B209744b9bc40;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 305) {\n if (routeId < 297) {\n if (routeId < 293) {\n if (routeId < 291) {\n if (routeId == 289) {\n return\n 0x6Efc86B40573e4C7F28659B13327D55ae955C483;\n } else {\n return\n 0x06BcC25CF8e0E72316F53631b3aA7134E9f73Ae0;\n }\n } else {\n if (routeId == 291) {\n return\n 0x710b6414E1D53882b1FCD3A168aD5Ccd435fc6D0;\n } else {\n return\n 0x5Ebb2C3d78c4e9818074559e7BaE7FCc99781DC1;\n }\n }\n } else {\n if (routeId < 295) {\n if (routeId == 293) {\n return\n 0xAf0a409c3AEe0bD08015cfb29D89E90b6e89A88F;\n } else {\n return\n 0x522559d8b99773C693B80cE06DF559036295Ce44;\n }\n } else {\n if (routeId == 295) {\n return\n 0xB65290A5Bae838aaa7825c9ECEC68041841a1B64;\n } else {\n return\n 0x801b8F2068edd5Bcb659E6BDa0c425909043C420;\n }\n }\n }\n } else {\n if (routeId < 301) {\n if (routeId < 299) {\n if (routeId == 297) {\n return\n 0x29b5F00515d093627E0B7bd0b5c8E84F6b4cDb87;\n } else {\n return\n 0x652839Ae74683cbF9f1293F1019D938F87464D3E;\n }\n } else {\n if (routeId == 299) {\n return\n 0x5Bc95dCebDDE9B79F2b6DC76121BC7936eF8D666;\n } else {\n return\n 0x90db359CEA62E53051158Ab5F99811C0a07Fe686;\n }\n }\n } else {\n if (routeId < 303) {\n if (routeId == 301) {\n return\n 0x2c3625EedadbDcDbB5330eb0d17b3C39ff269807;\n } else {\n return\n 0xC3f0324471b5c9d415acD625b8d8694a4e48e001;\n }\n } else {\n if (routeId == 303) {\n return\n 0x8C60e7E05fa0FfB6F720233736f245134685799d;\n } else {\n return\n 0x98fAF2c09aa4EBb995ad0B56152993E7291a500e;\n }\n }\n }\n }\n } else {\n if (routeId < 313) {\n if (routeId < 309) {\n if (routeId < 307) {\n if (routeId == 305) {\n return\n 0x802c1063a861414dFAEc16bacb81429FC0d40D6e;\n } else {\n return\n 0x11C4AeFCC0dC156f64195f6513CB1Fb3Be0Ae056;\n }\n } else {\n if (routeId == 307) {\n return\n 0xEff1F3258214E31B6B4F640b4389d55715C3Be2B;\n } else {\n return\n 0x47e379Abe8DDFEA4289aBa01235EFF7E93758fd7;\n }\n }\n } else {\n if (routeId < 311) {\n if (routeId == 309) {\n return\n 0x3CC26384c3eA31dDc8D9789e8872CeA6F20cD3ff;\n } else {\n return\n 0xEdd9EFa6c69108FAA4611097d643E20Ba0Ed1634;\n }\n } else {\n if (routeId == 311) {\n return\n 0xCb93525CA5f3D371F74F3D112bC19526740717B8;\n } else {\n return\n 0x7071E0124EB4438137e60dF1b8DD8Af1BfB362cF;\n }\n }\n }\n } else {\n if (routeId < 317) {\n if (routeId < 315) {\n if (routeId == 313) {\n return\n 0x4691096EB0b78C8F4b4A8091E5B66b18e1835c10;\n } else {\n return\n 0x8d953c9b2d1C2137CF95992079f3A77fCd793272;\n }\n } else {\n if (routeId == 315) {\n return\n 0xbdCc2A3Bf6e3Ba49ff86595e6b2b8D70d8368c92;\n } else {\n return\n 0x95E6948aB38c61b2D294E8Bd896BCc4cCC0713cf;\n }\n }\n } else {\n if (routeId < 319) {\n if (routeId == 317) {\n return\n 0x607b27C881fFEE4Cb95B1c5862FaE7224ccd0b4A;\n } else {\n return\n 0x09D28aFA166e566A2Ee1cB834ea8e78C7E627eD2;\n }\n } else {\n if (routeId == 319) {\n return\n 0x9c01449b38bDF0B263818401044Fb1401B29fDfA;\n } else {\n return\n 0x1F7723599bbB658c051F8A39bE2688388d22ceD6;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 353) {\n if (routeId < 337) {\n if (routeId < 329) {\n if (routeId < 325) {\n if (routeId < 323) {\n if (routeId == 321) {\n return\n 0x52B71603f7b8A5d15B4482e965a0619aa3210194;\n } else {\n return\n 0x01c0f072CB210406653752FecFA70B42dA9173a2;\n }\n } else {\n if (routeId == 323) {\n return\n 0x3021142f021E943e57fc1886cAF58D06147D09A6;\n } else {\n return\n 0xe6f2AF38e76AB09Db59225d97d3E770942D3D842;\n }\n }\n } else {\n if (routeId < 327) {\n if (routeId == 325) {\n return\n 0x06a25554e5135F08b9e2eD1DEC1fc3CEd52e0B48;\n } else {\n return\n 0x71d75e670EE3511C8290C705E0620126B710BF8D;\n }\n } else {\n if (routeId == 327) {\n return\n 0x8b9cE142b80FeA7c932952EC533694b1DF9B3c54;\n } else {\n return\n 0xd7Be24f32f39231116B3fDc483C2A12E1521f73B;\n }\n }\n }\n } else {\n if (routeId < 333) {\n if (routeId < 331) {\n if (routeId == 329) {\n return\n 0xb40cafBC4797d4Ff64087E087F6D2e661f954CbE;\n } else {\n return\n 0xBdDCe7771EfEe81893e838f62204A4c76D72757e;\n }\n } else {\n if (routeId == 331) {\n return\n 0x5d3D299EA7Fd4F39AcDb336E26631Dfee41F9287;\n } else {\n return\n 0x6BfEE09E1Fc0684e0826A9A0dC1352a14B136FAC;\n }\n }\n } else {\n if (routeId < 335) {\n if (routeId == 333) {\n return\n 0xd0001bB8E2Cb661436093f96458a4358B5156E3c;\n } else {\n return\n 0x1867c6485CfD1eD448988368A22bfB17a7747293;\n }\n } else {\n if (routeId == 335) {\n return\n 0x8997EF9F95dF24aB67703AB6C262aABfeEBE33bD;\n } else {\n return\n 0x1e39E9E601922deD91BCFc8F78836302133465e2;\n }\n }\n }\n }\n } else {\n if (routeId < 345) {\n if (routeId < 341) {\n if (routeId < 339) {\n if (routeId == 337) {\n return\n 0x8A8ec6CeacFf502a782216774E5AF3421562C6ff;\n } else {\n return\n 0x3B8FC561df5415c8DC01e97Ee6E38435A8F9C40A;\n }\n } else {\n if (routeId == 339) {\n return\n 0xD5d5f5B37E67c43ceA663aEDADFFc3a93a2065B0;\n } else {\n return\n 0xCC8F55EC43B4f25013CE1946FBB740c43Be5B96D;\n }\n }\n } else {\n if (routeId < 343) {\n if (routeId == 341) {\n return\n 0x18f586E816eEeDbb57B8011239150367561B58Fb;\n } else {\n return\n 0xd0CD802B19c1a52501cb2f07d656e3Cd7B0Ce124;\n }\n } else {\n if (routeId == 343) {\n return\n 0xe0AeD899b39C6e4f2d83e4913a1e9e0cf6368abE;\n } else {\n return\n 0x0606e1b6c0f1A398C38825DCcc4678a7Cbc2737c;\n }\n }\n }\n } else {\n if (routeId < 349) {\n if (routeId < 347) {\n if (routeId == 345) {\n return\n 0x2d188e85b27d18EF80f16686EA1593ABF7Ed2A63;\n } else {\n return\n 0x64412292fA4A135a3300E24366E99ff59Db2eAc1;\n }\n } else {\n if (routeId == 347) {\n return\n 0x38b74c173f3733E8b90aAEf0e98B89791266149F;\n } else {\n return\n 0x36DAA49A79aaEF4E7a217A11530D3cCD84414124;\n }\n }\n } else {\n if (routeId < 351) {\n if (routeId == 349) {\n return\n 0x10f088FE2C88F90270E4449c46c8B1b232511d58;\n } else {\n return\n 0x4FeDbd25B58586838ABD17D10272697dF1dC3087;\n }\n } else {\n if (routeId == 351) {\n return\n 0x685278209248CB058E5cEe93e37f274A80Faf6eb;\n } else {\n return\n 0xDd9F8F1eeC3955f78168e2Fb2d1e808fa8A8f15b;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 369) {\n if (routeId < 361) {\n if (routeId < 357) {\n if (routeId < 355) {\n if (routeId == 353) {\n return\n 0x7392aEeFD5825aaC28817031dEEBbFaAA20983D9;\n } else {\n return\n 0x0Cc182555E00767D6FB8AD161A10d0C04C476d91;\n }\n } else {\n if (routeId == 355) {\n return\n 0x90E52837d56715c79FD592E8D58bFD20365798b2;\n } else {\n return\n 0x6F4451DE14049B6770ad5BF4013118529e68A40C;\n }\n }\n } else {\n if (routeId < 359) {\n if (routeId == 357) {\n return\n 0x89B97ef2aFAb9ed9c7f0FDb095d02E6840b52d9c;\n } else {\n return\n 0x92A5cC5C42d94d3e23aeB1214fFf43Db2B97759E;\n }\n } else {\n if (routeId == 359) {\n return\n 0x63ddc52F135A1dcBA831EAaC11C63849F018b739;\n } else {\n return\n 0x692A691533B571C2c54C1D7F8043A204b3d8120E;\n }\n }\n }\n } else {\n if (routeId < 365) {\n if (routeId < 363) {\n if (routeId == 361) {\n return\n 0x97c7492CF083969F61C6f302d45c8270391b921c;\n } else {\n return\n 0xDeFD2B8643553dAd19548eB14fd94A57F4B9e543;\n }\n } else {\n if (routeId == 363) {\n return\n 0x30645C04205cA3f670B67b02F971B088930ACB8C;\n } else {\n return\n 0xA6f80ed2d607Cd67aEB4109B64A0BEcc4D7d03CF;\n }\n }\n } else {\n if (routeId < 367) {\n if (routeId == 365) {\n return\n 0xBbbbC6c276eB3F7E674f2D39301509236001c42f;\n } else {\n return\n 0xC20E77d349FB40CE88eB01824e2873ad9f681f3C;\n }\n } else {\n if (routeId == 367) {\n return\n 0x5fCfD9a962De19294467C358C1FA55082285960b;\n } else {\n return\n 0x4D87BD6a0E4E5cc6332923cb3E85fC71b287F58A;\n }\n }\n }\n }\n } else {\n if (routeId < 377) {\n if (routeId < 373) {\n if (routeId < 371) {\n if (routeId == 369) {\n return\n 0x3AA5B757cd6Dde98214E56D57Dde7fcF0F7aB04E;\n } else {\n return\n 0xe28eFCE7192e11a2297f44059113C1fD6967b2d4;\n }\n } else {\n if (routeId == 371) {\n return\n 0x3251cAE10a1Cf246e0808D76ACC26F7B5edA0eE5;\n } else {\n return\n 0xbA2091cc9357Cf4c4F25D64F30d1b4Ba3A5a174B;\n }\n }\n } else {\n if (routeId < 375) {\n if (routeId == 373) {\n return\n 0x49c8e1Da9693692096F63C82D11b52d738566d55;\n } else {\n return\n 0xA0731615aB5FFF451031E9551367A4F7dB27b39c;\n }\n } else {\n if (routeId == 375) {\n return\n 0xFb214541888671AE1403CecC1D59763a12fc1609;\n } else {\n return\n 0x1D6bCB17642E2336405df73dF22F07688cAec020;\n }\n }\n }\n } else {\n if (routeId < 381) {\n if (routeId < 379) {\n if (routeId == 377) {\n return\n 0xfC9c0C7bfe187120fF7f4E21446161794A617a9e;\n } else {\n return\n 0xBa5bF37678EeE2dAB17AEf9D898153258252250E;\n }\n } else {\n if (routeId == 379) {\n return\n 0x7c55690bd2C9961576A32c02f8EB29ed36415Ec7;\n } else {\n return\n 0xcA40073E868E8Bc611aEc8Fe741D17E68Fe422f6;\n }\n }\n } else {\n if (routeId < 383) {\n if (routeId == 381) {\n return\n 0x31641bAFb87E9A58f78835050a7BE56921986339;\n } else {\n return\n 0xA54766424f6dA74b45EbCc5Bf0Bd1D74D2CCcaAB;\n }\n } else {\n if (routeId == 383) {\n return\n 0xc7bBa57F8C179EDDBaa62117ddA360e28f3F8252;\n } else {\n return\n 0x5e663ED97ea77d393B8858C90d0683bF180E0ffd;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n if (routes[routeId] == address(0)) revert ZeroAddressNotAllowed();\n return routes[routeId];\n }\n\n /// @notice fallback function to handle swap, bridge execution\n /// @dev ensure routeId is converted to bytes4 and sent as msg.sig in the transaction\n fallback() external payable {\n address routeAddress = addressAt(uint32(msg.sig));\n\n bytes memory result;\n\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 4, sub(calldatasize(), 4))\n // execute function call using the facet\n result := delegatecall(\n gas(),\n routeAddress,\n 0,\n sub(calldatasize(), 4),\n 0,\n 0\n )\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" - }, - "src/bridges/hop/interfaces/IHopL1Bridge.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title L1Bridge Hop Interface\n * @notice L1 Hop Bridge, Used to transfer from L1 to L2s.\n */\ninterface IHopL1Bridge {\n /**\n * @notice `amountOutMin` and `deadline` should be 0 when no swap is intended at the destination.\n * @notice `amount` is the total amount the user wants to send including the relayer fee\n * @dev Send tokens to a supported layer-2 to mint hToken and optionally swap the hToken in the\n * AMM at the destination.\n * @param chainId The chainId of the destination chain\n * @param recipient The address receiving funds at the destination\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination\n * AMM market. 0 if no swap is intended.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no\n * swap is intended.\n * @param relayer The address of the relayer at the destination.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n */\n function sendToL2(\n uint256 chainId,\n address recipient,\n uint256 amount,\n uint256 amountOutMin,\n uint256 deadline,\n address relayer,\n uint256 relayerFee\n ) external payable;\n}\n" - }, - "src/bridges/refuel/interfaces/refuel.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/// @notice interface with functions to interact with Refuel contract\ninterface IRefuel {\n /**\n * @notice function to deposit nativeToken to Destination-address on destinationChain\n * @param destinationChainId chainId of the Destination chain\n * @param _to recipient address\n */\n function depositNativeToken(\n uint256 destinationChainId,\n address _to\n ) external payable;\n}\n" - }, - "src/bridges/stargate/interfaces/stargate.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\n/**\n * @title IBridgeStargate Interface Contract.\n * @notice Interface used by Stargate-L1 and L2 Router implementations\n * @dev router and routerETH addresses will be distinct for L1 and L2\n */\ninterface IBridgeStargate {\n // @notice Struct to hold the additional-data for bridging ERC20 token\n struct lzTxObj {\n // gas limit to bridge the token in Stargate to destinationChain\n uint256 dstGasForCall;\n // destination nativeAmount, this is always set as 0\n uint256 dstNativeAmount;\n // destination nativeAddress, this is always set as 0x\n bytes dstNativeAddr;\n }\n\n /// @notice function in stargate bridge which is used to bridge ERC20 tokens to recipient on destinationChain\n function swap(\n uint16 _dstChainId,\n uint256 _srcPoolId,\n uint256 _dstPoolId,\n address payable _refundAddress,\n uint256 _amountLD,\n uint256 _minAmountLD,\n lzTxObj memory _lzTxParams,\n bytes calldata _to,\n bytes calldata _payload\n ) external payable;\n\n /// @notice function in stargate bridge which is used to bridge native tokens to recipient on destinationChain\n function swapETH(\n uint16 _dstChainId, // destination Stargate chainId\n address payable _refundAddress, // refund additional messageFee to this address\n bytes calldata _toAddress, // the receiver of the destination ETH\n uint256 _amountLD, // the amount, in Local Decimals, to be swapped\n uint256 _minAmountLD // the minimum amount accepted out on destination\n ) external payable;\n}\n" - }, - "src/controllers/FeesTakerController.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BaseController} from \"./BaseController.sol\";\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\n\n/**\n * @title FeesTaker-Controller Implementation\n * @notice Controller with composed actions to deduct-fees followed by Refuel, Swap and Bridge\n * to be executed Sequentially and this is atomic\n * @author Socket dot tech.\n */\ncontract FeesTakerController is BaseController {\n using SafeTransferLib for ERC20;\n\n /// @notice event emitted upon fee-deduction to fees-taker address\n event SocketFeesDeducted(\n uint256 fees,\n address feesToken,\n address feesTaker\n );\n\n /// @notice Function-selector to invoke deduct-fees and swap token\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_SWAP_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"takeFeesAndSwap((address,address,uint256,uint32,bytes))\")\n );\n\n /// @notice Function-selector to invoke deduct-fees and bridge token\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeesAndBridge((address,address,uint256,uint32,bytes))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees and bridge multiple tokens\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_MULTI_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeesAndMultiBridge((address,address,uint256,uint32[],bytes[]))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees followed by swapping of a token and bridging the swapped bridge\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeeAndSwapAndBridge((address,address,uint256,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees refuel\n /// @notice followed by swapping of a token and bridging the swapped bridge\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeeAndRefuelAndSwapAndBridge((address,address,uint256,uint32,bytes,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BaseController\n constructor(\n address _socketGatewayAddress\n ) BaseController(_socketGatewayAddress) {}\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and swap token\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftsRequest feesTakerSwapRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_SWAP_FUNCTION_SELECTOR\n * @return output bytes from the swap operation (last operation in the composed actions)\n */\n function takeFeesAndSwap(\n ISocketRequest.FeesTakerSwapRequest calldata ftsRequest\n ) external payable returns (bytes memory) {\n if (ftsRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftsRequest.feesTakerAddress).transfer(\n ftsRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftsRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftsRequest.feesTakerAddress,\n ftsRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftsRequest.feesAmount,\n ftsRequest.feesTakerAddress,\n ftsRequest.feesToken\n );\n\n //call bridge function (executeRoute for the swapRequestData)\n return _executeRoute(ftsRequest.routeId, ftsRequest.swapRequestData);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and bridge amount to destinationChain\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftbRequest feesTakerBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_BRIDGE_FUNCTION_SELECTOR\n * @return output bytes from the bridge operation (last operation in the composed actions)\n */\n function takeFeesAndBridge(\n ISocketRequest.FeesTakerBridgeRequest calldata ftbRequest\n ) external payable returns (bytes memory) {\n if (ftbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftbRequest.feesTakerAddress).transfer(\n ftbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftbRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftbRequest.feesTakerAddress,\n ftbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftbRequest.feesAmount,\n ftbRequest.feesTakerAddress,\n ftbRequest.feesToken\n );\n\n //call bridge function (executeRoute for the bridgeData)\n return _executeRoute(ftbRequest.routeId, ftbRequest.bridgeRequestData);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and bridge amount to destinationChain\n * @notice multiple bridge-requests are to be generated and sequence and number of routeIds should match with the bridgeData array\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftmbRequest feesTakerMultiBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_MULTI_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeesAndMultiBridge(\n ISocketRequest.FeesTakerMultiBridgeRequest calldata ftmbRequest\n ) external payable {\n if (ftmbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftmbRequest.feesTakerAddress).transfer(\n ftmbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftmbRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftmbRequest.feesTakerAddress,\n ftmbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftmbRequest.feesAmount,\n ftmbRequest.feesTakerAddress,\n ftmbRequest.feesToken\n );\n\n // multiple bridge-requests are to be generated and sequence and number of routeIds should match with the bridgeData array\n for (\n uint256 index = 0;\n index < ftmbRequest.bridgeRouteIds.length;\n ++index\n ) {\n //call bridge function (executeRoute for the bridgeData)\n _executeRoute(\n ftmbRequest.bridgeRouteIds[index],\n ftmbRequest.bridgeRequestDataItems[index]\n );\n }\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain followed by swap the amount on sourceChain followed by\n * bridging the swapped amount to destinationChain\n * @dev while generating implData for swap and bridgeRequests, ensure correct function selector is used\n * bridge action corresponds to the bridgeAfterSwap function of the bridgeImplementation\n * @param fsbRequest feesTakerSwapBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_SWAP_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeeAndSwapAndBridge(\n ISocketRequest.FeesTakerSwapBridgeRequest calldata fsbRequest\n ) external payable returns (bytes memory) {\n if (fsbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(fsbRequest.feesTakerAddress).transfer(\n fsbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(fsbRequest.feesToken).safeTransferFrom(\n msg.sender,\n fsbRequest.feesTakerAddress,\n fsbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n fsbRequest.feesAmount,\n fsbRequest.feesTakerAddress,\n fsbRequest.feesToken\n );\n\n // execute swap operation\n bytes memory swapResponseData = _executeRoute(\n fsbRequest.swapRouteId,\n fsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n // swapped amount is to be bridged to the recipient on destinationChain\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n fsbRequest.bridgeData\n );\n\n // execute bridge operation and return the byte-data from response of bridge operation\n return _executeRoute(fsbRequest.bridgeRouteId, bridgeImpldata);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain followed by refuel followed by\n * swap the amount on sourceChain followed by bridging the swapped amount to destinationChain\n * @dev while generating implData for refuel, swap and bridge Requests, ensure correct function selector is used\n * bridge action corresponds to the bridgeAfterSwap function of the bridgeImplementation\n * @param frsbRequest feesTakerRefuelSwapBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeeAndRefuelAndSwapAndBridge(\n ISocketRequest.FeesTakerRefuelSwapBridgeRequest calldata frsbRequest\n ) external payable returns (bytes memory) {\n if (frsbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(frsbRequest.feesTakerAddress).transfer(\n frsbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(frsbRequest.feesToken).safeTransferFrom(\n msg.sender,\n frsbRequest.feesTakerAddress,\n frsbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n frsbRequest.feesAmount,\n frsbRequest.feesTakerAddress,\n frsbRequest.feesToken\n );\n\n // refuel is also done via bridge execution via refuelRouteImplementation identified by refuelRouteId\n _executeRoute(frsbRequest.refuelRouteId, frsbRequest.refuelData);\n\n // execute swap operation\n bytes memory swapResponseData = _executeRoute(\n frsbRequest.swapRouteId,\n frsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n // swapped amount is to be bridged to the recipient on destinationChain\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n frsbRequest.bridgeData\n );\n\n // execute bridge operation and return the byte-data from response of bridge operation\n return _executeRoute(frsbRequest.bridgeRouteId, bridgeImpldata);\n }\n}\n" - }, - "src/errors/SocketErrors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nerror CelerRefundNotReady();\nerror OnlySocketDeployer();\nerror OnlySocketGatewayOwner();\nerror OnlySocketGateway();\nerror OnlyOwner();\nerror OnlyNominee();\nerror TransferIdExists();\nerror TransferIdDoesnotExist();\nerror Address0Provided();\nerror SwapFailed();\nerror UnsupportedInterfaceId();\nerror InvalidCelerRefund();\nerror CelerAlreadyRefunded();\nerror IncorrectBridgeRatios();\nerror ZeroAddressNotAllowed();\nerror ArrayLengthMismatch();\n" - }, - "src/bridges/hop/l1/HopImplL1.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"../interfaces/IHopL1Bridge.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {HOP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hop-L1 Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Hop-Bridge from L1 to Supported L2s\n * Called via SocketGateway if the routeId in the request maps to the routeId of HopImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HopImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HopIdentifier = HOP;\n\n /// @notice Function-selector for ERC20-token bridging on Hop-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HOP_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,address,uint256,uint256,uint256,uint256,(uint256,bytes32))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Hop-L1-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable HOP_L1_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,address,uint256,uint256,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable HOP_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,address,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HopDataNoToken {\n // The address receiving funds at the destination\n address receiverAddress;\n // address of the Hop-L1-Bridge to handle bridging the tokens\n address l1bridgeAddr;\n // relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n address relayer;\n // The chainId of the destination chain\n uint256 toChainId;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n uint256 relayerFee;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopData {\n /// @notice address of token being bridged\n address token;\n // The address receiving funds at the destination\n address receiverAddress;\n // address of the Hop-L1-Bridge to handle bridging the tokens\n address l1bridgeAddr;\n // relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n address relayer;\n // The chainId of the destination chain\n uint256 toChainId;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n uint256 relayerFee;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopERC20Data {\n uint256 deadline;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Hop-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HopData memory hopData = abi.decode(bridgeData, (HopData));\n\n if (hopData.token == NATIVE_TOKEN_ADDRESS) {\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2{value: amount}(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n } else {\n ERC20(hopData.token).safeApprove(hopData.l1bridgeAddr, amount);\n\n // perform bridging\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n }\n\n emit SocketBridge(\n amount,\n hopData.token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hopData encoded data for HopData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HopDataNoToken calldata hopData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2{value: bridgeAmount}(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n } else {\n ERC20(token).safeApprove(hopData.l1bridgeAddr, bridgeAmount);\n\n // perform bridging\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hop-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param token token being bridged\n * @param l1bridgeAddr address of the Hop-L1-Bridge to handle bridging the tokens\n * @param relayer The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n * @param toChainId The chainId of the destination chain\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n * @param hopData extra data needed to build the tx\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n address l1bridgeAddr,\n address relayer,\n uint256 toChainId,\n uint256 amount,\n uint256 amountOutMin,\n uint256 relayerFee,\n HopERC20Data calldata hopData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(l1bridgeAddr, amount);\n\n // perform bridging\n IHopL1Bridge(l1bridgeAddr).sendToL2(\n toChainId,\n receiverAddress,\n amount,\n amountOutMin,\n hopData.deadline,\n relayer,\n relayerFee\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hop-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param l1bridgeAddr address of the Hop-L1-Bridge to handle bridging the tokens\n * @param relayer The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n * @param toChainId The chainId of the destination chain\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n */\n function bridgeNativeTo(\n address receiverAddress,\n address l1bridgeAddr,\n address relayer,\n uint256 toChainId,\n uint256 amount,\n uint256 amountOutMin,\n uint256 relayerFee,\n uint256 deadline,\n bytes32 metadata\n ) external payable {\n IHopL1Bridge(l1bridgeAddr).sendToL2{value: amount}(\n toChainId,\n receiverAddress,\n amount,\n amountOutMin,\n deadline,\n relayer,\n relayerFee\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - }, - "src/static/RouteIdentifiers.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\nbytes32 constant ACROSS = keccak256(\"Across\");\n\nbytes32 constant ANYSWAP = keccak256(\"Anyswap\");\n\nbytes32 constant CBRIDGE = keccak256(\"CBridge\");\n\nbytes32 constant HOP = keccak256(\"Hop\");\n\nbytes32 constant HYPHEN = keccak256(\"Hyphen\");\n\nbytes32 constant NATIVE_OPTIMISM = keccak256(\"NativeOptimism\");\n\nbytes32 constant NATIVE_ARBITRUM = keccak256(\"NativeArbitrum\");\n\nbytes32 constant NATIVE_POLYGON = keccak256(\"NativePolygon\");\n\nbytes32 constant REFUEL = keccak256(\"Refuel\");\n\nbytes32 constant STARGATE = keccak256(\"Stargate\");\n\nbytes32 constant ONEINCH = keccak256(\"OneInch\");\n\nbytes32 constant ZEROX = keccak256(\"Zerox\");\n\nbytes32 constant RAINBOW = keccak256(\"Rainbow\");\n" - }, - "src/SocketGateway.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\npragma experimental ABIEncoderV2;\n\nimport \"./utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {LibUtil} from \"./libraries/LibUtil.sol\";\nimport \"./libraries/LibBytes.sol\";\nimport {ISocketRoute} from \"./interfaces/ISocketRoute.sol\";\nimport {ISocketRequest} from \"./interfaces/ISocketRequest.sol\";\nimport {ISocketGateway} from \"./interfaces/ISocketGateway.sol\";\nimport {IncorrectBridgeRatios, ZeroAddressNotAllowed, ArrayLengthMismatch} from \"./errors/SocketErrors.sol\";\n\n/// @title SocketGatewayContract\n/// @notice Socketgateway is a contract with entrypoint functions for all interactions with socket liquidity layer\n/// @author Socket Team\ncontract SocketGatewayTemplate is Ownable {\n using LibBytes for bytes;\n using LibBytes for bytes4;\n using SafeTransferLib for ERC20;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice storage variable to keep track of total number of routes registered in socketgateway\n uint32 public routesCount = 385;\n\n /// @notice storage variable to keep track of total number of controllers registered in socketgateway\n uint32 public controllerCount;\n\n address public immutable disabledRouteAddress;\n\n uint256 public constant CENT_PERCENT = 100e18;\n\n /// @notice storage mapping for route implementation addresses\n mapping(uint32 => address) public routes;\n\n /// storage mapping for controller implemenation addresses\n mapping(uint32 => address) public controllers;\n\n // Events ------------------------------------------------------------------------------------------------------->\n\n /// @notice Event emitted when a router is added to socketgateway\n event NewRouteAdded(uint32 indexed routeId, address indexed route);\n\n /// @notice Event emitted when a route is disabled\n event RouteDisabled(uint32 indexed routeId);\n\n /// @notice Event emitted when ownership transfer is requested by socket-gateway-owner\n event OwnershipTransferRequested(\n address indexed _from,\n address indexed _to\n );\n\n /// @notice Event emitted when a controller is added to socketgateway\n event ControllerAdded(\n uint32 indexed controllerId,\n address indexed controllerAddress\n );\n\n /// @notice Event emitted when a controller is disabled\n event ControllerDisabled(uint32 indexed controllerId);\n\n constructor(address _owner, address _disabledRoute) Ownable(_owner) {\n disabledRouteAddress = _disabledRoute;\n }\n\n // Able to receive ether\n // solhint-disable-next-line no-empty-blocks\n receive() external payable {}\n\n /*******************************************\n * EXTERNAL AND PUBLIC FUNCTIONS *\n *******************************************/\n\n /**\n * @notice executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in routeData to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeId route identifier\n * @param routeData functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoute(\n uint32 routeId,\n bytes calldata routeData\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = addressAt(routeId).delegatecall(\n routeData\n );\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice swaps a token on sourceChain and split it across multiple bridge-recipients\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being swapped\n * @dev ensure the swap-data and bridge-data is generated using the function-selector defined as a constant in the implementation address\n * @param swapMultiBridgeRequest request\n */\n function swapAndMultiBridge(\n ISocketRequest.SwapMultiBridgeRequest calldata swapMultiBridgeRequest\n ) external payable {\n uint256 requestLength = swapMultiBridgeRequest.bridgeRouteIds.length;\n\n if (\n requestLength != swapMultiBridgeRequest.bridgeImplDataItems.length\n ) {\n revert ArrayLengthMismatch();\n }\n uint256 ratioAggregate;\n for (uint256 index = 0; index < requestLength; ) {\n ratioAggregate += swapMultiBridgeRequest.bridgeRatios[index];\n }\n\n if (ratioAggregate != CENT_PERCENT) {\n revert IncorrectBridgeRatios();\n }\n\n (bool swapSuccess, bytes memory swapResult) = addressAt(\n swapMultiBridgeRequest.swapRouteId\n ).delegatecall(swapMultiBridgeRequest.swapImplData);\n\n if (!swapSuccess) {\n assembly {\n revert(add(swapResult, 32), mload(swapResult))\n }\n }\n\n uint256 amountReceivedFromSwap = abi.decode(swapResult, (uint256));\n\n uint256 bridgedAmount;\n\n for (uint256 index = 0; index < requestLength; ) {\n uint256 bridgingAmount;\n\n // if it is the last bridge request, bridge the remaining amount\n if (index == requestLength - 1) {\n bridgingAmount = amountReceivedFromSwap - bridgedAmount;\n } else {\n // bridging amount is the multiplication of bridgeRatio and amountReceivedFromSwap\n bridgingAmount =\n (amountReceivedFromSwap *\n swapMultiBridgeRequest.bridgeRatios[index]) /\n (CENT_PERCENT);\n }\n\n // update the bridged amount, this would be used for computation for last bridgeRequest\n bridgedAmount += bridgingAmount;\n\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n bridgingAmount,\n swapMultiBridgeRequest.bridgeImplDataItems[index]\n );\n\n (bool bridgeSuccess, bytes memory bridgeResult) = addressAt(\n swapMultiBridgeRequest.bridgeRouteIds[index]\n ).delegatecall(bridgeImpldata);\n\n if (!bridgeSuccess) {\n assembly {\n revert(add(bridgeResult, 32), mload(bridgeResult))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice sequentially executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each dataItem to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeIds a list of route identifiers\n * @param dataItems a list of functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoutes(\n uint32[] calldata routeIds,\n bytes[] calldata dataItems\n ) external payable {\n uint256 routeIdslength = routeIds.length;\n if (routeIdslength != dataItems.length) revert ArrayLengthMismatch();\n for (uint256 index = 0; index < routeIdslength; ) {\n (bool success, bytes memory result) = addressAt(routeIds[index])\n .delegatecall(dataItems[index]);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice execute a controller function identified using the controllerId in the request\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param socketControllerRequest socketControllerRequest with controllerId to identify the\n * controllerAddress and byteData constructed using functionSelector\n * of the function being invoked\n * @return bytes data received from the call delegated to controller\n */\n function executeController(\n ISocketGateway.SocketControllerRequest calldata socketControllerRequest\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = controllers[\n socketControllerRequest.controllerId\n ].delegatecall(socketControllerRequest.data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice sequentially executes all controller requests\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each controller-request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param controllerRequests a list of socketControllerRequest\n * Each controllerRequest contains controllerId to identify the controllerAddress and\n * byteData constructed using functionSelector of the function being invoked\n */\n function executeControllers(\n ISocketGateway.SocketControllerRequest[] calldata controllerRequests\n ) external payable {\n for (uint32 index = 0; index < controllerRequests.length; ) {\n (bool success, bytes memory result) = controllers[\n controllerRequests[index].controllerId\n ].delegatecall(controllerRequests[index].data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**************************************\n * ADMIN FUNCTIONS *\n **************************************/\n\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(\n address routeAddress\n ) external onlyOwner returns (uint32) {\n uint32 routeId = routesCount;\n routes[routeId] = routeAddress;\n\n routesCount += 1;\n\n emit NewRouteAdded(routeId, routeAddress);\n\n return routeId;\n }\n\n /**\n * @notice Give Infinite or 0 approval to bridgeRoute for the tokenAddress\n This is a restricted function to be called by only socketGatewayOwner\n */\n\n function setApprovalForRouters(\n address[] memory routeAddresses,\n address[] memory tokenAddresses,\n bool isMax\n ) external onlyOwner {\n for (uint32 index = 0; index < routeAddresses.length; ) {\n ERC20(tokenAddresses[index]).approve(\n routeAddresses[index],\n isMax ? type(uint256).max : 0\n );\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address controllerAddress\n ) external onlyOwner returns (uint32) {\n uint32 controllerId = controllerCount;\n\n controllers[controllerId] = controllerAddress;\n\n controllerCount += 1;\n\n emit ControllerAdded(controllerId, controllerAddress);\n\n return controllerId;\n }\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 controllerId) public onlyOwner {\n controllers[controllerId] = disabledRouteAddress;\n emit ControllerDisabled(controllerId);\n }\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external onlyOwner {\n routes[routeId] = disabledRouteAddress;\n emit RouteDisabled(routeId);\n }\n\n /*******************************************\n * RESTRICTED RESCUE FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n\n /*******************************************\n * VIEW FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) public view returns (address) {\n return addressAt(routeId);\n }\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 controllerId) public view returns (address) {\n return controllers[controllerId];\n }\n\n function addressAt(uint32 routeId) public view returns (address) {\n if (routeId < 385) {\n if (routeId < 257) {\n if (routeId < 129) {\n if (routeId < 65) {\n if (routeId < 33) {\n if (routeId < 17) {\n if (routeId < 9) {\n if (routeId < 5) {\n if (routeId < 3) {\n if (routeId == 1) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 3) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 7) {\n if (routeId == 5) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 7) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 13) {\n if (routeId < 11) {\n if (routeId == 9) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 11) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 15) {\n if (routeId == 13) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 15) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 25) {\n if (routeId < 21) {\n if (routeId < 19) {\n if (routeId == 17) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 19) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 23) {\n if (routeId == 21) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 23) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 29) {\n if (routeId < 27) {\n if (routeId == 25) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 27) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 31) {\n if (routeId == 29) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 31) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 49) {\n if (routeId < 41) {\n if (routeId < 37) {\n if (routeId < 35) {\n if (routeId == 33) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 35) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 39) {\n if (routeId == 37) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 39) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 45) {\n if (routeId < 43) {\n if (routeId == 41) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 43) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 47) {\n if (routeId == 45) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 47) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 57) {\n if (routeId < 53) {\n if (routeId < 51) {\n if (routeId == 49) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 51) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 55) {\n if (routeId == 53) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 55) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 61) {\n if (routeId < 59) {\n if (routeId == 57) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 59) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 63) {\n if (routeId == 61) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 63) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 97) {\n if (routeId < 81) {\n if (routeId < 73) {\n if (routeId < 69) {\n if (routeId < 67) {\n if (routeId == 65) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 67) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 71) {\n if (routeId == 69) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 71) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 77) {\n if (routeId < 75) {\n if (routeId == 73) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 75) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 79) {\n if (routeId == 77) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 79) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 89) {\n if (routeId < 85) {\n if (routeId < 83) {\n if (routeId == 81) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 83) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 87) {\n if (routeId == 85) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 87) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 93) {\n if (routeId < 91) {\n if (routeId == 89) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 91) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 95) {\n if (routeId == 93) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 95) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 113) {\n if (routeId < 105) {\n if (routeId < 101) {\n if (routeId < 99) {\n if (routeId == 97) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 99) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 103) {\n if (routeId == 101) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 103) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 109) {\n if (routeId < 107) {\n if (routeId == 105) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 107) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 111) {\n if (routeId == 109) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 111) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 121) {\n if (routeId < 117) {\n if (routeId < 115) {\n if (routeId == 113) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 115) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 119) {\n if (routeId == 117) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 119) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 125) {\n if (routeId < 123) {\n if (routeId == 121) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 123) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 127) {\n if (routeId == 125) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 127) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 193) {\n if (routeId < 161) {\n if (routeId < 145) {\n if (routeId < 137) {\n if (routeId < 133) {\n if (routeId < 131) {\n if (routeId == 129) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 131) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 135) {\n if (routeId == 133) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 135) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 141) {\n if (routeId < 139) {\n if (routeId == 137) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 139) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 143) {\n if (routeId == 141) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 143) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 153) {\n if (routeId < 149) {\n if (routeId < 147) {\n if (routeId == 145) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 147) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 151) {\n if (routeId == 149) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 151) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 157) {\n if (routeId < 155) {\n if (routeId == 153) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 155) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 159) {\n if (routeId == 157) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 159) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 177) {\n if (routeId < 169) {\n if (routeId < 165) {\n if (routeId < 163) {\n if (routeId == 161) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 163) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 167) {\n if (routeId == 165) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 167) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 173) {\n if (routeId < 171) {\n if (routeId == 169) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 171) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 175) {\n if (routeId == 173) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 175) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 185) {\n if (routeId < 181) {\n if (routeId < 179) {\n if (routeId == 177) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 179) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 183) {\n if (routeId == 181) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 183) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 189) {\n if (routeId < 187) {\n if (routeId == 185) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 187) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 191) {\n if (routeId == 189) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 191) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 225) {\n if (routeId < 209) {\n if (routeId < 201) {\n if (routeId < 197) {\n if (routeId < 195) {\n if (routeId == 193) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 195) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 199) {\n if (routeId == 197) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 199) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 205) {\n if (routeId < 203) {\n if (routeId == 201) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 203) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 207) {\n if (routeId == 205) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 207) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 217) {\n if (routeId < 213) {\n if (routeId < 211) {\n if (routeId == 209) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 211) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 215) {\n if (routeId == 213) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 215) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 221) {\n if (routeId < 219) {\n if (routeId == 217) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 219) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 223) {\n if (routeId == 221) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 223) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 241) {\n if (routeId < 233) {\n if (routeId < 229) {\n if (routeId < 227) {\n if (routeId == 225) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 227) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 231) {\n if (routeId == 229) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 231) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 237) {\n if (routeId < 235) {\n if (routeId == 233) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 235) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 239) {\n if (routeId == 237) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 239) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 249) {\n if (routeId < 245) {\n if (routeId < 243) {\n if (routeId == 241) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 243) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 247) {\n if (routeId == 245) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 247) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 253) {\n if (routeId < 251) {\n if (routeId == 249) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 251) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 255) {\n if (routeId == 253) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 255) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 321) {\n if (routeId < 289) {\n if (routeId < 273) {\n if (routeId < 265) {\n if (routeId < 261) {\n if (routeId < 259) {\n if (routeId == 257) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 259) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 263) {\n if (routeId == 261) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 263) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 269) {\n if (routeId < 267) {\n if (routeId == 265) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 267) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 271) {\n if (routeId == 269) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 271) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 281) {\n if (routeId < 277) {\n if (routeId < 275) {\n if (routeId == 273) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 275) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 279) {\n if (routeId == 277) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 279) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 285) {\n if (routeId < 283) {\n if (routeId == 281) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 283) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 287) {\n if (routeId == 285) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 287) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 305) {\n if (routeId < 297) {\n if (routeId < 293) {\n if (routeId < 291) {\n if (routeId == 289) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 291) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 295) {\n if (routeId == 293) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 295) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 301) {\n if (routeId < 299) {\n if (routeId == 297) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 299) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 303) {\n if (routeId == 301) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 303) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 313) {\n if (routeId < 309) {\n if (routeId < 307) {\n if (routeId == 305) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 307) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 311) {\n if (routeId == 309) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 311) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 317) {\n if (routeId < 315) {\n if (routeId == 313) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 315) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 319) {\n if (routeId == 317) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 319) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 353) {\n if (routeId < 337) {\n if (routeId < 329) {\n if (routeId < 325) {\n if (routeId < 323) {\n if (routeId == 321) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 323) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 327) {\n if (routeId == 325) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 327) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 333) {\n if (routeId < 331) {\n if (routeId == 329) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 331) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 335) {\n if (routeId == 333) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 335) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 345) {\n if (routeId < 341) {\n if (routeId < 339) {\n if (routeId == 337) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 339) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 343) {\n if (routeId == 341) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 343) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 349) {\n if (routeId < 347) {\n if (routeId == 345) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 347) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 351) {\n if (routeId == 349) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 351) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 369) {\n if (routeId < 361) {\n if (routeId < 357) {\n if (routeId < 355) {\n if (routeId == 353) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 355) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 359) {\n if (routeId == 357) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 359) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 365) {\n if (routeId < 363) {\n if (routeId == 361) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 363) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 367) {\n if (routeId == 365) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 367) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 377) {\n if (routeId < 373) {\n if (routeId < 371) {\n if (routeId == 369) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 371) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 375) {\n if (routeId == 373) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 375) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 381) {\n if (routeId < 379) {\n if (routeId == 377) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 379) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 383) {\n if (routeId == 381) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 383) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n if (routes[routeId] == address(0)) revert ZeroAddressNotAllowed();\n return routes[routeId];\n }\n\n /// @notice fallback function to handle swap, bridge execution\n /// @dev ensure routeId is converted to bytes4 and sent as msg.sig in the transaction\n fallback() external payable {\n address routeAddress = addressAt(uint32(msg.sig));\n\n bytes memory result;\n\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 4, sub(calldatasize(), 4))\n // execute function call using the facet\n result := delegatecall(\n gas(),\n routeAddress,\n 0,\n sub(calldatasize(), 4),\n 0,\n 0\n )\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n" - }, - "src/swap/rainbow/Rainbow.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {Address0Provided, SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {RAINBOW} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Rainbow-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via Rainbow-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of RainbowImplementation\n * @author Socket dot tech.\n */\ncontract RainbowSwapImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable RainbowIdentifier = RAINBOW;\n\n /// @notice unique name to identify the router, used to emit event upon successful bridging\n bytes32 public immutable NAME = keccak256(\"Rainbow-Router\");\n\n /// @notice address of rainbow-swap-aggregator to swap the tokens on Chain\n address payable public immutable rainbowSwapAggregator;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @notice rainbow swap aggregator contract is payable to allow ethereum swaps\n /// @dev ensure _rainbowSwapAggregator are set properly for the chainId in which the contract is being deployed\n constructor(\n address _rainbowSwapAggregator,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n rainbowSwapAggregator = payable(_rainbowSwapAggregator);\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * @notice This method is payable because the caller is doing token transfer and swap operation\n * @param fromToken address of token being Swapped\n * @param toToken address of token that recipient will receive after swap\n * @param amount amount of fromToken being swapped\n * @param receiverAddress recipient-address\n * @param swapExtraData additional Data to perform Swap via Rainbow-Aggregator\n * @return swapped amount (in toToken Address)\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 toTokenERC20 = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(rainbowSwapAggregator, amount);\n\n // solhint-disable-next-line\n (bool success, ) = rainbowSwapAggregator.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(rainbowSwapAggregator, 0);\n } else {\n (bool success, ) = rainbowSwapAggregator.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n if (toToken == NATIVE_TOKEN_ADDRESS) {\n payable(receiverAddress).transfer(returnAmount);\n } else {\n toTokenERC20.transfer(receiverAddress, returnAmount);\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n RainbowIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 toTokenERC20 = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(rainbowSwapAggregator, amount);\n\n // solhint-disable-next-line\n (bool success, ) = rainbowSwapAggregator.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(rainbowSwapAggregator, 0);\n } else {\n (bool success, ) = rainbowSwapAggregator.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n RainbowIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n" - }, - "src/interfaces/ISocketBridgeBase.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface ISocketBridgeBase {\n function killme() external;\n}\n" - }, - "src/interfaces/ISocketRequest.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketRoute\n * @notice Interface with Request DataStructures to invoke controller functions.\n * @author Socket dot tech.\n */\ninterface ISocketRequest {\n struct SwapMultiBridgeRequest {\n uint32 swapRouteId;\n bytes swapImplData;\n uint32[] bridgeRouteIds;\n bytes[] bridgeImplDataItems;\n uint256[] bridgeRatios;\n bytes[] eventDataItems;\n }\n\n // Datastructure for Refuel-Swap-Bridge function\n struct RefuelSwapBridgeRequest {\n uint32 refuelRouteId;\n bytes refuelData;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n\n // Datastructure for DeductFees-Swap function\n struct FeesTakerSwapRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 routeId;\n bytes swapRequestData;\n }\n\n // Datastructure for DeductFees-Bridge function\n struct FeesTakerBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 routeId;\n bytes bridgeRequestData;\n }\n\n // Datastructure for DeductFees-MultiBridge function\n struct FeesTakerMultiBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32[] bridgeRouteIds;\n bytes[] bridgeRequestDataItems;\n }\n\n // Datastructure for DeductFees-Swap-Bridge function\n struct FeesTakerSwapBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n\n // Datastructure for DeductFees-Refuel-Swap-Bridge function\n struct FeesTakerRefuelSwapBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 refuelRouteId;\n bytes refuelData;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n}\n" - }, - "src/utils/Ownable.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.4;\n\nimport {OnlyOwner, OnlyNominee} from \"../errors/SocketErrors.sol\";\n\nabstract contract Ownable {\n address private _owner;\n address private _nominee;\n\n event OwnerNominated(address indexed nominee);\n event OwnerClaimed(address indexed claimer);\n\n constructor(address owner_) {\n _claimOwner(owner_);\n }\n\n modifier onlyOwner() {\n if (msg.sender != _owner) {\n revert OnlyOwner();\n }\n _;\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n function nominee() public view returns (address) {\n return _nominee;\n }\n\n function nominateOwner(address nominee_) external {\n if (msg.sender != _owner) {\n revert OnlyOwner();\n }\n _nominee = nominee_;\n emit OwnerNominated(_nominee);\n }\n\n function claimOwner() external {\n if (msg.sender != _nominee) {\n revert OnlyNominee();\n }\n _claimOwner(msg.sender);\n }\n\n function _claimOwner(address claimer_) internal {\n _owner = claimer_;\n _nominee = address(0);\n emit OwnerClaimed(claimer_);\n }\n}\n" - }, - "lib/solmate/src/tokens/ERC20.sol": { - "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n" - }, - "src/controllers/RefuelSwapAndBridgeController.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\nimport {BaseController} from \"./BaseController.sol\";\n\n/**\n * @title RefuelSwapAndBridge Controller Implementation\n * @notice Controller with composed actions for Refuel,Swap and Bridge to be executed Sequentially and this is atomic\n * @author Socket dot tech.\n */\ncontract RefuelSwapAndBridgeController is BaseController {\n /// @notice Function-selector to invoke refuel-swap-bridge function\n /// @dev This function selector is to be used while buidling transaction-data\n bytes4 public immutable REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"refuelAndSwapAndBridge((uint32,bytes,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BaseController\n constructor(\n address _socketGatewayAddress\n ) BaseController(_socketGatewayAddress) {}\n\n /**\n * @notice function to handle refuel followed by Swap and Bridge actions\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param rsbRequest Request with data to execute refuel followed by swap and bridge\n * @return output data from bridging operation\n */\n function refuelAndSwapAndBridge(\n ISocketRequest.RefuelSwapBridgeRequest calldata rsbRequest\n ) public payable returns (bytes memory) {\n _executeRoute(rsbRequest.refuelRouteId, rsbRequest.refuelData);\n\n // refuel is also a bridging activity via refuel-route-implementation\n bytes memory swapResponseData = _executeRoute(\n rsbRequest.swapRouteId,\n rsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n //sequence of arguments for implData: amount, token, data\n // Bridging the swapAmount received in the preceeding step\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n rsbRequest.bridgeData\n );\n\n return _executeRoute(rsbRequest.bridgeRouteId, bridgeImpldata);\n }\n}\n" - }, - "src/interfaces/ISocketGateway.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketGateway\n * @notice Interface for SocketGateway functions.\n * @dev functions can be added here for invocation from external contracts or off-chain\n * @author Socket dot tech.\n */\ninterface ISocketGateway {\n /**\n * @notice Request-struct for controllerRequests\n * @dev ensure the value for data is generated using the function-selectors defined in the controllerImplementation contracts\n */\n struct SocketControllerRequest {\n // controllerId is the id mapped to the controllerAddress\n uint32 controllerId;\n // transactionImplData generated off-chain or by caller using function-selector of the controllerContract\n bytes data;\n }\n\n // @notice view to get owner-address\n function owner() external view returns (address);\n}\n" - }, - "src/libraries/Pb.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.4;\n\n// runtime proto sol library\nlibrary Pb {\n enum WireType {\n Varint,\n Fixed64,\n LengthDelim,\n StartGroup,\n EndGroup,\n Fixed32\n }\n\n struct Buffer {\n uint256 idx; // the start index of next read. when idx=b.length, we're done\n bytes b; // hold serialized proto msg, readonly\n }\n\n // create a new in-memory Buffer object from raw msg bytes\n function fromBytes(\n bytes memory raw\n ) internal pure returns (Buffer memory buf) {\n buf.b = raw;\n buf.idx = 0;\n }\n\n // whether there are unread bytes\n function hasMore(Buffer memory buf) internal pure returns (bool) {\n return buf.idx < buf.b.length;\n }\n\n // decode current field number and wiretype\n function decKey(\n Buffer memory buf\n ) internal pure returns (uint256 tag, WireType wiretype) {\n uint256 v = decVarint(buf);\n tag = v / 8;\n wiretype = WireType(v & 7);\n }\n\n // read varint from current buf idx, move buf.idx to next read, return the int value\n function decVarint(Buffer memory buf) internal pure returns (uint256 v) {\n bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)\n bytes memory bb = buf.b; // get buf.b mem addr to use in assembly\n v = buf.idx; // use v to save one additional uint variable\n assembly {\n tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp\n }\n uint256 b; // store current byte content\n v = 0; // reset to 0 for return value\n for (uint256 i = 0; i < 10; i++) {\n assembly {\n b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra\n }\n v |= (b & 0x7F) << (i * 7);\n if (b & 0x80 == 0) {\n buf.idx += i + 1;\n return v;\n }\n }\n revert(); // i=10, invalid varint stream\n }\n\n // read length delimited field and return bytes\n function decBytes(\n Buffer memory buf\n ) internal pure returns (bytes memory b) {\n uint256 len = decVarint(buf);\n uint256 end = buf.idx + len;\n require(end <= buf.b.length); // avoid overflow\n b = new bytes(len);\n bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly\n uint256 bStart;\n uint256 bufBStart = buf.idx;\n assembly {\n bStart := add(b, 32)\n bufBStart := add(add(bufB, 32), bufBStart)\n }\n for (uint256 i = 0; i < len; i += 32) {\n assembly {\n mstore(add(bStart, i), mload(add(bufBStart, i)))\n }\n }\n buf.idx = end;\n }\n\n // move idx pass current value field, to beginning of next tag or msg end\n function skipValue(Buffer memory buf, WireType wire) internal pure {\n if (wire == WireType.Varint) {\n decVarint(buf);\n } else if (wire == WireType.LengthDelim) {\n uint256 len = decVarint(buf);\n buf.idx += len; // skip len bytes value data\n require(buf.idx <= buf.b.length); // avoid overflow\n } else {\n revert();\n } // unsupported wiretype\n }\n\n function _uint256(bytes memory b) internal pure returns (uint256 v) {\n require(b.length <= 32); // b's length must be smaller than or equal to 32\n assembly {\n v := mload(add(b, 32))\n } // load all 32bytes to v\n v = v >> (8 * (32 - b.length)); // only first b.length is valid\n }\n\n function _address(bytes memory b) internal pure returns (address v) {\n v = _addressPayable(b);\n }\n\n function _addressPayable(\n bytes memory b\n ) internal pure returns (address payable v) {\n require(b.length == 20);\n //load 32bytes then shift right 12 bytes\n assembly {\n v := div(mload(add(b, 32)), 0x1000000000000000000000000)\n }\n }\n\n function _bytes32(bytes memory b) internal pure returns (bytes32 v) {\n require(b.length == 32);\n assembly {\n v := mload(add(b, 32))\n }\n }\n}\n" - }, - "src/bridges/BridgeImplBase.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\nimport {OnlySocketGatewayOwner, OnlySocketDeployer} from \"../errors/SocketErrors.sol\";\n\n/**\n * @title Abstract Implementation Contract.\n * @notice All Bridge Implementation will follow this interface.\n */\nabstract contract BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketDeployFactory;\n\n /// @notice immutable variable with instance of SocketRoute to access route functions\n ISocketRoute public immutable socketRoute;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /****************************************\n * EVENTS *\n ****************************************/\n\n event SocketBridge(\n uint256 amount,\n address token,\n uint256 toChainId,\n bytes32 bridgeName,\n address sender,\n address receiver,\n bytes32 metadata\n );\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n * @param _socketDeployFactory Socket Deploy Factory address, an immutable variable to set.\n */\n constructor(address _socketGateway, address _socketDeployFactory) {\n socketGateway = _socketGateway;\n socketDeployFactory = _socketDeployFactory;\n socketRoute = ISocketRoute(_socketGateway);\n }\n\n /****************************************\n * MODIFIERS *\n ****************************************/\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketDeployFactory() {\n if (msg.sender != socketDeployFactory) {\n revert OnlySocketDeployer();\n }\n _;\n }\n\n /****************************************\n * RESTRICTED FUNCTIONS *\n ****************************************/\n\n /**\n * @notice function to rescue the ERC20 tokens in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n function killme() external isSocketDeployFactory {\n selfdestruct(payable(msg.sender));\n }\n\n /******************************\n * VIRTUAL FUNCTIONS *\n *****************************/\n\n /**\n * @notice function to bridge which is succeeding the swap function\n * @notice this function is to be used only when bridging as a succeeding step\n * @notice All bridge implementation contracts must implement this function\n * @notice bridge-implementations will have a bridge specific struct with properties used in bridging\n * @param bridgeData encoded value of properties in the bridgeData Struct\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable virtual;\n}\n" - }, - "src/bridges/cbridge/CelerImpl.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../../libraries/Pb.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"./interfaces/cbridge.sol\";\nimport \"./interfaces/ICelerStorageWrapper.sol\";\nimport {TransferIdExists, InvalidCelerRefund, CelerAlreadyRefunded, CelerRefundNotReady} from \"../../errors/SocketErrors.sol\";\nimport {BridgeImplBase} from \"../BridgeImplBase.sol\";\nimport {CBRIDGE} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Celer-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Celer-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of CelerImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract CelerImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable CBridgeIdentifier = CBRIDGE;\n\n /// @notice Utility to perform operation on Buffer\n using Pb for Pb.Buffer;\n\n /// @notice Function-selector for ERC20-token bridging on Celer-Route\n /// @dev This function selector is to be used while building transaction-data to bridge ERC20 tokens\n bytes4 public immutable CELER_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,uint256,bytes32,uint64,uint64,uint32)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Celer-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable CELER_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,uint256,bytes32,uint64,uint64,uint32)\"\n )\n );\n\n bytes4 public immutable CELER_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,uint64,uint32,uint64,bytes32))\"\n )\n );\n\n /// @notice router Contract instance used to deposit ERC20 and Native on to Celer-Bridge\n /// @dev contract instance is to be initialized in the constructor using the routerAddress passed as constructor argument\n ICBridge public immutable router;\n\n /// @notice celerStorageWrapper Contract instance used to store the transferId generated during ERC20 and Native bridge on to Celer-Bridge\n /// @dev contract instance is to be initialized in the constructor using the celerStorageWrapperAddress passed as constructor argument\n ICelerStorageWrapper public immutable celerStorageWrapper;\n\n /// @notice WETH token address\n address public immutable weth;\n\n /// @notice chainId used during generation of transferId generated while bridging ERC20 and Native on to Celer-Bridge\n /// @dev this is to be initialised in the constructor\n uint64 public immutable chainId;\n\n struct WithdrawMsg {\n uint64 chainid; // tag: 1\n uint64 seqnum; // tag: 2\n address receiver; // tag: 3\n address token; // tag: 4\n uint256 amount; // tag: 5\n bytes32 refid; // tag: 6\n }\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure routerAddress, weth-address, celerStorageWrapperAddress are set properly for the chainId in which the contract is being deployed\n constructor(\n address _routerAddress,\n address _weth,\n address _celerStorageWrapperAddress,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = ICBridge(_routerAddress);\n celerStorageWrapper = ICelerStorageWrapper(_celerStorageWrapperAddress);\n weth = _weth;\n chainId = uint64(block.chainid);\n }\n\n // Function to receive Ether. msg.data must be empty\n receive() external payable {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct CelerBridgeDataNoToken {\n address receiverAddress;\n uint64 toChainId;\n uint32 maxSlippage;\n uint64 nonce;\n bytes32 metadata;\n }\n\n struct CelerBridgeData {\n address token;\n address receiverAddress;\n uint64 toChainId;\n uint32 maxSlippage;\n uint64 nonce;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for CelerBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n CelerBridgeData memory celerBridgeData = abi.decode(\n bridgeData,\n (CelerBridgeData)\n );\n\n if (celerBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n weth,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: amount}(\n celerBridgeData.receiverAddress,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n } else {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n celerBridgeData.token,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n router.send(\n celerBridgeData.receiverAddress,\n celerBridgeData.token,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n }\n\n emit SocketBridge(\n amount,\n celerBridgeData.token,\n celerBridgeData.toChainId,\n CBridgeIdentifier,\n msg.sender,\n celerBridgeData.receiverAddress,\n celerBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param celerBridgeData encoded data for CelerBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n CelerBridgeDataNoToken calldata celerBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n weth,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: bridgeAmount}(\n celerBridgeData.receiverAddress,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n } else {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n token,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n router.send(\n celerBridgeData.receiverAddress,\n token,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n celerBridgeData.toChainId,\n CBridgeIdentifier,\n msg.sender,\n celerBridgeData.receiverAddress,\n celerBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Celer-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of recipient\n * @param token address of token being bridged\n * @param amount amount of token for bridging\n * @param toChainId destination ChainId\n * @param nonce nonce of the sender-account address\n * @param maxSlippage maximum Slippage for the bridging\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n uint256 amount,\n bytes32 metadata,\n uint64 toChainId,\n uint64 nonce,\n uint32 maxSlippage\n ) external payable {\n /// @notice transferId is generated using the request-params and nonce of the account\n /// @notice transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n receiverAddress,\n token,\n amount,\n toChainId,\n nonce,\n chainId\n )\n );\n\n /// @notice stored in the CelerStorageWrapper contract\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n router.send(\n receiverAddress,\n token,\n amount,\n toChainId,\n nonce,\n maxSlippage\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n CBridgeIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Celer-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of recipient\n * @param amount amount of token for bridging\n * @param toChainId destination ChainId\n * @param nonce nonce of the sender-account address\n * @param maxSlippage maximum Slippage for the bridging\n */\n function bridgeNativeTo(\n address receiverAddress,\n uint256 amount,\n bytes32 metadata,\n uint64 toChainId,\n uint64 nonce,\n uint32 maxSlippage\n ) external payable {\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n receiverAddress,\n weth,\n amount,\n toChainId,\n nonce,\n chainId\n )\n );\n\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: amount}(\n receiverAddress,\n amount,\n toChainId,\n nonce,\n maxSlippage\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n CBridgeIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle refund from CelerBridge-Router\n * @param _request request data generated offchain using the celer-SDK\n * @param _sigs generated offchain using the celer-SDK\n * @param _signers generated offchain using the celer-SDK\n * @param _powers generated offchain using the celer-SDK\n */\n function refundCelerUser(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable {\n WithdrawMsg memory request = decWithdrawMsg(_request);\n bytes32 transferId = keccak256(\n abi.encodePacked(\n request.chainid,\n request.seqnum,\n request.receiver,\n request.token,\n request.amount\n )\n );\n uint256 _initialNativeBalance = address(this).balance;\n uint256 _initialTokenBalance = ERC20(request.token).balanceOf(\n address(this)\n );\n if (!router.withdraws(transferId)) {\n router.withdraw(_request, _sigs, _signers, _powers);\n }\n\n if (request.receiver != socketGateway) {\n revert InvalidCelerRefund();\n }\n\n address _receiver = celerStorageWrapper.getAddressFromTransferId(\n request.refid\n );\n celerStorageWrapper.deleteTransferId(request.refid);\n\n if (_receiver == address(0)) {\n revert CelerAlreadyRefunded();\n }\n\n uint256 _nativeBalanceAfter = address(this).balance;\n uint256 _tokenBalanceAfter = ERC20(request.token).balanceOf(\n address(this)\n );\n if (_nativeBalanceAfter > _initialNativeBalance) {\n if ((_nativeBalanceAfter - _initialNativeBalance) != request.amount)\n revert CelerRefundNotReady();\n payable(_receiver).transfer(request.amount);\n return;\n }\n\n if (_tokenBalanceAfter > _initialTokenBalance) {\n if ((_tokenBalanceAfter - _initialTokenBalance) != request.amount)\n revert CelerRefundNotReady();\n ERC20(request.token).safeTransfer(_receiver, request.amount);\n return;\n }\n\n revert CelerRefundNotReady();\n }\n\n function decWithdrawMsg(\n bytes memory raw\n ) internal pure returns (WithdrawMsg memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.chainid = uint64(buf.decVarint());\n } else if (tag == 2) {\n m.seqnum = uint64(buf.decVarint());\n } else if (tag == 3) {\n m.receiver = Pb._address(buf.decBytes());\n } else if (tag == 4) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 5) {\n m.amount = Pb._uint256(buf.decBytes());\n } else if (tag == 6) {\n m.refid = Pb._bytes32(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder WithdrawMsg\n}\n" - }, - "src/libraries/LibBytes.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n// Functions taken out from https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol\nlibrary LibBytes {\n // solhint-disable no-inline-assembly\n\n // LibBytes specific errors\n error SliceOverflow();\n error SliceOutOfBounds();\n error AddressOutOfBounds();\n error UintOutOfBounds();\n\n // -------------------------\n\n function concat(\n bytes memory _preBytes,\n bytes memory _postBytes\n ) internal pure returns (bytes memory) {\n bytes memory tempBytes;\n\n assembly {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // Store the length of the first bytes array at the beginning of\n // the memory for tempBytes.\n let length := mload(_preBytes)\n mstore(tempBytes, length)\n\n // Maintain a memory counter for the current write location in the\n // temp bytes array by adding the 32 bytes for the array length to\n // the starting location.\n let mc := add(tempBytes, 0x20)\n // Stop copying when the memory counter reaches the length of the\n // first bytes array.\n let end := add(mc, length)\n\n for {\n // Initialize a copy counter to the start of the _preBytes data,\n // 32 bytes into its memory.\n let cc := add(_preBytes, 0x20)\n } lt(mc, end) {\n // Increase both counters by 32 bytes each iteration.\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // Write the _preBytes data into the tempBytes memory 32 bytes\n // at a time.\n mstore(mc, mload(cc))\n }\n\n // Add the length of _postBytes to the current length of tempBytes\n // and store it as the new length in the first 32 bytes of the\n // tempBytes memory.\n length := mload(_postBytes)\n mstore(tempBytes, add(length, mload(tempBytes)))\n\n // Move the memory counter back from a multiple of 0x20 to the\n // actual end of the _preBytes data.\n mc := end\n // Stop copying when the memory counter reaches the new combined\n // length of the arrays.\n end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n // Update the free-memory pointer by padding our last write location\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\n // next 32 byte block, then round down to the nearest multiple of\n // 32. If the sum of the length of the two arrays is zero then add\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\n mstore(\n 0x40,\n and(\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\n not(31) // Round down to the nearest 32 bytes.\n )\n )\n }\n\n return tempBytes;\n }\n\n function slice(\n bytes memory _bytes,\n uint256 _start,\n uint256 _length\n ) internal pure returns (bytes memory) {\n if (_length + 31 < _length) {\n revert SliceOverflow();\n }\n if (_bytes.length < _start + _length) {\n revert SliceOutOfBounds();\n }\n\n bytes memory tempBytes;\n\n assembly {\n switch iszero(_length)\n case 0 {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // The first word of the slice result is potentially a partial\n // word read from the original array. To read it, we calculate\n // the length of that partial word and start copying that many\n // bytes into the array. The first word we copy will start with\n // data we don't care about, but the last `lengthmod` bytes will\n // land at the beginning of the contents of the new array. When\n // we're done copying, we overwrite the full first word with\n // the actual length of the slice.\n let lengthmod := and(_length, 31)\n\n // The multiplication in the next line is necessary\n // because when slicing multiples of 32 bytes (lengthmod == 0)\n // the following copy loop was copying the origin's length\n // and then ending prematurely not copying everything it should.\n let mc := add(\n add(tempBytes, lengthmod),\n mul(0x20, iszero(lengthmod))\n )\n let end := add(mc, _length)\n\n for {\n // The multiplication in the next line has the same exact purpose\n // as the one above.\n let cc := add(\n add(\n add(_bytes, lengthmod),\n mul(0x20, iszero(lengthmod))\n ),\n _start\n )\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n mstore(tempBytes, _length)\n\n //update free-memory pointer\n //allocating the array padded to 32 bytes like the compiler does now\n mstore(0x40, and(add(mc, 31), not(31)))\n }\n //if we want a zero-length slice let's just return a zero-length array\n default {\n tempBytes := mload(0x40)\n //zero out the 32 bytes slice we are about to return\n //we need to do it because Solidity does not garbage collect\n mstore(tempBytes, 0)\n\n mstore(0x40, add(tempBytes, 0x20))\n }\n }\n\n return tempBytes;\n }\n}\n" - }, - "src/bridges/hyphen/interfaces/hyphen.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * @title HyphenLiquidityPoolManager\n * @notice interface with functions to bridge ERC20 and Native via Hyphen-Bridge\n * @author Socket dot tech.\n */\ninterface HyphenLiquidityPoolManager {\n /**\n * @dev Function used to deposit tokens into pool to initiate a cross chain token transfer.\n * @param toChainId Chain id where funds needs to be transfered\n * @param tokenAddress ERC20 Token address that needs to be transfered\n * @param receiver Address on toChainId where tokens needs to be transfered\n * @param amount Amount of token being transfered\n */\n function depositErc20(\n uint256 toChainId,\n address tokenAddress,\n address receiver,\n uint256 amount,\n string calldata tag\n ) external;\n\n /**\n * @dev Function used to deposit native token into pool to initiate a cross chain token transfer.\n * @param receiver Address on toChainId where tokens needs to be transfered\n * @param toChainId Chain id where funds needs to be transfered\n */\n function depositNative(\n address receiver,\n uint256 toChainId,\n string calldata tag\n ) external payable;\n}\n" - }, - "src/swap/SwapImplBase.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {OnlySocketGatewayOwner, OnlySocketDeployer} from \"../errors/SocketErrors.sol\";\n\n/**\n * @title Abstract Implementation Contract.\n * @notice All Swap Implementation will follow this interface.\n * @author Socket dot tech.\n */\nabstract contract SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketDeployFactory;\n\n /// @notice FunctionSelector used to delegatecall to the performAction function of swap-router-implementation\n bytes4 public immutable SWAP_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"performAction(address,address,uint256,address,bytes)\")\n );\n\n /// @notice FunctionSelector used to delegatecall to the performActionWithIn function of swap-router-implementation\n bytes4 public immutable SWAP_WITHIN_FUNCTION_SELECTOR =\n bytes4(keccak256(\"performActionWithIn(address,address,uint256,bytes)\"));\n\n /****************************************\n * EVENTS *\n ****************************************/\n\n event SocketSwapTokens(\n address fromToken,\n address toToken,\n uint256 buyAmount,\n uint256 sellAmount,\n bytes32 routeName,\n address receiver\n );\n\n /**\n * @notice Construct the base for all SwapImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n */\n constructor(address _socketGateway, address _socketDeployFactory) {\n socketGateway = _socketGateway;\n socketDeployFactory = _socketDeployFactory;\n }\n\n /****************************************\n * MODIFIERS *\n ****************************************/\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketDeployFactory() {\n if (msg.sender != socketDeployFactory) {\n revert OnlySocketDeployer();\n }\n _;\n }\n\n /****************************************\n * RESTRICTED FUNCTIONS *\n ****************************************/\n\n /**\n * @notice function to rescue the ERC20 tokens in the Swap-Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the Swap-Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n function killme() external isSocketDeployFactory {\n selfdestruct(payable(msg.sender));\n }\n\n /******************************\n * VIRTUAL FUNCTIONS *\n *****************************/\n\n /**\n * @notice function to swap tokens on the chain\n * All swap implementation contracts must implement this function\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param receiverAddress recipient address of toToken\n * @param data encoded value of properties in the swapData Struct\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes memory data\n ) external payable virtual returns (uint256);\n\n /**\n * @notice function to swapWith - swaps tokens on the chain to socketGateway as recipient\n * All swap implementation contracts must implement this function\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes memory swapExtraData\n ) external payable virtual returns (uint256, address);\n}\n" - }, - "src/swap/zerox/ZeroXSwapImpl.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {Address0Provided, SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {ZEROX} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title ZeroX-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via ZeroX-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of ZeroX-Swap-Implementation\n * @author Socket dot tech.\n */\ncontract ZeroXSwapImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable ZeroXIdentifier = ZEROX;\n\n /// @notice unique name to identify the router, used to emit event upon successful bridging\n bytes32 public immutable NAME = keccak256(\"Zerox-Router\");\n\n /// @notice address of ZeroX-Exchange-Proxy to swap the tokens on Chain\n address payable public immutable zeroXExchangeProxy;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @notice ZeroXExchangeProxy contract is payable to allow ethereum swaps\n /// @dev ensure _zeroXExchangeProxy are set properly for the chainId in which the contract is being deployed\n constructor(\n address _zeroXExchangeProxy,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n zeroXExchangeProxy = payable(_zeroXExchangeProxy);\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * @dev This is called only when there is a request for a swap.\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken is to be swapped\n * @param amount amount to be swapped\n * @param receiverAddress address of toToken recipient\n * @param swapExtraData data required for zeroX Exchange to get the swap done\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 erc20ToToken = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, address(this), amount);\n token.safeApprove(zeroXExchangeProxy, amount);\n\n // solhint-disable-next-line\n (bool success, ) = zeroXExchangeProxy.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(zeroXExchangeProxy, 0);\n } else {\n (bool success, ) = zeroXExchangeProxy.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n if (toToken == NATIVE_TOKEN_ADDRESS) {\n payable(receiverAddress).transfer(returnAmount);\n } else {\n erc20ToToken.transfer(receiverAddress, returnAmount);\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n ZeroXIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 erc20ToToken = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, address(this), amount);\n token.safeApprove(zeroXExchangeProxy, amount);\n\n // solhint-disable-next-line\n (bool success, ) = zeroXExchangeProxy.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(zeroXExchangeProxy, 0);\n } else {\n (bool success, ) = zeroXExchangeProxy.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n ZeroXIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n" - }, - "src/bridges/cbridge/interfaces/cbridge.sol": { - "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\ninterface ICBridge {\n function send(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChinId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external;\n\n function sendNative(\n address _receiver,\n uint256 _amount,\n uint64 _dstChinId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external payable;\n\n function withdraws(bytes32 withdrawId) external view returns (bool);\n\n function withdraw(\n bytes calldata _wdmsg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n}\n" - }, - "src/bridges/stargate/l2/Stargate.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/stargate.sol\";\nimport \"../../../errors/SocketErrors.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {STARGATE} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Stargate-L2-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Stargate-L2-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of Stargate-L2-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract StargateImplL2 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable StargateIdentifier = STARGATE;\n\n /// @notice Function-selector for ERC20-token bridging on Stargate-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable STARGATE_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,uint256,(uint256,uint256,uint256,uint256,bytes32,bytes,uint16))\"\n )\n );\n\n bytes4 public immutable STARGATE_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint16,uint256,uint256,uint256,uint256,uint256,uint256,bytes32,bytes))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Stargate-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable STARGATE_L2_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint16,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n /// @notice Stargate Router to bridge ERC20 tokens\n IBridgeStargate public immutable router;\n\n /// @notice Stargate Router to bridge native tokens\n IBridgeStargate public immutable routerETH;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router, routerEth are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _routerEth,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = IBridgeStargate(_router);\n routerETH = IBridgeStargate(_routerEth);\n }\n\n /// @notice Struct to be used as a input parameter for Bridging tokens via Stargate-L2-route\n /// @dev while building transactionData,values should be set in this sequence of properties in this struct\n struct StargateBridgeExtraData {\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 destinationGasLimit;\n uint256 minReceivedAmt;\n bytes32 metadata;\n bytes destinationPayload;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct StargateBridgeDataNoToken {\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n struct StargateBridgeData {\n address token;\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Stargate-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n StargateBridgeData memory stargateBridgeData = abi.decode(\n bridgeData,\n (StargateBridgeData)\n );\n\n if (stargateBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + stargateBridgeData.optionalValue}(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n amount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(stargateBridgeData.token).safeApprove(\n address(router),\n amount\n );\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n amount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n stargateBridgeData.token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swapping.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param stargateBridgeData encoded data for StargateBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n StargateBridgeDataNoToken calldata stargateBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n routerETH.swapETH{\n value: bridgeAmount + stargateBridgeData.optionalValue\n }(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n bridgeAmount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(token).safeApprove(address(router), bridgeAmount);\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n bridgeAmount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0,\n \"0x\"\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param senderAddress address of sender\n * @param receiverAddress address of recipient\n * @param amount amount of token being bridge\n * @param value value\n * @param optionalValue optionalValue\n * @param stargateBridgeExtraData stargate bridge extradata\n */\n function bridgeERC20To(\n address token,\n address senderAddress,\n address receiverAddress,\n uint256 amount,\n uint256 value,\n uint256 optionalValue,\n StargateBridgeExtraData calldata stargateBridgeExtraData\n ) external payable {\n // token address might not be indication thats why passed through extraData\n if (token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateBridgeExtraData.stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n stargateBridgeExtraData.minReceivedAmt\n );\n } else {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n {\n router.swap{value: value}(\n stargateBridgeExtraData.stargateDstChainId,\n stargateBridgeExtraData.srcPoolId,\n stargateBridgeExtraData.dstPoolId,\n payable(senderAddress), // default to refund to main contract\n amount,\n stargateBridgeExtraData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeExtraData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(receiverAddress),\n stargateBridgeExtraData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n token,\n stargateBridgeExtraData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n stargateBridgeExtraData.metadata\n );\n }\n\n function bridgeNativeTo(\n address receiverAddress,\n address senderAddress,\n uint16 stargateDstChainId,\n uint256 amount,\n uint256 minReceivedAmt,\n uint256 optionalValue,\n bytes32 metadata\n ) external payable {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n minReceivedAmt\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 1000000 - }, - "outputSelection": { - "*": { - "*": [ - "evm.bytecode", - "evm.deployedBytecode", - "devdoc", - "userdoc", - "metadata", - "abi" - ] - } - }, - "metadata": { - "useLiteralContent": true - }, - "libraries": {} - } - }, - "ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_disabledRoute\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ArrayLengthMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectBridgeRatios\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyNominee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddressNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"controllerAddress\",\"type\":\"address\"}],\"name\":\"ControllerAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"ControllerDisabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"route\",\"type\":\"address\"}],\"name\":\"NewRouteAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"claimer\",\"type\":\"address\"}],\"name\":\"OwnerClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nominee\",\"type\":\"address\"}],\"name\":\"OwnerNominated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"RouteDisabled\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"BRIDGE_AFTER_SWAP_SELECTOR\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"CENT_PERCENT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"controllerAddress\",\"type\":\"address\"}],\"name\":\"addController\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"routeAddress\",\"type\":\"address\"}],\"name\":\"addRoute\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"addressAt\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controllerCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"controllers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"disableController\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"disableRoute\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"disabledRouteAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct ISocketGateway.SocketControllerRequest\",\"name\":\"socketControllerRequest\",\"type\":\"tuple\"}],\"name\":\"executeController\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct ISocketGateway.SocketControllerRequest[]\",\"name\":\"controllerRequests\",\"type\":\"tuple[]\"}],\"name\":\"executeControllers\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"routeData\",\"type\":\"bytes\"}],\"name\":\"executeRoute\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32[]\",\"name\":\"routeIds\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes[]\",\"name\":\"dataItems\",\"type\":\"bytes[]\"}],\"name\":\"executeRoutes\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"getController\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"getRoute\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nominee_\",\"type\":\"address\"}],\"name\":\"nominateOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nominee\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"rescueEther\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"rescueFunds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"routes\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"routesCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"routeAddresses\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"tokenAddresses\",\"type\":\"address[]\"},{\"internalType\":\"bool\",\"name\":\"isMax\",\"type\":\"bool\"}],\"name\":\"setApprovalForRouters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"swapRouteId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"swapImplData\",\"type\":\"bytes\"},{\"internalType\":\"uint32[]\",\"name\":\"bridgeRouteIds\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes[]\",\"name\":\"bridgeImplDataItems\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256[]\",\"name\":\"bridgeRatios\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"eventDataItems\",\"type\":\"bytes[]\"}],\"internalType\":\"struct ISocketRequest.SwapMultiBridgeRequest\",\"name\":\"swapMultiBridgeRequest\",\"type\":\"tuple\"}],\"name\":\"swapAndMultiBridge\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - "ContractName": "SocketGateway", - "CompilerVersion": "v0.8.7+commit.e28d00a7", - "OptimizationUsed": 1, - "Runs": 1000000, - "ConstructorArguments": "0x000000000000000000000000e8dd38e673a93ccfc2e3d7053efccb5c93f493650000000000000000000000000f34a522ff82151c90679b73211955068fd854f1", - "EVMVersion": "Default", - "Library": "", - "LicenseType": "", - "Proxy": 1, - "Implementation": "0xa3c4e32af0da5efaddb20cc9fb26159f55c8c42f", - "SwarmSource": "" - } -] \ No newline at end of file +[{"SourceCode":{"language":"Solidity","sources":{"src/bridges/hop/interfaces/amm.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/**\n * @title HopAMM\n * @notice Interface to handle the token bridging to L2 chains.\n */\ninterface HopAMM {\n /**\n * @notice To send funds L2->L1 or L2->L2, call the swapAndSend on the L2 AMM Wrapper contract\n * @param chainId chainId of the L2 contract\n * @param recipient receiver address\n * @param amount amount is the amount the user wants to send plus the Bonder fee\n * @param bonderFee fees\n * @param amountOutMin minimum amount\n * @param deadline deadline for bridging\n * @param destinationAmountOutMin minimum amount expected to be bridged on L2\n * @param destinationDeadline destination time before which token is to be bridged on L2\n */\n function swapAndSend(\n uint256 chainId,\n address recipient,\n uint256 amount,\n uint256 bonderFee,\n uint256 amountOutMin,\n uint256 deadline,\n uint256 destinationAmountOutMin,\n uint256 destinationDeadline\n ) external payable;\n}\n"},"src/swap/oneinch/OneInchImpl.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {ONEINCH} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title OneInch-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via OneInch-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of OneInchImplementation\n * @author Socket dot tech.\n */\ncontract OneInchImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable OneInchIdentifier = ONEINCH;\n\n /// @notice address of OneInchAggregator to swap the tokens on Chain\n address public immutable ONEINCH_AGGREGATOR;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @dev ensure _oneinchAggregator are set properly for the chainId in which the contract is being deployed\n constructor(\n address _oneinchAggregator,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n ONEINCH_AGGREGATOR = _oneinchAggregator;\n }\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * via OneInch-Middleware-Aggregator\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param receiverAddress address of toToken recipient\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n uint256 returnAmount;\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(ONEINCH_AGGREGATOR, amount);\n {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call(\n swapExtraData\n );\n token.safeApprove(ONEINCH_AGGREGATOR, 0);\n\n if (!success) {\n revert SwapFailed();\n }\n\n returnAmount = abi.decode(result, (uint256));\n }\n } else {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call{\n value: amount\n }(swapExtraData);\n if (!success) {\n revert SwapFailed();\n }\n returnAmount = abi.decode(result, (uint256));\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n OneInchIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * via OneInch-Middleware-Aggregator\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n uint256 returnAmount;\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(ONEINCH_AGGREGATOR, amount);\n {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call(\n swapExtraData\n );\n token.safeApprove(ONEINCH_AGGREGATOR, 0);\n\n if (!success) {\n revert SwapFailed();\n }\n\n returnAmount = abi.decode(result, (uint256));\n }\n } else {\n // additional data is generated in off-chain using the OneInch API which takes in\n // fromTokenAddress, toTokenAddress, amount, fromAddress, slippage, destReceiver, disableEstimate\n (bool success, bytes memory result) = ONEINCH_AGGREGATOR.call{\n value: amount\n }(swapExtraData);\n if (!success) {\n revert SwapFailed();\n }\n returnAmount = abi.decode(result, (uint256));\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n OneInchIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n"},"src/libraries/LibUtil.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./LibBytes.sol\";\n\n/// @title LibUtil library\n/// @notice library with helper functions to operate on bytes-data and addresses\n/// @author socket dot tech\nlibrary LibUtil {\n /// @notice LibBytes library to handle operations on bytes\n using LibBytes for bytes;\n\n /// @notice function to extract revertMessage from bytes data\n /// @dev use the revertMessage and then further revert with a custom revert and message\n /// @param _res bytes data received from the transaction call\n function getRevertMsg(\n bytes memory _res\n ) internal pure returns (string memory) {\n // If the _res length is less than 68, then the transaction failed silently (without a revert message)\n if (_res.length < 68) {\n return \"Transaction reverted silently\";\n }\n bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes\n return abi.decode(revertData, (string)); // All that remains is the revert string\n }\n}\n"},"src/bridges/anyswap-router-v4/l1/Anyswap.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {ANYSWAP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Anyswap-V4-Route L1 Implementation\n * @notice Route implementation with functions to bridge ERC20 via Anyswap-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AnyswapImplementation\n * This is the L1 implementation, so this is used when transferring from l1 to supported l1s or L1.\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\n\n/// @notice Interface to interact with AnyswapV4-Router Implementation\ninterface AnyswapV4Router {\n function anySwapOutUnderlying(\n address token,\n address to,\n uint256 amount,\n uint256 toChainID\n ) external;\n}\n\ncontract AnyswapImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AnyswapIdentifier = ANYSWAP;\n\n /// @notice Function-selector for ERC20-token bridging on Anyswap-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ANYSWAP_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,address)\"\n )\n );\n\n bytes4 public immutable ANYSWAP_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,address,bytes32))\"\n )\n );\n\n /// @notice AnSwapV4Router Contract instance used to deposit ERC20 on to Anyswap-Bridge\n /// @dev contract instance is to be initialized in the constructor using the router-address passed as constructor argument\n AnyswapV4Router public immutable router;\n\n /**\n * @notice Constructor sets the router address and socketGateway address.\n * @dev anyswap 4 router is immutable. so no setter function required.\n */\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = AnyswapV4Router(_router);\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeDataNoToken {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeData {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AnyswapBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AnyswapBridgeData memory anyswapBridgeData = abi.decode(\n bridgeData,\n (AnyswapBridgeData)\n );\n ERC20(anyswapBridgeData.token).safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n amount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n amount,\n anyswapBridgeData.token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param anyswapBridgeData encoded data for AnyswapBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AnyswapBridgeDataNoToken calldata anyswapBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n ERC20(token).safeApprove(address(router), bridgeAmount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n bridgeAmount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Anyswap-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param wrapperTokenAddress address of wrapperToken, WrappedVersion of the token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address wrapperTokenAddress\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n wrapperTokenAddress,\n receiverAddress,\n amount,\n toChainId\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AnyswapIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/cbridge/CelerStorageWrapper.sol":{"content":"// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {OnlySocketGateway, TransferIdExists, TransferIdDoesnotExist} from \"../../errors/SocketErrors.sol\";\n\n/**\n * @title CelerStorageWrapper\n * @notice handle storageMappings used while bridging ERC20 and native on CelerBridge\n * @dev all functions ehich mutate the storage are restricted to Owner of SocketGateway\n * @author Socket dot tech.\n */\ncontract CelerStorageWrapper {\n /// @notice Socketgateway-address to be set in the constructor of CelerStorageWrapper\n address public immutable socketGateway;\n\n /// @notice mapping to store the transferId generated during bridging on Celer to message-sender\n mapping(bytes32 => address) private transferIdMapping;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(address _socketGateway) {\n socketGateway = _socketGateway;\n }\n\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @param transferIdAddress message sender who is making the bridging on CelerBridge\n */\n function setAddressForTransferId(\n bytes32 transferId,\n address transferIdAddress\n ) external {\n if (msg.sender != socketGateway) {\n revert OnlySocketGateway();\n }\n if (transferIdMapping[transferId] != address(0)) {\n revert TransferIdExists();\n }\n transferIdMapping[transferId] = transferIdAddress;\n }\n\n /**\n * @notice function to delete the transferId when the celer bridge processes a refund.\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n */\n function deleteTransferId(bytes32 transferId) external {\n if (msg.sender != socketGateway) {\n revert OnlySocketGateway();\n }\n if (transferIdMapping[transferId] == address(0)) {\n revert TransferIdDoesnotExist();\n }\n\n delete transferIdMapping[transferId];\n }\n\n /**\n * @notice function to lookup the address mapped to the transferId\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @return address of account mapped to transferId\n */\n function getAddressFromTransferId(\n bytes32 transferId\n ) external view returns (address) {\n return transferIdMapping[transferId];\n }\n}\n"},"src/bridges/polygon/interfaces/polygon.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/**\n * @title RootChain Manager Interface for Polygon Bridge.\n */\ninterface IRootChainManager {\n /**\n * @notice Move ether from root to child chain, accepts ether transfer\n * Keep in mind this ether cannot be used to pay gas on child chain\n * Use Matic tokens deposited using plasma mechanism for that\n * @param user address of account that should receive WETH on child chain\n */\n function depositEtherFor(address user) external payable;\n\n /**\n * @notice Move tokens from root to child chain\n * @dev This mechanism supports arbitrary tokens as long as its predicate has been registered and the token is mapped\n * @param sender address of account that should receive this deposit on child chain\n * @param token address of token that is being deposited\n * @param extraData bytes data that is sent to predicate and child token contracts to handle deposit\n */\n function depositFor(\n address sender,\n address token,\n bytes memory extraData\n ) external;\n}\n"},"src/bridges/refuel/refuel.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/refuel.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {REFUEL} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Refuel-Route Implementation\n * @notice Route implementation with functions to bridge Native via Refuel-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of RefuelImplementation\n * @author Socket dot tech.\n */\ncontract RefuelBridgeImpl is BridgeImplBase {\n bytes32 public immutable RefuelIdentifier = REFUEL;\n\n /// @notice refuelBridge-Contract address used to deposit Native on Refuel-Bridge\n address public immutable refuelBridge;\n\n /// @notice Function-selector for Native bridging via Refuel-Bridge\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable REFUEL_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,address,uint256,bytes32)\"));\n\n bytes4 public immutable REFUEL_NATIVE_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\"swapAndBridge(uint32,address,uint256,bytes32,bytes)\")\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure _refuelBridge are set properly for the chainId in which the contract is being deployed\n constructor(\n address _refuelBridge,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n refuelBridge = _refuelBridge;\n }\n\n // Function to receive Ether. msg.data must be empty\n receive() external payable {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct RefuelBridgeData {\n address receiverAddress;\n uint256 toChainId;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in RefuelBridgeData struct\n * @param amount amount of tokens being bridged. this must be only native\n * @param bridgeData encoded data for RefuelBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n RefuelBridgeData memory refuelBridgeData = abi.decode(\n bridgeData,\n (RefuelBridgeData)\n );\n IRefuel(refuelBridge).depositNativeToken{value: amount}(\n refuelBridgeData.toChainId,\n refuelBridgeData.receiverAddress\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n refuelBridgeData.toChainId,\n RefuelIdentifier,\n msg.sender,\n refuelBridgeData.receiverAddress,\n refuelBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in RefuelBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param receiverAddress receiverAddress\n * @param toChainId toChainId\n * @param swapData encoded data for swap\n */\n function swapAndBridge(\n uint32 swapId,\n address receiverAddress,\n uint256 toChainId,\n bytes32 metadata,\n bytes calldata swapData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, ) = abi.decode(result, (uint256, address));\n IRefuel(refuelBridge).depositNativeToken{value: bridgeAmount}(\n toChainId,\n receiverAddress\n );\n\n emit SocketBridge(\n bridgeAmount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n RefuelIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Refuel-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of native being refuelled to destination chain\n * @param receiverAddress recipient address of the refuelled native\n * @param toChainId destinationChainId\n */\n function bridgeNativeTo(\n uint256 amount,\n address receiverAddress,\n uint256 toChainId,\n bytes32 metadata\n ) external payable {\n IRefuel(refuelBridge).depositNativeToken{value: amount}(\n toChainId,\n receiverAddress\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n RefuelIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/across/interfaces/across.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/// @notice interface with functions to interact with SpokePool contract of Across-Bridge\ninterface SpokePool {\n /**************************************\n * DEPOSITOR FUNCTIONS *\n **************************************/\n\n /**\n * @notice Called by user to bridge funds from origin to destination chain. Depositor will effectively lock\n * tokens in this contract and receive a destination token on the destination chain. The origin => destination\n * token mapping is stored on the L1 HubPool.\n * @notice The caller must first approve this contract to spend amount of originToken.\n * @notice The originToken => destinationChainId must be enabled.\n * @notice This method is payable because the caller is able to deposit native token if the originToken is\n * wrappedNativeToken and this function will handle wrapping the native token to wrappedNativeToken.\n * @param recipient Address to receive funds at on destination chain.\n * @param originToken Token to lock into this contract to initiate deposit.\n * @param amount Amount of tokens to deposit. Will be amount of tokens to receive less fees.\n * @param destinationChainId Denotes network where user will receive funds from SpokePool by a relayer.\n * @param relayerFeePct % of deposit amount taken out to incentivize a fast relayer.\n * @param quoteTimestamp Timestamp used by relayers to compute this deposit's realizedLPFeePct which is paid\n * to LP pool on HubPool.\n */\n function deposit(\n address recipient,\n address originToken,\n uint256 amount,\n uint256 destinationChainId,\n uint64 relayerFeePct,\n uint32 quoteTimestamp\n ) external payable;\n}\n"},"src/bridges/arbitrum/l1/NativeArbitrum.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {L1GatewayRouter} from \"../interfaces/arbitrum.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {NATIVE_ARBITRUM} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Native Arbitrum-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 via NativeArbitrum-Bridge\n * @notice Called via SocketGateway if the routeId in the request maps to the routeId of NativeArbitrum-Implementation\n * @notice This is used when transferring from ethereum chain to arbitrum via their native bridge.\n * @notice Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * @notice RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract NativeArbitrumImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativeArbitrumIdentifier = NATIVE_ARBITRUM;\n\n uint256 public constant DESTINATION_CHAIN_ID = 42161;\n\n /// @notice Function-selector for ERC20-token bridging on NativeArbitrum\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_ARBITRUM_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,uint256,uint256,bytes32,address,address,address,bytes)\"\n )\n );\n\n bytes4 public immutable NATIVE_ARBITRUM_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,uint256,uint256,address,address,bytes32,bytes))\"\n )\n );\n\n /// @notice router address of NativeArbitrum Bridge\n /// @notice GatewayRouter looks up ERC20Token's gateway, and finding that it's Standard ERC20 gateway (the L1ERC20Gateway contract).\n address public immutable router;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = _router;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct NativeArbitrumBridgeDataNoToken {\n uint256 value;\n /// @notice maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 maxGas;\n /// @notice gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 gasPriceBid;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of Gateway which handles the token bridging for the token\n /// @notice gatewayAddress is unique for each token\n address gatewayAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n /// @notice data is a depositParameter derived from erc20Bridger of nativeArbitrum\n bytes data;\n }\n\n struct NativeArbitrumBridgeData {\n uint256 value;\n /// @notice maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 maxGas;\n /// @notice gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n uint256 gasPriceBid;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of Gateway which handles the token bridging for the token\n /// @notice gatewayAddress is unique for each token\n address gatewayAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n /// @notice data is a depositParameter derived from erc20Bridger of nativeArbitrum\n bytes data;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativeArbitrumBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for NativeArbitrumBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n NativeArbitrumBridgeData memory nativeArbitrumBridgeData = abi.decode(\n bridgeData,\n (NativeArbitrumBridgeData)\n );\n ERC20(nativeArbitrumBridgeData.token).safeApprove(\n nativeArbitrumBridgeData.gatewayAddress,\n amount\n );\n\n L1GatewayRouter(router).outboundTransfer{\n value: nativeArbitrumBridgeData.value\n }(\n nativeArbitrumBridgeData.token,\n nativeArbitrumBridgeData.receiverAddress,\n amount,\n nativeArbitrumBridgeData.maxGas,\n nativeArbitrumBridgeData.gasPriceBid,\n nativeArbitrumBridgeData.data\n );\n\n emit SocketBridge(\n amount,\n nativeArbitrumBridgeData.token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n nativeArbitrumBridgeData.receiverAddress,\n nativeArbitrumBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativeArbitrumBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param nativeArbitrumBridgeData encoded data for NativeArbitrumBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n NativeArbitrumBridgeDataNoToken calldata nativeArbitrumBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n ERC20(token).safeApprove(\n nativeArbitrumBridgeData.gatewayAddress,\n bridgeAmount\n );\n\n L1GatewayRouter(router).outboundTransfer{\n value: nativeArbitrumBridgeData.value\n }(\n token,\n nativeArbitrumBridgeData.receiverAddress,\n bridgeAmount,\n nativeArbitrumBridgeData.maxGas,\n nativeArbitrumBridgeData.gasPriceBid,\n nativeArbitrumBridgeData.data\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n nativeArbitrumBridgeData.receiverAddress,\n nativeArbitrumBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativeArbitrum-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param value value\n * @param maxGas maxGas is a depositParameter derived from erc20Bridger of nativeArbitrum\n * @param gasPriceBid gasPriceBid is a depositParameter derived from erc20Bridger of nativeArbitrum\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param gatewayAddress address of Gateway which handles the token bridging for the token, gatewayAddress is unique for each token\n * @param data data is a depositParameter derived from erc20Bridger of nativeArbitrum\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 value,\n uint256 maxGas,\n uint256 gasPriceBid,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address gatewayAddress,\n bytes memory data\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(gatewayAddress, amount);\n\n L1GatewayRouter(router).outboundTransfer{value: value}(\n token,\n receiverAddress,\n amount,\n maxGas,\n gasPriceBid,\n data\n );\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativeArbitrumIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/across/Across.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/across.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ACROSS} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Across-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Across-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AcrossImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract AcrossImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AcrossIdentifier = ACROSS;\n\n /// @notice Function-selector for ERC20-token bridging on Across-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ACROSS_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,uint32,uint64)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Across-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable ACROSS_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(uint256,uint256,bytes32,address,uint32,uint64)\"\n )\n );\n\n bytes4 public immutable ACROSS_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,uint32,uint64,bytes32))\"\n )\n );\n\n /// @notice spokePool Contract instance used to deposit ERC20 and Native on to Across-Bridge\n /// @dev contract instance is to be initialized in the constructor using the spokePoolAddress passed as constructor argument\n SpokePool public immutable spokePool;\n address public immutable spokePoolAddress;\n\n /// @notice address of WETH token to be initialised in constructor\n address public immutable WETH;\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AcrossBridgeDataNoToken {\n uint256 toChainId;\n address receiverAddress;\n uint32 quoteTimestamp;\n uint64 relayerFeePct;\n bytes32 metadata;\n }\n\n struct AcrossBridgeData {\n uint256 toChainId;\n address receiverAddress;\n address token;\n uint32 quoteTimestamp;\n uint64 relayerFeePct;\n bytes32 metadata;\n }\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure spokepool, weth-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _spokePool,\n address _wethAddress,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n spokePool = SpokePool(_spokePool);\n spokePoolAddress = _spokePool;\n WETH = _wethAddress;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AcrossBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AcrossBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AcrossBridgeData memory acrossBridgeData = abi.decode(\n bridgeData,\n (AcrossBridgeData)\n );\n\n if (acrossBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n spokePool.deposit{value: amount}(\n acrossBridgeData.receiverAddress,\n WETH,\n amount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n } else {\n spokePool.deposit(\n acrossBridgeData.receiverAddress,\n acrossBridgeData.token,\n amount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n }\n\n emit SocketBridge(\n amount,\n acrossBridgeData.token,\n acrossBridgeData.toChainId,\n AcrossIdentifier,\n msg.sender,\n acrossBridgeData.receiverAddress,\n acrossBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AcrossBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param acrossBridgeData encoded data for AcrossBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AcrossBridgeDataNoToken calldata acrossBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n spokePool.deposit{value: bridgeAmount}(\n acrossBridgeData.receiverAddress,\n WETH,\n bridgeAmount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n } else {\n spokePool.deposit(\n acrossBridgeData.receiverAddress,\n token,\n bridgeAmount,\n acrossBridgeData.toChainId,\n acrossBridgeData.relayerFeePct,\n acrossBridgeData.quoteTimestamp\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n acrossBridgeData.toChainId,\n AcrossIdentifier,\n msg.sender,\n acrossBridgeData.receiverAddress,\n acrossBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Across-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param quoteTimestamp timestamp for quote and this is to be used by Across-Bridge contract\n * @param relayerFeePct feePct that will be relayed by the Bridge to the relayer\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n uint32 quoteTimestamp,\n uint64 relayerFeePct\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n spokePool.deposit(\n receiverAddress,\n address(token),\n amount,\n toChainId,\n relayerFeePct,\n quoteTimestamp\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AcrossIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Across-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param quoteTimestamp timestamp for quote and this is to be used by Across-Bridge contract\n * @param relayerFeePct feePct that will be relayed by the Bridge to the relayer\n */\n function bridgeNativeTo(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n uint32 quoteTimestamp,\n uint64 relayerFeePct\n ) external payable {\n spokePool.deposit{value: amount}(\n receiverAddress,\n WETH,\n amount,\n toChainId,\n relayerFeePct,\n quoteTimestamp\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n AcrossIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/cbridge/interfaces/ICelerStorageWrapper.sol":{"content":"// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * @title Celer-StorageWrapper interface\n * @notice Interface to handle storageMappings used while bridging ERC20 and native on CelerBridge\n * @dev all functions ehich mutate the storage are restricted to Owner of SocketGateway\n * @author Socket dot tech.\n */\ninterface ICelerStorageWrapper {\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @param transferIdAddress message sender who is making the bridging on CelerBridge\n */\n function setAddressForTransferId(\n bytes32 transferId,\n address transferIdAddress\n ) external;\n\n /**\n * @notice function to store the transferId and message-sender of a bridging activity\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n */\n function deleteTransferId(bytes32 transferId) external;\n\n /**\n * @notice function to lookup the address mapped to the transferId\n * @param transferId transferId generated during the bridging of ERC20 or native on CelerBridge\n * @return address of account mapped to transferId\n */\n function getAddressFromTransferId(\n bytes32 transferId\n ) external view returns (address);\n}\n"},"src/bridges/optimism/interfaces/optimism.sol":{"content":"// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\ninterface L1StandardBridge {\n /**\n * @dev Performs the logic for deposits by storing the ETH and informing the L2 ETH Gateway of\n * the deposit.\n * @param _to Account to give the deposit to on L2.\n * @param _l2Gas Gas limit required to complete the deposit on L2.\n * @param _data Optional data to forward to L2. This data is provided\n * solely as a convenience for external contracts. Aside from enforcing a maximum\n * length, these contracts provide no guarantees about its content.\n */\n function depositETHTo(\n address _to,\n uint32 _l2Gas,\n bytes calldata _data\n ) external payable;\n\n /**\n * @dev deposit an amount of ERC20 to a recipient's balance on L2.\n * @param _l1Token Address of the L1 ERC20 we are depositing\n * @param _l2Token Address of the L1 respective L2 ERC20\n * @param _to L2 address to credit the withdrawal to.\n * @param _amount Amount of the ERC20 to deposit.\n * @param _l2Gas Gas limit required to complete the deposit on L2.\n * @param _data Optional data to forward to L2. This data is provided\n * solely as a convenience for external contracts. Aside from enforcing a maximum\n * length, these contracts provide no guarantees about its content.\n */\n function depositERC20To(\n address _l1Token,\n address _l2Token,\n address _to,\n uint256 _amount,\n uint32 _l2Gas,\n bytes calldata _data\n ) external;\n}\n\ninterface OldL1TokenGateway {\n /**\n * @dev Transfer SNX to L2 First, moves the SNX into the deposit escrow\n *\n * @param _to Account to give the deposit to on L2\n * @param _amount Amount of the ERC20 to deposit.\n */\n function depositTo(address _to, uint256 _amount) external;\n\n /**\n * @dev Transfer SNX to L2 First, moves the SNX into the deposit escrow\n *\n * @param currencyKey currencyKey for the SynthToken\n * @param destination Account to give the deposit to on L2\n * @param amount Amount of the ERC20 to deposit.\n */\n function initiateSynthTransfer(\n bytes32 currencyKey,\n address destination,\n uint256 amount\n ) external;\n}\n"},"src/bridges/arbitrum/interfaces/arbitrum.sol":{"content":"// SPDX-License-Identifier: Apache-2.0\n\n/*\n * Copyright 2021, Offchain Labs, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npragma solidity >=0.8.0;\n\n/**\n * @title L1gatewayRouter for native-arbitrum\n */\ninterface L1GatewayRouter {\n /**\n * @notice outbound function to bridge ERC20 via NativeArbitrum-Bridge\n * @param _token address of token being bridged via GatewayRouter\n * @param _to recipient of the token on arbitrum chain\n * @param _amount amount of ERC20 token being bridged\n * @param _maxGas a depositParameter for bridging the token\n * @param _gasPriceBid a depositParameter for bridging the token\n * @param _data a depositParameter for bridging the token\n * @return calldata returns the output of transactioncall made on gatewayRouter\n */\n function outboundTransfer(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _maxGas,\n uint256 _gasPriceBid,\n bytes calldata _data\n ) external payable returns (bytes calldata);\n}\n"},"src/deployFactory/DisabledSocketRoute.sol":{"content":"//SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {OnlySocketGatewayOwner} from \"../errors/SocketErrors.sol\";\n\ncontract DisabledSocketRoute {\n using SafeTransferLib for ERC20;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n error RouteDisabled();\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n */\n constructor(address _socketGateway) {\n socketGateway = _socketGateway;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /**\n * @notice function to rescue the ERC20 tokens in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n /**\n * @notice Handle route function calls gracefully.\n */\n fallback() external payable {\n revert RouteDisabled();\n }\n\n /**\n * @notice Support receiving ether to handle refunds etc.\n */\n receive() external payable {}\n}\n"},"src/bridges/polygon/NativePolygon.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"./interfaces/polygon.sol\";\nimport {BridgeImplBase} from \"../BridgeImplBase.sol\";\nimport {NATIVE_POLYGON} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title NativePolygon-Route Implementation\n * @notice This is the L1 implementation, so this is used when transferring from ethereum to polygon via their native bridge.\n * @author Socket dot tech.\n */\ncontract NativePolygonImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativePolyonIdentifier = NATIVE_POLYGON;\n\n /// @notice destination-chain-Id for this router is always arbitrum\n uint256 public constant DESTINATION_CHAIN_ID = 137;\n\n /// @notice Function-selector for ERC20-token bridging on NativePolygon-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_POLYGON_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeERC20To(uint256,bytes32,address,address)\"));\n\n /// @notice Function-selector for Native bridging on NativePolygon-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable NATIVE_POLYGON_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,bytes32,address)\"));\n\n bytes4 public immutable NATIVE_POLYGON_SWAP_BRIDGE_SELECTOR =\n bytes4(keccak256(\"swapAndBridge(uint32,address,bytes32,bytes)\"));\n\n /// @notice root chain manager proxy on the ethereum chain\n /// @dev to be initialised in the constructor\n IRootChainManager public immutable rootChainManagerProxy;\n\n /// @notice ERC20 Predicate proxy on the ethereum chain\n /// @dev to be initialised in the constructor\n address public immutable erc20PredicateProxy;\n\n /**\n * // @notice We set all the required addresses in the constructor while deploying the contract.\n * // These will be constant addresses.\n * // @dev Please use the Proxy addresses and not the implementation addresses while setting these\n * // @param _rootChainManagerProxy address of the root chain manager proxy on the ethereum chain\n * // @param _erc20PredicateProxy address of the ERC20 Predicate proxy on the ethereum chain.\n * // @param _socketGateway address of the socketGateway contract that calls this contract\n */\n constructor(\n address _rootChainManagerProxy,\n address _erc20PredicateProxy,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n rootChainManagerProxy = IRootChainManager(_rootChainManagerProxy);\n erc20PredicateProxy = _erc20PredicateProxy;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativePolygon-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for NativePolygon-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n (address token, address receiverAddress, bytes32 metadata) = abi.decode(\n bridgeData,\n (address, address, bytes32)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IRootChainManager(rootChainManagerProxy).depositEtherFor{\n value: amount\n }(receiverAddress);\n } else {\n ERC20(token).safeApprove(erc20PredicateProxy, amount);\n\n // deposit into rootchain manager\n IRootChainManager(rootChainManagerProxy).depositFor(\n receiverAddress,\n token,\n abi.encodePacked(amount)\n );\n }\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in NativePolygon-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param receiverAddress address of the receiver\n * @param swapData encoded data for swap\n */\n function swapAndBridge(\n uint32 swapId,\n address receiverAddress,\n bytes32 metadata,\n bytes calldata swapData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IRootChainManager(rootChainManagerProxy).depositEtherFor{\n value: bridgeAmount\n }(receiverAddress);\n } else {\n ERC20(token).safeApprove(erc20PredicateProxy, bridgeAmount);\n\n // deposit into rootchain manager\n IRootChainManager(rootChainManagerProxy).depositFor(\n receiverAddress,\n token,\n abi.encodePacked(bridgeAmount)\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativePolygon-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of tokens being bridged\n * @param receiverAddress recipient address\n * @param token address of token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n address token\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n\n // set allowance for erc20 predicate\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(erc20PredicateProxy, amount);\n\n // deposit into rootchain manager\n rootChainManagerProxy.depositFor(\n receiverAddress,\n token,\n abi.encodePacked(amount)\n );\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via NativePolygon-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount of tokens being bridged\n * @param receiverAddress recipient address\n */\n function bridgeNativeTo(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress\n ) external payable {\n rootChainManagerProxy.depositEtherFor{value: amount}(receiverAddress);\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n DESTINATION_CHAIN_ID,\n NativePolyonIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/stargate/l1/Stargate.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/stargate.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {STARGATE} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Stargate-L1-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Stargate-L1-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of Stargate-L1-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract StargateImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable StargateIdentifier = STARGATE;\n\n /// @notice Function-selector for ERC20-token bridging on Stargate-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable STARGATE_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,(uint256,uint256,uint256,uint256,bytes32,bytes,uint16))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Stargate-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable STARGATE_L1_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint16,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable STARGATE_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint16,uint256,uint256,uint256,uint256,uint256,uint256,bytes32,bytes))\"\n )\n );\n\n /// @notice Stargate Router to bridge ERC20 tokens\n IBridgeStargate public immutable router;\n\n /// @notice Stargate Router to bridge native tokens\n IBridgeStargate public immutable routerETH;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router, routerEth are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _routerEth,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = IBridgeStargate(_router);\n routerETH = IBridgeStargate(_routerEth);\n }\n\n struct StargateBridgeExtraData {\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 destinationGasLimit;\n uint256 minReceivedAmt;\n bytes32 metadata;\n bytes destinationPayload;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct StargateBridgeDataNoToken {\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n struct StargateBridgeData {\n address token;\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Stargate-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n StargateBridgeData memory stargateBridgeData = abi.decode(\n bridgeData,\n (StargateBridgeData)\n );\n\n if (stargateBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + stargateBridgeData.optionalValue}(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n amount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(stargateBridgeData.token).safeApprove(\n address(router),\n amount\n );\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n amount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n stargateBridgeData.token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param stargateBridgeData encoded data for StargateBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n StargateBridgeDataNoToken calldata stargateBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{\n value: bridgeAmount + stargateBridgeData.optionalValue\n }(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n bridgeAmount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(token).safeApprove(address(router), bridgeAmount);\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n bridgeAmount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param senderAddress address of sender\n * @param receiverAddress address of recipient\n * @param amount amount of token being bridge\n * @param value value\n * @param stargateBridgeExtraData stargate bridge extradata\n */\n function bridgeERC20To(\n address token,\n address senderAddress,\n address receiverAddress,\n uint256 amount,\n uint256 value,\n StargateBridgeExtraData calldata stargateBridgeExtraData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n {\n router.swap{value: value}(\n stargateBridgeExtraData.stargateDstChainId,\n stargateBridgeExtraData.srcPoolId,\n stargateBridgeExtraData.dstPoolId,\n payable(senderAddress), // default to refund to main contract\n amount,\n stargateBridgeExtraData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeExtraData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(receiverAddress),\n stargateBridgeExtraData.destinationPayload\n );\n }\n\n emit SocketBridge(\n amount,\n token,\n stargateBridgeExtraData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n stargateBridgeExtraData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of receipient\n * @param senderAddress address of sender\n * @param stargateDstChainId stargate defines chain id in its way\n * @param amount amount of token being bridge\n * @param minReceivedAmt defines the slippage, the min qty you would accept on the destination\n * @param optionalValue optionalValue Native amount\n */\n function bridgeNativeTo(\n address receiverAddress,\n address senderAddress,\n uint16 stargateDstChainId,\n uint256 amount,\n uint256 minReceivedAmt,\n uint256 optionalValue,\n bytes32 metadata\n ) external payable {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n minReceivedAmt\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/hop/l2/HopImplL2.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../interfaces/amm.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {HOP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hop-L2 Route Implementation\n * @notice This is the L2 implementation, so this is used when transferring from l2 to supported l2s\n * Called via SocketGateway if the routeId in the request maps to the routeId of HopL2-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HopImplL2 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HopIdentifier = HOP;\n\n /// @notice Function-selector for ERC20-token bridging on Hop-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HOP_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,(uint256,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Hop-L2-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable HOP_L2_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable HOP_L2_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used as a input parameter for Bridging tokens via Hop-L2-route\n /// @dev while building transactionData,values should be set in this sequence of properties in this struct\n struct HopBridgeRequestData {\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HopBridgeDataNoToken {\n // The address receiving funds at the destination\n address receiverAddress;\n // AMM address of Hop on L2\n address hopAMM;\n // The chainId of the destination chain\n uint256 toChainId;\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopBridgeData {\n /// @notice address of token being bridged\n address token;\n // The address receiving funds at the destination\n address receiverAddress;\n // AMM address of Hop on L2\n address hopAMM;\n // The chainId of the destination chain\n uint256 toChainId;\n // fees passed to relayer\n uint256 bonderFee;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // Minimum amount expected to be received or bridged to destination\n uint256 amountOutMinDestination;\n // deadline for bridging to destination\n uint256 deadlineDestination;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Hop-L2-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HopBridgeData memory hopData = abi.decode(bridgeData, (HopBridgeData));\n\n if (hopData.token == NATIVE_TOKEN_ADDRESS) {\n HopAMM(hopData.hopAMM).swapAndSend{value: amount}(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n } else {\n // perform bridging\n HopAMM(hopData.hopAMM).swapAndSend(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n }\n\n emit SocketBridge(\n amount,\n hopData.token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hopData encoded data for HopData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HopBridgeDataNoToken calldata hopData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n HopAMM(hopData.hopAMM).swapAndSend{value: bridgeAmount}(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n } else {\n // perform bridging\n HopAMM(hopData.hopAMM).swapAndSend(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.bonderFee,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.amountOutMinDestination,\n hopData.deadlineDestination\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hop-L2-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param token token being bridged\n * @param hopAMM AMM address of Hop on L2\n * @param amount The amount being bridged\n * @param toChainId The chainId of the destination chain\n * @param hopBridgeRequestData extraData for Bridging across Hop-L2\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n address hopAMM,\n uint256 amount,\n uint256 toChainId,\n HopBridgeRequestData calldata hopBridgeRequestData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n\n HopAMM(hopAMM).swapAndSend(\n toChainId,\n receiverAddress,\n amount,\n hopBridgeRequestData.bonderFee,\n hopBridgeRequestData.amountOutMin,\n hopBridgeRequestData.deadline,\n hopBridgeRequestData.amountOutMinDestination,\n hopBridgeRequestData.deadlineDestination\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n hopBridgeRequestData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hop-L2-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param hopAMM AMM address of Hop on L2\n * @param amount The amount being bridged\n * @param toChainId The chainId of the destination chain\n * @param bonderFee fees passed to relayer\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n * @param amountOutMinDestination Minimum amount expected to be received or bridged to destination\n * @param deadlineDestination deadline for bridging to destination\n */\n function bridgeNativeTo(\n address receiverAddress,\n address hopAMM,\n uint256 amount,\n uint256 toChainId,\n uint256 bonderFee,\n uint256 amountOutMin,\n uint256 deadline,\n uint256 amountOutMinDestination,\n uint256 deadlineDestination,\n bytes32 metadata\n ) external payable {\n // token address might not be indication thats why passed through extraData\n // perform bridging\n HopAMM(hopAMM).swapAndSend{value: amount}(\n toChainId,\n receiverAddress,\n amount,\n bonderFee,\n amountOutMin,\n deadline,\n amountOutMinDestination,\n deadlineDestination\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/anyswap-router-v4/l2/Anyswap.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {ANYSWAP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Anyswap-V4-Route L1 Implementation\n * @notice Route implementation with functions to bridge ERC20 via Anyswap-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of AnyswapImplementation\n * This is the L2 implementation, so this is used when transferring from l2.\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ninterface AnyswapV4Router {\n function anySwapOutUnderlying(\n address token,\n address to,\n uint256 amount,\n uint256 toChainID\n ) external;\n}\n\ncontract AnyswapL2Impl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable AnyswapIdentifier = ANYSWAP;\n\n /// @notice Function-selector for ERC20-token bridging on Anyswap-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable ANYSWAP_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(uint256,uint256,bytes32,address,address,address)\"\n )\n );\n\n bytes4 public immutable ANYSWAP_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,address,address,bytes32))\"\n )\n );\n\n // polygon router multichain router v4\n AnyswapV4Router public immutable router;\n\n /**\n * @notice Constructor sets the router address and socketGateway address.\n * @dev anyswap v4 router is immutable. so no setter function required.\n */\n constructor(\n address _router,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = AnyswapV4Router(_router);\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeDataNoToken {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct AnyswapBridgeData {\n /// @notice destination ChainId\n uint256 toChainId;\n /// @notice address of receiver of bridged tokens\n address receiverAddress;\n /// @notice address of wrapperToken, WrappedVersion of the token being bridged\n address wrapperTokenAddress;\n /// @notice address of token being bridged\n address token;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for AnyswapBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n AnyswapBridgeData memory anyswapBridgeData = abi.decode(\n bridgeData,\n (AnyswapBridgeData)\n );\n ERC20(anyswapBridgeData.token).safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n amount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n amount,\n anyswapBridgeData.token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in AnyswapBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param anyswapBridgeData encoded data for AnyswapBridge\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n AnyswapBridgeDataNoToken calldata anyswapBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n ERC20(token).safeApprove(address(router), bridgeAmount);\n router.anySwapOutUnderlying(\n anyswapBridgeData.wrapperTokenAddress,\n anyswapBridgeData.receiverAddress,\n bridgeAmount,\n anyswapBridgeData.toChainId\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n anyswapBridgeData.toChainId,\n AnyswapIdentifier,\n msg.sender,\n anyswapBridgeData.receiverAddress,\n anyswapBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Anyswap-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount being bridged\n * @param toChainId destination ChainId\n * @param receiverAddress address of receiver of bridged tokens\n * @param token address of token being bridged\n * @param wrapperTokenAddress address of wrapperToken, WrappedVersion of the token being bridged\n */\n function bridgeERC20To(\n uint256 amount,\n uint256 toChainId,\n bytes32 metadata,\n address receiverAddress,\n address token,\n address wrapperTokenAddress\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n router.anySwapOutUnderlying(\n wrapperTokenAddress,\n receiverAddress,\n amount,\n toChainId\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n AnyswapIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/hyphen/Hyphen.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"./interfaces/hyphen.sol\";\nimport \"../BridgeImplBase.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {HYPHEN} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hyphen-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Hyphen-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of HyphenImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HyphenImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HyphenIdentifier = HYPHEN;\n\n /// @notice Function-selector for ERC20-token bridging on Hyphen-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HYPHEN_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"bridgeERC20To(uint256,bytes32,address,address,uint256)\")\n );\n\n /// @notice Function-selector for Native bridging on Hyphen-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4 public immutable HYPHEN_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(keccak256(\"bridgeNativeTo(uint256,bytes32,address,uint256)\"));\n\n bytes4 public immutable HYPHEN_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\"swapAndBridge(uint32,bytes,(address,uint256,bytes32))\")\n );\n\n /// @notice liquidityPoolManager - liquidityPool Manager of Hyphen used to bridge ERC20 and native\n /// @dev this is to be initialized in constructor with a valid deployed address of hyphen-liquidityPoolManager\n HyphenLiquidityPoolManager public immutable liquidityPoolManager;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure liquidityPoolManager-address are set properly for the chainId in which the contract is being deployed\n constructor(\n address _liquidityPoolManager,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n liquidityPoolManager = HyphenLiquidityPoolManager(\n _liquidityPoolManager\n );\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HyphenData {\n /// @notice address of token being bridged\n address token;\n /// @notice address of receiver\n address receiverAddress;\n /// @notice chainId of destination\n uint256 toChainId;\n /// @notice socket offchain created hash\n bytes32 metadata;\n }\n\n struct HyphenDataNoToken {\n /// @notice address of receiver\n address receiverAddress;\n /// @notice chainId of destination\n uint256 toChainId;\n /// @notice chainId of destination\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HyphenBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for HyphenBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HyphenData memory hyphenData = abi.decode(bridgeData, (HyphenData));\n\n if (hyphenData.token == NATIVE_TOKEN_ADDRESS) {\n liquidityPoolManager.depositNative{value: amount}(\n hyphenData.receiverAddress,\n hyphenData.toChainId,\n \"SOCKET\"\n );\n } else {\n ERC20(hyphenData.token).safeApprove(\n address(liquidityPoolManager),\n amount\n );\n liquidityPoolManager.depositErc20(\n hyphenData.toChainId,\n hyphenData.token,\n hyphenData.receiverAddress,\n amount,\n \"SOCKET\"\n );\n }\n\n emit SocketBridge(\n amount,\n hyphenData.token,\n hyphenData.toChainId,\n HyphenIdentifier,\n msg.sender,\n hyphenData.receiverAddress,\n hyphenData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HyphenBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hyphenData encoded data for hyphenData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HyphenDataNoToken calldata hyphenData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n liquidityPoolManager.depositNative{value: bridgeAmount}(\n hyphenData.receiverAddress,\n hyphenData.toChainId,\n \"SOCKET\"\n );\n } else {\n ERC20(token).safeApprove(\n address(liquidityPoolManager),\n bridgeAmount\n );\n liquidityPoolManager.depositErc20(\n hyphenData.toChainId,\n token,\n hyphenData.receiverAddress,\n bridgeAmount,\n \"SOCKET\"\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hyphenData.toChainId,\n HyphenIdentifier,\n msg.sender,\n hyphenData.receiverAddress,\n hyphenData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hyphen-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount to be sent\n * @param receiverAddress address of the token to bridged to the destination chain.\n * @param token address of token being bridged\n * @param toChainId chainId of destination\n */\n function bridgeERC20To(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n address token,\n uint256 toChainId\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(liquidityPoolManager), amount);\n liquidityPoolManager.depositErc20(\n toChainId,\n token,\n receiverAddress,\n amount,\n \"SOCKET\"\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HyphenIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hyphen-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param amount amount to be sent\n * @param receiverAddress address of the token to bridged to the destination chain.\n * @param toChainId chainId of destination\n */\n function bridgeNativeTo(\n uint256 amount,\n bytes32 metadata,\n address receiverAddress,\n uint256 toChainId\n ) external payable {\n liquidityPoolManager.depositNative{value: amount}(\n receiverAddress,\n toChainId,\n \"SOCKET\"\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HyphenIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/bridges/optimism/l1/NativeOptimism.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/optimism.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {UnsupportedInterfaceId} from \"../../../errors/SocketErrors.sol\";\nimport {NATIVE_OPTIMISM} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title NativeOptimism-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via NativeOptimism-Bridge\n * Tokens are bridged from Ethereum to Optimism Chain.\n * Called via SocketGateway if the routeId in the request maps to the routeId of NativeOptimism-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract NativeOptimismImpl is BridgeImplBase {\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable NativeOptimismIdentifier = NATIVE_OPTIMISM;\n\n uint256 public constant DESTINATION_CHAIN_ID = 10;\n\n /// @notice Function-selector for ERC20-token bridging on Native-Optimism-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable NATIVE_OPTIMISM_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint32,(bytes32,bytes32),uint256,uint256,address,bytes)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Native-Optimism-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native balance\n bytes4\n public immutable NATIVE_OPTIMISM_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint32,uint256,bytes32,bytes)\"\n )\n );\n\n bytes4 public immutable NATIVE_OPTIMISM_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(uint256,bytes32,bytes32,address,address,uint32,address,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct OptimismBridgeDataNoToken {\n // interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n uint256 interfaceId;\n // currencyKey of the token beingBridged\n bytes32 currencyKey;\n // socket offchain created hash\n bytes32 metadata;\n // address of receiver of bridged tokens\n address receiverAddress;\n /**\n * OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n */\n address customBridgeAddress;\n // Gas limit required to complete the deposit on L2.\n uint32 l2Gas;\n // Address of the L1 respective L2 ERC20\n address l2Token;\n // additional data , for ll contracts this will be 0x data or empty data\n bytes data;\n }\n\n struct OptimismBridgeData {\n // interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n uint256 interfaceId;\n // currencyKey of the token beingBridged\n bytes32 currencyKey;\n // socket offchain created hash\n bytes32 metadata;\n // address of receiver of bridged tokens\n address receiverAddress;\n /**\n * OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n */\n address customBridgeAddress;\n /// @notice address of token being bridged\n address token;\n // Gas limit required to complete the deposit on L2.\n uint32 l2Gas;\n // Address of the L1 respective L2 ERC20\n address l2Token;\n // additional data , for ll contracts this will be 0x data or empty data\n bytes data;\n }\n\n struct OptimismERC20Data {\n bytes32 currencyKey;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in OptimismBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Optimism-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n OptimismBridgeData memory optimismBridgeData = abi.decode(\n bridgeData,\n (OptimismBridgeData)\n );\n\n emit SocketBridge(\n amount,\n optimismBridgeData.token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n optimismBridgeData.receiverAddress,\n optimismBridgeData.metadata\n );\n if (optimismBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositETHTo{value: amount}(\n optimismBridgeData.receiverAddress,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n } else {\n if (optimismBridgeData.interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20(optimismBridgeData.token).safeApprove(\n optimismBridgeData.customBridgeAddress,\n amount\n );\n\n if (optimismBridgeData.interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositERC20To(\n optimismBridgeData.token,\n optimismBridgeData.l2Token,\n optimismBridgeData.receiverAddress,\n amount,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (optimismBridgeData.interfaceId == 2) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .depositTo(optimismBridgeData.receiverAddress, amount);\n return;\n }\n\n if (optimismBridgeData.interfaceId == 3) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .initiateSynthTransfer(\n optimismBridgeData.currencyKey,\n optimismBridgeData.receiverAddress,\n amount\n );\n return;\n }\n }\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in OptimismBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param optimismBridgeData encoded data for OptimismBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n OptimismBridgeDataNoToken calldata optimismBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n emit SocketBridge(\n bridgeAmount,\n token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n optimismBridgeData.receiverAddress,\n optimismBridgeData.metadata\n );\n if (token == NATIVE_TOKEN_ADDRESS) {\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositETHTo{value: bridgeAmount}(\n optimismBridgeData.receiverAddress,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n } else {\n if (optimismBridgeData.interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20(token).safeApprove(\n optimismBridgeData.customBridgeAddress,\n bridgeAmount\n );\n\n if (optimismBridgeData.interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(optimismBridgeData.customBridgeAddress)\n .depositERC20To(\n token,\n optimismBridgeData.l2Token,\n optimismBridgeData.receiverAddress,\n bridgeAmount,\n optimismBridgeData.l2Gas,\n optimismBridgeData.data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (optimismBridgeData.interfaceId == 2) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .depositTo(\n optimismBridgeData.receiverAddress,\n bridgeAmount\n );\n return;\n }\n\n if (optimismBridgeData.interfaceId == 3) {\n OldL1TokenGateway(optimismBridgeData.customBridgeAddress)\n .initiateSynthTransfer(\n optimismBridgeData.currencyKey,\n optimismBridgeData.receiverAddress,\n bridgeAmount\n );\n return;\n }\n }\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via NativeOptimism-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param receiverAddress address of receiver of bridged tokens\n * @param customBridgeAddress OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n * @param l2Gas Gas limit required to complete the deposit on L2.\n * @param optimismData extra data needed for optimism bridge\n * @param amount amount being bridged\n * @param interfaceId interfaceId to be set offchain which is used to select one of the 3 kinds of bridging (standard bridge / old standard / synthetic)\n * @param l2Token Address of the L1 respective L2 ERC20\n * @param data additional data , for ll contracts this will be 0x data or empty data\n */\n function bridgeERC20To(\n address token,\n address receiverAddress,\n address customBridgeAddress,\n uint32 l2Gas,\n OptimismERC20Data calldata optimismData,\n uint256 amount,\n uint256 interfaceId,\n address l2Token,\n bytes calldata data\n ) external payable {\n if (interfaceId == 0) {\n revert UnsupportedInterfaceId();\n }\n\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(customBridgeAddress, amount);\n\n emit SocketBridge(\n amount,\n token,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n receiverAddress,\n optimismData.metadata\n );\n if (interfaceId == 1) {\n // deposit into standard bridge\n L1StandardBridge(customBridgeAddress).depositERC20To(\n token,\n l2Token,\n receiverAddress,\n amount,\n l2Gas,\n data\n );\n return;\n }\n\n // Deposit Using Old Standard - iOVM_L1TokenGateway(Example - SNX Token)\n if (interfaceId == 2) {\n OldL1TokenGateway(customBridgeAddress).depositTo(\n receiverAddress,\n amount\n );\n return;\n }\n\n if (interfaceId == 3) {\n OldL1TokenGateway(customBridgeAddress).initiateSynthTransfer(\n optimismData.currencyKey,\n receiverAddress,\n amount\n );\n return;\n }\n }\n\n /**\n * @notice function to handle native balance bridging to receipent via NativeOptimism-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of receiver of bridged tokens\n * @param customBridgeAddress OptimismBridge that Performs the logic for deposits by informing the L2 Deposited Token\n * contract of the deposit and calling a handler to lock the L1 funds. (e.g. transferFrom)\n * @param l2Gas Gas limit required to complete the deposit on L2.\n * @param amount amount being bridged\n * @param data additional data , for ll contracts this will be 0x data or empty data\n */\n function bridgeNativeTo(\n address receiverAddress,\n address customBridgeAddress,\n uint32 l2Gas,\n uint256 amount,\n bytes32 metadata,\n bytes calldata data\n ) external payable {\n L1StandardBridge(customBridgeAddress).depositETHTo{value: amount}(\n receiverAddress,\n l2Gas,\n data\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n DESTINATION_CHAIN_ID,\n NativeOptimismIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/deployFactory/SocketDeployFactory.sol":{"content":"//SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketBridgeBase} from \"../interfaces/ISocketBridgeBase.sol\";\n\n/**\n * @dev In the constructor, set up the initialization code for socket\n * contracts as well as the keccak256 hash of the given initialization code.\n * that will be used to deploy any transient contracts, which will deploy any\n * socket contracts that require the use of a constructor.\n *\n * Socket contract initialization code (29 bytes):\n *\n * 0x5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\n *\n * Description:\n *\n * pc|op|name | [stack] | \n *\n * ** set the first stack item to zero - used later **\n * 00 58 getpc [0] <>\n *\n * ** set second stack item to 32, length of word returned from staticcall **\n * 01 60 push1\n * 02 20 outsize [0, 32] <>\n *\n * ** set third stack item to 0, position of word returned from staticcall **\n * 03 81 dup2 [0, 32, 0] <>\n *\n * ** set fourth stack item to 4, length of selector given to staticcall **\n * 04 58 getpc [0, 32, 0, 4] <>\n *\n * ** set fifth stack item to 28, position of selector given to staticcall **\n * 05 60 push1\n * 06 1c inpos [0, 32, 0, 4, 28] <>\n *\n * ** set the sixth stack item to msg.sender, target address for staticcall **\n * 07 33 caller [0, 32, 0, 4, 28, caller] <>\n *\n * ** set the seventh stack item to msg.gas, gas to forward for staticcall **\n * 08 5a gas [0, 32, 0, 4, 28, caller, gas] <>\n *\n * ** set the eighth stack item to selector, \"what\" to store via mstore **\n * 09 63 push4\n * 10 aaf10f42 selector [0, 32, 0, 4, 28, caller, gas, 0xaaf10f42] <>\n *\n * ** set the ninth stack item to 0, \"where\" to store via mstore ***\n * 11 87 dup8 [0, 32, 0, 4, 28, caller, gas, 0xaaf10f42, 0] <>\n *\n * ** call mstore, consume 8 and 9 from the stack, place selector in memory **\n * 12 52 mstore [0, 32, 0, 4, 0, caller, gas] <0xaaf10f42>\n *\n * ** call staticcall, consume items 2 through 7, place address in memory **\n * 13 fa staticcall [0, 1 (if successful)]
\n *\n * ** flip success bit in second stack item to set to 0 **\n * 14 15 iszero [0, 0]
\n *\n * ** push a third 0 to the stack, position of address in memory **\n * 15 81 dup2 [0, 0, 0]
\n *\n * ** place address from position in memory onto third stack item **\n * 16 51 mload [0, 0, address] <>\n *\n * ** place address to fourth stack item for extcodesize to consume **\n * 17 80 dup1 [0, 0, address, address] <>\n *\n * ** get extcodesize on fourth stack item for extcodecopy **\n * 18 3b extcodesize [0, 0, address, size] <>\n *\n * ** dup and swap size for use by return at end of init code **\n * 19 80 dup1 [0, 0, address, size, size] <>\n * 20 93 swap4 [size, 0, address, size, 0] <>\n *\n * ** push code position 0 to stack and reorder stack items for extcodecopy **\n * 21 80 dup1 [size, 0, address, size, 0, 0] <>\n * 22 91 swap2 [size, 0, address, 0, 0, size] <>\n * 23 92 swap3 [size, 0, size, 0, 0, address] <>\n *\n * ** call extcodecopy, consume four items, clone runtime code to memory **\n * 24 3c extcodecopy [size, 0] \n *\n * ** return to deploy final code in memory **\n * 25 f3 return [] *deployed!*\n */\ncontract SocketDeployFactory is Ownable {\n using SafeTransferLib for ERC20;\n address public immutable disabledRouteAddress;\n\n mapping(address => address) _implementations;\n mapping(uint256 => bool) isDisabled;\n mapping(uint256 => bool) isRouteDeployed;\n mapping(address => bool) canDisableRoute;\n\n event Deployed(address _addr);\n event DisabledRoute(address _addr);\n event Destroyed(address _addr);\n error ContractAlreadyDeployed();\n error NothingToDestroy();\n error AlreadyDisabled();\n error CannotBeDisabled();\n error OnlyDisabler();\n\n constructor(address _owner, address disabledRoute) Ownable(_owner) {\n disabledRouteAddress = disabledRoute;\n canDisableRoute[_owner] = true;\n }\n\n modifier onlyDisabler() {\n if (!canDisableRoute[msg.sender]) {\n revert OnlyDisabler();\n }\n _;\n }\n\n function addDisablerAddress(address disabler) external onlyOwner {\n canDisableRoute[disabler] = true;\n }\n\n function removeDisablerAddress(address disabler) external onlyOwner {\n canDisableRoute[disabler] = false;\n }\n\n /**\n * @notice Deploys a route contract at predetermined location\n * @notice Caller must first deploy the route contract at another location and pass its address as implementation.\n * @param routeId route identifier\n * @param implementationContract address of deployed route contract. Its byte code will be copied to predetermined location.\n */\n function deploy(\n uint256 routeId,\n address implementationContract\n ) external onlyOwner returns (address) {\n // assign the initialization code for the socket contract.\n\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (isRouteDeployed[routeId]) {\n revert ContractAlreadyDeployed();\n }\n\n isRouteDeployed[routeId] = true;\n\n //first we deploy the code we want to deploy on a separate address\n // store the implementation to be retrieved by the socket contract.\n _implementations[routeContractAddress] = implementationContract;\n address addr;\n assembly {\n let encoded_data := add(0x20, initCode) // load initialization code.\n let encoded_size := mload(initCode) // load init code's length.\n addr := create2(0, encoded_data, encoded_size, routeId) // routeId is used as salt\n }\n require(\n addr == routeContractAddress,\n \"Failed to deploy the new socket contract.\"\n );\n emit Deployed(addr);\n return addr;\n }\n\n /**\n * @notice Destroy the route deployed at a location.\n * @param routeId route identifier to be destroyed.\n */\n function destroy(uint256 routeId) external onlyDisabler {\n // determine the address of the socket contract.\n _destroy(routeId);\n }\n\n /**\n * @notice Deploy a disabled contract at destroyed route to handle it gracefully.\n * @param routeId route identifier to be disabled.\n */\n function disableRoute(\n uint256 routeId\n ) external onlyDisabler returns (address) {\n return _disableRoute(routeId);\n }\n\n /**\n * @notice Destroy a list of routeIds\n * @param routeIds array of routeIds to be destroyed.\n */\n function multiDestroy(uint256[] calldata routeIds) external onlyDisabler {\n for (uint32 index = 0; index < routeIds.length; ) {\n _destroy(routeIds[index]);\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Deploy a disabled contract at list of routeIds.\n * @param routeIds array of routeIds to be disabled.\n */\n function multiDisableRoute(\n uint256[] calldata routeIds\n ) external onlyDisabler {\n for (uint32 index = 0; index < routeIds.length; ) {\n _disableRoute(routeIds[index]);\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @dev External view function for calculating a socket contract address\n * given a particular routeId.\n */\n function getContractAddress(\n uint256 routeId\n ) external view returns (address) {\n // determine the address of the socket contract.\n return _getContractAddress(routeId);\n }\n\n //those two functions are getting called by the socket Contract\n function getImplementation()\n external\n view\n returns (address implementation)\n {\n return _implementations[msg.sender];\n }\n\n function _disableRoute(uint256 routeId) internal returns (address) {\n // assign the initialization code for the socket contract.\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (!isRouteDeployed[routeId]) {\n revert CannotBeDisabled();\n }\n\n if (isDisabled[routeId]) {\n revert AlreadyDisabled();\n }\n\n isDisabled[routeId] = true;\n\n //first we deploy the code we want to deploy on a separate address\n // store the implementation to be retrieved by the socket contract.\n _implementations[routeContractAddress] = disabledRouteAddress;\n address addr;\n assembly {\n let encoded_data := add(0x20, initCode) // load initialization code.\n let encoded_size := mload(initCode) // load init code's length.\n addr := create2(0, encoded_data, encoded_size, routeId) // routeId is used as salt.\n }\n require(\n addr == routeContractAddress,\n \"Failed to deploy the new socket contract.\"\n );\n emit Deployed(addr);\n return addr;\n }\n\n function _destroy(uint256 routeId) internal {\n // determine the address of the socket contract.\n address routeContractAddress = _getContractAddress(routeId);\n\n if (!isRouteDeployed[routeId]) {\n revert NothingToDestroy();\n }\n ISocketBridgeBase(routeContractAddress).killme();\n emit Destroyed(routeContractAddress);\n }\n\n /**\n * @dev Internal view function for calculating a socket contract address\n * given a particular routeId.\n */\n function _getContractAddress(\n uint256 routeId\n ) internal view returns (address) {\n // determine the address of the socket contract.\n\n bytes memory initCode = (\n hex\"5860208158601c335a63aaf10f428752fa158151803b80938091923cf3\"\n );\n return\n address(\n uint160( // downcast to match the address type.\n uint256( // convert to uint to truncate upper digits.\n keccak256( // compute the CREATE2 hash using 4 inputs.\n abi.encodePacked( // pack all inputs to the hash together.\n hex\"ff\", // start with 0xff to distinguish from RLP.\n address(this), // this contract will be the caller.\n routeId, // the routeId is used as salt.\n keccak256(abi.encodePacked(initCode)) // the init code hash.\n )\n )\n )\n )\n );\n }\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n}\n"},"src/interfaces/ISocketController.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketController\n * @notice Interface for SocketController functions.\n * @dev functions can be added here for invocation from external contracts or off-chain\n * only restriction is that this should have functions to manage controllers\n * @author Socket dot tech.\n */\ninterface ISocketController {\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param _controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address _controllerAddress\n ) external returns (uint32);\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param _controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 _controllerId) external;\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param _controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 _controllerId) external returns (address);\n}\n"},"lib/solmate/src/utils/SafeTransferLib.sol":{"content":"// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n"},"src/controllers/BaseController.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\n\n/// @title BaseController Controller\n/// @notice Base contract for all controller contracts\nabstract contract BaseController {\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice Address used to identify if it is a Zero address\n address public immutable NULL_ADDRESS = address(0);\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGatewayAddress;\n\n /// @notice immutable variable with instance of SocketRoute to access route functions\n ISocketRoute public immutable socketRoute;\n\n /**\n * @notice Construct the base for all controllers.\n * @param _socketGatewayAddress Socketgateway address, an immutable variable to set.\n * @notice initialize the immutable variables of SocketRoute, SocketGateway\n */\n constructor(address _socketGatewayAddress) {\n socketGatewayAddress = _socketGatewayAddress;\n socketRoute = ISocketRoute(_socketGatewayAddress);\n }\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param routeId routeId mapped to the routrImplementation\n * @param data transactionData generated with arguments of bridgeRequest (offchain or by caller)\n * @return returns the bytes response of the route execution (bridging, refuel or swap executions)\n */\n function _executeRoute(\n uint32 routeId,\n bytes memory data\n ) internal returns (bytes memory) {\n (bool success, bytes memory result) = socketRoute\n .getRoute(routeId)\n .delegatecall(data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n}\n"},"src/interfaces/ISocketRoute.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketRoute\n * @notice Interface for routeManagement functions in SocketGateway.\n * @author Socket dot tech.\n */\ninterface ISocketRoute {\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(address routeAddress) external returns (uint256);\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external;\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) external view returns (address);\n}\n"},"src/SocketGatewayDeployment.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\npragma experimental ABIEncoderV2;\n\nimport \"./utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {LibUtil} from \"./libraries/LibUtil.sol\";\nimport \"./libraries/LibBytes.sol\";\nimport {ISocketRoute} from \"./interfaces/ISocketRoute.sol\";\nimport {ISocketRequest} from \"./interfaces/ISocketRequest.sol\";\nimport {ISocketGateway} from \"./interfaces/ISocketGateway.sol\";\nimport {IncorrectBridgeRatios, ZeroAddressNotAllowed, ArrayLengthMismatch} from \"./errors/SocketErrors.sol\";\n\n/// @title SocketGatewayContract\n/// @notice Socketgateway is a contract with entrypoint functions for all interactions with socket liquidity layer\n/// @author Socket Team\ncontract SocketGateway is Ownable {\n using LibBytes for bytes;\n using LibBytes for bytes4;\n using SafeTransferLib for ERC20;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice storage variable to keep track of total number of routes registered in socketgateway\n uint32 public routesCount = 385;\n\n /// @notice storage variable to keep track of total number of controllers registered in socketgateway\n uint32 public controllerCount;\n\n address public immutable disabledRouteAddress;\n\n uint256 public constant CENT_PERCENT = 100e18;\n\n /// @notice storage mapping for route implementation addresses\n mapping(uint32 => address) public routes;\n\n /// storage mapping for controller implemenation addresses\n mapping(uint32 => address) public controllers;\n\n // Events ------------------------------------------------------------------------------------------------------->\n\n /// @notice Event emitted when a router is added to socketgateway\n event NewRouteAdded(uint32 indexed routeId, address indexed route);\n\n /// @notice Event emitted when a route is disabled\n event RouteDisabled(uint32 indexed routeId);\n\n /// @notice Event emitted when ownership transfer is requested by socket-gateway-owner\n event OwnershipTransferRequested(\n address indexed _from,\n address indexed _to\n );\n\n /// @notice Event emitted when a controller is added to socketgateway\n event ControllerAdded(\n uint32 indexed controllerId,\n address indexed controllerAddress\n );\n\n /// @notice Event emitted when a controller is disabled\n event ControllerDisabled(uint32 indexed controllerId);\n\n constructor(address _owner, address _disabledRoute) Ownable(_owner) {\n disabledRouteAddress = _disabledRoute;\n }\n\n // Able to receive ether\n // solhint-disable-next-line no-empty-blocks\n receive() external payable {}\n\n /*******************************************\n * EXTERNAL AND PUBLIC FUNCTIONS *\n *******************************************/\n\n /**\n * @notice executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in routeData to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeId route identifier\n * @param routeData functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoute(\n uint32 routeId,\n bytes calldata routeData\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = addressAt(routeId).delegatecall(\n routeData\n );\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice swaps a token on sourceChain and split it across multiple bridge-recipients\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being swapped\n * @dev ensure the swap-data and bridge-data is generated using the function-selector defined as a constant in the implementation address\n * @param swapMultiBridgeRequest request\n */\n function swapAndMultiBridge(\n ISocketRequest.SwapMultiBridgeRequest calldata swapMultiBridgeRequest\n ) external payable {\n uint256 requestLength = swapMultiBridgeRequest.bridgeRouteIds.length;\n\n if (\n requestLength != swapMultiBridgeRequest.bridgeImplDataItems.length\n ) {\n revert ArrayLengthMismatch();\n }\n uint256 ratioAggregate;\n for (uint256 index = 0; index < requestLength; ) {\n ratioAggregate += swapMultiBridgeRequest.bridgeRatios[index];\n }\n\n if (ratioAggregate != CENT_PERCENT) {\n revert IncorrectBridgeRatios();\n }\n\n (bool swapSuccess, bytes memory swapResult) = addressAt(\n swapMultiBridgeRequest.swapRouteId\n ).delegatecall(swapMultiBridgeRequest.swapImplData);\n\n if (!swapSuccess) {\n assembly {\n revert(add(swapResult, 32), mload(swapResult))\n }\n }\n\n uint256 amountReceivedFromSwap = abi.decode(swapResult, (uint256));\n\n uint256 bridgedAmount;\n\n for (uint256 index = 0; index < requestLength; ) {\n uint256 bridgingAmount;\n\n // if it is the last bridge request, bridge the remaining amount\n if (index == requestLength - 1) {\n bridgingAmount = amountReceivedFromSwap - bridgedAmount;\n } else {\n // bridging amount is the multiplication of bridgeRatio and amountReceivedFromSwap\n bridgingAmount =\n (amountReceivedFromSwap *\n swapMultiBridgeRequest.bridgeRatios[index]) /\n (CENT_PERCENT);\n }\n\n // update the bridged amount, this would be used for computation for last bridgeRequest\n bridgedAmount += bridgingAmount;\n\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n bridgingAmount,\n swapMultiBridgeRequest.bridgeImplDataItems[index]\n );\n\n (bool bridgeSuccess, bytes memory bridgeResult) = addressAt(\n swapMultiBridgeRequest.bridgeRouteIds[index]\n ).delegatecall(bridgeImpldata);\n\n if (!bridgeSuccess) {\n assembly {\n revert(add(bridgeResult, 32), mload(bridgeResult))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice sequentially executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each dataItem to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeIds a list of route identifiers\n * @param dataItems a list of functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoutes(\n uint32[] calldata routeIds,\n bytes[] calldata dataItems\n ) external payable {\n uint256 routeIdslength = routeIds.length;\n if (routeIdslength != dataItems.length) revert ArrayLengthMismatch();\n for (uint256 index = 0; index < routeIdslength; ) {\n (bool success, bytes memory result) = addressAt(routeIds[index])\n .delegatecall(dataItems[index]);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice execute a controller function identified using the controllerId in the request\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param socketControllerRequest socketControllerRequest with controllerId to identify the\n * controllerAddress and byteData constructed using functionSelector\n * of the function being invoked\n * @return bytes data received from the call delegated to controller\n */\n function executeController(\n ISocketGateway.SocketControllerRequest calldata socketControllerRequest\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = controllers[\n socketControllerRequest.controllerId\n ].delegatecall(socketControllerRequest.data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice sequentially executes all controller requests\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each controller-request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param controllerRequests a list of socketControllerRequest\n * Each controllerRequest contains controllerId to identify the controllerAddress and\n * byteData constructed using functionSelector of the function being invoked\n */\n function executeControllers(\n ISocketGateway.SocketControllerRequest[] calldata controllerRequests\n ) external payable {\n for (uint32 index = 0; index < controllerRequests.length; ) {\n (bool success, bytes memory result) = controllers[\n controllerRequests[index].controllerId\n ].delegatecall(controllerRequests[index].data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**************************************\n * ADMIN FUNCTIONS *\n **************************************/\n\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(\n address routeAddress\n ) external onlyOwner returns (uint32) {\n uint32 routeId = routesCount;\n routes[routeId] = routeAddress;\n\n routesCount += 1;\n\n emit NewRouteAdded(routeId, routeAddress);\n\n return routeId;\n }\n\n /**\n * @notice Give Infinite or 0 approval to bridgeRoute for the tokenAddress\n This is a restricted function to be called by only socketGatewayOwner\n */\n\n function setApprovalForRouters(\n address[] memory routeAddresses,\n address[] memory tokenAddresses,\n bool isMax\n ) external onlyOwner {\n for (uint32 index = 0; index < routeAddresses.length; ) {\n ERC20(tokenAddresses[index]).approve(\n routeAddresses[index],\n isMax ? type(uint256).max : 0\n );\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address controllerAddress\n ) external onlyOwner returns (uint32) {\n uint32 controllerId = controllerCount;\n\n controllers[controllerId] = controllerAddress;\n\n controllerCount += 1;\n\n emit ControllerAdded(controllerId, controllerAddress);\n\n return controllerId;\n }\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 controllerId) public onlyOwner {\n controllers[controllerId] = disabledRouteAddress;\n emit ControllerDisabled(controllerId);\n }\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external onlyOwner {\n routes[routeId] = disabledRouteAddress;\n emit RouteDisabled(routeId);\n }\n\n /*******************************************\n * RESTRICTED RESCUE FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n\n /*******************************************\n * VIEW FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) public view returns (address) {\n return addressAt(routeId);\n }\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 controllerId) public view returns (address) {\n return controllers[controllerId];\n }\n\n function addressAt(uint32 routeId) public view returns (address) {\n if (routeId < 385) {\n if (routeId < 257) {\n if (routeId < 129) {\n if (routeId < 65) {\n if (routeId < 33) {\n if (routeId < 17) {\n if (routeId < 9) {\n if (routeId < 5) {\n if (routeId < 3) {\n if (routeId == 1) {\n return\n 0x8cd6BaCDAe46B449E2e5B34e348A4eD459c84D50;\n } else {\n return\n 0x31524750Cd865fF6A3540f232754Fb974c18585C;\n }\n } else {\n if (routeId == 3) {\n return\n 0xEd9b37342BeC8f3a2D7b000732ec87498aA6EC6a;\n } else {\n return\n 0xE8704Ef6211F8988Ccbb11badC89841808d66890;\n }\n }\n } else {\n if (routeId < 7) {\n if (routeId == 5) {\n return\n 0x9aFF58C460a461578C433e11C4108D1c4cF77761;\n } else {\n return\n 0x2D1733886cFd465B0B99F1492F40847495f334C5;\n }\n } else {\n if (routeId == 7) {\n return\n 0x715497Be4D130F04B8442F0A1F7a9312D4e54FC4;\n } else {\n return\n 0x90C8a40c38E633B5B0e0d0585b9F7FA05462CaaF;\n }\n }\n }\n } else {\n if (routeId < 13) {\n if (routeId < 11) {\n if (routeId == 9) {\n return\n 0xa402b70FCfF3F4a8422B93Ef58E895021eAdE4F6;\n } else {\n return\n 0xc1B718522E15CD42C4Ac385a929fc2B51f5B892e;\n }\n } else {\n if (routeId == 11) {\n return\n 0xa97bf2f7c26C43c010c349F52f5eA5dC49B2DD38;\n } else {\n return\n 0x969423d71b62C81d2f28d707364c9Dc4a0764c53;\n }\n }\n } else {\n if (routeId < 15) {\n if (routeId == 13) {\n return\n 0xF86729934C083fbEc8C796068A1fC60701Ea1207;\n } else {\n return\n 0xD7cC2571F5823caCA26A42690D2BE7803DD5393f;\n }\n } else {\n if (routeId == 15) {\n return\n 0x7c8837a279bbbf7d8B93413763176de9F65d5bB9;\n } else {\n return\n 0x13b81C27B588C07D04458ed7dDbdbD26D1e39bcc;\n }\n }\n }\n }\n } else {\n if (routeId < 25) {\n if (routeId < 21) {\n if (routeId < 19) {\n if (routeId == 17) {\n return\n 0x52560Ac678aFA1345D15474287d16Dc1eA3F78aE;\n } else {\n return\n 0x1E31e376551459667cd7643440c1b21CE69065A0;\n }\n } else {\n if (routeId == 19) {\n return\n 0xc57D822CB3288e7b97EF8f8af0EcdcD1B783529B;\n } else {\n return\n 0x2197A1D9Af24b4d6a64Bff95B4c29Fcd3Ff28C30;\n }\n }\n } else {\n if (routeId < 23) {\n if (routeId == 21) {\n return\n 0xE3700feAa5100041Bf6b7AdBA1f72f647809Fd00;\n } else {\n return\n 0xc02E8a0Fdabf0EeFCEA025163d90B5621E2b9948;\n }\n } else {\n if (routeId == 23) {\n return\n 0xF5144235E2926cAb3c69b30113254Fa632f72d62;\n } else {\n return\n 0xBa3F92313B00A1f7Bc53b2c24EB195c8b2F57682;\n }\n }\n }\n } else {\n if (routeId < 29) {\n if (routeId < 27) {\n if (routeId == 25) {\n return\n 0x77a6856fe1fFA5bEB55A1d2ED86E27C7c482CB76;\n } else {\n return\n 0x4826Ff4e01E44b1FCEFBfb38cd96687Eb7786b44;\n }\n } else {\n if (routeId == 27) {\n return\n 0x55FF3f5493cf5e80E76DEA7E327b9Cd8440Af646;\n } else {\n return\n 0xF430Db544bE9770503BE4aa51997aA19bBd5BA4f;\n }\n }\n } else {\n if (routeId < 31) {\n if (routeId == 29) {\n return\n 0x0f166446ce1484EE3B0663E7E67DF10F5D240115;\n } else {\n return\n 0x6365095D92537f242Db5EdFDd572745E72aC33d9;\n }\n } else {\n if (routeId == 31) {\n return\n 0x5c7BC93f06ce3eAe75ADf55E10e23d2c1dE5Bc65;\n } else {\n return\n 0xe46383bAD90d7A08197ccF08972e9DCdccCE9BA4;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 49) {\n if (routeId < 41) {\n if (routeId < 37) {\n if (routeId < 35) {\n if (routeId == 33) {\n return\n 0xf0f21710c071E3B728bdc4654c3c0b873aAaa308;\n } else {\n return\n 0x63Bc9ed3AcAAeB0332531C9fB03b0a2352E9Ff25;\n }\n } else {\n if (routeId == 35) {\n return\n 0xd1CE808625CB4007a1708824AE82CdB0ece57De9;\n } else {\n return\n 0x57BbB148112f4ba224841c3FE018884171004661;\n }\n }\n } else {\n if (routeId < 39) {\n if (routeId == 37) {\n return\n 0x037f7d6933036F34DFabd40Ff8e4D789069f92e3;\n } else {\n return\n 0xeF978c280915CfF3Dca4EDfa8932469e40ADA1e1;\n }\n } else {\n if (routeId == 39) {\n return\n 0x92ee9e071B13f7ecFD62B7DED404A16CBc223CD3;\n } else {\n return\n 0x94Ae539c186e41ed762271338Edf140414D1E442;\n }\n }\n }\n } else {\n if (routeId < 45) {\n if (routeId < 43) {\n if (routeId == 41) {\n return\n 0x30A64BBe4DdBD43dA2368EFd1eB2d80C10d84DAb;\n } else {\n return\n 0x3aEABf81c1Dc4c1b73d5B2a95410f126426FB596;\n }\n } else {\n if (routeId == 43) {\n return\n 0x25b08aB3D0C8ea4cC9d967b79688C6D98f3f563a;\n } else {\n return\n 0xea40cB15C9A3BBd27af6474483886F7c0c9AE406;\n }\n }\n } else {\n if (routeId < 47) {\n if (routeId == 45) {\n return\n 0x9580113Cc04e5a0a03359686304EF3A80b936Dd3;\n } else {\n return\n 0xD211c826d568957F3b66a3F4d9c5f68cCc66E619;\n }\n } else {\n if (routeId == 47) {\n return\n 0xCEE24D0635c4C56315d133b031984d4A6f509476;\n } else {\n return\n 0x3922e6B987983229798e7A20095EC372744d4D4c;\n }\n }\n }\n }\n } else {\n if (routeId < 57) {\n if (routeId < 53) {\n if (routeId < 51) {\n if (routeId == 49) {\n return\n 0x2d92D03413d296e1F31450479349757187F2a2b7;\n } else {\n return\n 0x0fe5308eE90FC78F45c89dB6053eA859097860CA;\n }\n } else {\n if (routeId == 51) {\n return\n 0x08Ba68e067C0505bAF0C1311E0cFB2B1B59b969c;\n } else {\n return\n 0x9bee5DdDF75C24897374f92A534B7A6f24e97f4a;\n }\n }\n } else {\n if (routeId < 55) {\n if (routeId == 53) {\n return\n 0x1FC5A90B232208704B930c1edf82FFC6ACc02734;\n } else {\n return\n 0x5b1B0417cb44c761C2a23ee435d011F0214b3C85;\n }\n } else {\n if (routeId == 55) {\n return\n 0x9d70cDaCA12A738C283020760f449D7816D592ec;\n } else {\n return\n 0x95a23b9CB830EcCFDDD5dF56A4ec665e3381Fa12;\n }\n }\n }\n } else {\n if (routeId < 61) {\n if (routeId < 59) {\n if (routeId == 57) {\n return\n 0x483a957Cf1251c20e096C35c8399721D1200A3Fc;\n } else {\n return\n 0xb4AD39Cb293b0Ec7FEDa743442769A7FF04987CD;\n }\n } else {\n if (routeId == 59) {\n return\n 0x4C543AD78c1590D81BAe09Fc5B6Df4132A2461d0;\n } else {\n return\n 0x471d5E5195c563902781734cfe1FF3981F8B6c86;\n }\n }\n } else {\n if (routeId < 63) {\n if (routeId == 61) {\n return\n 0x1B12a54B5E606D95B8B8D123c9Cb09221Ee37584;\n } else {\n return\n 0xE4127cC550baC433646a7D998775a84daC16c7f3;\n }\n } else {\n if (routeId == 63) {\n return\n 0xecb1b55AB12E7dd788D585c6C5cD61B5F87be836;\n } else {\n return\n 0xf91ef487C5A1579f70601b6D347e19756092eEBf;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 97) {\n if (routeId < 81) {\n if (routeId < 73) {\n if (routeId < 69) {\n if (routeId < 67) {\n if (routeId == 65) {\n return\n 0x34a16a7e9BADEEFD4f056310cbE0b1423Fa1b760;\n } else {\n return\n 0x60E10E80c7680f429dBbC232830BEcd3D623c4CF;\n }\n } else {\n if (routeId == 67) {\n return\n 0x66465285B8D65362A1d86CE00fE2bE949Fd6debF;\n } else {\n return\n 0x5aB231B7e1A3A74a48f67Ab7bde5Cdd4267022E0;\n }\n }\n } else {\n if (routeId < 71) {\n if (routeId == 69) {\n return\n 0x3A1C3633eE79d43366F5c67802a746aFD6b162Ba;\n } else {\n return\n 0x0C4BfCbA8dC3C811437521a80E81e41DAF479039;\n }\n } else {\n if (routeId == 71) {\n return\n 0x6caf25d2e139C5431a1FA526EAf8d73ff2e6252C;\n } else {\n return\n 0x74ad21e09FDa68638CE14A3009A79B6D16574257;\n }\n }\n }\n } else {\n if (routeId < 77) {\n if (routeId < 75) {\n if (routeId == 73) {\n return\n 0xD4923A61008894b99cc1CD3407eF9524f02aA0Ca;\n } else {\n return\n 0x6F159b5EB823BD415886b9271aA2A723a00a1987;\n }\n } else {\n if (routeId == 75) {\n return\n 0x742a8aA42E7bfB4554dE30f4Fb07FFb6f2068863;\n } else {\n return\n 0x4AE9702d3360400E47B446e76DE063ACAb930101;\n }\n }\n } else {\n if (routeId < 79) {\n if (routeId == 77) {\n return\n 0x0E19a0a44ddA7dAD854ec5Cc867d16869c4E80F4;\n } else {\n return\n 0xE021A51968f25148F726E326C88d2556c5647557;\n }\n } else {\n if (routeId == 79) {\n return\n 0x64287BDDDaeF4d94E4599a3D882bed29E6Ada4B6;\n } else {\n return\n 0xcBB57Fd2e19cc7e9D444d5b4325A2F1047d0C73f;\n }\n }\n }\n }\n } else {\n if (routeId < 89) {\n if (routeId < 85) {\n if (routeId < 83) {\n if (routeId == 81) {\n return\n 0x373DE80DF7D82cFF6D76F29581b360C56331e957;\n } else {\n return\n 0x0466356E131AD61596a51F86BAd1C03A328960D8;\n }\n } else {\n if (routeId == 83) {\n return\n 0x01726B960992f1b74311b248E2a922fC707d43A6;\n } else {\n return\n 0x2E21bdf9A4509b89795BCE7E132f248a75814CEc;\n }\n }\n } else {\n if (routeId < 87) {\n if (routeId == 85) {\n return\n 0x769512b23aEfF842379091d3B6E4B5456F631D42;\n } else {\n return\n 0xe7eD9be946a74Ec19325D39C6EEb57887ccB2B0D;\n }\n } else {\n if (routeId == 87) {\n return\n 0xc4D01Ec357c2b511d10c15e6b6974380F0E62e67;\n } else {\n return\n 0x5bC49CC9dD77bECF2fd3A3C55611e84E69AFa3AE;\n }\n }\n }\n } else {\n if (routeId < 93) {\n if (routeId < 91) {\n if (routeId == 89) {\n return\n 0x48bcD879954fA14e7DbdAeb56F79C1e9DDcb69ec;\n } else {\n return\n 0xE929bDde21b462572FcAA4de6F49B9D3246688D0;\n }\n } else {\n if (routeId == 91) {\n return\n 0x85Aae300438222f0e3A9Bc870267a5633A9438bd;\n } else {\n return\n 0x51f72E1096a81C55cd142d66d39B688C657f9Be8;\n }\n }\n } else {\n if (routeId < 95) {\n if (routeId == 93) {\n return\n 0x3A8a05BF68ac54B01E6C0f492abF97465F3d15f9;\n } else {\n return\n 0x145aA67133F0c2C36b9771e92e0B7655f0D59040;\n }\n } else {\n if (routeId == 95) {\n return\n 0xa030315d7DB11F9892758C9e7092D841e0ADC618;\n } else {\n return\n 0xdF1f8d81a3734bdDdEfaC6Ca1596E081e57c3044;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 113) {\n if (routeId < 105) {\n if (routeId < 101) {\n if (routeId < 99) {\n if (routeId == 97) {\n return\n 0xFF2833123B58aa05d04D7fb99f5FB768B2b435F8;\n } else {\n return\n 0xc8f09c1fD751C570233765f71b0e280d74e6e743;\n }\n } else {\n if (routeId == 99) {\n return\n 0x3026DA6Ceca2E5A57A05153653D9212FFAaA49d8;\n } else {\n return\n 0xdE68Ee703dE0D11f67B0cE5891cB4a903de6D160;\n }\n }\n } else {\n if (routeId < 103) {\n if (routeId == 101) {\n return\n 0xE23a7730e81FB4E87A6D0bd9f63EE77ac86C3DA4;\n } else {\n return\n 0x8b1DBe04aD76a7d8bC079cACd3ED4D99B897F4a0;\n }\n } else {\n if (routeId == 103) {\n return\n 0xBB227240FA459b69C6889B2b8cb1BE76F118061f;\n } else {\n return\n 0xC062b9b3f0dB28BB8afAfcD4d075729344114ffe;\n }\n }\n }\n } else {\n if (routeId < 109) {\n if (routeId < 107) {\n if (routeId == 105) {\n return\n 0x553188Aa45f5FDB83EC4Ca485982F8fC082480D1;\n } else {\n return\n 0x0109d83D746EaCb6d4014953D9E12d6ca85e330b;\n }\n } else {\n if (routeId == 107) {\n return\n 0x45B1bEd29812F5bf6711074ACD180B2aeB783AD9;\n } else {\n return\n 0xdA06eC8c19aea31D77F60299678Cba40E743e1aD;\n }\n }\n } else {\n if (routeId < 111) {\n if (routeId == 109) {\n return\n 0x3cC5235c97d975a9b4FD4501B3446c981ea3D855;\n } else {\n return\n 0xa1827267d6Bd989Ff38580aE3d9deff6Acf19163;\n }\n } else {\n if (routeId == 111) {\n return\n 0x3663CAA0433A3D4171b3581Cf2410702840A735A;\n } else {\n return\n 0x7575D0a7614F655BA77C74a72a43bbd4fA6246a3;\n }\n }\n }\n }\n } else {\n if (routeId < 121) {\n if (routeId < 117) {\n if (routeId < 115) {\n if (routeId == 113) {\n return\n 0x2516Defc18bc07089c5dAFf5eafD7B0EF64611E2;\n } else {\n return\n 0xfec5FF08E20fbc107a97Af2D38BD0025b84ee233;\n }\n } else {\n if (routeId == 115) {\n return\n 0x0FB5763a87242B25243e23D73f55945fE787523A;\n } else {\n return\n 0xe4C00db89678dBf8391f430C578Ca857Dd98aDE1;\n }\n }\n } else {\n if (routeId < 119) {\n if (routeId == 117) {\n return\n 0x8F2A22061F9F35E64f14523dC1A5f8159e6a21B7;\n } else {\n return\n 0x18e4b838ae966917E20E9c9c5Ad359cDD38303bB;\n }\n } else {\n if (routeId == 119) {\n return\n 0x61ACb1d3Dcb3e3429832A164Cc0fC9849fb75A4a;\n } else {\n return\n 0x7681e3c8e7A41DCA55C257cc0d1Ae757f5530E65;\n }\n }\n }\n } else {\n if (routeId < 125) {\n if (routeId < 123) {\n if (routeId == 121) {\n return\n 0x806a2AB9748C3D1DB976550890E3f528B7E8Faec;\n } else {\n return\n 0xBDb8A5DD52C2c239fbC31E9d43B763B0197028FF;\n }\n } else {\n if (routeId == 123) {\n return\n 0x474EC9203706010B9978D6bD0b105D36755e4848;\n } else {\n return\n 0x8dfd0D829b303F2239212E591a0F92a32880f36E;\n }\n }\n } else {\n if (routeId < 127) {\n if (routeId == 125) {\n return\n 0xad4BcE9745860B1adD6F1Bd34a916f050E4c82C2;\n } else {\n return\n 0xBC701115b9fe14bC8CC5934cdC92517173e308C4;\n }\n } else {\n if (routeId == 127) {\n return\n 0x0D1918d786Db8546a11aDeD475C98370E06f255E;\n } else {\n return\n 0xee44f57cD6936DB55B99163f3Df367B01EdA785a;\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 193) {\n if (routeId < 161) {\n if (routeId < 145) {\n if (routeId < 137) {\n if (routeId < 133) {\n if (routeId < 131) {\n if (routeId == 129) {\n return\n 0x63044521fe5a1e488D7eD419cD0e35b7C24F2aa7;\n } else {\n return\n 0x410085E73BD85e90d97b84A68C125aDB9F91f85b;\n }\n } else {\n if (routeId == 131) {\n return\n 0x7913fe97E07C7A397Ec274Ab1d4E2622C88EC5D1;\n } else {\n return\n 0x977f9fE93c064DCf54157406DaABC3a722e8184C;\n }\n }\n } else {\n if (routeId < 135) {\n if (routeId == 133) {\n return\n 0xCD2236468722057cFbbABad2db3DEA9c20d5B01B;\n } else {\n return\n 0x17c7287A491cf5Ff81E2678cF2BfAE4333F6108c;\n }\n } else {\n if (routeId == 135) {\n return\n 0x354D9a5Dbf96c71B79a265F03B595C6Fdc04dadd;\n } else {\n return\n 0xb4e409EB8e775eeFEb0344f9eee884cc7ed21c69;\n }\n }\n }\n } else {\n if (routeId < 141) {\n if (routeId < 139) {\n if (routeId == 137) {\n return\n 0xa1a3c4670Ad69D9be4ab2D39D1231FEC2a63b519;\n } else {\n return\n 0x4589A22199870729C1be5CD62EE93BeD858113E6;\n }\n } else {\n if (routeId == 139) {\n return\n 0x8E7b864dB26Bd6C798C38d4Ba36EbA0d6602cF11;\n } else {\n return\n 0xA2D17C7260a4CB7b9854e89Fc367E80E87872a2d;\n }\n }\n } else {\n if (routeId < 143) {\n if (routeId == 141) {\n return\n 0xC7F0EDf0A1288627b0432304918A75e9084CBD46;\n } else {\n return\n 0xE4B4EF1f9A4aBFEdB371fA7a6143993B15d4df25;\n }\n } else {\n if (routeId == 143) {\n return\n 0xfe3D84A2Ef306FEBb5452441C9BDBb6521666F6A;\n } else {\n return\n 0x8A12B6C64121920110aE58F7cd67DfEc21c6a4C3;\n }\n }\n }\n }\n } else {\n if (routeId < 153) {\n if (routeId < 149) {\n if (routeId < 147) {\n if (routeId == 145) {\n return\n 0x76c4d9aFC4717a2BAac4e5f26CccF02351f7a3DA;\n } else {\n return\n 0xd4719BA550E397aeAcca1Ad2201c1ba69024FAAf;\n }\n } else {\n if (routeId == 147) {\n return\n 0x9646126Ce025224d1682C227d915a386efc0A1Fb;\n } else {\n return\n 0x4DD8Af2E3F2044842f0247920Bc4BABb636915ea;\n }\n }\n } else {\n if (routeId < 151) {\n if (routeId == 149) {\n return\n 0x8e8a327183Af0cf8C2ece9F0ed547C42A160D409;\n } else {\n return\n 0x9D49614CaE1C685C71678CA6d8CDF7584bfd0740;\n }\n } else {\n if (routeId == 151) {\n return\n 0x5a00ef257394cbc31828d48655E3d39e9c11c93d;\n } else {\n return\n 0xC9a2751b38d3dDD161A41Ca0135C5C6c09EC1d56;\n }\n }\n }\n } else {\n if (routeId < 157) {\n if (routeId < 155) {\n if (routeId == 153) {\n return\n 0x7e1c261640a525C94Ca4f8c25b48CF754DD83590;\n } else {\n return\n 0x409Fe24ba6F6BD5aF31C1aAf8059b986A3158233;\n }\n } else {\n if (routeId == 155) {\n return\n 0x704Cf5BFDADc0f55fDBb53B6ed8B582E018A72A2;\n } else {\n return\n 0x3982bF65d7d6E77E3b6661cd6F6468c247512737;\n }\n }\n } else {\n if (routeId < 159) {\n if (routeId == 157) {\n return\n 0x3982b9f26FFD67a13Ee371e2C0a9Da338BA70E7f;\n } else {\n return\n 0x6D834AB385900c1f49055D098e90264077FbC4f2;\n }\n } else {\n if (routeId == 159) {\n return\n 0x11FE5F70779A094B7166B391e1Fb73d422eF4e4d;\n } else {\n return\n 0xD347e4E47280d21F13B73D89c6d16f867D50DD13;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 177) {\n if (routeId < 169) {\n if (routeId < 165) {\n if (routeId < 163) {\n if (routeId == 161) {\n return\n 0xb6035eDD53DDA28d8B69b4ae9836E40C80306CD7;\n } else {\n return\n 0x54c884e6f5C7CcfeCA990396c520C858c922b6CA;\n }\n } else {\n if (routeId == 163) {\n return\n 0x5eA93E240b083d686558Ed607BC013d88057cE46;\n } else {\n return\n 0x4C7131eE812De685cBe4e2cCb033d46ecD46612E;\n }\n }\n } else {\n if (routeId < 167) {\n if (routeId == 165) {\n return\n 0xc1a5Be9F0c33D8483801D702111068669f81fF91;\n } else {\n return\n 0x9E5fAb91455Be5E5b2C05967E73F456c8118B1Fc;\n }\n } else {\n if (routeId == 167) {\n return\n 0x3d9A05927223E0DC2F382831770405885e22F0d8;\n } else {\n return\n 0x6303A011fB6063f5B1681cb5a9938EA278dc6128;\n }\n }\n }\n } else {\n if (routeId < 173) {\n if (routeId < 171) {\n if (routeId == 169) {\n return\n 0xe9c60795c90C66797e4c8E97511eA07CdAda32bE;\n } else {\n return\n 0xD56cC98e69A1e13815818b466a8aA6163d84234A;\n }\n } else {\n if (routeId == 171) {\n return\n 0x47EbB9D36a6e40895316cD894E4860D774E2c531;\n } else {\n return\n 0xA5EB293629410065d14a7B1663A67829b0618292;\n }\n }\n } else {\n if (routeId < 175) {\n if (routeId == 173) {\n return\n 0x1b3B4C8146F939cE00899db8B3ddeF0062b7E023;\n } else {\n return\n 0x257Bbc11653625EbfB6A8587eF4f4FBe49828EB3;\n }\n } else {\n if (routeId == 175) {\n return\n 0x44cc979C01b5bB1eAC21301E73C37200dFD06F59;\n } else {\n return\n 0x2972fDF43352225D82754C0174Ff853819D1ef2A;\n }\n }\n }\n }\n } else {\n if (routeId < 185) {\n if (routeId < 181) {\n if (routeId < 179) {\n if (routeId == 177) {\n return\n 0x3e54144f032648A04D62d79f7B4b93FF3aC2333b;\n } else {\n return\n 0x444016102dB8adbE73C3B6703a1ea7F2f75A510D;\n }\n } else {\n if (routeId == 179) {\n return\n 0xac079143f98a6eb744Fde34541ebF243DF5B5dED;\n } else {\n return\n 0xAe9010767Fb112d29d35CEdfba2b372Ad7A308d3;\n }\n }\n } else {\n if (routeId < 183) {\n if (routeId == 181) {\n return\n 0xfE0BCcF9cCC2265D5fB3450743f17DfE57aE1e56;\n } else {\n return\n 0x04ED8C0545716119437a45386B1d691C63234C7D;\n }\n } else {\n if (routeId == 183) {\n return\n 0x636c14013e531A286Bc4C848da34585f0bB73d59;\n } else {\n return\n 0x2Fa67fc7ECC5cAA01C653d3BFeA98ecc5db9C42A;\n }\n }\n }\n } else {\n if (routeId < 189) {\n if (routeId < 187) {\n if (routeId == 185) {\n return\n 0x23e9a0FC180818aA872D2079a985217017E97bd9;\n } else {\n return\n 0x79A95c3Ef81b3ae64ee03A9D5f73e570495F164E;\n }\n } else {\n if (routeId == 187) {\n return\n 0xa7EA0E88F04a84ba0ad1E396cb07Fa3fDAD7dF6D;\n } else {\n return\n 0xd23cA1278a2B01a3C0Ca1a00d104b11c1Ebe6f42;\n }\n }\n } else {\n if (routeId < 191) {\n if (routeId == 189) {\n return\n 0x707bc4a9FA2E349AED5df4e9f5440C15aA9D14Bd;\n } else {\n return\n 0x7E290F2dd539Ac6CE58d8B4C2B944931a1fD3612;\n }\n } else {\n if (routeId == 191) {\n return\n 0x707AA5503088Ce06Ba450B6470A506122eA5c8eF;\n } else {\n return\n 0xFbB3f7BF680deeb149f4E7BC30eA3DDfa68F3C3f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 225) {\n if (routeId < 209) {\n if (routeId < 201) {\n if (routeId < 197) {\n if (routeId < 195) {\n if (routeId == 193) {\n return\n 0xDE74aD8cCC3dbF14992f49Cf24f36855912f4934;\n } else {\n return\n 0x409BA83df7777F070b2B50a10a41DE2468d2a3B3;\n }\n } else {\n if (routeId == 195) {\n return\n 0x5CB7Be90A5DD7CfDa54e87626e254FE8C18255B4;\n } else {\n return\n 0x0A684fE12BC64fb72B59d0771a566F49BC090356;\n }\n }\n } else {\n if (routeId < 199) {\n if (routeId == 197) {\n return\n 0xDf30048d91F8FA2bCfC54952B92bFA8e161D3360;\n } else {\n return\n 0x050825Fff032a547C47061CF0696FDB0f65AEa5D;\n }\n } else {\n if (routeId == 199) {\n return\n 0xd55e671dAC1f03d366d8535073ada5DB2Aab1Ea2;\n } else {\n return\n 0x9470C704A9616c8Cd41c595Fcd2181B6fe2183C2;\n }\n }\n }\n } else {\n if (routeId < 205) {\n if (routeId < 203) {\n if (routeId == 201) {\n return\n 0x2D9ffD275181F5865d5e11CbB4ced1521C4dF9f1;\n } else {\n return\n 0x816d28Dec10ec95DF5334f884dE85cA6215918d8;\n }\n } else {\n if (routeId == 203) {\n return\n 0xd1f87267c4A43835E666dd69Df077e578A3b6299;\n } else {\n return\n 0x39E89Bde9DACbe5468C025dE371FbDa12bDeBAB1;\n }\n }\n } else {\n if (routeId < 207) {\n if (routeId == 205) {\n return\n 0x7b40A3207956ecad6686E61EfcaC48912FcD0658;\n } else {\n return\n 0x090cF10D793B1Efba9c7D76115878814B663859A;\n }\n } else {\n if (routeId == 207) {\n return\n 0x312A59c06E41327878F2063eD0e9c282C1DA3AfC;\n } else {\n return\n 0x4F1188f46236DD6B5de11Ebf2a9fF08716E7DeB6;\n }\n }\n }\n }\n } else {\n if (routeId < 217) {\n if (routeId < 213) {\n if (routeId < 211) {\n if (routeId == 209) {\n return\n 0x0A6F9a3f4fA49909bBfb4339cbE12B42F53BbBeD;\n } else {\n return\n 0x01d13d7aCaCbB955B81935c80ffF31e14BdFa71f;\n }\n } else {\n if (routeId == 211) {\n return\n 0x691a14Fa6C7360422EC56dF5876f84d4eDD7f00A;\n } else {\n return\n 0x97Aad18d886d181a9c726B3B6aE15a0A69F5aF73;\n }\n }\n } else {\n if (routeId < 215) {\n if (routeId == 213) {\n return\n 0x2917241371D2099049Fa29432DC46735baEC33b4;\n } else {\n return\n 0x5F20F20F7890c2e383E29D4147C9695A371165f5;\n }\n } else {\n if (routeId == 215) {\n return\n 0xeC0a60e639958335662C5219A320cCEbb56C6077;\n } else {\n return\n 0x96d63CF5062975C09845d17ec672E10255866053;\n }\n }\n }\n } else {\n if (routeId < 221) {\n if (routeId < 219) {\n if (routeId == 217) {\n return\n 0xFF57429e57D383939CAB50f09ABBfB63C0e6c9AD;\n } else {\n return\n 0x18E393A7c8578fb1e235C242076E50013cDdD0d7;\n }\n } else {\n if (routeId == 219) {\n return\n 0xE7E5238AF5d61f52E9B4ACC025F713d1C0216507;\n } else {\n return\n 0x428401D4d0F25A2EE1DA4d5366cB96Ded425D9bD;\n }\n }\n } else {\n if (routeId < 223) {\n if (routeId == 221) {\n return\n 0x42E5733551ff1Ee5B48Aa9fc2B61Af9b58C812E6;\n } else {\n return\n 0x64Df9c7A0551B056d860Bc2419Ca4c1EF75320bE;\n }\n } else {\n if (routeId == 223) {\n return\n 0x46006925506145611bBf0263243D8627dAf26B0F;\n } else {\n return\n 0x8D64BE884314662804eAaB884531f5C50F4d500c;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 241) {\n if (routeId < 233) {\n if (routeId < 229) {\n if (routeId < 227) {\n if (routeId == 225) {\n return\n 0x157a62D92D07B5ce221A5429645a03bBaCE85373;\n } else {\n return\n 0xaF037D33e1F1F2F87309B425fe8a9d895Ef3722B;\n }\n } else {\n if (routeId == 227) {\n return\n 0x921D1154E494A2f7218a37ad7B17701f94b4B40e;\n } else {\n return\n 0xF282b4555186d8Dea51B8b3F947E1E0568d09bc4;\n }\n }\n } else {\n if (routeId < 231) {\n if (routeId == 229) {\n return\n 0xa794E2E1869765a4600b3DFd8a4ebcF16350f6B6;\n } else {\n return\n 0xFEFb048e20c5652F7940A49B1980E0125Ec4D358;\n }\n } else {\n if (routeId == 231) {\n return\n 0x220104b641971e9b25612a8F001bf48AbB23f1cF;\n } else {\n return\n 0xcB9D373Bb54A501B35dd3be5bF4Ba43cA31F7035;\n }\n }\n }\n } else {\n if (routeId < 237) {\n if (routeId < 235) {\n if (routeId == 233) {\n return\n 0x37D627F56e3FF36aC316372109ea82E03ac97DAc;\n } else {\n return\n 0x4E81355FfB4A271B4EA59ff78da2b61c7833161f;\n }\n } else {\n if (routeId == 235) {\n return\n 0xADd8D65cAF6Cc9ad73127B49E16eA7ac29d91e87;\n } else {\n return\n 0x630F9b95626487dfEAe3C97A44DB6C59cF35d996;\n }\n }\n } else {\n if (routeId < 239) {\n if (routeId == 237) {\n return\n 0x78CE2BC8238B679680A67FCB98C5A60E4ec17b2D;\n } else {\n return\n 0xA38D776028eD1310b9A6b086f67F788201762E21;\n }\n } else {\n if (routeId == 239) {\n return\n 0x7Bb5178827B76B86753Ed62a0d662c72cEcb1bD3;\n } else {\n return\n 0x4faC26f61C76eC5c3D43b43eDfAFF0736Ae0e3da;\n }\n }\n }\n }\n } else {\n if (routeId < 249) {\n if (routeId < 245) {\n if (routeId < 243) {\n if (routeId == 241) {\n return\n 0x791Bb49bfFA7129D6889FDB27744422Ac4571A85;\n } else {\n return\n 0x26766fFEbb5fa564777913A6f101dF019AB32afa;\n }\n } else {\n if (routeId == 243) {\n return\n 0x05e98E5e95b4ECBbbAf3258c3999Cc81ed8048Be;\n } else {\n return\n 0xC5c4621e52f1D6A1825A5ed4F95855401a3D9C6b;\n }\n }\n } else {\n if (routeId < 247) {\n if (routeId == 245) {\n return\n 0xfcb15f909BA7FC7Ea083503Fb4c1020203c107EB;\n } else {\n return\n 0xbD27603279d969c74f2486ad14E71080829DFd38;\n }\n } else {\n if (routeId == 247) {\n return\n 0xff2f756BcEcC1A55BFc09a30cc5F64720458cFCB;\n } else {\n return\n 0x3bfB968FEbC12F4e8420B2d016EfcE1E615f7246;\n }\n }\n }\n } else {\n if (routeId < 253) {\n if (routeId < 251) {\n if (routeId == 249) {\n return\n 0x982EE9Ffe23051A2ec945ed676D864fa8345222b;\n } else {\n return\n 0xe101899100785E74767d454FFF0131277BaD48d9;\n }\n } else {\n if (routeId == 251) {\n return\n 0x4F730C0c6b3B5B7d06ca511379f4Aa5BfB2E9525;\n } else {\n return\n 0x5499c36b365795e4e0Ef671aF6C2ce26D7c78265;\n }\n }\n } else {\n if (routeId < 255) {\n if (routeId == 253) {\n return\n 0x8AF51F7237Fc8fB2fc3E700488a94a0aC6Ad8b5a;\n } else {\n return\n 0xda8716df61213c0b143F2849785FB85928084857;\n }\n } else {\n if (routeId == 255) {\n return\n 0xF040Cf9b1ebD11Bf28e04e80740DF3DDe717e4f5;\n } else {\n return\n 0xB87ba32f759D14023C7520366B844dF7f0F036C2;\n }\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 321) {\n if (routeId < 289) {\n if (routeId < 273) {\n if (routeId < 265) {\n if (routeId < 261) {\n if (routeId < 259) {\n if (routeId == 257) {\n return\n 0x0Edde681b8478F0c3194f468EdD2dB5e75c65CDD;\n } else {\n return\n 0x59C70900Fca06eE2aCE1BDd5A8D0Af0cc3BBA720;\n }\n } else {\n if (routeId == 259) {\n return\n 0x8041F0f180D17dD07087199632c45E17AeB0BAd5;\n } else {\n return\n 0x4fB4727064BA595995DD516b63b5921Df9B93aC6;\n }\n }\n } else {\n if (routeId < 263) {\n if (routeId == 261) {\n return\n 0x86e98b594565857eD098864F560915C0dAfd6Ea1;\n } else {\n return\n 0x70f8818E8B698EFfeCd86A513a4c87c0c380Bef6;\n }\n } else {\n if (routeId == 263) {\n return\n 0x78Ed227c8A897A21Da2875a752142dd80d865158;\n } else {\n return\n 0xd02A30BB5C3a8C51d2751A029a6fcfDE2Af9fbc6;\n }\n }\n }\n } else {\n if (routeId < 269) {\n if (routeId < 267) {\n if (routeId == 265) {\n return\n 0x0F00d5c5acb24e975e2a56730609f7F40aa763b8;\n } else {\n return\n 0xC3e2091edc2D3D9D98ba09269138b617B536834A;\n }\n } else {\n if (routeId == 267) {\n return\n 0xa6FbaF7F30867C9633908998ea8C3da28920E75C;\n } else {\n return\n 0xE6dDdcD41E2bBe8122AE32Ac29B8fbAB79CD21d9;\n }\n }\n } else {\n if (routeId < 271) {\n if (routeId == 269) {\n return\n 0x537aa8c1Ef6a8Eaf039dd6e1Eb67694a48195cE4;\n } else {\n return\n 0x96ABAC485fd2D0B03CF4a10df8BD58b8dED28300;\n }\n } else {\n if (routeId == 271) {\n return\n 0xda8e7D46d04Bd4F62705Cd80355BDB6d441DafFD;\n } else {\n return\n 0xbE50018E7a5c67E2e5f5414393e971CC96F293f2;\n }\n }\n }\n }\n } else {\n if (routeId < 281) {\n if (routeId < 277) {\n if (routeId < 275) {\n if (routeId == 273) {\n return\n 0xa1b3907D6CB542a4cbe2eE441EfFAA909FAb62C3;\n } else {\n return\n 0x6d08ee8511C0237a515013aC389e7B3968Cb1753;\n }\n } else {\n if (routeId == 275) {\n return\n 0x22faa5B5Fe43eAdbB52745e35a5cdA8bD5F96bbA;\n } else {\n return\n 0x7a673eB74D79e4868D689E7852abB5f93Ec2fD4b;\n }\n }\n } else {\n if (routeId < 279) {\n if (routeId == 277) {\n return\n 0x0b8531F8AFD4190b76F3e10deCaDb84c98b4d419;\n } else {\n return\n 0x78eABC743A93583DeE403D6b84795490e652216B;\n }\n } else {\n if (routeId == 279) {\n return\n 0x3A95D907b2a7a8604B59BccA08585F58Afe0Aa64;\n } else {\n return\n 0xf4271f0C8c9Af0F06A80b8832fa820ccE64FAda8;\n }\n }\n }\n } else {\n if (routeId < 285) {\n if (routeId < 283) {\n if (routeId == 281) {\n return\n 0x74b2DF841245C3748c0d31542e1335659a25C33b;\n } else {\n return\n 0xdFC99Fd0Ad7D16f30f295a5EEFcE029E04d0fa65;\n }\n } else {\n if (routeId == 283) {\n return\n 0xE992416b6aC1144eD8148a9632973257839027F6;\n } else {\n return\n 0x54ce55ba954E981BB1fd9399054B35Ce1f2C0816;\n }\n }\n } else {\n if (routeId < 287) {\n if (routeId == 285) {\n return\n 0xD4AB52f9e7E5B315Bd7471920baD04F405Ab1c38;\n } else {\n return\n 0x3670C990994d12837e95eE127fE2f06FD3E2104B;\n }\n } else {\n if (routeId == 287) {\n return\n 0xDcf190B09C47E4f551E30BBb79969c3FdEA1e992;\n } else {\n return\n 0xa65057B967B59677237e57Ab815B209744b9bc40;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 305) {\n if (routeId < 297) {\n if (routeId < 293) {\n if (routeId < 291) {\n if (routeId == 289) {\n return\n 0x6Efc86B40573e4C7F28659B13327D55ae955C483;\n } else {\n return\n 0x06BcC25CF8e0E72316F53631b3aA7134E9f73Ae0;\n }\n } else {\n if (routeId == 291) {\n return\n 0x710b6414E1D53882b1FCD3A168aD5Ccd435fc6D0;\n } else {\n return\n 0x5Ebb2C3d78c4e9818074559e7BaE7FCc99781DC1;\n }\n }\n } else {\n if (routeId < 295) {\n if (routeId == 293) {\n return\n 0xAf0a409c3AEe0bD08015cfb29D89E90b6e89A88F;\n } else {\n return\n 0x522559d8b99773C693B80cE06DF559036295Ce44;\n }\n } else {\n if (routeId == 295) {\n return\n 0xB65290A5Bae838aaa7825c9ECEC68041841a1B64;\n } else {\n return\n 0x801b8F2068edd5Bcb659E6BDa0c425909043C420;\n }\n }\n }\n } else {\n if (routeId < 301) {\n if (routeId < 299) {\n if (routeId == 297) {\n return\n 0x29b5F00515d093627E0B7bd0b5c8E84F6b4cDb87;\n } else {\n return\n 0x652839Ae74683cbF9f1293F1019D938F87464D3E;\n }\n } else {\n if (routeId == 299) {\n return\n 0x5Bc95dCebDDE9B79F2b6DC76121BC7936eF8D666;\n } else {\n return\n 0x90db359CEA62E53051158Ab5F99811C0a07Fe686;\n }\n }\n } else {\n if (routeId < 303) {\n if (routeId == 301) {\n return\n 0x2c3625EedadbDcDbB5330eb0d17b3C39ff269807;\n } else {\n return\n 0xC3f0324471b5c9d415acD625b8d8694a4e48e001;\n }\n } else {\n if (routeId == 303) {\n return\n 0x8C60e7E05fa0FfB6F720233736f245134685799d;\n } else {\n return\n 0x98fAF2c09aa4EBb995ad0B56152993E7291a500e;\n }\n }\n }\n }\n } else {\n if (routeId < 313) {\n if (routeId < 309) {\n if (routeId < 307) {\n if (routeId == 305) {\n return\n 0x802c1063a861414dFAEc16bacb81429FC0d40D6e;\n } else {\n return\n 0x11C4AeFCC0dC156f64195f6513CB1Fb3Be0Ae056;\n }\n } else {\n if (routeId == 307) {\n return\n 0xEff1F3258214E31B6B4F640b4389d55715C3Be2B;\n } else {\n return\n 0x47e379Abe8DDFEA4289aBa01235EFF7E93758fd7;\n }\n }\n } else {\n if (routeId < 311) {\n if (routeId == 309) {\n return\n 0x3CC26384c3eA31dDc8D9789e8872CeA6F20cD3ff;\n } else {\n return\n 0xEdd9EFa6c69108FAA4611097d643E20Ba0Ed1634;\n }\n } else {\n if (routeId == 311) {\n return\n 0xCb93525CA5f3D371F74F3D112bC19526740717B8;\n } else {\n return\n 0x7071E0124EB4438137e60dF1b8DD8Af1BfB362cF;\n }\n }\n }\n } else {\n if (routeId < 317) {\n if (routeId < 315) {\n if (routeId == 313) {\n return\n 0x4691096EB0b78C8F4b4A8091E5B66b18e1835c10;\n } else {\n return\n 0x8d953c9b2d1C2137CF95992079f3A77fCd793272;\n }\n } else {\n if (routeId == 315) {\n return\n 0xbdCc2A3Bf6e3Ba49ff86595e6b2b8D70d8368c92;\n } else {\n return\n 0x95E6948aB38c61b2D294E8Bd896BCc4cCC0713cf;\n }\n }\n } else {\n if (routeId < 319) {\n if (routeId == 317) {\n return\n 0x607b27C881fFEE4Cb95B1c5862FaE7224ccd0b4A;\n } else {\n return\n 0x09D28aFA166e566A2Ee1cB834ea8e78C7E627eD2;\n }\n } else {\n if (routeId == 319) {\n return\n 0x9c01449b38bDF0B263818401044Fb1401B29fDfA;\n } else {\n return\n 0x1F7723599bbB658c051F8A39bE2688388d22ceD6;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 353) {\n if (routeId < 337) {\n if (routeId < 329) {\n if (routeId < 325) {\n if (routeId < 323) {\n if (routeId == 321) {\n return\n 0x52B71603f7b8A5d15B4482e965a0619aa3210194;\n } else {\n return\n 0x01c0f072CB210406653752FecFA70B42dA9173a2;\n }\n } else {\n if (routeId == 323) {\n return\n 0x3021142f021E943e57fc1886cAF58D06147D09A6;\n } else {\n return\n 0xe6f2AF38e76AB09Db59225d97d3E770942D3D842;\n }\n }\n } else {\n if (routeId < 327) {\n if (routeId == 325) {\n return\n 0x06a25554e5135F08b9e2eD1DEC1fc3CEd52e0B48;\n } else {\n return\n 0x71d75e670EE3511C8290C705E0620126B710BF8D;\n }\n } else {\n if (routeId == 327) {\n return\n 0x8b9cE142b80FeA7c932952EC533694b1DF9B3c54;\n } else {\n return\n 0xd7Be24f32f39231116B3fDc483C2A12E1521f73B;\n }\n }\n }\n } else {\n if (routeId < 333) {\n if (routeId < 331) {\n if (routeId == 329) {\n return\n 0xb40cafBC4797d4Ff64087E087F6D2e661f954CbE;\n } else {\n return\n 0xBdDCe7771EfEe81893e838f62204A4c76D72757e;\n }\n } else {\n if (routeId == 331) {\n return\n 0x5d3D299EA7Fd4F39AcDb336E26631Dfee41F9287;\n } else {\n return\n 0x6BfEE09E1Fc0684e0826A9A0dC1352a14B136FAC;\n }\n }\n } else {\n if (routeId < 335) {\n if (routeId == 333) {\n return\n 0xd0001bB8E2Cb661436093f96458a4358B5156E3c;\n } else {\n return\n 0x1867c6485CfD1eD448988368A22bfB17a7747293;\n }\n } else {\n if (routeId == 335) {\n return\n 0x8997EF9F95dF24aB67703AB6C262aABfeEBE33bD;\n } else {\n return\n 0x1e39E9E601922deD91BCFc8F78836302133465e2;\n }\n }\n }\n }\n } else {\n if (routeId < 345) {\n if (routeId < 341) {\n if (routeId < 339) {\n if (routeId == 337) {\n return\n 0x8A8ec6CeacFf502a782216774E5AF3421562C6ff;\n } else {\n return\n 0x3B8FC561df5415c8DC01e97Ee6E38435A8F9C40A;\n }\n } else {\n if (routeId == 339) {\n return\n 0xD5d5f5B37E67c43ceA663aEDADFFc3a93a2065B0;\n } else {\n return\n 0xCC8F55EC43B4f25013CE1946FBB740c43Be5B96D;\n }\n }\n } else {\n if (routeId < 343) {\n if (routeId == 341) {\n return\n 0x18f586E816eEeDbb57B8011239150367561B58Fb;\n } else {\n return\n 0xd0CD802B19c1a52501cb2f07d656e3Cd7B0Ce124;\n }\n } else {\n if (routeId == 343) {\n return\n 0xe0AeD899b39C6e4f2d83e4913a1e9e0cf6368abE;\n } else {\n return\n 0x0606e1b6c0f1A398C38825DCcc4678a7Cbc2737c;\n }\n }\n }\n } else {\n if (routeId < 349) {\n if (routeId < 347) {\n if (routeId == 345) {\n return\n 0x2d188e85b27d18EF80f16686EA1593ABF7Ed2A63;\n } else {\n return\n 0x64412292fA4A135a3300E24366E99ff59Db2eAc1;\n }\n } else {\n if (routeId == 347) {\n return\n 0x38b74c173f3733E8b90aAEf0e98B89791266149F;\n } else {\n return\n 0x36DAA49A79aaEF4E7a217A11530D3cCD84414124;\n }\n }\n } else {\n if (routeId < 351) {\n if (routeId == 349) {\n return\n 0x10f088FE2C88F90270E4449c46c8B1b232511d58;\n } else {\n return\n 0x4FeDbd25B58586838ABD17D10272697dF1dC3087;\n }\n } else {\n if (routeId == 351) {\n return\n 0x685278209248CB058E5cEe93e37f274A80Faf6eb;\n } else {\n return\n 0xDd9F8F1eeC3955f78168e2Fb2d1e808fa8A8f15b;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 369) {\n if (routeId < 361) {\n if (routeId < 357) {\n if (routeId < 355) {\n if (routeId == 353) {\n return\n 0x7392aEeFD5825aaC28817031dEEBbFaAA20983D9;\n } else {\n return\n 0x0Cc182555E00767D6FB8AD161A10d0C04C476d91;\n }\n } else {\n if (routeId == 355) {\n return\n 0x90E52837d56715c79FD592E8D58bFD20365798b2;\n } else {\n return\n 0x6F4451DE14049B6770ad5BF4013118529e68A40C;\n }\n }\n } else {\n if (routeId < 359) {\n if (routeId == 357) {\n return\n 0x89B97ef2aFAb9ed9c7f0FDb095d02E6840b52d9c;\n } else {\n return\n 0x92A5cC5C42d94d3e23aeB1214fFf43Db2B97759E;\n }\n } else {\n if (routeId == 359) {\n return\n 0x63ddc52F135A1dcBA831EAaC11C63849F018b739;\n } else {\n return\n 0x692A691533B571C2c54C1D7F8043A204b3d8120E;\n }\n }\n }\n } else {\n if (routeId < 365) {\n if (routeId < 363) {\n if (routeId == 361) {\n return\n 0x97c7492CF083969F61C6f302d45c8270391b921c;\n } else {\n return\n 0xDeFD2B8643553dAd19548eB14fd94A57F4B9e543;\n }\n } else {\n if (routeId == 363) {\n return\n 0x30645C04205cA3f670B67b02F971B088930ACB8C;\n } else {\n return\n 0xA6f80ed2d607Cd67aEB4109B64A0BEcc4D7d03CF;\n }\n }\n } else {\n if (routeId < 367) {\n if (routeId == 365) {\n return\n 0xBbbbC6c276eB3F7E674f2D39301509236001c42f;\n } else {\n return\n 0xC20E77d349FB40CE88eB01824e2873ad9f681f3C;\n }\n } else {\n if (routeId == 367) {\n return\n 0x5fCfD9a962De19294467C358C1FA55082285960b;\n } else {\n return\n 0x4D87BD6a0E4E5cc6332923cb3E85fC71b287F58A;\n }\n }\n }\n }\n } else {\n if (routeId < 377) {\n if (routeId < 373) {\n if (routeId < 371) {\n if (routeId == 369) {\n return\n 0x3AA5B757cd6Dde98214E56D57Dde7fcF0F7aB04E;\n } else {\n return\n 0xe28eFCE7192e11a2297f44059113C1fD6967b2d4;\n }\n } else {\n if (routeId == 371) {\n return\n 0x3251cAE10a1Cf246e0808D76ACC26F7B5edA0eE5;\n } else {\n return\n 0xbA2091cc9357Cf4c4F25D64F30d1b4Ba3A5a174B;\n }\n }\n } else {\n if (routeId < 375) {\n if (routeId == 373) {\n return\n 0x49c8e1Da9693692096F63C82D11b52d738566d55;\n } else {\n return\n 0xA0731615aB5FFF451031E9551367A4F7dB27b39c;\n }\n } else {\n if (routeId == 375) {\n return\n 0xFb214541888671AE1403CecC1D59763a12fc1609;\n } else {\n return\n 0x1D6bCB17642E2336405df73dF22F07688cAec020;\n }\n }\n }\n } else {\n if (routeId < 381) {\n if (routeId < 379) {\n if (routeId == 377) {\n return\n 0xfC9c0C7bfe187120fF7f4E21446161794A617a9e;\n } else {\n return\n 0xBa5bF37678EeE2dAB17AEf9D898153258252250E;\n }\n } else {\n if (routeId == 379) {\n return\n 0x7c55690bd2C9961576A32c02f8EB29ed36415Ec7;\n } else {\n return\n 0xcA40073E868E8Bc611aEc8Fe741D17E68Fe422f6;\n }\n }\n } else {\n if (routeId < 383) {\n if (routeId == 381) {\n return\n 0x31641bAFb87E9A58f78835050a7BE56921986339;\n } else {\n return\n 0xA54766424f6dA74b45EbCc5Bf0Bd1D74D2CCcaAB;\n }\n } else {\n if (routeId == 383) {\n return\n 0xc7bBa57F8C179EDDBaa62117ddA360e28f3F8252;\n } else {\n return\n 0x5e663ED97ea77d393B8858C90d0683bF180E0ffd;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n if (routes[routeId] == address(0)) revert ZeroAddressNotAllowed();\n return routes[routeId];\n }\n\n /// @notice fallback function to handle swap, bridge execution\n /// @dev ensure routeId is converted to bytes4 and sent as msg.sig in the transaction\n fallback() external payable {\n address routeAddress = addressAt(uint32(msg.sig));\n\n bytes memory result;\n\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 4, sub(calldatasize(), 4))\n // execute function call using the facet\n result := delegatecall(\n gas(),\n routeAddress,\n 0,\n sub(calldatasize(), 4),\n 0,\n 0\n )\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n"},"src/bridges/hop/interfaces/IHopL1Bridge.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title L1Bridge Hop Interface\n * @notice L1 Hop Bridge, Used to transfer from L1 to L2s.\n */\ninterface IHopL1Bridge {\n /**\n * @notice `amountOutMin` and `deadline` should be 0 when no swap is intended at the destination.\n * @notice `amount` is the total amount the user wants to send including the relayer fee\n * @dev Send tokens to a supported layer-2 to mint hToken and optionally swap the hToken in the\n * AMM at the destination.\n * @param chainId The chainId of the destination chain\n * @param recipient The address receiving funds at the destination\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination\n * AMM market. 0 if no swap is intended.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no\n * swap is intended.\n * @param relayer The address of the relayer at the destination.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n */\n function sendToL2(\n uint256 chainId,\n address recipient,\n uint256 amount,\n uint256 amountOutMin,\n uint256 deadline,\n address relayer,\n uint256 relayerFee\n ) external payable;\n}\n"},"src/bridges/refuel/interfaces/refuel.sol":{"content":"// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/// @notice interface with functions to interact with Refuel contract\ninterface IRefuel {\n /**\n * @notice function to deposit nativeToken to Destination-address on destinationChain\n * @param destinationChainId chainId of the Destination chain\n * @param _to recipient address\n */\n function depositNativeToken(\n uint256 destinationChainId,\n address _to\n ) external payable;\n}\n"},"src/bridges/stargate/interfaces/stargate.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\n/**\n * @title IBridgeStargate Interface Contract.\n * @notice Interface used by Stargate-L1 and L2 Router implementations\n * @dev router and routerETH addresses will be distinct for L1 and L2\n */\ninterface IBridgeStargate {\n // @notice Struct to hold the additional-data for bridging ERC20 token\n struct lzTxObj {\n // gas limit to bridge the token in Stargate to destinationChain\n uint256 dstGasForCall;\n // destination nativeAmount, this is always set as 0\n uint256 dstNativeAmount;\n // destination nativeAddress, this is always set as 0x\n bytes dstNativeAddr;\n }\n\n /// @notice function in stargate bridge which is used to bridge ERC20 tokens to recipient on destinationChain\n function swap(\n uint16 _dstChainId,\n uint256 _srcPoolId,\n uint256 _dstPoolId,\n address payable _refundAddress,\n uint256 _amountLD,\n uint256 _minAmountLD,\n lzTxObj memory _lzTxParams,\n bytes calldata _to,\n bytes calldata _payload\n ) external payable;\n\n /// @notice function in stargate bridge which is used to bridge native tokens to recipient on destinationChain\n function swapETH(\n uint16 _dstChainId, // destination Stargate chainId\n address payable _refundAddress, // refund additional messageFee to this address\n bytes calldata _toAddress, // the receiver of the destination ETH\n uint256 _amountLD, // the amount, in Local Decimals, to be swapped\n uint256 _minAmountLD // the minimum amount accepted out on destination\n ) external payable;\n}\n"},"src/controllers/FeesTakerController.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BaseController} from \"./BaseController.sol\";\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\n\n/**\n * @title FeesTaker-Controller Implementation\n * @notice Controller with composed actions to deduct-fees followed by Refuel, Swap and Bridge\n * to be executed Sequentially and this is atomic\n * @author Socket dot tech.\n */\ncontract FeesTakerController is BaseController {\n using SafeTransferLib for ERC20;\n\n /// @notice event emitted upon fee-deduction to fees-taker address\n event SocketFeesDeducted(\n uint256 fees,\n address feesToken,\n address feesTaker\n );\n\n /// @notice Function-selector to invoke deduct-fees and swap token\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_SWAP_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"takeFeesAndSwap((address,address,uint256,uint32,bytes))\")\n );\n\n /// @notice Function-selector to invoke deduct-fees and bridge token\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeesAndBridge((address,address,uint256,uint32,bytes))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees and bridge multiple tokens\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_MULTI_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeesAndMultiBridge((address,address,uint256,uint32[],bytes[]))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees followed by swapping of a token and bridging the swapped bridge\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeeAndSwapAndBridge((address,address,uint256,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice Function-selector to invoke deduct-fees refuel\n /// @notice followed by swapping of a token and bridging the swapped bridge\n /// @dev This function selector is to be used while building transaction-data\n bytes4 public immutable FEES_TAKER_REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"takeFeeAndRefuelAndSwapAndBridge((address,address,uint256,uint32,bytes,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BaseController\n constructor(\n address _socketGatewayAddress\n ) BaseController(_socketGatewayAddress) {}\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and swap token\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftsRequest feesTakerSwapRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_SWAP_FUNCTION_SELECTOR\n * @return output bytes from the swap operation (last operation in the composed actions)\n */\n function takeFeesAndSwap(\n ISocketRequest.FeesTakerSwapRequest calldata ftsRequest\n ) external payable returns (bytes memory) {\n if (ftsRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftsRequest.feesTakerAddress).transfer(\n ftsRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftsRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftsRequest.feesTakerAddress,\n ftsRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftsRequest.feesAmount,\n ftsRequest.feesTakerAddress,\n ftsRequest.feesToken\n );\n\n //call bridge function (executeRoute for the swapRequestData)\n return _executeRoute(ftsRequest.routeId, ftsRequest.swapRequestData);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and bridge amount to destinationChain\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftbRequest feesTakerBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_BRIDGE_FUNCTION_SELECTOR\n * @return output bytes from the bridge operation (last operation in the composed actions)\n */\n function takeFeesAndBridge(\n ISocketRequest.FeesTakerBridgeRequest calldata ftbRequest\n ) external payable returns (bytes memory) {\n if (ftbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftbRequest.feesTakerAddress).transfer(\n ftbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftbRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftbRequest.feesTakerAddress,\n ftbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftbRequest.feesAmount,\n ftbRequest.feesTakerAddress,\n ftbRequest.feesToken\n );\n\n //call bridge function (executeRoute for the bridgeData)\n return _executeRoute(ftbRequest.routeId, ftbRequest.bridgeRequestData);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain and bridge amount to destinationChain\n * @notice multiple bridge-requests are to be generated and sequence and number of routeIds should match with the bridgeData array\n * @dev ensure correct function selector is used to generate transaction-data for bridgeRequest\n * @param ftmbRequest feesTakerMultiBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_MULTI_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeesAndMultiBridge(\n ISocketRequest.FeesTakerMultiBridgeRequest calldata ftmbRequest\n ) external payable {\n if (ftmbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(ftmbRequest.feesTakerAddress).transfer(\n ftmbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(ftmbRequest.feesToken).safeTransferFrom(\n msg.sender,\n ftmbRequest.feesTakerAddress,\n ftmbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n ftmbRequest.feesAmount,\n ftmbRequest.feesTakerAddress,\n ftmbRequest.feesToken\n );\n\n // multiple bridge-requests are to be generated and sequence and number of routeIds should match with the bridgeData array\n for (\n uint256 index = 0;\n index < ftmbRequest.bridgeRouteIds.length;\n ++index\n ) {\n //call bridge function (executeRoute for the bridgeData)\n _executeRoute(\n ftmbRequest.bridgeRouteIds[index],\n ftmbRequest.bridgeRequestDataItems[index]\n );\n }\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain followed by swap the amount on sourceChain followed by\n * bridging the swapped amount to destinationChain\n * @dev while generating implData for swap and bridgeRequests, ensure correct function selector is used\n * bridge action corresponds to the bridgeAfterSwap function of the bridgeImplementation\n * @param fsbRequest feesTakerSwapBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_SWAP_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeeAndSwapAndBridge(\n ISocketRequest.FeesTakerSwapBridgeRequest calldata fsbRequest\n ) external payable returns (bytes memory) {\n if (fsbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(fsbRequest.feesTakerAddress).transfer(\n fsbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(fsbRequest.feesToken).safeTransferFrom(\n msg.sender,\n fsbRequest.feesTakerAddress,\n fsbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n fsbRequest.feesAmount,\n fsbRequest.feesTakerAddress,\n fsbRequest.feesToken\n );\n\n // execute swap operation\n bytes memory swapResponseData = _executeRoute(\n fsbRequest.swapRouteId,\n fsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n // swapped amount is to be bridged to the recipient on destinationChain\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n fsbRequest.bridgeData\n );\n\n // execute bridge operation and return the byte-data from response of bridge operation\n return _executeRoute(fsbRequest.bridgeRouteId, bridgeImpldata);\n }\n\n /**\n * @notice function to deduct-fees to fees-taker address on source-chain followed by refuel followed by\n * swap the amount on sourceChain followed by bridging the swapped amount to destinationChain\n * @dev while generating implData for refuel, swap and bridge Requests, ensure correct function selector is used\n * bridge action corresponds to the bridgeAfterSwap function of the bridgeImplementation\n * @param frsbRequest feesTakerRefuelSwapBridgeRequest object generated either off-chain or the calling contract using\n * the function-selector FEES_TAKER_REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR\n */\n function takeFeeAndRefuelAndSwapAndBridge(\n ISocketRequest.FeesTakerRefuelSwapBridgeRequest calldata frsbRequest\n ) external payable returns (bytes memory) {\n if (frsbRequest.feesToken == NATIVE_TOKEN_ADDRESS) {\n //transfer the native amount to the feeTakerAddress\n payable(frsbRequest.feesTakerAddress).transfer(\n frsbRequest.feesAmount\n );\n } else {\n //transfer feesAmount to feesTakerAddress\n ERC20(frsbRequest.feesToken).safeTransferFrom(\n msg.sender,\n frsbRequest.feesTakerAddress,\n frsbRequest.feesAmount\n );\n }\n\n emit SocketFeesDeducted(\n frsbRequest.feesAmount,\n frsbRequest.feesTakerAddress,\n frsbRequest.feesToken\n );\n\n // refuel is also done via bridge execution via refuelRouteImplementation identified by refuelRouteId\n _executeRoute(frsbRequest.refuelRouteId, frsbRequest.refuelData);\n\n // execute swap operation\n bytes memory swapResponseData = _executeRoute(\n frsbRequest.swapRouteId,\n frsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n // swapped amount is to be bridged to the recipient on destinationChain\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n frsbRequest.bridgeData\n );\n\n // execute bridge operation and return the byte-data from response of bridge operation\n return _executeRoute(frsbRequest.bridgeRouteId, bridgeImpldata);\n }\n}\n"},"src/errors/SocketErrors.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nerror CelerRefundNotReady();\nerror OnlySocketDeployer();\nerror OnlySocketGatewayOwner();\nerror OnlySocketGateway();\nerror OnlyOwner();\nerror OnlyNominee();\nerror TransferIdExists();\nerror TransferIdDoesnotExist();\nerror Address0Provided();\nerror SwapFailed();\nerror UnsupportedInterfaceId();\nerror InvalidCelerRefund();\nerror CelerAlreadyRefunded();\nerror IncorrectBridgeRatios();\nerror ZeroAddressNotAllowed();\nerror ArrayLengthMismatch();\n"},"src/bridges/hop/l1/HopImplL1.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"../interfaces/IHopL1Bridge.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {HOP} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Hop-L1 Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Hop-Bridge from L1 to Supported L2s\n * Called via SocketGateway if the routeId in the request maps to the routeId of HopImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract HopImplL1 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable HopIdentifier = HOP;\n\n /// @notice Function-selector for ERC20-token bridging on Hop-L1-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4 public immutable HOP_L1_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,address,uint256,uint256,uint256,uint256,(uint256,bytes32))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Hop-L1-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable HOP_L1_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,address,uint256,uint256,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n bytes4 public immutable HOP_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,address,uint256,uint256,uint256,uint256,bytes32))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n constructor(\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct HopDataNoToken {\n // The address receiving funds at the destination\n address receiverAddress;\n // address of the Hop-L1-Bridge to handle bridging the tokens\n address l1bridgeAddr;\n // relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n address relayer;\n // The chainId of the destination chain\n uint256 toChainId;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n uint256 relayerFee;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopData {\n /// @notice address of token being bridged\n address token;\n // The address receiving funds at the destination\n address receiverAddress;\n // address of the Hop-L1-Bridge to handle bridging the tokens\n address l1bridgeAddr;\n // relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n address relayer;\n // The chainId of the destination chain\n uint256 toChainId;\n // The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n uint256 amountOutMin;\n // The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n uint256 relayerFee;\n // The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n uint256 deadline;\n // socket offchain created hash\n bytes32 metadata;\n }\n\n struct HopERC20Data {\n uint256 deadline;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Hop-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n HopData memory hopData = abi.decode(bridgeData, (HopData));\n\n if (hopData.token == NATIVE_TOKEN_ADDRESS) {\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2{value: amount}(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n } else {\n ERC20(hopData.token).safeApprove(hopData.l1bridgeAddr, amount);\n\n // perform bridging\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2(\n hopData.toChainId,\n hopData.receiverAddress,\n amount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n }\n\n emit SocketBridge(\n amount,\n hopData.token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in HopBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param hopData encoded data for HopData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n HopDataNoToken calldata hopData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2{value: bridgeAmount}(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n } else {\n ERC20(token).safeApprove(hopData.l1bridgeAddr, bridgeAmount);\n\n // perform bridging\n IHopL1Bridge(hopData.l1bridgeAddr).sendToL2(\n hopData.toChainId,\n hopData.receiverAddress,\n bridgeAmount,\n hopData.amountOutMin,\n hopData.deadline,\n hopData.relayer,\n hopData.relayerFee\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n hopData.toChainId,\n HopIdentifier,\n msg.sender,\n hopData.receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Hop-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param token token being bridged\n * @param l1bridgeAddr address of the Hop-L1-Bridge to handle bridging the tokens\n * @param relayer The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n * @param toChainId The chainId of the destination chain\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n * @param hopData extra data needed to build the tx\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n address l1bridgeAddr,\n address relayer,\n uint256 toChainId,\n uint256 amount,\n uint256 amountOutMin,\n uint256 relayerFee,\n HopERC20Data calldata hopData\n ) external payable {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(l1bridgeAddr, amount);\n\n // perform bridging\n IHopL1Bridge(l1bridgeAddr).sendToL2(\n toChainId,\n receiverAddress,\n amount,\n amountOutMin,\n hopData.deadline,\n relayer,\n relayerFee\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n hopData.metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Hop-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress The address receiving funds at the destination\n * @param l1bridgeAddr address of the Hop-L1-Bridge to handle bridging the tokens\n * @param relayer The amount distributed to the relayer at the destination. This is subtracted from the `_amount`.\n * @param toChainId The chainId of the destination chain\n * @param amount The amount being sent\n * @param amountOutMin The minimum amount received after attempting to swap in the destination AMM market. 0 if no swap is intended.\n * @param relayerFee The amount distributed to the relayer at the destination. This is subtracted from the `amount`.\n * @param deadline The deadline for swapping in the destination AMM market. 0 if no swap is intended.\n */\n function bridgeNativeTo(\n address receiverAddress,\n address l1bridgeAddr,\n address relayer,\n uint256 toChainId,\n uint256 amount,\n uint256 amountOutMin,\n uint256 relayerFee,\n uint256 deadline,\n bytes32 metadata\n ) external payable {\n IHopL1Bridge(l1bridgeAddr).sendToL2{value: amount}(\n toChainId,\n receiverAddress,\n amount,\n amountOutMin,\n deadline,\n relayer,\n relayerFee\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n HopIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"},"src/static/RouteIdentifiers.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\nbytes32 constant ACROSS = keccak256(\"Across\");\n\nbytes32 constant ANYSWAP = keccak256(\"Anyswap\");\n\nbytes32 constant CBRIDGE = keccak256(\"CBridge\");\n\nbytes32 constant HOP = keccak256(\"Hop\");\n\nbytes32 constant HYPHEN = keccak256(\"Hyphen\");\n\nbytes32 constant NATIVE_OPTIMISM = keccak256(\"NativeOptimism\");\n\nbytes32 constant NATIVE_ARBITRUM = keccak256(\"NativeArbitrum\");\n\nbytes32 constant NATIVE_POLYGON = keccak256(\"NativePolygon\");\n\nbytes32 constant REFUEL = keccak256(\"Refuel\");\n\nbytes32 constant STARGATE = keccak256(\"Stargate\");\n\nbytes32 constant ONEINCH = keccak256(\"OneInch\");\n\nbytes32 constant ZEROX = keccak256(\"Zerox\");\n\nbytes32 constant RAINBOW = keccak256(\"Rainbow\");\n"},"src/SocketGateway.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\npragma experimental ABIEncoderV2;\n\nimport \"./utils/Ownable.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {LibUtil} from \"./libraries/LibUtil.sol\";\nimport \"./libraries/LibBytes.sol\";\nimport {ISocketRoute} from \"./interfaces/ISocketRoute.sol\";\nimport {ISocketRequest} from \"./interfaces/ISocketRequest.sol\";\nimport {ISocketGateway} from \"./interfaces/ISocketGateway.sol\";\nimport {IncorrectBridgeRatios, ZeroAddressNotAllowed, ArrayLengthMismatch} from \"./errors/SocketErrors.sol\";\n\n/// @title SocketGatewayContract\n/// @notice Socketgateway is a contract with entrypoint functions for all interactions with socket liquidity layer\n/// @author Socket Team\ncontract SocketGatewayTemplate is Ownable {\n using LibBytes for bytes;\n using LibBytes for bytes4;\n using SafeTransferLib for ERC20;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /// @notice storage variable to keep track of total number of routes registered in socketgateway\n uint32 public routesCount = 385;\n\n /// @notice storage variable to keep track of total number of controllers registered in socketgateway\n uint32 public controllerCount;\n\n address public immutable disabledRouteAddress;\n\n uint256 public constant CENT_PERCENT = 100e18;\n\n /// @notice storage mapping for route implementation addresses\n mapping(uint32 => address) public routes;\n\n /// storage mapping for controller implemenation addresses\n mapping(uint32 => address) public controllers;\n\n // Events ------------------------------------------------------------------------------------------------------->\n\n /// @notice Event emitted when a router is added to socketgateway\n event NewRouteAdded(uint32 indexed routeId, address indexed route);\n\n /// @notice Event emitted when a route is disabled\n event RouteDisabled(uint32 indexed routeId);\n\n /// @notice Event emitted when ownership transfer is requested by socket-gateway-owner\n event OwnershipTransferRequested(\n address indexed _from,\n address indexed _to\n );\n\n /// @notice Event emitted when a controller is added to socketgateway\n event ControllerAdded(\n uint32 indexed controllerId,\n address indexed controllerAddress\n );\n\n /// @notice Event emitted when a controller is disabled\n event ControllerDisabled(uint32 indexed controllerId);\n\n constructor(address _owner, address _disabledRoute) Ownable(_owner) {\n disabledRouteAddress = _disabledRoute;\n }\n\n // Able to receive ether\n // solhint-disable-next-line no-empty-blocks\n receive() external payable {}\n\n /*******************************************\n * EXTERNAL AND PUBLIC FUNCTIONS *\n *******************************************/\n\n /**\n * @notice executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in routeData to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeId route identifier\n * @param routeData functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoute(\n uint32 routeId,\n bytes calldata routeData\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = addressAt(routeId).delegatecall(\n routeData\n );\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice swaps a token on sourceChain and split it across multiple bridge-recipients\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being swapped\n * @dev ensure the swap-data and bridge-data is generated using the function-selector defined as a constant in the implementation address\n * @param swapMultiBridgeRequest request\n */\n function swapAndMultiBridge(\n ISocketRequest.SwapMultiBridgeRequest calldata swapMultiBridgeRequest\n ) external payable {\n uint256 requestLength = swapMultiBridgeRequest.bridgeRouteIds.length;\n\n if (\n requestLength != swapMultiBridgeRequest.bridgeImplDataItems.length\n ) {\n revert ArrayLengthMismatch();\n }\n uint256 ratioAggregate;\n for (uint256 index = 0; index < requestLength; ) {\n ratioAggregate += swapMultiBridgeRequest.bridgeRatios[index];\n }\n\n if (ratioAggregate != CENT_PERCENT) {\n revert IncorrectBridgeRatios();\n }\n\n (bool swapSuccess, bytes memory swapResult) = addressAt(\n swapMultiBridgeRequest.swapRouteId\n ).delegatecall(swapMultiBridgeRequest.swapImplData);\n\n if (!swapSuccess) {\n assembly {\n revert(add(swapResult, 32), mload(swapResult))\n }\n }\n\n uint256 amountReceivedFromSwap = abi.decode(swapResult, (uint256));\n\n uint256 bridgedAmount;\n\n for (uint256 index = 0; index < requestLength; ) {\n uint256 bridgingAmount;\n\n // if it is the last bridge request, bridge the remaining amount\n if (index == requestLength - 1) {\n bridgingAmount = amountReceivedFromSwap - bridgedAmount;\n } else {\n // bridging amount is the multiplication of bridgeRatio and amountReceivedFromSwap\n bridgingAmount =\n (amountReceivedFromSwap *\n swapMultiBridgeRequest.bridgeRatios[index]) /\n (CENT_PERCENT);\n }\n\n // update the bridged amount, this would be used for computation for last bridgeRequest\n bridgedAmount += bridgingAmount;\n\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n bridgingAmount,\n swapMultiBridgeRequest.bridgeImplDataItems[index]\n );\n\n (bool bridgeSuccess, bytes memory bridgeResult) = addressAt(\n swapMultiBridgeRequest.bridgeRouteIds[index]\n ).delegatecall(bridgeImpldata);\n\n if (!bridgeSuccess) {\n assembly {\n revert(add(bridgeResult, 32), mload(bridgeResult))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice sequentially executes functions in the routes identified using routeId and functionSelectorData\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each dataItem to be built using the function-selector defined as a\n * constant in the route implementation contract\n * @param routeIds a list of route identifiers\n * @param dataItems a list of functionSelectorData generated using the function-selector defined in the route Implementation\n */\n function executeRoutes(\n uint32[] calldata routeIds,\n bytes[] calldata dataItems\n ) external payable {\n uint256 routeIdslength = routeIds.length;\n if (routeIdslength != dataItems.length) revert ArrayLengthMismatch();\n for (uint256 index = 0; index < routeIdslength; ) {\n (bool success, bytes memory result) = addressAt(routeIds[index])\n .delegatecall(dataItems[index]);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice execute a controller function identified using the controllerId in the request\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param socketControllerRequest socketControllerRequest with controllerId to identify the\n * controllerAddress and byteData constructed using functionSelector\n * of the function being invoked\n * @return bytes data received from the call delegated to controller\n */\n function executeController(\n ISocketGateway.SocketControllerRequest calldata socketControllerRequest\n ) external payable returns (bytes memory) {\n (bool success, bytes memory result) = controllers[\n socketControllerRequest.controllerId\n ].delegatecall(socketControllerRequest.data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n return result;\n }\n\n /**\n * @notice sequentially executes all controller requests\n * @notice The caller must first approve this contract to spend amount of ERC20-Token being bridged/swapped\n * @dev ensure the data in each controller-request to be built using the function-selector defined as a\n * constant in the controller implementation contract\n * @param controllerRequests a list of socketControllerRequest\n * Each controllerRequest contains controllerId to identify the controllerAddress and\n * byteData constructed using functionSelector of the function being invoked\n */\n function executeControllers(\n ISocketGateway.SocketControllerRequest[] calldata controllerRequests\n ) external payable {\n for (uint32 index = 0; index < controllerRequests.length; ) {\n (bool success, bytes memory result) = controllers[\n controllerRequests[index].controllerId\n ].delegatecall(controllerRequests[index].data);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n unchecked {\n ++index;\n }\n }\n }\n\n /**************************************\n * ADMIN FUNCTIONS *\n **************************************/\n\n /**\n * @notice Add route to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure routeAddress is a verified bridge or middleware implementation address\n * @param routeAddress The address of bridge or middleware implementation contract deployed\n * @return Id of the route added to the routes-mapping in socketGateway storage\n */\n function addRoute(\n address routeAddress\n ) external onlyOwner returns (uint32) {\n uint32 routeId = routesCount;\n routes[routeId] = routeAddress;\n\n routesCount += 1;\n\n emit NewRouteAdded(routeId, routeAddress);\n\n return routeId;\n }\n\n /**\n * @notice Give Infinite or 0 approval to bridgeRoute for the tokenAddress\n This is a restricted function to be called by only socketGatewayOwner\n */\n\n function setApprovalForRouters(\n address[] memory routeAddresses,\n address[] memory tokenAddresses,\n bool isMax\n ) external onlyOwner {\n for (uint32 index = 0; index < routeAddresses.length; ) {\n ERC20(tokenAddresses[index]).approve(\n routeAddresses[index],\n isMax ? type(uint256).max : 0\n );\n unchecked {\n ++index;\n }\n }\n }\n\n /**\n * @notice Add controller to the socketGateway\n This is a restricted function to be called by only socketGatewayOwner\n * @dev ensure controllerAddress is a verified controller implementation address\n * @param controllerAddress The address of controller implementation contract deployed\n * @return Id of the controller added to the controllers-mapping in socketGateway storage\n */\n function addController(\n address controllerAddress\n ) external onlyOwner returns (uint32) {\n uint32 controllerId = controllerCount;\n\n controllers[controllerId] = controllerAddress;\n\n controllerCount += 1;\n\n emit ControllerAdded(controllerId, controllerAddress);\n\n return controllerId;\n }\n\n /**\n * @notice disable controller by setting ZeroAddress to the entry in controllers-mapping\n identified by controllerId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param controllerId The Id of controller-implementation in the controllers mapping\n */\n function disableController(uint32 controllerId) public onlyOwner {\n controllers[controllerId] = disabledRouteAddress;\n emit ControllerDisabled(controllerId);\n }\n\n /**\n * @notice disable a route by setting ZeroAddress to the entry in routes-mapping\n identified by routeId as key.\n This is a restricted function to be called by only socketGatewayOwner\n * @param routeId The Id of route-implementation in the routes mapping\n */\n function disableRoute(uint32 routeId) external onlyOwner {\n routes[routeId] = disabledRouteAddress;\n emit RouteDisabled(routeId);\n }\n\n /*******************************************\n * RESTRICTED RESCUE FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Rescues the ERC20 token to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param token address of the ERC20 token being rescued\n * @param userAddress address to which ERC20 is to be rescued\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external onlyOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice Rescues the native balance to an address\n this is a restricted function to be called by only socketGatewayOwner\n * @dev as this is a restricted to socketGatewayOwner, ensure the userAddress is a known address\n * @param userAddress address to which native-balance is to be rescued\n * @param amount amount of native-balance being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external onlyOwner {\n userAddress.transfer(amount);\n }\n\n /*******************************************\n * VIEW FUNCTIONS *\n *******************************************/\n\n /**\n * @notice Get routeImplementation address mapped to the routeId\n * @param routeId routeId is the key in the mapping for routes\n * @return route-implementation address\n */\n function getRoute(uint32 routeId) public view returns (address) {\n return addressAt(routeId);\n }\n\n /**\n * @notice Get controllerImplementation address mapped to the controllerId\n * @param controllerId controllerId is the key in the mapping for controllers\n * @return controller-implementation address\n */\n function getController(uint32 controllerId) public view returns (address) {\n return controllers[controllerId];\n }\n\n function addressAt(uint32 routeId) public view returns (address) {\n if (routeId < 385) {\n if (routeId < 257) {\n if (routeId < 129) {\n if (routeId < 65) {\n if (routeId < 33) {\n if (routeId < 17) {\n if (routeId < 9) {\n if (routeId < 5) {\n if (routeId < 3) {\n if (routeId == 1) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 3) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 7) {\n if (routeId == 5) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 7) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 13) {\n if (routeId < 11) {\n if (routeId == 9) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 11) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 15) {\n if (routeId == 13) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 15) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 25) {\n if (routeId < 21) {\n if (routeId < 19) {\n if (routeId == 17) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 19) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 23) {\n if (routeId == 21) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 23) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 29) {\n if (routeId < 27) {\n if (routeId == 25) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 27) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 31) {\n if (routeId == 29) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 31) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 49) {\n if (routeId < 41) {\n if (routeId < 37) {\n if (routeId < 35) {\n if (routeId == 33) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 35) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 39) {\n if (routeId == 37) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 39) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 45) {\n if (routeId < 43) {\n if (routeId == 41) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 43) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 47) {\n if (routeId == 45) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 47) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 57) {\n if (routeId < 53) {\n if (routeId < 51) {\n if (routeId == 49) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 51) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 55) {\n if (routeId == 53) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 55) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 61) {\n if (routeId < 59) {\n if (routeId == 57) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 59) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 63) {\n if (routeId == 61) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 63) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 97) {\n if (routeId < 81) {\n if (routeId < 73) {\n if (routeId < 69) {\n if (routeId < 67) {\n if (routeId == 65) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 67) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 71) {\n if (routeId == 69) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 71) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 77) {\n if (routeId < 75) {\n if (routeId == 73) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 75) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 79) {\n if (routeId == 77) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 79) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 89) {\n if (routeId < 85) {\n if (routeId < 83) {\n if (routeId == 81) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 83) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 87) {\n if (routeId == 85) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 87) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 93) {\n if (routeId < 91) {\n if (routeId == 89) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 91) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 95) {\n if (routeId == 93) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 95) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 113) {\n if (routeId < 105) {\n if (routeId < 101) {\n if (routeId < 99) {\n if (routeId == 97) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 99) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 103) {\n if (routeId == 101) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 103) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 109) {\n if (routeId < 107) {\n if (routeId == 105) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 107) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 111) {\n if (routeId == 109) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 111) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 121) {\n if (routeId < 117) {\n if (routeId < 115) {\n if (routeId == 113) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 115) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 119) {\n if (routeId == 117) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 119) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 125) {\n if (routeId < 123) {\n if (routeId == 121) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 123) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 127) {\n if (routeId == 125) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 127) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 193) {\n if (routeId < 161) {\n if (routeId < 145) {\n if (routeId < 137) {\n if (routeId < 133) {\n if (routeId < 131) {\n if (routeId == 129) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 131) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 135) {\n if (routeId == 133) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 135) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 141) {\n if (routeId < 139) {\n if (routeId == 137) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 139) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 143) {\n if (routeId == 141) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 143) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 153) {\n if (routeId < 149) {\n if (routeId < 147) {\n if (routeId == 145) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 147) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 151) {\n if (routeId == 149) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 151) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 157) {\n if (routeId < 155) {\n if (routeId == 153) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 155) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 159) {\n if (routeId == 157) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 159) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 177) {\n if (routeId < 169) {\n if (routeId < 165) {\n if (routeId < 163) {\n if (routeId == 161) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 163) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 167) {\n if (routeId == 165) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 167) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 173) {\n if (routeId < 171) {\n if (routeId == 169) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 171) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 175) {\n if (routeId == 173) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 175) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 185) {\n if (routeId < 181) {\n if (routeId < 179) {\n if (routeId == 177) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 179) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 183) {\n if (routeId == 181) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 183) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 189) {\n if (routeId < 187) {\n if (routeId == 185) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 187) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 191) {\n if (routeId == 189) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 191) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 225) {\n if (routeId < 209) {\n if (routeId < 201) {\n if (routeId < 197) {\n if (routeId < 195) {\n if (routeId == 193) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 195) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 199) {\n if (routeId == 197) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 199) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 205) {\n if (routeId < 203) {\n if (routeId == 201) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 203) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 207) {\n if (routeId == 205) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 207) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 217) {\n if (routeId < 213) {\n if (routeId < 211) {\n if (routeId == 209) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 211) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 215) {\n if (routeId == 213) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 215) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 221) {\n if (routeId < 219) {\n if (routeId == 217) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 219) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 223) {\n if (routeId == 221) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 223) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 241) {\n if (routeId < 233) {\n if (routeId < 229) {\n if (routeId < 227) {\n if (routeId == 225) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 227) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 231) {\n if (routeId == 229) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 231) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 237) {\n if (routeId < 235) {\n if (routeId == 233) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 235) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 239) {\n if (routeId == 237) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 239) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 249) {\n if (routeId < 245) {\n if (routeId < 243) {\n if (routeId == 241) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 243) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 247) {\n if (routeId == 245) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 247) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 253) {\n if (routeId < 251) {\n if (routeId == 249) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 251) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 255) {\n if (routeId == 253) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 255) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 321) {\n if (routeId < 289) {\n if (routeId < 273) {\n if (routeId < 265) {\n if (routeId < 261) {\n if (routeId < 259) {\n if (routeId == 257) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 259) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 263) {\n if (routeId == 261) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 263) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 269) {\n if (routeId < 267) {\n if (routeId == 265) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 267) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 271) {\n if (routeId == 269) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 271) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 281) {\n if (routeId < 277) {\n if (routeId < 275) {\n if (routeId == 273) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 275) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 279) {\n if (routeId == 277) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 279) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 285) {\n if (routeId < 283) {\n if (routeId == 281) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 283) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 287) {\n if (routeId == 285) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 287) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 305) {\n if (routeId < 297) {\n if (routeId < 293) {\n if (routeId < 291) {\n if (routeId == 289) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 291) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 295) {\n if (routeId == 293) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 295) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 301) {\n if (routeId < 299) {\n if (routeId == 297) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 299) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 303) {\n if (routeId == 301) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 303) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 313) {\n if (routeId < 309) {\n if (routeId < 307) {\n if (routeId == 305) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 307) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 311) {\n if (routeId == 309) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 311) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 317) {\n if (routeId < 315) {\n if (routeId == 313) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 315) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 319) {\n if (routeId == 317) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 319) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n } else {\n if (routeId < 353) {\n if (routeId < 337) {\n if (routeId < 329) {\n if (routeId < 325) {\n if (routeId < 323) {\n if (routeId == 321) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 323) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 327) {\n if (routeId == 325) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 327) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 333) {\n if (routeId < 331) {\n if (routeId == 329) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 331) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 335) {\n if (routeId == 333) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 335) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 345) {\n if (routeId < 341) {\n if (routeId < 339) {\n if (routeId == 337) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 339) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 343) {\n if (routeId == 341) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 343) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 349) {\n if (routeId < 347) {\n if (routeId == 345) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 347) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 351) {\n if (routeId == 349) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 351) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n } else {\n if (routeId < 369) {\n if (routeId < 361) {\n if (routeId < 357) {\n if (routeId < 355) {\n if (routeId == 353) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 355) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 359) {\n if (routeId == 357) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 359) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 365) {\n if (routeId < 363) {\n if (routeId == 361) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 363) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 367) {\n if (routeId == 365) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 367) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n } else {\n if (routeId < 377) {\n if (routeId < 373) {\n if (routeId < 371) {\n if (routeId == 369) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 371) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 375) {\n if (routeId == 373) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 375) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n } else {\n if (routeId < 381) {\n if (routeId < 379) {\n if (routeId == 377) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 379) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n } else {\n if (routeId < 383) {\n if (routeId == 381) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n } else {\n if (routeId == 383) {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n } else {\n return\n 0x822D4B4e63499a576Ab1cc152B86D1CFFf794F4f;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n if (routes[routeId] == address(0)) revert ZeroAddressNotAllowed();\n return routes[routeId];\n }\n\n /// @notice fallback function to handle swap, bridge execution\n /// @dev ensure routeId is converted to bytes4 and sent as msg.sig in the transaction\n fallback() external payable {\n address routeAddress = addressAt(uint32(msg.sig));\n\n bytes memory result;\n\n assembly {\n // copy function selector and any arguments\n calldatacopy(0, 4, sub(calldatasize(), 4))\n // execute function call using the facet\n result := delegatecall(\n gas(),\n routeAddress,\n 0,\n sub(calldatasize(), 4),\n 0,\n 0\n )\n // get any return value\n returndatacopy(0, 0, returndatasize())\n // return any return value or error back to the caller\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n}\n"},"src/swap/rainbow/Rainbow.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {Address0Provided, SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {RAINBOW} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Rainbow-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via Rainbow-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of RainbowImplementation\n * @author Socket dot tech.\n */\ncontract RainbowSwapImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable RainbowIdentifier = RAINBOW;\n\n /// @notice unique name to identify the router, used to emit event upon successful bridging\n bytes32 public immutable NAME = keccak256(\"Rainbow-Router\");\n\n /// @notice address of rainbow-swap-aggregator to swap the tokens on Chain\n address payable public immutable rainbowSwapAggregator;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @notice rainbow swap aggregator contract is payable to allow ethereum swaps\n /// @dev ensure _rainbowSwapAggregator are set properly for the chainId in which the contract is being deployed\n constructor(\n address _rainbowSwapAggregator,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n rainbowSwapAggregator = payable(_rainbowSwapAggregator);\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * @notice This method is payable because the caller is doing token transfer and swap operation\n * @param fromToken address of token being Swapped\n * @param toToken address of token that recipient will receive after swap\n * @param amount amount of fromToken being swapped\n * @param receiverAddress recipient-address\n * @param swapExtraData additional Data to perform Swap via Rainbow-Aggregator\n * @return swapped amount (in toToken Address)\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 toTokenERC20 = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(rainbowSwapAggregator, amount);\n\n // solhint-disable-next-line\n (bool success, ) = rainbowSwapAggregator.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(rainbowSwapAggregator, 0);\n } else {\n (bool success, ) = rainbowSwapAggregator.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n if (toToken == NATIVE_TOKEN_ADDRESS) {\n payable(receiverAddress).transfer(returnAmount);\n } else {\n toTokenERC20.transfer(receiverAddress, returnAmount);\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n RainbowIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 toTokenERC20 = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, socketGateway, amount);\n token.safeApprove(rainbowSwapAggregator, amount);\n\n // solhint-disable-next-line\n (bool success, ) = rainbowSwapAggregator.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(rainbowSwapAggregator, 0);\n } else {\n (bool success, ) = rainbowSwapAggregator.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = toTokenERC20.balanceOf(socketGateway);\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n RainbowIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n"},"src/interfaces/ISocketBridgeBase.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface ISocketBridgeBase {\n function killme() external;\n}\n"},"src/interfaces/ISocketRequest.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketRoute\n * @notice Interface with Request DataStructures to invoke controller functions.\n * @author Socket dot tech.\n */\ninterface ISocketRequest {\n struct SwapMultiBridgeRequest {\n uint32 swapRouteId;\n bytes swapImplData;\n uint32[] bridgeRouteIds;\n bytes[] bridgeImplDataItems;\n uint256[] bridgeRatios;\n bytes[] eventDataItems;\n }\n\n // Datastructure for Refuel-Swap-Bridge function\n struct RefuelSwapBridgeRequest {\n uint32 refuelRouteId;\n bytes refuelData;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n\n // Datastructure for DeductFees-Swap function\n struct FeesTakerSwapRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 routeId;\n bytes swapRequestData;\n }\n\n // Datastructure for DeductFees-Bridge function\n struct FeesTakerBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 routeId;\n bytes bridgeRequestData;\n }\n\n // Datastructure for DeductFees-MultiBridge function\n struct FeesTakerMultiBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32[] bridgeRouteIds;\n bytes[] bridgeRequestDataItems;\n }\n\n // Datastructure for DeductFees-Swap-Bridge function\n struct FeesTakerSwapBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n\n // Datastructure for DeductFees-Refuel-Swap-Bridge function\n struct FeesTakerRefuelSwapBridgeRequest {\n address feesTakerAddress;\n address feesToken;\n uint256 feesAmount;\n uint32 refuelRouteId;\n bytes refuelData;\n uint32 swapRouteId;\n bytes swapData;\n uint32 bridgeRouteId;\n bytes bridgeData;\n }\n}\n"},"src/utils/Ownable.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.4;\n\nimport {OnlyOwner, OnlyNominee} from \"../errors/SocketErrors.sol\";\n\nabstract contract Ownable {\n address private _owner;\n address private _nominee;\n\n event OwnerNominated(address indexed nominee);\n event OwnerClaimed(address indexed claimer);\n\n constructor(address owner_) {\n _claimOwner(owner_);\n }\n\n modifier onlyOwner() {\n if (msg.sender != _owner) {\n revert OnlyOwner();\n }\n _;\n }\n\n function owner() public view returns (address) {\n return _owner;\n }\n\n function nominee() public view returns (address) {\n return _nominee;\n }\n\n function nominateOwner(address nominee_) external {\n if (msg.sender != _owner) {\n revert OnlyOwner();\n }\n _nominee = nominee_;\n emit OwnerNominated(_nominee);\n }\n\n function claimOwner() external {\n if (msg.sender != _nominee) {\n revert OnlyNominee();\n }\n _claimOwner(msg.sender);\n }\n\n function _claimOwner(address claimer_) internal {\n _owner = claimer_;\n _nominee = address(0);\n emit OwnerClaimed(claimer_);\n }\n}\n"},"lib/solmate/src/tokens/ERC20.sol":{"content":"// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n"},"src/controllers/RefuelSwapAndBridgeController.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {ISocketRequest} from \"../interfaces/ISocketRequest.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\nimport {BaseController} from \"./BaseController.sol\";\n\n/**\n * @title RefuelSwapAndBridge Controller Implementation\n * @notice Controller with composed actions for Refuel,Swap and Bridge to be executed Sequentially and this is atomic\n * @author Socket dot tech.\n */\ncontract RefuelSwapAndBridgeController is BaseController {\n /// @notice Function-selector to invoke refuel-swap-bridge function\n /// @dev This function selector is to be used while buidling transaction-data\n bytes4 public immutable REFUEL_SWAP_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"refuelAndSwapAndBridge((uint32,bytes,uint32,bytes,uint32,bytes))\"\n )\n );\n\n /// @notice socketGatewayAddress to be initialised via storage variable BaseController\n constructor(\n address _socketGatewayAddress\n ) BaseController(_socketGatewayAddress) {}\n\n /**\n * @notice function to handle refuel followed by Swap and Bridge actions\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param rsbRequest Request with data to execute refuel followed by swap and bridge\n * @return output data from bridging operation\n */\n function refuelAndSwapAndBridge(\n ISocketRequest.RefuelSwapBridgeRequest calldata rsbRequest\n ) public payable returns (bytes memory) {\n _executeRoute(rsbRequest.refuelRouteId, rsbRequest.refuelData);\n\n // refuel is also a bridging activity via refuel-route-implementation\n bytes memory swapResponseData = _executeRoute(\n rsbRequest.swapRouteId,\n rsbRequest.swapData\n );\n\n uint256 swapAmount = abi.decode(swapResponseData, (uint256));\n\n //sequence of arguments for implData: amount, token, data\n // Bridging the swapAmount received in the preceeding step\n bytes memory bridgeImpldata = abi.encodeWithSelector(\n BRIDGE_AFTER_SWAP_SELECTOR,\n swapAmount,\n rsbRequest.bridgeData\n );\n\n return _executeRoute(rsbRequest.bridgeRouteId, bridgeImpldata);\n }\n}\n"},"src/interfaces/ISocketGateway.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/**\n * @title ISocketGateway\n * @notice Interface for SocketGateway functions.\n * @dev functions can be added here for invocation from external contracts or off-chain\n * @author Socket dot tech.\n */\ninterface ISocketGateway {\n /**\n * @notice Request-struct for controllerRequests\n * @dev ensure the value for data is generated using the function-selectors defined in the controllerImplementation contracts\n */\n struct SocketControllerRequest {\n // controllerId is the id mapped to the controllerAddress\n uint32 controllerId;\n // transactionImplData generated off-chain or by caller using function-selector of the controllerContract\n bytes data;\n }\n\n // @notice view to get owner-address\n function owner() external view returns (address);\n}\n"},"src/libraries/Pb.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.4;\n\n// runtime proto sol library\nlibrary Pb {\n enum WireType {\n Varint,\n Fixed64,\n LengthDelim,\n StartGroup,\n EndGroup,\n Fixed32\n }\n\n struct Buffer {\n uint256 idx; // the start index of next read. when idx=b.length, we're done\n bytes b; // hold serialized proto msg, readonly\n }\n\n // create a new in-memory Buffer object from raw msg bytes\n function fromBytes(\n bytes memory raw\n ) internal pure returns (Buffer memory buf) {\n buf.b = raw;\n buf.idx = 0;\n }\n\n // whether there are unread bytes\n function hasMore(Buffer memory buf) internal pure returns (bool) {\n return buf.idx < buf.b.length;\n }\n\n // decode current field number and wiretype\n function decKey(\n Buffer memory buf\n ) internal pure returns (uint256 tag, WireType wiretype) {\n uint256 v = decVarint(buf);\n tag = v / 8;\n wiretype = WireType(v & 7);\n }\n\n // read varint from current buf idx, move buf.idx to next read, return the int value\n function decVarint(Buffer memory buf) internal pure returns (uint256 v) {\n bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)\n bytes memory bb = buf.b; // get buf.b mem addr to use in assembly\n v = buf.idx; // use v to save one additional uint variable\n assembly {\n tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp\n }\n uint256 b; // store current byte content\n v = 0; // reset to 0 for return value\n for (uint256 i = 0; i < 10; i++) {\n assembly {\n b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra\n }\n v |= (b & 0x7F) << (i * 7);\n if (b & 0x80 == 0) {\n buf.idx += i + 1;\n return v;\n }\n }\n revert(); // i=10, invalid varint stream\n }\n\n // read length delimited field and return bytes\n function decBytes(\n Buffer memory buf\n ) internal pure returns (bytes memory b) {\n uint256 len = decVarint(buf);\n uint256 end = buf.idx + len;\n require(end <= buf.b.length); // avoid overflow\n b = new bytes(len);\n bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly\n uint256 bStart;\n uint256 bufBStart = buf.idx;\n assembly {\n bStart := add(b, 32)\n bufBStart := add(add(bufB, 32), bufBStart)\n }\n for (uint256 i = 0; i < len; i += 32) {\n assembly {\n mstore(add(bStart, i), mload(add(bufBStart, i)))\n }\n }\n buf.idx = end;\n }\n\n // move idx pass current value field, to beginning of next tag or msg end\n function skipValue(Buffer memory buf, WireType wire) internal pure {\n if (wire == WireType.Varint) {\n decVarint(buf);\n } else if (wire == WireType.LengthDelim) {\n uint256 len = decVarint(buf);\n buf.idx += len; // skip len bytes value data\n require(buf.idx <= buf.b.length); // avoid overflow\n } else {\n revert();\n } // unsupported wiretype\n }\n\n function _uint256(bytes memory b) internal pure returns (uint256 v) {\n require(b.length <= 32); // b's length must be smaller than or equal to 32\n assembly {\n v := mload(add(b, 32))\n } // load all 32bytes to v\n v = v >> (8 * (32 - b.length)); // only first b.length is valid\n }\n\n function _address(bytes memory b) internal pure returns (address v) {\n v = _addressPayable(b);\n }\n\n function _addressPayable(\n bytes memory b\n ) internal pure returns (address payable v) {\n require(b.length == 20);\n //load 32bytes then shift right 12 bytes\n assembly {\n v := div(mload(add(b, 32)), 0x1000000000000000000000000)\n }\n }\n\n function _bytes32(bytes memory b) internal pure returns (bytes32 v) {\n require(b.length == 32);\n assembly {\n v := mload(add(b, 32))\n }\n }\n}\n"},"src/bridges/BridgeImplBase.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {ISocketRoute} from \"../interfaces/ISocketRoute.sol\";\nimport {OnlySocketGatewayOwner, OnlySocketDeployer} from \"../errors/SocketErrors.sol\";\n\n/**\n * @title Abstract Implementation Contract.\n * @notice All Bridge Implementation will follow this interface.\n */\nabstract contract BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketDeployFactory;\n\n /// @notice immutable variable with instance of SocketRoute to access route functions\n ISocketRoute public immutable socketRoute;\n\n /// @notice FunctionSelector used to delegatecall from swap to the function of bridge router implementation\n bytes4 public immutable BRIDGE_AFTER_SWAP_SELECTOR =\n bytes4(keccak256(\"bridgeAfterSwap(uint256,bytes)\"));\n\n /****************************************\n * EVENTS *\n ****************************************/\n\n event SocketBridge(\n uint256 amount,\n address token,\n uint256 toChainId,\n bytes32 bridgeName,\n address sender,\n address receiver,\n bytes32 metadata\n );\n\n /**\n * @notice Construct the base for all BridgeImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n * @param _socketDeployFactory Socket Deploy Factory address, an immutable variable to set.\n */\n constructor(address _socketGateway, address _socketDeployFactory) {\n socketGateway = _socketGateway;\n socketDeployFactory = _socketDeployFactory;\n socketRoute = ISocketRoute(_socketGateway);\n }\n\n /****************************************\n * MODIFIERS *\n ****************************************/\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketDeployFactory() {\n if (msg.sender != socketDeployFactory) {\n revert OnlySocketDeployer();\n }\n _;\n }\n\n /****************************************\n * RESTRICTED FUNCTIONS *\n ****************************************/\n\n /**\n * @notice function to rescue the ERC20 tokens in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the bridge Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n function killme() external isSocketDeployFactory {\n selfdestruct(payable(msg.sender));\n }\n\n /******************************\n * VIRTUAL FUNCTIONS *\n *****************************/\n\n /**\n * @notice function to bridge which is succeeding the swap function\n * @notice this function is to be used only when bridging as a succeeding step\n * @notice All bridge implementation contracts must implement this function\n * @notice bridge-implementations will have a bridge specific struct with properties used in bridging\n * @param bridgeData encoded value of properties in the bridgeData Struct\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable virtual;\n}\n"},"src/bridges/cbridge/CelerImpl.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"../../libraries/Pb.sol\";\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"./interfaces/cbridge.sol\";\nimport \"./interfaces/ICelerStorageWrapper.sol\";\nimport {TransferIdExists, InvalidCelerRefund, CelerAlreadyRefunded, CelerRefundNotReady} from \"../../errors/SocketErrors.sol\";\nimport {BridgeImplBase} from \"../BridgeImplBase.sol\";\nimport {CBRIDGE} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Celer-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Celer-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of CelerImplementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract CelerImpl is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable CBridgeIdentifier = CBRIDGE;\n\n /// @notice Utility to perform operation on Buffer\n using Pb for Pb.Buffer;\n\n /// @notice Function-selector for ERC20-token bridging on Celer-Route\n /// @dev This function selector is to be used while building transaction-data to bridge ERC20 tokens\n bytes4 public immutable CELER_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,uint256,bytes32,uint64,uint64,uint32)\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Celer-Route\n /// @dev This function selector is to be used while building transaction-data to bridge Native tokens\n bytes4 public immutable CELER_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,uint256,bytes32,uint64,uint64,uint32)\"\n )\n );\n\n bytes4 public immutable CELER_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,uint64,uint32,uint64,bytes32))\"\n )\n );\n\n /// @notice router Contract instance used to deposit ERC20 and Native on to Celer-Bridge\n /// @dev contract instance is to be initialized in the constructor using the routerAddress passed as constructor argument\n ICBridge public immutable router;\n\n /// @notice celerStorageWrapper Contract instance used to store the transferId generated during ERC20 and Native bridge on to Celer-Bridge\n /// @dev contract instance is to be initialized in the constructor using the celerStorageWrapperAddress passed as constructor argument\n ICelerStorageWrapper public immutable celerStorageWrapper;\n\n /// @notice WETH token address\n address public immutable weth;\n\n /// @notice chainId used during generation of transferId generated while bridging ERC20 and Native on to Celer-Bridge\n /// @dev this is to be initialised in the constructor\n uint64 public immutable chainId;\n\n struct WithdrawMsg {\n uint64 chainid; // tag: 1\n uint64 seqnum; // tag: 2\n address receiver; // tag: 3\n address token; // tag: 4\n uint256 amount; // tag: 5\n bytes32 refid; // tag: 6\n }\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure routerAddress, weth-address, celerStorageWrapperAddress are set properly for the chainId in which the contract is being deployed\n constructor(\n address _routerAddress,\n address _weth,\n address _celerStorageWrapperAddress,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = ICBridge(_routerAddress);\n celerStorageWrapper = ICelerStorageWrapper(_celerStorageWrapperAddress);\n weth = _weth;\n chainId = uint64(block.chainid);\n }\n\n // Function to receive Ether. msg.data must be empty\n receive() external payable {}\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct CelerBridgeDataNoToken {\n address receiverAddress;\n uint64 toChainId;\n uint32 maxSlippage;\n uint64 nonce;\n bytes32 metadata;\n }\n\n struct CelerBridgeData {\n address token;\n address receiverAddress;\n uint64 toChainId;\n uint32 maxSlippage;\n uint64 nonce;\n bytes32 metadata;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for CelerBridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n CelerBridgeData memory celerBridgeData = abi.decode(\n bridgeData,\n (CelerBridgeData)\n );\n\n if (celerBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n weth,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: amount}(\n celerBridgeData.receiverAddress,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n } else {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n celerBridgeData.token,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n router.send(\n celerBridgeData.receiverAddress,\n celerBridgeData.token,\n amount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n }\n\n emit SocketBridge(\n amount,\n celerBridgeData.token,\n celerBridgeData.toChainId,\n CBridgeIdentifier,\n msg.sender,\n celerBridgeData.receiverAddress,\n celerBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in CelerBridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param celerBridgeData encoded data for CelerBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n CelerBridgeDataNoToken calldata celerBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n weth,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: bridgeAmount}(\n celerBridgeData.receiverAddress,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n } else {\n // transferId is generated using the request-params and nonce of the account\n // transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n celerBridgeData.receiverAddress,\n token,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n chainId\n )\n );\n\n // transferId is stored in CelerStorageWrapper with in a mapping where key is transferId and value is the msg-sender\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n router.send(\n celerBridgeData.receiverAddress,\n token,\n bridgeAmount,\n celerBridgeData.toChainId,\n celerBridgeData.nonce,\n celerBridgeData.maxSlippage\n );\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n celerBridgeData.toChainId,\n CBridgeIdentifier,\n msg.sender,\n celerBridgeData.receiverAddress,\n celerBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Celer-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of recipient\n * @param token address of token being bridged\n * @param amount amount of token for bridging\n * @param toChainId destination ChainId\n * @param nonce nonce of the sender-account address\n * @param maxSlippage maximum Slippage for the bridging\n */\n function bridgeERC20To(\n address receiverAddress,\n address token,\n uint256 amount,\n bytes32 metadata,\n uint64 toChainId,\n uint64 nonce,\n uint32 maxSlippage\n ) external payable {\n /// @notice transferId is generated using the request-params and nonce of the account\n /// @notice transferId should be unique for each request and this is used while handling refund from celerBridge\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n receiverAddress,\n token,\n amount,\n toChainId,\n nonce,\n chainId\n )\n );\n\n /// @notice stored in the CelerStorageWrapper contract\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n router.send(\n receiverAddress,\n token,\n amount,\n toChainId,\n nonce,\n maxSlippage\n );\n\n emit SocketBridge(\n amount,\n token,\n toChainId,\n CBridgeIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle Native bridging to receipent via Celer-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param receiverAddress address of recipient\n * @param amount amount of token for bridging\n * @param toChainId destination ChainId\n * @param nonce nonce of the sender-account address\n * @param maxSlippage maximum Slippage for the bridging\n */\n function bridgeNativeTo(\n address receiverAddress,\n uint256 amount,\n bytes32 metadata,\n uint64 toChainId,\n uint64 nonce,\n uint32 maxSlippage\n ) external payable {\n bytes32 transferId = keccak256(\n abi.encodePacked(\n address(this),\n receiverAddress,\n weth,\n amount,\n toChainId,\n nonce,\n chainId\n )\n );\n\n celerStorageWrapper.setAddressForTransferId(transferId, msg.sender);\n\n router.sendNative{value: amount}(\n receiverAddress,\n amount,\n toChainId,\n nonce,\n maxSlippage\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n toChainId,\n CBridgeIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n\n /**\n * @notice function to handle refund from CelerBridge-Router\n * @param _request request data generated offchain using the celer-SDK\n * @param _sigs generated offchain using the celer-SDK\n * @param _signers generated offchain using the celer-SDK\n * @param _powers generated offchain using the celer-SDK\n */\n function refundCelerUser(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable {\n WithdrawMsg memory request = decWithdrawMsg(_request);\n bytes32 transferId = keccak256(\n abi.encodePacked(\n request.chainid,\n request.seqnum,\n request.receiver,\n request.token,\n request.amount\n )\n );\n uint256 _initialNativeBalance = address(this).balance;\n uint256 _initialTokenBalance = ERC20(request.token).balanceOf(\n address(this)\n );\n if (!router.withdraws(transferId)) {\n router.withdraw(_request, _sigs, _signers, _powers);\n }\n\n if (request.receiver != socketGateway) {\n revert InvalidCelerRefund();\n }\n\n address _receiver = celerStorageWrapper.getAddressFromTransferId(\n request.refid\n );\n celerStorageWrapper.deleteTransferId(request.refid);\n\n if (_receiver == address(0)) {\n revert CelerAlreadyRefunded();\n }\n\n uint256 _nativeBalanceAfter = address(this).balance;\n uint256 _tokenBalanceAfter = ERC20(request.token).balanceOf(\n address(this)\n );\n if (_nativeBalanceAfter > _initialNativeBalance) {\n if ((_nativeBalanceAfter - _initialNativeBalance) != request.amount)\n revert CelerRefundNotReady();\n payable(_receiver).transfer(request.amount);\n return;\n }\n\n if (_tokenBalanceAfter > _initialTokenBalance) {\n if ((_tokenBalanceAfter - _initialTokenBalance) != request.amount)\n revert CelerRefundNotReady();\n ERC20(request.token).safeTransfer(_receiver, request.amount);\n return;\n }\n\n revert CelerRefundNotReady();\n }\n\n function decWithdrawMsg(\n bytes memory raw\n ) internal pure returns (WithdrawMsg memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.chainid = uint64(buf.decVarint());\n } else if (tag == 2) {\n m.seqnum = uint64(buf.decVarint());\n } else if (tag == 3) {\n m.receiver = Pb._address(buf.decBytes());\n } else if (tag == 4) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 5) {\n m.amount = Pb._uint256(buf.decBytes());\n } else if (tag == 6) {\n m.refid = Pb._bytes32(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder WithdrawMsg\n}\n"},"src/libraries/LibBytes.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n// Functions taken out from https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol\nlibrary LibBytes {\n // solhint-disable no-inline-assembly\n\n // LibBytes specific errors\n error SliceOverflow();\n error SliceOutOfBounds();\n error AddressOutOfBounds();\n error UintOutOfBounds();\n\n // -------------------------\n\n function concat(\n bytes memory _preBytes,\n bytes memory _postBytes\n ) internal pure returns (bytes memory) {\n bytes memory tempBytes;\n\n assembly {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // Store the length of the first bytes array at the beginning of\n // the memory for tempBytes.\n let length := mload(_preBytes)\n mstore(tempBytes, length)\n\n // Maintain a memory counter for the current write location in the\n // temp bytes array by adding the 32 bytes for the array length to\n // the starting location.\n let mc := add(tempBytes, 0x20)\n // Stop copying when the memory counter reaches the length of the\n // first bytes array.\n let end := add(mc, length)\n\n for {\n // Initialize a copy counter to the start of the _preBytes data,\n // 32 bytes into its memory.\n let cc := add(_preBytes, 0x20)\n } lt(mc, end) {\n // Increase both counters by 32 bytes each iteration.\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // Write the _preBytes data into the tempBytes memory 32 bytes\n // at a time.\n mstore(mc, mload(cc))\n }\n\n // Add the length of _postBytes to the current length of tempBytes\n // and store it as the new length in the first 32 bytes of the\n // tempBytes memory.\n length := mload(_postBytes)\n mstore(tempBytes, add(length, mload(tempBytes)))\n\n // Move the memory counter back from a multiple of 0x20 to the\n // actual end of the _preBytes data.\n mc := end\n // Stop copying when the memory counter reaches the new combined\n // length of the arrays.\n end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n // Update the free-memory pointer by padding our last write location\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\n // next 32 byte block, then round down to the nearest multiple of\n // 32. If the sum of the length of the two arrays is zero then add\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\n mstore(\n 0x40,\n and(\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\n not(31) // Round down to the nearest 32 bytes.\n )\n )\n }\n\n return tempBytes;\n }\n\n function slice(\n bytes memory _bytes,\n uint256 _start,\n uint256 _length\n ) internal pure returns (bytes memory) {\n if (_length + 31 < _length) {\n revert SliceOverflow();\n }\n if (_bytes.length < _start + _length) {\n revert SliceOutOfBounds();\n }\n\n bytes memory tempBytes;\n\n assembly {\n switch iszero(_length)\n case 0 {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // The first word of the slice result is potentially a partial\n // word read from the original array. To read it, we calculate\n // the length of that partial word and start copying that many\n // bytes into the array. The first word we copy will start with\n // data we don't care about, but the last `lengthmod` bytes will\n // land at the beginning of the contents of the new array. When\n // we're done copying, we overwrite the full first word with\n // the actual length of the slice.\n let lengthmod := and(_length, 31)\n\n // The multiplication in the next line is necessary\n // because when slicing multiples of 32 bytes (lengthmod == 0)\n // the following copy loop was copying the origin's length\n // and then ending prematurely not copying everything it should.\n let mc := add(\n add(tempBytes, lengthmod),\n mul(0x20, iszero(lengthmod))\n )\n let end := add(mc, _length)\n\n for {\n // The multiplication in the next line has the same exact purpose\n // as the one above.\n let cc := add(\n add(\n add(_bytes, lengthmod),\n mul(0x20, iszero(lengthmod))\n ),\n _start\n )\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n mstore(tempBytes, _length)\n\n //update free-memory pointer\n //allocating the array padded to 32 bytes like the compiler does now\n mstore(0x40, and(add(mc, 31), not(31)))\n }\n //if we want a zero-length slice let's just return a zero-length array\n default {\n tempBytes := mload(0x40)\n //zero out the 32 bytes slice we are about to return\n //we need to do it because Solidity does not garbage collect\n mstore(tempBytes, 0)\n\n mstore(0x40, add(tempBytes, 0x20))\n }\n }\n\n return tempBytes;\n }\n}\n"},"src/bridges/hyphen/interfaces/hyphen.sol":{"content":"// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * @title HyphenLiquidityPoolManager\n * @notice interface with functions to bridge ERC20 and Native via Hyphen-Bridge\n * @author Socket dot tech.\n */\ninterface HyphenLiquidityPoolManager {\n /**\n * @dev Function used to deposit tokens into pool to initiate a cross chain token transfer.\n * @param toChainId Chain id where funds needs to be transfered\n * @param tokenAddress ERC20 Token address that needs to be transfered\n * @param receiver Address on toChainId where tokens needs to be transfered\n * @param amount Amount of token being transfered\n */\n function depositErc20(\n uint256 toChainId,\n address tokenAddress,\n address receiver,\n uint256 amount,\n string calldata tag\n ) external;\n\n /**\n * @dev Function used to deposit native token into pool to initiate a cross chain token transfer.\n * @param receiver Address on toChainId where tokens needs to be transfered\n * @param toChainId Chain id where funds needs to be transfered\n */\n function depositNative(\n address receiver,\n uint256 toChainId,\n string calldata tag\n ) external payable;\n}\n"},"src/swap/SwapImplBase.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport {ISocketGateway} from \"../interfaces/ISocketGateway.sol\";\nimport {OnlySocketGatewayOwner, OnlySocketDeployer} from \"../errors/SocketErrors.sol\";\n\n/**\n * @title Abstract Implementation Contract.\n * @notice All Swap Implementation will follow this interface.\n * @author Socket dot tech.\n */\nabstract contract SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n /// @notice Address used to identify if it is a native token transfer or not\n address public immutable NATIVE_TOKEN_ADDRESS =\n address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketGateway;\n\n /// @notice immutable variable to store the socketGateway address\n address public immutable socketDeployFactory;\n\n /// @notice FunctionSelector used to delegatecall to the performAction function of swap-router-implementation\n bytes4 public immutable SWAP_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\"performAction(address,address,uint256,address,bytes)\")\n );\n\n /// @notice FunctionSelector used to delegatecall to the performActionWithIn function of swap-router-implementation\n bytes4 public immutable SWAP_WITHIN_FUNCTION_SELECTOR =\n bytes4(keccak256(\"performActionWithIn(address,address,uint256,bytes)\"));\n\n /****************************************\n * EVENTS *\n ****************************************/\n\n event SocketSwapTokens(\n address fromToken,\n address toToken,\n uint256 buyAmount,\n uint256 sellAmount,\n bytes32 routeName,\n address receiver\n );\n\n /**\n * @notice Construct the base for all SwapImplementations.\n * @param _socketGateway Socketgateway address, an immutable variable to set.\n */\n constructor(address _socketGateway, address _socketDeployFactory) {\n socketGateway = _socketGateway;\n socketDeployFactory = _socketDeployFactory;\n }\n\n /****************************************\n * MODIFIERS *\n ****************************************/\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketGatewayOwner() {\n if (msg.sender != ISocketGateway(socketGateway).owner()) {\n revert OnlySocketGatewayOwner();\n }\n _;\n }\n\n /// @notice Implementing contract needs to make use of the modifier where restricted access is to be used\n modifier isSocketDeployFactory() {\n if (msg.sender != socketDeployFactory) {\n revert OnlySocketDeployer();\n }\n _;\n }\n\n /****************************************\n * RESTRICTED FUNCTIONS *\n ****************************************/\n\n /**\n * @notice function to rescue the ERC20 tokens in the Swap-Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param token address of ERC20 token being rescued\n * @param userAddress receipient address to which ERC20 tokens will be rescued to\n * @param amount amount of ERC20 tokens being rescued\n */\n function rescueFunds(\n address token,\n address userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n ERC20(token).safeTransfer(userAddress, amount);\n }\n\n /**\n * @notice function to rescue the native-balance in the Swap-Implementation contract\n * @notice this is a function restricted to Owner of SocketGateway only\n * @param userAddress receipient address to which native-balance will be rescued to\n * @param amount amount of native balance tokens being rescued\n */\n function rescueEther(\n address payable userAddress,\n uint256 amount\n ) external isSocketGatewayOwner {\n userAddress.transfer(amount);\n }\n\n function killme() external isSocketDeployFactory {\n selfdestruct(payable(msg.sender));\n }\n\n /******************************\n * VIRTUAL FUNCTIONS *\n *****************************/\n\n /**\n * @notice function to swap tokens on the chain\n * All swap implementation contracts must implement this function\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param receiverAddress recipient address of toToken\n * @param data encoded value of properties in the swapData Struct\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes memory data\n ) external payable virtual returns (uint256);\n\n /**\n * @notice function to swapWith - swaps tokens on the chain to socketGateway as recipient\n * All swap implementation contracts must implement this function\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes memory swapExtraData\n ) external payable virtual returns (uint256, address);\n}\n"},"src/swap/zerox/ZeroXSwapImpl.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../SwapImplBase.sol\";\nimport {Address0Provided, SwapFailed} from \"../../errors/SocketErrors.sol\";\nimport {ZEROX} from \"../../static/RouteIdentifiers.sol\";\n\n/**\n * @title ZeroX-Swap-Route Implementation\n * @notice Route implementation with functions to swap tokens via ZeroX-Swap\n * Called via SocketGateway if the routeId in the request maps to the routeId of ZeroX-Swap-Implementation\n * @author Socket dot tech.\n */\ncontract ZeroXSwapImpl is SwapImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable ZeroXIdentifier = ZEROX;\n\n /// @notice unique name to identify the router, used to emit event upon successful bridging\n bytes32 public immutable NAME = keccak256(\"Zerox-Router\");\n\n /// @notice address of ZeroX-Exchange-Proxy to swap the tokens on Chain\n address payable public immutable zeroXExchangeProxy;\n\n /// @notice socketGatewayAddress to be initialised via storage variable SwapImplBase\n /// @notice ZeroXExchangeProxy contract is payable to allow ethereum swaps\n /// @dev ensure _zeroXExchangeProxy are set properly for the chainId in which the contract is being deployed\n constructor(\n address _zeroXExchangeProxy,\n address _socketGateway,\n address _socketDeployFactory\n ) SwapImplBase(_socketGateway, _socketDeployFactory) {\n zeroXExchangeProxy = payable(_zeroXExchangeProxy);\n }\n\n receive() external payable {}\n\n fallback() external payable {}\n\n /**\n * @notice function to swap tokens on the chain and transfer to receiver address\n * @dev This is called only when there is a request for a swap.\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken is to be swapped\n * @param amount amount to be swapped\n * @param receiverAddress address of toToken recipient\n * @param swapExtraData data required for zeroX Exchange to get the swap done\n */\n function performAction(\n address fromToken,\n address toToken,\n uint256 amount,\n address receiverAddress,\n bytes calldata swapExtraData\n ) external payable override returns (uint256) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 erc20ToToken = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, address(this), amount);\n token.safeApprove(zeroXExchangeProxy, amount);\n\n // solhint-disable-next-line\n (bool success, ) = zeroXExchangeProxy.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(zeroXExchangeProxy, 0);\n } else {\n (bool success, ) = zeroXExchangeProxy.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n if (toToken == NATIVE_TOKEN_ADDRESS) {\n payable(receiverAddress).transfer(returnAmount);\n } else {\n erc20ToToken.transfer(receiverAddress, returnAmount);\n }\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n ZeroXIdentifier,\n receiverAddress\n );\n\n return returnAmount;\n }\n\n /**\n * @notice function to swapWithIn SocketGateway - swaps tokens on the chain to socketGateway as recipient\n * @param fromToken token to be swapped\n * @param toToken token to which fromToken has to be swapped\n * @param amount amount of fromToken being swapped\n * @param swapExtraData encoded value of properties in the swapData Struct\n * @return swapped amount (in toToken Address)\n */\n function performActionWithIn(\n address fromToken,\n address toToken,\n uint256 amount,\n bytes calldata swapExtraData\n ) external payable override returns (uint256, address) {\n if (fromToken == address(0)) {\n revert Address0Provided();\n }\n\n bytes memory swapCallData = abi.decode(swapExtraData, (bytes));\n\n uint256 _initialBalanceTokenOut;\n uint256 _finalBalanceTokenOut;\n\n ERC20 erc20ToToken = ERC20(toToken);\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _initialBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _initialBalanceTokenOut = address(this).balance;\n }\n\n if (fromToken != NATIVE_TOKEN_ADDRESS) {\n ERC20 token = ERC20(fromToken);\n token.safeTransferFrom(msg.sender, address(this), amount);\n token.safeApprove(zeroXExchangeProxy, amount);\n\n // solhint-disable-next-line\n (bool success, ) = zeroXExchangeProxy.call(swapCallData);\n\n if (!success) {\n revert SwapFailed();\n }\n\n token.safeApprove(zeroXExchangeProxy, 0);\n } else {\n (bool success, ) = zeroXExchangeProxy.call{value: amount}(\n swapCallData\n );\n if (!success) {\n revert SwapFailed();\n }\n }\n\n if (toToken != NATIVE_TOKEN_ADDRESS) {\n _finalBalanceTokenOut = erc20ToToken.balanceOf(address(this));\n } else {\n _finalBalanceTokenOut = address(this).balance;\n }\n\n uint256 returnAmount = _finalBalanceTokenOut - _initialBalanceTokenOut;\n\n emit SocketSwapTokens(\n fromToken,\n toToken,\n returnAmount,\n amount,\n ZeroXIdentifier,\n socketGateway\n );\n\n return (returnAmount, toToken);\n }\n}\n"},"src/bridges/cbridge/interfaces/cbridge.sol":{"content":"// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\ninterface ICBridge {\n function send(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChinId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external;\n\n function sendNative(\n address _receiver,\n uint256 _amount,\n uint64 _dstChinId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external payable;\n\n function withdraws(bytes32 withdrawId) external view returns (bool);\n\n function withdraw(\n bytes calldata _wdmsg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n}\n"},"src/bridges/stargate/l2/Stargate.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport {SafeTransferLib} from \"lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"lib/solmate/src/tokens/ERC20.sol\";\nimport \"../interfaces/stargate.sol\";\nimport \"../../../errors/SocketErrors.sol\";\nimport {BridgeImplBase} from \"../../BridgeImplBase.sol\";\nimport {STARGATE} from \"../../../static/RouteIdentifiers.sol\";\n\n/**\n * @title Stargate-L2-Route Implementation\n * @notice Route implementation with functions to bridge ERC20 and Native via Stargate-L2-Bridge\n * Called via SocketGateway if the routeId in the request maps to the routeId of Stargate-L2-Implementation\n * Contains function to handle bridging as post-step i.e linked to a preceeding step for swap\n * RequestData is different to just bride and bridging chained with swap\n * @author Socket dot tech.\n */\ncontract StargateImplL2 is BridgeImplBase {\n /// @notice SafeTransferLib - library for safe and optimised operations on ERC20 tokens\n using SafeTransferLib for ERC20;\n\n bytes32 public immutable StargateIdentifier = STARGATE;\n\n /// @notice Function-selector for ERC20-token bridging on Stargate-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge ERC20 tokens\n bytes4\n public immutable STARGATE_L2_ERC20_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeERC20To(address,address,address,uint256,uint256,uint256,(uint256,uint256,uint256,uint256,bytes32,bytes,uint16))\"\n )\n );\n\n bytes4 public immutable STARGATE_L1_SWAP_BRIDGE_SELECTOR =\n bytes4(\n keccak256(\n \"swapAndBridge(uint32,bytes,(address,address,uint16,uint256,uint256,uint256,uint256,uint256,uint256,bytes32,bytes))\"\n )\n );\n\n /// @notice Function-selector for Native bridging on Stargate-L2-Route\n /// @dev This function selector is to be used while buidling transaction-data to bridge Native tokens\n bytes4\n public immutable STARGATE_L2_NATIVE_EXTERNAL_BRIDGE_FUNCTION_SELECTOR =\n bytes4(\n keccak256(\n \"bridgeNativeTo(address,address,uint16,uint256,uint256,uint256,bytes32)\"\n )\n );\n\n /// @notice Stargate Router to bridge ERC20 tokens\n IBridgeStargate public immutable router;\n\n /// @notice Stargate Router to bridge native tokens\n IBridgeStargate public immutable routerETH;\n\n /// @notice socketGatewayAddress to be initialised via storage variable BridgeImplBase\n /// @dev ensure router, routerEth are set properly for the chainId in which the contract is being deployed\n constructor(\n address _router,\n address _routerEth,\n address _socketGateway,\n address _socketDeployFactory\n ) BridgeImplBase(_socketGateway, _socketDeployFactory) {\n router = IBridgeStargate(_router);\n routerETH = IBridgeStargate(_routerEth);\n }\n\n /// @notice Struct to be used as a input parameter for Bridging tokens via Stargate-L2-route\n /// @dev while building transactionData,values should be set in this sequence of properties in this struct\n struct StargateBridgeExtraData {\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 destinationGasLimit;\n uint256 minReceivedAmt;\n bytes32 metadata;\n bytes destinationPayload;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n }\n\n /// @notice Struct to be used in decode step from input parameter - a specific case of bridging after swap.\n /// @dev the data being encoded in offchain or by caller should have values set in this sequence of properties in this struct\n struct StargateBridgeDataNoToken {\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n struct StargateBridgeData {\n address token;\n address receiverAddress;\n address senderAddress;\n uint16 stargateDstChainId; // stargate defines chain id in its way\n uint256 value;\n // a unique identifier that is uses to dedup transfers\n // this value is the a timestamp sent from frontend, but in theory can be any unique number\n uint256 srcPoolId;\n uint256 dstPoolId;\n uint256 minReceivedAmt; // defines the slippage, the min qty you would accept on the destination\n uint256 optionalValue;\n uint256 destinationGasLimit;\n bytes32 metadata;\n bytes destinationPayload;\n }\n\n /**\n * @notice function to bridge tokens after swap.\n * @notice this is different from swapAndBridge, this function is called when the swap has already happened at a different place.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param amount amount of tokens being bridged. this can be ERC20 or native\n * @param bridgeData encoded data for Stargate-L1-Bridge\n */\n function bridgeAfterSwap(\n uint256 amount,\n bytes calldata bridgeData\n ) external payable override {\n StargateBridgeData memory stargateBridgeData = abi.decode(\n bridgeData,\n (StargateBridgeData)\n );\n\n if (stargateBridgeData.token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + stargateBridgeData.optionalValue}(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n amount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(stargateBridgeData.token).safeApprove(\n address(router),\n amount\n );\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n amount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n stargateBridgeData.token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to bridge tokens after swapping.\n * @notice this is different from bridgeAfterSwap since this function holds the logic for swapping tokens too.\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @dev for usage, refer to controller implementations\n * encodedData for bridge should follow the sequence of properties in Stargate-BridgeData struct\n * @param swapId routeId for the swapImpl\n * @param swapData encoded data for swap\n * @param stargateBridgeData encoded data for StargateBridgeData\n */\n function swapAndBridge(\n uint32 swapId,\n bytes calldata swapData,\n StargateBridgeDataNoToken calldata stargateBridgeData\n ) external payable {\n (bool success, bytes memory result) = socketRoute\n .getRoute(swapId)\n .delegatecall(swapData);\n\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n\n (uint256 bridgeAmount, address token) = abi.decode(\n result,\n (uint256, address)\n );\n\n if (token == NATIVE_TOKEN_ADDRESS) {\n routerETH.swapETH{\n value: bridgeAmount + stargateBridgeData.optionalValue\n }(\n stargateBridgeData.stargateDstChainId,\n payable(stargateBridgeData.senderAddress),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n bridgeAmount,\n stargateBridgeData.minReceivedAmt\n );\n } else {\n ERC20(token).safeApprove(address(router), bridgeAmount);\n {\n router.swap{value: stargateBridgeData.value}(\n stargateBridgeData.stargateDstChainId,\n stargateBridgeData.srcPoolId,\n stargateBridgeData.dstPoolId,\n payable(stargateBridgeData.senderAddress), // default to refund to main contract\n bridgeAmount,\n stargateBridgeData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeData.destinationGasLimit,\n 0,\n \"0x\"\n ),\n abi.encodePacked(stargateBridgeData.receiverAddress),\n stargateBridgeData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n bridgeAmount,\n token,\n stargateBridgeData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n stargateBridgeData.receiverAddress,\n stargateBridgeData.metadata\n );\n }\n\n /**\n * @notice function to handle ERC20 bridging to receipent via Stargate-L1-Bridge\n * @notice This method is payable because the caller is doing token transfer and briding operation\n * @param token address of token being bridged\n * @param senderAddress address of sender\n * @param receiverAddress address of recipient\n * @param amount amount of token being bridge\n * @param value value\n * @param optionalValue optionalValue\n * @param stargateBridgeExtraData stargate bridge extradata\n */\n function bridgeERC20To(\n address token,\n address senderAddress,\n address receiverAddress,\n uint256 amount,\n uint256 value,\n uint256 optionalValue,\n StargateBridgeExtraData calldata stargateBridgeExtraData\n ) external payable {\n // token address might not be indication thats why passed through extraData\n if (token == NATIVE_TOKEN_ADDRESS) {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateBridgeExtraData.stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n stargateBridgeExtraData.minReceivedAmt\n );\n } else {\n ERC20 tokenInstance = ERC20(token);\n tokenInstance.safeTransferFrom(msg.sender, socketGateway, amount);\n tokenInstance.safeApprove(address(router), amount);\n {\n router.swap{value: value}(\n stargateBridgeExtraData.stargateDstChainId,\n stargateBridgeExtraData.srcPoolId,\n stargateBridgeExtraData.dstPoolId,\n payable(senderAddress), // default to refund to main contract\n amount,\n stargateBridgeExtraData.minReceivedAmt,\n IBridgeStargate.lzTxObj(\n stargateBridgeExtraData.destinationGasLimit,\n 0, // zero amount since this is a ERC20 bridging\n \"0x\" //empty data since this is for only ERC20\n ),\n abi.encodePacked(receiverAddress),\n stargateBridgeExtraData.destinationPayload\n );\n }\n }\n\n emit SocketBridge(\n amount,\n token,\n stargateBridgeExtraData.stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n stargateBridgeExtraData.metadata\n );\n }\n\n function bridgeNativeTo(\n address receiverAddress,\n address senderAddress,\n uint16 stargateDstChainId,\n uint256 amount,\n uint256 minReceivedAmt,\n uint256 optionalValue,\n bytes32 metadata\n ) external payable {\n // perform bridging\n routerETH.swapETH{value: amount + optionalValue}(\n stargateDstChainId,\n payable(senderAddress),\n abi.encodePacked(receiverAddress),\n amount,\n minReceivedAmt\n );\n\n emit SocketBridge(\n amount,\n NATIVE_TOKEN_ADDRESS,\n stargateDstChainId,\n StargateIdentifier,\n msg.sender,\n receiverAddress,\n metadata\n );\n }\n}\n"}},"settings":{"optimizer":{"enabled":true,"runs":1000000},"outputSelection":{"*":{"*":["evm.bytecode","evm.deployedBytecode","devdoc","userdoc","metadata","abi"]}},"metadata":{"useLiteralContent":true},"libraries":{}}},"ABI":"[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_disabledRoute\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ArrayLengthMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"IncorrectBridgeRatios\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyNominee\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddressNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"controllerAddress\",\"type\":\"address\"}],\"name\":\"ControllerAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"ControllerDisabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"route\",\"type\":\"address\"}],\"name\":\"NewRouteAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"claimer\",\"type\":\"address\"}],\"name\":\"OwnerClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"nominee\",\"type\":\"address\"}],\"name\":\"OwnerNominated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}],\"name\":\"OwnershipTransferRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"RouteDisabled\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"BRIDGE_AFTER_SWAP_SELECTOR\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"CENT_PERCENT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"controllerAddress\",\"type\":\"address\"}],\"name\":\"addController\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"routeAddress\",\"type\":\"address\"}],\"name\":\"addRoute\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"addressAt\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controllerCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"controllers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"disableController\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"disableRoute\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"disabledRouteAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct ISocketGateway.SocketControllerRequest\",\"name\":\"socketControllerRequest\",\"type\":\"tuple\"}],\"name\":\"executeController\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct ISocketGateway.SocketControllerRequest[]\",\"name\":\"controllerRequests\",\"type\":\"tuple[]\"}],\"name\":\"executeControllers\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"routeData\",\"type\":\"bytes\"}],\"name\":\"executeRoute\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32[]\",\"name\":\"routeIds\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes[]\",\"name\":\"dataItems\",\"type\":\"bytes[]\"}],\"name\":\"executeRoutes\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"controllerId\",\"type\":\"uint32\"}],\"name\":\"getController\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"routeId\",\"type\":\"uint32\"}],\"name\":\"getRoute\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nominee_\",\"type\":\"address\"}],\"name\":\"nominateOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nominee\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"rescueEther\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"rescueFunds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"routes\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"routesCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"routeAddresses\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"tokenAddresses\",\"type\":\"address[]\"},{\"internalType\":\"bool\",\"name\":\"isMax\",\"type\":\"bool\"}],\"name\":\"setApprovalForRouters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"swapRouteId\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"swapImplData\",\"type\":\"bytes\"},{\"internalType\":\"uint32[]\",\"name\":\"bridgeRouteIds\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes[]\",\"name\":\"bridgeImplDataItems\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256[]\",\"name\":\"bridgeRatios\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"eventDataItems\",\"type\":\"bytes[]\"}],\"internalType\":\"struct ISocketRequest.SwapMultiBridgeRequest\",\"name\":\"swapMultiBridgeRequest\",\"type\":\"tuple\"}],\"name\":\"swapAndMultiBridge\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]","ContractName":"SocketGateway","CompilerVersion":"v0.8.7+commit.e28d00a7","OptimizationUsed":1,"Runs":1000000,"ConstructorArguments":"0x000000000000000000000000e8dd38e673a93ccfc2e3d7053efccb5c93f493650000000000000000000000000f34a522ff82151c90679b73211955068fd854f1","EVMVersion":"Default","Library":"","LicenseType":"","Proxy":1,"Implementation":"0xa3c4e32af0da5efaddb20cc9fb26159f55c8c42f","SwarmSource":""}] \ No newline at end of file diff --git a/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json index b3976447f2486..08b838e2bc418 100644 --- a/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json +++ b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json @@ -1,5 +1 @@ -{ - "contractAddress": "0x71356e37e0368bd10bfdbf41dc052fe5fa24cd05", - "contractCreator": "0xaa1d342354d755ec515f40e7d5e83cb4184bb9ee", - "txHash": "0x1c800c2c2d5230823602cae6896a8db1ab7d1341ca697c6c64d9f0edf11dabe2" -} \ No newline at end of file +{"contractAddress":"0x71356e37e0368bd10bfdbf41dc052fe5fa24cd05","contractCreator":"0xaa1d342354d755ec515f40e7d5e83cb4184bb9ee","txHash":"0x1c800c2c2d5230823602cae6896a8db1ab7d1341ca697c6c64d9f0edf11dabe2"} \ No newline at end of file diff --git a/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json index cc890a5711229..08318ba41edfe 100644 --- a/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json +++ b/testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/metadata.json @@ -1,129 +1 @@ -[ - { - "SourceCode": { - "language": "Solidity", - "sources": { - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts/utils/StorageSlot.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "contracts/v0.8/extensions/GatewayV2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"../interfaces/IQuorum.sol\";\nimport \"../interfaces/IWeightedValidator.sol\";\nimport \"./HasProxyAdmin.sol\";\n\nabstract contract GatewayV2 is HasProxyAdmin, Pausable, IQuorum {\n /// @dev Emitted when the validator contract address is updated.\n event ValidatorContractUpdated(IWeightedValidator);\n\n uint256 internal _num;\n uint256 internal _denom;\n\n IWeightedValidator public validatorContract;\n uint256 public nonce;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev See {IQuorum-getThreshold}.\n */\n function getThreshold() external view virtual returns (uint256, uint256) {\n return (_num, _denom);\n }\n\n /**\n * @dev See {IQuorum-checkThreshold}.\n */\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _denom >= _num * validatorContract.totalWeights();\n }\n\n /**\n * @dev See {IQuorum-setThreshold}.\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n onlyAdmin\n returns (uint256, uint256)\n {\n return _setThreshold(_numerator, _denominator);\n }\n\n /**\n * @dev Triggers paused state.\n */\n function pause() external onlyAdmin {\n _pause();\n }\n\n /**\n * @dev Triggers unpaused state.\n */\n function unpause() external onlyAdmin {\n _unpause();\n }\n\n /**\n * @dev Sets validator contract address.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ValidatorContractUpdated` event.\n *\n */\n function setValidatorContract(IWeightedValidator _validatorContract) external virtual onlyAdmin {\n _setValidatorContract(_validatorContract);\n }\n\n /**\n * @dev See {IQuorum-minimumVoteWeight}.\n */\n function minimumVoteWeight() public view virtual returns (uint256) {\n return _minimumVoteWeight(validatorContract.totalWeights());\n }\n\n /**\n * @dev Sets validator contract address.\n *\n * Emits the `ValidatorContractUpdated` event.\n *\n */\n function _setValidatorContract(IWeightedValidator _validatorContract) internal virtual {\n validatorContract = _validatorContract;\n emit ValidatorContractUpdated(_validatorContract);\n }\n\n /**\n * @dev Sets threshold and returns the old one.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function _setThreshold(uint256 _numerator, uint256 _denominator)\n internal\n virtual\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n require(_numerator <= _denominator, \"GatewayV2: invalid threshold\");\n _previousNum = _num;\n _previousDenom = _denom;\n _num = _numerator;\n _denom = _denominator;\n emit ThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n\n /**\n * @dev Returns minimum vote weight.\n */\n function _minimumVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_num * _totalWeight + _denom - 1) / _denom;\n }\n}\n" - }, - "@openzeppelin/contracts/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n // contract may have been reentered.\n require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} modifier, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n function _isConstructor() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" - }, - "contracts/v0.8/extensions/WithdrawalLimitation.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./GatewayV2.sol\";\n\nabstract contract WithdrawalLimitation is GatewayV2 {\n /// @dev Emitted when the high-tier vote weight threshold is updated\n event HighTierVoteWeightThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n /// @dev Emitted when the thresholds for high-tier withdrawals that requires high-tier vote weights are updated\n event HighTierThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the thresholds for locked withdrawals are updated\n event LockedThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the fee percentages to unlock withdraw are updated\n event UnlockFeePercentagesUpdated(address[] tokens, uint256[] percentages);\n /// @dev Emitted when the daily limit thresholds are updated\n event DailyWithdrawalLimitsUpdated(address[] tokens, uint256[] limits);\n\n uint256 public constant _MAX_PERCENTAGE = 1_000_000;\n\n uint256 internal _highTierVWNum;\n uint256 internal _highTierVWDenom;\n\n /// @dev Mapping from mainchain token => the amount thresholds for high-tier withdrawals that requires high-tier vote weights\n mapping(address => uint256) public highTierThreshold;\n /// @dev Mapping from mainchain token => the amount thresholds to lock withdrawal\n mapping(address => uint256) public lockedThreshold;\n /// @dev Mapping from mainchain token => unlock fee percentages for unlocker\n /// @notice Values 0-1,000,000 map to 0%-100%\n mapping(address => uint256) public unlockFeePercentages;\n /// @dev Mapping from mainchain token => daily limit amount for withdrawal\n mapping(address => uint256) public dailyWithdrawalLimit;\n /// @dev Mapping from token address => today withdrawal amount\n mapping(address => uint256) public lastSyncedWithdrawal;\n /// @dev Mapping from token address => last date synced to record the `lastSyncedWithdrawal`\n mapping(address => uint256) public lastDateSynced;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev Override {GatewayV2-setThreshold}.\n *\n * Requirements:\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n override\n onlyAdmin\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n (_previousNum, _previousDenom) = _setThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Returns the high-tier vote weight threshold.\n */\n function getHighTierVoteWeightThreshold() external view virtual returns (uint256, uint256) {\n return (_highTierVWNum, _highTierVWDenom);\n }\n\n /**\n * @dev Checks whether the `_voteWeight` passes the high-tier vote weight threshold.\n */\n function checkHighTierVoteWeightThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _highTierVWDenom >= _highTierVWNum * validatorContract.totalWeights();\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Requirements:\n * - The method caller is admin.\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n onlyAdmin\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n (_previousNum, _previousDenom) = _setHighTierVoteWeightThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds)\n external\n virtual\n onlyAdmin\n {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setHighTierThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyAdmin {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setLockedThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages)\n external\n virtual\n onlyAdmin\n {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setUnlockFeePercentages(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) external virtual onlyAdmin {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setDailyWithdrawalLimits(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the limitation.\n */\n function reachedWithdrawalLimit(address _token, uint256 _quantity) external view virtual returns (bool) {\n return _reachedWithdrawalLimit(_token, _quantity);\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function _setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator)\n internal\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n require(_numerator <= _denominator, \"WithdrawalLimitation: invalid threshold\");\n _previousNum = _highTierVWNum;\n _previousDenom = _highTierVWDenom;\n _highTierVWNum = _numerator;\n _highTierVWDenom = _denominator;\n emit HighTierVoteWeightThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function _setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n require(_tokens.length == _thresholds.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n highTierThreshold[_tokens[_i]] = _thresholds[_i];\n }\n emit HighTierThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function _setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n require(_tokens.length == _thresholds.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n lockedThreshold[_tokens[_i]] = _thresholds[_i];\n }\n emit LockedThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n * - The percentage is equal to or less than 100_000.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function _setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) internal virtual {\n require(_tokens.length == _percentages.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n require(_percentages[_i] <= _MAX_PERCENTAGE, \"WithdrawalLimitation: invalid percentage\");\n unlockFeePercentages[_tokens[_i]] = _percentages[_i];\n }\n emit UnlockFeePercentagesUpdated(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function _setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) internal virtual {\n require(_tokens.length == _limits.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n dailyWithdrawalLimit[_tokens[_i]] = _limits[_i];\n }\n emit DailyWithdrawalLimitsUpdated(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the daily limitation.\n *\n * Requirements:\n * - The daily withdrawal threshold should not apply for locked withdrawals.\n *\n */\n function _reachedWithdrawalLimit(address _token, uint256 _quantity) internal view virtual returns (bool) {\n if (_lockedWithdrawalRequest(_token, _quantity)) {\n return false;\n }\n\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n return dailyWithdrawalLimit[_token] <= _quantity;\n } else {\n return dailyWithdrawalLimit[_token] <= lastSyncedWithdrawal[_token] + _quantity;\n }\n }\n\n /**\n * @dev Record withdrawal token.\n */\n function _recordWithdrawal(address _token, uint256 _quantity) internal virtual {\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n lastDateSynced[_token] = _currentDate;\n lastSyncedWithdrawal[_token] = _quantity;\n } else {\n lastSyncedWithdrawal[_token] += _quantity;\n }\n }\n\n /**\n * @dev Returns whether the withdrawal request is locked or not.\n */\n function _lockedWithdrawalRequest(address _token, uint256 _quantity) internal view virtual returns (bool) {\n return lockedThreshold[_token] <= _quantity;\n }\n\n /**\n * @dev Computes fee percentage.\n */\n function _computeFeePercentage(uint256 _amount, uint256 _percentage) internal view virtual returns (uint256) {\n return (_amount * _percentage) / _MAX_PERCENTAGE;\n }\n\n /**\n * @dev Returns high-tier vote weight.\n */\n function _highTierVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_highTierVWNum * _totalWeight + _highTierVWDenom - 1) / _highTierVWDenom;\n }\n\n /**\n * @dev Validates whether the high-tier vote weight threshold is larger than the normal threshold.\n */\n function _verifyThresholds() internal view {\n require(_num * _highTierVWDenom <= _highTierVWNum * _denom, \"WithdrawalLimitation: invalid thresholds\");\n }\n}\n" - }, - "contracts/v0.8/interfaces/MappedTokenConsumer.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../library/Token.sol\";\n\ninterface MappedTokenConsumer {\n struct MappedToken {\n Token.Standard erc;\n address tokenAddr;\n }\n}\n" - }, - "contracts/v0.8/library/Token.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nlibrary Token {\n enum Standard {\n ERC20,\n ERC721\n }\n struct Info {\n Standard erc;\n // For ERC20: the id must be 0 and the quantity is larger than 0.\n // For ERC721: the quantity must be 0.\n uint256 id;\n uint256 quantity;\n }\n\n // keccak256(\"TokenInfo(uint8 erc,uint256 id,uint256 quantity)\");\n bytes32 public constant INFO_TYPE_HASH = 0x1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Info memory _info) internal pure returns (bytes32) {\n return keccak256(abi.encode(INFO_TYPE_HASH, _info.erc, _info.id, _info.quantity));\n }\n\n /**\n * @dev Validates the token info.\n */\n function validate(Info memory _info) internal pure {\n require(\n (_info.erc == Standard.ERC20 && _info.quantity > 0 && _info.id == 0) ||\n (_info.erc == Standard.ERC721 && _info.quantity == 0),\n \"Token: invalid info\"\n );\n }\n\n /**\n * @dev Transfer asset from.\n *\n * Requirements:\n * - The `_from` address must approve for the contract using this library.\n *\n */\n function transferFrom(\n Info memory _info,\n address _from,\n address _to,\n address _token\n ) internal {\n bool _success;\n bytes memory _data;\n if (_info.erc == Standard.ERC20) {\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, _from, _to, _info.quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n } else if (_info.erc == Standard.ERC721) {\n // bytes4(keccak256(\"transferFrom(address,address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x23b872dd, _from, _to, _info.id));\n } else {\n revert(\"Token: unsupported token standard\");\n }\n\n if (!_success) {\n revert(\n string(\n abi.encodePacked(\n \"Token: could not transfer \",\n toString(_info),\n \" from \",\n Strings.toHexString(uint160(_from), 20),\n \" to \",\n Strings.toHexString(uint160(_to), 20),\n \" token \",\n Strings.toHexString(uint160(_token), 20)\n )\n )\n );\n }\n }\n\n /**\n * @dev Transfers ERC721 token and returns the result.\n */\n function tryTransferERC721(\n address _token,\n address _to,\n uint256 _id\n ) internal returns (bool _success) {\n (_success, ) = _token.call(abi.encodeWithSelector(IERC721.transferFrom.selector, address(this), _to, _id));\n }\n\n /**\n * @dev Transfers ERC20 token and returns the result.\n */\n function tryTransferERC20(\n address _token,\n address _to,\n uint256 _quantity\n ) internal returns (bool _success) {\n bytes memory _data;\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transfer.selector, _to, _quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n }\n\n /**\n * @dev Transfer assets from current address to `_to` address.\n */\n function transfer(\n Info memory _info,\n address _to,\n address _token\n ) internal {\n bool _success;\n if (_info.erc == Standard.ERC20) {\n _success = tryTransferERC20(_token, _to, _info.quantity);\n } else if (_info.erc == Standard.ERC721) {\n _success = tryTransferERC721(_token, _to, _info.id);\n } else {\n revert(\"Token: unsupported token standard\");\n }\n\n if (!_success) {\n revert(\n string(\n abi.encodePacked(\n \"Token: could not transfer \",\n toString(_info),\n \" to \",\n Strings.toHexString(uint160(_to), 20),\n \" token \",\n Strings.toHexString(uint160(_token), 20)\n )\n )\n );\n }\n }\n\n /**\n * @dev Tries minting and transfering assets.\n *\n * @notice Prioritizes transfer native token if the token is wrapped.\n *\n */\n function handleAssetTransfer(\n Info memory _info,\n address payable _to,\n address _token,\n IWETH _wrappedNativeToken\n ) internal {\n bool _success;\n if (_token == address(_wrappedNativeToken)) {\n // Try sending the native token before transferring the wrapped token\n if (!_to.send(_info.quantity)) {\n _wrappedNativeToken.deposit{ value: _info.quantity }();\n transfer(_info, _to, _token);\n }\n } else if (_info.erc == Token.Standard.ERC20) {\n uint256 _balance = IERC20(_token).balanceOf(address(this));\n\n if (_balance < _info.quantity) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, address(this), _info.quantity - _balance));\n require(_success, \"Token: ERC20 minting failed\");\n }\n\n transfer(_info, _to, _token);\n } else if (_info.erc == Token.Standard.ERC721) {\n if (!tryTransferERC721(_token, _to, _info.id)) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, _to, _info.id));\n require(_success, \"Token: ERC721 minting failed\");\n }\n } else {\n revert(\"Token: unsupported token standard\");\n }\n }\n\n /**\n * @dev Returns readable string.\n */\n function toString(Info memory _info) internal pure returns (string memory) {\n return\n string(\n abi.encodePacked(\n \"TokenInfo(\",\n Strings.toHexString(uint160(_info.erc), 1),\n \",\",\n Strings.toHexString(_info.id),\n \",\",\n Strings.toHexString(_info.quantity),\n \")\"\n )\n );\n }\n\n struct Owner {\n address addr;\n address tokenAddr;\n uint256 chainId;\n }\n\n // keccak256(\"TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant OWNER_TYPE_HASH = 0x353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764;\n\n /**\n * @dev Returns ownership struct hash.\n */\n function hash(Owner memory _owner) internal pure returns (bytes32) {\n return keccak256(abi.encode(OWNER_TYPE_HASH, _owner.addr, _owner.tokenAddr, _owner.chainId));\n }\n}\n" - }, - "contracts/v0.8/mainchain/IMainchainGatewayV2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../interfaces/IWETH.sol\";\nimport \"../library/Transfer.sol\";\nimport \"../interfaces/SignatureConsumer.sol\";\nimport \"../interfaces/MappedTokenConsumer.sol\";\n\ninterface IMainchainGatewayV2 is SignatureConsumer, MappedTokenConsumer {\n /// @dev Emitted when the deposit is requested\n event DepositRequested(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the assets are withdrawn\n event Withdrew(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the tokens are mapped\n event TokenMapped(address[] mainchainTokens, address[] roninTokens, Token.Standard[] standards);\n /// @dev Emitted when the wrapped native token contract is updated\n event WrappedNativeTokenContractUpdated(IWETH weth);\n /// @dev Emitted when the withdrawal is locked\n event WithdrawalLocked(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the withdrawal is unlocked\n event WithdrawalUnlocked(bytes32 receiptHash, Transfer.Receipt receipt);\n\n /**\n * @dev Returns the domain seperator.\n */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /**\n * @dev Returns deposit count.\n */\n function depositCount() external view returns (uint256);\n\n /**\n * @dev Sets the wrapped native token contract.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external;\n\n /**\n * @dev Returns whether the withdrawal is locked.\n */\n function withdrawalLocked(uint256 withdrawalId) external view returns (bool);\n\n /**\n * @dev Returns the withdrawal hash.\n */\n function withdrawalHash(uint256 withdrawalId) external view returns (bytes32);\n\n /**\n * @dev Locks the assets and request deposit.\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable;\n\n /**\n * @dev Withdraws based on the receipt and the validator signatures.\n * Returns whether the withdrawal is locked.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function submitWithdrawal(Transfer.Receipt memory _receipt, Signature[] memory _signatures)\n external\n returns (bool _locked);\n\n /**\n * @dev Approves a specific withdrawal.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network and sets thresholds.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n uint256[][4] calldata _thresholds\n ) external;\n\n /**\n * @dev Returns token address on Ronin network.\n * @notice Reverts for unsupported token.\n */\n function getRoninToken(address _mainchainToken) external view returns (MappedToken memory _token);\n}\n" - }, - "contracts/v0.8/mainchain/MainchainGatewayV2.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../extensions/GatewayV2.sol\";\nimport \"../extensions/WithdrawalLimitation.sol\";\nimport \"../library/Transfer.sol\";\nimport \"./IMainchainGatewayV2.sol\";\n\ncontract MainchainGatewayV2 is WithdrawalLimitation, Initializable, AccessControlEnumerable, IMainchainGatewayV2 {\n using Token for Token.Info;\n using Transfer for Transfer.Request;\n using Transfer for Transfer.Receipt;\n\n /// @dev Withdrawal unlocker role hash\n bytes32 public constant WITHDRAWAL_UNLOCKER_ROLE = keccak256(\"WITHDRAWAL_UNLOCKER_ROLE\");\n\n /// @dev Wrapped native token address\n IWETH public wrappedNativeToken;\n /// @dev Ronin network id\n uint256 public roninChainId;\n /// @dev Total deposit\n uint256 public depositCount;\n /// @dev Domain seperator\n bytes32 internal _domainSeparator;\n /// @dev Mapping from mainchain token => token address on Ronin network\n mapping(address => MappedToken) internal _roninToken;\n /// @dev Mapping from withdrawal id => withdrawal hash\n mapping(uint256 => bytes32) public withdrawalHash;\n /// @dev Mapping from withdrawal id => locked\n mapping(uint256 => bool) public withdrawalLocked;\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n /**\n * @dev Initializes contract storage.\n */\n function initialize(\n address _roleSetter,\n IWETH _wrappedToken,\n IWeightedValidator _validatorContract,\n uint256 _roninChainId,\n uint256 _numerator,\n uint256 _highTierVWNumerator,\n uint256 _denominator,\n // _addresses[0]: mainchainTokens\n // _addresses[1]: roninTokens\n // _addresses[2]: withdrawalUnlockers\n address[][3] calldata _addresses,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds,\n Token.Standard[] calldata _standards\n ) external payable virtual initializer {\n _setupRole(DEFAULT_ADMIN_ROLE, _roleSetter);\n roninChainId = _roninChainId;\n\n _setWrappedNativeTokenContract(_wrappedToken);\n _setValidatorContract(_validatorContract);\n _updateDomainSeparator();\n _setThreshold(_numerator, _denominator);\n _setHighTierVoteWeightThreshold(_highTierVWNumerator, _denominator);\n _verifyThresholds();\n\n if (_addresses[0].length > 0) {\n // Map mainchain tokens to ronin tokens\n _mapTokens(_addresses[0], _addresses[1], _standards);\n // Sets thresholds based on the mainchain tokens\n _setHighTierThresholds(_addresses[0], _thresholds[0]);\n _setLockedThresholds(_addresses[0], _thresholds[1]);\n _setUnlockFeePercentages(_addresses[0], _thresholds[2]);\n _setDailyWithdrawalLimits(_addresses[0], _thresholds[3]);\n }\n\n // Grant role for withdrawal unlocker\n for (uint256 _i; _i < _addresses[2].length; _i++) {\n _grantRole(WITHDRAWAL_UNLOCKER_ROLE, _addresses[2][_i]);\n }\n }\n\n /**\n * @dev Receives ether without doing anything. Use this function to topup native token.\n */\n function receiveEther() external payable {}\n\n /**\n * @dev See {IMainchainGatewayV2-DOMAIN_SEPARATOR}.\n */\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparator;\n }\n\n /**\n * @dev See {IMainchainGatewayV2-setWrappedNativeTokenContract}.\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external virtual onlyAdmin {\n _setWrappedNativeTokenContract(_wrappedToken);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-requestDepositFor}.\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable virtual whenNotPaused {\n _requestDepositFor(_request, msg.sender);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-submitWithdrawal}.\n */\n function submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] calldata _signatures)\n external\n virtual\n whenNotPaused\n returns (bool _locked)\n {\n return _submitWithdrawal(_receipt, _signatures);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-unlockWithdrawal}.\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external onlyRole(WITHDRAWAL_UNLOCKER_ROLE) {\n bytes32 _receiptHash = _receipt.hash();\n require(withdrawalHash[_receipt.id] == _receipt.hash(), \"MainchainGatewayV2: invalid receipt\");\n require(withdrawalLocked[_receipt.id], \"MainchainGatewayV2: query for approved withdrawal\");\n delete withdrawalLocked[_receipt.id];\n emit WithdrawalUnlocked(_receiptHash, _receipt);\n\n address _token = _receipt.mainchain.tokenAddr;\n if (_receipt.info.erc == Token.Standard.ERC20) {\n Token.Info memory _feeInfo = _receipt.info;\n _feeInfo.quantity = _computeFeePercentage(_receipt.info.quantity, unlockFeePercentages[_token]);\n Token.Info memory _withdrawInfo = _receipt.info;\n _withdrawInfo.quantity = _receipt.info.quantity - _feeInfo.quantity;\n\n _feeInfo.handleAssetTransfer(payable(msg.sender), _token, wrappedNativeToken);\n _withdrawInfo.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n } else {\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n }\n\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-mapTokens}.\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external virtual onlyAdmin {\n require(_mainchainTokens.length > 0, \"MainchainGatewayV2: query for empty array\");\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-mapTokensAndThresholds}.\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds\n ) external virtual onlyAdmin {\n require(_mainchainTokens.length > 0, \"MainchainGatewayV2: query for empty array\");\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n _setHighTierThresholds(_mainchainTokens, _thresholds[0]);\n _setLockedThresholds(_mainchainTokens, _thresholds[1]);\n _setUnlockFeePercentages(_mainchainTokens, _thresholds[2]);\n _setDailyWithdrawalLimits(_mainchainTokens, _thresholds[3]);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-getRoninToken}.\n */\n function getRoninToken(address _mainchainToken) public view returns (MappedToken memory _token) {\n _token = _roninToken[_mainchainToken];\n require(_token.tokenAddr != address(0), \"MainchainGatewayV2: unsupported token\");\n }\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The arrays have the same length.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function _mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) internal virtual {\n require(\n _mainchainTokens.length == _roninTokens.length && _mainchainTokens.length == _standards.length,\n \"MainchainGatewayV2: invalid array length\"\n );\n\n for (uint256 _i; _i < _mainchainTokens.length; _i++) {\n _roninToken[_mainchainTokens[_i]].tokenAddr = _roninTokens[_i];\n _roninToken[_mainchainTokens[_i]].erc = _standards[_i];\n }\n\n emit TokenMapped(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @dev Submits withdrawal receipt.\n *\n * Requirements:\n * - The receipt kind is withdrawal.\n * - The receipt is to withdraw on this chain.\n * - The receipt is not used to withdraw before.\n * - The withdrawal is not reached the limit threshold.\n * - The signer weight total is larger than or equal to the minimum threshold.\n * - The signature signers are in order.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function _submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] memory _signatures)\n internal\n virtual\n returns (bool _locked)\n {\n uint256 _id = _receipt.id;\n uint256 _quantity = _receipt.info.quantity;\n address _tokenAddr = _receipt.mainchain.tokenAddr;\n\n _receipt.info.validate();\n require(_receipt.kind == Transfer.Kind.Withdrawal, \"MainchainGatewayV2: invalid receipt kind\");\n require(_receipt.mainchain.chainId == block.chainid, \"MainchainGatewayV2: invalid chain id\");\n MappedToken memory _token = getRoninToken(_receipt.mainchain.tokenAddr);\n require(\n _token.erc == _receipt.info.erc && _token.tokenAddr == _receipt.ronin.tokenAddr,\n \"MainchainGatewayV2: invalid receipt\"\n );\n require(withdrawalHash[_id] == bytes32(0), \"MainchainGatewayV2: query for processed withdrawal\");\n require(\n _receipt.info.erc == Token.Standard.ERC721 || !_reachedWithdrawalLimit(_tokenAddr, _quantity),\n \"MainchainGatewayV2: reached daily withdrawal limit\"\n );\n\n bytes32 _receiptHash = _receipt.hash();\n bytes32 _receiptDigest = Transfer.receiptDigest(_domainSeparator, _receiptHash);\n IWeightedValidator _validatorContract = validatorContract;\n\n uint256 _minimumVoteWeight;\n (_minimumVoteWeight, _locked) = _computeMinVoteWeight(_receipt.info.erc, _tokenAddr, _quantity, _validatorContract);\n\n {\n bool _passed;\n address _signer;\n address _lastSigner;\n Signature memory _sig;\n uint256 _weight;\n for (uint256 _i; _i < _signatures.length; _i++) {\n _sig = _signatures[_i];\n _signer = ecrecover(_receiptDigest, _sig.v, _sig.r, _sig.s);\n require(_lastSigner < _signer, \"MainchainGatewayV2: invalid order\");\n _lastSigner = _signer;\n\n _weight += _validatorContract.getValidatorWeight(_signer);\n if (_weight >= _minimumVoteWeight) {\n _passed = true;\n break;\n }\n }\n require(_passed, \"MainchainGatewayV2: query for insufficient vote weight\");\n withdrawalHash[_id] = _receiptHash;\n }\n\n if (_locked) {\n withdrawalLocked[_id] = true;\n emit WithdrawalLocked(_receiptHash, _receipt);\n return _locked;\n }\n\n _recordWithdrawal(_tokenAddr, _quantity);\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _tokenAddr, wrappedNativeToken);\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @dev Requests deposit made by `_requester` address.\n *\n * Requirements:\n * - The token info is valid.\n * - The `msg.value` is 0 while depositing ERC20 token.\n * - The `msg.value` is equal to deposit quantity while depositing native token.\n *\n * Emits the `DepositRequested` event.\n *\n */\n function _requestDepositFor(Transfer.Request memory _request, address _requester) internal virtual {\n MappedToken memory _token;\n address _weth = address(wrappedNativeToken);\n\n _request.info.validate();\n if (_request.tokenAddr == address(0)) {\n require(_request.info.quantity == msg.value, \"MainchainGatewayV2: invalid request\");\n _token = getRoninToken(_weth);\n require(_token.erc == _request.info.erc, \"MainchainGatewayV2: invalid token standard\");\n _request.tokenAddr = _weth;\n } else {\n require(msg.value == 0, \"MainchainGatewayV2: invalid request\");\n _token = getRoninToken(_request.tokenAddr);\n require(_token.erc == _request.info.erc, \"MainchainGatewayV2: invalid token standard\");\n _request.info.transferFrom(_requester, address(this), _request.tokenAddr);\n // Withdraw if token is WETH\n if (_weth == _request.tokenAddr) {\n IWETH(_weth).withdraw(_request.info.quantity);\n }\n }\n\n uint256 _depositId = depositCount++;\n Transfer.Receipt memory _receipt = _request.into_deposit_receipt(\n _requester,\n _depositId,\n _token.tokenAddr,\n roninChainId\n );\n\n emit DepositRequested(_receipt.hash(), _receipt);\n }\n\n /**\n * @dev Returns the minimum vote weight for the token.\n */\n function _computeMinVoteWeight(\n Token.Standard _erc,\n address _token,\n uint256 _quantity,\n IWeightedValidator _validatorContract\n ) internal virtual returns (uint256 _weight, bool _locked) {\n uint256 _totalWeights = _validatorContract.totalWeights();\n _weight = _minimumVoteWeight(_totalWeights);\n if (_erc == Token.Standard.ERC20) {\n if (highTierThreshold[_token] <= _quantity) {\n _weight = _highTierVoteWeight(_totalWeights);\n }\n _locked = _lockedWithdrawalRequest(_token, _quantity);\n }\n }\n\n /**\n * @dev Update domain seperator.\n */\n function _updateDomainSeparator() internal {\n _domainSeparator = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(\"MainchainGatewayV2\"),\n keccak256(\"2\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /**\n * @dev Sets the WETH contract.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function _setWrappedNativeTokenContract(IWETH _wrapedToken) internal {\n wrappedNativeToken = _wrapedToken;\n emit WrappedNativeTokenContractUpdated(_wrapedToken);\n }\n\n /**\n * @dev Receives ETH from WETH or creates deposit request.\n */\n function _fallback() internal virtual whenNotPaused {\n if (msg.sender != address(wrappedNativeToken)) {\n Transfer.Request memory _request;\n _request.recipientAddr = msg.sender;\n _request.info.quantity = msg.value;\n _requestDepositFor(_request, _request.recipientAddr);\n }\n }\n}\n" - }, - "contracts/v0.8/interfaces/IWeightedValidator.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./IQuorum.sol\";\n\ninterface IWeightedValidator is IQuorum {\n struct WeightedValidator {\n address validator;\n address governor;\n uint256 weight;\n }\n\n /// @dev Emitted when the validators are added\n event ValidatorsAdded(uint256 indexed nonce, WeightedValidator[] validators);\n /// @dev Emitted when the validators are updated\n event ValidatorsUpdated(uint256 indexed nonce, WeightedValidator[] validators);\n /// @dev Emitted when the validators are removed\n event ValidatorsRemoved(uint256 indexed nonce, address[] validators);\n\n /**\n * @dev Returns validator weight of the validator.\n */\n function getValidatorWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns governor weight of the governor.\n */\n function getGovernorWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns total validator weights of the address list.\n */\n function sumValidatorWeights(address[] calldata _addrList) external view returns (uint256 _weight);\n\n /**\n * @dev Returns total governor weights of the address list.\n */\n function sumGovernorWeights(address[] calldata _addrList) external view returns (uint256 _weight);\n\n /**\n * @dev Returns the validator list attached with governor address and weight.\n */\n function getValidatorInfo() external view returns (WeightedValidator[] memory _list);\n\n /**\n * @dev Returns the validator list.\n */\n function getValidators() external view returns (address[] memory _validators);\n\n /**\n * @dev Returns the validator at `_index` position.\n */\n function validators(uint256 _index) external view returns (WeightedValidator memory);\n\n /**\n * @dev Returns total of validators.\n */\n function totalValidators() external view returns (uint256);\n\n /**\n * @dev Returns total weights.\n */\n function totalWeights() external view returns (uint256);\n\n /**\n * @dev Adds validators.\n *\n * Requirements:\n * - The weights are larger than 0.\n * - The validators are not added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsAdded` event.\n *\n */\n function addValidators(WeightedValidator[] calldata _validators) external;\n\n /**\n * @dev Updates validators.\n *\n * Requirements:\n * - The weights are larger than 0.\n * - The validators are added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsUpdated` event.\n *\n */\n function updateValidators(WeightedValidator[] calldata _validators) external;\n\n /**\n * @dev Removes validators.\n *\n * Requirements:\n * - The validators are added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsRemoved` event.\n *\n */\n function removeValidators(address[] calldata _validators) external;\n}\n" - }, - "contracts/v0.8/extensions/HasProxyAdmin.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\nabstract contract HasProxyAdmin {\n // bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n modifier onlyAdmin() {\n require(msg.sender == _getAdmin(), \"HasProxyAdmin: unauthorized sender\");\n _;\n }\n\n /**\n * @dev Returns proxy admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "contracts/v0.8/interfaces/SignatureConsumer.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface SignatureConsumer {\n struct Signature {\n uint8 v;\n bytes32 r;\n bytes32 s;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" - }, - "contracts/v0.8/library/Transfer.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./Token.sol\";\n\nlibrary Transfer {\n using ECDSA for bytes32;\n\n enum Kind {\n Deposit,\n Withdrawal\n }\n\n struct Request {\n // For deposit request: Recipient address on Ronin network\n // For withdrawal request: Recipient address on mainchain network\n address recipientAddr;\n // Token address to deposit/withdraw\n // Value 0: native token\n address tokenAddr;\n Token.Info info;\n }\n\n /**\n * @dev Converts the transfer request into the deposit receipt.\n */\n function into_deposit_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _roninTokenAddr,\n uint256 _roninChainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Deposit;\n _receipt.mainchain.addr = _requester;\n _receipt.mainchain.tokenAddr = _request.tokenAddr;\n _receipt.mainchain.chainId = block.chainid;\n _receipt.ronin.addr = _request.recipientAddr;\n _receipt.ronin.tokenAddr = _roninTokenAddr;\n _receipt.ronin.chainId = _roninChainId;\n _receipt.info = _request.info;\n }\n\n /**\n * @dev Converts the transfer request into the withdrawal receipt.\n */\n function into_withdrawal_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _mainchainTokenAddr,\n uint256 _mainchainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Withdrawal;\n _receipt.ronin.addr = _requester;\n _receipt.ronin.tokenAddr = _request.tokenAddr;\n _receipt.ronin.chainId = block.chainid;\n _receipt.mainchain.addr = _request.recipientAddr;\n _receipt.mainchain.tokenAddr = _mainchainTokenAddr;\n _receipt.mainchain.chainId = _mainchainId;\n _receipt.info = _request.info;\n }\n\n struct Receipt {\n uint256 id;\n Kind kind;\n Token.Owner mainchain;\n Token.Owner ronin;\n Token.Info info;\n }\n\n // keccak256(\"Receipt(uint256 id,uint8 kind,TokenOwner mainchain,TokenOwner ronin,TokenInfo info)TokenInfo(uint8 erc,uint256 id,uint256 quantity)TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant TYPE_HASH = 0xb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Receipt memory _receipt) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encode(\n TYPE_HASH,\n _receipt.id,\n _receipt.kind,\n Token.hash(_receipt.mainchain),\n Token.hash(_receipt.ronin),\n Token.hash(_receipt.info)\n )\n );\n }\n\n /**\n * @dev Returns the receipt digest.\n */\n function receiptDigest(bytes32 _domainSeparator, bytes32 _receiptHash) internal pure returns (bytes32) {\n return _domainSeparator.toTypedDataHash(_receiptHash);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" - }, - "contracts/v0.8/interfaces/IQuorum.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IQuorum {\n /// @dev Emitted when the threshold is updated\n event ThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n\n /**\n * @dev Returns the threshold.\n */\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\n\n /**\n * @dev Checks whether the `_voteWeight` passes the threshold.\n */\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\n\n /**\n * @dev Returns the minimum vote weight to pass the threshold.\n */\n function minimumVoteWeight() external view returns (uint256);\n\n /**\n * @dev Sets the threshold.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n returns (uint256 _previousNum, uint256 _previousDenom);\n}\n" - }, - "contracts/v0.8/interfaces/IWETH.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IWETH {\n function deposit() external payable;\n\n function withdraw(uint256 _wad) external;\n\n function balanceOf(address) external view returns (uint256);\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" - } - }, - "settings": { - "evmVersion": "london", - "libraries": {}, - "metadata": { - "bytecodeHash": "ipfs", - "useLiteralContent": true - }, - "optimizer": { - "enabled": true, - "runs": 1000 - }, - "remappings": [], - "outputSelection": { - "*": { - "*": [ - "evm.bytecode", - "evm.deployedBytecode", - "devdoc", - "userdoc", - "metadata", - "abi" - ] - } - } - } - }, - "ABI": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"limits\",\"type\":\"uint256[]\"}],\"name\":\"DailyWithdrawalLimitsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"DepositRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"thresholds\",\"type\":\"uint256[]\"}],\"name\":\"HighTierThresholdsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"HighTierVoteWeightThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"thresholds\",\"type\":\"uint256[]\"}],\"name\":\"LockedThresholdsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"ThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"mainchainTokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"roninTokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"enum Token.Standard[]\",\"name\":\"standards\",\"type\":\"uint8[]\"}],\"name\":\"TokenMapped\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"percentages\",\"type\":\"uint256[]\"}],\"name\":\"UnlockFeePercentagesUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IWeightedValidator\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"ValidatorContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"WithdrawalLocked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"WithdrawalUnlocked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"Withdrew\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IWETH\",\"name\":\"weth\",\"type\":\"address\"}],\"name\":\"WrappedNativeTokenContractUpdated\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WITHDRAWAL_UNLOCKER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_MAX_PERCENTAGE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"dailyWithdrawalLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_mainchainToken\",\"type\":\"address\"}],\"name\":\"getRoninToken\",\"outputs\":[{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"}],\"internalType\":\"struct MappedTokenConsumer.MappedToken\",\"name\":\"_token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"highTierThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_roleSetter\",\"type\":\"address\"},{\"internalType\":\"contract IWETH\",\"name\":\"_wrappedToken\",\"type\":\"address\"},{\"internalType\":\"contract IWeightedValidator\",\"name\":\"_validatorContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_roninChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_highTierVWNumerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"},{\"internalType\":\"address[][3]\",\"name\":\"_addresses\",\"type\":\"address[][3]\"},{\"internalType\":\"uint256[][4]\",\"name\":\"_thresholds\",\"type\":\"uint256[][4]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastDateSynced\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastSyncedWithdrawal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lockedThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_mainchainTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_roninTokens\",\"type\":\"address[]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"}],\"name\":\"mapTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_mainchainTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_roninTokens\",\"type\":\"address[]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"},{\"internalType\":\"uint256[][4]\",\"name\":\"_thresholds\",\"type\":\"uint256[][4]\"}],\"name\":\"mapTokensAndThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimumVoteWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_quantity\",\"type\":\"uint256\"}],\"name\":\"reachedWithdrawalLimit\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"receiveEther\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Request\",\"name\":\"_request\",\"type\":\"tuple\"}],\"name\":\"requestDepositFor\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"roninChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_limits\",\"type\":\"uint256[]\"}],\"name\":\"setDailyWithdrawalLimits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setHighTierThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_previousNum\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_previousDenom\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setLockedThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_previousNum\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_previousDenom\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_percentages\",\"type\":\"uint256[]\"}],\"name\":\"setUnlockFeePercentages\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IWeightedValidator\",\"name\":\"_validatorContract\",\"type\":\"address\"}],\"name\":\"setValidatorContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IWETH\",\"name\":\"_wrappedToken\",\"type\":\"address\"}],\"name\":\"setWrappedNativeTokenContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Receipt\",\"name\":\"_receipt\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct SignatureConsumer.Signature[]\",\"name\":\"_signatures\",\"type\":\"tuple[]\"}],\"name\":\"submitWithdrawal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_locked\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"unlockFeePercentages\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Receipt\",\"name\":\"_receipt\",\"type\":\"tuple\"}],\"name\":\"unlockWithdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"validatorContract\",\"outputs\":[{\"internalType\":\"contract IWeightedValidator\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"withdrawalHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"withdrawalLocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedNativeToken\",\"outputs\":[{\"internalType\":\"contract IWETH\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - "ContractName": "MainchainGatewayV2", - "CompilerVersion": "v0.8.9+commit.e5eed63a", - "OptimizationUsed": 1, - "Runs": 1000, - "ConstructorArguments": "0x", - "EVMVersion": "Default", - "Library": "", - "LicenseType": "MIT", - "Proxy": 0, - "SwarmSource": "" - } -] \ No newline at end of file +[{"SourceCode":{"language":"Solidity","sources":{"@openzeppelin/contracts/access/IAccessControl.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n"},"@openzeppelin/contracts/token/ERC721/IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"},"@openzeppelin/contracts/access/IAccessControlEnumerable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n"},"@openzeppelin/contracts/utils/StorageSlot.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n"},"@openzeppelin/contracts/utils/cryptography/ECDSA.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n"},"contracts/v0.8/extensions/GatewayV2.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"../interfaces/IQuorum.sol\";\nimport \"../interfaces/IWeightedValidator.sol\";\nimport \"./HasProxyAdmin.sol\";\n\nabstract contract GatewayV2 is HasProxyAdmin, Pausable, IQuorum {\n /// @dev Emitted when the validator contract address is updated.\n event ValidatorContractUpdated(IWeightedValidator);\n\n uint256 internal _num;\n uint256 internal _denom;\n\n IWeightedValidator public validatorContract;\n uint256 public nonce;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev See {IQuorum-getThreshold}.\n */\n function getThreshold() external view virtual returns (uint256, uint256) {\n return (_num, _denom);\n }\n\n /**\n * @dev See {IQuorum-checkThreshold}.\n */\n function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _denom >= _num * validatorContract.totalWeights();\n }\n\n /**\n * @dev See {IQuorum-setThreshold}.\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n onlyAdmin\n returns (uint256, uint256)\n {\n return _setThreshold(_numerator, _denominator);\n }\n\n /**\n * @dev Triggers paused state.\n */\n function pause() external onlyAdmin {\n _pause();\n }\n\n /**\n * @dev Triggers unpaused state.\n */\n function unpause() external onlyAdmin {\n _unpause();\n }\n\n /**\n * @dev Sets validator contract address.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ValidatorContractUpdated` event.\n *\n */\n function setValidatorContract(IWeightedValidator _validatorContract) external virtual onlyAdmin {\n _setValidatorContract(_validatorContract);\n }\n\n /**\n * @dev See {IQuorum-minimumVoteWeight}.\n */\n function minimumVoteWeight() public view virtual returns (uint256) {\n return _minimumVoteWeight(validatorContract.totalWeights());\n }\n\n /**\n * @dev Sets validator contract address.\n *\n * Emits the `ValidatorContractUpdated` event.\n *\n */\n function _setValidatorContract(IWeightedValidator _validatorContract) internal virtual {\n validatorContract = _validatorContract;\n emit ValidatorContractUpdated(_validatorContract);\n }\n\n /**\n * @dev Sets threshold and returns the old one.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function _setThreshold(uint256 _numerator, uint256 _denominator)\n internal\n virtual\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n require(_numerator <= _denominator, \"GatewayV2: invalid threshold\");\n _previousNum = _num;\n _previousDenom = _denom;\n _num = _numerator;\n _denom = _denominator;\n emit ThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n\n /**\n * @dev Returns minimum vote weight.\n */\n function _minimumVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_num * _totalWeight + _denom - 1) / _denom;\n }\n}\n"},"@openzeppelin/contracts/proxy/utils/Initializable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n // contract may have been reentered.\n require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} modifier, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n function _isConstructor() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n"},"contracts/v0.8/extensions/WithdrawalLimitation.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./GatewayV2.sol\";\n\nabstract contract WithdrawalLimitation is GatewayV2 {\n /// @dev Emitted when the high-tier vote weight threshold is updated\n event HighTierVoteWeightThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n /// @dev Emitted when the thresholds for high-tier withdrawals that requires high-tier vote weights are updated\n event HighTierThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the thresholds for locked withdrawals are updated\n event LockedThresholdsUpdated(address[] tokens, uint256[] thresholds);\n /// @dev Emitted when the fee percentages to unlock withdraw are updated\n event UnlockFeePercentagesUpdated(address[] tokens, uint256[] percentages);\n /// @dev Emitted when the daily limit thresholds are updated\n event DailyWithdrawalLimitsUpdated(address[] tokens, uint256[] limits);\n\n uint256 public constant _MAX_PERCENTAGE = 1_000_000;\n\n uint256 internal _highTierVWNum;\n uint256 internal _highTierVWDenom;\n\n /// @dev Mapping from mainchain token => the amount thresholds for high-tier withdrawals that requires high-tier vote weights\n mapping(address => uint256) public highTierThreshold;\n /// @dev Mapping from mainchain token => the amount thresholds to lock withdrawal\n mapping(address => uint256) public lockedThreshold;\n /// @dev Mapping from mainchain token => unlock fee percentages for unlocker\n /// @notice Values 0-1,000,000 map to 0%-100%\n mapping(address => uint256) public unlockFeePercentages;\n /// @dev Mapping from mainchain token => daily limit amount for withdrawal\n mapping(address => uint256) public dailyWithdrawalLimit;\n /// @dev Mapping from token address => today withdrawal amount\n mapping(address => uint256) public lastSyncedWithdrawal;\n /// @dev Mapping from token address => last date synced to record the `lastSyncedWithdrawal`\n mapping(address => uint256) public lastDateSynced;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n */\n uint256[50] private ______gap;\n\n /**\n * @dev Override {GatewayV2-setThreshold}.\n *\n * Requirements:\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n override\n onlyAdmin\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n (_previousNum, _previousDenom) = _setThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Returns the high-tier vote weight threshold.\n */\n function getHighTierVoteWeightThreshold() external view virtual returns (uint256, uint256) {\n return (_highTierVWNum, _highTierVWDenom);\n }\n\n /**\n * @dev Checks whether the `_voteWeight` passes the high-tier vote weight threshold.\n */\n function checkHighTierVoteWeightThreshold(uint256 _voteWeight) external view virtual returns (bool) {\n return _voteWeight * _highTierVWDenom >= _highTierVWNum * validatorContract.totalWeights();\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Requirements:\n * - The method caller is admin.\n * - The high-tier vote weight threshold must equal to or larger than the normal threshold.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator)\n external\n virtual\n onlyAdmin\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n (_previousNum, _previousDenom) = _setHighTierVoteWeightThreshold(_numerator, _denominator);\n _verifyThresholds();\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds)\n external\n virtual\n onlyAdmin\n {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setHighTierThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyAdmin {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setLockedThresholds(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages)\n external\n virtual\n onlyAdmin\n {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setUnlockFeePercentages(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) external virtual onlyAdmin {\n require(_tokens.length > 0, \"WithdrawalLimitation: invalid array length\");\n _setDailyWithdrawalLimits(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the limitation.\n */\n function reachedWithdrawalLimit(address _token, uint256 _quantity) external view virtual returns (bool) {\n return _reachedWithdrawalLimit(_token, _quantity);\n }\n\n /**\n * @dev Sets high-tier vote weight threshold and returns the old one.\n *\n * Emits the `HighTierVoteWeightThresholdUpdated` event.\n *\n */\n function _setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator)\n internal\n returns (uint256 _previousNum, uint256 _previousDenom)\n {\n require(_numerator <= _denominator, \"WithdrawalLimitation: invalid threshold\");\n _previousNum = _highTierVWNum;\n _previousDenom = _highTierVWDenom;\n _highTierVWNum = _numerator;\n _highTierVWDenom = _denominator;\n emit HighTierVoteWeightThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);\n }\n\n /**\n * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `HighTierThresholdsUpdated` event.\n *\n */\n function _setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n require(_tokens.length == _thresholds.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n highTierThreshold[_tokens[_i]] = _thresholds[_i];\n }\n emit HighTierThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets the amount thresholds to lock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `LockedThresholdsUpdated` event.\n *\n */\n function _setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {\n require(_tokens.length == _thresholds.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n lockedThreshold[_tokens[_i]] = _thresholds[_i];\n }\n emit LockedThresholdsUpdated(_tokens, _thresholds);\n }\n\n /**\n * @dev Sets fee percentages to unlock withdrawal.\n *\n * Requirements:\n * - The array lengths are equal.\n * - The percentage is equal to or less than 100_000.\n *\n * Emits the `UnlockFeePercentagesUpdated` event.\n *\n */\n function _setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) internal virtual {\n require(_tokens.length == _percentages.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n require(_percentages[_i] <= _MAX_PERCENTAGE, \"WithdrawalLimitation: invalid percentage\");\n unlockFeePercentages[_tokens[_i]] = _percentages[_i];\n }\n emit UnlockFeePercentagesUpdated(_tokens, _percentages);\n }\n\n /**\n * @dev Sets daily limit amounts for the withdrawals.\n *\n * Requirements:\n * - The array lengths are equal.\n *\n * Emits the `DailyWithdrawalLimitsUpdated` event.\n *\n */\n function _setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) internal virtual {\n require(_tokens.length == _limits.length, \"WithdrawalLimitation: invalid array length\");\n for (uint256 _i; _i < _tokens.length; _i++) {\n dailyWithdrawalLimit[_tokens[_i]] = _limits[_i];\n }\n emit DailyWithdrawalLimitsUpdated(_tokens, _limits);\n }\n\n /**\n * @dev Checks whether the withdrawal reaches the daily limitation.\n *\n * Requirements:\n * - The daily withdrawal threshold should not apply for locked withdrawals.\n *\n */\n function _reachedWithdrawalLimit(address _token, uint256 _quantity) internal view virtual returns (bool) {\n if (_lockedWithdrawalRequest(_token, _quantity)) {\n return false;\n }\n\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n return dailyWithdrawalLimit[_token] <= _quantity;\n } else {\n return dailyWithdrawalLimit[_token] <= lastSyncedWithdrawal[_token] + _quantity;\n }\n }\n\n /**\n * @dev Record withdrawal token.\n */\n function _recordWithdrawal(address _token, uint256 _quantity) internal virtual {\n uint256 _currentDate = block.timestamp / 1 days;\n if (_currentDate > lastDateSynced[_token]) {\n lastDateSynced[_token] = _currentDate;\n lastSyncedWithdrawal[_token] = _quantity;\n } else {\n lastSyncedWithdrawal[_token] += _quantity;\n }\n }\n\n /**\n * @dev Returns whether the withdrawal request is locked or not.\n */\n function _lockedWithdrawalRequest(address _token, uint256 _quantity) internal view virtual returns (bool) {\n return lockedThreshold[_token] <= _quantity;\n }\n\n /**\n * @dev Computes fee percentage.\n */\n function _computeFeePercentage(uint256 _amount, uint256 _percentage) internal view virtual returns (uint256) {\n return (_amount * _percentage) / _MAX_PERCENTAGE;\n }\n\n /**\n * @dev Returns high-tier vote weight.\n */\n function _highTierVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256) {\n return (_highTierVWNum * _totalWeight + _highTierVWDenom - 1) / _highTierVWDenom;\n }\n\n /**\n * @dev Validates whether the high-tier vote weight threshold is larger than the normal threshold.\n */\n function _verifyThresholds() internal view {\n require(_num * _highTierVWDenom <= _highTierVWNum * _denom, \"WithdrawalLimitation: invalid thresholds\");\n }\n}\n"},"contracts/v0.8/interfaces/MappedTokenConsumer.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../library/Token.sol\";\n\ninterface MappedTokenConsumer {\n struct MappedToken {\n Token.Standard erc;\n address tokenAddr;\n }\n}\n"},"contracts/v0.8/library/Token.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nlibrary Token {\n enum Standard {\n ERC20,\n ERC721\n }\n struct Info {\n Standard erc;\n // For ERC20: the id must be 0 and the quantity is larger than 0.\n // For ERC721: the quantity must be 0.\n uint256 id;\n uint256 quantity;\n }\n\n // keccak256(\"TokenInfo(uint8 erc,uint256 id,uint256 quantity)\");\n bytes32 public constant INFO_TYPE_HASH = 0x1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Info memory _info) internal pure returns (bytes32) {\n return keccak256(abi.encode(INFO_TYPE_HASH, _info.erc, _info.id, _info.quantity));\n }\n\n /**\n * @dev Validates the token info.\n */\n function validate(Info memory _info) internal pure {\n require(\n (_info.erc == Standard.ERC20 && _info.quantity > 0 && _info.id == 0) ||\n (_info.erc == Standard.ERC721 && _info.quantity == 0),\n \"Token: invalid info\"\n );\n }\n\n /**\n * @dev Transfer asset from.\n *\n * Requirements:\n * - The `_from` address must approve for the contract using this library.\n *\n */\n function transferFrom(\n Info memory _info,\n address _from,\n address _to,\n address _token\n ) internal {\n bool _success;\n bytes memory _data;\n if (_info.erc == Standard.ERC20) {\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, _from, _to, _info.quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n } else if (_info.erc == Standard.ERC721) {\n // bytes4(keccak256(\"transferFrom(address,address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x23b872dd, _from, _to, _info.id));\n } else {\n revert(\"Token: unsupported token standard\");\n }\n\n if (!_success) {\n revert(\n string(\n abi.encodePacked(\n \"Token: could not transfer \",\n toString(_info),\n \" from \",\n Strings.toHexString(uint160(_from), 20),\n \" to \",\n Strings.toHexString(uint160(_to), 20),\n \" token \",\n Strings.toHexString(uint160(_token), 20)\n )\n )\n );\n }\n }\n\n /**\n * @dev Transfers ERC721 token and returns the result.\n */\n function tryTransferERC721(\n address _token,\n address _to,\n uint256 _id\n ) internal returns (bool _success) {\n (_success, ) = _token.call(abi.encodeWithSelector(IERC721.transferFrom.selector, address(this), _to, _id));\n }\n\n /**\n * @dev Transfers ERC20 token and returns the result.\n */\n function tryTransferERC20(\n address _token,\n address _to,\n uint256 _quantity\n ) internal returns (bool _success) {\n bytes memory _data;\n (_success, _data) = _token.call(abi.encodeWithSelector(IERC20.transfer.selector, _to, _quantity));\n _success = _success && (_data.length == 0 || abi.decode(_data, (bool)));\n }\n\n /**\n * @dev Transfer assets from current address to `_to` address.\n */\n function transfer(\n Info memory _info,\n address _to,\n address _token\n ) internal {\n bool _success;\n if (_info.erc == Standard.ERC20) {\n _success = tryTransferERC20(_token, _to, _info.quantity);\n } else if (_info.erc == Standard.ERC721) {\n _success = tryTransferERC721(_token, _to, _info.id);\n } else {\n revert(\"Token: unsupported token standard\");\n }\n\n if (!_success) {\n revert(\n string(\n abi.encodePacked(\n \"Token: could not transfer \",\n toString(_info),\n \" to \",\n Strings.toHexString(uint160(_to), 20),\n \" token \",\n Strings.toHexString(uint160(_token), 20)\n )\n )\n );\n }\n }\n\n /**\n * @dev Tries minting and transfering assets.\n *\n * @notice Prioritizes transfer native token if the token is wrapped.\n *\n */\n function handleAssetTransfer(\n Info memory _info,\n address payable _to,\n address _token,\n IWETH _wrappedNativeToken\n ) internal {\n bool _success;\n if (_token == address(_wrappedNativeToken)) {\n // Try sending the native token before transferring the wrapped token\n if (!_to.send(_info.quantity)) {\n _wrappedNativeToken.deposit{ value: _info.quantity }();\n transfer(_info, _to, _token);\n }\n } else if (_info.erc == Token.Standard.ERC20) {\n uint256 _balance = IERC20(_token).balanceOf(address(this));\n\n if (_balance < _info.quantity) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, address(this), _info.quantity - _balance));\n require(_success, \"Token: ERC20 minting failed\");\n }\n\n transfer(_info, _to, _token);\n } else if (_info.erc == Token.Standard.ERC721) {\n if (!tryTransferERC721(_token, _to, _info.id)) {\n // bytes4(keccak256(\"mint(address,uint256)\"))\n (_success, ) = _token.call(abi.encodeWithSelector(0x40c10f19, _to, _info.id));\n require(_success, \"Token: ERC721 minting failed\");\n }\n } else {\n revert(\"Token: unsupported token standard\");\n }\n }\n\n /**\n * @dev Returns readable string.\n */\n function toString(Info memory _info) internal pure returns (string memory) {\n return\n string(\n abi.encodePacked(\n \"TokenInfo(\",\n Strings.toHexString(uint160(_info.erc), 1),\n \",\",\n Strings.toHexString(_info.id),\n \",\",\n Strings.toHexString(_info.quantity),\n \")\"\n )\n );\n }\n\n struct Owner {\n address addr;\n address tokenAddr;\n uint256 chainId;\n }\n\n // keccak256(\"TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant OWNER_TYPE_HASH = 0x353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764;\n\n /**\n * @dev Returns ownership struct hash.\n */\n function hash(Owner memory _owner) internal pure returns (bytes32) {\n return keccak256(abi.encode(OWNER_TYPE_HASH, _owner.addr, _owner.tokenAddr, _owner.chainId));\n }\n}\n"},"contracts/v0.8/mainchain/IMainchainGatewayV2.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../interfaces/IWETH.sol\";\nimport \"../library/Transfer.sol\";\nimport \"../interfaces/SignatureConsumer.sol\";\nimport \"../interfaces/MappedTokenConsumer.sol\";\n\ninterface IMainchainGatewayV2 is SignatureConsumer, MappedTokenConsumer {\n /// @dev Emitted when the deposit is requested\n event DepositRequested(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the assets are withdrawn\n event Withdrew(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the tokens are mapped\n event TokenMapped(address[] mainchainTokens, address[] roninTokens, Token.Standard[] standards);\n /// @dev Emitted when the wrapped native token contract is updated\n event WrappedNativeTokenContractUpdated(IWETH weth);\n /// @dev Emitted when the withdrawal is locked\n event WithdrawalLocked(bytes32 receiptHash, Transfer.Receipt receipt);\n /// @dev Emitted when the withdrawal is unlocked\n event WithdrawalUnlocked(bytes32 receiptHash, Transfer.Receipt receipt);\n\n /**\n * @dev Returns the domain seperator.\n */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /**\n * @dev Returns deposit count.\n */\n function depositCount() external view returns (uint256);\n\n /**\n * @dev Sets the wrapped native token contract.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external;\n\n /**\n * @dev Returns whether the withdrawal is locked.\n */\n function withdrawalLocked(uint256 withdrawalId) external view returns (bool);\n\n /**\n * @dev Returns the withdrawal hash.\n */\n function withdrawalHash(uint256 withdrawalId) external view returns (bytes32);\n\n /**\n * @dev Locks the assets and request deposit.\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable;\n\n /**\n * @dev Withdraws based on the receipt and the validator signatures.\n * Returns whether the withdrawal is locked.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function submitWithdrawal(Transfer.Receipt memory _receipt, Signature[] memory _signatures)\n external\n returns (bool _locked);\n\n /**\n * @dev Approves a specific withdrawal.\n *\n * Requirements:\n * - The method caller is a validator.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external;\n\n /**\n * @dev Maps mainchain tokens to Ronin network and sets thresholds.\n *\n * Requirement:\n * - The method caller is admin.\n * - The arrays have the same length and its length larger than 0.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n uint256[][4] calldata _thresholds\n ) external;\n\n /**\n * @dev Returns token address on Ronin network.\n * @notice Reverts for unsupported token.\n */\n function getRoninToken(address _mainchainToken) external view returns (MappedToken memory _token);\n}\n"},"contracts/v0.8/mainchain/MainchainGatewayV2.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"../extensions/GatewayV2.sol\";\nimport \"../extensions/WithdrawalLimitation.sol\";\nimport \"../library/Transfer.sol\";\nimport \"./IMainchainGatewayV2.sol\";\n\ncontract MainchainGatewayV2 is WithdrawalLimitation, Initializable, AccessControlEnumerable, IMainchainGatewayV2 {\n using Token for Token.Info;\n using Transfer for Transfer.Request;\n using Transfer for Transfer.Receipt;\n\n /// @dev Withdrawal unlocker role hash\n bytes32 public constant WITHDRAWAL_UNLOCKER_ROLE = keccak256(\"WITHDRAWAL_UNLOCKER_ROLE\");\n\n /// @dev Wrapped native token address\n IWETH public wrappedNativeToken;\n /// @dev Ronin network id\n uint256 public roninChainId;\n /// @dev Total deposit\n uint256 public depositCount;\n /// @dev Domain seperator\n bytes32 internal _domainSeparator;\n /// @dev Mapping from mainchain token => token address on Ronin network\n mapping(address => MappedToken) internal _roninToken;\n /// @dev Mapping from withdrawal id => withdrawal hash\n mapping(uint256 => bytes32) public withdrawalHash;\n /// @dev Mapping from withdrawal id => locked\n mapping(uint256 => bool) public withdrawalLocked;\n\n fallback() external payable {\n _fallback();\n }\n\n receive() external payable {\n _fallback();\n }\n\n /**\n * @dev Initializes contract storage.\n */\n function initialize(\n address _roleSetter,\n IWETH _wrappedToken,\n IWeightedValidator _validatorContract,\n uint256 _roninChainId,\n uint256 _numerator,\n uint256 _highTierVWNumerator,\n uint256 _denominator,\n // _addresses[0]: mainchainTokens\n // _addresses[1]: roninTokens\n // _addresses[2]: withdrawalUnlockers\n address[][3] calldata _addresses,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds,\n Token.Standard[] calldata _standards\n ) external payable virtual initializer {\n _setupRole(DEFAULT_ADMIN_ROLE, _roleSetter);\n roninChainId = _roninChainId;\n\n _setWrappedNativeTokenContract(_wrappedToken);\n _setValidatorContract(_validatorContract);\n _updateDomainSeparator();\n _setThreshold(_numerator, _denominator);\n _setHighTierVoteWeightThreshold(_highTierVWNumerator, _denominator);\n _verifyThresholds();\n\n if (_addresses[0].length > 0) {\n // Map mainchain tokens to ronin tokens\n _mapTokens(_addresses[0], _addresses[1], _standards);\n // Sets thresholds based on the mainchain tokens\n _setHighTierThresholds(_addresses[0], _thresholds[0]);\n _setLockedThresholds(_addresses[0], _thresholds[1]);\n _setUnlockFeePercentages(_addresses[0], _thresholds[2]);\n _setDailyWithdrawalLimits(_addresses[0], _thresholds[3]);\n }\n\n // Grant role for withdrawal unlocker\n for (uint256 _i; _i < _addresses[2].length; _i++) {\n _grantRole(WITHDRAWAL_UNLOCKER_ROLE, _addresses[2][_i]);\n }\n }\n\n /**\n * @dev Receives ether without doing anything. Use this function to topup native token.\n */\n function receiveEther() external payable {}\n\n /**\n * @dev See {IMainchainGatewayV2-DOMAIN_SEPARATOR}.\n */\n function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n return _domainSeparator;\n }\n\n /**\n * @dev See {IMainchainGatewayV2-setWrappedNativeTokenContract}.\n */\n function setWrappedNativeTokenContract(IWETH _wrappedToken) external virtual onlyAdmin {\n _setWrappedNativeTokenContract(_wrappedToken);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-requestDepositFor}.\n */\n function requestDepositFor(Transfer.Request calldata _request) external payable virtual whenNotPaused {\n _requestDepositFor(_request, msg.sender);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-submitWithdrawal}.\n */\n function submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] calldata _signatures)\n external\n virtual\n whenNotPaused\n returns (bool _locked)\n {\n return _submitWithdrawal(_receipt, _signatures);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-unlockWithdrawal}.\n */\n function unlockWithdrawal(Transfer.Receipt calldata _receipt) external onlyRole(WITHDRAWAL_UNLOCKER_ROLE) {\n bytes32 _receiptHash = _receipt.hash();\n require(withdrawalHash[_receipt.id] == _receipt.hash(), \"MainchainGatewayV2: invalid receipt\");\n require(withdrawalLocked[_receipt.id], \"MainchainGatewayV2: query for approved withdrawal\");\n delete withdrawalLocked[_receipt.id];\n emit WithdrawalUnlocked(_receiptHash, _receipt);\n\n address _token = _receipt.mainchain.tokenAddr;\n if (_receipt.info.erc == Token.Standard.ERC20) {\n Token.Info memory _feeInfo = _receipt.info;\n _feeInfo.quantity = _computeFeePercentage(_receipt.info.quantity, unlockFeePercentages[_token]);\n Token.Info memory _withdrawInfo = _receipt.info;\n _withdrawInfo.quantity = _receipt.info.quantity - _feeInfo.quantity;\n\n _feeInfo.handleAssetTransfer(payable(msg.sender), _token, wrappedNativeToken);\n _withdrawInfo.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n } else {\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _token, wrappedNativeToken);\n }\n\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-mapTokens}.\n */\n function mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) external virtual onlyAdmin {\n require(_mainchainTokens.length > 0, \"MainchainGatewayV2: query for empty array\");\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-mapTokensAndThresholds}.\n */\n function mapTokensAndThresholds(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards,\n // _thresholds[0]: highTierThreshold\n // _thresholds[1]: lockedThreshold\n // _thresholds[2]: unlockFeePercentages\n // _thresholds[3]: dailyWithdrawalLimit\n uint256[][4] calldata _thresholds\n ) external virtual onlyAdmin {\n require(_mainchainTokens.length > 0, \"MainchainGatewayV2: query for empty array\");\n _mapTokens(_mainchainTokens, _roninTokens, _standards);\n _setHighTierThresholds(_mainchainTokens, _thresholds[0]);\n _setLockedThresholds(_mainchainTokens, _thresholds[1]);\n _setUnlockFeePercentages(_mainchainTokens, _thresholds[2]);\n _setDailyWithdrawalLimits(_mainchainTokens, _thresholds[3]);\n }\n\n /**\n * @dev See {IMainchainGatewayV2-getRoninToken}.\n */\n function getRoninToken(address _mainchainToken) public view returns (MappedToken memory _token) {\n _token = _roninToken[_mainchainToken];\n require(_token.tokenAddr != address(0), \"MainchainGatewayV2: unsupported token\");\n }\n\n /**\n * @dev Maps mainchain tokens to Ronin network.\n *\n * Requirement:\n * - The arrays have the same length.\n *\n * Emits the `TokenMapped` event.\n *\n */\n function _mapTokens(\n address[] calldata _mainchainTokens,\n address[] calldata _roninTokens,\n Token.Standard[] calldata _standards\n ) internal virtual {\n require(\n _mainchainTokens.length == _roninTokens.length && _mainchainTokens.length == _standards.length,\n \"MainchainGatewayV2: invalid array length\"\n );\n\n for (uint256 _i; _i < _mainchainTokens.length; _i++) {\n _roninToken[_mainchainTokens[_i]].tokenAddr = _roninTokens[_i];\n _roninToken[_mainchainTokens[_i]].erc = _standards[_i];\n }\n\n emit TokenMapped(_mainchainTokens, _roninTokens, _standards);\n }\n\n /**\n * @dev Submits withdrawal receipt.\n *\n * Requirements:\n * - The receipt kind is withdrawal.\n * - The receipt is to withdraw on this chain.\n * - The receipt is not used to withdraw before.\n * - The withdrawal is not reached the limit threshold.\n * - The signer weight total is larger than or equal to the minimum threshold.\n * - The signature signers are in order.\n *\n * Emits the `Withdrew` once the assets are released.\n *\n */\n function _submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] memory _signatures)\n internal\n virtual\n returns (bool _locked)\n {\n uint256 _id = _receipt.id;\n uint256 _quantity = _receipt.info.quantity;\n address _tokenAddr = _receipt.mainchain.tokenAddr;\n\n _receipt.info.validate();\n require(_receipt.kind == Transfer.Kind.Withdrawal, \"MainchainGatewayV2: invalid receipt kind\");\n require(_receipt.mainchain.chainId == block.chainid, \"MainchainGatewayV2: invalid chain id\");\n MappedToken memory _token = getRoninToken(_receipt.mainchain.tokenAddr);\n require(\n _token.erc == _receipt.info.erc && _token.tokenAddr == _receipt.ronin.tokenAddr,\n \"MainchainGatewayV2: invalid receipt\"\n );\n require(withdrawalHash[_id] == bytes32(0), \"MainchainGatewayV2: query for processed withdrawal\");\n require(\n _receipt.info.erc == Token.Standard.ERC721 || !_reachedWithdrawalLimit(_tokenAddr, _quantity),\n \"MainchainGatewayV2: reached daily withdrawal limit\"\n );\n\n bytes32 _receiptHash = _receipt.hash();\n bytes32 _receiptDigest = Transfer.receiptDigest(_domainSeparator, _receiptHash);\n IWeightedValidator _validatorContract = validatorContract;\n\n uint256 _minimumVoteWeight;\n (_minimumVoteWeight, _locked) = _computeMinVoteWeight(_receipt.info.erc, _tokenAddr, _quantity, _validatorContract);\n\n {\n bool _passed;\n address _signer;\n address _lastSigner;\n Signature memory _sig;\n uint256 _weight;\n for (uint256 _i; _i < _signatures.length; _i++) {\n _sig = _signatures[_i];\n _signer = ecrecover(_receiptDigest, _sig.v, _sig.r, _sig.s);\n require(_lastSigner < _signer, \"MainchainGatewayV2: invalid order\");\n _lastSigner = _signer;\n\n _weight += _validatorContract.getValidatorWeight(_signer);\n if (_weight >= _minimumVoteWeight) {\n _passed = true;\n break;\n }\n }\n require(_passed, \"MainchainGatewayV2: query for insufficient vote weight\");\n withdrawalHash[_id] = _receiptHash;\n }\n\n if (_locked) {\n withdrawalLocked[_id] = true;\n emit WithdrawalLocked(_receiptHash, _receipt);\n return _locked;\n }\n\n _recordWithdrawal(_tokenAddr, _quantity);\n _receipt.info.handleAssetTransfer(payable(_receipt.mainchain.addr), _tokenAddr, wrappedNativeToken);\n emit Withdrew(_receiptHash, _receipt);\n }\n\n /**\n * @dev Requests deposit made by `_requester` address.\n *\n * Requirements:\n * - The token info is valid.\n * - The `msg.value` is 0 while depositing ERC20 token.\n * - The `msg.value` is equal to deposit quantity while depositing native token.\n *\n * Emits the `DepositRequested` event.\n *\n */\n function _requestDepositFor(Transfer.Request memory _request, address _requester) internal virtual {\n MappedToken memory _token;\n address _weth = address(wrappedNativeToken);\n\n _request.info.validate();\n if (_request.tokenAddr == address(0)) {\n require(_request.info.quantity == msg.value, \"MainchainGatewayV2: invalid request\");\n _token = getRoninToken(_weth);\n require(_token.erc == _request.info.erc, \"MainchainGatewayV2: invalid token standard\");\n _request.tokenAddr = _weth;\n } else {\n require(msg.value == 0, \"MainchainGatewayV2: invalid request\");\n _token = getRoninToken(_request.tokenAddr);\n require(_token.erc == _request.info.erc, \"MainchainGatewayV2: invalid token standard\");\n _request.info.transferFrom(_requester, address(this), _request.tokenAddr);\n // Withdraw if token is WETH\n if (_weth == _request.tokenAddr) {\n IWETH(_weth).withdraw(_request.info.quantity);\n }\n }\n\n uint256 _depositId = depositCount++;\n Transfer.Receipt memory _receipt = _request.into_deposit_receipt(\n _requester,\n _depositId,\n _token.tokenAddr,\n roninChainId\n );\n\n emit DepositRequested(_receipt.hash(), _receipt);\n }\n\n /**\n * @dev Returns the minimum vote weight for the token.\n */\n function _computeMinVoteWeight(\n Token.Standard _erc,\n address _token,\n uint256 _quantity,\n IWeightedValidator _validatorContract\n ) internal virtual returns (uint256 _weight, bool _locked) {\n uint256 _totalWeights = _validatorContract.totalWeights();\n _weight = _minimumVoteWeight(_totalWeights);\n if (_erc == Token.Standard.ERC20) {\n if (highTierThreshold[_token] <= _quantity) {\n _weight = _highTierVoteWeight(_totalWeights);\n }\n _locked = _lockedWithdrawalRequest(_token, _quantity);\n }\n }\n\n /**\n * @dev Update domain seperator.\n */\n function _updateDomainSeparator() internal {\n _domainSeparator = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(\"MainchainGatewayV2\"),\n keccak256(\"2\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /**\n * @dev Sets the WETH contract.\n *\n * Emits the `WrappedNativeTokenContractUpdated` event.\n *\n */\n function _setWrappedNativeTokenContract(IWETH _wrapedToken) internal {\n wrappedNativeToken = _wrapedToken;\n emit WrappedNativeTokenContractUpdated(_wrapedToken);\n }\n\n /**\n * @dev Receives ETH from WETH or creates deposit request.\n */\n function _fallback() internal virtual whenNotPaused {\n if (msg.sender != address(wrappedNativeToken)) {\n Transfer.Request memory _request;\n _request.recipientAddr = msg.sender;\n _request.info.quantity = msg.value;\n _requestDepositFor(_request, _request.recipientAddr);\n }\n }\n}\n"},"contracts/v0.8/interfaces/IWeightedValidator.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./IQuorum.sol\";\n\ninterface IWeightedValidator is IQuorum {\n struct WeightedValidator {\n address validator;\n address governor;\n uint256 weight;\n }\n\n /// @dev Emitted when the validators are added\n event ValidatorsAdded(uint256 indexed nonce, WeightedValidator[] validators);\n /// @dev Emitted when the validators are updated\n event ValidatorsUpdated(uint256 indexed nonce, WeightedValidator[] validators);\n /// @dev Emitted when the validators are removed\n event ValidatorsRemoved(uint256 indexed nonce, address[] validators);\n\n /**\n * @dev Returns validator weight of the validator.\n */\n function getValidatorWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns governor weight of the governor.\n */\n function getGovernorWeight(address _addr) external view returns (uint256);\n\n /**\n * @dev Returns total validator weights of the address list.\n */\n function sumValidatorWeights(address[] calldata _addrList) external view returns (uint256 _weight);\n\n /**\n * @dev Returns total governor weights of the address list.\n */\n function sumGovernorWeights(address[] calldata _addrList) external view returns (uint256 _weight);\n\n /**\n * @dev Returns the validator list attached with governor address and weight.\n */\n function getValidatorInfo() external view returns (WeightedValidator[] memory _list);\n\n /**\n * @dev Returns the validator list.\n */\n function getValidators() external view returns (address[] memory _validators);\n\n /**\n * @dev Returns the validator at `_index` position.\n */\n function validators(uint256 _index) external view returns (WeightedValidator memory);\n\n /**\n * @dev Returns total of validators.\n */\n function totalValidators() external view returns (uint256);\n\n /**\n * @dev Returns total weights.\n */\n function totalWeights() external view returns (uint256);\n\n /**\n * @dev Adds validators.\n *\n * Requirements:\n * - The weights are larger than 0.\n * - The validators are not added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsAdded` event.\n *\n */\n function addValidators(WeightedValidator[] calldata _validators) external;\n\n /**\n * @dev Updates validators.\n *\n * Requirements:\n * - The weights are larger than 0.\n * - The validators are added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsUpdated` event.\n *\n */\n function updateValidators(WeightedValidator[] calldata _validators) external;\n\n /**\n * @dev Removes validators.\n *\n * Requirements:\n * - The validators are added.\n * - The method caller is admin.\n *\n * Emits the `ValidatorsRemoved` event.\n *\n */\n function removeValidators(address[] calldata _validators) external;\n}\n"},"contracts/v0.8/extensions/HasProxyAdmin.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\nabstract contract HasProxyAdmin {\n // bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n modifier onlyAdmin() {\n require(msg.sender == _getAdmin(), \"HasProxyAdmin: unauthorized sender\");\n _;\n }\n\n /**\n * @dev Returns proxy admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n}\n"},"@openzeppelin/contracts/utils/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"contracts/v0.8/interfaces/SignatureConsumer.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface SignatureConsumer {\n struct Signature {\n uint8 v;\n bytes32 r;\n bytes32 s;\n }\n}\n"},"@openzeppelin/contracts/utils/Strings.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n"},"@openzeppelin/contracts/utils/introspection/ERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"},"@openzeppelin/contracts/access/AccessControlEnumerable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n"},"contracts/v0.8/library/Transfer.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./Token.sol\";\n\nlibrary Transfer {\n using ECDSA for bytes32;\n\n enum Kind {\n Deposit,\n Withdrawal\n }\n\n struct Request {\n // For deposit request: Recipient address on Ronin network\n // For withdrawal request: Recipient address on mainchain network\n address recipientAddr;\n // Token address to deposit/withdraw\n // Value 0: native token\n address tokenAddr;\n Token.Info info;\n }\n\n /**\n * @dev Converts the transfer request into the deposit receipt.\n */\n function into_deposit_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _roninTokenAddr,\n uint256 _roninChainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Deposit;\n _receipt.mainchain.addr = _requester;\n _receipt.mainchain.tokenAddr = _request.tokenAddr;\n _receipt.mainchain.chainId = block.chainid;\n _receipt.ronin.addr = _request.recipientAddr;\n _receipt.ronin.tokenAddr = _roninTokenAddr;\n _receipt.ronin.chainId = _roninChainId;\n _receipt.info = _request.info;\n }\n\n /**\n * @dev Converts the transfer request into the withdrawal receipt.\n */\n function into_withdrawal_receipt(\n Request memory _request,\n address _requester,\n uint256 _id,\n address _mainchainTokenAddr,\n uint256 _mainchainId\n ) internal view returns (Receipt memory _receipt) {\n _receipt.id = _id;\n _receipt.kind = Kind.Withdrawal;\n _receipt.ronin.addr = _requester;\n _receipt.ronin.tokenAddr = _request.tokenAddr;\n _receipt.ronin.chainId = block.chainid;\n _receipt.mainchain.addr = _request.recipientAddr;\n _receipt.mainchain.tokenAddr = _mainchainTokenAddr;\n _receipt.mainchain.chainId = _mainchainId;\n _receipt.info = _request.info;\n }\n\n struct Receipt {\n uint256 id;\n Kind kind;\n Token.Owner mainchain;\n Token.Owner ronin;\n Token.Info info;\n }\n\n // keccak256(\"Receipt(uint256 id,uint8 kind,TokenOwner mainchain,TokenOwner ronin,TokenInfo info)TokenInfo(uint8 erc,uint256 id,uint256 quantity)TokenOwner(address addr,address tokenAddr,uint256 chainId)\");\n bytes32 public constant TYPE_HASH = 0xb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea;\n\n /**\n * @dev Returns token info struct hash.\n */\n function hash(Receipt memory _receipt) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encode(\n TYPE_HASH,\n _receipt.id,\n _receipt.kind,\n Token.hash(_receipt.mainchain),\n Token.hash(_receipt.ronin),\n Token.hash(_receipt.info)\n )\n );\n }\n\n /**\n * @dev Returns the receipt digest.\n */\n function receiptDigest(bytes32 _domainSeparator, bytes32 _receiptHash) internal pure returns (bytes32) {\n return _domainSeparator.toTypedDataHash(_receiptHash);\n }\n}\n"},"@openzeppelin/contracts/utils/Context.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"},"@openzeppelin/contracts/security/Pausable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n"},"@openzeppelin/contracts/utils/structs/EnumerableSet.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n"},"contracts/v0.8/interfaces/IQuorum.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IQuorum {\n /// @dev Emitted when the threshold is updated\n event ThresholdUpdated(\n uint256 indexed nonce,\n uint256 indexed numerator,\n uint256 indexed denominator,\n uint256 previousNumerator,\n uint256 previousDenominator\n );\n\n /**\n * @dev Returns the threshold.\n */\n function getThreshold() external view returns (uint256 _num, uint256 _denom);\n\n /**\n * @dev Checks whether the `_voteWeight` passes the threshold.\n */\n function checkThreshold(uint256 _voteWeight) external view returns (bool);\n\n /**\n * @dev Returns the minimum vote weight to pass the threshold.\n */\n function minimumVoteWeight() external view returns (uint256);\n\n /**\n * @dev Sets the threshold.\n *\n * Requirements:\n * - The method caller is admin.\n *\n * Emits the `ThresholdUpdated` event.\n *\n */\n function setThreshold(uint256 _numerator, uint256 _denominator)\n external\n returns (uint256 _previousNum, uint256 _previousDenom);\n}\n"},"contracts/v0.8/interfaces/IWETH.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IWETH {\n function deposit() external payable;\n\n function withdraw(uint256 _wad) external;\n\n function balanceOf(address) external view returns (uint256);\n}\n"},"@openzeppelin/contracts/access/AccessControl.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n"},"@openzeppelin/contracts/utils/Address.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"},"@openzeppelin/contracts/token/ERC20/IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"}},"settings":{"evmVersion":"london","libraries":{},"metadata":{"bytecodeHash":"ipfs","useLiteralContent":true},"optimizer":{"enabled":true,"runs":1000},"remappings":[],"outputSelection":{"*":{"*":["evm.bytecode","evm.deployedBytecode","devdoc","userdoc","metadata","abi"]}}}},"ABI":"[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"limits\",\"type\":\"uint256[]\"}],\"name\":\"DailyWithdrawalLimitsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"DepositRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"thresholds\",\"type\":\"uint256[]\"}],\"name\":\"HighTierThresholdsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"HighTierVoteWeightThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"thresholds\",\"type\":\"uint256[]\"}],\"name\":\"LockedThresholdsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousNumerator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousDenominator\",\"type\":\"uint256\"}],\"name\":\"ThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"mainchainTokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"roninTokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"enum Token.Standard[]\",\"name\":\"standards\",\"type\":\"uint8[]\"}],\"name\":\"TokenMapped\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"percentages\",\"type\":\"uint256[]\"}],\"name\":\"UnlockFeePercentagesUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IWeightedValidator\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"ValidatorContractUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"WithdrawalLocked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"WithdrawalUnlocked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"receiptHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"indexed\":false,\"internalType\":\"struct Transfer.Receipt\",\"name\":\"receipt\",\"type\":\"tuple\"}],\"name\":\"Withdrew\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IWETH\",\"name\":\"weth\",\"type\":\"address\"}],\"name\":\"WrappedNativeTokenContractUpdated\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WITHDRAWAL_UNLOCKER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"_MAX_PERCENTAGE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voteWeight\",\"type\":\"uint256\"}],\"name\":\"checkThreshold\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"dailyWithdrawalLimit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_mainchainToken\",\"type\":\"address\"}],\"name\":\"getRoninToken\",\"outputs\":[{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"}],\"internalType\":\"struct MappedTokenConsumer.MappedToken\",\"name\":\"_token\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"highTierThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_roleSetter\",\"type\":\"address\"},{\"internalType\":\"contract IWETH\",\"name\":\"_wrappedToken\",\"type\":\"address\"},{\"internalType\":\"contract IWeightedValidator\",\"name\":\"_validatorContract\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_roninChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_highTierVWNumerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"},{\"internalType\":\"address[][3]\",\"name\":\"_addresses\",\"type\":\"address[][3]\"},{\"internalType\":\"uint256[][4]\",\"name\":\"_thresholds\",\"type\":\"uint256[][4]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastDateSynced\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastSyncedWithdrawal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lockedThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_mainchainTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_roninTokens\",\"type\":\"address[]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"}],\"name\":\"mapTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_mainchainTokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_roninTokens\",\"type\":\"address[]\"},{\"internalType\":\"enum Token.Standard[]\",\"name\":\"_standards\",\"type\":\"uint8[]\"},{\"internalType\":\"uint256[][4]\",\"name\":\"_thresholds\",\"type\":\"uint256[][4]\"}],\"name\":\"mapTokensAndThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimumVoteWeight\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_quantity\",\"type\":\"uint256\"}],\"name\":\"reachedWithdrawalLimit\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"receiveEther\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"recipientAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Request\",\"name\":\"_request\",\"type\":\"tuple\"}],\"name\":\"requestDepositFor\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"roninChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_limits\",\"type\":\"uint256[]\"}],\"name\":\"setDailyWithdrawalLimits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setHighTierThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setHighTierVoteWeightThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_previousNum\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_previousDenom\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setLockedThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_denominator\",\"type\":\"uint256\"}],\"name\":\"setThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_previousNum\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_previousDenom\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_percentages\",\"type\":\"uint256[]\"}],\"name\":\"setUnlockFeePercentages\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IWeightedValidator\",\"name\":\"_validatorContract\",\"type\":\"address\"}],\"name\":\"setValidatorContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IWETH\",\"name\":\"_wrappedToken\",\"type\":\"address\"}],\"name\":\"setWrappedNativeTokenContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Receipt\",\"name\":\"_receipt\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct SignatureConsumer.Signature[]\",\"name\":\"_signatures\",\"type\":\"tuple[]\"}],\"name\":\"submitWithdrawal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_locked\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"unlockFeePercentages\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"enum Transfer.Kind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"mainchain\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Owner\",\"name\":\"ronin\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"enum Token.Standard\",\"name\":\"erc\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"}],\"internalType\":\"struct Token.Info\",\"name\":\"info\",\"type\":\"tuple\"}],\"internalType\":\"struct Transfer.Receipt\",\"name\":\"_receipt\",\"type\":\"tuple\"}],\"name\":\"unlockWithdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"validatorContract\",\"outputs\":[{\"internalType\":\"contract IWeightedValidator\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"withdrawalHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"withdrawalLocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedNativeToken\",\"outputs\":[{\"internalType\":\"contract IWETH\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]","ContractName":"MainchainGatewayV2","CompilerVersion":"v0.8.9+commit.e5eed63a","OptimizationUsed":1,"Runs":1000,"ConstructorArguments":"0x","EVMVersion":"Default","Library":"","LicenseType":"MIT","Proxy":0,"SwarmSource":""}] \ No newline at end of file diff --git a/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json index fa26d9cad4256..f4dfea9e7de46 100644 --- a/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json +++ b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json @@ -1,5 +1 @@ -{ - "contractAddress": "0x8b3d32cf2bb4d0d16656f4c0b04fa546274f1545", - "contractCreator": "0x958892b4a0512b28aaac890fc938868bbd42f064", - "txHash": "0x79820495643caf5a1e7e96578361c9ddba0e0735cd684ada7450254f6fd58f51" -} \ No newline at end of file +{"contractAddress":"0x8b3d32cf2bb4d0d16656f4c0b04fa546274f1545","contractCreator":"0x958892b4a0512b28aaac890fc938868bbd42f064","txHash":"0x79820495643caf5a1e7e96578361c9ddba0e0735cd684ada7450254f6fd58f51"} \ No newline at end of file diff --git a/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json index 5921b5b303ee9..1fd95fa4fe5dd 100644 --- a/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json +++ b/testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/metadata.json @@ -1,63 +1 @@ -[ - { - "SourceCode": { - "language": "Solidity", - "sources": { - "contracts/governance/governor/GovernorStorage.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./IIpt.sol\";\nimport \"./Structs.sol\";\n\ncontract GovernorCharlieDelegatorStorage {\n /// @notice Active brains of Governor\n address public implementation;\n}\n\n/**\n * @title Storage for Governor Charlie Delegate\n * @notice For future upgrades, do not change GovernorCharlieDelegateStorage. Create a new\n * contract which implements GovernorCharlieDelegateStorage and following the naming convention\n * GovernorCharlieDelegateStorageVX.\n */\n//solhint-disable-next-line max-states-count\ncontract GovernorCharlieDelegateStorage is GovernorCharlieDelegatorStorage {\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed\n uint256 public quorumVotes;\n\n /// @notice The number of votes in support of a proposal required in order for an emergency quorum to be reached and for a vote to succeed\n uint256 public emergencyQuorumVotes;\n\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint256 public votingDelay;\n\n /// @notice The duration of voting on a proposal, in blocks\n uint256 public votingPeriod;\n\n /// @notice The number of votes required in order for a voter to become a proposer\n uint256 public proposalThreshold;\n\n /// @notice Initial proposal id set at become\n uint256 public initialProposalId;\n\n /// @notice The total number of proposals\n uint256 public proposalCount;\n\n /// @notice The address of the Interest Protocol governance token\n IIpt public ipt;\n\n /// @notice The official record of all proposals ever proposed\n mapping(uint256 => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping(address => uint256) public latestProposalIds;\n\n /// @notice The latest proposal for each proposer\n mapping(bytes32 => bool) public queuedTransactions;\n\n /// @notice The proposal holding period\n uint256 public proposalTimelockDelay;\n\n /// @notice Stores the expiration of account whitelist status as a timestamp\n mapping(address => uint256) public whitelistAccountExpirations;\n\n /// @notice Address which manages whitelisted proposals and whitelist accounts\n address public whitelistGuardian;\n\n /// @notice The duration of the voting on a emergency proposal, in blocks\n uint256 public emergencyVotingPeriod;\n\n /// @notice The emergency proposal holding period\n uint256 public emergencyTimelockDelay;\n\n /// all receipts for proposal\n mapping(uint256 => mapping(address => Receipt)) public proposalReceipts;\n\n /// @notice The emergency proposal holding period\n bool public initialized;\n\n /// @notice The number of votes to reject an optimistic proposal\n uint256 public optimisticQuorumVotes; \n\n /// @notice The delay period before voting begins\n uint256 public optimisticVotingDelay; \n\n /// @notice The maximum number of seconds an address can be whitelisted for\n uint256 public maxWhitelistPeriod; \n}\n" - }, - "hardhat/console.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity >= 0.4.22 <0.9.0;\n\nlibrary console {\n\taddress constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n\tfunction _sendLogPayload(bytes memory payload) private view {\n\t\tuint256 payloadLength = payload.length;\n\t\taddress consoleAddress = CONSOLE_ADDRESS;\n\t\tassembly {\n\t\t\tlet payloadStart := add(payload, 32)\n\t\t\tlet r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n\t\t}\n\t}\n\n\tfunction log() internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log()\"));\n\t}\n\n\tfunction logInt(int p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(int)\", p0));\n\t}\n\n\tfunction logUint(uint p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n\t}\n\n\tfunction logString(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction logBool(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction logAddress(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction logBytes(bytes memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n\t}\n\n\tfunction logBytes1(bytes1 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n\t}\n\n\tfunction logBytes2(bytes2 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n\t}\n\n\tfunction logBytes3(bytes3 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n\t}\n\n\tfunction logBytes4(bytes4 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n\t}\n\n\tfunction logBytes5(bytes5 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n\t}\n\n\tfunction logBytes6(bytes6 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n\t}\n\n\tfunction logBytes7(bytes7 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n\t}\n\n\tfunction logBytes8(bytes8 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n\t}\n\n\tfunction logBytes9(bytes9 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n\t}\n\n\tfunction logBytes10(bytes10 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n\t}\n\n\tfunction logBytes11(bytes11 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n\t}\n\n\tfunction logBytes12(bytes12 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n\t}\n\n\tfunction logBytes13(bytes13 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n\t}\n\n\tfunction logBytes14(bytes14 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n\t}\n\n\tfunction logBytes15(bytes15 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n\t}\n\n\tfunction logBytes16(bytes16 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n\t}\n\n\tfunction logBytes17(bytes17 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n\t}\n\n\tfunction logBytes18(bytes18 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n\t}\n\n\tfunction logBytes19(bytes19 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n\t}\n\n\tfunction logBytes20(bytes20 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n\t}\n\n\tfunction logBytes21(bytes21 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n\t}\n\n\tfunction logBytes22(bytes22 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n\t}\n\n\tfunction logBytes23(bytes23 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n\t}\n\n\tfunction logBytes24(bytes24 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n\t}\n\n\tfunction logBytes25(bytes25 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n\t}\n\n\tfunction logBytes26(bytes26 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n\t}\n\n\tfunction logBytes27(bytes27 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n\t}\n\n\tfunction logBytes28(bytes28 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n\t}\n\n\tfunction logBytes29(bytes29 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n\t}\n\n\tfunction logBytes30(bytes30 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n\t}\n\n\tfunction logBytes31(bytes31 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n\t}\n\n\tfunction logBytes32(bytes32 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n\t}\n\n\tfunction log(uint p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n\t}\n\n\tfunction log(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction log(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction log(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction log(uint p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n\t}\n\n\tfunction log(address p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint)\", p0, p1));\n\t}\n\n\tfunction log(address p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n\t}\n\n\tfunction log(address p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n\t}\n\n\tfunction log(address p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n}\n" - }, - "contracts/governance/governor/IGovernor.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./Structs.sol\";\n\n/// @title interface to interact with TokenDelgator\ninterface IGovernorCharlieDelegator {\n function _setImplementation(address implementation_) external;\n\n fallback() external payable;\n\n receive() external payable;\n}\n\n/// @title interface to interact with TokenDelgate\ninterface IGovernorCharlieDelegate {\n function initialize(\n address ipt_\n ) external;\n\n function propose(\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n bool emergency\n ) external returns (uint256);\n\n function queue(uint256 proposalId) external;\n\n function execute(uint256 proposalId) external payable;\n\n function executeTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) external payable;\n\n function cancel(uint256 proposalId) external;\n\n function getActions(uint256 proposalId)\n external\n view\n returns (\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas\n );\n\n function getReceipt(uint256 proposalId, address voter) external view returns (Receipt memory);\n\n function state(uint256 proposalId) external view returns (ProposalState);\n\n function castVote(uint256 proposalId, uint8 support) external;\n\n function castVoteWithReason(\n uint256 proposalId,\n uint8 support,\n string calldata reason\n ) external;\n\n function castVoteBySig(\n uint256 proposalId,\n uint8 support,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n function isWhitelisted(address account) external view returns (bool);\n\n function _setDelay(uint256 proposalTimelockDelay_) external;\n\n function _setEmergencyDelay(uint256 emergencyTimelockDelay_) external;\n\n function _setVotingDelay(uint256 newVotingDelay) external;\n\n function _setVotingPeriod(uint256 newVotingPeriod) external;\n\n function _setEmergencyVotingPeriod(uint256 newEmergencyVotingPeriod) external;\n\n function _setProposalThreshold(uint256 newProposalThreshold) external;\n\n function _setQuorumVotes(uint256 newQuorumVotes) external;\n\n function _setEmergencyQuorumVotes(uint256 newEmergencyQuorumVotes) external;\n\n function _setWhitelistAccountExpiration(address account, uint256 expiration) external;\n\n function _setWhitelistGuardian(address account) external;\n\n function _setOptimisticDelay(uint256 newOptimisticVotingDelay) external;\n\n function _setOptimisticQuorumVotes(uint256 newOptimisticQuorumVotes) external;\n}\n\n/// @title interface which contains all events emitted by delegator & delegate\ninterface GovernorCharlieEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(\n uint256 indexed id,\n address indexed proposer,\n address[] targets,\n uint256[] values,\n string[] signatures,\n bytes[] calldatas,\n uint256 indexed startBlock,\n uint256 endBlock,\n string description\n );\n\n /// @notice An event emitted when a vote has been cast on a proposal\n /// @param voter The address which casted a vote\n /// @param proposalId The proposal id which was voted on\n /// @param support Support value for the vote. 0=against, 1=for, 2=abstain\n /// @param votes Number of votes which were cast by the voter\n /// @param reason The reason given for the vote by the voter\n event VoteCast(address indexed voter, uint256 indexed proposalId, uint8 support, uint256 votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint256 indexed id);\n\n /// @notice An event emitted when a proposal has been queued in the Timelock\n event ProposalQueued(uint256 indexed id, uint256 eta);\n\n /// @notice An event emitted when a proposal has been executed in the Timelock\n event ProposalExecuted(uint256 indexed id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod);\n\n /// @notice An event emitted when the emergency voting period is set\n event EmergencyVotingPeriodSet(uint256 oldEmergencyVotingPeriod, uint256 emergencyVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold is set\n event ProposalThresholdSet(uint256 oldProposalThreshold, uint256 newProposalThreshold);\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Emitted when pendingAdmin is accepted, which means admin is updated\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /// @notice Emitted when whitelist account expiration is set\n event WhitelistAccountExpirationSet(address account, uint256 expiration);\n\n /// @notice Emitted when the whitelistGuardian is set\n event WhitelistGuardianSet(address oldGuardian, address newGuardian);\n\n /// @notice Emitted when the a new delay is set\n event NewDelay(uint256 oldTimelockDelay, uint256 proposalTimelockDelay);\n\n /// @notice Emitted when the a new emergency delay is set\n event NewEmergencyDelay(uint256 oldEmergencyTimelockDelay, uint256 emergencyTimelockDelay);\n\n /// @notice Emitted when the quorum is updated\n event NewQuorum(uint256 oldQuorumVotes, uint256 quorumVotes);\n\n /// @notice Emitted when the emergency quorum is updated\n event NewEmergencyQuorum(uint256 oldEmergencyQuorumVotes, uint256 emergencyQuorumVotes);\n\n /// @notice An event emitted when the optimistic voting delay is set\n event OptimisticVotingDelaySet(uint256 oldOptimisticVotingDelay, uint256 optimisticVotingDelay);\n\n /// @notice Emitted when the optimistic quorum is updated\n event OptimisticQuorumVotesSet(uint256 oldOptimisticQuorumVotes, uint256 optimisticQuorumVotes);\n\n /// @notice Emitted when a transaction is canceled\n event CancelTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n\n /// @notice Emitted when a transaction is executed\n event ExecuteTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n\n /// @notice Emitted when a transaction is queued\n event QueueTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n}\n" - }, - "contracts/governance/governor/Structs.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nstruct Proposal {\n /// @notice Unique id for looking up a proposal\n uint256 id;\n /// @notice Creator of the proposal\n address proposer;\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint256 eta;\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint256[] values;\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint256 startBlock;\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint256 endBlock;\n /// @notice Current number of votes in favor of this proposal\n uint256 forVotes;\n /// @notice Current number of votes in opposition to this proposal\n uint256 againstVotes;\n /// @notice Current number of votes for abstaining for this proposal\n uint256 abstainVotes;\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n /// @notice Whether the proposal is an emergency proposal\n bool emergency;\n /// @notice quorum votes requires\n uint256 quorumVotes;\n /// @notice time delay\n uint256 delay;\n}\n\n/// @notice Ballot receipt record for a voter\nstruct Receipt {\n /// @notice Whether or not a vote has been cast\n bool hasVoted;\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n /// @notice The number of votes the voter had, which were cast\n uint96 votes;\n}\n\n/// @notice Possible states that a proposal may be in\nenum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed\n}\n" - }, - "contracts/governance/governor/IIpt.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\ninterface IIpt {\n function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96);\n}\n" - }, - "contracts/governance/governor/GovernorDelegate.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\npragma experimental ABIEncoderV2;\nimport \"hardhat/console.sol\";\n\nimport \"./IGovernor.sol\";\nimport \"./GovernorStorage.sol\";\n\ncontract GovernorCharlieDelegate is GovernorCharlieDelegateStorage, GovernorCharlieEvents, IGovernorCharlieDelegate {\n /// @notice The name of this contract\n string public constant name = \"Interest Protocol Governor\";\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint256 public constant proposalMaxOperations = 10;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the ballot struct used by the contract\n bytes32 public constant BALLOT_TYPEHASH = keccak256(\"Ballot(uint256 proposalId,uint8 support)\");\n\n /// @notice The time for a proposal to be executed after passing\n uint256 public constant GRACE_PERIOD = 14 days;\n\n /**\n * @notice Used to initialize the contract during delegator contructor\n * @param ipt_ The address of the IPT token\n */\n function initialize(\n address ipt_\n ) external override {\n require(!initialized, \"already been initialized\");\n ipt = IIpt(ipt_);\n votingPeriod = 40320;\n votingDelay = 13140;\n proposalThreshold = 1000000000000000000000000;\n proposalTimelockDelay = 172800;\n proposalCount = 0;\n quorumVotes = 10000000000000000000000000;\n emergencyQuorumVotes = 40000000000000000000000000;\n emergencyVotingPeriod = 6570;\n emergencyTimelockDelay = 43200;\n optimisticQuorumVotes = 2000000000000000000000000;\n optimisticVotingDelay = 18000;\n maxWhitelistPeriod = 31536000;\n\n initialized = true;\n }\n\n /// @notice any function with this modifier will call the pay_interest() function before\n modifier onlyGov() {\n require(_msgSender() == address(this), \"must come from the gov.\");\n _;\n }\n\n /**\n * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold\n * @param targets Target addresses for proposal calls\n * @param values Eth values for proposal calls\n * @param signatures Function signatures for proposal calls\n * @param calldatas Calldatas for proposal calls\n * @param description String description of the proposal\n * @return Proposal id of new proposal\n */\n function propose(\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n bool emergency\n ) public override returns (uint256) {\n // Reject proposals before initiating as Governor\n require(quorumVotes != 0, \"Charlie not active\");\n // Allow addresses above proposal threshold and whitelisted addresses to propose\n require(\n ipt.getPriorVotes(_msgSender(), (block.number - 1)) >= proposalThreshold || isWhitelisted(_msgSender()),\n \"votes below proposal threshold\"\n );\n require(\n targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length,\n \"information arity mismatch\"\n );\n require(targets.length != 0, \"must provide actions\");\n require(targets.length <= proposalMaxOperations, \"too many actions\");\n\n uint256 latestProposalId = latestProposalIds[_msgSender()];\n if (latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(latestProposalId);\n require(proposersLatestProposalState != ProposalState.Active, \"one live proposal per proposer\");\n require(proposersLatestProposalState != ProposalState.Pending, \"one live proposal per proposer\");\n }\n\n proposalCount++;\n Proposal memory newProposal = Proposal({\n id: proposalCount,\n proposer: _msgSender(),\n eta: 0,\n targets: targets,\n values: values,\n signatures: signatures,\n calldatas: calldatas,\n startBlock: block.number + votingDelay,\n endBlock: block.number + votingDelay + votingPeriod,\n forVotes: 0,\n againstVotes: 0,\n abstainVotes: 0,\n canceled: false,\n executed: false,\n emergency: emergency,\n quorumVotes: quorumVotes,\n delay: proposalTimelockDelay\n });\n\n //whitelist can't make emergency\n if (emergency && !isWhitelisted(_msgSender())) {\n newProposal.startBlock = block.number;\n newProposal.endBlock = block.number + emergencyVotingPeriod;\n newProposal.quorumVotes = emergencyQuorumVotes;\n newProposal.delay = emergencyTimelockDelay;\n }\n\n //whitelist can only make optimistic proposals\n if (isWhitelisted(_msgSender())) {\n newProposal.quorumVotes = optimisticQuorumVotes;\n newProposal.startBlock = block.number + optimisticVotingDelay;\n newProposal.endBlock = block.number + optimisticVotingDelay + votingPeriod;\n }\n\n proposals[newProposal.id] = newProposal;\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n emit ProposalCreated(\n newProposal.id,\n _msgSender(),\n targets,\n values,\n signatures,\n calldatas,\n newProposal.startBlock,\n newProposal.endBlock,\n description\n );\n return newProposal.id;\n }\n\n /**\n * @notice Queues a proposal of state succeeded\n * @param proposalId The id of the proposal to queue\n */\n function queue(uint256 proposalId) external override {\n require(state(proposalId) == ProposalState.Succeeded, \"can only be queued if succeeded\");\n Proposal storage proposal = proposals[proposalId];\n uint256 eta = block.timestamp + proposal.delay;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n require(\n !queuedTransactions[\n keccak256(\n abi.encode(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta)\n )\n ],\n \"proposal already queued\"\n );\n queueTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n eta,\n proposal.delay\n );\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta,\n uint256 delay\n ) internal returns (bytes32) {\n require(eta >= (getBlockTimestamp() + delay), \"must satisfy delay.\");\n\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = true;\n\n emit QueueTransaction(txHash, target, value, signature, data, eta);\n return txHash;\n }\n\n /**\n * @notice Executes a queued proposal if eta has passed\n * @param proposalId The id of the proposal to execute\n */\n function execute(uint256 proposalId) external payable override {\n require(state(proposalId) == ProposalState.Queued, \"can only be exec'd if queued\");\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n this.executeTransaction{value: proposal.values[i]}(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n emit ProposalExecuted(proposalId);\n }\n\n function executeTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) external payable override {\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n require(queuedTransactions[txHash], \"tx hasn't been queued.\");\n require(getBlockTimestamp() >= eta, \"tx hasn't surpassed timelock.\");\n require(getBlockTimestamp() <= eta + GRACE_PERIOD, \"tx is stale.\");\n\n queuedTransactions[txHash] = false;\n\n bytes memory callData;\n\n if (bytes(signature).length == 0) {\n callData = data;\n } else {\n callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data);\n }\n\n // solhint-disable-next-line avoid-low-level-calls\n (\n bool success, /*bytes memory returnData*/\n\n ) = target.call{value: value}(callData);\n require(success, \"tx execution reverted.\");\n\n emit ExecuteTransaction(txHash, target, value, signature, data, eta);\n }\n\n /**\n * @notice Cancels a proposal only if sender is the proposer, or proposer delegates dropped below proposal threshold\n * @param proposalId The id of the proposal to cancel\n */\n function cancel(uint256 proposalId) external override {\n require(state(proposalId) != ProposalState.Executed, \"cant cancel executed proposal\");\n\n Proposal storage proposal = proposals[proposalId];\n\n // Proposer can cancel\n if (_msgSender() != proposal.proposer) {\n // Whitelisted proposers can't be canceled for falling below proposal threshold\n if (isWhitelisted(proposal.proposer)) {\n require(\n (ipt.getPriorVotes(proposal.proposer, (block.number - 1)) < proposalThreshold) &&\n _msgSender() == whitelistGuardian,\n \"cancel: whitelisted proposer\"\n );\n } else {\n require(\n (ipt.getPriorVotes(proposal.proposer, (block.number - 1)) < proposalThreshold),\n \"cancel: proposer above threshold\"\n );\n }\n }\n\n proposal.canceled = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n function cancelTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) internal {\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = false;\n\n emit CancelTransaction(txHash, target, value, signature, data, eta);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets proposal targets\n * @return values proposal values\n * @return signatures proposal signatures\n * @return calldatas proposal calldatae\n */\n function getActions(uint256 proposalId)\n external\n view\n override\n returns (\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas\n )\n {\n Proposal storage p = proposals[proposalId];\n return (p.targets, p.values, p.signatures, p.calldatas);\n }\n\n /**\n * @notice Gets the receipt for a voter on a given proposal\n * @param proposalId the id of proposal\n * @param voter The address of the voter\n * @return The voting receipt\n */\n function getReceipt(uint256 proposalId, address voter) external view override returns (Receipt memory) {\n return proposalReceipts[proposalId][voter];\n }\n\n /**\n * @notice Gets the state of a proposal\n * @param proposalId The id of the proposal\n * @return Proposal state\n */\n // solhint-disable-next-line code-complexity\n function state(uint256 proposalId) public view override returns (ProposalState) {\n require(proposalCount >= proposalId && proposalId > initialProposalId, \"state: invalid proposal id\");\n Proposal storage proposal = proposals[proposalId];\n bool whitelisted = isWhitelisted(proposal.proposer);\n if (proposal.canceled) {\n return ProposalState.Canceled;\n } else if (block.number <= proposal.startBlock) {\n return ProposalState.Pending;\n } else if (block.number <= proposal.endBlock) {\n return ProposalState.Active;\n } else if (\n (whitelisted && proposal.againstVotes > proposal.quorumVotes) ||\n (!whitelisted && proposal.forVotes <= proposal.againstVotes) ||\n (!whitelisted && proposal.forVotes < proposal.quorumVotes)\n ) {\n return ProposalState.Defeated;\n } else if (proposal.eta == 0) {\n return ProposalState.Succeeded;\n } else if (proposal.executed) {\n return ProposalState.Executed;\n } else if (block.timestamp >= (proposal.eta + GRACE_PERIOD)) {\n return ProposalState.Expired;\n }\n return ProposalState.Queued;\n }\n\n /**\n * @notice Cast a vote for a proposal\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n */\n function castVote(uint256 proposalId, uint8 support) external override {\n emit VoteCast(_msgSender(), proposalId, support, castVoteInternal(_msgSender(), proposalId, support), \"\");\n }\n\n /**\n * @notice Cast a vote for a proposal with a reason\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param reason The reason given for the vote by the voter\n */\n function castVoteWithReason(\n uint256 proposalId,\n uint8 support,\n string calldata reason\n ) external override {\n emit VoteCast(_msgSender(), proposalId, support, castVoteInternal(_msgSender(), proposalId, support), reason);\n }\n\n /**\n * @notice Cast a vote for a proposal by signature\n * @dev external override function that accepts EIP-712 signatures for voting on proposals.\n */\n function castVoteBySig(\n uint256 proposalId,\n uint8 support,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"castVoteBySig: invalid signature\");\n emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), \"\");\n }\n\n /**\n * @notice Internal function that caries out voting logic\n * @param voter The voter that is casting their vote\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @return The number of votes cast\n */\n function castVoteInternal(\n address voter,\n uint256 proposalId,\n uint8 support\n ) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, \"voting is closed\");\n require(support <= 2, \"invalid vote type\");\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposalReceipts[proposalId][voter];\n require(receipt.hasVoted == false, \"voter already voted\");\n uint96 votes = ipt.getPriorVotes(voter, proposal.startBlock);\n\n if (support == 0) {\n proposal.againstVotes = proposal.againstVotes + votes;\n } else if (support == 1) {\n proposal.forVotes = proposal.forVotes + votes;\n } else if (support == 2) {\n proposal.abstainVotes = proposal.abstainVotes + votes;\n }\n\n receipt.hasVoted = true;\n receipt.support = support;\n receipt.votes = votes;\n\n return votes;\n }\n\n /**\n * @notice View function which returns if an account is whitelisted\n * @param account Account to check white list status of\n * @return If the account is whitelisted\n */\n function isWhitelisted(address account) public view override returns (bool) {\n return (whitelistAccountExpirations[account] > block.timestamp);\n }\n\n /**\n * @notice Governance function for setting the governance token\n * @param token_ new token addr\n */\n function _setNewToken(address token_) external onlyGov {\n ipt = IIpt(token_);\n }\n\n /**\n * @notice Used to update the timelock period\n * @param proposalTimelockDelay_ The proposal holding period\n */\n function _setDelay(uint256 proposalTimelockDelay_) public override onlyGov {\n uint256 oldTimelockDelay = proposalTimelockDelay;\n proposalTimelockDelay = proposalTimelockDelay_;\n\n emit NewDelay(oldTimelockDelay, proposalTimelockDelay);\n }\n\n /**\n * @notice Used to update the emergency timelock period\n * @param emergencyTimelockDelay_ The proposal holding period\n */\n function _setEmergencyDelay(uint256 emergencyTimelockDelay_) public override onlyGov {\n uint256 oldEmergencyTimelockDelay = emergencyTimelockDelay;\n emergencyTimelockDelay = emergencyTimelockDelay_;\n\n emit NewEmergencyDelay(oldEmergencyTimelockDelay, emergencyTimelockDelay);\n }\n\n /**\n * @notice Governance function for setting the voting delay\n * @param newVotingDelay new voting delay, in blocks\n */\n function _setVotingDelay(uint256 newVotingDelay) external override onlyGov {\n uint256 oldVotingDelay = votingDelay;\n votingDelay = newVotingDelay;\n\n emit VotingDelaySet(oldVotingDelay, votingDelay);\n }\n\n /**\n * @notice Governance function for setting the voting period\n * @param newVotingPeriod new voting period, in blocks\n */\n function _setVotingPeriod(uint256 newVotingPeriod) external override onlyGov {\n uint256 oldVotingPeriod = votingPeriod;\n votingPeriod = newVotingPeriod;\n\n emit VotingPeriodSet(oldVotingPeriod, votingPeriod);\n }\n\n /**\n * @notice Governance function for setting the emergency voting period\n * @param newEmergencyVotingPeriod new voting period, in blocks\n */\n function _setEmergencyVotingPeriod(uint256 newEmergencyVotingPeriod) external override onlyGov {\n uint256 oldEmergencyVotingPeriod = emergencyVotingPeriod;\n emergencyVotingPeriod = newEmergencyVotingPeriod;\n\n emit EmergencyVotingPeriodSet(oldEmergencyVotingPeriod, emergencyVotingPeriod);\n }\n\n /**\n * @notice Governance function for setting the proposal threshold\n * @param newProposalThreshold new proposal threshold\n */\n function _setProposalThreshold(uint256 newProposalThreshold) external override onlyGov {\n uint256 oldProposalThreshold = proposalThreshold;\n proposalThreshold = newProposalThreshold;\n\n emit ProposalThresholdSet(oldProposalThreshold, proposalThreshold);\n }\n\n /**\n * @notice Governance function for setting the quorum\n * @param newQuorumVotes new proposal quorum\n */\n function _setQuorumVotes(uint256 newQuorumVotes) external override onlyGov {\n uint256 oldQuorumVotes = quorumVotes;\n quorumVotes = newQuorumVotes;\n\n emit NewQuorum(oldQuorumVotes, quorumVotes);\n }\n\n /**\n * @notice Governance function for setting the emergency quorum\n * @param newEmergencyQuorumVotes new proposal quorum\n */\n function _setEmergencyQuorumVotes(uint256 newEmergencyQuorumVotes) external override onlyGov {\n uint256 oldEmergencyQuorumVotes = emergencyQuorumVotes;\n emergencyQuorumVotes = newEmergencyQuorumVotes;\n\n emit NewEmergencyQuorum(oldEmergencyQuorumVotes, emergencyQuorumVotes);\n }\n\n /**\n * @notice Governance function for setting the whitelist expiration as a timestamp\n * for an account. Whitelist status allows accounts to propose without meeting threshold\n * @param account Account address to set whitelist expiration for\n * @param expiration Expiration for account whitelist status as timestamp (if now < expiration, whitelisted)\n */\n function _setWhitelistAccountExpiration(address account, uint256 expiration) external override onlyGov {\n require (expiration < (maxWhitelistPeriod + block.timestamp), \"expiration exceeds max\");\n whitelistAccountExpirations[account] = expiration;\n\n emit WhitelistAccountExpirationSet(account, expiration);\n }\n\n /**\n * @notice Governance function for setting the whitelistGuardian. WhitelistGuardian can cancel proposals from whitelisted addresses\n * @param account Account to set whitelistGuardian to (0x0 to remove whitelistGuardian)\n */\n function _setWhitelistGuardian(address account) external override onlyGov {\n address oldGuardian = whitelistGuardian;\n whitelistGuardian = account;\n\n emit WhitelistGuardianSet(oldGuardian, whitelistGuardian);\n }\n\n /**\n * @notice Governance function for setting the optimistic voting delay\n * @param newOptimisticVotingDelay new optimistic voting delay, in blocks\n */\n function _setOptimisticDelay(uint256 newOptimisticVotingDelay) external override onlyGov {\n uint256 oldOptimisticVotingDelay = optimisticVotingDelay;\n optimisticVotingDelay = newOptimisticVotingDelay;\n\n emit OptimisticVotingDelaySet(oldOptimisticVotingDelay, optimisticVotingDelay);\n }\n\n /**\n * @notice Governance function for setting the optimistic quorum\n * @param newOptimisticQuorumVotes new optimistic quorum votes, in blocks\n */\n function _setOptimisticQuorumVotes(uint256 newOptimisticQuorumVotes) external override onlyGov {\n uint256 oldOptimisticQuorumVotes = optimisticQuorumVotes;\n optimisticQuorumVotes = newOptimisticQuorumVotes;\n\n emit OptimisticQuorumVotesSet(oldOptimisticQuorumVotes, optimisticQuorumVotes);\n }\n\n function getChainIdInternal() internal view returns (uint256) {\n return block.chainid;\n }\n\n function getBlockTimestamp() internal view returns (uint256) {\n // solium-disable-next-line security/no-block-members\n return block.timestamp;\n }\n\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 200, - "details": { - "orderLiterals": true, - "deduplicate": true, - "cse": true, - "yul": true - } - }, - "outputSelection": { - "*": { - "*": [ - "evm.bytecode", - "evm.deployedBytecode", - "devdoc", - "userdoc", - "metadata", - "abi" - ] - } - }, - "libraries": {} - } - }, - "ABI": "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"CancelTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyVotingPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"EmergencyVotingPeriodSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"ExecuteTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"NewAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimelockDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"proposalTimelockDelay\",\"type\":\"uint256\"}],\"name\":\"NewDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyTimelockDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyTimelockDelay\",\"type\":\"uint256\"}],\"name\":\"NewEmergencyDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"NewEmergencyQuorum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"NewImplementation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"NewPendingAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"quorumVotes\",\"type\":\"uint256\"}],\"name\":\"NewQuorum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOptimisticQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"OptimisticQuorumVotesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOptimisticVotingDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticVotingDelay\",\"type\":\"uint256\"}],\"name\":\"OptimisticVotingDelaySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"ProposalCanceled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"proposer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"indexed\":false,\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"startBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"endBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"}],\"name\":\"ProposalCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"ProposalExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"ProposalQueued\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldProposalThreshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newProposalThreshold\",\"type\":\"uint256\"}],\"name\":\"ProposalThresholdSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"QueueTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"voter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"votes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"VoteCast\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldVotingDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newVotingDelay\",\"type\":\"uint256\"}],\"name\":\"VotingDelaySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldVotingPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"VotingPeriodSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"expiration\",\"type\":\"uint256\"}],\"name\":\"WhitelistAccountExpirationSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldGuardian\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGuardian\",\"type\":\"address\"}],\"name\":\"WhitelistGuardianSet\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BALLOT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalTimelockDelay_\",\"type\":\"uint256\"}],\"name\":\"_setDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"emergencyTimelockDelay_\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newEmergencyQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newEmergencyVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyVotingPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"_setNewToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newOptimisticVotingDelay\",\"type\":\"uint256\"}],\"name\":\"_setOptimisticDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newOptimisticQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setOptimisticQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newProposalThreshold\",\"type\":\"uint256\"}],\"name\":\"_setProposalThreshold\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newVotingDelay\",\"type\":\"uint256\"}],\"name\":\"_setVotingDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"_setVotingPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"expiration\",\"type\":\"uint256\"}],\"name\":\"_setWhitelistAccountExpiration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"_setWhitelistGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"cancel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"}],\"name\":\"castVote\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"castVoteBySig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"castVoteWithReason\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyQuorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyTimelockDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyVotingPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"execute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"executeTransaction\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"getActions\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"voter\",\"type\":\"address\"}],\"name\":\"getReceipt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"hasVoted\",\"type\":\"bool\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"internalType\":\"struct Receipt\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialProposalId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ipt_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ipt\",\"outputs\":[{\"internalType\":\"contract IIpt\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"latestProposalIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxWhitelistPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticQuorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticVotingDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalMaxOperations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"proposalReceipts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"hasVoted\",\"type\":\"bool\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalTimelockDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"proposals\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"proposer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"startBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"endBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"forVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"againstVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"abstainVotes\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"canceled\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"executed\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"emergency\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"quorumVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"emergency\",\"type\":\"bool\"}],\"name\":\"propose\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"queue\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"queuedTransactions\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"quorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"state\",\"outputs\":[{\"internalType\":\"enum ProposalState\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"whitelistAccountExpirations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"whitelistGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - "ContractName": "GovernorCharlieDelegate", - "CompilerVersion": "v0.8.9+commit.e5eed63a", - "OptimizationUsed": 1, - "Runs": 200, - "ConstructorArguments": "0x", - "EVMVersion": "Default", - "Library": "", - "LicenseType": "", - "Proxy": 0, - "SwarmSource": "" - } -] \ No newline at end of file +[{"SourceCode":{"language":"Solidity","sources":{"contracts/governance/governor/GovernorStorage.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./IIpt.sol\";\nimport \"./Structs.sol\";\n\ncontract GovernorCharlieDelegatorStorage {\n /// @notice Active brains of Governor\n address public implementation;\n}\n\n/**\n * @title Storage for Governor Charlie Delegate\n * @notice For future upgrades, do not change GovernorCharlieDelegateStorage. Create a new\n * contract which implements GovernorCharlieDelegateStorage and following the naming convention\n * GovernorCharlieDelegateStorageVX.\n */\n//solhint-disable-next-line max-states-count\ncontract GovernorCharlieDelegateStorage is GovernorCharlieDelegatorStorage {\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed\n uint256 public quorumVotes;\n\n /// @notice The number of votes in support of a proposal required in order for an emergency quorum to be reached and for a vote to succeed\n uint256 public emergencyQuorumVotes;\n\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint256 public votingDelay;\n\n /// @notice The duration of voting on a proposal, in blocks\n uint256 public votingPeriod;\n\n /// @notice The number of votes required in order for a voter to become a proposer\n uint256 public proposalThreshold;\n\n /// @notice Initial proposal id set at become\n uint256 public initialProposalId;\n\n /// @notice The total number of proposals\n uint256 public proposalCount;\n\n /// @notice The address of the Interest Protocol governance token\n IIpt public ipt;\n\n /// @notice The official record of all proposals ever proposed\n mapping(uint256 => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping(address => uint256) public latestProposalIds;\n\n /// @notice The latest proposal for each proposer\n mapping(bytes32 => bool) public queuedTransactions;\n\n /// @notice The proposal holding period\n uint256 public proposalTimelockDelay;\n\n /// @notice Stores the expiration of account whitelist status as a timestamp\n mapping(address => uint256) public whitelistAccountExpirations;\n\n /// @notice Address which manages whitelisted proposals and whitelist accounts\n address public whitelistGuardian;\n\n /// @notice The duration of the voting on a emergency proposal, in blocks\n uint256 public emergencyVotingPeriod;\n\n /// @notice The emergency proposal holding period\n uint256 public emergencyTimelockDelay;\n\n /// all receipts for proposal\n mapping(uint256 => mapping(address => Receipt)) public proposalReceipts;\n\n /// @notice The emergency proposal holding period\n bool public initialized;\n\n /// @notice The number of votes to reject an optimistic proposal\n uint256 public optimisticQuorumVotes; \n\n /// @notice The delay period before voting begins\n uint256 public optimisticVotingDelay; \n\n /// @notice The maximum number of seconds an address can be whitelisted for\n uint256 public maxWhitelistPeriod; \n}\n"},"hardhat/console.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity >= 0.4.22 <0.9.0;\n\nlibrary console {\n\taddress constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n\tfunction _sendLogPayload(bytes memory payload) private view {\n\t\tuint256 payloadLength = payload.length;\n\t\taddress consoleAddress = CONSOLE_ADDRESS;\n\t\tassembly {\n\t\t\tlet payloadStart := add(payload, 32)\n\t\t\tlet r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)\n\t\t}\n\t}\n\n\tfunction log() internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log()\"));\n\t}\n\n\tfunction logInt(int p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(int)\", p0));\n\t}\n\n\tfunction logUint(uint p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n\t}\n\n\tfunction logString(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction logBool(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction logAddress(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction logBytes(bytes memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes)\", p0));\n\t}\n\n\tfunction logBytes1(bytes1 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes1)\", p0));\n\t}\n\n\tfunction logBytes2(bytes2 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes2)\", p0));\n\t}\n\n\tfunction logBytes3(bytes3 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes3)\", p0));\n\t}\n\n\tfunction logBytes4(bytes4 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes4)\", p0));\n\t}\n\n\tfunction logBytes5(bytes5 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes5)\", p0));\n\t}\n\n\tfunction logBytes6(bytes6 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes6)\", p0));\n\t}\n\n\tfunction logBytes7(bytes7 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes7)\", p0));\n\t}\n\n\tfunction logBytes8(bytes8 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes8)\", p0));\n\t}\n\n\tfunction logBytes9(bytes9 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes9)\", p0));\n\t}\n\n\tfunction logBytes10(bytes10 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes10)\", p0));\n\t}\n\n\tfunction logBytes11(bytes11 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes11)\", p0));\n\t}\n\n\tfunction logBytes12(bytes12 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes12)\", p0));\n\t}\n\n\tfunction logBytes13(bytes13 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes13)\", p0));\n\t}\n\n\tfunction logBytes14(bytes14 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes14)\", p0));\n\t}\n\n\tfunction logBytes15(bytes15 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes15)\", p0));\n\t}\n\n\tfunction logBytes16(bytes16 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes16)\", p0));\n\t}\n\n\tfunction logBytes17(bytes17 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes17)\", p0));\n\t}\n\n\tfunction logBytes18(bytes18 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes18)\", p0));\n\t}\n\n\tfunction logBytes19(bytes19 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes19)\", p0));\n\t}\n\n\tfunction logBytes20(bytes20 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes20)\", p0));\n\t}\n\n\tfunction logBytes21(bytes21 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes21)\", p0));\n\t}\n\n\tfunction logBytes22(bytes22 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes22)\", p0));\n\t}\n\n\tfunction logBytes23(bytes23 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes23)\", p0));\n\t}\n\n\tfunction logBytes24(bytes24 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes24)\", p0));\n\t}\n\n\tfunction logBytes25(bytes25 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes25)\", p0));\n\t}\n\n\tfunction logBytes26(bytes26 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes26)\", p0));\n\t}\n\n\tfunction logBytes27(bytes27 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes27)\", p0));\n\t}\n\n\tfunction logBytes28(bytes28 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes28)\", p0));\n\t}\n\n\tfunction logBytes29(bytes29 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes29)\", p0));\n\t}\n\n\tfunction logBytes30(bytes30 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes30)\", p0));\n\t}\n\n\tfunction logBytes31(bytes31 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes31)\", p0));\n\t}\n\n\tfunction logBytes32(bytes32 p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bytes32)\", p0));\n\t}\n\n\tfunction log(uint p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint)\", p0));\n\t}\n\n\tfunction log(string memory p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string)\", p0));\n\t}\n\n\tfunction log(bool p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool)\", p0));\n\t}\n\n\tfunction log(address p0) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address)\", p0));\n\t}\n\n\tfunction log(uint p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n\t}\n\n\tfunction log(string memory p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n\t}\n\n\tfunction log(bool p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n\t}\n\n\tfunction log(address p0, uint p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint)\", p0, p1));\n\t}\n\n\tfunction log(address p0, string memory p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n\t}\n\n\tfunction log(address p0, bool p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n\t}\n\n\tfunction log(address p0, address p1) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(bool p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, uint p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, bool p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, uint p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, bool p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n\t}\n\n\tfunction log(address p0, address p1, address p2) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(uint p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(uint,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(bool p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, uint p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,uint,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, bool p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, uint p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,uint,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, bool p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, uint p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,uint)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, string memory p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, bool p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n\t}\n\n\tfunction log(address p0, address p1, address p2, address p3) internal view {\n\t\t_sendLogPayload(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n\t}\n\n}\n"},"contracts/governance/governor/IGovernor.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./Structs.sol\";\n\n/// @title interface to interact with TokenDelgator\ninterface IGovernorCharlieDelegator {\n function _setImplementation(address implementation_) external;\n\n fallback() external payable;\n\n receive() external payable;\n}\n\n/// @title interface to interact with TokenDelgate\ninterface IGovernorCharlieDelegate {\n function initialize(\n address ipt_\n ) external;\n\n function propose(\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n bool emergency\n ) external returns (uint256);\n\n function queue(uint256 proposalId) external;\n\n function execute(uint256 proposalId) external payable;\n\n function executeTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) external payable;\n\n function cancel(uint256 proposalId) external;\n\n function getActions(uint256 proposalId)\n external\n view\n returns (\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas\n );\n\n function getReceipt(uint256 proposalId, address voter) external view returns (Receipt memory);\n\n function state(uint256 proposalId) external view returns (ProposalState);\n\n function castVote(uint256 proposalId, uint8 support) external;\n\n function castVoteWithReason(\n uint256 proposalId,\n uint8 support,\n string calldata reason\n ) external;\n\n function castVoteBySig(\n uint256 proposalId,\n uint8 support,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n function isWhitelisted(address account) external view returns (bool);\n\n function _setDelay(uint256 proposalTimelockDelay_) external;\n\n function _setEmergencyDelay(uint256 emergencyTimelockDelay_) external;\n\n function _setVotingDelay(uint256 newVotingDelay) external;\n\n function _setVotingPeriod(uint256 newVotingPeriod) external;\n\n function _setEmergencyVotingPeriod(uint256 newEmergencyVotingPeriod) external;\n\n function _setProposalThreshold(uint256 newProposalThreshold) external;\n\n function _setQuorumVotes(uint256 newQuorumVotes) external;\n\n function _setEmergencyQuorumVotes(uint256 newEmergencyQuorumVotes) external;\n\n function _setWhitelistAccountExpiration(address account, uint256 expiration) external;\n\n function _setWhitelistGuardian(address account) external;\n\n function _setOptimisticDelay(uint256 newOptimisticVotingDelay) external;\n\n function _setOptimisticQuorumVotes(uint256 newOptimisticQuorumVotes) external;\n}\n\n/// @title interface which contains all events emitted by delegator & delegate\ninterface GovernorCharlieEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(\n uint256 indexed id,\n address indexed proposer,\n address[] targets,\n uint256[] values,\n string[] signatures,\n bytes[] calldatas,\n uint256 indexed startBlock,\n uint256 endBlock,\n string description\n );\n\n /// @notice An event emitted when a vote has been cast on a proposal\n /// @param voter The address which casted a vote\n /// @param proposalId The proposal id which was voted on\n /// @param support Support value for the vote. 0=against, 1=for, 2=abstain\n /// @param votes Number of votes which were cast by the voter\n /// @param reason The reason given for the vote by the voter\n event VoteCast(address indexed voter, uint256 indexed proposalId, uint8 support, uint256 votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint256 indexed id);\n\n /// @notice An event emitted when a proposal has been queued in the Timelock\n event ProposalQueued(uint256 indexed id, uint256 eta);\n\n /// @notice An event emitted when a proposal has been executed in the Timelock\n event ProposalExecuted(uint256 indexed id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod);\n\n /// @notice An event emitted when the emergency voting period is set\n event EmergencyVotingPeriodSet(uint256 oldEmergencyVotingPeriod, uint256 emergencyVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold is set\n event ProposalThresholdSet(uint256 oldProposalThreshold, uint256 newProposalThreshold);\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Emitted when pendingAdmin is accepted, which means admin is updated\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /// @notice Emitted when whitelist account expiration is set\n event WhitelistAccountExpirationSet(address account, uint256 expiration);\n\n /// @notice Emitted when the whitelistGuardian is set\n event WhitelistGuardianSet(address oldGuardian, address newGuardian);\n\n /// @notice Emitted when the a new delay is set\n event NewDelay(uint256 oldTimelockDelay, uint256 proposalTimelockDelay);\n\n /// @notice Emitted when the a new emergency delay is set\n event NewEmergencyDelay(uint256 oldEmergencyTimelockDelay, uint256 emergencyTimelockDelay);\n\n /// @notice Emitted when the quorum is updated\n event NewQuorum(uint256 oldQuorumVotes, uint256 quorumVotes);\n\n /// @notice Emitted when the emergency quorum is updated\n event NewEmergencyQuorum(uint256 oldEmergencyQuorumVotes, uint256 emergencyQuorumVotes);\n\n /// @notice An event emitted when the optimistic voting delay is set\n event OptimisticVotingDelaySet(uint256 oldOptimisticVotingDelay, uint256 optimisticVotingDelay);\n\n /// @notice Emitted when the optimistic quorum is updated\n event OptimisticQuorumVotesSet(uint256 oldOptimisticQuorumVotes, uint256 optimisticQuorumVotes);\n\n /// @notice Emitted when a transaction is canceled\n event CancelTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n\n /// @notice Emitted when a transaction is executed\n event ExecuteTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n\n /// @notice Emitted when a transaction is queued\n event QueueTransaction(\n bytes32 indexed txHash,\n address indexed target,\n uint256 value,\n string signature,\n bytes data,\n uint256 eta\n );\n}\n"},"contracts/governance/governor/Structs.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nstruct Proposal {\n /// @notice Unique id for looking up a proposal\n uint256 id;\n /// @notice Creator of the proposal\n address proposer;\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint256 eta;\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint256[] values;\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint256 startBlock;\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint256 endBlock;\n /// @notice Current number of votes in favor of this proposal\n uint256 forVotes;\n /// @notice Current number of votes in opposition to this proposal\n uint256 againstVotes;\n /// @notice Current number of votes for abstaining for this proposal\n uint256 abstainVotes;\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n /// @notice Whether the proposal is an emergency proposal\n bool emergency;\n /// @notice quorum votes requires\n uint256 quorumVotes;\n /// @notice time delay\n uint256 delay;\n}\n\n/// @notice Ballot receipt record for a voter\nstruct Receipt {\n /// @notice Whether or not a vote has been cast\n bool hasVoted;\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n /// @notice The number of votes the voter had, which were cast\n uint96 votes;\n}\n\n/// @notice Possible states that a proposal may be in\nenum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed\n}\n"},"contracts/governance/governor/IIpt.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\ninterface IIpt {\n function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96);\n}\n"},"contracts/governance/governor/GovernorDelegate.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\npragma experimental ABIEncoderV2;\nimport \"hardhat/console.sol\";\n\nimport \"./IGovernor.sol\";\nimport \"./GovernorStorage.sol\";\n\ncontract GovernorCharlieDelegate is GovernorCharlieDelegateStorage, GovernorCharlieEvents, IGovernorCharlieDelegate {\n /// @notice The name of this contract\n string public constant name = \"Interest Protocol Governor\";\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint256 public constant proposalMaxOperations = 10;\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n /// @notice The EIP-712 typehash for the ballot struct used by the contract\n bytes32 public constant BALLOT_TYPEHASH = keccak256(\"Ballot(uint256 proposalId,uint8 support)\");\n\n /// @notice The time for a proposal to be executed after passing\n uint256 public constant GRACE_PERIOD = 14 days;\n\n /**\n * @notice Used to initialize the contract during delegator contructor\n * @param ipt_ The address of the IPT token\n */\n function initialize(\n address ipt_\n ) external override {\n require(!initialized, \"already been initialized\");\n ipt = IIpt(ipt_);\n votingPeriod = 40320;\n votingDelay = 13140;\n proposalThreshold = 1000000000000000000000000;\n proposalTimelockDelay = 172800;\n proposalCount = 0;\n quorumVotes = 10000000000000000000000000;\n emergencyQuorumVotes = 40000000000000000000000000;\n emergencyVotingPeriod = 6570;\n emergencyTimelockDelay = 43200;\n optimisticQuorumVotes = 2000000000000000000000000;\n optimisticVotingDelay = 18000;\n maxWhitelistPeriod = 31536000;\n\n initialized = true;\n }\n\n /// @notice any function with this modifier will call the pay_interest() function before\n modifier onlyGov() {\n require(_msgSender() == address(this), \"must come from the gov.\");\n _;\n }\n\n /**\n * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold\n * @param targets Target addresses for proposal calls\n * @param values Eth values for proposal calls\n * @param signatures Function signatures for proposal calls\n * @param calldatas Calldatas for proposal calls\n * @param description String description of the proposal\n * @return Proposal id of new proposal\n */\n function propose(\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description,\n bool emergency\n ) public override returns (uint256) {\n // Reject proposals before initiating as Governor\n require(quorumVotes != 0, \"Charlie not active\");\n // Allow addresses above proposal threshold and whitelisted addresses to propose\n require(\n ipt.getPriorVotes(_msgSender(), (block.number - 1)) >= proposalThreshold || isWhitelisted(_msgSender()),\n \"votes below proposal threshold\"\n );\n require(\n targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length,\n \"information arity mismatch\"\n );\n require(targets.length != 0, \"must provide actions\");\n require(targets.length <= proposalMaxOperations, \"too many actions\");\n\n uint256 latestProposalId = latestProposalIds[_msgSender()];\n if (latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(latestProposalId);\n require(proposersLatestProposalState != ProposalState.Active, \"one live proposal per proposer\");\n require(proposersLatestProposalState != ProposalState.Pending, \"one live proposal per proposer\");\n }\n\n proposalCount++;\n Proposal memory newProposal = Proposal({\n id: proposalCount,\n proposer: _msgSender(),\n eta: 0,\n targets: targets,\n values: values,\n signatures: signatures,\n calldatas: calldatas,\n startBlock: block.number + votingDelay,\n endBlock: block.number + votingDelay + votingPeriod,\n forVotes: 0,\n againstVotes: 0,\n abstainVotes: 0,\n canceled: false,\n executed: false,\n emergency: emergency,\n quorumVotes: quorumVotes,\n delay: proposalTimelockDelay\n });\n\n //whitelist can't make emergency\n if (emergency && !isWhitelisted(_msgSender())) {\n newProposal.startBlock = block.number;\n newProposal.endBlock = block.number + emergencyVotingPeriod;\n newProposal.quorumVotes = emergencyQuorumVotes;\n newProposal.delay = emergencyTimelockDelay;\n }\n\n //whitelist can only make optimistic proposals\n if (isWhitelisted(_msgSender())) {\n newProposal.quorumVotes = optimisticQuorumVotes;\n newProposal.startBlock = block.number + optimisticVotingDelay;\n newProposal.endBlock = block.number + optimisticVotingDelay + votingPeriod;\n }\n\n proposals[newProposal.id] = newProposal;\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n emit ProposalCreated(\n newProposal.id,\n _msgSender(),\n targets,\n values,\n signatures,\n calldatas,\n newProposal.startBlock,\n newProposal.endBlock,\n description\n );\n return newProposal.id;\n }\n\n /**\n * @notice Queues a proposal of state succeeded\n * @param proposalId The id of the proposal to queue\n */\n function queue(uint256 proposalId) external override {\n require(state(proposalId) == ProposalState.Succeeded, \"can only be queued if succeeded\");\n Proposal storage proposal = proposals[proposalId];\n uint256 eta = block.timestamp + proposal.delay;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n require(\n !queuedTransactions[\n keccak256(\n abi.encode(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta)\n )\n ],\n \"proposal already queued\"\n );\n queueTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n eta,\n proposal.delay\n );\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta,\n uint256 delay\n ) internal returns (bytes32) {\n require(eta >= (getBlockTimestamp() + delay), \"must satisfy delay.\");\n\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = true;\n\n emit QueueTransaction(txHash, target, value, signature, data, eta);\n return txHash;\n }\n\n /**\n * @notice Executes a queued proposal if eta has passed\n * @param proposalId The id of the proposal to execute\n */\n function execute(uint256 proposalId) external payable override {\n require(state(proposalId) == ProposalState.Queued, \"can only be exec'd if queued\");\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n this.executeTransaction{value: proposal.values[i]}(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n emit ProposalExecuted(proposalId);\n }\n\n function executeTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) external payable override {\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n require(queuedTransactions[txHash], \"tx hasn't been queued.\");\n require(getBlockTimestamp() >= eta, \"tx hasn't surpassed timelock.\");\n require(getBlockTimestamp() <= eta + GRACE_PERIOD, \"tx is stale.\");\n\n queuedTransactions[txHash] = false;\n\n bytes memory callData;\n\n if (bytes(signature).length == 0) {\n callData = data;\n } else {\n callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data);\n }\n\n // solhint-disable-next-line avoid-low-level-calls\n (\n bool success, /*bytes memory returnData*/\n\n ) = target.call{value: value}(callData);\n require(success, \"tx execution reverted.\");\n\n emit ExecuteTransaction(txHash, target, value, signature, data, eta);\n }\n\n /**\n * @notice Cancels a proposal only if sender is the proposer, or proposer delegates dropped below proposal threshold\n * @param proposalId The id of the proposal to cancel\n */\n function cancel(uint256 proposalId) external override {\n require(state(proposalId) != ProposalState.Executed, \"cant cancel executed proposal\");\n\n Proposal storage proposal = proposals[proposalId];\n\n // Proposer can cancel\n if (_msgSender() != proposal.proposer) {\n // Whitelisted proposers can't be canceled for falling below proposal threshold\n if (isWhitelisted(proposal.proposer)) {\n require(\n (ipt.getPriorVotes(proposal.proposer, (block.number - 1)) < proposalThreshold) &&\n _msgSender() == whitelistGuardian,\n \"cancel: whitelisted proposer\"\n );\n } else {\n require(\n (ipt.getPriorVotes(proposal.proposer, (block.number - 1)) < proposalThreshold),\n \"cancel: proposer above threshold\"\n );\n }\n }\n\n proposal.canceled = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n function cancelTransaction(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) internal {\n bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));\n queuedTransactions[txHash] = false;\n\n emit CancelTransaction(txHash, target, value, signature, data, eta);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets proposal targets\n * @return values proposal values\n * @return signatures proposal signatures\n * @return calldatas proposal calldatae\n */\n function getActions(uint256 proposalId)\n external\n view\n override\n returns (\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas\n )\n {\n Proposal storage p = proposals[proposalId];\n return (p.targets, p.values, p.signatures, p.calldatas);\n }\n\n /**\n * @notice Gets the receipt for a voter on a given proposal\n * @param proposalId the id of proposal\n * @param voter The address of the voter\n * @return The voting receipt\n */\n function getReceipt(uint256 proposalId, address voter) external view override returns (Receipt memory) {\n return proposalReceipts[proposalId][voter];\n }\n\n /**\n * @notice Gets the state of a proposal\n * @param proposalId The id of the proposal\n * @return Proposal state\n */\n // solhint-disable-next-line code-complexity\n function state(uint256 proposalId) public view override returns (ProposalState) {\n require(proposalCount >= proposalId && proposalId > initialProposalId, \"state: invalid proposal id\");\n Proposal storage proposal = proposals[proposalId];\n bool whitelisted = isWhitelisted(proposal.proposer);\n if (proposal.canceled) {\n return ProposalState.Canceled;\n } else if (block.number <= proposal.startBlock) {\n return ProposalState.Pending;\n } else if (block.number <= proposal.endBlock) {\n return ProposalState.Active;\n } else if (\n (whitelisted && proposal.againstVotes > proposal.quorumVotes) ||\n (!whitelisted && proposal.forVotes <= proposal.againstVotes) ||\n (!whitelisted && proposal.forVotes < proposal.quorumVotes)\n ) {\n return ProposalState.Defeated;\n } else if (proposal.eta == 0) {\n return ProposalState.Succeeded;\n } else if (proposal.executed) {\n return ProposalState.Executed;\n } else if (block.timestamp >= (proposal.eta + GRACE_PERIOD)) {\n return ProposalState.Expired;\n }\n return ProposalState.Queued;\n }\n\n /**\n * @notice Cast a vote for a proposal\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n */\n function castVote(uint256 proposalId, uint8 support) external override {\n emit VoteCast(_msgSender(), proposalId, support, castVoteInternal(_msgSender(), proposalId, support), \"\");\n }\n\n /**\n * @notice Cast a vote for a proposal with a reason\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param reason The reason given for the vote by the voter\n */\n function castVoteWithReason(\n uint256 proposalId,\n uint8 support,\n string calldata reason\n ) external override {\n emit VoteCast(_msgSender(), proposalId, support, castVoteInternal(_msgSender(), proposalId, support), reason);\n }\n\n /**\n * @notice Cast a vote for a proposal by signature\n * @dev external override function that accepts EIP-712 signatures for voting on proposals.\n */\n function castVoteBySig(\n uint256 proposalId,\n uint8 support,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"castVoteBySig: invalid signature\");\n emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), \"\");\n }\n\n /**\n * @notice Internal function that caries out voting logic\n * @param voter The voter that is casting their vote\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @return The number of votes cast\n */\n function castVoteInternal(\n address voter,\n uint256 proposalId,\n uint8 support\n ) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, \"voting is closed\");\n require(support <= 2, \"invalid vote type\");\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposalReceipts[proposalId][voter];\n require(receipt.hasVoted == false, \"voter already voted\");\n uint96 votes = ipt.getPriorVotes(voter, proposal.startBlock);\n\n if (support == 0) {\n proposal.againstVotes = proposal.againstVotes + votes;\n } else if (support == 1) {\n proposal.forVotes = proposal.forVotes + votes;\n } else if (support == 2) {\n proposal.abstainVotes = proposal.abstainVotes + votes;\n }\n\n receipt.hasVoted = true;\n receipt.support = support;\n receipt.votes = votes;\n\n return votes;\n }\n\n /**\n * @notice View function which returns if an account is whitelisted\n * @param account Account to check white list status of\n * @return If the account is whitelisted\n */\n function isWhitelisted(address account) public view override returns (bool) {\n return (whitelistAccountExpirations[account] > block.timestamp);\n }\n\n /**\n * @notice Governance function for setting the governance token\n * @param token_ new token addr\n */\n function _setNewToken(address token_) external onlyGov {\n ipt = IIpt(token_);\n }\n\n /**\n * @notice Used to update the timelock period\n * @param proposalTimelockDelay_ The proposal holding period\n */\n function _setDelay(uint256 proposalTimelockDelay_) public override onlyGov {\n uint256 oldTimelockDelay = proposalTimelockDelay;\n proposalTimelockDelay = proposalTimelockDelay_;\n\n emit NewDelay(oldTimelockDelay, proposalTimelockDelay);\n }\n\n /**\n * @notice Used to update the emergency timelock period\n * @param emergencyTimelockDelay_ The proposal holding period\n */\n function _setEmergencyDelay(uint256 emergencyTimelockDelay_) public override onlyGov {\n uint256 oldEmergencyTimelockDelay = emergencyTimelockDelay;\n emergencyTimelockDelay = emergencyTimelockDelay_;\n\n emit NewEmergencyDelay(oldEmergencyTimelockDelay, emergencyTimelockDelay);\n }\n\n /**\n * @notice Governance function for setting the voting delay\n * @param newVotingDelay new voting delay, in blocks\n */\n function _setVotingDelay(uint256 newVotingDelay) external override onlyGov {\n uint256 oldVotingDelay = votingDelay;\n votingDelay = newVotingDelay;\n\n emit VotingDelaySet(oldVotingDelay, votingDelay);\n }\n\n /**\n * @notice Governance function for setting the voting period\n * @param newVotingPeriod new voting period, in blocks\n */\n function _setVotingPeriod(uint256 newVotingPeriod) external override onlyGov {\n uint256 oldVotingPeriod = votingPeriod;\n votingPeriod = newVotingPeriod;\n\n emit VotingPeriodSet(oldVotingPeriod, votingPeriod);\n }\n\n /**\n * @notice Governance function for setting the emergency voting period\n * @param newEmergencyVotingPeriod new voting period, in blocks\n */\n function _setEmergencyVotingPeriod(uint256 newEmergencyVotingPeriod) external override onlyGov {\n uint256 oldEmergencyVotingPeriod = emergencyVotingPeriod;\n emergencyVotingPeriod = newEmergencyVotingPeriod;\n\n emit EmergencyVotingPeriodSet(oldEmergencyVotingPeriod, emergencyVotingPeriod);\n }\n\n /**\n * @notice Governance function for setting the proposal threshold\n * @param newProposalThreshold new proposal threshold\n */\n function _setProposalThreshold(uint256 newProposalThreshold) external override onlyGov {\n uint256 oldProposalThreshold = proposalThreshold;\n proposalThreshold = newProposalThreshold;\n\n emit ProposalThresholdSet(oldProposalThreshold, proposalThreshold);\n }\n\n /**\n * @notice Governance function for setting the quorum\n * @param newQuorumVotes new proposal quorum\n */\n function _setQuorumVotes(uint256 newQuorumVotes) external override onlyGov {\n uint256 oldQuorumVotes = quorumVotes;\n quorumVotes = newQuorumVotes;\n\n emit NewQuorum(oldQuorumVotes, quorumVotes);\n }\n\n /**\n * @notice Governance function for setting the emergency quorum\n * @param newEmergencyQuorumVotes new proposal quorum\n */\n function _setEmergencyQuorumVotes(uint256 newEmergencyQuorumVotes) external override onlyGov {\n uint256 oldEmergencyQuorumVotes = emergencyQuorumVotes;\n emergencyQuorumVotes = newEmergencyQuorumVotes;\n\n emit NewEmergencyQuorum(oldEmergencyQuorumVotes, emergencyQuorumVotes);\n }\n\n /**\n * @notice Governance function for setting the whitelist expiration as a timestamp\n * for an account. Whitelist status allows accounts to propose without meeting threshold\n * @param account Account address to set whitelist expiration for\n * @param expiration Expiration for account whitelist status as timestamp (if now < expiration, whitelisted)\n */\n function _setWhitelistAccountExpiration(address account, uint256 expiration) external override onlyGov {\n require (expiration < (maxWhitelistPeriod + block.timestamp), \"expiration exceeds max\");\n whitelistAccountExpirations[account] = expiration;\n\n emit WhitelistAccountExpirationSet(account, expiration);\n }\n\n /**\n * @notice Governance function for setting the whitelistGuardian. WhitelistGuardian can cancel proposals from whitelisted addresses\n * @param account Account to set whitelistGuardian to (0x0 to remove whitelistGuardian)\n */\n function _setWhitelistGuardian(address account) external override onlyGov {\n address oldGuardian = whitelistGuardian;\n whitelistGuardian = account;\n\n emit WhitelistGuardianSet(oldGuardian, whitelistGuardian);\n }\n\n /**\n * @notice Governance function for setting the optimistic voting delay\n * @param newOptimisticVotingDelay new optimistic voting delay, in blocks\n */\n function _setOptimisticDelay(uint256 newOptimisticVotingDelay) external override onlyGov {\n uint256 oldOptimisticVotingDelay = optimisticVotingDelay;\n optimisticVotingDelay = newOptimisticVotingDelay;\n\n emit OptimisticVotingDelaySet(oldOptimisticVotingDelay, optimisticVotingDelay);\n }\n\n /**\n * @notice Governance function for setting the optimistic quorum\n * @param newOptimisticQuorumVotes new optimistic quorum votes, in blocks\n */\n function _setOptimisticQuorumVotes(uint256 newOptimisticQuorumVotes) external override onlyGov {\n uint256 oldOptimisticQuorumVotes = optimisticQuorumVotes;\n optimisticQuorumVotes = newOptimisticQuorumVotes;\n\n emit OptimisticQuorumVotesSet(oldOptimisticQuorumVotes, optimisticQuorumVotes);\n }\n\n function getChainIdInternal() internal view returns (uint256) {\n return block.chainid;\n }\n\n function getBlockTimestamp() internal view returns (uint256) {\n // solium-disable-next-line security/no-block-members\n return block.timestamp;\n }\n\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n}\n"}},"settings":{"optimizer":{"enabled":true,"runs":200,"details":{"orderLiterals":true,"deduplicate":true,"cse":true,"yul":true}},"outputSelection":{"*":{"*":["evm.bytecode","evm.deployedBytecode","devdoc","userdoc","metadata","abi"]}},"libraries":{}}},"ABI":"[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"CancelTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyVotingPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"EmergencyVotingPeriodSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"ExecuteTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"NewAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimelockDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"proposalTimelockDelay\",\"type\":\"uint256\"}],\"name\":\"NewDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyTimelockDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyTimelockDelay\",\"type\":\"uint256\"}],\"name\":\"NewEmergencyDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldEmergencyQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"emergencyQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"NewEmergencyQuorum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldImplementation\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"NewImplementation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldPendingAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPendingAdmin\",\"type\":\"address\"}],\"name\":\"NewPendingAdmin\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"quorumVotes\",\"type\":\"uint256\"}],\"name\":\"NewQuorum\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOptimisticQuorumVotes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"OptimisticQuorumVotesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldOptimisticVotingDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticVotingDelay\",\"type\":\"uint256\"}],\"name\":\"OptimisticVotingDelaySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"ProposalCanceled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"proposer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"indexed\":false,\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"startBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"endBlock\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"}],\"name\":\"ProposalCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"ProposalExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"ProposalQueued\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldProposalThreshold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newProposalThreshold\",\"type\":\"uint256\"}],\"name\":\"ProposalThresholdSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"QueueTransaction\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"voter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"votes\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"VoteCast\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldVotingDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newVotingDelay\",\"type\":\"uint256\"}],\"name\":\"VotingDelaySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldVotingPeriod\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"VotingPeriodSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"expiration\",\"type\":\"uint256\"}],\"name\":\"WhitelistAccountExpirationSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldGuardian\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGuardian\",\"type\":\"address\"}],\"name\":\"WhitelistGuardianSet\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BALLOT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GRACE_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalTimelockDelay_\",\"type\":\"uint256\"}],\"name\":\"_setDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"emergencyTimelockDelay_\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newEmergencyQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newEmergencyVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"_setEmergencyVotingPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token_\",\"type\":\"address\"}],\"name\":\"_setNewToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newOptimisticVotingDelay\",\"type\":\"uint256\"}],\"name\":\"_setOptimisticDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newOptimisticQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setOptimisticQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newProposalThreshold\",\"type\":\"uint256\"}],\"name\":\"_setProposalThreshold\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newQuorumVotes\",\"type\":\"uint256\"}],\"name\":\"_setQuorumVotes\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newVotingDelay\",\"type\":\"uint256\"}],\"name\":\"_setVotingDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newVotingPeriod\",\"type\":\"uint256\"}],\"name\":\"_setVotingPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"expiration\",\"type\":\"uint256\"}],\"name\":\"_setWhitelistAccountExpiration\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"_setWhitelistGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"cancel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"}],\"name\":\"castVote\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"castVoteBySig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"castVoteWithReason\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyQuorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyTimelockDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"emergencyVotingPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"execute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"signature\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"}],\"name\":\"executeTransaction\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"getActions\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"voter\",\"type\":\"address\"}],\"name\":\"getReceipt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"hasVoted\",\"type\":\"bool\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"internalType\":\"struct Receipt\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialProposalId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ipt_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ipt\",\"outputs\":[{\"internalType\":\"contract IIpt\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"latestProposalIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxWhitelistPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticQuorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticVotingDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalMaxOperations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"proposalReceipts\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"hasVoted\",\"type\":\"bool\"},{\"internalType\":\"uint8\",\"name\":\"support\",\"type\":\"uint8\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalThreshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proposalTimelockDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"proposals\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"proposer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"eta\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"startBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"endBlock\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"forVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"againstVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"abstainVotes\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"canceled\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"executed\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"emergency\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"quorumVotes\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"delay\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"targets\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"},{\"internalType\":\"string[]\",\"name\":\"signatures\",\"type\":\"string[]\"},{\"internalType\":\"bytes[]\",\"name\":\"calldatas\",\"type\":\"bytes[]\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"emergency\",\"type\":\"bool\"}],\"name\":\"propose\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"queue\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"queuedTransactions\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"quorumVotes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"proposalId\",\"type\":\"uint256\"}],\"name\":\"state\",\"outputs\":[{\"internalType\":\"enum ProposalState\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"whitelistAccountExpirations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"whitelistGuardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]","ContractName":"GovernorCharlieDelegate","CompilerVersion":"v0.8.9+commit.e5eed63a","OptimizationUsed":1,"Runs":200,"ConstructorArguments":"0x","EVMVersion":"Default","Library":"","LicenseType":"","Proxy":0,"SwarmSource":""}] \ No newline at end of file diff --git a/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json index d145e56aa8881..2378ed6aa2a8d 100644 --- a/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json +++ b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json @@ -1,5 +1 @@ -{ - "contractAddress": "0x9ab6b21cdf116f611110b048987e58894786c244", - "contractCreator": "0x603d50bad151da8becf405e51a8c4abc8ba1c95e", - "txHash": "0x72be611ae1ade09242d9fc9c950a73d076f6c23514564a7b9ac730400dbaf2c0" -} \ No newline at end of file +{"contractAddress":"0x9ab6b21cdf116f611110b048987e58894786c244","contractCreator":"0x603d50bad151da8becf405e51a8c4abc8ba1c95e","txHash":"0x72be611ae1ade09242d9fc9c950a73d076f6c23514564a7b9ac730400dbaf2c0"} \ No newline at end of file diff --git a/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json index ab133f38ff7a1..b0f893895eb0f 100644 --- a/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json +++ b/testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/metadata.json @@ -1,69 +1 @@ -[ - { - "SourceCode": { - "language": "Solidity", - "sources": { - "contracts/InterestRates/InterestRatePositionManager.f.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n/// Parameters for ERC20Permit.permit call\nstruct ERC20PermitSignature {\n IERC20Permit token;\n uint256 value;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\nlibrary PermitHelper {\n function applyPermit(\n ERC20PermitSignature calldata p,\n address owner,\n address spender\n ) internal {\n p.token.permit(owner, spender, p.value, p.deadline, p.v, p.r, p.s);\n }\n\n function applyPermits(\n ERC20PermitSignature[] calldata permits,\n address owner,\n address spender\n ) internal {\n for (uint256 i = 0; i < permits.length; i++) {\n applyPermit(permits[i], owner, spender);\n }\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashLender.sol)\n\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol)\n\n/**\n * @dev Interface of the ERC3156 FlashBorrower, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashBorrower {\n /**\n * @dev Receive a flash loan.\n * @param initiator The initiator of the loan.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @param fee The additional amount of tokens to repay.\n * @param data Arbitrary data structure, intended to contain user-defined parameters.\n * @return The keccak256 hash of \"IERC3156FlashBorrower.onFlashLoan\"\n */\n function onFlashLoan(\n address initiator,\n address token,\n uint256 amount,\n uint256 fee,\n bytes calldata data\n ) external returns (bytes32);\n}\n\n/**\n * @dev Interface of the ERC3156 FlashLender, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashLender {\n /**\n * @dev The amount of currency available to be lended.\n * @param token The loan currency.\n * @return The amount of `token` that can be borrowed.\n */\n function maxFlashLoan(address token) external view returns (uint256);\n\n /**\n * @dev The fee to be charged for a given loan.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @return The amount of `token` to be charged for the loan, on top of the returned principal.\n */\n function flashFee(address token, uint256 amount) external view returns (uint256);\n\n /**\n * @dev Initiate a flash loan.\n * @param receiver The receiver of the tokens in the loan, and the receiver of the callback.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @param data Arbitrary data structure, intended to contain user-defined parameters.\n */\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n ) external returns (bool);\n}\n\n/// @dev Interface to be used by contracts that collect fees. Contains fee recipient that can be changed by owner.\ninterface IFeeCollector {\n // --- Events ---\n\n /// @dev Fee Recipient is changed to @param feeRecipient address.\n /// @param feeRecipient New fee recipient address.\n event FeeRecipientChanged(address feeRecipient);\n\n // --- Errors ---\n\n /// @dev Invalid fee recipient.\n error InvalidFeeRecipient();\n\n // --- Functions ---\n\n /// @return Address of the current fee recipient.\n function feeRecipient() external view returns (address);\n\n /// @dev Sets new fee recipient address\n /// @param newFeeRecipient Address of the new fee recipient.\n function setFeeRecipient(address newFeeRecipient) external;\n}\n\ninterface IPositionManagerDependent {\n // --- Errors ---\n\n /// @dev Position Manager cannot be zero.\n error PositionManagerCannotBeZero();\n\n /// @dev Caller is not Position Manager.\n error CallerIsNotPositionManager(address caller);\n\n // --- Functions ---\n\n /// @dev Returns address of the PositionManager contract.\n function positionManager() external view returns (address);\n}\n\n/// @dev Interface of R stablecoin token. Implements some standards like IERC20, IERC20Permit, and IERC3156FlashLender.\n/// Raft's specific implementation contains IFeeCollector and IPositionManagerDependent.\n/// PositionManager can mint and burn R when particular actions happen with user's position.\ninterface IRToken is IERC20, IERC20Permit, IERC3156FlashLender, IFeeCollector, IPositionManagerDependent {\n // --- Events ---\n\n /// @dev New R token is deployed\n /// @param positionManager Address of the PositionManager contract that is authorized to mint and burn new tokens.\n /// @param flashMintFeeRecipient Address of flash mint fee recipient.\n event RDeployed(address positionManager, address flashMintFeeRecipient);\n\n /// @dev The Flash Mint Fee Percentage has been changed.\n /// @param flashMintFeePercentage The new Flash Mint Fee Percentage value.\n event FlashMintFeePercentageChanged(uint256 flashMintFeePercentage);\n\n /// --- Errors ---\n\n /// @dev Proposed flash mint fee percentage is too big.\n /// @param feePercentage Proposed flash mint fee percentage.\n error FlashFeePercentageTooBig(uint256 feePercentage);\n\n // --- Functions ---\n\n /// @return Number representing 100 percentage.\n function PERCENTAGE_BASE() external view returns (uint256);\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param to Address that will receive newly minted tokens.\n /// @param amount Amount of tokens to mint.\n function mint(address to, uint256 amount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param from Address of user whose tokens are burnt.\n /// @param amount Amount of tokens to burn.\n function burn(address from, uint256 amount) external;\n\n /// @return Maximum flash mint fee percentage that can be set by owner.\n function MAX_FLASH_MINT_FEE_PERCENTAGE() external view returns (uint256);\n\n /// @return Current flash mint fee percentage.\n function flashMintFeePercentage() external view returns (uint256);\n\n /// @dev Sets new flash mint fee percentage. Callable only by owner.\n /// @notice The proposed flash mint fee percentage cannot exceed `MAX_FLASH_MINT_FEE_PERCENTAGE`.\n /// @param feePercentage New flash fee percentage.\n function setFlashMintFeePercentage(uint256 feePercentage) external;\n}\n\ninterface IPriceOracle {\n // --- Errors ---\n\n /// @dev Contract initialized with an invalid deviation parameter.\n error InvalidDeviation();\n\n // --- Types ---\n\n struct PriceOracleResponse {\n bool isBrokenOrFrozen;\n bool priceChangeAboveMax;\n uint256 price;\n }\n\n // --- Functions ---\n\n /// @dev Return price oracle response which consists the following information: oracle is broken or frozen, the\n /// price change between two rounds is more than max, and the price.\n function getPriceOracleResponse() external returns (PriceOracleResponse memory);\n\n /// @dev Maximum time period allowed since oracle latest round data timestamp, beyond which oracle is considered\n /// frozen.\n function timeout() external view returns (uint256);\n\n /// @dev Used to convert a price answer to an 18-digit precision uint.\n function TARGET_DIGITS() external view returns (uint256);\n\n /// @dev price deviation for the oracle in percentage.\n function DEVIATION() external view returns (uint256);\n}\n\ninterface IPriceFeed {\n // --- Events ---\n\n /// @dev Last good price has been updated.\n event LastGoodPriceUpdated(uint256 lastGoodPrice);\n\n /// @dev Price difference between oracles has been updated.\n /// @param priceDifferenceBetweenOracles New price difference between oracles.\n event PriceDifferenceBetweenOraclesUpdated(uint256 priceDifferenceBetweenOracles);\n\n /// @dev Primary oracle has been updated.\n /// @param primaryOracle New primary oracle.\n event PrimaryOracleUpdated(IPriceOracle primaryOracle);\n\n /// @dev Secondary oracle has been updated.\n /// @param secondaryOracle New secondary oracle.\n event SecondaryOracleUpdated(IPriceOracle secondaryOracle);\n\n // --- Errors ---\n\n /// @dev Invalid primary oracle.\n error InvalidPrimaryOracle();\n\n /// @dev Invalid secondary oracle.\n error InvalidSecondaryOracle();\n\n /// @dev Primary oracle is broken or frozen or has bad result.\n error PrimaryOracleBrokenOrFrozenOrBadResult();\n\n /// @dev Invalid price difference between oracles.\n error InvalidPriceDifferenceBetweenOracles();\n\n // --- Functions ---\n\n /// @dev Return primary oracle address.\n function primaryOracle() external returns (IPriceOracle);\n\n /// @dev Return secondary oracle address\n function secondaryOracle() external returns (IPriceOracle);\n\n /// @dev The last good price seen from an oracle by Raft.\n function lastGoodPrice() external returns (uint256);\n\n /// @dev The maximum relative price difference between two oracle responses.\n function priceDifferenceBetweenOracles() external returns (uint256);\n\n /// @dev Set primary oracle address.\n /// @param newPrimaryOracle Primary oracle address.\n function setPrimaryOracle(IPriceOracle newPrimaryOracle) external;\n\n /// @dev Set secondary oracle address.\n /// @param newSecondaryOracle Secondary oracle address.\n function setSecondaryOracle(IPriceOracle newSecondaryOracle) external;\n\n /// @dev Set the maximum relative price difference between two oracle responses.\n /// @param newPriceDifferenceBetweenOracles The maximum relative price difference between two oracle responses.\n function setPriceDifferenceBetweenOracles(uint256 newPriceDifferenceBetweenOracles) external;\n\n /// @dev Returns the latest price obtained from the Oracle. Called by Raft functions that require a current price.\n ///\n /// Also callable by anyone externally.\n /// Non-view function - it stores the last good price seen by Raft.\n ///\n /// Uses a primary oracle and a fallback oracle in case primary fails. If both fail,\n /// it uses the last good price seen by Raft.\n ///\n /// @return currentPrice Returned price.\n /// @return deviation Deviation of the reported price in percentage.\n /// @notice Actual returned price is in range `currentPrice` +/- `currentPrice * deviation / ONE`\n function fetchPrice() external returns (uint256 currentPrice, uint256 deviation);\n}\n\ninterface IERC20Indexable is IERC20, IPositionManagerDependent {\n // --- Events ---\n\n /// @dev New token is deployed.\n /// @param positionManager Address of the PositionManager contract that is authorized to mint and burn new tokens.\n event ERC20IndexableDeployed(address positionManager);\n\n /// @dev New index has been set.\n /// @param newIndex Value of the new index.\n event IndexUpdated(uint256 newIndex);\n\n // --- Errors ---\n\n /// @dev Unsupported action for ERC20Indexable contract.\n error NotSupported();\n\n // --- Functions ---\n\n /// @return Precision for token index. Represents index that is equal to 1.\n function INDEX_PRECISION() external view returns (uint256);\n\n /// @return Current index value.\n function currentIndex() external view returns (uint256);\n\n /// @dev Sets new token index. Callable only by PositionManager contract.\n /// @param backingAmount Amount of backing token that is covered by total supply.\n function setIndex(uint256 backingAmount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param to Address that will receive newly minted tokens.\n /// @param amount Amount of tokens to mint.\n function mint(address to, uint256 amount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param from Address of user whose tokens are burnt.\n /// @param amount Amount of tokens to burn.\n function burn(address from, uint256 amount) external;\n}\n\ninterface ISplitLiquidationCollateral {\n // --- Functions ---\n\n /// @dev Returns lowest total debt that will be split.\n function LOW_TOTAL_DEBT() external view returns (uint256);\n\n /// @dev Minimum collateralization ratio for position\n function MCR() external view returns (uint256);\n\n /// @dev Splits collateral between protocol and liquidator.\n /// @param totalCollateral Amount of collateral to split.\n /// @param totalDebt Amount of debt to split.\n /// @param price Price of collateral.\n /// @param isRedistribution True if this is a redistribution.\n /// @return collateralToSendToProtocol Amount of collateral to send to protocol.\n /// @return collateralToSentToLiquidator Amount of collateral to send to liquidator.\n function split(\n uint256 totalCollateral,\n uint256 totalDebt,\n uint256 price,\n bool isRedistribution\n )\n external\n view\n returns (uint256 collateralToSendToProtocol, uint256 collateralToSentToLiquidator);\n}\n\n/// @dev Common interface for the Position Manager.\ninterface IPositionManager is IFeeCollector {\n // --- Types ---\n\n /// @dev Information for a Raft indexable collateral token.\n /// @param collateralToken The Raft indexable collateral token.\n /// @param debtToken Corresponding Raft indexable debt token.\n /// @param priceFeed The contract that provides a price for the collateral token.\n /// @param splitLiquidation The contract that calculates collateral split in case of liquidation.\n /// @param isEnabled Whether the token can be used as collateral or not.\n /// @param lastFeeOperationTime Timestamp of the last operation for the collateral token.\n /// @param borrowingSpread The current borrowing spread.\n /// @param baseRate The current base rate.\n /// @param redemptionSpread The current redemption spread.\n /// @param redemptionRebate Percentage of the redemption fee returned to redeemed positions.\n struct CollateralTokenInfo {\n IERC20Indexable collateralToken;\n IERC20Indexable debtToken;\n IPriceFeed priceFeed;\n ISplitLiquidationCollateral splitLiquidation;\n bool isEnabled;\n uint256 lastFeeOperationTime;\n uint256 borrowingSpread;\n uint256 baseRate;\n uint256 redemptionSpread;\n uint256 redemptionRebate;\n }\n\n // --- Events ---\n\n /// @dev New position manager has been token deployed.\n /// @param rToken The R token used by the position manager.\n /// @param feeRecipient The address of fee recipient.\n event PositionManagerDeployed(IRToken rToken, address feeRecipient);\n\n /// @dev New collateral token has been added added to the system.\n /// @param collateralToken The token used as collateral.\n /// @param raftCollateralToken The Raft indexable collateral token for the given collateral token.\n /// @param raftDebtToken The Raft indexable debt token for given collateral token.\n /// @param priceFeed The contract that provides price for the collateral token.\n event CollateralTokenAdded(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n IPriceFeed priceFeed\n );\n\n /// @dev Collateral token has been enabled or disabled.\n /// @param collateralToken The token used as collateral.\n /// @param isEnabled True if the token is enabled, false otherwise.\n event CollateralTokenModified(IERC20 collateralToken, bool isEnabled);\n\n /// @dev A delegate has been whitelisted for a certain position.\n /// @param position The position for which the delegate was whitelisted.\n /// @param delegate The delegate which was whitelisted.\n /// @param whitelisted Specifies whether the delegate whitelisting has been enabled (true) or disabled (false).\n event DelegateWhitelisted(address indexed position, address indexed delegate, bool whitelisted);\n\n /// @dev New position has been created.\n /// @param position The address of the user opening new position.\n /// @param collateralToken The token used as collateral for the created position.\n event PositionCreated(address indexed position, IERC20 indexed collateralToken);\n\n /// @dev The position has been closed by either repayment, liquidation, or redemption.\n /// @param position The address of the user whose position is closed.\n event PositionClosed(address indexed position);\n\n /// @dev Collateral amount for the position has been changed.\n /// @param position The address of the user that has opened the position.\n /// @param collateralToken The address of the collateral token being added to position.\n /// @param collateralAmount The amount of collateral added or removed.\n /// @param isCollateralIncrease Whether the collateral is added to the position or removed from it.\n event CollateralChanged(\n address indexed position, IERC20 indexed collateralToken, uint256 collateralAmount, bool isCollateralIncrease\n );\n\n /// @dev Debt amount for position has been changed.\n /// @param position The address of the user that has opened the position.\n /// @param collateralToken The address of the collateral token backing the debt.\n /// @param debtAmount The amount of debt added or removed.\n /// @param isDebtIncrease Whether the debt is added to the position or removed from it.\n event DebtChanged(\n address indexed position, IERC20 indexed collateralToken, uint256 debtAmount, bool isDebtIncrease\n );\n\n /// @dev Borrowing fee has been paid. Emitted only if the actual fee was paid - doesn't happen with no fees are\n /// paid.\n /// @param collateralToken Collateral token used to mint R.\n /// @param position The address of position's owner that triggered the fee payment.\n /// @param feeAmount The amount of tokens paid as the borrowing fee.\n event RBorrowingFeePaid(IERC20 collateralToken, address indexed position, uint256 feeAmount);\n\n /// @dev Liquidation has been executed.\n /// @param liquidator The liquidator that executed the liquidation.\n /// @param position The address of position's owner whose position was liquidated.\n /// @param collateralToken The collateral token used for the liquidation.\n /// @param debtLiquidated The total debt that was liquidated or redistributed.\n /// @param collateralLiquidated The total collateral liquidated.\n /// @param collateralSentToLiquidator The collateral amount sent to the liquidator.\n /// @param collateralLiquidationFeePaid The total collateral paid as the liquidation fee to the fee recipient.\n /// @param isRedistribution Whether the executed liquidation was redistribution or not.\n event Liquidation(\n address indexed liquidator,\n address indexed position,\n IERC20 indexed collateralToken,\n uint256 debtLiquidated,\n uint256 collateralLiquidated,\n uint256 collateralSentToLiquidator,\n uint256 collateralLiquidationFeePaid,\n bool isRedistribution\n );\n\n /// @dev Redemption has been executed.\n /// @param redeemer User that redeemed R.\n /// @param amount Amount of R that was redeemed.\n /// @param collateralSent The amount of collateral sent to the redeemer.\n /// @param fee The amount of fee paid to the fee recipient.\n /// @param rebate Redemption rebate amount.\n event Redemption(address indexed redeemer, uint256 amount, uint256 collateralSent, uint256 fee, uint256 rebate);\n\n /// @dev Borrowing spread has been updated.\n /// @param borrowingSpread The new borrowing spread.\n event BorrowingSpreadUpdated(uint256 borrowingSpread);\n\n /// @dev Redemption rebate has been updated.\n /// @param redemptionRebate The new redemption rebate.\n event RedemptionRebateUpdated(uint256 redemptionRebate);\n\n /// @dev Redemption spread has been updated.\n /// @param collateralToken Collateral token that the spread was set for.\n /// @param redemptionSpread The new redemption spread.\n event RedemptionSpreadUpdated(IERC20 collateralToken, uint256 redemptionSpread);\n\n /// @dev Base rate has been updated.\n /// @param collateralToken Collateral token that the baser rate was updated for.\n /// @param baseRate The new base rate.\n event BaseRateUpdated(IERC20 collateralToken, uint256 baseRate);\n\n /// @dev Last fee operation time has been updated.\n /// @param collateralToken Collateral token that the baser rate was updated for.\n /// @param lastFeeOpTime The new operation time.\n event LastFeeOpTimeUpdated(IERC20 collateralToken, uint256 lastFeeOpTime);\n\n /// @dev Split liquidation collateral has been changed.\n /// @param collateralToken Collateral token whose split liquidation collateral contract is set.\n /// @param newSplitLiquidationCollateral New value that was set to be split liquidation collateral.\n event SplitLiquidationCollateralChanged(\n IERC20 collateralToken, ISplitLiquidationCollateral indexed newSplitLiquidationCollateral\n );\n\n // --- Errors ---\n\n /// @dev Max fee percentage must be between borrowing spread and 100%.\n error InvalidMaxFeePercentage();\n\n /// @dev Max fee percentage must be between 0.5% and 100%.\n error MaxFeePercentageOutOfRange();\n\n /// @dev Amount is zero.\n error AmountIsZero();\n\n /// @dev Nothing to liquidate.\n error NothingToLiquidate();\n\n /// @dev Cannot liquidate last position.\n error CannotLiquidateLastPosition();\n\n /// @dev Cannot redeem collateral below minimum debt threshold.\n /// @param collateralToken Collateral token used to redeem.\n /// @param newTotalDebt New total debt backed by collateral, which is lower than minimum debt.\n error TotalDebtCannotBeLowerThanMinDebt(IERC20 collateralToken, uint256 newTotalDebt);\n\n /// @dev Cannot redeem collateral\n /// @param collateralToken Collateral token used to redeem.\n /// @param newTotalCollateral New total collateral, which is lower than minimum collateral.\n /// @param minimumCollateral Minimum collateral required to complete redeem\n error TotalCollateralCannotBeLowerThanMinCollateral(\n IERC20 collateralToken, uint256 newTotalCollateral, uint256 minimumCollateral\n );\n\n /// @dev Fee would eat up all returned collateral.\n error FeeEatsUpAllReturnedCollateral();\n\n /// @dev Borrowing spread exceeds maximum.\n error BorrowingSpreadExceedsMaximum();\n\n /// @dev Redemption rebate exceeds maximum.\n error RedemptionRebateExceedsMaximum();\n\n /// @dev Redemption spread is out of allowed range.\n error RedemptionSpreadOutOfRange();\n\n /// @dev There must be either a collateral change or a debt change.\n error NoCollateralOrDebtChange();\n\n /// @dev There is some collateral for position that doesn't have debt.\n error InvalidPosition();\n\n /// @dev An operation that would result in ICR < MCR is not permitted.\n /// @param newICR Resulting ICR that is below MCR.\n error NewICRLowerThanMCR(uint256 newICR);\n\n /// @dev Position's net debt must be greater than minimum.\n /// @param netDebt Net debt amount that is below minimum.\n error NetDebtBelowMinimum(uint256 netDebt);\n\n /// @dev The provided delegate address is invalid.\n error InvalidDelegateAddress();\n\n /// @dev A non-whitelisted delegate cannot adjust positions.\n error DelegateNotWhitelisted();\n\n /// @dev Fee exceeded provided maximum fee percentage.\n /// @param fee The fee amount.\n /// @param amount The amount of debt or collateral.\n /// @param maxFeePercentage The maximum fee percentage.\n error FeeExceedsMaxFee(uint256 fee, uint256 amount, uint256 maxFeePercentage);\n\n /// @dev Borrower uses a different collateral token already.\n error PositionCollateralTokenMismatch();\n\n /// @dev Collateral token address cannot be zero.\n error CollateralTokenAddressCannotBeZero();\n\n /// @dev Price feed address cannot be zero.\n error PriceFeedAddressCannotBeZero();\n\n /// @dev Collateral token already added.\n error CollateralTokenAlreadyAdded();\n\n /// @dev Collateral token is not added.\n error CollateralTokenNotAdded();\n\n /// @dev Collateral token is not enabled.\n error CollateralTokenDisabled();\n\n /// @dev Split liquidation collateral cannot be zero.\n error SplitLiquidationCollateralCannotBeZero();\n\n /// @dev Cannot change collateral in case of repaying the whole debt.\n error WrongCollateralParamsForFullRepayment();\n\n // --- Functions ---\n\n /// @return The R token used by position manager.\n function rToken() external view returns (IRToken);\n\n /// @dev Retrieves information about certain collateral type.\n /// @param collateralToken The token used as collateral.\n /// @return raftCollateralToken The Raft indexable collateral token.\n /// @return raftDebtToken The Raft indexable debt token.\n /// @return priceFeed The contract that provides a price for the collateral token.\n /// @return splitLiquidation The contract that calculates collateral split in case of liquidation.\n /// @return isEnabled Whether the collateral token can be used as collateral or not.\n /// @return lastFeeOperationTime Timestamp of the last operation for the collateral token.\n /// @return borrowingSpread The current borrowing spread.\n /// @return baseRate The current base rate.\n /// @return redemptionSpread The current redemption spread.\n /// @return redemptionRebate Percentage of the redemption fee returned to redeemed positions.\n function collateralInfo(IERC20 collateralToken)\n external\n view\n returns (\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral splitLiquidation,\n bool isEnabled,\n uint256 lastFeeOperationTime,\n uint256 borrowingSpread,\n uint256 baseRate,\n uint256 redemptionSpread,\n uint256 redemptionRebate\n );\n\n /// @param collateralToken Collateral token whose raft collateral indexable token is being queried.\n /// @return Raft collateral token address for given collateral token.\n function raftCollateralToken(IERC20 collateralToken) external view returns (IERC20Indexable);\n\n /// @param collateralToken Collateral token whose raft collateral indexable token is being queried.\n /// @return Raft debt token address for given collateral token.\n function raftDebtToken(IERC20 collateralToken) external view returns (IERC20Indexable);\n\n /// @param collateralToken Collateral token whose price feed contract is being queried.\n /// @return Price feed contract address for given collateral token.\n function priceFeed(IERC20 collateralToken) external view returns (IPriceFeed);\n\n /// @param collateralToken Collateral token whose split liquidation collateral is being queried.\n /// @return Returns address of the split liquidation collateral contract.\n function splitLiquidationCollateral(IERC20 collateralToken) external view returns (ISplitLiquidationCollateral);\n\n /// @param collateralToken Collateral token whose split liquidation collateral is being queried.\n /// @return Returns whether collateral is enabled or nor.\n function collateralEnabled(IERC20 collateralToken) external view returns (bool);\n\n /// @param collateralToken Collateral token we query last operation time fee for.\n /// @return The timestamp of the latest fee operation (redemption or new R issuance).\n function lastFeeOperationTime(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query borrowing spread for.\n /// @return The current borrowing spread.\n function borrowingSpread(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query base rate for.\n /// @return rate The base rate.\n function baseRate(IERC20 collateralToken) external view returns (uint256 rate);\n\n /// @param collateralToken Collateral token we query redemption spread for.\n /// @return The current redemption spread for collateral token.\n function redemptionSpread(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query redemption rebate for.\n /// @return rebate Percentage of the redemption fee returned to redeemed positions.\n function redemptionRebate(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query redemption rate for.\n /// @return rate The current redemption rate for collateral token.\n function getRedemptionRate(IERC20 collateralToken) external view returns (uint256 rate);\n\n /// @dev Returns the collateral token that a given position used for their position.\n /// @param position The address of the borrower.\n /// @return collateralToken The collateral token of the borrower's position.\n function collateralTokenForPosition(address position) external view returns (IERC20 collateralToken);\n\n /// @dev Adds a new collateral token to the protocol.\n /// @param collateralToken The new collateral token.\n /// @param priceFeed The price feed for the collateral token.\n /// @param newSplitLiquidationCollateral split liquidation collateral contract address.\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n external;\n\n /// @dev Adds a new collateral token to the protocol.\n /// @param collateralToken The new collateral token.\n /// @param priceFeed The price feed for the collateral token.\n /// @param newSplitLiquidationCollateral split liquidation collateral contract address.\n /// @param raftCollateralToken_ Address of raft collateral token.\n /// @param raftDebtToken_ Address of raft debt token.\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral,\n IERC20Indexable raftCollateralToken_,\n IERC20Indexable raftDebtToken_\n )\n external;\n\n /// @dev Enables or disables a collateral token. Reverts if the collateral token has not been added.\n /// @param collateralToken The collateral token.\n /// @param isEnabled Whether the collateral token can be used as collateral or not.\n function setCollateralEnabled(IERC20 collateralToken, bool isEnabled) external;\n\n /// @dev Sets the new split liquidation collateral contract.\n /// @param collateralToken Collateral token whose split liquidation collateral is being set.\n /// @param newSplitLiquidationCollateral New split liquidation collateral contract address.\n function setSplitLiquidationCollateral(\n IERC20 collateralToken,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n external;\n\n /// @dev Liquidates the borrower if its position's ICR is lower than the minimum collateral ratio.\n /// @param position The address of the borrower.\n function liquidate(address position) external;\n\n /// @dev Redeems the collateral token for a given debt amount. It sends @param debtAmount R to the system and\n /// redeems the corresponding amount of collateral from as many positions as are needed to fill the redemption\n /// request.\n /// @param collateralToken The token used as collateral.\n /// @param debtAmount The amount of debt to be redeemed. Must be greater than zero.\n /// @param maxFeePercentage The maximum fee percentage to pay for the redemption.\n function redeemCollateral(IERC20 collateralToken, uint256 debtAmount, uint256 maxFeePercentage) external;\n\n /// @dev Manages the position on behalf of a given borrower.\n /// @param collateralToken The token the borrower used as collateral.\n /// @param position The address of the borrower.\n /// @param collateralChange The amount of collateral to add or remove.\n /// @param isCollateralIncrease True if the collateral is being increased, false otherwise.\n /// @param debtChange The amount of R to add or remove. In case of repayment (isDebtIncrease = false)\n /// `type(uint256).max` value can be used to repay the whole outstanding loan.\n /// @param isDebtIncrease True if the debt is being increased, false otherwise.\n /// @param maxFeePercentage The maximum fee percentage to pay for the position management.\n /// @param permitSignature Optional permit signature for tokens that support IERC20Permit interface.\n /// @notice `permitSignature` it is ignored if permit signature is not for `collateralToken`.\n /// @notice In case of full debt repayment, `isCollateralIncrease` is ignored and `collateralChange` must be 0.\n /// These values are set to `false`(collateral decrease), and the whole collateral balance of the user.\n /// @return actualCollateralChange Actual amount of collateral added/removed.\n /// Can be different to `collateralChange` in case of full repayment.\n /// @return actualDebtChange Actual amount of debt added/removed.\n /// Can be different to `debtChange` in case of passing type(uint256).max as `debtChange`.\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n external\n returns (uint256 actualCollateralChange, uint256 actualDebtChange);\n\n /// @return The max borrowing spread.\n function MAX_BORROWING_SPREAD() external view returns (uint256);\n\n /// @return The max borrowing rate.\n function MAX_BORROWING_RATE() external view returns (uint256);\n\n /// @dev Sets the new borrowing spread.\n /// @param collateralToken Collateral token we set borrowing spread for.\n /// @param newBorrowingSpread New borrowing spread to be used.\n function setBorrowingSpread(IERC20 collateralToken, uint256 newBorrowingSpread) external;\n\n /// @param collateralToken Collateral token we query borrowing rate for.\n /// @return The current borrowing rate.\n function getBorrowingRate(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query borrowing rate with decay for.\n /// @return The current borrowing rate with decay.\n function getBorrowingRateWithDecay(IERC20 collateralToken) external view returns (uint256);\n\n /// @dev Returns the borrowing fee for a given debt amount.\n /// @param collateralToken Collateral token we query borrowing fee for.\n /// @param debtAmount The amount of debt.\n /// @return The borrowing fee.\n function getBorrowingFee(IERC20 collateralToken, uint256 debtAmount) external view returns (uint256);\n\n /// @dev Sets the new redemption spread.\n /// @param newRedemptionSpread New redemption spread to be used.\n function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) external;\n\n /// @dev Sets new redemption rebate percentage.\n /// @param newRedemptionRebate Value that is being set as a redemption rebate percentage.\n function setRedemptionRebate(IERC20 collateralToken, uint256 newRedemptionRebate) external;\n\n /// @param collateralToken Collateral token we query redemption rate with decay for.\n /// @return The current redemption rate with decay.\n function getRedemptionRateWithDecay(IERC20 collateralToken) external view returns (uint256);\n\n /// @dev Returns the redemption fee for a given collateral amount.\n /// @param collateralToken Collateral token we query redemption fee for.\n /// @param collateralAmount The amount of collateral.\n /// @param priceDeviation Deviation for the reported price by oracle in percentage.\n /// @return The redemption fee.\n function getRedemptionFee(\n IERC20 collateralToken,\n uint256 collateralAmount,\n uint256 priceDeviation\n )\n external\n view\n returns (uint256);\n\n /// @dev Returns the redemption fee with decay for a given collateral amount.\n /// @param collateralToken Collateral token we query redemption fee with decay for.\n /// @param collateralAmount The amount of collateral.\n /// @return The redemption fee with decay.\n function getRedemptionFeeWithDecay(\n IERC20 collateralToken,\n uint256 collateralAmount\n )\n external\n view\n returns (uint256);\n\n /// @return Half-life of 12h (720 min).\n /// @dev (1/2) = d^720 => d = (1/2)^(1/720)\n function MINUTE_DECAY_FACTOR() external view returns (uint256);\n\n /// @dev Returns if a given delegate is whitelisted for a given borrower.\n /// @param position The address of the borrower.\n /// @param delegate The address of the delegate.\n /// @return isWhitelisted True if the delegate is whitelisted for a given borrower, false otherwise.\n function isDelegateWhitelisted(address position, address delegate) external view returns (bool isWhitelisted);\n\n /// @dev Whitelists a delegate.\n /// @param delegate The address of the delegate.\n /// @param whitelisted True if delegate is being whitelisted, false otherwise.\n function whitelistDelegate(address delegate, bool whitelisted) external;\n\n /// @return Parameter by which to divide the redeemed fraction, in order to calc the new base rate from a\n /// redemption. Corresponds to (1 / ALPHA) in the white paper.\n function BETA() external view returns (uint256);\n}\n\n/// @dev Common interface for the Position Manager.\ninterface IInterestRatePositionManager is IPositionManager {\n // --- Events ---\n\n /// @dev Fees coming from accrued interest are minted.\n /// @param collateralToken Collateral token that fees are paid for.\n /// @param amount Amount of R minted.\n event MintedFees(IERC20 collateralToken, uint256 amount);\n\n // --- Errors ---\n\n /// @dev Only registered debt token can be caller.\n /// @param sender Actual caller.\n error InvalidDebtToken(address sender);\n\n // --- Functions ---\n\n /// @dev Mints fees coming from accrued interest. Can be called only from matching debt token.\n /// @param collateralToken Collateral token to mint fees for.\n /// @param amount Amount of R to mint.\n function mintFees(IERC20 collateralToken, uint256 amount) external;\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n\nlibrary Fixed256x18 {\n uint256 internal constant ONE = 1e18; // 18 decimal places\n\n function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a * b) / ONE;\n }\n\n function mulUp(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 product = a * b;\n\n if (product == 0) {\n return 0;\n } else {\n return ((product - 1) / ONE) + 1;\n }\n }\n\n function divDown(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a * ONE) / b;\n }\n\n function divUp(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n } else {\n return (((a * ONE) - 1) / b) + 1;\n }\n }\n\n function complement(uint256 x) internal pure returns (uint256) {\n return (x < ONE) ? (ONE - x) : 0;\n }\n}\n\nlibrary MathUtils {\n // --- Constants ---\n\n /// @notice Represents 100%.\n /// @dev 1e18 is the scaling factor (100% == 1e18).\n uint256 public constant _100_PERCENT = Fixed256x18.ONE;\n\n /// @notice Precision for Nominal ICR (independent of price).\n /// @dev Rationale for the value:\n /// - Making it “too high” could lead to overflows.\n /// - Making it “too low” could lead to an ICR equal to zero, due to truncation from floor division.\n ///\n /// This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 collateralToken,\n /// and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.\n uint256 internal constant _NICR_PRECISION = 1e20;\n\n /// @notice Number of minutes in 1000 years.\n uint256 internal constant _MINUTES_IN_1000_YEARS = 1000 * 365 days / 1 minutes;\n\n // --- Functions ---\n\n /// @notice Multiplies two decimal numbers and use normal rounding rules:\n /// - round product up if 19'th mantissa digit >= 5\n /// - round product down if 19'th mantissa digit < 5.\n /// @param x First number.\n /// @param y Second number.\n function _decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {\n decProd = (x * y + Fixed256x18.ONE / 2) / Fixed256x18.ONE;\n }\n\n /// @notice Exponentiation function for 18-digit decimal base, and integer exponent n.\n ///\n /// @dev Uses the efficient \"exponentiation by squaring\" algorithm. O(log(n)) complexity. The exponent is capped to\n /// avoid reverting due to overflow.\n ///\n /// If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be\n /// negligibly different from just passing the cap, since the decayed base rate will be 0 for 1000 years or > 1000\n /// years.\n /// @param base The decimal base.\n /// @param exponent The exponent.\n /// @return The result of the exponentiation.\n function _decPow(uint256 base, uint256 exponent) internal pure returns (uint256) {\n if (exponent == 0) {\n return Fixed256x18.ONE;\n }\n\n uint256 y = Fixed256x18.ONE;\n uint256 x = base;\n uint256 n = Math.min(exponent, _MINUTES_IN_1000_YEARS); // cap to avoid overflow\n\n // Exponentiation-by-squaring\n while (n > 1) {\n if (n % 2 != 0) {\n y = _decMul(x, y);\n }\n x = _decMul(x, x);\n n /= 2;\n }\n\n return _decMul(x, y);\n }\n\n /// @notice Computes the Nominal Individual Collateral Ratio (NICR) for given collateral and debt. If debt is zero,\n /// it returns the maximal value for uint256 (represents \"infinite\" CR).\n /// @param collateral Collateral amount.\n /// @param debt Debt amount.\n /// @return NICR.\n function _computeNominalCR(uint256 collateral, uint256 debt) internal pure returns (uint256) {\n return debt > 0 ? collateral * _NICR_PRECISION / debt : type(uint256).max;\n }\n\n /// @notice Computes the Collateral Ratio for given collateral, debt and price. If debt is zero, it returns the\n /// maximal value for uint256 (represents \"infinite\" CR).\n /// @param collateral Collateral amount.\n /// @param debt Debt amount.\n /// @param price Collateral price.\n /// @return Collateral ratio.\n function _computeCR(uint256 collateral, uint256 debt, uint256 price) internal pure returns (uint256) {\n return debt > 0 ? collateral * price / debt : type(uint256).max;\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\n\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n}\n\n/**\n * @dev Extension of {ERC20} that adds a cap to the supply of tokens.\n */\nabstract contract ERC20Capped is ERC20, Ownable2Step {\n uint256 public cap;\n\n /**\n * @dev Total supply cap has been exceeded.\n */\n error ERC20ExceededCap();\n\n /**\n * @dev The supplied cap is not a valid cap.\n */\n error ERC20InvalidCap(uint256 cap);\n\n constructor(uint256 cap_) {\n setCap(cap_);\n }\n\n /**\n * @dev Sets the value of the `cap`.\n */\n function setCap(uint256 cap_) public onlyOwner {\n if (cap_ == 0) {\n revert ERC20InvalidCap(0);\n }\n cap = cap_;\n }\n\n /**\n * @dev See {ERC20-_mint}.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n if (totalSupply() + amount > cap) {\n revert ERC20ExceededCap();\n }\n super._mint(account, amount);\n }\n}\n\nabstract contract PositionManagerDependent is IPositionManagerDependent {\n // --- Immutable variables ---\n\n address public immutable override positionManager;\n\n // --- Modifiers ---\n\n modifier onlyPositionManager() {\n if (msg.sender != positionManager) {\n revert CallerIsNotPositionManager(msg.sender);\n }\n _;\n }\n\n // --- Constructor ---\n\n constructor(address positionManager_) {\n if (positionManager_ == address(0)) {\n revert PositionManagerCannotBeZero();\n }\n positionManager = positionManager_;\n }\n}\n\ncontract ERC20Indexable is IERC20Indexable, ERC20Capped, PositionManagerDependent {\n // --- Types ---\n\n using Fixed256x18 for uint256;\n\n // --- Constants ---\n\n uint256 public constant override INDEX_PRECISION = Fixed256x18.ONE;\n\n // --- Variables ---\n\n uint256 internal storedIndex;\n\n // --- Constructor ---\n\n constructor(\n address positionManager_,\n string memory name_,\n string memory symbol_,\n uint256 cap_\n )\n ERC20(name_, symbol_)\n ERC20Capped(cap_)\n PositionManagerDependent(positionManager_)\n {\n storedIndex = INDEX_PRECISION;\n emit ERC20IndexableDeployed(positionManager_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) public virtual override onlyPositionManager {\n _mint(to, amount.divUp(storedIndex));\n }\n\n function burn(address from, uint256 amount) public virtual override onlyPositionManager {\n _burn(from, amount == type(uint256).max ? ERC20.balanceOf(from) : amount.divUp(storedIndex));\n }\n\n function setIndex(uint256 backingAmount) external override onlyPositionManager {\n uint256 supply = ERC20.totalSupply();\n uint256 newIndex = (backingAmount == 0 && supply == 0) ? INDEX_PRECISION : backingAmount.divUp(supply);\n storedIndex = newIndex;\n emit IndexUpdated(newIndex);\n }\n\n function currentIndex() public view virtual override returns (uint256) {\n return storedIndex;\n }\n\n function totalSupply() public view virtual override(IERC20, ERC20) returns (uint256) {\n return ERC20.totalSupply().mulDown(currentIndex());\n }\n\n function balanceOf(address account) public view virtual override(IERC20, ERC20) returns (uint256) {\n return ERC20.balanceOf(account).mulDown(currentIndex());\n }\n\n function transfer(address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function allowance(address, address) public view virtual override(IERC20, ERC20) returns (uint256) {\n revert NotSupported();\n }\n\n function approve(address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function transferFrom(address, address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function increaseAllowance(address, uint256) public virtual override returns (bool) {\n revert NotSupported();\n }\n\n function decreaseAllowance(address, uint256) public virtual override returns (bool) {\n revert NotSupported();\n }\n}\n\nabstract contract FeeCollector is Ownable2Step, IFeeCollector {\n // --- Variables ---\n\n address public override feeRecipient;\n\n // --- Constructor ---\n\n /// @param feeRecipient_ Address of the fee recipient to initialize contract with.\n constructor(address feeRecipient_) {\n if (feeRecipient_ == address(0)) {\n revert InvalidFeeRecipient();\n }\n\n feeRecipient = feeRecipient_;\n }\n\n // --- Functions ---\n\n function setFeeRecipient(address newFeeRecipient) external onlyOwner {\n if (newFeeRecipient == address(0)) {\n revert InvalidFeeRecipient();\n }\n\n feeRecipient = newFeeRecipient;\n emit FeeRecipientChanged(newFeeRecipient);\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/ERC20FlashMint.sol)\n\n/**\n * @dev Implementation of the ERC3156 Flash loans extension, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * Adds the {flashLoan} method, which provides flash loan support at the token\n * level. By default there is no fee, but this can be changed by overriding {flashFee}.\n *\n * _Available since v4.1._\n */\nabstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {\n bytes32 private constant _RETURN_VALUE = keccak256(\"ERC3156FlashBorrower.onFlashLoan\");\n\n /**\n * @dev Returns the maximum amount of tokens available for loan.\n * @param token The address of the token that is requested.\n * @return The amount of token that can be loaned.\n */\n function maxFlashLoan(address token) public view virtual override returns (uint256) {\n return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;\n }\n\n /**\n * @dev Returns the fee applied when doing flash loans. This function calls\n * the {_flashFee} function which returns the fee applied when doing flash\n * loans.\n * @param token The token to be flash loaned.\n * @param amount The amount of tokens to be loaned.\n * @return The fees applied to the corresponding flash loan.\n */\n function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {\n require(token == address(this), \"ERC20FlashMint: wrong token\");\n return _flashFee(token, amount);\n }\n\n /**\n * @dev Returns the fee applied when doing flash loans. By default this\n * implementation has 0 fees. This function can be overloaded to make\n * the flash loan mechanism deflationary.\n * @param token The token to be flash loaned.\n * @param amount The amount of tokens to be loaned.\n * @return The fees applied to the corresponding flash loan.\n */\n function _flashFee(address token, uint256 amount) internal view virtual returns (uint256) {\n // silence warning about unused variable without the addition of bytecode.\n token;\n amount;\n return 0;\n }\n\n /**\n * @dev Returns the receiver address of the flash fee. By default this\n * implementation returns the address(0) which means the fee amount will be burnt.\n * This function can be overloaded to change the fee receiver.\n * @return The address for which the flash fee will be sent to.\n */\n function _flashFeeReceiver() internal view virtual returns (address) {\n return address(0);\n }\n\n /**\n * @dev Performs a flash loan. New tokens are minted and sent to the\n * `receiver`, who is required to implement the {IERC3156FlashBorrower}\n * interface. By the end of the flash loan, the receiver is expected to own\n * amount + fee tokens and have them approved back to the token contract itself so\n * they can be burned.\n * @param receiver The receiver of the flash loan. Should implement the\n * {IERC3156FlashBorrower-onFlashLoan} interface.\n * @param token The token to be flash loaned. Only `address(this)` is\n * supported.\n * @param amount The amount of tokens to be loaned.\n * @param data An arbitrary datafield that is passed to the receiver.\n * @return `true` if the flash loan was successful.\n */\n // This function can reenter, but it doesn't pose a risk because it always preserves the property that the amount\n // minted at the beginning is always recovered and burned at the end, or else the entire function will revert.\n // slither-disable-next-line reentrancy-no-eth\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n ) public virtual override returns (bool) {\n require(amount <= maxFlashLoan(token), \"ERC20FlashMint: amount exceeds maxFlashLoan\");\n uint256 fee = flashFee(token, amount);\n _mint(address(receiver), amount);\n require(\n receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,\n \"ERC20FlashMint: invalid return value\"\n );\n address flashFeeReceiver = _flashFeeReceiver();\n _spendAllowance(address(receiver), address(this), amount + fee);\n if (fee == 0 || flashFeeReceiver == address(0)) {\n _burn(address(receiver), amount + fee);\n } else {\n _burn(address(receiver), amount);\n _transfer(address(receiver), flashFeeReceiver, fee);\n }\n return true;\n }\n}\n\ncontract RToken is ReentrancyGuard, ERC20Permit, ERC20FlashMint, PositionManagerDependent, FeeCollector, IRToken {\n // --- Constants ---\n\n uint256 public constant override PERCENTAGE_BASE = 10_000;\n uint256 public constant override MAX_FLASH_MINT_FEE_PERCENTAGE = 500;\n\n // --- Variables ---\n\n uint256 public override flashMintFeePercentage;\n\n // --- Constructor ---\n\n /// @dev Deploys new R token. Sets flash mint fee percentage to 0. Transfers ownership to @param feeRecipient_.\n /// @param positionManager_ Address of the PositionManager contract that is authorized to mint and burn new tokens.\n /// @param feeRecipient_ Address of flash mint fee recipient.\n constructor(\n address positionManager_,\n address feeRecipient_\n )\n ERC20Permit(\"R Stablecoin\")\n ERC20(\"R Stablecoin\", \"R\")\n PositionManagerDependent(positionManager_)\n FeeCollector(feeRecipient_)\n {\n setFlashMintFeePercentage(PERCENTAGE_BASE / 200); // 0.5%\n\n transferOwnership(feeRecipient_);\n\n emit RDeployed(positionManager_, feeRecipient_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) external override onlyPositionManager {\n _mint(to, amount);\n }\n\n function burn(address from, uint256 amount) external override onlyPositionManager {\n _burn(from, amount);\n }\n\n function setFlashMintFeePercentage(uint256 feePercentage) public override onlyOwner {\n if (feePercentage > MAX_FLASH_MINT_FEE_PERCENTAGE) {\n revert FlashFeePercentageTooBig(feePercentage);\n }\n\n flashMintFeePercentage = feePercentage;\n emit FlashMintFeePercentageChanged(flashMintFeePercentage);\n }\n\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n )\n public\n override(ERC20FlashMint, IERC3156FlashLender)\n nonReentrant\n returns (bool)\n {\n return super.flashLoan(receiver, token, amount, data);\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines maximum size of the flash mint.\n /// @param token Token to be flash minted. Returns 0 amount in case of token != address(this).\n function maxFlashLoan(address token)\n public\n view\n virtual\n override(ERC20FlashMint, IERC3156FlashLender)\n returns (uint256)\n {\n return token == address(this) ? Math.min(totalSupply() / 10, ERC20FlashMint.maxFlashLoan(address(this))) : 0;\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines flash mint fee for the flash mint of @param amount tokens.\n /// @param token Token to be flash minted. Returns 0 fee in case of token != address(this).\n /// @param amount Size of the flash mint.\n function _flashFee(address token, uint256 amount) internal view virtual override returns (uint256) {\n return token == address(this) ? amount * flashMintFeePercentage / PERCENTAGE_BASE : 0;\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines flash mint fee receiver.\n /// @return Address that will receive flash mint fees.\n function _flashFeeReceiver() internal view virtual override returns (address) {\n return feeRecipient;\n }\n}\n\n/// @dev Implementation of Position Manager. Current implementation does not support rebasing tokens as collateral.\ncontract PositionManager is FeeCollector, IPositionManager {\n // --- Types ---\n\n using SafeERC20 for IERC20;\n using Fixed256x18 for uint256;\n\n // --- Constants ---\n\n uint256 public constant override MINUTE_DECAY_FACTOR = 999_037_758_833_783_000;\n\n uint256 public constant override MAX_BORROWING_SPREAD = MathUtils._100_PERCENT / 100; // 1%\n uint256 public constant override MAX_BORROWING_RATE = MathUtils._100_PERCENT / 100 * 5; // 5%\n\n uint256 public constant override BETA = 2;\n\n // --- Immutables ---\n\n IRToken public immutable override rToken;\n\n // --- Variables ---\n\n mapping(address position => IERC20 collateralToken) public override collateralTokenForPosition;\n\n mapping(address position => mapping(address delegate => bool isWhitelisted)) public override isDelegateWhitelisted;\n\n mapping(IERC20 collateralToken => CollateralTokenInfo collateralTokenInfo) public override collateralInfo;\n\n // --- Modifiers ---\n\n /// @dev Checks if the collateral token has been added to the position manager, or reverts otherwise.\n /// @param collateralToken The collateral token to check.\n modifier collateralTokenExists(IERC20 collateralToken) {\n if (address(collateralInfo[collateralToken].collateralToken) == address(0)) {\n revert CollateralTokenNotAdded();\n }\n _;\n }\n\n /// @dev Checks if the collateral token has enabled, or reverts otherwise. When the condition is false, the check\n /// is skipped.\n /// @param collateralToken The collateral token to check.\n /// @param condition If true, the check will be performed.\n modifier onlyEnabledCollateralTokenWhen(IERC20 collateralToken, bool condition) {\n if (condition && !collateralInfo[collateralToken].isEnabled) {\n revert CollateralTokenDisabled();\n }\n _;\n }\n\n /// @dev Checks if the borrower has a position with the collateral token or doesn't have a position at all, or\n /// reverts otherwise.\n /// @param position The borrower to check.\n /// @param collateralToken The collateral token to check.\n modifier onlyDepositedCollateralTokenOrNew(address position, IERC20 collateralToken) {\n if (\n collateralTokenForPosition[position] != IERC20(address(0))\n && collateralTokenForPosition[position] != collateralToken\n ) {\n revert PositionCollateralTokenMismatch();\n }\n _;\n }\n\n /// @dev Checks if the max fee percentage is between the borrowing spread and 100%, or reverts otherwise. When the\n /// condition is false, the check is skipped.\n /// @param maxFeePercentage The max fee percentage to check.\n /// @param condition If true, the check will be performed.\n modifier validMaxFeePercentageWhen(uint256 maxFeePercentage, bool condition) {\n if (condition && maxFeePercentage > MathUtils._100_PERCENT) {\n revert InvalidMaxFeePercentage();\n }\n _;\n }\n\n // --- Constructor ---\n\n /// @dev Initializes the position manager.\n constructor(address rToken_) FeeCollector(msg.sender) {\n rToken = rToken_ == address(0) ? new RToken(address(this), msg.sender) : IRToken(rToken_);\n emit PositionManagerDeployed(rToken, msg.sender);\n }\n\n // --- External functions ---\n\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n public\n virtual\n override\n collateralTokenExists(collateralToken)\n validMaxFeePercentageWhen(maxFeePercentage, isDebtIncrease)\n onlyDepositedCollateralTokenOrNew(position, collateralToken)\n onlyEnabledCollateralTokenWhen(collateralToken, isDebtIncrease && debtChange > 0)\n returns (uint256 actualCollateralChange, uint256 actualDebtChange)\n {\n if (position != msg.sender && !isDelegateWhitelisted[position][msg.sender]) {\n revert DelegateNotWhitelisted();\n }\n if (collateralChange == 0 && debtChange == 0) {\n revert NoCollateralOrDebtChange();\n }\n if (address(permitSignature.token) == address(collateralToken)) {\n PermitHelper.applyPermit(permitSignature, msg.sender, address(this));\n }\n\n CollateralTokenInfo storage collateralTokenInfo = collateralInfo[collateralToken];\n IERC20Indexable raftCollateralToken = collateralTokenInfo.collateralToken;\n IERC20Indexable raftDebtToken = collateralTokenInfo.debtToken;\n\n uint256 debtBefore = raftDebtToken.balanceOf(position);\n if (!isDebtIncrease && (debtChange == type(uint256).max || (debtBefore != 0 && debtChange == debtBefore))) {\n if (collateralChange != 0 || isCollateralIncrease) {\n revert WrongCollateralParamsForFullRepayment();\n }\n collateralChange = raftCollateralToken.balanceOf(position);\n debtChange = debtBefore;\n }\n\n _adjustDebt(position, collateralToken, raftDebtToken, debtChange, isDebtIncrease, maxFeePercentage);\n _adjustCollateral(collateralToken, raftCollateralToken, position, collateralChange, isCollateralIncrease);\n\n uint256 positionDebt = raftDebtToken.balanceOf(position);\n uint256 positionCollateral = raftCollateralToken.balanceOf(position);\n\n if (positionDebt == 0) {\n if (positionCollateral != 0) {\n revert InvalidPosition();\n }\n // position was closed, remove it\n _closePosition(raftCollateralToken, raftDebtToken, position, false);\n } else {\n _checkValidPosition(collateralToken, positionDebt, positionCollateral);\n\n if (debtBefore == 0) {\n collateralTokenForPosition[position] = collateralToken;\n emit PositionCreated(position, collateralToken);\n }\n }\n return (collateralChange, debtChange);\n }\n\n function liquidate(address position) external override {\n IERC20 collateralToken = collateralTokenForPosition[position];\n CollateralTokenInfo storage collateralTokenInfo = collateralInfo[collateralToken];\n IERC20Indexable raftCollateralToken = collateralTokenInfo.collateralToken;\n IERC20Indexable raftDebtToken = collateralTokenInfo.debtToken;\n ISplitLiquidationCollateral splitLiquidation = collateralTokenInfo.splitLiquidation;\n\n if (address(collateralToken) == address(0)) {\n revert NothingToLiquidate();\n }\n (uint256 price,) = collateralTokenInfo.priceFeed.fetchPrice();\n uint256 entireCollateral = raftCollateralToken.balanceOf(position);\n uint256 entireDebt = raftDebtToken.balanceOf(position);\n uint256 icr = MathUtils._computeCR(entireCollateral, entireDebt, price);\n\n if (icr >= splitLiquidation.MCR()) {\n revert NothingToLiquidate();\n }\n\n uint256 totalDebt = raftDebtToken.totalSupply();\n if (entireDebt == totalDebt) {\n revert CannotLiquidateLastPosition();\n }\n bool isRedistribution = icr <= MathUtils._100_PERCENT;\n\n // prettier: ignore\n (uint256 collateralLiquidationFee, uint256 collateralToSendToLiquidator) =\n splitLiquidation.split(entireCollateral, entireDebt, price, isRedistribution);\n\n if (!isRedistribution) {\n _burnRTokens(msg.sender, entireDebt);\n totalDebt -= entireDebt;\n\n // Collateral is sent to protocol as a fee only in case of liquidation\n collateralToken.safeTransfer(feeRecipient, collateralLiquidationFee);\n }\n\n collateralToken.safeTransfer(msg.sender, collateralToSendToLiquidator);\n\n _closePosition(raftCollateralToken, raftDebtToken, position, true);\n\n _updateDebtAndCollateralIndex(collateralToken, raftCollateralToken, raftDebtToken, totalDebt);\n\n emit Liquidation(\n msg.sender,\n position,\n collateralToken,\n entireDebt,\n entireCollateral,\n collateralToSendToLiquidator,\n collateralLiquidationFee,\n isRedistribution\n );\n }\n\n function redeemCollateral(\n IERC20 collateralToken,\n uint256 debtAmount,\n uint256 maxFeePercentage\n )\n public\n virtual\n override\n {\n if (maxFeePercentage > MathUtils._100_PERCENT) {\n revert MaxFeePercentageOutOfRange();\n }\n if (debtAmount == 0) {\n revert AmountIsZero();\n }\n IERC20Indexable raftDebtToken = collateralInfo[collateralToken].debtToken;\n\n uint256 newTotalDebt = raftDebtToken.totalSupply() - debtAmount;\n uint256 lowTotalDebt = collateralInfo[collateralToken].splitLiquidation.LOW_TOTAL_DEBT();\n if (newTotalDebt < lowTotalDebt) {\n revert TotalDebtCannotBeLowerThanMinDebt(collateralToken, newTotalDebt);\n }\n\n (uint256 price, uint256 deviation) = collateralInfo[collateralToken].priceFeed.fetchPrice();\n uint256 collateralToRedeem = debtAmount.divDown(price);\n uint256 totalCollateral = collateralToken.balanceOf(address(this));\n if (\n totalCollateral - collateralToRedeem == 0\n || totalCollateral - collateralToRedeem < lowTotalDebt.divDown(price)\n ) {\n revert TotalCollateralCannotBeLowerThanMinCollateral(\n collateralToken, totalCollateral - collateralToRedeem, lowTotalDebt.divDown(price)\n );\n }\n\n // Decay the baseRate due to time passed, and then increase it according to the size of this redemption.\n // Use the saved total R supply value, from before it was reduced by the redemption.\n _updateBaseRateFromRedemption(collateralToken, collateralToRedeem, price, rToken.totalSupply());\n\n // Calculate the redemption fee\n uint256 redemptionFee = getRedemptionFee(collateralToken, collateralToRedeem, deviation);\n uint256 rebate = redemptionFee.mulDown(collateralInfo[collateralToken].redemptionRebate);\n\n _checkValidFee(redemptionFee, collateralToRedeem, maxFeePercentage);\n\n // Send the redemption fee to the recipient\n collateralToken.safeTransfer(feeRecipient, redemptionFee - rebate);\n\n // Burn the total R that is cancelled with debt, and send the redeemed collateral to msg.sender\n _burnRTokens(msg.sender, debtAmount);\n\n // Send collateral to account\n collateralToken.safeTransfer(msg.sender, collateralToRedeem - redemptionFee);\n\n _updateDebtAndCollateralIndex(\n collateralToken, collateralInfo[collateralToken].collateralToken, raftDebtToken, newTotalDebt\n );\n\n emit Redemption(msg.sender, debtAmount, collateralToRedeem, redemptionFee, rebate);\n }\n\n function whitelistDelegate(address delegate, bool whitelisted) external override {\n if (delegate == address(0)) {\n revert InvalidDelegateAddress();\n }\n isDelegateWhitelisted[msg.sender][delegate] = whitelisted;\n\n emit DelegateWhitelisted(msg.sender, delegate, whitelisted);\n }\n\n function setBorrowingSpread(IERC20 collateralToken, uint256 newBorrowingSpread) external override onlyOwner {\n if (newBorrowingSpread > MAX_BORROWING_SPREAD) {\n revert BorrowingSpreadExceedsMaximum();\n }\n collateralInfo[collateralToken].borrowingSpread = newBorrowingSpread;\n emit BorrowingSpreadUpdated(newBorrowingSpread);\n }\n\n function setRedemptionRebate(IERC20 collateralToken, uint256 newRedemptionRebate) public override onlyOwner {\n if (newRedemptionRebate > MathUtils._100_PERCENT) {\n revert RedemptionRebateExceedsMaximum();\n }\n collateralInfo[collateralToken].redemptionRebate = newRedemptionRebate;\n emit RedemptionRebateUpdated(newRedemptionRebate);\n }\n\n function getRedemptionFeeWithDecay(\n IERC20 collateralToken,\n uint256 collateralAmount\n )\n external\n view\n override\n returns (uint256 redemptionFee)\n {\n redemptionFee = getRedemptionRateWithDecay(collateralToken).mulDown(collateralAmount);\n if (redemptionFee >= collateralAmount) {\n revert FeeEatsUpAllReturnedCollateral();\n }\n }\n\n // --- Public functions ---\n\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n public\n virtual\n override\n {\n addCollateralToken(\n collateralToken,\n priceFeed,\n newSplitLiquidationCollateral,\n new ERC20Indexable(\n address(this),\n string(bytes.concat(\"Raft \", bytes(IERC20Metadata(address(collateralToken)).name()), \" collateral\")),\n string(bytes.concat(\"r\", bytes(IERC20Metadata(address(collateralToken)).symbol()), \"-c\")),\n type(uint256).max\n ),\n new ERC20Indexable(\n address(this),\n string(bytes.concat(\"Raft \", bytes(IERC20Metadata(address(collateralToken)).name()), \" debt\")),\n string(bytes.concat(\"r\", bytes(IERC20Metadata(address(collateralToken)).symbol()), \"-d\")),\n type(uint256).max\n )\n );\n }\n\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral,\n IERC20Indexable raftCollateralToken_,\n IERC20Indexable raftDebtToken_\n )\n public\n override\n onlyOwner\n {\n if (address(collateralToken) == address(0)) {\n revert CollateralTokenAddressCannotBeZero();\n }\n if (address(priceFeed) == address(0)) {\n revert PriceFeedAddressCannotBeZero();\n }\n if (address(collateralInfo[collateralToken].collateralToken) != address(0)) {\n revert CollateralTokenAlreadyAdded();\n }\n\n CollateralTokenInfo memory raftCollateralTokenInfo;\n raftCollateralTokenInfo.collateralToken = raftCollateralToken_;\n raftCollateralTokenInfo.debtToken = raftDebtToken_;\n raftCollateralTokenInfo.isEnabled = true;\n raftCollateralTokenInfo.priceFeed = priceFeed;\n\n collateralInfo[collateralToken] = raftCollateralTokenInfo;\n\n setRedemptionSpread(collateralToken, MathUtils._100_PERCENT);\n setRedemptionRebate(collateralToken, MathUtils._100_PERCENT);\n\n setSplitLiquidationCollateral(collateralToken, newSplitLiquidationCollateral);\n\n emit CollateralTokenAdded(\n collateralToken, raftCollateralTokenInfo.collateralToken, raftCollateralTokenInfo.debtToken, priceFeed\n );\n }\n\n function setCollateralEnabled(\n IERC20 collateralToken,\n bool isEnabled\n )\n public\n override\n onlyOwner\n collateralTokenExists(collateralToken)\n {\n bool previousIsEnabled = collateralInfo[collateralToken].isEnabled;\n collateralInfo[collateralToken].isEnabled = isEnabled;\n\n if (previousIsEnabled != isEnabled) {\n emit CollateralTokenModified(collateralToken, isEnabled);\n }\n }\n\n function setSplitLiquidationCollateral(\n IERC20 collateralToken,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n public\n override\n onlyOwner\n {\n if (address(newSplitLiquidationCollateral) == address(0)) {\n revert SplitLiquidationCollateralCannotBeZero();\n }\n collateralInfo[collateralToken].splitLiquidation = newSplitLiquidationCollateral;\n emit SplitLiquidationCollateralChanged(collateralToken, newSplitLiquidationCollateral);\n }\n\n function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) public override onlyOwner {\n if (newRedemptionSpread > MathUtils._100_PERCENT) {\n revert RedemptionSpreadOutOfRange();\n }\n collateralInfo[collateralToken].redemptionSpread = newRedemptionSpread;\n emit RedemptionSpreadUpdated(collateralToken, newRedemptionSpread);\n }\n\n function getRedemptionRateWithDecay(IERC20 collateralToken) public view override returns (uint256) {\n return _calcRedemptionRate(collateralToken, _calcDecayedBaseRate(collateralToken));\n }\n\n function raftCollateralToken(IERC20 collateralToken) external view override returns (IERC20Indexable) {\n return collateralInfo[collateralToken].collateralToken;\n }\n\n function raftDebtToken(IERC20 collateralToken) external view override returns (IERC20Indexable) {\n return collateralInfo[collateralToken].debtToken;\n }\n\n function priceFeed(IERC20 collateralToken) external view override returns (IPriceFeed) {\n return collateralInfo[collateralToken].priceFeed;\n }\n\n function splitLiquidationCollateral(IERC20 collateralToken) external view returns (ISplitLiquidationCollateral) {\n return collateralInfo[collateralToken].splitLiquidation;\n }\n\n function collateralEnabled(IERC20 collateralToken) external view override returns (bool) {\n return collateralInfo[collateralToken].isEnabled;\n }\n\n function lastFeeOperationTime(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].lastFeeOperationTime;\n }\n\n function borrowingSpread(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].borrowingSpread;\n }\n\n function baseRate(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].baseRate;\n }\n\n function redemptionSpread(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].redemptionSpread;\n }\n\n function redemptionRebate(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].redemptionRebate;\n }\n\n function getRedemptionRate(IERC20 collateralToken) public view override returns (uint256) {\n return _calcRedemptionRate(collateralToken, collateralInfo[collateralToken].baseRate);\n }\n\n function getRedemptionFee(\n IERC20 collateralToken,\n uint256 collateralAmount,\n uint256 priceDeviation\n )\n public\n view\n override\n returns (uint256)\n {\n return Math.min(getRedemptionRate(collateralToken) + priceDeviation, MathUtils._100_PERCENT).mulDown(\n collateralAmount\n );\n }\n\n function getBorrowingRate(IERC20 collateralToken) public view override returns (uint256) {\n return _calcBorrowingRate(collateralToken, collateralInfo[collateralToken].baseRate);\n }\n\n function getBorrowingRateWithDecay(IERC20 collateralToken) public view override returns (uint256) {\n return _calcBorrowingRate(collateralToken, _calcDecayedBaseRate(collateralToken));\n }\n\n function getBorrowingFee(IERC20 collateralToken, uint256 debtAmount) public view override returns (uint256) {\n return getBorrowingRate(collateralToken).mulDown(debtAmount);\n }\n\n // --- Helper functions ---\n\n /// @dev Adjusts the debt of a given borrower by burning or minting the corresponding amount of R and the Raft\n /// debt token. If the debt is being increased, the borrowing fee is also triggered.\n /// @param position The address of the borrower.\n /// @param debtChange The amount of R to add or remove. Must be positive.\n /// @param isDebtIncrease True if the debt is being increased, false otherwise.\n /// @param maxFeePercentage The maximum fee percentage.\n function _adjustDebt(\n address position,\n IERC20 collateralToken,\n IERC20Indexable raftDebtToken,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage\n )\n internal\n {\n if (debtChange == 0) {\n return;\n }\n\n if (isDebtIncrease) {\n uint256 totalDebtChange =\n debtChange + _triggerBorrowingFee(collateralToken, position, debtChange, maxFeePercentage);\n raftDebtToken.mint(position, totalDebtChange);\n _mintRTokens(msg.sender, debtChange);\n } else {\n raftDebtToken.burn(position, debtChange);\n _burnRTokens(msg.sender, debtChange);\n }\n\n emit DebtChanged(position, collateralToken, debtChange, isDebtIncrease);\n }\n\n /// @dev Mints R tokens\n function _mintRTokens(address to, uint256 amount) internal virtual {\n rToken.mint(to, amount);\n }\n\n /// @dev Burns R tokens\n function _burnRTokens(address from, uint256 amount) internal virtual {\n rToken.burn(from, amount);\n }\n\n /// @dev Adjusts the collateral of a given borrower by burning or minting the corresponding amount of Raft\n /// collateral token and transferring the corresponding amount of collateral token.\n /// @param collateralToken The token the borrower used as collateral.\n /// @param position The address of the borrower.\n /// @param collateralChange The amount of collateral to add or remove. Must be positive.\n /// @param isCollateralIncrease True if the collateral is being increased, false otherwise.\n function _adjustCollateral(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease\n )\n internal\n {\n if (collateralChange == 0) {\n return;\n }\n\n if (isCollateralIncrease) {\n raftCollateralToken.mint(position, collateralChange);\n collateralToken.safeTransferFrom(msg.sender, address(this), collateralChange);\n } else {\n raftCollateralToken.burn(position, collateralChange);\n collateralToken.safeTransfer(msg.sender, collateralChange);\n }\n\n emit CollateralChanged(position, collateralToken, collateralChange, isCollateralIncrease);\n }\n\n /// @dev Updates debt and collateral indexes for a given collateral token.\n /// @param collateralToken The collateral token for which to update the indexes.\n /// @param raftCollateralToken The raft collateral indexable token.\n /// @param raftDebtToken The raft debt indexable token.\n /// @param totalDebtForCollateral Totam amount of debt backed by collateral token.\n function _updateDebtAndCollateralIndex(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n uint256 totalDebtForCollateral\n )\n internal\n {\n raftDebtToken.setIndex(totalDebtForCollateral);\n raftCollateralToken.setIndex(collateralToken.balanceOf(address(this)));\n }\n\n function _closePosition(\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n address position,\n bool burnTokens\n )\n internal\n {\n collateralTokenForPosition[position] = IERC20(address(0));\n\n if (burnTokens) {\n raftDebtToken.burn(position, type(uint256).max);\n raftCollateralToken.burn(position, type(uint256).max);\n }\n emit PositionClosed(position);\n }\n\n // --- Borrowing & redemption fee helper functions ---\n\n /// @dev Updates the base rate from a redemption operation. Impacts on the base rate:\n /// 1. decays the base rate based on time passed since last redemption or R borrowing operation,\n /// 2. increases the base rate based on the amount redeemed, as a proportion of total supply.\n function _updateBaseRateFromRedemption(\n IERC20 collateralToken,\n uint256 collateralDrawn,\n uint256 price,\n uint256 totalDebtSupply\n )\n internal\n returns (uint256)\n {\n uint256 decayedBaseRate = _calcDecayedBaseRate(collateralToken);\n\n /* Convert the drawn collateral back to R at face value rate (1 R:1 USD), in order to get\n * the fraction of total supply that was redeemed at face value. */\n uint256 redeemedFraction = collateralDrawn * price / totalDebtSupply;\n\n uint256 newBaseRate = decayedBaseRate + redeemedFraction / BETA;\n newBaseRate = Math.min(newBaseRate, MathUtils._100_PERCENT); // cap baseRate at a maximum of 100%\n assert(newBaseRate > 0); // Base rate is always non-zero after redemption\n\n // Update the baseRate state variable\n collateralInfo[collateralToken].baseRate = newBaseRate;\n emit BaseRateUpdated(collateralToken, newBaseRate);\n\n _updateLastFeeOpTime(collateralToken);\n\n return newBaseRate;\n }\n\n function _calcRedemptionRate(IERC20 collateralToken, uint256 baseRate_) internal view returns (uint256) {\n return baseRate_ + collateralInfo[collateralToken].redemptionSpread;\n }\n\n function _calcBorrowingRate(IERC20 collateralToken, uint256 baseRate_) internal view returns (uint256) {\n return Math.min(collateralInfo[collateralToken].borrowingSpread + baseRate_, MAX_BORROWING_RATE);\n }\n\n /// @dev Updates the base rate based on time elapsed since the last redemption or R borrowing operation.\n function _decayBaseRateFromBorrowing(IERC20 collateralToken) internal {\n uint256 decayedBaseRate = _calcDecayedBaseRate(collateralToken);\n assert(decayedBaseRate <= MathUtils._100_PERCENT); // The baseRate can decay to 0\n\n collateralInfo[collateralToken].baseRate = decayedBaseRate;\n emit BaseRateUpdated(collateralToken, decayedBaseRate);\n\n _updateLastFeeOpTime(collateralToken);\n }\n\n /// @dev Update the last fee operation time only if time passed >= decay interval. This prevents base rate\n /// griefing.\n function _updateLastFeeOpTime(IERC20 collateralToken) internal {\n uint256 timePassed = block.timestamp - collateralInfo[collateralToken].lastFeeOperationTime;\n\n if (timePassed >= 1 minutes) {\n collateralInfo[collateralToken].lastFeeOperationTime = block.timestamp;\n emit LastFeeOpTimeUpdated(collateralToken, block.timestamp);\n }\n }\n\n function _calcDecayedBaseRate(IERC20 collateralToken) internal view returns (uint256) {\n uint256 minutesPassed = (block.timestamp - collateralInfo[collateralToken].lastFeeOperationTime) / 1 minutes;\n uint256 decayFactor = MathUtils._decPow(MINUTE_DECAY_FACTOR, minutesPassed);\n\n return collateralInfo[collateralToken].baseRate.mulDown(decayFactor);\n }\n\n function _triggerBorrowingFee(\n IERC20 collateralToken,\n address position,\n uint256 debtAmount,\n uint256 maxFeePercentage\n )\n internal\n virtual\n returns (uint256 borrowingFee)\n {\n _decayBaseRateFromBorrowing(collateralToken); // decay the baseRate state variable\n borrowingFee = getBorrowingFee(collateralToken, debtAmount);\n\n _checkValidFee(borrowingFee, debtAmount, maxFeePercentage);\n\n if (borrowingFee > 0) {\n _mintRTokens(feeRecipient, borrowingFee);\n emit RBorrowingFeePaid(collateralToken, position, borrowingFee);\n }\n }\n\n // --- Validation check helper functions ---\n\n function _checkValidPosition(IERC20 collateralToken, uint256 positionDebt, uint256 positionCollateral) internal {\n ISplitLiquidationCollateral splitCollateral = collateralInfo[collateralToken].splitLiquidation;\n if (positionDebt < splitCollateral.LOW_TOTAL_DEBT()) {\n revert NetDebtBelowMinimum(positionDebt);\n }\n\n (uint256 price,) = collateralInfo[collateralToken].priceFeed.fetchPrice();\n uint256 newICR = MathUtils._computeCR(positionCollateral, positionDebt, price);\n if (newICR < splitCollateral.MCR()) {\n revert NewICRLowerThanMCR(newICR);\n }\n }\n\n function _checkValidFee(uint256 fee, uint256 amount, uint256 maxFeePercentage) internal pure {\n uint256 feePercentage = fee.divDown(amount);\n\n if (feePercentage > maxFeePercentage) {\n revert FeeExceedsMaxFee(fee, amount, maxFeePercentage);\n }\n }\n}\n\ninterface IRMinter {\n /// @dev Emitted when tokens are recovered from the contract.\n /// @param token The address of the token being recovered.\n /// @param to The address receiving the recovered tokens.\n /// @param amount The amount of tokens recovered.\n event TokensRecovered(IERC20 token, address to, uint256 amount);\n\n /// @return Address of the R token.\n function r() external view returns (IRToken);\n\n /// @return Address of the Position manager contract responsible for minting R.\n function positionManager() external view returns (IPositionManager);\n\n /// @dev Recover accidentally sent tokens to the contract\n /// @param token Address of the token contract.\n /// @param to Address of the receiver of the tokens.\n /// @param amount Number of tokens to recover.\n function recoverTokens(IERC20 token, address to, uint256 amount) external;\n}\n\ninterface ILock {\n /// @dev Thrown when contract usage is locked.\n error ContractLocked();\n\n /// @dev Unauthorized call to lock/unlock.\n error Unauthorized();\n\n /// @dev Retrieves if contract is currently locked or not.\n function locked() external view returns (bool);\n\n /// @dev Retrieves address of the locker who can unlock contract.\n function locker() external view returns (address);\n\n /// @dev Unlcoks the usage of the contract.\n function unlock() external;\n\n /// @dev Locks the usage of the contract.\n function lock() external;\n}\n\nabstract contract ERC20RMinter is IRMinter, ERC20, Ownable2Step {\n using SafeERC20 for IERC20;\n\n IRToken public immutable override r;\n IPositionManager public immutable override positionManager;\n\n constructor(IRToken rToken_, string memory name_, string memory symbol_) ERC20(name_, symbol_) {\n r = rToken_;\n positionManager = IPositionManager(rToken_.positionManager());\n\n _approve(address(this), address(positionManager), type(uint256).max);\n }\n\n modifier unlockCall() {\n ILock lockContract = ILock(address(positionManager.priceFeed(IERC20(this))));\n lockContract.unlock();\n _;\n lockContract.lock();\n }\n\n function recoverTokens(IERC20 token, address to, uint256 amount) external override onlyOwner {\n token.safeTransfer(to, amount);\n emit TokensRecovered(token, to, amount);\n }\n\n function _mintR(address to, uint256 amount) internal unlockCall {\n _mint(address(this), amount);\n ERC20PermitSignature memory emptySignature;\n positionManager.managePosition(\n IERC20(address(this)),\n address(this),\n amount,\n true, // collateral increase\n amount,\n true, // debt increase\n 1e18, // 100%\n emptySignature\n );\n r.transfer(to, amount);\n }\n\n function _burnR(address from, uint256 amount) internal unlockCall {\n r.transferFrom(from, address(this), amount);\n ERC20PermitSignature memory emptySignature;\n positionManager.managePosition(\n IERC20(address(this)),\n address(this),\n amount,\n false, // collateral decrease\n amount,\n false, // debt decrease\n 1e18, // 100%\n emptySignature\n );\n _burn(address(this), amount);\n }\n}\n\ncontract InterestRateDebtToken is ERC20Indexable {\n // --- Types ---\n\n using Fixed256x18 for uint256;\n\n // --- Events ---\n\n event IndexIncreasePerSecondSet(uint256 indexIncreasePerSecond);\n\n // --- Immutables ---\n\n IERC20 immutable collateralToken;\n\n // --- Variables ---\n\n uint256 internal storedIndexUpdatedAt;\n\n uint256 public indexIncreasePerSecond;\n\n // --- Constructor ---\n\n constructor(\n address positionManager_,\n string memory name_,\n string memory symbol_,\n IERC20 collateralToken_,\n uint256 cap_,\n uint256 indexIncreasePerSecond_\n )\n ERC20Indexable(positionManager_, name_, symbol_, cap_)\n {\n storedIndexUpdatedAt = block.timestamp;\n collateralToken = collateralToken_;\n setIndexIncreasePerSecond(indexIncreasePerSecond_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) public virtual override {\n updateIndexAndPayFees();\n super.mint(to, amount);\n }\n\n function burn(address from, uint256 amount) public virtual override {\n updateIndexAndPayFees();\n super.burn(from, amount);\n }\n\n function currentIndex() public view virtual override returns (uint256) {\n return storedIndex.mulUp(INDEX_PRECISION + indexIncreasePerSecond * (block.timestamp - storedIndexUpdatedAt));\n }\n\n function updateIndexAndPayFees() public {\n uint256 currentIndex_ = currentIndex();\n _payFees(currentIndex_);\n storedIndexUpdatedAt = block.timestamp;\n storedIndex = currentIndex_;\n emit IndexUpdated(currentIndex_);\n }\n\n function setIndexIncreasePerSecond(uint256 indexIncreasePerSecond_) public onlyOwner {\n updateIndexAndPayFees();\n indexIncreasePerSecond = indexIncreasePerSecond_;\n emit IndexIncreasePerSecondSet(indexIncreasePerSecond_);\n }\n\n function unpaidFees() external view returns (uint256) {\n return _unpaidFees(currentIndex());\n }\n\n function _unpaidFees(uint256 currentIndex_) private view returns (uint256) {\n return totalSupply().mulDown(currentIndex_ - storedIndex);\n }\n\n function _payFees(uint256 currentIndex_) private {\n uint256 unpaidFees = _unpaidFees(currentIndex_);\n if (unpaidFees > 0) {\n IInterestRatePositionManager(positionManager).mintFees(collateralToken, unpaidFees);\n }\n }\n}\n\n/// @dev Implementation of Position Manager. Current implementation does not support rebasing tokens as collateral.\ncontract InterestRatePositionManager is ERC20RMinter, PositionManager, IInterestRatePositionManager {\n // --- Errors ---\n\n error Unsupported();\n\n // --- Constructor ---\n\n /// @dev Initializes the position manager.\n constructor(IRToken rToken_)\n PositionManager(address(rToken_))\n ERC20RMinter(rToken_, \"Interest Rate Posman\", \"IRPM\")\n { }\n\n // --- External functions ---\n\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n public\n virtual\n override(IPositionManager, PositionManager)\n returns (uint256 actualCollateralChange, uint256 actualDebtChange)\n {\n if (address(permitSignature.token) == address(r)) {\n PermitHelper.applyPermit(permitSignature, msg.sender, address(this));\n }\n return super.managePosition(\n collateralToken,\n position,\n collateralChange,\n isCollateralIncrease,\n debtChange,\n isDebtIncrease,\n maxFeePercentage,\n permitSignature\n );\n }\n\n function mintFees(IERC20 collateralToken, uint256 amount) external {\n if (msg.sender != address(collateralInfo[collateralToken].debtToken)) {\n revert InvalidDebtToken(msg.sender);\n }\n _mintR(feeRecipient, amount);\n\n emit MintedFees(collateralToken, amount);\n }\n\n function redeemCollateral(IERC20, uint256, uint256) public virtual override(IPositionManager, PositionManager) {\n revert Unsupported();\n }\n\n function addCollateralToken(\n IERC20,\n IPriceFeed,\n ISplitLiquidationCollateral\n )\n public\n override(IPositionManager, PositionManager)\n {\n revert Unsupported();\n }\n\n // --- Helper functions ---\n\n function _mintRTokens(address to, uint256 amount) internal virtual override {\n _mintR(to, amount);\n }\n\n function _burnRTokens(address from, uint256 amount) internal virtual override {\n _burnR(from, amount);\n }\n\n function _triggerBorrowingFee(\n IERC20,\n address,\n uint256,\n uint256\n )\n internal\n pure\n virtual\n override\n returns (uint256)\n {\n return 0;\n }\n}\n" - } - }, - "settings": { - "remappings": [ - "@balancer-labs/=node_modules/@balancer-labs/", - "@balancer-labs/v2-interfaces/contracts/=lib/balancer-v2-monorepo/pkg/interfaces/contracts/", - "@chainlink/=node_modules/@chainlink/", - "@eth-optimism/=node_modules/@eth-optimism/", - "@openzeppelin/=node_modules/@openzeppelin/", - "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", - "@redstone-finance/=node_modules/@redstone-finance/", - "@smartcontractkit/chainlink/=lib/chainlink/contracts/src/v0.8/", - "@tempusfinance/=node_modules/@tempusfinance/", - "@tempusfinance/tempus-utils/contracts/=lib/tempus-utils/contracts/", - "balancer-v2-monorepo/=lib/balancer-v2-monorepo/", - "chainlink/=lib/chainlink/", - "ds-test/=lib/forge-std/lib/ds-test/src/", - "erc4626-tests/=lib/chainlink/contracts/foundry-lib/openzeppelin-contracts/lib/erc4626-tests/", - "eth-gas-reporter/=node_modules/eth-gas-reporter/", - "forge-std/=lib/forge-std/src/", - "hardhat/=node_modules/hardhat/", - "openzeppelin-contracts/=lib/openzeppelin-contracts/", - "tempus-utils/=lib/tempus-utils/contracts/" - ], - "optimizer": { - "enabled": true, - "runs": 200000 - }, - "metadata": { - "bytecodeHash": "ipfs", - "appendCBOR": true - }, - "outputSelection": { - "*": { - "*": [ - "evm.bytecode", - "evm.deployedBytecode", - "devdoc", - "userdoc", - "metadata", - "abi" - ] - } - }, - "evmVersion": "london", - "viaIR": true, - "libraries": {} - } - }, - "ABI": "[{\"inputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"rToken_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AmountIsZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BorrowingSpreadExceedsMaximum\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotLiquidateLastPosition\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenDisabled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DelegateNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FeeEatsUpAllReturnedCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePercentage\",\"type\":\"uint256\"}],\"name\":\"FeeExceedsMaxFee\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"InvalidDebtToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidDelegateAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFeeRecipient\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidMaxFeePercentage\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidPosition\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MaxFeePercentageOutOfRange\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"netDebt\",\"type\":\"uint256\"}],\"name\":\"NetDebtBelowMinimum\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newICR\",\"type\":\"uint256\"}],\"name\":\"NewICRLowerThanMCR\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NoCollateralOrDebtChange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NothingToLiquidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PositionCollateralTokenMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PriceFeedAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RedemptionRebateExceedsMaximum\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RedemptionSpreadOutOfRange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SplitLiquidationCollateralCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newTotalCollateral\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minimumCollateral\",\"type\":\"uint256\"}],\"name\":\"TotalCollateralCannotBeLowerThanMinCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newTotalDebt\",\"type\":\"uint256\"}],\"name\":\"TotalDebtCannotBeLowerThanMinDebt\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unsupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WrongCollateralParamsForFullRepayment\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseRate\",\"type\":\"uint256\"}],\"name\":\"BaseRateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowingSpread\",\"type\":\"uint256\"}],\"name\":\"BorrowingSpreadUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCollateralIncrease\",\"type\":\"bool\"}],\"name\":\"CollateralChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftCollateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftDebtToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"}],\"name\":\"CollateralTokenAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"}],\"name\":\"CollateralTokenModified\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isDebtIncrease\",\"type\":\"bool\"}],\"name\":\"DebtChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"DelegateWhitelisted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"FeeRecipientChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastFeeOpTime\",\"type\":\"uint256\"}],\"name\":\"LastFeeOpTimeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtLiquidated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralLiquidated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralSentToLiquidator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralLiquidationFeePaid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isRedistribution\",\"type\":\"bool\"}],\"name\":\"Liquidation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintedFees\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"PositionClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"PositionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IRToken\",\"name\":\"rToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"PositionManagerDeployed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"RBorrowingFeePaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralSent\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rebate\",\"type\":\"uint256\"}],\"name\":\"Redemption\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redemptionRebate\",\"type\":\"uint256\"}],\"name\":\"RedemptionRebateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redemptionSpread\",\"type\":\"uint256\"}],\"name\":\"RedemptionSpreadUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"}],\"name\":\"SplitLiquidationCollateralChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokensRecovered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BETA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_BORROWING_RATE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_BORROWING_SPREAD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINUTE_DECAY_FACTOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftCollateralToken_\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftDebtToken_\",\"type\":\"address\"}],\"name\":\"addCollateralToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"addCollateralToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"baseRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"borrowingSpread\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"collateralEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"collateralInfo\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"debtToken\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"splitLiquidation\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"lastFeeOperationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowingSpread\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"redemptionSpread\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"redemptionRebate\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"collateralTokenForPosition\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeRecipient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"}],\"name\":\"getBorrowingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getBorrowingRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getBorrowingRateWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"priceDeviation\",\"type\":\"uint256\"}],\"name\":\"getRedemptionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"}],\"name\":\"getRedemptionFeeWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"redemptionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getRedemptionRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getRedemptionRateWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"}],\"name\":\"isDelegateWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isWhitelisted\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"lastFeeOperationTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"liquidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralChange\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isCollateralIncrease\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"debtChange\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isDebtIncrease\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePercentage\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"contract IERC20Permit\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct ERC20PermitSignature\",\"name\":\"permitSignature\",\"type\":\"tuple\"}],\"name\":\"managePosition\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"actualCollateralChange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actualDebtChange\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"positionManager\",\"outputs\":[{\"internalType\":\"contract IPositionManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"priceFeed\",\"outputs\":[{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"r\",\"outputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rToken\",\"outputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"raftCollateralToken\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"raftDebtToken\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"redeemCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"redemptionRebate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"redemptionSpread\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newBorrowingSpread\",\"type\":\"uint256\"}],\"name\":\"setBorrowingSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"}],\"name\":\"setCollateralEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newFeeRecipient\",\"type\":\"address\"}],\"name\":\"setFeeRecipient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newRedemptionRebate\",\"type\":\"uint256\"}],\"name\":\"setRedemptionRebate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newRedemptionSpread\",\"type\":\"uint256\"}],\"name\":\"setRedemptionSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"}],\"name\":\"setSplitLiquidationCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"splitLiquidationCollateral\",\"outputs\":[{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"whitelistDelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - "ContractName": "InterestRatePositionManager", - "CompilerVersion": "v0.8.19+commit.7dd6d404", - "OptimizationUsed": 1, - "Runs": 200000, - "ConstructorArguments": "0x000000000000000000000000183015a9ba6ff60230fdeadc3f43b3d788b13e21", - "EVMVersion": "london", - "Library": "", - "LicenseType": "", - "Proxy": 0, - "SwarmSource": "" - } -] \ No newline at end of file +[{"SourceCode":{"language":"Solidity","sources":{"contracts/InterestRates/InterestRatePositionManager.f.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n/// Parameters for ERC20Permit.permit call\nstruct ERC20PermitSignature {\n IERC20Permit token;\n uint256 value;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\nlibrary PermitHelper {\n function applyPermit(\n ERC20PermitSignature calldata p,\n address owner,\n address spender\n ) internal {\n p.token.permit(owner, spender, p.value, p.deadline, p.v, p.r, p.s);\n }\n\n function applyPermits(\n ERC20PermitSignature[] calldata permits,\n address owner,\n address spender\n ) internal {\n for (uint256 i = 0; i < permits.length; i++) {\n applyPermit(permits[i], owner, spender);\n }\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashLender.sol)\n\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC3156FlashBorrower.sol)\n\n/**\n * @dev Interface of the ERC3156 FlashBorrower, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashBorrower {\n /**\n * @dev Receive a flash loan.\n * @param initiator The initiator of the loan.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @param fee The additional amount of tokens to repay.\n * @param data Arbitrary data structure, intended to contain user-defined parameters.\n * @return The keccak256 hash of \"IERC3156FlashBorrower.onFlashLoan\"\n */\n function onFlashLoan(\n address initiator,\n address token,\n uint256 amount,\n uint256 fee,\n bytes calldata data\n ) external returns (bytes32);\n}\n\n/**\n * @dev Interface of the ERC3156 FlashLender, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashLender {\n /**\n * @dev The amount of currency available to be lended.\n * @param token The loan currency.\n * @return The amount of `token` that can be borrowed.\n */\n function maxFlashLoan(address token) external view returns (uint256);\n\n /**\n * @dev The fee to be charged for a given loan.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @return The amount of `token` to be charged for the loan, on top of the returned principal.\n */\n function flashFee(address token, uint256 amount) external view returns (uint256);\n\n /**\n * @dev Initiate a flash loan.\n * @param receiver The receiver of the tokens in the loan, and the receiver of the callback.\n * @param token The loan currency.\n * @param amount The amount of tokens lent.\n * @param data Arbitrary data structure, intended to contain user-defined parameters.\n */\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n ) external returns (bool);\n}\n\n/// @dev Interface to be used by contracts that collect fees. Contains fee recipient that can be changed by owner.\ninterface IFeeCollector {\n // --- Events ---\n\n /// @dev Fee Recipient is changed to @param feeRecipient address.\n /// @param feeRecipient New fee recipient address.\n event FeeRecipientChanged(address feeRecipient);\n\n // --- Errors ---\n\n /// @dev Invalid fee recipient.\n error InvalidFeeRecipient();\n\n // --- Functions ---\n\n /// @return Address of the current fee recipient.\n function feeRecipient() external view returns (address);\n\n /// @dev Sets new fee recipient address\n /// @param newFeeRecipient Address of the new fee recipient.\n function setFeeRecipient(address newFeeRecipient) external;\n}\n\ninterface IPositionManagerDependent {\n // --- Errors ---\n\n /// @dev Position Manager cannot be zero.\n error PositionManagerCannotBeZero();\n\n /// @dev Caller is not Position Manager.\n error CallerIsNotPositionManager(address caller);\n\n // --- Functions ---\n\n /// @dev Returns address of the PositionManager contract.\n function positionManager() external view returns (address);\n}\n\n/// @dev Interface of R stablecoin token. Implements some standards like IERC20, IERC20Permit, and IERC3156FlashLender.\n/// Raft's specific implementation contains IFeeCollector and IPositionManagerDependent.\n/// PositionManager can mint and burn R when particular actions happen with user's position.\ninterface IRToken is IERC20, IERC20Permit, IERC3156FlashLender, IFeeCollector, IPositionManagerDependent {\n // --- Events ---\n\n /// @dev New R token is deployed\n /// @param positionManager Address of the PositionManager contract that is authorized to mint and burn new tokens.\n /// @param flashMintFeeRecipient Address of flash mint fee recipient.\n event RDeployed(address positionManager, address flashMintFeeRecipient);\n\n /// @dev The Flash Mint Fee Percentage has been changed.\n /// @param flashMintFeePercentage The new Flash Mint Fee Percentage value.\n event FlashMintFeePercentageChanged(uint256 flashMintFeePercentage);\n\n /// --- Errors ---\n\n /// @dev Proposed flash mint fee percentage is too big.\n /// @param feePercentage Proposed flash mint fee percentage.\n error FlashFeePercentageTooBig(uint256 feePercentage);\n\n // --- Functions ---\n\n /// @return Number representing 100 percentage.\n function PERCENTAGE_BASE() external view returns (uint256);\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param to Address that will receive newly minted tokens.\n /// @param amount Amount of tokens to mint.\n function mint(address to, uint256 amount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param from Address of user whose tokens are burnt.\n /// @param amount Amount of tokens to burn.\n function burn(address from, uint256 amount) external;\n\n /// @return Maximum flash mint fee percentage that can be set by owner.\n function MAX_FLASH_MINT_FEE_PERCENTAGE() external view returns (uint256);\n\n /// @return Current flash mint fee percentage.\n function flashMintFeePercentage() external view returns (uint256);\n\n /// @dev Sets new flash mint fee percentage. Callable only by owner.\n /// @notice The proposed flash mint fee percentage cannot exceed `MAX_FLASH_MINT_FEE_PERCENTAGE`.\n /// @param feePercentage New flash fee percentage.\n function setFlashMintFeePercentage(uint256 feePercentage) external;\n}\n\ninterface IPriceOracle {\n // --- Errors ---\n\n /// @dev Contract initialized with an invalid deviation parameter.\n error InvalidDeviation();\n\n // --- Types ---\n\n struct PriceOracleResponse {\n bool isBrokenOrFrozen;\n bool priceChangeAboveMax;\n uint256 price;\n }\n\n // --- Functions ---\n\n /// @dev Return price oracle response which consists the following information: oracle is broken or frozen, the\n /// price change between two rounds is more than max, and the price.\n function getPriceOracleResponse() external returns (PriceOracleResponse memory);\n\n /// @dev Maximum time period allowed since oracle latest round data timestamp, beyond which oracle is considered\n /// frozen.\n function timeout() external view returns (uint256);\n\n /// @dev Used to convert a price answer to an 18-digit precision uint.\n function TARGET_DIGITS() external view returns (uint256);\n\n /// @dev price deviation for the oracle in percentage.\n function DEVIATION() external view returns (uint256);\n}\n\ninterface IPriceFeed {\n // --- Events ---\n\n /// @dev Last good price has been updated.\n event LastGoodPriceUpdated(uint256 lastGoodPrice);\n\n /// @dev Price difference between oracles has been updated.\n /// @param priceDifferenceBetweenOracles New price difference between oracles.\n event PriceDifferenceBetweenOraclesUpdated(uint256 priceDifferenceBetweenOracles);\n\n /// @dev Primary oracle has been updated.\n /// @param primaryOracle New primary oracle.\n event PrimaryOracleUpdated(IPriceOracle primaryOracle);\n\n /// @dev Secondary oracle has been updated.\n /// @param secondaryOracle New secondary oracle.\n event SecondaryOracleUpdated(IPriceOracle secondaryOracle);\n\n // --- Errors ---\n\n /// @dev Invalid primary oracle.\n error InvalidPrimaryOracle();\n\n /// @dev Invalid secondary oracle.\n error InvalidSecondaryOracle();\n\n /// @dev Primary oracle is broken or frozen or has bad result.\n error PrimaryOracleBrokenOrFrozenOrBadResult();\n\n /// @dev Invalid price difference between oracles.\n error InvalidPriceDifferenceBetweenOracles();\n\n // --- Functions ---\n\n /// @dev Return primary oracle address.\n function primaryOracle() external returns (IPriceOracle);\n\n /// @dev Return secondary oracle address\n function secondaryOracle() external returns (IPriceOracle);\n\n /// @dev The last good price seen from an oracle by Raft.\n function lastGoodPrice() external returns (uint256);\n\n /// @dev The maximum relative price difference between two oracle responses.\n function priceDifferenceBetweenOracles() external returns (uint256);\n\n /// @dev Set primary oracle address.\n /// @param newPrimaryOracle Primary oracle address.\n function setPrimaryOracle(IPriceOracle newPrimaryOracle) external;\n\n /// @dev Set secondary oracle address.\n /// @param newSecondaryOracle Secondary oracle address.\n function setSecondaryOracle(IPriceOracle newSecondaryOracle) external;\n\n /// @dev Set the maximum relative price difference between two oracle responses.\n /// @param newPriceDifferenceBetweenOracles The maximum relative price difference between two oracle responses.\n function setPriceDifferenceBetweenOracles(uint256 newPriceDifferenceBetweenOracles) external;\n\n /// @dev Returns the latest price obtained from the Oracle. Called by Raft functions that require a current price.\n ///\n /// Also callable by anyone externally.\n /// Non-view function - it stores the last good price seen by Raft.\n ///\n /// Uses a primary oracle and a fallback oracle in case primary fails. If both fail,\n /// it uses the last good price seen by Raft.\n ///\n /// @return currentPrice Returned price.\n /// @return deviation Deviation of the reported price in percentage.\n /// @notice Actual returned price is in range `currentPrice` +/- `currentPrice * deviation / ONE`\n function fetchPrice() external returns (uint256 currentPrice, uint256 deviation);\n}\n\ninterface IERC20Indexable is IERC20, IPositionManagerDependent {\n // --- Events ---\n\n /// @dev New token is deployed.\n /// @param positionManager Address of the PositionManager contract that is authorized to mint and burn new tokens.\n event ERC20IndexableDeployed(address positionManager);\n\n /// @dev New index has been set.\n /// @param newIndex Value of the new index.\n event IndexUpdated(uint256 newIndex);\n\n // --- Errors ---\n\n /// @dev Unsupported action for ERC20Indexable contract.\n error NotSupported();\n\n // --- Functions ---\n\n /// @return Precision for token index. Represents index that is equal to 1.\n function INDEX_PRECISION() external view returns (uint256);\n\n /// @return Current index value.\n function currentIndex() external view returns (uint256);\n\n /// @dev Sets new token index. Callable only by PositionManager contract.\n /// @param backingAmount Amount of backing token that is covered by total supply.\n function setIndex(uint256 backingAmount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param to Address that will receive newly minted tokens.\n /// @param amount Amount of tokens to mint.\n function mint(address to, uint256 amount) external;\n\n /// @dev Mints new tokens. Callable only by PositionManager contract.\n /// @param from Address of user whose tokens are burnt.\n /// @param amount Amount of tokens to burn.\n function burn(address from, uint256 amount) external;\n}\n\ninterface ISplitLiquidationCollateral {\n // --- Functions ---\n\n /// @dev Returns lowest total debt that will be split.\n function LOW_TOTAL_DEBT() external view returns (uint256);\n\n /// @dev Minimum collateralization ratio for position\n function MCR() external view returns (uint256);\n\n /// @dev Splits collateral between protocol and liquidator.\n /// @param totalCollateral Amount of collateral to split.\n /// @param totalDebt Amount of debt to split.\n /// @param price Price of collateral.\n /// @param isRedistribution True if this is a redistribution.\n /// @return collateralToSendToProtocol Amount of collateral to send to protocol.\n /// @return collateralToSentToLiquidator Amount of collateral to send to liquidator.\n function split(\n uint256 totalCollateral,\n uint256 totalDebt,\n uint256 price,\n bool isRedistribution\n )\n external\n view\n returns (uint256 collateralToSendToProtocol, uint256 collateralToSentToLiquidator);\n}\n\n/// @dev Common interface for the Position Manager.\ninterface IPositionManager is IFeeCollector {\n // --- Types ---\n\n /// @dev Information for a Raft indexable collateral token.\n /// @param collateralToken The Raft indexable collateral token.\n /// @param debtToken Corresponding Raft indexable debt token.\n /// @param priceFeed The contract that provides a price for the collateral token.\n /// @param splitLiquidation The contract that calculates collateral split in case of liquidation.\n /// @param isEnabled Whether the token can be used as collateral or not.\n /// @param lastFeeOperationTime Timestamp of the last operation for the collateral token.\n /// @param borrowingSpread The current borrowing spread.\n /// @param baseRate The current base rate.\n /// @param redemptionSpread The current redemption spread.\n /// @param redemptionRebate Percentage of the redemption fee returned to redeemed positions.\n struct CollateralTokenInfo {\n IERC20Indexable collateralToken;\n IERC20Indexable debtToken;\n IPriceFeed priceFeed;\n ISplitLiquidationCollateral splitLiquidation;\n bool isEnabled;\n uint256 lastFeeOperationTime;\n uint256 borrowingSpread;\n uint256 baseRate;\n uint256 redemptionSpread;\n uint256 redemptionRebate;\n }\n\n // --- Events ---\n\n /// @dev New position manager has been token deployed.\n /// @param rToken The R token used by the position manager.\n /// @param feeRecipient The address of fee recipient.\n event PositionManagerDeployed(IRToken rToken, address feeRecipient);\n\n /// @dev New collateral token has been added added to the system.\n /// @param collateralToken The token used as collateral.\n /// @param raftCollateralToken The Raft indexable collateral token for the given collateral token.\n /// @param raftDebtToken The Raft indexable debt token for given collateral token.\n /// @param priceFeed The contract that provides price for the collateral token.\n event CollateralTokenAdded(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n IPriceFeed priceFeed\n );\n\n /// @dev Collateral token has been enabled or disabled.\n /// @param collateralToken The token used as collateral.\n /// @param isEnabled True if the token is enabled, false otherwise.\n event CollateralTokenModified(IERC20 collateralToken, bool isEnabled);\n\n /// @dev A delegate has been whitelisted for a certain position.\n /// @param position The position for which the delegate was whitelisted.\n /// @param delegate The delegate which was whitelisted.\n /// @param whitelisted Specifies whether the delegate whitelisting has been enabled (true) or disabled (false).\n event DelegateWhitelisted(address indexed position, address indexed delegate, bool whitelisted);\n\n /// @dev New position has been created.\n /// @param position The address of the user opening new position.\n /// @param collateralToken The token used as collateral for the created position.\n event PositionCreated(address indexed position, IERC20 indexed collateralToken);\n\n /// @dev The position has been closed by either repayment, liquidation, or redemption.\n /// @param position The address of the user whose position is closed.\n event PositionClosed(address indexed position);\n\n /// @dev Collateral amount for the position has been changed.\n /// @param position The address of the user that has opened the position.\n /// @param collateralToken The address of the collateral token being added to position.\n /// @param collateralAmount The amount of collateral added or removed.\n /// @param isCollateralIncrease Whether the collateral is added to the position or removed from it.\n event CollateralChanged(\n address indexed position, IERC20 indexed collateralToken, uint256 collateralAmount, bool isCollateralIncrease\n );\n\n /// @dev Debt amount for position has been changed.\n /// @param position The address of the user that has opened the position.\n /// @param collateralToken The address of the collateral token backing the debt.\n /// @param debtAmount The amount of debt added or removed.\n /// @param isDebtIncrease Whether the debt is added to the position or removed from it.\n event DebtChanged(\n address indexed position, IERC20 indexed collateralToken, uint256 debtAmount, bool isDebtIncrease\n );\n\n /// @dev Borrowing fee has been paid. Emitted only if the actual fee was paid - doesn't happen with no fees are\n /// paid.\n /// @param collateralToken Collateral token used to mint R.\n /// @param position The address of position's owner that triggered the fee payment.\n /// @param feeAmount The amount of tokens paid as the borrowing fee.\n event RBorrowingFeePaid(IERC20 collateralToken, address indexed position, uint256 feeAmount);\n\n /// @dev Liquidation has been executed.\n /// @param liquidator The liquidator that executed the liquidation.\n /// @param position The address of position's owner whose position was liquidated.\n /// @param collateralToken The collateral token used for the liquidation.\n /// @param debtLiquidated The total debt that was liquidated or redistributed.\n /// @param collateralLiquidated The total collateral liquidated.\n /// @param collateralSentToLiquidator The collateral amount sent to the liquidator.\n /// @param collateralLiquidationFeePaid The total collateral paid as the liquidation fee to the fee recipient.\n /// @param isRedistribution Whether the executed liquidation was redistribution or not.\n event Liquidation(\n address indexed liquidator,\n address indexed position,\n IERC20 indexed collateralToken,\n uint256 debtLiquidated,\n uint256 collateralLiquidated,\n uint256 collateralSentToLiquidator,\n uint256 collateralLiquidationFeePaid,\n bool isRedistribution\n );\n\n /// @dev Redemption has been executed.\n /// @param redeemer User that redeemed R.\n /// @param amount Amount of R that was redeemed.\n /// @param collateralSent The amount of collateral sent to the redeemer.\n /// @param fee The amount of fee paid to the fee recipient.\n /// @param rebate Redemption rebate amount.\n event Redemption(address indexed redeemer, uint256 amount, uint256 collateralSent, uint256 fee, uint256 rebate);\n\n /// @dev Borrowing spread has been updated.\n /// @param borrowingSpread The new borrowing spread.\n event BorrowingSpreadUpdated(uint256 borrowingSpread);\n\n /// @dev Redemption rebate has been updated.\n /// @param redemptionRebate The new redemption rebate.\n event RedemptionRebateUpdated(uint256 redemptionRebate);\n\n /// @dev Redemption spread has been updated.\n /// @param collateralToken Collateral token that the spread was set for.\n /// @param redemptionSpread The new redemption spread.\n event RedemptionSpreadUpdated(IERC20 collateralToken, uint256 redemptionSpread);\n\n /// @dev Base rate has been updated.\n /// @param collateralToken Collateral token that the baser rate was updated for.\n /// @param baseRate The new base rate.\n event BaseRateUpdated(IERC20 collateralToken, uint256 baseRate);\n\n /// @dev Last fee operation time has been updated.\n /// @param collateralToken Collateral token that the baser rate was updated for.\n /// @param lastFeeOpTime The new operation time.\n event LastFeeOpTimeUpdated(IERC20 collateralToken, uint256 lastFeeOpTime);\n\n /// @dev Split liquidation collateral has been changed.\n /// @param collateralToken Collateral token whose split liquidation collateral contract is set.\n /// @param newSplitLiquidationCollateral New value that was set to be split liquidation collateral.\n event SplitLiquidationCollateralChanged(\n IERC20 collateralToken, ISplitLiquidationCollateral indexed newSplitLiquidationCollateral\n );\n\n // --- Errors ---\n\n /// @dev Max fee percentage must be between borrowing spread and 100%.\n error InvalidMaxFeePercentage();\n\n /// @dev Max fee percentage must be between 0.5% and 100%.\n error MaxFeePercentageOutOfRange();\n\n /// @dev Amount is zero.\n error AmountIsZero();\n\n /// @dev Nothing to liquidate.\n error NothingToLiquidate();\n\n /// @dev Cannot liquidate last position.\n error CannotLiquidateLastPosition();\n\n /// @dev Cannot redeem collateral below minimum debt threshold.\n /// @param collateralToken Collateral token used to redeem.\n /// @param newTotalDebt New total debt backed by collateral, which is lower than minimum debt.\n error TotalDebtCannotBeLowerThanMinDebt(IERC20 collateralToken, uint256 newTotalDebt);\n\n /// @dev Cannot redeem collateral\n /// @param collateralToken Collateral token used to redeem.\n /// @param newTotalCollateral New total collateral, which is lower than minimum collateral.\n /// @param minimumCollateral Minimum collateral required to complete redeem\n error TotalCollateralCannotBeLowerThanMinCollateral(\n IERC20 collateralToken, uint256 newTotalCollateral, uint256 minimumCollateral\n );\n\n /// @dev Fee would eat up all returned collateral.\n error FeeEatsUpAllReturnedCollateral();\n\n /// @dev Borrowing spread exceeds maximum.\n error BorrowingSpreadExceedsMaximum();\n\n /// @dev Redemption rebate exceeds maximum.\n error RedemptionRebateExceedsMaximum();\n\n /// @dev Redemption spread is out of allowed range.\n error RedemptionSpreadOutOfRange();\n\n /// @dev There must be either a collateral change or a debt change.\n error NoCollateralOrDebtChange();\n\n /// @dev There is some collateral for position that doesn't have debt.\n error InvalidPosition();\n\n /// @dev An operation that would result in ICR < MCR is not permitted.\n /// @param newICR Resulting ICR that is below MCR.\n error NewICRLowerThanMCR(uint256 newICR);\n\n /// @dev Position's net debt must be greater than minimum.\n /// @param netDebt Net debt amount that is below minimum.\n error NetDebtBelowMinimum(uint256 netDebt);\n\n /// @dev The provided delegate address is invalid.\n error InvalidDelegateAddress();\n\n /// @dev A non-whitelisted delegate cannot adjust positions.\n error DelegateNotWhitelisted();\n\n /// @dev Fee exceeded provided maximum fee percentage.\n /// @param fee The fee amount.\n /// @param amount The amount of debt or collateral.\n /// @param maxFeePercentage The maximum fee percentage.\n error FeeExceedsMaxFee(uint256 fee, uint256 amount, uint256 maxFeePercentage);\n\n /// @dev Borrower uses a different collateral token already.\n error PositionCollateralTokenMismatch();\n\n /// @dev Collateral token address cannot be zero.\n error CollateralTokenAddressCannotBeZero();\n\n /// @dev Price feed address cannot be zero.\n error PriceFeedAddressCannotBeZero();\n\n /// @dev Collateral token already added.\n error CollateralTokenAlreadyAdded();\n\n /// @dev Collateral token is not added.\n error CollateralTokenNotAdded();\n\n /// @dev Collateral token is not enabled.\n error CollateralTokenDisabled();\n\n /// @dev Split liquidation collateral cannot be zero.\n error SplitLiquidationCollateralCannotBeZero();\n\n /// @dev Cannot change collateral in case of repaying the whole debt.\n error WrongCollateralParamsForFullRepayment();\n\n // --- Functions ---\n\n /// @return The R token used by position manager.\n function rToken() external view returns (IRToken);\n\n /// @dev Retrieves information about certain collateral type.\n /// @param collateralToken The token used as collateral.\n /// @return raftCollateralToken The Raft indexable collateral token.\n /// @return raftDebtToken The Raft indexable debt token.\n /// @return priceFeed The contract that provides a price for the collateral token.\n /// @return splitLiquidation The contract that calculates collateral split in case of liquidation.\n /// @return isEnabled Whether the collateral token can be used as collateral or not.\n /// @return lastFeeOperationTime Timestamp of the last operation for the collateral token.\n /// @return borrowingSpread The current borrowing spread.\n /// @return baseRate The current base rate.\n /// @return redemptionSpread The current redemption spread.\n /// @return redemptionRebate Percentage of the redemption fee returned to redeemed positions.\n function collateralInfo(IERC20 collateralToken)\n external\n view\n returns (\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral splitLiquidation,\n bool isEnabled,\n uint256 lastFeeOperationTime,\n uint256 borrowingSpread,\n uint256 baseRate,\n uint256 redemptionSpread,\n uint256 redemptionRebate\n );\n\n /// @param collateralToken Collateral token whose raft collateral indexable token is being queried.\n /// @return Raft collateral token address for given collateral token.\n function raftCollateralToken(IERC20 collateralToken) external view returns (IERC20Indexable);\n\n /// @param collateralToken Collateral token whose raft collateral indexable token is being queried.\n /// @return Raft debt token address for given collateral token.\n function raftDebtToken(IERC20 collateralToken) external view returns (IERC20Indexable);\n\n /// @param collateralToken Collateral token whose price feed contract is being queried.\n /// @return Price feed contract address for given collateral token.\n function priceFeed(IERC20 collateralToken) external view returns (IPriceFeed);\n\n /// @param collateralToken Collateral token whose split liquidation collateral is being queried.\n /// @return Returns address of the split liquidation collateral contract.\n function splitLiquidationCollateral(IERC20 collateralToken) external view returns (ISplitLiquidationCollateral);\n\n /// @param collateralToken Collateral token whose split liquidation collateral is being queried.\n /// @return Returns whether collateral is enabled or nor.\n function collateralEnabled(IERC20 collateralToken) external view returns (bool);\n\n /// @param collateralToken Collateral token we query last operation time fee for.\n /// @return The timestamp of the latest fee operation (redemption or new R issuance).\n function lastFeeOperationTime(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query borrowing spread for.\n /// @return The current borrowing spread.\n function borrowingSpread(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query base rate for.\n /// @return rate The base rate.\n function baseRate(IERC20 collateralToken) external view returns (uint256 rate);\n\n /// @param collateralToken Collateral token we query redemption spread for.\n /// @return The current redemption spread for collateral token.\n function redemptionSpread(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query redemption rebate for.\n /// @return rebate Percentage of the redemption fee returned to redeemed positions.\n function redemptionRebate(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query redemption rate for.\n /// @return rate The current redemption rate for collateral token.\n function getRedemptionRate(IERC20 collateralToken) external view returns (uint256 rate);\n\n /// @dev Returns the collateral token that a given position used for their position.\n /// @param position The address of the borrower.\n /// @return collateralToken The collateral token of the borrower's position.\n function collateralTokenForPosition(address position) external view returns (IERC20 collateralToken);\n\n /// @dev Adds a new collateral token to the protocol.\n /// @param collateralToken The new collateral token.\n /// @param priceFeed The price feed for the collateral token.\n /// @param newSplitLiquidationCollateral split liquidation collateral contract address.\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n external;\n\n /// @dev Adds a new collateral token to the protocol.\n /// @param collateralToken The new collateral token.\n /// @param priceFeed The price feed for the collateral token.\n /// @param newSplitLiquidationCollateral split liquidation collateral contract address.\n /// @param raftCollateralToken_ Address of raft collateral token.\n /// @param raftDebtToken_ Address of raft debt token.\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral,\n IERC20Indexable raftCollateralToken_,\n IERC20Indexable raftDebtToken_\n )\n external;\n\n /// @dev Enables or disables a collateral token. Reverts if the collateral token has not been added.\n /// @param collateralToken The collateral token.\n /// @param isEnabled Whether the collateral token can be used as collateral or not.\n function setCollateralEnabled(IERC20 collateralToken, bool isEnabled) external;\n\n /// @dev Sets the new split liquidation collateral contract.\n /// @param collateralToken Collateral token whose split liquidation collateral is being set.\n /// @param newSplitLiquidationCollateral New split liquidation collateral contract address.\n function setSplitLiquidationCollateral(\n IERC20 collateralToken,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n external;\n\n /// @dev Liquidates the borrower if its position's ICR is lower than the minimum collateral ratio.\n /// @param position The address of the borrower.\n function liquidate(address position) external;\n\n /// @dev Redeems the collateral token for a given debt amount. It sends @param debtAmount R to the system and\n /// redeems the corresponding amount of collateral from as many positions as are needed to fill the redemption\n /// request.\n /// @param collateralToken The token used as collateral.\n /// @param debtAmount The amount of debt to be redeemed. Must be greater than zero.\n /// @param maxFeePercentage The maximum fee percentage to pay for the redemption.\n function redeemCollateral(IERC20 collateralToken, uint256 debtAmount, uint256 maxFeePercentage) external;\n\n /// @dev Manages the position on behalf of a given borrower.\n /// @param collateralToken The token the borrower used as collateral.\n /// @param position The address of the borrower.\n /// @param collateralChange The amount of collateral to add or remove.\n /// @param isCollateralIncrease True if the collateral is being increased, false otherwise.\n /// @param debtChange The amount of R to add or remove. In case of repayment (isDebtIncrease = false)\n /// `type(uint256).max` value can be used to repay the whole outstanding loan.\n /// @param isDebtIncrease True if the debt is being increased, false otherwise.\n /// @param maxFeePercentage The maximum fee percentage to pay for the position management.\n /// @param permitSignature Optional permit signature for tokens that support IERC20Permit interface.\n /// @notice `permitSignature` it is ignored if permit signature is not for `collateralToken`.\n /// @notice In case of full debt repayment, `isCollateralIncrease` is ignored and `collateralChange` must be 0.\n /// These values are set to `false`(collateral decrease), and the whole collateral balance of the user.\n /// @return actualCollateralChange Actual amount of collateral added/removed.\n /// Can be different to `collateralChange` in case of full repayment.\n /// @return actualDebtChange Actual amount of debt added/removed.\n /// Can be different to `debtChange` in case of passing type(uint256).max as `debtChange`.\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n external\n returns (uint256 actualCollateralChange, uint256 actualDebtChange);\n\n /// @return The max borrowing spread.\n function MAX_BORROWING_SPREAD() external view returns (uint256);\n\n /// @return The max borrowing rate.\n function MAX_BORROWING_RATE() external view returns (uint256);\n\n /// @dev Sets the new borrowing spread.\n /// @param collateralToken Collateral token we set borrowing spread for.\n /// @param newBorrowingSpread New borrowing spread to be used.\n function setBorrowingSpread(IERC20 collateralToken, uint256 newBorrowingSpread) external;\n\n /// @param collateralToken Collateral token we query borrowing rate for.\n /// @return The current borrowing rate.\n function getBorrowingRate(IERC20 collateralToken) external view returns (uint256);\n\n /// @param collateralToken Collateral token we query borrowing rate with decay for.\n /// @return The current borrowing rate with decay.\n function getBorrowingRateWithDecay(IERC20 collateralToken) external view returns (uint256);\n\n /// @dev Returns the borrowing fee for a given debt amount.\n /// @param collateralToken Collateral token we query borrowing fee for.\n /// @param debtAmount The amount of debt.\n /// @return The borrowing fee.\n function getBorrowingFee(IERC20 collateralToken, uint256 debtAmount) external view returns (uint256);\n\n /// @dev Sets the new redemption spread.\n /// @param newRedemptionSpread New redemption spread to be used.\n function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) external;\n\n /// @dev Sets new redemption rebate percentage.\n /// @param newRedemptionRebate Value that is being set as a redemption rebate percentage.\n function setRedemptionRebate(IERC20 collateralToken, uint256 newRedemptionRebate) external;\n\n /// @param collateralToken Collateral token we query redemption rate with decay for.\n /// @return The current redemption rate with decay.\n function getRedemptionRateWithDecay(IERC20 collateralToken) external view returns (uint256);\n\n /// @dev Returns the redemption fee for a given collateral amount.\n /// @param collateralToken Collateral token we query redemption fee for.\n /// @param collateralAmount The amount of collateral.\n /// @param priceDeviation Deviation for the reported price by oracle in percentage.\n /// @return The redemption fee.\n function getRedemptionFee(\n IERC20 collateralToken,\n uint256 collateralAmount,\n uint256 priceDeviation\n )\n external\n view\n returns (uint256);\n\n /// @dev Returns the redemption fee with decay for a given collateral amount.\n /// @param collateralToken Collateral token we query redemption fee with decay for.\n /// @param collateralAmount The amount of collateral.\n /// @return The redemption fee with decay.\n function getRedemptionFeeWithDecay(\n IERC20 collateralToken,\n uint256 collateralAmount\n )\n external\n view\n returns (uint256);\n\n /// @return Half-life of 12h (720 min).\n /// @dev (1/2) = d^720 => d = (1/2)^(1/720)\n function MINUTE_DECAY_FACTOR() external view returns (uint256);\n\n /// @dev Returns if a given delegate is whitelisted for a given borrower.\n /// @param position The address of the borrower.\n /// @param delegate The address of the delegate.\n /// @return isWhitelisted True if the delegate is whitelisted for a given borrower, false otherwise.\n function isDelegateWhitelisted(address position, address delegate) external view returns (bool isWhitelisted);\n\n /// @dev Whitelists a delegate.\n /// @param delegate The address of the delegate.\n /// @param whitelisted True if delegate is being whitelisted, false otherwise.\n function whitelistDelegate(address delegate, bool whitelisted) external;\n\n /// @return Parameter by which to divide the redeemed fraction, in order to calc the new base rate from a\n /// redemption. Corresponds to (1 / ALPHA) in the white paper.\n function BETA() external view returns (uint256);\n}\n\n/// @dev Common interface for the Position Manager.\ninterface IInterestRatePositionManager is IPositionManager {\n // --- Events ---\n\n /// @dev Fees coming from accrued interest are minted.\n /// @param collateralToken Collateral token that fees are paid for.\n /// @param amount Amount of R minted.\n event MintedFees(IERC20 collateralToken, uint256 amount);\n\n // --- Errors ---\n\n /// @dev Only registered debt token can be caller.\n /// @param sender Actual caller.\n error InvalidDebtToken(address sender);\n\n // --- Functions ---\n\n /// @dev Mints fees coming from accrued interest. Can be called only from matching debt token.\n /// @param collateralToken Collateral token to mint fees for.\n /// @param amount Amount of R to mint.\n function mintFees(IERC20 collateralToken, uint256 amount) external;\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n\nlibrary Fixed256x18 {\n uint256 internal constant ONE = 1e18; // 18 decimal places\n\n function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a * b) / ONE;\n }\n\n function mulUp(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 product = a * b;\n\n if (product == 0) {\n return 0;\n } else {\n return ((product - 1) / ONE) + 1;\n }\n }\n\n function divDown(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a * ONE) / b;\n }\n\n function divUp(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n } else {\n return (((a * ONE) - 1) / b) + 1;\n }\n }\n\n function complement(uint256 x) internal pure returns (uint256) {\n return (x < ONE) ? (ONE - x) : 0;\n }\n}\n\nlibrary MathUtils {\n // --- Constants ---\n\n /// @notice Represents 100%.\n /// @dev 1e18 is the scaling factor (100% == 1e18).\n uint256 public constant _100_PERCENT = Fixed256x18.ONE;\n\n /// @notice Precision for Nominal ICR (independent of price).\n /// @dev Rationale for the value:\n /// - Making it “too high” could lead to overflows.\n /// - Making it “too low” could lead to an ICR equal to zero, due to truncation from floor division.\n ///\n /// This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 collateralToken,\n /// and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.\n uint256 internal constant _NICR_PRECISION = 1e20;\n\n /// @notice Number of minutes in 1000 years.\n uint256 internal constant _MINUTES_IN_1000_YEARS = 1000 * 365 days / 1 minutes;\n\n // --- Functions ---\n\n /// @notice Multiplies two decimal numbers and use normal rounding rules:\n /// - round product up if 19'th mantissa digit >= 5\n /// - round product down if 19'th mantissa digit < 5.\n /// @param x First number.\n /// @param y Second number.\n function _decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {\n decProd = (x * y + Fixed256x18.ONE / 2) / Fixed256x18.ONE;\n }\n\n /// @notice Exponentiation function for 18-digit decimal base, and integer exponent n.\n ///\n /// @dev Uses the efficient \"exponentiation by squaring\" algorithm. O(log(n)) complexity. The exponent is capped to\n /// avoid reverting due to overflow.\n ///\n /// If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be\n /// negligibly different from just passing the cap, since the decayed base rate will be 0 for 1000 years or > 1000\n /// years.\n /// @param base The decimal base.\n /// @param exponent The exponent.\n /// @return The result of the exponentiation.\n function _decPow(uint256 base, uint256 exponent) internal pure returns (uint256) {\n if (exponent == 0) {\n return Fixed256x18.ONE;\n }\n\n uint256 y = Fixed256x18.ONE;\n uint256 x = base;\n uint256 n = Math.min(exponent, _MINUTES_IN_1000_YEARS); // cap to avoid overflow\n\n // Exponentiation-by-squaring\n while (n > 1) {\n if (n % 2 != 0) {\n y = _decMul(x, y);\n }\n x = _decMul(x, x);\n n /= 2;\n }\n\n return _decMul(x, y);\n }\n\n /// @notice Computes the Nominal Individual Collateral Ratio (NICR) for given collateral and debt. If debt is zero,\n /// it returns the maximal value for uint256 (represents \"infinite\" CR).\n /// @param collateral Collateral amount.\n /// @param debt Debt amount.\n /// @return NICR.\n function _computeNominalCR(uint256 collateral, uint256 debt) internal pure returns (uint256) {\n return debt > 0 ? collateral * _NICR_PRECISION / debt : type(uint256).max;\n }\n\n /// @notice Computes the Collateral Ratio for given collateral, debt and price. If debt is zero, it returns the\n /// maximal value for uint256 (represents \"infinite\" CR).\n /// @param collateral Collateral amount.\n /// @param debt Debt amount.\n /// @param price Collateral price.\n /// @return Collateral ratio.\n function _computeCR(uint256 collateral, uint256 debt, uint256 price) internal pure returns (uint256) {\n return debt > 0 ? collateral * price / debt : type(uint256).max;\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n // decrementing then incrementing.\n _balances[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n unchecked {\n // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n _balances[account] += amount;\n }\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n // Overflow not possible: amount <= accountBalance <= totalSupply.\n _totalSupply -= amount;\n }\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\n\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() external {\n address sender = _msgSender();\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n _transferOwnership(sender);\n }\n}\n\n/**\n * @dev Extension of {ERC20} that adds a cap to the supply of tokens.\n */\nabstract contract ERC20Capped is ERC20, Ownable2Step {\n uint256 public cap;\n\n /**\n * @dev Total supply cap has been exceeded.\n */\n error ERC20ExceededCap();\n\n /**\n * @dev The supplied cap is not a valid cap.\n */\n error ERC20InvalidCap(uint256 cap);\n\n constructor(uint256 cap_) {\n setCap(cap_);\n }\n\n /**\n * @dev Sets the value of the `cap`.\n */\n function setCap(uint256 cap_) public onlyOwner {\n if (cap_ == 0) {\n revert ERC20InvalidCap(0);\n }\n cap = cap_;\n }\n\n /**\n * @dev See {ERC20-_mint}.\n */\n function _mint(address account, uint256 amount) internal virtual override {\n if (totalSupply() + amount > cap) {\n revert ERC20ExceededCap();\n }\n super._mint(account, amount);\n }\n}\n\nabstract contract PositionManagerDependent is IPositionManagerDependent {\n // --- Immutable variables ---\n\n address public immutable override positionManager;\n\n // --- Modifiers ---\n\n modifier onlyPositionManager() {\n if (msg.sender != positionManager) {\n revert CallerIsNotPositionManager(msg.sender);\n }\n _;\n }\n\n // --- Constructor ---\n\n constructor(address positionManager_) {\n if (positionManager_ == address(0)) {\n revert PositionManagerCannotBeZero();\n }\n positionManager = positionManager_;\n }\n}\n\ncontract ERC20Indexable is IERC20Indexable, ERC20Capped, PositionManagerDependent {\n // --- Types ---\n\n using Fixed256x18 for uint256;\n\n // --- Constants ---\n\n uint256 public constant override INDEX_PRECISION = Fixed256x18.ONE;\n\n // --- Variables ---\n\n uint256 internal storedIndex;\n\n // --- Constructor ---\n\n constructor(\n address positionManager_,\n string memory name_,\n string memory symbol_,\n uint256 cap_\n )\n ERC20(name_, symbol_)\n ERC20Capped(cap_)\n PositionManagerDependent(positionManager_)\n {\n storedIndex = INDEX_PRECISION;\n emit ERC20IndexableDeployed(positionManager_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) public virtual override onlyPositionManager {\n _mint(to, amount.divUp(storedIndex));\n }\n\n function burn(address from, uint256 amount) public virtual override onlyPositionManager {\n _burn(from, amount == type(uint256).max ? ERC20.balanceOf(from) : amount.divUp(storedIndex));\n }\n\n function setIndex(uint256 backingAmount) external override onlyPositionManager {\n uint256 supply = ERC20.totalSupply();\n uint256 newIndex = (backingAmount == 0 && supply == 0) ? INDEX_PRECISION : backingAmount.divUp(supply);\n storedIndex = newIndex;\n emit IndexUpdated(newIndex);\n }\n\n function currentIndex() public view virtual override returns (uint256) {\n return storedIndex;\n }\n\n function totalSupply() public view virtual override(IERC20, ERC20) returns (uint256) {\n return ERC20.totalSupply().mulDown(currentIndex());\n }\n\n function balanceOf(address account) public view virtual override(IERC20, ERC20) returns (uint256) {\n return ERC20.balanceOf(account).mulDown(currentIndex());\n }\n\n function transfer(address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function allowance(address, address) public view virtual override(IERC20, ERC20) returns (uint256) {\n revert NotSupported();\n }\n\n function approve(address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function transferFrom(address, address, uint256) public virtual override(IERC20, ERC20) returns (bool) {\n revert NotSupported();\n }\n\n function increaseAllowance(address, uint256) public virtual override returns (bool) {\n revert NotSupported();\n }\n\n function decreaseAllowance(address, uint256) public virtual override returns (bool) {\n revert NotSupported();\n }\n}\n\nabstract contract FeeCollector is Ownable2Step, IFeeCollector {\n // --- Variables ---\n\n address public override feeRecipient;\n\n // --- Constructor ---\n\n /// @param feeRecipient_ Address of the fee recipient to initialize contract with.\n constructor(address feeRecipient_) {\n if (feeRecipient_ == address(0)) {\n revert InvalidFeeRecipient();\n }\n\n feeRecipient = feeRecipient_;\n }\n\n // --- Functions ---\n\n function setFeeRecipient(address newFeeRecipient) external onlyOwner {\n if (newFeeRecipient == address(0)) {\n revert InvalidFeeRecipient();\n }\n\n feeRecipient = newFeeRecipient;\n emit FeeRecipientChanged(newFeeRecipient);\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/ERC20FlashMint.sol)\n\n/**\n * @dev Implementation of the ERC3156 Flash loans extension, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * Adds the {flashLoan} method, which provides flash loan support at the token\n * level. By default there is no fee, but this can be changed by overriding {flashFee}.\n *\n * _Available since v4.1._\n */\nabstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {\n bytes32 private constant _RETURN_VALUE = keccak256(\"ERC3156FlashBorrower.onFlashLoan\");\n\n /**\n * @dev Returns the maximum amount of tokens available for loan.\n * @param token The address of the token that is requested.\n * @return The amount of token that can be loaned.\n */\n function maxFlashLoan(address token) public view virtual override returns (uint256) {\n return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;\n }\n\n /**\n * @dev Returns the fee applied when doing flash loans. This function calls\n * the {_flashFee} function which returns the fee applied when doing flash\n * loans.\n * @param token The token to be flash loaned.\n * @param amount The amount of tokens to be loaned.\n * @return The fees applied to the corresponding flash loan.\n */\n function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {\n require(token == address(this), \"ERC20FlashMint: wrong token\");\n return _flashFee(token, amount);\n }\n\n /**\n * @dev Returns the fee applied when doing flash loans. By default this\n * implementation has 0 fees. This function can be overloaded to make\n * the flash loan mechanism deflationary.\n * @param token The token to be flash loaned.\n * @param amount The amount of tokens to be loaned.\n * @return The fees applied to the corresponding flash loan.\n */\n function _flashFee(address token, uint256 amount) internal view virtual returns (uint256) {\n // silence warning about unused variable without the addition of bytecode.\n token;\n amount;\n return 0;\n }\n\n /**\n * @dev Returns the receiver address of the flash fee. By default this\n * implementation returns the address(0) which means the fee amount will be burnt.\n * This function can be overloaded to change the fee receiver.\n * @return The address for which the flash fee will be sent to.\n */\n function _flashFeeReceiver() internal view virtual returns (address) {\n return address(0);\n }\n\n /**\n * @dev Performs a flash loan. New tokens are minted and sent to the\n * `receiver`, who is required to implement the {IERC3156FlashBorrower}\n * interface. By the end of the flash loan, the receiver is expected to own\n * amount + fee tokens and have them approved back to the token contract itself so\n * they can be burned.\n * @param receiver The receiver of the flash loan. Should implement the\n * {IERC3156FlashBorrower-onFlashLoan} interface.\n * @param token The token to be flash loaned. Only `address(this)` is\n * supported.\n * @param amount The amount of tokens to be loaned.\n * @param data An arbitrary datafield that is passed to the receiver.\n * @return `true` if the flash loan was successful.\n */\n // This function can reenter, but it doesn't pose a risk because it always preserves the property that the amount\n // minted at the beginning is always recovered and burned at the end, or else the entire function will revert.\n // slither-disable-next-line reentrancy-no-eth\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n ) public virtual override returns (bool) {\n require(amount <= maxFlashLoan(token), \"ERC20FlashMint: amount exceeds maxFlashLoan\");\n uint256 fee = flashFee(token, amount);\n _mint(address(receiver), amount);\n require(\n receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,\n \"ERC20FlashMint: invalid return value\"\n );\n address flashFeeReceiver = _flashFeeReceiver();\n _spendAllowance(address(receiver), address(this), amount + fee);\n if (fee == 0 || flashFeeReceiver == address(0)) {\n _burn(address(receiver), amount + fee);\n } else {\n _burn(address(receiver), amount);\n _transfer(address(receiver), flashFeeReceiver, fee);\n }\n return true;\n }\n}\n\ncontract RToken is ReentrancyGuard, ERC20Permit, ERC20FlashMint, PositionManagerDependent, FeeCollector, IRToken {\n // --- Constants ---\n\n uint256 public constant override PERCENTAGE_BASE = 10_000;\n uint256 public constant override MAX_FLASH_MINT_FEE_PERCENTAGE = 500;\n\n // --- Variables ---\n\n uint256 public override flashMintFeePercentage;\n\n // --- Constructor ---\n\n /// @dev Deploys new R token. Sets flash mint fee percentage to 0. Transfers ownership to @param feeRecipient_.\n /// @param positionManager_ Address of the PositionManager contract that is authorized to mint and burn new tokens.\n /// @param feeRecipient_ Address of flash mint fee recipient.\n constructor(\n address positionManager_,\n address feeRecipient_\n )\n ERC20Permit(\"R Stablecoin\")\n ERC20(\"R Stablecoin\", \"R\")\n PositionManagerDependent(positionManager_)\n FeeCollector(feeRecipient_)\n {\n setFlashMintFeePercentage(PERCENTAGE_BASE / 200); // 0.5%\n\n transferOwnership(feeRecipient_);\n\n emit RDeployed(positionManager_, feeRecipient_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) external override onlyPositionManager {\n _mint(to, amount);\n }\n\n function burn(address from, uint256 amount) external override onlyPositionManager {\n _burn(from, amount);\n }\n\n function setFlashMintFeePercentage(uint256 feePercentage) public override onlyOwner {\n if (feePercentage > MAX_FLASH_MINT_FEE_PERCENTAGE) {\n revert FlashFeePercentageTooBig(feePercentage);\n }\n\n flashMintFeePercentage = feePercentage;\n emit FlashMintFeePercentageChanged(flashMintFeePercentage);\n }\n\n function flashLoan(\n IERC3156FlashBorrower receiver,\n address token,\n uint256 amount,\n bytes calldata data\n )\n public\n override(ERC20FlashMint, IERC3156FlashLender)\n nonReentrant\n returns (bool)\n {\n return super.flashLoan(receiver, token, amount, data);\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines maximum size of the flash mint.\n /// @param token Token to be flash minted. Returns 0 amount in case of token != address(this).\n function maxFlashLoan(address token)\n public\n view\n virtual\n override(ERC20FlashMint, IERC3156FlashLender)\n returns (uint256)\n {\n return token == address(this) ? Math.min(totalSupply() / 10, ERC20FlashMint.maxFlashLoan(address(this))) : 0;\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines flash mint fee for the flash mint of @param amount tokens.\n /// @param token Token to be flash minted. Returns 0 fee in case of token != address(this).\n /// @param amount Size of the flash mint.\n function _flashFee(address token, uint256 amount) internal view virtual override returns (uint256) {\n return token == address(this) ? amount * flashMintFeePercentage / PERCENTAGE_BASE : 0;\n }\n\n /// @dev Inherited from ERC20FlashMint. Defines flash mint fee receiver.\n /// @return Address that will receive flash mint fees.\n function _flashFeeReceiver() internal view virtual override returns (address) {\n return feeRecipient;\n }\n}\n\n/// @dev Implementation of Position Manager. Current implementation does not support rebasing tokens as collateral.\ncontract PositionManager is FeeCollector, IPositionManager {\n // --- Types ---\n\n using SafeERC20 for IERC20;\n using Fixed256x18 for uint256;\n\n // --- Constants ---\n\n uint256 public constant override MINUTE_DECAY_FACTOR = 999_037_758_833_783_000;\n\n uint256 public constant override MAX_BORROWING_SPREAD = MathUtils._100_PERCENT / 100; // 1%\n uint256 public constant override MAX_BORROWING_RATE = MathUtils._100_PERCENT / 100 * 5; // 5%\n\n uint256 public constant override BETA = 2;\n\n // --- Immutables ---\n\n IRToken public immutable override rToken;\n\n // --- Variables ---\n\n mapping(address position => IERC20 collateralToken) public override collateralTokenForPosition;\n\n mapping(address position => mapping(address delegate => bool isWhitelisted)) public override isDelegateWhitelisted;\n\n mapping(IERC20 collateralToken => CollateralTokenInfo collateralTokenInfo) public override collateralInfo;\n\n // --- Modifiers ---\n\n /// @dev Checks if the collateral token has been added to the position manager, or reverts otherwise.\n /// @param collateralToken The collateral token to check.\n modifier collateralTokenExists(IERC20 collateralToken) {\n if (address(collateralInfo[collateralToken].collateralToken) == address(0)) {\n revert CollateralTokenNotAdded();\n }\n _;\n }\n\n /// @dev Checks if the collateral token has enabled, or reverts otherwise. When the condition is false, the check\n /// is skipped.\n /// @param collateralToken The collateral token to check.\n /// @param condition If true, the check will be performed.\n modifier onlyEnabledCollateralTokenWhen(IERC20 collateralToken, bool condition) {\n if (condition && !collateralInfo[collateralToken].isEnabled) {\n revert CollateralTokenDisabled();\n }\n _;\n }\n\n /// @dev Checks if the borrower has a position with the collateral token or doesn't have a position at all, or\n /// reverts otherwise.\n /// @param position The borrower to check.\n /// @param collateralToken The collateral token to check.\n modifier onlyDepositedCollateralTokenOrNew(address position, IERC20 collateralToken) {\n if (\n collateralTokenForPosition[position] != IERC20(address(0))\n && collateralTokenForPosition[position] != collateralToken\n ) {\n revert PositionCollateralTokenMismatch();\n }\n _;\n }\n\n /// @dev Checks if the max fee percentage is between the borrowing spread and 100%, or reverts otherwise. When the\n /// condition is false, the check is skipped.\n /// @param maxFeePercentage The max fee percentage to check.\n /// @param condition If true, the check will be performed.\n modifier validMaxFeePercentageWhen(uint256 maxFeePercentage, bool condition) {\n if (condition && maxFeePercentage > MathUtils._100_PERCENT) {\n revert InvalidMaxFeePercentage();\n }\n _;\n }\n\n // --- Constructor ---\n\n /// @dev Initializes the position manager.\n constructor(address rToken_) FeeCollector(msg.sender) {\n rToken = rToken_ == address(0) ? new RToken(address(this), msg.sender) : IRToken(rToken_);\n emit PositionManagerDeployed(rToken, msg.sender);\n }\n\n // --- External functions ---\n\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n public\n virtual\n override\n collateralTokenExists(collateralToken)\n validMaxFeePercentageWhen(maxFeePercentage, isDebtIncrease)\n onlyDepositedCollateralTokenOrNew(position, collateralToken)\n onlyEnabledCollateralTokenWhen(collateralToken, isDebtIncrease && debtChange > 0)\n returns (uint256 actualCollateralChange, uint256 actualDebtChange)\n {\n if (position != msg.sender && !isDelegateWhitelisted[position][msg.sender]) {\n revert DelegateNotWhitelisted();\n }\n if (collateralChange == 0 && debtChange == 0) {\n revert NoCollateralOrDebtChange();\n }\n if (address(permitSignature.token) == address(collateralToken)) {\n PermitHelper.applyPermit(permitSignature, msg.sender, address(this));\n }\n\n CollateralTokenInfo storage collateralTokenInfo = collateralInfo[collateralToken];\n IERC20Indexable raftCollateralToken = collateralTokenInfo.collateralToken;\n IERC20Indexable raftDebtToken = collateralTokenInfo.debtToken;\n\n uint256 debtBefore = raftDebtToken.balanceOf(position);\n if (!isDebtIncrease && (debtChange == type(uint256).max || (debtBefore != 0 && debtChange == debtBefore))) {\n if (collateralChange != 0 || isCollateralIncrease) {\n revert WrongCollateralParamsForFullRepayment();\n }\n collateralChange = raftCollateralToken.balanceOf(position);\n debtChange = debtBefore;\n }\n\n _adjustDebt(position, collateralToken, raftDebtToken, debtChange, isDebtIncrease, maxFeePercentage);\n _adjustCollateral(collateralToken, raftCollateralToken, position, collateralChange, isCollateralIncrease);\n\n uint256 positionDebt = raftDebtToken.balanceOf(position);\n uint256 positionCollateral = raftCollateralToken.balanceOf(position);\n\n if (positionDebt == 0) {\n if (positionCollateral != 0) {\n revert InvalidPosition();\n }\n // position was closed, remove it\n _closePosition(raftCollateralToken, raftDebtToken, position, false);\n } else {\n _checkValidPosition(collateralToken, positionDebt, positionCollateral);\n\n if (debtBefore == 0) {\n collateralTokenForPosition[position] = collateralToken;\n emit PositionCreated(position, collateralToken);\n }\n }\n return (collateralChange, debtChange);\n }\n\n function liquidate(address position) external override {\n IERC20 collateralToken = collateralTokenForPosition[position];\n CollateralTokenInfo storage collateralTokenInfo = collateralInfo[collateralToken];\n IERC20Indexable raftCollateralToken = collateralTokenInfo.collateralToken;\n IERC20Indexable raftDebtToken = collateralTokenInfo.debtToken;\n ISplitLiquidationCollateral splitLiquidation = collateralTokenInfo.splitLiquidation;\n\n if (address(collateralToken) == address(0)) {\n revert NothingToLiquidate();\n }\n (uint256 price,) = collateralTokenInfo.priceFeed.fetchPrice();\n uint256 entireCollateral = raftCollateralToken.balanceOf(position);\n uint256 entireDebt = raftDebtToken.balanceOf(position);\n uint256 icr = MathUtils._computeCR(entireCollateral, entireDebt, price);\n\n if (icr >= splitLiquidation.MCR()) {\n revert NothingToLiquidate();\n }\n\n uint256 totalDebt = raftDebtToken.totalSupply();\n if (entireDebt == totalDebt) {\n revert CannotLiquidateLastPosition();\n }\n bool isRedistribution = icr <= MathUtils._100_PERCENT;\n\n // prettier: ignore\n (uint256 collateralLiquidationFee, uint256 collateralToSendToLiquidator) =\n splitLiquidation.split(entireCollateral, entireDebt, price, isRedistribution);\n\n if (!isRedistribution) {\n _burnRTokens(msg.sender, entireDebt);\n totalDebt -= entireDebt;\n\n // Collateral is sent to protocol as a fee only in case of liquidation\n collateralToken.safeTransfer(feeRecipient, collateralLiquidationFee);\n }\n\n collateralToken.safeTransfer(msg.sender, collateralToSendToLiquidator);\n\n _closePosition(raftCollateralToken, raftDebtToken, position, true);\n\n _updateDebtAndCollateralIndex(collateralToken, raftCollateralToken, raftDebtToken, totalDebt);\n\n emit Liquidation(\n msg.sender,\n position,\n collateralToken,\n entireDebt,\n entireCollateral,\n collateralToSendToLiquidator,\n collateralLiquidationFee,\n isRedistribution\n );\n }\n\n function redeemCollateral(\n IERC20 collateralToken,\n uint256 debtAmount,\n uint256 maxFeePercentage\n )\n public\n virtual\n override\n {\n if (maxFeePercentage > MathUtils._100_PERCENT) {\n revert MaxFeePercentageOutOfRange();\n }\n if (debtAmount == 0) {\n revert AmountIsZero();\n }\n IERC20Indexable raftDebtToken = collateralInfo[collateralToken].debtToken;\n\n uint256 newTotalDebt = raftDebtToken.totalSupply() - debtAmount;\n uint256 lowTotalDebt = collateralInfo[collateralToken].splitLiquidation.LOW_TOTAL_DEBT();\n if (newTotalDebt < lowTotalDebt) {\n revert TotalDebtCannotBeLowerThanMinDebt(collateralToken, newTotalDebt);\n }\n\n (uint256 price, uint256 deviation) = collateralInfo[collateralToken].priceFeed.fetchPrice();\n uint256 collateralToRedeem = debtAmount.divDown(price);\n uint256 totalCollateral = collateralToken.balanceOf(address(this));\n if (\n totalCollateral - collateralToRedeem == 0\n || totalCollateral - collateralToRedeem < lowTotalDebt.divDown(price)\n ) {\n revert TotalCollateralCannotBeLowerThanMinCollateral(\n collateralToken, totalCollateral - collateralToRedeem, lowTotalDebt.divDown(price)\n );\n }\n\n // Decay the baseRate due to time passed, and then increase it according to the size of this redemption.\n // Use the saved total R supply value, from before it was reduced by the redemption.\n _updateBaseRateFromRedemption(collateralToken, collateralToRedeem, price, rToken.totalSupply());\n\n // Calculate the redemption fee\n uint256 redemptionFee = getRedemptionFee(collateralToken, collateralToRedeem, deviation);\n uint256 rebate = redemptionFee.mulDown(collateralInfo[collateralToken].redemptionRebate);\n\n _checkValidFee(redemptionFee, collateralToRedeem, maxFeePercentage);\n\n // Send the redemption fee to the recipient\n collateralToken.safeTransfer(feeRecipient, redemptionFee - rebate);\n\n // Burn the total R that is cancelled with debt, and send the redeemed collateral to msg.sender\n _burnRTokens(msg.sender, debtAmount);\n\n // Send collateral to account\n collateralToken.safeTransfer(msg.sender, collateralToRedeem - redemptionFee);\n\n _updateDebtAndCollateralIndex(\n collateralToken, collateralInfo[collateralToken].collateralToken, raftDebtToken, newTotalDebt\n );\n\n emit Redemption(msg.sender, debtAmount, collateralToRedeem, redemptionFee, rebate);\n }\n\n function whitelistDelegate(address delegate, bool whitelisted) external override {\n if (delegate == address(0)) {\n revert InvalidDelegateAddress();\n }\n isDelegateWhitelisted[msg.sender][delegate] = whitelisted;\n\n emit DelegateWhitelisted(msg.sender, delegate, whitelisted);\n }\n\n function setBorrowingSpread(IERC20 collateralToken, uint256 newBorrowingSpread) external override onlyOwner {\n if (newBorrowingSpread > MAX_BORROWING_SPREAD) {\n revert BorrowingSpreadExceedsMaximum();\n }\n collateralInfo[collateralToken].borrowingSpread = newBorrowingSpread;\n emit BorrowingSpreadUpdated(newBorrowingSpread);\n }\n\n function setRedemptionRebate(IERC20 collateralToken, uint256 newRedemptionRebate) public override onlyOwner {\n if (newRedemptionRebate > MathUtils._100_PERCENT) {\n revert RedemptionRebateExceedsMaximum();\n }\n collateralInfo[collateralToken].redemptionRebate = newRedemptionRebate;\n emit RedemptionRebateUpdated(newRedemptionRebate);\n }\n\n function getRedemptionFeeWithDecay(\n IERC20 collateralToken,\n uint256 collateralAmount\n )\n external\n view\n override\n returns (uint256 redemptionFee)\n {\n redemptionFee = getRedemptionRateWithDecay(collateralToken).mulDown(collateralAmount);\n if (redemptionFee >= collateralAmount) {\n revert FeeEatsUpAllReturnedCollateral();\n }\n }\n\n // --- Public functions ---\n\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n public\n virtual\n override\n {\n addCollateralToken(\n collateralToken,\n priceFeed,\n newSplitLiquidationCollateral,\n new ERC20Indexable(\n address(this),\n string(bytes.concat(\"Raft \", bytes(IERC20Metadata(address(collateralToken)).name()), \" collateral\")),\n string(bytes.concat(\"r\", bytes(IERC20Metadata(address(collateralToken)).symbol()), \"-c\")),\n type(uint256).max\n ),\n new ERC20Indexable(\n address(this),\n string(bytes.concat(\"Raft \", bytes(IERC20Metadata(address(collateralToken)).name()), \" debt\")),\n string(bytes.concat(\"r\", bytes(IERC20Metadata(address(collateralToken)).symbol()), \"-d\")),\n type(uint256).max\n )\n );\n }\n\n function addCollateralToken(\n IERC20 collateralToken,\n IPriceFeed priceFeed,\n ISplitLiquidationCollateral newSplitLiquidationCollateral,\n IERC20Indexable raftCollateralToken_,\n IERC20Indexable raftDebtToken_\n )\n public\n override\n onlyOwner\n {\n if (address(collateralToken) == address(0)) {\n revert CollateralTokenAddressCannotBeZero();\n }\n if (address(priceFeed) == address(0)) {\n revert PriceFeedAddressCannotBeZero();\n }\n if (address(collateralInfo[collateralToken].collateralToken) != address(0)) {\n revert CollateralTokenAlreadyAdded();\n }\n\n CollateralTokenInfo memory raftCollateralTokenInfo;\n raftCollateralTokenInfo.collateralToken = raftCollateralToken_;\n raftCollateralTokenInfo.debtToken = raftDebtToken_;\n raftCollateralTokenInfo.isEnabled = true;\n raftCollateralTokenInfo.priceFeed = priceFeed;\n\n collateralInfo[collateralToken] = raftCollateralTokenInfo;\n\n setRedemptionSpread(collateralToken, MathUtils._100_PERCENT);\n setRedemptionRebate(collateralToken, MathUtils._100_PERCENT);\n\n setSplitLiquidationCollateral(collateralToken, newSplitLiquidationCollateral);\n\n emit CollateralTokenAdded(\n collateralToken, raftCollateralTokenInfo.collateralToken, raftCollateralTokenInfo.debtToken, priceFeed\n );\n }\n\n function setCollateralEnabled(\n IERC20 collateralToken,\n bool isEnabled\n )\n public\n override\n onlyOwner\n collateralTokenExists(collateralToken)\n {\n bool previousIsEnabled = collateralInfo[collateralToken].isEnabled;\n collateralInfo[collateralToken].isEnabled = isEnabled;\n\n if (previousIsEnabled != isEnabled) {\n emit CollateralTokenModified(collateralToken, isEnabled);\n }\n }\n\n function setSplitLiquidationCollateral(\n IERC20 collateralToken,\n ISplitLiquidationCollateral newSplitLiquidationCollateral\n )\n public\n override\n onlyOwner\n {\n if (address(newSplitLiquidationCollateral) == address(0)) {\n revert SplitLiquidationCollateralCannotBeZero();\n }\n collateralInfo[collateralToken].splitLiquidation = newSplitLiquidationCollateral;\n emit SplitLiquidationCollateralChanged(collateralToken, newSplitLiquidationCollateral);\n }\n\n function setRedemptionSpread(IERC20 collateralToken, uint256 newRedemptionSpread) public override onlyOwner {\n if (newRedemptionSpread > MathUtils._100_PERCENT) {\n revert RedemptionSpreadOutOfRange();\n }\n collateralInfo[collateralToken].redemptionSpread = newRedemptionSpread;\n emit RedemptionSpreadUpdated(collateralToken, newRedemptionSpread);\n }\n\n function getRedemptionRateWithDecay(IERC20 collateralToken) public view override returns (uint256) {\n return _calcRedemptionRate(collateralToken, _calcDecayedBaseRate(collateralToken));\n }\n\n function raftCollateralToken(IERC20 collateralToken) external view override returns (IERC20Indexable) {\n return collateralInfo[collateralToken].collateralToken;\n }\n\n function raftDebtToken(IERC20 collateralToken) external view override returns (IERC20Indexable) {\n return collateralInfo[collateralToken].debtToken;\n }\n\n function priceFeed(IERC20 collateralToken) external view override returns (IPriceFeed) {\n return collateralInfo[collateralToken].priceFeed;\n }\n\n function splitLiquidationCollateral(IERC20 collateralToken) external view returns (ISplitLiquidationCollateral) {\n return collateralInfo[collateralToken].splitLiquidation;\n }\n\n function collateralEnabled(IERC20 collateralToken) external view override returns (bool) {\n return collateralInfo[collateralToken].isEnabled;\n }\n\n function lastFeeOperationTime(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].lastFeeOperationTime;\n }\n\n function borrowingSpread(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].borrowingSpread;\n }\n\n function baseRate(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].baseRate;\n }\n\n function redemptionSpread(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].redemptionSpread;\n }\n\n function redemptionRebate(IERC20 collateralToken) external view override returns (uint256) {\n return collateralInfo[collateralToken].redemptionRebate;\n }\n\n function getRedemptionRate(IERC20 collateralToken) public view override returns (uint256) {\n return _calcRedemptionRate(collateralToken, collateralInfo[collateralToken].baseRate);\n }\n\n function getRedemptionFee(\n IERC20 collateralToken,\n uint256 collateralAmount,\n uint256 priceDeviation\n )\n public\n view\n override\n returns (uint256)\n {\n return Math.min(getRedemptionRate(collateralToken) + priceDeviation, MathUtils._100_PERCENT).mulDown(\n collateralAmount\n );\n }\n\n function getBorrowingRate(IERC20 collateralToken) public view override returns (uint256) {\n return _calcBorrowingRate(collateralToken, collateralInfo[collateralToken].baseRate);\n }\n\n function getBorrowingRateWithDecay(IERC20 collateralToken) public view override returns (uint256) {\n return _calcBorrowingRate(collateralToken, _calcDecayedBaseRate(collateralToken));\n }\n\n function getBorrowingFee(IERC20 collateralToken, uint256 debtAmount) public view override returns (uint256) {\n return getBorrowingRate(collateralToken).mulDown(debtAmount);\n }\n\n // --- Helper functions ---\n\n /// @dev Adjusts the debt of a given borrower by burning or minting the corresponding amount of R and the Raft\n /// debt token. If the debt is being increased, the borrowing fee is also triggered.\n /// @param position The address of the borrower.\n /// @param debtChange The amount of R to add or remove. Must be positive.\n /// @param isDebtIncrease True if the debt is being increased, false otherwise.\n /// @param maxFeePercentage The maximum fee percentage.\n function _adjustDebt(\n address position,\n IERC20 collateralToken,\n IERC20Indexable raftDebtToken,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage\n )\n internal\n {\n if (debtChange == 0) {\n return;\n }\n\n if (isDebtIncrease) {\n uint256 totalDebtChange =\n debtChange + _triggerBorrowingFee(collateralToken, position, debtChange, maxFeePercentage);\n raftDebtToken.mint(position, totalDebtChange);\n _mintRTokens(msg.sender, debtChange);\n } else {\n raftDebtToken.burn(position, debtChange);\n _burnRTokens(msg.sender, debtChange);\n }\n\n emit DebtChanged(position, collateralToken, debtChange, isDebtIncrease);\n }\n\n /// @dev Mints R tokens\n function _mintRTokens(address to, uint256 amount) internal virtual {\n rToken.mint(to, amount);\n }\n\n /// @dev Burns R tokens\n function _burnRTokens(address from, uint256 amount) internal virtual {\n rToken.burn(from, amount);\n }\n\n /// @dev Adjusts the collateral of a given borrower by burning or minting the corresponding amount of Raft\n /// collateral token and transferring the corresponding amount of collateral token.\n /// @param collateralToken The token the borrower used as collateral.\n /// @param position The address of the borrower.\n /// @param collateralChange The amount of collateral to add or remove. Must be positive.\n /// @param isCollateralIncrease True if the collateral is being increased, false otherwise.\n function _adjustCollateral(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease\n )\n internal\n {\n if (collateralChange == 0) {\n return;\n }\n\n if (isCollateralIncrease) {\n raftCollateralToken.mint(position, collateralChange);\n collateralToken.safeTransferFrom(msg.sender, address(this), collateralChange);\n } else {\n raftCollateralToken.burn(position, collateralChange);\n collateralToken.safeTransfer(msg.sender, collateralChange);\n }\n\n emit CollateralChanged(position, collateralToken, collateralChange, isCollateralIncrease);\n }\n\n /// @dev Updates debt and collateral indexes for a given collateral token.\n /// @param collateralToken The collateral token for which to update the indexes.\n /// @param raftCollateralToken The raft collateral indexable token.\n /// @param raftDebtToken The raft debt indexable token.\n /// @param totalDebtForCollateral Totam amount of debt backed by collateral token.\n function _updateDebtAndCollateralIndex(\n IERC20 collateralToken,\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n uint256 totalDebtForCollateral\n )\n internal\n {\n raftDebtToken.setIndex(totalDebtForCollateral);\n raftCollateralToken.setIndex(collateralToken.balanceOf(address(this)));\n }\n\n function _closePosition(\n IERC20Indexable raftCollateralToken,\n IERC20Indexable raftDebtToken,\n address position,\n bool burnTokens\n )\n internal\n {\n collateralTokenForPosition[position] = IERC20(address(0));\n\n if (burnTokens) {\n raftDebtToken.burn(position, type(uint256).max);\n raftCollateralToken.burn(position, type(uint256).max);\n }\n emit PositionClosed(position);\n }\n\n // --- Borrowing & redemption fee helper functions ---\n\n /// @dev Updates the base rate from a redemption operation. Impacts on the base rate:\n /// 1. decays the base rate based on time passed since last redemption or R borrowing operation,\n /// 2. increases the base rate based on the amount redeemed, as a proportion of total supply.\n function _updateBaseRateFromRedemption(\n IERC20 collateralToken,\n uint256 collateralDrawn,\n uint256 price,\n uint256 totalDebtSupply\n )\n internal\n returns (uint256)\n {\n uint256 decayedBaseRate = _calcDecayedBaseRate(collateralToken);\n\n /* Convert the drawn collateral back to R at face value rate (1 R:1 USD), in order to get\n * the fraction of total supply that was redeemed at face value. */\n uint256 redeemedFraction = collateralDrawn * price / totalDebtSupply;\n\n uint256 newBaseRate = decayedBaseRate + redeemedFraction / BETA;\n newBaseRate = Math.min(newBaseRate, MathUtils._100_PERCENT); // cap baseRate at a maximum of 100%\n assert(newBaseRate > 0); // Base rate is always non-zero after redemption\n\n // Update the baseRate state variable\n collateralInfo[collateralToken].baseRate = newBaseRate;\n emit BaseRateUpdated(collateralToken, newBaseRate);\n\n _updateLastFeeOpTime(collateralToken);\n\n return newBaseRate;\n }\n\n function _calcRedemptionRate(IERC20 collateralToken, uint256 baseRate_) internal view returns (uint256) {\n return baseRate_ + collateralInfo[collateralToken].redemptionSpread;\n }\n\n function _calcBorrowingRate(IERC20 collateralToken, uint256 baseRate_) internal view returns (uint256) {\n return Math.min(collateralInfo[collateralToken].borrowingSpread + baseRate_, MAX_BORROWING_RATE);\n }\n\n /// @dev Updates the base rate based on time elapsed since the last redemption or R borrowing operation.\n function _decayBaseRateFromBorrowing(IERC20 collateralToken) internal {\n uint256 decayedBaseRate = _calcDecayedBaseRate(collateralToken);\n assert(decayedBaseRate <= MathUtils._100_PERCENT); // The baseRate can decay to 0\n\n collateralInfo[collateralToken].baseRate = decayedBaseRate;\n emit BaseRateUpdated(collateralToken, decayedBaseRate);\n\n _updateLastFeeOpTime(collateralToken);\n }\n\n /// @dev Update the last fee operation time only if time passed >= decay interval. This prevents base rate\n /// griefing.\n function _updateLastFeeOpTime(IERC20 collateralToken) internal {\n uint256 timePassed = block.timestamp - collateralInfo[collateralToken].lastFeeOperationTime;\n\n if (timePassed >= 1 minutes) {\n collateralInfo[collateralToken].lastFeeOperationTime = block.timestamp;\n emit LastFeeOpTimeUpdated(collateralToken, block.timestamp);\n }\n }\n\n function _calcDecayedBaseRate(IERC20 collateralToken) internal view returns (uint256) {\n uint256 minutesPassed = (block.timestamp - collateralInfo[collateralToken].lastFeeOperationTime) / 1 minutes;\n uint256 decayFactor = MathUtils._decPow(MINUTE_DECAY_FACTOR, minutesPassed);\n\n return collateralInfo[collateralToken].baseRate.mulDown(decayFactor);\n }\n\n function _triggerBorrowingFee(\n IERC20 collateralToken,\n address position,\n uint256 debtAmount,\n uint256 maxFeePercentage\n )\n internal\n virtual\n returns (uint256 borrowingFee)\n {\n _decayBaseRateFromBorrowing(collateralToken); // decay the baseRate state variable\n borrowingFee = getBorrowingFee(collateralToken, debtAmount);\n\n _checkValidFee(borrowingFee, debtAmount, maxFeePercentage);\n\n if (borrowingFee > 0) {\n _mintRTokens(feeRecipient, borrowingFee);\n emit RBorrowingFeePaid(collateralToken, position, borrowingFee);\n }\n }\n\n // --- Validation check helper functions ---\n\n function _checkValidPosition(IERC20 collateralToken, uint256 positionDebt, uint256 positionCollateral) internal {\n ISplitLiquidationCollateral splitCollateral = collateralInfo[collateralToken].splitLiquidation;\n if (positionDebt < splitCollateral.LOW_TOTAL_DEBT()) {\n revert NetDebtBelowMinimum(positionDebt);\n }\n\n (uint256 price,) = collateralInfo[collateralToken].priceFeed.fetchPrice();\n uint256 newICR = MathUtils._computeCR(positionCollateral, positionDebt, price);\n if (newICR < splitCollateral.MCR()) {\n revert NewICRLowerThanMCR(newICR);\n }\n }\n\n function _checkValidFee(uint256 fee, uint256 amount, uint256 maxFeePercentage) internal pure {\n uint256 feePercentage = fee.divDown(amount);\n\n if (feePercentage > maxFeePercentage) {\n revert FeeExceedsMaxFee(fee, amount, maxFeePercentage);\n }\n }\n}\n\ninterface IRMinter {\n /// @dev Emitted when tokens are recovered from the contract.\n /// @param token The address of the token being recovered.\n /// @param to The address receiving the recovered tokens.\n /// @param amount The amount of tokens recovered.\n event TokensRecovered(IERC20 token, address to, uint256 amount);\n\n /// @return Address of the R token.\n function r() external view returns (IRToken);\n\n /// @return Address of the Position manager contract responsible for minting R.\n function positionManager() external view returns (IPositionManager);\n\n /// @dev Recover accidentally sent tokens to the contract\n /// @param token Address of the token contract.\n /// @param to Address of the receiver of the tokens.\n /// @param amount Number of tokens to recover.\n function recoverTokens(IERC20 token, address to, uint256 amount) external;\n}\n\ninterface ILock {\n /// @dev Thrown when contract usage is locked.\n error ContractLocked();\n\n /// @dev Unauthorized call to lock/unlock.\n error Unauthorized();\n\n /// @dev Retrieves if contract is currently locked or not.\n function locked() external view returns (bool);\n\n /// @dev Retrieves address of the locker who can unlock contract.\n function locker() external view returns (address);\n\n /// @dev Unlcoks the usage of the contract.\n function unlock() external;\n\n /// @dev Locks the usage of the contract.\n function lock() external;\n}\n\nabstract contract ERC20RMinter is IRMinter, ERC20, Ownable2Step {\n using SafeERC20 for IERC20;\n\n IRToken public immutable override r;\n IPositionManager public immutable override positionManager;\n\n constructor(IRToken rToken_, string memory name_, string memory symbol_) ERC20(name_, symbol_) {\n r = rToken_;\n positionManager = IPositionManager(rToken_.positionManager());\n\n _approve(address(this), address(positionManager), type(uint256).max);\n }\n\n modifier unlockCall() {\n ILock lockContract = ILock(address(positionManager.priceFeed(IERC20(this))));\n lockContract.unlock();\n _;\n lockContract.lock();\n }\n\n function recoverTokens(IERC20 token, address to, uint256 amount) external override onlyOwner {\n token.safeTransfer(to, amount);\n emit TokensRecovered(token, to, amount);\n }\n\n function _mintR(address to, uint256 amount) internal unlockCall {\n _mint(address(this), amount);\n ERC20PermitSignature memory emptySignature;\n positionManager.managePosition(\n IERC20(address(this)),\n address(this),\n amount,\n true, // collateral increase\n amount,\n true, // debt increase\n 1e18, // 100%\n emptySignature\n );\n r.transfer(to, amount);\n }\n\n function _burnR(address from, uint256 amount) internal unlockCall {\n r.transferFrom(from, address(this), amount);\n ERC20PermitSignature memory emptySignature;\n positionManager.managePosition(\n IERC20(address(this)),\n address(this),\n amount,\n false, // collateral decrease\n amount,\n false, // debt decrease\n 1e18, // 100%\n emptySignature\n );\n _burn(address(this), amount);\n }\n}\n\ncontract InterestRateDebtToken is ERC20Indexable {\n // --- Types ---\n\n using Fixed256x18 for uint256;\n\n // --- Events ---\n\n event IndexIncreasePerSecondSet(uint256 indexIncreasePerSecond);\n\n // --- Immutables ---\n\n IERC20 immutable collateralToken;\n\n // --- Variables ---\n\n uint256 internal storedIndexUpdatedAt;\n\n uint256 public indexIncreasePerSecond;\n\n // --- Constructor ---\n\n constructor(\n address positionManager_,\n string memory name_,\n string memory symbol_,\n IERC20 collateralToken_,\n uint256 cap_,\n uint256 indexIncreasePerSecond_\n )\n ERC20Indexable(positionManager_, name_, symbol_, cap_)\n {\n storedIndexUpdatedAt = block.timestamp;\n collateralToken = collateralToken_;\n setIndexIncreasePerSecond(indexIncreasePerSecond_);\n }\n\n // --- Functions ---\n\n function mint(address to, uint256 amount) public virtual override {\n updateIndexAndPayFees();\n super.mint(to, amount);\n }\n\n function burn(address from, uint256 amount) public virtual override {\n updateIndexAndPayFees();\n super.burn(from, amount);\n }\n\n function currentIndex() public view virtual override returns (uint256) {\n return storedIndex.mulUp(INDEX_PRECISION + indexIncreasePerSecond * (block.timestamp - storedIndexUpdatedAt));\n }\n\n function updateIndexAndPayFees() public {\n uint256 currentIndex_ = currentIndex();\n _payFees(currentIndex_);\n storedIndexUpdatedAt = block.timestamp;\n storedIndex = currentIndex_;\n emit IndexUpdated(currentIndex_);\n }\n\n function setIndexIncreasePerSecond(uint256 indexIncreasePerSecond_) public onlyOwner {\n updateIndexAndPayFees();\n indexIncreasePerSecond = indexIncreasePerSecond_;\n emit IndexIncreasePerSecondSet(indexIncreasePerSecond_);\n }\n\n function unpaidFees() external view returns (uint256) {\n return _unpaidFees(currentIndex());\n }\n\n function _unpaidFees(uint256 currentIndex_) private view returns (uint256) {\n return totalSupply().mulDown(currentIndex_ - storedIndex);\n }\n\n function _payFees(uint256 currentIndex_) private {\n uint256 unpaidFees = _unpaidFees(currentIndex_);\n if (unpaidFees > 0) {\n IInterestRatePositionManager(positionManager).mintFees(collateralToken, unpaidFees);\n }\n }\n}\n\n/// @dev Implementation of Position Manager. Current implementation does not support rebasing tokens as collateral.\ncontract InterestRatePositionManager is ERC20RMinter, PositionManager, IInterestRatePositionManager {\n // --- Errors ---\n\n error Unsupported();\n\n // --- Constructor ---\n\n /// @dev Initializes the position manager.\n constructor(IRToken rToken_)\n PositionManager(address(rToken_))\n ERC20RMinter(rToken_, \"Interest Rate Posman\", \"IRPM\")\n { }\n\n // --- External functions ---\n\n function managePosition(\n IERC20 collateralToken,\n address position,\n uint256 collateralChange,\n bool isCollateralIncrease,\n uint256 debtChange,\n bool isDebtIncrease,\n uint256 maxFeePercentage,\n ERC20PermitSignature calldata permitSignature\n )\n public\n virtual\n override(IPositionManager, PositionManager)\n returns (uint256 actualCollateralChange, uint256 actualDebtChange)\n {\n if (address(permitSignature.token) == address(r)) {\n PermitHelper.applyPermit(permitSignature, msg.sender, address(this));\n }\n return super.managePosition(\n collateralToken,\n position,\n collateralChange,\n isCollateralIncrease,\n debtChange,\n isDebtIncrease,\n maxFeePercentage,\n permitSignature\n );\n }\n\n function mintFees(IERC20 collateralToken, uint256 amount) external {\n if (msg.sender != address(collateralInfo[collateralToken].debtToken)) {\n revert InvalidDebtToken(msg.sender);\n }\n _mintR(feeRecipient, amount);\n\n emit MintedFees(collateralToken, amount);\n }\n\n function redeemCollateral(IERC20, uint256, uint256) public virtual override(IPositionManager, PositionManager) {\n revert Unsupported();\n }\n\n function addCollateralToken(\n IERC20,\n IPriceFeed,\n ISplitLiquidationCollateral\n )\n public\n override(IPositionManager, PositionManager)\n {\n revert Unsupported();\n }\n\n // --- Helper functions ---\n\n function _mintRTokens(address to, uint256 amount) internal virtual override {\n _mintR(to, amount);\n }\n\n function _burnRTokens(address from, uint256 amount) internal virtual override {\n _burnR(from, amount);\n }\n\n function _triggerBorrowingFee(\n IERC20,\n address,\n uint256,\n uint256\n )\n internal\n pure\n virtual\n override\n returns (uint256)\n {\n return 0;\n }\n}\n"}},"settings":{"remappings":["@balancer-labs/=node_modules/@balancer-labs/","@balancer-labs/v2-interfaces/contracts/=lib/balancer-v2-monorepo/pkg/interfaces/contracts/","@chainlink/=node_modules/@chainlink/","@eth-optimism/=node_modules/@eth-optimism/","@openzeppelin/=node_modules/@openzeppelin/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","@redstone-finance/=node_modules/@redstone-finance/","@smartcontractkit/chainlink/=lib/chainlink/contracts/src/v0.8/","@tempusfinance/=node_modules/@tempusfinance/","@tempusfinance/tempus-utils/contracts/=lib/tempus-utils/contracts/","balancer-v2-monorepo/=lib/balancer-v2-monorepo/","chainlink/=lib/chainlink/","ds-test/=lib/forge-std/lib/ds-test/src/","erc4626-tests/=lib/chainlink/contracts/foundry-lib/openzeppelin-contracts/lib/erc4626-tests/","eth-gas-reporter/=node_modules/eth-gas-reporter/","forge-std/=lib/forge-std/src/","hardhat/=node_modules/hardhat/","openzeppelin-contracts/=lib/openzeppelin-contracts/","tempus-utils/=lib/tempus-utils/contracts/"],"optimizer":{"enabled":true,"runs":200000},"metadata":{"bytecodeHash":"ipfs","appendCBOR":true},"outputSelection":{"*":{"*":["evm.bytecode","evm.deployedBytecode","devdoc","userdoc","metadata","abi"]}},"evmVersion":"london","viaIR":true,"libraries":{}}},"ABI":"[{\"inputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"rToken_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AmountIsZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BorrowingSpreadExceedsMaximum\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CannotLiquidateLastPosition\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenDisabled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CollateralTokenNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DelegateNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FeeEatsUpAllReturnedCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePercentage\",\"type\":\"uint256\"}],\"name\":\"FeeExceedsMaxFee\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"InvalidDebtToken\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidDelegateAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidFeeRecipient\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidMaxFeePercentage\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidPosition\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MaxFeePercentageOutOfRange\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"netDebt\",\"type\":\"uint256\"}],\"name\":\"NetDebtBelowMinimum\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newICR\",\"type\":\"uint256\"}],\"name\":\"NewICRLowerThanMCR\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NoCollateralOrDebtChange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NothingToLiquidate\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PositionCollateralTokenMismatch\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"PriceFeedAddressCannotBeZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RedemptionRebateExceedsMaximum\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RedemptionSpreadOutOfRange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SplitLiquidationCollateralCannotBeZero\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newTotalCollateral\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minimumCollateral\",\"type\":\"uint256\"}],\"name\":\"TotalCollateralCannotBeLowerThanMinCollateral\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newTotalDebt\",\"type\":\"uint256\"}],\"name\":\"TotalDebtCannotBeLowerThanMinDebt\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Unsupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WrongCollateralParamsForFullRepayment\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseRate\",\"type\":\"uint256\"}],\"name\":\"BaseRateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"borrowingSpread\",\"type\":\"uint256\"}],\"name\":\"BorrowingSpreadUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCollateralIncrease\",\"type\":\"bool\"}],\"name\":\"CollateralChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftCollateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftDebtToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"}],\"name\":\"CollateralTokenAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"}],\"name\":\"CollateralTokenModified\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isDebtIncrease\",\"type\":\"bool\"}],\"name\":\"DebtChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"DelegateWhitelisted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"FeeRecipientChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastFeeOpTime\",\"type\":\"uint256\"}],\"name\":\"LastFeeOpTimeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtLiquidated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralLiquidated\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralSentToLiquidator\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralLiquidationFeePaid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isRedistribution\",\"type\":\"bool\"}],\"name\":\"Liquidation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MintedFees\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"PositionClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"PositionCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IRToken\",\"name\":\"rToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeRecipient\",\"type\":\"address\"}],\"name\":\"PositionManagerDeployed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeAmount\",\"type\":\"uint256\"}],\"name\":\"RBorrowingFeePaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralSent\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rebate\",\"type\":\"uint256\"}],\"name\":\"Redemption\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redemptionRebate\",\"type\":\"uint256\"}],\"name\":\"RedemptionRebateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"redemptionSpread\",\"type\":\"uint256\"}],\"name\":\"RedemptionSpreadUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"}],\"name\":\"SplitLiquidationCollateralChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokensRecovered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BETA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_BORROWING_RATE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_BORROWING_SPREAD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINUTE_DECAY_FACTOR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftCollateralToken_\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"raftDebtToken_\",\"type\":\"address\"}],\"name\":\"addCollateralToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"addCollateralToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"baseRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"borrowingSpread\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"collateralEnabled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"collateralInfo\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract IERC20Indexable\",\"name\":\"debtToken\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"priceFeed\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"splitLiquidation\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"lastFeeOperationTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowingSpread\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"redemptionSpread\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"redemptionRebate\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"collateralTokenForPosition\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeRecipient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"}],\"name\":\"getBorrowingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getBorrowingRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getBorrowingRateWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"priceDeviation\",\"type\":\"uint256\"}],\"name\":\"getRedemptionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"}],\"name\":\"getRedemptionFeeWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"redemptionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getRedemptionRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"getRedemptionRateWithDecay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"}],\"name\":\"isDelegateWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isWhitelisted\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"lastFeeOperationTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"}],\"name\":\"liquidate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"position\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"collateralChange\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isCollateralIncrease\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"debtChange\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isDebtIncrease\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"maxFeePercentage\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"contract IERC20Permit\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct ERC20PermitSignature\",\"name\":\"permitSignature\",\"type\":\"tuple\"}],\"name\":\"managePosition\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"actualCollateralChange\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actualDebtChange\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"positionManager\",\"outputs\":[{\"internalType\":\"contract IPositionManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"priceFeed\",\"outputs\":[{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"r\",\"outputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rToken\",\"outputs\":[{\"internalType\":\"contract IRToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"raftCollateralToken\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"raftDebtToken\",\"outputs\":[{\"internalType\":\"contract IERC20Indexable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"redeemCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"redemptionRebate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"redemptionSpread\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newBorrowingSpread\",\"type\":\"uint256\"}],\"name\":\"setBorrowingSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEnabled\",\"type\":\"bool\"}],\"name\":\"setCollateralEnabled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newFeeRecipient\",\"type\":\"address\"}],\"name\":\"setFeeRecipient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newRedemptionRebate\",\"type\":\"uint256\"}],\"name\":\"setRedemptionRebate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"newRedemptionSpread\",\"type\":\"uint256\"}],\"name\":\"setRedemptionSpread\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"newSplitLiquidationCollateral\",\"type\":\"address\"}],\"name\":\"setSplitLiquidationCollateral\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"collateralToken\",\"type\":\"address\"}],\"name\":\"splitLiquidationCollateral\",\"outputs\":[{\"internalType\":\"contract ISplitLiquidationCollateral\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelisted\",\"type\":\"bool\"}],\"name\":\"whitelistDelegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]","ContractName":"InterestRatePositionManager","CompilerVersion":"v0.8.19+commit.7dd6d404","OptimizationUsed":1,"Runs":200000,"ConstructorArguments":"0x000000000000000000000000183015a9ba6ff60230fdeadc3f43b3d788b13e21","EVMVersion":"london","Library":"","LicenseType":"","Proxy":0,"SwarmSource":""}] \ No newline at end of file diff --git a/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json index 6a1311bb42585..646ea065a473e 100644 --- a/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json +++ b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json @@ -1,5 +1 @@ -{ - "contractAddress": "0xdb53f47ac61fe54f456a4eb3e09832d08dd7beec", - "contractCreator": "0xc7f8d87734ab2cbf70030ac8aa82abfe3e8126cb", - "txHash": "0x196898c69f6b1944f1011120b15c0903329d46259c8cdc0fbcad71da1fe58245" -} \ No newline at end of file +{"contractAddress":"0xdb53f47ac61fe54f456a4eb3e09832d08dd7beec","contractCreator":"0xc7f8d87734ab2cbf70030ac8aa82abfe3e8126cb","txHash":"0x196898c69f6b1944f1011120b15c0903329d46259c8cdc0fbcad71da1fe58245"} \ No newline at end of file diff --git a/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json index 83c1a063596fa..df45d9be39c9e 100644 --- a/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json +++ b/testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/metadata.json @@ -1,148 +1 @@ -[ - { - "SourceCode": { - "language": "Solidity", - "sources": { - "@solidstate/contracts/token/ERC1155/base/ERC1155Base.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC1155 } from '../IERC1155.sol';\nimport { IERC1155Receiver } from '../IERC1155Receiver.sol';\nimport { ERC1155BaseInternal, ERC1155BaseStorage } from './ERC1155BaseInternal.sol';\n\n/**\n * @title Base ERC1155 contract\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)\n */\nabstract contract ERC1155Base is IERC1155, ERC1155BaseInternal {\n /**\n * @inheritdoc IERC1155\n */\n function balanceOf(address account, uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return _balanceOf(account, id);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function balanceOfBatch(address[] memory accounts, uint256[] memory ids)\n public\n view\n virtual\n override\n returns (uint256[] memory)\n {\n require(\n accounts.length == ids.length,\n 'ERC1155: accounts and ids length mismatch'\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n uint256[] memory batchBalances = new uint256[](accounts.length);\n\n unchecked {\n for (uint256 i; i < accounts.length; i++) {\n require(\n accounts[i] != address(0),\n 'ERC1155: batch balance query for the zero address'\n );\n batchBalances[i] = balances[ids[i]][accounts[i]];\n }\n }\n\n return batchBalances;\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function isApprovedForAll(address account, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n return ERC1155BaseStorage.layout().operatorApprovals[account][operator];\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function setApprovalForAll(address operator, bool status)\n public\n virtual\n override\n {\n require(\n msg.sender != operator,\n 'ERC1155: setting approval status for self'\n );\n ERC1155BaseStorage.layout().operatorApprovals[msg.sender][\n operator\n ] = status;\n emit ApprovalForAll(msg.sender, operator, status);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) public virtual override {\n require(\n from == msg.sender || isApprovedForAll(from, msg.sender),\n 'ERC1155: caller is not owner nor approved'\n );\n _safeTransfer(msg.sender, from, to, id, amount, data);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) public virtual override {\n require(\n from == msg.sender || isApprovedForAll(from, msg.sender),\n 'ERC1155: caller is not owner nor approved'\n );\n _safeTransferBatch(msg.sender, from, to, ids, amounts, data);\n }\n}\n" - }, - "@solidstate/contracts/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC165 interface registration interface\n * @dev see https://eips.ethereum.org/EIPS/eip-165\n */\ninterface IERC165 {\n /**\n * @notice query whether contract has registered support for given interface\n * @param interfaceId interface id\n * @return bool whether interface is supported\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "abdk-libraries-solidity/ABDKMath64x64.sol": { - "content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov \n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x8) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n" - }, - "@solidstate/contracts/token/ERC20/metadata/IERC20Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC20 metadata interface\n */\ninterface IERC20Metadata {\n /**\n * @notice return token name\n * @return token name\n */\n function name() external view returns (string memory);\n\n /**\n * @notice return token symbol\n * @return token symbol\n */\n function symbol() external view returns (string memory);\n\n /**\n * @notice return token decimals, generally used only for display purposes\n * @return token decimals\n */\n function decimals() external view returns (uint8);\n}\n" - }, - "contracts/staking/FeeDiscountStorage.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nlibrary FeeDiscountStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.staking.PremiaFeeDiscount\");\r\n\r\n struct UserInfo {\r\n uint256 balance; // Balance staked by user\r\n uint64 stakePeriod; // Stake period selected by user\r\n uint64 lockedUntil; // Timestamp at which the lock ends\r\n }\r\n\r\n struct Layout {\r\n // User data with xPREMIA balance staked and date at which lock ends\r\n mapping(address => UserInfo) userInfo;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n}\r\n" - }, - "contracts/libraries/OptionMath.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\n\r\nlibrary OptionMath {\r\n using ABDKMath64x64 for int128;\r\n\r\n struct QuoteArgs {\r\n int128 varianceAnnualized64x64; // 64x64 fixed point representation of annualized variance\r\n int128 strike64x64; // 64x64 fixed point representation of strike price\r\n int128 spot64x64; // 64x64 fixed point representation of spot price\r\n int128 timeToMaturity64x64; // 64x64 fixed point representation of duration of option contract (in years)\r\n int128 oldCLevel64x64; // 64x64 fixed point representation of C-Level of Pool before purchase\r\n int128 oldPoolState; // 64x64 fixed point representation of current state of the pool\r\n int128 newPoolState; // 64x64 fixed point representation of state of the pool after trade\r\n int128 steepness64x64; // 64x64 fixed point representation of Pool state delta multiplier\r\n int128 minAPY64x64; // 64x64 fixed point representation of minimum APY for capital locked up to underwrite options\r\n bool isCall; // whether to price \"call\" or \"put\" option\r\n }\r\n\r\n struct CalculateCLevelDecayArgs {\r\n int128 timeIntervalsElapsed64x64; // 64x64 fixed point representation of quantity of discrete arbitrary intervals elapsed since last update\r\n int128 oldCLevel64x64; // 64x64 fixed point representation of C-Level prior to accounting for decay\r\n int128 utilization64x64; // 64x64 fixed point representation of pool capital utilization rate\r\n int128 utilizationLowerBound64x64;\r\n int128 utilizationUpperBound64x64;\r\n int128 cLevelLowerBound64x64;\r\n int128 cLevelUpperBound64x64;\r\n int128 cConvergenceULowerBound64x64;\r\n int128 cConvergenceUUpperBound64x64;\r\n }\r\n\r\n // 64x64 fixed point integer constants\r\n int128 internal constant ONE_64x64 = 0x10000000000000000;\r\n int128 internal constant THREE_64x64 = 0x30000000000000000;\r\n\r\n // 64x64 fixed point constants used in Choudhury’s approximation of the Black-Scholes CDF\r\n int128 private constant CDF_CONST_0 = 0x09109f285df452394; // 2260 / 3989\r\n int128 private constant CDF_CONST_1 = 0x19abac0ea1da65036; // 6400 / 3989\r\n int128 private constant CDF_CONST_2 = 0x0d3c84b78b749bd6b; // 3300 / 3989\r\n\r\n /**\r\n * @notice recalculate C-Level based on change in liquidity\r\n * @param initialCLevel64x64 64x64 fixed point representation of C-Level of Pool before update\r\n * @param oldPoolState64x64 64x64 fixed point representation of liquidity in pool before update\r\n * @param newPoolState64x64 64x64 fixed point representation of liquidity in pool after update\r\n * @param steepness64x64 64x64 fixed point representation of steepness coefficient\r\n * @return 64x64 fixed point representation of new C-Level\r\n */\r\n function calculateCLevel(\r\n int128 initialCLevel64x64,\r\n int128 oldPoolState64x64,\r\n int128 newPoolState64x64,\r\n int128 steepness64x64\r\n ) external pure returns (int128) {\r\n return\r\n newPoolState64x64\r\n .sub(oldPoolState64x64)\r\n .div(\r\n oldPoolState64x64 > newPoolState64x64\r\n ? oldPoolState64x64\r\n : newPoolState64x64\r\n )\r\n .mul(steepness64x64)\r\n .neg()\r\n .exp()\r\n .mul(initialCLevel64x64);\r\n }\r\n\r\n /**\r\n * @notice calculate the price of an option using the Premia Finance model\r\n * @param args arguments of quotePrice\r\n * @return premiaPrice64x64 64x64 fixed point representation of Premia option price\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level of Pool after purchase\r\n */\r\n function quotePrice(QuoteArgs memory args)\r\n external\r\n pure\r\n returns (\r\n int128 premiaPrice64x64,\r\n int128 cLevel64x64,\r\n int128 slippageCoefficient64x64\r\n )\r\n {\r\n int128 deltaPoolState64x64 = args\r\n .newPoolState\r\n .sub(args.oldPoolState)\r\n .div(args.oldPoolState)\r\n .mul(args.steepness64x64);\r\n int128 tradingDelta64x64 = deltaPoolState64x64.neg().exp();\r\n\r\n int128 blackScholesPrice64x64 = _blackScholesPrice(\r\n args.varianceAnnualized64x64,\r\n args.strike64x64,\r\n args.spot64x64,\r\n args.timeToMaturity64x64,\r\n args.isCall\r\n );\r\n\r\n cLevel64x64 = tradingDelta64x64.mul(args.oldCLevel64x64);\r\n slippageCoefficient64x64 = ONE_64x64.sub(tradingDelta64x64).div(\r\n deltaPoolState64x64\r\n );\r\n\r\n premiaPrice64x64 = blackScholesPrice64x64.mul(cLevel64x64).mul(\r\n slippageCoefficient64x64\r\n );\r\n\r\n int128 intrinsicValue64x64;\r\n\r\n if (args.isCall && args.strike64x64 < args.spot64x64) {\r\n intrinsicValue64x64 = args.spot64x64.sub(args.strike64x64);\r\n } else if (!args.isCall && args.strike64x64 > args.spot64x64) {\r\n intrinsicValue64x64 = args.strike64x64.sub(args.spot64x64);\r\n }\r\n\r\n int128 collateralValue64x64 = args.isCall\r\n ? args.spot64x64\r\n : args.strike64x64;\r\n\r\n int128 minPrice64x64 = intrinsicValue64x64.add(\r\n collateralValue64x64.mul(args.minAPY64x64).mul(\r\n args.timeToMaturity64x64\r\n )\r\n );\r\n\r\n if (minPrice64x64 > premiaPrice64x64) {\r\n premiaPrice64x64 = minPrice64x64;\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate the decay of C-Level based on heat diffusion function\r\n * @param args structured CalculateCLevelDecayArgs\r\n * @return cLevelDecayed64x64 C-Level after accounting for decay\r\n */\r\n function calculateCLevelDecay(CalculateCLevelDecayArgs memory args)\r\n external\r\n pure\r\n returns (int128 cLevelDecayed64x64)\r\n {\r\n int128 convFHighU64x64 = (args.utilization64x64 >=\r\n args.utilizationUpperBound64x64 &&\r\n args.oldCLevel64x64 <= args.cLevelLowerBound64x64)\r\n ? ONE_64x64\r\n : int128(0);\r\n\r\n int128 convFLowU64x64 = (args.utilization64x64 <=\r\n args.utilizationLowerBound64x64 &&\r\n args.oldCLevel64x64 >= args.cLevelUpperBound64x64)\r\n ? ONE_64x64\r\n : int128(0);\r\n\r\n cLevelDecayed64x64 = args\r\n .oldCLevel64x64\r\n .sub(args.cConvergenceULowerBound64x64.mul(convFLowU64x64))\r\n .sub(args.cConvergenceUUpperBound64x64.mul(convFHighU64x64))\r\n .mul(\r\n convFLowU64x64\r\n .mul(ONE_64x64.sub(args.utilization64x64))\r\n .add(convFHighU64x64.mul(args.utilization64x64))\r\n .mul(args.timeIntervalsElapsed64x64)\r\n .neg()\r\n .exp()\r\n )\r\n .add(\r\n args.cConvergenceULowerBound64x64.mul(convFLowU64x64).add(\r\n args.cConvergenceUUpperBound64x64.mul(convFHighU64x64)\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate the exponential decay coefficient for a given interval\r\n * @param oldTimestamp timestamp of previous update\r\n * @param newTimestamp current timestamp\r\n * @return 64x64 fixed point representation of exponential decay coefficient\r\n */\r\n function _decay(uint256 oldTimestamp, uint256 newTimestamp)\r\n internal\r\n pure\r\n returns (int128)\r\n {\r\n return\r\n ONE_64x64.sub(\r\n (-ABDKMath64x64.divu(newTimestamp - oldTimestamp, 7 days)).exp()\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate Choudhury’s approximation of the Black-Scholes CDF\r\n * @param input64x64 64x64 fixed point representation of random variable\r\n * @return 64x64 fixed point representation of the approximated CDF of x\r\n */\r\n function _N(int128 input64x64) internal pure returns (int128) {\r\n // squaring via mul is cheaper than via pow\r\n int128 inputSquared64x64 = input64x64.mul(input64x64);\r\n\r\n int128 value64x64 = (-inputSquared64x64 >> 1).exp().div(\r\n CDF_CONST_0.add(CDF_CONST_1.mul(input64x64.abs())).add(\r\n CDF_CONST_2.mul(inputSquared64x64.add(THREE_64x64).sqrt())\r\n )\r\n );\r\n\r\n return input64x64 > 0 ? ONE_64x64.sub(value64x64) : value64x64;\r\n }\r\n\r\n /**\r\n * @notice calculate the price of an option using the Black-Scholes model\r\n * @param varianceAnnualized64x64 64x64 fixed point representation of annualized variance\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param spot64x64 64x64 fixed point representation of spot price\r\n * @param timeToMaturity64x64 64x64 fixed point representation of duration of option contract (in years)\r\n * @param isCall whether to price \"call\" or \"put\" option\r\n * @return 64x64 fixed point representation of Black-Scholes option price\r\n */\r\n function _blackScholesPrice(\r\n int128 varianceAnnualized64x64,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) internal pure returns (int128) {\r\n int128 cumulativeVariance64x64 = timeToMaturity64x64.mul(\r\n varianceAnnualized64x64\r\n );\r\n int128 cumulativeVarianceSqrt64x64 = cumulativeVariance64x64.sqrt();\r\n\r\n int128 d1_64x64 = spot64x64\r\n .div(strike64x64)\r\n .ln()\r\n .add(cumulativeVariance64x64 >> 1)\r\n .div(cumulativeVarianceSqrt64x64);\r\n int128 d2_64x64 = d1_64x64.sub(cumulativeVarianceSqrt64x64);\r\n\r\n if (isCall) {\r\n return\r\n spot64x64.mul(_N(d1_64x64)).sub(strike64x64.mul(_N(d2_64x64)));\r\n } else {\r\n return\r\n -spot64x64.mul(_N(-d1_64x64)).sub(\r\n strike64x64.mul(_N(-d2_64x64))\r\n );\r\n }\r\n }\r\n}\r\n" - }, - "@solidstate/contracts/access/IERC173.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Contract ownership standard interface\n * @dev see https://eips.ethereum.org/EIPS/eip-173\n */\ninterface IERC173 {\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n /**\n * @notice get the ERC173 contract owner\n * @return conract owner\n */\n function owner() external view returns (address);\n\n /**\n * @notice transfer contract ownership to new account\n * @param account address of new owner\n */\n function transferOwnership(address account) external;\n}\n" - }, - "contracts/libraries/ABDKMath64x64Token.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\n\r\nlibrary ABDKMath64x64Token {\r\n using ABDKMath64x64 for int128;\r\n\r\n /**\r\n * @notice convert 64x64 fixed point representation of token amount to decimal\r\n * @param value64x64 64x64 fixed point representation of token amount\r\n * @param decimals token display decimals\r\n * @return value decimal representation of token amount\r\n */\r\n function toDecimals(int128 value64x64, uint8 decimals)\r\n internal\r\n pure\r\n returns (uint256 value)\r\n {\r\n value = value64x64.mulu(10**decimals);\r\n }\r\n\r\n /**\r\n * @notice convert decimal representation of token amount to 64x64 fixed point\r\n * @param value decimal representation of token amount\r\n * @param decimals token display decimals\r\n * @return value64x64 64x64 fixed point representation of token amount\r\n */\r\n function fromDecimals(uint256 value, uint8 decimals)\r\n internal\r\n pure\r\n returns (int128 value64x64)\r\n {\r\n value64x64 = ABDKMath64x64.divu(value, 10**decimals);\r\n }\r\n\r\n /**\r\n * @notice convert 64x64 fixed point representation of token amount to wei (18 decimals)\r\n * @param value64x64 64x64 fixed point representation of token amount\r\n * @return value wei representation of token amount\r\n */\r\n function toWei(int128 value64x64) internal pure returns (uint256 value) {\r\n value = toDecimals(value64x64, 18);\r\n }\r\n\r\n /**\r\n * @notice convert wei representation (18 decimals) of token amount to 64x64 fixed point\r\n * @param value wei representation of token amount\r\n * @return value64x64 64x64 fixed point representation of token amount\r\n */\r\n function fromWei(uint256 value) internal pure returns (int128 value64x64) {\r\n value64x64 = fromDecimals(value, 18);\r\n }\r\n}\r\n" - }, - "@solidstate/contracts/token/ERC1155/IERC1155.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC1155Internal } from './IERC1155Internal.sol';\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @notice ERC1155 interface\n * @dev see https://github.com/ethereum/EIPs/issues/1155\n */\ninterface IERC1155 is IERC1155Internal, IERC165 {\n /**\n * @notice query the balance of given token held by given address\n * @param account address to query\n * @param id token to query\n * @return token balance\n */\n function balanceOf(address account, uint256 id)\n external\n view\n returns (uint256);\n\n /**\n * @notice query the balances of given tokens held by given addresses\n * @param accounts addresss to query\n * @param ids tokens to query\n * @return token balances\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @notice query approval status of given operator with respect to given address\n * @param account address to query for approval granted\n * @param operator address to query for approval received\n * @return whether operator is approved to spend tokens held by account\n */\n function isApprovedForAll(address account, address operator)\n external\n view\n returns (bool);\n\n /**\n * @notice grant approval to or revoke approval from given operator to spend held tokens\n * @param operator address whose approval status to update\n * @param status whether operator should be considered approved\n */\n function setApprovalForAll(address operator, bool status) external;\n\n /**\n * @notice transfer tokens between given addresses, checking for ERC1155Receiver implementation if applicable\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @notice transfer batch of tokens between given addresses, checking for ERC1155Receiver implementation if applicable\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to transfer\n * @param data data payload\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n" - }, - "contracts/staking/IFeeDiscount.sol": { - "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {FeeDiscountStorage} from \"./FeeDiscountStorage.sol\";\r\n\r\ninterface IFeeDiscount {\r\n event Staked(\r\n address indexed user,\r\n uint256 amount,\r\n uint256 stakePeriod,\r\n uint256 lockedUntil\r\n );\r\n event Unstaked(address indexed user, uint256 amount);\r\n\r\n struct StakeLevel {\r\n uint256 amount; // Amount to stake\r\n uint256 discount; // Discount when amount is reached\r\n }\r\n\r\n /**\r\n * @notice Stake using IERC2612 permit\r\n * @param amount The amount of xPremia to stake\r\n * @param period The lockup period (in seconds)\r\n * @param deadline Deadline after which permit will fail\r\n * @param v V\r\n * @param r R\r\n * @param s S\r\n */\r\n function stakeWithPermit(\r\n uint256 amount,\r\n uint256 period,\r\n uint256 deadline,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external;\r\n\r\n /**\r\n * @notice Lockup xPremia for protocol fee discounts\r\n * Longer period of locking will apply a multiplier on the amount staked, in the fee discount calculation\r\n * @param amount The amount of xPremia to stake\r\n * @param period The lockup period (in seconds)\r\n */\r\n function stake(uint256 amount, uint256 period) external;\r\n\r\n /**\r\n * @notice Unstake xPremia (If lockup period has ended)\r\n * @param amount The amount of xPremia to unstake\r\n */\r\n function unstake(uint256 amount) external;\r\n\r\n //////////\r\n // View //\r\n //////////\r\n\r\n /**\r\n * Calculate the stake amount of a user, after applying the bonus from the lockup period chosen\r\n * @param user The user from which to query the stake amount\r\n * @return The user stake amount after applying the bonus\r\n */\r\n function getStakeAmountWithBonus(address user)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n /**\r\n * @notice Calculate the % of fee discount for user, based on his stake\r\n * @param user The _user for which the discount is for\r\n * @return Percentage of protocol fee discount (in basis point)\r\n * Ex : 1000 = 10% fee discount\r\n */\r\n function getDiscount(address user) external view returns (uint256);\r\n\r\n /**\r\n * @notice Get stake levels\r\n * @return Stake levels\r\n * Ex : 2500 = -25%\r\n */\r\n function getStakeLevels() external returns (StakeLevel[] memory);\r\n\r\n /**\r\n * @notice Get stake period multiplier\r\n * @param period The duration (in seconds) for which tokens are locked\r\n * @return The multiplier for this staking period\r\n * Ex : 20000 = x2\r\n */\r\n function getStakePeriodMultiplier(uint256 period)\r\n external\r\n returns (uint256);\r\n\r\n /**\r\n * @notice Get staking infos of a user\r\n * @param user The user address for which to get staking infos\r\n * @return The staking infos of the user\r\n */\r\n function getUserInfo(address user)\r\n external\r\n view\r\n returns (FeeDiscountStorage.UserInfo memory);\r\n}\r\n" - }, - "@solidstate/contracts/token/ERC1155/base/ERC1155BaseInternal.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { AddressUtils } from '../../../utils/AddressUtils.sol';\nimport { IERC1155Internal } from '../IERC1155Internal.sol';\nimport { IERC1155Receiver } from '../IERC1155Receiver.sol';\nimport { ERC1155BaseStorage } from './ERC1155BaseStorage.sol';\n\n/**\n * @title Base ERC1155 internal functions\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)\n */\nabstract contract ERC1155BaseInternal is IERC1155Internal {\n using AddressUtils for address;\n\n /**\n * @notice query the balance of given token held by given address\n * @param account address to query\n * @param id token to query\n * @return token balance\n */\n function _balanceOf(address account, uint256 id)\n internal\n view\n virtual\n returns (uint256)\n {\n require(\n account != address(0),\n 'ERC1155: balance query for the zero address'\n );\n return ERC1155BaseStorage.layout().balances[id][account];\n }\n\n /**\n * @notice mint given quantity of tokens for given address\n * @dev ERC1155Receiver implementation is not checked\n * @param account beneficiary of minting\n * @param id token ID\n * @param amount quantity of tokens to mint\n * @param data data payload\n */\n function _mint(\n address account,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(account != address(0), 'ERC1155: mint to the zero address');\n\n _beforeTokenTransfer(\n msg.sender,\n address(0),\n account,\n _asSingletonArray(id),\n _asSingletonArray(amount),\n data\n );\n\n mapping(address => uint256) storage balances = ERC1155BaseStorage\n .layout()\n .balances[id];\n balances[account] += amount;\n\n emit TransferSingle(msg.sender, address(0), account, id, amount);\n }\n\n /**\n * @notice mint given quantity of tokens for given address\n * @param account beneficiary of minting\n * @param id token ID\n * @param amount quantity of tokens to mint\n * @param data data payload\n */\n function _safeMint(\n address account,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n _mint(account, id, amount, data);\n\n _doSafeTransferAcceptanceCheck(\n msg.sender,\n address(0),\n account,\n id,\n amount,\n data\n );\n }\n\n /**\n * @notice mint batch of tokens for given address\n * @dev ERC1155Receiver implementation is not checked\n * @param account beneficiary of minting\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to mint\n * @param data data payload\n */\n function _mintBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(account != address(0), 'ERC1155: mint to the zero address');\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(\n msg.sender,\n address(0),\n account,\n ids,\n amounts,\n data\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n for (uint256 i; i < ids.length; i++) {\n balances[ids[i]][account] += amounts[i];\n }\n\n emit TransferBatch(msg.sender, address(0), account, ids, amounts);\n }\n\n /**\n * @notice mint batch of tokens for given address\n * @param account beneficiary of minting\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to mint\n * @param data data payload\n */\n function _safeMintBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _mintBatch(account, ids, amounts, data);\n\n _doSafeBatchTransferAcceptanceCheck(\n msg.sender,\n address(0),\n account,\n ids,\n amounts,\n data\n );\n }\n\n /**\n * @notice burn given quantity of tokens held by given address\n * @param account holder of tokens to burn\n * @param id token ID\n * @param amount quantity of tokens to burn\n */\n function _burn(\n address account,\n uint256 id,\n uint256 amount\n ) internal virtual {\n require(account != address(0), 'ERC1155: burn from the zero address');\n\n _beforeTokenTransfer(\n msg.sender,\n account,\n address(0),\n _asSingletonArray(id),\n _asSingletonArray(amount),\n ''\n );\n\n mapping(address => uint256) storage balances = ERC1155BaseStorage\n .layout()\n .balances[id];\n\n unchecked {\n require(\n balances[account] >= amount,\n 'ERC1155: burn amount exceeds balances'\n );\n balances[account] -= amount;\n }\n\n emit TransferSingle(msg.sender, account, address(0), id, amount);\n }\n\n /**\n * @notice burn given batch of tokens held by given address\n * @param account holder of tokens to burn\n * @param ids token IDs\n * @param amounts quantities of tokens to burn\n */\n function _burnBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal virtual {\n require(account != address(0), 'ERC1155: burn from the zero address');\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(msg.sender, account, address(0), ids, amounts, '');\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n unchecked {\n for (uint256 i; i < ids.length; i++) {\n uint256 id = ids[i];\n require(\n balances[id][account] >= amounts[i],\n 'ERC1155: burn amount exceeds balance'\n );\n balances[id][account] -= amounts[i];\n }\n }\n\n emit TransferBatch(msg.sender, account, address(0), ids, amounts);\n }\n\n /**\n * @notice transfer tokens between given addresses\n * @dev ERC1155Receiver implementation is not checked\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _transfer(\n address operator,\n address sender,\n address recipient,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(\n recipient != address(0),\n 'ERC1155: transfer to the zero address'\n );\n\n _beforeTokenTransfer(\n operator,\n sender,\n recipient,\n _asSingletonArray(id),\n _asSingletonArray(amount),\n data\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n unchecked {\n uint256 senderBalance = balances[id][sender];\n require(\n senderBalance >= amount,\n 'ERC1155: insufficient balances for transfer'\n );\n balances[id][sender] = senderBalance - amount;\n }\n\n balances[id][recipient] += amount;\n\n emit TransferSingle(operator, sender, recipient, id, amount);\n }\n\n /**\n * @notice transfer tokens between given addresses\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _safeTransfer(\n address operator,\n address sender,\n address recipient,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n _transfer(operator, sender, recipient, id, amount, data);\n\n _doSafeTransferAcceptanceCheck(\n operator,\n sender,\n recipient,\n id,\n amount,\n data\n );\n }\n\n /**\n * @notice transfer batch of tokens between given addresses\n * @dev ERC1155Receiver implementation is not checked\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _transferBatch(\n address operator,\n address sender,\n address recipient,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(\n recipient != address(0),\n 'ERC1155: transfer to the zero address'\n );\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(operator, sender, recipient, ids, amounts, data);\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n for (uint256 i; i < ids.length; i++) {\n uint256 token = ids[i];\n uint256 amount = amounts[i];\n\n unchecked {\n uint256 senderBalance = balances[token][sender];\n require(\n senderBalance >= amount,\n 'ERC1155: insufficient balances for transfer'\n );\n balances[token][sender] = senderBalance - amount;\n }\n\n balances[token][recipient] += amount;\n }\n\n emit TransferBatch(operator, sender, recipient, ids, amounts);\n }\n\n /**\n * @notice transfer batch of tokens between given addresses\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _safeTransferBatch(\n address operator,\n address sender,\n address recipient,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _transferBatch(operator, sender, recipient, ids, amounts, data);\n\n _doSafeBatchTransferAcceptanceCheck(\n operator,\n sender,\n recipient,\n ids,\n amounts,\n data\n );\n }\n\n /**\n * @notice wrap given element in array of length 1\n * @param element element to wrap\n * @return singleton array\n */\n function _asSingletonArray(uint256 element)\n private\n pure\n returns (uint256[] memory)\n {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n /**\n * @notice revert if applicable transfer recipient is not valid ERC1155Receiver\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _doSafeTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try\n IERC1155Receiver(to).onERC1155Received(\n operator,\n from,\n id,\n amount,\n data\n )\n returns (bytes4 response) {\n require(\n response == IERC1155Receiver.onERC1155Received.selector,\n 'ERC1155: ERC1155Receiver rejected tokens'\n );\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert('ERC1155: transfer to non ERC1155Receiver implementer');\n }\n }\n }\n\n /**\n * @notice revert if applicable transfer recipient is not valid ERC1155Receiver\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _doSafeBatchTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try\n IERC1155Receiver(to).onERC1155BatchReceived(\n operator,\n from,\n ids,\n amounts,\n data\n )\n returns (bytes4 response) {\n require(\n response ==\n IERC1155Receiver.onERC1155BatchReceived.selector,\n 'ERC1155: ERC1155Receiver rejected tokens'\n );\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert('ERC1155: transfer to non ERC1155Receiver implementer');\n }\n }\n }\n\n /**\n * @notice ERC1155 hook, called before all transfers including mint and burn\n * @dev function should be overridden and new implementation must call super\n * @dev called for both single and batch transfers\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n}\n" - }, - "@solidstate/contracts/token/ERC20/IERC20Internal.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Partial ERC20 interface needed by internal functions\n */\ninterface IERC20Internal {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer()\n external\n view\n returns (\n int256\n );\n \n function latestTimestamp()\n external\n view\n returns (\n uint256\n );\n\n function latestRound()\n external\n view\n returns (\n uint256\n );\n\n function getAnswer(\n uint256 roundId\n )\n external\n view\n returns (\n int256\n );\n\n function getTimestamp(\n uint256 roundId\n )\n external\n view\n returns (\n uint256\n );\n\n event AnswerUpdated(\n int256 indexed current,\n uint256 indexed roundId,\n uint256 updatedAt\n );\n\n event NewRound(\n uint256 indexed roundId,\n address indexed startedBy,\n uint256 startedAt\n );\n}\n" - }, - "contracts/pool/PoolExercise.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ERC1155BaseStorage} from \"@solidstate/contracts/token/ERC1155/base/ERC1155BaseStorage.sol\";\r\n\r\nimport {PoolInternal} from \"./PoolInternal.sol\";\r\nimport {IPoolExercise} from \"./IPoolExercise.sol\";\r\n\r\n/**\r\n * @title Premia option pool\r\n * @dev deployed standalone and referenced by PoolProxy\r\n */\r\ncontract PoolExercise is IPoolExercise, PoolInternal {\r\n constructor(\r\n address ivolOracle,\r\n address weth,\r\n address premiaMining,\r\n address feeReceiver,\r\n address feeDiscountAddress,\r\n int128 fee64x64\r\n )\r\n PoolInternal(\r\n ivolOracle,\r\n weth,\r\n premiaMining,\r\n feeReceiver,\r\n feeDiscountAddress,\r\n fee64x64\r\n )\r\n {}\r\n\r\n /**\r\n * @inheritdoc IPoolExercise\r\n */\r\n function exerciseFrom(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) external override {\r\n if (msg.sender != holder) {\r\n require(\r\n ERC1155BaseStorage.layout().operatorApprovals[holder][\r\n msg.sender\r\n ],\r\n \"not approved\"\r\n );\r\n }\r\n\r\n _exercise(holder, longTokenId, contractSize);\r\n }\r\n\r\n /**\r\n * @inheritdoc IPoolExercise\r\n */\r\n function processExpired(uint256 longTokenId, uint256 contractSize)\r\n external\r\n override\r\n {\r\n _exercise(address(0), longTokenId, contractSize);\r\n }\r\n}\r\n" - }, - "contracts/pool/IPoolExercise.sol": { - "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @notice Pool interface for exercising and processing of expired options\r\n */\r\ninterface IPoolExercise {\r\n /**\r\n * @notice exercise option on behalf of holder\r\n * @param holder owner of long option tokens to exercise\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to exercise\r\n */\r\n function exerciseFrom(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) external;\r\n\r\n /**\r\n * @notice process expired option, freeing liquidity and distributing profits\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to process\r\n */\r\n function processExpired(uint256 longTokenId, uint256 contractSize) external;\r\n}\r\n" - }, - "contracts/pool/PoolStorage.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {AggregatorInterface} from \"@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol\";\r\nimport {AggregatorV3Interface} from \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\r\nimport {EnumerableSet, ERC1155EnumerableStorage} from \"@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableStorage.sol\";\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\nimport {ABDKMath64x64Token} from \"../libraries/ABDKMath64x64Token.sol\";\r\nimport {OptionMath} from \"../libraries/OptionMath.sol\";\r\n\r\nlibrary PoolStorage {\r\n using ABDKMath64x64 for int128;\r\n using PoolStorage for PoolStorage.Layout;\r\n\r\n enum TokenType {\r\n UNDERLYING_FREE_LIQ,\r\n BASE_FREE_LIQ,\r\n UNDERLYING_RESERVED_LIQ,\r\n BASE_RESERVED_LIQ,\r\n LONG_CALL,\r\n SHORT_CALL,\r\n LONG_PUT,\r\n SHORT_PUT\r\n }\r\n\r\n struct PoolSettings {\r\n address underlying;\r\n address base;\r\n address underlyingOracle;\r\n address baseOracle;\r\n }\r\n\r\n struct QuoteArgsInternal {\r\n address feePayer; // address of the fee payer\r\n uint64 maturity; // timestamp of option maturity\r\n int128 strike64x64; // 64x64 fixed point representation of strike price\r\n int128 spot64x64; // 64x64 fixed point representation of spot price\r\n uint256 contractSize; // size of option contract\r\n bool isCall; // true for call, false for put\r\n }\r\n\r\n struct QuoteResultInternal {\r\n int128 baseCost64x64; // 64x64 fixed point representation of option cost denominated in underlying currency (without fee)\r\n int128 feeCost64x64; // 64x64 fixed point representation of option fee cost denominated in underlying currency for call, or base currency for put\r\n int128 cLevel64x64; // 64x64 fixed point representation of C-Level of Pool after purchase\r\n int128 slippageCoefficient64x64; // 64x64 fixed point representation of slippage coefficient for given order size\r\n }\r\n\r\n struct BatchData {\r\n uint256 eta;\r\n uint256 totalPendingDeposits;\r\n }\r\n\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.Pool\");\r\n\r\n uint256 private constant C_DECAY_BUFFER = 12 hours;\r\n uint256 private constant C_DECAY_INTERVAL = 4 hours;\r\n\r\n struct Layout {\r\n // ERC20 token addresses\r\n address base;\r\n address underlying;\r\n // AggregatorV3Interface oracle addresses\r\n address baseOracle;\r\n address underlyingOracle;\r\n // token metadata\r\n uint8 underlyingDecimals;\r\n uint8 baseDecimals;\r\n // minimum amounts\r\n uint256 baseMinimum;\r\n uint256 underlyingMinimum;\r\n // deposit caps\r\n uint256 basePoolCap;\r\n uint256 underlyingPoolCap;\r\n // market state\r\n int128 _deprecated_steepness64x64;\r\n int128 cLevelBase64x64;\r\n int128 cLevelUnderlying64x64;\r\n uint256 cLevelBaseUpdatedAt;\r\n uint256 cLevelUnderlyingUpdatedAt;\r\n uint256 updatedAt;\r\n // User -> isCall -> depositedAt\r\n mapping(address => mapping(bool => uint256)) depositedAt;\r\n mapping(address => mapping(bool => uint256)) divestmentTimestamps;\r\n // doubly linked list of free liquidity intervals\r\n // isCall -> User -> User\r\n mapping(bool => mapping(address => address)) liquidityQueueAscending;\r\n mapping(bool => mapping(address => address)) liquidityQueueDescending;\r\n // minimum resolution price bucket => price\r\n mapping(uint256 => int128) bucketPrices64x64;\r\n // sequence id (minimum resolution price bucket / 256) => price update sequence\r\n mapping(uint256 => uint256) priceUpdateSequences;\r\n // isCall -> batch data\r\n mapping(bool => BatchData) nextDeposits;\r\n // user -> batch timestamp -> isCall -> pending amount\r\n mapping(address => mapping(uint256 => mapping(bool => uint256))) pendingDeposits;\r\n EnumerableSet.UintSet tokenIds;\r\n // user -> isCallPool -> total value locked of user (Used for liquidity mining)\r\n mapping(address => mapping(bool => uint256)) userTVL;\r\n // isCallPool -> total value locked\r\n mapping(bool => uint256) totalTVL;\r\n // steepness values\r\n int128 steepnessBase64x64;\r\n int128 steepnessUnderlying64x64;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate ERC1155 token id for given option parameters\r\n * @param tokenType TokenType enum\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @return tokenId token id\r\n */\r\n function formatTokenId(\r\n TokenType tokenType,\r\n uint64 maturity,\r\n int128 strike64x64\r\n ) internal pure returns (uint256 tokenId) {\r\n tokenId =\r\n (uint256(tokenType) << 248) +\r\n (uint256(maturity) << 128) +\r\n uint256(int256(strike64x64));\r\n }\r\n\r\n /**\r\n * @notice derive option maturity and strike price from ERC1155 token id\r\n * @param tokenId token id\r\n * @return tokenType TokenType enum\r\n * @return maturity timestamp of option maturity\r\n * @return strike64x64 option strike price\r\n */\r\n function parseTokenId(uint256 tokenId)\r\n internal\r\n pure\r\n returns (\r\n TokenType tokenType,\r\n uint64 maturity,\r\n int128 strike64x64\r\n )\r\n {\r\n assembly {\r\n tokenType := shr(248, tokenId)\r\n maturity := shr(128, tokenId)\r\n strike64x64 := tokenId\r\n }\r\n }\r\n\r\n function getTokenDecimals(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint8 decimals)\r\n {\r\n decimals = isCall ? l.underlyingDecimals : l.baseDecimals;\r\n }\r\n\r\n /**\r\n * @notice get the total supply of free liquidity tokens, minus pending deposits\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return 64x64 fixed point representation of total free liquidity\r\n */\r\n function totalFreeLiquiditySupply64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n uint256 tokenId = formatTokenId(\r\n isCall ? TokenType.UNDERLYING_FREE_LIQ : TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n return\r\n ABDKMath64x64Token.fromDecimals(\r\n ERC1155EnumerableStorage.layout().totalSupply[tokenId] -\r\n l.nextDeposits[isCall].totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n );\r\n }\r\n\r\n function getReinvestmentStatus(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal view returns (bool) {\r\n uint256 timestamp = l.divestmentTimestamps[account][isCallPool];\r\n return timestamp == 0 || timestamp > block.timestamp;\r\n }\r\n\r\n function addUnderwriter(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal {\r\n require(account != address(0));\r\n\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n if (_isInQueue(account, asc, desc)) return;\r\n\r\n address last = desc[address(0)];\r\n\r\n asc[last] = account;\r\n desc[account] = last;\r\n desc[address(0)] = account;\r\n }\r\n\r\n function removeUnderwriter(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal {\r\n require(account != address(0));\r\n\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n if (!_isInQueue(account, asc, desc)) return;\r\n\r\n address prev = desc[account];\r\n address next = asc[account];\r\n asc[prev] = next;\r\n desc[next] = prev;\r\n delete asc[account];\r\n delete desc[account];\r\n }\r\n\r\n function isInQueue(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal view returns (bool) {\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n return _isInQueue(account, asc, desc);\r\n }\r\n\r\n function _isInQueue(\r\n address account,\r\n mapping(address => address) storage asc,\r\n mapping(address => address) storage desc\r\n ) private view returns (bool) {\r\n return asc[account] != address(0) || desc[address(0)] == account;\r\n }\r\n\r\n /**\r\n * @notice get current C-Level, without accounting for pending adjustments\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function getRawCLevel64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128 cLevel64x64)\r\n {\r\n cLevel64x64 = isCall ? l.cLevelUnderlying64x64 : l.cLevelBase64x64;\r\n }\r\n\r\n /**\r\n * @notice get current C-Level, accounting for unrealized decay\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function getDecayAdjustedCLevel64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128 cLevel64x64)\r\n {\r\n // get raw C-Level from storage\r\n cLevel64x64 = l.getRawCLevel64x64(isCall);\r\n\r\n // account for C-Level decay\r\n cLevel64x64 = l.applyCLevelDecayAdjustment(cLevel64x64, isCall);\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for unrealized decay\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for decay\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level of Pool after accounting for decay\r\n */\r\n function applyCLevelDecayAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n bool isCall\r\n ) internal view returns (int128 cLevel64x64) {\r\n uint256 timeElapsed = block.timestamp -\r\n (isCall ? l.cLevelUnderlyingUpdatedAt : l.cLevelBaseUpdatedAt);\r\n\r\n // do not apply C decay if less than 24 hours have elapsed\r\n\r\n if (timeElapsed > C_DECAY_BUFFER) {\r\n timeElapsed -= C_DECAY_BUFFER;\r\n } else {\r\n return oldCLevel64x64;\r\n }\r\n\r\n int128 timeIntervalsElapsed64x64 = ABDKMath64x64.divu(\r\n timeElapsed,\r\n C_DECAY_INTERVAL\r\n );\r\n\r\n uint256 tokenId = formatTokenId(\r\n isCall ? TokenType.UNDERLYING_FREE_LIQ : TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n uint256 tvl = l.totalTVL[isCall];\r\n\r\n int128 utilization = ABDKMath64x64.divu(\r\n tvl -\r\n (ERC1155EnumerableStorage.layout().totalSupply[tokenId] -\r\n l.nextDeposits[isCall].totalPendingDeposits),\r\n tvl\r\n );\r\n\r\n return\r\n OptionMath.calculateCLevelDecay(\r\n OptionMath.CalculateCLevelDecayArgs(\r\n timeIntervalsElapsed64x64,\r\n oldCLevel64x64,\r\n utilization,\r\n 0xb333333333333333, // 0.7\r\n 0xe666666666666666, // 0.9\r\n 0x10000000000000000, // 1.0\r\n 0x10000000000000000, // 1.0\r\n 0xe666666666666666, // 0.9\r\n 0x56fc2a2c515da32ea // 2e\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for pending deposits\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for liquidity change\r\n * @param oldLiquidity64x64 64x64 fixed point representation of previous liquidity\r\n * @param isCall whether to update C-Level for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n * @return liquidity64x64 64x64 fixed point representation of new liquidity amount\r\n */\r\n function applyCLevelPendingDepositAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n int128 oldLiquidity64x64,\r\n bool isCall\r\n ) internal view returns (int128 cLevel64x64, int128 liquidity64x64) {\r\n PoolStorage.BatchData storage batchData = l.nextDeposits[isCall];\r\n int128 pendingDeposits64x64;\r\n\r\n if (\r\n batchData.totalPendingDeposits > 0 &&\r\n batchData.eta != 0 &&\r\n block.timestamp >= batchData.eta\r\n ) {\r\n pendingDeposits64x64 = ABDKMath64x64Token.fromDecimals(\r\n batchData.totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n liquidity64x64 = oldLiquidity64x64.add(pendingDeposits64x64);\r\n\r\n cLevel64x64 = l.applyCLevelLiquidityChangeAdjustment(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n liquidity64x64,\r\n isCall\r\n );\r\n } else {\r\n cLevel64x64 = oldCLevel64x64;\r\n liquidity64x64 = oldLiquidity64x64;\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for change in liquidity\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for liquidity change\r\n * @param oldLiquidity64x64 64x64 fixed point representation of previous liquidity\r\n * @param newLiquidity64x64 64x64 fixed point representation of current liquidity\r\n * @param isCallPool whether to update C-Level for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function applyCLevelLiquidityChangeAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64,\r\n bool isCallPool\r\n ) internal view returns (int128 cLevel64x64) {\r\n int128 steepness64x64 = isCallPool\r\n ? l.steepnessUnderlying64x64\r\n : l.steepnessBase64x64;\r\n\r\n // fallback to deprecated storage value if side-specific value is not set\r\n if (steepness64x64 == 0) steepness64x64 = l._deprecated_steepness64x64;\r\n\r\n cLevel64x64 = OptionMath.calculateCLevel(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64,\r\n steepness64x64\r\n );\r\n\r\n if (cLevel64x64 < 0xb333333333333333) {\r\n cLevel64x64 = int128(0xb333333333333333); // 64x64 fixed point representation of 0.7\r\n }\r\n }\r\n\r\n /**\r\n * @notice set C-Level to arbitrary pre-calculated value\r\n * @param cLevel64x64 new C-Level of pool\r\n * @param isCallPool whether to update C-Level for call or put pool\r\n */\r\n function setCLevel(\r\n Layout storage l,\r\n int128 cLevel64x64,\r\n bool isCallPool\r\n ) internal {\r\n if (isCallPool) {\r\n l.cLevelUnderlying64x64 = cLevel64x64;\r\n l.cLevelUnderlyingUpdatedAt = block.timestamp;\r\n } else {\r\n l.cLevelBase64x64 = cLevel64x64;\r\n l.cLevelBaseUpdatedAt = block.timestamp;\r\n }\r\n }\r\n\r\n function setOracles(\r\n Layout storage l,\r\n address baseOracle,\r\n address underlyingOracle\r\n ) internal {\r\n require(\r\n AggregatorV3Interface(baseOracle).decimals() ==\r\n AggregatorV3Interface(underlyingOracle).decimals(),\r\n \"Pool: oracle decimals must match\"\r\n );\r\n\r\n l.baseOracle = baseOracle;\r\n l.underlyingOracle = underlyingOracle;\r\n }\r\n\r\n function fetchPriceUpdate(Layout storage l)\r\n internal\r\n view\r\n returns (int128 price64x64)\r\n {\r\n int256 priceUnderlying = AggregatorInterface(l.underlyingOracle)\r\n .latestAnswer();\r\n int256 priceBase = AggregatorInterface(l.baseOracle).latestAnswer();\r\n\r\n return ABDKMath64x64.divi(priceUnderlying, priceBase);\r\n }\r\n\r\n /**\r\n * @notice set price update for hourly bucket corresponding to given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to update\r\n * @param price64x64 64x64 fixed point representation of price\r\n */\r\n function setPriceUpdate(\r\n Layout storage l,\r\n uint256 timestamp,\r\n int128 price64x64\r\n ) internal {\r\n uint256 bucket = timestamp / (1 hours);\r\n l.bucketPrices64x64[bucket] = price64x64;\r\n l.priceUpdateSequences[bucket >> 8] += 1 << (255 - (bucket & 255));\r\n }\r\n\r\n /**\r\n * @notice get price update for hourly bucket corresponding to given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to query\r\n * @return 64x64 fixed point representation of price\r\n */\r\n function getPriceUpdate(Layout storage l, uint256 timestamp)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n return l.bucketPrices64x64[timestamp / (1 hours)];\r\n }\r\n\r\n /**\r\n * @notice get first price update available following given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to query\r\n * @return 64x64 fixed point representation of price\r\n */\r\n function getPriceUpdateAfter(Layout storage l, uint256 timestamp)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n // price updates are grouped into hourly buckets\r\n uint256 bucket = timestamp / (1 hours);\r\n // divide by 256 to get the index of the relevant price update sequence\r\n uint256 sequenceId = bucket >> 8;\r\n\r\n // get position within sequence relevant to current price update\r\n\r\n uint256 offset = bucket & 255;\r\n // shift to skip buckets from earlier in sequence\r\n uint256 sequence = (l.priceUpdateSequences[sequenceId] << offset) >>\r\n offset;\r\n\r\n // iterate through future sequences until a price update is found\r\n // sequence corresponding to current timestamp used as upper bound\r\n\r\n uint256 currentPriceUpdateSequenceId = block.timestamp / (256 hours);\r\n\r\n while (sequence == 0 && sequenceId <= currentPriceUpdateSequenceId) {\r\n sequence = l.priceUpdateSequences[++sequenceId];\r\n }\r\n\r\n // if no price update is found (sequence == 0) function will return 0\r\n // this should never occur, as each relevant external function triggers a price update\r\n\r\n // the most significant bit of the sequence corresponds to the offset of the relevant bucket\r\n\r\n uint256 msb;\r\n\r\n for (uint256 i = 128; i > 0; i >>= 1) {\r\n if (sequence >> i > 0) {\r\n msb += i;\r\n sequence >>= i;\r\n }\r\n }\r\n\r\n return l.bucketPrices64x64[((sequenceId + 1) << 8) - msb - 1];\r\n }\r\n\r\n function fromBaseToUnderlyingDecimals(Layout storage l, uint256 value)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n int128 valueFixed64x64 = ABDKMath64x64Token.fromDecimals(\r\n value,\r\n l.baseDecimals\r\n );\r\n return\r\n ABDKMath64x64Token.toDecimals(\r\n valueFixed64x64,\r\n l.underlyingDecimals\r\n );\r\n }\r\n\r\n function fromUnderlyingToBaseDecimals(Layout storage l, uint256 value)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n int128 valueFixed64x64 = ABDKMath64x64Token.fromDecimals(\r\n value,\r\n l.underlyingDecimals\r\n );\r\n return ABDKMath64x64Token.toDecimals(valueFixed64x64, l.baseDecimals);\r\n }\r\n}\r\n" - }, - "@solidstate/contracts/utils/AddressUtils.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary AddressUtils {\n function toString(address account) internal pure returns (string memory) {\n bytes32 value = bytes32(uint256(uint160(account)));\n bytes memory alphabet = '0123456789abcdef';\n bytes memory chars = new bytes(42);\n\n chars[0] = '0';\n chars[1] = 'x';\n\n for (uint256 i = 0; i < 20; i++) {\n chars[2 + i * 2] = alphabet[uint8(value[i + 12] >> 4)];\n chars[3 + i * 2] = alphabet[uint8(value[i + 12] & 0x0f)];\n }\n\n return string(chars);\n }\n\n function isContract(address account) internal view returns (bool) {\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n function sendValue(address payable account, uint256 amount) internal {\n (bool success, ) = account.call{ value: amount }('');\n require(success, 'AddressUtils: failed to send value');\n }\n\n function functionCall(address target, bytes memory data)\n internal\n returns (bytes memory)\n {\n return\n functionCall(target, data, 'AddressUtils: failed low-level call');\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory error\n ) internal returns (bytes memory) {\n return _functionCallWithValue(target, data, 0, error);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n 'AddressUtils: failed low-level call with value'\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory error\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n 'AddressUtils: insufficient balance for call'\n );\n return _functionCallWithValue(target, data, value, error);\n }\n\n function _functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory error\n ) private returns (bytes memory) {\n require(\n isContract(target),\n 'AddressUtils: function call to non-contract'\n );\n\n (bool success, bytes memory returnData) = target.call{ value: value }(\n data\n );\n\n if (success) {\n return returnData;\n } else if (returnData.length > 0) {\n assembly {\n let returnData_size := mload(returnData)\n revert(add(32, returnData), returnData_size)\n }\n } else {\n revert(error);\n }\n }\n}\n" - }, - "@solidstate/contracts/token/ERC1155/enumerable/ERC1155Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\nimport { ERC1155Base, ERC1155BaseInternal } from '../base/ERC1155Base.sol';\nimport { IERC1155Enumerable } from './IERC1155Enumerable.sol';\nimport { ERC1155EnumerableInternal, ERC1155EnumerableStorage } from './ERC1155EnumerableInternal.sol';\n\n/**\n * @title ERC1155 implementation including enumerable and aggregate functions\n */\nabstract contract ERC1155Enumerable is\n IERC1155Enumerable,\n ERC1155Base,\n ERC1155EnumerableInternal\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function totalSupply(uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return ERC1155EnumerableStorage.layout().totalSupply[id];\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function totalHolders(uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return ERC1155EnumerableStorage.layout().accountsByToken[id].length();\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function accountsByToken(uint256 id)\n public\n view\n virtual\n override\n returns (address[] memory)\n {\n EnumerableSet.AddressSet storage accounts = ERC1155EnumerableStorage\n .layout()\n .accountsByToken[id];\n\n address[] memory addresses = new address[](accounts.length());\n\n for (uint256 i; i < accounts.length(); i++) {\n addresses[i] = accounts.at(i);\n }\n\n return addresses;\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function tokensByAccount(address account)\n public\n view\n virtual\n override\n returns (uint256[] memory)\n {\n EnumerableSet.UintSet storage tokens = ERC1155EnumerableStorage\n .layout()\n .tokensByAccount[account];\n\n uint256[] memory ids = new uint256[](tokens.length());\n\n for (uint256 i; i < tokens.length(); i++) {\n ids[i] = tokens.at(i);\n }\n\n return ids;\n }\n\n /**\n * @notice ERC1155 hook: update aggregate values\n * @inheritdoc ERC1155EnumerableInternal\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n )\n internal\n virtual\n override(ERC1155BaseInternal, ERC1155EnumerableInternal)\n {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n }\n}\n" - }, - "@solidstate/contracts/token/ERC1155/IERC1155Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @title ERC1155 transfer receiver interface\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @notice validate receipt of ERC1155 transfer\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param id token ID received\n * @param value quantity of tokens received\n * @param data data payload\n * @return function's own selector if transfer is accepted\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @notice validate receipt of ERC1155 batch transfer\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param ids token IDs received\n * @param values quantities of tokens received\n * @param data data payload\n * @return function's own selector if transfer is accepted\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "contracts/pool/IPoolEvents.sol": { - "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\ninterface IPoolEvents {\r\n event Purchase(\r\n address indexed user,\r\n uint256 longTokenId,\r\n uint256 contractSize,\r\n uint256 baseCost,\r\n uint256 feeCost,\r\n int128 spot64x64\r\n );\r\n\r\n event Exercise(\r\n address indexed user,\r\n uint256 longTokenId,\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 fee\r\n );\r\n\r\n event Underwrite(\r\n address indexed underwriter,\r\n address indexed longReceiver,\r\n uint256 shortTokenId,\r\n uint256 intervalContractSize,\r\n uint256 intervalPremium,\r\n bool isManualUnderwrite\r\n );\r\n\r\n event AssignExercise(\r\n address indexed underwriter,\r\n uint256 shortTokenId,\r\n uint256 freedAmount,\r\n uint256 intervalContractSize,\r\n uint256 fee\r\n );\r\n\r\n event Deposit(address indexed user, bool isCallPool, uint256 amount);\r\n\r\n event Withdrawal(\r\n address indexed user,\r\n bool isCallPool,\r\n uint256 depositedAt,\r\n uint256 amount\r\n );\r\n\r\n event FeeWithdrawal(bool indexed isCallPool, uint256 amount);\r\n\r\n event Annihilate(uint256 shortTokenId, uint256 amount);\r\n\r\n event UpdateCLevel(\r\n bool indexed isCall,\r\n int128 cLevel64x64,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64\r\n );\r\n\r\n event UpdateSteepness(int128 steepness64x64, bool isCallPool);\r\n}\r\n" - }, - "contracts/oracle/VolatilitySurfaceOracleStorage.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {EnumerableSet} from \"@solidstate/contracts/utils/EnumerableSet.sol\";\r\n\r\nlibrary VolatilitySurfaceOracleStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.VolatilitySurfaceOracle\");\r\n\r\n uint256 internal constant COEFF_BITS = 51;\r\n uint256 internal constant COEFF_BITS_MINUS_ONE = 50;\r\n uint256 internal constant COEFF_AMOUNT = 5;\r\n // START_BIT = COEFF_BITS * (COEFF_AMOUNT - 1)\r\n uint256 internal constant START_BIT = 204;\r\n\r\n struct Update {\r\n uint256 updatedAt;\r\n bytes32 callCoefficients;\r\n bytes32 putCoefficients;\r\n }\r\n\r\n struct Layout {\r\n // Base token -> Underlying token -> Update\r\n mapping(address => mapping(address => Update)) volatilitySurfaces;\r\n // Relayer addresses which can be trusted to provide accurate option trades\r\n EnumerableSet.AddressSet whitelistedRelayers;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n\r\n function getCoefficients(\r\n Layout storage l,\r\n address baseToken,\r\n address underlyingToken,\r\n bool isCall\r\n ) internal view returns (bytes32) {\r\n Update storage u = l.volatilitySurfaces[baseToken][underlyingToken];\r\n return isCall ? u.callCoefficients : u.putCoefficients;\r\n }\r\n\r\n function parseVolatilitySurfaceCoefficients(bytes32 input)\r\n internal\r\n pure\r\n returns (int256[] memory coefficients)\r\n {\r\n coefficients = new int256[](COEFF_AMOUNT);\r\n\r\n // Value to add to negative numbers to cast them to int256\r\n int256 toAdd = (int256(-1) >> COEFF_BITS) << COEFF_BITS;\r\n\r\n assembly {\r\n let i := 0\r\n // Value equal to -1\r\n let mid := shl(COEFF_BITS_MINUS_ONE, 1)\r\n\r\n for {\r\n\r\n } lt(i, COEFF_AMOUNT) {\r\n\r\n } {\r\n let offset := sub(START_BIT, mul(COEFF_BITS, i))\r\n let coeff := shr(\r\n offset,\r\n sub(\r\n input,\r\n shl(\r\n add(offset, COEFF_BITS),\r\n shr(add(offset, COEFF_BITS), input)\r\n )\r\n )\r\n )\r\n\r\n // Check if value is a negative number and needs casting\r\n if or(eq(coeff, mid), gt(coeff, mid)) {\r\n coeff := add(coeff, toAdd)\r\n }\r\n\r\n // Store result in the coefficients array\r\n mstore(add(coefficients, add(0x20, mul(0x20, i))), coeff)\r\n\r\n i := add(i, 1)\r\n }\r\n }\r\n }\r\n\r\n function formatVolatilitySurfaceCoefficients(int256[5] memory coefficients)\r\n internal\r\n pure\r\n returns (bytes32 result)\r\n {\r\n for (uint256 i = 0; i < COEFF_AMOUNT; i++) {\r\n int256 max = int256(1 << COEFF_BITS_MINUS_ONE);\r\n require(\r\n coefficients[i] < max && coefficients[i] > -max,\r\n \"Out of bounds\"\r\n );\r\n }\r\n\r\n assembly {\r\n let i := 0\r\n\r\n for {\r\n\r\n } lt(i, COEFF_AMOUNT) {\r\n\r\n } {\r\n let offset := sub(START_BIT, mul(COEFF_BITS, i))\r\n let coeff := mload(add(coefficients, mul(0x20, i)))\r\n\r\n result := add(\r\n result,\r\n shl(\r\n offset,\r\n sub(coeff, shl(COEFF_BITS, shr(COEFF_BITS, coeff)))\r\n )\r\n )\r\n\r\n i := add(i, 1)\r\n }\r\n }\r\n }\r\n}\r\n" - }, - "@solidstate/contracts/token/ERC1155/enumerable/IERC1155Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC1155 enumerable and aggregate function interface\n */\ninterface IERC1155Enumerable {\n /**\n * @notice query total minted supply of given token\n * @param id token id to query\n * @return token supply\n */\n function totalSupply(uint256 id) external view returns (uint256);\n\n /**\n * @notice query total number of holders for given token\n * @param id token id to query\n * @return quantity of holders\n */\n function totalHolders(uint256 id) external view returns (uint256);\n\n /**\n * @notice query holders of given token\n * @param id token id to query\n * @return list of holder addresses\n */\n function accountsByToken(uint256 id)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice query tokens held by given address\n * @param account address to query\n * @return list of token ids\n */\n function tokensByAccount(address account)\n external\n view\n returns (uint256[] memory);\n}\n" - }, - "@solidstate/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20Internal } from './IERC20Internal.sol';\n\n/**\n * @title ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/20\n */\ninterface IERC20 is IERC20Internal {\n /**\n * @notice query the total minted token supply\n * @return token supply\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice query the token balance of given account\n * @param account address to query\n * @return token balance\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @notice query the allowance granted from given holder to given spender\n * @param holder approver of allowance\n * @param spender recipient of allowance\n * @return token allowance\n */\n function allowance(address holder, address spender)\n external\n view\n returns (uint256);\n\n /**\n * @notice grant approval to spender to spend tokens\n * @dev prefer ERC20Extended functions to avoid transaction-ordering vulnerability (see https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729)\n * @param spender recipient of allowance\n * @param amount quantity of tokens approved for spending\n * @return success status (always true; otherwise function should revert)\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @notice transfer tokens to given recipient\n * @param recipient beneficiary of token transfer\n * @param amount quantity of tokens to transfer\n * @return success status (always true; otherwise function should revert)\n */\n function transfer(address recipient, uint256 amount)\n external\n returns (bool);\n\n /**\n * @notice transfer tokens to given recipient on behalf of given holder\n * @param holder holder of tokens prior to transfer\n * @param recipient beneficiary of token transfer\n * @param amount quantity of tokens to transfer\n * @return success status (always true; otherwise function should revert)\n */\n function transferFrom(\n address holder,\n address recipient,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "contracts/mining/IPremiaMining.sol": { - "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {PremiaMiningStorage} from \"./PremiaMiningStorage.sol\";\r\n\r\ninterface IPremiaMining {\r\n function addPremiaRewards(uint256 _amount) external;\r\n\r\n function premiaRewardsAvailable() external view returns (uint256);\r\n\r\n function getTotalAllocationPoints() external view returns (uint256);\r\n\r\n function getPoolInfo(address pool, bool isCallPool)\r\n external\r\n view\r\n returns (PremiaMiningStorage.PoolInfo memory);\r\n\r\n function getPremiaPerYear() external view returns (uint256);\r\n\r\n function addPool(address _pool, uint256 _allocPoints) external;\r\n\r\n function setPoolAllocPoints(\r\n address[] memory _pools,\r\n uint256[] memory _allocPoints\r\n ) external;\r\n\r\n function pendingPremia(\r\n address _pool,\r\n bool _isCallPool,\r\n address _user\r\n ) external view returns (uint256);\r\n\r\n function updatePool(\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _totalTVL\r\n ) external;\r\n\r\n function allocatePending(\r\n address _user,\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _userTVLOld,\r\n uint256 _userTVLNew,\r\n uint256 _totalTVL\r\n ) external;\r\n\r\n function claim(\r\n address _user,\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _userTVLOld,\r\n uint256 _userTVLNew,\r\n uint256 _totalTVL\r\n ) external;\r\n}\r\n" - }, - "@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableStorage.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\n\nlibrary ERC1155EnumerableStorage {\n struct Layout {\n mapping(uint256 => uint256) totalSupply;\n mapping(uint256 => EnumerableSet.AddressSet) accountsByToken;\n mapping(address => EnumerableSet.UintSet) tokensByAccount;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.ERC1155Enumerable');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n" - }, - "@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableInternal.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\nimport { ERC1155BaseInternal, ERC1155BaseStorage } from '../base/ERC1155BaseInternal.sol';\nimport { ERC1155EnumerableStorage } from './ERC1155EnumerableStorage.sol';\n\n/**\n * @title ERC1155Enumerable internal functions\n */\nabstract contract ERC1155EnumerableInternal is ERC1155BaseInternal {\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /**\n * @notice ERC1155 hook: update aggregate values\n * @inheritdoc ERC1155BaseInternal\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n\n if (from != to) {\n ERC1155EnumerableStorage.Layout storage l = ERC1155EnumerableStorage\n .layout();\n mapping(uint256 => EnumerableSet.AddressSet)\n storage tokenAccounts = l.accountsByToken;\n EnumerableSet.UintSet storage fromTokens = l.tokensByAccount[from];\n EnumerableSet.UintSet storage toTokens = l.tokensByAccount[to];\n\n for (uint256 i; i < ids.length; i++) {\n uint256 amount = amounts[i];\n\n if (amount > 0) {\n uint256 id = ids[i];\n\n if (from == address(0)) {\n l.totalSupply[id] += amount;\n } else if (_balanceOf(from, id) == amount) {\n tokenAccounts[id].remove(from);\n fromTokens.remove(id);\n }\n\n if (to == address(0)) {\n l.totalSupply[id] -= amount;\n } else if (_balanceOf(to, id) == 0) {\n tokenAccounts[id].add(to);\n toTokens.add(id);\n }\n }\n }\n }\n }\n}\n" - }, - "contracts/oracle/IVolatilitySurfaceOracle.sol": { - "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {VolatilitySurfaceOracleStorage} from \"./VolatilitySurfaceOracleStorage.sol\";\r\n\r\ninterface IVolatilitySurfaceOracle {\r\n function getWhitelistedRelayers() external view returns (address[] memory);\r\n\r\n function getVolatilitySurface(address baseToken, address underlyingToken)\r\n external\r\n view\r\n returns (VolatilitySurfaceOracleStorage.Update memory);\r\n\r\n function getVolatilitySurfaceCoefficientsUnpacked(\r\n address baseToken,\r\n address underlyingToken,\r\n bool isCall\r\n ) external view returns (int256[] memory);\r\n\r\n function getTimeToMaturity64x64(uint64 maturity)\r\n external\r\n view\r\n returns (int128);\r\n\r\n function getAnnualizedVolatility64x64(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 spot64x64,\r\n int128 strike64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (int128);\r\n\r\n function getBlackScholesPrice64x64(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (int128);\r\n\r\n function getBlackScholesPrice(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (uint256);\r\n}\r\n" - }, - "contracts/pool/PoolInternal.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {IERC173} from \"@solidstate/contracts/access/IERC173.sol\";\r\nimport {OwnableStorage} from \"@solidstate/contracts/access/OwnableStorage.sol\";\r\nimport {IERC20} from \"@solidstate/contracts/token/ERC20/IERC20.sol\";\r\nimport {ERC1155EnumerableInternal, ERC1155EnumerableStorage, EnumerableSet} from \"@solidstate/contracts/token/ERC1155/enumerable/ERC1155Enumerable.sol\";\r\nimport {IWETH} from \"@solidstate/contracts/utils/IWETH.sol\";\r\n\r\nimport {PoolStorage} from \"./PoolStorage.sol\";\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\nimport {ABDKMath64x64Token} from \"../libraries/ABDKMath64x64Token.sol\";\r\nimport {OptionMath} from \"../libraries/OptionMath.sol\";\r\nimport {IFeeDiscount} from \"../staking/IFeeDiscount.sol\";\r\nimport {IPoolEvents} from \"./IPoolEvents.sol\";\r\nimport {IPremiaMining} from \"../mining/IPremiaMining.sol\";\r\nimport {IVolatilitySurfaceOracle} from \"../oracle/IVolatilitySurfaceOracle.sol\";\r\n\r\n/**\r\n * @title Premia option pool\r\n * @dev deployed standalone and referenced by PoolProxy\r\n */\r\ncontract PoolInternal is IPoolEvents, ERC1155EnumerableInternal {\r\n using ABDKMath64x64 for int128;\r\n using EnumerableSet for EnumerableSet.AddressSet;\r\n using EnumerableSet for EnumerableSet.UintSet;\r\n using PoolStorage for PoolStorage.Layout;\r\n\r\n address internal immutable WETH_ADDRESS;\r\n address internal immutable PREMIA_MINING_ADDRESS;\r\n address internal immutable FEE_RECEIVER_ADDRESS;\r\n address internal immutable FEE_DISCOUNT_ADDRESS;\r\n address internal immutable IVOL_ORACLE_ADDRESS;\r\n\r\n int128 internal immutable FEE_64x64;\r\n\r\n uint256 internal immutable UNDERLYING_FREE_LIQ_TOKEN_ID;\r\n uint256 internal immutable BASE_FREE_LIQ_TOKEN_ID;\r\n\r\n uint256 internal immutable UNDERLYING_RESERVED_LIQ_TOKEN_ID;\r\n uint256 internal immutable BASE_RESERVED_LIQ_TOKEN_ID;\r\n\r\n uint256 internal constant INVERSE_BASIS_POINT = 1e4;\r\n uint256 internal constant BATCHING_PERIOD = 260;\r\n\r\n // Minimum APY for capital locked up to underwrite options.\r\n // The quote will return a minimum price corresponding to this APY\r\n int128 internal constant MIN_APY_64x64 = 0x4ccccccccccccccd; // 0.3\r\n\r\n constructor(\r\n address ivolOracle,\r\n address weth,\r\n address premiaMining,\r\n address feeReceiver,\r\n address feeDiscountAddress,\r\n int128 fee64x64\r\n ) {\r\n IVOL_ORACLE_ADDRESS = ivolOracle;\r\n WETH_ADDRESS = weth;\r\n PREMIA_MINING_ADDRESS = premiaMining;\r\n FEE_RECEIVER_ADDRESS = feeReceiver;\r\n // PremiaFeeDiscount contract address\r\n FEE_DISCOUNT_ADDRESS = feeDiscountAddress;\r\n FEE_64x64 = fee64x64;\r\n\r\n UNDERLYING_FREE_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.UNDERLYING_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n BASE_FREE_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n UNDERLYING_RESERVED_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.UNDERLYING_RESERVED_LIQ,\r\n 0,\r\n 0\r\n );\r\n BASE_RESERVED_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.BASE_RESERVED_LIQ,\r\n 0,\r\n 0\r\n );\r\n }\r\n\r\n modifier onlyProtocolOwner() {\r\n require(\r\n msg.sender == IERC173(OwnableStorage.layout().owner).owner(),\r\n \"Not protocol owner\"\r\n );\r\n _;\r\n }\r\n\r\n function _getFeeDiscount(address feePayer)\r\n internal\r\n view\r\n returns (uint256 discount)\r\n {\r\n if (FEE_DISCOUNT_ADDRESS != address(0)) {\r\n discount = IFeeDiscount(FEE_DISCOUNT_ADDRESS).getDiscount(feePayer);\r\n }\r\n }\r\n\r\n function _getFeeWithDiscount(address feePayer, uint256 fee)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n uint256 discount = _getFeeDiscount(feePayer);\r\n return fee - ((fee * discount) / INVERSE_BASIS_POINT);\r\n }\r\n\r\n function _withdrawFees(bool isCall) internal returns (uint256 amount) {\r\n uint256 tokenId = _getReservedLiquidityTokenId(isCall);\r\n amount = _balanceOf(FEE_RECEIVER_ADDRESS, tokenId);\r\n\r\n if (amount > 0) {\r\n _burn(FEE_RECEIVER_ADDRESS, tokenId, amount);\r\n emit FeeWithdrawal(isCall, amount);\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate price of option contract\r\n * @param args structured quote arguments\r\n * @return result quote result\r\n */\r\n function _quote(PoolStorage.QuoteArgsInternal memory args)\r\n internal\r\n view\r\n returns (PoolStorage.QuoteResultInternal memory result)\r\n {\r\n require(\r\n args.strike64x64 > 0 && args.spot64x64 > 0 && args.maturity > 0,\r\n \"invalid args\"\r\n );\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n int128 contractSize64x64 = ABDKMath64x64Token.fromDecimals(\r\n args.contractSize,\r\n l.underlyingDecimals\r\n );\r\n bool isCall = args.isCall;\r\n\r\n (int128 adjustedCLevel64x64, int128 oldLiquidity64x64) = l\r\n .applyCLevelPendingDepositAdjustment(\r\n l.getDecayAdjustedCLevel64x64(isCall),\r\n l.totalFreeLiquiditySupply64x64(isCall),\r\n isCall\r\n );\r\n\r\n require(oldLiquidity64x64 > 0, \"no liq\");\r\n\r\n int128 timeToMaturity64x64 = ABDKMath64x64.divu(\r\n args.maturity - block.timestamp,\r\n 365 days\r\n );\r\n\r\n int128 annualizedVolatility64x64 = IVolatilitySurfaceOracle(\r\n IVOL_ORACLE_ADDRESS\r\n ).getAnnualizedVolatility64x64(\r\n l.base,\r\n l.underlying,\r\n args.spot64x64,\r\n args.strike64x64,\r\n timeToMaturity64x64,\r\n isCall\r\n );\r\n\r\n require(annualizedVolatility64x64 > 0, \"vol = 0\");\r\n\r\n (\r\n int128 price64x64,\r\n int128 cLevel64x64,\r\n int128 slippageCoefficient64x64\r\n ) = OptionMath.quotePrice(\r\n OptionMath.QuoteArgs(\r\n annualizedVolatility64x64.mul(annualizedVolatility64x64),\r\n args.strike64x64,\r\n args.spot64x64,\r\n timeToMaturity64x64,\r\n adjustedCLevel64x64,\r\n oldLiquidity64x64,\r\n oldLiquidity64x64.sub(contractSize64x64),\r\n 0x10000000000000000, // 64x64 fixed point representation of 1\r\n MIN_APY_64x64,\r\n isCall\r\n )\r\n );\r\n\r\n result.baseCost64x64 = isCall\r\n ? price64x64.mul(contractSize64x64).div(args.spot64x64)\r\n : price64x64.mul(contractSize64x64);\r\n result.feeCost64x64 = result.baseCost64x64.mul(FEE_64x64);\r\n result.cLevel64x64 = cLevel64x64;\r\n result.slippageCoefficient64x64 = slippageCoefficient64x64;\r\n\r\n int128 discount = ABDKMath64x64.divu(\r\n _getFeeDiscount(args.feePayer),\r\n INVERSE_BASIS_POINT\r\n );\r\n result.feeCost64x64 -= result.feeCost64x64.mul(discount);\r\n }\r\n\r\n /**\r\n * @notice burn corresponding long and short option tokens\r\n * @param account holder of tokens to annihilate\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize quantity of option contract tokens to annihilate\r\n */\r\n function _annihilate(\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize\r\n ) internal {\r\n uint256 longTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, true),\r\n maturity,\r\n strike64x64\r\n );\r\n uint256 shortTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n _burn(account, longTokenId, contractSize);\r\n _burn(account, shortTokenId, contractSize);\r\n\r\n emit Annihilate(shortTokenId, contractSize);\r\n }\r\n\r\n /**\r\n * @notice purchase option\r\n * @param l storage layout struct\r\n * @param account recipient of purchased option\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize size of option contract\r\n * @param newPrice64x64 64x64 fixed point representation of current spot price\r\n * @return baseCost quantity of tokens required to purchase long position\r\n * @return feeCost quantity of tokens required to pay fees\r\n */\r\n function _purchase(\r\n PoolStorage.Layout storage l,\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize,\r\n int128 newPrice64x64\r\n ) internal returns (uint256 baseCost, uint256 feeCost) {\r\n require(maturity > block.timestamp, \"expired\");\r\n require(contractSize >= l.underlyingMinimum, \"too small\");\r\n\r\n {\r\n uint256 size = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(\r\n strike64x64.mulu(contractSize)\r\n );\r\n\r\n require(\r\n size <=\r\n ERC1155EnumerableStorage.layout().totalSupply[\r\n _getFreeLiquidityTokenId(isCall)\r\n ] -\r\n l.nextDeposits[isCall].totalPendingDeposits,\r\n \"insuf liq\"\r\n );\r\n }\r\n\r\n PoolStorage.QuoteResultInternal memory quote = _quote(\r\n PoolStorage.QuoteArgsInternal(\r\n account,\r\n maturity,\r\n strike64x64,\r\n newPrice64x64,\r\n contractSize,\r\n isCall\r\n )\r\n );\r\n\r\n baseCost = ABDKMath64x64Token.toDecimals(\r\n quote.baseCost64x64,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n feeCost = ABDKMath64x64Token.toDecimals(\r\n quote.feeCost64x64,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n uint256 longTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, true),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n uint256 shortTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n // mint long option token for buyer\r\n _mint(account, longTokenId, contractSize);\r\n\r\n int128 oldLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n // burn free liquidity tokens from other underwriters\r\n _mintShortTokenLoop(\r\n l,\r\n account,\r\n contractSize,\r\n baseCost,\r\n shortTokenId,\r\n isCall\r\n );\r\n int128 newLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n\r\n _setCLevel(l, oldLiquidity64x64, newLiquidity64x64, isCall);\r\n\r\n // mint reserved liquidity tokens for fee receiver\r\n _mint(\r\n FEE_RECEIVER_ADDRESS,\r\n _getReservedLiquidityTokenId(isCall),\r\n feeCost\r\n );\r\n\r\n emit Purchase(\r\n account,\r\n longTokenId,\r\n contractSize,\r\n baseCost,\r\n feeCost,\r\n newPrice64x64\r\n );\r\n }\r\n\r\n /**\r\n * @notice reassign short position to new underwriter\r\n * @param l storage layout struct\r\n * @param account holder of positions to be reassigned\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize quantity of option contract tokens to reassign\r\n * @param newPrice64x64 64x64 fixed point representation of current spot price\r\n * @return baseCost quantity of tokens required to reassign short position\r\n * @return feeCost quantity of tokens required to pay fees\r\n * @return amountOut quantity of liquidity freed\r\n */\r\n function _reassign(\r\n PoolStorage.Layout storage l,\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize,\r\n int128 newPrice64x64\r\n )\r\n internal\r\n returns (\r\n uint256 baseCost,\r\n uint256 feeCost,\r\n uint256 amountOut\r\n )\r\n {\r\n (baseCost, feeCost) = _purchase(\r\n l,\r\n account,\r\n maturity,\r\n strike64x64,\r\n isCall,\r\n contractSize,\r\n newPrice64x64\r\n );\r\n\r\n _annihilate(account, maturity, strike64x64, isCall, contractSize);\r\n\r\n uint256 annihilateAmount = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(contractSize));\r\n\r\n amountOut = annihilateAmount - baseCost - feeCost;\r\n }\r\n\r\n /**\r\n * @notice exercise option on behalf of holder\r\n * @dev used for processing of expired options if passed holder is zero address\r\n * @param holder owner of long option tokens to exercise\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to exercise\r\n */\r\n function _exercise(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) internal {\r\n uint64 maturity;\r\n int128 strike64x64;\r\n bool isCall;\r\n\r\n bool onlyExpired = holder == address(0);\r\n\r\n {\r\n PoolStorage.TokenType tokenType;\r\n (tokenType, maturity, strike64x64) = PoolStorage.parseTokenId(\r\n longTokenId\r\n );\r\n require(\r\n tokenType == PoolStorage.TokenType.LONG_CALL ||\r\n tokenType == PoolStorage.TokenType.LONG_PUT,\r\n \"invalid type\"\r\n );\r\n require(!onlyExpired || maturity < block.timestamp, \"not expired\");\r\n isCall = tokenType == PoolStorage.TokenType.LONG_CALL;\r\n }\r\n\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n int128 spot64x64 = _update(l);\r\n\r\n if (maturity < block.timestamp) {\r\n spot64x64 = l.getPriceUpdateAfter(maturity);\r\n }\r\n\r\n require(\r\n onlyExpired ||\r\n (\r\n isCall\r\n ? (spot64x64 > strike64x64)\r\n : (spot64x64 < strike64x64)\r\n ),\r\n \"not ITM\"\r\n );\r\n\r\n uint256 exerciseValue;\r\n // option has a non-zero exercise value\r\n if (isCall) {\r\n if (spot64x64 > strike64x64) {\r\n exerciseValue = spot64x64.sub(strike64x64).div(spot64x64).mulu(\r\n contractSize\r\n );\r\n }\r\n } else {\r\n if (spot64x64 < strike64x64) {\r\n exerciseValue = l.fromUnderlyingToBaseDecimals(\r\n strike64x64.sub(spot64x64).mulu(contractSize)\r\n );\r\n }\r\n }\r\n\r\n uint256 totalFee;\r\n\r\n if (onlyExpired) {\r\n totalFee += _burnLongTokenLoop(\r\n contractSize,\r\n exerciseValue,\r\n longTokenId,\r\n isCall\r\n );\r\n } else {\r\n // burn long option tokens from sender\r\n _burn(holder, longTokenId, contractSize);\r\n\r\n uint256 fee;\r\n\r\n if (exerciseValue > 0) {\r\n fee = _getFeeWithDiscount(\r\n holder,\r\n FEE_64x64.mulu(exerciseValue)\r\n );\r\n totalFee += fee;\r\n\r\n _pushTo(holder, _getPoolToken(isCall), exerciseValue - fee);\r\n }\r\n\r\n emit Exercise(\r\n holder,\r\n longTokenId,\r\n contractSize,\r\n exerciseValue,\r\n fee\r\n );\r\n }\r\n\r\n totalFee += _burnShortTokenLoop(\r\n contractSize,\r\n exerciseValue,\r\n PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n ),\r\n isCall\r\n );\r\n\r\n _mint(\r\n FEE_RECEIVER_ADDRESS,\r\n _getReservedLiquidityTokenId(isCall),\r\n totalFee\r\n );\r\n }\r\n\r\n function _mintShortTokenLoop(\r\n PoolStorage.Layout storage l,\r\n address buyer,\r\n uint256 contractSize,\r\n uint256 premium,\r\n uint256 shortTokenId,\r\n bool isCall\r\n ) internal {\r\n uint256 freeLiqTokenId = _getFreeLiquidityTokenId(isCall);\r\n (, , int128 strike64x64) = PoolStorage.parseTokenId(shortTokenId);\r\n\r\n uint256 toPay = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(contractSize));\r\n\r\n while (toPay > 0) {\r\n address underwriter = l.liquidityQueueAscending[isCall][address(0)];\r\n uint256 balance = _balanceOf(underwriter, freeLiqTokenId);\r\n\r\n // If dust left, we remove underwriter and skip to next\r\n if (balance < _getMinimumAmount(l, isCall)) {\r\n l.removeUnderwriter(underwriter, isCall);\r\n continue;\r\n }\r\n\r\n if (!l.getReinvestmentStatus(underwriter, isCall)) {\r\n _burn(underwriter, freeLiqTokenId, balance);\r\n _mint(\r\n underwriter,\r\n _getReservedLiquidityTokenId(isCall),\r\n balance\r\n );\r\n _subUserTVL(l, underwriter, isCall, balance);\r\n continue;\r\n }\r\n\r\n // amount of liquidity provided by underwriter, accounting for reinvested premium\r\n uint256 intervalContractSize = ((balance -\r\n l.pendingDeposits[underwriter][l.nextDeposits[isCall].eta][\r\n isCall\r\n ]) * (toPay + premium)) / toPay;\r\n if (intervalContractSize == 0) continue;\r\n if (intervalContractSize > toPay) intervalContractSize = toPay;\r\n\r\n // amount of premium paid to underwriter\r\n uint256 intervalPremium = (premium * intervalContractSize) / toPay;\r\n premium -= intervalPremium;\r\n toPay -= intervalContractSize;\r\n _addUserTVL(l, underwriter, isCall, intervalPremium);\r\n\r\n // burn free liquidity tokens from underwriter\r\n _burn(\r\n underwriter,\r\n freeLiqTokenId,\r\n intervalContractSize - intervalPremium\r\n );\r\n\r\n if (isCall == false) {\r\n // For PUT, conversion to contract amount is done here (Prior to this line, it is token amount)\r\n intervalContractSize = l.fromBaseToUnderlyingDecimals(\r\n strike64x64.inv().mulu(intervalContractSize)\r\n );\r\n }\r\n\r\n // mint short option tokens for underwriter\r\n // toPay == 0 ? contractSize : intervalContractSize : To prevent minting less than amount,\r\n // because of rounding (Can happen for put, because of fixed point precision)\r\n _mint(\r\n underwriter,\r\n shortTokenId,\r\n toPay == 0 ? contractSize : intervalContractSize\r\n );\r\n\r\n emit Underwrite(\r\n underwriter,\r\n buyer,\r\n shortTokenId,\r\n toPay == 0 ? contractSize : intervalContractSize,\r\n intervalPremium,\r\n false\r\n );\r\n\r\n contractSize -= intervalContractSize;\r\n }\r\n }\r\n\r\n function _burnLongTokenLoop(\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 longTokenId,\r\n bool isCall\r\n ) internal returns (uint256 totalFee) {\r\n EnumerableSet.AddressSet storage holders = ERC1155EnumerableStorage\r\n .layout()\r\n .accountsByToken[longTokenId];\r\n\r\n while (contractSize > 0) {\r\n address longTokenHolder = holders.at(holders.length() - 1);\r\n\r\n uint256 intervalContractSize = _balanceOf(\r\n longTokenHolder,\r\n longTokenId\r\n );\r\n if (intervalContractSize > contractSize)\r\n intervalContractSize = contractSize;\r\n\r\n uint256 intervalExerciseValue;\r\n\r\n uint256 fee;\r\n if (exerciseValue > 0) {\r\n intervalExerciseValue =\r\n (exerciseValue * intervalContractSize) /\r\n contractSize;\r\n\r\n fee = _getFeeWithDiscount(\r\n longTokenHolder,\r\n FEE_64x64.mulu(intervalExerciseValue)\r\n );\r\n totalFee += fee;\r\n\r\n exerciseValue -= intervalExerciseValue;\r\n _pushTo(\r\n longTokenHolder,\r\n _getPoolToken(isCall),\r\n intervalExerciseValue - fee\r\n );\r\n }\r\n\r\n contractSize -= intervalContractSize;\r\n\r\n emit Exercise(\r\n longTokenHolder,\r\n longTokenId,\r\n intervalContractSize,\r\n intervalExerciseValue - fee,\r\n fee\r\n );\r\n\r\n _burn(longTokenHolder, longTokenId, intervalContractSize);\r\n }\r\n }\r\n\r\n function _burnShortTokenLoop(\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 shortTokenId,\r\n bool isCall\r\n ) internal returns (uint256 totalFee) {\r\n EnumerableSet.AddressSet storage underwriters = ERC1155EnumerableStorage\r\n .layout()\r\n .accountsByToken[shortTokenId];\r\n (, , int128 strike64x64) = PoolStorage.parseTokenId(shortTokenId);\r\n\r\n while (contractSize > 0) {\r\n address underwriter = underwriters.at(underwriters.length() - 1);\r\n\r\n // amount of liquidity provided by underwriter\r\n uint256 intervalContractSize = _balanceOf(\r\n underwriter,\r\n shortTokenId\r\n );\r\n if (intervalContractSize > contractSize)\r\n intervalContractSize = contractSize;\r\n\r\n // amount of value claimed by buyer\r\n uint256 intervalExerciseValue = (exerciseValue *\r\n intervalContractSize) / contractSize;\r\n exerciseValue -= intervalExerciseValue;\r\n contractSize -= intervalContractSize;\r\n\r\n uint256 freeLiq = isCall\r\n ? intervalContractSize - intervalExerciseValue\r\n : PoolStorage.layout().fromUnderlyingToBaseDecimals(\r\n strike64x64.mulu(intervalContractSize)\r\n ) - intervalExerciseValue;\r\n\r\n uint256 fee = _getFeeWithDiscount(\r\n underwriter,\r\n FEE_64x64.mulu(freeLiq)\r\n );\r\n totalFee += fee;\r\n\r\n uint256 tvlToSubtract = intervalExerciseValue;\r\n\r\n // mint free liquidity tokens for underwriter\r\n if (\r\n PoolStorage.layout().getReinvestmentStatus(underwriter, isCall)\r\n ) {\r\n _addToDepositQueue(underwriter, freeLiq - fee, isCall);\r\n tvlToSubtract += fee;\r\n } else {\r\n _mint(\r\n underwriter,\r\n _getReservedLiquidityTokenId(isCall),\r\n freeLiq - fee\r\n );\r\n tvlToSubtract += freeLiq;\r\n }\r\n\r\n _subUserTVL(\r\n PoolStorage.layout(),\r\n underwriter,\r\n isCall,\r\n tvlToSubtract\r\n );\r\n\r\n // burn short option tokens from underwriter\r\n _burn(underwriter, shortTokenId, intervalContractSize);\r\n\r\n emit AssignExercise(\r\n underwriter,\r\n shortTokenId,\r\n freeLiq - fee,\r\n intervalContractSize,\r\n fee\r\n );\r\n }\r\n }\r\n\r\n function _addToDepositQueue(\r\n address account,\r\n uint256 amount,\r\n bool isCallPool\r\n ) internal {\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n _mint(account, _getFreeLiquidityTokenId(isCallPool), amount);\r\n\r\n uint256 nextBatch = (block.timestamp / BATCHING_PERIOD) *\r\n BATCHING_PERIOD +\r\n BATCHING_PERIOD;\r\n l.pendingDeposits[account][nextBatch][isCallPool] += amount;\r\n\r\n PoolStorage.BatchData storage batchData = l.nextDeposits[isCallPool];\r\n batchData.totalPendingDeposits += amount;\r\n batchData.eta = nextBatch;\r\n }\r\n\r\n function _processPendingDeposits(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n {\r\n PoolStorage.BatchData storage data = l.nextDeposits[isCall];\r\n\r\n if (data.eta == 0 || block.timestamp < data.eta) return;\r\n\r\n int128 oldLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n\r\n _setCLevel(\r\n l,\r\n oldLiquidity64x64,\r\n oldLiquidity64x64.add(\r\n ABDKMath64x64Token.fromDecimals(\r\n data.totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n )\r\n ),\r\n isCall\r\n );\r\n\r\n delete l.nextDeposits[isCall];\r\n }\r\n\r\n function _getFreeLiquidityTokenId(bool isCall)\r\n internal\r\n view\r\n returns (uint256 freeLiqTokenId)\r\n {\r\n freeLiqTokenId = isCall\r\n ? UNDERLYING_FREE_LIQ_TOKEN_ID\r\n : BASE_FREE_LIQ_TOKEN_ID;\r\n }\r\n\r\n function _getReservedLiquidityTokenId(bool isCall)\r\n internal\r\n view\r\n returns (uint256 reservedLiqTokenId)\r\n {\r\n reservedLiqTokenId = isCall\r\n ? UNDERLYING_RESERVED_LIQ_TOKEN_ID\r\n : BASE_RESERVED_LIQ_TOKEN_ID;\r\n }\r\n\r\n function _getPoolToken(bool isCall) internal view returns (address token) {\r\n token = isCall\r\n ? PoolStorage.layout().underlying\r\n : PoolStorage.layout().base;\r\n }\r\n\r\n function _getTokenType(bool isCall, bool isLong)\r\n internal\r\n pure\r\n returns (PoolStorage.TokenType tokenType)\r\n {\r\n if (isCall) {\r\n tokenType = isLong\r\n ? PoolStorage.TokenType.LONG_CALL\r\n : PoolStorage.TokenType.SHORT_CALL;\r\n } else {\r\n tokenType = isLong\r\n ? PoolStorage.TokenType.LONG_PUT\r\n : PoolStorage.TokenType.SHORT_PUT;\r\n }\r\n }\r\n\r\n function _getMinimumAmount(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint256 minimumAmount)\r\n {\r\n minimumAmount = isCall ? l.underlyingMinimum : l.baseMinimum;\r\n }\r\n\r\n function _getPoolCapAmount(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint256 poolCapAmount)\r\n {\r\n poolCapAmount = isCall ? l.underlyingPoolCap : l.basePoolCap;\r\n }\r\n\r\n function _setCLevel(\r\n PoolStorage.Layout storage l,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64,\r\n bool isCallPool\r\n ) internal {\r\n int128 oldCLevel64x64 = l.getDecayAdjustedCLevel64x64(isCallPool);\r\n\r\n int128 cLevel64x64 = l.applyCLevelLiquidityChangeAdjustment(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64,\r\n isCallPool\r\n );\r\n\r\n l.setCLevel(cLevel64x64, isCallPool);\r\n\r\n emit UpdateCLevel(\r\n isCallPool,\r\n cLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate and store updated market state\r\n * @param l storage layout struct\r\n * @return newPrice64x64 64x64 fixed point representation of current spot price\r\n */\r\n function _update(PoolStorage.Layout storage l)\r\n internal\r\n returns (int128 newPrice64x64)\r\n {\r\n if (l.updatedAt == block.timestamp) {\r\n return (l.getPriceUpdate(block.timestamp));\r\n }\r\n\r\n newPrice64x64 = l.fetchPriceUpdate();\r\n\r\n if (l.getPriceUpdate(block.timestamp) == 0) {\r\n l.setPriceUpdate(block.timestamp, newPrice64x64);\r\n }\r\n\r\n l.updatedAt = block.timestamp;\r\n\r\n _processPendingDeposits(l, true);\r\n _processPendingDeposits(l, false);\r\n }\r\n\r\n /**\r\n * @notice transfer ERC20 tokens to message sender\r\n * @param token ERC20 token address\r\n * @param amount quantity of token to transfer\r\n */\r\n function _pushTo(\r\n address to,\r\n address token,\r\n uint256 amount\r\n ) internal {\r\n if (amount == 0) return;\r\n\r\n require(IERC20(token).transfer(to, amount), \"ERC20 transfer failed\");\r\n }\r\n\r\n /**\r\n * @notice transfer ERC20 tokens from message sender\r\n * @param from address from which tokens are pulled from\r\n * @param token ERC20 token address\r\n * @param amount quantity of token to transfer\r\n * @param skipWethDeposit if false, will not try to deposit weth from attach eth\r\n */\r\n function _pullFrom(\r\n address from,\r\n address token,\r\n uint256 amount,\r\n bool skipWethDeposit\r\n ) internal {\r\n if (!skipWethDeposit) {\r\n if (token == WETH_ADDRESS) {\r\n if (msg.value > 0) {\r\n if (msg.value > amount) {\r\n IWETH(WETH_ADDRESS).deposit{value: amount}();\r\n\r\n (bool success, ) = payable(msg.sender).call{\r\n value: msg.value - amount\r\n }(\"\");\r\n\r\n require(success, \"ETH refund failed\");\r\n\r\n amount = 0;\r\n } else {\r\n unchecked {\r\n amount -= msg.value;\r\n }\r\n\r\n IWETH(WETH_ADDRESS).deposit{value: msg.value}();\r\n }\r\n }\r\n } else {\r\n require(msg.value == 0, \"not WETH deposit\");\r\n }\r\n }\r\n\r\n if (amount > 0) {\r\n require(\r\n IERC20(token).transferFrom(from, address(this), amount),\r\n \"ERC20 transfer failed\"\r\n );\r\n }\r\n }\r\n\r\n function _mint(\r\n address account,\r\n uint256 tokenId,\r\n uint256 amount\r\n ) internal {\r\n _mint(account, tokenId, amount, \"\");\r\n }\r\n\r\n function _addUserTVL(\r\n PoolStorage.Layout storage l,\r\n address user,\r\n bool isCallPool,\r\n uint256 amount\r\n ) internal {\r\n uint256 userTVL = l.userTVL[user][isCallPool];\r\n uint256 totalTVL = l.totalTVL[isCallPool];\r\n\r\n IPremiaMining(PREMIA_MINING_ADDRESS).allocatePending(\r\n user,\r\n address(this),\r\n isCallPool,\r\n userTVL,\r\n userTVL + amount,\r\n totalTVL\r\n );\r\n\r\n l.userTVL[user][isCallPool] = userTVL + amount;\r\n l.totalTVL[isCallPool] = totalTVL + amount;\r\n }\r\n\r\n function _subUserTVL(\r\n PoolStorage.Layout storage l,\r\n address user,\r\n bool isCallPool,\r\n uint256 amount\r\n ) internal {\r\n uint256 userTVL = l.userTVL[user][isCallPool];\r\n uint256 totalTVL = l.totalTVL[isCallPool];\r\n\r\n IPremiaMining(PREMIA_MINING_ADDRESS).allocatePending(\r\n user,\r\n address(this),\r\n isCallPool,\r\n userTVL,\r\n userTVL - amount,\r\n totalTVL\r\n );\r\n l.userTVL[user][isCallPool] = userTVL - amount;\r\n l.totalTVL[isCallPool] = totalTVL - amount;\r\n }\r\n\r\n /**\r\n * @notice ERC1155 hook: track eligible underwriters\r\n * @param operator transaction sender\r\n * @param from token sender\r\n * @param to token receiver\r\n * @param ids token ids transferred\r\n * @param amounts token quantities transferred\r\n * @param data data payload\r\n */\r\n function _beforeTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual override {\r\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n for (uint256 i; i < ids.length; i++) {\r\n uint256 id = ids[i];\r\n uint256 amount = amounts[i];\r\n\r\n if (amount == 0) continue;\r\n\r\n if (from == address(0)) {\r\n l.tokenIds.add(id);\r\n }\r\n\r\n if (\r\n to == address(0) &&\r\n ERC1155EnumerableStorage.layout().totalSupply[id] == 0\r\n ) {\r\n l.tokenIds.remove(id);\r\n }\r\n\r\n // prevent transfer of free and reserved liquidity during waiting period\r\n\r\n if (\r\n id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == BASE_FREE_LIQ_TOKEN_ID ||\r\n id == UNDERLYING_RESERVED_LIQ_TOKEN_ID ||\r\n id == BASE_RESERVED_LIQ_TOKEN_ID\r\n ) {\r\n if (from != address(0) && to != address(0)) {\r\n bool isCallPool = id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == UNDERLYING_RESERVED_LIQ_TOKEN_ID;\r\n\r\n require(\r\n l.depositedAt[from][isCallPool] + (1 days) <\r\n block.timestamp,\r\n \"liq lock 1d\"\r\n );\r\n }\r\n }\r\n\r\n if (\r\n id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == BASE_FREE_LIQ_TOKEN_ID\r\n ) {\r\n bool isCallPool = id == UNDERLYING_FREE_LIQ_TOKEN_ID;\r\n uint256 minimum = _getMinimumAmount(l, isCallPool);\r\n\r\n if (from != address(0)) {\r\n uint256 balance = _balanceOf(from, id);\r\n\r\n if (balance > minimum && balance <= amount + minimum) {\r\n require(\r\n balance -\r\n l.pendingDeposits[from][\r\n l.nextDeposits[isCallPool].eta\r\n ][isCallPool] >=\r\n amount,\r\n \"Insuf balance\"\r\n );\r\n l.removeUnderwriter(from, isCallPool);\r\n }\r\n\r\n if (to != address(0)) {\r\n _subUserTVL(l, from, isCallPool, amounts[i]);\r\n _addUserTVL(l, to, isCallPool, amounts[i]);\r\n }\r\n }\r\n\r\n if (to != address(0)) {\r\n uint256 balance = _balanceOf(to, id);\r\n\r\n if (balance <= minimum && balance + amount > minimum) {\r\n l.addUnderwriter(to, isCallPool);\r\n }\r\n }\r\n }\r\n\r\n // Update userTVL on SHORT options transfers\r\n (\r\n PoolStorage.TokenType tokenType,\r\n ,\r\n int128 strike64x64\r\n ) = PoolStorage.parseTokenId(id);\r\n\r\n if (\r\n (from != address(0) && to != address(0)) &&\r\n (tokenType == PoolStorage.TokenType.SHORT_CALL ||\r\n tokenType == PoolStorage.TokenType.SHORT_PUT)\r\n ) {\r\n bool isCall = tokenType == PoolStorage.TokenType.SHORT_CALL;\r\n uint256 collateral = isCall\r\n ? amount\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(amount));\r\n\r\n _subUserTVL(l, from, isCall, collateral);\r\n _addUserTVL(l, to, isCall, collateral);\r\n }\r\n }\r\n }\r\n}\r\n" - }, - "@solidstate/contracts/token/ERC1155/base/ERC1155BaseStorage.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary ERC1155BaseStorage {\n struct Layout {\n mapping(uint256 => mapping(address => uint256)) balances;\n mapping(address => mapping(address => bool)) operatorApprovals;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.ERC1155Base');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n" - }, - "@solidstate/contracts/utils/EnumerableSet.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Set implementation with enumeration functions\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts (MIT license)\n */\nlibrary EnumerableSet {\n struct Set {\n bytes32[] _values;\n // 1-indexed to allow 0 to signify nonexistence\n mapping(bytes32 => uint256) _indexes;\n }\n\n struct Bytes32Set {\n Set _inner;\n }\n\n struct AddressSet {\n Set _inner;\n }\n\n struct UintSet {\n Set _inner;\n }\n\n function at(Bytes32Set storage set, uint256 index)\n internal\n view\n returns (bytes32)\n {\n return _at(set._inner, index);\n }\n\n function at(AddressSet storage set, uint256 index)\n internal\n view\n returns (address)\n {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n function at(UintSet storage set, uint256 index)\n internal\n view\n returns (uint256)\n {\n return uint256(_at(set._inner, index));\n }\n\n function contains(Bytes32Set storage set, bytes32 value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, value);\n }\n\n function contains(AddressSet storage set, address value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function contains(UintSet storage set, uint256 value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, bytes32(value));\n }\n\n function indexOf(Bytes32Set storage set, bytes32 value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, value);\n }\n\n function indexOf(AddressSet storage set, address value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function indexOf(UintSet storage set, uint256 value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, bytes32(value));\n }\n\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function add(Bytes32Set storage set, bytes32 value)\n internal\n returns (bool)\n {\n return _add(set._inner, value);\n }\n\n function add(AddressSet storage set, address value)\n internal\n returns (bool)\n {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n function remove(Bytes32Set storage set, bytes32 value)\n internal\n returns (bool)\n {\n return _remove(set._inner, value);\n }\n\n function remove(AddressSet storage set, address value)\n internal\n returns (bool)\n {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function remove(UintSet storage set, uint256 value)\n internal\n returns (bool)\n {\n return _remove(set._inner, bytes32(value));\n }\n\n function _at(Set storage set, uint256 index)\n private\n view\n returns (bytes32)\n {\n require(\n set._values.length > index,\n 'EnumerableSet: index out of bounds'\n );\n return set._values[index];\n }\n\n function _contains(Set storage set, bytes32 value)\n private\n view\n returns (bool)\n {\n return set._indexes[value] != 0;\n }\n\n function _indexOf(Set storage set, bytes32 value)\n private\n view\n returns (uint256)\n {\n unchecked {\n return set._indexes[value] - 1;\n }\n }\n\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n uint256 index = valueIndex - 1;\n bytes32 last = set._values[set._values.length - 1];\n\n // move last value to now-vacant index\n\n set._values[index] = last;\n set._indexes[last] = index + 1;\n\n // clear last index\n\n set._values.pop();\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n}\n" - }, - "contracts/mining/PremiaMiningStorage.sol": { - "content": "// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nlibrary PremiaMiningStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.PremiaMining\");\r\n\r\n // Info of each pool.\r\n struct PoolInfo {\r\n uint256 allocPoint; // How many allocation points assigned to this pool. PREMIA to distribute per block.\r\n uint256 lastRewardTimestamp; // Last timestamp that PREMIA distribution occurs\r\n uint256 accPremiaPerShare; // Accumulated PREMIA per share, times 1e12. See below.\r\n }\r\n\r\n // Info of each user.\r\n struct UserInfo {\r\n uint256 reward; // Total allocated unclaimed reward\r\n uint256 rewardDebt; // Reward debt. See explanation below.\r\n //\r\n // We do some fancy math here. Basically, any point in time, the amount of PREMIA\r\n // entitled to a user but is pending to be distributed is:\r\n //\r\n // pending reward = (user.amount * pool.accPremiaPerShare) - user.rewardDebt\r\n //\r\n // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:\r\n // 1. The pool's `accPremiaPerShare` (and `lastRewardBlock`) gets updated.\r\n // 2. User receives the pending reward sent to his/her address.\r\n // 3. User's `amount` gets updated.\r\n // 4. User's `rewardDebt` gets updated.\r\n }\r\n\r\n struct Layout {\r\n // Total PREMIA left to distribute\r\n uint256 premiaAvailable;\r\n // Amount of premia distributed per year\r\n uint256 premiaPerYear;\r\n // pool -> isCallPool -> PoolInfo\r\n mapping(address => mapping(bool => PoolInfo)) poolInfo;\r\n // pool -> isCallPool -> user -> UserInfo\r\n mapping(address => mapping(bool => mapping(address => UserInfo))) userInfo;\r\n // Total allocation points. Must be the sum of all allocation points in all pools.\r\n uint256 totalAllocPoint;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n}\r\n" - }, - "@solidstate/contracts/utils/IWETH.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from '../token/ERC20/IERC20.sol';\nimport { IERC20Metadata } from '../token/ERC20/metadata/IERC20Metadata.sol';\n\n/**\n * @title WETH (Wrapped ETH) interface\n */\ninterface IWETH is IERC20, IERC20Metadata {\n /**\n * @notice convert ETH to WETH\n */\n function deposit() external payable;\n\n /**\n * @notice convert WETH to ETH\n * @dev if caller is a contract, it should have a fallback or receive function\n * @param amount quantity of WETH to convert, denominated in wei\n */\n function withdraw(uint256 amount) external;\n}\n" - }, - "@solidstate/contracts/token/ERC1155/IERC1155Internal.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @notice Partial ERC1155 interface needed by internal functions\n */\ninterface IERC1155Internal {\n event TransferSingle(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256 id,\n uint256 value\n );\n\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n event ApprovalForAll(\n address indexed account,\n address indexed operator,\n bool approved\n );\n}\n" - }, - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n\n function decimals()\n external\n view\n returns (\n uint8\n );\n\n function description()\n external\n view\n returns (\n string memory\n );\n\n function version()\n external\n view\n returns (\n uint256\n );\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n}\n" - }, - "@solidstate/contracts/access/OwnableStorage.sol": { - "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary OwnableStorage {\n struct Layout {\n address owner;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.Ownable');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n\n function setOwner(Layout storage l, address owner) internal {\n l.owner = owner;\n }\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 200 - }, - "outputSelection": { - "*": { - "*": [ - "evm.bytecode", - "evm.deployedBytecode", - "devdoc", - "userdoc", - "metadata", - "abi" - ] - } - }, - "libraries": { - "contracts/libraries/OptionMath.sol": { - "OptionMath": "0x0f6e8ef18fb5bb61d545fee60f779d8aed60408f" - } - } - } - }, - "ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ivolOracle\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"weth\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"premiaMining\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeReceiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeDiscountAddress\",\"type\":\"address\"},{\"internalType\":\"int128\",\"name\":\"fee64x64\",\"type\":\"int128\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Annihilate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"freedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalContractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"AssignExercise\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"exerciseValue\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"Exercise\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseCost\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeCost\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"spot64x64\",\"type\":\"int128\"}],\"name\":\"Purchase\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"longReceiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalContractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalPremium\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isManualUnderwrite\",\"type\":\"bool\"}],\"name\":\"Underwrite\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"isCall\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"cLevel64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"oldLiquidity64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"newLiquidity64x64\",\"type\":\"int128\"}],\"name\":\"UpdateCLevel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"steepness64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"}],\"name\":\"UpdateSteepness\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositedAt\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"holder\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"}],\"name\":\"exerciseFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"}],\"name\":\"processExpired\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - "ContractName": "PoolExercise", - "CompilerVersion": "v0.8.9+commit.e5eed63a", - "OptimizationUsed": 1, - "Runs": 200, - "ConstructorArguments": "0x0000000000000000000000003a87bb29b984d672664aa1dd2d19d2e8b24f0f2a000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009abb27581c2e46a114f8c367355851e0580e9703000000000000000000000000c4b2c51f969e0713e799de73b7f130fb7bb604cf000000000000000000000000f1bb87563a122211d40d393ebf1c633c330377f900000000000000000000000000000000000000000000000007ae147ae147ae14", - "EVMVersion": "Default", - "Library": "", - "LicenseType": "", - "Proxy": 0, - "SwarmSource": "" - } -] \ No newline at end of file +[{"SourceCode":{"language":"Solidity","sources":{"@solidstate/contracts/token/ERC1155/base/ERC1155Base.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC1155 } from '../IERC1155.sol';\nimport { IERC1155Receiver } from '../IERC1155Receiver.sol';\nimport { ERC1155BaseInternal, ERC1155BaseStorage } from './ERC1155BaseInternal.sol';\n\n/**\n * @title Base ERC1155 contract\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)\n */\nabstract contract ERC1155Base is IERC1155, ERC1155BaseInternal {\n /**\n * @inheritdoc IERC1155\n */\n function balanceOf(address account, uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return _balanceOf(account, id);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function balanceOfBatch(address[] memory accounts, uint256[] memory ids)\n public\n view\n virtual\n override\n returns (uint256[] memory)\n {\n require(\n accounts.length == ids.length,\n 'ERC1155: accounts and ids length mismatch'\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n uint256[] memory batchBalances = new uint256[](accounts.length);\n\n unchecked {\n for (uint256 i; i < accounts.length; i++) {\n require(\n accounts[i] != address(0),\n 'ERC1155: batch balance query for the zero address'\n );\n batchBalances[i] = balances[ids[i]][accounts[i]];\n }\n }\n\n return batchBalances;\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function isApprovedForAll(address account, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n return ERC1155BaseStorage.layout().operatorApprovals[account][operator];\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function setApprovalForAll(address operator, bool status)\n public\n virtual\n override\n {\n require(\n msg.sender != operator,\n 'ERC1155: setting approval status for self'\n );\n ERC1155BaseStorage.layout().operatorApprovals[msg.sender][\n operator\n ] = status;\n emit ApprovalForAll(msg.sender, operator, status);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) public virtual override {\n require(\n from == msg.sender || isApprovedForAll(from, msg.sender),\n 'ERC1155: caller is not owner nor approved'\n );\n _safeTransfer(msg.sender, from, to, id, amount, data);\n }\n\n /**\n * @inheritdoc IERC1155\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) public virtual override {\n require(\n from == msg.sender || isApprovedForAll(from, msg.sender),\n 'ERC1155: caller is not owner nor approved'\n );\n _safeTransferBatch(msg.sender, from, to, ids, amounts, data);\n }\n}\n"},"@solidstate/contracts/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC165 interface registration interface\n * @dev see https://eips.ethereum.org/EIPS/eip-165\n */\ninterface IERC165 {\n /**\n * @notice query whether contract has registered support for given interface\n * @param interfaceId interface id\n * @return bool whether interface is supported\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"abdk-libraries-solidity/ABDKMath64x64.sol":{"content":"// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov \n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x8) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"},"@solidstate/contracts/token/ERC20/metadata/IERC20Metadata.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC20 metadata interface\n */\ninterface IERC20Metadata {\n /**\n * @notice return token name\n * @return token name\n */\n function name() external view returns (string memory);\n\n /**\n * @notice return token symbol\n * @return token symbol\n */\n function symbol() external view returns (string memory);\n\n /**\n * @notice return token decimals, generally used only for display purposes\n * @return token decimals\n */\n function decimals() external view returns (uint8);\n}\n"},"contracts/staking/FeeDiscountStorage.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nlibrary FeeDiscountStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.staking.PremiaFeeDiscount\");\r\n\r\n struct UserInfo {\r\n uint256 balance; // Balance staked by user\r\n uint64 stakePeriod; // Stake period selected by user\r\n uint64 lockedUntil; // Timestamp at which the lock ends\r\n }\r\n\r\n struct Layout {\r\n // User data with xPREMIA balance staked and date at which lock ends\r\n mapping(address => UserInfo) userInfo;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n}\r\n"},"contracts/libraries/OptionMath.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\n\r\nlibrary OptionMath {\r\n using ABDKMath64x64 for int128;\r\n\r\n struct QuoteArgs {\r\n int128 varianceAnnualized64x64; // 64x64 fixed point representation of annualized variance\r\n int128 strike64x64; // 64x64 fixed point representation of strike price\r\n int128 spot64x64; // 64x64 fixed point representation of spot price\r\n int128 timeToMaturity64x64; // 64x64 fixed point representation of duration of option contract (in years)\r\n int128 oldCLevel64x64; // 64x64 fixed point representation of C-Level of Pool before purchase\r\n int128 oldPoolState; // 64x64 fixed point representation of current state of the pool\r\n int128 newPoolState; // 64x64 fixed point representation of state of the pool after trade\r\n int128 steepness64x64; // 64x64 fixed point representation of Pool state delta multiplier\r\n int128 minAPY64x64; // 64x64 fixed point representation of minimum APY for capital locked up to underwrite options\r\n bool isCall; // whether to price \"call\" or \"put\" option\r\n }\r\n\r\n struct CalculateCLevelDecayArgs {\r\n int128 timeIntervalsElapsed64x64; // 64x64 fixed point representation of quantity of discrete arbitrary intervals elapsed since last update\r\n int128 oldCLevel64x64; // 64x64 fixed point representation of C-Level prior to accounting for decay\r\n int128 utilization64x64; // 64x64 fixed point representation of pool capital utilization rate\r\n int128 utilizationLowerBound64x64;\r\n int128 utilizationUpperBound64x64;\r\n int128 cLevelLowerBound64x64;\r\n int128 cLevelUpperBound64x64;\r\n int128 cConvergenceULowerBound64x64;\r\n int128 cConvergenceUUpperBound64x64;\r\n }\r\n\r\n // 64x64 fixed point integer constants\r\n int128 internal constant ONE_64x64 = 0x10000000000000000;\r\n int128 internal constant THREE_64x64 = 0x30000000000000000;\r\n\r\n // 64x64 fixed point constants used in Choudhury’s approximation of the Black-Scholes CDF\r\n int128 private constant CDF_CONST_0 = 0x09109f285df452394; // 2260 / 3989\r\n int128 private constant CDF_CONST_1 = 0x19abac0ea1da65036; // 6400 / 3989\r\n int128 private constant CDF_CONST_2 = 0x0d3c84b78b749bd6b; // 3300 / 3989\r\n\r\n /**\r\n * @notice recalculate C-Level based on change in liquidity\r\n * @param initialCLevel64x64 64x64 fixed point representation of C-Level of Pool before update\r\n * @param oldPoolState64x64 64x64 fixed point representation of liquidity in pool before update\r\n * @param newPoolState64x64 64x64 fixed point representation of liquidity in pool after update\r\n * @param steepness64x64 64x64 fixed point representation of steepness coefficient\r\n * @return 64x64 fixed point representation of new C-Level\r\n */\r\n function calculateCLevel(\r\n int128 initialCLevel64x64,\r\n int128 oldPoolState64x64,\r\n int128 newPoolState64x64,\r\n int128 steepness64x64\r\n ) external pure returns (int128) {\r\n return\r\n newPoolState64x64\r\n .sub(oldPoolState64x64)\r\n .div(\r\n oldPoolState64x64 > newPoolState64x64\r\n ? oldPoolState64x64\r\n : newPoolState64x64\r\n )\r\n .mul(steepness64x64)\r\n .neg()\r\n .exp()\r\n .mul(initialCLevel64x64);\r\n }\r\n\r\n /**\r\n * @notice calculate the price of an option using the Premia Finance model\r\n * @param args arguments of quotePrice\r\n * @return premiaPrice64x64 64x64 fixed point representation of Premia option price\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level of Pool after purchase\r\n */\r\n function quotePrice(QuoteArgs memory args)\r\n external\r\n pure\r\n returns (\r\n int128 premiaPrice64x64,\r\n int128 cLevel64x64,\r\n int128 slippageCoefficient64x64\r\n )\r\n {\r\n int128 deltaPoolState64x64 = args\r\n .newPoolState\r\n .sub(args.oldPoolState)\r\n .div(args.oldPoolState)\r\n .mul(args.steepness64x64);\r\n int128 tradingDelta64x64 = deltaPoolState64x64.neg().exp();\r\n\r\n int128 blackScholesPrice64x64 = _blackScholesPrice(\r\n args.varianceAnnualized64x64,\r\n args.strike64x64,\r\n args.spot64x64,\r\n args.timeToMaturity64x64,\r\n args.isCall\r\n );\r\n\r\n cLevel64x64 = tradingDelta64x64.mul(args.oldCLevel64x64);\r\n slippageCoefficient64x64 = ONE_64x64.sub(tradingDelta64x64).div(\r\n deltaPoolState64x64\r\n );\r\n\r\n premiaPrice64x64 = blackScholesPrice64x64.mul(cLevel64x64).mul(\r\n slippageCoefficient64x64\r\n );\r\n\r\n int128 intrinsicValue64x64;\r\n\r\n if (args.isCall && args.strike64x64 < args.spot64x64) {\r\n intrinsicValue64x64 = args.spot64x64.sub(args.strike64x64);\r\n } else if (!args.isCall && args.strike64x64 > args.spot64x64) {\r\n intrinsicValue64x64 = args.strike64x64.sub(args.spot64x64);\r\n }\r\n\r\n int128 collateralValue64x64 = args.isCall\r\n ? args.spot64x64\r\n : args.strike64x64;\r\n\r\n int128 minPrice64x64 = intrinsicValue64x64.add(\r\n collateralValue64x64.mul(args.minAPY64x64).mul(\r\n args.timeToMaturity64x64\r\n )\r\n );\r\n\r\n if (minPrice64x64 > premiaPrice64x64) {\r\n premiaPrice64x64 = minPrice64x64;\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate the decay of C-Level based on heat diffusion function\r\n * @param args structured CalculateCLevelDecayArgs\r\n * @return cLevelDecayed64x64 C-Level after accounting for decay\r\n */\r\n function calculateCLevelDecay(CalculateCLevelDecayArgs memory args)\r\n external\r\n pure\r\n returns (int128 cLevelDecayed64x64)\r\n {\r\n int128 convFHighU64x64 = (args.utilization64x64 >=\r\n args.utilizationUpperBound64x64 &&\r\n args.oldCLevel64x64 <= args.cLevelLowerBound64x64)\r\n ? ONE_64x64\r\n : int128(0);\r\n\r\n int128 convFLowU64x64 = (args.utilization64x64 <=\r\n args.utilizationLowerBound64x64 &&\r\n args.oldCLevel64x64 >= args.cLevelUpperBound64x64)\r\n ? ONE_64x64\r\n : int128(0);\r\n\r\n cLevelDecayed64x64 = args\r\n .oldCLevel64x64\r\n .sub(args.cConvergenceULowerBound64x64.mul(convFLowU64x64))\r\n .sub(args.cConvergenceUUpperBound64x64.mul(convFHighU64x64))\r\n .mul(\r\n convFLowU64x64\r\n .mul(ONE_64x64.sub(args.utilization64x64))\r\n .add(convFHighU64x64.mul(args.utilization64x64))\r\n .mul(args.timeIntervalsElapsed64x64)\r\n .neg()\r\n .exp()\r\n )\r\n .add(\r\n args.cConvergenceULowerBound64x64.mul(convFLowU64x64).add(\r\n args.cConvergenceUUpperBound64x64.mul(convFHighU64x64)\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate the exponential decay coefficient for a given interval\r\n * @param oldTimestamp timestamp of previous update\r\n * @param newTimestamp current timestamp\r\n * @return 64x64 fixed point representation of exponential decay coefficient\r\n */\r\n function _decay(uint256 oldTimestamp, uint256 newTimestamp)\r\n internal\r\n pure\r\n returns (int128)\r\n {\r\n return\r\n ONE_64x64.sub(\r\n (-ABDKMath64x64.divu(newTimestamp - oldTimestamp, 7 days)).exp()\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate Choudhury’s approximation of the Black-Scholes CDF\r\n * @param input64x64 64x64 fixed point representation of random variable\r\n * @return 64x64 fixed point representation of the approximated CDF of x\r\n */\r\n function _N(int128 input64x64) internal pure returns (int128) {\r\n // squaring via mul is cheaper than via pow\r\n int128 inputSquared64x64 = input64x64.mul(input64x64);\r\n\r\n int128 value64x64 = (-inputSquared64x64 >> 1).exp().div(\r\n CDF_CONST_0.add(CDF_CONST_1.mul(input64x64.abs())).add(\r\n CDF_CONST_2.mul(inputSquared64x64.add(THREE_64x64).sqrt())\r\n )\r\n );\r\n\r\n return input64x64 > 0 ? ONE_64x64.sub(value64x64) : value64x64;\r\n }\r\n\r\n /**\r\n * @notice calculate the price of an option using the Black-Scholes model\r\n * @param varianceAnnualized64x64 64x64 fixed point representation of annualized variance\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param spot64x64 64x64 fixed point representation of spot price\r\n * @param timeToMaturity64x64 64x64 fixed point representation of duration of option contract (in years)\r\n * @param isCall whether to price \"call\" or \"put\" option\r\n * @return 64x64 fixed point representation of Black-Scholes option price\r\n */\r\n function _blackScholesPrice(\r\n int128 varianceAnnualized64x64,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) internal pure returns (int128) {\r\n int128 cumulativeVariance64x64 = timeToMaturity64x64.mul(\r\n varianceAnnualized64x64\r\n );\r\n int128 cumulativeVarianceSqrt64x64 = cumulativeVariance64x64.sqrt();\r\n\r\n int128 d1_64x64 = spot64x64\r\n .div(strike64x64)\r\n .ln()\r\n .add(cumulativeVariance64x64 >> 1)\r\n .div(cumulativeVarianceSqrt64x64);\r\n int128 d2_64x64 = d1_64x64.sub(cumulativeVarianceSqrt64x64);\r\n\r\n if (isCall) {\r\n return\r\n spot64x64.mul(_N(d1_64x64)).sub(strike64x64.mul(_N(d2_64x64)));\r\n } else {\r\n return\r\n -spot64x64.mul(_N(-d1_64x64)).sub(\r\n strike64x64.mul(_N(-d2_64x64))\r\n );\r\n }\r\n }\r\n}\r\n"},"@solidstate/contracts/access/IERC173.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Contract ownership standard interface\n * @dev see https://eips.ethereum.org/EIPS/eip-173\n */\ninterface IERC173 {\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n /**\n * @notice get the ERC173 contract owner\n * @return conract owner\n */\n function owner() external view returns (address);\n\n /**\n * @notice transfer contract ownership to new account\n * @param account address of new owner\n */\n function transferOwnership(address account) external;\n}\n"},"contracts/libraries/ABDKMath64x64Token.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\n\r\nlibrary ABDKMath64x64Token {\r\n using ABDKMath64x64 for int128;\r\n\r\n /**\r\n * @notice convert 64x64 fixed point representation of token amount to decimal\r\n * @param value64x64 64x64 fixed point representation of token amount\r\n * @param decimals token display decimals\r\n * @return value decimal representation of token amount\r\n */\r\n function toDecimals(int128 value64x64, uint8 decimals)\r\n internal\r\n pure\r\n returns (uint256 value)\r\n {\r\n value = value64x64.mulu(10**decimals);\r\n }\r\n\r\n /**\r\n * @notice convert decimal representation of token amount to 64x64 fixed point\r\n * @param value decimal representation of token amount\r\n * @param decimals token display decimals\r\n * @return value64x64 64x64 fixed point representation of token amount\r\n */\r\n function fromDecimals(uint256 value, uint8 decimals)\r\n internal\r\n pure\r\n returns (int128 value64x64)\r\n {\r\n value64x64 = ABDKMath64x64.divu(value, 10**decimals);\r\n }\r\n\r\n /**\r\n * @notice convert 64x64 fixed point representation of token amount to wei (18 decimals)\r\n * @param value64x64 64x64 fixed point representation of token amount\r\n * @return value wei representation of token amount\r\n */\r\n function toWei(int128 value64x64) internal pure returns (uint256 value) {\r\n value = toDecimals(value64x64, 18);\r\n }\r\n\r\n /**\r\n * @notice convert wei representation (18 decimals) of token amount to 64x64 fixed point\r\n * @param value wei representation of token amount\r\n * @return value64x64 64x64 fixed point representation of token amount\r\n */\r\n function fromWei(uint256 value) internal pure returns (int128 value64x64) {\r\n value64x64 = fromDecimals(value, 18);\r\n }\r\n}\r\n"},"@solidstate/contracts/token/ERC1155/IERC1155.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC1155Internal } from './IERC1155Internal.sol';\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @notice ERC1155 interface\n * @dev see https://github.com/ethereum/EIPs/issues/1155\n */\ninterface IERC1155 is IERC1155Internal, IERC165 {\n /**\n * @notice query the balance of given token held by given address\n * @param account address to query\n * @param id token to query\n * @return token balance\n */\n function balanceOf(address account, uint256 id)\n external\n view\n returns (uint256);\n\n /**\n * @notice query the balances of given tokens held by given addresses\n * @param accounts addresss to query\n * @param ids tokens to query\n * @return token balances\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @notice query approval status of given operator with respect to given address\n * @param account address to query for approval granted\n * @param operator address to query for approval received\n * @return whether operator is approved to spend tokens held by account\n */\n function isApprovedForAll(address account, address operator)\n external\n view\n returns (bool);\n\n /**\n * @notice grant approval to or revoke approval from given operator to spend held tokens\n * @param operator address whose approval status to update\n * @param status whether operator should be considered approved\n */\n function setApprovalForAll(address operator, bool status) external;\n\n /**\n * @notice transfer tokens between given addresses, checking for ERC1155Receiver implementation if applicable\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @notice transfer batch of tokens between given addresses, checking for ERC1155Receiver implementation if applicable\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to transfer\n * @param data data payload\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n"},"contracts/staking/IFeeDiscount.sol":{"content":"// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {FeeDiscountStorage} from \"./FeeDiscountStorage.sol\";\r\n\r\ninterface IFeeDiscount {\r\n event Staked(\r\n address indexed user,\r\n uint256 amount,\r\n uint256 stakePeriod,\r\n uint256 lockedUntil\r\n );\r\n event Unstaked(address indexed user, uint256 amount);\r\n\r\n struct StakeLevel {\r\n uint256 amount; // Amount to stake\r\n uint256 discount; // Discount when amount is reached\r\n }\r\n\r\n /**\r\n * @notice Stake using IERC2612 permit\r\n * @param amount The amount of xPremia to stake\r\n * @param period The lockup period (in seconds)\r\n * @param deadline Deadline after which permit will fail\r\n * @param v V\r\n * @param r R\r\n * @param s S\r\n */\r\n function stakeWithPermit(\r\n uint256 amount,\r\n uint256 period,\r\n uint256 deadline,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) external;\r\n\r\n /**\r\n * @notice Lockup xPremia for protocol fee discounts\r\n * Longer period of locking will apply a multiplier on the amount staked, in the fee discount calculation\r\n * @param amount The amount of xPremia to stake\r\n * @param period The lockup period (in seconds)\r\n */\r\n function stake(uint256 amount, uint256 period) external;\r\n\r\n /**\r\n * @notice Unstake xPremia (If lockup period has ended)\r\n * @param amount The amount of xPremia to unstake\r\n */\r\n function unstake(uint256 amount) external;\r\n\r\n //////////\r\n // View //\r\n //////////\r\n\r\n /**\r\n * Calculate the stake amount of a user, after applying the bonus from the lockup period chosen\r\n * @param user The user from which to query the stake amount\r\n * @return The user stake amount after applying the bonus\r\n */\r\n function getStakeAmountWithBonus(address user)\r\n external\r\n view\r\n returns (uint256);\r\n\r\n /**\r\n * @notice Calculate the % of fee discount for user, based on his stake\r\n * @param user The _user for which the discount is for\r\n * @return Percentage of protocol fee discount (in basis point)\r\n * Ex : 1000 = 10% fee discount\r\n */\r\n function getDiscount(address user) external view returns (uint256);\r\n\r\n /**\r\n * @notice Get stake levels\r\n * @return Stake levels\r\n * Ex : 2500 = -25%\r\n */\r\n function getStakeLevels() external returns (StakeLevel[] memory);\r\n\r\n /**\r\n * @notice Get stake period multiplier\r\n * @param period The duration (in seconds) for which tokens are locked\r\n * @return The multiplier for this staking period\r\n * Ex : 20000 = x2\r\n */\r\n function getStakePeriodMultiplier(uint256 period)\r\n external\r\n returns (uint256);\r\n\r\n /**\r\n * @notice Get staking infos of a user\r\n * @param user The user address for which to get staking infos\r\n * @return The staking infos of the user\r\n */\r\n function getUserInfo(address user)\r\n external\r\n view\r\n returns (FeeDiscountStorage.UserInfo memory);\r\n}\r\n"},"@solidstate/contracts/token/ERC1155/base/ERC1155BaseInternal.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { AddressUtils } from '../../../utils/AddressUtils.sol';\nimport { IERC1155Internal } from '../IERC1155Internal.sol';\nimport { IERC1155Receiver } from '../IERC1155Receiver.sol';\nimport { ERC1155BaseStorage } from './ERC1155BaseStorage.sol';\n\n/**\n * @title Base ERC1155 internal functions\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)\n */\nabstract contract ERC1155BaseInternal is IERC1155Internal {\n using AddressUtils for address;\n\n /**\n * @notice query the balance of given token held by given address\n * @param account address to query\n * @param id token to query\n * @return token balance\n */\n function _balanceOf(address account, uint256 id)\n internal\n view\n virtual\n returns (uint256)\n {\n require(\n account != address(0),\n 'ERC1155: balance query for the zero address'\n );\n return ERC1155BaseStorage.layout().balances[id][account];\n }\n\n /**\n * @notice mint given quantity of tokens for given address\n * @dev ERC1155Receiver implementation is not checked\n * @param account beneficiary of minting\n * @param id token ID\n * @param amount quantity of tokens to mint\n * @param data data payload\n */\n function _mint(\n address account,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(account != address(0), 'ERC1155: mint to the zero address');\n\n _beforeTokenTransfer(\n msg.sender,\n address(0),\n account,\n _asSingletonArray(id),\n _asSingletonArray(amount),\n data\n );\n\n mapping(address => uint256) storage balances = ERC1155BaseStorage\n .layout()\n .balances[id];\n balances[account] += amount;\n\n emit TransferSingle(msg.sender, address(0), account, id, amount);\n }\n\n /**\n * @notice mint given quantity of tokens for given address\n * @param account beneficiary of minting\n * @param id token ID\n * @param amount quantity of tokens to mint\n * @param data data payload\n */\n function _safeMint(\n address account,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n _mint(account, id, amount, data);\n\n _doSafeTransferAcceptanceCheck(\n msg.sender,\n address(0),\n account,\n id,\n amount,\n data\n );\n }\n\n /**\n * @notice mint batch of tokens for given address\n * @dev ERC1155Receiver implementation is not checked\n * @param account beneficiary of minting\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to mint\n * @param data data payload\n */\n function _mintBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(account != address(0), 'ERC1155: mint to the zero address');\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(\n msg.sender,\n address(0),\n account,\n ids,\n amounts,\n data\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n for (uint256 i; i < ids.length; i++) {\n balances[ids[i]][account] += amounts[i];\n }\n\n emit TransferBatch(msg.sender, address(0), account, ids, amounts);\n }\n\n /**\n * @notice mint batch of tokens for given address\n * @param account beneficiary of minting\n * @param ids list of token IDs\n * @param amounts list of quantities of tokens to mint\n * @param data data payload\n */\n function _safeMintBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _mintBatch(account, ids, amounts, data);\n\n _doSafeBatchTransferAcceptanceCheck(\n msg.sender,\n address(0),\n account,\n ids,\n amounts,\n data\n );\n }\n\n /**\n * @notice burn given quantity of tokens held by given address\n * @param account holder of tokens to burn\n * @param id token ID\n * @param amount quantity of tokens to burn\n */\n function _burn(\n address account,\n uint256 id,\n uint256 amount\n ) internal virtual {\n require(account != address(0), 'ERC1155: burn from the zero address');\n\n _beforeTokenTransfer(\n msg.sender,\n account,\n address(0),\n _asSingletonArray(id),\n _asSingletonArray(amount),\n ''\n );\n\n mapping(address => uint256) storage balances = ERC1155BaseStorage\n .layout()\n .balances[id];\n\n unchecked {\n require(\n balances[account] >= amount,\n 'ERC1155: burn amount exceeds balances'\n );\n balances[account] -= amount;\n }\n\n emit TransferSingle(msg.sender, account, address(0), id, amount);\n }\n\n /**\n * @notice burn given batch of tokens held by given address\n * @param account holder of tokens to burn\n * @param ids token IDs\n * @param amounts quantities of tokens to burn\n */\n function _burnBatch(\n address account,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal virtual {\n require(account != address(0), 'ERC1155: burn from the zero address');\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(msg.sender, account, address(0), ids, amounts, '');\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n unchecked {\n for (uint256 i; i < ids.length; i++) {\n uint256 id = ids[i];\n require(\n balances[id][account] >= amounts[i],\n 'ERC1155: burn amount exceeds balance'\n );\n balances[id][account] -= amounts[i];\n }\n }\n\n emit TransferBatch(msg.sender, account, address(0), ids, amounts);\n }\n\n /**\n * @notice transfer tokens between given addresses\n * @dev ERC1155Receiver implementation is not checked\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _transfer(\n address operator,\n address sender,\n address recipient,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(\n recipient != address(0),\n 'ERC1155: transfer to the zero address'\n );\n\n _beforeTokenTransfer(\n operator,\n sender,\n recipient,\n _asSingletonArray(id),\n _asSingletonArray(amount),\n data\n );\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n unchecked {\n uint256 senderBalance = balances[id][sender];\n require(\n senderBalance >= amount,\n 'ERC1155: insufficient balances for transfer'\n );\n balances[id][sender] = senderBalance - amount;\n }\n\n balances[id][recipient] += amount;\n\n emit TransferSingle(operator, sender, recipient, id, amount);\n }\n\n /**\n * @notice transfer tokens between given addresses\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _safeTransfer(\n address operator,\n address sender,\n address recipient,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n _transfer(operator, sender, recipient, id, amount, data);\n\n _doSafeTransferAcceptanceCheck(\n operator,\n sender,\n recipient,\n id,\n amount,\n data\n );\n }\n\n /**\n * @notice transfer batch of tokens between given addresses\n * @dev ERC1155Receiver implementation is not checked\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _transferBatch(\n address operator,\n address sender,\n address recipient,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(\n recipient != address(0),\n 'ERC1155: transfer to the zero address'\n );\n require(\n ids.length == amounts.length,\n 'ERC1155: ids and amounts length mismatch'\n );\n\n _beforeTokenTransfer(operator, sender, recipient, ids, amounts, data);\n\n mapping(uint256 => mapping(address => uint256))\n storage balances = ERC1155BaseStorage.layout().balances;\n\n for (uint256 i; i < ids.length; i++) {\n uint256 token = ids[i];\n uint256 amount = amounts[i];\n\n unchecked {\n uint256 senderBalance = balances[token][sender];\n require(\n senderBalance >= amount,\n 'ERC1155: insufficient balances for transfer'\n );\n balances[token][sender] = senderBalance - amount;\n }\n\n balances[token][recipient] += amount;\n }\n\n emit TransferBatch(operator, sender, recipient, ids, amounts);\n }\n\n /**\n * @notice transfer batch of tokens between given addresses\n * @param operator executor of transfer\n * @param sender sender of tokens\n * @param recipient receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _safeTransferBatch(\n address operator,\n address sender,\n address recipient,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _transferBatch(operator, sender, recipient, ids, amounts, data);\n\n _doSafeBatchTransferAcceptanceCheck(\n operator,\n sender,\n recipient,\n ids,\n amounts,\n data\n );\n }\n\n /**\n * @notice wrap given element in array of length 1\n * @param element element to wrap\n * @return singleton array\n */\n function _asSingletonArray(uint256 element)\n private\n pure\n returns (uint256[] memory)\n {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n /**\n * @notice revert if applicable transfer recipient is not valid ERC1155Receiver\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param id token ID\n * @param amount quantity of tokens to transfer\n * @param data data payload\n */\n function _doSafeTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try\n IERC1155Receiver(to).onERC1155Received(\n operator,\n from,\n id,\n amount,\n data\n )\n returns (bytes4 response) {\n require(\n response == IERC1155Receiver.onERC1155Received.selector,\n 'ERC1155: ERC1155Receiver rejected tokens'\n );\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert('ERC1155: transfer to non ERC1155Receiver implementer');\n }\n }\n }\n\n /**\n * @notice revert if applicable transfer recipient is not valid ERC1155Receiver\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _doSafeBatchTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try\n IERC1155Receiver(to).onERC1155BatchReceived(\n operator,\n from,\n ids,\n amounts,\n data\n )\n returns (bytes4 response) {\n require(\n response ==\n IERC1155Receiver.onERC1155BatchReceived.selector,\n 'ERC1155: ERC1155Receiver rejected tokens'\n );\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert('ERC1155: transfer to non ERC1155Receiver implementer');\n }\n }\n }\n\n /**\n * @notice ERC1155 hook, called before all transfers including mint and burn\n * @dev function should be overridden and new implementation must call super\n * @dev called for both single and batch transfers\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param to receiver of tokens\n * @param ids token IDs\n * @param amounts quantities of tokens to transfer\n * @param data data payload\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n}\n"},"@solidstate/contracts/token/ERC20/IERC20Internal.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Partial ERC20 interface needed by internal functions\n */\ninterface IERC20Internal {\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(\n address indexed owner,\n address indexed spender,\n uint256 value\n );\n}\n"},"@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n function latestAnswer()\n external\n view\n returns (\n int256\n );\n \n function latestTimestamp()\n external\n view\n returns (\n uint256\n );\n\n function latestRound()\n external\n view\n returns (\n uint256\n );\n\n function getAnswer(\n uint256 roundId\n )\n external\n view\n returns (\n int256\n );\n\n function getTimestamp(\n uint256 roundId\n )\n external\n view\n returns (\n uint256\n );\n\n event AnswerUpdated(\n int256 indexed current,\n uint256 indexed roundId,\n uint256 updatedAt\n );\n\n event NewRound(\n uint256 indexed roundId,\n address indexed startedBy,\n uint256 startedAt\n );\n}\n"},"contracts/pool/PoolExercise.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {ERC1155BaseStorage} from \"@solidstate/contracts/token/ERC1155/base/ERC1155BaseStorage.sol\";\r\n\r\nimport {PoolInternal} from \"./PoolInternal.sol\";\r\nimport {IPoolExercise} from \"./IPoolExercise.sol\";\r\n\r\n/**\r\n * @title Premia option pool\r\n * @dev deployed standalone and referenced by PoolProxy\r\n */\r\ncontract PoolExercise is IPoolExercise, PoolInternal {\r\n constructor(\r\n address ivolOracle,\r\n address weth,\r\n address premiaMining,\r\n address feeReceiver,\r\n address feeDiscountAddress,\r\n int128 fee64x64\r\n )\r\n PoolInternal(\r\n ivolOracle,\r\n weth,\r\n premiaMining,\r\n feeReceiver,\r\n feeDiscountAddress,\r\n fee64x64\r\n )\r\n {}\r\n\r\n /**\r\n * @inheritdoc IPoolExercise\r\n */\r\n function exerciseFrom(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) external override {\r\n if (msg.sender != holder) {\r\n require(\r\n ERC1155BaseStorage.layout().operatorApprovals[holder][\r\n msg.sender\r\n ],\r\n \"not approved\"\r\n );\r\n }\r\n\r\n _exercise(holder, longTokenId, contractSize);\r\n }\r\n\r\n /**\r\n * @inheritdoc IPoolExercise\r\n */\r\n function processExpired(uint256 longTokenId, uint256 contractSize)\r\n external\r\n override\r\n {\r\n _exercise(address(0), longTokenId, contractSize);\r\n }\r\n}\r\n"},"contracts/pool/IPoolExercise.sol":{"content":"// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @notice Pool interface for exercising and processing of expired options\r\n */\r\ninterface IPoolExercise {\r\n /**\r\n * @notice exercise option on behalf of holder\r\n * @param holder owner of long option tokens to exercise\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to exercise\r\n */\r\n function exerciseFrom(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) external;\r\n\r\n /**\r\n * @notice process expired option, freeing liquidity and distributing profits\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to process\r\n */\r\n function processExpired(uint256 longTokenId, uint256 contractSize) external;\r\n}\r\n"},"contracts/pool/PoolStorage.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {AggregatorInterface} from \"@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol\";\r\nimport {AggregatorV3Interface} from \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\r\nimport {EnumerableSet, ERC1155EnumerableStorage} from \"@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableStorage.sol\";\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\nimport {ABDKMath64x64Token} from \"../libraries/ABDKMath64x64Token.sol\";\r\nimport {OptionMath} from \"../libraries/OptionMath.sol\";\r\n\r\nlibrary PoolStorage {\r\n using ABDKMath64x64 for int128;\r\n using PoolStorage for PoolStorage.Layout;\r\n\r\n enum TokenType {\r\n UNDERLYING_FREE_LIQ,\r\n BASE_FREE_LIQ,\r\n UNDERLYING_RESERVED_LIQ,\r\n BASE_RESERVED_LIQ,\r\n LONG_CALL,\r\n SHORT_CALL,\r\n LONG_PUT,\r\n SHORT_PUT\r\n }\r\n\r\n struct PoolSettings {\r\n address underlying;\r\n address base;\r\n address underlyingOracle;\r\n address baseOracle;\r\n }\r\n\r\n struct QuoteArgsInternal {\r\n address feePayer; // address of the fee payer\r\n uint64 maturity; // timestamp of option maturity\r\n int128 strike64x64; // 64x64 fixed point representation of strike price\r\n int128 spot64x64; // 64x64 fixed point representation of spot price\r\n uint256 contractSize; // size of option contract\r\n bool isCall; // true for call, false for put\r\n }\r\n\r\n struct QuoteResultInternal {\r\n int128 baseCost64x64; // 64x64 fixed point representation of option cost denominated in underlying currency (without fee)\r\n int128 feeCost64x64; // 64x64 fixed point representation of option fee cost denominated in underlying currency for call, or base currency for put\r\n int128 cLevel64x64; // 64x64 fixed point representation of C-Level of Pool after purchase\r\n int128 slippageCoefficient64x64; // 64x64 fixed point representation of slippage coefficient for given order size\r\n }\r\n\r\n struct BatchData {\r\n uint256 eta;\r\n uint256 totalPendingDeposits;\r\n }\r\n\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.Pool\");\r\n\r\n uint256 private constant C_DECAY_BUFFER = 12 hours;\r\n uint256 private constant C_DECAY_INTERVAL = 4 hours;\r\n\r\n struct Layout {\r\n // ERC20 token addresses\r\n address base;\r\n address underlying;\r\n // AggregatorV3Interface oracle addresses\r\n address baseOracle;\r\n address underlyingOracle;\r\n // token metadata\r\n uint8 underlyingDecimals;\r\n uint8 baseDecimals;\r\n // minimum amounts\r\n uint256 baseMinimum;\r\n uint256 underlyingMinimum;\r\n // deposit caps\r\n uint256 basePoolCap;\r\n uint256 underlyingPoolCap;\r\n // market state\r\n int128 _deprecated_steepness64x64;\r\n int128 cLevelBase64x64;\r\n int128 cLevelUnderlying64x64;\r\n uint256 cLevelBaseUpdatedAt;\r\n uint256 cLevelUnderlyingUpdatedAt;\r\n uint256 updatedAt;\r\n // User -> isCall -> depositedAt\r\n mapping(address => mapping(bool => uint256)) depositedAt;\r\n mapping(address => mapping(bool => uint256)) divestmentTimestamps;\r\n // doubly linked list of free liquidity intervals\r\n // isCall -> User -> User\r\n mapping(bool => mapping(address => address)) liquidityQueueAscending;\r\n mapping(bool => mapping(address => address)) liquidityQueueDescending;\r\n // minimum resolution price bucket => price\r\n mapping(uint256 => int128) bucketPrices64x64;\r\n // sequence id (minimum resolution price bucket / 256) => price update sequence\r\n mapping(uint256 => uint256) priceUpdateSequences;\r\n // isCall -> batch data\r\n mapping(bool => BatchData) nextDeposits;\r\n // user -> batch timestamp -> isCall -> pending amount\r\n mapping(address => mapping(uint256 => mapping(bool => uint256))) pendingDeposits;\r\n EnumerableSet.UintSet tokenIds;\r\n // user -> isCallPool -> total value locked of user (Used for liquidity mining)\r\n mapping(address => mapping(bool => uint256)) userTVL;\r\n // isCallPool -> total value locked\r\n mapping(bool => uint256) totalTVL;\r\n // steepness values\r\n int128 steepnessBase64x64;\r\n int128 steepnessUnderlying64x64;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate ERC1155 token id for given option parameters\r\n * @param tokenType TokenType enum\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @return tokenId token id\r\n */\r\n function formatTokenId(\r\n TokenType tokenType,\r\n uint64 maturity,\r\n int128 strike64x64\r\n ) internal pure returns (uint256 tokenId) {\r\n tokenId =\r\n (uint256(tokenType) << 248) +\r\n (uint256(maturity) << 128) +\r\n uint256(int256(strike64x64));\r\n }\r\n\r\n /**\r\n * @notice derive option maturity and strike price from ERC1155 token id\r\n * @param tokenId token id\r\n * @return tokenType TokenType enum\r\n * @return maturity timestamp of option maturity\r\n * @return strike64x64 option strike price\r\n */\r\n function parseTokenId(uint256 tokenId)\r\n internal\r\n pure\r\n returns (\r\n TokenType tokenType,\r\n uint64 maturity,\r\n int128 strike64x64\r\n )\r\n {\r\n assembly {\r\n tokenType := shr(248, tokenId)\r\n maturity := shr(128, tokenId)\r\n strike64x64 := tokenId\r\n }\r\n }\r\n\r\n function getTokenDecimals(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint8 decimals)\r\n {\r\n decimals = isCall ? l.underlyingDecimals : l.baseDecimals;\r\n }\r\n\r\n /**\r\n * @notice get the total supply of free liquidity tokens, minus pending deposits\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return 64x64 fixed point representation of total free liquidity\r\n */\r\n function totalFreeLiquiditySupply64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n uint256 tokenId = formatTokenId(\r\n isCall ? TokenType.UNDERLYING_FREE_LIQ : TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n return\r\n ABDKMath64x64Token.fromDecimals(\r\n ERC1155EnumerableStorage.layout().totalSupply[tokenId] -\r\n l.nextDeposits[isCall].totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n );\r\n }\r\n\r\n function getReinvestmentStatus(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal view returns (bool) {\r\n uint256 timestamp = l.divestmentTimestamps[account][isCallPool];\r\n return timestamp == 0 || timestamp > block.timestamp;\r\n }\r\n\r\n function addUnderwriter(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal {\r\n require(account != address(0));\r\n\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n if (_isInQueue(account, asc, desc)) return;\r\n\r\n address last = desc[address(0)];\r\n\r\n asc[last] = account;\r\n desc[account] = last;\r\n desc[address(0)] = account;\r\n }\r\n\r\n function removeUnderwriter(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal {\r\n require(account != address(0));\r\n\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n if (!_isInQueue(account, asc, desc)) return;\r\n\r\n address prev = desc[account];\r\n address next = asc[account];\r\n asc[prev] = next;\r\n desc[next] = prev;\r\n delete asc[account];\r\n delete desc[account];\r\n }\r\n\r\n function isInQueue(\r\n Layout storage l,\r\n address account,\r\n bool isCallPool\r\n ) internal view returns (bool) {\r\n mapping(address => address) storage asc = l.liquidityQueueAscending[\r\n isCallPool\r\n ];\r\n mapping(address => address) storage desc = l.liquidityQueueDescending[\r\n isCallPool\r\n ];\r\n\r\n return _isInQueue(account, asc, desc);\r\n }\r\n\r\n function _isInQueue(\r\n address account,\r\n mapping(address => address) storage asc,\r\n mapping(address => address) storage desc\r\n ) private view returns (bool) {\r\n return asc[account] != address(0) || desc[address(0)] == account;\r\n }\r\n\r\n /**\r\n * @notice get current C-Level, without accounting for pending adjustments\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function getRawCLevel64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128 cLevel64x64)\r\n {\r\n cLevel64x64 = isCall ? l.cLevelUnderlying64x64 : l.cLevelBase64x64;\r\n }\r\n\r\n /**\r\n * @notice get current C-Level, accounting for unrealized decay\r\n * @param l storage layout struct\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function getDecayAdjustedCLevel64x64(Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (int128 cLevel64x64)\r\n {\r\n // get raw C-Level from storage\r\n cLevel64x64 = l.getRawCLevel64x64(isCall);\r\n\r\n // account for C-Level decay\r\n cLevel64x64 = l.applyCLevelDecayAdjustment(cLevel64x64, isCall);\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for unrealized decay\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for decay\r\n * @param isCall whether query is for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level of Pool after accounting for decay\r\n */\r\n function applyCLevelDecayAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n bool isCall\r\n ) internal view returns (int128 cLevel64x64) {\r\n uint256 timeElapsed = block.timestamp -\r\n (isCall ? l.cLevelUnderlyingUpdatedAt : l.cLevelBaseUpdatedAt);\r\n\r\n // do not apply C decay if less than 24 hours have elapsed\r\n\r\n if (timeElapsed > C_DECAY_BUFFER) {\r\n timeElapsed -= C_DECAY_BUFFER;\r\n } else {\r\n return oldCLevel64x64;\r\n }\r\n\r\n int128 timeIntervalsElapsed64x64 = ABDKMath64x64.divu(\r\n timeElapsed,\r\n C_DECAY_INTERVAL\r\n );\r\n\r\n uint256 tokenId = formatTokenId(\r\n isCall ? TokenType.UNDERLYING_FREE_LIQ : TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n uint256 tvl = l.totalTVL[isCall];\r\n\r\n int128 utilization = ABDKMath64x64.divu(\r\n tvl -\r\n (ERC1155EnumerableStorage.layout().totalSupply[tokenId] -\r\n l.nextDeposits[isCall].totalPendingDeposits),\r\n tvl\r\n );\r\n\r\n return\r\n OptionMath.calculateCLevelDecay(\r\n OptionMath.CalculateCLevelDecayArgs(\r\n timeIntervalsElapsed64x64,\r\n oldCLevel64x64,\r\n utilization,\r\n 0xb333333333333333, // 0.7\r\n 0xe666666666666666, // 0.9\r\n 0x10000000000000000, // 1.0\r\n 0x10000000000000000, // 1.0\r\n 0xe666666666666666, // 0.9\r\n 0x56fc2a2c515da32ea // 2e\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for pending deposits\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for liquidity change\r\n * @param oldLiquidity64x64 64x64 fixed point representation of previous liquidity\r\n * @param isCall whether to update C-Level for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n * @return liquidity64x64 64x64 fixed point representation of new liquidity amount\r\n */\r\n function applyCLevelPendingDepositAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n int128 oldLiquidity64x64,\r\n bool isCall\r\n ) internal view returns (int128 cLevel64x64, int128 liquidity64x64) {\r\n PoolStorage.BatchData storage batchData = l.nextDeposits[isCall];\r\n int128 pendingDeposits64x64;\r\n\r\n if (\r\n batchData.totalPendingDeposits > 0 &&\r\n batchData.eta != 0 &&\r\n block.timestamp >= batchData.eta\r\n ) {\r\n pendingDeposits64x64 = ABDKMath64x64Token.fromDecimals(\r\n batchData.totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n liquidity64x64 = oldLiquidity64x64.add(pendingDeposits64x64);\r\n\r\n cLevel64x64 = l.applyCLevelLiquidityChangeAdjustment(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n liquidity64x64,\r\n isCall\r\n );\r\n } else {\r\n cLevel64x64 = oldCLevel64x64;\r\n liquidity64x64 = oldLiquidity64x64;\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate updated C-Level, accounting for change in liquidity\r\n * @param l storage layout struct\r\n * @param oldCLevel64x64 64x64 fixed point representation pool C-Level before accounting for liquidity change\r\n * @param oldLiquidity64x64 64x64 fixed point representation of previous liquidity\r\n * @param newLiquidity64x64 64x64 fixed point representation of current liquidity\r\n * @param isCallPool whether to update C-Level for call or put pool\r\n * @return cLevel64x64 64x64 fixed point representation of C-Level\r\n */\r\n function applyCLevelLiquidityChangeAdjustment(\r\n Layout storage l,\r\n int128 oldCLevel64x64,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64,\r\n bool isCallPool\r\n ) internal view returns (int128 cLevel64x64) {\r\n int128 steepness64x64 = isCallPool\r\n ? l.steepnessUnderlying64x64\r\n : l.steepnessBase64x64;\r\n\r\n // fallback to deprecated storage value if side-specific value is not set\r\n if (steepness64x64 == 0) steepness64x64 = l._deprecated_steepness64x64;\r\n\r\n cLevel64x64 = OptionMath.calculateCLevel(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64,\r\n steepness64x64\r\n );\r\n\r\n if (cLevel64x64 < 0xb333333333333333) {\r\n cLevel64x64 = int128(0xb333333333333333); // 64x64 fixed point representation of 0.7\r\n }\r\n }\r\n\r\n /**\r\n * @notice set C-Level to arbitrary pre-calculated value\r\n * @param cLevel64x64 new C-Level of pool\r\n * @param isCallPool whether to update C-Level for call or put pool\r\n */\r\n function setCLevel(\r\n Layout storage l,\r\n int128 cLevel64x64,\r\n bool isCallPool\r\n ) internal {\r\n if (isCallPool) {\r\n l.cLevelUnderlying64x64 = cLevel64x64;\r\n l.cLevelUnderlyingUpdatedAt = block.timestamp;\r\n } else {\r\n l.cLevelBase64x64 = cLevel64x64;\r\n l.cLevelBaseUpdatedAt = block.timestamp;\r\n }\r\n }\r\n\r\n function setOracles(\r\n Layout storage l,\r\n address baseOracle,\r\n address underlyingOracle\r\n ) internal {\r\n require(\r\n AggregatorV3Interface(baseOracle).decimals() ==\r\n AggregatorV3Interface(underlyingOracle).decimals(),\r\n \"Pool: oracle decimals must match\"\r\n );\r\n\r\n l.baseOracle = baseOracle;\r\n l.underlyingOracle = underlyingOracle;\r\n }\r\n\r\n function fetchPriceUpdate(Layout storage l)\r\n internal\r\n view\r\n returns (int128 price64x64)\r\n {\r\n int256 priceUnderlying = AggregatorInterface(l.underlyingOracle)\r\n .latestAnswer();\r\n int256 priceBase = AggregatorInterface(l.baseOracle).latestAnswer();\r\n\r\n return ABDKMath64x64.divi(priceUnderlying, priceBase);\r\n }\r\n\r\n /**\r\n * @notice set price update for hourly bucket corresponding to given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to update\r\n * @param price64x64 64x64 fixed point representation of price\r\n */\r\n function setPriceUpdate(\r\n Layout storage l,\r\n uint256 timestamp,\r\n int128 price64x64\r\n ) internal {\r\n uint256 bucket = timestamp / (1 hours);\r\n l.bucketPrices64x64[bucket] = price64x64;\r\n l.priceUpdateSequences[bucket >> 8] += 1 << (255 - (bucket & 255));\r\n }\r\n\r\n /**\r\n * @notice get price update for hourly bucket corresponding to given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to query\r\n * @return 64x64 fixed point representation of price\r\n */\r\n function getPriceUpdate(Layout storage l, uint256 timestamp)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n return l.bucketPrices64x64[timestamp / (1 hours)];\r\n }\r\n\r\n /**\r\n * @notice get first price update available following given timestamp\r\n * @param l storage layout struct\r\n * @param timestamp timestamp to query\r\n * @return 64x64 fixed point representation of price\r\n */\r\n function getPriceUpdateAfter(Layout storage l, uint256 timestamp)\r\n internal\r\n view\r\n returns (int128)\r\n {\r\n // price updates are grouped into hourly buckets\r\n uint256 bucket = timestamp / (1 hours);\r\n // divide by 256 to get the index of the relevant price update sequence\r\n uint256 sequenceId = bucket >> 8;\r\n\r\n // get position within sequence relevant to current price update\r\n\r\n uint256 offset = bucket & 255;\r\n // shift to skip buckets from earlier in sequence\r\n uint256 sequence = (l.priceUpdateSequences[sequenceId] << offset) >>\r\n offset;\r\n\r\n // iterate through future sequences until a price update is found\r\n // sequence corresponding to current timestamp used as upper bound\r\n\r\n uint256 currentPriceUpdateSequenceId = block.timestamp / (256 hours);\r\n\r\n while (sequence == 0 && sequenceId <= currentPriceUpdateSequenceId) {\r\n sequence = l.priceUpdateSequences[++sequenceId];\r\n }\r\n\r\n // if no price update is found (sequence == 0) function will return 0\r\n // this should never occur, as each relevant external function triggers a price update\r\n\r\n // the most significant bit of the sequence corresponds to the offset of the relevant bucket\r\n\r\n uint256 msb;\r\n\r\n for (uint256 i = 128; i > 0; i >>= 1) {\r\n if (sequence >> i > 0) {\r\n msb += i;\r\n sequence >>= i;\r\n }\r\n }\r\n\r\n return l.bucketPrices64x64[((sequenceId + 1) << 8) - msb - 1];\r\n }\r\n\r\n function fromBaseToUnderlyingDecimals(Layout storage l, uint256 value)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n int128 valueFixed64x64 = ABDKMath64x64Token.fromDecimals(\r\n value,\r\n l.baseDecimals\r\n );\r\n return\r\n ABDKMath64x64Token.toDecimals(\r\n valueFixed64x64,\r\n l.underlyingDecimals\r\n );\r\n }\r\n\r\n function fromUnderlyingToBaseDecimals(Layout storage l, uint256 value)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n int128 valueFixed64x64 = ABDKMath64x64Token.fromDecimals(\r\n value,\r\n l.underlyingDecimals\r\n );\r\n return ABDKMath64x64Token.toDecimals(valueFixed64x64, l.baseDecimals);\r\n }\r\n}\r\n"},"@solidstate/contracts/utils/AddressUtils.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary AddressUtils {\n function toString(address account) internal pure returns (string memory) {\n bytes32 value = bytes32(uint256(uint160(account)));\n bytes memory alphabet = '0123456789abcdef';\n bytes memory chars = new bytes(42);\n\n chars[0] = '0';\n chars[1] = 'x';\n\n for (uint256 i = 0; i < 20; i++) {\n chars[2 + i * 2] = alphabet[uint8(value[i + 12] >> 4)];\n chars[3 + i * 2] = alphabet[uint8(value[i + 12] & 0x0f)];\n }\n\n return string(chars);\n }\n\n function isContract(address account) internal view returns (bool) {\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n function sendValue(address payable account, uint256 amount) internal {\n (bool success, ) = account.call{ value: amount }('');\n require(success, 'AddressUtils: failed to send value');\n }\n\n function functionCall(address target, bytes memory data)\n internal\n returns (bytes memory)\n {\n return\n functionCall(target, data, 'AddressUtils: failed low-level call');\n }\n\n function functionCall(\n address target,\n bytes memory data,\n string memory error\n ) internal returns (bytes memory) {\n return _functionCallWithValue(target, data, 0, error);\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return\n functionCallWithValue(\n target,\n data,\n value,\n 'AddressUtils: failed low-level call with value'\n );\n }\n\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory error\n ) internal returns (bytes memory) {\n require(\n address(this).balance >= value,\n 'AddressUtils: insufficient balance for call'\n );\n return _functionCallWithValue(target, data, value, error);\n }\n\n function _functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory error\n ) private returns (bytes memory) {\n require(\n isContract(target),\n 'AddressUtils: function call to non-contract'\n );\n\n (bool success, bytes memory returnData) = target.call{ value: value }(\n data\n );\n\n if (success) {\n return returnData;\n } else if (returnData.length > 0) {\n assembly {\n let returnData_size := mload(returnData)\n revert(add(32, returnData), returnData_size)\n }\n } else {\n revert(error);\n }\n }\n}\n"},"@solidstate/contracts/token/ERC1155/enumerable/ERC1155Enumerable.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\nimport { ERC1155Base, ERC1155BaseInternal } from '../base/ERC1155Base.sol';\nimport { IERC1155Enumerable } from './IERC1155Enumerable.sol';\nimport { ERC1155EnumerableInternal, ERC1155EnumerableStorage } from './ERC1155EnumerableInternal.sol';\n\n/**\n * @title ERC1155 implementation including enumerable and aggregate functions\n */\nabstract contract ERC1155Enumerable is\n IERC1155Enumerable,\n ERC1155Base,\n ERC1155EnumerableInternal\n{\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function totalSupply(uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return ERC1155EnumerableStorage.layout().totalSupply[id];\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function totalHolders(uint256 id)\n public\n view\n virtual\n override\n returns (uint256)\n {\n return ERC1155EnumerableStorage.layout().accountsByToken[id].length();\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function accountsByToken(uint256 id)\n public\n view\n virtual\n override\n returns (address[] memory)\n {\n EnumerableSet.AddressSet storage accounts = ERC1155EnumerableStorage\n .layout()\n .accountsByToken[id];\n\n address[] memory addresses = new address[](accounts.length());\n\n for (uint256 i; i < accounts.length(); i++) {\n addresses[i] = accounts.at(i);\n }\n\n return addresses;\n }\n\n /**\n * @inheritdoc IERC1155Enumerable\n */\n function tokensByAccount(address account)\n public\n view\n virtual\n override\n returns (uint256[] memory)\n {\n EnumerableSet.UintSet storage tokens = ERC1155EnumerableStorage\n .layout()\n .tokensByAccount[account];\n\n uint256[] memory ids = new uint256[](tokens.length());\n\n for (uint256 i; i < tokens.length(); i++) {\n ids[i] = tokens.at(i);\n }\n\n return ids;\n }\n\n /**\n * @notice ERC1155 hook: update aggregate values\n * @inheritdoc ERC1155EnumerableInternal\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n )\n internal\n virtual\n override(ERC1155BaseInternal, ERC1155EnumerableInternal)\n {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n }\n}\n"},"@solidstate/contracts/token/ERC1155/IERC1155Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @title ERC1155 transfer receiver interface\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @notice validate receipt of ERC1155 transfer\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param id token ID received\n * @param value quantity of tokens received\n * @param data data payload\n * @return function's own selector if transfer is accepted\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @notice validate receipt of ERC1155 batch transfer\n * @param operator executor of transfer\n * @param from sender of tokens\n * @param ids token IDs received\n * @param values quantities of tokens received\n * @param data data payload\n * @return function's own selector if transfer is accepted\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n"},"contracts/pool/IPoolEvents.sol":{"content":"// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\ninterface IPoolEvents {\r\n event Purchase(\r\n address indexed user,\r\n uint256 longTokenId,\r\n uint256 contractSize,\r\n uint256 baseCost,\r\n uint256 feeCost,\r\n int128 spot64x64\r\n );\r\n\r\n event Exercise(\r\n address indexed user,\r\n uint256 longTokenId,\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 fee\r\n );\r\n\r\n event Underwrite(\r\n address indexed underwriter,\r\n address indexed longReceiver,\r\n uint256 shortTokenId,\r\n uint256 intervalContractSize,\r\n uint256 intervalPremium,\r\n bool isManualUnderwrite\r\n );\r\n\r\n event AssignExercise(\r\n address indexed underwriter,\r\n uint256 shortTokenId,\r\n uint256 freedAmount,\r\n uint256 intervalContractSize,\r\n uint256 fee\r\n );\r\n\r\n event Deposit(address indexed user, bool isCallPool, uint256 amount);\r\n\r\n event Withdrawal(\r\n address indexed user,\r\n bool isCallPool,\r\n uint256 depositedAt,\r\n uint256 amount\r\n );\r\n\r\n event FeeWithdrawal(bool indexed isCallPool, uint256 amount);\r\n\r\n event Annihilate(uint256 shortTokenId, uint256 amount);\r\n\r\n event UpdateCLevel(\r\n bool indexed isCall,\r\n int128 cLevel64x64,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64\r\n );\r\n\r\n event UpdateSteepness(int128 steepness64x64, bool isCallPool);\r\n}\r\n"},"contracts/oracle/VolatilitySurfaceOracleStorage.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {EnumerableSet} from \"@solidstate/contracts/utils/EnumerableSet.sol\";\r\n\r\nlibrary VolatilitySurfaceOracleStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.VolatilitySurfaceOracle\");\r\n\r\n uint256 internal constant COEFF_BITS = 51;\r\n uint256 internal constant COEFF_BITS_MINUS_ONE = 50;\r\n uint256 internal constant COEFF_AMOUNT = 5;\r\n // START_BIT = COEFF_BITS * (COEFF_AMOUNT - 1)\r\n uint256 internal constant START_BIT = 204;\r\n\r\n struct Update {\r\n uint256 updatedAt;\r\n bytes32 callCoefficients;\r\n bytes32 putCoefficients;\r\n }\r\n\r\n struct Layout {\r\n // Base token -> Underlying token -> Update\r\n mapping(address => mapping(address => Update)) volatilitySurfaces;\r\n // Relayer addresses which can be trusted to provide accurate option trades\r\n EnumerableSet.AddressSet whitelistedRelayers;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n\r\n function getCoefficients(\r\n Layout storage l,\r\n address baseToken,\r\n address underlyingToken,\r\n bool isCall\r\n ) internal view returns (bytes32) {\r\n Update storage u = l.volatilitySurfaces[baseToken][underlyingToken];\r\n return isCall ? u.callCoefficients : u.putCoefficients;\r\n }\r\n\r\n function parseVolatilitySurfaceCoefficients(bytes32 input)\r\n internal\r\n pure\r\n returns (int256[] memory coefficients)\r\n {\r\n coefficients = new int256[](COEFF_AMOUNT);\r\n\r\n // Value to add to negative numbers to cast them to int256\r\n int256 toAdd = (int256(-1) >> COEFF_BITS) << COEFF_BITS;\r\n\r\n assembly {\r\n let i := 0\r\n // Value equal to -1\r\n let mid := shl(COEFF_BITS_MINUS_ONE, 1)\r\n\r\n for {\r\n\r\n } lt(i, COEFF_AMOUNT) {\r\n\r\n } {\r\n let offset := sub(START_BIT, mul(COEFF_BITS, i))\r\n let coeff := shr(\r\n offset,\r\n sub(\r\n input,\r\n shl(\r\n add(offset, COEFF_BITS),\r\n shr(add(offset, COEFF_BITS), input)\r\n )\r\n )\r\n )\r\n\r\n // Check if value is a negative number and needs casting\r\n if or(eq(coeff, mid), gt(coeff, mid)) {\r\n coeff := add(coeff, toAdd)\r\n }\r\n\r\n // Store result in the coefficients array\r\n mstore(add(coefficients, add(0x20, mul(0x20, i))), coeff)\r\n\r\n i := add(i, 1)\r\n }\r\n }\r\n }\r\n\r\n function formatVolatilitySurfaceCoefficients(int256[5] memory coefficients)\r\n internal\r\n pure\r\n returns (bytes32 result)\r\n {\r\n for (uint256 i = 0; i < COEFF_AMOUNT; i++) {\r\n int256 max = int256(1 << COEFF_BITS_MINUS_ONE);\r\n require(\r\n coefficients[i] < max && coefficients[i] > -max,\r\n \"Out of bounds\"\r\n );\r\n }\r\n\r\n assembly {\r\n let i := 0\r\n\r\n for {\r\n\r\n } lt(i, COEFF_AMOUNT) {\r\n\r\n } {\r\n let offset := sub(START_BIT, mul(COEFF_BITS, i))\r\n let coeff := mload(add(coefficients, mul(0x20, i)))\r\n\r\n result := add(\r\n result,\r\n shl(\r\n offset,\r\n sub(coeff, shl(COEFF_BITS, shr(COEFF_BITS, coeff)))\r\n )\r\n )\r\n\r\n i := add(i, 1)\r\n }\r\n }\r\n }\r\n}\r\n"},"@solidstate/contracts/token/ERC1155/enumerable/IERC1155Enumerable.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC1155 enumerable and aggregate function interface\n */\ninterface IERC1155Enumerable {\n /**\n * @notice query total minted supply of given token\n * @param id token id to query\n * @return token supply\n */\n function totalSupply(uint256 id) external view returns (uint256);\n\n /**\n * @notice query total number of holders for given token\n * @param id token id to query\n * @return quantity of holders\n */\n function totalHolders(uint256 id) external view returns (uint256);\n\n /**\n * @notice query holders of given token\n * @param id token id to query\n * @return list of holder addresses\n */\n function accountsByToken(uint256 id)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice query tokens held by given address\n * @param account address to query\n * @return list of token ids\n */\n function tokensByAccount(address account)\n external\n view\n returns (uint256[] memory);\n}\n"},"@solidstate/contracts/token/ERC20/IERC20.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20Internal } from './IERC20Internal.sol';\n\n/**\n * @title ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/20\n */\ninterface IERC20 is IERC20Internal {\n /**\n * @notice query the total minted token supply\n * @return token supply\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @notice query the token balance of given account\n * @param account address to query\n * @return token balance\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @notice query the allowance granted from given holder to given spender\n * @param holder approver of allowance\n * @param spender recipient of allowance\n * @return token allowance\n */\n function allowance(address holder, address spender)\n external\n view\n returns (uint256);\n\n /**\n * @notice grant approval to spender to spend tokens\n * @dev prefer ERC20Extended functions to avoid transaction-ordering vulnerability (see https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729)\n * @param spender recipient of allowance\n * @param amount quantity of tokens approved for spending\n * @return success status (always true; otherwise function should revert)\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @notice transfer tokens to given recipient\n * @param recipient beneficiary of token transfer\n * @param amount quantity of tokens to transfer\n * @return success status (always true; otherwise function should revert)\n */\n function transfer(address recipient, uint256 amount)\n external\n returns (bool);\n\n /**\n * @notice transfer tokens to given recipient on behalf of given holder\n * @param holder holder of tokens prior to transfer\n * @param recipient beneficiary of token transfer\n * @param amount quantity of tokens to transfer\n * @return success status (always true; otherwise function should revert)\n */\n function transferFrom(\n address holder,\n address recipient,\n uint256 amount\n ) external returns (bool);\n}\n"},"contracts/mining/IPremiaMining.sol":{"content":"// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {PremiaMiningStorage} from \"./PremiaMiningStorage.sol\";\r\n\r\ninterface IPremiaMining {\r\n function addPremiaRewards(uint256 _amount) external;\r\n\r\n function premiaRewardsAvailable() external view returns (uint256);\r\n\r\n function getTotalAllocationPoints() external view returns (uint256);\r\n\r\n function getPoolInfo(address pool, bool isCallPool)\r\n external\r\n view\r\n returns (PremiaMiningStorage.PoolInfo memory);\r\n\r\n function getPremiaPerYear() external view returns (uint256);\r\n\r\n function addPool(address _pool, uint256 _allocPoints) external;\r\n\r\n function setPoolAllocPoints(\r\n address[] memory _pools,\r\n uint256[] memory _allocPoints\r\n ) external;\r\n\r\n function pendingPremia(\r\n address _pool,\r\n bool _isCallPool,\r\n address _user\r\n ) external view returns (uint256);\r\n\r\n function updatePool(\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _totalTVL\r\n ) external;\r\n\r\n function allocatePending(\r\n address _user,\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _userTVLOld,\r\n uint256 _userTVLNew,\r\n uint256 _totalTVL\r\n ) external;\r\n\r\n function claim(\r\n address _user,\r\n address _pool,\r\n bool _isCallPool,\r\n uint256 _userTVLOld,\r\n uint256 _userTVLNew,\r\n uint256 _totalTVL\r\n ) external;\r\n}\r\n"},"@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableStorage.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\n\nlibrary ERC1155EnumerableStorage {\n struct Layout {\n mapping(uint256 => uint256) totalSupply;\n mapping(uint256 => EnumerableSet.AddressSet) accountsByToken;\n mapping(address => EnumerableSet.UintSet) tokensByAccount;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.ERC1155Enumerable');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n"},"@solidstate/contracts/token/ERC1155/enumerable/ERC1155EnumerableInternal.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../../utils/EnumerableSet.sol';\nimport { ERC1155BaseInternal, ERC1155BaseStorage } from '../base/ERC1155BaseInternal.sol';\nimport { ERC1155EnumerableStorage } from './ERC1155EnumerableStorage.sol';\n\n/**\n * @title ERC1155Enumerable internal functions\n */\nabstract contract ERC1155EnumerableInternal is ERC1155BaseInternal {\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.UintSet;\n\n /**\n * @notice ERC1155 hook: update aggregate values\n * @inheritdoc ERC1155BaseInternal\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n\n if (from != to) {\n ERC1155EnumerableStorage.Layout storage l = ERC1155EnumerableStorage\n .layout();\n mapping(uint256 => EnumerableSet.AddressSet)\n storage tokenAccounts = l.accountsByToken;\n EnumerableSet.UintSet storage fromTokens = l.tokensByAccount[from];\n EnumerableSet.UintSet storage toTokens = l.tokensByAccount[to];\n\n for (uint256 i; i < ids.length; i++) {\n uint256 amount = amounts[i];\n\n if (amount > 0) {\n uint256 id = ids[i];\n\n if (from == address(0)) {\n l.totalSupply[id] += amount;\n } else if (_balanceOf(from, id) == amount) {\n tokenAccounts[id].remove(from);\n fromTokens.remove(id);\n }\n\n if (to == address(0)) {\n l.totalSupply[id] -= amount;\n } else if (_balanceOf(to, id) == 0) {\n tokenAccounts[id].add(to);\n toTokens.add(id);\n }\n }\n }\n }\n }\n}\n"},"contracts/oracle/IVolatilitySurfaceOracle.sol":{"content":"// SPDX-License-Identifier: LGPL-3.0-or-later\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {VolatilitySurfaceOracleStorage} from \"./VolatilitySurfaceOracleStorage.sol\";\r\n\r\ninterface IVolatilitySurfaceOracle {\r\n function getWhitelistedRelayers() external view returns (address[] memory);\r\n\r\n function getVolatilitySurface(address baseToken, address underlyingToken)\r\n external\r\n view\r\n returns (VolatilitySurfaceOracleStorage.Update memory);\r\n\r\n function getVolatilitySurfaceCoefficientsUnpacked(\r\n address baseToken,\r\n address underlyingToken,\r\n bool isCall\r\n ) external view returns (int256[] memory);\r\n\r\n function getTimeToMaturity64x64(uint64 maturity)\r\n external\r\n view\r\n returns (int128);\r\n\r\n function getAnnualizedVolatility64x64(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 spot64x64,\r\n int128 strike64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (int128);\r\n\r\n function getBlackScholesPrice64x64(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (int128);\r\n\r\n function getBlackScholesPrice(\r\n address baseToken,\r\n address underlyingToken,\r\n int128 strike64x64,\r\n int128 spot64x64,\r\n int128 timeToMaturity64x64,\r\n bool isCall\r\n ) external view returns (uint256);\r\n}\r\n"},"contracts/pool/PoolInternal.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport {IERC173} from \"@solidstate/contracts/access/IERC173.sol\";\r\nimport {OwnableStorage} from \"@solidstate/contracts/access/OwnableStorage.sol\";\r\nimport {IERC20} from \"@solidstate/contracts/token/ERC20/IERC20.sol\";\r\nimport {ERC1155EnumerableInternal, ERC1155EnumerableStorage, EnumerableSet} from \"@solidstate/contracts/token/ERC1155/enumerable/ERC1155Enumerable.sol\";\r\nimport {IWETH} from \"@solidstate/contracts/utils/IWETH.sol\";\r\n\r\nimport {PoolStorage} from \"./PoolStorage.sol\";\r\n\r\nimport {ABDKMath64x64} from \"abdk-libraries-solidity/ABDKMath64x64.sol\";\r\nimport {ABDKMath64x64Token} from \"../libraries/ABDKMath64x64Token.sol\";\r\nimport {OptionMath} from \"../libraries/OptionMath.sol\";\r\nimport {IFeeDiscount} from \"../staking/IFeeDiscount.sol\";\r\nimport {IPoolEvents} from \"./IPoolEvents.sol\";\r\nimport {IPremiaMining} from \"../mining/IPremiaMining.sol\";\r\nimport {IVolatilitySurfaceOracle} from \"../oracle/IVolatilitySurfaceOracle.sol\";\r\n\r\n/**\r\n * @title Premia option pool\r\n * @dev deployed standalone and referenced by PoolProxy\r\n */\r\ncontract PoolInternal is IPoolEvents, ERC1155EnumerableInternal {\r\n using ABDKMath64x64 for int128;\r\n using EnumerableSet for EnumerableSet.AddressSet;\r\n using EnumerableSet for EnumerableSet.UintSet;\r\n using PoolStorage for PoolStorage.Layout;\r\n\r\n address internal immutable WETH_ADDRESS;\r\n address internal immutable PREMIA_MINING_ADDRESS;\r\n address internal immutable FEE_RECEIVER_ADDRESS;\r\n address internal immutable FEE_DISCOUNT_ADDRESS;\r\n address internal immutable IVOL_ORACLE_ADDRESS;\r\n\r\n int128 internal immutable FEE_64x64;\r\n\r\n uint256 internal immutable UNDERLYING_FREE_LIQ_TOKEN_ID;\r\n uint256 internal immutable BASE_FREE_LIQ_TOKEN_ID;\r\n\r\n uint256 internal immutable UNDERLYING_RESERVED_LIQ_TOKEN_ID;\r\n uint256 internal immutable BASE_RESERVED_LIQ_TOKEN_ID;\r\n\r\n uint256 internal constant INVERSE_BASIS_POINT = 1e4;\r\n uint256 internal constant BATCHING_PERIOD = 260;\r\n\r\n // Minimum APY for capital locked up to underwrite options.\r\n // The quote will return a minimum price corresponding to this APY\r\n int128 internal constant MIN_APY_64x64 = 0x4ccccccccccccccd; // 0.3\r\n\r\n constructor(\r\n address ivolOracle,\r\n address weth,\r\n address premiaMining,\r\n address feeReceiver,\r\n address feeDiscountAddress,\r\n int128 fee64x64\r\n ) {\r\n IVOL_ORACLE_ADDRESS = ivolOracle;\r\n WETH_ADDRESS = weth;\r\n PREMIA_MINING_ADDRESS = premiaMining;\r\n FEE_RECEIVER_ADDRESS = feeReceiver;\r\n // PremiaFeeDiscount contract address\r\n FEE_DISCOUNT_ADDRESS = feeDiscountAddress;\r\n FEE_64x64 = fee64x64;\r\n\r\n UNDERLYING_FREE_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.UNDERLYING_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n BASE_FREE_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.BASE_FREE_LIQ,\r\n 0,\r\n 0\r\n );\r\n\r\n UNDERLYING_RESERVED_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.UNDERLYING_RESERVED_LIQ,\r\n 0,\r\n 0\r\n );\r\n BASE_RESERVED_LIQ_TOKEN_ID = PoolStorage.formatTokenId(\r\n PoolStorage.TokenType.BASE_RESERVED_LIQ,\r\n 0,\r\n 0\r\n );\r\n }\r\n\r\n modifier onlyProtocolOwner() {\r\n require(\r\n msg.sender == IERC173(OwnableStorage.layout().owner).owner(),\r\n \"Not protocol owner\"\r\n );\r\n _;\r\n }\r\n\r\n function _getFeeDiscount(address feePayer)\r\n internal\r\n view\r\n returns (uint256 discount)\r\n {\r\n if (FEE_DISCOUNT_ADDRESS != address(0)) {\r\n discount = IFeeDiscount(FEE_DISCOUNT_ADDRESS).getDiscount(feePayer);\r\n }\r\n }\r\n\r\n function _getFeeWithDiscount(address feePayer, uint256 fee)\r\n internal\r\n view\r\n returns (uint256)\r\n {\r\n uint256 discount = _getFeeDiscount(feePayer);\r\n return fee - ((fee * discount) / INVERSE_BASIS_POINT);\r\n }\r\n\r\n function _withdrawFees(bool isCall) internal returns (uint256 amount) {\r\n uint256 tokenId = _getReservedLiquidityTokenId(isCall);\r\n amount = _balanceOf(FEE_RECEIVER_ADDRESS, tokenId);\r\n\r\n if (amount > 0) {\r\n _burn(FEE_RECEIVER_ADDRESS, tokenId, amount);\r\n emit FeeWithdrawal(isCall, amount);\r\n }\r\n }\r\n\r\n /**\r\n * @notice calculate price of option contract\r\n * @param args structured quote arguments\r\n * @return result quote result\r\n */\r\n function _quote(PoolStorage.QuoteArgsInternal memory args)\r\n internal\r\n view\r\n returns (PoolStorage.QuoteResultInternal memory result)\r\n {\r\n require(\r\n args.strike64x64 > 0 && args.spot64x64 > 0 && args.maturity > 0,\r\n \"invalid args\"\r\n );\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n int128 contractSize64x64 = ABDKMath64x64Token.fromDecimals(\r\n args.contractSize,\r\n l.underlyingDecimals\r\n );\r\n bool isCall = args.isCall;\r\n\r\n (int128 adjustedCLevel64x64, int128 oldLiquidity64x64) = l\r\n .applyCLevelPendingDepositAdjustment(\r\n l.getDecayAdjustedCLevel64x64(isCall),\r\n l.totalFreeLiquiditySupply64x64(isCall),\r\n isCall\r\n );\r\n\r\n require(oldLiquidity64x64 > 0, \"no liq\");\r\n\r\n int128 timeToMaturity64x64 = ABDKMath64x64.divu(\r\n args.maturity - block.timestamp,\r\n 365 days\r\n );\r\n\r\n int128 annualizedVolatility64x64 = IVolatilitySurfaceOracle(\r\n IVOL_ORACLE_ADDRESS\r\n ).getAnnualizedVolatility64x64(\r\n l.base,\r\n l.underlying,\r\n args.spot64x64,\r\n args.strike64x64,\r\n timeToMaturity64x64,\r\n isCall\r\n );\r\n\r\n require(annualizedVolatility64x64 > 0, \"vol = 0\");\r\n\r\n (\r\n int128 price64x64,\r\n int128 cLevel64x64,\r\n int128 slippageCoefficient64x64\r\n ) = OptionMath.quotePrice(\r\n OptionMath.QuoteArgs(\r\n annualizedVolatility64x64.mul(annualizedVolatility64x64),\r\n args.strike64x64,\r\n args.spot64x64,\r\n timeToMaturity64x64,\r\n adjustedCLevel64x64,\r\n oldLiquidity64x64,\r\n oldLiquidity64x64.sub(contractSize64x64),\r\n 0x10000000000000000, // 64x64 fixed point representation of 1\r\n MIN_APY_64x64,\r\n isCall\r\n )\r\n );\r\n\r\n result.baseCost64x64 = isCall\r\n ? price64x64.mul(contractSize64x64).div(args.spot64x64)\r\n : price64x64.mul(contractSize64x64);\r\n result.feeCost64x64 = result.baseCost64x64.mul(FEE_64x64);\r\n result.cLevel64x64 = cLevel64x64;\r\n result.slippageCoefficient64x64 = slippageCoefficient64x64;\r\n\r\n int128 discount = ABDKMath64x64.divu(\r\n _getFeeDiscount(args.feePayer),\r\n INVERSE_BASIS_POINT\r\n );\r\n result.feeCost64x64 -= result.feeCost64x64.mul(discount);\r\n }\r\n\r\n /**\r\n * @notice burn corresponding long and short option tokens\r\n * @param account holder of tokens to annihilate\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize quantity of option contract tokens to annihilate\r\n */\r\n function _annihilate(\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize\r\n ) internal {\r\n uint256 longTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, true),\r\n maturity,\r\n strike64x64\r\n );\r\n uint256 shortTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n _burn(account, longTokenId, contractSize);\r\n _burn(account, shortTokenId, contractSize);\r\n\r\n emit Annihilate(shortTokenId, contractSize);\r\n }\r\n\r\n /**\r\n * @notice purchase option\r\n * @param l storage layout struct\r\n * @param account recipient of purchased option\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize size of option contract\r\n * @param newPrice64x64 64x64 fixed point representation of current spot price\r\n * @return baseCost quantity of tokens required to purchase long position\r\n * @return feeCost quantity of tokens required to pay fees\r\n */\r\n function _purchase(\r\n PoolStorage.Layout storage l,\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize,\r\n int128 newPrice64x64\r\n ) internal returns (uint256 baseCost, uint256 feeCost) {\r\n require(maturity > block.timestamp, \"expired\");\r\n require(contractSize >= l.underlyingMinimum, \"too small\");\r\n\r\n {\r\n uint256 size = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(\r\n strike64x64.mulu(contractSize)\r\n );\r\n\r\n require(\r\n size <=\r\n ERC1155EnumerableStorage.layout().totalSupply[\r\n _getFreeLiquidityTokenId(isCall)\r\n ] -\r\n l.nextDeposits[isCall].totalPendingDeposits,\r\n \"insuf liq\"\r\n );\r\n }\r\n\r\n PoolStorage.QuoteResultInternal memory quote = _quote(\r\n PoolStorage.QuoteArgsInternal(\r\n account,\r\n maturity,\r\n strike64x64,\r\n newPrice64x64,\r\n contractSize,\r\n isCall\r\n )\r\n );\r\n\r\n baseCost = ABDKMath64x64Token.toDecimals(\r\n quote.baseCost64x64,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n feeCost = ABDKMath64x64Token.toDecimals(\r\n quote.feeCost64x64,\r\n l.getTokenDecimals(isCall)\r\n );\r\n\r\n uint256 longTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, true),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n uint256 shortTokenId = PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n );\r\n\r\n // mint long option token for buyer\r\n _mint(account, longTokenId, contractSize);\r\n\r\n int128 oldLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n // burn free liquidity tokens from other underwriters\r\n _mintShortTokenLoop(\r\n l,\r\n account,\r\n contractSize,\r\n baseCost,\r\n shortTokenId,\r\n isCall\r\n );\r\n int128 newLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n\r\n _setCLevel(l, oldLiquidity64x64, newLiquidity64x64, isCall);\r\n\r\n // mint reserved liquidity tokens for fee receiver\r\n _mint(\r\n FEE_RECEIVER_ADDRESS,\r\n _getReservedLiquidityTokenId(isCall),\r\n feeCost\r\n );\r\n\r\n emit Purchase(\r\n account,\r\n longTokenId,\r\n contractSize,\r\n baseCost,\r\n feeCost,\r\n newPrice64x64\r\n );\r\n }\r\n\r\n /**\r\n * @notice reassign short position to new underwriter\r\n * @param l storage layout struct\r\n * @param account holder of positions to be reassigned\r\n * @param maturity timestamp of option maturity\r\n * @param strike64x64 64x64 fixed point representation of strike price\r\n * @param isCall true for call, false for put\r\n * @param contractSize quantity of option contract tokens to reassign\r\n * @param newPrice64x64 64x64 fixed point representation of current spot price\r\n * @return baseCost quantity of tokens required to reassign short position\r\n * @return feeCost quantity of tokens required to pay fees\r\n * @return amountOut quantity of liquidity freed\r\n */\r\n function _reassign(\r\n PoolStorage.Layout storage l,\r\n address account,\r\n uint64 maturity,\r\n int128 strike64x64,\r\n bool isCall,\r\n uint256 contractSize,\r\n int128 newPrice64x64\r\n )\r\n internal\r\n returns (\r\n uint256 baseCost,\r\n uint256 feeCost,\r\n uint256 amountOut\r\n )\r\n {\r\n (baseCost, feeCost) = _purchase(\r\n l,\r\n account,\r\n maturity,\r\n strike64x64,\r\n isCall,\r\n contractSize,\r\n newPrice64x64\r\n );\r\n\r\n _annihilate(account, maturity, strike64x64, isCall, contractSize);\r\n\r\n uint256 annihilateAmount = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(contractSize));\r\n\r\n amountOut = annihilateAmount - baseCost - feeCost;\r\n }\r\n\r\n /**\r\n * @notice exercise option on behalf of holder\r\n * @dev used for processing of expired options if passed holder is zero address\r\n * @param holder owner of long option tokens to exercise\r\n * @param longTokenId long option token id\r\n * @param contractSize quantity of tokens to exercise\r\n */\r\n function _exercise(\r\n address holder,\r\n uint256 longTokenId,\r\n uint256 contractSize\r\n ) internal {\r\n uint64 maturity;\r\n int128 strike64x64;\r\n bool isCall;\r\n\r\n bool onlyExpired = holder == address(0);\r\n\r\n {\r\n PoolStorage.TokenType tokenType;\r\n (tokenType, maturity, strike64x64) = PoolStorage.parseTokenId(\r\n longTokenId\r\n );\r\n require(\r\n tokenType == PoolStorage.TokenType.LONG_CALL ||\r\n tokenType == PoolStorage.TokenType.LONG_PUT,\r\n \"invalid type\"\r\n );\r\n require(!onlyExpired || maturity < block.timestamp, \"not expired\");\r\n isCall = tokenType == PoolStorage.TokenType.LONG_CALL;\r\n }\r\n\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n int128 spot64x64 = _update(l);\r\n\r\n if (maturity < block.timestamp) {\r\n spot64x64 = l.getPriceUpdateAfter(maturity);\r\n }\r\n\r\n require(\r\n onlyExpired ||\r\n (\r\n isCall\r\n ? (spot64x64 > strike64x64)\r\n : (spot64x64 < strike64x64)\r\n ),\r\n \"not ITM\"\r\n );\r\n\r\n uint256 exerciseValue;\r\n // option has a non-zero exercise value\r\n if (isCall) {\r\n if (spot64x64 > strike64x64) {\r\n exerciseValue = spot64x64.sub(strike64x64).div(spot64x64).mulu(\r\n contractSize\r\n );\r\n }\r\n } else {\r\n if (spot64x64 < strike64x64) {\r\n exerciseValue = l.fromUnderlyingToBaseDecimals(\r\n strike64x64.sub(spot64x64).mulu(contractSize)\r\n );\r\n }\r\n }\r\n\r\n uint256 totalFee;\r\n\r\n if (onlyExpired) {\r\n totalFee += _burnLongTokenLoop(\r\n contractSize,\r\n exerciseValue,\r\n longTokenId,\r\n isCall\r\n );\r\n } else {\r\n // burn long option tokens from sender\r\n _burn(holder, longTokenId, contractSize);\r\n\r\n uint256 fee;\r\n\r\n if (exerciseValue > 0) {\r\n fee = _getFeeWithDiscount(\r\n holder,\r\n FEE_64x64.mulu(exerciseValue)\r\n );\r\n totalFee += fee;\r\n\r\n _pushTo(holder, _getPoolToken(isCall), exerciseValue - fee);\r\n }\r\n\r\n emit Exercise(\r\n holder,\r\n longTokenId,\r\n contractSize,\r\n exerciseValue,\r\n fee\r\n );\r\n }\r\n\r\n totalFee += _burnShortTokenLoop(\r\n contractSize,\r\n exerciseValue,\r\n PoolStorage.formatTokenId(\r\n _getTokenType(isCall, false),\r\n maturity,\r\n strike64x64\r\n ),\r\n isCall\r\n );\r\n\r\n _mint(\r\n FEE_RECEIVER_ADDRESS,\r\n _getReservedLiquidityTokenId(isCall),\r\n totalFee\r\n );\r\n }\r\n\r\n function _mintShortTokenLoop(\r\n PoolStorage.Layout storage l,\r\n address buyer,\r\n uint256 contractSize,\r\n uint256 premium,\r\n uint256 shortTokenId,\r\n bool isCall\r\n ) internal {\r\n uint256 freeLiqTokenId = _getFreeLiquidityTokenId(isCall);\r\n (, , int128 strike64x64) = PoolStorage.parseTokenId(shortTokenId);\r\n\r\n uint256 toPay = isCall\r\n ? contractSize\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(contractSize));\r\n\r\n while (toPay > 0) {\r\n address underwriter = l.liquidityQueueAscending[isCall][address(0)];\r\n uint256 balance = _balanceOf(underwriter, freeLiqTokenId);\r\n\r\n // If dust left, we remove underwriter and skip to next\r\n if (balance < _getMinimumAmount(l, isCall)) {\r\n l.removeUnderwriter(underwriter, isCall);\r\n continue;\r\n }\r\n\r\n if (!l.getReinvestmentStatus(underwriter, isCall)) {\r\n _burn(underwriter, freeLiqTokenId, balance);\r\n _mint(\r\n underwriter,\r\n _getReservedLiquidityTokenId(isCall),\r\n balance\r\n );\r\n _subUserTVL(l, underwriter, isCall, balance);\r\n continue;\r\n }\r\n\r\n // amount of liquidity provided by underwriter, accounting for reinvested premium\r\n uint256 intervalContractSize = ((balance -\r\n l.pendingDeposits[underwriter][l.nextDeposits[isCall].eta][\r\n isCall\r\n ]) * (toPay + premium)) / toPay;\r\n if (intervalContractSize == 0) continue;\r\n if (intervalContractSize > toPay) intervalContractSize = toPay;\r\n\r\n // amount of premium paid to underwriter\r\n uint256 intervalPremium = (premium * intervalContractSize) / toPay;\r\n premium -= intervalPremium;\r\n toPay -= intervalContractSize;\r\n _addUserTVL(l, underwriter, isCall, intervalPremium);\r\n\r\n // burn free liquidity tokens from underwriter\r\n _burn(\r\n underwriter,\r\n freeLiqTokenId,\r\n intervalContractSize - intervalPremium\r\n );\r\n\r\n if (isCall == false) {\r\n // For PUT, conversion to contract amount is done here (Prior to this line, it is token amount)\r\n intervalContractSize = l.fromBaseToUnderlyingDecimals(\r\n strike64x64.inv().mulu(intervalContractSize)\r\n );\r\n }\r\n\r\n // mint short option tokens for underwriter\r\n // toPay == 0 ? contractSize : intervalContractSize : To prevent minting less than amount,\r\n // because of rounding (Can happen for put, because of fixed point precision)\r\n _mint(\r\n underwriter,\r\n shortTokenId,\r\n toPay == 0 ? contractSize : intervalContractSize\r\n );\r\n\r\n emit Underwrite(\r\n underwriter,\r\n buyer,\r\n shortTokenId,\r\n toPay == 0 ? contractSize : intervalContractSize,\r\n intervalPremium,\r\n false\r\n );\r\n\r\n contractSize -= intervalContractSize;\r\n }\r\n }\r\n\r\n function _burnLongTokenLoop(\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 longTokenId,\r\n bool isCall\r\n ) internal returns (uint256 totalFee) {\r\n EnumerableSet.AddressSet storage holders = ERC1155EnumerableStorage\r\n .layout()\r\n .accountsByToken[longTokenId];\r\n\r\n while (contractSize > 0) {\r\n address longTokenHolder = holders.at(holders.length() - 1);\r\n\r\n uint256 intervalContractSize = _balanceOf(\r\n longTokenHolder,\r\n longTokenId\r\n );\r\n if (intervalContractSize > contractSize)\r\n intervalContractSize = contractSize;\r\n\r\n uint256 intervalExerciseValue;\r\n\r\n uint256 fee;\r\n if (exerciseValue > 0) {\r\n intervalExerciseValue =\r\n (exerciseValue * intervalContractSize) /\r\n contractSize;\r\n\r\n fee = _getFeeWithDiscount(\r\n longTokenHolder,\r\n FEE_64x64.mulu(intervalExerciseValue)\r\n );\r\n totalFee += fee;\r\n\r\n exerciseValue -= intervalExerciseValue;\r\n _pushTo(\r\n longTokenHolder,\r\n _getPoolToken(isCall),\r\n intervalExerciseValue - fee\r\n );\r\n }\r\n\r\n contractSize -= intervalContractSize;\r\n\r\n emit Exercise(\r\n longTokenHolder,\r\n longTokenId,\r\n intervalContractSize,\r\n intervalExerciseValue - fee,\r\n fee\r\n );\r\n\r\n _burn(longTokenHolder, longTokenId, intervalContractSize);\r\n }\r\n }\r\n\r\n function _burnShortTokenLoop(\r\n uint256 contractSize,\r\n uint256 exerciseValue,\r\n uint256 shortTokenId,\r\n bool isCall\r\n ) internal returns (uint256 totalFee) {\r\n EnumerableSet.AddressSet storage underwriters = ERC1155EnumerableStorage\r\n .layout()\r\n .accountsByToken[shortTokenId];\r\n (, , int128 strike64x64) = PoolStorage.parseTokenId(shortTokenId);\r\n\r\n while (contractSize > 0) {\r\n address underwriter = underwriters.at(underwriters.length() - 1);\r\n\r\n // amount of liquidity provided by underwriter\r\n uint256 intervalContractSize = _balanceOf(\r\n underwriter,\r\n shortTokenId\r\n );\r\n if (intervalContractSize > contractSize)\r\n intervalContractSize = contractSize;\r\n\r\n // amount of value claimed by buyer\r\n uint256 intervalExerciseValue = (exerciseValue *\r\n intervalContractSize) / contractSize;\r\n exerciseValue -= intervalExerciseValue;\r\n contractSize -= intervalContractSize;\r\n\r\n uint256 freeLiq = isCall\r\n ? intervalContractSize - intervalExerciseValue\r\n : PoolStorage.layout().fromUnderlyingToBaseDecimals(\r\n strike64x64.mulu(intervalContractSize)\r\n ) - intervalExerciseValue;\r\n\r\n uint256 fee = _getFeeWithDiscount(\r\n underwriter,\r\n FEE_64x64.mulu(freeLiq)\r\n );\r\n totalFee += fee;\r\n\r\n uint256 tvlToSubtract = intervalExerciseValue;\r\n\r\n // mint free liquidity tokens for underwriter\r\n if (\r\n PoolStorage.layout().getReinvestmentStatus(underwriter, isCall)\r\n ) {\r\n _addToDepositQueue(underwriter, freeLiq - fee, isCall);\r\n tvlToSubtract += fee;\r\n } else {\r\n _mint(\r\n underwriter,\r\n _getReservedLiquidityTokenId(isCall),\r\n freeLiq - fee\r\n );\r\n tvlToSubtract += freeLiq;\r\n }\r\n\r\n _subUserTVL(\r\n PoolStorage.layout(),\r\n underwriter,\r\n isCall,\r\n tvlToSubtract\r\n );\r\n\r\n // burn short option tokens from underwriter\r\n _burn(underwriter, shortTokenId, intervalContractSize);\r\n\r\n emit AssignExercise(\r\n underwriter,\r\n shortTokenId,\r\n freeLiq - fee,\r\n intervalContractSize,\r\n fee\r\n );\r\n }\r\n }\r\n\r\n function _addToDepositQueue(\r\n address account,\r\n uint256 amount,\r\n bool isCallPool\r\n ) internal {\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n _mint(account, _getFreeLiquidityTokenId(isCallPool), amount);\r\n\r\n uint256 nextBatch = (block.timestamp / BATCHING_PERIOD) *\r\n BATCHING_PERIOD +\r\n BATCHING_PERIOD;\r\n l.pendingDeposits[account][nextBatch][isCallPool] += amount;\r\n\r\n PoolStorage.BatchData storage batchData = l.nextDeposits[isCallPool];\r\n batchData.totalPendingDeposits += amount;\r\n batchData.eta = nextBatch;\r\n }\r\n\r\n function _processPendingDeposits(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n {\r\n PoolStorage.BatchData storage data = l.nextDeposits[isCall];\r\n\r\n if (data.eta == 0 || block.timestamp < data.eta) return;\r\n\r\n int128 oldLiquidity64x64 = l.totalFreeLiquiditySupply64x64(isCall);\r\n\r\n _setCLevel(\r\n l,\r\n oldLiquidity64x64,\r\n oldLiquidity64x64.add(\r\n ABDKMath64x64Token.fromDecimals(\r\n data.totalPendingDeposits,\r\n l.getTokenDecimals(isCall)\r\n )\r\n ),\r\n isCall\r\n );\r\n\r\n delete l.nextDeposits[isCall];\r\n }\r\n\r\n function _getFreeLiquidityTokenId(bool isCall)\r\n internal\r\n view\r\n returns (uint256 freeLiqTokenId)\r\n {\r\n freeLiqTokenId = isCall\r\n ? UNDERLYING_FREE_LIQ_TOKEN_ID\r\n : BASE_FREE_LIQ_TOKEN_ID;\r\n }\r\n\r\n function _getReservedLiquidityTokenId(bool isCall)\r\n internal\r\n view\r\n returns (uint256 reservedLiqTokenId)\r\n {\r\n reservedLiqTokenId = isCall\r\n ? UNDERLYING_RESERVED_LIQ_TOKEN_ID\r\n : BASE_RESERVED_LIQ_TOKEN_ID;\r\n }\r\n\r\n function _getPoolToken(bool isCall) internal view returns (address token) {\r\n token = isCall\r\n ? PoolStorage.layout().underlying\r\n : PoolStorage.layout().base;\r\n }\r\n\r\n function _getTokenType(bool isCall, bool isLong)\r\n internal\r\n pure\r\n returns (PoolStorage.TokenType tokenType)\r\n {\r\n if (isCall) {\r\n tokenType = isLong\r\n ? PoolStorage.TokenType.LONG_CALL\r\n : PoolStorage.TokenType.SHORT_CALL;\r\n } else {\r\n tokenType = isLong\r\n ? PoolStorage.TokenType.LONG_PUT\r\n : PoolStorage.TokenType.SHORT_PUT;\r\n }\r\n }\r\n\r\n function _getMinimumAmount(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint256 minimumAmount)\r\n {\r\n minimumAmount = isCall ? l.underlyingMinimum : l.baseMinimum;\r\n }\r\n\r\n function _getPoolCapAmount(PoolStorage.Layout storage l, bool isCall)\r\n internal\r\n view\r\n returns (uint256 poolCapAmount)\r\n {\r\n poolCapAmount = isCall ? l.underlyingPoolCap : l.basePoolCap;\r\n }\r\n\r\n function _setCLevel(\r\n PoolStorage.Layout storage l,\r\n int128 oldLiquidity64x64,\r\n int128 newLiquidity64x64,\r\n bool isCallPool\r\n ) internal {\r\n int128 oldCLevel64x64 = l.getDecayAdjustedCLevel64x64(isCallPool);\r\n\r\n int128 cLevel64x64 = l.applyCLevelLiquidityChangeAdjustment(\r\n oldCLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64,\r\n isCallPool\r\n );\r\n\r\n l.setCLevel(cLevel64x64, isCallPool);\r\n\r\n emit UpdateCLevel(\r\n isCallPool,\r\n cLevel64x64,\r\n oldLiquidity64x64,\r\n newLiquidity64x64\r\n );\r\n }\r\n\r\n /**\r\n * @notice calculate and store updated market state\r\n * @param l storage layout struct\r\n * @return newPrice64x64 64x64 fixed point representation of current spot price\r\n */\r\n function _update(PoolStorage.Layout storage l)\r\n internal\r\n returns (int128 newPrice64x64)\r\n {\r\n if (l.updatedAt == block.timestamp) {\r\n return (l.getPriceUpdate(block.timestamp));\r\n }\r\n\r\n newPrice64x64 = l.fetchPriceUpdate();\r\n\r\n if (l.getPriceUpdate(block.timestamp) == 0) {\r\n l.setPriceUpdate(block.timestamp, newPrice64x64);\r\n }\r\n\r\n l.updatedAt = block.timestamp;\r\n\r\n _processPendingDeposits(l, true);\r\n _processPendingDeposits(l, false);\r\n }\r\n\r\n /**\r\n * @notice transfer ERC20 tokens to message sender\r\n * @param token ERC20 token address\r\n * @param amount quantity of token to transfer\r\n */\r\n function _pushTo(\r\n address to,\r\n address token,\r\n uint256 amount\r\n ) internal {\r\n if (amount == 0) return;\r\n\r\n require(IERC20(token).transfer(to, amount), \"ERC20 transfer failed\");\r\n }\r\n\r\n /**\r\n * @notice transfer ERC20 tokens from message sender\r\n * @param from address from which tokens are pulled from\r\n * @param token ERC20 token address\r\n * @param amount quantity of token to transfer\r\n * @param skipWethDeposit if false, will not try to deposit weth from attach eth\r\n */\r\n function _pullFrom(\r\n address from,\r\n address token,\r\n uint256 amount,\r\n bool skipWethDeposit\r\n ) internal {\r\n if (!skipWethDeposit) {\r\n if (token == WETH_ADDRESS) {\r\n if (msg.value > 0) {\r\n if (msg.value > amount) {\r\n IWETH(WETH_ADDRESS).deposit{value: amount}();\r\n\r\n (bool success, ) = payable(msg.sender).call{\r\n value: msg.value - amount\r\n }(\"\");\r\n\r\n require(success, \"ETH refund failed\");\r\n\r\n amount = 0;\r\n } else {\r\n unchecked {\r\n amount -= msg.value;\r\n }\r\n\r\n IWETH(WETH_ADDRESS).deposit{value: msg.value}();\r\n }\r\n }\r\n } else {\r\n require(msg.value == 0, \"not WETH deposit\");\r\n }\r\n }\r\n\r\n if (amount > 0) {\r\n require(\r\n IERC20(token).transferFrom(from, address(this), amount),\r\n \"ERC20 transfer failed\"\r\n );\r\n }\r\n }\r\n\r\n function _mint(\r\n address account,\r\n uint256 tokenId,\r\n uint256 amount\r\n ) internal {\r\n _mint(account, tokenId, amount, \"\");\r\n }\r\n\r\n function _addUserTVL(\r\n PoolStorage.Layout storage l,\r\n address user,\r\n bool isCallPool,\r\n uint256 amount\r\n ) internal {\r\n uint256 userTVL = l.userTVL[user][isCallPool];\r\n uint256 totalTVL = l.totalTVL[isCallPool];\r\n\r\n IPremiaMining(PREMIA_MINING_ADDRESS).allocatePending(\r\n user,\r\n address(this),\r\n isCallPool,\r\n userTVL,\r\n userTVL + amount,\r\n totalTVL\r\n );\r\n\r\n l.userTVL[user][isCallPool] = userTVL + amount;\r\n l.totalTVL[isCallPool] = totalTVL + amount;\r\n }\r\n\r\n function _subUserTVL(\r\n PoolStorage.Layout storage l,\r\n address user,\r\n bool isCallPool,\r\n uint256 amount\r\n ) internal {\r\n uint256 userTVL = l.userTVL[user][isCallPool];\r\n uint256 totalTVL = l.totalTVL[isCallPool];\r\n\r\n IPremiaMining(PREMIA_MINING_ADDRESS).allocatePending(\r\n user,\r\n address(this),\r\n isCallPool,\r\n userTVL,\r\n userTVL - amount,\r\n totalTVL\r\n );\r\n l.userTVL[user][isCallPool] = userTVL - amount;\r\n l.totalTVL[isCallPool] = totalTVL - amount;\r\n }\r\n\r\n /**\r\n * @notice ERC1155 hook: track eligible underwriters\r\n * @param operator transaction sender\r\n * @param from token sender\r\n * @param to token receiver\r\n * @param ids token ids transferred\r\n * @param amounts token quantities transferred\r\n * @param data data payload\r\n */\r\n function _beforeTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual override {\r\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n PoolStorage.Layout storage l = PoolStorage.layout();\r\n\r\n for (uint256 i; i < ids.length; i++) {\r\n uint256 id = ids[i];\r\n uint256 amount = amounts[i];\r\n\r\n if (amount == 0) continue;\r\n\r\n if (from == address(0)) {\r\n l.tokenIds.add(id);\r\n }\r\n\r\n if (\r\n to == address(0) &&\r\n ERC1155EnumerableStorage.layout().totalSupply[id] == 0\r\n ) {\r\n l.tokenIds.remove(id);\r\n }\r\n\r\n // prevent transfer of free and reserved liquidity during waiting period\r\n\r\n if (\r\n id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == BASE_FREE_LIQ_TOKEN_ID ||\r\n id == UNDERLYING_RESERVED_LIQ_TOKEN_ID ||\r\n id == BASE_RESERVED_LIQ_TOKEN_ID\r\n ) {\r\n if (from != address(0) && to != address(0)) {\r\n bool isCallPool = id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == UNDERLYING_RESERVED_LIQ_TOKEN_ID;\r\n\r\n require(\r\n l.depositedAt[from][isCallPool] + (1 days) <\r\n block.timestamp,\r\n \"liq lock 1d\"\r\n );\r\n }\r\n }\r\n\r\n if (\r\n id == UNDERLYING_FREE_LIQ_TOKEN_ID ||\r\n id == BASE_FREE_LIQ_TOKEN_ID\r\n ) {\r\n bool isCallPool = id == UNDERLYING_FREE_LIQ_TOKEN_ID;\r\n uint256 minimum = _getMinimumAmount(l, isCallPool);\r\n\r\n if (from != address(0)) {\r\n uint256 balance = _balanceOf(from, id);\r\n\r\n if (balance > minimum && balance <= amount + minimum) {\r\n require(\r\n balance -\r\n l.pendingDeposits[from][\r\n l.nextDeposits[isCallPool].eta\r\n ][isCallPool] >=\r\n amount,\r\n \"Insuf balance\"\r\n );\r\n l.removeUnderwriter(from, isCallPool);\r\n }\r\n\r\n if (to != address(0)) {\r\n _subUserTVL(l, from, isCallPool, amounts[i]);\r\n _addUserTVL(l, to, isCallPool, amounts[i]);\r\n }\r\n }\r\n\r\n if (to != address(0)) {\r\n uint256 balance = _balanceOf(to, id);\r\n\r\n if (balance <= minimum && balance + amount > minimum) {\r\n l.addUnderwriter(to, isCallPool);\r\n }\r\n }\r\n }\r\n\r\n // Update userTVL on SHORT options transfers\r\n (\r\n PoolStorage.TokenType tokenType,\r\n ,\r\n int128 strike64x64\r\n ) = PoolStorage.parseTokenId(id);\r\n\r\n if (\r\n (from != address(0) && to != address(0)) &&\r\n (tokenType == PoolStorage.TokenType.SHORT_CALL ||\r\n tokenType == PoolStorage.TokenType.SHORT_PUT)\r\n ) {\r\n bool isCall = tokenType == PoolStorage.TokenType.SHORT_CALL;\r\n uint256 collateral = isCall\r\n ? amount\r\n : l.fromUnderlyingToBaseDecimals(strike64x64.mulu(amount));\r\n\r\n _subUserTVL(l, from, isCall, collateral);\r\n _addUserTVL(l, to, isCall, collateral);\r\n }\r\n }\r\n }\r\n}\r\n"},"@solidstate/contracts/token/ERC1155/base/ERC1155BaseStorage.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary ERC1155BaseStorage {\n struct Layout {\n mapping(uint256 => mapping(address => uint256)) balances;\n mapping(address => mapping(address => bool)) operatorApprovals;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.ERC1155Base');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n"},"@solidstate/contracts/utils/EnumerableSet.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Set implementation with enumeration functions\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts (MIT license)\n */\nlibrary EnumerableSet {\n struct Set {\n bytes32[] _values;\n // 1-indexed to allow 0 to signify nonexistence\n mapping(bytes32 => uint256) _indexes;\n }\n\n struct Bytes32Set {\n Set _inner;\n }\n\n struct AddressSet {\n Set _inner;\n }\n\n struct UintSet {\n Set _inner;\n }\n\n function at(Bytes32Set storage set, uint256 index)\n internal\n view\n returns (bytes32)\n {\n return _at(set._inner, index);\n }\n\n function at(AddressSet storage set, uint256 index)\n internal\n view\n returns (address)\n {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n function at(UintSet storage set, uint256 index)\n internal\n view\n returns (uint256)\n {\n return uint256(_at(set._inner, index));\n }\n\n function contains(Bytes32Set storage set, bytes32 value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, value);\n }\n\n function contains(AddressSet storage set, address value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function contains(UintSet storage set, uint256 value)\n internal\n view\n returns (bool)\n {\n return _contains(set._inner, bytes32(value));\n }\n\n function indexOf(Bytes32Set storage set, bytes32 value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, value);\n }\n\n function indexOf(AddressSet storage set, address value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function indexOf(UintSet storage set, uint256 value)\n internal\n view\n returns (uint256)\n {\n return _indexOf(set._inner, bytes32(value));\n }\n\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n function add(Bytes32Set storage set, bytes32 value)\n internal\n returns (bool)\n {\n return _add(set._inner, value);\n }\n\n function add(AddressSet storage set, address value)\n internal\n returns (bool)\n {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n function remove(Bytes32Set storage set, bytes32 value)\n internal\n returns (bool)\n {\n return _remove(set._inner, value);\n }\n\n function remove(AddressSet storage set, address value)\n internal\n returns (bool)\n {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n function remove(UintSet storage set, uint256 value)\n internal\n returns (bool)\n {\n return _remove(set._inner, bytes32(value));\n }\n\n function _at(Set storage set, uint256 index)\n private\n view\n returns (bytes32)\n {\n require(\n set._values.length > index,\n 'EnumerableSet: index out of bounds'\n );\n return set._values[index];\n }\n\n function _contains(Set storage set, bytes32 value)\n private\n view\n returns (bool)\n {\n return set._indexes[value] != 0;\n }\n\n function _indexOf(Set storage set, bytes32 value)\n private\n view\n returns (uint256)\n {\n unchecked {\n return set._indexes[value] - 1;\n }\n }\n\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n uint256 index = valueIndex - 1;\n bytes32 last = set._values[set._values.length - 1];\n\n // move last value to now-vacant index\n\n set._values[index] = last;\n set._indexes[last] = index + 1;\n\n // clear last index\n\n set._values.pop();\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n}\n"},"contracts/mining/PremiaMiningStorage.sol":{"content":"// SPDX-License-Identifier: BUSL-1.1\r\n// For further clarification please see https://license.premia.legal\r\n\r\npragma solidity ^0.8.0;\r\n\r\nlibrary PremiaMiningStorage {\r\n bytes32 internal constant STORAGE_SLOT =\r\n keccak256(\"premia.contracts.storage.PremiaMining\");\r\n\r\n // Info of each pool.\r\n struct PoolInfo {\r\n uint256 allocPoint; // How many allocation points assigned to this pool. PREMIA to distribute per block.\r\n uint256 lastRewardTimestamp; // Last timestamp that PREMIA distribution occurs\r\n uint256 accPremiaPerShare; // Accumulated PREMIA per share, times 1e12. See below.\r\n }\r\n\r\n // Info of each user.\r\n struct UserInfo {\r\n uint256 reward; // Total allocated unclaimed reward\r\n uint256 rewardDebt; // Reward debt. See explanation below.\r\n //\r\n // We do some fancy math here. Basically, any point in time, the amount of PREMIA\r\n // entitled to a user but is pending to be distributed is:\r\n //\r\n // pending reward = (user.amount * pool.accPremiaPerShare) - user.rewardDebt\r\n //\r\n // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:\r\n // 1. The pool's `accPremiaPerShare` (and `lastRewardBlock`) gets updated.\r\n // 2. User receives the pending reward sent to his/her address.\r\n // 3. User's `amount` gets updated.\r\n // 4. User's `rewardDebt` gets updated.\r\n }\r\n\r\n struct Layout {\r\n // Total PREMIA left to distribute\r\n uint256 premiaAvailable;\r\n // Amount of premia distributed per year\r\n uint256 premiaPerYear;\r\n // pool -> isCallPool -> PoolInfo\r\n mapping(address => mapping(bool => PoolInfo)) poolInfo;\r\n // pool -> isCallPool -> user -> UserInfo\r\n mapping(address => mapping(bool => mapping(address => UserInfo))) userInfo;\r\n // Total allocation points. Must be the sum of all allocation points in all pools.\r\n uint256 totalAllocPoint;\r\n }\r\n\r\n function layout() internal pure returns (Layout storage l) {\r\n bytes32 slot = STORAGE_SLOT;\r\n assembly {\r\n l.slot := slot\r\n }\r\n }\r\n}\r\n"},"@solidstate/contracts/utils/IWETH.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from '../token/ERC20/IERC20.sol';\nimport { IERC20Metadata } from '../token/ERC20/metadata/IERC20Metadata.sol';\n\n/**\n * @title WETH (Wrapped ETH) interface\n */\ninterface IWETH is IERC20, IERC20Metadata {\n /**\n * @notice convert ETH to WETH\n */\n function deposit() external payable;\n\n /**\n * @notice convert WETH to ETH\n * @dev if caller is a contract, it should have a fallback or receive function\n * @param amount quantity of WETH to convert, denominated in wei\n */\n function withdraw(uint256 amount) external;\n}\n"},"@solidstate/contracts/token/ERC1155/IERC1155Internal.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC165 } from '../../introspection/IERC165.sol';\n\n/**\n * @notice Partial ERC1155 interface needed by internal functions\n */\ninterface IERC1155Internal {\n event TransferSingle(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256 id,\n uint256 value\n );\n\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n event ApprovalForAll(\n address indexed account,\n address indexed operator,\n bool approved\n );\n}\n"},"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n\n function decimals()\n external\n view\n returns (\n uint8\n );\n\n function description()\n external\n view\n returns (\n string memory\n );\n\n function version()\n external\n view\n returns (\n uint256\n );\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(\n uint80 _roundId\n )\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n}\n"},"@solidstate/contracts/access/OwnableStorage.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nlibrary OwnableStorage {\n struct Layout {\n address owner;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256('solidstate.contracts.storage.Ownable');\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n\n function setOwner(Layout storage l, address owner) internal {\n l.owner = owner;\n }\n}\n"}},"settings":{"optimizer":{"enabled":true,"runs":200},"outputSelection":{"*":{"*":["evm.bytecode","evm.deployedBytecode","devdoc","userdoc","metadata","abi"]}},"libraries":{"contracts/libraries/OptionMath.sol":{"OptionMath":"0x0f6e8ef18fb5bb61d545fee60f779d8aed60408f"}}}},"ABI":"[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ivolOracle\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"weth\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"premiaMining\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeReceiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeDiscountAddress\",\"type\":\"address\"},{\"internalType\":\"int128\",\"name\":\"fee64x64\",\"type\":\"int128\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Annihilate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"freedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalContractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"AssignExercise\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"exerciseValue\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"Exercise\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"FeeWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"baseCost\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feeCost\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"spot64x64\",\"type\":\"int128\"}],\"name\":\"Purchase\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"longReceiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"shortTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalContractSize\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"intervalPremium\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isManualUnderwrite\",\"type\":\"bool\"}],\"name\":\"Underwrite\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"isCall\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"cLevel64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"oldLiquidity64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"newLiquidity64x64\",\"type\":\"int128\"}],\"name\":\"UpdateCLevel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int128\",\"name\":\"steepness64x64\",\"type\":\"int128\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"}],\"name\":\"UpdateSteepness\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isCallPool\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositedAt\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Withdrawal\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"holder\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"}],\"name\":\"exerciseFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"longTokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"contractSize\",\"type\":\"uint256\"}],\"name\":\"processExpired\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]","ContractName":"PoolExercise","CompilerVersion":"v0.8.9+commit.e5eed63a","OptimizationUsed":1,"Runs":200,"ConstructorArguments":"0x0000000000000000000000003a87bb29b984d672664aa1dd2d19d2e8b24f0f2a000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009abb27581c2e46a114f8c367355851e0580e9703000000000000000000000000c4b2c51f969e0713e799de73b7f130fb7bb604cf000000000000000000000000f1bb87563a122211d40d393ebf1c633c330377f900000000000000000000000000000000000000000000000007ae147ae147ae14","EVMVersion":"Default","Library":"","LicenseType":"","Proxy":0,"SwarmSource":""}] \ No newline at end of file From b7437499c5802f10d5b98b60f2c6d77a11b3d2f3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:09:00 +0200 Subject: [PATCH 0871/1963] feat: re-enable jemalloc for anvil (#7708) --- crates/anvil/Cargo.toml | 4 +--- crates/anvil/src/anvil.rs | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index d9d443643f679..7930d437a0ea1 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -105,6 +105,4 @@ default = ["cli"] cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"] cli = ["tokio/full", "cmd", "fdlimit"] asm-keccak = ["alloy-primitives/asm-keccak"] -# TODO: parity dependencies are not compatible with a different global allocator. -# jemalloc = ["dep:tikv-jemallocator"] -jemalloc = [] +jemalloc = ["dep:tikv-jemallocator"] diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 54a5e41cf55ea..1aa204587b200 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -4,8 +4,6 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; use foundry_cli::utils; -// TODO: parity dependencies are not compatible with a different global allocator. -#[cfg(any())] #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; From 358107683da49f4f57b8ff7123c5e119af7d9544 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:12:23 +0200 Subject: [PATCH 0872/1963] chore(deps): bump ariadne to 0.4.0 (#7710) --- Cargo.lock | 4 ++-- crates/fmt/Cargo.toml | 2 +- crates/fmt/src/helpers.rs | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7dcd51e06731..17f662ae2a546 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -800,9 +800,9 @@ dependencies = [ [[package]] name = "ariadne" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72fe02fc62033df9ba41cba57ee19acf5e742511a140c7dbc3a873e19a19a1bd" +checksum = "dd002a6223f12c7a95cdd4b1cb3a0149d22d37f7a9ecdb2cb691a071fe236c29" dependencies = [ "unicode-width", "yansi 0.5.1", diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index 0f49a10a1b82e..c8937a281a5f3 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -14,7 +14,7 @@ foundry-config.workspace = true alloy-primitives.workspace = true -ariadne = "0.3" +ariadne = "0.4" itertools.workspace = true solang-parser.workspace = true thiserror = "1" diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index 8d472e3bb33be..9a31edeb0901b 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -81,6 +81,10 @@ pub fn print_diagnostics_report( path: Option<&Path>, diagnostics: Vec, ) -> std::io::Result<()> { + if diagnostics.is_empty() { + return Ok(()); + } + let filename = path.map(|p| p.file_name().unwrap().to_string_lossy().to_string()).unwrap_or_default(); for diag in diagnostics { From 18e0d030d259d8d9129e955516c6eaf919f937f8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:32:04 +0200 Subject: [PATCH 0873/1963] chore(deps): update to hyper 1.0 (#6470) --- Cargo.lock | 155 ++++++++++++++--------------- Cargo.toml | 12 +-- crates/anvil/server/Cargo.toml | 1 - crates/anvil/server/src/ipc.rs | 4 +- crates/anvil/server/src/lib.rs | 93 +++++++---------- crates/anvil/src/cmd.rs | 2 +- crates/anvil/src/lib.rs | 67 +++++++++---- crates/anvil/src/server/mod.rs | 57 +++++++---- crates/chisel/Cargo.toml | 2 +- crates/common/Cargo.toml | 2 +- crates/config/Cargo.toml | 2 +- crates/forge/Cargo.toml | 4 +- crates/forge/bin/cmd/doc/server.rs | 13 ++- crates/verify/Cargo.toml | 2 +- 14 files changed, 219 insertions(+), 197 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17f662ae2a546..bd1fe244a7885 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -558,7 +558,7 @@ dependencies = [ "http 0.2.12", "serde_json", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.20.1", "tracing", "ws_stream_wasm", ] @@ -708,7 +708,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 0.14.28", + "hyper 1.2.0", "itertools 0.12.1", "k256", "parking_lot", @@ -771,7 +771,6 @@ dependencies = [ "bytes", "clap", "futures", - "hyper 0.14.28", "parity-tokio-ipc", "parking_lot", "pin-project", @@ -1409,19 +1408,20 @@ dependencies = [ [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", "base64 0.21.7", - "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -1434,29 +1434,34 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.21.0", "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -1877,7 +1882,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest 0.11.27", + "reqwest 0.12.3", "revm", "rustyline", "semver 1.0.22", @@ -3158,7 +3163,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.20.1", "tracing", "tracing-futures", "url", @@ -3494,7 +3499,7 @@ dependencies = [ "foundry-wallets", "futures", "globset", - "hyper 0.14.28", + "hyper 1.2.0", "indicatif", "itertools 0.12.1", "mockall", @@ -3507,7 +3512,7 @@ dependencies = [ "proptest", "rayon", "regex", - "reqwest 0.11.27", + "reqwest 0.12.3", "revm-inspectors", "rustc-hash", "semver 1.0.22", @@ -3516,7 +3521,7 @@ dependencies = [ "similar", "solang-parser", "strum", - "svm-rs 0.4.1", + "svm-rs 0.5.1", "tempfile", "thiserror", "tikv-jemallocator", @@ -3637,7 +3642,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest 0.11.27", + "reqwest 0.12.3", "revm-primitives", "semver 1.0.22", "serde", @@ -4128,16 +4133,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fs4" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f9df8a11882c4e3335eb2d18a0137c505d9ca927470b0cac9c6f0ae07d28f7" -dependencies = [ - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "fs4" version = "0.8.2" @@ -4812,9 +4807,9 @@ dependencies = [ [[package]] name = "http-range-header" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe" [[package]] name = "httparse" @@ -4870,6 +4865,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -4910,19 +4906,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.28", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -6927,12 +6910,10 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.28", "hyper-rustls 0.24.2", - "hyper-tls 0.5.0", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -6942,10 +6923,9 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", - "tokio-native-tls", "tokio-rustls 0.24.1", "tower-service", "url", @@ -6972,7 +6952,7 @@ dependencies = [ "http-body-util", "hyper 1.2.0", "hyper-rustls 0.26.0", - "hyper-tls 0.6.0", + "hyper-tls", "hyper-util", "ipnet", "js-sys", @@ -6989,7 +6969,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "tokio", "tokio-native-tls", "tokio-rustls 0.25.0", @@ -8054,26 +8034,6 @@ dependencies = [ "zip", ] -[[package]] -name = "svm-rs" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd5e919f01c9280dce59ab66296449d0e9144b8472b8892fbacf9612998b653" -dependencies = [ - "const-hex", - "dirs 5.0.1", - "fs4 0.7.0", - "once_cell", - "reqwest 0.11.27", - "semver 1.0.22", - "serde", - "serde_json", - "sha2", - "thiserror", - "url", - "zip", -] - [[package]] name = "svm-rs" version = "0.5.1" @@ -8082,7 +8042,7 @@ checksum = "c912d2f0dfbf9d8ba683b3181c4bd6d042bac9279d5c062346c253c1eadf46e2" dependencies = [ "const-hex", "dirs 5.0.1", - "fs4 0.8.2", + "fs4", "once_cell", "reqwest 0.12.3", "semver 1.0.22", @@ -8147,6 +8107,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -8453,10 +8419,22 @@ dependencies = [ "rustls 0.21.10", "tokio", "tokio-rustls 0.24.1", - "tungstenite", + "tungstenite 0.20.1", "webpki-roots 0.25.4", ] +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.21.0", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -8573,16 +8551,16 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.5.0", "bytes", - "futures-core", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "http-range-header", "httpdate", "mime", @@ -8730,6 +8708,25 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand 0.8.5", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typed-arena" version = "2.0.2" diff --git a/Cargo.toml b/Cargo.toml index 622b2cf3f6349..2859b9349afee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -192,10 +192,7 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" @@ -218,7 +215,8 @@ indexmap = "2.2" tikv-jemallocator = "0.5.4" num-format = "0.4.4" -axum = "0.6" -hyper = "0.14" +axum = "0.7" +hyper = "1.0" +reqwest = { version = "0.12", default-features = false } tower = "0.4" -tower-http = "0.4" +tower-http = "0.5" diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index fb880a422de95..a9d87051050da 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -15,7 +15,6 @@ anvil-rpc = { path = "../rpc" } # axum related axum = { workspace = true, features = ["ws"] } -hyper.workspace = true tower-http = { workspace = true, features = ["trace", "cors"] } # tracing diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index 97ec0709887dc..152b41873f95a 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -24,8 +24,8 @@ pub struct IpcEndpoint { impl IpcEndpoint { /// Creates a new endpoint with the given handler - pub fn new(handler: Handler, endpoint: impl Into) -> Self { - Self { handler, endpoint: Endpoint::new(endpoint.into()) } + pub fn new(handler: Handler, endpoint: String) -> Self { + Self { handler, endpoint: Endpoint::new(endpoint) } } /// Returns a stream of incoming connection handlers diff --git a/crates/anvil/server/src/lib.rs b/crates/anvil/server/src/lib.rs index 5ff287c96b3cf..5bd81b043e8ea 100644 --- a/crates/anvil/server/src/lib.rs +++ b/crates/anvil/server/src/lib.rs @@ -1,4 +1,4 @@ -//! Bootstrap [axum] RPC servers +//! Bootstrap [axum] RPC servers. #![warn(missing_docs, unused_crate_dependencies)] @@ -12,91 +12,66 @@ use anvil_rpc::{ }; use axum::{ http::{header, HeaderValue, Method}, - routing::{post, IntoMakeService}, - Router, Server, + routing::{post, MethodRouter}, + Router, }; -use hyper::server::conn::AddrIncoming; use serde::de::DeserializeOwned; -use std::{fmt, net::SocketAddr}; +use std::fmt; use tower_http::{cors::CorsLayer, trace::TraceLayer}; mod config; +pub use config::ServerConfig; mod error; -/// handlers for axum server mod handler; -#[cfg(feature = "ipc")] -pub mod ipc; + mod pubsub; -mod ws; +pub use pubsub::{PubSubContext, PubSubRpcHandler}; -pub use crate::pubsub::{PubSubContext, PubSubRpcHandler}; -pub use config::ServerConfig; +mod ws; -/// Type alias for the configured axum server -pub type AnvilServer = Server>; +#[cfg(feature = "ipc")] +pub mod ipc; -/// Configures an [axum::Server] that handles RPC-Calls, both HTTP requests and requests via -/// websocket -pub fn serve_http_ws( - addr: SocketAddr, - config: ServerConfig, - http: Http, - ws: Ws, -) -> AnvilServer +/// Configures an [`axum::Router`] that handles JSON-RPC calls via both HTTP and WS. +pub fn http_ws_router(config: ServerConfig, http: Http, ws: Ws) -> Router where Http: RpcHandler, Ws: PubSubRpcHandler, { - let ServerConfig { allow_origin, no_cors } = config; - - let svc = Router::new() - .route("/", post(handler::handle).get(ws::handle_ws)) - .with_state((http, ws)) - .layer(TraceLayer::new_for_http()); - - let svc = if no_cors { - svc - } else { - svc.layer( - // see https://docs.rs/tower-http/latest/tower_http/cors/index.html - // for more details - CorsLayer::new() - .allow_origin(allow_origin.0) - .allow_headers(vec![header::CONTENT_TYPE]) - .allow_methods(vec![Method::GET, Method::POST]), - ) - } - .into_make_service(); - Server::bind(&addr).serve(svc) + router_inner(config, post(handler::handle).get(ws::handle_ws), (http, ws)) } -/// Configures an [axum::Server] that handles RPC-Calls listing for POST on `/` -pub fn serve_http(addr: SocketAddr, config: ServerConfig, http: Http) -> AnvilServer +/// Configures an [`axum::Router`] that handles JSON-RPC calls via HTTP. +pub fn http_router(config: ServerConfig, http: Http) -> Router where Http: RpcHandler, { + router_inner(config, post(handler::handle), (http, ())) +} + +fn router_inner( + config: ServerConfig, + root_method_router: MethodRouter, + state: S, +) -> Router { let ServerConfig { allow_origin, no_cors } = config; - let svc = Router::new() - .route("/", post(handler::handle)) - .with_state((http, ())) + let mut router = Router::new() + .route("/", root_method_router) + .with_state(state) .layer(TraceLayer::new_for_http()); - let svc = if no_cors { - svc - } else { - svc.layer( - // see https://docs.rs/tower-http/latest/tower_http/cors/index.html - // for more details + if !no_cors { + // See [`tower_http::cors`](https://docs.rs/tower-http/latest/tower_http/cors/index.html) + // for more details. + router = router.layer( CorsLayer::new() .allow_origin(allow_origin.0) - .allow_headers(vec![header::CONTENT_TYPE]) - .allow_methods(vec![Method::GET, Method::POST]), - ) + .allow_headers([header::CONTENT_TYPE]) + .allow_methods([Method::GET, Method::POST]), + ); } - .into_make_service(); - - Server::bind(&addr).serve(svc) + router } /// Helper trait that is used to execute ethereum rpc calls diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 8e29152410eee..c64d9471fd81b 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -275,7 +275,7 @@ impl NodeArgs { let dump_interval = self.state_interval.map(Duration::from_secs).unwrap_or(DEFAULT_DUMP_INTERVAL); - let (api, mut handle) = crate::spawn(self.into_node_config()).await; + let (api, mut handle) = crate::try_spawn(self.into_node_config()).await?; // sets the signal handler to gracefully shutdown. let mut fork = api.get_fork(); diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 31c635990b11a..b08fd7e9c6654 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -70,26 +70,56 @@ mod tasks; #[cfg(feature = "cmd")] pub mod cmd; -/// Creates the node and runs the server +/// Creates the node and runs the server. /// /// Returns the [EthApi] that can be used to interact with the node and the [JoinHandle] of the /// task. /// -/// # Example +/// # Panics +/// +/// Panics if any error occurs. For a non-panicking version, use [`try_spawn`]. +/// /// -/// ```rust +/// # Examples +/// +/// ```no_run /// # use anvil::NodeConfig; -/// # async fn spawn() { +/// # async fn spawn() -> eyre::Result<()> { /// let config = NodeConfig::default(); /// let (api, handle) = anvil::spawn(config).await; /// /// // use api /// /// // wait forever -/// handle.await.unwrap(); +/// handle.await.unwrap().unwrap(); +/// # Ok(()) +/// # } +/// ``` +pub async fn spawn(config: NodeConfig) -> (EthApi, NodeHandle) { + try_spawn(config).await.expect("failed to spawn node") +} + +/// Creates the node and runs the server +/// +/// Returns the [EthApi] that can be used to interact with the node and the [JoinHandle] of the +/// task. +/// +/// # Examples +/// +/// ```no_run +/// # use anvil::NodeConfig; +/// # async fn spawn() -> eyre::Result<()> { +/// let config = NodeConfig::default(); +/// let (api, handle) = anvil::try_spawn(config).await?; +/// +/// // use api +/// +/// // wait forever +/// handle.await??; +/// # Ok(()) /// # } /// ``` -pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { +pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle)> { let logger = if config.enable_tracing { init_tracing() } else { Default::default() }; logger.set_enabled(!config.silent); @@ -174,18 +204,19 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { let node_service = tokio::task::spawn(NodeService::new(pool, backend, miner, fee_history_service, filters)); - let mut servers = Vec::new(); - let mut addresses = Vec::new(); + let mut servers = Vec::with_capacity(config.host.len()); + let mut addresses = Vec::with_capacity(config.host.len()); - for addr in config.host.iter() { - let sock_addr = SocketAddr::new(addr.to_owned(), port); - let srv = server::serve(sock_addr, api.clone(), server_config.clone()); + for addr in &config.host { + let sock_addr = SocketAddr::new(*addr, port); - addresses.push(srv.local_addr()); + // Create a TCP listener. + let tcp_listener = tokio::net::TcpListener::bind(sock_addr).await?; + addresses.push(tcp_listener.local_addr()?); - // spawn the server on a new task - let srv = tokio::task::spawn(srv.map_err(NodeError::from)); - servers.push(srv); + // Spawn the server future on a new task. + let srv = server::serve_on(tcp_listener, api.clone(), server_config.clone()); + servers.push(tokio::task::spawn(srv.map_err(Into::into))); } let tokio_handle = Handle::current(); @@ -206,10 +237,10 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { handle.print(fork.as_ref()); - (api, handle) + Ok((api, handle)) } -type IpcTask = JoinHandle>; +type IpcTask = JoinHandle<()>; /// A handle to the spawned node and server tasks /// @@ -359,7 +390,7 @@ impl Future for NodeHandle { // poll the ipc task if let Some(mut ipc) = pin.ipc_task.take() { if let Poll::Ready(res) = ipc.poll_unpin(cx) { - return Poll::Ready(res.map(|res| res.map_err(NodeError::from))); + return Poll::Ready(res.map(|()| Ok(()))); } else { pin.ipc_task = Some(ipc); } diff --git a/crates/anvil/src/server/mod.rs b/crates/anvil/src/server/mod.rs index 10d86f6713d5f..c488bcdc15ca3 100644 --- a/crates/anvil/src/server/mod.rs +++ b/crates/anvil/src/server/mod.rs @@ -1,48 +1,67 @@ -//! Contains the code to launch an ethereum RPC-Server -use crate::EthApi; -use anvil_server::{ipc::IpcEndpoint, AnvilServer, ServerConfig}; +//! Contains the code to launch an Ethereum RPC server. + +use crate::{EthApi, IpcTask}; +use anvil_server::{ipc::IpcEndpoint, ServerConfig}; +use axum::Router; use futures::StreamExt; use handler::{HttpEthRpcHandler, PubSubEthRpcHandler}; -use std::net::SocketAddr; -use tokio::{io, task::JoinHandle}; +use std::{future::Future, io, net::SocketAddr, pin::pin}; +use tokio::net::TcpListener; +pub mod error; mod handler; -pub mod error; +/// Configures a server that handles [`EthApi`] related JSON-RPC calls via HTTP and WS. +/// +/// The returned future creates a new server, binding it to the given address, which returns another +/// future that runs it. +pub async fn serve( + addr: SocketAddr, + api: EthApi, + config: ServerConfig, +) -> io::Result>> { + let tcp_listener = TcpListener::bind(addr).await?; + Ok(serve_on(tcp_listener, api, config)) +} -/// Configures an [axum::Server] that handles [EthApi] related JSON-RPC calls via HTTP and WS -pub fn serve(addr: SocketAddr, api: EthApi, config: ServerConfig) -> AnvilServer { +/// Configures a server that handles [`EthApi`] related JSON-RPC calls via HTTP and WS. +pub async fn serve_on( + tcp_listener: TcpListener, + api: EthApi, + config: ServerConfig, +) -> io::Result<()> { + axum::serve(tcp_listener, router(api, config).into_make_service()).await +} + +/// Configures an [`axum::Router`] that handles [`EthApi`] related JSON-RPC calls via HTTP and WS. +pub fn router(api: EthApi, config: ServerConfig) -> Router { let http = HttpEthRpcHandler::new(api.clone()); let ws = PubSubEthRpcHandler::new(api); - anvil_server::serve_http_ws(addr, config, http, ws) + anvil_server::http_ws_router(config, http, ws) } /// Launches an ipc server at the given path in a new task /// /// # Panics /// -/// if setting up the ipc connection was unsuccessful -pub fn spawn_ipc(api: EthApi, path: impl Into) -> JoinHandle> { +/// Panics if setting up the IPC connection was unsuccessful. +#[track_caller] +pub fn spawn_ipc(api: EthApi, path: String) -> IpcTask { try_spawn_ipc(api, path).expect("failed to establish ipc connection") } -/// Launches an ipc server at the given path in a new task -pub fn try_spawn_ipc( - api: EthApi, - path: impl Into, -) -> io::Result>> { - let path = path.into(); +/// Launches an ipc server at the given path in a new task. +pub fn try_spawn_ipc(api: EthApi, path: String) -> io::Result { let handler = PubSubEthRpcHandler::new(api); let ipc = IpcEndpoint::new(handler, path); let incoming = ipc.incoming()?; let task = tokio::task::spawn(async move { - tokio::pin!(incoming); + let mut incoming = pin!(incoming); while let Some(stream) = incoming.next().await { trace!(target: "ipc", "new ipc connection"); tokio::task::spawn(stream); } - Ok(()) }); Ok(task) diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 9829abb7c475b..9d07ae80019a1 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -37,7 +37,7 @@ dirs = "5" eyre.workspace = true once_cell = "1.18.0" regex = "1" -reqwest = { version = "0.11", default-features = false } +reqwest.workspace = true revm.workspace = true rustyline = "12" semver = "1" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index cafa1938a5ece..07f8837cabb8a 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -50,7 +50,7 @@ glob = "0.3" globset = "0.4" hex.workspace = true once_cell = "1" -reqwest = { version = "0.12", default-features = false } +reqwest.workspace = true semver = "1" serde_json.workspace = true serde.workspace = true diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index da1371c75bd47..1b639ee55ae1e 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -29,7 +29,7 @@ Inflector = "0.11" number_prefix = "0.4" once_cell = "1" regex = "1" -reqwest = { version = "0.12", default-features = false } +reqwest.workspace = true semver = { version = "1", features = ["serde"] } serde_json.workspace = true serde_regex = "1" diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 30b5975768c76..9ccec21508fc1 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -71,7 +71,7 @@ itertools.workspace = true once_cell = "1" parking_lot = "0.12" regex = { version = "1", default-features = false } -reqwest = { version = "0.11", default-features = false, features = ["json"] } +reqwest = { workspace = true, features = ["json"] } semver = "1" serde_json.workspace = true similar = { version = "2", features = ["inline"] } @@ -104,7 +104,7 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.4", default-features = false, features = ["rustls"] } +svm = { package = "svm-rs", version = "0.5", default-features = false, features = ["rustls"] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } diff --git a/crates/forge/bin/cmd/doc/server.rs b/crates/forge/bin/cmd/doc/server.rs index 7c092713615d4..f5991ba438377 100644 --- a/crates/forge/bin/cmd/doc/server.rs +++ b/crates/forge/bin/cmd/doc/server.rs @@ -1,6 +1,7 @@ use axum::{routing::get_service, Router}; use forge_doc::mdbook::{utils::fs::get_404_output_file, MDBook}; use std::{ + io, net::{SocketAddr, ToSocketAddrs}, path::PathBuf, }; @@ -82,18 +83,20 @@ impl Server { open(serving_url); } - let _ = thread_handle.join(); - - Ok(()) + match thread_handle.join() { + Ok(r) => r.map_err(Into::into), + Err(e) => std::panic::resume_unwind(e), + } } } #[tokio::main] -async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) { +async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) -> io::Result<()> { let file_404 = build_dir.join(file_404); let svc = ServeDir::new(build_dir).not_found_service(ServeFile::new(file_404)); let app = Router::new().nest_service("/", get_service(svc)); - hyper::Server::bind(&address).serve(app.into_make_service()).await.unwrap(); + let tcp_listener = tokio::net::TcpListener::bind(address).await?; + axum::serve(tcp_listener, app.into_make_service()).await } fn open>(path: P) { diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 16efe68881d7f..d365388d09f7a 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -29,7 +29,7 @@ foundry-compilers = { workspace = true, features = ["full"] } foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } -reqwest = { version = "0.11", default-features = false, features = ["json"] } +reqwest = { workspace = true, features = ["json"] } async-trait = "0.1" futures = "0.3" semver = "1" From e97a35abf66e76f96a86f6018575f0a8d017f6b9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:18:11 +0200 Subject: [PATCH 0874/1963] feat: temporarily re-introduce custom trace printer (#7716) --- crates/cast/bin/cmd/run.rs | 10 +++------- crates/evm/evm/src/executors/mod.rs | 6 ++++++ crates/evm/evm/src/inspectors/stack.rs | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 33c26e2a907b1..5a5d362fdfe11 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -30,8 +30,7 @@ pub struct RunArgs { debug: bool, /// Print out opcode traces. - #[deprecated] - #[arg(long, short, hide = true)] + #[arg(long, short)] trace_printer: bool, /// Executes the transaction only with the state from the previous block. @@ -83,11 +82,6 @@ impl RunArgs { /// /// Note: This executes the transaction(s) as is: Cheatcodes are disabled pub async fn run(self) -> Result<()> { - #[allow(deprecated)] - if self.trace_printer { - eprintln!("WARNING: --trace-printer is deprecated and has no effect\n"); - } - let figment = Config::figment_with_root(find_project_root_path(None).unwrap()).merge(self.rpc); let evm_opts = figment.extract::()?; @@ -214,6 +208,8 @@ impl RunArgs { // Execute our transaction let result = { + executor.set_trace_printer(self.trace_printer); + configure_tx_env(&mut env, &tx); if let Some(to) = tx.to { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 76f67abd9aa5f..45abbfc9c823a 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -171,6 +171,12 @@ impl Executor { self } + #[inline] + pub fn set_trace_printer(&mut self, trace_printer: bool) -> &mut Self { + self.inspector.print(trace_printer); + self + } + #[inline] pub fn set_gas_limit(&mut self, gas_limit: U256) -> &mut Self { self.gas_limit = gas_limit; diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 627ca2438de45..abcfee4906a6c 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -11,6 +11,7 @@ use foundry_evm_core::{ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ + inspectors::CustomPrintTracer, interpreter::{ CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, @@ -45,6 +46,8 @@ pub struct InspectorStackBuilder { pub logs: Option, /// Whether coverage info should be collected. pub coverage: Option, + /// Whether to print all opcode traces into the console. Useful for debugging the EVM. + pub print: Option, /// The chisel state inspector. pub chisel_state: Option, /// Whether to enable call isolation. @@ -116,6 +119,13 @@ impl InspectorStackBuilder { self } + /// Set whether to enable the trace printer. + #[inline] + pub fn print(mut self, yes: bool) -> Self { + self.print = Some(yes); + self + } + /// Set whether to enable the tracer. #[inline] pub fn trace(mut self, yes: bool) -> Self { @@ -144,6 +154,7 @@ impl InspectorStackBuilder { debug, logs, coverage, + print, chisel_state, enable_isolation, } = self; @@ -162,6 +173,7 @@ impl InspectorStackBuilder { stack.collect_coverage(coverage.unwrap_or(false)); stack.collect_logs(logs.unwrap_or(true)); stack.enable_debugger(debug.unwrap_or(false)); + stack.print(print.unwrap_or(false)); stack.tracing(trace.unwrap_or(false)); stack.enable_isolation(enable_isolation); @@ -273,6 +285,7 @@ pub struct InspectorStack { pub debugger: Option, pub fuzzer: Option, pub log_collector: Option, + pub printer: Option, pub tracer: Option, pub enable_isolation: bool, @@ -357,6 +370,12 @@ impl InspectorStack { self.log_collector = yes.then(Default::default); } + /// Set whether to enable the trace printer. + #[inline] + pub fn print(&mut self, yes: bool) { + self.printer = yes.then(Default::default); + } + /// Set whether to enable the tracer. #[inline] pub fn tracing(&mut self, yes: bool) { From 8d547757cc4d7fef062f383efcf79fe90304618e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 18 Apr 2024 22:47:29 +0200 Subject: [PATCH 0875/1963] feat: support ipc path as rpc url (#7717) * feat: support ipc path as rpc url * typo --- crates/cheatcodes/src/config.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index a2b9a5f5b091f..64e02070ac480 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -155,13 +155,15 @@ impl CheatsConfig { /// /// If `url_or_alias` is a known alias in the `ResolvedRpcEndpoints` then it returns the /// corresponding URL of that alias. otherwise this assumes `url_or_alias` is itself a URL - /// if it starts with a `http` or `ws` scheme + /// if it starts with a `http` or `ws` scheme. + /// + /// If the url is a path to an existing file, it is also considered a valid RPC URL, IPC path. /// /// # Errors /// /// - Returns an error if `url_or_alias` is a known alias but references an unresolved env var. /// - Returns an error if `url_or_alias` is not an alias but does not start with a `http` or - /// `scheme` + /// `ws` `scheme` and is not a path to an existing file pub fn rpc_url(&self, url_or_alias: &str) -> Result { match self.rpc_endpoints.get(url_or_alias) { Some(Ok(url)) => Ok(url.clone()), @@ -170,7 +172,12 @@ impl CheatsConfig { err.try_resolve().map_err(Into::into) } None => { - if url_or_alias.starts_with("http") || url_or_alias.starts_with("ws") { + // check if it's a URL or a path to an existing file to an ipc socket + if url_or_alias.starts_with("http") || + url_or_alias.starts_with("ws") || + // check for existing ipc file + Path::new(url_or_alias).exists() + { Ok(url_or_alias.into()) } else { Err(fmt_err!("invalid rpc url: {url_or_alias}")) From 3f5c61528e9b936f77cae3b8ac246b59a82f729d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 19 Apr 2024 01:49:56 +0400 Subject: [PATCH 0876/1963] fix: use 2718 encoding for transactions trie root calculation (#7718) * fix: use 2718 encoding for tx root * fmt * rm doc * fix --- crates/anvil/core/src/eth/block.rs | 3 +- crates/anvil/core/src/eth/transaction/mod.rs | 31 +++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 44fe1c517383e..fd7e530e00491 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -3,6 +3,7 @@ use super::{ trie, }; use alloy_consensus::Header; +use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{Address, Bloom, Bytes, B256, B64, U256}; use alloy_rlp::{RlpDecodable, RlpEncodable}; @@ -47,7 +48,7 @@ impl Block { let ommers_hash = B256::from_slice(alloy_primitives::utils::keccak256(encoded_ommers).as_slice()); let transactions_root = - trie::ordered_trie_root(transactions.iter().map(|r| Bytes::from(alloy_rlp::encode(r)))); + trie::ordered_trie_root(transactions.iter().map(|r| r.encoded_2718())); Self { header: Header { diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index e42300d6a59c4..70f887f1e2e5c 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -6,7 +6,7 @@ use alloy_consensus::{ TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, TxReceipt, }; -use alloy_eips::eip2718::Decodable2718; +use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ @@ -924,6 +924,35 @@ impl Decodable for TypedTransaction { } } +impl Encodable2718 for TypedTransaction { + fn type_flag(&self) -> Option { + self.r#type() + } + + fn encode_2718_len(&self) -> usize { + match self { + TypedTransaction::Legacy(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + TypedTransaction::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + TypedTransaction::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + TypedTransaction::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + TypedTransaction::Deposit(tx) => 1 + tx.length(), + } + } + + fn encode_2718(&self, out: &mut dyn BufMut) { + match self { + TypedTransaction::Legacy(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + TypedTransaction::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + TypedTransaction::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + TypedTransaction::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + TypedTransaction::Deposit(tx) => { + out.put_u8(0x7E); + tx.encode(out); + } + } + } +} + impl Decodable2718 for TypedTransaction { fn typed_decode(ty: u8, buf: &mut &[u8]) -> alloy_rlp::Result { if ty == 0x7E { From 79dd88c29794b9c7eb47bca792dc7ea8ab4f114a Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 19 Apr 2024 02:11:34 +0400 Subject: [PATCH 0877/1963] fix: exclude empty artifacts from `ContractsByArtifact` (#7713) * fix: exclude empty artifacts from ContractsByArtifact * additional check * fmt * doc * use Option for bytecodes --- crates/cheatcodes/src/fs.rs | 11 ++++++---- crates/common/src/contracts.rs | 25 ++++++++++++++++++----- crates/evm/traces/src/identifier/local.rs | 21 +++++++++++-------- crates/script/src/execute.rs | 4 +++- crates/script/src/lib.rs | 8 +++----- crates/script/src/transaction.rs | 5 +++-- crates/script/src/verify.rs | 6 +++--- 7 files changed, 51 insertions(+), 29 deletions(-) diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index a729d53bb8432..728358bd63011 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -355,11 +355,14 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result { diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 561d7229b5281..1627e79587c91 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -20,9 +20,9 @@ pub struct ContractData { /// Contract ABI. pub abi: JsonAbi, /// Contract creation code. - pub bytecode: Bytes, + pub bytecode: Option, /// Contract runtime code. - pub deployed_bytecode: Bytes, + pub deployed_bytecode: Option, } type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a ContractData); @@ -45,6 +45,12 @@ impl ContractsByArtifact { let bytecode = artifact.bytecode.and_then(|b| b.into_bytes())?; let deployed_bytecode = artifact.deployed_bytecode.and_then(|b| b.into_bytes())?; + + // Exclude artifacts with present but empty bytecode. Such artifacts are usually + // interfaces and abstract contracts. + let bytecode = (bytecode.len() > 0).then_some(bytecode); + let deployed_bytecode = + (deployed_bytecode.len() > 0).then_some(deployed_bytecode); let abi = artifact.abi?; Some((id, ContractData { name, abi, bytecode, deployed_bytecode })) @@ -55,14 +61,23 @@ impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. pub fn find_by_creation_code(&self, code: &[u8]) -> Option { - self.iter() - .find(|(_, contract)| bytecode_diff_score(contract.bytecode.as_ref(), code) <= 0.1) + self.iter().find(|(_, contract)| { + if let Some(bytecode) = &contract.bytecode { + bytecode_diff_score(bytecode.as_ref(), code) <= 0.1 + } else { + false + } + }) } /// Finds a contract which has a similar deployed bytecode as `code`. pub fn find_by_deployed_code(&self, code: &[u8]) -> Option { self.iter().find(|(_, contract)| { - bytecode_diff_score(contract.deployed_bytecode.as_ref(), code) <= 0.1 + if let Some(deployed_bytecode) = &contract.deployed_bytecode { + bytecode_diff_score(deployed_bytecode.as_ref(), code) <= 0.1 + } else { + false + } }) } diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index 175414a7caeee..129656b959212 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -19,7 +19,8 @@ impl<'a> LocalTraceIdentifier<'a> { pub fn new(known_contracts: &'a ContractsByArtifact) -> Self { let mut ordered_ids = known_contracts .iter() - .map(|(id, contract)| (id, contract.deployed_bytecode.len())) + .filter_map(|(id, contract)| Some((id, contract.deployed_bytecode.as_ref()?))) + .map(|(id, bytecode)| (id, bytecode.len())) .collect::>(); ordered_ids.sort_by_key(|(_, len)| *len); Self { known_contracts, ordered_ids } @@ -40,14 +41,16 @@ impl<'a> LocalTraceIdentifier<'a> { let mut check = |id| { let contract = self.known_contracts.get(id)?; - let score = bytecode_diff_score(&contract.deployed_bytecode, code); - if score == 0.0 { - trace!(target: "evm::traces", "found exact match"); - return Some((id, &contract.abi)); - } - if score < min_score { - min_score = score; - min_score_id = Some((id, &contract.abi)); + if let Some(deployed_bytecode) = &contract.deployed_bytecode { + let score = bytecode_diff_score(deployed_bytecode, code); + if score == 0.0 { + trace!(target: "evm::traces", "found exact match"); + return Some((id, &contract.abi)); + } + if score < min_score { + min_score = score; + min_score_id = Some((id, &contract.abi)); + } } None }; diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 1239cda1f3bcd..6dc6a9617c090 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -11,7 +11,7 @@ use alloy_primitives::{Address, Bytes}; use alloy_provider::Provider; use alloy_rpc_types::request::TransactionRequest; use async_recursion::async_recursion; -use eyre::Result; +use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ @@ -63,6 +63,8 @@ impl LinkedState { let ContractData { abi, bytecode, .. } = build_data.get_target_contract()?; + let bytecode = bytecode.ok_or_eyre("target contract has no bytecode")?; + let (func, calldata) = args.get_method_and_calldata(&abi)?; ensure_clean_constructor(&abi)?; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index dc4e05e1a0bf9..cc43929a6e066 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -362,11 +362,9 @@ impl ScriptArgs { // From artifacts for (artifact, contract) in known_contracts.iter() { - bytecodes.push(( - artifact.name.clone(), - &contract.bytecode, - &contract.deployed_bytecode, - )); + let Some(bytecode) = &contract.bytecode else { continue }; + let Some(deployed_bytecode) = &contract.deployed_bytecode else { continue }; + bytecodes.push((artifact.name.clone(), bytecode, deployed_bytecode)); } // From traces diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index cf392129055ee..3f5405db6f680 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -131,6 +131,7 @@ impl TransactionWithMetadata { let Some(data) = self.transaction.input.input() else { return Ok(()) }; let Some(info) = info else { return Ok(()) }; + let Some(bytecode) = info.bytecode.as_ref() else { return Ok(()) }; // `create2` transactions are prefixed by a 32 byte salt. let creation_code = if is_create2 { @@ -143,11 +144,11 @@ impl TransactionWithMetadata { }; // The constructor args start after bytecode. - let contains_constructor_args = creation_code.len() > info.bytecode.len(); + let contains_constructor_args = creation_code.len() > bytecode.len(); if !contains_constructor_args { return Ok(()); } - let constructor_args = &creation_code[info.bytecode.len()..]; + let constructor_args = &creation_code[bytecode.len()..]; let Some(constructor) = info.abi.constructor() else { return Ok(()) }; let values = constructor.abi_decode_input(constructor_args, false).map_err(|e| { diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index c9e10200437d2..f6545c30194cc 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -106,11 +106,11 @@ impl VerifyBundle { libraries: &[String], ) -> Option { for (artifact, contract) in self.known_contracts.iter() { + let Some(bytecode) = contract.bytecode.as_ref() else { continue }; // If it's a CREATE2, the tx.data comes with a 32-byte salt in the beginning // of the transaction - if data.split_at(create2_offset).1.starts_with(&contract.bytecode) { - let constructor_args = - data.split_at(create2_offset + contract.bytecode.len()).1.to_vec(); + if data.split_at(create2_offset).1.starts_with(bytecode) { + let constructor_args = data.split_at(create2_offset + bytecode.len()).1.to_vec(); let contract = ContractInfo { path: Some( From 5c6c68c63c08aba410d0013889e2336aa9dbb916 Mon Sep 17 00:00:00 2001 From: ThreeHrSleep <151536303+ThreeHrSleep@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:12:32 +0530 Subject: [PATCH 0878/1963] feat: use humatime serde for SuiteResult duration (#7722) added humantime serde --- Cargo.lock | 11 +++++++++++ crates/forge/Cargo.toml | 1 + crates/forge/src/result.rs | 1 + 3 files changed, 13 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index bd1fe244a7885..6f2fe9630e8b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3499,6 +3499,7 @@ dependencies = [ "foundry-wallets", "futures", "globset", + "humantime-serde", "hyper 1.2.0", "indicatif", "itertools 0.12.1", @@ -4829,6 +4830,16 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + [[package]] name = "hyper" version = "0.14.28" diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 9ccec21508fc1..7b05ee06e3209 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -38,6 +38,7 @@ rayon = "1" serde.workspace = true tracing.workspace = true yansi = "0.5" +humantime-serde = "1.1.1" # bin forge-doc.workspace = true diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 09c3661dc7194..7cef52a9e233e 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -192,6 +192,7 @@ impl TestOutcome { #[derive(Clone, Debug, Serialize)] pub struct SuiteResult { /// Wall clock time it took to execute all tests in this suite. + #[serde(with = "humantime_serde")] pub duration: Duration, /// Individual test results: `test fn signature -> TestResult`. pub test_results: BTreeMap, From 21b3346bc441505d06e15a758d57fe556fc51756 Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Fri, 19 Apr 2024 17:43:22 +0800 Subject: [PATCH 0879/1963] fix: Type parameter of Vm.prevrandao as uint256 (#7695) * fix: Type parameter of Vm.prevrandao as uint256 * fix: tests types * fix: overload instead of breaking --- crates/cheatcodes/assets/cheatcodes.json | 22 +++++++++++++++++++++- crates/cheatcodes/spec/src/vm.rs | 5 +++++ crates/cheatcodes/src/evm.rs | 15 ++++++++++++++- testdata/cheats/Vm.sol | 1 + testdata/default/cheats/Prevrandao.t.sol | 6 +++--- testdata/default/cheats/Setup.t.sol | 2 +- testdata/default/cheats/Snapshots.t.sol | 2 +- 7 files changed, 46 insertions(+), 7 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 1f25182261e53..30a63009a59a1 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6173,7 +6173,7 @@ }, { "func": { - "id": "prevrandao", + "id": "prevrandao_0", "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", "declaration": "function prevrandao(bytes32 newPrevrandao) external;", "visibility": "external", @@ -6191,6 +6191,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "prevrandao_1", + "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", + "declaration": "function prevrandao(uint256 newPrevrandao) external;", + "visibility": "external", + "mutability": "", + "signature": "prevrandao(uint256)", + "selector": "0x9cb1c0d4", + "selectorBytes": [ + 156, + 177, + 192, + 212 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "projectRoot", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 01d1290a68c08..e9d5a49caa511 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -375,6 +375,11 @@ interface Vm { /// If used on unsupported EVM versions it will revert. #[cheatcode(group = Evm, safety = Unsafe)] function prevrandao(bytes32 newPrevrandao) external; + /// Sets `block.prevrandao`. + /// Not available on EVM versions before Paris. Use `difficulty` instead. + /// If used on unsupported EVM versions it will revert. + #[cheatcode(group = Evm, safety = Unsafe)] + function prevrandao(uint256 newPrevrandao) external; /// Sets `block.height`. #[cheatcode(group = Evm, safety = Unsafe)] diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index d9c0f5cff09eb..bfe43d6849aa5 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -277,7 +277,7 @@ impl Cheatcode for feeCall { } } -impl Cheatcode for prevrandaoCall { +impl Cheatcode for prevrandao_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newPrevrandao } = self; ensure!( @@ -290,6 +290,19 @@ impl Cheatcode for prevrandaoCall { } } +impl Cheatcode for prevrandao_1Call { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { newPrevrandao } = self; + ensure!( + ccx.ecx.spec_id() >= SpecId::MERGE, + "`prevrandao` is not supported before the Paris hard fork, use `difficulty` instead; \ + see EIP-4399: https://eips.ethereum.org/EIPS/eip-4399" + ); + ccx.ecx.env.block.prevrandao = Some((*newPrevrandao).into()); + Ok(Default::default()) + } +} + impl Cheatcode for rollCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newHeight } = self; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 65c65784399b3..b04a07e1d54d0 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -305,6 +305,7 @@ interface Vm { function prank(address msgSender) external; function prank(address msgSender, address txOrigin) external; function prevrandao(bytes32 newPrevrandao) external; + function prevrandao(uint256 newPrevrandao) external; function projectRoot() external view returns (string memory path); function prompt(string calldata promptText) external returns (string memory input); function promptAddress(string calldata promptText) external returns (address); diff --git a/testdata/default/cheats/Prevrandao.t.sol b/testdata/default/cheats/Prevrandao.t.sol index a356fcd4ef293..7011ce3bee9cc 100644 --- a/testdata/default/cheats/Prevrandao.t.sol +++ b/testdata/default/cheats/Prevrandao.t.sol @@ -9,14 +9,14 @@ contract PrevrandaoTest is DSTest { function testPrevrandao() public { assertEq(block.prevrandao, 0); - vm.prevrandao(bytes32(uint256(10))); + vm.prevrandao(uint256(10)); assertEq(block.prevrandao, 10, "prevrandao cheatcode failed"); } function testPrevrandaoFuzzed(uint256 newPrevrandao) public { vm.assume(newPrevrandao != block.prevrandao); assertEq(block.prevrandao, 0); - vm.prevrandao(bytes32(newPrevrandao)); + vm.prevrandao(newPrevrandao); assertEq(block.prevrandao, newPrevrandao); } @@ -25,7 +25,7 @@ contract PrevrandaoTest is DSTest { uint256 oldPrevrandao = block.prevrandao; uint256 snapshot = vm.snapshot(); - vm.prevrandao(bytes32(newPrevrandao)); + vm.prevrandao(newPrevrandao); assertEq(block.prevrandao, newPrevrandao); assert(vm.revertTo(snapshot)); diff --git a/testdata/default/cheats/Setup.t.sol b/testdata/default/cheats/Setup.t.sol index e94bf34ec2d11..d694fb2c1c620 100644 --- a/testdata/default/cheats/Setup.t.sol +++ b/testdata/default/cheats/Setup.t.sol @@ -21,7 +21,7 @@ contract VmSetupTest is DSTest { vm.chainId(99); vm.roll(100); vm.fee(1000); - vm.prevrandao(bytes32(uint256(10000))); + vm.prevrandao(uint256(10000)); vm.startPrank(address(1337)); } diff --git a/testdata/default/cheats/Snapshots.t.sol b/testdata/default/cheats/Snapshots.t.sol index 8f85fee40e8ce..bb7b4e0e6008d 100644 --- a/testdata/default/cheats/Snapshots.t.sol +++ b/testdata/default/cheats/Snapshots.t.sol @@ -93,7 +93,7 @@ contract SnapshotTest is DSTest { vm.roll(99); assertEq(block.number, 99); - vm.prevrandao(bytes32(uint256(123))); + vm.prevrandao(uint256(123)); assertEq(block.prevrandao, 123); assert(vm.revertTo(snapshot)); From b18c149547e0bcdc968297b12c651e6fc2eed005 Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Fri, 19 Apr 2024 20:16:03 +0530 Subject: [PATCH 0880/1963] fix(forge): fix some typos in forge clone (#7725) fix some typos --- crates/forge/bin/cmd/clone.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 86ef41539a048..b7b83d04cfb7a 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -31,7 +31,7 @@ pub struct CloneMetadata { pub path: PathBuf, /// The name of the contract in the file. pub target_contract: String, - /// The address of the contract on the blockchian. + /// The address of the contract on the blockchain. pub address: Address, /// The chain id. pub chain_id: ChainId, @@ -67,7 +67,7 @@ pub struct CloneArgs { #[arg(value_hint = ValueHint::DirPath, default_value = ".", value_name = "PATH")] pub root: PathBuf, - /// Do not generaet the remappings.txt file. Instead, keep the remappings in the configuration. + /// Do not generate the remappings.txt file. Instead, keep the remappings in the configuration. #[arg(long)] pub no_remappings_txt: bool, @@ -160,7 +160,7 @@ impl CloneArgs { /// Collect the compilation metadata of the cloned contract. /// This function compiles the cloned contract and collects the compilation metadata. /// - /// * `meta` - the metadata of the contract (from Etherscam). + /// * `meta` - the metadata of the contract (from Etherscan). /// * `chain` - the chain where the contract to be cloned locates. /// * `address` - the address of the contract to be cloned. /// * `root` - the root directory of the cloned project. From 844caa88082d48e2b2df5b447dba09530a654cb1 Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Sat, 20 Apr 2024 03:03:02 +0530 Subject: [PATCH 0881/1963] fix(cast): return logs in all cases (#7731) * return logs in all cases * make clippy happy * nits --- crates/cast/bin/cmd/logs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index dd66176e8edc3..85f0c8414d67d 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -81,8 +81,10 @@ impl LogsArgs { None => None, }; - let from_block = cast.convert_block_number(from_block).await?; - let to_block = cast.convert_block_number(to_block).await?; + let from_block = + cast.convert_block_number(Some(from_block.unwrap_or_else(BlockId::earliest))).await?; + let to_block = + cast.convert_block_number(Some(to_block.unwrap_or_else(BlockId::latest))).await?; let filter = build_filter(from_block, to_block, address, sig_or_topic, topics_or_args)?; From dba274da4fbd7fe966215357c65909463c88ee0e Mon Sep 17 00:00:00 2001 From: "Du, Chengbin" Date: Sat, 20 Apr 2024 18:59:13 +0800 Subject: [PATCH 0882/1963] chore(deps): update rustls to 0.21.11 and 0.22.4 for security reason (#7734) details: https://cxsecurity.com/cveshow/CVE-2024-32650/ --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f2fe9630e8b6..a52ff0b62ad10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1337,7 +1337,7 @@ dependencies = [ "once_cell", "pin-project-lite", "pin-utils", - "rustls 0.21.10", + "rustls 0.21.11", "tokio", "tracing", ] @@ -4894,7 +4894,7 @@ dependencies = [ "http 0.2.12", "hyper 0.14.28", "log", - "rustls 0.21.10", + "rustls 0.21.11", "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", @@ -4910,7 +4910,7 @@ dependencies = [ "http 1.1.0", "hyper 1.2.0", "hyper-util", - "rustls 0.22.3", + "rustls 0.22.4", "rustls-pki-types", "tokio", "tokio-rustls 0.25.0", @@ -6928,7 +6928,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.10", + "rustls 0.21.11", "rustls-native-certs 0.6.3", "rustls-pemfile 1.0.4", "serde", @@ -6973,7 +6973,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.22.3", + "rustls 0.22.4", "rustls-native-certs 0.7.0", "rustls-pemfile 2.1.2", "rustls-pki-types", @@ -7255,9 +7255,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", "ring 0.17.8", @@ -7267,9 +7267,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring 0.17.8", @@ -8392,7 +8392,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.10", + "rustls 0.21.11", "tokio", ] @@ -8402,7 +8402,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.3", + "rustls 0.22.4", "rustls-pki-types", "tokio", ] @@ -8427,7 +8427,7 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls 0.21.10", + "rustls 0.21.11", "tokio", "tokio-rustls 0.24.1", "tungstenite 0.20.1", @@ -8712,7 +8712,7 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "rustls 0.21.10", + "rustls 0.21.11", "sha1", "thiserror", "url", From 167295ee0dd8425300656135a4570ac039e77296 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 20 Apr 2024 16:39:57 +0400 Subject: [PATCH 0883/1963] fix: always compile sources when running scripts (#7738) --- crates/script/src/build.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index bdc940097a896..99c1ff7a7fde8 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -11,13 +11,14 @@ use alloy_provider::Provider; use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_common::{ - compile::{self, ContractSources}, + compile::{ContractSources, ProjectCompiler}, provider::alloy::try_get_http_provider, ContractData, ContractsByArtifact, }; use foundry_compilers::{ artifacts::{BytecodeObject, Libraries}, info::ContractInfo, + utils::source_files_iter, ArtifactId, ProjectCompileOutput, }; use foundry_linking::{LinkOutput, Linker}; @@ -149,7 +150,13 @@ impl PreprocessedState { } }; - let output = compile::compile_target(&target_path, &project, args.opts.silent)?; + let sources_to_compile = + source_files_iter(project.paths.sources.as_path()).chain([target_path.to_path_buf()]); + + let output = ProjectCompiler::new() + .quiet_if(args.opts.silent) + .files(sources_to_compile) + .compile(&project)?; let mut target_id: Option = None; From 30f145ff677eb01361f7f05c3233c133d1fd0d5b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 20 Apr 2024 16:40:05 +0400 Subject: [PATCH 0884/1963] fix: correctly process relative paths as `--skip` values (#7737) * fix: correctly process relative paths as values * clippy * nit --- crates/common/src/compile.rs | 24 ++++++++++++++++++++---- crates/forge/bin/cmd/build.rs | 3 ++- crates/forge/tests/cli/cmd.rs | 7 ++++++- crates/verify/src/bytecode.rs | 5 ++++- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index a498a61b34a73..3b1d83c182502 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -560,19 +560,35 @@ pub fn etherscan_project(metadata: &Metadata, target_path: impl AsRef) -> /// Bundles multiple `SkipBuildFilter` into a single `FileFilter` #[derive(Clone, Debug)] -pub struct SkipBuildFilters(Vec); +pub struct SkipBuildFilters { + /// All provided filters. + pub matchers: Vec, + /// Root of the project. + pub project_root: PathBuf, +} impl FileFilter for SkipBuildFilters { /// Only returns a match if _no_ exclusion filter matches fn is_match(&self, file: &Path) -> bool { - self.0.iter().all(|matcher| is_match_exclude(matcher, file)) + self.matchers.iter().all(|matcher| { + if !is_match_exclude(matcher, file) { + false + } else { + file.strip_prefix(&self.project_root) + .map_or(true, |stripped| is_match_exclude(matcher, stripped)) + } + }) } } impl SkipBuildFilters { /// Creates a new `SkipBuildFilters` from multiple `SkipBuildFilter`. - pub fn new(matchers: impl IntoIterator) -> Result { - matchers.into_iter().map(|m| m.compile()).collect::>().map(Self) + pub fn new( + filters: impl IntoIterator, + project_root: PathBuf, + ) -> Result { + let matchers = filters.into_iter().map(|m| m.compile()).collect::>(); + matchers.map(|filters| Self { matchers: filters, project_root }) } } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 66dae630e1b05..c2e6715a4615f 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -94,7 +94,8 @@ impl BuildArgs { .bail(!self.format_json); if let Some(skip) = self.skip { if !skip.is_empty() { - compiler = compiler.filter(Box::new(SkipBuildFilters::new(skip)?)); + compiler = compiler + .filter(Box::new(SkipBuildFilters::new(skip, project.root().to_path_buf())?)); } } let output = compiler.compile(&project)?; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 0da6191b0e600..ab1583d2c9d03 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1620,7 +1620,12 @@ function test_run() external {} // only builds the single template contract `src/*` even if `*.t.sol` or `.s.sol` is absent prj.clear(); - cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**"]); + cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**", "--force"]); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_build_skip_glob.stdout"), + ); + + cmd.forge_fuse().args(["build", "--skip", "./test/**", "--skip", "./script/**", "--force"]); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_build_skip_glob.stdout"), ); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index d84acbccc9985..b89fc91f13a6e 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -373,7 +373,10 @@ impl VerifyBytecodeArgs { if let Some(skip) = &self.skip { if !skip.is_empty() { - compiler = compiler.filter(Box::new(SkipBuildFilters::new(skip.to_owned())?)); + compiler = compiler.filter(Box::new(SkipBuildFilters::new( + skip.to_owned(), + project.root().to_path_buf(), + )?)); } } let output = compiler.compile(&project)?; From 6f2668f925ca0cd98d19e0f2208ec3fe89ac8832 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 21 Apr 2024 02:56:31 +0400 Subject: [PATCH 0885/1963] fix: do not require `--sender` with `--unlocked` (#7742) * fix: do not require --sender with --unlocked * test --- crates/forge/tests/cli/script.rs | 33 ++++++++++++++++++++++++++++++++ crates/script/src/lib.rs | 1 - 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 21b5837bb1bcb..70b97b58fe10e 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1288,3 +1288,36 @@ contract SimpleScript is Script { let output = cmd.stdout_lossy(); assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); }); + +// https://github.com/foundry-rs/foundry/pull/7742 +forgetest_async!(unlocked_no_sender, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function run() external { + vm.startBroadcast(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + address(0).call(""); + } +} + "#, + ) + .unwrap(); + + let (_api, handle) = spawn(NodeConfig::test()).await; + + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--broadcast", + "--unlocked", + ]); + + let output = cmd.stdout_lossy(); + assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +}); diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index cc43929a6e066..0f9d8ad476c34 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -120,7 +120,6 @@ pub struct ScriptArgs { /// Send via `eth_sendTransaction` using the `--from` argument or `$ETH_FROM` as sender #[arg( long, - requires = "sender", conflicts_with_all = &["private_key", "private_keys", "froms", "ledger", "trezor", "aws"], )] pub unlocked: bool, From db74e6ecfecdc19b3821a908721b7c00b0808b22 Mon Sep 17 00:00:00 2001 From: 0xtekgrinder <72015889+0xtekgrinder@users.noreply.github.com> Date: Sat, 20 Apr 2024 19:10:30 -0400 Subject: [PATCH 0886/1963] feat: add envExists cheatcode to check if a environment variable exists (#7744) --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 4 ++++ crates/cheatcodes/src/env.rs | 7 +++++++ testdata/cheats/Vm.sol | 1 + testdata/default/cheats/Env.t.sol | 8 ++++++++ 5 files changed, 40 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 30a63009a59a1..9ce73e931abe2 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3811,6 +3811,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "envExists", + "description": "Gets the environment variable `name` and returns true if it exists, else returns false.", + "declaration": "function envExists(string calldata name) external view returns (bool exists);", + "visibility": "external", + "mutability": "view", + "signature": "envExists(string)", + "selector": "0xce8365f9", + "selectorBytes": [ + 206, + 131, + 101, + 249 + ] + }, + "group": "environment", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "envInt_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index e9d5a49caa511..39f0fd8b0006e 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1501,6 +1501,10 @@ interface Vm { #[cheatcode(group = Environment)] function setEnv(string calldata name, string calldata value) external; + /// Gets the environment variable `name` and returns true if it exists, else returns false. + #[cheatcode(group = Environment)] + function envExists(string calldata name) external view returns (bool exists); + /// Gets the environment variable `name` and parses it as `bool`. /// Reverts if the variable was not found or could not be parsed. #[cheatcode(group = Environment)] diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index d9022d1b3f086..b8245dda1d00a 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -26,6 +26,13 @@ impl Cheatcode for setEnvCall { } } +impl Cheatcode for envExistsCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + Ok(env::var(name).is_ok().abi_encode()) + } +} + impl Cheatcode for envBool_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { name } = self; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index b04a07e1d54d0..02eeac480e333 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -186,6 +186,7 @@ interface Vm { function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value); function envBytes(string calldata name) external view returns (bytes memory value); function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value); + function envExists(string calldata name) external view returns (bool exists); function envInt(string calldata name) external view returns (int256 value); 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); diff --git a/testdata/default/cheats/Env.t.sol b/testdata/default/cheats/Env.t.sol index 523ab34dc1f59..e325df2fa4429 100644 --- a/testdata/default/cheats/Env.t.sol +++ b/testdata/default/cheats/Env.t.sol @@ -13,6 +13,14 @@ contract EnvTest is DSTest { vm.setEnv(key, val); } + function testEnvExists() public { + string memory key = "_foundryCheatcodeEnvExistsTestKey"; + string memory val = "_foundryCheatcodeEnvExistsTestVal"; + vm.setEnv(key, val); + require(vm.envExists(key), "envExists failed"); + require(!vm.envExists("nonexistent"), "envExists failed"); + } + uint256 constant numEnvBoolTests = 2; function testEnvBool() public { From 63fff3510408b552f11efb8196f48cfe6c1da664 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 21 Apr 2024 03:13:18 +0400 Subject: [PATCH 0887/1963] fix: print test results while running coverage (#7743) --- crates/forge/bin/cmd/coverage.rs | 57 +++++++++----------------------- 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index fc919934f0378..66f45b7704c9f 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -1,4 +1,4 @@ -use super::{install, test::FilterArgs}; +use super::{install, test::TestArgs}; use alloy_primitives::{Address, Bytes, U256}; use clap::{Parser, ValueEnum, ValueHint}; use eyre::{Context, Result}; @@ -8,17 +8,15 @@ use forge::{ CoverageReport, CoverageReporter, DebugReporter, LcovReporter, SummaryReporter, }, opts::EvmOpts, - result::SuiteResult, revm::primitives::SpecId, utils::IcPcMap, MultiContractRunnerBuilder, TestOptions, }; use foundry_cli::{ - opts::CoreBuildArgs, p_println, utils::{LoadConfig, STATIC_FUZZ_SEED}, }; -use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; +use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ artifacts::{contract::CompactContractBytecode, Ast, CompactBytecode, CompactDeployedBytecode}, sourcemap::SourceMap, @@ -27,18 +25,14 @@ use foundry_compilers::{ use foundry_config::{Config, SolcReq}; use rustc_hash::FxHashMap; use semver::Version; -use std::{ - collections::HashMap, - path::PathBuf, - sync::{mpsc::channel, Arc}, -}; +use std::{collections::HashMap, path::PathBuf, sync::Arc}; use yansi::Paint; /// A map, keyed by contract ID, to a tuple of the deployment source map and the runtime source map. type SourceMaps = HashMap; // Loads project's figment and merges the build cli arguments into it -foundry_config::impl_figment_convert!(CoverageArgs, opts, evm_opts); +foundry_config::impl_figment_convert!(CoverageArgs, test); /// CLI arguments for `forge coverage`. #[derive(Clone, Debug, Parser)] @@ -72,13 +66,7 @@ pub struct CoverageArgs { include_libs: bool, #[command(flatten)] - filter: FilterArgs, - - #[command(flatten)] - evm_opts: EvmArgs, - - #[command(flatten)] - opts: CoreBuildArgs, + test: TestArgs, } impl CoverageArgs { @@ -86,7 +74,7 @@ impl CoverageArgs { let (mut config, evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; // install missing dependencies - if install::install_missing_dependencies(&mut config, self.build_args().silent) && + if install::install_missing_dependencies(&mut config, self.test.build_args().silent) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings @@ -100,10 +88,10 @@ impl CoverageArgs { config.ast = true; let (project, output) = self.build(&config)?; - p_println!(!self.opts.silent => "Analysing contracts..."); + p_println!(!self.test.build_args().silent => "Analysing contracts..."); let report = self.prepare(&config, output.clone())?; - p_println!(!self.opts.silent => "Running tests..."); + p_println!(!self.test.build_args().silent => "Running tests..."); self.collect(project, output, report, Arc::new(config), evm_opts).await } @@ -131,7 +119,7 @@ impl CoverageArgs { "Note that \"viaIR\" is only available in Solidity 0.8.13 and above.\n", "See more: https://github.com/foundry-rs/foundry/issues/3357", )); - p_println!(!self.opts.silent => "{msg}"); + p_println!(!self.test.build_args().silent => "{msg}"); // Enable viaIR with minimum optimization // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 @@ -315,10 +303,11 @@ impl CoverageArgs { evm_opts: EvmOpts, ) -> Result<()> { let root = project.paths.root; + let verbosity = evm_opts.verbosity; // Build the contract runner let env = evm_opts.evm_env().await?; - let mut runner = MultiContractRunnerBuilder::new(config.clone()) + let runner = MultiContractRunnerBuilder::new(config.clone()) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) @@ -331,13 +320,13 @@ impl CoverageArgs { .set_coverage(true) .build(&root, output, env, evm_opts)?; - // Run tests - let filter = self.filter; - let (tx, rx) = channel::<(String, SuiteResult)>(); - let handle = tokio::task::spawn_blocking(move || runner.test(&filter, tx)); + let outcome = self + .test + .run_tests(runner, config.clone(), verbosity, &self.test.filter(&config)) + .await?; // Add hit data to the coverage report - let data = rx.into_iter().flat_map(|(_, suite)| { + let data = outcome.results.into_iter().flat_map(|(_, suite)| { let mut hits = Vec::new(); for (_, mut result) in suite.test_results { let Some(hit_maps) = result.coverage.take() else { continue }; @@ -359,7 +348,6 @@ impl CoverageArgs { }); for (artifact_id, hits, is_deployed_code) in data { - // TODO: Note down failing tests if let Some(source_id) = report.get_source_id( artifact_id.version.clone(), artifact_id.source.to_string_lossy().to_string(), @@ -377,14 +365,6 @@ impl CoverageArgs { } } - // Reattach the thread - if let Err(e) = handle.await { - match e.try_into_panic() { - Ok(payload) => std::panic::resume_unwind(payload), - Err(e) => return Err(e.into()), - } - } - // Output final report for report_kind in self.report { match report_kind { @@ -409,11 +389,6 @@ impl CoverageArgs { } Ok(()) } - - /// Returns the flattened [`CoreBuildArgs`] - pub fn build_args(&self) -> &CoreBuildArgs { - &self.opts - } } // TODO: HTML From 68006b65f3df56d262a3402b7cfb4b87fed71efc Mon Sep 17 00:00:00 2001 From: Zhuo Zhang <14835483+ZhangZhuoSJTU@users.noreply.github.com> Date: Mon, 22 Apr 2024 17:04:27 +0800 Subject: [PATCH 0888/1963] fix(forge): fix `forge clone` when there is nested `src` (#7747) * test: add a test case with nested src * fix: fix the bug caused by nested src * chore: make the directory of the cloned project more readable * chore: add --keep-directory-structure option to improve compilation robustness if necessary test: add two more tests for forge clone * chore: use instead of --- crates/forge/bin/cmd/clone.rs | 189 ++++++++++++------ crates/forge/tests/cli/cmd.rs | 42 ++++ .../creation_data.json | 5 + .../metadata.json | 96 +++++++++ 4 files changed, 276 insertions(+), 56 deletions(-) create mode 100644 testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/creation_data.json create mode 100644 testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/metadata.json diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index b7b83d04cfb7a..ca6fdf7be767b 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -71,6 +71,14 @@ pub struct CloneArgs { #[arg(long)] pub no_remappings_txt: bool, + /// Keep the original directory structure collected from Etherscan. + /// + /// If this flag is set, the directory structure of the cloned project will be kept as is. + /// By default, the directory structure is re-orgnized to increase the readability, but may + /// risk some compilation failures. + #[arg(long)] + pub keep_directory_structure: bool, + #[command(flatten)] pub etherscan: EtherscanOpts, @@ -80,7 +88,14 @@ pub struct CloneArgs { impl CloneArgs { pub async fn run(self) -> Result<()> { - let CloneArgs { address, root, opts, etherscan, no_remappings_txt } = self; + let CloneArgs { + address, + root, + opts, + etherscan, + no_remappings_txt, + keep_directory_structure, + } = self; // step 0. get the chain and api key from the config let config = Config::from(ðerscan); @@ -99,7 +114,8 @@ impl CloneArgs { let root = dunce::canonicalize(&root)?; // step 3. parse the metadata - Self::parse_metadata(&meta, chain, &root, no_remappings_txt).await?; + Self::parse_metadata(&meta, chain, &root, no_remappings_txt, keep_directory_structure) + .await?; // step 4. collect the compilation metadata // if the etherscan api key is not set, we need to wait for 3 seconds between calls @@ -214,33 +230,24 @@ impl CloneArgs { chain: Chain, root: &PathBuf, no_remappings_txt: bool, + keep_directory_structure: bool, ) -> Result<()> { // dump sources and update the remapping in configuration - let Settings { remappings: original_remappings, .. } = meta.settings()?; - let (remappings, strip_old_src) = dump_sources(meta, root)?; + let remappings = dump_sources(meta, root, keep_directory_structure)?; Config::update_at(root, |config, doc| { let profile = config.profile.as_str().as_str(); + + // update the remappings in the configuration let mut remapping_array = toml_edit::Array::new(); - // original remappings - for r in original_remappings.iter() { - // we should update its remapped path in the same way as we dump sources - // i.e., remove prefix `contracts` (if any) and add prefix `src` - let mut r = r.to_owned(); - if strip_old_src { - let new_path = PathBuf::from(r.path.clone()) - .strip_prefix("contracts") - .map(|p| p.to_path_buf()) - .unwrap_or(PathBuf::from(r.path)); - r.path = PathBuf::from("src").join(new_path).to_string_lossy().to_string(); - } - remapping_array.push(r.to_string()); - } - // new remappings for r in remappings { remapping_array.push(r.to_string()); } doc[Config::PROFILE_SECTION][profile]["remappings"] = toml_edit::value(remapping_array); + // make sure auto_detect_remappings is false (it is very important because cloned + // project may not follow the common remappings) + doc[Config::PROFILE_SECTION][profile]["auto_detect_remappings"] = + toml_edit::value(false); true })?; @@ -407,13 +414,13 @@ fn update_config_by_metadata( /// Dump the contract sources to the root directory. /// The sources are dumped to the `src` directory. /// IO errors may be returned. -/// A list of remappings is returned, as well as a boolean indicating whether the old `contract` -/// or `src` directories are stripped. -fn dump_sources(meta: &Metadata, root: &PathBuf) -> Result<(Vec, bool)> { +/// A list of remappings is returned +fn dump_sources(meta: &Metadata, root: &PathBuf, no_reorg: bool) -> Result> { // get config let path_config = ProjectPathsConfig::builder().build_with_root(root); // we will canonicalize the sources directory later let src_dir = &path_config.sources; + let lib_dir = &path_config.libraries[0]; let contract_name = &meta.contract_name; let source_tree = meta.source_tree(); @@ -421,8 +428,6 @@ fn dump_sources(meta: &Metadata, root: &PathBuf) -> Result<(Vec = Remapping::find_many(root); - // we also load the original remappings from the metadata - remappings.extend(meta.settings()?.remappings); // first we dump the sources to a temporary directory let tmp_dump_dir = root.join("raw_sources"); @@ -430,51 +435,115 @@ fn dump_sources(meta: &Metadata, root: &PathBuf) -> Result<(Vec Option<(&'static str, &'static str)> { for (addr, contract_name, creation_code) in CREATION_ARRAY.iter() { if address == *addr { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index ab1583d2c9d03..df6a306f5cab1 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -468,6 +468,48 @@ forgetest!(can_clone_quiet, |prj, cmd| { cmd.assert_empty_stdout(); }); +// checks that clone works with --no-remappings-txt +forgetest!(can_clone_no_remappings_txt, |prj, cmd| { + prj.wipe(); + + let foundry_toml = prj.root().join(Config::FILE_NAME); + assert!(!foundry_toml.exists()); + + cmd.args([ + "clone", + "--etherscan-api-key", + next_etherscan_api_key().as_str(), + "--no-remappings-txt", + "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", + ]) + .arg(prj.root()); + cmd.assert_non_empty_stdout(); + + let s = read_string(&foundry_toml); + let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; +}); + +// checks that clone works with --keep-directory-structure +forgetest!(can_clone_keep_directory_structure, |prj, cmd| { + prj.wipe(); + + let foundry_toml = prj.root().join(Config::FILE_NAME); + assert!(!foundry_toml.exists()); + + cmd.args([ + "clone", + "--etherscan-api-key", + next_etherscan_api_key().as_str(), + "--keep-directory-structure", + "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", + ]) + .arg(prj.root()); + cmd.assert_non_empty_stdout(); + + let s = read_string(&foundry_toml); + let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; +}); + // checks that `clean` removes dapptools style paths forgetest!(can_clean, |prj, cmd| { prj.assert_create_dirs_exists(); diff --git a/testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/creation_data.json b/testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/creation_data.json new file mode 100644 index 0000000000000..7896ef85659c8 --- /dev/null +++ b/testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/creation_data.json @@ -0,0 +1,5 @@ +{ + "contractAddress": "0x9d27527ada2cf29fbdab2973cfa243845a08bd3f", + "contractCreator": "0x7773ae67403d2e30102a84c48cc939919c4c881c", + "txHash": "0xc757719b7ae11ea651b1b23249978a3e8fca94d358610f5809a5dc19fbf850ce" +} \ No newline at end of file diff --git a/testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/metadata.json b/testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/metadata.json new file mode 100644 index 0000000000000..514b2571c4ecf --- /dev/null +++ b/testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/metadata.json @@ -0,0 +1,96 @@ +[ + { + "SourceCode": { + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "src/base/ERC721Checkpointable.sol": { + "content": "// SPDX-License-Identifier: BSD-3-Clause\n\n/// @title Vote checkpointing for an ERC-721 token\n\n/*********************************\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░█████████░░█████████░░░ *\n * ░░░░░░██░░░████░░██░░░████░░░ *\n * ░░██████░░░████████░░░████░░░ *\n * ░░██░░██░░░████░░██░░░████░░░ *\n * ░░██░░██░░░████░░██░░░████░░░ *\n * ░░░░░░█████████░░█████████░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n *********************************/\n\n// LICENSE\n// ERC721Checkpointable.sol uses and modifies part of Compound Lab's Comp.sol:\n// https://github.com/compound-finance/compound-protocol/blob/ae4388e780a8d596d97619d9704a931a2752c2bc/contracts/Governance/Comp.sol\n//\n// Comp.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license.\n// With modifications by Nounders DAO.\n//\n// Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause\n//\n// MODIFICATIONS\n// Checkpointing logic from Comp.sol has been used with the following modifications:\n// - `delegates` is renamed to `_delegates` and is set to private\n// - `delegates` is a public function that uses the `_delegates` mapping look-up, but unlike\n// Comp.sol, returns the delegator's own address if there is no delegate.\n// This avoids the delegator needing to \"delegate to self\" with an additional transaction\n// - `_transferTokens()` is renamed `_beforeTokenTransfer()` and adapted to hook into OpenZeppelin's ERC721 hooks.\n\npragma solidity 0.8.9;\n\nimport \"./ERC721BaseWithERC4494Permit.sol\";\n\nabstract contract ERC721Checkpointable is ERC721BaseWithERC4494Permit {\n bool internal _useCheckpoints = true; // can only be disabled and never re-enabled\n\n /// @notice Defines decimals as per ERC-20 convention to make integrations with 3rd party governance platforms easier\n uint8 public constant decimals = 0;\n\n /// @notice A record of each accounts delegate\n mapping(address => address) private _delegates;\n\n /// @notice A checkpoint for marking number of votes from a given block\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n /// @notice A record of votes checkpoints for each account, by index\n mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;\n\n /// @notice The number of checkpoints for each account\n mapping(address => uint32) public numCheckpoints;\n\n /// @notice The EIP-712 typehash for the delegation struct used by the contract\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n /// @notice An event thats emitted when an account changes its delegate\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /// @notice An event thats emitted when a delegate account's vote balance changes\n event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n /**\n * @notice The votes a delegator can delegate, which is the current balance of the delegator.\n * @dev Used when calling `_delegate()`\n */\n function votesToDelegate(address delegator) public view returns (uint96) {\n return safe96(balanceOf(delegator), \"ERC721Checkpointable::votesToDelegate: amount exceeds 96 bits\");\n }\n\n /**\n * @notice Overrides the standard `Comp.sol` delegates mapping to return\n * the delegator's own address if they haven't delegated.\n * This avoids having to delegate to oneself.\n */\n function delegates(address delegator) public view returns (address) {\n address current = _delegates[delegator];\n return current == address(0) ? delegator : current;\n }\n\n /**\n * @notice Adapted from `_transferTokens()` in `Comp.sol` to update delegate votes.\n * @dev hooks into ERC721Base's `ERC721._transfer`\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal override {\n super._beforeTokenTransfer(from, to, tokenId);\n if (_useCheckpoints) {\n /// @notice Differs from `_transferTokens()` to use `delegates` override method to simulate auto-delegation\n _moveDelegates(delegates(from), delegates(to), 1);\n }\n }\n\n /**\n * @notice Delegate votes from `msg.sender` to `delegatee`\n * @param delegatee The address to delegate votes to\n */\n function delegate(address delegatee) public {\n if (delegatee == address(0)) delegatee = msg.sender;\n return _delegate(msg.sender, delegatee);\n }\n\n /**\n * @notice Delegates votes from signatory to `delegatee`\n * @param delegatee The address to delegate votes to\n * @param nonce The contract state required to match the signature\n * @param expiry The time at which to expire the signature\n * @param v The recovery byte of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n _DOMAIN_SEPARATOR(),\n keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry))\n )\n );\n // TODO support smart contract wallet via IERC721, require change in function signature to know which signer to call first\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), \"ERC721Checkpointable::delegateBySig: invalid signature\");\n require(nonce == _userNonces[signatory]++, \"ERC721Checkpointable::delegateBySig: invalid nonce\");\n require(block.timestamp <= expiry, \"ERC721Checkpointable::delegateBySig: signature expired\");\n return _delegate(signatory, delegatee);\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getCurrentVotes(address account) public view returns (uint96) {\n uint32 nCheckpoints = numCheckpoints[account];\n return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;\n }\n\n /**\n * @notice Gets the current votes balance for `account`\n * @param account The address to get votes balance\n * @return The number of current votes for `account`\n */\n function getVotes(address account) external view returns (uint96) {\n return getCurrentVotes(account);\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPriorVotes(address account, uint256 blockNumber) public view returns (uint96) {\n require(blockNumber < block.number, \"ERC721Checkpointable::getPriorVotes: not yet determined\");\n\n uint32 nCheckpoints = numCheckpoints[account];\n if (nCheckpoints == 0) {\n return 0;\n }\n\n // First check most recent balance\n if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {\n return checkpoints[account][nCheckpoints - 1].votes;\n }\n\n // Next check implicit zero balance\n if (checkpoints[account][0].fromBlock > blockNumber) {\n return 0;\n }\n\n uint32 lower = 0;\n uint32 upper = nCheckpoints - 1;\n while (upper > lower) {\n uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n Checkpoint memory cp = checkpoints[account][center];\n if (cp.fromBlock == blockNumber) {\n return cp.votes;\n } else if (cp.fromBlock < blockNumber) {\n lower = center;\n } else {\n upper = center - 1;\n }\n }\n return checkpoints[account][lower].votes;\n }\n\n /**\n * @notice Determine the prior number of votes for an account as of a block number\n * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n * @param account The address of the account to check\n * @param blockNumber The block number to get the vote balance at\n * @return The number of votes the account had as of the given block\n */\n function getPastVotes(address account, uint256 blockNumber) external view returns (uint96) {\n return this.getPriorVotes(account, blockNumber);\n }\n\n function _delegate(address delegator, address delegatee) internal {\n /// @notice differs from `_delegate()` in `Comp.sol` to use `delegates` override method to simulate auto-delegation\n address currentDelegate = delegates(delegator);\n\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n uint96 amount = votesToDelegate(delegator);\n\n _moveDelegates(currentDelegate, delegatee, amount);\n }\n\n function _moveDelegates(\n address srcRep,\n address dstRep,\n uint96 amount\n ) internal {\n if (srcRep != dstRep && amount > 0) {\n if (srcRep != address(0)) {\n uint32 srcRepNum = numCheckpoints[srcRep];\n uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;\n uint96 srcRepNew = sub96(srcRepOld, amount, \"ERC721Checkpointable::_moveDelegates: amount underflows\");\n _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);\n }\n\n if (dstRep != address(0)) {\n uint32 dstRepNum = numCheckpoints[dstRep];\n uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;\n uint96 dstRepNew = add96(dstRepOld, amount, \"ERC721Checkpointable::_moveDelegates: amount overflows\");\n _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);\n }\n }\n }\n\n function _writeCheckpoint(\n address delegatee,\n uint32 nCheckpoints,\n uint96 oldVotes,\n uint96 newVotes\n ) internal {\n uint32 blockNumber = safe32(\n block.number,\n \"ERC721Checkpointable::_writeCheckpoint: block number exceeds 32 bits\"\n );\n\n if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {\n checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;\n } else {\n checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);\n numCheckpoints[delegatee] = nCheckpoints + 1;\n }\n\n emit DelegateVotesChanged(delegatee, oldVotes, newVotes);\n }\n\n function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {\n require(n < 2**32, errorMessage);\n return uint32(n);\n }\n\n function safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) {\n require(n < 2**96, errorMessage);\n return uint96(n);\n }\n\n function add96(\n uint96 a,\n uint96 b,\n string memory errorMessage\n ) internal pure returns (uint96) {\n uint96 c = a + b;\n require(c >= a, errorMessage);\n return c;\n }\n\n function sub96(\n uint96 a,\n uint96 b,\n string memory errorMessage\n ) internal pure returns (uint96) {\n require(b <= a, errorMessage);\n return a - b;\n }\n}\n" + }, + "src/base/ERC721Base.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\n\nabstract contract ERC721Base is IERC165, IERC721 {\n using Address for address;\n\n bytes4 internal constant ERC721_RECEIVED = 0x150b7a02;\n bytes4 internal constant ERC165ID = 0x01ffc9a7;\n\n uint256 internal constant OPERATOR_FLAG = 0x8000000000000000000000000000000000000000000000000000000000000000;\n uint256 internal constant NOT_OPERATOR_FLAG = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n mapping(uint256 => uint256) internal _owners;\n mapping(address => uint256) internal _balances;\n mapping(address => mapping(address => bool)) internal _operatorsForAll;\n mapping(uint256 => address) internal _operators;\n\n function name() public pure virtual returns (string memory) {\n revert(\"NOT_IMPLEMENTED\");\n }\n\n /// @notice Approve an operator to transfer a specific token on the senders behalf.\n /// @param operator The address receiving the approval.\n /// @param id The id of the token.\n function approve(address operator, uint256 id) external override {\n (address owner, uint256 blockNumber) = _ownerAndBlockNumberOf(id);\n require(owner != address(0), \"NONEXISTENT_TOKEN\");\n require(msg.sender == owner || isApprovedForAll(owner, msg.sender), \"UNAUTHORIZED_APPROVAL\");\n _approveFor(owner, blockNumber, operator, id);\n }\n\n /// @notice Transfer a token between 2 addresses.\n /// @param from The sender of the token.\n /// @param to The recipient of the token.\n /// @param id The id of the token.\n function transferFrom(\n address from,\n address to,\n uint256 id\n ) external override {\n (address owner, bool operatorEnabled) = _ownerAndOperatorEnabledOf(id);\n require(owner != address(0), \"NONEXISTENT_TOKEN\");\n require(owner == from, \"NOT_OWNER\");\n require(to != address(0), \"NOT_TO_ZEROADDRESS\");\n require(to != address(this), \"NOT_TO_THIS\");\n if (msg.sender != from) {\n require(\n (operatorEnabled && _operators[id] == msg.sender) || isApprovedForAll(from, msg.sender),\n \"UNAUTHORIZED_TRANSFER\"\n );\n }\n _transferFrom(from, to, id);\n }\n\n /// @notice Transfer a token between 2 addresses letting the receiver know of the transfer.\n /// @param from The send of the token.\n /// @param to The recipient of the token.\n /// @param id The id of the token.\n function safeTransferFrom(\n address from,\n address to,\n uint256 id\n ) external override {\n safeTransferFrom(from, to, id, \"\");\n }\n\n /// @notice Set the approval for an operator to manage all the tokens of the sender.\n /// @param operator The address receiving the approval.\n /// @param approved The determination of the approval.\n function setApprovalForAll(address operator, bool approved) external override {\n _setApprovalForAll(msg.sender, operator, approved);\n }\n\n /// @notice Get the number of tokens owned by an address.\n /// @param owner The address to look for.\n /// @return balance The number of tokens owned by the address.\n function balanceOf(address owner) public view override returns (uint256 balance) {\n require(owner != address(0), \"ZERO_ADDRESS_OWNER\");\n balance = _balances[owner];\n }\n\n /// @notice Get the owner of a token.\n /// @param id The id of the token.\n /// @return owner The address of the token owner.\n function ownerOf(uint256 id) external view override returns (address owner) {\n owner = _ownerOf(id);\n require(owner != address(0), \"NONEXISTENT_TOKEN\");\n }\n\n /// @notice Get the owner of a token and the blockNumber of the last transfer, useful to voting mechanism.\n /// @param id The id of the token.\n /// @return owner The address of the token owner.\n /// @return blockNumber The blocknumber at which the last transfer of that id happened.\n function ownerAndLastTransferBlockNumberOf(uint256 id) internal view returns (address owner, uint256 blockNumber) {\n return _ownerAndBlockNumberOf(id);\n }\n\n struct OwnerData {\n address owner;\n uint256 lastTransferBlockNumber;\n }\n\n /// @notice Get the list of owner of a token and the blockNumber of its last transfer, useful to voting mechanism.\n /// @param ids The list of token ids to check.\n /// @return ownersData The list of (owner, lastTransferBlockNumber) for each ids given as input.\n function ownerAndLastTransferBlockNumberList(uint256[] calldata ids)\n external\n view\n returns (OwnerData[] memory ownersData)\n {\n ownersData = new OwnerData[](ids.length);\n for (uint256 i = 0; i < ids.length; i++) {\n uint256 data = _owners[ids[i]];\n ownersData[i].owner = address(uint160(data));\n ownersData[i].lastTransferBlockNumber = (data >> 160) & 0xFFFFFFFFFFFFFFFFFFFFFF;\n }\n }\n\n /// @notice Get the approved operator for a specific token.\n /// @param id The id of the token.\n /// @return The address of the operator.\n function getApproved(uint256 id) external view override returns (address) {\n (address owner, bool operatorEnabled) = _ownerAndOperatorEnabledOf(id);\n require(owner != address(0), \"NONEXISTENT_TOKEN\");\n if (operatorEnabled) {\n return _operators[id];\n } else {\n return address(0);\n }\n }\n\n /// @notice Check if the sender approved the operator.\n /// @param owner The address of the owner.\n /// @param operator The address of the operator.\n /// @return isOperator The status of the approval.\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool isOperator) {\n return _operatorsForAll[owner][operator];\n }\n\n /// @notice Transfer a token between 2 addresses letting the receiver knows of the transfer.\n /// @param from The sender of the token.\n /// @param to The recipient of the token.\n /// @param id The id of the token.\n /// @param data Additional data.\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n bytes memory data\n ) public override {\n (address owner, bool operatorEnabled) = _ownerAndOperatorEnabledOf(id);\n require(owner != address(0), \"NONEXISTENT_TOKEN\");\n require(owner == from, \"NOT_OWNER\");\n require(to != address(0), \"NOT_TO_ZEROADDRESS\");\n require(to != address(this), \"NOT_TO_THIS\");\n if (msg.sender != from) {\n require(\n (operatorEnabled && _operators[id] == msg.sender) || isApprovedForAll(from, msg.sender),\n \"UNAUTHORIZED_TRANSFER\"\n );\n }\n _safeTransferFrom(from, to, id, data);\n }\n\n /// @notice Check if the contract supports an interface.\n /// @param id The id of the interface.\n /// @return Whether the interface is supported.\n function supportsInterface(bytes4 id) public pure virtual override returns (bool) {\n /// 0x01ffc9a7 is ERC165.\n /// 0x80ac58cd is ERC721\n /// 0x5b5e139f is for ERC721 metadata\n return id == 0x01ffc9a7 || id == 0x80ac58cd || id == 0x5b5e139f;\n }\n\n function _safeTransferFrom(\n address from,\n address to,\n uint256 id,\n bytes memory data\n ) internal {\n _transferFrom(from, to, id);\n if (to.isContract()) {\n require(_checkOnERC721Received(msg.sender, from, to, id, data), \"ERC721_TRANSFER_REJECTED\");\n }\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 id\n ) internal virtual {}\n\n function _transferFrom(\n address from,\n address to,\n uint256 id\n ) internal {\n _beforeTokenTransfer(from, to, id);\n unchecked {\n _balances[to]++;\n if (from != address(0)) {\n _balances[from]--;\n }\n }\n _owners[id] = (block.number << 160) | uint256(uint160(to));\n emit Transfer(from, to, id);\n }\n\n /// @dev See approve.\n function _approveFor(\n address owner,\n uint256 blockNumber,\n address operator,\n uint256 id\n ) internal {\n if (operator == address(0)) {\n _owners[id] = (blockNumber << 160) | uint256(uint160(owner));\n } else {\n _owners[id] = OPERATOR_FLAG | (blockNumber << 160) | uint256(uint160(owner));\n _operators[id] = operator;\n }\n emit Approval(owner, operator, id);\n }\n\n /// @dev See setApprovalForAll.\n function _setApprovalForAll(\n address sender,\n address operator,\n bool approved\n ) internal {\n _operatorsForAll[sender][operator] = approved;\n\n emit ApprovalForAll(sender, operator, approved);\n }\n\n /// @dev Check if receiving contract accepts erc721 transfers.\n /// @param operator The address of the operator.\n /// @param from The from address, may be different from msg.sender.\n /// @param to The adddress we want to transfer to.\n /// @param id The id of the token we would like to transfer.\n /// @param _data Any additional data to send with the transfer.\n /// @return Whether the expected value of 0x150b7a02 is returned.\n function _checkOnERC721Received(\n address operator,\n address from,\n address to,\n uint256 id,\n bytes memory _data\n ) internal returns (bool) {\n bytes4 retval = IERC721Receiver(to).onERC721Received(operator, from, id, _data);\n return (retval == ERC721_RECEIVED);\n }\n\n /// @dev See ownerOf\n function _ownerOf(uint256 id) internal view returns (address owner) {\n return address(uint160(_owners[id]));\n }\n\n /// @dev Get the owner and operatorEnabled status of a token.\n /// @param id The token to query.\n /// @return owner The owner of the token.\n /// @return operatorEnabled Whether or not operators are enabled for this token.\n function _ownerAndOperatorEnabledOf(uint256 id) internal view returns (address owner, bool operatorEnabled) {\n uint256 data = _owners[id];\n owner = address(uint160(data));\n operatorEnabled = (data & OPERATOR_FLAG) == OPERATOR_FLAG;\n }\n\n // @dev Get the owner and operatorEnabled status of a token.\n /// @param id The token to query.\n /// @return owner The owner of the token.\n /// @return blockNumber the blockNumber at which the owner became the owner (last transfer).\n function _ownerAndBlockNumberOf(uint256 id) internal view returns (address owner, uint256 blockNumber) {\n uint256 data = _owners[id];\n owner = address(uint160(data));\n blockNumber = (data >> 160) & 0xFFFFFFFFFFFFFFFFFFFFFF;\n }\n\n // from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/Multicall.sol\n /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed.\n /// @dev The `msg.value` should not be trusted for any method callable from multicall.\n /// @param data The encoded function data for each of the calls to make to this contract.\n /// @return results The results from each of the calls passed in via data.\n function multicall(bytes[] calldata data) public payable returns (bytes[] memory results) {\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n\n if (!success) {\n // Next 5 lines from https://ethereum.stackexchange.com/a/83577\n if (result.length < 68) revert();\n assembly {\n result := add(result, 0x04)\n }\n revert(abi.decode(result, (string)));\n }\n\n results[i] = result;\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" + }, + "src/base/IERC4494.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\ninterface IERC4494 {\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /// @notice Allows to retrieve current nonce for token\n /// @param tokenId token id\n /// @return current token nonce\n function nonces(uint256 tokenId) external view returns (uint256);\n\n /// @notice function to be called by anyone to approve `spender` using a Permit signature\n /// @dev Anyone can call this to approve `spender`, even a third-party\n /// @param spender the actor to approve\n /// @param tokenId the token id\n /// @param deadline the deadline for the permit to be used\n /// @param signature permit\n function permit(\n address spender,\n uint256 tokenId,\n uint256 deadline,\n bytes memory signature\n ) external;\n}\n\ninterface IERC4494Alternative {\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /// @notice Allows to retrieve current nonce for token\n /// @param tokenId token id\n /// @return current token nonce\n function tokenNonces(uint256 tokenId) external view returns (uint256);\n\n /// @notice function to be called by anyone to approve `spender` using a Permit signature\n /// @dev Anyone can call this to approve `spender`, even a third-party\n /// @param spender the actor to approve\n /// @param tokenId the token id\n /// @param deadline the deadline for the permit to be used\n /// @param signature permit\n function permit(\n address spender,\n uint256 tokenId,\n uint256 deadline,\n bytes memory signature\n ) external;\n}\n" + }, + "src/bleeps/BleepsRoles.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface ReverseRegistrar {\n function setName(string memory name) external returns (bytes32);\n}\n\ninterface ENS {\n function owner(bytes32 node) external view returns (address);\n}\n\ncontract BleepsRoles {\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n event TokenURIAdminSet(address newTokenURIAdmin);\n event RoyaltyAdminSet(address newRoyaltyAdmin);\n event MinterAdminSet(address newMinterAdmin);\n event GuardianSet(address newGuardian);\n event MinterSet(address newMinter);\n\n bytes32 internal constant ADDR_REVERSE_NODE = 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2;\n ENS internal immutable _ens;\n\n ///@notice the address of the current owner, that is able to set ENS names and withdraw ERC20 owned by the contract.\n address public owner;\n\n /// @notice tokenURIAdmin can update the tokenURI contract, this is intended to be relinquished once the tokenURI has been heavily tested in the wild and that no modification are needed.\n address public tokenURIAdmin;\n\n /// @notice address allowed to set royalty parameters\n address public royaltyAdmin;\n\n /// @notice minterAdmin can update the minter. At the time being there is 576 Bleeps but there is space for extra instrument and the upper limit is 1024.\n /// could be given to the DAO later so instrument can be added, the sale of these new bleeps could benenfit the DAO too and add new members.\n address public minterAdmin;\n\n /// @notice address allowed to mint, allow the sale contract to be separated from the token contract that can focus on the core logic\n /// Once all 1024 potential bleeps (there could be less, at minimum there are 576 bleeps) are minted, no minter can mint anymore\n address public minter;\n\n /// @notice guardian has some special vetoing power to guide the direction of the DAO. It can only remove rights from the DAO. It could be used to immortalize rules.\n /// For example: the royalty setup could be frozen.\n address public guardian;\n\n constructor(\n address ens,\n address initialOwner,\n address initialTokenURIAdmin,\n address initialMinterAdmin,\n address initialRoyaltyAdmin,\n address initialGuardian\n ) {\n _ens = ENS(ens);\n owner = initialOwner;\n tokenURIAdmin = initialTokenURIAdmin;\n royaltyAdmin = initialRoyaltyAdmin;\n minterAdmin = initialMinterAdmin;\n guardian = initialGuardian;\n emit OwnershipTransferred(address(0), initialOwner);\n emit TokenURIAdminSet(initialTokenURIAdmin);\n emit RoyaltyAdminSet(initialRoyaltyAdmin);\n emit MinterAdminSet(initialMinterAdmin);\n emit GuardianSet(initialGuardian);\n }\n\n function setENSName(string memory name) external {\n require(msg.sender == owner, \"NOT_AUTHORIZED\");\n ReverseRegistrar reverseRegistrar = ReverseRegistrar(_ens.owner(ADDR_REVERSE_NODE));\n reverseRegistrar.setName(name);\n }\n\n function withdrawERC20(IERC20 token, address to) external {\n require(msg.sender == owner, \"NOT_AUTHORIZED\");\n token.transfer(to, token.balanceOf(address(this)));\n }\n\n /**\n * @notice Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) external {\n address oldOwner = owner;\n require(msg.sender == oldOwner);\n owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @notice set the new tokenURIAdmin that can change the tokenURI\n * Can only be called by the current tokenURI admin.\n */\n function setTokenURIAdmin(address newTokenURIAdmin) external {\n require(\n msg.sender == tokenURIAdmin || (msg.sender == guardian && newTokenURIAdmin == address(0)),\n \"NOT_AUTHORIZED\"\n );\n tokenURIAdmin = newTokenURIAdmin;\n emit TokenURIAdminSet(newTokenURIAdmin);\n }\n\n /**\n * @notice set the new royaltyAdmin that can change the royalties\n * Can only be called by the current royalty admin.\n */\n function setRoyaltyAdmin(address newRoyaltyAdmin) external {\n require(\n msg.sender == royaltyAdmin || (msg.sender == guardian && newRoyaltyAdmin == address(0)),\n \"NOT_AUTHORIZED\"\n );\n royaltyAdmin = newRoyaltyAdmin;\n emit RoyaltyAdminSet(newRoyaltyAdmin);\n }\n\n /**\n * @notice set the new minterAdmin that can set the minter for Bleeps\n * Can only be called by the current minter admin.\n */\n function setMinterAdmin(address newMinterAdmin) external {\n require(\n msg.sender == minterAdmin || (msg.sender == guardian && newMinterAdmin == address(0)),\n \"NOT_AUTHORIZED\"\n );\n minterAdmin = newMinterAdmin;\n emit MinterAdminSet(newMinterAdmin);\n }\n\n /**\n * @notice set the new guardian that can freeze the other admins (except owner).\n * Can only be called by the current guardian.\n */\n function setGuardian(address newGuardian) external {\n require(msg.sender == guardian, \"NOT_AUTHORIZED\");\n guardian = newGuardian;\n emit GuardianSet(newGuardian);\n }\n\n /**\n * @notice set the new minter that can mint Bleeps (up to 1024).\n * Can only be called by the minter admin.\n */\n function setMinter(address newMinter) external {\n require(msg.sender == minterAdmin, \"NOT_AUTHORIZED\");\n minter = newMinter;\n emit MinterSet(newMinter);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "src/interfaces/ITokenURI.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\ninterface ITokenURI {\n function tokenURI(uint256 id) external view returns (string memory);\n\n function contractURI(address receiver, uint96 per10Thousands) external view returns (string memory);\n}\n" + }, + "src/base/WithSupportForOpenSeaProxies.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\ncontract OwnableDelegateProxy {}\n\ncontract ProxyRegistry {\n mapping(address => OwnableDelegateProxy) public proxies;\n}\n\nabstract contract WithSupportForOpenSeaProxies {\n address internal immutable _proxyRegistryAddress;\n\n constructor(address proxyRegistryAddress) {\n _proxyRegistryAddress = proxyRegistryAddress;\n }\n\n function _isOpenSeaProxy(address owner, address operator) internal view returns (bool) {\n if (_proxyRegistryAddress == address(0)) {\n return false;\n }\n // Whitelist OpenSea proxy contract for easy trading.\n ProxyRegistry proxyRegistry = ProxyRegistry(_proxyRegistryAddress);\n return address(proxyRegistry.proxies(owner)) == operator;\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC1271.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n *\n * _Available since v4.1._\n */\ninterface IERC1271 {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param hash Hash of the data to be signed\n * @param signature Signature byte array associated with _data\n */\n function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n" + }, + "src/bleeps/Bleeps.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./BleepsRoles.sol\";\nimport \"../base/ERC721Checkpointable.sol\";\n\nimport \"../interfaces/ITokenURI.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nimport \"../base/WithSupportForOpenSeaProxies.sol\";\n\ncontract Bleeps is IERC721, WithSupportForOpenSeaProxies, ERC721Checkpointable, BleepsRoles {\n event RoyaltySet(address receiver, uint256 royaltyPer10Thousands);\n event TokenURIContractSet(ITokenURI newTokenURIContract);\n event CheckpointingDisablerSet(address newCheckpointingDisabler);\n event CheckpointingDisabled();\n\n /// @notice the contract that actually generate the sound (and all metadata via the a data: uri via tokenURI call).\n ITokenURI public tokenURIContract;\n\n struct Royalty {\n address receiver;\n uint96 per10Thousands;\n }\n\n Royalty internal _royalty;\n\n /// @dev address that is able to switch off the use of checkpointing, this will make token transfers much cheaper in term of gas, but require the design of a new governance system.\n address public checkpointingDisabler;\n\n /// @dev Create the Bleeps contract\n /// @param ens ENS address for the network the contract is deployed to\n /// @param initialOwner address that can set the ENS name of the contract and that can witthdraw ERC20 tokens sent by mistake here.\n /// @param initialTokenURIAdmin admin able to update the tokenURI contract.\n /// @param initialMinterAdmin admin able to set the minter contract.\n /// @param initialRoyaltyAdmin admin able to update the royalty receiver and rates.\n /// @param initialGuardian guardian able to immortalize rules\n /// @param openseaProxyRegistry allow Bleeps to be sold on opensea without prior approval tx as long as the user have already an opensea proxy.\n /// @param initialRoyaltyReceiver receiver of royalties\n /// @param imitialRoyaltyPer10Thousands amount of royalty in 10,000 basis point\n /// @param initialTokenURIContract initial tokenURI contract that generate the metadata including the wav file.\n /// @param initialCheckpointingDisabler admin able to cancel checkpointing\n constructor(\n address ens,\n address initialOwner,\n address initialTokenURIAdmin,\n address initialMinterAdmin,\n address initialRoyaltyAdmin,\n address initialGuardian,\n address openseaProxyRegistry,\n address initialRoyaltyReceiver,\n uint96 imitialRoyaltyPer10Thousands,\n ITokenURI initialTokenURIContract,\n address initialCheckpointingDisabler\n )\n WithSupportForOpenSeaProxies(openseaProxyRegistry)\n BleepsRoles(ens, initialOwner, initialTokenURIAdmin, initialMinterAdmin, initialRoyaltyAdmin, initialGuardian)\n {\n tokenURIContract = initialTokenURIContract;\n emit TokenURIContractSet(initialTokenURIContract);\n checkpointingDisabler = initialCheckpointingDisabler;\n emit CheckpointingDisablerSet(initialCheckpointingDisabler);\n\n _royalty.receiver = initialRoyaltyReceiver;\n _royalty.per10Thousands = imitialRoyaltyPer10Thousands;\n emit RoyaltySet(initialRoyaltyReceiver, imitialRoyaltyPer10Thousands);\n }\n\n /// @notice A descriptive name for a collection of NFTs in this contract.\n function name() public pure override returns (string memory) {\n return \"Bleeps\";\n }\n\n /// @notice An abbreviated name for NFTs in this contract.\n function symbol() external pure returns (string memory) {\n return \"BLEEP\";\n }\n\n /// @notice Returns the Uniform Resource Identifier (URI) for the token collection.\n function contractURI() external view returns (string memory) {\n return tokenURIContract.contractURI(_royalty.receiver, _royalty.per10Thousands);\n }\n\n /// @notice Returns the Uniform Resource Identifier (URI) for token `id`.\n function tokenURI(uint256 id) external view returns (string memory) {\n return tokenURIContract.tokenURI(id);\n }\n\n /// @notice set a new tokenURI contract, that generate the metadata including the wav file, Can only be set by the `tokenURIAdmin`.\n /// @param newTokenURIContract The address of the new tokenURI contract.\n function setTokenURIContract(ITokenURI newTokenURIContract) external {\n require(msg.sender == tokenURIAdmin, \"NOT_AUTHORIZED\");\n tokenURIContract = newTokenURIContract;\n emit TokenURIContractSet(newTokenURIContract);\n }\n\n /// @notice give the list of owners for the list of ids given.\n /// @param ids The list if token ids to check.\n /// @return addresses The list of addresses, corresponding to the list of ids.\n function owners(uint256[] calldata ids) external view returns (address[] memory addresses) {\n addresses = new address[](ids.length);\n for (uint256 i = 0; i < ids.length; i++) {\n uint256 id = ids[i];\n addresses[i] = address(uint160(_owners[id]));\n }\n }\n\n /// @notice Check if the sender approved the operator.\n /// @param owner The address of the owner.\n /// @param operator The address of the operator.\n /// @return isOperator The status of the approval.\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n override(ERC721Base, IERC721)\n returns (bool isOperator)\n {\n return super.isApprovedForAll(owner, operator) || _isOpenSeaProxy(owner, operator);\n }\n\n /// @notice Check if the contract supports an interface.\n /// @param id The id of the interface.\n /// @return Whether the interface is supported.\n function supportsInterface(bytes4 id)\n public\n pure\n virtual\n override(ERC721BaseWithERC4494Permit, IERC165)\n returns (bool)\n {\n return super.supportsInterface(id) || id == 0x2a55205a; /// 0x2a55205a is ERC2981 (royalty standard)\n }\n\n /// @notice Called with the sale price to determine how much royalty is owed and to whom.\n /// @param id - the token queried for royalty information.\n /// @param salePrice - the sale price of the token specified by id.\n /// @return receiver - address of who should be sent the royalty payment.\n /// @return royaltyAmount - the royalty payment amount for salePrice.\n function royaltyInfo(uint256 id, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount)\n {\n receiver = _royalty.receiver;\n royaltyAmount = (salePrice * uint256(_royalty.per10Thousands)) / 10000;\n }\n\n /// @notice set a new royalty receiver and rate, Can only be set by the `royaltyAdmin`.\n /// @param newReceiver the address that should receive the royalty proceeds.\n /// @param royaltyPer10Thousands the share of the salePrice (in 1/10000) given to the receiver.\n function setRoyaltyParameters(address newReceiver, uint96 royaltyPer10Thousands) external {\n require(msg.sender == royaltyAdmin, \"NOT_AUTHORIZED\");\n // require(royaltyPer10Thousands <= 50, \"ROYALTY_TOO_HIGH\"); ?\n _royalty.receiver = newReceiver;\n _royalty.per10Thousands = royaltyPer10Thousands;\n emit RoyaltySet(newReceiver, royaltyPer10Thousands);\n }\n\n /// @notice disable checkpointing overhead\n /// This can be used if the governance system can switch to use ownerAndLastTransferBlockNumberOf instead of checkpoints\n function disableTheUseOfCheckpoints() external {\n require(msg.sender == checkpointingDisabler, \"NOT_AUTHORIZED\");\n _useCheckpoints = false;\n checkpointingDisabler = address(0);\n emit CheckpointingDisablerSet(address(0));\n emit CheckpointingDisabled();\n }\n\n /// @notice update the address that can disable the use of checkpinting, can be used to disable it entirely.\n /// @param newCheckpointingDisabler new address that can disable the use of checkpointing. can be the zero address to remove the ability to change.\n function setCheckpointingDisabler(address newCheckpointingDisabler) external {\n require(msg.sender == checkpointingDisabler, \"NOT_AUTHORIZED\");\n checkpointingDisabler = newCheckpointingDisabler;\n emit CheckpointingDisablerSet(newCheckpointingDisabler);\n }\n\n /// @notice mint one of bleep if not already minted. Can only be called by `minter`.\n /// @param id bleep id which represent a pair of (note, instrument).\n /// @param to address that will receive the Bleep.\n function mint(uint16 id, address to) external {\n require(msg.sender == minter, \"ONLY_MINTER_ALLOWED\");\n require(id < 1024, \"INVALID_BLEEP\");\n\n require(to != address(0), \"NOT_TO_ZEROADDRESS\");\n require(to != address(this), \"NOT_TO_THIS\");\n address owner = _ownerOf(id);\n require(owner == address(0), \"ALREADY_CREATED\");\n _safeTransferFrom(address(0), to, id, \"\");\n }\n\n /// @notice mint multiple bleeps if not already minted. Can only be called by `minter`.\n /// @param ids list of bleep id which represent each a pair of (note, instrument).\n /// @param tos addresses that will receive the Bleeps. (if only one, use for all)\n function multiMint(uint16[] calldata ids, address[] calldata tos) external {\n require(msg.sender == minter, \"ONLY_MINTER_ALLOWED\");\n\n address to;\n if (tos.length == 1) {\n to = tos[0];\n }\n for (uint256 i = 0; i < ids.length; i++) {\n uint256 id = ids[i];\n if (tos.length > 1) {\n to = tos[i];\n }\n require(to != address(0), \"NOT_TO_ZEROADDRESS\");\n require(to != address(this), \"NOT_TO_THIS\");\n require(id < 1024, \"INVALID_BLEEP\");\n address owner = _ownerOf(id);\n require(owner == address(0), \"ALREADY_CREATED\");\n _safeTransferFrom(address(0), to, id, \"\");\n }\n }\n\n /// @notice gives the note and instrument for a particular Bleep id.\n /// @param id bleep id which represent a pair of (note, instrument).\n /// @return note the note index (0 to 63) starting from C2 to D#7\n /// @return instrument the instrument index (0 to 16). At launch there is only 9 instrument but the DAO could add more (up to 16 in total).\n function sound(uint256 id) external pure returns (uint8 note, uint8 instrument) {\n note = uint8(id & 0x3F);\n instrument = uint8(uint256(id >> 6) & 0x0F);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s;\n uint8 v;\n assembly {\n s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)\n v := add(shr(255, vs), 27)\n }\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\nimport \"../Address.sol\";\nimport \"../../interfaces/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper: Provide a single mechanism to verify both private-key (EOA) ECDSA signature and\n * ERC1271 contract sigantures. Using this instead of ECDSA.recover in your contract will make them compatible with\n * smart contract wallets such as Argent and Gnosis.\n *\n * Note: unlike ECDSA signatures, contract signature's are revocable, and the outcome of this function can thus change\n * through time. It could return true at block N and false at block N+1 (or the opposite).\n *\n * _Available since v4.1._\n */\nlibrary SignatureChecker {\n function isValidSignatureNow(\n address signer,\n bytes32 hash,\n bytes memory signature\n ) internal view returns (bool) {\n (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);\n if (error == ECDSA.RecoverError.NoError && recovered == signer) {\n return true;\n }\n\n (bool success, bytes memory result) = signer.staticcall(\n abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)\n );\n return (success && result.length == 32 && abi.decode(result, (bytes4)) == IERC1271.isValidSignature.selector);\n }\n}\n" + }, + "src/base/ERC721BaseWithERC4494Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"./ERC721Base.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol\";\nimport \"./IERC4494.sol\";\n\nabstract contract ERC721BaseWithERC4494Permit is ERC721Base {\n using Address for address;\n\n bytes32 public constant PERMIT_TYPEHASH =\n keccak256(\"Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)\");\n bytes32 public constant PERMIT_FOR_ALL_TYPEHASH =\n keccak256(\"PermitForAll(address spender,uint256 nonce,uint256 deadline)\");\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n uint256 private immutable _deploymentChainId;\n bytes32 private immutable _deploymentDomainSeparator;\n\n mapping(address => uint256) internal _userNonces;\n\n constructor() {\n uint256 chainId;\n //solhint-disable-next-line no-inline-assembly\n assembly {\n chainId := chainid()\n }\n _deploymentChainId = chainId;\n _deploymentDomainSeparator = _calculateDomainSeparator(chainId);\n }\n\n /// @dev Return the DOMAIN_SEPARATOR.\n function DOMAIN_SEPARATOR() external view returns (bytes32) {\n return _DOMAIN_SEPARATOR();\n }\n\n /// @notice return the account nonce, used for approvalForAll permit or other account related matter\n /// @param account the account to query\n /// @return nonce\n function nonces(address account) external view virtual returns (uint256 nonce) {\n return _userNonces[account];\n }\n\n /// @notice return the token nonce, used for individual approve permit or other token related matter\n /// @param id token id to query\n /// @return nonce\n function nonces(uint256 id) public view virtual returns (uint256 nonce) {\n (address owner, uint256 blockNumber) = _ownerAndBlockNumberOf(id);\n require(owner != address(0), \"NONEXISTENT_TOKEN\");\n return blockNumber;\n }\n\n /// @notice return the token nonce, used for individual approve permit or other token related matter\n /// @param id token id to query\n /// @return nonce\n function tokenNonces(uint256 id) external view returns (uint256 nonce) {\n return nonces(id);\n }\n\n function permit(\n address spender,\n uint256 tokenId,\n uint256 deadline,\n bytes memory sig\n ) external {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n (address owner, uint256 blockNumber) = _ownerAndBlockNumberOf(tokenId);\n require(owner != address(0), \"NONEXISTENT_TOKEN\");\n\n // We use blockNumber as nonce as we already store it per tokens. It can thus act as an increasing transfer counter.\n // while technically multiple transfer could happen in the same block, the signed message would be using a previous block.\n // And the transfer would use then a more recent blockNumber, invalidating that message when transfer is executed.\n _requireValidPermit(owner, spender, tokenId, deadline, blockNumber, sig);\n\n _approveFor(owner, blockNumber, spender, tokenId);\n }\n\n function permitForAll(\n address signer,\n address spender,\n uint256 deadline,\n bytes memory sig\n ) external {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n _requireValidPermitForAll(signer, spender, deadline, _userNonces[signer]++, sig);\n\n _setApprovalForAll(signer, spender, true);\n }\n\n /// @notice Check if the contract supports an interface.\n /// @param id The id of the interface.\n /// @return Whether the interface is supported.\n function supportsInterface(bytes4 id) public pure virtual override returns (bool) {\n return\n super.supportsInterface(id) ||\n id == type(IERC4494).interfaceId ||\n id == type(IERC4494Alternative).interfaceId;\n }\n\n // -------------------------------------------------------- INTERNAL --------------------------------------------------------------------\n\n function _requireValidPermit(\n address signer,\n address spender,\n uint256 id,\n uint256 deadline,\n uint256 nonce,\n bytes memory sig\n ) internal view {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n _DOMAIN_SEPARATOR(),\n keccak256(abi.encode(PERMIT_TYPEHASH, spender, id, nonce, deadline))\n )\n );\n require(SignatureChecker.isValidSignatureNow(signer, digest, sig), \"INVALID_SIGNATURE\");\n }\n\n function _requireValidPermitForAll(\n address signer,\n address spender,\n uint256 deadline,\n uint256 nonce,\n bytes memory sig\n ) internal view {\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n _DOMAIN_SEPARATOR(),\n keccak256(abi.encode(PERMIT_FOR_ALL_TYPEHASH, spender, nonce, deadline))\n )\n );\n require(SignatureChecker.isValidSignatureNow(signer, digest, sig), \"INVALID_SIGNATURE\");\n }\n\n /// @dev Return the DOMAIN_SEPARATOR.\n function _DOMAIN_SEPARATOR() internal view returns (bytes32) {\n uint256 chainId;\n //solhint-disable-next-line no-inline-assembly\n assembly {\n chainId := chainid()\n }\n\n // in case a fork happen, to support the chain that had to change its chainId,, we compute the domain operator\n return chainId == _deploymentChainId ? _deploymentDomainSeparator : _calculateDomainSeparator(chainId);\n }\n\n /// @dev Calculate the DOMAIN_SEPARATOR.\n function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), chainId, address(this)));\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + } + }, + "settings": { + "evmVersion": "london", + "libraries": {}, + "metadata": { + "bytecodeHash": "ipfs", + "useLiteralContent": true + }, + "optimizer": { + "enabled": true, + "runs": 999999 + }, + "remappings": [], + "outputSelection": { + "*": { + "*": [ + "evm.bytecode", + "evm.deployedBytecode", + "devdoc", + "userdoc", + "metadata", + "abi" + ] + } + } + } + }, + "ABI": "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ens\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialOwner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialTokenURIAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialMinterAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialRoyaltyAdmin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialGuardian\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"openseaProxyRegistry\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialRoyaltyReceiver\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"imitialRoyaltyPer10Thousands\",\"type\":\"uint96\"},{\"internalType\":\"contract ITokenURI\",\"name\":\"initialTokenURIContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialCheckpointingDisabler\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"CheckpointingDisabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newCheckpointingDisabler\",\"type\":\"address\"}],\"name\":\"CheckpointingDisablerSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGuardian\",\"type\":\"address\"}],\"name\":\"GuardianSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newMinterAdmin\",\"type\":\"address\"}],\"name\":\"MinterAdminSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newMinter\",\"type\":\"address\"}],\"name\":\"MinterSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newRoyaltyAdmin\",\"type\":\"address\"}],\"name\":\"RoyaltyAdminSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"royaltyPer10Thousands\",\"type\":\"uint256\"}],\"name\":\"RoyaltySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newTokenURIAdmin\",\"type\":\"address\"}],\"name\":\"TokenURIAdminSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contract ITokenURI\",\"name\":\"newTokenURIContract\",\"type\":\"address\"}],\"name\":\"TokenURIContractSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DELEGATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_FOR_ALL_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"checkpointingDisabler\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"fromBlock\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"delegateBySig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"disableTheUseOfCheckpoints\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getCurrentVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPriorVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"guardian\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"isOperator\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"id\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minterAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16[]\",\"name\":\"ids\",\"type\":\"uint16[]\"},{\"internalType\":\"address[]\",\"name\":\"tos\",\"type\":\"address[]\"}],\"name\":\"multiMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"multicall\",\"outputs\":[{\"internalType\":\"bytes[]\",\"name\":\"results\",\"type\":\"bytes[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"ownerAndLastTransferBlockNumberList\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"lastTransferBlockNumber\",\"type\":\"uint256\"}],\"internalType\":\"struct ERC721Base.OwnerData[]\",\"name\":\"ownersData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"owners\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"addresses\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"permitForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"royaltyAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"salePrice\",\"type\":\"uint256\"}],\"name\":\"royaltyInfo\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"royaltyAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newCheckpointingDisabler\",\"type\":\"address\"}],\"name\":\"setCheckpointingDisabler\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"setENSName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newGuardian\",\"type\":\"address\"}],\"name\":\"setGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newMinter\",\"type\":\"address\"}],\"name\":\"setMinter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newMinterAdmin\",\"type\":\"address\"}],\"name\":\"setMinterAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newRoyaltyAdmin\",\"type\":\"address\"}],\"name\":\"setRoyaltyAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newReceiver\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"royaltyPer10Thousands\",\"type\":\"uint96\"}],\"name\":\"setRoyaltyParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newTokenURIAdmin\",\"type\":\"address\"}],\"name\":\"setTokenURIAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ITokenURI\",\"name\":\"newTokenURIContract\",\"type\":\"address\"}],\"name\":\"setTokenURIContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"sound\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"note\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"instrument\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"id\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"tokenNonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tokenURIAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tokenURIContract\",\"outputs\":[{\"internalType\":\"contract ITokenURI\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"}],\"name\":\"votesToDelegate\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"withdrawERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + "ContractName": "Bleeps", + "CompilerVersion": "v0.8.9+commit.e5eed63a", + "OptimizationUsed": 1, + "Runs": 999999, + "ConstructorArguments": "0x00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e0000000000000000000000007773ae67403d2e30102a84c48cc939919c4c881c000000000000000000000000dca9d1fa839bb9fe65ddc4de5161bca43751d4b40000000000000000000000007773ae67403d2e30102a84c48cc939919c4c881c000000000000000000000000dca9d1fa839bb9fe65ddc4de5161bca43751d4b4000000000000000000000000dca9d1fa839bb9fe65ddc4de5161bca43751d4b4000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c10000000000000000000000008350c9989ef11325b36ce6f7549004d418dbcee700000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000e114dce59a333f8d351371f54188f92c287b73e6000000000000000000000000dca9d1fa839bb9fe65ddc4de5161bca43751d4b4", + "EVMVersion": "Default", + "Library": "", + "LicenseType": "MIT", + "Proxy": 0, + "SwarmSource": "" + } +] \ No newline at end of file From ecd637373b557d8df95dc20b8b7ce1dccff988cf Mon Sep 17 00:00:00 2001 From: "Du, Chengbin" Date: Mon, 22 Apr 2024 17:34:10 +0800 Subject: [PATCH 0889/1963] chore(deps): update yansi to v1.0 (#7735) * chore(deps): update yansi to v1.0 * move yansi to workspace deps * move yansi to workspace deps * adjustments --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 27 +++++----- Cargo.toml | 3 +- crates/anvil/Cargo.toml | 2 +- crates/anvil/src/config.rs | 23 ++++---- crates/cast/Cargo.toml | 2 +- crates/cast/bin/cmd/wallet/mod.rs | 4 +- crates/chisel/Cargo.toml | 2 +- crates/chisel/bin/main.rs | 29 +++++----- crates/chisel/src/dispatcher.rs | 32 +++++------ crates/chisel/src/executor.rs | 80 ++++++++++++++-------------- crates/chisel/src/session_source.rs | 13 ++--- crates/chisel/src/solidity_helper.rs | 32 ++++++----- crates/cli/Cargo.toml | 2 +- crates/cli/src/handler.rs | 2 +- crates/cli/src/utils/cmd.rs | 6 +-- crates/cli/src/utils/mod.rs | 12 +---- crates/common/Cargo.toml | 2 +- crates/common/src/fmt/mod.rs | 8 +-- crates/common/src/term.rs | 8 +-- crates/evm/traces/Cargo.toml | 2 +- crates/evm/traces/src/lib.rs | 20 +++---- crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/coverage.rs | 4 +- crates/forge/bin/cmd/fmt.rs | 16 +++--- crates/forge/bin/cmd/geiger/find.rs | 13 ++--- crates/forge/bin/cmd/geiger/mod.rs | 2 +- crates/forge/bin/cmd/generate/mod.rs | 2 +- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/install.rs | 6 +-- crates/forge/bin/cmd/snapshot.rs | 8 +-- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/gas_report.rs | 3 +- crates/forge/src/result.rs | 24 ++++----- crates/script/Cargo.toml | 2 +- crates/script/src/execute.rs | 8 ++- crates/script/src/lib.rs | 4 +- crates/script/src/runner.rs | 2 +- crates/script/src/sequence.rs | 5 +- crates/verify/Cargo.toml | 2 +- crates/verify/src/bytecode.rs | 17 +++--- 40 files changed, 210 insertions(+), 225 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a52ff0b62ad10..1ba16aacc1242 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -725,7 +725,7 @@ dependencies = [ "tracing", "tracing-subscriber", "vergen", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -1821,7 +1821,7 @@ dependencies = [ "tokio", "tracing", "vergen", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -1897,7 +1897,7 @@ dependencies = [ "tracing", "tracing-subscriber", "vergen", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -3534,7 +3534,7 @@ dependencies = [ "tracing-subscriber", "vergen", "watchexec", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -3618,7 +3618,7 @@ dependencies = [ "serde_json", "tempfile", "tracing", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -3651,7 +3651,7 @@ dependencies = [ "tempfile", "tokio", "tracing", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -3764,7 +3764,7 @@ dependencies = [ "tracing", "tracing-error", "tracing-subscriber", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -3820,14 +3820,14 @@ dependencies = [ "tracing", "url", "walkdir", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] name = "foundry-compilers" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8caca67f174741b05c2f4188d3ee93420342130eb2a768abb9b885bb8b918df2" +checksum = "10a73252c7753488cf7779e2788e05088b3b3d9198fbbc5d4da94b5afd0f751d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3857,7 +3857,7 @@ dependencies = [ "tokio", "tracing", "walkdir", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -4042,7 +4042,7 @@ dependencies = [ "tempfile", "tokio", "tracing", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -9459,6 +9459,9 @@ name = "yansi" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +dependencies = [ + "is-terminal", +] [[package]] name = "zerocopy" diff --git a/Cargo.toml b/Cargo.toml index 2859b9349afee..d14288a38fd87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,7 +138,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.6", default-features = false } -foundry-compilers = { version = "0.3.17", default-features = false } +foundry-compilers = { version = "0.3.18", default-features = false } ## revm # no default features to avoid c-kzg @@ -214,6 +214,7 @@ vergen = { version = "8", default-features = false } indexmap = "2.2" tikv-jemallocator = "0.5.4" num-format = "0.4.4" +yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } axum = "0.7" hyper = "1.0" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 7930d437a0ea1..b7619eb5ac3fa 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -70,7 +70,7 @@ serde_repr = "0.1" serde_json.workspace = true serde.workspace = true thiserror = "1" -yansi = "0.5" +yansi.workspace = true tempfile = "3" itertools.workspace = true rand = "0.8" diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 7c35f0c9d7c93..883e1dd449214 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -182,13 +182,9 @@ pub struct NodeConfig { impl NodeConfig { fn as_string(&self, fork: Option<&ClientFork>) -> String { let mut config_string: String = String::new(); - let _ = write!(config_string, "\n{}", Paint::green(BANNER)); + let _ = write!(config_string, "\n{}", BANNER.green()); let _ = write!(config_string, "\n {VERSION_MESSAGE}"); - let _ = write!( - config_string, - "\n {}", - Paint::green("https://github.com/foundry-rs/foundry") - ); + let _ = write!(config_string, "\n {}", "https://github.com/foundry-rs/foundry".green()); let _ = write!( config_string, @@ -256,9 +252,10 @@ Chain ID: {} Chain ID ================== + {} "#, - Paint::green(format!("\n{}", self.get_chain_id())) + self.get_chain_id().green() ); } @@ -268,9 +265,10 @@ Chain ID r#" Gas Price ================== + {} "#, - Paint::green(format!("\n{}", self.get_gas_price())) + self.get_gas_price().green() ); } else { let _ = write!( @@ -278,9 +276,10 @@ Gas Price r#" Base Fee ================== + {} "#, - Paint::green(format!("\n{}", self.get_base_fee())) + self.get_base_fee().green() ); } @@ -289,9 +288,10 @@ Base Fee r#" Gas Limit ================== + {} "#, - Paint::green(format!("\n{}", self.gas_limit)) + self.gas_limit.green() ); let _ = write!( @@ -299,9 +299,10 @@ Gas Limit r#" Genesis Timestamp ================== + {} "#, - Paint::green(format!("\n{}", self.get_genesis_timestamp())) + self.get_genesis_timestamp().green() ); config_string diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 04160fa3ffeb3..e96737ce578e6 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -78,7 +78,7 @@ semver = "1" tempfile = "3" tokio = { version = "1", features = ["macros", "signal"] } tracing.workspace = true -yansi = "0.5" +yansi.workspace = true evmole = "0.3.1" [target.'cfg(unix)'.dependencies] diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 60e21a2fb7327..1ac943204e112 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -236,7 +236,7 @@ impl WalletSubcommands { let wallets = wallets.into_iter().map(|b| b.build()).collect::, _>>()?; - println!("{}", Paint::green("Successfully generated a new mnemonic.")); + println!("{}", "Successfully generated a new mnemonic.".green()); println!("Phrase:\n{phrase}"); println!("\nAccounts:"); for (i, wallet) in wallets.iter().enumerate() { @@ -347,7 +347,7 @@ flag to set your key via: "`{}` keystore was saved successfully. Address: {:?}", &account_name, address, ); - println!("{}", Paint::green(success_message)); + println!("{}", success_message.green()); } WalletSubcommands::List(cmd) => { cmd.run().await?; diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 9d07ae80019a1..05ad5aefc8b16 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -47,7 +47,7 @@ solang-parser.workspace = true strum = { workspace = true, features = ["derive"] } time = { version = "0.3", features = ["formatting"] } tokio = { version = "1", features = ["full"] } -yansi = "0.5" +yansi.workspace = true tracing.workspace = true [target.'cfg(unix)'.dependencies] diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 0cca09bf98735..706c6af99e08b 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -98,11 +98,6 @@ pub enum ChiselSubcommand { async fn main() -> eyre::Result<()> { handler::install(); utils::subscriber(); - #[cfg(windows)] - if !Paint::enable_windows_ascii() { - Paint::disable() - } - utils::load_dotenv(); // Parse command args @@ -165,7 +160,7 @@ async fn main() -> eyre::Result<()> { } Some(ChiselSubcommand::ClearCache) => { match dispatcher.dispatch_command(ChiselCommand::ClearCache, &[]).await { - DispatchResult::CommandSuccess(Some(msg)) => println!("{}", Paint::green(msg)), + DispatchResult::CommandSuccess(Some(msg)) => println!("{}", msg.green()), DispatchResult::CommandFailed(e) => eprintln!("{e}"), _ => panic!("Unexpected result! Please report this bug."), } @@ -187,7 +182,7 @@ async fn main() -> eyre::Result<()> { } // Print welcome header - println!("Welcome to Chisel! Type `{}` to show available commands.", Paint::green("!help")); + println!("Welcome to Chisel! Type `{}` to show available commands.", "!help".green()); // Begin Rustyline loop loop { @@ -250,17 +245,17 @@ async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) -> bo DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => { debug!(%line, ?msg, "dispatch success"); if let Some(msg) = msg { - println!("{}", Paint::green(msg)); + println!("{}", msg.green()); } }, DispatchResult::UnrecognizedCommand(e) => eprintln!("{e}"), DispatchResult::SolangParserFailed(e) => { - eprintln!("{}", Paint::red("Compilation error")); - eprintln!("{}", Paint::red(format!("{e:?}"))); + eprintln!("{}", "Compilation error".red()); + eprintln!("{}", format!("{e:?}").red()); } - DispatchResult::FileIoError(e) => eprintln!("{}", Paint::red(format!("⚒️ Chisel File IO Error - {e}"))), - DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => eprintln!("{}", Paint::red(msg)), - DispatchResult::Failure(None) => eprintln!("{}\nPlease Report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose", Paint::red("⚒️ Unknown Chisel Error ⚒️")), + DispatchResult::FileIoError(e) => eprintln!("{}", format!("⚒️ Chisel File IO Error - {e}").red()), + DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => eprintln!("{}", msg.red()), + DispatchResult::Failure(None) => eprintln!("{}\nPlease Report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose", "⚒️ Unknown Chisel Error ⚒️".red()), } r.is_error() } @@ -273,19 +268,19 @@ async fn evaluate_prelude( ) -> eyre::Result<()> { let Some(prelude_dir) = maybe_prelude else { return Ok(()) }; if prelude_dir.is_file() { - println!("{} {}", Paint::yellow("Loading prelude source file:"), prelude_dir.display(),); + println!("{} {}", "Loading prelude source file:".yellow(), prelude_dir.display(),); load_prelude_file(dispatcher, prelude_dir).await?; - println!("{}\n", Paint::green("Prelude source file loaded successfully!")); + println!("{}\n", "Prelude source file loaded successfully!".green()); } else { let prelude_sources = fs::files_with_ext(prelude_dir, "sol"); let print_success_msg = !prelude_sources.is_empty(); for source_file in prelude_sources { - println!("{} {}", Paint::yellow("Loading prelude source file:"), source_file.display(),); + println!("{} {}", "Loading prelude source file:".yellow(), source_file.display(),); load_prelude_file(dispatcher, source_file).await?; } if print_success_msg { - println!("{}\n", Paint::green("All prelude source files loaded successfully!")); + println!("{}\n", "All prelude source files loaded successfully!".green()); } } Ok(()) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index cba66f7aa4f70..ebf4aeb3765ef 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -195,7 +195,7 @@ impl ChiselDispatcher { ChiselCommand::iter().map(CmdDescriptor::from).collect::>(); DispatchResult::CommandSuccess(Some(format!( "{}\n{}", - Paint::cyan(format!("{CHISEL_CHAR} Chisel help\n=============")), + format!("{CHISEL_CHAR} Chisel help\n=============").cyan(), CmdCategory::iter() .map(|cat| { // Get commands in the current category @@ -209,13 +209,13 @@ impl ChiselDispatcher { // Format the help menu for the current category format!( "{}\n{}\n", - Paint::magenta(cat), + cat.magenta(), cat_cmds .iter() .map(|(cmds, desc, _)| format!( "\t{} - {}", cmds.iter() - .map(|cmd| format!("!{}", Paint::green(cmd))) + .map(|cmd| format!("!{}", cmd.green())) .collect::>() .join(" | "), desc @@ -274,7 +274,7 @@ impl ChiselDispatcher { if let Err(e) = self.session.write() { return DispatchResult::FileIoError(e.into()) } - println!("{}", Paint::green("Saved current session!")); + println!("{}", "Saved current session!".green()); } // Parse the arguments @@ -304,11 +304,11 @@ impl ChiselDispatcher { ChiselCommand::ListSessions => match ChiselSession::list_sessions() { Ok(sessions) => DispatchResult::CommandSuccess(Some(format!( "{}\n{}", - Paint::cyan(format!("{CHISEL_CHAR} Chisel Sessions")), + format!("{CHISEL_CHAR} Chisel Sessions").cyan(), sessions .iter() .map(|(time, name)| { - format!("{} - {}", Paint::blue(format!("{time:?}")), name) + format!("{} - {}", format!("{time:?}").blue(), name) }) .collect::>() .join("\n") @@ -372,7 +372,7 @@ impl ChiselDispatcher { } // Create success message before moving the fork_url - let success_msg = format!("Set fork URL to {}", Paint::yellow(&fork_url)); + let success_msg = format!("Set fork URL to {}", &fork_url.yellow()); // Update the fork_url inside of the [SessionSourceConfig]'s [EvmOpts] // field @@ -410,7 +410,7 @@ impl ChiselDispatcher { self.source_mut().config.calldata = Some(calldata); DispatchResult::CommandSuccess(Some(format!( "Set calldata to '{}'", - Paint::yellow(arg) + arg.yellow() ))) } Err(e) => DispatchResult::CommandFailed(Self::make_error(format!( @@ -428,8 +428,8 @@ impl ChiselDispatcher { (0..mem.len()).step_by(32).for_each(|i| { println!( "{}: {}", - Paint::yellow(format!("[0x{:02x}:0x{:02x}]", i, i + 32)), - Paint::cyan(hex::encode_prefixed(&mem[i..i + 32])) + format!("[0x{:02x}:0x{:02x}]", i, i + 32).yellow(), + hex::encode_prefixed(&mem[i..i + 32]).cyan() ); }); } else { @@ -437,8 +437,8 @@ impl ChiselDispatcher { (0..stack.len()).rev().for_each(|i| { println!( "{}: {}", - Paint::yellow(format!("[{}]", stack.len() - i - 1)), - Paint::cyan(format!("0x{:02x}", stack[i])) + format!("[{}]", stack.len() - i - 1).yellow(), + format!("0x{:02x}", stack[i]).cyan() ); }); } @@ -698,7 +698,7 @@ impl ChiselDispatcher { // Show console logs, if there are any let decoded_logs = decode_console_logs(&res.logs); if !decoded_logs.is_empty() { - println!("{}", Paint::green("Logs:")); + println!("{}", "Logs:".green()); for log in decoded_logs { println!(" {log}"); } @@ -842,7 +842,7 @@ impl ChiselDispatcher { // Show console logs, if there are any let decoded_logs = decode_console_logs(&res.logs); if !decoded_logs.is_empty() { - println!("{}", Paint::green("Logs:")); + println!("{}", "Logs:".green()); for log in decoded_logs { println!(" {log}"); } @@ -931,7 +931,7 @@ impl ChiselDispatcher { eyre::bail!("Unexpected error: No traces gathered. Please report this as a bug: https://github.com/foundry-rs/foundry/issues/new?assignees=&labels=T-bug&template=BUG-FORM.yml"); } - println!("{}", Paint::green("Traces:")); + println!("{}", "Traces:".green()); for (kind, trace) in &result.traces { // Display all Setup + Execution traces. if matches!(kind, TraceKind::Setup | TraceKind::Execution) { @@ -952,7 +952,7 @@ impl ChiselDispatcher { /// /// A formatted error [String]. pub fn make_error(msg: T) -> String { - format!("{} {}", Paint::red(format!("{CHISEL_CHAR} Chisel Error:")), Paint::red(msg)) + format!("{} {}", format!("{CHISEL_CHAR} Chisel Error:").red(), msg.red()) } } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 6343013b18bab..424bcda901d7f 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -194,7 +194,7 @@ impl SessionSource { } let decoded_logs = decode_console_logs(&res.logs); if !decoded_logs.is_empty() { - println!("{}", Paint::green("Logs:")); + println!("{}", "Logs:".green()); for log in decoded_logs { println!(" {log}"); } @@ -337,20 +337,20 @@ impl SessionSource { fn format_token(token: DynSolValue) -> String { match token { DynSolValue::Address(a) => { - format!("Type: {}\n└ Data: {}", Paint::red("address"), Paint::cyan(a.to_string())) + format!("Type: {}\n└ Data: {}", "address".red(), a.cyan()) } DynSolValue::FixedBytes(b, byte_len) => { format!( "Type: {}\n└ Data: {}", - Paint::red(format!("bytes{byte_len}")), - Paint::cyan(hex::encode_prefixed(b)) + format!("bytes{byte_len}").red(), + hex::encode_prefixed(b).cyan() ) } DynSolValue::Int(i, bit_len) => { format!( "Type: {}\n├ Hex: {}\n├ Hex (full word): {}\n└ Decimal: {}", - Paint::red(format!("int{}", bit_len)), - Paint::cyan(format!( + format!("int{}", bit_len).red(), + format!( "0x{}", format!("{i:x}") .char_indices() @@ -358,16 +358,17 @@ fn format_token(token: DynSolValue) -> String { .take(bit_len / 4) .map(|(_, c)| c) .collect::() - )), - Paint::cyan(format!("{i:#x}")), - Paint::cyan(i) + ) + .cyan(), + format!("{i:#x}").cyan(), + i.cyan() ) } DynSolValue::Uint(i, bit_len) => { format!( "Type: {}\n├ Hex: {}\n├ Hex (full word): {}\n└ Decimal: {}", - Paint::red(format!("uint{}", bit_len)), - Paint::cyan(format!( + format!("uint{}", bit_len).red(), + format!( "0x{}", format!("{i:x}") .char_indices() @@ -375,50 +376,51 @@ fn format_token(token: DynSolValue) -> String { .take(bit_len / 4) .map(|(_, c)| c) .collect::() - )), - Paint::cyan(format!("{i:#x}")), - Paint::cyan(i) + ) + .cyan(), + format!("{i:#x}").cyan(), + i.cyan() ) } DynSolValue::Bool(b) => { - format!("Type: {}\n└ Value: {}", Paint::red("bool"), Paint::cyan(b)) + format!("Type: {}\n└ Value: {}", "bool".red(), b.cyan()) } DynSolValue::String(_) | DynSolValue::Bytes(_) => { let hex = hex::encode(token.abi_encode()); let s = token.as_str(); format!( "Type: {}\n{}├ Hex (Memory):\n├─ Length ({}): {}\n├─ Contents ({}): {}\n├ Hex (Tuple Encoded):\n├─ Pointer ({}): {}\n├─ Length ({}): {}\n└─ Contents ({}): {}", - Paint::red(if s.is_some() { "string" } else { "dynamic bytes" }), + if s.is_some() { "string" } else { "dynamic bytes" }.red(), if let Some(s) = s { - format!("├ UTF-8: {}\n", Paint::cyan(s)) + format!("├ UTF-8: {}\n", s.cyan()) } else { String::default() }, - Paint::yellow("[0x00:0x20]"), - Paint::cyan(format!("0x{}", &hex[64..128])), - Paint::yellow("[0x20:..]"), - Paint::cyan(format!("0x{}", &hex[128..])), - Paint::yellow("[0x00:0x20]"), - Paint::cyan(format!("0x{}", &hex[..64])), - Paint::yellow("[0x20:0x40]"), - Paint::cyan(format!("0x{}", &hex[64..128])), - Paint::yellow("[0x40:..]"), - Paint::cyan(format!("0x{}", &hex[128..])), + "[0x00:0x20]".yellow(), + format!("0x{}", &hex[64..128]).cyan(), + "[0x20:..]".yellow(), + format!("0x{}", &hex[128..]).cyan(), + "[0x00:0x20]".yellow(), + format!("0x{}", &hex[..64]).cyan(), + "[0x20:0x40]".yellow(), + format!("0x{}", &hex[64..128]).cyan(), + "[0x40:..]".yellow(), + format!("0x{}", &hex[128..]).cyan(), ) } DynSolValue::FixedArray(tokens) | DynSolValue::Array(tokens) => { let mut out = format!( "{}({}) = {}", - Paint::red("array"), - Paint::yellow(format!("{}", tokens.len())), - Paint::red('[') + "array".red(), + format!("{}", tokens.len()).yellow(), + '['.red() ); for token in tokens { out.push_str("\n ├ "); out.push_str(&format_token(token).replace('\n', "\n ")); out.push('\n'); } - out.push_str(&Paint::red(']').to_string()); + out.push_str(&']'.red().to_string()); out } DynSolValue::Tuple(tokens) => { @@ -428,18 +430,14 @@ fn format_token(token: DynSolValue) -> String { .map(|t| t.unwrap_or_default().into_owned()) .collect::>() .join(", "); - let mut out = format!( - "{}({}) = {}", - Paint::red("tuple"), - Paint::yellow(displayed_types), - Paint::red('(') - ); + let mut out = + format!("{}({}) = {}", "tuple".red(), displayed_types.yellow(), '('.red()); for token in tokens { out.push_str("\n ├ "); out.push_str(&format_token(token).replace('\n', "\n ")); out.push('\n'); } - out.push_str(&Paint::red(')').to_string()); + out.push_str(&')'.red().to_string()); out } _ => { @@ -487,7 +485,7 @@ fn format_event_definition(event_definition: &pt::EventDefinition) -> Result Result>() .join(", ") )), - Paint::cyan(event.signature()), - Paint::cyan(event.selector()), + event.signature().cyan(), + event.selector().cyan(), )) } diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 47660ba091aec..9deac254b0131 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -97,7 +97,7 @@ impl SessionSourceConfig { SolcReq::Version(version.into()) } else { if !self.foundry_config.offline { - print!("{}", Paint::green("No solidity versions installed! ")); + print!("{}", "No solidity versions installed! ".green()); } // use default SolcReq::Version("0.8.19".parse().unwrap()) @@ -121,10 +121,7 @@ impl SessionSourceConfig { if self.foundry_config.offline { eyre::bail!("can't install missing solc {version} in offline mode") } - println!( - "{}", - Paint::green(format!("Installing solidity version {version}...")) - ); + println!("{}", format!("Installing solidity version {version}...").green()); Solc::blocking_install(&version)?; solc = Solc::find_svm_installed_version(version.to_string())?; } @@ -289,21 +286,21 @@ impl SessionSource { /// Clears global code from the source pub fn drain_global_code(&mut self) -> &mut Self { - self.global_code.clear(); + String::clear(&mut self.global_code); self.generated_output = None; self } /// Clears top-level code from the source pub fn drain_top_level_code(&mut self) -> &mut Self { - self.top_level_code.clear(); + String::clear(&mut self.top_level_code); self.generated_output = None; self } /// Clears the "run()" function's code pub fn drain_run(&mut self) -> &mut Self { - self.run_code.clear(); + String::clear(&mut self.run_code); self.generated_output = None; self } diff --git a/crates/chisel/src/solidity_helper.rs b/crates/chisel/src/solidity_helper.rs index 42641a1f0a8d2..f09ad168356e2 100644 --- a/crates/chisel/src/solidity_helper.rs +++ b/crates/chisel/src/solidity_helper.rs @@ -19,7 +19,7 @@ use solang_parser::{ pt, }; use std::{borrow::Cow, str::FromStr}; -use yansi::{Color, Paint, Style}; +use yansi::{Color, Style}; /// The default pre-allocation for solang parsed comments const DEFAULT_COMMENTS: usize = 5; @@ -71,7 +71,7 @@ impl SolidityHelper { pt::Comment::DocLine(loc, _) | pt::Comment::DocBlock(loc, _) => loc, }; - (loc.start(), Style::default().dimmed(), loc.end()) + (loc.start(), Style::new().dim(), loc.end()) }); out.extend(comments_iter); @@ -102,7 +102,7 @@ impl SolidityHelper { /// Highlights a solidity source string pub fn highlight(input: &str) -> Cow { - if !Paint::is_enabled() { + if !yansi::is_enabled() { return Cow::Borrowed(input) } @@ -119,7 +119,7 @@ impl SolidityHelper { // cmd out.push(COMMAND_LEADER); let cmd_res = ChiselCommand::from_str(cmd); - let style = Style::new(if cmd_res.is_ok() { Color::Green } else { Color::Red }); + let style = (if cmd_res.is_ok() { Color::Green } else { Color::Red }).foreground(); Self::paint_unchecked(cmd, style, &mut out); // rest @@ -186,7 +186,7 @@ impl SolidityHelper { } /// Formats `input` with `style` into `out`, without checking `style.wrapping` or - /// `Paint::is_enabled` + /// `yansi::is_enabled` #[inline] fn paint_unchecked(string: &str, style: Style, out: &mut String) { if style == Style::default() { @@ -220,7 +220,7 @@ impl Highlighter for SolidityHelper { prompt: &'p str, _default: bool, ) -> Cow<'b, str> { - if !Paint::is_enabled() { + if !yansi::is_enabled() { return Cow::Borrowed(prompt) } @@ -231,12 +231,16 @@ impl Highlighter for SolidityHelper { let id_end = prompt.find(')').unwrap(); let id_span = 5..id_end; let id = &prompt[id_span.clone()]; - out.replace_range(id_span, &Self::paint_unchecked_owned(id, Color::Yellow.style())); - out.replace_range(1..=2, &Self::paint_unchecked_owned("ID", Color::Cyan.style())); + out.replace_range( + id_span, + &Self::paint_unchecked_owned(id, Color::Yellow.foreground()), + ); + out.replace_range(1..=2, &Self::paint_unchecked_owned("ID", Color::Cyan.foreground())); } if let Some(i) = out.find(PROMPT_ARROW) { - let style = if self.errored { Color::Red.style() } else { Color::Green.style() }; + let style = + if self.errored { Color::Red.foreground() } else { Color::Green.foreground() }; let mut arrow = String::with_capacity(MAX_ANSI_LEN + 4); @@ -278,7 +282,7 @@ impl<'a> TokenStyle for Token<'a> { fn style(&self) -> Style { use Token::*; match self { - StringLiteral(_, _) => Color::Green.style(), + StringLiteral(_, _) => Color::Green.foreground(), AddressLiteral(_) | HexLiteral(_) | @@ -286,21 +290,21 @@ impl<'a> TokenStyle for Token<'a> { RationalNumber(_, _, _) | HexNumber(_) | True | - False => Color::Yellow.style(), + False => Color::Yellow.foreground(), Memory | Storage | Calldata | Public | Private | Internal | External | Constant | Pure | View | Payable | Anonymous | Indexed | Abstract | Virtual | Override | - Modifier | Immutable | Unchecked => Color::Cyan.style(), + Modifier | Immutable | Unchecked => Color::Cyan.foreground(), Contract | Library | Interface | Function | Pragma | Import | Struct | Event | Enum | Type | Constructor | As | Is | Using | New | Delete | Do | Continue | Break | Throw | Emit | Return | Returns | Revert | For | While | If | Else | Try | Catch | Assembly | Let | Leave | Switch | Case | Default | YulArrow | Arrow => { - Color::Magenta.style() + Color::Magenta.foreground() } Uint(_) | Int(_) | Bytes(_) | Byte | DynamicBytes | Bool | Address | String | - Mapping => Color::Blue.style(), + Mapping => Color::Blue.foreground(), Identifier(_) => Style::default(), diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index fcc95d55e822d..a314ebb602ebd 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -40,7 +40,7 @@ tokio = { version = "1", features = ["macros"] } tracing-error = "0.2" tracing-subscriber = { workspace = true, features = ["registry", "env-filter", "fmt"] } tracing.workspace = true -yansi = "0.5" +yansi.workspace = true hex.workspace = true futures = "0.3" diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index 6666686c5555d..d6e34f3b8e1ae 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -16,7 +16,7 @@ impl EyreHandler for Handler { return core::fmt::Debug::fmt(error, f) } writeln!(f)?; - write!(f, "{}", Paint::red(error))?; + write!(f, "{}", error.red())?; if let Some(cause) = error.source() { write!(f, "\n\nContext:")?; diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 475fae2ed2e43..d8c5ab2227b81 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -128,7 +128,7 @@ pub fn needs_setup(abi: &JsonAbi) -> bool { if setup_fn.name != "setUp" { println!( "{} Found invalid setup function \"{}\" did you mean \"setUp()\"?", - Paint::yellow("Warning:").bold(), + "Warning:".yellow().bold(), setup_fn.signature() ); } @@ -437,9 +437,9 @@ pub async fn print_traces(result: &mut TraceResult, decoder: &CallTraceDecoder) println!(); if result.success { - println!("{}", Paint::green("Transaction successfully executed.")); + println!("{}", "Transaction successfully executed.".green()); } else { - println!("{}", Paint::red("Transaction failed.")); + println!("{}", "Transaction failed.".red()); } println!("Gas used: {}", result.gas_used); diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 015ce2145af68..e5950078e4475 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -13,7 +13,6 @@ use std::{ }; use tracing_error::ErrorLayer; use tracing_subscriber::prelude::*; -use yansi::Paint; mod cmd; pub use cmd::*; @@ -208,16 +207,9 @@ pub fn load_dotenv() { }; } -/// Disables terminal colours if either: -/// - Running windows and the terminal does not support colour codes. -/// - Colour has been disabled by some environment variable. -/// - We are running inside a test +/// Sets the default [`yansi`] color output condition. pub fn enable_paint() { - let is_windows = cfg!(windows) && !Paint::enable_windows_ascii(); - let env_colour_disabled = std::env::var("NO_COLOR").is_ok(); - if is_windows || env_colour_disabled { - Paint::disable(); - } + yansi::whenever(yansi::Condition::TTY_AND_COLOR); } /// Useful extensions to [`std::process::Command`]. diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 07f8837cabb8a..8bccf5054c6f7 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -60,7 +60,7 @@ tokio = "1" tracing.workspace = true url = "2" walkdir = "2" -yansi = "0.5" +yansi.workspace = true rustc-hash.workspace = true num-format.workspace = true diff --git a/crates/common/src/fmt/mod.rs b/crates/common/src/fmt/mod.rs index fbe1670fc6cbc..a43fe7dea0889 100644 --- a/crates/common/src/fmt/mod.rs +++ b/crates/common/src/fmt/mod.rs @@ -23,7 +23,7 @@ pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, get_pretty_tx_receipt_at /// use alloy_primitives::U256; /// use foundry_common::fmt::format_uint_exp as f; /// -/// # yansi::Paint::disable(); +/// # yansi::disable(); /// assert_eq!(f(U256::from(0)), "0"); /// assert_eq!(f(U256::from(1234)), "1234"); /// assert_eq!(f(U256::from(1234567890)), "1234567890 [1.234e9]"); @@ -36,7 +36,7 @@ pub fn format_uint_exp(num: U256) -> String { } let exp = to_exp_notation(num, 4, true, Sign::Positive); - format!("{num} {}", Paint::default(format!("[{exp}]")).dimmed()) + format!("{num} {}", format!("[{exp}]").dim()) } /// Formats a U256 number to string, adding an exponential notation _hint_. @@ -49,7 +49,7 @@ pub fn format_uint_exp(num: U256) -> String { /// use alloy_primitives::I256; /// use foundry_common::fmt::format_int_exp as f; /// -/// # yansi::Paint::disable(); +/// # yansi::disable(); /// assert_eq!(f(I256::try_from(0).unwrap()), "0"); /// assert_eq!(f(I256::try_from(-1).unwrap()), "-1"); /// assert_eq!(f(I256::try_from(1234).unwrap()), "1234"); @@ -72,5 +72,5 @@ pub fn format_int_exp(num: I256) -> String { } let exp = to_exp_notation(abs, 4, true, sign); - format!("{sign}{abs} {}", Paint::default(format!("[{exp}]")).dimmed()) + format!("{sign}{abs} {}", format!("[{exp}]").dim()) } diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index afeae0664049c..5cfb5ef37fdda 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -69,7 +69,7 @@ impl Spinner { return } - let indicator = Paint::green(self.indicator[self.idx % self.indicator.len()]); + let indicator = self.indicator[self.idx % self.indicator.len()].green(); let indicator = Paint::new(format!("[{indicator}]")).bold(); print!("\r\x33[2K\r{indicator} {}", self.message); io::stdout().flush().unwrap(); @@ -194,7 +194,7 @@ impl Reporter for SpinnerReporter { } fn on_solc_installation_error(&self, version: &Version, error: &str) { - self.send_msg(Paint::red(format!("Failed to install Solc {version}: {error}")).to_string()); + self.send_msg(format!("Failed to install Solc {version}: {error}").red().to_string()); } fn on_unresolved_imports(&self, imports: &[(&Path, &Path)], remappings: &[Remapping]) { @@ -221,8 +221,8 @@ macro_rules! cli_warn { ($($arg:tt)*) => { eprintln!( "{}{} {}", - yansi::Paint::yellow("warning").bold(), - yansi::Paint::new(":").bold(), + yansi::Painted::new("warning").yellow().bold(), + yansi::Painted::new(":").bold(), format_args!($($arg)*) ) } diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index be3cecb363832..fd873609d7270 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -31,7 +31,7 @@ once_cell = "1" serde = "1" tokio = { version = "1", features = ["time", "macros"] } tracing = "0.1" -yansi = "0.5" +yansi.workspace = true [dev-dependencies] tempfile = "3" diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index a52fd3b42eaaf..16cadde109e7b 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -125,8 +125,8 @@ pub async fn render_trace_arena( write!( s, "{child}{EDGE}{}{}", - color.paint(RETURN), - color.paint(format!("[{:?}] ", node.trace.status)) + RETURN.fg(color), + format!("[{:?}] ", node.trace.status).fg(color) )?; match return_data { Some(val) => write!(s, "{val}"), @@ -164,8 +164,8 @@ pub async fn render_trace( write!( &mut s, "{}{} {}@{}", - Paint::yellow(CALL), - Paint::yellow("new"), + CALL.yellow(), + "new".yellow(), decoded.label.as_deref().unwrap_or(""), address )?; @@ -198,14 +198,14 @@ pub async fn render_trace( write!( &mut s, "{addr}::{func_name}{opt_value}({inputs}){action}", - addr = color.paint(decoded.label.as_deref().unwrap_or(&address)), - func_name = color.paint(func_name), + addr = decoded.label.as_deref().unwrap_or(&address).fg(color), + func_name = func_name.fg(color), opt_value = if trace.value.is_zero() { String::new() } else { format!("{{value: {}}}", trace.value) }, - action = Paint::yellow(action), + action = action.yellow(), )?; } @@ -227,11 +227,11 @@ async fn render_trace_log( s, "{:>13}: {}", if i == 0 { "emit topic 0".to_string() } else { format!("topic {i}") }, - Paint::cyan(format!("{topic:?}")) + format!("{topic:?}").cyan() )?; } - write!(s, " data: {}", Paint::cyan(hex::encode_prefixed(&log.data)))?; + write!(s, " data: {}", hex::encode_prefixed(&log.data).cyan())?; } DecodedCallLog::Decoded(name, params) => { let params = params @@ -240,7 +240,7 @@ async fn render_trace_log( .collect::>() .join(", "); - write!(s, "emit {}({params})", Paint::cyan(name.clone()))?; + write!(s, "emit {}({params})", name.clone().cyan())?; } } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 7b05ee06e3209..3f724481c9573 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -37,7 +37,7 @@ proptest = "1" rayon = "1" serde.workspace = true tracing.workspace = true -yansi = "0.5" +yansi.workspace = true humantime-serde = "1.1.1" # bin diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 66f45b7704c9f..2b5ce85a6f3c2 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -112,13 +112,13 @@ impl CoverageArgs { } // print warning message - let msg = Paint::yellow(concat!( + let msg = concat!( "Warning! \"--ir-minimum\" flag enables viaIR with minimum optimization, \ which can result in inaccurate source mappings.\n", "Only use this flag as a workaround if you are experiencing \"stack too deep\" errors.\n", "Note that \"viaIR\" is only available in Solidity 0.8.13 and above.\n", "See more: https://github.com/foundry-rs/foundry/issues/3357", - )); + ).yellow(); p_println!(!self.test.build_args().silent => "{msg}"); // Enable viaIR with minimum optimization diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 36c0800008f19..06e05a5680dc6 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -12,7 +12,7 @@ use std::{ io::{Read, Write as _}, path::{Path, PathBuf}, }; -use yansi::Color; +use yansi::{Color, Paint, Style}; /// CLI arguments for `forge fmt`. #[derive(Clone, Debug, Parser)] @@ -217,24 +217,24 @@ where } for op in group { for change in diff.iter_inline_changes(&op) { - let dimmed = Color::Default.style().dimmed(); + let dimmed = Style::new().dim(); let (sign, s) = match change.tag() { - ChangeTag::Delete => ("-", Color::Red.style()), - ChangeTag::Insert => ("+", Color::Green.style()), + ChangeTag::Delete => ("-", Color::Red.foreground()), + ChangeTag::Insert => ("+", Color::Green.foreground()), ChangeTag::Equal => (" ", dimmed), }; let _ = write!( diff_summary, "{}{} |{}", - dimmed.paint(Line(change.old_index())), - dimmed.paint(Line(change.new_index())), - s.bold().paint(sign), + Line(change.old_index()).paint(dimmed), + Line(change.new_index()).paint(dimmed), + sign.paint(s.bold()), ); for (emphasized, value) in change.iter_strings_lossy() { let s = if emphasized { s.underline().bg(Color::Black) } else { s }; - let _ = write!(diff_summary, "{}", s.paint(value)); + let _ = write!(diff_summary, "{}", value.paint(s)); } if change.missing_newline() { diff --git a/crates/forge/bin/cmd/geiger/find.rs b/crates/forge/bin/cmd/geiger/find.rs index ed1d5e691ae89..3ea9c02341098 100644 --- a/crates/forge/bin/cmd/geiger/find.rs +++ b/crates/forge/bin/cmd/geiger/find.rs @@ -55,15 +55,15 @@ impl<'a, 'b> fmt::Display for SolFileMetricsPrinter<'a, 'b> { ($($name:literal => $field:ident),*) => {$( let $field = &metrics.cheatcodes.$field[..]; if !$field.is_empty() { - writeln!(f, " {} {}", Paint::red(metrics.cheatcodes.$field.len()), Paint::red($name))?; + writeln!(f, " {} {}", metrics.cheatcodes.$field.len().red(), $name.red())?; for &loc in $field { let content = &metrics.contents[loc.range()]; let (line, col) = offset_to_line_column(&metrics.contents, loc.start()); let pos = format!(" --> {}:{}:{}", file.display(), line, col); - writeln!(f,"{}", Paint::red(pos))?; + writeln!(f,"{}", pos.red())?; for line in content.lines() { - writeln!(f, " {}", Paint::red(line))?; + writeln!(f, " {}", line.red())?; } } } @@ -71,12 +71,7 @@ impl<'a, 'b> fmt::Display for SolFileMetricsPrinter<'a, 'b> { } if !metrics.cheatcodes.is_empty() { - writeln!( - f, - "{} {}", - Paint::red(metrics.cheatcodes.len()), - Paint::red(file.display()) - )?; + writeln!(f, "{} {}", metrics.cheatcodes.len().red(), file.display().red())?; print_unsafe_fn!( "ffi" => ffi, "readFile" => read_file, diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 8e3bc6fc56609..27555ed1a7944 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -91,7 +91,7 @@ impl GeigerArgs { let sources = self.sources(&config).wrap_err("Failed to resolve files")?; if config.ffi { - eprintln!("{}\n", Paint::red("ffi enabled")); + eprintln!("{}\n", "ffi enabled".red()); } let root = config.__root.0; diff --git a/crates/forge/bin/cmd/generate/mod.rs b/crates/forge/bin/cmd/generate/mod.rs index 190ea52b7752b..fd40a78ae6ca8 100644 --- a/crates/forge/bin/cmd/generate/mod.rs +++ b/crates/forge/bin/cmd/generate/mod.rs @@ -44,7 +44,7 @@ impl GenerateTestArgs { // Write the test content to the test file. fs::write(&test_file_path, test_content)?; - println!("{} test file: {}", Paint::green("Generated"), test_file_path.to_str().unwrap()); + println!("{} test file: {}", "Generated".green(), test_file_path.to_str().unwrap()); Ok(()) } } diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index d05c8a7bd472d..87010244ccfe6 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -159,7 +159,7 @@ impl InitArgs { } } - p_println!(!quiet => " {} forge project", Paint::green("Initialized")); + p_println!(!quiet => " {} forge project", "Initialized".green()); Ok(()) } } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 75fdbe3aa2ea0..ccec7d5de4f12 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -103,9 +103,7 @@ impl DependencyInstallOpts { if self.install(config, Vec::new()).is_err() && !quiet { eprintln!( "{}", - Paint::yellow( - "Your project has missing dependencies that could not be installed." - ) + "Your project has missing dependencies that could not be installed.".yellow() ) } true @@ -193,7 +191,7 @@ impl DependencyInstallOpts { } if !quiet { - let mut msg = format!(" {} {}", Paint::green("Installed"), dep.name); + let mut msg = format!(" {} {}", "Installed".green(), dep.name); if let Some(tag) = dep.tag.or(installed_tag) { msg.push(' '); msg.push_str(tag.as_str()); diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index d7147f49b6c14..5f91951d834ca 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -398,21 +398,21 @@ fn diff(tests: Vec, snaps: Vec) -> Result<()> { fn fmt_pct_change(change: f64) -> String { let change_pct = change * 100.0; match change.partial_cmp(&0.0).unwrap_or(Ordering::Equal) { - Ordering::Less => Paint::green(format!("{change_pct:.3}%")).to_string(), + Ordering::Less => format!("{change_pct:.3}%").green().to_string(), Ordering::Equal => { format!("{change_pct:.3}%") } - Ordering::Greater => Paint::red(format!("{change_pct:.3}%")).to_string(), + Ordering::Greater => format!("{change_pct:.3}%").red().to_string(), } } fn fmt_change(change: i128) -> String { match change.cmp(&0) { - Ordering::Less => Paint::green(format!("{change}")).to_string(), + Ordering::Less => format!("{change}").green().to_string(), Ordering::Equal => { format!("{change}") } - Ordering::Greater => Paint::red(format!("{change}")).to_string(), + Ordering::Greater => format!("{change}").red().to_string(), } } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 4a120adc73555..72835f097c920 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -408,7 +408,7 @@ impl TestArgs { // Print suite header. println!(); for warning in suite_result.warnings.iter() { - eprintln!("{} {warning}", Paint::yellow("Warning:").bold()); + eprintln!("{} {warning}", "Warning:".yellow().bold()); } if !tests.is_empty() { let len = tests.len(); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 2bdd6d4daec63..058af0587dab9 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -12,6 +12,7 @@ use std::{ collections::{BTreeMap, HashSet}, fmt::Display, }; +use yansi::Paint; /// Represents the gas report for a set of contracts. #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -51,7 +52,7 @@ impl GasReport { // indicating the "double listing". eprintln!( "{}: {} is listed in both 'gas_reports' and 'gas_reports_ignore'.", - yansi::Paint::yellow("warning").bold(), + "warning".yellow().bold(), contract_name ); } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 7cef52a9e233e..04f397c4834c2 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -141,9 +141,9 @@ impl TestOutcome { suites, wall_clock_time, self.total_time(), - Paint::green(total_passed), - Paint::red(total_failed), - Paint::yellow(total_skipped), + total_passed.green(), + total_failed.red(), + total_skipped.yellow(), total_tests ) } @@ -179,8 +179,8 @@ impl TestOutcome { let successes = outcome.passed(); shell::println(format!( "Encountered a total of {} failing tests, {} tests succeeded", - Paint::red(failures.to_string()), - Paint::green(successes.to_string()) + failures.to_string().red(), + successes.to_string().green() ))?; // TODO: Avoid process::exit @@ -271,13 +271,13 @@ impl SuiteResult { /// Returns the summary of a single test suite. pub fn summary(&self) -> String { let failed = self.failed(); - let result = if failed == 0 { Paint::green("ok") } else { Paint::red("FAILED") }; + let result = if failed == 0 { "ok".green() } else { "FAILED".red() }; format!( "Suite result: {}. {} passed; {} failed; {} skipped; finished in {:.2?} ({:.2?} CPU time)", result, - Paint::green(self.passed()), - Paint::red(failed), - Paint::yellow(self.skipped()), + self.passed().green(), + failed.red(), + self.skipped().yellow(), self.duration, self.total_time(), ) @@ -397,8 +397,8 @@ pub struct TestResult { impl fmt::Display for TestResult { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.status { - TestStatus::Success => Paint::green("[PASS]").fmt(f), - TestStatus::Skipped => Paint::yellow("[SKIP]").fmt(f), + TestStatus::Success => "[PASS]".green().fmt(f), + TestStatus::Skipped => "[SKIP]".yellow().fmt(f), TestStatus::Failure => { let mut s = String::from("[FAIL. Reason: "); @@ -421,7 +421,7 @@ impl fmt::Display for TestResult { s.push(']'); } - Paint::red(s).fmt(f) + s.red().fmt(f) } } } diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index e62e054bfadb8..4c14d26b4e915 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -35,7 +35,7 @@ async-recursion = "1.0.5" itertools.workspace = true parking_lot = "0.12" -yansi = "0.5" +yansi.workspace = true revm-inspectors.workspace = true alloy-rpc-types.workspace = true alloy-json-abi.workspace = true diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 6dc6a9617c090..66d44da0e5e27 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -267,7 +267,7 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855", .map(|(_, chain)| *chain as u64) .format(", ") ); - shell::println(Paint::yellow(msg))?; + shell::println(msg.yellow())?; } Ok(()) } @@ -306,9 +306,7 @@ impl ExecutedState { if rpc_data.is_multi_chain() { shell::eprintln(format!( "{}", - Paint::yellow( - "Multi chain deployment is still under development. Use with caution." - ) + "Multi chain deployment is still under development. Use with caution.".yellow() ))?; if !self.build_data.libraries.is_empty() { eyre::bail!( @@ -453,7 +451,7 @@ impl PreSimulationState { } if result.success { - shell::println(format!("{}", Paint::green("Script ran successfully.")))?; + shell::println(format!("{}", "Script ran successfully.".green()))?; } if self.script_config.evm_opts.fork_url.is_none() { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 0f9d8ad476c34..bbdda84ae55c0 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -419,9 +419,9 @@ impl ScriptArgs { prompt_user = self.broadcast; shell::println(format!( "{}", - Paint::red(format!( + format!( "`{name}` is above the contract size limit ({deployment_size} > {max_size})." - )) + ).red() ))?; } } diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 23c25d133dc08..ff77b8e61cb81 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -200,7 +200,7 @@ impl ScriptRunner { Ok(DeployResult { address, raw }) => (address, raw), Err(EvmError::Execution(err)) => { let ExecutionErr { raw, reason } = *err; - println!("{}", Paint::red(format!("\nFailed with `{reason}`:\n"))); + println!("{}", format!("\nFailed with `{reason}`:\n").red()); (Address::ZERO, raw) } Err(e) => eyre::bail!("Failed deploying contract: {e:?}"), diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 2d39c12923dbd..f98326564ffb6 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -324,11 +324,12 @@ impl ScriptSequence { if !unverifiable_contracts.is_empty() { println!( "\n{}", - Paint::yellow(format!( + format!( "We haven't found any matching bytecode for the following contracts: {:?}.\n\n{}", unverifiable_contracts, "This may occur when resuming a verification, but the underlying source code or compiler version has changed." - )) + ) + .yellow() .bold(), ); diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index d365388d09f7a..5fa8c761d92ce 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -35,7 +35,7 @@ futures = "0.3" semver = "1" regex = { version = "1", default-features = false } once_cell = "1" -yansi = "0.5" +yansi.workspace = true [dev-dependencies] tokio = { version = "1", features = ["macros"] } diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index b89fc91f13a6e..6f8d44ff9ad29 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -117,8 +117,8 @@ impl VerifyBytecodeArgs { if !self.json { println!( "Verifying bytecode for contract {} at address {}", - Paint::green(self.contract.name.clone()), - Paint::green(self.address.to_string()) + self.contract.name.clone().green(), + self.address.green() ); } @@ -174,7 +174,7 @@ impl VerifyBytecodeArgs { if provided_constructor_args != constructor_args.to_string() && !self.json { println!( "{}", - Paint::red("The provided constructor args do not match the constructor args from etherscan. This will result in a mismatch - Using the args from etherscan").bold(), + "The provided constructor args do not match the constructor args from etherscan. This will result in a mismatch - Using the args from etherscan".red().bold(), ); } @@ -456,8 +456,8 @@ impl VerifyBytecodeArgs { if !self.json { println!( "{} with status {}", - Paint::green(format!("{:?} code matched", bytecode_type)).bold(), - Paint::green(res.1.unwrap()).bold() + format!("{:?} code matched", bytecode_type).green().bold(), + res.1.unwrap().green().bold() ); } else { let json_res = JsonResult { @@ -471,15 +471,16 @@ impl VerifyBytecodeArgs { } else if !res.0 && !self.json { println!( "{}", - Paint::red(format!( + format!( "{:?} code did not match - this may be due to varying compiler settings", bytecode_type - )) + ) + .red() .bold() ); let mismatches = find_mismatch_in_settings(etherscan_config, config); for mismatch in mismatches { - println!("{}", Paint::red(mismatch).bold()); + println!("{}", mismatch.red().bold()); } } else if !res.0 && self.json { let json_res = JsonResult { From 9f06a4af1dfdf648a9cee1e7540e2af5a83bd8df Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:50:23 +0200 Subject: [PATCH 0890/1963] chore(deps): weekly `cargo update` (#7746) * chore(deps): weekly `cargo update` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Locking 23 packages to latest compatible versions Updating async-channel v2.2.0 -> v2.2.1 Updating aurora-engine-modexp v1.0.0 -> v1.1.0 Updating aws-smithy-http v0.60.7 -> v0.60.8 Updating aws-smithy-runtime v1.3.0 -> v1.3.1 Updating aws-smithy-xml v0.60.7 -> v0.60.8 Updating cc v1.0.94 -> v1.0.95 Updating chrono v0.4.37 -> v0.4.38 Updating figment v0.10.16 -> v0.10.18 Updating foundry-compilers v0.3.17 -> v0.3.18 Updating hyper v1.2.0 -> v1.3.1 Adding lzma-rs v0.3.0 Updating prettyplease v0.2.17 -> v0.2.19 Updating proc-macro2 v1.0.79 -> v1.0.81 Updating reqwest v0.12.3 -> v0.12.4 Updating serde v1.0.197 -> v1.0.198 Updating serde_derive v1.0.197 -> v1.0.198 Updating serde_json v1.0.115 -> v1.0.116 Updating syn v2.0.58 -> v2.0.60 Updating thiserror v1.0.58 -> v1.0.59 Updating thiserror-impl v1.0.58 -> v1.0.59 Updating toml_edit v0.22.9 -> v0.22.12 Adding zip v1.1.0 Updating zip_next v1.0.1 -> v1.1.1 note: pass `--verbose` to see 169 unchanged dependencies behind latest * tempfile --------- Co-authored-by: mattsse Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 352 ++++++++++++++--------------------- Cargo.toml | 1 + crates/anvil/Cargo.toml | 2 +- crates/cast/Cargo.toml | 8 +- crates/chisel/Cargo.toml | 1 - crates/cli/Cargo.toml | 2 +- crates/cli/src/utils/mod.rs | 3 +- crates/common/Cargo.toml | 2 +- crates/config/Cargo.toml | 2 +- crates/evm/traces/Cargo.toml | 2 +- crates/forge/Cargo.toml | 2 +- crates/script/Cargo.toml | 2 +- crates/verify/Cargo.toml | 2 +- 13 files changed, 155 insertions(+), 226 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ba16aacc1242..114b59a2a8e1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,7 +245,7 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", - "reqwest 0.12.3", + "reqwest 0.12.4", "serde_json", "tokio", "tracing", @@ -289,7 +289,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -306,7 +306,7 @@ dependencies = [ "alloy-transport-ws", "futures", "pin-project", - "reqwest 0.12.3", + "reqwest 0.12.4", "serde", "serde_json", "tokio", @@ -454,7 +454,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "syn-solidity", "tiny-keccak", ] @@ -472,7 +472,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.58", + "syn 2.0.60", "syn-solidity", ] @@ -523,7 +523,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be9 dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.3", + "reqwest 0.12.4", "serde_json", "tower", "url", @@ -708,7 +708,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 1.2.0", + "hyper 1.3.1", "itertools 0.12.1", "k256", "parking_lot", @@ -948,9 +948,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", @@ -987,7 +987,7 @@ checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1009,7 +1009,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1026,7 +1026,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1063,9 +1063,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "aurora-engine-modexp" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfacad86e9e138fca0670949eb8ed4ffdf73a55bded8887efe0863cd1a3a6f70" +checksum = "0aef7712851e524f35fbbb74fa6599c5cd8692056a1c36f9ca0d2001b670e7e5" dependencies = [ "hex", "num", @@ -1079,7 +1079,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1279,9 +1279,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.7" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f10fa66956f01540051b0aa7ad54574640f748f9839e843442d99b970d3aff9" +checksum = "4a7de001a1b9a25601016d8057ea16e31a45fdca3751304c8edf4ad72e706c08" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -1318,9 +1318,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de34bcfa1fb3c82a80e252a753db34a6658e07f23d3a5b3fc96919518fa7a3f5" +checksum = "44e7945379821074549168917e89e60630647e186a69243248f08c6d168b975a" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1384,9 +1384,9 @@ dependencies = [ [[package]] name = "aws-smithy-xml" -version = "0.60.7" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872c68cf019c0e4afc5de7753c4f7288ce4b71663212771bf5e4542eb9346ca9" +checksum = "d123fbc2a4adc3c301652ba8e149bf4bc1d1725affb9784eb20c953ace06bf55" dependencies = [ "xmlparser", ] @@ -1420,7 +1420,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.1", "hyper-util", "itoa", "matchit", @@ -1841,12 +1841,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -1882,7 +1883,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest 0.12.3", + "reqwest 0.12.4", "revm", "rustyline", "semver 1.0.22", @@ -1902,9 +1903,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -2002,7 +2003,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2035,15 +2036,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "coins-bip32" version = "0.8.7" @@ -2236,12 +2228,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -[[package]] -name = "constant_time_eq" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" - [[package]] name = "convert_case" version = "0.4.0" @@ -2471,7 +2457,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2482,7 +2468,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2504,12 +2490,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" -[[package]] -name = "deflate64" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83ace6c86376be0b6cdcf3fb41882e81d94b31587573d1cfa9d01cd06bba210d" - [[package]] name = "der" version = "0.7.9" @@ -2549,7 +2529,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2570,7 +2550,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2580,7 +2560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2830,7 +2810,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -3042,7 +3022,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.58", + "syn 2.0.60", "toml 0.8.12", "walkdir", ] @@ -3060,7 +3040,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -3086,7 +3066,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.58", + "syn 2.0.60", "tempfile", "thiserror", "tiny-keccak", @@ -3329,7 +3309,7 @@ dependencies = [ "bytes", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -3376,9 +3356,9 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.16" +version = "0.10.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdefe49ed1057d124dc81a0681c30dd07de56ad96e32adc7b64e8f28eaab31c4" +checksum = "d032832d74006f99547004d49410a4b4218e4c33382d56ca3ff89df74f86b953" dependencies = [ "atomic", "parking_lot", @@ -3428,7 +3408,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", - "libz-ng-sys", "miniz_oxide", ] @@ -3500,7 +3479,7 @@ dependencies = [ "futures", "globset", "humantime-serde", - "hyper 1.2.0", + "hyper 1.3.1", "indicatif", "itertools 0.12.1", "mockall", @@ -3513,7 +3492,7 @@ dependencies = [ "proptest", "rayon", "regex", - "reqwest 0.12.3", + "reqwest 0.12.4", "revm-inspectors", "rustc-hash", "semver 1.0.22", @@ -3522,13 +3501,13 @@ dependencies = [ "similar", "solang-parser", "strum", - "svm-rs 0.5.1", + "svm-rs 0.5.2", "tempfile", "thiserror", "tikv-jemallocator", "tokio", "toml 0.8.12", - "toml_edit 0.22.9", + "toml_edit 0.22.12", "tower-http", "tracing", "tracing-subscriber", @@ -3643,7 +3622,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest 0.12.3", + "reqwest 0.12.4", "revm-primitives", "semver 1.0.22", "serde", @@ -3673,7 +3652,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers", - "reqwest 0.12.3", + "reqwest 0.12.4", "semver 1.0.22", "serde", "serde_json", @@ -3808,7 +3787,7 @@ dependencies = [ "once_cell", "pretty_assertions", "reqwest 0.11.27", - "reqwest 0.12.3", + "reqwest 0.12.4", "rustc-hash", "semver 1.0.22", "serde", @@ -3850,7 +3829,7 @@ dependencies = [ "serde_json", "sha2", "solang-parser", - "svm-rs 0.5.1", + "svm-rs 0.5.2", "svm-rs-builds", "tempfile", "thiserror", @@ -3879,7 +3858,7 @@ dependencies = [ "path-slash", "pretty_assertions", "regex", - "reqwest 0.12.3", + "reqwest 0.12.4", "revm-primitives", "semver 1.0.22", "serde", @@ -3889,7 +3868,7 @@ dependencies = [ "tempfile", "thiserror", "toml 0.8.12", - "toml_edit 0.22.9", + "toml_edit 0.22.12", "tracing", "walkdir", ] @@ -4062,7 +4041,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4251,7 +4230,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -4866,9 +4845,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" dependencies = [ "bytes", "futures-channel", @@ -4908,7 +4887,7 @@ checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.2.0", + "hyper 1.3.1", "hyper-util", "rustls 0.22.4", "rustls-pki-types", @@ -4925,7 +4904,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.1", "hyper-util", "native-tls", "tokio", @@ -4944,7 +4923,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.2.0", + "hyper 1.3.1", "pin-project-lite", "socket2", "tokio", @@ -5389,16 +5368,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "libz-ng-sys" -version = "1.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6409efc61b12687963e602df8ecf70e8ddacf95bc6576bcf16e3ac6328083c5" -dependencies = [ - "cmake", - "libc", -] - [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -5562,7 +5531,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -5632,7 +5601,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -5866,7 +5835,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -5977,7 +5946,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6168,7 +6137,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6226,7 +6195,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6329,7 +6298,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6367,7 +6336,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6499,12 +6468,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" dependencies = [ "proc-macro2", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -6584,9 +6553,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -6599,7 +6568,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "version_check", "yansi 1.0.1", ] @@ -6949,9 +6918,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19" +checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ "base64 0.22.0", "bytes", @@ -6961,7 +6930,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.1", "hyper-rustls 0.26.0", "hyper-tls", "hyper-util", @@ -7242,9 +7211,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" dependencies = [ "bitflags 2.5.0", "errno", @@ -7439,6 +7408,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scc" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec96560eea317a9cc4e0bb1f6a2c93c09a19b8c4fc5cb3fcc0ec1c094cd783e2" +dependencies = [ + "sdd", +] + [[package]] name = "schannel" version = "0.1.23" @@ -7500,6 +7478,12 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "sdd" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d" + [[package]] name = "sec1" version = "0.7.3" @@ -7597,22 +7581,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -7628,9 +7612,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "indexmap", "itoa", @@ -7666,7 +7650,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -7692,27 +7676,27 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" +checksum = "adb86f9315df5df6a70eae0cc22395a44e544a0d8897586820770a35ede74449" dependencies = [ - "dashmap", "futures", - "lazy_static", "log", + "once_cell", "parking_lot", + "scc", "serial_test_derive", ] [[package]] name = "serial_test_derive" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" +checksum = "a9bb72430492e9549b0c4596725c0f82729bff861c45aa8099c0a8e67fc3b721" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -7807,9 +7791,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -7824,12 +7808,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "simd-adler32" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" - [[package]] name = "similar" version = "2.5.0" @@ -7931,7 +7909,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" dependencies = [ "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -8003,7 +7981,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -8042,40 +8020,40 @@ dependencies = [ "sha2", "thiserror", "url", - "zip", + "zip 0.6.6", ] [[package]] name = "svm-rs" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912d2f0dfbf9d8ba683b3181c4bd6d042bac9279d5c062346c253c1eadf46e2" +checksum = "f7c7a55b859b986daa02c731cd07758d84b1db852665e45c5cfa6698c41d17cb" dependencies = [ "const-hex", "dirs 5.0.1", "fs4", "once_cell", - "reqwest 0.12.3", + "reqwest 0.12.4", "semver 1.0.22", "serde", "serde_json", "sha2", "thiserror", "url", - "zip_next", + "zip 1.1.1", ] [[package]] name = "svm-rs-builds" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc1e420b6e969cb161e3b1758ea50cbde308c82fbfcb322979eae71c5cc947a" +checksum = "f1bb4806c96207e7cde40fc238f9a1d570f3090f850a742e1e96665440615a31" dependencies = [ "build_const", "const-hex", "semver 1.0.22", "serde_json", - "svm-rs 0.5.1", + "svm-rs 0.5.2", ] [[package]] @@ -8091,9 +8069,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -8109,7 +8087,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -8216,22 +8194,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -8373,7 +8351,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -8480,7 +8458,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.9", + "toml_edit 0.22.12", ] [[package]] @@ -8527,9 +8505,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap", "serde", @@ -8617,7 +8595,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -8738,12 +8716,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "typed-arena" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" - [[package]] name = "typenum" version = "1.17.0" @@ -8992,7 +8964,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -9026,7 +8998,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9480,7 +9452,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -9500,7 +9472,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -9512,7 +9484,7 @@ dependencies = [ "aes", "byteorder", "bzip2", - "constant_time_eq 0.1.5", + "constant_time_eq", "crc32fast", "crossbeam-utils", "flate2", @@ -9520,42 +9492,20 @@ dependencies = [ "pbkdf2 0.11.0", "sha1", "time", - "zstd 0.11.2+zstd.1.5.2", + "zstd", ] [[package]] -name = "zip_next" -version = "1.0.1" +name = "zip" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658758d431446f97e25f129b30c97646db8799b30f00aaf10379b4fa343d4ded" +checksum = "f2655979068a1f8fa91cb9e8e5b9d3ee54d18e0ddc358f2f4a395afc0929a84b" dependencies = [ - "aes", "arbitrary", "byteorder", - "bzip2", - "constant_time_eq 0.3.0", "crc32fast", "crossbeam-utils", - "deflate64", "flate2", - "hmac", - "pbkdf2 0.12.2", - "sha1", - "time", - "zopfli", - "zstd 0.13.1", -] - -[[package]] -name = "zopfli" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1f48f3508a3a3f2faee01629564400bc12260f6214a056d06a3aaaa6ef0736" -dependencies = [ - "crc32fast", - "log", - "simd-adler32", - "typed-arena", ] [[package]] @@ -9564,16 +9514,7 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", -] - -[[package]] -name = "zstd" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" -dependencies = [ - "zstd-safe 7.1.0", + "zstd-safe", ] [[package]] @@ -9586,15 +9527,6 @@ dependencies = [ "zstd-sys", ] -[[package]] -name = "zstd-safe" -version = "7.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" -dependencies = [ - "zstd-sys", -] - [[package]] name = "zstd-sys" version = "2.0.10+zstd.1.5.6" diff --git a/Cargo.toml b/Cargo.toml index d14288a38fd87..4ef7befcbafc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -215,6 +215,7 @@ indexmap = "2.2" tikv-jemallocator = "0.5.4" num-format = "0.4.4" yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } +tempfile = "3.10" axum = "0.7" hyper = "1.0" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index b7619eb5ac3fa..b067bfd04f802 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -71,7 +71,7 @@ serde_json.workspace = true serde.workspace = true thiserror = "1" yansi.workspace = true -tempfile = "3" +tempfile.workspace = true itertools.workspace = true rand = "0.8" eyre.workspace = true diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index e96737ce578e6..11b304212f576 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -15,11 +15,7 @@ name = "cast" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # lib @@ -75,7 +71,7 @@ itertools.workspace = true regex = { version = "1", default-features = false } rpassword = "7" semver = "1" -tempfile = "3" +tempfile.workspace = true tokio = { version = "1", features = ["macros", "signal"] } tracing.workspace = true yansi.workspace = true diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 05ad5aefc8b16..6ae62b970db33 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -55,7 +55,6 @@ tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] criterion = { version = "0.5", features = ["async_tokio"] } -once_cell = "1" serial_test = "3" tracing-subscriber.workspace = true diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index a314ebb602ebd..dd247ac4802f3 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -45,7 +45,7 @@ hex.workspace = true futures = "0.3" [dev-dependencies] -tempfile = "3.7" +tempfile.workspace = true [features] default = ["rustls"] diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index e5950078e4475..cd071617520ff 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -209,7 +209,8 @@ pub fn load_dotenv() { /// Sets the default [`yansi`] color output condition. pub fn enable_paint() { - yansi::whenever(yansi::Condition::TTY_AND_COLOR); + let enable = yansi::Condition::os_support() && yansi::Condition::tty_and_color_live(); + yansi::whenever(yansi::Condition::cached(enable)); } /// Useful extensions to [`std::process::Command`]. diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 8bccf5054c6f7..29d55fe5f5214 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -54,7 +54,7 @@ reqwest.workspace = true semver = "1" serde_json.workspace = true serde.workspace = true -tempfile = "3" +tempfile.workspace = true thiserror = "1" tokio = "1" tracing.workspace = true diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 1b639ee55ae1e..7a65678d4f8a0 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -46,7 +46,7 @@ path-slash = "0.2.1" [dev-dependencies] pretty_assertions.workspace = true figment = { version = "0.10", features = ["test"] } -tempfile = "3" +tempfile.workspace = true [features] default = ["rustls"] diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index fd873609d7270..a4bcb0a0b33fb 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -34,4 +34,4 @@ tracing = "0.1" yansi.workspace = true [dev-dependencies] -tempfile = "3" +tempfile.workspace = true diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 3f724481c9573..05a7f75f5a92e 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -106,7 +106,7 @@ paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true svm = { package = "svm-rs", version = "0.5", default-features = false, features = ["rustls"] } -tempfile = "3" +tempfile.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } ethers-core.workspace = true diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 4c14d26b4e915..3d41ac7954786 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -52,4 +52,4 @@ alloy-eips.workspace = true alloy-transport.workspace = true [dev-dependencies] -tempfile = "3" \ No newline at end of file +tempfile.workspace = true diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 5fa8c761d92ce..21eb659423c32 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -40,4 +40,4 @@ yansi.workspace = true [dev-dependencies] tokio = { version = "1", features = ["macros"] } foundry-test-utils.workspace = true -tempfile = "3" +tempfile.workspace = true From e971af109b8240b8de694b23bf6d1f96ed10ae71 Mon Sep 17 00:00:00 2001 From: sealer3 <125761775+sealer3@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:20:25 +0000 Subject: [PATCH 0891/1963] fix(anvil): Return transaction hash in ots_getTransactionBySenderAndNonce (#7741) Return transaction hash in ots_getTransactionBySenderAndNonce --- crates/anvil/src/eth/otterscan/api.rs | 8 +++----- crates/anvil/tests/it/otterscan.rs | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 636140f13ffea..400f99193aecd 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -8,9 +8,7 @@ use crate::eth::{ EthApi, }; use alloy_primitives::{Address, Bytes, B256, U256}; -use alloy_rpc_types::{ - Block, BlockId, BlockNumberOrTag as BlockNumber, Transaction, WithOtherFields, -}; +use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag as BlockNumber}; use alloy_rpc_types_trace::parity::{ Action, CallAction, CreateAction, CreateOutput, RewardAction, TraceOutput, }; @@ -240,7 +238,7 @@ impl EthApi { &self, address: Address, nonce: U256, - ) -> Result>> { + ) -> Result> { node_info!("ots_getTransactionBySenderAndNonce"); let from = self.get_fork().map(|f| f.block_number() + 1).unwrap_or_default(); @@ -250,7 +248,7 @@ impl EthApi { if let Some(txs) = self.backend.mined_transactions_by_block_number(n.into()).await { for tx in txs { if U256::from(tx.nonce) == nonce && tx.from == address { - return Ok(Some(tx)) + return Ok(Some(tx.hash)) } } } diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 4c344264034c2..3b27a0f6c687b 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -594,8 +594,8 @@ async fn can_call_ots_get_transaction_by_sender_and_nonce() { .await .unwrap(); - assert_eq!(result1.unwrap().hash, receipt1.transaction_hash.to_alloy()); - assert_eq!(result2.unwrap().hash, receipt2.transaction_hash.to_alloy()); + assert_eq!(result1.unwrap(), receipt1.transaction_hash.to_alloy()); + assert_eq!(result2.unwrap(), receipt2.transaction_hash.to_alloy()); } #[tokio::test(flavor = "multi_thread")] From 008922d5165c764859bc540d7298045eebf5bc60 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:33:39 +0300 Subject: [PATCH 0892/1963] feat(fuzz): ability to declare fuzz test fixtures (#7428) * fix(fuzz): deduplicate fuzz inputs * Fix tests, collect fixtures in test setup, arc fixtures * Cleanup * Use fixture_ prefix * Update tests to reflect that random values are used if no fixtures * Review changes * Group fuzz_calldata and fuzz_calldata_from_state in calldata mod * Review changes: remove unnecessary clones, nicer code to collect fixtures * Add support for bytes and string fixtures, fixture strategy macro. Solidity test * Remove unnecessary clone * Use inline config * More robust invariant assume test - previously rejecting when param was 0 (vm.assume(param != 0)) that is param should have been fuzzed twice with 0 in a run - with fuzz input deduplication is now harder to occur, changed rejected if param is not 0 (vm.assume(param != 0)) and narrow down to one run and just 10 depth * Fixtures as storage arrays, remove inline config * Simplify code * Support fixed size arrays fixtures * Update comment * Use DynSolValue::type_strategy for address and fixed bytes fuzzed params * Add prefix to mark a storage array or a function as fixture * Fix test * Simplify code / fixture strategy macro, panic if configured fixture not of param type * Consistent panic with fixture strategy if uint / int fixture of different type. Keep level of randomness in fixture strategy, at par with uint / int strategies. * Review changes: don't panic when invalid fixture, use prop_filter_map for fixture strategy and raise error --- crates/common/src/traits.rs | 15 +++ crates/config/src/fuzz.rs | 5 - crates/config/src/inline/conf_parser.rs | 4 +- crates/config/src/inline/mod.rs | 2 +- crates/evm/evm/src/executors/fuzz/mod.rs | 7 +- crates/evm/evm/src/executors/invariant/mod.rs | 31 ++--- crates/evm/fuzz/src/lib.rs | 41 +++++- crates/evm/fuzz/src/strategies/calldata.rs | 126 +++++++++--------- crates/evm/fuzz/src/strategies/int.rs | 33 ++++- crates/evm/fuzz/src/strategies/invariants.rs | 23 ++-- crates/evm/fuzz/src/strategies/mod.rs | 36 ++++- crates/evm/fuzz/src/strategies/param.rs | 124 +++++++++++------ crates/evm/fuzz/src/strategies/state.rs | 29 +--- crates/evm/fuzz/src/strategies/uint.rs | 45 +++++-- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/result.rs | 8 +- crates/forge/src/runner.rs | 95 +++++++++++-- crates/forge/tests/it/invariant.rs | 61 ++++++--- crates/forge/tests/it/test_helpers.rs | 2 - testdata/default/fuzz/FuzzInt.t.sol | 17 +-- testdata/default/fuzz/FuzzUint.t.sol | 11 +- .../invariant/common/InvariantAssume.t.sol | 2 +- .../common/InvariantCalldataDictionary.t.sol | 11 ++ .../invariant/common/InvariantFixtures.t.sol | 77 +++++++++++ 24 files changed, 568 insertions(+), 239 deletions(-) create mode 100644 testdata/default/fuzz/invariant/common/InvariantFixtures.t.sol diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index 4232fb946dc3b..8ed1edbec304d 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -33,6 +33,9 @@ pub trait TestFunctionExt { /// Returns whether this function is a `setUp` function. fn is_setup(&self) -> bool; + + /// Returns whether this function is a fixture function. + fn is_fixture(&self) -> bool; } impl TestFunctionExt for Function { @@ -56,6 +59,10 @@ impl TestFunctionExt for Function { fn is_setup(&self) -> bool { self.name.is_setup() } + + fn is_fixture(&self) -> bool { + self.name.is_fixture() + } } impl TestFunctionExt for String { @@ -78,6 +85,10 @@ impl TestFunctionExt for String { fn is_setup(&self) -> bool { self.as_str().is_setup() } + + fn is_fixture(&self) -> bool { + self.as_str().is_fixture() + } } impl TestFunctionExt for str { @@ -100,6 +111,10 @@ impl TestFunctionExt for str { fn is_setup(&self) -> bool { self.eq_ignore_ascii_case("setup") } + + fn is_fixture(&self) -> bool { + self.starts_with("fixture") + } } /// An extension trait for `std::error::Error` for ABI encoding. diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index 3b0e13bcd509c..7049a401a5f3e 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -111,10 +111,6 @@ pub struct FuzzDictionaryConfig { /// Once the fuzzer exceeds this limit, it will start evicting random entries #[serde(deserialize_with = "crate::deserialize_usize_or_max")] pub max_fuzz_dictionary_values: usize, - /// How many random addresses to use and to recycle when fuzzing calldata. - /// If not specified then `max_fuzz_dictionary_addresses` value applies. - #[serde(deserialize_with = "crate::deserialize_usize_or_max")] - pub max_calldata_fuzz_dictionary_addresses: usize, } impl Default for FuzzDictionaryConfig { @@ -127,7 +123,6 @@ impl Default for FuzzDictionaryConfig { max_fuzz_dictionary_addresses: (300 * 1024 * 1024) / 20, // limit this to 200MB max_fuzz_dictionary_values: (200 * 1024 * 1024) / 32, - max_calldata_fuzz_dictionary_addresses: 0, } } } diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index acad057ae0d73..1f6fca6c7ac55 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -149,7 +149,7 @@ mod tests { function: Default::default(), line: Default::default(), docs: r" - forge-config: ciii.invariant.depth = 1 + forge-config: ciii.invariant.depth = 1 forge-config: default.invariant.depth = 1 " .into(), @@ -167,7 +167,7 @@ mod tests { function: Default::default(), line: Default::default(), docs: r" - forge-config: ci.invariant.depth = 1 + forge-config: ci.invariant.depth = 1 forge-config: default.invariant.depth = 1 " .into(), diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 9989d5b76c554..f2222901f9065 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -37,7 +37,7 @@ impl InlineConfig { } /// Inserts an inline configuration, for a test function. - /// Configuration is identified by the pair "contract", "function". + /// Configuration is identified by the pair "contract", "function". pub fn insert(&mut self, contract_id: C, fn_name: F, config: T) where C: Into, diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index ae63d2386bae4..8e3a85bddfaa8 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -11,7 +11,7 @@ use foundry_evm_core::{ use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, - BaseCounterExample, CounterExample, FuzzCase, FuzzError, FuzzTestResult, + BaseCounterExample, CounterExample, FuzzCase, FuzzError, FuzzFixtures, FuzzTestResult, }; use foundry_evm_traces::CallTraceArena; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; @@ -55,6 +55,7 @@ impl FuzzedExecutor { pub fn fuzz( &self, func: &Function, + fuzz_fixtures: &FuzzFixtures, address: Address, should_fail: bool, rd: &RevertDecoder, @@ -80,10 +81,12 @@ impl FuzzedExecutor { let state = self.build_fuzz_state(); let dictionary_weight = self.config.dictionary.dictionary_weight.min(100); + let strat = proptest::prop_oneof![ - 100 - dictionary_weight => fuzz_calldata(func.clone()), + 100 - dictionary_weight => fuzz_calldata(func.clone(), fuzz_fixtures), dictionary_weight => fuzz_calldata_from_state(func.clone(), &state), ]; + debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 2a7000ec1a782..b5669cb7ddddd 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -18,14 +18,14 @@ use foundry_evm_fuzz::{ }, strategies::{ build_initial_state, collect_created_contracts, invariant_strat, override_call_strat, - CalldataFuzzDictionary, EvmFuzzState, + EvmFuzzState, }, - FuzzCase, FuzzedCases, + FuzzCase, FuzzFixtures, FuzzedCases, }; use foundry_evm_traces::CallTraceArena; use parking_lot::RwLock; use proptest::{ - strategy::{BoxedStrategy, Strategy, ValueTree}, + strategy::{BoxedStrategy, Strategy}, test_runner::{TestCaseError, TestRunner}, }; use revm::{primitives::HashMap, DatabaseCommit}; @@ -88,12 +88,8 @@ sol! { } /// Alias for (Dictionary for fuzzing, initial contracts to fuzz and an InvariantStrategy). -type InvariantPreparation = ( - EvmFuzzState, - FuzzRunIdentifiedContracts, - BoxedStrategy, - CalldataFuzzDictionary, -); +type InvariantPreparation = + (EvmFuzzState, FuzzRunIdentifiedContracts, BoxedStrategy); /// Enriched results of an invariant run check. /// @@ -152,14 +148,15 @@ impl<'a> InvariantExecutor<'a> { pub fn invariant_fuzz( &mut self, invariant_contract: InvariantContract<'_>, + fuzz_fixtures: &FuzzFixtures, ) -> Result { // Throw an error to abort test run if the invariant function accepts input params if !invariant_contract.invariant_function.inputs.is_empty() { return Err(eyre!("Invariant test function should have no inputs")) } - let (fuzz_state, targeted_contracts, strat, calldata_fuzz_dictionary) = - self.prepare_fuzzing(&invariant_contract)?; + let (fuzz_state, targeted_contracts, strat) = + self.prepare_fuzzing(&invariant_contract, fuzz_fixtures)?; // Stores the consumed gas and calldata of every successful fuzz call. let fuzz_cases: RefCell> = RefCell::new(Default::default()); @@ -329,7 +326,7 @@ impl<'a> InvariantExecutor<'a> { Ok(()) }); - trace!(target: "forge::test::invariant::calldata_address_fuzz_dictionary", "{:?}", calldata_fuzz_dictionary.inner.addresses); + trace!(target: "forge::test::invariant::fuzz_fixtures", "{:?}", fuzz_fixtures); trace!(target: "forge::test::invariant::dictionary", "{:?}", fuzz_state.dictionary_read().values().iter().map(hex::encode).collect::>()); let (reverts, error) = failures.into_inner().into_inner(); @@ -350,6 +347,7 @@ impl<'a> InvariantExecutor<'a> { fn prepare_fuzzing( &mut self, invariant_contract: &InvariantContract<'_>, + fuzz_fixtures: &FuzzFixtures, ) -> eyre::Result { // Finds out the chosen deployed contracts and/or senders. self.select_contract_artifacts(invariant_contract.address)?; @@ -360,16 +358,13 @@ impl<'a> InvariantExecutor<'a> { let fuzz_state: EvmFuzzState = build_initial_state(self.executor.backend.mem_db(), self.config.dictionary); - let calldata_fuzz_config = - CalldataFuzzDictionary::new(&self.config.dictionary, &fuzz_state); - // Creates the invariant strategy. let strat = invariant_strat( fuzz_state.clone(), targeted_senders, targeted_contracts.clone(), self.config.dictionary.dictionary_weight, - calldata_fuzz_config.clone(), + fuzz_fixtures.clone(), ) .no_shrink() .boxed(); @@ -387,7 +382,7 @@ impl<'a> InvariantExecutor<'a> { fuzz_state.clone(), targeted_contracts.clone(), target_contract_ref.clone(), - calldata_fuzz_config.clone(), + fuzz_fixtures.clone(), ), target_contract_ref, )); @@ -396,7 +391,7 @@ impl<'a> InvariantExecutor<'a> { self.executor.inspector.fuzzer = Some(Fuzzer { call_generator, fuzz_state: fuzz_state.clone(), collect: true }); - Ok((fuzz_state, targeted_contracts, strat, calldata_fuzz_config)) + Ok((fuzz_state, targeted_contracts, strat)) } /// Fills the `InvariantExecutor` with the artifact identifier filters (in `path:name` string diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index f8928ea3e13f5..b2a058e5bb022 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -14,7 +14,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, fmt}; +use std::{collections::HashMap, fmt, sync::Arc}; pub use proptest::test_runner::{Config as FuzzConfig, Reason}; @@ -272,3 +272,42 @@ impl FuzzedCases { self.lowest().map(|c| c.gas).unwrap_or_default() } } + +/// Fixtures to be used for fuzz tests. +/// The key represents name of the fuzzed parameter, value holds possible fuzzed values. +/// For example, for a fixture function declared as +/// `function fixture_sender() external returns (address[] memory senders)` +/// the fuzz fixtures will contain `sender` key with `senders` array as value +#[derive(Clone, Default, Debug)] +pub struct FuzzFixtures { + inner: Arc>, +} + +impl FuzzFixtures { + pub fn new(fixtures: HashMap) -> FuzzFixtures { + Self { inner: Arc::new(fixtures) } + } + + /// Returns configured fixtures for `param_name` fuzzed parameter. + pub fn param_fixtures(&self, param_name: &str) -> Option<&[DynSolValue]> { + if let Some(param_fixtures) = self.inner.get(&normalize_fixture(param_name)) { + match param_fixtures { + DynSolValue::FixedArray(_) => param_fixtures.as_fixed_array(), + _ => param_fixtures.as_array(), + } + } else { + None + } + } +} + +/// Extracts fixture name from a function name. +/// For example: fixtures defined in `fixture_Owner` function will be applied for `owner` parameter. +pub fn fixture_name(function_name: String) -> String { + normalize_fixture(function_name.strip_prefix("fixture").unwrap()) +} + +/// Normalize fixture parameter name, for example `_Owner` to `owner`. +fn normalize_fixture(param_name: &str) -> String { + param_name.trim_matches(&['_']).to_ascii_lowercase() +} diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index ff3bb57134469..760d661754813 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -1,71 +1,26 @@ -use crate::strategies::{fuzz_param, EvmFuzzState}; +use crate::{ + strategies::{fuzz_param, fuzz_param_from_state, EvmFuzzState}, + FuzzFixtures, +}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes}; -use foundry_config::FuzzDictionaryConfig; -use proptest::prelude::Strategy; -use std::{collections::HashSet, sync::Arc}; - -/// Clonable wrapper around [CalldataFuzzDictionary]. -#[derive(Clone, Debug)] -pub struct CalldataFuzzDictionary { - pub inner: Arc, -} - -impl CalldataFuzzDictionary { - pub fn new(config: &FuzzDictionaryConfig, state: &EvmFuzzState) -> Self { - Self { inner: Arc::new(CalldataFuzzDictionaryConfig::new(config, state)) } - } -} - -#[derive(Clone, Debug)] -pub struct CalldataFuzzDictionaryConfig { - /// Addresses that can be used for fuzzing calldata. - pub addresses: Vec
, -} - -/// Represents custom configuration for invariant fuzzed calldata strategies. -/// -/// At the moment only the dictionary of addresses to be used for a fuzzed `function(address)` can -/// be configured, but support for other types can be added. -impl CalldataFuzzDictionaryConfig { - /// Creates config with the set of addresses that can be used for fuzzing invariant calldata (if - /// `max_calldata_fuzz_dictionary_addresses` configured). - /// The set of addresses contains a number of `max_calldata_fuzz_dictionary_addresses` random - /// addresses plus all addresses that already had their PUSH bytes collected (retrieved from - /// `EvmFuzzState`, if `include_push_bytes` config enabled). - pub fn new(config: &FuzzDictionaryConfig, state: &EvmFuzzState) -> Self { - let mut addresses = HashSet::
::new(); - - let dict_size = config.max_calldata_fuzz_dictionary_addresses; - if dict_size > 0 { - addresses.extend(std::iter::repeat_with(Address::random).take(dict_size)); - // Add all addresses that already had their PUSH bytes collected. - addresses.extend(state.dictionary_read().addresses()); - } - - Self { addresses: addresses.into_iter().collect() } - } -} +use alloy_primitives::Bytes; +use proptest::prelude::{BoxedStrategy, Strategy}; /// Given a function, it returns a strategy which generates valid calldata -/// for that function's input types. -pub fn fuzz_calldata(func: Function) -> impl Strategy { - fuzz_calldata_with_config(func, None) -} - -/// Given a function, it returns a strategy which generates valid calldata -/// for that function's input types, following custom configuration rules. -pub fn fuzz_calldata_with_config( - func: Function, - config: Option<&CalldataFuzzDictionary>, -) -> impl Strategy { +/// for that function's input types, following declared test fixtures. +pub fn fuzz_calldata(func: Function, fuzz_fixtures: &FuzzFixtures) -> impl Strategy { // We need to compose all the strategies generated for each parameter in all - // possible combinations + // possible combinations, accounting any parameter declared fixture let strats = func .inputs .iter() - .map(|input| fuzz_param(&input.selector_type().parse().unwrap(), config)) + .map(|input| { + fuzz_param( + &input.selector_type().parse().unwrap(), + fuzz_fixtures.param_fixtures(&input.name), + ) + }) .collect::>(); strats.prop_map(move |values| { func.abi_encode_input(&values) @@ -78,3 +33,54 @@ pub fn fuzz_calldata_with_config( .into() }) } + +/// Given a function and some state, it returns a strategy which generated valid calldata for the +/// given function's input types, based on state taken from the EVM. +pub fn fuzz_calldata_from_state(func: Function, state: &EvmFuzzState) -> BoxedStrategy { + let strats = func + .inputs + .iter() + .map(|input| fuzz_param_from_state(&input.selector_type().parse().unwrap(), state)) + .collect::>(); + strats + .prop_map(move |values| { + func.abi_encode_input(&values) + .unwrap_or_else(|_| { + panic!( + "Fuzzer generated invalid arguments for function `{}` with inputs {:?}: {:?}", + func.name, func.inputs, values + ) + }) + .into() + }) + .no_shrink() + .boxed() +} + +#[cfg(test)] +mod tests { + use crate::{strategies::fuzz_calldata, FuzzFixtures}; + use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; + use alloy_json_abi::Function; + use alloy_primitives::Address; + use proptest::prelude::Strategy; + use std::collections::HashMap; + + #[test] + fn can_fuzz_with_fixtures() { + let function = Function::parse("test_fuzzed_address(address addressFixture)").unwrap(); + + let address_fixture = DynSolValue::Address(Address::random()); + let mut fixtures = HashMap::new(); + fixtures.insert( + "addressFixture".to_string(), + DynSolValue::Array(vec![address_fixture.clone()]), + ); + + let expected = function.abi_encode_input(&[address_fixture]).unwrap(); + let strategy = fuzz_calldata(function, &FuzzFixtures::new(fixtures)); + let _ = strategy.prop_map(move |fuzzed| { + assert_eq!(expected, fuzzed); + }); + } +} diff --git a/crates/evm/fuzz/src/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs index f772d97c0c1e8..b27f62f2854d9 100644 --- a/crates/evm/fuzz/src/strategies/int.rs +++ b/crates/evm/fuzz/src/strategies/int.rs @@ -1,3 +1,4 @@ +use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{Sign, I256, U256}; use proptest::{ strategy::{NewTree, Strategy, ValueTree}, @@ -83,12 +84,20 @@ impl ValueTree for IntValueTree { /// param). Then generate a value for this bit size. /// 2. Generate a random value around the edges (+/- 3 around min, 0 and max possible value) /// 3. Generate a value from a predefined fixtures set +/// +/// To define int fixtures: +/// - return an array of possible values for a parameter named `amount` declare a function +/// `function fixture_amount() public returns (int32[] memory)`. +/// - use `amount` named parameter in fuzzed test in order to include fixtures in fuzzed values +/// `function testFuzz_int32(int32 amount)`. +/// +/// If fixture is not a valid int type then error is raised and random value generated. #[derive(Debug)] pub struct IntStrategy { /// Bit size of int (e.g. 256) bits: usize, /// A set of fixtures to be generated - fixtures: Vec, + fixtures: Vec, /// The weight for edge cases (+/- 3 around 0 and max possible value) edge_weight: usize, /// The weight for fixtures @@ -102,10 +111,10 @@ impl IntStrategy { /// #Arguments /// * `bits` - Size of uint in bits /// * `fixtures` - A set of fixed values to be generated (according to fixtures weight) - pub fn new(bits: usize, fixtures: Vec) -> Self { + pub fn new(bits: usize, fixtures: Option<&[DynSolValue]>) -> Self { Self { bits, - fixtures, + fixtures: Vec::from(fixtures.unwrap_or_default()), edge_weight: 10usize, fixtures_weight: 40usize, random_weight: 50usize, @@ -132,12 +141,22 @@ impl IntStrategy { } fn generate_fixtures_tree(&self, runner: &mut TestRunner) -> NewTree { - // generate edge cases if there's no fixtures + // generate random cases if there's no fixtures if self.fixtures.is_empty() { - return self.generate_edge_tree(runner) + return self.generate_random_tree(runner) } - let idx = runner.rng().gen_range(0..self.fixtures.len()); - Ok(IntValueTree::new(self.fixtures[idx], false)) + + // Generate value tree from fixture. + let fixture = &self.fixtures[runner.rng().gen_range(0..self.fixtures.len())]; + if let Some(int_fixture) = fixture.as_int() { + if int_fixture.1 == self.bits { + return Ok(IntValueTree::new(int_fixture.0, false)); + } + } + + // If fixture is not a valid type, raise error and generate random value. + error!("{:?} is not a valid {} fixture", fixture, DynSolType::Int(self.bits)); + self.generate_random_tree(runner) } fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree { diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 137e708523662..08e53b2a0bf5e 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -1,7 +1,8 @@ -use super::{fuzz_calldata_with_config, fuzz_param_from_state, CalldataFuzzDictionary}; +use super::{fuzz_calldata, fuzz_param_from_state}; use crate::{ invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, SenderFilters}, strategies::{fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, + FuzzFixtures, }; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes}; @@ -14,7 +15,7 @@ pub fn override_call_strat( fuzz_state: EvmFuzzState, contracts: FuzzRunIdentifiedContracts, target: Arc>, - calldata_fuzz_config: CalldataFuzzDictionary, + fuzz_fixtures: FuzzFixtures, ) -> SBoxedStrategy<(Address, Bytes)> { let contracts_ref = contracts.targets.clone(); proptest::prop_oneof![ @@ -24,7 +25,7 @@ pub fn override_call_strat( ] .prop_flat_map(move |target_address| { let fuzz_state = fuzz_state.clone(); - let calldata_fuzz_config = calldata_fuzz_config.clone(); + let fuzz_fixtures = fuzz_fixtures.clone(); let func = { let contracts = contracts.targets.lock(); @@ -40,7 +41,7 @@ pub fn override_call_strat( }; func.prop_flat_map(move |func| { - fuzz_contract_with_calldata(&fuzz_state, &calldata_fuzz_config, target_address, func) + fuzz_contract_with_calldata(&fuzz_state, &fuzz_fixtures, target_address, func) }) }) .sboxed() @@ -61,11 +62,11 @@ pub fn invariant_strat( senders: SenderFilters, contracts: FuzzRunIdentifiedContracts, dictionary_weight: u32, - calldata_fuzz_config: CalldataFuzzDictionary, + fuzz_fixtures: FuzzFixtures, ) -> impl Strategy { // We only want to seed the first value, since we want to generate the rest as we mutate the // state - generate_call(fuzz_state, senders, contracts, dictionary_weight, calldata_fuzz_config) + generate_call(fuzz_state, senders, contracts, dictionary_weight, fuzz_fixtures) } /// Strategy to generate a transaction where the `sender`, `target` and `calldata` are all generated @@ -75,7 +76,7 @@ fn generate_call( senders: SenderFilters, contracts: FuzzRunIdentifiedContracts, dictionary_weight: u32, - calldata_fuzz_config: CalldataFuzzDictionary, + fuzz_fixtures: FuzzFixtures, ) -> BoxedStrategy { let senders = Rc::new(senders); any::() @@ -92,11 +93,11 @@ fn generate_call( let senders = senders.clone(); let fuzz_state = fuzz_state.clone(); - let calldata_fuzz_config = calldata_fuzz_config.clone(); + let fuzz_fixtures = fuzz_fixtures.clone(); func.prop_flat_map(move |func| { let sender = select_random_sender(&fuzz_state, senders.clone(), dictionary_weight); let contract = - fuzz_contract_with_calldata(&fuzz_state, &calldata_fuzz_config, contract, func); + fuzz_contract_with_calldata(&fuzz_state, &fuzz_fixtures, contract, func); (sender, contract) }) }) @@ -164,7 +165,7 @@ fn select_random_function( /// for that function's input types. pub fn fuzz_contract_with_calldata( fuzz_state: &EvmFuzzState, - calldata_fuzz_config: &CalldataFuzzDictionary, + fuzz_fixtures: &FuzzFixtures, contract: Address, func: Function, ) -> impl Strategy { @@ -173,7 +174,7 @@ pub fn fuzz_contract_with_calldata( // `prop_oneof!` / `TupleUnion` `Arc`s for cheap cloning. #[allow(clippy::arc_with_non_send_sync)] prop_oneof![ - 60 => fuzz_calldata_with_config(func.clone(), Some(calldata_fuzz_config)), + 60 => fuzz_calldata(func.clone(), fuzz_fixtures), 40 => fuzz_calldata_from_state(func, fuzz_state), ] .prop_map(move |calldata| { diff --git a/crates/evm/fuzz/src/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs index 0e82a4d4b8d69..74cefca2ab371 100644 --- a/crates/evm/fuzz/src/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -8,14 +8,38 @@ mod param; pub use param::{fuzz_param, fuzz_param_from_state}; mod calldata; -pub use calldata::{ - fuzz_calldata, fuzz_calldata_with_config, CalldataFuzzDictionary, CalldataFuzzDictionaryConfig, -}; +pub use calldata::{fuzz_calldata, fuzz_calldata_from_state}; mod state; -pub use state::{ - build_initial_state, collect_created_contracts, fuzz_calldata_from_state, EvmFuzzState, -}; +pub use state::{build_initial_state, collect_created_contracts, EvmFuzzState}; mod invariants; pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call_strat}; + +/// Macro to create strategy with fixtures. +/// 1. A default strategy if no fixture defined for current parameter. +/// 2. A weighted strategy that use fixtures and default strategy values for current parameter. +/// If fixture is not of the same type as fuzzed parameter then value is rejected and error raised. +macro_rules! fixture_strategy { + ($fixtures:ident, $strategy_value:expr, $default_strategy:expr) => { + if let Some(fixtures) = $fixtures { + proptest::prop_oneof![ + 50 => { + let custom_fixtures: Vec = + fixtures.iter().enumerate().map(|(_, value)| value.to_owned()).collect(); + let custom_fixtures_len = custom_fixtures.len(); + any::() + .prop_filter_map("invalid fixture", move |index| { + let index = index.index(custom_fixtures_len); + $strategy_value(custom_fixtures.get(index)) + }) + }, + 50 => $default_strategy + ].boxed() + } else { + $default_strategy.boxed() + } + }; +} + +pub(crate) use fixture_strategy; diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 20e69a27e7255..12904cb005699 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -1,5 +1,5 @@ use super::state::EvmFuzzState; -use crate::strategies::calldata::CalldataFuzzDictionary; +use crate::strategies::fixture_strategy; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{Address, B256, I256, U256}; use proptest::prelude::*; @@ -7,68 +7,105 @@ use proptest::prelude::*; /// The max length of arrays we fuzz for is 256. const MAX_ARRAY_LEN: usize = 256; -/// Given a parameter type, returns a strategy for generating values for that type. +/// Given a parameter type and configured fixtures for param name, returns a strategy for generating +/// values for that type. Fixtures can be currently generated for uint, int, address, bytes and +/// string types and are defined for parameter name. +/// +/// For example, fixtures for parameter `owner` of type `address` can be defined in a function with +/// a `function fixture_owner() public returns (address[] memory)` signature. +/// +/// Fixtures are matched on parameter name, hence fixtures defined in +/// `fixture_owner` function can be used in a fuzzed test function with a signature like +/// `function testFuzz_ownerAddress(address owner, uint amount)`. +/// +/// Fuzzer will reject value and raise error if the fixture type is not of the same type as +/// parameter to fuzz. /// /// Works with ABI Encoder v2 tuples. pub fn fuzz_param( param: &DynSolType, - config: Option<&CalldataFuzzDictionary>, + fuzz_fixtures: Option<&[DynSolValue]>, ) -> BoxedStrategy { match *param { DynSolType::Address => { - if let Some(config) = config { - let len = config.inner.addresses.len(); - if len > 0 { - let dict = config.inner.clone(); - // Create strategy to return random address from configured dictionary. - return any::() - .prop_map(move |index| { - let index = index.index(len); - DynSolValue::Address(dict.addresses[index]) - }) - .boxed(); - } - } - - // If no config for addresses dictionary then create unbounded addresses strategy. - any::
().prop_map(DynSolValue::Address).boxed() - } - DynSolType::Int(n @ 8..=256) => { - super::IntStrategy::new(n, vec![]).prop_map(move |x| DynSolValue::Int(x, n)).boxed() + fixture_strategy!( + fuzz_fixtures, + |fixture: Option<&DynSolValue>| { + if let Some(val @ DynSolValue::Address(_)) = fixture { + Some(val.clone()) + } else { + error!("{:?} is not a valid address fixture", fixture.unwrap()); + None + } + }, + DynSolValue::type_strategy(&DynSolType::Address) + ) } - DynSolType::Uint(n @ 8..=256) => { - super::UintStrategy::new(n, vec![]).prop_map(move |x| DynSolValue::Uint(x, n)).boxed() - } - DynSolType::Function | DynSolType::Bool | DynSolType::Bytes => { - DynSolValue::type_strategy(param).boxed() - } - DynSolType::FixedBytes(size @ 1..=32) => any::() - .prop_map(move |mut v| { - v[size..].fill(0); - DynSolValue::FixedBytes(v, size) - }) + DynSolType::Int(n @ 8..=256) => super::IntStrategy::new(n, fuzz_fixtures) + .prop_map(move |x| DynSolValue::Int(x, n)) .boxed(), - DynSolType::String => DynSolValue::type_strategy(param) - .prop_map(move |value| { + DynSolType::Uint(n @ 8..=256) => super::UintStrategy::new(n, fuzz_fixtures) + .prop_map(move |x| DynSolValue::Uint(x, n)) + .boxed(), + DynSolType::Function | DynSolType::Bool => DynSolValue::type_strategy(param).boxed(), + DynSolType::Bytes => { + fixture_strategy!( + fuzz_fixtures, + |fixture: Option<&DynSolValue>| { + if let Some(val @ DynSolValue::Bytes(_)) = fixture { + Some(val.clone()) + } else { + error!("{:?} is not a valid bytes fixture", fixture.unwrap()); + None + } + }, + DynSolValue::type_strategy(&DynSolType::Bytes) + ) + } + DynSolType::FixedBytes(size @ 1..=32) => fixture_strategy!( + fuzz_fixtures, + |fixture: Option<&DynSolValue>| { + if let Some(val @ DynSolValue::FixedBytes(_, _)) = fixture { + if let Some(val) = val.as_fixed_bytes() { + if val.1 == size { + return Some(DynSolValue::FixedBytes(B256::from_slice(val.0), val.1)) + } + } + } + error!("{:?} is not a valid fixed bytes fixture", fixture.unwrap()); + None + }, + DynSolValue::type_strategy(&DynSolType::FixedBytes(size)) + ), + DynSolType::String => fixture_strategy!( + fuzz_fixtures, + |fixture: Option<&DynSolValue>| { + if let Some(val @ DynSolValue::String(_)) = fixture { + Some(val.clone()) + } else { + error!("{:?} is not a valid string fixture", fixture.unwrap()); + None + } + }, + DynSolValue::type_strategy(&DynSolType::String).prop_map(move |value| { DynSolValue::String( value.as_str().unwrap().trim().trim_end_matches('\0').to_string(), ) }) - .boxed(), - + ), DynSolType::Tuple(ref params) => params .iter() - .map(|p| fuzz_param(p, config)) + .map(|p| fuzz_param(p, None)) .collect::>() .prop_map(DynSolValue::Tuple) .boxed(), DynSolType::FixedArray(ref param, size) => { - proptest::collection::vec(fuzz_param(param, config), size) + proptest::collection::vec(fuzz_param(param, None), size) .prop_map(DynSolValue::FixedArray) .boxed() } DynSolType::Array(ref param) => { - proptest::collection::vec(fuzz_param(param, config), 0..MAX_ARRAY_LEN) + proptest::collection::vec(fuzz_param(param, None), 0..MAX_ARRAY_LEN) .prop_map(DynSolValue::Array) .boxed() } @@ -174,7 +211,10 @@ pub fn fuzz_param_from_state( #[cfg(test)] mod tests { - use crate::strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state}; + use crate::{ + strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state}, + FuzzFixtures, + }; use foundry_common::abi::get_func; use foundry_config::FuzzDictionaryConfig; use revm::db::{CacheDB, EmptyDB}; @@ -186,7 +226,7 @@ mod tests { let db = CacheDB::new(EmptyDB::default()); let state = build_initial_state(&db, FuzzDictionaryConfig::default()); let strat = proptest::prop_oneof![ - 60 => fuzz_calldata(func.clone()), + 60 => fuzz_calldata(func.clone(), &FuzzFixtures::default()), 40 => fuzz_calldata_from_state(func, &state), ]; let cfg = proptest::test_runner::Config { failure_persistence: None, ..Default::default() }; diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 2c5e98d9c39af..2ee3f7fca1817 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,14 +1,10 @@ -use super::fuzz_param_from_state; use crate::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}; -use alloy_dyn_abi::JsonAbiExt; -use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes, Log, B256, U256}; +use alloy_primitives::{Address, Log, B256, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; use indexmap::IndexSet; use parking_lot::{lock_api::RwLockReadGuard, RawRwLock, RwLock}; -use proptest::prelude::{BoxedStrategy, Strategy}; use revm::{ db::{CacheDB, DatabaseRef}, interpreter::opcode::{self, spec_opcode_gas}, @@ -181,29 +177,6 @@ impl FuzzDictionary { } } -/// Given a function and some state, it returns a strategy which generated valid calldata for the -/// given function's input types, based on state taken from the EVM. -pub fn fuzz_calldata_from_state(func: Function, state: &EvmFuzzState) -> BoxedStrategy { - let strats = func - .inputs - .iter() - .map(|input| fuzz_param_from_state(&input.selector_type().parse().unwrap(), state)) - .collect::>(); - strats - .prop_map(move |values| { - func.abi_encode_input(&values) - .unwrap_or_else(|_| { - panic!( - "Fuzzer generated invalid arguments for function `{}` with inputs {:?}: {:?}", - func.name, func.inputs, values - ) - }) - .into() - }) - .no_shrink() - .boxed() -} - /// Builds the initial [EvmFuzzState] from a database. pub fn build_initial_state( db: &CacheDB, diff --git a/crates/evm/fuzz/src/strategies/uint.rs b/crates/evm/fuzz/src/strategies/uint.rs index 7b9aac1d49ed9..1b1eb2540499a 100644 --- a/crates/evm/fuzz/src/strategies/uint.rs +++ b/crates/evm/fuzz/src/strategies/uint.rs @@ -1,3 +1,4 @@ +use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::U256; use proptest::{ strategy::{NewTree, Strategy, ValueTree}, @@ -71,12 +72,20 @@ impl ValueTree for UintValueTree { /// param). Then generate a value for this bit size. /// 2. Generate a random value around the edges (+/- 3 around 0 and max possible value) /// 3. Generate a value from a predefined fixtures set +/// +/// To define uint fixtures: +/// - return an array of possible values for a parameter named `amount` declare a function +/// `function fixture_amount() public returns (uint32[] memory)`. +/// - use `amount` named parameter in fuzzed test in order to include fixtures in fuzzed values +/// `function testFuzz_uint32(uint32 amount)`. +/// +/// If fixture is not a valid uint type then error is raised and random value generated. #[derive(Debug)] pub struct UintStrategy { /// Bit size of uint (e.g. 256) bits: usize, /// A set of fixtures to be generated - fixtures: Vec, + fixtures: Vec, /// The weight for edge cases (+/- 3 around 0 and max possible value) edge_weight: usize, /// The weight for fixtures @@ -90,10 +99,10 @@ impl UintStrategy { /// #Arguments /// * `bits` - Size of uint in bits /// * `fixtures` - A set of fixed values to be generated (according to fixtures weight) - pub fn new(bits: usize, fixtures: Vec) -> Self { + pub fn new(bits: usize, fixtures: Option<&[DynSolValue]>) -> Self { Self { bits, - fixtures, + fixtures: Vec::from(fixtures.unwrap_or_default()), edge_weight: 10usize, fixtures_weight: 40usize, random_weight: 50usize, @@ -105,19 +114,27 @@ impl UintStrategy { // Choose if we want values around 0 or max let is_min = rng.gen_bool(0.5); let offset = U256::from(rng.gen_range(0..4)); - let max = - if self.bits < 256 { (U256::from(1) << self.bits) - U256::from(1) } else { U256::MAX }; - let start = if is_min { offset } else { max.saturating_sub(offset) }; + let start = if is_min { offset } else { self.type_max().saturating_sub(offset) }; Ok(UintValueTree::new(start, false)) } fn generate_fixtures_tree(&self, runner: &mut TestRunner) -> NewTree { - // generate edge cases if there's no fixtures + // generate random cases if there's no fixtures if self.fixtures.is_empty() { - return self.generate_edge_tree(runner) + return self.generate_random_tree(runner) } - let idx = runner.rng().gen_range(0..self.fixtures.len()); - Ok(UintValueTree::new(self.fixtures[idx], false)) + + // Generate value tree from fixture. + let fixture = &self.fixtures[runner.rng().gen_range(0..self.fixtures.len())]; + if let Some(uint_fixture) = fixture.as_uint() { + if uint_fixture.1 == self.bits { + return Ok(UintValueTree::new(uint_fixture.0, false)); + } + } + + // If fixture is not a valid type, raise error and generate random value. + error!("{:?} is not a valid {} fixture", fixture, DynSolType::Uint(self.bits)); + self.generate_random_tree(runner) } fn generate_random_tree(&self, runner: &mut TestRunner) -> NewTree { @@ -151,6 +168,14 @@ impl UintStrategy { Ok(UintValueTree::new(start, false)) } + + fn type_max(&self) -> U256 { + if self.bits < 256 { + (U256::from(1) << self.bits) - U256::from(1) + } else { + U256::MAX + } + } } impl Strategy for UintStrategy { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 72835f097c920..ed0c1305cb7bc 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -254,7 +254,7 @@ impl TestArgs { let profiles = get_available_profiles(toml)?; let test_options: TestOptions = TestOptionsBuilder::default() - .fuzz(config.clone().fuzz) + .fuzz(config.fuzz.clone()) .invariant(config.invariant) .profiles(profiles) .build(&output, project_root)?; diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 04f397c4834c2..2dd5508e85d69 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -9,7 +9,7 @@ use foundry_evm::{ coverage::HitMaps, debug::DebugArena, executors::EvmError, - fuzz::{CounterExample, FuzzCase}, + fuzz::{CounterExample, FuzzCase, FuzzFixtures}, traces::{CallTraceArena, CallTraceDecoder, TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; @@ -534,6 +534,8 @@ pub struct TestSetup { pub reason: Option, /// Coverage info during setup pub coverage: Option, + /// Defined fuzz test fixtures + pub fuzz_fixtures: FuzzFixtures, } impl TestSetup { @@ -566,8 +568,9 @@ impl TestSetup { traces: Traces, labeled_addresses: HashMap, coverage: Option, + fuzz_fixtures: FuzzFixtures, ) -> Self { - Self { address, logs, traces, labeled_addresses, reason: None, coverage } + Self { address, logs, traces, labeled_addresses, reason: None, coverage, fuzz_fixtures } } pub fn failed_with( @@ -583,6 +586,7 @@ impl TestSetup { labeled_addresses, reason: Some(reason), coverage: None, + fuzz_fixtures: FuzzFixtures::default(), } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index ad335e7674808..ed48bdc34494b 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -5,6 +5,7 @@ use crate::{ result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, }; +use alloy_dyn_abi::DynSolValue; use alloy_json_abi::Function; use alloy_primitives::{Address, U256}; use eyre::Result; @@ -20,9 +21,9 @@ use foundry_evm::{ executors::{ fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, invariant::{replay_run, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult}, - EvmError, ExecutionErr, Executor, RawCallResult, + CallResult, EvmError, ExecutionErr, Executor, RawCallResult, }, - fuzz::{invariant::InvariantContract, CounterExample}, + fuzz::{fixture_name, invariant::InvariantContract, CounterExample, FuzzFixtures}, traces::{load_contracts, TraceKind}, }; use proptest::test_runner::TestRunner; @@ -166,14 +167,84 @@ impl<'a> ContractRunner<'a> { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(setup_logs); - TestSetup { address, logs, traces, labeled_addresses, reason, coverage } + TestSetup { + address, + logs, + traces, + labeled_addresses, + reason, + coverage, + fuzz_fixtures: self.fuzz_fixtures(address), + } } else { - TestSetup::success(address, logs, traces, Default::default(), None) + TestSetup::success( + address, + logs, + traces, + Default::default(), + None, + self.fuzz_fixtures(address), + ) }; Ok(setup) } + /// Collect fixtures from test contract. + /// + /// Fixtures can be defined: + /// - as storage arrays in test contract, prefixed with `fixture` + /// - as functions prefixed with `fixture` and followed by parameter name to be + /// fuzzed + /// + /// Storage array fixtures: + /// `uint256[] public fixture_amount = [1, 2, 3];` + /// define an array of uint256 values to be used for fuzzing `amount` named parameter in scope + /// of the current test. + /// + /// Function fixtures: + /// `function fixture_owner() public returns (address[] memory){}` + /// returns an array of addresses to be used for fuzzing `owner` named parameter in scope of the + /// current test. + fn fuzz_fixtures(&mut self, address: Address) -> FuzzFixtures { + let mut fixtures = HashMap::new(); + self.contract.abi.functions().filter(|func| func.is_fixture()).for_each(|func| { + if func.inputs.is_empty() { + // Read fixtures declared as functions. + if let Ok(CallResult { raw: _, decoded_result }) = + self.executor.call(CALLER, address, func, &[], U256::ZERO, None) + { + fixtures.insert(fixture_name(func.name.clone()), decoded_result); + } + } else { + // For reading fixtures from storage arrays we collect values by calling the + // function with incremented indexes until there's an error. + let mut vals = Vec::new(); + let mut index = 0; + loop { + if let Ok(CallResult { raw: _, decoded_result }) = self.executor.call( + CALLER, + address, + func, + &[DynSolValue::Uint(U256::from(index), 256)], + U256::ZERO, + None, + ) { + vals.push(decoded_result); + } else { + // No result returned for this index, we reached the end of storage + // array or the function is not a valid fixture. + break; + } + index += 1; + } + fixtures.insert(fixture_name(func.name.clone()), DynSolValue::Array(vals)); + }; + }); + + FuzzFixtures::new(fixtures) + } + /// Runs all tests for a contract whose names match the provided regular expression pub fn run_tests( mut self, @@ -442,7 +513,8 @@ impl<'a> ContractRunner<'a> { identified_contracts: &ContractsByAddress, ) -> TestResult { trace!(target: "forge::test::fuzz", "executing invariant test for {:?}", func.name); - let TestSetup { address, logs, traces, labeled_addresses, coverage, .. } = setup; + let TestSetup { address, logs, traces, labeled_addresses, coverage, fuzz_fixtures, .. } = + setup; // First, run the test normally to see if it needs to be skipped. let start = Instant::now(); @@ -479,7 +551,7 @@ impl<'a> ContractRunner<'a> { InvariantContract { address, invariant_function: func, abi: &self.contract.abi }; let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs, gas_report_traces } = - match evm.invariant_fuzz(invariant_contract.clone()) { + match evm.invariant_fuzz(invariant_contract.clone(), &fuzz_fixtures) { Ok(x) => x, Err(e) => { return TestResult { @@ -587,7 +659,13 @@ impl<'a> ContractRunner<'a> { let _guard = span.enter(); let TestSetup { - address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. + address, + mut logs, + mut traces, + mut labeled_addresses, + mut coverage, + fuzz_fixtures, + .. } = setup; // Run fuzz test @@ -598,7 +676,8 @@ impl<'a> ContractRunner<'a> { self.sender, fuzz_config.clone(), ); - let result = fuzzed_executor.fuzz(func, address, should_fail, self.revert_decoder); + let result = + fuzzed_executor.fuzz(func, &fuzz_fixtures, address, should_fail, self.revert_decoder); let mut debug = Default::default(); let mut breakpoints = Default::default(); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index efbd95d7103ea..e03272ea80ca9 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -139,7 +139,13 @@ async fn test_invariant() { ), ( "default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", - vec![("invariant_owner_never_changes()", true, None, None, None)], + vec![( + "invariant_owner_never_changes()", + false, + Some("".into()), + None, + None, + )], ), ( "default/fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", @@ -157,6 +163,16 @@ async fn test_invariant() { "default/fuzz/invariant/target/FuzzedTargetContracts.t.sol:DynamicTargetContract", vec![("invariant_dynamic_targets()", true, None, None, None)], ), + ( + "default/fuzz/invariant/common/InvariantFixtures.t.sol:InvariantFixtures", + vec![( + "invariant_target_not_compromised()", + false, + Some("".into()), + None, + None, + )], + ), ]), ); } @@ -348,30 +364,13 @@ async fn test_invariant_preserve_state() { } #[tokio::test(flavor = "multi_thread")] -async fn test_invariant_calldata_fuzz_dictionary_addresses() { - // should not fail with default options (address dict not finite) +async fn test_invariant_with_address_fixture() { let mut runner = TEST_DATA_DEFAULT.runner(); let results = runner.test_collect(&Filter::new( ".*", ".*", ".*fuzz/invariant/common/InvariantCalldataDictionary.t.sol", )); - assert_multiple( - &results, - BTreeMap::from([( - "default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", - vec![("invariant_owner_never_changes()", true, None, None, None)], - )]), - ); - - // same test should fail when calldata address dict is bounded - // set address dictionary to single entry to fail fast - runner.test_options.invariant.dictionary.max_calldata_fuzz_dictionary_addresses = 1; - let results = runner.test_collect(&Filter::new( - ".*", - ".*", - ".*fuzz/invariant/common/InvariantCalldataDictionary.t.sol", - )); assert_multiple( &results, BTreeMap::from([( @@ -407,6 +406,8 @@ async fn test_invariant_assume_does_not_revert() { async fn test_invariant_assume_respects_restrictions() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAssume.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.runs = 1; + runner.test_options.invariant.depth = 10; runner.test_options.invariant.max_assume_rejects = 1; let results = runner.test_collect(&filter); assert_multiple( @@ -471,3 +472,25 @@ async fn test_invariant_fuzzed_selected_targets() { ]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_fixtures() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantFixtures.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.runs = 1; + runner.test_options.invariant.depth = 100; + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantFixtures.t.sol:InvariantFixtures", + vec![( + "invariant_target_not_compromised()", + false, + Some("".into()), + None, + None, + )], + )]), + ); +} diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index f65a3c116222e..27f5749904ffd 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -87,7 +87,6 @@ impl ForgeTestProfile { dictionary_weight: 40, max_fuzz_dictionary_addresses: 10_000, max_fuzz_dictionary_values: 10_000, - max_calldata_fuzz_dictionary_addresses: 0, }, gas_report_samples: 256, failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), @@ -104,7 +103,6 @@ impl ForgeTestProfile { include_push_bytes: true, max_fuzz_dictionary_addresses: 10_000, max_fuzz_dictionary_values: 10_000, - max_calldata_fuzz_dictionary_addresses: 0, }, shrink_sequence: true, shrink_run_limit: 2usize.pow(18u32), diff --git a/testdata/default/fuzz/FuzzInt.t.sol b/testdata/default/fuzz/FuzzInt.t.sol index aac0825dbb5d9..071727f6da929 100644 --- a/testdata/default/fuzz/FuzzInt.t.sol +++ b/testdata/default/fuzz/FuzzInt.t.sol @@ -3,7 +3,8 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -// See https://github.com/foundry-rs/foundry/pull/735 for context +// https://github.com/foundry-rs/foundry/pull/735 behavior changed with https://github.com/foundry-rs/foundry/issues/3521 +// random values (instead edge cases) are generated if no fixtures defined contract FuzzNumbersTest is DSTest { function testPositive(int256) public { assertTrue(true); @@ -14,31 +15,31 @@ contract FuzzNumbersTest is DSTest { } function testNegative0(int256 val) public { - assertTrue(val != 0); + assertTrue(val == 0); } function testNegative1(int256 val) public { - assertTrue(val != -1); + assertTrue(val == -1); } function testNegative2(int128 val) public { - assertTrue(val != 1); + assertTrue(val == 1); } function testNegativeMax0(int256 val) public { - assertTrue(val != type(int256).max); + assertTrue(val == type(int256).max); } function testNegativeMax1(int256 val) public { - assertTrue(val != type(int256).max - 2); + assertTrue(val == type(int256).max - 2); } function testNegativeMin0(int256 val) public { - assertTrue(val != type(int256).min); + assertTrue(val == type(int256).min); } function testNegativeMin1(int256 val) public { - assertTrue(val != type(int256).min + 2); + assertTrue(val == type(int256).min + 2); } function testEquality(int256 x, int256 y) public { diff --git a/testdata/default/fuzz/FuzzUint.t.sol b/testdata/default/fuzz/FuzzUint.t.sol index 5ae90a57bba00..923c2980f2bc1 100644 --- a/testdata/default/fuzz/FuzzUint.t.sol +++ b/testdata/default/fuzz/FuzzUint.t.sol @@ -3,7 +3,8 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -// See https://github.com/foundry-rs/foundry/pull/735 for context +// https://github.com/foundry-rs/foundry/pull/735 behavior changed with https://github.com/foundry-rs/foundry/issues/3521 +// random values (instead edge cases) are generated if no fixtures defined contract FuzzNumbersTest is DSTest { function testPositive(uint256) public { assertTrue(true); @@ -14,19 +15,19 @@ contract FuzzNumbersTest is DSTest { } function testNegative0(uint256 val) public { - assertTrue(val != 0); + assertTrue(val == 0); } function testNegative2(uint256 val) public { - assertTrue(val != 2); + assertTrue(val == 2); } function testNegative2Max(uint256 val) public { - assertTrue(val != type(uint256).max - 2); + assertTrue(val == type(uint256).max - 2); } function testNegativeMax(uint256 val) public { - assertTrue(val != type(uint256).max); + assertTrue(val == type(uint256).max); } function testEquality(uint256 x, uint256 y) public { diff --git a/testdata/default/fuzz/invariant/common/InvariantAssume.t.sol b/testdata/default/fuzz/invariant/common/InvariantAssume.t.sol index 4ac0d085c1800..9808a870f7228 100644 --- a/testdata/default/fuzz/invariant/common/InvariantAssume.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantAssume.t.sol @@ -8,7 +8,7 @@ contract Handler is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function doSomething(uint256 param) public { - vm.assume(param != 0); + vm.assume(param == 0); } } diff --git a/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol b/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol index e1486f9639e90..5387b020d37d6 100644 --- a/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol @@ -62,11 +62,14 @@ contract InvariantCalldataDictionary is DSTest { address owner; Owned owned; Handler handler; + address[] actors; function setUp() public { owner = address(this); owned = new Owned(); handler = new Handler(owned); + actors.push(owner); + actors.push(address(777)); } function targetSelectors() public returns (FuzzSelector[] memory) { @@ -78,6 +81,14 @@ contract InvariantCalldataDictionary is DSTest { return targets; } + function fixtureSender() external returns (address[] memory) { + return actors; + } + + function fixtureCandidate() external returns (address[] memory) { + return actors; + } + function invariant_owner_never_changes() public { assertEq(owned.owner(), owner); } diff --git a/testdata/default/fuzz/invariant/common/InvariantFixtures.t.sol b/testdata/default/fuzz/invariant/common/InvariantFixtures.t.sol new file mode 100644 index 0000000000000..b3f1e17cb2497 --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantFixtures.t.sol @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.0; + +import "ds-test/test.sol"; + +contract Target { + bool ownerFound; + bool amountFound; + bool magicFound; + bool keyFound; + bool backupFound; + bool extraStringFound; + + function fuzzWithFixtures( + address owner_, + uint256 _amount, + int32 magic, + bytes32 key, + bytes memory backup, + string memory extra + ) external { + if (owner_ == address(0x6B175474E89094C44Da98b954EedeAC495271d0F)) { + ownerFound = true; + } + if (_amount == 1122334455) amountFound = true; + if (magic == -777) magicFound = true; + if (key == "abcd1234") keyFound = true; + if (keccak256(backup) == keccak256("qwerty1234")) backupFound = true; + if (keccak256(abi.encodePacked(extra)) == keccak256(abi.encodePacked("112233aabbccdd"))) { + extraStringFound = true; + } + } + + function isCompromised() public view returns (bool) { + return ownerFound && amountFound && magicFound && keyFound && backupFound && extraStringFound; + } +} + +/// Try to compromise target contract by finding all accepted values using fixtures. +contract InvariantFixtures is DSTest { + Target target; + address[] public fixture_owner_ = [address(0x6B175474E89094C44Da98b954EedeAC495271d0F)]; + uint256[] public fixture_amount = [1, 2, 1122334455]; + + function setUp() public { + target = new Target(); + } + + function fixtureMagic() external returns (int32[2] memory) { + int32[2] memory magic; + magic[0] = -777; + magic[1] = 777; + return magic; + } + + function fixtureKey() external pure returns (bytes32[] memory) { + bytes32[] memory keyFixture = new bytes32[](1); + keyFixture[0] = "abcd1234"; + return keyFixture; + } + + function fixtureBackup() external pure returns (bytes[] memory) { + bytes[] memory backupFixture = new bytes[](1); + backupFixture[0] = "qwerty1234"; + return backupFixture; + } + + function fixtureExtra() external pure returns (string[] memory) { + string[] memory extraFixture = new string[](1); + extraFixture[0] = "112233aabbccdd"; + return extraFixture; + } + + function invariant_target_not_compromised() public { + assertEq(target.isCompromised(), false); + } +} From db64c3e61fc37934a352b4c5ad5a7feb3d2753e7 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 23 Apr 2024 11:44:15 +0200 Subject: [PATCH 0893/1963] chore: bump alloy chains (#7763) --- Cargo.lock | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 114b59a2a8e1a..0082e8412ebb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,9 +67,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40646aa7f01e396139cf0d6c3a7475eeb8094a0f41d8199f10860c8aef09d2f1" +checksum = "fe6c2674230e94ea98767550b02853bf7024b46f784827be95acfc5f5f1a445f" dependencies = [ "num_enum", "serde", @@ -5832,7 +5832,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.60", @@ -6518,15 +6518,6 @@ dependencies = [ "toml_edit 0.20.7", ] -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -8492,17 +8483,6 @@ dependencies = [ "winnow 0.5.40", ] -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.12" From bf853afe4be085f06e5ff673c33fb09e91390945 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:27:51 +0200 Subject: [PATCH 0894/1963] fix(cast): list all files in the keystore directory (#7766) --- crates/cast/bin/cmd/wallet/list.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/list.rs b/crates/cast/bin/cmd/wallet/list.rs index d4ca3f0134371..e534d5713088f 100644 --- a/crates/cast/bin/cmd/wallet/list.rs +++ b/crates/cast/bin/cmd/wallet/list.rs @@ -91,17 +91,17 @@ impl ListArgs { dunce::canonicalize(keystore_path)? }; - // list files within keystore dir - std::fs::read_dir(keystore_dir)?.flatten().for_each(|entry| { - let path = entry.path(); - if path.is_file() && path.extension().is_none() { + // List all files within the keystore directory. + for entry in std::fs::read_dir(keystore_dir)? { + let path = entry?.path(); + if path.is_file() { if let Some(file_name) = path.file_name() { if let Some(name) = file_name.to_str() { - println!("{} (Local)", name); + println!("{name} (Local)"); } } } - }); + } Ok(()) } From 6ff43857bbb38c1f0c7f8dec5db1fda802362c10 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 23 Apr 2024 18:29:13 +0200 Subject: [PATCH 0895/1963] fix(cast): ENS commands (#7765) --- crates/cast/bin/main.rs | 18 ++--- crates/cast/src/lib.rs | 47 ----------- crates/cast/tests/cli/main.rs | 34 ++++++++ crates/common/src/ens.rs | 147 ++++++++++++++++++++++------------ 4 files changed, 138 insertions(+), 108 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 8c0181367b70f..565cd6eda7a8f 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -11,7 +11,7 @@ use eyre::Result; use foundry_cli::{handler, prompt, stdin, utils}; use foundry_common::{ abi::get_event, - ens::ProviderEnsExt, + ens::{namehash, ProviderEnsExt}, fmt::{format_tokens, format_uint_exp}, fs, selectors::{ @@ -446,19 +446,19 @@ async fn main() -> Result<()> { // ENS CastSubcommand::Namehash { name } => { let name = stdin::unwrap_line(name)?; - println!("{}", SimpleCast::namehash(&name)?); + println!("{}", namehash(&name)); } CastSubcommand::LookupAddress { who, rpc, verify } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = stdin::unwrap_line(who)?; - let name = provider.lookup_address(who).await?; + let name = provider.lookup_address(&who).await?; if verify { let address = provider.resolve_name(&name).await?; eyre::ensure!( address == who, - "Forward lookup verification failed: got `{name:?}`, expected `{who:?}`" + "Reverse lookup verification failed: got `{address}`, expected `{who}`" ); } println!("{name}"); @@ -470,13 +470,13 @@ async fn main() -> Result<()> { let who = stdin::unwrap_line(who)?; let address = provider.resolve_name(&who).await?; if verify { - let name = provider.lookup_address(address).await?; - assert_eq!( - name, who, - "forward lookup verification failed. got {name}, expected {who}" + let name = provider.lookup_address(&address).await?; + eyre::ensure!( + name == who, + "Forward lookup verification failed: got `{name}`, expected `{who}`" ); } - println!("{}", address.to_checksum(None)); + println!("{address}"); } // Misc diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 338510eb94199..beb5e4dc3d6e7 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1676,53 +1676,6 @@ impl SimpleCast { Ok(location.to_string()) } - /// Converts ENS names to their namehash representation - /// [Namehash reference](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names) - /// [namehash-rust reference](https://github.com/InstateDev/namehash-rust/blob/master/src/lib.rs) - /// - /// # Example - /// - /// ``` - /// use cast::SimpleCast as Cast; - /// - /// assert_eq!( - /// Cast::namehash("")?, - /// "0x0000000000000000000000000000000000000000000000000000000000000000" - /// ); - /// assert_eq!( - /// Cast::namehash("eth")?, - /// "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae" - /// ); - /// assert_eq!( - /// Cast::namehash("foo.eth")?, - /// "0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f" - /// ); - /// assert_eq!( - /// Cast::namehash("sub.foo.eth")?, - /// "0x500d86f9e663479e5aaa6e99276e55fc139c597211ee47d17e1e92da16a83402" - /// ); - /// # Ok::<_, eyre::Report>(()) - /// ``` - pub fn namehash(ens: &str) -> Result { - let mut node = vec![0u8; 32]; - - if !ens.is_empty() { - let ens_lower = ens.to_lowercase(); - let mut labels: Vec<&str> = ens_lower.split('.').collect(); - labels.reverse(); - - for label in labels { - let mut label_hash = keccak256(label.as_bytes()); - node.append(&mut label_hash.to_vec()); - - label_hash = keccak256(node.as_slice()); - node = label_hash.to_vec(); - } - } - - Ok(hex::encode_prefixed(node)) - } - /// Keccak-256 hashes arbitrary data /// /// # Example diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index bdc17a2fa9101..c6f2b04501235 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,5 +1,6 @@ //! Contains various tests for checking cast commands +use alloy_primitives::{address, b256, Address, B256}; use foundry_test_utils::{ casttest, rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}, @@ -794,3 +795,36 @@ interface Interface { }"#; assert_eq!(output.trim(), s); }); + +const ENS_NAME: &str = "emo.eth"; +const ENS_NAMEHASH: B256 = + b256!("0a21aaf2f6414aa664deb341d1114351fdb023cad07bf53b28e57c26db681910"); +const ENS_ADDRESS: Address = address!("28679A1a632125fbBf7A68d850E50623194A709E"); + +casttest!(ens_namehash, |_prj, cmd| { + cmd.args(["namehash", ENS_NAME]); + let out = cmd.stdout_lossy().trim().parse::(); + assert_eq!(out, Ok(ENS_NAMEHASH)); +}); + +casttest!(ens_lookup, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + cmd.args(["lookup-address", &ENS_ADDRESS.to_string(), "--rpc-url", ð_rpc_url, "--verify"]); + let out = cmd.stdout_lossy(); + assert_eq!(out.trim(), ENS_NAME); +}); + +casttest!(ens_resolve, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + cmd.args(["resolve-name", ENS_NAME, "--rpc-url", ð_rpc_url, "--verify"]); + let out = cmd.stdout_lossy().trim().parse::
(); + assert_eq!(out, Ok(ENS_ADDRESS)); +}); + +casttest!(ens_resolve_no_dot_eth, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + let name = ENS_NAME.strip_suffix(".eth").unwrap(); + cmd.args(["resolve-name", name, "--rpc-url", ð_rpc_url, "--verify"]); + let (_out, err) = cmd.unchecked_output_lossy(); + assert!(err.contains("not found"), "{err:?}"); +}); diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index cb10583841319..131980f55fa86 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -1,30 +1,31 @@ //! ENS Name resolving utilities. + #![allow(missing_docs)] -use alloy_primitives::{address, keccak256, Address, B256}; + +use self::EnsResolver::EnsResolverInstance; +use alloy_primitives::{address, Address, Keccak256, B256}; use alloy_provider::{Network, Provider}; use alloy_sol_types::sol; use alloy_transport::Transport; use async_trait::async_trait; -use std::str::FromStr; - -use self::EnsResolver::EnsResolverInstance; +use std::{borrow::Cow, str::FromStr}; // ENS Registry and Resolver contracts. sol! { + /// ENS Registry contract. #[sol(rpc)] - // ENS Registry contract. contract EnsRegistry { /// Returns the resolver for the specified node. function resolver(bytes32 node) view returns (address); } + /// ENS Resolver interface. #[sol(rpc)] - // ENS Resolver interface. contract EnsResolver { - // Returns the address associated with the specified node. + /// Returns the address associated with the specified node. function addr(bytes32 node) view returns (address); - // Returns the name associated with an ENS node, for reverse records. + /// Returns the name associated with an ENS node, for reverse records. function name(bytes32 node) view returns (string); } } @@ -36,13 +37,19 @@ pub const ENS_REVERSE_REGISTRAR_DOMAIN: &str = "addr.reverse"; /// Error type for ENS resolution. #[derive(Debug, thiserror::Error)] -pub enum EnsResolutionError { - /// Failed to resolve ENS registry. - #[error("Failed to get resolver from ENS registry: {0}")] - EnsRegistryResolutionFailed(String), +pub enum EnsError { + /// Failed to get resolver from the ENS registry. + #[error("Failed to get resolver from the ENS registry: {0}")] + Resolver(alloy_contract::Error), + /// Failed to get resolver from the ENS registry. + #[error("ENS resolver not found for name {0:?}")] + ResolverNotFound(String), + /// Failed to lookup ENS name from an address. + #[error("Failed to lookup ENS name from an address: {0}")] + Lookup(alloy_contract::Error), /// Failed to resolve ENS name to an address. #[error("Failed to resolve ENS name to an address: {0}")] - EnsResolutionFailed(String), + Resolve(alloy_contract::Error), } /// ENS name or Ethereum Address. @@ -59,7 +66,7 @@ impl NameOrAddress { pub async fn resolve>( &self, provider: &P, - ) -> Result { + ) -> Result { match self { NameOrAddress::Name(name) => provider.resolve_name(name).await, NameOrAddress::Address(addr) => Ok(*addr), @@ -97,35 +104,36 @@ impl FromStr for NameOrAddress { } } +/// Extension trait for ENS contract calls. #[async_trait] pub trait ProviderEnsExt> { - async fn get_resolver(&self) -> Result, EnsResolutionError>; + /// Returns the resolver for the specified node. The `&str` is only used for error messages. + async fn get_resolver( + &self, + node: B256, + error_name: &str, + ) -> Result, EnsError>; - async fn resolve_name(&self, name: &str) -> Result { + /// Performs a forward lookup of an ENS name to an address. + async fn resolve_name(&self, name: &str) -> Result { let node = namehash(name); - let addr = self - .get_resolver() - .await? + let resolver = self.get_resolver(node, name).await?; + let addr = resolver .addr(node) .call() .await - .map_err(|err| EnsResolutionError::EnsResolutionFailed(err.to_string()))? + .map_err(EnsError::Resolve) + .inspect_err(|e| eprintln!("{e:?}"))? ._0; - Ok(addr) } - async fn lookup_address(&self, address: Address) -> Result { - let node = namehash(&reverse_address(address)); - let name = self - .get_resolver() - .await? - .name(node) - .call() - .await - .map_err(|err| EnsResolutionError::EnsResolutionFailed(err.to_string()))? - ._0; - + /// Performs a reverse lookup of an address to an ENS name. + async fn lookup_address(&self, address: &Address) -> Result { + let name = reverse_address(address); + let node = namehash(&name); + let resolver = self.get_resolver(node, &name).await?; + let name = resolver.name(node).call().await.map_err(EnsError::Lookup)?._0; Ok(name) } } @@ -137,15 +145,16 @@ where N: Network, T: Transport + Clone, { - async fn get_resolver(&self) -> Result, EnsResolutionError> { + async fn get_resolver( + &self, + node: B256, + error_name: &str, + ) -> Result, EnsError> { let registry = EnsRegistry::new(ENS_ADDRESS, self); - let address = registry - .resolver(namehash("eth")) - .call() - .await - .map_err(|err| EnsResolutionError::EnsRegistryResolutionFailed(err.to_string()))? - ._0; - + let address = registry.resolver(node).call().await.map_err(EnsError::Resolver)?._0; + if address == Address::ZERO { + return Err(EnsError::ResolverNotFound(error_name.to_string())); + } Ok(EnsResolverInstance::new(address, self)) } } @@ -156,18 +165,36 @@ pub fn namehash(name: &str) -> B256 { return B256::ZERO } - // Remove the variation selector U+FE0F - let name = name.replace('\u{fe0f}', ""); - - // Generate the node starting from the right - name.rsplit('.') - .fold([0u8; 32], |node, label| *keccak256([node, *keccak256(label.as_bytes())].concat())) - .into() + // Remove the variation selector `U+FE0F` if present. + const VARIATION_SELECTOR: char = '\u{fe0f}'; + let name = if name.contains(VARIATION_SELECTOR) { + Cow::Owned(name.replace(VARIATION_SELECTOR, "")) + } else { + Cow::Borrowed(name) + }; + + // Generate the node starting from the right. + // This buffer is `[node @ [u8; 32], label_hash @ [u8; 32]]`. + let mut buffer = [0u8; 64]; + for label in name.rsplit('.') { + // node = keccak256([node, keccak256(label)]) + + // Hash the label. + let mut label_hasher = Keccak256::new(); + label_hasher.update(label.as_bytes()); + label_hasher.finalize_into(&mut buffer[32..]); + + // Hash both the node and the label hash, writing into the node. + let mut buffer_hasher = Keccak256::new(); + buffer_hasher.update(buffer.as_slice()); + buffer_hasher.finalize_into(&mut buffer[..32]); + } + buffer[..32].try_into().unwrap() } /// Returns the reverse-registrar name of an address. -pub fn reverse_address(addr: Address) -> String { - format!("{addr:?}.{ENS_REVERSE_REGISTRAR_DOMAIN}")[2..].to_string() +pub fn reverse_address(addr: &Address) -> String { + format!("{addr:x}.{ENS_REVERSE_REGISTRAR_DOMAIN}") } #[cfg(test)] @@ -175,19 +202,35 @@ mod test { use super::*; fn assert_hex(hash: B256, val: &str) { - assert_eq!(hash.0.to_vec(), hex::decode(val).unwrap()); + assert_eq!(hash.0[..], hex::decode(val).unwrap()[..]); } #[test] fn test_namehash() { for (name, expected) in &[ - ("", "0000000000000000000000000000000000000000000000000000000000000000"), - ("foo.eth", "de9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f"), + ("", "0x0000000000000000000000000000000000000000000000000000000000000000"), ("eth", "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae"), + ("foo.eth", "0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f"), ("alice.eth", "0x787192fc5378cc32aa956ddfdedbf26b24e8d78e40109add0eea2c1a012c3dec"), ("ret↩️rn.eth", "0x3de5f4c02db61b221e7de7f1c40e29b6e2f07eb48d65bf7e304715cd9ed33b24"), ] { assert_hex(namehash(name), expected); } } + + #[test] + fn test_reverse_address() { + for (addr, expected) in [ + ( + "0x314159265dd8dbb310642f98f50c066173c1259b", + "314159265dd8dbb310642f98f50c066173c1259b.addr.reverse", + ), + ( + "0x28679A1a632125fbBf7A68d850E50623194A709E", + "28679a1a632125fbbf7a68d850e50623194a709e.addr.reverse", + ), + ] { + assert_eq!(reverse_address(&addr.parse().unwrap()), expected, "{addr}"); + } + } } From 21dfde4df13fc2be8fe9ce2f1d6fd63023c2ed40 Mon Sep 17 00:00:00 2001 From: Krishang <93703995+kamuik16@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:23:10 +0530 Subject: [PATCH 0896/1963] feat(cheatcode): UintToHex cheatcode (#7767) uintToHex cheatcode --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 5 +++++ crates/cheatcodes/src/json.rs | 8 ++++++++ crates/evm/traces/src/decoder/mod.rs | 1 + testdata/cheats/Vm.sol | 1 + testdata/default/cheats/Json.t.sol | 1 + 6 files changed, 36 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 9ce73e931abe2..1c7781591e6cc 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7191,6 +7191,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "serializeUintToHex", + "description": "See `serializeJson`.", + "declaration": "function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeUintToHex(string,string,uint256)", + "selector": "0xae5a2ae8", + "selectorBytes": [ + 174, + 90, + 42, + 232 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "serializeUint_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 39f0fd8b0006e..44ee2534fec18 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1865,6 +1865,11 @@ interface Vm { returns (string memory json); /// See `serializeJson`. #[cheatcode(group = Json)] + function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value) + external + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] function serializeInt(string calldata objectKey, string calldata valueKey, int256 value) external returns (string memory json); diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index b837c8425051c..e493078a3262d 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -248,6 +248,14 @@ impl Cheatcode for serializeBytes_1Call { } } +impl Cheatcode for serializeUintToHexCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, value } = self; + let hex = format!("0x{:x}", value); + serialize_json(state, objectKey, Some(valueKey), &hex) + } +} + impl Cheatcode for writeJson_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { json, path } = self; diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index ad4e161cf9544..70720dc6c7085 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -441,6 +441,7 @@ impl CallTraceDecoder { "keyExistsJson" | "serializeBool" | "serializeUint" | + "serializeUintToHex" | "serializeInt" | "serializeAddress" | "serializeBytes32" | diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 02eeac480e333..01d2bd431f361 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -355,6 +355,7 @@ interface Vm { function serializeJson(string calldata objectKey, string calldata 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 setEnv(string calldata name, string calldata value) external; diff --git a/testdata/default/cheats/Json.t.sol b/testdata/default/cheats/Json.t.sol index b15292e15c7aa..ca53b18012978 100644 --- a/testdata/default/cheats/Json.t.sol +++ b/testdata/default/cheats/Json.t.sol @@ -224,6 +224,7 @@ contract WriteJsonTest is DSTest { vm.serializeBool(json1, "boolean", true); vm.serializeInt(json2, "key2", -234); vm.serializeUint(json2, "deploy", uint256(254)); + vm.serializeUintToHex(json2, "hexUint", uint256(255)); string memory data = vm.serializeBool(json2, "boolean", true); vm.serializeString(json2, "json1", data); emit log(data); From 7dfa26392c2e0f23270c965c39126370fc642941 Mon Sep 17 00:00:00 2001 From: "Du, Chengbin" Date: Wed, 24 Apr 2024 06:17:17 +0800 Subject: [PATCH 0897/1963] Fix contract create-and-verify with libraries (#7750) pass libraries to verify args --- crates/forge/bin/cmd/create.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 2212c4e9861f4..68b303362efdf 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -185,7 +185,7 @@ impl CreateArgs { skip_is_verified_check: true, watch: true, retry: self.retry, - libraries: vec![], + libraries: self.opts.libraries.clone(), root: None, verifier: self.verifier.clone(), via_ir: self.opts.via_ir, @@ -330,7 +330,7 @@ impl CreateArgs { skip_is_verified_check: false, watch: true, retry: self.retry, - libraries: vec![], + libraries: self.opts.libraries.clone(), root: None, verifier: self.verifier, via_ir: self.opts.via_ir, From e0ea59cae26d945445d9cf21fdf22f4a18ac5bb2 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:56:29 -0700 Subject: [PATCH 0898/1963] refactor: migrate cast doctests to alloy (#7768) * migrate: cast doctests to alloy * migrated: cast doctests to alloy * nits * use alloy_provider not helper fn --- crates/cast/src/lib.rs | 244 +++++++++++++++++++++++------------------ 1 file changed, 138 insertions(+), 106 deletions(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index beb5e4dc3d6e7..d63bbc33e370e 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -71,11 +71,12 @@ where /// # Example /// /// ``` + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use foundry_common::provider::alloy::get_http_provider; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = get_http_provider("http://localhost:8545"); + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// # Ok(()) /// # } @@ -88,25 +89,27 @@ where /// /// # Example /// - /// ```ignore - /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; - /// use foundry_common::provider::alloy::get_http_provider; + /// ``` + /// use alloy_primitives::{Address, U256, Bytes}; + /// use alloy_rpc_types::{TransactionRequest, WithOtherFields}; + /// use cast::Cast; + /// use alloy_provider::{RootProvider, ProviderBuilder, network::AnyNetwork}; /// use std::str::FromStr; + /// use alloy_sol_types::{sol, SolCall}; + /// + /// sol!( + /// function greeting(uint256 i) public returns (string); + /// ); /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; - /// let alloy_provider = get_http_provider("http://localhost:8545"); + /// let alloy_provider = ProviderBuilder::<_,_, AnyNetwork>::default().on_builtin("http://localhost:8545").await?;; /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; - /// let sig = "function greeting(uint256 i) public returns (string)"; - /// let args = vec!["5".to_owned()]; - /// let mut builder = - /// TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; - /// builder.set_args(sig, args).await?; - /// let builder_output = builder.build(); - /// let cast = Cast::new(provider, alloy_provider); - /// let data = cast.call(builder_output, None).await?; + /// let greeting = greetingCall { i: U256::from(5) }.abi_encode(); + /// let bytes = Bytes::from_iter(greeting.iter()); + /// let tx = TransactionRequest::default().to(Some(to)).input(bytes.into()); + /// let tx = WithOtherFields::new(tx); + /// let cast = Cast::new(alloy_provider); + /// let data = cast.call(&tx, None, None).await?; /// println!("{}", data); /// # Ok(()) /// # } @@ -159,23 +162,27 @@ where /// /// # Example /// - /// ```ignore - /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; + /// ``` + /// use cast::{Cast}; + /// use alloy_primitives::{Address, U256, Bytes}; + /// use alloy_rpc_types::{TransactionRequest, WithOtherFields}; + /// use alloy_provider::{RootProvider, ProviderBuilder, network::AnyNetwork}; /// use std::str::FromStr; + /// use alloy_sol_types::{sol, SolCall}; + /// + /// sol!( + /// function greeting(uint256 i) public returns (string); + /// ); /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = ProviderBuilder::<_,_, AnyNetwork>::default().on_builtin("http://localhost:8545").await?;; /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; - /// let sig = "greeting(uint256)(string)"; - /// let args = vec!["5".to_owned()]; - /// let mut builder = - /// TxBuilder::new(&provider, Address::zero(), Some(to), Chain::Mainnet, false).await?; - /// builder.set_args(sig, args).await?; - /// let builder_output = builder.peek(); + /// let greeting = greetingCall { i: U256::from(5) }.abi_encode(); + /// let bytes = Bytes::from_iter(greeting.iter()); + /// let tx = TransactionRequest::default().to(Some(to)).input(bytes.into()); + /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(&provider); - /// let access_list = cast.access_list(builder_output, None, false).await?; + /// let access_list = cast.access_list(&tx, None, false).await?; /// println!("{}", access_list); /// # Ok(()) /// # } @@ -215,27 +222,32 @@ where /// /// # Example /// - /// ```ignore - /// use cast::{Cast, TxBuilder}; - /// use ethers_core::types::{Address, U256}; - /// use ethers_providers::{Http, Provider}; + /// ``` + /// use cast::{Cast}; + /// use alloy_primitives::{Address, U256, Bytes}; + /// use alloy_rpc_types::{TransactionRequest, WithOtherFields}; + /// use alloy_provider::{RootProvider, ProviderBuilder, network::AnyNetwork}; /// use std::str::FromStr; + /// use alloy_sol_types::{sol, SolCall}; + /// + /// sol!( + /// function greet(string greeting) public; + /// ); /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; - /// let from = "vitalik.eth"; - /// let to = eAddress::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; - /// let sig = "greet(string)()"; - /// let args = vec!["hello".to_owned()]; + /// let provider = ProviderBuilder::<_,_, AnyNetwork>::default().on_builtin("http://localhost:8545").await?;; + /// let from = Address::from_str("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")?; + /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; + /// let greeting = greetCall { greeting: "hello".to_string() }.abi_encode(); + /// let bytes = Bytes::from_iter(greeting.iter()); /// let gas = U256::from_str("200000").unwrap(); /// let value = U256::from_str("1").unwrap(); /// let nonce = U256::from_str("1").unwrap(); - /// let mut builder = TxBuilder::new(&provider, from, Some(to), Chain::Mainnet, false).await?; - /// builder.set_args(sig, args).await?.set_gas(gas).set_value(value).set_nonce(nonce); - /// let builder_output = builder.build(); + /// let tx = TransactionRequest::default().to(Some(to)).input(bytes.into()).from(from); + /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(provider); - /// let data = cast.send(builder_output).await?; - /// println!("{}", *data); + /// let data = cast.send(tx).await?; + /// println!("{:#?}", data); /// # Ok(()) /// # } /// ``` @@ -252,12 +264,13 @@ where /// /// # Example /// - /// ```ignore + /// ``` + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let res = cast.publish("0x1234".to_string()).await?; /// println!("{:?}", res); @@ -280,12 +293,13 @@ where /// # Example /// - /// ```ignore + /// ``` + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let block = cast.block(5, true, None, false).await?; /// println!("{}", block); @@ -436,14 +450,15 @@ where /// # Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::Address; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; /// let nonce = cast.nonce(addr, None).await?; @@ -457,14 +472,15 @@ where /// # Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::Address; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; /// let implementation = cast.implementation(addr, None).await?; @@ -482,14 +498,15 @@ where /// # Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::Address; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; /// let admin = cast.admin(addr, None).await?; @@ -507,14 +524,15 @@ where /// # Example /// - /// ```ignore + /// ``` /// use alloy_primitives::{Address, U256}; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; /// let computed_address = cast.compute_address(addr, None).await?; @@ -529,14 +547,15 @@ where /// # Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::Address; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("0x00000000219ab540356cbb839cbe05303d7705fa")?; /// let code = cast.code(addr, None, false).await?; @@ -560,14 +579,15 @@ where /// Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::Address; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_core::types::Address; - /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("0x00000000219ab540356cbb839cbe05303d7705fa")?; /// let codesize = cast.codesize(addr, None).await?; @@ -582,12 +602,13 @@ where /// # Example /// - /// ```ignore + /// ``` + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let tx_hash = "0xf8d1713ea15a81482958fb7ddf884baee8d3bcc478c5f2f604e008dc788ee4fc"; /// let tx = cast.transaction(tx_hash.to_string(), None, false, false).await?; @@ -620,12 +641,13 @@ where /// # Example /// - /// ```ignore + /// ``` + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let tx_hash = "0xf8d1713ea15a81482958fb7ddf884baee8d3bcc478c5f2f604e008dc788ee4fc"; /// let receipt = cast.receipt(tx_hash.to_string(), None, 1, false, false).await?; @@ -679,12 +701,13 @@ where /// /// # Example /// - /// ```ignore + /// ``` + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_providers::{Http, Provider}; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let result = cast /// .rpc("eth_getBalance", &["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"]) @@ -708,17 +731,18 @@ where /// /// # Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::{Address, B256}; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; /// use cast::Cast; - /// use ethers_core::types::{Address, H256}; - /// use ethers_providers::{Http, Provider}; /// use std::str::FromStr; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("0x00000000006c3852cbEf3e08E8dF289169EdE581")?; - /// let slot = H256::zero(); + /// let slot = B256::ZERO; /// let storage = cast.storage(addr, slot, None).await?; /// println!("{}", storage); /// # Ok(()) @@ -763,23 +787,27 @@ where /// /// # Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::fixed_bytes; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; + /// use alloy_rpc_types::{BlockId, BlockNumberOrTag}; /// use cast::Cast; - /// use ethers_core::types::{BlockId, BlockNumber}; - /// use ethers_providers::{Http, Provider}; - /// use std::convert::TryFrom; + /// use std::{convert::TryFrom, str::FromStr}; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::::try_from("http://localhost:8545")?; + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// - /// let block_number = - /// cast.convert_block_number(Some(BlockId::Number(BlockNumber::from(5)))).await?; - /// assert_eq!(block_number, Some(BlockNumber::from(5))); + /// let block_number = cast.convert_block_number(Some(BlockId::number(5))).await?; + /// assert_eq!(block_number, Some(BlockNumberOrTag::Number(5))); /// - /// let block_number = - /// cast.convert_block_number(Some(BlockId::Hash("0x1234".parse().unwrap()))).await?; - /// assert_eq!(block_number, Some(BlockNumber::from(1234))); + /// let block_number = cast + /// .convert_block_number(Some(BlockId::hash(fixed_bytes!( + /// "0000000000000000000000000000000000000000000000000000000000001234" + /// )))) + /// .await?; + /// assert_eq!(block_number, Some(BlockNumberOrTag::Number(4660))); /// /// let block_number = cast.convert_block_number(None).await?; /// assert_eq!(block_number, None); @@ -806,14 +834,18 @@ where /// /// # Example /// - /// ```ignore + /// ``` + /// use alloy_primitives::Address; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; + /// use alloy_rpc_types::Filter; + /// use alloy_transport::BoxTransport; /// use cast::Cast; - /// use ethers_core::{abi::Address, types::Filter}; - /// use ethers_providers::{Provider, Ws}; + /// use foundry_common::provider::alloy::get_http_provider as get_ws_provider; /// use std::{io, str::FromStr}; /// /// # async fn foo() -> eyre::Result<()> { - /// let provider = Provider::new(Ws::connect("wss://localhost:8545").await?); + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("wss://localhost:8545").await?; /// let cast = Cast::new(provider); /// /// let filter = @@ -930,8 +962,8 @@ impl SimpleCast { /// # Example /// /// ``` + /// use alloy_primitives::{I256, U256}; /// use cast::SimpleCast; - /// use ethers_core::types::{I256, U256}; /// /// assert_eq!(SimpleCast::max_int("uint256")?, U256::MAX.to_string()); /// assert_eq!(SimpleCast::max_int("int256")?, I256::MAX.to_string()); @@ -947,8 +979,8 @@ impl SimpleCast { /// # Example /// /// ``` + /// use alloy_primitives::{I256, U256}; /// use cast::SimpleCast; - /// use ethers_core::types::{I256, U256}; /// /// assert_eq!(SimpleCast::min_int("uint256")?, "0"); /// assert_eq!(SimpleCast::min_int("int256")?, I256::MIN.to_string()); @@ -1025,8 +1057,8 @@ impl SimpleCast { /// Converts fixed point number into specified number of decimals /// ``` + /// use alloy_primitives::U256; /// use cast::SimpleCast as Cast; - /// use ethers_core::types::U256; /// /// assert_eq!(Cast::from_fixed_point("10", "0")?, "10"); /// assert_eq!(Cast::from_fixed_point("1.0", "1")?, "10"); @@ -1050,8 +1082,8 @@ impl SimpleCast { /// # Example /// /// ``` + /// use alloy_primitives::U256; /// use cast::SimpleCast as Cast; - /// use ethers_core::types::U256; /// /// assert_eq!(Cast::to_fixed_point("10", "0")?, "10."); /// assert_eq!(Cast::to_fixed_point("10", "1")?, "1.0"); @@ -1833,7 +1865,7 @@ impl SimpleCast { /// /// # Example /// - /// ```ignore + /// ``` /// use cast::SimpleCast as Cast; /// /// # async fn foo() -> eyre::Result<()> { From ad04f2392a76220abe288b4af7d5230f817be9b3 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:15:45 -0700 Subject: [PATCH 0899/1963] fix: change envExists return sig (#7774) * fix: change envExists return sig * update: cheats testdata --- crates/cheatcodes/assets/cheatcodes.json | 2 +- crates/cheatcodes/spec/src/vm.rs | 2 +- testdata/cheats/Vm.sol | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 1c7781591e6cc..f769b2f06254d 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3815,7 +3815,7 @@ "func": { "id": "envExists", "description": "Gets the environment variable `name` and returns true if it exists, else returns false.", - "declaration": "function envExists(string calldata name) external view returns (bool exists);", + "declaration": "function envExists(string calldata name) external view returns (bool result);", "visibility": "external", "mutability": "view", "signature": "envExists(string)", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 44ee2534fec18..e838298c73ebd 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1503,7 +1503,7 @@ interface Vm { /// Gets the environment variable `name` and returns true if it exists, else returns false. #[cheatcode(group = Environment)] - function envExists(string calldata name) external view returns (bool exists); + function envExists(string calldata name) external view returns (bool result); /// Gets the environment variable `name` and parses it as `bool`. /// Reverts if the variable was not found or could not be parsed. diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 01d2bd431f361..854f57d23f514 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -186,7 +186,7 @@ interface Vm { function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value); function envBytes(string calldata name) external view returns (bytes memory value); function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value); - function envExists(string calldata name) external view returns (bool exists); + function envExists(string calldata name) external view returns (bool result); function envInt(string calldata name) external view returns (int256 value); 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); From e01038f35750b4a41b1eda5a4ea3da976027eee2 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 24 Apr 2024 17:05:14 -0700 Subject: [PATCH 0900/1963] Bump alloy to use `get_receipt` hotfix (#7772) * bump alloy to include `get_receipt` hotfix * refactor: alloy bump breaking changes * fix(cast): doctests * fix(forge/tests): can_broadcast_script_skipping_simulation * fix(forge): create tests --- Cargo.lock | 80 ++++++++++---------- Cargo.toml | 51 +++++++------ crates/anvil/core/src/eth/transaction/mod.rs | 20 ++--- crates/anvil/src/eth/api.rs | 7 +- crates/anvil/src/eth/backend/fork.rs | 24 +++--- crates/anvil/src/eth/backend/mem/mod.rs | 8 +- crates/anvil/src/eth/pool/mod.rs | 4 +- crates/anvil/tests/it/api.rs | 7 +- crates/anvil/tests/it/fork.rs | 80 ++++++++++++-------- crates/anvil/tests/it/genesis.rs | 3 +- crates/anvil/tests/it/transaction.rs | 4 +- crates/anvil/tests/it/wsapi.rs | 3 +- crates/cast/bin/cmd/access_list.rs | 6 +- crates/cast/bin/cmd/call.rs | 9 ++- crates/cast/bin/cmd/estimate.rs | 10 +-- crates/cast/bin/cmd/mktx.rs | 4 +- crates/cast/bin/cmd/send.rs | 9 ++- crates/cast/bin/cmd/storage.rs | 3 +- crates/cast/bin/main.rs | 4 +- crates/cast/bin/tx.rs | 16 ++-- crates/cast/src/lib.rs | 39 +++++++--- crates/cheatcodes/src/inspector.rs | 4 +- crates/common/src/fmt/ui.rs | 2 +- crates/common/src/transactions.rs | 2 +- crates/evm/core/src/fork/backend.rs | 6 +- crates/forge/bin/cmd/create.rs | 13 ++-- crates/script/src/broadcast.rs | 16 +++- crates/script/src/lib.rs | 10 ++- crates/script/src/simulate.rs | 5 +- crates/script/src/transaction.rs | 4 +- crates/test-utils/Cargo.toml | 1 + crates/test-utils/src/script.rs | 23 ++++-- crates/verify/src/bytecode.rs | 5 +- crates/wallets/src/wallet_signer.rs | 8 +- 34 files changed, 284 insertions(+), 206 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0082e8412ebb2..a4ab4783e9a15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-eips", "alloy-primitives", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872f239c15befa27cc4f0d3d82a70b3365c2d0202562bf906eb93b299fa31882" +checksum = "22ab339ca7b4ea9115f0578c941abc80a171edf8e5eadd01e6c4237b68db8083" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-primitives", "alloy-serde", @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a35ddfd27576474322a5869e4c123e5f3e7b2177297c18e4e82ea501cb125b" +checksum = "44294729c145cf7ae65feab544b5b81fb2bb7e2fd060214842eb3989a1e9d882" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -169,7 +169,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-primitives", "serde", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-consensus", "alloy-eips", @@ -189,6 +189,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types", "alloy-signer", + "alloy-sol-types", "async-trait", "futures-utils-wasm", "thiserror", @@ -196,9 +197,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99bbad0a6b588ef4aec1b5ddbbfdacd9ef04e00b979617765b03174318ee1f3a" +checksum = "50c715249705afa1e32be79dabfd35e2ef0f1cc02ad2cf48c9d1e20026ee637b" dependencies = [ "alloy-rlp", "arbitrary", @@ -224,7 +225,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -255,7 +256,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -295,7 +296,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -319,7 +320,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-consensus", "alloy-eips", @@ -337,7 +338,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -349,7 +350,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-primitives", "serde", @@ -359,7 +360,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -374,7 +375,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-consensus", "alloy-network", @@ -391,7 +392,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-consensus", "alloy-network", @@ -408,7 +409,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-consensus", "alloy-network", @@ -424,7 +425,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-consensus", "alloy-network", @@ -442,9 +443,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "452d929748ac948a10481fff4123affead32c553cf362841c5103dd508bdfc16" +checksum = "bef9a94a27345fb31e3fcb5f5e9f592bb4847493b07fa1e47dd9fde2222f2e28" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -461,9 +462,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df64e094f6d2099339f9e82b5b38440b159757b6920878f28316243f8166c8d1" +checksum = "c31fe73cd259527e24dc2dbfe64bc95e5ddfcd2b2731f670a11ff72b2be2c25b" dependencies = [ "alloy-json-abi", "const-hex", @@ -478,18 +479,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715f4d09a330cc181fc7c361b5c5c2766408fa59a0bac60349dcb7baabd404cc" +checksum = "8c8d6e74e4feeaa2bcfdecfd3da247ab53c67bd654ba1907270c32e02b142331" dependencies = [ "winnow 0.6.6", ] [[package]] name = "alloy-sol-types" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43bc2d6dfc2a19fd56644494479510f98b1ee929e04cf0d4aa45e98baa3e545b" +checksum = "afaffed78bfb17526375754931e045f96018aa810844b29c7aef823266dd4b4b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -501,7 +502,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-json-rpc", "base64 0.22.0", @@ -519,7 +520,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -532,7 +533,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -550,7 +551,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=7629f79#7629f79e3ffb6abd0be901a06deed2ab9f695e4e" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -4050,6 +4051,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-provider", + "alloy-rpc-types", "eyre", "fd-lock 4.0.2", "foundry-common", @@ -5832,7 +5834,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.60", @@ -6971,7 +6973,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=413b892#413b892dd936d117c52d47ba07d195b09a7f1216" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=813d7e7#813d7e73a090d426935e63d9308bdd2c945a58c4" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -8071,9 +8073,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4497156948bd342b52038035a6fa514a89626e37af9d2c52a5e8d8ebcc7ee479" +checksum = "70aba06097b6eda3c15f6eebab8a6339e121475bcf08bbe6758807e716c372a1" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 4ef7befcbafc3..08b4080bfaa14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.3.18", default-features = false } # no default features to avoid c-kzg revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "413b892", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "813d7e7", features = [ "serde", ] } @@ -158,28 +158,28 @@ ethers-signers = { version = "2.0.14", default-features = false } ethers-middleware = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7629f79", default-features = false } -alloy-primitives = { version = "0.7.0", features = ["getrandom"] } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.0" alloy-json-abi = "0.7.0" alloy-sol-types = "0.7.0" @@ -192,7 +192,10 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 70f887f1e2e5c..2617266364bbc 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -58,12 +58,13 @@ pub fn transaction_request_to_typed( other, } = tx; + let to = if let Some(TxKind::Call(to)) = to { TxKind::Call(to) } else { TxKind::Create }; // Special case: OP-stack deposit tx if transaction_type == Some(126) { return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { from: from.unwrap_or_default(), source_hash: other.get_deserialized::("sourceHash")?.ok()?, - kind: to.into(), + kind: to, mint: other.get_deserialized::("mint")?.ok()?, value: value.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), @@ -92,10 +93,7 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, + to, chain_id: None, })) } @@ -108,10 +106,7 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, + to, chain_id: 0, access_list: access_list.unwrap_or_default(), })) @@ -129,16 +124,13 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to: match to { - Some(to) => TxKind::Call(to), - None => TxKind::Create, - }, + to, chain_id: 0, access_list: access_list.unwrap_or_default(), })) } // EIP4844 - (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), Some(to)) => { + (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), TxKind::Call(to)) => { let tx = TxEip4844 { nonce: nonce.unwrap_or_default(), max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 1ed664a349b51..10689de90f28b 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2025,9 +2025,9 @@ impl EthApi { fn convert(tx: Arc) -> TxpoolInspectSummary { let tx = &tx.pending_transaction.transaction; let to = tx.to(); - let gas_price = U256::from(tx.gas_price()); + let gas_price = tx.gas_price(); let value = tx.value(); - let gas = U256::from(tx.gas_limit()); + let gas = tx.gas_limit(); TxpoolInspectSummary { to, value, gas, gas_price } } @@ -2188,9 +2188,10 @@ impl EthApi { { // If the request is a simple native token transfer we can optimize // We assume it's a transfer if we have no input data. + let to = if let Some(TxKind::Call(to)) = request.to { Some(to) } else { None }; let likely_transfer = request.input.clone().into_input().is_none(); if likely_transfer { - if let Some(to) = request.to { + if let Some(to) = to { if let Ok(target_code) = self.backend.get_code_with_state(&state, to) { if target_code.as_ref().is_empty() { return Ok(MIN_TRANSACTION_GAS); diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 3727740cd51a7..0f4a04f86a817 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -1,8 +1,8 @@ //! Support for forking off another client use crate::eth::{backend::db::Db, error::BlockchainError}; -use alloy_primitives::{Address, Bytes, StorageValue, B256, U256, U64}; -use alloy_provider::Provider; +use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; +use alloy_provider::{debug::DebugApi, Provider}; use alloy_rpc_types::{ request::TransactionRequest, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, @@ -162,7 +162,7 @@ impl ClientFork { keys: Vec, block_number: Option, ) -> Result { - self.provider().get_proof(address, keys, block_number).await + self.provider().get_proof(address, keys, block_number.unwrap_or(BlockId::latest())).await } /// Sends `eth_call` @@ -172,7 +172,7 @@ impl ClientFork { block: Option, ) -> Result { let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().call(request, Some(block.into())).await?; + let res = self.provider().call(request, block.into()).await?; Ok(res) } @@ -184,7 +184,7 @@ impl ClientFork { block: Option, ) -> Result { let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().estimate_gas(request, Some(block.into())).await?; + let res = self.provider().estimate_gas(request, block.into()).await?; Ok(res) } @@ -195,7 +195,9 @@ impl ClientFork { request: &WithOtherFields, block: Option, ) -> Result { - self.provider().create_access_list(request, block.map(|b| b.into())).await + self.provider() + .create_access_list(request, block.unwrap_or(BlockNumber::Latest).into()) + .await } pub async fn storage_at( @@ -204,7 +206,9 @@ impl ClientFork { index: U256, number: Option, ) -> Result { - self.provider().get_storage_at(address, index, number.map(Into::into)).await + self.provider() + .get_storage_at(address, index, number.unwrap_or(BlockNumber::Latest).into()) + .await } pub async fn logs(&self, filter: &Filter) -> Result, TransportError> { @@ -245,12 +249,12 @@ impl ClientFork { blocknumber: u64, ) -> Result { trace!(target: "backend::fork", "get_balance={:?}", address); - self.provider().get_balance(address, Some(blocknumber.into())).await + self.provider().get_balance(address, blocknumber.into()).await } pub async fn get_nonce(&self, address: Address, block: u64) -> Result { trace!(target: "backend::fork", "get_nonce={:?}", address); - self.provider().get_transaction_count(address, Some(block.into())).await + self.provider().get_transaction_count(address, block.into()).await } pub async fn transaction_by_block_number_and_index( @@ -532,7 +536,7 @@ impl ClientFork { let mut uncles = Vec::with_capacity(block.uncles.len()); for (uncle_idx, _) in block.uncles.iter().enumerate() { let uncle = - match self.provider().get_uncle(block_number.into(), U64::from(uncle_idx)).await? { + match self.provider().get_uncle(block_number.into(), uncle_idx as u64).await? { Some(u) => u, None => return Ok(None), }; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 3b5fdc73f577a..1e82700ed87cf 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -35,7 +35,7 @@ use crate::{ NodeConfig, PrecompileFactory, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; -use alloy_primitives::{keccak256, Address, Bytes, TxHash, B256, U256, U64}; +use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256, U64}; use alloy_rpc_types::{ request::TransactionRequest, serde_helpers::JsonStorageKey, state::StateOverride, AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, @@ -1120,7 +1120,7 @@ impl Backend { let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); let caller = from.unwrap_or_default(); - + let to = if let Some(TxKind::Call(addr)) = to { Some(addr) } else { None }; env.tx = TxEnv { caller, gas_limit: gas_limit as u64, @@ -1223,7 +1223,7 @@ impl Backend { D: DatabaseRef, { let from = request.from.unwrap_or_default(); - let to = if let Some(to) = request.to { + let to = if let Some(TxKind::Call(to)) = request.to { to } else { let nonce = state.basic_ref(from)?.unwrap_or_default().nonce; @@ -2038,7 +2038,7 @@ impl Backend { let inner = TransactionReceipt { inner, transaction_hash: info.transaction_hash, - transaction_index: info.transaction_index, + transaction_index: Some(info.transaction_index), block_number: Some(block.header.number), gas_used: info.gas_used, contract_address: info.contract_address, diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index 6748855008c3a..ace226fe5e740 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -75,8 +75,8 @@ impl Pool { /// Returns the number of tx that are ready and queued for further execution pub fn txpool_status(&self) -> TxpoolStatus { // Note: naming differs here compared to geth's `TxpoolStatus` - let pending = U64::from(self.ready_transactions().count()); - let queued = U64::from(self.inner.read().pending_transactions.len()); + let pending = self.ready_transactions().count() as u64; + let queued = self.inner.read().pending_transactions.len() as u64; TxpoolStatus { pending, queued } } diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index acf9a0f9834a3..1afa76df1cbf5 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -4,7 +4,8 @@ use crate::{ abi::{MulticallContract, SimpleStorage}, utils::ethers_http_provider, }; -use alloy_primitives::{Address as rAddress, B256, U256 as rU256}; +use alloy_eips::BlockId; +use alloy_primitives::{Address as rAddress, TxKind, B256, U256 as rU256}; use alloy_provider::Provider; use alloy_rpc_types::{ request::{TransactionInput as CallInput, TransactionRequest as CallRequest}, @@ -45,7 +46,7 @@ async fn can_dev_get_balance() { let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { - let balance = provider.get_balance(acc, None).await.unwrap(); + let balance = provider.get_balance(acc, BlockId::latest()).await.unwrap(); assert_eq!(balance, genesis_balance); } } @@ -246,7 +247,7 @@ where .call( WithOtherFields::new(CallRequest { input: CallInput::maybe_input(call.tx.data().cloned().map(|b| b.0.into())), - to: Some(to.to_alloy()), + to: Some(TxKind::Call(to.to_alloy())), ..Default::default() }), None, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 717e0c57828c4..f22d22a917045 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -4,11 +4,11 @@ use crate::{ abi::*, utils::{self, ethers_http_provider}, }; -use alloy_primitives::{address, U256 as rU256}; +use alloy_primitives::{address, TxKind, U256 as rU256}; use alloy_provider::Provider as AlloyProvider; use alloy_rpc_types::{ request::{TransactionInput, TransactionRequest as CallRequest}, - BlockNumberOrTag, WithOtherFields, + BlockId, BlockNumberOrTag, WithOtherFields, }; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; @@ -273,8 +273,8 @@ async fn test_fork_snapshotting() { let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); - let balance_before = provider.get_balance(to, None).await.unwrap(); + let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); let provider = ethers_http_provider(&handle.http_endpoint()); @@ -287,18 +287,18 @@ async fn test_fork_snapshotting() { let provider = handle.http_provider(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, None).await.unwrap(); + let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); assert!(api.evm_revert(snapshot).await.unwrap()); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce); - let balance = provider.get_balance(from, None).await.unwrap(); + let balance = provider.get_balance(from, BlockId::latest()).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); - let balance = provider.get_balance(to, None).await.unwrap(); + let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); assert_eq!(block_number, provider.get_block_number().await.unwrap()); } @@ -315,8 +315,8 @@ async fn test_fork_snapshotting_repeated() { let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); - let balance_before = provider.get_balance(to, None).await.unwrap(); + let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); let amount = handle.genesis_balance().checked_div(rU256::from(92u64)).unwrap(); let tx = TransactionRequest::new() @@ -326,20 +326,20 @@ async fn test_fork_snapshotting_repeated() { let tx_provider = ethers_http_provider(&handle.http_endpoint()); let _ = tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, None).await.unwrap(); + let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); let _second_snapshot = api.evm_snapshot().await.unwrap(); assert!(api.evm_revert(snapshot).await.unwrap()); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce); - let balance = provider.get_balance(from, None).await.unwrap(); + let balance = provider.get_balance(from, BlockId::latest()).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); - let balance = provider.get_balance(to, None).await.unwrap(); + let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); assert_eq!(block_number, provider.get_block_number().await.unwrap()); @@ -366,8 +366,8 @@ async fn test_fork_snapshotting_blocks() { let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); - let balance_before = provider.get_balance(to, None).await.unwrap(); + let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); // send the transaction @@ -380,26 +380,29 @@ async fn test_fork_snapshotting_blocks() { let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, None).await.unwrap(); + let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); // revert snapshot assert!(api.evm_revert(snapshot).await.unwrap()); - assert_eq!(initial_nonce, provider.get_transaction_count(from, None).await.unwrap()); + assert_eq!( + initial_nonce, + provider.get_transaction_count(from, BlockId::latest()).await.unwrap() + ); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number); // repeat transaction let _ = tx_provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); // revert again: nothing to revert since snapshot gone assert!(!api.evm_revert(snapshot).await.unwrap()); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); @@ -469,31 +472,46 @@ async fn can_reset_properly() { let origin_nonce = 1u64; origin_api.anvil_set_nonce(account, rU256::from(origin_nonce)).await.unwrap(); - assert_eq!(origin_nonce, origin_provider.get_transaction_count(account, None).await.unwrap()); + assert_eq!( + origin_nonce, + origin_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() + ); let (fork_api, fork_handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some(origin_handle.http_endpoint()))).await; let fork_provider = fork_handle.http_provider(); let fork_tx_provider = ethers_http_provider(&fork_handle.http_endpoint()); - assert_eq!(origin_nonce, fork_provider.get_transaction_count(account, None).await.unwrap()); + assert_eq!( + origin_nonce, + fork_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() + ); let to = Address::random(); - let to_balance = fork_provider.get_balance(to.to_alloy(), None).await.unwrap(); + let to_balance = fork_provider.get_balance(to.to_alloy(), BlockId::latest()).await.unwrap(); let tx = TransactionRequest::new().from(account.to_ethers()).to(to).value(1337u64); let tx = fork_tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); // nonce incremented by 1 - assert_eq!(origin_nonce + 1, fork_provider.get_transaction_count(account, None).await.unwrap()); + assert_eq!( + origin_nonce + 1, + fork_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() + ); // resetting to origin state fork_api.anvil_reset(Some(Forking::default())).await.unwrap(); // nonce reset to origin - assert_eq!(origin_nonce, fork_provider.get_transaction_count(account, None).await.unwrap()); + assert_eq!( + origin_nonce, + fork_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() + ); // balance is reset - assert_eq!(to_balance, fork_provider.get_balance(to.to_alloy(), None).await.unwrap()); + assert_eq!( + to_balance, + fork_provider.get_balance(to.to_alloy(), BlockId::latest()).await.unwrap() + ); // tx does not exist anymore assert!(fork_tx_provider.get_transaction(tx.transaction_hash).await.is_err()) @@ -790,7 +808,7 @@ async fn test_fork_call() { let res1 = api .call( WithOtherFields::new(CallRequest { - to: Some(to.to_alloy()), + to: Some(TxKind::Call(to.to_alloy())), input: input.to_alloy().into(), ..Default::default() }), @@ -1179,7 +1197,7 @@ async fn test_fork_execution_reverted() { let resp = api .call( WithOtherFields::new(CallRequest { - to: Some(address!("Fd6CC4F251eaE6d02f9F7B41D1e80464D3d2F377")), + to: Some(TxKind::Call(address!("Fd6CC4F251eaE6d02f9F7B41D1e80464D3d2F377"))), input: TransactionInput::new("0x8f283b3c".as_bytes().into()), ..Default::default() }), diff --git a/crates/anvil/tests/it/genesis.rs b/crates/anvil/tests/it/genesis.rs index 0b243db3edb9c..c8157e1601649 100644 --- a/crates/anvil/tests/it/genesis.rs +++ b/crates/anvil/tests/it/genesis.rs @@ -2,6 +2,7 @@ use std::str::FromStr; +use alloy_eips::BlockId; use alloy_genesis::Genesis; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; @@ -44,7 +45,7 @@ async fn can_apply_genesis() { assert_eq!(provider.get_chain_id().await.unwrap(), 19763u64); let addr: Address = Address::from_str("71562b71999873db5b286df957af199ec94617f7").unwrap(); - let balance = provider.get_balance(addr, None).await.unwrap(); + let balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); let expected: U256 = U256::from_str_radix("ffffffffffffffffffffffffff", 16).unwrap(); assert_eq!(balance, expected); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 46c059374c602..6dfae6a8d2a7a 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -963,7 +963,7 @@ async fn estimates_gas_on_pending_by_default() { let tx = AlloyTransactionRequest::default() .from(recipient.to_alloy()) - .to(Some(sender.to_alloy())) + .to(sender.to_alloy()) .value(rU256::from(1e10)) .input(Bytes::from(vec![0x42]).into()); api.estimate_gas(WithOtherFields::new(tx), None, None).await.unwrap(); @@ -979,7 +979,7 @@ async fn test_estimate_gas() { let tx = AlloyTransactionRequest::default() .from(recipient.to_alloy()) - .to(Some(sender.to_alloy())) + .to(sender.to_alloy()) .value(rU256::from(1e10)) .input(Bytes::from(vec![0x42]).into()); // Expect the gas estimation to fail due to insufficient funds. diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index ce0c4d6a43877..58bad12ebcef6 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -1,5 +1,6 @@ //! general eth api tests with websocket provider +use alloy_eips::BlockId; use alloy_provider::Provider; use anvil::{spawn, NodeConfig}; use ethers::types::U256; @@ -24,7 +25,7 @@ async fn can_dev_get_balance_ws() { let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { - let balance = provider.get_balance(acc, None).await.unwrap(); + let balance = provider.get_balance(acc, BlockId::latest()).await.unwrap(); assert_eq!(balance, genesis_balance); } } diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index ed572628de66f..d344017f629df 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -1,5 +1,5 @@ use alloy_network::{AnyNetwork, TransactionBuilder}; -use alloy_primitives::Address; +use alloy_primitives::{Address, Bytes}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use alloy_transport::Transport; @@ -105,7 +105,7 @@ async fn access_list, T: Transport + Clone>( to_json: bool, ) -> Result<()> { let mut req = WithOtherFields::::default() - .with_to(to.into()) + .with_to(to.unwrap_or_default()) .with_from(from) .with_value(tx.value.unwrap_or_default()) .with_chain_id(chain.id()); @@ -127,7 +127,7 @@ async fn access_list, T: Transport + Clone>( Vec::new() }; - req.set_input(data.into()); + req.set_input::(data.into()); let cast = Cast::new(&provider); diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index eeb09d5c0442e..32b4ec794e2b4 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,5 +1,5 @@ use alloy_network::TransactionBuilder; -use alloy_primitives::U256; +use alloy_primitives::{Bytes, TxKind, U256}; use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use cast::Cast; use clap::Parser; @@ -122,7 +122,7 @@ impl CallArgs { }; let mut req = WithOtherFields::::default() - .with_to(to.into()) + .with_to(to.unwrap_or_default()) .with_from(sender) .with_value(tx.value.unwrap_or_default()); @@ -209,9 +209,10 @@ impl CallArgs { let mut executor = TracingExecutor::new(env, fork, evm_version, debug); + let to = if let Some(TxKind::Call(to)) = req.to { Some(to) } else { None }; let trace = TraceResult::from(executor.call_raw_committing( sender, - req.to.expect("an address to be here"), + to.expect("an address to be here"), data.into(), req.value.unwrap_or_default(), )?); @@ -225,7 +226,7 @@ impl CallArgs { } }; - req.set_input(data.into()); + req.set_input::(data.into()); println!("{}", Cast::new(provider).call(&req, func.as_ref(), block).await?); diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 55149937b8a6c..6ee33ed267154 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,7 +1,7 @@ use alloy_network::TransactionBuilder; -use alloy_primitives::U256; +use alloy_primitives::{Bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use clap::Parser; use eyre::Result; use foundry_cli::{ @@ -94,7 +94,7 @@ impl EstimateArgs { }; let mut req = WithOtherFields::::default() - .with_to(to.into()) + .with_to(to.unwrap_or_default()) .with_from(from) .with_value(value.unwrap_or_default()); @@ -121,9 +121,9 @@ impl EstimateArgs { } }; - req.set_input(data.into()); + req.set_input::(data.into()); - let gas = provider.estimate_gas(&req, None).await?; + let gas = provider.estimate_gas(&req, BlockId::latest()).await?; println!("{gas}"); Ok(()) } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index def6d46f4b27d..e26115da32ab5 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -2,6 +2,7 @@ use crate::tx; use alloy_network::{eip2718::Encodable2718, EthereumSigner, TransactionBuilder}; use alloy_primitives::U64; use alloy_provider::Provider; +use alloy_rpc_types::BlockId; use alloy_signer::Signer; use clap::Parser; use eyre::Result; @@ -89,7 +90,8 @@ impl MakeTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = Some(U64::from(provider.get_transaction_count(from, None).await?)); + tx.nonce = + Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); } let provider = get_provider(&config)?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index b24de5fba2948..7799f522691d8 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -2,6 +2,7 @@ use crate::tx; use alloy_network::{AnyNetwork, EthereumSigner}; use alloy_primitives::{Address, U64}; use alloy_provider::{Provider, ProviderBuilder}; +use alloy_rpc_types::BlockId; use alloy_signer::Signer; use alloy_transport::Transport; use cast::Cast; @@ -142,8 +143,9 @@ impl SendTxArgs { } if resend { - tx.nonce = - Some(U64::from(provider.get_transaction_count(config.sender, None).await?)); + tx.nonce = Some(U64::from( + provider.get_transaction_count(config.sender, BlockId::latest()).await?, + )); } cast_send( @@ -173,7 +175,8 @@ impl SendTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = Some(U64::from(provider.get_transaction_count(from, None).await?)); + tx.nonce = + Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); } let signer = EthereumSigner::from(signer); diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 0bf041b8a9cff..18411165ea130 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -230,7 +230,8 @@ async fn fetch_storage_slots, T: Transport + Clone>( ) -> Result> { let requests = layout.storage.iter().map(|storage_slot| async { let slot = B256::from(U256::from_str(&storage_slot.slot)?); - let raw_slot_value = provider.get_storage_at(address, slot.into(), block).await?; + let raw_slot_value = + provider.get_storage_at(address, slot.into(), block.unwrap_or_default()).await?; let value = StorageValue { slot, raw_slot_value: raw_slot_value.into() }; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 565cd6eda7a8f..e1b411864bd29 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -346,7 +346,9 @@ async fn main() -> Result<()> { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let address = address.resolve(&provider).await?; - let value = provider.get_proof(address, slots.into_iter().collect(), block).await?; + let value = provider + .get_proof(address, slots.into_iter().collect(), block.unwrap_or(BlockId::latest())) + .await?; println!("{}", serde_json::to_string(&value)?); } CastSubcommand::Rpc(cmd) => cmd.run().await?, diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 98f7bf67e4c4d..184da16d6dca2 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,8 +1,8 @@ use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; -use alloy_primitives::{Address, U256}; +use alloy_primitives::{Address, Bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use alloy_transport::Transport; use eyre::Result; use foundry_cli::{opts::TransactionOpts, utils::parse_function_args}; @@ -56,10 +56,12 @@ pub async fn build_tx< let chain = chain.into(); let from = from.into().resolve(provider).await?; - let to = if let Some(to) = to { Some(to.into().resolve(provider).await?) } else { None }; + // TODO: Possible bug here? + let to: Option
= + if let Some(to) = to { Some(to.into().resolve(provider).await?) } else { None }; let mut req = WithOtherFields::new(TransactionRequest::default()) - .with_to(to.into()) + .with_to(to.unwrap_or_default()) .with_from(from) .with_value(tx.value.unwrap_or_default()) .with_chain_id(chain.id()); @@ -67,7 +69,7 @@ pub async fn build_tx< req.set_nonce(if let Some(nonce) = tx.nonce { nonce.to() } else { - provider.get_transaction_count(from, None).await? + provider.get_transaction_count(from, BlockId::latest()).await? }); if tx.legacy || chain.is_legacy() { @@ -110,12 +112,12 @@ pub async fn build_tx< (Vec::new(), None) }; - req.set_input(data.into()); + req.set_input::(data.into()); req.set_gas_limit(if let Some(gas_limit) = tx.gas_limit { gas_limit.to() } else { - provider.estimate_gas(&req, None).await? + provider.estimate_gas(&req, BlockId::latest()).await? }); Ok((req, func)) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index d63bbc33e370e..1f26acbee85a8 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -4,7 +4,7 @@ use alloy_json_abi::{ContractObject, Function}; use alloy_network::AnyNetwork; use alloy_primitives::{ utils::{keccak256, ParseUnits, Unit}, - Address, Keccak256, TxHash, B256, I256, U256, + Address, Keccak256, TxHash, TxKind, B256, I256, U256, }; use alloy_provider::{ network::eip2718::{Decodable2718, Encodable2718}, @@ -106,7 +106,7 @@ where /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; /// let greeting = greetingCall { i: U256::from(5) }.abi_encode(); /// let bytes = Bytes::from_iter(greeting.iter()); - /// let tx = TransactionRequest::default().to(Some(to)).input(bytes.into()); + /// let tx = TransactionRequest::default().to(to).input(bytes.into()); /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(alloy_provider); /// let data = cast.call(&tx, None, None).await?; @@ -120,7 +120,7 @@ where func: Option<&Function>, block: Option, ) -> Result { - let res = self.provider.call(req, block).await?; + let res = self.provider.call(req, block.unwrap_or(BlockId::latest())).await?; let mut decoded = vec![]; @@ -132,7 +132,7 @@ where // ensure the address is a contract if res.is_empty() { // check that the recipient is a contract that can be called - if let Some(addr) = req.to { + if let Some(TxKind::Call(addr)) = req.to { if let Ok(code) = self.provider.get_code_at(addr, block.unwrap_or_default()).await { @@ -140,6 +140,10 @@ where eyre::bail!("contract {addr:?} does not have any code") } } + } else if Some(TxKind::Create) == req.to { + eyre::bail!("tx req is a contract deployment"); + } else { + eyre::bail!("recipient is None"); } } return Err(err).wrap_err( @@ -179,7 +183,7 @@ where /// let to = Address::from_str("0xB3C95ff08316fb2F2e3E52Ee82F8e7b605Aa1304")?; /// let greeting = greetingCall { i: U256::from(5) }.abi_encode(); /// let bytes = Bytes::from_iter(greeting.iter()); - /// let tx = TransactionRequest::default().to(Some(to)).input(bytes.into()); + /// let tx = TransactionRequest::default().to(to).input(bytes.into()); /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(&provider); /// let access_list = cast.access_list(&tx, None, false).await?; @@ -193,7 +197,8 @@ where block: Option, to_json: bool, ) -> Result { - let access_list = self.provider.create_access_list(req, block).await?; + let access_list = + self.provider.create_access_list(req, block.unwrap_or(BlockId::latest())).await?; let res = if to_json { serde_json::to_string(&access_list)? } else { @@ -215,7 +220,7 @@ where } pub async fn balance(&self, who: Address, block: Option) -> Result { - Ok(self.provider.get_balance(who, block).await?) + Ok(self.provider.get_balance(who, block.unwrap_or(BlockId::latest())).await?) } /// Sends a transaction to the specified address @@ -243,7 +248,7 @@ where /// let gas = U256::from_str("200000").unwrap(); /// let value = U256::from_str("1").unwrap(); /// let nonce = U256::from_str("1").unwrap(); - /// let tx = TransactionRequest::default().to(Some(to)).input(bytes.into()).from(from); + /// let tx = TransactionRequest::default().to(to).input(bytes.into()).from(from); /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(provider); /// let data = cast.send(tx).await?; @@ -467,7 +472,7 @@ where /// # } /// ``` pub async fn nonce(&self, who: Address, block: Option) -> Result { - Ok(self.provider.get_transaction_count(who, block).await?) + Ok(self.provider.get_transaction_count(who, block.unwrap_or(BlockId::latest())).await?) } /// # Example @@ -491,7 +496,10 @@ where pub async fn implementation(&self, who: Address, block: Option) -> Result { let slot = B256::from_str("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")?; - let value = self.provider.get_storage_at(who, slot.into(), block).await?; + let value = self + .provider + .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) + .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) } @@ -517,7 +525,10 @@ where pub async fn admin(&self, who: Address, block: Option) -> Result { let slot = B256::from_str("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")?; - let value = self.provider.get_storage_at(who, slot.into(), block).await?; + let value = self + .provider + .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) + .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) } @@ -756,7 +767,11 @@ where ) -> Result { Ok(format!( "{:?}", - B256::from(self.provider.get_storage_at(from, slot.into(), block).await?) + B256::from( + self.provider + .get_storage_at(from, slot.into(), block.unwrap_or(BlockId::latest())) + .await? + ) )) } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 64d2e70a4f986..68418e2823a7f 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -15,7 +15,7 @@ use crate::{ CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, Vm, Vm::AccountAccess, }; -use alloy_primitives::{Address, Bytes, Log, B256, U256}; +use alloy_primitives::{Address, Bytes, Log, TxKind, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, SELECTOR_LEN}; @@ -915,7 +915,7 @@ impl Inspector for Cheatcodes { rpc: ecx.db.active_fork_url(), transaction: TransactionRequest { from: Some(broadcast.new_origin), - to: Some(call.contract), + to: Some(TxKind::Call(call.contract)), value: Some(call.transfer.value), input: TransactionInput::new(call.input.clone()), nonce: Some(account.info.nonce), diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 1607b6d104dce..26db7038cc1bd 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -453,7 +453,7 @@ pub fn get_pretty_tx_receipt_attr( } "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), "transactionIndex" | "transaction_index" => { - Some(receipt.receipt.transaction_index.to_string()) + Some(receipt.receipt.transaction_index.pretty()) } "type" | "transaction_type" => Some(receipt.receipt.inner.inner.r#type.to_string()), "revertReason" | "revert_reason" => Some(receipt.revert_reason.pretty()), diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index cf3f5a89a75a9..1f7d6228eef3c 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -50,7 +50,7 @@ impl TransactionReceiptWithRevertReason { match provider .call( &WithOtherFields::new(transaction.inner.into()), - Some(BlockId::Hash(block_hash.into())), + BlockId::Hash(block_hash.into()), ) .await { diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index f6da76fc5c429..5daa4e96ce52f 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -187,7 +187,7 @@ where trace!(target: "backendhandler", %address, %idx, "preparing storage request"); entry.insert(vec![listener]); let provider = self.provider.clone(); - let block_id = self.block_id; + let block_id = self.block_id.unwrap_or(BlockId::latest()); let fut = Box::pin(async move { let storage = provider.get_storage_at(address, idx, block_id).await.map_err(Into::into); @@ -202,11 +202,11 @@ where fn get_account_req(&self, address: Address) -> ProviderRequest { trace!(target: "backendhandler", "preparing account request, address={:?}", address); let provider = self.provider.clone(); - let block_id = self.block_id; + let block_id = self.block_id.unwrap_or(BlockId::latest()); let fut = Box::pin(async move { let balance = provider.get_balance(address, block_id); let nonce = provider.get_transaction_count(address, block_id); - let code = provider.get_code_at(address, block_id.unwrap_or_default()); + let code = provider.get_code_at(address, block_id); let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); (resp, address) }); diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 68b303362efdf..dfa1c003e63f1 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -4,7 +4,7 @@ use alloy_json_abi::{Constructor, JsonAbi}; use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; use alloy_primitives::{Address, Bytes}; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{AnyTransactionReceipt, BlockId, TransactionRequest, WithOtherFields}; use alloy_signer::Signer; use alloy_transport::{Transport, TransportError}; use clap::{Parser, ValueHint}; @@ -233,17 +233,20 @@ impl CreateArgs { deployer.tx.set_from(deployer_address); deployer.tx.set_chain_id(chain); - + // `to` field must be set explicitly, cannot be None. + if deployer.tx.to.is_none() { + deployer.tx.set_create(); + } deployer.tx.set_nonce(if let Some(nonce) = self.tx.nonce { Ok(nonce.to()) } else { - provider.get_transaction_count(deployer_address, None).await + provider.get_transaction_count(deployer_address, BlockId::latest()).await }?); deployer.tx.set_gas_limit(if let Some(gas_limit) = self.tx.gas_limit { Ok(gas_limit.to()) } else { - provider.estimate_gas(&deployer.tx, None).await + provider.estimate_gas(&deployer.tx, BlockId::latest()).await }?); // set tx value if specified @@ -557,7 +560,7 @@ where }; // create the tx object. Since we're deploying a contract, `to` is `None` - let tx = WithOtherFields::new(TransactionRequest::default().input(data.into()).to(None)); + let tx = WithOtherFields::new(TransactionRequest::default().input(data.into())); Ok(Deployer { client: self.client.clone(), diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 0cb5b0c9c5299..cd4decfcbe33c 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -4,7 +4,7 @@ use crate::{ ScriptConfig, }; use alloy_chains::Chain; -use alloy_eips::eip2718::Encodable2718; +use alloy_eips::{eip2718::Encodable2718, BlockId}; use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; use alloy_primitives::{utils::format_units, Address, TxHash}; use alloy_provider::{utils::Eip1559Estimation, Provider}; @@ -45,7 +45,10 @@ where tx.gas = None; tx.set_gas_limit( - provider.estimate_gas(tx, None).await.wrap_err("Failed to estimate gas for tx")? * + provider + .estimate_gas(tx, BlockId::latest()) + .await + .wrap_err("Failed to estimate gas for tx")? * estimate_multiplier as u128 / 100, ); @@ -55,7 +58,7 @@ where pub async fn next_nonce(caller: Address, provider_url: &str) -> eyre::Result { let provider = try_get_http_provider(provider_url) .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; - Ok(provider.get_transaction_count(caller, None).await?) + Ok(provider.get_transaction_count(caller, BlockId::latest()).await?) } pub async fn send_transaction( @@ -70,7 +73,7 @@ pub async fn send_transaction( let from = tx.from.expect("no sender"); if sequential_broadcast { - let nonce = provider.get_transaction_count(from, None).await?; + let nonce = provider.get_transaction_count(from, BlockId::latest()).await?; let tx_nonce = tx.nonce.expect("no nonce"); if nonce != tx_nonce { @@ -287,6 +290,11 @@ impl BundledState { let mut tx = tx.clone(); tx.set_chain_id(sequence.chain); + // Set TxKind::Create explicityly to satify `check_reqd_fields` in alloy + if tx.to().is_none() { + tx.set_create(); + } + if let Some(gas_price) = gas_price { tx.set_gas_price(gas_price); } else { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index bbdda84ae55c0..9500c4d714e30 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -6,7 +6,7 @@ extern crate tracing; use self::transaction::AdditionalContract; use crate::runner::ScriptRunner; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{Address, Bytes, Log, TxKind, U256}; use alloy_signer::Signer; use broadcast::next_nonce; use build::PreprocessedState; @@ -400,13 +400,15 @@ impl ScriptArgs { let mut offset = 0; // Find if it's a CREATE or CREATE2. Otherwise, skip transaction. - if let Some(to) = to { + if let Some(TxKind::Call(to)) = to { if to == DEFAULT_CREATE2_DEPLOYER { // Size of the salt prefix. offset = 32; + } else { + continue; } - } else if to.is_some() { - continue; + } else if let Some(TxKind::Create) = to { + // Pass } // Find artifact with a deployment code same as the data. diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 87f9b3515fb22..37926e3080cdc 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -13,7 +13,7 @@ use crate::{ ScriptArgs, ScriptConfig, ScriptResult, }; use alloy_network::TransactionBuilder; -use alloy_primitives::{utils::format_units, Address, U256}; +use alloy_primitives::{utils::format_units, Address, TxKind, U256}; use eyre::{Context, Result}; use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; use foundry_cli::utils::{has_different_gas_calc, now}; @@ -99,11 +99,12 @@ impl PreSimulationState { let mut runner = runners.get(&rpc).expect("invalid rpc url").write(); let mut tx = transaction.transaction; + let to = if let Some(TxKind::Call(to)) = tx.to { Some(to) } else { None }; let result = runner .simulate( tx.from .expect("transaction doesn't have a `from` address at execution time"), - tx.to, + to, tx.input.clone().into_input(), tx.value, ) diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 3f5405db6f680..534b4964138bd 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,6 +1,6 @@ use super::ScriptResult; use alloy_dyn_abi::JsonAbiExt; -use alloy_primitives::{Address, Bytes, B256}; +use alloy_primitives::{Address, Bytes, TxKind, B256}; use alloy_rpc_types::{request::TransactionRequest, WithOtherFields}; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{fmt::format_token_raw, provider::alloy::RpcUrl, ContractData, SELECTOR_LEN}; @@ -71,7 +71,7 @@ impl TransactionWithMetadata { metadata.is_fixed_gas_limit = is_fixed_gas_limit; // Specify if any contract was directly created with this transaction - if let Some(to) = metadata.transaction.to { + if let Some(TxKind::Call(to)) = metadata.transaction.to { if to == DEFAULT_CREATE2_DEPLOYER { metadata.set_create( true, diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 1950487117798..a73c53a394c27 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -18,6 +18,7 @@ foundry-config.workspace = true alloy-primitives.workspace = true alloy-provider.workspace = true +alloy-rpc-types.workspace = true eyre.workspace = true fd-lock = "4.0.0" diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index fecbc9f5f07f8..3fa5f07f89957 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,6 +1,7 @@ use crate::{init_tracing, TestCommand}; use alloy_primitives::Address; use alloy_provider::Provider; +use alloy_rpc_types::BlockId; use eyre::Result; use foundry_common::provider::alloy::{get_http_provider, RetryProvider}; use std::{collections::BTreeMap, fs, path::Path, str::FromStr}; @@ -117,7 +118,7 @@ impl ScriptTester { if let Some(provider) = &self.provider { let nonce = provider - .get_transaction_count(self.accounts_pub[index as usize], None) + .get_transaction_count(self.accounts_pub[index as usize], BlockId::latest()) .await .unwrap(); self.nonces.insert(index, nonce); @@ -128,8 +129,13 @@ impl ScriptTester { pub async fn load_addresses(&mut self, addresses: &[Address]) -> &mut Self { for &address in addresses { - let nonce = - self.provider.as_ref().unwrap().get_transaction_count(address, None).await.unwrap(); + let nonce = self + .provider + .as_ref() + .unwrap() + .get_transaction_count(address, BlockId::latest()) + .await + .unwrap(); self.address_nonces.insert(address, nonce); } self @@ -169,8 +175,13 @@ impl ScriptTester { pub async fn assert_nonce_increment(&mut self, keys_indexes: &[(u32, u32)]) -> &mut Self { for &(private_key_slot, expected_increment) in keys_indexes { let addr = self.accounts_pub[private_key_slot as usize]; - let nonce = - self.provider.as_ref().unwrap().get_transaction_count(addr, None).await.unwrap(); + let nonce = self + .provider + .as_ref() + .unwrap() + .get_transaction_count(addr, BlockId::latest()) + .await + .unwrap(); let prev_nonce = self.nonces.get(&private_key_slot).unwrap(); assert_eq!( @@ -193,7 +204,7 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(*address, None) + .get_transaction_count(*address, BlockId::latest()) .await .unwrap(); let prev_nonce = self.address_nonces.get(address).unwrap(); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 6f8d44ff9ad29..91963752d9bad 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -286,9 +286,8 @@ impl VerifyBytecodeArgs { // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same // block. let prev_block_id = BlockId::Number(BlockNumberOrTag::Number(simulation_block - 1)); - let prev_block_nonce = provider - .get_transaction_count(creation_data.contract_creator, Some(prev_block_id)) - .await?; + let prev_block_nonce = + provider.get_transaction_count(creation_data.contract_creator, prev_block_id).await?; transaction.nonce = prev_block_nonce; if let Some(ref block) = block { diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index 9cf4478e2d8b2..37526559c7f0b 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -91,7 +91,7 @@ impl WalletSigner { } } WalletSigner::Aws(aws) => { - senders.push(aws.address()); + senders.push(alloy_signer::Signer::address(aws)); } } Ok(senders) @@ -142,7 +142,7 @@ impl Signer for WalletSigner { } fn address(&self) -> Address { - delegate!(self, inner => inner.address()) + delegate!(self, inner => alloy_signer::Signer::address(inner)) } fn chain_id(&self) -> Option { @@ -180,6 +180,10 @@ impl TxSigner for WalletSigner { ) -> alloy_signer::Result { delegate!(self, inner => inner.sign_transaction(tx)).await } + + fn address(&self) -> Address { + delegate!(self, inner => alloy_signer::Signer::address(inner)) + } } /// Signers that require user action to be obtained. From 651cec1665d785a2671d666a7bdfe55dd3eeebfb Mon Sep 17 00:00:00 2001 From: Danil Menkin <83108115+golden-expiriensu@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:05:11 +0700 Subject: [PATCH 0901/1963] fix(anvil): take block count limit in fee history into account (#7780) --- crates/anvil/src/eth/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 10689de90f28b..ac1760c6d9b6b 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1264,7 +1264,7 @@ impl EthApi { } const MAX_BLOCK_COUNT: u64 = 1024u64; - let block_count = block_count.to::().max(MAX_BLOCK_COUNT); + let block_count = block_count.to::().min(MAX_BLOCK_COUNT); // highest and lowest block num in the requested range let highest = number; From 1fc4aa34c4331c12aaa8ee831b16b80b7d5a446f Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:38:40 +0300 Subject: [PATCH 0902/1963] perf(invariant): sequentially shrink failed sequence (#7756) * perf(invariant): sequentially shrink failed sequence * If invariant function to test sequence is not set then return true (meaning original sequence is the smallest sequence we can identify) Follow ups: always set invariant function so we can shrink / test sequence, figure out why sometimes a failed sequence (reproducible with a regression test) doesn't fail when it's replayed * Reduce number of calls by trying to simplify in same step as complicate and avoid duplicate tests * Changes after review - for loop to shrink run limit - store only call seq len in shrinker - clone call seq only once * Nit --- Cargo.lock | 3 - crates/config/src/invariant.rs | 1 + crates/evm/evm/Cargo.toml | 3 - .../evm/evm/src/executors/invariant/error.rs | 249 ++++-------------- crates/evm/evm/src/executors/invariant/mod.rs | 2 + .../evm/evm/src/executors/invariant/shrink.rs | 68 +++++ crates/forge/tests/it/invariant.rs | 42 +++ .../common/InvariantShrinkBigSequence.t.sol | 31 +++ 8 files changed, 188 insertions(+), 211 deletions(-) create mode 100644 crates/evm/evm/src/executors/invariant/shrink.rs create mode 100644 testdata/default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol diff --git a/Cargo.lock b/Cargo.lock index a4ab4783e9a15..1c081fb297e22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3910,11 +3910,8 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-fuzz", "foundry-evm-traces", - "itertools 0.12.1", "parking_lot", "proptest", - "rand 0.8.5", - "rayon", "revm", "revm-inspectors", "thiserror", diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 13c203d396fa2..c7462d539461b 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -25,6 +25,7 @@ pub struct InvariantConfig { #[serde(flatten)] pub dictionary: FuzzDictionaryConfig, /// Attempt to shrink the failure case to its smallest sequence of calls + /// TODO: remove this setting as it is now redundant with shrink_run_limit = 0 pub shrink_sequence: bool, /// The maximum number of attempts to shrink the sequence pub shrink_run_limit: usize, diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 9336ffff740e1..8a5d40db554f3 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -38,10 +38,7 @@ revm-inspectors.workspace = true arrayvec.workspace = true eyre = "0.6" hex.workspace = true -itertools.workspace = true parking_lot = "0.12" proptest = "1" -rand.workspace = true -rayon = "1" thiserror = "1" tracing = "0.1" diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index ae122d0fa7be8..5b3ebad91f002 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -1,5 +1,5 @@ use super::{BasicTxDetails, InvariantContract}; -use crate::executors::{Executor, RawCallResult}; +use crate::executors::{invariant::shrink::CallSequenceShrinker, Executor, RawCallResult}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log}; use eyre::Result; @@ -9,11 +9,8 @@ use foundry_evm_fuzz::{ invariant::FuzzRunIdentifiedContracts, BaseCounterExample, CounterExample, FuzzedCases, Reason, }; use foundry_evm_traces::{load_contracts, CallTraceArena, TraceKind, Traces}; -use itertools::Itertools; use parking_lot::RwLock; use proptest::test_runner::TestError; -use rand::{seq, thread_rng, Rng}; -use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use revm::primitives::U256; use std::{borrow::Cow, sync::Arc}; @@ -162,7 +159,7 @@ impl FailedInvariantCaseData { }; if self.shrink { - calls = self.try_shrinking(&calls, &executor)?.into_iter().cloned().collect(); + calls = self.shrink_sequence(&calls, &executor)?; } else { trace!(target: "forge::test", "Shrinking disabled."); } @@ -212,69 +209,14 @@ impl FailedInvariantCaseData { .then_some(CounterExample::Sequence(counterexample_sequence))) } - /// Checks that a subsequence of the provided calls fails the provided invariant test - /// and updates an Arc Mutex of the indices of the shortest sequence - fn set_fails_successfully( - &self, - mut executor: Executor, - calls: &[BasicTxDetails], - use_calls: &[usize], - curr_seq: Arc>>, - ) -> eyre::Result<()> { - if curr_seq.read().len() == 1 { - // if current sequence is already the smallest possible, just return - return Ok(()); - } - - let mut new_sequence = Vec::with_capacity(calls.len()); - for index in 0..calls.len() { - if !use_calls.contains(&index) { - continue - } - - new_sequence.push(index); - - // If the new sequence is already longer than the known best, skip execution - if new_sequence.len() >= curr_seq.read().len() { - return Ok(()); - } - } - - for (seq_idx, call_index) in new_sequence.iter().enumerate() { - let (sender, (addr, bytes)) = &calls[*call_index]; - - executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; - - // Checks the invariant. If we revert or fail before the last call, all the better. - if let Some(func) = &self.func { - let mut call_result = - executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO)?; - let is_success = executor.is_raw_call_success( - self.addr, - Cow::Owned(call_result.state_changeset.take().unwrap()), - &call_result, - false, - ); - if !is_success { - let mut locked = curr_seq.write(); - if new_sequence[..=seq_idx].len() < locked.len() { - // update the curr_sequence if the new sequence is lower than - *locked = new_sequence[..=seq_idx].to_vec(); - } - } - } - } - Ok(()) - } - /// Tries to shrink the failure case to its smallest sequence of calls. /// /// If the number of calls is small enough, we can guarantee maximal shrinkage - fn try_shrinking<'a>( + fn shrink_sequence( &self, - calls: &'a [BasicTxDetails], + calls: &[BasicTxDetails], executor: &Executor, - ) -> eyre::Result> { + ) -> Result> { trace!(target: "forge::test", "Shrinking."); // Special case test: the invariant is *unsatisfiable* - it took 0 calls to @@ -287,7 +229,18 @@ impl FailedInvariantCaseData { } } - let shrunk_call_indices = self.try_shrinking_recurse(calls, executor, 0, 0)?; + let mut shrinker = CallSequenceShrinker::new(calls.len()); + for _ in 0..self.shrink_run_limit { + // Check candidate sequence result. + match self.check_sequence(executor.clone(), calls, shrinker.current().collect()) { + // If candidate sequence still fails then shrink more if possible. + false if !shrinker.simplify() => break, + // If candidate sequence pass then restore last removed call and shrink other + // calls if possible. + true if !shrinker.complicate() => break, + _ => {} + } + } // We recreate the call sequence in the same order as they reproduce the failure, // otherwise we could end up with inverted sequence. @@ -296,153 +249,39 @@ impl FailedInvariantCaseData { // 2. Bob calls transferOwnership to Alice // 3. Alice calls acceptOwnership and test fails // we shrink to indices of [2, 1] and we recreate call sequence in same order. - Ok(shrunk_call_indices.iter().map(|idx| &calls[*idx]).collect()) + Ok(shrinker.current().map(|idx| &calls[idx]).cloned().collect()) } - /// We try to construct a [powerset](https://en.wikipedia.org/wiki/Power_set) of the sequence if - /// the configuration allows for it and the length of the sequence is small enough. If we - /// do construct the powerset, we run all of the sequences in parallel, finding the smallest - /// one. If we have ran the powerset, we are guaranteed to find the smallest sequence for a - /// given set of calls (however, not guaranteed *global* smallest if a random sequence was - /// used at any point during recursion). - /// - /// If we were unable to construct a powerset, we construct a random sample over the sequence - /// and run these sequences in parallel instead. - /// - /// After running either the powerset or the random sequences, we check if we successfully - /// shrunk the call sequence. - fn try_shrinking_recurse( + fn check_sequence( &self, + mut executor: Executor, calls: &[BasicTxDetails], - executor: &Executor, - runs: usize, - retries: usize, - ) -> eyre::Result> { - // Construct a ArcRwLock vector of indices of `calls` - let shrunk_call_indices = Arc::new(RwLock::new((0..calls.len()).collect())); - let shrink_limit = self.shrink_run_limit - runs; - - let upper_bound = calls.len().saturating_sub(1); - // We construct either a full powerset (this guarantees we maximally shrunk for the given - // calls) or a random subset - let (set_of_indices, is_powerset): (Vec<_>, bool) = if calls.len() <= 64 && - (1 << calls.len() as u32) <= shrink_limit - { - // We add the last tx always because thats ultimately what broke the invariant - let powerset = (0..upper_bound) - .powerset() - .map(|mut subset| { - subset.push(upper_bound); - subset - }) - .collect(); - (powerset, true) - } else { - // construct a random set of subsequences - let mut rng = thread_rng(); - ( - (0..shrink_limit / 3) - .map(|_| { - // Select between 1 and calls.len() - 2 number of indices - let amt: usize = rng.gen_range(1..upper_bound); - // Construct a random sequence of indices, up to calls.len() - 1 (sample is - // exclusive range and we dont include the last tx - // because its always included), and amt number of indices - let mut seq = seq::index::sample(&mut rng, upper_bound, amt).into_vec(); - // Sort the indices because seq::index::sample is unordered - seq.sort(); - // We add the last tx always because thats what ultimately broke the - // invariant - seq.push(upper_bound); - seq - }) - .collect(), + sequence: Vec, + ) -> bool { + // Apply the shrinked candidate sequence. + sequence.iter().for_each(|call_index| { + let (sender, (addr, bytes)) = &calls[*call_index]; + executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO).unwrap(); + }); + + // Check the invariant for candidate sequence. + // If sequence fails then we can continue with shrinking - the removed call does not affect + // failure. + // + // If sequence doesn't fail then we have to restore last removed call and continue with next + // call - removed call is a required step for reproducing the failure. + if let Some(func) = &self.func { + let mut call_result = + executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO).unwrap(); + executor.is_raw_call_success( + self.addr, + Cow::Owned(call_result.state_changeset.take().unwrap()), + &call_result, false, ) - }; - - let new_runs = set_of_indices.len(); - - // just try all of them in parallel - set_of_indices - .par_iter() - .map(|use_calls| { - self.set_fails_successfully( - executor.clone(), - calls, - use_calls, - Arc::clone(&shrunk_call_indices), - ) - }) - .collect::>()?; - - // There are no more live references to shrunk_call_indices as the parallel execution is - // finished, so it is fine to get the inner value via `Arc::unwrap`. - let shrunk_call_indices = Arc::try_unwrap(shrunk_call_indices).unwrap().into_inner(); - - if is_powerset { - // A powerset is guaranteed to be smallest local subset, so we return early. - return Ok(shrunk_call_indices); - } - - let computation_budget_not_hit = new_runs + runs < self.shrink_run_limit; - // If the new shrunk_call_indices is less than the input calls length, - // we found a subsequence that is shorter. So we can measure if we made progress by - // comparing them - let made_progress = shrunk_call_indices.len() < calls.len(); - // We limit the number of times we can iterate without making progress - let has_remaining_retries = retries <= 3; - - match (computation_budget_not_hit, made_progress) { - (true, false) if has_remaining_retries => { - // we havent hit the computation budget and we have retries remaining - // - // use the same call set but increase retries which should select a different random - // subset we dont need to do the mapping stuff like above because we dont - // take a subset of the input - self.try_shrinking_recurse(calls, executor, runs + new_runs, retries + 1) - } - (true, true) => { - // We construct a *new* subset of calls using the `shrunk_call_indices` of the - // passed in calls i.e. if shrunk_call_indices == [1, 3], and calls - // is: [call0, call1, call2, call3] then new_calls == [call1, call3] - let new_calls: Vec<_> = calls - .iter() - .enumerate() - .filter(|(i, _)| shrunk_call_indices.contains(i)) - .map(|(_, call)| call.clone()) - .collect(); - - // We rerun this algorithm as if the new smaller subset above were the original - // calls. i.e. if [call0, call1, call2, call3] got reduced to - // [call1, call3] (in the above line) and we still have progress - // to make, we recall this function with [call1, call3]. Then after this call say it - // returns [1]. This means `call3` is all that is required to break - // the invariant. - let new_calls_idxs = - self.try_shrinking_recurse(&new_calls, executor, runs + new_runs, 0)?; - - // Notably, the indices returned above are relative to `new_calls`, *not* the - // originally passed in `calls`. So we map back by filtering - // `new_calls` by index if the index was returned above, and finding the position - // of the `new_call` in the passed in `call` - Ok(new_calls - .iter() - .enumerate() - .filter_map(|(idx, new_call)| { - if !new_calls_idxs.contains(&idx) { - None - } else { - calls.iter().position(|r| r == new_call) - } - }) - .collect()) - } - _ => { - // The computation budget has been hit or no retries remaining, stop trying to make - // progress - Ok(shrunk_call_indices) - } + } else { + // Invariant function is not set, return true as we cannot test the sequence. + true } } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index b5669cb7ddddd..d0593d919883b 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -36,6 +36,8 @@ use self::error::FailedInvariantCaseData; pub use error::{InvariantFailures, InvariantFuzzError, InvariantFuzzTestResult}; mod funcs; +mod shrink; + pub use funcs::{assert_invariants, replay_run}; sol! { diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs new file mode 100644 index 0000000000000..09f890c65dda9 --- /dev/null +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -0,0 +1,68 @@ +use proptest::bits::{BitSetLike, VarBitSet}; + +#[derive(Clone, Copy, Debug)] +struct Shrink { + call_index: usize, +} + +/// Shrinker for a call sequence failure. +/// Iterates sequence call sequence top down and removes calls one by one. +/// If the failure is still reproducible with removed call then moves to the next one. +/// If the failure is not reproducible then restore removed call and moves to next one. +#[derive(Debug)] +pub(crate) struct CallSequenceShrinker { + /// Length of call sequence to be shrinked. + call_sequence_len: usize, + /// Call ids contained in current shrinked sequence. + included_calls: VarBitSet, + /// Current shrinked call id. + shrink: Shrink, + /// Previous shrinked call id. + prev_shrink: Option, +} + +impl CallSequenceShrinker { + pub(crate) fn new(call_sequence_len: usize) -> Self { + Self { + call_sequence_len, + included_calls: VarBitSet::saturated(call_sequence_len), + shrink: Shrink { call_index: 0 }, + prev_shrink: None, + } + } + + /// Return candidate shrink sequence to be tested, by removing ids from original sequence. + pub(crate) fn current(&self) -> impl Iterator + '_ { + (0..self.call_sequence_len).filter(|&call_id| self.included_calls.test(call_id)) + } + + /// Removes next call from sequence. + pub(crate) fn simplify(&mut self) -> bool { + if self.shrink.call_index >= self.call_sequence_len { + // We reached the end of call sequence, nothing left to simplify. + false + } else { + // Remove current call. + self.included_calls.clear(self.shrink.call_index); + // Record current call as previous call. + self.prev_shrink = Some(self.shrink); + // Remove next call index + self.shrink = Shrink { call_index: self.shrink.call_index + 1 }; + true + } + } + + /// Reverts removed call from sequence and tries to simplify next call. + pub(crate) fn complicate(&mut self) -> bool { + match self.prev_shrink { + Some(shrink) => { + // Undo the last call removed. + self.included_calls.set(shrink.call_index); + self.prev_shrink = None; + // Try to simplify next call. + self.simplify() + } + None => false, + } + } +} diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index e03272ea80ca9..ee3f0edc34a7d 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -173,6 +173,10 @@ async fn test_invariant() { None, )], ), + ( + "default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol:ShrinkBigSequenceTest", + vec![("invariant_shrink_big_sequence()", true, None, None, None)], + ), ]), ); } @@ -329,6 +333,44 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { }; } +#[tokio::test(flavor = "multi_thread")] +#[cfg_attr(windows, ignore = "for some reason there's different rng")] +async fn test_shrink_big_sequence() { + let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); + opts.fuzz.seed = Some(U256::from(119u32)); + + let filter = + Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantShrinkBigSequence.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options = opts.clone(); + runner.test_options.invariant.runs = 1; + runner.test_options.invariant.depth = 500; + let results = runner.test_collect(&filter); + let results = + results.values().last().expect("`InvariantShrinkBigSequence` should be testable."); + + let result = results + .test_results + .values() + .last() + .expect("`InvariantShrinkBigSequence` should be testable."); + + assert_eq!(result.status, TestStatus::Failure); + + let counter = result + .counterexample + .as_ref() + .expect("`InvariantShrinkBigSequence` should have failed with a counterexample."); + + match counter { + CounterExample::Single(_) => panic!("CounterExample should be a sequence."), + CounterExample::Sequence(sequence) => { + // ensure shrinks to same sequence of 77 + assert_eq!(sequence.len(), 77); + } + }; +} + #[tokio::test(flavor = "multi_thread")] async fn test_invariant_preserve_state() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"); diff --git a/testdata/default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol b/testdata/default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol new file mode 100644 index 0000000000000..5699d9c455e89 --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract ShrinkBigSequence { + uint256 cond; + + function work(uint256 x) public { + if (x % 2 != 0 && x < 9000) { + cond++; + } + } + + function checkCond() public view { + require(cond < 77, "condition met"); + } +} + +contract ShrinkBigSequenceTest is DSTest { + ShrinkBigSequence target; + + function setUp() public { + target = new ShrinkBigSequence(); + } + + function invariant_shrink_big_sequence() public view { + target.checkCond(); + } +} From 19d69f277de96f621d930cdb767a9693c55ae8e1 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 26 Apr 2024 00:28:34 +0200 Subject: [PATCH 0903/1963] feat: `vm.blobhashes` (#7001) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: `vm.blobhashes` * chore: rename * test: add `vm.blobhashes` test * fix: add missing vm fn * fix: `cargo cheat` * fix: specify blobhashes loc * fix: use solidity 0.8.24 for blobhash test * chore: reinsert noop line ¯\_(ツ)_/¯ * refactor: move cancun cheats to sep dir * temp * temp * feat(cheatcodes): getBlobhashes --------- Co-authored-by: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 40 ++++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 12 +++++++ crates/cheatcodes/src/evm.rs | 25 +++++++++++++++ testdata/cancun/cheats/Blobhashes.t.sol | 20 ++++++++++++ testdata/cheats/Vm.sol | 2 ++ 5 files changed, 99 insertions(+) create mode 100644 testdata/cancun/cheats/Blobhashes.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index f769b2f06254d..1d34bf578ebe5 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2991,6 +2991,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "blobhashes", + "description": "Sets the blobhashes in the transaction.\nNot available on EVM versions before Cancun.\nIf used on unsupported EVM versions it will revert.", + "declaration": "function blobhashes(bytes32[] calldata blobhashes) external;", + "visibility": "external", + "mutability": "", + "signature": "blobhashes(bytes32[])", + "selector": "0x129de7eb", + "selectorBytes": [ + 18, + 157, + 231, + 235 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "breakpoint_0", @@ -4711,6 +4731,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getBlobhashes", + "description": "Gets the blockhashes from the current transaction.\nNot available on EVM versions before Cancun.\nIf used on unsupported EVM versions it will revert.", + "declaration": "function getBlobhashes() external view returns (bytes32[] memory blobhashes);", + "visibility": "external", + "mutability": "view", + "signature": "getBlobhashes()", + "selector": "0xf56ff18b", + "selectorBytes": [ + 245, + 111, + 241, + 139 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "getBlockNumber", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index e838298c73ebd..a62a05880f27b 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -381,6 +381,18 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function prevrandao(uint256 newPrevrandao) external; + /// Sets the blobhashes in the transaction. + /// Not available on EVM versions before Cancun. + /// If used on unsupported EVM versions it will revert. + #[cheatcode(group = Evm, safety = Unsafe)] + function blobhashes(bytes32[] calldata blobhashes) external; + + /// Gets the blockhashes from the current transaction. + /// Not available on EVM versions before Cancun. + /// If used on unsupported EVM versions it will revert. + #[cheatcode(group = Evm, safety = Unsafe)] + function getBlobhashes() external view returns (bytes32[] memory blobhashes); + /// Sets `block.height`. #[cheatcode(group = Evm, safety = Unsafe)] function roll(uint256 newHeight) external; diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index bfe43d6849aa5..c924c243629f0 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -303,6 +303,31 @@ impl Cheatcode for prevrandao_1Call { } } +impl Cheatcode for blobhashesCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { blobhashes } = self; + ensure!( + ccx.ecx.spec_id() >= SpecId::CANCUN, + "`blobhash` is not supported before the Cancun hard fork; \ + see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844" + ); + ccx.ecx.env.tx.blob_hashes.clone_from(blobhashes); + Ok(Default::default()) + } +} + +impl Cheatcode for getBlobhashesCall { + fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + ensure!( + ccx.ecx.spec_id() >= SpecId::CANCUN, + "`blobhash` is not supported before the Cancun hard fork; \ + see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844" + ); + Ok(ccx.ecx.env.tx.blob_hashes.clone().abi_encode()) + } +} + impl Cheatcode for rollCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newHeight } = self; diff --git a/testdata/cancun/cheats/Blobhashes.t.sol b/testdata/cancun/cheats/Blobhashes.t.sol new file mode 100644 index 0000000000000..4a589b45a38ff --- /dev/null +++ b/testdata/cancun/cheats/Blobhashes.t.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.25; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract BlobhashesTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testSetAndGetBlobhashes() public { + bytes32[] memory blobhashes = new bytes32[](2); + blobhashes[0] = bytes32(0x0000000000000000000000000000000000000000000000000000000000000001); + blobhashes[1] = bytes32(0x0000000000000000000000000000000000000000000000000000000000000002); + vm.blobhashes(blobhashes); + + bytes32[] memory gotBlobhashes = vm.getBlobhashes(); + assertEq(gotBlobhashes[0], blobhashes[0]); + assertEq(gotBlobhashes[1], blobhashes[1]); + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 854f57d23f514..e70049cbf8f32 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -145,6 +145,7 @@ interface Vm { function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; function blobBaseFee(uint256 newBlobBaseFee) external; + function blobhashes(bytes32[] calldata blobhashes) external; function breakpoint(string calldata char) external; function breakpoint(string calldata char, bool value) external; function broadcast() external; @@ -231,6 +232,7 @@ interface Vm { function ffi(string[] calldata commandInput) external returns (bytes memory result); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); function getBlobBaseFee() external view returns (uint256 blobBaseFee); + function getBlobhashes() external view returns (bytes32[] memory blobhashes); function getBlockNumber() external view returns (uint256 height); function getBlockTimestamp() external view returns (uint256 timestamp); function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); From d21c3e7e1864d909cbece8ad650f91770193f128 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:16:59 -0700 Subject: [PATCH 0904/1963] fix: blob cheats shadowing (#7787) * fix: blob cheats shadowing * fix: cargo cheats --- crates/cheatcodes/assets/cheatcodes.json | 4 ++-- crates/cheatcodes/spec/src/vm.rs | 4 ++-- crates/cheatcodes/src/evm.rs | 4 ++-- testdata/cheats/Vm.sol | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 1d34bf578ebe5..39b58ff5e7fe3 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2995,7 +2995,7 @@ "func": { "id": "blobhashes", "description": "Sets the blobhashes in the transaction.\nNot available on EVM versions before Cancun.\nIf used on unsupported EVM versions it will revert.", - "declaration": "function blobhashes(bytes32[] calldata blobhashes) external;", + "declaration": "function blobhashes(bytes32[] calldata hashes) external;", "visibility": "external", "mutability": "", "signature": "blobhashes(bytes32[])", @@ -4735,7 +4735,7 @@ "func": { "id": "getBlobhashes", "description": "Gets the blockhashes from the current transaction.\nNot available on EVM versions before Cancun.\nIf used on unsupported EVM versions it will revert.", - "declaration": "function getBlobhashes() external view returns (bytes32[] memory blobhashes);", + "declaration": "function getBlobhashes() external view returns (bytes32[] memory hashes);", "visibility": "external", "mutability": "view", "signature": "getBlobhashes()", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index a62a05880f27b..4bbf631690206 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -385,13 +385,13 @@ interface Vm { /// Not available on EVM versions before Cancun. /// If used on unsupported EVM versions it will revert. #[cheatcode(group = Evm, safety = Unsafe)] - function blobhashes(bytes32[] calldata blobhashes) external; + function blobhashes(bytes32[] calldata hashes) external; /// Gets the blockhashes from the current transaction. /// Not available on EVM versions before Cancun. /// If used on unsupported EVM versions it will revert. #[cheatcode(group = Evm, safety = Unsafe)] - function getBlobhashes() external view returns (bytes32[] memory blobhashes); + function getBlobhashes() external view returns (bytes32[] memory hashes); /// Sets `block.height`. #[cheatcode(group = Evm, safety = Unsafe)] diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index c924c243629f0..6189980716b5a 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -305,13 +305,13 @@ impl Cheatcode for prevrandao_1Call { impl Cheatcode for blobhashesCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { blobhashes } = self; + let Self { hashes } = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, "`blobhash` is not supported before the Cancun hard fork; \ see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844" ); - ccx.ecx.env.tx.blob_hashes.clone_from(blobhashes); + ccx.ecx.env.tx.blob_hashes.clone_from(hashes); Ok(Default::default()) } } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index e70049cbf8f32..db8e45ada043e 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -145,7 +145,7 @@ interface Vm { function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; function blobBaseFee(uint256 newBlobBaseFee) external; - function blobhashes(bytes32[] calldata blobhashes) external; + function blobhashes(bytes32[] calldata hashes) external; function breakpoint(string calldata char) external; function breakpoint(string calldata char, bool value) external; function broadcast() external; @@ -232,7 +232,7 @@ interface Vm { function ffi(string[] calldata commandInput) external returns (bytes memory result); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); function getBlobBaseFee() external view returns (uint256 blobBaseFee); - function getBlobhashes() external view returns (bytes32[] memory blobhashes); + function getBlobhashes() external view returns (bytes32[] memory hashes); function getBlockNumber() external view returns (uint256 height); function getBlockTimestamp() external view returns (uint256 timestamp); function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); From d431f74f78eb52e4a0c528cd728aad5e4270367d Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 26 Apr 2024 19:04:08 +0200 Subject: [PATCH 0905/1963] Upgrade to latest version of Alloy and port Anvil tests (#7701) * add: alloy utils and fix anvil tests * fix: clippy * migrate`can_order_transactions` test * migrate(anvil/tests): transactions - `can_respect_nonces`, `can_replace_transaction`, `can_reject_too_high_gas_limits`, `can_reject_underpriced_replacement` * add: provider with signer utils * use: sol! in abi * start porting anvil_api tests * additional tests * add: can_impersonate_gnosis_safe * add: can_impersonate_multiple_account * add: can_mine_manually + test_set_next_timestamp * more tests * add: test_can_set_storage_bsc_fork * port the rest of the tests, final test is blocked on lack of txpool_inspect methods on the provider, see https://github.com/alloy-rs/alloy/issues/502 * simplify types * use provider_with_signer, unclear exactly if it will interact as expected in relation to impersonation * migrate(anvil/tests): `can_deploy_greeter_http`, `can_deploy_and_mine_manually` tx tests migrated to alloy * migrate(anvil/tests): `can_mine_automatically`, `can_call_greeter_historic` tx tests to alloy * migrate(anvil/test): tx tests migrated to alloy - TODOs remaining * migrate transaction::test_tx_access_list to alloy * nit * migrate(anvil/tests): transactions::call_past_state * migrate(anvil/tests): can_handle_multiple_concurrent_deploys_with_same_nonce & can_handle_multiple_concurrent_transactions_with_same_nonce tx tests * migrate: tx test stream_pending_txs - fix TODO * start on api * finish api examples, softly blocked on simulated call overrides - needs some more investigation * clean up imports * specify from on contract builder * finish ganache tests * wrap up ganache, start on gas * add gas tests * considering these tests are ignored is it necessary to keep them around? * add back ganache and geth * port geth * add ipc * add txpool, missing methods * migrates(anvil/tests): `fork` tests to alloy - fix TODOs * migrate(anvil/tests): trace tests to alloy - fix `debug_*` TODO * bump alloy - satisfy clippy * bump alloy & migrate sign examples * fix revm-inspectors * use latest evm-inspectors version * start fixing broken test ports * fix test_tip_above_fee_cap * fix broken tests, long running websocket / ipc tests still have issues * add can_call_with_state_override test * re-enable txpool test body * add logs:get_past_events test * add logs:get_all_events * add logs:watch_events * pubsub utils * yash/anvil-to-alloy (#7705) * migrate(anvil/tests): pubsub * pubsub tests to alloy * nit * nits * nit:test_sub_new_heads_fast * fix api:can_get_pending_block * temporarily change ipc_provider to connect_pubsub, add ignores to breaking tests relying on #389 * fix gas:test_respect_base_fee * fix api:can_call_on_pending_block * add note on broken test to revisit, all tests should run now * add temp attempt at optimism port, not behaving an expected and a lot of conversions * revert for now * start porting otterscan * continue adding otterscan tests * another otterscan test case * finish otterscan tests * clean up imports * start porting revert tests * fix(anvil/tests): TODOs * bump alloy * nit * nits * bump alloy to fix test_fork_uncles_fetch * fmt nits * nit * rm abigen from abi * nit * rm unused ethers utils * finish revert examples * clean up imports and commits, use dynamic complilation where previously implemented * port optimism * lift comment to todo * clean up imports, start porting leftover ethers references * inline alloy namespace in foundry-common * remove runtime_client, unnecessary imports * fix: test_sub_new_heads_fast using workaround * port jwt * update alloy / alloy-core / evm-inspectors * remove hex dep * add missing hex * implement txkind change, issues around test running - spotty * cast differently, still not working * rm ignore fork tests * fix: clippy * nits * fix flaky test, make sure block is available by mining it * fix cargo hack check * ignore specific ipc error on windows * append to previous commit, same ipc issue * http_provider(&handle.http_endpoint()) -> handle.http_provider() * apply for ws_provider and ipc_provider as well, re-enable can_remove_pool_transactions * refactor test_sub_new_heads_fast * remove redundant RpcUrl alias * temp enable ipc tests for windows with debug * attempt fix of ipc issue with tempfile, as used in Alloy test suite * fix(anvil/tests): can_replace_transaction * explicitly enable mocking for tests * attempt ipc prefix * enhance error, ignore failing ipc tests on windows for now --------- Co-authored-by: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> --- Cargo.lock | 79 +- Cargo.toml | 10 +- crates/anvil/Cargo.toml | 19 +- crates/anvil/core/src/eth/transaction/mod.rs | 16 +- crates/anvil/src/config.rs | 3 +- crates/anvil/src/eth/api.rs | 6 +- crates/anvil/src/eth/backend/fork.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 30 +- crates/anvil/src/eth/error.rs | 14 +- crates/anvil/src/eth/pool/mod.rs | 4 +- crates/anvil/src/filter.rs | 6 +- crates/anvil/src/lib.rs | 2 +- crates/anvil/tests/it/abi.rs | 96 +- crates/anvil/tests/it/anvil.rs | 41 +- crates/anvil/tests/it/anvil_api.rs | 434 ++++---- crates/anvil/tests/it/api.rs | 333 +++--- crates/anvil/tests/it/fork.rs | 608 +++++------ crates/anvil/tests/it/ganache.rs | 216 ++-- crates/anvil/tests/it/gas.rs | 157 ++- crates/anvil/tests/it/genesis.rs | 5 +- crates/anvil/tests/it/geth.rs | 105 +- crates/anvil/tests/it/ipc.rs | 16 +- crates/anvil/tests/it/logs.rs | 252 +++-- crates/anvil/tests/it/main.rs | 4 +- crates/anvil/tests/it/optimism.rs | 215 ++-- crates/anvil/tests/it/otterscan.rs | 509 +++++---- crates/anvil/tests/it/proof.rs | 3 +- crates/anvil/tests/it/pubsub.rs | 255 +++-- crates/anvil/tests/it/revert.rs | 247 +++-- crates/anvil/tests/it/sign.rs | 39 +- crates/anvil/tests/it/traces.rs | 245 ++--- crates/anvil/tests/it/transaction.rs | 975 ++++++++++-------- crates/anvil/tests/it/txpool.rs | 36 +- crates/anvil/tests/it/utils.rs | 124 +-- crates/anvil/tests/it/wsapi.rs | 7 +- crates/cast/Cargo.toml | 8 +- crates/cast/bin/cmd/call.rs | 4 +- crates/cast/bin/cmd/estimate.rs | 4 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/tx.rs | 2 +- crates/cast/src/lib.rs | 3 +- crates/cheatcodes/Cargo.toml | 5 +- crates/cheatcodes/src/evm/fork.rs | 2 +- crates/cheatcodes/src/inspector.rs | 6 +- crates/cli/src/utils/mod.rs | 12 +- crates/common/Cargo.toml | 26 +- crates/common/src/ens.rs | 1 + crates/common/src/fmt/ui.rs | 25 - crates/common/src/lib.rs | 2 - crates/common/src/provider/alloy.rs | 324 ------ crates/common/src/provider/ethers.rs | 283 ----- crates/common/src/provider/mod.rs | 325 +++++- .../common/src/provider/runtime_transport.rs | 22 +- crates/common/src/runtime_client.rs | 337 ------ crates/common/src/types.rs | 210 ---- crates/evm/core/src/fork/backend.rs | 2 +- crates/evm/core/src/fork/database.rs | 2 +- crates/evm/core/src/fork/multi.rs | 4 +- crates/evm/core/src/opts.rs | 7 +- crates/forge/Cargo.toml | 13 +- crates/forge/bin/cmd/create.rs | 5 +- crates/forge/tests/cli/utils.rs | 39 +- crates/script/src/broadcast.rs | 12 +- crates/script/src/build.rs | 2 +- crates/script/src/execute.rs | 4 +- crates/script/src/lib.rs | 3 +- crates/script/src/providers.rs | 6 +- crates/script/src/receipts.rs | 2 +- crates/script/src/simulate.rs | 6 +- crates/script/src/transaction.rs | 6 +- crates/test-utils/src/script.rs | 2 +- crates/verify/src/bytecode.rs | 2 +- crates/wallets/src/wallet_signer.rs | 8 +- 73 files changed, 3133 insertions(+), 3708 deletions(-) delete mode 100644 crates/common/src/provider/alloy.rs delete mode 100644 crates/common/src/provider/ethers.rs delete mode 100644 crates/common/src/runtime_client.rs delete mode 100644 crates/common/src/types.rs diff --git a/Cargo.lock b/Cargo.lock index 1c081fb297e22..0076ecc4210dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,6 +101,7 @@ dependencies = [ "alloy-network", "alloy-primitives", "alloy-provider", + "alloy-pubsub", "alloy-rpc-types", "alloy-sol-types", "alloy-transport", @@ -335,6 +336,23 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-rpc-types-engine" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-rpc-types", + "alloy-serde", + "jsonwebtoken 9.3.0", + "rand 0.8.5", + "serde", + "thiserror", +] + [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" @@ -542,7 +560,9 @@ dependencies = [ "futures", "interprocess", "pin-project", + "serde", "serde_json", + "tempfile", "tokio", "tokio-util", "tracing", @@ -668,20 +688,26 @@ version = "0.2.0" dependencies = [ "alloy-chains", "alloy-consensus", + "alloy-contract", "alloy-dyn-abi", "alloy-eips", "alloy-genesis", "alloy-json-abi", + "alloy-json-rpc", "alloy-network", "alloy-primitives", "alloy-provider", + "alloy-pubsub", "alloy-rlp", + "alloy-rpc-client", "alloy-rpc-types", "alloy-rpc-types-trace", "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", "alloy-transport", + "alloy-transport-ipc", + "alloy-transport-ws", "alloy-trie", "anvil-core", "anvil-rpc", @@ -3136,7 +3162,7 @@ dependencies = [ "hashers", "http 0.2.12", "instant", - "jsonwebtoken", + "jsonwebtoken 8.3.0", "once_cell", "pin-project", "reqwest 0.11.27", @@ -3460,7 +3486,6 @@ dependencies = [ "dialoguer", "dunce", "ethers-contract", - "ethers-core", "evm-disassembler", "eyre", "forge-doc", @@ -3761,7 +3786,7 @@ dependencies = [ "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", - "alloy-signer-wallet", + "alloy-rpc-types-engine", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3770,12 +3795,7 @@ dependencies = [ "async-trait", "clap", "comfy-table", - "const-hex", "dunce", - "ethers-core", - "ethers-middleware", - "ethers-providers", - "ethers-signers", "eyre", "foundry-block-explorers", "foundry-compilers", @@ -3787,7 +3807,6 @@ dependencies = [ "num-format", "once_cell", "pretty_assertions", - "reqwest 0.11.27", "reqwest 0.12.4", "rustc-hash", "semver 1.0.22", @@ -3805,9 +3824,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a73252c7753488cf7779e2788e05088b3b3d9198fbbc5d4da94b5afd0f751d" +checksum = "e5421772f768d43f81052159c5175e7d10941e0f0416dafd768f353ed9c554fd" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -5200,9 +5219,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -5234,13 +5253,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ "base64 0.21.7", - "pem", + "pem 1.1.1", "ring 0.16.20", "serde", "serde_json", "simple_asn1", ] +[[package]] +name = "jsonwebtoken" +version = "9.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" +dependencies = [ + "base64 0.21.7", + "js-sys", + "pem 3.0.4", + "ring 0.17.8", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "k256" version = "0.13.3" @@ -6148,6 +6182,16 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.0", + "serde", +] + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -6888,7 +6932,6 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.11", - "rustls-native-certs 0.6.3", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -7233,7 +7276,7 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki 0.102.3", "subtle", "zeroize", ] @@ -7300,9 +7343,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" dependencies = [ "ring 0.17.8", "rustls-pki-types", diff --git a/Cargo.toml b/Cargo.toml index 08b4080bfaa14..3513cf6c18e5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,7 +155,6 @@ ethers-contract = { version = "2.0.14", default-features = false } ethers-contract-abigen = { version = "2.0.14", default-features = false } ethers-providers = { version = "2.0.14", default-features = false } ethers-signers = { version = "2.0.14", default-features = false } -ethers-middleware = { version = "2.0.14", default-features = false } ## alloy alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } @@ -168,6 +167,7 @@ alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "8808d2 alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } @@ -180,10 +180,10 @@ alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "8808d alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } -alloy-dyn-abi = "0.7.0" -alloy-json-abi = "0.7.0" -alloy-sol-types = "0.7.0" -syn-solidity = "0.7.0" +alloy-dyn-abi = "0.7.1" +alloy-json-abi = "0.7.1" +alloy-sol-types = "0.7.1" +syn-solidity = "0.7.1" alloy-chains = "0.1" alloy-trie = "0.3.1" alloy-rlp = "0.3.3" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index b067bfd04f802..afbf940fb8b1a 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,7 +16,11 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # foundry internal @@ -34,6 +38,7 @@ k256.workspace = true ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } alloy-primitives = { workspace = true, features = ["serde"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } +alloy-contract = { workspace = true, features = ["pubsub"] } alloy-network.workspace = true alloy-eips.workspace = true alloy-rlp.workspace = true @@ -77,7 +82,11 @@ rand = "0.8" eyre.workspace = true # cli -clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } +clap = { version = "4", features = [ + "derive", + "env", + "wrap_help", +], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" @@ -94,8 +103,12 @@ alloy-json-abi.workspace = true ethers = { workspace = true, features = ["abigen", "optimism"] } ethers-core = { workspace = true, features = ["optimism"] } foundry-compilers = { workspace = true, features = ["project-util", "full"] } +alloy-rpc-client = { workspace = true, features = ["pubsub"] } +alloy-transport-ipc = { workspace = true, features = ["mock"] } +alloy-transport-ws.workspace = true +alloy-json-rpc.workspace = true +alloy-pubsub.workspace = true foundry-test-utils.workspace = true - pretty_assertions.workspace = true tokio = { version = "1", features = ["full"] } crc = "3.0.1" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 2617266364bbc..3c60bb3a6fee0 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -58,13 +58,12 @@ pub fn transaction_request_to_typed( other, } = tx; - let to = if let Some(TxKind::Call(to)) = to { TxKind::Call(to) } else { TxKind::Create }; // Special case: OP-stack deposit tx if transaction_type == Some(126) { return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { from: from.unwrap_or_default(), source_hash: other.get_deserialized::("sourceHash")?.ok()?, - kind: to, + kind: to.unwrap_or_default(), mint: other.get_deserialized::("mint")?.ok()?, value: value.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), @@ -93,7 +92,7 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to, + to: to.unwrap_or_default(), chain_id: None, })) } @@ -106,7 +105,7 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to, + to: to.unwrap_or_default(), chain_id: 0, access_list: access_list.unwrap_or_default(), })) @@ -124,13 +123,13 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to, + to: to.unwrap_or_default(), chain_id: 0, access_list: access_list.unwrap_or_default(), })) } // EIP4844 - (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), TxKind::Call(to)) => { + (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), Some(to)) => { let tx = TxEip4844 { nonce: nonce.unwrap_or_default(), max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), @@ -139,7 +138,10 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to, + to: match to { + TxKind::Call(to) => to, + TxKind::Create => Address::ZERO, + }, chain_id: 0, access_list: access_list.unwrap_or_default(), blob_versioned_hashes: blob_versioned_hashes.unwrap_or_default(), diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 883e1dd449214..a5eb3237fa374 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -27,8 +27,7 @@ use alloy_signer_wallet::{ use alloy_transport::{Transport, TransportError}; use anvil_server::ServerConfig; use foundry_common::{ - provider::alloy::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, - REQUEST_TIMEOUT, + provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, }; use foundry_config::Config; use foundry_evm::{ diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index ac1760c6d9b6b..ba9965faafcd1 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -62,7 +62,7 @@ use anvil_core::{ }, }; use anvil_rpc::{error::RpcError, response::ResponseResult}; -use foundry_common::provider::alloy::ProviderBuilder; +use foundry_common::provider::ProviderBuilder; use foundry_evm::{ backend::DatabaseError, decode::RevertDecoder, @@ -2188,11 +2188,11 @@ impl EthApi { { // If the request is a simple native token transfer we can optimize // We assume it's a transfer if we have no input data. - let to = if let Some(TxKind::Call(to)) = request.to { Some(to) } else { None }; + let to = request.to.as_ref().and_then(TxKind::to); let likely_transfer = request.input.clone().into_input().is_none(); if likely_transfer { if let Some(to) = to { - if let Ok(target_code) = self.backend.get_code_with_state(&state, to) { + if let Ok(target_code) = self.backend.get_code_with_state(&state, *to) { if target_code.as_ref().is_empty() { return Ok(MIN_TRANSACTION_GAS); } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 0f4a04f86a817..0d456b3c613b2 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -14,7 +14,7 @@ use alloy_rpc_types_trace::{ }; use alloy_transport::TransportError; use anvil_core::eth::transaction::{convert_to_anvil_receipt, ReceiptResponse}; -use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; +use foundry_common::provider::{ProviderBuilder, RetryProvider}; use parking_lot::{ lock_api::{RwLockReadGuard, RwLockWriteGuard}, RawRwLock, RwLock, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 1e82700ed87cf..994dde5fd6d67 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -28,10 +28,7 @@ use crate::{ inspector::Inspector, storage::{BlockchainStorage, InMemoryBlockStates, MinedBlockOutcome}, }, - revm::{ - db::DatabaseRef, - primitives::{AccountInfo, U256 as rU256}, - }, + revm::{db::DatabaseRef, primitives::AccountInfo}, NodeConfig, PrecompileFactory, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; @@ -60,7 +57,6 @@ use anvil_core::{ }; use anvil_rpc::error::RpcError; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; -use foundry_common::types::ToAlloy; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, @@ -419,7 +415,7 @@ impl Backend { env.cfg.chain_id = fork.chain_id(); env.block = BlockEnv { - number: rU256::from(fork_block_number), + number: U256::from(fork_block_number), timestamp: U256::from(fork_block.header.timestamp), gas_limit: U256::from(fork_block.header.gas_limit), difficulty: fork_block.header.difficulty, @@ -720,7 +716,7 @@ impl Backend { let mut env = self.env.write(); env.block = BlockEnv { - number: rU256::from(num), + number: U256::from(num), timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, // ensures prevrandao is set @@ -937,9 +933,9 @@ impl Backend { } // increase block number for this block - env.block.number = env.block.number.saturating_add(rU256::from(1)); + env.block.number = env.block.number.saturating_add(U256::from(1)); env.block.basefee = U256::from(current_base_fee); - env.block.timestamp = rU256::from(self.time.next_timestamp()); + env.block.timestamp = U256::from(self.time.next_timestamp()); let best_hash = self.blockchain.storage.read().best_hash; @@ -1038,7 +1034,7 @@ impl Backend { } // we intentionally set the difficulty to `0` for newer blocks - env.block.difficulty = rU256::from(0); + env.block.difficulty = U256::from(0); // update env with new values *self.env.write() = env; @@ -1120,14 +1116,14 @@ impl Backend { let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); let caller = from.unwrap_or_default(); - let to = if let Some(TxKind::Call(addr)) = to { Some(addr) } else { None }; + let to = to.as_ref().and_then(TxKind::to); env.tx = TxEnv { caller, gas_limit: gas_limit as u64, gas_price: U256::from(gas_price), gas_priority_fee: max_priority_fee_per_gas.map(U256::from), transact_to: match to { - Some(addr) => TransactTo::Call(addr), + Some(addr) => TransactTo::Call(*addr), None => TransactTo::Create(CreateScheme::Create), }, value: value.unwrap_or_default(), @@ -1669,7 +1665,7 @@ impl Backend { .with_pending_block(pool_transactions, |state, block| { let block = block.block; let block = BlockEnv { - number: block.header.number.to_alloy(), + number: U256::from(block.header.number), coinbase: block.header.beneficiary, timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, @@ -1697,9 +1693,9 @@ impl Backend { .and_then(|block| Some((states.get(&block.header.hash_slow())?, block))) { let block = BlockEnv { - number: block.header.number.to_alloy(), + number: U256::from(block.header.number), coinbase: block.header.beneficiary, - timestamp: rU256::from(block.header.timestamp), + timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, prevrandao: Some(block.header.mix_hash), basefee: U256::from(block.header.base_fee_per_gas.unwrap_or_default()), @@ -1722,8 +1718,8 @@ impl Backend { let gen_db = self.genesis.state_db_at_genesis(Box::new(&*db)); block.number = block_number; - block.timestamp = rU256::from(fork.timestamp()); - block.basefee = rU256::from(fork.base_fee().unwrap_or_default()); + block.timestamp = U256::from(fork.timestamp()); + block.basefee = U256::from(fork.base_fee().unwrap_or_default()); return Ok(f(Box::new(&gen_db), block)); } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 9bd3d64a4beea..cc7517b42de91 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -1,8 +1,8 @@ //! Aggregated error type for this module use crate::eth::pool::transactions::PoolTransaction; -use alloy_primitives::{Bytes, SignatureError as AlloySignatureError}; -use alloy_signer::Error as AlloySignerError; +use alloy_primitives::{Bytes, SignatureError}; +use alloy_signer::Error as SignerError; use alloy_transport::TransportError; use anvil_rpc::{ error::{ErrorCode, RpcError}, @@ -44,9 +44,9 @@ pub enum BlockchainError { #[error("Prevrandao not in th EVM's environment after merge")] PrevrandaoNotSet, #[error(transparent)] - AlloySignatureError(#[from] AlloySignatureError), + SignatureError(#[from] SignatureError), #[error(transparent)] - AlloySignerError(#[from] AlloySignerError), + SignerError(#[from] SignerError), #[error("Rpc Endpoint not implemented")] RpcUnimplemented, #[error("Rpc error {0:?}")] @@ -356,10 +356,8 @@ impl ToRpcResponseResult for Result { BlockchainError::FailedToDecodeStateDump => { RpcError::invalid_params("Failed to decode state dump") } - BlockchainError::AlloySignerError(err) => RpcError::invalid_params(err.to_string()), - BlockchainError::AlloySignatureError(err) => { - RpcError::invalid_params(err.to_string()) - } + BlockchainError::SignerError(err) => RpcError::invalid_params(err.to_string()), + BlockchainError::SignatureError(err) => RpcError::invalid_params(err.to_string()), BlockchainError::RpcUnimplemented => { RpcError::internal_error_with("Not implemented") } diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index ace226fe5e740..c94fafaca5780 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -75,8 +75,8 @@ impl Pool { /// Returns the number of tx that are ready and queued for further execution pub fn txpool_status(&self) -> TxpoolStatus { // Note: naming differs here compared to geth's `TxpoolStatus` - let pending = self.ready_transactions().count() as u64; - let queued = self.inner.read().pending_transactions.len() as u64; + let pending: u64 = self.ready_transactions().count().try_into().unwrap_or(0); + let queued: u64 = self.inner.read().pending_transactions.len().try_into().unwrap_or(0); TxpoolStatus { pending, queued } } diff --git a/crates/anvil/src/filter.rs b/crates/anvil/src/filter.rs index 60dce6b669568..268a8f46eb58d 100644 --- a/crates/anvil/src/filter.rs +++ b/crates/anvil/src/filter.rs @@ -5,7 +5,7 @@ use crate::{ StorageInfo, }; use alloy_primitives::TxHash; -use alloy_rpc_types::{Filter, FilteredParams, Log as AlloyLog}; +use alloy_rpc_types::{Filter, FilteredParams, Log}; use anvil_core::eth::subscription::SubscriptionId; use anvil_rpc::response::ResponseResult; use futures::{channel::mpsc::Receiver, Stream, StreamExt}; @@ -162,14 +162,14 @@ pub struct LogsFilter { /// existing logs that matched the filter when the listener was installed /// /// They'll be returned on the first pill - pub historic: Option>, + pub historic: Option>, } // === impl LogsFilter === impl LogsFilter { /// Returns all the logs since the last time this filter was polled - pub fn poll(&mut self, cx: &mut Context<'_>) -> Vec { + pub fn poll(&mut self, cx: &mut Context<'_>) -> Vec { let mut logs = self.historic.take().unwrap_or_default(); while let Poll::Ready(Some(block)) = self.blocks.poll_next_unpin(cx) { let b = self.storage.block(block.hash); diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index b08fd7e9c6654..ce6a85411e8e1 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -19,7 +19,7 @@ use crate::{ use alloy_primitives::{Address, U256}; use alloy_signer_wallet::LocalWallet; use eth::backend::fork::ClientFork; -use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider}; +use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; use parking_lot::Mutex; diff --git a/crates/anvil/tests/it/abi.rs b/crates/anvil/tests/it/abi.rs index c9cb0d7b1d818..fda13dc46327d 100644 --- a/crates/anvil/tests/it/abi.rs +++ b/crates/anvil/tests/it/abi.rs @@ -1,49 +1,52 @@ -//! commonly used abigen generated types +//! commonly used sol generated types +use alloy_sol_types::sol; -use ethers::{ - contract::{abigen, EthEvent}, - types::Address, -}; +sol!( + #[sol(rpc)] + Greeter, + "test-data/greeter.json" +); -#[derive(Clone, Debug, EthEvent)] -pub struct ValueChanged { - #[ethevent(indexed)] - pub old_author: Address, - #[ethevent(indexed)] - pub new_author: Address, - pub old_value: String, - pub new_value: String, -} +sol!( + #[derive(Debug)] + #[sol(rpc)] + SimpleStorage, + "test-data/SimpleStorage.json" +); -abigen!(Greeter, "test-data/greeter.json"); -abigen!(SimpleStorage, "test-data/SimpleStorage.json"); -abigen!(MulticallContract, "test-data/multicall.json"); -abigen!( - Erc721, - r#"[ - balanceOf(address)(uint256) - ownerOf(uint256)(address) - name()(string) - symbol()(string) - tokenURI(uint256)(string) - getApproved(uint256)(address) - setApprovalForAll(address,bool) - isApprovedForAll(address,address) - transferFrom(address,address,uint256) - safeTransferFrom(address,address,uint256,bytes) - _transfer(address,address,uint256) - _approve(address, uint256) - _burn(uint256) - _safeMint(address,uint256,bytes) - _mint(address,uint256) - _exists(uint256)(bool) -]"# +sol!( + #[sol(rpc)] + MulticallContract, + "test-data/multicall.json" +); + +sol!( + #[sol(rpc)] + contract BUSD { + function balanceOf(address) external view returns (uint256); + } ); -abigen!( - BUSD, - r#"[ - balanceOf(address)(uint256) -]"# + +sol!( + #[sol(rpc)] + interface ERC721 { + function balanceOf(address owner) public view virtual returns (uint256); + function ownerOf(uint256 tokenId) public view virtual returns (address); + function name() public view virtual returns (string memory); + function symbol() public view virtual returns (string memory); + function tokenURI(uint256 tokenId) public view virtual returns (string memory); + function getApproved(uint256 tokenId) public view virtual returns (address); + function setApprovalForAll(address operator, bool approved) public virtual; + function isApprovedForAll(address owner, address operator) public view virtual returns (bool); + function transferFrom(address from, address to, uint256 tokenId) public virtual; + function safeTransferFrom(address from, address to, uint256 tokenId) public; + function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual; + function _mint(address to, uint256 tokenId) internal; + function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual; + function _burn(uint256 tokenId) internal; + function _transfer(address from, address to, uint256 tokenId) internal; + function _approve(address to, uint256 tokenId, address auth) internal; + } ); // @@ -70,3 +73,12 @@ contract VendingMachine { payable(msg.sender).transfer(address(this).balance); } }"#; + +sol!( + #[sol(rpc)] + contract VendingMachine { + function buyRevert(uint amount) external payable; + function buyRequire(uint amount) external payable; + function withdraw() external; + } +); diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 3a39f7e74664a..7aff5660e6ce9 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -1,52 +1,46 @@ //! tests for anvil specific logic -use crate::utils::ethers_http_provider; +use alloy_primitives::Address; +use alloy_provider::Provider; use anvil::{spawn, NodeConfig}; -use ethers::{prelude::Middleware, types::Address}; -use foundry_common::types::ToAlloy; #[tokio::test(flavor = "multi_thread")] async fn test_can_change_mining_mode() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); assert!(api.anvil_get_auto_mine().unwrap()); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 0); + assert_eq!(num, 0); api.anvil_set_interval_mining(1).unwrap(); assert!(!api.anvil_get_auto_mine().unwrap()); // changing the mining mode will instantly mine a new block tokio::time::sleep(std::time::Duration::from_millis(500)).await; let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 0); + assert_eq!(num, 0); tokio::time::sleep(std::time::Duration::from_millis(700)).await; let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 1); + assert_eq!(num, 1); // assert that no block is mined when the interval is set to 0 api.anvil_set_interval_mining(0).unwrap(); assert!(!api.anvil_get_auto_mine().unwrap()); tokio::time::sleep(std::time::Duration::from_millis(1000)).await; let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 1); + assert_eq!(num, 1); } #[tokio::test(flavor = "multi_thread")] async fn can_get_default_dev_keys() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let dev_accounts = handle.dev_accounts().collect::>(); - let accounts = provider - .get_accounts() - .await - .unwrap() - .into_iter() - .map(ToAlloy::to_alloy) - .collect::>(); + let accounts = provider.get_accounts().await.unwrap(); + assert_eq!(dev_accounts, accounts); } @@ -54,8 +48,8 @@ async fn can_get_default_dev_keys() { async fn can_set_empty_code() { let (api, _handle) = spawn(NodeConfig::test()).await; let addr = Address::random(); - api.anvil_set_code(addr.to_alloy(), Vec::new().into()).await.unwrap(); - let code = api.get_code(addr.to_alloy(), None).await.unwrap(); + api.anvil_set_code(addr, Vec::new().into()).await.unwrap(); + let code = api.get_code(addr, None).await.unwrap(); assert!(code.as_ref().is_empty()); } @@ -64,15 +58,18 @@ async fn test_can_set_genesis_timestamp() { let genesis_timestamp = 1000u64; let (_api, handle) = spawn(NodeConfig::test().with_genesis_timestamp(genesis_timestamp.into())).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - assert_eq!(genesis_timestamp, provider.get_block(0).await.unwrap().unwrap().timestamp.as_u64()); + assert_eq!( + genesis_timestamp, + provider.get_block(0.into(), false).await.unwrap().unwrap().header.timestamp + ); } #[tokio::test(flavor = "multi_thread")] async fn test_can_use_default_genesis_timestamp() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - assert_ne!(0u64, provider.get_block(0).await.unwrap().unwrap().timestamp.as_u64()); + assert_ne!(0u64, provider.get_block(0.into(), false).await.unwrap().unwrap().header.timestamp); } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index d2826b9ed0a7a..01247fb280cc9 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -1,50 +1,45 @@ //! tests for custom anvil endpoints -use crate::{abi::*, fork::fork_config, utils::ethers_http_provider}; -use alloy_rpc_types::BlockNumberOrTag; + +use crate::{ + abi::{Greeter, MulticallContract, BUSD}, + fork::fork_config, + utils::http_provider_with_signer, +}; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{address, fixed_bytes, Address, U256, U64}; +use alloy_provider::{txpool::TxPoolApi, Provider}; +use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionRequest, WithOtherFields}; use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; use anvil_core::{ eth::EthRequest, types::{AnvilMetadata, ForkedNetwork, Forking, NodeEnvironment, NodeForkConfig, NodeInfo}, }; -use ethers::{ - abi::{ethereum_types::BigEndianHash, AbiDecode}, - prelude::{Middleware, SignerMiddleware}, - signers::Signer, - types::{ - transaction::eip2718::TypedTransaction, Address, BlockNumber, Eip1559TransactionRequest, - TransactionRequest, H256, U256, U64, - }, - utils::hex, -}; -use foundry_common::types::{ToAlloy, ToEthers}; use foundry_evm::revm::primitives::SpecId; use std::{ str::FromStr, - sync::Arc, time::{Duration, SystemTime}, }; #[tokio::test(flavor = "multi_thread")] async fn can_set_gas_price() { let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let gas_price: U256 = 1337u64.into(); - api.anvil_set_min_gas_price(gas_price.to_alloy()).await.unwrap(); - assert_eq!(gas_price, provider.get_gas_price().await.unwrap()); + let gas_price = U256::from(1337); + api.anvil_set_min_gas_price(gas_price).await.unwrap(); + assert_eq!(gas_price.to::(), provider.get_gas_price().await.unwrap()); } #[tokio::test(flavor = "multi_thread")] async fn can_set_block_gas_limit() { let (api, _) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let block_gas_limit: U256 = 1337u64.into(); - assert!(api.evm_set_block_gas_limit(block_gas_limit.to_alloy()).unwrap()); + let block_gas_limit = U256::from(1337); + assert!(api.evm_set_block_gas_limit(block_gas_limit).unwrap()); // Mine a new block, and check the new block gas limit api.mine_one().await; - let latest_block = - api.block_by_number(alloy_rpc_types::BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert_eq!(block_gas_limit.as_u128(), latest_block.header.gas_limit); + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert_eq!(block_gas_limit.to::(), latest_block.header.gas_limit); } // Ref @@ -62,227 +57,226 @@ async fn can_set_storage() { let storage_value = api.storage_at(addr, slot, None).await.unwrap(); assert_eq!(val, storage_value); - assert_eq!(val.to_ethers(), H256::from_uint(&U256::from(12345))); } #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + + let provider = handle.http_provider(); let impersonate = Address::random(); let to = Address::random(); - let val = 1337u64; + let val = U256::from(1337); let funding = U256::from(1e18 as u64); // fund the impersonated account - api.anvil_set_balance(impersonate.to_alloy(), funding.to_alloy()).await.unwrap(); + api.anvil_set_balance(impersonate, funding).await.unwrap(); - let balance = api.balance(impersonate.to_alloy(), None).await.unwrap(); - assert_eq!(balance, funding.to_alloy()); + let balance = api.balance(impersonate, None).await.unwrap(); + assert_eq!(balance, funding); - let tx = TransactionRequest::new().from(impersonate).to(to).value(val); + let tx = TransactionRequest::default().with_from(impersonate).with_to(to).with_value(val); + let tx = WithOtherFields::new(tx); - let res = provider.send_transaction(tx.clone(), None).await; + let res = provider.send_transaction(tx.clone()).await; res.unwrap_err(); - api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); - assert!(api.accounts().unwrap().contains(&impersonate.to_alloy())); + api.anvil_impersonate_account(impersonate).await.unwrap(); + assert!(api.accounts().unwrap().contains(&impersonate)); - let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, impersonate); - let nonce = provider.get_transaction_count(impersonate, None).await.unwrap(); - assert_eq!(nonce, 1u64.into()); + let nonce = provider.get_transaction_count(impersonate, BlockId::latest()).await.unwrap(); + assert_eq!(nonce, 1); - let balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance, val.into()); + let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(balance, val); - api.anvil_stop_impersonating_account(impersonate.to_alloy()).await.unwrap(); - let res = provider.send_transaction(tx, None).await; + api.anvil_stop_impersonating_account(impersonate).await.unwrap(); + let res = provider.send_transaction(tx).await; res.unwrap_err(); } #[tokio::test(flavor = "multi_thread")] async fn can_auto_impersonate_account() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + + let provider = handle.http_provider(); let impersonate = Address::random(); let to = Address::random(); - let val = 1337u64; + let val = U256::from(1337); let funding = U256::from(1e18 as u64); // fund the impersonated account - api.anvil_set_balance(impersonate.to_alloy(), funding.to_alloy()).await.unwrap(); + api.anvil_set_balance(impersonate, funding).await.unwrap(); - let balance = api.balance(impersonate.to_alloy(), None).await.unwrap(); - assert_eq!(balance, funding.to_alloy()); + let balance = api.balance(impersonate, None).await.unwrap(); + assert_eq!(balance, funding); - let tx = TransactionRequest::new().from(impersonate).to(to).value(val); + let tx = TransactionRequest::default().with_from(impersonate).with_to(to).with_value(val); + let tx = WithOtherFields::new(tx); - let res = provider.send_transaction(tx.clone(), None).await; + let res = provider.send_transaction(tx.clone()).await; res.unwrap_err(); api.anvil_auto_impersonate_account(true).await.unwrap(); - let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, impersonate); - let nonce = provider.get_transaction_count(impersonate, None).await.unwrap(); - assert_eq!(nonce, 1u64.into()); + let nonce = provider.get_transaction_count(impersonate, BlockId::latest()).await.unwrap(); + assert_eq!(nonce, 1); - let balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance, val.into()); + let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(balance, val); api.anvil_auto_impersonate_account(false).await.unwrap(); - let res = provider.send_transaction(tx, None).await; + let res = provider.send_transaction(tx).await; res.unwrap_err(); // explicitly impersonated accounts get returned by `eth_accounts` - api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); - assert!(api.accounts().unwrap().contains(&impersonate.to_alloy())); + api.anvil_impersonate_account(impersonate).await.unwrap(); + assert!(api.accounts().unwrap().contains(&impersonate)); } #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_contract() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let provider = Arc::new(SignerMiddleware::new(provider, wallet)); + let provider = handle.http_provider(); - let greeter_contract = - Greeter::deploy(provider, "Hello World!".to_string()).unwrap().send().await.unwrap(); - let impersonate = greeter_contract.address(); + let greeter_contract = Greeter::deploy(&provider, "Hello World!".to_string()).await.unwrap(); + let impersonate = greeter_contract.address().to_owned(); let to = Address::random(); - let val = 1337u64; - - let provider = ethers_http_provider(&handle.http_endpoint()); + let val = U256::from(1337); - // fund the impersonated account - api.anvil_set_balance(impersonate.to_alloy(), U256::from(1e18 as u64).to_alloy()) - .await - .unwrap(); + // // fund the impersonated account + api.anvil_set_balance(impersonate, U256::from(1e18 as u64)).await.unwrap(); - let tx = TransactionRequest::new().from(impersonate).to(to).value(val); + let tx = TransactionRequest::default().with_from(impersonate).to(to).with_value(val); + let tx = WithOtherFields::new(tx); - let res = provider.send_transaction(tx.clone(), None).await; + let res = provider.send_transaction(tx.clone()).await; res.unwrap_err(); - let greeting = greeter_contract.greet().call().await.unwrap(); + let greeting = greeter_contract.greet().call().await.unwrap()._0; assert_eq!("Hello World!", greeting); - api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(impersonate).await.unwrap(); - let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, impersonate); - let balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance, val.into()); + let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(balance, val); - api.anvil_stop_impersonating_account(impersonate.to_alloy()).await.unwrap(); - let res = provider.send_transaction(tx, None).await; + api.anvil_stop_impersonating_account(impersonate).await.unwrap(); + let res = provider.send_transaction(tx).await; res.unwrap_err(); - let greeting = greeter_contract.greet().call().await.unwrap(); + let greeting = greeter_contract.greet().call().await.unwrap()._0; assert_eq!("Hello World!", greeting); } #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_gnosis_safe() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); // - let safe: Address = "0xA063Cb7CFd8E57c30c788A0572CBbf2129ae56B6".parse().unwrap(); + let safe = address!("A063Cb7CFd8E57c30c788A0572CBbf2129ae56B6"); - let code = provider.get_code(safe, None).await.unwrap(); + let code = provider.get_code_at(safe, BlockId::default()).await.unwrap(); assert!(!code.is_empty()); - api.anvil_impersonate_account(safe.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(safe).await.unwrap(); - let code = provider.get_code(safe, None).await.unwrap(); + let code = provider.get_code_at(safe, BlockId::default()).await.unwrap(); assert!(!code.is_empty()); let balance = U256::from(1e18 as u64); // fund the impersonated account - api.anvil_set_balance(safe.to_alloy(), balance.to_alloy()).await.unwrap(); + api.anvil_set_balance(safe, balance).await.unwrap(); - let on_chain_balance = provider.get_balance(safe, None).await.unwrap(); + let on_chain_balance = provider.get_balance(safe, BlockId::latest()).await.unwrap(); assert_eq!(on_chain_balance, balance); - api.anvil_stop_impersonating_account(safe.to_alloy()).await.unwrap(); + api.anvil_stop_impersonating_account(safe).await.unwrap(); - let code = provider.get_code(safe, None).await.unwrap(); + let code = provider.get_code_at(safe, BlockId::default()).await.unwrap(); // code is added back after stop impersonating assert!(!code.is_empty()); } #[tokio::test(flavor = "multi_thread")] -async fn can_impersonate_multiple_account() { +async fn can_impersonate_multiple_accounts() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let impersonate0 = Address::random(); let impersonate1 = Address::random(); let to = Address::random(); - let val = 1337u64; + let val = U256::from(1337); let funding = U256::from(1e18 as u64); // fund the impersonated accounts - api.anvil_set_balance(impersonate0.to_alloy(), funding.to_alloy()).await.unwrap(); - api.anvil_set_balance(impersonate1.to_alloy(), funding.to_alloy()).await.unwrap(); + api.anvil_set_balance(impersonate0, funding).await.unwrap(); + api.anvil_set_balance(impersonate1, funding).await.unwrap(); - let tx = TransactionRequest::new().from(impersonate0).to(to).value(val); + let tx = TransactionRequest::default().with_from(impersonate0).to(to).with_value(val); + let tx = WithOtherFields::new(tx); - api.anvil_impersonate_account(impersonate0.to_alloy()).await.unwrap(); - api.anvil_impersonate_account(impersonate1.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(impersonate0).await.unwrap(); + api.anvil_impersonate_account(impersonate1).await.unwrap(); - let res0 = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let res0 = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res0.from, impersonate0); - let nonce = provider.get_transaction_count(impersonate0, None).await.unwrap(); - assert_eq!(nonce, 1u64.into()); + let nonce = provider.get_transaction_count(impersonate0, BlockId::latest()).await.unwrap(); + assert_eq!(nonce, 1); let receipt = provider.get_transaction_receipt(res0.transaction_hash).await.unwrap().unwrap(); - assert_eq!(res0, receipt); + assert_eq!(res0.inner, receipt.inner); let res1 = provider - .send_transaction(tx.from(impersonate1), None) + .send_transaction(tx.with_from(impersonate1)) .await .unwrap() + .get_receipt() .await - .unwrap() .unwrap(); + assert_eq!(res1.from, impersonate1); - let nonce = provider.get_transaction_count(impersonate1, None).await.unwrap(); - assert_eq!(nonce, 1u64.into()); + let nonce = provider.get_transaction_count(impersonate1, BlockId::latest()).await.unwrap(); + assert_eq!(nonce, 1); let receipt = provider.get_transaction_receipt(res1.transaction_hash).await.unwrap().unwrap(); - assert_eq!(res1, receipt); + assert_eq!(res1.inner, receipt.inner); - assert_ne!(res0, res1); + assert_ne!(res0.inner, res1.inner); } #[tokio::test(flavor = "multi_thread")] async fn can_mine_manually() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let start_num = provider.get_block_number().await.unwrap(); for (idx, _) in std::iter::repeat(()).take(10).enumerate() { api.evm_mine(None).await.unwrap(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num, start_num + idx + 1); + assert_eq!(num, start_num + idx as u64 + 1); } } #[tokio::test(flavor = "multi_thread")] async fn test_set_next_timestamp() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -293,23 +287,23 @@ async fn test_set_next_timestamp() { api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); - assert_eq!(block.number.unwrap().as_u64(), 1); - assert_eq!(block.timestamp.as_u64(), next_timestamp.as_secs()); + assert_eq!(block.header.number.unwrap(), 1); + assert_eq!(block.header.timestamp, next_timestamp.as_secs()); api.evm_mine(None).await.unwrap(); - let next = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(next.number.unwrap().as_u64(), 2); + let next = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + assert_eq!(next.header.number.unwrap(), 2); - assert!(next.timestamp > block.timestamp); + assert!(next.header.timestamp > block.header.timestamp); } #[tokio::test(flavor = "multi_thread")] async fn test_evm_set_time() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -320,20 +314,20 @@ async fn test_evm_set_time() { // mine a block api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); - assert!(block.timestamp.as_u64() >= timestamp.as_secs()); + assert!(block.header.timestamp >= timestamp.as_secs()); api.evm_mine(None).await.unwrap(); - let next = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let next = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); - assert!(next.timestamp > block.timestamp); + assert!(next.header.timestamp > block.header.timestamp); } #[tokio::test(flavor = "multi_thread")] async fn test_evm_set_time_in_past() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); @@ -344,59 +338,59 @@ async fn test_evm_set_time_in_past() { // mine a block api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); - assert!(block.timestamp.as_u64() >= timestamp.as_secs()); - assert!(block.timestamp.as_u64() < now.as_secs()); + assert!(block.header.timestamp >= timestamp.as_secs()); + assert!(block.header.timestamp < now.as_secs()); } #[tokio::test(flavor = "multi_thread")] async fn test_timestamp_interval() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); api.evm_mine(None).await.unwrap(); let interval = 10; for _ in 0..5 { - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); // mock timestamp api.evm_set_block_timestamp_interval(interval).unwrap(); api.evm_mine(None).await.unwrap(); - let new_block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let new_block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); - assert_eq!(new_block.timestamp, block.timestamp + interval); + assert_eq!(new_block.header.timestamp, block.header.timestamp + interval); } - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); - let next_timestamp = block.timestamp + 50; - api.evm_set_next_block_timestamp(next_timestamp.as_u64()).unwrap(); + let next_timestamp = block.header.timestamp + 50; + api.evm_set_next_block_timestamp(next_timestamp).unwrap(); api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(block.timestamp, next_timestamp); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + assert_eq!(block.header.timestamp, next_timestamp); api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); // interval also works after setting the next timestamp manually - assert_eq!(block.timestamp, next_timestamp + interval); + assert_eq!(block.header.timestamp, next_timestamp + interval); assert!(api.evm_remove_block_timestamp_interval().unwrap()); api.evm_mine(None).await.unwrap(); - let new_block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let new_block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); // offset is applied correctly after resetting the interval - assert!(new_block.timestamp > block.timestamp); + assert!(new_block.header.timestamp > block.header.timestamp); api.evm_mine(None).await.unwrap(); - let another_block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let another_block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); // check interval is disabled - assert!(another_block.timestamp - new_block.timestamp < U256::from(interval)); + assert!(another_block.header.timestamp - new_block.header.timestamp < interval); } // @@ -404,26 +398,25 @@ async fn test_timestamp_interval() { async fn test_can_set_storage_bsc_fork() { let (api, handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; - let provider = Arc::new(ethers_http_provider(&handle.http_endpoint())); - - let busd_addr: Address = "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56".parse().unwrap(); - let idx: U256 = - "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49".parse().unwrap(); - let value: H256 = - "0x0000000000000000000000000000000000000000000000000000000000003039".parse().unwrap(); + let provider = handle.http_provider(); - api.anvil_set_storage_at(busd_addr.to_alloy(), idx.to_alloy(), value.to_alloy()).await.unwrap(); - let storage = api.storage_at(busd_addr.to_alloy(), idx.to_alloy(), None).await.unwrap(); - assert_eq!(storage.to_ethers(), value); + let busd_addr = address!("e9e7CEA3DedcA5984780Bafc599bD69ADd087D56"); + let idx = U256::from_str("0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49") + .unwrap(); + let value = fixed_bytes!("0000000000000000000000000000000000000000000000000000000000003039"); - let input = - hex::decode("70a082310000000000000000000000000000000000000000000000000000000000000000") - .unwrap(); + api.anvil_set_storage_at(busd_addr, idx, value).await.unwrap(); + let storage = api.storage_at(busd_addr, idx, None).await.unwrap(); + assert_eq!(storage, value); - let busd = BUSD::new(busd_addr, provider); - let call = busd::BalanceOfCall::decode(&input).unwrap(); + let busd_contract = BUSD::new(busd_addr, &provider); - let balance = busd.balance_of(call.0).call().await.unwrap(); + let BUSD::balanceOfReturn { _0 } = busd_contract + .balanceOf(address!("0000000000000000000000000000000000000000")) + .call() + .await + .unwrap(); + let balance = _0; assert_eq!(balance, U256::from(12345u64)); } @@ -433,22 +426,22 @@ async fn can_get_node_info() { let node_info = api.anvil_node_info().await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let block_number = provider.get_block_number().await.unwrap(); - let block = provider.get_block(block_number).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::from(block_number), false).await.unwrap().unwrap(); let expected_node_info = NodeInfo { - current_block_number: U64([0]).to_alloy(), + current_block_number: U64::from(0), current_block_timestamp: 1, - current_block_hash: block.hash.unwrap().to_alloy(), + current_block_hash: block.header.hash.unwrap(), hard_fork: SpecId::CANCUN, transaction_order: "fees".to_owned(), environment: NodeEnvironment { - base_fee: alloy_primitives::U256::from_str("0x3b9aca00").unwrap().to(), + base_fee: U256::from_str("0x3b9aca00").unwrap().to(), chain_id: 0x7a69, - gas_limit: alloy_primitives::U256::from_str("0x1c9c380").unwrap().to(), - gas_price: alloy_primitives::U256::from_str("0x77359400").unwrap().to(), + gas_limit: U256::from_str("0x1c9c380").unwrap().to(), + gas_price: U256::from_str("0x77359400").unwrap().to(), }, fork_config: NodeForkConfig { fork_url: None, @@ -466,14 +459,14 @@ async fn can_get_metadata() { let metadata = api.anvil_metadata().await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let block_number = provider.get_block_number().await.unwrap().as_u64(); - let chain_id = provider.get_chainid().await.unwrap().as_u64(); - let block = provider.get_block(block_number).await.unwrap().unwrap(); + let block_number = provider.get_block_number().await.unwrap(); + let chain_id = provider.get_chain_id().await.unwrap(); + let block = provider.get_block(BlockId::from(block_number), false).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { - latest_block_hash: block.hash.unwrap().to_alloy(), + latest_block_hash: block.header.hash.unwrap(), latest_block_number: block_number, chain_id, client_version: CLIENT_VERSION, @@ -489,16 +482,16 @@ async fn can_get_metadata() { async fn can_get_metadata_on_fork() { let (api, handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some("https://bsc-dataseed.binance.org/"))).await; - let provider = Arc::new(ethers_http_provider(&handle.http_endpoint())); + let provider = handle.http_provider(); let metadata = api.anvil_metadata().await.unwrap(); - let block_number = provider.get_block_number().await.unwrap().as_u64(); - let chain_id = provider.get_chainid().await.unwrap().as_u64(); - let block = provider.get_block(block_number).await.unwrap().unwrap(); + let block_number = provider.get_block_number().await.unwrap(); + let chain_id = provider.get_chain_id().await.unwrap(); + let block = provider.get_block(BlockId::from(block_number), false).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { - latest_block_hash: block.hash.unwrap().to_alloy(), + latest_block_hash: block.header.hash.unwrap(), latest_block_number: block_number, chain_id, client_version: CLIENT_VERSION, @@ -506,7 +499,7 @@ async fn can_get_metadata_on_fork() { forked_network: Some(ForkedNetwork { chain_id, fork_block_number: block_number, - fork_block_hash: block.hash.unwrap().to_alloy(), + fork_block_hash: block.header.hash.unwrap(), }), snapshots: Default::default(), }; @@ -533,46 +526,45 @@ async fn metadata_changes_on_reset() { #[tokio::test(flavor = "multi_thread")] async fn test_get_transaction_receipt() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); // set the base fee - let new_base_fee = U256::from(1_000); - api.anvil_set_next_block_base_fee_per_gas(new_base_fee.to_alloy()).await.unwrap(); + let new_base_fee = U256::from(1000); + api.anvil_set_next_block_base_fee_per_gas(new_base_fee).await.unwrap(); // send a EIP-1559 transaction - let tx = - TypedTransaction::Eip1559(Eip1559TransactionRequest::new().gas(U256::from(30_000_000))); - let receipt = - provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let to = Address::random(); + let val = U256::from(1337); + let tx = TransactionRequest::default().with_to(to).with_value(val); + let tx = WithOtherFields::new(tx); + + let receipt = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); // the block should have the new base fee - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(block.base_fee_per_gas.unwrap().as_u64(), new_base_fee.as_u64()); + let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + assert_eq!(block.header.base_fee_per_gas.unwrap(), new_base_fee.to::()); - // mine block + // mine blocks api.evm_mine(None).await.unwrap(); // the transaction receipt should have the original effective gas price let new_receipt = provider.get_transaction_receipt(receipt.transaction_hash).await.unwrap(); - assert_eq!( - receipt.effective_gas_price.unwrap().as_u64(), - new_receipt.unwrap().effective_gas_price.unwrap().as_u64() - ); + assert_eq!(receipt.effective_gas_price, new_receipt.unwrap().effective_gas_price); } // test can set chain id #[tokio::test(flavor = "multi_thread")] async fn test_set_chain_id() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let chain_id = provider.get_chainid().await.unwrap(); - assert_eq!(chain_id, U256::from(31337)); + let provider = handle.http_provider(); + let chain_id = provider.get_chain_id().await.unwrap(); + assert_eq!(chain_id, 31337); let chain_id = 1234; api.anvil_set_chain_id(chain_id).await.unwrap(); - let chain_id = provider.get_chainid().await.unwrap(); - assert_eq!(chain_id, U256::from(1234)); + let chain_id = provider.get_chain_id().await.unwrap(); + assert_eq!(chain_id, 1234); } // @@ -600,7 +592,7 @@ async fn test_fork_revert_next_block_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_revert_call_latest_block_timestamp() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); // Mine a new block, and check the new block gas limit api.mine_one().await; @@ -610,48 +602,48 @@ async fn test_fork_revert_call_latest_block_timestamp() { api.mine_one().await; api.evm_revert(snapshot_id).await.unwrap(); - let multicall = MulticallContract::new( - Address::from_str("0xeefba1e63905ef1d7acba5a8513c70307c1ce441").unwrap(), - provider.into(), - ); - - assert_eq!( - multicall.get_current_block_timestamp().await.unwrap().as_u64(), - latest_block.header.timestamp - ); - assert_eq!( - multicall.get_current_block_difficulty().await.unwrap(), - latest_block.header.difficulty.to_ethers() - ); - assert_eq!( - multicall.get_current_block_gas_limit().await.unwrap().as_u128(), - latest_block.header.gas_limit - ); - assert_eq!( - multicall.get_current_block_coinbase().await.unwrap(), - latest_block.header.miner.to_ethers() - ); + let multicall_contract = + MulticallContract::new(address!("eefba1e63905ef1d7acba5a8513c70307c1ce441"), &provider); + + let MulticallContract::getCurrentBlockTimestampReturn { timestamp } = + multicall_contract.getCurrentBlockTimestamp().call().await.unwrap(); + assert_eq!(timestamp, U256::from(latest_block.header.timestamp)); + + let MulticallContract::getCurrentBlockDifficultyReturn { difficulty } = + multicall_contract.getCurrentBlockDifficulty().call().await.unwrap(); + assert_eq!(difficulty, U256::from(latest_block.header.difficulty)); + + let MulticallContract::getCurrentBlockGasLimitReturn { gaslimit } = + multicall_contract.getCurrentBlockGasLimit().call().await.unwrap(); + assert_eq!(gaslimit, U256::from(latest_block.header.gas_limit)); + + let MulticallContract::getCurrentBlockCoinbaseReturn { coinbase } = + multicall_contract.getCurrentBlockCoinbase().call().await.unwrap(); + assert_eq!(coinbase, latest_block.header.miner); } #[tokio::test(flavor = "multi_thread")] async fn can_remove_pool_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let provider = Arc::new(SignerMiddleware::new(provider, wallet.clone())); + + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let from = wallet.address(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); let sender = Address::random(); let to = Address::random(); - let val = 1337u64; - - let tx = TransactionRequest::new().from(sender).to(to).value(val); + let val = U256::from(1337); + let tx = TransactionRequest::default().with_from(sender).with_to(to).with_value(val); + let tx = WithOtherFields::new(tx); - provider.send_transaction(tx.from(wallet.address()), None).await.unwrap(); + provider.send_transaction(tx.with_from(from)).await.unwrap().register().await.unwrap(); let initial_txs = provider.txpool_inspect().await.unwrap(); assert_eq!(initial_txs.pending.len(), 1); - api.anvil_remove_pool_transactions(wallet.address().to_alloy()).await.unwrap(); + api.anvil_remove_pool_transactions(wallet.address()).await.unwrap(); let final_txs = provider.txpool_inspect().await.unwrap(); assert_eq!(final_txs.pending.len(), 0); diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 1afa76df1cbf5..ec8335562f79a 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -2,41 +2,29 @@ use crate::{ abi::{MulticallContract, SimpleStorage}, - utils::ethers_http_provider, + utils::{connect_pubsub_with_signer, http_provider_with_signer}, }; -use alloy_eips::BlockId; -use alloy_primitives::{Address as rAddress, TxKind, B256, U256 as rU256}; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{Address, ChainId, B256, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ - request::{TransactionInput as CallInput, TransactionRequest as CallRequest}, - state::{AccountOverride, StateOverride}, - WithOtherFields, + request::TransactionRequest, state::AccountOverride, BlockId, BlockNumberOrTag, + BlockTransactions, WithOtherFields, }; -use anvil::{ - eth::{api::CLIENT_VERSION, EthApi}, - spawn, NodeConfig, CHAIN_ID, -}; -use ethers::{ - abi::{Address, Tokenizable}, - prelude::{builders::ContractCall, decode_function_data, Middleware, SignerMiddleware}, - signers::Signer, - types::{Block, BlockNumber, Chain, Transaction, TransactionRequest, U256}, - utils::get_contract_address, -}; -use foundry_common::types::{ToAlloy, ToEthers}; -use std::{collections::HashMap, sync::Arc, time::Duration}; +use anvil::{eth::api::CLIENT_VERSION, spawn, NodeConfig, CHAIN_ID}; +use std::{collections::HashMap, time::Duration}; #[tokio::test(flavor = "multi_thread")] async fn can_get_block_number() { let (api, handle) = spawn(NodeConfig::test()).await; let block_num = api.block_number().unwrap(); - assert_eq!(block_num, U256::zero().to_alloy()); + assert_eq!(block_num, U256::from(0)); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num, block_num.to::().into()); + assert_eq!(num, block_num.to::()); } #[tokio::test(flavor = "multi_thread")] @@ -54,7 +42,7 @@ async fn can_dev_get_balance() { #[tokio::test(flavor = "multi_thread")] async fn can_get_price() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let _ = provider.get_gas_price().await.unwrap(); } @@ -62,7 +50,7 @@ async fn can_get_price() { #[tokio::test(flavor = "multi_thread")] async fn can_get_accounts() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let _ = provider.get_accounts().await.unwrap(); } @@ -70,31 +58,32 @@ async fn can_get_accounts() { #[tokio::test(flavor = "multi_thread")] async fn can_get_client_version() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let version = provider.client_version().await.unwrap(); + let version = provider.get_client_version().await.unwrap(); assert_eq!(CLIENT_VERSION, version); } #[tokio::test(flavor = "multi_thread")] async fn can_get_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let chain_id = provider.get_chainid().await.unwrap(); - assert_eq!(chain_id, CHAIN_ID.into()); + let chain_id = provider.get_chain_id().await.unwrap(); + assert_eq!(chain_id, CHAIN_ID); } #[tokio::test(flavor = "multi_thread")] async fn can_modify_chain_id() { - let (_api, handle) = spawn(NodeConfig::test().with_chain_id(Some(Chain::Goerli))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let (_api, handle) = + spawn(NodeConfig::test().with_chain_id(Some(ChainId::from(777_u64)))).await; + let provider = handle.http_provider(); - let chain_id = provider.get_chainid().await.unwrap(); - assert_eq!(chain_id, Chain::Goerli.into()); + let chain_id = provider.get_chain_id().await.unwrap(); + assert_eq!(chain_id, 777); let chain_id = provider.get_net_version().await.unwrap(); - assert_eq!(chain_id, (Chain::Goerli as u64).to_string()); + assert_eq!(chain_id, 777); } #[tokio::test(flavor = "multi_thread")] @@ -108,252 +97,218 @@ async fn can_get_network_id() { #[tokio::test(flavor = "multi_thread")] async fn can_get_block_by_number() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let accounts: Vec<_> = handle.dev_wallets().collect(); + let signer: EthereumSigner = accounts[0].clone().into(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); - // send a dummy transactions - let tx = TransactionRequest::new() - .to(to.to_ethers()) - .value(amount.to_ethers()) - .from(from.to_ethers()); - let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - - let block: Block = provider.get_block_with_txs(1u64).await.unwrap().unwrap(); - assert_eq!(block.transactions.len(), 1); - let block = provider.get_block(1u64).await.unwrap().unwrap(); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let val = handle.genesis_balance().checked_div(U256::from(2)).unwrap(); + + // send a dummy transaction + let tx = TransactionRequest::default().with_from(from).with_to(to).with_value(val); + let tx = WithOtherFields::new(tx); + + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); + + let block = provider.get_block(BlockId::number(1), true).await.unwrap().unwrap(); assert_eq!(block.transactions.len(), 1); - let block = provider.get_block(block.hash.unwrap()).await.unwrap().unwrap(); + let block = + provider.get_block(BlockId::hash(block.header.hash.unwrap()), true).await.unwrap().unwrap(); assert_eq!(block.transactions.len(), 1); } #[tokio::test(flavor = "multi_thread")] async fn can_get_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let accounts: Vec<_> = handle.dev_wallets().collect(); + let signer: EthereumSigner = accounts[0].clone().into(); + let from = accounts[0].address(); + let to = accounts[1].address(); - let block = provider.get_block(BlockNumber::Pending).await.unwrap().unwrap(); + let provider = connect_pubsub_with_signer(&handle.http_endpoint(), signer).await; - assert_eq!(block.number.unwrap().as_u64(), 1u64); + let block = provider.get_block(BlockId::pending(), false).await.unwrap().unwrap(); + assert_eq!(block.header.number.unwrap(), 1); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 0u64); + assert_eq!(num, 0); api.anvil_set_auto_mine(false).await.unwrap(); - let from = accounts[0].address(); - let to = accounts[1].address(); - let tx = TransactionRequest::new().to(to.to_ethers()).value(100u64).from(from.to_ethers()); + let tx = TransactionRequest::default().with_from(from).with_to(to).with_value(U256::from(100)); - let tx = provider.send_transaction(tx, None).await.unwrap(); + let pending = provider.send_transaction(tx.clone()).await.unwrap().register().await.unwrap(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 0u64); + assert_eq!(num, 0); - let block = provider.get_block(BlockNumber::Pending).await.unwrap().unwrap(); - assert_eq!(block.number.unwrap().as_u64(), 1u64); + let block = provider.get_block(BlockId::pending(), false).await.unwrap().unwrap(); + assert_eq!(block.header.number.unwrap(), 1); assert_eq!(block.transactions.len(), 1); - assert_eq!(block.transactions, vec![tx.tx_hash()]); + assert_eq!(block.transactions, BlockTransactions::Hashes(vec![*pending.tx_hash()])); - let block = provider.get_block_with_txs(BlockNumber::Pending).await.unwrap().unwrap(); - assert_eq!(block.number.unwrap().as_u64(), 1u64); + let block = provider.get_block(BlockId::pending(), true).await.unwrap().unwrap(); + assert_eq!(block.header.number.unwrap(), 1); assert_eq!(block.transactions.len(), 1); } #[tokio::test(flavor = "multi_thread")] async fn can_call_on_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 0u64); - - api.anvil_set_auto_mine(false).await.unwrap(); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); let sender = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - let mut deploy_tx = MulticallContract::deploy(Arc::clone(&client), ()).unwrap().deployer.tx; - deploy_tx.set_nonce(0); - let pending_contract_address = get_contract_address(sender, deploy_tx.nonce().unwrap()); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - client.send_transaction(deploy_tx, None).await.unwrap(); + let num = provider.get_block_number().await.unwrap(); + assert_eq!(num, 0); - let pending_contract = MulticallContract::new(pending_contract_address, client.clone()); + api.anvil_set_auto_mine(false).await.unwrap(); - let num = client.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), 0u64); + let _contract_pending = MulticallContract::deploy_builder(&provider) + .from(wallet.address()) + .send() + .await + .unwrap() + .register() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = MulticallContract::new(contract_address, &provider); + + let num = provider.get_block_number().await.unwrap(); + assert_eq!(num, 0); // Ensure that we can get the block_number from the pending contract - let (ret_block_number, _) = - pending_contract.aggregate(vec![]).block(BlockNumber::Pending).call().await.unwrap(); - assert_eq!(ret_block_number.as_u64(), 1u64); + let MulticallContract::aggregateReturn { blockNumber: ret_block_number, .. } = + contract.aggregate(vec![]).block(BlockId::pending()).call().await.unwrap(); + assert_eq!(ret_block_number, U256::from(1)); + + let accounts: Vec
= handle.dev_wallets().map(|w| w.address()).collect(); - let accounts: Vec = handle.dev_wallets().map(|w| w.address()).collect(); for i in 1..10 { api.anvil_set_coinbase(accounts[i % accounts.len()]).await.unwrap(); - api.evm_set_block_gas_limit(rU256::from(30_000_000 + i)).unwrap(); + api.evm_set_block_gas_limit(U256::from(30_000_000 + i)).unwrap(); - api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); + api.anvil_mine(Some(U256::from(1)), None).await.unwrap(); tokio::time::sleep(Duration::from_secs(1)).await; } + // Ensure that the right header values are set when calling a past block - for block_number in 1..(api.block_number().unwrap().to::() + 1) { - let block_number_alloy = alloy_rpc_types::BlockNumberOrTag::Number(block_number as u64); - let block_number_ethers = BlockNumber::Number((block_number as u64).into()); - let block = api.block_by_number(block_number_alloy).await.unwrap().unwrap(); - - let block_timestamp = pending_contract - .get_current_block_timestamp() - .block(block_number_ethers) - .call() - .await - .unwrap(); - assert_eq!(block.header.timestamp, block_timestamp.as_u64()); - - let block_gas_limit = pending_contract - .get_current_block_gas_limit() - .block(block_number_ethers) - .call() - .await - .unwrap(); - assert_eq!(block.header.gas_limit, block_gas_limit.as_u128()); - - let block_coinbase = pending_contract - .get_current_block_coinbase() - .block(block_number_ethers) - .call() - .await - .unwrap(); - assert_eq!(block.header.miner, block_coinbase.to_alloy()); + for anvil_block_number in 1..(api.block_number().unwrap().to::() + 1) { + let block_number = BlockNumberOrTag::Number(anvil_block_number as u64); + let block = api.block_by_number(block_number).await.unwrap().unwrap(); + + let MulticallContract::getCurrentBlockTimestampReturn { timestamp: ret_timestamp, .. } = + contract + .getCurrentBlockTimestamp() + .block(BlockId::number(anvil_block_number as u64)) + .call() + .await + .unwrap(); + assert_eq!(block.header.timestamp, ret_timestamp.to::()); + + let MulticallContract::getCurrentBlockGasLimitReturn { gaslimit: ret_gas_limit, .. } = + contract + .getCurrentBlockGasLimit() + .block(BlockId::number(anvil_block_number as u64)) + .call() + .await + .unwrap(); + assert_eq!(block.header.gas_limit, ret_gas_limit.to::()); + + let MulticallContract::getCurrentBlockCoinbaseReturn { coinbase: ret_coinbase, .. } = + contract + .getCurrentBlockCoinbase() + .block(BlockId::number(anvil_block_number as u64)) + .call() + .await + .unwrap(); + assert_eq!(block.header.miner, ret_coinbase); } } -async fn call_with_override( - api: &EthApi, - call: ContractCall, - to: Address, - overrides: StateOverride, -) -> D -where - D: Tokenizable, -{ - let result = api - .call( - WithOtherFields::new(CallRequest { - input: CallInput::maybe_input(call.tx.data().cloned().map(|b| b.0.into())), - to: Some(TxKind::Call(to.to_alloy())), - ..Default::default() - }), - None, - Some(overrides), - ) - .await - .unwrap(); - decode_function_data(&call.function, result.as_ref(), false).unwrap() -} - #[tokio::test(flavor = "multi_thread")] async fn can_call_with_state_override() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let account = wallet.address(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); api.anvil_set_auto_mine(true).await.unwrap(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let account = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let multicall_contract = MulticallContract::deploy(&provider).await.unwrap(); let init_value = "toto".to_string(); - let multicall = - MulticallContract::deploy(Arc::clone(&client), ()).unwrap().send().await.unwrap(); - let simple_storage = SimpleStorage::deploy(Arc::clone(&client), init_value.clone()) - .unwrap() - .send() - .await - .unwrap(); + + let simple_storage_contract = + SimpleStorage::deploy(&provider, init_value.clone()).await.unwrap(); // Test the `balance` account override - let balance = rU256::from(42u64); - let result = call_with_override( - &api, - multicall.get_eth_balance(account), - multicall.address(), - HashMap::from([( - account.to_alloy(), - AccountOverride { balance: Some(balance), ..Default::default() }, - )]), - ) - .await; - assert_eq!(result, balance.to_ethers()); + let balance = U256::from(42u64); + let overrides = HashMap::from([( + account, + AccountOverride { balance: Some(balance), ..Default::default() }, + )]); + let result = + multicall_contract.getEthBalance(account).state(overrides).call().await.unwrap().balance; + assert_eq!(result, balance); // Test the `state_diff` account override let overrides = HashMap::from([( - simple_storage.address().to_alloy(), + *simple_storage_contract.address(), AccountOverride { // The `lastSender` is in the first storage slot state_diff: Some(HashMap::from([( B256::ZERO, - rU256::from_be_slice(B256::from(account.to_alloy().into_word()).as_slice()), + U256::from_be_slice(B256::from(account.into_word()).as_slice()), )])), ..Default::default() }, )]); - let last_sender = call_with_override( - &api, - simple_storage.last_sender(), - simple_storage.address(), - Default::default(), - ) - .await; + let last_sender = + simple_storage_contract.lastSender().state(HashMap::default()).call().await.unwrap()._0; // No `sender` set without override - assert_eq!(last_sender, Address::zero()); - let last_sender = call_with_override( - &api, - simple_storage.last_sender(), - simple_storage.address(), - overrides.clone(), - ) - .await; + assert_eq!(last_sender, Address::ZERO); + + let last_sender = + simple_storage_contract.lastSender().state(overrides.clone()).call().await.unwrap()._0; // `sender` *is* set with override assert_eq!(last_sender, account); - let value = - call_with_override(&api, simple_storage.get_value(), simple_storage.address(), overrides) - .await; + + let value = simple_storage_contract.getValue().state(overrides).call().await.unwrap()._0; // `value` *is not* changed with state-diff assert_eq!(value, init_value); // Test the `state` account override let overrides = HashMap::from([( - simple_storage.address().to_alloy(), + *simple_storage_contract.address(), AccountOverride { // The `lastSender` is in the first storage slot state: Some(HashMap::from([( B256::ZERO, - rU256::from_be_slice(B256::from(account.to_alloy().into_word()).as_slice()), + U256::from_be_slice(B256::from(account.into_word()).as_slice()), )])), ..Default::default() }, )]); - let last_sender = call_with_override( - &api, - simple_storage.last_sender(), - simple_storage.address(), - overrides.clone(), - ) - .await; + let last_sender = + simple_storage_contract.lastSender().state(overrides.clone()).call().await.unwrap()._0; // `sender` *is* set with override assert_eq!(last_sender, account); - let value = - call_with_override(&api, simple_storage.get_value(), simple_storage.address(), overrides) - .await; + + let value = simple_storage_contract.getValue().state(overrides).call().await.unwrap()._0; // `value` *is* changed with state assert_eq!(value, ""); } diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index f22d22a917045..2ef1e70788196 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1,30 +1,20 @@ //! various fork related test use crate::{ - abi::*, - utils::{self, ethers_http_provider}, + abi::{Greeter, ERC721}, + utils::{http_provider, http_provider_with_signer}, }; -use alloy_primitives::{address, TxKind, U256 as rU256}; -use alloy_provider::Provider as AlloyProvider; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{address, Address, Bytes, TxKind, U256}; +use alloy_provider::Provider; use alloy_rpc_types::{ - request::{TransactionInput, TransactionRequest as CallRequest}, + request::{TransactionInput, TransactionRequest}, BlockId, BlockNumberOrTag, WithOtherFields, }; +use alloy_signer_wallet::LocalWallet; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; -use ethers::{ - prelude::{Bytes, LocalWallet, Middleware, SignerMiddleware}, - providers::{Http, Provider}, - signers::Signer, - types::{ - transaction::eip2718::TypedTransaction, Address, BlockNumber, Chain, TransactionRequest, - U256, - }, -}; -use foundry_common::{ - provider::alloy::get_http_provider, - types::{ToAlloy, ToEthers}, -}; +use foundry_common::provider::get_http_provider; use foundry_config::Config; use foundry_test_utils::rpc::{self, next_http_rpc_endpoint}; use futures::StreamExt; @@ -75,18 +65,18 @@ async fn test_spawn_fork() { assert!(api.is_fork()); let head = api.block_number().unwrap(); - assert_eq!(head, rU256::from(BLOCK_NUMBER)) + assert_eq!(head, U256::from(BLOCK_NUMBER)) } #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_balance() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); for _ in 0..10 { let addr = Address::random(); - let balance = api.balance(addr.to_alloy(), None).await.unwrap(); - let provider_balance = provider.get_balance(addr, None).await.unwrap(); - assert_eq!(balance, provider_balance.to_alloy()) + let balance = api.balance(addr, None).await.unwrap(); + let provider_balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + assert_eq!(balance, provider_balance) } } @@ -94,66 +84,65 @@ async fn test_fork_eth_get_balance() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_balance_after_mine() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let info = api.anvil_node_info().await.unwrap(); let number = info.fork_config.fork_block_number.unwrap(); assert_eq!(number, BLOCK_NUMBER); let address = Address::random(); - let _balance = provider - .get_balance(address, Some(BlockNumber::Number(number.into()).into())) - .await - .unwrap(); + let _balance = provider.get_balance(address, BlockId::Number(number.into())).await.unwrap(); api.evm_mine(None).await.unwrap(); - let _balance = provider - .get_balance(address, Some(BlockNumber::Number(number.into()).into())) - .await - .unwrap(); + let _balance = provider.get_balance(address, BlockId::Number(number.into())).await.unwrap(); } // #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_code_after_mine() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let info = api.anvil_node_info().await.unwrap(); let number = info.fork_config.fork_block_number.unwrap(); assert_eq!(number, BLOCK_NUMBER); let address = Address::random(); - let _code = - provider.get_code(address, Some(BlockNumber::Number(number.into()).into())).await.unwrap(); + let _code = provider.get_code_at(address, BlockId::Number(1.into())).await.unwrap(); api.evm_mine(None).await.unwrap(); - let _code = - provider.get_code(address, Some(BlockNumber::Number(number.into()).into())).await.unwrap(); + let _code = provider.get_code_at(address, BlockId::Number(1.into())).await.unwrap(); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_code() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); for _ in 0..10 { let addr = Address::random(); - let code = api.get_code(addr.to_alloy(), None).await.unwrap(); - let provider_code = provider.get_code(addr, None).await.unwrap(); - assert_eq!(code, provider_code.to_alloy()) + let code = api.get_code(addr, None).await.unwrap(); + let provider_code = provider.get_code_at(addr, BlockId::latest()).await.unwrap(); + assert_eq!(code, provider_code) } - for address in utils::contract_addresses(Chain::Mainnet) { + let addresses: Vec
= vec![ + "0x6b175474e89094c44da98b954eedeac495271d0f".parse().unwrap(), + "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48".parse().unwrap(), + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".parse().unwrap(), + "0x1F98431c8aD98523631AE4a59f267346ea31F984".parse().unwrap(), + "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45".parse().unwrap(), + ]; + for address in addresses { let prev_code = api - .get_code(address.to_alloy(), Some(BlockNumberOrTag::Number(BLOCK_NUMBER - 10).into())) + .get_code(address, Some(BlockNumberOrTag::Number(BLOCK_NUMBER - 10).into())) .await .unwrap(); - let code = api.get_code(address.to_alloy(), None).await.unwrap(); - let provider_code = provider.get_code(address, None).await.unwrap(); + let code = api.get_code(address, None).await.unwrap(); + let provider_code = provider.get_code_at(address, BlockId::latest()).await.unwrap(); assert_eq!(code, prev_code); - assert_eq!(code, provider_code.to_alloy()); + assert_eq!(code, provider_code); assert!(!code.as_ref().is_empty()); } } @@ -161,72 +150,70 @@ async fn test_fork_eth_get_code() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_get_nonce() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); for _ in 0..10 { let addr = Address::random(); - let api_nonce = api.transaction_count(addr.to_alloy(), None).await.unwrap(); - let provider_nonce = provider.get_transaction_count(addr, None).await.unwrap(); - assert_eq!(api_nonce, provider_nonce.to_alloy()); + let api_nonce = api.transaction_count(addr, None).await.unwrap().to::(); + let provider_nonce = provider.get_transaction_count(addr, BlockId::latest()).await.unwrap(); + assert_eq!(api_nonce, provider_nonce); } let addr = Config::DEFAULT_SENDER; - let api_nonce = api.transaction_count(addr, None).await.unwrap(); - let provider_nonce = provider.get_transaction_count(addr.to_ethers(), None).await.unwrap(); - assert_eq!(api_nonce, provider_nonce.to_alloy()); + let api_nonce = api.transaction_count(addr, None).await.unwrap().to::(); + let provider_nonce = provider.get_transaction_count(addr, BlockId::latest()).await.unwrap(); + assert_eq!(api_nonce, provider_nonce); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_fee_history() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let count = 10u64; let _history = - api.fee_history(rU256::from(count), BlockNumberOrTag::Latest, vec![]).await.unwrap(); - let _provider_history = provider.fee_history(count, BlockNumber::Latest, &[]).await.unwrap(); + api.fee_history(U256::from(count), BlockNumberOrTag::Latest, vec![]).await.unwrap(); + let _provider_history = + provider.get_fee_history(count, BlockNumberOrTag::Latest, &[]).await.unwrap(); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_reset() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); - let from = accounts[0].address().to_ethers(); - let to = accounts[1].address().to_ethers(); + let from = accounts[0].address(); + let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let balance_before = provider.get_balance(to, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); - - let initial_nonce = provider.get_transaction_count(from, None).await.unwrap(); + let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); + let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.transaction_index, 0u64.into()); + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + assert_eq!(tx.transaction_index, Some(0)); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance_before.saturating_add(amount.to_ethers()), to_balance); - api.anvil_reset(Some(Forking { - json_rpc_url: None, - block_number: Some(block_number.as_u64()), - })) - .await - .unwrap(); + let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(balance_before.saturating_add(amount), to_balance); + api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(block_number) })) + .await + .unwrap(); // reset block number assert_eq!(block_number, provider.get_block_number().await.unwrap()); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce); - let balance = provider.get_balance(from, None).await.unwrap(); - assert_eq!(balance, handle.genesis_balance().to_ethers()); - let balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance, handle.genesis_balance().to_ethers()); + let balance = provider.get_balance(from, BlockId::latest()).await.unwrap(); + assert_eq!(balance, handle.genesis_balance()); + let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(balance, handle.genesis_balance()); // reset to latest api.anvil_reset(Some(Forking::default())).await.unwrap(); @@ -238,15 +225,15 @@ async fn test_fork_reset() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_reset_setup() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let dead_addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); let block_number = provider.get_block_number().await.unwrap(); - assert_eq!(block_number, 0.into()); + assert_eq!(block_number, 0); - let local_balance = provider.get_balance(dead_addr, None).await.unwrap(); - assert_eq!(local_balance, 0.into()); + let local_balance = provider.get_balance(dead_addr, BlockId::latest()).await.unwrap(); + assert_eq!(local_balance, U256::ZERO); api.anvil_reset(Some(Forking { json_rpc_url: Some(rpc::next_http_archive_rpc_endpoint()), @@ -256,10 +243,10 @@ async fn test_fork_reset_setup() { .unwrap(); let block_number = provider.get_block_number().await.unwrap(); - assert_eq!(block_number, BLOCK_NUMBER.into()); + assert_eq!(block_number, BLOCK_NUMBER); - let remote_balance = provider.get_balance(dead_addr, None).await.unwrap(); - assert_eq!(remote_balance, DEAD_BALANCE_AT_BLOCK_NUMBER.into()); + let remote_balance = provider.get_balance(dead_addr, BlockId::latest()).await.unwrap(); + assert_eq!(remote_balance, U256::from(DEAD_BALANCE_AT_BLOCK_NUMBER)); } #[tokio::test(flavor = "multi_thread")] @@ -275,15 +262,13 @@ async fn test_fork_snapshotting() { let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); - let tx = TransactionRequest::new() - .to(to.to_ethers()) - .value(amount.to_ethers()) - .from(from.to_ethers()); + let provider = handle.http_provider(); + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); - let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let provider = handle.http_provider(); @@ -317,14 +302,12 @@ async fn test_fork_snapshotting_repeated() { let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(92u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(92u64)).unwrap(); - let tx = TransactionRequest::new() - .to(to.to_ethers()) - .value(amount.to_ethers()) - .from(from.to_ethers()); - let tx_provider = ethers_http_provider(&handle.http_endpoint()); - let _ = tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); + let tx_provider = handle.http_provider(); + let _ = tx_provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); @@ -356,7 +339,6 @@ async fn test_fork_snapshotting_repeated() { async fn test_fork_snapshotting_blocks() { let (api, handle) = spawn(fork_config()).await; let provider = handle.http_provider(); - let tx_provider = ethers_http_provider(&handle.http_endpoint()); // create a snapshot let snapshot = api.evm_snapshot().await.unwrap(); @@ -368,14 +350,12 @@ async fn test_fork_snapshotting_blocks() { let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); // send the transaction - let tx = TransactionRequest::new() - .to(to.to_ethers()) - .value(amount.to_ethers()) - .from(from.to_ethers()); - let _ = tx_provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); + let _ = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); @@ -396,7 +376,7 @@ async fn test_fork_snapshotting_blocks() { assert_eq!(block_number_after, block_number); // repeat transaction - let _ = tx_provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let _ = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); @@ -414,16 +394,16 @@ async fn test_fork_snapshotting_blocks() { #[tokio::test(flavor = "multi_thread")] async fn test_separate_states() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(14723772u64))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); - let remote_balance = provider.get_balance(addr, None).await.unwrap(); - assert_eq!(remote_balance, 12556104082473169733500u128.into()); + let remote_balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + assert_eq!(remote_balance, U256::from(12556104082473169733500u128)); - api.anvil_set_balance(addr.to_alloy(), rU256::from(1337u64)).await.unwrap(); - let balance = provider.get_balance(addr, None).await.unwrap(); - assert_eq!(balance, 1337u64.into()); + api.anvil_set_balance(addr, U256::from(1337u64)).await.unwrap(); + let balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + assert_eq!(balance, U256::from(1337u64)); let fork = api.get_fork().unwrap(); let fork_db = fork.database.read().await; @@ -433,35 +413,31 @@ async fn test_separate_states() { .db() .accounts .read() - .get(&addr.to_alloy()) + .get(&addr) .cloned() .unwrap(); - assert_eq!(acc.balance, remote_balance.to_alloy()) + assert_eq!(acc.balance, remote_balance); } #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_on_fork() { let (_api, handle) = spawn(fork_config().with_fork_block_number(Some(14723772u64))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.into(); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .send() - .await - .unwrap(); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let greeter_contract = Greeter::deploy(&provider, "Hello World!".to_string()).await.unwrap(); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); - let greeter_contract = - Greeter::deploy(client, "Hello World!".to_string()).unwrap().send().await.unwrap(); + let greeter_contract = Greeter::deploy(&provider, "Hello World!".to_string()).await.unwrap(); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); } #[tokio::test(flavor = "multi_thread")] @@ -470,7 +446,7 @@ async fn can_reset_properly() { let account = origin_handle.dev_accounts().next().unwrap(); let origin_provider = origin_handle.http_provider(); let origin_nonce = 1u64; - origin_api.anvil_set_nonce(account, rU256::from(origin_nonce)).await.unwrap(); + origin_api.anvil_set_nonce(account, U256::from(origin_nonce)).await.unwrap(); assert_eq!( origin_nonce, @@ -481,16 +457,17 @@ async fn can_reset_properly() { spawn(NodeConfig::test().with_eth_rpc_url(Some(origin_handle.http_endpoint()))).await; let fork_provider = fork_handle.http_provider(); - let fork_tx_provider = ethers_http_provider(&fork_handle.http_endpoint()); + let fork_tx_provider = http_provider(&fork_handle.http_endpoint()); assert_eq!( origin_nonce, fork_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() ); let to = Address::random(); - let to_balance = fork_provider.get_balance(to.to_alloy(), BlockId::latest()).await.unwrap(); - let tx = TransactionRequest::new().from(account.to_ethers()).to(to).value(1337u64); - let tx = fork_tx_provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let to_balance = fork_provider.get_balance(to, BlockId::latest()).await.unwrap(); + let tx = TransactionRequest::default().from(account).to(to).value(U256::from(1337u64)); + let tx = WithOtherFields::new(tx); + let tx = fork_tx_provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); // nonce incremented by 1 assert_eq!( @@ -508,13 +485,10 @@ async fn can_reset_properly() { ); // balance is reset - assert_eq!( - to_balance, - fork_provider.get_balance(to.to_alloy(), BlockId::latest()).await.unwrap() - ); + assert_eq!(to_balance, fork_provider.get_balance(to, BlockId::latest()).await.unwrap()); // tx does not exist anymore - assert!(fork_tx_provider.get_transaction(tx.transaction_hash).await.is_err()) + assert!(fork_tx_provider.get_transaction_by_hash(tx.transaction_hash).await.is_err()) } #[tokio::test(flavor = "multi_thread")] @@ -522,41 +496,48 @@ async fn test_fork_timestamp() { let start = std::time::Instant::now(); let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let block = provider.get_block(BLOCK_NUMBER).await.unwrap().unwrap(); - assert_eq!(block.timestamp.as_u64(), BLOCK_TIMESTAMP); + let block = + provider.get_block(BlockId::Number(BLOCK_NUMBER.into()), false).await.unwrap().unwrap(); + assert_eq!(block.header.timestamp, BLOCK_TIMESTAMP); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let status = tx.inner.inner.inner.receipt.status; + assert!(status); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); let elapsed = start.elapsed().as_secs() + 1; // ensure the diff between the new mined block and the original block is within the elapsed time - let diff = block.timestamp - BLOCK_TIMESTAMP; - assert!(diff <= elapsed.into(), "diff={diff}, elapsed={elapsed}"); + let diff = block.header.timestamp - BLOCK_TIMESTAMP; + assert!(diff <= elapsed, "diff={diff}, elapsed={elapsed}"); let start = std::time::Instant::now(); // reset to check timestamp works after resetting api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(BLOCK_NUMBER) })) .await .unwrap(); - let block = provider.get_block(BLOCK_NUMBER).await.unwrap().unwrap(); - assert_eq!(block.timestamp.as_u64(), BLOCK_TIMESTAMP); + let block = + provider.get_block(BlockId::Number(BLOCK_NUMBER.into()), false).await.unwrap().unwrap(); + assert_eq!(block.header.timestamp, BLOCK_TIMESTAMP); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); - let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); + let tx = WithOtherFields::new(tx); + let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); // FIXME: Awaits endlessly here. - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); let elapsed = start.elapsed().as_secs() + 1; - let diff = block.timestamp - BLOCK_TIMESTAMP; - assert!(diff <= elapsed.into()); + let diff = block.header.timestamp - BLOCK_TIMESTAMP; + assert!(diff <= elapsed); // ensure that after setting a timestamp manually, then next block time is correct let start = std::time::Instant::now(); @@ -564,19 +545,23 @@ async fn test_fork_timestamp() { .await .unwrap(); api.evm_set_next_block_timestamp(BLOCK_TIMESTAMP + 1).unwrap(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); - let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); + let tx = WithOtherFields::new(tx); + let _tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(block.timestamp.as_u64(), BLOCK_TIMESTAMP + 1); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + assert_eq!(block.header.timestamp, BLOCK_TIMESTAMP + 1); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); - let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); + let tx = WithOtherFields::new(tx); + let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); let elapsed = start.elapsed().as_secs() + 1; - let diff = block.timestamp - (BLOCK_TIMESTAMP + 1); - assert!(diff <= elapsed.into()); + let diff = block.header.timestamp - (BLOCK_TIMESTAMP + 1); + assert!(diff <= elapsed); } #[tokio::test(flavor = "multi_thread")] @@ -595,22 +580,25 @@ async fn test_fork_can_send_tx() { let (api, handle) = spawn(fork_config().with_blocktime(Some(std::time::Duration::from_millis(800)))).await; - let wallet = LocalWallet::new(&mut rand::thread_rng()); - let provider = ethers_http_provider(&handle.http_endpoint()); - let provider = SignerMiddleware::new(provider, wallet); + let wallet = LocalWallet::random(); + let signer = wallet.address(); + let provider = handle.http_provider(); + // let provider = SignerMiddleware::new(provider, wallet); - api.anvil_set_balance(provider.address().to_alloy(), rU256::MAX).await.unwrap(); - let balance = provider.get_balance(provider.address(), None).await.unwrap(); - assert_eq!(balance, rU256::MAX.to_ethers()); + api.anvil_set_balance(signer, U256::MAX).await.unwrap(); + api.anvil_impersonate_account(signer).await.unwrap(); // Added until SignerFiller for alloy-provider is fixed. + let balance = provider.get_balance(signer, BlockId::latest()).await.unwrap(); + assert_eq!(balance, U256::MAX); let addr = Address::random(); - let val = 1337u64; - let tx = TransactionRequest::new().to(addr).value(val); + let val = U256::from(1337u64); + let tx = TransactionRequest::default().to(addr).value(val).from(signer); + let tx = WithOtherFields::new(tx); // broadcast it via the eth_sendTransaction API - let _ = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let balance = provider.get_balance(addr, None).await.unwrap(); - assert_eq!(balance, val.into()); + let balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + assert_eq!(balance, val); } // @@ -625,42 +613,50 @@ async fn test_fork_nft_set_approve_all() { .await; // create and fund a random wallet - let wallet = LocalWallet::new(&mut rand::thread_rng()); - api.anvil_set_balance(wallet.address().to_alloy(), rU256::from(1000e18 as u64)).await.unwrap(); + let wallet = LocalWallet::random(); + let signer = wallet.address(); + api.anvil_set_balance(signer, U256::from(1000e18)).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); - let provider = Arc::new(SignerMiddleware::new(provider, wallet.clone())); + let provider = handle.http_provider(); // pick a random nft let nouns_addr: Address = "0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03".parse().unwrap(); let owner: Address = "0x052564eb0fd8b340803df55def89c25c432f43f4".parse().unwrap(); - let token_id: U256 = 154u64.into(); - - let nouns = Erc721::new(nouns_addr, Arc::clone(&provider)); - - let real_owner = nouns.owner_of(token_id).call().await.unwrap(); - assert_eq!(real_owner, owner); - let approval = nouns.set_approval_for_all(nouns_addr, true); - let tx = approval.send().await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); - - let real_owner = real_owner.to_alloy(); + let token_id: U256 = U256::from(154u64); + + let nouns = ERC721::new(nouns_addr, provider.clone()); + + let real_owner = nouns.ownerOf(token_id).call().await.unwrap(); + assert_eq!(real_owner._0, owner); + let approval = nouns.setApprovalForAll(nouns_addr, true); + let tx = TransactionRequest::default() + .from(owner) + .to(nouns_addr) + .with_input(approval.calldata().to_owned()); + let tx = WithOtherFields::new(tx); + api.anvil_impersonate_account(owner).await.unwrap(); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let status = tx.inner.inner.inner.receipt.status; + assert!(status); // transfer: impersonate real owner and transfer nft - api.anvil_impersonate_account(real_owner).await.unwrap(); - - api.anvil_set_balance(real_owner, rU256::from(10000e18 as u64)).await.unwrap(); - - let call = nouns.transfer_from(real_owner.to_ethers(), wallet.address(), token_id); - let mut tx: TypedTransaction = call.tx; - tx.set_from(real_owner.to_ethers()); - provider.fill_transaction(&mut tx, None).await.unwrap(); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); - - let real_owner = nouns.owner_of(token_id).call().await.unwrap(); - assert_eq!(real_owner, wallet.address()); + api.anvil_impersonate_account(real_owner._0).await.unwrap(); + + api.anvil_set_balance(real_owner._0, U256::from(10000e18 as u64)).await.unwrap(); + + let call = nouns.transferFrom(real_owner._0, signer, token_id); + let tx = TransactionRequest::default() + .from(real_owner._0) + .to(nouns_addr) + .with_input(call.calldata().to_owned()); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let status = tx.inner.inner.inner.receipt.status; + assert!(status); + + let real_owner = nouns.ownerOf(token_id).call().await.unwrap(); + assert_eq!(real_owner._0, wallet.address()); } // @@ -701,22 +697,24 @@ async fn test_fork_can_send_opensea_tx() { let sender: Address = "0x8fdbae54b6d9f3fc2c649e3dd4602961967fd42f".parse().unwrap(); // transfer: impersonate real sender - api.anvil_impersonate_account(sender.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(sender).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let input: Bytes = "0xfb0f3ee1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ff2e795f5000000000000000000000000000023f28ae3e9756ba982a6290f9081b6a84900b758000000000000000000000000004c00500000ad104d7dbd00e3ae0a5c00560c0000000000000000000000000003235b597a78eabcb08ffcb4d97411073211dbcb0000000000000000000000000000000000000000000000000000000000000e72000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000062ad47c20000000000000000000000000000000000000000000000000000000062d43104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000df44e65d2a2cf40000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000001c6bf526340000000000000000000000000008de9c5a032463c561423387a9648c5c7bcc5bc900000000000000000000000000000000000000000000000000005543df729c0000000000000000000000000006eb234847a9e3a546539aac57a071c01dc3f398600000000000000000000000000000000000000000000000000000000000000416d39b5352353a22cf2d44faa696c2089b03137a13b5acfee0366306f2678fede043bc8c7e422f6f13a3453295a4a063dac7ee6216ab7bade299690afc77397a51c00000000000000000000000000000000000000000000000000000000000000".parse().unwrap(); let to: Address = "0x00000000006c3852cbef3e08e8df289169ede581".parse().unwrap(); - let tx = TransactionRequest::new() + let tx = TransactionRequest::default() .from(sender) .to(to) - .value(20000000000000000u64) - .data(input) - .gas_price(22180711707u64) - .gas(150_000u64); - - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); + .value(U256::from(20000000000000000u64)) + .with_input(input) + .with_gas_price(22180711707u128) + .with_gas_limit(150_000u128); + let tx = WithOtherFields::new(tx); + + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let status = tx.inner.inner.inner.receipt.status; + assert!(status); } #[tokio::test(flavor = "multi_thread")] @@ -726,34 +724,34 @@ async fn test_fork_base_fee() { let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - api.anvil_set_next_block_base_fee_per_gas(rU256::ZERO).await.unwrap(); + api.anvil_set_next_block_base_fee_per_gas(U256::ZERO).await.unwrap(); let addr = Address::random(); - let val = 1337u64; - let tx = TransactionRequest::new().from(from.to_ethers()).to(addr).value(val); - - let _res = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let val = U256::from(1337u64); + let tx = TransactionRequest::default().from(from).to(addr).value(val); + let tx = WithOtherFields::new(tx); + let _res = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); } #[tokio::test(flavor = "multi_thread")] async fn test_fork_init_base_fee() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(13184859u64))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); // - assert_eq!(block.number.unwrap().as_u64(), 13184859u64); - let init_base_fee = block.base_fee_per_gas.unwrap(); - assert_eq!(init_base_fee, 63739886069u64.into()); + assert_eq!(block.header.number.unwrap(), 13184859u64); + let init_base_fee = block.header.base_fee_per_gas.unwrap(); + assert_eq!(init_base_fee, 63739886069u128); api.mine_one().await; - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); - let next_base_fee = block.base_fee_per_gas.unwrap(); + let next_base_fee = block.header.base_fee_per_gas.unwrap(); assert!(next_base_fee < init_base_fee); } @@ -764,8 +762,7 @@ async fn test_reset_fork_on_new_blocks() { ) .await; - let anvil_provider = ethers_http_provider(&handle.http_endpoint()); - + let anvil_provider = handle.http_provider(); let endpoint = next_http_rpc_endpoint(); let provider = Arc::new(get_http_provider(&endpoint)); @@ -782,7 +779,7 @@ async fn test_reset_fork_on_new_blocks() { .flat_map(futures::stream::iter); // the http watcher may fetch multiple blocks at once, so we set a timeout here to offset edge // cases where the stream immediately returns a block - tokio::time::sleep(Chain::Mainnet.average_blocktime_hint().unwrap()).await; + tokio::time::sleep(Duration::from_secs(12)).await; stream.next().await.unwrap(); stream.next().await.unwrap(); @@ -797,19 +794,18 @@ async fn test_fork_call() { let to: Address = "0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc".parse().unwrap(); let block_number = 14746300u64; - let provider = Provider::::try_from(rpc::next_http_archive_rpc_endpoint()).unwrap(); - let mut tx = TypedTransaction::default(); - tx.set_to(to).set_data(input.clone()); - let res0 = - provider.call(&tx, Some(BlockNumber::Number(block_number.into()).into())).await.unwrap(); + let provider = http_provider(rpc::next_http_archive_rpc_endpoint().as_str()); + let tx = TransactionRequest::default().to(to).with_input(input.clone()); + let tx = WithOtherFields::new(tx); + let res0 = provider.call(&tx, BlockId::Number(block_number.into())).await.unwrap(); let (api, _) = spawn(fork_config().with_fork_block_number(Some(block_number))).await; let res1 = api .call( - WithOtherFields::new(CallRequest { - to: Some(TxKind::Call(to.to_alloy())), - input: input.to_alloy().into(), + WithOtherFields::new(TransactionRequest { + to: Some(TxKind::from(to)), + input: input.into(), ..Default::default() }), None, @@ -818,7 +814,7 @@ async fn test_fork_call() { .await .unwrap(); - assert_eq!(res0, res1.to_ethers()); + assert_eq!(res0, res1); } #[tokio::test(flavor = "multi_thread")] @@ -826,7 +822,7 @@ async fn test_fork_block_timestamp() { let (api, _) = spawn(fork_config()).await; let initial_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); + api.anvil_mine(Some(U256::from(1)), None).await.unwrap(); let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); assert!(initial_block.header.timestamp < latest_block.header.timestamp); @@ -837,11 +833,11 @@ async fn test_fork_snapshot_block_timestamp() { let (api, _) = spawn(fork_config()).await; let snapshot_id = api.evm_snapshot().await.unwrap(); - api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); + api.anvil_mine(Some(U256::from(1)), None).await.unwrap(); let initial_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); api.evm_revert(snapshot_id).await.unwrap(); api.evm_set_next_block_timestamp(initial_block.header.timestamp).unwrap(); - api.anvil_mine(Some(rU256::from(1)), None).await.unwrap(); + api.anvil_mine(Some(U256::from(1)), None).await.unwrap(); let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); assert_eq!(initial_block.header.timestamp, latest_block.header.timestamp); @@ -850,7 +846,7 @@ async fn test_fork_snapshot_block_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn test_fork_uncles_fetch() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); // Block on ETH mainnet with 2 uncles let block_with_uncles = 190u64; @@ -860,35 +856,36 @@ async fn test_fork_uncles_fetch() { assert_eq!(block.uncles.len(), 2); - let count = provider.get_uncle_count(block_with_uncles).await.unwrap(); - assert_eq!(count.as_usize(), block.uncles.len()); + let count = provider.get_uncle_count(block_with_uncles.into()).await.unwrap(); + assert_eq!(count as usize, block.uncles.len()); - let count = provider.get_uncle_count(block.header.hash.unwrap().to_ethers()).await.unwrap(); - assert_eq!(count.as_usize(), block.uncles.len()); + let hash = BlockId::hash(block.header.hash.unwrap()); + let count = provider.get_uncle_count(hash).await.unwrap(); + assert_eq!(count as usize, block.uncles.len()); for (uncle_idx, uncle_hash) in block.uncles.iter().enumerate() { // Try with block number let uncle = provider - .get_uncle(block_with_uncles, (uncle_idx as u64).into()) + .get_uncle(BlockId::number(block_with_uncles), uncle_idx as u64) .await .unwrap() .unwrap(); - assert_eq!(*uncle_hash, uncle.hash.unwrap().to_alloy()); + assert_eq!(*uncle_hash, uncle.header.hash.unwrap()); // Try with block hash let uncle = provider - .get_uncle(block.header.hash.unwrap().to_ethers(), (uncle_idx as u64).into()) + .get_uncle(BlockId::hash(block.header.hash.unwrap()), uncle_idx as u64) .await .unwrap() .unwrap(); - assert_eq!(*uncle_hash, uncle.hash.unwrap().to_alloy()); + assert_eq!(*uncle_hash, uncle.header.hash.unwrap()); } } #[tokio::test(flavor = "multi_thread")] async fn test_fork_block_transaction_count() { let (api, handle) = spawn(fork_config()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let sender = accounts[0].address(); @@ -898,8 +895,10 @@ async fn test_fork_block_transaction_count() { // transfer: impersonate real sender api.anvil_impersonate_account(sender).await.unwrap(); - let tx = TransactionRequest::new().from(sender.to_ethers()).value(42u64).gas(100_000); - provider.send_transaction(tx, None).await.unwrap(); + let tx = + TransactionRequest::default().from(sender).value(U256::from(42u64)).with_gas_limit(100_000); + let tx = WithOtherFields::new(tx); + let _ = provider.send_transaction(tx).await.unwrap(); let pending_txs = api.block_transaction_count_by_number(BlockNumberOrTag::Pending).await.unwrap().unwrap(); @@ -943,31 +942,32 @@ async fn test_fork_block_transaction_count() { #[tokio::test(flavor = "multi_thread")] async fn can_impersonate_in_fork() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15347924u64))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let token_holder: Address = "0x2f0b23f53734252bda2277357e97e1517d6b042a".parse().unwrap(); let to = Address::random(); - let val = 1337u64; + let val = U256::from(1337u64); // fund the impersonated account - api.anvil_set_balance(token_holder.to_alloy(), rU256::from(1e18 as u64)).await.unwrap(); - - let tx = TransactionRequest::new().from(token_holder).to(to).value(val); + api.anvil_set_balance(token_holder, U256::from(1e18)).await.unwrap(); - let res = provider.send_transaction(tx.clone(), None).await; + let tx = TransactionRequest::default().from(token_holder).to(to).value(val); + let tx = WithOtherFields::new(tx); + let res = provider.send_transaction(tx.clone()).await; res.unwrap_err(); - api.anvil_impersonate_account(token_holder.to_alloy()).await.unwrap(); + api.anvil_impersonate_account(token_holder).await.unwrap(); - let res = provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); + let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, token_holder); - assert_eq!(res.status, Some(1u64.into())); + let status = res.inner.inner.inner.receipt.status; + assert!(status); - let balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance, val.into()); + let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(balance, val); - api.anvil_stop_impersonating_account(token_holder.to_alloy()).await.unwrap(); - let res = provider.send_transaction(tx, None).await; + api.anvil_stop_impersonating_account(token_holder).await.unwrap(); + let res = provider.send_transaction(tx).await; res.unwrap_err(); } @@ -976,22 +976,22 @@ async fn can_impersonate_in_fork() { async fn test_total_difficulty_fork() { let (api, handle) = spawn(fork_config()).await; - let total_difficulty: U256 = 46_673_965_560_973_856_260_636u128.into(); - let difficulty: U256 = 13_680_435_288_526_144u128.into(); + let total_difficulty = U256::from(46_673_965_560_973_856_260_636u128); + let difficulty = U256::from(13_680_435_288_526_144u128); - let provider = ethers_http_provider(&handle.http_endpoint()); - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(block.total_difficulty, Some(total_difficulty)); - assert_eq!(block.difficulty, difficulty); + let provider = handle.http_provider(); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + assert_eq!(block.header.total_difficulty, Some(total_difficulty)); + assert_eq!(block.header.difficulty, difficulty); api.mine_one().await; api.mine_one().await; let next_total_difficulty = total_difficulty + difficulty; - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); - assert_eq!(block.total_difficulty, Some(next_total_difficulty)); - assert_eq!(block.difficulty, U256::zero()); + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + assert_eq!(block.header.total_difficulty, Some(next_total_difficulty)); + assert_eq!(block.header.difficulty, U256::ZERO); } // @@ -1041,29 +1041,24 @@ async fn can_override_fork_chain_id() { .with_chain_id(Some(chain_id_override)), ) .await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .send() - .await - .unwrap(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.into(); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + let greeter_contract = + Greeter::deploy(provider.clone(), "Hello World!".to_string()).await.unwrap(); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); let greeter_contract = - Greeter::deploy(client, "Hello World!".to_string()).unwrap().send().await.unwrap(); - + Greeter::deploy(provider.clone(), "Hello World!".to_string()).await.unwrap(); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); - let provider = ethers_http_provider(&handle.http_endpoint()); - let chain_id = provider.get_chainid().await.unwrap(); - assert_eq!(chain_id.as_u64(), chain_id_override); + let provider = handle.http_provider(); + let chain_id = provider.get_chain_id().await.unwrap(); + assert_eq!(chain_id, chain_id_override); } // @@ -1076,14 +1071,18 @@ async fn test_fork_reset_moonbeam() { .with_fork_block_number(None::), ) .await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); + let tx = WithOtherFields::new(tx); + api.anvil_impersonate_account(from).await.unwrap(); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let status = tx.inner.inner.inner.receipt.status; + assert!(status); // reset to check timestamp works after resetting api.anvil_reset(Some(Forking { @@ -1093,9 +1092,12 @@ async fn test_fork_reset_moonbeam() { .await .unwrap(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64).from(from.to_ethers()); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let status = tx.inner.inner.inner.receipt.status; + assert!(status); } // = handle.dev_wallets().collect(); for acc in accounts { let balance = api.balance(acc.address(), Some(Default::default())).await.unwrap(); - assert_eq!(balance, rU256::from(100000000000000000000u128)); + assert_eq!(balance, U256::from(100000000000000000000u128)); } } @@ -1149,8 +1151,8 @@ async fn test_arbitrum_fork_block_number() { .with_eth_rpc_url(Some("https://arb1.arbitrum.io/rpc".to_string())), ) .await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let initial_block_number = provider.get_block_number().await.unwrap().as_u64(); + let provider = handle.http_provider(); + let initial_block_number = provider.get_block_number().await.unwrap(); // fork again at block number returned by `eth_blockNumber` // if wrong block number returned (e.g. L1) then fork will fail with error code -32000: missing @@ -1196,8 +1198,8 @@ async fn test_fork_execution_reverted() { let resp = api .call( - WithOtherFields::new(CallRequest { - to: Some(TxKind::Call(address!("Fd6CC4F251eaE6d02f9F7B41D1e80464D3d2F377"))), + WithOtherFields::new(TransactionRequest { + to: Some(TxKind::from(address!("Fd6CC4F251eaE6d02f9F7B41D1e80464D3d2F377"))), input: TransactionInput::new("0x8f283b3c".as_bytes().into()), ..Default::default() }), diff --git a/crates/anvil/tests/it/ganache.rs b/crates/anvil/tests/it/ganache.rs index b95b55433ba8b..ca8589e210bdf 100644 --- a/crates/anvil/tests/it/ganache.rs +++ b/crates/anvil/tests/it/ganache.rs @@ -1,101 +1,93 @@ //! tests against local ganache for local debug purposes #![allow(unused)] use crate::{ + abi::Greeter, init_tracing, - utils::{ContractInstanceCompat, DeploymentTxFactoryCompat}, -}; -use ethers::{ - abi::Address, - contract::{Contract, ContractFactory, ContractInstance}, - core::k256::SecretKey, - prelude::{abigen, Middleware, Signer, SignerMiddleware, TransactionRequest, Ws}, - providers::{Http, Provider}, - signers::LocalWallet, - types::{BlockNumber, U256}, - utils::hex, + utils::{http_provider, http_provider_with_signer, ws_provider_with_signer}, }; +use alloy_contract::ContractInstance; +use alloy_network::EthereumSigner; +use alloy_primitives::{address, Address, TxKind}; +use alloy_provider::Provider; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_signer_wallet::{LocalWallet, MnemonicBuilder}; +use alloy_sol_types::{sol, Revert}; use foundry_compilers::{project_util::TempProject, Artifact}; -use std::sync::Arc; +use std::{str::FromStr, sync::Arc}; // the mnemonic used to start the local ganache instance const MNEMONIC: &str = "amazing discover palace once resource choice flush horn wink shift planet relief"; fn ganache_wallet() -> LocalWallet { - wallet("552dd2534c4984f892191997d6b1dd9e6a23c7e07b908a6cebfad1d3f2af4c4c") + LocalWallet::from_str("552dd2534c4984f892191997d6b1dd9e6a23c7e07b908a6cebfad1d3f2af4c4c") + .unwrap() } fn ganache_wallet2() -> LocalWallet { - wallet("305b526d493844b63466be6d48a424ab83f5216011eef860acc6db4c1821adc9") + LocalWallet::from_str("305b526d493844b63466be6d48a424ab83f5216011eef860acc6db4c1821adc9") + .unwrap() } fn wallet(key_str: &str) -> LocalWallet { - let key_hex = hex::decode(key_str).expect("could not parse as hex"); - let key = SecretKey::from_bytes(key_hex.as_slice().into()).expect("did not get private key"); - key.into() -} - -fn http_client() -> Arc, LocalWallet>> { - let provider = Provider::::try_from("http://127.0.0.1:8545").unwrap(); - Arc::new(SignerMiddleware::new(provider, ganache_wallet())) -} - -async fn ws_client() -> Arc, LocalWallet>> { - let provider = Provider::::connect("ws://127.0.0.1:8545").await.unwrap(); - Arc::new(SignerMiddleware::new(provider, ganache_wallet())) + LocalWallet::from_str(key_str).unwrap() } #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_ganache_block_number() { - let client = http_client(); - let balance = client - .get_balance(Address::random(), Some(BlockNumber::Number(100u64.into()).into())) - .await; + let provider = http_provider("http://127.0.0.1:8545"); + + let balance = provider.get_balance(Address::random(), BlockId::latest()).await; } #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_ganache_deploy() { - abigen!(Greeter, "test-data/greeter.json"); - let client = http_client(); + let signer: EthereumSigner = ganache_wallet().into(); + let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); - let greeter_contract = - Greeter::deploy(client, "Hello World!".to_string()).unwrap().legacy().send().await.unwrap(); + let greeter_contract_builder = Greeter::deploy_builder(&provider, "Hello World!".to_string()); + let greeter_contract_address = greeter_contract_builder.deploy().await.unwrap(); + let greeter_contract = Greeter::new(greeter_contract_address, &provider); - let greeting = greeter_contract.greet().call().await.unwrap(); + let Greeter::greetReturn { _0 } = greeter_contract.greet().call().await.unwrap(); + let greeting = _0; assert_eq!("Hello World!", greeting); } #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_ganache_emit_logs() { - abigen!(EmitLogs, "test-data/emit_logs.json"); - let client = ws_client().await; + sol!( + #[sol(rpc)] + EmitLogs, + "test-data/emit_logs.json" + ); - let msg = "First Message".to_string(); - let contract = - EmitLogs::deploy(Arc::clone(&client), msg.clone()).unwrap().legacy().send().await.unwrap(); + let signer: EthereumSigner = ganache_wallet().into(); + let provider = ws_provider_with_signer("ws://127.0.0.1:8545", signer); - let val = contract.get_value().call().await.unwrap(); - assert_eq!(val, msg); + let first_msg = "First Message".to_string(); + let next_msg = "Next Message".to_string(); + let emit_logs_contract_builder = EmitLogs::deploy_builder(&provider, first_msg.clone()); + let emit_logs_contract_address = emit_logs_contract_builder.deploy().await.unwrap(); + let emit_logs_contract = EmitLogs::new(emit_logs_contract_address, &provider); - let val = contract - .set_value("Next Message".to_string()) - .legacy() - .send() - .await - .unwrap() - .await - .unwrap() - .unwrap(); + let EmitLogs::getValueReturn { _0 } = emit_logs_contract.getValue().call().await.unwrap(); + let val = _0; + assert_eq!(val, first_msg); + + emit_logs_contract.setValue(next_msg.clone()).send().await.unwrap(); + + let EmitLogs::getValueReturn { _0 } = emit_logs_contract.getValue().call().await.unwrap(); + let val = _0; + assert_eq!(val, next_msg); } #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_ganache_deploy_reverting() { - let client = http_client(); - let prj = TempProject::dapptools().unwrap(); prj.add_source( "Contract", @@ -110,17 +102,33 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract {} + ); + let mut compiled = prj.compile().unwrap(); - println!("{compiled}"); assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); - - let factory = ContractFactory::new_compat(abi.unwrap(), bytecode.unwrap(), Arc::clone(&client)); - let contract = factory.deploy(()).unwrap().legacy().send().await; - contract.unwrap_err(); + let bytecode = contract.into_bytecode_bytes().unwrap(); + + let wallet = ganache_wallet(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); + + let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); + + // should catch the revert during estimation which results in an err + let err = provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap_err(); + assert!(err.to_string().contains("execution reverted")); } #[tokio::test(flavor = "multi_thread")] @@ -148,41 +156,63 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function getSecret() public view returns (uint256); + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); + + let wallet = ganache_wallet(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let client = Arc::new(http_client()); + let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); // deploy successfully - let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().legacy().send().await.unwrap(); - let provider = SignerMiddleware::new( - Provider::::try_from("http://127.0.0.1:8545").unwrap(), - ganache_wallet2(), - ); - let contract = ContractInstance::new_compat(contract.address(), abi.unwrap(), provider); - let resp = contract.method::<_, U256>("getSecret", ()).unwrap().legacy().call().await; - resp.unwrap_err(); - - /* Ganache rpc errors look like: - < { - < "id": 1627277502538, - < "jsonrpc": "2.0", - < "error": { - < "message": "VM Exception while processing transaction: revert !authorized", - < "code": -32000, - < "data": { - < "0x90264de254689f1d4e7f8670cd97f60d9bc803874fdecb34d249bd1cc3ca823a": { - < "error": "revert", - < "program_counter": 223, - < "return": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b21617574686f72697a6564000000000000000000000000000000000000000000", - < "reason": "!authorized" - < }, - < "stack": "c: VM Exception while processing transaction: revert !authorized\n at Function.c.fromResults (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:192416)\n at /usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:50402", - < "name": "c" - < } - < } - */ + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = Contract::new(contract_address, &provider); + + // should catch the revert during the call which results in an err + contract.getSecret().send().await.unwrap_err(); + + // /* Ganache rpc errors look like: + // < { + // < "id": 1627277502538, + // < "jsonrpc": "2.0", + // < "error": { + // < "message": "VM Exception while processing transaction: revert !authorized", + // < "code": -32000, + // < "data": { + // < "0x90264de254689f1d4e7f8670cd97f60d9bc803874fdecb34d249bd1cc3ca823a": { + // < "error": "revert", + // < "program_counter": 223, + // < "return": + // "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b21617574686f72697a6564000000000000000000000000000000000000000000" + // , < "reason": "!authorized" + // < }, + // < "stack": "c: VM Exception while processing transaction: revert !authorized\n at + // Function.c.fromResults + // (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:192416)\n at + // /usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:50402", < + // "name": "c" < } + // < } + // */ } diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index e2d194340c57b..93cebb90c7247 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -1,14 +1,11 @@ //! Gas related tests -use crate::utils::ethers_http_provider; +use crate::utils::http_provider_with_signer; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{Address, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use anvil::{eth::fees::INITIAL_BASE_FEE, spawn, NodeConfig}; -use ethers::{ - prelude::Middleware, - types::{ - transaction::eip2718::TypedTransaction, Address, BlockNumber, Eip1559TransactionRequest, - TransactionRequest, - }, -}; const GAS_TRANSFER: u128 = 21_000; @@ -18,19 +15,41 @@ async fn test_basefee_full_block() { NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE)).with_gas_limit(Some(GAS_TRANSFER)), ) .await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64); - provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); - let base_fee = - provider.get_block(BlockNumber::Latest).await.unwrap().unwrap().base_fee_per_gas.unwrap(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64); - provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); - let next_base_fee = - provider.get_block(BlockNumber::Latest).await.unwrap().unwrap().base_fee_per_gas.unwrap(); + + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let tx = TransactionRequest::default().to(Address::random()).with_value(U256::from(1337)); + let tx = WithOtherFields::new(tx); + + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); + + let base_fee = provider + .get_block(BlockId::latest(), false) + .await + .unwrap() + .unwrap() + .header + .base_fee_per_gas + .unwrap(); + + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); + + let next_base_fee = provider + .get_block(BlockId::latest(), false) + .await + .unwrap() + .unwrap() + .header + .base_fee_per_gas + .unwrap(); assert!(next_base_fee > base_fee); + // max increase, full block - assert_eq!(next_base_fee.as_u128(), INITIAL_BASE_FEE + 125_000_000); + assert_eq!(next_base_fee, INITIAL_BASE_FEE + 125_000_000); } #[tokio::test(flavor = "multi_thread")] @@ -41,32 +60,69 @@ async fn test_basefee_half_block() { .with_gas_limit(Some(GAS_TRANSFER * 2)), ) .await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64); - provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64); - provider.send_transaction(tx.clone(), None).await.unwrap().await.unwrap().unwrap(); - let next_base_fee = - provider.get_block(BlockNumber::Latest).await.unwrap().unwrap().base_fee_per_gas.unwrap(); + + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let tx = TransactionRequest::default().to(Address::random()).with_value(U256::from(1337)); + let tx = WithOtherFields::new(tx); + + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); + + let tx = TransactionRequest::default().to(Address::random()).with_value(U256::from(1337)); + let tx = WithOtherFields::new(tx); + + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); + + let next_base_fee = provider + .get_block(BlockId::latest(), false) + .await + .unwrap() + .unwrap() + .header + .base_fee_per_gas + .unwrap(); // unchanged, half block - assert_eq!(next_base_fee.as_u128(), INITIAL_BASE_FEE); + assert_eq!(next_base_fee, INITIAL_BASE_FEE); } + #[tokio::test(flavor = "multi_thread")] async fn test_basefee_empty_block() { let (api, handle) = spawn(NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64); - provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - let base_fee = - provider.get_block(BlockNumber::Latest).await.unwrap().unwrap().base_fee_per_gas.unwrap(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let tx = TransactionRequest::default().with_to(Address::random()).with_value(U256::from(1337)); + let tx = WithOtherFields::new(tx); + + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); + + let base_fee = provider + .get_block(BlockId::latest(), false) + .await + .unwrap() + .unwrap() + .header + .base_fee_per_gas + .unwrap(); // mine empty block api.mine_one().await; - let next_base_fee = - provider.get_block(BlockNumber::Latest).await.unwrap().unwrap().base_fee_per_gas.unwrap(); + let next_base_fee = provider + .get_block(BlockId::latest(), false) + .await + .unwrap() + .unwrap() + .header + .base_fee_per_gas + .unwrap(); // empty block, decreased base fee assert!(next_base_fee < base_fee); @@ -76,35 +132,38 @@ async fn test_basefee_empty_block() { async fn test_respect_base_fee() { let base_fee = 50u128; let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let mut tx = TypedTransaction::default(); - tx.set_value(100u64); - tx.set_to(Address::random()); + + let provider = handle.http_provider(); + + let tx = TransactionRequest::default().with_to(Address::random()).with_value(U256::from(100)); + let mut tx = WithOtherFields::new(tx); let mut underpriced = tx.clone(); underpriced.set_gas_price(base_fee - 1); - let res = provider.send_transaction(underpriced, None).await; + + let res = provider.send_transaction(underpriced).await; assert!(res.is_err()); assert!(res.unwrap_err().to_string().contains("max fee per gas less than block base fee")); tx.set_gas_price(base_fee); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); } #[tokio::test(flavor = "multi_thread")] async fn test_tip_above_fee_cap() { let base_fee = 50u128; let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let tx = TypedTransaction::Eip1559( - Eip1559TransactionRequest::new() - .max_fee_per_gas(base_fee) - .max_priority_fee_per_gas(base_fee + 1) - .to(Address::random()) - .value(100u64), - ); - let res = provider.send_transaction(tx, None).await; + + let provider = handle.http_provider(); + + let tx = TransactionRequest::default() + .max_fee_per_gas(base_fee) + .max_priority_fee_per_gas(base_fee + 1) + .with_to(Address::random()) + .with_value(U256::from(100)); + let tx = WithOtherFields::new(tx); + + let res = provider.send_transaction(tx.clone()).await; assert!(res.is_err()); assert!(res .unwrap_err() diff --git a/crates/anvil/tests/it/genesis.rs b/crates/anvil/tests/it/genesis.rs index c8157e1601649..bb4e2d24bd5b9 100644 --- a/crates/anvil/tests/it/genesis.rs +++ b/crates/anvil/tests/it/genesis.rs @@ -1,12 +1,11 @@ //! genesis.json tests -use std::str::FromStr; - -use alloy_eips::BlockId; use alloy_genesis::Genesis; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; +use alloy_rpc_types::BlockId; use anvil::{spawn, NodeConfig}; +use std::str::FromStr; #[tokio::test(flavor = "multi_thread")] async fn can_apply_genesis() { diff --git a/crates/anvil/tests/it/geth.rs b/crates/anvil/tests/it/geth.rs index e1c9bc7b88401..7879f4911f676 100644 --- a/crates/anvil/tests/it/geth.rs +++ b/crates/anvil/tests/it/geth.rs @@ -1,37 +1,35 @@ //! tests against local geth for local debug purposes use crate::{ - abi::VENDING_MACHINE_CONTRACT, - utils::{ContractInstanceCompat, DeploymentTxFactoryCompat}, -}; -use ethers::{ - abi::Address, - contract::{Contract, ContractFactory}, - prelude::{Middleware, TransactionRequest}, - providers::Provider, - types::U256, - utils::WEI_IN_ETHER, + abi::{VendingMachine, VENDING_MACHINE_CONTRACT}, + utils::{http_provider, http_provider_with_signer}, }; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{Address, TxKind, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use anvil::{spawn, NodeConfig}; use foundry_compilers::{project_util::TempProject, Artifact}; use futures::StreamExt; -use std::sync::Arc; use tokio::time::timeout; #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_geth_pending_transaction() { - let client = Provider::try_from("http://127.0.0.1:8545").unwrap(); - let accounts = client.get_accounts().await.unwrap(); - let tx = TransactionRequest::new() - .from(accounts[0]) - .to(Address::random()) - .value(1337u64) - .nonce(2u64); + let provider = http_provider("http://127.0.0.1:8545"); + + let account = provider.get_accounts().await.unwrap().remove(0); - let mut watch_tx_stream = - client.watch_pending_transactions().await.unwrap().transactions_unordered(1).fuse(); + let tx = TransactionRequest::default() + .with_from(account) + .with_to(Address::random()) + .with_value(U256::from(1337u64)) + .with_nonce(2u64); + let tx = WithOtherFields::new(tx); - let _res = client.send_transaction(tx, None).await.unwrap(); + let mut watch_tx_stream = provider.watch_pending_transactions().await.unwrap().into_stream(); + + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); let pending = timeout(std::time::Duration::from_secs(3), watch_tx_stream.next()).await; pending.unwrap_err(); @@ -47,48 +45,59 @@ async fn test_geth_revert_transaction() { let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("VendingMachine").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); - let client = Arc::new(Provider::try_from("http://127.0.0.1:8545").unwrap()); + let (_api, handle) = spawn(NodeConfig::test()).await; + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let account = client.get_accounts().await.unwrap().remove(0); + let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); // deploy successfully - let factory = - ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), Arc::clone(&client)); - - let mut tx = factory.deploy(()).unwrap().tx; - tx.set_from(account); - - let resp = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - - let contract = - Contract::>::new_compat(resp.contract_address.unwrap(), abi.unwrap(), client); - - let ten = WEI_IN_ETHER.saturating_mul(10u64.into()); - let call = contract.method::<_, ()>("buyRevert", ten).unwrap().value(ten).from(account); - let resp = call.call().await; - let err = resp.unwrap_err().to_string(); - assert!(err.contains("execution reverted: Not enough Ether provided.")); - assert!(err.contains("code: 3")); + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = VendingMachine::new(contract_address, &provider); + + let res = contract + .buyRevert(U256::from(100)) + .value(U256::from(1)) + .from(sender) + .send() + .await + .unwrap_err(); + let msg = res.to_string(); + assert!(msg.contains("execution reverted: revert: Not enough Ether provided.")); + assert!(msg.contains("code: 3")); } #[tokio::test(flavor = "multi_thread")] #[ignore] async fn test_geth_low_gas_limit() { - let provider = Arc::new(Provider::try_from("http://127.0.0.1:8545").unwrap()); + let provider = http_provider("http://127.0.0.1:8545"); let account = provider.get_accounts().await.unwrap().remove(0); - let gas = 21_000u64 - 1; - let tx = TransactionRequest::new() + let gas_limit = 21_000u128 - 1; + let tx = TransactionRequest::default() + .from(account) .to(Address::random()) .value(U256::from(1337u64)) - .from(account) - .gas(gas); - - let resp = provider.send_transaction(tx, None).await; + .gas_limit(gas_limit); + let tx = WithOtherFields::new(tx); + let resp = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await; let err = resp.unwrap_err().to_string(); assert!(err.contains("intrinsic gas too low")); } diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index 8b7de088467de..676a0f61b5171 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -1,9 +1,9 @@ //! IPC tests -use crate::utils::ethers_ipc_provider; +use crate::utils::connect_pubsub; use alloy_primitives::U256; +use alloy_provider::Provider; use anvil::{spawn, NodeConfig}; -use ethers::prelude::Middleware; use futures::StreamExt; pub fn rand_ipc_endpoint() -> String { @@ -20,31 +20,33 @@ fn ipc_config() -> NodeConfig { } #[tokio::test(flavor = "multi_thread")] +#[cfg_attr(target_os = "windows", ignore)] async fn can_get_block_number_ipc() { let (api, handle) = spawn(ipc_config()).await; let block_num = api.block_number().unwrap(); assert_eq!(block_num, U256::ZERO); - let provider = ethers_ipc_provider(handle.ipc_path()).unwrap(); + let provider = handle.ipc_provider().unwrap(); let num = provider.get_block_number().await.unwrap(); - assert_eq!(num.as_u64(), block_num.to::()); + assert_eq!(num, block_num.to::()); } #[tokio::test(flavor = "multi_thread")] +#[cfg_attr(target_os = "windows", ignore)] async fn test_sub_new_heads_ipc() { let (api, handle) = spawn(ipc_config()).await; - let provider = ethers_ipc_provider(handle.ipc_path()).unwrap(); + let provider = connect_pubsub(handle.ipc_path().unwrap().as_str()).await; - let blocks = provider.subscribe_blocks().await.unwrap(); + let blocks = provider.subscribe_blocks().await.unwrap().into_stream(); // mine a block every 1 seconds api.anvil_set_interval_mining(1).unwrap(); let blocks = blocks.take(3).collect::>().await; - let block_numbers = blocks.into_iter().map(|b| b.number.unwrap().as_u64()).collect::>(); + let block_numbers = blocks.into_iter().map(|b| b.header.number.unwrap()).collect::>(); assert_eq!(block_numbers, vec![1, 2, 3]); } diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index 2f9290f3e7540..afcb340197fd3 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -1,88 +1,119 @@ //! log/event related tests use crate::{ - abi::*, - utils::{ethers_http_provider, ethers_ws_provider}, + abi::SimpleStorage::{self}, + utils::{http_provider_with_signer, ws_provider_with_signer}, }; +use alloy_network::EthereumSigner; +use alloy_primitives::B256; +use alloy_provider::Provider; +use alloy_rpc_types::{BlockNumberOrTag, Filter}; use anvil::{spawn, NodeConfig}; -use ethers::{ - middleware::SignerMiddleware, - prelude::{BlockNumber, Filter, FilterKind, Middleware, Signer, H256}, - types::Log, -}; -use foundry_common::types::ToEthers; use futures::StreamExt; -use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn get_past_events() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let address = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + let account = wallet.address(); + let signer: EthereumSigner = wallet.into(); - let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) - .unwrap() + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let contract = + SimpleStorage::deploy(provider.clone(), "initial value".to_string()).await.unwrap(); + let _ = contract + .setValue("hi".to_string()) + .from(account) .send() .await + .unwrap() + .get_receipt() + .await .unwrap(); + let simple_storage_address = *contract.address(); - let func = contract.method::<_, H256>("setValue", "hi".to_owned()).unwrap(); - let tx = func.send().await.unwrap(); - let _receipt = tx.await.unwrap(); + let filter = Filter::new() + .address(simple_storage_address) + .topic1(B256::from(account.into_word())) + .from_block(BlockNumberOrTag::from(0)); - // and we can fetch the events - let logs: Vec = - contract.event().from_block(0u64).topic1(address).query().await.unwrap(); + let logs = provider + .get_logs(&filter) + .await + .unwrap() + .into_iter() + .map(|log| log.log_decode::().unwrap()) + .collect::>(); // 2 events, 1 in constructor, 1 in call - assert_eq!(logs[0].new_value, "initial value"); - assert_eq!(logs[1].new_value, "hi"); + assert_eq!(logs[0].inner.newValue, "initial value"); + assert_eq!(logs[1].inner.newValue, "hi"); assert_eq!(logs.len(), 2); // and we can fetch the events at a block hash - let hash = client.get_block(1).await.unwrap().unwrap().hash.unwrap(); + // let hash = provider.get_block(1).await.unwrap().unwrap().hash.unwrap(); + let hash = provider + .get_block_by_number(BlockNumberOrTag::from(1), false) + .await + .unwrap() + .unwrap() + .header + .hash + .unwrap(); + + let filter = Filter::new() + .address(simple_storage_address) + .topic1(B256::from(account.into_word())) + .at_block_hash(hash); + + let logs = provider + .get_logs(&filter) + .await + .unwrap() + .into_iter() + .map(|log| log.log_decode::().unwrap()) + .collect::>(); - let logs: Vec = - contract.event().at_block_hash(hash).topic1(address).query().await.unwrap(); - assert_eq!(logs[0].new_value, "initial value"); + assert_eq!(logs[0].inner.newValue, "initial value"); assert_eq!(logs.len(), 1); } #[tokio::test(flavor = "multi_thread")] async fn get_all_events() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + let account = wallet.address(); + let signer: EthereumSigner = wallet.into(); - let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) - .unwrap() - .send() - .await - .unwrap(); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let contract = + SimpleStorage::deploy(provider.clone(), "initial value".to_string()).await.unwrap(); api.anvil_set_auto_mine(false).await.unwrap(); - let pre_logs = client.get_logs(&Filter::new().from_block(BlockNumber::Earliest)).await.unwrap(); + let pre_logs = + provider.get_logs(&Filter::new().from_block(BlockNumberOrTag::Earliest)).await.unwrap(); assert_eq!(pre_logs.len(), 1); let pre_logs = - client.get_logs(&Filter::new().from_block(BlockNumber::Number(0u64.into()))).await.unwrap(); + provider.get_logs(&Filter::new().from_block(BlockNumberOrTag::Number(0))).await.unwrap(); assert_eq!(pre_logs.len(), 1); // spread logs across several blocks let num_tx = 10; + let tx = contract.setValue("hi".to_string()).from(account); for _ in 0..num_tx { - let func = contract.method::<_, H256>("setValue", "hi".to_owned()).unwrap(); - let tx = func.send().await.unwrap(); + let tx = tx.send().await.unwrap(); api.mine_one().await; - let _receipt = tx.await.unwrap(); + tx.get_receipt().await.unwrap(); } - let logs = client.get_logs(&Filter::new().from_block(BlockNumber::Earliest)).await.unwrap(); + + let logs = + provider.get_logs(&Filter::new().from_block(BlockNumberOrTag::Earliest)).await.unwrap(); let num_logs = num_tx + pre_logs.len(); assert_eq!(logs.len(), num_logs); @@ -95,17 +126,19 @@ async fn get_all_events() { if seen_tx_hashes.contains(&log.transaction_hash.unwrap()) { continue; } - tasks.push(client.get_transaction_receipt(log.transaction_hash.unwrap())); + tasks.push(provider.get_transaction_receipt(log.transaction_hash.unwrap())); seen_tx_hashes.insert(log.transaction_hash.unwrap()); } + let receipt_logs = futures::future::join_all(tasks) .await .into_iter() .collect::, _>>() .unwrap() .into_iter() - .flat_map(|receipt| receipt.unwrap().logs) + .flat_map(|receipt| receipt.unwrap().inner.inner.inner.receipt.logs) .collect::>(); + assert_eq!(receipt_logs.len(), logs.len()); for (receipt_log, log) in receipt_logs.iter().zip(logs.iter()) { assert_eq!(receipt_log.transaction_hash, log.transaction_hash); @@ -114,93 +147,58 @@ async fn get_all_events() { } } -#[tokio::test(flavor = "multi_thread")] -async fn can_install_filter() { - let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - - let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) - .unwrap() - .send() - .await - .unwrap(); - - let filter = Filter::new().from_block(BlockNumber::Number(0u64.into())); - - let filter = client.new_filter(FilterKind::Logs(&filter)).await.unwrap(); - - let logs = client.get_filter_changes::<_, Log>(filter).await.unwrap(); - assert_eq!(logs.len(), 1); - - let logs = client.get_filter_changes::<_, Log>(filter).await.unwrap(); - assert!(logs.is_empty()); - api.anvil_set_auto_mine(false).await.unwrap(); - // create some logs - let num_logs = 10; - for _ in 0..num_logs { - let func = contract.method::<_, H256>("setValue", "hi".to_owned()).unwrap(); - let tx = func.send().await.unwrap(); - api.mine_one().await; - let _receipt = tx.await.unwrap(); - let logs = client.get_filter_changes::<_, Log>(filter).await.unwrap(); - assert_eq!(logs.len(), 1); - } - let all_logs = api - .get_filter_logs(&serde_json::to_string(&filter).unwrap().replace('\"', "")) - .await - .unwrap(); - - assert_eq!(all_logs.len(), num_logs + 1); -} - #[tokio::test(flavor = "multi_thread")] async fn watch_events() { let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let provider = ethers_http_provider(&handle.http_endpoint()); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - - let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) - .unwrap() - .send() - .await - .unwrap(); - - // We spawn the event listener: - let event = contract.event::(); - let mut stream = event.stream().await.unwrap(); - - // Also set up a subscription for the same thing - let ws = Arc::new(ethers_ws_provider(&handle.ws_endpoint())); - let contract2 = SimpleStorage::new(contract.address(), ws); - let event2 = contract2.event::(); - let mut subscription = event2.subscribe().await.unwrap(); - - let mut subscription_meta = event2.subscribe().await.unwrap().with_meta(); - - let num_calls = 3u64; - - // and we make a few calls - let num = client.get_block_number().await.unwrap(); - for i in 0..num_calls { - let call = contract.method::<_, H256>("setValue", i.to_string()).unwrap().legacy(); - let pending_tx = call.send().await.unwrap(); - let _receipt = pending_tx.await.unwrap(); - } - for i in 0..num_calls { - // unwrap the option of the stream, then unwrap the decoding result - let log = stream.next().await.unwrap().unwrap(); - let log2 = subscription.next().await.unwrap().unwrap(); - let (log3, meta) = subscription_meta.next().await.unwrap().unwrap(); - assert_eq!(log.new_value, log3.new_value); - assert_eq!(log.new_value, log2.new_value); - assert_eq!(log.new_value, i.to_string()); - assert_eq!(meta.block_number, num + i + 1); - let hash = client.get_block(num + i + 1).await.unwrap().unwrap().hash.unwrap(); - assert_eq!(meta.block_hash, hash); + let wallet = handle.dev_wallets().next().unwrap(); + let account = wallet.address(); + let signer: EthereumSigner = wallet.into(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer.clone()); + + let contract1 = + SimpleStorage::deploy(provider.clone(), "initial value".to_string()).await.unwrap(); + + // Spawn the event listener. + let event1 = contract1.event_filter::(); + let mut stream1 = event1.watch().await.unwrap().into_stream(); + + // Also set up a subscription for the same thing. + let ws = ws_provider_with_signer(&handle.ws_endpoint(), signer.clone()); + let contract2 = SimpleStorage::new(*contract1.address(), ws); + let event2 = contract2.event_filter::(); + let mut stream2 = event2.watch().await.unwrap().into_stream(); + + let num_tx = 3; + + let starting_block_number = provider.get_block_number().await.unwrap(); + for i in 0..num_tx { + contract1 + .setValue(i.to_string()) + .from(account) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + + let log = stream1.next().await.unwrap().unwrap(); + let log2 = stream2.next().await.unwrap().unwrap(); + + assert_eq!(log.0.newValue, log2.0.newValue); + assert_eq!(log.0.newValue, i.to_string()); + assert_eq!(log.1.block_number.unwrap(), starting_block_number + i + 1); + + let hash = provider + .get_block_by_number(BlockNumberOrTag::from(starting_block_number + i + 1), false) + .await + .unwrap() + .unwrap() + .header + .hash + .unwrap(); + assert_eq!(log.1.block_hash.unwrap(), hash); } } diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 1ba8e3fe9da92..799cd16f04047 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -10,10 +10,10 @@ mod geth; mod ipc; mod logs; mod optimism; +mod otterscan; mod proof; mod pubsub; -// mod revert; // TODO uncomment -mod otterscan; +mod revert; mod sign; mod state; diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 78dcf92277480..0a7801c4ed6dd 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -1,48 +1,44 @@ //! Tests for OP chain support. -use crate::utils::ethers_http_provider; +use crate::utils::http_provider_with_signer; +use alloy_eips::{eip2718::Encodable2718, BlockId}; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{b256, U128, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest, WithOtherFields}; use anvil::{spawn, Hardfork, NodeConfig}; -use ethers::{ - abi::Address, - providers::Middleware, - types::{ - transaction::{eip2718::TypedTransaction, optimism::DepositTransaction}, - TransactionRequest, U256, - }, -}; -use ethers_core::types::{Bytes, H256}; -use foundry_common::types::ToAlloy; -use std::str::FromStr; +// TODO: transaction is expected to fail, it does not, remove ignore once fixed #[tokio::test(flavor = "multi_thread")] +#[ignore] async fn test_deposits_not_supported_if_optimism_disabled() { - // optimism disabled by default - let (_, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - - let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); - let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); - let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { - tx: TransactionRequest { - chain_id: None, - from: Some(from_addr), - to: Some(ethers::types::NameOrAddress::Address(to_addr)), - value: Some("1234".parse().unwrap()), - gas: Some(U256::from(21000)), - gas_price: None, - data: Some(Bytes::default()), - nonce: None, - }, - source_hash: H256::from_str( - "0000000000000000000000000000000000000000000000000000000000000000", - ) - .unwrap(), - mint: Some(U256::zero()), - is_system_tx: true, - }); - - // sending the deposit transaction should fail with error saying not supported - let res = provider.send_transaction(deposit_tx.clone(), None).await; + let (_api, handle) = spawn(NodeConfig::test()).await; + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let signer: EthereumSigner = accounts[0].clone().into(); + let from = accounts[0].address(); + let to = accounts[1].address(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + let tx = TransactionRequest::default() + .with_from(from) + .with_to(to) + .with_value(U256::from(1234)) + .with_gas_limit(21000); + let tx = WithOtherFields { + inner: tx, + other: OptimismTransactionFields { + source_hash: Some(b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )), + mint: Some(U128::from(0)), + is_system_tx: Some(true), + } + .into(), + }; + + let res = provider.send_transaction(tx).await.unwrap().register().await; assert!(res .unwrap_err() .to_string() @@ -54,46 +50,47 @@ async fn test_send_value_deposit_transaction() { // enable the Optimism flag let (api, handle) = spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let signer: EthereumSigner = accounts[0].clone().into(); + let from = accounts[0].address(); + let to = accounts[1].address(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); let send_value = U256::from(1234); - let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); - let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); - - // fund the sender - api.anvil_set_balance(from_addr.to_alloy(), send_value.to_alloy()).await.unwrap(); - - let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { - tx: TransactionRequest { - chain_id: None, - from: Some(from_addr), - to: Some(ethers::types::NameOrAddress::Address(to_addr)), - value: Some(send_value), - gas: Some(U256::from(21000)), - gas_price: None, - data: Some(Bytes::default()), - nonce: None, - }, - source_hash: H256::from_str( - "0000000000000000000000000000000000000000000000000000000000000000", - ) - .unwrap(), - mint: Some(U256::zero()), - is_system_tx: true, - }); - - let pending = provider.send_transaction(deposit_tx.clone(), None).await.unwrap(); + let before_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + + let tx = TransactionRequest::default() + .with_from(from) + .with_to(to) + .with_value(send_value) + .with_gas_limit(21000); + let tx: WithOtherFields = WithOtherFields { + inner: tx, + other: OptimismTransactionFields { + source_hash: Some(b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )), + mint: Some(U128::from(0)), + is_system_tx: Some(true), + } + .into(), + }; + + let pending = provider.send_transaction(tx).await.unwrap().register().await.unwrap(); // mine block api.evm_mine(None).await.unwrap(); - let receipt = provider.get_transaction_receipt(pending.tx_hash()).await.unwrap().unwrap(); - assert_eq!(receipt.from, from_addr); - assert_eq!(receipt.to, Some(to_addr)); + let receipt = + provider.get_transaction_receipt(pending.tx_hash().to_owned()).await.unwrap().unwrap(); + assert_eq!(receipt.from, from); + assert_eq!(receipt.to, Some(to)); // the recipient should have received the value - let balance = provider.get_balance(to_addr, None).await.unwrap(); - assert_eq!(balance, send_value); + let after_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(after_balance_to, before_balance_to + send_value); } #[tokio::test(flavor = "multi_thread")] @@ -101,46 +98,54 @@ async fn test_send_value_raw_deposit_transaction() { // enable the Optimism flag let (api, handle) = spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let signer: EthereumSigner = accounts[0].clone().into(); + let from = accounts[0].address(); + let to = accounts[1].address(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer.clone()); let send_value = U256::from(1234); - let from_addr: Address = "cf7f9e66af820a19257a2108375b180b0ec49167".parse().unwrap(); - let to_addr: Address = "71562b71999873db5b286df957af199ec94617f7".parse().unwrap(); - - // fund the sender - api.anvil_set_balance(from_addr.to_alloy(), send_value.to_alloy()).await.unwrap(); - - let deposit_tx: TypedTransaction = TypedTransaction::DepositTransaction(DepositTransaction { - tx: TransactionRequest { - chain_id: None, - from: Some(from_addr), - to: Some(ethers::types::NameOrAddress::Address(to_addr)), - value: Some(send_value), - gas: Some(U256::from(21000)), - gas_price: None, - data: Some(Bytes::default()), - nonce: None, - }, - source_hash: H256::from_str( - "0000000000000000000000000000000000000000000000000000000000000000", - ) - .unwrap(), - mint: Some(U256::zero()), - is_system_tx: true, - }); - - let rlpbytes = deposit_tx.rlp(); - let pending = provider.send_raw_transaction(rlpbytes).await.unwrap(); + let before_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + + let tx = TransactionRequest::default() + .with_chain_id(31337) + .with_nonce(0) + .with_from(from) + .with_to(to) + .with_value(send_value) + .with_gas_limit(21_000) + .with_max_fee_per_gas(20_000_000_000) + .with_max_priority_fee_per_gas(1_000_000_000); + let tx = WithOtherFields { + inner: tx, + other: OptimismTransactionFields { + source_hash: Some(b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )), + mint: Some(U128::from(0)), + is_system_tx: Some(true), + } + .into(), + }; + let tx_envelope = tx.build(&signer).await.unwrap(); + let mut tx_buffer = Vec::with_capacity(tx_envelope.encode_2718_len()); + tx_envelope.encode_2718(&mut tx_buffer); + let tx_encoded = tx_buffer.as_slice(); + + let pending = + provider.send_raw_transaction(tx_encoded).await.unwrap().register().await.unwrap(); // mine block api.evm_mine(None).await.unwrap(); - let receipt = provider.get_transaction_receipt(pending.tx_hash()).await.unwrap().unwrap(); - assert_eq!(receipt.from, from_addr); - assert_eq!(receipt.to, Some(to_addr)); - assert_eq!(receipt.other.get_deserialized::("depositNonce").unwrap().unwrap(), 0); + let receipt = + provider.get_transaction_receipt(pending.tx_hash().to_owned()).await.unwrap().unwrap(); + assert_eq!(receipt.from, from); + assert_eq!(receipt.to, Some(to)); // the recipient should have received the value - let balance = provider.get_balance(to_addr, None).await.unwrap(); - assert_eq!(balance, send_value); + let after_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(after_balance_to, before_balance_to + send_value); } diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 3b27a0f6c687b..8f4bc942fce6a 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -1,28 +1,21 @@ //! tests for otterscan endpoints use crate::{ abi::MulticallContract, - utils::{ - ethers_http_provider, ethers_ws_provider, ContractInstanceCompat, DeploymentTxFactoryCompat, - }, + utils::{http_provider_with_signer, ws_provider_with_signer}, }; -use alloy_primitives::U256 as rU256; -use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions}; +use alloy_network::EthereumSigner; +use alloy_primitives::{Address, Bytes, TxKind, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions, TransactionRequest, WithOtherFields}; +use alloy_sol_types::sol; use anvil::{ eth::otterscan::types::{ OtsInternalOperation, OtsInternalOperationType, OtsTrace, OtsTraceType, }, spawn, NodeConfig, }; -use ethers::{ - abi::Address, - prelude::{ContractFactory, ContractInstance, Middleware, SignerMiddleware}, - signers::Signer, - types::{Bytes, TransactionRequest}, - utils::get_contract_address, -}; -use foundry_common::types::{ToAlloy, ToEthers}; use foundry_compilers::{project_util::TempProject, Artifact}; -use std::{collections::VecDeque, str::FromStr, sync::Arc}; +use std::{collections::VecDeque, str::FromStr}; #[tokio::test(flavor = "multi_thread")] async fn can_call_erigon_get_header_by_number() { @@ -46,28 +39,33 @@ async fn can_call_ots_get_api_level() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_internal_operations_contract_deploy() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); let sender = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - let mut deploy_tx = MulticallContract::deploy(Arc::clone(&client), ()).unwrap().deployer.tx; - deploy_tx.set_nonce(0); - let contract_address = get_contract_address(sender, deploy_tx.nonce().unwrap()); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let receipt = client.send_transaction(deploy_tx, None).await.unwrap().await.unwrap().unwrap(); + let contract_receipt = MulticallContract::deploy_builder(provider.clone()) + .from(sender) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); - let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); + let res = api.ots_get_internal_operations(contract_receipt.transaction_hash).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( res[0], OtsInternalOperation { r#type: OtsInternalOperationType::Create, - from: sender.to_alloy(), - to: contract_address.to_alloy(), - value: rU256::from(0) + from: sender, + to: contract_address, + value: U256::from(0) } ); } @@ -75,22 +73,21 @@ async fn can_call_ots_get_internal_operations_contract_deploy() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_internal_operations_contract_transfer() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + + let provider = handle.http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); - let tx = TransactionRequest::new() - .to(to.to_ethers()) - .value(amount.to_ethers()) - .from(from.to_ethers()); + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); - let receipt = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); + let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( @@ -114,7 +111,7 @@ pragma solidity 0.8.13; contract Contract { address constant CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; constructor() {} - function deploy() public { + function deployContract() public { uint256 salt = 0; uint256 code = 0; bytes memory creationCode = abi.encodePacked(code); @@ -126,40 +123,52 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function deployContract() external; + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallets = handle.dev_wallets().collect::>().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - // deploy successfully - let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - let contract = ContractInstance::new_compat( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), - ); - let call = contract.method::<_, ()>("deploy", ()).unwrap(); + // deploy successfully + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = Contract::new(contract_address, &provider); + let receipt = contract.deployContract().send().await.unwrap().get_receipt().await.unwrap(); - let receipt = call.send().await.unwrap().await.unwrap().unwrap(); - let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); + let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( res[0], OtsInternalOperation { r#type: OtsInternalOperationType::Create2, - from: Address::from_str("0x4e59b44847b379578588920cA78FbF26c0B4956C") - .unwrap() - .to_alloy(), - to: Address::from_str("0x347bcdad821abc09b8c275881b368de36476b62c").unwrap().to_alloy(), - value: rU256::from(0) + from: Address::from_str("0x4e59b44847b379578588920cA78FbF26c0B4956C").unwrap(), + to: Address::from_str("0x347bcdad821abc09b8c275881b368de36476b62c").unwrap(), + value: U256::from(0) } ); } @@ -184,39 +193,53 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function goodbye() external; + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallets = handle.dev_wallets().collect::>().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - // deploy successfully - let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - let contract = ContractInstance::new_compat( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), - ); - let call = contract.method::<_, ()>("goodbye", ()).unwrap(); + // deploy successfully + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = Contract::new(contract_address, &provider); - let receipt = call.send().await.unwrap().await.unwrap().unwrap(); + let receipt = contract.goodbye().send().await.unwrap().get_receipt().await.unwrap(); - let res = api.ots_get_internal_operations(receipt.transaction_hash.to_alloy()).await.unwrap(); + let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!(res.len(), 1); assert_eq!( res[0], OtsInternalOperation { r#type: OtsInternalOperationType::SelfDestruct, - from: contract.address().to_alloy(), + from: *contract.address(), to: Default::default(), - value: rU256::from(0) + value: U256::from(0) } ); } @@ -224,44 +247,30 @@ contract Contract { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_has_code() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); let sender = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - api.mine_one().await; - let mut deploy_tx = MulticallContract::deploy(Arc::clone(&client), ()).unwrap().deployer.tx; - deploy_tx.set_nonce(0); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let pending_contract_address = get_contract_address(sender, deploy_tx.nonce().unwrap()); + api.mine_one().await; + + let contract_address = sender.create(0); // no code in the address before deploying - assert!(!api - .ots_has_code(pending_contract_address.to_alloy(), BlockNumberOrTag::Number(1)) - .await - .unwrap()); + assert!(!api.ots_has_code(contract_address, BlockNumberOrTag::Number(1)).await.unwrap()); - let pending = client.send_transaction(deploy_tx, None).await.unwrap(); - let receipt = pending.await.unwrap().unwrap(); + let contract_builder = MulticallContract::deploy_builder(provider.clone()); + let contract_receipt = contract_builder.send().await.unwrap().get_receipt().await.unwrap(); - let num = client.get_block_number().await.unwrap(); - assert_eq!(num, receipt.block_number.unwrap()); + let num = provider.get_block_number().await.unwrap(); + assert_eq!(num, contract_receipt.block_number.unwrap()); // code is detected after deploying - assert!(api - .ots_has_code(pending_contract_address.to_alloy(), BlockNumberOrTag::Number(num.as_u64())) - .await - .unwrap()); + assert!(api.ots_has_code(contract_address, BlockNumberOrTag::Number(num)).await.unwrap()); // code is not detected for the previous block - assert!(!api - .ots_has_code( - pending_contract_address.to_alloy(), - BlockNumberOrTag::Number(num.as_u64() - 1) - ) - .await - .unwrap()); + assert!(!api.ots_has_code(contract_address, BlockNumberOrTag::Number(num - 1)).await.unwrap()); } #[tokio::test(flavor = "multi_thread")] @@ -297,29 +306,56 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function run() external payable; + function do_staticcall() external view returns (bool); + function do_call() external; + function do_delegatecall() external; + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallets = handle.dev_wallets().collect::>().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + let wallets = handle.dev_wallets().collect::>(); + let signer: EthereumSigner = wallets[0].clone().into(); + let sender = wallets[0].address(); - // deploy successfully - let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - let contract = ContractInstance::new_compat( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), - ); - let call = contract.method::<_, ()>("run", ()).unwrap().value(1337); - let receipt = call.send().await.unwrap().await.unwrap().unwrap(); + // deploy successfully + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = Contract::new(contract_address, &provider); + + let receipt = contract + .run() + .from(sender) + .value(U256::from(1337)) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); - let res = api.ots_trace_transaction(receipt.transaction_hash.to_alloy()).await.unwrap(); + let res = api.ots_trace_transaction(receipt.transaction_hash).await.unwrap(); assert_eq!( res, @@ -327,41 +363,41 @@ contract Contract { OtsTrace { r#type: OtsTraceType::Call, depth: 0, - from: wallets[1].address().to_alloy(), - to: contract.address().to_alloy(), - value: rU256::from(1337), + from: sender, + to: contract_address, + value: U256::from(1337), input: Bytes::from_str("0xc0406226").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::StaticCall, depth: 1, - from: contract.address().to_alloy(), - to: contract.address().to_alloy(), - value: rU256::ZERO, + from: contract_address, + to: contract_address, + value: U256::ZERO, input: Bytes::from_str("0x6a6758fe").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::Call, depth: 1, - from: contract.address().to_alloy(), - to: contract.address().to_alloy(), - value: rU256::ZERO, + from: contract_address, + to: contract_address, + value: U256::ZERO, input: Bytes::from_str("0x96385e39").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::Call, depth: 2, - from: contract.address().to_alloy(), - to: wallets[0].address().to_alloy(), - value: rU256::from(1337), + from: contract_address, + to: sender, + value: U256::from(1337), input: Bytes::from_str("0x").unwrap().0.into() }, OtsTrace { r#type: OtsTraceType::DelegateCall, depth: 2, - from: contract.address().to_alloy(), - to: contract.address().to_alloy(), - value: rU256::ZERO, + from: contract_address, + to: contract_address, + value: U256::ZERO, input: Bytes::from_str("0xa1325397").unwrap().0.into() }, ] @@ -386,40 +422,62 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function trigger_revert() external; + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); - let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let (_api, handle) = spawn(NodeConfig::test()).await; + let wallets = handle.dev_wallets().collect::>(); + let signer: EthereumSigner = wallets[0].clone().into(); + let sender = wallets[0].address(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); // deploy successfully - let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let _contract = Contract::new(contract_address, &provider); - let call = contract.method::<_, ()>("trigger_revert", ()).unwrap().gas(150_000u64); - let receipt = call.send().await.unwrap().await.unwrap().unwrap(); + // TODO: currently not possible to capture the receipt + // let receipt = contract.trigger_revert().send().await.unwrap().get_receipt().await.unwrap(); - let res = - api.ots_get_transaction_error(receipt.transaction_hash.to_alloy()).await.unwrap().unwrap(); - let res: Bytes = res.0.into(); - assert_eq!(res, Bytes::from_str("0x8d6ea8be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012526576657274537472696e67466f6f4261720000000000000000000000000000").unwrap()); + // let res = api.ots_get_transaction_error(receipt.transaction_hash).await; + // assert!(res.is_err()); + // assert!(res.unwrap_err().to_string().contains("0x8d6ea8be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012526576657274537472696e67466f6f4261720000000000000000000000000000")); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_details() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let tx = TransactionRequest::new().to(Address::random()).value(100u64); - let receipt = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = + TransactionRequest::default().from(sender).to(Address::random()).value(U256::from(100)); + let tx = WithOtherFields::new(tx); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let result = api.ots_get_block_details(1.into()).await.unwrap(); @@ -429,22 +487,25 @@ async fn can_call_ots_get_block_details() { BlockTransactions::Hashes(hashes) => hashes[0], BlockTransactions::Uncle => unreachable!(), }; - assert_eq!(hash, receipt.transaction_hash.to_alloy()); + assert_eq!(hash, receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_details_by_hash() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let tx = TransactionRequest::new().to(Address::random()).value(100u64); - let receipt = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = + TransactionRequest::default().from(sender).to(Address::random()).value(U256::from(100)); + let tx = WithOtherFields::new(tx); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let block_hash = receipt.block_hash.unwrap(); - let result = api.ots_get_block_details_by_hash(block_hash.to_alloy()).await.unwrap(); + let result = api.ots_get_block_details_by_hash(block_hash).await.unwrap(); assert_eq!(result.block.transaction_count, 1); let hash = match result.block.block.transactions { @@ -452,25 +513,32 @@ async fn can_call_ots_get_block_details_by_hash() { BlockTransactions::Hashes(hashes) => hashes[0], BlockTransactions::Uncle => unreachable!(), }; - assert_eq!(hash.to_ethers(), receipt.transaction_hash); + assert_eq!(hash, receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); // disable automine api.anvil_set_auto_mine(false).await.unwrap(); let mut hashes = VecDeque::new(); for i in 0..10 { - let tx = TransactionRequest::new().to(Address::random()).value(100u64).nonce(i); - let receipt = client.send_transaction(tx, None).await.unwrap(); - hashes.push_back(receipt.tx_hash()); + let tx = TransactionRequest::default() + .from(sender) + .to(Address::random()) + .value(U256::from(100)) + .nonce(i); + let tx = WithOtherFields::new(tx); + let pending_receipt = + provider.send_transaction(tx).await.unwrap().register().await.unwrap(); + hashes.push_back(*pending_receipt.tx_hash()); } api.mine_one().await; @@ -486,11 +554,8 @@ async fn can_call_ots_get_block_transactions() { result.receipts.iter().enumerate().for_each(|(i, receipt)| { let expected = hashes.pop_front(); - assert_eq!(expected, Some(receipt.transaction_hash.to_ethers())); - assert_eq!( - expected.map(|h| h.to_alloy()), - result.fullblock.block.transactions.hashes().nth(i).copied(), - ); + assert_eq!(expected, Some(receipt.transaction_hash)); + assert_eq!(expected, result.fullblock.block.transactions.hashes().nth(i).copied()); }); } @@ -500,31 +565,35 @@ async fn can_call_ots_get_block_transactions() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_search_transactions_before() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); let sender = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); let mut hashes = vec![]; for i in 0..7 { - let tx = TransactionRequest::new().to(Address::random()).value(100u64).nonce(i); - let receipt = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = TransactionRequest::default() + .from(sender) + .to(Address::random()) + .value(U256::from(100)) + .nonce(i); + let tx = WithOtherFields::new(tx); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); hashes.push(receipt.transaction_hash); } let page_size = 2; let mut block = 0; for _ in 0..4 { - let result = - api.ots_search_transactions_before(sender.to_alloy(), block, page_size).await.unwrap(); + let result = api.ots_search_transactions_before(sender, block, page_size).await.unwrap(); assert!(result.txs.len() <= page_size); // check each individual hash result.txs.iter().for_each(|tx| { - assert_eq!(hashes.pop(), Some(tx.hash.to_ethers())); + assert_eq!(hashes.pop(), Some(tx.hash)); }); block = result.txs.last().unwrap().block_number.unwrap() - 1; @@ -536,31 +605,35 @@ async fn can_call_ots_search_transactions_before() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_search_transactions_after() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); let sender = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); let mut hashes = VecDeque::new(); for i in 0..7 { - let tx = TransactionRequest::new().to(Address::random()).value(100u64).nonce(i); - let receipt = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = TransactionRequest::default() + .from(sender) + .to(Address::random()) + .value(U256::from(100)) + .nonce(i); + let tx = WithOtherFields::new(tx); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); hashes.push_front(receipt.transaction_hash); } let page_size = 2; let mut block = 0; for _ in 0..4 { - let result = - api.ots_search_transactions_after(sender.to_alloy(), block, page_size).await.unwrap(); + let result = api.ots_search_transactions_after(sender, block, page_size).await.unwrap(); assert!(result.txs.len() <= page_size); // check each individual hash result.txs.iter().for_each(|tx| { - assert_eq!(hashes.pop_back(), Some(tx.hash.to_ethers())); + assert_eq!(hashes.pop_back(), Some(tx.hash)); }); block = result.txs.last().unwrap().block_number.unwrap() + 1; @@ -572,52 +645,58 @@ async fn can_call_ots_search_transactions_after() { #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_transaction_by_sender_and_nonce() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - api.mine_one().await; - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); let sender = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - let tx1 = TransactionRequest::new().to(Address::random()).value(100u64); - let tx2 = TransactionRequest::new().to(Address::random()).value(100u64); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let receipt1 = client.send_transaction(tx1, None).await.unwrap().await.unwrap().unwrap(); - let receipt2 = client.send_transaction(tx2, None).await.unwrap().await.unwrap().unwrap(); + api.mine_one().await; - let result1 = api - .ots_get_transaction_by_sender_and_nonce(sender.to_alloy(), rU256::from(0)) - .await - .unwrap(); - let result2 = api - .ots_get_transaction_by_sender_and_nonce(sender.to_alloy(), rU256::from(1)) - .await - .unwrap(); + let tx1 = WithOtherFields::new( + TransactionRequest::default() + .from(sender) + .to(Address::random()) + .value(U256::from(100)) + .nonce(0), + ); + let tx2 = WithOtherFields::new( + TransactionRequest::default() + .from(sender) + .to(Address::random()) + .value(U256::from(100)) + .nonce(1), + ); + + let receipt1 = provider.send_transaction(tx1).await.unwrap().get_receipt().await.unwrap(); + let receipt2 = provider.send_transaction(tx2).await.unwrap().get_receipt().await.unwrap(); - assert_eq!(result1.unwrap(), receipt1.transaction_hash.to_alloy()); - assert_eq!(result2.unwrap(), receipt2.transaction_hash.to_alloy()); + let result1 = + api.ots_get_transaction_by_sender_and_nonce(sender, U256::from(0)).await.unwrap().unwrap(); + let result2 = + api.ots_get_transaction_by_sender_and_nonce(sender, U256::from(1)).await.unwrap().unwrap(); + + assert_eq!(result1, receipt1.transaction_hash); + assert_eq!(result2, receipt2.transaction_hash); } #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_contract_creator() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - api.mine_one().await; - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); let sender = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - let mut deploy_tx = MulticallContract::deploy(Arc::clone(&client), ()).unwrap().deployer.tx; - deploy_tx.set_nonce(0); + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let pending_contract_address = get_contract_address(sender, deploy_tx.nonce().unwrap()); + api.mine_one().await; - let receipt = client.send_transaction(deploy_tx, None).await.unwrap().await.unwrap().unwrap(); + let contract_builder = MulticallContract::deploy_builder(provider.clone()); + let contract_receipt = contract_builder.send().await.unwrap().get_receipt().await.unwrap(); + let contract_address = sender.create(0); - let creator = - api.ots_get_contract_creator(pending_contract_address.to_alloy()).await.unwrap().unwrap(); + let creator = api.ots_get_contract_creator(contract_address).await.unwrap().unwrap(); - assert_eq!(creator.creator, sender.to_alloy()); - assert_eq!(creator.hash, receipt.transaction_hash.to_alloy()); + assert_eq!(creator.creator, sender); + assert_eq!(creator.hash, contract_receipt.transaction_hash); } diff --git a/crates/anvil/tests/it/proof.rs b/crates/anvil/tests/it/proof.rs index d5a09e8ad9e2a..757d36082696d 100644 --- a/crates/anvil/tests/it/proof.rs +++ b/crates/anvil/tests/it/proof.rs @@ -1,9 +1,8 @@ //! tests for `eth_getProof` -use std::{collections::BTreeMap, str::FromStr}; - use alloy_primitives::{address, fixed_bytes, Address, Bytes, B256, U256}; use anvil::{eth::EthApi, spawn, NodeConfig}; +use std::{collections::BTreeMap, str::FromStr}; async fn verify_account_proof( api: &EthApi, diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index a8dd6d3d75558..f29dbb81f2117 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -1,275 +1,272 @@ //! tests for subscriptions -use crate::utils::{ethers_http_provider, ethers_ws_provider}; +use crate::utils::{connect_pubsub, connect_pubsub_with_signer}; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{Address, U256}; +use alloy_provider::Provider; +use alloy_pubsub::Subscription; +use alloy_rpc_types::{Block as AlloyBlock, Filter, TransactionRequest, WithOtherFields}; +use alloy_sol_types::sol; use anvil::{spawn, NodeConfig}; -use ethers::{ - contract::abigen, - middleware::SignerMiddleware, - prelude::{Middleware, Ws}, - providers::{JsonRpcClient, PubsubClient}, - signers::Signer, - types::{Address, Block, Filter, TransactionRequest, TxHash, ValueOrArray, U256}, -}; -use foundry_common::types::{ToAlloy, ToEthers}; use futures::StreamExt; -use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn test_sub_new_heads() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = connect_pubsub(&handle.ws_endpoint()).await; let blocks = provider.subscribe_blocks().await.unwrap(); // mine a block every 1 seconds api.anvil_set_interval_mining(1).unwrap(); - let blocks = blocks.take(3).collect::>().await; - let block_numbers = blocks.into_iter().map(|b| b.number.unwrap().as_u64()).collect::>(); + let blocks = blocks.into_stream().take(3).collect::>().await; + let block_numbers = blocks.into_iter().map(|b| b.header.number.unwrap()).collect::>(); assert_eq!(block_numbers, vec![1, 2, 3]); } +sol!( + #[sol(rpc)] + EmitLogs, + "test-data/emit_logs.json" +); +// FIXME: Use .legacy() in tx when implemented in alloy #[tokio::test(flavor = "multi_thread")] async fn test_sub_logs_legacy() { - abigen!(EmitLogs, "test-data/emit_logs.json"); - let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + let provider = connect_pubsub(&handle.ws_endpoint()).await; let msg = "First Message".to_string(); - let contract = - EmitLogs::deploy(Arc::clone(&client), msg.clone()).unwrap().legacy().send().await.unwrap(); + let contract_addr = EmitLogs::deploy_builder(provider.clone(), msg.clone()) + .from(wallet.address()) + .deploy() + .await + .unwrap(); + let contract = EmitLogs::new(contract_addr, provider.clone()); - let val = contract.get_value().call().await.unwrap(); - assert_eq!(val, msg); + let val = contract.getValue().call().await.unwrap(); + assert_eq!(val._0, msg); // subscribe to events from the contract - let filter = Filter::new().address(ValueOrArray::Value(contract.address())); - let mut logs_sub = client.subscribe_logs(&filter).await.unwrap(); + let filter = Filter::new().address(contract.address().to_owned()); + let logs_sub = provider.subscribe_logs(&filter).await.unwrap(); // send a tx triggering an event + // FIXME: Use .legacy() in tx let receipt = contract - .set_value("Next Message".to_string()) - .legacy() + .setValue("Next Message".to_string()) .send() .await .unwrap() + .get_receipt() .await - .unwrap() .unwrap(); + let mut logs_sub = logs_sub.into_stream(); // get the emitted event let log = logs_sub.next().await.unwrap(); // ensure the log in the receipt is the same as received via subscription stream - assert_eq!(receipt.logs[0], log); + assert_eq!(receipt.inner.logs()[0], log); } #[tokio::test(flavor = "multi_thread")] async fn test_sub_logs() { - abigen!(EmitLogs, "test-data/emit_logs.json"); - let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + let provider = connect_pubsub(&handle.ws_endpoint()).await; let msg = "First Message".to_string(); - let contract = - EmitLogs::deploy(Arc::clone(&client), msg.clone()).unwrap().send().await.unwrap(); + let contract_addr = EmitLogs::deploy_builder(provider.clone(), msg.clone()) + .from(wallet.address()) + .deploy() + .await + .unwrap(); + let contract = EmitLogs::new(contract_addr, provider.clone()); - let val = contract.get_value().call().await.unwrap(); - assert_eq!(val, msg); + let val = contract.getValue().call().await.unwrap(); + assert_eq!(val._0, msg); // subscribe to events from the contract - let filter = Filter::new().address(ValueOrArray::Value(contract.address())); - let mut logs_sub = client.subscribe_logs(&filter).await.unwrap(); + let filter = Filter::new().address(contract.address().to_owned()); + let logs_sub = provider.subscribe_logs(&filter).await.unwrap(); // send a tx triggering an event let receipt = contract - .set_value("Next Message".to_string()) + .setValue("Next Message".to_string()) .send() .await .unwrap() + .get_receipt() .await - .unwrap() .unwrap(); + let mut logs_sub = logs_sub.into_stream(); // get the emitted event let log = logs_sub.next().await.unwrap(); // ensure the log in the receipt is the same as received via subscription stream - assert_eq!(receipt.logs[0], log); + assert_eq!(receipt.inner.logs()[0], log); } #[tokio::test(flavor = "multi_thread")] async fn test_sub_logs_impersonated() { - abigen!(EmitLogs, "test-data/emit_logs.json"); - let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); + let provider = + connect_pubsub_with_signer(&handle.ws_endpoint(), EthereumSigner::from(wallet.clone())) + .await; // impersonate account let impersonate = Address::random(); let funding = U256::from(1e18 as u64); - api.anvil_set_balance(impersonate.to_alloy(), funding.to_alloy()).await.unwrap(); - api.anvil_impersonate_account(impersonate.to_alloy()).await.unwrap(); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + api.anvil_set_balance(impersonate, funding).await.unwrap(); + api.anvil_impersonate_account(impersonate).await.unwrap(); let msg = "First Message".to_string(); - let contract = - EmitLogs::deploy(Arc::clone(&client), msg.clone()).unwrap().send().await.unwrap(); + let contract = EmitLogs::deploy(provider.clone(), msg.clone()).await.unwrap(); - let _val = contract.get_value().call().await.unwrap(); + let _val = contract.getValue().call().await.unwrap(); // subscribe to events from the impersonated account - let filter = Filter::new().address(ValueOrArray::Value(contract.address())); - let mut logs_sub = client.subscribe_logs(&filter).await.unwrap(); + let filter = Filter::new().address(contract.address().to_owned()); + let logs_sub = provider.subscribe_logs(&filter).await.unwrap(); // send a tx triggering an event - let data = contract.set_value("Next Message".to_string()).tx.data().cloned().unwrap(); + let data = contract.setValue("Next Message".to_string()); + let data = data.calldata().clone(); - let tx = TransactionRequest::new().from(impersonate).to(contract.address()).data(data); + let tx = + TransactionRequest::default().from(impersonate).to(*contract.address()).with_input(data); - let provider = ethers_http_provider(&handle.http_endpoint()); + let tx = WithOtherFields::new(tx); + let provider = handle.http_provider(); - let receipt = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let mut logs_sub = logs_sub.into_stream(); // get the emitted event let log = logs_sub.next().await.unwrap(); // ensure the log in the receipt is the same as received via subscription stream - assert_eq!(receipt.logs[0], log); + assert_eq!(receipt.inner.inner.logs()[0], log); } +// FIXME: Use legacy() in tx when implemented in alloy #[tokio::test(flavor = "multi_thread")] async fn test_filters_legacy() { - abigen!(EmitLogs, "test-data/emit_logs.json"); - let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); + let provider = + connect_pubsub_with_signer(&handle.ws_endpoint(), EthereumSigner::from(wallet.clone())) + .await; - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let from = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); let msg = "First Message".to_string(); - let contract = - EmitLogs::deploy(Arc::clone(&client), msg.clone()).unwrap().legacy().send().await.unwrap(); - let filter = contract.value_changed_filter(); - let mut stream = filter.stream().await.unwrap(); + // FIXME: Use legacy() in tx when implemented in alloy + let contract = EmitLogs::deploy(provider.clone(), msg.clone()).await.unwrap(); + + let stream = contract.ValueChanged_filter().subscribe().await.unwrap(); // send a tx triggering an event + // FIXME: Use legacy() in tx when implemented in alloy let _receipt = contract - .set_value("Next Message".to_string()) - .legacy() + .setValue("Next Message".to_string()) .send() .await .unwrap() + .get_receipt() .await - .unwrap() .unwrap(); + let mut log = stream.into_stream(); // get the emitted event - let log = stream.next().await.unwrap().unwrap(); - assert_eq!( - log, - ValueChangedFilter { - author: from, - old_value: "First Message".to_string(), - new_value: "Next Message".to_string(), - }, - ); + let (value_changed, _log) = log.next().await.unwrap().unwrap(); + + assert_eq!(value_changed.author, from); + assert_eq!(value_changed.oldValue, "First Message".to_string()); + assert_eq!(value_changed.newValue, "Next Message".to_string()); } #[tokio::test(flavor = "multi_thread")] async fn test_filters() { - abigen!(EmitLogs, "test-data/emit_logs.json"); - let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); + let provider = + connect_pubsub_with_signer(&handle.ws_endpoint(), EthereumSigner::from(wallet.clone())) + .await; - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); let from = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); let msg = "First Message".to_string(); - let contract = - EmitLogs::deploy(Arc::clone(&client), msg.clone()).unwrap().send().await.unwrap(); - let filter = contract.value_changed_filter(); - let mut stream = filter.stream().await.unwrap(); + let contract = EmitLogs::deploy(provider.clone(), msg.clone()).await.unwrap(); + + let stream = contract.ValueChanged_filter().subscribe().await.unwrap(); // send a tx triggering an event let _receipt = contract - .set_value("Next Message".to_string()) + .setValue("Next Message".to_string()) .send() .await .unwrap() + .get_receipt() .await - .unwrap() .unwrap(); + let mut log = stream.into_stream(); // get the emitted event - let log = stream.next().await.unwrap().unwrap(); - assert_eq!( - log, - ValueChangedFilter { - author: from, - old_value: "First Message".to_string(), - new_value: "Next Message".to_string(), - }, - ); + let (value_changed, _log) = log.next().await.unwrap().unwrap(); + + assert_eq!(value_changed.author, from); + assert_eq!(value_changed.oldValue, "First Message".to_string()); + assert_eq!(value_changed.newValue, "Next Message".to_string()); } #[tokio::test(flavor = "multi_thread")] async fn test_subscriptions() { let (_api, handle) = spawn(NodeConfig::test().with_blocktime(Some(std::time::Duration::from_secs(1)))).await; - let ws = Ws::connect(handle.ws_endpoint()).await.unwrap(); - - // Subscribing requires sending the sub request and then subscribing to - // the returned sub_id - let sub_id: U256 = ws.request("eth_subscribe", ["newHeads"]).await.unwrap(); - let mut stream = ws.subscribe(sub_id).unwrap(); - - let mut blocks = Vec::new(); - for _ in 0..3 { - let item = stream.next().await.unwrap(); - let block: Block = serde_json::from_str(item.get()).unwrap(); - blocks.push(block.number.unwrap_or_default().as_u64()); - } + let provider = connect_pubsub(&handle.ws_endpoint()).await; + let sub_id: U256 = provider.raw_request("eth_subscribe".into(), ["newHeads"]).await.unwrap(); + let stream: Subscription = provider.get_subscription(sub_id).await.unwrap(); + let blocks = stream + .into_stream() + .take(3) + .collect::>() + .await + .into_iter() + .map(|b| b.header.number.unwrap()) + .collect::>(); assert_eq!(blocks, vec![1, 2, 3]) } +// TODO: Fix this, num > 17 breaks the test due to poller channel_size defaults to 16. Recv channel +// lags behind. #[tokio::test(flavor = "multi_thread")] async fn test_sub_new_heads_fast() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = connect_pubsub(&handle.ws_endpoint()).await; let blocks = provider.subscribe_blocks().await.unwrap(); + let mut blocks = blocks.into_stream(); + + let num = 1000u64; + + let mut block_numbers = Vec::new(); + for _ in 0..num { + api.mine_one().await; + let block_number = blocks.next().await.unwrap().header.number.unwrap(); + block_numbers.push(block_number); + } - let num = 1_000u64; - let mine_api = api.clone(); - tokio::task::spawn(async move { - for _ in 0..num { - mine_api.mine_one().await; - } - }); - - // collect all the blocks - let blocks = blocks.take(num as usize).collect::>().await; - let block_numbers = blocks.into_iter().map(|b| b.number.unwrap().as_u64()).collect::>(); + println!("Collected {} blocks", block_numbers.len()); let numbers = (1..=num).collect::>(); assert_eq!(block_numbers, numbers); diff --git a/crates/anvil/tests/it/revert.rs b/crates/anvil/tests/it/revert.rs index 6ba4a67f7ec17..5cb9b2fedc81a 100644 --- a/crates/anvil/tests/it/revert.rs +++ b/crates/anvil/tests/it/revert.rs @@ -1,13 +1,14 @@ -use crate::abi::VENDING_MACHINE_CONTRACT; -use anvil::{spawn, NodeConfig}; -use ethers::{ - contract::{ContractFactory, ContractInstance}, - middleware::SignerMiddleware, - types::U256, - utils::WEI_IN_ETHER, +use crate::{ + abi::{VendingMachine, VENDING_MACHINE_CONTRACT}, + utils::ws_provider_with_signer, }; +use alloy_network::EthereumSigner; +use alloy_primitives::{TxKind, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_sol_types::sol; +use anvil::{spawn, NodeConfig}; use foundry_compilers::{project_util::TempProject, Artifact}; -use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn test_deploy_reverting() { @@ -28,20 +29,25 @@ contract Contract { let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); - let wallet = handle.dev_wallets().next().unwrap(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let factory = ContractFactory::new(abi.unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await; - assert!(contract.is_err()); + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); // should catch the revert during estimation which results in an err - let err = contract.unwrap_err(); + let err = provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap_err(); assert!(err.to_string().contains("execution reverted")); } @@ -55,7 +61,7 @@ pragma solidity 0.8.13; contract Contract { address owner; constructor() public { - owner = msg.sender; + owner = address(1); } modifier onlyOwner() { require(msg.sender == owner, "!authorized"); @@ -69,31 +75,45 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function getSecret() external; + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); - let wallets = handle.dev_wallets().collect::>(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); - - // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); - - let contract = ContractInstance::new( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), - ); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let resp = contract.method::<_, U256>("getSecret", ()).unwrap().call().await; + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - let err = resp.unwrap_err(); - let msg = err.to_string(); - assert!(msg.contains("execution reverted: !authorized")); + // deploy successfully + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = Contract::new(contract_address, &provider); + + let res = contract.getSecret().send().await.unwrap_err(); + + let msg = res.to_string(); + assert!(msg.contains("execution reverted: revert: !authorized")); } #[tokio::test(flavor = "multi_thread")] @@ -104,35 +124,50 @@ async fn test_solc_revert_example() { let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("VendingMachine").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); - let wallets = handle.dev_wallets().collect::>(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); - - // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); - - let contract = ContractInstance::new( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), - ); - - for fun in ["buyRevert", "buyRequire"] { - let resp = contract.method::<_, ()>(fun, U256::zero()).unwrap().call().await; - resp.unwrap(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let ten = WEI_IN_ETHER.saturating_mul(10u64.into()); - let call = contract.method::<_, ()>(fun, ten).unwrap().value(ten); + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - let resp = call.clone().call().await; - let err = resp.unwrap_err().to_string(); - assert!(err.contains("execution reverted: Not enough Ether provided.")); - assert!(err.contains("code: 3")); - } + // deploy successfully + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = VendingMachine::new(contract_address, &provider); + + let res = contract + .buyRevert(U256::from(100)) + .value(U256::from(1)) + .from(sender) + .send() + .await + .unwrap_err(); + let msg = res.to_string(); + assert!(msg.contains("execution reverted: revert: Not enough Ether provided.")); + + let res = contract + .buyRequire(U256::from(100)) + .value(U256::from(1)) + .from(sender) + .send() + .await + .unwrap_err(); + let msg = res.to_string(); + assert!(msg.contains("execution reverted: revert: Not enough Ether provided.")); } // @@ -155,31 +190,45 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function setNumber(uint256 num) external; + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.ws_provider(); - let wallets = handle.dev_wallets().collect::>(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); - - // deploy successfully - let factory = ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let contract = ContractInstance::new( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(handle.http_provider(), wallets[1].clone()), - ); - let call = contract.method::<_, ()>("setNumber", U256::zero()).unwrap(); - let resp = call.send().await; + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - let err = resp.unwrap_err(); - let msg = err.to_string(); - assert!(msg.contains("execution reverted: RevertStringFooBar")); + // deploy successfully + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = Contract::new(contract_address, &provider); + + let res = contract.setNumber(U256::from(0)).send().await.unwrap_err(); + + let msg = res.to_string(); + assert!(msg.contains("execution reverted: revert: RevertStringFooBar")); } #[tokio::test(flavor = "multi_thread")] @@ -201,25 +250,41 @@ contract Contract { ) .unwrap(); + sol!( + #[sol(rpc)] + contract Contract { + function revertAddress() external; + } + ); + let mut compiled = prj.compile().unwrap(); assert!(!compiled.has_compiler_errors()); let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let bytecode = contract.into_bytecode_bytes().unwrap(); let (_api, handle) = spawn(NodeConfig::test()).await; + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumSigner = wallet.clone().into(); + let sender = wallet.address(); - let provider = handle.ws_provider(); - let wallets = handle.dev_wallets().collect::>(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); // deploy successfully - let factory = - ContractFactory::new(abi.clone().unwrap(), bytecode.unwrap(), Arc::clone(&client)); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); - - let call = contract.method::<_, ()>("revertAddress", ()).unwrap().gas(150000); - - let resp = call.call().await; - - let _ = resp.unwrap_err(); + provider + .send_transaction(WithOtherFields::new(TransactionRequest { + from: Some(sender), + to: Some(TxKind::Create), + input: bytecode.into(), + ..Default::default() + })) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = sender.create(0); + let contract = Contract::new(contract_address, &provider); + + let res = contract.revertAddress().send().await.unwrap_err(); + assert!(res.to_string().contains("execution reverted")); } diff --git a/crates/anvil/tests/it/sign.rs b/crates/anvil/tests/it/sign.rs index 79b8efbf17691..b59b22ffbb304 100644 --- a/crates/anvil/tests/it/sign.rs +++ b/crates/anvil/tests/it/sign.rs @@ -1,12 +1,11 @@ -use crate::utils::ethers_http_provider; +use crate::utils::http_provider_with_signer; use alloy_dyn_abi::TypedData; +use alloy_network::EthereumSigner; +use alloy_primitives::{Address, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_signer::Signer; use anvil::{spawn, NodeConfig}; -use ethers::{ - prelude::{Middleware, SignerMiddleware}, - signers::Signer, - types::{Address, Chain, TransactionRequest}, -}; -use foundry_common::types::ToEthers; #[tokio::test(flavor = "multi_thread")] async fn can_sign_typed_data() { @@ -286,27 +285,25 @@ async fn can_sign_typed_data_os() { #[tokio::test(flavor = "multi_thread")] async fn rejects_different_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap().with_chain_id(Some(1)); + let provider = http_provider_with_signer(&handle.http_endpoint(), EthereumSigner::from(wallet)); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = SignerMiddleware::new(provider, wallet.with_chain_id(Chain::Mainnet)); - - let tx = TransactionRequest::new().to(Address::random()).value(100u64); - - let res = client.send_transaction(tx, None).await; + let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100)); + let tx = WithOtherFields::new(tx); + let res = provider.send_transaction(tx).await; let err = res.unwrap_err(); - assert!(err.to_string().contains("signed for another chain"), "{}", err.to_string()); + assert!(err.to_string().contains("does not match the signer's"), "{}", err.to_string()); } #[tokio::test(flavor = "multi_thread")] async fn rejects_invalid_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let wallet = wallet.with_chain_id(99u64); - let provider = ethers_http_provider(&handle.http_endpoint()); - let client = SignerMiddleware::new(provider, wallet); - let tx = TransactionRequest::new().to(Address::random()).value(100u64); - let res = client.send_transaction(tx, None).await; + let wallet = handle.dev_wallets().next().unwrap(); + let wallet = wallet.with_chain_id(Some(99u64)); + let provider = http_provider_with_signer(&handle.http_endpoint(), EthereumSigner::from(wallet)); + let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100u64)); + let tx = WithOtherFields::new(tx); + let res = provider.send_transaction(tx).await; let _err = res.unwrap_err(); } diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 8b506f3cdb0ce..932e8e362f32a 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,47 +1,39 @@ -use crate::{ - fork::fork_config, - utils::{ - ethers_http_provider, ethers_ws_provider, ContractInstanceCompat, DeploymentTxFactoryCompat, - }, +use crate::{fork::fork_config, utils::http_provider_with_signer}; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{hex, Address, Bytes, U256}; +use alloy_provider::{debug::DebugApi, Provider}; +use alloy_rpc_types::{BlockNumberOrTag, TransactionRequest, WithOtherFields}; +use alloy_rpc_types_trace::{ + geth::{GethDebugTracingCallOptions, GethTrace}, + parity::{Action, LocalizedTransactionTrace}, }; -use alloy_primitives::U256; +use alloy_sol_types::sol; use anvil::{spawn, Hardfork, NodeConfig}; -use ethers::{ - contract::ContractInstance, - prelude::{ - Action, ContractFactory, GethTrace, GethTraceFrame, Middleware, Signer, SignerMiddleware, - TransactionRequest, - }, - types::{ActionType, Address, GethDebugTracingCallOptions, Trace}, - utils::hex, -}; -use foundry_common::types::{ToAlloy, ToEthers}; -use foundry_compilers::{project_util::TempProject, Artifact}; -use std::sync::Arc; #[tokio::test(flavor = "multi_thread")] async fn test_get_transfer_parity_traces() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = handle.ws_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); // specify the `from` field so that the client knows which account to use - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); // broadcast it via the eth_sendTransaction API - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let traces = provider.trace_transaction(tx.transaction_hash).await.unwrap(); assert!(!traces.is_empty()); - match traces[0].action { + match traces[0].trace.action { Action::Call(ref call) => { assert_eq!(call.from, from); assert_eq!(call.to, to); - assert_eq!(call.value, amount.to_ethers()); + assert_eq!(call.value, amount); } _ => unreachable!("unexpected action"), } @@ -53,111 +45,89 @@ async fn test_get_transfer_parity_traces() { assert_eq!(traces, block_traces); } -#[tokio::test(flavor = "multi_thread")] -async fn test_parity_suicide_trace() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r" -pragma solidity 0.8.13; -contract Contract { - address payable private owner; - constructor() public { - owner = payable(msg.sender); - } - function goodbye() public { - selfdestruct(owner); +sol!( + #[sol(rpc, bytecode = "0x6080604052348015600f57600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060a48061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806375fc8e3c14602d575b600080fd5b60336035565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16fffea26469706673582212205006867290df97c54f2df1cb94fc081197ab670e2adf5353071d2ecce1d694b864736f6c634300080d0033")] + contract SuicideContract { + address payable private owner; + constructor() public { + owner = payable(msg.sender); + } + function goodbye() public { + selfdestruct(owner); + } } -} -", - ) - .unwrap(); - - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); +); +#[tokio::test(flavor = "multi_thread")] +async fn test_parity_suicide_trace() { let (_api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Shanghai))).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallets = handle.dev_wallets().collect::>().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + let provider = handle.ws_provider(); + let wallets = handle.dev_wallets().collect::>(); + let owner = wallets[0].address(); + let destructor = wallets[1].address(); // deploy successfully - let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); - - let contract = ContractInstance::new_compat( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), - ); - let call = contract.method::<_, ()>("goodbye", ()).unwrap(); - let tx = call.send().await.unwrap().await.unwrap().unwrap(); - - let traces = ethers_http_provider(&handle.http_endpoint()) - .trace_transaction(tx.transaction_hash) - .await - .unwrap(); + let contract_addr = + SuicideContract::deploy_builder(provider.clone()).from(owner).deploy().await.unwrap(); + let contract = SuicideContract::new(contract_addr, provider.clone()); + let call = contract.goodbye().from(destructor); + let call = call.send().await.unwrap(); + let tx = call.get_receipt().await.unwrap(); + + let traces = handle.http_provider().trace_transaction(tx.transaction_hash).await.unwrap(); assert!(!traces.is_empty()); - assert_eq!(traces[1].action_type, ActionType::Suicide); + assert!(traces[1].trace.action.is_selfdestruct()); } +sol!( + #[sol(rpc, bytecode = "0x6080604052348015600f57600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060a48061005e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806375fc8e3c14602d575b600080fd5b60336035565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16fffea26469706673582212205006867290df97c54f2df1cb94fc081197ab670e2adf5353071d2ecce1d694b864736f6c634300080d0033")] + contract DebugTraceContract { + address payable private owner; + constructor() public { + owner = payable(msg.sender); + } + function goodbye() public { + selfdestruct(owner); + } + } +); + #[tokio::test(flavor = "multi_thread")] async fn test_transfer_debug_trace_call() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r" -pragma solidity 0.8.13; -contract Contract { - address payable private owner; - constructor() public { - owner = payable(msg.sender); - } - function goodbye() public { - selfdestruct(owner); - } -} -", - ) - .unwrap(); + let (_api, handle) = spawn(NodeConfig::test()).await; + let wallets = handle.dev_wallets().collect::>(); + let deployer: EthereumSigner = wallets[0].clone().into(); + let provider = http_provider_with_signer(&handle.http_endpoint(), deployer); - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let (abi, bytecode, _) = contract.into_contract_bytecode().into_parts(); + let contract_addr = DebugTraceContract::deploy_builder(provider.clone()) + .from(wallets[0].clone().address()) + .deploy() + .await + .unwrap(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); - let wallets = handle.dev_wallets().collect::>().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallets[0].clone())); + let caller: EthereumSigner = wallets[1].clone().into(); + let caller_provider = http_provider_with_signer(&handle.http_endpoint(), caller); + let contract = DebugTraceContract::new(contract_addr, caller_provider); - // deploy successfully - let factory = ContractFactory::new_compat(abi.clone().unwrap(), bytecode.unwrap(), client); - let contract = factory.deploy(()).unwrap().send().await.unwrap(); - - let contract = ContractInstance::new_compat( - contract.address(), - abi.unwrap(), - SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallets[1].clone()), - ); - let call = contract.method::<_, ()>("goodbye", ()).unwrap(); - - let traces = ethers_http_provider(&handle.http_endpoint()) - .debug_trace_call(call.tx, None, GethDebugTracingCallOptions::default()) + let call = contract.goodbye().from(wallets[1].address()); + let calldata = call.calldata().to_owned(); + + let tx = TransactionRequest::default() + .from(wallets[1].address()) + .to(*contract.address()) + .with_input(calldata); + + let traces = handle + .http_provider() + .debug_trace_call(tx, BlockNumberOrTag::Latest, GethDebugTracingCallOptions::default()) .await .unwrap(); + match traces { - GethTrace::Known(traces) => match traces { - GethTraceFrame::Default(traces) => { - assert!(!traces.failed); - } - _ => { - unreachable!() - } - }, - GethTrace::Unknown(_) => { + GethTrace::Default(default_frame) => { + assert!(!default_frame.failed); + } + _ => { unreachable!() } } @@ -167,21 +137,26 @@ contract Contract { #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15291050u64))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let input = hex::decode("43bcfab60000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000e0bd811c8769a824b00000000000000000000000000000000000000000000000e0ae9925047d8440b60000000000000000000000002e4777139254ff76db957e284b186a4507ff8c67").unwrap(); let from: Address = "0x2e4777139254ff76db957e284b186a4507ff8c67".parse().unwrap(); let to: Address = "0xe2f2a5c287993345a840db3b0845fbc70f5935a5".parse().unwrap(); - let tx = TransactionRequest::new().to(to).from(from).data(input).gas(300_000); + let tx = TransactionRequest::default() + .to(to) + .from(from) + .with_input::(input.into()) + .with_gas_limit(300_000); - api.anvil_impersonate_account(from.to_alloy()).await.unwrap(); + let tx = WithOtherFields::new(tx); + api.anvil_impersonate_account(from).await.unwrap(); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let traces = provider.trace_transaction(tx.transaction_hash).await.unwrap(); assert!(!traces.is_empty()); - match traces[0].action { + match traces[0].trace.action { Action::Call(ref call) => { assert_eq!(call.from, from); assert_eq!(call.to, to); @@ -339,13 +314,13 @@ async fn test_trace_address_fork() { } ]); - let expected_traces: Vec = serde_json::from_value(json).unwrap(); + let expected_traces: Vec = serde_json::from_value(json).unwrap(); // test matching traceAddress traces.into_iter().zip(expected_traces).for_each(|(a, b)| { - assert_eq!(a.trace_address, b.trace_address); - assert_eq!(a.subtraces, b.subtraces); - match (a.action, b.action) { + assert_eq!(a.trace.trace_address, b.trace.trace_address); + assert_eq!(a.trace.subtraces, b.trace.subtraces); + match (a.trace.action, b.trace.action) { (Action::Call(a), Action::Call(b)) => { assert_eq!(a.from, b.from); assert_eq!(a.to, b.to); @@ -360,23 +335,29 @@ async fn test_trace_address_fork() { #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork2() { let (api, handle) = spawn(fork_config().with_fork_block_number(Some(15314401u64))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let input = hex::decode("30000003000000000000000000000000adda1059a6c6c102b0fa562b9bb2cb9a0de5b1f4000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a300000004fffffffffffffffffffffffffffffffffffffffffffff679dc91ecfe150fb980c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f4d2888d29d722226fafa5d9b24f9164c092421e000bb8000000000000004319b52bf08b65295d49117e790000000000000000000000000000000000000000000000008b6d9e8818d6141f000000000000000000000000000000000000000000000000000000086a23af210000000000000000000000000000000000000000000000000000000000").unwrap(); let from: Address = "0xa009fa1ac416ec02f6f902a3a4a584b092ae6123".parse().unwrap(); let to: Address = "0x99999999d116ffa7d76590de2f427d8e15aeb0b8".parse().unwrap(); - let tx = TransactionRequest::new().to(to).from(from).data(input).gas(350_000); + let tx = TransactionRequest::default() + .to(to) + .from(from) + .with_input::(input.into()) + .with_gas_limit(350_000); - api.anvil_impersonate_account(from.to_alloy()).await.unwrap(); + let tx = WithOtherFields::new(tx); + api.anvil_impersonate_account(from).await.unwrap(); - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); - assert_eq!(tx.status, Some(1u64.into())); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + let status = tx.inner.inner.inner.receipt.status; + assert!(status); let traces = provider.trace_transaction(tx.transaction_hash).await.unwrap(); assert!(!traces.is_empty()); - match traces[0].action { + match traces[0].trace.action { Action::Call(ref call) => { assert_eq!(call.from, from); assert_eq!(call.to, to); @@ -597,13 +578,13 @@ async fn test_trace_address_fork2() { } ]); - let expected_traces: Vec = serde_json::from_value(json).unwrap(); + let expected_traces: Vec = serde_json::from_value(json).unwrap(); // test matching traceAddress traces.into_iter().zip(expected_traces).for_each(|(a, b)| { - assert_eq!(a.trace_address, b.trace_address); - assert_eq!(a.subtraces, b.subtraces); - match (a.action, b.action) { + assert_eq!(a.trace.trace_address, b.trace.trace_address); + assert_eq!(a.trace.subtraces, b.trace.subtraces); + match (a.trace.action, b.trace.action) { (Action::Call(a), Action::Call(b)) => { assert_eq!(a.from, b.from); assert_eq!(a.to, b.to); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 6dfae6a8d2a7a..7e088e0b5cc79 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -1,137 +1,140 @@ use crate::{ - abi::*, - utils::{ethers_http_provider, ethers_ws_provider}, + abi::{Greeter, MulticallContract, SimpleStorage}, + utils::http_provider_with_signer, }; -use alloy_primitives::{Bytes, U256 as rU256}; +use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_primitives::{Address, Bytes, FixedBytes, U256}; +use alloy_provider::Provider; use alloy_rpc_types::{ - request::TransactionRequest as AlloyTransactionRequest, state::{AccountOverride, StateOverride}, - BlockNumberOrTag, WithOtherFields, + AccessList, AccessListItem, BlockId, BlockNumberOrTag, BlockTransactions, TransactionRequest, + WithOtherFields, }; use anvil::{spawn, Hardfork, NodeConfig}; -use ethers::{ - abi::ethereum_types::BigEndianHash, - prelude::{ - signer::SignerMiddlewareError, BlockId, Middleware, Signer, SignerMiddleware, - TransactionRequest, - }, - types::{ - transaction::eip2930::{AccessList, AccessListItem}, - Address, BlockNumber, Transaction, TransactionReceipt, H256, U256, - }, -}; -use foundry_common::types::{ToAlloy, ToEthers}; +use eyre::Ok; use futures::{future::join_all, FutureExt, StreamExt}; -use std::{collections::HashSet, sync::Arc, time::Duration}; +use std::{collections::HashSet, str::FromStr, time::Duration}; use tokio::time::timeout; #[tokio::test(flavor = "multi_thread")] async fn can_transfer_eth() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); - assert!(nonce.is_zero()); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + assert!(nonce == 0); - let balance_before = provider.get_balance(to, None).await.unwrap(); + let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); // craft the tx // specify the `from` field so that the client knows which account to use - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); - + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); // broadcast it via the eth_sendTransaction API - let tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = provider.send_transaction(tx).await.unwrap(); + + let tx = tx.get_receipt().await.unwrap(); - assert_eq!(tx.block_number, Some(1u64.into())); - assert_eq!(tx.transaction_index, 0u64.into()); + assert_eq!(tx.block_number, Some(1)); + assert_eq!(tx.transaction_index, Some(0)); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); - assert_eq!(nonce, 1u64.into()); + assert_eq!(nonce, 1); - let to_balance = provider.get_balance(to, None).await.unwrap(); + let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); - assert_eq!(balance_before.saturating_add(amount.to_ethers()), to_balance); + assert_eq!(balance_before.saturating_add(amount), to_balance); } #[tokio::test(flavor = "multi_thread")] async fn can_order_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); // disable automine api.anvil_set_auto_mine(false).await.unwrap(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); // craft the tx with lower price - let tx = - TransactionRequest::new().to(to).from(from).value(amount.to_ethers()).gas_price(gas_price); - let tx_lower = provider.send_transaction(tx, None).await.unwrap(); + let mut tx = TransactionRequest::default().to(to).from(from).value(amount); + + tx.set_gas_price(gas_price); + let tx = WithOtherFields::new(tx); + let tx_lower = provider.send_transaction(tx).await.unwrap(); // craft the tx with higher price - let tx = TransactionRequest::new() - .to(from) - .from(to) - .value(amount.to_ethers()) - .gas_price(gas_price + 1); - let tx_higher = provider.send_transaction(tx, None).await.unwrap(); + let mut tx = TransactionRequest::default().to(from).from(to).value(amount); + + tx.set_gas_price(gas_price + 1); + let tx = WithOtherFields::new(tx); + let tx_higher = provider.send_transaction(tx).await.unwrap(); // manually mine the block with the transactions api.mine_one().await; + let higher_price = tx_higher.get_receipt().await.unwrap().transaction_hash; + let lower_price = tx_lower.get_receipt().await.unwrap().transaction_hash; + // get the block, await receipts - let block = provider.get_block(BlockNumber::Latest).await.unwrap().unwrap(); - let lower_price = tx_lower.await.unwrap().unwrap().transaction_hash; - let higher_price = tx_higher.await.unwrap().unwrap().transaction_hash; - assert_eq!(block.transactions, vec![higher_price, lower_price]) + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + + assert_eq!(block.transactions, BlockTransactions::Hashes(vec![higher_price, lower_price])) } #[tokio::test(flavor = "multi_thread")] async fn can_respect_nonces() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); + let tx = TransactionRequest::default().to(to).value(amount).from(from).nonce(nonce + 1); + + let tx = WithOtherFields::new(tx); // send the transaction with higher nonce than on chain - let higher_pending_tx = - provider.send_transaction(tx.clone().nonce(nonce + 1u64), None).await.unwrap(); + let higher_pending_tx = provider.send_transaction(tx).await.unwrap(); // ensure the listener for ready transactions times out let mut listener = api.new_ready_transactions(); let res = timeout(Duration::from_millis(1500), listener.next()).await; res.unwrap_err(); + let tx = TransactionRequest::default().to(to).value(amount).from(from).nonce(nonce); + + let tx = WithOtherFields::new(tx); // send with the actual nonce which is mined immediately - let tx = - provider.send_transaction(tx.nonce(nonce), None).await.unwrap().await.unwrap().unwrap(); + let tx = provider.send_transaction(tx).await.unwrap(); + let tx = tx.get_receipt().await.unwrap(); // this will unblock the currently pending tx - let higher_tx = higher_pending_tx.await.unwrap().unwrap(); + let higher_tx = higher_pending_tx.get_receipt().await.unwrap(); // Awaits endlessly here due to alloy/#389 - let block = provider.get_block(1u64).await.unwrap().unwrap(); + let block = provider.get_block(1.into(), false).await.unwrap().unwrap(); assert_eq!(2, block.transactions.len()); - assert_eq!(vec![tx.transaction_hash, higher_tx.transaction_hash], block.transactions); + assert_eq!( + BlockTransactions::Hashes(vec![tx.transaction_hash, higher_tx.transaction_hash]), + block.transactions + ); } #[tokio::test(flavor = "multi_thread")] @@ -141,72 +144,87 @@ async fn can_replace_transaction() { // disable auto mining api.anvil_set_auto_mine(false).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); + + let tx = TransactionRequest::default().to(to).value(amount).from(from).nonce(nonce); - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from).nonce(nonce); + let mut tx = WithOtherFields::new(tx); + tx.set_gas_price(gas_price); // send transaction with lower gas price - let lower_priced_pending_tx = - provider.send_transaction(tx.clone().gas_price(gas_price), None).await.unwrap(); + let _lower_priced_pending_tx = provider.send_transaction(tx.clone()).await.unwrap(); + tx.set_gas_price(gas_price + 1); // send the same transaction with higher gas price - let higher_priced_pending_tx = - provider.send_transaction(tx.gas_price(gas_price + 1u64), None).await.unwrap(); + let higher_priced_pending_tx = provider.send_transaction(tx).await.unwrap(); + let higher_tx_hash = *higher_priced_pending_tx.tx_hash(); // mine exactly one block api.mine_one().await; - // lower priced transaction was replaced - let lower_priced_receipt = lower_priced_pending_tx.await.unwrap(); - assert!(lower_priced_receipt.is_none()); + let block = provider.get_block(1.into(), false).await.unwrap().unwrap(); - let higher_priced_receipt = higher_priced_pending_tx.await.unwrap().unwrap(); + assert_eq!(block.transactions.len(), 1); + assert_eq!(BlockTransactions::Hashes(vec![higher_tx_hash]), block.transactions); - // ensure that only the replacement tx was mined - let block = provider.get_block(1u64).await.unwrap().unwrap(); - assert_eq!(1, block.transactions.len()); - assert_eq!(vec![higher_priced_receipt.transaction_hash], block.transactions); + // FIXME: Unable to get receipt despite hotfix in https://github.com/alloy-rs/alloy/pull/614 + + // lower priced transaction was replaced + // let _lower_priced_receipt = lower_priced_pending_tx.get_receipt().await.unwrap(); + // let higher_priced_receipt = higher_priced_pending_tx.get_receipt().await.unwrap(); + + // assert_eq!(1, block.transactions.len()); + // assert_eq!( + // BlockTransactions::Hashes(vec![higher_priced_receipt.transaction_hash]), + // block.transactions + // ); } #[tokio::test(flavor = "multi_thread")] async fn can_reject_too_high_gas_limits() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let gas_limit = api.gas_limit(); - let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); + let gas_limit = api.gas_limit().to::(); + let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); + + let tx = + TransactionRequest::default().to(to).value(amount).from(from).with_gas_limit(gas_limit); - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); + let mut tx = WithOtherFields::new(tx); // send transaction with the exact gas limit - let pending = provider.send_transaction(tx.clone().gas(gas_limit.to_ethers()), None).await; + let pending = provider.send_transaction(tx.clone()).await.unwrap(); - pending.unwrap(); + let pending_receipt = pending.get_receipt().await; + assert!(pending_receipt.is_ok()); + + tx.set_gas_limit(gas_limit + 1); // send transaction with higher gas limit - let pending = - provider.send_transaction(tx.clone().gas(gas_limit.to_ethers() + 1u64), None).await; + let pending = provider.send_transaction(tx.clone()).await; assert!(pending.is_err()); let err = pending.unwrap_err(); assert!(err.to_string().contains("gas too high")); - api.anvil_set_balance(from.to_alloy(), U256::MAX.to_alloy()).await.unwrap(); + api.anvil_set_balance(from, U256::MAX).await.unwrap(); - let pending = provider.send_transaction(tx.gas(gas_limit.to_ethers()), None).await; - pending.unwrap(); + tx.set_gas_limit(gas_limit); + let pending = provider.send_transaction(tx).await; + let _ = pending.unwrap(); } #[tokio::test(flavor = "multi_thread")] @@ -216,61 +234,65 @@ async fn can_reject_underpriced_replacement() { // disable auto mining api.anvil_set_auto_mine(false).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let amount = handle.genesis_balance().checked_div(rU256::from(3u64)).unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); + + let tx = TransactionRequest::default().to(to).value(amount).from(from).nonce(nonce); - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from).nonce(nonce); + let mut tx = WithOtherFields::new(tx); + tx.set_gas_price(gas_price + 1); // send transaction with higher gas price - let higher_priced_pending_tx = - provider.send_transaction(tx.clone().gas_price(gas_price + 1u64), None).await.unwrap(); + let higher_priced_pending_tx = provider.send_transaction(tx.clone()).await.unwrap(); + tx.set_gas_price(gas_price); // send the same transaction with lower gas price - let lower_priced_pending_tx = provider.send_transaction(tx.gas_price(gas_price), None).await; + let lower_priced_pending_tx = provider.send_transaction(tx).await; let replacement_err = lower_priced_pending_tx.unwrap_err(); assert!(replacement_err.to_string().contains("replacement transaction underpriced")); // mine exactly one block api.mine_one().await; - let higher_priced_receipt = higher_priced_pending_tx.await.unwrap().unwrap(); + let higher_priced_receipt = higher_priced_pending_tx.get_receipt().await.unwrap(); // ensure that only the higher priced tx was mined - let block = provider.get_block(1u64).await.unwrap().unwrap(); + let block = provider.get_block(1.into(), false).await.unwrap().unwrap(); assert_eq!(1, block.transactions.len()); - assert_eq!(vec![higher_priced_receipt.transaction_hash], block.transactions); + assert_eq!( + BlockTransactions::Hashes(vec![higher_priced_receipt.transaction_hash]), + block.transactions + ); } #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_http() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let wallet = handle.dev_wallets().next().unwrap(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let signer: EthereumSigner = wallet.clone().into(); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .legacy() - .send() - .await - .unwrap(); + let alloy_provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + let alloy_greeter_addr = + Greeter::deploy_builder(alloy_provider.clone(), "Hello World!".to_string()) + // .legacy() unimplemented! in alloy + .deploy() + .await + .unwrap(); - let greeter_contract = - Greeter::deploy(client, "Hello World!".to_string()).unwrap().send().await.unwrap(); + let alloy_greeter = Greeter::new(alloy_greeter_addr, alloy_provider); - let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + let greeting = alloy_greeter.greet().call().await.unwrap(); + + assert_eq!("Hello World!", greeting._0); } #[tokio::test(flavor = "multi_thread")] @@ -284,285 +306,302 @@ async fn can_deploy_and_mine_manually() { // can mine in manual mode api.evm_mine(None).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); + + let wallet = handle.dev_wallets().next().unwrap(); + let from = wallet.address(); + + let greeter_builder = + Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()).from(from); + let greeter_calldata = greeter_builder.calldata(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let tx = TransactionRequest::default().from(from).with_input(greeter_calldata.to_owned()); - let tx = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()).unwrap().deployer.tx; + let tx = WithOtherFields::new(tx); - let tx = client.send_transaction(tx, None).await.unwrap(); + let tx = provider.send_transaction(tx).await.unwrap(); // mine block with tx manually api.evm_mine(None).await.unwrap(); - let receipt = tx.await.unwrap().unwrap(); + let receipt = tx.get_receipt().await.unwrap(); let address = receipt.contract_address.unwrap(); - let greeter_contract = Greeter::new(address, Arc::clone(&client)); + let greeter_contract = Greeter::new(address, provider); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); - let set_greeting = greeter_contract.set_greeting("Another Message".to_string()); + let set_greeting = greeter_contract.setGreeting("Another Message".to_string()); let tx = set_greeting.send().await.unwrap(); // mine block manually api.evm_mine(None).await.unwrap(); - let _tx = tx.await.unwrap(); + let _tx = tx.get_receipt().await.unwrap(); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Another Message", greeting); + assert_eq!("Another Message", greeting._0); } #[tokio::test(flavor = "multi_thread")] async fn can_mine_automatically() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + + let greeter_builder = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()) + .from(wallet.address()); + + let greeter_calldata = greeter_builder.calldata(); + + let tx = TransactionRequest::default() + .from(wallet.address()) + .with_input(greeter_calldata.to_owned()); + + let tx = WithOtherFields::new(tx); - let tx = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()).unwrap().deployer.tx; - let sent_tx = client.send_transaction(tx, None).await.unwrap(); + let sent_tx = provider.send_transaction(tx).await.unwrap(); // re-enable auto mine api.anvil_set_auto_mine(true).await.unwrap(); - let receipt = sent_tx.await.unwrap().unwrap(); - assert_eq!(receipt.status.unwrap().as_u64(), 1u64); + let receipt = sent_tx.get_receipt().await.unwrap(); + assert_eq!(receipt.block_number, Some(1)); } #[tokio::test(flavor = "multi_thread")] async fn can_call_greeter_historic() { - let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .send() + let greeter_addr = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()) + .from(wallet.address()) + .deploy() .await .unwrap(); + let greeter_contract = Greeter::new(greeter_addr, provider.clone()); + let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); - let block = client.get_block_number().await.unwrap(); + let block_number = provider.get_block_number().await.unwrap(); + + let _ = greeter_contract.setGreeting("Another Message".to_string()).send().await.unwrap(); - greeter_contract - .set_greeting("Another Message".to_string()) - .send() - .await - .unwrap() - .await - .unwrap(); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Another Message", greeting); + assert_eq!("Another Message", greeting._0); + + // min + api.mine_one().await; // returns previous state let greeting = - greeter_contract.greet().block(BlockId::Number(block.into())).call().await.unwrap(); - assert_eq!("Hello World!", greeting); + greeter_contract.greet().block(BlockId::Number(block_number.into())).call().await.unwrap(); + assert_eq!("Hello World!", greeting._0); } #[tokio::test(flavor = "multi_thread")] async fn can_deploy_greeter_ws() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = handle.ws_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .legacy() - .send() + let greeter_addr = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()) + .from(wallet.address()) + // .legacy() unimplemented! in alloy + .deploy() .await .unwrap(); - let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); - - let greeter_contract = - Greeter::deploy(client, "Hello World!".to_string()).unwrap().send().await.unwrap(); + let greeter_contract = Greeter::new(greeter_addr, provider.clone()); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); } #[tokio::test(flavor = "multi_thread")] async fn can_deploy_get_code() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = handle.ws_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .legacy() - .send() + let greeter_addr = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()) + .from(wallet.address()) + .deploy() .await .unwrap(); - let code = client.get_code(greeter_contract.address(), None).await.unwrap(); + let code = provider.get_code_at(greeter_addr, BlockId::latest()).await.unwrap(); assert!(!code.as_ref().is_empty()); } #[tokio::test(flavor = "multi_thread")] async fn get_blocktimestamp_works() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); - - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let provider = handle.http_provider(); - let contract = - MulticallContract::deploy(Arc::clone(&client), ()).unwrap().send().await.unwrap(); + let contract = MulticallContract::deploy(provider.clone()).await.unwrap(); - let timestamp = contract.get_current_block_timestamp().call().await.unwrap(); + let timestamp = contract.getCurrentBlockTimestamp().call().await.unwrap().timestamp; - assert!(timestamp > U256::one()); + assert!(timestamp > U256::from(1)); let latest_block = api.block_by_number(alloy_rpc_types::BlockNumberOrTag::Latest).await.unwrap().unwrap(); - let timestamp = contract.get_current_block_timestamp().call().await.unwrap(); - assert_eq!(timestamp.as_u64(), latest_block.header.timestamp); + let timestamp = contract.getCurrentBlockTimestamp().call().await.unwrap().timestamp; + assert_eq!(timestamp.to::(), latest_block.header.timestamp); // repeat call same result - let timestamp = contract.get_current_block_timestamp().call().await.unwrap(); - assert_eq!(timestamp.as_u64(), latest_block.header.timestamp); + let timestamp = contract.getCurrentBlockTimestamp().call().await.unwrap().timestamp; + assert_eq!(timestamp.to::(), latest_block.header.timestamp); // mock timestamp - let next_timestamp = timestamp.as_u64() + 1337; + let next_timestamp = timestamp.to::() + 1337; api.evm_set_next_block_timestamp(next_timestamp).unwrap(); - let timestamp = - contract.get_current_block_timestamp().block(BlockNumber::Pending).call().await.unwrap(); - assert_eq!(timestamp, next_timestamp.into()); + let timestamp = contract + .getCurrentBlockTimestamp() + .block(BlockId::pending()) + .call() + .await + .unwrap() + .timestamp; + assert_eq!(timestamp, U256::from(next_timestamp)); // repeat call same result - let timestamp = - contract.get_current_block_timestamp().block(BlockNumber::Pending).call().await.unwrap(); - assert_eq!(timestamp, next_timestamp.into()); + let timestamp = contract + .getCurrentBlockTimestamp() + .block(BlockId::pending()) + .call() + .await + .unwrap() + .timestamp; + assert_eq!(timestamp, U256::from(next_timestamp)); } #[tokio::test(flavor = "multi_thread")] async fn call_past_state() { - let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + let contract_addr = + SimpleStorage::deploy_builder(provider.clone(), "initial value".to_string()) + .from(wallet.address()) + .deploy() + .await + .unwrap(); - let contract = SimpleStorage::deploy(Arc::clone(&client), "initial value".to_string()) - .unwrap() - .send() - .await - .unwrap(); + let contract = SimpleStorage::new(contract_addr, provider.clone()); - let deployed_block = client.get_block_number().await.unwrap(); + let deployed_block = provider.get_block_number().await.unwrap(); - // assert initial state - let value = contract.method::<_, String>("getValue", ()).unwrap().call().await.unwrap(); - assert_eq!(value, "initial value"); + let value = contract.getValue().call().await.unwrap(); + assert_eq!(value._0, "initial value"); - // make a call with `client` - let _tx_hash = contract - .method::<_, H256>("setValue", "hi".to_owned()) - .unwrap() - .send() - .await - .unwrap() - .await - .unwrap() - .unwrap(); + let gas_price = api.gas_price().unwrap().to::(); + let set_tx = contract.setValue("hi".to_string()).gas_price(gas_price + 1); + + let _set_tx = set_tx.send().await.unwrap().get_receipt().await.unwrap(); // assert new value - let value = contract.method::<_, String>("getValue", ()).unwrap().call().await.unwrap(); - assert_eq!(value, "hi"); + let value = contract.getValue().call().await.unwrap(); + assert_eq!(value._0, "hi"); // assert previous value - let value = contract - .method::<_, String>("getValue", ()) - .unwrap() - .block(BlockId::Number(deployed_block.into())) - .call() - .await - .unwrap(); - assert_eq!(value, "initial value"); + let value = + contract.getValue().block(BlockId::Number(deployed_block.into())).call().await.unwrap(); + assert_eq!(value._0, "initial value"); - let hash = client.get_block(1).await.unwrap().unwrap().hash.unwrap(); - let value = contract - .method::<_, String>("getValue", ()) - .unwrap() - .block(BlockId::Hash(hash)) - .call() + let hash = provider + .get_block(BlockId::Number(1.into()), false) .await + .unwrap() + .unwrap() + .header + .hash .unwrap(); - assert_eq!(value, "initial value"); + let value = contract.getValue().block(BlockId::Hash(hash.into())).call().await.unwrap(); + assert_eq!(value._0, "initial value"); } #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = handle.ws_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, None).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); // explicitly set the nonce - let tx = TransactionRequest::new().to(to).value(100u64).from(from).nonce(nonce).gas(21_000u64); + let tx = TransactionRequest::default() + .to(to) + .value(U256::from(100)) + .from(from) + .nonce(nonce) + .with_gas_limit(21000u128); + + let tx = WithOtherFields::new(tx); + let mut tasks = Vec::new(); for _ in 0..10 { - let provider = provider.clone(); let tx = tx.clone(); - let task = - tokio::task::spawn(async move { provider.send_transaction(tx, None).await?.await }); + let provider = provider.clone(); + let task = tokio::task::spawn(async move { + provider.send_transaction(tx).await.unwrap().get_receipt().await + }); tasks.push(task); } // only one succeeded let successful_tx = - join_all(tasks).await.into_iter().filter(|res| res.as_ref().unwrap().is_ok()).count(); + join_all(tasks).await.into_iter().filter(|res| res.as_ref().is_ok()).count(); assert_eq!(successful_tx, 1); - assert_eq!(provider.get_transaction_count(from, None).await.unwrap(), 1u64.into()); + assert_eq!(provider.get_transaction_count(from, BlockId::latest()).await.unwrap(), 1u64); } #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = handle.ws_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - let nonce = client.get_transaction_count(from, None).await.unwrap(); - // explicitly set the nonce + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let mut tasks = Vec::new(); - let mut tx = - Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()).unwrap().deployer.tx; - tx.set_nonce(nonce); - tx.set_gas(300_000u64); + + let greeter = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()); + + let greeter_calldata = greeter.calldata(); + + let tx = TransactionRequest::default() + .from(from) + .with_input(greeter_calldata.to_owned()) + .nonce(nonce) + .with_gas_limit(300_000u128); + + let tx = WithOtherFields::new(tx); for _ in 0..10 { - let client = Arc::clone(&client); + let provider = provider.clone(); let tx = tx.clone(); let task = tokio::task::spawn(async move { - Ok::<_, SignerMiddlewareError<_, _>>( - client.send_transaction(tx, None).await?.await.unwrap(), - ) + Ok(provider.send_transaction(tx).await?.get_receipt().await.unwrap()) }); tasks.push(task); } @@ -571,51 +610,54 @@ async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { let successful_tx = join_all(tasks).await.into_iter().filter(|res| res.as_ref().unwrap().is_ok()).count(); assert_eq!(successful_tx, 1); - assert_eq!(client.get_transaction_count(from, None).await.unwrap(), 1u64.into()); + assert_eq!(provider.get_transaction_count(from, BlockId::latest()).await.unwrap(), 1u64); } #[tokio::test(flavor = "multi_thread")] async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_ws_provider(&handle.ws_endpoint()); + let provider = handle.ws_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .send() - .await - .unwrap(); + let greeter_contract = + Greeter::deploy(provider.clone(), "Hello World!".to_string()).await.unwrap(); + + let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); - let nonce = client.get_transaction_count(from, None).await.unwrap(); - // explicitly set the nonce let mut tasks = Vec::new(); - let mut deploy_tx = - Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()).unwrap().deployer.tx; - deploy_tx.set_nonce(nonce); - deploy_tx.set_gas(300_000u64); - let mut set_greeting_tx = greeter_contract.set_greeting("Hello".to_string()).tx; - set_greeting_tx.set_nonce(nonce); - set_greeting_tx.set_gas(300_000u64); + let deploy = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()); + let deploy_calldata = deploy.calldata(); + let deploy_tx = TransactionRequest::default() + .from(from) + .with_input(deploy_calldata.to_owned()) + .nonce(nonce) + .with_gas_limit(300_000u128); + let deploy_tx = WithOtherFields::new(deploy_tx); + + let set_greeting = greeter_contract.setGreeting("Hello".to_string()); + let set_greeting_calldata = set_greeting.calldata(); + + let set_greeting_tx = TransactionRequest::default() + .from(from) + .with_input(set_greeting_calldata.to_owned()) + .nonce(nonce) + .with_gas_limit(300_000u128); + let set_greeting_tx = WithOtherFields::new(set_greeting_tx); for idx in 0..10 { - let client = Arc::clone(&client); + let provider = provider.clone(); let task = if idx % 2 == 0 { let tx = deploy_tx.clone(); tokio::task::spawn(async move { - Ok::<_, SignerMiddlewareError<_, _>>( - client.send_transaction(tx, None).await?.await.unwrap(), - ) + Ok(provider.send_transaction(tx).await?.get_receipt().await.unwrap()) }) } else { let tx = set_greeting_tx.clone(); tokio::task::spawn(async move { - Ok::<_, SignerMiddlewareError<_, _>>( - client.send_transaction(tx, None).await?.await.unwrap(), - ) + Ok(provider.send_transaction(tx).await?.get_receipt().await.unwrap()) }) }; @@ -626,9 +668,8 @@ async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { let successful_tx = join_all(tasks).await.into_iter().filter(|res| res.as_ref().unwrap().is_ok()).count(); assert_eq!(successful_tx, 1); - assert_eq!(client.get_transaction_count(from, None).await.unwrap(), nonce + 1); + assert_eq!(provider.get_transaction_count(from, BlockId::latest()).await.unwrap(), nonce + 1); } - #[tokio::test(flavor = "multi_thread")] async fn can_get_pending_transaction() { let (api, handle) = spawn(NodeConfig::test()).await; @@ -636,17 +677,18 @@ async fn can_get_pending_transaction() { // disable auto mining so we can check if we can return pending tx from the mempool api.anvil_set_auto_mine(false).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let from = handle.dev_wallets().next().unwrap().address(); - let tx = TransactionRequest::new().from(from.to_ethers()).value(1337u64).to(Address::random()); - let tx = provider.send_transaction(tx, None).await.unwrap(); + let tx = TransactionRequest::default().from(from).value(U256::from(1337)).to(Address::random()); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap(); - let pending = provider.get_transaction(tx.tx_hash()).await.unwrap(); - assert!(pending.is_some()); + let pending = provider.get_transaction_by_hash(*tx.tx_hash()).await; + assert!(pending.is_ok()); api.mine_one().await; - let mined = provider.get_transaction(tx.tx_hash()).await.unwrap().unwrap(); + let mined = provider.get_transaction_by_hash(*tx.tx_hash()).await.unwrap(); assert_eq!(mined.hash, pending.unwrap().hash); } @@ -657,15 +699,12 @@ async fn test_first_noce_is_zero() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let from = handle.dev_wallets().next().unwrap().address(); - let nonce = provider - .get_transaction_count(from.to_ethers(), Some(BlockId::Number(BlockNumber::Pending))) - .await - .unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::pending()).await.unwrap(); - assert_eq!(nonce, U256::zero()); + assert_eq!(nonce, 0); } #[tokio::test(flavor = "multi_thread")] @@ -674,8 +713,8 @@ async fn can_handle_different_sender_nonce_calculation() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let provider = handle.http_provider(); + let accounts = handle.dev_wallets().collect::>(); let from_first = accounts[0].address(); let from_second = accounts[1].address(); @@ -683,23 +722,25 @@ async fn can_handle_different_sender_nonce_calculation() { // send a bunch of tx to the mempool and check nonce is returned correctly for idx in 1..=tx_count { - let tx_from_first = - TransactionRequest::new().from(from_first).value(1337u64).to(Address::random()); - let _tx = provider.send_transaction(tx_from_first, None).await.unwrap(); - let nonce_from_first = provider - .get_transaction_count(from_first, Some(BlockId::Number(BlockNumber::Pending))) - .await - .unwrap(); - assert_eq!(nonce_from_first, idx.into()); - - let tx_from_second = - TransactionRequest::new().from(from_second).value(1337u64).to(Address::random()); - let _tx = provider.send_transaction(tx_from_second, None).await.unwrap(); - let nonce_from_second = provider - .get_transaction_count(from_second, Some(BlockId::Number(BlockNumber::Pending))) - .await - .unwrap(); - assert_eq!(nonce_from_second, idx.into()); + let tx_from_first = TransactionRequest::default() + .from(from_first) + .value(U256::from(1337u64)) + .to(Address::random()); + let tx_from_first = WithOtherFields::new(tx_from_first); + let _tx = provider.send_transaction(tx_from_first).await.unwrap(); + let nonce_from_first = + provider.get_transaction_count(from_first, BlockId::pending()).await.unwrap(); + assert_eq!(nonce_from_first, idx); + + let tx_from_second = TransactionRequest::default() + .from(from_second) + .value(U256::from(1337u64)) + .to(Address::random()); + let tx_from_second = WithOtherFields::new(tx_from_second); + let _tx = provider.send_transaction(tx_from_second).await.unwrap(); + let nonce_from_second = + provider.get_transaction_count(from_second, BlockId::pending()).await.unwrap(); + assert_eq!(nonce_from_second, idx); } } @@ -709,7 +750,7 @@ async fn includes_pending_tx_for_transaction_count() { api.anvil_set_auto_mine(false).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let from = handle.dev_wallets().next().unwrap().address(); let tx_count = 10u64; @@ -717,55 +758,47 @@ async fn includes_pending_tx_for_transaction_count() { // send a bunch of tx to the mempool and check nonce is returned correctly for idx in 1..=tx_count { let tx = - TransactionRequest::new().from(from.to_ethers()).value(1337u64).to(Address::random()); - let _tx = provider.send_transaction(tx, None).await.unwrap(); - let nonce = provider - .get_transaction_count(from.to_ethers(), Some(BlockId::Number(BlockNumber::Pending))) - .await - .unwrap(); - assert_eq!(nonce, idx.into()); + TransactionRequest::default().from(from).value(U256::from(1337)).to(Address::random()); + let tx = WithOtherFields::new(tx); + let _tx = provider.send_transaction(tx).await.unwrap(); + let nonce = provider.get_transaction_count(from, BlockId::pending()).await.unwrap(); + assert_eq!(nonce, idx); } api.mine_one().await; - let nonce = provider - .get_transaction_count(from.to_ethers(), Some(BlockId::Number(BlockNumber::Pending))) - .await - .unwrap(); - assert_eq!(nonce, tx_count.into()); + let nonce = provider.get_transaction_count(from, BlockId::pending()).await.unwrap(); + assert_eq!(nonce, tx_count); } #[tokio::test(flavor = "multi_thread")] async fn can_get_historic_info() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let accounts = handle.dev_wallets().collect::>().to_ethers(); + let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let amount = handle.genesis_balance().checked_div(rU256::from(2u64)).unwrap(); - let tx = TransactionRequest::new().to(to).value(amount.to_ethers()).from(from); - let _tx = provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); + let tx = TransactionRequest::default().to(to).value(amount).from(from); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap(); + let _ = tx.get_receipt().await.unwrap(); - let nonce_pre = provider - .get_transaction_count(from, Some(BlockNumber::Number(0.into()).into())) - .await - .unwrap(); + let nonce_pre = provider.get_transaction_count(from, BlockId::Number(0.into())).await.unwrap(); - let nonce_post = - provider.get_transaction_count(from, Some(BlockNumber::Latest.into())).await.unwrap(); + let nonce_post = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); assert!(nonce_pre < nonce_post); - let balance_pre = - provider.get_balance(from, Some(BlockNumber::Number(0.into()).into())).await.unwrap(); + let balance_pre = provider.get_balance(from, BlockId::Number(0.into())).await.unwrap(); - let balance_post = provider.get_balance(from, Some(BlockNumber::Latest.into())).await.unwrap(); + let balance_post = provider.get_balance(from, BlockId::latest()).await.unwrap(); assert!(balance_post < balance_pre); - let to_balance = provider.get_balance(to, None).await.unwrap(); - assert_eq!(balance_pre.saturating_add(amount.to_ethers()), to_balance); + let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + assert_eq!(balance_pre.saturating_add(amount), to_balance); } // @@ -773,55 +806,78 @@ async fn can_get_historic_info() { async fn test_tx_receipt() { let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = - Arc::new(SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallet)); + let wallet = handle.dev_wallets().next().unwrap(); + let provider = handle.http_provider(); - let tx = TransactionRequest::new().to(Address::random()).value(1337u64); + let tx = TransactionRequest::default().to(Address::random()).value(U256::from(1337)); - let tx = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); assert!(tx.to.is_some()); - let tx = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()).unwrap().deployer.tx; + let greeter_deploy = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()); + let greeter_calldata = greeter_deploy.calldata(); - let tx = client.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap(); + let tx = TransactionRequest::default() + .from(wallet.address()) + .with_input(greeter_calldata.to_owned()); + + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); // `to` field is none if it's a contract creation transaction: https://eth.wiki/json-rpc/API#eth_getTransactionReceipt assert!(tx.to.is_none()); assert!(tx.contract_address.is_some()); } +// TODO: Fix error: ErrorPayload { code: -32602, message: "invalid type: boolean `true`, expected +// unit", data: None } originating from watch_full_pending_transactions, remove ignore +#[ignore] #[tokio::test(flavor = "multi_thread")] async fn can_stream_pending_transactions() { let (_api, handle) = spawn(NodeConfig::test().with_blocktime(Some(Duration::from_secs(2)))).await; let num_txs = 5; - let provider = ethers_http_provider(&handle.http_endpoint()); - let ws_provider = ethers_ws_provider(&handle.ws_endpoint()); + + let provider = handle.http_provider(); + let ws_provider = handle.ws_provider(); let accounts = provider.get_accounts().await.unwrap(); - let tx = TransactionRequest::new().from(accounts[0]).to(accounts[0]).value(1e18 as u64); + let tx = + TransactionRequest::default().from(accounts[0]).to(accounts[0]).value(U256::from(1e18)); let mut sending = futures::future::join_all( std::iter::repeat(tx.clone()) .take(num_txs) .enumerate() - .map(|(nonce, tx)| tx.nonce(nonce)) + .map(|(nonce, tx)| tx.nonce(nonce as u64)) .map(|tx| async { - provider.send_transaction(tx, None).await.unwrap().await.unwrap().unwrap() + let tx = WithOtherFields::new(tx); + provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap() }), ) .fuse(); - let mut watch_tx_stream = - provider.watch_pending_transactions().await.unwrap().transactions_unordered(num_txs).fuse(); - - let mut sub_tx_stream = - ws_provider.subscribe_pending_txs().await.unwrap().transactions_unordered(2).fuse(); + let mut watch_tx_stream = provider + .watch_full_pending_transactions() + .await + .unwrap() // TODO: Fix error here + .into_stream() + .flat_map(futures::stream::iter) + .take(num_txs) + .fuse(); + + let mut sub_tx_stream = ws_provider + .subscribe_full_pending_transactions() + .await + .unwrap() + .into_stream() + .take(2) + .fuse(); - let mut sent: Option> = None; - let mut watch_received: Vec = Vec::with_capacity(num_txs); - let mut sub_received: Vec = Vec::with_capacity(num_txs); + let mut sent = None; + let mut watch_received = Vec::with_capacity(num_txs); + let mut sub_received = Vec::with_capacity(num_txs); loop { futures::select! { @@ -829,12 +885,17 @@ async fn can_stream_pending_transactions() { sent = Some(txs) }, tx = watch_tx_stream.next() => { - watch_received.push(tx.unwrap().unwrap()); + if let Some(tx) = tx { + watch_received.push(tx); + } }, tx = sub_tx_stream.next() => { - sub_received.push(tx.unwrap().unwrap()); + if let Some(tx) = tx { + sub_received.push(tx); + } }, }; + if watch_received.len() == num_txs && sub_received.len() == num_txs { if let Some(ref sent) = sent { assert_eq!(sent.len(), watch_received.len()); @@ -879,39 +940,51 @@ async fn test_tx_access_list() { // - The sender shouldn't be in the AL let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = - Arc::new(SignerMiddleware::new(ethers_http_provider(&handle.http_endpoint()), wallet)); + let provider = handle.http_provider(); let sender = Address::random(); let other_acc = Address::random(); - let multicall = MulticallContract::deploy(client.clone(), ()).unwrap().send().await.unwrap(); - let simple_storage = - SimpleStorage::deploy(client.clone(), "foo".to_string()).unwrap().send().await.unwrap(); + let multicall = MulticallContract::deploy(provider.clone()).await.unwrap(); + let simple_storage = SimpleStorage::deploy(provider.clone(), "foo".to_string()).await.unwrap(); // when calling `setValue` on SimpleStorage, both the `lastSender` and `_value` storages are // modified The `_value` is a `string`, so the storage slots here (small string) are `0x1` // and `keccak(0x1)` - let set_value_tx = simple_storage.set_value("bar".to_string()).from(sender).tx; - let access_list = client.create_access_list(&set_value_tx, None).await.unwrap(); + let set_value = simple_storage.setValue("bar".to_string()); + let set_value_calldata = set_value.calldata(); + let set_value_tx = TransactionRequest::default() + .from(sender) + .to(*simple_storage.address()) + .with_input(set_value_calldata.to_owned()); + let set_value_tx = WithOtherFields::new(set_value_tx); + let access_list = provider.create_access_list(&set_value_tx, BlockId::latest()).await.unwrap(); + // let set_value_tx = simple_storage.set_value("bar".to_string()).from(sender).tx; + // let access_list = client.create_access_list(&set_value_tx, None).await.unwrap(); assert_access_list_eq( access_list.access_list, AccessList::from(vec![AccessListItem { - address: simple_storage.address(), + address: *simple_storage.address(), storage_keys: vec![ - H256::zero(), - H256::from_uint(&(1u64.into())), - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6" - .parse() - .unwrap(), + FixedBytes::ZERO, + FixedBytes::with_last_byte(1), + FixedBytes::from_str( + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6", + ) + .unwrap(), ], }]), ); // With a subcall that fetches the balances of an account (`other_acc`), only the address // of this account should be in the Access List - let call_tx = multicall.get_eth_balance(other_acc).from(sender).tx; - let access_list = client.create_access_list(&call_tx, None).await.unwrap(); + let call_tx = multicall.getEthBalance(other_acc); + let call_tx_data = call_tx.calldata(); + let call_tx = TransactionRequest::default() + .from(sender) + .to(*multicall.address()) + .with_input(call_tx_data.to_owned()); + let call_tx = WithOtherFields::new(call_tx); + let access_list = provider.create_access_list(&call_tx, BlockId::latest()).await.unwrap(); assert_access_list_eq( access_list.access_list, AccessList::from(vec![AccessListItem { address: other_acc, storage_keys: vec![] }]), @@ -919,24 +992,31 @@ async fn test_tx_access_list() { // With a subcall to another contract, the AccessList should be the same as when calling the // subcontract directly (given that the proxy contract doesn't read/write any state) - let subcall_tx = multicall - .aggregate(vec![Call { - target: simple_storage.address(), - call_data: set_value_tx.data().unwrap().clone(), - }]) + let subcall_tx = multicall.aggregate(vec![MulticallContract::Call { + target: *simple_storage.address(), + callData: set_value_calldata.to_owned(), + }]); + + let subcall_tx_calldata = subcall_tx.calldata(); + + let subcall_tx = TransactionRequest::default() .from(sender) - .tx; - let access_list = client.create_access_list(&subcall_tx, None).await.unwrap(); + .to(*multicall.address()) + .with_input(subcall_tx_calldata.to_owned()); + let subcall_tx = WithOtherFields::new(subcall_tx); + let access_list = provider.create_access_list(&subcall_tx, BlockId::latest()).await.unwrap(); assert_access_list_eq( access_list.access_list, + // H256::from_uint(&(1u64.into())), AccessList::from(vec![AccessListItem { - address: simple_storage.address(), + address: *simple_storage.address(), storage_keys: vec![ - H256::zero(), - H256::from_uint(&(1u64.into())), - "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6" - .parse() - .unwrap(), + FixedBytes::ZERO, + FixedBytes::with_last_byte(1), + FixedBytes::from_str( + "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6", + ) + .unwrap(), ], }]), ); @@ -950,21 +1030,21 @@ async fn estimates_gas_on_pending_by_default() { // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); let sender = wallet.address(); let recipient = Address::random(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let tx = TransactionRequest::default().from(sender).to(recipient).value(U256::from(1e18)); + let tx = WithOtherFields::new(tx); - let tx = TransactionRequest::new().from(sender).to(recipient).value(1e18 as u64); - client.send_transaction(tx, None).await.unwrap(); + let _pending = provider.send_transaction(tx).await.unwrap(); - let tx = AlloyTransactionRequest::default() - .from(recipient.to_alloy()) - .to(sender.to_alloy()) - .value(rU256::from(1e10)) + let tx = TransactionRequest::default() + .from(recipient) + .to(sender) + .value(U256::from(1e10)) .input(Bytes::from(vec![0x42]).into()); api.estimate_gas(WithOtherFields::new(tx), None, None).await.unwrap(); } @@ -973,14 +1053,14 @@ async fn estimates_gas_on_pending_by_default() { async fn test_estimate_gas() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); + let wallet = handle.dev_wallets().next().unwrap(); let sender = wallet.address(); let recipient = Address::random(); - let tx = AlloyTransactionRequest::default() - .from(recipient.to_alloy()) - .to(sender.to_alloy()) - .value(rU256::from(1e10)) + let tx = TransactionRequest::default() + .from(recipient) + .to(sender) + .value(U256::from(1e10)) .input(Bytes::from(vec![0x42]).into()); // Expect the gas estimation to fail due to insufficient funds. let error_result = api.estimate_gas(WithOtherFields::new(tx.clone()), None, None).await; @@ -994,7 +1074,7 @@ async fn test_estimate_gas() { ); // Setup state override to simulate sufficient funds for the recipient. - let addr = alloy_primitives::Address::from_slice(recipient.as_bytes()); + let addr = recipient; let account_override = AccountOverride { balance: Some(alloy_primitives::U256::from(1e18)), ..Default::default() }; let mut state_override = StateOverride::new(); @@ -1007,24 +1087,25 @@ async fn test_estimate_gas() { .expect("Failed to estimate gas with state override"); // Assert the gas estimate meets the expected minimum. - assert!(gas_estimate >= rU256::from(21000), "Gas estimate is lower than expected minimum"); + assert!(gas_estimate >= U256::from(21000), "Gas estimate is lower than expected minimum"); } #[tokio::test(flavor = "multi_thread")] async fn test_reject_gas_too_low() { let (_api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); let account = handle.dev_accounts().next().unwrap(); let gas = 21_000u64 - 1; - let tx = TransactionRequest::new() + let tx = TransactionRequest::default() .to(Address::random()) .value(U256::from(1337u64)) - .from(account.to_ethers()) - .gas(gas); + .from(account) + .with_gas_limit(gas as u128); + let tx = WithOtherFields::new(tx); - let resp = provider.send_transaction(tx, None).await; + let resp = provider.send_transaction(tx).await; let err = resp.unwrap_err().to_string(); assert!(err.contains("intrinsic gas too low")); @@ -1034,50 +1115,50 @@ async fn test_reject_gas_too_low() { #[tokio::test(flavor = "multi_thread")] async fn can_call_with_high_gas_limit() { let (_api, handle) = spawn(NodeConfig::test().with_gas_limit(Some(100_000_000))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let greeter_contract = Greeter::deploy(provider, "Hello World!".to_string()).await.unwrap(); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .send() - .await - .unwrap(); - - let greeting = greeter_contract.greet().gas(60_000_000u64).call().await.unwrap(); - assert_eq!("Hello World!", greeting); + let greeting = greeter_contract.greet().gas(60_000_000u128).call().await.unwrap(); + assert_eq!("Hello World!", greeting._0); } #[tokio::test(flavor = "multi_thread")] async fn test_reject_eip1559_pre_london() { let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); - let wallet = handle.dev_wallets().next().unwrap().to_ethers(); - let client = Arc::new(SignerMiddleware::new(provider, wallet)); + let gas_limit = api.gas_limit().to::(); + let gas_price = api.gas_price().unwrap().to::(); - let gas_limit = api.gas_limit(); - let gas_price = api.gas_price().unwrap(); - let unsupported = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .gas(gas_limit.to_ethers()) - .gas_price(gas_price.to_ethers()) - .send() - .await - .unwrap_err() - .to_string(); + let unsupported_call_builder = + Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()); + let unsupported_calldata = unsupported_call_builder.calldata(); + + let unsup_tx = TransactionRequest::default() + .from(handle.dev_accounts().next().unwrap()) + .with_input(unsupported_calldata.to_owned()) + .with_gas_limit(gas_limit) + .with_max_fee_per_gas(gas_price) + .with_max_priority_fee_per_gas(gas_price); + + let unsup_tx = WithOtherFields::new(unsup_tx); + + let unsupported = provider.send_transaction(unsup_tx).await.unwrap_err().to_string(); assert!(unsupported.contains("not supported by the current hardfork"), "{unsupported}"); - let greeter_contract = Greeter::deploy(Arc::clone(&client), "Hello World!".to_string()) - .unwrap() - .legacy() - .send() - .await - .unwrap(); + let greeter_contract_addr = + Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()) + .gas(gas_limit) + .gas_price(gas_price) + .deploy() + .await + .unwrap(); + + let greeter_contract = Greeter::new(greeter_contract_addr, provider); let greeting = greeter_contract.greet().call().await.unwrap(); - assert_eq!("Hello World!", greeting); + assert_eq!("Hello World!", greeting._0); } // https://github.com/foundry-rs/foundry/issues/6931 @@ -1088,7 +1169,7 @@ async fn can_mine_multiple_in_block() { // disable auto mine api.anvil_set_auto_mine(false).await.unwrap(); - let tx = AlloyTransactionRequest { + let tx = TransactionRequest { from: Some("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266".parse().unwrap()), ..Default::default() }; @@ -1097,7 +1178,7 @@ async fn can_mine_multiple_in_block() { let first = api.send_transaction(WithOtherFields::new(tx.clone())).await.unwrap(); let second = api.send_transaction(WithOtherFields::new(tx.clone())).await.unwrap(); - api.anvil_mine(Some(rU256::from(1)), Some(rU256::ZERO)).await.unwrap(); + api.anvil_mine(Some(U256::from(1)), Some(U256::ZERO)).await.unwrap(); let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); diff --git a/crates/anvil/tests/it/txpool.rs b/crates/anvil/tests/it/txpool.rs index 3c10a577f306a..40007447e5aa5 100644 --- a/crates/anvil/tests/it/txpool.rs +++ b/crates/anvil/tests/it/txpool.rs @@ -1,34 +1,40 @@ //! txpool related tests -use crate::utils::ethers_http_provider; +use alloy_network::TransactionBuilder; +use alloy_primitives::U256; +use alloy_provider::{txpool::TxPoolApi, Provider}; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use anvil::{spawn, NodeConfig}; -use ethers::{ - prelude::Middleware, - types::{TransactionRequest, U256}, -}; #[tokio::test(flavor = "multi_thread")] async fn geth_txpool() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = ethers_http_provider(&handle.http_endpoint()); + let provider = handle.http_provider(); + api.anvil_set_auto_mine(false).await.unwrap(); - let account = provider.get_accounts().await.unwrap()[0]; - let value: u64 = 42; - let gas_price: U256 = 221435145689u64.into(); - let tx = TransactionRequest::new().to(account).from(account).value(value).gas_price(gas_price); + let account = provider.get_accounts().await.unwrap().remove(0); + let value = U256::from(42); + let gas_price = 221435145689u128; + + let tx = TransactionRequest::default() + .with_to(account) + .with_from(account) + .with_value(value) + .with_gas_price(gas_price); + let tx = WithOtherFields::new(tx); // send a few transactions let mut txs = Vec::new(); for _ in 0..10 { - let tx_hash = provider.send_transaction(tx.clone(), None).await.unwrap(); + let tx_hash = provider.send_transaction(tx.clone()).await.unwrap(); txs.push(tx_hash); } // we gave a 20s block time, should be plenty for us to get the txpool's content let status = provider.txpool_status().await.unwrap(); - assert_eq!(status.pending.as_u64(), 10); - assert_eq!(status.queued.as_u64(), 0); + assert_eq!(status.pending, 10); + assert_eq!(status.queued, 0); let inspect = provider.txpool_inspect().await.unwrap(); assert!(inspect.queued.is_empty()); @@ -36,8 +42,8 @@ async fn geth_txpool() { for i in 0..10 { let tx_summary = summary.get(&i.to_string()).unwrap(); assert_eq!(tx_summary.gas_price, gas_price); - assert_eq!(tx_summary.value, value.into()); - assert_eq!(tx_summary.gas, 21000.into()); + assert_eq!(tx_summary.value, value); + assert_eq!(tx_summary.gas, 21000); assert_eq!(tx_summary.to.unwrap(), account); } diff --git a/crates/anvil/tests/it/utils.rs b/crates/anvil/tests/it/utils.rs index 9aa0770949dc4..066ec807c96e9 100644 --- a/crates/anvil/tests/it/utils.rs +++ b/crates/anvil/tests/it/utils.rs @@ -1,84 +1,62 @@ -use alloy_json_abi::JsonAbi; -use alloy_primitives::Bytes; -use ethers::{ - addressbook::contract, - contract::ContractInstance, - middleware::Middleware, - prelude::DeploymentTxFactory, - types::{Address, Chain}, +use alloy_network::{Ethereum, EthereumSigner}; +use foundry_common::provider::{ + get_http_provider, ProviderBuilder, RetryProvider, RetryProviderWithSigner, }; -use foundry_common::provider::ethers::{ProviderBuilder, RetryProvider}; -use std::borrow::Borrow; -/// Returns a set of various contract addresses -pub fn contract_addresses(chain: Chain) -> Vec
{ - vec![ - contract("dai").unwrap().address(chain).unwrap(), - contract("usdc").unwrap().address(chain).unwrap(), - contract("weth").unwrap().address(chain).unwrap(), - contract("uniswapV3Factory").unwrap().address(chain).unwrap(), - contract("uniswapV3SwapRouter02").unwrap().address(chain).unwrap(), - ] +pub fn http_provider(http_endpoint: &str) -> RetryProvider { + get_http_provider(http_endpoint) } -/// Builds an ethers HTTP [RetryProvider] -pub fn ethers_http_provider(http_endpoint: &str) -> RetryProvider { - ProviderBuilder::new(http_endpoint).build().expect("failed to build ethers HTTP provider") +pub fn http_provider_with_signer( + http_endpoint: &str, + signer: EthereumSigner, +) -> RetryProviderWithSigner { + ProviderBuilder::new(http_endpoint) + .build_with_signer(signer) + .expect("failed to build Alloy HTTP provider with signer") } -/// Builds an ethers ws [RetryProvider] -pub fn ethers_ws_provider(ws_endpoint: &str) -> RetryProvider { - ProviderBuilder::new(ws_endpoint).build().expect("failed to build ethers HTTP provider") +pub fn ws_provider_with_signer( + ws_endpoint: &str, + signer: EthereumSigner, +) -> RetryProviderWithSigner { + ProviderBuilder::new(ws_endpoint) + .build_with_signer(signer) + .expect("failed to build Alloy WS provider with signer") } -/// Builds an ethers ws [RetryProvider] -pub fn ethers_ipc_provider(ipc_endpoint: Option) -> Option { - ProviderBuilder::new(&ipc_endpoint?).build().ok() +pub async fn connect_pubsub(conn_str: &str) -> RootProvider { + alloy_provider::ProviderBuilder::new().on_builtin(conn_str).await.unwrap() } -/// Temporary helper trait for compatibility with ethers -pub trait ContractInstanceCompat -where - B: Borrow, - M: Middleware, -{ - fn new_compat(address: Address, abi: JsonAbi, client: B) -> Self; -} - -impl ContractInstanceCompat for ContractInstance -where - B: Borrow, - M: Middleware, -{ - fn new_compat(address: Address, abi: JsonAbi, client: B) -> Self { - let json = serde_json::to_string(&abi).unwrap(); - ContractInstance::new( - address, - serde_json::from_str::(&json).unwrap(), - client, - ) - } -} - -pub trait DeploymentTxFactoryCompat -where - B: Borrow + Clone, - M: Middleware, -{ - fn new_compat(abi: JsonAbi, bytecode: Bytes, client: B) -> Self; -} - -impl DeploymentTxFactoryCompat for DeploymentTxFactory -where - B: Borrow + Clone, - M: Middleware, -{ - fn new_compat(abi: JsonAbi, bytecode: Bytes, client: B) -> Self { - let json = serde_json::to_string(&abi).unwrap(); - DeploymentTxFactory::new( - serde_json::from_str::(&json).unwrap(), - bytecode.as_ref().to_vec().into(), - client, - ) - } +use alloy_provider::{ + fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SignerFiller}, + Identity, RootProvider, +}; +use alloy_transport::BoxTransport; +type PubsubSigner = FillProvider< + JoinFill< + JoinFill, NonceFiller>, ChainIdFiller>, + SignerFiller, + >, + RootProvider, + BoxTransport, + Ethereum, +>; +pub async fn connect_pubsub_with_signer(conn_str: &str, signer: EthereumSigner) -> PubsubSigner { + alloy_provider::ProviderBuilder::new() + .with_recommended_fillers() + .signer(signer) + .on_builtin(conn_str) + .await + .unwrap() +} + +pub async fn ipc_provider_with_signer( + ipc_endpoint: &str, + signer: EthereumSigner, +) -> RetryProviderWithSigner { + ProviderBuilder::new(ipc_endpoint) + .build_with_signer(signer) + .expect("failed to build Alloy IPC provider with signer") } diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index 58bad12ebcef6..f68b15312a673 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -1,16 +1,15 @@ //! general eth api tests with websocket provider -use alloy_eips::BlockId; +use alloy_primitives::U256; use alloy_provider::Provider; +use alloy_rpc_types::BlockId; use anvil::{spawn, NodeConfig}; -use ethers::types::U256; -use foundry_common::types::ToAlloy; #[tokio::test(flavor = "multi_thread")] async fn can_get_block_number_ws() { let (api, handle) = spawn(NodeConfig::test()).await; let block_num = api.block_number().unwrap(); - assert_eq!(block_num, U256::zero().to_alloy()); + assert_eq!(block_num, U256::ZERO); let provider = handle.ws_provider(); diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 11b304212f576..ff7457e20c973 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -15,7 +15,11 @@ name = "cast" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # lib @@ -43,7 +47,7 @@ alloy-sol-types.workspace = true alloy-chains.workspace = true ethers-core.workspace = true -ethers-contract.workspace = true +ethers-contract = { workspace = true, features = ["abigen"] } chrono.workspace = true evm-disassembler.workspace = true diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 32b4ec794e2b4..2caa54d2abc30 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,5 +1,5 @@ use alloy_network::TransactionBuilder; -use alloy_primitives::{Bytes, TxKind, U256}; +use alloy_primitives::{TxKind, U256}; use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use cast::Cast; use clap::Parser; @@ -226,7 +226,7 @@ impl CallArgs { } }; - req.set_input::(data.into()); + req.set_input(data); println!("{}", Cast::new(provider).call(&req, func.as_ref(), block).await?); diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 6ee33ed267154..b0f0d6fcf27df 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,5 +1,5 @@ use alloy_network::TransactionBuilder; -use alloy_primitives::{Bytes, U256}; +use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use clap::Parser; @@ -121,7 +121,7 @@ impl EstimateArgs { } }; - req.set_input::(data.into()); + req.set_input(data); let gas = provider.estimate_gas(&req, BlockId::latest()).await?; println!("{gas}"); diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 5a5d362fdfe11..599d73247f73b 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -90,7 +90,7 @@ impl RunArgs { let compute_units_per_second = if self.no_rate_limit { Some(u64::MAX) } else { self.compute_units_per_second }; - let provider = foundry_common::provider::alloy::ProviderBuilder::new( + let provider = foundry_common::provider::ProviderBuilder::new( &config.get_rpc_url_or_localhost_http()?, ) .compute_units_per_second_opt(compute_units_per_second) diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 184da16d6dca2..1ad0ee2a9679e 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -56,7 +56,7 @@ pub async fn build_tx< let chain = chain.into(); let from = from.into().resolve(provider).await?; - // TODO: Possible bug here? + let to: Option
= if let Some(to) = to { Some(to.into().resolve(provider).await?) } else { None }; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 1f26acbee85a8..da4103b74c180 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -120,7 +120,7 @@ where func: Option<&Function>, block: Option, ) -> Result { - let res = self.provider.call(req, block.unwrap_or(BlockId::latest())).await?; + let res = self.provider.call(req, block.unwrap_or_default()).await?; let mut decoded = vec![]; @@ -855,7 +855,6 @@ where /// use alloy_rpc_types::Filter; /// use alloy_transport::BoxTransport; /// use cast::Cast; - /// use foundry_common::provider::alloy::get_http_provider as get_ws_provider; /// use std::{io, str::FromStr}; /// /// # async fn foo() -> eyre::Result<()> { diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 17cddc6076c2e..a4e9a0ad85743 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -27,7 +27,10 @@ alloy-sol-types.workspace = true alloy-provider.workspace = true alloy-rpc-types.workspace = true alloy-signer.workspace = true -alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } +alloy-signer-wallet = { workspace = true, features = [ + "mnemonic-all-languages", + "keystore", +] } parking_lot = "0.12" eyre.workspace = true diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index d2a8ff4ebbeba..f7db4c0e9774b 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -4,7 +4,7 @@ use alloy_provider::Provider; use alloy_rpc_types::Filter; use alloy_sol_types::SolValue; use eyre::WrapErr; -use foundry_common::provider::alloy::ProviderBuilder; +use foundry_common::provider::ProviderBuilder; use foundry_compilers::utils::RuntimeOrHandle; use foundry_evm_core::fork::CreateFork; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 68418e2823a7f..b66d262e21dc8 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -18,7 +18,7 @@ use crate::{ use alloy_primitives::{Address, Bytes, Log, TxKind, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolInterface, SolValue}; -use foundry_common::{evm::Breakpoints, provider::alloy::RpcUrl, SELECTOR_LEN}; +use foundry_common::{evm::Breakpoints, SELECTOR_LEN}; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseExt, RevertDiagnostic}, @@ -80,7 +80,7 @@ impl Context { #[derive(Clone, Debug, Default)] pub struct BroadcastableTransaction { /// The optional RPC URL. - pub rpc: Option, + pub rpc: Option, /// The transaction to broadcast. pub transaction: TransactionRequest, } @@ -915,7 +915,7 @@ impl Inspector for Cheatcodes { rpc: ecx.db.active_fork_url(), transaction: TransactionRequest { from: Some(broadcast.new_origin), - to: Some(TxKind::Call(call.contract)), + to: Some(TxKind::from(Some(call.contract))), value: Some(call.transfer.value), input: TransactionInput::new(call.input.clone()), nonce: Some(account.info.nonce), diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index cd071617520ff..8f751728dee3d 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -81,21 +81,19 @@ pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { Ok(s) } -/// Returns a [RetryProvider](foundry_common::alloy::RetryProvider) instantiated using [Config]'s +/// Returns a [RetryProvider](foundry_common::RetryProvider) instantiated using [Config]'s /// RPC -pub fn get_provider(config: &Config) -> Result { +pub fn get_provider(config: &Config) -> Result { get_provider_builder(config)?.build() } -/// Returns a [ProviderBuilder](foundry_common::provider::alloy::ProviderBuilder) instantiated using +/// Returns a [ProviderBuilder](foundry_common::provider::ProviderBuilder) instantiated using /// [Config] values. /// /// Defaults to `http://localhost:8545` and `Mainnet`. -pub fn get_provider_builder( - config: &Config, -) -> Result { +pub fn get_provider_builder(config: &Config) -> Result { let url = config.get_rpc_url_or_localhost_http()?; - let mut builder = foundry_common::provider::alloy::ProviderBuilder::new(url.as_ref()); + let mut builder = foundry_common::provider::ProviderBuilder::new(url.as_ref()); if let Ok(chain) = config.chain.unwrap_or_default().try_into() { builder = builder.chain(chain); diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 29d55fe5f5214..10f3cf6aab934 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -15,22 +15,23 @@ foundry-compilers.workspace = true foundry-config.workspace = true foundry-linking.workspace = true -ethers-core.workspace = true -ethers-middleware.workspace = true -ethers-providers = { workspace = true, features = ["ws", "ipc"] } -ethers-signers.workspace = true -# should be removed along with ethers -reqwest_ethers = { package = "reqwest", version = "0.11", default-features = false } - alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } +alloy-rpc-types-engine.workspace = true alloy-rpc-types.workspace = true alloy-rpc-client.workspace = true alloy-provider.workspace = true alloy-transport.workspace = true -alloy-signer-wallet.workspace = true -alloy-transport-http = { workspace = true, features = ["reqwest", "reqwest-rustls-tls"] } +alloy-transport-http = { workspace = true, features = [ + "reqwest", + "reqwest-rustls-tls", +] } alloy-transport-ws.workspace = true alloy-transport-ipc.workspace = true alloy-json-rpc.workspace = true @@ -48,7 +49,6 @@ dunce = "1" eyre.workspace = true glob = "0.3" globset = "0.4" -hex.workspace = true once_cell = "1" reqwest.workspace = true semver = "1" @@ -68,7 +68,3 @@ num-format.workspace = true foundry-macros.workspace = true pretty_assertions.workspace = true tokio = { version = "1", features = ["rt-multi-thread", "macros"] } - -[features] -default = ["rustls"] -rustls = ["reqwest_ethers/rustls-tls-native-roots"] diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index 131980f55fa86..b96ecba8d8742 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -200,6 +200,7 @@ pub fn reverse_address(addr: &Address) -> String { #[cfg(test)] mod test { use super::*; + use alloy_primitives::hex; fn assert_hex(hash: B256, val: &str) { assert_eq!(hash.0[..], hex::decode(val).unwrap()[..]); diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 26db7038cc1bd..3893fb4c9d40f 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -378,31 +378,6 @@ impl UIfmt for EthValue { } } -// TODO: replace these above and remove this module once types are converted -mod temp_ethers { - use super::UIfmt; - use ethers_core::types::{Address, Bloom, Bytes, H256, H64, I256, U256, U64}; - use foundry_common::types::ToAlloy; - - macro_rules! with_alloy { - ($($t:ty),*) => {$( - impl UIfmt for $t { - fn pretty(&self) -> String { - self.to_alloy().pretty() - } - } - )*}; - } - - impl UIfmt for Bytes { - fn pretty(&self) -> String { - self.clone().to_alloy().pretty() - } - } - - with_alloy!(Address, Bloom, H64, H256, I256, U256, U64); -} - /// Returns the `UiFmt::pretty()` formatted attribute of the transactions pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option { match attr { diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 484bc89d273bb..6febaa3787751 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -20,14 +20,12 @@ pub mod fs; pub mod glob; pub mod provider; pub mod retry; -pub mod runtime_client; pub mod selectors; pub mod serde_helpers; pub mod shell; pub mod term; pub mod traits; pub mod transactions; -pub mod types; pub use constants::*; pub use contracts::*; diff --git a/crates/common/src/provider/alloy.rs b/crates/common/src/provider/alloy.rs deleted file mode 100644 index e76a898bd8144..0000000000000 --- a/crates/common/src/provider/alloy.rs +++ /dev/null @@ -1,324 +0,0 @@ -//! Commonly used helpers to construct `Provider`s - -use crate::{ - provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, -}; -use alloy_provider::{ - network::AnyNetwork, utils::Eip1559Estimation, Provider, - ProviderBuilder as AlloyProviderBuilder, RootProvider, -}; -use alloy_rpc_client::ClientBuilder; -use alloy_transport::Transport; -use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon}; -use eyre::{Result, WrapErr}; -use foundry_common::types::ToAlloy; -use foundry_config::NamedChain; -use reqwest::Url; -use std::{ - net::SocketAddr, - path::{Path, PathBuf}, - str::FromStr, - time::Duration, -}; -use url::ParseError; - -use super::{ - runtime_transport::RuntimeTransport, - tower::{RetryBackoffLayer, RetryBackoffService}, -}; - -/// Helper type alias for a retry provider -pub type RetryProvider = RootProvider, N>; - -/// Helper type alias for a rpc url -pub type RpcUrl = String; - -/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely -/// an anvil or other dev node) and with the default, or 7 second otherwise. -/// -/// See [`try_get_http_provider`] for more details. -/// -/// # Panics -/// -/// Panics if the URL is invalid. -/// -/// # Examples -/// -/// ``` -/// use foundry_common::provider::alloy::get_http_provider; -/// -/// let retry_provider = get_http_provider("http://localhost:8545"); -/// ``` -#[inline] -#[track_caller] -pub fn get_http_provider(builder: impl AsRef) -> RetryProvider { - try_get_http_provider(builder).unwrap() -} - -/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely -/// an anvil or other dev node) and with the default, or 7 second otherwise. -#[inline] -pub fn try_get_http_provider(builder: impl AsRef) -> Result { - ProviderBuilder::new(builder.as_ref()).build() -} - -/// Helper type to construct a `RetryProvider` -#[derive(Debug)] -pub struct ProviderBuilder { - // Note: this is a result, so we can easily chain builder calls - url: Result, - chain: NamedChain, - max_retry: u32, - timeout_retry: u32, - initial_backoff: u64, - timeout: Duration, - /// available CUPS - compute_units_per_second: u64, - /// JWT Secret - jwt: Option, - headers: Vec, -} - -// === impl ProviderBuilder === - -impl ProviderBuilder { - /// Creates a new builder instance - pub fn new(url_str: &str) -> Self { - // a copy is needed for the next lines to work - let mut url_str = url_str; - - // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http - // prefix - let storage; - if url_str.starts_with("localhost:") { - storage = format!("http://{url_str}"); - url_str = storage.as_str(); - } - - let url = Url::parse(url_str) - .or_else(|err| match err { - ParseError::RelativeUrlWithoutBase => { - if SocketAddr::from_str(url_str).is_ok() { - Url::parse(&format!("http://{}", url_str)) - } else { - let path = Path::new(url_str); - - if let Ok(path) = resolve_path(path) { - Url::parse(&format!("file://{}", path.display())) - } else { - Err(err) - } - } - } - _ => Err(err), - }) - .wrap_err_with(|| format!("invalid provider URL: {url_str:?}")); - - Self { - url, - chain: NamedChain::Mainnet, - max_retry: 8, - timeout_retry: 8, - initial_backoff: 800, - timeout: REQUEST_TIMEOUT, - // alchemy max cpus - compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, - jwt: None, - headers: vec![], - } - } - - /// Enables a request timeout. - /// - /// The timeout is applied from when the request starts connecting until the - /// response body has finished. - /// - /// Default is no timeout. - pub fn timeout(mut self, timeout: Duration) -> Self { - self.timeout = timeout; - self - } - - /// Sets the chain of the node the provider will connect to - pub fn chain(mut self, chain: NamedChain) -> Self { - self.chain = chain; - self - } - - /// How often to retry a failed request - pub fn max_retry(mut self, max_retry: u32) -> Self { - self.max_retry = max_retry; - self - } - - /// How often to retry a failed request. If `None`, defaults to the already-set value. - pub fn maybe_max_retry(mut self, max_retry: Option) -> Self { - self.max_retry = max_retry.unwrap_or(self.max_retry); - self - } - - /// The starting backoff delay to use after the first failed request. If `None`, defaults to - /// the already-set value. - pub fn maybe_initial_backoff(mut self, initial_backoff: Option) -> Self { - self.initial_backoff = initial_backoff.unwrap_or(self.initial_backoff); - self - } - - /// How often to retry a failed request due to connection issues - pub fn timeout_retry(mut self, timeout_retry: u32) -> Self { - self.timeout_retry = timeout_retry; - self - } - - /// The starting backoff delay to use after the first failed request - pub fn initial_backoff(mut self, initial_backoff: u64) -> Self { - self.initial_backoff = initial_backoff; - self - } - - /// Sets the number of assumed available compute units per second - /// - /// See also, - pub fn compute_units_per_second(mut self, compute_units_per_second: u64) -> Self { - self.compute_units_per_second = compute_units_per_second; - self - } - - /// Sets the number of assumed available compute units per second - /// - /// See also, - pub fn compute_units_per_second_opt(mut self, compute_units_per_second: Option) -> Self { - if let Some(cups) = compute_units_per_second { - self.compute_units_per_second = cups; - } - self - } - - /// Sets aggressive `max_retry` and `initial_backoff` values - /// - /// This is only recommend for local dev nodes - pub fn aggressive(self) -> Self { - self.max_retry(100).initial_backoff(100) - } - - /// Sets the JWT secret - pub fn jwt(mut self, jwt: impl Into) -> Self { - self.jwt = Some(jwt.into()); - self - } - - /// Sets http headers - pub fn headers(mut self, headers: Vec) -> Self { - self.headers = headers; - - self - } - - /// Constructs the `RetryProvider` taking all configs into account. - pub fn build(self) -> Result { - let ProviderBuilder { - url, - chain: _, - max_retry, - timeout_retry, - initial_backoff, - timeout, - compute_units_per_second, - jwt, - headers, - } = self; - let url = url?; - - let retry_layer = RetryBackoffLayer::new( - max_retry, - timeout_retry, - initial_backoff, - compute_units_per_second, - ); - let transport = RuntimeTransportBuilder::new(url.clone()) - .with_timeout(timeout) - .with_headers(headers) - .with_jwt(jwt) - .build(); - let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); - - let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() - .on_provider(RootProvider::new(client)); - - Ok(provider) - } -} - -/// Estimates EIP1559 fees depending on the chain -/// -/// Uses custom gas oracles for -/// - polygon -/// -/// Fallback is the default [`Provider::estimate_eip1559_fees`] implementation -pub async fn estimate_eip1559_fees, T: Transport + Clone>( - provider: &P, - chain: Option, -) -> Result { - let chain = if let Some(chain) = chain { - chain - } else { - provider.get_chain_id().await.wrap_err("Failed to get chain id")? - }; - - if let Ok(chain) = NamedChain::try_from(chain) { - // handle chains that deviate from `eth_feeHistory` and have their own oracle - match chain { - NamedChain::Polygon | NamedChain::PolygonMumbai => { - // TODO: phase this out somehow - let chain = match chain { - NamedChain::Polygon => ethers_core::types::Chain::Polygon, - NamedChain::PolygonMumbai => ethers_core::types::Chain::PolygonMumbai, - _ => unreachable!(), - }; - let estimator = Polygon::new(chain)?.category(GasCategory::Standard); - let (a, b) = estimator.estimate_eip1559_fees().await?; - - let estimation = Eip1559Estimation { - max_fee_per_gas: a.to_alloy().to(), - max_priority_fee_per_gas: b.to_alloy().to(), - }; - return Ok(estimation) - } - _ => {} - } - } - provider.estimate_eip1559_fees(None).await.wrap_err("Failed fetch EIP1559 fees") -} - -#[cfg(not(windows))] -fn resolve_path(path: &Path) -> Result { - if path.is_absolute() { - Ok(path.to_path_buf()) - } else { - std::env::current_dir().map(|d| d.join(path)).map_err(drop) - } -} - -#[cfg(windows)] -fn resolve_path(path: &Path) -> Result { - if let Some(s) = path.to_str() { - if s.starts_with(r"\\.\pipe\") { - return Ok(path.to_path_buf()); - } - } - Err(()) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_auto_correct_missing_prefix() { - let builder = ProviderBuilder::new("localhost:8545"); - assert!(builder.url.is_ok()); - - let url = builder.url.unwrap(); - assert_eq!(url, Url::parse("http://localhost:8545").unwrap()); - } -} diff --git a/crates/common/src/provider/ethers.rs b/crates/common/src/provider/ethers.rs deleted file mode 100644 index 7d99763de3211..0000000000000 --- a/crates/common/src/provider/ethers.rs +++ /dev/null @@ -1,283 +0,0 @@ -//! Commonly used helpers to construct `Provider`s - -use crate::{ - runtime_client::{RuntimeClient, RuntimeClientBuilder}, - ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, -}; -use ethers_providers::{is_local_endpoint, Middleware, Provider, DEFAULT_LOCAL_POLL_INTERVAL}; -use eyre::{Result, WrapErr}; -use foundry_config::NamedChain; -use reqwest::Url; -use std::{ - path::{Path, PathBuf}, - time::Duration, -}; -use url::ParseError; - -/// Helper type alias for a retry provider -pub type RetryProvider = Provider; - -/// Helper type alias for a rpc url -pub type RpcUrl = String; - -/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely -/// an anvil or other dev node) and with the default, or 7 second otherwise. -/// -/// See [`try_get_http_provider`] for more details. -/// -/// # Panics -/// -/// Panics if the URL is invalid. -/// -/// # Examples -/// -/// ``` -/// use foundry_common::provider::ethers::get_http_provider; -/// -/// let retry_provider = get_http_provider("http://localhost:8545"); -/// ``` -#[inline] -#[track_caller] -pub fn get_http_provider(builder: impl AsRef) -> RetryProvider { - try_get_http_provider(builder).unwrap() -} - -/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely -/// an anvil or other dev node) and with the default, or 7 second otherwise. -#[inline] -pub fn try_get_http_provider(builder: impl AsRef) -> Result { - ProviderBuilder::new(builder.as_ref()).build() -} - -/// Helper type to construct a `RetryProvider` -#[derive(Debug)] -pub struct ProviderBuilder { - // Note: this is a result, so we can easily chain builder calls - url: Result, - chain: NamedChain, - max_retry: u32, - timeout_retry: u32, - initial_backoff: u64, - timeout: Duration, - /// available CUPS - compute_units_per_second: u64, - /// JWT Secret - jwt: Option, - headers: Vec, -} - -// === impl ProviderBuilder === - -impl ProviderBuilder { - /// Creates a new builder instance - pub fn new(url_str: &str) -> Self { - // a copy is needed for the next lines to work - let mut url_str = url_str; - - // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http - // prefix - let storage; - if url_str.starts_with("localhost:") || url_str.starts_with("127.0.0.1:") { - storage = format!("http://{url_str}"); - url_str = storage.as_str(); - } - - let url = Url::parse(url_str) - .or_else(|err| match err { - ParseError::RelativeUrlWithoutBase => { - let path = Path::new(url_str); - - if let Ok(path) = resolve_path(path) { - Url::parse(&format!("file://{}", path.display())) - } else { - Err(err) - } - } - _ => Err(err), - }) - .wrap_err_with(|| format!("invalid provider URL: {url_str:?}")); - - Self { - url, - chain: NamedChain::Mainnet, - max_retry: 8, - timeout_retry: 8, - initial_backoff: 800, - timeout: REQUEST_TIMEOUT, - // alchemy max cpus - compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, - jwt: None, - headers: vec![], - } - } - - /// Enables a request timeout. - /// - /// The timeout is applied from when the request starts connecting until the - /// response body has finished. - /// - /// Default is no timeout. - pub fn timeout(mut self, timeout: Duration) -> Self { - self.timeout = timeout; - self - } - - /// Sets the chain of the node the provider will connect to - pub fn chain(mut self, chain: NamedChain) -> Self { - self.chain = chain; - self - } - - /// How often to retry a failed request - pub fn max_retry(mut self, max_retry: u32) -> Self { - self.max_retry = max_retry; - self - } - - /// How often to retry a failed request. If `None`, defaults to the already-set value. - pub fn maybe_max_retry(mut self, max_retry: Option) -> Self { - self.max_retry = max_retry.unwrap_or(self.max_retry); - self - } - - /// The starting backoff delay to use after the first failed request. If `None`, defaults to - /// the already-set value. - pub fn maybe_initial_backoff(mut self, initial_backoff: Option) -> Self { - self.initial_backoff = initial_backoff.unwrap_or(self.initial_backoff); - self - } - - /// How often to retry a failed request due to connection issues - pub fn timeout_retry(mut self, timeout_retry: u32) -> Self { - self.timeout_retry = timeout_retry; - self - } - - /// The starting backoff delay to use after the first failed request - pub fn initial_backoff(mut self, initial_backoff: u64) -> Self { - self.initial_backoff = initial_backoff; - self - } - - /// Sets the number of assumed available compute units per second - /// - /// See also, - pub fn compute_units_per_second(mut self, compute_units_per_second: u64) -> Self { - self.compute_units_per_second = compute_units_per_second; - self - } - - /// Sets the number of assumed available compute units per second - /// - /// See also, - pub fn compute_units_per_second_opt(mut self, compute_units_per_second: Option) -> Self { - if let Some(cups) = compute_units_per_second { - self.compute_units_per_second = cups; - } - self - } - - /// Sets aggressive `max_retry` and `initial_backoff` values - /// - /// This is only recommend for local dev nodes - pub fn aggressive(self) -> Self { - self.max_retry(100).initial_backoff(100) - } - - /// Sets the JWT secret - pub fn jwt(mut self, jwt: impl Into) -> Self { - self.jwt = Some(jwt.into()); - self - } - - /// Sets http headers - pub fn headers(mut self, headers: Vec) -> Self { - self.headers = headers; - - self - } - - /// Same as [`Self:build()`] but also retrieves the `chainId` in order to derive an appropriate - /// interval. - pub async fn connect(self) -> Result { - let mut provider = self.build()?; - if let Some(blocktime) = provider.get_chainid().await.ok().and_then(|id| { - NamedChain::try_from(id.as_u64()).ok().and_then(|chain| chain.average_blocktime_hint()) - }) { - provider = provider.interval(blocktime / 2); - } - Ok(provider) - } - - /// Constructs the `RetryProvider` taking all configs into account. - pub fn build(self) -> Result { - let ProviderBuilder { - url, - chain, - max_retry, - timeout_retry, - initial_backoff, - timeout, - compute_units_per_second, - jwt, - headers, - } = self; - let url = url?; - - let client_builder = RuntimeClientBuilder::new( - url.clone(), - max_retry, - timeout_retry, - initial_backoff, - timeout, - compute_units_per_second, - ) - .with_headers(headers) - .with_jwt(jwt); - - let mut provider = Provider::new(client_builder.build()); - - let is_local = is_local_endpoint(url.as_str()); - - if is_local { - provider = provider.interval(DEFAULT_LOCAL_POLL_INTERVAL); - } else if let Some(blocktime) = chain.average_blocktime_hint() { - provider = provider.interval(blocktime / 2); - } - - Ok(provider) - } -} - -#[cfg(not(windows))] -fn resolve_path(path: &Path) -> Result { - if path.is_absolute() { - Ok(path.to_path_buf()) - } else { - std::env::current_dir().map(|d| d.join(path)).map_err(drop) - } -} - -#[cfg(windows)] -fn resolve_path(path: &Path) -> Result { - if let Some(s) = path.to_str() { - if s.starts_with(r"\\.\pipe\") { - return Ok(path.to_path_buf()); - } - } - Err(()) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_auto_correct_missing_prefix() { - let builder = ProviderBuilder::new("localhost:8545"); - assert!(builder.url.is_ok()); - - let url = builder.url.unwrap(); - assert_eq!(url, Url::parse("http://localhost:8545").unwrap()); - } -} diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index cbd9ecbd00ef9..c8e9a0ba2733f 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -1,7 +1,328 @@ //! Provider-related instantiation and usage utilities. -pub mod alloy; -pub mod ethers; pub mod retry; pub mod runtime_transport; pub mod tower; + +use crate::{ + provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, +}; +use alloy_provider::{ + fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SignerFiller}, + network::{AnyNetwork, EthereumSigner}, + Identity, ProviderBuilder as AlloyProviderBuilder, RootProvider, +}; +use alloy_rpc_client::ClientBuilder; +use eyre::{Result, WrapErr}; +use foundry_config::NamedChain; +use reqwest::Url; +use runtime_transport::RuntimeTransport; +use std::{ + net::SocketAddr, + path::{Path, PathBuf}, + str::FromStr, + time::Duration, +}; +use tower::{RetryBackoffLayer, RetryBackoffService}; +use url::ParseError; + +/// Helper type alias for a retry provider +pub type RetryProvider = RootProvider, N>; + +/// Helper type alias for a retry provider with a signer +pub type RetryProviderWithSigner = FillProvider< + JoinFill< + JoinFill, NonceFiller>, ChainIdFiller>, + SignerFiller, + >, + RootProvider, N>, + RetryBackoffService, + N, +>; + +/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely +/// an anvil or other dev node) and with the default, or 7 second otherwise. +/// +/// See [`try_get_http_provider`] for more details. +/// +/// # Panics +/// +/// Panics if the URL is invalid. +/// +/// # Examples +/// +/// ``` +/// use foundry_common::provider::get_http_provider; +/// +/// let retry_provider = get_http_provider("http://localhost:8545"); +/// ``` +#[inline] +#[track_caller] +pub fn get_http_provider(builder: impl AsRef) -> RetryProvider { + try_get_http_provider(builder).unwrap() +} + +/// Constructs a provider with a 100 millisecond interval poll if it's a localhost URL (most likely +/// an anvil or other dev node) and with the default, or 7 second otherwise. +#[inline] +pub fn try_get_http_provider(builder: impl AsRef) -> Result { + ProviderBuilder::new(builder.as_ref()).build() +} + +/// Helper type to construct a `RetryProvider` +#[derive(Debug)] +pub struct ProviderBuilder { + // Note: this is a result, so we can easily chain builder calls + url: Result, + chain: NamedChain, + max_retry: u32, + timeout_retry: u32, + initial_backoff: u64, + timeout: Duration, + /// available CUPS + compute_units_per_second: u64, + /// JWT Secret + jwt: Option, + headers: Vec, +} + +// === impl ProviderBuilder === + +impl ProviderBuilder { + /// Creates a new builder instance + pub fn new(url_str: &str) -> Self { + // a copy is needed for the next lines to work + let mut url_str = url_str; + + // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http + // prefix + let storage; + if url_str.starts_with("localhost:") { + storage = format!("http://{url_str}"); + url_str = storage.as_str(); + } + + let url = Url::parse(url_str) + .or_else(|err| match err { + ParseError::RelativeUrlWithoutBase => { + if SocketAddr::from_str(url_str).is_ok() { + Url::parse(&format!("http://{}", url_str)) + } else { + let path = Path::new(url_str); + + if let Ok(path) = resolve_path(path) { + Url::parse(&format!("file://{}", path.display())) + } else { + Err(err) + } + } + } + _ => Err(err), + }) + .wrap_err_with(|| format!("invalid provider URL: {url_str:?}")); + + Self { + url, + chain: NamedChain::Mainnet, + max_retry: 8, + timeout_retry: 8, + initial_backoff: 800, + timeout: REQUEST_TIMEOUT, + // alchemy max cpus + compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, + jwt: None, + headers: vec![], + } + } + + /// Enables a request timeout. + /// + /// The timeout is applied from when the request starts connecting until the + /// response body has finished. + /// + /// Default is no timeout. + pub fn timeout(mut self, timeout: Duration) -> Self { + self.timeout = timeout; + self + } + + /// Sets the chain of the node the provider will connect to + pub fn chain(mut self, chain: NamedChain) -> Self { + self.chain = chain; + self + } + + /// How often to retry a failed request + pub fn max_retry(mut self, max_retry: u32) -> Self { + self.max_retry = max_retry; + self + } + + /// How often to retry a failed request. If `None`, defaults to the already-set value. + pub fn maybe_max_retry(mut self, max_retry: Option) -> Self { + self.max_retry = max_retry.unwrap_or(self.max_retry); + self + } + + /// The starting backoff delay to use after the first failed request. If `None`, defaults to + /// the already-set value. + pub fn maybe_initial_backoff(mut self, initial_backoff: Option) -> Self { + self.initial_backoff = initial_backoff.unwrap_or(self.initial_backoff); + self + } + + /// How often to retry a failed request due to connection issues + pub fn timeout_retry(mut self, timeout_retry: u32) -> Self { + self.timeout_retry = timeout_retry; + self + } + + /// The starting backoff delay to use after the first failed request + pub fn initial_backoff(mut self, initial_backoff: u64) -> Self { + self.initial_backoff = initial_backoff; + self + } + + /// Sets the number of assumed available compute units per second + /// + /// See also, + pub fn compute_units_per_second(mut self, compute_units_per_second: u64) -> Self { + self.compute_units_per_second = compute_units_per_second; + self + } + + /// Sets the number of assumed available compute units per second + /// + /// See also, + pub fn compute_units_per_second_opt(mut self, compute_units_per_second: Option) -> Self { + if let Some(cups) = compute_units_per_second { + self.compute_units_per_second = cups; + } + self + } + + /// Sets aggressive `max_retry` and `initial_backoff` values + /// + /// This is only recommend for local dev nodes + pub fn aggressive(self) -> Self { + self.max_retry(100).initial_backoff(100) + } + + /// Sets the JWT secret + pub fn jwt(mut self, jwt: impl Into) -> Self { + self.jwt = Some(jwt.into()); + self + } + + /// Sets http headers + pub fn headers(mut self, headers: Vec) -> Self { + self.headers = headers; + + self + } + + /// Constructs the `RetryProvider` taking all configs into account. + pub fn build(self) -> Result { + let ProviderBuilder { + url, + chain: _, + max_retry, + timeout_retry, + initial_backoff, + timeout, + compute_units_per_second, + jwt, + headers, + } = self; + let url = url?; + + let retry_layer = RetryBackoffLayer::new( + max_retry, + timeout_retry, + initial_backoff, + compute_units_per_second, + ); + let transport = RuntimeTransportBuilder::new(url.clone()) + .with_timeout(timeout) + .with_headers(headers) + .with_jwt(jwt) + .build(); + let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); + + let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() + .on_provider(RootProvider::new(client)); + + Ok(provider) + } + + /// Constructs the `RetryProvider` with a signer + pub fn build_with_signer(self, signer: EthereumSigner) -> Result { + let ProviderBuilder { + url, + chain: _, + max_retry, + timeout_retry, + initial_backoff, + timeout, + compute_units_per_second, + jwt, + headers, + } = self; + let url = url?; + + let retry_layer = RetryBackoffLayer::new( + max_retry, + timeout_retry, + initial_backoff, + compute_units_per_second, + ); + + let transport = RuntimeTransportBuilder::new(url.clone()) + .with_timeout(timeout) + .with_headers(headers) + .with_jwt(jwt) + .build(); + + let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); + + let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() + .with_recommended_fillers() + .signer(signer) + .on_provider(RootProvider::new(client)); + + Ok(provider) + } +} + +#[cfg(not(windows))] +fn resolve_path(path: &Path) -> Result { + if path.is_absolute() { + Ok(path.to_path_buf()) + } else { + std::env::current_dir().map(|d| d.join(path)).map_err(drop) + } +} + +#[cfg(windows)] +fn resolve_path(path: &Path) -> Result { + if let Some(s) = path.to_str() { + if s.starts_with(r"\\.\pipe\") { + return Ok(path.to_path_buf()); + } + } + Err(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn can_auto_correct_missing_prefix() { + let builder = ProviderBuilder::new("localhost:8545"); + assert!(builder.url.is_ok()); + + let url = builder.url.unwrap(); + assert_eq!(url, Url::parse("http://localhost:8545").unwrap()); + } +} diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 48411a321f1d9..5402148918ddf 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -3,13 +3,13 @@ use crate::REQUEST_TIMEOUT; use alloy_json_rpc::{RequestPacket, ResponsePacket}; use alloy_pubsub::{PubSubConnect, PubSubFrontend}; +use alloy_rpc_types_engine::{Claims, JwtSecret}; use alloy_transport::{ Authorization, BoxTransport, TransportError, TransportErrorKind, TransportFut, }; use alloy_transport_http::Http; use alloy_transport_ipc::IpcConnect; use alloy_transport_ws::WsConnect; -use ethers_providers::{JwtAuth, JwtKey}; use reqwest::header::{HeaderName, HeaderValue}; use std::{path::PathBuf, str::FromStr, sync::Arc}; use thiserror::Error; @@ -33,8 +33,8 @@ pub enum InnerTransport { #[derive(Error, Debug)] pub enum RuntimeTransportError { /// Internal transport error - #[error(transparent)] - TransportError(TransportError), + #[error("Internal transport error: {0} with {1}")] + TransportError(TransportError, String), /// Failed to lock the transport #[error("Failed to lock the transport")] @@ -187,7 +187,7 @@ impl RuntimeTransport { let ws = WsConnect { url: self.url.to_string(), auth } .into_service() .await - .map_err(RuntimeTransportError::TransportError)?; + .map_err(|e| RuntimeTransportError::TransportError(e, self.url.to_string()))?; Ok(InnerTransport::Ws(ws)) } @@ -195,9 +195,10 @@ impl RuntimeTransport { async fn connect_ipc(&self) -> Result { let path = url_to_file_path(&self.url) .map_err(|_| RuntimeTransportError::BadPath(self.url.to_string()))?; - let ipc_connector: IpcConnect = path.into(); - let ipc = - ipc_connector.into_service().await.map_err(RuntimeTransportError::TransportError)?; + let ipc_connector: IpcConnect = path.clone().into(); + let ipc = ipc_connector.into_service().await.map_err(|e| { + RuntimeTransportError::TransportError(e, path.clone().display().to_string()) + })?; Ok(InnerTransport::Ipc(ipc)) } @@ -292,10 +293,9 @@ impl tower::Service for &RuntimeTransport { fn build_auth(jwt: String) -> eyre::Result { // Decode jwt from hex, then generate claims (iat with current timestamp) - let jwt = hex::decode(jwt)?; - let secret = JwtKey::from_slice(&jwt).map_err(|err| eyre::eyre!("Invalid JWT: {}", err))?; - let auth = JwtAuth::new(secret, None, None); - let token = auth.generate_token()?; + let secret = JwtSecret::from_hex(jwt)?; + let claims = Claims::default(); + let token = secret.encode(&claims)?; let auth = Authorization::Bearer(token); diff --git a/crates/common/src/runtime_client.rs b/crates/common/src/runtime_client.rs deleted file mode 100644 index 3bb1631d5fb73..0000000000000 --- a/crates/common/src/runtime_client.rs +++ /dev/null @@ -1,337 +0,0 @@ -//! Wrap different providers -// todo: remove -use async_trait::async_trait; -use ethers_core::types::U256; -use ethers_providers::{ - Authorization, ConnectionDetails, Http, HttpRateLimitRetryPolicy, Ipc, JsonRpcClient, - JsonRpcError, JwtAuth, JwtKey, ProviderError, PubsubClient, RetryClient, RetryClientBuilder, - RpcError, Ws, -}; -use reqwest_ethers::{ - header::{HeaderName, HeaderValue}, - Url, -}; -use serde::{de::DeserializeOwned, Serialize}; -use std::{fmt::Debug, path::PathBuf, str::FromStr, sync::Arc, time::Duration}; -use thiserror::Error; -use tokio::sync::RwLock; - -/// Enum representing a the client types supported by the runtime provider -#[derive(Debug)] -enum InnerClient { - /// HTTP client - Http(RetryClient), - /// WebSocket client - Ws(Ws), - /// IPC client - Ipc(Ipc), -} - -/// Error type for the runtime provider -#[derive(Debug, Error)] -pub enum RuntimeClientError { - /// Internal provider error - #[error(transparent)] - ProviderError(ProviderError), - - /// Failed to lock the client - #[error("Failed to lock the client")] - LockError, - - /// Invalid URL scheme - #[error("URL scheme is not supported: {0}")] - BadScheme(String), - - /// Invalid HTTP header - #[error("Invalid HTTP header: {0}")] - BadHeader(String), - - /// Invalid file path - #[error("Invalid IPC file path: {0}")] - BadPath(String), -} - -impl RpcError for RuntimeClientError { - fn as_error_response(&self) -> Option<&JsonRpcError> { - match self { - RuntimeClientError::ProviderError(err) => err.as_error_response(), - _ => None, - } - } - - fn as_serde_error(&self) -> Option<&serde_json::Error> { - match self { - RuntimeClientError::ProviderError(e) => e.as_serde_error(), - _ => None, - } - } -} - -impl From for ProviderError { - fn from(src: RuntimeClientError) -> Self { - match src { - RuntimeClientError::ProviderError(err) => err, - _ => ProviderError::JsonRpcClientError(Box::new(src)), - } - } -} - -/// A provider that connects on first request allowing handling of different provider types at -/// runtime -#[derive(Clone, Debug, Error)] -pub struct RuntimeClient { - client: Arc>>, - url: Url, - max_retry: u32, - timeout_retry: u32, - initial_backoff: u64, - timeout: Duration, - /// available CUPS - compute_units_per_second: u64, - jwt: Option, - headers: Vec, -} - -/// Builder for RuntimeClient -pub struct RuntimeClientBuilder { - url: Url, - max_retry: u32, - timeout_retry: u32, - initial_backoff: u64, - timeout: Duration, - /// available CUPS - compute_units_per_second: u64, - jwt: Option, - headers: Vec, -} - -impl ::core::fmt::Display for RuntimeClient { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "RuntimeClient") - } -} - -fn build_auth(jwt: String) -> eyre::Result { - // Decode jwt from hex, then generate claims (iat with current timestamp) - let jwt = hex::decode(jwt)?; - let secret = JwtKey::from_slice(&jwt).map_err(|err| eyre::eyre!("Invalid JWT: {}", err))?; - let auth = JwtAuth::new(secret, None, None); - let token = auth.generate_token()?; - - // Essentially unrolled ethers-rs new_with_auth to accommodate the custom timeout - let auth = Authorization::Bearer(token); - - Ok(auth) -} - -impl RuntimeClient { - async fn connect(&self) -> Result { - match self.url.scheme() { - "http" | "https" => { - let mut client_builder = reqwest_ethers::Client::builder() - .timeout(self.timeout) - .tls_built_in_root_certs(self.url.scheme() == "https"); - let mut headers = reqwest_ethers::header::HeaderMap::new(); - - if let Some(jwt) = self.jwt.as_ref() { - let auth = build_auth(jwt.clone()).map_err(|err| { - RuntimeClientError::ProviderError(ProviderError::CustomError( - err.to_string(), - )) - })?; - - let mut auth_value: HeaderValue = HeaderValue::from_str(&auth.to_string()) - .expect("Header should be valid string"); - auth_value.set_sensitive(true); - - headers.insert(reqwest_ethers::header::AUTHORIZATION, auth_value); - }; - - for header in self.headers.iter() { - let make_err = || RuntimeClientError::BadHeader(header.to_string()); - - let (key, val) = header.split_once(':').ok_or_else(make_err)?; - - headers.insert( - HeaderName::from_str(key.trim()).map_err(|_| make_err())?, - HeaderValue::from_str(val.trim()).map_err(|_| make_err())?, - ); - } - - client_builder = client_builder.default_headers(headers); - - let client = client_builder - .build() - .map_err(|e| RuntimeClientError::ProviderError(e.into()))?; - let provider = Http::new_with_client(self.url.clone(), client); - - #[allow(clippy::box_default)] - let provider = RetryClientBuilder::default() - .initial_backoff(Duration::from_millis(self.initial_backoff)) - .rate_limit_retries(self.max_retry) - .timeout_retries(self.timeout_retry) - .compute_units_per_second(self.compute_units_per_second) - .build(provider, Box::new(HttpRateLimitRetryPolicy)); - Ok(InnerClient::Http(provider)) - } - "ws" | "wss" => { - let auth: Option = - self.jwt.as_ref().and_then(|jwt| build_auth(jwt.clone()).ok()); - let connection_details = ConnectionDetails::new(self.url.as_str(), auth); - - let client = - Ws::connect_with_reconnects(connection_details, self.max_retry as usize) - .await - .map_err(|e| RuntimeClientError::ProviderError(e.into()))?; - - Ok(InnerClient::Ws(client)) - } - "file" => { - let path = url_to_file_path(&self.url) - .map_err(|_| RuntimeClientError::BadPath(self.url.to_string()))?; - - let client = Ipc::connect(path) - .await - .map_err(|e| RuntimeClientError::ProviderError(e.into()))?; - - Ok(InnerClient::Ipc(client)) - } - _ => Err(RuntimeClientError::BadScheme(self.url.to_string())), - } - } -} - -impl RuntimeClientBuilder { - /// Create new RuntimeClientBuilder - pub fn new( - url: Url, - max_retry: u32, - timeout_retry: u32, - initial_backoff: u64, - timeout: Duration, - compute_units_per_second: u64, - ) -> Self { - Self { - url, - max_retry, - timeout, - timeout_retry, - initial_backoff, - compute_units_per_second, - jwt: None, - headers: vec![], - } - } - - /// Set jwt to use with RuntimeClient - pub fn with_jwt(mut self, jwt: Option) -> Self { - self.jwt = jwt; - self - } - - /// Set http headers to use with RuntimeClient - /// Only works with http/https schemas - pub fn with_headers(mut self, headers: Vec) -> Self { - self.headers = headers; - self - } - - /// Builds RuntimeClient instance - pub fn build(self) -> RuntimeClient { - RuntimeClient { - client: Arc::new(RwLock::new(None)), - url: self.url, - max_retry: self.max_retry, - timeout_retry: self.timeout_retry, - initial_backoff: self.initial_backoff, - timeout: self.timeout, - compute_units_per_second: self.compute_units_per_second, - jwt: self.jwt, - headers: self.headers, - } - } -} - -#[cfg(windows)] -fn url_to_file_path(url: &Url) -> Result { - const PREFIX: &str = "file:///pipe/"; - - let url_str = url.as_str(); - - if url_str.starts_with(PREFIX) { - let pipe_name = &url_str[PREFIX.len()..]; - let pipe_path = format!(r"\\.\pipe\{}", pipe_name); - return Ok(PathBuf::from(pipe_path)); - } - - url.to_file_path() -} - -#[cfg(not(windows))] -fn url_to_file_path(url: &Url) -> Result { - url.to_file_path() -} - -#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait)] -impl JsonRpcClient for RuntimeClient { - type Error = RuntimeClientError; - - async fn request(&self, method: &str, params: T) -> Result - where - T: Debug + Serialize + Send + Sync, - R: DeserializeOwned + Send, - { - if self.client.read().await.is_none() { - let mut w = self.client.write().await; - *w = Some( - self.connect().await.map_err(|e| RuntimeClientError::ProviderError(e.into()))?, - ); - } - - let res = match self.client.read().await.as_ref().unwrap() { - InnerClient::Http(http) => RetryClient::request(http, method, params) - .await - .map_err(|e| RuntimeClientError::ProviderError(e.into())), - InnerClient::Ws(ws) => JsonRpcClient::request(ws, method, params) - .await - .map_err(|e| RuntimeClientError::ProviderError(e.into())), - InnerClient::Ipc(ipc) => JsonRpcClient::request(ipc, method, params) - .await - .map_err(|e| RuntimeClientError::ProviderError(e.into())), - }?; - Ok(res) - } -} - -// We can also implement [`PubsubClient`] for our dynamic provider. -impl PubsubClient for RuntimeClient { - // Since both `Ws` and `Ipc`'s `NotificationStream` associated type is the same, - // we can simply return one of them. - type NotificationStream = ::NotificationStream; - - fn subscribe>(&self, id: T) -> Result { - match self.client.try_read().map_err(|_| RuntimeClientError::LockError)?.as_ref().unwrap() { - InnerClient::Http(_) => { - Err(RuntimeClientError::ProviderError(ProviderError::UnsupportedRPC)) - } - InnerClient::Ws(client) => Ok(PubsubClient::subscribe(client, id) - .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), - InnerClient::Ipc(client) => Ok(PubsubClient::subscribe(client, id) - .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), - } - } - - fn unsubscribe>(&self, id: T) -> Result<(), Self::Error> { - match self.client.try_read().map_err(|_| (RuntimeClientError::LockError))?.as_ref().unwrap() - { - InnerClient::Http(_) => { - Err(RuntimeClientError::ProviderError(ProviderError::UnsupportedRPC)) - } - InnerClient::Ws(client) => Ok(PubsubClient::unsubscribe(client, id) - .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), - InnerClient::Ipc(client) => Ok(PubsubClient::unsubscribe(client, id) - .map_err(|e| RuntimeClientError::ProviderError(e.into()))?), - } - } -} diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs deleted file mode 100644 index bcfed539ff000..0000000000000 --- a/crates/common/src/types.rs +++ /dev/null @@ -1,210 +0,0 @@ -//! Temporary utility conversion traits between ethers-rs and alloy types. - -use alloy_primitives::{Address, Bloom, Bytes, B256, B64, I256, U256, U64}; -use alloy_rpc_types::{AccessList, AccessListItem, BlockNumberOrTag}; -use alloy_signer_wallet::LocalWallet; -use ethers_core::types::{ - transaction::eip2930::{ - AccessList as EthersAccessList, AccessListItem as EthersAccessListItem, - }, - BlockNumber, Bloom as EthersBloom, Bytes as EthersBytes, H160, H256, H64, I256 as EthersI256, - U256 as EthersU256, U64 as EthersU64, -}; - -/// Conversion trait to easily convert from Ethers types to Alloy types. -pub trait ToAlloy { - /// The corresponding Alloy type. - type To; - - /// Converts the Ethers type to the corresponding Alloy type. - fn to_alloy(self) -> Self::To; -} - -impl ToAlloy for EthersBytes { - type To = Bytes; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - Bytes(self.0) - } -} - -impl ToAlloy for H64 { - type To = B64; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - B64::new(self.0) - } -} - -impl ToAlloy for H160 { - type To = Address; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - Address::new(self.0) - } -} - -impl ToAlloy for H256 { - type To = B256; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - B256::new(self.0) - } -} - -impl ToAlloy for EthersBloom { - type To = Bloom; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - Bloom::new(self.0) - } -} - -impl ToAlloy for EthersU256 { - type To = U256; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - U256::from_limbs(self.0) - } -} - -impl ToAlloy for EthersI256 { - type To = I256; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - I256::from_raw(self.into_raw().to_alloy()) - } -} - -impl ToAlloy for EthersU64 { - type To = U64; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - U64::from_limbs(self.0) - } -} - -impl ToAlloy for u64 { - type To = U256; - - #[inline(always)] - fn to_alloy(self) -> Self::To { - U256::from(self) - } -} - -impl ToEthers for alloy_signer_wallet::LocalWallet { - type To = ethers_signers::LocalWallet; - - fn to_ethers(self) -> Self::To { - ethers_signers::LocalWallet::new_with_signer( - self.signer().clone(), - self.address().to_ethers(), - self.chain_id().unwrap(), - ) - } -} - -impl ToEthers for Vec { - type To = Vec; - - fn to_ethers(self) -> Self::To { - self.into_iter().map(ToEthers::to_ethers).collect() - } -} - -impl ToAlloy for EthersAccessList { - type To = AccessList; - fn to_alloy(self) -> Self::To { - AccessList(self.0.into_iter().map(ToAlloy::to_alloy).collect()) - } -} - -impl ToAlloy for EthersAccessListItem { - type To = AccessListItem; - - fn to_alloy(self) -> Self::To { - AccessListItem { - address: self.address.to_alloy(), - storage_keys: self.storage_keys.into_iter().map(ToAlloy::to_alloy).collect(), - } - } -} - -/// Conversion trait to easily convert from Alloy types to Ethers types. -pub trait ToEthers { - /// The corresponding Ethers type. - type To; - - /// Converts the Alloy type to the corresponding Ethers type. - fn to_ethers(self) -> Self::To; -} - -impl ToEthers for Address { - type To = H160; - - #[inline(always)] - fn to_ethers(self) -> Self::To { - H160(self.0 .0) - } -} - -impl ToEthers for B256 { - type To = H256; - - #[inline(always)] - fn to_ethers(self) -> Self::To { - H256(self.0) - } -} - -impl ToEthers for U256 { - type To = EthersU256; - - #[inline(always)] - fn to_ethers(self) -> Self::To { - EthersU256(self.into_limbs()) - } -} - -impl ToEthers for U64 { - type To = EthersU64; - - #[inline(always)] - fn to_ethers(self) -> Self::To { - EthersU64(self.into_limbs()) - } -} - -impl ToEthers for Bytes { - type To = EthersBytes; - - #[inline(always)] - fn to_ethers(self) -> Self::To { - EthersBytes(self.0) - } -} - -impl ToEthers for BlockNumberOrTag { - type To = BlockNumber; - - #[inline(always)] - fn to_ethers(self) -> Self::To { - match self { - BlockNumberOrTag::Number(n) => BlockNumber::Number(n.into()), - BlockNumberOrTag::Earliest => BlockNumber::Earliest, - BlockNumberOrTag::Latest => BlockNumber::Latest, - BlockNumberOrTag::Pending => BlockNumber::Pending, - BlockNumberOrTag::Finalized => BlockNumber::Finalized, - BlockNumberOrTag::Safe => BlockNumber::Safe, - } - } -} diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 5daa4e96ce52f..db59118844e3e 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -698,7 +698,7 @@ mod tests { fork::{BlockchainDbMeta, CreateFork, JsonBlockCacheDB}, opts::EvmOpts, }; - use foundry_common::provider::alloy::get_http_provider; + use foundry_common::provider::get_http_provider; use foundry_config::{Config, NamedChain}; use std::{collections::BTreeSet, path::PathBuf}; diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 649291a0435cb..4b1e3d6b0f9b1 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -267,7 +267,7 @@ impl DatabaseRef for ForkDbSnapshot { mod tests { use super::*; use crate::fork::BlockchainDbMeta; - use foundry_common::provider::alloy::get_http_provider; + use foundry_common::provider::get_http_provider; use std::collections::BTreeSet; /// Demonstrates that `Database::basic` for `ForkedDatabase` will always return the diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 60096784c60e9..da1f980ffbcb2 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -5,9 +5,7 @@ use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; use foundry_common::provider::{ - alloy::{ProviderBuilder, RetryProvider}, - runtime_transport::RuntimeTransport, - tower::RetryBackoffService, + runtime_transport::RuntimeTransport, tower::RetryBackoffService, ProviderBuilder, RetryProvider, }; use foundry_config::Config; use futures::{ diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index fcd92dd6adf37..682e2444fd4d0 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -4,10 +4,7 @@ use alloy_primitives::{Address, B256, U256}; use alloy_provider::Provider; use alloy_rpc_types::Block; use eyre::WrapErr; -use foundry_common::{ - provider::alloy::{ProviderBuilder, RpcUrl}, - ALCHEMY_FREE_TIER_CUPS, -}; +use foundry_common::{provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS}; use foundry_compilers::utils::RuntimeOrHandle; use foundry_config::{Chain, Config}; use revm::primitives::{BlockEnv, CfgEnv, TxEnv}; @@ -21,7 +18,7 @@ pub struct EvmOpts { /// Fetch state over a remote instead of starting from empty state. #[serde(rename = "eth_rpc_url")] - pub fork_url: Option, + pub fork_url: Option, /// Pins the block number for the state fork. pub fork_block_number: Option, diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 05a7f75f5a92e..9d7b2777d71e7 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,7 +15,11 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # lib @@ -27,7 +31,7 @@ foundry-evm.workspace = true foundry-wallets.workspace = true foundry-linking.workspace = true -ethers-contract.workspace = true +ethers-contract = { workspace = true, features = ["abigen"] } revm-inspectors.workspace = true @@ -105,11 +109,12 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.5", default-features = false, features = ["rustls"] } +svm = { package = "svm-rs", version = "0.5", default-features = false, features = [ + "rustls", +] } tempfile.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } -ethers-core.workspace = true alloy-signer-wallet.workspace = true [features] diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index dfa1c003e63f1..46260ddefbaf7 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -17,7 +17,6 @@ use foundry_cli::{ use foundry_common::{ compile::{self}, fmt::parse_tokens, - provider::alloy::estimate_eip1559_fees, }; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalize}; use serde_json::json; @@ -262,9 +261,7 @@ impl CreateArgs { }; deployer.tx.set_gas_price(gas_price); } else { - let estimate = estimate_eip1559_fees(&provider, Some(chain)) - .await - .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; + let estimate = provider.estimate_eip1559_fees(None).await.wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; let priority_fee = if let Some(priority_fee) = self.tx.priority_gas_price { priority_fee.to() } else { diff --git a/crates/forge/tests/cli/utils.rs b/crates/forge/tests/cli/utils.rs index e8e79fa688720..75523e50a9d8b 100644 --- a/crates/forge/tests/cli/utils.rs +++ b/crates/forge/tests/cli/utils.rs @@ -1,8 +1,8 @@ //! Various helper functions +use alloy_chains::NamedChain; +use alloy_primitives::Address; use alloy_signer_wallet::LocalWallet; -use ethers_core::types::{Address, Chain}; -use foundry_common::types::ToEthers; /// Returns the current millis since unix epoch. /// @@ -14,12 +14,12 @@ pub fn millis_since_epoch() -> u128 { .as_millis() } -pub fn etherscan_key(chain: Chain) -> Option { +pub fn etherscan_key(chain: NamedChain) -> Option { match chain { - Chain::Fantom | Chain::FantomTestnet => { + NamedChain::Fantom | NamedChain::FantomTestnet => { std::env::var("FTMSCAN_API_KEY").or_else(|_| std::env::var("FANTOMSCAN_API_KEY")).ok() } - Chain::OptimismKovan => std::env::var("OP_KOVAN_API_KEY").ok(), + NamedChain::OptimismKovan => std::env::var("OP_KOVAN_API_KEY").ok(), _ => std::env::var("ETHERSCAN_API_KEY").ok(), } } @@ -36,76 +36,75 @@ pub fn network_private_key(chain: &str) -> Option { /// Represents external input required for executing verification requests pub struct EnvExternalities { - pub chain: Chain, + pub chain: NamedChain, pub rpc: String, pub pk: String, pub etherscan: String, pub verifier: String, } -#[allow(dead_code)] impl EnvExternalities { pub fn address(&self) -> Option
{ let pk: LocalWallet = self.pk.parse().ok()?; - Some(pk.address().to_ethers()) + Some(pk.address()) } pub fn goerli() -> Option { Some(Self { - chain: Chain::Goerli, + chain: NamedChain::Goerli, rpc: network_rpc_key("goerli")?, pk: network_private_key("goerli")?, - etherscan: etherscan_key(Chain::Goerli)?, + etherscan: etherscan_key(NamedChain::Goerli)?, verifier: "etherscan".to_string(), }) } pub fn ftm_testnet() -> Option { Some(Self { - chain: Chain::FantomTestnet, + chain: NamedChain::FantomTestnet, rpc: network_rpc_key("ftm_testnet")?, pk: network_private_key("ftm_testnet")?, - etherscan: etherscan_key(Chain::FantomTestnet)?, + etherscan: etherscan_key(NamedChain::FantomTestnet)?, verifier: "etherscan".to_string(), }) } pub fn optimism_kovan() -> Option { Some(Self { - chain: Chain::OptimismKovan, + chain: NamedChain::OptimismKovan, rpc: network_rpc_key("op_kovan")?, pk: network_private_key("op_kovan")?, - etherscan: etherscan_key(Chain::OptimismKovan)?, + etherscan: etherscan_key(NamedChain::OptimismKovan)?, verifier: "etherscan".to_string(), }) } pub fn arbitrum_goerli() -> Option { Some(Self { - chain: Chain::ArbitrumGoerli, + chain: NamedChain::ArbitrumGoerli, rpc: network_rpc_key("arbitrum-goerli")?, pk: network_private_key("arbitrum-goerli")?, - etherscan: etherscan_key(Chain::ArbitrumGoerli)?, + etherscan: etherscan_key(NamedChain::ArbitrumGoerli)?, verifier: "blockscout".to_string(), }) } pub fn mumbai() -> Option { Some(Self { - chain: Chain::PolygonMumbai, + chain: NamedChain::PolygonMumbai, rpc: network_rpc_key("mumbai")?, pk: network_private_key("mumbai")?, - etherscan: etherscan_key(Chain::PolygonMumbai)?, + etherscan: etherscan_key(NamedChain::PolygonMumbai)?, verifier: "etherscan".to_string(), }) } pub fn sepolia() -> Option { Some(Self { - chain: Chain::Sepolia, + chain: NamedChain::Sepolia, rpc: network_rpc_key("sepolia")?, pk: network_private_key("sepolia")?, - etherscan: etherscan_key(Chain::Sepolia)?, + etherscan: etherscan_key(NamedChain::Sepolia)?, verifier: "etherscan".to_string(), }) } diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index cd4decfcbe33c..a278e44d75917 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -4,11 +4,11 @@ use crate::{ ScriptConfig, }; use alloy_chains::Chain; -use alloy_eips::{eip2718::Encodable2718, BlockId}; +use alloy_eips::eip2718::Encodable2718; use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; use alloy_primitives::{utils::format_units, Address, TxHash}; use alloy_provider::{utils::Eip1559Estimation, Provider}; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use alloy_transport::Transport; use eyre::{bail, Context, Result}; use forge_verify::provider::VerificationProviderType; @@ -18,9 +18,7 @@ use foundry_cli::{ utils::{has_batch_support, has_different_gas_calc}, }; use foundry_common::{ - provider::alloy::{ - estimate_eip1559_fees, get_http_provider, try_get_http_provider, RetryProvider, - }, + provider::{get_http_provider, try_get_http_provider, RetryProvider}, shell, }; use foundry_config::Config; @@ -258,9 +256,7 @@ impl BundledState { }), ), (false, _, _) => { - let mut fees = estimate_eip1559_fees(&provider, Some(sequence.chain)) - .await - .wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; + let mut fees = provider.estimate_eip1559_fees(None).await.wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?; if let Some(gas_price) = self.args.with_gas_price { fees.max_fee_per_gas = gas_price.to(); diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 99c1ff7a7fde8..06d76af74ab9e 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -12,7 +12,7 @@ use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_common::{ compile::{ContractSources, ProjectCompiler}, - provider::alloy::try_get_http_provider, + provider::try_get_http_provider, ContractData, ContractsByArtifact, }; use foundry_compilers::{ diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 66d44da0e5e27..ea307de5bd045 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -16,7 +16,7 @@ use foundry_cheatcodes::ScriptWallets; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ fmt::{format_token, format_token_raw}, - provider::alloy::{get_http_provider, RpcUrl}, + provider::get_http_provider, shell, ContractData, ContractsByArtifact, }; use foundry_config::{Config, NamedChain}; @@ -225,7 +225,7 @@ impl PreExecutionState { /// Container for information about RPC-endpoints used during script execution. pub struct RpcData { /// Unique list of rpc urls present. - pub total_rpcs: HashSet, + pub total_rpcs: HashSet, /// If true, one of the transactions did not have a rpc. pub missing_rpc: bool, } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 9500c4d714e30..6445b845044c5 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -19,7 +19,6 @@ use foundry_common::{ abi::{encode_function_args, get_func}, compile::SkipBuildFilter, evm::{Breakpoints, EvmArgs}, - provider::alloy::RpcUrl, shell, ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::ArtifactId; @@ -513,7 +512,7 @@ pub struct ScriptConfig { pub evm_opts: EvmOpts, pub sender_nonce: u64, /// Maps a rpc url to a backend - pub backends: HashMap, + pub backends: HashMap, } impl ScriptConfig { diff --git a/crates/script/src/providers.rs b/crates/script/src/providers.rs index ab2ee99112f9b..aeb94fddf89ba 100644 --- a/crates/script/src/providers.rs +++ b/crates/script/src/providers.rs @@ -1,6 +1,6 @@ use alloy_provider::{utils::Eip1559Estimation, Provider}; use eyre::{Result, WrapErr}; -use foundry_common::provider::alloy::{get_http_provider, RetryProvider, RpcUrl}; +use foundry_common::provider::{get_http_provider, RetryProvider}; use foundry_config::Chain; use std::{ collections::{hash_map::Entry, HashMap}, @@ -11,7 +11,7 @@ use std::{ /// Contains a map of RPC urls to single instances of [`ProviderInfo`]. #[derive(Default)] pub struct ProvidersManager { - pub inner: HashMap, + pub inner: HashMap, } impl ProvidersManager { @@ -32,7 +32,7 @@ impl ProvidersManager { } impl Deref for ProvidersManager { - type Target = HashMap; + type Target = HashMap; fn deref(&self) -> &Self::Target { &self.inner diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 3bdc228f05755..5686f18f68d74 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -5,7 +5,7 @@ use alloy_provider::{PendingTransactionBuilder, Provider}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::Result; use foundry_cli::{init_progress, update_progress}; -use foundry_common::provider::alloy::RetryProvider; +use foundry_common::provider::RetryProvider; use futures::StreamExt; use std::sync::Arc; diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 37926e3080cdc..a27506810ed22 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -17,7 +17,7 @@ use alloy_primitives::{utils::format_units, Address, TxKind, U256}; use eyre::{Context, Result}; use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; use foundry_cli::utils::{has_different_gas_calc, now}; -use foundry_common::{get_contract_name, provider::alloy::RpcUrl, shell, ContractData}; +use foundry_common::{get_contract_name, shell, ContractData}; use foundry_evm::traces::render_trace_arena; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; @@ -199,7 +199,7 @@ impl PreSimulationState { } /// Build [ScriptRunner] forking given RPC for each RPC used in the script. - async fn build_runners(&self) -> Result> { + async fn build_runners(&self) -> Result> { let rpcs = self.execution_artifacts.rpc_data.total_rpcs.clone(); if !shell::verbosity().is_silent() { let n = rpcs.len(); @@ -258,7 +258,7 @@ impl FilledTransactionsState { eyre::bail!("Multi-chain deployment is not supported with libraries."); } - let mut total_gas_per_rpc: HashMap = HashMap::new(); + let mut total_gas_per_rpc: HashMap = HashMap::new(); // Batches sequence of transactions from different rpcs. let mut new_sequence = VecDeque::new(); diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 534b4964138bd..c46301f9f3985 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -3,7 +3,7 @@ use alloy_dyn_abi::JsonAbiExt; use alloy_primitives::{Address, Bytes, TxKind, B256}; use alloy_rpc_types::{request::TransactionRequest, WithOtherFields}; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{fmt::format_token_raw, provider::alloy::RpcUrl, ContractData, SELECTOR_LEN}; +use foundry_common::{fmt::format_token_raw, ContractData, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; use itertools::Itertools; use revm_inspectors::tracing::types::CallKind; @@ -34,7 +34,7 @@ pub struct TransactionWithMetadata { #[serde(default = "default_vec_of_strings")] pub arguments: Option>, #[serde(skip)] - pub rpc: RpcUrl, + pub rpc: String, pub transaction: WithOtherFields, pub additional_contracts: Vec, pub is_fixed_gas_limit: bool, @@ -59,7 +59,7 @@ impl TransactionWithMetadata { pub fn new( transaction: TransactionRequest, - rpc: RpcUrl, + rpc: String, result: &ScriptResult, local_contracts: &BTreeMap, decoder: &CallTraceDecoder, diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 3fa5f07f89957..b14ba2a54f358 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -3,7 +3,7 @@ use alloy_primitives::Address; use alloy_provider::Provider; use alloy_rpc_types::BlockId; use eyre::Result; -use foundry_common::provider::alloy::{get_http_provider, RetryProvider}; +use foundry_common::provider::{get_http_provider, RetryProvider}; use std::{collections::BTreeMap, fs, path::Path, str::FromStr}; const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 91963752d9bad..317a65941f94e 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -10,7 +10,7 @@ use foundry_cli::{ }; use foundry_common::{ compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}, - provider::alloy::ProviderBuilder, + provider::ProviderBuilder, }; use foundry_compilers::{ artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode}, diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index 37526559c7f0b..c28126c43b01f 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -174,16 +174,16 @@ impl Signer for WalletSigner { #[async_trait] impl TxSigner for WalletSigner { + fn address(&self) -> Address { + delegate!(self, inner => alloy_signer::Signer::address(inner)) + } + async fn sign_transaction( &self, tx: &mut dyn SignableTransaction, ) -> alloy_signer::Result { delegate!(self, inner => inner.sign_transaction(tx)).await } - - fn address(&self) -> Address { - delegate!(self, inner => alloy_signer::Signer::address(inner)) - } } /// Signers that require user action to be obtained. From 7f3e880c4542d37137b0278b095745d92fdffe9f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 27 Apr 2024 05:18:48 +0400 Subject: [PATCH 0906/1963] fix: set gas limit to `u64::MAX` (#7795) fix: set block gas limit to u64::MAX instead of u128::MAX --- crates/anvil/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index a5eb3237fa374..ffc648199d6f7 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1042,7 +1042,7 @@ latest block number: {latest_block}" // limit is enabled, since there are networks where this is not used and is always // `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also let gas_limit = if self.disable_block_gas_limit || block.header.gas_limit == 0 { - u128::MAX + u64::MAX as u128 } else { block.header.gas_limit }; From 12e53e575c66d348a3a90e24f6cf393201fd4766 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 27 Apr 2024 07:42:55 +0400 Subject: [PATCH 0907/1963] fix: `eth_feeHistory` (#7792) * Add test * fix * fmt --- crates/anvil/src/eth/api.rs | 23 ++--------------------- crates/anvil/src/eth/backend/mem/mod.rs | 6 +++--- crates/anvil/src/eth/fees.rs | 6 +----- crates/anvil/tests/it/gas.rs | 22 ++++++++++++++++++++++ 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index ba9965faafcd1..3d9a1c4861509 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1313,30 +1313,11 @@ impl EthApi { response.reward = Some(rewards); - // calculate next base fee + // add the next block's base fee to the response // The spec states that `base_fee_per_gas` "[..] includes the next block after the // newest of the returned range, because this value can be derived from the // newest block" - if let (Some(last_gas_used), Some(last_fee_per_gas)) = - (response.gas_used_ratio.last(), response.base_fee_per_gas.last()) - { - let elasticity = self.backend.elasticity(); - let last_fee_per_gas = *last_fee_per_gas as f64; - if last_gas_used > &0.5 { - // increase base gas - let increase = ((last_gas_used - 0.5) * 2f64) * elasticity; - let new_base_fee = (last_fee_per_gas + (last_fee_per_gas * increase)) as u128; - response.base_fee_per_gas.push(new_base_fee); - } else if last_gas_used < &0.5 { - // decrease gas - let increase = ((0.5 - last_gas_used) * 2f64) * elasticity; - let new_base_fee = (last_fee_per_gas - (last_fee_per_gas * increase)) as u128; - response.base_fee_per_gas.push(new_base_fee); - } else { - // same base gas - response.base_fee_per_gas.push(last_fee_per_gas as u128); - } - } + response.base_fee_per_gas.push(self.backend.fees().base_fee()); Ok(response) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 994dde5fd6d67..51b14bb2dcee6 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1055,12 +1055,12 @@ impl Backend { header.base_fee_per_gas.unwrap_or_default(), ); - // notify all listeners - self.notify_on_new_block(header, block_hash); - // update next base fee self.fees.set_base_fee(next_block_base_fee); + // notify all listeners + self.notify_on_new_block(header, block_hash); + outcome } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 142a6a4af38c2..f5534a0cd10cf 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -174,7 +174,6 @@ impl FeeHistoryService { /// Create a new history entry for the block fn create_cache_entry(&self, hash: B256) -> (FeeHistoryCacheItem, Option) { - let elasticity = self.fees.elasticity(); // percentile list from 0.0 to 100.0 with a 0.5 resolution. // this will create 200 percentile points let reward_percentiles: Vec = { @@ -199,10 +198,7 @@ impl FeeHistoryService { block_number = Some(block.header.number); let gas_used = block.header.gas_used as f64; - let gas_limit = block.header.gas_limit as f64; - - let gas_target = gas_limit / elasticity; - item.gas_used_ratio = gas_used / (gas_target * elasticity); + item.gas_used_ratio = gas_used / block.header.gas_limit as f64; // extract useful tx info (gas_used, effective_reward) let mut transactions: Vec<(u128, u128)> = receipts diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index 93cebb90c7247..bca7102cbf6b9 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -170,3 +170,25 @@ async fn test_tip_above_fee_cap() { .to_string() .contains("max priority fee per gas higher than max fee per gas")); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_can_use_fee_history() { + let base_fee = 50u128; + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; + let provider = handle.http_provider(); + + for _ in 0..10 { + let fee_history = provider.get_fee_history(1, Default::default(), &[]).await.unwrap(); + let next_base_fee = fee_history.base_fee_per_gas.last().unwrap(); + + let tx = TransactionRequest::default() + .with_to(Address::random()) + .with_value(U256::from(100)) + .with_gas_price(*next_base_fee); + let tx = WithOtherFields::new(tx); + + let receipt = + provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); + assert!(receipt.inner.inner.is_success()); + } +} From 26e6e57527497a90af1a5409484c01b5e7702a02 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 27 Apr 2024 09:21:09 +0200 Subject: [PATCH 0908/1963] fix: unsafe balance conversion (#7796) --- crates/anvil/src/eth/api.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 3d9a1c4861509..261436b52787d 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2206,8 +2206,8 @@ impl EthApi { } // amount of gas the sender can afford with the `gas_price` let allowance = - available_funds.to::().checked_div(gas_price).unwrap_or_default(); - highest_gas_limit = std::cmp::min(highest_gas_limit, allowance); + available_funds.checked_div(U256::from(gas_price)).unwrap_or_default(); + highest_gas_limit = std::cmp::min(highest_gas_limit, allowance.saturating_to()); } } From 267e14fab654d9ce955dce64c0eb09f01c8538ee Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sun, 28 Apr 2024 16:27:31 +0300 Subject: [PATCH 0909/1963] fix(invariant): shrink when fail-on-revert set to true (#7783) * fix(invariant): shrink when fail-on-revert set to true * Fix test fmt --- .../evm/evm/src/executors/invariant/error.rs | 103 +++++++++--------- .../evm/evm/src/executors/invariant/funcs.rs | 13 +-- crates/evm/evm/src/executors/invariant/mod.rs | 34 +++--- crates/forge/tests/it/invariant.rs | 43 ++++++++ .../common/InvariantShrinkFailOnRevert.t.sol | 26 +++++ 5 files changed, 139 insertions(+), 80 deletions(-) create mode 100644 testdata/default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 5b3ebad91f002..bf84cb4cb908e 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -1,9 +1,9 @@ use super::{BasicTxDetails, InvariantContract}; use crate::executors::{invariant::shrink::CallSequenceShrinker, Executor, RawCallResult}; -use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log}; use eyre::Result; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_config::InvariantConfig; use foundry_evm_core::{constants::CALLER, decode::RevertDecoder}; use foundry_evm_fuzz::{ invariant::FuzzRunIdentifiedContracts, BaseCounterExample, CounterExample, FuzzedCases, Reason, @@ -87,33 +87,26 @@ pub struct FailedInvariantCaseData { /// Address of the invariant asserter. pub addr: Address, /// Function data for invariant check. - pub func: Option, + pub func: Bytes, /// Inner fuzzing Sequence coming from overriding calls. pub inner_sequence: Vec>, /// Shrink the failed test case to the smallest sequence. - pub shrink: bool, + pub shrink_sequence: bool, /// Shrink run limit pub shrink_run_limit: usize, + /// Fail on revert, used to check sequence when shrinking. + pub fail_on_revert: bool, } impl FailedInvariantCaseData { - #[allow(clippy::too_many_arguments)] pub fn new( invariant_contract: &InvariantContract<'_>, + invariant_config: &InvariantConfig, targeted_contracts: &FuzzRunIdentifiedContracts, - error_func: Option<&Function>, calldata: &[BasicTxDetails], call_result: RawCallResult, inner_sequence: &[Option], - shrink: bool, - shrink_run_limit: usize, ) -> Self { - let (func, origin) = if let Some(f) = error_func { - (Some(f.selector().to_vec().into()), f.name.as_str()) - } else { - (None, "Revert") - }; - // Collect abis of fuzzed and invariant contracts to decode custom error. let targets = targeted_contracts.targets.lock(); let abis = targets @@ -125,6 +118,8 @@ impl FailedInvariantCaseData { .with_abis(abis) .decode(call_result.result.as_ref(), Some(call_result.exit_reason)); + let func = invariant_contract.invariant_function; + let origin = func.name.as_str(); Self { logs: call_result.logs, traces: call_result.traces, @@ -135,14 +130,15 @@ impl FailedInvariantCaseData { return_reason: "".into(), revert_reason, addr: invariant_contract.address, - func, + func: func.selector().to_vec().into(), inner_sequence: inner_sequence.to_vec(), - shrink, - shrink_run_limit, + shrink_sequence: invariant_config.shrink_sequence, + shrink_run_limit: invariant_config.shrink_run_limit, + fail_on_revert: invariant_config.fail_on_revert, } } - /// Replays the error case and collects all necessary traces. + /// Replays the error case, shrinks the failing sequence and collects all necessary traces. pub fn replay( &self, mut executor: Executor, @@ -158,7 +154,7 @@ impl FailedInvariantCaseData { TestError::Fail(_, ref calls) => calls.clone(), }; - if self.shrink { + if self.shrink_sequence { calls = self.shrink_sequence(&calls, &executor)?; } else { trace!(target: "forge::test", "Shrinking disabled."); @@ -192,16 +188,14 @@ impl FailedInvariantCaseData { )); // Checks the invariant. - if let Some(func) = &self.func { - let error_call_result = - executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO)?; + let error_call_result = + executor.call_raw(CALLER, self.addr, self.func.clone(), U256::ZERO)?; - traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); + traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); - logs.extend(error_call_result.logs); - if error_call_result.reverted { - break - } + logs.extend(error_call_result.logs); + if error_call_result.reverted { + break } } @@ -221,12 +215,10 @@ impl FailedInvariantCaseData { // Special case test: the invariant is *unsatisfiable* - it took 0 calls to // break the invariant -- consider emitting a warning. - if let Some(func) = &self.func { - let error_call_result = - executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO)?; - if error_call_result.reverted { - return Ok(vec![]); - } + let error_call_result = + executor.call_raw(CALLER, self.addr, self.func.clone(), U256::ZERO)?; + if error_call_result.reverted { + return Ok(vec![]); } let mut shrinker = CallSequenceShrinker::new(calls.len()); @@ -234,10 +226,10 @@ impl FailedInvariantCaseData { // Check candidate sequence result. match self.check_sequence(executor.clone(), calls, shrinker.current().collect()) { // If candidate sequence still fails then shrink more if possible. - false if !shrinker.simplify() => break, + Ok(false) if !shrinker.simplify() => break, // If candidate sequence pass then restore last removed call and shrink other // calls if possible. - true if !shrinker.complicate() => break, + Ok(true) if !shrinker.complicate() => break, _ => {} } } @@ -257,12 +249,24 @@ impl FailedInvariantCaseData { mut executor: Executor, calls: &[BasicTxDetails], sequence: Vec, - ) -> bool { + ) -> Result { + let mut sequence_failed = false; // Apply the shrinked candidate sequence. - sequence.iter().for_each(|call_index| { - let (sender, (addr, bytes)) = &calls[*call_index]; - executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO).unwrap(); - }); + for call_index in sequence { + let (sender, (addr, bytes)) = &calls[call_index]; + let call_result = + executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; + if call_result.reverted && self.fail_on_revert { + // Candidate sequence fails test. + // We don't have to apply remaining calls to check sequence. + sequence_failed = true; + break; + } + } + // Return without checking the invariant if we already have failing sequence. + if sequence_failed { + return Ok(false); + }; // Check the invariant for candidate sequence. // If sequence fails then we can continue with shrinking - the removed call does not affect @@ -270,19 +274,14 @@ impl FailedInvariantCaseData { // // If sequence doesn't fail then we have to restore last removed call and continue with next // call - removed call is a required step for reproducing the failure. - if let Some(func) = &self.func { - let mut call_result = - executor.call_raw(CALLER, self.addr, func.clone(), U256::ZERO).unwrap(); - executor.is_raw_call_success( - self.addr, - Cow::Owned(call_result.state_changeset.take().unwrap()), - &call_result, - false, - ) - } else { - // Invariant function is not set, return true as we cannot test the sequence. - true - } + let mut call_result = + executor.call_raw(CALLER, self.addr, self.func.clone(), U256::ZERO)?; + Ok(executor.is_raw_call_success( + self.addr, + Cow::Owned(call_result.state_changeset.take().unwrap()), + &call_result, + false, + )) } } diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs index b3a913fb3e65f..6753899b15522 100644 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ b/crates/evm/evm/src/executors/invariant/funcs.rs @@ -3,7 +3,9 @@ use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::Log; +use eyre::Result; use foundry_common::{ContractsByAddress, ContractsByArtifact}; +use foundry_config::InvariantConfig; use foundry_evm_core::constants::CALLER; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract}; @@ -16,13 +18,12 @@ use std::borrow::Cow; /// Either returns the call result if successful, or nothing if there was an error. pub fn assert_invariants( invariant_contract: &InvariantContract<'_>, + invariant_config: &InvariantConfig, targeted_contracts: &FuzzRunIdentifiedContracts, executor: &Executor, calldata: &[BasicTxDetails], invariant_failures: &mut InvariantFailures, - shrink_sequence: bool, - shrink_run_limit: usize, -) -> eyre::Result> { +) -> Result> { let mut inner_sequence = vec![]; if let Some(fuzzer) = &executor.inspector.fuzzer { @@ -50,13 +51,11 @@ pub fn assert_invariants( if invariant_failures.error.is_none() { let case_data = FailedInvariantCaseData::new( invariant_contract, + invariant_config, targeted_contracts, - Some(func), calldata, call_result, &inner_sequence, - shrink_sequence, - shrink_run_limit, ); invariant_failures.error = Some(InvariantFuzzError::BrokenInvariant(case_data)); return Ok(None); @@ -78,7 +77,7 @@ pub fn replay_run( coverage: &mut Option, func: Function, inputs: Vec, -) -> eyre::Result<()> { +) -> Result<()> { // We want traces for a failed case. executor.set_tracing(true); diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index d0593d919883b..521fb6722ec83 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -178,12 +178,11 @@ impl<'a> InvariantExecutor<'a> { // This does not count as a fuzz run. It will just register the revert. let last_call_results = RefCell::new(assert_invariants( &invariant_contract, + &self.config, &targeted_contracts, &self.executor, &[], &mut failures.borrow_mut(), - self.config.shrink_sequence, - self.config.shrink_run_limit, )?); if last_call_results.borrow().is_none() { @@ -274,15 +273,13 @@ impl<'a> InvariantExecutor<'a> { let RichInvariantResults { success: can_continue, call_result: call_results } = can_continue( &invariant_contract, + &self.config, call_result, &executor, &inputs, &mut failures.borrow_mut(), &targeted_contracts, &state_changeset, - self.config.fail_on_revert, - self.config.shrink_sequence, - self.config.shrink_run_limit, &mut run_traces, ) .map_err(|e| TestCaseError::fail(e.to_string()))?; @@ -350,7 +347,7 @@ impl<'a> InvariantExecutor<'a> { &mut self, invariant_contract: &InvariantContract<'_>, fuzz_fixtures: &FuzzFixtures, - ) -> eyre::Result { + ) -> Result { // Finds out the chosen deployed contracts and/or senders. self.select_contract_artifacts(invariant_contract.address)?; let (targeted_senders, targeted_contracts) = @@ -405,7 +402,7 @@ impl<'a> InvariantExecutor<'a> { /// Priority: /// /// targetArtifactSelectors > excludeArtifacts > targetArtifacts - pub fn select_contract_artifacts(&mut self, invariant_address: Address) -> eyre::Result<()> { + pub fn select_contract_artifacts(&mut self, invariant_address: Address) -> Result<()> { let result = self .call_sol_default(invariant_address, &IInvariantTest::targetArtifactSelectorsCall {}); @@ -471,7 +468,7 @@ impl<'a> InvariantExecutor<'a> { &mut self, contract: String, selectors: &[FixedBytes<4>], - ) -> eyre::Result { + ) -> Result { if let Some((artifact, contract_data)) = self.project_contracts.find_by_name_or_identifier(&contract)? { @@ -494,7 +491,7 @@ impl<'a> InvariantExecutor<'a> { pub fn select_contracts_and_senders( &self, to: Address, - ) -> eyre::Result<(SenderFilters, FuzzRunIdentifiedContracts)> { + ) -> Result<(SenderFilters, FuzzRunIdentifiedContracts)> { let targeted_senders = self.call_sol_default(to, &IInvariantTest::targetSendersCall {}).targetedSenders; let excluded_senders = @@ -545,7 +542,7 @@ impl<'a> InvariantExecutor<'a> { &self, invariant_address: Address, targeted_contracts: &mut TargetedContracts, - ) -> eyre::Result<()> { + ) -> Result<()> { let interfaces = self .call_sol_default(invariant_address, &IInvariantTest::targetInterfacesCall {}) .targetedInterfaces; @@ -593,7 +590,7 @@ impl<'a> InvariantExecutor<'a> { &self, address: Address, targeted_contracts: &mut TargetedContracts, - ) -> eyre::Result<()> { + ) -> Result<()> { let some_abi_selectors = self .artifact_filters .targeted @@ -696,17 +693,15 @@ fn collect_data( #[allow(clippy::too_many_arguments)] fn can_continue( invariant_contract: &InvariantContract<'_>, + invariant_config: &InvariantConfig, call_result: RawCallResult, executor: &Executor, calldata: &[BasicTxDetails], failures: &mut InvariantFailures, targeted_contracts: &FuzzRunIdentifiedContracts, state_changeset: &StateChangeset, - fail_on_revert: bool, - shrink_sequence: bool, - shrink_run_limit: usize, run_traces: &mut Vec, -) -> eyre::Result { +) -> Result { let mut call_results = None; // Detect handler assertion failures first. @@ -722,12 +717,11 @@ fn can_continue( call_results = assert_invariants( invariant_contract, + invariant_config, targeted_contracts, executor, calldata, failures, - shrink_sequence, - shrink_run_limit, )?; if call_results.is_none() { return Ok(RichInvariantResults::new(false, None)); @@ -736,16 +730,14 @@ fn can_continue( // Increase the amount of reverts. failures.reverts += 1; // If fail on revert is set, we must return immediately. - if fail_on_revert { + if invariant_config.fail_on_revert { let case_data = FailedInvariantCaseData::new( invariant_contract, + invariant_config, targeted_contracts, - None, calldata, call_result, &[], - shrink_sequence, - shrink_run_limit, ); failures.revert_reason = Some(case_data.revert_reason.clone()); let error = InvariantFuzzError::Revert(case_data); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index ee3f0edc34a7d..e906c83569b94 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -177,6 +177,10 @@ async fn test_invariant() { "default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol:ShrinkBigSequenceTest", vec![("invariant_shrink_big_sequence()", true, None, None, None)], ), + ( + "default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol:ShrinkFailOnRevertTest", + vec![("invariant_shrink_fail_on_revert()", true, None, None, None)], + ), ]), ); } @@ -371,6 +375,45 @@ async fn test_shrink_big_sequence() { }; } +#[tokio::test(flavor = "multi_thread")] +#[cfg_attr(windows, ignore = "for some reason there's different rng")] +async fn test_shrink_fail_on_revert() { + let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); + opts.fuzz.seed = Some(U256::from(119u32)); + + let filter = + Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options = opts.clone(); + runner.test_options.invariant.fail_on_revert = true; + runner.test_options.invariant.runs = 1; + runner.test_options.invariant.depth = 100; + let results = runner.test_collect(&filter); + let results = + results.values().last().expect("`InvariantShrinkFailOnRevert` should be testable."); + + let result = results + .test_results + .values() + .last() + .expect("`InvariantShrinkFailOnRevert` should be testable."); + + assert_eq!(result.status, TestStatus::Failure); + + let counter = result + .counterexample + .as_ref() + .expect("`InvariantShrinkFailOnRevert` should have failed with a counterexample."); + + match counter { + CounterExample::Single(_) => panic!("CounterExample should be a sequence."), + CounterExample::Sequence(sequence) => { + // ensure shrinks to sequence of 10 + assert_eq!(sequence.len(), 10); + } + }; +} + #[tokio::test(flavor = "multi_thread")] async fn test_invariant_preserve_state() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"); diff --git a/testdata/default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol b/testdata/default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol new file mode 100644 index 0000000000000..d971367b69988 --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract ShrinkFailOnRevert { + uint256 cond; + + function work(uint256 x) public { + if (x % 2 != 0 && x < 9000) { + cond++; + } + require(cond < 10, "condition met"); + } +} + +contract ShrinkFailOnRevertTest is DSTest { + ShrinkFailOnRevert target; + + function setUp() public { + target = new ShrinkFailOnRevert(); + } + + function invariant_shrink_fail_on_revert() public view {} +} From ea9584f63c901a38bce67e1330bc0555d2bb883f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 02:39:22 +0200 Subject: [PATCH 0910/1963] chore(deps): weekly `cargo update` (#7802) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Locking 34 packages to latest compatible versions Updating ariadne v0.4.0 -> v0.4.1 Updating async-recursion v1.1.0 -> v1.1.1 Updating async-task v4.7.0 -> v4.7.1 Updating aws-config v1.2.0 -> v1.2.1 Updating aws-sdk-kms v1.21.0 -> v1.22.0 Updating aws-sdk-sso v1.20.0 -> v1.21.0 Updating aws-sdk-ssooidc v1.20.0 -> v1.21.0 Updating aws-sdk-sts v1.20.0 -> v1.21.0 Updating aws-sigv4 v1.2.0 -> v1.2.1 Updating blocking v1.5.1 -> v1.6.0 Updating concurrent-queue v2.4.0 -> v2.5.0 Updating event-listener-strategy v0.5.1 -> v0.5.2 Updating fastrand v2.0.2 -> v2.1.0 Updating flate2 v1.0.28 -> v1.0.29 Updating libusb1-sys v0.6.4 -> v0.7.0 Updating lock_api v0.4.11 -> v0.4.12 Updating parking_lot v0.12.1 -> v0.12.2 Updating parking_lot_core v0.9.9 -> v0.9.10 Adding proc-macro-crate v3.1.0 Updating pulldown-cmark v0.10.2 -> v0.10.3 Updating pulldown-cmark-escape v0.10.0 -> v0.10.1 Adding redox_syscall v0.5.1 Updating rusb v0.9.3 -> v0.9.4 Updating rustix v0.38.33 -> v0.38.34 Updating rustls v0.21.11 -> v0.21.12 (latest: v0.23.5) Updating rustls-pki-types v1.4.1 -> v1.5.0 Updating serde v1.0.198 -> v1.0.199 Updating serde_derive v1.0.198 -> v1.0.199 Updating serial_test v3.1.0 -> v3.1.1 Updating serial_test_derive v3.1.0 -> v3.1.1 Adding toml_edit v0.21.1 (latest: v0.22.12) Updating unicode-width v0.1.11 -> v0.1.12 Updating winapi-util v0.1.6 -> v0.1.8 Updating winnow v0.6.6 -> v0.6.7 note: pass `--verbose` to see 168 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 187 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 107 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0076ecc4210dc..97c3c3e93f6af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,7 +128,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.6", + "winnow 0.6.7", ] [[package]] @@ -501,7 +501,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c8d6e74e4feeaa2bcfdecfd3da247ab53c67bd654ba1907270c32e02b142331" dependencies = [ - "winnow 0.6.6", + "winnow 0.6.7", ] [[package]] @@ -826,12 +826,12 @@ dependencies = [ [[package]] name = "ariadne" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd002a6223f12c7a95cdd4b1cb3a0149d22d37f7a9ecdb2cb691a071fe236c29" +checksum = "44055e597c674aef7cb903b2b9f6e4cba1277ed0d2d61dae7cd52d7ffa81f8e2" dependencies = [ "unicode-width", - "yansi 0.5.1", + "yansi 1.0.1", ] [[package]] @@ -981,7 +981,7 @@ checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", - "event-listener-strategy 0.5.1", + "event-listener-strategy 0.5.2", "futures-core", "pin-project-lite", ] @@ -1008,9 +1008,9 @@ dependencies = [ [[package]] name = "async-recursion" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", @@ -1041,9 +1041,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.7.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" @@ -1117,9 +1117,9 @@ checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "aws-config" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a89e0000cde82447155d64eeb71720b933b4396a6fbbebad3f8b4f88ca7b54" +checksum = "b2a4707646259764ab59fd9a50e9de2e92c637b28b36285d6f6fa030e915fbd9" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1183,9 +1183,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1747213c6bb8fae0f388157e07e144fd442c1e28cfd9c4e257b1b6ee26c4a54" +checksum = "4453868f71232e0baf5947972972e87813c8bbb311351f669a6ad6aa5b86ee63" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1205,9 +1205,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fcc572fd5c58489ec205ec3e4e5f7d63018898a485cbf922a462af496bc300" +checksum = "3d70fb493f4183f5102d8a8d0cc9b57aec29a762f55c0e7bf527e0f7177bb408" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1227,9 +1227,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6275fa8684a1192754221173b1f7a7c1260d6b0571cc2b8af09468eb0cffe5" +checksum = "de3f37549b3e38b7ea5efd419d4d7add6ea1e55223506eb0b4fef9d25e7cc90d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1249,9 +1249,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30acd58272fd567e4853c5075d838be1626b59057e0249c9be5a1a7eb13bf70f" +checksum = "3b2ff219a5d4b795cd33251c19dbe9c4b401f2b2cbe513e07c76ada644eaf34e" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1272,9 +1272,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d6f29688a4be9895c0ba8bef861ad0c0dac5c15e9618b9b7a6c233990fc263" +checksum = "58b56f1cbe6fd4d0c2573df72868f20ab1c125ca9c9dbce17927a463433a2e57" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1364,7 +1364,7 @@ dependencies = [ "once_cell", "pin-project-lite", "pin-utils", - "rustls 0.21.11", + "rustls 0.21.12", "tokio", "tracing", ] @@ -1613,18 +1613,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" dependencies = [ "async-channel", "async-lock", "async-task", - "fastrand", "futures-io", "futures-lite", "piper", - "tracing", ] [[package]] @@ -2210,9 +2208,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -3272,9 +3270,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener 5.3.0", "pin-project-lite", @@ -3311,9 +3309,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fastrlp" @@ -3405,7 +3403,7 @@ checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "windows-sys 0.52.0", ] @@ -3430,9 +3428,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "4556222738635b7a3417ae6130d8f52201e45a0c4d1a907f0826383adb5f85e7" dependencies = [ "crc32fast", "miniz_oxide", @@ -4891,7 +4889,7 @@ dependencies = [ "http 0.2.12", "hyper 0.14.28", "log", - "rustls 0.21.11", + "rustls 0.21.12", "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", @@ -5391,9 +5389,9 @@ dependencies = [ [[package]] name = "libusb1-sys" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d0e2afce4245f2c9a418511e5af8718bcaf2fa408aefb259504d1a9cb25f27" +checksum = "da050ade7ac4ff1ba5379af847a10a10a8e284181e060105bf8d86960ce9ce0f" dependencies = [ "cc", "libc", @@ -5409,9 +5407,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -5865,7 +5863,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.60", @@ -6084,9 +6082,9 @@ checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -6094,15 +6092,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -6561,6 +6559,15 @@ dependencies = [ "toml_edit 0.20.7", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -6671,9 +6678,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0530d13d87d1f549b66a3e8d0c688952abe5994e204ed62615baaf25dc029c" +checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ "bitflags 2.5.0", "memchr", @@ -6683,9 +6690,9 @@ dependencies = [ [[package]] name = "pulldown-cmark-escape" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d8f9aa0e3cbcfaf8bf00300004ee3b72f74770f9cbac93f6928771f613276b" +checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3" [[package]] name = "quick-error" @@ -6847,6 +6854,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.4.5" @@ -6931,7 +6947,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.11", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -7198,9 +7214,9 @@ checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" [[package]] name = "rusb" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45fff149b6033f25e825cbb7b2c625a11ee8e6dac09264d49beb125e39aa97bf" +checksum = "ab9f9ff05b63a786553a4c02943b74b34a988448671001e9a27e2f0565cc05a4" dependencies = [ "libc", "libusb1-sys", @@ -7244,9 +7260,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.33" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -7257,9 +7273,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.11" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", @@ -7327,9 +7343,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" [[package]] name = "rustls-webpki" @@ -7614,18 +7630,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.199" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.199" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" dependencies = [ "proc-macro2", "quote", @@ -7709,9 +7725,9 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb86f9315df5df6a70eae0cc22395a44e544a0d8897586820770a35ede74449" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" dependencies = [ "futures", "log", @@ -7723,9 +7739,9 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9bb72430492e9549b0c4596725c0f82729bff861c45aa8099c0a8e67fc3b721" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", @@ -8403,7 +8419,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.11", + "rustls 0.21.12", "tokio", ] @@ -8438,7 +8454,7 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls 0.21.11", + "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", "tungstenite 0.20.1", @@ -8525,6 +8541,17 @@ dependencies = [ "winnow 0.5.40", ] +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow 0.5.40", +] + [[package]] name = "toml_edit" version = "0.22.12" @@ -8535,7 +8562,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.6", + "winnow 0.6.7", ] [[package]] @@ -8712,7 +8739,7 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "rustls 0.21.11", + "rustls 0.21.12", "sha1", "thiserror", "url", @@ -8822,9 +8849,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -9134,11 +9161,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -9381,9 +9408,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" dependencies = [ "memchr", ] From bab83500e220df10231e27f542041d11b73af87a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:03:55 +0300 Subject: [PATCH 0911/1963] chore(invariant): deprecate shrink_sequence, code reuse and cleanup (#7808) * chore(invariant): deprecate shrink_sequence, code reuse and cleanup * Split func mod in replay and result * Update visibility, export only needed --- .../evm/evm/src/executors/invariant/error.rs | 193 +----------------- .../evm/evm/src/executors/invariant/funcs.rs | 121 ----------- crates/evm/evm/src/executors/invariant/mod.rs | 129 +++--------- .../evm/evm/src/executors/invariant/replay.rs | 134 ++++++++++++ .../evm/evm/src/executors/invariant/result.rs | 156 ++++++++++++++ .../evm/evm/src/executors/invariant/shrink.rs | 94 ++++++++- crates/forge/src/runner.rs | 13 +- 7 files changed, 423 insertions(+), 417 deletions(-) delete mode 100644 crates/evm/evm/src/executors/invariant/funcs.rs create mode 100644 crates/evm/evm/src/executors/invariant/replay.rs create mode 100644 crates/evm/evm/src/executors/invariant/result.rs diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index bf84cb4cb908e..e797174a53532 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -1,18 +1,10 @@ use super::{BasicTxDetails, InvariantContract}; -use crate::executors::{invariant::shrink::CallSequenceShrinker, Executor, RawCallResult}; -use alloy_primitives::{Address, Bytes, Log}; -use eyre::Result; -use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use crate::executors::RawCallResult; +use alloy_primitives::{Address, Bytes}; use foundry_config::InvariantConfig; -use foundry_evm_core::{constants::CALLER, decode::RevertDecoder}; -use foundry_evm_fuzz::{ - invariant::FuzzRunIdentifiedContracts, BaseCounterExample, CounterExample, FuzzedCases, Reason, -}; -use foundry_evm_traces::{load_contracts, CallTraceArena, TraceKind, Traces}; -use parking_lot::RwLock; +use foundry_evm_core::decode::RevertDecoder; +use foundry_evm_fuzz::{invariant::FuzzRunIdentifiedContracts, Reason}; use proptest::test_runner::TestError; -use revm::primitives::U256; -use std::{borrow::Cow, sync::Arc}; /// Stores information about failures and reverts of the invariant tests. #[derive(Clone, Default)] @@ -37,23 +29,6 @@ impl InvariantFailures { } } -/// The outcome of an invariant fuzz test -#[derive(Debug)] -pub struct InvariantFuzzTestResult { - pub error: Option, - /// Every successful fuzz test case - pub cases: Vec, - /// Number of reverted fuzz calls - pub reverts: usize, - - /// The entire inputs of the last run of the invariant campaign, used for - /// replaying the run for collecting traces. - pub last_run_inputs: Vec, - - /// Additional traces used for gas report construction. - pub gas_report_traces: Vec>, -} - #[derive(Clone, Debug)] pub enum InvariantFuzzError { Revert(FailedInvariantCaseData), @@ -76,8 +51,6 @@ impl InvariantFuzzError { #[derive(Clone, Debug)] pub struct FailedInvariantCaseData { - pub logs: Vec, - pub traces: Option, /// The proptest error occurred as a result of a test case. pub test_error: TestError>, /// The return reason of the offending call. @@ -121,8 +94,6 @@ impl FailedInvariantCaseData { let func = invariant_contract.invariant_function; let origin = func.name.as_str(); Self { - logs: call_result.logs, - traces: call_result.traces, test_error: proptest::test_runner::TestError::Fail( format!("{origin}, reason: {revert_reason}").into(), calldata.to_vec(), @@ -137,160 +108,4 @@ impl FailedInvariantCaseData { fail_on_revert: invariant_config.fail_on_revert, } } - - /// Replays the error case, shrinks the failing sequence and collects all necessary traces. - pub fn replay( - &self, - mut executor: Executor, - known_contracts: &ContractsByArtifact, - mut ided_contracts: ContractsByAddress, - logs: &mut Vec, - traces: &mut Traces, - ) -> Result> { - let mut counterexample_sequence = vec![]; - let mut calls = match self.test_error { - // Don't use at the moment. - TestError::Abort(_) => return Ok(None), - TestError::Fail(_, ref calls) => calls.clone(), - }; - - if self.shrink_sequence { - calls = self.shrink_sequence(&calls, &executor)?; - } else { - trace!(target: "forge::test", "Shrinking disabled."); - } - - // We want traces for a failed case. - executor.set_tracing(true); - - set_up_inner_replay(&mut executor, &self.inner_sequence); - - // Replay each call from the sequence until we break the invariant. - for (sender, (addr, bytes)) in calls.iter() { - let call_result = - executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; - - logs.extend(call_result.logs); - traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); - - // Identify newly generated contracts, if they exist. - ided_contracts.extend(load_contracts( - vec![(TraceKind::Execution, call_result.traces.clone().unwrap())], - known_contracts, - )); - - counterexample_sequence.push(BaseCounterExample::create( - *sender, - *addr, - bytes, - &ided_contracts, - call_result.traces, - )); - - // Checks the invariant. - let error_call_result = - executor.call_raw(CALLER, self.addr, self.func.clone(), U256::ZERO)?; - - traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); - - logs.extend(error_call_result.logs); - if error_call_result.reverted { - break - } - } - - Ok((!counterexample_sequence.is_empty()) - .then_some(CounterExample::Sequence(counterexample_sequence))) - } - - /// Tries to shrink the failure case to its smallest sequence of calls. - /// - /// If the number of calls is small enough, we can guarantee maximal shrinkage - fn shrink_sequence( - &self, - calls: &[BasicTxDetails], - executor: &Executor, - ) -> Result> { - trace!(target: "forge::test", "Shrinking."); - - // Special case test: the invariant is *unsatisfiable* - it took 0 calls to - // break the invariant -- consider emitting a warning. - let error_call_result = - executor.call_raw(CALLER, self.addr, self.func.clone(), U256::ZERO)?; - if error_call_result.reverted { - return Ok(vec![]); - } - - let mut shrinker = CallSequenceShrinker::new(calls.len()); - for _ in 0..self.shrink_run_limit { - // Check candidate sequence result. - match self.check_sequence(executor.clone(), calls, shrinker.current().collect()) { - // If candidate sequence still fails then shrink more if possible. - Ok(false) if !shrinker.simplify() => break, - // If candidate sequence pass then restore last removed call and shrink other - // calls if possible. - Ok(true) if !shrinker.complicate() => break, - _ => {} - } - } - - // We recreate the call sequence in the same order as they reproduce the failure, - // otherwise we could end up with inverted sequence. - // E.g. in a sequence of: - // 1. Alice calls acceptOwnership and reverts - // 2. Bob calls transferOwnership to Alice - // 3. Alice calls acceptOwnership and test fails - // we shrink to indices of [2, 1] and we recreate call sequence in same order. - Ok(shrinker.current().map(|idx| &calls[idx]).cloned().collect()) - } - - fn check_sequence( - &self, - mut executor: Executor, - calls: &[BasicTxDetails], - sequence: Vec, - ) -> Result { - let mut sequence_failed = false; - // Apply the shrinked candidate sequence. - for call_index in sequence { - let (sender, (addr, bytes)) = &calls[call_index]; - let call_result = - executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; - if call_result.reverted && self.fail_on_revert { - // Candidate sequence fails test. - // We don't have to apply remaining calls to check sequence. - sequence_failed = true; - break; - } - } - // Return without checking the invariant if we already have failing sequence. - if sequence_failed { - return Ok(false); - }; - - // Check the invariant for candidate sequence. - // If sequence fails then we can continue with shrinking - the removed call does not affect - // failure. - // - // If sequence doesn't fail then we have to restore last removed call and continue with next - // call - removed call is a required step for reproducing the failure. - let mut call_result = - executor.call_raw(CALLER, self.addr, self.func.clone(), U256::ZERO)?; - Ok(executor.is_raw_call_success( - self.addr, - Cow::Owned(call_result.state_changeset.take().unwrap()), - &call_result, - false, - )) - } -} - -/// Sets up the calls generated by the internal fuzzer, if they exist. -fn set_up_inner_replay(executor: &mut Executor, inner_sequence: &[Option]) { - if let Some(fuzzer) = &mut executor.inspector.fuzzer { - if let Some(call_generator) = &mut fuzzer.call_generator { - call_generator.last_sequence = Arc::new(RwLock::new(inner_sequence.to_owned())); - call_generator.set_replay(true); - } - } } diff --git a/crates/evm/evm/src/executors/invariant/funcs.rs b/crates/evm/evm/src/executors/invariant/funcs.rs deleted file mode 100644 index 6753899b15522..0000000000000 --- a/crates/evm/evm/src/executors/invariant/funcs.rs +++ /dev/null @@ -1,121 +0,0 @@ -use super::{error::FailedInvariantCaseData, InvariantFailures, InvariantFuzzError}; -use crate::executors::{Executor, RawCallResult}; -use alloy_dyn_abi::JsonAbiExt; -use alloy_json_abi::Function; -use alloy_primitives::Log; -use eyre::Result; -use foundry_common::{ContractsByAddress, ContractsByArtifact}; -use foundry_config::InvariantConfig; -use foundry_evm_core::constants::CALLER; -use foundry_evm_coverage::HitMaps; -use foundry_evm_fuzz::invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract}; -use foundry_evm_traces::{load_contracts, TraceKind, Traces}; -use revm::primitives::U256; -use std::borrow::Cow; - -/// Given the executor state, asserts that no invariant has been broken. Otherwise, it fills the -/// external `invariant_failures.failed_invariant` map and returns a generic error. -/// Either returns the call result if successful, or nothing if there was an error. -pub fn assert_invariants( - invariant_contract: &InvariantContract<'_>, - invariant_config: &InvariantConfig, - targeted_contracts: &FuzzRunIdentifiedContracts, - executor: &Executor, - calldata: &[BasicTxDetails], - invariant_failures: &mut InvariantFailures, -) -> Result> { - let mut inner_sequence = vec![]; - - if let Some(fuzzer) = &executor.inspector.fuzzer { - if let Some(call_generator) = &fuzzer.call_generator { - inner_sequence.extend(call_generator.last_sequence.read().iter().cloned()); - } - } - - let func = invariant_contract.invariant_function; - let mut call_result = executor.call_raw( - CALLER, - invariant_contract.address, - func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), - U256::ZERO, - )?; - - let is_err = !executor.is_raw_call_success( - invariant_contract.address, - Cow::Owned(call_result.state_changeset.take().unwrap()), - &call_result, - false, - ); - if is_err { - // We only care about invariants which we haven't broken yet. - if invariant_failures.error.is_none() { - let case_data = FailedInvariantCaseData::new( - invariant_contract, - invariant_config, - targeted_contracts, - calldata, - call_result, - &inner_sequence, - ); - invariant_failures.error = Some(InvariantFuzzError::BrokenInvariant(case_data)); - return Ok(None); - } - } - - Ok(Some(call_result)) -} - -/// Replays the provided invariant run for collecting the logs and traces from all depths. -#[allow(clippy::too_many_arguments)] -pub fn replay_run( - invariant_contract: &InvariantContract<'_>, - mut executor: Executor, - known_contracts: &ContractsByArtifact, - mut ided_contracts: ContractsByAddress, - logs: &mut Vec, - traces: &mut Traces, - coverage: &mut Option, - func: Function, - inputs: Vec, -) -> Result<()> { - // We want traces for a failed case. - executor.set_tracing(true); - - // set_up_inner_replay(&mut executor, &inputs); - - // Replay each call from the sequence until we break the invariant. - for (sender, (addr, bytes)) in inputs.iter() { - let call_result = - executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; - - logs.extend(call_result.logs); - traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); - - if let Some(new_coverage) = call_result.coverage { - if let Some(old_coverage) = coverage { - *coverage = Some(std::mem::take(old_coverage).merge(new_coverage)); - } else { - *coverage = Some(new_coverage); - } - } - - // Identify newly generated contracts, if they exist. - ided_contracts.extend(load_contracts( - vec![(TraceKind::Execution, call_result.traces.clone().unwrap())], - known_contracts, - )); - - // Checks the invariant. - let error_call_result = executor.call_raw( - CALLER, - invariant_contract.address, - func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), - U256::ZERO, - )?; - - traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); - - logs.extend(error_call_result.logs); - } - Ok(()) -} diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 521fb6722ec83..37d433a315db9 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -9,7 +9,7 @@ use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::InvariantConfig; use foundry_evm_core::{ constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME}, - utils::{get_function, StateChangeset}, + utils::get_function, }; use foundry_evm_fuzz::{ invariant::{ @@ -28,17 +28,21 @@ use proptest::{ strategy::{BoxedStrategy, Strategy}, test_runner::{TestCaseError, TestRunner}, }; +use result::{assert_invariants, can_continue}; use revm::{primitives::HashMap, DatabaseCommit}; -use std::{borrow::Cow, cell::RefCell, collections::BTreeMap, sync::Arc}; +use shrink::shrink_sequence; +use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; mod error; -use self::error::FailedInvariantCaseData; -pub use error::{InvariantFailures, InvariantFuzzError, InvariantFuzzTestResult}; +pub use error::{InvariantFailures, InvariantFuzzError}; -mod funcs; -mod shrink; +mod replay; +pub use replay::{replay_error, replay_run}; + +mod result; +pub use result::InvariantFuzzTestResult; -pub use funcs::{assert_invariants, replay_run}; +mod shrink; sol! { interface IInvariantTest { @@ -93,20 +97,6 @@ sol! { type InvariantPreparation = (EvmFuzzState, FuzzRunIdentifiedContracts, BoxedStrategy); -/// Enriched results of an invariant run check. -/// -/// Contains the success condition and call results of the last run -struct RichInvariantResults { - success: bool, - call_result: Option, -} - -impl RichInvariantResults { - fn new(success: bool, call_result: Option) -> Self { - Self { success, call_result } - } -} - /// Wrapper around any [`Executor`] implementor which provides fuzzing support using [`proptest`]. /// /// After instantiation, calling `fuzz` will proceed to hammer the deployed smart contracts with @@ -157,6 +147,10 @@ impl<'a> InvariantExecutor<'a> { return Err(eyre!("Invariant test function should have no inputs")) } + if !self.config.shrink_sequence { + error!(target: "forge::test", "shrink_sequence config is deprecated and will be removed, use shrink_run_limit = 0") + } + let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract, fuzz_fixtures)?; @@ -270,29 +264,28 @@ impl<'a> InvariantExecutor<'a> { stipend: call_result.stipend, }); - let RichInvariantResults { success: can_continue, call_result: call_results } = - can_continue( - &invariant_contract, - &self.config, - call_result, - &executor, - &inputs, - &mut failures.borrow_mut(), - &targeted_contracts, - &state_changeset, - &mut run_traces, - ) - .map_err(|e| TestCaseError::fail(e.to_string()))?; + let result = can_continue( + &invariant_contract, + &self.config, + call_result, + &executor, + &inputs, + &mut failures.borrow_mut(), + &targeted_contracts, + &state_changeset, + &mut run_traces, + ) + .map_err(|e| TestCaseError::fail(e.to_string()))?; - if !can_continue || current_run == self.config.depth - 1 { + if !result.can_continue || current_run == self.config.depth - 1 { last_run_calldata.borrow_mut().clone_from(&inputs); } - if !can_continue { + if !result.can_continue { break } - *last_call_results.borrow_mut() = call_results; + *last_call_results.borrow_mut() = result.call_result; current_run += 1; } @@ -686,65 +679,3 @@ fn collect_data( state_changeset.insert(*sender, changed); } } - -/// Verifies that the invariant run execution can continue. -/// Returns the mapping of (Invariant Function Name -> Call Result, Logs, Traces) if invariants were -/// asserted. -#[allow(clippy::too_many_arguments)] -fn can_continue( - invariant_contract: &InvariantContract<'_>, - invariant_config: &InvariantConfig, - call_result: RawCallResult, - executor: &Executor, - calldata: &[BasicTxDetails], - failures: &mut InvariantFailures, - targeted_contracts: &FuzzRunIdentifiedContracts, - state_changeset: &StateChangeset, - run_traces: &mut Vec, -) -> Result { - let mut call_results = None; - - // Detect handler assertion failures first. - let handlers_failed = targeted_contracts.targets.lock().iter().any(|contract| { - !executor.is_success(*contract.0, false, Cow::Borrowed(state_changeset), false) - }); - - // Assert invariants IF the call did not revert and the handlers did not fail. - if !call_result.reverted && !handlers_failed { - if let Some(traces) = call_result.traces { - run_traces.push(traces); - } - - call_results = assert_invariants( - invariant_contract, - invariant_config, - targeted_contracts, - executor, - calldata, - failures, - )?; - if call_results.is_none() { - return Ok(RichInvariantResults::new(false, None)); - } - } else { - // Increase the amount of reverts. - failures.reverts += 1; - // If fail on revert is set, we must return immediately. - if invariant_config.fail_on_revert { - let case_data = FailedInvariantCaseData::new( - invariant_contract, - invariant_config, - targeted_contracts, - calldata, - call_result, - &[], - ); - failures.revert_reason = Some(case_data.revert_reason.clone()); - let error = InvariantFuzzError::Revert(case_data); - failures.error = Some(error); - - return Ok(RichInvariantResults::new(false, None)); - } - } - Ok(RichInvariantResults::new(true, call_results)) -} diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs new file mode 100644 index 0000000000000..941df781aacf8 --- /dev/null +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -0,0 +1,134 @@ +use super::{error::FailedInvariantCaseData, shrink_sequence}; +use crate::executors::Executor; +use alloy_dyn_abi::JsonAbiExt; +use alloy_primitives::Log; +use eyre::Result; +use foundry_common::{ContractsByAddress, ContractsByArtifact}; +use foundry_evm_core::constants::CALLER; +use foundry_evm_coverage::HitMaps; +use foundry_evm_fuzz::{ + invariant::{BasicTxDetails, InvariantContract}, + BaseCounterExample, CounterExample, +}; +use foundry_evm_traces::{load_contracts, TraceKind, Traces}; +use parking_lot::RwLock; +use proptest::test_runner::TestError; +use revm::primitives::U256; +use std::sync::Arc; + +/// Replays a call sequence for collecting logs and traces. +/// Returns counterexample to be used when the call sequence is a failed scenario. +#[allow(clippy::too_many_arguments)] +pub fn replay_run( + invariant_contract: &InvariantContract<'_>, + mut executor: Executor, + known_contracts: &ContractsByArtifact, + mut ided_contracts: ContractsByAddress, + logs: &mut Vec, + traces: &mut Traces, + coverage: &mut Option, + inputs: Vec, +) -> Result> { + // We want traces for a failed case. + executor.set_tracing(true); + + let mut counterexample_sequence = vec![]; + + // Replay each call from the sequence, collect logs, traces and coverage. + for (sender, (addr, bytes)) in inputs.iter() { + let call_result = + executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; + logs.extend(call_result.logs); + traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); + + if let Some(new_coverage) = call_result.coverage { + if let Some(old_coverage) = coverage { + *coverage = Some(std::mem::take(old_coverage).merge(new_coverage)); + } else { + *coverage = Some(new_coverage); + } + } + + // Identify newly generated contracts, if they exist. + ided_contracts.extend(load_contracts( + vec![(TraceKind::Execution, call_result.traces.clone().unwrap())], + known_contracts, + )); + + // Create counter example to be used in failed case. + counterexample_sequence.push(BaseCounterExample::create( + *sender, + *addr, + bytes, + &ided_contracts, + call_result.traces, + )); + + // Replay invariant to collect logs and traces. + let error_call_result = executor.call_raw( + CALLER, + invariant_contract.address, + invariant_contract + .invariant_function + .abi_encode_input(&[]) + .expect("invariant should have no inputs") + .into(), + U256::ZERO, + )?; + traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); + logs.extend(error_call_result.logs); + } + + Ok((!counterexample_sequence.is_empty()) + .then_some(CounterExample::Sequence(counterexample_sequence))) +} + +/// Replays the error case, shrinks the failing sequence and collects all necessary traces. +#[allow(clippy::too_many_arguments)] +pub fn replay_error( + failed_case: &FailedInvariantCaseData, + invariant_contract: &InvariantContract<'_>, + mut executor: Executor, + known_contracts: &ContractsByArtifact, + ided_contracts: ContractsByAddress, + logs: &mut Vec, + traces: &mut Traces, + coverage: &mut Option, +) -> Result> { + match failed_case.test_error { + // Don't use at the moment. + TestError::Abort(_) => Ok(None), + TestError::Fail(_, ref calls) => { + // Shrink sequence of failed calls. + let calls = if failed_case.shrink_sequence { + shrink_sequence(failed_case, calls, &executor)? + } else { + trace!(target: "forge::test", "Shrinking disabled."); + calls.clone() + }; + + set_up_inner_replay(&mut executor, &failed_case.inner_sequence); + // Replay calls to get the counterexample and to collect logs, traces and coverage. + replay_run( + invariant_contract, + executor, + known_contracts, + ided_contracts, + logs, + traces, + coverage, + calls, + ) + } + } +} + +/// Sets up the calls generated by the internal fuzzer, if they exist. +fn set_up_inner_replay(executor: &mut Executor, inner_sequence: &[Option]) { + if let Some(fuzzer) = &mut executor.inspector.fuzzer { + if let Some(call_generator) = &mut fuzzer.call_generator { + call_generator.last_sequence = Arc::new(RwLock::new(inner_sequence.to_owned())); + call_generator.set_replay(true); + } + } +} diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs new file mode 100644 index 0000000000000..8b2acc56cbd23 --- /dev/null +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -0,0 +1,156 @@ +use super::{error::FailedInvariantCaseData, InvariantFailures, InvariantFuzzError}; +use crate::executors::{Executor, RawCallResult}; +use alloy_dyn_abi::JsonAbiExt; +use eyre::Result; +use foundry_config::InvariantConfig; +use foundry_evm_core::{constants::CALLER, utils::StateChangeset}; +use foundry_evm_fuzz::{ + invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract}, + FuzzedCases, +}; +use revm::primitives::U256; +use revm_inspectors::tracing::CallTraceArena; +use std::borrow::Cow; + +/// The outcome of an invariant fuzz test +#[derive(Debug)] +pub struct InvariantFuzzTestResult { + pub error: Option, + /// Every successful fuzz test case + pub cases: Vec, + /// Number of reverted fuzz calls + pub reverts: usize, + /// The entire inputs of the last run of the invariant campaign, used for + /// replaying the run for collecting traces. + pub last_run_inputs: Vec, + /// Additional traces used for gas report construction. + pub gas_report_traces: Vec>, +} + +/// Enriched results of an invariant run check. +/// +/// Contains the success condition and call results of the last run +pub(crate) struct RichInvariantResults { + pub(crate) can_continue: bool, + pub(crate) call_result: Option, +} + +impl RichInvariantResults { + fn new(can_continue: bool, call_result: Option) -> Self { + Self { can_continue, call_result } + } +} + +/// Given the executor state, asserts that no invariant has been broken. Otherwise, it fills the +/// external `invariant_failures.failed_invariant` map and returns a generic error. +/// Either returns the call result if successful, or nothing if there was an error. +pub(crate) fn assert_invariants( + invariant_contract: &InvariantContract<'_>, + invariant_config: &InvariantConfig, + targeted_contracts: &FuzzRunIdentifiedContracts, + executor: &Executor, + calldata: &[BasicTxDetails], + invariant_failures: &mut InvariantFailures, +) -> Result> { + let mut inner_sequence = vec![]; + + if let Some(fuzzer) = &executor.inspector.fuzzer { + if let Some(call_generator) = &fuzzer.call_generator { + inner_sequence.extend(call_generator.last_sequence.read().iter().cloned()); + } + } + + let func = invariant_contract.invariant_function; + let mut call_result = executor.call_raw( + CALLER, + invariant_contract.address, + func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), + U256::ZERO, + )?; + + let is_err = !executor.is_raw_call_success( + invariant_contract.address, + Cow::Owned(call_result.state_changeset.take().unwrap()), + &call_result, + false, + ); + if is_err { + // We only care about invariants which we haven't broken yet. + if invariant_failures.error.is_none() { + let case_data = FailedInvariantCaseData::new( + invariant_contract, + invariant_config, + targeted_contracts, + calldata, + call_result, + &inner_sequence, + ); + invariant_failures.error = Some(InvariantFuzzError::BrokenInvariant(case_data)); + return Ok(None); + } + } + + Ok(Some(call_result)) +} + +/// Verifies that the invariant run execution can continue. +/// Returns the mapping of (Invariant Function Name -> Call Result, Logs, Traces) if invariants were +/// asserted. +#[allow(clippy::too_many_arguments)] +pub(crate) fn can_continue( + invariant_contract: &InvariantContract<'_>, + invariant_config: &InvariantConfig, + call_result: RawCallResult, + executor: &Executor, + calldata: &[BasicTxDetails], + failures: &mut InvariantFailures, + targeted_contracts: &FuzzRunIdentifiedContracts, + state_changeset: &StateChangeset, + run_traces: &mut Vec, +) -> Result { + let mut call_results = None; + + // Detect handler assertion failures first. + let handlers_failed = targeted_contracts.targets.lock().iter().any(|contract| { + !executor.is_success(*contract.0, false, Cow::Borrowed(state_changeset), false) + }); + + // Assert invariants IF the call did not revert and the handlers did not fail. + if !call_result.reverted && !handlers_failed { + if let Some(traces) = call_result.traces { + run_traces.push(traces); + } + + call_results = assert_invariants( + invariant_contract, + invariant_config, + targeted_contracts, + executor, + calldata, + failures, + )?; + if call_results.is_none() { + return Ok(RichInvariantResults::new(false, None)); + } + } else { + // Increase the amount of reverts. + failures.reverts += 1; + // If fail on revert is set, we must return immediately. + if invariant_config.fail_on_revert { + let case_data = FailedInvariantCaseData::new( + invariant_contract, + invariant_config, + targeted_contracts, + calldata, + call_result, + &[], + ); + failures.revert_reason = Some(case_data.revert_reason.clone()); + let error = InvariantFuzzError::Revert(case_data); + failures.error = Some(error); + + return Ok(RichInvariantResults::new(false, None)); + } + } + Ok(RichInvariantResults::new(true, call_results)) +} diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index 09f890c65dda9..bfa592136eafe 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -1,4 +1,9 @@ +use crate::executors::{invariant::error::FailedInvariantCaseData, Executor}; +use alloy_primitives::U256; +use foundry_evm_core::constants::CALLER; +use foundry_evm_fuzz::invariant::BasicTxDetails; use proptest::bits::{BitSetLike, VarBitSet}; +use std::borrow::Cow; #[derive(Clone, Copy, Debug)] struct Shrink { @@ -10,7 +15,7 @@ struct Shrink { /// If the failure is still reproducible with removed call then moves to the next one. /// If the failure is not reproducible then restore removed call and moves to next one. #[derive(Debug)] -pub(crate) struct CallSequenceShrinker { +struct CallSequenceShrinker { /// Length of call sequence to be shrinked. call_sequence_len: usize, /// Call ids contained in current shrinked sequence. @@ -22,7 +27,7 @@ pub(crate) struct CallSequenceShrinker { } impl CallSequenceShrinker { - pub(crate) fn new(call_sequence_len: usize) -> Self { + fn new(call_sequence_len: usize) -> Self { Self { call_sequence_len, included_calls: VarBitSet::saturated(call_sequence_len), @@ -32,12 +37,12 @@ impl CallSequenceShrinker { } /// Return candidate shrink sequence to be tested, by removing ids from original sequence. - pub(crate) fn current(&self) -> impl Iterator + '_ { + fn current(&self) -> impl Iterator + '_ { (0..self.call_sequence_len).filter(|&call_id| self.included_calls.test(call_id)) } /// Removes next call from sequence. - pub(crate) fn simplify(&mut self) -> bool { + fn simplify(&mut self) -> bool { if self.shrink.call_index >= self.call_sequence_len { // We reached the end of call sequence, nothing left to simplify. false @@ -53,7 +58,7 @@ impl CallSequenceShrinker { } /// Reverts removed call from sequence and tries to simplify next call. - pub(crate) fn complicate(&mut self) -> bool { + fn complicate(&mut self) -> bool { match self.prev_shrink { Some(shrink) => { // Undo the last call removed. @@ -66,3 +71,82 @@ impl CallSequenceShrinker { } } } + +/// Shrinks the failure case to its smallest sequence of calls. +/// +/// Maximal shrinkage is guaranteed if the shrink_run_limit is not set to a value lower than the +/// length of failed call sequence. +/// +/// The shrinked call sequence always respect the order failure is reproduced as it is tested +/// top-down. +pub(crate) fn shrink_sequence( + failed_case: &FailedInvariantCaseData, + calls: &[BasicTxDetails], + executor: &Executor, +) -> eyre::Result> { + trace!(target: "forge::test", "Shrinking."); + + // Special case test: the invariant is *unsatisfiable* - it took 0 calls to + // break the invariant -- consider emitting a warning. + let error_call_result = + executor.call_raw(CALLER, failed_case.addr, failed_case.func.clone(), U256::ZERO)?; + if error_call_result.reverted { + return Ok(vec![]); + } + + let mut shrinker = CallSequenceShrinker::new(calls.len()); + for _ in 0..failed_case.shrink_run_limit { + // Check candidate sequence result. + match check_sequence(failed_case, executor.clone(), calls, shrinker.current().collect()) { + // If candidate sequence still fails then shrink more if possible. + Ok(false) if !shrinker.simplify() => break, + // If candidate sequence pass then restore last removed call and shrink other + // calls if possible. + Ok(true) if !shrinker.complicate() => break, + _ => {} + } + } + + Ok(shrinker.current().map(|idx| &calls[idx]).cloned().collect()) +} + +/// Checks if the shrinked sequence fails test, if it does then we can try simplifying more. +fn check_sequence( + failed_case: &FailedInvariantCaseData, + mut executor: Executor, + calls: &[BasicTxDetails], + sequence: Vec, +) -> eyre::Result { + let mut sequence_failed = false; + // Apply the shrinked candidate sequence. + for call_index in sequence { + let (sender, (addr, bytes)) = &calls[call_index]; + let call_result = + executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; + if call_result.reverted && failed_case.fail_on_revert { + // Candidate sequence fails test. + // We don't have to apply remaining calls to check sequence. + sequence_failed = true; + break; + } + } + // Return without checking the invariant if we already have failing sequence. + if sequence_failed { + return Ok(false); + }; + + // Check the invariant for candidate sequence. + // If sequence fails then we can continue with shrinking - the removed call does not affect + // failure. + // + // If sequence doesn't fail then we have to restore last removed call and continue with next + // call - removed call is a required step for reproducing the failure. + let mut call_result = + executor.call_raw(CALLER, failed_case.addr, failed_case.func.clone(), U256::ZERO)?; + Ok(executor.is_raw_call_success( + failed_case.addr, + Cow::Owned(call_result.state_changeset.take().unwrap()), + &call_result, + false, + )) +} diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index ed48bdc34494b..b29309bb0ac45 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -20,7 +20,10 @@ use foundry_evm::{ decode::{decode_console_logs, RevertDecoder}, executors::{ fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, - invariant::{replay_run, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult}, + invariant::{ + replay_error, replay_run, InvariantExecutor, InvariantFuzzError, + InvariantFuzzTestResult, + }, CallResult, EvmError, ExecutionErr, Executor, RawCallResult, }, fuzz::{fixture_name, invariant::InvariantContract, CounterExample, FuzzFixtures}, @@ -580,12 +583,17 @@ impl<'a> ContractRunner<'a> { Some(error) => match error { InvariantFuzzError::BrokenInvariant(case_data) | InvariantFuzzError::Revert(case_data) => { - match case_data.replay( + // Replay error to create counterexample and to collect logs, traces and + // coverage. + match replay_error( + &case_data, + &invariant_contract, self.executor.clone(), known_contracts, identified_contracts.clone(), &mut logs, &mut traces, + &mut coverage, ) { Ok(c) => counterexample = c, Err(err) => { @@ -607,7 +615,6 @@ impl<'a> ContractRunner<'a> { &mut logs, &mut traces, &mut coverage, - func.clone(), last_run_inputs.clone(), ) { error!(%err, "Failed to replay last invariant run"); From 39d68815ac9ae4458baf2c661d4d70ee4767cd70 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:18:37 +0300 Subject: [PATCH 0912/1963] fix(fuzz): remove fuzz dir on forge clean (#7809) --- crates/forge/bin/main.rs | 5 +++++ crates/forge/tests/cli/cmd.rs | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 1c7095026e294..2aaa82d62fdbd 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -82,6 +82,11 @@ fn main() -> Result<()> { ForgeSubcommand::Clean { root } => { let config = utils::load_config_with_root(root); config.project()?.cleanup()?; + + // Remove fuzz cache directory. + if let Some(fuzz_cache) = config.fuzz.failure_persist_dir { + let _ = std::fs::remove_dir_all(fuzz_cache); + } Ok(()) } ForgeSubcommand::Snapshot(cmd) => { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index df6a306f5cab1..a4deb8bcef3de 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2,7 +2,9 @@ use crate::constants::*; use foundry_compilers::{artifacts::Metadata, remappings::Remapping, ConfigurableContractArtifact}; -use foundry_config::{parse_with_profile, BasicConfig, Chain, Config, SolidityErrorCode}; +use foundry_config::{ + parse_with_profile, BasicConfig, Chain, Config, FuzzConfig, SolidityErrorCode, +}; use foundry_test_utils::{ foundry_compilers::PathStyle, rpc::next_etherscan_api_key, @@ -544,6 +546,20 @@ forgetest_init!(can_clean_config, |prj, cmd| { assert!(!artifact.exists()); }); +// checks that `clean` removes fuzz cache dir +forgetest_init!(can_clean_fuzz_cache, |prj, cmd| { + let config = Config { fuzz: FuzzConfig::new("cache/fuzz".into()), ..Default::default() }; + prj.write_config(config); + // default test contract is written in custom out directory + let cache_dir = prj.root().join("cache/fuzz"); + let _ = fs::create_dir(cache_dir.clone()); + assert!(cache_dir.exists()); + + cmd.forge_fuse().arg("clean"); + cmd.output(); + assert!(!cache_dir.exists()); +}); + // checks that extra output works forgetest_init!(can_emit_extra_output, |prj, cmd| { cmd.args(["build", "--extra-output", "metadata"]); From f0d9eeced8ec01045b2849ea2cc3c72773282d70 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:25:38 +0300 Subject: [PATCH 0913/1963] chore(fuzz): delete fuzz dir relative to proj root (#7810) --- crates/forge/bin/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 2aaa82d62fdbd..eb676b88806b7 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -81,11 +81,12 @@ fn main() -> Result<()> { } ForgeSubcommand::Clean { root } => { let config = utils::load_config_with_root(root); - config.project()?.cleanup()?; + let proj = config.project()?; + proj.cleanup()?; // Remove fuzz cache directory. if let Some(fuzz_cache) = config.fuzz.failure_persist_dir { - let _ = std::fs::remove_dir_all(fuzz_cache); + let _ = std::fs::remove_dir_all(proj.root().join(fuzz_cache)); } Ok(()) } From a6e7fe0cbd1d55c069c0523c37eec3c349d279b7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 30 Apr 2024 03:37:09 +0200 Subject: [PATCH 0914/1963] chore: sync `forge clean` and `--force` implementations (#7815) --- crates/config/src/lib.rs | 19 +++++++++++++++++-- crates/forge/bin/main.rs | 9 ++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 65923ced798a6..7c8dcdb8cb37d 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -20,7 +20,7 @@ use foundry_compilers::{ RevertStrings, Settings, SettingsMetadata, Severity, }, cache::SOLIDITY_FILES_CACHE_FILENAME, - error::SolcError, + error::{SolcError, SolcIoError}, remappings::{RelativeRemapping, Remapping}, ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, SolcConfig, }; @@ -691,7 +691,7 @@ impl Config { .build()?; if self.force { - project.cleanup()?; + self.cleanup(&project)?; } if let Some(solc) = self.ensure_solc()? { @@ -701,6 +701,21 @@ impl Config { Ok(project) } + /// Cleans the project. + pub fn cleanup(&self, project: &Project) -> Result<(), SolcError> { + project.cleanup()?; + + // Remove fuzz cache directory. + if let Some(fuzz_cache) = &self.fuzz.failure_persist_dir { + let path = project.root().join(fuzz_cache); + if path.exists() { + std::fs::remove_dir_all(&path).map_err(|e| SolcIoError::new(e, path))?; + } + } + + Ok(()) + } + /// Ensures that the configured version is installed if explicitly set /// /// If `solc` is [`SolcReq::Version`] then this will download and install the solc version if diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index eb676b88806b7..f598c1212e617 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -81,13 +81,8 @@ fn main() -> Result<()> { } ForgeSubcommand::Clean { root } => { let config = utils::load_config_with_root(root); - let proj = config.project()?; - proj.cleanup()?; - - // Remove fuzz cache directory. - if let Some(fuzz_cache) = config.fuzz.failure_persist_dir { - let _ = std::fs::remove_dir_all(proj.root().join(fuzz_cache)); - } + let project = config.project()?; + config.cleanup(&project)?; Ok(()) } ForgeSubcommand::Snapshot(cmd) => { From ba399ae5ec1562367d689b6e060fda4996ad409e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 30 Apr 2024 11:52:53 +0200 Subject: [PATCH 0915/1963] perf: support FigmentProviders settings (#7812) --- crates/config/src/lib.rs | 171 ++++++++++++++++++++++-------------- crates/config/src/macros.rs | 6 +- 2 files changed, 108 insertions(+), 69 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 7c8dcdb8cb37d..5e760d3b69ffb 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -509,6 +509,86 @@ impl Config { Ok(config) } + /// Returns the populated [Figment] using the requested [FigmentProviders] preset. + /// + /// This will merge various providers, such as env,toml,remappings into the figment. + pub fn to_figment(self, providers: FigmentProviders) -> Figment { + let mut c = self; + let profile = Config::selected_profile(); + let mut figment = Figment::default().merge(DappHardhatDirProvider(&c.__root.0)); + + // merge global foundry.toml file + if let Some(global_toml) = Config::foundry_dir_toml().filter(|p| p.exists()) { + figment = Config::merge_toml_provider( + figment, + TomlFileProvider::new(None, global_toml).cached(), + profile.clone(), + ); + } + // merge local foundry.toml file + figment = Config::merge_toml_provider( + figment, + TomlFileProvider::new(Some("FOUNDRY_CONFIG"), c.__root.0.join(Config::FILE_NAME)) + .cached(), + profile.clone(), + ); + + // merge environment variables + figment = figment + .merge( + Env::prefixed("DAPP_") + .ignore(&["REMAPPINGS", "LIBRARIES", "FFI", "FS_PERMISSIONS"]) + .global(), + ) + .merge( + Env::prefixed("DAPP_TEST_") + .ignore(&["CACHE", "FUZZ_RUNS", "DEPTH", "FFI", "FS_PERMISSIONS"]) + .global(), + ) + .merge(DappEnvCompatProvider) + .merge(EtherscanEnvProvider::default()) + .merge( + Env::prefixed("FOUNDRY_") + .ignore(&["PROFILE", "REMAPPINGS", "LIBRARIES", "FFI", "FS_PERMISSIONS"]) + .map(|key| { + let key = key.as_str(); + if Config::STANDALONE_SECTIONS.iter().any(|section| { + key.starts_with(&format!("{}_", section.to_ascii_uppercase())) + }) { + key.replacen('_', ".", 1).into() + } else { + key.into() + } + }) + .global(), + ) + .select(profile.clone()); + + // only resolve remappings if all providers are requested + if providers.is_all() { + // we try to merge remappings after we've merged all other providers, this prevents + // redundant fs lookups to determine the default remappings that are eventually updated + // by other providers, like the toml file + let remappings = RemappingsProvider { + auto_detect_remappings: figment + .extract_inner::("auto_detect_remappings") + .unwrap_or(true), + lib_paths: figment + .extract_inner::>("libs") + .map(Cow::Owned) + .unwrap_or_else(|_| Cow::Borrowed(&c.libs)), + root: &c.__root.0, + remappings: figment.extract_inner::>("remappings"), + }; + figment = figment.merge(remappings); + } + + // normalize defaults + figment = c.normalize_defaults(figment); + + Figment::from(c).merge(figment).select(profile) + } + /// The config supports relative paths and tracks the root path separately see /// `Config::with_root` /// @@ -1658,77 +1738,32 @@ impl Config { } impl From for Figment { - fn from(mut c: Config) -> Figment { - let profile = Config::selected_profile(); - let mut figment = Figment::default().merge(DappHardhatDirProvider(&c.__root.0)); - - // merge global foundry.toml file - if let Some(global_toml) = Config::foundry_dir_toml().filter(|p| p.exists()) { - figment = Config::merge_toml_provider( - figment, - TomlFileProvider::new(None, global_toml).cached(), - profile.clone(), - ); - } - // merge local foundry.toml file - figment = Config::merge_toml_provider( - figment, - TomlFileProvider::new(Some("FOUNDRY_CONFIG"), c.__root.0.join(Config::FILE_NAME)) - .cached(), - profile.clone(), - ); - - // merge environment variables - figment = figment - .merge( - Env::prefixed("DAPP_") - .ignore(&["REMAPPINGS", "LIBRARIES", "FFI", "FS_PERMISSIONS"]) - .global(), - ) - .merge( - Env::prefixed("DAPP_TEST_") - .ignore(&["CACHE", "FUZZ_RUNS", "DEPTH", "FFI", "FS_PERMISSIONS"]) - .global(), - ) - .merge(DappEnvCompatProvider) - .merge(EtherscanEnvProvider::default()) - .merge( - Env::prefixed("FOUNDRY_") - .ignore(&["PROFILE", "REMAPPINGS", "LIBRARIES", "FFI", "FS_PERMISSIONS"]) - .map(|key| { - let key = key.as_str(); - if Config::STANDALONE_SECTIONS.iter().any(|section| { - key.starts_with(&format!("{}_", section.to_ascii_uppercase())) - }) { - key.replacen('_', ".", 1).into() - } else { - key.into() - } - }) - .global(), - ) - .select(profile.clone()); + fn from(c: Config) -> Figment { + c.to_figment(FigmentProviders::All) + } +} - // we try to merge remappings after we've merged all other providers, this prevents - // redundant fs lookups to determine the default remappings that are eventually updated by - // other providers, like the toml file - let remappings = RemappingsProvider { - auto_detect_remappings: figment - .extract_inner::("auto_detect_remappings") - .unwrap_or(true), - lib_paths: figment - .extract_inner::>("libs") - .map(Cow::Owned) - .unwrap_or_else(|_| Cow::Borrowed(&c.libs)), - root: &c.__root.0, - remappings: figment.extract_inner::>("remappings"), - }; - let merge = figment.merge(remappings); +/// Determines what providers should be used when loading the [Figment] for a [Config] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +pub enum FigmentProviders { + /// Include all providers + #[default] + All, + /// Only include necessary providers that are useful for cast commands + /// + /// This will exclude more expensive providers such as remappings + Cast, +} - // normalize defaults - let merge = c.normalize_defaults(merge); +impl FigmentProviders { + /// Returns true if all providers should be included + pub const fn is_all(&self) -> bool { + matches!(self, Self::All) + } - Figment::from(c).merge(merge).select(profile) + /// Returns true if this is the cast preset + pub const fn is_cast(&self) -> bool { + matches!(self, Self::Cast) } } diff --git a/crates/config/src/macros.rs b/crates/config/src/macros.rs index b84876b8e571f..d7e206a978250 100644 --- a/crates/config/src/macros.rs +++ b/crates/config/src/macros.rs @@ -184,12 +184,16 @@ macro_rules! merge_impl_figment_convert { } /// A macro to implement converters from a type to [`Config`] and [`figment::Figment`] +/// +/// Via [Config::to_figment](crate::Config::to_figment) and the +/// [Cast](crate::FigmentProviders::Cast) profile. #[macro_export] macro_rules! impl_figment_convert_cast { ($name:ty) => { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { - $crate::Config::figment_with_root($crate::find_project_root_path(None).unwrap()) + $crate::Config::with_root($crate::find_project_root_path(None).unwrap()) + .to_figment($crate::FigmentProviders::Cast) .merge(args) } } From 45591b22ca6f14fb697d5a75311bb331e2a6e1ab Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 30 Apr 2024 19:29:50 +0200 Subject: [PATCH 0916/1963] perf: skip remappings when loading anvil config (#7821) --- crates/anvil/src/cmd.rs | 4 ++-- crates/config/src/lib.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index c64d9471fd81b..4a4b329da9704 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -9,7 +9,7 @@ use alloy_signer_wallet::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; use clap::Parser; use core::fmt; -use foundry_config::{Chain, Config}; +use foundry_config::{Chain, Config, FigmentProviders}; use futures::FutureExt; use rand::{rngs::StdRng, SeedableRng}; use std::{ @@ -516,7 +516,7 @@ pub struct AnvilEvmArgs { impl AnvilEvmArgs { pub fn resolve_rpc_alias(&mut self) { if let Some(fork_url) = &self.fork_url { - let config = Config::load(); + let config = Config::load_with_providers(FigmentProviders::Anvil); if let Some(Ok(url)) = config.get_rpc_url_with_alias(&fork_url.url) { self.fork_url = Some(ForkUrl { url: url.to_string(), block: fork_url.block }); } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 5e760d3b69ffb..17d15a6b1da05 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -455,6 +455,14 @@ impl Config { Config::from_provider(Config::figment()) } + /// Returns the current `Config` with the given `providers` preset + /// + /// See `Config::to_figment` + #[track_caller] + pub fn load_with_providers(providers: FigmentProviders) -> Self { + Config::default().to_figment(providers).extract().unwrap() + } + /// Returns the current `Config` /// /// See `Config::figment_with_root` @@ -1753,6 +1761,10 @@ pub enum FigmentProviders { /// /// This will exclude more expensive providers such as remappings Cast, + /// Only include necessary providers that are useful for anvil + /// + /// This will exclude more expensive providers such as remappings + Anvil, } impl FigmentProviders { From 721eb94e04bc2075b59d4221f09190d1897669d3 Mon Sep 17 00:00:00 2001 From: sealer3 <125761775+sealer3@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:33:31 +0000 Subject: [PATCH 0917/1963] fix(anvil): Otterscan searchTransactions behavior (#7807) --- crates/anvil/src/eth/otterscan/api.rs | 65 +++++++++---------------- crates/anvil/src/eth/otterscan/types.rs | 30 +++++++++++- crates/anvil/tests/it/otterscan.rs | 16 +++--- 3 files changed, 60 insertions(+), 51 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 400f99193aecd..40d660012ac66 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -9,9 +9,7 @@ use crate::eth::{ }; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag as BlockNumber}; -use alloy_rpc_types_trace::parity::{ - Action, CallAction, CreateAction, CreateOutput, RewardAction, TraceOutput, -}; +use alloy_rpc_types_trace::parity::{Action, CreateAction, CreateOutput, TraceOutput}; use itertools::Itertools; impl EthApi { @@ -134,38 +132,31 @@ impl EthApi { let best = self.backend.best_number(); // we go from given block (defaulting to best) down to first block // considering only post-fork - let from = if block_number == 0 { best } else { block_number }; + let from = if block_number == 0 { best } else { block_number - 1 }; let to = self.get_fork().map(|f| f.block_number() + 1).unwrap_or(1); - let first_page = from == best; + let first_page = from >= best; let mut last_page = false; let mut res: Vec<_> = vec![]; for n in (to..=from).rev() { - if n == to { - last_page = true; - } - if let Some(traces) = self.backend.mined_parity_trace_block(n) { let hashes = traces .into_iter() .rev() - .filter_map(|trace| match trace.trace.action { - Action::Call(CallAction { from, to, .. }) - if from == address || to == address => - { - trace.transaction_hash - } - _ => None, - }) + .filter_map(|trace| OtsSearchTransactions::mentions_address(trace, address)) .unique(); - res.extend(hashes); - if res.len() >= page_size { break } + + res.extend(hashes); + } + + if n == to { + last_page = true; } } @@ -183,20 +174,17 @@ impl EthApi { let best = self.backend.best_number(); // we go from the first post-fork block, up to the tip - let from = if block_number == 0 { - self.get_fork().map(|f| f.block_number() + 1).unwrap_or(1) - } else { - block_number - }; + let first_block = self.get_fork().map(|f| f.block_number() + 1).unwrap_or(1); + let from = if block_number == 0 { first_block } else { block_number + 1 }; let to = best; - let first_page = from == best; + let mut first_page = from >= best; let mut last_page = false; let mut res: Vec<_> = vec![]; for n in from..=to { - if n == to { + if n == first_block { last_page = true; } @@ -204,30 +192,23 @@ impl EthApi { let hashes = traces .into_iter() .rev() - .filter_map(|trace| match trace.trace.action { - Action::Call(CallAction { from, to, .. }) - if from == address || to == address => - { - trace.transaction_hash - } - Action::Create(CreateAction { from, .. }) if from == address => { - trace.transaction_hash - } - Action::Reward(RewardAction { author, .. }) if author == address => { - trace.transaction_hash - } - _ => None, - }) + .filter_map(|trace| OtsSearchTransactions::mentions_address(trace, address)) .unique(); - res.extend(hashes); - if res.len() >= page_size { break } + + res.extend(hashes); + } + + if n == to { + first_page = true; } } + // Results are always sent in reverse chronological order, according to the Otterscan spec + res.reverse(); OtsSearchTransactions::build(res, &self.backend, first_page, last_page).await } diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index d7e75c02c7e4f..7fe337d97a04a 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -2,9 +2,12 @@ use crate::eth::{ backend::mem::{storage::MinedTransaction, Backend}, error::{BlockchainError, Result}, }; -use alloy_primitives::{Address, Bytes, B256, U256 as rU256, U256}; +use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256 as rU256, U256}; use alloy_rpc_types::{Block, BlockTransactions, Transaction, WithOtherFields}; -use alloy_rpc_types_trace::parity::{Action, CallType, LocalizedTransactionTrace}; +use alloy_rpc_types_trace::parity::{ + Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, + RewardAction, TraceOutput, +}; use anvil_core::eth::transaction::ReceiptResponse; use foundry_evm::{revm::interpreter::InstructionResult, traces::CallKind}; use futures::future::join_all; @@ -251,6 +254,29 @@ impl OtsSearchTransactions { .collect::>>() .map(|receipts| Self { txs, receipts, first_page, last_page }) } + + pub fn mentions_address( + trace: LocalizedTransactionTrace, + address: Address, + ) -> Option> { + match (trace.trace.action, trace.trace.result) { + (Action::Call(CallAction { from, to, .. }), _) if from == address || to == address => { + trace.transaction_hash + } + (_, Some(TraceOutput::Create(CreateOutput { address: created_address, .. }))) + if created_address == address => + { + trace.transaction_hash + } + (Action::Create(CreateAction { from, .. }), _) if from == address => { + trace.transaction_hash + } + (Action::Reward(RewardAction { author, .. }), _) if author == address => { + trace.transaction_hash + } + _ => None, + } + } } impl OtsInternalOperation { diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 8f4bc942fce6a..c4b5d8c7a2a4f 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -586,17 +586,18 @@ async fn can_call_ots_search_transactions_before() { let page_size = 2; let mut block = 0; - for _ in 0..4 { + for i in 0..4 { let result = api.ots_search_transactions_before(sender, block, page_size).await.unwrap(); - assert!(result.txs.len() <= page_size); + assert_eq!(result.first_page, i == 0); + assert_eq!(result.last_page, i == 3); // check each individual hash result.txs.iter().for_each(|tx| { assert_eq!(hashes.pop(), Some(tx.hash)); }); - block = result.txs.last().unwrap().block_number.unwrap() - 1; + block = result.txs.last().unwrap().block_number.unwrap(); } assert!(hashes.is_empty()); @@ -626,17 +627,18 @@ async fn can_call_ots_search_transactions_after() { let page_size = 2; let mut block = 0; - for _ in 0..4 { + for i in 0..4 { let result = api.ots_search_transactions_after(sender, block, page_size).await.unwrap(); - assert!(result.txs.len() <= page_size); + assert_eq!(result.first_page, i == 3); + assert_eq!(result.last_page, i == 0); // check each individual hash - result.txs.iter().for_each(|tx| { + result.txs.iter().rev().for_each(|tx| { assert_eq!(hashes.pop_back(), Some(tx.hash)); }); - block = result.txs.last().unwrap().block_number.unwrap() + 1; + block = result.txs.first().unwrap().block_number.unwrap(); } assert!(hashes.is_empty()); From c0aac85ebb6b9480185f5aaea2a37d5b3e90b195 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 1 May 2024 06:40:30 +0200 Subject: [PATCH 0918/1963] fix: make trace printer work (#7824) --- crates/evm/evm/src/inspectors/stack.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index abcfee4906a6c..bcb1e5517ead2 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -419,7 +419,13 @@ impl InspectorStack { ) -> CallOutcome { let result = outcome.result.result; call_inspectors_adjust_depth!( - [&mut self.fuzzer, &mut self.debugger, &mut self.tracer, &mut self.cheatcodes], + [ + &mut self.fuzzer, + &mut self.debugger, + &mut self.tracer, + &mut self.cheatcodes, + &mut self.printer, + ], |inspector| { let new_outcome = inspector.call_end(ecx, inputs, outcome.clone()); @@ -595,7 +601,7 @@ impl Inspector<&mut DB> for InspectorStack { fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( #[no_ret] - [&mut self.coverage, &mut self.tracer, &mut self.cheatcodes], + [&mut self.coverage, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.initialize_interp(interpreter, ecx), self, ecx @@ -611,6 +617,7 @@ impl Inspector<&mut DB> for InspectorStack { &mut self.tracer, &mut self.coverage, &mut self.cheatcodes, + &mut self.printer, ], |inspector| inspector.step(interpreter, ecx), self, @@ -621,7 +628,7 @@ impl Inspector<&mut DB> for InspectorStack { fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( #[no_ret] - [&mut self.tracer, &mut self.cheatcodes, &mut self.chisel_state], + [&mut self.tracer, &mut self.cheatcodes, &mut self.chisel_state, &mut self.printer], |inspector| inspector.step_end(interpreter, ecx), self, ecx @@ -631,7 +638,7 @@ impl Inspector<&mut DB> for InspectorStack { fn log(&mut self, ecx: &mut EvmContext<&mut DB>, log: &Log) { call_inspectors_adjust_depth!( #[no_ret] - [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes], + [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.log(ecx, log), self, ecx @@ -655,6 +662,7 @@ impl Inspector<&mut DB> for InspectorStack { &mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, + &mut self.printer, ], |inspector| { let mut out = None; @@ -760,7 +768,7 @@ impl Inspector<&mut DB> for InspectorStack { let result = outcome.result.result; call_inspectors_adjust_depth!( - [&mut self.debugger, &mut self.tracer, &mut self.cheatcodes], + [&mut self.debugger, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| { let new_outcome = inspector.create_end(ecx, call, outcome.clone()); @@ -779,9 +787,9 @@ impl Inspector<&mut DB> for InspectorStack { } fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { - call_inspectors!([&mut self.tracer], |inspector| Inspector::::selfdestruct( - inspector, contract, target, value - )); + call_inspectors!([&mut self.tracer, &mut self.printer], |inspector| { + Inspector::::selfdestruct(inspector, contract, target, value) + }); } } From 5885dbc38c27c2bd80fcdcd87a47e06398752662 Mon Sep 17 00:00:00 2001 From: Alisina Bahadori Date: Wed, 1 May 2024 06:18:49 -0400 Subject: [PATCH 0919/1963] Fix `eth_signTransaction` request and response (#7804) * Fix eth_signTransaction request and response * fixup! Fix eth_signTransaction request and response * Hardcode test nonce and fee values * Fix test signed result --- crates/anvil/core/src/eth/mod.rs | 2 +- crates/anvil/src/eth/api.rs | 7 +++---- crates/anvil/tests/it/sign.rs | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 4c485f56be07d..8378506532a2c 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -142,7 +142,7 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "eth_sign", alias = "personal_sign"))] EthSign(Address, Bytes), - #[cfg_attr(feature = "serde", serde(rename = "eth_signTransaction"))] + #[cfg_attr(feature = "serde", serde(rename = "eth_signTransaction", with = "sequence"))] EthSignTransaction(Box>), /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md). diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 261436b52787d..70457b52bce15 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -32,6 +32,7 @@ use crate::{ ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; use alloy_dyn_abi::TypedData; +use alloy_eips::eip2718::Encodable2718; use alloy_network::eip2718::Decodable2718; use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, B64, U256, U64}; use alloy_rpc_types::{ @@ -862,10 +863,8 @@ impl EthApi { let request = self.build_typed_tx_request(request, nonce)?; - let signer = self.get_signer(from).ok_or(BlockchainError::NoSignerAvailable)?; - let signature = - alloy_primitives::hex::encode(signer.sign_transaction(request, &from)?.as_bytes()); - Ok(format!("0x{signature}")) + let signed_transaction = self.sign_request(&from, request)?.encoded_2718(); + Ok(alloy_primitives::hex::encode_prefixed(signed_transaction)) } /// Sends a transaction diff --git a/crates/anvil/tests/it/sign.rs b/crates/anvil/tests/it/sign.rs index b59b22ffbb304..1417fec52d4db 100644 --- a/crates/anvil/tests/it/sign.rs +++ b/crates/anvil/tests/it/sign.rs @@ -282,6 +282,30 @@ async fn can_sign_typed_data_os() { ); } +#[tokio::test(flavor = "multi_thread")] +async fn can_sign_transaction() { + let (api, handle) = spawn(NodeConfig::test()).await; + + let accounts = handle.dev_wallets().collect::>(); + let from = accounts[0].address(); + let to = accounts[1].address(); + + // craft the tx + // specify the `from` field so that the client knows which account to use + let tx = TransactionRequest::default() + .nonce(10) + .max_fee_per_gas(100) + .max_priority_fee_per_gas(101) + .to(to) + .value(U256::from(1001u64)) + .from(from); + let tx = WithOtherFields::new(tx); + // sign it via the eth_signTransaction API + let signed_tx = api.sign_transaction(tx).await.unwrap(); + + assert_eq!(signed_tx, "0x02f868827a690a65648252089470997970c51812dc3a010c7d01b50e0d17dc79c88203e980c082f4f6a0e4de88aefcf87ccb04466e60de66a83192e46aa26177d5ea35efbfd43fd0ecdca00e3148e0e8e0b9a6f9b329efd6e30c4a461920f3a27497be3dbefaba996601da"); +} + #[tokio::test(flavor = "multi_thread")] async fn rejects_different_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; From cafc2606a2187a42b236df4aa65f4e8cdfcea970 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 1 May 2024 20:38:28 +0200 Subject: [PATCH 0920/1963] fix: set value before estimating gas (#7829) --- crates/forge/bin/cmd/create.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 46260ddefbaf7..460dbdea70ed0 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -242,17 +242,17 @@ impl CreateArgs { provider.get_transaction_count(deployer_address, BlockId::latest()).await }?); + // set tx value if specified + if let Some(value) = self.tx.value { + deployer.tx.set_value(value); + } + deployer.tx.set_gas_limit(if let Some(gas_limit) = self.tx.gas_limit { Ok(gas_limit.to()) } else { provider.estimate_gas(&deployer.tx, BlockId::latest()).await }?); - // set tx value if specified - if let Some(value) = self.tx.value { - deployer.tx.set_value(value); - } - if is_legacy { let gas_price = if let Some(gas_price) = self.tx.gas_price { gas_price.to() From 451d98453b331e40b8a08fbcb165919ca0dae535 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 2 May 2024 12:40:43 +0200 Subject: [PATCH 0921/1963] fix(forge): require at least one dependency in `remove` (#7832) --- crates/forge/bin/cmd/remove.rs | 1 + crates/forge/bin/cmd/update.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/remove.rs b/crates/forge/bin/cmd/remove.rs index 22343ef7d69d1..a4d62b9f77d88 100644 --- a/crates/forge/bin/cmd/remove.rs +++ b/crates/forge/bin/cmd/remove.rs @@ -11,6 +11,7 @@ use std::path::PathBuf; #[derive(Clone, Debug, Parser)] pub struct RemoveArgs { /// The dependencies you want to remove. + #[arg(required = true)] dependencies: Vec, /// The project's root path. diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index 0cc25b6b6edc5..05f8e0eb20d37 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -44,7 +44,7 @@ impl UpdateArgs { git.submodule_update(self.force, true, false, false, paths)?; // initialize submodules of each submodule recursively (otherwise direct submodule // dependencies will revert to last commit) - git.submodule_foreach(false, "git submodule update --init --progress --recursive ") + git.submodule_foreach(false, "git submodule update --init --progress --recursive") } } } From 97186b53038a887a954766a234e83feec9a26fd1 Mon Sep 17 00:00:00 2001 From: sealer3 <125761775+sealer3@users.noreply.github.com> Date: Thu, 2 May 2024 18:04:40 +0000 Subject: [PATCH 0922/1963] fix(anvil): `ots_getTransactionError` default return (#7837) --- crates/anvil/src/eth/otterscan/api.rs | 6 +++--- crates/anvil/tests/it/otterscan.rs | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 40d660012ac66..d2a1c7f0c1979 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -62,16 +62,16 @@ impl EthApi { } /// Given a transaction hash, returns its raw revert reason. - pub async fn ots_get_transaction_error(&self, hash: B256) -> Result> { + pub async fn ots_get_transaction_error(&self, hash: B256) -> Result { node_info!("ots_getTransactionError"); if let Some(receipt) = self.backend.mined_transaction_receipt(hash) { if !receipt.inner.inner.as_receipt_with_bloom().receipt.status { - return Ok(receipt.out.map(|b| b.0.into())) + return Ok(receipt.out.map(|b| b.0.into()).unwrap_or(Bytes::default())) } } - Ok(Default::default()) + Ok(Bytes::default()) } /// For simplicity purposes, we return the entire block instead of emptying the values that diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index c4b5d8c7a2a4f..07af1b8ead13e 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -465,6 +465,26 @@ contract Contract { // assert!(res.unwrap_err().to_string().contains("0x8d6ea8be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012526576657274537472696e67466f6f4261720000000000000000000000000000")); } +#[tokio::test(flavor = "multi_thread")] +async fn ots_get_transaction_error_no_error() { + let (api, handle) = spawn(NodeConfig::test()).await; + let wallets = handle.dev_wallets().collect::>(); + let signer: EthereumSigner = wallets[0].clone().into(); + let sender = wallets[0].address(); + + let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); + + // Send a successful transaction + let tx = + TransactionRequest::default().from(sender).to(Address::random()).value(U256::from(100)); + let tx = WithOtherFields::new(tx); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + let res = api.ots_get_transaction_error(receipt.transaction_hash).await; + assert!(res.is_ok()); + assert_eq!(res.unwrap().to_string(), "0x"); +} + #[tokio::test(flavor = "multi_thread")] async fn can_call_ots_get_block_details() { let (api, handle) = spawn(NodeConfig::test()).await; From 7a676f801365ad1c5d347b8300bba805e727897d Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 2 May 2024 17:09:23 -0400 Subject: [PATCH 0923/1963] feat: Anvil Cancun support (#7242) * feat(anvil-core): EIP4844 variant support * chore: proper support when converting txs * feat: add more type support * chore: lock * feat: missing type conversions, decoding test * use correct eip check * force no blob hashes for eip1559 * feat: support sidecar with 4844 types * fmt * feat: turn on c-kzg revm feature * chore: add new invalid tx errors * feat: execution validation steps * feat: enable c-kzg * feat: use main branch for consensus, update * chore: rename * lockfile * fmt * fmt * fmt * clippy * feat: update blob fees * set current blob excess gas and price when creating block * blob gas checks * clippy * chore: remove unneeded fns * chore: handle fee history * chore: add excess blob gas and price to feehistory cache * chore: remove unused * chore: properly sum cumulative blob gas * chore: rewrite validation checks * chore: handle eip4844 variant when decoding * max blob validation check * chore: correct and rename blob fee capp err * feat: fee history response changes * docs * several fee fixes * chore: set blob gas used on rpc response * fix: use primitives types * fix: satisfy clippy * feat(anvil/tests): can_send_eip4844_transaction - fails * use sidecar builder in tests * fix: tx_req_to_typed * nits * fix: return `blob_gas_price` and `blob_gas_used` in tx receipt * nits * fix: gas_price calc in backend::tx_build and nits * feat(anvil-tests): `can_send_multiple_blobs_in_one_tx`, `cannot_exceed_six_blobs` * nits * fix: eip4844 test * nits Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * feat(anvil-test): 4844 - test should fail. * fix(anvil): check MAX_BLOB_GAS_PER_BLOCK in tx executor * nits * fix: blob error handling * nits * type nits * nit --------- Co-authored-by: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 3 + crates/anvil/Cargo.toml | 6 + crates/anvil/core/Cargo.toml | 1 + crates/anvil/core/src/eth/block.rs | 12 +- crates/anvil/core/src/eth/transaction/mod.rs | 45 ++++- crates/anvil/src/config.rs | 34 +++- crates/anvil/src/eth/api.rs | 47 ++++- crates/anvil/src/eth/backend/executor.rs | 43 +++++ crates/anvil/src/eth/backend/mem/mod.rs | 86 +++++++-- crates/anvil/src/eth/error.rs | 36 +++- crates/anvil/src/eth/fees.rs | 144 ++++++++++++-- crates/anvil/tests/it/eip4844.rs | 192 +++++++++++++++++++ crates/anvil/tests/it/main.rs | 2 +- crates/evm/core/Cargo.toml | 3 +- crates/evm/evm/Cargo.toml | 8 +- crates/evm/fuzz/Cargo.toml | 2 +- 16 files changed, 613 insertions(+), 51 deletions(-) create mode 100644 crates/anvil/tests/it/eip4844.rs diff --git a/Cargo.lock b/Cargo.lock index 97c3c3e93f6af..67c48847968b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -741,6 +741,7 @@ dependencies = [ "parking_lot", "pretty_assertions", "rand 0.8.5", + "revm", "serde", "serde_json", "serde_repr", @@ -7082,10 +7083,12 @@ dependencies = [ "bitvec", "c-kzg", "cfg-if", + "derive_more", "dyn-clone", "enumn", "hashbrown", "hex", + "once_cell", "serde", ] diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index afbf940fb8b1a..7739e8fa2f3f0 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -36,6 +36,12 @@ foundry-evm.workspace = true bytes = "1.4.0" k256.workspace = true ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } +revm = { workspace = true, features = [ + "std", + "serde", + "memory_limit", + "c-kzg", +] } alloy-primitives = { workspace = true, features = ["serde"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-contract = { workspace = true, features = ["pubsub"] } diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index feddead952123..90738112e6402 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -16,6 +16,7 @@ revm = { workspace = true, default-features = false, features = [ "std", "serde", "memory_limit", + "c-kzg", ] } alloy-primitives = { workspace = true, features = ["serde"] } diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index fd7e530e00491..a05c2cae45c6f 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -67,9 +67,9 @@ impl Block { extra_data: partial_header.extra_data, mix_hash: partial_header.mix_hash, withdrawals_root: None, - blob_gas_used: None, - excess_blob_gas: None, - parent_beacon_block_root: None, + blob_gas_used: partial_header.blob_gas_used, + excess_blob_gas: partial_header.excess_blob_gas, + parent_beacon_block_root: partial_header.parent_beacon_block_root, nonce: partial_header.nonce, base_fee_per_gas: partial_header.base_fee, }, @@ -94,6 +94,9 @@ pub struct PartialHeader { pub timestamp: u64, pub extra_data: Bytes, pub mix_hash: B256, + pub blob_gas_used: Option, + pub excess_blob_gas: Option, + pub parent_beacon_block_root: Option, pub nonce: B64, pub base_fee: Option, } @@ -115,6 +118,9 @@ impl From
for PartialHeader { mix_hash: value.mix_hash, nonce: value.nonce, base_fee: value.base_fee_per_gas, + blob_gas_used: value.blob_gas_used, + excess_blob_gas: value.excess_blob_gas, + parent_beacon_block_root: value.parent_beacon_block_root, } } } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 3c60bb3a6fee0..c52beb16e1045 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -20,7 +20,7 @@ use revm::{ primitives::{CreateScheme, OptimismFields, TransactTo, TxEnv}, }; use serde::{Deserialize, Serialize}; -use std::ops::Deref; +use std::ops::{Deref, Mul}; pub mod optimism; @@ -45,12 +45,12 @@ pub fn transaction_request_to_typed( max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas, - mut blob_versioned_hashes, + blob_versioned_hashes, gas, value, input, nonce, - mut access_list, + access_list, sidecar, transaction_type, .. @@ -77,9 +77,9 @@ pub fn transaction_request_to_typed( gas_price, max_fee_per_gas, max_priority_fee_per_gas, - access_list.take(), + access_list.as_ref(), max_fee_per_blob_gas, - blob_versioned_hashes.take(), + blob_versioned_hashes.as_ref(), sidecar, to, ) { @@ -129,7 +129,7 @@ pub fn transaction_request_to_typed( })) } // EIP4844 - (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), Some(to)) => { + (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), to) => { let tx = TxEip4844 { nonce: nonce.unwrap_or_default(), max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), @@ -138,7 +138,7 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), value: value.unwrap_or(U256::ZERO), input: input.into_input().unwrap_or_default(), - to: match to { + to: match to.unwrap_or(TxKind::Create) { TxKind::Call(to) => to, TxKind::Create => Address::ZERO, }, @@ -619,9 +619,9 @@ pub enum TypedTransaction { } impl TypedTransaction { - /// Returns true if the transaction uses dynamic fees: EIP1559 + /// Returns true if the transaction uses dynamic fees: EIP1559 or EIP4844 pub fn is_dynamic_fee(&self) -> bool { - matches!(self, TypedTransaction::EIP1559(_)) + matches!(self, TypedTransaction::EIP1559(_)) || matches!(self, TypedTransaction::EIP4844(_)) } pub fn gas_price(&self) -> u128 { @@ -676,8 +676,33 @@ impl TypedTransaction { } /// Max cost of the transaction + /// It is the gas limit multiplied by the gas price, + /// and if the transaction is EIP-4844, the result of (total blob gas cost * max fee per blob + /// gas) is also added pub fn max_cost(&self) -> u128 { - self.gas_limit().saturating_mul(self.gas_price()) + let mut max_cost = self.gas_limit().saturating_mul(self.gas_price()); + + if self.is_eip4844() { + max_cost = max_cost.saturating_add( + self.blob_gas().unwrap_or(0).mul(self.max_fee_per_blob_gas().unwrap_or(0)), + ) + } + + max_cost + } + + pub fn blob_gas(&self) -> Option { + match self { + TypedTransaction::EIP4844(tx) => Some(tx.tx().tx().blob_gas() as u128), + _ => None, + } + } + + pub fn max_fee_per_blob_gas(&self) -> Option { + match self { + TypedTransaction::EIP4844(tx) => Some(tx.tx().tx().max_fee_per_blob_gas), + _ => None, + } } /// Returns a helper type that contains commonly used values as fields diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index ffc648199d6f7..6905b69dcfe44 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -39,6 +39,7 @@ use foundry_evm::{ }; use parking_lot::RwLock; use rand::thread_rng; +use revm::primitives::BlobExcessGasAndPrice; use serde_json::{json, to_writer, Value}; use std::{ collections::HashMap, @@ -98,6 +99,8 @@ pub struct NodeConfig { pub gas_price: Option, /// Default base fee pub base_fee: Option, + /// Default blob excess gas and price + pub blob_excess_gas_and_price: Option, /// The hardfork to use pub hardfork: Option, /// Signer accounts that will be initialised with `genesis_balance` in the genesis block @@ -398,6 +401,7 @@ impl Default for NodeConfig { fork_block_number: None, account_generator: None, base_fee: None, + blob_excess_gas_and_price: None, enable_tracing: true, enable_steps_tracing: false, enable_auto_impersonate: false, @@ -447,6 +451,17 @@ impl NodeConfig { self.gas_price.unwrap_or(INITIAL_GAS_PRICE) } + pub fn get_blob_excess_gas_and_price(&self) -> BlobExcessGasAndPrice { + if let Some(blob_excess_gas_and_price) = &self.blob_excess_gas_and_price { + blob_excess_gas_and_price.clone() + } else if let Some(excess_blob_gas) = self.genesis.as_ref().and_then(|g| g.excess_blob_gas) + { + BlobExcessGasAndPrice::new(excess_blob_gas as u64) + } else { + BlobExcessGasAndPrice { blob_gasprice: 0, excess_blob_gas: 0 } + } + } + /// Returns the base fee to use pub fn get_hardfork(&self) -> Hardfork { self.hardfork.unwrap_or_default() @@ -876,8 +891,12 @@ impl NodeConfig { }; let mut env = EnvWithHandlerCfg::new(Box::new(env), cfg.handler_cfg); - let fees = - FeeManager::new(cfg.handler_cfg.spec_id, self.get_base_fee(), self.get_gas_price()); + let fees = FeeManager::new( + cfg.handler_cfg.spec_id, + self.get_base_fee(), + self.get_gas_price(), + self.get_blob_excess_gas_and_price(), + ); let (db, fork): (Arc>>, Option) = if let Some(eth_rpc_url) = self.eth_rpc_url.clone() { @@ -1075,6 +1094,17 @@ latest block number: {latest_block}" // update next base fee fees.set_base_fee(next_block_base_fee); } + if let (Some(blob_excess_gas), Some(blob_gas_used)) = + (block.header.excess_blob_gas, block.header.blob_gas_used) + { + env.block.blob_excess_gas_and_price = + Some(BlobExcessGasAndPrice::new(blob_excess_gas as u64)); + let next_block_blob_excess_gas = + fees.get_next_block_blob_excess_gas(blob_excess_gas, blob_gas_used); + fees.set_blob_excess_gas_and_price(BlobExcessGasAndPrice::new( + next_block_blob_excess_gas, + )); + } } // use remote gas price diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 70457b52bce15..cc77746da7a75 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -28,9 +28,10 @@ use crate::{ }, filter::{EthFilter, Filters, LogsFilter}, mem::transaction_build, - revm::primitives::Output, + revm::primitives::{BlobExcessGasAndPrice, Output}, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; +use alloy_consensus::TxEip4844Variant; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; use alloy_network::eip2718::Decodable2718; @@ -550,6 +551,11 @@ impl EthApi { Ok(U256::from(self.backend.gas_price())) } + /// Returns the excess blob gas and current blob gas price + pub fn excess_blob_gas_and_price(&self) -> Result> { + Ok(self.backend.excess_blob_gas_and_price()) + } + /// Returns a fee per gas that is an estimate of how much you can pay as a priority fee, or /// 'tip', to get a transaction included in the current block. /// @@ -977,6 +983,7 @@ impl EthApi { request.gas_price, request.max_fee_per_gas, request.max_priority_fee_per_gas, + request.max_fee_per_blob_gas, )? .or_zero_fees(); // this can be blocking for a bit, especially in forking mode @@ -1292,6 +1299,8 @@ impl EthApi { // if let Some(block) = fee_history.get(&n) { response.base_fee_per_gas.push(block.base_fee); + response.base_fee_per_blob_gas.push(block.base_fee_per_blob_gas.unwrap_or(0)); + response.blob_gas_used_ratio.push(block.blob_gas_used_ratio); response.gas_used_ratio.push(block.gas_used_ratio); // requested percentiles @@ -1318,6 +1327,11 @@ impl EthApi { // newest block" response.base_fee_per_gas.push(self.backend.fees().base_fee()); + // Same goes for the `base_fee_per_blob_gas`: + // > [..] includes the next block after the newest of the returned range, because this + // > value can be derived from the newest block. + response.base_fee_per_blob_gas.push(self.backend.fees().base_fee_per_blob_gas()); + Ok(response) } @@ -1424,6 +1438,7 @@ impl EthApi { request.gas_price, request.max_fee_per_gas, request.max_priority_fee_per_gas, + request.max_fee_per_blob_gas, )? .or_zero_fees(); @@ -2184,6 +2199,7 @@ impl EthApi { request.gas_price, request.max_fee_per_gas, request.max_priority_fee_per_gas, + request.max_fee_per_blob_gas, )? .or_zero_fees(); @@ -2387,6 +2403,7 @@ impl EthApi { ) -> Result { let chain_id = request.chain_id.unwrap_or_else(|| self.chain_id()); let max_fee_per_gas = request.max_fee_per_gas; + let max_fee_per_blob_gas = request.max_fee_per_blob_gas; let gas_price = request.gas_price; let gas_limit = request.gas.unwrap_or(self.backend.gas_limit()); @@ -2419,11 +2436,37 @@ impl EthApi { } TypedTransactionRequest::EIP1559(m) } + Some(TypedTransactionRequest::EIP4844(m)) => { + TypedTransactionRequest::EIP4844(match m { + // We only accept the TxEip4844 variant which has the sidecar. + TxEip4844Variant::TxEip4844WithSidecar(mut m) => { + m.tx.nonce = nonce; + m.tx.chain_id = chain_id; + m.tx.gas_limit = gas_limit; + if max_fee_per_gas.is_none() { + m.tx.max_fee_per_gas = + self.gas_price().unwrap_or_default().to::(); + } + if max_fee_per_blob_gas.is_none() { + m.tx.max_fee_per_blob_gas = self + .excess_blob_gas_and_price() + .unwrap_or_default() + .map_or(0, |g| g.blob_gasprice) + } + TxEip4844Variant::TxEip4844WithSidecar(m) + } + // It is not valid to receive a TxEip4844 without a sidecar, therefore + // we must reject it. + TxEip4844Variant::TxEip4844(_) => { + return Err(BlockchainError::FailedToDecodeTransaction) + } + }) + } Some(TypedTransactionRequest::Deposit(mut m)) => { m.gas_limit = gas_limit; TypedTransactionRequest::Deposit(m) } - _ => return Err(BlockchainError::FailedToDecodeTransaction), + None => return Err(BlockchainError::FailedToDecodeTransaction), }; Ok(request) } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 2d5d55500a2fc..999bfae4fc8b6 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -29,6 +29,7 @@ use foundry_evm::{ }, traces::CallTraceNode, }; +use revm::primitives::MAX_BLOB_GAS_PER_BLOCK; use std::sync::Arc; /// Represents an executed transaction (transacted on the DB) @@ -97,6 +98,8 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> pub parent_hash: B256, /// Cumulative gas used by all executed transactions pub gas_used: u128, + /// Cumulative blob gas used by all executed transactions + pub blob_gas_used: u128, pub enable_steps_tracing: bool, /// Precompiles to inject to the EVM. pub precompile_factory: Option>, @@ -124,6 +127,10 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' None }; + let is_cancun = self.cfg_env.handler_cfg.spec_id >= SpecId::CANCUN; + let excess_blob_gas = if is_cancun { self.block_env.get_blob_excess_gas() } else { None }; + let mut cumulative_blob_gas_used = if is_cancun { Some(0u128) } else { None }; + for tx in self.into_iter() { let tx = match tx { TransactionExecutionOutcome::Executed(tx) => { @@ -134,6 +141,10 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' trace!(target: "backend", tx_gas_limit = %tx.pending_transaction.transaction.gas_limit(), ?tx, "block gas limit exhausting, skipping transaction"); continue } + TransactionExecutionOutcome::BlobGasExhausted(tx) => { + trace!(target: "backend", blob_gas = %tx.pending_transaction.transaction.blob_gas().unwrap_or_default(), ?tx, "block blob gas limit exhausting, skipping transaction"); + continue + } TransactionExecutionOutcome::Invalid(tx, _) => { trace!(target: "backend", ?tx, "skipping invalid transaction"); invalid.push(tx); @@ -146,7 +157,19 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' continue } }; + if is_cancun { + let tx_blob_gas = tx + .transaction + .pending_transaction + .transaction + .transaction + .blob_gas() + .unwrap_or(0); + cumulative_blob_gas_used = + Some(cumulative_blob_gas_used.unwrap_or(0u128).saturating_add(tx_blob_gas)); + } let receipt = tx.create_receipt(&mut cumulative_gas_used); + let ExecutedTransaction { transaction, logs, out, traces, exit_reason: exit, .. } = tx; build_logs_bloom(logs.clone(), &mut bloom); @@ -200,6 +223,9 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' mix_hash: Default::default(), nonce: Default::default(), base_fee, + parent_beacon_block_root: Default::default(), + blob_gas_used: cumulative_blob_gas_used, + excess_blob_gas: excess_blob_gas.map(|g| g as u128), }; let block = Block::new(partial_header, transactions.clone(), ommers); @@ -227,6 +253,8 @@ pub enum TransactionExecutionOutcome { Invalid(Arc, InvalidTransactionError), /// Execution skipped because could exceed gas limit Exhausted(Arc), + /// Execution skipped because it exceeded the blob gas limit + BlobGasExhausted(Arc), /// When an error occurred during execution DatabaseError(Arc, DatabaseError), } @@ -244,12 +272,21 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator Err(err) => return Some(TransactionExecutionOutcome::DatabaseError(transaction, err)), }; let env = self.env_for(&transaction.pending_transaction); + // check that we comply with the block's gas limit let max_gas = self.gas_used.saturating_add(env.tx.gas_limit as u128); if max_gas > env.block.gas_limit.to::() { return Some(TransactionExecutionOutcome::Exhausted(transaction)) } + // check that we comply with the block's blob gas limit + let max_blob_gas = self.blob_gas_used.saturating_add( + transaction.pending_transaction.transaction.transaction.blob_gas().unwrap_or(0u128), + ); + if max_blob_gas > MAX_BLOB_GAS_PER_BLOCK as u128 { + return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction)) + } + // validate before executing if let Err(err) = self.validator.validate_pool_transaction_for( &transaction.pending_transaction, @@ -322,8 +359,14 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator trace!(target: "backend", ?exit_reason, ?gas_used, "[{:?}] executed with out={:?}", transaction.hash(), out); + // Track the total gas used for total gas per block checks self.gas_used = self.gas_used.saturating_add(gas_used as u128); + // Track the total blob gas used for total blob gas per blob checks + if let Some(blob_gas) = transaction.pending_transaction.transaction.transaction.blob_gas() { + self.blob_gas_used = self.blob_gas_used.saturating_add(blob_gas); + } + trace!(target: "backend::executor", "transacted [{:?}], result: {:?} gas {}", transaction.hash(), exit_reason, gas_used); let tx = ExecutedTransaction { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 51b14bb2dcee6..ed27557b311e1 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -32,6 +32,7 @@ use crate::{ NodeConfig, PrecompileFactory, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; +use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK; use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256, U64}; use alloy_rpc_types::{ request::TransactionRequest, serde_helpers::JsonStorageKey, state::StateOverride, AccessList, @@ -78,7 +79,9 @@ use futures::channel::mpsc::{unbounded, UnboundedSender}; use parking_lot::{Mutex, RwLock}; use revm::{ db::WrapDatabaseRef, - primitives::{HashMap, OptimismFields, ResultAndState}, + primitives::{ + calc_blob_gasprice, BlobExcessGasAndPrice, HashMap, OptimismFields, ResultAndState, + }, }; use std::{ collections::BTreeMap, @@ -639,6 +642,10 @@ impl Backend { self.fees.base_fee() } + pub fn excess_blob_gas_and_price(&self) -> Option { + self.fees.excess_blob_gas_and_price() + } + /// Sets the current basefee pub fn set_base_fee(&self, basefee: u128) { self.fees.set_base_fee(basefee) @@ -895,6 +902,7 @@ impl Backend { cfg_env, parent_hash: storage.best_hash, gas_used: 0, + blob_gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, precompile_factory: self.precompile_factory.clone(), }; @@ -923,6 +931,7 @@ impl Backend { let (outcome, header, block_hash) = { let current_base_fee = self.base_fee(); + let current_excess_blob_gas_and_price = self.excess_blob_gas_and_price(); let mut env = self.env.read().clone(); @@ -935,6 +944,7 @@ impl Backend { // increase block number for this block env.block.number = env.block.number.saturating_add(U256::from(1)); env.block.basefee = U256::from(current_base_fee); + env.block.blob_excess_gas_and_price = current_excess_blob_gas_and_price; env.block.timestamp = U256::from(self.time.next_timestamp()); let best_hash = self.blockchain.storage.read().best_hash; @@ -955,6 +965,7 @@ impl Backend { cfg_env: CfgEnvWithHandlerCfg::new(env.cfg.clone(), env.handler_cfg), parent_hash: best_hash, gas_used: 0, + blob_gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, precompile_factory: self.precompile_factory.clone(), }; @@ -1054,9 +1065,15 @@ impl Backend { header.gas_limit, header.base_fee_per_gas.unwrap_or_default(), ); + let next_block_excess_blob_gas = self.fees.get_next_block_blob_excess_gas( + header.excess_blob_gas.unwrap_or_default(), + header.blob_gas_used.unwrap_or_default(), + ); // update next base fee self.fees.set_base_fee(next_block_base_fee); + self.fees + .set_blob_excess_gas_and_price(BlobExcessGasAndPrice::new(next_block_excess_blob_gas)); // notify all listeners self.notify_on_new_block(header, block_hash); @@ -1101,7 +1118,12 @@ impl Backend { .. } = request; - let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = fee_details; + let FeeDetails { + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + max_fee_per_blob_gas, + } = fee_details; let gas_limit = gas.unwrap_or(block_env.gas_limit.to()); let mut env = self.env.read().clone(); @@ -1122,6 +1144,7 @@ impl Backend { gas_limit: gas_limit as u64, gas_price: U256::from(gas_price), gas_priority_fee: max_priority_fee_per_gas.map(U256::from), + max_fee_per_blob_gas: max_fee_per_blob_gas.map(U256::from), transact_to: match to { Some(addr) => TransactTo::Call(*addr), None => TransactTo::Create(CreateScheme::Create), @@ -1564,9 +1587,9 @@ impl Backend { nonce, base_fee_per_gas, withdrawals_root: _, - blob_gas_used: _, - excess_blob_gas: _, - parent_beacon_block_root: _, + blob_gas_used, + excess_blob_gas, + parent_beacon_block_root, } = header; AlloyBlock { @@ -1590,9 +1613,9 @@ impl Backend { nonce: Some(nonce), base_fee_per_gas, withdrawals_root: None, - blob_gas_used: None, - excess_blob_gas: None, - parent_beacon_block_root: None, + blob_gas_used, + excess_blob_gas, + parent_beacon_block_root, }, size: Some(size), transactions: alloy_rpc_types::BlockTransactions::Hashes( @@ -1977,6 +2000,11 @@ impl Backend { let block = self.blockchain.get_block_by_hash(&block_hash)?; let transaction = block.transactions[index].clone(); + // Cancun specific + let excess_blob_gas = block.header.excess_blob_gas; + let blob_gas_price = calc_blob_gasprice(excess_blob_gas.map_or(0, |g| g as u64)); + let blob_gas_used = transaction.blob_gas(); + let effective_gas_price = match transaction.transaction { TypedTransaction::Legacy(t) => t.tx().gas_price, TypedTransaction::EIP2930(t) => t.tx().gas_price, @@ -2043,8 +2071,8 @@ impl Backend { from: info.from, to: info.to, state_root: Some(block.header.state_root), - blob_gas_price: None, - blob_gas_used: None, + blob_gas_price: Some(blob_gas_price), + blob_gas_used, }; Some(MinedTransactionReceipt { inner, out: info.out.map(|o| o.0.into()) }) @@ -2331,6 +2359,42 @@ impl TransactionValidator for Backend { } } + // EIP-4844 Cancun hard fork validation steps + if env.spec_id() >= SpecId::CANCUN && tx.transaction.is_eip4844() { + // Light checks first: see if the blob fee cap is too low. + if let Some(max_fee_per_blob_gas) = tx.essentials().max_fee_per_blob_gas { + if let Some(blob_gas_and_price) = &env.block.blob_excess_gas_and_price { + if max_fee_per_blob_gas.to::() < blob_gas_and_price.blob_gasprice { + warn!(target: "backend", "max fee per blob gas={}, too low, block blob gas price={}", max_fee_per_blob_gas, blob_gas_and_price.blob_gasprice); + return Err(InvalidTransactionError::BlobFeeCapTooLow); + } + } + } + + // Heavy (blob validation) checks + let tx = match &tx.transaction { + TypedTransaction::EIP4844(tx) => tx.tx(), + _ => unreachable!(), + }; + + let blob_count = tx.tx().blob_versioned_hashes.len(); + + // Ensure there are blob hashes. + if blob_count == 0 { + return Err(InvalidTransactionError::NoBlobHashes) + } + + // Ensure the tx does not exceed the max blobs per block. + if blob_count > MAX_BLOBS_PER_BLOCK { + return Err(InvalidTransactionError::TooManyBlobs) + } + + // Check for any blob validation errors + if let Err(err) = tx.validate(env.cfg.kzg_settings.get()) { + return Err(InvalidTransactionError::BlobTransactionValidationError(err)) + } + } + let max_cost = tx.max_cost(); let value = tx.value(); // check sufficient funds: `gas * price + value` @@ -2381,7 +2445,7 @@ pub fn transaction_build( } else { // if transaction is already mined, gas price is considered base fee + priority fee: the // effective gas price. - let base_fee = base_fee.unwrap_or(0); + let base_fee = base_fee.unwrap_or(0u128); let max_priority_fee_per_gas = transaction.max_priority_fee_per_gas.unwrap_or(0); transaction.gas_price = Some(base_fee.saturating_add(max_priority_fee_per_gas)); } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index cc7517b42de91..ce00da3194d2c 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -2,6 +2,7 @@ use crate::eth::pool::transactions::PoolTransaction; use alloy_primitives::{Bytes, SignatureError}; +use alloy_rpc_types::BlockNumberOrTag; use alloy_signer::Error as SignerError; use alloy_transport::TransportError; use anvil_rpc::{ @@ -131,8 +132,10 @@ pub enum PoolError { /// Errors that can occur with `eth_feeHistory` #[derive(Debug, thiserror::Error)] pub enum FeeHistoryError { - #[error("Requested block range is out of bounds")] + #[error("requested block range is out of bounds")] InvalidBlockRange, + #[error("could not find newest block number requested: {0}")] + BlockNotFound(BlockNumberOrTag), } #[derive(Debug)] @@ -201,7 +204,7 @@ pub enum InvalidTransactionError { /// Thrown when the block's `blob_gas_price` is greater than tx-specified /// `max_fee_per_blob_gas` after Cancun. #[error("Block `blob_gas_price` is greater than tx-specified `max_fee_per_blob_gas`")] - BlobGasPriceGreaterThanMax, + BlobFeeCapTooLow, /// Thrown when we receive a tx with `blob_versioned_hashes` and we're not on the Cancun hard /// fork. #[error("Block `blob_versioned_hashes` is not supported before the Cancun hardfork")] @@ -209,6 +212,23 @@ pub enum InvalidTransactionError { /// Thrown when `max_fee_per_blob_gas` is not supported for blocks before the Cancun hardfork. #[error("`max_fee_per_blob_gas` is not supported for blocks before the Cancun hardfork.")] MaxFeePerBlobGasNotSupported, + /// Thrown when there are no `blob_hashes` in the transaction, and it is an EIP-4844 tx. + #[error("`blob_hashes` are required for EIP-4844 transactions")] + NoBlobHashes, + #[error("too many blobs in one transaction")] + TooManyBlobs, + /// Thrown when there's a blob validation error + #[error(transparent)] + BlobTransactionValidationError(#[from] alloy_consensus::BlobTransactionValidationError), + /// Thrown when Blob transaction is a create transaction. `to` must be present. + #[error("Blob transaction can't be a create transaction. `to` must be present.")] + BlobCreateTransaction, + /// Thrown when Blob transaction contains a versioned hash with an incorrect version. + #[error("Blob transaction contains a versioned hash with an incorrect version")] + BlobVersionNotSupported, + /// Thrown when there are no `blob_hashes` in the transaction. + #[error("There should be at least one blob in a Blob transaction.")] + EmptyBlobs, } impl From for InvalidTransactionError { @@ -249,7 +269,7 @@ impl From for InvalidTransactionError { InvalidTransactionError::AccessListNotSupported } InvalidTransaction::BlobGasPriceGreaterThanMax => { - InvalidTransactionError::BlobGasPriceGreaterThanMax + InvalidTransactionError::BlobFeeCapTooLow } InvalidTransaction::BlobVersionedHashesNotSupported => { InvalidTransactionError::BlobVersionedHashesNotSupported @@ -257,8 +277,14 @@ impl From for InvalidTransactionError { InvalidTransaction::MaxFeePerBlobGasNotSupported => { InvalidTransactionError::MaxFeePerBlobGasNotSupported } - // TODO: Blob-related errors should be handled once the Reth migration is done and code - // is moved over. + InvalidTransaction::BlobCreateTransaction => { + InvalidTransactionError::BlobCreateTransaction + } + InvalidTransaction::BlobVersionNotSupported => { + InvalidTransactionError::BlobVersionedHashesNotSupported + } + InvalidTransaction::EmptyBlobs => InvalidTransactionError::EmptyBlobs, + InvalidTransaction::TooManyBlobs => InvalidTransactionError::TooManyBlobs, _ => todo!(), } } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index f5534a0cd10cf..f0a614c35c6b8 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -2,10 +2,12 @@ use crate::eth::{ backend::{info::StorageInfo, notifications::NewBlockNotifications}, error::BlockchainError, }; -use alloy_eips::{calc_next_block_base_fee, eip1559::BaseFeeParams}; +use alloy_eips::{ + calc_next_block_base_fee, eip1559::BaseFeeParams, eip4844::MAX_DATA_GAS_PER_BLOCK, +}; use alloy_primitives::B256; use anvil_core::eth::transaction::TypedTransaction; -use foundry_evm::revm::primitives::SpecId; +use foundry_evm::revm::primitives::{BlobExcessGasAndPrice, SpecId}; use futures::StreamExt; use parking_lot::{Mutex, RwLock}; use std::{ @@ -42,6 +44,10 @@ pub struct FeeManager { /// /// This value will be updated after a new block was mined base_fee: Arc>, + /// Tracks the excess blob gas, and the base fee, for the next block post Cancun + /// + /// This value will be updated after a new block was mined + blob_excess_gas_and_price: Arc>, /// The base price to use Pre London /// /// This will be constant value unless changed manually @@ -52,11 +58,17 @@ pub struct FeeManager { // === impl FeeManager === impl FeeManager { - pub fn new(spec_id: SpecId, base_fee: u128, gas_price: u128) -> Self { + pub fn new( + spec_id: SpecId, + base_fee: u128, + gas_price: u128, + blob_excess_gas_and_price: BlobExcessGasAndPrice, + ) -> Self { Self { spec_id, base_fee: Arc::new(RwLock::new(base_fee)), gas_price: Arc::new(RwLock::new(gas_price)), + blob_excess_gas_and_price: Arc::new(RwLock::new(blob_excess_gas_and_price)), elasticity: Arc::new(RwLock::new(default_elasticity())), } } @@ -70,6 +82,10 @@ impl FeeManager { (self.spec_id as u8) >= (SpecId::LONDON as u8) } + pub fn is_eip4844(&self) -> bool { + (self.spec_id as u8) >= (SpecId::CANCUN as u8) + } + /// Calculates the current gas price pub fn gas_price(&self) -> u128 { if self.is_eip1559() { @@ -79,6 +95,15 @@ impl FeeManager { } } + /// Calculates the current blob gas price + pub fn blob_gas_price(&self) -> u128 { + if self.is_eip4844() { + self.base_fee_per_blob_gas() + } else { + 0 + } + } + /// Suggested priority fee to add to the base fee pub fn suggested_priority_fee(&self) -> u128 { 1e9 as u128 @@ -92,6 +117,22 @@ impl FeeManager { } } + pub fn excess_blob_gas_and_price(&self) -> Option { + if self.is_eip4844() { + Some(self.blob_excess_gas_and_price.read().clone()) + } else { + None + } + } + + pub fn base_fee_per_blob_gas(&self) -> u128 { + if self.is_eip4844() { + self.blob_excess_gas_and_price.read().blob_gasprice + } else { + 0 + } + } + /// Returns the suggested fee cap /// /// Note: This currently returns a constant value: [Self::suggested_priority_fee] @@ -112,6 +153,13 @@ impl FeeManager { *base = fee; } + /// Sets the current blob excess gas and price + pub fn set_blob_excess_gas_and_price(&self, blob_excess_gas_and_price: BlobExcessGasAndPrice) { + trace!(target: "backend::fees", "updated blob base fee {:?}", blob_excess_gas_and_price); + let mut base = self.blob_excess_gas_and_price.write(); + *base = blob_excess_gas_and_price; + } + /// Calculates the base fee for the next block pub fn get_next_block_base_fee_per_gas( &self, @@ -125,8 +173,28 @@ impl FeeManager { if self.base_fee() == 0 { return 0 } - calc_next_block_base_fee(gas_used, gas_limit, last_fee_per_gas, BaseFeeParams::ethereum()) + calculate_next_block_base_fee(gas_used, gas_limit, last_fee_per_gas) } + + /// Calculates the next block blob base fee, using the provided excess blob gas + pub fn get_next_block_blob_base_fee_per_gas(&self, excess_blob_gas: u128) -> u128 { + crate::revm::primitives::calc_blob_gasprice(excess_blob_gas as u64) + } + + /// Calculates the next block blob excess gas, using the provided parent blob gas used and + /// parent blob excess gas + pub fn get_next_block_blob_excess_gas( + &self, + blob_gas_used: u128, + blob_excess_gas: u128, + ) -> u64 { + crate::revm::primitives::calc_excess_blob_gas(blob_gas_used as u64, blob_excess_gas as u64) + } +} + +/// Calculate base fee for next block. [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) spec +pub fn calculate_next_block_base_fee(gas_used: u128, gas_limit: u128, base_fee: u128) -> u128 { + calc_next_block_base_fee(gas_used, gas_limit, base_fee, BaseFeeParams::ethereum()) } /// An async service that takes care of the `FeeHistory` cache @@ -189,7 +257,16 @@ impl FeeHistoryService { let mut block_number: Option = None; let base_fee = self.fees.base_fee(); - let mut item = FeeHistoryCacheItem { base_fee, gas_used_ratio: 0f64, rewards: Vec::new() }; + let excess_blob_gas_and_price = self.fees.excess_blob_gas_and_price(); + let mut item = FeeHistoryCacheItem { + base_fee, + gas_used_ratio: 0f64, + blob_gas_used_ratio: 0f64, + rewards: Vec::new(), + excess_blob_gas: excess_blob_gas_and_price.as_ref().map(|g| g.excess_blob_gas as u128), + base_fee_per_blob_gas: excess_blob_gas_and_price.as_ref().map(|g| g.blob_gasprice), + blob_gas_used: excess_blob_gas_and_price.as_ref().map(|_| 0), + }; let current_block = self.storage_info.block(hash); let current_receipts = self.storage_info.receipts(hash); @@ -198,7 +275,10 @@ impl FeeHistoryService { block_number = Some(block.header.number); let gas_used = block.header.gas_used as f64; + let blob_gas_used = block.header.blob_gas_used.map(|g| g as f64); item.gas_used_ratio = gas_used / block.header.gas_limit as f64; + item.blob_gas_used_ratio = + blob_gas_used.map(|g| g / MAX_DATA_GAS_PER_BLOCK as f64).unwrap_or(0 as f64); // extract useful tx info (gas_used, effective_reward) let mut transactions: Vec<(u128, u128)> = receipts @@ -299,6 +379,10 @@ pub type FeeHistoryCache = Arc>>; pub struct FeeHistoryCacheItem { pub base_fee: u128, pub gas_used_ratio: f64, + pub base_fee_per_blob_gas: Option, + pub blob_gas_used_ratio: f64, + pub excess_blob_gas: Option, + pub blob_gas_used: Option, pub rewards: Vec, } @@ -307,29 +391,42 @@ pub struct FeeDetails { pub gas_price: Option, pub max_fee_per_gas: Option, pub max_priority_fee_per_gas: Option, + pub max_fee_per_blob_gas: Option, } impl FeeDetails { /// All values zero pub fn zero() -> Self { - Self { gas_price: Some(0), max_fee_per_gas: Some(0), max_priority_fee_per_gas: Some(0) } + Self { + gas_price: Some(0), + max_fee_per_gas: Some(0), + max_priority_fee_per_gas: Some(0), + max_fee_per_blob_gas: None, + } } /// If neither `gas_price` nor `max_fee_per_gas` is `Some`, this will set both to `0` pub fn or_zero_fees(self) -> Self { - let FeeDetails { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = self; + let FeeDetails { + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + max_fee_per_blob_gas, + } = self; let no_fees = gas_price.is_none() && max_fee_per_gas.is_none(); let gas_price = if no_fees { Some(0) } else { gas_price }; let max_fee_per_gas = if no_fees { Some(0) } else { max_fee_per_gas }; + let max_fee_per_blob_gas = if no_fees { None } else { max_fee_per_blob_gas }; - Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas } + Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas } } /// Turns this type into a tuple - pub fn split(self) -> (Option, Option, Option) { - let Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas } = self; - (gas_price, max_fee_per_gas, max_priority_fee_per_gas) + pub fn split(self) -> (Option, Option, Option, Option) { + let Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas } = + self; + (gas_price, max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas) } /// Creates a new instance from the request's gas related values @@ -337,17 +434,35 @@ impl FeeDetails { request_gas_price: Option, request_max_fee: Option, request_priority: Option, + max_fee_per_blob_gas: Option, ) -> Result { - match (request_gas_price, request_max_fee, request_priority) { - (gas_price, None, None) => { + match (request_gas_price, request_max_fee, request_priority, max_fee_per_blob_gas) { + (gas_price, None, None, None) => { // Legacy request, all default to gas price. Ok(FeeDetails { gas_price, max_fee_per_gas: gas_price, max_priority_fee_per_gas: gas_price, + max_fee_per_blob_gas: None, + }) + } + (_, max_fee, max_priority, None) => { + // eip-1559 + // Ensure `max_priority_fee_per_gas` is less or equal to `max_fee_per_gas`. + if let Some(max_priority) = max_priority { + let max_fee = max_fee.unwrap_or_default(); + if max_priority > max_fee { + return Err(BlockchainError::InvalidFeeInput) + } + } + Ok(FeeDetails { + gas_price: max_fee, + max_fee_per_gas: max_fee, + max_priority_fee_per_gas: max_priority, + max_fee_per_blob_gas: None, }) } - (_, max_fee, max_priority) => { + (_, max_fee, max_priority, max_fee_per_blob_gas) => { // eip-1559 // Ensure `max_priority_fee_per_gas` is less or equal to `max_fee_per_gas`. if let Some(max_priority) = max_priority { @@ -360,6 +475,7 @@ impl FeeDetails { gas_price: max_fee, max_fee_per_gas: max_fee, max_priority_fee_per_gas: max_priority, + max_fee_per_blob_gas, }) } } diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs new file mode 100644 index 0000000000000..cb3bf5aa983ca --- /dev/null +++ b/crates/anvil/tests/it/eip4844.rs @@ -0,0 +1,192 @@ +use crate::utils::http_provider; +use alloy_consensus::{SidecarBuilder, SimpleCoder}; +use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK}; +use alloy_network::TransactionBuilder; +use alloy_primitives::U256; +use alloy_provider::Provider; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use anvil::{spawn, Hardfork, NodeConfig}; + +#[tokio::test(flavor = "multi_thread")] +async fn can_send_eip4844_transaction() { + let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let (_api, handle) = spawn(node_config).await; + + let wallets = handle.dev_wallets().collect::>(); + let from = wallets[0].address(); + let to = wallets[1].address(); + let provider = http_provider(&handle.http_endpoint()); + + let eip1559_est = provider.estimate_eip1559_fees(None).await.unwrap(); + let gas_price = provider.get_gas_price().await.unwrap(); + + let sidecar: SidecarBuilder = SidecarBuilder::from_slice("Hello World".as_bytes()); + + let sidecar = sidecar.build().unwrap(); + let tx = TransactionRequest::default() + .with_from(from) + .with_to(to) + .with_nonce(0) + .with_max_fee_per_blob_gas(gas_price + 1) + .with_max_fee_per_gas(eip1559_est.max_fee_per_gas) + .with_max_priority_fee_per_gas(eip1559_est.max_priority_fee_per_gas) + .with_blob_sidecar(sidecar) + .value(U256::from(5)); + + let mut tx = WithOtherFields::new(tx); + + tx.populate_blob_hashes(); + + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + assert_eq!(receipt.blob_gas_used, Some(131072)); + assert_eq!(receipt.blob_gas_price, Some(0x1)); // 1 wei +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_send_multiple_blobs_in_one_tx() { + let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let (_api, handle) = spawn(node_config).await; + + let wallets = handle.dev_wallets().collect::>(); + + let from = wallets[0].address(); + let to = wallets[1].address(); + + let provider = http_provider(&handle.http_endpoint()); + + let eip1559_est = provider.estimate_eip1559_fees(None).await.unwrap(); + let gas_price = provider.get_gas_price().await.unwrap(); + + let large_data = vec![1u8; DATA_GAS_PER_BLOB as usize * 5]; // 131072 is DATA_GAS_PER_BLOB and also BYTE_PER_BLOB + let sidecar: SidecarBuilder = SidecarBuilder::from_slice(&large_data); + + let sidecar = sidecar.build().unwrap(); + + let tx = TransactionRequest::default() + .with_from(from) + .with_to(to) + .with_nonce(0) + .with_max_fee_per_blob_gas(gas_price + 1) + .with_max_fee_per_gas(eip1559_est.max_fee_per_gas) + .with_max_priority_fee_per_gas(eip1559_est.max_priority_fee_per_gas) + .with_blob_sidecar(sidecar); + let mut tx = WithOtherFields::new(tx); + + tx.populate_blob_hashes(); + + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + assert_eq!(receipt.blob_gas_used, Some(MAX_DATA_GAS_PER_BLOCK as u128)); + assert_eq!(receipt.blob_gas_price, Some(0x1)); // 1 wei +} + +#[tokio::test(flavor = "multi_thread")] +async fn cannot_exceed_six_blobs() { + let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let (_api, handle) = spawn(node_config).await; + + let wallets = handle.dev_wallets().collect::>(); + + let from = wallets[0].address(); + let to = wallets[1].address(); + + let provider = http_provider(&handle.http_endpoint()); + + let eip1559_est = provider.estimate_eip1559_fees(None).await.unwrap(); + let gas_price = provider.get_gas_price().await.unwrap(); + + let large_data = vec![1u8; DATA_GAS_PER_BLOB as usize * 6]; // 131072 is DATA_GAS_PER_BLOB and also BYTE_PER_BLOB + let sidecar: SidecarBuilder = SidecarBuilder::from_slice(&large_data); + + let sidecar = sidecar.build().unwrap(); + + let tx = TransactionRequest::default() + .with_from(from) + .with_to(to) + .with_nonce(0) + .with_max_fee_per_blob_gas(gas_price + 1) + .with_max_fee_per_gas(eip1559_est.max_fee_per_gas) + .with_max_priority_fee_per_gas(eip1559_est.max_priority_fee_per_gas) + .with_blob_sidecar(sidecar); + let mut tx = WithOtherFields::new(tx); + + tx.populate_blob_hashes(); + + let err = provider.send_transaction(tx).await.unwrap_err(); + + assert!(err.to_string().contains("too many blobs")); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_mine_blobs_when_exceeds_max_blobs() { + let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let (api, handle) = spawn(node_config).await; + api.anvil_set_auto_mine(false).await.unwrap(); + + let wallets = handle.dev_wallets().collect::>(); + + let from = wallets[0].address(); + let to = wallets[1].address(); + + let provider = http_provider(&handle.http_endpoint()); + + let eip1559_est = provider.estimate_eip1559_fees(None).await.unwrap(); + let gas_price = provider.get_gas_price().await.unwrap(); + + let first_batch = vec![1u8; DATA_GAS_PER_BLOB as usize * 3]; + let sidecar: SidecarBuilder = SidecarBuilder::from_slice(&first_batch); + + let num_blobs_first = sidecar.clone().take().len(); + + let sidecar = sidecar.build().unwrap(); + + let tx = TransactionRequest::default() + .with_from(from) + .with_to(to) + .with_nonce(0) + .with_max_fee_per_blob_gas(gas_price + 1) + .with_max_fee_per_gas(eip1559_est.max_fee_per_gas) + .with_max_priority_fee_per_gas(eip1559_est.max_priority_fee_per_gas) + .with_blob_sidecar(sidecar); + let mut tx = WithOtherFields::new(tx); + + tx.populate_blob_hashes(); + + let first_tx = provider.send_transaction(tx.clone()).await.unwrap(); + + let second_batch = vec![1u8; DATA_GAS_PER_BLOB as usize * 2]; + + let sidecar: SidecarBuilder = SidecarBuilder::from_slice(&second_batch); + + let num_blobs_second = sidecar.clone().take().len(); + + let sidecar = sidecar.build().unwrap(); + tx.set_blob_sidecar(sidecar); + tx.set_nonce(1); + tx.populate_blob_hashes(); + let second_tx = provider.send_transaction(tx).await.unwrap(); + + api.mine_one().await; + + let first_receipt = first_tx.get_receipt().await.unwrap(); + + api.mine_one().await; + let second_receipt = second_tx.get_receipt().await.unwrap(); + + let (first_block, second_block) = tokio::join!( + provider.get_block_by_number(first_receipt.block_number.unwrap().into(), false), + provider.get_block_by_number(second_receipt.block_number.unwrap().into(), false) + ); + assert_eq!( + first_block.unwrap().unwrap().header.blob_gas_used, + Some(DATA_GAS_PER_BLOB as u128 * num_blobs_first as u128) + ); + + assert_eq!( + second_block.unwrap().unwrap().header.blob_gas_used, + Some(DATA_GAS_PER_BLOB as u128 * num_blobs_second as u128) + ); + assert_eq!(first_receipt.block_number.unwrap() + 1, second_receipt.block_number.unwrap()); // Mined in two + // different blocks +} diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 799cd16f04047..94b1bc492c317 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -2,6 +2,7 @@ mod abi; mod anvil; mod anvil_api; mod api; +mod eip4844; mod fork; mod ganache; mod gas; @@ -14,7 +15,6 @@ mod otterscan; mod proof; mod pubsub; mod revert; - mod sign; mod state; mod traces; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index ff106a406543f..9b558e350d530 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -26,7 +26,7 @@ alloy-transport.workspace = true alloy-rpc-types.workspace = true alloy-sol-types.workspace = true -revm = { workspace = true, default-features = false, features = [ +revm = { workspace = true, features = [ "std", "serde", "memory_limit", @@ -35,6 +35,7 @@ revm = { workspace = true, default-features = false, features = [ "optional_no_base_fee", "arbitrary", "optimism", + "c-kzg" ] } revm-inspectors.workspace = true diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 8a5d40db554f3..72f4a6d171567 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -22,7 +22,12 @@ foundry-evm-traces.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } alloy-sol-types.workspace = true revm = { workspace = true, default-features = false, features = [ "std", @@ -32,6 +37,7 @@ revm = { workspace = true, default-features = false, features = [ "optional_block_gas_limit", "optional_no_base_fee", "arbitrary", + "c-kzg", ] } revm-inspectors.workspace = true diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 8a21d96526874..5fd6db65db49f 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -21,7 +21,7 @@ foundry-evm-traces.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } -revm = { workspace = true, default-features = false, features = [ +revm = { workspace = true, features = [ "std", "serde", "memory_limit", From d495216638c0adaa3df76190a6835537c579304d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 3 May 2024 02:16:38 +0400 Subject: [PATCH 0924/1963] fix: avoid panic on missing CREATE2 deployer (#7838) * fix: avoid panic on missing CREATE2 deployer * rm println * rm println --- crates/evm/core/src/utils.rs | 43 +++++++++++++++------------- crates/evm/traces/src/decoder/mod.rs | 3 +- crates/forge/tests/cli/script.rs | 36 +++++++++++++++++++++++ 3 files changed, 61 insertions(+), 21 deletions(-) diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index d1e73a1fa9024..20d8aa6478644 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -11,8 +11,8 @@ use revm::{ db::WrapDatabaseRef, handler::register::EvmHandler, interpreter::{ - return_ok, CallContext, CallInputs, CallScheme, CreateInputs, CreateOutcome, Gas, - InstructionResult, InterpreterResult, Transfer, + return_ok, CallContext, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, + Gas, InstructionResult, InterpreterResult, Transfer, }, primitives::{CreateScheme, EVMError, SpecId, TransactTo, KECCAK_EMPTY}, FrameOrResult, FrameResult, @@ -151,35 +151,38 @@ pub fn create2_handler_register>( return old_handle(ctx, inputs); } - // Sanity check that CREATE2 deployer exists. - let code_hash = ctx.evm.load_account(DEFAULT_CREATE2_DEPLOYER)?.0.info.code_hash; - if code_hash == KECCAK_EMPTY { - return Ok(FrameOrResult::Result(FrameResult::Create(CreateOutcome { - result: InterpreterResult { - result: InstructionResult::Revert, - output: "missing CREATE2 deployer".into(), - gas: Gas::new(inputs.gas_limit), - }, - address: None, - }))) - } + let gas_limit = inputs.gas_limit; // Generate call inputs for CREATE2 factory. let mut call_inputs = get_create2_factory_call_inputs(salt, *inputs); // Call inspector to change input or return outcome. - if let Some(outcome) = ctx.external.call(&mut ctx.evm, &mut call_inputs) { - create2_overrides_inner - .borrow_mut() - .push((ctx.evm.journaled_state.depth(), call_inputs.clone())); - return Ok(FrameOrResult::Result(FrameResult::Call(outcome))); - } + let outcome = ctx.external.call(&mut ctx.evm, &mut call_inputs); // Push data about current override to the stack. create2_overrides_inner .borrow_mut() .push((ctx.evm.journaled_state.depth(), call_inputs.clone())); + // Handle potential inspector override. + if let Some(outcome) = outcome { + return Ok(FrameOrResult::Result(FrameResult::Call(outcome))); + } + + // Sanity check that CREATE2 deployer exists. + let code_hash = ctx.evm.load_account(DEFAULT_CREATE2_DEPLOYER)?.0.info.code_hash; + if code_hash == KECCAK_EMPTY { + return Ok(FrameOrResult::Result(FrameResult::Call(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: "missing CREATE2 deployer".into(), + gas: Gas::new(gas_limit), + }, + memory_offset: 0..0, + }))) + } + + // Create CALL frame for CREATE2 factory invocation. let mut frame_or_result = ctx.evm.make_call_frame(&call_inputs); if let Ok(FrameOrResult::Frame(frame)) = &mut frame_or_result { diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 70720dc6c7085..cbbec53f748f8 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -310,7 +310,8 @@ impl CallTraceDecoder { if trace.address == DEFAULT_CREATE2_DEPLOYER { return DecodedCallTrace { label, - return_data: None, + return_data: (!trace.status.is_ok()) + .then(|| self.revert_decoder.decode(&trace.output, Some(trace.status))), contract, func: Some(DecodedCallData { signature: "create2".to_string(), args: vec![] }), }; diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 70b97b58fe10e..714bb036b5642 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1321,3 +1321,39 @@ contract SimpleScript is Script { let output = cmd.stdout_lossy(); assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); }); + +// https://github.com/foundry-rs/foundry/issues/7833 +forgetest_async!(error_no_create2, |prj, cmd| { + let (_api, handle) = + spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleContract {} + +contract SimpleScript is Script { + function run() external { + vm.startBroadcast(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + new SimpleContract{salt: bytes32(0)}(); + } +} + "#, + ) + .unwrap(); + + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--broadcast", + "--unlocked", + ]); + + let output = cmd.stderr_lossy(); + assert!(output.contains("missing CREATE2 deployer")); +}); From cc24a3e455baace683e5f45c56e082c3ae3ae547 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 2 May 2024 17:59:13 -0700 Subject: [PATCH 0925/1963] feat(anvil): eth_blobBaseFee --- crates/anvil/core/src/eth/mod.rs | 3 +++ crates/anvil/src/eth/api.rs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 8378506532a2c..dd7d05c973a95 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -69,6 +69,9 @@ pub enum EthRequest { )] EthMaxPriorityFeePerGas(()), + #[cfg_attr(feature = "serde", serde(rename = "eth_blobBaseFee", with = "empty_params"))] + EthBlobBaseFee(()), + #[cfg_attr( feature = "serde", serde(rename = "eth_accounts", alias = "eth_requestAccounts", with = "empty_params") diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index cc77746da7a75..a22526ce62304 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -170,6 +170,7 @@ impl EthApi { EthRequest::EthMaxPriorityFeePerGas(_) => { self.gas_max_priority_fee_per_gas().to_rpc_result() } + EthRequest::EthBlobBaseFee(_) => self.blob_base_fee().to_rpc_result(), EthRequest::EthAccounts(_) => self.accounts().to_rpc_result(), EthRequest::EthBlockNumber(_) => self.block_number().to_rpc_result(), EthRequest::EthGetStorageAt(addr, slot, block) => { @@ -564,6 +565,13 @@ impl EthApi { Ok(U256::from(self.backend.max_priority_fee_per_gas())) } + /// Returns the base fee per blob required to send a EIP-4844 tx. + /// + /// Handler for ETH RPC call: `eth_blobBaseFee` + pub fn blob_base_fee(&self) -> Result { + Ok(U256::from(self.backend.fees().base_fee_per_blob_gas())) + } + /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { U256::from(self.backend.gas_limit()) From 0dbdabac8c6b50a2de4258476f1ad8bd00afad0c Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 2 May 2024 18:16:00 -0700 Subject: [PATCH 0926/1963] Revert "feat(anvil): eth_blobBaseFee" This reverts commit cc24a3e455baace683e5f45c56e082c3ae3ae547. --- crates/anvil/core/src/eth/mod.rs | 3 --- crates/anvil/src/eth/api.rs | 8 -------- 2 files changed, 11 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index dd7d05c973a95..8378506532a2c 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -69,9 +69,6 @@ pub enum EthRequest { )] EthMaxPriorityFeePerGas(()), - #[cfg_attr(feature = "serde", serde(rename = "eth_blobBaseFee", with = "empty_params"))] - EthBlobBaseFee(()), - #[cfg_attr( feature = "serde", serde(rename = "eth_accounts", alias = "eth_requestAccounts", with = "empty_params") diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index a22526ce62304..cc77746da7a75 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -170,7 +170,6 @@ impl EthApi { EthRequest::EthMaxPriorityFeePerGas(_) => { self.gas_max_priority_fee_per_gas().to_rpc_result() } - EthRequest::EthBlobBaseFee(_) => self.blob_base_fee().to_rpc_result(), EthRequest::EthAccounts(_) => self.accounts().to_rpc_result(), EthRequest::EthBlockNumber(_) => self.block_number().to_rpc_result(), EthRequest::EthGetStorageAt(addr, slot, block) => { @@ -565,13 +564,6 @@ impl EthApi { Ok(U256::from(self.backend.max_priority_fee_per_gas())) } - /// Returns the base fee per blob required to send a EIP-4844 tx. - /// - /// Handler for ETH RPC call: `eth_blobBaseFee` - pub fn blob_base_fee(&self) -> Result { - Ok(U256::from(self.backend.fees().base_fee_per_blob_gas())) - } - /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { U256::from(self.backend.gas_limit()) From 36d9fab64858b103f61047afc5948bda7bc9ceb6 Mon Sep 17 00:00:00 2001 From: evalir Date: Fri, 3 May 2024 03:31:18 -0400 Subject: [PATCH 0927/1963] chore(`chisel`): make clippy happy (#7842) chore: make clippy happy --- crates/chisel/src/executor.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 424bcda901d7f..144ff38f6e1e4 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1210,12 +1210,9 @@ impl Type { #[inline] fn is_dynamic(&self) -> bool { match self { - Self::Builtin(ty) => match ty { - // TODO: Note, this is not entirely correct. Fixed arrays of non-dynamic types are - // not dynamic, nor are tuples of non-dynamic types. - DynSolType::Bytes | DynSolType::String | DynSolType::Array(_) => true, - _ => false, - }, + // TODO: Note, this is not entirely correct. Fixed arrays of non-dynamic types are + // not dynamic, nor are tuples of non-dynamic types. + Self::Builtin(DynSolType::Bytes | DynSolType::String | DynSolType::Array(_)) => true, Self::Array(_) => true, _ => false, } From 233b0f245dd7c1ec030a8af73dd7460020d1a2a1 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 3 May 2024 03:42:39 -0700 Subject: [PATCH 0928/1963] feat(anvil): eth_blobBaseFee (#7840) --- crates/anvil/core/src/eth/mod.rs | 3 +++ crates/anvil/src/eth/api.rs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 8378506532a2c..dd7d05c973a95 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -69,6 +69,9 @@ pub enum EthRequest { )] EthMaxPriorityFeePerGas(()), + #[cfg_attr(feature = "serde", serde(rename = "eth_blobBaseFee", with = "empty_params"))] + EthBlobBaseFee(()), + #[cfg_attr( feature = "serde", serde(rename = "eth_accounts", alias = "eth_requestAccounts", with = "empty_params") diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index cc77746da7a75..a22526ce62304 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -170,6 +170,7 @@ impl EthApi { EthRequest::EthMaxPriorityFeePerGas(_) => { self.gas_max_priority_fee_per_gas().to_rpc_result() } + EthRequest::EthBlobBaseFee(_) => self.blob_base_fee().to_rpc_result(), EthRequest::EthAccounts(_) => self.accounts().to_rpc_result(), EthRequest::EthBlockNumber(_) => self.block_number().to_rpc_result(), EthRequest::EthGetStorageAt(addr, slot, block) => { @@ -564,6 +565,13 @@ impl EthApi { Ok(U256::from(self.backend.max_priority_fee_per_gas())) } + /// Returns the base fee per blob required to send a EIP-4844 tx. + /// + /// Handler for ETH RPC call: `eth_blobBaseFee` + pub fn blob_base_fee(&self) -> Result { + Ok(U256::from(self.backend.fees().base_fee_per_blob_gas())) + } + /// Returns the block gas limit pub fn gas_limit(&self) -> U256 { U256::from(self.backend.gas_limit()) From 181dc3c5b704b1e6284ed82509b150b31bd77d61 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 3 May 2024 04:15:24 -0700 Subject: [PATCH 0929/1963] fix(anvil): include blob hashes in call env (#7839) * fix(anvil): include blob hashes in call env * nit --- crates/anvil/src/eth/backend/mem/mod.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ed27557b311e1..2c4554d017e95 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1114,7 +1114,21 @@ impl Backend { block_env: BlockEnv, ) -> EnvWithHandlerCfg { let WithOtherFields:: { - inner: TransactionRequest { from, to, gas, value, input, nonce, access_list, .. }, + inner: + TransactionRequest { + from, + to, + gas, + value, + input, + nonce, + access_list, + blob_versioned_hashes, + sidecar: _, + chain_id: _, + transaction_type: _, + .. // Rest of the gas fees related fields are taken from `fee_details` + }, .. } = request; @@ -1154,8 +1168,8 @@ impl Backend { chain_id: None, nonce, access_list: access_list.unwrap_or_default().flattened(), + blob_hashes: blob_versioned_hashes.unwrap_or_default(), optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, - ..Default::default() }; if env.block.basefee == revm::primitives::U256::ZERO { From e159e6e8360e1ef7c9cc5ae866d0dd18b32306fc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 3 May 2024 16:45:52 +0200 Subject: [PATCH 0930/1963] fix: more gas estimation checks for transfer (#7845) * fix: more gas estimation checks for transfer * rustmft * flip value check * style --- crates/anvil/src/eth/api.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index a22526ce62304..e1991bb62b271 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2192,8 +2192,14 @@ impl EthApi { // If the request is a simple native token transfer we can optimize // We assume it's a transfer if we have no input data. let to = request.to.as_ref().and_then(TxKind::to); - let likely_transfer = request.input.clone().into_input().is_none(); - if likely_transfer { + + // check certain fields to see if the request could be a simple transfer + let maybe_transfer = request.input.input().is_none() && + request.access_list.is_none() && + request.blob_versioned_hashes.is_none() && + request.value.is_some(); + + if maybe_transfer { if let Some(to) = to { if let Ok(target_code) = self.backend.get_code_with_state(&state, *to) { if target_code.as_ref().is_empty() { From 2e95d2f610b58b12578cffba29f6bf4556f81411 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 3 May 2024 17:30:48 +0200 Subject: [PATCH 0931/1963] chore: make clippy happy (#7847) --- crates/anvil/src/config.rs | 1 - crates/anvil/src/eth/backend/mem/inspector.rs | 1 - crates/anvil/src/eth/backend/mem/mod.rs | 1 - crates/anvil/src/eth/error.rs | 1 - crates/anvil/src/evm.rs | 10 +++------- 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 6905b69dcfe44..aa0a3fcccb6e4 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -33,7 +33,6 @@ use foundry_config::Config; use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, - revm, revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv}, utils::apply_chain_and_block_specific_env_changes, }; diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 6ea16a34057e2..892fa1778594e 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -7,7 +7,6 @@ use foundry_evm::{ decode::decode_console_logs, inspectors::{LogCollector, TracingInspector}, revm::{ - self, interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}, primitives::U256, EvmContext, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 2c4554d017e95..22e2360e83caf 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -64,7 +64,6 @@ use foundry_evm::{ decode::RevertDecoder, inspectors::AccessListInspector, revm::{ - self, db::CacheDB, interpreter::InstructionResult, primitives::{ diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index ce00da3194d2c..c411d8dec722a 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -13,7 +13,6 @@ use foundry_evm::{ backend::DatabaseError, decode::RevertDecoder, revm::{ - self, interpreter::InstructionResult, primitives::{EVMError, InvalidHeader}, }, diff --git a/crates/anvil/src/evm.rs b/crates/anvil/src/evm.rs index de1dfbd51e2a9..e6c76dd60e345 100644 --- a/crates/anvil/src/evm.rs +++ b/crates/anvil/src/evm.rs @@ -1,7 +1,6 @@ -use std::{fmt::Debug, sync::Arc}; - use alloy_primitives::Address; -use foundry_evm::revm::{self, precompile::Precompile, ContextPrecompile, ContextPrecompiles}; +use foundry_evm::revm::{precompile::Precompile, ContextPrecompile, ContextPrecompiles}; +use std::{fmt::Debug, sync::Arc}; /// Object-safe trait that enables injecting extra precompiles when using /// `anvil` as a library. @@ -42,10 +41,7 @@ pub fn inject_precompiles( mod tests { use crate::{evm::inject_precompiles, PrecompileFactory}; use alloy_primitives::Address; - use foundry_evm::revm::{ - self, - primitives::{address, Bytes, Precompile, PrecompileResult, SpecId}, - }; + use foundry_evm::revm::primitives::{address, Bytes, Precompile, PrecompileResult, SpecId}; #[test] fn build_evm_with_extra_precompiles() { From 3ed4af0f274ea4c6451ad52b9e6795b03bcb4e11 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 3 May 2024 12:52:12 -0700 Subject: [PATCH 0932/1963] fix(anvil): correctly use `BlobVersionNotSupported` (#7855) --- crates/anvil/src/eth/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index c411d8dec722a..61333822c9ea8 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -280,7 +280,7 @@ impl From for InvalidTransactionError { InvalidTransactionError::BlobCreateTransaction } InvalidTransaction::BlobVersionNotSupported => { - InvalidTransactionError::BlobVersionedHashesNotSupported + InvalidTransactionError::BlobVersionNotSupported } InvalidTransaction::EmptyBlobs => InvalidTransactionError::EmptyBlobs, InvalidTransaction::TooManyBlobs => InvalidTransactionError::TooManyBlobs, From fd9ecd8491c44e825a3bf3992cc319b93c1f822e Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 3 May 2024 14:13:32 -0700 Subject: [PATCH 0933/1963] fix(anvil): set blob fields in genesis (#7853) * fix(anvil): set blob fields in genesis * track blob fields in fork * nit + test --- crates/anvil/src/config.rs | 2 ++ crates/anvil/src/eth/backend/fork.rs | 5 +++++ crates/anvil/src/eth/backend/mem/storage.rs | 2 ++ crates/anvil/tests/it/eip4844.rs | 15 ++++++++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index aa0a3fcccb6e4..d2abc47ec371f 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1164,6 +1164,8 @@ latest block number: {latest_block}" backoff: self.fork_retry_backoff, compute_units_per_second: self.compute_units_per_second, total_difficulty: block.header.total_difficulty.unwrap_or_default(), + blob_gas_used: block.header.blob_gas_used, + blob_excess_gas_and_price: env.block.blob_excess_gas_and_price.clone(), }; let mut db = ForkedDatabase::new(backend, block_chain_db); diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 0d456b3c613b2..934225fbceb69 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -19,6 +19,7 @@ use parking_lot::{ lock_api::{RwLockReadGuard, RwLockWriteGuard}, RawRwLock, RwLock, }; +use revm::primitives::BlobExcessGasAndPrice; use std::{collections::HashMap, sync::Arc, time::Duration}; use tokio::sync::RwLock as AsyncRwLock; @@ -582,6 +583,10 @@ pub struct ClientForkConfig { pub timestamp: u64, /// The basefee of the forked block pub base_fee: Option, + /// Blob gas used of the forked block + pub blob_gas_used: Option, + /// Blob excess gas and price of the forked block + pub blob_excess_gas_and_price: Option, /// request timeout pub timeout: Duration, /// request retries for spurious networks diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 434490de575a1..916b07f6470b1 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -233,6 +233,8 @@ impl BlockchainStorage { gas_limit: env.block.gas_limit.to::(), beneficiary: env.block.coinbase, difficulty: env.block.difficulty, + blob_gas_used: env.block.blob_excess_gas_and_price.as_ref().map(|_| 0), + excess_blob_gas: env.block.get_blob_excess_gas().map(|v| v as u128), ..Default::default() }; let block = Block::new::(partial_header, vec![], vec![]); diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index cb3bf5aa983ca..180bcf17864ba 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -4,7 +4,7 @@ use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK}; use alloy_network::TransactionBuilder; use alloy_primitives::U256; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; use anvil::{spawn, Hardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] @@ -190,3 +190,16 @@ async fn can_mine_blobs_when_exceeds_max_blobs() { assert_eq!(first_receipt.block_number.unwrap() + 1, second_receipt.block_number.unwrap()); // Mined in two // different blocks } + +#[tokio::test(flavor = "multi_thread")] +async fn can_check_blob_fields_on_genesis() { + let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let (_api, handle) = spawn(node_config).await; + + let provider = http_provider(&handle.http_endpoint()); + + let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + + assert_eq!(block.header.blob_gas_used, Some(0)); + assert_eq!(block.header.excess_blob_gas, Some(0)); +} From f21760b9a9a0d6623ce69a1c93c99d8eb6a66be8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 4 May 2024 00:21:08 +0200 Subject: [PATCH 0934/1963] fix: enable eip712 for all signers (#7854) --- Cargo.lock | 1 + crates/cast/Cargo.toml | 6 +----- crates/wallets/Cargo.toml | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67c48847968b5..833828303b7f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -416,6 +416,7 @@ dependencies = [ "alloy-network", "alloy-primitives", "alloy-signer", + "alloy-sol-types", "async-trait", "coins-ledger", "futures-util", diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index ff7457e20c973..380dfabe0d33e 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -15,11 +15,7 @@ name = "cast" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # lib diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 31ea5607ce964..545207b4096d5 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -13,8 +13,8 @@ repository.workspace = true alloy-primitives.workspace = true alloy-signer = { workspace = true, features = ["eip712"] } alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } -alloy-signer-aws.workspace = true -alloy-signer-ledger.workspace = true +alloy-signer-aws = { workspace = true, features = ["eip712"] } +alloy-signer-ledger = { workspace = true, features = ["eip712"] } alloy-signer-trezor.workspace = true alloy-network.workspace = true alloy-consensus.workspace = true From 11e7dfdacf7292e135efb21a717f4c6ebbfe6fdb Mon Sep 17 00:00:00 2001 From: jxom Date: Sat, 4 May 2024 15:00:26 +1000 Subject: [PATCH 0935/1963] fix: transfer check (#7856) --- crates/anvil/src/eth/api.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index e1991bb62b271..7fd4133a68b7e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2196,8 +2196,7 @@ impl EthApi { // check certain fields to see if the request could be a simple transfer let maybe_transfer = request.input.input().is_none() && request.access_list.is_none() && - request.blob_versioned_hashes.is_none() && - request.value.is_some(); + request.blob_versioned_hashes.is_none(); if maybe_transfer { if let Some(to) = to { From d65c65f101f7384cab9b6c8566513206b3830eb5 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 4 May 2024 16:12:53 +0400 Subject: [PATCH 0936/1963] bump foundry-compilers (#7822) * patch compilers * update fixture regex * update patch * update patch * update patch * update patch * update patch * update patch * update patch * update patch * rm patch --- Cargo.lock | 9 ++-- Cargo.toml | 6 +-- crates/cast/bin/cmd/storage.rs | 21 +++++--- crates/chisel/benches/session_source.rs | 9 +++- crates/chisel/src/executor.rs | 22 +++++--- crates/chisel/src/session_source.rs | 60 ++++++++++----------- crates/chisel/tests/cache.rs | 3 +- crates/cli/src/utils/cmd.rs | 6 +-- crates/common/src/compile.rs | 46 ++++++++-------- crates/common/src/term.rs | 33 +++--------- crates/config/src/lib.rs | 71 +++++++++++++------------ crates/doc/src/builder.rs | 10 ++-- crates/evm/coverage/src/lib.rs | 50 ++++++++--------- crates/forge/bin/cmd/build.rs | 9 ++-- crates/forge/bin/cmd/clone.rs | 4 +- crates/forge/bin/cmd/coverage.rs | 21 ++++---- crates/forge/bin/cmd/fmt.rs | 6 ++- crates/forge/bin/cmd/geiger/mod.rs | 8 ++- crates/forge/bin/cmd/selectors.rs | 6 +-- crates/forge/bin/cmd/test/mod.rs | 8 +-- crates/forge/bin/cmd/tree.rs | 4 +- crates/forge/src/coverage.rs | 24 ++++++--- crates/forge/tests/cli/config.rs | 10 ++-- crates/linking/src/lib.rs | 8 ++- crates/script/src/build.rs | 5 +- crates/test-utils/src/util.rs | 9 ++-- crates/verify/src/bytecode.rs | 7 +-- crates/verify/src/etherscan/flatten.rs | 15 +++--- crates/verify/src/etherscan/mod.rs | 2 +- crates/verify/src/sourcify.rs | 2 +- 30 files changed, 264 insertions(+), 230 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 833828303b7f9..90effef319a85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3670,9 +3670,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64cb03e297eb85b9f84a195fec7390a5e9805d9b82b11b2af57f65fc6d4ceb7" +checksum = "351c6be2db0090c6c5ae214a7e768a1a61d7d46ff70ab9e7ee45c8f34e6c3c60" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3824,12 +3824,13 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.3.19" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5421772f768d43f81052159c5175e7d10941e0f0416dafd768f353ed9c554fd" +checksum = "d76463dbe20b1a0830acc74ef8ed59d9d9392f2aed21b0542001dc5a1a725b8e" dependencies = [ "alloy-json-abi", "alloy-primitives", + "auto_impl", "cfg-if", "dirs 5.0.1", "dunce", diff --git a/Cargo.toml b/Cargo.toml index 3513cf6c18e5f..550a0e644e4db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,8 +137,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.2.6", default-features = false } -foundry-compilers = { version = "0.3.18", default-features = false } +foundry-block-explorers = { version = "0.2.7", default-features = false } +foundry-compilers = { version = "0.4.0", default-features = false } ## revm # no default features to avoid c-kzg @@ -224,4 +224,4 @@ axum = "0.7" hyper = "1.0" reqwest = { version = "0.12", default-features = false } tower = "0.4" -tower-http = "0.5" +tower-http = "0.5" \ No newline at end of file diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 18411165ea130..6197e40c96e54 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -19,14 +19,16 @@ use foundry_common::{ ens::NameOrAddress, }; use foundry_compilers::{ - artifacts::StorageLayout, Artifact, ConfigurableContractArtifact, Project, Solc, + artifacts::StorageLayout, + compilers::{solc::SolcVersionManager, CompilerVersionManager}, + Artifact, CompilerConfig, ConfigurableContractArtifact, Project, }; use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, impl_figment_convert_cast, Config, }; use semver::Version; -use std::str::FromStr; +use std::{str::FromStr, sync::Arc}; /// The minimum Solc version for outputting storage layouts. /// @@ -138,7 +140,13 @@ impl StorageArgs { let root_path = root.path(); let mut project = etherscan_project(metadata, root_path)?; add_storage_layout_output(&mut project); - project.auto_detect = auto_detect; + + let vm = SolcVersionManager::default(); + project.compiler_config = if auto_detect { + CompilerConfig::AutoDetect(Arc::new(vm)) + } else { + CompilerConfig::Specific(vm.get_or_install(&version)?) + }; // Compile let mut out = ProjectCompiler::new().quiet(true).compile(&project)?; @@ -151,9 +159,8 @@ impl StorageArgs { if is_storage_layout_empty(&artifact.storage_layout) && auto_detect { // try recompiling with the minimum version eprintln!("The requested contract was compiled with {version} while the minimum version for storage layouts is {MIN_SOLC} and as a result the output may be empty."); - let solc = Solc::find_or_install_svm_version(MIN_SOLC.to_string())?; - project.solc = solc; - project.auto_detect = false; + let solc = SolcVersionManager::default().get_or_install(&MIN_SOLC)?; + project.compiler_config = CompilerConfig::Specific(solc); if let Ok(output) = ProjectCompiler::new().quiet(true).compile(&project) { out = output; let (_, new_artifact) = out @@ -277,7 +284,7 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) fn add_storage_layout_output(project: &mut Project) { project.artifacts.additional_values.storage_layout = true; let output_selection = project.artifacts.output_selection(); - project.solc_config.settings.push_all(output_selection); + project.settings.push_all(output_selection); } fn is_storage_layout_empty(storage_layout: &Option) -> bool { diff --git a/crates/chisel/benches/session_source.rs b/crates/chisel/benches/session_source.rs index 3c3196956b950..a6fc6e463ad1e 100644 --- a/crates/chisel/benches/session_source.rs +++ b/crates/chisel/benches/session_source.rs @@ -1,11 +1,16 @@ use chisel::session_source::{SessionSource, SessionSourceConfig}; use criterion::{criterion_group, Criterion}; -use foundry_compilers::Solc; +use foundry_compilers::{ + compilers::{solc::SolcVersionManager, CompilerVersionManager}, + Solc, +}; use once_cell::sync::Lazy; +use semver::Version; use std::hint::black_box; use tokio::runtime::Runtime; -static SOLC: Lazy = Lazy::new(|| Solc::find_or_install_svm_version("0.8.19").unwrap()); +static SOLC: Lazy = + Lazy::new(|| SolcVersionManager::default().get_or_install(&Version::new(0, 8, 19)).unwrap()); /// Benchmark for the `clone_with_new_line` function in [SessionSource] fn clone_with_new_line(c: &mut Criterion) { diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 144ff38f6e1e4..3ae465e4d8484 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -308,7 +308,7 @@ impl SessionSource { self.config.evm_opts.clone(), None, None, - self.solc.version().ok(), + Some(self.solc.version.clone()), ) .into(), ) @@ -1401,7 +1401,12 @@ impl<'a> Iterator for InstructionIter<'a> { #[cfg(test)] mod tests { use super::*; - use foundry_compilers::{error::SolcError, Solc}; + use foundry_compilers::{ + compilers::{solc::SolcVersionManager, CompilerVersionManager}, + error::SolcError, + Solc, + }; + use semver::Version; use std::sync::Mutex; #[test] @@ -1685,10 +1690,11 @@ mod tests { for _ in 0..3 { let mut is_preinstalled = PRE_INSTALL_SOLC_LOCK.lock().unwrap(); if !*is_preinstalled { - let solc = Solc::find_or_install_svm_version(version) - .and_then(|solc| solc.version().map(|v| (solc, v))); + let solc = SolcVersionManager::default() + .get_or_install(&version.parse().unwrap()) + .map(|solc| (solc.version.clone(), solc)); match solc { - Ok((solc, v)) => { + Ok((v, solc)) => { // successfully installed eprintln!("found installed Solc v{v} @ {}", solc.solc.display()); break @@ -1697,7 +1703,7 @@ mod tests { // try reinstalling eprintln!("error while trying to re-install Solc v{version}: {e}"); let solc = Solc::blocking_install(&version.parse().unwrap()); - if solc.map_err(SolcError::from).and_then(|solc| solc.version()).is_ok() { + if solc.map_err(SolcError::from).is_ok() { *is_preinstalled = true; break } @@ -1706,7 +1712,9 @@ mod tests { } } - let solc = Solc::find_or_install_svm_version("0.8.19").expect("could not install solc"); + let solc = SolcVersionManager::default() + .get_or_install(&Version::new(0, 8, 19)) + .expect("could not install solc"); SessionSource::new(solc, Default::default()) } diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 9deac254b0131..21fa3d8345763 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -7,8 +7,9 @@ use eyre::Result; use forge_fmt::solang_ext::SafeUnwrap; use foundry_compilers::{ - artifacts::{Source, Sources}, - CompilerInput, CompilerOutput, Solc, + artifacts::{Settings, Source, Sources}, + compilers::{solc::SolcVersionManager, CompilerInput, CompilerVersionManager}, + CompilerOutput, Solc, SolcInput, }; use foundry_config::{Config, SolcReq}; use foundry_evm::{backend::Backend, opts::EvmOpts}; @@ -94,20 +95,22 @@ impl SessionSourceConfig { let solc_req = if let Some(solc_req) = self.foundry_config.solc.clone() { solc_req } else if let Some(version) = Solc::installed_versions().into_iter().max() { - SolcReq::Version(version.into()) + SolcReq::Version(version) } else { if !self.foundry_config.offline { print!("{}", "No solidity versions installed! ".green()); } // use default - SolcReq::Version("0.8.19".parse().unwrap()) + SolcReq::Version(Version::new(0, 8, 19)) }; + let vm = SolcVersionManager::default(); + match solc_req { SolcReq::Version(version) => { // Validate that the requested evm version is supported by the solc version let req_evm_version = self.foundry_config.evm_version; - if let Some(compat_evm_version) = req_evm_version.normalize_version(&version) { + if let Some(compat_evm_version) = req_evm_version.normalize_version_solc(&version) { if req_evm_version > compat_evm_version { eyre::bail!( "The set evm version, {req_evm_version}, is not supported by solc {version}. Upgrade to a newer solc version." @@ -115,23 +118,22 @@ impl SessionSourceConfig { } } - let mut solc = Solc::find_svm_installed_version(version.to_string())?; - - if solc.is_none() { + let solc = if let Ok(solc) = vm.get_installed(&version) { + solc + } else { if self.foundry_config.offline { eyre::bail!("can't install missing solc {version} in offline mode") } println!("{}", format!("Installing solidity version {version}...").green()); - Solc::blocking_install(&version)?; - solc = Solc::find_svm_installed_version(version.to_string())?; - } - solc.ok_or_else(|| eyre::eyre!("Failed to install {version}")) + vm.install(&version)? + }; + Ok(solc) } SolcReq::Local(solc) => { if !solc.is_file() { eyre::bail!("`solc` {} does not exist", solc.display()); } - Ok(Solc::new(solc)) + Ok(Solc::new(solc)?) } } } @@ -182,11 +184,9 @@ impl SessionSource { /// A new instance of [SessionSource] #[track_caller] pub fn new(solc: Solc, mut config: SessionSourceConfig) -> Self { - if let Ok(v) = solc.version_short() { - if v < MIN_VM_VERSION && !config.no_vm { - tracing::info!(version=%v, minimum=%MIN_VM_VERSION, "Disabling VM injection"); - config.no_vm = true; - } + if solc.version < MIN_VM_VERSION && !config.no_vm { + tracing::info!(version=%solc.version, minimum=%MIN_VM_VERSION, "Disabling VM injection"); + config.no_vm = true; } Self { @@ -311,7 +311,7 @@ impl SessionSource { /// /// A [CompilerInput] object containing forge-std's `Vm` interface as well as the REPL contract /// source. - pub fn compiler_input(&self) -> CompilerInput { + pub fn compiler_input(&self) -> SolcInput { let mut sources = Sources::new(); sources.insert(self.file_name.clone(), Source::new(self.to_repl_source())); @@ -322,19 +322,17 @@ impl SessionSource { sources.insert(PathBuf::from("forge-std/Vm.sol"), Source::new(VM_SOURCE)); } + let settings = Settings { + remappings, + evm_version: Some(self.config.foundry_config.evm_version), + ..Default::default() + }; + // we only care about the solidity source, so we can safely unwrap - let mut compiler_input = CompilerInput::with_sources(sources) + SolcInput::build(sources, settings, &self.solc.version) .into_iter() .next() - .expect("Solidity source not found"); - - // get all remappings from the config - compiler_input.settings.remappings = remappings; - - // We also need to enforce the EVM version that the user has specified. - compiler_input.settings.evm_version = Some(self.config.foundry_config.evm_version); - - compiler_input + .expect("Solidity source not found") } /// Compiles the source using [solang_parser] @@ -442,7 +440,7 @@ impl SessionSource { /// /// The [SessionSource] represented as a Forge Script contract. pub fn to_script_source(&self) -> String { - let Version { major, minor, patch, .. } = self.solc.version().unwrap(); + let Version { major, minor, patch, .. } = self.solc.version; let Self { contract_name, global_code, top_level_code, run_code, config, .. } = self; let script_import = @@ -473,7 +471,7 @@ contract {contract_name} is Script {{ /// /// The [SessionSource] represented as a REPL contract. pub fn to_repl_source(&self) -> String { - let Version { major, minor, patch, .. } = self.solc.version().unwrap(); + let Version { major, minor, patch, .. } = self.solc.version; let Self { contract_name, global_code, top_level_code, run_code, config, .. } = self; let (vm_import, vm_constant) = if !config.no_vm { diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index c6b9625ebd7c3..5575a814a22c6 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -1,6 +1,7 @@ use chisel::session::ChiselSession; use foundry_compilers::EvmVersion; use foundry_config::{Config, SolcReq}; +use semver::Version; use serial_test::serial; use std::path::Path; @@ -231,7 +232,7 @@ fn test_solc_evm_configuration_mismatch() { // Force the solc version to be 0.8.13 which does not support Paris let foundry_config = Config { evm_version: EvmVersion::Paris, - solc: Some(SolcReq::Version("0.8.13".parse().expect("invalid semver"))), + solc: Some(SolcReq::Version(Version::new(0, 8, 13))), ..Default::default() }; diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index d8c5ab2227b81..96c9e2e5024c9 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -3,8 +3,8 @@ use alloy_primitives::Address; use eyre::{Result, WrapErr}; use foundry_common::{cli_warn, fs, TestFunctionExt}; use foundry_compilers::{ - artifacts::{CompactBytecode, CompactDeployedBytecode}, - cache::{CacheEntry, SolFilesCache}, + artifacts::{CompactBytecode, CompactDeployedBytecode, Settings}, + cache::{CacheEntry, CompilerCache}, utils::read_json_file, Artifact, ProjectCompileOutput, }; @@ -74,7 +74,7 @@ pub fn remove_contract( // TODO: Is there a better / more ergonomic way to get the artifacts given a project and a // contract name? pub fn get_cached_entry_by_name( - cache: &SolFilesCache, + cache: &CompilerCache, name: &str, ) -> Result<(PathBuf, CacheEntry)> { let mut cached_entry = None; diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 3b1d83c182502..3141a69786d81 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -6,10 +6,11 @@ use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ artifacts::{BytecodeObject, ContractBytecodeSome, Libraries}, + compilers::{solc::SolcVersionManager, Compiler, CompilerVersionManager}, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, - Artifact, ArtifactId, FileFilter, Project, ProjectCompileOutput, ProjectPathsConfig, Solc, - SolcConfig, + Artifact, ArtifactId, CompilerConfig, ConfigurableArtifacts, FileFilter, Project, + ProjectCompileOutput, ProjectPathsConfig, SolcConfig, SparseOutputFileFilter, }; use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; @@ -30,7 +31,7 @@ use std::{ /// This is merely a wrapper for [`Project::compile()`] which also prints to stdout depending on its /// settings. #[must_use = "ProjectCompiler does nothing unless you call a `compile*` method"] -pub struct ProjectCompiler { +pub struct ProjectCompiler { /// Whether we are going to verify the contracts after compilation. verify: Option, @@ -47,20 +48,20 @@ pub struct ProjectCompiler { bail: Option, /// Files to exclude. - filter: Option>, + filter: Option>>, /// Extra files to include, that are not necessarily in the project's source dir. files: Vec, } -impl Default for ProjectCompiler { +impl Default for ProjectCompiler { #[inline] fn default() -> Self { Self::new() } } -impl ProjectCompiler { +impl ProjectCompiler { /// Create a new builder with the default settings. #[inline] pub fn new() -> Self { @@ -122,7 +123,7 @@ impl ProjectCompiler { /// Sets the filter to use. #[inline] - pub fn filter(mut self, filter: Box) -> Self { + pub fn filter(mut self, filter: Box>) -> Self { self.filter = Some(filter); self } @@ -135,7 +136,10 @@ impl ProjectCompiler { } /// Compiles the project. - pub fn compile(mut self, project: &Project) -> Result { + pub fn compile( + mut self, + project: &Project, + ) -> Result> { // TODO: Avoid process::exit if !project.paths.has_input_files() && self.files.is_empty() { println!("Nothing to compile"); @@ -169,9 +173,9 @@ impl ProjectCompiler { /// ProjectCompiler::new().compile_with(|| Ok(prj.compile()?)).unwrap(); /// ``` #[instrument(target = "forge::compile", skip_all)] - fn compile_with(self, f: F) -> Result + fn compile_with(self, f: F) -> Result> where - F: FnOnce() -> Result, + F: FnOnce() -> Result>, { let quiet = self.quiet.unwrap_or(false); let bail = self.bail.unwrap_or(true); @@ -219,7 +223,7 @@ impl ProjectCompiler { } /// If configured, this will print sizes or names - fn handle_output(&self, output: &ProjectCompileOutput) { + fn handle_output(&self, output: &ProjectCompileOutput) { let print_names = self.print_names.unwrap_or(false); let print_sizes = self.print_sizes.unwrap_or(false); @@ -470,12 +474,12 @@ pub struct ContractInfo { /// If `verify` and it's a standalone script, throw error. Only allowed for projects. /// /// **Note:** this expects the `target_path` to be absolute -pub fn compile_target( +pub fn compile_target( target_path: &Path, - project: &Project, + project: &Project, quiet: bool, -) -> Result { - ProjectCompiler::new().quiet(quiet).files([target_path.into()]).compile(project) +) -> Result> { + ProjectCompiler::::new().quiet(quiet).files([target_path.into()]).compile(project) } /// Compiles an Etherscan source from metadata by creating a project. @@ -545,17 +549,17 @@ pub fn etherscan_project(metadata: &Metadata, target_path: impl AsRef) -> .build_with_root(sources_path); let v = metadata.compiler_version()?; - let v = format!("{}.{}.{}", v.major, v.minor, v.patch); - let solc = Solc::find_or_install_svm_version(v)?; + let vm = SolcVersionManager::default(); + let solc = vm.get_or_install(&v)?; + + let compiler_config = CompilerConfig::Specific(solc); Ok(Project::builder() - .solc_config(SolcConfig::builder().settings(settings).build()) - .no_auto_detect() + .settings(SolcConfig::builder().settings(settings).build().settings) .paths(paths) - .solc(solc) .ephemeral() .no_artifacts() - .build()?) + .build(compiler_config)?) } /// Bundles multiple `SkipBuildFilter` into a single `FileFilter` diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 5cfb5ef37fdda..81aff615c6a08 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -1,8 +1,7 @@ //! terminal utils use foundry_compilers::{ remappings::Remapping, - report::{self, BasicStdoutReporter, Reporter, SolcCompilerIoReporter}, - CompilerInput, CompilerOutput, Solc, + report::{self, BasicStdoutReporter, Reporter}, }; use once_cell::sync::Lazy; use semver::Version; @@ -90,9 +89,6 @@ impl Spinner { pub struct SpinnerReporter { /// The sender to the spinner thread. sender: mpsc::Sender, - /// Reporter that logs Solc compiler input and output to separate files if configured via env - /// var. - solc_io_report: SolcCompilerIoReporter, } impl SpinnerReporter { @@ -129,7 +125,7 @@ impl SpinnerReporter { }) .expect("failed to spawn thread"); - SpinnerReporter { sender, solc_io_report: SolcCompilerIoReporter::from_default_env() } + SpinnerReporter { sender } } fn send_msg(&self, msg: impl Into) { @@ -152,34 +148,21 @@ impl Drop for SpinnerReporter { } impl Reporter for SpinnerReporter { - fn on_solc_spawn( - &self, - _solc: &Solc, - version: &Version, - input: &CompilerInput, - dirty_files: &[PathBuf], - ) { + fn on_compiler_spawn(&self, compiler_name: &str, version: &Version, dirty_files: &[PathBuf]) { self.send_msg(format!( - "Compiling {} files with {}.{}.{}", + "Compiling {} files with {} {}.{}.{}", dirty_files.len(), + compiler_name, version.major, version.minor, version.patch )); - self.solc_io_report.log_compiler_input(input, version); } - fn on_solc_success( - &self, - _solc: &Solc, - version: &Version, - output: &CompilerOutput, - duration: &Duration, - ) { - self.solc_io_report.log_compiler_output(output, version); + fn on_compiler_success(&self, compiler_name: &str, version: &Version, duration: &Duration) { self.send_msg(format!( - "Solc {}.{}.{} finished in {duration:.2?}", - version.major, version.minor, version.patch + "{} {}.{}.{} finished in {duration:.2?}", + compiler_name, version.major, version.minor, version.patch )); } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 17d15a6b1da05..2a7ddc3ab484c 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -20,9 +20,11 @@ use foundry_compilers::{ RevertStrings, Settings, SettingsMetadata, Severity, }, cache::SOLIDITY_FILES_CACHE_FILENAME, + compilers::{solc::SolcVersionManager, CompilerVersionManager}, error::{SolcError, SolcIoError}, remappings::{RelativeRemapping, Remapping}, - ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, SolcConfig, + CompilerConfig, ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, + SolcConfig, }; use inflector::Inflector; use regex::Regex; @@ -35,6 +37,7 @@ use std::{ fs, path::{Path, PathBuf}, str::FromStr, + sync::Arc, }; // Macros useful for creating a figment. @@ -683,7 +686,7 @@ impl Config { /// Otherwise it returns the configured [EvmVersion]. pub fn get_normalized_evm_version(&self) -> EvmVersion { if let Some(version) = self.solc.as_ref().and_then(|solc| solc.try_version().ok()) { - if let Some(evm_version) = self.evm_version.normalize_version(&version) { + if let Some(evm_version) = self.evm_version.normalize_version_solc(&version) { return evm_version; } } @@ -756,14 +759,10 @@ impl Config { /// Creates a [Project] with the given `cached` and `no_artifacts` flags pub fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { - let mut project = Project::builder() + let project = Project::builder() .artifacts(self.configured_artifacts_handler()) .paths(self.project_paths()) - .allowed_path(&self.__root.0) - .allowed_paths(&self.libs) - .allowed_paths(&self.allow_paths) - .include_paths(&self.include_paths) - .solc_config(SolcConfig::builder().settings(self.solc_settings()?).build()) + .settings(SolcConfig::builder().settings(self.solc_settings()?).build().settings) .ignore_error_codes(self.ignored_error_codes.iter().copied().map(Into::into)) .ignore_paths(self.ignored_file_paths.clone()) .set_compiler_severity_filter(if self.deny_warnings { @@ -771,21 +770,16 @@ impl Config { } else { Severity::Error }) - .set_auto_detect(self.is_auto_detect()) .set_offline(self.offline) .set_cached(cached && !self.build_info) .set_build_info(!no_artifacts && self.build_info) .set_no_artifacts(no_artifacts) - .build()?; + .build(self.compiler_config()?)?; if self.force { self.cleanup(&project)?; } - if let Some(solc) = self.ensure_solc()? { - project.solc = solc; - } - Ok(project) } @@ -812,20 +806,19 @@ impl Config { /// If `solc` is [`SolcReq::Local`] then this will ensure that the path exists. fn ensure_solc(&self) -> Result, SolcError> { if let Some(ref solc) = self.solc { + let version_manager = SolcVersionManager::default(); let solc = match solc { SolcReq::Version(version) => { - let v = version.to_string(); - let mut solc = Solc::find_svm_installed_version(&v)?; - if solc.is_none() { + if let Ok(solc) = version_manager.get_installed(version) { + solc + } else { if self.offline { return Err(SolcError::msg(format!( "can't install missing solc {version} in offline mode" ))) } - Solc::blocking_install(version)?; - solc = Solc::find_svm_installed_version(&v)?; + version_manager.install(version)? } - solc } SolcReq::Local(solc) => { if !solc.is_file() { @@ -834,10 +827,10 @@ impl Config { solc.display() ))) } - Some(Solc::new(solc)) + Solc::new(solc)? } }; - return Ok(solc) + return Ok(Some(solc)) } Ok(None) @@ -890,7 +883,11 @@ impl Config { .scripts(&self.script) .artifacts(&self.out) .libs(self.libs.iter()) - .remappings(self.get_all_remappings()); + .remappings(self.get_all_remappings()) + .allowed_path(&self.__root.0) + .allowed_paths(&self.libs) + .allowed_paths(&self.allow_paths) + .include_paths(&self.include_paths); if let Some(build_info_path) = &self.build_info_path { builder = builder.build_infos(build_info_path); @@ -899,6 +896,15 @@ impl Config { builder.build_with_root(&self.__root.0) } + /// Returns configuration for a compiler to use when setting up a [Project]. + pub fn compiler_config(&self) -> Result, SolcError> { + if let Some(solc) = self.ensure_solc()? { + Ok(CompilerConfig::Specific(solc)) + } else { + Ok(CompilerConfig::AutoDetect(Arc::new(SolcVersionManager::default()))) + } + } + /// Returns all configured [`Remappings`] /// /// **Note:** this will add an additional `/=` remapping here, see @@ -1271,7 +1277,7 @@ impl Config { pub fn with_root(root: impl Into) -> Self { // autodetect paths let root = root.into(); - let paths = ProjectPathsConfig::builder().build_with_root(&root); + let paths = ProjectPathsConfig::builder().build_with_root::<()>(&root); let artifacts: PathBuf = paths.artifacts.file_name().unwrap().into(); Config { __root: paths.root.into(), @@ -1733,7 +1739,7 @@ impl Config { if let Some(version) = solc .try_version() .ok() - .and_then(|version| self.evm_version.normalize_version(&version)) + .and_then(|version| self.evm_version.normalize_version_solc(&version)) { // normalize evm_version based on the provided solc version self.evm_version = version; @@ -2098,10 +2104,7 @@ impl SolcReq { fn try_version(&self) -> Result { match self { SolcReq::Version(version) => Ok(version.clone()), - SolcReq::Local(path) => Solc::new(path).version().map_err(|err| { - warn!("failed to get solc version from {}: {}", path.display(), err); - err - }), + SolcReq::Local(path) => Solc::new(path).map(|solc| solc.version), } } } @@ -3754,7 +3757,7 @@ mod tests { )?; let config = Config::load(); - assert_eq!(config.solc, Some(SolcReq::Version("0.8.12".parse().unwrap()))); + assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 12)))); jail.create_file( "foundry.toml", @@ -3765,7 +3768,7 @@ mod tests { )?; let config = Config::load(); - assert_eq!(config.solc, Some(SolcReq::Version("0.8.12".parse().unwrap()))); + assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 12)))); jail.create_file( "foundry.toml", @@ -3780,7 +3783,7 @@ mod tests { jail.set_env("FOUNDRY_SOLC_VERSION", "0.6.6"); let config = Config::load(); - assert_eq!(config.solc, Some(SolcReq::Version("0.6.6".parse().unwrap()))); + assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 6, 6)))); Ok(()) }); } @@ -3799,7 +3802,7 @@ mod tests { )?; let config = Config::load(); - assert_eq!(config.solc, Some(SolcReq::Version("0.8.12".parse().unwrap()))); + assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 12)))); Ok(()) }); @@ -3814,7 +3817,7 @@ mod tests { )?; let config = Config::load(); - assert_eq!(config.solc, Some(SolcReq::Version("0.8.20".parse().unwrap()))); + assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 20)))); Ok(()) }); diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index ac54e97e21e22..ae51e982cf451 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -4,7 +4,7 @@ use crate::{ }; use forge_fmt::{FormatterConfig, Visitable}; use foundry_common::glob::expand_globs; -use foundry_compilers::utils::source_files_iter; +use foundry_compilers::{utils::source_files_iter, SOLC_EXTENSIONS}; use foundry_config::DocConfig; use itertools::Itertools; use mdbook::MDBook; @@ -101,7 +101,7 @@ impl DocBuilder { let ignored = expand_globs(&self.root, self.config.ignore.iter())?; // Collect and parse source files - let sources = source_files_iter(&self.sources) + let sources = source_files_iter(&self.sources, SOLC_EXTENSIONS) .filter(|file| !ignored.contains(file)) .collect::>(); @@ -110,7 +110,11 @@ impl DocBuilder { return Ok(()) } - let library_sources = self.libraries.iter().flat_map(source_files_iter).collect::>(); + let library_sources = self + .libraries + .iter() + .flat_map(|lib| source_files_iter(lib, SOLC_EXTENSIONS)) + .collect::>(); let combined_sources = sources .iter() diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 7a8f51c2e969f..a563764b8b0e8 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -14,6 +14,7 @@ use std::{ collections::{BTreeMap, HashMap}, fmt::Display, ops::{AddAssign, Deref, DerefMut}, + path::PathBuf, }; use eyre::{Context, Result}; @@ -31,9 +32,9 @@ pub use inspector::CoverageCollector; #[derive(Clone, Debug, Default)] pub struct CoverageReport { /// A map of source IDs to the source path - pub source_paths: HashMap<(Version, usize), String>, + pub source_paths: HashMap<(Version, usize), PathBuf>, /// A map of source paths to source IDs - pub source_paths_to_ids: HashMap<(Version, String), usize>, + pub source_paths_to_ids: HashMap<(Version, PathBuf), usize>, /// All coverage items for the codebase, keyed by the compiler version. pub items: HashMap>, /// All item anchors for the codebase, keyed by their contract ID. @@ -46,13 +47,13 @@ pub struct CoverageReport { impl CoverageReport { /// Add a source file path. - pub fn add_source(&mut self, version: Version, source_id: usize, path: String) { + pub fn add_source(&mut self, version: Version, source_id: usize, path: PathBuf) { self.source_paths.insert((version.clone(), source_id), path.clone()); self.source_paths_to_ids.insert((version, path), source_id); } /// Get the source ID for a specific source file path. - pub fn get_source_id(&self, version: Version, path: String) -> Option<&usize> { + pub fn get_source_id(&self, version: Version, path: PathBuf) -> Option<&usize> { self.source_paths_to_ids.get(&(version, path)) } @@ -78,21 +79,17 @@ impl CoverageReport { } /// Get coverage summaries by source file path - pub fn summary_by_file(&self) -> impl Iterator { - let mut summaries: BTreeMap = BTreeMap::new(); + pub fn summary_by_file(&self) -> impl Iterator { + let mut summaries = BTreeMap::new(); for (version, items) in self.items.iter() { for item in items { - let mut summary = summaries - .entry( - self.source_paths - .get(&(version.clone(), item.loc.source_id)) - .cloned() - .unwrap_or_else(|| { - format!("Unknown (ID: {}, solc: {version})", item.loc.source_id) - }), - ) - .or_default(); + let Some(path) = + self.source_paths.get(&(version.clone(), item.loc.source_id)).cloned() + else { + continue; + }; + let mut summary = summaries.entry(path).or_default(); summary += item; } } @@ -101,22 +98,17 @@ impl CoverageReport { } /// Get coverage items by source file path - pub fn items_by_source(&self) -> impl Iterator)> { - let mut items_by_source: BTreeMap> = BTreeMap::new(); + pub fn items_by_source(&self) -> impl Iterator)> { + let mut items_by_source: BTreeMap<_, Vec<_>> = BTreeMap::new(); for (version, items) in self.items.iter() { for item in items { - items_by_source - .entry( - self.source_paths - .get(&(version.clone(), item.loc.source_id)) - .cloned() - .unwrap_or_else(|| { - format!("Unknown (ID: {}, solc: {version})", item.loc.source_id) - }), - ) - .or_default() - .push(item.clone()); + let Some(path) = + self.source_paths.get(&(version.clone(), item.loc.source_id)).cloned() + else { + continue; + }; + items_by_source.entry(path).or_default().push(item.clone()); } } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index c2e6715a4615f..673198fdc80ff 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -3,7 +3,7 @@ use clap::Parser; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}; -use foundry_compilers::{Project, ProjectCompileOutput}; +use foundry_compilers::{Project, ProjectCompileOutput, SolcSparseFileFilter}; use foundry_config::{ figment::{ self, @@ -94,8 +94,11 @@ impl BuildArgs { .bail(!self.format_json); if let Some(skip) = self.skip { if !skip.is_empty() { - compiler = compiler - .filter(Box::new(SkipBuildFilters::new(skip, project.root().to_path_buf())?)); + let filter = SolcSparseFileFilter::new(SkipBuildFilters::new( + skip.clone(), + project.root().to_path_buf(), + )?); + compiler = compiler.filter(Box::new(filter)); } } let output = compiler.compile(&project)?; diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index ca6fdf7be767b..c3315e19835d5 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -12,7 +12,7 @@ use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ artifacts::{output_selection::ContractOutputSelection, Settings, StorageLayout}, remappings::{RelativeRemapping, Remapping}, - ConfigurableContractArtifact, ProjectCompileOutput, ProjectPathsConfig, + ConfigurableContractArtifact, ProjectCompileOutput, ProjectPathsConfig, Solc, }; use foundry_config::{Chain, Config}; use std::{ @@ -417,7 +417,7 @@ fn update_config_by_metadata( /// A list of remappings is returned fn dump_sources(meta: &Metadata, root: &PathBuf, no_reorg: bool) -> Result> { // get config - let path_config = ProjectPathsConfig::builder().build_with_root(root); + let path_config = ProjectPathsConfig::builder().build_with_root::(root); // we will canonicalize the sources directory later let src_dir = &path_config.sources; let lib_dir = &path_config.libraries[0]; diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 2b5ce85a6f3c2..d099035fb8043 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -125,13 +125,12 @@ impl CoverageArgs { // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 // And also in new releases of solidity: // https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 - project.solc_config.settings = - project.solc_config.settings.with_via_ir_minimum_optimization() + project.settings = project.settings.with_via_ir_minimum_optimization() } else { - project.solc_config.settings.optimizer.disable(); - project.solc_config.settings.optimizer.runs = None; - project.solc_config.settings.optimizer.details = None; - project.solc_config.settings.via_ir = None; + project.settings.optimizer.disable(); + project.settings.optimizer.runs = None; + project.settings.optimizer.details = None; + project.settings.via_ir = None; } let output = ProjectCompiler::default() @@ -186,8 +185,7 @@ impl CoverageArgs { .filter_map(|(id, artifact)| { let contract_id = ContractId { version: id.version.clone(), - source_id: *report - .get_source_id(id.version, id.source.to_string_lossy().to_string())?, + source_id: *report.get_source_id(id.version, id.source)?, contract_name: id.name, }; let source_maps = ( @@ -348,10 +346,9 @@ impl CoverageArgs { }); for (artifact_id, hits, is_deployed_code) in data { - if let Some(source_id) = report.get_source_id( - artifact_id.version.clone(), - artifact_id.source.to_string_lossy().to_string(), - ) { + if let Some(source_id) = + report.get_source_id(artifact_id.version.clone(), artifact_id.source) + { let source_id = *source_id; report.add_hit_map( &ContractId { diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 06e05a5680dc6..6ff5387faef57 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -3,6 +3,7 @@ use eyre::Result; use forge_fmt::{format_to, parse, print_diagnostics_report}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; use foundry_common::{fs, glob::expand_globs, term::cli_warn}; +use foundry_compilers::SOLC_EXTENSIONS; use foundry_config::impl_figment_convert_basic; use rayon::prelude::*; use similar::{ChangeTag, TextDiff}; @@ -81,7 +82,10 @@ impl FmtArgs { } if path.is_dir() { - inputs.extend(foundry_compilers::utils::source_files_iter(path)); + inputs.extend(foundry_compilers::utils::source_files_iter( + path, + SOLC_EXTENSIONS, + )); } else if path.is_sol() { inputs.push(path.to_path_buf()); } else { diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 27555ed1a7944..451c29dbd7924 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -1,7 +1,7 @@ use clap::{Parser, ValueHint}; use eyre::{Result, WrapErr}; use foundry_cli::utils::LoadConfig; -use foundry_compilers::Graph; +use foundry_compilers::{resolver::parse::SolData, Graph}; use foundry_config::{impl_figment_convert_basic, Config}; use itertools::Itertools; use rayon::prelude::*; @@ -62,7 +62,11 @@ impl GeigerArgs { let mut sources: Vec = { if self.paths.is_empty() { - Graph::resolve(&config.project_paths())?.files().keys().cloned().collect() + Graph::::resolve(&config.project_paths())? + .files() + .keys() + .cloned() + .collect() } else { self.paths .iter() diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 8e07fb1f61caf..d3cada4b5025f 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -81,8 +81,7 @@ impl SelectorsSubcommands { output .into_artifacts_with_files() .filter(|(file, _, _)| { - let is_sources_path = file - .starts_with(&project.paths.sources.to_string_lossy().to_string()); + let is_sources_path = file.starts_with(&project.paths.sources); let is_test = file.is_sol_test(); is_sources_path && !is_test @@ -212,8 +211,7 @@ impl SelectorsSubcommands { outcome .into_artifacts_with_files() .filter(|(file, _, _)| { - let is_sources_path = file - .starts_with(&project.paths.sources.to_string_lossy().to_string()); + let is_sources_path = file.starts_with(&project.paths.sources); let is_test = file.is_sol_test(); is_sources_path && !is_test diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index ed0c1305cb7bc..b20017c85a469 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -19,7 +19,9 @@ use foundry_common::{ evm::EvmArgs, shell, }; -use foundry_compilers::{artifacts::output_selection::OutputSelection, utils::source_files_iter}; +use foundry_compilers::{ + artifacts::output_selection::OutputSelection, utils::source_files_iter, SOLC_EXTENSIONS, +}; use foundry_config::{ figment, figment::{ @@ -149,7 +151,7 @@ impl TestArgs { filter: &ProjectPathsAwareFilter, ) -> Result> { let mut project = config.create_project(true, true)?; - project.solc_config.settings.output_selection = + project.settings.output_selection = OutputSelection::common_output_selection(["abi".to_string()]); let output = project.compile()?; @@ -201,7 +203,7 @@ impl TestArgs { } // Always recompile all sources to ensure that `getCode` cheatcode can use any artifact. - test_sources.extend(source_files_iter(project.paths.sources)); + test_sources.extend(source_files_iter(project.paths.sources, SOLC_EXTENSIONS)); Ok(test_sources) } diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index 8133010253894..088975d8752e5 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -2,7 +2,7 @@ use clap::Parser; use eyre::Result; use foundry_cli::{opts::ProjectPathsArgs, utils::LoadConfig}; use foundry_compilers::{ - resolver::{Charset, TreeOptions}, + resolver::{parse::SolData, Charset, TreeOptions}, Graph, }; @@ -28,7 +28,7 @@ foundry_config::impl_figment_convert!(TreeArgs, opts); impl TreeArgs { pub fn run(self) -> Result<()> { let config = self.try_load_config_emit_warnings()?; - let graph = Graph::resolve(&config.project_paths())?; + let graph = Graph::::resolve(&config.project_paths())?; let opts = TreeOptions { charset: self.charset, no_dedupe: self.no_dedupe }; graph.print_with_options(opts); diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 19724bc2fa9a4..b3ccc7e82c469 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -7,7 +7,7 @@ pub use foundry_evm::coverage::*; use std::{ collections::{hash_map, HashMap}, io::Write, - path::PathBuf, + path::{Path, PathBuf}, }; /// A coverage reporter. @@ -49,7 +49,7 @@ impl CoverageReporter for SummaryReporter { fn report(mut self, report: &CoverageReport) -> eyre::Result<()> { for (path, summary) in report.summary_by_file() { self.total += &summary; - self.add_row(path, summary); + self.add_row(path.display(), summary); } self.add_row("Total", self.total.clone()); @@ -95,7 +95,7 @@ impl<'a> CoverageReporter for LcovReporter<'a> { }); writeln!(self.destination, "TN:")?; - writeln!(self.destination, "SF:{file}")?; + writeln!(self.destination, "SF:{}", file.display())?; for item in items { let line = item.loc.line; @@ -150,7 +150,7 @@ pub struct DebugReporter; impl CoverageReporter for DebugReporter { fn report(self, report: &CoverageReport) -> eyre::Result<()> { for (path, items) in report.items_by_source() { - println!("Uncovered for {path}:"); + println!("Uncovered for {}:", path.display()); items.iter().for_each(|item| { if item.hits == 0 { println!("- {item}"); @@ -235,7 +235,15 @@ impl CoverageReporter for BytecodeReporter { writeln!( formatted, "{} {:40} // {}: {}:{}-{}:{} ({}-{})", - hits, code, source_path, sline, spos, eline, epos, start, end + hits, + code, + source_path.display(), + sline, + spos, + eline, + epos, + start, + end )?; } else if let Some(source_id) = source_id { writeln!( @@ -260,7 +268,7 @@ impl CoverageReporter for BytecodeReporter { /// Cache line number offsets for source files struct LineNumberCache { root: PathBuf, - line_offsets: HashMap>, + line_offsets: HashMap>, } impl LineNumberCache { @@ -268,8 +276,8 @@ impl LineNumberCache { LineNumberCache { root, line_offsets: HashMap::new() } } - pub fn get_position(&mut self, path: &str, offset: usize) -> eyre::Result<(usize, usize)> { - let line_offsets = match self.line_offsets.entry(path.to_owned()) { + pub fn get_position(&mut self, path: &Path, offset: usize) -> eyre::Result<(usize, usize)> { + let line_offsets = match self.line_offsets.entry(path.to_path_buf()) { hash_map::Entry::Occupied(o) => o.into_mut(), hash_map::Entry::Vacant(v) => { let text = fs::read_to_string(self.root.join(path))?; diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 8c69fcc4f84ea..a2997be0399bd 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -2,7 +2,10 @@ use alloy_primitives::{Address, B256, U256}; use foundry_cli::utils as forge_utils; -use foundry_compilers::artifacts::{BytecodeHash, OptimizerDetails, RevertStrings, YulDetails}; +use foundry_compilers::{ + artifacts::{BytecodeHash, OptimizerDetails, RevertStrings, YulDetails}, + compilers::{solc::SolcVersionManager, CompilerVersionManager}, +}; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, fs_permissions::{FsAccessPermission, PathPermission}, @@ -356,9 +359,8 @@ contract Foo {} assert!(cmd.stderr_lossy().contains("this/solc/does/not/exist does not exist")); // `OTHER_SOLC_VERSION` was installed in previous step, so we can use the path to this directly - let local_solc = foundry_compilers::Solc::find_svm_installed_version(OTHER_SOLC_VERSION) - .unwrap() - .expect("solc is installed"); + let local_solc = + SolcVersionManager::default().get_or_install(&OTHER_SOLC_VERSION.parse().unwrap()).unwrap(); cmd.forge_fuse().args(["build", "--force", "--use"]).arg(local_solc.solc).root_arg(); let stdout = cmd.stdout_lossy(); assert!(stdout.contains("Compiler run successful")); diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index 869a18e64b34d..ff019ae0699bb 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -232,8 +232,12 @@ mod tests { .build() .unwrap(); - let project = - Project::builder().paths(paths).ephemeral().no_artifacts().build().unwrap(); + let project = Project::builder() + .paths(paths) + .ephemeral() + .no_artifacts() + .build(Default::default()) + .unwrap(); let mut output = project.compile().unwrap(); diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 06d76af74ab9e..8c41cfde63af3 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -19,7 +19,7 @@ use foundry_compilers::{ artifacts::{BytecodeObject, Libraries}, info::ContractInfo, utils::source_files_iter, - ArtifactId, ProjectCompileOutput, + ArtifactId, ProjectCompileOutput, SOLC_EXTENSIONS, }; use foundry_linking::{LinkOutput, Linker}; use std::{path::PathBuf, str::FromStr, sync::Arc}; @@ -151,7 +151,8 @@ impl PreprocessedState { }; let sources_to_compile = - source_files_iter(project.paths.sources.as_path()).chain([target_path.to_path_buf()]); + source_files_iter(project.paths.sources.as_path(), SOLC_EXTENSIONS) + .chain([target_path.to_path_buf()]); let output = ProjectCompiler::new() .quiet_if(args.opts.silent) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 9d9905d1ce789..eec9d8bbc5c43 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1,7 +1,8 @@ use crate::init_tracing; use eyre::{Result, WrapErr}; use foundry_compilers::{ - cache::SolFilesCache, + artifacts::Settings, + cache::CompilerCache, error::Result as SolcResult, project_util::{copy_dir, TempProject}, ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, @@ -532,7 +533,9 @@ impl TestProject { #[track_caller] pub fn assert_create_dirs_exists(&self) { self.paths().create_all().unwrap_or_else(|_| panic!("Failed to create project paths")); - SolFilesCache::default().write(&self.paths().cache).expect("Failed to create cache"); + CompilerCache::::default() + .write(&self.paths().cache) + .expect("Failed to create cache"); self.assert_all_paths_exist(); } @@ -1064,7 +1067,7 @@ static IGNORE_IN_FIXTURES: Lazy = Lazy::new(|| { let re = &[ // solc version r" ?Solc(?: version)? \d+.\d+.\d+", - r" with \d+.\d+.\d+", + r" with(?: Solc)? \d+.\d+.\d+", // solc runs r"runs: \d+, μ: \d+, ~: \d+", // elapsed time diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 317a65941f94e..484b7780184c7 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -15,7 +15,7 @@ use foundry_common::{ use foundry_compilers::{ artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode}, info::ContractInfo, - Artifact, EvmVersion, + Artifact, EvmVersion, SolcSparseFileFilter, }; use foundry_config::{figment, impl_figment_convert, Chain, Config}; use foundry_evm::{ @@ -372,10 +372,11 @@ impl VerifyBytecodeArgs { if let Some(skip) = &self.skip { if !skip.is_empty() { - compiler = compiler.filter(Box::new(SkipBuildFilters::new( + let filter = SolcSparseFileFilter::new(SkipBuildFilters::new( skip.to_owned(), project.root().to_path_buf(), - )?)); + )?); + compiler = compiler.filter(Box::new(filter)); } } let output = compiler.compile(&project)?; diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index 62e534a66785e..ca028fdabac78 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -3,7 +3,8 @@ use eyre::{Context, Result}; use foundry_block_explorers::verify::CodeFormat; use foundry_compilers::{ artifacts::{BytecodeHash, Source}, - AggregatedCompilerOutput, CompilerInput, Project, Solc, + compilers::{solc::SolcVersionManager, Compiler, CompilerVersionManager}, + AggregatedCompilerOutput, Project, SolcInput, }; use semver::{BuildMetadata, Version}; use std::{collections::BTreeMap, path::Path}; @@ -18,7 +19,7 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource { target: &Path, version: &Version, ) -> Result<(String, String, CodeFormat)> { - let metadata = project.solc_config.settings.metadata.as_ref(); + let metadata = project.settings.metadata.as_ref(); let bch = metadata.and_then(|m| m.bytecode_hash).unwrap_or_default(); eyre::ensure!( @@ -66,18 +67,18 @@ impl EtherscanFlattenedSource { version: &Version, contract_path: &Path, ) -> Result<()> { + let vm = SolcVersionManager::default(); let version = strip_build_meta(version.clone()); - let solc = Solc::find_svm_installed_version(version.to_string())? - .unwrap_or(Solc::blocking_install(&version)?); + let solc = vm.get_or_install(&version)?; - let input = CompilerInput { + let input = SolcInput { language: "Solidity".to_string(), sources: BTreeMap::from([("contract.sol".into(), Source::new(content))]), settings: Default::default(), }; - let out = solc.compile(&input)?; - if out.has_error() { + let (_, out) = Compiler::compile(&solc, input)?; + if out.errors.iter().any(|e| e.is_error()) { let mut o = AggregatedCompilerOutput::default(); o.extend(version, out); let diags = o.diagnostics(&[], &[], Default::default()); diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index ec218e714e90d..33dea487eb315 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -407,7 +407,7 @@ impl EtherscanVerificationProvider { SolcReq::Version(version) => return Ok(version.to_owned()), SolcReq::Local(solc) => { if solc.is_file() { - return Ok(Solc::new(solc).version()?) + return Ok(Solc::new(solc).map(|solc| solc.version)?) } } } diff --git a/crates/verify/src/sourcify.rs b/crates/verify/src/sourcify.rs index d30946f8945e6..71fde6336133b 100644 --- a/crates/verify/src/sourcify.rs +++ b/crates/verify/src/sourcify.rs @@ -112,7 +112,7 @@ impl SourcifyVerificationProvider { let cache = project.read_cache_file()?; let (path, entry) = get_cached_entry_by_name(&cache, &args.contract.name)?; - if entry.solc_config.settings.metadata.is_none() { + if entry.compiler_settings.metadata.is_none() { eyre::bail!( r#"Contract {} was compiled without the solc `metadata` setting. Sourcify requires contract metadata for verification. From aa333c6bebf43cb59de34cdf40b2e2bd70d98442 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 4 May 2024 15:17:37 +0300 Subject: [PATCH 0937/1963] chore(invariant) - rename TargetAbiSelector (#7850) * chore(invariant) - rename TargetAbiSelector * Rename contract_abi to artifact --- crates/evm/evm/src/executors/invariant/mod.rs | 10 +++++----- .../targetAbi/TargetArtifactSelectors.t.sol | 11 ++++++----- .../targetAbi/TargetArtifactSelectors2.t.sol | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 37d433a315db9..23972e0c59a55 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -53,8 +53,8 @@ sol! { } #[derive(Default)] - struct FuzzAbiSelector { - string contract_abi; + struct FuzzArtifactSelector { + string artifact; bytes4[] selectors; } @@ -77,7 +77,7 @@ sol! { function targetArtifacts() public view returns (string[] memory targetedArtifacts); #[derive(Default)] - function targetArtifactSelectors() public view returns (FuzzAbiSelector[] memory targetedArtifactSelectors); + function targetArtifactSelectors() public view returns (FuzzArtifactSelector[] memory targetedArtifactSelectors); #[derive(Default)] function targetContracts() public view returns (address[] memory targetedContracts); @@ -400,10 +400,10 @@ impl<'a> InvariantExecutor<'a> { .call_sol_default(invariant_address, &IInvariantTest::targetArtifactSelectorsCall {}); // Insert them into the executor `targeted_abi`. - for IInvariantTest::FuzzAbiSelector { contract_abi, selectors } in + for IInvariantTest::FuzzArtifactSelector { artifact, selectors } in result.targetedArtifactSelectors { - let identifier = self.validate_selected_contract(contract_abi, &selectors)?; + let identifier = self.validate_selected_contract(artifact, &selectors)?; self.artifact_filters.targeted.entry(identifier).or_default().extend(selectors); } diff --git a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol index d7c8bcdfae4aa..2957c57de2af6 100644 --- a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol @@ -3,8 +3,8 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -struct FuzzAbiSelector { - string contract_abi; +struct FuzzArtifactSelector { + string artifact; bytes4[] selectors; } @@ -27,11 +27,12 @@ contract TargetArtifactSelectors is DSTest { hello = new Hi(); } - function targetArtifactSelectors() public returns (FuzzAbiSelector[] memory) { - FuzzAbiSelector[] memory targets = new FuzzAbiSelector[](1); + function targetArtifactSelectors() public returns (FuzzArtifactSelector[] memory) { + FuzzArtifactSelector[] memory targets = new FuzzArtifactSelector[](1); bytes4[] memory selectors = new bytes4[](1); selectors[0] = Hi.no_change.selector; - targets[0] = FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:Hi", selectors); + targets[0] = + FuzzArtifactSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:Hi", selectors); return targets; } diff --git a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol index 573350c6e0238..c12cae74f5942 100644 --- a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol @@ -3,8 +3,8 @@ pragma solidity 0.8.18; import "ds-test/test.sol"; -struct FuzzAbiSelector { - string contract_abi; +struct FuzzArtifactSelector { + string artifact; bytes4[] selectors; } @@ -46,18 +46,20 @@ contract TargetArtifactSelectors2 is DSTest { parent = new Parent(); } - function targetArtifactSelectors() public returns (FuzzAbiSelector[] memory) { - FuzzAbiSelector[] memory targets = new FuzzAbiSelector[](2); + function targetArtifactSelectors() public returns (FuzzArtifactSelector[] memory) { + FuzzArtifactSelector[] memory targets = new FuzzArtifactSelector[](2); bytes4[] memory selectors_child = new bytes4[](1); selectors_child[0] = Child.change_parent.selector; - targets[0] = - FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Child", selectors_child); + targets[0] = FuzzArtifactSelector( + "default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Child", selectors_child + ); bytes4[] memory selectors_parent = new bytes4[](1); selectors_parent[0] = Parent.create.selector; - targets[1] = - FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Parent", selectors_parent); + targets[1] = FuzzArtifactSelector( + "default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Parent", selectors_parent + ); return targets; } From 2e9b584705ed91c5cb02ce3e4810062bed5c496d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 May 2024 10:05:45 +0200 Subject: [PATCH 0938/1963] chore(deps): weekly `cargo update` (#7857) --- Cargo.lock | 224 +++++++++++++++++++++++++++++------------------------ 1 file changed, 122 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 90effef319a85..892f5281c3af8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ab339ca7b4ea9115f0578c941abc80a171edf8e5eadd01e6c4237b68db8083" +checksum = "545885d9b0b2c30fd344ae291439b4bfe59e48dd62fbc862f8503d98088967dc" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44294729c145cf7ae65feab544b5b81fb2bb7e2fd060214842eb3989a1e9d882" +checksum = "786689872ec4e7d354810ab0dffd48bb40b838c047522eb031cbd47d15634849" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c715249705afa1e32be79dabfd35e2ef0f1cc02ad2cf48c9d1e20026ee637b" +checksum = "525448f6afc1b70dd0f9d0a8145631bf2f5e434678ab23ab18409ca264cae6b3" dependencies = [ "alloy-rlp", "arbitrary", @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef9a94a27345fb31e3fcb5f5e9f592bb4847493b07fa1e47dd9fde2222f2e28" +checksum = "89c80a2cb97e7aa48611cbb63950336f9824a174cdf670527cc6465078a26ea1" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -481,9 +481,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31fe73cd259527e24dc2dbfe64bc95e5ddfcd2b2731f670a11ff72b2be2c25b" +checksum = "c58894b58ac50979eeac6249661991ac40b9d541830d9a725f7714cc9ef08c23" dependencies = [ "alloy-json-abi", "const-hex", @@ -498,18 +498,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c8d6e74e4feeaa2bcfdecfd3da247ab53c67bd654ba1907270c32e02b142331" +checksum = "7da8e71ea68e780cc203919e03f69f59e7afe92d2696fb1dcb6662f61e4031b6" dependencies = [ "winnow 0.6.7", ] [[package]] name = "alloy-sol-types" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afaffed78bfb17526375754931e045f96018aa810844b29c7aef823266dd4b4b" +checksum = "399287f68d1081ed8b1f4903c49687658b95b142207d7cb4ae2f4813915343ef" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -524,7 +524,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" dependencies = [ "alloy-json-rpc", - "base64 0.22.0", + "base64 0.22.1", "futures-util", "futures-utils-wasm", "serde", @@ -637,47 +637,48 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -1113,15 +1114,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4707646259764ab59fd9a50e9de2e92c637b28b36285d6f6fa030e915fbd9" +checksum = "baaa0be6ee7d90b775ae6ccb6d2ba182b91219ec2001f92338773a094246af1d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1185,9 +1186,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.22.0" +version = "1.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4453868f71232e0baf5947972972e87813c8bbb311351f669a6ad6aa5b86ee63" +checksum = "db70afa14e99c6d3bfa45f1c41ec28414f628d1f5a242d8ae2578f4b7a4b8480" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1207,9 +1208,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d70fb493f4183f5102d8a8d0cc9b57aec29a762f55c0e7bf527e0f7177bb408" +checksum = "ca3d6c4cba4e009391b72b0fcf12aff04ea3c9c3aa2ecaafa330326a8bd7e601" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1229,9 +1230,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3f37549b3e38b7ea5efd419d4d7add6ea1e55223506eb0b4fef9d25e7cc90d" +checksum = "73400dc239d14f63d932f4ca7b55af5e9ef1f857f7d70655249ccc287adb2570" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1251,9 +1252,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2ff219a5d4b795cd33251c19dbe9c4b401f2b2cbe513e07c76ada644eaf34e" +checksum = "10f8858308af76fba3e5ffcf1bb56af5471574d2bdfaf0159470c25bc2f760e5" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1347,9 +1348,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44e7945379821074549168917e89e60630647e186a69243248f08c6d168b975a" +checksum = "1cf64e73ef8d4dac6c933230d56d136b75b252edcf82ed36e37d603090cd7348" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1373,9 +1374,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cc56a5c96ec741de6c5e6bf1ce6948be969d6506dfa9c39cffc284e31e4979b" +checksum = "8c19fdae6e3d5ac9cd01f2d6e6c359c5f5a3e028c2d148a8f5b90bf3399a18a7" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1528,9 +1529,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64-simd" @@ -1868,9 +1869,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" dependencies = [ "jobserver", "libc", @@ -2167,9 +2168,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "comfy-table" @@ -2513,9 +2514,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "der" @@ -2705,6 +2706,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -3430,9 +3442,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4556222738635b7a3417ae6130d8f52201e45a0c4d1a907f0826383adb5f85e7" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -3699,7 +3711,7 @@ dependencies = [ "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", - "base64 0.22.0", + "base64 0.22.1", "const-hex", "dialoguer", "eyre", @@ -4653,9 +4665,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -4806,9 +4818,9 @@ dependencies = [ [[package]] name = "http-range-header" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe" +checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a" [[package]] name = "httparse" @@ -5185,6 +5197,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.10.5" @@ -5370,9 +5388,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libm" @@ -5810,9 +5828,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -5833,9 +5851,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -6189,7 +6207,7 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "serde", ] @@ -6210,9 +6228,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -6221,9 +6239,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -6231,9 +6249,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", @@ -6244,9 +6262,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -6974,7 +6992,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "bytes", "futures-channel", "futures-core", @@ -7342,7 +7360,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "rustls-pki-types", ] @@ -7464,9 +7482,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96560eea317a9cc4e0bb1f6a2c93c09a19b8c4fc5cb3fcc0ec1c094cd783e2" +checksum = "76ad2bbb0ae5100a07b7a6f2ed7ab5fd0045551a4c507989b7a620046ea3efdc" dependencies = [ "sdd", ] @@ -7482,9 +7500,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +checksum = "7f55c82c700538496bdc329bb4918a81f87cc8888811bd123cf325a0f2f8d309" dependencies = [ "dyn-clone", "schemars_derive", @@ -7494,14 +7512,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +checksum = "83263746fe5e32097f06356968a077f96089739c927a61450efa069905eec108" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -7635,18 +7653,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", @@ -7655,13 +7673,13 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -7903,9 +7921,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -8094,7 +8112,7 @@ dependencies = [ "sha2", "thiserror", "url", - "zip 1.1.1", + "zip 1.1.4", ] [[package]] @@ -8134,9 +8152,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70aba06097b6eda3c15f6eebab8a6339e121475bcf08bbe6758807e716c372a1" +checksum = "5aa0cefd02f532035d83cfec82647c6eb53140b0485220760e669f4bad489e36" dependencies = [ "paste", "proc-macro2", @@ -8480,9 +8498,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -8490,7 +8508,6 @@ dependencies = [ "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -9491,18 +9508,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393" dependencies = [ "proc-macro2", "quote", @@ -9551,15 +9568,18 @@ dependencies = [ [[package]] name = "zip" -version = "1.1.1" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2655979068a1f8fa91cb9e8e5b9d3ee54d18e0ddc358f2f4a395afc0929a84b" +checksum = "9cc23c04387f4da0374be4533ad1208cbb091d5c11d070dfef13676ad6497164" dependencies = [ "arbitrary", - "byteorder", "crc32fast", "crossbeam-utils", + "displaydoc", "flate2", + "indexmap", + "num_enum", + "thiserror", ] [[package]] From c08aa6899183ec2fcaa3b5bb8e37874300498dd3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 5 May 2024 16:52:20 +0200 Subject: [PATCH 0939/1963] feat: remove most of ethers (#7861) * feat: remove most of ethers * chore: update deny --- Cargo.lock | 717 +++------------------ Cargo.toml | 15 +- README.md | 4 +- crates/anvil/Cargo.toml | 24 +- crates/anvil/core/Cargo.toml | 3 +- crates/anvil/core/src/eth/serde_helpers.rs | 29 - crates/anvil/core/src/types.rs | 19 +- crates/cast/Cargo.toml | 3 +- crates/cast/bin/cmd/bind.rs | 2 +- crates/cheatcodes/Cargo.toml | 5 +- crates/common/Cargo.toml | 14 +- crates/common/src/fmt/ui.rs | 2 +- crates/config/Cargo.toml | 2 +- crates/config/src/cache.rs | 4 +- crates/config/src/fix.rs | 2 +- crates/config/src/lib.rs | 6 +- crates/evm/core/Cargo.toml | 2 +- crates/evm/core/src/fork/backend.rs | 2 +- crates/evm/evm/Cargo.toml | 7 +- crates/fmt/Cargo.toml | 2 +- crates/fmt/src/string.rs | 2 +- crates/fmt/tests/formatter.rs | 6 +- crates/forge/Cargo.toml | 14 +- crates/forge/bin/cmd/bind.rs | 4 +- crates/forge/tests/cli/cmd.rs | 31 - crates/forge/tests/cli/config.rs | 14 +- crates/forge/tests/cli/script.rs | 4 +- crates/linking/Cargo.toml | 2 +- crates/test-utils/Cargo.toml | 2 +- crates/test-utils/src/util.rs | 4 +- crates/wallets/src/wallet_signer.rs | 1 - deny.toml | 22 +- docs/dev/debugging.md | 3 +- 33 files changed, 153 insertions(+), 820 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 892f5281c3af8..66abc3c553bcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,7 +247,7 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", - "reqwest 0.12.4", + "reqwest", "serde_json", "tokio", "tracing", @@ -308,7 +308,7 @@ dependencies = [ "alloy-transport-ws", "futures", "pin-project", - "reqwest 0.12.4", + "reqwest", "serde", "serde_json", "tokio", @@ -347,7 +347,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-types", "alloy-serde", - "jsonwebtoken 9.3.0", + "jsonwebtoken", "rand 0.8.5", "serde", "thiserror", @@ -543,7 +543,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04 dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.4", + "reqwest", "serde_json", "tower", "url", @@ -725,8 +725,6 @@ dependencies = [ "crc 3.2.1", "ctrlc", "ethereum-forkid", - "ethers", - "ethers-core", "eyre", "fdlimit", "flate2", @@ -741,12 +739,12 @@ dependencies = [ "itertools 0.12.1", "k256", "parking_lot", - "pretty_assertions", "rand 0.8.5", "revm", "serde", "serde_json", "serde_repr", + "similar-asserts", "tempfile", "thiserror", "tikv-jemallocator", @@ -755,7 +753,7 @@ dependencies = [ "tracing", "tracing-subscriber", "vergen", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -770,6 +768,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-types", "alloy-rpc-types-trace", + "alloy-serde", "alloy-trie", "anvil-core", "bytes", @@ -834,7 +833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44055e597c674aef7cb903b2b9f6e4cba1277ed0d2d61dae7cd52d7ffa81f8e2" dependencies = [ "unicode-width", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -1141,7 +1140,7 @@ dependencies = [ "hex", "http 0.2.12", "hyper 0.14.28", - "ring 0.17.8", + "ring", "time", "tokio", "tracing", @@ -1515,12 +1514,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -1650,6 +1643,17 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata 0.1.10", +] + [[package]] name = "bstr" version = "1.9.1" @@ -1719,27 +1723,6 @@ dependencies = [ "either", ] -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "c-kzg" version = "1.0.0" @@ -1821,8 +1804,7 @@ dependencies = [ "const-hex", "criterion", "dunce", - "ethers-contract", - "ethers-core", + "ethers-contract-abigen", "evm-disassembler", "evmole", "eyre", @@ -1849,7 +1831,7 @@ dependencies = [ "tokio", "tracing", "vergen", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -1872,11 +1854,6 @@ name = "cc" version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" -dependencies = [ - "jobserver", - "libc", - "once_cell", -] [[package]] name = "cfg-if" @@ -1911,7 +1888,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest 0.12.4", + "reqwest", "revm", "rustyline", "semver 1.0.22", @@ -1926,7 +1903,7 @@ dependencies = [ "tracing", "tracing-subscriber", "vergen", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -2250,12 +2227,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "convert_case" version = "0.4.0" @@ -2617,12 +2588,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "diff" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" - [[package]] name = "digest" version = "0.9.0" @@ -2808,39 +2773,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "endian-type" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" -[[package]] -name = "enr" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" -dependencies = [ - "base64 0.21.7", - "bytes", - "hex", - "k256", - "log", - "rand 0.8.5", - "rlp", - "serde", - "sha3", - "zeroize", -] - [[package]] name = "enumn" version = "0.1.13" @@ -2995,53 +2933,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "ethers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816841ea989f0c69e459af1cf23a6b0033b19a55424a1ea3a30099becdb8dec0" -dependencies = [ - "ethers-addressbook", - "ethers-contract", - "ethers-core", - "ethers-etherscan", - "ethers-middleware", - "ethers-providers", - "ethers-signers", - "ethers-solc", -] - -[[package]] -name = "ethers-addressbook" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5495afd16b4faa556c3bba1f21b98b4983e53c1755022377051a975c3b021759" -dependencies = [ - "ethers-core", - "once_cell", - "serde", - "serde_json", -] - -[[package]] -name = "ethers-contract" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fceafa3578c836eeb874af87abacfb041f92b4da0a78a5edd042564b8ecdaaa" -dependencies = [ - "const-hex", - "ethers-contract-abigen", - "ethers-contract-derive", - "ethers-core", - "ethers-providers", - "futures-util", - "once_cell", - "pin-project", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "ethers-contract-abigen" version = "2.0.14" @@ -3052,13 +2943,11 @@ dependencies = [ "const-hex", "dunce", "ethers-core", - "ethers-etherscan", "eyre", "prettyplease", "proc-macro2", "quote", "regex", - "reqwest 0.11.27", "serde", "serde_json", "syn 2.0.60", @@ -3066,22 +2955,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "ethers-contract-derive" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87689dcabc0051cde10caaade298f9e9093d65f6125c14575db3fd8c669a168f" -dependencies = [ - "Inflector", - "const-hex", - "ethers-contract-abigen", - "ethers-core", - "proc-macro2", - "quote", - "serde_json", - "syn 2.0.60", -] - [[package]] name = "ethers-core" version = "2.0.14" @@ -3112,138 +2985,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "ethers-etherscan" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" -dependencies = [ - "chrono", - "ethers-core", - "reqwest 0.11.27", - "semver 1.0.22", - "serde", - "serde_json", - "thiserror", - "tracing", -] - -[[package]] -name = "ethers-middleware" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f9fdf09aec667c099909d91908d5eaf9be1bd0e2500ba4172c1d28bfaa43de" -dependencies = [ - "async-trait", - "auto_impl", - "ethers-contract", - "ethers-core", - "ethers-providers", - "ethers-signers", - "futures-channel", - "futures-locks", - "futures-util", - "instant", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", - "tracing-futures", - "url", -] - -[[package]] -name = "ethers-providers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" -dependencies = [ - "async-trait", - "auto_impl", - "base64 0.21.7", - "bytes", - "const-hex", - "enr", - "ethers-core", - "futures-channel", - "futures-core", - "futures-timer", - "futures-util", - "hashers", - "http 0.2.12", - "instant", - "jsonwebtoken 8.3.0", - "once_cell", - "pin-project", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite 0.20.1", - "tracing", - "tracing-futures", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winapi", - "ws_stream_wasm", -] - -[[package]] -name = "ethers-signers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228875491c782ad851773b652dd8ecac62cda8571d3bc32a5853644dd26766c2" -dependencies = [ - "async-trait", - "coins-bip32", - "coins-bip39", - "const-hex", - "elliptic-curve", - "eth-keystore", - "ethers-core", - "rand 0.8.5", - "sha2", - "thiserror", - "tracing", -] - -[[package]] -name = "ethers-solc" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66244a771d9163282646dbeffe0e6eca4dda4146b6498644e678ac6089b11edd" -dependencies = [ - "cfg-if", - "const-hex", - "dirs 5.0.1", - "dunce", - "ethers-core", - "glob", - "home", - "md-5", - "num_cpus", - "once_cell", - "path-slash", - "rayon", - "regex", - "semver 1.0.22", - "serde", - "serde_json", - "solang-parser", - "svm-rs 0.3.5", - "thiserror", - "tiny-keccak", - "tokio", - "tracing", - "walkdir", - "yansi 0.5.1", -] - [[package]] name = "event-listener" version = "2.5.3" @@ -3497,7 +3238,7 @@ dependencies = [ "criterion", "dialoguer", "dunce", - "ethers-contract", + "ethers-contract-abigen", "evm-disassembler", "eyre", "forge-doc", @@ -3526,20 +3267,20 @@ dependencies = [ "parking_lot", "paste", "path-slash", - "pretty_assertions", "proptest", "rayon", "regex", - "reqwest 0.12.4", + "reqwest", "revm-inspectors", "rustc-hash", "semver 1.0.22", "serde", "serde_json", "similar", + "similar-asserts", "solang-parser", "strum", - "svm-rs 0.5.2", + "svm-rs", "tempfile", "thiserror", "tikv-jemallocator", @@ -3551,7 +3292,7 @@ dependencies = [ "tracing-subscriber", "vergen", "watchexec", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -3587,7 +3328,7 @@ dependencies = [ "ariadne", "foundry-config", "itertools 0.12.1", - "pretty_assertions", + "similar-asserts", "solang-parser", "thiserror", "toml 0.8.12", @@ -3635,7 +3376,7 @@ dependencies = [ "serde_json", "tempfile", "tracing", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -3660,7 +3401,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest 0.12.4", + "reqwest", "revm-primitives", "semver 1.0.22", "serde", @@ -3668,7 +3409,7 @@ dependencies = [ "tempfile", "tokio", "tracing", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -3690,7 +3431,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers", - "reqwest 0.12.4", + "reqwest", "semver 1.0.22", "serde", "serde_json", @@ -3781,7 +3522,7 @@ dependencies = [ "tracing", "tracing-error", "tracing-subscriber", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -3818,12 +3559,12 @@ dependencies = [ "globset", "num-format", "once_cell", - "pretty_assertions", - "reqwest 0.12.4", + "reqwest", "rustc-hash", "semver 1.0.22", "serde", "serde_json", + "similar-asserts", "tempfile", "thiserror", "tokio", @@ -3831,7 +3572,7 @@ dependencies = [ "tracing", "url", "walkdir", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -3862,14 +3603,14 @@ dependencies = [ "serde_json", "sha2", "solang-parser", - "svm-rs 0.5.2", + "svm-rs", "svm-rs-builds", "tempfile", "thiserror", "tokio", "tracing", "walkdir", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -3889,14 +3630,14 @@ dependencies = [ "number_prefix", "once_cell", "path-slash", - "pretty_assertions", "regex", - "reqwest 0.12.4", + "reqwest", "revm-primitives", "semver 1.0.22", "serde", "serde_json", "serde_regex", + "similar-asserts", "solang-parser", "tempfile", "thiserror", @@ -4051,7 +3792,7 @@ dependencies = [ "tempfile", "tokio", "tracing", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -4088,10 +3829,10 @@ dependencies = [ "foundry-config", "once_cell", "parking_lot", - "pretty_assertions", "rand 0.8.5", "regex", "serde_json", + "similar-asserts", "tracing", "tracing-subscriber", "walkdir", @@ -4134,16 +3875,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "fs4" version = "0.8.2" @@ -4243,16 +3974,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "futures-locks" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" -dependencies = [ - "futures-channel", - "futures-task", -] - [[package]] name = "futures-macro" version = "0.3.30" @@ -4276,16 +3997,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" -[[package]] -name = "futures-timer" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" -dependencies = [ - "gloo-timers", - "send_wrapper 0.4.0", -] - [[package]] name = "futures-util" version = "0.3.30" @@ -4310,15 +4021,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -4366,7 +4068,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "848efa0f1210cea8638f95691c82a46f98a74b9e3524f01d4955ebc25a8f84f3" dependencies = [ - "bstr", + "bstr 1.9.1", "btoi", "gix-date", "itoa", @@ -4380,7 +4082,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d252a0eddb6df74600d3d8872dc9fe98835a7da43110411d705b682f49d4ac1" dependencies = [ - "bstr", + "bstr 1.9.1", "gix-config-value", "gix-features", "gix-glob", @@ -4403,7 +4105,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" dependencies = [ "bitflags 2.5.0", - "bstr", + "bstr 1.9.1", "gix-path", "libc", "thiserror", @@ -4415,7 +4117,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc164145670e9130a60a21670d9b6f0f4f8de04e5dd256c51fa5a0340c625902" dependencies = [ - "bstr", + "bstr 1.9.1", "itoa", "thiserror", "time", @@ -4449,7 +4151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" dependencies = [ "bitflags 2.5.0", - "bstr", + "bstr 1.9.1", "gix-features", "gix-path", ] @@ -4481,7 +4183,7 @@ version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d96bd620fd08accdd37f70b2183cfa0b001b4f1c6ade8b7f6e15cb3d9e261ce" dependencies = [ - "bstr", + "bstr 1.9.1", "btoi", "gix-actor", "gix-features", @@ -4500,7 +4202,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18609c8cbec8508ea97c64938c33cd305b75dfc04a78d0c3b78b8b3fd618a77c" dependencies = [ - "bstr", + "bstr 1.9.1", "gix-trace", "home", "once_cell", @@ -4574,7 +4276,7 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba9b3737b2cef3dcd014633485f0034b0f1a931ee54aeb7d8f87f177f3c89040" dependencies = [ - "bstr", + "bstr 1.9.1", "thiserror", ] @@ -4591,24 +4293,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", - "bstr", + "bstr 1.9.1", "log", "regex-automata 0.4.6", "regex-syntax 0.8.3", ] -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "group" version = "0.13.0" @@ -4674,15 +4364,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hashers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" -dependencies = [ - "fxhash", -] - [[package]] name = "heck" version = "0.4.1" @@ -5236,15 +4917,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "jobserver" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.69" @@ -5265,20 +4937,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "jsonwebtoken" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" -dependencies = [ - "base64 0.21.7", - "pem 1.1.1", - "ring 0.16.20", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "jsonwebtoken" version = "9.3.0" @@ -5287,8 +4945,8 @@ checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" dependencies = [ "base64 0.21.7", "js-sys", - "pem 3.0.4", - "ring 0.17.8", + "pem", + "ring", "serde", "serde_json", "simple_asn1", @@ -5970,7 +5628,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c62dcb6174f9cb326eac248f07e955d5d559c272730b6c03e396b443b562788" dependencies = [ - "bstr", + "bstr 1.9.1", "normpath", "winapi", ] @@ -6124,17 +5782,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "paste" version = "1.0.14" @@ -6154,9 +5801,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest 0.10.7", - "hmac", - "password-hash", - "sha2", ] [[package]] @@ -6177,7 +5821,7 @@ checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" dependencies = [ "inlinable_string", "pear_codegen", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -6192,15 +5836,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - [[package]] name = "pem" version = "3.0.4" @@ -6518,16 +6153,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "pretty_assertions" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" -dependencies = [ - "diff", - "yansi 0.5.1", -] - [[package]] name = "prettyplease" version = "0.2.19" @@ -6632,7 +6257,7 @@ dependencies = [ "quote", "syn 2.0.60", "version_check", - "yansi 1.0.1", + "yansi", ] [[package]] @@ -6945,47 +6570,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", - "hyper-rustls 0.24.2", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", - "tokio", - "tokio-rustls 0.24.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots 0.25.4", - "winreg 0.50.0", -] - [[package]] name = "reqwest" version = "0.12.4" @@ -7029,7 +6613,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.26.1", - "winreg 0.52.0", + "winreg", ] [[package]] @@ -7122,21 +6706,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.8" @@ -7148,7 +6717,7 @@ dependencies = [ "getrandom 0.2.14", "libc", "spin 0.9.8", - "untrusted 0.9.0", + "untrusted", "windows-sys 0.52.0", ] @@ -7301,7 +6870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", - "ring 0.17.8", + "ring", "rustls-webpki 0.101.7", "sct", ] @@ -7313,7 +6882,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", - "ring 0.17.8", + "ring", "rustls-pki-types", "rustls-webpki 0.102.3", "subtle", @@ -7376,8 +6945,8 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -7386,9 +6955,9 @@ version = "0.102.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" dependencies = [ - "ring 0.17.8", + "ring", "rustls-pki-types", - "untrusted 0.9.0", + "untrusted", ] [[package]] @@ -7546,8 +7115,8 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -7639,12 +7208,6 @@ dependencies = [ "pest", ] -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "send_wrapper" version = "0.6.0" @@ -7885,6 +7448,20 @@ name = "similar" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" +dependencies = [ + "bstr 0.2.17", + "unicode-segmentation", +] + +[[package]] +name = "similar-asserts" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" +dependencies = [ + "console", + "similar", +] [[package]] name = "simple_asn1" @@ -8075,26 +7652,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "svm-rs" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" -dependencies = [ - "dirs 5.0.1", - "fs2", - "hex", - "once_cell", - "reqwest 0.11.27", - "semver 1.0.22", - "serde", - "serde_json", - "sha2", - "thiserror", - "url", - "zip 0.6.6", -] - [[package]] name = "svm-rs" version = "0.5.2" @@ -8105,14 +7662,14 @@ dependencies = [ "dirs 5.0.1", "fs4", "once_cell", - "reqwest 0.12.4", + "reqwest", "semver 1.0.22", "serde", "serde_json", "sha2", "thiserror", "url", - "zip 1.1.4", + "zip", ] [[package]] @@ -8125,7 +7682,7 @@ dependencies = [ "const-hex", "semver 1.0.22", "serde_json", - "svm-rs 0.5.2", + "svm-rs", ] [[package]] @@ -8174,27 +7731,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" @@ -8689,16 +8225,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-log" version = "0.2.0" @@ -8881,12 +8407,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -9437,16 +8957,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "winreg" version = "0.52.0" @@ -9469,7 +8979,7 @@ dependencies = [ "log", "pharos", "rustc_version 0.4.0", - "send_wrapper 0.6.0", + "send_wrapper", "thiserror", "wasm-bindgen", "wasm-bindgen-futures", @@ -9491,12 +9001,6 @@ version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" - [[package]] name = "yansi" version = "1.0.1" @@ -9546,26 +9050,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "aes", - "byteorder", - "bzip2", - "constant_time_eq", - "crc32fast", - "crossbeam-utils", - "flate2", - "hmac", - "pbkdf2 0.11.0", - "sha1", - "time", - "zstd", -] - [[package]] name = "zip" version = "1.1.4" @@ -9581,32 +9065,3 @@ dependencies = [ "num_enum", "thiserror", ] - -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/Cargo.toml b/Cargo.toml index 550a0e644e4db..f777385f300b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -149,12 +149,7 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = ] } ## ethers -ethers = { version = "2.0.14", default-features = false } -ethers-core = { version = "2.0.14", default-features = false } -ethers-contract = { version = "2.0.14", default-features = false } ethers-contract-abigen = { version = "2.0.14", default-features = false } -ethers-providers = { version = "2.0.14", default-features = false } -ethers-signers = { version = "2.0.14", default-features = false } ## alloy alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } @@ -170,6 +165,7 @@ alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } @@ -192,10 +188,7 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" @@ -204,7 +197,7 @@ hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.12" jsonpath_lib = "0.3" k256 = "0.13" -pretty_assertions = "1.4" +similar-asserts = "1.5" rand = "0.8" rustc-hash = "1.1" serde = { version = "1.0", features = ["derive"] } @@ -224,4 +217,4 @@ axum = "0.7" hyper = "1.0" reqwest = { version = "0.12", default-features = false } tower = "0.4" -tower-http = "0.5" \ No newline at end of file +tower-http = "0.5" diff --git a/README.md b/README.md index b6f4f8640a1ab..6ca5e9a6ee2b4 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ If you're experiencing any issues while installing, check out [Getting Help](#ge ### How Fast? -Forge is quite fast at both compiling (leveraging [ethers-solc][ethers-solc]) and testing. +Forge is quite fast at both compiling (leveraging [ethers-solc]) and testing. See the benchmarks below. More benchmarks can be found in the [v0.2.0 announcement post][benchmark-post] and in the [Convex Shutdown Simulation][convex] repository. @@ -126,7 +126,7 @@ If you want to contribute, or follow along with contributor discussion, you can ## Acknowledgements - Foundry is a clean-room rewrite of the testing framework [DappTools](https://github.com/dapphub/dapptools). None of this would have been possible without the DappHub team's work over the years. -- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc](https://github.com/gakonst/ethers-rs/tree/master/ethers-solc/) which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. +- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. - [Rohit Narurkar](https://twitter.com/rohitnarurkar): Created the Rust Solidity version manager [svm-rs](https://github.com/roynalnaruto/svm-rs) which we use to auto-detect and manage multiple Solidity versions. - [Brock Elmore](https://twitter.com/brockjelmore): For extending the VM's cheatcodes and implementing [structured call tracing](https://github.com/foundry-rs/foundry/pull/192), a critical feature for debugging smart contract calls. - All the other [contributors](https://github.com/foundry-rs/foundry/graphs/contributors) to the [ethers-rs](https://github.com/gakonst/ethers-rs) & [foundry](https://github.com/foundry-rs/foundry) repositories and chatrooms. diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 7739e8fa2f3f0..152c0680a6fc7 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,11 +16,7 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # foundry internal @@ -35,13 +31,7 @@ foundry-evm.workspace = true # evm support bytes = "1.4.0" k256.workspace = true -ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] } -revm = { workspace = true, features = [ - "std", - "serde", - "memory_limit", - "c-kzg", -] } +revm = { workspace = true, features = ["std", "serde", "memory_limit", "c-kzg"] } alloy-primitives = { workspace = true, features = ["serde"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-contract = { workspace = true, features = ["pubsub"] } @@ -88,11 +78,7 @@ rand = "0.8" eyre.workspace = true # cli -clap = { version = "4", features = [ - "derive", - "env", - "wrap_help", -], optional = true } +clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" @@ -106,8 +92,6 @@ tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] alloy-json-abi.workspace = true -ethers = { workspace = true, features = ["abigen", "optimism"] } -ethers-core = { workspace = true, features = ["optimism"] } foundry-compilers = { workspace = true, features = ["project-util", "full"] } alloy-rpc-client = { workspace = true, features = ["pubsub"] } alloy-transport-ipc = { workspace = true, features = ["mock"] } @@ -115,7 +99,7 @@ alloy-transport-ws.workspace = true alloy-json-rpc.workspace = true alloy-pubsub.workspace = true foundry-test-utils.workspace = true -pretty_assertions.workspace = true +similar-asserts.workspace = true tokio = { version = "1", features = ["full"] } crc = "3.0.1" diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 90738112e6402..92f907c4ec20f 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -20,8 +20,9 @@ revm = { workspace = true, default-features = false, features = [ ] } alloy-primitives = { workspace = true, features = ["serde"] } -alloy-rpc-types = { workspace = true } +alloy-rpc-types.workspace = true alloy-rpc-types-trace.workspace = true +alloy-serde.workspace = true alloy-rlp.workspace = true alloy-eips.workspace = true alloy-network = { workspace = true, features = ["k256"] } diff --git a/crates/anvil/core/src/eth/serde_helpers.rs b/crates/anvil/core/src/eth/serde_helpers.rs index 311b3a9f27e80..f7d5bd46dba2e 100644 --- a/crates/anvil/core/src/eth/serde_helpers.rs +++ b/crates/anvil/core/src/eth/serde_helpers.rs @@ -33,35 +33,6 @@ pub mod sequence { } } -pub mod numeric { - use alloy_primitives::U256; - use serde::{Deserialize, Deserializer}; - /// Supports parsing u64 - /// - /// See - pub fn deserialize_stringified_u64_opt<'de, D>(deserializer: D) -> Result, D::Error> - where - D: Deserializer<'de>, - { - if let Some(num) = Option::::deserialize(deserializer)? { - num.try_into().map(Some).map_err(serde::de::Error::custom) - } else { - Ok(None) - } - } - - /// Supports parsing u64 - /// - /// See - pub fn deserialize_stringified_u64<'de, D>(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let num = U256::deserialize(deserializer)?; - num.try_into().map_err(serde::de::Error::custom) - } -} - /// A module that deserializes `[]` optionally pub mod empty_params { use serde::{Deserialize, Deserializer}; diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 2e0c63b13485f..87209606f5b61 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -24,10 +24,7 @@ impl<'de> serde::Deserialize<'de> for Forking { #[serde(rename_all = "camelCase")] struct ForkOpts { pub json_rpc_url: Option, - #[serde( - default, - deserialize_with = "crate::eth::serde_helpers::numeric::deserialize_stringified_u64_opt" - )] + #[serde(default, with = "alloy_serde::num::u64_opt_via_ruint")] pub block_number: Option, } @@ -60,24 +57,14 @@ impl<'de> serde::Deserialize<'de> for Forking { #[cfg_attr(feature = "serde", serde(untagged))] pub enum EvmMineOptions { Options { - #[cfg_attr( - feature = "serde", - serde( - deserialize_with = "crate::eth::serde_helpers::numeric::deserialize_stringified_u64_opt" - ) - )] + #[cfg_attr(feature = "serde", serde(with = "alloy_serde::num::u64_opt_via_ruint"))] timestamp: Option, // If `blocks` is given, it will mine exactly blocks number of blocks, regardless of any // other blocks mined or reverted during it's operation blocks: Option, }, /// The timestamp the block should be mined with - #[cfg_attr( - feature = "serde", - serde( - deserialize_with = "crate::eth::serde_helpers::numeric::deserialize_stringified_u64_opt" - ) - )] + #[cfg_attr(feature = "serde", serde(with = "alloy_serde::num::u64_opt_via_ruint"))] Timestamp(Option), } diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 380dfabe0d33e..cf7325512a58e 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -42,8 +42,7 @@ alloy-network.workspace = true alloy-sol-types.workspace = true alloy-chains.workspace = true -ethers-core.workspace = true -ethers-contract = { workspace = true, features = ["abigen"] } +ethers-contract-abigen.workspace = true chrono.workspace = true evm-disassembler.workspace = true diff --git a/crates/cast/bin/cmd/bind.rs b/crates/cast/bin/cmd/bind.rs index 73a62825ae7b4..a83afc8ae1d03 100644 --- a/crates/cast/bin/cmd/bind.rs +++ b/crates/cast/bin/cmd/bind.rs @@ -1,5 +1,5 @@ use clap::{Parser, ValueHint}; -use ethers_contract::{Abigen, MultiAbigen}; +use ethers_contract_abigen::{Abigen, MultiAbigen}; use eyre::Result; use foundry_block_explorers::{errors::EtherscanError, Client}; use foundry_cli::opts::EtherscanOpts; diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index a4e9a0ad85743..fa2daa8760de5 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -27,10 +27,7 @@ alloy-sol-types.workspace = true alloy-provider.workspace = true alloy-rpc-types.workspace = true alloy-signer.workspace = true -alloy-signer-wallet = { workspace = true, features = [ - "mnemonic-all-languages", - "keystore", -] } +alloy-signer-wallet = { workspace = true, features = ["mnemonic-all-languages", "keystore"] } parking_lot = "0.12" eyre.workspace = true diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 10f3cf6aab934..6a4ae4f38ce1a 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -17,21 +17,13 @@ foundry-linking.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = [ - "serde", - "getrandom", - "arbitrary", - "rlp", -] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-rpc-types-engine.workspace = true alloy-rpc-types.workspace = true alloy-rpc-client.workspace = true alloy-provider.workspace = true alloy-transport.workspace = true -alloy-transport-http = { workspace = true, features = [ - "reqwest", - "reqwest-rustls-tls", -] } +alloy-transport-http = { workspace = true, features = ["reqwest", "reqwest-rustls-tls"] } alloy-transport-ws.workspace = true alloy-transport-ipc.workspace = true alloy-json-rpc.workspace = true @@ -66,5 +58,5 @@ num-format.workspace = true [dev-dependencies] foundry-macros.workspace = true -pretty_assertions.workspace = true +similar-asserts.workspace = true tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 3893fb4c9d40f..635d1434bd485 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -518,7 +518,7 @@ totalDifficulty {}{}", #[cfg(test)] mod tests { use super::*; - use pretty_assertions::assert_eq; + use similar_asserts::assert_eq; use std::str::FromStr; #[test] diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 7a65678d4f8a0..d5a1ddda6fa9a 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -44,7 +44,7 @@ walkdir = "2" path-slash = "0.2.1" [dev-dependencies] -pretty_assertions.workspace = true +similar-asserts.workspace = true figment = { version = "0.10", features = ["test"] } tempfile.workspace = true diff --git a/crates/config/src/cache.rs b/crates/config/src/cache.rs index ef0ca40a468ea..ed1475c7ea5e4 100644 --- a/crates/config/src/cache.rs +++ b/crates/config/src/cache.rs @@ -230,7 +230,7 @@ pub struct ChainCache { #[cfg(test)] mod tests { use super::*; - use pretty_assertions::assert_str_eq; + use similar_asserts::assert_eq; #[test] fn can_parse_storage_config() { @@ -307,6 +307,6 @@ mod tests { - Block Explorer (0.0 B)\n\n\t\ - Block 1 (1.0 B)\n\t\ - Block 2 (2.0 B)\n"; - assert_str_eq!(format!("{cache}"), expected); + assert_eq!(format!("{cache}"), expected); } } diff --git a/crates/config/src/fix.rs b/crates/config/src/fix.rs index dc43fd25500b5..a49097c8f34d4 100644 --- a/crates/config/src/fix.rs +++ b/crates/config/src/fix.rs @@ -220,7 +220,7 @@ pub fn fix_tomls() -> Vec { mod tests { use super::*; use figment::Jail; - use pretty_assertions::assert_eq; + use similar_asserts::assert_eq; macro_rules! fix_test { ($(#[$attr:meta])* $name:ident, $fun:expr) => { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 2a7ddc3ab484c..8b65bfa7813f1 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -752,7 +752,7 @@ impl Config { } /// Same as [`Self::project()`] but sets configures the project to not emit artifacts and ignore - /// cache, caching causes no output until https://github.com/gakonst/ethers-rs/issues/727 + /// cache. pub fn ephemeral_no_artifacts_project(&self) -> Result { self.create_project(false, true) } @@ -2708,7 +2708,7 @@ mod tests { }; use figment::error::Kind::InvalidType; use foundry_compilers::artifacts::{ModelCheckerEngine, YulDetails}; - use pretty_assertions::assert_eq; + use similar_asserts::assert_eq; use std::{collections::BTreeMap, fs::File, io::Write}; use tempfile::tempdir; use NamedChain::Moonbeam; @@ -4170,7 +4170,7 @@ mod tests { let libs = config.parsed_libraries().unwrap().libs; - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( libs, BTreeMap::from([ ( diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 9b558e350d530..c3285d92cdf90 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -35,7 +35,7 @@ revm = { workspace = true, features = [ "optional_no_base_fee", "arbitrary", "optimism", - "c-kzg" + "c-kzg", ] } revm-inspectors.workspace = true diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index db59118844e3e..b60f00e5cb091 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -488,7 +488,7 @@ where /// that is used by the `BackendHandler` to send the result of an executed `BackendRequest` back to /// `SharedBackend`. /// -/// The `BackendHandler` holds an ethers `Provider` to look up missing accounts or storage slots +/// The `BackendHandler` holds a `Provider` to look up missing accounts or storage slots /// from remote (e.g. infura). It detects duplicate requests from multiple `SharedBackend`s and /// bundles them together, so that always only one provider request is executed. For example, there /// are two `SharedBackend`s, `A` and `B`, both request the basic account info of account diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 72f4a6d171567..be3324c10959c 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -22,12 +22,7 @@ foundry-evm-traces.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = [ - "serde", - "getrandom", - "arbitrary", - "rlp", -] } +alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-sol-types.workspace = true revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index c8937a281a5f3..8fbf962ebd281 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -22,6 +22,6 @@ tracing.workspace = true [dev-dependencies] itertools.workspace = true -pretty_assertions.workspace = true +similar-asserts.workspace = true toml.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/crates/fmt/src/string.rs b/crates/fmt/src/string.rs index 607c890e7c7ca..082d25d52496a 100644 --- a/crates/fmt/src/string.rs +++ b/crates/fmt/src/string.rs @@ -140,7 +140,7 @@ impl QuotedStringExt for str { #[cfg(test)] mod tests { use super::*; - use pretty_assertions::assert_eq; + use similar_asserts::assert_eq; #[test] fn quote_state_char_indices() { diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index 18b72a54512be..efbd63ef5690a 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -111,7 +111,7 @@ fn test_formatter( let expected_parsed = parse(expected_source).unwrap(); if !test_config.skip_compare_ast_eq && !source_parsed.pt.ast_eq(&expected_parsed.pt) { - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( source_parsed.pt, expected_parsed.pt, "(formatted Parse Tree == expected Parse Tree) in {}", @@ -127,7 +127,7 @@ fn test_formatter( let source_formatted = PrettyString(source_formatted); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( source_formatted, expected, "(formatted == expected) in {}", @@ -140,7 +140,7 @@ fn test_formatter( let expected_formatted = PrettyString(expected_formatted); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( expected_formatted, expected, "(formatted == expected) in {}", diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 9d7b2777d71e7..6bb111eac52fc 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,11 +15,7 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } [dependencies] # lib @@ -31,7 +27,7 @@ foundry-evm.workspace = true foundry-wallets.workspace = true foundry-linking.workspace = true -ethers-contract = { workspace = true, features = ["abigen"] } +ethers-contract-abigen.workspace = true revm-inspectors.workspace = true @@ -108,10 +104,8 @@ criterion = "0.5" globset = "0.4" paste = "1.0" path-slash = "0.2" -pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.5", default-features = false, features = [ - "rustls", -] } +similar-asserts.workspace = true +svm = { package = "svm-rs", version = "0.5", default-features = false, features = ["rustls"] } tempfile.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 5be0f262a1a21..11f855f049580 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -1,5 +1,7 @@ use clap::{Parser, ValueHint}; -use ethers_contract::{Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts}; +use ethers_contract_abigen::{ + Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts, +}; use eyre::{Result, WrapErr}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs::json_files}; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index a4deb8bcef3de..b4d8df8ccd3a3 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -842,37 +842,6 @@ contract A { assert!(!out.contains("Compiler run successful with warnings:")); }); -// test against a local checkout, useful to debug with local ethers-rs patch -forgetest!( - #[ignore] - can_compile_local_spells, - |_prj, cmd| { - let current_dir = std::env::current_dir().unwrap(); - let root = current_dir - .join("../../foundry-integration-tests/testdata/spells-mainnet") - .to_string_lossy() - .to_string(); - println!("project root: \"{root}\""); - - let eth_rpc_url = foundry_test_utils::rpc::next_http_archive_rpc_endpoint(); - let dss_exec_lib = "src/DssSpell.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4"; - - cmd.args([ - "test", - "--root", - root.as_str(), - "--fork-url", - eth_rpc_url.as_str(), - "--fork-block-number", - "14435000", - "--libraries", - dss_exec_lib, - "-vvvvv", - ]); - cmd.assert_non_empty_stdout(); - } -); - // test that a failing `forge build` does not impact followup builds forgetest!(can_build_after_failure, |prj, cmd| { prj.insert_ds_test(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index a2997be0399bd..f60eebfdef7eb 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -17,7 +17,7 @@ use foundry_test_utils::{ util::{pretty_err, OutputExt, TestCommand, OTHER_SOLC_VERSION}, }; use path_slash::PathBufExt; -use pretty_assertions::assert_eq; +use similar_asserts::assert_eq; use std::{ fs, path::{Path, PathBuf}, @@ -135,7 +135,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { }; prj.write_config(input.clone()); let config = cmd.config(); - pretty_assertions::assert_eq!(input, config); + similar_asserts::assert_eq!(input, config); }); // tests config gets printed to std out @@ -441,7 +441,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); dbg!(&remappings); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( remappings, vec![ // global @@ -459,7 +459,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( remappings, vec![ // default @@ -482,7 +482,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let another_config = cmd.config(); let remappings = another_config.remappings.iter().cloned().map(Remapping::from).collect::>(); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( remappings, vec![ // local to the lib @@ -500,7 +500,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( remappings, vec![ // local to the lib @@ -530,7 +530,7 @@ forgetest_init!(can_prioritise_closer_lib_remappings, |prj, cmd| { let config = cmd.config(); let remappings = config.get_all_remappings().collect::>(); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( remappings, vec![ "dep1/=lib/dep1/src/".parse().unwrap(), diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 714bb036b5642..eee345595ab14 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -691,7 +691,7 @@ forgetest_async!(check_broadcast_log, |prj, cmd| { std::fs::read_to_string("broadcast/Broadcast.t.sol/31337/run-latest.json").unwrap(); let _run_log = re.replace_all(&run_log, ""); - // pretty_assertions::assert_eq!(fixtures_log, run_log); + // similar_asserts::assert_eq!(fixtures_log, run_log); // Uncomment to recreate the sensitive log // std::fs::copy( @@ -719,7 +719,7 @@ forgetest_async!(check_broadcast_log, |prj, cmd| { let fixtures_log = re.replace_all(&fixtures_log, "\n"); let run_log = re.replace_all(&run_log, "\n"); - pretty_assertions::assert_eq!(fixtures_log, run_log); + similar_asserts::assert_eq!(fixtures_log, run_log); }); forgetest_async!(test_default_sender_balance, |prj, cmd| { diff --git a/crates/linking/Cargo.toml b/crates/linking/Cargo.toml index 31edf1c5d1b3f..77c54ccf7da89 100644 --- a/crates/linking/Cargo.toml +++ b/crates/linking/Cargo.toml @@ -14,4 +14,4 @@ repository.workspace = true foundry-compilers = { workspace = true, features = ["full"] } semver = "1" alloy-primitives = { workspace = true, features = ["rlp"] } -thiserror = "1" \ No newline at end of file +thiserror = "1" diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index a73c53a394c27..c2ee04cbef7bd 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -24,7 +24,7 @@ eyre.workspace = true fd-lock = "4.0.0" once_cell = "1" parking_lot = "0.12" -pretty_assertions.workspace = true +similar-asserts.workspace = true regex = "1" serde_json.workspace = true tracing = "0.1" diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index eec9d8bbc5c43..be7e13af1ec08 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1090,7 +1090,7 @@ impl OutputExt for Output { #[track_caller] fn stdout_matches_content(&self, expected: &str) { let out = lossy_string(&self.stdout); - pretty_assertions::assert_eq!(normalize_output(&out), normalize_output(expected)); + similar_asserts::assert_eq!(normalize_output(&out), normalize_output(expected)); } #[track_caller] @@ -1103,7 +1103,7 @@ impl OutputExt for Output { fn stderr_matches_path(&self, expected_path: impl AsRef) { let expected = fs::read_to_string(expected_path).unwrap(); let err = lossy_string(&self.stderr); - pretty_assertions::assert_eq!(normalize_output(&err), normalize_output(&expected)); + similar_asserts::assert_eq!(normalize_output(&err), normalize_output(&expected)); } } diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index c28126c43b01f..7b1f698b72bd3 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -36,7 +36,6 @@ impl WalletSigner { } pub async fn from_trezor_path(path: TrezorHDPath) -> Result { - // cached to ~/.ethers-rs/trezor/cache/trezor.session let trezor = TrezorSigner::new(path, None).await?; Ok(Self::Trezor(trezor)) } diff --git a/deny.toml b/deny.toml index e3ae679d035c3..299c1452ac012 100644 --- a/deny.toml +++ b/deny.toml @@ -1,16 +1,9 @@ -# Temporarily exclude rusoto and ethers-providers from bans since we've yet to transition to the -# Rust AWS SDK. -exclude = ["rusoto_core", "rusoto_kms", "rusoto_credential", "ethers-providers", "tungstenite", "shlex"] - # This section is considered when running `cargo deny check advisories` # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] -vulnerability = "deny" -unmaintained = "warn" +version = 2 yanked = "warn" -notice = "warn" -ignore = [] # This section is considered when running `cargo deny check bans`. # More documentation about the 'bans' section can be found here: @@ -32,7 +25,9 @@ skip = [] skip-tree = [] [licenses] -unlicensed = "deny" +version = 2 +confidence-threshold = 0.8 + # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.7 short identifier (+ optional exception)]. @@ -49,6 +44,7 @@ allow = [ "WTFPL", "BSL-1.0", "0BSD", + "MPL-2.0", ] # Allow 1 or more licenses on a per-crate basis, so that particular licenses @@ -57,14 +53,10 @@ exceptions = [ # CC0 is a permissive license but somewhat unclear status for source code # so we prefer to not have dependencies using it # https://tldrlegal.com/license/creative-commons-cc0-1.0-universal - { allow = ["CC0-1.0"], name = "secp256k1" }, - { allow = ["CC0-1.0"], name = "secp256k1-sys" }, { allow = ["CC0-1.0"], name = "tiny-keccak" }, { allow = ["CC0-1.0"], name = "to_method" }, - { allow = ["CC0-1.0"], name = "more-asserts" }, { allow = ["CC0-1.0"], name = "trezor-client" }, { allow = ["CC0-1.0"], name = "notify" }, - { allow = ["CC0-1.0"], name = "constant_time_eq" }, { allow = ["CC0-1.0"], name = "dunce" }, { allow = ["CC0-1.0"], name = "aurora-engine-modexp" }, ] @@ -76,6 +68,7 @@ name = "unicode-ident" version = "*" expression = "(MIT OR Apache-2.0) AND Unicode-DFS-2016" license-files = [{ path = "LICENSE-UNICODE", hash = 0x3fb01745 }] + [[licenses.clarify]] name = "ring" version = "*" @@ -91,4 +84,5 @@ license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] unknown-registry = "warn" # Lint level for what to happen when a crate from a git repository that is not # in the allow list is encountered -unknown-git = "allow" +unknown-git = "deny" +allow-git = ["https://github.com/alloy-rs/alloy", "https://github.com/paradigmxyz/evm-inspectors"] diff --git a/docs/dev/debugging.md b/docs/dev/debugging.md index 9431d7c33ca82..df8664440dc40 100644 --- a/docs/dev/debugging.md +++ b/docs/dev/debugging.md @@ -20,4 +20,5 @@ Filters are explained in detail in the [`env_logger` crate docs](https://docs.rs ### Compiler input and output -You can get the compiler input JSON and output JSON from `ethers-solc` by passing the `--build-info` flag. This will create two files: one for the input and one for the output. +You can get the compiler input JSON and output JSON by passing the `--build-info` flag. +This will create two files: one for the input and one for the output. From 784e3829ff6e575277be50837ee4cfcd541a902c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 5 May 2024 19:41:25 +0200 Subject: [PATCH 0940/1963] chore: remove unused fork ID support (#7863) --- Cargo.lock | 52 ------------------ crates/anvil/Cargo.toml | 2 - crates/anvil/src/hardfork.rs | 103 ----------------------------------- 3 files changed, 157 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66abc3c553bcc..7496c56aa493a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -722,9 +722,7 @@ dependencies = [ "clap", "clap_complete", "clap_complete_fig", - "crc 3.2.1", "ctrlc", - "ethereum-forkid", "eyre", "fdlimit", "flate2", @@ -2258,30 +2256,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" -dependencies = [ - "build_const", -] - -[[package]] -name = "crc" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" - [[package]] name = "crc32fast" version = "1.4.0" @@ -2893,19 +2867,6 @@ dependencies = [ "tiny-keccak", ] -[[package]] -name = "ethereum-forkid" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcace6f36a8fd79d06c535444b42c8966e10733165fca6dec3542abfc3e00318" -dependencies = [ - "crc 1.8.1", - "fastrlp", - "maplit", - "primitive-types", - "thiserror", -] - [[package]] name = "ethereum-types" version = "0.14.1" @@ -3077,19 +3038,6 @@ dependencies = [ "arrayvec", "auto_impl", "bytes", - "fastrlp-derive", -] - -[[package]] -name = "fastrlp-derive" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4caf31122bfc780557fdcd80897e95f12cc4d7217f8ac6b9d150df828a38ee8" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 2.0.60", ] [[package]] diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 152c0680a6fc7..63a7f89f9af6d 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -85,7 +85,6 @@ auto_impl = "1" ctrlc = { version = "3", optional = true } fdlimit = { version = "0.3", optional = true } clap_complete_fig = "4" -ethereum-forkid = "0.12" [target.'cfg(unix)'.dependencies] tikv-jemallocator = { workspace = true, optional = true } @@ -101,7 +100,6 @@ alloy-pubsub.workspace = true foundry-test-utils.workspace = true similar-asserts.workspace = true tokio = { version = "1", features = ["full"] } -crc = "3.0.1" [features] default = ["cli"] diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index 8fabace321be5..e2f107b5332c1 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -1,5 +1,4 @@ use alloy_rpc_types::BlockNumberOrTag; -use ethereum_forkid::{ForkHash, ForkId}; use foundry_evm::revm::primitives::SpecId; use std::str::FromStr; @@ -48,58 +47,6 @@ impl Hardfork { Hardfork::Cancun | Hardfork::Latest => 19426587, } } - - /// Get the EIP-2124 fork id for a given hardfork - /// - /// The [`ForkId`](ethereum_forkid::ForkId) includes a CRC32 checksum of the all fork block - /// numbers from genesis, and the next upcoming fork block number. - /// If the next fork block number is not yet known, it is set to 0. - pub fn fork_id(&self) -> ForkId { - match *self { - Hardfork::Frontier => { - ForkId { hash: ForkHash([0xfc, 0x64, 0xec, 0x04]), next: 1150000 } - } - Hardfork::Homestead => { - ForkId { hash: ForkHash([0x97, 0xc2, 0xc3, 0x4c]), next: 1920000 } - } - Hardfork::Dao => ForkId { hash: ForkHash([0x91, 0xd1, 0xf9, 0x48]), next: 2463000 }, - Hardfork::Tangerine => { - ForkId { hash: ForkHash([0x7a, 0x64, 0xda, 0x13]), next: 2675000 } - } - Hardfork::SpuriousDragon => { - ForkId { hash: ForkHash([0x3e, 0xdd, 0x5b, 0x10]), next: 4370000 } - } - Hardfork::Byzantium => { - ForkId { hash: ForkHash([0xa0, 0x0b, 0xc3, 0x24]), next: 7280000 } - } - Hardfork::Constantinople | Hardfork::Petersburg => { - ForkId { hash: ForkHash([0x66, 0x8d, 0xb0, 0xaf]), next: 9069000 } - } - Hardfork::Istanbul => { - ForkId { hash: ForkHash([0x87, 0x9d, 0x6e, 0x30]), next: 9200000 } - } - Hardfork::Muirglacier => { - ForkId { hash: ForkHash([0xe0, 0x29, 0xe9, 0x91]), next: 12244000 } - } - Hardfork::Berlin => ForkId { hash: ForkHash([0x0e, 0xb4, 0x40, 0xf6]), next: 12965000 }, - Hardfork::London => ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 13773000 }, - Hardfork::ArrowGlacier => { - ForkId { hash: ForkHash([0x20, 0xc3, 0x27, 0xfc]), next: 15050000 } - } - Hardfork::GrayGlacier => { - ForkId { hash: ForkHash([0xf0, 0xaf, 0xd0, 0xe3]), next: 15537394 } - } - Hardfork::Paris => ForkId { hash: ForkHash([0x4f, 0xb8, 0xa8, 0x72]), next: 17034870 }, - Hardfork::Shanghai | Hardfork::Latest => { - // update `next` when another fork block num is known - ForkId { hash: ForkHash([0xc1, 0xfd, 0xf1, 0x81]), next: 19426587 } - } - Hardfork::Cancun => { - // TODO: set fork hash once known - ForkId { hash: ForkHash([0xc1, 0xfd, 0xf1, 0x81]), next: 0 } - } - } - } } impl FromStr for Hardfork { @@ -187,8 +134,6 @@ impl> From for Hardfork { #[cfg(test)] mod tests { use crate::Hardfork; - use alloy_primitives::hex; - use crc::{Crc, CRC_32_ISO_HDLC}; #[test] fn test_hardfork_blocks() { @@ -201,52 +146,4 @@ mod tests { let hf: Hardfork = 12244000u64.into(); assert_eq!(hf, Hardfork::Berlin); } - - #[test] - // this test checks that the fork hash assigned to forks accurately map to the fork_id method - fn test_forkhash_from_fork_blocks() { - // set the genesis hash - let genesis = - hex::decode("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") - .unwrap(); - - // instantiate the crc "hasher" - let crc_hasher = Crc::::new(&CRC_32_ISO_HDLC); - let mut crc_digest = crc_hasher.digest(); - - // check frontier forkhash - crc_digest.update(&genesis); - - // now we go through enum members - let frontier_forkid = Hardfork::Frontier.fork_id(); - let frontier_forkhash = u32::from_be_bytes(frontier_forkid.hash.0); - // clone the digest for finalization so we can update it again - assert_eq!(crc_digest.clone().finalize(), frontier_forkhash); - - // list of the above hardforks - let hardforks = vec![ - Hardfork::Homestead, - Hardfork::Dao, - Hardfork::Tangerine, - Hardfork::SpuriousDragon, - Hardfork::Byzantium, - Hardfork::Constantinople, - Hardfork::Istanbul, - Hardfork::Muirglacier, - Hardfork::Berlin, - Hardfork::London, - Hardfork::ArrowGlacier, - Hardfork::GrayGlacier, - ]; - - // now loop through each hardfork, conducting each forkhash test - for hardfork in hardforks { - // this could also be done with frontier_forkhash.next, but fork_block is used for more - // coverage - let fork_block = hardfork.fork_block().to_be_bytes(); - crc_digest.update(&fork_block); - let fork_hash = u32::from_be_bytes(hardfork.fork_id().hash.0); - assert_eq!(crc_digest.clone().finalize(), fork_hash); - } - } } From c486fca34f74fbfb66233229e55b660a2235a986 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 5 May 2024 20:36:11 +0200 Subject: [PATCH 0941/1963] chore(deps): replace `parity-ipc-server` with `interprocess` (#7862) --- Cargo.lock | 186 +++++++----------- crates/anvil/core/src/eth/trie.rs | 4 +- crates/anvil/server/Cargo.toml | 4 +- crates/anvil/server/src/ipc.rs | 68 ++++--- crates/anvil/src/config.rs | 10 +- crates/anvil/src/lib.rs | 16 +- crates/anvil/tests/it/ipc.rs | 44 +++-- .../common/src/provider/runtime_transport.rs | 2 +- 8 files changed, 153 insertions(+), 181 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7496c56aa493a..3557e819b12a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,14 +210,14 @@ dependencies = [ "derive_arbitrary", "derive_more", "ethereum_ssz", - "getrandom 0.2.14", + "getrandom", "hex-literal", "itoa", "k256", "keccak-asm", "proptest", "proptest-derive", - "rand 0.8.5", + "rand", "ruint", "serde", "tiny-keccak", @@ -348,7 +348,7 @@ dependencies = [ "alloy-rpc-types", "alloy-serde", "jsonwebtoken", - "rand 0.8.5", + "rand", "serde", "thiserror", ] @@ -456,7 +456,7 @@ dependencies = [ "elliptic-curve", "eth-keystore", "k256", - "rand 0.8.5", + "rand", "thiserror", ] @@ -559,7 +559,7 @@ dependencies = [ "alloy-transport", "bytes", "futures", - "interprocess", + "interprocess 1.2.1", "pin-project", "serde", "serde_json", @@ -737,7 +737,7 @@ dependencies = [ "itertools 0.12.1", "k256", "parking_lot", - "rand 0.8.5", + "rand", "revm", "serde", "serde_json", @@ -773,7 +773,7 @@ dependencies = [ "c-kzg", "foundry-common", "foundry-evm", - "rand 0.8.5", + "rand", "revm", "serde", "serde_json", @@ -783,7 +783,7 @@ dependencies = [ name = "anvil-rpc" version = "0.2.0" dependencies = [ - "rand 0.8.5", + "rand", "serde", "serde_json", ] @@ -798,7 +798,7 @@ dependencies = [ "bytes", "clap", "futures", - "parity-tokio-ipc", + "interprocess 2.0.1", "parking_lot", "pin-project", "serde", @@ -945,7 +945,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -955,7 +955,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -1817,7 +1817,7 @@ dependencies = [ "futures", "indicatif", "itertools 0.12.1", - "rand 0.8.5", + "rand", "rayon", "regex", "rpassword", @@ -2066,7 +2066,7 @@ dependencies = [ "hmac", "once_cell", "pbkdf2 0.12.2", - "rand 0.8.5", + "rand", "sha2", "thiserror", ] @@ -2100,7 +2100,7 @@ dependencies = [ "async-trait", "byteorder", "cfg-if", - "getrandom 0.2.14", + "getrandom", "hex", "hidapi-rusb", "js-sys", @@ -2375,7 +2375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -2726,7 +2726,7 @@ dependencies = [ "group", "pem-rfc7468", "pkcs8", - "rand_core 0.6.4", + "rand_core", "sec1", "subtle", "zeroize", @@ -2825,7 +2825,7 @@ dependencies = [ "hex", "hmac", "pbkdf2 0.11.0", - "rand 0.8.5", + "rand", "scrypt", "serde", "serde_json", @@ -2934,7 +2934,7 @@ dependencies = [ "num_enum", "once_cell", "open-fastrlp", - "rand 0.8.5", + "rand", "rlp", "serde", "serde_json", @@ -3078,7 +3078,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -3118,7 +3118,7 @@ checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "arbitrary", "byteorder", - "rand 0.8.5", + "rand", "rustc-hex", "static_assertions", ] @@ -3543,7 +3543,7 @@ dependencies = [ "memmap2 0.9.4", "once_cell", "path-slash", - "rand 0.8.5", + "rand", "rayon", "regex", "semver 1.0.22", @@ -3710,7 +3710,7 @@ dependencies = [ "itertools 0.12.1", "parking_lot", "proptest", - "rand 0.8.5", + "rand", "revm", "serde", "thiserror", @@ -3777,7 +3777,7 @@ dependencies = [ "foundry-config", "once_cell", "parking_lot", - "rand 0.8.5", + "rand", "regex", "serde_json", "similar-asserts", @@ -3980,17 +3980,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.14" @@ -4000,7 +3989,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -4254,7 +4243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -4803,6 +4792,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "interprocess" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c7fb8583fab9503654385e2bafda123376445a77027a1b106dd7e44cf51122f" +dependencies = [ + "futures-core", + "libc", + "recvmsg", + "tokio", + "widestring", + "windows-sys 0.52.0", +] + [[package]] name = "intmap" version = "0.7.1" @@ -5231,7 +5234,7 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -5687,20 +5690,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parity-tokio-ipc" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9981e32fb75e004cc148f5fb70342f393830e0a4aa62e3cc93b50976218d42b6" -dependencies = [ - "futures", - "libc", - "log", - "rand 0.7.3", - "tokio", - "winapi", -] - [[package]] name = "parking" version = "2.2.0" @@ -5920,7 +5909,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" dependencies = [ "phf_shared 0.10.0", - "rand 0.8.5", + "rand", ] [[package]] @@ -5930,7 +5919,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared 0.11.2", - "rand 0.8.5", + "rand", ] [[package]] @@ -6230,8 +6219,8 @@ dependencies = [ "bitflags 2.5.0", "lazy_static", "num-traits", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rand_xorshift", "regex-syntax 0.8.3", "rusty-fork", @@ -6319,19 +6308,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -6339,18 +6315,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -6360,16 +6326,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -6378,16 +6335,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.14", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -6396,7 +6344,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -6439,6 +6387,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "recvmsg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" + [[package]] name = "redox_syscall" version = "0.4.1" @@ -6463,7 +6417,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.14", + "getrandom", "libredox", "thiserror", ] @@ -6662,7 +6616,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.14", + "getrandom", "libc", "spin 0.9.8", "untrusted", @@ -6738,7 +6692,7 @@ dependencies = [ "parity-scale-codec", "primitive-types", "proptest", - "rand 0.8.5", + "rand", "rlp", "ruint-macro", "serde", @@ -7093,7 +7047,7 @@ version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ - "rand 0.8.5", + "rand", "secp256k1-sys", ] @@ -7388,7 +7342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -7590,7 +7544,7 @@ dependencies = [ "byteorder", "crunchy", "lazy_static", - "rand 0.8.5", + "rand", "rustc-hex", ] @@ -8234,7 +8188,7 @@ dependencies = [ "http 0.2.12", "httparse", "log", - "rand 0.8.5", + "rand", "rustls 0.21.12", "sha1", "thiserror", @@ -8254,7 +8208,7 @@ dependencies = [ "http 1.1.0", "httparse", "log", - "rand 0.8.5", + "rand", "sha1", "thiserror", "url", @@ -8396,7 +8350,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.14", + "getrandom", "serde", ] @@ -8470,12 +8424,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -8633,6 +8581,12 @@ dependencies = [ "rustix", ] +[[package]] +name = "widestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" + [[package]] name = "winapi" version = "0.3.9" diff --git a/crates/anvil/core/src/eth/trie.rs b/crates/anvil/core/src/eth/trie.rs index bcc86ac8ba36b..59c5cd910a33e 100644 --- a/crates/anvil/core/src/eth/trie.rs +++ b/crates/anvil/core/src/eth/trie.rs @@ -1,8 +1,8 @@ -//! Utility functions for Ethereum adapted from https://github.dev/rust-blockchain/ethereum/blob/755dffaa4903fbec1269f50cde9863cf86269a14/src/util.rs -use std::collections::BTreeMap; +//! Utility functions for Ethereum adapted from use alloy_primitives::{fixed_bytes, B256}; use alloy_trie::{HashBuilder, Nibbles}; +use std::collections::BTreeMap; /// The KECCAK of the RLP encoding of empty data. pub const KECCAK_NULL_RLP: B256 = diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index a9d87051050da..250bf2787a7de 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -25,7 +25,7 @@ parking_lot = "0.12" futures = "0.3" # ipc -parity-tokio-ipc = { version = "0.9", optional = true } +interprocess = { version = "2", optional = true, features = ["tokio"] } bytes = { version = "1.4", optional = true } tokio-util = { version = "0.7", features = ["codec"], optional = true } @@ -40,4 +40,4 @@ pin-project = "1" [features] default = ["ipc"] -ipc = ["parity-tokio-ipc", "bytes", "tokio-util"] +ipc = ["dep:interprocess", "dep:bytes", "dep:tokio-util"] diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index 152b41873f95a..eb2d2d4fd24e3 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -4,7 +4,7 @@ use crate::{error::RequestError, pubsub::PubSubConnection, PubSubRpcHandler}; use anvil_rpc::request::Request; use bytes::BytesMut; use futures::{ready, Sink, Stream, StreamExt}; -use parity_tokio_ipc::Endpoint; +use interprocess::local_socket::{self as ls, tokio::prelude::*}; use std::{ future::Future, io, @@ -18,14 +18,14 @@ use std::{ pub struct IpcEndpoint { /// the handler for the websocket connection handler: Handler, - /// The endpoint we listen for incoming transactions - endpoint: Endpoint, + /// The path to the socket + path: String, } impl IpcEndpoint { /// Creates a new endpoint with the given handler - pub fn new(handler: Handler, endpoint: String) -> Self { - Self { handler, endpoint: Endpoint::new(endpoint) } + pub fn new(handler: Handler, path: String) -> Self { + Self { handler, path } } /// Returns a stream of incoming connection handlers @@ -34,39 +34,43 @@ impl IpcEndpoint { /// connections, See [`PubSubConnection`] that should be spawned #[instrument(target = "ipc", skip_all)] pub fn incoming(self) -> io::Result>> { - let IpcEndpoint { handler, endpoint } = self; - trace!(endpoint=?endpoint.path(), "starting IPC server" ); + let IpcEndpoint { handler, path } = self; + + trace!(%path, "starting IPC server"); if cfg!(unix) { // ensure the file does not exist - if std::fs::remove_file(endpoint.path()).is_ok() { - warn!(endpoint=?endpoint.path(), "removed existing file"); + if std::fs::remove_file(&path).is_ok() { + warn!(%path, "removed existing file"); } } - let connections = match endpoint.incoming() { - Ok(connections) => connections, - Err(err) => { - error!(%err, "Failed to create IPC listener"); - return Err(err) - } - }; + let name = to_name(path.as_ref())?; + let listener = ls::ListenerOptions::new().name(name).create_tokio()?; + // TODO: https://github.com/kotauskas/interprocess/issues/64 + let connections = futures::stream::unfold(listener, |listener| async move { + let conn = listener.accept().await; + Some((conn, listener)) + }); trace!("established connection listener"); - let connections = connections.filter_map(move |stream| { + Ok(connections.filter_map(move |stream| { let handler = handler.clone(); - Box::pin(async move { - if let Ok(stream) = stream { - trace!("successful incoming IPC connection"); - let framed = tokio_util::codec::Decoder::framed(JsonRpcCodec, stream); - Some(PubSubConnection::new(IpcConn(framed), handler)) - } else { - None + async move { + match stream { + Ok(stream) => { + trace!("successful incoming IPC connection"); + let framed = tokio_util::codec::Decoder::framed(JsonRpcCodec, stream); + Some(PubSubConnection::new(IpcConn(framed), handler)) + } + Err(err) => { + trace!(%err, "unsuccessful incoming IPC connection"); + None + } } - }) - }); - Ok(connections) + } + })) } } @@ -118,7 +122,7 @@ where struct JsonRpcCodec; -// Adapted from +// Adapted from impl tokio_util::codec::Decoder for JsonRpcCodec { type Item = String; type Error = io::Error; @@ -171,3 +175,11 @@ impl tokio_util::codec::Encoder for JsonRpcCodec { Ok(()) } } + +fn to_name(path: &std::ffi::OsStr) -> io::Result> { + if cfg!(windows) && !path.as_encoded_bytes().starts_with(br"\\.\pipe\") { + ls::ToNsName::to_ns_name::(path) + } else { + ls::ToFsName::to_fs_name::(path) + } +} diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index d2abc47ec371f..9cac52cfe2f0c 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -59,12 +59,8 @@ pub const CHAIN_ID: u64 = 31337; pub const DEFAULT_MNEMONIC: &str = "test test test test test test test test test test test junk"; /// The default IPC endpoint -#[cfg(windows)] -pub const DEFAULT_IPC_ENDPOINT: &str = r"\\.\pipe\anvil.ipc"; - -/// The default IPC endpoint -#[cfg(not(windows))] -pub const DEFAULT_IPC_ENDPOINT: &str = "/tmp/anvil.ipc"; +pub const DEFAULT_IPC_ENDPOINT: &str = + if cfg!(unix) { "/tmp/anvil.ipc" } else { r"\\.\pipe\anvil.ipc" }; /// `anvil 0.1.0 (f01b232bc 2022-04-13T23:28:39.493201+00:00)` pub const VERSION_MESSAGE: &str = concat!( @@ -801,7 +797,7 @@ impl NodeConfig { /// Returns the ipc path for the ipc endpoint if any pub fn get_ipc_path(&self) -> Option { - match self.ipc_path.as_ref() { + match &self.ipc_path { Some(path) => path.clone().or_else(|| Some(DEFAULT_IPC_ENDPOINT.to_string())), None => None, } diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index ce6a85411e8e1..2cb39a8931535 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -12,6 +12,7 @@ use crate::{ }, filter::Filters, logging::{LoggingManager, NodeLogLayer}, + server::error::{NodeError, NodeResult}, service::NodeService, shutdown::Signal, tasks::TaskManager, @@ -23,6 +24,7 @@ use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; use parking_lot::Mutex; +use server::try_spawn_ipc; use std::{ future::Future, io, @@ -41,11 +43,8 @@ mod service; mod config; pub use config::{AccountGenerator, NodeConfig, CHAIN_ID, VERSION_MESSAGE}; + mod hardfork; -use crate::server::{ - error::{NodeError, NodeResult}, - spawn_ipc, -}; pub use hardfork::Hardfork; /// ethereum related implementations @@ -223,7 +222,8 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle let (signal, on_shutdown) = shutdown::signal(); let task_manager = TaskManager::new(tokio_handle, on_shutdown); - let ipc_task = config.get_ipc_path().map(|path| spawn_ipc(api.clone(), path)); + let ipc_task = + config.get_ipc_path().map(|path| try_spawn_ipc(api.clone(), path)).transpose()?; let handle = NodeHandle { config, @@ -310,8 +310,10 @@ impl NodeHandle { /// Constructs a [`RetryProvider`] for this handle's HTTP endpoint. pub fn http_provider(&self) -> RetryProvider { - ProviderBuilder::new(&self.http_endpoint()).build().expect("failed to build HTTP provider") - // .interval(Duration::from_millis(500)) + ProviderBuilder::new(&self.http_endpoint()) + .aggressive() + .build() + .expect("failed to build HTTP provider") } /// Constructs a [`RetryProvider`] for this handle's WS endpoint. diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index 676a0f61b5171..786217ecd6ab2 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -1,28 +1,34 @@ //! IPC tests -use crate::utils::connect_pubsub; +use crate::{init_tracing, utils::connect_pubsub}; use alloy_primitives::U256; use alloy_provider::Provider; use anvil::{spawn, NodeConfig}; use futures::StreamExt; - -pub fn rand_ipc_endpoint() -> String { - let num: u64 = rand::Rng::gen(&mut rand::thread_rng()); - if cfg!(windows) { - format!(r"\\.\pipe\anvil-ipc-{num}") +use tempfile::TempDir; + +fn ipc_config() -> (Option, NodeConfig) { + let path; + let dir; + if cfg!(unix) { + let tmp = tempfile::tempdir().unwrap(); + path = tmp.path().join("anvil.ipc").to_string_lossy().into_owned(); + dir = Some(tmp); } else { - format!(r"/tmp/anvil-ipc-{num}") + dir = None; + path = format!(r"\\.\pipe\anvil_test_{}.ipc", rand::random::()); } -} - -fn ipc_config() -> NodeConfig { - NodeConfig::test().with_ipc(Some(Some(rand_ipc_endpoint()))) + let config = NodeConfig::test().with_ipc(Some(Some(path))); + (dir, config) } #[tokio::test(flavor = "multi_thread")] -#[cfg_attr(target_os = "windows", ignore)] +#[cfg_attr(windows, ignore = "TODO")] async fn can_get_block_number_ipc() { - let (api, handle) = spawn(ipc_config()).await; + init_tracing(); + + let (_dir, config) = ipc_config(); + let (api, handle) = spawn(config).await; let block_num = api.block_number().unwrap(); assert_eq!(block_num, U256::ZERO); @@ -34,17 +40,19 @@ async fn can_get_block_number_ipc() { } #[tokio::test(flavor = "multi_thread")] -#[cfg_attr(target_os = "windows", ignore)] +#[cfg_attr(windows, ignore = "TODO")] async fn test_sub_new_heads_ipc() { - let (api, handle) = spawn(ipc_config()).await; - - let provider = connect_pubsub(handle.ipc_path().unwrap().as_str()).await; + init_tracing(); - let blocks = provider.subscribe_blocks().await.unwrap().into_stream(); + let (_dir, config) = ipc_config(); + let (api, handle) = spawn(config).await; + let provider = connect_pubsub(handle.ipc_path().unwrap().as_str()).await; // mine a block every 1 seconds api.anvil_set_interval_mining(1).unwrap(); + let blocks = provider.subscribe_blocks().await.unwrap().into_stream(); + let blocks = blocks.take(3).collect::>().await; let block_numbers = blocks.into_iter().map(|b| b.header.number.unwrap()).collect::>(); diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 5402148918ddf..38a24e81b00e2 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -195,7 +195,7 @@ impl RuntimeTransport { async fn connect_ipc(&self) -> Result { let path = url_to_file_path(&self.url) .map_err(|_| RuntimeTransportError::BadPath(self.url.to_string()))?; - let ipc_connector: IpcConnect = path.clone().into(); + let ipc_connector = IpcConnect::new(path.clone()); let ipc = ipc_connector.into_service().await.map_err(|e| { RuntimeTransportError::TransportError(e, path.clone().display().to_string()) })?; From 10c0c7a1160d6500aa1c54053d4f6df9a7249238 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 6 May 2024 17:29:09 +0200 Subject: [PATCH 0942/1963] fix: use B256::try_from for pk (#7871) --- crates/wallets/src/utils.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/wallets/src/utils.rs b/crates/wallets/src/utils.rs index 08c95242af332..898a82fdc4a7e 100644 --- a/crates/wallets/src/utils.rs +++ b/crates/wallets/src/utils.rs @@ -26,7 +26,9 @@ pub fn create_private_key_signer(private_key: &str) -> Result { eyre::bail!("Failed to decode private key") }; - match LocalWallet::from_bytes(&B256::from_slice(&private_key)) { + match LocalWallet::from_bytes( + &B256::try_from(private_key.as_slice()).wrap_err("Failed to decode private key")?, + ) { Ok(pk) => Ok(WalletSigner::Local(pk)), Err(err) => { ensure_pk_not_env(privk)?; From 2e3c197afc341c0f4adbb9dbe09fc04ebb9b7a5d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 6 May 2024 17:49:19 +0200 Subject: [PATCH 0943/1963] chore: bump alloy 17c5650 (#7868) * chore: bump alloy 17c5650 * fix * fix * fix * fix * bump --- Cargo.lock | 228 +++---------------- Cargo.toml | 48 ++-- crates/anvil/core/src/eth/block.rs | 5 + crates/anvil/core/src/eth/transaction/mod.rs | 24 +- crates/anvil/src/eth/backend/fork.rs | 4 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 + crates/anvil/tests/it/anvil_api.rs | 2 +- crates/anvil/tests/it/fork.rs | 2 +- crates/anvil/tests/it/traces.rs | 2 +- crates/anvil/tests/it/txpool.rs | 2 +- crates/cast/src/lib.rs | 2 +- crates/common/src/transactions.rs | 6 +- crates/debugger/src/tui/draw.rs | 1 + crates/evm/traces/src/lib.rs | 1 + 14 files changed, 74 insertions(+), 255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3557e819b12a7..199fb03d5c000 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-eips", "alloy-primitives", @@ -87,14 +87,12 @@ dependencies = [ "alloy-serde", "c-kzg", "serde", - "sha2", - "thiserror", ] [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -134,7 +132,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -143,16 +141,18 @@ dependencies = [ "derive_more", "once_cell", "serde", + "sha2", ] [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "alloy-serde", "serde", + "serde_json", ] [[package]] @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "serde", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -257,7 +257,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -321,7 +321,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -339,7 +339,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -356,7 +356,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -368,7 +368,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "serde", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus", "alloy-network", @@ -410,7 +410,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus", "alloy-network", @@ -428,7 +428,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus", "alloy-network", @@ -444,7 +444,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus", "alloy-network", @@ -521,7 +521,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -539,27 +539,28 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-json-rpc", "alloy-transport", "reqwest", "serde_json", "tower", + "tracing", "url", ] [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-json-rpc", "alloy-pubsub", "alloy-transport", "bytes", "futures", - "interprocess 1.2.1", + "interprocess", "pin-project", "serde", "serde_json", @@ -572,7 +573,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=8808d21#8808d21677ed9a05ff04000ac7f4acdd2fde94e3" +source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -798,7 +799,7 @@ dependencies = [ "bytes", "clap", "futures", - "interprocess 2.0.1", + "interprocess", "parking_lot", "pin-project", "serde", @@ -973,37 +974,13 @@ dependencies = [ "term", ] -[[package]] -name = "async-channel" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" -dependencies = [ - "concurrent-queue", - "event-listener 5.3.0", - "event-listener-strategy 0.5.2", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-lock" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" -dependencies = [ - "event-listener 4.0.3", - "event-listener-strategy 0.4.0", - "pin-project-lite", -] - [[package]] name = "async-priority-channel" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c21678992e1b21bebfe2bc53ab5f5f68c106eddab31b24e0bb06e9b715a86640" dependencies = [ - "event-listener 2.5.3", + "event-listener", ] [[package]] @@ -1039,12 +1016,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "async-task" -version = "4.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" - [[package]] name = "async-trait" version = "0.1.80" @@ -1082,12 +1053,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - [[package]] name = "aurora-engine-modexp" version = "1.1.0" @@ -1605,20 +1570,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "blocking" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" -dependencies = [ - "async-channel", - "async-lock", - "async-task", - "futures-io", - "futures-lite", - "piper", -] - [[package]] name = "blst" version = "0.3.11" @@ -2184,15 +2135,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "concurrent-queue" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "console" version = "0.15.8" @@ -2952,48 +2894,6 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" -[[package]] -name = "event-listener" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener-strategy" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" -dependencies = [ - "event-listener 4.0.3", - "pin-project-lite", -] - -[[package]] -name = "event-listener-strategy" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" -dependencies = [ - "event-listener 5.3.0", - "pin-project-lite", -] - [[package]] name = "evm-disassembler" version = "0.5.0" @@ -3912,16 +3812,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" -[[package]] -name = "futures-lite" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" -dependencies = [ - "futures-core", - "pin-project-lite", -] - [[package]] name = "futures-macro" version = "0.3.30" @@ -4771,27 +4661,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "interprocess" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f2533f3be42fffe3b5e63b71aeca416c1c3bc33e4e27be018521e76b1f38fb" -dependencies = [ - "blocking", - "cfg-if", - "futures-core", - "futures-io", - "intmap", - "libc", - "once_cell", - "rustc_version 0.4.0", - "spinning", - "thiserror", - "to_method", - "tokio", - "winapi", -] - [[package]] name = "interprocess" version = "2.0.1" @@ -4806,12 +4675,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "intmap" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae52f28f45ac2bc96edb7714de995cffc174a395fb0abf5bff453587c980d7b9" - [[package]] name = "ipnet" version = "2.9.0" @@ -5690,12 +5553,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parking" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" - [[package]] name = "parking_lot" version = "0.12.2" @@ -5985,17 +5842,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "piper" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" -dependencies = [ - "atomic-waker", - "fastrand", - "futures-io", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -6536,7 +6382,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=813d7e7#813d7e73a090d426935e63d9308bdd2c945a58c4" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=9a91a10#9a91a107edd197a65a3fd55b3942948036a72b33" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7434,15 +7280,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "spinning" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d4f0e86297cad2658d92a707320d87bf4e6ae1050287f51d19b67ef3f153a7b" -dependencies = [ - "lock_api", -] - [[package]] name = "spki" version = "0.7.3" @@ -7828,12 +7665,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "to_method" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c4ceeeca15c8384bbc3e011dbd8fccb7f068a440b752b7d9b32ceb0ca0e2e8" - [[package]] name = "tokio" version = "1.37.0" @@ -7942,7 +7773,6 @@ checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", - "futures-io", "futures-sink", "pin-project-lite", "tokio", diff --git a/Cargo.toml b/Cargo.toml index f777385f300b1..a06b31f9b002a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.4.0", default-features = false } # no default features to avoid c-kzg revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "813d7e7", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "9a91a10", features = [ "serde", ] } @@ -152,29 +152,29 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index a05c2cae45c6f..bf96a0df5a8dc 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -72,6 +72,7 @@ impl Block { parent_beacon_block_root: partial_header.parent_beacon_block_root, nonce: partial_header.nonce, base_fee_per_gas: partial_header.base_fee, + requests_root: None, }, transactions, ommers, @@ -159,6 +160,7 @@ mod tests { excess_blob_gas: Default::default(), parent_beacon_block_root: Default::default(), base_fee_per_gas: None, + requests_root: None, }; let encoded = alloy_rlp::encode(&header); @@ -199,6 +201,7 @@ mod tests { parent_beacon_block_root: None, nonce: B64::ZERO, base_fee_per_gas: None, + requests_root: None, }; header.encode(&mut data); @@ -231,6 +234,7 @@ mod tests { excess_blob_gas: None, parent_beacon_block_root: None, base_fee_per_gas: None, + requests_root: None, }; let header = Header::decode(&mut data.as_slice()).unwrap(); assert_eq!(header, expected); @@ -262,6 +266,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, + requests_root: None, }; assert_eq!(header.hash_slow(), expected_hash); } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index c52beb16e1045..d29125cdc0f43 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -2,9 +2,8 @@ use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest}; use alloy_consensus::{ - AnyReceiptEnvelope, BlobTransactionSidecar, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, - TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, - TxReceipt, + AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, + TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, TxReceipt, }; use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256}; @@ -146,25 +145,8 @@ pub fn transaction_request_to_typed( access_list: access_list.unwrap_or_default(), blob_versioned_hashes: blob_versioned_hashes.unwrap_or_default(), }; - let blob_sidecar = BlobTransactionSidecar { - blobs: sidecar - .blobs - .into_iter() - .map(|b| c_kzg::Blob::from_bytes(b.as_slice()).unwrap()) - .collect(), - commitments: sidecar - .commitments - .into_iter() - .map(|c| c_kzg::Bytes48::from_bytes(c.as_slice()).unwrap()) - .collect(), - proofs: sidecar - .proofs - .into_iter() - .map(|p| c_kzg::Bytes48::from_bytes(p.as_slice()).unwrap()) - .collect(), - }; Some(TypedTransactionRequest::EIP4844(TxEip4844Variant::TxEip4844WithSidecar( - TxEip4844WithSidecar::from_tx_and_sidecar(tx, blob_sidecar), + TxEip4844WithSidecar::from_tx_and_sidecar(tx, sidecar), ))) } _ => None, diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 934225fbceb69..8b1ed0655f097 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -2,7 +2,7 @@ use crate::eth::{backend::db::Db, error::BlockchainError}; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; -use alloy_provider::{debug::DebugApi, Provider}; +use alloy_provider::{ext::DebugApi, Provider}; use alloy_rpc_types::{ request::TransactionRequest, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, @@ -173,7 +173,7 @@ impl ClientFork { block: Option, ) -> Result { let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().call(request, block.into()).await?; + let res = self.provider().call(request).block(block.into()).await?; Ok(res) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 22e2360e83caf..d49c99d914ef3 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1595,6 +1595,7 @@ impl Backend { gas_limit, gas_used, timestamp, + requests_root, extra_data, mix_hash, nonce, @@ -1629,6 +1630,7 @@ impl Backend { blob_gas_used, excess_blob_gas, parent_beacon_block_root, + requests_root, }, size: Some(size), transactions: alloy_rpc_types::BlockTransactions::Hashes( diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 01247fb280cc9..4f46d7525384e 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -7,7 +7,7 @@ use crate::{ }; use alloy_network::{EthereumSigner, TransactionBuilder}; use alloy_primitives::{address, fixed_bytes, Address, U256, U64}; -use alloy_provider::{txpool::TxPoolApi, Provider}; +use alloy_provider::{ext::TxPoolApi, Provider}; use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionRequest, WithOtherFields}; use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; use anvil_core::{ diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 2ef1e70788196..3af626962bcd5 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -797,7 +797,7 @@ async fn test_fork_call() { let provider = http_provider(rpc::next_http_archive_rpc_endpoint().as_str()); let tx = TransactionRequest::default().to(to).with_input(input.clone()); let tx = WithOtherFields::new(tx); - let res0 = provider.call(&tx, BlockId::Number(block_number.into())).await.unwrap(); + let res0 = provider.call(&tx).block(BlockId::Number(block_number.into())).await.unwrap(); let (api, _) = spawn(fork_config().with_fork_block_number(Some(block_number))).await; diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 932e8e362f32a..d12a848e47106 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,7 +1,7 @@ use crate::{fork::fork_config, utils::http_provider_with_signer}; use alloy_network::{EthereumSigner, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes, U256}; -use alloy_provider::{debug::DebugApi, Provider}; +use alloy_provider::{ext::DebugApi, Provider}; use alloy_rpc_types::{BlockNumberOrTag, TransactionRequest, WithOtherFields}; use alloy_rpc_types_trace::{ geth::{GethDebugTracingCallOptions, GethTrace}, diff --git a/crates/anvil/tests/it/txpool.rs b/crates/anvil/tests/it/txpool.rs index 40007447e5aa5..0882d19775172 100644 --- a/crates/anvil/tests/it/txpool.rs +++ b/crates/anvil/tests/it/txpool.rs @@ -2,7 +2,7 @@ use alloy_network::TransactionBuilder; use alloy_primitives::U256; -use alloy_provider::{txpool::TxPoolApi, Provider}; +use alloy_provider::{ext::TxPoolApi, Provider}; use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use anvil::{spawn, NodeConfig}; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index da4103b74c180..67048fda716ae 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -120,7 +120,7 @@ where func: Option<&Function>, block: Option, ) -> Result { - let res = self.provider.call(req, block.unwrap_or_default()).await?; + let res = self.provider.call(req).block(block.unwrap_or_default()).await?; let mut decoded = vec![]; diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 1f7d6228eef3c..8ec95179f1595 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -48,10 +48,8 @@ impl TransactionReceiptWithRevertReason { if let Some(block_hash) = self.receipt.block_hash { match provider - .call( - &WithOtherFields::new(transaction.inner.into()), - BlockId::Hash(block_hash.into()), - ) + .call(&WithOtherFields::new(transaction.inner.into())) + .block(BlockId::Hash(block_hash.into())) .await { Err(e) => return Ok(extract_revert_reason(e.to_string())), diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index b80a8a77a1079..ffe348f4726d4 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -198,6 +198,7 @@ impl DebuggerContext<'_> { CallKind::StaticCall => "Contract staticcall", CallKind::CallCode => "Contract callcode", CallKind::DelegateCall => "Contract delegatecall", + CallKind::AuthCall => "Contract authcall", }; let block = Block::default().title(title).borders(Borders::ALL); let paragraph = Paragraph::new(text_output).block(block).wrap(Wrap { trim: false }); diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 16cadde109e7b..46ba27891e527 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -192,6 +192,7 @@ pub async fn render_trace( CallKind::CallCode => " [callcode]", CallKind::DelegateCall => " [delegatecall]", CallKind::Create | CallKind::Create2 => unreachable!(), + CallKind::AuthCall => " [authcall]", }; let color = trace_color(trace); From bc5e78d4a3a777c23f70fa9f6e8c2f0cb9cac7c8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 6 May 2024 18:51:58 +0300 Subject: [PATCH 0944/1963] chore(invariant) - reuse code to collect push bytes and storage values (#7865) * chore(invariant) - reuse code to collect push bytes and storage values * Remove build_initial_state, move logic in EvmFuzzState::new --- crates/evm/evm/src/executors/fuzz/mod.rs | 6 +- crates/evm/evm/src/executors/invariant/mod.rs | 8 +- crates/evm/fuzz/src/strategies/mod.rs | 2 +- crates/evm/fuzz/src/strategies/param.rs | 4 +- crates/evm/fuzz/src/strategies/state.rs | 247 +++++++++--------- 5 files changed, 130 insertions(+), 137 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 8e3a85bddfaa8..d81ddbaca01b3 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -10,7 +10,7 @@ use foundry_evm_core::{ }; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ - strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, + strategies::{fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, BaseCounterExample, CounterExample, FuzzCase, FuzzError, FuzzFixtures, FuzzTestResult, }; use foundry_evm_traces::CallTraceArena; @@ -243,9 +243,9 @@ impl FuzzedExecutor { /// Stores fuzz state for use with [fuzz_calldata_from_state] pub fn build_fuzz_state(&self) -> EvmFuzzState { if let Some(fork_db) = self.executor.backend.active_fork_db() { - build_initial_state(fork_db, self.config.dictionary) + EvmFuzzState::new(fork_db, self.config.dictionary) } else { - build_initial_state(self.executor.backend.mem_db(), self.config.dictionary) + EvmFuzzState::new(self.executor.backend.mem_db(), self.config.dictionary) } } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 23972e0c59a55..f2bf2ec0d6571 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -16,10 +16,7 @@ use foundry_evm_fuzz::{ ArtifactFilters, BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract, RandomCallGenerator, SenderFilters, TargetedContracts, }, - strategies::{ - build_initial_state, collect_created_contracts, invariant_strat, override_call_strat, - EvmFuzzState, - }, + strategies::{collect_created_contracts, invariant_strat, override_call_strat, EvmFuzzState}, FuzzCase, FuzzFixtures, FuzzedCases, }; use foundry_evm_traces::CallTraceArena; @@ -347,8 +344,7 @@ impl<'a> InvariantExecutor<'a> { self.select_contracts_and_senders(invariant_contract.address)?; // Stores fuzz state for use with [fuzz_calldata_from_state]. - let fuzz_state: EvmFuzzState = - build_initial_state(self.executor.backend.mem_db(), self.config.dictionary); + let fuzz_state = EvmFuzzState::new(self.executor.backend.mem_db(), self.config.dictionary); // Creates the invariant strategy. let strat = invariant_strat( diff --git a/crates/evm/fuzz/src/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs index 74cefca2ab371..4e1120b589aec 100644 --- a/crates/evm/fuzz/src/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -11,7 +11,7 @@ mod calldata; pub use calldata::{fuzz_calldata, fuzz_calldata_from_state}; mod state; -pub use state::{build_initial_state, collect_created_contracts, EvmFuzzState}; +pub use state::{collect_created_contracts, EvmFuzzState}; mod invariants; pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call_strat}; diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 12904cb005699..137a04232aa87 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -212,7 +212,7 @@ pub fn fuzz_param_from_state( #[cfg(test)] mod tests { use crate::{ - strategies::{build_initial_state, fuzz_calldata, fuzz_calldata_from_state}, + strategies::{fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, FuzzFixtures, }; use foundry_common::abi::get_func; @@ -224,7 +224,7 @@ mod tests { let f = "testArray(uint64[2] calldata values)"; let func = get_func(f).unwrap(); let db = CacheDB::new(EmptyDB::default()); - let state = build_initial_state(&db, FuzzDictionaryConfig::default()); + let state = EvmFuzzState::new(&db, FuzzDictionaryConfig::default()); let strat = proptest::prop_oneof![ 60 => fuzz_calldata(func.clone(), &FuzzFixtures::default()), 40 => fuzz_calldata_from_state(func, &state), diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 2ee3f7fca1817..0a05028cc8502 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -6,9 +6,9 @@ use foundry_evm_core::utils::StateChangeset; use indexmap::IndexSet; use parking_lot::{lock_api::RwLockReadGuard, RawRwLock, RwLock}; use revm::{ - db::{CacheDB, DatabaseRef}, + db::{CacheDB, DatabaseRef, DbAccount}, interpreter::opcode::{self, spec_opcode_gas}, - primitives::SpecId, + primitives::{AccountInfo, SpecId}, }; use std::{fmt, sync::Arc}; @@ -21,14 +21,21 @@ pub struct EvmFuzzState { } impl EvmFuzzState { - pub fn new(dictionary: FuzzDictionary) -> Self { + pub fn new(db: &CacheDB, config: FuzzDictionaryConfig) -> EvmFuzzState { + // Sort accounts to ensure deterministic dictionary generation from the same setUp state. + let mut accs = db.accounts.iter().collect::>(); + accs.sort_by_key(|(address, _)| *address); + + // Create fuzz dictionary and insert values from db state. + let mut dictionary = FuzzDictionary::new(config); + dictionary.insert_db_values(accs); Self { inner: Arc::new(RwLock::new(dictionary)) } } pub fn collect_values(&self, values: impl IntoIterator) { let mut dict = self.inner.write(); for value in values { - dict.insert_value(value); + dict.insert_value(value, true); } } @@ -36,54 +43,8 @@ impl EvmFuzzState { /// the given [FuzzDictionaryConfig]. pub fn collect_state_from_call(&self, logs: &[Log], state_changeset: &StateChangeset) { let mut dict = self.inner.write(); - - // Insert log topics and data. - for log in logs { - for topic in log.topics() { - dict.insert_value(topic.0); - } - let chunks = log.data.data.chunks_exact(32); - let rem = chunks.remainder(); - for chunk in chunks { - dict.insert_value(chunk.try_into().unwrap()); - } - if !rem.is_empty() { - dict.insert_value(B256::right_padding_from(rem).0); - } - } - - for (address, account) in state_changeset { - // Insert basic account information - dict.insert_value(address.into_word().into()); - - if dict.config.include_push_bytes { - // Insert push bytes - if let Some(code) = &account.info.code { - dict.insert_address(*address); - for push_byte in collect_push_bytes(code.bytes()) { - dict.insert_value(push_byte); - } - } - } - - if dict.config.include_storage { - // Insert storage - for (slot, value) in &account.storage { - let value = value.present_value; - dict.insert_value(B256::from(*slot).0); - dict.insert_value(B256::from(value).0); - // also add the value below and above the storage value to the dictionary. - if value != U256::ZERO { - let below_value = value - U256::from(1); - dict.insert_value(B256::from(below_value).0); - } - if value != U256::MAX { - let above_value = value + U256::from(1); - dict.insert_value(B256::from(above_value).0); - } - } - } - } + dict.insert_logs_values(logs); + dict.insert_state_values(state_changeset); } /// Removes all newly added entries from the dictionary. @@ -101,6 +62,7 @@ impl EvmFuzzState { // We're using `IndexSet` to have a stable element order when restoring persisted state, as well as // for performance when iterating over the sets. +#[derive(Default)] pub struct FuzzDictionary { /// Collected state values. state_values: IndexSet<[u8; 32]>, @@ -124,36 +86,126 @@ impl fmt::Debug for FuzzDictionary { } impl FuzzDictionary { - pub fn new( - initial_values: IndexSet<[u8; 32]>, - initial_addresses: IndexSet
, - config: FuzzDictionaryConfig, - ) -> Self { - Self { - state_values: initial_values, - addresses: initial_addresses, - config, - new_values: IndexSet::new(), - new_addreses: IndexSet::new(), + pub fn new(config: FuzzDictionaryConfig) -> Self { + Self { config, ..Default::default() } + } + + /// Insert values from initial db state into fuzz dictionary. + /// These values are persisted across invariant runs. + fn insert_db_values(&mut self, db_state: Vec<(&Address, &DbAccount)>) { + for (address, account) in db_state { + // Insert basic account information + self.insert_value(address.into_word().into(), false); + // Insert push bytes + self.insert_push_bytes_values(address, &account.info, false); + // Insert storage values. + if self.config.include_storage { + for (slot, value) in &account.storage { + self.insert_storage_value(slot, value, false); + } + } + } + + // need at least some state data if db is empty otherwise we can't select random data for + // state fuzzing + if self.values().is_empty() { + // prefill with a random addresses + self.insert_value(Address::random().into_word().into(), false); } } - pub fn insert_value(&mut self, value: [u8; 32]) { - if self.state_values.len() < self.config.max_fuzz_dictionary_values && - self.state_values.insert(value) - { - self.new_values.insert(value); + /// Insert values from call state changeset into fuzz dictionary. + /// These values are removed at the end of current run. + fn insert_state_values(&mut self, state_changeset: &StateChangeset) { + for (address, account) in state_changeset { + // Insert basic account information. + self.insert_value(address.into_word().into(), true); + // Insert push bytes. + self.insert_push_bytes_values(address, &account.info, true); + // Insert storage values. + if self.config.include_storage { + for (slot, value) in &account.storage { + self.insert_storage_value(slot, &value.present_value, true); + } + } + } + } + + /// Insert values from call log topics and data into fuzz dictionary. + /// These values are removed at the end of current run. + fn insert_logs_values(&mut self, logs: &[Log]) { + for log in logs { + for topic in log.topics() { + self.insert_value(topic.0, true); + } + let chunks = log.data.data.chunks_exact(32); + let rem = chunks.remainder(); + for chunk in chunks { + self.insert_value(chunk.try_into().unwrap(), true); + } + if !rem.is_empty() { + self.insert_value(B256::right_padding_from(rem).0, true); + } + } + } + + /// Insert values from push bytes into fuzz dictionary. + /// If values are newly collected then they are removed at the end of current run. + fn insert_push_bytes_values( + &mut self, + address: &Address, + account_info: &AccountInfo, + collected: bool, + ) { + if self.config.include_push_bytes { + // Insert push bytes + if let Some(code) = account_info.code.clone() { + self.insert_address(*address, collected); + for push_byte in collect_push_bytes(code.bytes()) { + self.insert_value(push_byte, collected); + } + } } } - pub fn insert_address(&mut self, address: Address) { + /// Insert values from single storage slot and storage value into fuzz dictionary. + /// If storage values are newly collected then they are removed at the end of current run. + fn insert_storage_value(&mut self, storage_slot: &U256, storage_value: &U256, collected: bool) { + self.insert_value(B256::from(*storage_slot).0, collected); + self.insert_value(B256::from(*storage_value).0, collected); + // also add the value below and above the storage value to the dictionary. + if *storage_value != U256::ZERO { + let below_value = storage_value - U256::from(1); + self.insert_value(B256::from(below_value).0, collected); + } + if *storage_value != U256::MAX { + let above_value = storage_value + U256::from(1); + self.insert_value(B256::from(above_value).0, collected); + } + } + + /// Insert address into fuzz dictionary. + /// If address is newly collected then it is removed at the end of current run. + fn insert_address(&mut self, address: Address, collected: bool) { if self.addresses.len() < self.config.max_fuzz_dictionary_addresses && - self.addresses.insert(address) + self.addresses.insert(address) && + collected { self.new_addreses.insert(address); } } + /// Insert raw value into fuzz dictionary. + /// If value is newly collected then it is removed at the end of current run. + fn insert_value(&mut self, value: [u8; 32], collected: bool) { + if self.state_values.len() < self.config.max_fuzz_dictionary_values && + self.state_values.insert(value) && + collected + { + self.new_values.insert(value); + } + } + #[inline] pub fn values(&self) -> &IndexSet<[u8; 32]> { &self.state_values @@ -177,61 +229,6 @@ impl FuzzDictionary { } } -/// Builds the initial [EvmFuzzState] from a database. -pub fn build_initial_state( - db: &CacheDB, - config: FuzzDictionaryConfig, -) -> EvmFuzzState { - let mut values = IndexSet::new(); - let mut addresses = IndexSet::new(); - - // Sort accounts to ensure deterministic dictionary generation from the same setUp state. - let mut accs = db.accounts.iter().collect::>(); - accs.sort_by_key(|(address, _)| *address); - - for (address, account) in accs { - let address: Address = *address; - // Insert basic account information - values.insert(address.into_word().into()); - - // Insert push bytes - if config.include_push_bytes { - if let Some(code) = &account.info.code { - addresses.insert(address); - for push_byte in collect_push_bytes(code.bytes()) { - values.insert(push_byte); - } - } - } - - if config.include_storage { - // Insert storage - for (slot, value) in &account.storage { - values.insert(B256::from(*slot).0); - values.insert(B256::from(*value).0); - // also add the value below and above the storage value to the dictionary. - if *value != U256::ZERO { - let below_value = value - U256::from(1); - values.insert(B256::from(below_value).0); - } - if *value != U256::MAX { - let above_value = value + U256::from(1); - values.insert(B256::from(above_value).0); - } - } - } - } - - // need at least some state data if db is empty otherwise we can't select random data for state - // fuzzing - if values.is_empty() { - // prefill with a random addresses - values.insert(Address::random().into_word().into()); - } - - EvmFuzzState::new(FuzzDictionary::new(values, addresses, config)) -} - /// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). /// /// This is to limit the performance impact of fuzz tests that might deploy arbitrarily sized From 6ded8579b28493704d6efd4eacf4962088456aaa Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 6 May 2024 18:48:01 +0200 Subject: [PATCH 0945/1963] test: fix some flaky tests (#7873) --- crates/anvil/tests/it/api.rs | 2 +- crates/anvil/tests/it/ganache.rs | 9 ++++++++- crates/anvil/tests/it/transaction.rs | 11 +++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index ec8335562f79a..9619e1388e379 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -198,7 +198,7 @@ async fn can_call_on_pending_block() { api.evm_set_block_gas_limit(U256::from(30_000_000 + i)).unwrap(); api.anvil_mine(Some(U256::from(1)), None).await.unwrap(); - tokio::time::sleep(Duration::from_secs(1)).await; + tokio::time::sleep(Duration::from_millis(100)).await; } // Ensure that the right header values are set when calling a past block diff --git a/crates/anvil/tests/it/ganache.rs b/crates/anvil/tests/it/ganache.rs index ca8589e210bdf..f86aa7cf8e3f2 100644 --- a/crates/anvil/tests/it/ganache.rs +++ b/crates/anvil/tests/it/ganache.rs @@ -78,7 +78,14 @@ async fn test_ganache_emit_logs() { let val = _0; assert_eq!(val, first_msg); - emit_logs_contract.setValue(next_msg.clone()).send().await.unwrap(); + emit_logs_contract + .setValue(next_msg.clone()) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); let EmitLogs::getValueReturn { _0 } = emit_logs_contract.getValue().call().await.unwrap(); let val = _0; diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 7e088e0b5cc79..d0dbc539c97c2 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -392,7 +392,14 @@ async fn can_call_greeter_historic() { let block_number = provider.get_block_number().await.unwrap(); - let _ = greeter_contract.setGreeting("Another Message".to_string()).send().await.unwrap(); + let _receipt = greeter_contract + .setGreeting("Another Message".to_string()) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); let greeting = greeter_contract.greet().call().await.unwrap(); assert_eq!("Another Message", greeting._0); @@ -511,7 +518,7 @@ async fn call_past_state() { let gas_price = api.gas_price().unwrap().to::(); let set_tx = contract.setValue("hi".to_string()).gas_price(gas_price + 1); - let _set_tx = set_tx.send().await.unwrap().get_receipt().await.unwrap(); + let _receipt = set_tx.send().await.unwrap().get_receipt().await.unwrap(); // assert new value let value = contract.getValue().call().await.unwrap(); From e7f9b75a5146b36a5c6df01757132957c42a1050 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 6 May 2024 23:17:50 +0200 Subject: [PATCH 0946/1963] chore: stop using RuntimeOrHandle (#7860) --- Cargo.lock | 1 - Cargo.toml | 1 + crates/anvil/Cargo.toml | 4 +-- crates/cast/Cargo.toml | 2 +- crates/cheatcodes/src/evm/fork.rs | 29 +++++-------------- crates/cheatcodes/src/utils.rs | 7 ++--- crates/chisel/Cargo.toml | 2 +- crates/chisel/src/dispatcher.rs | 9 +++--- crates/chisel/src/executor.rs | 2 +- crates/cli/Cargo.toml | 2 +- crates/cli/src/utils/mod.rs | 1 - crates/common/Cargo.toml | 4 +-- crates/common/src/lib.rs | 13 +++++++++ crates/evm/core/Cargo.toml | 3 +- crates/evm/core/src/opts.rs | 9 +++--- crates/evm/core/src/utils.rs | 4 +-- crates/evm/evm/src/executors/tracing.rs | 2 +- crates/evm/traces/Cargo.toml | 2 +- crates/evm/traces/src/identifier/etherscan.rs | 3 +- crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/bin/main.rs | 2 +- crates/forge/src/multi_runner.rs | 7 +++-- crates/forge/src/runner.rs | 3 ++ crates/script/src/execute.rs | 6 ++-- crates/verify/Cargo.toml | 2 +- crates/wallets/Cargo.toml | 2 +- 27 files changed, 63 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 199fb03d5c000..c6060c8b0ee32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3558,7 +3558,6 @@ dependencies = [ "eyre", "foundry-cheatcodes-spec", "foundry-common", - "foundry-compilers", "foundry-config", "foundry-macros", "foundry-test-utils", diff --git a/Cargo.toml b/Cargo.toml index a06b31f9b002a..bd96efd2e8f18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -212,6 +212,7 @@ tikv-jemallocator = "0.5.4" num-format = "0.4.4" yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } tempfile = "3.10" +tokio = "1" axum = "0.7" hyper = "1.0" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 63a7f89f9af6d..7ab515768af58 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -60,7 +60,7 @@ tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } # async -tokio = { version = "1", features = ["time"] } +tokio = { workspace = true, features = ["time"] } parking_lot = "0.12" futures = "0.3" async-trait = "0.1" @@ -99,7 +99,7 @@ alloy-json-rpc.workspace = true alloy-pubsub.workspace = true foundry-test-utils.workspace = true similar-asserts.workspace = true -tokio = { version = "1", features = ["full"] } +tokio = { workspace = true, features = ["full"] } [features] default = ["cli"] diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index cf7325512a58e..5d4405ae51420 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -71,7 +71,7 @@ regex = { version = "1", default-features = false } rpassword = "7" semver = "1" tempfile.workspace = true -tokio = { version = "1", features = ["macros", "signal"] } +tokio = { workspace = true, features = ["macros", "signal"] } tracing.workspace = true yansi.workspace = true evmole = "0.3.1" diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index f7db4c0e9774b..63f0bbad1b0c8 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -3,9 +3,7 @@ use alloy_primitives::{B256, U256}; use alloy_provider::Provider; use alloy_rpc_types::Filter; use alloy_sol_types::SolValue; -use eyre::WrapErr; use foundry_common::provider::ProviderBuilder; -use foundry_compilers::utils::RuntimeOrHandle; use foundry_evm_core::fork::CreateFork; impl Cheatcode for activeForkCall { @@ -227,11 +225,10 @@ impl Cheatcode for rpcCall { let url = ccx.ecx.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; - let method: &'static str = Box::new(method.clone()).leak(); let params_json: serde_json::Value = serde_json::from_str(params)?; - let result = RuntimeOrHandle::new() - .block_on(provider.raw_request(method.into(), params_json)) - .map_err(|err| fmt_err!("{method:?}: {err}"))?; + let result = + foundry_common::block_on(provider.raw_request(method.clone().into(), params_json)) + .map_err(|err| fmt_err!("{method:?}: {err}"))?; let result_as_tokens = crate::json::json_value_to_token(&result) .map_err(|err| fmt_err!("failed to parse result: {err}"))?; @@ -256,24 +253,12 @@ impl Cheatcode for eth_getLogsCall { ccx.ecx.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; let provider = ProviderBuilder::new(&url).build()?; let mut filter = Filter::new().address(*target).from_block(from_block).to_block(to_block); - for (i, topic) in topics.iter().enumerate() { - // todo: needed because rust wants to convert FixedBytes<32> to U256 to convert it back - // to FixedBytes<32> and then to Topic for some reason removing the - // From impl in alloy does not fix the situation, and it is not possible to impl - // From> either because of a conflicting impl - match i { - 0 => filter = filter.event_signature(*topic), - 1 => filter = filter.topic1(*topic), - 2 => filter = filter.topic2(*topic), - 3 => filter = filter.topic3(*topic), - _ => unreachable!(), - }; + for (i, &topic) in topics.iter().enumerate() { + filter.topics[i] = topic.into(); } - // todo: handle the errors somehow - let logs = RuntimeOrHandle::new() - .block_on(provider.get_logs(&filter)) - .wrap_err("failed to get logs")?; + let logs = foundry_common::block_on(provider.get_logs(&filter)) + .map_err(|e| fmt_err!("failed to get logs: {e}"))?; let eth_logs = logs .into_iter() diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 7544abc0a624b..71cfe6ae67262 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -11,7 +11,7 @@ use alloy_signer_wallet::{ LocalWallet, MnemonicBuilder, }; use alloy_sol_types::SolValue; -use foundry_evm_core::{constants::DEFAULT_CREATE2_DEPLOYER, utils::RuntimeOrHandle}; +use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; use k256::{ ecdsa::SigningKey, elliptic_curve::{sec1::ToEncodedPoint, Curve}, @@ -202,9 +202,8 @@ pub(super) fn sign_with_wallet( .get(&signer) .ok_or_else(|| fmt_err!("signer with address {signer} is not available"))?; - let sig = RuntimeOrHandle::new() - .block_on(wallet.sign_hash(digest)) - .map_err(|err| fmt_err!("{err}"))?; + let sig = + foundry_common::block_on(wallet.sign_hash(digest)).map_err(|err| fmt_err!("{err}"))?; let recovered = sig.recover_address_from_prehash(digest).map_err(|err| fmt_err!("{err}"))?; assert_eq!(recovered, signer); diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 6ae62b970db33..fc8a2a7822e60 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -46,7 +46,7 @@ serde.workspace = true solang-parser.workspace = true strum = { workspace = true, features = ["derive"] } time = { version = "0.3", features = ["formatting"] } -tokio = { version = "1", features = ["full"] } +tokio = { workspace = true, features = ["full"] } yansi.workspace = true tracing.workspace = true diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index ebf4aeb3765ef..e32b1ac013ea4 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -689,7 +689,7 @@ impl ChiselDispatcher { let failed = !res.success; if new_session_source.config.traces || failed { if let Ok(decoder) = - Self::decode_traces(&new_session_source.config, &mut res) + Self::decode_traces(&new_session_source.config, &mut res).await { if let Err(e) = Self::show_traces(&decoder, &mut res).await { return DispatchResult::CommandFailed(e.to_string()) @@ -834,7 +834,8 @@ impl ChiselDispatcher { // If traces are enabled or there was an error in execution, show the execution // traces. if new_source.config.traces || failed { - if let Ok(decoder) = Self::decode_traces(&new_source.config, &mut res) { + if let Ok(decoder) = Self::decode_traces(&new_source.config, &mut res).await + { if let Err(e) = Self::show_traces(&decoder, &mut res).await { return DispatchResult::CommandFailed(e.to_string()) }; @@ -888,7 +889,7 @@ impl ChiselDispatcher { /// ### Returns /// /// Optionally, a [CallTraceDecoder] - pub fn decode_traces( + pub async fn decode_traces( session_config: &SessionSourceConfig, result: &mut ChiselResult, // known_contracts: &ContractsByArtifact, @@ -903,7 +904,7 @@ impl ChiselDispatcher { let mut identifier = TraceIdentifiers::new().with_etherscan( &session_config.foundry_config, - session_config.evm_opts.get_remote_chain_id(), + session_config.evm_opts.get_remote_chain_id().await, )?; if !identifier.is_empty() { for (_, trace) in &mut result.traces { diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 3ae465e4d8484..fc1e7c84a86fd 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -189,7 +189,7 @@ impl SessionSource { let Some((stack, memory, _)) = &res.state else { // Show traces and logs, if there are any, and return an error - if let Ok(decoder) = ChiselDispatcher::decode_traces(&source.config, &mut res) { + if let Ok(decoder) = ChiselDispatcher::decode_traces(&source.config, &mut res).await { ChiselDispatcher::show_traces(&decoder, &mut res).await?; } let decoded_logs = decode_console_logs(&res.logs); diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index dd247ac4802f3..8c4f353ddf818 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -36,7 +36,7 @@ regex = { version = "1", default-features = false } serde.workspace = true strsim = "0.10" strum = { workspace = true, features = ["derive"] } -tokio = { version = "1", features = ["macros"] } +tokio = { workspace = true, features = ["macros"] } tracing-error = "0.2" tracing-subscriber = { workspace = true, features = ["registry", "env-filter", "fmt"] } tracing.workspace = true diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 8f751728dee3d..34333e5931081 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -158,7 +158,6 @@ pub fn now() -> Duration { } /// Runs the `future` in a new [`tokio::runtime::Runtime`] -#[allow(unused)] pub fn block_on(future: F) -> F::Output { let rt = tokio::runtime::Runtime::new().expect("could not start tokio rt"); rt.block_on(future) diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 6a4ae4f38ce1a..bdf0e34579685 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -48,7 +48,7 @@ serde_json.workspace = true serde.workspace = true tempfile.workspace = true thiserror = "1" -tokio = "1" +tokio.workspace = true tracing.workspace = true url = "2" walkdir = "2" @@ -59,4 +59,4 @@ num-format.workspace = true [dev-dependencies] foundry-macros.workspace = true similar-asserts.workspace = true -tokio = { version = "1", features = ["rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 6febaa3787751..2ffc066d6de53 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -31,3 +31,16 @@ pub use constants::*; pub use contracts::*; pub use traits::*; pub use transactions::*; + +/// Block on a future using the current tokio runtime on the current thread. +pub fn block_on(future: F) -> F::Output { + block_on_handle(&tokio::runtime::Handle::current(), future) +} + +/// Block on a future using the current tokio runtime on the current thread with the given handle. +pub fn block_on_handle( + handle: &tokio::runtime::Handle, + future: F, +) -> F::Output { + tokio::task::block_in_place(|| handle.block_on(future)) +} diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index c3285d92cdf90..589e13b2572a5 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -13,7 +13,6 @@ repository.workspace = true [dependencies] foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true -foundry-compilers.workspace = true foundry-config.workspace = true foundry-macros.workspace = true @@ -52,7 +51,7 @@ rustc-hash.workspace = true serde = "1" serde_json = "1" thiserror = "1" -tokio = { version = "1", features = ["time", "macros"] } +tokio = { workspace = true, features = ["time", "macros"] } tracing = "0.1" url = "2" diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 682e2444fd4d0..2fe3d0390be5b 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -5,7 +5,6 @@ use alloy_provider::Provider; use alloy_rpc_types::Block; use eyre::WrapErr; use foundry_common::{provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS}; -use foundry_compilers::utils::RuntimeOrHandle; use foundry_config::{Chain, Config}; use revm::primitives::{BlockEnv, CfgEnv, TxEnv}; use serde::{Deserialize, Deserializer, Serialize}; @@ -166,11 +165,11 @@ impl EvmOpts { /// - mainnet if `fork_url` contains "mainnet" /// - the chain if `fork_url` is set and the endpoints returned its chain id successfully /// - mainnet otherwise - pub fn get_chain_id(&self) -> u64 { + pub async fn get_chain_id(&self) -> u64 { if let Some(id) = self.env.chain_id { return id; } - self.get_remote_chain_id().unwrap_or(Chain::mainnet()).id() + self.get_remote_chain_id().await.unwrap_or(Chain::mainnet()).id() } /// Returns the available compute units per second, which will be @@ -188,7 +187,7 @@ impl EvmOpts { } /// Returns the chain ID from the RPC, if any. - pub fn get_remote_chain_id(&self) -> Option { + pub async fn get_remote_chain_id(&self) -> Option { if let Some(ref url) = self.fork_url { if url.contains("mainnet") { trace!(?url, "auto detected mainnet chain"); @@ -201,7 +200,7 @@ impl EvmOpts { .ok() .unwrap_or_else(|| panic!("Failed to establish provider to {url}")); - if let Ok(id) = RuntimeOrHandle::new().block_on(provider.get_chain_id()) { + if let Ok(id) = provider.get_chain_id().await { return Some(Chain::from(id)); } } diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 20d8aa6478644..bf9664bd8820b 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -4,9 +4,7 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, FixedBytes, U256}; use alloy_rpc_types::{Block, Transaction}; use eyre::ContextCompat; -pub use foundry_compilers::utils::RuntimeOrHandle; use foundry_config::NamedChain; -pub use revm::primitives::State as StateChangeset; use revm::{ db::WrapDatabaseRef, handler::register::EvmHandler, @@ -19,6 +17,8 @@ use revm::{ }; use std::{cell::RefCell, rc::Rc, sync::Arc}; +pub use revm::primitives::State as StateChangeset; + /// Depending on the configured chain id and block number this should apply any specific changes /// /// - checks for prevrandao mixhash after merge diff --git a/crates/evm/evm/src/executors/tracing.rs b/crates/evm/evm/src/executors/tracing.rs index 08979bc168669..a175aecb6f739 100644 --- a/crates/evm/evm/src/executors/tracing.rs +++ b/crates/evm/evm/src/executors/tracing.rs @@ -45,7 +45,7 @@ impl TracingExecutor { let fork = evm_opts.get_fork(config, env.clone()); - Ok((env, fork, evm_opts.get_remote_chain_id())) + Ok((env, fork, evm_opts.get_remote_chain_id().await)) } } diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index a4bcb0a0b33fb..496a4e9989797 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -29,7 +29,7 @@ hex.workspace = true itertools.workspace = true once_cell = "1" serde = "1" -tokio = { version = "1", features = ["time", "macros"] } +tokio = { workspace = true, features = ["time", "macros"] } tracing = "0.1" yansi.workspace = true diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 11996be3a5d65..977b69a42340a 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -6,7 +6,6 @@ use foundry_block_explorers::{ }; use foundry_common::compile::{self, ContractSources}; use foundry_config::{Chain, Config}; -use foundry_evm_core::utils::RuntimeOrHandle; use futures::{ future::{join_all, Future}, stream::{FuturesUnordered, Stream, StreamExt}, @@ -129,7 +128,7 @@ impl TraceIdentifier for EtherscanIdentifier { } } - let fetched_identities = RuntimeOrHandle::new().block_on( + let fetched_identities = foundry_common::block_on( fetcher .map(|(address, metadata)| { let label = metadata.contract_name.clone(); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 6bb111eac52fc..f58968bf0315d 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -79,7 +79,7 @@ similar = { version = "2", features = ["inline"] } solang-parser.workspace = true strum = { workspace = true, features = ["derive"] } thiserror = "1" -tokio = { version = "1", features = ["time"] } +tokio = { workspace = true, features = ["time"] } toml = { version = "0.8", features = ["preserve_order"] } toml_edit = "0.22.4" watchexec = "2.3.2" diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index b20017c85a469..cef2349661479 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -361,7 +361,7 @@ impl TestArgs { return Ok(TestOutcome::new(results, self.allow_failure)); } - let remote_chain_id = runner.evm_opts.get_remote_chain_id(); + let remote_chain_id = runner.evm_opts.get_remote_chain_id().await; // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index f598c1212e617..8db9036e186ba 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -49,7 +49,7 @@ fn main() -> Result<()> { if cmd.is_watch() { utils::block_on(watch::watch_build(cmd)) } else { - cmd.run().map(|_| ()) + cmd.run().map(drop) } } ForgeSubcommand::Debug(cmd) => utils::block_on(cmd.run()), diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 9fed56982a8b8..1e4f773882953 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -147,6 +147,7 @@ impl MultiContractRunner { /// /// Each Executor gets its own instance of the `Backend`. pub fn test(&mut self, filter: &dyn TestFilter, tx: mpsc::Sender<(String, SuiteResult)>) { + let handle = tokio::runtime::Handle::current(); trace!("running all tests"); // The DB backend that serves all the data. @@ -163,7 +164,8 @@ impl MultiContractRunner { ); contracts.par_iter().for_each_with(tx, |tx, &(id, contract)| { - let result = self.run_tests(id, contract, db.clone(), filter); + let _guard = handle.enter(); + let result = self.run_tests(id, contract, db.clone(), filter, &handle); let _ = tx.send((id.identifier(), result)); }) } @@ -174,6 +176,7 @@ impl MultiContractRunner { contract: &TestContract, db: Backend, filter: &dyn TestFilter, + handle: &tokio::runtime::Handle, ) -> SuiteResult { let identifier = artifact_id.identifier(); let mut span_name = identifier.as_str(); @@ -220,7 +223,7 @@ impl MultiContractRunner { &self.revert_decoder, self.debug, ); - let r = runner.run_tests(filter, &self.test_options, known_contracts); + let r = runner.run_tests(filter, &self.test_options, known_contracts, handle); debug!(duration=?r.duration, "executed all tests in contract"); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index b29309bb0ac45..48fa10b6dcd08 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -254,6 +254,7 @@ impl<'a> ContractRunner<'a> { filter: &dyn TestFilter, test_options: &TestOptions, known_contracts: Arc, + handle: &tokio::runtime::Handle, ) -> SuiteResult { info!("starting tests"); let start = Instant::now(); @@ -346,6 +347,8 @@ impl<'a> ContractRunner<'a> { let test_results = functions .par_iter() .map(|&func| { + let _guard = handle.enter(); + let sig = func.signature(); let setup = setup.clone(); diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index ea307de5bd045..9e988c09b50a4 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -298,7 +298,7 @@ impl ExecutedState { pub async fn prepare_simulation(self) -> Result { let returns = self.get_returns()?; - let decoder = self.build_trace_decoder(&self.build_data.known_contracts)?; + let decoder = self.build_trace_decoder(&self.build_data.known_contracts).await?; let txs = self.execution_result.transactions.clone().unwrap_or_default(); let rpc_data = RpcData::from_transactions(&txs); @@ -328,7 +328,7 @@ impl ExecutedState { } /// Builds [CallTraceDecoder] from the execution result and known contracts. - fn build_trace_decoder( + async fn build_trace_decoder( &self, known_contracts: &ContractsByArtifact, ) -> Result { @@ -344,7 +344,7 @@ impl ExecutedState { let mut identifier = TraceIdentifiers::new().with_local(known_contracts).with_etherscan( &self.script_config.config, - self.script_config.evm_opts.get_remote_chain_id(), + self.script_config.evm_opts.get_remote_chain_id().await, )?; // Decoding traces using etherscan is costly as we run into rate limits, diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 21eb659423c32..62979edbc8a78 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -38,6 +38,6 @@ once_cell = "1" yansi.workspace = true [dev-dependencies] -tokio = { version = "1", features = ["macros"] } +tokio = { workspace = true, features = ["macros"] } foundry-test-utils.workspace = true tempfile.workspace = true diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 545207b4096d5..a0495c51d169f 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -39,7 +39,7 @@ thiserror = "1" tracing.workspace = true [dev-dependencies] -tokio = { version = "1", features = ["macros"] } +tokio = { workspace = true, features = ["macros"] } [features] default = ["rustls"] From bfc6549f0d50fe31cd2fae875c2c7233db98bde9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 7 May 2024 00:49:12 +0300 Subject: [PATCH 0947/1963] chore(invariant): remove persist_state config, commit by default (#7819) * chore(invariant): remove persist_state config, commit to backend by default * Test snekmate fix * Point to latest snekmate commit --- crates/config/README.md | 1 - crates/config/src/invariant.rs | 6 ------ crates/evm/evm/src/executors/invariant/mod.rs | 18 +++++------------- crates/forge/tests/cli/ext_integration.rs | 2 +- crates/forge/tests/it/invariant.rs | 13 ------------- crates/forge/tests/it/test_helpers.rs | 1 - 6 files changed, 6 insertions(+), 35 deletions(-) diff --git a/crates/config/README.md b/crates/config/README.md index ffa4cdc750257..105aaffc6e776 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -196,7 +196,6 @@ dictionary_weight = 80 include_storage = true include_push_bytes = true shrink_sequence = true -preserve_state = false [fmt] line_length = 100 diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index c7462d539461b..0442d467b77ce 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -29,10 +29,6 @@ pub struct InvariantConfig { pub shrink_sequence: bool, /// The maximum number of attempts to shrink the sequence pub shrink_run_limit: usize, - /// If set to true then VM state is committed and available for next call - /// Useful for handlers that use cheatcodes as roll or warp - /// Use it with caution, introduces performance penalty. - pub preserve_state: bool, /// The maximum number of rejects via `vm.assume` which can be encountered during a single /// invariant run. pub max_assume_rejects: u32, @@ -50,7 +46,6 @@ impl Default for InvariantConfig { dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() }, shrink_sequence: true, shrink_run_limit: 2usize.pow(18_u32), - preserve_state: false, max_assume_rejects: 65536, gas_report_samples: 256, } @@ -81,7 +76,6 @@ impl InlineConfigParser for InvariantConfig { "fail-on-revert" => conf_clone.fail_on_revert = parse_config_bool(key, value)?, "call-override" => conf_clone.call_override = parse_config_bool(key, value)?, "shrink-sequence" => conf_clone.shrink_sequence = parse_config_bool(key, value)?, - "preserve-state" => conf_clone.preserve_state = parse_config_bool(key, value)?, _ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?, } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index f2bf2ec0d6571..2818018cbc7cd 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -26,7 +26,7 @@ use proptest::{ test_runner::{TestCaseError, TestRunner}, }; use result::{assert_invariants, can_continue}; -use revm::{primitives::HashMap, DatabaseCommit}; +use revm::primitives::HashMap; use shrink::shrink_sequence; use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; @@ -211,16 +211,10 @@ impl<'a> InvariantExecutor<'a> { while current_run < self.config.depth { let (sender, (address, calldata)) = inputs.last().expect("no input generated"); - // Executes the call from the randomly generated sequence. - let call_result = if self.config.preserve_state { - executor - .call_raw_committing(*sender, *address, calldata.clone(), U256::ZERO) - .expect("could not make raw evm call") - } else { - executor - .call_raw(*sender, *address, calldata.clone(), U256::ZERO) - .expect("could not make raw evm call") - }; + // Execute call from the randomly generated sequence and commit state changes. + let call_result = executor + .call_raw_committing(*sender, *address, calldata.clone(), U256::ZERO) + .expect("could not make raw evm call"); if call_result.result.as_ref() == MAGIC_ASSUME { inputs.pop(); @@ -252,8 +246,6 @@ impl<'a> InvariantExecutor<'a> { warn!(target: "forge::test", "{error}"); } } - // Commit changes to the database. - executor.backend.commit(state_changeset.clone()); fuzz_runs.push(FuzzCase { calldata: calldata.clone(), diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 3483708f2c37f..889000ad52f4f 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -81,7 +81,7 @@ fn lil_web3() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn snekmate() { - ExtTester::new("pcaversaccio", "snekmate", "ed49a0454393673cdf9a4250dd7051c28e6ac35f") + ExtTester::new("pcaversaccio", "snekmate", "1aa50098720d49e04b257a4aa5138b3d737a0667") .install_command(&["pnpm", "install", "--prefer-offline"]) // Try npm if pnpm fails / is not installed. .install_command(&["npm", "install", "--prefer-offline"]) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index e906c83569b94..90bc4c9c590e7 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -418,21 +418,8 @@ async fn test_shrink_fail_on_revert() { async fn test_invariant_preserve_state() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); - // Should not fail with default options. runner.test_options.invariant.fail_on_revert = true; let results = runner.test_collect(&filter); - assert_multiple( - &results, - BTreeMap::from([( - "default/fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", - vec![("invariant_preserve_state()", true, None, None, None)], - )]), - ); - - // same test should revert when preserve state enabled - runner.test_options.invariant.fail_on_revert = true; - runner.test_options.invariant.preserve_state = true; - let results = runner.test_collect(&filter); assert_multiple( &results, BTreeMap::from([( diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 27f5749904ffd..cf3d5757dbefd 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -106,7 +106,6 @@ impl ForgeTestProfile { }, shrink_sequence: true, shrink_run_limit: 2usize.pow(18u32), - preserve_state: false, max_assume_rejects: 65536, gas_report_samples: 256, }) From 6da2ff4cf221feab427260f87aa8ca48f8c5460e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 7 May 2024 07:45:39 +0300 Subject: [PATCH 0948/1963] chore(invariant): remove shrink_sequence config (#7875) --- crates/config/README.md | 1 - crates/config/src/invariant.rs | 5 ----- crates/config/src/lib.rs | 1 - crates/evm/evm/src/executors/invariant/error.rs | 3 --- crates/evm/evm/src/executors/invariant/mod.rs | 4 ---- crates/evm/evm/src/executors/invariant/replay.rs | 7 +------ crates/evm/evm/src/executors/invariant/shrink.rs | 2 +- crates/forge/tests/it/test_helpers.rs | 1 - testdata/foundry.toml | 1 - 9 files changed, 2 insertions(+), 23 deletions(-) diff --git a/crates/config/README.md b/crates/config/README.md index 105aaffc6e776..04fd53bb6ea78 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -195,7 +195,6 @@ call_override = false dictionary_weight = 80 include_storage = true include_push_bytes = true -shrink_sequence = true [fmt] line_length = 100 diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 0442d467b77ce..fa9e5489f79d5 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -24,9 +24,6 @@ pub struct InvariantConfig { /// The fuzz dictionary configuration #[serde(flatten)] pub dictionary: FuzzDictionaryConfig, - /// Attempt to shrink the failure case to its smallest sequence of calls - /// TODO: remove this setting as it is now redundant with shrink_run_limit = 0 - pub shrink_sequence: bool, /// The maximum number of attempts to shrink the sequence pub shrink_run_limit: usize, /// The maximum number of rejects via `vm.assume` which can be encountered during a single @@ -44,7 +41,6 @@ impl Default for InvariantConfig { fail_on_revert: false, call_override: false, dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() }, - shrink_sequence: true, shrink_run_limit: 2usize.pow(18_u32), max_assume_rejects: 65536, gas_report_samples: 256, @@ -75,7 +71,6 @@ impl InlineConfigParser for InvariantConfig { "depth" => conf_clone.depth = parse_config_u32(key, value)?, "fail-on-revert" => conf_clone.fail_on_revert = parse_config_bool(key, value)?, "call-override" => conf_clone.call_override = parse_config_bool(key, value)?, - "shrink-sequence" => conf_clone.shrink_sequence = parse_config_bool(key, value)?, _ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?, } } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 8b65bfa7813f1..96cd23a63fddf 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -3714,7 +3714,6 @@ mod tests { depth = 15 fail_on_revert = false call_override = false - shrink_sequence = true "#, )?; diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index e797174a53532..6e8dc929b58c2 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -63,8 +63,6 @@ pub struct FailedInvariantCaseData { pub func: Bytes, /// Inner fuzzing Sequence coming from overriding calls. pub inner_sequence: Vec>, - /// Shrink the failed test case to the smallest sequence. - pub shrink_sequence: bool, /// Shrink run limit pub shrink_run_limit: usize, /// Fail on revert, used to check sequence when shrinking. @@ -103,7 +101,6 @@ impl FailedInvariantCaseData { addr: invariant_contract.address, func: func.selector().to_vec().into(), inner_sequence: inner_sequence.to_vec(), - shrink_sequence: invariant_config.shrink_sequence, shrink_run_limit: invariant_config.shrink_run_limit, fail_on_revert: invariant_config.fail_on_revert, } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 2818018cbc7cd..a15f98f8bd60d 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -144,10 +144,6 @@ impl<'a> InvariantExecutor<'a> { return Err(eyre!("Invariant test function should have no inputs")) } - if !self.config.shrink_sequence { - error!(target: "forge::test", "shrink_sequence config is deprecated and will be removed, use shrink_run_limit = 0") - } - let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract, fuzz_fixtures)?; diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 941df781aacf8..e555811745dc6 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -100,12 +100,7 @@ pub fn replay_error( TestError::Abort(_) => Ok(None), TestError::Fail(_, ref calls) => { // Shrink sequence of failed calls. - let calls = if failed_case.shrink_sequence { - shrink_sequence(failed_case, calls, &executor)? - } else { - trace!(target: "forge::test", "Shrinking disabled."); - calls.clone() - }; + let calls = shrink_sequence(failed_case, calls, &executor)?; set_up_inner_replay(&mut executor, &failed_case.inner_sequence); // Replay calls to get the counterexample and to collect logs, traces and coverage. diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index bfa592136eafe..7b78ae028bf51 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -84,7 +84,7 @@ pub(crate) fn shrink_sequence( calls: &[BasicTxDetails], executor: &Executor, ) -> eyre::Result> { - trace!(target: "forge::test", "Shrinking."); + trace!(target: "forge::test", "Shrinking sequence of {} calls.", calls.len()); // Special case test: the invariant is *unsatisfiable* - it took 0 calls to // break the invariant -- consider emitting a warning. diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index cf3d5757dbefd..be87b9ce9348a 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -104,7 +104,6 @@ impl ForgeTestProfile { max_fuzz_dictionary_addresses: 10_000, max_fuzz_dictionary_values: 10_000, }, - shrink_sequence: true, shrink_run_limit: 2usize.pow(18u32), max_assume_rejects: 65536, gas_report_samples: 256, diff --git a/testdata/foundry.toml b/testdata/foundry.toml index 22df7b3e586a5..1fd8c610f730d 100644 --- a/testdata/foundry.toml +++ b/testdata/foundry.toml @@ -16,7 +16,6 @@ ffi = false force = false invariant_fail_on_revert = false invariant_call_override = false -invariant_shrink_sequence = true invariant_preserve_state = false gas_limit = 9223372036854775807 gas_price = 0 From 0ed87260285ed9520a3634f1cb8dea12531717c0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 7 May 2024 09:55:31 +0200 Subject: [PATCH 0949/1963] test(anvil): fix remaining TODOs/ignores, remove compiler dependency (#7877) --- Cargo.lock | 1 - crates/anvil/Cargo.toml | 1 - crates/anvil/core/src/eth/transaction/mod.rs | 12 +- crates/anvil/src/lib.rs | 5 +- crates/anvil/tests/it/abi.rs | 25 +- crates/anvil/tests/it/eip4844.rs | 14 +- crates/anvil/tests/it/ganache.rs | 225 ------- crates/anvil/tests/it/geth.rs | 103 ---- crates/anvil/tests/it/main.rs | 2 - crates/anvil/tests/it/optimism.rs | 14 +- crates/anvil/tests/it/otterscan.rs | 588 ++++++------------- crates/anvil/tests/it/pubsub.rs | 2 - crates/anvil/tests/it/revert.rs | 309 +++------- crates/anvil/tests/it/traces.rs | 1 - crates/anvil/tests/it/transaction.rs | 22 +- crates/anvil/tests/it/utils.rs | 1 + crates/cheatcodes/src/fs.rs | 6 +- crates/common/src/provider/mod.rs | 24 +- testdata/default/cheats/UnixTime.t.sol | 5 +- 19 files changed, 322 insertions(+), 1038 deletions(-) delete mode 100644 crates/anvil/tests/it/ganache.rs delete mode 100644 crates/anvil/tests/it/geth.rs diff --git a/Cargo.lock b/Cargo.lock index c6060c8b0ee32..55b297812695b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,7 +729,6 @@ dependencies = [ "flate2", "foundry-cli", "foundry-common", - "foundry-compilers", "foundry-config", "foundry-evm", "foundry-test-utils", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 7ab515768af58..9ca41a520de5e 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -91,7 +91,6 @@ tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] alloy-json-abi.workspace = true -foundry-compilers = { workspace = true, features = ["project-util", "full"] } alloy-rpc-client = { workspace = true, features = ["pubsub"] } alloy-transport-ipc = { workspace = true, features = ["mock"] } alloy-transport-ws.workspace = true diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index d29125cdc0f43..7e2fc71dade24 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -9,8 +9,8 @@ use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ - request::TransactionRequest, AccessList, AnyTransactionReceipt, Signature as RpcSignature, - Transaction as RpcTransaction, TransactionReceipt, WithOtherFields, + other::OtherFields, request::TransactionRequest, AccessList, AnyTransactionReceipt, + Signature as RpcSignature, Transaction as RpcTransaction, TransactionReceipt, WithOtherFields, }; use bytes::BufMut; use foundry_evm::traces::CallTraceNode; @@ -58,7 +58,7 @@ pub fn transaction_request_to_typed( } = tx; // Special case: OP-stack deposit tx - if transaction_type == Some(126) { + if transaction_type == Some(0x7E) || has_optimism_fields(&other) { return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { from: from.unwrap_or_default(), source_hash: other.get_deserialized::("sourceHash")?.ok()?, @@ -153,6 +153,12 @@ pub fn transaction_request_to_typed( } } +fn has_optimism_fields(other: &OtherFields) -> bool { + other.contains_key("sourceHash") && + other.contains_key("mint") && + other.contains_key("isSystemTx") +} + #[derive(Clone, Debug, PartialEq, Eq)] pub enum TypedTransactionRequest { Legacy(TxLegacy), diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 2cb39a8931535..8fbb130f23d8f 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -310,10 +310,7 @@ impl NodeHandle { /// Constructs a [`RetryProvider`] for this handle's HTTP endpoint. pub fn http_provider(&self) -> RetryProvider { - ProviderBuilder::new(&self.http_endpoint()) - .aggressive() - .build() - .expect("failed to build HTTP provider") + ProviderBuilder::new(&self.http_endpoint()).build().expect("failed to build HTTP provider") } /// Constructs a [`RetryProvider`] for this handle's WS endpoint. diff --git a/crates/anvil/tests/it/abi.rs b/crates/anvil/tests/it/abi.rs index fda13dc46327d..3356b02f10e40 100644 --- a/crates/anvil/tests/it/abi.rs +++ b/crates/anvil/tests/it/abi.rs @@ -49,22 +49,25 @@ sol!( } ); -// -pub(crate) const VENDING_MACHINE_CONTRACT: &str = r#"// SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.13; +// https://docs.soliditylang.org/en/latest/control-structures.html#revert +sol!( +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.4; +#[sol(rpc, bytecode = "6080806040523460155761011e908161001a8239f35b5f80fdfe60808060405260043610156011575f80fd5b5f3560e01c9081633ccfd60b146094575063d96a094a14602f575f80fd5b6020366003190112609057671bc16d674ec80000340460043511604e57005b60405162461bcd60e51b815260206004820152601a6024820152792737ba1032b737bab3b41022ba3432b910383937bb34b232b21760311b6044820152606490fd5b5f80fd5b346090575f3660031901126090575f546001600160a01b0316330360da575f8080804781811560d2575b3390f11560c757005b6040513d5f823e3d90fd5b506108fc60be565b6282b42960e81b8152600490fdfea2646970667358221220c143fcbf0da5cee61ae3fcc385d9f7c4d6a7fb2ea42530d70d6049478db0b8a964736f6c63430008190033")] contract VendingMachine { address owner; error Unauthorized(); - function buyRevert(uint amount) public payable { + #[derive(Debug)] + function buy(uint amount) public payable { if (amount > msg.value / 2 ether) revert("Not enough Ether provided."); - } - function buyRequire(uint amount) public payable { + // Alternative way to do it: require( amount <= msg.value / 2 ether, "Not enough Ether provided." ); + // Perform the purchase. } function withdraw() public { if (msg.sender != owner) @@ -72,13 +75,5 @@ contract VendingMachine { payable(msg.sender).transfer(address(this).balance); } -}"#; - -sol!( - #[sol(rpc)] - contract VendingMachine { - function buyRevert(uint amount) external payable; - function buyRequire(uint amount) external payable; - function withdraw() external; - } +} ); diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 180bcf17864ba..c9ab2943c5f9c 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -9,7 +9,7 @@ use anvil::{spawn, Hardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] async fn can_send_eip4844_transaction() { - let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); let (_api, handle) = spawn(node_config).await; let wallets = handle.dev_wallets().collect::>(); @@ -45,7 +45,7 @@ async fn can_send_eip4844_transaction() { #[tokio::test(flavor = "multi_thread")] async fn can_send_multiple_blobs_in_one_tx() { - let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); let (_api, handle) = spawn(node_config).await; let wallets = handle.dev_wallets().collect::>(); @@ -83,7 +83,7 @@ async fn can_send_multiple_blobs_in_one_tx() { #[tokio::test(flavor = "multi_thread")] async fn cannot_exceed_six_blobs() { - let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); let (_api, handle) = spawn(node_config).await; let wallets = handle.dev_wallets().collect::>(); @@ -120,7 +120,7 @@ async fn cannot_exceed_six_blobs() { #[tokio::test(flavor = "multi_thread")] async fn can_mine_blobs_when_exceeds_max_blobs() { - let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); let (api, handle) = spawn(node_config).await; api.anvil_set_auto_mine(false).await.unwrap(); @@ -187,13 +187,13 @@ async fn can_mine_blobs_when_exceeds_max_blobs() { second_block.unwrap().unwrap().header.blob_gas_used, Some(DATA_GAS_PER_BLOB as u128 * num_blobs_second as u128) ); - assert_eq!(first_receipt.block_number.unwrap() + 1, second_receipt.block_number.unwrap()); // Mined in two - // different blocks + // Mined in two different blocks + assert_eq!(first_receipt.block_number.unwrap() + 1, second_receipt.block_number.unwrap()); } #[tokio::test(flavor = "multi_thread")] async fn can_check_blob_fields_on_genesis() { - let node_config = NodeConfig::default().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); let (_api, handle) = spawn(node_config).await; let provider = http_provider(&handle.http_endpoint()); diff --git a/crates/anvil/tests/it/ganache.rs b/crates/anvil/tests/it/ganache.rs deleted file mode 100644 index f86aa7cf8e3f2..0000000000000 --- a/crates/anvil/tests/it/ganache.rs +++ /dev/null @@ -1,225 +0,0 @@ -//! tests against local ganache for local debug purposes -#![allow(unused)] -use crate::{ - abi::Greeter, - init_tracing, - utils::{http_provider, http_provider_with_signer, ws_provider_with_signer}, -}; -use alloy_contract::ContractInstance; -use alloy_network::EthereumSigner; -use alloy_primitives::{address, Address, TxKind}; -use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; -use alloy_signer_wallet::{LocalWallet, MnemonicBuilder}; -use alloy_sol_types::{sol, Revert}; -use foundry_compilers::{project_util::TempProject, Artifact}; -use std::{str::FromStr, sync::Arc}; - -// the mnemonic used to start the local ganache instance -const MNEMONIC: &str = - "amazing discover palace once resource choice flush horn wink shift planet relief"; - -fn ganache_wallet() -> LocalWallet { - LocalWallet::from_str("552dd2534c4984f892191997d6b1dd9e6a23c7e07b908a6cebfad1d3f2af4c4c") - .unwrap() -} - -fn ganache_wallet2() -> LocalWallet { - LocalWallet::from_str("305b526d493844b63466be6d48a424ab83f5216011eef860acc6db4c1821adc9") - .unwrap() -} - -fn wallet(key_str: &str) -> LocalWallet { - LocalWallet::from_str(key_str).unwrap() -} - -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_ganache_block_number() { - let provider = http_provider("http://127.0.0.1:8545"); - - let balance = provider.get_balance(Address::random(), BlockId::latest()).await; -} - -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_ganache_deploy() { - let signer: EthereumSigner = ganache_wallet().into(); - let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); - - let greeter_contract_builder = Greeter::deploy_builder(&provider, "Hello World!".to_string()); - let greeter_contract_address = greeter_contract_builder.deploy().await.unwrap(); - let greeter_contract = Greeter::new(greeter_contract_address, &provider); - - let Greeter::greetReturn { _0 } = greeter_contract.greet().call().await.unwrap(); - let greeting = _0; - assert_eq!("Hello World!", greeting); -} - -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_ganache_emit_logs() { - sol!( - #[sol(rpc)] - EmitLogs, - "test-data/emit_logs.json" - ); - - let signer: EthereumSigner = ganache_wallet().into(); - let provider = ws_provider_with_signer("ws://127.0.0.1:8545", signer); - - let first_msg = "First Message".to_string(); - let next_msg = "Next Message".to_string(); - let emit_logs_contract_builder = EmitLogs::deploy_builder(&provider, first_msg.clone()); - let emit_logs_contract_address = emit_logs_contract_builder.deploy().await.unwrap(); - let emit_logs_contract = EmitLogs::new(emit_logs_contract_address, &provider); - - let EmitLogs::getValueReturn { _0 } = emit_logs_contract.getValue().call().await.unwrap(); - let val = _0; - assert_eq!(val, first_msg); - - emit_logs_contract - .setValue(next_msg.clone()) - .send() - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - - let EmitLogs::getValueReturn { _0 } = emit_logs_contract.getValue().call().await.unwrap(); - let val = _0; - assert_eq!(val, next_msg); -} - -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_ganache_deploy_reverting() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - constructor() { - require(false, ""); - } -} -"#, - ) - .unwrap(); - - sol!( - #[sol(rpc)] - contract Contract {} - ); - - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - - let wallet = ganache_wallet(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); - - // should catch the revert during estimation which results in an err - let err = provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap_err(); - assert!(err.to_string().contains("execution reverted")); -} - -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_ganache_tx_reverting() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - address owner; - constructor() public { - owner = msg.sender; - } - modifier onlyOwner() { - require(msg.sender == owner, "!authorized"); - _; - } - function getSecret() public onlyOwner view returns(uint256 secret) { - return 123; - } -} -"#, - ) - .unwrap(); - - sol!( - #[sol(rpc)] - contract Contract { - function getSecret() public view returns (uint256); - } - ); - - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - - let wallet = ganache_wallet(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); - - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = Contract::new(contract_address, &provider); - - // should catch the revert during the call which results in an err - contract.getSecret().send().await.unwrap_err(); - - // /* Ganache rpc errors look like: - // < { - // < "id": 1627277502538, - // < "jsonrpc": "2.0", - // < "error": { - // < "message": "VM Exception while processing transaction: revert !authorized", - // < "code": -32000, - // < "data": { - // < "0x90264de254689f1d4e7f8670cd97f60d9bc803874fdecb34d249bd1cc3ca823a": { - // < "error": "revert", - // < "program_counter": 223, - // < "return": - // "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b21617574686f72697a6564000000000000000000000000000000000000000000" - // , < "reason": "!authorized" - // < }, - // < "stack": "c: VM Exception while processing transaction: revert !authorized\n at - // Function.c.fromResults - // (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:192416)\n at - // /usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:50402", < - // "name": "c" < } - // < } - // */ -} diff --git a/crates/anvil/tests/it/geth.rs b/crates/anvil/tests/it/geth.rs deleted file mode 100644 index 7879f4911f676..0000000000000 --- a/crates/anvil/tests/it/geth.rs +++ /dev/null @@ -1,103 +0,0 @@ -//! tests against local geth for local debug purposes - -use crate::{ - abi::{VendingMachine, VENDING_MACHINE_CONTRACT}, - utils::{http_provider, http_provider_with_signer}, -}; -use alloy_network::{EthereumSigner, TransactionBuilder}; -use alloy_primitives::{Address, TxKind, U256}; -use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; -use anvil::{spawn, NodeConfig}; -use foundry_compilers::{project_util::TempProject, Artifact}; -use futures::StreamExt; -use tokio::time::timeout; - -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_geth_pending_transaction() { - let provider = http_provider("http://127.0.0.1:8545"); - - let account = provider.get_accounts().await.unwrap().remove(0); - - let tx = TransactionRequest::default() - .with_from(account) - .with_to(Address::random()) - .with_value(U256::from(1337u64)) - .with_nonce(2u64); - let tx = WithOtherFields::new(tx); - - let mut watch_tx_stream = provider.watch_pending_transactions().await.unwrap().into_stream(); - - provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); - - let pending = timeout(std::time::Duration::from_secs(3), watch_tx_stream.next()).await; - pending.unwrap_err(); -} - -// check how geth returns reverts -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_geth_revert_transaction() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source("VendingMachine", VENDING_MACHINE_CONTRACT).unwrap(); - - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("VendingMachine").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - - let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer("http://127.0.0.1:8545", signer); - - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = VendingMachine::new(contract_address, &provider); - - let res = contract - .buyRevert(U256::from(100)) - .value(U256::from(1)) - .from(sender) - .send() - .await - .unwrap_err(); - let msg = res.to_string(); - assert!(msg.contains("execution reverted: revert: Not enough Ether provided.")); - assert!(msg.contains("code: 3")); -} - -#[tokio::test(flavor = "multi_thread")] -#[ignore] -async fn test_geth_low_gas_limit() { - let provider = http_provider("http://127.0.0.1:8545"); - - let account = provider.get_accounts().await.unwrap().remove(0); - - let gas_limit = 21_000u128 - 1; - let tx = TransactionRequest::default() - .from(account) - .to(Address::random()) - .value(U256::from(1337u64)) - .gas_limit(gas_limit); - let tx = WithOtherFields::new(tx); - - let resp = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await; - let err = resp.unwrap_err().to_string(); - assert!(err.contains("intrinsic gas too low")); -} diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 94b1bc492c317..5337e5bbd30b0 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -4,10 +4,8 @@ mod anvil_api; mod api; mod eip4844; mod fork; -mod ganache; mod gas; mod genesis; -mod geth; mod ipc; mod logs; mod optimism; diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 0a7801c4ed6dd..7b38a3e5c7bfc 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -8,19 +8,15 @@ use alloy_provider::Provider; use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest, WithOtherFields}; use anvil::{spawn, Hardfork, NodeConfig}; -// TODO: transaction is expected to fail, it does not, remove ignore once fixed #[tokio::test(flavor = "multi_thread")] -#[ignore] async fn test_deposits_not_supported_if_optimism_disabled() { let (_api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); - let signer: EthereumSigner = accounts[0].clone().into(); let from = accounts[0].address(); let to = accounts[1].address(); - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - let tx = TransactionRequest::default() .with_from(from) .with_to(to) @@ -38,11 +34,9 @@ async fn test_deposits_not_supported_if_optimism_disabled() { .into(), }; - let res = provider.send_transaction(tx).await.unwrap().register().await; - assert!(res - .unwrap_err() - .to_string() - .contains("op-stack deposit tx received but is not supported")); + let err = provider.send_transaction(tx).await.unwrap_err(); + let s = err.to_string(); + assert!(s.contains("op-stack deposit tx received but is not supported"), "{s:?}"); } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 07af1b8ead13e..f9fbd91235f33 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -1,79 +1,66 @@ -//! tests for otterscan endpoints -use crate::{ - abi::MulticallContract, - utils::{http_provider_with_signer, ws_provider_with_signer}, -}; -use alloy_network::EthereumSigner; -use alloy_primitives::{Address, Bytes, TxKind, U256}; +//! Tests for otterscan endpoints. + +use crate::abi::MulticallContract; +use alloy_primitives::{address, Address, Bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions, TransactionRequest, WithOtherFields}; -use alloy_sol_types::sol; +use alloy_sol_types::{sol, SolCall, SolError}; use anvil::{ eth::otterscan::types::{ OtsInternalOperation, OtsInternalOperationType, OtsTrace, OtsTraceType, }, spawn, NodeConfig, }; -use foundry_compilers::{project_util::TempProject, Artifact}; -use std::{collections::VecDeque, str::FromStr}; +use std::collections::VecDeque; #[tokio::test(flavor = "multi_thread")] -async fn can_call_erigon_get_header_by_number() { +async fn erigon_get_header_by_number() { let (api, _handle) = spawn(NodeConfig::test()).await; api.mine_one().await; let res0 = api.erigon_get_header_by_number(0.into()).await.unwrap().unwrap(); - let res1 = api.erigon_get_header_by_number(1.into()).await.unwrap().unwrap(); - assert_eq!(res0.header.number, Some(0)); + + let res1 = api.erigon_get_header_by_number(1.into()).await.unwrap().unwrap(); assert_eq!(res1.header.number, Some(1)); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_api_level() { +async fn ots_get_api_level() { let (api, _handle) = spawn(NodeConfig::test()).await; assert_eq!(api.ots_get_api_level().await.unwrap(), 8); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_internal_operations_contract_deploy() { +async fn ots_get_internal_operations_contract_deploy() { let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + let sender = handle.dev_accounts().next().unwrap(); - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - - let contract_receipt = MulticallContract::deploy_builder(provider.clone()) - .from(sender) + let contract_receipt = MulticallContract::deploy_builder(&provider) .send() .await .unwrap() .get_receipt() .await .unwrap(); - let contract_address = sender.create(0); let res = api.ots_get_internal_operations(contract_receipt.transaction_hash).await.unwrap(); - - assert_eq!(res.len(), 1); assert_eq!( - res[0], - OtsInternalOperation { + res, + [OtsInternalOperation { r#type: OtsInternalOperationType::Create, from: sender, - to: contract_address, + to: contract_receipt.contract_address.unwrap(), value: U256::from(0) - } + }], ); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_internal_operations_contract_transfer() { +async fn ots_get_internal_operations_contract_transfer() { let (api, handle) = spawn(NodeConfig::test()).await; - let provider = handle.http_provider(); let accounts: Vec<_> = handle.dev_wallets().collect(); @@ -88,170 +75,88 @@ async fn can_call_ots_get_internal_operations_contract_transfer() { let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); - - assert_eq!(res.len(), 1); assert_eq!( - res[0], - OtsInternalOperation { + res, + [OtsInternalOperation { r#type: OtsInternalOperationType::Transfer, from, to, value: amount - } + }], ); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_internal_operations_contract_create2() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r" -pragma solidity 0.8.13; -contract Contract { - address constant CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; - constructor() {} - function deployContract() public { - uint256 salt = 0; - uint256 code = 0; - bytes memory creationCode = abi.encodePacked(code); - (bool success,) = address(CREATE2_DEPLOYER).call(abi.encodePacked(salt, creationCode)); - require(success); - } -} -", - ) - .unwrap(); - +async fn ots_get_internal_operations_contract_create2() { sol!( - #[sol(rpc)] + #[sol(rpc, bytecode = "60808060405234601557610147908161001a8239f35b5f80fdfe6080600436101561000e575f80fd5b5f3560e01c636cd5c39b14610021575f80fd5b346100d0575f3660031901126100d0575f602082810191825282526001600160401b03916040810191838311828410176100d4578261008960405f959486958252606081019486865281518091608084015e81018660808201520360208101845201826100ee565b519082734e59b44847b379578588920ca78fbf26c0b4956c5af1903d156100e8573d9081116100d4576040516100c991601f01601f1916602001906100ee565b156100d057005b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b506100c9565b601f909101601f19168101906001600160401b038211908210176100d45760405256fea2646970667358221220f76968e121fc002b537029df51a2aecca0793282491baf84b872ffbfbfb1c9d764736f6c63430008190033")] contract Contract { - function deployContract() external; + address constant CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + + function deployContract() public { + uint256 salt = 0; + uint256 code = 0; + bytes memory creationCode = abi.encodePacked(code); + (bool success,) = address(CREATE2_DEPLOYER).call(abi.encodePacked(salt, creationCode)); + require(success); + } } ); - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = Contract::new(contract_address, &provider); + let provider = handle.http_provider(); + + let contract = Contract::deploy(&provider).await.unwrap(); + let receipt = contract.deployContract().send().await.unwrap().get_receipt().await.unwrap(); let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); - - assert_eq!(res.len(), 1); assert_eq!( - res[0], - OtsInternalOperation { + res, + [OtsInternalOperation { r#type: OtsInternalOperationType::Create2, - from: Address::from_str("0x4e59b44847b379578588920cA78FbF26c0B4956C").unwrap(), - to: Address::from_str("0x347bcdad821abc09b8c275881b368de36476b62c").unwrap(), - value: U256::from(0) - } + from: address!("4e59b44847b379578588920cA78FbF26c0B4956C"), + to: address!("347bcdad821abc09b8c275881b368de36476b62c"), + value: U256::from(0), + }], ); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_internal_operations_contract_selfdestruct() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r" -pragma solidity 0.8.13; -contract Contract { - address payable private owner; - constructor() public { - owner = payable(msg.sender); - } - function goodbye() public { - selfdestruct(owner); - } -} -", - ) - .unwrap(); - +async fn ots_get_internal_operations_contract_selfdestruct() { sol!( - #[sol(rpc)] + #[sol(rpc, bytecode = "60808060405234601357607c908160188239f35b5f80fdfe6004361015600b575f80fd5b5f3560e01c6375fc8e3c14601d575f80fd5b346042575f36600319011260425773dcdd539da22bffaa499dbea4d37d086dde196e75ff5b5f80fdfea26469706673582212201778e88721238015f480b3a901848b460799e91836caf557a8dcfdb2a1a2469e64736f6c63430008190033")] contract Contract { - function goodbye() external; + function goodbye() public { + selfdestruct(payable(0xDcDD539DA22bfFAa499dBEa4d37d086Dde196E75)); + } } ); - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = Contract::new(contract_address, &provider); + let provider = handle.http_provider(); + + let contract = Contract::deploy(&provider).await.unwrap(); let receipt = contract.goodbye().send().await.unwrap().get_receipt().await.unwrap(); let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); - - assert_eq!(res.len(), 1); assert_eq!( - res[0], - OtsInternalOperation { + res, + [OtsInternalOperation { r#type: OtsInternalOperationType::SelfDestruct, from: *contract.address(), - to: Default::default(), - value: U256::from(0) - } + to: Address::ZERO, + value: U256::from(0), + }], ); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_has_code() { +async fn ots_has_code() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + let provider = handle.http_provider(); + let sender = handle.dev_accounts().next().unwrap(); api.mine_one().await; @@ -260,7 +165,7 @@ async fn can_call_ots_has_code() { // no code in the address before deploying assert!(!api.ots_has_code(contract_address, BlockNumberOrTag::Number(1)).await.unwrap()); - let contract_builder = MulticallContract::deploy_builder(provider.clone()); + let contract_builder = MulticallContract::deploy_builder(&provider); let contract_receipt = contract_builder.send().await.unwrap().get_receipt().await.unwrap(); let num = provider.get_block_number().await.unwrap(); @@ -274,253 +179,152 @@ async fn can_call_ots_has_code() { } #[tokio::test(flavor = "multi_thread")] -async fn test_call_call_ots_trace_transaction() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - address payable private owner; - constructor() public { - owner = payable(msg.sender); - } - function run() payable public { - this.do_staticcall(); - this.do_call(); - } +async fn test_call_ots_trace_transaction() { + sol!( + #[sol(rpc, bytecode = "608080604052346026575f80546001600160a01b0319163317905561025e908161002b8239f35b5f80fdfe6080604081815260049081361015610015575f80fd5b5f925f3560e01c9081636a6758fe1461019a5750806396385e3914610123578063a1325397146101115763c04062261461004d575f80fd5b5f3660031901126100d5578051633533ac7f60e11b81526020818481305afa80156100cb576100d9575b50303b156100d55780516396385e3960e01b8152915f83828183305af180156100cb576100a2578380f35b919250906001600160401b0383116100b8575052005b604190634e487b7160e01b5f525260245ffd5b82513d5f823e3d90fd5b5f80fd5b6020813d602011610109575b816100f2602093836101b3565b810103126100d55751801515036100d5575f610077565b3d91506100e5565b346100d5575f3660031901126100d557005b5090346100d5575f3660031901126100d5575f805481908190819047906001600160a01b03165af1506101546101ea565b50815163a132539760e01b6020820190815282825292909182820191906001600160401b038311848410176100b8575f8086868686525190305af4506101986101ea565b005b346100d5575f3660031901126100d55780600160209252f35b601f909101601f19168101906001600160401b038211908210176101d657604052565b634e487b7160e01b5f52604160045260245ffd5b3d15610223573d906001600160401b0382116101d65760405191610218601f8201601f1916602001846101b3565b82523d5f602084013e565b60609056fea264697066735822122099817ea378044f1f6434272aeb1f3f01a734645e599e69b4caf2ba7a4fb65f9d64736f6c63430008190033")] + contract Contract { + address private owner; - function do_staticcall() external view returns (bool) { - return true; - } + constructor() { + owner = msg.sender; + } - function do_call() external { - owner.call{value: address(this).balance}(""); - address(this).delegatecall(abi.encodeWithSignature("do_delegatecall()")); - } - - function do_delegatecall() internal { - } -} -"#, - ) - .unwrap(); + function run() payable public { + this.do_staticcall(); + this.do_call(); + } - sol!( - #[sol(rpc)] - contract Contract { - function run() external payable; - function do_staticcall() external view returns (bool); - function do_call() external; - function do_delegatecall() external; + function do_staticcall() external view returns (bool) { + return true; + } + + function do_call() external { + owner.call{value: address(this).balance}(""); + address(this).delegatecall(abi.encodeWithSignature("do_delegatecall()")); + } + + function do_delegatecall() external {} } ); - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); let wallets = handle.dev_wallets().collect::>(); - let signer: EthereumSigner = wallets[0].clone().into(); let sender = wallets[0].address(); - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); + let contract_address = Contract::deploy_builder(&provider).from(sender).deploy().await.unwrap(); let contract = Contract::new(contract_address, &provider); - let receipt = contract - .run() - .from(sender) - .value(U256::from(1337)) - .send() - .await - .unwrap() - .get_receipt() - .await - .unwrap(); + let receipt = + contract.run().value(U256::from(1337)).send().await.unwrap().get_receipt().await.unwrap(); let res = api.ots_trace_transaction(receipt.transaction_hash).await.unwrap(); - - assert_eq!( - res, - vec![ - OtsTrace { - r#type: OtsTraceType::Call, - depth: 0, - from: sender, - to: contract_address, - value: U256::from(1337), - input: Bytes::from_str("0xc0406226").unwrap().0.into() - }, - OtsTrace { - r#type: OtsTraceType::StaticCall, - depth: 1, - from: contract_address, - to: contract_address, - value: U256::ZERO, - input: Bytes::from_str("0x6a6758fe").unwrap().0.into() - }, - OtsTrace { - r#type: OtsTraceType::Call, - depth: 1, - from: contract_address, - to: contract_address, - value: U256::ZERO, - input: Bytes::from_str("0x96385e39").unwrap().0.into() - }, - OtsTrace { - r#type: OtsTraceType::Call, - depth: 2, - from: contract_address, - to: sender, - value: U256::from(1337), - input: Bytes::from_str("0x").unwrap().0.into() - }, - OtsTrace { - r#type: OtsTraceType::DelegateCall, - depth: 2, - from: contract_address, - to: contract_address, - value: U256::ZERO, - input: Bytes::from_str("0xa1325397").unwrap().0.into() - }, - ] - ); + let expected = vec![ + OtsTrace { + r#type: OtsTraceType::Call, + depth: 0, + from: sender, + to: contract_address, + value: U256::from(1337), + input: Contract::runCall::SELECTOR.into(), + }, + OtsTrace { + r#type: OtsTraceType::StaticCall, + depth: 1, + from: contract_address, + to: contract_address, + value: U256::ZERO, + input: Contract::do_staticcallCall::SELECTOR.into(), + }, + OtsTrace { + r#type: OtsTraceType::Call, + depth: 1, + from: contract_address, + to: contract_address, + value: U256::ZERO, + input: Contract::do_callCall::SELECTOR.into(), + }, + OtsTrace { + r#type: OtsTraceType::Call, + depth: 2, + from: contract_address, + to: sender, + value: U256::from(1337), + input: Bytes::new(), + }, + OtsTrace { + r#type: OtsTraceType::DelegateCall, + depth: 2, + from: contract_address, + to: contract_address, + value: U256::ZERO, + input: Contract::do_delegatecallCall::SELECTOR.into(), + }, + ]; + assert_eq!(res, expected); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_transaction_error() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - error CustomError(string msg); - - function trigger_revert() public { - revert CustomError("RevertStringFooBar"); - } -} -"#, - ) - .unwrap(); - +async fn ots_get_transaction_error() { sol!( - #[sol(rpc)] + #[sol(rpc, bytecode = "6080806040523460135760a3908160188239f35b5f80fdfe60808060405260043610156011575f80fd5b5f3560e01c63f67f4650146023575f80fd5b346069575f3660031901126069576346b7545f60e11b81526020600482015260126024820152712932bb32b93a29ba3934b733a337b7a130b960711b6044820152606490fd5b5f80fdfea264697066735822122069222918090d4d3ddc6a9c8b6ef282464076c71f923a0e8618ed25489b87f12b64736f6c63430008190033")] contract Contract { - function trigger_revert() external; + error CustomError(string msg); + + function trigger_revert() public { + revert CustomError("RevertStringFooBar"); + } } ); - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let wallets = handle.dev_wallets().collect::>(); - let signer: EthereumSigner = wallets[0].clone().into(); - let sender = wallets[0].address(); + let contract = Contract::deploy(&provider).await.unwrap(); - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); + let receipt = contract.trigger_revert().send().await.unwrap().get_receipt().await.unwrap(); - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let _contract = Contract::new(contract_address, &provider); - - // TODO: currently not possible to capture the receipt - // let receipt = contract.trigger_revert().send().await.unwrap().get_receipt().await.unwrap(); - - // let res = api.ots_get_transaction_error(receipt.transaction_hash).await; - // assert!(res.is_err()); - // assert!(res.unwrap_err().to_string().contains("0x8d6ea8be00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012526576657274537472696e67466f6f4261720000000000000000000000000000")); + let err = api.ots_get_transaction_error(receipt.transaction_hash).await.unwrap(); + let expected = Contract::CustomError { msg: String::from("RevertStringFooBar") }.abi_encode(); + assert_eq!(err, Bytes::from(expected)); } #[tokio::test(flavor = "multi_thread")] async fn ots_get_transaction_error_no_error() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallets = handle.dev_wallets().collect::>(); - let signer: EthereumSigner = wallets[0].clone().into(); - let sender = wallets[0].address(); - - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); + let provider = handle.http_provider(); // Send a successful transaction - let tx = - TransactionRequest::default().from(sender).to(Address::random()).value(U256::from(100)); + let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100)); let tx = WithOtherFields::new(tx); let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let res = api.ots_get_transaction_error(receipt.transaction_hash).await; - assert!(res.is_ok()); - assert_eq!(res.unwrap().to_string(), "0x"); + let res = api.ots_get_transaction_error(receipt.transaction_hash).await.unwrap(); + assert!(res.is_empty(), "{res}"); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_block_details() { +async fn ots_get_block_details() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + let provider = handle.http_provider(); - let tx = - TransactionRequest::default().from(sender).to(Address::random()).value(U256::from(100)); + let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100)); let tx = WithOtherFields::new(tx); let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let result = api.ots_get_block_details(1.into()).await.unwrap(); assert_eq!(result.block.transaction_count, 1); - let hash = match result.block.block.transactions { - BlockTransactions::Full(txs) => txs[0].hash, - BlockTransactions::Hashes(hashes) => hashes[0], - BlockTransactions::Uncle => unreachable!(), - }; - assert_eq!(hash, receipt.transaction_hash); + let hash = result.block.block.transactions.hashes().next().unwrap(); + assert_eq!(*hash, receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_block_details_by_hash() { +async fn ots_get_block_details_by_hash() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + let provider = handle.http_provider(); - let tx = - TransactionRequest::default().from(sender).to(Address::random()).value(U256::from(100)); + let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100)); let tx = WithOtherFields::new(tx); let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); @@ -537,24 +341,17 @@ async fn can_call_ots_get_block_details_by_hash() { } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_block_transactions() { +async fn ots_get_block_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + let provider = handle.http_provider(); // disable automine api.anvil_set_auto_mine(false).await.unwrap(); let mut hashes = VecDeque::new(); for i in 0..10 { - let tx = TransactionRequest::default() - .from(sender) - .to(Address::random()) - .value(U256::from(100)) - .nonce(i); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(100)).nonce(i); let tx = WithOtherFields::new(tx); let pending_receipt = provider.send_transaction(tx).await.unwrap().register().await.unwrap(); @@ -583,22 +380,16 @@ async fn can_call_ots_get_block_transactions() { } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_search_transactions_before() { +async fn ots_search_transactions_before() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + let provider = handle.http_provider(); + let sender = handle.dev_accounts().next().unwrap(); let mut hashes = vec![]; for i in 0..7 { - let tx = TransactionRequest::default() - .from(sender) - .to(Address::random()) - .value(U256::from(100)) - .nonce(i); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(100)).nonce(i); let tx = WithOtherFields::new(tx); let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); hashes.push(receipt.transaction_hash); @@ -624,22 +415,16 @@ async fn can_call_ots_search_transactions_before() { } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_search_transactions_after() { +async fn ots_search_transactions_after() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + let provider = handle.http_provider(); + let sender = handle.dev_accounts().next().unwrap(); let mut hashes = VecDeque::new(); for i in 0..7 { - let tx = TransactionRequest::default() - .from(sender) - .to(Address::random()) - .value(U256::from(100)) - .nonce(i); + let tx = + TransactionRequest::default().to(Address::random()).value(U256::from(100)).nonce(i); let tx = WithOtherFields::new(tx); let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); hashes.push_front(receipt.transaction_hash); @@ -665,15 +450,10 @@ async fn can_call_ots_search_transactions_after() { } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_transaction_by_sender_and_nonce() { +async fn ots_get_transaction_by_sender_and_nonce() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - - api.mine_one().await; + let provider = handle.http_provider(); + let sender = handle.dev_accounts().next().unwrap(); let tx1 = WithOtherFields::new( TransactionRequest::default() @@ -703,22 +483,22 @@ async fn can_call_ots_get_transaction_by_sender_and_nonce() { } #[tokio::test(flavor = "multi_thread")] -async fn can_call_ots_get_contract_creator() { +async fn ots_get_contract_creator() { let (api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = http_provider_with_signer(&handle.http_endpoint(), signer); - - api.mine_one().await; + let provider = handle.http_provider(); + let sender = handle.dev_accounts().next().unwrap(); - let contract_builder = MulticallContract::deploy_builder(provider.clone()); - let contract_receipt = contract_builder.send().await.unwrap().get_receipt().await.unwrap(); - let contract_address = sender.create(0); + let receipt = MulticallContract::deploy_builder(&provider) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + let contract_address = receipt.contract_address.unwrap(); let creator = api.ots_get_contract_creator(contract_address).await.unwrap().unwrap(); assert_eq!(creator.creator, sender); - assert_eq!(creator.hash, contract_receipt.transaction_hash); + assert_eq!(creator.hash, receipt.transaction_hash); } diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index f29dbb81f2117..d11208feb0616 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -246,8 +246,6 @@ async fn test_subscriptions() { assert_eq!(blocks, vec![1, 2, 3]) } -// TODO: Fix this, num > 17 breaks the test due to poller channel_size defaults to 16. Recv channel -// lags behind. #[tokio::test(flavor = "multi_thread")] async fn test_sub_new_heads_fast() { let (api, handle) = spawn(NodeConfig::test()).await; diff --git a/crates/anvil/tests/it/revert.rs b/crates/anvil/tests/it/revert.rs index 5cb9b2fedc81a..051f6be669a57 100644 --- a/crates/anvil/tests/it/revert.rs +++ b/crates/anvil/tests/it/revert.rs @@ -1,290 +1,125 @@ -use crate::{ - abi::{VendingMachine, VENDING_MACHINE_CONTRACT}, - utils::ws_provider_with_signer, -}; -use alloy_network::EthereumSigner; -use alloy_primitives::{TxKind, U256}; +use crate::abi::VendingMachine; +use alloy_network::TransactionBuilder; +use alloy_primitives::{bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use alloy_sol_types::sol; use anvil::{spawn, NodeConfig}; -use foundry_compilers::{project_util::TempProject, Artifact}; #[tokio::test(flavor = "multi_thread")] async fn test_deploy_reverting() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - constructor() { - require(false, ""); - } -} -"#, - ) - .unwrap(); - - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); - - // should catch the revert during estimation which results in an err - let err = provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap_err(); - assert!(err.to_string().contains("execution reverted")); + let provider = handle.http_provider(); + let sender = handle.dev_accounts().next().unwrap(); + + let code = bytes!("5f5ffd"); // PUSH0 PUSH0 REVERT + let tx = TransactionRequest::default().from(sender).with_deploy_code(code); + let tx = WithOtherFields::new(tx); + + // Calling/estimating gas fails early. + let err = provider.call(&tx).await.unwrap_err(); + let s = err.to_string(); + assert!(s.contains("execution reverted"), "{s:?}"); + + // Sending the transaction is successful but reverts on chain. + let tx = provider.send_transaction(tx).await.unwrap(); + let receipt = tx.get_receipt().await.unwrap(); + assert!(!receipt.inner.inner.status()); } #[tokio::test(flavor = "multi_thread")] async fn test_revert_messages() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - address owner; - constructor() public { - owner = address(1); - } - modifier onlyOwner() { - require(msg.sender == owner, "!authorized"); - _; - } - function getSecret() public onlyOwner view returns(uint256 secret) { - return 123; - } -} -"#, - ) - .unwrap(); - sol!( - #[sol(rpc)] + #[sol(rpc, bytecode = "608080604052346025575f80546001600160a01b031916600117905560b69081602a8239f35b5f80fdfe60808060405260043610156011575f80fd5b5f3560e01c635b9fdc30146023575f80fd5b34607c575f366003190112607c575f546001600160a01b03163303604c576020604051607b8152f35b62461bcd60e51b815260206004820152600b60248201526a08585d5d1a1bdc9a5e995960aa1b6044820152606490fd5b5f80fdfea2646970667358221220f593e5ccd46935f623185de62a72d9f1492d8d15075a111b0fa4d7e16acf4a7064736f6c63430008190033")] contract Contract { - function getSecret() external; - } - ); + address private owner; - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); + constructor() { + owner = address(1); + } - let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); + modifier onlyOwner() { + require(msg.sender == owner, "!authorized"); + _; + } - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); + #[derive(Debug)] + function getSecret() public onlyOwner view returns(uint256 secret) { + return 123; + } + } + ); - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = Contract::new(contract_address, &provider); + let (_api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); - let res = contract.getSecret().send().await.unwrap_err(); + let contract = Contract::deploy(&provider).await.unwrap(); - let msg = res.to_string(); - assert!(msg.contains("execution reverted: revert: !authorized")); + let err = contract.getSecret().call().await.unwrap_err(); + let s = err.to_string(); + assert!(s.contains("!authorized"), "{s:?}"); } #[tokio::test(flavor = "multi_thread")] async fn test_solc_revert_example() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source("VendingMachine", VENDING_MACHINE_CONTRACT).unwrap(); - - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("VendingMachine").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); + let sender = handle.dev_accounts().next().unwrap(); + let provider = handle.http_provider(); - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); + let contract = VendingMachine::deploy(&provider).await.unwrap(); - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = VendingMachine::new(contract_address, &provider); - - let res = contract - .buyRevert(U256::from(100)) - .value(U256::from(1)) - .from(sender) - .send() - .await - .unwrap_err(); - let msg = res.to_string(); - assert!(msg.contains("execution reverted: revert: Not enough Ether provided.")); - - let res = contract - .buyRequire(U256::from(100)) - .value(U256::from(1)) - .from(sender) - .send() - .await - .unwrap_err(); - let msg = res.to_string(); - assert!(msg.contains("execution reverted: revert: Not enough Ether provided.")); + let err = + contract.buy(U256::from(100)).value(U256::from(1)).from(sender).call().await.unwrap_err(); + let s = err.to_string(); + assert!(s.contains("Not enough Ether provided."), "{s:?}"); } // #[tokio::test(flavor = "multi_thread")] async fn test_another_revert_message() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - uint256 public number; - - function setNumber(uint256 num) public { - require(num != 0, "RevertStringFooBar"); - number = num; - } -} -"#, - ) - .unwrap(); - sol!( - #[sol(rpc)] + #[sol(rpc, bytecode = "6080806040523460135760d7908160188239f35b5f80fdfe60808060405260043610156011575f80fd5b5f3560e01c9081633fb5c1cb14604d5750638381f58a14602f575f80fd5b346049575f36600319011260495760205f54604051908152f35b5f80fd5b346049576020366003190112604957600435908115606a57505f55005b62461bcd60e51b81526020600482015260126024820152712932bb32b93a29ba3934b733a337b7a130b960711b6044820152606490fdfea2646970667358221220314bf8261cc467619137c071584f8d3bd8d9d97bf2846c138c0567040cf9828a64736f6c63430008190033")] contract Contract { - function setNumber(uint256 num) external; + uint256 public number; + + #[derive(Debug)] + function setNumber(uint256 num) public { + require(num != 0, "RevertStringFooBar"); + number = num; + } } ); - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); + let provider = handle.http_provider(); - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = Contract::new(contract_address, &provider); + let contract = Contract::deploy(&provider).await.unwrap(); - let res = contract.setNumber(U256::from(0)).send().await.unwrap_err(); - - let msg = res.to_string(); - assert!(msg.contains("execution reverted: revert: RevertStringFooBar")); + let err = contract.setNumber(U256::from(0)).call().await.unwrap_err(); + let s = err.to_string(); + assert!(s.contains("RevertStringFooBar"), "{s:?}"); } #[tokio::test(flavor = "multi_thread")] async fn test_solc_revert_custom_errors() { - let prj = TempProject::dapptools().unwrap(); - prj.add_source( - "Contract", - r#" -pragma solidity 0.8.13; -contract Contract { - uint256 public number; - error AddressRevert(address); - - function revertAddress() public { - revert AddressRevert(address(1)); - } -} -"#, - ) - .unwrap(); - sol!( - #[sol(rpc)] + #[sol(rpc, bytecode = "608080604052346013576081908160188239f35b5f80fdfe60808060405260043610156011575f80fd5b5f3560e01c63e57207e6146023575f80fd5b346047575f3660031901126047576373ea2a7f60e01b815260016004820152602490fd5b5f80fdfea26469706673582212202a8d69545801394af36c56ca229b52ae0b22d7b8f938b107dca8ebbf655464f764736f6c63430008190033")] contract Contract { - function revertAddress() external; + error AddressRevert(address); + + #[derive(Debug)] + function revertAddress() public { + revert AddressRevert(address(1)); + } } ); - let mut compiled = prj.compile().unwrap(); - assert!(!compiled.has_compiler_errors()); - let contract = compiled.remove_first("Contract").unwrap(); - let bytecode = contract.into_bytecode_bytes().unwrap(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); - let sender = wallet.address(); - - let provider = ws_provider_with_signer(&handle.ws_endpoint(), signer); + let provider = handle.http_provider(); - // deploy successfully - provider - .send_transaction(WithOtherFields::new(TransactionRequest { - from: Some(sender), - to: Some(TxKind::Create), - input: bytecode.into(), - ..Default::default() - })) - .await - .unwrap() - .get_receipt() - .await - .unwrap(); - let contract_address = sender.create(0); - let contract = Contract::new(contract_address, &provider); + let contract = Contract::deploy(&provider).await.unwrap(); - let res = contract.revertAddress().send().await.unwrap_err(); - assert!(res.to_string().contains("execution reverted")); + let err = contract.revertAddress().call().await.unwrap_err(); + let s = err.to_string(); + assert!(s.contains("execution reverted"), "{s:?}"); } diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index d12a848e47106..011e489bba492 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -66,7 +66,6 @@ async fn test_parity_suicide_trace() { let owner = wallets[0].address(); let destructor = wallets[1].address(); - // deploy successfully let contract_addr = SuicideContract::deploy_builder(provider.clone()).from(owner).deploy().await.unwrap(); let contract = SuicideContract::new(contract_addr, provider.clone()); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index d0dbc539c97c2..90ede1d73712d 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -1,6 +1,6 @@ use crate::{ abi::{Greeter, MulticallContract, SimpleStorage}, - utils::http_provider_with_signer, + utils::{connect_pubsub, http_provider_with_signer}, }; use alloy_network::{EthereumSigner, TransactionBuilder}; use alloy_primitives::{Address, Bytes, FixedBytes, U256}; @@ -837,9 +837,6 @@ async fn test_tx_receipt() { assert!(tx.contract_address.is_some()); } -// TODO: Fix error: ErrorPayload { code: -32602, message: "invalid type: boolean `true`, expected -// unit", data: None } originating from watch_full_pending_transactions, remove ignore -#[ignore] #[tokio::test(flavor = "multi_thread")] async fn can_stream_pending_transactions() { let (_api, handle) = @@ -847,7 +844,7 @@ async fn can_stream_pending_transactions() { let num_txs = 5; let provider = handle.http_provider(); - let ws_provider = handle.ws_provider(); + let ws_provider = connect_pubsub(&handle.ws_endpoint()).await; let accounts = provider.get_accounts().await.unwrap(); let tx = @@ -866,20 +863,20 @@ async fn can_stream_pending_transactions() { .fuse(); let mut watch_tx_stream = provider - .watch_full_pending_transactions() + .watch_pending_transactions() .await - .unwrap() // TODO: Fix error here + .unwrap() .into_stream() .flat_map(futures::stream::iter) .take(num_txs) .fuse(); let mut sub_tx_stream = ws_provider - .subscribe_full_pending_transactions() + .subscribe_pending_transactions() .await .unwrap() .into_stream() - .take(2) + .take(num_txs) .fuse(); let mut sent = None; @@ -901,14 +898,15 @@ async fn can_stream_pending_transactions() { sub_received.push(tx); } }, + complete => unreachable!(), }; if watch_received.len() == num_txs && sub_received.len() == num_txs { - if let Some(ref sent) = sent { + if let Some(sent) = &sent { assert_eq!(sent.len(), watch_received.len()); let sent_txs = sent.iter().map(|tx| tx.transaction_hash).collect::>(); - assert_eq!(sent_txs, watch_received.iter().map(|tx| tx.hash).collect()); - assert_eq!(sent_txs, sub_received.iter().map(|tx| tx.hash).collect()); + assert_eq!(sent_txs, watch_received.iter().copied().collect()); + assert_eq!(sent_txs, sub_received.iter().copied().collect()); break } } diff --git a/crates/anvil/tests/it/utils.rs b/crates/anvil/tests/it/utils.rs index 066ec807c96e9..56c8037025a3e 100644 --- a/crates/anvil/tests/it/utils.rs +++ b/crates/anvil/tests/it/utils.rs @@ -25,6 +25,7 @@ pub fn ws_provider_with_signer( .expect("failed to build Alloy WS provider with signer") } +/// Currently required to get around pub async fn connect_pubsub(conn_str: &str) -> RootProvider { alloy_provider::ProviderBuilder::new().on_builtin(conn_str).await.unwrap() } diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 728358bd63011..423ed2767fa04 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -526,13 +526,13 @@ fn prompt( ) -> Result { let text_clone = prompt_text.to_string(); let timeout = state.config.prompt_timeout; - let (send, recv) = mpsc::channel(); + let (tx, rx) = mpsc::channel(); thread::spawn(move || { - send.send(input(&text_clone)).unwrap(); + let _ = tx.send(input(&text_clone)); }); - match recv.recv_timeout(timeout) { + match rx.recv_timeout(timeout) { Ok(res) => res.map_err(|err| { println!(); err.to_string().into() diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index c8e9a0ba2733f..1083052b5b59a 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -13,6 +13,7 @@ use alloy_provider::{ Identity, ProviderBuilder as AlloyProviderBuilder, RootProvider, }; use alloy_rpc_client::ClientBuilder; +use alloy_transport::utils::guess_local_url; use eyre::{Result, WrapErr}; use foundry_config::NamedChain; use reqwest::Url; @@ -84,10 +85,9 @@ pub struct ProviderBuilder { /// JWT Secret jwt: Option, headers: Vec, + is_local: bool, } -// === impl ProviderBuilder === - impl ProviderBuilder { /// Creates a new builder instance pub fn new(url_str: &str) -> Self { @@ -121,6 +121,9 @@ impl ProviderBuilder { }) .wrap_err_with(|| format!("invalid provider URL: {url_str:?}")); + // Use the final URL string to guess if it's a local URL. + let is_local = url.as_ref().map_or(false, |url| guess_local_url(url.as_str())); + Self { url, chain: NamedChain::Mainnet, @@ -132,6 +135,7 @@ impl ProviderBuilder { compute_units_per_second: ALCHEMY_FREE_TIER_CUPS, jwt: None, headers: vec![], + is_local, } } @@ -201,11 +205,19 @@ impl ProviderBuilder { self } + /// Sets the provider to be local. + /// + /// This is useful for local dev nodes. + pub fn local(mut self, is_local: bool) -> Self { + self.is_local = is_local; + self + } + /// Sets aggressive `max_retry` and `initial_backoff` values /// /// This is only recommend for local dev nodes pub fn aggressive(self) -> Self { - self.max_retry(100).initial_backoff(100) + self.max_retry(100).initial_backoff(100).local(true) } /// Sets the JWT secret @@ -233,6 +245,7 @@ impl ProviderBuilder { compute_units_per_second, jwt, headers, + is_local, } = self; let url = url?; @@ -247,7 +260,7 @@ impl ProviderBuilder { .with_headers(headers) .with_jwt(jwt) .build(); - let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); + let client = ClientBuilder::default().layer(retry_layer).transport(transport, is_local); let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() .on_provider(RootProvider::new(client)); @@ -267,6 +280,7 @@ impl ProviderBuilder { compute_units_per_second, jwt, headers, + is_local, } = self; let url = url?; @@ -283,7 +297,7 @@ impl ProviderBuilder { .with_jwt(jwt) .build(); - let client = ClientBuilder::default().layer(retry_layer).transport(transport, false); + let client = ClientBuilder::default().layer(retry_layer).transport(transport, is_local); let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() .with_recommended_fillers() diff --git a/testdata/default/cheats/UnixTime.t.sol b/testdata/default/cheats/UnixTime.t.sol index e128dad2463b2..786c1ef5929db 100644 --- a/testdata/default/cheats/UnixTime.t.sol +++ b/testdata/default/cheats/UnixTime.t.sol @@ -8,7 +8,7 @@ contract UnixTimeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); // This is really wide because CI sucks. - uint256 constant errMargin = 300; + uint256 constant errMargin = 500; function testUnixTimeAgainstDate() public { string[] memory inputs = new string[](2); @@ -33,7 +33,6 @@ contract UnixTimeTest is DSTest { uint256 end = vm.unixTime(); uint256 interval = end - start; - assertGe(interval, sleepTime - errMargin, ".unixTime() is inaccurate"); - assertLe(interval, sleepTime + errMargin, ".unixTime() is inaccurate"); + vm.assertApproxEqAbs(interval, sleepTime, errMargin, ".unixTime() is inaccurate"); } } From a87faf6a725ab4327f8617bc56a7f85671bc52d8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 7 May 2024 15:52:20 +0200 Subject: [PATCH 0950/1963] fix(anvil/ots): include selfdestruct target address (#7880) --- Cargo.lock | 47 +++++----- Cargo.toml | 48 +++++----- crates/anvil/src/eth/backend/executor.rs | 20 +---- crates/anvil/src/eth/otterscan/types.rs | 108 ++++++++++------------- crates/anvil/src/hardfork.rs | 2 +- crates/anvil/tests/it/otterscan.rs | 43 +++++++-- 6 files changed, 136 insertions(+), 132 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55b297812695b..d327c38fb7fd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-eips", "alloy-primitives", @@ -92,7 +92,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -132,7 +132,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-primitives", "alloy-serde", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-primitives", "serde", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-consensus", "alloy-eips", @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -257,7 +257,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -321,7 +321,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-consensus", "alloy-eips", @@ -339,7 +339,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-consensus", "alloy-eips", @@ -356,7 +356,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -368,7 +368,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-primitives", "serde", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-consensus", "alloy-network", @@ -410,9 +410,10 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-consensus", + "alloy-dyn-abi", "alloy-network", "alloy-primitives", "alloy-signer", @@ -428,7 +429,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-consensus", "alloy-network", @@ -444,7 +445,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-consensus", "alloy-network", @@ -521,7 +522,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -539,7 +540,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -553,7 +554,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -573,7 +574,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=05af0de#05af0de129dc0fa081b19b2f0a69b26941f8fec7" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -6380,7 +6381,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=9a91a10#9a91a107edd197a65a3fd55b3942948036a72b33" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=ee6f6be#ee6f6be412c61a494472468c37bc7b8bc292b458" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index bd96efd2e8f18..c89a9e0ed8f1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.4.0", default-features = false } # no default features to avoid c-kzg revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "9a91a10", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ee6f6be", features = [ "serde", ] } @@ -152,29 +152,29 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "05af0de", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 999bfae4fc8b6..4c7e01a477b5c 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -19,7 +19,6 @@ use anvil_core::eth::{ }; use foundry_evm::{ backend::DatabaseError, - inspectors::{TracingInspector, TracingInspectorConfig}, revm::{ interpreter::InstructionResult, primitives::{ @@ -191,11 +190,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' contract_address, traces, exit, - out: match out { - Some(Output::Call(b)) => Some(alloy_primitives::Bytes(b.0)), - Some(Output::Create(b, _)) => Some(alloy_primitives::Bytes(b.0)), - _ => None, - }, + out: out.map(Output::into_data), nonce: tx.nonce, gas_used: tx.gas_used, }; @@ -308,7 +303,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator let exec_result = { let mut evm = foundry_evm::utils::new_evm_with_inspector(&mut *self.db, env, &mut inspector); - if let Some(ref factory) = self.precompile_factory { + if let Some(factory) = &self.precompile_factory { inject_precompiles(&mut evm, factory.precompiles()); } @@ -333,9 +328,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator } // This will correspond to prevrandao not set, and it should never happen. // If it does, it's a bug. - e => { - panic!("Failed to execute transaction. This is a bug.\n {:?}", e) - } + e => panic!("failed to execute transaction: {e}"), } } } @@ -375,12 +368,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator out, gas_used: gas_used as u128, logs: logs.unwrap_or_default(), - traces: inspector - .tracer - .unwrap_or(TracingInspector::new(TracingInspectorConfig::all())) - .get_traces() - .clone() - .into_nodes(), + traces: inspector.tracer.map(|t| t.into_traces().into_nodes()).unwrap_or_default(), nonce, }; diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 7fe337d97a04a..72bcb0de19938 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -9,7 +9,7 @@ use alloy_rpc_types_trace::parity::{ RewardAction, TraceOutput, }; use anvil_core::eth::transaction::ReceiptResponse; -use foundry_evm::{revm::interpreter::InstructionResult, traces::CallKind}; +use foundry_evm::traces::CallKind; use futures::future::join_all; use serde::Serialize; use serde_repr::Serialize_repr; @@ -73,7 +73,9 @@ pub struct OtsSearchTransactions { pub last_page: bool, } -/// Otterscan format for listing relevant internal operations +/// Otterscan format for listing relevant internal operations. +/// +/// Ref: #[derive(Debug, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] pub struct OtsInternalOperation { @@ -83,7 +85,9 @@ pub struct OtsInternalOperation { pub value: U256, } -/// Types of internal operations recognized by Otterscan +/// Types of internal operations recognized by Otterscan. +/// +/// Ref: #[derive(Debug, PartialEq, Serialize_repr)] #[repr(u8)] pub enum OtsInternalOperationType { @@ -102,6 +106,8 @@ pub struct OtsTrace { pub to: Address, pub value: U256, pub input: Bytes, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub output: Option, } /// The type of call being described by an Otterscan trace. Only CALL, STATICCALL and DELEGATECALL @@ -117,23 +123,28 @@ pub enum OtsTraceType { impl OtsBlockDetails { /// The response for ots_getBlockDetails includes an `issuance` object that requires computing /// the total gas spent in a given block. + /// /// The only way to do this with the existing API is to explicitly fetch all receipts, to get /// their `gas_used`. This would be extremely inefficient in a real blockchain RPC, but we can /// get away with that in this context. /// - /// The [original spec](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) also mentions we can hardcode `transactions` and `logsBloom` to an empty array to save bandwidth, because fields weren't intended to be used in the Otterscan UI at this point. This has two problems though: + /// The [original spec](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) + /// also mentions we can hardcode `transactions` and `logsBloom` to an empty array to save + /// bandwidth, because fields weren't intended to be used in the Otterscan UI at this point. + /// + /// This has two problems though: /// - It makes the endpoint too specific to Otterscan's implementation /// - It breaks the abstraction built in `OtsBlock` which computes `transaction_count` /// based on the existing list. /// Therefore we keep it simple by keeping the data in the response pub async fn build(block: Block, backend: &Backend) -> Result { - let block_txs = match block.transactions.clone() { - BlockTransactions::Full(txs) => txs.into_iter().map(|tx| tx.hash).collect(), - BlockTransactions::Hashes(txs) => txs, - BlockTransactions::Uncle => return Err(BlockchainError::DataUnavailable), - }; - let receipts_futs = - block_txs.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); + if block.transactions.is_uncle() { + return Err(BlockchainError::DataUnavailable); + } + let receipts_futs = block + .transactions + .hashes() + .map(|hash| async { backend.transaction_receipt(*hash).await }); // fetch all receipts let receipts = join_all(receipts_futs) @@ -162,32 +173,24 @@ impl OtsBlockDetails { /// which includes the `transaction_count` field impl From for OtsBlock { fn from(block: Block) -> Self { - let transaction_count = match block.transactions { - BlockTransactions::Full(ref txs) => txs.len(), - BlockTransactions::Hashes(ref txs) => txs.len(), - BlockTransactions::Uncle => 0, - }; - - Self { block, transaction_count } + Self { transaction_count: block.transactions.len(), block } } } impl OtsBlockTransactions { - /// Fetches all receipts for the blocks's transactions, as required by the [`ots_getBlockTransactions`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) endpoint spec, and returns the final response object. + /// Fetches all receipts for the blocks's transactions, as required by the + /// [`ots_getBlockTransactions`] endpoint spec, and returns the final response object. + /// + /// [`ots_getBlockTransactions`]: https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails pub async fn build( mut block: Block, backend: &Backend, page: usize, page_size: usize, ) -> Result { - let block_txs = match block.transactions.clone() { - BlockTransactions::Full(txs) => txs.into_iter().map(|tx| tx.hash).collect(), - BlockTransactions::Hashes(txs) => txs, - BlockTransactions::Uncle => return Err(BlockchainError::DataUnavailable), - }; - - let block_txs = - block_txs.into_iter().skip(page * page_size).take(page_size).collect::>(); + if block.transactions.is_uncle() { + return Err(BlockchainError::DataUnavailable); + } block.transactions = match block.transactions { BlockTransactions::Full(txs) => BlockTransactions::Full( @@ -196,11 +199,11 @@ impl OtsBlockTransactions { BlockTransactions::Hashes(txs) => BlockTransactions::Hashes( txs.into_iter().skip(page * page_size).take(page_size).collect(), ), - BlockTransactions::Uncle => return Err(BlockchainError::DataUnavailable), + BlockTransactions::Uncle => unreachable!(), }; let receipt_futs = - block_txs.iter().map(|tx| async { backend.transaction_receipt(*tx).await }); + block.transactions.hashes().map(|hash| backend.transaction_receipt(*hash)); let receipts = join_all(receipt_futs) .await @@ -288,36 +291,22 @@ impl OtsInternalOperation { .traces .iter() .filter_map(|node| { - match (node.trace.kind, node.trace.status) { - (CallKind::Call, _) if node.trace.value != rU256::ZERO => Some(Self { - r#type: OtsInternalOperationType::Transfer, - from: node.trace.caller, - to: node.trace.address, - value: node.trace.value, - }), - (CallKind::Create, _) => Some(Self { - r#type: OtsInternalOperationType::Create, - from: node.trace.caller, - to: node.trace.address, - value: node.trace.value, - }), - (CallKind::Create2, _) => Some(Self { - r#type: OtsInternalOperationType::Create2, - from: node.trace.caller, - to: node.trace.address, - value: node.trace.value, - }), - (_, InstructionResult::SelfDestruct) => { - Some(Self { - r#type: OtsInternalOperationType::SelfDestruct, - from: node.trace.address, - // the foundry CallTraceNode doesn't have a refund address - to: Default::default(), - value: node.trace.value, - }) + let r#type = match node.trace.kind { + _ if node.is_selfdestruct() => OtsInternalOperationType::SelfDestruct, + CallKind::Call if node.trace.value != rU256::ZERO => { + OtsInternalOperationType::Transfer } - _ => None, + CallKind::Create => OtsInternalOperationType::Create, + CallKind::Create2 => OtsInternalOperationType::Create2, + _ => return None, + }; + let mut from = node.trace.caller; + let mut to = node.trace.address; + if node.is_selfdestruct() { + from = node.trace.address; + to = node.trace.selfdestruct_refund_target.unwrap_or_default(); } + Some(Self { r#type, from, to, value: node.trace.value }) }) .collect() } @@ -339,14 +328,13 @@ impl OtsTrace { to: call.to, value: call.value, input: call.input.0.into(), + output: None, }) } else { None } } - Action::Create(_) => None, - Action::Selfdestruct(_) => None, - Action::Reward(_) => None, + Action::Create(_) | Action::Selfdestruct(_) | Action::Reward(_) => None, }) .collect() } diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index e2f107b5332c1..7d95f13e7aaa6 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -2,7 +2,7 @@ use alloy_rpc_types::BlockNumberOrTag; use foundry_evm::revm::primitives::SpecId; use std::str::FromStr; -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Hardfork { Frontier, Homestead, diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index f9fbd91235f33..573fc1c7e75a4 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -9,7 +9,7 @@ use anvil::{ eth::otterscan::types::{ OtsInternalOperation, OtsInternalOperationType, OtsTrace, OtsTraceType, }, - spawn, NodeConfig, + spawn, Hardfork, NodeConfig, }; use std::collections::VecDeque; @@ -123,31 +123,53 @@ async fn ots_get_internal_operations_contract_create2() { } #[tokio::test(flavor = "multi_thread")] -async fn ots_get_internal_operations_contract_selfdestruct() { +async fn ots_get_internal_operations_contract_selfdestruct_london() { + ots_get_internal_operations_contract_selfdestruct(Hardfork::London).await; +} + +#[tokio::test(flavor = "multi_thread")] +async fn ots_get_internal_operations_contract_selfdestruct_cancun() { + ots_get_internal_operations_contract_selfdestruct(Hardfork::Cancun).await; +} + +async fn ots_get_internal_operations_contract_selfdestruct(hardfork: Hardfork) { sol!( - #[sol(rpc, bytecode = "60808060405234601357607c908160188239f35b5f80fdfe6004361015600b575f80fd5b5f3560e01c6375fc8e3c14601d575f80fd5b346042575f36600319011260425773dcdd539da22bffaa499dbea4d37d086dde196e75ff5b5f80fdfea26469706673582212201778e88721238015f480b3a901848b460799e91836caf557a8dcfdb2a1a2469e64736f6c63430008190033")] + #[sol(rpc, bytecode = "608080604052607f908160108239f3fe6004361015600c57600080fd5b6000803560e01c6375fc8e3c14602157600080fd5b346046578060031936011260465773dcdd539da22bffaa499dbea4d37d086dde196e75ff5b80fdfea264697066735822122080a9ad005cc408b2d4e30ca11216d8e310700fbcdf58a629d6edbb91531f9c6164736f6c63430008190033")] contract Contract { + constructor() payable {} function goodbye() public { selfdestruct(payable(0xDcDD539DA22bfFAa499dBEa4d37d086Dde196E75)); } } ); - let (api, handle) = spawn(NodeConfig::test()).await; + let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(hardfork))).await; let provider = handle.http_provider(); - let contract = Contract::deploy(&provider).await.unwrap(); + let sender = handle.dev_accounts().next().unwrap(); + let value = U256::from(69); + + let contract_address = + Contract::deploy_builder(&provider).from(sender).value(value).deploy().await.unwrap(); + let contract = Contract::new(contract_address, &provider); let receipt = contract.goodbye().send().await.unwrap().get_receipt().await.unwrap(); + // TODO: This is currently not supported by revm-inspectors + let (expected_to, expected_value) = if hardfork < Hardfork::Cancun { + (address!("DcDD539DA22bfFAa499dBEa4d37d086Dde196E75"), value) + } else { + (Address::ZERO, U256::ZERO) + }; + let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!( res, [OtsInternalOperation { r#type: OtsInternalOperationType::SelfDestruct, - from: *contract.address(), - to: Address::ZERO, - value: U256::from(0), + from: contract_address, + to: expected_to, + value: expected_value, }], ); } @@ -227,6 +249,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::from(1337), input: Contract::runCall::SELECTOR.into(), + output: None, }, OtsTrace { r#type: OtsTraceType::StaticCall, @@ -235,6 +258,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::ZERO, input: Contract::do_staticcallCall::SELECTOR.into(), + output: None, }, OtsTrace { r#type: OtsTraceType::Call, @@ -243,6 +267,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::ZERO, input: Contract::do_callCall::SELECTOR.into(), + output: None, }, OtsTrace { r#type: OtsTraceType::Call, @@ -251,6 +276,7 @@ async fn test_call_ots_trace_transaction() { to: sender, value: U256::from(1337), input: Bytes::new(), + output: None, }, OtsTrace { r#type: OtsTraceType::DelegateCall, @@ -259,6 +285,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::ZERO, input: Contract::do_delegatecallCall::SELECTOR.into(), + output: None, }, ]; assert_eq!(res, expected); From 7ce6c9b7c541e64c780c68b5ddf95ab3a6c3ddc1 Mon Sep 17 00:00:00 2001 From: Meet Mangukiya Date: Tue, 7 May 2024 20:47:39 +0530 Subject: [PATCH 0951/1963] feat(cheatcodes): add ens namehash cheatcode (#7882) * feat(cheatcodes): add ens namehash cheatcode * fix test * fix test * rename the cheatcode from namehash -> ensNamehash * update cheatcodes.json --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 4 ++++ crates/cheatcodes/src/utils.rs | 8 ++++++++ testdata/cheats/Vm.sol | 1 + testdata/default/cheats/EnsNamehash.t.sol | 15 +++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 testdata/default/cheats/EnsNamehash.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 39b58ff5e7fe3..a461f614df572 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3671,6 +3671,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "ensNamehash", + "description": "Returns ENS namehash for provided string.", + "declaration": "function ensNamehash(string calldata name) external pure returns (bytes32);", + "visibility": "external", + "mutability": "pure", + "signature": "ensNamehash(string)", + "selector": "0x8c374c65", + "selectorBytes": [ + 140, + 55, + 76, + 101 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "envAddress_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 4bbf631690206..6e2fbd2787631 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2135,6 +2135,10 @@ interface Vm { /// Encodes a `string` value to a base64url string. #[cheatcode(group = Utilities)] function toBase64URL(string calldata data) external pure returns (string memory); + + /// Returns ENS namehash for provided string. + #[cheatcode(group = Utilities)] + function ensNamehash(string calldata name) external pure returns (bytes32); } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 71cfe6ae67262..df10613465dc3 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -11,6 +11,7 @@ use alloy_signer_wallet::{ LocalWallet, MnemonicBuilder, }; use alloy_sol_types::SolValue; +use foundry_common::ens::namehash; use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; use k256::{ ecdsa::SigningKey, @@ -137,6 +138,13 @@ impl Cheatcode for computeCreate2Address_1Call { } } +impl Cheatcode for ensNamehashCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { name } = self; + Ok(namehash(name).abi_encode()) + } +} + /// Using a given private key, return its public ETH address, its public key affine x and y /// coordinates, and its private key (see the 'Wallet' struct) /// diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index db8e45ada043e..45c720e6c51e5 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -179,6 +179,7 @@ interface Vm { 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); function envAddress(string calldata name) external view returns (address value); function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value); function envBool(string calldata name) external view returns (bool value); diff --git a/testdata/default/cheats/EnsNamehash.t.sol b/testdata/default/cheats/EnsNamehash.t.sol new file mode 100644 index 0000000000000..2d66beea4167e --- /dev/null +++ b/testdata/default/cheats/EnsNamehash.t.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract EnsNamehashTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testEnsNamehash() public { + assertEq(vm.ensNamehash(""), 0x0000000000000000000000000000000000000000000000000000000000000000); + assertEq(vm.ensNamehash("eth"), 0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae); + assertEq(vm.ensNamehash("foo.eth"), 0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f); + } +} From 874ea8cd3f8bf3545d210efd7b9f4c41ff36218a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 7 May 2024 18:31:28 +0200 Subject: [PATCH 0952/1963] chore: bump foundry-compilers (#7883) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/verify/src/etherscan/flatten.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d327c38fb7fd4..88c1db3e3e36b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3425,9 +3425,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76463dbe20b1a0830acc74ef8ed59d9d9392f2aed21b0542001dc5a1a725b8e" +checksum = "f97f9de33410d0daf13834f818a8594c0ed277c848af750e40a9f28e67d62e3a" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index c89a9e0ed8f1e..122f7f3d99966 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,7 +138,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.7", default-features = false } -foundry-compilers = { version = "0.4.0", default-features = false } +foundry-compilers = { version = "0.4.1", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index ca028fdabac78..ee0f95d83c091 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -77,7 +77,7 @@ impl EtherscanFlattenedSource { settings: Default::default(), }; - let (_, out) = Compiler::compile(&solc, input)?; + let out = Compiler::compile(&solc, &input)?; if out.errors.iter().any(|e| e.is_error()) { let mut o = AggregatedCompilerOutput::default(); o.extend(version, out); From 58c0c006d08eb43bc96f6d23516e43c249311eea Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 7 May 2024 13:05:12 -0400 Subject: [PATCH 0953/1963] fix(anvil): `tx.gas_price()` return val (#7876) * fix(anvil): cmp 1559 fees with basefee in 4844 tx not blobfee * fix(anvil): TypedTx - return 1559 fees in `.gas_price()` in case of 4844 --- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 7e2fc71dade24..c7bd580547c4a 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -617,7 +617,7 @@ impl TypedTransaction { TypedTransaction::Legacy(tx) => tx.tx().gas_price, TypedTransaction::EIP2930(tx) => tx.tx().gas_price, TypedTransaction::EIP1559(tx) => tx.tx().max_fee_per_gas, - TypedTransaction::EIP4844(tx) => tx.tx().tx().max_fee_per_blob_gas, + TypedTransaction::EIP4844(tx) => tx.tx().tx().max_fee_per_gas, TypedTransaction::Deposit(_) => 0, } } From 936238b0719de7a1520a29cc4747263670d3d683 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 8 May 2024 13:36:33 +0200 Subject: [PATCH 0954/1963] chore: remove `cast bind` (#7887) --- Cargo.lock | 1 - crates/cast/Cargo.toml | 2 -- crates/cast/bin/cmd/bind.rs | 59 +++++-------------------------------- crates/wallets/src/utils.rs | 16 ++++------ 4 files changed, 14 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88c1db3e3e36b..9520dd1d45dbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1753,7 +1753,6 @@ dependencies = [ "const-hex", "criterion", "dunce", - "ethers-contract-abigen", "evm-disassembler", "evmole", "eyre", diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 5d4405ae51420..59ac39e269856 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -42,8 +42,6 @@ alloy-network.workspace = true alloy-sol-types.workspace = true alloy-chains.workspace = true -ethers-contract-abigen.workspace = true - chrono.workspace = true evm-disassembler.workspace = true eyre.workspace = true diff --git a/crates/cast/bin/cmd/bind.rs b/crates/cast/bin/cmd/bind.rs index a83afc8ae1d03..942c441f6c1ff 100644 --- a/crates/cast/bin/cmd/bind.rs +++ b/crates/cast/bin/cmd/bind.rs @@ -1,13 +1,10 @@ use clap::{Parser, ValueHint}; -use ethers_contract_abigen::{Abigen, MultiAbigen}; use eyre::Result; -use foundry_block_explorers::{errors::EtherscanError, Client}; use foundry_cli::opts::EtherscanOpts; -use foundry_config::Config; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; -static DEFAULT_CRATE_NAME: &str = "foundry-contracts"; -static DEFAULT_CRATE_VERSION: &str = "0.0.1"; +const DEFAULT_CRATE_NAME: &str = "foundry-contracts"; +const DEFAULT_CRATE_VERSION: &str = "0.0.1"; /// CLI arguments for `cast bind`. #[derive(Clone, Debug, Parser)] @@ -58,50 +55,10 @@ pub struct BindArgs { impl BindArgs { pub async fn run(self) -> Result<()> { - let path = Path::new(&self.path_or_address); - let multi = if path.exists() { - MultiAbigen::from_json_files(path) - } else { - self.abigen_etherscan().await - }?; - - println!("Generating bindings for {} contracts", multi.len()); - let bindings = multi.build()?; - - let out = self - .output_dir - .clone() - .unwrap_or_else(|| std::env::current_dir().unwrap().join("bindings")); - bindings.write_to_crate(self.crate_name, self.crate_version, out, !self.separate_files)?; - Ok(()) - } - - async fn abigen_etherscan(&self) -> Result { - let config = Config::from(&self.etherscan); - - let chain = config.chain.unwrap_or_default(); - let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - - let client = Client::new(chain, api_key)?; - let address = self.path_or_address.parse()?; - let source = match client.contract_source_code(address).await { - Ok(source) => source, - Err(EtherscanError::InvalidApiKey) => { - eyre::bail!("Invalid Etherscan API key. Did you set it correctly? You may be using an API key for another Etherscan API chain (e.g. Etherscan API key for Polygonscan).") - } - Err(EtherscanError::ContractCodeNotVerified(address)) => { - eyre::bail!("Contract source code at {:?} on {} not verified. Maybe you have selected the wrong chain?", address, chain) - } - Err(err) => { - eyre::bail!(err) - } - }; - let abigens = source - .items - .into_iter() - .map(|item| Abigen::new(item.contract_name, item.abi).unwrap()) - .collect::>(); - - Ok(MultiAbigen::from_abigens(abigens)) + Err(eyre::eyre!( + "`cast bind` has been removed.\n\ + Please use `cast etherscan-source` to create a Forge project from an Etherscan source\n\ + and `forge bind` to generate the bindings to it instead." + )) } } diff --git a/crates/wallets/src/utils.rs b/crates/wallets/src/utils.rs index 898a82fdc4a7e..eaaf81e45403d 100644 --- a/crates/wallets/src/utils.rs +++ b/crates/wallets/src/utils.rs @@ -5,6 +5,7 @@ use alloy_signer_trezor::HDPath as TrezorHDPath; use alloy_signer_wallet::LocalWallet; use eyre::{Context, Result}; use foundry_config::Config; +use hex::FromHex; use std::{ fs, path::{Path, PathBuf}, @@ -18,20 +19,15 @@ fn ensure_pk_not_env(pk: &str) -> Result<()> { } /// Validates and sanitizes user inputs, returning configured [WalletSigner]. -pub fn create_private_key_signer(private_key: &str) -> Result { - let privk = private_key.trim().strip_prefix("0x").unwrap_or(private_key); - - let Ok(private_key) = hex::decode(privk) else { - ensure_pk_not_env(privk)?; +pub fn create_private_key_signer(private_key_str: &str) -> Result { + let Ok(private_key) = B256::from_hex(private_key_str) else { + ensure_pk_not_env(private_key_str)?; eyre::bail!("Failed to decode private key") }; - - match LocalWallet::from_bytes( - &B256::try_from(private_key.as_slice()).wrap_err("Failed to decode private key")?, - ) { + match LocalWallet::from_bytes(&private_key) { Ok(pk) => Ok(WalletSigner::Local(pk)), Err(err) => { - ensure_pk_not_env(privk)?; + ensure_pk_not_env(private_key_str)?; eyre::bail!("Failed to create wallet from private key: {err}") } } From a4d79ac5495b6294610c0a0bd5e4e13efdca13ee Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 8 May 2024 08:01:57 -0400 Subject: [PATCH 0955/1963] chore: deprecate `forge bind --ethers` (#7886) Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/chisel/bin/main.rs | 7 +- crates/common/src/fs.rs | 15 ++-- crates/forge/bin/cmd/bind.rs | 137 +++++++++++++++++++------------ crates/forge/tests/cli/script.rs | 8 +- 4 files changed, 97 insertions(+), 70 deletions(-) diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 706c6af99e08b..d2b3a726f48e8 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -272,10 +272,11 @@ async fn evaluate_prelude( load_prelude_file(dispatcher, prelude_dir).await?; println!("{}\n", "Prelude source file loaded successfully!".green()); } else { - let prelude_sources = fs::files_with_ext(prelude_dir, "sol"); - let print_success_msg = !prelude_sources.is_empty(); + let prelude_sources = fs::files_with_ext(&prelude_dir, "sol"); + let mut print_success_msg = false; for source_file in prelude_sources { - println!("{} {}", "Loading prelude source file:".yellow(), source_file.display(),); + print_success_msg = true; + println!("{} {}", "Loading prelude source file:".yellow(), source_file.display()); load_prelude_file(dispatcher, source_file).await?; } diff --git a/crates/common/src/fs.rs b/crates/common/src/fs.rs index 83b98670affc8..8ee47d2fd2a06 100644 --- a/crates/common/src/fs.rs +++ b/crates/common/src/fs.rs @@ -133,19 +133,18 @@ pub fn normalize_path(path: &Path) -> PathBuf { ret } -/// Returns all files with the given extension under the `root` dir -pub fn files_with_ext(root: impl AsRef, ext: &str) -> Vec { +/// Returns an iterator over all files with the given extension under the `root` dir. +pub fn files_with_ext<'a>(root: &Path, ext: &'a str) -> impl Iterator + 'a { walkdir::WalkDir::new(root) + .sort_by_file_name() .into_iter() .filter_map(walkdir::Result::ok) - .filter(|e| e.file_type().is_file()) - .filter(|e| e.path().extension().map(|e| e == ext).unwrap_or_default()) - .map(|e| e.path().into()) - .collect() + .filter(|e| e.file_type().is_file() && e.path().extension() == Some(ext.as_ref())) + .map(walkdir::DirEntry::into_path) } -/// Returns a list of absolute paths to all the json files under the root -pub fn json_files(root: impl AsRef) -> Vec { +/// Returns an iterator over all JSON files under the `root` dir. +pub fn json_files(root: &Path) -> impl Iterator { files_with_ext(root, "json") } diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 11f855f049580..3643642e70647 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -83,6 +83,14 @@ pub struct BindArgs { #[arg(long)] skip_extra_derives: bool, + /// Generate bindings for the `alloy` library, instead of `ethers`. + #[arg(skip)] + alloy: bool, + + /// Generate bindings for the `ethers` library, instead of `alloy` (default, deprecated). + #[arg(long)] + ethers: bool, + #[command(flatten)] build_args: CoreBuildArgs, } @@ -90,42 +98,40 @@ pub struct BindArgs { impl BindArgs { pub fn run(self) -> Result<()> { if !self.skip_build { - // run `forge build` let project = self.build_args.project()?; let _ = ProjectCompiler::new().compile(&project)?; } - let artifacts = self.try_load_config_emit_warnings()?.out; - - if !self.overwrite && self.bindings_exist(&artifacts) { - println!("Bindings found. Checking for consistency."); - return self.check_existing_bindings(&artifacts) + if !self.alloy { + eprintln!("Warning: ethers bindings are deprecated and will be removed in the future"); + /* + eprintln!( + "Warning: `--ethers` (default) bindings are deprecated and will be removed in the future. \ + Consider using `--alloy` instead." + ); + */ } - if self.overwrite && self.bindings_exist(&artifacts) { + let config = self.try_load_config_emit_warnings()?; + let artifacts = config.out; + let bindings_root = self.bindings.clone().unwrap_or_else(|| artifacts.join("bindings")); + + if bindings_root.exists() { + if !self.overwrite { + println!("Bindings found. Checking for consistency."); + return self.check_existing_bindings(&artifacts, &bindings_root); + } + trace!(?artifacts, "Removing existing bindings"); - fs::remove_dir_all(self.bindings_root(&artifacts))?; + fs::remove_dir_all(&bindings_root)?; } - self.generate_bindings(&artifacts)?; + self.generate_bindings(&artifacts, &bindings_root)?; - println!( - "Bindings have been output to {}", - self.bindings_root(&artifacts).to_str().unwrap() - ); + println!("Bindings have been generated to {}", bindings_root.display()); Ok(()) } - /// Get the path to the root of the autogenerated crate - fn bindings_root(&self, artifacts: impl AsRef) -> PathBuf { - self.bindings.clone().unwrap_or_else(|| artifacts.as_ref().join("bindings")) - } - - /// `true` if the bindings root already exists - fn bindings_exist(&self, artifacts: impl AsRef) -> bool { - self.bindings_root(artifacts).is_dir() - } - /// Returns the filter to use for `MultiAbigen` fn get_filter(&self) -> ContractFilter { if self.select_all { @@ -152,26 +158,39 @@ impl BindArgs { .into() } - /// Instantiate the multi-abigen - fn get_multi(&self, artifacts: impl AsRef) -> Result { - let abigens = json_files(artifacts.as_ref()) - .into_iter() + /// Returns an iterator over the JSON files and the contract name in the `artifacts` directory. + fn get_json_files(&self, artifacts: &Path) -> impl Iterator { + let filter = self.get_filter(); + json_files(artifacts) .filter_map(|path| { - if path.to_string_lossy().contains("/build-info/") { - // ignore the build info json - return None + // Ignore the build info JSON. + if path.to_str()?.contains("/build-info/") { + return None; } - // we don't want `.metadata.json files - let stem = path.file_stem()?; - if stem.to_str()?.ends_with(".metadata") { - None - } else { - Some(path) + + // We don't want `.metadata.json` files. + let stem = path.file_stem()?.to_str()?; + if stem.ends_with(".metadata") { + return None; } + + let name = stem.split('.').next().unwrap(); + + // Best effort identifier cleanup. + let name = name.replace(char::is_whitespace, "").replace('-', "_"); + + Some((name, path)) }) - .map(|path| { + .filter(move |(name, _path)| filter.is_match(name)) + } + + /// Instantiate the multi-abigen + fn get_multi(&self, artifacts: &Path) -> Result { + let abigens = self + .get_json_files(artifacts) + .map(|(name, path)| { trace!(?path, "parsing Abigen from file"); - let abi = Abigen::from_file(&path) + let abi = Abigen::new(name, path.to_str().unwrap()) .wrap_err_with(|| format!("failed to parse Abigen from file: {:?}", path)); if !self.skip_extra_derives { abi?.add_derive("serde::Serialize")?.add_derive("serde::Deserialize") @@ -180,27 +199,29 @@ impl BindArgs { } }) .collect::, _>>()?; - let multi = MultiAbigen::from_abigens(abigens).with_filter(self.get_filter()); - - eyre::ensure!( - !multi.is_empty(), - r#" -No contract artifacts found. Hint: Have you built your contracts yet? `forge bind` does not currently invoke `forge build`, although this is planned for future versions. - "# - ); + let multi = MultiAbigen::from_abigens(abigens); + eyre::ensure!(!multi.is_empty(), "No contract artifacts found"); Ok(multi) } /// Check that the existing bindings match the expected abigen output - fn check_existing_bindings(&self, artifacts: impl AsRef) -> Result<()> { - let bindings = self.get_multi(&artifacts)?.build()?; + fn check_existing_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + if !self.alloy { + return self.check_ethers(artifacts, bindings_root); + } + + todo!("alloy") + } + + fn check_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + let bindings = self.get_multi(artifacts)?.build()?; println!("Checking bindings for {} contracts.", bindings.len()); if !self.module { bindings .ensure_consistent_crate( &self.crate_name, &self.crate_version, - self.bindings_root(&artifacts), + bindings_root, self.single_file, !self.skip_cargo_toml, ) @@ -212,15 +233,23 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin } })?; } else { - bindings.ensure_consistent_module(self.bindings_root(&artifacts), self.single_file)?; + bindings.ensure_consistent_module(bindings_root, self.single_file)?; } println!("OK."); Ok(()) } /// Generate the bindings - fn generate_bindings(&self, artifacts: impl AsRef) -> Result<()> { - let mut bindings = self.get_multi(&artifacts)?.build()?; + fn generate_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + if !self.alloy { + return self.generate_ethers(artifacts, bindings_root); + } + + todo!("alloy") + } + + fn generate_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + let mut bindings = self.get_multi(artifacts)?.build()?; println!("Generating bindings for {} contracts", bindings.len()); if !self.module { trace!(single_file = self.single_file, "generating crate"); @@ -230,12 +259,12 @@ No contract artifacts found. Hint: Have you built your contracts yet? `forge bin bindings.write_to_crate( &self.crate_name, &self.crate_version, - self.bindings_root(&artifacts), + bindings_root, self.single_file, ) } else { trace!(single_file = self.single_file, "generating module"); - bindings.write_to_module(self.bindings_root(&artifacts), self.single_file) + bindings.write_to_module(bindings_root, self.single_file) } } } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index eee345595ab14..9f1a12c4ef1b5 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -808,9 +808,8 @@ contract Script0 is Script { assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); - let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast")) - .into_iter() - .find(|file| file.ends_with("run-latest.json")) + let run_latest = foundry_common::fs::json_files(&prj.root().join("broadcast")) + .find(|path| path.ends_with("run-latest.json")) .expect("No broadcast artifacts"); let content = foundry_common::fs::read_to_string(run_latest).unwrap(); @@ -893,8 +892,7 @@ contract Script0 is Script { assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); - let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast")) - .into_iter() + let run_latest = foundry_common::fs::json_files(&prj.root().join("broadcast")) .find(|file| file.ends_with("run-latest.json")) .expect("No broadcast artifacts"); From 3ef5466d0e917e6ea783433a44da3feaf1ce7055 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 10 May 2024 09:57:46 +0200 Subject: [PATCH 0956/1963] fix(cast): create transactions (#7904) --- crates/cast/bin/cmd/access_list.rs | 7 ++++++- crates/cast/bin/cmd/call.rs | 7 ++++++- crates/cast/bin/cmd/estimate.rs | 7 ++++++- crates/cast/bin/tx.rs | 12 +++++++----- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index d344017f629df..0e8fd042d4658 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -105,11 +105,16 @@ async fn access_list, T: Transport + Clone>( to_json: bool, ) -> Result<()> { let mut req = WithOtherFields::::default() - .with_to(to.unwrap_or_default()) .with_from(from) .with_value(tx.value.unwrap_or_default()) .with_chain_id(chain.id()); + if let Some(to) = to { + req.set_to(to); + } else { + req.set_kind(alloy_primitives::TxKind::Create); + } + if let Some(gas_limit) = tx.gas_limit { req.set_gas_limit(gas_limit.to()); } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 2caa54d2abc30..129e3da3081e1 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -122,10 +122,15 @@ impl CallArgs { }; let mut req = WithOtherFields::::default() - .with_to(to.unwrap_or_default()) .with_from(sender) .with_value(tx.value.unwrap_or_default()); + if let Some(to) = to { + req.set_to(to); + } else { + req.set_kind(alloy_primitives::TxKind::Create); + } + if let Some(nonce) = tx.nonce { req.set_nonce(nonce.to()); } diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index b0f0d6fcf27df..33f375f9c3ec5 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -94,10 +94,15 @@ impl EstimateArgs { }; let mut req = WithOtherFields::::default() - .with_to(to.unwrap_or_default()) .with_from(from) .with_value(value.unwrap_or_default()); + if let Some(to) = to { + req.set_to(to); + } else { + req.set_kind(alloy_primitives::TxKind::Create); + } + let data = match command { Some(EstimateSubcommands::Create { code, sig, args, value }) => { if let Some(value) = value { diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 1ad0ee2a9679e..64b33b280712f 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -57,15 +57,17 @@ pub async fn build_tx< let from = from.into().resolve(provider).await?; - let to: Option
= - if let Some(to) = to { Some(to.into().resolve(provider).await?) } else { None }; - - let mut req = WithOtherFields::new(TransactionRequest::default()) - .with_to(to.unwrap_or_default()) + let mut req = WithOtherFields::::default() .with_from(from) .with_value(tx.value.unwrap_or_default()) .with_chain_id(chain.id()); + if let Some(to) = to { + req.set_to(to.into().resolve(provider).await?); + } else { + req.set_kind(alloy_primitives::TxKind::Create); + } + req.set_nonce(if let Some(nonce) = tx.nonce { nonce.to() } else { From 503792a1dbadd901a4c02f6fcd1de1caff1573ff Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 10 May 2024 13:23:10 +0200 Subject: [PATCH 0957/1963] chore: bump alloy 899fc51 (#7905) * chore: bump alloy 899fc51 * fixes * fixes * update test --- Cargo.lock | 46 +++++++++++++------------- Cargo.toml | 48 ++++++++++++++-------------- crates/anvil/src/eth/backend/fork.rs | 9 +++--- crates/anvil/tests/it/fork.rs | 2 +- crates/anvil/tests/it/transaction.rs | 4 +-- crates/cast/bin/cmd/run.rs | 3 +- crates/cast/src/lib.rs | 6 +++- crates/common/src/transactions.rs | 3 +- crates/evm/core/src/fork/backend.rs | 5 ++- crates/verify/src/bytecode.rs | 9 ++++-- crates/verify/src/etherscan/mod.rs | 5 ++- 11 files changed, 79 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9520dd1d45dbe..7a352ef671add 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-eips", "alloy-primitives", @@ -92,7 +92,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -132,7 +132,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", "alloy-serde", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", "serde", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-consensus", "alloy-eips", @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -257,7 +257,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -321,7 +321,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-consensus", "alloy-eips", @@ -339,7 +339,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-consensus", "alloy-eips", @@ -356,7 +356,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -368,7 +368,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", "serde", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-consensus", "alloy-network", @@ -410,7 +410,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -429,7 +429,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-consensus", "alloy-network", @@ -445,7 +445,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-consensus", "alloy-network", @@ -522,7 +522,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -540,7 +540,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -554,7 +554,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -574,7 +574,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -6380,7 +6380,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=ee6f6be#ee6f6be412c61a494472468c37bc7b8bc292b458" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=c1b5dd0#c1b5dd0d85dd46ef5ec5258aebd24adc041d103a" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 122f7f3d99966..b2932bcb6893d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.4.1", default-features = false } # no default features to avoid c-kzg revm = { version = "8", default-features = false } revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ee6f6be", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "c1b5dd0", features = [ "serde", ] } @@ -152,29 +152,29 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 8b1ed0655f097..a9cc1cd9de461 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -316,10 +316,11 @@ impl ClientFork { } let tx = self.provider().get_transaction_by_hash(hash).await?; - - let mut storage = self.storage_write(); - storage.transactions.insert(hash, tx.clone()); - Ok(Some(tx)) + if let Some(tx) = tx.clone() { + let mut storage = self.storage_write(); + storage.transactions.insert(hash, tx); + } + Ok(tx) } pub async fn trace_transaction(&self, hash: B256) -> Result, TransportError> { diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 3af626962bcd5..067934d8a28cd 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -488,7 +488,7 @@ async fn can_reset_properly() { assert_eq!(to_balance, fork_provider.get_balance(to, BlockId::latest()).await.unwrap()); // tx does not exist anymore - assert!(fork_tx_provider.get_transaction_by_hash(tx.transaction_hash).await.is_err()) + assert!(fork_tx_provider.get_transaction_by_hash(tx.transaction_hash).await.unwrap().is_none()) } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 90ede1d73712d..eac152a510d75 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -695,9 +695,9 @@ async fn can_get_pending_transaction() { assert!(pending.is_ok()); api.mine_one().await; - let mined = provider.get_transaction_by_hash(*tx.tx_hash()).await.unwrap(); + let mined = provider.get_transaction_by_hash(*tx.tx_hash()).await.unwrap().unwrap(); - assert_eq!(mined.hash, pending.unwrap().hash); + assert_eq!(mined.hash, pending.unwrap().unwrap().hash); } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 599d73247f73b..35ab17ec4f49e 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -100,7 +100,8 @@ impl RunArgs { let tx = provider .get_transaction_by_hash(tx_hash) .await - .wrap_err_with(|| format!("tx not found: {:?}", tx_hash))?; + .wrap_err_with(|| format!("tx not found: {:?}", tx_hash))? + .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; // check if the tx is a system transaction if is_known_system_sender(tx.from) || tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) { diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 67048fda716ae..d7fa2a9f9bc34 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -635,7 +635,11 @@ where to_json: bool, ) -> Result { let tx_hash = TxHash::from_str(&tx_hash).wrap_err("invalid tx hash")?; - let tx = self.provider.get_transaction_by_hash(tx_hash).await?; + let tx = self + .provider + .get_transaction_by_hash(tx_hash) + .await? + .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; Ok(if raw { format!("0x{}", hex::encode(TxEnvelope::try_from(tx.inner)?.encoded_2718())) diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 8ec95179f1595..98244ddb42038 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -44,7 +44,8 @@ impl TransactionReceiptWithRevertReason { let transaction = provider .get_transaction_by_hash(self.receipt.transaction_hash) .await - .map_err(|_| eyre::eyre!("unable to fetch transaction"))?; + .map_err(|err| eyre::eyre!("unable to fetch transaction: {err}"))? + .ok_or_else(|| eyre::eyre!("transaction not found"))?; if let Some(block_hash) = self.receipt.block_hash { match provider diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index b60f00e5cb091..2ab9bdc9bdb49 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -245,7 +245,10 @@ where let block = provider .get_transaction_by_hash(tx) .await - .wrap_err("could not get transaction {tx}"); + .wrap_err_with(|| format!("could not get transaction {tx}")) + .and_then(|maybe| { + maybe.ok_or_else(|| eyre::eyre!("could not get transaction {tx}")) + }); (sender, block, tx) }); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 484b7780184c7..53654a7d35e51 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -184,7 +184,10 @@ impl VerifyBytecodeArgs { let mut transaction = provider .get_transaction_by_hash(creation_data.transaction_hash) .await - .or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))?; + .or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))? + .ok_or_else(|| { + eyre::eyre!("Transaction not found for hash {}", creation_data.transaction_hash) + })?; let receipt = provider .get_transaction_receipt(creation_data.transaction_hash) .await @@ -262,7 +265,9 @@ impl VerifyBytecodeArgs { let provider = utils::get_provider(&config)?; provider .get_transaction_by_hash(creation_data.transaction_hash) - .await.or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))? + .await.or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))?.ok_or_else(|| { + eyre::eyre!("Transaction not found for hash {}", creation_data.transaction_hash) + })? .block_number.ok_or_else(|| { eyre::eyre!("Failed to get block number of the contract creation tx, specify using the --block flag") })? diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 33dea487eb315..8ebe0dc46a24e 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -498,7 +498,10 @@ impl EtherscanVerificationProvider { )?; let creation_data = client.contract_creation_data(args.address).await?; - let transaction = provider.get_transaction_by_hash(creation_data.transaction_hash).await?; + let transaction = provider + .get_transaction_by_hash(creation_data.transaction_hash) + .await? + .ok_or_eyre("Transaction not found")?; let receipt = provider .get_transaction_receipt(creation_data.transaction_hash) .await? From 8d724584b3bd37260ef2b864c9ac69f55531670c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 12 May 2024 12:57:34 +0200 Subject: [PATCH 0958/1963] chore(deps): weekly `cargo update` (#7910) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Locking 51 packages to latest compatible versions Updating anyhow v1.0.82 -> v1.0.83 Updating aws-config v1.3.0 -> v1.4.0 Updating aws-runtime v1.2.0 -> v1.2.2 Updating aws-sdk-kms v1.23.0 -> v1.25.0 Updating aws-sdk-sso v1.22.0 -> v1.24.0 Updating aws-sdk-ssooidc v1.22.0 -> v1.25.0 Updating aws-sdk-sts v1.22.0 -> v1.24.0 Updating aws-smithy-runtime v1.4.0 -> v1.5.0 Updating aws-smithy-runtime-api v1.5.0 -> v1.6.0 Updating aws-smithy-types v1.1.8 -> v1.1.9 Updating aws-types v1.2.0 -> v1.2.1 Updating c-kzg v1.0.0 -> v1.0.2 Updating cc v1.0.96 -> v1.0.97 Updating ena v0.14.2 -> v0.14.3 Updating errno v0.3.8 -> v0.3.9 Updating fs4 v0.8.2 -> v0.8.3 Updating getrandom v0.2.14 -> v0.2.15 Updating interprocess v2.0.1 -> v2.1.0 Updating keccak-asm v0.1.0 -> v0.1.1 Updating num v0.4.2 -> v0.4.3 Updating num-bigint v0.4.4 -> v0.4.5 Updating num-complex v0.4.5 -> v0.4.6 Updating num-rational v0.4.1 -> v0.4.2 Updating parity-scale-codec v3.6.9 -> v3.6.12 Updating parity-scale-codec-derive v3.6.9 -> v3.6.12 Updating paste v1.0.14 -> v1.0.15 Updating petgraph v0.6.4 -> v0.6.5 Updating prettyplease v0.2.19 -> v0.2.20 Removing proc-macro-crate v1.3.1 Removing proc-macro-crate v2.0.0 Updating proc-macro2 v1.0.81 -> v1.0.82 Updating rustc-demangle v0.1.23 -> v0.1.24 Updating rustls-pki-types v1.5.0 -> v1.7.0 Updating rustversion v1.0.15 -> v1.0.16 Updating ryu v1.0.17 -> v1.0.18 Updating scale-info v2.11.2 -> v2.11.3 Updating scale-info-derive v2.11.2 -> v2.11.3 Updating schemars v0.8.17 -> v0.8.19 Updating schemars_derive v0.8.17 -> v0.8.19 Updating security-framework v2.10.0 -> v2.11.0 Updating security-framework-sys v2.10.0 -> v2.11.0 Updating semver v1.0.22 -> v1.0.23 Updating serde v1.0.200 -> v1.0.201 Updating serde_derive v1.0.200 -> v1.0.201 Updating serde_json v1.0.116 -> v1.0.117 Updating sha3-asm v0.1.0 -> v0.1.1 Updating syn v2.0.60 -> v2.0.63 Updating thiserror v1.0.59 -> v1.0.60 Updating thiserror-impl v1.0.59 -> v1.0.60 Removing toml_edit v0.19.15 Removing toml_edit v0.20.7 Updating winnow v0.6.7 -> v0.6.8 Updating zerocopy v0.7.33 -> v0.7.34 Updating zerocopy-derive v0.7.33 -> v0.7.34 Updating zip v1.1.4 -> v1.2.3 note: pass `--verbose` to see 137 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 386 ++++++++++++++++++++++++----------------------------- 1 file changed, 171 insertions(+), 215 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a352ef671add..69cc5af416495 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,7 +126,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.7", + "winnow 0.6.8", ] [[package]] @@ -291,7 +291,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -421,7 +421,7 @@ dependencies = [ "async-trait", "coins-ledger", "futures-util", - "semver 1.0.22", + "semver 1.0.23", "thiserror", "tracing", ] @@ -436,7 +436,7 @@ dependencies = [ "alloy-primitives", "alloy-signer", "async-trait", - "semver 1.0.22", + "semver 1.0.23", "thiserror", "tracing", "trezor-client", @@ -475,7 +475,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "syn-solidity", "tiny-keccak", ] @@ -493,7 +493,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.60", + "syn 2.0.63", "syn-solidity", ] @@ -503,7 +503,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8e71ea68e780cc203919e03f69f59e7afe92d2696fb1dcb6662f61e4031b6" dependencies = [ - "winnow 0.6.7", + "winnow 0.6.8", ] [[package]] @@ -812,9 +812,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" [[package]] name = "arbitrary" @@ -991,7 +991,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1013,7 +1013,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1024,7 +1024,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1071,7 +1071,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1082,9 +1082,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baaa0be6ee7d90b775ae6ccb6d2ba182b91219ec2001f92338773a094246af1d" +checksum = "40ddbfb5db93d62521f47b3f223da0884a2f02741ff54cb9cda192a0e73ba08b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1125,9 +1125,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.2.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4963ac9ff2d33a4231b3806c1c69f578f221a9cabb89ad2bde62ce2b442c8a7" +checksum = "75588e7ee5e8496eed939adac2035a6dbab9f7eb2acdd9ab2d31856dab6f3955" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1148,9 +1148,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.23.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db70afa14e99c6d3bfa45f1c41ec28414f628d1f5a242d8ae2578f4b7a4b8480" +checksum = "dca6ab350d6652bf85e38503758a67b2735b3d1ad38fd2f55181ef3c09afdb1c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.22.0" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3d6c4cba4e009391b72b0fcf12aff04ea3c9c3aa2ecaafa330326a8bd7e601" +checksum = "5fd6a9b38fe2dcaa2422b42e2c667112872d03a83522533f8b4165fd2d9d4bd1" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1192,9 +1192,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.22.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73400dc239d14f63d932f4ca7b55af5e9ef1f857f7d70655249ccc287adb2570" +checksum = "c99f342a364c8490b7715387244d2f7ebfc05f07bb6a0fc6e70b8e62b7078d06" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1214,9 +1214,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.22.0" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f8858308af76fba3e5ffcf1bb56af5471574d2bdfaf0159470c25bc2f760e5" +checksum = "7207ca62206c93e470457babf0512d7b6b97170fdba929a2a2f5682f9f68407c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1310,9 +1310,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cf64e73ef8d4dac6c933230d56d136b75b252edcf82ed36e37d603090cd7348" +checksum = "c9ac79e9f3a4d576f3cd4a470a0275b138d9e7b11b1cd514a6858ae0a79dd5bb" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1336,9 +1336,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c19fdae6e3d5ac9cd01f2d6e6c359c5f5a3e028c2d148a8f5b90bf3399a18a7" +checksum = "04ec42c2f5c0e7796a2848dde4d9f3bf8ce12ccbb3d5aa40c52fa0cdd61a1c47" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1353,9 +1353,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe14dceea1e70101d38fbf2a99e6a34159477c0fb95e68e05c66bd7ae4c3729" +checksum = "baf98d97bba6ddaba180f1b1147e202d8fe04940403a95a3f826c790f931bbd1" dependencies = [ "base64-simd", "bytes", @@ -1385,9 +1385,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a43b56df2c529fe44cb4d92bd64d0479883fb9608ff62daede4df5405381814" +checksum = "a807d90cd50a969b3d95e4e7ad1491fcae13c6e83948d8728363ecc09d66343a" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1674,9 +1674,9 @@ dependencies = [ [[package]] name = "c-kzg" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3130f3d8717cc02e668a896af24984d5d5d4e8bf12e278e982e0f1bd88a0f9af" +checksum = "cdf100c4cea8f207e883ff91ca886d621d8a166cb04971dfaa9bb8fd99ed95df" dependencies = [ "blst", "cc", @@ -1712,7 +1712,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -1771,7 +1771,7 @@ dependencies = [ "rayon", "regex", "rpassword", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "tempfile", @@ -1799,9 +1799,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" [[package]] name = "cfg-if" @@ -1839,7 +1839,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "serial_test", @@ -1956,7 +1956,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2371,7 +2371,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2382,7 +2382,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2443,7 +2443,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2464,7 +2464,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2474,7 +2474,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2594,7 +2594,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2675,9 +2675,9 @@ dependencies = [ [[package]] name = "ena" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" dependencies = [ "log", ] @@ -2702,7 +2702,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2736,9 +2736,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -2852,7 +2852,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.60", + "syn 2.0.63", "toml 0.8.12", "walkdir", ] @@ -2880,7 +2880,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.60", + "syn 2.0.63", "tempfile", "thiserror", "tiny-keccak", @@ -3120,7 +3120,7 @@ dependencies = [ "reqwest", "revm-inspectors", "rustc-hash", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "similar", @@ -3218,7 +3218,7 @@ dependencies = [ "itertools 0.12.1", "parking_lot", "revm-inspectors", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "tempfile", @@ -3250,7 +3250,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "tempfile", @@ -3279,7 +3279,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "reqwest", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -3316,7 +3316,7 @@ dependencies = [ "parking_lot", "revm", "rustc-hash", - "semver 1.0.22", + "semver 1.0.23", "serde_json", "thiserror", "toml 0.8.12", @@ -3408,7 +3408,7 @@ dependencies = [ "once_cell", "reqwest", "rustc-hash", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "similar-asserts", @@ -3445,7 +3445,7 @@ dependencies = [ "rand", "rayon", "regex", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -3480,7 +3480,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "serde_regex", @@ -3586,7 +3586,7 @@ dependencies = [ "foundry-evm-core", "revm", "rustc-hash", - "semver 1.0.22", + "semver 1.0.23", "tracing", ] @@ -3647,7 +3647,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "foundry-compilers", - "semver 1.0.22", + "semver 1.0.23", "thiserror", ] @@ -3658,7 +3658,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3723,9 +3723,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "fs4" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21dabded2e32cd57ded879041205c60a4a4c4bab47bd0fd2fa8b01f30849f02b" +checksum = "73969b81e8bc90a3828d913dd3973d80771bfb9d7fbe1a78a79122aad456af15" dependencies = [ "rustix", "windows-sys 0.52.0", @@ -3818,7 +3818,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3870,9 +3870,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -4661,9 +4661,9 @@ dependencies = [ [[package]] name = "interprocess" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7fb8583fab9503654385e2bafda123376445a77027a1b106dd7e44cf51122f" +checksum = "7b4d0250d41da118226e55b3d50ca3f0d9e0a0f6829b92f543ac0054aeea1572" dependencies = [ "futures-core", "libc", @@ -4789,9 +4789,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb8515fff80ed850aea4a1595f2e519c003e2a00a82fe168ebf5269196caf444" +checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -5053,7 +5053,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5123,7 +5123,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5239,9 +5239,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -5253,20 +5253,19 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] @@ -5309,11 +5308,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -5354,10 +5352,10 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5468,7 +5466,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5527,9 +5525,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "bitvec", @@ -5541,11 +5539,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -5576,9 +5574,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "path-slash" @@ -5625,7 +5623,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5684,7 +5682,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5700,9 +5698,9 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap", @@ -5787,7 +5785,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5825,7 +5823,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5936,12 +5934,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5967,25 +5965,6 @@ dependencies = [ "uint", ] -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.7", -] - [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -6021,9 +6000,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -6036,7 +6015,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "version_check", "yansi", ] @@ -6562,9 +6541,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -6593,7 +6572,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.22", + "semver 1.0.23", ] [[package]] @@ -6681,9 +6660,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" @@ -6708,9 +6687,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" [[package]] name = "rusty-fork" @@ -6749,9 +6728,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "salsa20" @@ -6773,9 +6752,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", "derive_more", @@ -6785,11 +6764,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -6815,9 +6794,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55c82c700538496bdc329bb4918a81f87cc8888811bd123cf325a0f2f8d309" +checksum = "fc6e7ed6919cb46507fb01ff1654309219f62b4d603822501b0b80d42f6f21ef" dependencies = [ "dyn-clone", "schemars_derive", @@ -6827,14 +6806,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83263746fe5e32097f06356968a077f96089739c927a61450efa069905eec108" +checksum = "185f2b7aa7e02d418e453790dde16890256bbd2bcd04b7dc5348811052b53f49" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -6906,11 +6885,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -6919,9 +6898,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -6938,9 +6917,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -6962,22 +6941,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.200" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.200" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -6988,14 +6967,14 @@ checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "indexmap", "itoa", @@ -7031,7 +7010,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7077,7 +7056,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7120,9 +7099,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac61da6b35ad76b195eb4771210f947734321a8d81d7738e1580d953bc7a15e" +checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" dependencies = [ "cc", "cfg-if", @@ -7295,7 +7274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" dependencies = [ "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7367,7 +7346,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7400,7 +7379,7 @@ dependencies = [ "fs4", "once_cell", "reqwest", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -7417,7 +7396,7 @@ checksum = "f1bb4806c96207e7cde40fc238f9a1d570f3090f850a742e1e96665440615a31" dependencies = [ "build_const", "const-hex", - "semver 1.0.22", + "semver 1.0.23", "serde_json", "svm-rs", ] @@ -7435,9 +7414,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" dependencies = [ "proc-macro2", "quote", @@ -7453,7 +7432,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7539,22 +7518,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7690,7 +7669,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7807,28 +7786,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.21.1" @@ -7850,7 +7807,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.7", + "winnow 0.6.8", ] [[package]] @@ -7932,7 +7889,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -8279,7 +8236,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-shared", ] @@ -8313,7 +8270,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8680,9 +8637,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr", ] @@ -8742,22 +8699,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.33" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.33" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -8777,14 +8734,14 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] name = "zip" -version = "1.1.4" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cc23c04387f4da0374be4533ad1208cbb091d5c11d070dfef13676ad6497164" +checksum = "c700ea425e148de30c29c580c1f9508b93ca57ad31c9f4e96b83c194c37a7a8f" dependencies = [ "arbitrary", "crc32fast", @@ -8792,6 +8749,5 @@ dependencies = [ "displaydoc", "flate2", "indexmap", - "num_enum", "thiserror", ] From a117fbfa41edbaa1618ed099d78d65727bff4790 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 12 May 2024 15:03:23 +0300 Subject: [PATCH 0959/1963] fix: nonce correction logic (#7907) * add test * fix: refactor correct_sender_nonce logic * fix doc --- crates/cheatcodes/src/evm.rs | 1 - crates/cheatcodes/src/evm/fork.rs | 10 -------- crates/cheatcodes/src/inspector.rs | 31 ++++++++++++++++++++--- crates/cheatcodes/src/script.rs | 18 -------------- crates/forge/tests/cli/script.rs | 40 ++++++++++++++++++++++++++++++ crates/script/src/runner.rs | 22 ---------------- 6 files changed, 67 insertions(+), 55 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 6189980716b5a..d40fae0ad9f8d 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -553,7 +553,6 @@ impl Cheatcode for stopAndReturnStateDiffCall { } pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { - super::script::correct_sender_nonce(ccx)?; let (account, _) = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?; Ok(account.info.nonce.abi_encode()) } diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 63f0bbad1b0c8..81b364aaf1093 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -116,10 +116,6 @@ impl Cheatcode for selectForkCall { let Self { forkId } = self; check_broadcast(ccx.state)?; - // No need to correct since the sender's nonce does not get incremented when selecting a - // fork. - ccx.state.corrected_nonce = true; - ccx.ecx.db.select_fork(*forkId, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state)?; Ok(Default::default()) } @@ -287,9 +283,6 @@ fn create_select_fork( ) -> Result { check_broadcast(ccx.state)?; - // No need to correct since the sender's nonce does not get incremented when selecting a fork. - ccx.state.corrected_nonce = true; - let fork = create_fork_request(ccx, url_or_alias, block)?; let id = ccx.ecx.db.create_select_fork(fork, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state)?; Ok(id.abi_encode()) @@ -314,9 +307,6 @@ fn create_select_fork_at_transaction( ) -> Result { check_broadcast(ccx.state)?; - // No need to correct since the sender's nonce does not get incremented when selecting a fork. - ccx.state.corrected_nonce = true; - let fork = create_fork_request(ccx, url_or_alias, None)?; let id = ccx.ecx.db.create_select_fork_at_transaction( fork, diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index b66d262e21dc8..25e34313c45ef 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -19,6 +19,7 @@ use alloy_primitives::{Address, Bytes, Log, TxKind, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, SELECTOR_LEN}; +use foundry_config::Config; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseExt, RevertDiagnostic}, @@ -166,10 +167,6 @@ pub struct Cheatcodes { /// Current broadcasting information pub broadcast: Option, - /// Used to correct the nonce of --sender after the initiating call. For more, check - /// `docs/scripting`. - pub corrected_nonce: bool, - /// Scripting based transactions pub broadcastable_transactions: BroadcastableTransactions, @@ -767,6 +764,32 @@ impl Inspector for Cheatcodes { fn call(&mut self, ecx: &mut EvmContext, call: &mut CallInputs) -> Option { let gas = Gas::new(call.gas_limit); + // At the root call to test function or script `run()`/`setUp()` functions, we are + // decreasing sender nonce to ensure that it matches on-chain nonce once we start + // broadcasting. + if ecx.journaled_state.depth == 0 { + let sender = ecx.env.tx.caller; + if sender != Config::DEFAULT_SENDER { + let account = match super::evm::journaled_account(ecx, sender) { + Ok(account) => account, + Err(err) => { + return Some(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: err.abi_encode().into(), + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }) + } + }; + let prev = account.info.nonce; + account.info.nonce = prev.saturating_sub(1); + + debug!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); + } + } + if call.contract == CHEATCODE_ADDRESS { return match self.apply_cheatcode(ecx, call) { Ok(retdata) => Some(CallOutcome { diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index a28a8be490ca2..19922ad34666b 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -3,7 +3,6 @@ use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, U256}; use alloy_signer_wallet::LocalWallet; -use foundry_config::Config; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; use parking_lot::Mutex; use std::sync::Arc; @@ -130,8 +129,6 @@ fn broadcast( ); ensure!(ccx.state.broadcast.is_none(), "a broadcast is active already"); - correct_sender_nonce(ccx)?; - let mut new_origin = new_origin.cloned(); if new_origin.is_none() { @@ -181,18 +178,3 @@ fn broadcast_key( } result } - -/// When using `forge script`, the script method is called using the address from `--sender`. -/// That leads to its nonce being incremented by `call_raw`. In a `broadcast` scenario this is -/// undesirable. Therefore, we make sure to fix the sender's nonce **once**. -pub(super) fn correct_sender_nonce(ccx: &mut CheatsCtxt) -> Result<()> { - let sender = ccx.ecx.env.tx.caller; - if !ccx.state.corrected_nonce && sender != Config::DEFAULT_SENDER { - let account = super::evm::journaled_account(ccx.ecx, sender)?; - let prev = account.info.nonce; - account.info.nonce = prev.saturating_sub(1); - debug!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); - ccx.state.corrected_nonce = true; - } - Ok(()) -} diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 9f1a12c4ef1b5..b981739cad45a 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1355,3 +1355,43 @@ contract SimpleScript is Script { let output = cmd.stderr_lossy(); assert!(output.contains("missing CREATE2 deployer")); }); + +forgetest_async!(can_switch_forks_in_setup, |prj, cmd| { + let (_api, handle) = + spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await; + + foundry_test_utils::util::initialize(prj.root()); + let url = handle.http_endpoint(); + + prj.add_script( + "Foo", + &r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function setUp() external { + uint256 initialFork = vm.activeFork(); + vm.createSelectFork(""); + vm.selectFork(initialFork); + } + + function run() external { + assert(vm.getNonce(msg.sender) == 0); + } +} + "# + .replace("", &url), + ) + .unwrap(); + + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &url, + "--sender", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + ]); + + cmd.stdout_lossy(); +}); diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index ff77b8e61cb81..901e5e58a87b3 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -101,8 +101,6 @@ impl ScriptRunner { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend_from_slice(&setup_logs); - self.maybe_correct_nonce(sender_nonce, libraries.len())?; - ( !reverted, gas_used, @@ -125,8 +123,6 @@ impl ScriptRunner { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend_from_slice(&setup_logs); - self.maybe_correct_nonce(sender_nonce, libraries.len())?; - ( !reverted, gas_used, @@ -156,24 +152,6 @@ impl ScriptRunner { )) } - /// We call the `setUp()` function with self.sender, and if there haven't been - /// any broadcasts, then the EVM cheatcode module hasn't corrected the nonce. - /// So we have to. - fn maybe_correct_nonce( - &mut self, - sender_initial_nonce: u64, - libraries_len: usize, - ) -> Result<()> { - if let Some(cheatcodes) = &self.executor.inspector.cheatcodes { - if !cheatcodes.corrected_nonce { - self.executor - .set_nonce(self.sender, sender_initial_nonce + libraries_len as u64)?; - } - self.executor.inspector.cheatcodes.as_mut().unwrap().corrected_nonce = false; - } - Ok(()) - } - /// Executes the method that will collect all broadcastable transactions. pub fn script(&mut self, address: Address, calldata: Bytes) -> Result { self.call(self.sender, address, calldata, U256::ZERO, false) From 4aa17bc86e7a43ca321da26cc049f85849fc9bc7 Mon Sep 17 00:00:00 2001 From: galois Date: Mon, 13 May 2024 23:35:40 +0800 Subject: [PATCH 0960/1963] feat(cast): support convert hex data to a utf-8 string (#7917) * feat(cast): support convert hex data to a utf-8 string * fix: return result and use `from_utf8_lossy` --- crates/cast/bin/main.rs | 4 ++++ crates/cast/bin/opts.rs | 7 +++++++ crates/cast/src/lib.rs | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index e1b411864bd29..30bb1205e56ef 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -68,6 +68,10 @@ async fn main() -> Result<()> { let value = stdin::unwrap(hexdata, false)?; println!("{}", SimpleCast::to_ascii(&value)?); } + CastSubcommand::ToUtf8 { hexdata } => { + let value = stdin::unwrap(hexdata, false)?; + println!("{}", SimpleCast::to_utf8(&value)?); + } CastSubcommand::FromFixedPoint { value, decimals } => { let (value, decimals) = stdin::unwrap2(value, decimals)?; println!("{}", SimpleCast::from_fixed_point(&value, &decimals)?); diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 51f32b145c838..4a9a009926069 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -126,6 +126,13 @@ pub enum CastSubcommand { hexdata: Option, }, + /// Convert hex data to a utf-8 string. + #[command(visible_aliases = &["--to-utf8", "tu8", "2u8"])] + ToUtf8 { + /// The hex data to convert. + hexdata: Option, + }, + /// Convert a fixed point number into an integer. #[command(visible_aliases = &["--from-fix", "ff"])] FromFixedPoint { diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index d7fa2a9f9bc34..e2f706b74dac0 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1053,6 +1053,24 @@ impl SimpleCast { hex::encode_prefixed(s) } + /// Converts hex input to UTF-8 text + /// + /// # Example + /// + /// ``` + /// use cast::SimpleCast as Cast; + /// + /// assert_eq!(Cast::to_utf8("0x796f")?, "yo"); + /// assert_eq!(Cast::to_utf8("0x48656c6c6f2c20576f726c6421")?, "Hello, World!"); + /// assert_eq!(Cast::to_utf8("0x547572626f44617070546f6f6c73")?, "TurboDappTools"); + /// assert_eq!(Cast::to_utf8("0xe4bda0e5a5bd")?, "你好"); + /// # Ok::<_, eyre::Report>(()) + /// ``` + pub fn to_utf8(s: &str) -> Result { + let bytes = hex::decode(s)?; + Ok(String::from_utf8_lossy(bytes.as_ref()).to_string()) + } + /// Converts hex data into text data /// /// # Example From 781acf0fa67b068e4e1538b5384c0ad522e8b279 Mon Sep 17 00:00:00 2001 From: Rafael Quintero Date: Tue, 14 May 2024 14:44:35 +0100 Subject: [PATCH 0961/1963] feat(cast): wallet keystore decrypting (#7893) * feat(cast): wallet keystore decrypting * test(cast): casttest for wallet import and decrypt-keystore * docs(cast): change keystore_dir explanation for DecryptKeystore --- crates/cast/bin/cmd/wallet/mod.rs | 50 +++++++++++++++++++++++++++- crates/cast/tests/cli/main.rs | 55 ++++++++++++++++++++++++++++++- 2 files changed, 103 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 1ac943204e112..3068af08364ce 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,5 +1,5 @@ use alloy_dyn_abi::TypedData; -use alloy_primitives::{Address, Signature}; +use alloy_primitives::{Address, Signature, B256}; use alloy_signer::Signer; use alloy_signer_wallet::{ coins_bip39::{English, Mnemonic}, @@ -151,6 +151,22 @@ pub enum WalletSubcommands { /// Derives private key from mnemonic #[command(name = "derive-private-key", visible_aliases = &["--derive-private-key"])] DerivePrivateKey { mnemonic: String, mnemonic_index: Option }, + + /// Decrypt a keystore file to get the private key + #[command(name = "decrypt-keystore", visible_alias = "dk")] + DecryptKeystore { + /// The name for the account in the keystore. + #[arg(value_name = "ACCOUNT_NAME")] + account_name: String, + /// If not provided, keystore will try to be located at the default keystores directory + /// (~/.foundry/keystores) + #[arg(long, short)] + keystore_dir: Option, + /// Password for the JSON keystore in cleartext + /// This is unsafe, we recommend using the default hidden password prompt + #[arg(long, env = "CAST_UNSAFE_PASSWORD", value_name = "PASSWORD")] + unsafe_password: Option, + }, } impl WalletSubcommands { @@ -365,6 +381,38 @@ flag to set your key via: println!("Address: {}", wallet.address()); println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); } + WalletSubcommands::DecryptKeystore { account_name, keystore_dir, unsafe_password } => { + // Set up keystore directory + let dir = if let Some(path) = keystore_dir { + Path::new(&path).to_path_buf() + } else { + Config::foundry_keystores_dir().ok_or_else(|| { + eyre::eyre!("Could not find the default keystore directory.") + })? + }; + + let keypath = dir.join(&account_name); + + if !keypath.exists() { + eyre::bail!("Keystore file does not exist at {}", keypath.display()); + } + + let password = if let Some(password) = unsafe_password { + password + } else { + // if no --unsafe-password was provided read via stdin + rpassword::prompt_password("Enter password: ")? + }; + + let wallet = LocalWallet::decrypt_keystore(keypath, password)?; + + let private_key = B256::from_slice(&wallet.signer().to_bytes()); + + let success_message = + format!("{}'s private key is: {}", &account_name, private_key); + + println!("{}", success_message.green()); + } }; Ok(()) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index c6f2b04501235..61594460fc32f 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -6,7 +6,7 @@ use foundry_test_utils::{ rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}, util::OutputExt, }; -use std::{fs, io::Write, path::Path}; +use std::{fs, io::Write, path::Path, str::FromStr}; // tests `--help` is printed to std out casttest!(print_help, |_prj, cmd| { @@ -156,6 +156,59 @@ casttest!(wallet_list_local_accounts, |prj, cmd| { assert_eq!(list_output.matches('\n').count(), 10); }); +// tests that `cast wallet import` creates a keystore for a private key and that `cast wallet +// decrypt-keystore` can access it +casttest!(wallet_import_and_decrypt, |prj, cmd| { + let keystore_path = prj.root().join("keystore"); + + cmd.set_current_dir(prj.root()); + + let account_name = "testAccount"; + + // Default Anvil private key + let test_private_key = + b256!("ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"); + + // import private key + cmd.cast_fuse().args([ + "wallet", + "import", + account_name, + "--private-key", + &test_private_key.to_string(), + "-k", + "keystore", + "--unsafe-password", + "test", + ]); + + cmd.assert_non_empty_stdout(); + + // check that the keystore file was created + let keystore_file = keystore_path.join(account_name); + + assert!(keystore_file.exists()); + + // decrypt the keystore file + let decrypt_output = cmd.cast_fuse().args([ + "wallet", + "decrypt-keystore", + account_name, + "-k", + "keystore", + "--unsafe-password", + "test", + ]); + + // get the PK out of the output (last word in the output) + let decrypt_output = decrypt_output.stdout_lossy(); + let private_key_string = decrypt_output.split_whitespace().last().unwrap(); + // check that the decrypted private key matches the imported private key + let decrypted_private_key = B256::from_str(private_key_string).unwrap(); + // the form + assert_eq!(decrypted_private_key, test_private_key); +}); + // tests that `cast estimate` is working correctly. casttest!(estimate_function_gas, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); From 4267f44e13bcfcb6ee3a38b10eba4afa1293296c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 14 May 2024 18:29:43 +0400 Subject: [PATCH 0962/1963] bump compilers (#7926) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 69cc5af416495..796e47fbd43a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3424,9 +3424,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f97f9de33410d0daf13834f818a8594c0ed277c848af750e40a9f28e67d62e3a" +checksum = "74a0bb9a4a8da5ded9ddbf2aba3d25bf26d2c4e8a3dfb4f20164d47d4da8761a" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index b2932bcb6893d..a807d1983c4c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,7 +138,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.7", default-features = false } -foundry-compilers = { version = "0.4.1", default-features = false } +foundry-compilers = { version = "0.4.3", default-features = false } ## revm # no default features to avoid c-kzg From 39f155d1fd68a8e2d0663c7d87573ad76831c23e Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 14 May 2024 18:36:25 +0400 Subject: [PATCH 0963/1963] feat: library deployments though CREATE2 (#7711) * wip * tests * fix test * clippy * check that CREATE2 deployer present * fmt * update doc * fix * rm blank lines * fmt * nits * fmt * fix nonce --- crates/config/src/lib.rs | 9 +- crates/evm/evm/src/executors/mod.rs | 5 + crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/script.rs | 56 +++++ crates/linking/src/lib.rs | 303 +++++++++++++++++++++------- crates/script/src/build.rs | 127 +++++++----- crates/script/src/execute.rs | 32 +-- crates/script/src/lib.rs | 9 +- crates/script/src/runner.rs | 129 +++++++++--- crates/test-utils/src/script.rs | 64 ++++-- 10 files changed, 537 insertions(+), 198 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 96cd23a63fddf..9c490ef031de4 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -28,7 +28,7 @@ use foundry_compilers::{ }; use inflector::Inflector; use regex::Regex; -use revm_primitives::SpecId; +use revm_primitives::{FixedBytes, SpecId}; use semver::Version; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{ @@ -394,6 +394,9 @@ pub struct Config { /// If disabled, it is possible to access artifacts which were not recompiled or cached. pub unchecked_cheatcode_artifacts: bool, + /// CREATE2 salt to use for the library deployment in scripts. + pub create2_library_salt: B256, + /// The root path where the config detection started from, `Config::with_root` #[doc(hidden)] // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] @@ -450,6 +453,9 @@ impl Config { /// `0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38` pub const DEFAULT_SENDER: Address = address!("1804c8AB1F12E6bbf3894d4083f33e07309d1f38"); + /// Default salt for create2 library deployments + pub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> = FixedBytes::<32>::ZERO; + /// Returns the current `Config` /// /// See `Config::figment` @@ -2006,6 +2012,7 @@ impl Default for Config { doc: Default::default(), labels: Default::default(), unchecked_cheatcode_artifacts: false, + create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, __non_exhaustive: (), __warnings: vec![], } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 45abbfc9c823a..6998006413d40 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -159,6 +159,11 @@ impl Executor { Ok(self.backend.basic_ref(address)?.map(|acc| acc.nonce).unwrap_or_default()) } + /// Returns true if account has no code. + pub fn is_empty_code(&self, address: Address) -> DatabaseResult { + Ok(self.backend.basic_ref(address)?.map(|acc| acc.is_empty_code_hash()).unwrap_or(true)) + } + #[inline] pub fn set_tracing(&mut self, tracing: bool) -> &mut Self { self.inspector.tracing(tracing); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f60eebfdef7eb..c0856ce08af8a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -130,6 +130,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { cancun: true, isolate: true, unchecked_cheatcode_artifacts: false, + create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, __non_exhaustive: (), __warnings: vec![], }; diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index b981739cad45a..61aff4db03acb 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1395,3 +1395,59 @@ contract SimpleScript is Script { cmd.stdout_lossy(); }); + +// Asserts that running the same script twice only deploys library once. +forgetest_async!(can_deploy_library_create2, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + + tester + .load_private_keys(&[0, 1]) + .await + .add_sig("BroadcastTest", "deploy()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(0, 2), (1, 1)]) + .await; + + tester.clear(); + + tester + .load_private_keys(&[0, 1]) + .await + .add_sig("BroadcastTest", "deploy()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(0, 1), (1, 1)]) + .await; +}); + +// Asserts that running the same script twice only deploys library once when using different +// senders. +forgetest_async!(can_deploy_library_create2_different_sender, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + + tester + .load_private_keys(&[0, 1]) + .await + .add_sig("BroadcastTest", "deploy()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(0, 2), (1, 1)]) + .await; + + tester.clear(); + + // Run different script from the same contract (which requires the same library). + tester + .load_private_keys(&[2]) + .await + .add_sig("BroadcastTest", "deployNoArgs()") + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(2, 2)]) + .await; +}); diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index ff019ae0699bb..8c0c6f5fedc89 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{Address, Bytes, B256}; use foundry_compilers::{ artifacts::{CompactContractBytecode, CompactContractBytecodeCow, Libraries}, contracts::ArtifactContracts, @@ -8,7 +8,7 @@ use foundry_compilers::{ }; use semver::Version; use std::{ - collections::{BTreeMap, BTreeSet}, + collections::{BTreeMap, BTreeSet, HashMap}, path::{Path, PathBuf}, str::FromStr, }; @@ -22,6 +22,8 @@ pub enum LinkerError { MissingTargetArtifact, #[error(transparent)] InvalidAddress(
::Err), + #[error("cyclic dependency found, can't link libraries via CREATE2")] + CyclicDependency, } pub struct Linker<'a> { @@ -172,6 +174,66 @@ impl<'a> Linker<'a> { Ok(LinkOutput { libraries, libs_to_deploy }) } + pub fn link_with_create2( + &'a self, + libraries: Libraries, + sender: Address, + salt: B256, + target: &'a ArtifactId, + ) -> Result { + // Library paths in `link_references` keys are always stripped, so we have to strip + // user-provided paths to be able to match them correctly. + let mut libraries = libraries.with_stripped_file_prefixes(self.root.as_path()); + + let mut needed_libraries = BTreeSet::new(); + self.collect_dependencies(target, &mut needed_libraries)?; + + let mut needed_libraries = needed_libraries + .into_iter() + .filter(|id| { + // Filter out already provided libraries. + let (file, name) = self.convert_artifact_id_to_lib_path(id); + !libraries.libs.contains_key(&file) || !libraries.libs[&file].contains_key(&name) + }) + .map(|id| { + // Link library with provided libs and extract bytecode object (possibly unlinked). + let bytecode = self.link(id, &libraries).unwrap().bytecode.unwrap(); + (id, bytecode) + }) + .collect::>(); + + let mut libs_to_deploy = Vec::new(); + + // Iteratively compute addresses and link libraries until we have no unlinked libraries + // left. + while !needed_libraries.is_empty() { + // Find any library which is fully linked. + let deployable = needed_libraries + .iter() + .find(|(_, bytecode)| !bytecode.object.is_unlinked()) + .map(|(id, _)| *id); + + // If we haven't found any deployable library, it means we have a cyclic dependency. + let Some(id) = deployable else { + return Err(LinkerError::CyclicDependency); + }; + let bytecode = needed_libraries.remove(id).unwrap(); + let code = bytecode.into_bytes().unwrap(); + let address = sender.create2_from_code(salt, code.as_ref()); + libs_to_deploy.push(code); + + let (file, name) = self.convert_artifact_id_to_lib_path(id); + + for (_, bytecode) in needed_libraries.iter_mut() { + bytecode.link(file.to_string_lossy(), name.clone(), address); + } + + libraries.libs.entry(file).or_default().insert(name, address.to_checksum(None)); + } + + Ok(LinkOutput { libraries, libs_to_deploy }) + } + /// Links given artifact with given libraries. pub fn link( &self, @@ -212,6 +274,7 @@ impl<'a> Linker<'a> { #[cfg(test)] mod tests { use super::*; + use alloy_primitives::fixed_bytes; use foundry_compilers::{Project, ProjectCompileOutput, ProjectPathsConfig}; use std::collections::HashMap; @@ -225,7 +288,7 @@ mod tests { fn new(path: impl Into, strip_prefixes: bool) -> Self { let path = path.into(); let paths = ProjectPathsConfig::builder() - .root("../../testdata/linking") + .root("../../testdata") .lib("../../testdata/lib") .sources(path.clone()) .tests(path) @@ -259,7 +322,29 @@ mod tests { fn test_with_sender_and_nonce(self, sender: Address, initial_nonce: u64) { let linker = Linker::new(self.project.root(), self.output.artifact_ids().collect()); - for id in linker.contracts.keys() { + for (id, identifier) in self.iter_linking_targets(&linker) { + let output = linker + .link_with_nonce_or_address(Default::default(), sender, initial_nonce, id) + .expect("Linking failed"); + self.validate_assertions(identifier, output); + } + } + + fn test_with_create2(self, sender: Address, salt: B256) { + let linker = Linker::new(self.project.root(), self.output.artifact_ids().collect()); + for (id, identifier) in self.iter_linking_targets(&linker) { + let output = linker + .link_with_create2(Default::default(), sender, salt, id) + .expect("Linking failed"); + self.validate_assertions(identifier, output); + } + } + + fn iter_linking_targets<'a>( + &'a self, + linker: &'a Linker<'_>, + ) -> impl IntoIterator + 'a { + linker.contracts.keys().filter_map(move |id| { // If we didn't strip paths, artifacts will have absolute paths. // That's expected and we want to ensure that only `libraries` object has relative // paths, artifacts should be kept as is. @@ -273,36 +358,42 @@ mod tests { // Skip ds-test as it always has no dependencies etc. (and the path is outside root // so is not sanitized) if identifier.contains("DSTest") { - continue; + return None; } - let LinkOutput { libs_to_deploy, libraries, .. } = linker - .link_with_nonce_or_address(Default::default(), sender, initial_nonce, id) - .expect("Linking failed"); - - let assertions = self - .dependency_assertions - .get(&identifier) - .unwrap_or_else(|| panic!("Unexpected artifact: {identifier}")); - - assert_eq!( - libs_to_deploy.len(), - assertions.len(), - "artifact {identifier} has more/less dependencies than expected ({} vs {}): {:#?}", - libs_to_deploy.len(), - assertions.len(), - libs_to_deploy - ); + Some((id, identifier)) + }) + } - for (dep_identifier, address) in assertions { - let (file, name) = dep_identifier.split_once(':').unwrap(); - if let Some(lib_address) = - libraries.libs.get(&PathBuf::from(file)).and_then(|libs| libs.get(name)) - { - assert_eq!(*lib_address, address.to_string(), "incorrect library address for dependency {dep_identifier} of {identifier}"); - } else { - panic!("Library not found") - } + fn validate_assertions(&self, identifier: String, output: LinkOutput) { + let LinkOutput { libs_to_deploy, libraries } = output; + + let assertions = self + .dependency_assertions + .get(&identifier) + .unwrap_or_else(|| panic!("Unexpected artifact: {identifier}")); + + assert_eq!( + libs_to_deploy.len(), + assertions.len(), + "artifact {identifier} has more/less dependencies than expected ({} vs {}): {:#?}", + libs_to_deploy.len(), + assertions.len(), + libs_to_deploy + ); + + for (dep_identifier, address) in assertions { + let (file, name) = dep_identifier.split_once(':').unwrap(); + if let Some(lib_address) = + libraries.libs.get(&PathBuf::from(file)).and_then(|libs| libs.get(name)) + { + assert_eq!( + *lib_address, + address.to_string(), + "incorrect library address for dependency {dep_identifier} of {identifier}" + ); + } else { + panic!("Library {} not found", dep_identifier); } } } @@ -316,20 +407,20 @@ mod tests { #[test] fn link_simple() { - link_test("../../testdata/linking/simple", |linker| { + link_test("../../testdata/default/linking/simple", |linker| { linker - .assert_dependencies("simple/Simple.t.sol:Lib".to_string(), vec![]) + .assert_dependencies("default/linking/simple/Simple.t.sol:Lib".to_string(), vec![]) .assert_dependencies( - "simple/Simple.t.sol:LibraryConsumer".to_string(), + "default/linking/simple/Simple.t.sol:LibraryConsumer".to_string(), vec![( - "simple/Simple.t.sol:Lib".to_string(), + "default/linking/simple/Simple.t.sol:Lib".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) .assert_dependencies( - "simple/Simple.t.sol:SimpleLibraryLinkingTest".to_string(), + "default/linking/simple/Simple.t.sol:SimpleLibraryLinkingTest".to_string(), vec![( - "simple/Simple.t.sol:Lib".to_string(), + "default/linking/simple/Simple.t.sol:Lib".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) @@ -339,43 +430,43 @@ mod tests { #[test] fn link_nested() { - link_test("../../testdata/linking/nested", |linker| { + link_test("../../testdata/default/linking/nested", |linker| { linker - .assert_dependencies("nested/Nested.t.sol:Lib".to_string(), vec![]) + .assert_dependencies("default/linking/nested/Nested.t.sol:Lib".to_string(), vec![]) .assert_dependencies( - "nested/Nested.t.sol:NestedLib".to_string(), + "default/linking/nested/Nested.t.sol:NestedLib".to_string(), vec![( - "nested/Nested.t.sol:Lib".to_string(), + "default/linking/nested/Nested.t.sol:Lib".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) .assert_dependencies( - "nested/Nested.t.sol:LibraryConsumer".to_string(), + "default/linking/nested/Nested.t.sol:LibraryConsumer".to_string(), vec![ // Lib shows up here twice, because the linker sees it twice, but it should // have the same address and nonce. ( - "nested/Nested.t.sol:Lib".to_string(), + "default/linking/nested/Nested.t.sol:Lib".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") .unwrap(), ), ( - "nested/Nested.t.sol:NestedLib".to_string(), + "default/linking/nested/Nested.t.sol:NestedLib".to_string(), Address::from_str("0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D") .unwrap(), ), ], ) .assert_dependencies( - "nested/Nested.t.sol:NestedLibraryLinkingTest".to_string(), + "default/linking/nested/Nested.t.sol:NestedLibraryLinkingTest".to_string(), vec![ ( - "nested/Nested.t.sol:Lib".to_string(), + "default/linking/nested/Nested.t.sol:Lib".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") .unwrap(), ), ( - "nested/Nested.t.sol:NestedLib".to_string(), + "default/linking/nested/Nested.t.sol:NestedLib".to_string(), Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") .unwrap(), ), @@ -387,94 +478,101 @@ mod tests { #[test] fn link_duplicate() { - link_test("../../testdata/linking/duplicate", |linker| { + link_test("../../testdata/default/linking/duplicate", |linker| { linker - .assert_dependencies("duplicate/Duplicate.t.sol:A".to_string(), vec![]) - .assert_dependencies("duplicate/Duplicate.t.sol:B".to_string(), vec![]) .assert_dependencies( - "duplicate/Duplicate.t.sol:C".to_string(), + "default/linking/duplicate/Duplicate.t.sol:A".to_string(), + vec![], + ) + .assert_dependencies( + "default/linking/duplicate/Duplicate.t.sol:B".to_string(), + vec![], + ) + .assert_dependencies( + "default/linking/duplicate/Duplicate.t.sol:C".to_string(), vec![( - "duplicate/Duplicate.t.sol:A".to_string(), + "default/linking/duplicate/Duplicate.t.sol:A".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) .assert_dependencies( - "duplicate/Duplicate.t.sol:D".to_string(), + "default/linking/duplicate/Duplicate.t.sol:D".to_string(), vec![( - "duplicate/Duplicate.t.sol:B".to_string(), + "default/linking/duplicate/Duplicate.t.sol:B".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3").unwrap(), )], ) .assert_dependencies( - "duplicate/Duplicate.t.sol:E".to_string(), + "default/linking/duplicate/Duplicate.t.sol:E".to_string(), vec![ ( - "duplicate/Duplicate.t.sol:A".to_string(), + "default/linking/duplicate/Duplicate.t.sol:A".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:C".to_string(), + "default/linking/duplicate/Duplicate.t.sol:C".to_string(), Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") .unwrap(), ), ], ) .assert_dependencies( - "duplicate/Duplicate.t.sol:LibraryConsumer".to_string(), + "default/linking/duplicate/Duplicate.t.sol:LibraryConsumer".to_string(), vec![ ( - "duplicate/Duplicate.t.sol:A".to_string(), + "default/linking/duplicate/Duplicate.t.sol:A".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:B".to_string(), + "default/linking/duplicate/Duplicate.t.sol:B".to_string(), Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:C".to_string(), + "default/linking/duplicate/Duplicate.t.sol:C".to_string(), Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:D".to_string(), + "default/linking/duplicate/Duplicate.t.sol:D".to_string(), Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:E".to_string(), + "default/linking/duplicate/Duplicate.t.sol:E".to_string(), Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f") .unwrap(), ), ], ) .assert_dependencies( - "duplicate/Duplicate.t.sol:DuplicateLibraryLinkingTest".to_string(), + "default/linking/duplicate/Duplicate.t.sol:DuplicateLibraryLinkingTest" + .to_string(), vec![ ( - "duplicate/Duplicate.t.sol:A".to_string(), + "default/linking/duplicate/Duplicate.t.sol:A".to_string(), Address::from_str("0x5a443704dd4b594b382c22a083e2bd3090a6fef3") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:B".to_string(), + "default/linking/duplicate/Duplicate.t.sol:B".to_string(), Address::from_str("0x47e9fbef8c83a1714f1951f142132e6e90f5fa5d") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:C".to_string(), + "default/linking/duplicate/Duplicate.t.sol:C".to_string(), Address::from_str("0x8be503bcded90ed42eff31f56199399b2b0154ca") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:D".to_string(), + "default/linking/duplicate/Duplicate.t.sol:D".to_string(), Address::from_str("0x47c5e40890bce4a473a49d7501808b9633f29782") .unwrap(), ), ( - "duplicate/Duplicate.t.sol:E".to_string(), + "default/linking/duplicate/Duplicate.t.sol:E".to_string(), Address::from_str("0x29b2440db4a256b0c1e6d3b4cdcaa68e2440a08f") .unwrap(), ), @@ -486,33 +584,33 @@ mod tests { #[test] fn link_cycle() { - link_test("../../testdata/linking/cycle", |linker| { + link_test("../../testdata/default/linking/cycle", |linker| { linker .assert_dependencies( - "cycle/Cycle.t.sol:Foo".to_string(), + "default/linking/cycle/Cycle.t.sol:Foo".to_string(), vec![ ( - "cycle/Cycle.t.sol:Foo".to_string(), + "default/linking/cycle/Cycle.t.sol:Foo".to_string(), Address::from_str("0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D") .unwrap(), ), ( - "cycle/Cycle.t.sol:Bar".to_string(), + "default/linking/cycle/Cycle.t.sol:Bar".to_string(), Address::from_str("0x5a443704dd4B594B382c22a083e2BD3090A6feF3") .unwrap(), ), ], ) .assert_dependencies( - "cycle/Cycle.t.sol:Bar".to_string(), + "default/linking/cycle/Cycle.t.sol:Bar".to_string(), vec![ ( - "cycle/Cycle.t.sol:Foo".to_string(), + "default/linking/cycle/Cycle.t.sol:Foo".to_string(), Address::from_str("0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D") .unwrap(), ), ( - "cycle/Cycle.t.sol:Bar".to_string(), + "default/linking/cycle/Cycle.t.sol:Bar".to_string(), Address::from_str("0x5a443704dd4B594B382c22a083e2BD3090A6feF3") .unwrap(), ), @@ -521,4 +619,57 @@ mod tests { .test_with_sender_and_nonce(Address::default(), 1); }); } + + #[test] + fn link_create2_nested() { + link_test("../../testdata/default/linking/nested", |linker| { + linker + .assert_dependencies("default/linking/nested/Nested.t.sol:Lib".to_string(), vec![]) + .assert_dependencies( + "default/linking/nested/Nested.t.sol:NestedLib".to_string(), + vec![( + "default/linking/nested/Nested.t.sol:Lib".to_string(), + Address::from_str("0xCD3864eB2D88521a5477691EE589D9994b796834").unwrap(), + )], + ) + .assert_dependencies( + "default/linking/nested/Nested.t.sol:LibraryConsumer".to_string(), + vec![ + // Lib shows up here twice, because the linker sees it twice, but it should + // have the same address and nonce. + ( + "default/linking/nested/Nested.t.sol:Lib".to_string(), + Address::from_str("0xCD3864eB2D88521a5477691EE589D9994b796834") + .unwrap(), + ), + ( + "default/linking/nested/Nested.t.sol:NestedLib".to_string(), + Address::from_str("0x023d9a6bfA39c45997572dC4F87b3E2713b6EBa4") + .unwrap(), + ), + ], + ) + .assert_dependencies( + "default/linking/nested/Nested.t.sol:NestedLibraryLinkingTest".to_string(), + vec![ + ( + "default/linking/nested/Nested.t.sol:Lib".to_string(), + Address::from_str("0xCD3864eB2D88521a5477691EE589D9994b796834") + .unwrap(), + ), + ( + "default/linking/nested/Nested.t.sol:NestedLib".to_string(), + Address::from_str("0x023d9a6bfA39c45997572dC4F87b3E2713b6EBa4") + .unwrap(), + ), + ], + ) + .test_with_create2( + Address::default(), + fixed_bytes!( + "19bf59b7b67ae8edcbc6e53616080f61fa99285c061450ad601b0bc40c9adfc9" + ), + ); + }); + } } diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 8c41cfde63af3..8d9907ccfebe4 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -5,8 +5,7 @@ use crate::{ sequence::{ScriptSequence, ScriptSequenceKind}, ScriptArgs, ScriptConfig, }; - -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{Bytes, B256}; use alloy_provider::Provider; use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; @@ -21,10 +20,12 @@ use foundry_compilers::{ utils::source_files_iter, ArtifactId, ProjectCompileOutput, SOLC_EXTENSIONS, }; -use foundry_linking::{LinkOutput, Linker}; +use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; +use foundry_linking::Linker; use std::{path::PathBuf, str::FromStr, sync::Arc}; /// Container for the compiled contracts. +#[derive(Debug)] pub struct BuildData { /// Root of the project pub project_root: PathBuf, @@ -39,43 +40,81 @@ impl BuildData { Linker::new(self.project_root.clone(), self.output.artifact_ids().collect()) } - /// Links the build data with given libraries, using sender and nonce to compute addresses of - /// missing libraries. - pub fn link( - self, - known_libraries: Libraries, - sender: Address, - nonce: u64, - ) -> Result { - let link_output = self.get_linker().link_with_nonce_or_address( - known_libraries, - sender, - nonce, - &self.target, - )?; + /// Links contracts. Uses CREATE2 linking when possible, otherwise falls back to + /// default linking with sender nonce and address. + pub async fn link(self, script_config: &ScriptConfig) -> Result { + let can_use_create2 = if let Some(fork_url) = &script_config.evm_opts.fork_url { + let provider = try_get_http_provider(fork_url)?; + let deployer_code = + provider.get_code_at(DEFAULT_CREATE2_DEPLOYER, Default::default()).await?; + + !deployer_code.is_empty() + } else { + // If --fork-url is not provided, we are just simulating the script. + true + }; + + let known_libraries = script_config.config.libraries_with_remappings()?; + + let maybe_create2_link_output = can_use_create2 + .then(|| { + self.get_linker() + .link_with_create2( + known_libraries.clone(), + DEFAULT_CREATE2_DEPLOYER, + script_config.config.create2_library_salt, + &self.target, + ) + .ok() + }) + .flatten(); + + let (libraries, predeploy_libs) = if let Some(output) = maybe_create2_link_output { + ( + output.libraries, + ScriptPredeployLibraries::Create2( + output.libs_to_deploy, + script_config.config.create2_library_salt, + ), + ) + } else { + let output = self.get_linker().link_with_nonce_or_address( + known_libraries, + script_config.evm_opts.sender, + script_config.sender_nonce, + &self.target, + )?; - LinkedBuildData::new(link_output, self) + (output.libraries, ScriptPredeployLibraries::Default(output.libs_to_deploy)) + }; + + LinkedBuildData::new(libraries, predeploy_libs, self) } /// Links the build data with the given libraries. Expects supplied libraries set being enough /// to fully link target contract. pub fn link_with_libraries(self, libraries: Libraries) -> Result { - let link_output = self.get_linker().link_with_nonce_or_address( - libraries, - Address::ZERO, - 0, - &self.target, - )?; + LinkedBuildData::new(libraries, ScriptPredeployLibraries::Default(Vec::new()), self) + } +} - if !link_output.libs_to_deploy.is_empty() { - eyre::bail!("incomplete libraries set"); - } +#[derive(Debug)] +pub enum ScriptPredeployLibraries { + Default(Vec), + Create2(Vec, B256), +} - LinkedBuildData::new(link_output, self) +impl ScriptPredeployLibraries { + pub fn libraries_count(&self) -> usize { + match self { + Self::Default(libs) => libs.len(), + Self::Create2(libs, _) => libs.len(), + } } } /// Container for the linked contracts and their dependencies +#[derive(Debug)] pub struct LinkedBuildData { /// Original build data, might be used to relink this object with different libraries. pub build_data: BuildData, @@ -84,30 +123,27 @@ pub struct LinkedBuildData { /// Libraries used to link the contracts. pub libraries: Libraries, /// Libraries that need to be deployed by sender before script execution. - pub predeploy_libraries: Vec, + pub predeploy_libraries: ScriptPredeployLibraries, /// Source files of the contracts. Used by debugger. pub sources: ContractSources, } impl LinkedBuildData { - pub fn new(link_output: LinkOutput, build_data: BuildData) -> Result { + pub fn new( + libraries: Libraries, + predeploy_libraries: ScriptPredeployLibraries, + build_data: BuildData, + ) -> Result { let sources = ContractSources::from_project_output( &build_data.output, &build_data.project_root, - &link_output.libraries, + &libraries, )?; - let known_contracts = ContractsByArtifact::new( - build_data.get_linker().get_linked_artifacts(&link_output.libraries)?, - ); + let known_contracts = + ContractsByArtifact::new(build_data.get_linker().get_linked_artifacts(&libraries)?); - Ok(Self { - build_data, - known_contracts, - libraries: link_output.libraries, - predeploy_libraries: link_output.libs_to_deploy, - sources, - }) + Ok(Self { build_data, known_contracts, libraries, predeploy_libraries, sources }) } /// Fetches target bytecode from linked contracts. @@ -212,13 +248,10 @@ pub struct CompiledState { impl CompiledState { /// Uses provided sender address to compute library addresses and link contracts with them. - pub fn link(self) -> Result { + pub async fn link(self) -> Result { let Self { args, script_config, script_wallets, build_data } = self; - let sender = script_config.evm_opts.sender; - let nonce = script_config.sender_nonce; - let known_libraries = script_config.config.libraries_with_remappings()?; - let build_data = build_data.link(known_libraries, sender, nonce)?; + let build_data = build_data.link(&script_config).await?; Ok(LinkedState { args, script_config, script_wallets, build_data }) } @@ -269,7 +302,7 @@ impl CompiledState { if !froms.all(|from| available_signers.contains(&from)) { // IF we are missing required signers, execute script as we might need to collect // private keys from the execution. - let executed = self.link()?.prepare_execution().await?.execute().await?; + let executed = self.link().await?.prepare_execution().await?.execute().await?; ( executed.args, executed.build_data.build_data, diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 9e988c09b50a4..a0c8397ca2682 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -9,7 +9,6 @@ use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; use alloy_primitives::{Address, Bytes}; use alloy_provider::Provider; -use alloy_rpc_types::request::TransactionRequest; use async_recursion::async_recursion; use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; @@ -23,7 +22,7 @@ use foundry_config::{Config, NamedChain}; use foundry_debugger::Debugger; use foundry_evm::{ decode::decode_console_logs, - inspectors::cheatcodes::{BroadcastableTransaction, BroadcastableTransactions}, + inspectors::cheatcodes::BroadcastableTransactions, traces::{ identifier::{SignaturesIdentifier, TraceIdentifiers}, render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, @@ -44,6 +43,7 @@ pub struct LinkedState { } /// Container for data we need for execution which can only be obtained after linking stage. +#[derive(Debug)] pub struct ExecutionData { /// Function to call. pub func: Function, @@ -80,6 +80,7 @@ impl LinkedState { } /// Same as [LinkedState], but also contains [ExecutionData]. +#[derive(Debug)] pub struct PreExecutionState { pub args: ScriptArgs, pub script_config: ScriptConfig, @@ -102,7 +103,7 @@ impl PreExecutionState { self.build_data.build_data.target.clone(), ) .await?; - let mut result = self.execute_with_runner(&mut runner).await?; + let result = self.execute_with_runner(&mut runner).await?; // If we have a new sender from execution, we need to use it to deploy libraries and relink // contracts. @@ -117,28 +118,7 @@ impl PreExecutionState { build_data: self.build_data.build_data, }; - return state.link()?.prepare_execution().await?.execute().await; - } - - // Add library deployment transactions to broadcastable transactions list. - if let Some(txs) = result.transactions.take() { - result.transactions = Some( - self.build_data - .predeploy_libraries - .iter() - .enumerate() - .map(|(i, bytes)| BroadcastableTransaction { - rpc: self.script_config.evm_opts.fork_url.clone(), - transaction: TransactionRequest { - from: Some(self.script_config.evm_opts.sender), - input: Some(bytes.clone()).into(), - nonce: Some(self.script_config.sender_nonce + i as u64), - ..Default::default() - }, - }) - .chain(txs) - .collect(), - ); + return state.link().await?.prepare_execution().await?.execute().await; } Ok(ExecutedState { @@ -200,7 +180,7 @@ impl PreExecutionState { if let Some(txs) = transactions { // If the user passed a `--sender` don't check anything. - if !self.build_data.predeploy_libraries.is_empty() && + if self.build_data.predeploy_libraries.libraries_count() > 0 && self.args.evm_opts.sender.is_none() { for tx in txs.iter() { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 6445b845044c5..7b84802b1183a 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -228,7 +228,8 @@ impl ScriptArgs { } else { // Drive state machine to point at which we have everything needed for simulation. let pre_simulation = compiled - .link()? + .link() + .await? .prepare_execution() .await? .execute() @@ -600,11 +601,7 @@ impl ScriptConfig { }); } - Ok(ScriptRunner::new( - builder.build(env, db), - self.evm_opts.initial_balance, - self.evm_opts.sender, - )) + Ok(ScriptRunner::new(builder.build(env, db), self.evm_opts.clone())) } } diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 901e5e58a87b3..0321d0c5ec1db 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -1,32 +1,36 @@ use super::ScriptResult; -use alloy_primitives::{Address, Bytes, U256}; +use crate::build::ScriptPredeployLibraries; +use alloy_primitives::{Address, Bytes, TxKind, U256}; +use alloy_rpc_types::TransactionRequest; use eyre::Result; +use foundry_cheatcodes::BroadcastableTransaction; use foundry_config::Config; use foundry_evm::{ - constants::CALLER, + constants::{CALLER, DEFAULT_CREATE2_DEPLOYER}, executors::{DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, + opts::EvmOpts, revm::interpreter::{return_ok, InstructionResult}, traces::{TraceKind, Traces}, }; +use std::collections::VecDeque; use yansi::Paint; /// Drives script execution #[derive(Debug)] pub struct ScriptRunner { pub executor: Executor, - pub initial_balance: U256, - pub sender: Address, + pub evm_opts: EvmOpts, } impl ScriptRunner { - pub fn new(executor: Executor, initial_balance: U256, sender: Address) -> Self { - Self { executor, initial_balance, sender } + pub fn new(executor: Executor, evm_opts: EvmOpts) -> Self { + Self { executor, evm_opts } } /// Deploys the libraries and broadcast contract. Calls setUp method if requested. pub fn setup( &mut self, - libraries: &[Bytes], + libraries: &ScriptPredeployLibraries, code: Bytes, setup: bool, sender_nonce: u64, @@ -36,9 +40,9 @@ impl ScriptRunner { trace!(target: "script", "executing setUP()"); if !is_broadcast { - if self.sender == Config::DEFAULT_SENDER { + if self.evm_opts.sender == Config::DEFAULT_SENDER { // We max out their balance so that they can deploy and make calls. - self.executor.set_balance(self.sender, U256::MAX)?; + self.executor.set_balance(self.evm_opts.sender, U256::MAX)?; } if need_create2_deployer { @@ -46,29 +50,86 @@ impl ScriptRunner { } } - self.executor.set_nonce(self.sender, sender_nonce)?; + self.executor.set_nonce(self.evm_opts.sender, sender_nonce)?; // We max out their balance so that they can deploy and make calls. self.executor.set_balance(CALLER, U256::MAX)?; + let mut library_transactions = VecDeque::new(); + let mut traces = Traces::default(); + // Deploy libraries - let mut traces: Traces = libraries - .iter() - .filter_map(|code| { - self.executor - .deploy(self.sender, code.clone(), U256::ZERO, None) + match libraries { + ScriptPredeployLibraries::Default(libraries) => libraries.iter().for_each(|code| { + let result = self + .executor + .deploy(self.evm_opts.sender, code.clone(), U256::ZERO, None) .expect("couldn't deploy library") - .raw - .traces - }) - .map(|traces| (TraceKind::Deployment, traces)) - .collect(); + .raw; + + if let Some(deploy_traces) = result.traces { + traces.push((TraceKind::Deployment, deploy_traces)); + } + + library_transactions.push_back(BroadcastableTransaction { + rpc: self.evm_opts.fork_url.clone(), + transaction: TransactionRequest { + from: Some(self.evm_opts.sender), + input: Some(code.clone()).into(), + nonce: Some(sender_nonce + library_transactions.len() as u64), + ..Default::default() + }, + }) + }), + ScriptPredeployLibraries::Create2(libraries, salt) => { + for library in libraries { + let address = + DEFAULT_CREATE2_DEPLOYER.create2_from_code(salt, library.as_ref()); + // Skip if already deployed + if !self.executor.is_empty_code(address)? { + continue; + } + let calldata = [salt.as_ref(), library.as_ref()].concat(); + let result = self + .executor + .call_raw_committing( + self.evm_opts.sender, + DEFAULT_CREATE2_DEPLOYER, + calldata.clone().into(), + U256::from(0), + ) + .expect("couldn't deploy library"); + + if let Some(deploy_traces) = result.traces { + traces.push((TraceKind::Deployment, deploy_traces)); + } + + library_transactions.push_back(BroadcastableTransaction { + rpc: self.evm_opts.fork_url.clone(), + transaction: TransactionRequest { + from: Some(self.evm_opts.sender), + input: Some(calldata.into()).into(), + nonce: Some(sender_nonce + library_transactions.len() as u64), + to: Some(TxKind::Call(DEFAULT_CREATE2_DEPLOYER)), + ..Default::default() + }, + }); + } + + // Sender nonce is not incremented when performing CALLs. We need to manually + // increase it. + self.executor.set_nonce( + self.evm_opts.sender, + sender_nonce + library_transactions.len() as u64, + )?; + } + }; let address = CALLER.create(self.executor.get_nonce(CALLER)?); // Set the contracts initial balance before deployment, so it is available during the // construction - self.executor.set_balance(address, self.initial_balance)?; + self.executor.set_balance(address, self.evm_opts.initial_balance)?; // Deploy an instance of the contract let DeployResult { @@ -85,9 +146,15 @@ impl ScriptRunner { // Optionally call the `setUp` function let (success, gas_used, labeled_addresses, transactions, debug) = if !setup { self.executor.backend.set_test_contract(address); - (true, 0, Default::default(), None, vec![constructor_debug].into_iter().collect()) + ( + true, + 0, + Default::default(), + Some(library_transactions), + vec![constructor_debug].into_iter().collect(), + ) } else { - match self.executor.setup(Some(self.sender), address, None) { + match self.executor.setup(Some(self.evm_opts.sender), address, None) { Ok(RawCallResult { reverted, traces: setup_traces, @@ -95,17 +162,21 @@ impl ScriptRunner { logs: setup_logs, debug, gas_used, - transactions, + transactions: setup_transactions, .. }) => { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend_from_slice(&setup_logs); + if let Some(txs) = setup_transactions { + library_transactions.extend(txs); + } + ( !reverted, gas_used, labels, - transactions, + Some(library_transactions), vec![constructor_debug, debug].into_iter().collect(), ) } @@ -123,11 +194,15 @@ impl ScriptRunner { traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend_from_slice(&setup_logs); + if let Some(txs) = transactions { + library_transactions.extend(txs); + } + ( !reverted, gas_used, labels, - transactions, + Some(library_transactions), vec![constructor_debug, debug].into_iter().collect(), ) } @@ -154,7 +229,7 @@ impl ScriptRunner { /// Executes the method that will collect all broadcastable transactions. pub fn script(&mut self, address: Address, calldata: Bytes) -> Result { - self.call(self.sender, address, calldata, U256::ZERO, false) + self.call(self.evm_opts.sender, address, calldata, U256::ZERO, false) } /// Runs a broadcastable transaction locally and persists its state. diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index b14ba2a54f358..8b625d6eed9ab 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -4,11 +4,41 @@ use alloy_provider::Provider; use alloy_rpc_types::BlockId; use eyre::Result; use foundry_common::provider::{get_http_provider, RetryProvider}; -use std::{collections::BTreeMap, fs, path::Path, str::FromStr}; +use std::{ + collections::BTreeMap, + fs, + path::{Path, PathBuf}, + str::FromStr, +}; const BROADCAST_TEST_PATH: &str = "src/Broadcast.t.sol"; const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); +fn init_script_cmd( + cmd: &mut TestCommand, + project_root: &Path, + target_contract: &str, + endpoint: Option<&str>, +) { + cmd.forge_fuse(); + cmd.set_current_dir(project_root); + + cmd.args([ + "script", + "-R", + "ds-test/=lib/", + "-R", + "cheats/=cheats/", + target_contract, + "--root", + project_root.to_str().unwrap(), + "-vvvvv", + ]); + + if let Some(rpc_url) = endpoint { + cmd.args(["--fork-url", rpc_url]); + } +} /// A helper struct to test forge script scenarios pub struct ScriptTester { pub accounts_pub: Vec
, @@ -17,6 +47,9 @@ pub struct ScriptTester { pub nonces: BTreeMap, pub address_nonces: BTreeMap, pub cmd: TestCommand, + pub project_root: PathBuf, + pub target_contract: String, + pub endpoint: Option, } impl ScriptTester { @@ -29,23 +62,10 @@ impl ScriptTester { ) -> Self { init_tracing(); ScriptTester::copy_testdata(project_root).unwrap(); - cmd.set_current_dir(project_root); - - cmd.args([ - "script", - "-R", - "ds-test/=lib/", - "-R", - "cheats/=cheats/", - target_contract, - "--root", - project_root.to_str().unwrap(), - "-vvvvv", - ]); + init_script_cmd(&mut cmd, project_root, target_contract, endpoint); let mut provider = None; if let Some(endpoint) = endpoint { - cmd.args(["--fork-url", endpoint]); provider = Some(get_http_provider(endpoint)) } @@ -64,6 +84,9 @@ impl ScriptTester { nonces: BTreeMap::default(), address_nonces: BTreeMap::default(), cmd, + project_root: project_root.to_path_buf(), + target_contract: target_contract.to_string(), + endpoint: endpoint.map(|s| s.to_string()), } } @@ -243,6 +266,17 @@ impl ScriptTester { self.cmd.args(args); self } + + pub fn clear(&mut self) { + init_script_cmd( + &mut self.cmd, + &self.project_root, + &self.target_contract, + self.endpoint.as_deref(), + ); + self.nonces.clear(); + self.address_nonces.clear(); + } } /// Various `forge` script results From 12eaec8dbe04625381d974fa0ea2c8a03230d082 Mon Sep 17 00:00:00 2001 From: bixia <343224563@qq.com> Date: Wed, 15 May 2024 02:54:09 +0800 Subject: [PATCH 0964/1963] forge(verify): OKLink support (#7915) * update * Update provider.rs remove the requirement * cargo fmt --- crates/verify/src/provider.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index d5721018dce84..deac48229b028 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -33,6 +33,7 @@ impl FromStr for VerificationProviderType { "e" | "etherscan" => Ok(VerificationProviderType::Etherscan), "s" | "sourcify" => Ok(VerificationProviderType::Sourcify), "b" | "blockscout" => Ok(VerificationProviderType::Blockscout), + "o" | "oklink" => Ok(VerificationProviderType::Oklink), _ => Err(format!("Unknown provider: {s}")), } } @@ -50,6 +51,9 @@ impl fmt::Display for VerificationProviderType { VerificationProviderType::Blockscout => { write!(f, "blockscout")?; } + VerificationProviderType::Oklink => { + write!(f, "oklink")?; + } }; Ok(()) } @@ -61,6 +65,7 @@ pub enum VerificationProviderType { Etherscan, Sourcify, Blockscout, + Oklink, } impl VerificationProviderType { @@ -79,6 +84,7 @@ impl VerificationProviderType { VerificationProviderType::Blockscout => { Ok(Box::::default()) } + VerificationProviderType::Oklink => Ok(Box::::default()), } } } From 7469d79cca59e0bb5f23563ac5a6bd5f2ec8c5e4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 14 May 2024 21:25:47 +0200 Subject: [PATCH 0965/1963] chore(deps): bump chains (#7927) --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 796e47fbd43a1..52a36a589dc4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,9 +67,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6c2674230e94ea98767550b02853bf7024b46f784827be95acfc5f5f1a445f" +checksum = "03fd095a9d70f4b1c5c102c84a4c782867a5c6416dbf6dcd42a63e7c7a89d3c8" dependencies = [ "num_enum", "serde", From a470d635cfcdce68609e9dc5762a3584351bacc1 Mon Sep 17 00:00:00 2001 From: Azleal Date: Wed, 15 May 2024 17:40:59 +0800 Subject: [PATCH 0966/1963] fix: fuzz console log (#7781) * fix fuzz console * test case * fuzz console * remove clone --- crates/evm/evm/src/executors/fuzz/mod.rs | 16 ++++++++--- crates/evm/evm/src/executors/fuzz/types.rs | 4 ++- crates/forge/tests/cli/test_cmd.rs | 31 +++++++++++++++++++++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index d81ddbaca01b3..1adabc5fd98dd 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,7 +1,7 @@ use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{Address, Bytes, Log, U256}; use eyre::Result; use foundry_config::FuzzConfig; use foundry_evm_core::{ @@ -87,6 +87,9 @@ impl FuzzedExecutor { dictionary_weight => fuzz_calldata_from_state(func.clone(), &state), ]; + //Stores logs for all fuzz cases + let logs: RefCell> = RefCell::default(); + debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; @@ -104,6 +107,7 @@ impl FuzzedExecutor { } traces.borrow_mut().push(call_traces); } + logs.borrow_mut().extend(case.logs); if let Some(prev) = coverage.take() { // Safety: If `Option::or` evaluates to `Some`, then `call.coverage` must @@ -127,6 +131,7 @@ impl FuzzedExecutor { // to run at least one more case to find a minimal failure // case. let call_res = _counterexample.1.result.clone(); + logs.borrow_mut().extend(_counterexample.1.logs.clone()); *counterexample.borrow_mut() = _counterexample; // HACK: we have to use an empty string here to denote `None` let reason = rd.maybe_decode(&call_res, Some(status)); @@ -140,14 +145,16 @@ impl FuzzedExecutor { let mut traces = traces.into_inner(); let last_run_traces = if run_result.is_ok() { traces.pop() } else { call.traces.clone() }; + let inner_logs = logs.into_inner(); + let mut result = FuzzTestResult { first_case: first_case.take().unwrap_or_default(), gas_by_case: gas_by_case.take(), success: run_result.is_ok(), reason: None, counterexample: None, - decoded_logs: decode_console_logs(&call.logs), - logs: call.logs, + decoded_logs: decode_console_logs(&inner_logs), + logs: inner_logs, labeled_addresses: call.labels, traces: last_run_traces, gas_report_traces: traces, @@ -207,7 +214,7 @@ impl FuzzedExecutor { // When the `assume` cheatcode is called it returns a special string if call.result.as_ref() == MAGIC_ASSUME { - return Err(TestCaseError::reject(FuzzError::AssumeReject)) + return Err(TestCaseError::reject(FuzzError::AssumeReject)); } let breakpoints = call @@ -229,6 +236,7 @@ impl FuzzedExecutor { coverage: call.coverage, debug: call.debug, breakpoints, + logs: call.logs, })) } else { Ok(FuzzOutcome::CounterExample(CounterExampleOutcome { diff --git a/crates/evm/evm/src/executors/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs index b15cf3faae3ca..3791165ca62c8 100644 --- a/crates/evm/evm/src/executors/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -1,5 +1,5 @@ use crate::executors::RawCallResult; -use alloy_primitives::Bytes; +use alloy_primitives::{Bytes, Log}; use foundry_common::evm::Breakpoints; use foundry_evm_core::debug::DebugArena; use foundry_evm_coverage::HitMaps; @@ -20,6 +20,8 @@ pub struct CaseOutcome { pub debug: Option, /// Breakpoints char pc map pub breakpoints: Breakpoints, + /// logs of a single fuzz test case + pub logs: Vec, } /// Returned by a single fuzz when a counterexample has been discovered diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 2b0784d6a27d0..5fe9b388ac74a 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,6 +1,6 @@ //! Contains various tests for `forge test`. -use foundry_config::Config; +use foundry_config::{Config, FuzzConfig}; use foundry_test_utils::{ rpc, util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, @@ -544,3 +544,32 @@ contract Dummy { cmd.args(["test", "--match-path", "src/dummy.sol"]); cmd.assert_success() }); + +// tests that `forge test` for fuzz tests will display `console.log` info +forgetest_init!(can_test_fuzz_with_console_log, |prj, cmd| { + prj.wipe_contracts(); + + // run fuzz test 3 times + let config = + Config { fuzz: { FuzzConfig { runs: 3, ..Default::default() } }, ..Default::default() }; + prj.write_config(config); + let config = cmd.config(); + assert_eq!(config.fuzz.runs, 3); + + prj.add_test( + "ContractFuzz.t.sol", + r#"pragma solidity 0.8.24; + import {Test, console2} from "forge-std/Test.sol"; + + contract ContractFuzz is Test { + function testFuzzConsoleLog(uint256 x) public { + console2.log("inside fuzz test, x is:", x); + } + } + "#, + ) + .unwrap(); + cmd.args(["test", "-vv"]); + let stdout = cmd.stdout_lossy(); + assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); +}); From 48e5d112f7675d1bb5b8fd3fa2d1ae7df4bd8245 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 16 May 2024 10:16:21 -0400 Subject: [PATCH 0967/1963] bump alloy f415827 --- Cargo.lock | 217 ++++++++++++++++++--------- Cargo.toml | 51 ++++--- crates/anvil/src/eth/backend/fork.rs | 19 ++- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/mktx.rs | 5 +- crates/cast/bin/cmd/send.rs | 10 +- crates/cast/bin/cmd/storage.rs | 9 +- crates/cast/bin/main.rs | 3 +- crates/cast/bin/tx.rs | 4 +- crates/cast/src/lib.rs | 42 ++++-- crates/evm/core/src/fork/backend.rs | 14 +- crates/forge/bin/cmd/create.rs | 4 +- crates/script/src/broadcast.rs | 7 +- crates/script/src/build.rs | 3 +- crates/test-utils/src/script.rs | 12 +- crates/verify/src/bytecode.rs | 13 +- 16 files changed, 270 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52a36a589dc4c..6eb52da314476 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,10 +81,23 @@ name = "alloy-consensus" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-eips", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "c-kzg", + "serde", +] + +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +dependencies = [ + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "c-kzg", "serde", ] @@ -92,7 +105,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -100,7 +113,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-pubsub", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-sol-types", "alloy-transport", "futures", @@ -136,7 +149,21 @@ source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1 dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "c-kzg", + "once_cell", + "serde", + "sha2", +] + +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "c-kzg", "derive_more", "once_cell", @@ -150,7 +177,18 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-genesis" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +dependencies = [ + "alloy-primitives", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "serde", "serde_json", ] @@ -170,7 +208,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-primitives", "serde", @@ -182,13 +220,13 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-json-rpc", "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-signer", "alloy-sol-types", "async-trait", @@ -226,16 +264,16 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ - "alloy-eips", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-json-rpc", "alloy-network", "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types", - "alloy-rpc-types-trace", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-transport", "alloy-transport-http", "alloy-transport-ipc", @@ -247,6 +285,7 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", + "pin-project", "reqwest", "serde_json", "tokio", @@ -257,7 +296,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -297,7 +336,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -323,12 +362,30 @@ name = "alloy-rpc-types" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus", - "alloy-eips", - "alloy-genesis", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-sol-types", + "itertools 0.12.1", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +dependencies = [ + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-sol-types", "itertools 0.12.1", "serde", @@ -339,14 +396,14 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types", - "alloy-serde", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "jsonwebtoken", "rand", "serde", @@ -359,8 +416,20 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", - "alloy-rpc-types", - "alloy-serde", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-rpc-types-trace" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "serde", "serde_json", ] @@ -375,10 +444,20 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-serde" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", +] + [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -393,9 +472,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-network", "alloy-primitives", "alloy-signer", @@ -410,9 +489,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -429,9 +508,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-network", "alloy-primitives", "alloy-signer", @@ -445,9 +524,9 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-network", "alloy-primitives", "alloy-signer", @@ -522,7 +601,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -540,7 +619,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -554,7 +633,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -574,7 +653,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -691,11 +770,11 @@ name = "anvil" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-contract", "alloy-dyn-abi", - "alloy-eips", - "alloy-genesis", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-json-abi", "alloy-json-rpc", "alloy-network", @@ -704,8 +783,8 @@ dependencies = [ "alloy-pubsub", "alloy-rlp", "alloy-rpc-client", - "alloy-rpc-types", - "alloy-rpc-types-trace", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", @@ -759,15 +838,15 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-dyn-abi", - "alloy-eips", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-network", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types", - "alloy-rpc-types-trace", - "alloy-serde", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-trie", "anvil-core", "bytes", @@ -1729,7 +1808,7 @@ name = "cast" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -1738,7 +1817,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rlp", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", @@ -1822,7 +1901,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "clap", "criterion", "dirs 5.0.1", @@ -3064,13 +3143,13 @@ name = "forge" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-dyn-abi", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-signer", "alloy-signer-wallet", "alloy-transport", @@ -3189,12 +3268,12 @@ version = "0.2.0" dependencies = [ "alloy-chains", "alloy-dyn-abi", - "alloy-eips", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-signer", "alloy-transport", "async-recursion", @@ -3233,7 +3312,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-provider", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "async-trait", "clap", "const-hex", @@ -3291,11 +3370,11 @@ name = "foundry-cheatcodes" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-genesis", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-json-abi", "alloy-primitives", "alloy-provider", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", @@ -3376,7 +3455,7 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -3385,7 +3464,7 @@ dependencies = [ "alloy-provider", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-rpc-types-engine", "alloy-sol-types", "alloy-transport", @@ -3543,11 +3622,11 @@ name = "foundry-evm-core" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-genesis", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-json-abi", "alloy-primitives", "alloy-provider", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-sol-types", "alloy-transport", "arrayvec", @@ -3667,7 +3746,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-provider", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "eyre", "fd-lock 4.0.2", "foundry-common", @@ -3688,7 +3767,7 @@ dependencies = [ name = "foundry-wallets" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -6362,8 +6441,8 @@ version = "0.1.0" source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=c1b5dd0#c1b5dd0d85dd46ef5ec5258aebd24adc041d103a" dependencies = [ "alloy-primitives", - "alloy-rpc-types", - "alloy-rpc-types-trace", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", "alloy-sol-types", "anstyle", "colorchoice", diff --git a/Cargo.toml b/Cargo.toml index a807d1983c4c7..d4a3f6403e64c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,29 +152,29 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" @@ -188,7 +188,10 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index a9cc1cd9de461..dfaa92c62b6fc 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -163,7 +163,10 @@ impl ClientFork { keys: Vec, block_number: Option, ) -> Result { - self.provider().get_proof(address, keys, block_number.unwrap_or(BlockId::latest())).await + self.provider() + .get_proof(address, keys) + .block_id(block_number.unwrap_or(BlockId::latest())) + .await } /// Sends `eth_call` @@ -185,7 +188,7 @@ impl ClientFork { block: Option, ) -> Result { let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().estimate_gas(request, block.into()).await?; + let res = self.provider().estimate_gas(request).block_id(block.into()).await?; Ok(res) } @@ -197,7 +200,8 @@ impl ClientFork { block: Option, ) -> Result { self.provider() - .create_access_list(request, block.unwrap_or(BlockNumber::Latest).into()) + .create_access_list(request) + .block_id(block.unwrap_or(BlockNumber::Latest).into()) .await } @@ -208,7 +212,8 @@ impl ClientFork { number: Option, ) -> Result { self.provider() - .get_storage_at(address, index, number.unwrap_or(BlockNumber::Latest).into()) + .get_storage_at(address, index) + .block_id(number.unwrap_or(BlockNumber::Latest).into()) .await } @@ -236,7 +241,7 @@ impl ClientFork { let block_id = BlockId::Number(blocknumber.into()); - let code = self.provider().get_code_at(address, block_id).await?; + let code = self.provider().get_code_at(address).block_id(block_id).await?; let mut storage = self.storage_write(); storage.code_at.insert((address, blocknumber), code.clone().0.into()); @@ -250,12 +255,12 @@ impl ClientFork { blocknumber: u64, ) -> Result { trace!(target: "backend::fork", "get_balance={:?}", address); - self.provider().get_balance(address, blocknumber.into()).await + self.provider().get_balance(address).block_id(blocknumber.into()).await } pub async fn get_nonce(&self, address: Address, block: u64) -> Result { trace!(target: "backend::fork", "get_nonce={:?}", address); - self.provider().get_transaction_count(address, block.into()).await + self.provider().get_transaction_count(address).block_id(block.into()).await } pub async fn transaction_by_block_number_and_index( diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 33f375f9c3ec5..0627e41255ad3 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -128,7 +128,7 @@ impl EstimateArgs { req.set_input(data); - let gas = provider.estimate_gas(&req, BlockId::latest()).await?; + let gas = provider.estimate_gas(&req).block_id(BlockId::latest()).await?; println!("{gas}"); Ok(()) } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index e26115da32ab5..bfef0a898b28e 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -90,8 +90,9 @@ impl MakeTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = - Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); + tx.nonce = Some(U64::from( + provider.get_transaction_count(from).block_id(BlockId::latest()).await?, + )); } let provider = get_provider(&config)?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 7799f522691d8..2997bfb88b7ec 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -144,7 +144,10 @@ impl SendTxArgs { if resend { tx.nonce = Some(U64::from( - provider.get_transaction_count(config.sender, BlockId::latest()).await?, + provider + .get_transaction_count(config.sender) + .block_id(BlockId::latest()) + .await?, )); } @@ -175,8 +178,9 @@ impl SendTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = - Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); + tx.nonce = Some(U64::from( + provider.get_transaction_count(from).block_id(BlockId::latest()).await?, + )); } let signer = EthereumSigner::from(signer); diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 6197e40c96e54..a59d93c5d1047 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -95,7 +95,8 @@ impl StorageArgs { // No slot was provided // Get deployed bytecode at given address - let address_code = provider.get_code_at(address, block.unwrap_or_default()).await?; + let address_code = + provider.get_code_at(address).block_id(block.unwrap_or_default()).await?; if address_code.is_empty() { eyre::bail!("Provided address has no deployed code and thus no storage"); } @@ -237,8 +238,10 @@ async fn fetch_storage_slots, T: Transport + Clone>( ) -> Result> { let requests = layout.storage.iter().map(|storage_slot| async { let slot = B256::from(U256::from_str(&storage_slot.slot)?); - let raw_slot_value = - provider.get_storage_at(address, slot.into(), block.unwrap_or_default()).await?; + let raw_slot_value = provider + .get_storage_at(address, slot.into()) + .block_id(block.unwrap_or_default()) + .await?; let value = StorageValue { slot, raw_slot_value: raw_slot_value.into() }; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 30bb1205e56ef..500c831d158ff 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -351,7 +351,8 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let address = address.resolve(&provider).await?; let value = provider - .get_proof(address, slots.into_iter().collect(), block.unwrap_or(BlockId::latest())) + .get_proof(address, slots.into_iter().collect()) + .block_id(block.unwrap_or(BlockId::latest())) .await?; println!("{}", serde_json::to_string(&value)?); } diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 64b33b280712f..80ce6e04b6466 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -71,7 +71,7 @@ pub async fn build_tx< req.set_nonce(if let Some(nonce) = tx.nonce { nonce.to() } else { - provider.get_transaction_count(from, BlockId::latest()).await? + provider.get_transaction_count(from).block_id(BlockId::latest()).await? }); if tx.legacy || chain.is_legacy() { @@ -119,7 +119,7 @@ pub async fn build_tx< req.set_gas_limit(if let Some(gas_limit) = tx.gas_limit { gas_limit.to() } else { - provider.estimate_gas(&req, BlockId::latest()).await? + provider.estimate_gas(&req).block_id(BlockId::latest()).await? }); Ok((req, func)) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index e2f706b74dac0..e9c8cb7b26bad 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -133,8 +133,11 @@ where if res.is_empty() { // check that the recipient is a contract that can be called if let Some(TxKind::Call(addr)) = req.to { - if let Ok(code) = - self.provider.get_code_at(addr, block.unwrap_or_default()).await + if let Ok(code) = self + .provider + .get_code_at(addr) + .block_id(block.unwrap_or_default()) + .await { if code.is_empty() { eyre::bail!("contract {addr:?} does not have any code") @@ -197,8 +200,11 @@ where block: Option, to_json: bool, ) -> Result { - let access_list = - self.provider.create_access_list(req, block.unwrap_or(BlockId::latest())).await?; + let access_list = self + .provider + .create_access_list(req) + .block_id(block.unwrap_or(BlockId::latest())) + .await?; let res = if to_json { serde_json::to_string(&access_list)? } else { @@ -220,7 +226,7 @@ where } pub async fn balance(&self, who: Address, block: Option) -> Result { - Ok(self.provider.get_balance(who, block.unwrap_or(BlockId::latest())).await?) + Ok(self.provider.get_balance(who).block_id(block.unwrap_or(BlockId::latest())).await?) } /// Sends a transaction to the specified address @@ -472,7 +478,11 @@ where /// # } /// ``` pub async fn nonce(&self, who: Address, block: Option) -> Result { - Ok(self.provider.get_transaction_count(who, block.unwrap_or(BlockId::latest())).await?) + Ok(self + .provider + .get_transaction_count(who) + .block_id(block.unwrap_or(BlockId::latest())) + .await?) } /// # Example @@ -498,7 +508,8 @@ where B256::from_str("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")?; let value = self .provider - .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) + .get_storage_at(who, slot.into()) + .block_id(block.unwrap_or(BlockId::latest())) .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) @@ -527,7 +538,8 @@ where B256::from_str("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")?; let value = self .provider - .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) + .get_storage_at(who, slot.into()) + .block_id(block.unwrap_or(BlockId::latest())) .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) @@ -581,10 +593,14 @@ where disassemble: bool, ) -> Result { if disassemble { - let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); + let code = + self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await?.to_vec(); Ok(format_operations(disassemble_bytes(code)?)?) } else { - Ok(format!("{}", self.provider.get_code_at(who, block.unwrap_or_default()).await?)) + Ok(format!( + "{}", + self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await? + )) } } @@ -607,7 +623,8 @@ where /// # } /// ``` pub async fn codesize(&self, who: Address, block: Option) -> Result { - let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); + let code = + self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await?.to_vec(); Ok(format!("{}", code.len())) } @@ -773,7 +790,8 @@ where "{:?}", B256::from( self.provider - .get_storage_at(from, slot.into(), block.unwrap_or(BlockId::latest())) + .get_storage_at(from, slot.into()) + .block_id(block.unwrap_or_default()) .await? ) )) diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 2ab9bdc9bdb49..f2e4d15c325b5 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -22,6 +22,7 @@ use revm::{ use rustc_hash::FxHashMap; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, + future::IntoFuture, marker::PhantomData, pin::Pin, sync::{ @@ -189,8 +190,11 @@ where let provider = self.provider.clone(); let block_id = self.block_id.unwrap_or(BlockId::latest()); let fut = Box::pin(async move { - let storage = - provider.get_storage_at(address, idx, block_id).await.map_err(Into::into); + let storage = provider + .get_storage_at(address, idx) + .block_id(block_id) + .await + .map_err(Into::into); (storage, address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); @@ -204,9 +208,9 @@ where let provider = self.provider.clone(); let block_id = self.block_id.unwrap_or(BlockId::latest()); let fut = Box::pin(async move { - let balance = provider.get_balance(address, block_id); - let nonce = provider.get_transaction_count(address, block_id); - let code = provider.get_code_at(address, block_id); + let balance = provider.get_balance(address).block_id(block_id).into_future(); + let nonce = provider.get_transaction_count(address).block_id(block_id).into_future(); + let code = provider.get_code_at(address).block_id(block_id).into_future(); let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); (resp, address) }); diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 460dbdea70ed0..02e68213af9ce 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -239,7 +239,7 @@ impl CreateArgs { deployer.tx.set_nonce(if let Some(nonce) = self.tx.nonce { Ok(nonce.to()) } else { - provider.get_transaction_count(deployer_address, BlockId::latest()).await + provider.get_transaction_count(deployer_address).block_id(BlockId::latest()).await }?); // set tx value if specified @@ -250,7 +250,7 @@ impl CreateArgs { deployer.tx.set_gas_limit(if let Some(gas_limit) = self.tx.gas_limit { Ok(gas_limit.to()) } else { - provider.estimate_gas(&deployer.tx, BlockId::latest()).await + provider.estimate_gas(&deployer.tx).block_id(BlockId::latest()).await }?); if is_legacy { diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index a278e44d75917..39bf392897cc2 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -44,7 +44,8 @@ where tx.set_gas_limit( provider - .estimate_gas(tx, BlockId::latest()) + .estimate_gas(tx) + .block_id(BlockId::latest()) .await .wrap_err("Failed to estimate gas for tx")? * estimate_multiplier as u128 / @@ -56,7 +57,7 @@ where pub async fn next_nonce(caller: Address, provider_url: &str) -> eyre::Result { let provider = try_get_http_provider(provider_url) .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; - Ok(provider.get_transaction_count(caller, BlockId::latest()).await?) + Ok(provider.get_transaction_count(caller).block_id(BlockId::latest()).await?) } pub async fn send_transaction( @@ -71,7 +72,7 @@ pub async fn send_transaction( let from = tx.from.expect("no sender"); if sequential_broadcast { - let nonce = provider.get_transaction_count(from, BlockId::latest()).await?; + let nonce = provider.get_transaction_count(from).block_id(BlockId::latest()).await?; let tx_nonce = tx.nonce.expect("no nonce"); if nonce != tx_nonce { diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 8d9907ccfebe4..64e1c7539151c 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -7,6 +7,7 @@ use crate::{ }; use alloy_primitives::{Bytes, B256}; use alloy_provider::Provider; +use alloy_rpc_types::BlockId; use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_common::{ @@ -46,7 +47,7 @@ impl BuildData { let can_use_create2 = if let Some(fork_url) = &script_config.evm_opts.fork_url { let provider = try_get_http_provider(fork_url)?; let deployer_code = - provider.get_code_at(DEFAULT_CREATE2_DEPLOYER, Default::default()).await?; + provider.get_code_at(DEFAULT_CREATE2_DEPLOYER).block_id(BlockId::latest()).await?; !deployer_code.is_empty() } else { diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 8b625d6eed9ab..c0331ed9fcbf6 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -141,7 +141,8 @@ impl ScriptTester { if let Some(provider) = &self.provider { let nonce = provider - .get_transaction_count(self.accounts_pub[index as usize], BlockId::latest()) + .get_transaction_count(self.accounts_pub[index as usize]) + .block_id(BlockId::latest()) .await .unwrap(); self.nonces.insert(index, nonce); @@ -156,7 +157,8 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(address, BlockId::latest()) + .get_transaction_count(address) + .block_id(BlockId::latest()) .await .unwrap(); self.address_nonces.insert(address, nonce); @@ -202,7 +204,8 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(addr, BlockId::latest()) + .get_transaction_count(addr) + .block_id(BlockId::latest()) .await .unwrap(); let prev_nonce = self.nonces.get(&private_key_slot).unwrap(); @@ -227,7 +230,8 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(*address, BlockId::latest()) + .get_transaction_count(*address) + .block_id(BlockId::latest()) .await .unwrap(); let prev_nonce = self.address_nonces.get(address).unwrap(); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 53654a7d35e51..da0f805fd0bbe 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -109,7 +109,7 @@ impl VerifyBytecodeArgs { let config = self.load_config_emit_warnings(); let provider = ProviderBuilder::new(&config.get_rpc_url_or_localhost_http()?).build()?; - let code = provider.get_code_at(self.address, BlockId::latest()).await?; + let code = provider.get_code_at(self.address).block_id(BlockId::latest()).await?; if code.is_empty() { eyre::bail!("No bytecode found at address {}", self.address); } @@ -291,8 +291,10 @@ impl VerifyBytecodeArgs { // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same // block. let prev_block_id = BlockId::Number(BlockNumberOrTag::Number(simulation_block - 1)); - let prev_block_nonce = - provider.get_transaction_count(creation_data.contract_creator, prev_block_id).await?; + let prev_block_nonce = provider + .get_transaction_count(creation_data.contract_creator) + .block_id(prev_block_id) + .await?; transaction.nonce = prev_block_nonce; if let Some(ref block) = block { @@ -343,9 +345,8 @@ impl VerifyBytecodeArgs { ) })?; - let onchain_runtime_code = provider - .get_code_at(self.address, BlockId::Number(BlockNumberOrTag::Number(simulation_block))) - .await?; + let onchain_runtime_code = + provider.get_code_at(self.address).block_id(BlockId::number(simulation_block)).await?; // Compare the runtime bytecode with the locally built bytecode let (did_match, with_status) = try_match( From 20feac7ef7a8263d8aa7be5955a83dac9327c30a Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 16 May 2024 10:20:41 -0400 Subject: [PATCH 0968/1963] Revert "bump alloy f415827" This reverts commit 48e5d112f7675d1bb5b8fd3fa2d1ae7df4bd8245. --- Cargo.lock | 217 +++++++++------------------ Cargo.toml | 51 +++---- crates/anvil/src/eth/backend/fork.rs | 19 +-- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/mktx.rs | 5 +- crates/cast/bin/cmd/send.rs | 10 +- crates/cast/bin/cmd/storage.rs | 9 +- crates/cast/bin/main.rs | 3 +- crates/cast/bin/tx.rs | 4 +- crates/cast/src/lib.rs | 42 ++---- crates/evm/core/src/fork/backend.rs | 14 +- crates/forge/bin/cmd/create.rs | 4 +- crates/script/src/broadcast.rs | 7 +- crates/script/src/build.rs | 3 +- crates/test-utils/src/script.rs | 12 +- crates/verify/src/bytecode.rs | 13 +- 16 files changed, 145 insertions(+), 270 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6eb52da314476..52a36a589dc4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,23 +81,10 @@ name = "alloy-consensus" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "c-kzg", - "serde", -] - -[[package]] -name = "alloy-consensus" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" -dependencies = [ - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-serde", "c-kzg", "serde", ] @@ -105,7 +92,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -113,7 +100,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-pubsub", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-sol-types", "alloy-transport", "futures", @@ -149,21 +136,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1 dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "c-kzg", - "once_cell", - "serde", - "sha2", -] - -[[package]] -name = "alloy-eips" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-serde", "c-kzg", "derive_more", "once_cell", @@ -177,18 +150,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "serde", - "serde_json", -] - -[[package]] -name = "alloy-genesis" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" -dependencies = [ - "alloy-primitives", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-serde", "serde", "serde_json", ] @@ -208,7 +170,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", "serde", @@ -220,13 +182,13 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", + "alloy-eips", "alloy-json-rpc", "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-signer", "alloy-sol-types", "async-trait", @@ -264,16 +226,16 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-eips", "alloy-json-rpc", "alloy-network", "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", + "alloy-rpc-types-trace", "alloy-transport", "alloy-transport-http", "alloy-transport-ipc", @@ -285,7 +247,6 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", - "pin-project", "reqwest", "serde_json", "tokio", @@ -296,7 +257,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -336,7 +297,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -362,30 +323,12 @@ name = "alloy-rpc-types" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-consensus", + "alloy-eips", + "alloy-genesis", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "alloy-sol-types", - "itertools 0.12.1", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "alloy-rpc-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" -dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-serde", "alloy-sol-types", "itertools 0.12.1", "serde", @@ -396,14 +339,14 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", + "alloy-serde", "jsonwebtoken", "rand", "serde", @@ -416,20 +359,8 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "serde", - "serde_json", -] - -[[package]] -name = "alloy-rpc-types-trace" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", + "alloy-serde", "serde", "serde_json", ] @@ -444,20 +375,10 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-serde" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" -dependencies = [ - "alloy-primitives", - "serde", - "serde_json", -] - [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -472,9 +393,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", @@ -489,9 +410,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -508,9 +429,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", @@ -524,9 +445,9 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", @@ -601,7 +522,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -619,7 +540,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -633,7 +554,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -653,7 +574,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -770,11 +691,11 @@ name = "anvil" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-contract", "alloy-dyn-abi", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-eips", + "alloy-genesis", "alloy-json-abi", "alloy-json-rpc", "alloy-network", @@ -783,8 +704,8 @@ dependencies = [ "alloy-pubsub", "alloy-rlp", "alloy-rpc-client", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", + "alloy-rpc-types-trace", "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", @@ -838,15 +759,15 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-dyn-abi", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-eips", "alloy-network", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", + "alloy-rpc-types-trace", + "alloy-serde", "alloy-trie", "anvil-core", "bytes", @@ -1808,7 +1729,7 @@ name = "cast" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -1817,7 +1738,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", @@ -1901,7 +1822,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "clap", "criterion", "dirs 5.0.1", @@ -3143,13 +3064,13 @@ name = "forge" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-dyn-abi", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-signer", "alloy-signer-wallet", "alloy-transport", @@ -3268,12 +3189,12 @@ version = "0.2.0" dependencies = [ "alloy-chains", "alloy-dyn-abi", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-eips", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-signer", "alloy-transport", "async-recursion", @@ -3312,7 +3233,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-provider", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "async-trait", "clap", "const-hex", @@ -3370,11 +3291,11 @@ name = "foundry-cheatcodes" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-genesis", "alloy-json-abi", "alloy-primitives", "alloy-provider", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-signer", "alloy-signer-wallet", "alloy-sol-types", @@ -3455,7 +3376,7 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -3464,7 +3385,7 @@ dependencies = [ "alloy-provider", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-rpc-types-engine", "alloy-sol-types", "alloy-transport", @@ -3622,11 +3543,11 @@ name = "foundry-evm-core" version = "0.2.0" dependencies = [ "alloy-dyn-abi", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-genesis", "alloy-json-abi", "alloy-primitives", "alloy-provider", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "alloy-sol-types", "alloy-transport", "arrayvec", @@ -3746,7 +3667,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-provider", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-rpc-types", "eyre", "fd-lock 4.0.2", "foundry-common", @@ -3767,7 +3688,7 @@ dependencies = [ name = "foundry-wallets" version = "0.2.0" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=f415827)", + "alloy-consensus", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -6441,8 +6362,8 @@ version = "0.1.0" source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=c1b5dd0#c1b5dd0d85dd46ef5ec5258aebd24adc041d103a" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", - "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=899fc51)", + "alloy-rpc-types", + "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "colorchoice", diff --git a/Cargo.toml b/Cargo.toml index d4a3f6403e64c..a807d1983c4c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,29 +152,29 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" @@ -188,10 +188,7 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index dfaa92c62b6fc..a9cc1cd9de461 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -163,10 +163,7 @@ impl ClientFork { keys: Vec, block_number: Option, ) -> Result { - self.provider() - .get_proof(address, keys) - .block_id(block_number.unwrap_or(BlockId::latest())) - .await + self.provider().get_proof(address, keys, block_number.unwrap_or(BlockId::latest())).await } /// Sends `eth_call` @@ -188,7 +185,7 @@ impl ClientFork { block: Option, ) -> Result { let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().estimate_gas(request).block_id(block.into()).await?; + let res = self.provider().estimate_gas(request, block.into()).await?; Ok(res) } @@ -200,8 +197,7 @@ impl ClientFork { block: Option, ) -> Result { self.provider() - .create_access_list(request) - .block_id(block.unwrap_or(BlockNumber::Latest).into()) + .create_access_list(request, block.unwrap_or(BlockNumber::Latest).into()) .await } @@ -212,8 +208,7 @@ impl ClientFork { number: Option, ) -> Result { self.provider() - .get_storage_at(address, index) - .block_id(number.unwrap_or(BlockNumber::Latest).into()) + .get_storage_at(address, index, number.unwrap_or(BlockNumber::Latest).into()) .await } @@ -241,7 +236,7 @@ impl ClientFork { let block_id = BlockId::Number(blocknumber.into()); - let code = self.provider().get_code_at(address).block_id(block_id).await?; + let code = self.provider().get_code_at(address, block_id).await?; let mut storage = self.storage_write(); storage.code_at.insert((address, blocknumber), code.clone().0.into()); @@ -255,12 +250,12 @@ impl ClientFork { blocknumber: u64, ) -> Result { trace!(target: "backend::fork", "get_balance={:?}", address); - self.provider().get_balance(address).block_id(blocknumber.into()).await + self.provider().get_balance(address, blocknumber.into()).await } pub async fn get_nonce(&self, address: Address, block: u64) -> Result { trace!(target: "backend::fork", "get_nonce={:?}", address); - self.provider().get_transaction_count(address).block_id(block.into()).await + self.provider().get_transaction_count(address, block.into()).await } pub async fn transaction_by_block_number_and_index( diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 0627e41255ad3..33f375f9c3ec5 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -128,7 +128,7 @@ impl EstimateArgs { req.set_input(data); - let gas = provider.estimate_gas(&req).block_id(BlockId::latest()).await?; + let gas = provider.estimate_gas(&req, BlockId::latest()).await?; println!("{gas}"); Ok(()) } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index bfef0a898b28e..e26115da32ab5 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -90,9 +90,8 @@ impl MakeTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = Some(U64::from( - provider.get_transaction_count(from).block_id(BlockId::latest()).await?, - )); + tx.nonce = + Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); } let provider = get_provider(&config)?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 2997bfb88b7ec..7799f522691d8 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -144,10 +144,7 @@ impl SendTxArgs { if resend { tx.nonce = Some(U64::from( - provider - .get_transaction_count(config.sender) - .block_id(BlockId::latest()) - .await?, + provider.get_transaction_count(config.sender, BlockId::latest()).await?, )); } @@ -178,9 +175,8 @@ impl SendTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = Some(U64::from( - provider.get_transaction_count(from).block_id(BlockId::latest()).await?, - )); + tx.nonce = + Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); } let signer = EthereumSigner::from(signer); diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index a59d93c5d1047..6197e40c96e54 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -95,8 +95,7 @@ impl StorageArgs { // No slot was provided // Get deployed bytecode at given address - let address_code = - provider.get_code_at(address).block_id(block.unwrap_or_default()).await?; + let address_code = provider.get_code_at(address, block.unwrap_or_default()).await?; if address_code.is_empty() { eyre::bail!("Provided address has no deployed code and thus no storage"); } @@ -238,10 +237,8 @@ async fn fetch_storage_slots, T: Transport + Clone>( ) -> Result> { let requests = layout.storage.iter().map(|storage_slot| async { let slot = B256::from(U256::from_str(&storage_slot.slot)?); - let raw_slot_value = provider - .get_storage_at(address, slot.into()) - .block_id(block.unwrap_or_default()) - .await?; + let raw_slot_value = + provider.get_storage_at(address, slot.into(), block.unwrap_or_default()).await?; let value = StorageValue { slot, raw_slot_value: raw_slot_value.into() }; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 500c831d158ff..30bb1205e56ef 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -351,8 +351,7 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let address = address.resolve(&provider).await?; let value = provider - .get_proof(address, slots.into_iter().collect()) - .block_id(block.unwrap_or(BlockId::latest())) + .get_proof(address, slots.into_iter().collect(), block.unwrap_or(BlockId::latest())) .await?; println!("{}", serde_json::to_string(&value)?); } diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 80ce6e04b6466..64b33b280712f 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -71,7 +71,7 @@ pub async fn build_tx< req.set_nonce(if let Some(nonce) = tx.nonce { nonce.to() } else { - provider.get_transaction_count(from).block_id(BlockId::latest()).await? + provider.get_transaction_count(from, BlockId::latest()).await? }); if tx.legacy || chain.is_legacy() { @@ -119,7 +119,7 @@ pub async fn build_tx< req.set_gas_limit(if let Some(gas_limit) = tx.gas_limit { gas_limit.to() } else { - provider.estimate_gas(&req).block_id(BlockId::latest()).await? + provider.estimate_gas(&req, BlockId::latest()).await? }); Ok((req, func)) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index e9c8cb7b26bad..e2f706b74dac0 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -133,11 +133,8 @@ where if res.is_empty() { // check that the recipient is a contract that can be called if let Some(TxKind::Call(addr)) = req.to { - if let Ok(code) = self - .provider - .get_code_at(addr) - .block_id(block.unwrap_or_default()) - .await + if let Ok(code) = + self.provider.get_code_at(addr, block.unwrap_or_default()).await { if code.is_empty() { eyre::bail!("contract {addr:?} does not have any code") @@ -200,11 +197,8 @@ where block: Option, to_json: bool, ) -> Result { - let access_list = self - .provider - .create_access_list(req) - .block_id(block.unwrap_or(BlockId::latest())) - .await?; + let access_list = + self.provider.create_access_list(req, block.unwrap_or(BlockId::latest())).await?; let res = if to_json { serde_json::to_string(&access_list)? } else { @@ -226,7 +220,7 @@ where } pub async fn balance(&self, who: Address, block: Option) -> Result { - Ok(self.provider.get_balance(who).block_id(block.unwrap_or(BlockId::latest())).await?) + Ok(self.provider.get_balance(who, block.unwrap_or(BlockId::latest())).await?) } /// Sends a transaction to the specified address @@ -478,11 +472,7 @@ where /// # } /// ``` pub async fn nonce(&self, who: Address, block: Option) -> Result { - Ok(self - .provider - .get_transaction_count(who) - .block_id(block.unwrap_or(BlockId::latest())) - .await?) + Ok(self.provider.get_transaction_count(who, block.unwrap_or(BlockId::latest())).await?) } /// # Example @@ -508,8 +498,7 @@ where B256::from_str("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")?; let value = self .provider - .get_storage_at(who, slot.into()) - .block_id(block.unwrap_or(BlockId::latest())) + .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) @@ -538,8 +527,7 @@ where B256::from_str("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")?; let value = self .provider - .get_storage_at(who, slot.into()) - .block_id(block.unwrap_or(BlockId::latest())) + .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) @@ -593,14 +581,10 @@ where disassemble: bool, ) -> Result { if disassemble { - let code = - self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await?.to_vec(); + let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); Ok(format_operations(disassemble_bytes(code)?)?) } else { - Ok(format!( - "{}", - self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await? - )) + Ok(format!("{}", self.provider.get_code_at(who, block.unwrap_or_default()).await?)) } } @@ -623,8 +607,7 @@ where /// # } /// ``` pub async fn codesize(&self, who: Address, block: Option) -> Result { - let code = - self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await?.to_vec(); + let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); Ok(format!("{}", code.len())) } @@ -790,8 +773,7 @@ where "{:?}", B256::from( self.provider - .get_storage_at(from, slot.into()) - .block_id(block.unwrap_or_default()) + .get_storage_at(from, slot.into(), block.unwrap_or(BlockId::latest())) .await? ) )) diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index f2e4d15c325b5..2ab9bdc9bdb49 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -22,7 +22,6 @@ use revm::{ use rustc_hash::FxHashMap; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, - future::IntoFuture, marker::PhantomData, pin::Pin, sync::{ @@ -190,11 +189,8 @@ where let provider = self.provider.clone(); let block_id = self.block_id.unwrap_or(BlockId::latest()); let fut = Box::pin(async move { - let storage = provider - .get_storage_at(address, idx) - .block_id(block_id) - .await - .map_err(Into::into); + let storage = + provider.get_storage_at(address, idx, block_id).await.map_err(Into::into); (storage, address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); @@ -208,9 +204,9 @@ where let provider = self.provider.clone(); let block_id = self.block_id.unwrap_or(BlockId::latest()); let fut = Box::pin(async move { - let balance = provider.get_balance(address).block_id(block_id).into_future(); - let nonce = provider.get_transaction_count(address).block_id(block_id).into_future(); - let code = provider.get_code_at(address).block_id(block_id).into_future(); + let balance = provider.get_balance(address, block_id); + let nonce = provider.get_transaction_count(address, block_id); + let code = provider.get_code_at(address, block_id); let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); (resp, address) }); diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 02e68213af9ce..460dbdea70ed0 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -239,7 +239,7 @@ impl CreateArgs { deployer.tx.set_nonce(if let Some(nonce) = self.tx.nonce { Ok(nonce.to()) } else { - provider.get_transaction_count(deployer_address).block_id(BlockId::latest()).await + provider.get_transaction_count(deployer_address, BlockId::latest()).await }?); // set tx value if specified @@ -250,7 +250,7 @@ impl CreateArgs { deployer.tx.set_gas_limit(if let Some(gas_limit) = self.tx.gas_limit { Ok(gas_limit.to()) } else { - provider.estimate_gas(&deployer.tx).block_id(BlockId::latest()).await + provider.estimate_gas(&deployer.tx, BlockId::latest()).await }?); if is_legacy { diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 39bf392897cc2..a278e44d75917 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -44,8 +44,7 @@ where tx.set_gas_limit( provider - .estimate_gas(tx) - .block_id(BlockId::latest()) + .estimate_gas(tx, BlockId::latest()) .await .wrap_err("Failed to estimate gas for tx")? * estimate_multiplier as u128 / @@ -57,7 +56,7 @@ where pub async fn next_nonce(caller: Address, provider_url: &str) -> eyre::Result { let provider = try_get_http_provider(provider_url) .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; - Ok(provider.get_transaction_count(caller).block_id(BlockId::latest()).await?) + Ok(provider.get_transaction_count(caller, BlockId::latest()).await?) } pub async fn send_transaction( @@ -72,7 +71,7 @@ pub async fn send_transaction( let from = tx.from.expect("no sender"); if sequential_broadcast { - let nonce = provider.get_transaction_count(from).block_id(BlockId::latest()).await?; + let nonce = provider.get_transaction_count(from, BlockId::latest()).await?; let tx_nonce = tx.nonce.expect("no nonce"); if nonce != tx_nonce { diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 64e1c7539151c..8d9907ccfebe4 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -7,7 +7,6 @@ use crate::{ }; use alloy_primitives::{Bytes, B256}; use alloy_provider::Provider; -use alloy_rpc_types::BlockId; use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_common::{ @@ -47,7 +46,7 @@ impl BuildData { let can_use_create2 = if let Some(fork_url) = &script_config.evm_opts.fork_url { let provider = try_get_http_provider(fork_url)?; let deployer_code = - provider.get_code_at(DEFAULT_CREATE2_DEPLOYER).block_id(BlockId::latest()).await?; + provider.get_code_at(DEFAULT_CREATE2_DEPLOYER, Default::default()).await?; !deployer_code.is_empty() } else { diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index c0331ed9fcbf6..8b625d6eed9ab 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -141,8 +141,7 @@ impl ScriptTester { if let Some(provider) = &self.provider { let nonce = provider - .get_transaction_count(self.accounts_pub[index as usize]) - .block_id(BlockId::latest()) + .get_transaction_count(self.accounts_pub[index as usize], BlockId::latest()) .await .unwrap(); self.nonces.insert(index, nonce); @@ -157,8 +156,7 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(address) - .block_id(BlockId::latest()) + .get_transaction_count(address, BlockId::latest()) .await .unwrap(); self.address_nonces.insert(address, nonce); @@ -204,8 +202,7 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(addr) - .block_id(BlockId::latest()) + .get_transaction_count(addr, BlockId::latest()) .await .unwrap(); let prev_nonce = self.nonces.get(&private_key_slot).unwrap(); @@ -230,8 +227,7 @@ impl ScriptTester { .provider .as_ref() .unwrap() - .get_transaction_count(*address) - .block_id(BlockId::latest()) + .get_transaction_count(*address, BlockId::latest()) .await .unwrap(); let prev_nonce = self.address_nonces.get(address).unwrap(); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index da0f805fd0bbe..53654a7d35e51 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -109,7 +109,7 @@ impl VerifyBytecodeArgs { let config = self.load_config_emit_warnings(); let provider = ProviderBuilder::new(&config.get_rpc_url_or_localhost_http()?).build()?; - let code = provider.get_code_at(self.address).block_id(BlockId::latest()).await?; + let code = provider.get_code_at(self.address, BlockId::latest()).await?; if code.is_empty() { eyre::bail!("No bytecode found at address {}", self.address); } @@ -291,10 +291,8 @@ impl VerifyBytecodeArgs { // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same // block. let prev_block_id = BlockId::Number(BlockNumberOrTag::Number(simulation_block - 1)); - let prev_block_nonce = provider - .get_transaction_count(creation_data.contract_creator) - .block_id(prev_block_id) - .await?; + let prev_block_nonce = + provider.get_transaction_count(creation_data.contract_creator, prev_block_id).await?; transaction.nonce = prev_block_nonce; if let Some(ref block) = block { @@ -345,8 +343,9 @@ impl VerifyBytecodeArgs { ) })?; - let onchain_runtime_code = - provider.get_code_at(self.address).block_id(BlockId::number(simulation_block)).await?; + let onchain_runtime_code = provider + .get_code_at(self.address, BlockId::Number(BlockNumberOrTag::Number(simulation_block))) + .await?; // Compare the runtime bytecode with the locally built bytecode let (did_match, with_status) = try_match( From 467aff3056842e8d45bc58a353be17349f0e8651 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 16 May 2024 23:27:54 +0300 Subject: [PATCH 0969/1963] Revert "fix: fuzz console log (#7781)" (#7935) This reverts commit a470d635cfcdce68609e9dc5762a3584351bacc1. --- crates/evm/evm/src/executors/fuzz/mod.rs | 16 +++-------- crates/evm/evm/src/executors/fuzz/types.rs | 4 +-- crates/forge/tests/cli/test_cmd.rs | 31 +--------------------- 3 files changed, 6 insertions(+), 45 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 1adabc5fd98dd..d81ddbaca01b3 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,7 +1,7 @@ use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_config::FuzzConfig; use foundry_evm_core::{ @@ -87,9 +87,6 @@ impl FuzzedExecutor { dictionary_weight => fuzz_calldata_from_state(func.clone(), &state), ]; - //Stores logs for all fuzz cases - let logs: RefCell> = RefCell::default(); - debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; @@ -107,7 +104,6 @@ impl FuzzedExecutor { } traces.borrow_mut().push(call_traces); } - logs.borrow_mut().extend(case.logs); if let Some(prev) = coverage.take() { // Safety: If `Option::or` evaluates to `Some`, then `call.coverage` must @@ -131,7 +127,6 @@ impl FuzzedExecutor { // to run at least one more case to find a minimal failure // case. let call_res = _counterexample.1.result.clone(); - logs.borrow_mut().extend(_counterexample.1.logs.clone()); *counterexample.borrow_mut() = _counterexample; // HACK: we have to use an empty string here to denote `None` let reason = rd.maybe_decode(&call_res, Some(status)); @@ -145,16 +140,14 @@ impl FuzzedExecutor { let mut traces = traces.into_inner(); let last_run_traces = if run_result.is_ok() { traces.pop() } else { call.traces.clone() }; - let inner_logs = logs.into_inner(); - let mut result = FuzzTestResult { first_case: first_case.take().unwrap_or_default(), gas_by_case: gas_by_case.take(), success: run_result.is_ok(), reason: None, counterexample: None, - decoded_logs: decode_console_logs(&inner_logs), - logs: inner_logs, + decoded_logs: decode_console_logs(&call.logs), + logs: call.logs, labeled_addresses: call.labels, traces: last_run_traces, gas_report_traces: traces, @@ -214,7 +207,7 @@ impl FuzzedExecutor { // When the `assume` cheatcode is called it returns a special string if call.result.as_ref() == MAGIC_ASSUME { - return Err(TestCaseError::reject(FuzzError::AssumeReject)); + return Err(TestCaseError::reject(FuzzError::AssumeReject)) } let breakpoints = call @@ -236,7 +229,6 @@ impl FuzzedExecutor { coverage: call.coverage, debug: call.debug, breakpoints, - logs: call.logs, })) } else { Ok(FuzzOutcome::CounterExample(CounterExampleOutcome { diff --git a/crates/evm/evm/src/executors/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs index 3791165ca62c8..b15cf3faae3ca 100644 --- a/crates/evm/evm/src/executors/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -1,5 +1,5 @@ use crate::executors::RawCallResult; -use alloy_primitives::{Bytes, Log}; +use alloy_primitives::Bytes; use foundry_common::evm::Breakpoints; use foundry_evm_core::debug::DebugArena; use foundry_evm_coverage::HitMaps; @@ -20,8 +20,6 @@ pub struct CaseOutcome { pub debug: Option, /// Breakpoints char pc map pub breakpoints: Breakpoints, - /// logs of a single fuzz test case - pub logs: Vec, } /// Returned by a single fuzz when a counterexample has been discovered diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 5fe9b388ac74a..2b0784d6a27d0 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,6 +1,6 @@ //! Contains various tests for `forge test`. -use foundry_config::{Config, FuzzConfig}; +use foundry_config::Config; use foundry_test_utils::{ rpc, util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, @@ -544,32 +544,3 @@ contract Dummy { cmd.args(["test", "--match-path", "src/dummy.sol"]); cmd.assert_success() }); - -// tests that `forge test` for fuzz tests will display `console.log` info -forgetest_init!(can_test_fuzz_with_console_log, |prj, cmd| { - prj.wipe_contracts(); - - // run fuzz test 3 times - let config = - Config { fuzz: { FuzzConfig { runs: 3, ..Default::default() } }, ..Default::default() }; - prj.write_config(config); - let config = cmd.config(); - assert_eq!(config.fuzz.runs, 3); - - prj.add_test( - "ContractFuzz.t.sol", - r#"pragma solidity 0.8.24; - import {Test, console2} from "forge-std/Test.sol"; - - contract ContractFuzz is Test { - function testFuzzConsoleLog(uint256 x) public { - console2.log("inside fuzz test, x is:", x); - } - } - "#, - ) - .unwrap(); - cmd.args(["test", "-vv"]); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); -}); From 54d8510c0f2b0f791f4c5ef99866c6af99b7606a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 10:46:09 +0200 Subject: [PATCH 0970/1963] chore(deps): weekly `cargo update` (#7946) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/evm-inspectors` Locking 48 packages to latest compatible versions Updating alloy-dyn-abi v0.7.2 -> v0.7.4 Updating alloy-json-abi v0.7.2 -> v0.7.4 Updating alloy-primitives v0.7.2 -> v0.7.4 Updating alloy-sol-macro v0.7.2 -> v0.7.4 Adding alloy-sol-macro-expander v0.7.4 Updating alloy-sol-macro-input v0.7.2 -> v0.7.4 Updating alloy-sol-type-parser v0.7.2 -> v0.7.4 Updating alloy-sol-types v0.7.2 -> v0.7.4 Updating ammonia v3.3.0 -> v4.0.0 Updating anyhow v1.0.83 -> v1.0.86 Updating aws-sdk-kms v1.25.0 -> v1.26.0 Updating aws-sdk-sso v1.24.0 -> v1.25.0 Updating aws-sdk-ssooidc v1.25.0 -> v1.26.0 Updating aws-sdk-sts v1.24.0 -> v1.25.0 Updating bytemuck v1.15.0 -> v1.16.0 Updating camino v1.1.6 -> v1.1.7 Updating const-hex v1.11.3 -> v1.11.4 Updating darling v0.20.8 -> v0.20.9 Updating darling_core v0.20.8 -> v0.20.9 Updating darling_macro v0.20.8 -> v0.20.9 Adding dbus v0.9.7 Updating either v1.11.0 -> v1.12.0 Updating figment v0.10.18 -> v0.10.19 Updating html5ever v0.26.0 -> v0.27.0 Updating instant v0.1.12 -> v0.1.13 Updating libc v0.2.154 -> v0.2.155 Adding libdbus-sys v0.2.5 Updating linux-raw-sys v0.4.13 -> v0.4.14 (latest: v0.6.4) Updating markup5ever v0.11.0 -> v0.12.1 Updating mdbook v0.4.37 -> v0.4.40 Updating miniz_oxide v0.7.2 -> v0.7.3 Adding opener v0.7.1 Removing phf v0.10.1 Removing phf_codegen v0.10.0 Updating rustls-webpki v0.102.3 -> v0.102.4 Updating rustversion v1.0.16 -> v1.0.17 Updating schemars v0.8.19 -> v0.8.20 Updating schemars_derive v0.8.19 -> v0.8.20 Updating serde v1.0.201 -> v1.0.202 Updating serde_derive v1.0.201 -> v1.0.202 Updating serde_derive_internals v0.29.0 -> v0.29.1 Updating serde_spanned v0.6.5 -> v0.6.6 Updating syn v2.0.63 -> v2.0.64 Updating syn-solidity v0.7.2 -> v0.7.4 Updating thiserror v1.0.60 -> v1.0.61 Updating thiserror-impl v1.0.60 -> v1.0.61 Updating toml v0.8.12 -> v0.8.13 Updating toml_datetime v0.6.5 -> v0.6.6 Updating toml_edit v0.22.12 -> v0.22.13 Updating zip v1.2.3 -> v1.3.0 note: pass `--verbose` to see 139 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 370 ++++++++++++++++++++++++++++------------------------- 1 file changed, 199 insertions(+), 171 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52a36a589dc4c..440f2e3d98c68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545885d9b0b2c30fd344ae291439b4bfe59e48dd62fbc862f8503d98088967dc" +checksum = "8425a283510106b1a6ad25dd4bb648ecde7da3fd2baeb9400a85ad62f51ec90b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786689872ec4e7d354810ab0dffd48bb40b838c047522eb031cbd47d15634849" +checksum = "7e30946aa6173020259055a44971f5cf40a7d76c931d209caeb51b333263df4f" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525448f6afc1b70dd0f9d0a8145631bf2f5e434678ab23ab18409ca264cae6b3" +checksum = "db8aa973e647ec336810a9356af8aea787249c9d00b1525359f3db29a68d231b" dependencies = [ "alloy-rlp", "arbitrary", @@ -291,7 +291,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -463,9 +463,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c80a2cb97e7aa48611cbb63950336f9824a174cdf670527cc6465078a26ea1" +checksum = "7dbd17d67f3e89478c8a634416358e539e577899666c927bc3d2b1328ee9b6ca" +dependencies = [ + "alloy-sol-macro-expander", + "alloy-sol-macro-input", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.64", +] + +[[package]] +name = "alloy-sol-macro-expander" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6da95adcf4760bb4b108fefa51d50096c5e5fdd29ee72fed3e86ee414f2e34" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -475,16 +489,16 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58894b58ac50979eeac6249661991ac40b9d541830d9a725f7714cc9ef08c23" +checksum = "32c8da04c1343871fb6ce5a489218f9c85323c8340a36e9106b5fc98d4dd59d5" dependencies = [ "alloy-json-abi", "const-hex", @@ -493,24 +507,24 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.63", + "syn 2.0.64", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8e71ea68e780cc203919e03f69f59e7afe92d2696fb1dcb6662f61e4031b6" +checksum = "368cae4dc052cad1d8f72eb2ae0c38027116933eeb49213c200a9e9875f208d7" dependencies = [ "winnow 0.6.8", ] [[package]] name = "alloy-sol-types" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "399287f68d1081ed8b1f4903c49687658b95b142207d7cb4ae2f4813915343ef" +checksum = "40a64d2d2395c1ac636b62419a7b17ec39031d6b2367e66e9acbf566e6055e9c" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -605,9 +619,9 @@ dependencies = [ [[package]] name = "ammonia" -version = "3.3.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e6d1c7838db705c9b756557ee27c384ce695a1c51a6fe528784cb1c6840170" +checksum = "1ab99eae5ee58501ab236beb6f20f6ca39be615267b014899c89b2f0bc18a459" dependencies = [ "html5ever", "maplit", @@ -812,9 +826,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arbitrary" @@ -991,7 +1005,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -1013,7 +1027,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -1024,7 +1038,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -1071,7 +1085,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -1148,9 +1162,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca6ab350d6652bf85e38503758a67b2735b3d1ad38fd2f55181ef3c09afdb1c" +checksum = "b5a6b58615203957a253a180b81db9427cb4b623fc8bab8dcac42369239f7716" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1170,9 +1184,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.24.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd6a9b38fe2dcaa2422b42e2c667112872d03a83522533f8b4165fd2d9d4bd1" +checksum = "fef2d9ca2b43051224ed326ed9960a85e277b7d554a2cd0397e57c0553d86e64" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1192,9 +1206,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c99f342a364c8490b7715387244d2f7ebfc05f07bb6a0fc6e70b8e62b7078d06" +checksum = "c869d1f5c4ee7437b79c3c1664ddbf7a60231e893960cf82b2b299a5ccf2cc5d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1214,9 +1228,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.24.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7207ca62206c93e470457babf0512d7b6b97170fdba929a2a2f5682f9f68407c" +checksum = "9e2b4a632a59e4fab7abf1db0d94a3136ad7871aba46bebd1fdb95c7054afcdb" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1643,9 +1657,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" [[package]] name = "byteorder" @@ -1688,9 +1702,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ "serde", ] @@ -1956,7 +1970,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -2149,9 +2163,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.3" +version = "1.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" +checksum = "70ff96486ccc291d36a958107caf2c0af8c78c0af7d31ae2f35ce055130de1a6" dependencies = [ "cfg-if", "cpufeatures", @@ -2352,9 +2366,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ "darling_core", "darling_macro", @@ -2362,27 +2376,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", - "syn 2.0.63", + "strsim 0.11.1", + "syn 2.0.64", ] [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -2404,6 +2418,17 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +[[package]] +name = "dbus" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" +dependencies = [ + "libc", + "libdbus-sys", + "winapi", +] + [[package]] name = "der" version = "0.7.9" @@ -2443,7 +2468,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -2464,7 +2489,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -2474,7 +2499,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -2594,7 +2619,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -2637,9 +2662,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elasticlunr-rs" @@ -2702,7 +2727,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -2852,8 +2877,8 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.63", - "toml 0.8.12", + "syn 2.0.64", + "toml 0.8.13", "walkdir", ] @@ -2880,7 +2905,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.63", + "syn 2.0.64", "tempfile", "thiserror", "tiny-keccak", @@ -2983,16 +3008,16 @@ dependencies = [ [[package]] name = "figment" -version = "0.10.18" +version = "0.10.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d032832d74006f99547004d49410a4b4218e4c33382d56ca3ff89df74f86b953" +checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3" dependencies = [ "atomic", "parking_lot", "pear", "serde", "tempfile", - "toml 0.8.12", + "toml 0.8.13", "uncased", "version_check", ] @@ -3110,7 +3135,7 @@ dependencies = [ "itertools 0.12.1", "mockall", "once_cell", - "opener", + "opener 0.6.1", "parking_lot", "paste", "path-slash", @@ -3132,8 +3157,8 @@ dependencies = [ "thiserror", "tikv-jemallocator", "tokio", - "toml 0.8.12", - "toml_edit 0.22.12", + "toml 0.8.13", + "toml_edit 0.22.13", "tower-http", "tracing", "tracing-subscriber", @@ -3163,7 +3188,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.12", + "toml 0.8.13", "tracing", ] @@ -3178,7 +3203,7 @@ dependencies = [ "similar-asserts", "solang-parser", "thiserror", - "toml 0.8.12", + "toml 0.8.13", "tracing", "tracing-subscriber", ] @@ -3319,7 +3344,7 @@ dependencies = [ "semver 1.0.23", "serde_json", "thiserror", - "toml 0.8.12", + "toml 0.8.13", "tracing", "walkdir", ] @@ -3488,8 +3513,8 @@ dependencies = [ "solang-parser", "tempfile", "thiserror", - "toml 0.8.12", - "toml_edit 0.22.12", + "toml 0.8.13", + "toml_edit 0.22.13", "tracing", "walkdir", ] @@ -3658,7 +3683,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -3818,7 +3843,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -4254,16 +4279,16 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" +checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4" dependencies = [ "log", "mac", "markup5ever", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.64", ] [[package]] @@ -4652,9 +4677,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -4858,9 +4883,19 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libdbus-sys" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" +dependencies = [ + "cc", + "pkg-config", +] [[package]] name = "libm" @@ -4892,9 +4927,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -4935,13 +4970,13 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "markup5ever" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" +checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45" dependencies = [ "log", - "phf 0.10.1", - "phf_codegen 0.10.0", + "phf", + "phf_codegen", "string_cache", "string_cache_codegen", "tendril", @@ -4974,9 +5009,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.37" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c33564061c3c640bed5ace7d6a2a1b65f2c64257d1ac930c15e94ed0fb561d3" +checksum = "b45a38e19bd200220ef07c892b0157ad3d2365e5b5a267ca01ad12182491eea5" dependencies = [ "ammonia", "anyhow", @@ -4989,7 +5024,7 @@ dependencies = [ "log", "memchr", "once_cell", - "opener", + "opener 0.7.1", "pulldown-cmark", "regex", "serde", @@ -5053,7 +5088,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5080,9 +5115,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", ] @@ -5123,7 +5158,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5355,7 +5390,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5443,6 +5478,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "opener" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8df34be653210fbe9ffaff41d3b92721c56ce82dfee58ee684f9afb5e3a90c0" +dependencies = [ + "bstr 1.9.1", + "dbus", + "normpath", + "windows-sys 0.52.0", +] + [[package]] name = "openssl" version = "0.10.64" @@ -5466,7 +5513,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5623,7 +5670,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5682,7 +5729,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5716,15 +5763,6 @@ dependencies = [ "rustc_version 0.4.0", ] -[[package]] -name = "phf" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" -dependencies = [ - "phf_shared 0.10.0", -] - [[package]] name = "phf" version = "0.11.2" @@ -5735,16 +5773,6 @@ dependencies = [ "phf_shared 0.11.2", ] -[[package]] -name = "phf_codegen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", -] - [[package]] name = "phf_codegen" version = "0.11.2" @@ -5785,7 +5813,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5823,7 +5851,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -5939,7 +5967,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -6015,7 +6043,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", "version_check", "yansi", ] @@ -6609,7 +6637,7 @@ dependencies = [ "log", "ring", "rustls-pki-types", - "rustls-webpki 0.102.3", + "rustls-webpki 0.102.4", "subtle", "zeroize", ] @@ -6676,9 +6704,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.3" +version = "0.102.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ "ring", "rustls-pki-types", @@ -6687,9 +6715,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "rusty-fork" @@ -6794,9 +6822,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc6e7ed6919cb46507fb01ff1654309219f62b4d603822501b0b80d42f6f21ef" +checksum = "b0218ceea14babe24a4a5836f86ade86c1effbc198164e619194cb5069187e29" dependencies = [ "dyn-clone", "schemars_derive", @@ -6806,14 +6834,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185f2b7aa7e02d418e453790dde16890256bbd2bcd04b7dc5348811052b53f49" +checksum = "3ed5a1ccce8ff962e31a165d41f6e2a2dd1245099dc4d594f5574a86cd90f4d3" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -6941,33 +6969,33 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] name = "serde_derive_internals" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -7010,14 +7038,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -7056,7 +7084,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -7240,7 +7268,7 @@ dependencies = [ "itertools 0.11.0", "lalrpop", "lalrpop-util", - "phf 0.11.2", + "phf", "thiserror", "unicode-xid", ] @@ -7274,7 +7302,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" dependencies = [ "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -7346,7 +7374,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -7414,9 +7442,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.63" +version = "2.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" dependencies = [ "proc-macro2", "quote", @@ -7425,14 +7453,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa0cefd02f532035d83cfec82647c6eb53140b0485220760e669f4bad489e36" +checksum = "b8db114c44cf843a8bacd37a146e37987a0b823a0e8bc4fdc610c9c72ab397a5" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -7506,8 +7534,8 @@ dependencies = [ "dirs 4.0.0", "fnv", "nom", - "phf 0.11.2", - "phf_codegen 0.11.2", + "phf", + "phf_codegen", ] [[package]] @@ -7518,22 +7546,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -7669,7 +7697,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -7766,22 +7794,22 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.12", + "toml_edit 0.22.13", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] @@ -7799,9 +7827,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.12" +version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ "indexmap", "serde", @@ -7889,7 +7917,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -8236,7 +8264,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", "wasm-bindgen-shared", ] @@ -8270,7 +8298,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8714,7 +8742,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] @@ -8734,14 +8762,14 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.64", ] [[package]] name = "zip" -version = "1.2.3" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700ea425e148de30c29c580c1f9508b93ca57ad31c9f4e96b83c194c37a7a8f" +checksum = "f1f4a27345eb6f7aa7bd015ba7eb4175fa4e1b462a29874b779e0bbcf96c6ac7" dependencies = [ "arbitrary", "crc32fast", From 1ddea96f34a35fcc63238e02c44d2983df2f4fbb Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 20 May 2024 10:22:48 +0300 Subject: [PATCH 0971/1963] feat(invariant): fuzz with values from events and return values (#7666) * feat(invariant): scrape return values and add to fuzz dictionary * Perist mined values between runs * Refactor, add persistent samples * Apply weight to collected sample values * Add Function to BasicTxDetails (if has outputs), to be used for decoding. Decode results and persist per types. Use typed samples when fuzzing from state. * Fix clippy and fmt * Use prop-perturb take 1 * Decode logs using target abi, populate type samples * Fmt * Fix clippy, add calldetails type * Fix fmt test * Insert call sample once * Proper function naming * Generate state values bias using strategy * Add BasicTxDetails and CallTargetDetails struct, add Function always to call details and use it to generate counterexample * Tests cleanup * Code cleanup * Move args in CallDetails * Fallback to old impl if we are not able to decode logs * Refactor collect values fn * Get abi from FuzzedContracts * Lookup function from identified target abi. --- crates/evm/evm/src/executors/invariant/mod.rs | 44 +++++-- .../evm/evm/src/executors/invariant/replay.rs | 16 ++- .../evm/evm/src/executors/invariant/shrink.rs | 10 +- crates/evm/fuzz/src/inspector.rs | 14 +- .../evm/fuzz/src/invariant/call_override.rs | 12 +- crates/evm/fuzz/src/invariant/mod.rs | 31 ++++- crates/evm/fuzz/src/strategies/invariants.rs | 13 +- crates/evm/fuzz/src/strategies/param.rs | 28 +++- crates/evm/fuzz/src/strategies/state.rs | 121 ++++++++++++++---- crates/forge/tests/it/invariant.rs | 52 ++++++++ .../common/InvariantScrapeValues.t.sol | 69 ++++++++++ 11 files changed, 341 insertions(+), 69 deletions(-) create mode 100644 testdata/default/fuzz/invariant/common/InvariantScrapeValues.t.sol diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index a15f98f8bd60d..ef7823342eff1 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -205,11 +205,16 @@ impl<'a> InvariantExecutor<'a> { let mut assume_rejects_counter = 0; while current_run < self.config.depth { - let (sender, (address, calldata)) = inputs.last().expect("no input generated"); + let tx = inputs.last().expect("no input generated"); // Execute call from the randomly generated sequence and commit state changes. let call_result = executor - .call_raw_committing(*sender, *address, calldata.clone(), U256::ZERO) + .call_raw_committing( + tx.sender, + tx.call_details.target, + tx.call_details.calldata.clone(), + U256::ZERO, + ) .expect("could not make raw evm call"); if call_result.result.as_ref() == MAGIC_ASSUME { @@ -226,7 +231,16 @@ impl<'a> InvariantExecutor<'a> { let mut state_changeset = call_result.state_changeset.to_owned().expect("no changesets"); - collect_data(&mut state_changeset, sender, &call_result, &fuzz_state); + if !&call_result.reverted { + collect_data( + &mut state_changeset, + &targeted_contracts, + tx, + &call_result, + &fuzz_state, + self.config.depth, + ); + } // Collect created contracts and add to fuzz targets only if targeted contracts // are updatable. @@ -244,7 +258,7 @@ impl<'a> InvariantExecutor<'a> { } fuzz_runs.push(FuzzCase { - calldata: calldata.clone(), + calldata: tx.call_details.calldata.clone(), gas: call_result.gas_used, stipend: call_result.stipend, }); @@ -639,13 +653,16 @@ impl<'a> InvariantExecutor<'a> { /// randomly generated addresses. fn collect_data( state_changeset: &mut HashMap, - sender: &Address, + fuzzed_contracts: &FuzzRunIdentifiedContracts, + tx: &BasicTxDetails, call_result: &RawCallResult, fuzz_state: &EvmFuzzState, + run_depth: u32, ) { // Verify it has no code. let mut has_code = false; - if let Some(Some(code)) = state_changeset.get(sender).map(|account| account.info.code.as_ref()) + if let Some(Some(code)) = + state_changeset.get(&tx.sender).map(|account| account.info.code.as_ref()) { has_code = !code.is_empty(); } @@ -653,13 +670,22 @@ fn collect_data( // We keep the nonce changes to apply later. let mut sender_changeset = None; if !has_code { - sender_changeset = state_changeset.remove(sender); + sender_changeset = state_changeset.remove(&tx.sender); } - fuzz_state.collect_state_from_call(&call_result.logs, &*state_changeset); + // Collect values from fuzzed call result and add them to fuzz dictionary. + let (fuzzed_contract_abi, fuzzed_function) = fuzzed_contracts.fuzzed_artifacts(tx); + fuzz_state.collect_values_from_call( + fuzzed_contract_abi.as_ref(), + fuzzed_function.as_ref(), + &call_result.result, + &call_result.logs, + &*state_changeset, + run_depth, + ); // Re-add changes if let Some(changed) = sender_changeset { - state_changeset.insert(*sender, changed); + state_changeset.insert(tx.sender, changed); } } diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index e555811745dc6..a225ccb2c921d 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -35,9 +35,13 @@ pub fn replay_run( let mut counterexample_sequence = vec![]; // Replay each call from the sequence, collect logs, traces and coverage. - for (sender, (addr, bytes)) in inputs.iter() { - let call_result = - executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; + for tx in inputs.iter() { + let call_result = executor.call_raw_committing( + tx.sender, + tx.call_details.target, + tx.call_details.calldata.clone(), + U256::ZERO, + )?; logs.extend(call_result.logs); traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); @@ -57,9 +61,9 @@ pub fn replay_run( // Create counter example to be used in failed case. counterexample_sequence.push(BaseCounterExample::create( - *sender, - *addr, - bytes, + tx.sender, + tx.call_details.target, + &tx.call_details.calldata, &ided_contracts, call_result.traces, )); diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index 7b78ae028bf51..e6af9c1bcfd8e 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -120,9 +120,13 @@ fn check_sequence( let mut sequence_failed = false; // Apply the shrinked candidate sequence. for call_index in sequence { - let (sender, (addr, bytes)) = &calls[call_index]; - let call_result = - executor.call_raw_committing(*sender, *addr, bytes.clone(), U256::ZERO)?; + let tx = &calls[call_index]; + let call_result = executor.call_raw_committing( + tx.sender, + tx.call_details.target, + tx.call_details.calldata.clone(), + U256::ZERO, + )?; if call_result.reverted && failed_case.fail_on_revert { // Candidate sequence fails test. // We don't have to apply remaining calls to check sequence. diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index 5e7e644b11d60..eb089baf6c289 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -82,16 +82,14 @@ impl Fuzzer { !call_generator.used { // There's only a 30% chance that an override happens. - if let Some((sender, (contract, input))) = - call_generator.next(call.context.caller, call.contract) - { - *call.input = input.0; - call.context.caller = sender; - call.contract = contract; + if let Some(tx) = call_generator.next(call.context.caller, call.contract) { + *call.input = tx.call_details.calldata.0; + call.context.caller = tx.sender; + call.contract = tx.call_details.target; // TODO: in what scenarios can the following be problematic - call.context.code_address = contract; - call.context.address = contract; + call.context.code_address = tx.call_details.target; + call.context.address = tx.call_details.target; call_generator.used = true; } diff --git a/crates/evm/fuzz/src/invariant/call_override.rs b/crates/evm/fuzz/src/invariant/call_override.rs index 1d9edba5c3db1..a98c500024413 100644 --- a/crates/evm/fuzz/src/invariant/call_override.rs +++ b/crates/evm/fuzz/src/invariant/call_override.rs @@ -1,5 +1,5 @@ -use super::BasicTxDetails; -use alloy_primitives::{Address, Bytes}; +use super::{BasicTxDetails, CallDetails}; +use alloy_primitives::Address; use parking_lot::{Mutex, RwLock}; use proptest::{ option::weighted, @@ -17,7 +17,7 @@ pub struct RandomCallGenerator { /// Runner that will generate the call from the strategy. pub runner: Arc>, /// Strategy to be used to generate calls from `target_reference`. - pub strategy: SBoxedStrategy>, + pub strategy: SBoxedStrategy>, /// Reference to which contract we want a fuzzed calldata from. pub target_reference: Arc>, /// Flag to know if a call has been overridden. Don't allow nesting for now. @@ -33,7 +33,7 @@ impl RandomCallGenerator { pub fn new( test_address: Address, runner: TestRunner, - strategy: SBoxedStrategy<(Address, Bytes)>, + strategy: SBoxedStrategy, target_reference: Arc>, ) -> Self { let strategy = weighted(0.9, strategy).sboxed(); @@ -71,7 +71,7 @@ impl RandomCallGenerator { ) } else { // TODO: Do we want it to be 80% chance only too ? - let new_caller = original_target; + let sender = original_target; // Set which contract we mostly (80% chance) want to generate calldata from. *self.target_reference.write() = original_caller; @@ -82,7 +82,7 @@ impl RandomCallGenerator { .new_tree(&mut self.runner.lock()) .unwrap() .current() - .map(|(new_target, calldata)| (new_caller, (new_target, calldata))); + .map(|call_details| BasicTxDetails { sender, call_details }); self.last_sequence.write().push(choice.clone()); choice diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index d682041e97065..7c3a1ffc086d3 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -26,10 +26,37 @@ impl FuzzRunIdentifiedContracts { pub fn new(targets: TargetedContracts, is_updatable: bool) -> Self { Self { targets: Arc::new(Mutex::new(targets)), is_updatable } } + + /// Returns fuzzed contract abi and fuzzed function from address and provided calldata. + /// Used to decode return values and logs in order to add values into fuzz dictionary. + pub fn fuzzed_artifacts(&self, tx: &BasicTxDetails) -> (Option, Option) { + match self.targets.lock().get(&tx.call_details.target) { + Some((_, abi, _)) => ( + Some(abi.to_owned()), + abi.functions().find(|f| f.selector() == tx.call_details.calldata[..4]).cloned(), + ), + None => (None, None), + } + } } -/// (Sender, (TargetContract, Calldata)) -pub type BasicTxDetails = (Address, (Address, Bytes)); +/// Details of a transaction generated by invariant strategy for fuzzing a target. +#[derive(Clone, Debug)] +pub struct BasicTxDetails { + // Transaction sender address. + pub sender: Address, + // Transaction call details. + pub call_details: CallDetails, +} + +/// Call details of a transaction generated to fuzz invariant target. +#[derive(Clone, Debug)] +pub struct CallDetails { + // Address of target contract. + pub target: Address, + // The data of the transaction. + pub calldata: Bytes, +} /// Test contract which is testing its invariants. #[derive(Clone, Debug)] diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 08e53b2a0bf5e..49971613ea799 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -1,11 +1,11 @@ use super::{fuzz_calldata, fuzz_param_from_state}; use crate::{ - invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, SenderFilters}, + invariant::{BasicTxDetails, CallDetails, FuzzRunIdentifiedContracts, SenderFilters}, strategies::{fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, FuzzFixtures, }; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::Address; use parking_lot::RwLock; use proptest::prelude::*; use std::{rc::Rc, sync::Arc}; @@ -16,7 +16,7 @@ pub fn override_call_strat( contracts: FuzzRunIdentifiedContracts, target: Arc>, fuzz_fixtures: FuzzFixtures, -) -> SBoxedStrategy<(Address, Bytes)> { +) -> SBoxedStrategy { let contracts_ref = contracts.targets.clone(); proptest::prop_oneof![ 80 => proptest::strategy::LazyJust::new(move || *target.read()), @@ -101,6 +101,7 @@ fn generate_call( (sender, contract) }) }) + .prop_map(|(sender, call_details)| BasicTxDetails { sender, call_details }) .boxed() } @@ -166,9 +167,9 @@ fn select_random_function( pub fn fuzz_contract_with_calldata( fuzz_state: &EvmFuzzState, fuzz_fixtures: &FuzzFixtures, - contract: Address, + target: Address, func: Function, -) -> impl Strategy { +) -> impl Strategy { // We need to compose all the strategies generated for each parameter in all possible // combinations. // `prop_oneof!` / `TupleUnion` `Arc`s for cheap cloning. @@ -179,6 +180,6 @@ pub fn fuzz_contract_with_calldata( ] .prop_map(move |calldata| { trace!(input=?calldata); - (contract, calldata) + CallDetails { target, calldata } }) } diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 137a04232aa87..df7fb28c09161 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -124,13 +124,27 @@ pub fn fuzz_param_from_state( // Value strategy that uses the state. let value = || { let state = state.clone(); - // Use `Index` instead of `Selector` to not iterate over the entire dictionary. - any::().prop_map(move |index| { - let state = state.dictionary_read(); - let values = state.values(); - let index = index.index(values.len()); - *values.iter().nth(index).unwrap() - }) + let param = param.clone(); + // Generate a bias and use it to pick samples or non-persistent values (50 / 50). + // Use `Index` instead of `Selector` when selecting a value to avoid iterating over the + // entire dictionary. + ((0..100).prop_flat_map(Just), any::()).prop_map( + move |(bias, index)| { + let state = state.dictionary_read(); + let values = match bias { + x if x < 50 => { + if let Some(sample_values) = state.samples(param.clone()) { + sample_values + } else { + state.values() + } + } + _ => state.values(), + }; + let index = index.index(values.len()); + *values.iter().nth(index).unwrap() + }, + ) }; // Convert the value based on the parameter type diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 0a05028cc8502..1bb2a7e7a9fda 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,5 +1,7 @@ use crate::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}; -use alloy_primitives::{Address, Log, B256, U256}; +use alloy_dyn_abi::{DynSolType, DynSolValue, EventExt, FunctionExt}; +use alloy_json_abi::{Function, JsonAbi}; +use alloy_primitives::{Address, Bytes, Log, B256, U256}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; @@ -10,7 +12,7 @@ use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::{AccountInfo, SpecId}, }; -use std::{fmt, sync::Arc}; +use std::{collections::HashMap, fmt, sync::Arc}; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// @@ -41,9 +43,18 @@ impl EvmFuzzState { /// Collects state changes from a [StateChangeset] and logs into an [EvmFuzzState] according to /// the given [FuzzDictionaryConfig]. - pub fn collect_state_from_call(&self, logs: &[Log], state_changeset: &StateChangeset) { + pub fn collect_values_from_call( + &self, + target_abi: Option<&JsonAbi>, + target_function: Option<&Function>, + result: &Bytes, + logs: &[Log], + state_changeset: &StateChangeset, + run_depth: u32, + ) { let mut dict = self.inner.write(); - dict.insert_logs_values(logs); + dict.insert_result_values(target_function, result, run_depth); + dict.insert_logs_values(target_abi, logs, run_depth); dict.insert_state_values(state_changeset); } @@ -74,6 +85,8 @@ pub struct FuzzDictionary { new_values: IndexSet<[u8; 32]>, /// New addresses added to the dictionary since container initialization. new_addreses: IndexSet
, + /// Sample typed values that are collected from call result and used across invariant runs. + sample_values: HashMap>, } impl fmt::Debug for FuzzDictionary { @@ -114,6 +127,61 @@ impl FuzzDictionary { } } + /// Insert values collected from call result into fuzz dictionary. + fn insert_result_values( + &mut self, + function: Option<&Function>, + result: &Bytes, + run_depth: u32, + ) { + if let Some(function) = function { + if !function.outputs.is_empty() { + // Decode result and collect samples to be used in subsequent fuzz runs. + if let Ok(decoded_result) = function.abi_decode_output(result, false) { + self.insert_sample_values(decoded_result, run_depth); + } + } + } + } + + /// Insert values from call log topics and data into fuzz dictionary. + fn insert_logs_values(&mut self, abi: Option<&JsonAbi>, logs: &[Log], run_depth: u32) { + let mut samples = Vec::new(); + // Decode logs with known events and collect samples from indexed fields and event body. + for log in logs { + let mut log_decoded = false; + // Try to decode log with events from contract abi. + if let Some(abi) = abi { + for event in abi.events() { + if let Ok(decoded_event) = event.decode_log(log, false) { + samples.extend(decoded_event.indexed); + samples.extend(decoded_event.body); + log_decoded = true; + break; + } + } + } + + // If we weren't able to decode event then we insert raw data in fuzz dictionary. + if !log_decoded { + for topic in log.topics() { + self.insert_value(topic.0, true); + } + let chunks = log.data.data.chunks_exact(32); + let rem = chunks.remainder(); + for chunk in chunks { + self.insert_value(chunk.try_into().unwrap(), true); + } + if !rem.is_empty() { + self.insert_value(B256::right_padding_from(rem).0, true); + } + } + } + + // Insert samples collected from current call in fuzz dictionary. + self.insert_sample_values(samples, run_depth); + } + /// Insert values from call state changeset into fuzz dictionary. /// These values are removed at the end of current run. fn insert_state_values(&mut self, state_changeset: &StateChangeset) { @@ -131,24 +199,6 @@ impl FuzzDictionary { } } - /// Insert values from call log topics and data into fuzz dictionary. - /// These values are removed at the end of current run. - fn insert_logs_values(&mut self, logs: &[Log]) { - for log in logs { - for topic in log.topics() { - self.insert_value(topic.0, true); - } - let chunks = log.data.data.chunks_exact(32); - let rem = chunks.remainder(); - for chunk in chunks { - self.insert_value(chunk.try_into().unwrap(), true); - } - if !rem.is_empty() { - self.insert_value(B256::right_padding_from(rem).0, true); - } - } - } - /// Insert values from push bytes into fuzz dictionary. /// If values are newly collected then they are removed at the end of current run. fn insert_push_bytes_values( @@ -206,17 +256,44 @@ impl FuzzDictionary { } } + /// Insert sample values that are reused across multiple runs. + /// The number of samples is limited to invariant run depth. + /// If collected samples limit is reached then values are inserted as regular values. + pub fn insert_sample_values(&mut self, sample_values: Vec, limit: u32) { + for sample in sample_values { + let sample_type = sample.as_type().unwrap(); + let sample_value = sample.as_word().unwrap().into(); + + if let Some(values) = self.sample_values.get_mut(&sample_type) { + if values.len() < limit as usize { + values.insert(sample_value); + } else { + // Insert as state value (will be removed at the end of the run). + self.insert_value(sample_value, true); + } + } else { + self.sample_values.entry(sample_type).or_default().insert(sample_value); + } + } + } + #[inline] pub fn values(&self) -> &IndexSet<[u8; 32]> { &self.state_values } + #[inline] + pub fn samples(&self, param_type: DynSolType) -> Option<&IndexSet<[u8; 32]>> { + self.sample_values.get(¶m_type) + } + #[inline] pub fn addresses(&self) -> &IndexSet
{ &self.addresses } pub fn revert(&mut self) { + // Revert new values collected during the run. for key in self.new_values.iter() { self.state_values.swap_remove(key); } diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 90bc4c9c590e7..cb39b650098ff 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -181,6 +181,26 @@ async fn test_invariant() { "default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol:ShrinkFailOnRevertTest", vec![("invariant_shrink_fail_on_revert()", true, None, None, None)], ), + ( + "default/fuzz/invariant/common/InvariantScrapeValues.t.sol:FindFromReturnValueTest", + vec![( + "invariant_value_not_found()", + false, + Some("revert: value from return found".into()), + None, + None, + )], + ), + ( + "default/fuzz/invariant/common/InvariantScrapeValues.t.sol:FindFromLogValueTest", + vec![( + "invariant_value_not_found()", + false, + Some("revert: value from logs found".into()), + None, + None, + )], + ) ]), ); } @@ -566,3 +586,35 @@ async fn test_invariant_fixtures() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_scrape_values() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantScrapeValues.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([ + ( + "default/fuzz/invariant/common/InvariantScrapeValues.t.sol:FindFromReturnValueTest", + vec![( + "invariant_value_not_found()", + false, + Some("revert: value from return found".into()), + None, + None, + )], + ), + ( + "default/fuzz/invariant/common/InvariantScrapeValues.t.sol:FindFromLogValueTest", + vec![( + "invariant_value_not_found()", + false, + Some("revert: value from logs found".into()), + None, + None, + )], + ), + ]), + ); +} diff --git a/testdata/default/fuzz/invariant/common/InvariantScrapeValues.t.sol b/testdata/default/fuzz/invariant/common/InvariantScrapeValues.t.sol new file mode 100644 index 0000000000000..40824a2602e77 --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantScrapeValues.t.sol @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract FindFromReturnValue { + bool public found = false; + + function seed() public returns (int256) { + int256 mystery = 13337; + return (1337 + mystery); + } + + function find(int256 i) public { + int256 mystery = 13337; + if (i == 1337 + mystery) { + found = true; + } + } +} + +contract FindFromReturnValueTest is DSTest { + FindFromReturnValue target; + + function setUp() public { + target = new FindFromReturnValue(); + } + + /// forge-config: default.invariant.runs = 50 + /// forge-config: default.invariant.depth = 300 + /// forge-config: default.invariant.fail-on-revert = true + function invariant_value_not_found() public view { + require(!target.found(), "value from return found"); + } +} + +contract FindFromLogValue { + event FindFromLog(int256 indexed mystery, bytes32 rand); + + bool public found = false; + + function seed() public { + int256 mystery = 13337; + emit FindFromLog(1337 + mystery, keccak256(abi.encodePacked("mystery"))); + } + + function find(int256 i) public { + int256 mystery = 13337; + if (i == 1337 + mystery) { + found = true; + } + } +} + +contract FindFromLogValueTest is DSTest { + FindFromLogValue target; + + function setUp() public { + target = new FindFromLogValue(); + } + + /// forge-config: default.invariant.runs = 50 + /// forge-config: default.invariant.depth = 300 + /// forge-config: default.invariant.fail-on-revert = true + function invariant_value_not_found() public view { + require(!target.found(), "value from logs found"); + } +} From 1b08ae4ece84a862d1d85a6e6b41bc64311bfb1e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 20 May 2024 21:11:10 +0300 Subject: [PATCH 0972/1963] fix(fuzz) - consistent snapshot results between runs (#7951) * fix(fuzz) - consistent gas snapshot between runs * sort storage values before inserting * Revert "fix(fuzz) - consistent gas snapshot between runs" This reverts commit cf187fb2315c191782129c2fca0e3318a8a3a36d. --------- Co-authored-by: Arsenii Kulikov --- crates/evm/fuzz/src/strategies/state.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 1bb2a7e7a9fda..0bcf81baee50a 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -12,7 +12,11 @@ use revm::{ interpreter::opcode::{self, spec_opcode_gas}, primitives::{AccountInfo, SpecId}, }; -use std::{collections::HashMap, fmt, sync::Arc}; +use std::{ + collections::{BTreeMap, HashMap}, + fmt, + sync::Arc, +}; /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// @@ -113,7 +117,9 @@ impl FuzzDictionary { self.insert_push_bytes_values(address, &account.info, false); // Insert storage values. if self.config.include_storage { - for (slot, value) in &account.storage { + // Sort storage values before inserting to ensure deterministic dictionary. + let values = account.storage.iter().collect::>(); + for (slot, value) in values { self.insert_storage_value(slot, value, false); } } From c9ae920ae3e215a02e77384d1fc0b2eb4a5d0d96 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 21 May 2024 07:59:58 +0300 Subject: [PATCH 0973/1963] feature(invariant) - persist and replay failure (#7899) * feature(invariant) - persist and replay failure * Fix unit test * Changes after review: - replace test cache rm macro with closure - use commons for load / persist failure sequence * Changes after review: display proper message if replayed sequence reverts before checking invariant * Changes after review: simplify check sequence logic --- crates/config/src/invariant.rs | 37 ++++- crates/config/src/lib.rs | 27 ++-- crates/evm/evm/src/executors/fuzz/mod.rs | 13 +- crates/evm/evm/src/executors/invariant/mod.rs | 1 + .../evm/evm/src/executors/invariant/replay.rs | 46 +++--- .../evm/evm/src/executors/invariant/shrink.rs | 63 ++++---- crates/evm/fuzz/src/lib.rs | 44 ++++-- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/runner.rs | 103 +++++++++++-- crates/forge/tests/cli/cmd.rs | 25 +++- crates/forge/tests/cli/config.rs | 6 +- crates/forge/tests/it/invariant.rs | 137 ++++++++++-------- crates/forge/tests/it/test_helpers.rs | 1 + 14 files changed, 343 insertions(+), 164 deletions(-) diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index fa9e5489f79d5..869125324cc56 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -8,9 +8,10 @@ use crate::{ }, }; use serde::{Deserialize, Serialize}; +use std::path::PathBuf; /// Contains for invariant testing -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct InvariantConfig { /// The number of runs that must execute for each invariant test group. pub runs: u32, @@ -31,6 +32,8 @@ pub struct InvariantConfig { pub max_assume_rejects: u32, /// Number of runs to execute and include in the gas report. pub gas_report_samples: u32, + /// Path where invariant failures are recorded and replayed. + pub failure_persist_dir: Option, } impl Default for InvariantConfig { @@ -44,10 +47,36 @@ impl Default for InvariantConfig { shrink_run_limit: 2usize.pow(18_u32), max_assume_rejects: 65536, gas_report_samples: 256, + failure_persist_dir: None, } } } +impl InvariantConfig { + /// Creates invariant configuration to write failures in `{PROJECT_ROOT}/cache/fuzz` dir. + pub fn new(cache_dir: PathBuf) -> Self { + InvariantConfig { + runs: 256, + depth: 15, + fail_on_revert: false, + call_override: false, + dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() }, + shrink_run_limit: 2usize.pow(18_u32), + max_assume_rejects: 65536, + gas_report_samples: 256, + failure_persist_dir: Some(cache_dir), + } + } + + /// Returns path to failure dir of given invariant test contract. + pub fn failure_dir(self, contract_name: &str) -> PathBuf { + self.failure_persist_dir + .unwrap() + .join("failures") + .join(contract_name.split(':').last().unwrap()) + } +} + impl InlineConfigParser for InvariantConfig { fn config_key() -> String { INLINE_CONFIG_INVARIANT_KEY.into() @@ -60,8 +89,7 @@ impl InlineConfigParser for InvariantConfig { return Ok(None) } - // self is Copy. We clone it with dereference. - let mut conf_clone = *self; + let mut conf_clone = self.clone(); for pair in overrides { let key = pair.0; @@ -71,6 +99,9 @@ impl InlineConfigParser for InvariantConfig { "depth" => conf_clone.depth = parse_config_u32(key, value)?, "fail-on-revert" => conf_clone.fail_on_revert = parse_config_bool(key, value)?, "call-override" => conf_clone.call_override = parse_config_bool(key, value)?, + "failure-persist-dir" => { + conf_clone.failure_persist_dir = Some(PathBuf::from(value)) + } _ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?, } } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 9c490ef031de4..e48f8d571e055 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -21,7 +21,7 @@ use foundry_compilers::{ }, cache::SOLIDITY_FILES_CACHE_FILENAME, compilers::{solc::SolcVersionManager, CompilerVersionManager}, - error::{SolcError, SolcIoError}, + error::SolcError, remappings::{RelativeRemapping, Remapping}, CompilerConfig, ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, SolcConfig, @@ -793,13 +793,17 @@ impl Config { pub fn cleanup(&self, project: &Project) -> Result<(), SolcError> { project.cleanup()?; - // Remove fuzz cache directory. - if let Some(fuzz_cache) = &self.fuzz.failure_persist_dir { - let path = project.root().join(fuzz_cache); - if path.exists() { - std::fs::remove_dir_all(&path).map_err(|e| SolcIoError::new(e, path))?; + // Remove fuzz and invariant cache directories. + let remove_test_dir = |test_dir: &Option| { + if let Some(test_dir) = test_dir { + let path = project.root().join(test_dir); + if path.exists() { + let _ = fs::remove_dir_all(&path); + } } - } + }; + remove_test_dir(&self.fuzz.failure_persist_dir); + remove_test_dir(&self.invariant.failure_persist_dir); Ok(()) } @@ -1958,7 +1962,7 @@ impl Default for Config { path_pattern: None, path_pattern_inverse: None, fuzz: FuzzConfig::new("cache/fuzz".into()), - invariant: Default::default(), + invariant: InvariantConfig::new("cache/invariant".into()), always_use_create_2_factory: false, ffi: false, prompt_timeout: 120, @@ -4461,7 +4465,12 @@ mod tests { let loaded = Config::load().sanitized(); assert_eq!( loaded.invariant, - InvariantConfig { runs: 512, depth: 10, ..Default::default() } + InvariantConfig { + runs: 512, + depth: 10, + failure_persist_dir: Some(PathBuf::from("cache/invariant")), + ..Default::default() + } ); Ok(()) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index d81ddbaca01b3..520a56cf2fe76 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -175,15 +175,10 @@ impl FuzzedExecutor { } else { vec![] }; - result.counterexample = Some(CounterExample::Single(BaseCounterExample { - sender: None, - addr: None, - signature: None, - contract_name: None, - traces: call.traces, - calldata, - args, - })); + + result.counterexample = Some(CounterExample::Single( + BaseCounterExample::from_fuzz_call(calldata, args, call.traces), + )); } _ => {} } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index ef7823342eff1..edf1f929187e6 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -40,6 +40,7 @@ mod result; pub use result::InvariantFuzzTestResult; mod shrink; +pub use shrink::check_sequence; sol! { interface IInvariantTest { diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index a225ccb2c921d..1da2a3ebdb5a5 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -8,7 +8,7 @@ use foundry_evm_core::constants::CALLER; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ invariant::{BasicTxDetails, InvariantContract}, - BaseCounterExample, CounterExample, + BaseCounterExample, }; use foundry_evm_traces::{load_contracts, TraceKind, Traces}; use parking_lot::RwLock; @@ -28,7 +28,7 @@ pub fn replay_run( traces: &mut Traces, coverage: &mut Option, inputs: Vec, -) -> Result> { +) -> Result> { // We want traces for a failed case. executor.set_tracing(true); @@ -60,31 +60,34 @@ pub fn replay_run( )); // Create counter example to be used in failed case. - counterexample_sequence.push(BaseCounterExample::create( + counterexample_sequence.push(BaseCounterExample::from_invariant_call( tx.sender, tx.call_details.target, &tx.call_details.calldata, &ided_contracts, call_result.traces, )); - - // Replay invariant to collect logs and traces. - let error_call_result = executor.call_raw( - CALLER, - invariant_contract.address, - invariant_contract - .invariant_function - .abi_encode_input(&[]) - .expect("invariant should have no inputs") - .into(), - U256::ZERO, - )?; - traces.push((TraceKind::Execution, error_call_result.traces.clone().unwrap())); - logs.extend(error_call_result.logs); } - Ok((!counterexample_sequence.is_empty()) - .then_some(CounterExample::Sequence(counterexample_sequence))) + // Replay invariant to collect logs and traces. + // We do this only once at the end of the replayed sequence. + // Checking after each call doesn't add valuable info for passing scenario + // (invariant call result is always success) nor for failed scenarios + // (invariant call result is always success until the last call that breaks it). + let invariant_result = executor.call_raw( + CALLER, + invariant_contract.address, + invariant_contract + .invariant_function + .abi_encode_input(&[]) + .expect("invariant should have no inputs") + .into(), + U256::ZERO, + )?; + traces.push((TraceKind::Execution, invariant_result.traces.clone().unwrap())); + logs.extend(invariant_result.logs); + + Ok(counterexample_sequence) } /// Replays the error case, shrinks the failing sequence and collects all necessary traces. @@ -98,15 +101,16 @@ pub fn replay_error( logs: &mut Vec, traces: &mut Traces, coverage: &mut Option, -) -> Result> { +) -> Result> { match failed_case.test_error { // Don't use at the moment. - TestError::Abort(_) => Ok(None), + TestError::Abort(_) => Ok(vec![]), TestError::Fail(_, ref calls) => { // Shrink sequence of failed calls. let calls = shrink_sequence(failed_case, calls, &executor)?; set_up_inner_replay(&mut executor, &failed_case.inner_sequence); + // Replay calls to get the counterexample and to collect logs, traces and coverage. replay_run( invariant_contract, diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index e6af9c1bcfd8e..47711e11bb9cf 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -1,5 +1,5 @@ use crate::executors::{invariant::error::FailedInvariantCaseData, Executor}; -use alloy_primitives::U256; +use alloy_primitives::{Address, Bytes, U256}; use foundry_evm_core::constants::CALLER; use foundry_evm_fuzz::invariant::BasicTxDetails; use proptest::bits::{BitSetLike, VarBitSet}; @@ -97,12 +97,19 @@ pub(crate) fn shrink_sequence( let mut shrinker = CallSequenceShrinker::new(calls.len()); for _ in 0..failed_case.shrink_run_limit { // Check candidate sequence result. - match check_sequence(failed_case, executor.clone(), calls, shrinker.current().collect()) { + match check_sequence( + executor.clone(), + calls, + shrinker.current().collect(), + failed_case.addr, + failed_case.func.clone(), + failed_case.fail_on_revert, + ) { // If candidate sequence still fails then shrink more if possible. - Ok(false) if !shrinker.simplify() => break, + Ok((false, _)) if !shrinker.simplify() => break, // If candidate sequence pass then restore last removed call and shrink other // calls if possible. - Ok(true) if !shrinker.complicate() => break, + Ok((true, _)) if !shrinker.complicate() => break, _ => {} } } @@ -110,15 +117,19 @@ pub(crate) fn shrink_sequence( Ok(shrinker.current().map(|idx| &calls[idx]).cloned().collect()) } -/// Checks if the shrinked sequence fails test, if it does then we can try simplifying more. -fn check_sequence( - failed_case: &FailedInvariantCaseData, +/// Checks if the given call sequence breaks the invariant. +/// Used in shrinking phase for checking candidate sequences and in replay failures phase to test +/// persisted failures. +/// Returns the result of invariant check and if sequence was entirely applied. +pub fn check_sequence( mut executor: Executor, calls: &[BasicTxDetails], sequence: Vec, -) -> eyre::Result { - let mut sequence_failed = false; - // Apply the shrinked candidate sequence. + test_address: Address, + test_function: Bytes, + fail_on_revert: bool, +) -> eyre::Result<(bool, bool)> { + // Apply the call sequence. for call_index in sequence { let tx = &calls[call_index]; let call_result = executor.call_raw_committing( @@ -127,30 +138,22 @@ fn check_sequence( tx.call_details.calldata.clone(), U256::ZERO, )?; - if call_result.reverted && failed_case.fail_on_revert { + if call_result.reverted && fail_on_revert { // Candidate sequence fails test. // We don't have to apply remaining calls to check sequence. - sequence_failed = true; - break; + return Ok((false, false)); } } - // Return without checking the invariant if we already have failing sequence. - if sequence_failed { - return Ok(false); - }; - // Check the invariant for candidate sequence. - // If sequence fails then we can continue with shrinking - the removed call does not affect - // failure. - // - // If sequence doesn't fail then we have to restore last removed call and continue with next - // call - removed call is a required step for reproducing the failure. - let mut call_result = - executor.call_raw(CALLER, failed_case.addr, failed_case.func.clone(), U256::ZERO)?; - Ok(executor.is_raw_call_success( - failed_case.addr, - Cow::Owned(call_result.state_changeset.take().unwrap()), - &call_result, - false, + // Check the invariant for call sequence. + let mut call_result = executor.call_raw(CALLER, test_address, test_function, U256::ZERO)?; + Ok(( + executor.is_raw_call_success( + test_address, + Cow::Owned(call_result.state_changeset.take().unwrap()), + &call_result, + false, + ), + true, )) } diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index b2a058e5bb022..c6b5e00499e88 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -43,19 +43,20 @@ pub struct BaseCounterExample { pub addr: Option
, /// The data to provide pub calldata: Bytes, - /// Function signature if it exists - pub signature: Option, /// Contract name if it exists pub contract_name: Option, + /// Function signature if it exists + pub signature: Option, + /// Args used to call the function + pub args: Option, /// Traces #[serde(skip)] pub traces: Option, - #[serde(skip)] - pub args: Vec, } impl BaseCounterExample { - pub fn create( + /// Creates counter example representing a step from invariant call sequence. + pub fn from_invariant_call( sender: Address, addr: Address, bytes: &Bytes, @@ -70,10 +71,12 @@ impl BaseCounterExample { sender: Some(sender), addr: Some(addr), calldata: bytes.clone(), - signature: Some(func.signature()), contract_name: Some(name.clone()), + signature: Some(func.signature()), + args: Some( + foundry_common::fmt::format_tokens(&args).format(", ").to_string(), + ), traces, - args, }; } } @@ -83,10 +86,27 @@ impl BaseCounterExample { sender: Some(sender), addr: Some(addr), calldata: bytes.clone(), + contract_name: None, signature: None, + args: None, + traces, + } + } + + /// Creates counter example for a fuzz test failure. + pub fn from_fuzz_call( + bytes: Bytes, + args: Vec, + traces: Option, + ) -> Self { + BaseCounterExample { + sender: None, + addr: None, + calldata: bytes, contract_name: None, + signature: None, + args: Some(foundry_common::fmt::format_tokens(&args).format(", ").to_string()), traces, - args: vec![], } } } @@ -108,10 +128,14 @@ impl fmt::Display for BaseCounterExample { if let Some(sig) = &self.signature { write!(f, "calldata={sig}")? } else { - write!(f, "calldata={}", self.calldata)? + write!(f, "calldata={}", &self.calldata)? } - write!(f, " args=[{}]", foundry_common::fmt::format_tokens(&self.args).format(", ")) + if let Some(args) = &self.args { + write!(f, " args=[{}]", args) + } else { + write!(f, " args=[]") + } } } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index d099035fb8043..d55c4db9a84bd 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -312,7 +312,7 @@ impl CoverageArgs { .with_fork(evm_opts.get_fork(&config, env.clone())) .with_test_options(TestOptions { fuzz: config.fuzz.clone(), - invariant: config.invariant, + invariant: config.invariant.clone(), ..Default::default() }) .set_coverage(true) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index cef2349661479..720d132847602 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -257,7 +257,7 @@ impl TestArgs { let test_options: TestOptions = TestOptionsBuilder::default() .fuzz(config.fuzz.clone()) - .invariant(config.invariant) + .invariant(config.invariant.clone()) .profiles(profiles) .build(&output, project_root)?; diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 48fa10b6dcd08..3f4824c22c713 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -1,6 +1,7 @@ //! The Forge test runner. use crate::{ + fuzz::{invariant::BasicTxDetails, BaseCounterExample}, multi_runner::{is_matching_test, TestContract}, result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, @@ -21,18 +22,23 @@ use foundry_evm::{ executors::{ fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, invariant::{ - replay_error, replay_run, InvariantExecutor, InvariantFuzzError, + check_sequence, replay_error, replay_run, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult, }, CallResult, EvmError, ExecutionErr, Executor, RawCallResult, }, - fuzz::{fixture_name, invariant::InvariantContract, CounterExample, FuzzFixtures}, + fuzz::{ + fixture_name, + invariant::{CallDetails, InvariantContract}, + CounterExample, FuzzFixtures, + }, traces::{load_contracts, TraceKind}, }; use proptest::test_runner::TestRunner; use rayon::prelude::*; use std::{ borrow::Cow, + cmp::min, collections::{BTreeMap, HashMap}, sync::Arc, time::Instant, @@ -359,7 +365,7 @@ impl<'a> ContractRunner<'a> { self.run_invariant_test( runner, setup, - *invariant_config, + invariant_config.clone(), func, &known_contracts, identified_contracts.as_ref().unwrap(), @@ -548,14 +554,82 @@ impl<'a> ContractRunner<'a> { let mut evm = InvariantExecutor::new( self.executor.clone(), runner, - invariant_config, + invariant_config.clone(), identified_contracts, known_contracts, ); - let invariant_contract = InvariantContract { address, invariant_function: func, abi: &self.contract.abi }; + let mut logs = logs.clone(); + let mut traces = traces.clone(); + let mut coverage = coverage.clone(); + + let failure_dir = invariant_config.clone().failure_dir(self.name); + let failure_file = failure_dir.join(invariant_contract.invariant_function.clone().name); + + // Try to replay recorded failure if any. + if let Ok(call_sequence) = + foundry_common::fs::read_json_file::>(failure_file.as_path()) + { + // Create calls from failed sequence and check if invariant still broken. + let txes = call_sequence + .clone() + .into_iter() + .map(|seq| BasicTxDetails { + sender: seq.sender.unwrap_or_default(), + call_details: CallDetails { + target: seq.addr.unwrap_or_default(), + calldata: seq.calldata, + }, + }) + .collect::>(); + if let Ok((success, replayed_entirely)) = check_sequence( + self.executor.clone(), + &txes, + (0..min(txes.len(), invariant_config.depth as usize)).collect(), + invariant_contract.address, + invariant_contract.invariant_function.selector().to_vec().into(), + invariant_config.fail_on_revert, + ) { + if !success { + // If sequence still fails then replay error to collect traces and + // exit without executing new runs. + let _ = replay_run( + &invariant_contract, + self.executor.clone(), + known_contracts, + identified_contracts.clone(), + &mut logs, + &mut traces, + &mut coverage, + txes, + ); + return TestResult { + status: TestStatus::Failure, + reason: if replayed_entirely { + Some(format!( + "{} replay failure", + invariant_contract.invariant_function.name + )) + } else { + Some(format!( + "{} persisted failure revert", + invariant_contract.invariant_function.name + )) + }, + decoded_logs: decode_console_logs(&logs), + traces, + coverage, + counterexample: Some(CounterExample::Sequence(call_sequence)), + kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, + duration: start.elapsed(), + ..Default::default() + } + } + } + } + let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs, gas_report_traces } = match evm.invariant_fuzz(invariant_contract.clone(), &fuzz_fixtures) { Ok(x) => x, @@ -576,11 +650,9 @@ impl<'a> ContractRunner<'a> { }; let mut counterexample = None; - let mut logs = logs.clone(); - let mut traces = traces.clone(); let success = error.is_none(); let reason = error.as_ref().and_then(|err| err.revert_reason()); - let mut coverage = coverage.clone(); + match error { // If invariants were broken, replay the error to collect logs and traces Some(error) => match error { @@ -598,7 +670,20 @@ impl<'a> ContractRunner<'a> { &mut traces, &mut coverage, ) { - Ok(c) => counterexample = c, + Ok(call_sequence) => { + if !call_sequence.is_empty() { + // Persist error in invariant failure dir. + if let Err(err) = foundry_common::fs::create_dir_all(failure_dir) { + error!(%err, "Failed to create invariant failure dir"); + } else if let Err(err) = foundry_common::fs::write_json_file( + failure_file.as_path(), + &call_sequence, + ) { + error!(%err, "Failed to record call sequence"); + } + counterexample = Some(CounterExample::Sequence(call_sequence)) + } + } Err(err) => { error!(%err, "Failed to replay invariant error"); } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index b4d8df8ccd3a3..de2c242418a06 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -3,7 +3,7 @@ use crate::constants::*; use foundry_compilers::{artifacts::Metadata, remappings::Remapping, ConfigurableContractArtifact}; use foundry_config::{ - parse_with_profile, BasicConfig, Chain, Config, FuzzConfig, SolidityErrorCode, + parse_with_profile, BasicConfig, Chain, Config, FuzzConfig, InvariantConfig, SolidityErrorCode, }; use foundry_test_utils::{ foundry_compilers::PathStyle, @@ -546,18 +546,27 @@ forgetest_init!(can_clean_config, |prj, cmd| { assert!(!artifact.exists()); }); -// checks that `clean` removes fuzz cache dir -forgetest_init!(can_clean_fuzz_cache, |prj, cmd| { - let config = Config { fuzz: FuzzConfig::new("cache/fuzz".into()), ..Default::default() }; +// checks that `clean` removes fuzz and invariant cache dirs +forgetest_init!(can_clean_test_cache, |prj, cmd| { + let config = Config { + fuzz: FuzzConfig::new("cache/fuzz".into()), + invariant: InvariantConfig::new("cache/invariant".into()), + ..Default::default() + }; prj.write_config(config); // default test contract is written in custom out directory - let cache_dir = prj.root().join("cache/fuzz"); - let _ = fs::create_dir(cache_dir.clone()); - assert!(cache_dir.exists()); + let fuzz_cache_dir = prj.root().join("cache/fuzz"); + let _ = fs::create_dir(fuzz_cache_dir.clone()); + let invariant_cache_dir = prj.root().join("cache/invariant"); + let _ = fs::create_dir(invariant_cache_dir.clone()); + + assert!(fuzz_cache_dir.exists()); + assert!(invariant_cache_dir.exists()); cmd.forge_fuse().arg("clean"); cmd.output(); - assert!(!cache_dir.exists()); + assert!(!fuzz_cache_dir.exists()); + assert!(!invariant_cache_dir.exists()); }); // checks that extra output works diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index c0856ce08af8a..aec3b6dc21d7e 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -72,7 +72,11 @@ forgetest!(can_extract_config_values, |prj, cmd| { failure_persist_file: Some("failures".to_string()), ..Default::default() }, - invariant: InvariantConfig { runs: 256, ..Default::default() }, + invariant: InvariantConfig { + runs: 256, + failure_persist_dir: Some("test-cache/fuzz".into()), + ..Default::default() + }, ffi: true, always_use_create_2_factory: false, prompt_timeout: 0, diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index cb39b650098ff..abdd6591a490d 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -2,14 +2,33 @@ use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_primitives::U256; -use forge::{fuzz::CounterExample, result::TestStatus, TestOptions}; +use forge::{fuzz::CounterExample, TestOptions}; use foundry_test_utils::Filter; use std::collections::BTreeMap; +macro_rules! get_counterexample { + ($runner:ident, $filter:expr) => { + $runner + .test_collect($filter) + .values() + .last() + .expect("Invariant contract should be testable.") + .test_results + .values() + .last() + .expect("Invariant contract should be testable.") + .counterexample + .as_ref() + .expect("Invariant contract should have failed with a counterexample.") + }; +} + #[tokio::test(flavor = "multi_thread")] async fn test_invariant() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"); let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.failure_persist_dir = + Some(tempfile::tempdir().unwrap().into_path()); let results = runner.test_collect(&filter); assert_multiple( @@ -275,20 +294,8 @@ async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.fuzz.seed = Some(U256::from(119u32)); - let results = runner.test_collect(&filter); - let results = - results.values().last().expect("`InvariantInnerContract.t.sol` should be testable."); - - let result = - results.test_results.values().last().expect("`InvariantInnerContract` should be testable."); - - let counter = result - .counterexample - .as_ref() - .expect("`InvariantInnerContract` should have failed with a counterexample."); - - match counter { + match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), // `fuzz_seed` at 119 makes this sequence shrinkable from 4 to 2. CounterExample::Sequence(sequence) => { @@ -333,23 +340,8 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { ); let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options = opts.clone(); - let results = runner.test_collect(&filter); - let results = results.values().last().expect("`InvariantShrinkWithAssert` should be testable."); - - let result = results - .test_results - .values() - .last() - .expect("`InvariantShrinkWithAssert` should be testable."); - assert_eq!(result.status, TestStatus::Failure); - - let counter = result - .counterexample - .as_ref() - .expect("`InvariantShrinkWithAssert` should have failed with a counterexample."); - - match counter { + match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), CounterExample::Sequence(sequence) => { assert!(sequence.len() <= 3); @@ -369,30 +361,67 @@ async fn test_shrink_big_sequence() { runner.test_options = opts.clone(); runner.test_options.invariant.runs = 1; runner.test_options.invariant.depth = 500; - let results = runner.test_collect(&filter); - let results = - results.values().last().expect("`InvariantShrinkBigSequence` should be testable."); - let result = results + let initial_counterexample = runner + .test_collect(&filter) + .values() + .last() + .expect("Invariant contract should be testable.") .test_results .values() .last() - .expect("`InvariantShrinkBigSequence` should be testable."); + .expect("Invariant contract should be testable.") + .counterexample + .clone() + .unwrap(); - assert_eq!(result.status, TestStatus::Failure); + let initial_sequence = match initial_counterexample { + CounterExample::Single(_) => panic!("CounterExample should be a sequence."), + CounterExample::Sequence(sequence) => sequence, + }; + // ensure shrinks to same sequence of 77 + assert_eq!(initial_sequence.len(), 77); - let counter = result + // test failure persistence + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol:ShrinkBigSequenceTest", + vec![( + "invariant_shrink_big_sequence()", + false, + Some("invariant_shrink_big_sequence replay failure".into()), + None, + None, + )], + )]), + ); + let new_sequence = match results + .values() + .last() + .expect("Invariant contract should be testable.") + .test_results + .values() + .last() + .expect("Invariant contract should be testable.") .counterexample - .as_ref() - .expect("`InvariantShrinkBigSequence` should have failed with a counterexample."); - - match counter { + .clone() + .unwrap() + { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), - CounterExample::Sequence(sequence) => { - // ensure shrinks to same sequence of 77 - assert_eq!(sequence.len(), 77); - } + CounterExample::Sequence(sequence) => sequence, }; + // ensure shrinks to same sequence of 77 + assert_eq!(new_sequence.len(), 77); + // ensure calls within failed sequence are the same as initial one + for index in 0..77 { + let new_call = new_sequence.get(index).unwrap(); + let initial_call = initial_sequence.get(index).unwrap(); + assert_eq!(new_call.sender, initial_call.sender); + assert_eq!(new_call.addr, initial_call.addr); + assert_eq!(new_call.calldata, initial_call.calldata); + } } #[tokio::test(flavor = "multi_thread")] @@ -408,24 +437,8 @@ async fn test_shrink_fail_on_revert() { runner.test_options.invariant.fail_on_revert = true; runner.test_options.invariant.runs = 1; runner.test_options.invariant.depth = 100; - let results = runner.test_collect(&filter); - let results = - results.values().last().expect("`InvariantShrinkFailOnRevert` should be testable."); - - let result = results - .test_results - .values() - .last() - .expect("`InvariantShrinkFailOnRevert` should be testable."); - - assert_eq!(result.status, TestStatus::Failure); - - let counter = result - .counterexample - .as_ref() - .expect("`InvariantShrinkFailOnRevert` should have failed with a counterexample."); - match counter { + match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), CounterExample::Sequence(sequence) => { // ensure shrinks to sequence of 10 diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index be87b9ce9348a..b2993151d3275 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -107,6 +107,7 @@ impl ForgeTestProfile { shrink_run_limit: 2usize.pow(18u32), max_assume_rejects: 65536, gas_report_samples: 256, + failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), }) .build(output, Path::new(self.project().root())) .expect("Config loaded") From 003d0889ddb2aba5af8ff3606ae692e660156ae8 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 21 May 2024 04:01:36 -0400 Subject: [PATCH 0974/1963] feat(cast): send 4844 support (#7823) * feat(cast-send): 4844 support boilerplate * send 4844 initial test success * add path arg * use coder ingest * bump alloy d78e79e - satisfy clippy * clap nit and use get_blob_base_fee * nits * fix: cast cli tests --- Cargo.toml | 5 ++++- crates/cast/Cargo.toml | 2 +- crates/cast/bin/cmd/mktx.rs | 2 +- crates/cast/bin/cmd/send.rs | 17 ++++++++++++++--- crates/cast/bin/tx.rs | 19 +++++++++++++++++++ crates/cli/src/opts/transaction.rs | 8 ++++++++ 6 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a807d1983c4c7..55d368d4a5acf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -188,7 +188,10 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 59ac39e269856..d6837b17622be 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -37,7 +37,7 @@ alloy-json-rpc.workspace = true alloy-signer.workspace = true alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } alloy-contract.workspace = true -alloy-consensus = { workspace = true, features = ["serde"] } +alloy-consensus = { workspace = true, features = ["serde", "kzg"] } alloy-network.workspace = true alloy-sol-types.workspace = true alloy-chains.workspace = true diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index e26115da32ab5..6b7b08c6fa3ac 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -97,7 +97,7 @@ impl MakeTxArgs { let provider = get_provider(&config)?; let (tx, _) = - tx::build_tx(&provider, from, to, code, sig, args, tx, chain, api_key).await?; + tx::build_tx(&provider, from, to, code, sig, args, tx, chain, api_key, None).await?; let tx = tx.build(&EthereumSigner::new(signer)).await?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 7799f522691d8..3a6de10a9256c 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -14,7 +14,7 @@ use foundry_cli::{ }; use foundry_common::{cli_warn, ens::NameOrAddress}; use foundry_config::{Chain, Config}; -use std::str::FromStr; +use std::{path::PathBuf, str::FromStr}; /// CLI arguments for `cast send`. #[derive(Debug, Parser)] @@ -59,6 +59,10 @@ pub struct SendTxArgs { #[command(flatten)] eth: EthereumOpts, + + /// The path of blob data to be sent. + #[arg(long, value_name = "BLOB_DATA_PATH", conflicts_with = "legacy", requires = "blob")] + path: Option, } #[derive(Debug, Parser)] @@ -91,8 +95,11 @@ impl SendTxArgs { resend, command, unlocked, + path, } = self; + let blob_data = if let Some(path) = path { Some(std::fs::read(path)?) } else { None }; + let code = if let Some(SendTxSubcommands::Create { code, sig: constructor_sig, @@ -161,6 +168,7 @@ impl SendTxArgs { cast_async, confirmations, to_json, + blob_data, ) .await // Case 2: @@ -196,6 +204,7 @@ impl SendTxArgs { cast_async, confirmations, to_json, + blob_data, ) .await } @@ -216,13 +225,15 @@ async fn cast_send, T: Transport + Clone>( cast_async: bool, confs: u64, to_json: bool, + blob_data: Option>, ) -> Result<()> { let (tx, _) = - tx::build_tx(&provider, from, to, code, sig, args, tx, chain, etherscan_api_key).await?; + tx::build_tx(&provider, from, to, code, sig, args, tx, chain, etherscan_api_key, blob_data) + .await?; let cast = Cast::new(provider); - let pending_tx = cast.send(tx).await?; + let tx_hash = pending_tx.inner().tx_hash(); if cast_async { diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 64b33b280712f..82b1d8b4d0bc1 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,3 +1,4 @@ +use alloy_consensus::{SidecarBuilder, SimpleCoder}; use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; use alloy_primitives::{Address, Bytes, U256}; @@ -52,16 +53,34 @@ pub async fn build_tx< tx: TransactionOpts, chain: impl Into, etherscan_api_key: Option, + blob_data: Option>, ) -> Result<(WithOtherFields, Option)> { let chain = chain.into(); let from = from.into().resolve(provider).await?; + let sidecar = blob_data + .map(|data| { + let mut coder = SidecarBuilder::::default(); + coder.ingest(&data); + coder.build() + }) + .transpose()?; + let mut req = WithOtherFields::::default() .with_from(from) .with_value(tx.value.unwrap_or_default()) .with_chain_id(chain.id()); + if let Some(sidecar) = sidecar { + req.set_blob_sidecar(sidecar); + req.populate_blob_hashes(); + req.set_max_fee_per_blob_gas( + // If blob_base_fee is 0, uses 1 wei as minimum. + tx.blob_gas_price.map_or(provider.get_blob_base_fee().await?.max(1), |g| g.to()), + ); + } + if let Some(to) = to { req.set_to(to.into().resolve(provider).await?); } else { diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index 81d6107bdea03..d424626c4df92 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -45,6 +45,14 @@ pub struct TransactionOpts { /// This is automatically enabled for common networks without EIP1559. #[arg(long)] pub legacy: bool, + + /// Send a EIP-4844 blob transaction. + #[arg(long, conflicts_with = "legacy")] + pub blob: bool, + + /// Gas price for EIP-4844 blob transaction. + #[arg(long, conflicts_with = "legacy", value_parser = parse_ether_value, env = "ETH_BLOB_GAS_PRICE", value_name = "BLOB_PRICE")] + pub blob_gas_price: Option, } #[cfg(test)] From 0a5b22f07ba4f2ddf525089c8ee9cdcb05e44bd9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 21 May 2024 13:13:10 +0300 Subject: [PATCH 0975/1963] fix(invariant): panic when decoding logs with None value (#7956) * fix(invariant): panic when decoding logs with None value * Changes after review: code cleanup --- crates/evm/fuzz/src/strategies/state.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 0bcf81baee50a..791ca3d9a67e4 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -267,18 +267,18 @@ impl FuzzDictionary { /// If collected samples limit is reached then values are inserted as regular values. pub fn insert_sample_values(&mut self, sample_values: Vec, limit: u32) { for sample in sample_values { - let sample_type = sample.as_type().unwrap(); - let sample_value = sample.as_word().unwrap().into(); - - if let Some(values) = self.sample_values.get_mut(&sample_type) { - if values.len() < limit as usize { - values.insert(sample_value); + if let (Some(sample_type), Some(sample_value)) = (sample.as_type(), sample.as_word()) { + let sample_value = sample_value.into(); + if let Some(values) = self.sample_values.get_mut(&sample_type) { + if values.len() < limit as usize { + values.insert(sample_value); + } else { + // Insert as state value (will be removed at the end of the run). + self.insert_value(sample_value, true); + } } else { - // Insert as state value (will be removed at the end of the run). - self.insert_value(sample_value, true); + self.sample_values.entry(sample_type).or_default().insert(sample_value); } - } else { - self.sample_values.entry(sample_type).or_default().insert(sample_value); } } } From 28ccb97e6a9133631f9b7f21a818e0f8c5bd0b5a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 21 May 2024 21:29:03 +0300 Subject: [PATCH 0976/1963] chore: update interprocess to fix a todo (#7913) chore: remove interprocess TODO --- crates/anvil/server/src/ipc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index eb2d2d4fd24e3..a1ca67af85b84 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -47,7 +47,6 @@ impl IpcEndpoint { let name = to_name(path.as_ref())?; let listener = ls::ListenerOptions::new().name(name).create_tokio()?; - // TODO: https://github.com/kotauskas/interprocess/issues/64 let connections = futures::stream::unfold(listener, |listener| async move { let conn = listener.accept().await; Some((conn, listener)) From 23700c9233314e06ba65be4522daf3aa89130dc0 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 21 May 2024 22:22:43 +0300 Subject: [PATCH 0977/1963] feat: support solc 0.8.26 (#7968) --- Cargo.lock | 8 ++++---- crates/forge/tests/cli/svm.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 440f2e3d98c68..d291a6f9d8ad6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7398,9 +7398,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "svm-rs" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c7a55b859b986daa02c731cd07758d84b1db852665e45c5cfa6698c41d17cb" +checksum = "b19990faaaed6298d6b21984544ad941dc88d507330012fb4a6a8d4f1833de73" dependencies = [ "const-hex", "dirs 5.0.1", @@ -7418,9 +7418,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bb4806c96207e7cde40fc238f9a1d570f3090f850a742e1e96665440615a31" +checksum = "68be542b0720275ac352f85ab67713ae22d56bcc58d83bdebdd3eda0473a1d7f" dependencies = [ "build_const", "const-hex", diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index cbdd56f9d787e..8403053d84d6a 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -11,7 +11,7 @@ use svm::Platform; /// 3. svm bumped in foundry-compilers /// 4. foundry-compilers update with any breaking changes /// 5. upgrade the `LATEST_SOLC` -const LATEST_SOLC: Version = Version::new(0, 8, 25); +const LATEST_SOLC: Version = Version::new(0, 8, 26); macro_rules! ensure_svm_releases { ($($test:ident => $platform:ident),* $(,)?) => {$( From a539f3a234af763df59f91f80d622999ab630a2e Mon Sep 17 00:00:00 2001 From: aureliusbtc <82057759+aureliusbtc@users.noreply.github.com> Date: Wed, 22 May 2024 16:44:42 +0100 Subject: [PATCH 0978/1963] Nit: Fix EIP 1159 typo in comment (#7963) eip-1159 -> eip-1559 --- crates/anvil/src/eth/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 7fd4133a68b7e..4fd9d090d3aa8 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1242,7 +1242,7 @@ impl EthApi { Err(BlockchainError::RpcUnimplemented) } - /// Introduced in EIP-1159 for getting information on the appropriate priority fee to use. + /// Introduced in EIP-1559 for getting information on the appropriate priority fee to use. /// /// Handler for ETH RPC call: `eth_feeHistory` pub async fn fee_history( From 44d98ea9359070017819ba44f3d11e4fedb63420 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 22 May 2024 19:32:18 +0300 Subject: [PATCH 0979/1963] fix(fuzz): do not exceed configured runs (#7971) * fix(fuzz): do not exceed configured runs * Add test --- crates/forge/src/lib.rs | 3 ++ crates/forge/tests/cli/test_cmd.rs | 51 +++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 98dc0aa4783ef..6a9334b1679c3 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -149,6 +149,9 @@ impl TestOptions { failure_persistence: file_failure_persistence, cases, max_global_rejects: self.fuzz.max_test_rejects, + // Disable proptest shrink: for fuzz tests we provide single counterexample, + // for invariant tests we shrink outside proptest. + max_shrink_iters: 0, ..Default::default() }; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 2b0784d6a27d0..22e928a431b08 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,6 +1,7 @@ //! Contains various tests for `forge test`. -use foundry_config::Config; +use alloy_primitives::U256; +use foundry_config::{Config, FuzzConfig}; use foundry_test_utils::{ rpc, util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, @@ -544,3 +545,51 @@ contract Dummy { cmd.args(["test", "--match-path", "src/dummy.sol"]); cmd.assert_success() }); + +forgetest_init!(should_not_shrink_fuzz_failure, |prj, cmd| { + prj.wipe_contracts(); + + // deterministic test so we always have 54 runs until test fails with overflow + let config = Config { + fuzz: { FuzzConfig { runs: 256, seed: Some(U256::from(100)), ..Default::default() } }, + ..Default::default() + }; + prj.write_config(config); + + prj.add_test( + "CounterFuzz.t.sol", + r#"pragma solidity 0.8.24; +import {Test} from "forge-std/Test.sol"; + +contract Counter { + uint256 public number = 0; + + function addOne(uint256 x) external pure returns (uint256) { + return x + 100_000_000; + } +} + +contract CounterTest is Test { + Counter public counter; + + function setUp() public { + counter = new Counter(); + } + + function testAddOne(uint256 x) public view { + assertEq(counter.addOne(x), x + 100_000_000); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]); + let (stderr, _) = cmd.unchecked_output_lossy(); + let runs = stderr.find("runs:").and_then(|start_runs| { + let runs_split = &stderr[start_runs + 6..]; + runs_split.find(',').map(|end_runs| &runs_split[..end_runs]) + }); + // make sure there are only 54 runs (with proptest shrinking same test results in 292 runs) + assert_eq!(runs.unwrap().parse::().unwrap(), 54); +}); From 78aef64c735dcfe6a6a6f68c9ba92a5bc9d65d1a Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 22 May 2024 22:06:48 +0300 Subject: [PATCH 0980/1963] fix: apply `--no-match-test` when invoking compiler (#7941) * fix: apply --no-match-test when invoking compiler * fix filter * fix * fix --- crates/forge/bin/cmd/test/filter.rs | 15 +++------------ crates/forge/bin/cmd/test/mod.rs | 6 ++++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index eb8baea4620f4..c30b3434ae942 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -1,6 +1,5 @@ use clap::Parser; use forge::TestFilter; -use foundry_cli::utils::FoundryPathExt; use foundry_common::glob::GlobMatcher; use foundry_compilers::{FileFilter, ProjectPathsConfig}; use foundry_config::Config; @@ -93,16 +92,9 @@ impl fmt::Debug for FilterArgs { impl FileFilter for FilterArgs { /// Returns true if the file regex pattern match the `file` /// - /// If no file regex is set this returns true if the file ends with `.t.sol`, see - /// [`FoundryPathExt::is_sol_test()`]. + /// If no file regex is set this returns true by default fn is_match(&self, file: &Path) -> bool { - if let Some(glob) = &self.path_pattern { - return glob.is_match(file) - } - if let Some(glob) = &self.path_pattern_inverse { - return !glob.is_match(file) - } - file.is_sol_test() + self.matches_path(file) } } @@ -194,8 +186,7 @@ impl ProjectPathsAwareFilter { impl FileFilter for ProjectPathsAwareFilter { /// Returns true if the file regex pattern match the `file` /// - /// If no file regex is set this returns true if the file ends with `.t.sol`, see - /// [FoundryPathExr::is_sol_test()] + /// If no file regex is set this returns true by default fn is_match(&self, mut file: &Path) -> bool { file = file.strip_prefix(&self.paths.root).unwrap_or(file); self.args_filter.is_match(file) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 720d132847602..1bb70aa7eb4ec 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -20,7 +20,8 @@ use foundry_common::{ shell, }; use foundry_compilers::{ - artifacts::output_selection::OutputSelection, utils::source_files_iter, SOLC_EXTENSIONS, + artifacts::output_selection::OutputSelection, utils::source_files_iter, SolcSparseFileFilter, + SOLC_EXTENSIONS, }; use foundry_config::{ figment, @@ -153,7 +154,8 @@ impl TestArgs { let mut project = config.create_project(true, true)?; project.settings.output_selection = OutputSelection::common_output_selection(["abi".to_string()]); - let output = project.compile()?; + + let output = project.compile_sparse(Box::new(SolcSparseFileFilter::new(filter.clone())))?; if output.has_compiler_errors() { println!("{}", output); From 3e9385b65d5ff502095c7896aab6042127548c34 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 22 May 2024 22:28:07 +0300 Subject: [PATCH 0981/1963] feat: smarter verification (#7937) * fix: smarter verification * version build regex * rm println * fix tests * clippy * review fixes * fmt * ref -> & --- Cargo.lock | 1 + crates/cheatcodes/src/fs.rs | 4 +- crates/common/src/contracts.rs | 144 +++++++++-- crates/evm/traces/src/identifier/local.rs | 4 +- crates/forge/bin/cmd/create.rs | 8 +- crates/script/src/execute.rs | 17 +- crates/script/src/lib.rs | 4 +- crates/script/src/transaction.rs | 2 +- crates/script/src/verify.rs | 4 +- crates/verify/Cargo.toml | 1 + crates/verify/src/etherscan/flatten.rs | 18 +- crates/verify/src/etherscan/mod.rs | 257 ++++--------------- crates/verify/src/etherscan/standard_json.rs | 32 ++- crates/verify/src/lib.rs | 101 +++++++- crates/verify/src/provider.rs | 95 ++++++- crates/verify/src/sourcify.rs | 73 ++---- 16 files changed, 440 insertions(+), 325 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d291a6f9d8ad6..5472893a89ab9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3271,6 +3271,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", + "itertools 0.12.1", "once_cell", "regex", "reqwest", diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 423ed2767fa04..33e29475c370e 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -356,9 +356,9 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result +const CALL_PROTECTION_BYTECODE_PREFIX: [u8; 21] = + hex!("730000000000000000000000000000000000000000"); + /// Container for commonly used contract data. #[derive(Debug, Clone)] pub struct ContractData { @@ -20,9 +31,21 @@ pub struct ContractData { /// Contract ABI. pub abi: JsonAbi, /// Contract creation code. - pub bytecode: Option, + pub bytecode: Option, /// Contract runtime code. - pub deployed_bytecode: Option, + pub deployed_bytecode: Option, +} + +impl ContractData { + /// Returns reference to bytes of contract creation code, if present. + pub fn bytecode(&self) -> Option<&Bytes> { + self.bytecode.as_ref()?.bytes().filter(|b| !b.is_empty()) + } + + /// Returns reference to bytes of contract deployed code, if present. + pub fn deployed_bytecode(&self) -> Option<&Bytes> { + self.deployed_bytecode.as_ref()?.bytes().filter(|b| !b.is_empty()) + } } type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a ContractData); @@ -42,18 +65,10 @@ impl ContractsByArtifact { .into_iter() .filter_map(|(id, artifact)| { let name = id.name.clone(); - let bytecode = artifact.bytecode.and_then(|b| b.into_bytes())?; - let deployed_bytecode = - artifact.deployed_bytecode.and_then(|b| b.into_bytes())?; - - // Exclude artifacts with present but empty bytecode. Such artifacts are usually - // interfaces and abstract contracts. - let bytecode = (bytecode.len() > 0).then_some(bytecode); - let deployed_bytecode = - (deployed_bytecode.len() > 0).then_some(deployed_bytecode); - let abi = artifact.abi?; - - Some((id, ContractData { name, abi, bytecode, deployed_bytecode })) + + let CompactContractBytecode { abi, bytecode, deployed_bytecode } = artifact; + + Some((id, ContractData { name, abi: abi?, bytecode, deployed_bytecode })) }) .collect(), ) @@ -62,7 +77,7 @@ impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. pub fn find_by_creation_code(&self, code: &[u8]) -> Option { self.iter().find(|(_, contract)| { - if let Some(bytecode) = &contract.bytecode { + if let Some(bytecode) = contract.bytecode() { bytecode_diff_score(bytecode.as_ref(), code) <= 0.1 } else { false @@ -73,7 +88,7 @@ impl ContractsByArtifact { /// Finds a contract which has a similar deployed bytecode as `code`. pub fn find_by_deployed_code(&self, code: &[u8]) -> Option { self.iter().find(|(_, contract)| { - if let Some(deployed_bytecode) = &contract.deployed_bytecode { + if let Some(deployed_bytecode) = contract.deployed_bytecode() { bytecode_diff_score(deployed_bytecode.as_ref(), code) <= 0.1 } else { false @@ -81,6 +96,99 @@ impl ContractsByArtifact { }) } + /// Finds a contract which deployed bytecode exactly matches the given code. Accounts for link + /// references and immutables. + pub fn find_by_deployed_code_exact(&self, code: &[u8]) -> Option { + self.iter().find(|(_, contract)| { + let Some(deployed_bytecode) = &contract.deployed_bytecode else { + return false; + }; + let Some(deployed_code) = &deployed_bytecode.bytecode else { + return false; + }; + + let len = match deployed_code.object { + BytecodeObject::Bytecode(ref bytes) => bytes.len(), + BytecodeObject::Unlinked(ref bytes) => bytes.len() / 2, + }; + + if len != code.len() { + return false; + } + + // Collect ignored offsets by chaining link and immutable references. + let mut ignored = deployed_bytecode + .immutable_references + .values() + .chain(deployed_code.link_references.values().flat_map(|v| v.values())) + .flatten() + .cloned() + .collect::>(); + + // For libraries solidity adds a call protection prefix to the bytecode. We need to + // ignore it as it includes library address determined at runtime. + // See https://docs.soliditylang.org/en/latest/contracts.html#call-protection-for-libraries and + // https://github.com/NomicFoundation/hardhat/blob/af7807cf38842a4f56e7f4b966b806e39631568a/packages/hardhat-verify/src/internal/solc/bytecode.ts#L172 + let has_call_protection = match deployed_code.object { + BytecodeObject::Bytecode(ref bytes) => { + bytes.starts_with(&CALL_PROTECTION_BYTECODE_PREFIX) + } + BytecodeObject::Unlinked(ref bytes) => { + if let Ok(bytes) = + Bytes::from_str(&bytes[..CALL_PROTECTION_BYTECODE_PREFIX.len() * 2]) + { + bytes.starts_with(&CALL_PROTECTION_BYTECODE_PREFIX) + } else { + false + } + } + }; + + if has_call_protection { + ignored.push(Offsets { start: 1, length: 20 }); + } + + ignored.sort_by_key(|o| o.start); + + let mut left = 0; + for offset in ignored { + let right = offset.start as usize; + + let matched = match deployed_code.object { + BytecodeObject::Bytecode(ref bytes) => bytes[left..right] == code[left..right], + BytecodeObject::Unlinked(ref bytes) => { + if let Ok(bytes) = Bytes::from_str(&bytes[left * 2..right * 2]) { + bytes == code[left..right] + } else { + false + } + } + }; + + if !matched { + return false; + } + + left = right + offset.length as usize; + } + + if left < code.len() { + match deployed_code.object { + BytecodeObject::Bytecode(ref bytes) => bytes[left..] == code[left..], + BytecodeObject::Unlinked(ref bytes) => { + if let Ok(bytes) = Bytes::from_str(&bytes[left * 2..]) { + bytes == code[left..] + } else { + false + } + } + } + } else { + true + } + }) + } + /// Finds a contract which has the same contract name or identifier as `id`. If more than one is /// found, return error. pub fn find_by_name_or_identifier(&self, id: &str) -> Result> { diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index 129656b959212..e82d733789f87 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -19,7 +19,7 @@ impl<'a> LocalTraceIdentifier<'a> { pub fn new(known_contracts: &'a ContractsByArtifact) -> Self { let mut ordered_ids = known_contracts .iter() - .filter_map(|(id, contract)| Some((id, contract.deployed_bytecode.as_ref()?))) + .filter_map(|(id, contract)| Some((id, contract.deployed_bytecode()?))) .map(|(id, bytecode)| (id, bytecode.len())) .collect::>(); ordered_ids.sort_by_key(|(_, len)| *len); @@ -41,7 +41,7 @@ impl<'a> LocalTraceIdentifier<'a> { let mut check = |id| { let contract = self.known_contracts.get(id)?; - if let Some(deployed_bytecode) = &contract.deployed_bytecode { + if let Some(deployed_bytecode) = contract.deployed_bytecode() { let score = bytecode_diff_score(deployed_bytecode, code); if score == 0.0 { trace!(target: "evm::traces", "found exact match"); diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 460dbdea70ed0..71a1cffd71571 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -169,7 +169,7 @@ impl CreateArgs { // since we don't know the address yet. let mut verify = forge_verify::VerifyArgs { address: Default::default(), - contract: self.contract.clone(), + contract: Some(self.contract.clone()), compiler_version: None, constructor_args, constructor_args_path: None, @@ -199,7 +199,9 @@ impl CreateArgs { verify.etherscan.key = config.get_etherscan_config_with_chain(Some(chain.into()))?.map(|c| c.key); - verify.verification_provider()?.preflight_check(verify).await?; + let context = verify.resolve_context().await?; + + verify.verification_provider()?.preflight_check(verify, context).await?; Ok(()) } @@ -318,7 +320,7 @@ impl CreateArgs { if self.opts.compiler.optimize { self.opts.compiler.optimizer_runs } else { None }; let verify = forge_verify::VerifyArgs { address, - contract: self.contract, + contract: Some(self.contract), compiler_version: None, constructor_args, constructor_args_path: None, diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index a0c8397ca2682..afba19f22f06b 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -16,7 +16,7 @@ use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ fmt::{format_token, format_token_raw}, provider::get_http_provider, - shell, ContractData, ContractsByArtifact, + shell, ContractsByArtifact, }; use foundry_config::{Config, NamedChain}; use foundry_debugger::Debugger; @@ -61,20 +61,25 @@ impl LinkedState { pub async fn prepare_execution(self) -> Result { let Self { args, script_config, script_wallets, build_data } = self; - let ContractData { abi, bytecode, .. } = build_data.get_target_contract()?; + let target_contract = build_data.get_target_contract()?; - let bytecode = bytecode.ok_or_eyre("target contract has no bytecode")?; + let bytecode = target_contract.bytecode().ok_or_eyre("target contract has no bytecode")?; - let (func, calldata) = args.get_method_and_calldata(&abi)?; + let (func, calldata) = args.get_method_and_calldata(&target_contract.abi)?; - ensure_clean_constructor(&abi)?; + ensure_clean_constructor(&target_contract.abi)?; Ok(PreExecutionState { args, script_config, script_wallets, build_data, - execution_data: ExecutionData { func, calldata, bytecode, abi }, + execution_data: ExecutionData { + func, + calldata, + bytecode: bytecode.clone(), + abi: target_contract.abi, + }, }) } } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 7b84802b1183a..88ab0782a8515 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -361,8 +361,8 @@ impl ScriptArgs { // From artifacts for (artifact, contract) in known_contracts.iter() { - let Some(bytecode) = &contract.bytecode else { continue }; - let Some(deployed_bytecode) = &contract.deployed_bytecode else { continue }; + let Some(bytecode) = contract.bytecode() else { continue }; + let Some(deployed_bytecode) = contract.deployed_bytecode() else { continue }; bytecodes.push((artifact.name.clone(), bytecode, deployed_bytecode)); } diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index c46301f9f3985..f5f9399d46a97 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -131,7 +131,7 @@ impl TransactionWithMetadata { let Some(data) = self.transaction.input.input() else { return Ok(()) }; let Some(info) = info else { return Ok(()) }; - let Some(bytecode) = info.bytecode.as_ref() else { return Ok(()) }; + let Some(bytecode) = info.bytecode() else { return Ok(()) }; // `create2` transactions are prefixed by a 32 byte salt. let creation_code = if is_create2 { diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index f6545c30194cc..6437e9a5d929a 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -106,7 +106,7 @@ impl VerifyBundle { libraries: &[String], ) -> Option { for (artifact, contract) in self.known_contracts.iter() { - let Some(bytecode) = contract.bytecode.as_ref() else { continue }; + let Some(bytecode) = contract.bytecode() else { continue }; // If it's a CREATE2, the tx.data comes with a 32-byte salt in the beginning // of the transaction if data.split_at(create2_offset).1.starts_with(bytecode) { @@ -130,7 +130,7 @@ impl VerifyBundle { let verify = VerifyArgs { address: contract_address, - contract, + contract: Some(contract), compiler_version: Some(version.to_string()), constructor_args: Some(hex::encode(constructor_args)), constructor_args_path: None, diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 62979edbc8a78..54d886f7cea6d 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -36,6 +36,7 @@ semver = "1" regex = { version = "1", default-features = false } once_cell = "1" yansi.workspace = true +itertools.workspace = true [dev-dependencies] tokio = { workspace = true, features = ["macros"] } diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index ee0f95d83c091..cebdfbd22e7aa 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -1,10 +1,11 @@ use super::{EtherscanSourceProvider, VerifyArgs}; +use crate::provider::VerificationContext; use eyre::{Context, Result}; use foundry_block_explorers::verify::CodeFormat; use foundry_compilers::{ artifacts::{BytecodeHash, Source}, compilers::{solc::SolcVersionManager, Compiler, CompilerVersionManager}, - AggregatedCompilerOutput, Project, SolcInput, + AggregatedCompilerOutput, SolcInput, }; use semver::{BuildMetadata, Version}; use std::{collections::BTreeMap, path::Path}; @@ -15,11 +16,9 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource { fn source( &self, args: &VerifyArgs, - project: &Project, - target: &Path, - version: &Version, + context: &VerificationContext, ) -> Result<(String, String, CodeFormat)> { - let metadata = project.settings.metadata.as_ref(); + let metadata = context.project.settings.metadata.as_ref(); let bch = metadata.and_then(|m| m.bytecode_hash).unwrap_or_default(); eyre::ensure!( @@ -28,11 +27,13 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource { bch, ); - let source = project.flatten(target).wrap_err("Failed to flatten contract")?; + let source = + context.project.flatten(&context.target_path).wrap_err("Failed to flatten contract")?; if !args.force { // solc dry run of flattened code - self.check_flattened(source.clone(), version, target).map_err(|err| { + self.check_flattened(source.clone(), &context.compiler_version, &context.target_path) + .map_err(|err| { eyre::eyre!( "Failed to compile the flattened code locally: `{}`\ To skip this solc dry, have a look at the `--force` flag of this command.", @@ -41,8 +42,7 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource { })?; } - let name = args.contract.name.clone(); - Ok((source, name, CodeFormat::SingleFile)) + Ok((source, context.target_name.clone(), CodeFormat::SingleFile)) } } diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 8ebe0dc46a24e..b0698d58b4fb7 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -1,5 +1,5 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; -use crate::retry::RETRY_CHECK_ON_VERIFY; +use crate::{provider::VerificationContext, retry::RETRY_CHECK_ON_VERIFY}; use alloy_json_abi::Function; use alloy_provider::Provider; use eyre::{eyre, Context, OptionExt, Result}; @@ -9,25 +9,16 @@ use foundry_block_explorers::{ verify::{CodeFormat, VerifyContract}, Client, }; -use foundry_cli::utils::{self, get_cached_entry_by_name, read_constructor_args_file, LoadConfig}; -use foundry_common::{abi::encode_function_args, retry::Retry}; -use foundry_compilers::{ - artifacts::{BytecodeObject, CompactContract}, - cache::CacheEntry, - info::ContractInfo, - Artifact, Project, Solc, -}; -use foundry_config::{Chain, Config, SolcReq}; +use foundry_cli::utils::{self, read_constructor_args_file, LoadConfig}; +use foundry_common::{abi::encode_function_args, retry::Retry, shell}; +use foundry_compilers::{artifacts::BytecodeObject, Artifact}; +use foundry_config::{Chain, Config}; use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; use futures::FutureExt; use once_cell::sync::Lazy; use regex::Regex; use semver::{BuildMetadata, Version}; -use std::{ - collections::HashSet, - fmt::Debug, - path::{Path, PathBuf}, -}; +use std::fmt::Debug; mod flatten; mod standard_json; @@ -37,10 +28,7 @@ pub static RE_BUILD_COMMIT: Lazy = #[derive(Clone, Debug, Default)] #[non_exhaustive] -pub struct EtherscanVerificationProvider { - /// Memoized cached entry of the target contract - cached_entry: Option<(PathBuf, CacheEntry, CompactContract)>, -} +pub struct EtherscanVerificationProvider; /// The contract source provider for [EtherscanVerificationProvider] /// @@ -49,21 +37,23 @@ trait EtherscanSourceProvider: Send + Sync + Debug { fn source( &self, args: &VerifyArgs, - project: &Project, - target: &Path, - version: &Version, + context: &VerificationContext, ) -> Result<(String, String, CodeFormat)>; } #[async_trait::async_trait] impl VerificationProvider for EtherscanVerificationProvider { - async fn preflight_check(&mut self, args: VerifyArgs) -> Result<()> { - let _ = self.prepare_request(&args).await?; + async fn preflight_check( + &mut self, + args: VerifyArgs, + context: VerificationContext, + ) -> Result<()> { + let _ = self.prepare_request(&args, &context).await?; Ok(()) } - async fn verify(&mut self, args: VerifyArgs) -> Result<()> { - let (etherscan, verify_args) = self.prepare_request(&args).await?; + async fn verify(&mut self, args: VerifyArgs, context: VerificationContext) -> Result<()> { + let (etherscan, verify_args) = self.prepare_request(&args, &context).await?; if !args.skip_is_verified_check && self.is_contract_verified(ðerscan, &verify_args).await? @@ -214,38 +204,12 @@ impl EtherscanVerificationProvider { } } - /// Return the memoized cache entry for the target contract. - /// Read the artifact from cache on first access. - fn cache_entry( - &mut self, - project: &Project, - contract: &ContractInfo, - ) -> Result<&(PathBuf, CacheEntry, CompactContract)> { - if let Some(ref entry) = self.cached_entry { - return Ok(entry) - } - - let cache = project.read_cache_file()?; - let (path, entry) = if let Some(path) = contract.path.as_ref() { - let path = project.root().join(path); - ( - path.clone(), - cache - .entry(&path) - .ok_or_else(|| { - eyre::eyre!(format!("Cache entry not found for {}", path.display())) - })? - .to_owned(), - ) - } else { - get_cached_entry_by_name(&cache, &contract.name)? - }; - let contract: CompactContract = cache.read_artifact(path.clone(), &contract.name)?; - Ok(self.cached_entry.insert((path, entry, contract))) - } - /// Configures the API request to the etherscan API using the given [`VerifyArgs`]. - async fn prepare_request(&mut self, args: &VerifyArgs) -> Result<(Client, VerifyContract)> { + async fn prepare_request( + &mut self, + args: &VerifyArgs, + context: &VerificationContext, + ) -> Result<(Client, VerifyContract)> { let config = args.try_load_config_emit_warnings()?; let etherscan = self.client( args.etherscan.chain.unwrap_or_default(), @@ -253,7 +217,7 @@ impl EtherscanVerificationProvider { args.etherscan.key().as_deref(), &config, )?; - let verify_args = self.create_verify_request(args, Some(config)).await?; + let verify_args = self.create_verify_request(args, context).await?; Ok((etherscan, verify_args)) } @@ -325,22 +289,20 @@ impl EtherscanVerificationProvider { pub async fn create_verify_request( &mut self, args: &VerifyArgs, - config: Option, + context: &VerificationContext, ) -> Result { - let mut config = - if let Some(config) = config { config } else { args.try_load_config_emit_warnings()? }; - - config.libraries.extend(args.libraries.clone()); - - let project = config.project()?; - - let contract_path = self.contract_path(args, &project)?; - let compiler_version = self.compiler_version(args, &config, &project)?; let (source, contract_name, code_format) = - self.source_provider(args).source(args, &project, &contract_path, &compiler_version)?; + self.source_provider(args).source(args, context)?; + + let mut compiler_version = context.compiler_version.clone(); + compiler_version.build = match RE_BUILD_COMMIT.captures(compiler_version.build.as_str()) { + Some(cap) => BuildMetadata::new(cap.name("commit").unwrap().as_str())?, + _ => BuildMetadata::EMPTY, + }; - let compiler_version = format!("v{}", ensure_solc_build_metadata(compiler_version).await?); - let constructor_args = self.constructor_args(args, &project, &config).await?; + let compiler_version = + format!("v{}", ensure_solc_build_metadata(context.compiler_version.clone()).await?); + let constructor_args = self.constructor_args(args, context).await?; let mut verify_args = VerifyContract::new(args.address, contract_name, source, compiler_version) .constructor_arguments(constructor_args) @@ -357,8 +319,8 @@ impl EtherscanVerificationProvider { if code_format == CodeFormat::SingleFile { verify_args = if let Some(optimizations) = args.num_of_optimizations { verify_args.optimized().runs(optimizations as u32) - } else if config.optimizer { - verify_args.optimized().runs(config.optimizer_runs.try_into()?) + } else if context.config.optimizer { + verify_args.optimized().runs(context.config.optimizer_runs.try_into()?) } else { verify_args.not_optimized() }; @@ -367,94 +329,16 @@ impl EtherscanVerificationProvider { Ok(verify_args) } - /// Get the target contract path. If it wasn't provided, attempt a lookup - /// in cache. Validate the path indeed exists on disk. - fn contract_path(&mut self, args: &VerifyArgs, project: &Project) -> Result { - let path = if let Some(path) = args.contract.path.as_ref() { - project.root().join(path) - } else { - let (path, _, _) = self.cache_entry(project, &args.contract).wrap_err( - "If cache is disabled, contract info must be provided in the format :", - )?; - path.to_owned() - }; - - // check that the provided contract is part of the source dir - if !path.exists() { - eyre::bail!("Contract {:?} does not exist.", path); - } - - Ok(path) - } - - /// Parse the compiler version. - /// The priority desc: - /// 1. Through CLI arg `--compiler-version` - /// 2. `solc` defined in foundry.toml - /// 3. The version contract was last compiled with. - fn compiler_version( - &mut self, - args: &VerifyArgs, - config: &Config, - project: &Project, - ) -> Result { - if let Some(ref version) = args.compiler_version { - return Ok(version.trim_start_matches('v').parse()?) - } - - if let Some(ref solc) = config.solc { - match solc { - SolcReq::Version(version) => return Ok(version.to_owned()), - SolcReq::Local(solc) => { - if solc.is_file() { - return Ok(Solc::new(solc).map(|solc| solc.version)?) - } - } - } - } - - let (_, entry, _) = self.cache_entry(project, &args.contract).wrap_err( - "If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml" - )?; - let artifacts = entry.artifacts_versions().collect::>(); - - if artifacts.is_empty() { - eyre::bail!("No matching artifact found for {}", args.contract.name); - } - - // ensure we have a single version - let unique_versions = artifacts.iter().map(|a| a.0.to_string()).collect::>(); - if unique_versions.len() > 1 { - let versions = unique_versions.into_iter().collect::>(); - warn!("Ambiguous compiler versions found in cache: {}", versions.join(", ")); - eyre::bail!("Compiler version has to be set in `foundry.toml`. If the project was not deployed with foundry, specify the version through `--compiler-version` flag.") - } - - // we have a unique version - let mut version = artifacts[0].0.clone(); - version.build = match RE_BUILD_COMMIT.captures(version.build.as_str()) { - Some(cap) => BuildMetadata::new(cap.name("commit").unwrap().as_str())?, - _ => BuildMetadata::EMPTY, - }; - - Ok(version) - } - /// Return the optional encoded constructor arguments. If the path to /// constructor arguments was provided, read them and encode. Otherwise, /// return whatever was set in the [VerifyArgs] args. async fn constructor_args( &mut self, args: &VerifyArgs, - project: &Project, - config: &Config, + context: &VerificationContext, ) -> Result> { if let Some(ref constructor_args_path) = args.constructor_args_path { - let (_, _, contract) = self.cache_entry(project, &args.contract).wrap_err( - "Cache must be enabled in order to use the `--constructor-args-path` option", - )?; - let abi = - contract.abi.as_ref().ok_or_else(|| eyre!("Can't find ABI in cached artifact."))?; + let abi = context.get_target_abi()?; let constructor = abi .constructor() .ok_or_else(|| eyre!("Can't retrieve constructor info from artifact ABI."))?; @@ -473,7 +357,7 @@ impl EtherscanVerificationProvider { return Ok(Some(encoded_args[8..].into())) } if args.guess_constructor_args { - return Ok(Some(self.guess_constructor_args(args, project, config).await?)) + return Ok(Some(self.guess_constructor_args(args, context).await?)) } Ok(args.constructor_args.clone()) @@ -486,15 +370,14 @@ impl EtherscanVerificationProvider { async fn guess_constructor_args( &mut self, args: &VerifyArgs, - project: &Project, - config: &Config, + context: &VerificationContext, ) -> Result { - let provider = utils::get_provider(config)?; + let provider = utils::get_provider(&context.config)?; let client = self.client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), args.etherscan.key.as_deref(), - config, + &context.config, )?; let creation_data = client.contract_creation_data(args.address).await?; @@ -507,20 +390,17 @@ impl EtherscanVerificationProvider { .await? .ok_or_eyre("Couldn't fetch transaction receipt from RPC")?; - let maybe_creation_code: &[u8]; - - if receipt.contract_address == Some(args.address) { - maybe_creation_code = &transaction.input; + let maybe_creation_code = if receipt.contract_address == Some(args.address) { + &transaction.input } else if transaction.to == Some(DEFAULT_CREATE2_DEPLOYER) { - maybe_creation_code = &transaction.input[32..]; + &transaction.input[32..] } else { eyre::bail!("Fetching of constructor arguments is not supported for contracts created by contracts") - } + }; - let contract_path = self.contract_path(args, project)?.to_string_lossy().into_owned(); - let output = project.compile()?; + let output = context.project.compile_file(&context.target_path)?; let artifact = output - .find(contract_path, &args.contract.name) + .find(context.target_path.to_string_lossy(), &context.target_name) .ok_or_eyre("Contract artifact wasn't found locally")?; let bytecode = artifact .get_bytecode_object() @@ -535,7 +415,9 @@ impl EtherscanVerificationProvider { if maybe_creation_code.starts_with(bytecode) { let constructor_args = &maybe_creation_code[bytecode.len()..]; - Ok(hex::encode(constructor_args)) + let constructor_args = hex::encode(constructor_args); + shell::println(format!("Identified constructor arguments: {constructor_args}"))?; + Ok(constructor_args) } else { eyre::bail!("Local bytecode doesn't match on-chain bytecode") } @@ -656,8 +538,6 @@ mod tests { let contract_path = format!("{src_dir}/Counter.sol"); fs::write(root.join(&contract_path), "").unwrap(); - let mut etherscan = EtherscanVerificationProvider::default(); - // No compiler argument let args = VerifyArgs::parse_from([ "foundry-cli", @@ -666,44 +546,12 @@ mod tests { "--root", root_path, ]); - - let result = etherscan.preflight_check(args).await; + let result = args.resolve_context().await; assert!(result.is_err()); assert_eq!( result.unwrap_err().to_string(), "If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml" ); - - // No contract path - let args = - VerifyArgs::parse_from(["foundry-cli", address, contract_name, "--root", root_path]); - - let result = etherscan.preflight_check(args).await; - assert!(result.is_err()); - assert_eq!( - result.unwrap_err().to_string(), - "If cache is disabled, contract info must be provided in the format :" - ); - - // Constructor args path - let args = VerifyArgs::parse_from([ - "foundry-cli", - address, - &format!("{contract_path}:{contract_name}"), - "--constructor-args-path", - ".", - "--compiler-version", - "0.8.15", - "--root", - root_path, - ]); - - let result = etherscan.preflight_check(args).await; - assert!(result.is_err()); - assert_eq!( - result.unwrap_err().to_string(), - "Cache must be enabled in order to use the `--constructor-args-path` option", - ); } forgetest_async!(respects_path_for_duplicate, |prj, cmd| { @@ -719,8 +567,9 @@ mod tests { "--root", &prj.root().to_string_lossy(), ]); + let context = args.resolve_context().await.unwrap(); let mut etherscan = EtherscanVerificationProvider::default(); - etherscan.preflight_check(args).await.unwrap(); + etherscan.preflight_check(args, context).await.unwrap(); }); } diff --git a/crates/verify/src/etherscan/standard_json.rs b/crates/verify/src/etherscan/standard_json.rs index db4854355e9ae..944ee6b101cf5 100644 --- a/crates/verify/src/etherscan/standard_json.rs +++ b/crates/verify/src/etherscan/standard_json.rs @@ -1,35 +1,35 @@ use super::{EtherscanSourceProvider, VerifyArgs}; +use crate::provider::VerificationContext; use eyre::{Context, Result}; use foundry_block_explorers::verify::CodeFormat; -use foundry_compilers::{artifacts::StandardJsonCompilerInput, Project}; -use semver::Version; -use std::path::Path; +use foundry_compilers::artifacts::StandardJsonCompilerInput; #[derive(Debug)] pub struct EtherscanStandardJsonSource; impl EtherscanSourceProvider for EtherscanStandardJsonSource { fn source( &self, - args: &VerifyArgs, - project: &Project, - target: &Path, - version: &Version, + _args: &VerifyArgs, + context: &VerificationContext, ) -> Result<(String, String, CodeFormat)> { - let mut input: StandardJsonCompilerInput = project - .standard_json_input(target) + let mut input: StandardJsonCompilerInput = context + .project + .standard_json_input(&context.target_path) .wrap_err("Failed to get standard json input")? - .normalize_evm_version(version); + .normalize_evm_version(&context.compiler_version); input.settings.libraries.libs = input .settings .libraries .libs .into_iter() - .map(|(f, libs)| (f.strip_prefix(project.root()).unwrap_or(&f).to_path_buf(), libs)) + .map(|(f, libs)| { + (f.strip_prefix(context.project.root()).unwrap_or(&f).to_path_buf(), libs) + }) .collect(); // remove all incompatible settings - input.settings.sanitize(version); + input.settings.sanitize(&context.compiler_version); let source = serde_json::to_string(&input).wrap_err("Failed to parse standard json input")?; @@ -38,8 +38,12 @@ impl EtherscanSourceProvider for EtherscanStandardJsonSource { let name = format!( "{}:{}", - target.strip_prefix(project.root()).unwrap_or(target).display(), - args.contract.name.clone() + context + .target_path + .strip_prefix(context.project.root()) + .unwrap_or(context.target_path.as_path()) + .display(), + context.target_name.clone() ); Ok((source, name, CodeFormat::StandardJsonInput)) } diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rs index ee6dd13f63fce..5655791182a4c 100644 --- a/crates/verify/src/lib.rs +++ b/crates/verify/src/lib.rs @@ -4,17 +4,20 @@ extern crate tracing; use alloy_primitives::Address; +use alloy_provider::Provider; use clap::{Parser, ValueHint}; use eyre::Result; use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, - utils, - utils::LoadConfig, + utils::{self, LoadConfig}, }; -use foundry_compilers::{info::ContractInfo, EvmVersion}; -use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config}; +use foundry_common::{compile::ProjectCompiler, ContractsByArtifact}; +use foundry_compilers::{info::ContractInfo, EvmVersion, Solc}; +use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config, SolcReq}; +use itertools::Itertools; use provider::VerificationProviderType; use reqwest::Url; +use revm_primitives::HashSet; use std::path::PathBuf; mod etherscan; @@ -29,6 +32,8 @@ mod sourcify; pub use retry::RetryArgs; +use crate::provider::VerificationContext; + /// Verification provider arguments #[derive(Clone, Debug, Parser)] pub struct VerifierArgs { @@ -54,7 +59,7 @@ pub struct VerifyArgs { pub address: Address, /// The contract identifier in the form `:`. - pub contract: ContractInfo, + pub contract: Option, /// The ABI-encoded constructor arguments. #[arg( @@ -192,19 +197,22 @@ impl VerifyArgs { None => config.chain.unwrap_or_default(), }; + let context = self.resolve_context().await?; + self.etherscan.chain = Some(chain); self.etherscan.key = config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); if self.show_standard_json_input { - let args = - EtherscanVerificationProvider::default().create_verify_request(&self, None).await?; + let args = EtherscanVerificationProvider::default() + .create_verify_request(&self, &context) + .await?; println!("{}", args.source); return Ok(()) } let verifier_url = self.verifier.verifier_url.clone(); println!("Start verifying contract `{}` deployed on {chain}", self.address); - self.verifier.verifier.client(&self.etherscan.key())?.verify(self).await.map_err(|err| { + self.verifier.verifier.client(&self.etherscan.key())?.verify(self, context).await.map_err(|err| { if let Some(verifier_url) = verifier_url { match Url::parse(&verifier_url) { Ok(url) => { @@ -230,6 +238,83 @@ impl VerifyArgs { pub fn verification_provider(&self) -> Result> { self.verifier.verifier.client(&self.etherscan.key()) } + + /// Resolves [VerificationContext] object either from entered contract name or by trying to + /// match bytecode located at given address. + pub async fn resolve_context(&self) -> Result { + let mut config = self.load_config_emit_warnings(); + config.libraries.extend(self.libraries.clone()); + + let project = config.project()?; + + if let Some(ref contract) = self.contract { + let contract_path = if let Some(ref path) = contract.path { + project.root().join(PathBuf::from(path)) + } else { + project.find_contract_path(&contract.name)? + }; + + let version = if let Some(ref version) = self.compiler_version { + version.trim_start_matches('v').parse()? + } else if let Some(ref solc) = config.solc { + match solc { + SolcReq::Version(version) => version.to_owned(), + SolcReq::Local(solc) => Solc::new(solc)?.version, + } + } else if let Some(entry) = project + .read_cache_file() + .ok() + .and_then(|mut cache| cache.files.remove(&contract_path)) + { + let unique_versions = entry + .artifacts + .get(&contract.name) + .map(|artifacts| artifacts.keys().collect::>()) + .unwrap_or_default(); + + if unique_versions.is_empty() { + eyre::bail!("No matching artifact found for {}", contract.name); + } else if unique_versions.len() > 1 { + warn!( + "Ambiguous compiler versions found in cache: {}", + unique_versions.iter().join(", ") + ); + eyre::bail!("Compiler version has to be set in `foundry.toml`. If the project was not deployed with foundry, specify the version through `--compiler-version` flag.") + } + + unique_versions.into_iter().next().unwrap().to_owned() + } else { + eyre::bail!("If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml") + }; + + VerificationContext::new(contract_path, contract.name.clone(), version, config) + } else { + if config.get_rpc_url().is_none() { + eyre::bail!("You have to provide a contract name or a valid RPC URL") + } + let provider = utils::get_provider(&config)?; + let code = provider.get_code_at(self.address, Default::default()).await?; + + let output = ProjectCompiler::new().compile(&project)?; + let contracts = ContractsByArtifact::new( + output.artifact_ids().map(|(id, artifact)| (id, artifact.clone().into())), + ); + + let Some((artifact_id, _)) = contracts.find_by_deployed_code_exact(&code) else { + eyre::bail!(format!( + "Bytecode at {} does not match any local contracts", + self.address + )) + }; + + VerificationContext::new( + artifact_id.source.clone(), + artifact_id.name.split('.').next().unwrap().to_owned(), + artifact_id.version.clone(), + config, + ) + } + } } /// Check verification status arguments diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index deac48229b028..210283c3ac842 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -2,9 +2,92 @@ use super::{ etherscan::EtherscanVerificationProvider, sourcify::SourcifyVerificationProvider, VerifyArgs, VerifyCheckArgs, }; +use alloy_json_abi::JsonAbi; use async_trait::async_trait; -use eyre::Result; -use std::{fmt, str::FromStr}; +use eyre::{OptionExt, Result}; +use foundry_common::compile::ProjectCompiler; +use foundry_compilers::{ + artifacts::{output_selection::OutputSelection, Metadata, Source}, + compilers::{solc::SolcVersionManager, CompilerVersionManager}, + CompilerConfig, Graph, Project, +}; +use foundry_config::Config; +use semver::Version; +use std::{fmt, path::PathBuf, str::FromStr}; + +/// Container with data required for contract verification. +#[derive(Debug, Clone)] +pub struct VerificationContext { + pub config: Config, + pub project: Project, + pub target_path: PathBuf, + pub target_name: String, + pub compiler_version: Version, +} + +impl VerificationContext { + pub fn new( + target_path: PathBuf, + target_name: String, + compiler_version: Version, + config: Config, + ) -> Result { + let mut project = config.project()?; + project.no_artifacts = true; + + // Set project's compiler to always use resolved version. + let vm = SolcVersionManager::default(); + let solc = vm.get_or_install(&compiler_version)?; + project.compiler_config = CompilerConfig::Specific(solc); + + Ok(Self { config, project, target_name, target_path, compiler_version }) + } + + /// Compiles target contract requesting only ABI and returns it. + pub fn get_target_abi(&self) -> Result { + let mut project = self.project.clone(); + project.settings.output_selection = + OutputSelection::common_output_selection(["abi".to_string()]); + + let output = ProjectCompiler::new() + .quiet(true) + .files([self.target_path.clone()]) + .compile(&project)?; + + let artifact = output + .find(self.target_path.to_string_lossy(), &self.target_name) + .ok_or_eyre("failed to find target artifact when compiling for abi")?; + + artifact.abi.clone().ok_or_eyre("target artifact does not have an ABI") + } + + /// Compiles target file requesting only metadata and returns it. + pub fn get_target_metadata(&self) -> Result { + let mut project = self.project.clone(); + project.settings.output_selection = + OutputSelection::common_output_selection(["metadata".to_string()]); + + let output = ProjectCompiler::new() + .quiet(true) + .files([self.target_path.clone()]) + .compile(&project)?; + + let artifact = output + .find(self.target_path.to_string_lossy(), &self.target_name) + .ok_or_eyre("failed to find target artifact when compiling for metadata")?; + + artifact.metadata.clone().ok_or_eyre("target artifact does not have an ABI") + } + + /// Returns [Vec] containing imports of the target file. + pub fn get_target_imports(&self) -> Result> { + let mut sources = self.project.paths.read_input_files()?; + sources.insert(self.target_path.clone(), Source::read(&self.target_path)?); + let graph = Graph::resolve_sources(&self.project.paths, sources)?; + + Ok(graph.imports(&self.target_path).into_iter().cloned().collect()) + } +} /// An abstraction for various verification providers such as etherscan, sourcify, blockscout #[async_trait] @@ -16,10 +99,14 @@ pub trait VerificationProvider { /// [`VerifyArgs`] are valid to begin with. This should prevent situations where there's a /// contract deployment that's executed before the verify request and the subsequent verify task /// fails due to misconfiguration. - async fn preflight_check(&mut self, args: VerifyArgs) -> Result<()>; + async fn preflight_check( + &mut self, + args: VerifyArgs, + context: VerificationContext, + ) -> Result<()>; /// Sends the actual verify request for the targeted contract. - async fn verify(&mut self, args: VerifyArgs) -> Result<()>; + async fn verify(&mut self, args: VerifyArgs, context: VerificationContext) -> Result<()>; /// Checks whether the contract is verified. async fn check(&self, args: VerifyCheckArgs) -> Result<()>; diff --git a/crates/verify/src/sourcify.rs b/crates/verify/src/sourcify.rs index 71fde6336133b..58cb2b4b93d74 100644 --- a/crates/verify/src/sourcify.rs +++ b/crates/verify/src/sourcify.rs @@ -1,13 +1,12 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; +use crate::provider::VerificationContext; use async_trait::async_trait; use eyre::Result; -use foundry_cli::utils::{get_cached_entry_by_name, LoadConfig}; use foundry_common::{fs, retry::Retry}; -use foundry_compilers::ConfigurableContractArtifact; use futures::FutureExt; use reqwest::Url; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, path::PathBuf, str::FromStr}; +use std::{collections::HashMap, str::FromStr}; pub static SOURCIFY_URL: &str = "https://sourcify.dev/server/"; @@ -18,13 +17,17 @@ pub struct SourcifyVerificationProvider; #[async_trait] impl VerificationProvider for SourcifyVerificationProvider { - async fn preflight_check(&mut self, args: VerifyArgs) -> Result<()> { - let _ = self.prepare_request(&args)?; + async fn preflight_check( + &mut self, + args: VerifyArgs, + context: VerificationContext, + ) -> Result<()> { + let _ = self.prepare_request(&args, &context)?; Ok(()) } - async fn verify(&mut self, args: VerifyArgs) -> Result<()> { - let body = self.prepare_request(&args)?; + async fn verify(&mut self, args: VerifyArgs, context: VerificationContext) -> Result<()> { + let body = self.prepare_request(&args, &context)?; trace!("submitting verification request {:?}", body); @@ -36,7 +39,7 @@ impl VerificationProvider for SourcifyVerificationProvider { async { println!( "\nSubmitting verification for [{}] {:?}.", - args.contract.name, + context.target_name, args.address.to_string() ); let response = client @@ -99,54 +102,24 @@ impl VerificationProvider for SourcifyVerificationProvider { impl SourcifyVerificationProvider { /// Configures the API request to the sourcify API using the given [`VerifyArgs`]. - fn prepare_request(&self, args: &VerifyArgs) -> Result { - let mut config = args.try_load_config_emit_warnings()?; - config.libraries.extend(args.libraries.clone()); - - let project = config.project()?; - - if !config.cache { - eyre::bail!("Cache is required for sourcify verification.") - } - - let cache = project.read_cache_file()?; - let (path, entry) = get_cached_entry_by_name(&cache, &args.contract.name)?; + fn prepare_request( + &self, + args: &VerifyArgs, + context: &VerificationContext, + ) -> Result { + let metadata = context.get_target_metadata()?; + let imports = context.get_target_imports()?; - if entry.compiler_settings.metadata.is_none() { - eyre::bail!( - r#"Contract {} was compiled without the solc `metadata` setting. -Sourcify requires contract metadata for verification. -metadata output can be enabled via `extra_output = ["metadata"]` in `foundry.toml`"#, - args.contract.name - ) - } + let mut files = HashMap::with_capacity(2 + imports.len()); - let mut files = HashMap::with_capacity(2 + entry.imports.len()); - - // the metadata is included in the contract's artifact file - let artifact_path = entry - .find_artifact_path(&args.contract.name) - .ok_or_else(|| eyre::eyre!("No artifact found for contract {}", args.contract.name))?; - - let artifact: ConfigurableContractArtifact = fs::read_json_file(artifact_path)?; - if let Some(metadata) = artifact.metadata { - let metadata = serde_json::to_string_pretty(&metadata)?; - files.insert("metadata.json".to_string(), metadata); - } else { - eyre::bail!( - r#"No metadata found in artifact `{}` for contract {}. -Sourcify requires contract metadata for verification. -metadata output can be enabled via `extra_output = ["metadata"]` in `foundry.toml`"#, - artifact_path.display(), - args.contract.name - ) - } + let metadata = serde_json::to_string_pretty(&metadata)?; + files.insert("metadata.json".to_string(), metadata); - let contract_path = args.contract.path.clone().map_or(path, PathBuf::from); + let contract_path = context.target_path.clone(); let filename = contract_path.file_name().unwrap().to_string_lossy().to_string(); files.insert(filename, fs::read_to_string(&contract_path)?); - for import in entry.imports { + for import in imports { let import_entry = format!("{}", import.display()); files.insert(import_entry, fs::read_to_string(&import)?); } From 9c719d94997467363082520ab5437e2682b7036d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 23 May 2024 17:12:50 +0300 Subject: [PATCH 0982/1963] fix: make clippy happy (#7975) --- crates/anvil/src/eth/otterscan/types.rs | 3 ++- crates/cheatcodes/src/test/expect.rs | 23 +++++++++++------------ crates/config/src/providers/remappings.rs | 1 + crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/fork/backend.rs | 2 +- crates/evm/core/src/utils.rs | 1 + crates/evm/fuzz/src/strategies/int.rs | 8 ++++---- crates/evm/fuzz/src/strategies/mod.rs | 1 + crates/evm/fuzz/src/strategies/uint.rs | 8 ++++---- crates/forge/bin/cmd/clone.rs | 2 +- crates/forge/src/coverage.rs | 2 +- crates/forge/src/runner.rs | 3 +-- 12 files changed, 29 insertions(+), 27 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 72bcb0de19938..fc0104066e020 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -135,7 +135,8 @@ impl OtsBlockDetails { /// This has two problems though: /// - It makes the endpoint too specific to Otterscan's implementation /// - It breaks the abstraction built in `OtsBlock` which computes `transaction_count` - /// based on the existing list. + /// based on the existing list. + /// /// Therefore we keep it simple by keeping the data in the response pub async fn build(block: Block, backend: &Backend) -> Result { if block.transactions.is_uncle() { diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 2fdc99476e4bd..3b777bd8a487d 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -301,19 +301,18 @@ impl Cheatcode for expectSafeMemoryCallCall { /// /// It can handle calls in two ways: /// - If the cheatcode was used with a `count` argument, it will expect the call to be made exactly -/// `count` times. -/// e.g. `vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f), 4)` will expect the -/// call to address(0xc4f3) with selector `0xd34db33f` to be made exactly 4 times. If the amount of -/// calls is less or more than 4, the test will fail. Note that the `count` argument cannot be -/// overwritten with another `vm.expectCall`. If this is attempted, `expectCall` will revert. +/// `count` times. e.g. `vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f), 4)` +/// will expect the call to address(0xc4f3) with selector `0xd34db33f` to be made exactly 4 times. +/// If the amount of calls is less or more than 4, the test will fail. Note that the `count` +/// argument cannot be overwritten with another `vm.expectCall`. If this is attempted, +/// `expectCall` will revert. /// - If the cheatcode was used without a `count` argument, it will expect the call to be made at -/// least the amount of times the cheatcode -/// was called. This means that `vm.expectCall` without a count argument can be called many times, -/// but cannot be called with a `count` argument after it was called without one. If the latter -/// happens, `expectCall` will revert. e.g `vm.expectCall(address(0xc4f3), -/// abi.encodeWithSelector(0xd34db33f))` will expect the call to address(0xc4f3) and selector -/// `0xd34db33f` to be made at least once. If the amount of calls is 0, the test will fail. If the -/// call is made more than once, the test will pass. +/// least the amount of times the cheatcode was called. This means that `vm.expectCall` without a +/// count argument can be called many times, but cannot be called with a `count` argument after it +/// was called without one. If the latter happens, `expectCall` will revert. e.g +/// `vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f))` will expect the call to +/// address(0xc4f3) and selector `0xd34db33f` to be made at least once. If the amount of calls is +/// 0, the test will fail. If the call is made more than once, the test will pass. #[allow(clippy::too_many_arguments)] // It is what it is fn expect_call( state: &mut Cheatcodes, diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 67ae449fb8141..2bfbf4ca4e108 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -102,6 +102,7 @@ impl<'a> RemappingsProvider<'a> { trace!("get all remappings from {:?}", self.root); /// prioritizes remappings that are closer: shorter `path` /// - ("a", "1/2") over ("a", "1/2/3") + /// /// grouped by remapping context fn insert_closest( mappings: &mut BTreeMap, BTreeMap>, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 90e27444b2227..fd4eeba7f0a7d 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -398,7 +398,7 @@ pub struct Backend { /// In a way the `JournaledState` is something like a cache that /// 1. check if account is already loaded (hot) /// 2. if not load from the `Database` (this will then retrieve the account via RPC in forking - /// mode) + /// mode) /// /// To properly initialize we store the `JournaledState` before the first fork is selected /// ([`DatabaseExt::select_fork`]). diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 2ab9bdc9bdb49..960f3779ffb5b 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -134,7 +134,7 @@ where /// We always check: /// 1. if the requested value is already stored in the cache, then answer the sender /// 2. otherwise, fetch it via the provider but check if a request for that value is already in - /// progress (e.g. another Sender just requested the same account) + /// progress (e.g. another Sender just requested the same account) fn on_request(&mut self, req: BackendRequest) { match req { BackendRequest::Basic(addr, sender) => { diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index bf9664bd8820b..d02889052ec41 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -23,6 +23,7 @@ pub use revm::primitives::State as StateChangeset; /// /// - checks for prevrandao mixhash after merge /// - applies chain specifics: on Arbitrum `block.number` is the L1 block +/// /// Should be called with proper chain id (retrieved from provider if not provided). pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::Env, block: &Block) { if let Ok(chain) = NamedChain::try_from(env.cfg.chain_id) { diff --git a/crates/evm/fuzz/src/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs index b27f62f2854d9..fc8f88ed6cb13 100644 --- a/crates/evm/fuzz/src/strategies/int.rs +++ b/crates/evm/fuzz/src/strategies/int.rs @@ -81,15 +81,15 @@ impl ValueTree for IntValueTree { /// Value tree for signed ints (up to int256). /// The strategy combines 3 different strategies, each assigned a specific weight: /// 1. Generate purely random value in a range. This will first choose bit size uniformly (up `bits` -/// param). Then generate a value for this bit size. +/// param). Then generate a value for this bit size. /// 2. Generate a random value around the edges (+/- 3 around min, 0 and max possible value) /// 3. Generate a value from a predefined fixtures set /// /// To define int fixtures: -/// - return an array of possible values for a parameter named `amount` declare a function -/// `function fixture_amount() public returns (int32[] memory)`. +/// - return an array of possible values for a parameter named `amount` declare a function `function +/// fixture_amount() public returns (int32[] memory)`. /// - use `amount` named parameter in fuzzed test in order to include fixtures in fuzzed values -/// `function testFuzz_int32(int32 amount)`. +/// `function testFuzz_int32(int32 amount)`. /// /// If fixture is not a valid int type then error is raised and random value generated. #[derive(Debug)] diff --git a/crates/evm/fuzz/src/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs index 4e1120b589aec..b49adf16cf359 100644 --- a/crates/evm/fuzz/src/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -19,6 +19,7 @@ pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call /// Macro to create strategy with fixtures. /// 1. A default strategy if no fixture defined for current parameter. /// 2. A weighted strategy that use fixtures and default strategy values for current parameter. +/// /// If fixture is not of the same type as fuzzed parameter then value is rejected and error raised. macro_rules! fixture_strategy { ($fixtures:ident, $strategy_value:expr, $default_strategy:expr) => { diff --git a/crates/evm/fuzz/src/strategies/uint.rs b/crates/evm/fuzz/src/strategies/uint.rs index 1b1eb2540499a..77a080f8cdbd1 100644 --- a/crates/evm/fuzz/src/strategies/uint.rs +++ b/crates/evm/fuzz/src/strategies/uint.rs @@ -69,15 +69,15 @@ impl ValueTree for UintValueTree { /// Value tree for unsigned ints (up to uint256). /// The strategy combines 3 different strategies, each assigned a specific weight: /// 1. Generate purely random value in a range. This will first choose bit size uniformly (up `bits` -/// param). Then generate a value for this bit size. +/// param). Then generate a value for this bit size. /// 2. Generate a random value around the edges (+/- 3 around 0 and max possible value) /// 3. Generate a value from a predefined fixtures set /// /// To define uint fixtures: -/// - return an array of possible values for a parameter named `amount` declare a function -/// `function fixture_amount() public returns (uint32[] memory)`. +/// - return an array of possible values for a parameter named `amount` declare a function `function +/// fixture_amount() public returns (uint32[] memory)`. /// - use `amount` named parameter in fuzzed test in order to include fixtures in fuzzed values -/// `function testFuzz_uint32(uint32 amount)`. +/// `function testFuzz_uint32(uint32 amount)`. /// /// If fixture is not a valid uint type then error is raised and random value generated. #[derive(Debug)] diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index c3315e19835d5..61e4d637f4fa0 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -470,7 +470,7 @@ fn dump_sources(meta: &Metadata, root: &PathBuf, no_reorg: bool) -> Result ContractRunner<'a> { /// /// Fixtures can be defined: /// - as storage arrays in test contract, prefixed with `fixture` - /// - as functions prefixed with `fixture` and followed by parameter name to be - /// fuzzed + /// - as functions prefixed with `fixture` and followed by parameter name to be fuzzed /// /// Storage array fixtures: /// `uint256[] public fixture_amount = [1, 2, 3];` From 299902e34d32c4ea77bf2c8b9b13c68f45113f13 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 23 May 2024 10:33:42 -0400 Subject: [PATCH 0983/1963] chore: bump to latest alloy and revm (#7934) * revert to alloy f415827 * revm-inspectors bump 098ab30 * deny.toml nit * satisfy AccessListInspector trait bounds * bump revm * map Opcode * nit * fix: revm `CallInputs` for cheatcodes/inspector * remove: `BlockId::latest()` calls * use unwrap_or_default * fix: evm/coverage * fix: evm/fuzz * fix: cheatcodes * fix: evm executors and inspectors * fix: anvil & verify * fix: add `AnvilAccessListInspector` to satisfy trait bounds * fix: anvil tests * clippy: rm unused * fmt * fix: cheatcodes inspector revm `CallInputs` * rm spec arg * use OPCODE_INFO_JUMPTABLE * nit * rm wrapped inspectors * fix: anvil test can_sign_tx * fix: evm deser cache tests * deprecate gas memory recording * nits * nit * nits * ci nits * fix: use `call.bytecode_address` instead of `call.target_address` * nit Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * fix arg * rm forge-std --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Matthias Seitz --- Cargo.lock | 72 +++++------ Cargo.toml | 52 ++++---- crates/anvil/core/src/eth/transaction/mod.rs | 4 +- crates/anvil/src/eth/api.rs | 4 + crates/anvil/src/eth/backend/db.rs | 6 +- crates/anvil/src/eth/backend/fork.rs | 21 ++-- crates/anvil/src/eth/backend/mem/fork_db.rs | 3 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 7 +- crates/anvil/src/eth/backend/mem/mod.rs | 9 +- crates/anvil/src/eth/error.rs | 8 +- crates/anvil/tests/it/anvil_api.rs | 22 ++-- crates/anvil/tests/it/api.rs | 2 +- crates/anvil/tests/it/fork.rs | 115 ++++++++---------- crates/anvil/tests/it/genesis.rs | 3 +- crates/anvil/tests/it/optimism.rs | 10 +- crates/anvil/tests/it/sign.rs | 2 +- crates/anvil/tests/it/transaction.rs | 56 +++++---- crates/anvil/tests/it/wsapi.rs | 3 +- crates/cast/bin/cmd/estimate.rs | 4 +- crates/cast/bin/cmd/mktx.rs | 4 +- crates/cast/bin/cmd/send.rs | 8 +- crates/cast/bin/cmd/storage.rs | 9 +- crates/cast/bin/main.rs | 3 +- crates/cast/bin/tx.rs | 6 +- crates/cast/src/lib.rs | 33 +++-- crates/cheatcodes/assets/cheatcodes.json | 2 +- crates/cheatcodes/spec/src/vm.rs | 2 +- crates/cheatcodes/src/evm.rs | 2 +- crates/cheatcodes/src/evm/mapping.rs | 5 +- crates/cheatcodes/src/evm/mock.rs | 2 +- crates/cheatcodes/src/inspector.rs | 83 ++++++------- crates/debugger/src/tui/mod.rs | 5 +- crates/evm/core/src/backend/mod.rs | 10 +- crates/evm/core/src/fork/backend.rs | 20 +-- crates/evm/core/src/fork/cache.rs | 44 ++++--- crates/evm/core/src/ic.rs | 21 ++-- crates/evm/core/src/utils.rs | 23 ++-- crates/evm/coverage/src/anchors.rs | 9 +- crates/evm/coverage/src/inspector.rs | 6 +- crates/evm/evm/Cargo.toml | 7 +- crates/evm/evm/src/executors/mod.rs | 8 +- crates/evm/evm/src/inspectors/debugger.rs | 19 ++- crates/evm/evm/src/inspectors/logs.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 18 +-- crates/evm/fuzz/src/inspector.rs | 16 ++- crates/evm/fuzz/src/strategies/state.rs | 9 +- crates/forge/bin/cmd/coverage.rs | 6 +- crates/forge/bin/cmd/create.rs | 6 +- crates/script/src/broadcast.rs | 11 +- crates/script/src/build.rs | 3 +- crates/test-utils/Cargo.toml | 1 - crates/test-utils/src/script.rs | 29 +---- crates/verify/src/bytecode.rs | 17 +-- crates/verify/src/lib.rs | 2 +- deny.toml | 5 +- testdata/default/cheats/LastCallGas.t.sol | 24 +--- 56 files changed, 417 insertions(+), 466 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5472893a89ab9..b03d115c6f5c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-eips", "alloy-primitives", @@ -92,7 +92,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -132,7 +132,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-primitives", "alloy-serde", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-primitives", "serde", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-consensus", "alloy-eips", @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -247,6 +247,7 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", + "pin-project", "reqwest", "serde_json", "tokio", @@ -257,7 +258,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -297,7 +298,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -321,7 +322,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-consensus", "alloy-eips", @@ -339,7 +340,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-consensus", "alloy-eips", @@ -356,7 +357,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -368,7 +369,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-primitives", "serde", @@ -378,7 +379,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -393,7 +394,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-consensus", "alloy-network", @@ -410,7 +411,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -429,7 +430,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-consensus", "alloy-network", @@ -445,7 +446,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-consensus", "alloy-network", @@ -536,7 +537,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -554,7 +555,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -568,7 +569,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -588,7 +589,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=899fc51#899fc51af8b5f4de6df1605ca3ffe8d8d6fa8c69" +source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -3693,7 +3694,6 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-provider", - "alloy-rpc-types", "eyre", "fd-lock 4.0.2", "foundry-common", @@ -6372,9 +6372,9 @@ dependencies = [ [[package]] name = "revm" -version = "8.0.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a454c1c650b2b2e23f0c461af09e6c31e1d15e1cbebe905a701c46b8a50afc" +checksum = "3a2c336f9921588e50871c00024feb51a521eca50ce6d01494bb9c50f837c8ed" dependencies = [ "auto_impl", "cfg-if", @@ -6388,7 +6388,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=c1b5dd0#c1b5dd0d85dd46ef5ec5258aebd24adc041d103a" +source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=098ab30#098ab30faf3254c8ba3159b1af006d71d3577d95" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -6404,9 +6404,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "4.0.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d322f2730cd300e99d271a1704a2dfb8973d832428f5aa282aaa40e2473b5eec" +checksum = "a58182c7454179826f9dad2ca577661963092ce9d0fd0c9d682c1e9215a72e70" dependencies = [ "revm-primitives", "serde", @@ -6414,9 +6414,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931f692f3f4fc72ec39d5d270f8e9d208c4a6008de7590ee96cf948e3b6d3f8d" +checksum = "dc8af9aa737eef0509a50d9f3cc1a631557a00ef2e70a3aa8a75d9ee0ed275bb" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6431,9 +6431,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "3.1.1" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbbc9640790cebcb731289afb7a7d96d16ad94afeb64b5d0b66443bd151e79d6" +checksum = "b9bf5d465e64b697da6a111cb19e798b5b2ebb18e5faf2ad48e9e8d47c64add2" dependencies = [ "alloy-primitives", "auto_impl", @@ -6895,9 +6895,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.28.2" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" dependencies = [ "rand", "secp256k1-sys", @@ -6905,9 +6905,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.9.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index 55d368d4a5acf..d55304817382e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,9 +142,9 @@ foundry-compilers = { version = "0.4.3", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "8", default-features = false } -revm-primitives = { version = "3", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "c1b5dd0", features = [ +revm = { version = "9", default-features = false } +revm-primitives = { version = "4", default-features = false } +revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "098ab30", features = [ "serde", ] } @@ -152,29 +152,29 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "899fc51", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index c7bd580547c4a..eced8fe336b4d 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -16,7 +16,7 @@ use bytes::BufMut; use foundry_evm::traces::CallTraceNode; use revm::{ interpreter::InstructionResult, - primitives::{CreateScheme, OptimismFields, TransactTo, TxEnv}, + primitives::{OptimismFields, TransactTo, TxEnv}, }; use serde::{Deserialize, Serialize}; use std::ops::{Deref, Mul}; @@ -447,7 +447,7 @@ impl PendingTransaction { fn transact_to(kind: &TxKind) -> TransactTo { match kind { TxKind::Call(c) => TransactTo::Call(*c), - TxKind::Create => TransactTo::Create(CreateScheme::Create), + TxKind::Create => TransactTo::Create, } } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 4fd9d090d3aa8..70641043f8e59 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2668,6 +2668,10 @@ impl TryFrom, u128, State)>> for GasEs InstructionResult::FatalExternalError | InstructionResult::OutOfFunds | InstructionResult::CallTooDeep => Ok(Self::EvmError(exit)), + // Handle Revm EOF InstructionResults: Not supported yet + InstructionResult::ReturnContractInNotInitEOF | + InstructionResult::EOFOpcodeDisabledInLegacy | + InstructionResult::EOFFunctionStackOverflow => Ok(Self::EvmError(exit)), }, } } diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 6149c01080f6b..34ad343b5e9cf 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -100,7 +100,7 @@ pub trait Db: B256::from_slice(&keccak256(code.as_ref())[..]) }; info.code_hash = code_hash; - info.code = Some(Bytecode::new_raw(alloy_primitives::Bytes(code.0)).to_checked()); + info.code = Some(Bytecode::new_raw(alloy_primitives::Bytes(code.0))); self.insert_account(address, info); Ok(()) } @@ -137,9 +137,7 @@ pub trait Db: code: if account.code.0.is_empty() { None } else { - Some( - Bytecode::new_raw(alloy_primitives::Bytes(account.code.0)).to_checked(), - ) + Some(Bytecode::new_raw(alloy_primitives::Bytes(account.code.0))) }, nonce, }, diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index a9cc1cd9de461..b193a6fa783ef 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -163,7 +163,7 @@ impl ClientFork { keys: Vec, block_number: Option, ) -> Result { - self.provider().get_proof(address, keys, block_number.unwrap_or(BlockId::latest())).await + self.provider().get_proof(address, keys).block_id(block_number.unwrap_or_default()).await } /// Sends `eth_call` @@ -184,8 +184,8 @@ impl ClientFork { request: &WithOtherFields, block: Option, ) -> Result { - let block = block.unwrap_or(BlockNumber::Latest); - let res = self.provider().estimate_gas(request, block.into()).await?; + let block = block.unwrap_or_default(); + let res = self.provider().estimate_gas(request).block_id(block.into()).await?; Ok(res) } @@ -196,9 +196,7 @@ impl ClientFork { request: &WithOtherFields, block: Option, ) -> Result { - self.provider() - .create_access_list(request, block.unwrap_or(BlockNumber::Latest).into()) - .await + self.provider().create_access_list(request).block_id(block.unwrap_or_default().into()).await } pub async fn storage_at( @@ -208,7 +206,8 @@ impl ClientFork { number: Option, ) -> Result { self.provider() - .get_storage_at(address, index, number.unwrap_or(BlockNumber::Latest).into()) + .get_storage_at(address, index) + .block_id(number.unwrap_or_default().into()) .await } @@ -234,9 +233,9 @@ impl ClientFork { return Ok(code); } - let block_id = BlockId::Number(blocknumber.into()); + let block_id = BlockId::number(blocknumber); - let code = self.provider().get_code_at(address, block_id).await?; + let code = self.provider().get_code_at(address).block_id(block_id).await?; let mut storage = self.storage_write(); storage.code_at.insert((address, blocknumber), code.clone().0.into()); @@ -250,12 +249,12 @@ impl ClientFork { blocknumber: u64, ) -> Result { trace!(target: "backend::fork", "get_balance={:?}", address); - self.provider().get_balance(address, blocknumber.into()).await + self.provider().get_balance(address).block_id(blocknumber.into()).await } pub async fn get_nonce(&self, address: Address, block: u64) -> Result { trace!(target: "backend::fork", "get_nonce={:?}", address); - self.provider().get_transaction_count(address, block.into()).await + self.provider().get_transaction_count(address).block_id(block.into()).await } pub async fn transaction_by_block_number_and_index( diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index d99aeb5ed415b..93070ef88ab4c 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -48,8 +48,7 @@ impl Db for ForkedDatabase { code } else { db.code_by_hash(v.info.code_hash)? - } - .to_checked(); + }; Ok(( k, SerializableAccountRecord { diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 1c96a0eb585f6..4a1a429f0cea1 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -48,8 +48,7 @@ impl Db for MemDb { code } else { self.inner.code_by_hash_ref(v.info.code_hash)? - } - .to_checked(); + }; Ok(( k, SerializableAccountRecord { @@ -147,7 +146,7 @@ mod tests { let mut dump_db = MemDb::default(); - let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")).to_checked(); + let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")); dump_db.insert_account( test_addr, @@ -184,7 +183,7 @@ mod tests { let test_addr2: Address = Address::from_str("0x70997970c51812dc3a010c7d01b50e0d17dc79c8").unwrap(); - let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")).to_checked(); + let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")); let mut db = MemDb::default(); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d49c99d914ef3..861bad0a558eb 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -67,8 +67,8 @@ use foundry_evm::{ db::CacheDB, interpreter::InstructionResult, primitives::{ - BlockEnv, CfgEnvWithHandlerCfg, CreateScheme, EnvWithHandlerCfg, ExecutionResult, - Output, SpecId, TransactTo, TxEnv, KECCAK_EMPTY, + BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ExecutionResult, Output, SpecId, + TransactTo, TxEnv, KECCAK_EMPTY, }, }, utils::new_evm_with_inspector_ref, @@ -1160,7 +1160,7 @@ impl Backend { max_fee_per_blob_gas: max_fee_per_blob_gas.map(U256::from), transact_to: match to { Some(addr) => TransactTo::Call(*addr), - None => TransactTo::Create(CreateScheme::Create), + None => TransactTo::Create, }, value: value.unwrap_or_default(), data: input.into_input().unwrap_or_default(), @@ -1169,6 +1169,7 @@ impl Backend { access_list: access_list.unwrap_or_default().flattened(), blob_hashes: blob_versioned_hashes.unwrap_or_default(), optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, + ..Default::default() }; if env.block.basefee == revm::primitives::U256::ZERO { @@ -2401,7 +2402,7 @@ impl TransactionValidator for Backend { // Ensure the tx does not exceed the max blobs per block. if blob_count > MAX_BLOBS_PER_BLOCK { - return Err(InvalidTransactionError::TooManyBlobs) + return Err(InvalidTransactionError::TooManyBlobs(MAX_BLOBS_PER_BLOCK, blob_count)) } // Check for any blob validation errors diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 61333822c9ea8..417ec77a06c53 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -214,8 +214,8 @@ pub enum InvalidTransactionError { /// Thrown when there are no `blob_hashes` in the transaction, and it is an EIP-4844 tx. #[error("`blob_hashes` are required for EIP-4844 transactions")] NoBlobHashes, - #[error("too many blobs in one transaction")] - TooManyBlobs, + #[error("too many blobs in one transaction, max: {0}, have: {1}")] + TooManyBlobs(usize, usize), /// Thrown when there's a blob validation error #[error(transparent)] BlobTransactionValidationError(#[from] alloy_consensus::BlobTransactionValidationError), @@ -283,7 +283,9 @@ impl From for InvalidTransactionError { InvalidTransactionError::BlobVersionNotSupported } InvalidTransaction::EmptyBlobs => InvalidTransactionError::EmptyBlobs, - InvalidTransaction::TooManyBlobs => InvalidTransactionError::TooManyBlobs, + InvalidTransaction::TooManyBlobs { max, have } => { + InvalidTransactionError::TooManyBlobs(max, have) + } _ => todo!(), } } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 4f46d7525384e..0ebffe94acac6 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -87,10 +87,10 @@ async fn can_impersonate_account() { let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, impersonate); - let nonce = provider.get_transaction_count(impersonate, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(impersonate).await.unwrap(); assert_eq!(nonce, 1); - let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance, val); api.anvil_stop_impersonating_account(impersonate).await.unwrap(); @@ -125,10 +125,10 @@ async fn can_auto_impersonate_account() { let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, impersonate); - let nonce = provider.get_transaction_count(impersonate, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(impersonate).await.unwrap(); assert_eq!(nonce, 1); - let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance, val); api.anvil_auto_impersonate_account(false).await.unwrap(); @@ -169,7 +169,7 @@ async fn can_impersonate_contract() { let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, impersonate); - let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance, val); api.anvil_stop_impersonating_account(impersonate).await.unwrap(); @@ -188,24 +188,24 @@ async fn can_impersonate_gnosis_safe() { // let safe = address!("A063Cb7CFd8E57c30c788A0572CBbf2129ae56B6"); - let code = provider.get_code_at(safe, BlockId::default()).await.unwrap(); + let code = provider.get_code_at(safe).await.unwrap(); assert!(!code.is_empty()); api.anvil_impersonate_account(safe).await.unwrap(); - let code = provider.get_code_at(safe, BlockId::default()).await.unwrap(); + let code = provider.get_code_at(safe).await.unwrap(); assert!(!code.is_empty()); let balance = U256::from(1e18 as u64); // fund the impersonated account api.anvil_set_balance(safe, balance).await.unwrap(); - let on_chain_balance = provider.get_balance(safe, BlockId::latest()).await.unwrap(); + let on_chain_balance = provider.get_balance(safe).await.unwrap(); assert_eq!(on_chain_balance, balance); api.anvil_stop_impersonating_account(safe).await.unwrap(); - let code = provider.get_code_at(safe, BlockId::default()).await.unwrap(); + let code = provider.get_code_at(safe).await.unwrap(); // code is added back after stop impersonating assert!(!code.is_empty()); } @@ -234,7 +234,7 @@ async fn can_impersonate_multiple_accounts() { let res0 = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res0.from, impersonate0); - let nonce = provider.get_transaction_count(impersonate0, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(impersonate0).await.unwrap(); assert_eq!(nonce, 1); let receipt = provider.get_transaction_receipt(res0.transaction_hash).await.unwrap().unwrap(); @@ -250,7 +250,7 @@ async fn can_impersonate_multiple_accounts() { assert_eq!(res1.from, impersonate1); - let nonce = provider.get_transaction_count(impersonate1, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(impersonate1).await.unwrap(); assert_eq!(nonce, 1); let receipt = provider.get_transaction_receipt(res1.transaction_hash).await.unwrap().unwrap(); diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 9619e1388e379..8dd9b570cab46 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -34,7 +34,7 @@ async fn can_dev_get_balance() { let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { - let balance = provider.get_balance(acc, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(acc).await.unwrap(); assert_eq!(balance, genesis_balance); } } diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 067934d8a28cd..87a1b6985e722 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -75,7 +75,7 @@ async fn test_fork_eth_get_balance() { for _ in 0..10 { let addr = Address::random(); let balance = api.balance(addr, None).await.unwrap(); - let provider_balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + let provider_balance = provider.get_balance(addr).await.unwrap(); assert_eq!(balance, provider_balance) } } @@ -91,11 +91,11 @@ async fn test_fork_eth_get_balance_after_mine() { let address = Address::random(); - let _balance = provider.get_balance(address, BlockId::Number(number.into())).await.unwrap(); + let _balance = provider.get_balance(address).await.unwrap(); api.evm_mine(None).await.unwrap(); - let _balance = provider.get_balance(address, BlockId::Number(number.into())).await.unwrap(); + let _balance = provider.get_balance(address).await.unwrap(); } // @@ -109,11 +109,11 @@ async fn test_fork_eth_get_code_after_mine() { let address = Address::random(); - let _code = provider.get_code_at(address, BlockId::Number(1.into())).await.unwrap(); + let _code = provider.get_code_at(address).block_id(BlockId::number(1)).await.unwrap(); api.evm_mine(None).await.unwrap(); - let _code = provider.get_code_at(address, BlockId::Number(1.into())).await.unwrap(); + let _code = provider.get_code_at(address).block_id(BlockId::number(1)).await.unwrap(); } #[tokio::test(flavor = "multi_thread")] @@ -123,7 +123,7 @@ async fn test_fork_eth_get_code() { for _ in 0..10 { let addr = Address::random(); let code = api.get_code(addr, None).await.unwrap(); - let provider_code = provider.get_code_at(addr, BlockId::latest()).await.unwrap(); + let provider_code = provider.get_code_at(addr).await.unwrap(); assert_eq!(code, provider_code) } @@ -140,7 +140,7 @@ async fn test_fork_eth_get_code() { .await .unwrap(); let code = api.get_code(address, None).await.unwrap(); - let provider_code = provider.get_code_at(address, BlockId::latest()).await.unwrap(); + let provider_code = provider.get_code_at(address).await.unwrap(); assert_eq!(code, prev_code); assert_eq!(code, provider_code); assert!(!code.as_ref().is_empty()); @@ -155,13 +155,13 @@ async fn test_fork_eth_get_nonce() { for _ in 0..10 { let addr = Address::random(); let api_nonce = api.transaction_count(addr, None).await.unwrap().to::(); - let provider_nonce = provider.get_transaction_count(addr, BlockId::latest()).await.unwrap(); + let provider_nonce = provider.get_transaction_count(addr).await.unwrap(); assert_eq!(api_nonce, provider_nonce); } let addr = Config::DEFAULT_SENDER; let api_nonce = api.transaction_count(addr, None).await.unwrap().to::(); - let provider_nonce = provider.get_transaction_count(addr, BlockId::latest()).await.unwrap(); + let provider_nonce = provider.get_transaction_count(addr).await.unwrap(); assert_eq!(api_nonce, provider_nonce); } @@ -186,20 +186,20 @@ async fn test_fork_reset() { let from = accounts[0].address(); let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance_before = provider.get_balance(to).await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); - let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let initial_nonce = provider.get_transaction_count(from).await.unwrap(); let tx = TransactionRequest::default().to(to).value(amount).from(from); let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); assert_eq!(tx.transaction_index, Some(0)); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(block_number) })) .await @@ -208,11 +208,11 @@ async fn test_fork_reset() { // reset block number assert_eq!(block_number, provider.get_block_number().await.unwrap()); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce); - let balance = provider.get_balance(from, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(from).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); - let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); // reset to latest @@ -232,7 +232,7 @@ async fn test_fork_reset_setup() { let block_number = provider.get_block_number().await.unwrap(); assert_eq!(block_number, 0); - let local_balance = provider.get_balance(dead_addr, BlockId::latest()).await.unwrap(); + let local_balance = provider.get_balance(dead_addr).await.unwrap(); assert_eq!(local_balance, U256::ZERO); api.anvil_reset(Some(Forking { @@ -245,7 +245,7 @@ async fn test_fork_reset_setup() { let block_number = provider.get_block_number().await.unwrap(); assert_eq!(block_number, BLOCK_NUMBER); - let remote_balance = provider.get_balance(dead_addr, BlockId::latest()).await.unwrap(); + let remote_balance = provider.get_balance(dead_addr).await.unwrap(); assert_eq!(remote_balance, U256::from(DEAD_BALANCE_AT_BLOCK_NUMBER)); } @@ -260,8 +260,8 @@ async fn test_fork_snapshotting() { let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); - let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let initial_nonce = provider.get_transaction_count(from).await.unwrap(); + let balance_before = provider.get_balance(to).await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); let provider = handle.http_provider(); @@ -272,18 +272,18 @@ async fn test_fork_snapshotting() { let provider = handle.http_provider(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); assert!(api.evm_revert(snapshot).await.unwrap()); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce); - let balance = provider.get_balance(from, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(from).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); - let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); assert_eq!(block_number, provider.get_block_number().await.unwrap()); } @@ -300,8 +300,8 @@ async fn test_fork_snapshotting_repeated() { let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); - let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let initial_nonce = provider.get_transaction_count(from).await.unwrap(); + let balance_before = provider.get_balance(to).await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(92u64)).unwrap(); let tx = TransactionRequest::default().to(to).value(amount).from(from); @@ -309,20 +309,20 @@ async fn test_fork_snapshotting_repeated() { let tx_provider = handle.http_provider(); let _ = tx_provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); let _second_snapshot = api.evm_snapshot().await.unwrap(); assert!(api.evm_revert(snapshot).await.unwrap()); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce); - let balance = provider.get_balance(from, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(from).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); - let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance, handle.genesis_balance()); assert_eq!(block_number, provider.get_block_number().await.unwrap()); @@ -348,8 +348,8 @@ async fn test_fork_snapshotting_blocks() { let to = accounts[1].address(); let block_number = provider.get_block_number().await.unwrap(); - let initial_nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); - let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let initial_nonce = provider.get_transaction_count(from).await.unwrap(); + let balance_before = provider.get_balance(to).await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); // send the transaction @@ -360,29 +360,26 @@ async fn test_fork_snapshotting_blocks() { let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); // revert snapshot assert!(api.evm_revert(snapshot).await.unwrap()); - assert_eq!( - initial_nonce, - provider.get_transaction_count(from, BlockId::latest()).await.unwrap() - ); + assert_eq!(initial_nonce, provider.get_transaction_count(from).await.unwrap()); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number); // repeat transaction let _ = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); // revert again: nothing to revert since snapshot gone assert!(!api.evm_revert(snapshot).await.unwrap()); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); let block_number_after = provider.get_block_number().await.unwrap(); assert_eq!(block_number_after, block_number + 1); @@ -398,11 +395,11 @@ async fn test_separate_states() { let addr: Address = "000000000000000000000000000000000000dEaD".parse().unwrap(); - let remote_balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + let remote_balance = provider.get_balance(addr).await.unwrap(); assert_eq!(remote_balance, U256::from(12556104082473169733500u128)); api.anvil_set_balance(addr, U256::from(1337u64)).await.unwrap(); - let balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(addr).await.unwrap(); assert_eq!(balance, U256::from(1337u64)); let fork = api.get_fork().unwrap(); @@ -448,44 +445,32 @@ async fn can_reset_properly() { let origin_nonce = 1u64; origin_api.anvil_set_nonce(account, U256::from(origin_nonce)).await.unwrap(); - assert_eq!( - origin_nonce, - origin_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() - ); + assert_eq!(origin_nonce, origin_provider.get_transaction_count(account).await.unwrap()); let (fork_api, fork_handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some(origin_handle.http_endpoint()))).await; let fork_provider = fork_handle.http_provider(); let fork_tx_provider = http_provider(&fork_handle.http_endpoint()); - assert_eq!( - origin_nonce, - fork_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() - ); + assert_eq!(origin_nonce, fork_provider.get_transaction_count(account).await.unwrap()); let to = Address::random(); - let to_balance = fork_provider.get_balance(to, BlockId::latest()).await.unwrap(); + let to_balance = fork_provider.get_balance(to).await.unwrap(); let tx = TransactionRequest::default().from(account).to(to).value(U256::from(1337u64)); let tx = WithOtherFields::new(tx); let tx = fork_tx_provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); // nonce incremented by 1 - assert_eq!( - origin_nonce + 1, - fork_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() - ); + assert_eq!(origin_nonce + 1, fork_provider.get_transaction_count(account).await.unwrap()); // resetting to origin state fork_api.anvil_reset(Some(Forking::default())).await.unwrap(); // nonce reset to origin - assert_eq!( - origin_nonce, - fork_provider.get_transaction_count(account, BlockId::latest()).await.unwrap() - ); + assert_eq!(origin_nonce, fork_provider.get_transaction_count(account).await.unwrap()); // balance is reset - assert_eq!(to_balance, fork_provider.get_balance(to, BlockId::latest()).await.unwrap()); + assert_eq!(to_balance, fork_provider.get_balance(to).await.unwrap()); // tx does not exist anymore assert!(fork_tx_provider.get_transaction_by_hash(tx.transaction_hash).await.unwrap().is_none()) @@ -587,7 +572,7 @@ async fn test_fork_can_send_tx() { api.anvil_set_balance(signer, U256::MAX).await.unwrap(); api.anvil_impersonate_account(signer).await.unwrap(); // Added until SignerFiller for alloy-provider is fixed. - let balance = provider.get_balance(signer, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(signer).await.unwrap(); assert_eq!(balance, U256::MAX); let addr = Address::random(); @@ -597,7 +582,7 @@ async fn test_fork_can_send_tx() { // broadcast it via the eth_sendTransaction API let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(addr).await.unwrap(); assert_eq!(balance, val); } @@ -963,7 +948,7 @@ async fn can_impersonate_in_fork() { let status = res.inner.inner.inner.receipt.status; assert!(status); - let balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance, val); api.anvil_stop_impersonating_account(token_holder).await.unwrap(); diff --git a/crates/anvil/tests/it/genesis.rs b/crates/anvil/tests/it/genesis.rs index bb4e2d24bd5b9..139a2fe209d5b 100644 --- a/crates/anvil/tests/it/genesis.rs +++ b/crates/anvil/tests/it/genesis.rs @@ -3,7 +3,6 @@ use alloy_genesis::Genesis; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; -use alloy_rpc_types::BlockId; use anvil::{spawn, NodeConfig}; use std::str::FromStr; @@ -44,7 +43,7 @@ async fn can_apply_genesis() { assert_eq!(provider.get_chain_id().await.unwrap(), 19763u64); let addr: Address = Address::from_str("71562b71999873db5b286df957af199ec94617f7").unwrap(); - let balance = provider.get_balance(addr, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(addr).await.unwrap(); let expected: U256 = U256::from_str_radix("ffffffffffffffffffffffffff", 16).unwrap(); assert_eq!(balance, expected); diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 7b38a3e5c7bfc..60d506aee3237 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -1,7 +1,7 @@ //! Tests for OP chain support. use crate::utils::http_provider_with_signer; -use alloy_eips::{eip2718::Encodable2718, BlockId}; +use alloy_eips::eip2718::Encodable2718; use alloy_network::{EthereumSigner, TransactionBuilder}; use alloy_primitives::{b256, U128, U256}; use alloy_provider::Provider; @@ -53,7 +53,7 @@ async fn test_send_value_deposit_transaction() { let provider = http_provider_with_signer(&handle.http_endpoint(), signer); let send_value = U256::from(1234); - let before_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let before_balance_to = provider.get_balance(to).await.unwrap(); let tx = TransactionRequest::default() .with_from(from) @@ -83,7 +83,7 @@ async fn test_send_value_deposit_transaction() { assert_eq!(receipt.to, Some(to)); // the recipient should have received the value - let after_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let after_balance_to = provider.get_balance(to).await.unwrap(); assert_eq!(after_balance_to, before_balance_to + send_value); } @@ -101,7 +101,7 @@ async fn test_send_value_raw_deposit_transaction() { let provider = http_provider_with_signer(&handle.http_endpoint(), signer.clone()); let send_value = U256::from(1234); - let before_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let before_balance_to = provider.get_balance(to).await.unwrap(); let tx = TransactionRequest::default() .with_chain_id(31337) @@ -140,6 +140,6 @@ async fn test_send_value_raw_deposit_transaction() { assert_eq!(receipt.to, Some(to)); // the recipient should have received the value - let after_balance_to = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let after_balance_to = provider.get_balance(to).await.unwrap(); assert_eq!(after_balance_to, before_balance_to + send_value); } diff --git a/crates/anvil/tests/it/sign.rs b/crates/anvil/tests/it/sign.rs index 1417fec52d4db..c279619f2c6ca 100644 --- a/crates/anvil/tests/it/sign.rs +++ b/crates/anvil/tests/it/sign.rs @@ -303,7 +303,7 @@ async fn can_sign_transaction() { // sign it via the eth_signTransaction API let signed_tx = api.sign_transaction(tx).await.unwrap(); - assert_eq!(signed_tx, "0x02f868827a690a65648252089470997970c51812dc3a010c7d01b50e0d17dc79c88203e980c082f4f6a0e4de88aefcf87ccb04466e60de66a83192e46aa26177d5ea35efbfd43fd0ecdca00e3148e0e8e0b9a6f9b329efd6e30c4a461920f3a27497be3dbefaba996601da"); + assert_eq!(signed_tx, "0x02f866827a690a65648252089470997970c51812dc3a010c7d01b50e0d17dc79c88203e980c001a0e4de88aefcf87ccb04466e60de66a83192e46aa26177d5ea35efbfd43fd0ecdca00e3148e0e8e0b9a6f9b329efd6e30c4a461920f3a27497be3dbefaba996601da"); } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index eac152a510d75..cf9845d6f5408 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -25,10 +25,10 @@ async fn can_transfer_eth() { let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert!(nonce == 0); - let balance_before = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let balance_before = provider.get_balance(to).await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(2u64)).unwrap(); @@ -44,11 +44,11 @@ async fn can_transfer_eth() { assert_eq!(tx.block_number, Some(1)); assert_eq!(tx.transaction_index, Some(0)); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, 1); - let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); } @@ -104,7 +104,7 @@ async fn can_respect_nonces() { let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); let tx = TransactionRequest::default().to(to).value(amount).from(from).nonce(nonce + 1); @@ -150,7 +150,7 @@ async fn can_replace_transaction() { let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); @@ -240,7 +240,7 @@ async fn can_reject_underpriced_replacement() { let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); @@ -446,7 +446,7 @@ async fn can_deploy_get_code() { .await .unwrap(); - let code = provider.get_code_at(greeter_addr, BlockId::latest()).await.unwrap(); + let code = provider.get_code_at(greeter_addr).await.unwrap(); assert!(!code.as_ref().is_empty()); } @@ -551,7 +551,7 @@ async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { let from = accounts[0].address(); let to = accounts[1].address(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); // explicitly set the nonce let tx = TransactionRequest::default() @@ -578,7 +578,7 @@ async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { join_all(tasks).await.into_iter().filter(|res| res.as_ref().is_ok()).count(); assert_eq!(successful_tx, 1); - assert_eq!(provider.get_transaction_count(from, BlockId::latest()).await.unwrap(), 1u64); + assert_eq!(provider.get_transaction_count(from).await.unwrap(), 1u64); } #[tokio::test(flavor = "multi_thread")] @@ -588,7 +588,7 @@ async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { let wallet = handle.dev_wallets().next().unwrap(); let from = wallet.address(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); let mut tasks = Vec::new(); @@ -617,7 +617,7 @@ async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { let successful_tx = join_all(tasks).await.into_iter().filter(|res| res.as_ref().unwrap().is_ok()).count(); assert_eq!(successful_tx, 1); - assert_eq!(provider.get_transaction_count(from, BlockId::latest()).await.unwrap(), 1u64); + assert_eq!(provider.get_transaction_count(from).await.unwrap(), 1u64); } #[tokio::test(flavor = "multi_thread")] @@ -631,7 +631,7 @@ async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { let greeter_contract = Greeter::deploy(provider.clone(), "Hello World!".to_string()).await.unwrap(); - let nonce = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce = provider.get_transaction_count(from).await.unwrap(); let mut tasks = Vec::new(); @@ -675,7 +675,7 @@ async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { let successful_tx = join_all(tasks).await.into_iter().filter(|res| res.as_ref().unwrap().is_ok()).count(); assert_eq!(successful_tx, 1); - assert_eq!(provider.get_transaction_count(from, BlockId::latest()).await.unwrap(), nonce + 1); + assert_eq!(provider.get_transaction_count(from).await.unwrap(), nonce + 1); } #[tokio::test(flavor = "multi_thread")] async fn can_get_pending_transaction() { @@ -709,7 +709,7 @@ async fn test_first_noce_is_zero() { let provider = handle.http_provider(); let from = handle.dev_wallets().next().unwrap().address(); - let nonce = provider.get_transaction_count(from, BlockId::pending()).await.unwrap(); + let nonce = provider.get_transaction_count(from).block_id(BlockId::pending()).await.unwrap(); assert_eq!(nonce, 0); } @@ -736,7 +736,7 @@ async fn can_handle_different_sender_nonce_calculation() { let tx_from_first = WithOtherFields::new(tx_from_first); let _tx = provider.send_transaction(tx_from_first).await.unwrap(); let nonce_from_first = - provider.get_transaction_count(from_first, BlockId::pending()).await.unwrap(); + provider.get_transaction_count(from_first).block_id(BlockId::pending()).await.unwrap(); assert_eq!(nonce_from_first, idx); let tx_from_second = TransactionRequest::default() @@ -746,7 +746,7 @@ async fn can_handle_different_sender_nonce_calculation() { let tx_from_second = WithOtherFields::new(tx_from_second); let _tx = provider.send_transaction(tx_from_second).await.unwrap(); let nonce_from_second = - provider.get_transaction_count(from_second, BlockId::pending()).await.unwrap(); + provider.get_transaction_count(from_second).block_id(BlockId::pending()).await.unwrap(); assert_eq!(nonce_from_second, idx); } } @@ -768,12 +768,13 @@ async fn includes_pending_tx_for_transaction_count() { TransactionRequest::default().from(from).value(U256::from(1337)).to(Address::random()); let tx = WithOtherFields::new(tx); let _tx = provider.send_transaction(tx).await.unwrap(); - let nonce = provider.get_transaction_count(from, BlockId::pending()).await.unwrap(); + let nonce = + provider.get_transaction_count(from).block_id(BlockId::pending()).await.unwrap(); assert_eq!(nonce, idx); } api.mine_one().await; - let nonce = provider.get_transaction_count(from, BlockId::pending()).await.unwrap(); + let nonce = provider.get_transaction_count(from).block_id(BlockId::pending()).await.unwrap(); assert_eq!(nonce, tx_count); } @@ -792,19 +793,20 @@ async fn can_get_historic_info() { let tx = provider.send_transaction(tx).await.unwrap(); let _ = tx.get_receipt().await.unwrap(); - let nonce_pre = provider.get_transaction_count(from, BlockId::Number(0.into())).await.unwrap(); + let nonce_pre = + provider.get_transaction_count(from).block_id(BlockId::number(0)).await.unwrap(); - let nonce_post = provider.get_transaction_count(from, BlockId::latest()).await.unwrap(); + let nonce_post = provider.get_transaction_count(from).await.unwrap(); assert!(nonce_pre < nonce_post); - let balance_pre = provider.get_balance(from, BlockId::Number(0.into())).await.unwrap(); + let balance_pre = provider.get_balance(from).block_id(BlockId::number(0)).await.unwrap(); - let balance_post = provider.get_balance(from, BlockId::latest()).await.unwrap(); + let balance_post = provider.get_balance(from).await.unwrap(); assert!(balance_post < balance_pre); - let to_balance = provider.get_balance(to, BlockId::latest()).await.unwrap(); + let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_pre.saturating_add(amount), to_balance); } @@ -962,7 +964,7 @@ async fn test_tx_access_list() { .to(*simple_storage.address()) .with_input(set_value_calldata.to_owned()); let set_value_tx = WithOtherFields::new(set_value_tx); - let access_list = provider.create_access_list(&set_value_tx, BlockId::latest()).await.unwrap(); + let access_list = provider.create_access_list(&set_value_tx).await.unwrap(); // let set_value_tx = simple_storage.set_value("bar".to_string()).from(sender).tx; // let access_list = client.create_access_list(&set_value_tx, None).await.unwrap(); assert_access_list_eq( @@ -989,7 +991,7 @@ async fn test_tx_access_list() { .to(*multicall.address()) .with_input(call_tx_data.to_owned()); let call_tx = WithOtherFields::new(call_tx); - let access_list = provider.create_access_list(&call_tx, BlockId::latest()).await.unwrap(); + let access_list = provider.create_access_list(&call_tx).await.unwrap(); assert_access_list_eq( access_list.access_list, AccessList::from(vec![AccessListItem { address: other_acc, storage_keys: vec![] }]), @@ -1009,7 +1011,7 @@ async fn test_tx_access_list() { .to(*multicall.address()) .with_input(subcall_tx_calldata.to_owned()); let subcall_tx = WithOtherFields::new(subcall_tx); - let access_list = provider.create_access_list(&subcall_tx, BlockId::latest()).await.unwrap(); + let access_list = provider.create_access_list(&subcall_tx).await.unwrap(); assert_access_list_eq( access_list.access_list, // H256::from_uint(&(1u64.into())), diff --git a/crates/anvil/tests/it/wsapi.rs b/crates/anvil/tests/it/wsapi.rs index f68b15312a673..ebe853a7d8789 100644 --- a/crates/anvil/tests/it/wsapi.rs +++ b/crates/anvil/tests/it/wsapi.rs @@ -2,7 +2,6 @@ use alloy_primitives::U256; use alloy_provider::Provider; -use alloy_rpc_types::BlockId; use anvil::{spawn, NodeConfig}; #[tokio::test(flavor = "multi_thread")] @@ -24,7 +23,7 @@ async fn can_dev_get_balance_ws() { let genesis_balance = handle.genesis_balance(); for acc in handle.genesis_accounts() { - let balance = provider.get_balance(acc, BlockId::latest()).await.unwrap(); + let balance = provider.get_balance(acc).await.unwrap(); assert_eq!(balance, genesis_balance); } } diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 33f375f9c3ec5..c000a79c12c31 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,7 +1,7 @@ use alloy_network::TransactionBuilder; use alloy_primitives::U256; use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use clap::Parser; use eyre::Result; use foundry_cli::{ @@ -128,7 +128,7 @@ impl EstimateArgs { req.set_input(data); - let gas = provider.estimate_gas(&req, BlockId::latest()).await?; + let gas = provider.estimate_gas(&req).await?; println!("{gas}"); Ok(()) } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index 6b7b08c6fa3ac..f8f6d9fb20444 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -2,7 +2,6 @@ use crate::tx; use alloy_network::{eip2718::Encodable2718, EthereumSigner, TransactionBuilder}; use alloy_primitives::U64; use alloy_provider::Provider; -use alloy_rpc_types::BlockId; use alloy_signer::Signer; use clap::Parser; use eyre::Result; @@ -90,8 +89,7 @@ impl MakeTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = - Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); + tx.nonce = Some(U64::from(provider.get_transaction_count(from).await?)); } let provider = get_provider(&config)?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 3a6de10a9256c..06c8b99f249c6 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -2,7 +2,6 @@ use crate::tx; use alloy_network::{AnyNetwork, EthereumSigner}; use alloy_primitives::{Address, U64}; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::BlockId; use alloy_signer::Signer; use alloy_transport::Transport; use cast::Cast; @@ -150,9 +149,7 @@ impl SendTxArgs { } if resend { - tx.nonce = Some(U64::from( - provider.get_transaction_count(config.sender, BlockId::latest()).await?, - )); + tx.nonce = Some(U64::from(provider.get_transaction_count(config.sender).await?)); } cast_send( @@ -183,8 +180,7 @@ impl SendTxArgs { tx::validate_from_address(eth.wallet.from, from)?; if resend { - tx.nonce = - Some(U64::from(provider.get_transaction_count(from, BlockId::latest()).await?)); + tx.nonce = Some(U64::from(provider.get_transaction_count(from).await?)); } let signer = EthereumSigner::from(signer); diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 6197e40c96e54..a59d93c5d1047 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -95,7 +95,8 @@ impl StorageArgs { // No slot was provided // Get deployed bytecode at given address - let address_code = provider.get_code_at(address, block.unwrap_or_default()).await?; + let address_code = + provider.get_code_at(address).block_id(block.unwrap_or_default()).await?; if address_code.is_empty() { eyre::bail!("Provided address has no deployed code and thus no storage"); } @@ -237,8 +238,10 @@ async fn fetch_storage_slots, T: Transport + Clone>( ) -> Result> { let requests = layout.storage.iter().map(|storage_slot| async { let slot = B256::from(U256::from_str(&storage_slot.slot)?); - let raw_slot_value = - provider.get_storage_at(address, slot.into(), block.unwrap_or_default()).await?; + let raw_slot_value = provider + .get_storage_at(address, slot.into()) + .block_id(block.unwrap_or_default()) + .await?; let value = StorageValue { slot, raw_slot_value: raw_slot_value.into() }; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 30bb1205e56ef..0af23e2001547 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -351,7 +351,8 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let address = address.resolve(&provider).await?; let value = provider - .get_proof(address, slots.into_iter().collect(), block.unwrap_or(BlockId::latest())) + .get_proof(address, slots.into_iter().collect()) + .block_id(block.unwrap_or_default()) .await?; println!("{}", serde_json::to_string(&value)?); } diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 82b1d8b4d0bc1..d4c9e205c2409 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -3,7 +3,7 @@ use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; use alloy_primitives::{Address, Bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use alloy_transport::Transport; use eyre::Result; use foundry_cli::{opts::TransactionOpts, utils::parse_function_args}; @@ -90,7 +90,7 @@ pub async fn build_tx< req.set_nonce(if let Some(nonce) = tx.nonce { nonce.to() } else { - provider.get_transaction_count(from, BlockId::latest()).await? + provider.get_transaction_count(from).await? }); if tx.legacy || chain.is_legacy() { @@ -138,7 +138,7 @@ pub async fn build_tx< req.set_gas_limit(if let Some(gas_limit) = tx.gas_limit { gas_limit.to() } else { - provider.estimate_gas(&req, BlockId::latest()).await? + provider.estimate_gas(&req).await? }); Ok((req, func)) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index e2f706b74dac0..c83fe9aa1a6bc 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -133,8 +133,11 @@ where if res.is_empty() { // check that the recipient is a contract that can be called if let Some(TxKind::Call(addr)) = req.to { - if let Ok(code) = - self.provider.get_code_at(addr, block.unwrap_or_default()).await + if let Ok(code) = self + .provider + .get_code_at(addr) + .block_id(block.unwrap_or_default()) + .await { if code.is_empty() { eyre::bail!("contract {addr:?} does not have any code") @@ -198,7 +201,7 @@ where to_json: bool, ) -> Result { let access_list = - self.provider.create_access_list(req, block.unwrap_or(BlockId::latest())).await?; + self.provider.create_access_list(req).block_id(block.unwrap_or_default()).await?; let res = if to_json { serde_json::to_string(&access_list)? } else { @@ -220,7 +223,7 @@ where } pub async fn balance(&self, who: Address, block: Option) -> Result { - Ok(self.provider.get_balance(who, block.unwrap_or(BlockId::latest())).await?) + Ok(self.provider.get_balance(who).block_id(block.unwrap_or_default()).await?) } /// Sends a transaction to the specified address @@ -472,7 +475,7 @@ where /// # } /// ``` pub async fn nonce(&self, who: Address, block: Option) -> Result { - Ok(self.provider.get_transaction_count(who, block.unwrap_or(BlockId::latest())).await?) + Ok(self.provider.get_transaction_count(who).block_id(block.unwrap_or_default()).await?) } /// # Example @@ -498,7 +501,8 @@ where B256::from_str("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")?; let value = self .provider - .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) + .get_storage_at(who, slot.into()) + .block_id(block.unwrap_or_default()) .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) @@ -527,7 +531,8 @@ where B256::from_str("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")?; let value = self .provider - .get_storage_at(who, slot.into(), block.unwrap_or(BlockId::latest())) + .get_storage_at(who, slot.into()) + .block_id(block.unwrap_or_default()) .await?; let addr = Address::from_word(value.into()); Ok(format!("{addr:?}")) @@ -581,10 +586,14 @@ where disassemble: bool, ) -> Result { if disassemble { - let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); + let code = + self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await?.to_vec(); Ok(format_operations(disassemble_bytes(code)?)?) } else { - Ok(format!("{}", self.provider.get_code_at(who, block.unwrap_or_default()).await?)) + Ok(format!( + "{}", + self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await? + )) } } @@ -607,7 +616,8 @@ where /// # } /// ``` pub async fn codesize(&self, who: Address, block: Option) -> Result { - let code = self.provider.get_code_at(who, block.unwrap_or_default()).await?.to_vec(); + let code = + self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await?.to_vec(); Ok(format!("{}", code.len())) } @@ -773,7 +783,8 @@ where "{:?}", B256::from( self.provider - .get_storage_at(from, slot.into(), block.unwrap_or(BlockId::latest())) + .get_storage_at(from, slot.into()) + .block_id(block.unwrap_or_default()) .await? ) )) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index a461f614df572..5606a10b15265 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -475,7 +475,7 @@ { "name": "gasMemoryUsed", "ty": "uint64", - "description": "The amount of gas used for memory expansion." + "description": "DEPRECATED: The amount of gas used for memory expansion. Ref: " }, { "name": "gasRefunded", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 6e2fbd2787631..e8d24e3c51a21 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -102,7 +102,7 @@ interface Vm { uint64 gasLimit; /// The total gas used. uint64 gasTotalUsed; - /// The amount of gas used for memory expansion. + /// DEPRECATED: The amount of gas used for memory expansion. Ref: uint64 gasMemoryUsed; /// The amount of gas refunded. int64 gasRefunded; diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index d40fae0ad9f8d..7eae7331ba9c4 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -402,7 +402,7 @@ impl Cheatcode for etchCall { let Self { target, newRuntimeBytecode } = self; ensure_not_precompile!(target, ccx); ccx.ecx.load_account(*target)?; - let bytecode = Bytecode::new_raw(Bytes::copy_from_slice(newRuntimeBytecode)).to_checked(); + let bytecode = Bytecode::new_raw(Bytes::copy_from_slice(newRuntimeBytecode)); ccx.ecx.journaled_state.set_code(*target, bytecode); Ok(Default::default()) } diff --git a/crates/cheatcodes/src/evm/mapping.rs b/crates/cheatcodes/src/evm/mapping.rs index f5acc4966595a..b506d2058fc3b 100644 --- a/crates/cheatcodes/src/evm/mapping.rs +++ b/crates/cheatcodes/src/evm/mapping.rs @@ -117,7 +117,7 @@ pub(crate) fn step(mapping_slots: &mut HashMap, interpret match interpreter.current_opcode() { opcode::KECCAK256 => { if interpreter.stack.peek(1) == Ok(U256::from(0x40)) { - let address = interpreter.contract.address; + let address = interpreter.contract.target_address; let offset = interpreter.stack.peek(0).expect("stack size > 1").saturating_to(); let data = interpreter.shared_memory.slice(offset, 0x40); let low = B256::from_slice(&data[..0x20]); @@ -128,7 +128,8 @@ pub(crate) fn step(mapping_slots: &mut HashMap, interpret } } opcode::SSTORE => { - if let Some(mapping_slots) = mapping_slots.get_mut(&interpreter.contract.address) { + if let Some(mapping_slots) = mapping_slots.get_mut(&interpreter.contract.target_address) + { if let Ok(slot) = interpreter.stack.peek(0) { mapping_slots.insert(slot.into()); } diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 6a266a4108fb7..b2c46f116f4b6 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -56,7 +56,7 @@ impl Cheatcode for mockCall_0Call { // check Solidity might perform. let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty); if empty_bytecode { - let code = Bytecode::new_raw(Bytes::from_static(&[0u8])).to_checked(); + let code = Bytecode::new_raw(Bytes::from_static(&[0u8])); ccx.ecx.journaled_state.set_code(*callee, code); } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 25e34313c45ef..855e0374f7858 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -236,7 +236,7 @@ impl Cheatcodes { } e })?; - let caller = call.context.caller; + let caller = call.caller; // ensure the caller is allowed to execute cheatcodes, // but only if the backend is in forking mode @@ -391,7 +391,7 @@ impl Inspector for Cheatcodes { let key = try_or_continue!(interpreter.stack().peek(0)); storage_accesses .reads - .entry(interpreter.contract().address) + .entry(interpreter.contract().target_address) .or_default() .push(key); } @@ -401,12 +401,12 @@ impl Inspector for Cheatcodes { // An SSTORE does an SLOAD internally storage_accesses .reads - .entry(interpreter.contract().address) + .entry(interpreter.contract().target_address) .or_default() .push(key); storage_accesses .writes - .entry(interpreter.contract().address) + .entry(interpreter.contract().target_address) .or_default() .push(key); } @@ -420,7 +420,7 @@ impl Inspector for Cheatcodes { let target = try_or_continue!(interpreter.stack().peek(0)); // load balance of this account let value = ecx - .balance(interpreter.contract().address) + .balance(interpreter.contract().target_address) .map(|(b, _)| b) .unwrap_or(U256::ZERO); let account = Address::from_word(B256::from(target)); @@ -439,7 +439,7 @@ impl Inspector for Cheatcodes { forkId: ecx.db.active_fork_id().unwrap_or_default(), chainId: U256::from(ecx.env.cfg.chain_id), }, - accessor: interpreter.contract().address, + accessor: interpreter.contract().target_address, account, kind: crate::Vm::AccountAccessKind::SelfDestruct, initialized, @@ -464,7 +464,7 @@ impl Inspector for Cheatcodes { match interpreter.current_opcode() { opcode::SLOAD => { let key = try_or_continue!(interpreter.stack().peek(0)); - let address = interpreter.contract().address; + let address = interpreter.contract().target_address; // Try to include present value for informational purposes, otherwise assume // it's not set (zero value) @@ -476,7 +476,7 @@ impl Inspector for Cheatcodes { } } let access = crate::Vm::StorageAccess { - account: interpreter.contract().address, + account: interpreter.contract().target_address, slot: key.into(), isWrite: false, previousValue: present_value.into(), @@ -492,7 +492,7 @@ impl Inspector for Cheatcodes { opcode::SSTORE => { let key = try_or_continue!(interpreter.stack().peek(0)); let value = try_or_continue!(interpreter.stack().peek(1)); - let address = interpreter.contract().address; + let address = interpreter.contract().target_address; // Try to load the account and the slot's previous value, otherwise, assume it's // not set (zero value) let mut previous_value = U256::ZERO; @@ -546,7 +546,7 @@ impl Inspector for Cheatcodes { forkId: ecx.db.active_fork_id().unwrap_or_default(), chainId: U256::from(ecx.env.cfg.chain_id), }, - accessor: interpreter.contract().address, + accessor: interpreter.contract().target_address, account: address, kind, initialized, @@ -790,7 +790,7 @@ impl Inspector for Cheatcodes { } } - if call.contract == CHEATCODE_ADDRESS { + if call.target_address == CHEATCODE_ADDRESS { return match self.apply_cheatcode(ecx, call) { Ok(retdata) => Some(CallOutcome { result: InterpreterResult { @@ -813,14 +813,15 @@ impl Inspector for Cheatcodes { let ecx = &mut ecx.inner; - if call.contract == HARDHAT_CONSOLE_ADDRESS { + if call.target_address == HARDHAT_CONSOLE_ADDRESS { return None } // Handle expected calls // Grab the different calldatas expected. - if let Some(expected_calls_for_target) = self.expected_calls.get_mut(&(call.contract)) { + if let Some(expected_calls_for_target) = self.expected_calls.get_mut(&(call.target_address)) + { // Match every partial/full calldata for (calldata, (expected, actual_count)) in expected_calls_for_target { // Increment actual times seen if... @@ -831,7 +832,7 @@ impl Inspector for Cheatcodes { // The value matches, if provided expected .value - .map_or(true, |value| value == call.transfer.value) && + .map_or(true, |value| Some(value) == call.transfer_value()) && // The gas matches, if provided expected.gas.map_or(true, |gas| gas == call.gas_limit) && // The minimum gas matches, if provided @@ -843,17 +844,15 @@ impl Inspector for Cheatcodes { } // Handle mocked calls - if let Some(mocks) = self.mocked_calls.get(&call.contract) { - let ctx = MockCallDataContext { - calldata: call.input.clone(), - value: Some(call.transfer.value), - }; + if let Some(mocks) = self.mocked_calls.get(&call.target_address) { + let ctx = + MockCallDataContext { calldata: call.input.clone(), value: call.transfer_value() }; if let Some(return_data) = mocks.get(&ctx).or_else(|| { mocks .iter() .find(|(mock, _)| { call.input.get(..mock.calldata.len()) == Some(&mock.calldata[..]) && - mock.value.map_or(true, |value| value == call.transfer.value) + mock.value.map_or(true, |value| Some(value) == call.transfer_value()) }) .map(|(_, v)| v) }) { @@ -870,15 +869,12 @@ impl Inspector for Cheatcodes { // Apply our prank if let Some(prank) = &self.prank { - if ecx.journaled_state.depth() >= prank.depth && - call.context.caller == prank.prank_caller - { + if ecx.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { let mut prank_applied = false; // At the target depth we set `msg.sender` if ecx.journaled_state.depth() == prank.depth { - call.context.caller = prank.new_caller; - call.transfer.source = prank.new_caller; + call.caller = prank.new_caller; prank_applied = true; } @@ -904,15 +900,14 @@ impl Inspector for Cheatcodes { // 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.journaled_state.depth() == broadcast.depth && - call.context.caller == broadcast.original_caller + 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 // broadcast.origin. ecx.env.tx.caller = broadcast.new_origin; - call.context.caller = broadcast.new_origin; - call.transfer.source = broadcast.new_origin; + call.caller = broadcast.new_origin; // Add a `legacy` transaction to the VecDeque. We use a legacy transaction here // because we only need the from, to, value, and data. We can later change this // into 1559, in the cli package, relatively easily once we @@ -938,8 +933,8 @@ impl Inspector for Cheatcodes { rpc: ecx.db.active_fork_url(), transaction: TransactionRequest { from: Some(broadcast.new_origin), - to: Some(TxKind::from(Some(call.contract))), - value: Some(call.transfer.value), + to: Some(TxKind::from(Some(call.target_address))), + value: call.transfer_value(), input: TransactionInput::new(call.input.clone()), nonce: Some(account.info.nonce), gas: if is_fixed_gas_limit { @@ -979,14 +974,15 @@ impl Inspector for Cheatcodes { let initialized; let old_balance; // TODO: use ecx.load_account - if let Ok((acc, _)) = ecx.journaled_state.load_account(call.contract, &mut ecx.db) { + if let Ok((acc, _)) = ecx.journaled_state.load_account(call.target_address, &mut ecx.db) + { initialized = acc.info.exists(); old_balance = acc.info.balance; } else { initialized = false; old_balance = U256::ZERO; } - let kind = match call.context.scheme { + let kind = match call.scheme { CallScheme::Call => crate::Vm::AccountAccessKind::Call, CallScheme::CallCode => crate::Vm::AccountAccessKind::CallCode, CallScheme::DelegateCall => crate::Vm::AccountAccessKind::DelegateCall, @@ -1002,13 +998,13 @@ impl Inspector for Cheatcodes { forkId: ecx.db.active_fork_id().unwrap_or_default(), chainId: U256::from(ecx.env.cfg.chain_id), }, - accessor: call.context.caller, - account: call.contract, + accessor: call.caller, + account: call.bytecode_address, kind, initialized, oldBalance: old_balance, newBalance: U256::ZERO, // updated on call_end - value: call.transfer.value, + value: call.call_value(), data: call.input.clone(), reverted: false, deployedCode: Bytes::new(), @@ -1027,8 +1023,8 @@ impl Inspector for Cheatcodes { mut outcome: CallOutcome, ) -> CallOutcome { let ecx = &mut ecx.inner; - let cheatcode_call = - call.contract == CHEATCODE_ADDRESS || call.contract == 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 appplied for cheatcodes in the `call` hook. @@ -1115,15 +1111,10 @@ impl Inspector for Cheatcodes { // retrieve the gas usage of the last call. let gas = outcome.result.gas; self.last_call_gas = Some(crate::Vm::Gas { - // The gas limit of the call. gasLimit: gas.limit(), - // The total gas used. gasTotalUsed: gas.spent(), - // The amount of gas used for memory expansion. - gasMemoryUsed: gas.memory(), - // The amount of gas refunded. + gasMemoryUsed: 0, gasRefunded: gas.refunded(), - // The amount of gas remaining. gasRemaining: gas.remaining(), }); @@ -1152,7 +1143,7 @@ impl Inspector for Cheatcodes { if call_access.depth == ecx.journaled_state.depth() { // TODO: use ecx.load_account if let Ok((acc, _)) = - ecx.journaled_state.load_account(call.contract, &mut ecx.db) + ecx.journaled_state.load_account(call.target_address, &mut ecx.db) { debug_assert!(access_is_call(call_access.kind)); call_access.newBalance = acc.info.balance; @@ -1220,10 +1211,10 @@ impl Inspector for Cheatcodes { // `Stop` we check if the contract actually exists on the active fork if ecx.db.is_forked_mode() && outcome.result.result == InstructionResult::Stop && - call.contract != test_contract + call.target_address != test_contract { self.fork_revert_diagnostic = - ecx.db.diagnose_revert(call.contract, &ecx.journaled_state); + ecx.db.diagnose_revert(call.target_address, &ecx.journaled_state); } } diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 1fac3d051de2e..d57c6e7a26ee9 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -13,7 +13,6 @@ use ratatui::{ backend::{Backend, CrosstermBackend}, Terminal, }; -use revm::primitives::SpecId; use std::{ collections::{BTreeMap, HashMap}, io, @@ -71,8 +70,8 @@ impl Debugger { Some(( contract_name.to_owned(), ( - PcIcMap::new(SpecId::LATEST, contract.bytecode.bytes()?), - PcIcMap::new(SpecId::LATEST, contract.deployed_bytecode.bytes()?), + PcIcMap::new(contract.bytecode.bytes()?), + PcIcMap::new(contract.deployed_bytecode.bytes()?), ), )) }) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index fd4eeba7f0a7d..baeb1145b0d80 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -17,7 +17,7 @@ use revm::{ inspectors::NoOpInspector, precompile::{PrecompileSpecId, Precompiles}, primitives::{ - Account, AccountInfo, Bytecode, CreateScheme, Env, EnvWithHandlerCfg, HashMap as Map, Log, + Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, HashMap as Map, Log, ResultAndState, SpecId, State, StorageSlot, TransactTo, KECCAK_EMPTY, }, Database, DatabaseCommit, JournaledState, @@ -761,13 +761,7 @@ impl Backend { let test_contract = match env.tx.transact_to { TransactTo::Call(to) => to, - TransactTo::Create(CreateScheme::Create) => { - env.tx.caller.create(env.tx.nonce.unwrap_or_default()) - } - TransactTo::Create(CreateScheme::Create2 { salt }) => { - let code_hash = B256::from_slice(keccak256(&env.tx.data).as_slice()); - env.tx.caller.create2(B256::from(salt), code_hash) - } + TransactTo::Create => env.tx.caller.create(env.tx.nonce.unwrap_or_default()), }; self.set_test_contract(test_contract); } diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 960f3779ffb5b..4dda2a9942c0e 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -22,6 +22,7 @@ use revm::{ use rustc_hash::FxHashMap; use std::{ collections::{hash_map::Entry, HashMap, VecDeque}, + future::IntoFuture, marker::PhantomData, pin::Pin, sync::{ @@ -187,10 +188,13 @@ where trace!(target: "backendhandler", %address, %idx, "preparing storage request"); entry.insert(vec![listener]); let provider = self.provider.clone(); - let block_id = self.block_id.unwrap_or(BlockId::latest()); + let block_id = self.block_id.unwrap_or_default(); let fut = Box::pin(async move { - let storage = - provider.get_storage_at(address, idx, block_id).await.map_err(Into::into); + let storage = provider + .get_storage_at(address, idx) + .block_id(block_id) + .await + .map_err(Into::into); (storage, address, idx) }); self.pending_requests.push(ProviderRequest::Storage(fut)); @@ -202,11 +206,11 @@ where fn get_account_req(&self, address: Address) -> ProviderRequest { trace!(target: "backendhandler", "preparing account request, address={:?}", address); let provider = self.provider.clone(); - let block_id = self.block_id.unwrap_or(BlockId::latest()); + let block_id = self.block_id.unwrap_or_default(); let fut = Box::pin(async move { - let balance = provider.get_balance(address, block_id); - let nonce = provider.get_transaction_count(address, block_id); - let code = provider.get_code_at(address, block_id); + let balance = provider.get_balance(address).block_id(block_id).into_future(); + let nonce = provider.get_transaction_count(address).block_id(block_id).into_future(); + let code = provider.get_code_at(address).block_id(block_id).into_future(); let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); (resp, address) }); @@ -358,7 +362,7 @@ where let acc = AccountInfo { nonce, balance, - code: Some(Bytecode::new_raw(code).to_checked()), + code: Some(Bytecode::new_raw(code)), code_hash, }; pin.db.accounts().write().insert(addr, acc.clone()); diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index 607eced688945..ce13f69c1a3f0 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -487,12 +487,12 @@ mod tests { "meta": { "cfg_env": { "chain_id": 1337, - "spec_id": "LATEST", - "perf_all_precompiles_have_balance": false, - "disable_coinbase_tip": false, "perf_analyse_created_bytecodes": "Analyse", "limit_contract_code_size": 18446744073709551615, - "memory_limit": 4294967295 + "memory_limit": 4294967295, + "disable_block_gas_limit": false, + "disable_eip3607": false, + "disable_base_fee": false }, "block_env": { "number": "0xed3ddf", @@ -500,7 +500,8 @@ mod tests { "timestamp": "0x6324bc3f", "difficulty": "0x0", "basefee": "0x2e5fda223", - "gas_limit": "0x1c9c380" + "gas_limit": "0x1c9c380", + "prevrandao": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "hosts": [ "eth-mainnet.alchemyapi.io" @@ -512,11 +513,17 @@ mod tests { "nonce": 10, "code_hash": "0x3ac64c95eedf82e5d821696a12daac0e1b22c8ee18a9fd688b00cfaf14550aad", "code": { - "bytecode": "0x60806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416634555d5c9811461012b5780634558850c1461015257806348a0c8dd146101965780635c60da1b146101bf57806386070cfe146101d4575b6127107f665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea6000825a10156100e15760003411361583541616156100dc576040513381523460208201527f15eeaa57c7bd188c1388020bcadc2c436ec60d647d36ef5b9eb3c742217ddee1604082a1005b600080fd5b6100e96101e9565b9050610126816000368080601f0160208091040260200160405190810160405280939291908181526020018383808284375061026c945050505050565b505050005b34801561013757600080fd5b506101406102ad565b60408051918252519081900360200190f35b34801561015e57600080fd5b5061016d6004356024356102b2565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156101a257600080fd5b506101ab6102e2565b604080519115158252519081900360200190f35b3480156101cb57600080fd5b5061016d6101e9565b3480156101e057600080fd5b50610140610312565b7f3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c6000527fc67454ed56db7ff90a4bb32fc9a8de1ab3174b221e5fecea22b7503a3111791f6020527f8e2ed18767e9c33b25344c240cdf92034fae56be99e2c07f3d9946d949ffede45473ffffffffffffffffffffffffffffffffffffffff1690565b600061027783610318565b151561028257600080fd5b612710905060008083516020850186855a03f43d604051816000823e8280156102a9578282f35b8282fd5b600290565b600060208181529281526040808220909352908152205473ffffffffffffffffffffffffffffffffffffffff1681565b600061030d7f665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea610352565b905090565b60015481565b60008073ffffffffffffffffffffffffffffffffffffffff83161515610341576000915061034c565b823b90506000811191505b50919050565b54905600a165627a7a72305820968d404e148c1ec7bb58c8df6cbdcaad4978b93a804e00a1f0e97a5e789eacd40029000000000000000000000000000000000000000000000000000000000000000000", - "hash": "0x3ac64c95eedf82e5d821696a12daac0e1b22c8ee18a9fd688b00cfaf14550aad", - "state": { - "Checked": { - "len": 898 + "LegacyAnalyzed": { + "bytecode": "0x00", + "original_len": 0, + "jump_table": { + "order": "bitvec::order::Lsb0", + "head": { + "width": 8, + "index": 0 + }, + "bits": 1, + "data": [0] } } } @@ -557,7 +564,7 @@ mod tests { "meta": { "cfg_env": { "chain_id": 1, - "spec_id": "LATEST", + "kzg_settings": "Default", "perf_analyse_created_bytecodes": "Analyse", "limit_contract_code_size": 18446744073709551615, "memory_limit": 134217728, @@ -589,10 +596,17 @@ mod tests { "nonce": 128912, "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", "code": { - "bytecode": "0x000000000000000000000000000000000000000000000000000000000000000000", - "state": { - "Checked": { - "len": 0 + "LegacyAnalyzed": { + "bytecode": "0x00", + "original_len": 0, + "jump_table": { + "order": "bitvec::order::Lsb0", + "head": { + "width": 8, + "index": 0 + }, + "bits": 1, + "data": [0] } } } diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index 9f679fc36e50f..fa2b5efd55018 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -1,7 +1,4 @@ -use revm::{ - interpreter::{opcode, opcode::spec_opcode_gas}, - primitives::SpecId, -}; +use revm::interpreter::opcode::{PUSH0, PUSH1, PUSH32}; use rustc_hash::FxHashMap; /// Maps from program counter to instruction counter. @@ -13,8 +10,8 @@ pub struct PcIcMap { impl PcIcMap { /// Creates a new `PcIcMap` for the given code. - pub fn new(spec: SpecId, code: &[u8]) -> Self { - Self { inner: make_map::(spec, code) } + pub fn new(code: &[u8]) -> Self { + Self { inner: make_map::(code) } } /// Returns the instruction counter for the given program counter. @@ -32,8 +29,8 @@ pub struct IcPcMap { impl IcPcMap { /// Creates a new `IcPcMap` for the given code. - pub fn new(spec: SpecId, code: &[u8]) -> Self { - Self { inner: make_map::(spec, code) } + pub fn new(code: &[u8]) -> Self { + Self { inner: make_map::(code) } } /// Returns the program counter for the given instruction counter. @@ -42,8 +39,7 @@ impl IcPcMap { } } -fn make_map(spec: SpecId, code: &[u8]) -> FxHashMap { - let opcode_infos = spec_opcode_gas(spec); +fn make_map(code: &[u8]) -> FxHashMap { let mut map = FxHashMap::default(); let mut pc = 0; @@ -56,10 +52,9 @@ fn make_map(spec: SpecId, code: &[u8]) -> FxHashMap u64 { fn get_create2_factory_call_inputs(salt: U256, inputs: CreateInputs) -> CallInputs { let calldata = [&salt.to_be_bytes::<32>()[..], &inputs.init_code[..]].concat(); CallInputs { - contract: DEFAULT_CREATE2_DEPLOYER, - transfer: Transfer { - source: inputs.caller, - target: DEFAULT_CREATE2_DEPLOYER, - value: inputs.value, - }, + caller: inputs.caller, + bytecode_address: DEFAULT_CREATE2_DEPLOYER, + target_address: DEFAULT_CREATE2_DEPLOYER, + scheme: CallScheme::Call, + value: CallValue::Transfer(inputs.value), input: calldata.into(), gas_limit: inputs.gas_limit, - context: CallContext { - caller: inputs.caller, - address: DEFAULT_CREATE2_DEPLOYER, - code_address: DEFAULT_CREATE2_DEPLOYER, - apparent_value: inputs.value, - scheme: CallScheme::Call, - }, is_static: false, return_memory_offset: 0..0, + is_eof: false, } } diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index d45fdae57dca3..a1992d47ad14f 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -5,8 +5,8 @@ use alloy_primitives::Bytes; use foundry_compilers::sourcemap::{SourceElement, SourceMap}; use foundry_evm_core::utils::IcPcMap; use revm::{ - interpreter::opcode::{self, spec_opcode_gas}, - primitives::{HashSet, SpecId}, + interpreter::opcode::{self, PUSH1, PUSH32}, + primitives::HashSet, }; /// Attempts to find anchors for the given items using the given source map and bytecode. @@ -114,7 +114,6 @@ pub fn find_anchor_branch( ) -> eyre::Result<(ItemAnchor, ItemAnchor)> { // NOTE(onbjerg): We use `SpecId::LATEST` here since it does not matter; the only difference // is the gas cost. - let opcode_infos = spec_opcode_gas(SpecId::LATEST); let mut anchors: Option<(ItemAnchor, ItemAnchor)> = None; let mut pc = 0; @@ -124,7 +123,9 @@ pub fn find_anchor_branch( // We found a push, so we do some PC -> IC translation accounting, but we also check if // this push is coupled with the JUMPI we are interested in. - if opcode_infos[op as usize].is_push() { + + // Check if Opcode is PUSH + if (PUSH1..=PUSH32).contains(&op) { let element = if let Some(element) = source_map.get(pc - cumulative_push_size) { element } else { diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index 3c3af1ba21486..4e25ddb51a041 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -10,15 +10,15 @@ pub struct CoverageCollector { impl Inspector for CoverageCollector { #[inline] fn initialize_interp(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { - let hash = interp.contract.hash; + let hash = interp.contract.hash.expect("Contract hash is None"); self.maps .entry(hash) - .or_insert_with(|| HitMap::new(interp.contract.bytecode.original_bytecode())); + .or_insert_with(|| HitMap::new(interp.contract.bytecode.original_bytes())); } #[inline] fn step(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { - let hash = interp.contract.hash; + let hash = interp.contract.hash.expect("Contract hash is None"); self.maps.entry(hash).and_modify(|map| map.hit(interp.program_counter())); } } diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index be3324c10959c..72f4a6d171567 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -22,7 +22,12 @@ foundry-evm-traces.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } alloy-sol-types.workspace = true revm = { workspace = true, default-features = false, features = [ "std", diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 6998006413d40..940e223b2448b 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -26,7 +26,7 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use revm::{ db::{DatabaseCommit, DatabaseRef}, - interpreter::{return_ok, CreateScheme, InstructionResult}, + interpreter::{return_ok, InstructionResult}, primitives::{ BlockEnv, Bytecode, Env, EnvWithHandlerCfg, ExecutionResult, Output, ResultAndState, SpecId, TransactTo, TxEnv, @@ -92,7 +92,7 @@ impl Executor { backend.insert_account_info( CHEATCODE_ADDRESS, revm::primitives::AccountInfo { - code: Some(Bytecode::new_raw(Bytes::from_static(&[0])).to_checked()), + code: Some(Bytecode::new_raw(Bytes::from_static(&[0]))), ..Default::default() }, ); @@ -386,7 +386,7 @@ impl Executor { rd: Option<&RevertDecoder>, ) -> Result { assert!( - matches!(env.tx.transact_to, TransactTo::Create(_)), + matches!(env.tx.transact_to, TransactTo::Create), "Expected create transaction, got {:?}", env.tx.transact_to ); @@ -419,7 +419,7 @@ impl Executor { value: U256, rd: Option<&RevertDecoder>, ) -> Result { - let env = self.build_test_env(from, TransactTo::Create(CreateScheme::Create), code, value); + let env = self.build_test_env(from, TransactTo::Create, code, value); self.deploy_with_env(env, rd) } diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index d68a14bf6dc43..c6b8a7cc5df4d 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -8,9 +8,8 @@ use foundry_evm_core::{ }; use revm::{ interpreter::{ - opcode::{self, spec_opcode_gas}, - CallInputs, CallOutcome, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, - InterpreterResult, + opcode, CallInputs, CallOutcome, CreateInputs, CreateOutcome, Gas, InstructionResult, + Interpreter, InterpreterResult, }, EvmContext, Inspector, }; @@ -50,12 +49,12 @@ impl Inspector for Debugger { let pc = interp.program_counter(); let op = interp.current_opcode(); - // Get opcode information - let opcode_infos = spec_opcode_gas(ecx.spec_id()); - let opcode_info = &opcode_infos[op as usize]; - // Extract the push bytes - let push_size = if opcode_info.is_push() { (op - opcode::PUSH0) as usize } else { 0 }; + let push_size = if (opcode::PUSH1..=opcode::PUSH32).contains(&op) { + (op - opcode::PUSH0) as usize + } else { + 0 + }; let push_bytes = (push_size > 0).then(|| { let start = pc + 1; let end = start + push_size; @@ -95,8 +94,8 @@ impl Inspector for Debugger { fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { self.enter( ecx.journaled_state.depth() as usize, - inputs.context.code_address, - inputs.context.scheme.into(), + inputs.bytecode_address, + inputs.scheme.into(), ); None diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index a8e4a063c352a..f2bf3a114706e 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -48,7 +48,7 @@ impl Inspector for LogCollector { _context: &mut EvmContext, inputs: &mut CallInputs, ) -> Option { - if inputs.contract == HARDHAT_CONSOLE_ADDRESS { + if inputs.target_address == HARDHAT_CONSOLE_ADDRESS { let (res, out) = self.hardhat_log(inputs.input.to_vec()); if res != InstructionResult::Continue { return Some(CallOutcome { diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index bcb1e5517ead2..10108c89137df 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -486,7 +486,7 @@ impl InspectorStack { sender: ecx.env.tx.caller, original_origin: cached_env.tx.caller, original_sender_nonce: nonce, - is_create: matches!(transact_to, TransactTo::Create(_)), + is_create: matches!(transact_to, TransactTo::Create), }); self.in_inner_context = true; @@ -551,7 +551,7 @@ impl InspectorStack { let (result, address, output) = match res.result { ExecutionResult::Success { reason, gas_used, gas_refunded, logs: _, output } => { gas.set_refund(gas_refunded as i64); - gas.record_cost(gas_used); + let _ = gas.record_cost(gas_used); let address = match output { Output::Create(_, address) => address, Output::Call(_) => None, @@ -559,11 +559,11 @@ impl InspectorStack { (reason.into(), address, output.into_data()) } ExecutionResult::Halt { reason, gas_used } => { - gas.record_cost(gas_used); + let _ = gas.record_cost(gas_used); (reason.into(), None, Bytes::new()) } ExecutionResult::Revert { gas_used, output } => { - gas.record_cost(gas_used); + let _ = gas.record_cost(gas_used); (InstructionResult::Revert, None, output) } }; @@ -678,17 +678,17 @@ impl Inspector<&mut DB> for InspectorStack { ); if self.enable_isolation && - call.context.scheme == CallScheme::Call && + call.scheme == CallScheme::Call && !self.in_inner_context && ecx.journaled_state.depth == 1 { let (result, _) = self.transact_inner( ecx, - TransactTo::Call(call.contract), - call.context.caller, + TransactTo::Call(call.target_address), + call.caller, call.input.clone(), call.gas_limit, - call.transfer.value, + call.value.get(), ); return Some(CallOutcome { result, memory_offset: call.return_memory_offset.clone() }) } @@ -741,7 +741,7 @@ impl Inspector<&mut DB> for InspectorStack { if self.enable_isolation && !self.in_inner_context && ecx.journaled_state.depth == 1 { let (result, address) = self.transact_inner( ecx, - TransactTo::Create(create.scheme), + TransactTo::Create, create.caller, create.init_code.clone(), create.gas_limit, diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index eb089baf6c289..fe5c134560bf8 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -29,7 +29,7 @@ impl Inspector for Fuzzer { #[inline] fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { // We don't want to override the very first call made to the test contract. - if self.call_generator.is_some() && ecx.env.tx.caller != inputs.context.caller { + if self.call_generator.is_some() && ecx.env.tx.caller != inputs.caller { self.override_call(inputs); } @@ -77,20 +77,18 @@ impl Fuzzer { fn override_call(&mut self, call: &mut CallInputs) { if let Some(ref mut call_generator) = self.call_generator { // We only override external calls which are not coming from the test contract. - if call.context.caller != call_generator.test_address && - call.context.scheme == CallScheme::Call && + if call.caller != call_generator.test_address && + call.scheme == CallScheme::Call && !call_generator.used { // There's only a 30% chance that an override happens. - if let Some(tx) = call_generator.next(call.context.caller, call.contract) { + if let Some(tx) = call_generator.next(call.caller, call.target_address) { *call.input = tx.call_details.calldata.0; - call.context.caller = tx.sender; - call.contract = tx.call_details.target; + call.caller = tx.sender; + call.target_address = tx.call_details.target; // TODO: in what scenarios can the following be problematic - call.context.code_address = tx.call_details.target; - call.context.address = tx.call_details.target; - + call.bytecode_address = tx.call_details.target; call_generator.used = true; } } diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 791ca3d9a67e4..81aa93a5aec22 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -9,8 +9,8 @@ use indexmap::IndexSet; use parking_lot::{lock_api::RwLockReadGuard, RawRwLock, RwLock}; use revm::{ db::{CacheDB, DatabaseRef, DbAccount}, - interpreter::opcode::{self, spec_opcode_gas}, - primitives::{AccountInfo, SpecId}, + interpreter::opcode, + primitives::AccountInfo, }; use std::{ collections::{BTreeMap, HashMap}, @@ -217,7 +217,7 @@ impl FuzzDictionary { // Insert push bytes if let Some(code) = account_info.code.clone() { self.insert_address(*address, collected); - for push_byte in collect_push_bytes(code.bytes()) { + for push_byte in collect_push_bytes(&code.bytes()) { self.insert_value(push_byte, collected); } } @@ -323,11 +323,10 @@ fn collect_push_bytes(code: &[u8]) -> Vec<[u8; 32]> { let mut bytes: Vec<[u8; 32]> = Vec::new(); // We use [SpecId::LATEST] since we do not really care what spec it is - we are not interested // in gas costs. - let opcode_infos = spec_opcode_gas(SpecId::LATEST); let mut i = 0; while i < code.len().min(PUSH_BYTE_ANALYSIS_LIMIT) { let op = code[i]; - if opcode_infos[op as usize].is_push() { + if (opcode::PUSH1..=opcode::PUSH32).contains(&op) { let push_size = (op - opcode::PUSH1 + 1) as usize; let push_start = i + 1; let push_end = push_start + push_size; diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index d55c4db9a84bd..380aa4927c061 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -8,7 +8,6 @@ use forge::{ CoverageReport, CoverageReporter, DebugReporter, LcovReporter, SummaryReporter, }, opts::EvmOpts, - revm::primitives::SpecId, utils::IcPcMap, MultiContractRunnerBuilder, TestOptions, }; @@ -231,10 +230,7 @@ impl CoverageArgs { // TODO: Creation bytecode as well ( id.clone(), - ( - IcPcMap::new(SpecId::LATEST, bytecodes.0.as_ref()), - IcPcMap::new(SpecId::LATEST, bytecodes.1.as_ref()), - ), + (IcPcMap::new(bytecodes.0.as_ref()), IcPcMap::new(bytecodes.1.as_ref())), ) }) .collect(); diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 71a1cffd71571..6ef37cf102144 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -4,7 +4,7 @@ use alloy_json_abi::{Constructor, JsonAbi}; use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; use alloy_primitives::{Address, Bytes}; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::{AnyTransactionReceipt, BlockId, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest, WithOtherFields}; use alloy_signer::Signer; use alloy_transport::{Transport, TransportError}; use clap::{Parser, ValueHint}; @@ -241,7 +241,7 @@ impl CreateArgs { deployer.tx.set_nonce(if let Some(nonce) = self.tx.nonce { Ok(nonce.to()) } else { - provider.get_transaction_count(deployer_address, BlockId::latest()).await + provider.get_transaction_count(deployer_address).await }?); // set tx value if specified @@ -252,7 +252,7 @@ impl CreateArgs { deployer.tx.set_gas_limit(if let Some(gas_limit) = self.tx.gas_limit { Ok(gas_limit.to()) } else { - provider.estimate_gas(&deployer.tx, BlockId::latest()).await + provider.estimate_gas(&deployer.tx).await }?); if is_legacy { diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index a278e44d75917..3a2e663700fb4 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -8,7 +8,7 @@ use alloy_eips::eip2718::Encodable2718; use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; use alloy_primitives::{utils::format_units, Address, TxHash}; use alloy_provider::{utils::Eip1559Estimation, Provider}; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use alloy_transport::Transport; use eyre::{bail, Context, Result}; use forge_verify::provider::VerificationProviderType; @@ -43,10 +43,7 @@ where tx.gas = None; tx.set_gas_limit( - provider - .estimate_gas(tx, BlockId::latest()) - .await - .wrap_err("Failed to estimate gas for tx")? * + provider.estimate_gas(tx).await.wrap_err("Failed to estimate gas for tx")? * estimate_multiplier as u128 / 100, ); @@ -56,7 +53,7 @@ where pub async fn next_nonce(caller: Address, provider_url: &str) -> eyre::Result { let provider = try_get_http_provider(provider_url) .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; - Ok(provider.get_transaction_count(caller, BlockId::latest()).await?) + Ok(provider.get_transaction_count(caller).await?) } pub async fn send_transaction( @@ -71,7 +68,7 @@ pub async fn send_transaction( let from = tx.from.expect("no sender"); if sequential_broadcast { - let nonce = provider.get_transaction_count(from, BlockId::latest()).await?; + let nonce = provider.get_transaction_count(from).await?; let tx_nonce = tx.nonce.expect("no nonce"); if nonce != tx_nonce { diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 8d9907ccfebe4..3bf9e154bf934 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -45,8 +45,7 @@ impl BuildData { pub async fn link(self, script_config: &ScriptConfig) -> Result { let can_use_create2 = if let Some(fork_url) = &script_config.evm_opts.fork_url { let provider = try_get_http_provider(fork_url)?; - let deployer_code = - provider.get_code_at(DEFAULT_CREATE2_DEPLOYER, Default::default()).await?; + let deployer_code = provider.get_code_at(DEFAULT_CREATE2_DEPLOYER).await?; !deployer_code.is_empty() } else { diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index c2ee04cbef7bd..c34faf250c8f8 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -18,7 +18,6 @@ foundry-config.workspace = true alloy-primitives.workspace = true alloy-provider.workspace = true -alloy-rpc-types.workspace = true eyre.workspace = true fd-lock = "4.0.0" diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 8b625d6eed9ab..232417f875707 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,7 +1,6 @@ use crate::{init_tracing, TestCommand}; use alloy_primitives::Address; use alloy_provider::Provider; -use alloy_rpc_types::BlockId; use eyre::Result; use foundry_common::provider::{get_http_provider, RetryProvider}; use std::{ @@ -141,7 +140,7 @@ impl ScriptTester { if let Some(provider) = &self.provider { let nonce = provider - .get_transaction_count(self.accounts_pub[index as usize], BlockId::latest()) + .get_transaction_count(self.accounts_pub[index as usize]) .await .unwrap(); self.nonces.insert(index, nonce); @@ -152,13 +151,8 @@ impl ScriptTester { pub async fn load_addresses(&mut self, addresses: &[Address]) -> &mut Self { for &address in addresses { - let nonce = self - .provider - .as_ref() - .unwrap() - .get_transaction_count(address, BlockId::latest()) - .await - .unwrap(); + let nonce = + self.provider.as_ref().unwrap().get_transaction_count(address).await.unwrap(); self.address_nonces.insert(address, nonce); } self @@ -198,13 +192,7 @@ impl ScriptTester { pub async fn assert_nonce_increment(&mut self, keys_indexes: &[(u32, u32)]) -> &mut Self { for &(private_key_slot, expected_increment) in keys_indexes { let addr = self.accounts_pub[private_key_slot as usize]; - let nonce = self - .provider - .as_ref() - .unwrap() - .get_transaction_count(addr, BlockId::latest()) - .await - .unwrap(); + let nonce = self.provider.as_ref().unwrap().get_transaction_count(addr).await.unwrap(); let prev_nonce = self.nonces.get(&private_key_slot).unwrap(); assert_eq!( @@ -223,13 +211,8 @@ impl ScriptTester { address_indexes: &[(Address, u32)], ) -> &mut Self { for (address, expected_increment) in address_indexes { - let nonce = self - .provider - .as_ref() - .unwrap() - .get_transaction_count(*address, BlockId::latest()) - .await - .unwrap(); + let nonce = + self.provider.as_ref().unwrap().get_transaction_count(*address).await.unwrap(); let prev_nonce = self.address_nonces.get(address).unwrap(); assert_eq!(nonce, *prev_nonce + *expected_increment as u64); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 53654a7d35e51..829efd42624c8 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -109,7 +109,7 @@ impl VerifyBytecodeArgs { let config = self.load_config_emit_warnings(); let provider = ProviderBuilder::new(&config.get_rpc_url_or_localhost_http()?).build()?; - let code = provider.get_code_at(self.address, BlockId::latest()).await?; + let code = provider.get_code_at(self.address).await?; if code.is_empty() { eyre::bail!("No bytecode found at address {}", self.address); } @@ -290,9 +290,11 @@ impl VerifyBytecodeArgs { // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same // block. - let prev_block_id = BlockId::Number(BlockNumberOrTag::Number(simulation_block - 1)); - let prev_block_nonce = - provider.get_transaction_count(creation_data.contract_creator, prev_block_id).await?; + let prev_block_id = BlockId::number(simulation_block - 1); + let prev_block_nonce = provider + .get_transaction_count(creation_data.contract_creator) + .block_id(prev_block_id) + .await?; transaction.nonce = prev_block_nonce; if let Some(ref block) = block { @@ -343,13 +345,12 @@ impl VerifyBytecodeArgs { ) })?; - let onchain_runtime_code = provider - .get_code_at(self.address, BlockId::Number(BlockNumberOrTag::Number(simulation_block))) - .await?; + let onchain_runtime_code = + provider.get_code_at(self.address).block_id(BlockId::number(simulation_block)).await?; // Compare the runtime bytecode with the locally built bytecode let (did_match, with_status) = try_match( - &fork_runtime_code.bytecode, + fork_runtime_code.bytecode(), &onchain_runtime_code, &constructor_args, &verification_type, diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rs index 5655791182a4c..200abbf3d46e0 100644 --- a/crates/verify/src/lib.rs +++ b/crates/verify/src/lib.rs @@ -293,7 +293,7 @@ impl VerifyArgs { eyre::bail!("You have to provide a contract name or a valid RPC URL") } let provider = utils::get_provider(&config)?; - let code = provider.get_code_at(self.address, Default::default()).await?; + let code = provider.get_code_at(self.address).await?; let output = ProjectCompiler::new().compile(&project)?; let contracts = ContractsByArtifact::new( diff --git a/deny.toml b/deny.toml index 299c1452ac012..d69e73391da87 100644 --- a/deny.toml +++ b/deny.toml @@ -85,4 +85,7 @@ unknown-registry = "warn" # Lint level for what to happen when a crate from a git repository that is not # in the allow list is encountered unknown-git = "deny" -allow-git = ["https://github.com/alloy-rs/alloy", "https://github.com/paradigmxyz/evm-inspectors"] +allow-git = [ + "https://github.com/alloy-rs/alloy", + "https://github.com/paradigmxyz/revm-inspectors", +] diff --git a/testdata/default/cheats/LastCallGas.t.sol b/testdata/default/cheats/LastCallGas.t.sol index ec8c6ba0aad5a..0f5b65e350e13 100644 --- a/testdata/default/cheats/LastCallGas.t.sol +++ b/testdata/default/cheats/LastCallGas.t.sol @@ -53,10 +53,6 @@ abstract contract LastCallGasFixture is DSTest { (success,) = address(target).call(""); } - function _performExpandMemory() internal view { - target.expandMemory(1000); - } - function _performRefund() internal { target.setValue(1); target.resetValue(); @@ -84,12 +80,6 @@ contract LastCallGasIsolatedTest is LastCallGasFixture { _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); } - function testRecordGasMemory() public { - _setup(); - _performExpandMemory(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 186470, gasMemoryUsed: 4994, gasRefunded: 0})); - } - function testRecordGasRefund() public { _setup(); _performRefund(); @@ -102,24 +92,18 @@ contract LastCallGasDefaultTest is LastCallGasFixture { function testRecordLastCallGas() public { _setup(); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 9, gasRefunded: 0})); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 9, gasRefunded: 0})); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 9, gasRefunded: 0})); - } - - function testRecordGasMemory() public { - _setup(); - _performExpandMemory(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 186470, gasMemoryUsed: 4994, gasRefunded: 0})); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); } function testRecordGasRefund() public { _setup(); _performRefund(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 216, gasMemoryUsed: 9, gasRefunded: 19900})); + _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 216, gasMemoryUsed: 0, gasRefunded: 19900})); } } From 8fd3eb9fb803dc546f57d1d0ca3bffac7d3b794a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 23 May 2024 17:51:09 +0300 Subject: [PATCH 0984/1963] chore(fuzz): add unit test for #1168 (#7974) --- crates/forge/tests/it/fuzz.rs | 24 ++++++++++++- .../default/fuzz/FuzzScrapeBytecode.t.sol | 35 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 testdata/default/fuzz/FuzzScrapeBytecode.t.sol diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index c6369e896615f..46f8115ab55c8 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -12,7 +12,7 @@ use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] async fn test_fuzz() { let filter = Filter::new(".*", ".*", ".*fuzz/") - .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)|testSuccessChecker\(uint256\)|testSuccessChecker2\(int256\)|testSuccessChecker3\(uint32\)") + .exclude_tests(r"invariantCounter|testIncrement\(address\)|testNeedle\(uint256\)|testSuccessChecker\(uint256\)|testSuccessChecker2\(int256\)|testSuccessChecker3\(uint32\)|testStorageOwner\(address\)|testImmutableOwner\(address\)") .exclude_paths("invariant"); let mut runner = TEST_DATA_DEFAULT.runner(); let suite_result = runner.test_collect(&filter); @@ -153,3 +153,25 @@ async fn test_persist_fuzz_failure() { // empty file is used to load failure so new calldata is generated assert_ne!(initial_calldata, new_calldata); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_scrape_bytecode() { + let filter = Filter::new(".*", ".*", ".*fuzz/FuzzScrapeBytecode.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.fuzz.runs = 750; + runner.test_options.fuzz.seed = Some(U256::from(6u32)); + let suite_result = runner.test_collect(&filter); + + assert!(!suite_result.is_empty()); + + for (_, SuiteResult { test_results, .. }) in suite_result { + for (test_name, result) in test_results { + match test_name.as_str() { + "testImmutableOwner(address)" | "testStorageOwner(address)" => { + assert_eq!(result.status, TestStatus::Failure) + } + _ => {} + } + } + } +} diff --git a/testdata/default/fuzz/FuzzScrapeBytecode.t.sol b/testdata/default/fuzz/FuzzScrapeBytecode.t.sol new file mode 100644 index 0000000000000..ffded67f03311 --- /dev/null +++ b/testdata/default/fuzz/FuzzScrapeBytecode.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +// https://github.com/foundry-rs/foundry/issues/1168 +contract FuzzerDict { + // Immutables should get added to the dictionary. + address public immutable immutableOwner; + // Regular storage variables should also get added to the dictionary. + address public storageOwner; + + constructor(address _immutableOwner, address _storageOwner) { + immutableOwner = _immutableOwner; + storageOwner = _storageOwner; + } +} + +contract FuzzerDictTest is DSTest { + FuzzerDict fuzzerDict; + + function setUp() public { + fuzzerDict = new FuzzerDict(address(100), address(200)); + } + + // Fuzzer should try `fuzzerDict.immutableOwner()` as input, causing this to fail + function testImmutableOwner(address who) public { + assertTrue(who != fuzzerDict.immutableOwner()); + } + + // Fuzzer should try `fuzzerDict.storageOwner()` as input, causing this to fail + function testStorageOwner(address who) public { + assertTrue(who != fuzzerDict.storageOwner()); + } +} From 10b9baa3a162f5742e561be2bc8048eceb03a3da Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 23 May 2024 17:59:30 +0300 Subject: [PATCH 0985/1963] feat: Vyper support for forge build (#7953) * feat: Vyper support for forge build * clippy * fix doc * fmt * fix * rm patch * fmt * review fixes * update test * clippy + fmt --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 9 +- Cargo.toml | 4 +- crates/common/src/compile.rs | 36 ++++++-- crates/config/src/language.rs | 39 +++++++++ crates/config/src/lib.rs | 131 +++++++++++++++++++++++------ crates/forge/bin/cmd/build.rs | 50 ++++++++--- crates/forge/bin/cmd/coverage.rs | 6 +- crates/forge/bin/cmd/doc/mod.rs | 4 +- crates/forge/bin/cmd/fmt.rs | 4 +- crates/forge/bin/cmd/geiger/mod.rs | 4 +- crates/forge/bin/cmd/tree.rs | 4 +- crates/forge/src/multi_runner.rs | 8 +- crates/forge/tests/cli/config.rs | 7 +- crates/test-utils/src/util.rs | 4 +- 14 files changed, 244 insertions(+), 66 deletions(-) create mode 100644 crates/config/src/language.rs diff --git a/Cargo.lock b/Cargo.lock index b03d115c6f5c4..1496b337910ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3297,9 +3297,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351c6be2db0090c6c5ae214a7e768a1a61d7d46ff70ab9e7ee45c8f34e6c3c60" +checksum = "7101c78b700b8c84294aee0319289af724201181a9b757d8a9a2fea991f3ce4e" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3451,9 +3451,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74a0bb9a4a8da5ded9ddbf2aba3d25bf26d2c4e8a3dfb4f20164d47d4da8761a" +checksum = "136f5e0af939b12cf072ac6577818a87cb7a408b269070f5d6f52ba23454660e" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3484,6 +3484,7 @@ dependencies = [ "tokio", "tracing", "walkdir", + "winnow 0.6.8", "yansi", ] diff --git a/Cargo.toml b/Cargo.toml index d55304817382e..4f5b962b2fbeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,8 +137,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.2.7", default-features = false } -foundry-compilers = { version = "0.4.3", default-features = false } +foundry-block-explorers = { version = "0.2.8", default-features = false } +foundry-compilers = { version = "0.5", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 3141a69786d81..329e53213d901 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -6,11 +6,15 @@ use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ artifacts::{BytecodeObject, ContractBytecodeSome, Libraries}, - compilers::{solc::SolcVersionManager, Compiler, CompilerVersionManager}, + compilers::{ + solc::SolcVersionManager, vyper::parser::VyperParsedSource, Compiler, + CompilerVersionManager, + }, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, - Artifact, ArtifactId, CompilerConfig, ConfigurableArtifacts, FileFilter, Project, - ProjectCompileOutput, ProjectPathsConfig, SolcConfig, SparseOutputFileFilter, + resolver::{parse::SolData, GraphEdges}, + Artifact, ArtifactId, CompilerConfig, FileFilter, Project, ProjectCompileOutput, + ProjectPathsConfig, SolcConfig, SolcSparseFileFilter, SparseOutputFileFilter, }; use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; @@ -138,7 +142,7 @@ impl ProjectCompiler { /// Compiles the project. pub fn compile( mut self, - project: &Project, + project: &Project, ) -> Result> { // TODO: Avoid process::exit if !project.paths.has_input_files() && self.files.is_empty() { @@ -476,7 +480,7 @@ pub struct ContractInfo { /// **Note:** this expects the `target_path` to be absolute pub fn compile_target( target_path: &Path, - project: &Project, + project: &Project, quiet: bool, ) -> Result> { ProjectCompiler::::new().quiet(quiet).files([target_path.into()]).compile(project) @@ -585,6 +589,28 @@ impl FileFilter for SkipBuildFilters { } } +impl FileFilter for &SkipBuildFilters { + fn is_match(&self, file: &Path) -> bool { + (*self).is_match(file) + } +} + +impl SparseOutputFileFilter for SkipBuildFilters { + fn sparse_sources(&self, file: &Path, graph: &GraphEdges) -> Vec { + SolcSparseFileFilter::new(self).sparse_sources(file, graph) + } +} + +impl SparseOutputFileFilter for SkipBuildFilters { + fn sparse_sources(&self, file: &Path, _graph: &GraphEdges) -> Vec { + if self.is_match(file) { + vec![file.to_path_buf()] + } else { + vec![] + } + } +} + impl SkipBuildFilters { /// Creates a new `SkipBuildFilters` from multiple `SkipBuildFilter`. pub fn new( diff --git a/crates/config/src/language.rs b/crates/config/src/language.rs new file mode 100644 index 0000000000000..dd1105e2d307e --- /dev/null +++ b/crates/config/src/language.rs @@ -0,0 +1,39 @@ +use serde::{Deserialize, Serialize}; +use std::str::FromStr; + +/// Compilers supported by foundry. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub enum Language { + /// Solidity + Solidity, + /// Vyper + Vyper, +} + +impl Language { + /// Returns the language name as a string. + pub const fn as_str(&self) -> &'static str { + match self { + Self::Solidity => "solidity", + Self::Vyper => "vyper", + } + } +} + +impl std::fmt::Display for Language { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl FromStr for Language { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "solidity" => Ok(Self::Solidity), + "vyper" => Ok(Self::Vyper), + s => Err(format!("Unknown language: {s}")), + } + } +} diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index e48f8d571e055..aff1ec88b3a0b 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -15,16 +15,21 @@ use figment::{ }; use foundry_compilers::{ artifacts::{ - output_selection::ContractOutputSelection, serde_helpers, BytecodeHash, DebuggingSettings, - Libraries, ModelCheckerSettings, ModelCheckerTarget, Optimizer, OptimizerDetails, - RevertStrings, Settings, SettingsMetadata, Severity, + output_selection::{ContractOutputSelection, OutputSelection}, + serde_helpers, BytecodeHash, DebuggingSettings, Libraries, ModelCheckerSettings, + ModelCheckerTarget, Optimizer, OptimizerDetails, RevertStrings, Settings, SettingsMetadata, + Severity, }, cache::SOLIDITY_FILES_CACHE_FILENAME, - compilers::{solc::SolcVersionManager, CompilerVersionManager}, + compilers::{ + solc::SolcVersionManager, + vyper::{Vyper, VyperSettings}, + Compiler, CompilerVersionManager, + }, error::SolcError, remappings::{RelativeRemapping, Remapping}, - CompilerConfig, ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, - SolcConfig, + CompilerConfig, ConfigurableArtifacts, EvmVersion, Project, ProjectBuilder, ProjectPathsConfig, + Solc, SolcConfig, }; use inflector::Inflector; use regex::Regex; @@ -82,6 +87,10 @@ pub use figment; /// config providers pub mod providers; +/// compilers supported by foundry +pub mod language; +pub use language::Language; + use crate::{ error::ExtractConfigError, etherscan::{EtherscanConfigError, EtherscanConfigs, ResolvedEtherscanConfig}, @@ -397,6 +406,10 @@ pub struct Config { /// CREATE2 salt to use for the library deployment in scripts. pub create2_library_salt: B256, + /// Compiler to use + #[serde(with = "from_str_lowercase")] + pub lang: Language, + /// The root path where the config detection started from, `Config::with_root` #[doc(hidden)] // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] @@ -757,6 +770,11 @@ impl Config { self.create_project(self.cache, false) } + /// Configures [Project] with [Vyper] compiler. + pub fn vyper_project(&self) -> Result, SolcError> { + self.create_vyper_project(self.cache, false) + } + /// Same as [`Self::project()`] but sets configures the project to not emit artifacts and ignore /// cache. pub fn ephemeral_no_artifacts_project(&self) -> Result { @@ -765,10 +783,38 @@ impl Config { /// Creates a [Project] with the given `cached` and `no_artifacts` flags pub fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { - let project = Project::builder() + let compiler_config = self.solc_config()?; + let settings = SolcConfig::builder().settings(self.solc_settings()?).build().settings; + + self.create_project_with_compiler(cached, no_artifacts, compiler_config, settings) + } + + /// Creates a [Project] with the given `cached` and `no_artifacts` flags + pub fn create_vyper_project( + &self, + cached: bool, + no_artifacts: bool, + ) -> Result, SolcError> { + self.create_project_with_compiler( + cached, + no_artifacts, + self.vyper_config()?, + self.vyper_settings()?, + ) + } + + /// Creates a [Project] with a given [CompilerConfig]. + pub fn create_project_with_compiler( + &self, + cached: bool, + no_artifacts: bool, + compiler_config: CompilerConfig, + settings: C::Settings, + ) -> Result, SolcError> { + let project = ProjectBuilder::::new(Default::default()) .artifacts(self.configured_artifacts_handler()) .paths(self.project_paths()) - .settings(SolcConfig::builder().settings(self.solc_settings()?).build().settings) + .settings(settings) .ignore_error_codes(self.ignored_error_codes.iter().copied().map(Into::into)) .ignore_paths(self.ignored_file_paths.clone()) .set_compiler_severity_filter(if self.deny_warnings { @@ -780,7 +826,7 @@ impl Config { .set_cached(cached && !self.build_info) .set_build_info(!no_artifacts && self.build_info) .set_no_artifacts(no_artifacts) - .build(self.compiler_config()?)?; + .build(compiler_config)?; if self.force { self.cleanup(&project)?; @@ -790,7 +836,7 @@ impl Config { } /// Cleans the project. - pub fn cleanup(&self, project: &Project) -> Result<(), SolcError> { + pub fn cleanup(&self, project: &Project) -> Result<(), SolcError> { project.cleanup()?; // Remove fuzz and invariant cache directories. @@ -830,15 +876,7 @@ impl Config { version_manager.install(version)? } } - SolcReq::Local(solc) => { - if !solc.is_file() { - return Err(SolcError::msg(format!( - "`solc` {} does not exist", - solc.display() - ))) - } - Solc::new(solc)? - } + SolcReq::Local(solc) => Solc::new(solc)?, }; return Ok(Some(solc)) } @@ -881,11 +919,12 @@ impl Config { /// # Example /// /// ``` + /// use foundry_compilers::Solc; /// use foundry_config::Config; /// let config = Config::load_with_root(".").sanitized(); - /// let paths = config.project_paths(); + /// let paths = config.project_paths::(); /// ``` - pub fn project_paths(&self) -> ProjectPathsConfig { + pub fn project_paths(&self) -> ProjectPathsConfig { let mut builder = ProjectPathsConfig::builder() .cache(self.cache_path.join(SOLIDITY_FILES_CACHE_FILENAME)) .sources(&self.src) @@ -907,7 +946,7 @@ impl Config { } /// Returns configuration for a compiler to use when setting up a [Project]. - pub fn compiler_config(&self) -> Result, SolcError> { + pub fn solc_config(&self) -> Result, SolcError> { if let Some(solc) = self.ensure_solc()? { Ok(CompilerConfig::Specific(solc)) } else { @@ -915,6 +954,15 @@ impl Config { } } + /// Returns configuration for a compiler to use when setting up a [Project]. + pub fn vyper_config(&self) -> Result, SolcError> { + if let Some(SolcReq::Local(path)) = &self.solc { + Ok(CompilerConfig::Specific(Vyper::new(path)?)) + } else { + Ok(CompilerConfig::Specific(Vyper::new("vyper")?)) + } + } + /// Returns all configured [`Remappings`] /// /// **Note:** this will add an additional `/=` remapping here, see @@ -1237,6 +1285,23 @@ impl Config { Ok(settings) } + /// Returns the configured [VyperSettings] that includes: + /// - evm version + pub fn vyper_settings(&self) -> Result { + Ok(VyperSettings { + evm_version: Some(self.evm_version), + optimize: None, + bytecode_metadata: None, + // TODO: We don't yet have a way to deserialize other outputs correctly, so request only + // those for now. It should be enough to run tests and deploy contracts. + output_selection: OutputSelection::common_output_selection([ + "abi".to_string(), + "evm.bytecode".to_string(), + "evm.deployedBytecode".to_string(), + ]), + }) + } + /// Returns the default figment /// /// The default figment reads from the following sources, in ascending @@ -2017,6 +2082,7 @@ impl Default for Config { labels: Default::default(), unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, + lang: Language::Solidity, __non_exhaustive: (), __warnings: vec![], } @@ -2709,6 +2775,23 @@ fn canonic(path: impl Into) -> PathBuf { foundry_compilers::utils::canonicalize(&path).unwrap_or(path) } +/// Executes the given closure with a [Project] configured via the given [Config]. +#[macro_export] +macro_rules! with_resolved_project { + ($config:ident, |$prj:ident| $e:expr) => { + match $config.lang { + foundry_config::Language::Solidity => { + let $prj = $config.project(); + $e + } + foundry_config::Language::Vyper => { + let $prj = $config.vyper_project(); + $e + } + } + }; +} + #[cfg(test)] mod tests { use super::*; @@ -2849,7 +2932,7 @@ mod tests { fn test_default_test_path() { figment::Jail::expect_with(|_| { let config = Config::default(); - let paths_config = config.project_paths(); + let paths_config = config.project_paths::(); assert_eq!(paths_config.tests, PathBuf::from(r"test")); Ok(()) }); @@ -2916,7 +2999,7 @@ mod tests { )?; let config = Config::load(); - let paths_config = config.project_paths(); + let paths_config = config.project_paths::(); assert_eq!(paths_config.tests, PathBuf::from(r"mytest")); Ok(()) }); diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 673198fdc80ff..c4bbbb8a21b3e 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -3,7 +3,9 @@ use clap::Parser; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}; -use foundry_compilers::{Project, ProjectCompileOutput, SolcSparseFileFilter}; +use foundry_compilers::{ + compilers::Compiler, Project, ProjectCompileOutput, SparseOutputFileFilter, +}; use foundry_config::{ figment::{ self, @@ -11,7 +13,7 @@ use foundry_config::{ value::{Dict, Map, Value}, Metadata, Profile, Provider, }, - Config, + with_resolved_project, Config, }; use serde::Serialize; use watchexec::config::{InitConfig, RuntimeConfig}; @@ -75,32 +77,54 @@ pub struct BuildArgs { } impl BuildArgs { - pub fn run(self) -> Result { + pub fn run(self) -> Result<()> { let mut config = self.try_load_config_emit_warnings()?; - let mut project = config.project()?; if install::install_missing_dependencies(&mut config, self.args.silent) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings config = self.load_config(); - project = config.project()?; } + with_resolved_project!(config, |project| { + let project = project?; + + let filter = if let Some(ref skip) = self.skip { + if !skip.is_empty() { + let filter = SkipBuildFilters::new(skip.clone(), project.root().clone())?; + Some(filter) + } else { + None + } + } else { + None + }; + + self.run_with_project(project, filter)?; + }); + + Ok(()) + } + + pub fn run_with_project( + &self, + project: Project, + filter: Option + 'static>, + ) -> Result> + where + C::CompilationError: Clone, + { let mut compiler = ProjectCompiler::new() .print_names(self.names) .print_sizes(self.sizes) .quiet(self.format_json) .bail(!self.format_json); - if let Some(skip) = self.skip { - if !skip.is_empty() { - let filter = SolcSparseFileFilter::new(SkipBuildFilters::new( - skip.clone(), - project.root().to_path_buf(), - )?); - compiler = compiler.filter(Box::new(filter)); - } + + if let Some(filter) = filter { + compiler = compiler.filter(Box::new(filter)); } + let output = compiler.compile(&project)?; if self.format_json { diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 380aa4927c061..89765e9dad406 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -88,7 +88,7 @@ impl CoverageArgs { let (project, output) = self.build(&config)?; p_println!(!self.test.build_args().silent => "Analysing contracts..."); - let report = self.prepare(&config, output.clone())?; + let report = self.prepare(&project, output.clone())?; p_println!(!self.test.build_args().silent => "Running tests..."); self.collect(project, output, report, Arc::new(config), evm_opts).await @@ -141,8 +141,8 @@ impl CoverageArgs { /// Builds the coverage report. #[instrument(name = "prepare", skip_all)] - fn prepare(&self, config: &Config, output: ProjectCompileOutput) -> Result { - let project_paths = config.project_paths(); + fn prepare(&self, project: &Project, output: ProjectCompileOutput) -> Result { + let project_paths = &project.paths; // Extract artifacts let (artifacts, sources) = output.into_artifacts_with_sources(); diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index 30de31e5a2031..e561dcc5cc4f2 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -95,8 +95,8 @@ impl DocArgs { let mut builder = DocBuilder::new( root.clone(), - config.project_paths().sources, - config.project_paths().libraries, + project.paths.sources, + project.paths.libraries, self.include_libraries, ) .with_should_build(self.build) diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 6ff5387faef57..71ac7ceb00836 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -3,7 +3,7 @@ use eyre::Result; use forge_fmt::{format_to, parse, print_diagnostics_report}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; use foundry_common::{fs, glob::expand_globs, term::cli_warn}; -use foundry_compilers::SOLC_EXTENSIONS; +use foundry_compilers::{Solc, SOLC_EXTENSIONS}; use foundry_config::impl_figment_convert_basic; use rayon::prelude::*; use similar::{ChangeTag, TextDiff}; @@ -60,7 +60,7 @@ impl FmtArgs { [] => { // Retrieve the project paths, and filter out the ignored ones. let project_paths: Vec = config - .project_paths() + .project_paths::() .input_files_iter() .filter(|p| !(ignored.contains(p) || ignored.contains(&cwd.join(p)))) .collect(); diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 451c29dbd7924..0b08f2d0d76ef 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -1,7 +1,7 @@ use clap::{Parser, ValueHint}; use eyre::{Result, WrapErr}; use foundry_cli::utils::LoadConfig; -use foundry_compilers::{resolver::parse::SolData, Graph}; +use foundry_compilers::{resolver::parse::SolData, Graph, Solc}; use foundry_config::{impl_figment_convert_basic, Config}; use itertools::Itertools; use rayon::prelude::*; @@ -62,7 +62,7 @@ impl GeigerArgs { let mut sources: Vec = { if self.paths.is_empty() { - Graph::::resolve(&config.project_paths())? + Graph::::resolve(&config.project_paths::())? .files() .keys() .cloned() diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index 088975d8752e5..e2f958034f1b5 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -3,7 +3,7 @@ use eyre::Result; use foundry_cli::{opts::ProjectPathsArgs, utils::LoadConfig}; use foundry_compilers::{ resolver::{parse::SolData, Charset, TreeOptions}, - Graph, + Graph, Solc, }; /// CLI arguments for `forge tree`. @@ -28,7 +28,7 @@ foundry_config::impl_figment_convert!(TreeArgs, opts); impl TreeArgs { pub fn run(self) -> Result<()> { let config = self.try_load_config_emit_warnings()?; - let graph = Graph::::resolve(&config.project_paths())?; + let graph = Graph::::resolve(&config.project_paths::())?; let opts = TreeOptions { charset: self.charset, no_dedupe: self.no_dedupe }; graph.print_with_options(opts); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 1e4f773882953..3653a0e3f064b 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -5,7 +5,7 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput}; +use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput, Solc}; use foundry_config::Config; use foundry_evm::{ backend::Backend, decode::RevertDecoder, executors::ExecutorBuilder, fork::CreateFork, @@ -181,8 +181,10 @@ impl MultiContractRunner { let identifier = artifact_id.identifier(); let mut span_name = identifier.as_str(); - let linker = - Linker::new(self.config.project_paths().root, self.output.artifact_ids().collect()); + let linker = Linker::new( + self.config.project_paths::().root, + self.output.artifact_ids().collect(), + ); let linked_contracts = linker.get_linked_artifacts(&contract.libraries).unwrap_or_default(); let known_contracts = Arc::new(ContractsByArtifact::new(linked_contracts)); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index aec3b6dc21d7e..54e7caff75118 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -9,7 +9,7 @@ use foundry_compilers::{ use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, fs_permissions::{FsAccessPermission, PathPermission}, - Config, FsPermissions, FuzzConfig, InvariantConfig, SolcReq, + Config, FsPermissions, FuzzConfig, InvariantConfig, Language, SolcReq, }; use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ @@ -135,6 +135,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { isolate: true, unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, + lang: Language::Solidity, __non_exhaustive: (), __warnings: vec![], }; @@ -361,7 +362,9 @@ contract Foo {} // fails to use solc that does not exist cmd.forge_fuse().args(["build", "--use", "this/solc/does/not/exist"]); - assert!(cmd.stderr_lossy().contains("this/solc/does/not/exist does not exist")); + assert!(cmd + .stderr_lossy() + .contains(r#""this/solc/does/not/exist": No such file or directory"#)); // `OTHER_SOLC_VERSION` was installed in previous step, so we can use the path to this directly let local_solc = diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index be7e13af1ec08..cba0104a79af0 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -5,7 +5,7 @@ use foundry_compilers::{ cache::CompilerCache, error::Result as SolcResult, project_util::{copy_dir, TempProject}, - ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, + ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, Solc, }; use foundry_config::Config; use once_cell::sync::Lazy; @@ -408,7 +408,7 @@ pub struct TestProject { /// The directory in which this test executable is running. exe_root: PathBuf, /// The project in which the test should run. - inner: Arc>, + inner: Arc>, } impl TestProject { From f8ad354e9d61933d5ed8f299b88d724043440448 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Date: Thu, 23 May 2024 21:05:35 +0200 Subject: [PATCH 0986/1963] feat: add tmp prague config value (#7697) --- crates/config/src/lib.rs | 15 ++++++++++++--- crates/forge/tests/cli/config.rs | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index aff1ec88b3a0b..d57dc68a6f91e 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -388,6 +388,11 @@ pub struct Config { /// Should be removed once EvmVersion Cancun is supported by solc pub cancun: bool, + /// Temporary config to enable [SpecId::PRAGUE] + /// + /// Should be removed once EvmVersion Prague is supported by solc + pub prague: bool, + /// Whether to enable call isolation. /// /// Useful for more correct gas accounting and EVM behavior in general. @@ -890,6 +895,9 @@ impl Config { if self.cancun { return SpecId::CANCUN } + if self.prague { + return SpecId::PRAGUE + } evm_spec_id(&self.evm_version) } @@ -1993,6 +2001,7 @@ impl Default for Config { profile: Self::DEFAULT_PROFILE, fs_permissions: FsPermissions::new([PathPermission::read("out")]), cancun: false, + prague: false, isolate: false, __root: Default::default(), src: "src".into(), @@ -2966,7 +2975,7 @@ mod tests { test = "defaulttest" src = "defaultsrc" libs = ['lib', 'node_modules'] - + [profile.custom] src = "customsrc" "#, @@ -3788,7 +3797,7 @@ mod tests { tx_origin = '0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38' verbosity = 0 via_ir = false - + [profile.default.rpc_storage_caching] chains = 'all' endpoints = 'all' @@ -4256,7 +4265,7 @@ mod tests { './src/SizeAuction.sol:Math:0x902f6cf364b8d9470d5793a9b2b2e86bddd21e0c', './src/test/ChainlinkTWAP.t.sol:ChainlinkTWAP:0xffedba5e171c4f15abaaabc86e8bd01f9b54dae5', './src/SizeAuctionDiscount.sol:Math:0x902f6cf364b8d9470d5793a9b2b2e86bddd21e0c', - ] + ] ", )?; let config = Config::load(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 54e7caff75118..a00a50ba42ceb 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -132,6 +132,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { fs_permissions: Default::default(), labels: Default::default(), cancun: true, + prague: true, isolate: true, unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, From f4102c1458fe6cf5223a5018591f58b8dd4763e6 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 23 May 2024 23:01:33 +0200 Subject: [PATCH 0987/1963] chore: remove cancun setting (#7977) --- crates/config/src/lib.rs | 10 ---------- crates/forge/tests/cli/config.rs | 1 - 2 files changed, 11 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d57dc68a6f91e..4b622662a24e0 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -382,12 +382,6 @@ pub struct Config { /// This includes what operations can be executed (read, write) pub fs_permissions: FsPermissions, - /// Temporary config to enable [SpecId::CANCUN] - /// - /// - /// Should be removed once EvmVersion Cancun is supported by solc - pub cancun: bool, - /// Temporary config to enable [SpecId::PRAGUE] /// /// Should be removed once EvmVersion Prague is supported by solc @@ -892,9 +886,6 @@ impl Config { /// Returns the [SpecId] derived from the configured [EvmVersion] #[inline] pub fn evm_spec_id(&self) -> SpecId { - if self.cancun { - return SpecId::CANCUN - } if self.prague { return SpecId::PRAGUE } @@ -2000,7 +1991,6 @@ impl Default for Config { Self { profile: Self::DEFAULT_PROFILE, fs_permissions: FsPermissions::new([PathPermission::read("out")]), - cancun: false, prague: false, isolate: false, __root: Default::default(), diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index a00a50ba42ceb..d439cf68d3c54 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -131,7 +131,6 @@ forgetest!(can_extract_config_values, |prj, cmd| { doc: Default::default(), fs_permissions: Default::default(), labels: Default::default(), - cancun: true, prague: true, isolate: true, unchecked_cheatcode_artifacts: false, From 2b5af1b07d439fc46a9ef0d34711afedef5a573d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 May 2024 00:20:10 +0300 Subject: [PATCH 0988/1963] chore: make aws-kms signer support optional (#7976) --- Cargo.lock | 49 ----------------------------- crates/cast/Cargo.toml | 5 +-- crates/wallets/Cargo.toml | 10 +++--- crates/wallets/src/error.rs | 15 +++++++-- crates/wallets/src/multi_wallet.rs | 2 ++ crates/wallets/src/wallet.rs | 2 +- crates/wallets/src/wallet_signer.rs | 24 ++++++++++---- 7 files changed, 42 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1496b337910ba..131c6351dfee6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1103,8 +1103,6 @@ checksum = "40ddbfb5db93d62521f47b3f223da0884a2f02741ff54cb9cda192a0e73ba08b" dependencies = [ "aws-credential-types", "aws-runtime", - "aws-sdk-sso", - "aws-sdk-ssooidc", "aws-sdk-sts", "aws-smithy-async", "aws-smithy-http", @@ -1115,15 +1113,12 @@ dependencies = [ "aws-types", "bytes", "fastrand", - "hex", "http 0.2.12", "hyper 0.14.28", - "ring", "time", "tokio", "tracing", "url", - "zeroize", ] [[package]] @@ -1183,50 +1178,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "aws-sdk-sso" -version = "1.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fef2d9ca2b43051224ed326ed9960a85e277b7d554a2cd0397e57c0553d86e64" -dependencies = [ - "aws-credential-types", - "aws-runtime", - "aws-smithy-async", - "aws-smithy-http", - "aws-smithy-json", - "aws-smithy-runtime", - "aws-smithy-runtime-api", - "aws-smithy-types", - "aws-types", - "bytes", - "http 0.2.12", - "once_cell", - "regex-lite", - "tracing", -] - -[[package]] -name = "aws-sdk-ssooidc" -version = "1.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c869d1f5c4ee7437b79c3c1664ddbf7a60231e893960cf82b2b299a5ccf2cc5d" -dependencies = [ - "aws-credential-types", - "aws-runtime", - "aws-smithy-async", - "aws-smithy-http", - "aws-smithy-json", - "aws-smithy-runtime", - "aws-smithy-runtime-api", - "aws-smithy-types", - "aws-types", - "bytes", - "http 0.2.12", - "once_cell", - "regex-lite", - "tracing", -] - [[package]] name = "aws-sdk-sts" version = "1.25.0" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index d6837b17622be..bf180b9b5598b 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -52,8 +52,8 @@ rayon = "1" serde_json.workspace = true serde.workspace = true -# aws -aws-sdk-kms = { version = "1", default-features = false } +# aws-kms +aws-sdk-kms = { version = "1", default-features = false, optional = true } # bin foundry-cli.workspace = true @@ -88,6 +88,7 @@ rustls = ["foundry-cli/rustls", "foundry-wallets/rustls"] openssl = ["foundry-cli/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] +aws-kms = ["foundry-wallets/aws-kms", "dep:aws-sdk-kms"] [[bench]] name = "vanity" diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index a0495c51d169f..c7c4038cdee13 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -13,7 +13,6 @@ repository.workspace = true alloy-primitives.workspace = true alloy-signer = { workspace = true, features = ["eip712"] } alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } -alloy-signer-aws = { workspace = true, features = ["eip712"] } alloy-signer-ledger = { workspace = true, features = ["eip712"] } alloy-signer-trezor.workspace = true alloy-network.workspace = true @@ -21,8 +20,10 @@ alloy-consensus.workspace = true alloy-sol-types.workspace = true alloy-dyn-abi.workspace = true -aws-sdk-kms = { version = "1", default-features = false } -aws-config = "1" +# aws-kms +alloy-signer-aws = { workspace = true, features = ["eip712"], optional = true } +aws-config = { version = "1", default-features = false, optional = true } +aws-sdk-kms = { version = "1", default-features = false, optional = true } foundry-config.workspace = true foundry-common.workspace = true @@ -43,4 +44,5 @@ tokio = { workspace = true, features = ["macros"] } [features] default = ["rustls"] -rustls = ["aws-sdk-kms/rustls"] +rustls = ["aws-sdk-kms?/rustls"] +aws-kms = ["dep:alloy-signer-aws", "dep:aws-config", "dep:aws-sdk-kms"] diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index b9a5e34f592ab..8b341cc3d5a98 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -1,10 +1,12 @@ use alloy_signer::k256::ecdsa; -use alloy_signer_aws::AwsSignerError; use alloy_signer_ledger::LedgerError; use alloy_signer_trezor::TrezorError; use alloy_signer_wallet::WalletError; use hex::FromHexError; +#[cfg(feature = "aws-kms")] +use alloy_signer_aws::AwsSignerError; + #[derive(Debug, thiserror::Error)] pub enum PrivateKeyError { #[error("Failed to create wallet from private key. Private key is invalid hex: {0}")] @@ -22,6 +24,7 @@ pub enum WalletSignerError { #[error(transparent)] Trezor(#[from] TrezorError), #[error(transparent)] + #[cfg(feature = "aws-kms")] Aws(#[from] AwsSignerError), #[error(transparent)] Io(#[from] std::io::Error), @@ -29,6 +32,12 @@ pub enum WalletSignerError { InvalidHex(#[from] FromHexError), #[error(transparent)] Ecdsa(#[from] ecdsa::Error), - #[error("{0} cannot sign raw hashes")] - CannotSignRawHash(&'static str), + #[error("foundry was not built with support for {0} signer")] + UnsupportedSigner(&'static str), +} + +impl WalletSignerError { + pub fn aws_unsupported() -> Self { + WalletSignerError::UnsupportedSigner("AWS KMS") + } } diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index c95bb8d0e2ae0..7dc78c48e37f5 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -375,6 +375,7 @@ impl MultiWalletOpts { } pub async fn aws_signers(&self) -> Result>> { + #[cfg(feature = "aws-kms")] if self.aws { let mut wallets = vec![]; let aws_keys = std::env::var("AWS_KMS_KEY_IDS") @@ -390,6 +391,7 @@ impl MultiWalletOpts { return Ok(Some(wallets)); } + Ok(None) } } diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 5773e57d80b6c..b2a188b915083 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -78,7 +78,7 @@ pub struct WalletOpts { pub trezor: bool, /// Use AWS Key Management Service. - #[arg(long, help_heading = "Wallet options - AWS KMS")] + #[arg(long, help_heading = "Wallet options - AWS KMS", hide = !cfg!(feature = "aws-kms"))] pub aws: bool, } diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index 7b1f698b72bd3..15e450289c6e2 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -4,16 +4,16 @@ use alloy_dyn_abi::TypedData; use alloy_network::TxSigner; use alloy_primitives::{Address, ChainId, B256}; use alloy_signer::{Signature, Signer}; -use alloy_signer_aws::AwsSigner; use alloy_signer_ledger::{HDPath as LedgerHDPath, LedgerSigner}; use alloy_signer_trezor::{HDPath as TrezorHDPath, TrezorSigner}; use alloy_signer_wallet::{coins_bip39::English, LocalWallet, MnemonicBuilder}; use alloy_sol_types::{Eip712Domain, SolStruct}; use async_trait::async_trait; -use aws_config::BehaviorVersion; -use aws_sdk_kms::Client as AwsClient; use std::path::PathBuf; +#[cfg(feature = "aws-kms")] +use {alloy_signer_aws::AwsSigner, aws_config::BehaviorVersion, aws_sdk_kms::Client as AwsClient}; + pub type Result = std::result::Result; /// Wrapper enum around different signers. @@ -26,6 +26,7 @@ pub enum WalletSigner { /// Wrapper around Trezor signer. Trezor(TrezorSigner), /// Wrapper around AWS KMS signer. + #[cfg(feature = "aws-kms")] Aws(AwsSigner), } @@ -41,10 +42,19 @@ impl WalletSigner { } pub async fn from_aws(key_id: String) -> Result { - let config = aws_config::load_defaults(BehaviorVersion::latest()).await; - let client = AwsClient::new(&config); + #[cfg(feature = "aws-kms")] + { + let config = aws_config::load_defaults(BehaviorVersion::latest()).await; + let client = AwsClient::new(&config); + + Ok(Self::Aws(AwsSigner::new(client, key_id, None).await?)) + } - Ok(Self::Aws(AwsSigner::new(client, key_id, None).await?)) + #[cfg(not(feature = "aws-kms"))] + { + let _ = key_id; + Err(WalletSignerError::aws_unsupported()) + } } pub fn from_private_key(private_key: impl AsRef<[u8]>) -> Result { @@ -89,6 +99,7 @@ impl WalletSigner { } } } + #[cfg(feature = "aws-kms")] WalletSigner::Aws(aws) => { senders.push(alloy_signer::Signer::address(aws)); } @@ -124,6 +135,7 @@ macro_rules! delegate { Self::Local($inner) => $e, Self::Ledger($inner) => $e, Self::Trezor($inner) => $e, + #[cfg(feature = "aws-kms")] Self::Aws($inner) => $e, } }; From 30c93a22e359b9b4df11e29e921c1a781eeaf37e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 May 2024 00:44:12 +0300 Subject: [PATCH 0989/1963] fix(config): deprecated key warnings (#7978) --- crates/config/src/providers/mod.rs | 58 +++++++++++++++++------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/crates/config/src/providers/mod.rs b/crates/config/src/providers/mod.rs index 239ee0c74a36b..9dbbf38eaaa47 100644 --- a/crates/config/src/providers/mod.rs +++ b/crates/config/src/providers/mod.rs @@ -3,6 +3,7 @@ use figment::{ value::{Dict, Map, Value}, Error, Figment, Metadata, Profile, Provider, }; +use std::collections::BTreeMap; /// Remappings provider pub mod remappings; @@ -43,15 +44,15 @@ impl

WarningsProvider

{ impl WarningsProvider

{ /// Collects all warnings. pub fn collect_warnings(&self) -> Result, Error> { + let data = self.provider.data().unwrap_or_default(); + let mut out = self.old_warnings.clone()?; - // add warning for unknown sections + + // Add warning for unknown sections. out.extend( - self.provider - .data() - .unwrap_or_default() - .keys() + data.keys() .filter(|k| { - k != &Config::PROFILE_SECTION && + **k != Config::PROFILE_SECTION && !Config::STANDALONE_SECTIONS.iter().any(|s| s == k) }) .map(|unknown_section| { @@ -59,26 +60,33 @@ impl WarningsProvider

{ Warning::UnknownSection { unknown_section: unknown_section.clone(), source } }), ); - // add warning for deprecated keys - out.extend( - self.provider - .data() - .unwrap_or_default() - .iter() - .flat_map(|(profile, dict)| dict.keys().map(move |key| format!("{profile}.{key}"))) - .filter_map(|key| { - DEPRECATIONS.iter().find_map(|(deprecated_key, new_value)| { - if key == *deprecated_key { - Some(Warning::DeprecatedKey { - old: deprecated_key.to_string(), - new: new_value.to_string(), - }) - } else { - None - } + + // Add warning for deprecated keys. + let deprecated_key_warning = |key| { + DEPRECATIONS.iter().find_map(|(deprecated_key, new_value)| { + if key == *deprecated_key { + Some(Warning::DeprecatedKey { + old: deprecated_key.to_string(), + new: new_value.to_string(), }) - }), + } else { + None + } + }) + }; + let profiles = data + .iter() + .filter(|(profile, _)| **profile == Config::PROFILE_SECTION) + .map(|(_, dict)| dict); + out.extend(profiles.clone().flat_map(BTreeMap::keys).filter_map(deprecated_key_warning)); + out.extend( + profiles + .filter_map(|dict| dict.get(self.profile.as_str().as_str())) + .filter_map(Value::as_dict) + .flat_map(BTreeMap::keys) + .filter_map(deprecated_key_warning), ); + Ok(out) } } @@ -91,6 +99,7 @@ impl Provider for WarningsProvider

{ Metadata::named("Warnings") } } + fn data(&self) -> Result, Error> { Ok(Map::from([( self.profile.clone(), @@ -100,6 +109,7 @@ impl Provider for WarningsProvider

{ )]), )])) } + fn profile(&self) -> Option { Some(self.profile.clone()) } From b1f4684d5bdcfc9eb777256633af523f7eed1cd7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 May 2024 01:11:01 +0300 Subject: [PATCH 0990/1963] chore: hide aws flags when not enabled (#7979) --- crates/cast/bin/cmd/wallet/list.rs | 2 +- crates/wallets/src/multi_wallet.rs | 2 +- crates/wallets/src/wallet.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/list.rs b/crates/cast/bin/cmd/wallet/list.rs index e534d5713088f..88b9486058294 100644 --- a/crates/cast/bin/cmd/wallet/list.rs +++ b/crates/cast/bin/cmd/wallet/list.rs @@ -22,7 +22,7 @@ pub struct ListArgs { trezor: bool, /// List accounts from AWS KMS. - #[arg(long)] + #[arg(long, hide = !cfg!(feature = "aws-kms"))] aws: bool, /// List all configured accounts. diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index 7dc78c48e37f5..459074aaa5848 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -219,7 +219,7 @@ pub struct MultiWalletOpts { pub trezor: bool, /// Use AWS Key Management Service. - #[arg(long, help_heading = "Wallet options - remote")] + #[arg(long, help_heading = "Wallet options - remote", hide = !cfg!(feature = "aws-kms"))] pub aws: bool, } diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index b2a188b915083..5b984d70120a8 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -78,7 +78,7 @@ pub struct WalletOpts { pub trezor: bool, /// Use AWS Key Management Service. - #[arg(long, help_heading = "Wallet options - AWS KMS", hide = !cfg!(feature = "aws-kms"))] + #[arg(long, help_heading = "Wallet options - remote", hide = !cfg!(feature = "aws-kms"))] pub aws: bool, } From fecac4c49a6eefe678ce7b290e55d5dc2ed5db44 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 24 May 2024 10:24:32 +0300 Subject: [PATCH 0991/1963] fix: unchecked getCode (#7982) * fix: unchecked getCode * fix windows test * fix --- crates/cheatcodes/src/fs.rs | 29 ++++++++++++++++------------- crates/config/src/lib.rs | 10 +++++++++- crates/forge/tests/cli/config.rs | 4 +--- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 33e29475c370e..308d866413061 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -364,19 +364,22 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result { - PathBuf::from(format!("{file}/{contract_name}.json")) - } - (None, Some(contract_name)) => { - PathBuf::from(format!("{contract_name}.sol/{contract_name}.json")) - } - (Some(file), None) => { - let name = file.replace(".sol", ""); - PathBuf::from(format!("{file}/{name}.json")) - } - _ => return Err(fmt_err!("Invalid artifact path")), - } + let path_in_artifacts = + match (file.map(|f| f.to_string_lossy().to_string()), contract_name) { + (Some(file), Some(contract_name)) => { + PathBuf::from(format!("{file}/{contract_name}.json")) + } + (None, Some(contract_name)) => { + PathBuf::from(format!("{contract_name}.sol/{contract_name}.json")) + } + (Some(file), None) => { + let name = file.replace(".sol", ""); + PathBuf::from(format!("{file}/{name}.json")) + } + _ => return Err(fmt_err!("Invalid artifact path")), + }; + + state.config.paths.artifacts.join(path_in_artifacts) } }; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 4b622662a24e0..ec2118c16696a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -875,7 +875,15 @@ impl Config { version_manager.install(version)? } } - SolcReq::Local(solc) => Solc::new(solc)?, + SolcReq::Local(solc) => { + if !solc.is_file() { + return Err(SolcError::msg(format!( + "`solc` {} does not exist", + solc.display() + ))) + } + Solc::new(solc)? + } }; return Ok(Some(solc)) } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index d439cf68d3c54..f463a437e3f80 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -362,9 +362,7 @@ contract Foo {} // fails to use solc that does not exist cmd.forge_fuse().args(["build", "--use", "this/solc/does/not/exist"]); - assert!(cmd - .stderr_lossy() - .contains(r#""this/solc/does/not/exist": No such file or directory"#)); + assert!(cmd.stderr_lossy().contains("`solc` this/solc/does/not/exist does not exist")); // `OTHER_SOLC_VERSION` was installed in previous step, so we can use the path to this directly let local_solc = From 31c13dce772cccb4d4b7adfb2f366c9d8276ebc5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 24 May 2024 13:03:31 +0300 Subject: [PATCH 0992/1963] fix(forge): load state on roll fork for non persisting accounts (#7983) * fix(forge): load state on roll fork for non persisting accounts * Add roll fork invariant test * Nested is_created check --- crates/evm/core/src/backend/mod.rs | 22 +++++++---- crates/forge/tests/it/invariant.rs | 37 +++++++++++++++++++ crates/forge/tests/it/repros.rs | 3 ++ .../invariant/common/InvariantRollFork.t.sol | 29 +++++++++++++++ testdata/default/repros/Issue5739.t.sol | 35 ++++++++++++++++++ 5 files changed, 118 insertions(+), 8 deletions(-) create mode 100644 testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol create mode 100644 testdata/default/repros/Issue5739.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index baeb1145b0d80..88a4b060adb62 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1176,16 +1176,22 @@ impl DatabaseExt for Backend { merge_journaled_state_data(addr, journaled_state, &mut active.journaled_state); } - // ensure all previously loaded accounts are present in the journaled state to + // Ensure all previously loaded accounts are present in the journaled state to // prevent issues in the new journalstate, e.g. assumptions that accounts are loaded - // if the account is not touched, we reload it, if it's touched we clone it + // if the account is not touched, we reload it, if it's touched we clone it. + // + // Special case for accounts that are not created: we don't merge their state but + // load it in order to reflect their state at the new block (they should explicitly + // be marked as persistent if it is desired to keep state between fork rolls). for (addr, acc) in journaled_state.state.iter() { - if acc.is_touched() { - merge_journaled_state_data( - *addr, - journaled_state, - &mut active.journaled_state, - ); + if acc.is_created() { + if acc.is_touched() { + merge_journaled_state_data( + *addr, + journaled_state, + &mut active.journaled_state, + ); + } } else { let _ = active.journaled_state.load_account(*addr, &mut active.db); } diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index abdd6591a490d..62e76c274be6e 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -219,6 +219,16 @@ async fn test_invariant() { None, None, )], + ), + ( + "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkTest", + vec![( + "invariant_fork_handler_block()", + false, + Some("revert: too many blocks mined".into()), + None, + None, + )], ) ]), ); @@ -631,3 +641,30 @@ async fn test_invariant_scrape_values() { ]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_roll_fork_handler() { + let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); + opts.fuzz.seed = Some(U256::from(119u32)); + + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantRollFork.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options = opts.clone(); + runner.test_options.invariant.failure_persist_dir = + Some(tempfile::tempdir().unwrap().into_path()); + + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkTest", + vec![( + "invariant_fork_handler_block()", + false, + Some("revert: too many blocks mined".into()), + None, + None, + )], + )]), + ); +} diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 6f95767653857..75856c5e47ce7 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -326,3 +326,6 @@ test_repro!(6634; |config| { }); test_repro!(7481); + +// https://github.com/foundry-rs/foundry/issues/5739 +test_repro!(5739); diff --git a/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol b/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol new file mode 100644 index 0000000000000..7934a29160e4d --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract RollForkHandler is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function work() external { + vm.rollFork(block.number + 1); + } +} + +contract InvariantRollForkTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + RollForkHandler forkHandler; + + function setUp() public { + vm.createSelectFork("rpcAlias", 19812632); + forkHandler = new RollForkHandler(); + } + + /// forge-config: default.invariant.runs = 2 + /// forge-config: default.invariant.depth = 4 + function invariant_fork_handler_block() public { + require(block.number < 19812634, "too many blocks mined"); + } +} diff --git a/testdata/default/repros/Issue5739.t.sol b/testdata/default/repros/Issue5739.t.sol new file mode 100644 index 0000000000000..2864c0cbffb32 --- /dev/null +++ b/testdata/default/repros/Issue5739.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +interface IERC20 { + function totalSupply() external view returns (uint256 supply); +} + +// https://github.com/foundry-rs/foundry/issues/5739 +contract Issue5739Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + IERC20 dai; + + function setUp() public { + vm.createSelectFork("rpcAlias", 19000000); + dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); + } + + function testRollForkStateUpdated() public { + // dai not persistent so state should be updated between rolls + assertEq(dai.totalSupply(), 3723031040751006502480211083); + vm.rollFork(19925849); + assertEq(dai.totalSupply(), 3320242279303699674318705475); + } + + function testRollForkStatePersisted() public { + // make dai persistent so state is preserved between rolls + vm.makePersistent(address(dai)); + assertEq(dai.totalSupply(), 3723031040751006502480211083); + vm.rollFork(19925849); + assertEq(dai.totalSupply(), 3723031040751006502480211083); + } +} From a03fed9aeb9986e809f78e7204a5b8e979702b5e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 May 2024 22:09:12 +0300 Subject: [PATCH 0993/1963] chore(deps): bump alloy (#7990) --- Cargo.lock | 86 +++++++++++--------- Cargo.toml | 57 ++++++------- crates/anvil/core/src/eth/transaction/mod.rs | 3 +- crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 6 +- 5 files changed, 82 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 131c6351dfee6..f5fffa400856b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-eips", "alloy-primitives", @@ -92,7 +92,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -132,7 +132,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-primitives", "alloy-serde", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-primitives", "serde", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -192,6 +192,7 @@ dependencies = [ "alloy-signer", "alloy-sol-types", "async-trait", + "auto_impl", "futures-utils-wasm", "thiserror", ] @@ -226,8 +227,9 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ + "alloy-chains", "alloy-eips", "alloy-json-rpc", "alloy-network", @@ -249,6 +251,7 @@ dependencies = [ "lru", "pin-project", "reqwest", + "serde", "serde_json", "tokio", "tracing", @@ -258,7 +261,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -298,7 +301,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -322,7 +325,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -340,7 +343,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -357,7 +360,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -369,7 +372,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-primitives", "serde", @@ -379,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -394,7 +397,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-consensus", "alloy-network", @@ -411,7 +414,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -430,7 +433,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-consensus", "alloy-network", @@ -446,7 +449,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-consensus", "alloy-network", @@ -537,7 +540,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -555,7 +558,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -569,7 +572,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -589,7 +592,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=f415827#f41582792950a3bf4c334c588a5497468e1f8149" +source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -604,9 +607,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.3.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb28aa4ecd32fdfa1b1bdd111ff7357dd562c6b2372694cf9e613434fcba659" +checksum = "03704f265cbbb943b117ecb5055fd46e8f41e7dc8a58b1aed20bcd40ace38c15" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -750,7 +753,7 @@ dependencies = [ "foundry-test-utils", "futures", "hyper 1.3.1", - "itertools 0.12.1", + "itertools 0.13.0", "k256", "parking_lot", "rand", @@ -1732,7 +1735,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.12.1", + "itertools 0.13.0", "rand", "rayon", "regex", @@ -3084,7 +3087,7 @@ dependencies = [ "humantime-serde", "hyper 1.3.1", "indicatif", - "itertools 0.12.1", + "itertools 0.13.0", "mockall", "once_cell", "opener 0.6.1", @@ -3131,7 +3134,7 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", - "itertools 0.12.1", + "itertools 0.13.0", "mdbook", "once_cell", "rayon", @@ -3151,7 +3154,7 @@ dependencies = [ "alloy-primitives", "ariadne", "foundry-config", - "itertools 0.12.1", + "itertools 0.13.0", "similar-asserts", "solang-parser", "thiserror", @@ -3192,7 +3195,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.12.1", + "itertools 0.13.0", "parking_lot", "revm-inspectors", "semver 1.0.23", @@ -3223,7 +3226,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "itertools 0.12.1", + "itertools 0.13.0", "once_cell", "regex", "reqwest", @@ -3287,7 +3290,7 @@ dependencies = [ "foundry-config", "foundry-evm-core", "foundry-wallets", - "itertools 0.12.1", + "itertools 0.13.0", "jsonpath_lib", "k256", "p256", @@ -3540,7 +3543,7 @@ dependencies = [ "foundry-macros", "foundry-test-utils", "futures", - "itertools 0.12.1", + "itertools 0.13.0", "once_cell", "parking_lot", "revm", @@ -3584,7 +3587,7 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-traces", "indexmap", - "itertools 0.12.1", + "itertools 0.13.0", "parking_lot", "proptest", "rand", @@ -3610,7 +3613,7 @@ dependencies = [ "foundry-config", "foundry-evm-core", "futures", - "itertools 0.12.1", + "itertools 0.13.0", "once_cell", "revm-inspectors", "serde", @@ -3685,7 +3688,7 @@ dependencies = [ "eyre", "foundry-common", "foundry-config", - "itertools 0.12.1", + "itertools 0.13.0", "rpassword", "serde", "thiserror", @@ -4701,6 +4704,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -6340,7 +6352,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=098ab30#098ab30faf3254c8ba3159b1af006d71d3577d95" +source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=0d3f1f4#0d3f1f4e41bfa2e1e56d37994494934edf0a11ef" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 4f5b962b2fbeb..fc19e062d81f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ foundry-compilers = { version = "0.5", default-features = false } # no default features to avoid c-kzg revm = { version = "9", default-features = false } revm-primitives = { version = "4", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "098ab30", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "0d3f1f4", features = [ "serde", ] } @@ -152,52 +152,49 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "f415827", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" alloy-sol-types = "0.7.1" syn-solidity = "0.7.1" alloy-chains = "0.1" -alloy-trie = "0.3.1" +alloy-trie = "0.4.1" alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" eyre = "0.6" hex = { package = "const-hex", version = "1.6", features = ["hex"] } -itertools = "0.12" +itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" similar-asserts = "1.5" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index eced8fe336b4d..6710ce1bcb26c 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -2,8 +2,9 @@ use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest}; use alloy_consensus::{ + transaction::eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, - TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, TxReceipt, + TxEnvelope, TxLegacy, TxReceipt, }; use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256}; diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 70641043f8e59..98c68abf36b59 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -31,7 +31,7 @@ use crate::{ revm::primitives::{BlobExcessGasAndPrice, Output}, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; -use alloy_consensus::TxEip4844Variant; +use alloy_consensus::transaction::eip4844::TxEip4844Variant; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; use alloy_network::eip2718::Decodable2718; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 861bad0a558eb..3668c4e3cb888 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -44,7 +44,7 @@ use alloy_rpc_types_trace::{ geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, }; -use alloy_trie::{HashBuilder, Nibbles}; +use alloy_trie::{proof::ProofRetainer, HashBuilder, Nibbles}; use anvil_core::{ eth::{ block::{Block, BlockInfo}, @@ -2226,7 +2226,7 @@ impl Backend { let account = db.get(&address).cloned().unwrap_or_default(); let mut builder = HashBuilder::default() - .with_proof_retainer(vec![Nibbles::unpack(keccak256(address))]); + .with_proof_retainer(ProofRetainer::new(vec![Nibbles::unpack(keccak256(address))])); for (key, account) in trie_accounts(db) { builder.add_leaf(key, &account); @@ -2508,7 +2508,7 @@ pub fn transaction_build( pub fn prove_storage(storage: &HashMap, keys: &[B256]) -> Vec> { let keys: Vec<_> = keys.iter().map(|key| Nibbles::unpack(keccak256(key))).collect(); - let mut builder = HashBuilder::default().with_proof_retainer(keys.clone()); + let mut builder = HashBuilder::default().with_proof_retainer(ProofRetainer::new(keys.clone())); for (key, value) in trie_storage(storage) { builder.add_leaf(key, &value); From 10f1402b9dc7c4d0fdffd47d5c842cf416f656ea Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 May 2024 23:22:52 +0300 Subject: [PATCH 0994/1963] fix(debugger): don't panic on pc-ic / sourcemap mismatch (#7991) --- crates/debugger/src/tui/draw.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index ffe348f4726d4..ad1645d27b717 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -350,17 +350,18 @@ impl DebuggerContext<'_> { } else { contract_source.deployed_bytecode.bytecode.as_ref()? }; - let mut source_map = bytecode.source_map()?.ok()?; + let source_map = bytecode.source_map()?.ok()?; let pc_ic_map = if is_create { create_map } else { rt_map }; let ic = pc_ic_map.get(pc)?; - let source_element = source_map.swap_remove(ic); + let source_element = source_map.get(ic)?; // if the source element has an index, find the sourcemap for that index source_element .index - .and_then(|index| // if index matches current file_id, return current source code - (index == file_id).then(|| (source_element.clone(), source_code))) + .and_then(|index| { + (index == file_id).then(|| (source_element.clone(), source_code)) + }) .or_else(|| { // otherwise find the source code for the element's index self.debugger From 83e6aec038760a58dbab1acd992ed5ce18b9d90b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 25 May 2024 11:43:09 +0300 Subject: [PATCH 0995/1963] refactor: clean-up cast send (#7967) * refactor: clean-up cast build_tx * doc * wip * refactor access-list and send * fixes --- crates/cast/bin/cmd/access_list.rs | 106 ++------- crates/cast/bin/cmd/call.rs | 177 ++++++---------- crates/cast/bin/cmd/estimate.rs | 114 ++++------ crates/cast/bin/cmd/mktx.rs | 29 +-- crates/cast/bin/cmd/send.rs | 94 ++------ crates/cast/bin/tx.rs | 330 +++++++++++++++++++++-------- crates/cli/src/utils/abi.rs | 4 +- 7 files changed, 401 insertions(+), 453 deletions(-) diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 0e8fd042d4658..0ec110bae4ba1 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -1,17 +1,15 @@ -use alloy_network::{AnyNetwork, TransactionBuilder}; -use alloy_primitives::{Address, Bytes}; -use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; -use alloy_transport::Transport; +use crate::tx::CastTxBuilder; +use alloy_primitives::TxKind; +use alloy_rpc_types::BlockId; use cast::Cast; use clap::Parser; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils::{self, parse_function_args}, + utils, }; use foundry_common::ens::NameOrAddress; -use foundry_config::{Chain, Config}; +use foundry_config::Config; use std::str::FromStr; /// CLI arguments for `cast access-list`. @@ -32,14 +30,6 @@ pub struct AccessListArgs { #[arg(value_name = "ARGS")] args: Vec, - /// The data for the transaction. - #[arg( - long, - value_name = "DATA", - conflicts_with_all = &["sig", "args"] - )] - data: Option, - /// The block height to query at. /// /// Can also be the tags earliest, finalized, safe, latest, or pending. @@ -59,86 +49,32 @@ pub struct AccessListArgs { impl AccessListArgs { pub async fn run(self) -> Result<()> { - let AccessListArgs { to, sig, args, data, tx, eth, block, json: to_json } = self; + let AccessListArgs { to, sig, args, tx, eth, block, json: to_json } = self; let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain, &provider).await?; let sender = eth.wallet.sender().await; - let etherscan_api_key = config.get_etherscan_api_key(Some(chain)); - let to = match to { - Some(to) => Some(to.resolve(&provider).await?), - None => None, + let tx_kind = if let Some(to) = to { + TxKind::Call(to.resolve(&provider).await?) + } else { + TxKind::Create }; - access_list( - &provider, - etherscan_api_key.as_deref(), - sender, - to, - sig, - args, - data, - tx, - chain, - block, - to_json, - ) - .await?; - Ok(()) - } -} + let (tx, _) = CastTxBuilder::new(&provider, tx, &config) + .await? + .with_tx_kind(tx_kind) + .with_code_sig_and_args(None, sig, args) + .await? + .build_raw(sender) + .await?; -#[allow(clippy::too_many_arguments)] -async fn access_list, T: Transport + Clone>( - provider: P, - etherscan_api_key: Option<&str>, - from: Address, - to: Option

, - sig: Option, - args: Vec, - data: Option, - tx: TransactionOpts, - chain: Chain, - block: Option, - to_json: bool, -) -> Result<()> { - let mut req = WithOtherFields::::default() - .with_from(from) - .with_value(tx.value.unwrap_or_default()) - .with_chain_id(chain.id()); + let cast = Cast::new(&provider); - if let Some(to) = to { - req.set_to(to); - } else { - req.set_kind(alloy_primitives::TxKind::Create); - } + let access_list: String = cast.access_list(&tx, block, to_json).await?; - if let Some(gas_limit) = tx.gas_limit { - req.set_gas_limit(gas_limit.to()); - } + println!("{}", access_list); - if let Some(nonce) = tx.nonce { - req.set_nonce(nonce.to()); + Ok(()) } - - let data = if let Some(sig) = sig { - parse_function_args(&sig, args, to, chain, &provider, etherscan_api_key).await?.0 - } else if let Some(data) = data { - // Note: `sig+args` and `data` are mutually exclusive - hex::decode(data)? - } else { - Vec::new() - }; - - req.set_input::(data.into()); - - let cast = Cast::new(&provider); - - let access_list: String = cast.access_list(&req, block, to_json).await?; - - println!("{}", access_list); - - Ok(()) } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 129e3da3081e1..10a97ea00b572 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,12 +1,12 @@ -use alloy_network::TransactionBuilder; +use crate::tx::CastTxBuilder; use alloy_primitives::{TxKind, U256}; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::BlockId; use cast::Cast; use clap::Parser; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils::{self, handle_traces, parse_ether_value, parse_function_args, TraceResult}, + utils::{self, handle_traces, parse_ether_value, TraceResult}, }; use foundry_common::ens::NameOrAddress; use foundry_compilers::EvmVersion; @@ -97,10 +97,9 @@ impl CallArgs { pub async fn run(self) -> Result<()> { let CallArgs { to, - sig, - args, - data, - tx, + mut sig, + mut args, + mut tx, eth, command, block, @@ -108,132 +107,78 @@ impl CallArgs { evm_version, debug, labels, + data, } = self; + if let Some(data) = data { + sig = Some(data); + } + let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain, &provider).await?; let sender = eth.wallet.sender().await; - let etherscan_api_key = config.get_etherscan_api_key(Some(chain)); - let to = match to { - Some(to) => Some(to.resolve(&provider).await?), - None => None, + let tx_kind = if let Some(to) = to { + TxKind::Call(to.resolve(&provider).await?) + } else { + TxKind::Create }; - let mut req = WithOtherFields::::default() - .with_from(sender) - .with_value(tx.value.unwrap_or_default()); - - if let Some(to) = to { - req.set_to(to); + let code = if let Some(CallSubcommands::Create { + code, + sig: create_sig, + args: create_args, + value, + }) = command + { + sig = create_sig; + args = create_args; + if let Some(value) = value { + tx.value = Some(value); + } + Some(code) } else { - req.set_kind(alloy_primitives::TxKind::Create); - } - - if let Some(nonce) = tx.nonce { - req.set_nonce(nonce.to()); - } - - let (data, func) = match command { - Some(CallSubcommands::Create { code, sig, args, value }) => { - if let Some(value) = value { - req.set_value(value); - } - - let mut data = hex::decode(code)?; - - if let Some(s) = sig { - let (mut constructor_args, _) = parse_function_args( - &s, - args, - None, - chain, - &provider, - etherscan_api_key.as_deref(), - ) - .await?; - data.append(&mut constructor_args); - } - - if trace { - let figment = Config::figment_with_root(find_project_root_path(None).unwrap()) - .merge(eth.rpc); - - let evm_opts = figment.extract::()?; - - let (env, fork, chain) = - TracingExecutor::get_fork_material(&config, evm_opts).await?; - - let mut executor = TracingExecutor::new(env, fork, evm_version, debug); + None + }; - let trace = match executor.deploy( - sender, - data.into(), - req.value.unwrap_or_default(), - None, - ) { + let (tx, func) = CastTxBuilder::new(&provider, tx, &config) + .await? + .with_tx_kind(tx_kind) + .with_code_sig_and_args(code, sig, args) + .await? + .build_raw(sender) + .await?; + + if trace { + let figment = + Config::figment_with_root(find_project_root_path(None).unwrap()).merge(eth.rpc); + let evm_opts = figment.extract::()?; + let (env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; + let mut executor = TracingExecutor::new(env, fork, evm_version, debug); + + let value = tx.value.unwrap_or_default(); + let input = tx.inner.input.into_input().unwrap_or_default(); + + let trace = match tx_kind { + TxKind::Create => { + let deploy_result = executor.deploy(sender, input, value, None); + + match deploy_result { Ok(deploy_result) => TraceResult::from(deploy_result), Err(evm_err) => TraceResult::try_from(evm_err)?, - }; - - handle_traces(trace, &config, chain, labels, debug).await?; - - return Ok(()); + } } - - (data, None) - } - _ => { - // fill first here because we need to use the builder in the conditional - let (data, func) = if let Some(sig) = sig { - parse_function_args( - &sig, - args, - to, - chain, - &provider, - etherscan_api_key.as_deref(), - ) - .await? - } else if let Some(data) = data { - // Note: `sig+args` and `data` are mutually exclusive - (hex::decode(data)?, None) - } else { - (Vec::new(), None) - }; - - if trace { - let figment = Config::figment_with_root(find_project_root_path(None).unwrap()) - .merge(eth.rpc); - - let evm_opts = figment.extract::()?; - - let (env, fork, chain) = - TracingExecutor::get_fork_material(&config, evm_opts).await?; - - let mut executor = TracingExecutor::new(env, fork, evm_version, debug); - - let to = if let Some(TxKind::Call(to)) = req.to { Some(to) } else { None }; - let trace = TraceResult::from(executor.call_raw_committing( - sender, - to.expect("an address to be here"), - data.into(), - req.value.unwrap_or_default(), - )?); - - handle_traces(trace, &config, chain, labels, debug).await?; - - return Ok(()); + TxKind::Call(to) => { + TraceResult::from(executor.call_raw_committing(sender, to, input, value)?) } + }; - (data, func) - } - }; + handle_traces(trace, &config, chain, labels, debug).await?; - req.set_input(data); + return Ok(()); + } - println!("{}", Cast::new(provider).call(&req, func.as_ref(), block).await?); + println!("{}", Cast::new(provider).call(&tx, func.as_ref(), block).await?); Ok(()) } diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index c000a79c12c31..5e60c979661a9 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,15 +1,15 @@ -use alloy_network::TransactionBuilder; -use alloy_primitives::U256; +use crate::tx::CastTxBuilder; +use alloy_primitives::{TxKind, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::BlockId; use clap::Parser; use eyre::Result; use foundry_cli::{ - opts::{EtherscanOpts, RpcOpts}, - utils::{self, parse_ether_value, parse_function_args}, + opts::{EthereumOpts, TransactionOpts}, + utils::{self, parse_ether_value}, }; use foundry_common::ens::NameOrAddress; -use foundry_config::{figment::Figment, Config}; +use foundry_config::Config; use std::str::FromStr; /// CLI arguments for `cast estimate`. @@ -25,32 +25,20 @@ pub struct EstimateArgs { /// The arguments of the function to call. args: Vec, - /// The sender account. - #[arg( - short, - long, - value_parser = NameOrAddress::from_str, - default_value = "0x0000000000000000000000000000000000000000", - env = "ETH_FROM", - )] - from: NameOrAddress, - - /// Ether to send in the transaction. + /// The block height to query at. /// - /// Either specified in wei, or as a string with a unit type: - /// - /// Examples: 1ether, 10gwei, 0.01ether - #[arg(long, value_parser = parse_ether_value)] - value: Option, + /// Can also be the tags earliest, finalized, safe, latest, or pending. + #[arg(long, short = 'B')] + block: Option, - #[command(flatten)] - rpc: RpcOpts, + #[command(subcommand)] + command: Option, #[command(flatten)] - etherscan: EtherscanOpts, + tx: TransactionOpts, - #[command(subcommand)] - command: Option, + #[command(flatten)] + eth: EthereumOpts, } #[derive(Debug, Parser)] @@ -79,56 +67,44 @@ pub enum EstimateSubcommands { impl EstimateArgs { pub async fn run(self) -> Result<()> { - let EstimateArgs { from, to, sig, args, value, rpc, etherscan, command } = self; + let EstimateArgs { to, mut sig, mut args, mut tx, block, eth, command } = self; - let figment = Figment::from(Config::figment()).merge(etherscan).merge(rpc); - let config = Config::try_from(figment)?; + let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain, &provider).await?; - let api_key = config.get_etherscan_api_key(Some(chain)); - - let from = from.resolve(&provider).await?; - let to = match to { - Some(to) => Some(to.resolve(&provider).await?), - None => None, - }; - - let mut req = WithOtherFields::::default() - .with_from(from) - .with_value(value.unwrap_or_default()); + let sender = eth.wallet.sender().await; - if let Some(to) = to { - req.set_to(to); + let tx_kind = if let Some(to) = to { + TxKind::Call(to.resolve(&provider).await?) } else { - req.set_kind(alloy_primitives::TxKind::Create); - } - - let data = match command { - Some(EstimateSubcommands::Create { code, sig, args, value }) => { - if let Some(value) = value { - req.set_value(value); - } - - let mut data = hex::decode(code)?; - - if let Some(s) = sig { - let (mut constructor_args, _) = - parse_function_args(&s, args, to, chain, &provider, api_key.as_deref()) - .await?; - data.append(&mut constructor_args); - } + TxKind::Create + }; - data - } - _ => { - let sig = sig.ok_or_else(|| eyre::eyre!("Function signature must be provided."))?; - parse_function_args(&sig, args, to, chain, &provider, api_key.as_deref()).await?.0 + let code = if let Some(EstimateSubcommands::Create { + code, + sig: create_sig, + args: create_args, + value, + }) = command + { + sig = create_sig; + args = create_args; + if let Some(value) = value { + tx.value = Some(value); } + Some(code) + } else { + None }; - req.set_input(data); + let (tx, _) = CastTxBuilder::new(&provider, tx, &config) + .await? + .with_tx_kind(tx_kind) + .with_code_sig_and_args(code, sig, args) + .await? + .build_raw(sender) + .await?; - let gas = provider.estimate_gas(&req).await?; + let gas = provider.estimate_gas(&tx).block_id(block.unwrap_or_default()).await?; println!("{gas}"); Ok(()) } @@ -141,6 +117,6 @@ mod tests { #[test] fn parse_estimate_value() { let args: EstimateArgs = EstimateArgs::parse_from(["foundry-cli", "--value", "100"]); - assert!(args.value.is_some()); + assert!(args.tx.value.is_some()); } } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index f8f6d9fb20444..999688b19c004 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -1,7 +1,5 @@ -use crate::tx; +use crate::tx::{self, CastTxBuilder}; use alloy_network::{eip2718::Encodable2718, EthereumSigner, TransactionBuilder}; -use alloy_primitives::U64; -use alloy_provider::Provider; use alloy_signer::Signer; use clap::Parser; use eyre::Result; @@ -28,10 +26,6 @@ pub struct MakeTxArgs { /// The arguments of the function to call. args: Vec, - /// Reuse the latest nonce for the sender account. - #[arg(long, conflicts_with = "nonce")] - resend: bool, - #[command(subcommand)] command: Option, @@ -60,7 +54,7 @@ pub enum MakeTxSubcommands { impl MakeTxArgs { pub async fn run(self) -> Result<()> { - let MakeTxArgs { to, mut sig, mut args, resend, command, mut tx, eth } = self; + let MakeTxArgs { to, mut sig, mut args, command, tx, eth } = self; let code = if let Some(MakeTxSubcommands::Create { code, @@ -75,12 +69,10 @@ impl MakeTxArgs { None }; - tx::validate_to_address(&code, &to)?; - let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain, &provider).await?; - let api_key = config.get_etherscan_api_key(Some(chain)); + + let tx_kind = tx::resolve_tx_kind(&provider, &code, &to).await?; // Retrieve the signer, and bail if it can't be constructed. let signer = eth.wallet.signer().await?; @@ -88,14 +80,15 @@ impl MakeTxArgs { tx::validate_from_address(eth.wallet.from, from)?; - if resend { - tx.nonce = Some(U64::from(provider.get_transaction_count(from).await?)); - } - let provider = get_provider(&config)?; - let (tx, _) = - tx::build_tx(&provider, from, to, code, sig, args, tx, chain, api_key, None).await?; + let (tx, _) = CastTxBuilder::new(provider, tx, &config) + .await? + .with_tx_kind(tx_kind) + .with_code_sig_and_args(code, sig, args) + .await? + .build(from) + .await?; let tx = tx.build(&EthereumSigner::new(signer)).await?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 06c8b99f249c6..ea9cfcdcd282c 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -1,7 +1,7 @@ -use crate::tx; +use crate::tx::{self, CastTxBuilder}; use alloy_network::{AnyNetwork, EthereumSigner}; -use alloy_primitives::{Address, U64}; use alloy_provider::{Provider, ProviderBuilder}; +use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use alloy_signer::Signer; use alloy_transport::Transport; use cast::Cast; @@ -12,7 +12,7 @@ use foundry_cli::{ utils, }; use foundry_common::{cli_warn, ens::NameOrAddress}; -use foundry_config::{Chain, Config}; +use foundry_config::Config; use std::{path::PathBuf, str::FromStr}; /// CLI arguments for `cast send`. @@ -42,10 +42,6 @@ pub struct SendTxArgs { #[arg(long, short, help_heading = "Display options")] json: bool, - /// Reuse the latest nonce for the sender account. - #[arg(long, conflicts_with = "nonce")] - resend: bool, - #[command(subcommand)] command: Option, @@ -88,10 +84,9 @@ impl SendTxArgs { mut sig, cast_async, mut args, - mut tx, + tx, confirmations, json: to_json, - resend, command, unlocked, path, @@ -112,17 +107,16 @@ impl SendTxArgs { None }; - tx::validate_to_address(&code, &to)?; - let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let chain = utils::get_chain(config.chain, &provider).await?; - let api_key = config.get_etherscan_api_key(Some(chain)); + let tx_kind = tx::resolve_tx_kind(&provider, &code, &to).await?; - let to = match to { - Some(to) => Some(to.resolve(&provider).await?), - None => None, - }; + let builder = CastTxBuilder::new(&provider, tx, &config) + .await? + .with_tx_kind(tx_kind) + .with_code_sig_and_args(code, sig, args) + .await? + .with_blob_data(blob_data)?; // Case 1: // Default to sending via eth_sendTransaction if the --unlocked flag is passed. @@ -148,26 +142,9 @@ impl SendTxArgs { } } - if resend { - tx.nonce = Some(U64::from(provider.get_transaction_count(config.sender).await?)); - } + let (tx, _) = builder.build(config.sender).await?; - cast_send( - provider, - config.sender, - to, - code, - sig, - args, - tx, - chain, - api_key, - cast_async, - confirmations, - to_json, - blob_data, - ) - .await + cast_send(provider, tx, cast_async, confirmations, to_json).await // Case 2: // An option to use a local signer was provided. // If we cannot successfully instantiate a local signer, then we will assume we don't have @@ -179,54 +156,25 @@ impl SendTxArgs { tx::validate_from_address(eth.wallet.from, from)?; - if resend { - tx.nonce = Some(U64::from(provider.get_transaction_count(from).await?)); - } - let signer = EthereumSigner::from(signer); - let provider = - ProviderBuilder::<_, _, AnyNetwork>::default().signer(signer).on_provider(provider); - - cast_send( - provider, - from, - to, - code, - sig, - args, - tx, - chain, - api_key, - cast_async, - confirmations, - to_json, - blob_data, - ) - .await + let provider = ProviderBuilder::<_, _, AnyNetwork>::default() + .signer(signer) + .on_provider(&provider); + + let (tx, _) = builder.build(from).await?; + + cast_send(provider, tx, cast_async, confirmations, to_json).await } } } -#[allow(clippy::too_many_arguments)] async fn cast_send, T: Transport + Clone>( provider: P, - from: Address, - to: Option
, - code: Option, - sig: Option, - args: Vec, - tx: TransactionOpts, - chain: Chain, - etherscan_api_key: Option, + tx: WithOtherFields, cast_async: bool, confs: u64, to_json: bool, - blob_data: Option>, ) -> Result<()> { - let (tx, _) = - tx::build_tx(&provider, from, to, code, sig, args, tx, chain, etherscan_api_key, blob_data) - .await?; - let cast = Cast::new(provider); let pending_tx = cast.send(tx).await?; diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index d4c9e205c2409..77ed93babd3f8 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,14 +1,17 @@ use alloy_consensus::{SidecarBuilder, SimpleCoder}; use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{Address, TxKind}; use alloy_provider::Provider; use alloy_rpc_types::{TransactionRequest, WithOtherFields}; use alloy_transport::Transport; use eyre::Result; -use foundry_cli::{opts::TransactionOpts, utils::parse_function_args}; +use foundry_cli::{ + opts::TransactionOpts, + utils::{self, parse_function_args}, +}; use foundry_common::ens::NameOrAddress; -use foundry_config::Chain; +use foundry_config::{Chain, Config}; /// Prevents a misconfigured hwlib from sending a transaction that defies user-specified --from pub fn validate_from_address( @@ -30,116 +33,263 @@ corresponds to the sender, or let foundry automatically detect it by not specify } /// Ensures the transaction is either a contract deployment or a recipient address is specified -pub fn validate_to_address(code: &Option, to: &Option) -> Result<()> { - if code.is_none() && to.is_none() { +pub async fn resolve_tx_kind, T: Transport + Clone>( + provider: &P, + code: &Option, + to: &Option, +) -> Result { + if code.is_some() { + Ok(TxKind::Create) + } else if let Some(to) = to { + Ok(TxKind::Call(to.resolve(provider).await?)) + } else { eyre::bail!("Must specify a recipient address or contract code to deploy"); } - Ok(()) } -#[allow(clippy::too_many_arguments)] -pub async fn build_tx< +/// Initial state. +#[derive(Debug)] +pub struct InitState; + +/// State with known [TxKind]. +#[derive(Debug)] +pub struct TxKindState { + kind: TxKind, +} + +/// State with known input for the transaction. +#[derive(Debug)] +pub struct InputState { + kind: TxKind, + input: Vec, + func: Option, +} + +/// Builder type constructing [TransactionRequest] from cast send/mktx inputs. +/// +/// It is implemented as a stateful builder with expected state transition of [InitState] -> +/// [TxKindState] -> [InputState]. +#[derive(Debug)] +pub struct CastTxBuilder { + provider: P, + tx: WithOtherFields, + legacy: bool, + blob: bool, + chain: Chain, + etherscan_api_key: Option, + state: S, + _t: std::marker::PhantomData, +} + +impl CastTxBuilder +where P: Provider, T: Transport + Clone, - F: Into, - TO: Into, ->( - provider: &P, - from: F, - to: Option, - code: Option, - sig: Option, - args: Vec, - tx: TransactionOpts, - chain: impl Into, - etherscan_api_key: Option, - blob_data: Option>, -) -> Result<(WithOtherFields, Option)> { - let chain = chain.into(); +{ + /// Creates a new instance of [CastTxBuilder] filling transaction with fields present in + /// provided [TransactionOpts]. + pub async fn new(provider: P, tx_opts: TransactionOpts, config: &Config) -> Result { + let mut tx = WithOtherFields::::default(); + + let chain = utils::get_chain(config.chain, &provider).await?; + let etherscan_api_key = config.get_etherscan_api_key(Some(chain)); + + if let Some(gas_limit) = tx_opts.gas_limit { + tx.set_gas_limit(gas_limit.to()); + } + + if let Some(value) = tx_opts.value { + tx.set_value(value); + } - let from = from.into().resolve(provider).await?; + if let Some(gas_price) = tx_opts.gas_price { + if tx_opts.legacy { + tx.set_gas_price(gas_price.to()); + } else { + tx.set_max_fee_per_gas(gas_price.to()); + } + } - let sidecar = blob_data - .map(|data| { - let mut coder = SidecarBuilder::::default(); - coder.ingest(&data); - coder.build() + if !tx_opts.legacy { + if let Some(priority_fee) = tx_opts.priority_gas_price { + tx.set_max_priority_fee_per_gas(priority_fee.to()); + } + } + + if let Some(max_blob_fee) = tx_opts.blob_gas_price { + tx.set_max_fee_per_blob_gas(max_blob_fee.to()) + } + + if let Some(nonce) = tx_opts.nonce { + tx.set_nonce(nonce.to()); + } + + Ok(Self { + provider, + tx, + legacy: tx_opts.legacy || chain.is_legacy(), + blob: tx_opts.blob, + chain, + etherscan_api_key, + state: InitState, + _t: std::marker::PhantomData, }) - .transpose()?; - - let mut req = WithOtherFields::::default() - .with_from(from) - .with_value(tx.value.unwrap_or_default()) - .with_chain_id(chain.id()); - - if let Some(sidecar) = sidecar { - req.set_blob_sidecar(sidecar); - req.populate_blob_hashes(); - req.set_max_fee_per_blob_gas( - // If blob_base_fee is 0, uses 1 wei as minimum. - tx.blob_gas_price.map_or(provider.get_blob_base_fee().await?.max(1), |g| g.to()), - ); } - if let Some(to) = to { - req.set_to(to.into().resolve(provider).await?); - } else { - req.set_kind(alloy_primitives::TxKind::Create); + /// Sets [TxKind] for this builder and changes state to [TxKindState]. + pub fn with_tx_kind(self, kind: TxKind) -> CastTxBuilder { + CastTxBuilder { + provider: self.provider, + tx: self.tx, + legacy: self.legacy, + blob: self.blob, + chain: self.chain, + etherscan_api_key: self.etherscan_api_key, + state: TxKindState { kind }, + _t: self._t, + } } +} - req.set_nonce(if let Some(nonce) = tx.nonce { - nonce.to() - } else { - provider.get_transaction_count(from).await? - }); +impl CastTxBuilder +where + P: Provider, + T: Transport + Clone, +{ + /// Accepts user-provided code, sig and args params and constructs calldata for the transaction. + /// If code is present, input will be set to code + encoded constructor arguments. If no code is + /// present, input is set to just provided arguments. + pub async fn with_code_sig_and_args( + self, + code: Option, + sig: Option, + args: Vec, + ) -> Result> { + let (mut args, func) = if let Some(sig) = sig { + parse_function_args( + &sig, + args, + self.state.kind.to().cloned(), + self.chain, + &self.provider, + self.etherscan_api_key.as_deref(), + ) + .await? + } else { + (Vec::new(), None) + }; - if tx.legacy || chain.is_legacy() { - req.set_gas_price(if let Some(gas_price) = tx.gas_price { - gas_price.to() + let input = if let Some(code) = code { + let mut code = hex::decode(code)?; + code.append(&mut args); + code } else { - provider.get_gas_price().await? - }); - } else { - let (max_fee, priority_fee) = match (tx.gas_price, tx.priority_gas_price) { - (Some(gas_price), Some(priority_gas_price)) => (gas_price, priority_gas_price), - (_, _) => { - let estimate = provider.estimate_eip1559_fees(None).await?; - ( - tx.gas_price.unwrap_or(U256::from(estimate.max_fee_per_gas)), - tx.priority_gas_price.unwrap_or(U256::from(estimate.max_priority_fee_per_gas)), - ) - } + args }; - req.set_max_fee_per_gas(max_fee.to()); - req.set_max_priority_fee_per_gas(priority_fee.to()); + Ok(CastTxBuilder { + provider: self.provider, + tx: self.tx, + legacy: self.legacy, + blob: self.blob, + chain: self.chain, + etherscan_api_key: self.etherscan_api_key, + state: InputState { kind: self.state.kind, input, func }, + _t: self._t, + }) } +} - let params = sig.as_deref().map(|sig| (sig, args)); - let (data, func) = if let Some(code) = code { - let mut data = hex::decode(code)?; +impl CastTxBuilder +where + P: Provider, + T: Transport + Clone, +{ + /// Builds [TransactionRequest] and fiils missing fields. Returns a transaction which is ready + /// to be broadcasted. + pub async fn build( + self, + from: impl Into, + ) -> Result<(WithOtherFields, Option)> { + self._build(from, true).await + } - if let Some((sig, args)) = params { - let (mut sigdata, _) = - parse_function_args(sig, args, None, chain, provider, etherscan_api_key.as_deref()) - .await?; - data.append(&mut sigdata); + /// Builds [TransactionRequest] without filling missing fields. Used for read-only calls such as + /// eth_call, eth_estimateGas, etc + pub async fn build_raw( + self, + from: impl Into, + ) -> Result<(WithOtherFields, Option)> { + self._build(from, false).await + } + + async fn _build( + mut self, + from: impl Into, + fill: bool, + ) -> Result<(WithOtherFields, Option)> { + let from = from.into().resolve(&self.provider).await?; + + self.tx.set_kind(self.state.kind); + self.tx.set_input(self.state.input); + self.tx.set_from(from); + self.tx.set_chain_id(self.chain.id()); + + if !fill { + return Ok((self.tx, self.state.func)); } - (data, None) - } else if let Some((sig, args)) = params { - parse_function_args(sig, args, None, chain, provider, etherscan_api_key.as_deref()).await? - } else { - (Vec::new(), None) - }; + if self.legacy && self.tx.gas_price.is_none() { + self.tx.gas_price = Some(self.provider.get_gas_price().await?); + } - req.set_input::(data.into()); + if self.blob && self.tx.max_fee_per_blob_gas.is_none() { + self.tx.max_fee_per_blob_gas = Some(self.provider.get_blob_base_fee().await?) + } - req.set_gas_limit(if let Some(gas_limit) = tx.gas_limit { - gas_limit.to() - } else { - provider.estimate_gas(&req).await? - }); + if !self.legacy && + (self.tx.max_fee_per_gas.is_none() || self.tx.max_priority_fee_per_gas.is_none()) + { + let estimate = self.provider.estimate_eip1559_fees(None).await?; - Ok((req, func)) + if !self.legacy { + if self.tx.max_fee_per_gas.is_none() { + self.tx.max_fee_per_gas = Some(estimate.max_fee_per_gas); + } + + if self.tx.max_priority_fee_per_gas.is_none() { + self.tx.max_priority_fee_per_gas = Some(estimate.max_priority_fee_per_gas); + } + } + } + + if self.tx.gas.is_none() { + self.tx.gas = Some(self.provider.estimate_gas(&self.tx).await?); + } + + if self.tx.nonce.is_none() { + self.tx.nonce = Some(self.provider.get_transaction_count(from).await?); + } + + Ok((self.tx, self.state.func)) + } +} + +impl CastTxBuilder +where + P: Provider, + T: Transport + Clone, +{ + pub fn with_blob_data(mut self, blob_data: Option>) -> Result { + let Some(blob_data) = blob_data else { return Ok(self) }; + + let mut coder = SidecarBuilder::::default(); + coder.ingest(&blob_data); + let sidecar = coder.build()?; + + self.tx.set_blob_sidecar(sidecar); + self.tx.populate_blob_hashes(); + + Ok(self) + } } diff --git a/crates/cli/src/utils/abi.rs b/crates/cli/src/utils/abi.rs index 634b889ca7110..a52bdc15898e7 100644 --- a/crates/cli/src/utils/abi.rs +++ b/crates/cli/src/utils/abi.rs @@ -42,8 +42,8 @@ pub async fn parse_function_args Date: Sat, 25 May 2024 22:42:50 +0300 Subject: [PATCH 0996/1963] fix(invariant) - do not panic when evm call fails (#7994) fix(invariant) - remove expect when evm call --- crates/evm/evm/src/executors/invariant/mod.rs | 11 +++++++---- crates/evm/evm/src/executors/invariant/replay.rs | 6 +----- crates/evm/evm/src/executors/invariant/result.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 3 --- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index edf1f929187e6..be8dbf2baf797 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -206,7 +206,9 @@ impl<'a> InvariantExecutor<'a> { let mut assume_rejects_counter = 0; while current_run < self.config.depth { - let tx = inputs.last().expect("no input generated"); + let tx = inputs.last().ok_or_else(|| { + TestCaseError::fail("No input generated to call fuzzed target.") + })?; // Execute call from the randomly generated sequence and commit state changes. let call_result = executor @@ -216,7 +218,9 @@ impl<'a> InvariantExecutor<'a> { tx.call_details.calldata.clone(), U256::ZERO, ) - .expect("could not make raw evm call"); + .map_err(|e| { + TestCaseError::fail(format!("Could not make raw evm call: {}", e)) + })?; if call_result.result.as_ref() == MAGIC_ASSUME { inputs.pop(); @@ -229,8 +233,7 @@ impl<'a> InvariantExecutor<'a> { } } else { // Collect data for fuzzing from the state changeset. - let mut state_changeset = - call_result.state_changeset.to_owned().expect("no changesets"); + let mut state_changeset = call_result.state_changeset.to_owned().unwrap(); if !&call_result.reverted { collect_data( diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 1da2a3ebdb5a5..ff4fbc89dbb8f 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -77,11 +77,7 @@ pub fn replay_run( let invariant_result = executor.call_raw( CALLER, invariant_contract.address, - invariant_contract - .invariant_function - .abi_encode_input(&[]) - .expect("invariant should have no inputs") - .into(), + invariant_contract.invariant_function.abi_encode_input(&[])?.into(), U256::ZERO, )?; traces.push((TraceKind::Execution, invariant_result.traces.clone().unwrap())); diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index 8b2acc56cbd23..12d745de554af 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -64,7 +64,7 @@ pub(crate) fn assert_invariants( let mut call_result = executor.call_raw( CALLER, invariant_contract.address, - func.abi_encode_input(&[]).expect("invariant should have no inputs").into(), + func.abi_encode_input(&[])?.into(), U256::ZERO, )?; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 940e223b2448b..2e4c4b229a076 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -674,9 +674,6 @@ pub struct RawCallResult { /// Scripted transactions generated from this call pub transactions: Option, /// The changeset of the state. - /// - /// This is only present if the changed state was not committed to the database (i.e. if you - /// used `call` and `call_raw` not `call_committing` or `call_raw_committing`). pub state_changeset: Option, /// The `revm::Env` after the call pub env: EnvWithHandlerCfg, From ea2eff95b5c17edd3ffbdfc6daab5ce5cc80afc0 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sun, 26 May 2024 19:39:17 +0300 Subject: [PATCH 0997/1963] fix(forge): consistently apply `no_storage_caching` config (#7997) * fix(forge): consistently apply no_storage_caching config * Settings cleanup, Add test --- crates/cheatcodes/src/config.rs | 4 ++++ crates/cheatcodes/src/evm/fork.rs | 3 ++- crates/config/src/cache.rs | 8 ++++---- crates/config/src/lib.rs | 2 +- crates/forge/tests/it/fork.rs | 33 +++++++++++++++++++++++++++++- testdata/default/cheats/Fork.t.sol | 5 +++++ 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 64e02070ac480..66aef3cff7350 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -29,6 +29,8 @@ pub struct CheatsConfig { pub prompt_timeout: Duration, /// RPC storage caching settings determines what chains and endpoints to cache pub rpc_storage_caching: StorageCachingConfig, + /// Disables storage caching entirely. + pub no_storage_caching: bool, /// All known endpoints and their aliases pub rpc_endpoints: ResolvedRpcEndpoints, /// Project's paths as configured @@ -78,6 +80,7 @@ impl CheatsConfig { always_use_create_2_factory: evm_opts.always_use_create_2_factory, prompt_timeout: Duration::from_secs(config.prompt_timeout), rpc_storage_caching: config.rpc_storage_caching.clone(), + no_storage_caching: config.no_storage_caching, rpc_endpoints, paths: config.project_paths(), fs_permissions: config.fs_permissions.clone().joined(&config.__root), @@ -204,6 +207,7 @@ impl Default for CheatsConfig { always_use_create_2_factory: false, prompt_timeout: Duration::from_secs(120), rpc_storage_caching: Default::default(), + no_storage_caching: false, rpc_endpoints: Default::default(), paths: ProjectPathsConfig::builder().build_with_root("./"), fs_permissions: Default::default(), diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 81b364aaf1093..4c91a226128a8 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -338,7 +338,8 @@ fn create_fork_request( let mut evm_opts = ccx.state.config.evm_opts.clone(); evm_opts.fork_block_number = block; let fork = CreateFork { - enable_caching: ccx.state.config.rpc_storage_caching.enable_for_endpoint(&url), + enable_caching: !ccx.state.config.no_storage_caching && + ccx.state.config.rpc_storage_caching.enable_for_endpoint(&url), url, env: (*ccx.ecx.env).clone(), evm_opts, diff --git a/crates/config/src/cache.rs b/crates/config/src/cache.rs index ed1475c7ea5e4..58b3b8cbea30f 100644 --- a/crates/config/src/cache.rs +++ b/crates/config/src/cache.rs @@ -5,12 +5,12 @@ use number_prefix::NumberPrefix; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{fmt, fmt::Formatter, str::FromStr}; -/// Settings to configure caching of remote +/// Settings to configure caching of remote. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct StorageCachingConfig { - /// chains to cache + /// Chains to cache. pub chains: CachedChains, - /// endpoints to cache + /// Endpoints to cache. pub endpoints: CachedEndpoints, } @@ -258,7 +258,7 @@ mod tests { Chain::optimism_mainnet(), Chain::from_id(999999) ]), - endpoints: CachedEndpoints::All + endpoints: CachedEndpoints::All, } ) } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ec2118c16696a..d6a157ecfb5a4 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -3689,7 +3689,7 @@ mod tests { Chain::optimism_mainnet(), Chain::from_id(999999) ]), - endpoints: CachedEndpoints::All + endpoints: CachedEndpoints::All, }, use_literal_content: false, bytecode_hash: BytecodeHash::Ipfs, diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index d3f81ff67ea13..3f3576ac412e8 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -4,9 +4,11 @@ use crate::{ config::*, test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT}, }; +use alloy_chains::Chain; use forge::result::SuiteResult; -use foundry_config::{fs_permissions::PathPermission, FsPermissions}; +use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_test_utils::Filter; +use std::fs; /// Executes reverting fork test #[tokio::test(flavor = "multi_thread")] @@ -96,3 +98,32 @@ async fn test_create_same_fork() { let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}ForkSame")); TestConfig::with_filter(runner, filter).run().await; } + +/// Test that `no_storage_caching` config is properly applied +#[tokio::test(flavor = "multi_thread")] +async fn test_storage_caching_config() { + // no_storage_caching set to true: storage should not be cached + let mut config = TEST_DATA_DEFAULT.config.clone(); + config.no_storage_caching = true; + let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let filter = + Filter::new("testStorageCaching", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) + .exclude_tests(".*Revert"); + TestConfig::with_filter(runner, filter).run().await; + let cache_dir = Config::foundry_block_cache_dir(Chain::mainnet(), 19800000); + assert!(!cache_dir.unwrap().exists()); + + // no_storage_caching set to false: storage should be cached + let mut config = TEST_DATA_DEFAULT.config.clone(); + config.no_storage_caching = false; + let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let filter = + Filter::new("testStorageCaching", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) + .exclude_tests(".*Revert"); + TestConfig::with_filter(runner, filter).run().await; + let cache_dir = Config::foundry_block_cache_dir(Chain::mainnet(), 19800000).unwrap(); + assert!(cache_dir.exists()); + + // cleanup cached storage so subsequent tests does not fail + let _ = fs::remove_file(cache_dir); +} diff --git a/testdata/default/cheats/Fork.t.sol b/testdata/default/cheats/Fork.t.sol index 950865eacca91..cb6a4e3ff9c04 100644 --- a/testdata/default/cheats/Fork.t.sol +++ b/testdata/default/cheats/Fork.t.sol @@ -117,4 +117,9 @@ contract ForkTest is DSTest { vm.createSelectFork("https://polygon-pokt.nodies.app"); // Polygon mainnet RPC URL assertEq(block.chainid, 137); } + + // ensures forks storage is cached at block + function testStorageCaching() public { + vm.createSelectFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 19800000); + } } From 93a6c3a9e50d149e9058e25ba0589e0acad4d82b Mon Sep 17 00:00:00 2001 From: NIC Lin Date: Wed, 29 May 2024 17:17:50 +0800 Subject: [PATCH 0998/1963] Fix missing error code (#7999) * Fix string identifier of `UnnamedReturnVariable` error code * Add missing error code in `from_str` and update the order of error codes --- crates/config/src/error.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 00692d67dbea8..448553cdcc174 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -149,6 +149,7 @@ impl SolidityErrorCode { pub fn as_str(&self) -> Result<&'static str, u64> { let s = match self { SolidityErrorCode::SpdxLicenseNotProvided => "license", + SolidityErrorCode::VisibilityForConstructorIsIgnored => "constructor-visibility", SolidityErrorCode::ContractExceeds24576Bytes => "code-size", SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes => "init-code-size", SolidityErrorCode::FunctionStateMutabilityCanBeRestricted => "func-mutability", @@ -162,9 +163,8 @@ impl SolidityErrorCode { SolidityErrorCode::UnnamedReturnVariable => "unnamed-return", SolidityErrorCode::Unreachable => "unreachable", SolidityErrorCode::PragmaSolidity => "pragma-solidity", - SolidityErrorCode::Other(code) => return Err(*code), - SolidityErrorCode::VisibilityForConstructorIsIgnored => "constructor-visibility", SolidityErrorCode::TransientStorageUsed => "transient-storage", + SolidityErrorCode::Other(code) => return Err(*code), }; Ok(s) } @@ -174,7 +174,9 @@ impl From for u64 { fn from(code: SolidityErrorCode) -> u64 { match code { SolidityErrorCode::SpdxLicenseNotProvided => 1878, + SolidityErrorCode::VisibilityForConstructorIsIgnored => 2462, SolidityErrorCode::ContractExceeds24576Bytes => 5574, + SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes => 3860, SolidityErrorCode::FunctionStateMutabilityCanBeRestricted => 2018, SolidityErrorCode::UnusedLocalVariable => 2072, SolidityErrorCode::UnusedFunctionParameter => 5667, @@ -186,8 +188,6 @@ impl From for u64 { SolidityErrorCode::UnnamedReturnVariable => 6321, SolidityErrorCode::Unreachable => 5740, SolidityErrorCode::PragmaSolidity => 3420, - SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes => 3860, - SolidityErrorCode::VisibilityForConstructorIsIgnored => 2462, SolidityErrorCode::TransientStorageUsed => 2394, SolidityErrorCode::Other(code) => code, } @@ -208,20 +208,21 @@ impl FromStr for SolidityErrorCode { fn from_str(s: &str) -> Result { let code = match s { - "unreachable" => SolidityErrorCode::Unreachable, - "unused-return" => SolidityErrorCode::UnnamedReturnVariable, - "unused-param" => SolidityErrorCode::UnusedFunctionParameter, - "unused-var" => SolidityErrorCode::UnusedLocalVariable, + "license" => SolidityErrorCode::SpdxLicenseNotProvided, + "constructor-visibility" => SolidityErrorCode::VisibilityForConstructorIsIgnored, "code-size" => SolidityErrorCode::ContractExceeds24576Bytes, "init-code-size" => SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes, - "shadowing" => SolidityErrorCode::ShadowsExistingDeclaration, "func-mutability" => SolidityErrorCode::FunctionStateMutabilityCanBeRestricted, - "license" => SolidityErrorCode::SpdxLicenseNotProvided, - "pragma-solidity" => SolidityErrorCode::PragmaSolidity, + "unused-var" => SolidityErrorCode::UnusedLocalVariable, + "unused-param" => SolidityErrorCode::UnusedFunctionParameter, + "unused-return" => SolidityErrorCode::ReturnValueOfCallsNotUsed, "virtual-interfaces" => SolidityErrorCode::InterfacesExplicitlyVirtual, "missing-receive-ether" => SolidityErrorCode::PayableNoReceiveEther, + "shadowing" => SolidityErrorCode::ShadowsExistingDeclaration, "same-varname" => SolidityErrorCode::DeclarationSameNameAsAnother, - "constructor-visibility" => SolidityErrorCode::VisibilityForConstructorIsIgnored, + "unnamed-return" => SolidityErrorCode::UnnamedReturnVariable, + "unreachable" => SolidityErrorCode::Unreachable, + "pragma-solidity" => SolidityErrorCode::PragmaSolidity, "transient-storage" => SolidityErrorCode::TransientStorageUsed, _ => return Err(format!("Unknown variant {s}")), }; @@ -234,6 +235,7 @@ impl From for SolidityErrorCode { fn from(code: u64) -> Self { match code { 1878 => SolidityErrorCode::SpdxLicenseNotProvided, + 2462 => SolidityErrorCode::VisibilityForConstructorIsIgnored, 5574 => SolidityErrorCode::ContractExceeds24576Bytes, 3860 => SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes, 2018 => SolidityErrorCode::FunctionStateMutabilityCanBeRestricted, @@ -245,9 +247,8 @@ impl From for SolidityErrorCode { 2519 => SolidityErrorCode::ShadowsExistingDeclaration, 8760 => SolidityErrorCode::DeclarationSameNameAsAnother, 6321 => SolidityErrorCode::UnnamedReturnVariable, - 3420 => SolidityErrorCode::PragmaSolidity, 5740 => SolidityErrorCode::Unreachable, - 2462 => SolidityErrorCode::VisibilityForConstructorIsIgnored, + 3420 => SolidityErrorCode::PragmaSolidity, 2394 => SolidityErrorCode::TransientStorageUsed, other => SolidityErrorCode::Other(other), } From 82e7406af08e1e7b8719757e80e37d9625e794f1 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 29 May 2024 14:48:32 +0530 Subject: [PATCH 0999/1963] feat(cheatcodes): randomUint (#7960) * feat(cheatcodes): randomUint * fix: cargo cheats * add vm.randomUint test * nit cargo cheats * add randomUint range and randomAddress * use U256::rand * cargo cheats nit --- Cargo.lock | 1 + Cargo.toml | 7 ++- crates/cheatcodes/Cargo.toml | 6 ++- crates/cheatcodes/assets/cheatcodes.json | 60 ++++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 12 +++++ crates/cheatcodes/src/utils.rs | 30 ++++++++++++ testdata/cheats/Vm.sol | 3 ++ testdata/default/cheats/RandomUint.t.sol | 15 ++++++ 8 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 testdata/default/cheats/RandomUint.t.sol diff --git a/Cargo.lock b/Cargo.lock index f5fffa400856b..cc0e58724c735 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3295,6 +3295,7 @@ dependencies = [ "k256", "p256", "parking_lot", + "rand", "revm", "rustc-hash", "semver 1.0.23", diff --git a/Cargo.toml b/Cargo.toml index fc19e062d81f1..d5b4bdb410ab4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -175,7 +175,7 @@ alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-primitives = { version = "0.7.1", features = ["getrandom"] } +alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" alloy-sol-types = "0.7.1" @@ -188,7 +188,10 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } +chrono = { version = "0.4", default-features = false, features = [ + "clock", + "std", +] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index fa2daa8760de5..f712b77665dd3 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -27,7 +27,10 @@ alloy-sol-types.workspace = true alloy-provider.workspace = true alloy-rpc-types.workspace = true alloy-signer.workspace = true -alloy-signer-wallet = { workspace = true, features = ["mnemonic-all-languages", "keystore"] } +alloy-signer-wallet = { workspace = true, features = [ + "mnemonic-all-languages", + "keystore", +] } parking_lot = "0.12" eyre.workspace = true @@ -46,3 +49,4 @@ thiserror = "1" semver = "1" rustc-hash.workspace = true dialoguer = "0.11.0" +rand = "0.8" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 5606a10b15265..3f2f3cb334617 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6391,6 +6391,66 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "randomAddress", + "description": "Returns a random `address`.", + "declaration": "function randomAddress() external returns (address);", + "visibility": "external", + "mutability": "", + "signature": "randomAddress()", + "selector": "0xd5bee9f5", + "selectorBytes": [ + 213, + 190, + 233, + 245 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "randomUint_0", + "description": "Returns a random uint256 value.", + "declaration": "function randomUint() external returns (uint256);", + "visibility": "external", + "mutability": "", + "signature": "randomUint()", + "selector": "0x25124730", + "selectorBytes": [ + 37, + 18, + 71, + 48 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "randomUint_1", + "description": "Returns random uin256 value between the provided range (min..=max).", + "declaration": "function randomUint(uint256 min, uint256 max) external returns (uint256);", + "visibility": "external", + "mutability": "", + "signature": "randomUint(uint256,uint256)", + "selector": "0xd61b051b", + "selectorBytes": [ + 214, + 27, + 5, + 27 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readCallers", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index e8d24e3c51a21..d1123b4484c2c 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2139,6 +2139,18 @@ interface Vm { /// Returns ENS namehash for provided string. #[cheatcode(group = Utilities)] function ensNamehash(string calldata name) external pure returns (bytes32); + + /// Returns a random uint256 value. + #[cheatcode(group = Utilities)] + function randomUint() external returns (uint256); + + /// Returns random uin256 value between the provided range (min..=max). + #[cheatcode(group = Utilities)] + function randomUint(uint256 min, uint256 max) external returns (uint256); + + /// Returns a random `address`. + #[cheatcode(group = Utilities)] + function randomAddress() external returns (address); } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index df10613465dc3..fb750fa91c104 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -19,6 +19,7 @@ use k256::{ Secp256k1, }; use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; +use rand::Rng; /// The BIP32 default derivation path prefix. const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; @@ -145,6 +146,35 @@ impl Cheatcode for ensNamehashCall { } } +impl Cheatcode for randomUint_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self {} = self; + // Use thread_rng to get a random number + let mut rng = rand::thread_rng(); + let random_number: U256 = rng.gen(); + Ok(random_number.abi_encode()) + } +} + +impl Cheatcode for randomUint_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { min, max } = self; + // Generate random between range min..=max + let mut rng = rand::thread_rng(); + let range = *max - *min + U256::from(1); + let random_number = rng.gen::() % range + *min; + Ok(random_number.abi_encode()) + } +} + +impl Cheatcode for randomAddressCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self {} = self; + let addr = Address::random(); + Ok(addr.abi_encode()) + } +} + /// Using a given private key, return its public ETH address, its public key affine x and y /// coordinates, and its private key (see the 'Wallet' struct) /// diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 45c720e6c51e5..e1551362a5a58 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -315,6 +315,9 @@ interface Vm { function promptAddress(string calldata promptText) external returns (address); function promptSecret(string calldata promptText) external returns (string memory input); function promptUint(string calldata promptText) external returns (uint256); + function randomAddress() external returns (address); + function randomUint() external returns (uint256); + function randomUint(uint256 min, uint256 max) external returns (uint256); 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); diff --git a/testdata/default/cheats/RandomUint.t.sol b/testdata/default/cheats/RandomUint.t.sol new file mode 100644 index 0000000000000..5c5b1024aec6b --- /dev/null +++ b/testdata/default/cheats/RandomUint.t.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract RandomUint is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testRandomUint() public { + uint256 rand = vm.randomUint(); + + assertTrue(rand > 0); + } +} From 25b24554a1effd98c7c32f4c0c26911a6066f84b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 29 May 2024 12:19:08 +0300 Subject: [PATCH 1000/1963] chore(invariant): config defaults, add max test threads config (#7957) * chore(invariant): default depth / shrink run limit, config num of threads * Limit depth in testing at 15 * Set depth for ext integrations to 15 * Make max threads global config, propagate error if thread pool creation fails * Run invariant gas report with depth of 15 * Typo, move set threads at top of execute --- crates/config/README.md | 3 ++- crates/config/src/invariant.rs | 11 +++++----- crates/config/src/lib.rs | 3 ++- .../evm/evm/src/executors/invariant/error.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 21 ++++++++++++++++++- crates/forge/tests/it/test_helpers.rs | 2 +- crates/test-utils/src/util.rs | 1 + testdata/foundry.toml | 2 +- 8 files changed, 34 insertions(+), 11 deletions(-) diff --git a/crates/config/README.md b/crates/config/README.md index 04fd53bb6ea78..25100a5df7795 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -189,12 +189,13 @@ include_push_bytes = true [invariant] runs = 256 -depth = 15 +depth = 500 fail_on_revert = false call_override = false dictionary_weight = 80 include_storage = true include_push_bytes = true +shrink_run_limit = 5000 [fmt] line_length = 100 diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 869125324cc56..8c90e3cc340f4 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -26,7 +26,7 @@ pub struct InvariantConfig { #[serde(flatten)] pub dictionary: FuzzDictionaryConfig, /// The maximum number of attempts to shrink the sequence - pub shrink_run_limit: usize, + pub shrink_run_limit: u32, /// The maximum number of rejects via `vm.assume` which can be encountered during a single /// invariant run. pub max_assume_rejects: u32, @@ -40,11 +40,11 @@ impl Default for InvariantConfig { fn default() -> Self { InvariantConfig { runs: 256, - depth: 15, + depth: 500, fail_on_revert: false, call_override: false, dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() }, - shrink_run_limit: 2usize.pow(18_u32), + shrink_run_limit: 5000, max_assume_rejects: 65536, gas_report_samples: 256, failure_persist_dir: None, @@ -57,11 +57,11 @@ impl InvariantConfig { pub fn new(cache_dir: PathBuf) -> Self { InvariantConfig { runs: 256, - depth: 15, + depth: 500, fail_on_revert: false, call_override: false, dictionary: FuzzDictionaryConfig { dictionary_weight: 80, ..Default::default() }, - shrink_run_limit: 2usize.pow(18_u32), + shrink_run_limit: 5000, max_assume_rejects: 65536, gas_report_samples: 256, failure_persist_dir: Some(cache_dir), @@ -102,6 +102,7 @@ impl InlineConfigParser for InvariantConfig { "failure-persist-dir" => { conf_clone.failure_persist_dir = Some(PathBuf::from(value)) } + "shrink-run-limit" => conf_clone.shrink_run_limit = parse_config_u32(key, value)?, _ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?, } } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d6a157ecfb5a4..81dbff8a426da 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -3812,9 +3812,10 @@ mod tests { [invariant] runs = 256 - depth = 15 + depth = 500 fail_on_revert = false call_override = false + shrink_run_limit = 5000 "#, )?; diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 6e8dc929b58c2..b0004c8cbdf01 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -64,7 +64,7 @@ pub struct FailedInvariantCaseData { /// Inner fuzzing Sequence coming from overriding calls. pub inner_sequence: Vec>, /// Shrink run limit - pub shrink_run_limit: usize, + pub shrink_run_limit: u32, /// Fail on revert, used to check sequence when shrinking. pub fail_on_revert: bool, } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1bb70aa7eb4ec..152d21db51d93 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -110,6 +110,11 @@ pub struct TestArgs { #[arg(long)] pub fuzz_input_file: Option, + /// Max concurrent threads to use. + /// Default value is the number of available CPUs. + #[arg(long)] + pub max_threads: Option, + #[command(flatten)] filter: FilterArgs, @@ -217,6 +222,13 @@ impl TestArgs { /// /// Returns the test results for all matching tests. pub async fn execute_tests(self) -> Result { + // Set number of max threads to execute tests. + // If not specified then the number of threads determined by rayon will be used. + if let Some(test_threads) = self.max_threads { + trace!(target: "forge::test", "execute tests with {} max threads", test_threads); + rayon::ThreadPoolBuilder::new().num_threads(test_threads as usize).build_global()?; + } + // Merge all configs let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; @@ -627,7 +639,7 @@ fn list( #[cfg(test)] mod tests { use super::*; - use foundry_config::Chain; + use foundry_config::{Chain, InvariantConfig}; use foundry_test_utils::forgetest_async; #[test] @@ -664,6 +676,13 @@ mod tests { } forgetest_async!(gas_report_fuzz_invariant, |prj, _cmd| { + // speed up test by running with depth of 15 + let config = Config { + invariant: { InvariantConfig { depth: 15, ..Default::default() } }, + ..Default::default() + }; + prj.write_config(config); + prj.insert_ds_test(); prj.add_source( "Contracts.sol", diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index b2993151d3275..cd54526d68ddb 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -104,7 +104,7 @@ impl ForgeTestProfile { max_fuzz_dictionary_addresses: 10_000, max_fuzz_dictionary_values: 10_000, }, - shrink_run_limit: 2usize.pow(18u32), + shrink_run_limit: 5000, max_assume_rejects: 65536, gas_report_samples: 256, failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index cba0104a79af0..37b927e19877d 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -198,6 +198,7 @@ impl ExtTester { test_cmd.env("FOUNDRY_ETH_RPC_URL", crate::rpc::next_http_archive_rpc_endpoint()); test_cmd.env("FOUNDRY_FORK_BLOCK_NUMBER", fork_block.to_string()); } + test_cmd.env("FOUNDRY_INVARIANT_DEPTH", "15"); test_cmd.assert_non_empty_stdout(); } diff --git a/testdata/foundry.toml b/testdata/foundry.toml index 1fd8c610f730d..e9189bb008a32 100644 --- a/testdata/foundry.toml +++ b/testdata/foundry.toml @@ -16,7 +16,7 @@ ffi = false force = false invariant_fail_on_revert = false invariant_call_override = false -invariant_preserve_state = false +invariant_shrink_run_limit = 5000 gas_limit = 9223372036854775807 gas_price = 0 gas_reports = ["*"] From 5494c33bc7977b3537bd296e375431d938d44ca3 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 29 May 2024 17:47:18 +0530 Subject: [PATCH 1001/1963] fix(cast): set --block value as fork_block_number while tracing (#8009) fix(cast): set --block value as fork_block_number while Tracing --- crates/cast/bin/cmd/call.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 10a97ea00b572..b8e6330ba0379 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,6 +1,6 @@ use crate::tx::CastTxBuilder; use alloy_primitives::{TxKind, U256}; -use alloy_rpc_types::BlockId; +use alloy_rpc_types::{BlockId, BlockNumberOrTag}; use cast::Cast; use clap::Parser; use eyre::Result; @@ -114,7 +114,7 @@ impl CallArgs { sig = Some(data); } - let config = Config::from(ð); + let mut config = Config::from(ð); let provider = utils::get_provider(&config)?; let sender = eth.wallet.sender().await; @@ -153,6 +153,11 @@ impl CallArgs { let figment = Config::figment_with_root(find_project_root_path(None).unwrap()).merge(eth.rpc); let evm_opts = figment.extract::()?; + if let Some(BlockId::Number(BlockNumberOrTag::Number(block_number))) = self.block { + // Override Config `fork_block_number` (if set) with CLI value. + config.fork_block_number = Some(block_number); + } + let (env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; let mut executor = TracingExecutor::new(env, fork, evm_version, debug); From 7c52ecda14a81a93471437aab08edff1c2ced415 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 31 May 2024 19:52:13 +0530 Subject: [PATCH 1002/1963] fix(cheatcodes): inspector `call` (#8019) * use `call.bytecode_address` instead of `call.target_address` * nit Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * add test --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/src/inspector.rs | 2 +- testdata/default/cheats/ExpectCall.t.sol | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 855e0374f7858..968f2b4d77eb3 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -820,7 +820,7 @@ impl Inspector for Cheatcodes { // Handle expected calls // Grab the different calldatas expected. - if let Some(expected_calls_for_target) = self.expected_calls.get_mut(&(call.target_address)) + if let Some(expected_calls_for_target) = self.expected_calls.get_mut(&call.bytecode_address) { // Match every partial/full calldata for (calldata, (expected, actual_count)) in expected_calls_for_target { diff --git a/testdata/default/cheats/ExpectCall.t.sol b/testdata/default/cheats/ExpectCall.t.sol index 86a5290a92603..7d757101ad3b6 100644 --- a/testdata/default/cheats/ExpectCall.t.sol +++ b/testdata/default/cheats/ExpectCall.t.sol @@ -50,6 +50,16 @@ contract NestedContract { } } +contract SimpleCall { + function call() public {} +} + +contract ProxyWithDelegateCall { + function delegateCall(SimpleCall simpleCall) public { + address(simpleCall).delegatecall(abi.encodeWithSignature("call()")); + } +} + contract ExpectCallTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); @@ -249,6 +259,14 @@ contract ExpectCallTest is DSTest { vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); this.exposed_callTargetNTimes(target, 5, 5, 1); } + + /// Ensure expectCall works for Proxy DelegateCalls. Ref: + function testExpectCallForProxyDelegateCall() public { + ProxyWithDelegateCall proxyWithDelegateCall = new ProxyWithDelegateCall(); + SimpleCall simpleCall = new SimpleCall(); + vm.expectCall(address(simpleCall), abi.encodeWithSignature("call()")); + proxyWithDelegateCall.delegateCall(simpleCall); + } } contract ExpectCallCountTest is DSTest { From 08ef489e9ce73304b898058d031c8a6ac27759c0 Mon Sep 17 00:00:00 2001 From: Colin Kennedy Date: Fri, 31 May 2024 18:53:37 -0300 Subject: [PATCH 1003/1963] feat(foundryup): add a `--jobs` flag while building from source (#8021) * feat: add --jobs flag to foundryup this flag is passed on to cargo build. It's useful for people building on lower powered machines (<=16 GB Ram). * doc: clarify build / binary options * fix: rename jobs variable --------- Co-authored-by: Colin Kennedy --- foundryup/foundryup | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index f1e40b648f477..033e68d6ff179 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -6,6 +6,8 @@ FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin" FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1" +FOUNDRYUP_JOBS=$(nproc) + BINS=(forge cast anvil chisel) export RUSTFLAGS="${RUSTFLAGS:--C target-cpu=native}" @@ -24,6 +26,7 @@ main() { -p|--path) shift; FOUNDRYUP_LOCAL_REPO=$1;; -P|--pr) shift; FOUNDRYUP_PR=$1;; -C|--commit) shift; FOUNDRYUP_COMMIT=$1;; + -j|--jobs) shift; FOUNDRYUP_JOBS=$1;; --arch) shift; FOUNDRYUP_ARCH=$1;; --platform) shift; FOUNDRYUP_PLATFORM=$1;; -h|--help) @@ -60,7 +63,7 @@ main() { # Enter local repo and build say "installing from $FOUNDRYUP_LOCAL_REPO" cd "$FOUNDRYUP_LOCAL_REPO" - ensure cargo build --bins --release # need 4 speed + ensure cargo build --bins --release -j "$FOUNDRYUP_JOBS" # need 4 speed for bin in "${BINS[@]}"; do # Remove prior installations if they exist @@ -197,7 +200,7 @@ EOF fi # Build the repo and install the binaries locally to the .foundry bin directory. - ensure cargo build --bins --release + ensure cargo build --bins --release -j "$FOUNDRYUP_JOBS" for bin in "${BINS[@]}"; do for try_path in target/release/$bin target/release/$bin.exe; do if [ -f "$try_path" ]; then @@ -224,17 +227,20 @@ The installer for Foundry. Update or revert to a specific Foundry version with ease. +By default, the latest nightly version is installed from built binaries. + USAGE: foundryup OPTIONS: -h, --help Print help information - -v, --version Install a specific version - -b, --branch Install a specific branch - -P, --pr Install a specific Pull Request - -C, --commit Install a specific commit - -r, --repo Install from a remote GitHub repo (uses default branch if no other options are set) - -p, --path Install a local repository + -v, --version Install a specific version from built binaries + -b, --branch Build and install a specific branch + -P, --pr Build and install a specific Pull Request + -C, --commit Build and install a specific commit + -r, --repo Build and install from a remote GitHub repo (uses default branch if no other options are set) + -p, --path Build and install a local repository + -j, --jobs Number of CPUs to use for building Foundry (default: all CPUs) --arch Install a specific architecture (supports amd64 and arm64) --platform Install a specific platform (supports win32, linux, and darwin) EOF From f479e945c6be78bb902df12f9d683c3bb55e3fb0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 1 Jun 2024 01:07:01 +0300 Subject: [PATCH 1004/1963] chore: simplify debug traces (#8020) --- crates/cast/bin/cmd/call.rs | 15 +++---- crates/cast/bin/cmd/run.rs | 9 ++-- crates/cli/src/utils/cmd.rs | 53 ++++++++--------------- crates/evm/core/src/debug.rs | 13 +++++- crates/evm/evm/src/inspectors/debugger.rs | 6 +-- crates/evm/evm/src/inspectors/stack.rs | 4 +- 6 files changed, 43 insertions(+), 57 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index b8e6330ba0379..3b4e8da361857 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,7 +1,7 @@ use crate::tx::CastTxBuilder; use alloy_primitives::{TxKind, U256}; use alloy_rpc_types::{BlockId, BlockNumberOrTag}; -use cast::Cast; +use cast::{traces::TraceKind, Cast}; use clap::Parser; use eyre::Result; use foundry_cli::{ @@ -167,15 +167,12 @@ impl CallArgs { let trace = match tx_kind { TxKind::Create => { let deploy_result = executor.deploy(sender, input, value, None); - - match deploy_result { - Ok(deploy_result) => TraceResult::from(deploy_result), - Err(evm_err) => TraceResult::try_from(evm_err)?, - } - } - TxKind::Call(to) => { - TraceResult::from(executor.call_raw_committing(sender, to, input, value)?) + TraceResult::try_from(deploy_result)? } + TxKind::Call(to) => TraceResult::from_raw( + executor.call_raw_committing(sender, to, input, value)?, + TraceKind::Execution, + ), }; handle_traces(trace, &config, chain, labels, debug).await?; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 35ab17ec4f49e..32bd4fea69b02 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,7 +1,7 @@ use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::BlockTransactions; -use cast::revm::primitives::EnvWithHandlerCfg; +use cast::{revm::primitives::EnvWithHandlerCfg, traces::TraceKind}; use clap::Parser; use eyre::{Result, WrapErr}; use foundry_cli::{ @@ -215,13 +215,10 @@ impl RunArgs { if let Some(to) = tx.to { trace!(tx=?tx.hash, to=?to, "executing call transaction"); - TraceResult::from(executor.commit_tx_with_env(env)?) + TraceResult::from_raw(executor.commit_tx_with_env(env)?, TraceKind::Execution) } else { trace!(tx=?tx.hash, "executing create transaction"); - match executor.deploy_with_env(env, None) { - Ok(res) => TraceResult::from(res), - Err(err) => TraceResult::try_from(err)?, - } + TraceResult::try_from(executor.deploy_with_env(env, None))? } }; diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 96c9e2e5024c9..9e8f992414bec 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -323,19 +323,19 @@ pub fn read_constructor_args_file(constructor_args_path: PathBuf) -> Result, + pub debug: Option, pub gas_used: u64, } -impl From for TraceResult { - fn from(result: RawCallResult) -> Self { - let RawCallResult { gas_used, traces, reverted, debug, .. } = result; - +impl TraceResult { + /// Create a new [`TraceResult`] from a [`RawCallResult`]. + pub fn from_raw(raw: RawCallResult, trace_kind: TraceKind) -> Self { + let RawCallResult { gas_used, traces, reverted, debug, .. } = raw; Self { success: !reverted, - traces: vec![(TraceKind::Execution, traces.expect("traces is None"))], - debug: debug.unwrap_or_default(), + traces: traces.map(|arena| vec![(trace_kind, arena)]), + debug, gas_used, } } @@ -343,31 +343,18 @@ impl From for TraceResult { impl From for TraceResult { fn from(result: DeployResult) -> Self { - let RawCallResult { gas_used, traces, debug, .. } = result.raw; - Self { - success: true, - traces: vec![(TraceKind::Execution, traces.expect("traces is None"))], - debug: debug.unwrap_or_default(), - gas_used, - } + Self::from_raw(result.raw, TraceKind::Deployment) } } -impl TryFrom for TraceResult { +impl TryFrom> for TraceResult { type Error = EvmError; - fn try_from(err: EvmError) -> Result { - match err { - EvmError::Execution(err) => { - let RawCallResult { reverted, gas_used, traces, debug: run_debug, .. } = err.raw; - Ok(TraceResult { - success: !reverted, - traces: vec![(TraceKind::Execution, traces.expect("traces is None"))], - debug: run_debug.unwrap_or_default(), - gas_used, - }) - } - _ => Err(err), + fn try_from(value: Result) -> Result { + match value { + Ok(result) => Ok(Self::from(result)), + Err(EvmError::Execution(err)) => Ok(Self::from_raw(err.raw, TraceKind::Deployment)), + Err(err) => Err(err), } } } @@ -401,7 +388,7 @@ pub async fn handle_traces( let mut etherscan_identifier = EtherscanIdentifier::new(config, chain)?; if let Some(etherscan_identifier) = &mut etherscan_identifier { - for (_, trace) in &mut result.traces { + for (_, trace) in result.traces.as_deref_mut().unwrap_or_default() { decoder.identify(trace, etherscan_identifier); } } @@ -413,7 +400,7 @@ pub async fn handle_traces( Default::default() }; let mut debugger = Debugger::builder() - .debug_arena(&result.debug) + .debug_arena(result.debug.as_ref().expect("missing debug arena")) .decoder(&decoder) .sources(sources) .build(); @@ -426,12 +413,10 @@ pub async fn handle_traces( } pub async fn print_traces(result: &mut TraceResult, decoder: &CallTraceDecoder) -> Result<()> { - if result.traces.is_empty() { - panic!("No traces found") - } + let traces = result.traces.as_ref().expect("No traces found"); println!("Traces:"); - for (_, arena) in &result.traces { + for (_, arena) in traces { println!("{}", render_trace_arena(arena, decoder).await?); } println!(); diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 056bde54cfc61..21705f1289678 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -6,13 +6,24 @@ use revm_inspectors::tracing::types::CallKind; use serde::{Deserialize, Serialize}; /// An arena of [DebugNode]s -#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct DebugArena { /// The arena of nodes pub arena: Vec, } +impl Default for DebugArena { + fn default() -> Self { + Self::new() + } +} + impl DebugArena { + /// Creates a new debug arena. + pub const fn new() -> Self { + Self { arena: Vec::new() } + } + /// Pushes a new debug node into the arena pub fn push_node(&mut self, mut new_node: DebugNode) -> usize { fn recursively_push( diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs index c6b8a7cc5df4d..c970cd67103e0 100644 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ b/crates/evm/evm/src/inspectors/debugger.rs @@ -37,9 +37,7 @@ impl Debugger { pub fn exit(&mut self) { if let Some(parent_id) = self.arena.arena[self.head].parent { let DebugNode { depth, address, kind, .. } = self.arena.arena[parent_id]; - self.context = address; - self.head = - self.arena.push_node(DebugNode { depth, address, kind, ..Default::default() }); + self.enter(depth, address, kind); } } } @@ -59,7 +57,7 @@ impl Inspector for Debugger { let start = pc + 1; let end = start + push_size; let slice = &interp.contract.bytecode.bytecode()[start..end]; - assert!(slice.len() <= 32); + debug_assert!(slice.len() <= 32); let mut array = ArrayVec::new(); array.try_extend_from_slice(slice).unwrap(); array diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 10108c89137df..022586ae2cdd8 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -399,9 +399,7 @@ impl InspectorStack { labels: self .cheatcodes .as_ref() - .map(|cheatcodes| { - cheatcodes.labels.clone().into_iter().map(|l| (l.0, l.1)).collect() - }) + .map(|cheatcodes| cheatcodes.labels.clone()) .unwrap_or_default(), traces: self.tracer.map(|tracer| tracer.get_traces().clone()), debug: self.debugger.map(|debugger| debugger.arena), From a3071e5225122fd7c3d7a1759cabdfd17e314ded Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 1 Jun 2024 06:12:53 +0300 Subject: [PATCH 1005/1963] fix(foundryup): nproc does not exist on macos (#8024) --- foundryup/foundryup | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 033e68d6ff179..2dc94bfb49d3c 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -6,7 +6,7 @@ FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin" FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1" -FOUNDRYUP_JOBS=$(nproc) +FOUNDRYUP_JOBS="" BINS=(forge cast anvil chisel) @@ -40,6 +40,12 @@ main() { esac; shift done + CARGO_BUILD_ARGS=(--release) + + if [ -n "$FOUNDRYUP_JOBS" ]; then + CARGO_BUILD_ARGS+=(--jobs "$FOUNDRYUP_JOBS") + fi + # Print the banner after successfully parsing args banner @@ -63,7 +69,7 @@ main() { # Enter local repo and build say "installing from $FOUNDRYUP_LOCAL_REPO" cd "$FOUNDRYUP_LOCAL_REPO" - ensure cargo build --bins --release -j "$FOUNDRYUP_JOBS" # need 4 speed + ensure cargo build --bins "${CARGO_BUILD_ARGS[@]}" for bin in "${BINS[@]}"; do # Remove prior installations if they exist @@ -200,7 +206,7 @@ EOF fi # Build the repo and install the binaries locally to the .foundry bin directory. - ensure cargo build --bins --release -j "$FOUNDRYUP_JOBS" + ensure cargo build --bins "${CARGO_BUILD_ARGS[@]}" for bin in "${BINS[@]}"; do for try_path in target/release/$bin target/release/$bin.exe; do if [ -f "$try_path" ]; then From bdf05a8bb4aabc5683508c33e90f421b46a27261 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 1 Jun 2024 12:38:55 +0300 Subject: [PATCH 1006/1963] perf: prefill fuzz dictionary with 0 (#8027) --- Cargo.lock | 1 - crates/evm/evm/Cargo.toml | 1 - crates/evm/evm/src/executors/invariant/mod.rs | 9 +- crates/evm/fuzz/src/invariant/mod.rs | 20 ++-- crates/evm/fuzz/src/strategies/state.rs | 113 ++++++++++-------- 5 files changed, 80 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc0e58724c735..59daf146b6860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3503,7 +3503,6 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "arrayvec", - "const-hex", "eyre", "foundry-cheatcodes", "foundry-common", diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 72f4a6d171567..5168c35e02725 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -43,7 +43,6 @@ revm-inspectors.workspace = true arrayvec.workspace = true eyre = "0.6" -hex.workspace = true parking_lot = "0.12" proptest = "1" thiserror = "1" diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index be8dbf2baf797..9d4a9f4c016e4 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -321,8 +321,8 @@ impl<'a> InvariantExecutor<'a> { Ok(()) }); - trace!(target: "forge::test::invariant::fuzz_fixtures", "{:?}", fuzz_fixtures); - trace!(target: "forge::test::invariant::dictionary", "{:?}", fuzz_state.dictionary_read().values().iter().map(hex::encode).collect::>()); + trace!(?fuzz_fixtures); + trace!(state_len = fuzz_state.dictionary_read().len()); let (reverts, error) = failures.into_inner().into_inner(); @@ -678,10 +678,9 @@ fn collect_data( } // Collect values from fuzzed call result and add them to fuzz dictionary. - let (fuzzed_contract_abi, fuzzed_function) = fuzzed_contracts.fuzzed_artifacts(tx); fuzz_state.collect_values_from_call( - fuzzed_contract_abi.as_ref(), - fuzzed_function.as_ref(), + fuzzed_contracts, + tx, &call_result.result, &call_result.logs, &*state_changeset, diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index 7c3a1ffc086d3..e83c595498d29 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -28,15 +28,21 @@ impl FuzzRunIdentifiedContracts { } /// Returns fuzzed contract abi and fuzzed function from address and provided calldata. + /// /// Used to decode return values and logs in order to add values into fuzz dictionary. - pub fn fuzzed_artifacts(&self, tx: &BasicTxDetails) -> (Option, Option) { - match self.targets.lock().get(&tx.call_details.target) { - Some((_, abi, _)) => ( - Some(abi.to_owned()), - abi.functions().find(|f| f.selector() == tx.call_details.calldata[..4]).cloned(), - ), + pub fn with_fuzzed_artifacts( + &self, + tx: &BasicTxDetails, + f: impl FnOnce(Option<&JsonAbi>, Option<&Function>), + ) { + let targets = self.targets.lock(); + let (abi, abi_f) = match targets.get(&tx.call_details.target) { + Some((_, abi, _)) => { + (Some(abi), abi.functions().find(|f| f.selector() == tx.call_details.calldata[..4])) + } None => (None, None), - } + }; + f(abi, abi_f); } } diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 81aa93a5aec22..a138f4507c646 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,4 +1,4 @@ -use crate::invariant::{ArtifactFilters, FuzzRunIdentifiedContracts}; +use crate::invariant::{ArtifactFilters, BasicTxDetails, FuzzRunIdentifiedContracts}; use alloy_dyn_abi::{DynSolType, DynSolValue, EventExt, FunctionExt}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, Log, B256, U256}; @@ -18,6 +18,12 @@ use std::{ sync::Arc, }; +/// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). +/// +/// This is to limit the performance impact of fuzz tests that might deploy arbitrarily sized +/// bytecode (as is the case with Solmate). +const PUSH_BYTE_ANALYSIS_LIMIT: usize = 24 * 1024; + /// A set of arbitrary 32 byte data from the VM used to generate values for the strategy. /// /// Wrapped in a shareable container. @@ -49,16 +55,18 @@ impl EvmFuzzState { /// the given [FuzzDictionaryConfig]. pub fn collect_values_from_call( &self, - target_abi: Option<&JsonAbi>, - target_function: Option<&Function>, + fuzzed_contracts: &FuzzRunIdentifiedContracts, + tx: &BasicTxDetails, result: &Bytes, logs: &[Log], state_changeset: &StateChangeset, run_depth: u32, ) { let mut dict = self.inner.write(); - dict.insert_result_values(target_function, result, run_depth); - dict.insert_logs_values(target_abi, logs, run_depth); + fuzzed_contracts.with_fuzzed_artifacts(tx, |target_abi, target_function| { + dict.insert_logs_values(target_abi, logs, run_depth); + dict.insert_result_values(target_function, result, run_depth); + }); dict.insert_state_values(state_changeset); } @@ -104,7 +112,14 @@ impl fmt::Debug for FuzzDictionary { impl FuzzDictionary { pub fn new(config: FuzzDictionaryConfig) -> Self { - Self { config, ..Default::default() } + let mut dictionary = Self { config, ..Default::default() }; + dictionary.prefill(); + dictionary + } + + /// Insert common values into the dictionary at initialization. + fn prefill(&mut self) { + self.insert_value([0; 32], false); } /// Insert values from initial db state into fuzz dictionary. @@ -217,10 +232,42 @@ impl FuzzDictionary { // Insert push bytes if let Some(code) = account_info.code.clone() { self.insert_address(*address, collected); - for push_byte in collect_push_bytes(&code.bytes()) { - self.insert_value(push_byte, collected); + self.collect_push_bytes(code.bytes_slice(), collected); + } + } + } + + fn collect_push_bytes(&mut self, code: &[u8], collected: bool) { + let mut i = 0; + let len = code.len().min(PUSH_BYTE_ANALYSIS_LIMIT); + while i < len { + let op = code[i]; + if (opcode::PUSH1..=opcode::PUSH32).contains(&op) { + let push_size = (op - opcode::PUSH1 + 1) as usize; + let push_start = i + 1; + let push_end = push_start + push_size; + // As a precaution, if a fuzz test deploys malformed bytecode (such as using + // `CREATE2`) this will terminate the loop early. + if push_start > code.len() || push_end > code.len() { + break; + } + + let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); + // Also add the value below and above the push value to the dictionary. + if push_value != U256::ZERO { + // Never add 0 to the dictionary as it's always present, and it's a pretty + // common value that this is worth it. + self.insert_value(push_value.to_be_bytes(), collected); + + self.insert_value((push_value - U256::from(1)).to_be_bytes(), collected); } + if push_value != U256::MAX { + self.insert_value((push_value + U256::from(1)).to_be_bytes(), collected); + } + + i += push_size; } + i += 1; } } @@ -283,11 +330,18 @@ impl FuzzDictionary { } } - #[inline] pub fn values(&self) -> &IndexSet<[u8; 32]> { &self.state_values } + pub fn len(&self) -> usize { + self.state_values.len() + } + + pub fn is_empty(&self) -> bool { + self.state_values.is_empty() + } + #[inline] pub fn samples(&self, param_type: DynSolType) -> Option<&IndexSet<[u8; 32]>> { self.sample_values.get(¶m_type) @@ -312,47 +366,6 @@ impl FuzzDictionary { } } -/// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). -/// -/// This is to limit the performance impact of fuzz tests that might deploy arbitrarily sized -/// bytecode (as is the case with Solmate). -const PUSH_BYTE_ANALYSIS_LIMIT: usize = 24 * 1024; - -/// Collects all push bytes from the given bytecode. -fn collect_push_bytes(code: &[u8]) -> Vec<[u8; 32]> { - let mut bytes: Vec<[u8; 32]> = Vec::new(); - // We use [SpecId::LATEST] since we do not really care what spec it is - we are not interested - // in gas costs. - let mut i = 0; - while i < code.len().min(PUSH_BYTE_ANALYSIS_LIMIT) { - let op = code[i]; - if (opcode::PUSH1..=opcode::PUSH32).contains(&op) { - let push_size = (op - opcode::PUSH1 + 1) as usize; - let push_start = i + 1; - let push_end = push_start + push_size; - // As a precaution, if a fuzz test deploys malformed bytecode (such as using `CREATE2`) - // this will terminate the loop early. - if push_start > code.len() || push_end > code.len() { - return bytes; - } - - let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); - bytes.push(push_value.to_be_bytes()); - // also add the value below and above the push value to the dictionary. - if push_value != U256::ZERO { - bytes.push((push_value - U256::from(1)).to_be_bytes()); - } - if push_value != U256::MAX { - bytes.push((push_value + U256::from(1)).to_be_bytes()); - } - - i += push_size; - } - i += 1; - } - bytes -} - /// Collects all created contracts from a StateChangeset which haven't been discovered yet. Stores /// them at `targeted_contracts` and `created_contracts`. pub fn collect_created_contracts( From 80986a7eff10ae4ddba7e757fc073afb5e079569 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 1 Jun 2024 12:42:14 +0300 Subject: [PATCH 1007/1963] refactor(coverage): refactor coverage analysis (#8025) --- Cargo.lock | 2 + Cargo.toml | 5 +- crates/anvil/Cargo.toml | 21 ++- crates/cast/Cargo.toml | 10 +- crates/chisel/Cargo.toml | 20 +- crates/doc/Cargo.toml | 2 +- crates/evm/core/src/decode.rs | 5 +- crates/evm/core/src/ic.rs | 20 ++ crates/evm/coverage/Cargo.toml | 1 + crates/evm/coverage/src/analysis.rs | 232 ++++++++++++----------- crates/evm/coverage/src/anchors.rs | 89 +++++---- crates/evm/coverage/src/lib.rs | 28 ++- crates/evm/traces/Cargo.toml | 8 +- crates/evm/traces/src/decoder/mod.rs | 3 +- crates/forge/Cargo.toml | 14 +- crates/forge/bin/cmd/coverage.rs | 263 +++++++++++++-------------- crates/forge/src/coverage.rs | 2 +- 17 files changed, 396 insertions(+), 329 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59daf146b6860..b77ed1a3362f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3566,6 +3566,7 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-evm-core", + "rayon", "revm", "rustc-hash", "semver 1.0.23", @@ -3616,6 +3617,7 @@ dependencies = [ "itertools 0.13.0", "once_cell", "revm-inspectors", + "rustc-hash", "serde", "tempfile", "tokio", diff --git a/Cargo.toml b/Cargo.toml index d5b4bdb410ab4..8d0264d455a10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,17 +82,17 @@ scrypt.opt-level = 3 [profile.local] inherits = "dev" opt-level = 1 +debug-assertions = false strip = "debuginfo" panic = "abort" codegen-units = 16 # Like release, but with full debug symbols and with stack unwinds. Useful for e.g. `perf`. [profile.debug-fast] -inherits = "release" +inherits = "local" debug = true strip = "none" panic = "unwind" -incremental = false # Optimized release profile. [profile.release] @@ -216,6 +216,7 @@ num-format = "0.4.4" yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } tempfile = "3.10" tokio = "1" +rayon = "1" axum = "0.7" hyper = "1.0" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 9ca41a520de5e..96c0a2071e1fa 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -16,7 +16,11 @@ path = "src/anvil.rs" required-features = ["cli"] [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # foundry internal @@ -31,7 +35,12 @@ foundry-evm.workspace = true # evm support bytes = "1.4.0" k256.workspace = true -revm = { workspace = true, features = ["std", "serde", "memory_limit", "c-kzg"] } +revm = { workspace = true, features = [ + "std", + "serde", + "memory_limit", + "c-kzg", +] } alloy-primitives = { workspace = true, features = ["serde"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-contract = { workspace = true, features = ["pubsub"] } @@ -78,7 +87,11 @@ rand = "0.8" eyre.workspace = true # cli -clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true } +clap = { version = "4", features = [ + "derive", + "env", + "wrap_help", +], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true auto_impl = "1" @@ -101,7 +114,7 @@ similar-asserts.workspace = true tokio = { workspace = true, features = ["full"] } [features] -default = ["cli"] +default = ["cli", "jemalloc"] cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"] cli = ["tokio/full", "cmd", "fdlimit"] asm-keccak = ["alloy-primitives/asm-keccak"] diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index bf180b9b5598b..443e5992c5372 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -15,7 +15,11 @@ name = "cast" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # lib @@ -48,7 +52,7 @@ eyre.workspace = true futures = "0.3" hex.workspace = true rand.workspace = true -rayon = "1" +rayon.workspace = true serde_json.workspace = true serde.workspace = true @@ -83,7 +87,7 @@ async-trait = "0.1" criterion = "0.5" [features] -default = ["rustls"] +default = ["rustls", "jemalloc"] rustls = ["foundry-cli/rustls", "foundry-wallets/rustls"] openssl = ["foundry-cli/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index fc8a2a7822e60..f5e9b7b023fb1 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -1,6 +1,9 @@ [package] name = "chisel" -authors = ["clabby ", "asnared "] +authors = [ + "clabby ", + "asnared ", +] description = "Fast, utilitarian, and verbose Solidity REPL" version.workspace = true @@ -15,7 +18,11 @@ name = "chisel" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # forge @@ -28,7 +35,12 @@ foundry-config.workspace = true foundry-evm.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary"] } -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } alloy-json-abi.workspace = true alloy-rpc-types.workspace = true @@ -59,7 +71,7 @@ serial_test = "3" tracing-subscriber.workspace = true [features] -default = ["rustls"] +default = ["rustls", "jemalloc"] rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-compilers/openssl", "reqwest/default-tls"] asm-keccak = ["alloy-primitives/asm-keccak"] diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 73368bd9f1f26..1965befb88313 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -24,7 +24,7 @@ eyre.workspace = true itertools.workspace = true mdbook = { version = "0.4", default-features = false, features = ["search"] } once_cell = "1" -rayon = "1" +rayon.workspace = true serde_json.workspace = true serde.workspace = true solang-parser.workspace = true diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index bf82c2d349208..8b09316e30482 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -8,7 +8,8 @@ use alloy_sol_types::{SolCall, SolError, SolEventInterface, SolInterface, SolVal use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; -use std::{collections::HashMap, sync::OnceLock}; +use rustc_hash::FxHashMap; +use std::sync::OnceLock; /// Decode a set of logs, only returning logs from DSTest logging events and Hardhat's `console.log` pub fn decode_console_logs(logs: &[Log]) -> Vec { @@ -27,7 +28,7 @@ pub fn decode_console_log(log: &Log) -> Option { #[derive(Clone, Debug, Default)] pub struct RevertDecoder { /// The custom errors to use for decoding. - pub errors: HashMap>, + pub errors: FxHashMap>, } impl Default for &RevertDecoder { diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index fa2b5efd55018..c2792ab87ba4d 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -14,6 +14,16 @@ impl PcIcMap { Self { inner: make_map::(code) } } + /// Returns the length of the map. + pub fn len(&self) -> usize { + self.inner.len() + } + + /// Returns `true` if the map is empty. + pub fn is_empty(&self) -> bool { + self.inner.is_empty() + } + /// Returns the instruction counter for the given program counter. pub fn get(&self, pc: usize) -> Option { self.inner.get(&pc).copied() @@ -33,6 +43,16 @@ impl IcPcMap { Self { inner: make_map::(code) } } + /// Returns the length of the map. + pub fn len(&self) -> usize { + self.inner.len() + } + + /// Returns `true` if the map is empty. + pub fn is_empty(&self) -> bool { + self.inner.is_empty() + } + /// Returns the program counter for the given instruction counter. pub fn get(&self, ic: usize) -> Option { self.inner.get(&ic).copied() diff --git a/crates/evm/coverage/Cargo.toml b/crates/evm/coverage/Cargo.toml index 6a3dc92ff3b32..57a7a9f2bab0c 100644 --- a/crates/evm/coverage/Cargo.toml +++ b/crates/evm/coverage/Cargo.toml @@ -21,3 +21,4 @@ revm.workspace = true semver = "1" tracing = "0.1" rustc-hash.workspace = true +rayon.workspace = true diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 040da5a0f4fa9..cfcb7406f6a32 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -1,9 +1,9 @@ -use super::{ContractId, CoverageItem, CoverageItemKind, SourceLocation}; +use super::{CoverageItem, CoverageItemKind, SourceLocation}; use foundry_common::TestFunctionExt; use foundry_compilers::artifacts::ast::{self, Ast, Node, NodeType}; +use rayon::prelude::*; use rustc_hash::FxHashMap; -use semver::Version; -use std::collections::HashMap; +use std::sync::Arc; /// A visitor that walks the AST of a single contract and finds coverage items. #[derive(Clone, Debug)] @@ -14,7 +14,7 @@ pub struct ContractVisitor<'a> { source: &'a str, /// The name of the contract being walked. - contract_name: String, + contract_name: &'a Arc, /// The current branch ID branch_id: usize, @@ -26,14 +26,14 @@ pub struct ContractVisitor<'a> { } impl<'a> ContractVisitor<'a> { - pub fn new(source_id: usize, source: &'a str, contract_name: String) -> Self { + pub fn new(source_id: usize, source: &'a str, contract_name: &'a Arc) -> Self { Self { source_id, source, contract_name, branch_id: 0, last_line: 0, items: Vec::new() } } - pub fn visit(mut self, contract_ast: Node) -> eyre::Result { + pub fn visit_contract(&mut self, node: &Node) -> eyre::Result<()> { // Find all functions and walk their AST - for node in contract_ast.nodes { - match &node.node_type { + for node in &node.nodes { + match node.node_type { NodeType::FunctionDefinition => { self.visit_function_definition(node)?; } @@ -43,11 +43,10 @@ impl<'a> ContractVisitor<'a> { _ => {} } } - - Ok(self) + Ok(()) } - fn visit_function_definition(&mut self, mut node: Node) -> eyre::Result<()> { + fn visit_function_definition(&mut self, node: &Node) -> eyre::Result<()> { let name: String = node.attribute("name").ok_or_else(|| eyre::eyre!("Function has no name"))?; @@ -58,46 +57,47 @@ impl<'a> ContractVisitor<'a> { return Ok(()) } - match node.body.take() { + match &node.body { Some(body) => { self.push_item(CoverageItem { kind: CoverageItemKind::Function { name }, loc: self.source_location_for(&node.src), hits: 0, }); - self.visit_block(*body) + self.visit_block(body) } _ => Ok(()), } } - fn visit_modifier_definition(&mut self, mut node: Node) -> eyre::Result<()> { + fn visit_modifier_definition(&mut self, node: &Node) -> eyre::Result<()> { let name: String = node.attribute("name").ok_or_else(|| eyre::eyre!("Modifier has no name"))?; - match node.body.take() { + match &node.body { Some(body) => { self.push_item(CoverageItem { kind: CoverageItemKind::Function { name }, loc: self.source_location_for(&node.src), hits: 0, }); - self.visit_block(*body) + self.visit_block(body) } _ => Ok(()), } } - fn visit_block(&mut self, node: Node) -> eyre::Result<()> { + fn visit_block(&mut self, node: &Node) -> eyre::Result<()> { let statements: Vec = node.attribute("statements").unwrap_or_default(); - for statement in statements { + for statement in &statements { self.visit_statement(statement)?; } Ok(()) } - fn visit_statement(&mut self, node: Node) -> eyre::Result<()> { + + fn visit_statement(&mut self, node: &Node) -> eyre::Result<()> { // TODO: YulSwitch, YulForLoop, YulFunctionDefinition, YulVariableDeclaration match node.node_type { // Blocks @@ -106,7 +106,8 @@ impl<'a> ContractVisitor<'a> { } // Inline assembly block NodeType::InlineAssembly => self.visit_block( - node.attribute("AST") + &node + .attribute("AST") .ok_or_else(|| eyre::eyre!("inline assembly block with no AST attribute"))?, ), // Simple statements @@ -137,7 +138,7 @@ impl<'a> ContractVisitor<'a> { hits: 0, }); if let Some(expr) = node.attribute("expression") { - self.visit_expression(expr)?; + self.visit_expression(&expr)?; } Ok(()) } @@ -150,47 +151,54 @@ impl<'a> ContractVisitor<'a> { hits: 0, }); if let Some(expr) = node.attribute("initialValue") { - self.visit_expression(expr)?; + self.visit_expression(&expr)?; } Ok(()) } // While loops NodeType::DoWhileStatement | NodeType::WhileStatement => { self.visit_expression( - node.attribute("condition") + &node + .attribute("condition") .ok_or_else(|| eyre::eyre!("while statement had no condition"))?, )?; - let body = - node.body.ok_or_else(|| eyre::eyre!("while statement had no body node"))?; - self.visit_block_or_statement(*body) + let body = node + .body + .as_deref() + .ok_or_else(|| eyre::eyre!("while statement had no body node"))?; + self.visit_block_or_statement(body) } // For loops NodeType::ForStatement => { if let Some(stmt) = node.attribute("initializationExpression") { - self.visit_statement(stmt)?; + self.visit_statement(&stmt)?; } if let Some(expr) = node.attribute("condition") { - self.visit_expression(expr)?; + self.visit_expression(&expr)?; } if let Some(stmt) = node.attribute("loopExpression") { - self.visit_statement(stmt)?; + self.visit_statement(&stmt)?; } - let body = - node.body.ok_or_else(|| eyre::eyre!("for statement had no body node"))?; - self.visit_block_or_statement(*body) + let body = node + .body + .as_deref() + .ok_or_else(|| eyre::eyre!("for statement had no body node"))?; + self.visit_block_or_statement(body) } // Expression statement NodeType::ExpressionStatement | NodeType::YulExpressionStatement => self .visit_expression( - node.attribute("expression") + &node + .attribute("expression") .ok_or_else(|| eyre::eyre!("expression statement had no expression"))?, ), // If statement NodeType::IfStatement => { self.visit_expression( - node.attribute("condition") + &node + .attribute("condition") .ok_or_else(|| eyre::eyre!("while statement had no condition"))?, )?; @@ -224,22 +232,25 @@ impl<'a> ContractVisitor<'a> { ); // Process the true branch - self.visit_block_or_statement(true_body)?; + self.visit_block_or_statement(&true_body)?; // Process the false branch - let false_body: Option = node.attribute("falseBody"); - if let Some(false_body) = false_body { - self.visit_block_or_statement(false_body)?; + if let Some(false_body) = node.attribute("falseBody") { + self.visit_block_or_statement(&false_body)?; } Ok(()) } NodeType::YulIf => { self.visit_expression( - node.attribute("condition") + &node + .attribute("condition") .ok_or_else(|| eyre::eyre!("yul if statement had no condition"))?, )?; - let body = node.body.ok_or_else(|| eyre::eyre!("yul if statement had no body"))?; + let body = node + .body + .as_deref() + .ok_or_else(|| eyre::eyre!("yul if statement had no body"))?; // We need to store the current branch ID here since visiting the body of either of // the if blocks may increase `self.branch_id` in the case of nested if statements. @@ -254,7 +265,7 @@ impl<'a> ContractVisitor<'a> { loc: self.source_location_for(&node.src), hits: 0, }); - self.visit_block(*body)?; + self.visit_block(body)?; Ok(()) } @@ -263,7 +274,8 @@ impl<'a> ContractVisitor<'a> { // TODO: Clauses // TODO: This is branching, right? self.visit_expression( - node.attribute("externalCall") + &node + .attribute("externalCall") .ok_or_else(|| eyre::eyre!("try statement had no call"))?, ) } @@ -274,7 +286,7 @@ impl<'a> ContractVisitor<'a> { } } - fn visit_expression(&mut self, node: Node) -> eyre::Result<()> { + fn visit_expression(&mut self, node: &Node) -> eyre::Result<()> { // TODO // elementarytypenameexpression // memberaccess @@ -301,11 +313,11 @@ impl<'a> ContractVisitor<'a> { // There could possibly a function call in the left or right expression // e.g: callFunc(a) + callFunc(b) if let Some(expr) = node.attribute("leftExpression") { - self.visit_expression(expr)?; + self.visit_expression(&expr)?; } if let Some(expr) = node.attribute("rightExpression") { - self.visit_expression(expr)?; + self.visit_expression(&expr)?; } Ok(()) @@ -352,7 +364,7 @@ impl<'a> ContractVisitor<'a> { } } - fn visit_block_or_statement(&mut self, node: Node) -> eyre::Result<()> { + fn visit_block_or_statement(&mut self, node: &Node) -> eyre::Result<()> { match node.node_type { NodeType::Block => self.visit_block(node), NodeType::Break | @@ -420,6 +432,7 @@ impl<'a> ContractVisitor<'a> { } } +/// [`SourceAnalyzer`] result type. #[derive(Debug)] pub struct SourceAnalysis { /// A collection of coverage items. @@ -427,47 +440,15 @@ pub struct SourceAnalysis { } /// Analyzes a set of sources to find coverage items. -#[derive(Clone, Debug, Default)] -pub struct SourceAnalyzer { - /// A map of source IDs to their source code - sources: FxHashMap, - /// A map of contract IDs to their AST nodes. - contracts: HashMap, - /// A collection of coverage items. - items: Vec, +#[derive(Debug)] +pub struct SourceAnalyzer<'a> { + sources: &'a SourceFiles<'a>, } -impl SourceAnalyzer { +impl<'a> SourceAnalyzer<'a> { /// Creates a new source analyzer. - /// - /// The source analyzer expects all given sources to belong to the same compilation job - /// (defined by `version`). - pub fn new( - version: Version, - asts: FxHashMap, - sources: FxHashMap, - ) -> eyre::Result { - let mut analyzer = SourceAnalyzer { sources, ..Default::default() }; - - // TODO: Skip interfaces - for (source_id, ast) in asts.into_iter() { - for child in ast.nodes { - if !matches!(child.node_type, NodeType::ContractDefinition) { - continue - } - - let contract_id = ContractId { - version: version.clone(), - source_id, - contract_name: child - .attribute("name") - .ok_or_else(|| eyre::eyre!("Contract has no name"))?, - }; - analyzer.contracts.insert(contract_id, child); - } - } - - Ok(analyzer) + pub fn new(data: &'a SourceFiles<'a>) -> Self { + Self { sources: data } } /// Analyzes contracts in the sources held by the source analyzer. @@ -483,33 +464,64 @@ impl SourceAnalyzer { /// Note: Source IDs are only unique per compilation job; that is, a code base compiled with /// two different solc versions will produce overlapping source IDs if the compiler version is /// not taken into account. - pub fn analyze(mut self) -> eyre::Result { - for (contract_id, ast) in self.contracts { - let ContractVisitor { items, .. } = ContractVisitor::new( - contract_id.source_id, - self.sources.get(&contract_id.source_id).ok_or_else(|| { - eyre::eyre!( - "We should have the source code for source ID {}", - contract_id.source_id - ) - })?, - contract_id.contract_name.clone(), - ) - .visit(ast)?; - - let is_test = items.iter().any(|item| { - if let CoverageItemKind::Function { name } = &item.kind { - name.is_test() - } else { - false - } - }); + pub fn analyze(&self) -> eyre::Result { + let items = self + .sources + .sources + .par_iter() + .flat_map_iter(|(&source_id, SourceFile { source, ast })| { + ast.nodes.iter().map(move |node| { + if !matches!(node.node_type, NodeType::ContractDefinition) { + return Ok(vec![]); + } - if !is_test { - self.items.extend(items); - } - } + // Skip interfaces which have no function implementations. + let contract_kind: String = node + .attribute("contractKind") + .ok_or_else(|| eyre::eyre!("Contract has no kind"))?; + if contract_kind == "interface" { + return Ok(vec![]); + } - Ok(SourceAnalysis { items: self.items }) + let name = node + .attribute("name") + .ok_or_else(|| eyre::eyre!("Contract has no name"))?; + + let mut visitor = ContractVisitor::new(source_id, source, &name); + visitor.visit_contract(node)?; + let mut items = visitor.items; + + let is_test = items.iter().any(|item| { + if let CoverageItemKind::Function { name } = &item.kind { + name.is_test() + } else { + false + } + }); + if is_test { + items.clear(); + } + + Ok(items) + }) + }) + .collect::>>>()?; + Ok(SourceAnalysis { items: items.concat() }) } } + +/// A list of versioned sources and their ASTs. +#[derive(Debug, Default)] +pub struct SourceFiles<'a> { + /// The versioned sources. + pub sources: FxHashMap>, +} + +/// The source code and AST of a file. +#[derive(Debug)] +pub struct SourceFile<'a> { + /// The source code. + pub source: String, + /// The AST of the source code. + pub ast: &'a Ast, +} diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index a1992d47ad14f..f05f7c287596d 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -1,52 +1,47 @@ -use std::collections::HashMap; - use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; -use alloy_primitives::Bytes; +use eyre::ensure; use foundry_compilers::sourcemap::{SourceElement, SourceMap}; use foundry_evm_core::utils::IcPcMap; -use revm::{ - interpreter::opcode::{self, PUSH1, PUSH32}, - primitives::HashSet, -}; +use revm::interpreter::opcode; +use rustc_hash::{FxHashMap, FxHashSet}; /// Attempts to find anchors for the given items using the given source map and bytecode. pub fn find_anchors( - bytecode: &Bytes, + bytecode: &[u8], source_map: &SourceMap, ic_pc_map: &IcPcMap, items: &[CoverageItem], - items_by_source_id: &HashMap>, + items_by_source_id: &FxHashMap>, ) -> Vec { - // Prepare coverage items from all sources referenced in the source map - let potential_item_ids = source_map + let mut seen = FxHashSet::default(); + source_map .iter() .filter_map(|element| items_by_source_id.get(&(element.index? as usize))) .flatten() - .collect::>(); - - potential_item_ids - .into_iter() - .filter_map(|item_id| { - let item = &items[*item_id]; + .filter_map(|&item_id| { + if !seen.insert(item_id) { + return None; + } + let item = &items[item_id]; match item.kind { CoverageItemKind::Branch { path_id, .. } => { - match find_anchor_branch(bytecode, source_map, *item_id, &item.loc) { + match find_anchor_branch(bytecode, source_map, item_id, &item.loc) { Ok(anchors) => match path_id { 0 => Some(anchors.0), 1 => Some(anchors.1), _ => panic!("Too many paths for branch"), }, Err(e) => { - warn!("Could not find anchor for item: {}, error: {e}", item); + warn!("Could not find anchor for item {item}: {e}"); None } } } - _ => match find_anchor_simple(source_map, ic_pc_map, *item_id, &item.loc) { + _ => match find_anchor_simple(source_map, ic_pc_map, item_id, &item.loc) { Ok(anchor) => Some(anchor), Err(e) => { - warn!("Could not find anchor for item: {}, error: {e}", item); + warn!("Could not find anchor for item {item}: {e}"); None } }, @@ -62,13 +57,10 @@ pub fn find_anchor_simple( item_id: usize, loc: &SourceLocation, ) -> eyre::Result { - let instruction = source_map - .iter() - .enumerate() - .find_map(|(ic, element)| is_in_source_range(element, loc).then_some(ic)) - .ok_or_else(|| { - eyre::eyre!("Could not find anchor: No matching instruction in range {}", loc) - })?; + let instruction = + source_map.iter().position(|element| is_in_source_range(element, loc)).ok_or_else( + || eyre::eyre!("Could not find anchor: No matching instruction in range {loc}"), + )?; Ok(ItemAnchor { instruction: ic_pc_map.get(instruction).ok_or_else(|| { @@ -107,7 +99,7 @@ pub fn find_anchor_simple( /// counter of the first branch, and return an item for that program counter, and the /// program counter immediately after the JUMPI instruction. pub fn find_anchor_branch( - bytecode: &Bytes, + bytecode: &[u8], source_map: &SourceMap, item_id: usize, loc: &SourceLocation, @@ -118,14 +110,14 @@ pub fn find_anchor_branch( let mut anchors: Option<(ItemAnchor, ItemAnchor)> = None; let mut pc = 0; let mut cumulative_push_size = 0; - while pc < bytecode.0.len() { - let op = bytecode.0[pc]; + while pc < bytecode.len() { + let op = bytecode[pc]; // We found a push, so we do some PC -> IC translation accounting, but we also check if // this push is coupled with the JUMPI we are interested in. // Check if Opcode is PUSH - if (PUSH1..=PUSH32).contains(&op) { + if (opcode::PUSH1..=opcode::PUSH32).contains(&op) { let element = if let Some(element) = source_map.get(pc - cumulative_push_size) { element } else { @@ -141,29 +133,25 @@ pub fn find_anchor_branch( // Check if we are in the source range we are interested in, and if the next opcode // is a JUMPI - if is_in_source_range(element, loc) && bytecode.0[pc + 1] == opcode::JUMPI { + if is_in_source_range(element, loc) && bytecode[pc + 1] == opcode::JUMPI { // We do not support program counters bigger than usize. This is also an // assumption in REVM, so this is just a sanity check. - if push_size > 8 { - panic!("We found the anchor for the branch, but it refers to a program counter bigger than 64 bits."); - } + ensure!(push_size <= 8, "jump destination overflow"); // Convert the push bytes for the second branch's PC to a usize let push_bytes_start = pc - push_size + 1; - let mut pc_bytes: [u8; 8] = [0; 8]; - for (i, push_byte) in - bytecode.0[push_bytes_start..push_bytes_start + push_size].iter().enumerate() - { - pc_bytes[8 - push_size + i] = *push_byte; - } - + let push_bytes = &bytecode[push_bytes_start..push_bytes_start + push_size]; + let mut pc_bytes = [0u8; 8]; + pc_bytes[8 - push_size..].copy_from_slice(push_bytes); + let pc = u64::from_be_bytes(pc_bytes); + let pc = usize::try_from(pc).expect("PC is too big"); anchors = Some(( ItemAnchor { item_id, // The first branch is the opcode directly after JUMPI instruction: pc + 2, }, - ItemAnchor { item_id, instruction: usize::from_be_bytes(pc_bytes) }, + ItemAnchor { item_id, instruction: pc }, )); } } @@ -175,14 +163,25 @@ pub fn find_anchor_branch( /// Calculates whether `element` is within the range of the target `location`. fn is_in_source_range(element: &SourceElement, location: &SourceLocation) -> bool { + // Source IDs must match. let source_ids_match = element.index.map_or(false, |a| a as usize == location.source_id); + if !source_ids_match { + return false; + } // Needed because some source ranges in the source map mark the entire contract... let is_within_start = element.offset >= location.start; + if !is_within_start { + return false; + } let start_of_ranges = location.start.max(element.offset); let end_of_ranges = (location.start + location.length.unwrap_or_default()).min(element.offset + element.length); + let within_ranges = start_of_ranges <= end_of_ranges; + if !within_ranges { + return false; + } - source_ids_match && is_within_start && start_of_ranges <= end_of_ranges + true } diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index a563764b8b0e8..45b89b2d97e40 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -8,13 +8,14 @@ extern crate tracing; use alloy_primitives::{Bytes, B256}; -use foundry_compilers::sourcemap::SourceElement; +use foundry_compilers::sourcemap::SourceMap; use semver::Version; use std::{ collections::{BTreeMap, HashMap}, fmt::Display, ops::{AddAssign, Deref, DerefMut}, path::PathBuf, + sync::Arc, }; use eyre::{Context, Result}; @@ -42,7 +43,7 @@ pub struct CoverageReport { /// All the bytecode hits for the codebase pub bytecode_hits: HashMap, /// The bytecode -> source mappings - pub source_maps: HashMap, Vec)>, + pub source_maps: HashMap, } impl CoverageReport { @@ -53,27 +54,27 @@ impl CoverageReport { } /// Get the source ID for a specific source file path. - pub fn get_source_id(&self, version: Version, path: PathBuf) -> Option<&usize> { - self.source_paths_to_ids.get(&(version, path)) + pub fn get_source_id(&self, version: Version, path: PathBuf) -> Option { + self.source_paths_to_ids.get(&(version, path)).copied() } /// Add the source maps pub fn add_source_maps( &mut self, - source_maps: HashMap, Vec)>, + source_maps: impl IntoIterator, ) { self.source_maps.extend(source_maps); } /// Add coverage items to this report - pub fn add_items(&mut self, version: Version, items: Vec) { + pub fn add_items(&mut self, version: Version, items: impl IntoIterator) { self.items.entry(version).or_default().extend(items); } /// Add anchors to this report pub fn add_anchors( &mut self, - anchors: HashMap, Vec)>, + anchors: impl IntoIterator, Vec))>, ) { self.anchors.extend(anchors); } @@ -130,18 +131,13 @@ impl CoverageReport { .bytecode_hits .entry(contract_id.clone()) .or_insert_with(|| HitMap::new(hit_map.bytecode.clone())); - e.merge(hit_map).context(format!( - "contract_id {:?}, hash {}, hash {}", - contract_id, - e.bytecode.clone(), - hit_map.bytecode.clone(), - ))?; + e.merge(hit_map).wrap_err_with(|| format!("{contract_id:?}"))?; // Add source level hits if let Some(anchors) = self.anchors.get(contract_id) { let anchors = if is_deployed_code { &anchors.1 } else { &anchors.0 }; for anchor in anchors { - if let Some(hits) = hit_map.hits.get(&anchor.instruction) { + if let Some(&hits) = hit_map.hits.get(&anchor.instruction) { self.items .get_mut(&contract_id.version) .and_then(|items| items.get_mut(anchor.item_id)) @@ -233,7 +229,7 @@ impl HitMap { pub struct ContractId { pub version: Version, pub source_id: usize, - pub contract_name: String, + pub contract_name: Arc, } impl Display for ContractId { @@ -321,7 +317,7 @@ pub struct SourceLocation { /// The source ID. pub source_id: usize, /// The contract this source range is in. - pub contract_name: String, + pub contract_name: Arc, /// Start byte in the source code. pub start: usize, /// Number of bytes in the source code. diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 496a4e9989797..0d6192aefcc06 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -19,7 +19,12 @@ foundry-evm-core.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } alloy-sol-types.workspace = true revm-inspectors.workspace = true @@ -32,6 +37,7 @@ serde = "1" tokio = { workspace = true, features = ["time", "macros"] } tracing = "0.1" yansi.workspace = true +rustc-hash.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index cbbec53f748f8..73bf52bdd9494 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -20,6 +20,7 @@ use foundry_evm_core::{ }; use itertools::Itertools; use once_cell::sync::OnceCell; +use rustc_hash::FxHashMap; use std::collections::{hash_map::Entry, BTreeMap, HashMap}; mod precompiles; @@ -108,7 +109,7 @@ pub struct CallTraceDecoder { pub receive_contracts: Vec
, /// All known functions. - pub functions: HashMap>, + pub functions: FxHashMap>, /// All known events. pub events: BTreeMap<(B256, usize), Vec>, /// Revert decoder. Contains all known custom errors. diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index f58968bf0315d..9ca39877dbbe0 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -15,7 +15,11 @@ name = "forge" path = "bin/main.rs" [build-dependencies] -vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] } +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } [dependencies] # lib @@ -34,7 +38,7 @@ revm-inspectors.workspace = true comfy-table = "7" eyre.workspace = true proptest = "1" -rayon = "1" +rayon.workspace = true serde.workspace = true tracing.workspace = true yansi.workspace = true @@ -105,14 +109,16 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" similar-asserts.workspace = true -svm = { package = "svm-rs", version = "0.5", default-features = false, features = ["rustls"] } +svm = { package = "svm-rs", version = "0.5", default-features = false, features = [ + "rustls", +] } tempfile.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } alloy-signer-wallet.workspace = true [features] -default = ["rustls"] +default = ["rustls", "jemalloc"] rustls = [ "foundry-cli/rustls", "foundry-wallets/rustls", diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 89765e9dad406..efdcc0e38f6f4 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -4,8 +4,10 @@ use clap::{Parser, ValueEnum, ValueHint}; use eyre::{Context, Result}; use forge::{ coverage::{ - analysis::SourceAnalyzer, anchors::find_anchors, BytecodeReporter, ContractId, - CoverageReport, CoverageReporter, DebugReporter, LcovReporter, SummaryReporter, + analysis::{SourceAnalysis, SourceAnalyzer, SourceFile, SourceFiles}, + anchors::find_anchors, + BytecodeReporter, ContractId, CoverageReport, CoverageReporter, DebugReporter, ItemAnchor, + LcovReporter, SummaryReporter, }, opts::EvmOpts, utils::IcPcMap, @@ -17,19 +19,17 @@ use foundry_cli::{ }; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ - artifacts::{contract::CompactContractBytecode, Ast, CompactBytecode, CompactDeployedBytecode}, + artifacts::{CompactBytecode, CompactDeployedBytecode}, sourcemap::SourceMap, - Artifact, Project, ProjectCompileOutput, + Artifact, ArtifactId, Project, ProjectCompileOutput, }; use foundry_config::{Config, SolcReq}; +use rayon::prelude::*; use rustc_hash::FxHashMap; use semver::Version; use std::{collections::HashMap, path::PathBuf, sync::Arc}; use yansi::Paint; -/// A map, keyed by contract ID, to a tuple of the deployment source map and the runtime source map. -type SourceMaps = HashMap; - // Loads project's figment and merges the build cli arguments into it foundry_config::impl_figment_convert!(CoverageArgs, test); @@ -88,7 +88,7 @@ impl CoverageArgs { let (project, output) = self.build(&config)?; p_println!(!self.test.build_args().silent => "Analysing contracts..."); - let report = self.prepare(&project, output.clone())?; + let report = self.prepare(&project, &output)?; p_println!(!self.test.build_args().silent => "Running tests..."); self.collect(project, output, report, Arc::new(config), evm_opts).await @@ -141,148 +141,80 @@ impl CoverageArgs { /// Builds the coverage report. #[instrument(name = "prepare", skip_all)] - fn prepare(&self, project: &Project, output: ProjectCompileOutput) -> Result { - let project_paths = &project.paths; - - // Extract artifacts - let (artifacts, sources) = output.into_artifacts_with_sources(); + fn prepare(&self, project: &Project, output: &ProjectCompileOutput) -> Result { let mut report = CoverageReport::default(); - // Collect ASTs and sources - let mut versioned_asts: HashMap> = HashMap::new(); - let mut versioned_sources: HashMap> = HashMap::new(); - for (path, mut source_file, version) in sources.into_sources_with_version() { + // Collect source files. + let project_paths = &project.paths; + let mut versioned_sources = HashMap::::new(); + for (path, source_file, version) in output.output().sources.sources_with_version() { report.add_source(version.clone(), source_file.id as usize, path.clone()); // Filter out dependencies - if !self.include_libs && project_paths.has_library_ancestor(std::path::Path::new(&path)) - { - continue + if !self.include_libs && project_paths.has_library_ancestor(path) { + continue; } - if let Some(ast) = source_file.ast.take() { - versioned_asts - .entry(version.clone()) - .or_default() - .insert(source_file.id as usize, ast); - - let file = project_paths.root.join(&path); + if let Some(ast) = &source_file.ast { + let file = project_paths.root.join(path); trace!(root=?project_paths.root, ?file, "reading source file"); - versioned_sources.entry(version.clone()).or_default().insert( - source_file.id as usize, - fs::read_to_string(&file) + let source = SourceFile { + ast, + source: fs::read_to_string(&file) .wrap_err("Could not read source code for analysis")?, - ); + }; + versioned_sources + .entry(version.clone()) + .or_default() + .sources + .insert(source_file.id as usize, source); } } // Get source maps and bytecodes - let (source_maps, bytecodes): (SourceMaps, HashMap) = artifacts - .into_iter() - .map(|(id, artifact)| (id, CompactContractBytecode::from(artifact))) + let artifacts: Vec = output + .artifact_ids() + .par_bridge() .filter_map(|(id, artifact)| { - let contract_id = ContractId { - version: id.version.clone(), - source_id: *report.get_source_id(id.version, id.source)?, - contract_name: id.name, - }; - let source_maps = ( - contract_id.clone(), - ( - artifact.get_source_map()?.ok()?, - artifact - .get_deployed_bytecode() - .as_ref()? - .bytecode - .as_ref()? - .source_map()? - .ok()?, - ), - ); - let bytecodes = ( - contract_id, - ( - artifact - .get_bytecode() - .and_then(|bytecode| dummy_link_bytecode(bytecode.into_owned()))?, - artifact.get_deployed_bytecode().and_then(|bytecode| { - dummy_link_deployed_bytecode(bytecode.into_owned()) - })?, - ), - ); - - Some((source_maps, bytecodes)) - }) - .unzip(); - - // Build IC -> PC mappings - // - // The source maps are indexed by *instruction counters*, which are the indexes of - // instructions in the bytecode *minus any push bytes*. - // - // Since our coverage inspector collects hit data using program counters, the anchors also - // need to be based on program counters. - // TODO: Index by contract ID - let ic_pc_maps: HashMap = bytecodes - .iter() - .map(|(id, bytecodes)| { - // TODO: Creation bytecode as well - ( - id.clone(), - (IcPcMap::new(bytecodes.0.as_ref()), IcPcMap::new(bytecodes.1.as_ref())), - ) + let source_id = report.get_source_id(id.version.clone(), id.source.clone())?; + ArtifactData::new(&id, source_id, artifact) }) .collect(); // Add coverage items - for (version, asts) in versioned_asts.into_iter() { - let source_analysis = SourceAnalyzer::new( - version.clone(), - asts, - versioned_sources.remove(&version).ok_or_else(|| { - eyre::eyre!( - "File tree is missing source code, cannot perform coverage analysis" - ) - })?, - )? - .analyze()?; + for (version, sources) in &versioned_sources { + let source_analysis = SourceAnalyzer::new(sources).analyze()?; // Build helper mapping used by `find_anchors` - let mut items_by_source_id: HashMap<_, Vec<_>> = - HashMap::with_capacity(source_analysis.items.len()); + let mut items_by_source_id = FxHashMap::<_, Vec<_>>::with_capacity_and_hasher( + source_analysis.items.len(), + Default::default(), + ); for (item_id, item) in source_analysis.items.iter().enumerate() { items_by_source_id.entry(item.loc.source_id).or_default().push(item_id); } - let anchors = source_maps - .iter() - .filter(|(contract_id, _)| contract_id.version == version) - .filter_map(|(contract_id, (creation_source_map, deployed_source_map))| { - let creation_code_anchors = find_anchors( - &bytecodes.get(contract_id)?.0, - creation_source_map, - &ic_pc_maps.get(contract_id)?.0, - &source_analysis.items, - &items_by_source_id, - ); - let deployed_code_anchors = find_anchors( - &bytecodes.get(contract_id)?.1, - deployed_source_map, - &ic_pc_maps.get(contract_id)?.1, - &source_analysis.items, - &items_by_source_id, - ); - // TODO: Creation source map/bytecode as well - Some((contract_id.clone(), (creation_code_anchors, deployed_code_anchors))) + let anchors = artifacts + .par_iter() + .filter(|artifact| artifact.contract_id.version == *version) + .map(|artifact| { + let creation_code_anchors = + artifact.creation.find_anchors(&source_analysis, &items_by_source_id); + let deployed_code_anchors = + artifact.deployed.find_anchors(&source_analysis, &items_by_source_id); + (artifact.contract_id.clone(), (creation_code_anchors, deployed_code_anchors)) }) - .collect(); - report.add_items(version, source_analysis.items); + .collect::>(); + report.add_anchors(anchors); + report.add_items(version.clone(), source_analysis.items); } - report.add_source_maps(source_maps); + report.add_source_maps(artifacts.into_iter().map(|artifact| { + (artifact.contract_id, (artifact.creation.source_map, artifact.deployed.source_map)) + })); Ok(report) } @@ -320,39 +252,36 @@ impl CoverageArgs { .await?; // Add hit data to the coverage report - let data = outcome.results.into_iter().flat_map(|(_, suite)| { + let data = outcome.results.iter().flat_map(|(_, suite)| { let mut hits = Vec::new(); - for (_, mut result) in suite.test_results { - let Some(hit_maps) = result.coverage.take() else { continue }; - - for map in hit_maps.0.into_values() { + for result in suite.test_results.values() { + let Some(hit_maps) = result.coverage.as_ref() else { continue }; + for map in hit_maps.0.values() { if let Some((id, _)) = - suite.known_contracts.find_by_deployed_code(map.bytecode.as_ref()) + suite.known_contracts.find_by_deployed_code(&map.bytecode) { - hits.push((id.clone(), map, true)); + hits.push((id, map, true)); } else if let Some((id, _)) = - suite.known_contracts.find_by_creation_code(map.bytecode.as_ref()) + suite.known_contracts.find_by_creation_code(&map.bytecode) { - hits.push((id.clone(), map, false)); + hits.push((id, map, false)); } } } - hits }); - for (artifact_id, hits, is_deployed_code) in data { + for (artifact_id, map, is_deployed_code) in data { if let Some(source_id) = - report.get_source_id(artifact_id.version.clone(), artifact_id.source) + report.get_source_id(artifact_id.version.clone(), artifact_id.source.clone()) { - let source_id = *source_id; report.add_hit_map( &ContractId { version: artifact_id.version.clone(), source_id, - contract_name: artifact_id.name.clone(), + contract_name: artifact_id.name.as_str().into(), }, - &hits, + map, is_deployed_code, )?; } @@ -414,3 +343,67 @@ fn dummy_link_bytecode(mut obj: CompactBytecode) -> Option { fn dummy_link_deployed_bytecode(obj: CompactDeployedBytecode) -> Option { obj.bytecode.and_then(dummy_link_bytecode) } + +pub struct ArtifactData { + pub contract_id: ContractId, + pub creation: BytecodeData, + pub deployed: BytecodeData, +} + +impl ArtifactData { + pub fn new(id: &ArtifactId, source_id: usize, artifact: &impl Artifact) -> Option { + Some(Self { + contract_id: ContractId { + version: id.version.clone(), + source_id, + contract_name: id.name.as_str().into(), + }, + creation: BytecodeData::new( + artifact.get_source_map()?.ok()?, + artifact + .get_bytecode() + .and_then(|bytecode| dummy_link_bytecode(bytecode.into_owned()))?, + ), + deployed: BytecodeData::new( + artifact.get_source_map_deployed()?.ok()?, + artifact + .get_deployed_bytecode() + .and_then(|bytecode| dummy_link_deployed_bytecode(bytecode.into_owned()))?, + ), + }) + } +} + +pub struct BytecodeData { + source_map: SourceMap, + bytecode: Bytes, + /// The instruction counter to program counter mapping. + /// + /// The source maps are indexed by *instruction counters*, which are the indexes of + /// instructions in the bytecode *minus any push bytes*. + /// + /// Since our coverage inspector collects hit data using program counters, the anchors + /// also need to be based on program counters. + ic_pc_map: IcPcMap, +} + +impl BytecodeData { + fn new(source_map: SourceMap, bytecode: Bytes) -> Self { + let ic_pc_map = IcPcMap::new(&bytecode); + Self { source_map, bytecode, ic_pc_map } + } + + pub fn find_anchors( + &self, + source_analysis: &SourceAnalysis, + items_by_source_id: &FxHashMap>, + ) -> Vec { + find_anchors( + &self.bytecode, + &self.source_map, + &self.ic_pc_map, + &source_analysis.items, + items_by_source_id, + ) + } +} diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 920c847be607c..cef6714f39df9 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -256,7 +256,7 @@ impl CoverageReporter for BytecodeReporter { } } fs::write( - self.destdir.join(contract_id.contract_name.clone()).with_extension("asm"), + self.destdir.join(&*contract_id.contract_name).with_extension("asm"), formatted, )?; } From 8e9fca8d79912f5d9dd9bb40d1ed692e97188b1c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 1 Jun 2024 11:43:25 +0200 Subject: [PATCH 1008/1963] perf: exclude source maps from `ContractData` (#8022) perf: exclude source maps from ContractData --- crates/common/src/contracts.rs | 62 +++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index e523c3813c58e..6e9de97911103 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -23,6 +23,42 @@ use std::{ const CALL_PROTECTION_BYTECODE_PREFIX: [u8; 21] = hex!("730000000000000000000000000000000000000000"); +/// Subset of [CompactBytecode] excluding sourcemaps. +#[allow(missing_docs)] +#[derive(Debug, Clone)] +pub struct BytecodeData { + pub object: Option, + pub link_references: BTreeMap>>, + pub immutable_references: BTreeMap>, +} + +impl BytecodeData { + fn bytes(&self) -> Option<&Bytes> { + self.object.as_ref().and_then(|b| b.as_bytes()) + } +} + +impl From for BytecodeData { + fn from(bytecode: CompactBytecode) -> Self { + Self { + object: Some(bytecode.object), + link_references: bytecode.link_references, + immutable_references: BTreeMap::new(), + } + } +} + +impl From for BytecodeData { + fn from(bytecode: CompactDeployedBytecode) -> Self { + let (object, link_references) = if let Some(compact) = bytecode.bytecode { + (Some(compact.object), compact.link_references) + } else { + (None, BTreeMap::new()) + }; + Self { object, link_references, immutable_references: bytecode.immutable_references } + } +} + /// Container for commonly used contract data. #[derive(Debug, Clone)] pub struct ContractData { @@ -31,9 +67,9 @@ pub struct ContractData { /// Contract ABI. pub abi: JsonAbi, /// Contract creation code. - pub bytecode: Option, + pub bytecode: Option, /// Contract runtime code. - pub deployed_bytecode: Option, + pub deployed_bytecode: Option, } impl ContractData { @@ -68,7 +104,15 @@ impl ContractsByArtifact { let CompactContractBytecode { abi, bytecode, deployed_bytecode } = artifact; - Some((id, ContractData { name, abi: abi?, bytecode, deployed_bytecode })) + Some(( + id, + ContractData { + name, + abi: abi?, + bytecode: bytecode.map(Into::into), + deployed_bytecode: deployed_bytecode.map(Into::into), + }, + )) }) .collect(), ) @@ -103,11 +147,11 @@ impl ContractsByArtifact { let Some(deployed_bytecode) = &contract.deployed_bytecode else { return false; }; - let Some(deployed_code) = &deployed_bytecode.bytecode else { + let Some(deployed_code) = &deployed_bytecode.object else { return false; }; - let len = match deployed_code.object { + let len = match deployed_code { BytecodeObject::Bytecode(ref bytes) => bytes.len(), BytecodeObject::Unlinked(ref bytes) => bytes.len() / 2, }; @@ -120,7 +164,7 @@ impl ContractsByArtifact { let mut ignored = deployed_bytecode .immutable_references .values() - .chain(deployed_code.link_references.values().flat_map(|v| v.values())) + .chain(deployed_bytecode.link_references.values().flat_map(|v| v.values())) .flatten() .cloned() .collect::>(); @@ -129,7 +173,7 @@ impl ContractsByArtifact { // ignore it as it includes library address determined at runtime. // See https://docs.soliditylang.org/en/latest/contracts.html#call-protection-for-libraries and // https://github.com/NomicFoundation/hardhat/blob/af7807cf38842a4f56e7f4b966b806e39631568a/packages/hardhat-verify/src/internal/solc/bytecode.ts#L172 - let has_call_protection = match deployed_code.object { + let has_call_protection = match deployed_code { BytecodeObject::Bytecode(ref bytes) => { bytes.starts_with(&CALL_PROTECTION_BYTECODE_PREFIX) } @@ -154,7 +198,7 @@ impl ContractsByArtifact { for offset in ignored { let right = offset.start as usize; - let matched = match deployed_code.object { + let matched = match deployed_code { BytecodeObject::Bytecode(ref bytes) => bytes[left..right] == code[left..right], BytecodeObject::Unlinked(ref bytes) => { if let Ok(bytes) = Bytes::from_str(&bytes[left * 2..right * 2]) { @@ -173,7 +217,7 @@ impl ContractsByArtifact { } if left < code.len() { - match deployed_code.object { + match deployed_code { BytecodeObject::Bytecode(ref bytes) => bytes[left..] == code[left..], BytecodeObject::Unlinked(ref bytes) => { if let Ok(bytes) = Bytes::from_str(&bytes[left * 2..]) { From 2b95250d7858e660de30a8c195f5fc60007524ce Mon Sep 17 00:00:00 2001 From: sodamntired Date: Sat, 1 Jun 2024 13:13:22 +0300 Subject: [PATCH 1009/1963] feat: Priority fee suggestion (#7984) * Suggested tip cap * Clippy warnings resolved * Reviews updated * Tests * review updated * Subtle refactorings --- crates/anvil/src/eth/api.rs | 42 ++++++++++++++++++------- crates/anvil/src/eth/backend/mem/mod.rs | 14 ++------- crates/anvil/src/eth/fees.rs | 26 +++------------ crates/anvil/tests/it/transaction.rs | 4 +-- 4 files changed, 41 insertions(+), 45 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 98c68abf36b59..25a6b69bb50b2 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -544,12 +544,16 @@ impl EthApi { /// Returns the current gas price fn eth_gas_price(&self) -> Result { node_info!("eth_gasPrice"); - self.gas_price() + Ok(U256::from(self.gas_price())) } /// Returns the current gas price - pub fn gas_price(&self) -> Result { - Ok(U256::from(self.backend.gas_price())) + pub fn gas_price(&self) -> u128 { + if self.backend.is_eip1559() { + self.backend.base_fee().saturating_add(self.lowest_suggestion_tip()) + } else { + self.backend.fees().raw_gas_price() + } } /// Returns the excess blob gas and current blob gas price @@ -562,7 +566,7 @@ impl EthApi { /// /// Handler for ETH RPC call: `eth_maxPriorityFeePerGas` pub fn gas_max_priority_fee_per_gas(&self) -> Result { - Ok(U256::from(self.backend.max_priority_fee_per_gas())) + self.max_priority_fee_per_gas() } /// Returns the base fee per blob required to send a EIP-4844 tx. @@ -1351,7 +1355,24 @@ impl EthApi { /// Handler for ETH RPC call: `eth_maxPriorityFeePerGas` pub fn max_priority_fee_per_gas(&self) -> Result { node_info!("eth_maxPriorityFeePerGas"); - Ok(U256::from(self.backend.max_priority_fee_per_gas())) + Ok(U256::from(self.lowest_suggestion_tip())) + } + + /// Returns the suggested fee cap. + fn lowest_suggestion_tip(&self) -> u128 { + let block_number = self.backend.best_number(); + let latest_cached_block = self.fee_history_cache.lock().get(&block_number).cloned(); + + match latest_cached_block { + Some(block) => block.rewards.iter().copied().min().unwrap_or(1e9 as u128), + None => self + .fee_history_cache + .lock() + .values() + .flat_map(|b| b.rewards.clone()) + .min() + .unwrap_or(1e9 as u128), + } } /// Creates a filter object, based on filter options, to notify when the state changes (logs). @@ -1744,7 +1765,7 @@ impl EthApi { base_fee: self.backend.base_fee(), chain_id: self.backend.chain_id().to::(), gas_limit: self.backend.gas_limit(), - gas_price: self.backend.gas_price(), + gas_price: self.gas_price(), }, fork_config: fork_config .map(|fork| { @@ -2427,7 +2448,7 @@ impl EthApi { m.chain_id = Some(chain_id); m.gas_limit = gas_limit; if gas_price.is_none() { - m.gas_price = self.backend.gas_price() + m.gas_price = self.gas_price(); } TypedTransactionRequest::Legacy(m) } @@ -2436,7 +2457,7 @@ impl EthApi { m.chain_id = chain_id; m.gas_limit = gas_limit; if gas_price.is_none() { - m.gas_price = self.backend.gas_price(); + m.gas_price = self.gas_price(); } TypedTransactionRequest::EIP2930(m) } @@ -2445,7 +2466,7 @@ impl EthApi { m.chain_id = chain_id; m.gas_limit = gas_limit; if max_fee_per_gas.is_none() { - m.max_fee_per_gas = self.backend.gas_price(); + m.max_fee_per_gas = self.gas_price(); } TypedTransactionRequest::EIP1559(m) } @@ -2457,8 +2478,7 @@ impl EthApi { m.tx.chain_id = chain_id; m.tx.gas_limit = gas_limit; if max_fee_per_gas.is_none() { - m.tx.max_fee_per_gas = - self.gas_price().unwrap_or_default().to::(); + m.tx.max_fee_per_gas = self.gas_price(); } if max_fee_per_blob_gas.is_none() { m.tx.max_fee_per_blob_gas = self diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 3668c4e3cb888..25aa47cef983b 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -650,16 +650,6 @@ impl Backend { self.fees.set_base_fee(basefee) } - /// Returns the current gas price - pub fn gas_price(&self) -> u128 { - self.fees.gas_price() - } - - /// Returns the suggested fee cap - pub fn max_priority_fee_per_gas(&self) -> u128 { - self.fees.max_priority_fee_per_gas() - } - /// Sets the gas price pub fn set_gas_price(&self, price: u128) { self.fees.set_gas_price(price) @@ -1149,7 +1139,9 @@ impl Backend { env.block.basefee = U256::from(base); } - let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price()); + let gas_price = gas_price + .or(max_fee_per_gas) + .unwrap_or_else(|| self.fees().raw_gas_price().saturating_add(1e9 as u128)); let caller = from.unwrap_or_default(); let to = to.as_ref().and_then(TxKind::to); env.tx = TxEnv { diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index f0a614c35c6b8..11f84ea5e1128 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -86,15 +86,6 @@ impl FeeManager { (self.spec_id as u8) >= (SpecId::CANCUN as u8) } - /// Calculates the current gas price - pub fn gas_price(&self) -> u128 { - if self.is_eip1559() { - self.base_fee().saturating_add(self.suggested_priority_fee()) - } else { - *self.gas_price.read() - } - } - /// Calculates the current blob gas price pub fn blob_gas_price(&self) -> u128 { if self.is_eip4844() { @@ -104,11 +95,6 @@ impl FeeManager { } } - /// Suggested priority fee to add to the base fee - pub fn suggested_priority_fee(&self) -> u128 { - 1e9 as u128 - } - pub fn base_fee(&self) -> u128 { if self.is_eip1559() { *self.base_fee.read() @@ -117,6 +103,11 @@ impl FeeManager { } } + /// Raw base gas price + pub fn raw_gas_price(&self) -> u128 { + *self.gas_price.read() + } + pub fn excess_blob_gas_and_price(&self) -> Option { if self.is_eip4844() { Some(self.blob_excess_gas_and_price.read().clone()) @@ -133,13 +124,6 @@ impl FeeManager { } } - /// Returns the suggested fee cap - /// - /// Note: This currently returns a constant value: [Self::suggested_priority_fee] - pub fn max_priority_fee_per_gas(&self) -> u128 { - self.suggested_priority_fee() - } - /// Returns the current gas price pub fn set_gas_price(&self, price: u128) { let mut gas = self.gas_price.write(); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index cf9845d6f5408..b8ef827a79210 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -515,7 +515,7 @@ async fn call_past_state() { let value = contract.getValue().call().await.unwrap(); assert_eq!(value._0, "initial value"); - let gas_price = api.gas_price().unwrap().to::(); + let gas_price = api.gas_price(); let set_tx = contract.setValue("hi".to_string()).gas_price(gas_price + 1); let _receipt = set_tx.send().await.unwrap().get_receipt().await.unwrap(); @@ -1136,7 +1136,7 @@ async fn test_reject_eip1559_pre_london() { let provider = handle.http_provider(); let gas_limit = api.gas_limit().to::(); - let gas_price = api.gas_price().unwrap().to::(); + let gas_price = api.gas_price(); let unsupported_call_builder = Greeter::deploy_builder(provider.clone(), "Hello World!".to_string()); From 489453c7b955441179b805a2e15ac107682220a4 Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Sat, 1 Jun 2024 13:56:18 +0100 Subject: [PATCH 1010/1963] nit: Minor help style consistency (#8029) Follow up https://github.com/foundry-rs/book/pull/1210 --- crates/anvil/src/cmd.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 4a4b329da9704..f36b200130d25 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -46,21 +46,21 @@ pub struct NodeArgs { pub timestamp: Option, /// BIP39 mnemonic phrase used for generating accounts. - /// Cannot be used if `mnemonic_random` or `mnemonic_seed` are used + /// Cannot be used if `mnemonic_random` or `mnemonic_seed` are used. #[arg(long, short, conflicts_with_all = &["mnemonic_seed", "mnemonic_random"])] pub mnemonic: Option, /// Automatically generates a BIP39 mnemonic phrase, and derives accounts from it. - /// Cannot be used with other `mnemonic` options + /// Cannot be used with other `mnemonic` options. /// You can specify the number of words you want in the mnemonic. /// [default: 12] #[arg(long, conflicts_with_all = &["mnemonic", "mnemonic_seed"], default_missing_value = "12", num_args(0..=1))] pub mnemonic_random: Option, /// Generates a BIP39 mnemonic phrase from a given seed - /// Cannot be used with other `mnemonic` options + /// Cannot be used with other `mnemonic` options. /// - /// CAREFUL: this is NOT SAFE and should only be used for testing. + /// CAREFUL: This is NOT SAFE and should only be used for testing. /// Never use the private keys generated in production. #[arg(long = "mnemonic-seed-unsafe", conflicts_with_all = &["mnemonic", "mnemonic_random"])] pub mnemonic_seed: Option, From 399a42df7ea1f77ad4d4a0ffb2337dc36f5cc8d0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 1 Jun 2024 18:16:31 +0300 Subject: [PATCH 1011/1963] chore(deps): bump foundry-compilers to 0.5.1 (#8030) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/chisel/src/executor.rs | 6 +++--- crates/config/src/lib.rs | 2 +- crates/debugger/src/tui/draw.rs | 8 ++++---- crates/evm/coverage/src/analysis.rs | 4 ++-- crates/evm/coverage/src/anchors.rs | 12 ++++++------ crates/evm/coverage/src/lib.rs | 4 ++-- crates/forge/src/coverage.rs | 8 ++++---- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b77ed1a3362f4..4260c729c4ddd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3406,9 +3406,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136f5e0af939b12cf072ac6577818a87cb7a408b269070f5d6f52ba23454660e" +checksum = "cd571882cd635dd2a11169d5b696e51644fc803487989e2b5fd7ff6bdd008f1c" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 8d0264d455a10..d9db1d72f1e80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -138,7 +138,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.8", default-features = false } -foundry-compilers = { version = "0.5", default-features = false } +foundry-compilers = { version = "0.5.2", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index fc1e7c84a86fd..3ce6a7d199766 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -91,15 +91,15 @@ impl SessionSource { // Map the source location of the final statement of the `run()` function to its // corresponding runtime program counter let final_pc = { - let offset = source_loc.start(); - let length = source_loc.end() - source_loc.start(); + let offset = source_loc.start() as u32; + let length = (source_loc.end() - source_loc.start()) as u32; contract .get_source_map_deployed() .unwrap() .unwrap() .into_iter() .zip(InstructionIter::new(&deployed_bytecode)) - .filter(|(s, _)| s.offset == offset && s.length == length) + .filter(|(s, _)| s.offset() == offset && s.length() == length) .map(|(_, i)| i.pc) .max() .unwrap_or_default() diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 81dbff8a426da..f2957c6a4ce6a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -810,7 +810,7 @@ impl Config { compiler_config: CompilerConfig, settings: C::Settings, ) -> Result, SolcError> { - let project = ProjectBuilder::::new(Default::default()) + let project = ProjectBuilder::::new(Default::default()) .artifacts(self.configured_artifacts_handler()) .paths(self.project_paths()) .settings(settings) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index ad1645d27b717..9a33e6a059104 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -215,8 +215,8 @@ impl DebuggerContext<'_> { // currently being executed. This includes an offset and length. // This vector is in instruction pointer order, meaning the location of the instruction // minus `sum(push_bytes[..pc])`. - let offset = source_element.offset; - let len = source_element.length; + let offset = source_element.offset() as usize; + let len = source_element.length() as usize; let max = source_code.len(); // Split source into before, relevant, and after chunks, split by line, for formatting. @@ -357,7 +357,7 @@ impl DebuggerContext<'_> { let source_element = source_map.get(ic)?; // if the source element has an index, find the sourcemap for that index source_element - .index + .index() // if index matches current file_id, return current source code .and_then(|index| { (index == file_id).then(|| (source_element.clone(), source_code)) @@ -367,7 +367,7 @@ impl DebuggerContext<'_> { self.debugger .contracts_sources .sources_by_id - .get(&(source_element.index?)) + .get(&source_element.index()?) .map(|source_code| (source_element.clone(), source_code.as_ref())) }) }) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index cfcb7406f6a32..bbfaa189754a8 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -412,8 +412,8 @@ impl<'a> ContractVisitor<'a> { SourceLocation { source_id: self.source_id, contract_name: self.contract_name.clone(), - start: loc.start, - length: loc.length, + start: loc.start as u32, + length: loc.length.map(|x| x as u32), line: self.source[..loc.start].lines().count(), } } diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index f05f7c287596d..f717e24abced3 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -16,7 +16,7 @@ pub fn find_anchors( let mut seen = FxHashSet::default(); source_map .iter() - .filter_map(|element| items_by_source_id.get(&(element.index? as usize))) + .filter_map(|element| items_by_source_id.get(&(element.index()? as usize))) .flatten() .filter_map(|&item_id| { if !seen.insert(item_id) { @@ -164,20 +164,20 @@ pub fn find_anchor_branch( /// Calculates whether `element` is within the range of the target `location`. fn is_in_source_range(element: &SourceElement, location: &SourceLocation) -> bool { // Source IDs must match. - let source_ids_match = element.index.map_or(false, |a| a as usize == location.source_id); + let source_ids_match = element.index().map_or(false, |a| a as usize == location.source_id); if !source_ids_match { return false; } // Needed because some source ranges in the source map mark the entire contract... - let is_within_start = element.offset >= location.start; + let is_within_start = element.offset() >= location.start; if !is_within_start { return false; } - let start_of_ranges = location.start.max(element.offset); - let end_of_ranges = - (location.start + location.length.unwrap_or_default()).min(element.offset + element.length); + let start_of_ranges = location.start.max(element.offset()); + let end_of_ranges = (location.start + location.length.unwrap_or_default()) + .min(element.offset() + element.length()); let within_ranges = start_of_ranges <= end_of_ranges; if !within_ranges { return false; diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 45b89b2d97e40..53ca928f6b096 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -319,9 +319,9 @@ pub struct SourceLocation { /// The contract this source range is in. pub contract_name: Arc, /// Start byte in the source code. - pub start: usize, + pub start: u32, /// Number of bytes in the source code. - pub length: Option, + pub length: Option, /// The line in the source code. pub line: usize, } diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index cef6714f39df9..29920d735e2ff 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -220,14 +220,14 @@ impl CoverageReporter for BytecodeReporter { .get(&(code.offset as usize)) .map(|h| format!("[{:03}]", h)) .unwrap_or(" ".to_owned()); - let source_id = source_element.index; + let source_id = source_element.index(); let source_path = source_id.and_then(|i| { report.source_paths.get(&(contract_id.version.clone(), i as usize)) }); - let code = format!("{:?}", code); - let start = source_element.offset; - let end = source_element.offset + source_element.length; + let code = format!("{code:?}"); + let start = source_element.offset() as usize; + let end = (source_element.offset() + source_element.length()) as usize; if let Some(source_path) = source_path { let (sline, spos) = line_number_cache.get_position(source_path, start)?; From 5ac78a9cd4b94dc53d1fe5e0f42372b28b5a7559 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 1 Jun 2024 18:37:02 +0300 Subject: [PATCH 1012/1963] chore: Arc ContractsByArtifact internally (#8026) * chore: Arc ContractsByArtifact internally * perf: clear from test suite result * chore: clear only when not coverage --- crates/cheatcodes/src/config.rs | 5 ++- crates/common/src/contracts.rs | 58 +++++++++++++----------------- crates/forge/bin/cmd/test/mod.rs | 15 ++++---- crates/forge/src/multi_runner.rs | 2 +- crates/forge/src/result.rs | 17 ++++++--- crates/forge/src/runner.rs | 3 +- crates/forge/tests/cli/coverage.rs | 12 +++---- crates/script/src/build.rs | 3 +- crates/script/src/execute.rs | 4 +-- crates/script/src/lib.rs | 4 +-- 10 files changed, 58 insertions(+), 65 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 66aef3cff7350..54ba1dad1d616 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -12,7 +12,6 @@ use semver::Version; use std::{ collections::HashMap, path::{Path, PathBuf}, - sync::Arc, time::Duration, }; @@ -50,7 +49,7 @@ pub struct CheatsConfig { /// Artifacts which are guaranteed to be fresh (either recompiled or cached). /// If Some, `vm.getDeployedCode` invocations are validated to be in scope of this list. /// If None, no validation is performed. - pub available_artifacts: Option>, + pub available_artifacts: Option, /// Version of the script/test contract which is currently running. pub running_version: Option, } @@ -60,7 +59,7 @@ impl CheatsConfig { pub fn new( config: &Config, evm_opts: EvmOpts, - available_artifacts: Option>, + available_artifacts: Option, script_wallets: Option, running_version: Option, ) -> Self { diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 6e9de97911103..3e6b2ce1030dd 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -10,11 +10,7 @@ use foundry_compilers::{ }, ArtifactId, }; -use std::{ - collections::BTreeMap, - ops::{Deref, DerefMut}, - str::FromStr, -}; +use std::{collections::BTreeMap, ops::Deref, str::FromStr, sync::Arc}; /// Libraries' runtime code always starts with the following instruction: /// `PUSH20 0x0000000000000000000000000000000000000000` @@ -60,7 +56,7 @@ impl From for BytecodeData { } /// Container for commonly used contract data. -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct ContractData { /// Contract name. pub name: String, @@ -88,7 +84,7 @@ type ArtifactWithContractRef<'a> = (&'a ArtifactId, &'a ContractData); /// Wrapper type that maps an artifact to a contract ABI and bytecode. #[derive(Clone, Default, Debug)] -pub struct ContractsByArtifact(pub BTreeMap); +pub struct ContractsByArtifact(Arc>); impl ContractsByArtifact { /// Creates a new instance by collecting all artifacts with present bytecode from an iterator. @@ -96,26 +92,28 @@ impl ContractsByArtifact { /// It is recommended to use this method with an output of /// [foundry_linking::Linker::get_linked_artifacts]. pub fn new(artifacts: impl IntoIterator) -> Self { - Self( - artifacts - .into_iter() - .filter_map(|(id, artifact)| { - let name = id.name.clone(); - - let CompactContractBytecode { abi, bytecode, deployed_bytecode } = artifact; - - Some(( - id, - ContractData { - name, - abi: abi?, - bytecode: bytecode.map(Into::into), - deployed_bytecode: deployed_bytecode.map(Into::into), - }, - )) - }) - .collect(), - ) + let map = artifacts + .into_iter() + .filter_map(|(id, artifact)| { + let name = id.name.clone(); + let CompactContractBytecode { abi, bytecode, deployed_bytecode } = artifact; + Some(( + id, + ContractData { + name, + abi: abi?, + bytecode: bytecode.map(Into::into), + deployed_bytecode: deployed_bytecode.map(Into::into), + }, + )) + }) + .collect(); + Self(Arc::new(map)) + } + + /// Clears all contracts. + pub fn clear(&mut self) { + *self = Self::default(); } /// Finds a contract which has a similar bytecode as `code`. @@ -276,12 +274,6 @@ impl Deref for ContractsByArtifact { } } -impl DerefMut for ContractsByArtifact { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - /// Wrapper type that maps an address to a contract identifier and contract ABI. pub type ContractsByAddress = BTreeMap; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 152d21db51d93..8f1df029c45f2 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -392,12 +392,12 @@ impl TestArgs { let mut outcome = TestOutcome::empty(self.allow_failure); let mut any_test_failed = false; - for (contract_name, suite_result) in rx { + for (contract_name, mut suite_result) in rx { let tests = &suite_result.test_results; // Set up trace identifiers. - let known_contracts = suite_result.known_contracts.clone(); - let mut identifier = TraceIdentifiers::new().with_local(&known_contracts); + let known_contracts = &suite_result.known_contracts; + let mut identifier = TraceIdentifiers::new().with_local(known_contracts); // Avoid using etherscan for gas report as we decode more traces and this will be // expensive. @@ -407,7 +407,7 @@ impl TestArgs { // Build the trace decoder. let mut builder = CallTraceDecoderBuilder::new() - .with_known_contracts(&known_contracts) + .with_known_contracts(known_contracts) .with_verbosity(verbosity); // Signatures are of no value for gas reports. if !self.gas_report { @@ -453,10 +453,6 @@ impl TestArgs { // processing the remaining tests and print the suite summary. any_test_failed |= result.status == TestStatus::Failure; - if result.traces.is_empty() { - continue; - } - // Clear the addresses and labels from previous runs. decoder.clear_addresses(); decoder @@ -524,6 +520,9 @@ impl TestArgs { // Print suite summary. shell::println(suite_result.summary())?; + // Free memory if it's not needed. + suite_result.clear_unneeded(); + // Add the suite result to the outcome. outcome.results.insert(contract_name, suite_result); outcome.last_run_decoder = Some(decoder); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 3653a0e3f064b..d910215e9c26d 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -186,7 +186,7 @@ impl MultiContractRunner { self.output.artifact_ids().collect(), ); let linked_contracts = linker.get_linked_artifacts(&contract.libraries).unwrap_or_default(); - let known_contracts = Arc::new(ContractsByArtifact::new(linked_contracts)); + let known_contracts = ContractsByArtifact::new(linked_contracts); let cheats_config = CheatsConfig::new( &self.config, diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 2dd5508e85d69..ab289db54d195 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,5 +1,6 @@ //! Test outcomes. +use crate::gas_report::GasReport; use alloy_primitives::{Address, Log}; use foundry_common::{ evm::Breakpoints, get_contract_name, get_file_name, shell, ContractsByArtifact, @@ -16,13 +17,10 @@ use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashMap}, fmt::{self, Write}, - sync::Arc, time::Duration, }; use yansi::Paint; -use crate::gas_report::GasReport; - /// The aggregated result of a test run. #[derive(Clone, Debug)] pub struct TestOutcome { @@ -201,8 +199,10 @@ pub struct SuiteResult { /// Libraries used to link test contract. pub libraries: Libraries, /// Contracts linked with correct libraries. + /// + /// This is cleared at the end of the test run if coverage is not enabled. #[serde(skip)] - pub known_contracts: Arc, + pub known_contracts: ContractsByArtifact, } impl SuiteResult { @@ -211,11 +211,18 @@ impl SuiteResult { test_results: BTreeMap, warnings: Vec, libraries: Libraries, - known_contracts: Arc, + known_contracts: ContractsByArtifact, ) -> Self { Self { duration, test_results, warnings, libraries, known_contracts } } + /// Frees memory that is not used for the final output. + pub fn clear_unneeded(&mut self) { + if !self.test_results.values().any(|r| r.coverage.is_some()) { + ContractsByArtifact::clear(&mut self.known_contracts); + } + } + /// Returns an iterator over all individual succeeding tests and their names. pub fn successes(&self) -> impl Iterator { self.tests().filter(|(_, t)| t.status == TestStatus::Success) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 33a2ce64ad545..ea6b6efe70e34 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -40,7 +40,6 @@ use std::{ borrow::Cow, cmp::min, collections::{BTreeMap, HashMap}, - sync::Arc, time::Instant, }; @@ -258,7 +257,7 @@ impl<'a> ContractRunner<'a> { mut self, filter: &dyn TestFilter, test_options: &TestOptions, - known_contracts: Arc, + known_contracts: ContractsByArtifact, handle: &tokio::runtime::Handle, ) -> SuiteResult { info!("starting tests"); diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index df44a1cf6a50e..546a1103849d2 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -70,11 +70,9 @@ contract AContractTest is DSTest { let lcov_data = std::fs::read_to_string(lcov_info).unwrap(); // AContract.init must be hit at least once let re = Regex::new(r"FNDA:(\d+),AContract\.init").unwrap(); - assert!(lcov_data.lines().any(|line| re.captures(line).map_or(false, |caps| caps - .get(1) - .unwrap() - .as_str() - .parse::() - .unwrap() > - 0))); + let valid_line = |line| { + re.captures(line) + .map_or(false, |caps| caps.get(1).unwrap().as_str().parse::().unwrap() > 0) + }; + assert!(lcov_data.lines().any(valid_line), "{lcov_data}"); }); diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 3bf9e154bf934..a2462e4b2d85d 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -146,10 +146,9 @@ impl LinkedBuildData { } /// Fetches target bytecode from linked contracts. - pub fn get_target_contract(&self) -> Result { + pub fn get_target_contract(&self) -> Result<&ContractData> { self.known_contracts .get(&self.build_data.target) - .cloned() .ok_or_eyre("target not found in linked artifacts") } } diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index afba19f22f06b..2b57468e276bd 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -73,13 +73,13 @@ impl LinkedState { args, script_config, script_wallets, - build_data, execution_data: ExecutionData { func, calldata, bytecode: bytecode.clone(), - abi: target_contract.abi, + abi: target_contract.abi.clone(), }, + build_data, }) } } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 88ab0782a8515..39059ed212cc6 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -44,7 +44,7 @@ use foundry_evm::{ }; use foundry_wallets::MultiWalletOpts; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, sync::Arc}; +use std::collections::HashMap; use yansi::Paint; mod broadcast; @@ -591,7 +591,7 @@ impl ScriptConfig { CheatsConfig::new( &self.config, self.evm_opts.clone(), - Some(Arc::new(known_contracts)), + Some(known_contracts), Some(script_wallets), Some(target.version), ) From 741377fc391cc10fff5fb15f8e23213046db49d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 2 Jun 2024 03:38:30 +0200 Subject: [PATCH 1013/1963] chore(deps): weekly `cargo update` (#8033) Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/revm-inspectors` Locking 43 packages to latest compatible versions Updating alloy-rlp v0.3.4 -> v0.3.5 Updating alloy-rlp-derive v0.3.4 -> v0.3.5 Updating aws-config v1.4.0 -> v1.5.0 Updating aws-sdk-kms v1.26.0 -> v1.29.0 Updating aws-sdk-sts v1.25.0 -> v1.28.0 Updating aws-smithy-runtime v1.5.0 -> v1.5.4 Updating aws-smithy-runtime-api v1.6.0 -> v1.6.1 Updating aws-smithy-types v1.1.9 -> v1.1.10 Updating aws-types v1.2.1 -> v1.3.0 Updating blst v0.3.11 -> v0.3.12 Updating cc v1.0.97 -> v1.0.98 Updating const-hex v1.11.4 -> v1.12.0 Updating crc32fast v1.4.0 -> v1.4.2 Updating crossbeam-channel v0.5.12 -> v0.5.13 Updating crossbeam-utils v0.8.19 -> v0.8.20 Adding doctest-file v1.0.0 Updating ethereum_ssz v0.5.3 -> v0.5.4 Updating hyper-util v0.1.3 -> v0.1.5 Removing indoc v2.0.5 Updating interprocess v2.1.0 -> v2.1.1 Adding lockfree-object-pool v0.1.6 Updating native-tls v0.2.11 -> v0.2.12 Updating parking_lot v0.12.2 -> v0.12.3 Updating plotters v0.3.5 -> v0.3.6 Updating plotters-backend v0.3.5 -> v0.3.6 Updating plotters-svg v0.3.5 -> v0.3.6 Updating proc-macro2 v1.0.82 -> v1.0.84 Updating ratatui v0.26.2 -> v0.26.3 Updating schemars v0.8.20 -> v0.8.21 Updating schemars_derive v0.8.20 -> v0.8.21 Updating serde v1.0.202 -> v1.0.203 Updating serde_derive v1.0.202 -> v1.0.203 Adding simd-adler32 v0.3.7 Updating strum_macros v0.26.2 -> v0.26.3 Updating svm-rs v0.5.3 -> v0.5.4 Updating svm-rs-builds v0.5.3 -> v0.5.4 Updating syn v2.0.64 -> v2.0.66 Updating tokio v1.37.0 -> v1.38.0 Updating tokio-macros v2.2.0 -> v2.3.0 Adding unicode-truncate v1.0.0 Updating winnow v0.6.8 -> v0.6.9 Updating zeroize v1.7.0 -> v1.8.1 Updating zip v1.3.0 -> v2.1.1 Adding zopfli v0.8.1 note: pass `--verbose` to see 137 unchanged dependencies behind latest Co-authored-by: mattsse --- Cargo.lock | 308 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 173 insertions(+), 135 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4260c729c4ddd..0e7bd7cf0d39d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,7 +126,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.8", + "winnow 0.6.9", ] [[package]] @@ -278,9 +278,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" +checksum = "b155716bab55763c95ba212806cf43d05bcc70e5f35b02bad20cf5ec7fe11fed" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -289,13 +289,13 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" +checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -476,7 +476,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -493,7 +493,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", "syn-solidity", "tiny-keccak", ] @@ -511,7 +511,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.64", + "syn 2.0.66", "syn-solidity", ] @@ -521,7 +521,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "368cae4dc052cad1d8f72eb2ae0c38027116933eeb49213c200a9e9875f208d7" dependencies = [ - "winnow 0.6.8", + "winnow 0.6.9", ] [[package]] @@ -1009,7 +1009,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -1031,7 +1031,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -1042,7 +1042,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -1089,7 +1089,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -1100,9 +1100,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ddbfb5db93d62521f47b3f223da0884a2f02741ff54cb9cda192a0e73ba08b" +checksum = "1234b742ac4a40a7d3459c6e3c99818271976a5a6ae3732cb415f4a9a94da7b6" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1161,9 +1161,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.26.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a6b58615203957a253a180b81db9427cb4b623fc8bab8dcac42369239f7716" +checksum = "53d5f3e0faac32aa4edbcdcc10330e7b6b1fdbb2e83b44439f5696281e18d278" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1183,9 +1183,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.25.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2b4a632a59e4fab7abf1db0d94a3136ad7871aba46bebd1fdb95c7054afcdb" +checksum = "a422d2f3080421ed23630ada0e474c76e4279c18b4a379bff2f1062e05cef466" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1279,9 +1279,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.5.0" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9ac79e9f3a4d576f3cd4a470a0275b138d9e7b11b1cd514a6858ae0a79dd5bb" +checksum = "607e8b53aeb2bc23fb332159d72a69650cd9643c161d76cd3b7f88ac00b5a1bb" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1305,9 +1305,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ec42c2f5c0e7796a2848dde4d9f3bf8ce12ccbb3d5aa40c52fa0cdd61a1c47" +checksum = "5b7d790d553d163c7d80a4e06e2906bf24b9172c9ebe045fc3a274e9358ab7bb" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1322,9 +1322,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf98d97bba6ddaba180f1b1147e202d8fe04940403a95a3f826c790f931bbd1" +checksum = "5b6764ba7e1c5ede1c9f9e4046645534f06c2581402461c559b481a420330a83" dependencies = [ "base64-simd", "bytes", @@ -1354,9 +1354,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a807d90cd50a969b3d95e4e7ad1491fcae13c6e83948d8728363ecc09d66343a" +checksum = "02fa328e19c849b20ef7ada4c9b581dd12351ff35ecc7642d06e69de4f98407c" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1541,9 +1541,9 @@ dependencies = [ [[package]] name = "blst" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +checksum = "62dc83a094a71d43eeadd254b1ec2d24cb6a0bb6cadce00df51f0db594711a32" dependencies = [ "cc", "glob", @@ -1768,9 +1768,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -1925,7 +1925,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -2118,9 +2118,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.4" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ff96486ccc291d36a958107caf2c0af8c78c0af7d31ae2f35ce055130de1a6" +checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" dependencies = [ "cfg-if", "cpufeatures", @@ -2168,9 +2168,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -2215,9 +2215,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -2243,9 +2243,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" @@ -2340,7 +2340,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -2351,7 +2351,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -2423,7 +2423,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -2444,7 +2444,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -2454,7 +2454,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -2574,9 +2574,15 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] +[[package]] +name = "doctest-file" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac81fa3e28d21450aa4d2ac065992ba96a1d7303efbce51a95f4fd175b67562" + [[package]] name = "dotenvy" version = "0.15.7" @@ -2682,7 +2688,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -2806,9 +2812,9 @@ dependencies = [ [[package]] name = "ethereum_ssz" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e61ffea29f26e8249d35128a82ec8d3bd4fbc80179ea5f5e5e3daafef6a80fcb" +checksum = "7d3627f83d8b87b432a5fad9934b4565260722a141a2c40f371f8080adec9425" dependencies = [ "ethereum-types", "itertools 0.10.5", @@ -2832,7 +2838,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.64", + "syn 2.0.66", "toml 0.8.13", "walkdir", ] @@ -2860,7 +2866,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.64", + "syn 2.0.66", "tempfile", "thiserror", "tiny-keccak", @@ -3439,7 +3445,7 @@ dependencies = [ "tokio", "tracing", "walkdir", - "winnow 0.6.8", + "winnow 0.6.9", "yansi", ] @@ -3642,7 +3648,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -3801,7 +3807,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -4246,7 +4252,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -4434,9 +4440,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", "futures-channel", @@ -4592,12 +4598,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "indoc" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" - [[package]] name = "inlinable_string" version = "0.1.15" @@ -4644,10 +4644,11 @@ dependencies = [ [[package]] name = "interprocess" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4d0250d41da118226e55b3d50ca3f0d9e0a0f6829b92f543ac0054aeea1572" +checksum = "13f2533e1f1a70bec71ea7a85d1c0a4dab141c314035ce76e51a19a2f48be708" dependencies = [ + "doctest-file", "futures-core", "libc", "recvmsg", @@ -4908,6 +4909,12 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "lockfree-object-pool" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" + [[package]] name = "log" version = "0.4.21" @@ -5055,7 +5062,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5125,16 +5132,15 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -5357,7 +5363,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5480,7 +5486,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5565,9 +5571,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -5637,7 +5643,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5696,7 +5702,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5780,7 +5786,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5818,7 +5824,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5851,9 +5857,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" dependencies = [ "num-traits", "plotters-backend", @@ -5864,15 +5870,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" dependencies = [ "plotters-backend", ] @@ -5934,7 +5940,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -5995,9 +6001,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" dependencies = [ "unicode-ident", ] @@ -6010,7 +6016,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", "version_check", "yansi", ] @@ -6167,21 +6173,21 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a564a852040e82671dc50a37d88f3aa83bbc690dfc6844cfe7a2591620206a80" +checksum = "f44c9e68fd46eda15c646fbb85e1040b657a58cdc8c98db1d97a55930d991eef" dependencies = [ "bitflags 2.5.0", "cassowary", "compact_str", "crossterm", - "indoc", "itertools 0.12.1", "lru", "paste", "stability", "strum", "unicode-segmentation", + "unicode-truncate", "unicode-width", ] @@ -6789,9 +6795,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0218ceea14babe24a4a5836f86ade86c1effbc198164e619194cb5069187e29" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", "schemars_derive", @@ -6801,14 +6807,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed5a1ccce8ff962e31a165d41f6e2a2dd1245099dc4d594f5574a86cd90f4d3" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -6936,22 +6942,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -6962,7 +6968,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7005,7 +7011,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7051,7 +7057,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7163,6 +7169,12 @@ dependencies = [ "rand_core", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "similar" version = "2.5.0" @@ -7269,7 +7281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" dependencies = [ "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7333,15 +7345,15 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7365,9 +7377,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "svm-rs" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b19990faaaed6298d6b21984544ad941dc88d507330012fb4a6a8d4f1833de73" +checksum = "af5910befd515534a92e9424f250d952fe6f6dba6a92bd001dfeba1fb4a2f87c" dependencies = [ "const-hex", "dirs 5.0.1", @@ -7385,9 +7397,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68be542b0720275ac352f85ab67713ae22d56bcc58d83bdebdd3eda0473a1d7f" +checksum = "3d5ea000fdbeab0b2739315f9093c75ea63030e5c44f92daa72401d11b48adda" dependencies = [ "build_const", "const-hex", @@ -7409,9 +7421,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.64" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -7427,7 +7439,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7528,7 +7540,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7639,9 +7651,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -7658,13 +7670,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -7802,7 +7814,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.8", + "winnow 0.6.9", ] [[package]] @@ -7884,7 +7896,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -8077,6 +8089,16 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +[[package]] +name = "unicode-truncate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5fbabedabe362c618c714dbefda9927b5afc8e2a8102f47f081089a9019226" +dependencies = [ + "itertools 0.12.1", + "unicode-width", +] + [[package]] name = "unicode-width" version = "0.1.12" @@ -8231,7 +8253,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -8265,7 +8287,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8632,9 +8654,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" dependencies = [ "memchr", ] @@ -8709,14 +8731,14 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -8729,14 +8751,14 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] name = "zip" -version = "1.3.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f4a27345eb6f7aa7bd015ba7eb4175fa4e1b462a29874b779e0bbcf96c6ac7" +checksum = "1dd56a4d5921bc2f99947ac5b3abe5f510b1be7376fdc5e9fce4a23c6a93e87c" dependencies = [ "arbitrary", "crc32fast", @@ -8744,5 +8766,21 @@ dependencies = [ "displaydoc", "flate2", "indexmap", + "memchr", "thiserror", + "zopfli", +] + +[[package]] +name = "zopfli" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +dependencies = [ + "bumpalo", + "crc32fast", + "lockfree-object-pool", + "log", + "once_cell", + "simd-adler32", ] From fd4236868e02b41063a063c2f31da127c38a8cdb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 2 Jun 2024 17:23:56 +0300 Subject: [PATCH 1014/1963] fix: enable providers in ethers-contract-abigen (#8032) --- crates/forge/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 9ca39877dbbe0..940acb087189e 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -31,7 +31,7 @@ foundry-evm.workspace = true foundry-wallets.workspace = true foundry-linking.workspace = true -ethers-contract-abigen.workspace = true +ethers-contract-abigen = { workspace = true, features = ["providers"] } revm-inspectors.workspace = true From 0fc39763d46b8ffab5fa4eaeb2f65ae078fa07de Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 2 Jun 2024 19:55:54 +0200 Subject: [PATCH 1015/1963] feat: better run feedback for scripts (#8023) * feat: better feedback for scripts * fix tests * review fixes --- crates/cast/bin/cmd/run.rs | 10 +- crates/cli/src/utils/cmd.rs | 37 ++--- crates/script/src/broadcast.rs | 47 +++---- crates/script/src/lib.rs | 1 + crates/script/src/progress.rs | 245 +++++++++++++++++++++++++++++++++ crates/script/src/receipts.rs | 114 +-------------- 6 files changed, 294 insertions(+), 160 deletions(-) create mode 100644 crates/script/src/progress.rs diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 32bd4fea69b02..0f3ca609d66cc 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -5,10 +5,8 @@ use cast::{revm::primitives::EnvWithHandlerCfg, traces::TraceKind}; use clap::Parser; use eyre::{Result, WrapErr}; use foundry_cli::{ - init_progress, opts::RpcOpts, - update_progress, - utils::{handle_traces, TraceResult}, + utils::{handle_traces, init_progress, TraceResult}, }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::EvmVersion; @@ -153,7 +151,7 @@ impl RunArgs { println!("Executing previous transactions from the block."); if let Some(block) = block { - let pb = init_progress!(block.transactions, "tx"); + let pb = init_progress(block.transactions.len() as u64, "tx"); pb.set_position(0); let BlockTransactions::Full(txs) = block.transactions else { @@ -167,7 +165,7 @@ impl RunArgs { if is_known_system_sender(tx.from) || tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) { - update_progress!(pb, index); + pb.set_position((index + 1) as u64); continue; } if tx.hash == tx_hash { @@ -202,7 +200,7 @@ impl RunArgs { } } - update_progress!(pb, index); + pb.set_position((index + 1) as u64); } } } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 9e8f992414bec..b9020c0457afd 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -141,29 +141,20 @@ pub fn eta_key(state: &indicatif::ProgressState, f: &mut dyn Write) { write!(f, "{:.1}s", state.eta().as_secs_f64()).unwrap() } -#[macro_export] -macro_rules! init_progress { - ($local:expr, $label:expr) => {{ - let pb = indicatif::ProgressBar::new($local.len() as u64); - let mut template = - "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len} ".to_string(); - template += $label; - template += " ({eta})"; - pb.set_style( - indicatif::ProgressStyle::with_template(&template) - .unwrap() - .with_key("eta", $crate::utils::eta_key) - .progress_chars("#>-"), - ); - pb - }}; -} - -#[macro_export] -macro_rules! update_progress { - ($pb:ident, $index:expr) => { - $pb.set_position(($index + 1) as u64); - }; +pub fn init_progress(len: u64, label: &str) -> indicatif::ProgressBar { + let pb = indicatif::ProgressBar::new(len); + let mut template = + "{prefix}{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len} " + .to_string(); + write!(template, "{}", label).unwrap(); + template += " ({eta})"; + pb.set_style( + indicatif::ProgressStyle::with_template(&template) + .unwrap() + .with_key("eta", crate::utils::eta_key) + .progress_chars("#>-"), + ); + pb } /// True if the network calculates gas costs differently. diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 3a2e663700fb4..63b2de818bf7d 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -1,7 +1,6 @@ -use super::receipts; use crate::{ - build::LinkedBuildData, sequence::ScriptSequenceKind, verify::BroadcastedState, ScriptArgs, - ScriptConfig, + build::LinkedBuildData, progress::ScriptProgress, sequence::ScriptSequenceKind, + verify::BroadcastedState, ScriptArgs, ScriptConfig, }; use alloy_chains::Chain; use alloy_eips::eip2718::Encodable2718; @@ -13,10 +12,7 @@ use alloy_transport::Transport; use eyre::{bail, Context, Result}; use forge_verify::provider::VerificationProviderType; use foundry_cheatcodes::ScriptWallets; -use foundry_cli::{ - init_progress, update_progress, - utils::{has_batch_support, has_different_gas_calc}, -}; +use foundry_cli::utils::{has_batch_support, has_different_gas_calc}; use foundry_common::{ provider::{get_http_provider, try_get_http_provider, RetryProvider}, shell, @@ -160,14 +156,17 @@ pub struct BundledState { impl BundledState { pub async fn wait_for_pending(mut self) -> Result { + let progress = ScriptProgress::default(); + let progress_ref = &progress; let futs = self .sequence .sequences_mut() .iter_mut() - .map(|sequence| async move { + .enumerate() + .map(|(sequence_idx, sequence)| async move { let rpc_url = sequence.rpc_url(); let provider = Arc::new(get_http_provider(rpc_url)); - receipts::wait_for_pending(provider, sequence).await + progress_ref.wait_for_pending(sequence_idx, sequence, &provider).await }) .collect::>(); @@ -229,12 +228,16 @@ impl BundledState { SendTransactionsKind::Raw(signers) }; + let progress = ScriptProgress::default(); + for i in 0..self.sequence.sequences().len() { let mut sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); let provider = Arc::new(try_get_http_provider(sequence.rpc_url())?); let already_broadcasted = sequence.receipts.len(); + let seq_progress = progress.get_sequence_progress(i, sequence); + if already_broadcasted < sequence.transactions.len() { let is_legacy = Chain::from(sequence.chain).is_legacy() || self.args.legacy; // Make a one-time gas price estimation @@ -313,8 +316,6 @@ impl BundledState { send_kind.signers_count() != 1 || !has_batch_support(sequence.chain); - let pb = init_progress!(transactions, "txes"); - // We send transactions and wait for receipts in batches. let batch_size = if sequential_broadcast { 1 } else { self.args.batch_size }; let mut index = already_broadcasted; @@ -322,11 +323,11 @@ impl BundledState { for (batch_number, batch) in transactions.chunks(batch_size).enumerate() { let mut pending_transactions = vec![]; - shell::println(format!( - "##\nSending transactions [{} - {}].", + seq_progress.inner.write().set_status(&format!( + "Sending transactions [{} - {}]", batch_number * batch_size, batch_number * batch_size + std::cmp::min(batch_size, batch.len()) - 1 - ))?; + )); for (tx, kind, is_fixed_gas_limit) in batch { let fut = send_transaction( provider.clone(), @@ -351,7 +352,7 @@ impl BundledState { self.sequence.save(true, false)?; sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); - update_progress!(pb, index - already_broadcasted); + seq_progress.inner.write().tx_sent(tx_hash); index += 1; } @@ -359,8 +360,7 @@ impl BundledState { self.sequence.save(true, false)?; sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); - shell::println("##\nWaiting for receipts.")?; - receipts::clear_pendings(provider.clone(), sequence, None).await?; + progress.wait_for_pending(i, sequence, &provider).await? } // Checkpoint save self.sequence.save(true, false)?; @@ -368,9 +368,6 @@ impl BundledState { } } - shell::println("\n\n==========================")?; - shell::println("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; - let (total_gas, total_gas_price, total_paid) = sequence.receipts.iter().fold((0, 0, 0), |acc, receipt| { let gas_used = receipt.gas_used; @@ -381,14 +378,18 @@ impl BundledState { let avg_gas_price = format_units(total_gas_price / sequence.receipts.len() as u128, 9) .unwrap_or_else(|_| "N/A".to_string()); - shell::println(format!( - "Total Paid: {} ETH ({} gas * avg {} gwei)", + seq_progress.inner.write().set_status(&format!( + "Total Paid: {} ETH ({} gas * avg {} gwei)\n", paid.trim_end_matches('0'), total_gas, avg_gas_price.trim_end_matches('0').trim_end_matches('.') - ))?; + )); + seq_progress.inner.write().finish(); } + shell::println("\n\n==========================")?; + shell::println("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; + Ok(BroadcastedState { args: self.args, script_config: self.script_config, diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 39059ed212cc6..95f88dd8d64b6 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -51,6 +51,7 @@ mod broadcast; mod build; mod execute; mod multi_sequence; +mod progress; mod providers; mod receipts; mod runner; diff --git a/crates/script/src/progress.rs b/crates/script/src/progress.rs new file mode 100644 index 0000000000000..c8fd065cb0587 --- /dev/null +++ b/crates/script/src/progress.rs @@ -0,0 +1,245 @@ +use crate::{ + receipts::{check_tx_status, format_receipt, TxStatus}, + sequence::ScriptSequence, +}; +use alloy_chains::Chain; +use alloy_primitives::B256; +use eyre::Result; +use foundry_cli::utils::init_progress; +use foundry_common::provider::RetryProvider; +use futures::StreamExt; +use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; +use parking_lot::RwLock; +use std::{collections::HashMap, fmt::Write, sync::Arc, time::Duration}; +use yansi::Paint; + +/// State of [ProgressBar]s displayed for the given [ScriptSequence]. +#[derive(Debug)] +pub struct SequenceProgressState { + /// The top spinner with containt of the format "Sequence #{id} on {network} | {status}"" + top_spinner: ProgressBar, + /// Progress bar with the count of transactions. + txs: ProgressBar, + /// Progress var with the count of confirmed transactions. + receipts: ProgressBar, + /// Standalone spinners for pending transactions. + tx_spinners: HashMap, + /// Copy of the main [MultiProgress] instance. + multi: MultiProgress, +} + +impl SequenceProgressState { + pub fn new(sequence_idx: usize, sequence: &ScriptSequence, multi: MultiProgress) -> Self { + let mut template = "{spinner:.green}".to_string(); + write!(template, " Sequence #{} on {}", sequence_idx + 1, Chain::from(sequence.chain)) + .unwrap(); + template.push_str("{msg}"); + + let top_spinner = ProgressBar::new_spinner() + .with_style(ProgressStyle::with_template(&template).unwrap().tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈✅")); + let top_spinner = multi.add(top_spinner); + + let txs = multi.insert_after( + &top_spinner, + init_progress(sequence.transactions.len() as u64, "txes").with_prefix(" "), + ); + + let receipts = multi.insert_after( + &txs, + init_progress(sequence.transactions.len() as u64, "receipts").with_prefix(" "), + ); + + top_spinner.enable_steady_tick(Duration::from_millis(100)); + txs.enable_steady_tick(Duration::from_millis(1000)); + receipts.enable_steady_tick(Duration::from_millis(1000)); + + txs.set_position(sequence.receipts.len() as u64); + receipts.set_position(sequence.receipts.len() as u64); + + let mut state = SequenceProgressState { + top_spinner, + txs, + receipts, + tx_spinners: Default::default(), + multi, + }; + + for tx_hash in sequence.pending.iter() { + state.tx_sent(*tx_hash); + } + + state + } + + /// Called when a new transaction is sent. Displays a spinner with a hash of the transaction and + /// advances the sent transactions progress bar. + pub fn tx_sent(&mut self, tx_hash: B256) { + // Avoid showing more than 10 spinners. + if self.tx_spinners.len() < 10 { + let spinner = ProgressBar::new_spinner() + .with_style( + ProgressStyle::with_template(" {spinner:.green} {msg}") + .unwrap() + .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈"), + ) + .with_message(format!("{} {}", "[Pending]".yellow(), tx_hash)); + + let spinner = self.multi.insert_before(&self.txs, spinner); + spinner.enable_steady_tick(Duration::from_millis(100)); + + self.tx_spinners.insert(tx_hash, spinner); + } + self.txs.inc(1); + } + + /// Removes the pending transaction spinner and advances confirmed transactions progress bar. + pub fn finish_tx_spinner(&mut self, tx_hash: B256) { + if let Some(spinner) = self.tx_spinners.remove(&tx_hash) { + spinner.finish_and_clear(); + } + self.receipts.inc(1); + } + + /// Same as finish_tx_spinner but also prints a message to stdout above all other progress bars. + pub fn finish_tx_spinner_with_msg(&mut self, tx_hash: B256, msg: &str) -> std::io::Result<()> { + self.finish_tx_spinner(tx_hash); + self.multi.println(msg)?; + + Ok(()) + } + + /// Sets status for the current sequence progress. + pub fn set_status(&mut self, status: &str) { + self.top_spinner.set_message(format!(" | {status}")); + } + + /// Hides transactions and receipts progress bar, leaving only top line with the latest set + /// status. + pub fn finish(&self) { + self.top_spinner.finish(); + self.txs.finish_and_clear(); + self.receipts.finish_and_clear(); + } +} + +/// Clonable wrapper around [SequenceProgressState]. +#[derive(Debug, Clone)] +pub struct SequenceProgress { + pub inner: Arc>, +} + +impl SequenceProgress { + pub fn new(sequence_idx: usize, sequence: &ScriptSequence, multi: MultiProgress) -> Self { + Self { + inner: Arc::new(RwLock::new(SequenceProgressState::new(sequence_idx, sequence, multi))), + } + } +} + +/// Container for multiple [SequenceProgress] instances keyed by sequence index. +#[derive(Debug, Clone, Default)] +pub struct ScriptProgress { + state: Arc>>, + multi: MultiProgress, +} + +impl ScriptProgress { + /// Returns a [SequenceProgress] instance for the given sequence index. If it doesn't exist, + /// creates one. + pub fn get_sequence_progress( + &self, + sequence_idx: usize, + sequence: &ScriptSequence, + ) -> SequenceProgress { + if let Some(progress) = self.state.read().get(&sequence_idx) { + return progress.clone(); + } + let progress = SequenceProgress::new(sequence_idx, sequence, self.multi.clone()); + self.state.write().insert(sequence_idx, progress.clone()); + progress + } + + /// Traverses a set of pendings and either finds receipts, or clears them from + /// the deployment sequence. + /// + /// For each `tx_hash`, we check if it has confirmed. If it has + /// confirmed, we push the receipt (if successful) or push an error (if + /// revert). If the transaction has not confirmed, but can be found in the + /// node's mempool, we wait for its receipt to be available. If the transaction + /// has not confirmed, and cannot be found in the mempool, we remove it from + /// the `deploy_sequence.pending` vector so that it will be rebroadcast in + /// later steps. + pub async fn wait_for_pending( + &self, + sequence_idx: usize, + deployment_sequence: &mut ScriptSequence, + provider: &RetryProvider, + ) -> Result<()> { + if deployment_sequence.pending.is_empty() { + return Ok(()); + } + + let count = deployment_sequence.pending.len(); + let seq_progress = self.get_sequence_progress(sequence_idx, deployment_sequence); + + seq_progress.inner.write().set_status("Waiting for pending transactions"); + + trace!("Checking status of {count} pending transactions"); + + let futs = + deployment_sequence.pending.clone().into_iter().map(|tx| check_tx_status(provider, tx)); + let mut tasks = futures::stream::iter(futs).buffer_unordered(10); + + let mut errors: Vec = vec![]; + + while let Some((tx_hash, result)) = tasks.next().await { + match result { + Err(err) => { + errors.push(format!("Failure on receiving a receipt for {tx_hash:?}:\n{err}")); + + seq_progress.inner.write().finish_tx_spinner(tx_hash); + } + Ok(TxStatus::Dropped) => { + // We want to remove it from pending so it will be re-broadcast. + deployment_sequence.remove_pending(tx_hash); + errors.push(format!("Transaction dropped from the mempool: {tx_hash:?}")); + + seq_progress.inner.write().finish_tx_spinner(tx_hash); + } + Ok(TxStatus::Success(receipt)) => { + trace!(tx_hash=?tx_hash, "received tx receipt"); + + let msg = format_receipt(deployment_sequence.chain.into(), &receipt); + seq_progress.inner.write().finish_tx_spinner_with_msg(tx_hash, &msg)?; + + deployment_sequence.remove_pending(receipt.transaction_hash); + deployment_sequence.add_receipt(receipt); + } + Ok(TxStatus::Revert(receipt)) => { + // consider: + // if this is not removed from pending, then the script becomes + // un-resumable. Is this desirable on reverts? + warn!(tx_hash=?tx_hash, "Transaction Failure"); + deployment_sequence.remove_pending(receipt.transaction_hash); + + let msg = format_receipt(deployment_sequence.chain.into(), &receipt); + seq_progress.inner.write().finish_tx_spinner_with_msg(tx_hash, &msg)?; + + errors.push(format!("Transaction Failure: {:?}", receipt.transaction_hash)); + } + } + } + + // print any errors + if !errors.is_empty() { + let mut error_msg = errors.join("\n"); + if !deployment_sequence.pending.is_empty() { + error_msg += "\n\n Add `--resume` to your command to try and continue broadcasting + the transactions." + } + eyre::bail!(error_msg); + } + + Ok(()) + } +} diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 5686f18f68d74..57c3e94a3b273 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -1,16 +1,12 @@ -use super::sequence::ScriptSequence; use alloy_chains::Chain; use alloy_primitives::{utils::format_units, TxHash, U256}; use alloy_provider::{PendingTransactionBuilder, Provider}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::Result; -use foundry_cli::{init_progress, update_progress}; use foundry_common::provider::RetryProvider; -use futures::StreamExt; -use std::sync::Arc; /// Convenience enum for internal signalling of transaction status -enum TxStatus { +pub enum TxStatus { Dropped, Success(AnyTransactionReceipt), Revert(AnyTransactionReceipt), @@ -26,106 +22,9 @@ impl From for TxStatus { } } -/// Gets the receipts of previously pending transactions, or removes them from -/// the deploy sequence's pending vector -pub async fn wait_for_pending( - provider: Arc, - deployment_sequence: &mut ScriptSequence, -) -> Result<()> { - if deployment_sequence.pending.is_empty() { - return Ok(()); - } - println!("##\nChecking previously pending transactions."); - clear_pendings(provider, deployment_sequence, None).await -} - -/// Traverses a set of pendings and either finds receipts, or clears them from -/// the deployment sequence. -/// -/// If no `tx_hashes` are provided, then `deployment_sequence.pending` will be -/// used. For each `tx_hash`, we check if it has confirmed. If it has -/// confirmed, we push the receipt (if successful) or push an error (if -/// revert). If the transaction has not confirmed, but can be found in the -/// node's mempool, we wait for its receipt to be available. If the transaction -/// has not confirmed, and cannot be found in the mempool, we remove it from -/// the `deploy_sequence.pending` vector so that it will be rebroadcast in -/// later steps. -pub async fn clear_pendings( - provider: Arc, - deployment_sequence: &mut ScriptSequence, - tx_hashes: Option>, -) -> Result<()> { - let to_query = tx_hashes.unwrap_or_else(|| deployment_sequence.pending.clone()); - - let count = deployment_sequence.pending.len(); - - trace!("Checking status of {count} pending transactions"); - - let futs = to_query.iter().copied().map(|tx| check_tx_status(&provider, tx)); - let mut tasks = futures::stream::iter(futs).buffer_unordered(10); - - let mut errors: Vec = vec![]; - let mut receipts = Vec::::with_capacity(count); - - // set up progress bar - let mut pos = 0; - let pb = init_progress!(deployment_sequence.pending, "receipts"); - pb.set_position(pos); - - while let Some((tx_hash, result)) = tasks.next().await { - match result { - Err(err) => { - errors.push(format!("Failure on receiving a receipt for {tx_hash:?}:\n{err}")) - } - Ok(TxStatus::Dropped) => { - // We want to remove it from pending so it will be re-broadcast. - deployment_sequence.remove_pending(tx_hash); - errors.push(format!("Transaction dropped from the mempool: {tx_hash:?}")); - } - Ok(TxStatus::Success(receipt)) => { - trace!(tx_hash=?tx_hash, "received tx receipt"); - deployment_sequence.remove_pending(receipt.transaction_hash); - receipts.push(receipt); - } - Ok(TxStatus::Revert(receipt)) => { - // consider: - // if this is not removed from pending, then the script becomes - // un-resumable. Is this desirable on reverts? - warn!(tx_hash=?tx_hash, "Transaction Failure"); - deployment_sequence.remove_pending(receipt.transaction_hash); - errors.push(format!("Transaction Failure: {:?}", receipt.transaction_hash)); - } - } - // update the progress bar - update_progress!(pb, pos); - pos += 1; - } - - // sort receipts by blocks asc and index - receipts.sort_by_key(|r| (r.block_number, r.transaction_index)); - - // print all receipts - for receipt in receipts { - print_receipt(deployment_sequence.chain.into(), &receipt); - deployment_sequence.add_receipt(receipt); - } - - // print any errors - if !errors.is_empty() { - let mut error_msg = errors.join("\n"); - if !deployment_sequence.pending.is_empty() { - error_msg += "\n\n Add `--resume` to your command to try and continue broadcasting - the transactions." - } - eyre::bail!(error_msg); - } - - Ok(()) -} - /// Checks the status of a txhash by first polling for a receipt, then for /// mempool inclusion. Returns the tx hash, and a status -async fn check_tx_status( +pub async fn check_tx_status( provider: &RetryProvider, hash: TxHash, ) -> (TxHash, Result) { @@ -151,11 +50,11 @@ async fn check_tx_status( } /// Prints parts of the receipt to stdout -pub fn print_receipt(chain: Chain, receipt: &AnyTransactionReceipt) { +pub fn format_receipt(chain: Chain, receipt: &AnyTransactionReceipt) -> String { let gas_used = receipt.gas_used; let gas_price = receipt.effective_gas_price; - foundry_common::shell::println(format!( - "\n##### {chain}\n{status}Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n", + format!( + "\n##### {chain}\n{status}Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n\n", status = if !receipt.inner.inner.inner.receipt.status { "❌ [Failed]" } else { @@ -180,6 +79,5 @@ pub fn print_receipt(chain: Chain, receipt: &AnyTransactionReceipt) { gas_price.trim_end_matches('0').trim_end_matches('.') ) }, - )) - .expect("could not print receipt"); + ) } From 9eebb37588e2bda4393157fd157f5468f603803b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 3 Jun 2024 13:43:01 +0200 Subject: [PATCH 1016/1963] fix: use timeouts for script transactions (#8037) --- crates/script/src/receipts.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 57c3e94a3b273..16f97536b0911 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -4,6 +4,7 @@ use alloy_provider::{PendingTransactionBuilder, Provider}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::Result; use foundry_common::provider::RetryProvider; +use std::time::Duration; /// Convenience enum for internal signalling of transaction status pub enum TxStatus { @@ -40,6 +41,7 @@ pub async fn check_tx_status( // If the tx is present in the mempool, run the pending tx future, and // assume the next drop is really really real Ok(PendingTransactionBuilder::new(provider, hash) + .with_timeout(Some(Duration::from_secs(120))) .get_receipt() .await .map_or(TxStatus::Dropped, |r| r.into())) From 3b175cb852cbac6ab29fa7f470fe5461277a6e1d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 3 Jun 2024 13:45:35 +0200 Subject: [PATCH 1017/1963] refactor: deploy all libraries when running tests (#8034) * refactor: deploy all libraries when running tests * fix test * fix tests * fix traces test * review fixes * fix * review fixes --- crates/evm/core/src/backend/mod.rs | 5 --- crates/forge/bin/cmd/coverage.rs | 8 ++-- crates/forge/bin/cmd/test/mod.rs | 59 +++++++++++++------------ crates/forge/src/multi_runner.rs | 71 ++++++++++++++---------------- crates/forge/src/result.rs | 23 +--------- crates/forge/src/runner.rs | 34 +++++++------- crates/forge/tests/it/core.rs | 6 +-- crates/forge/tests/it/fuzz.rs | 2 +- crates/forge/tests/it/repros.rs | 2 +- crates/linking/src/lib.rs | 8 ++-- crates/script/src/build.rs | 2 +- 11 files changed, 98 insertions(+), 122 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 88a4b060adb62..357a79f433217 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -536,11 +536,6 @@ impl Backend { /// This will also grant cheatcode access to the test account pub fn set_test_contract(&mut self, acc: Address) -> &mut Self { trace!(?acc, "setting test account"); - // toggle the previous sender - if let Some(current) = self.inner.test_contract_address.take() { - self.remove_persistent_account(¤t); - self.revoke_cheatcode_access(&acc); - } self.add_persistent_account(acc); self.allow_cheatcode_access(acc); diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index efdcc0e38f6f4..22dbab67c5683 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -246,6 +246,8 @@ impl CoverageArgs { .set_coverage(true) .build(&root, output, env, evm_opts)?; + let known_contracts = runner.known_contracts.clone(); + let outcome = self .test .run_tests(runner, config.clone(), verbosity, &self.test.filter(&config)) @@ -257,12 +259,10 @@ impl CoverageArgs { for result in suite.test_results.values() { let Some(hit_maps) = result.coverage.as_ref() else { continue }; for map in hit_maps.0.values() { - if let Some((id, _)) = - suite.known_contracts.find_by_deployed_code(&map.bytecode) - { + if let Some((id, _)) = known_contracts.find_by_deployed_code(&map.bytecode) { hits.push((id, map, true)); } else if let Some((id, _)) = - suite.known_contracts.find_by_creation_code(&map.bytecode) + known_contracts.find_by_creation_code(&map.bytecode) { hits.push((id, map, false)); } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 8f1df029c45f2..03d6266d71f50 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -312,11 +312,12 @@ impl TestArgs { *test_pattern = Some(debug_test_pattern.clone()); } + let libraries = runner.libraries.clone(); let outcome = self.run_tests(runner, config, verbosity, &filter).await?; if should_debug { // Get first non-empty suite result. We will have only one such entry - let Some((suite_result, test_result)) = outcome + let Some((_, test_result)) = outcome .results .iter() .find(|(_, r)| !r.test_results.is_empty()) @@ -328,7 +329,7 @@ impl TestArgs { let sources = ContractSources::from_project_output( output_clone.as_ref().unwrap(), project.root(), - &suite_result.libraries, + &libraries, )?; // Run the debugger. @@ -376,6 +377,7 @@ impl TestArgs { } let remote_chain_id = runner.evm_opts.get_remote_chain_id().await; + let known_contracts = runner.known_contracts.clone(); // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); @@ -385,6 +387,28 @@ impl TestArgs { move || runner.test(&filter, tx) }); + // Set up trace identifiers. + let mut identifier = TraceIdentifiers::new().with_local(&known_contracts); + + // Avoid using etherscan for gas report as we decode more traces and this will be + // expensive. + if !self.gas_report { + identifier = identifier.with_etherscan(&config, remote_chain_id)?; + } + + // Build the trace decoder. + let mut builder = CallTraceDecoderBuilder::new() + .with_known_contracts(&known_contracts) + .with_verbosity(verbosity); + // Signatures are of no value for gas reports. + if !self.gas_report { + builder = builder.with_signature_identifier(SignaturesIdentifier::new( + Config::foundry_cache_dir(), + config.offline, + )?); + } + let mut decoder = builder.build(); + let mut gas_report = self .gas_report .then(|| GasReport::new(config.gas_reports.clone(), config.gas_reports_ignore.clone())); @@ -392,31 +416,11 @@ impl TestArgs { let mut outcome = TestOutcome::empty(self.allow_failure); let mut any_test_failed = false; - for (contract_name, mut suite_result) in rx { + for (contract_name, suite_result) in rx { let tests = &suite_result.test_results; - // Set up trace identifiers. - let known_contracts = &suite_result.known_contracts; - let mut identifier = TraceIdentifiers::new().with_local(known_contracts); - - // Avoid using etherscan for gas report as we decode more traces and this will be - // expensive. - if !self.gas_report { - identifier = identifier.with_etherscan(&config, remote_chain_id)?; - } - - // Build the trace decoder. - let mut builder = CallTraceDecoderBuilder::new() - .with_known_contracts(known_contracts) - .with_verbosity(verbosity); - // Signatures are of no value for gas reports. - if !self.gas_report { - builder = builder.with_signature_identifier(SignaturesIdentifier::new( - Config::foundry_cache_dir(), - config.offline, - )?); - } - let mut decoder = builder.build(); + // Clear the addresses and labels from previous test. + decoder.clear_addresses(); // We identify addresses if we're going to print *any* trace or gas report. let identify_addresses = verbosity >= 3 || self.gas_report || self.debug.is_some(); @@ -520,18 +524,15 @@ impl TestArgs { // Print suite summary. shell::println(suite_result.summary())?; - // Free memory if it's not needed. - suite_result.clear_unneeded(); - // Add the suite result to the outcome. outcome.results.insert(contract_name, suite_result); - outcome.last_run_decoder = Some(decoder); // Stop processing the remaining suites if any test failed and `fail_fast` is set. if self.fail_fast && any_test_failed { break; } } + outcome.last_run_decoder = Some(decoder); let duration = timer.elapsed(); trace!(target: "forge::test", len=outcome.results.len(), %any_test_failed, "done with results"); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index d910215e9c26d..4e671a77a6307 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,11 +1,13 @@ //! Forge test runner for multiple contracts. -use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; +use crate::{ + result::SuiteResult, runner::LIBRARY_DEPLOYER, ContractRunner, TestFilter, TestOptions, +}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput, Solc}; +use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput}; use foundry_config::Config; use foundry_evm::{ backend::Backend, decode::RevertDecoder, executors::ExecutorBuilder, fork::CreateFork, @@ -27,8 +29,6 @@ use std::{ pub struct TestContract { pub abi: JsonAbi, pub bytecode: Bytes, - pub libs_to_deploy: Vec, - pub libraries: Libraries, } pub type DeployableContracts = BTreeMap; @@ -61,8 +61,12 @@ pub struct MultiContractRunner { pub test_options: TestOptions, /// Whether to enable call isolation pub isolation: bool, - /// Output of the project compilation - pub output: ProjectCompileOutput, + /// Known contracts linked with computed library addresses. + pub known_contracts: ContractsByArtifact, + /// Libraries to deploy. + pub libs_to_deploy: Vec, + /// Library addresses used to link contracts. + pub libraries: Libraries, } impl MultiContractRunner { @@ -181,17 +185,10 @@ impl MultiContractRunner { let identifier = artifact_id.identifier(); let mut span_name = identifier.as_str(); - let linker = Linker::new( - self.config.project_paths::().root, - self.output.artifact_ids().collect(), - ); - let linked_contracts = linker.get_linked_artifacts(&contract.libraries).unwrap_or_default(); - let known_contracts = ContractsByArtifact::new(linked_contracts); - let cheats_config = CheatsConfig::new( &self.config, self.evm_opts.clone(), - Some(known_contracts.clone()), + Some(self.known_contracts.clone()), None, Some(artifact_id.version.clone()), ); @@ -220,12 +217,13 @@ impl MultiContractRunner { &identifier, executor, contract, + &self.libs_to_deploy, self.evm_opts.initial_balance, self.sender, &self.revert_decoder, self.debug, ); - let r = runner.run_tests(filter, &self.test_options, known_contracts, handle); + let r = runner.run_tests(filter, &self.test_options, self.known_contracts.clone(), handle); debug!(duration=?r.duration, "executed all tests in contract"); @@ -332,10 +330,19 @@ impl MultiContractRunnerBuilder { .filter_map(|(_, contract)| contract.abi.as_ref().map(|abi| abi.borrow())); let revert_decoder = RevertDecoder::new().with_abis(abis); + let LinkOutput { libraries, libs_to_deploy } = linker.link_with_nonce_or_address( + Default::default(), + LIBRARY_DEPLOYER, + 0, + linker.contracts.keys(), + )?; + + let linked_contracts = linker.get_linked_artifacts(&libraries)?; + // Create a mapping of name => (abi, deployment code, Vec) let mut deployable_contracts = DeployableContracts::default(); - for (id, contract) in linker.contracts.iter() { + for (id, contract) in linked_contracts.iter() { let Some(abi) = contract.abi.as_ref() else { continue; }; @@ -344,35 +351,19 @@ impl MultiContractRunnerBuilder { if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && abi.functions().any(|func| func.name.is_test() || func.name.is_invariant_test()) { - let LinkOutput { libs_to_deploy, libraries } = linker.link_with_nonce_or_address( - Default::default(), - evm_opts.sender, - 1, - id, - )?; - - let linked_contract = linker.link(id, &libraries)?; - - let Some(bytecode) = linked_contract - .get_bytecode_bytes() - .map(|b| b.into_owned()) - .filter(|b| !b.is_empty()) + let Some(bytecode) = + contract.get_bytecode_bytes().map(|b| b.into_owned()).filter(|b| !b.is_empty()) else { continue; }; - deployable_contracts.insert( - id.clone(), - TestContract { - abi: abi.clone().into_owned(), - bytecode, - libs_to_deploy, - libraries, - }, - ); + deployable_contracts + .insert(id.clone(), TestContract { abi: abi.clone(), bytecode }); } } + let known_contracts = ContractsByArtifact::new(linked_contracts); + Ok(MultiContractRunner { contracts: deployable_contracts, evm_opts, @@ -386,7 +377,9 @@ impl MultiContractRunnerBuilder { debug: self.debug, test_options: self.test_options.unwrap_or_default(), isolation: self.isolation, - output, + known_contracts, + libs_to_deploy, + libraries, }) } } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index ab289db54d195..cd168c1d7a0f3 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -2,10 +2,7 @@ use crate::gas_report::GasReport; use alloy_primitives::{Address, Log}; -use foundry_common::{ - evm::Breakpoints, get_contract_name, get_file_name, shell, ContractsByArtifact, -}; -use foundry_compilers::artifacts::Libraries; +use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ coverage::HitMaps, debug::DebugArena, @@ -196,13 +193,6 @@ pub struct SuiteResult { pub test_results: BTreeMap, /// Generated warnings. pub warnings: Vec, - /// Libraries used to link test contract. - pub libraries: Libraries, - /// Contracts linked with correct libraries. - /// - /// This is cleared at the end of the test run if coverage is not enabled. - #[serde(skip)] - pub known_contracts: ContractsByArtifact, } impl SuiteResult { @@ -210,17 +200,8 @@ impl SuiteResult { duration: Duration, test_results: BTreeMap, warnings: Vec, - libraries: Libraries, - known_contracts: ContractsByArtifact, ) -> Self { - Self { duration, test_results, warnings, libraries, known_contracts } - } - - /// Frees memory that is not used for the final output. - pub fn clear_unneeded(&mut self) { - if !self.test_results.values().any(|r| r.coverage.is_some()) { - ContractsByArtifact::clear(&mut self.known_contracts); - } + Self { duration, test_results, warnings } } /// Returns an iterator over all individual succeeding tests and their names. diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index ea6b6efe70e34..72f8b03c45f83 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -8,7 +8,7 @@ use crate::{ }; use alloy_dyn_abi::DynSolValue; use alloy_json_abi::Function; -use alloy_primitives::{Address, U256}; +use alloy_primitives::{address, Address, Bytes, U256}; use eyre::Result; use foundry_common::{ contracts::{ContractsByAddress, ContractsByArtifact}, @@ -43,12 +43,21 @@ use std::{ time::Instant, }; +/// When running tests, we deploy all external libraries present in the project. To avoid additional +/// libraries affecting nonces of senders used in tests, we are using separate address to +/// predeploy libraries. +/// +/// `address(uint160(uint256(keccak256("foundry library deployer"))))` +pub const LIBRARY_DEPLOYER: Address = address!("1F95D37F27EA0dEA9C252FC09D5A6eaA97647353"); + /// A type that executes all tests of a contract #[derive(Clone, Debug)] pub struct ContractRunner<'a> { pub name: &'a str, /// The data of the contract being ran. pub contract: &'a TestContract, + /// The libraries that need to be deployed before the contract. + pub libs_to_deploy: &'a Vec, /// The executor used by the runner. pub executor: Executor, /// Revert decoder. Contains all known errors. @@ -62,10 +71,12 @@ pub struct ContractRunner<'a> { } impl<'a> ContractRunner<'a> { + #[allow(clippy::too_many_arguments)] pub fn new( name: &'a str, executor: Executor, contract: &'a TestContract, + libs_to_deploy: &'a Vec, initial_balance: U256, sender: Option
, revert_decoder: &'a RevertDecoder, @@ -75,6 +86,7 @@ impl<'a> ContractRunner<'a> { name, executor, contract, + libs_to_deploy, initial_balance, sender: sender.unwrap_or_default(), revert_decoder, @@ -104,11 +116,13 @@ impl<'a> ContractRunner<'a> { self.executor.set_nonce(self.sender, 1)?; // Deploy libraries + self.executor.set_balance(LIBRARY_DEPLOYER, U256::MAX)?; + let mut logs = Vec::new(); - let mut traces = Vec::with_capacity(self.contract.libs_to_deploy.len()); - for code in self.contract.libs_to_deploy.iter() { + let mut traces = Vec::with_capacity(self.libs_to_deploy.len()); + for code in self.libs_to_deploy.iter() { match self.executor.deploy( - self.sender, + LIBRARY_DEPLOYER, code.clone(), U256::ZERO, Some(self.revert_decoder), @@ -286,8 +300,6 @@ impl<'a> ContractRunner<'a> { [("setUp()".to_string(), TestResult::fail("multiple setUp functions".to_string()))] .into(), warnings, - self.contract.libraries.clone(), - known_contracts, ) } @@ -324,8 +336,6 @@ impl<'a> ContractRunner<'a> { )] .into(), warnings, - self.contract.libraries.clone(), - known_contracts, ) } @@ -383,13 +393,7 @@ impl<'a> ContractRunner<'a> { .collect::>(); let duration = start.elapsed(); - let suite_result = SuiteResult::new( - duration, - test_results, - warnings, - self.contract.libraries.clone(), - known_contracts, - ); + let suite_result = SuiteResult::new(duration, test_results, warnings); info!( duration=?suite_result.duration, "done. {}/{} successful", diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 34cdc0d179287..b229f151f2d3b 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -710,12 +710,12 @@ async fn test_trace() { result.traces.iter().filter(|(kind, _)| *kind == TraceKind::Deployment); let setup_traces = result.traces.iter().filter(|(kind, _)| *kind == TraceKind::Setup); let execution_traces = - result.traces.iter().filter(|(kind, _)| *kind == TraceKind::Deployment); + result.traces.iter().filter(|(kind, _)| *kind == TraceKind::Execution); assert_eq!( deployment_traces.count(), - 1, - "Test {test_name} did not have exactly 1 deployment trace." + 12, + "Test {test_name} did not have exactly 12 deployment trace." ); assert!(setup_traces.count() <= 1, "Test {test_name} had more than 1 setup trace."); assert_eq!( diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 46f8115ab55c8..4f8a6d41272b9 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -158,7 +158,7 @@ async fn test_persist_fuzz_failure() { async fn test_scrape_bytecode() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzScrapeBytecode.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.runs = 750; + runner.test_options.fuzz.runs = 2000; runner.test_options.fuzz.seed = Some(U256::from(6u32)); let suite_result = runner.test_collect(&filter); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 75856c5e47ce7..aeae1175aa085 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -254,7 +254,7 @@ test_repro!(6501, false, None, |res| { assert_eq!(test.status, TestStatus::Success); assert_eq!(test.decoded_logs, ["a".to_string(), "1".to_string(), "b 2".to_string()]); - let (kind, traces) = test.traces[1].clone(); + let (kind, traces) = test.traces.last().unwrap().clone(); let nodes = traces.into_nodes(); assert_eq!(kind, TraceKind::Execution); diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index 8c0c6f5fedc89..8d9791a183cd8 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -138,14 +138,16 @@ impl<'a> Linker<'a> { libraries: Libraries, sender: Address, mut nonce: u64, - target: &'a ArtifactId, + targets: impl IntoIterator, ) -> Result { // Library paths in `link_references` keys are always stripped, so we have to strip // user-provided paths to be able to match them correctly. let mut libraries = libraries.with_stripped_file_prefixes(self.root.as_path()); let mut needed_libraries = BTreeSet::new(); - self.collect_dependencies(target, &mut needed_libraries)?; + for target in targets { + self.collect_dependencies(target, &mut needed_libraries)?; + } let mut libs_to_deploy = Vec::new(); @@ -324,7 +326,7 @@ mod tests { let linker = Linker::new(self.project.root(), self.output.artifact_ids().collect()); for (id, identifier) in self.iter_linking_targets(&linker) { let output = linker - .link_with_nonce_or_address(Default::default(), sender, initial_nonce, id) + .link_with_nonce_or_address(Default::default(), sender, initial_nonce, [id]) .expect("Linking failed"); self.validate_assertions(identifier, output); } diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index a2462e4b2d85d..90e72c66cadac 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -81,7 +81,7 @@ impl BuildData { known_libraries, script_config.evm_opts.sender, script_config.sender_nonce, - &self.target, + [&self.target], )?; (output.libraries, ScriptPredeployLibraries::Default(output.libs_to_deploy)) From 590f5669df6d69766fc8ad7c288e83d821c367e2 Mon Sep 17 00:00:00 2001 From: Alisina Bahadori Date: Mon, 3 Jun 2024 14:03:25 -0400 Subject: [PATCH 1018/1963] Fix shadowed branch coverage PC variable (#8040) --- crates/evm/coverage/src/anchors.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index f717e24abced3..a31ef0237fd0e 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -143,15 +143,15 @@ pub fn find_anchor_branch( let push_bytes = &bytecode[push_bytes_start..push_bytes_start + push_size]; let mut pc_bytes = [0u8; 8]; pc_bytes[8 - push_size..].copy_from_slice(push_bytes); - let pc = u64::from_be_bytes(pc_bytes); - let pc = usize::try_from(pc).expect("PC is too big"); + let pc_jump = u64::from_be_bytes(pc_bytes); + let pc_jump = usize::try_from(pc_jump).expect("PC is too big"); anchors = Some(( ItemAnchor { item_id, // The first branch is the opcode directly after JUMPI instruction: pc + 2, }, - ItemAnchor { item_id, instruction: pc }, + ItemAnchor { item_id, instruction: pc_jump }, )); } } From fbad377ab26a432e48444cf324feee1195a30960 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 3 Jun 2024 23:11:15 +0200 Subject: [PATCH 1019/1963] bump compilers (#8011) * patch compilers * patch block-explorers * update patch * add println * add printlm * RUST_LOG * update patch * update patch * fix * update patch * update patch * skip vyper contracts * fix * update patch * rm patch * fix generics --- Cargo.lock | 10 +-- Cargo.toml | 4 +- crates/cast/bin/cmd/storage.rs | 28 ++++--- crates/cheatcodes/src/fs.rs | 2 +- crates/chisel/benches/session_source.rs | 8 +- crates/chisel/src/executor.rs | 13 +-- crates/chisel/src/session_source.rs | 25 +++--- crates/cli/src/opts/build/core.rs | 5 +- crates/common/src/compile.rs | 40 +++------ crates/config/src/lib.rs | 107 ++++++++---------------- crates/forge/bin/cmd/build.rs | 45 +++------- crates/forge/bin/cmd/coverage.rs | 12 +-- crates/forge/bin/cmd/flatten.rs | 6 +- crates/forge/bin/cmd/fmt.rs | 4 +- crates/forge/bin/cmd/geiger/mod.rs | 4 +- crates/forge/bin/cmd/test/mod.rs | 17 ++-- crates/forge/bin/cmd/tree.rs | 4 +- crates/forge/src/multi_runner.rs | 4 +- crates/forge/tests/cli/config.rs | 6 +- crates/forge/tests/cli/test_cmd.rs | 1 + crates/script/src/verify.rs | 8 +- crates/test-utils/src/util.rs | 5 +- crates/verify/src/bytecode.rs | 7 +- crates/verify/src/etherscan/flatten.rs | 34 +++++--- crates/verify/src/provider.rs | 23 ++--- 25 files changed, 175 insertions(+), 247 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e7bd7cf0d39d..375391847d281 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3257,9 +3257,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.2.8" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7101c78b700b8c84294aee0319289af724201181a9b757d8a9a2fea991f3ce4e" +checksum = "673c42208fee48238ef6833cf55295c9e9b5546383caf426da72d849fb43dc24" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3412,9 +3412,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd571882cd635dd2a11169d5b696e51644fc803487989e2b5fd7ff6bdd008f1c" +checksum = "fe70a3860ec9f1861e5d82cbd4ffc55756975c0826dacf8ae4d6d696df8f7f53" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3425,7 +3425,7 @@ dependencies = [ "fs_extra", "futures-util", "home", - "itertools 0.12.1", + "itertools 0.13.0", "md-5", "memmap2 0.9.4", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index d9db1d72f1e80..3818778fa02e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,8 +137,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.2.8", default-features = false } -foundry-compilers = { version = "0.5.2", default-features = false } +foundry-block-explorers = { version = "0.3.0", default-features = false } +foundry-compilers = { version = "0.6.0", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index a59d93c5d1047..aedf8447190ca 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -20,15 +20,15 @@ use foundry_common::{ }; use foundry_compilers::{ artifacts::StorageLayout, - compilers::{solc::SolcVersionManager, CompilerVersionManager}, - Artifact, CompilerConfig, ConfigurableContractArtifact, Project, + compilers::{solc::SolcCompiler, Compiler, CompilerSettings}, + Artifact, ConfigurableContractArtifact, Project, Solc, }; use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, impl_figment_convert_cast, Config, }; use semver::Version; -use std::{str::FromStr, sync::Arc}; +use std::str::FromStr; /// The minimum Solc version for outputting storage layouts. /// @@ -142,11 +142,10 @@ impl StorageArgs { let mut project = etherscan_project(metadata, root_path)?; add_storage_layout_output(&mut project); - let vm = SolcVersionManager::default(); - project.compiler_config = if auto_detect { - CompilerConfig::AutoDetect(Arc::new(vm)) + project.compiler = if auto_detect { + SolcCompiler::AutoDetect } else { - CompilerConfig::Specific(vm.get_or_install(&version)?) + SolcCompiler::Specific(Solc::find_or_install(&version)?) }; // Compile @@ -160,8 +159,8 @@ impl StorageArgs { if is_storage_layout_empty(&artifact.storage_layout) && auto_detect { // try recompiling with the minimum version eprintln!("The requested contract was compiled with {version} while the minimum version for storage layouts is {MIN_SOLC} and as a result the output may be empty."); - let solc = SolcVersionManager::default().get_or_install(&MIN_SOLC)?; - project.compiler_config = CompilerConfig::Specific(solc); + let solc = Solc::find_or_install(&MIN_SOLC)?; + project.compiler = SolcCompiler::Specific(solc); if let Ok(output) = ProjectCompiler::new().quiet(true).compile(&project) { out = output; let (_, new_artifact) = out @@ -284,10 +283,15 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) Ok(()) } -fn add_storage_layout_output(project: &mut Project) { +fn add_storage_layout_output(project: &mut Project) { project.artifacts.additional_values.storage_layout = true; - let output_selection = project.artifacts.output_selection(); - project.settings.push_all(output_selection); + project.settings.update_output_selection(|selection| { + selection.0.values_mut().for_each(|contract_selection| { + contract_selection + .values_mut() + .for_each(|selection| selection.push("storageLayout".to_string())) + }); + }) } fn is_storage_layout_empty(storage_layout: &Option) -> bool { diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 308d866413061..fd4234d21fa00 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -283,7 +283,7 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result = - Lazy::new(|| SolcVersionManager::default().get_or_install(&Version::new(0, 8, 19)).unwrap()); +static SOLC: Lazy = Lazy::new(|| Solc::find_or_install(&Version::new(0, 8, 19)).unwrap()); /// Benchmark for the `clone_with_new_line` function in [SessionSource] fn clone_with_new_line(c: &mut Criterion) { diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 3ce6a7d199766..eea595486dfa5 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1401,11 +1401,7 @@ impl<'a> Iterator for InstructionIter<'a> { #[cfg(test)] mod tests { use super::*; - use foundry_compilers::{ - compilers::{solc::SolcVersionManager, CompilerVersionManager}, - error::SolcError, - Solc, - }; + use foundry_compilers::{error::SolcError, Solc}; use semver::Version; use std::sync::Mutex; @@ -1690,8 +1686,7 @@ mod tests { for _ in 0..3 { let mut is_preinstalled = PRE_INSTALL_SOLC_LOCK.lock().unwrap(); if !*is_preinstalled { - let solc = SolcVersionManager::default() - .get_or_install(&version.parse().unwrap()) + let solc = Solc::find_or_install(&version.parse().unwrap()) .map(|solc| (solc.version.clone(), solc)); match solc { Ok((v, solc)) => { @@ -1712,9 +1707,7 @@ mod tests { } } - let solc = SolcVersionManager::default() - .get_or_install(&Version::new(0, 8, 19)) - .expect("could not install solc"); + let solc = Solc::find_or_install(&Version::new(0, 8, 19)).expect("could not install solc"); SessionSource::new(solc, Default::default()) } diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 21fa3d8345763..6882a63aa3e42 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -8,7 +8,6 @@ use eyre::Result; use forge_fmt::solang_ext::SafeUnwrap; use foundry_compilers::{ artifacts::{Settings, Source, Sources}, - compilers::{solc::SolcVersionManager, CompilerInput, CompilerVersionManager}, CompilerOutput, Solc, SolcInput, }; use foundry_config::{Config, SolcReq}; @@ -104,8 +103,6 @@ impl SessionSourceConfig { SolcReq::Version(Version::new(0, 8, 19)) }; - let vm = SolcVersionManager::default(); - match solc_req { SolcReq::Version(version) => { // Validate that the requested evm version is supported by the solc version @@ -118,15 +115,16 @@ impl SessionSourceConfig { } } - let solc = if let Ok(solc) = vm.get_installed(&version) { - solc - } else { - if self.foundry_config.offline { - eyre::bail!("can't install missing solc {version} in offline mode") - } - println!("{}", format!("Installing solidity version {version}...").green()); - vm.install(&version)? - }; + let solc = + if let Some(solc) = Solc::find_svm_installed_version(version.to_string())? { + solc + } else { + if self.foundry_config.offline { + eyre::bail!("can't install missing solc {version} in offline mode") + } + println!("{}", format!("Installing solidity version {version}...").green()); + Solc::blocking_install(&version)? + }; Ok(solc) } SolcReq::Local(solc) => { @@ -329,9 +327,10 @@ impl SessionSource { }; // we only care about the solidity source, so we can safely unwrap - SolcInput::build(sources, settings, &self.solc.version) + SolcInput::resolve_and_build(sources, settings) .into_iter() .next() + .map(|i| i.sanitized(&self.solc.version)) .expect("Solidity source not found") } diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 99caaea354542..85575bccce573 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -3,7 +3,8 @@ use crate::{opts::CompilerArgs, utils::LoadConfig}; use clap::{Parser, ValueHint}; use eyre::Result; use foundry_compilers::{ - artifacts::RevertStrings, remappings::Remapping, utils::canonicalized, Project, + artifacts::RevertStrings, compilers::multi::MultiCompiler, remappings::Remapping, + utils::canonicalized, Project, }; use foundry_config::{ figment, @@ -132,7 +133,7 @@ impl CoreBuildArgs { /// This loads the `foundry_config::Config` for the current workspace (see /// [`utils::find_project_root_path`] and merges the cli `BuildArgs` into it before returning /// [`foundry_config::Config::project()`] - pub fn project(&self) -> Result { + pub fn project(&self) -> Result> { let config = self.try_load_config_emit_warnings()?; Ok(config.project()?) } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 329e53213d901..8e8cff36854d8 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -6,15 +6,11 @@ use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ artifacts::{BytecodeObject, ContractBytecodeSome, Libraries}, - compilers::{ - solc::SolcVersionManager, vyper::parser::VyperParsedSource, Compiler, - CompilerVersionManager, - }, + compilers::{solc::SolcCompiler, Compiler}, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, - resolver::{parse::SolData, GraphEdges}, - Artifact, ArtifactId, CompilerConfig, FileFilter, Project, ProjectCompileOutput, - ProjectPathsConfig, SolcConfig, SolcSparseFileFilter, SparseOutputFileFilter, + Artifact, ArtifactId, FileFilter, Project, ProjectBuilder, ProjectCompileOutput, + ProjectPathsConfig, Solc, SolcConfig, SparseOutputFileFilter, }; use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; @@ -521,7 +517,10 @@ pub async fn compile_from_source( } /// Creates a [Project] from an Etherscan source. -pub fn etherscan_project(metadata: &Metadata, target_path: impl AsRef) -> Result { +pub fn etherscan_project( + metadata: &Metadata, + target_path: impl AsRef, +) -> Result> { let target_path = dunce::canonicalize(target_path.as_ref())?; let sources_path = target_path.join(&metadata.contract_name); metadata.source_tree().write_to(&target_path)?; @@ -553,17 +552,16 @@ pub fn etherscan_project(metadata: &Metadata, target_path: impl AsRef) -> .build_with_root(sources_path); let v = metadata.compiler_version()?; - let vm = SolcVersionManager::default(); - let solc = vm.get_or_install(&v)?; + let solc = Solc::find_or_install(&v)?; - let compiler_config = CompilerConfig::Specific(solc); + let compiler = SolcCompiler::Specific(solc); - Ok(Project::builder() + Ok(ProjectBuilder::::default() .settings(SolcConfig::builder().settings(settings).build().settings) .paths(paths) .ephemeral() .no_artifacts() - .build(compiler_config)?) + .build(compiler)?) } /// Bundles multiple `SkipBuildFilter` into a single `FileFilter` @@ -595,22 +593,6 @@ impl FileFilter for &SkipBuildFilters { } } -impl SparseOutputFileFilter for SkipBuildFilters { - fn sparse_sources(&self, file: &Path, graph: &GraphEdges) -> Vec { - SolcSparseFileFilter::new(self).sparse_sources(file, graph) - } -} - -impl SparseOutputFileFilter for SkipBuildFilters { - fn sparse_sources(&self, file: &Path, _graph: &GraphEdges) -> Vec { - if self.is_match(file) { - vec![file.to_path_buf()] - } else { - vec![] - } - } -} - impl SkipBuildFilters { /// Creates a new `SkipBuildFilters` from multiple `SkipBuildFilter`. pub fn new( diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f2957c6a4ce6a..cc2cfc1b6d2db 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -22,14 +22,14 @@ use foundry_compilers::{ }, cache::SOLIDITY_FILES_CACHE_FILENAME, compilers::{ - solc::SolcVersionManager, + multi::{MultiCompiler, MultiCompilerSettings}, + solc::SolcCompiler, vyper::{Vyper, VyperSettings}, - Compiler, CompilerVersionManager, + Compiler, }, error::SolcError, remappings::{RelativeRemapping, Remapping}, - CompilerConfig, ConfigurableArtifacts, EvmVersion, Project, ProjectBuilder, ProjectPathsConfig, - Solc, SolcConfig, + ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, }; use inflector::Inflector; use regex::Regex; @@ -42,7 +42,6 @@ use std::{ fs, path::{Path, PathBuf}, str::FromStr, - sync::Arc, }; // Macros useful for creating a figment. @@ -193,6 +192,8 @@ pub struct Config { /// **Note** for backwards compatibility reasons this also accepts solc_version from the toml /// file, see [`BackwardsCompatProvider`] pub solc: Option, + /// The Vyper instance to use if any. + pub vyper: Option, /// whether to autodetect the solc compiler version to use pub auto_detect_solc: bool, /// Offline mode, if set, network access (downloading solc) is disallowed. @@ -765,55 +766,22 @@ impl Config { /// let config = Config::load_with_root(".").sanitized(); /// let project = config.project(); /// ``` - pub fn project(&self) -> Result { + pub fn project(&self) -> Result, SolcError> { self.create_project(self.cache, false) } - /// Configures [Project] with [Vyper] compiler. - pub fn vyper_project(&self) -> Result, SolcError> { - self.create_vyper_project(self.cache, false) - } - /// Same as [`Self::project()`] but sets configures the project to not emit artifacts and ignore /// cache. - pub fn ephemeral_no_artifacts_project(&self) -> Result { + pub fn ephemeral_no_artifacts_project(&self) -> Result, SolcError> { self.create_project(false, true) } /// Creates a [Project] with the given `cached` and `no_artifacts` flags pub fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { - let compiler_config = self.solc_config()?; - let settings = SolcConfig::builder().settings(self.solc_settings()?).build().settings; - - self.create_project_with_compiler(cached, no_artifacts, compiler_config, settings) - } - - /// Creates a [Project] with the given `cached` and `no_artifacts` flags - pub fn create_vyper_project( - &self, - cached: bool, - no_artifacts: bool, - ) -> Result, SolcError> { - self.create_project_with_compiler( - cached, - no_artifacts, - self.vyper_config()?, - self.vyper_settings()?, - ) - } - - /// Creates a [Project] with a given [CompilerConfig]. - pub fn create_project_with_compiler( - &self, - cached: bool, - no_artifacts: bool, - compiler_config: CompilerConfig, - settings: C::Settings, - ) -> Result, SolcError> { - let project = ProjectBuilder::::new(Default::default()) + let project = Project::builder() .artifacts(self.configured_artifacts_handler()) .paths(self.project_paths()) - .settings(settings) + .settings(self.compiler_settings()?) .ignore_error_codes(self.ignored_error_codes.iter().copied().map(Into::into)) .ignore_paths(self.ignored_file_paths.clone()) .set_compiler_severity_filter(if self.deny_warnings { @@ -825,7 +793,7 @@ impl Config { .set_cached(cached && !self.build_info) .set_build_info(!no_artifacts && self.build_info) .set_no_artifacts(no_artifacts) - .build(compiler_config)?; + .build(self.compiler()?)?; if self.force { self.cleanup(&project)?; @@ -861,10 +829,9 @@ impl Config { /// If `solc` is [`SolcReq::Local`] then this will ensure that the path exists. fn ensure_solc(&self) -> Result, SolcError> { if let Some(ref solc) = self.solc { - let version_manager = SolcVersionManager::default(); let solc = match solc { SolcReq::Version(version) => { - if let Ok(solc) = version_manager.get_installed(version) { + if let Some(solc) = Solc::find_svm_installed_version(version.to_string())? { solc } else { if self.offline { @@ -872,7 +839,7 @@ impl Config { "can't install missing solc {version} in offline mode" ))) } - version_manager.install(version)? + Solc::blocking_install(version)? } } SolcReq::Local(solc) => { @@ -953,21 +920,33 @@ impl Config { } /// Returns configuration for a compiler to use when setting up a [Project]. - pub fn solc_config(&self) -> Result, SolcError> { + pub fn solc_compiler(&self) -> Result { if let Some(solc) = self.ensure_solc()? { - Ok(CompilerConfig::Specific(solc)) + Ok(SolcCompiler::Specific(solc)) } else { - Ok(CompilerConfig::AutoDetect(Arc::new(SolcVersionManager::default()))) + Ok(SolcCompiler::AutoDetect) } } - /// Returns configuration for a compiler to use when setting up a [Project]. - pub fn vyper_config(&self) -> Result, SolcError> { - if let Some(SolcReq::Local(path)) = &self.solc { - Ok(CompilerConfig::Specific(Vyper::new(path)?)) + /// Returns configured [Vyper] compiler. + pub fn vyper_compiler(&self) -> Result, SolcError> { + let vyper = if let Some(path) = &self.vyper { + Some(Vyper::new(path)?) } else { - Ok(CompilerConfig::Specific(Vyper::new("vyper")?)) - } + Vyper::new("vyper").ok() + }; + + Ok(vyper) + } + + /// Returns configuration for a compiler to use when setting up a [Project]. + pub fn compiler(&self) -> Result { + Ok(MultiCompiler { solc: self.solc_compiler()?, vyper: self.vyper_compiler()? }) + } + + /// Returns configured [MultiCompilerSettings]. + pub fn compiler_settings(&self) -> Result { + Ok(MultiCompilerSettings { solc: self.solc_settings()?, vyper: self.vyper_settings()? }) } /// Returns all configured [`Remappings`] @@ -2017,6 +1996,7 @@ impl Default for Config { gas_reports: vec!["*".to_string()], gas_reports_ignore: vec![], solc: None, + vyper: None, auto_detect_solc: true, offline: false, optimizer: true, @@ -2782,23 +2762,6 @@ fn canonic(path: impl Into) -> PathBuf { foundry_compilers::utils::canonicalize(&path).unwrap_or(path) } -/// Executes the given closure with a [Project] configured via the given [Config]. -#[macro_export] -macro_rules! with_resolved_project { - ($config:ident, |$prj:ident| $e:expr) => { - match $config.lang { - foundry_config::Language::Solidity => { - let $prj = $config.project(); - $e - } - foundry_config::Language::Vyper => { - let $prj = $config.vyper_project(); - $e - } - } - }; -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index c4bbbb8a21b3e..c2fc8088f469e 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -3,9 +3,7 @@ use clap::Parser; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}; -use foundry_compilers::{ - compilers::Compiler, Project, ProjectCompileOutput, SparseOutputFileFilter, -}; +use foundry_compilers::{Project, ProjectCompileOutput}; use foundry_config::{ figment::{ self, @@ -13,7 +11,7 @@ use foundry_config::{ value::{Dict, Map, Value}, Metadata, Profile, Provider, }, - with_resolved_project, Config, + Config, }; use serde::Serialize; use watchexec::config::{InitConfig, RuntimeConfig}; @@ -77,7 +75,7 @@ pub struct BuildArgs { } impl BuildArgs { - pub fn run(self) -> Result<()> { + pub fn run(self) -> Result { let mut config = self.try_load_config_emit_warnings()?; if install::install_missing_dependencies(&mut config, self.args.silent) && @@ -87,43 +85,20 @@ impl BuildArgs { config = self.load_config(); } - with_resolved_project!(config, |project| { - let project = project?; - - let filter = if let Some(ref skip) = self.skip { - if !skip.is_empty() { - let filter = SkipBuildFilters::new(skip.clone(), project.root().clone())?; - Some(filter) - } else { - None - } - } else { - None - }; - - self.run_with_project(project, filter)?; - }); + let project = config.project()?; - Ok(()) - } - - pub fn run_with_project( - &self, - project: Project, - filter: Option + 'static>, - ) -> Result> - where - C::CompilationError: Clone, - { let mut compiler = ProjectCompiler::new() .print_names(self.names) .print_sizes(self.sizes) .quiet(self.format_json) .bail(!self.format_json); - if let Some(filter) = filter { - compiler = compiler.filter(Box::new(filter)); - } + if let Some(ref skip) = self.skip { + if !skip.is_empty() { + let filter = SkipBuildFilters::new(skip.clone(), project.root().clone())?; + compiler = compiler.filter(Box::new(filter)); + } + }; let output = compiler.compile(&project)?; diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 22dbab67c5683..2fcfbb1dcb6e5 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -97,7 +97,7 @@ impl CoverageArgs { /// Builds the project. fn build(&self, config: &Config) -> Result<(Project, ProjectCompileOutput)> { // Set up the project - let mut project = config.ephemeral_no_artifacts_project()?; + let mut project = config.create_project(false, false)?; if self.ir_minimum { // TODO: How to detect solc version if the user does not specify a solc version in // config case1: specify local installed solc ? @@ -124,12 +124,12 @@ impl CoverageArgs { // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 // And also in new releases of solidity: // https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 - project.settings = project.settings.with_via_ir_minimum_optimization() + project.settings.solc = project.settings.solc.with_via_ir_minimum_optimization() } else { - project.settings.optimizer.disable(); - project.settings.optimizer.runs = None; - project.settings.optimizer.details = None; - project.settings.via_ir = None; + project.settings.solc.optimizer.disable(); + project.settings.solc.optimizer.runs = None; + project.settings.solc.optimizer.details = None; + project.settings.solc.via_ir = None; } let output = ProjectCompiler::default() diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index c1351d06d95a9..0c9c6f23ae8b1 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -5,7 +5,7 @@ use foundry_cli::{ utils::LoadConfig, }; use foundry_common::{compile::compile_target, fs}; -use foundry_compilers::{error::SolcError, flatten::Flattener}; +use foundry_compilers::{compilers::solc::SolcLanguage, error::SolcError, flatten::Flattener}; use std::path::PathBuf; /// CLI arguments for `forge flatten`. @@ -39,7 +39,7 @@ impl FlattenArgs { let mut config = build_args.try_load_config_emit_warnings()?; // `Flattener` uses the typed AST for better flattening results. config.ast = true; - let project = config.ephemeral_no_artifacts_project()?; + let project = config.create_project(false, true)?; let target_path = dunce::canonicalize(target_path)?; let compiler_output = compile_target(&target_path, &project, false); @@ -52,7 +52,7 @@ impl FlattenArgs { // Fallback to the old flattening implementation if we couldn't compile the target // successfully. This would be the case if the target has invalid // syntax. (e.g. Solang) - project.paths.flatten(&target_path) + project.paths.clone().with_language::().flatten(&target_path) } } .map_err(|err: SolcError| eyre::eyre!("Failed to flatten: {err}"))?; diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 71ac7ceb00836..b3207bcb754e7 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -3,7 +3,7 @@ use eyre::Result; use forge_fmt::{format_to, parse, print_diagnostics_report}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; use foundry_common::{fs, glob::expand_globs, term::cli_warn}; -use foundry_compilers::{Solc, SOLC_EXTENSIONS}; +use foundry_compilers::{compilers::solc::SolcLanguage, SOLC_EXTENSIONS}; use foundry_config::impl_figment_convert_basic; use rayon::prelude::*; use similar::{ChangeTag, TextDiff}; @@ -60,7 +60,7 @@ impl FmtArgs { [] => { // Retrieve the project paths, and filter out the ignored ones. let project_paths: Vec = config - .project_paths::() + .project_paths::() .input_files_iter() .filter(|p| !(ignored.contains(p) || ignored.contains(&cwd.join(p)))) .collect(); diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 0b08f2d0d76ef..451c29dbd7924 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -1,7 +1,7 @@ use clap::{Parser, ValueHint}; use eyre::{Result, WrapErr}; use foundry_cli::utils::LoadConfig; -use foundry_compilers::{resolver::parse::SolData, Graph, Solc}; +use foundry_compilers::{resolver::parse::SolData, Graph}; use foundry_config::{impl_figment_convert_basic, Config}; use itertools::Itertools; use rayon::prelude::*; @@ -62,7 +62,7 @@ impl GeigerArgs { let mut sources: Vec = { if self.paths.is_empty() { - Graph::::resolve(&config.project_paths::())? + Graph::::resolve(&config.project_paths())? .files() .keys() .cloned() diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 03d6266d71f50..a441b8e6651b4 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -20,8 +20,9 @@ use foundry_common::{ shell, }; use foundry_compilers::{ - artifacts::output_selection::OutputSelection, utils::source_files_iter, SolcSparseFileFilter, - SOLC_EXTENSIONS, + artifacts::output_selection::OutputSelection, + compilers::{multi::MultiCompilerLanguage, CompilerSettings, Language}, + utils::source_files_iter, }; use foundry_config::{ figment, @@ -157,10 +158,11 @@ impl TestArgs { filter: &ProjectPathsAwareFilter, ) -> Result> { let mut project = config.create_project(true, true)?; - project.settings.output_selection = - OutputSelection::common_output_selection(["abi".to_string()]); + project.settings.update_output_selection(|selection| { + *selection = OutputSelection::common_output_selection(["abi".to_string()]); + }); - let output = project.compile_sparse(Box::new(SolcSparseFileFilter::new(filter.clone())))?; + let output = project.compile_sparse(Box::new(filter.clone()))?; if output.has_compiler_errors() { println!("{}", output); @@ -210,7 +212,10 @@ impl TestArgs { } // Always recompile all sources to ensure that `getCode` cheatcode can use any artifact. - test_sources.extend(source_files_iter(project.paths.sources, SOLC_EXTENSIONS)); + test_sources.extend(source_files_iter( + project.paths.sources, + MultiCompilerLanguage::FILE_EXTENSIONS, + )); Ok(test_sources) } diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index e2f958034f1b5..088975d8752e5 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -3,7 +3,7 @@ use eyre::Result; use foundry_cli::{opts::ProjectPathsArgs, utils::LoadConfig}; use foundry_compilers::{ resolver::{parse::SolData, Charset, TreeOptions}, - Graph, Solc, + Graph, }; /// CLI arguments for `forge tree`. @@ -28,7 +28,7 @@ foundry_config::impl_figment_convert!(TreeArgs, opts); impl TreeArgs { pub fn run(self) -> Result<()> { let config = self.try_load_config_emit_warnings()?; - let graph = Graph::::resolve(&config.project_paths::())?; + let graph = Graph::::resolve(&config.project_paths())?; let opts = TreeOptions { charset: self.charset, no_dedupe: self.no_dedupe }; graph.print_with_options(opts); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 4e671a77a6307..8508abbe55b7c 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -313,10 +313,10 @@ impl MultiContractRunnerBuilder { /// Given an EVM, proceeds to return a runner which is able to execute all tests /// against that evm - pub fn build( + pub fn build( self, root: &Path, - output: ProjectCompileOutput, + output: ProjectCompileOutput, env: revm::primitives::Env, evm_opts: EvmOpts, ) -> Result { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f463a437e3f80..e8812dce11a16 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -4,7 +4,7 @@ use alloy_primitives::{Address, B256, U256}; use foundry_cli::utils as forge_utils; use foundry_compilers::{ artifacts::{BytecodeHash, OptimizerDetails, RevertStrings, YulDetails}, - compilers::{solc::SolcVersionManager, CompilerVersionManager}, + Solc, }; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, @@ -43,6 +43,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { gas_reports: vec!["Contract".to_string()], gas_reports_ignore: vec![], solc: Some(SolcReq::Local(PathBuf::from("custom-solc"))), + vyper: Some(PathBuf::from("custom-vyper")), auto_detect_solc: false, auto_detect_remappings: true, offline: true, @@ -365,8 +366,7 @@ contract Foo {} assert!(cmd.stderr_lossy().contains("`solc` this/solc/does/not/exist does not exist")); // `OTHER_SOLC_VERSION` was installed in previous step, so we can use the path to this directly - let local_solc = - SolcVersionManager::default().get_or_install(&OTHER_SOLC_VERSION.parse().unwrap()).unwrap(); + let local_solc = Solc::find_or_install(&OTHER_SOLC_VERSION.parse().unwrap()).unwrap(); cmd.forge_fuse().args(["build", "--force", "--use"]).arg(local_solc.solc).root_arg(); let stdout = cmd.stdout_lossy(); assert!(stdout.contains("Compiler run successful")); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 22e928a431b08..c9f76a3aa6115 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -266,6 +266,7 @@ contract ContractTest is DSTest { // tests that libraries are handled correctly in multiforking mode forgetest_init!(can_use_libs_in_multi_fork, |prj, cmd| { prj.wipe_contracts(); + prj.add_source( "Contract.sol", r" diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 6437e9a5d929a..11dab9575a99a 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -112,10 +112,12 @@ impl VerifyBundle { if data.split_at(create2_offset).1.starts_with(bytecode) { let constructor_args = data.split_at(create2_offset + bytecode.len()).1.to_vec(); + if artifact.source.extension().map_or(false, |e| e.to_str() == Some("vy")) { + warn!("Skipping verification of Vyper contract: {}", artifact.name); + } + let contract = ContractInfo { - path: Some( - artifact.source.to_str().expect("There should be an artifact.").to_string(), - ), + path: Some(artifact.source.to_string_lossy().to_string()), name: artifact.name.clone(), }; diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 37b927e19877d..0ada068fde28a 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -3,9 +3,10 @@ use eyre::{Result, WrapErr}; use foundry_compilers::{ artifacts::Settings, cache::CompilerCache, + compilers::multi::MultiCompiler, error::Result as SolcResult, project_util::{copy_dir, TempProject}, - ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, Solc, + ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, }; use foundry_config::Config; use once_cell::sync::Lazy; @@ -409,7 +410,7 @@ pub struct TestProject { /// The directory in which this test executable is running. exe_root: PathBuf, /// The project in which the test should run. - inner: Arc>, + inner: Arc>, } impl TestProject { diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 829efd42624c8..8a2a49f9c4ae0 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -15,7 +15,7 @@ use foundry_common::{ use foundry_compilers::{ artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode}, info::ContractInfo, - Artifact, EvmVersion, SolcSparseFileFilter, + Artifact, EvmVersion, }; use foundry_config::{figment, impl_figment_convert, Chain, Config}; use foundry_evm::{ @@ -378,10 +378,7 @@ impl VerifyBytecodeArgs { if let Some(skip) = &self.skip { if !skip.is_empty() { - let filter = SolcSparseFileFilter::new(SkipBuildFilters::new( - skip.to_owned(), - project.root().to_path_buf(), - )?); + let filter = SkipBuildFilters::new(skip.to_owned(), project.root().to_path_buf())?; compiler = compiler.filter(Box::new(filter)); } } diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index cebdfbd22e7aa..1542f3a0e3b0d 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -4,8 +4,11 @@ use eyre::{Context, Result}; use foundry_block_explorers::verify::CodeFormat; use foundry_compilers::{ artifacts::{BytecodeHash, Source}, - compilers::{solc::SolcVersionManager, Compiler, CompilerVersionManager}, - AggregatedCompilerOutput, SolcInput, + compilers::{ + solc::{SolcCompiler, SolcLanguage, SolcVersionedInput}, + Compiler, CompilerInput, + }, + AggregatedCompilerOutput, Solc, }; use semver::{BuildMetadata, Version}; use std::{collections::BTreeMap, path::Path}; @@ -18,7 +21,7 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource { args: &VerifyArgs, context: &VerificationContext, ) -> Result<(String, String, CodeFormat)> { - let metadata = context.project.settings.metadata.as_ref(); + let metadata = context.project.settings.solc.metadata.as_ref(); let bch = metadata.and_then(|m| m.bytecode_hash).unwrap_or_default(); eyre::ensure!( @@ -27,8 +30,13 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource { bch, ); - let source = - context.project.flatten(&context.target_path).wrap_err("Failed to flatten contract")?; + let source = context + .project + .paths + .clone() + .with_language::() + .flatten(&context.target_path) + .wrap_err("Failed to flatten contract")?; if !args.force { // solc dry run of flattened code @@ -67,17 +75,17 @@ impl EtherscanFlattenedSource { version: &Version, contract_path: &Path, ) -> Result<()> { - let vm = SolcVersionManager::default(); let version = strip_build_meta(version.clone()); - let solc = vm.get_or_install(&version)?; + let solc = Solc::find_or_install(&version)?; - let input = SolcInput { - language: "Solidity".to_string(), - sources: BTreeMap::from([("contract.sol".into(), Source::new(content))]), - settings: Default::default(), - }; + let input = SolcVersionedInput::build( + BTreeMap::from([("contract.sol".into(), Source::new(content))]), + Default::default(), + SolcLanguage::Solidity, + version.clone(), + ); - let out = Compiler::compile(&solc, &input)?; + let out = SolcCompiler::Specific(solc).compile(&input)?; if out.errors.iter().any(|e| e.is_error()) { let mut o = AggregatedCompilerOutput::default(); o.extend(version, out); diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index 210283c3ac842..cc65078d3f7b9 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -8,8 +8,8 @@ use eyre::{OptionExt, Result}; use foundry_common::compile::ProjectCompiler; use foundry_compilers::{ artifacts::{output_selection::OutputSelection, Metadata, Source}, - compilers::{solc::SolcVersionManager, CompilerVersionManager}, - CompilerConfig, Graph, Project, + compilers::{multi::MultiCompilerParsedSource, solc::SolcCompiler, CompilerSettings}, + Graph, Project, Solc, }; use foundry_config::Config; use semver::Version; @@ -35,10 +35,8 @@ impl VerificationContext { let mut project = config.project()?; project.no_artifacts = true; - // Set project's compiler to always use resolved version. - let vm = SolcVersionManager::default(); - let solc = vm.get_or_install(&compiler_version)?; - project.compiler_config = CompilerConfig::Specific(solc); + let solc = Solc::find_or_install(&compiler_version)?; + project.compiler.solc = SolcCompiler::Specific(solc); Ok(Self { config, project, target_name, target_path, compiler_version }) } @@ -46,8 +44,9 @@ impl VerificationContext { /// Compiles target contract requesting only ABI and returns it. pub fn get_target_abi(&self) -> Result { let mut project = self.project.clone(); - project.settings.output_selection = - OutputSelection::common_output_selection(["abi".to_string()]); + project.settings.update_output_selection(|selection| { + *selection = OutputSelection::common_output_selection(["abi".to_string()]) + }); let output = ProjectCompiler::new() .quiet(true) @@ -64,8 +63,9 @@ impl VerificationContext { /// Compiles target file requesting only metadata and returns it. pub fn get_target_metadata(&self) -> Result { let mut project = self.project.clone(); - project.settings.output_selection = - OutputSelection::common_output_selection(["metadata".to_string()]); + project.settings.update_output_selection(|selection| { + *selection = OutputSelection::common_output_selection(["metadata".to_string()]); + }); let output = ProjectCompiler::new() .quiet(true) @@ -83,7 +83,8 @@ impl VerificationContext { pub fn get_target_imports(&self) -> Result> { let mut sources = self.project.paths.read_input_files()?; sources.insert(self.target_path.clone(), Source::read(&self.target_path)?); - let graph = Graph::resolve_sources(&self.project.paths, sources)?; + let graph = + Graph::::resolve_sources(&self.project.paths, sources)?; Ok(graph.imports(&self.target_path).into_iter().cloned().collect()) } From 8c7e28a0c1047d1fa43be9c31d7ce38a2dff07fd Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:54:51 +0300 Subject: [PATCH 1020/1963] perf(fuzz): store dict values once, track newly inserted indexes (#8043) * perf(fuzz): store values only once, track newly inserted indexes * Update crates/evm/fuzz/src/strategies/state.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/evm/fuzz/src/strategies/state.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/evm/fuzz/src/strategies/state.rs | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index a138f4507c646..c469e291068a6 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -93,10 +93,10 @@ pub struct FuzzDictionary { addresses: IndexSet
, /// Configuration for the dictionary. config: FuzzDictionaryConfig, - /// New keys added to the dictionary since container initialization. - new_values: IndexSet<[u8; 32]>, - /// New addresses added to the dictionary since container initialization. - new_addreses: IndexSet
, + /// New key indexes added to the dictionary since container initialization. + new_values: Vec, + /// New address indexes added to the dictionary since container initialization. + new_addreses: Vec, /// Sample typed values that are collected from call result and used across invariant runs. sample_values: HashMap>, } @@ -288,24 +288,24 @@ impl FuzzDictionary { } /// Insert address into fuzz dictionary. - /// If address is newly collected then it is removed at the end of current run. + /// If address is newly collected then it is removed by index at the end of current run. fn insert_address(&mut self, address: Address, collected: bool) { - if self.addresses.len() < self.config.max_fuzz_dictionary_addresses && - self.addresses.insert(address) && - collected - { - self.new_addreses.insert(address); + if self.addresses.len() < self.config.max_fuzz_dictionary_addresses { + let (index, new_address) = self.addresses.insert_full(address); + if new_address && collected { + self.new_addreses.push(index); + } } } /// Insert raw value into fuzz dictionary. - /// If value is newly collected then it is removed at the end of current run. + /// If value is newly collected then it is removed by index at the end of current run. fn insert_value(&mut self, value: [u8; 32], collected: bool) { - if self.state_values.len() < self.config.max_fuzz_dictionary_values && - self.state_values.insert(value) && - collected - { - self.new_values.insert(value); + if self.state_values.len() < self.config.max_fuzz_dictionary_values { + let (index, new_value) = self.state_values.insert_full(value); + if new_value && collected { + self.new_values.push(index); + } } } @@ -354,11 +354,11 @@ impl FuzzDictionary { pub fn revert(&mut self) { // Revert new values collected during the run. - for key in self.new_values.iter() { - self.state_values.swap_remove(key); + for &value_index in &self.new_values { + self.state_values.swap_remove_index(value_index); } - for address in self.new_addreses.iter() { - self.addresses.swap_remove(address); + for &address_index in &self.new_addreses { + self.addresses.swap_remove_index(address_index); } self.new_values.clear(); From 4f30c3fdd758bc7ff82b67a26949fb27b4a45f11 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:49:13 +0200 Subject: [PATCH 1021/1963] perf(invariant): only compute success when necessary (#8045) --- crates/evm/evm/src/executors/invariant/result.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index 12d745de554af..f4ba88e2af8aa 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -110,13 +110,14 @@ pub(crate) fn can_continue( ) -> Result { let mut call_results = None; - // Detect handler assertion failures first. - let handlers_failed = targeted_contracts.targets.lock().iter().any(|contract| { - !executor.is_success(*contract.0, false, Cow::Borrowed(state_changeset), false) - }); + let handlers_succeeded = || { + targeted_contracts.targets.lock().iter().all(|(address, ..)| { + executor.is_success(*address, false, Cow::Borrowed(state_changeset), false) + }) + }; - // Assert invariants IF the call did not revert and the handlers did not fail. - if !call_result.reverted && !handlers_failed { + // Assert invariants if the call did not revert and the handlers did not fail. + if !call_result.reverted && handlers_succeeded() { if let Some(traces) = call_result.traces { run_traces.push(traces); } From 2466e31e73180b4c5a4dcecf2e7c36ff692e09f8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:51:24 +0300 Subject: [PATCH 1022/1963] fix(forge) - reset lib deployer balance to initial (#8046) * fix(forge) - reset lib deployer balance to initial * Update crates/forge/src/runner.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/forge/src/runner.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 72f8b03c45f83..7c05b573c51d3 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -160,9 +160,10 @@ impl<'a> ContractRunner<'a> { } }; - // Reset `self.sender`s and `CALLER`s balance to the initial balance we want + // Reset `self.sender`s, `CALLER`s and `LIBRARY_DEPLOYER`'s balance to the initial balance. self.executor.set_balance(self.sender, self.initial_balance)?; self.executor.set_balance(CALLER, self.initial_balance)?; + self.executor.set_balance(LIBRARY_DEPLOYER, self.initial_balance)?; self.executor.deploy_create2_deployer()?; From a4ebf4143d5ee5501851a761ad7d9b268dc1dedd Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:54:34 +0200 Subject: [PATCH 1023/1963] perf: manually set code hash when inserting cheatcodes account (#8044) --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/evm/core/src/backend/in_memory_db.rs | 1 + crates/evm/core/src/backend/mod.rs | 35 +++++++++++++------ crates/evm/core/src/constants.rs | 12 +++++-- crates/evm/core/src/utils.rs | 14 +++++++- crates/evm/evm/src/executors/invariant/mod.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 6 +++- 7 files changed, 55 insertions(+), 17 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 25aa47cef983b..c705ec3760008 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -839,7 +839,7 @@ impl Backend { let db = self.db.read().await; let mut inspector = Inspector::default(); - let mut evm = self.new_evm_with_inspector_ref(&*db, env, &mut inspector); + let mut evm = self.new_evm_with_inspector_ref(&**db, env, &mut inspector); let ResultAndState { result, state } = evm.transact()?; let (exit_reason, gas_used, out, logs) = match result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index 3b19d0fce00f1..a3cb3aab4fa65 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -29,6 +29,7 @@ impl Default for MemDb { impl DatabaseRef for MemDb { type Error = DatabaseError; + fn basic_ref(&self, address: Address) -> Result, Self::Error> { DatabaseRef::basic_ref(&self.inner, address) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 357a79f433217..1e648491d622d 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -496,15 +496,11 @@ impl Backend { slot: U256, value: U256, ) -> Result<(), DatabaseError> { - let ret = if let Some(db) = self.active_fork_db_mut() { + if let Some(db) = self.active_fork_db_mut() { db.insert_account_storage(address, slot, value) } else { self.mem_db.insert_account_storage(address, slot, value) - }; - - debug_assert!(self.storage(address, slot).unwrap() == value); - - ret + } } /// Completely replace an account's storage without overriding account info. @@ -598,11 +594,11 @@ impl Backend { /// Instead, it stores whether an `assert` failed in a boolean variable that we can read pub fn is_failed_test_contract(&self, address: Address) -> bool { /* - contract DSTest { + contract DSTest { bool public IS_TEST = true; // slot 0 offset 1 => second byte of slot0 bool private _failed; - } + } */ let value = self.storage_ref(address, U256::ZERO).unwrap_or_default(); value.as_le_bytes()[1] != 0 @@ -670,9 +666,8 @@ impl Backend { active_journaled_state: &mut JournaledState, target_fork: &mut Fork, ) { - if let Some((_, fork_idx)) = self.active_fork_ids.as_ref() { - let active = self.inner.get_fork(*fork_idx); - merge_account_data(accounts, &active.db, active_journaled_state, target_fork) + if let Some(db) = self.active_fork_db() { + merge_account_data(accounts, db, active_journaled_state, target_fork) } else { merge_account_data(accounts, &self.mem_db, active_journaled_state, target_fork) } @@ -713,6 +708,24 @@ impl Backend { self.active_fork_mut().map(|f| &mut f.db) } + /// Returns the current database implementation as a `&dyn` value. + #[inline(always)] + pub fn db(&self) -> &dyn Database { + match self.active_fork_db() { + Some(fork_db) => fork_db, + None => &self.mem_db, + } + } + + /// Returns the current database implementation as a `&mut dyn` value. + #[inline(always)] + pub fn db_mut(&mut self) -> &mut dyn Database { + match self.active_fork_ids.map(|(_, idx)| &mut self.inner.get_fork_mut(idx).db) { + Some(fork_db) => fork_db, + None => &mut self.mem_db, + } + } + /// Creates a snapshot of the currently active database pub(crate) fn create_db_snapshot(&self) -> BackendDatabaseSnapshot { if let Some((id, idx)) = self.active_fork_ids { diff --git a/crates/evm/core/src/constants.rs b/crates/evm/core/src/constants.rs index 3e8941d278585..67fa2d338b2e3 100644 --- a/crates/evm/core/src/constants.rs +++ b/crates/evm/core/src/constants.rs @@ -1,12 +1,20 @@ -use alloy_primitives::{address, hex, Address}; +use alloy_primitives::{address, b256, hex, Address, B256}; /// The cheatcode handler address. /// /// This is the same address as the one used in DappTools's HEVM. -/// It is calculated as: +/// +/// This is calculated as: /// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))` pub const CHEATCODE_ADDRESS: Address = address!("7109709ECfa91a80626fF3989D68f67F5b1DD12D"); +/// The contract hash at [`CHEATCODE_ADDRESS`]. +/// +/// This is calculated as: +/// `keccak256(abi.encodePacked(CHEATCODE_ADDRESS))`. +pub const CHEATCODE_CONTRACT_HASH: B256 = + b256!("b0450508e5a2349057c3b4c9c84524d62be4bb17e565dbe2df34725a26872291"); + /// The Hardhat console address. /// /// See: diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index d68a9d754df3b..faacee68bc5a1 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -235,9 +235,21 @@ where DB: revm::Database, I: InspectorExt, { + let revm::primitives::EnvWithHandlerCfg { env, handler_cfg } = env; + // NOTE: We could use `revm::Evm::builder()` here, but on the current patch it has some // performance issues. - let revm::primitives::EnvWithHandlerCfg { env, handler_cfg } = env; + /* + revm::Evm::builder() + .with_db(db) + .with_env(env) + .with_external_context(inspector) + .with_handler_cfg(handler_cfg) + .append_handler_register(revm::inspector_handle_register) + .append_handler_register(create2_handler_register) + .build() + */ + let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); let mut handler = revm::Handler::new(handler_cfg); handler.append_handler_register_plain(revm::inspector_handle_register); diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 9d4a9f4c016e4..c6f2a44ec80bd 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -235,7 +235,7 @@ impl<'a> InvariantExecutor<'a> { // Collect data for fuzzing from the state changeset. let mut state_changeset = call_result.state_changeset.to_owned().unwrap(); - if !&call_result.reverted { + if !call_result.reverted { collect_data( &mut state_changeset, &targeted_contracts, diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 2e4c4b229a076..5c830c256e9e9 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -16,7 +16,8 @@ use alloy_sol_types::{sol, SolCall}; use foundry_evm_core::{ backend::{Backend, CowBackend, DatabaseError, DatabaseExt, DatabaseResult}, constants::{ - CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, + CALLER, CHEATCODE_ADDRESS, CHEATCODE_CONTRACT_HASH, DEFAULT_CREATE2_DEPLOYER, + DEFAULT_CREATE2_DEPLOYER_CODE, }, debug::DebugArena, decode::RevertDecoder, @@ -93,6 +94,9 @@ impl Executor { CHEATCODE_ADDRESS, revm::primitives::AccountInfo { code: Some(Bytecode::new_raw(Bytes::from_static(&[0]))), + // Also set the code hash manually so that it's not computed later. + // The code hash value does not matter, as long as it's not zero or `KECCAK_EMPTY`. + code_hash: CHEATCODE_CONTRACT_HASH, ..Default::default() }, ); From 23cb7e09a0bc8811ea3c2f50b5a5b0243575c7af Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:17:41 +0200 Subject: [PATCH 1024/1963] chore(fuzz): some cleanup (#8050) --- crates/evm/core/src/utils.rs | 16 +++--- crates/evm/coverage/src/lib.rs | 10 ++-- crates/evm/evm/src/executors/fuzz/mod.rs | 21 +++----- .../evm/evm/src/executors/invariant/error.rs | 16 +++--- crates/evm/evm/src/executors/invariant/mod.rs | 53 +++++++------------ .../evm/evm/src/executors/invariant/replay.rs | 2 +- .../evm/evm/src/executors/invariant/result.rs | 4 +- .../evm/evm/src/executors/invariant/shrink.rs | 8 +-- crates/evm/fuzz/src/invariant/filters.rs | 10 +++- crates/forge/src/runner.rs | 2 +- 10 files changed, 65 insertions(+), 77 deletions(-) diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index faacee68bc5a1..230c068e61277 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,9 +1,8 @@ pub use crate::ic::*; use crate::{constants::DEFAULT_CREATE2_DEPLOYER, InspectorExt}; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, FixedBytes, U256}; +use alloy_primitives::{Address, Selector, U256}; use alloy_rpc_types::{Block, Transaction}; -use eyre::ContextCompat; use foundry_config::NamedChain; use revm::{ db::WrapDatabaseRef, @@ -61,15 +60,14 @@ pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::En } /// Given an ABI and selector, it tries to find the respective function. -pub fn get_function( +pub fn get_function<'a>( contract_name: &str, - selector: &FixedBytes<4>, - abi: &JsonAbi, -) -> eyre::Result { + selector: Selector, + abi: &'a JsonAbi, +) -> eyre::Result<&'a Function> { abi.functions() - .find(|func| func.selector().as_slice() == selector.as_slice()) - .cloned() - .wrap_err(format!("{contract_name} does not have the selector {selector:?}")) + .find(|func| func.selector() == selector) + .ok_or_else(|| eyre::eyre!("{contract_name} does not have the selector {selector}")) } /// Configures the env for the transaction diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 53ca928f6b096..9496c0aca095d 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -155,15 +155,19 @@ impl CoverageReport { pub struct HitMaps(pub HashMap); impl HitMaps { - pub fn merge(mut self, other: HitMaps) -> Self { - for (code_hash, hit_map) in other.0.into_iter() { + pub fn merge(&mut self, other: HitMaps) { + for (code_hash, hit_map) in other.0 { if let Some(HitMap { hits: extra_hits, .. }) = self.insert(code_hash, hit_map) { - for (pc, hits) in extra_hits.into_iter() { + for (pc, hits) in extra_hits { self.entry(code_hash) .and_modify(|map| *map.hits.entry(pc).or_default() += hits); } } } + } + + pub fn merged(mut self, other: HitMaps) -> Self { + self.merge(other); self } } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 520a56cf2fe76..d0ff892977b98 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -105,31 +105,26 @@ impl FuzzedExecutor { traces.borrow_mut().push(call_traces); } - if let Some(prev) = coverage.take() { - // Safety: If `Option::or` evaluates to `Some`, then `call.coverage` must - // necessarily also be `Some` - coverage.replace(Some(prev.merge(case.coverage.unwrap()))); - } else { - coverage.replace(case.coverage); + match &mut *coverage.borrow_mut() { + Some(prev) => prev.merge(case.coverage.unwrap()), + opt => *opt = case.coverage, } Ok(()) } FuzzOutcome::CounterExample(CounterExampleOutcome { - exit_reason, - counterexample: _counterexample, + exit_reason: status, + counterexample: outcome, .. }) => { - let status = exit_reason; // We cannot use the calldata returned by the test runner in `TestError::Fail`, // since that input represents the last run case, which may not correspond with // our failure - when a fuzz case fails, proptest will try // to run at least one more case to find a minimal failure // case. - let call_res = _counterexample.1.result.clone(); - *counterexample.borrow_mut() = _counterexample; - // HACK: we have to use an empty string here to denote `None` - let reason = rd.maybe_decode(&call_res, Some(status)); + let reason = rd.maybe_decode(&outcome.1.result, Some(status)); + *counterexample.borrow_mut() = outcome; + // HACK: we have to use an empty string here to denote `None`. Err(TestCaseError::fail(reason.unwrap_or_default())) } } diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index b0004c8cbdf01..74f8d92ccf19c 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -59,8 +59,8 @@ pub struct FailedInvariantCaseData { pub revert_reason: String, /// Address of the invariant asserter. pub addr: Address, - /// Function data for invariant check. - pub func: Bytes, + /// Function calldata for invariant check. + pub calldata: Bytes, /// Inner fuzzing Sequence coming from overriding calls. pub inner_sequence: Vec>, /// Shrink run limit @@ -79,17 +79,13 @@ impl FailedInvariantCaseData { inner_sequence: &[Option], ) -> Self { // Collect abis of fuzzed and invariant contracts to decode custom error. - let targets = targeted_contracts.targets.lock(); - let abis = targets - .iter() - .map(|contract| &contract.1 .1) - .chain(std::iter::once(invariant_contract.abi)); - let revert_reason = RevertDecoder::new() - .with_abis(abis) + .with_abis(targeted_contracts.targets.lock().iter().map(|(_, (_, abi, _))| abi)) + .with_abi(invariant_contract.abi) .decode(call_result.result.as_ref(), Some(call_result.exit_reason)); let func = invariant_contract.invariant_function; + debug_assert!(func.inputs.is_empty()); let origin = func.name.as_str(); Self { test_error: proptest::test_runner::TestError::Fail( @@ -99,7 +95,7 @@ impl FailedInvariantCaseData { return_reason: "".into(), revert_reason, addr: invariant_contract.address, - func: func.selector().to_vec().into(), + calldata: func.selector().to_vec().into(), inner_sequence: inner_sequence.to_vec(), shrink_run_limit: invariant_config.shrink_run_limit, fail_on_revert: invariant_config.fail_on_revert, diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index c6f2a44ec80bd..fba994cba6030 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -2,7 +2,7 @@ use crate::{ executors::{Executor, RawCallResult}, inspectors::Fuzzer, }; -use alloy_primitives::{Address, FixedBytes, U256}; +use alloy_primitives::{Address, FixedBytes, Selector, U256}; use alloy_sol_types::{sol, SolCall}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; @@ -491,6 +491,8 @@ impl<'a> InvariantExecutor<'a> { self.call_sol_default(to, &IInvariantTest::targetSendersCall {}).targetedSenders; let excluded_senders = self.call_sol_default(to, &IInvariantTest::excludeSendersCall {}).excludedSenders; + let sender_filters = SenderFilters::new(targeted_senders, excluded_senders); + let selected = self.call_sol_default(to, &IInvariantTest::targetContractsCall {}).targetedContracts; let excluded = @@ -498,20 +500,16 @@ impl<'a> InvariantExecutor<'a> { let mut contracts: TargetedContracts = self .setup_contracts - .clone() - .into_iter() - .filter(|(addr, (identifier, _))| { + .iter() + .filter(|&(addr, (identifier, _))| { *addr != to && *addr != CHEATCODE_ADDRESS && *addr != HARDHAT_CONSOLE_ADDRESS && (selected.is_empty() || selected.contains(addr)) && - (self.artifact_filters.targeted.is_empty() || - self.artifact_filters.targeted.contains_key(identifier)) && (excluded.is_empty() || !excluded.contains(addr)) && - (self.artifact_filters.excluded.is_empty() || - !self.artifact_filters.excluded.contains(identifier)) + self.artifact_filters.matches(identifier) }) - .map(|(addr, (identifier, abi))| (addr, (identifier, abi, vec![]))) + .map(|(addr, (identifier, abi))| (*addr, (identifier.clone(), abi.clone(), vec![]))) .collect(); self.target_interfaces(to, &mut contracts)?; @@ -523,10 +521,7 @@ impl<'a> InvariantExecutor<'a> { eyre::bail!("No contracts to fuzz."); } - Ok(( - SenderFilters::new(targeted_senders, excluded_senders), - FuzzRunIdentifiedContracts::new(contracts, selected.is_empty()), - )) + Ok((sender_filters, FuzzRunIdentifiedContracts::new(contracts, selected.is_empty()))) } /// Extends the contracts and selectors to fuzz with the addresses and ABIs specified in @@ -586,26 +581,18 @@ impl<'a> InvariantExecutor<'a> { address: Address, targeted_contracts: &mut TargetedContracts, ) -> Result<()> { - let some_abi_selectors = self - .artifact_filters - .targeted - .iter() - .filter(|(_, selectors)| !selectors.is_empty()) - .collect::>(); - for (address, (identifier, _)) in self.setup_contracts.iter() { - if let Some(selectors) = some_abi_selectors.get(identifier) { - self.add_address_with_functions( - *address, - (*selectors).clone(), - targeted_contracts, - )?; + if let Some(selectors) = self.artifact_filters.targeted.get(identifier) { + if selectors.is_empty() { + continue; + } + self.add_address_with_functions(*address, selectors, targeted_contracts)?; } } let selectors = self.call_sol_default(address, &IInvariantTest::targetSelectorsCall {}); for IInvariantTest::FuzzSelector { addr, selectors } in selectors.targetedSelectors { - self.add_address_with_functions(addr, selectors, targeted_contracts)?; + self.add_address_with_functions(addr, &selectors, targeted_contracts)?; } Ok(()) } @@ -614,14 +601,14 @@ impl<'a> InvariantExecutor<'a> { fn add_address_with_functions( &self, address: Address, - bytes4_array: Vec>, + selectors: &[Selector], targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { if let Some((name, abi, address_selectors)) = targeted_contracts.get_mut(&address) { // The contract is already part of our filter, and all we do is specify that we're // only looking at specific functions coming from `bytes4_array`. - for selector in bytes4_array { - address_selectors.push(get_function(name, &selector, abi)?); + for &selector in selectors { + address_selectors.push(get_function(name, selector, abi).cloned()?); } } else { let (name, abi) = self.setup_contracts.get(&address).ok_or_else(|| { @@ -630,9 +617,9 @@ impl<'a> InvariantExecutor<'a> { ) })?; - let functions = bytes4_array - .into_iter() - .map(|selector| get_function(name, &selector, abi)) + let functions = selectors + .iter() + .map(|&selector| get_function(name, selector, abi).cloned()) .collect::, _>>()?; targeted_contracts.insert(address, (name.to_string(), abi.clone(), functions)); diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index ff4fbc89dbb8f..b6c2c6d9e32ce 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -47,7 +47,7 @@ pub fn replay_run( if let Some(new_coverage) = call_result.coverage { if let Some(old_coverage) = coverage { - *coverage = Some(std::mem::take(old_coverage).merge(new_coverage)); + *coverage = Some(std::mem::take(old_coverage).merged(new_coverage)); } else { *coverage = Some(new_coverage); } diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index f4ba88e2af8aa..2d08efb12d22b 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -68,13 +68,13 @@ pub(crate) fn assert_invariants( U256::ZERO, )?; - let is_err = !executor.is_raw_call_success( + let success = executor.is_raw_call_success( invariant_contract.address, Cow::Owned(call_result.state_changeset.take().unwrap()), &call_result, false, ); - if is_err { + if !success { // We only care about invariants which we haven't broken yet. if invariant_failures.error.is_none() { let case_data = FailedInvariantCaseData::new( diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index 47711e11bb9cf..9d397bfe1c75f 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -89,7 +89,7 @@ pub(crate) fn shrink_sequence( // Special case test: the invariant is *unsatisfiable* - it took 0 calls to // break the invariant -- consider emitting a warning. let error_call_result = - executor.call_raw(CALLER, failed_case.addr, failed_case.func.clone(), U256::ZERO)?; + executor.call_raw(CALLER, failed_case.addr, failed_case.calldata.clone(), U256::ZERO)?; if error_call_result.reverted { return Ok(vec![]); } @@ -102,7 +102,7 @@ pub(crate) fn shrink_sequence( calls, shrinker.current().collect(), failed_case.addr, - failed_case.func.clone(), + failed_case.calldata.clone(), failed_case.fail_on_revert, ) { // If candidate sequence still fails then shrink more if possible. @@ -126,7 +126,7 @@ pub fn check_sequence( calls: &[BasicTxDetails], sequence: Vec, test_address: Address, - test_function: Bytes, + calldata: Bytes, fail_on_revert: bool, ) -> eyre::Result<(bool, bool)> { // Apply the call sequence. @@ -146,7 +146,7 @@ pub fn check_sequence( } // Check the invariant for call sequence. - let mut call_result = executor.call_raw(CALLER, test_address, test_function, U256::ZERO)?; + let mut call_result = executor.call_raw(CALLER, test_address, calldata, U256::ZERO)?; Ok(( executor.is_raw_call_success( test_address, diff --git a/crates/evm/fuzz/src/invariant/filters.rs b/crates/evm/fuzz/src/invariant/filters.rs index c56450c27065d..2925c6e4506cd 100644 --- a/crates/evm/fuzz/src/invariant/filters.rs +++ b/crates/evm/fuzz/src/invariant/filters.rs @@ -14,7 +14,14 @@ pub struct ArtifactFilters { /// List of `contract_path:contract_name` which are to be excluded. pub excluded: Vec, } + impl ArtifactFilters { + /// Returns `true` if the given identifier matches this filter. + pub fn matches(&self, identifier: &str) -> bool { + (self.targeted.is_empty() || self.targeted.contains_key(identifier)) && + (self.excluded.is_empty() || !self.excluded.iter().any(|id| id == identifier)) + } + /// Gets all the targeted functions from `artifact`. Returns error, if selectors do not match /// the `artifact`. /// @@ -28,7 +35,7 @@ impl ArtifactFilters { if let Some(selectors) = self.targeted.get(&artifact.identifier()) { let functions = selectors .iter() - .map(|selector| get_function(&artifact.name, selector, abi)) + .map(|selector| get_function(&artifact.name, *selector, abi).cloned()) .collect::>>()?; // targetArtifactSelectors > excludeArtifacts > targetArtifacts if functions.is_empty() && self.excluded.contains(&artifact.identifier()) { @@ -44,6 +51,7 @@ impl ArtifactFilters { Ok(None) } } + /// Filter for acceptable senders to use for invariant testing. Exclusion takes priority if /// clashing. /// diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 7c05b573c51d3..c6588b582ff1d 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -877,7 +877,7 @@ impl<'a> ContractRunner<'a> { fn merge_coverages(mut coverage: Option, other: Option) -> Option { let old_coverage = std::mem::take(&mut coverage); match (old_coverage, other) { - (Some(old_coverage), Some(other)) => Some(old_coverage.merge(other)), + (Some(old_coverage), Some(other)) => Some(old_coverage.merged(other)), (None, Some(other)) => Some(other), (Some(old_coverage), None) => Some(old_coverage), (None, None) => None, From cffc812075412a1e6d63575d8d8f2fef00ada3ef Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:33:49 +0200 Subject: [PATCH 1025/1963] fix: use revm to calculate gas stipend (#8048) --- crates/evm/evm/src/executors/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 5c830c256e9e9..7e770f54f444e 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -785,12 +785,6 @@ impl std::ops::DerefMut for CallResult { } } -/// Calculates the initial gas stipend for a transaction -fn calc_stipend(calldata: &[u8], spec: SpecId) -> u64 { - let non_zero_data_cost = if SpecId::enabled(spec, SpecId::ISTANBUL) { 16 } else { 68 }; - calldata.iter().fold(21000, |sum, byte| sum + if *byte == 0 { 4 } else { non_zero_data_cost }) -} - /// Converts the data aggregated in the `inspector` and `call` to a `RawCallResult` fn convert_executed_result( env: EnvWithHandlerCfg, @@ -809,7 +803,13 @@ fn convert_executed_result( } ExecutionResult::Halt { reason, gas_used } => (reason.into(), 0_u64, gas_used, None), }; - let stipend = calc_stipend(&env.tx.data, env.handler_cfg.spec_id); + let stipend = revm::interpreter::gas::validate_initial_tx_gas( + env.spec_id(), + &env.tx.data, + env.tx.transact_to.is_create(), + &env.tx.access_list, + &env.tx.eof_initcodes, + ); let result = match &out { Some(Output::Call(data)) => data.clone(), From 99a12d1f2c1146823d27032c94247d1b501b8429 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:49:51 +0200 Subject: [PATCH 1026/1963] perf(cheatcodes): don't recover verify signature after signing (#8051) --- crates/cheatcodes/src/utils.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index fb750fa91c104..7356d7133fd64 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -204,12 +204,8 @@ fn encode_vrs(sig: alloy_primitives::Signature) -> Vec { pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. let wallet = parse_wallet(private_key)?; - let sig = wallet.sign_hash_sync(digest)?; - let recovered = sig.recover_address_from_prehash(digest)?; - - assert_eq!(recovered, wallet.address()); - + debug_assert_eq!(sig.recover_address_from_prehash(digest)?, wallet.address()); Ok(encode_vrs(sig)) } @@ -243,8 +239,10 @@ pub(super) fn sign_with_wallet( let sig = foundry_common::block_on(wallet.sign_hash(digest)).map_err(|err| fmt_err!("{err}"))?; - let recovered = sig.recover_address_from_prehash(digest).map_err(|err| fmt_err!("{err}"))?; - assert_eq!(recovered, signer); + debug_assert_eq!( + sig.recover_address_from_prehash(digest).map_err(|err| fmt_err!("{err}"))?, + signer + ); Ok(encode_vrs(sig)) } From 2193a274e568cfd6ce64e6823c036d778e0ebbea Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:50:32 +0300 Subject: [PATCH 1027/1963] fix(forge): ensure contract managing fork is persistent (#8041) * fix(forge): ensure contract managing fork is persistent * Review changes: rename to persist_caller, always add (instead check + add) --- crates/cheatcodes/src/evm/fork.rs | 16 +++++ crates/forge/tests/it/repros.rs | 3 + testdata/default/repros/Issue8004.t.sol | 94 +++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 testdata/default/repros/Issue8004.t.sol diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 4c91a226128a8..a767520288f21 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -62,6 +62,7 @@ impl Cheatcode for createSelectFork_2Call { impl Cheatcode for rollFork_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { blockNumber } = self; + persist_caller(ccx); ccx.ecx.db.roll_fork( None, (*blockNumber).to(), @@ -75,6 +76,7 @@ impl Cheatcode for rollFork_0Call { impl Cheatcode for rollFork_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { txHash } = self; + persist_caller(ccx); ccx.ecx.db.roll_fork_to_transaction( None, *txHash, @@ -88,6 +90,7 @@ impl Cheatcode for rollFork_1Call { impl Cheatcode for rollFork_2Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, blockNumber } = self; + persist_caller(ccx); ccx.ecx.db.roll_fork( Some(*forkId), (*blockNumber).to(), @@ -101,6 +104,7 @@ impl Cheatcode for rollFork_2Call { impl Cheatcode for rollFork_3Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, txHash } = self; + persist_caller(ccx); ccx.ecx.db.roll_fork_to_transaction( Some(*forkId), *txHash, @@ -114,6 +118,7 @@ impl Cheatcode for rollFork_3Call { impl Cheatcode for selectForkCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId } = self; + persist_caller(ccx); check_broadcast(ccx.state)?; ccx.ecx.db.select_fork(*forkId, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state)?; @@ -334,6 +339,8 @@ fn create_fork_request( url_or_alias: &str, block: Option, ) -> Result { + persist_caller(ccx); + let url = ccx.state.config.rpc_url(url_or_alias)?; let mut evm_opts = ccx.state.config.evm_opts.clone(); evm_opts.fork_block_number = block; @@ -355,3 +362,12 @@ fn check_broadcast(state: &Cheatcodes) -> Result<()> { Err(fmt_err!("cannot select forks during a broadcast")) } } + +// Helper to add the caller of fork cheat code as persistent account (in order to make sure that the +// state of caller contract is not lost when fork changes). +// Applies to create, select and roll forks actions. +// https://github.com/foundry-rs/foundry/issues/8004 +#[inline] +fn persist_caller(ccx: &mut CheatsCtxt) { + ccx.ecx.db.add_persistent_account(ccx.caller); +} diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index aeae1175aa085..0c0f1bc50c7cc 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -329,3 +329,6 @@ test_repro!(7481); // https://github.com/foundry-rs/foundry/issues/5739 test_repro!(5739); + +// https://github.com/foundry-rs/foundry/issues/8004 +test_repro!(8004); diff --git a/testdata/default/repros/Issue8004.t.sol b/testdata/default/repros/Issue8004.t.sol new file mode 100644 index 0000000000000..3e077e2a27ec0 --- /dev/null +++ b/testdata/default/repros/Issue8004.t.sol @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract NonPersistentHelper is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + uint256 public curState; + + function createSelectFork() external { + vm.createSelectFork("rpcAlias"); + curState += 1; + } + + function createSelectForkAtBlock() external { + vm.createSelectFork("rpcAlias", 19000000); + curState += 1; + } + + function createSelectForkAtTx() external { + vm.createSelectFork( + "rpcAlias", vm.parseBytes32("0xb5c978f15d01fcc9b4d78967e8189e35ecc21ff4e78315ea5d616f3467003c84") + ); + curState += 1; + } + + function selectFork(uint256 forkId) external { + vm.selectFork(forkId); + curState += 1; + } + + function rollForkAtBlock() external { + vm.rollFork(19000000); + curState += 1; + } + + function rollForkIdAtBlock(uint256 forkId) external { + vm.rollFork(forkId, 19000000); + curState += 1; + } +} + +// https://github.com/foundry-rs/foundry/issues/8004 +contract Issue8004CreateSelectForkTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + NonPersistentHelper helper; + + function setUp() public { + helper = new NonPersistentHelper(); + } + + function testNonPersistentHelperCreateFork() external { + helper.createSelectFork(); + assertEq(helper.curState(), 1); + } + + function testNonPersistentHelperCreateForkAtBlock() external { + helper.createSelectForkAtBlock(); + assertEq(helper.curState(), 1); + } + + function testNonPersistentHelperCreateForkAtTx() external { + helper.createSelectForkAtBlock(); + assertEq(helper.curState(), 1); + } + + function testNonPersistentHelperSelectFork() external { + uint256 forkId = vm.createFork("rpcAlias"); + helper.selectFork(forkId); + assertEq(helper.curState(), 1); + } +} + +contract Issue8004RollForkTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + NonPersistentHelper helper; + uint256 forkId; + + function setUp() public { + forkId = vm.createSelectFork("rpcAlias"); + helper = new NonPersistentHelper(); + } + + function testNonPersistentHelperRollForkAtBlock() external { + helper.rollForkAtBlock(); + assertEq(helper.curState(), 1); + } + + function testNonPersistentHelperRollForkIdAtBlock() external { + helper.rollForkIdAtBlock(forkId); + assertEq(helper.curState(), 1); + } +} From f9cbe69300b896514694d13f9bf2cd2f787b203b Mon Sep 17 00:00:00 2001 From: sam bacha Date: Tue, 4 Jun 2024 09:07:14 -0700 Subject: [PATCH 1028/1963] fix(docker build): update index checksum (#8003) fixes https://github.com/foundry-rs/foundry/issues/7925 --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index e5ce88c0139ef..e900ee1e81742 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,9 @@ RUN [[ "$TARGETARCH" = "arm64" ]] && echo "export CFLAGS=-mno-outline-atomics" > WORKDIR /opt/foundry COPY . . +# see +RUN git update-index --force-write-index + RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/root/.cargo/git --mount=type=cache,target=/opt/foundry/target \ source $HOME/.profile && cargo build --release \ && mkdir out \ From 9e95c5537ec13e66d770d4d10dd18891f85332a5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:27:57 +0200 Subject: [PATCH 1029/1963] ci: switch macos test runner to use aarch64 (#8055) * ci: switch macos test runner to use aarch64 * tmp: run it * Revert "ci: switch macos test runner to use aarch64" This reverts commit 844d375d933e108ba746fd668822490e2297dc98. * Revert "tmp: run it" This reverts commit 0eb13b77de39e6989ab40171909640fae5c1f895. * Reapply "ci: switch macos test runner to use aarch64" This reverts commit f6da78534404ceb3ce8335996c9ddff643097ee2. --- .github/scripts/matrices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 3fdcea1154211..a71ff368391ac 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -69,7 +69,7 @@ def __init__( t_linux_x86 = Target("ubuntu-latest", "x86_64-unknown-linux-gnu", "linux-amd64") # 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", "x86_64-apple-darwin", "macosx-amd64") +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] From 5668e4699c1adc2dc39526dcfb319bdad78f98ea Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:28:06 +0200 Subject: [PATCH 1030/1963] ci: release x86_64 darwin binaries with macos-12 runner (#8056) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7422bfb67f88..3db72dfcf3693 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,7 +88,7 @@ jobs: svm_target_platform: linux-aarch64 platform: linux arch: arm64 - - runner: macos-latest-large + - runner: macos-12-large target: x86_64-apple-darwin svm_target_platform: macosx-amd64 platform: darwin From ec89c4f84e195ac155eb022dd1c522aff8e9967f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 20:28:56 +0200 Subject: [PATCH 1031/1963] fix: re-enable aws-config default-features (#8058) --- Cargo.lock | 49 +++++++++++++++++++++++++++++++++++++++ crates/wallets/Cargo.toml | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 375391847d281..b802db9cd4a5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1106,6 +1106,8 @@ checksum = "1234b742ac4a40a7d3459c6e3c99818271976a5a6ae3732cb415f4a9a94da7b6" dependencies = [ "aws-credential-types", "aws-runtime", + "aws-sdk-sso", + "aws-sdk-ssooidc", "aws-sdk-sts", "aws-smithy-async", "aws-smithy-http", @@ -1116,12 +1118,15 @@ dependencies = [ "aws-types", "bytes", "fastrand", + "hex", "http 0.2.12", "hyper 0.14.28", + "ring", "time", "tokio", "tracing", "url", + "zeroize", ] [[package]] @@ -1181,6 +1186,50 @@ dependencies = [ "tracing", ] +[[package]] +name = "aws-sdk-sso" +version = "1.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef53f254e16c00cfbfd69fa6eca4d858b7c161878db2cd248410af402d1951e" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-ssooidc" +version = "1.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1b673b2972c38463955e27d76c9d2ebb0452a9ce8059a0e2c9ed67efe69ef35" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + [[package]] name = "aws-sdk-sts" version = "1.28.0" diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index c7c4038cdee13..a8c7658deb4c0 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -22,7 +22,7 @@ alloy-dyn-abi.workspace = true # aws-kms alloy-signer-aws = { workspace = true, features = ["eip712"], optional = true } -aws-config = { version = "1", default-features = false, optional = true } +aws-config = { version = "1", optional = true } # default-features are necessary aws-sdk-kms = { version = "1", default-features = false, optional = true } foundry-config.workspace = true From 1c6bd3274430b96ea5c0c1f6bf81bb68912e9813 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:18:02 +0200 Subject: [PATCH 1032/1963] fix: panic in WalletSigner::from_private_key (#8052) * fix: panic in WalletSigner::from_private_key * stuff --- crates/cheatcodes/src/fs.rs | 2 +- crates/cheatcodes/src/script.rs | 20 ++++++++++++-------- crates/cheatcodes/src/utils.rs | 20 +++++++------------- crates/wallets/src/wallet_signer.rs | 7 +++---- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index fd4234d21fa00..75e0d24678249 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -376,7 +376,7 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result return Err(fmt_err!("Invalid artifact path")), + _ => bail!("invalid artifact path"), }; state.config.paths.artifacts.join(path_in_artifacts) diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 19922ad34666b..8eacb52a8e47f 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -1,7 +1,7 @@ //! Implementations of [`Scripting`](crate::Group::Scripting) cheatcodes. use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::{Address, U256}; +use alloy_primitives::{Address, B256, U256}; use alloy_signer_wallet::LocalWallet; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; use parking_lot::Mutex; @@ -106,9 +106,14 @@ impl ScriptWallets { } /// Locks inner Mutex and adds a signer to the [MultiWallet]. - pub fn add_signer(&self, private_key: impl AsRef<[u8]>) -> Result { - self.inner.lock().multi_wallet.add_signer(WalletSigner::from_private_key(private_key)?); - Ok(Default::default()) + pub fn add_private_key(&self, private_key: &B256) -> Result<()> { + self.add_local_signer(LocalWallet::from_bytes(private_key)?); + Ok(()) + } + + /// Locks inner Mutex and adds a signer to the [MultiWallet]. + pub fn add_local_signer(&self, wallet: LocalWallet) { + self.inner.lock().multi_wallet.add_signer(WalletSigner::Local(wallet)); } /// Locks inner Mutex and returns all signer addresses in the [MultiWallet]. @@ -166,14 +171,13 @@ fn broadcast_key( private_key: &U256, single_call: bool, ) -> Result { - let key = super::utils::parse_private_key(private_key)?; - let new_origin = LocalWallet::from(key.clone()).address(); + let wallet = super::utils::parse_wallet(private_key)?; + let new_origin = wallet.address(); let result = broadcast(ccx, Some(&new_origin), single_call); - if result.is_ok() { if let Some(script_wallets) = &ccx.state.script_wallets { - script_wallets.add_signer(key.to_bytes())?; + script_wallets.add_local_signer(wallet); } } result diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 7356d7133fd64..95a7c6d32bc3a 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -90,10 +90,10 @@ impl Cheatcode for deriveKey_3Call { impl Cheatcode for rememberKeyCall { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; - let key = parse_private_key(privateKey)?; - let address = LocalWallet::from(key.clone()).address(); + let wallet = parse_wallet(privateKey)?; + let address = wallet.address(); if let Some(script_wallets) = &ccx.state.script_wallets { - script_wallets.add_signer(key.to_bytes())?; + script_wallets.add_local_signer(wallet); } Ok(address.abi_encode()) } @@ -215,7 +215,7 @@ pub(super) fn sign_with_wallet( digest: &B256, ) -> Result { let Some(script_wallets) = &ccx.state.script_wallets else { - return Err("no wallets are available".into()); + bail!("no wallets are available"); }; let mut script_wallets = script_wallets.inner.lock(); @@ -229,21 +229,15 @@ pub(super) fn sign_with_wallet( } else if signers.len() == 1 { *signers.keys().next().unwrap() } else { - return Err("could not determine signer".into()); + bail!("could not determine signer"); }; let wallet = signers .get(&signer) .ok_or_else(|| fmt_err!("signer with address {signer} is not available"))?; - let sig = - foundry_common::block_on(wallet.sign_hash(digest)).map_err(|err| fmt_err!("{err}"))?; - - debug_assert_eq!( - sig.recover_address_from_prehash(digest).map_err(|err| fmt_err!("{err}"))?, - signer - ); - + let sig = foundry_common::block_on(wallet.sign_hash(digest))?; + debug_assert_eq!(sig.recover_address_from_prehash(digest)?, signer); Ok(encode_vrs(sig)) } diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index 15e450289c6e2..9ab30e1ad4f49 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -57,9 +57,8 @@ impl WalletSigner { } } - pub fn from_private_key(private_key: impl AsRef<[u8]>) -> Result { - let wallet = LocalWallet::from_bytes(&B256::from_slice(private_key.as_ref()))?; - Ok(Self::Local(wallet)) + pub fn from_private_key(private_key: &B256) -> Result { + Ok(Self::Local(LocalWallet::from_bytes(private_key)?)) } /// Returns a list of addresses available to use with current signer @@ -213,7 +212,7 @@ impl PendingSigner { } Self::Interactive => { let private_key = rpassword::prompt_password("Enter private key:")?; - Ok(WalletSigner::from_private_key(hex::decode(private_key)?)?) + Ok(WalletSigner::from_private_key(&hex::FromHex::from_hex(private_key)?)?) } } } From fb86e5d3bf41f9cef3ccc7fbd04e1a422f20c29e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 5 Jun 2024 01:12:17 +0200 Subject: [PATCH 1033/1963] perf(link): keep around the cow for a bit longer (#8059) --- crates/common/src/compile.rs | 2 +- crates/forge/src/multi_runner.rs | 4 +--- crates/linking/src/lib.rs | 40 +++++++++++++++++--------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 8e8cff36854d8..4b1cd78748baa 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -316,7 +316,7 @@ impl ContractSources { format!("failed to read artifact source file for `{}`", id.identifier()) })?; let linked = linker.link(&id, libraries)?; - let contract = compact_to_contract(linked)?; + let contract = compact_to_contract(linked.into_contract_bytecode())?; sources.insert(&id, file_id, source_code, contract); } else { warn!(id = id.identifier(), "source not found"); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 8508abbe55b7c..0b56f3500726e 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -343,9 +343,7 @@ impl MultiContractRunnerBuilder { let mut deployable_contracts = DeployableContracts::default(); for (id, contract) in linked_contracts.iter() { - let Some(abi) = contract.abi.as_ref() else { - continue; - }; + let Some(abi) = &contract.abi else { continue }; // if it's a test, link it and add to deployable contracts if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index 8d9791a183cd8..980dfc8fd791a 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -2,13 +2,13 @@ use alloy_primitives::{Address, Bytes, B256}; use foundry_compilers::{ - artifacts::{CompactContractBytecode, CompactContractBytecodeCow, Libraries}, + artifacts::{CompactContractBytecodeCow, Libraries}, contracts::ArtifactContracts, Artifact, ArtifactId, }; use semver::Version; use std::{ - collections::{BTreeMap, BTreeSet, HashMap}, + collections::{BTreeMap, BTreeSet}, path::{Path, PathBuf}, str::FromStr, }; @@ -202,7 +202,7 @@ impl<'a> Linker<'a> { let bytecode = self.link(id, &libraries).unwrap().bytecode.unwrap(); (id, bytecode) }) - .collect::>(); + .collect::>(); let mut libs_to_deploy = Vec::new(); @@ -212,22 +212,22 @@ impl<'a> Linker<'a> { // Find any library which is fully linked. let deployable = needed_libraries .iter() - .find(|(_, bytecode)| !bytecode.object.is_unlinked()) - .map(|(id, _)| *id); + .enumerate() + .find(|(_, (_, bytecode))| !bytecode.object.is_unlinked()); // If we haven't found any deployable library, it means we have a cyclic dependency. - let Some(id) = deployable else { + let Some((index, &(id, _))) = deployable else { return Err(LinkerError::CyclicDependency); }; - let bytecode = needed_libraries.remove(id).unwrap(); - let code = bytecode.into_bytes().unwrap(); - let address = sender.create2_from_code(salt, code.as_ref()); - libs_to_deploy.push(code); + let (_, bytecode) = needed_libraries.swap_remove(index); + let code = bytecode.bytes().unwrap(); + let address = sender.create2_from_code(salt, code); + libs_to_deploy.push(code.clone()); let (file, name) = self.convert_artifact_id_to_lib_path(id); - for (_, bytecode) in needed_libraries.iter_mut() { - bytecode.link(file.to_string_lossy(), name.clone(), address); + for (_, bytecode) in &mut needed_libraries { + bytecode.to_mut().link(file.to_string_lossy(), name.clone(), address); } libraries.libs.entry(file).or_default().insert(name, address.to_checksum(None)); @@ -241,7 +241,7 @@ impl<'a> Linker<'a> { &self, target: &ArtifactId, libraries: &Libraries, - ) -> Result { + ) -> Result, LinkerError> { let mut contract = self.contracts.get(target).ok_or(LinkerError::MissingTargetArtifact)?.clone(); for (file, libs) in &libraries.libs { @@ -257,12 +257,7 @@ impl<'a> Linker<'a> { } } } - - Ok(CompactContractBytecode { - abi: contract.abi.map(|a| a.into_owned()), - bytecode: contract.bytecode.map(|b| b.into_owned()), - deployed_bytecode: contract.deployed_bytecode.map(|b| b.into_owned()), - }) + Ok(contract) } pub fn get_linked_artifacts( @@ -271,6 +266,13 @@ impl<'a> Linker<'a> { ) -> Result { self.contracts.keys().map(|id| Ok((id.clone(), self.link(id, libraries)?))).collect() } + + pub fn get_linked_artifacts_cow( + &self, + libraries: &Libraries, + ) -> Result>, LinkerError> { + self.contracts.keys().map(|id| Ok((id.clone(), self.link(id, libraries)?))).collect() + } } #[cfg(test)] From b164c206659ab410ea67d6e13b1968b79e5447bc Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:01:46 +0200 Subject: [PATCH 1034/1963] chore: add fuzz dictionary stats (#8060) --- crates/evm/evm/src/executors/fuzz/mod.rs | 2 ++ crates/evm/evm/src/executors/invariant/mod.rs | 2 +- crates/evm/fuzz/src/strategies/state.rs | 21 +++++++++++ crates/forge/src/multi_runner.rs | 2 +- crates/forge/src/runner.rs | 35 ++++++------------- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index d0ff892977b98..163d5444d2062 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -178,6 +178,8 @@ impl FuzzedExecutor { _ => {} } + state.log_stats(); + result } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index fba994cba6030..69ef106f68d13 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -322,7 +322,7 @@ impl<'a> InvariantExecutor<'a> { }); trace!(?fuzz_fixtures); - trace!(state_len = fuzz_state.dictionary_read().len()); + fuzz_state.log_stats(); let (reverts, error) = failures.into_inner().into_inner(); diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index c469e291068a6..3717f370ea9b9 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -81,6 +81,11 @@ impl EvmFuzzState { pub fn dictionary_read(&self) -> RwLockReadGuard<'_, RawRwLock, FuzzDictionary> { self.inner.read() } + + /// Logs stats about the current state. + pub fn log_stats(&self) { + self.inner.read().log_stats(); + } } // We're using `IndexSet` to have a stable element order when restoring persisted state, as well as @@ -99,6 +104,9 @@ pub struct FuzzDictionary { new_addreses: Vec, /// Sample typed values that are collected from call result and used across invariant runs. sample_values: HashMap>, + + misses: usize, + hits: usize, } impl fmt::Debug for FuzzDictionary { @@ -303,6 +311,8 @@ impl FuzzDictionary { fn insert_value(&mut self, value: [u8; 32], collected: bool) { if self.state_values.len() < self.config.max_fuzz_dictionary_values { let (index, new_value) = self.state_values.insert_full(value); + let counter = if new_value { &mut self.misses } else { &mut self.hits }; + *counter += 1; if new_value && collected { self.new_values.push(index); } @@ -364,6 +374,17 @@ impl FuzzDictionary { self.new_values.clear(); self.new_addreses.clear(); } + + pub fn log_stats(&self) { + trace!( + addresses.len = self.addresses.len(), + sample.len = self.sample_values.len(), + state.len = self.state_values.len(), + state.misses = self.misses, + state.hits = self.hits, + "FuzzDictionary stats", + ); + } } /// Collects all created contracts from a StateChangeset which haven't been discovered yet. Stores diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 0b56f3500726e..3c3eb2ad49b63 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -209,7 +209,7 @@ impl MultiContractRunner { if !enabled!(tracing::Level::TRACE) { span_name = get_contract_name(&identifier); } - let _guard = info_span!("run_tests", name = span_name).entered(); + let _guard = debug_span!("run_suite", name = span_name).entered(); debug!("start executing all tests in contract"); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index c6588b582ff1d..dadd519631a00 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -365,6 +365,14 @@ impl<'a> ContractRunner<'a> { let _guard = handle.enter(); let sig = func.signature(); + let span = debug_span!("test", name = tracing::field::Empty).entered(); + if !span.is_disabled() { + if enabled!(tracing::Level::TRACE) { + span.record("name", &sig); + } else { + span.record("name", &func.name); + } + } let setup = setup.clone(); let should_fail = func.is_test_fail(); @@ -410,18 +418,8 @@ impl<'a> ContractRunner<'a> { /// /// State modifications are not committed to the evm database but discarded after the call, /// similar to `eth_call`. + #[instrument(level = "debug", name = "normal", skip_all)] pub fn run_test(&self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { - let span = info_span!("test", %should_fail); - if !span.is_disabled() { - let sig = &func.signature()[..]; - if enabled!(tracing::Level::TRACE) { - span.record("sig", sig); - } else { - span.record("sig", sig.split('(').next().unwrap()); - } - } - let _guard = span.enter(); - let TestSetup { address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. } = setup; @@ -517,7 +515,7 @@ impl<'a> ContractRunner<'a> { } } - #[instrument(name = "invariant_test", skip_all)] + #[instrument(level = "debug", name = "invariant", skip_all)] pub fn run_invariant_test( &self, runner: TestRunner, @@ -736,7 +734,7 @@ impl<'a> ContractRunner<'a> { } } - #[instrument(name = "fuzz_test", skip_all, fields(name = %func.signature(), %should_fail))] + #[instrument(level = "debug", name = "fuzz", skip_all)] pub fn run_fuzz_test( &self, func: &Function, @@ -745,17 +743,6 @@ impl<'a> ContractRunner<'a> { setup: TestSetup, fuzz_config: FuzzConfig, ) -> TestResult { - let span = info_span!("fuzz_test", %should_fail); - if !span.is_disabled() { - let sig = &func.signature()[..]; - if enabled!(tracing::Level::TRACE) { - span.record("test", sig); - } else { - span.record("test", sig.split('(').next().unwrap()); - } - } - let _guard = span.enter(); - let TestSetup { address, mut logs, From 487892dd05730a4120b8ed2639b38d9c0bee5fe6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:55:53 +0300 Subject: [PATCH 1035/1963] perf(invariant): collect push bytes only once (#8063) --- crates/evm/fuzz/src/strategies/state.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 3717f370ea9b9..6ff36f8e46d9c 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -229,6 +229,7 @@ impl FuzzDictionary { } /// Insert values from push bytes into fuzz dictionary. + /// Values are collected only once for a given address. /// If values are newly collected then they are removed at the end of current run. fn insert_push_bytes_values( &mut self, @@ -236,7 +237,7 @@ impl FuzzDictionary { account_info: &AccountInfo, collected: bool, ) { - if self.config.include_push_bytes { + if self.config.include_push_bytes && !self.addresses.contains(address) { // Insert push bytes if let Some(code) = account_info.code.clone() { self.insert_address(*address, collected); From 29a47350b6e12a0fea61640ff7a3dff923034b54 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:04:29 +0200 Subject: [PATCH 1036/1963] chore: remove '=== impl' comments (#8068) Sorry @mattsse but these are completely useless :D --- crates/anvil/core/src/eth/subscription.rs | 4 ---- crates/anvil/server/src/config.rs | 2 -- crates/anvil/server/src/pubsub.rs | 4 ---- crates/anvil/src/config.rs | 4 ---- crates/anvil/src/eth/api.rs | 4 ---- crates/anvil/src/eth/backend/cheats.rs | 2 -- crates/anvil/src/eth/backend/db.rs | 4 ---- crates/anvil/src/eth/backend/fork.rs | 6 ------ crates/anvil/src/eth/backend/genesis.rs | 2 -- crates/anvil/src/eth/backend/info.rs | 2 -- crates/anvil/src/eth/backend/mem/inspector.rs | 2 -- crates/anvil/src/eth/backend/mem/storage.rs | 10 ---------- crates/anvil/src/eth/backend/time.rs | 2 -- crates/anvil/src/eth/fees.rs | 4 ---- crates/anvil/src/eth/miner.rs | 10 ---------- crates/anvil/src/eth/pool/transactions.rs | 4 ---- crates/anvil/src/filter.rs | 6 ------ crates/anvil/src/logging.rs | 4 ---- crates/anvil/src/pubsub.rs | 6 ------ crates/anvil/src/server/handler.rs | 2 -- crates/anvil/src/service.rs | 2 -- crates/anvil/src/tasks/mod.rs | 2 -- crates/anvil/tests/it/fork.rs | 1 - crates/common/src/shell.rs | 6 ------ crates/config/src/endpoints.rs | 6 ------ crates/config/src/error.rs | 2 -- crates/config/src/etherscan.rs | 10 ---------- crates/config/src/fs_permissions.rs | 6 ------ crates/config/src/resolve.rs | 2 -- crates/evm/core/src/backend/mod.rs | 8 -------- crates/evm/core/src/backend/snapshot.rs | 2 -- crates/evm/core/src/fork/database.rs | 2 -- crates/evm/core/src/fork/multi.rs | 6 ------ crates/forge/bin/cmd/fmt.rs | 2 -- crates/forge/bin/cmd/test/filter.rs | 2 -- crates/script/src/lib.rs | 2 -- 36 files changed, 145 deletions(-) diff --git a/crates/anvil/core/src/eth/subscription.rs b/crates/anvil/core/src/eth/subscription.rs index cc162cc4dc9f7..cec95ba312585 100644 --- a/crates/anvil/core/src/eth/subscription.rs +++ b/crates/anvil/core/src/eth/subscription.rs @@ -14,8 +14,6 @@ pub enum SubscriptionId { String(String), } -// === impl SubscriptionId === - impl SubscriptionId { /// Generates a new random hex identifier pub fn random_hex() -> Self { @@ -47,8 +45,6 @@ pub struct HexIdProvider { len: usize, } -// === impl HexIdProvider === - impl HexIdProvider { /// Generates a random hex encoded Id pub fn gen(&self) -> String { diff --git a/crates/anvil/server/src/config.rs b/crates/anvil/server/src/config.rs index f968a6da39640..29b0e88121e0d 100644 --- a/crates/anvil/server/src/config.rs +++ b/crates/anvil/server/src/config.rs @@ -25,8 +25,6 @@ pub struct ServerConfig { pub no_cors: bool, } -// === impl ServerConfig === - impl ServerConfig { /// Sets the "allow origin" header for cors pub fn with_allow_origin(mut self, allow_origin: impl Into) -> Self { diff --git a/crates/anvil/server/src/pubsub.rs b/crates/anvil/server/src/pubsub.rs index 3c9be85bce6d7..2fe4358ef0ca8 100644 --- a/crates/anvil/server/src/pubsub.rs +++ b/crates/anvil/server/src/pubsub.rs @@ -40,8 +40,6 @@ pub struct PubSubContext { subscriptions: Subscriptions, } -// === impl PubSubContext === - impl PubSubContext { /// Adds new active subscription /// @@ -125,8 +123,6 @@ pub struct PubSubConnection { pending: VecDeque, } -// === impl PubSubConnection === - impl PubSubConnection { pub fn new(connection: Connection, handler: Handler) -> Self { Self { diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 9cac52cfe2f0c..7ee7d5e342eb8 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -350,8 +350,6 @@ Genesis Timestamp } } -// === impl NodeConfig === - impl NodeConfig { /// Returns a new config intended to be used in tests, which does not print and binds to a /// random, free port by setting it to `0` @@ -1179,8 +1177,6 @@ pub struct PruneStateHistoryConfig { pub max_memory_history: Option, } -// === impl PruneStateHistoryConfig === - impl PruneStateHistoryConfig { /// Returns `true` if writing state history is supported pub fn is_state_history_supported(&self) -> bool { diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 25a6b69bb50b2..6d4da2af4b28c 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -116,8 +116,6 @@ pub struct EthApi { instance_id: Arc>, } -// === impl Eth RPC API === - impl EthApi { /// Creates a new instance #[allow(clippy::too_many_arguments)] @@ -2114,8 +2112,6 @@ impl EthApi { } } -// === impl EthApi utility functions === - impl EthApi { /// Executes the future on a new blocking task. async fn on_blocking_task(&self, c: C) -> Result diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 0dc3189b07eb4..dbc58670f62f3 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -14,8 +14,6 @@ pub struct CheatsManager { state: Arc>, } -// === impl CheatsManager === - impl CheatsManager { /// Sets the account to impersonate /// diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 34ad343b5e9cf..852956d734817 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -266,8 +266,6 @@ impl> MaybeForkedDatabase for CacheDB { /// Represents a state at certain point pub struct StateDb(pub(crate) Box); -// === impl StateDB === - impl StateDb { pub fn new(db: impl MaybeFullDatabase + Send + Sync + 'static) -> Self { Self(Box::new(db)) @@ -322,8 +320,6 @@ pub struct SerializableState { pub best_block_number: Option, } -// === impl SerializableState === - impl SerializableState { /// Loads the `Genesis` object from the given json file path pub fn load(path: impl AsRef) -> Result { diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index b193a6fa783ef..04d62f48ba8f5 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -39,8 +39,6 @@ pub struct ClientFork { pub database: Arc>>, } -// === impl ClientFork === - impl ClientFork { /// Creates a new instance of the fork pub fn new(config: ClientForkConfig, database: Arc>>) -> Self { @@ -599,8 +597,6 @@ pub struct ClientForkConfig { pub total_difficulty: U256, } -// === impl ClientForkConfig === - impl ClientForkConfig { /// Updates the provider URL /// @@ -659,8 +655,6 @@ pub struct ForkedStorage { pub code_at: HashMap<(Address, u64), Bytes>, } -// === impl ForkedStorage === - impl ForkedStorage { /// Clears all data pub fn clear(&mut self) { diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index bbfbda55edc8d..ebe6e6f6ef1fa 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -32,8 +32,6 @@ pub struct GenesisConfig { pub genesis_init: Option, } -// === impl GenesisConfig === - impl GenesisConfig { /// Returns fresh `AccountInfo`s for the configured `accounts` pub fn account_infos(&self) -> impl Iterator + '_ { diff --git a/crates/anvil/src/eth/backend/info.rs b/crates/anvil/src/eth/backend/info.rs index 7b4c5d9c7e7ab..448dc660a1091 100644 --- a/crates/anvil/src/eth/backend/info.rs +++ b/crates/anvil/src/eth/backend/info.rs @@ -16,8 +16,6 @@ pub struct StorageInfo { backend: Arc, } -// === impl StorageInfo === - impl StorageInfo { pub(crate) fn new(backend: Arc) -> Self { Self { backend } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 892fa1778594e..0fe0f26af79d0 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -23,8 +23,6 @@ pub struct Inspector { pub log_collector: LogCollector, } -// === impl Inspector === - impl Inspector { /// Called after the inspecting the evm /// diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 916b07f6470b1..1f97addb4954f 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -35,8 +35,6 @@ const MIN_HISTORY_LIMIT: usize = 10; // 1hr of up-time at lowest 1s interval const MAX_ON_DISK_HISTORY_LIMIT: usize = 3_600; -// === impl DiskStateCache === - /// Represents the complete state of single block pub struct InMemoryBlockStates { /// The states at a certain block @@ -59,8 +57,6 @@ pub struct InMemoryBlockStates { disk_cache: DiskStateCache, } -// === impl InMemoryBlockStates === - impl InMemoryBlockStates { /// Creates a new instance with limited slots pub fn new(limit: usize) -> Self { @@ -296,8 +292,6 @@ impl BlockchainStorage { } } -// === impl BlockchainStorage === - impl BlockchainStorage { /// Returns the hash for [BlockNumberOrTag] pub fn hash(&self, number: BlockNumberOrTag) -> Option { @@ -334,8 +328,6 @@ pub struct Blockchain { pub storage: Arc>, } -// === impl BlockchainStorage === - impl Blockchain { /// Creates a new storage with a genesis block pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { @@ -395,8 +387,6 @@ pub struct MinedTransaction { pub block_number: u64, } -// === impl MinedTransaction === - impl MinedTransaction { /// Returns the traces of the transaction for `trace_transaction` pub fn parity_traces(&self) -> Vec { diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index ce6900eb48f90..5cad24f2bc49b 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -25,8 +25,6 @@ pub struct TimeManager { interval: Arc>>, } -// === impl TimeManager === - impl TimeManager { pub fn new(start_timestamp: u64) -> TimeManager { let time_manager = TimeManager { diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 11f84ea5e1128..8c0104a1b84e2 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -55,8 +55,6 @@ pub struct FeeManager { elasticity: Arc>, } -// === impl FeeManager === - impl FeeManager { pub fn new( spec_id: SpecId, @@ -195,8 +193,6 @@ pub struct FeeHistoryService { storage_info: StorageInfo, } -// === impl FeeHistoryService === - impl FeeHistoryService { pub fn new( new_blocks: NewBlockNotifications, diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index 2199a50613511..442c6fe7bbe31 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -27,8 +27,6 @@ pub struct Miner { inner: Arc, } -// === impl Miner === - impl Miner { /// Returns a new miner with that operates in the given `mode` pub fn new(mode: MiningMode) -> Self { @@ -79,8 +77,6 @@ pub struct MinerInner { waker: AtomicWaker, } -// === impl MinerInner === - impl MinerInner { /// Call the waker again fn wake(&self) { @@ -112,8 +108,6 @@ pub enum MiningMode { FixedBlockTime(FixedBlockTimeMiner), } -// === impl MiningMode === - impl MiningMode { pub fn instant(max_transactions: usize, listener: Receiver) -> Self { MiningMode::Auto(ReadyTransactionMiner { @@ -151,8 +145,6 @@ pub struct FixedBlockTimeMiner { interval: Interval, } -// === impl FixedBlockTimeMiner === - impl FixedBlockTimeMiner { /// Creates a new instance with an interval of `duration` pub fn new(duration: Duration) -> Self { @@ -185,8 +177,6 @@ pub struct ReadyTransactionMiner { rx: Fuse>, } -// === impl ReadyTransactionMiner === - impl ReadyTransactionMiner { fn poll(&mut self, pool: &Arc, cx: &mut Context<'_>) -> Poll>> { // drain the notification stream diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 9a229001d4054..23841b0d7700b 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -37,8 +37,6 @@ pub enum TransactionOrder { Fees, } -// === impl TransactionOrder === - impl TransactionOrder { /// Returns the priority of the transactions pub fn priority(&self, tx: &TypedTransaction) -> TransactionPriority { @@ -686,8 +684,6 @@ pub struct ReadyTransaction { pub requires_offset: usize, } -// === impl ReadyTransaction == - impl ReadyTransaction { pub fn provides(&self) -> &[TxMarker] { &self.transaction.transaction.provides diff --git a/crates/anvil/src/filter.rs b/crates/anvil/src/filter.rs index 268a8f46eb58d..b1d2370f5da2b 100644 --- a/crates/anvil/src/filter.rs +++ b/crates/anvil/src/filter.rs @@ -33,8 +33,6 @@ pub struct Filters { keepalive: Duration, } -// === impl Filters === - impl Filters { /// Adds a new `EthFilter` to the set pub async fn add_filter(&self, filter: EthFilter) -> String { @@ -123,8 +121,6 @@ pub enum EthFilter { PendingTransactions(Receiver), } -// === impl EthFilter === - impl Stream for EthFilter { type Item = ResponseResult; @@ -165,8 +161,6 @@ pub struct LogsFilter { pub historic: Option>, } -// === impl LogsFilter === - impl LogsFilter { /// Returns all the logs since the last time this filter was polled pub fn poll(&mut self, cx: &mut Context<'_>) -> Vec { diff --git a/crates/anvil/src/logging.rs b/crates/anvil/src/logging.rs index 5819aafc99c2d..ba97ab7ef47d2 100644 --- a/crates/anvil/src/logging.rs +++ b/crates/anvil/src/logging.rs @@ -17,8 +17,6 @@ pub struct NodeLogLayer { state: LoggingManager, } -// === impl NodeLogLayer === - impl NodeLogLayer { /// Returns a new instance of this layer pub fn new(state: LoggingManager) -> Self { @@ -51,8 +49,6 @@ pub struct LoggingManager { pub enabled: Arc>, } -// === impl LoggingManager === - impl LoggingManager { /// Returns true if logging is currently enabled pub fn is_enabled(&self) -> bool { diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index a063ee6697b2f..46caa9d7cadae 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -24,8 +24,6 @@ pub struct LogsSubscription { pub id: SubscriptionId, } -// === impl LogsSubscription === - impl LogsSubscription { fn poll(&mut self, cx: &mut Context<'_>) -> Poll> { loop { @@ -68,8 +66,6 @@ pub struct EthSubscriptionResponse { params: EthSubscriptionParams, } -// === impl EthSubscriptionResponse === - impl EthSubscriptionResponse { pub fn new(params: EthSubscriptionParams) -> Self { Self { jsonrpc: Version::V2, method: "eth_subscription", params } @@ -92,8 +88,6 @@ pub enum EthSubscription { PendingTransactions(Receiver, SubscriptionId), } -// === impl EthSubscription === - impl EthSubscription { fn poll_response(&mut self, cx: &mut Context<'_>) -> Poll> { match self { diff --git a/crates/anvil/src/server/handler.rs b/crates/anvil/src/server/handler.rs index 2cab0d5b7ae05..79adb87df7bcb 100644 --- a/crates/anvil/src/server/handler.rs +++ b/crates/anvil/src/server/handler.rs @@ -19,8 +19,6 @@ pub struct HttpEthRpcHandler { api: EthApi, } -// === impl WsEthRpcHandler === - impl HttpEthRpcHandler { /// Creates a new instance of the handler using the given `EthApi` pub fn new(api: EthApi) -> Self { diff --git a/crates/anvil/src/service.rs b/crates/anvil/src/service.rs index 71cfdfecbd8d0..6759f68121ca3 100644 --- a/crates/anvil/src/service.rs +++ b/crates/anvil/src/service.rs @@ -112,8 +112,6 @@ struct BlockProducer { queued: VecDeque>>, } -// === impl BlockProducer === - impl BlockProducer { fn new(backend: Arc) -> Self { Self { idle_backend: Some(backend), block_mining: None, queued: Default::default() } diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index e42b0437ca68a..a63b190163e12 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -22,8 +22,6 @@ pub struct TaskManager { on_shutdown: Shutdown, } -// === impl TaskManager === - impl TaskManager { /// Creates a new instance of the task manager pub fn new(tokio_handle: Handle, on_shutdown: Shutdown) -> Self { diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 87a1b6985e722..19377e845fdef 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -34,7 +34,6 @@ pub struct LocalFork { fork_handle: NodeHandle, } -// === impl LocalFork === #[allow(dead_code)] impl LocalFork { /// Spawns two nodes with the test config diff --git a/crates/common/src/shell.rs b/crates/common/src/shell.rs index 9955269ee38aa..89d9905364732 100644 --- a/crates/common/src/shell.rs +++ b/crates/common/src/shell.rs @@ -70,8 +70,6 @@ pub struct Shell { verbosity: Verbosity, } -// === impl Shell === - impl Shell { /// Creates a new shell instance pub fn new(output: ShellOut, verbosity: Verbosity) -> Self { @@ -210,8 +208,6 @@ pub enum ShellOut { Stream, } -// === impl ShellOut === - impl ShellOut { /// Creates a new shell that writes to memory pub fn memory() -> Self { @@ -294,8 +290,6 @@ pub enum Verbosity { Silent, } -// === impl Verbosity === - impl Verbosity { /// Returns true if json mode pub fn is_json(&self) -> bool { diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index 36cc8c7b6a83f..f29e72545b55a 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -15,8 +15,6 @@ pub struct RpcEndpoints { endpoints: BTreeMap, } -// === impl RpcEndpoints === - impl RpcEndpoints { /// Creates a new list of endpoints pub fn new( @@ -132,8 +130,6 @@ pub enum RpcEndpoint { Env(String), } -// === impl RpcEndpoint === - impl RpcEndpoint { /// Returns the url variant pub fn as_url(&self) -> Option<&str> { @@ -341,8 +337,6 @@ pub struct ResolvedRpcEndpoints { endpoints: BTreeMap>, } -// === impl ResolvedEndpoints === - impl ResolvedRpcEndpoints { /// Returns true if there's an endpoint that couldn't be resolved pub fn has_unresolved(&self) -> bool { diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 448553cdcc174..fe193171a33f6 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -140,8 +140,6 @@ pub enum SolidityErrorCode { Other(u64), } -// === impl SolidityErrorCode === - impl SolidityErrorCode { /// The textual identifier for this error /// diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index fb254a6357d8e..8863ad059a796 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -66,8 +66,6 @@ pub struct EtherscanConfigs { configs: BTreeMap, } -// === impl Endpoints === - impl EtherscanConfigs { /// Creates a new list of etherscan configs pub fn new(configs: impl IntoIterator, EtherscanConfig)>) -> Self { @@ -121,8 +119,6 @@ pub struct ResolvedEtherscanConfigs { configs: BTreeMap>, } -// === impl ResolvedEtherscanConfigs === - impl ResolvedEtherscanConfigs { /// Creates a new list of resolved etherscan configs pub fn new( @@ -181,8 +177,6 @@ pub struct EtherscanConfig { pub key: EtherscanApiKey, } -// === impl EtherscanConfig === - impl EtherscanConfig { /// Returns the etherscan config required to create a client. /// @@ -262,8 +256,6 @@ pub struct ResolvedEtherscanConfig { pub chain: Option, } -// === impl ResolvedEtherscanConfig === - impl ResolvedEtherscanConfig { /// Creates a new instance using the api key and chain pub fn create(api_key: impl Into, chain: impl Into) -> Option { @@ -350,8 +342,6 @@ pub enum EtherscanApiKey { Env(String), } -// === impl EtherscanApiKey === - impl EtherscanApiKey { /// Returns the key variant pub fn as_key(&self) -> Option<&str> { diff --git a/crates/config/src/fs_permissions.rs b/crates/config/src/fs_permissions.rs index fbbe67af9fdb8..6a75beb055f03 100644 --- a/crates/config/src/fs_permissions.rs +++ b/crates/config/src/fs_permissions.rs @@ -17,8 +17,6 @@ pub struct FsPermissions { pub permissions: Vec, } -// === impl FsPermissions === - impl FsPermissions { /// Creates anew instance with the given `permissions` pub fn new(permissions: impl IntoIterator) -> Self { @@ -108,8 +106,6 @@ pub struct PathPermission { pub path: PathBuf, } -// === impl PathPermission === - impl PathPermission { /// Returns a new permission for the path and the given access pub fn new(path: impl Into, access: FsAccessPermission) -> Self { @@ -174,8 +170,6 @@ pub enum FsAccessPermission { Write, } -// === impl FsAccessPermission === - impl FsAccessPermission { /// Returns true if the access is allowed pub fn is_granted(&self, kind: FsAccessKind) -> bool { diff --git a/crates/config/src/resolve.rs b/crates/config/src/resolve.rs index b817f43677c62..981ddc886db3c 100644 --- a/crates/config/src/resolve.rs +++ b/crates/config/src/resolve.rs @@ -19,8 +19,6 @@ pub struct UnresolvedEnvVarError { pub source: VarError, } -// === impl UnresolvedEnvVarError === - impl UnresolvedEnvVarError { /// Tries to resolve a value pub fn try_resolve(&self) -> Result { diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 1e648491d622d..94a1eeead2281 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -414,8 +414,6 @@ pub struct Backend { inner: BackendInner, } -// === impl Backend === - impl Backend { /// Creates a new Backend with a spawned multi fork thread. pub fn spawn(fork: Option) -> Self { @@ -934,8 +932,6 @@ impl Backend { } } -// === impl a bunch of `revm::Database` adjacent implementations === - impl DatabaseExt for Backend { fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256 { trace!("create snapshot"); @@ -1514,8 +1510,6 @@ pub struct Fork { journaled_state: JournaledState, } -// === impl Fork === - impl Fork { /// Returns true if the account is a contract pub fn is_contract(&self, acc: Address) -> bool { @@ -1587,8 +1581,6 @@ pub struct BackendInner { pub cheatcode_access_accounts: HashSet
, } -// === impl BackendInner === - impl BackendInner { pub fn ensure_fork_id(&self, id: LocalForkId) -> eyre::Result<&ForkId> { self.issued_local_fork_ids diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index 4c0c665f299ec..5fd0cfa77958a 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -23,8 +23,6 @@ pub struct BackendSnapshot { pub env: Env, } -// === impl BackendSnapshot === - impl BackendSnapshot { /// Takes a new snapshot pub fn new(db: T, journaled_state: JournaledState, env: Env) -> Self { diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 4b1e3d6b0f9b1..2712b57798c1a 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -207,8 +207,6 @@ pub struct ForkDbSnapshot { pub snapshot: StateSnapshot, } -// === impl DbSnapshot === - impl ForkDbSnapshot { fn get_storage(&self, address: Address, index: U256) -> Option { self.local.accounts.get(&address).and_then(|account| account.storage.get(&index)).copied() diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index da1f980ffbcb2..bece8c4f5bcce 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -72,8 +72,6 @@ pub struct MultiFork { _shutdown: Arc, } -// === impl MultiForkBackend === - impl MultiFork { /// Creates a new pair multi fork pair pub fn new() -> (Self, MultiForkHandler) { @@ -222,8 +220,6 @@ pub struct MultiForkHandler { flush_cache_interval: Option, } -// === impl MultiForkHandler === - impl MultiForkHandler { fn new(incoming: Receiver) -> Self { Self { @@ -438,8 +434,6 @@ struct CreatedFork { num_senders: Arc, } -// === impl CreatedFork === - impl CreatedFork { pub fn new(opts: CreateFork, backend: SharedBackend) -> Self { Self { opts, backend, num_senders: Arc::new(AtomicUsize::new(1)) } diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index b3207bcb754e7..34df8dbcf5e13 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -43,8 +43,6 @@ pub struct FmtArgs { impl_figment_convert_basic!(FmtArgs); -// === impl FmtArgs === - impl FmtArgs { pub fn run(self) -> Result<()> { let config = self.try_load_config_emit_warnings()?; diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index c30b3434ae942..1a7f355d7e753 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -164,8 +164,6 @@ pub struct ProjectPathsAwareFilter { paths: ProjectPathsConfig, } -// === impl ProjectPathsAwareFilter === - impl ProjectPathsAwareFilter { /// Returns true if the filter is empty. pub fn is_empty(&self) -> bool { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 95f88dd8d64b6..bd0e2373663ca 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -197,8 +197,6 @@ pub struct ScriptArgs { pub retry: RetryArgs, } -// === impl ScriptArgs === - impl ScriptArgs { async fn preprocess(self) -> Result { let script_wallets = From d5fb75006c668935398f26516400b9f193a7caae Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:17:11 +0200 Subject: [PATCH 1037/1963] chore: add and use workspace.lints (#8067) * chore: add and use workspace.lints * chore: clippy --fix * fixdoc --- Cargo.lock | 6 - Cargo.toml | 14 ++ crates/anvil/Cargo.toml | 3 + crates/anvil/core/Cargo.toml | 8 +- crates/anvil/core/src/eth/proof.rs | 2 +- crates/anvil/core/src/eth/subscription.rs | 10 +- crates/anvil/core/src/eth/transaction/mod.rs | 211 +++++++++--------- crates/anvil/core/src/lib.rs | 7 + crates/anvil/core/src/types.rs | 13 +- crates/anvil/rpc/Cargo.toml | 6 +- crates/anvil/rpc/src/error.rs | 62 +++-- crates/anvil/rpc/src/lib.rs | 7 + crates/anvil/rpc/src/request.rs | 8 +- crates/anvil/rpc/src/response.rs | 12 +- crates/anvil/server/Cargo.toml | 3 + crates/anvil/server/src/config.rs | 4 +- crates/anvil/server/src/ipc.rs | 2 +- crates/anvil/server/src/lib.rs | 3 +- crates/anvil/src/cmd.rs | 8 +- crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/backend/mem/cache.rs | 2 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 4 +- crates/anvil/src/eth/backend/mem/storage.rs | 2 +- crates/anvil/src/eth/backend/time.rs | 4 +- crates/anvil/src/eth/error.rs | 76 +++---- crates/anvil/src/eth/fees.rs | 16 +- crates/anvil/src/eth/miner.rs | 10 +- crates/anvil/src/eth/otterscan/types.rs | 10 +- crates/anvil/src/eth/pool/mod.rs | 4 +- crates/anvil/src/eth/pool/transactions.rs | 8 +- crates/anvil/src/filter.rs | 6 +- crates/anvil/src/hardfork.rs | 132 +++++------ crates/anvil/src/lib.rs | 5 +- crates/anvil/src/pubsub.rs | 6 +- crates/anvil/src/service.rs | 2 +- crates/anvil/tests/it/transaction.rs | 3 +- crates/cast/Cargo.toml | 3 + crates/cast/bin/cmd/access_list.rs | 4 +- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/create2.rs | 2 +- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/find_block.rs | 2 +- crates/cast/bin/cmd/interface.rs | 9 +- crates/cast/bin/cmd/logs.rs | 4 +- crates/cast/bin/cmd/mktx.rs | 2 +- crates/cast/bin/cmd/rpc.rs | 2 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/cmd/send.rs | 2 +- crates/cast/bin/cmd/wallet/mod.rs | 25 +-- crates/cast/bin/cmd/wallet/vanity.rs | 2 +- crates/cast/bin/main.rs | 2 +- crates/cast/src/base.rs | 4 +- crates/cast/src/errors.rs | 8 +- crates/cast/src/lib.rs | 25 ++- crates/cast/src/rlp_converter.rs | 30 +-- crates/cheatcodes/Cargo.toml | 3 + crates/cheatcodes/spec/Cargo.toml | 3 + crates/cheatcodes/spec/src/lib.rs | 3 +- crates/cheatcodes/spec/src/vm.rs | 28 ++- crates/cheatcodes/src/evm/prank.rs | 14 +- crates/cheatcodes/src/json.rs | 4 +- crates/cheatcodes/src/lib.rs | 3 +- crates/cheatcodes/src/test/assert.rs | 8 +- crates/chisel/Cargo.toml | 3 + crates/chisel/src/cmd.rs | 44 ++-- crates/chisel/src/dispatcher.rs | 13 +- crates/chisel/src/executor.rs | 10 +- crates/chisel/src/lib.rs | 5 +- crates/chisel/src/session.rs | 6 +- crates/chisel/src/session_source.rs | 2 +- crates/chisel/src/solidity_helper.rs | 4 +- crates/chisel/tests/cache.rs | 14 +- crates/cli/Cargo.toml | 3 + crates/cli/src/lib.rs | 7 +- crates/cli/src/opts/build/core.rs | 2 +- crates/cli/src/opts/dependency.rs | 2 +- crates/cli/src/utils/cmd.rs | 4 +- crates/common/Cargo.toml | 3 + crates/common/src/compile.rs | 16 +- crates/common/src/contracts.rs | 11 +- crates/common/src/ens.rs | 14 +- crates/common/src/errors/fs.rs | 18 +- crates/common/src/fmt/console.rs | 6 +- crates/common/src/fmt/ui.rs | 18 +- crates/common/src/lib.rs | 6 +- crates/common/src/provider/mod.rs | 6 +- .../common/src/provider/runtime_transport.rs | 7 +- crates/common/src/selectors.rs | 4 +- crates/common/src/serde_helpers.rs | 12 +- crates/common/src/shell.rs | 24 +- crates/common/src/term.rs | 8 +- crates/config/src/lib.rs | 5 +- crates/debugger/Cargo.toml | 3 + crates/debugger/src/lib.rs | 3 +- crates/debugger/src/tui/context.rs | 12 +- crates/debugger/src/tui/draw.rs | 4 +- crates/doc/Cargo.toml | 3 + crates/doc/src/document.rs | 34 ++- crates/doc/src/lib.rs | 12 +- crates/doc/src/parser/comment.rs | 30 +-- crates/doc/src/parser/item.rs | 18 +- crates/doc/src/parser/mod.rs | 2 +- .../doc/src/preprocessor/infer_hyperlinks.rs | 2 +- crates/evm/core/Cargo.toml | 3 + crates/evm/core/src/backend/diagnostic.rs | 4 +- crates/evm/core/src/backend/error.rs | 14 +- crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/backend/snapshot.rs | 2 +- crates/evm/core/src/fork/cache.rs | 8 +- crates/evm/core/src/fork/multi.rs | 2 +- crates/evm/core/src/lib.rs | 3 +- crates/evm/coverage/Cargo.toml | 3 + crates/evm/coverage/src/lib.rs | 11 +- crates/evm/evm/Cargo.toml | 3 + crates/evm/evm/src/executors/invariant/mod.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 8 +- crates/evm/evm/src/lib.rs | 3 +- crates/evm/fuzz/Cargo.toml | 3 + .../evm/fuzz/src/invariant/call_override.rs | 2 +- crates/evm/fuzz/src/invariant/filters.rs | 2 +- crates/evm/fuzz/src/lib.rs | 13 +- crates/evm/fuzz/src/strategies/int.rs | 4 +- crates/evm/fuzz/src/strategies/state.rs | 2 +- crates/evm/traces/Cargo.toml | 3 + crates/evm/traces/src/decoder/mod.rs | 4 +- crates/evm/traces/src/lib.rs | 5 +- crates/fmt/Cargo.toml | 3 + crates/fmt/src/buffer.rs | 8 +- crates/fmt/src/chunk.rs | 6 +- crates/fmt/src/comments.rs | 14 +- crates/fmt/src/helpers.rs | 4 +- crates/fmt/src/inline_config.rs | 10 +- crates/fmt/src/lib.rs | 1 + crates/fmt/src/solang_ext/ast_eq.rs | 24 +- crates/fmt/src/string.rs | 14 +- crates/fmt/src/visit.rs | 120 +++++----- crates/fmt/tests/formatter.rs | 2 +- crates/forge/Cargo.toml | 3 + crates/forge/README.md | 4 +- crates/forge/bin/cmd/bind.rs | 2 +- crates/forge/bin/cmd/cache.rs | 10 +- crates/forge/bin/cmd/clone.rs | 14 +- crates/forge/bin/cmd/coverage.rs | 2 +- crates/forge/bin/cmd/create.rs | 6 +- crates/forge/bin/cmd/flatten.rs | 2 +- crates/forge/bin/cmd/generate/mod.rs | 2 +- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/bin/cmd/install.rs | 4 +- crates/forge/bin/cmd/selectors.rs | 8 +- crates/forge/bin/cmd/snapshot.rs | 8 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/bin/cmd/watch.rs | 2 +- crates/forge/src/coverage.rs | 16 +- crates/forge/src/lib.rs | 3 + crates/forge/src/result.rs | 18 +- crates/forge/tests/cli/config.rs | 1 - crates/forge/tests/cli/verify.rs | 2 +- crates/forge/tests/it/test_helpers.rs | 6 +- crates/linking/Cargo.toml | 3 + crates/linking/src/lib.rs | 9 +- crates/macros/Cargo.toml | 3 + crates/macros/src/lib.rs | 7 +- crates/script/Cargo.toml | 3 + crates/script/src/broadcast.rs | 8 +- crates/script/src/build.rs | 2 +- crates/script/src/lib.rs | 5 + crates/script/src/multi_sequence.rs | 12 +- crates/script/src/progress.rs | 8 +- crates/script/src/providers.rs | 4 +- crates/script/src/receipts.rs | 4 +- crates/script/src/sequence.rs | 21 +- crates/script/src/transaction.rs | 2 +- crates/script/src/verify.rs | 2 +- crates/test-utils/Cargo.toml | 3 + crates/test-utils/src/filter.rs | 4 +- crates/test-utils/src/lib.rs | 7 +- crates/test-utils/src/script.rs | 26 +-- crates/test-utils/src/util.rs | 16 +- crates/verify/Cargo.toml | 3 + crates/verify/src/bytecode.rs | 16 +- crates/verify/src/lib.rs | 7 +- crates/verify/src/provider.rs | 28 +-- crates/verify/src/retry.rs | 2 +- crates/wallets/Cargo.toml | 9 +- crates/wallets/src/error.rs | 2 +- crates/wallets/src/lib.rs | 7 + crates/wallets/src/wallet_signer.rs | 8 +- 189 files changed, 992 insertions(+), 951 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b802db9cd4a5b..920d46dd14f62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -780,16 +780,13 @@ dependencies = [ "alloy-consensus", "alloy-dyn-abi", "alloy-eips", - "alloy-network", "alloy-primitives", "alloy-rlp", "alloy-rpc-types", "alloy-rpc-types-trace", "alloy-serde", "alloy-trie", - "anvil-core", "bytes", - "c-kzg", "foundry-common", "foundry-evm", "rand", @@ -802,7 +799,6 @@ dependencies = [ name = "anvil-rpc" version = "0.2.0" dependencies = [ - "rand", "serde", "serde_json", ] @@ -3743,9 +3739,7 @@ dependencies = [ "const-hex", "derive_builder", "eyre", - "foundry-common", "foundry-config", - "itertools 0.13.0", "rpassword", "serde", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 3818778fa02e0..7becafbc7dfc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,20 @@ homepage = "https://github.com/foundry-rs/foundry" repository = "https://github.com/foundry-rs/foundry" exclude = ["benches/", "tests/", "test-data/", "testdata/"] +[workspace.lints.clippy] +dbg-macro = "warn" +manual-string-new = "warn" +uninlined-format-args = "warn" +use-self = "warn" + +[workspace.lints.rust] +rust-2018-idioms = "deny" +# unreachable-pub = "warn" +unused-must-use = "deny" + +[workspace.lints.rustdoc] +# all = "warn" + # Speed up compilation time for dev builds by reducing emitted debug info. # NOTE: Debuggers may provide less useful information with this setting. # Uncomment this section if you're using a debugger. diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 96c0a2071e1fa..749db58dbad80 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [[bin]] name = "anvil" path = "src/anvil.rs" diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 92f907c4ec20f..aa7a323ed891c 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-common.workspace = true foundry-evm.workspace = true @@ -25,7 +28,6 @@ alloy-rpc-types-trace.workspace = true alloy-serde.workspace = true alloy-rlp.workspace = true alloy-eips.workspace = true -alloy-network = { workspace = true, features = ["k256"] } alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-trie.workspace = true @@ -33,14 +35,10 @@ alloy-trie.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true bytes = "1.4" -c-kzg = { version = "1", features = ["serde"] } # misc rand = "0.8" -[dev-dependencies] -anvil-core = { path = ".", features = ["serde"] } - [features] default = ["serde"] impersonated-tx = [] diff --git a/crates/anvil/core/src/eth/proof.rs b/crates/anvil/core/src/eth/proof.rs index ba2357bffd578..450e53e471410 100644 --- a/crates/anvil/core/src/eth/proof.rs +++ b/crates/anvil/core/src/eth/proof.rs @@ -14,7 +14,7 @@ pub struct BasicAccount { impl Default for BasicAccount { fn default() -> Self { - BasicAccount { + Self { balance: U256::ZERO, nonce: U256::ZERO, code_hash: KECCAK_EMPTY, diff --git a/crates/anvil/core/src/eth/subscription.rs b/crates/anvil/core/src/eth/subscription.rs index cec95ba312585..9d347e9a60333 100644 --- a/crates/anvil/core/src/eth/subscription.rs +++ b/crates/anvil/core/src/eth/subscription.rs @@ -17,15 +17,15 @@ pub enum SubscriptionId { impl SubscriptionId { /// Generates a new random hex identifier pub fn random_hex() -> Self { - SubscriptionId::String(hex_id()) + Self::String(hex_id()) } } impl fmt::Display for SubscriptionId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - SubscriptionId::Number(num) => num.fmt(f), - SubscriptionId::String(s) => s.fmt(f), + Self::Number(num) => num.fmt(f), + Self::String(s) => s.fmt(f), } } } @@ -33,8 +33,8 @@ impl fmt::Display for SubscriptionId { impl fmt::Debug for SubscriptionId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - SubscriptionId::Number(num) => num.fmt(f), - SubscriptionId::String(s) => s.fmt(f), + Self::Number(num) => num.fmt(f), + Self::String(s) => s.fmt(f), } } } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 6710ce1bcb26c..0aa6b83309adb 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -231,13 +231,13 @@ impl From for TypedTransaction { impl From for MaybeImpersonatedTransaction { fn from(value: TypedTransaction) -> Self { - MaybeImpersonatedTransaction::new(value) + Self::new(value) } } impl Decodable for MaybeImpersonatedTransaction { fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - TypedTransaction::decode(buf).map(MaybeImpersonatedTransaction::new) + TypedTransaction::decode(buf).map(Self::new) } } @@ -610,57 +610,57 @@ pub enum TypedTransaction { impl TypedTransaction { /// Returns true if the transaction uses dynamic fees: EIP1559 or EIP4844 pub fn is_dynamic_fee(&self) -> bool { - matches!(self, TypedTransaction::EIP1559(_)) || matches!(self, TypedTransaction::EIP4844(_)) + matches!(self, Self::EIP1559(_)) || matches!(self, Self::EIP4844(_)) } pub fn gas_price(&self) -> u128 { match self { - TypedTransaction::Legacy(tx) => tx.tx().gas_price, - TypedTransaction::EIP2930(tx) => tx.tx().gas_price, - TypedTransaction::EIP1559(tx) => tx.tx().max_fee_per_gas, - TypedTransaction::EIP4844(tx) => tx.tx().tx().max_fee_per_gas, - TypedTransaction::Deposit(_) => 0, + Self::Legacy(tx) => tx.tx().gas_price, + Self::EIP2930(tx) => tx.tx().gas_price, + Self::EIP1559(tx) => tx.tx().max_fee_per_gas, + Self::EIP4844(tx) => tx.tx().tx().max_fee_per_gas, + Self::Deposit(_) => 0, } } pub fn gas_limit(&self) -> u128 { match self { - TypedTransaction::Legacy(tx) => tx.tx().gas_limit, - TypedTransaction::EIP2930(tx) => tx.tx().gas_limit, - TypedTransaction::EIP1559(tx) => tx.tx().gas_limit, - TypedTransaction::EIP4844(tx) => tx.tx().tx().gas_limit, - TypedTransaction::Deposit(tx) => tx.gas_limit, + Self::Legacy(tx) => tx.tx().gas_limit, + Self::EIP2930(tx) => tx.tx().gas_limit, + Self::EIP1559(tx) => tx.tx().gas_limit, + Self::EIP4844(tx) => tx.tx().tx().gas_limit, + Self::Deposit(tx) => tx.gas_limit, } } pub fn value(&self) -> U256 { U256::from(match self { - TypedTransaction::Legacy(tx) => tx.tx().value, - TypedTransaction::EIP2930(tx) => tx.tx().value, - TypedTransaction::EIP1559(tx) => tx.tx().value, - TypedTransaction::EIP4844(tx) => tx.tx().tx().value, - TypedTransaction::Deposit(tx) => tx.value, + Self::Legacy(tx) => tx.tx().value, + Self::EIP2930(tx) => tx.tx().value, + Self::EIP1559(tx) => tx.tx().value, + Self::EIP4844(tx) => tx.tx().tx().value, + Self::Deposit(tx) => tx.value, }) } pub fn data(&self) -> &Bytes { match self { - TypedTransaction::Legacy(tx) => &tx.tx().input, - TypedTransaction::EIP2930(tx) => &tx.tx().input, - TypedTransaction::EIP1559(tx) => &tx.tx().input, - TypedTransaction::EIP4844(tx) => &tx.tx().tx().input, - TypedTransaction::Deposit(tx) => &tx.input, + Self::Legacy(tx) => &tx.tx().input, + Self::EIP2930(tx) => &tx.tx().input, + Self::EIP1559(tx) => &tx.tx().input, + Self::EIP4844(tx) => &tx.tx().tx().input, + Self::Deposit(tx) => &tx.input, } } /// Returns the transaction type pub fn r#type(&self) -> Option { match self { - TypedTransaction::Legacy(_) => None, - TypedTransaction::EIP2930(_) => Some(1), - TypedTransaction::EIP1559(_) => Some(2), - TypedTransaction::EIP4844(_) => Some(3), - TypedTransaction::Deposit(_) => Some(0x7E), + Self::Legacy(_) => None, + Self::EIP2930(_) => Some(1), + Self::EIP1559(_) => Some(2), + Self::EIP4844(_) => Some(3), + Self::Deposit(_) => Some(0x7E), } } @@ -682,14 +682,14 @@ impl TypedTransaction { pub fn blob_gas(&self) -> Option { match self { - TypedTransaction::EIP4844(tx) => Some(tx.tx().tx().blob_gas() as u128), + Self::EIP4844(tx) => Some(tx.tx().tx().blob_gas() as u128), _ => None, } } pub fn max_fee_per_blob_gas(&self) -> Option { match self { - TypedTransaction::EIP4844(tx) => Some(tx.tx().tx().max_fee_per_blob_gas), + Self::EIP4844(tx) => Some(tx.tx().tx().max_fee_per_blob_gas), _ => None, } } @@ -697,7 +697,7 @@ impl TypedTransaction { /// Returns a helper type that contains commonly used values as fields pub fn essentials(&self) -> TransactionEssentials { match self { - TypedTransaction::Legacy(t) => TransactionEssentials { + Self::Legacy(t) => TransactionEssentials { kind: t.tx().to, input: t.tx().input.clone(), nonce: t.tx().nonce, @@ -711,7 +711,7 @@ impl TypedTransaction { chain_id: t.tx().chain_id, access_list: Default::default(), }, - TypedTransaction::EIP2930(t) => TransactionEssentials { + Self::EIP2930(t) => TransactionEssentials { kind: t.tx().to, input: t.tx().input.clone(), nonce: t.tx().nonce, @@ -725,7 +725,7 @@ impl TypedTransaction { chain_id: Some(t.tx().chain_id), access_list: t.tx().access_list.clone(), }, - TypedTransaction::EIP1559(t) => TransactionEssentials { + Self::EIP1559(t) => TransactionEssentials { kind: t.tx().to, input: t.tx().input.clone(), nonce: t.tx().nonce, @@ -739,7 +739,7 @@ impl TypedTransaction { chain_id: Some(t.tx().chain_id), access_list: t.tx().access_list.clone(), }, - TypedTransaction::EIP4844(t) => TransactionEssentials { + Self::EIP4844(t) => TransactionEssentials { kind: TxKind::Call(t.tx().tx().to), input: t.tx().tx().input.clone(), nonce: t.tx().tx().nonce, @@ -753,7 +753,7 @@ impl TypedTransaction { chain_id: Some(t.tx().tx().chain_id), access_list: t.tx().tx().access_list.clone(), }, - TypedTransaction::Deposit(t) => TransactionEssentials { + Self::Deposit(t) => TransactionEssentials { kind: t.kind, input: t.input.clone(), nonce: t.nonce, @@ -772,49 +772,49 @@ impl TypedTransaction { pub fn nonce(&self) -> u64 { match self { - TypedTransaction::Legacy(t) => t.tx().nonce, - TypedTransaction::EIP2930(t) => t.tx().nonce, - TypedTransaction::EIP1559(t) => t.tx().nonce, - TypedTransaction::EIP4844(t) => t.tx().tx().nonce, - TypedTransaction::Deposit(t) => t.nonce, + Self::Legacy(t) => t.tx().nonce, + Self::EIP2930(t) => t.tx().nonce, + Self::EIP1559(t) => t.tx().nonce, + Self::EIP4844(t) => t.tx().tx().nonce, + Self::Deposit(t) => t.nonce, } } pub fn chain_id(&self) -> Option { match self { - TypedTransaction::Legacy(t) => t.tx().chain_id, - TypedTransaction::EIP2930(t) => Some(t.tx().chain_id), - TypedTransaction::EIP1559(t) => Some(t.tx().chain_id), - TypedTransaction::EIP4844(t) => Some(t.tx().tx().chain_id), - TypedTransaction::Deposit(t) => t.chain_id(), + Self::Legacy(t) => t.tx().chain_id, + Self::EIP2930(t) => Some(t.tx().chain_id), + Self::EIP1559(t) => Some(t.tx().chain_id), + Self::EIP4844(t) => Some(t.tx().tx().chain_id), + Self::Deposit(t) => t.chain_id(), } } pub fn as_legacy(&self) -> Option<&Signed> { match self { - TypedTransaction::Legacy(tx) => Some(tx), + Self::Legacy(tx) => Some(tx), _ => None, } } /// Returns true whether this tx is a legacy transaction pub fn is_legacy(&self) -> bool { - matches!(self, TypedTransaction::Legacy(_)) + matches!(self, Self::Legacy(_)) } /// Returns true whether this tx is a EIP1559 transaction pub fn is_eip1559(&self) -> bool { - matches!(self, TypedTransaction::EIP1559(_)) + matches!(self, Self::EIP1559(_)) } /// Returns true whether this tx is a EIP2930 transaction pub fn is_eip2930(&self) -> bool { - matches!(self, TypedTransaction::EIP2930(_)) + matches!(self, Self::EIP2930(_)) } /// Returns true whether this tx is a EIP4844 transaction pub fn is_eip4844(&self) -> bool { - matches!(self, TypedTransaction::EIP4844(_)) + matches!(self, Self::EIP4844(_)) } /// Returns the hash of the transaction. @@ -823,11 +823,11 @@ impl TypedTransaction { /// hash. This allows us to treat impersonated transactions as unique. pub fn hash(&self) -> B256 { match self { - TypedTransaction::Legacy(t) => *t.hash(), - TypedTransaction::EIP2930(t) => *t.hash(), - TypedTransaction::EIP1559(t) => *t.hash(), - TypedTransaction::EIP4844(t) => *t.hash(), - TypedTransaction::Deposit(t) => t.hash(), + Self::Legacy(t) => *t.hash(), + Self::EIP2930(t) => *t.hash(), + Self::EIP1559(t) => *t.hash(), + Self::EIP4844(t) => *t.hash(), + Self::Deposit(t) => t.hash(), } } @@ -851,22 +851,22 @@ impl TypedTransaction { /// Recovers the Ethereum address which was used to sign the transaction. pub fn recover(&self) -> Result { match self { - TypedTransaction::Legacy(tx) => tx.recover_signer(), - TypedTransaction::EIP2930(tx) => tx.recover_signer(), - TypedTransaction::EIP1559(tx) => tx.recover_signer(), - TypedTransaction::EIP4844(tx) => tx.recover_signer(), - TypedTransaction::Deposit(tx) => tx.recover(), + Self::Legacy(tx) => tx.recover_signer(), + Self::EIP2930(tx) => tx.recover_signer(), + Self::EIP1559(tx) => tx.recover_signer(), + Self::EIP4844(tx) => tx.recover_signer(), + Self::Deposit(tx) => tx.recover(), } } /// Returns what kind of transaction this is pub fn kind(&self) -> TxKind { match self { - TypedTransaction::Legacy(tx) => tx.tx().to, - TypedTransaction::EIP2930(tx) => tx.tx().to, - TypedTransaction::EIP1559(tx) => tx.tx().to, - TypedTransaction::EIP4844(tx) => TxKind::Call(tx.tx().tx().to), - TypedTransaction::Deposit(tx) => tx.kind, + Self::Legacy(tx) => tx.tx().to, + Self::EIP2930(tx) => tx.tx().to, + Self::EIP1559(tx) => tx.tx().to, + Self::EIP4844(tx) => TxKind::Call(tx.tx().tx().to), + Self::Deposit(tx) => tx.kind, } } @@ -878,11 +878,11 @@ impl TypedTransaction { /// Returns the Signature of the transaction pub fn signature(&self) -> Signature { match self { - TypedTransaction::Legacy(tx) => *tx.signature(), - TypedTransaction::EIP2930(tx) => *tx.signature(), - TypedTransaction::EIP1559(tx) => *tx.signature(), - TypedTransaction::EIP4844(tx) => *tx.signature(), - TypedTransaction::Deposit(_) => Signature::from_scalars_and_parity( + Self::Legacy(tx) => *tx.signature(), + Self::EIP2930(tx) => *tx.signature(), + Self::EIP1559(tx) => *tx.signature(), + Self::EIP4844(tx) => *tx.signature(), + Self::Deposit(_) => Signature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), false, @@ -895,11 +895,11 @@ impl TypedTransaction { impl Encodable for TypedTransaction { fn encode(&self, out: &mut dyn bytes::BufMut) { match self { - TypedTransaction::Legacy(tx) => TxEnvelope::from(tx.clone()).encode(out), - TypedTransaction::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode(out), - TypedTransaction::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode(out), - TypedTransaction::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode(out), - TypedTransaction::Deposit(tx) => { + Self::Legacy(tx) => TxEnvelope::from(tx.clone()).encode(out), + Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode(out), + Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode(out), + Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode(out), + Self::Deposit(tx) => { let tx_payload_len = tx.fields_len(); let tx_header_len = Header { list: false, payload_length: tx_payload_len }.length(); Header { list: false, payload_length: 1 + tx_payload_len + tx_header_len } @@ -939,21 +939,21 @@ impl Encodable2718 for TypedTransaction { fn encode_2718_len(&self) -> usize { match self { - TypedTransaction::Legacy(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), - TypedTransaction::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), - TypedTransaction::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), - TypedTransaction::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), - TypedTransaction::Deposit(tx) => 1 + tx.length(), + Self::Legacy(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + Self::Deposit(tx) => 1 + tx.length(), } } fn encode_2718(&self, out: &mut dyn BufMut) { match self { - TypedTransaction::Legacy(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), - TypedTransaction::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), - TypedTransaction::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), - TypedTransaction::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), - TypedTransaction::Deposit(tx) => { + Self::Legacy(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + Self::Deposit(tx) => { out.put_u8(0x7E); tx.encode(out); } @@ -985,10 +985,10 @@ impl Decodable2718 for TypedTransaction { impl From for TypedTransaction { fn from(value: TxEnvelope) -> Self { match value { - TxEnvelope::Legacy(tx) => TypedTransaction::Legacy(tx), - TxEnvelope::Eip2930(tx) => TypedTransaction::EIP2930(tx), - TxEnvelope::Eip1559(tx) => TypedTransaction::EIP1559(tx), - TxEnvelope::Eip4844(tx) => TypedTransaction::EIP4844(tx), + TxEnvelope::Legacy(tx) => Self::Legacy(tx), + TxEnvelope::Eip2930(tx) => Self::EIP2930(tx), + TxEnvelope::Eip1559(tx) => Self::EIP1559(tx), + TxEnvelope::Eip4844(tx) => Self::EIP4844(tx), _ => unreachable!(), } } @@ -1139,11 +1139,8 @@ pub enum TypedReceipt { impl TypedReceipt { pub fn as_receipt_with_bloom(&self) -> &ReceiptWithBloom { match self { - TypedReceipt::Legacy(r) | - TypedReceipt::EIP1559(r) | - TypedReceipt::EIP2930(r) | - TypedReceipt::EIP4844(r) => r, - TypedReceipt::Deposit(r) => &r.inner, + Self::Legacy(r) | Self::EIP1559(r) | Self::EIP2930(r) | Self::EIP4844(r) => r, + Self::Deposit(r) => &r.inner, } } } @@ -1165,10 +1162,10 @@ impl TypedReceipt { impl From> for TypedReceipt { fn from(value: ReceiptEnvelope) -> Self { match value { - ReceiptEnvelope::Legacy(r) => TypedReceipt::Legacy(r), - ReceiptEnvelope::Eip2930(r) => TypedReceipt::EIP2930(r), - ReceiptEnvelope::Eip1559(r) => TypedReceipt::EIP1559(r), - ReceiptEnvelope::Eip4844(r) => TypedReceipt::EIP4844(r), + ReceiptEnvelope::Legacy(r) => Self::Legacy(r), + ReceiptEnvelope::Eip2930(r) => Self::EIP2930(r), + ReceiptEnvelope::Eip1559(r) => Self::EIP1559(r), + ReceiptEnvelope::Eip4844(r) => Self::EIP4844(r), _ => unreachable!(), } } @@ -1177,33 +1174,33 @@ impl From> for TypedReceipt r.encode(out), + Self::Legacy(r) => r.encode(out), receipt => { let payload_len = match receipt { - TypedReceipt::EIP2930(r) => r.length() + 1, - TypedReceipt::EIP1559(r) => r.length() + 1, - TypedReceipt::EIP4844(r) => r.length() + 1, - TypedReceipt::Deposit(r) => r.length() + 1, + Self::EIP2930(r) => r.length() + 1, + Self::EIP1559(r) => r.length() + 1, + Self::EIP4844(r) => r.length() + 1, + Self::Deposit(r) => r.length() + 1, _ => unreachable!("receipt already matched"), }; match receipt { - TypedReceipt::EIP2930(r) => { + Self::EIP2930(r) => { Header { list: true, payload_length: payload_len }.encode(out); 1u8.encode(out); r.encode(out); } - TypedReceipt::EIP1559(r) => { + Self::EIP1559(r) => { Header { list: true, payload_length: payload_len }.encode(out); 2u8.encode(out); r.encode(out); } - TypedReceipt::EIP4844(r) => { + Self::EIP4844(r) => { Header { list: true, payload_length: payload_len }.encode(out); 3u8.encode(out); r.encode(out); } - TypedReceipt::Deposit(r) => { + Self::Deposit(r) => { Header { list: true, payload_length: payload_len }.encode(out); 0x7Eu8.encode(out); r.encode(out); diff --git a/crates/anvil/core/src/lib.rs b/crates/anvil/core/src/lib.rs index a09e7cd684321..5d51d4691da7c 100644 --- a/crates/anvil/core/src/lib.rs +++ b/crates/anvil/core/src/lib.rs @@ -1,3 +1,10 @@ +//! # anvil-core +//! +//! Core Ethereum types for Anvil. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + /// Various Ethereum types pub mod eth; diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 87209606f5b61..79a6c7a2c4d52 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -40,12 +40,11 @@ impl<'de> serde::Deserialize<'de> for Forking { } let f = match ForkingVariants::deserialize(deserializer)? { ForkingVariants::Fork(ForkOpts { json_rpc_url, block_number }) => { - Forking { json_rpc_url, block_number } + Self { json_rpc_url, block_number } + } + ForkingVariants::Tagged(f) => { + Self { json_rpc_url: f.forking.json_rpc_url, block_number: f.forking.block_number } } - ForkingVariants::Tagged(f) => Forking { - json_rpc_url: f.forking.json_rpc_url, - block_number: f.forking.block_number, - }, }; Ok(f) } @@ -70,7 +69,7 @@ pub enum EvmMineOptions { impl Default for EvmMineOptions { fn default() -> Self { - EvmMineOptions::Options { timestamp: None, blocks: None } + Self::Options { timestamp: None, blocks: None } } } @@ -110,7 +109,7 @@ impl From for usize { #[cfg(feature = "serde")] impl<'a> serde::Deserialize<'a> for Index { - fn deserialize(deserializer: D) -> Result + fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'a>, { diff --git a/crates/anvil/rpc/Cargo.toml b/crates/anvil/rpc/Cargo.toml index 6d4e76540fbe6..46a148ea42627 100644 --- a/crates/anvil/rpc/Cargo.toml +++ b/crates/anvil/rpc/Cargo.toml @@ -9,9 +9,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] serde.workspace = true serde_json.workspace = true - -[dev-dependencies] -rand = "0.8" diff --git a/crates/anvil/rpc/src/error.rs b/crates/anvil/rpc/src/error.rs index b1929818fa8c6..0836b8a27469e 100644 --- a/crates/anvil/rpc/src/error.rs +++ b/crates/anvil/rpc/src/error.rs @@ -16,7 +16,7 @@ pub struct RpcError { impl RpcError { /// New [Error] with the given [ErrorCode] pub const fn new(code: ErrorCode) -> Self { - RpcError { message: Cow::Borrowed(code.message()), code, data: None } + Self { message: Cow::Borrowed(code.message()), code, data: None } } /// Creates a new `ParseError` @@ -44,7 +44,7 @@ impl RpcError { where M: Into, { - RpcError { code: ErrorCode::InvalidParams, message: message.into().into(), data: None } + Self { code: ErrorCode::InvalidParams, message: message.into().into(), data: None } } /// Creates a new `InternalError` with a message @@ -52,7 +52,7 @@ impl RpcError { where M: Into, { - RpcError { code: ErrorCode::InternalError, message: message.into().into(), data: None } + Self { code: ErrorCode::InternalError, message: message.into().into(), data: None } } /// Creates a new rpc error for when a transaction was rejected @@ -60,11 +60,7 @@ impl RpcError { where M: Into, { - RpcError { - code: ErrorCode::TransactionRejected, - message: message.into().into(), - data: None, - } + Self { code: ErrorCode::TransactionRejected, message: message.into().into(), data: None } } } @@ -100,28 +96,28 @@ impl ErrorCode { /// Returns the error code as `i64` pub fn code(&self) -> i64 { match *self { - ErrorCode::ParseError => -32700, - ErrorCode::InvalidRequest => -32600, - ErrorCode::MethodNotFound => -32601, - ErrorCode::InvalidParams => -32602, - ErrorCode::InternalError => -32603, - ErrorCode::TransactionRejected => -32003, - ErrorCode::ExecutionError => 3, - ErrorCode::ServerError(c) => c, + Self::ParseError => -32700, + Self::InvalidRequest => -32600, + Self::MethodNotFound => -32601, + Self::InvalidParams => -32602, + Self::InternalError => -32603, + Self::TransactionRejected => -32003, + Self::ExecutionError => 3, + Self::ServerError(c) => c, } } /// Returns the message associated with the error pub const fn message(&self) -> &'static str { match *self { - ErrorCode::ParseError => "Parse error", - ErrorCode::InvalidRequest => "Invalid request", - ErrorCode::MethodNotFound => "Method not found", - ErrorCode::InvalidParams => "Invalid params", - ErrorCode::InternalError => "Internal error", - ErrorCode::TransactionRejected => "Transaction rejected", - ErrorCode::ServerError(_) => "Server error", - ErrorCode::ExecutionError => "Execution error", + Self::ParseError => "Parse error", + Self::InvalidRequest => "Invalid request", + Self::MethodNotFound => "Method not found", + Self::InvalidParams => "Invalid params", + Self::InternalError => "Internal error", + Self::TransactionRejected => "Transaction rejected", + Self::ServerError(_) => "Server error", + Self::ExecutionError => "Execution error", } } } @@ -136,7 +132,7 @@ impl Serialize for ErrorCode { } impl<'a> Deserialize<'a> for ErrorCode { - fn deserialize(deserializer: D) -> Result + fn deserialize(deserializer: D) -> Result where D: Deserializer<'a>, { @@ -147,14 +143,14 @@ impl<'a> Deserialize<'a> for ErrorCode { impl From for ErrorCode { fn from(code: i64) -> Self { match code { - -32700 => ErrorCode::ParseError, - -32600 => ErrorCode::InvalidRequest, - -32601 => ErrorCode::MethodNotFound, - -32602 => ErrorCode::InvalidParams, - -32603 => ErrorCode::InternalError, - -32003 => ErrorCode::TransactionRejected, - 3 => ErrorCode::ExecutionError, - _ => ErrorCode::ServerError(code), + -32700 => Self::ParseError, + -32600 => Self::InvalidRequest, + -32601 => Self::MethodNotFound, + -32602 => Self::InvalidParams, + -32603 => Self::InternalError, + -32003 => Self::TransactionRejected, + 3 => Self::ExecutionError, + _ => Self::ServerError(code), } } } diff --git a/crates/anvil/rpc/src/lib.rs b/crates/anvil/rpc/src/lib.rs index 939fbff1690b1..bd5382cee17ad 100644 --- a/crates/anvil/rpc/src/lib.rs +++ b/crates/anvil/rpc/src/lib.rs @@ -1,3 +1,10 @@ +//! # anvil-rpc +//! +//! JSON-RPC types. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + /// JSON-RPC request bindings pub mod request; diff --git a/crates/anvil/rpc/src/request.rs b/crates/anvil/rpc/src/request.rs index 8630f4a4c1f5a..5cb8510b80f2b 100644 --- a/crates/anvil/rpc/src/request.rs +++ b/crates/anvil/rpc/src/request.rs @@ -77,7 +77,7 @@ pub enum RequestParams { impl From for serde_json::Value { fn from(params: RequestParams) -> Self { match params { - RequestParams::None => serde_json::Value::Null, + RequestParams::None => Self::Null, RequestParams::Array(arr) => arr.into(), RequestParams::Object(obj) => obj.into(), } @@ -106,9 +106,9 @@ pub enum Id { impl fmt::Display for Id { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Id::String(s) => s.fmt(f), - Id::Number(n) => n.fmt(f), - Id::Null => f.write_str("null"), + Self::String(s) => s.fmt(f), + Self::Number(n) => n.fmt(f), + Self::Null => f.write_str("null"), } } } diff --git a/crates/anvil/rpc/src/response.rs b/crates/anvil/rpc/src/response.rs index c7649dbe351a8..49ad70d0dfd28 100644 --- a/crates/anvil/rpc/src/response.rs +++ b/crates/anvil/rpc/src/response.rs @@ -24,7 +24,7 @@ impl From for RpcResponse { impl RpcResponse { pub fn new(id: Id, content: impl Into) -> Self { - RpcResponse { jsonrpc: Version::V2, id: Some(id), result: content.into() } + Self { jsonrpc: Version::V2, id: Some(id), result: content.into() } } pub fn invalid_request(id: Id) -> Self { @@ -47,17 +47,17 @@ impl ResponseResult { where S: Serialize + 'static, { - ResponseResult::Success(serde_json::to_value(&content).unwrap()) + Self::Success(serde_json::to_value(&content).unwrap()) } pub fn error(error: RpcError) -> Self { - ResponseResult::Error(error) + Self::Error(error) } } impl From for ResponseResult { fn from(err: RpcError) -> Self { - ResponseResult::error(err) + Self::error(err) } } /// Synchronous response @@ -80,12 +80,12 @@ impl Response { impl From for Response { fn from(err: RpcError) -> Self { - Response::error(err) + Self::error(err) } } impl From for Response { fn from(resp: RpcResponse) -> Self { - Response::Single(resp) + Self::Single(resp) } } diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index 250bf2787a7de..051da35c7887e 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] anvil-rpc = { path = "../rpc" } diff --git a/crates/anvil/server/src/config.rs b/crates/anvil/server/src/config.rs index 29b0e88121e0d..ea97d24cd7674 100644 --- a/crates/anvil/server/src/config.rs +++ b/crates/anvil/server/src/config.rs @@ -52,7 +52,7 @@ impl FromStr for HeaderValueWrapper { type Err = ::Err; fn from_str(s: &str) -> Result { - Ok(HeaderValueWrapper(s.parse()?)) + Ok(Self(s.parse()?)) } } @@ -91,6 +91,6 @@ impl From for HeaderValue { impl From for HeaderValueWrapper { fn from(header: HeaderValue) -> Self { - HeaderValueWrapper(header) + Self(header) } } diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index a1ca67af85b84..ddcf5a21f7502 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -34,7 +34,7 @@ impl IpcEndpoint { /// connections, See [`PubSubConnection`] that should be spawned #[instrument(target = "ipc", skip_all)] pub fn incoming(self) -> io::Result>> { - let IpcEndpoint { handler, path } = self; + let Self { handler, path } = self; trace!(%path, "starting IPC server"); diff --git a/crates/anvil/server/src/lib.rs b/crates/anvil/server/src/lib.rs index 5bd81b043e8ea..b60182505933e 100644 --- a/crates/anvil/server/src/lib.rs +++ b/crates/anvil/server/src/lib.rs @@ -1,6 +1,7 @@ //! Bootstrap [axum] RPC servers. -#![warn(missing_docs, unused_crate_dependencies)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index f36b200130d25..5febf290575d5 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -596,7 +596,7 @@ impl Future for PeriodicStateDumper { if this.interval.poll_tick(cx).is_ready() { let api = this.api.clone(); let path = this.dump_state.clone().expect("exists; see above"); - this.in_progress_dump = Some(Box::pin(PeriodicStateDumper::dump_state(api, path))); + this.in_progress_dump = Some(Box::pin(Self::dump_state(api, path))); } else { break } @@ -663,17 +663,17 @@ impl FromStr for ForkUrl { fn from_str(s: &str) -> Result { if let Some((url, block)) = s.rsplit_once('@') { if block == "latest" { - return Ok(ForkUrl { url: url.to_string(), block: None }) + return Ok(Self { url: url.to_string(), block: None }) } // this will prevent false positives for auths `user:password@example.com` if !block.is_empty() && !block.contains(':') && !block.contains('.') { let block: u64 = block .parse() .map_err(|_| format!("Failed to parse block number: `{block}`"))?; - return Ok(ForkUrl { url: url.to_string(), block: Some(block) }) + return Ok(Self { url: url.to_string(), block: Some(block) }) } } - Ok(ForkUrl { url: s.to_string(), block: None }) + Ok(Self { url: s.to_string(), block: None }) } } diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 7ee7d5e342eb8..24a354267e47a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1043,7 +1043,7 @@ latest block number: {latest_block}" // the block, and the block number is less than equal the latest block, then // the user is forking from a non-archive node with an older block number. if fork_block_number <= latest_block { - message.push_str(&format!("\n{}", NON_ARCHIVE_NODE_WARNING)); + message.push_str(&format!("\n{NON_ARCHIVE_NODE_WARNING}")); } panic!("{}", message); } diff --git a/crates/anvil/src/eth/backend/mem/cache.rs b/crates/anvil/src/eth/backend/mem/cache.rs index d4aff594878d0..e51aaae7e1ae9 100644 --- a/crates/anvil/src/eth/backend/mem/cache.rs +++ b/crates/anvil/src/eth/backend/mem/cache.rs @@ -102,7 +102,7 @@ impl DiskStateCache { impl Default for DiskStateCache { fn default() -> Self { - DiskStateCache { temp_path: anvil_tmp_dir(), temp_dir: None } + Self { temp_path: anvil_tmp_dir(), temp_dir: None } } } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 4a1a429f0cea1..2049c9f902c96 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -94,7 +94,7 @@ impl Db for MemDb { } fn current_state(&self) -> StateDb { - StateDb::new(MemDb { inner: self.inner.clone(), ..Default::default() }) + StateDb::new(Self { inner: self.inner.clone(), ..Default::default() }) } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index c705ec3760008..335d1620e7a49 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -115,8 +115,8 @@ pub enum BlockRequest { impl BlockRequest { pub fn block_number(&self) -> BlockNumber { match *self { - BlockRequest::Pending(_) => BlockNumber::Pending, - BlockRequest::Number(n) => BlockNumber::Number(n), + Self::Pending(_) => BlockNumber::Pending, + Self::Number(n) => BlockNumber::Number(n), } } } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 1f97addb4954f..46365739e40af 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -250,7 +250,7 @@ impl BlockchainStorage { } pub fn forked(block_number: u64, block_hash: B256, total_difficulty: U256) -> Self { - BlockchainStorage { + Self { blocks: Default::default(), hashes: HashMap::from([(U64::from(block_number), block_hash)]), best_hash: block_hash, diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index 5cad24f2bc49b..0822baa047168 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -26,8 +26,8 @@ pub struct TimeManager { } impl TimeManager { - pub fn new(start_timestamp: u64) -> TimeManager { - let time_manager = TimeManager { + pub fn new(start_timestamp: u64) -> Self { + let time_manager = Self { last_timestamp: Default::default(), offset: Default::default(), next_exact_timestamp: Default::default(), diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 417ec77a06c53..f7818585dd832 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -95,23 +95,23 @@ pub enum BlockchainError { impl From for BlockchainError { fn from(err: RpcError) -> Self { - BlockchainError::RpcError(err) + Self::RpcError(err) } } impl From> for BlockchainError where - T: Into, + T: Into, { fn from(err: EVMError) -> Self { match err { EVMError::Transaction(err) => InvalidTransactionError::from(err).into(), EVMError::Header(err) => match err { - InvalidHeader::ExcessBlobGasNotSet => BlockchainError::ExcessBlobGasNotSet, - InvalidHeader::PrevrandaoNotSet => BlockchainError::PrevrandaoNotSet, + InvalidHeader::ExcessBlobGasNotSet => Self::ExcessBlobGasNotSet, + InvalidHeader::PrevrandaoNotSet => Self::PrevrandaoNotSet, }, EVMError::Database(err) => err.into(), - EVMError::Custom(err) => BlockchainError::Message(err), + EVMError::Custom(err) => Self::Message(err), } } } @@ -234,58 +234,32 @@ impl From for InvalidTransactionError { fn from(err: revm::primitives::InvalidTransaction) -> Self { use revm::primitives::InvalidTransaction; match err { - InvalidTransaction::InvalidChainId => InvalidTransactionError::InvalidChainId, - InvalidTransaction::PriorityFeeGreaterThanMaxFee => { - InvalidTransactionError::TipAboveFeeCap - } - InvalidTransaction::GasPriceLessThanBasefee => InvalidTransactionError::FeeCapTooLow, + InvalidTransaction::InvalidChainId => Self::InvalidChainId, + InvalidTransaction::PriorityFeeGreaterThanMaxFee => Self::TipAboveFeeCap, + InvalidTransaction::GasPriceLessThanBasefee => Self::FeeCapTooLow, InvalidTransaction::CallerGasLimitMoreThanBlock => { - InvalidTransactionError::GasTooHigh(ErrDetail { - detail: String::from("CallerGasLimitMoreThanBlock"), - }) + Self::GasTooHigh(ErrDetail { detail: String::from("CallerGasLimitMoreThanBlock") }) } InvalidTransaction::CallGasCostMoreThanGasLimit => { - InvalidTransactionError::GasTooHigh(ErrDetail { - detail: String::from("CallGasCostMoreThanGasLimit"), - }) - } - InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA, - InvalidTransaction::LackOfFundForMaxFee { .. } => { - InvalidTransactionError::InsufficientFunds - } - InvalidTransaction::OverflowPaymentInTransaction => { - InvalidTransactionError::GasUintOverflow - } - InvalidTransaction::NonceOverflowInTransaction => { - InvalidTransactionError::NonceMaxValue - } - InvalidTransaction::CreateInitCodeSizeLimit => { - InvalidTransactionError::MaxInitCodeSizeExceeded - } - InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh, - InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow, - InvalidTransaction::AccessListNotSupported => { - InvalidTransactionError::AccessListNotSupported - } - InvalidTransaction::BlobGasPriceGreaterThanMax => { - InvalidTransactionError::BlobFeeCapTooLow + Self::GasTooHigh(ErrDetail { detail: String::from("CallGasCostMoreThanGasLimit") }) } + InvalidTransaction::RejectCallerWithCode => Self::SenderNoEOA, + InvalidTransaction::LackOfFundForMaxFee { .. } => Self::InsufficientFunds, + InvalidTransaction::OverflowPaymentInTransaction => Self::GasUintOverflow, + InvalidTransaction::NonceOverflowInTransaction => Self::NonceMaxValue, + InvalidTransaction::CreateInitCodeSizeLimit => Self::MaxInitCodeSizeExceeded, + InvalidTransaction::NonceTooHigh { .. } => Self::NonceTooHigh, + InvalidTransaction::NonceTooLow { .. } => Self::NonceTooLow, + InvalidTransaction::AccessListNotSupported => Self::AccessListNotSupported, + InvalidTransaction::BlobGasPriceGreaterThanMax => Self::BlobFeeCapTooLow, InvalidTransaction::BlobVersionedHashesNotSupported => { - InvalidTransactionError::BlobVersionedHashesNotSupported - } - InvalidTransaction::MaxFeePerBlobGasNotSupported => { - InvalidTransactionError::MaxFeePerBlobGasNotSupported - } - InvalidTransaction::BlobCreateTransaction => { - InvalidTransactionError::BlobCreateTransaction - } - InvalidTransaction::BlobVersionNotSupported => { - InvalidTransactionError::BlobVersionNotSupported - } - InvalidTransaction::EmptyBlobs => InvalidTransactionError::EmptyBlobs, - InvalidTransaction::TooManyBlobs { max, have } => { - InvalidTransactionError::TooManyBlobs(max, have) + Self::BlobVersionedHashesNotSupported } + InvalidTransaction::MaxFeePerBlobGasNotSupported => Self::MaxFeePerBlobGasNotSupported, + InvalidTransaction::BlobCreateTransaction => Self::BlobCreateTransaction, + InvalidTransaction::BlobVersionNotSupported => Self::BlobVersionNotSupported, + InvalidTransaction::EmptyBlobs => Self::EmptyBlobs, + InvalidTransaction::TooManyBlobs { max, have } => Self::TooManyBlobs(max, have), _ => todo!(), } } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 8c0104a1b84e2..922f149e3e665 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -387,12 +387,8 @@ impl FeeDetails { /// If neither `gas_price` nor `max_fee_per_gas` is `Some`, this will set both to `0` pub fn or_zero_fees(self) -> Self { - let FeeDetails { - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - max_fee_per_blob_gas, - } = self; + let Self { gas_price, max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas } = + self; let no_fees = gas_price.is_none() && max_fee_per_gas.is_none(); let gas_price = if no_fees { Some(0) } else { gas_price }; @@ -415,11 +411,11 @@ impl FeeDetails { request_max_fee: Option, request_priority: Option, max_fee_per_blob_gas: Option, - ) -> Result { + ) -> Result { match (request_gas_price, request_max_fee, request_priority, max_fee_per_blob_gas) { (gas_price, None, None, None) => { // Legacy request, all default to gas price. - Ok(FeeDetails { + Ok(Self { gas_price, max_fee_per_gas: gas_price, max_priority_fee_per_gas: gas_price, @@ -435,7 +431,7 @@ impl FeeDetails { return Err(BlockchainError::InvalidFeeInput) } } - Ok(FeeDetails { + Ok(Self { gas_price: max_fee, max_fee_per_gas: max_fee, max_priority_fee_per_gas: max_priority, @@ -451,7 +447,7 @@ impl FeeDetails { return Err(BlockchainError::InvalidFeeInput) } } - Ok(FeeDetails { + Ok(Self { gas_price: max_fee, max_fee_per_gas: max_fee, max_priority_fee_per_gas: max_priority, diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index 442c6fe7bbe31..b559351fe3bf0 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -110,7 +110,7 @@ pub enum MiningMode { impl MiningMode { pub fn instant(max_transactions: usize, listener: Receiver) -> Self { - MiningMode::Auto(ReadyTransactionMiner { + Self::Auto(ReadyTransactionMiner { max_transactions, has_pending_txs: None, rx: listener.fuse(), @@ -118,7 +118,7 @@ impl MiningMode { } pub fn interval(duration: Duration) -> Self { - MiningMode::FixedBlockTime(FixedBlockTimeMiner::new(duration)) + Self::FixedBlockTime(FixedBlockTimeMiner::new(duration)) } /// polls the [Pool] and returns those transactions that should be put in a block, if any. @@ -128,9 +128,9 @@ impl MiningMode { cx: &mut Context<'_>, ) -> Poll>> { match self { - MiningMode::None => Poll::Pending, - MiningMode::Auto(miner) => miner.poll(pool, cx), - MiningMode::FixedBlockTime(miner) => miner.poll(pool, cx), + Self::None => Poll::Pending, + Self::Auto(miner) => miner.poll(pool, cx), + Self::FixedBlockTime(miner) => miner.poll(pool, cx), } } } diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index fc0104066e020..7f85762575369 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -286,7 +286,7 @@ impl OtsSearchTransactions { impl OtsInternalOperation { /// Converts a batch of traces into a batch of internal operations, to comply with the spec for /// [`ots_getInternalOperations`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getinternaloperations) - pub fn batch_build(traces: MinedTransaction) -> Vec { + pub fn batch_build(traces: MinedTransaction) -> Vec { traces .info .traces @@ -322,7 +322,7 @@ impl OtsTrace { .filter_map(|trace| match trace.trace.action { Action::Call(call) => { if let Ok(ots_type) = call.call_type.try_into() { - Some(OtsTrace { + Some(Self { r#type: ots_type, depth: trace.trace.trace_address.len(), from: call.from, @@ -346,9 +346,9 @@ impl TryFrom for OtsTraceType { fn try_from(value: CallType) -> std::result::Result { match value { - CallType::Call => Ok(OtsTraceType::Call), - CallType::StaticCall => Ok(OtsTraceType::StaticCall), - CallType::DelegateCall => Ok(OtsTraceType::DelegateCall), + CallType::Call => Ok(Self::Call), + CallType::StaticCall => Ok(Self::StaticCall), + CallType::DelegateCall => Ok(Self::DelegateCall), _ => Err(()), } } diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index c94fafaca5780..9ef45ace2c2cc 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -464,8 +464,8 @@ pub enum AddedTransaction { impl AddedTransaction { pub fn hash(&self) -> &TxHash { match self { - AddedTransaction::Ready(tx) => &tx.hash, - AddedTransaction::Pending { hash } => hash, + Self::Ready(tx) => &tx.hash, + Self::Pending { hash } => hash, } } } diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 23841b0d7700b..7a1e8e8ab3a8a 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -41,8 +41,8 @@ impl TransactionOrder { /// Returns the priority of the transactions pub fn priority(&self, tx: &TypedTransaction) -> TransactionPriority { match self { - TransactionOrder::Fifo => TransactionPriority::default(), - TransactionOrder::Fees => TransactionPriority(tx.gas_price()), + Self::Fifo => TransactionPriority::default(), + Self::Fees => TransactionPriority(tx.gas_price()), } } } @@ -53,8 +53,8 @@ impl FromStr for TransactionOrder { fn from_str(s: &str) -> Result { let s = s.to_lowercase(); let order = match s.as_str() { - "fees" => TransactionOrder::Fees, - "fifo" => TransactionOrder::Fifo, + "fees" => Self::Fees, + "fifo" => Self::Fifo, _ => return Err(format!("Unknown TransactionOrder: `{s}`")), }; Ok(order) diff --git a/crates/anvil/src/filter.rs b/crates/anvil/src/filter.rs index b1d2370f5da2b..2144ce27c9882 100644 --- a/crates/anvil/src/filter.rs +++ b/crates/anvil/src/filter.rs @@ -127,15 +127,15 @@ impl Stream for EthFilter { fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let pin = self.get_mut(); match pin { - EthFilter::Logs(logs) => Poll::Ready(Some(Ok(logs.poll(cx)).to_rpc_result())), - EthFilter::Blocks(blocks) => { + Self::Logs(logs) => Poll::Ready(Some(Ok(logs.poll(cx)).to_rpc_result())), + Self::Blocks(blocks) => { let mut new_blocks = Vec::new(); while let Poll::Ready(Some(block)) = blocks.poll_next_unpin(cx) { new_blocks.push(block.hash); } Poll::Ready(Some(Ok(new_blocks).to_rpc_result())) } - EthFilter::PendingTransactions(tx) => { + Self::PendingTransactions(tx) => { let mut new_txs = Vec::new(); while let Poll::Ready(Some(tx_hash)) = tx.poll_next_unpin(cx) { new_txs.push(tx_hash); diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index 7d95f13e7aaa6..3c6eb0aa8c212 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -29,22 +29,22 @@ impl Hardfork { /// Get the first block number of the hardfork. pub fn fork_block(&self) -> u64 { match *self { - Hardfork::Frontier => 0, - Hardfork::Homestead => 1150000, - Hardfork::Dao => 1920000, - Hardfork::Tangerine => 2463000, - Hardfork::SpuriousDragon => 2675000, - Hardfork::Byzantium => 4370000, - Hardfork::Constantinople | Hardfork::Petersburg => 7280000, - Hardfork::Istanbul => 9069000, - Hardfork::Muirglacier => 9200000, - Hardfork::Berlin => 12244000, - Hardfork::London => 12965000, - Hardfork::ArrowGlacier => 13773000, - Hardfork::GrayGlacier => 15050000, - Hardfork::Paris => 15537394, - Hardfork::Shanghai => 17034870, - Hardfork::Cancun | Hardfork::Latest => 19426587, + Self::Frontier => 0, + Self::Homestead => 1150000, + Self::Dao => 1920000, + Self::Tangerine => 2463000, + Self::SpuriousDragon => 2675000, + Self::Byzantium => 4370000, + Self::Constantinople | Self::Petersburg => 7280000, + Self::Istanbul => 9069000, + Self::Muirglacier => 9200000, + Self::Berlin => 12244000, + Self::London => 12965000, + Self::ArrowGlacier => 13773000, + Self::GrayGlacier => 15050000, + Self::Paris => 15537394, + Self::Shanghai => 17034870, + Self::Cancun | Self::Latest => 19426587, } } } @@ -55,24 +55,24 @@ impl FromStr for Hardfork { fn from_str(s: &str) -> Result { let s = s.to_lowercase(); let hardfork = match s.as_str() { - "frontier" | "1" => Hardfork::Frontier, - "homestead" | "2" => Hardfork::Homestead, - "dao" | "3" => Hardfork::Dao, - "tangerine" | "4" => Hardfork::Tangerine, - "spuriousdragon" | "5" => Hardfork::SpuriousDragon, - "byzantium" | "6" => Hardfork::Byzantium, - "constantinople" | "7" => Hardfork::Constantinople, - "petersburg" | "8" => Hardfork::Petersburg, - "istanbul" | "9" => Hardfork::Istanbul, - "muirglacier" | "10" => Hardfork::Muirglacier, - "berlin" | "11" => Hardfork::Berlin, - "london" | "12" => Hardfork::London, - "arrowglacier" | "13" => Hardfork::ArrowGlacier, - "grayglacier" | "14" => Hardfork::GrayGlacier, - "paris" | "merge" | "15" => Hardfork::Paris, - "shanghai" | "16" => Hardfork::Shanghai, - "cancun" | "17" => Hardfork::Cancun, - "latest" => Hardfork::Latest, + "frontier" | "1" => Self::Frontier, + "homestead" | "2" => Self::Homestead, + "dao" | "3" => Self::Dao, + "tangerine" | "4" => Self::Tangerine, + "spuriousdragon" | "5" => Self::SpuriousDragon, + "byzantium" | "6" => Self::Byzantium, + "constantinople" | "7" => Self::Constantinople, + "petersburg" | "8" => Self::Petersburg, + "istanbul" | "9" => Self::Istanbul, + "muirglacier" | "10" => Self::Muirglacier, + "berlin" | "11" => Self::Berlin, + "london" | "12" => Self::London, + "arrowglacier" | "13" => Self::ArrowGlacier, + "grayglacier" | "14" => Self::GrayGlacier, + "paris" | "merge" | "15" => Self::Paris, + "shanghai" | "16" => Self::Shanghai, + "cancun" | "17" => Self::Cancun, + "latest" => Self::Latest, _ => return Err(format!("Unknown hardfork {s}")), }; Ok(hardfork) @@ -82,23 +82,23 @@ impl FromStr for Hardfork { impl From for SpecId { fn from(fork: Hardfork) -> Self { match fork { - Hardfork::Frontier => SpecId::FRONTIER, - Hardfork::Homestead => SpecId::HOMESTEAD, - Hardfork::Dao => SpecId::HOMESTEAD, - Hardfork::Tangerine => SpecId::TANGERINE, - Hardfork::SpuriousDragon => SpecId::SPURIOUS_DRAGON, - Hardfork::Byzantium => SpecId::BYZANTIUM, - Hardfork::Constantinople => SpecId::CONSTANTINOPLE, - Hardfork::Petersburg => SpecId::PETERSBURG, - Hardfork::Istanbul => SpecId::ISTANBUL, - Hardfork::Muirglacier => SpecId::MUIR_GLACIER, - Hardfork::Berlin => SpecId::BERLIN, - Hardfork::London => SpecId::LONDON, - Hardfork::ArrowGlacier => SpecId::LONDON, - Hardfork::GrayGlacier => SpecId::GRAY_GLACIER, - Hardfork::Paris => SpecId::MERGE, - Hardfork::Shanghai => SpecId::SHANGHAI, - Hardfork::Cancun | Hardfork::Latest => SpecId::CANCUN, + Hardfork::Frontier => Self::FRONTIER, + Hardfork::Homestead => Self::HOMESTEAD, + Hardfork::Dao => Self::HOMESTEAD, + Hardfork::Tangerine => Self::TANGERINE, + Hardfork::SpuriousDragon => Self::SPURIOUS_DRAGON, + Hardfork::Byzantium => Self::BYZANTIUM, + Hardfork::Constantinople => Self::CONSTANTINOPLE, + Hardfork::Petersburg => Self::PETERSBURG, + Hardfork::Istanbul => Self::ISTANBUL, + Hardfork::Muirglacier => Self::MUIR_GLACIER, + Hardfork::Berlin => Self::BERLIN, + Hardfork::London => Self::LONDON, + Hardfork::ArrowGlacier => Self::LONDON, + Hardfork::GrayGlacier => Self::GRAY_GLACIER, + Hardfork::Paris => Self::MERGE, + Hardfork::Shanghai => Self::SHANGHAI, + Hardfork::Cancun | Hardfork::Latest => Self::CANCUN, } } } @@ -112,21 +112,21 @@ impl> From for Hardfork { }; match num { - _i if num < 1_150_000 => Hardfork::Frontier, - _i if num < 1_920_000 => Hardfork::Dao, - _i if num < 2_463_000 => Hardfork::Homestead, - _i if num < 2_675_000 => Hardfork::Tangerine, - _i if num < 4_370_000 => Hardfork::SpuriousDragon, - _i if num < 7_280_000 => Hardfork::Byzantium, - _i if num < 9_069_000 => Hardfork::Constantinople, - _i if num < 9_200_000 => Hardfork::Istanbul, - _i if num < 12_244_000 => Hardfork::Muirglacier, - _i if num < 12_965_000 => Hardfork::Berlin, - _i if num < 13_773_000 => Hardfork::London, - _i if num < 15_050_000 => Hardfork::ArrowGlacier, - _i if num < 17_034_870 => Hardfork::Paris, - _i if num < 19_426_587 => Hardfork::Shanghai, - _ => Hardfork::Latest, + _i if num < 1_150_000 => Self::Frontier, + _i if num < 1_920_000 => Self::Dao, + _i if num < 2_463_000 => Self::Homestead, + _i if num < 2_675_000 => Self::Tangerine, + _i if num < 4_370_000 => Self::SpuriousDragon, + _i if num < 7_280_000 => Self::Byzantium, + _i if num < 9_069_000 => Self::Constantinople, + _i if num < 9_200_000 => Self::Istanbul, + _i if num < 12_244_000 => Self::Muirglacier, + _i if num < 12_965_000 => Self::Berlin, + _i if num < 13_773_000 => Self::London, + _i if num < 15_050_000 => Self::ArrowGlacier, + _i if num < 17_034_870 => Self::Paris, + _i if num < 19_426_587 => Self::Shanghai, + _ => Self::Latest, } } } diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 8fbb130f23d8f..da08b0a4a32f3 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -1,3 +1,6 @@ +#![doc = include_str!("../README.md")] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + #[macro_use] extern crate tracing; @@ -272,7 +275,7 @@ impl NodeHandle { self.config.print(fork); if !self.config.silent { if let Some(ipc_path) = self.ipc_path() { - println!("IPC path: {}", ipc_path); + println!("IPC path: {ipc_path}"); } println!( "Listening on {}", diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index 46caa9d7cadae..21a5c631c9c0c 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -91,8 +91,8 @@ pub enum EthSubscription { impl EthSubscription { fn poll_response(&mut self, cx: &mut Context<'_>) -> Poll> { match self { - EthSubscription::Logs(listener) => listener.poll(cx), - EthSubscription::Header(blocks, storage, id) => { + Self::Logs(listener) => listener.poll(cx), + Self::Header(blocks, storage, id) => { // this loop ensures we poll the receiver until it is pending, in which case the // underlying `UnboundedReceiver` will register the new waker, see // [`futures::channel::mpsc::UnboundedReceiver::poll_next()`] @@ -110,7 +110,7 @@ impl EthSubscription { } } } - EthSubscription::PendingTransactions(tx, id) => { + Self::PendingTransactions(tx, id) => { let res = ready!(tx.poll_next_unpin(cx)) .map(SubscriptionResult::TransactionHash) .map(to_rpc_result) diff --git a/crates/anvil/src/service.rs b/crates/anvil/src/service.rs index 6759f68121ca3..6f8624d9431c6 100644 --- a/crates/anvil/src/service.rs +++ b/crates/anvil/src/service.rs @@ -151,7 +151,7 @@ impl Stream for BlockProducer { Poll::Ready(Some(outcome)) } Err(err) => { - panic!("miner task failed: {}", err); + panic!("miner task failed: {err}"); } } } else { diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index b8ef827a79210..c693381c6f97a 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -1076,8 +1076,7 @@ async fn test_estimate_gas() { let error_message = error_result.unwrap_err().to_string(); assert!( error_message.contains("Insufficient funds for gas * price + value"), - "Error message did not match expected: {}", - error_message + "Error message did not match expected: {error_message}" ); // Setup state override to simulate sufficient funds for the recipient. diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 443e5992c5372..421bd6d4d7b48 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [[bin]] name = "cast" path = "bin/main.rs" diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 0ec110bae4ba1..2a672bffd6779 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -49,7 +49,7 @@ pub struct AccessListArgs { impl AccessListArgs { pub async fn run(self) -> Result<()> { - let AccessListArgs { to, sig, args, tx, eth, block, json: to_json } = self; + let Self { to, sig, args, tx, eth, block, json: to_json } = self; let config = Config::from(ð); let provider = utils::get_provider(&config)?; @@ -73,7 +73,7 @@ impl AccessListArgs { let access_list: String = cast.access_list(&tx, block, to_json).await?; - println!("{}", access_list); + println!("{access_list}"); Ok(()) } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 3b4e8da361857..afd6108c679fb 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -95,7 +95,7 @@ pub enum CallSubcommands { impl CallArgs { pub async fn run(self) -> Result<()> { - let CallArgs { + let Self { to, mut sig, mut args, diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index dae91c6422911..8c3b12dad78e3 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -81,7 +81,7 @@ pub struct Create2Output { impl Create2Args { pub fn run(self) -> Result { - let Create2Args { + let Self { starts_with, ends_with, matching, diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 5e60c979661a9..c48ce2d430302 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -67,7 +67,7 @@ pub enum EstimateSubcommands { impl EstimateArgs { pub async fn run(self) -> Result<()> { - let EstimateArgs { to, mut sig, mut args, mut tx, block, eth, command } = self; + let Self { to, mut sig, mut args, mut tx, block, eth, command } = self; let config = Config::from(ð); let provider = utils::get_provider(&config)?; diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index f75f2c82f2634..e598a21217787 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -18,7 +18,7 @@ pub struct FindBlockArgs { impl FindBlockArgs { pub async fn run(self) -> Result<()> { - let FindBlockArgs { timestamp, rpc } = self; + let Self { timestamp, rpc } = self; let ts_target = timestamp; let config = Config::from(&rpc); diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 14de351f202b7..59956b78ef1e4 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -44,14 +44,7 @@ pub struct InterfaceArgs { impl InterfaceArgs { pub async fn run(self) -> Result<()> { - let InterfaceArgs { - path_or_address, - name, - pragma, - output: output_location, - etherscan, - json, - } = self; + let Self { path_or_address, name, pragma, output: output_location, etherscan, json } = self; let source = if Path::new(&path_or_address).exists() { AbiPath::Local { path: path_or_address, name } } else { diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 85f0c8414d67d..3c538f21034c7 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -60,7 +60,7 @@ pub struct LogsArgs { impl LogsArgs { pub async fn run(self) -> Result<()> { - let LogsArgs { + let Self { from_block, to_block, address, @@ -91,7 +91,7 @@ impl LogsArgs { if !subscribe { let logs = cast.filter_logs(filter, json).await?; - println!("{}", logs); + println!("{logs}"); return Ok(()) } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index 999688b19c004..cd0fdfecd0a7a 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -54,7 +54,7 @@ pub enum MakeTxSubcommands { impl MakeTxArgs { pub async fn run(self) -> Result<()> { - let MakeTxArgs { to, mut sig, mut args, command, tx, eth } = self; + let Self { to, mut sig, mut args, command, tx, eth } = self; let code = if let Some(MakeTxSubcommands::Create { code, diff --git a/crates/cast/bin/cmd/rpc.rs b/crates/cast/bin/cmd/rpc.rs index 9dffcfd18de53..cae5d3386a68f 100644 --- a/crates/cast/bin/cmd/rpc.rs +++ b/crates/cast/bin/cmd/rpc.rs @@ -35,7 +35,7 @@ pub struct RpcArgs { impl RpcArgs { pub async fn run(self) -> Result<()> { - let RpcArgs { raw, method, params, rpc } = self; + let Self { raw, method, params, rpc } = self; let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 0f3ca609d66cc..d9ba45726e544 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -98,7 +98,7 @@ impl RunArgs { let tx = provider .get_transaction_by_hash(tx_hash) .await - .wrap_err_with(|| format!("tx not found: {:?}", tx_hash))? + .wrap_err_with(|| format!("tx not found: {tx_hash:?}"))? .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; // check if the tx is a system transaction diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index ea9cfcdcd282c..d4aee145bb4cb 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -78,7 +78,7 @@ pub enum SendTxSubcommands { impl SendTxArgs { pub async fn run(self) -> Result<()> { - let SendTxArgs { + let Self { eth, to, mut sig, diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 3068af08364ce..b312e4a606fb3 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -172,7 +172,7 @@ pub enum WalletSubcommands { impl WalletSubcommands { pub async fn run(self) -> Result<()> { match self { - WalletSubcommands::New { path, unsafe_password, number, json, .. } => { + Self::New { path, unsafe_password, number, json, .. } => { let mut rng = thread_rng(); let mut json_values = if json { Some(vec![]) } else { None }; @@ -240,7 +240,7 @@ impl WalletSubcommands { } } } - WalletSubcommands::NewMnemonic { words, accounts } => { + Self::NewMnemonic { words, accounts } => { let mut rng = thread_rng(); let phrase = Mnemonic::::new_with_count(&mut rng, words)?.to_phrase(); @@ -261,10 +261,10 @@ impl WalletSubcommands { println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); } } - WalletSubcommands::Vanity(cmd) => { + Self::Vanity(cmd) => { cmd.run()?; } - WalletSubcommands::Address { wallet, private_key_override } => { + Self::Address { wallet, private_key_override } => { let wallet = private_key_override .map(|pk| WalletOpts { raw: RawWalletOpts { private_key: Some(pk), ..Default::default() }, @@ -276,7 +276,7 @@ impl WalletSubcommands { let addr = wallet.address(); println!("{}", addr.to_checksum(None)); } - WalletSubcommands::Sign { message, data, from_file, no_hash, wallet } => { + Self::Sign { message, data, from_file, no_hash, wallet } => { let wallet = wallet.signer().await?; let sig = if data { let typed_data: TypedData = if from_file { @@ -294,7 +294,7 @@ impl WalletSubcommands { }; println!("0x{}", hex::encode(sig.as_bytes())); } - WalletSubcommands::Verify { message, signature, address } => { + Self::Verify { message, signature, address } => { let recovered_address = Self::recover_address_from_message(&message, &signature)?; if address == recovered_address { println!("Validation succeeded. Address {address} signed this message."); @@ -302,12 +302,7 @@ impl WalletSubcommands { println!("Validation failed. Address {address} did not sign this message."); } } - WalletSubcommands::Import { - account_name, - keystore_dir, - unsafe_password, - raw_wallet_options, - } => { + Self::Import { account_name, keystore_dir, unsafe_password, raw_wallet_options } => { // Set up keystore directory let dir = if let Some(path) = keystore_dir { Path::new(&path).to_path_buf() @@ -365,10 +360,10 @@ flag to set your key via: ); println!("{}", success_message.green()); } - WalletSubcommands::List(cmd) => { + Self::List(cmd) => { cmd.run().await?; } - WalletSubcommands::DerivePrivateKey { mnemonic, mnemonic_index } => { + Self::DerivePrivateKey { mnemonic, mnemonic_index } => { let phrase = Mnemonic::::new_from_phrase(mnemonic.as_str())?.to_phrase(); let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); let derivation_path = "m/44'/60'/0'/0/"; @@ -381,7 +376,7 @@ flag to set your key via: println!("Address: {}", wallet.address()); println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); } - WalletSubcommands::DecryptKeystore { account_name, keystore_dir, unsafe_password } => { + Self::DecryptKeystore { account_name, keystore_dir, unsafe_password } => { // Set up keystore directory let dir = if let Some(path) = keystore_dir { Path::new(&path).to_path_buf() diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 28ada95b11cb4..5bab0e318823e 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -64,7 +64,7 @@ struct Wallets { impl WalletData { pub fn new(wallet: &LocalWallet) -> Self { - WalletData { + Self { address: wallet.address().to_checksum(None), private_key: format!("0x{}", hex::encode(wallet.signer().to_bytes())), } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 0af23e2001547..7baf543312040 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -309,7 +309,7 @@ async fn main() -> Result<()> { { let resolved = match func_names { Some(v) => v.join("|"), - None => "".to_string(), + None => String::new(), }; println!("{selector}\t{arguments:max_args_len$}\t{resolved}"); } diff --git a/crates/cast/src/base.rs b/crates/cast/src/base.rs index 44f58091e4193..63ae59c1cbffb 100644 --- a/crates/cast/src/base.rs +++ b/crates/cast/src/base.rs @@ -90,7 +90,7 @@ impl TryFrom for Base { impl From for u32 { fn from(b: Base) -> Self { - b as u32 + b as Self } } @@ -293,7 +293,7 @@ impl From for NumberWithBase { impl From for I256 { fn from(n: NumberWithBase) -> Self { - I256::from_raw(n.number) + Self::from_raw(n.number) } } diff --git a/crates/cast/src/errors.rs b/crates/cast/src/errors.rs index 40a8e9755b112..3e6c5977bfa4c 100644 --- a/crates/cast/src/errors.rs +++ b/crates/cast/src/errors.rs @@ -15,18 +15,18 @@ pub enum FunctionSignatureError { impl fmt::Display for FunctionSignatureError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - FunctionSignatureError::MissingSignature => { + Self::MissingSignature => { writeln!(f, "Function signature must be set") } - FunctionSignatureError::MissingEtherscan { sig } => { + Self::MissingEtherscan { sig } => { writeln!(f, "Failed to determine function signature for `{sig}`")?; writeln!(f, "To lookup a function signature of a deployed contract by name, a valid ETHERSCAN_API_KEY must be set.")?; write!(f, "\tOr did you mean:\t {sig}()") } - FunctionSignatureError::UnknownChain(chain) => { + Self::UnknownChain(chain) => { write!(f, "Resolving via etherscan requires a known chain. Unknown chain: {chain}") } - FunctionSignatureError::MissingToAddress => f.write_str("Target address must be set"), + Self::MissingToAddress => f.write_str("Target address must be set"), } } } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index c83fe9aa1a6bc..70e8523ecc5dc 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1,3 +1,6 @@ +#![doc = include_str!("../README.md")] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use alloy_consensus::TxEnvelope; use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; use alloy_json_abi::{ContractObject, Function}; @@ -288,7 +291,7 @@ where pub async fn publish( &self, mut raw_tx: String, - ) -> Result> { + ) -> Result> { raw_tx = match raw_tx.strip_prefix("0x") { Some(s) => s.to_string(), None => raw_tx, @@ -348,7 +351,7 @@ where async fn block_field_as_num>(&self, block: B, field: String) -> Result { let block = block.into(); - let block_field = Cast::block( + let block_field = Self::block( self, block, false, @@ -367,22 +370,22 @@ where } pub async fn base_fee>(&self, block: B) -> Result { - Cast::block_field_as_num(self, block, String::from("baseFeePerGas")).await + Self::block_field_as_num(self, block, String::from("baseFeePerGas")).await } pub async fn age>(&self, block: B) -> Result { let timestamp_str = - Cast::block_field_as_num(self, block, String::from("timestamp")).await?.to_string(); + Self::block_field_as_num(self, block, String::from("timestamp")).await?.to_string(); let datetime = DateTime::from_timestamp(timestamp_str.parse::().unwrap(), 0).unwrap(); Ok(datetime.format("%a %b %e %H:%M:%S %Y").to_string()) } pub async fn timestamp>(&self, block: B) -> Result { - Cast::block_field_as_num(self, block, "timestamp".to_string()).await + Self::block_field_as_num(self, block, "timestamp".to_string()).await } pub async fn chain(&self) -> Result<&str> { - let genesis_hash = Cast::block( + let genesis_hash = Self::block( self, 0, false, @@ -394,7 +397,7 @@ where Ok(match &genesis_hash[..] { "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" => { - match &(Cast::block(self, 1920000, false, Some("hash".to_string()), false).await?)[..] + match &(Self::block(self, 1920000, false, Some("hash".to_string()), false).await?)[..] { "0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f" => { "etclive" @@ -433,7 +436,7 @@ where "0x6d3c66c5357ec91d5c43af47e234a939b22557cbb552dc45bebbceeed90fbe34" => "bsctest", "0x0d21840abff46b96c84b2ac9e10e4f5cdaeb5693cb665db62a2f3b02d2d57b5b" => "bsc", "0x31ced5b9beb7f8782b014660da0cb18cc409f121f408186886e1ca3e8eeca96b" => { - match &(Cast::block(self, 1, false, Some(String::from("hash")), false).await?)[..] { + match &(Self::block(self, 1, false, Some(String::from("hash")), false).await?)[..] { "0x738639479dc82d199365626f90caa82f7eafcfe9ed354b456fb3d294597ceb53" => { "avalanche-fuji" } @@ -931,12 +934,12 @@ where } first = false; let log_str = serde_json::to_string(&log).unwrap(); - write!(output, "{}", log_str)?; + write!(output, "{log_str}")?; } else { let log_str = log.pretty() .replacen('\n', "- ", 1) // Remove empty first line .replace('\n', "\n "); // Indent - writeln!(output, "{}", log_str)?; + writeln!(output, "{log_str}")?; } }, // Break on cancel signal, to allow for closing JSON bracket @@ -1959,7 +1962,7 @@ impl SimpleCast { let mut nonce = nonce_start; while nonce < u32::MAX && !found.load(Ordering::Relaxed) { - let input = format!("{}{}({}", name, nonce, params); + let input = format!("{name}{nonce}({params}"); let hash = keccak256(input.as_bytes()); let selector = &hash[..4]; diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index d0e94301ee658..d0d60c08290c6 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -14,8 +14,8 @@ pub enum Item { impl Encodable for Item { fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { match self { - Item::Array(arr) => arr.encode(out), - Item::Data(data) => <[u8]>::encode(data, out), + Self::Array(arr) => arr.encode(out), + Self::Data(data) => <[u8]>::encode(data, out), } } } @@ -31,11 +31,11 @@ impl Decodable for Item { let view = &mut d; let mut v = Vec::new(); while !view.is_empty() { - v.push(Item::decode(view)?); + v.push(Self::decode(view)?); } - Ok(Item::Array(v)) + Ok(Self::Array(v)) } else { - Ok(Item::Data(d.to_vec())) + Ok(Self::Data(d.to_vec())) }; buf.advance(h.payload_length); r @@ -43,16 +43,16 @@ impl Decodable for Item { } impl Item { - pub(crate) fn value_to_item(value: &Value) -> eyre::Result { + pub(crate) fn value_to_item(value: &Value) -> eyre::Result { return match value { - Value::Null => Ok(Item::Data(vec![])), + Value::Null => Ok(Self::Data(vec![])), Value::Bool(_) => { eyre::bail!("RLP input should not contain booleans") } // If a value is passed without quotes we cast it to string - Value::Number(n) => Ok(Item::value_to_item(&Value::String(n.to_string()))?), - Value::String(s) => Ok(Item::Data(hex::decode(s).expect("Could not decode hex"))), - Value::Array(values) => values.iter().map(Item::value_to_item).collect(), + Value::Number(n) => Ok(Self::value_to_item(&Value::String(n.to_string()))?), + Value::String(s) => Ok(Self::Data(hex::decode(s).expect("Could not decode hex"))), + Value::Array(values) => values.iter().map(Self::value_to_item).collect(), Value::Object(_) => { eyre::bail!("RLP input can not contain objects") } @@ -60,9 +60,9 @@ impl Item { } } -impl FromIterator for Item { - fn from_iter>(iter: T) -> Self { - Item::Array(Vec::from_iter(iter)) +impl FromIterator for Item { + fn from_iter>(iter: T) -> Self { + Self::Array(Vec::from_iter(iter)) } } @@ -70,10 +70,10 @@ impl FromIterator for Item { impl fmt::Display for Item { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result { match self { - Item::Data(dat) => { + Self::Data(dat) => { write!(f, "\"0x{}\"", hex::encode(dat))?; } - Item::Array(items) => { + Self::Array(items) => { f.write_str("[")?; for (i, item) in items.iter().enumerate() { if i > 0 { diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index f712b77665dd3..07474076595b4 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -11,6 +11,9 @@ homepage.workspace = true repository.workspace = true exclude.workspace = true +[lints] +workspace = true + [dependencies] foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true diff --git a/crates/cheatcodes/spec/Cargo.toml b/crates/cheatcodes/spec/Cargo.toml index ae4ca21e06ec2..738bb62b765f2 100644 --- a/crates/cheatcodes/spec/Cargo.toml +++ b/crates/cheatcodes/spec/Cargo.toml @@ -11,6 +11,9 @@ homepage.workspace = true repository.workspace = true exclude.workspace = true +[lints] +workspace = true + [dependencies] foundry-macros.workspace = true alloy-sol-types = { workspace = true, features = ["json"] } diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index b2a267f8d716a..37cf149cd3ade 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -1,5 +1,6 @@ #![doc = include_str!("../README.md")] -#![warn(missing_docs, unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use serde::{Deserialize, Serialize}; use std::{borrow::Cow, fmt}; diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index d1123b4484c2c..410039852ec77 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2159,23 +2159,21 @@ impl PartialEq for ForgeContext { // and script group case (any of dry run, broadcast or resume). fn eq(&self, other: &Self) -> bool { match (self, other) { - (_, &ForgeContext::TestGroup) => { - self == &ForgeContext::Test || - self == &ForgeContext::Snapshot || - self == &ForgeContext::Coverage + (_, &Self::TestGroup) => { + self == &Self::Test || self == &Self::Snapshot || self == &Self::Coverage } - (_, &ForgeContext::ScriptGroup) => { - self == &ForgeContext::ScriptDryRun || - self == &ForgeContext::ScriptBroadcast || - self == &ForgeContext::ScriptResume + (_, &Self::ScriptGroup) => { + self == &Self::ScriptDryRun || + self == &Self::ScriptBroadcast || + self == &Self::ScriptResume } - (&ForgeContext::Test, &ForgeContext::Test) | - (&ForgeContext::Snapshot, &ForgeContext::Snapshot) | - (&ForgeContext::Coverage, &ForgeContext::Coverage) | - (&ForgeContext::ScriptDryRun, &ForgeContext::ScriptDryRun) | - (&ForgeContext::ScriptBroadcast, &ForgeContext::ScriptBroadcast) | - (&ForgeContext::ScriptResume, &ForgeContext::ScriptResume) | - (&ForgeContext::Unknown, &ForgeContext::Unknown) => true, + (&Self::Test, &Self::Test) | + (&Self::Snapshot, &Self::Snapshot) | + (&Self::Coverage, &Self::Coverage) | + (&Self::ScriptDryRun, &Self::ScriptDryRun) | + (&Self::ScriptBroadcast, &Self::ScriptBroadcast) | + (&Self::ScriptResume, &Self::ScriptResume) | + (&Self::Unknown, &Self::Unknown) => true, _ => false, } } diff --git a/crates/cheatcodes/src/evm/prank.rs b/crates/cheatcodes/src/evm/prank.rs index 3e1452d4236db..4e4ef81f759f3 100644 --- a/crates/cheatcodes/src/evm/prank.rs +++ b/crates/cheatcodes/src/evm/prank.rs @@ -29,16 +29,8 @@ impl Prank { new_origin: Option
, depth: u64, single_call: bool, - ) -> Prank { - Prank { - prank_caller, - prank_origin, - new_caller, - new_origin, - depth, - single_call, - used: false, - } + ) -> Self { + Self { prank_caller, prank_origin, new_caller, new_origin, depth, single_call, used: false } } /// Apply the prank by setting `used` to true iff it is false @@ -47,7 +39,7 @@ impl Prank { if self.used { None } else { - Some(Prank { used: true, ..self.clone() }) + Some(Self { used: true, ..self.clone() }) } } } diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index e493078a3262d..6b7dd0e97557c 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -251,7 +251,7 @@ impl Cheatcode for serializeBytes_1Call { impl Cheatcode for serializeUintToHexCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - let hex = format!("0x{:x}", value); + let hex = format!("0x{value:x}"); serialize_json(state, objectKey, Some(valueKey), &hex) } } @@ -445,7 +445,7 @@ pub(super) fn json_value_to_token(value: &Value) -> Result { if let Some(mut val) = string.strip_prefix("0x") { let s; if val.len() % 2 != 0 { - s = format!("0{}", val); + s = format!("0{val}"); val = &s[..]; } let bytes = hex::decode(val)?; diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 01695fa707006..023ef877d7589 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -2,7 +2,8 @@ //! //! Foundry cheatcodes implementations. -#![warn(missing_docs, unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![allow(elided_lifetimes_in_paths)] // Cheats context uses 3 lifetimes #[macro_use] diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index 3c1ab22f3c859..c7dce14731069 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -925,7 +925,7 @@ impl Cheatcode for assertLeDecimal_3Call { impl Cheatcode for assertApproxEqAbs_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("assertion failed: {}", e))?) + .map_err(|e| format!("assertion failed: {e}"))?) } } @@ -939,7 +939,7 @@ impl Cheatcode for assertApproxEqAbs_1Call { impl Cheatcode for assertApproxEqAbs_2Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("assertion failed: {}", e))?) + .map_err(|e| format!("assertion failed: {e}"))?) } } @@ -981,7 +981,7 @@ impl Cheatcode for assertApproxEqAbsDecimal_3Call { impl Cheatcode for assertApproxEqRel_0Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("assertion failed: {}", e))?) + .map_err(|e| format!("assertion failed: {e}"))?) } } @@ -995,7 +995,7 @@ impl Cheatcode for assertApproxEqRel_1Call { impl Cheatcode for assertApproxEqRel_2Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("assertion failed: {}", e))?) + .map_err(|e| format!("assertion failed: {e}"))?) } } diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index f5e9b7b023fb1..f527deb2e1db9 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -13,6 +13,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [[bin]] name = "chisel" path = "bin/main.rs" diff --git a/crates/chisel/src/cmd.rs b/crates/chisel/src/cmd.rs index 99e4086b3311a..86925fc1be416 100644 --- a/crates/chisel/src/cmd.rs +++ b/crates/chisel/src/cmd.rs @@ -61,24 +61,24 @@ impl FromStr for ChiselCommand { fn from_str(s: &str) -> Result { match s.to_lowercase().as_ref() { - "help" | "h" => Ok(ChiselCommand::Help), - "quit" | "q" => Ok(ChiselCommand::Quit), - "clear" | "c" => Ok(ChiselCommand::Clear), - "source" | "so" => Ok(ChiselCommand::Source), - "save" | "s" => Ok(ChiselCommand::Save), - "list" | "ls" => Ok(ChiselCommand::ListSessions), - "load" | "l" => Ok(ChiselCommand::Load), - "clearcache" | "cc" => Ok(ChiselCommand::ClearCache), - "fork" | "f" => Ok(ChiselCommand::Fork), - "traces" | "t" => Ok(ChiselCommand::Traces), - "calldata" | "cd" => Ok(ChiselCommand::Calldata), - "memdump" | "md" => Ok(ChiselCommand::MemDump), - "stackdump" | "sd" => Ok(ChiselCommand::StackDump), - "export" | "ex" => Ok(ChiselCommand::Export), - "fetch" | "fe" => Ok(ChiselCommand::Fetch), - "exec" | "e" => Ok(ChiselCommand::Exec), - "rawstack" | "rs" => Ok(ChiselCommand::RawStack), - "edit" => Ok(ChiselCommand::Edit), + "help" | "h" => Ok(Self::Help), + "quit" | "q" => Ok(Self::Quit), + "clear" | "c" => Ok(Self::Clear), + "source" | "so" => Ok(Self::Source), + "save" | "s" => Ok(Self::Save), + "list" | "ls" => Ok(Self::ListSessions), + "load" | "l" => Ok(Self::Load), + "clearcache" | "cc" => Ok(Self::ClearCache), + "fork" | "f" => Ok(Self::Fork), + "traces" | "t" => Ok(Self::Traces), + "calldata" | "cd" => Ok(Self::Calldata), + "memdump" | "md" => Ok(Self::MemDump), + "stackdump" | "sd" => Ok(Self::StackDump), + "export" | "ex" => Ok(Self::Export), + "fetch" | "fe" => Ok(Self::Fetch), + "exec" | "e" => Ok(Self::Exec), + "rawstack" | "rs" => Ok(Self::RawStack), + "edit" => Ok(Self::Edit), _ => Err(ChiselDispatcher::make_error(format!( "Unknown command \"{s}\"! See available commands with `!help`.", )) @@ -103,10 +103,10 @@ pub enum CmdCategory { impl core::fmt::Display for CmdCategory { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let string = match self { - CmdCategory::General => "General", - CmdCategory::Session => "Session", - CmdCategory::Env => "Environment", - CmdCategory::Debug => "Debug", + Self::General => "General", + Self::Session => "Session", + Self::Env => "Environment", + Self::Debug => "Debug", }; f.write_str(string) } diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index e32b1ac013ea4..33520e308bd12 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -86,11 +86,11 @@ impl DispatchResult { pub fn is_error(&self) -> bool { matches!( self, - DispatchResult::Failure(_) | - DispatchResult::CommandFailed(_) | - DispatchResult::UnrecognizedCommand(_) | - DispatchResult::SolangParserFailed(_) | - DispatchResult::FileIoError(_) + Self::Failure(_) | + Self::CommandFailed(_) | + Self::UnrecognizedCommand(_) | + Self::SolangParserFailed(_) | + Self::FileIoError(_) ) } } @@ -414,8 +414,7 @@ impl ChiselDispatcher { ))) } Err(e) => DispatchResult::CommandFailed(Self::make_error(format!( - "Invalid calldata: {}", - e + "Invalid calldata: {e}" ))), } } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index eea595486dfa5..f9cce49942a7d 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -349,7 +349,7 @@ fn format_token(token: DynSolValue) -> String { DynSolValue::Int(i, bit_len) => { format!( "Type: {}\n├ Hex: {}\n├ Hex (full word): {}\n└ Decimal: {}", - format!("int{}", bit_len).red(), + format!("int{bit_len}").red(), format!( "0x{}", format!("{i:x}") @@ -367,7 +367,7 @@ fn format_token(token: DynSolValue) -> String { DynSolValue::Uint(i, bit_len) => { format!( "Type: {}\n├ Hex: {}\n├ Hex (full word): {}\n└ Decimal: {}", - format!("uint{}", bit_len).red(), + format!("uint{bit_len}").red(), format!( "0x{}", format!("{i:x}") @@ -755,7 +755,7 @@ impl Type { .map(|(returns, _)| map_parameters(returns)) .unwrap_or_default(); Self::Function( - Box::new(Type::Custom(vec!["__fn_type__".to_string()])), + Box::new(Self::Custom(vec!["__fn_type__".to_string()])), params, returns, ) @@ -900,7 +900,7 @@ impl Type { /// Recurses over itself, appending all the idents and function arguments in the order that they /// are found - fn recurse(&self, types: &mut Vec, args: &mut Option>>) { + fn recurse(&self, types: &mut Vec, args: &mut Option>>) { match self { Self::Builtin(ty) => types.push(ty.to_string()), Self::Custom(tys) => types.extend(tys.clone()), @@ -1167,7 +1167,7 @@ impl Type { .function_definitions .get(&function_name.name)?; let return_parameter = contract.as_ref().returns.first()?.to_owned().1?; - Type::ethabi(&return_parameter.ty, Some(intermediate)).map(|p| (contract_expr.unwrap(), p)) + Self::ethabi(&return_parameter.ty, Some(intermediate)).map(|p| (contract_expr.unwrap(), p)) } /// Inverts Int to Uint and viceversa. diff --git a/crates/chisel/src/lib.rs b/crates/chisel/src/lib.rs index 2004ed0c41c92..d0085c327d2d5 100644 --- a/crates/chisel/src/lib.rs +++ b/crates/chisel/src/lib.rs @@ -1,8 +1,5 @@ #![doc = include_str!("../README.md")] -#![warn(missing_docs)] -#![warn(unused_extern_crates)] -#![forbid(unsafe_code)] -#![forbid(where_clauses_object_safety)] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] /// REPL input dispatcher module pub mod dispatcher; diff --git a/crates/chisel/src/session.rs b/crates/chisel/src/session.rs index 3be34a179cc90..e0865e28a267a 100644 --- a/crates/chisel/src/session.rs +++ b/crates/chisel/src/session.rs @@ -205,9 +205,9 @@ impl ChiselSession { /// /// Optionally, an owned instance of the loaded chisel session. pub fn load(id: &str) -> Result { - let cache_dir = ChiselSession::cache_dir()?; + let cache_dir = Self::cache_dir()?; let contents = std::fs::read_to_string(Path::new(&format!("{cache_dir}chisel-{id}.json")))?; - let chisel_env: ChiselSession = serde_json::from_str(&contents)?; + let chisel_env: Self = serde_json::from_str(&contents)?; Ok(chisel_env) } @@ -241,7 +241,7 @@ impl ChiselSession { pub fn latest() -> Result { let last_session = Self::latest_cached_session()?; let last_session_contents = std::fs::read_to_string(Path::new(&last_session))?; - let chisel_env: ChiselSession = serde_json::from_str(&last_session_contents)?; + let chisel_env: Self = serde_json::from_str(&last_session_contents)?; Ok(chisel_env) } } diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 6882a63aa3e42..b8ba084cd62a2 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -225,7 +225,7 @@ impl SessionSource { /// /// Optionally, a shallow-cloned [SessionSource] with the passed content appended to the /// source code. - pub fn clone_with_new_line(&self, mut content: String) -> Result<(SessionSource, bool)> { + pub fn clone_with_new_line(&self, mut content: String) -> Result<(Self, bool)> { let new_source = self.shallow_clone(); if let Some(parsed) = parse_fragment(new_source.solc, new_source.config, &content) .or_else(|| { diff --git a/crates/chisel/src/solidity_helper.rs b/crates/chisel/src/solidity_helper.rs index f09ad168356e2..84140c820a542 100644 --- a/crates/chisel/src/solidity_helper.rs +++ b/crates/chisel/src/solidity_helper.rs @@ -101,7 +101,7 @@ impl SolidityHelper { } /// Highlights a solidity source string - pub fn highlight(input: &str) -> Cow { + pub fn highlight(input: &str) -> Cow<'_, str> { if !yansi::is_enabled() { return Cow::Borrowed(input) } @@ -256,7 +256,7 @@ impl Highlighter for SolidityHelper { } impl Validator for SolidityHelper { - fn validate(&self, ctx: &mut ValidationContext) -> rustyline::Result { + fn validate(&self, ctx: &mut ValidationContext<'_>) -> rustyline::Result { Ok(Self::validate_closed(ctx.input())) } } diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index 5575a814a22c6..7be980ec83073 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -45,7 +45,7 @@ fn test_write_session() { foundry_config, ..Default::default() }) - .unwrap_or_else(|e| panic!("Failed to create ChiselSession!, {}", e)); + .unwrap_or_else(|e| panic!("Failed to create ChiselSession!, {e}")); // Write the session let cached_session_name = env.write().unwrap(); @@ -73,7 +73,7 @@ fn test_write_session_with_name() { foundry_config, ..Default::default() }) - .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {}", e)); + .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {e}")); env.id = Some(String::from("test")); // Write the session @@ -123,7 +123,7 @@ fn test_list_sessions() { foundry_config, ..Default::default() }) - .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {}", e)); + .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {e}")); env.write().unwrap(); @@ -150,7 +150,7 @@ fn test_load_cache() { foundry_config, ..Default::default() }) - .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {}", e)); + .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {e}")); env.write().unwrap(); // Load the session @@ -178,7 +178,7 @@ fn test_write_same_session_multiple_times() { foundry_config, ..Default::default() }) - .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {}", e)); + .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {e}")); env.write().unwrap(); env.write().unwrap(); env.write().unwrap(); @@ -201,7 +201,7 @@ fn test_load_latest_cache() { foundry_config: foundry_config.clone(), ..Default::default() }) - .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {}", e)); + .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {e}")); env.write().unwrap(); let wait_time = std::time::Duration::from_millis(100); @@ -211,7 +211,7 @@ fn test_load_latest_cache() { foundry_config, ..Default::default() }) - .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {}", e)); + .unwrap_or_else(|e| panic!("Failed to create ChiselSession! {e}")); env2.write().unwrap(); // Load the latest session diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 8c4f353ddf818..7b66c7045c4a8 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] forge-fmt.workspace = true foundry-common.workspace = true diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index f0e90a96c58d5..6f5e2f6076932 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -1,4 +1,9 @@ -#![warn(unused_crate_dependencies)] +//! # foundry-cli +//! +//! Common CLI utilities. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 85575bccce573..a3143144dd328 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -172,7 +172,7 @@ impl<'a> From<&'a CoreBuildArgs> for Figment { impl<'a> From<&'a CoreBuildArgs> for Config { fn from(args: &'a CoreBuildArgs) -> Self { let figment: Figment = args.into(); - let mut config = Config::from_provider(figment).sanitized(); + let mut config = Self::from_provider(figment).sanitized(); // if `--config-path` is set we need to adjust the config's root path to the actual root // path for the project, otherwise it will the parent dir of the `--config-path` if args.project_paths.config_path.is_some() { diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index 5fa1d851f3cfc..945386d2b64a9 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -120,7 +120,7 @@ impl FromStr for Dependency { (None, None, None) }; - Ok(Dependency { name: name.or_else(|| alias.clone()).unwrap(), url, tag, alias }) + Ok(Self { name: name.or_else(|| alias.clone()).unwrap(), url, tag, alias }) } } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index b9020c0457afd..6c010655b8525 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -37,7 +37,7 @@ pub fn remove_contract( let contract = if let Some(contract) = output.remove(path.to_string_lossy(), name) { contract } else { - let mut err = format!("could not find artifact: `{}`", name); + let mut err = format!("could not find artifact: `{name}`"); if let Some(suggestion) = super::did_you_mean(name, output.artifacts().map(|(name, _)| name)).pop() { @@ -146,7 +146,7 @@ pub fn init_progress(len: u64, label: &str) -> indicatif::ProgressBar { let mut template = "{prefix}{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len} " .to_string(); - write!(template, "{}", label).unwrap(); + write!(template, "{label}").unwrap(); template += " ({eta})"; pb.set_style( indicatif::ProgressStyle::with_template(&template) diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index bdf0e34579685..5b11a1be90a0e 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-compilers.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 4b1cd78748baa..13fb79be06b9d 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -305,10 +305,10 @@ impl ContractSources { output: &ProjectCompileOutput, root: &Path, libraries: &Libraries, - ) -> Result { + ) -> Result { let linker = Linker::new(root, output.artifact_ids().collect()); - let mut sources = ContractSources::default(); + let mut sources = Self::default(); for (id, artifact) in output.artifact_ids() { if let Some(file_id) = artifact.id { let abs_path = root.join(&id.source); @@ -618,18 +618,18 @@ pub enum SkipBuildFilter { impl SkipBuildFilter { fn new(s: &str) -> Self { match s { - "test" | "tests" => SkipBuildFilter::Tests, - "script" | "scripts" => SkipBuildFilter::Scripts, - s => SkipBuildFilter::Custom(s.to_string()), + "test" | "tests" => Self::Tests, + "script" | "scripts" => Self::Scripts, + s => Self::Custom(s.to_string()), } } /// Returns the pattern to match against a file fn file_pattern(&self) -> &str { match self { - SkipBuildFilter::Tests => ".t.sol", - SkipBuildFilter::Scripts => ".s.sol", - SkipBuildFilter::Custom(s) => s.as_str(), + Self::Tests => ".t.sol", + Self::Scripts => ".s.sol", + Self::Custom(s) => s.as_str(), } } diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 3e6b2ce1030dd..046a074257d8d 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -117,7 +117,7 @@ impl ContractsByArtifact { } /// Finds a contract which has a similar bytecode as `code`. - pub fn find_by_creation_code(&self, code: &[u8]) -> Option { + pub fn find_by_creation_code(&self, code: &[u8]) -> Option> { self.iter().find(|(_, contract)| { if let Some(bytecode) = contract.bytecode() { bytecode_diff_score(bytecode.as_ref(), code) <= 0.1 @@ -128,7 +128,7 @@ impl ContractsByArtifact { } /// Finds a contract which has a similar deployed bytecode as `code`. - pub fn find_by_deployed_code(&self, code: &[u8]) -> Option { + pub fn find_by_deployed_code(&self, code: &[u8]) -> Option> { self.iter().find(|(_, contract)| { if let Some(deployed_bytecode) = contract.deployed_bytecode() { bytecode_diff_score(deployed_bytecode.as_ref(), code) <= 0.1 @@ -140,7 +140,7 @@ impl ContractsByArtifact { /// Finds a contract which deployed bytecode exactly matches the given code. Accounts for link /// references and immutables. - pub fn find_by_deployed_code_exact(&self, code: &[u8]) -> Option { + pub fn find_by_deployed_code_exact(&self, code: &[u8]) -> Option> { self.iter().find(|(_, contract)| { let Some(deployed_bytecode) = &contract.deployed_bytecode else { return false; @@ -233,7 +233,10 @@ impl ContractsByArtifact { /// Finds a contract which has the same contract name or identifier as `id`. If more than one is /// found, return error. - pub fn find_by_name_or_identifier(&self, id: &str) -> Result> { + pub fn find_by_name_or_identifier( + &self, + id: &str, + ) -> Result>> { let contracts = self .iter() .filter(|(artifact, _)| artifact.name == id || artifact.identifier() == id) diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index b96ecba8d8742..f84ea84cecab2 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -68,27 +68,27 @@ impl NameOrAddress { provider: &P, ) -> Result { match self { - NameOrAddress::Name(name) => provider.resolve_name(name).await, - NameOrAddress::Address(addr) => Ok(*addr), + Self::Name(name) => provider.resolve_name(name).await, + Self::Address(addr) => Ok(*addr), } } } impl From for NameOrAddress { fn from(name: String) -> Self { - NameOrAddress::Name(name) + Self::Name(name) } } impl From<&String> for NameOrAddress { fn from(name: &String) -> Self { - NameOrAddress::Name(name.clone()) + Self::Name(name.clone()) } } impl From
for NameOrAddress { fn from(addr: Address) -> Self { - NameOrAddress::Address(addr) + Self::Address(addr) } } @@ -97,9 +97,9 @@ impl FromStr for NameOrAddress { fn from_str(s: &str) -> Result { if let Ok(addr) = Address::from_str(s) { - Ok(NameOrAddress::Address(addr)) + Ok(Self::Address(addr)) } else { - Ok(NameOrAddress::Name(s.to_string())) + Ok(Self::Name(s.to_string())) } } } diff --git a/crates/common/src/errors/fs.rs b/crates/common/src/errors/fs.rs index b929e7838140e..1e466171e12c2 100644 --- a/crates/common/src/errors/fs.rs +++ b/crates/common/src/errors/fs.rs @@ -46,47 +46,47 @@ pub enum FsPathError { impl FsPathError { /// Returns the complementary error variant for [`std::fs::write`]. pub fn write(source: io::Error, path: impl Into) -> Self { - FsPathError::Write { source, path: path.into() } + Self::Write { source, path: path.into() } } /// Returns the complementary error variant for [`std::fs::read`]. pub fn read(source: io::Error, path: impl Into) -> Self { - FsPathError::Read { source, path: path.into() } + Self::Read { source, path: path.into() } } /// Returns the complementary error variant for [`std::fs::copy`]. pub fn copy(source: io::Error, from: impl Into, to: impl Into) -> Self { - FsPathError::Copy { source, from: from.into(), to: to.into() } + Self::Copy { source, from: from.into(), to: to.into() } } /// Returns the complementary error variant for [`std::fs::read_link`]. pub fn read_link(source: io::Error, path: impl Into) -> Self { - FsPathError::ReadLink { source, path: path.into() } + Self::ReadLink { source, path: path.into() } } /// Returns the complementary error variant for [`File::create`]. pub fn create_file(source: io::Error, path: impl Into) -> Self { - FsPathError::CreateFile { source, path: path.into() } + Self::CreateFile { source, path: path.into() } } /// Returns the complementary error variant for [`std::fs::remove_file`]. pub fn remove_file(source: io::Error, path: impl Into) -> Self { - FsPathError::RemoveFile { source, path: path.into() } + Self::RemoveFile { source, path: path.into() } } /// Returns the complementary error variant for [`std::fs::create_dir`]. pub fn create_dir(source: io::Error, path: impl Into) -> Self { - FsPathError::CreateDir { source, path: path.into() } + Self::CreateDir { source, path: path.into() } } /// Returns the complementary error variant for [`std::fs::remove_dir`]. pub fn remove_dir(source: io::Error, path: impl Into) -> Self { - FsPathError::RemoveDir { source, path: path.into() } + Self::RemoveDir { source, path: path.into() } } /// Returns the complementary error variant for [`File::open`]. pub fn open(source: io::Error, path: impl Into) -> Self { - FsPathError::Open { source, path: path.into() } + Self::Open { source, path: path.into() } } } diff --git a/crates/common/src/fmt/console.rs b/crates/common/src/fmt/console.rs index e4b33c5cd957c..efade2e436a6e 100644 --- a/crates/common/src/fmt/console.rs +++ b/crates/common/src/fmt/console.rs @@ -47,7 +47,7 @@ impl ConsoleFmt for String { FormatSpec::Number | FormatSpec::Integer | FormatSpec::Exponential | - FormatSpec::Hexadecimal => String::from("NaN"), + FormatSpec::Hexadecimal => Self::from("NaN"), } } } @@ -77,7 +77,7 @@ impl ConsoleFmt for U256 { } FormatSpec::Exponential => { let log = self.pretty().len() - 1; - let exp10 = U256::from(10).pow(U256::from(log)); + let exp10 = Self::from(10).pow(Self::from(log)); let amount = *self; let integer = amount / exp10; let decimal = (amount % exp10).to_string(); @@ -110,7 +110,7 @@ impl ConsoleFmt for I256 { } else { self.pretty().len() - 1 }; - let exp10 = I256::exp10(log); + let exp10 = Self::exp10(log); let integer = (amount / exp10).twos_complement(); let decimal = (amount % exp10).twos_complement().to_string(); let decimal = format!("{decimal:0>log$}").trim_end_matches('0').to_string(); diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 635d1434bd485..f2f647ae85949 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -223,7 +223,7 @@ blobGasUsed {}", // additional captured fields for (key, val) in other.iter() { - pretty.push_str(&format!("\n{} {}", key, val)); + pretty.push_str(&format!("\n{key} {val}")); } pretty @@ -271,9 +271,9 @@ transactions: {}", impl UIfmt for BlockTransactions { fn pretty(&self) -> String { match self { - BlockTransactions::Hashes(hashes) => hashes.pretty(), - BlockTransactions::Full(transactions) => transactions.pretty(), - BlockTransactions::Uncle => String::new(), + Self::Hashes(hashes) => hashes.pretty(), + Self::Full(transactions) => transactions.pretty(), + Self::Uncle => String::new(), } } } @@ -369,11 +369,11 @@ impl From for EthValue { impl UIfmt for EthValue { fn pretty(&self) -> String { match self { - EthValue::U64(num) => num.pretty(), - EthValue::U256(num) => num.pretty(), - EthValue::U64Array(arr) => arr.pretty(), - EthValue::U256Array(arr) => arr.pretty(), - EthValue::Other(val) => val.to_string().trim_matches('"').to_string(), + Self::U64(num) => num.pretty(), + Self::U256(num) => num.pretty(), + Self::U64Array(arr) => arr.pretty(), + Self::U256Array(arr) => arr.pretty(), + Self::Other(val) => val.to_string().trim_matches('"').to_string(), } } } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 2ffc066d6de53..fa1cecbbe85de 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -1,7 +1,11 @@ +//! # foundry-common +//! //! Common utilities for building and using foundry's tools. -#![warn(missing_docs, unused_crate_dependencies)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[allow(unused_extern_crates)] // Used by `ConsoleFmt`. extern crate self as foundry_common; #[macro_use] diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index 1083052b5b59a..388a795dddd32 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -106,7 +106,7 @@ impl ProviderBuilder { .or_else(|err| match err { ParseError::RelativeUrlWithoutBase => { if SocketAddr::from_str(url_str).is_ok() { - Url::parse(&format!("http://{}", url_str)) + Url::parse(&format!("http://{url_str}")) } else { let path = Path::new(url_str); @@ -235,7 +235,7 @@ impl ProviderBuilder { /// Constructs the `RetryProvider` taking all configs into account. pub fn build(self) -> Result { - let ProviderBuilder { + let Self { url, chain: _, max_retry, @@ -270,7 +270,7 @@ impl ProviderBuilder { /// Constructs the `RetryProvider` with a signer pub fn build_with_signer(self, signer: EthereumSigner) -> Result { - let ProviderBuilder { + let Self { url, chain: _, max_retry, diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 38a24e81b00e2..72c4dadc9aba7 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -1,5 +1,6 @@ //! Runtime transport that connects on first request, which can take either of an HTTP, //! WebSocket, or IPC transport and supports retries based on CUPS logic. + use crate::REQUEST_TIMEOUT; use alloy_json_rpc::{RequestPacket, ResponsePacket}; use alloy_pubsub::{PubSubConnect, PubSubFrontend}; @@ -11,7 +12,7 @@ use alloy_transport_http::Http; use alloy_transport_ipc::IpcConnect; use alloy_transport_ws::WsConnect; use reqwest::header::{HeaderName, HeaderValue}; -use std::{path::PathBuf, str::FromStr, sync::Arc}; +use std::{fmt, path::PathBuf, str::FromStr, sync::Arc}; use thiserror::Error; use tokio::sync::RwLock; use tower::Service; @@ -125,8 +126,8 @@ impl RuntimeTransportBuilder { } } -impl ::core::fmt::Display for RuntimeTransport { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl fmt::Display for RuntimeTransport { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "RuntimeTransport {}", self.url) } } diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 2537b2c0cdecd..bf820a4125b2c 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -369,7 +369,7 @@ pub struct PossibleSigs { impl PossibleSigs { fn new() -> Self { - PossibleSigs { method: SelectorOrSig::Selector("0x00000000".to_string()), data: vec![] } + Self { method: SelectorOrSig::Selector("0x00000000".to_string()), data: vec![] } } } @@ -634,7 +634,7 @@ mod tests { let abi: JsonAbi = serde_json::from_str(r#"[{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function", "methodIdentifiers": {"transfer(address,uint256)(uint256)": "0xa9059cbb"}}]"#).unwrap(); let result = import_selectors(SelectorImportData::Abi(vec![abi])).await; - println!("{:?}", result); + println!("{result:?}"); assert_eq!( result.unwrap().result.function.duplicated.get("transfer(address,uint256)").unwrap(), "0xa9059cbb" diff --git a/crates/common/src/serde_helpers.rs b/crates/common/src/serde_helpers.rs index c1b61b6e24241..776d049c4a946 100644 --- a/crates/common/src/serde_helpers.rs +++ b/crates/common/src/serde_helpers.rs @@ -15,10 +15,10 @@ pub enum Numeric { } impl From for U256 { - fn from(n: Numeric) -> U256 { + fn from(n: Numeric) -> Self { match n { Numeric::U256(n) => n, - Numeric::Num(n) => U256::from(n), + Numeric::Num(n) => Self::from(n), } } } @@ -28,7 +28,7 @@ impl FromStr for Numeric { fn from_str(s: &str) -> Result { if let Ok(val) = s.parse::() { - Ok(Numeric::U256(U256::from(val))) + Ok(Self::U256(U256::from(val))) } else if s.starts_with("0x") { U256::from_str_radix(s, 16).map(Numeric::U256).map_err(|err| err.to_string()) } else { @@ -63,10 +63,8 @@ impl NumberOrHexU256 { /// Tries to convert this into a [U256]]. pub fn try_into_u256(self) -> Result { match self { - NumberOrHexU256::Int(num) => { - U256::from_str(num.to_string().as_str()).map_err(E::custom) - } - NumberOrHexU256::Hex(val) => Ok(val), + Self::Int(num) => U256::from_str(num.to_string().as_str()).map_err(E::custom), + Self::Hex(val) => Ok(val), } } } diff --git a/crates/common/src/shell.rs b/crates/common/src/shell.rs index 89d9905364732..ac5ff1b969056 100644 --- a/crates/common/src/shell.rs +++ b/crates/common/src/shell.rs @@ -213,18 +213,18 @@ impl ShellOut { pub fn memory() -> Self { #[allow(clippy::box_default)] #[allow(clippy::arc_with_non_send_sync)] - ShellOut::Write(WriteShellOut(Arc::new(Mutex::new(Box::new(Vec::new()))))) + Self::Write(WriteShellOut(Arc::new(Mutex::new(Box::new(Vec::new()))))) } /// Write a fragment to stdout fn write_stdout(&self, fragment: impl fmt::Display) -> io::Result<()> { match *self { - ShellOut::Stream => { + Self::Stream => { let stdout = io::stdout(); let mut handle = stdout.lock(); writeln!(handle, "{fragment}")?; } - ShellOut::Write(ref w) => { + Self::Write(ref w) => { w.write(fragment)?; } } @@ -234,12 +234,12 @@ impl ShellOut { /// Write output to stderr fn write_stderr(&self, fragment: impl fmt::Display) -> io::Result<()> { match *self { - ShellOut::Stream => { + Self::Stream => { let stderr = io::stderr(); let mut handle = stderr.lock(); writeln!(handle, "{fragment}")?; } - ShellOut::Write(ref w) => { + Self::Write(ref w) => { w.write(fragment)?; } } @@ -252,12 +252,12 @@ impl ShellOut { for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R, { match *self { - ShellOut::Stream => { + Self::Stream => { let stdout = io::stdout(); let mut handler = stdout.lock(); f(&mut handler) } - ShellOut::Write(ref w) => w.with_stdout(f), + Self::Write(ref w) => w.with_stdout(f), } } @@ -268,12 +268,12 @@ impl ShellOut { for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R, { match *self { - ShellOut::Stream => { + Self::Stream => { let stderr = io::stderr(); let mut handler = stderr.lock(); f(&mut handler) } - ShellOut::Write(ref w) => w.with_err(f), + Self::Write(ref w) => w.with_err(f), } } } @@ -293,16 +293,16 @@ pub enum Verbosity { impl Verbosity { /// Returns true if json mode pub fn is_json(&self) -> bool { - matches!(self, Verbosity::Json) + matches!(self, Self::Json) } /// Returns true if silent pub fn is_silent(&self) -> bool { - matches!(self, Verbosity::Silent) + matches!(self, Self::Silent) } /// Returns true if normal verbosity pub fn is_normal(&self) -> bool { - matches!(self, Verbosity::Normal) + matches!(self, Self::Normal) } } diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 81aff615c6a08..4057a504fe2d3 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -34,8 +34,8 @@ pub struct TermSettings { impl TermSettings { /// Returns a new [`TermSettings`], configured from the current environment. - pub fn from_env() -> TermSettings { - TermSettings { indicate_progress: std::io::stdout().is_terminal() } + pub fn from_env() -> Self { + Self { indicate_progress: std::io::stdout().is_terminal() } } } @@ -55,7 +55,7 @@ impl Spinner { } pub fn with_indicator(indicator: &'static [&'static str], msg: impl Into) -> Self { - Spinner { + Self { indicator, no_progress: !TERM_SETTINGS.indicate_progress, message: msg.into(), @@ -125,7 +125,7 @@ impl SpinnerReporter { }) .expect("failed to spawn thread"); - SpinnerReporter { sender } + Self { sender } } fn send_msg(&self, msg: impl Into) { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index cc2cfc1b6d2db..6d64e36251079 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1,6 +1,9 @@ +//! # foundry-config +//! //! Foundry configuration. -#![warn(missing_docs, unused_crate_dependencies)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index bc3c746e3d859..812c6fdada920 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-common.workspace = true foundry-compilers.workspace = true diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 5683cb8a5b7c4..ed5da934271a2 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -2,7 +2,8 @@ //! //! Interactive Solidity TUI debugger. -#![warn(unused_crate_dependencies, unreachable_pub)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index 58a8e57f42751..22ea7d5d32271 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -27,18 +27,18 @@ impl BufferKind { /// Helper to cycle through the active buffers. pub(crate) fn next(&self) -> Self { match self { - BufferKind::Memory => BufferKind::Calldata, - BufferKind::Calldata => BufferKind::Returndata, - BufferKind::Returndata => BufferKind::Memory, + Self::Memory => Self::Calldata, + Self::Calldata => Self::Returndata, + Self::Returndata => Self::Memory, } } /// Helper to format the title of the active buffer pane pub(crate) fn title(&self, size: usize) -> String { match self { - BufferKind::Memory => format!("Memory (max expansion: {} bytes)", size), - BufferKind::Calldata => format!("Calldata (size: {} bytes)", size), - BufferKind::Returndata => format!("Returndata (size: {} bytes)", size), + Self::Memory => format!("Memory (max expansion: {size} bytes)"), + Self::Calldata => format!("Calldata (size: {size} bytes)"), + Self::Returndata => format!("Returndata (size: {size} bytes)"), } } } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 9a33e6a059104..8e55687a0aec1 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -420,7 +420,7 @@ impl DebuggerContext<'_> { let params = OpcodeParam::of(step.instruction); - let text: Vec = stack + let text: Vec> = stack .iter() .rev() .enumerate() @@ -515,7 +515,7 @@ impl DebuggerContext<'_> { let height = area.height as usize; let end_line = self.draw_memory.current_buf_startline + height; - let text: Vec = buf + let text: Vec> = buf .chunks(32) .enumerate() .skip(self.draw_memory.current_buf_startline) diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 1965befb88313..baf914347cd20 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] forge-fmt.workspace = true foundry-common.workspace = true diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index 3f1f2935c0bd8..be4c1e647670d 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -90,36 +90,34 @@ pub enum DocumentContent { impl DocumentContent { pub(crate) fn len(&self) -> usize { match self { - DocumentContent::Empty => 0, - DocumentContent::Single(_) => 1, - DocumentContent::Constants(items) => items.len(), - DocumentContent::OverloadedFunctions(items) => items.len(), + Self::Empty => 0, + Self::Single(_) => 1, + Self::Constants(items) => items.len(), + Self::OverloadedFunctions(items) => items.len(), } } pub(crate) fn get_mut(&mut self, index: usize) -> Option<&mut ParseItem> { match self { - DocumentContent::Empty => None, - DocumentContent::Single(item) => { + Self::Empty => None, + Self::Single(item) => { if index == 0 { Some(item) } else { None } } - DocumentContent::Constants(items) => items.get_mut(index), - DocumentContent::OverloadedFunctions(items) => items.get_mut(index), + Self::Constants(items) => items.get_mut(index), + Self::OverloadedFunctions(items) => items.get_mut(index), } } pub fn iter_items(&self) -> ParseItemIter<'_> { match self { - DocumentContent::Empty => ParseItemIter { next: None, other: None }, - DocumentContent::Single(item) => ParseItemIter { next: Some(item), other: None }, - DocumentContent::Constants(items) => { - ParseItemIter { next: None, other: Some(items.iter()) } - } - DocumentContent::OverloadedFunctions(items) => { + Self::Empty => ParseItemIter { next: None, other: None }, + Self::Single(item) => ParseItemIter { next: Some(item), other: None }, + Self::Constants(items) => ParseItemIter { next: None, other: Some(items.iter()) }, + Self::OverloadedFunctions(items) => { ParseItemIter { next: None, other: Some(items.iter()) } } } @@ -127,12 +125,12 @@ impl DocumentContent { pub fn iter_items_mut(&mut self) -> ParseItemIterMut<'_> { match self { - DocumentContent::Empty => ParseItemIterMut { next: None, other: None }, - DocumentContent::Single(item) => ParseItemIterMut { next: Some(item), other: None }, - DocumentContent::Constants(items) => { + Self::Empty => ParseItemIterMut { next: None, other: None }, + Self::Single(item) => ParseItemIterMut { next: Some(item), other: None }, + Self::Constants(items) => { ParseItemIterMut { next: None, other: Some(items.iter_mut()) } } - DocumentContent::OverloadedFunctions(items) => { + Self::OverloadedFunctions(items) => { ParseItemIterMut { next: None, other: Some(items.iter_mut()) } } } diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 3f92be47aa8c1..fd8e4d3ba7e64 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -1,13 +1,9 @@ //! The module for generating Solidity documentation. //! -//! See [DocBuilder] - -#![warn(missing_debug_implementations, missing_docs, unreachable_pub, unused_crate_dependencies)] -#![deny(unused_must_use, rust_2018_idioms)] -#![doc(test( - no_crate_inject, - attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) -))] +//! See [`DocBuilder`]. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index b6e6d08af276a..55e69249d452d 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -28,20 +28,20 @@ impl CommentTag { fn from_str(s: &str) -> Option { let trimmed = s.trim(); let tag = match trimmed { - "title" => CommentTag::Title, - "author" => CommentTag::Author, - "notice" => CommentTag::Notice, - "dev" => CommentTag::Dev, - "param" => CommentTag::Param, - "return" => CommentTag::Return, - "inheritdoc" => CommentTag::Inheritdoc, + "title" => Self::Title, + "author" => Self::Author, + "notice" => Self::Notice, + "dev" => Self::Dev, + "param" => Self::Param, + "return" => Self::Return, + "inheritdoc" => Self::Inheritdoc, _ if trimmed.starts_with("custom:") => { // `@custom:param` tag will be parsed as `CommentTag::Param` due to a limitation // on specifying parameter docs for unnamed function arguments. let custom_tag = trimmed.trim_start_matches("custom:").trim(); match custom_tag { - "param" => CommentTag::Param, - _ => CommentTag::Custom(custom_tag.to_owned()), + "param" => Self::Param, + _ => Self::Custom(custom_tag.to_owned()), } } _ => { @@ -126,9 +126,9 @@ impl Comments { pub fn merge_inheritdoc( &self, ident: &str, - inheritdocs: Option>, - ) -> Comments { - let mut result = Comments(Vec::from_iter(self.iter().cloned())); + inheritdocs: Option>, + ) -> Self { + let mut result = Self(Vec::from_iter(self.iter().cloned())); if let (Some(inheritdocs), Some(base)) = (inheritdocs, self.find_inheritdoc_base()) { let key = format!("{base}.{ident}"); @@ -157,18 +157,18 @@ pub struct CommentsRef<'a>(Vec<&'a Comment>); impl<'a> CommentsRef<'a> { /// Filter a collection of comments and return only those that match a provided tag - pub fn include_tag(&self, tag: CommentTag) -> CommentsRef<'a> { + pub fn include_tag(&self, tag: CommentTag) -> Self { self.include_tags(&[tag]) } /// Filter a collection of comments and return only those that match provided tags - pub fn include_tags(&self, tags: &[CommentTag]) -> CommentsRef<'a> { + pub fn include_tags(&self, tags: &[CommentTag]) -> Self { // Cloning only references here CommentsRef(self.iter().cloned().filter(|c| tags.contains(&c.tag)).collect()) } /// Filter a collection of comments and return only those that do not match provided tags - pub fn exclude_tags(&self, tags: &[CommentTag]) -> CommentsRef<'a> { + pub fn exclude_tags(&self, tags: &[CommentTag]) -> Self { // Cloning only references here CommentsRef(self.iter().cloned().filter(|c| !tags.contains(&c.tag)).collect()) } diff --git a/crates/doc/src/parser/item.rs b/crates/doc/src/parser/item.rs index 60faf78b411b1..b93f0d199491f 100644 --- a/crates/doc/src/parser/item.rs +++ b/crates/doc/src/parser/item.rs @@ -75,7 +75,7 @@ impl ParseItem { } /// Set children on the [ParseItem]. - pub fn with_children(mut self, children: Vec) -> Self { + pub fn with_children(mut self, children: Vec) -> Self { self.children = children; self } @@ -171,16 +171,16 @@ impl ParseSource { /// Get the identity of the source pub fn ident(&self) -> String { match self { - ParseSource::Contract(contract) => contract.name.safe_unwrap().name.to_owned(), - ParseSource::Variable(var) => var.name.safe_unwrap().name.to_owned(), - ParseSource::Event(event) => event.name.safe_unwrap().name.to_owned(), - ParseSource::Error(error) => error.name.safe_unwrap().name.to_owned(), - ParseSource::Struct(structure) => structure.name.safe_unwrap().name.to_owned(), - ParseSource::Enum(enumerable) => enumerable.name.safe_unwrap().name.to_owned(), - ParseSource::Function(func) => { + Self::Contract(contract) => contract.name.safe_unwrap().name.to_owned(), + Self::Variable(var) => var.name.safe_unwrap().name.to_owned(), + Self::Event(event) => event.name.safe_unwrap().name.to_owned(), + Self::Error(error) => error.name.safe_unwrap().name.to_owned(), + Self::Struct(structure) => structure.name.safe_unwrap().name.to_owned(), + Self::Enum(enumerable) => enumerable.name.safe_unwrap().name.to_owned(), + Self::Function(func) => { func.name.as_ref().map_or(func.ty.to_string(), |n| n.name.to_owned()) } - ParseSource::Type(ty) => ty.name.name.to_owned(), + Self::Type(ty) => ty.name.name.to_owned(), } } } diff --git a/crates/doc/src/parser/mod.rs b/crates/doc/src/parser/mod.rs index 6f03a5fb2b1dd..aa493c5c6ddd0 100644 --- a/crates/doc/src/parser/mod.rs +++ b/crates/doc/src/parser/mod.rs @@ -52,7 +52,7 @@ struct ParserContext { impl Parser { /// Create a new instance of [Parser]. pub fn new(comments: Vec, source: String) -> Self { - Parser { comments, source, ..Default::default() } + Self { comments, source, ..Default::default() } } /// Set formatter config on the [Parser] diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index 865c4302fdf46..a7f7c19c4cb74 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -179,7 +179,7 @@ impl InferInlineHyperlinks { }; if let Some(target) = target { let display_value = link.markdown_link_display_value(); - let markdown_link = format!("[{}]({})", display_value, target); + let markdown_link = format!("[{display_value}]({target})"); // replace the link with the markdown link comment.value = comment.value.as_str().replacen(link.as_str(), markdown_link.as_str(), 1); diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 589e13b2572a5..c0b1b3e3d0fb3 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true diff --git a/crates/evm/core/src/backend/diagnostic.rs b/crates/evm/core/src/backend/diagnostic.rs index f4de9260ab565..109190a8fe594 100644 --- a/crates/evm/core/src/backend/diagnostic.rs +++ b/crates/evm/core/src/backend/diagnostic.rs @@ -26,7 +26,7 @@ impl RevertDiagnostic { |addr: &Address| labels.get(addr).cloned().unwrap_or_else(|| addr.to_string()); match self { - RevertDiagnostic::ContractExistsOnOtherForks { contract, active, available_on } => { + Self::ContractExistsOnOtherForks { contract, active, available_on } => { let contract_label = get_label(contract); format!( @@ -37,7 +37,7 @@ impl RevertDiagnostic { available_on.iter().format(", ") ) } - RevertDiagnostic::ContractDoesNotExist { contract, persistent, .. } => { + Self::ContractDoesNotExist { contract, persistent, .. } => { let contract_label = get_label(contract); if *persistent { format!("Contract {contract_label} does not exist") diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index f1f9733d494ee..2f40bd4569942 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -54,12 +54,12 @@ pub enum DatabaseError { impl DatabaseError { /// Create a new error with a message pub fn msg(msg: impl Into) -> Self { - DatabaseError::Message(msg.into()) + Self::Message(msg.into()) } /// Create a new error with a message pub fn display(msg: impl std::fmt::Display) -> Self { - DatabaseError::Message(msg.to_string()) + Self::Message(msg.to_string()) } fn get_rpc_error(&self) -> Option<&eyre::Error> { @@ -79,7 +79,7 @@ impl DatabaseError { Self::BlockNotFound(_) | Self::TransactionNotFound(_) | Self::MissingCreate2Deployer => None, - DatabaseError::Other(_) => None, + Self::Other(_) => None, } } @@ -96,7 +96,7 @@ impl DatabaseError { impl From for DatabaseError { fn from(value: tokio::task::JoinError) -> Self { - DatabaseError::display(value) + Self::display(value) } } @@ -113,11 +113,11 @@ impl From for DatabaseError { } // Note: this is mostly necessary to use some revm internals that return an [EVMError] -impl From> for DatabaseError { - fn from(err: EVMError) -> Self { +impl From> for DatabaseError { + fn from(err: EVMError) -> Self { match err { EVMError::Database(err) => err, - err => DatabaseError::Other(err.to_string()), + err => Self::Other(err.to_string()), } } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 94a1eeead2281..bb43c7243bc67 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1233,7 +1233,7 @@ impl DatabaseExt for Backend { Ok(()) } - fn transact>( + fn transact>( &mut self, maybe_id: Option, transaction: B256, diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index 5fd0cfa77958a..f8961c7a0e674 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -56,6 +56,6 @@ pub enum RevertSnapshotAction { impl RevertSnapshotAction { /// Returns `true` if the action is to keep the snapshot pub fn is_keep(&self) -> bool { - matches!(self, RevertSnapshotAction::RevertKeep) + matches!(self, Self::RevertKeep) } } diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index ce13f69c1a3f0..fd768e3f74e39 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -132,11 +132,7 @@ impl BlockchainDbMeta { .and_then(|url| url.host().map(|host| host.to_string())) .unwrap_or(url); - BlockchainDbMeta { - cfg_env: env.cfg.clone(), - block_env: env.block, - hosts: BTreeSet::from([host]), - } + Self { cfg_env: env.cfg.clone(), block_env: env.block, hosts: BTreeSet::from([host]) } } } @@ -451,7 +447,7 @@ impl<'de> Deserialize<'de> for JsonBlockCacheData { let Data { meta, data: StateSnapshot { accounts, storage, block_hashes } } = Data::deserialize(deserializer)?; - Ok(JsonBlockCacheData { + Ok(Self { meta: Arc::new(RwLock::new(meta)), data: Arc::new(MemDb { accounts: RwLock::new(accounts), diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index bece8c4f5bcce..79b30c0ce8b94 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -41,7 +41,7 @@ impl ForkId { Some(n) => write!(id, "{n:#x}").unwrap(), None => id.push_str("latest"), } - ForkId(id) + Self(id) } /// Returns the identifier of the fork. diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index ef28ad9223adb..c2c2e200663d9 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -2,7 +2,8 @@ //! //! Core EVM abstractions. -#![warn(unused_crate_dependencies)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use auto_impl::auto_impl; use revm::{inspectors::NoOpInspector, interpreter::CreateInputs, Database, EvmContext, Inspector}; diff --git a/crates/evm/coverage/Cargo.toml b/crates/evm/coverage/Cargo.toml index 57a7a9f2bab0c..6858159de43dd 100644 --- a/crates/evm/coverage/Cargo.toml +++ b/crates/evm/coverage/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-common.workspace = true foundry-compilers.workspace = true diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 9496c0aca095d..58bfb9cdb6b9e 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -2,7 +2,8 @@ //! //! EVM bytecode coverage analysis. -#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; @@ -155,7 +156,7 @@ impl CoverageReport { pub struct HitMaps(pub HashMap); impl HitMaps { - pub fn merge(&mut self, other: HitMaps) { + pub fn merge(&mut self, other: Self) { for (code_hash, hit_map) in other.0 { if let Some(HitMap { hits: extra_hits, .. }) = self.insert(code_hash, hit_map) { for (pc, hits) in extra_hits { @@ -166,7 +167,7 @@ impl HitMaps { } } - pub fn merged(mut self, other: HitMaps) -> Self { + pub fn merged(mut self, other: Self) -> Self { self.merge(other); self } @@ -206,14 +207,14 @@ impl HitMap { } /// Merge another hitmap into this, assuming the bytecode is consistent - pub fn merge(&mut self, other: &HitMap) -> Result<(), eyre::Report> { + pub fn merge(&mut self, other: &Self) -> Result<(), eyre::Report> { for (pc, hits) in &other.hits { *self.hits.entry(*pc).or_default() += hits; } Ok(()) } - pub fn consistent_bytecode(&self, hm1: &HitMap, hm2: &HitMap) -> bool { + pub fn consistent_bytecode(&self, hm1: &Self, hm2: &Self) -> bool { // Consider the bytecodes consistent if they are the same out as far as the // recorded hits let len1 = hm1.hits.last_key_value(); diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 5168c35e02725..e3a1c9c6b56c4 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-cheatcodes.workspace = true foundry-common.workspace = true diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 69ef106f68d13..2474ed5aabc02 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -219,7 +219,7 @@ impl<'a> InvariantExecutor<'a> { U256::ZERO, ) .map_err(|e| { - TestCaseError::fail(format!("Could not make raw evm call: {}", e)) + TestCaseError::fail(format!("Could not make raw evm call: {e}")) })?; if call_result.result.as_ref() == MAGIC_ASSUME { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 7e770f54f444e..ba1e5277c4c5f 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -101,7 +101,7 @@ impl Executor { }, ); - Executor { backend, env, inspector, gas_limit } + Self { backend, env, inspector, gas_limit } } /// Returns the spec id of the executor @@ -513,7 +513,7 @@ impl Executor { // Check if a DSTest assertion failed let executor = - Executor::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); + Self::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); let call = executor.call_sol(CALLER, address, &ITest::failedCall {}, U256::ZERO, None); if let Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { _0: failed } }) = call @@ -610,13 +610,13 @@ pub enum EvmError { impl From for EvmError { fn from(err: ExecutionErr) -> Self { - EvmError::Execution(Box::new(err)) + Self::Execution(Box::new(err)) } } impl From for EvmError { fn from(err: alloy_sol_types::Error) -> Self { - EvmError::AbiError(err.into()) + Self::AbiError(err.into()) } } diff --git a/crates/evm/evm/src/lib.rs b/crates/evm/evm/src/lib.rs index a699b6bf80447..598012770a450 100644 --- a/crates/evm/evm/src/lib.rs +++ b/crates/evm/evm/src/lib.rs @@ -2,7 +2,8 @@ //! //! Main Foundry EVM backend abstractions. -#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 5fd6db65db49f..87d5d9ab306e2 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-common.workspace = true foundry-compilers.workspace = true diff --git a/crates/evm/fuzz/src/invariant/call_override.rs b/crates/evm/fuzz/src/invariant/call_override.rs index a98c500024413..a65b0abc9f195 100644 --- a/crates/evm/fuzz/src/invariant/call_override.rs +++ b/crates/evm/fuzz/src/invariant/call_override.rs @@ -38,7 +38,7 @@ impl RandomCallGenerator { ) -> Self { let strategy = weighted(0.9, strategy).sboxed(); - RandomCallGenerator { + Self { test_address, runner: Arc::new(Mutex::new(runner)), strategy, diff --git a/crates/evm/fuzz/src/invariant/filters.rs b/crates/evm/fuzz/src/invariant/filters.rs index 2925c6e4506cd..d0ebb33e5db1d 100644 --- a/crates/evm/fuzz/src/invariant/filters.rs +++ b/crates/evm/fuzz/src/invariant/filters.rs @@ -69,6 +69,6 @@ impl SenderFilters { excluded.push(addr_0); } targeted.retain(|addr| !excluded.contains(addr)); - SenderFilters { targeted, excluded } + Self { targeted, excluded } } } diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index c6b5e00499e88..7da74601ff8c2 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -2,7 +2,8 @@ //! //! EVM fuzzing implementation using [`proptest`]. -#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; @@ -67,7 +68,7 @@ impl BaseCounterExample { if let Some(func) = abi.functions().find(|f| f.selector() == bytes[..4]) { // skip the function selector when decoding if let Ok(args) = func.abi_decode_input(&bytes[4..], false) { - return BaseCounterExample { + return Self { sender: Some(sender), addr: Some(addr), calldata: bytes.clone(), @@ -82,7 +83,7 @@ impl BaseCounterExample { } } - BaseCounterExample { + Self { sender: Some(sender), addr: Some(addr), calldata: bytes.clone(), @@ -99,7 +100,7 @@ impl BaseCounterExample { args: Vec, traces: Option, ) -> Self { - BaseCounterExample { + Self { sender: None, addr: None, calldata: bytes, @@ -132,7 +133,7 @@ impl fmt::Display for BaseCounterExample { } if let Some(args) = &self.args { - write!(f, " args=[{}]", args) + write!(f, " args=[{args}]") } else { write!(f, " args=[]") } @@ -308,7 +309,7 @@ pub struct FuzzFixtures { } impl FuzzFixtures { - pub fn new(fixtures: HashMap) -> FuzzFixtures { + pub fn new(fixtures: HashMap) -> Self { Self { inner: Arc::new(fixtures) } } diff --git a/crates/evm/fuzz/src/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs index fc8f88ed6cb13..3f8ff548bb6d3 100644 --- a/crates/evm/fuzz/src/strategies/int.rs +++ b/crates/evm/fuzz/src/strategies/int.rs @@ -56,7 +56,7 @@ impl ValueTree for IntValueTree { } fn simplify(&mut self) -> bool { - if self.fixed || !IntValueTree::magnitude_greater(self.hi, self.lo) { + if self.fixed || !Self::magnitude_greater(self.hi, self.lo) { return false } self.hi = self.curr; @@ -64,7 +64,7 @@ impl ValueTree for IntValueTree { } fn complicate(&mut self) -> bool { - if self.fixed || !IntValueTree::magnitude_greater(self.hi, self.lo) { + if self.fixed || !Self::magnitude_greater(self.hi, self.lo) { return false } diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 6ff36f8e46d9c..3e4628d9a441d 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -33,7 +33,7 @@ pub struct EvmFuzzState { } impl EvmFuzzState { - pub fn new(db: &CacheDB, config: FuzzDictionaryConfig) -> EvmFuzzState { + pub fn new(db: &CacheDB, config: FuzzDictionaryConfig) -> Self { // Sort accounts to ensure deterministic dictionary generation from the same setUp state. let mut accs = db.accounts.iter().collect::>(); accs.sort_by_key(|(address, _)| *address); diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 0d6192aefcc06..d6b13e3ccf85e 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-block-explorers.workspace = true foundry-common.workspace = true diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 73bf52bdd9494..75ea3d2602a90 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -698,13 +698,13 @@ mod tests { for (function_signature, data, expected) in cheatcode_input_test_cases { let function = Function::parse(function_signature).unwrap(); let result = decoder.decode_cheatcode_inputs(&function, &data); - assert_eq!(result, expected, "Input case failed for: {}", function_signature); + assert_eq!(result, expected, "Input case failed for: {function_signature}"); } for (function_signature, expected) in cheatcode_output_test_cases { let function = Function::parse(function_signature).unwrap(); let result = Some(decoder.decode_cheatcode_outputs(&function).unwrap_or_default()); - assert_eq!(result, expected, "Output case failed for: {}", function_signature); + assert_eq!(result, expected, "Output case failed for: {function_signature}"); } } } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 46ba27891e527..052be9c053422 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -2,7 +2,8 @@ //! //! EVM trace identifying and decoding. -#![warn(unreachable_pub, unused_crate_dependencies, rust_2018_idioms)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; @@ -86,7 +87,7 @@ pub async fn render_trace_arena( // Display trace header let (trace, return_data) = render_trace(&node.trace, decoder).await?; - writeln!(s, "{left}{}", trace)?; + writeln!(s, "{left}{trace}")?; // Display logs and subcalls let left_prefix = format!("{child}{BRANCH}"); diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index 8fbf962ebd281..835b2e8b7547c 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-config.workspace = true diff --git a/crates/fmt/src/buffer.rs b/crates/fmt/src/buffer.rs index 11c0838ecd370..8d62a70f9881e 100644 --- a/crates/fmt/src/buffer.rs +++ b/crates/fmt/src/buffer.rs @@ -22,16 +22,16 @@ enum WriteState { impl WriteState { fn comment_state(&self) -> CommentState { match self { - WriteState::LineStart(state) => *state, - WriteState::WriteTokens(state) => *state, - WriteState::WriteString(_) => CommentState::None, + Self::LineStart(state) => *state, + Self::WriteTokens(state) => *state, + Self::WriteString(_) => CommentState::None, } } } impl Default for WriteState { fn default() -> Self { - WriteState::LineStart(CommentState::default()) + Self::LineStart(CommentState::default()) } } diff --git a/crates/fmt/src/chunk.rs b/crates/fmt/src/chunk.rs index badce88db5675..7d9ce25c7fbd0 100644 --- a/crates/fmt/src/chunk.rs +++ b/crates/fmt/src/chunk.rs @@ -12,13 +12,13 @@ pub struct Chunk { impl From for Chunk { fn from(string: String) -> Self { - Chunk { content: string, ..Default::default() } + Self { content: string, ..Default::default() } } } impl From<&str> for Chunk { fn from(string: &str) -> Self { - Chunk { content: string.to_owned(), ..Default::default() } + Self { content: string.to_owned(), ..Default::default() } } } @@ -37,7 +37,7 @@ impl SurroundingChunk { before: Option, next: Option, ) -> Self { - SurroundingChunk { before, next, content: format!("{content}"), spaced: None } + Self { before, next, content: format!("{content}"), spaced: None } } pub fn spaced(mut self) -> Self { diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index 03f4e41813c19..5b9d7fb276672 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -72,11 +72,7 @@ impl CommentWithMetadata { } /// Construct a comment with metadata by analyzing its surrounding source code - fn from_comment_and_src( - comment: Comment, - src: &str, - last_comment: Option<&CommentWithMetadata>, - ) -> Self { + fn from_comment_and_src(comment: Comment, src: &str, last_comment: Option<&Self>) -> Self { let src_before = &src[..comment.loc().start()]; if src_before.is_empty() { return Self::new(comment, CommentPosition::Prefix, false, 0) @@ -429,10 +425,10 @@ impl<'a> Iterator for NonCommentChars<'a> { /// Helpers for iterating over comment containing strings pub trait CommentStringExt { - fn comment_state_char_indices(&self) -> CommentStateCharIndices; + fn comment_state_char_indices(&self) -> CommentStateCharIndices<'_>; #[inline] - fn non_comment_chars(&self) -> NonCommentChars { + fn non_comment_chars(&self) -> NonCommentChars<'_> { NonCommentChars(self.comment_state_char_indices()) } @@ -447,14 +443,14 @@ where T: AsRef, { #[inline] - fn comment_state_char_indices(&self) -> CommentStateCharIndices { + fn comment_state_char_indices(&self) -> CommentStateCharIndices<'_> { CommentStateCharIndices::new(self.as_ref()) } } impl CommentStringExt for str { #[inline] - fn comment_state_char_indices(&self) -> CommentStateCharIndices { + fn comment_state_char_indices(&self) -> CommentStateCharIndices<'_> { CommentStateCharIndices::new(self) } } diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index 9a31edeb0901b..1bed8069a23a7 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -23,7 +23,7 @@ pub struct Parsed<'a> { } /// Parse source code -pub fn parse(src: &str) -> Result> { +pub fn parse(src: &str) -> Result, Vec> { let (pt, comments) = solang_parser::parse(src, 0)?; let comments = Comments::new(comments, src); let (inline_config_items, invalid_inline_config_items): (Vec<_>, Vec<_>) = @@ -35,7 +35,7 @@ pub fn parse(src: &str) -> Result> { /// Format parsed code pub fn format_to( writer: W, - mut parsed: Parsed, + mut parsed: Parsed<'_>, config: FormatterConfig, ) -> Result<(), FormatterError> { trace!(?parsed, ?config, "Formatting"); diff --git a/crates/fmt/src/inline_config.rs b/crates/fmt/src/inline_config.rs index 702669fe518bd..7593bb92c278f 100644 --- a/crates/fmt/src/inline_config.rs +++ b/crates/fmt/src/inline_config.rs @@ -23,11 +23,11 @@ impl FromStr for InlineConfigItem { type Err = InvalidInlineConfigItem; fn from_str(s: &str) -> Result { Ok(match s { - "disable-next-item" => InlineConfigItem::DisableNextItem, - "disable-line" => InlineConfigItem::DisableLine, - "disable-next-line" => InlineConfigItem::DisableNextLine, - "disable-start" => InlineConfigItem::DisableStart, - "disable-end" => InlineConfigItem::DisableEnd, + "disable-next-item" => Self::DisableNextItem, + "disable-line" => Self::DisableLine, + "disable-next-line" => Self::DisableNextLine, + "disable-start" => Self::DisableStart, + "disable-end" => Self::DisableEnd, s => return Err(InvalidInlineConfigItem(s.into())), }) } diff --git a/crates/fmt/src/lib.rs b/crates/fmt/src/lib.rs index 958d74647451c..4d5fe17a7f04e 100644 --- a/crates/fmt/src/lib.rs +++ b/crates/fmt/src/lib.rs @@ -1,5 +1,6 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/fmt/src/solang_ext/ast_eq.rs b/crates/fmt/src/solang_ext/ast_eq.rs index e31fc2b410139..2640008e2eaa0 100644 --- a/crates/fmt/src/solang_ext/ast_eq.rs +++ b/crates/fmt/src/solang_ext/ast_eq.rs @@ -225,13 +225,13 @@ macro_rules! wrap_in_box { impl AstEq for Statement { fn ast_eq(&self, other: &Self) -> bool { match self { - Statement::If(loc, expr, stmt1, stmt2) => { + Self::If(loc, expr, stmt1, stmt2) => { #[allow(clippy::borrowed_box)] - let wrap_if = |stmt1: &Box, stmt2: &Option>| { + let wrap_if = |stmt1: &Box, stmt2: &Option>| { ( wrap_in_box!(stmt1, *loc), stmt2.as_ref().map(|stmt2| { - if matches!(**stmt2, Statement::If(..)) { + if matches!(**stmt2, Self::If(..)) { stmt2.clone() } else { wrap_in_box!(stmt2, *loc) @@ -241,7 +241,7 @@ impl AstEq for Statement { }; let (stmt1, stmt2) = wrap_if(stmt1, stmt2); let left = (loc, expr, &stmt1, &stmt2); - if let Statement::If(loc, expr, stmt1, stmt2) = other { + if let Self::If(loc, expr, stmt1, stmt2) = other { let (stmt1, stmt2) = wrap_if(stmt1, stmt2); let right = (loc, expr, &stmt1, &stmt2); left.ast_eq(&right) @@ -249,10 +249,10 @@ impl AstEq for Statement { false } } - Statement::While(loc, expr, stmt1) => { + Self::While(loc, expr, stmt1) => { let stmt1 = wrap_in_box!(stmt1, *loc); let left = (loc, expr, &stmt1); - if let Statement::While(loc, expr, stmt1) = other { + if let Self::While(loc, expr, stmt1) = other { let stmt1 = wrap_in_box!(stmt1, *loc); let right = (loc, expr, &stmt1); left.ast_eq(&right) @@ -260,10 +260,10 @@ impl AstEq for Statement { false } } - Statement::DoWhile(loc, stmt1, expr) => { + Self::DoWhile(loc, stmt1, expr) => { let stmt1 = wrap_in_box!(stmt1, *loc); let left = (loc, &stmt1, expr); - if let Statement::DoWhile(loc, stmt1, expr) = other { + if let Self::DoWhile(loc, stmt1, expr) = other { let stmt1 = wrap_in_box!(stmt1, *loc); let right = (loc, &stmt1, expr); left.ast_eq(&right) @@ -271,10 +271,10 @@ impl AstEq for Statement { false } } - Statement::For(loc, stmt1, expr, stmt2, stmt3) => { + Self::For(loc, stmt1, expr, stmt2, stmt3) => { let stmt3 = stmt3.as_ref().map(|stmt3| wrap_in_box!(stmt3, *loc)); let left = (loc, stmt1, expr, stmt2, &stmt3); - if let Statement::For(loc, stmt1, expr, stmt2, stmt3) = other { + if let Self::For(loc, stmt1, expr, stmt2, stmt3) = other { let stmt3 = stmt3.as_ref().map(|stmt3| wrap_in_box!(stmt3, *loc)); let right = (loc, stmt1, expr, stmt2, &stmt3); left.ast_eq(&right) @@ -282,11 +282,11 @@ impl AstEq for Statement { false } } - Statement::Try(loc, expr, returns, catch) => { + Self::Try(loc, expr, returns, catch) => { let left_returns = returns.as_ref().map(|(params, stmt)| (filter_params(params), stmt)); let left = (loc, expr, left_returns, catch); - if let Statement::Try(loc, expr, returns, catch) = other { + if let Self::Try(loc, expr, returns, catch) = other { let right_returns = returns.as_ref().map(|(params, stmt)| (filter_params(params), stmt)); let right = (loc, expr, right_returns, catch); diff --git a/crates/fmt/src/string.rs b/crates/fmt/src/string.rs index 082d25d52496a..1dbc2f2f61b59 100644 --- a/crates/fmt/src/string.rs +++ b/crates/fmt/src/string.rs @@ -100,12 +100,14 @@ impl<'a> Iterator for QuotedRanges<'a> { /// Helpers for iterating over quoted strings pub trait QuotedStringExt { - /// Get an iterator of characters, indices and their quoted string state - fn quote_state_char_indices(&self) -> QuoteStateCharIndices; - /// Get an iterator of quoted string ranges - fn quoted_ranges(&self) -> QuotedRanges { + /// Returns an iterator of characters, indices and their quoted string state. + fn quote_state_char_indices(&self) -> QuoteStateCharIndices<'_>; + + /// Returns an iterator of quoted string ranges. + fn quoted_ranges(&self) -> QuotedRanges<'_> { QuotedRanges(self.quote_state_char_indices()) } + /// Check to see if a string is quoted. This will return true if the first character /// is a quote and the last character is a quote with no non-quoted sections in between. fn is_quoted(&self) -> bool { @@ -126,13 +128,13 @@ impl QuotedStringExt for T where T: AsRef, { - fn quote_state_char_indices(&self) -> QuoteStateCharIndices { + fn quote_state_char_indices(&self) -> QuoteStateCharIndices<'_> { QuoteStateCharIndices::new(self.as_ref()) } } impl QuotedStringExt for str { - fn quote_state_char_indices(&self) -> QuoteStateCharIndices { + fn quote_state_char_indices(&self) -> QuoteStateCharIndices<'_> { QuoteStateCharIndices::new(self) } } diff --git a/crates/fmt/src/visit.rs b/crates/fmt/src/visit.rs index da7f3ca376d10..ef9273a30ce2d 100644 --- a/crates/fmt/src/visit.rs +++ b/crates/fmt/src/visit.rs @@ -456,19 +456,19 @@ impl Visitable for SourceUnitPart { V: Visitor, { match self { - SourceUnitPart::ContractDefinition(contract) => v.visit_contract(contract), - SourceUnitPart::PragmaDirective(loc, ident, str) => v.visit_pragma(*loc, ident, str), - SourceUnitPart::ImportDirective(import) => import.visit(v), - SourceUnitPart::EnumDefinition(enumeration) => v.visit_enum(enumeration), - SourceUnitPart::StructDefinition(structure) => v.visit_struct(structure), - SourceUnitPart::EventDefinition(event) => v.visit_event(event), - SourceUnitPart::ErrorDefinition(error) => v.visit_error(error), - SourceUnitPart::FunctionDefinition(function) => v.visit_function(function), - SourceUnitPart::VariableDefinition(variable) => v.visit_var_definition(variable), - SourceUnitPart::TypeDefinition(def) => v.visit_type_definition(def), - SourceUnitPart::StraySemicolon(_) => v.visit_stray_semicolon(), - SourceUnitPart::Using(using) => v.visit_using(using), - SourceUnitPart::Annotation(annotation) => v.visit_annotation(annotation), + Self::ContractDefinition(contract) => v.visit_contract(contract), + Self::PragmaDirective(loc, ident, str) => v.visit_pragma(*loc, ident, str), + Self::ImportDirective(import) => import.visit(v), + Self::EnumDefinition(enumeration) => v.visit_enum(enumeration), + Self::StructDefinition(structure) => v.visit_struct(structure), + Self::EventDefinition(event) => v.visit_event(event), + Self::ErrorDefinition(error) => v.visit_error(error), + Self::FunctionDefinition(function) => v.visit_function(function), + Self::VariableDefinition(variable) => v.visit_var_definition(variable), + Self::TypeDefinition(def) => v.visit_type_definition(def), + Self::StraySemicolon(_) => v.visit_stray_semicolon(), + Self::Using(using) => v.visit_using(using), + Self::Annotation(annotation) => v.visit_annotation(annotation), } } } @@ -479,11 +479,11 @@ impl Visitable for Import { V: Visitor, { match self { - Import::Plain(import, loc) => v.visit_import_plain(*loc, import), - Import::GlobalSymbol(global, import_as, loc) => { + Self::Plain(import, loc) => v.visit_import_plain(*loc, import), + Self::GlobalSymbol(global, import_as, loc) => { v.visit_import_global(*loc, global, import_as) } - Import::Rename(from, imports, loc) => v.visit_import_renames(*loc, imports, from), + Self::Rename(from, imports, loc) => v.visit_import_renames(*loc, imports, from), } } } @@ -494,16 +494,16 @@ impl Visitable for ContractPart { V: Visitor, { match self { - ContractPart::StructDefinition(structure) => v.visit_struct(structure), - ContractPart::EventDefinition(event) => v.visit_event(event), - ContractPart::ErrorDefinition(error) => v.visit_error(error), - ContractPart::EnumDefinition(enumeration) => v.visit_enum(enumeration), - ContractPart::VariableDefinition(variable) => v.visit_var_definition(variable), - ContractPart::FunctionDefinition(function) => v.visit_function(function), - ContractPart::TypeDefinition(def) => v.visit_type_definition(def), - ContractPart::StraySemicolon(_) => v.visit_stray_semicolon(), - ContractPart::Using(using) => v.visit_using(using), - ContractPart::Annotation(annotation) => v.visit_annotation(annotation), + Self::StructDefinition(structure) => v.visit_struct(structure), + Self::EventDefinition(event) => v.visit_event(event), + Self::ErrorDefinition(error) => v.visit_error(error), + Self::EnumDefinition(enumeration) => v.visit_enum(enumeration), + Self::VariableDefinition(variable) => v.visit_var_definition(variable), + Self::FunctionDefinition(function) => v.visit_function(function), + Self::TypeDefinition(def) => v.visit_type_definition(def), + Self::StraySemicolon(_) => v.visit_stray_semicolon(), + Self::Using(using) => v.visit_using(using), + Self::Annotation(annotation) => v.visit_annotation(annotation), } } } @@ -514,40 +514,34 @@ impl Visitable for Statement { V: Visitor, { match self { - Statement::Block { loc, unchecked, statements } => { + Self::Block { loc, unchecked, statements } => { v.visit_block(*loc, *unchecked, statements) } - Statement::Assembly { loc, dialect, block, flags } => { + Self::Assembly { loc, dialect, block, flags } => { v.visit_assembly(*loc, dialect, block, flags) } - Statement::Args(loc, args) => v.visit_args(*loc, args), - Statement::If(loc, cond, if_branch, else_branch) => { + Self::Args(loc, args) => v.visit_args(*loc, args), + Self::If(loc, cond, if_branch, else_branch) => { v.visit_if(*loc, cond, if_branch, else_branch, true) } - Statement::While(loc, cond, body) => v.visit_while(*loc, cond, body), - Statement::Expression(loc, expr) => { + Self::While(loc, cond, body) => v.visit_while(*loc, cond, body), + Self::Expression(loc, expr) => { v.visit_expr(*loc, expr)?; v.visit_stray_semicolon() } - Statement::VariableDefinition(loc, declaration, expr) => { + Self::VariableDefinition(loc, declaration, expr) => { v.visit_var_definition_stmt(*loc, declaration, expr) } - Statement::For(loc, init, cond, update, body) => { - v.visit_for(*loc, init, cond, update, body) - } - Statement::DoWhile(loc, body, cond) => v.visit_do_while(*loc, body, cond), - Statement::Continue(loc) => v.visit_continue(*loc, true), - Statement::Break(loc) => v.visit_break(*loc, true), - Statement::Return(loc, expr) => v.visit_return(*loc, expr), - Statement::Revert(loc, error, args) => v.visit_revert(*loc, error, args), - Statement::RevertNamedArgs(loc, error, args) => { - v.visit_revert_named_args(*loc, error, args) - } - Statement::Emit(loc, event) => v.visit_emit(*loc, event), - Statement::Try(loc, expr, returns, clauses) => { - v.visit_try(*loc, expr, returns, clauses) - } - Statement::Error(loc) => v.visit_parser_error(*loc), + Self::For(loc, init, cond, update, body) => v.visit_for(*loc, init, cond, update, body), + Self::DoWhile(loc, body, cond) => v.visit_do_while(*loc, body, cond), + Self::Continue(loc) => v.visit_continue(*loc, true), + Self::Break(loc) => v.visit_break(*loc, true), + Self::Return(loc, expr) => v.visit_return(*loc, expr), + Self::Revert(loc, error, args) => v.visit_revert(*loc, error, args), + Self::RevertNamedArgs(loc, error, args) => v.visit_revert_named_args(*loc, error, args), + Self::Emit(loc, event) => v.visit_emit(*loc, event), + Self::Try(loc, expr, returns, clauses) => v.visit_try(*loc, expr, returns, clauses), + Self::Error(loc) => v.visit_parser_error(*loc), } } } @@ -603,24 +597,20 @@ impl Visitable for YulStatement { V: Visitor, { match self { - YulStatement::Assign(loc, exprs, expr) => { - v.visit_yul_assignment(*loc, exprs, &mut Some(expr)) - } - YulStatement::Block(block) => { - v.visit_yul_block(block.loc, block.statements.as_mut(), false) - } - YulStatement::Break(loc) => v.visit_break(*loc, false), - YulStatement::Continue(loc) => v.visit_continue(*loc, false), - YulStatement::For(stmt) => v.visit_yul_for(stmt), - YulStatement::FunctionCall(stmt) => v.visit_yul_function_call(stmt), - YulStatement::FunctionDefinition(stmt) => v.visit_yul_fun_def(stmt), - YulStatement::If(loc, expr, block) => v.visit_yul_if(*loc, expr, block), - YulStatement::Leave(loc) => v.visit_yul_leave(*loc), - YulStatement::Switch(stmt) => v.visit_yul_switch(stmt), - YulStatement::VariableDeclaration(loc, idents, expr) => { + Self::Assign(loc, exprs, expr) => v.visit_yul_assignment(*loc, exprs, &mut Some(expr)), + Self::Block(block) => v.visit_yul_block(block.loc, block.statements.as_mut(), false), + Self::Break(loc) => v.visit_break(*loc, false), + Self::Continue(loc) => v.visit_continue(*loc, false), + Self::For(stmt) => v.visit_yul_for(stmt), + Self::FunctionCall(stmt) => v.visit_yul_function_call(stmt), + Self::FunctionDefinition(stmt) => v.visit_yul_fun_def(stmt), + Self::If(loc, expr, block) => v.visit_yul_if(*loc, expr, block), + Self::Leave(loc) => v.visit_yul_leave(*loc), + Self::Switch(stmt) => v.visit_yul_switch(stmt), + Self::VariableDeclaration(loc, idents, expr) => { v.visit_yul_var_declaration(*loc, idents, expr) } - YulStatement::Error(loc) => v.visit_parser_error(*loc), + Self::Error(loc) => v.visit_parser_error(*loc), } } } diff --git a/crates/fmt/tests/formatter.rs b/crates/fmt/tests/formatter.rs index efbd63ef5690a..ba1d9216d92da 100644 --- a/crates/fmt/tests/formatter.rs +++ b/crates/fmt/tests/formatter.rs @@ -94,7 +94,7 @@ fn test_formatter( struct PrettyString(String); impl PartialEq for PrettyString { - fn eq(&self, other: &PrettyString) -> bool { + fn eq(&self, other: &Self) -> bool { self.0.lines().eq(other.0.lines()) } } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 940acb087189e..eec9496105208 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [[bin]] name = "forge" path = "bin/main.rs" diff --git a/crates/forge/README.md b/crates/forge/README.md index 5ac9d57478b56..d4cfeede210f3 100644 --- a/crates/forge/README.md +++ b/crates/forge/README.md @@ -386,7 +386,7 @@ Logs: If you are working in a repo with NPM-style imports, like -``` +```solidity import "@openzeppelin/contracts/access/Ownable.sol"; ``` @@ -398,7 +398,7 @@ For example, if you have `@openzeppelin` imports, you would 2. Create a remappings file: `touch remappings.txt` 3. Add this line to `remappings.txt` -``` +```text @openzeppelin/=lib/openzeppelin-contracts/ ``` diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 3643642e70647..b4cd5ede89e61 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -191,7 +191,7 @@ impl BindArgs { .map(|(name, path)| { trace!(?path, "parsing Abigen from file"); let abi = Abigen::new(name, path.to_str().unwrap()) - .wrap_err_with(|| format!("failed to parse Abigen from file: {:?}", path)); + .wrap_err_with(|| format!("failed to parse Abigen from file: {path:?}")); if !self.skip_extra_derives { abi?.add_derive("serde::Serialize")?.add_derive("serde::Deserialize") } else { diff --git a/crates/forge/bin/cmd/cache.rs b/crates/forge/bin/cmd/cache.rs index ff3117d345f1e..1adaf4d267794 100644 --- a/crates/forge/bin/cmd/cache.rs +++ b/crates/forge/bin/cmd/cache.rs @@ -55,7 +55,7 @@ pub struct CleanArgs { impl CleanArgs { pub fn run(self) -> Result<()> { - let CleanArgs { chains, blocks, etherscan } = self; + let Self { chains, blocks, etherscan } = self; for chain_or_all in chains { match chain_or_all { @@ -91,7 +91,7 @@ pub struct LsArgs { impl LsArgs { pub fn run(self) -> Result<()> { - let LsArgs { chains } = self; + let Self { chains } = self; let mut cache = Cache::default(); for chain_or_all in chains { match chain_or_all { @@ -117,9 +117,9 @@ impl FromStr for ChainOrAll { fn from_str(s: &str) -> Result { if let Ok(chain) = NamedChain::from_str(s) { - Ok(ChainOrAll::NamedChain(chain)) + Ok(Self::NamedChain(chain)) } else if s == "all" { - Ok(ChainOrAll::All) + Ok(Self::All) } else { Err(format!("Expected known chain or all, found: {s}")) } @@ -150,7 +150,7 @@ pub struct ChainOrAllValueParser { impl Default for ChainOrAllValueParser { fn default() -> Self { - ChainOrAllValueParser { inner: possible_chains() } + Self { inner: possible_chains() } } } diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 61e4d637f4fa0..822f595fb0212 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -88,14 +88,8 @@ pub struct CloneArgs { impl CloneArgs { pub async fn run(self) -> Result<()> { - let CloneArgs { - address, - root, - opts, - etherscan, - no_remappings_txt, - keep_directory_structure, - } = self; + let Self { address, root, opts, etherscan, no_remappings_txt, keep_directory_structure } = + self; // step 0. get the chain and api key from the config let config = Config::from(ðerscan); @@ -131,7 +125,7 @@ impl CloneArgs { if !opts.no_commit { let git = Git::new(&root).quiet(opts.quiet); git.add(Some("--all"))?; - let msg = format!("chore: forge clone {}", address); + let msg = format!("chore: forge clone {address}"); git.commit(&msg)?; } @@ -619,7 +613,7 @@ mod tests { use std::collections::BTreeMap; fn assert_successful_compilation(root: &PathBuf) -> ProjectCompileOutput { - println!("project_root: {:#?}", root); + println!("project_root: {root:#?}"); compile_project(root, false).expect("compilation failure") } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 2fcfbb1dcb6e5..b6a549742c68e 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -146,7 +146,7 @@ impl CoverageArgs { // Collect source files. let project_paths = &project.paths; - let mut versioned_sources = HashMap::::new(); + let mut versioned_sources = HashMap::>::new(); for (path, source_file, version) in output.output().sources.sources_with_version() { report.add_source(version.clone(), source_file.id as usize, path.clone()); diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 6ef37cf102144..3b0bc12bc25e3 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -394,7 +394,7 @@ where B: Clone, { fn clone(&self) -> Self { - ContractDeploymentTx { deployer: self.deployer.clone(), _contract: self._contract } + Self { deployer: self.deployer.clone(), _contract: self._contract } } } @@ -422,7 +422,7 @@ where B: Clone, { fn clone(&self) -> Self { - Deployer { + Self { tx: self.tx.clone(), abi: self.abi.clone(), client: self.client.clone(), @@ -512,7 +512,7 @@ where B: Clone, { fn clone(&self) -> Self { - DeploymentTxFactory { + Self { client: self.client.clone(), abi: self.abi.clone(), bytecode: self.bytecode.clone(), diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 0c9c6f23ae8b1..3cd5abb683bf7 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -32,7 +32,7 @@ pub struct FlattenArgs { impl FlattenArgs { pub fn run(self) -> Result<()> { - let FlattenArgs { target_path, output, project_paths } = self; + let Self { target_path, output, project_paths } = self; // flatten is a subset of `BuildArgs` so we can reuse that to get the config let build_args = CoreBuildArgs { project_paths, ..Default::default() }; diff --git a/crates/forge/bin/cmd/generate/mod.rs b/crates/forge/bin/cmd/generate/mod.rs index fd40a78ae6ca8..2c3a512821ca9 100644 --- a/crates/forge/bin/cmd/generate/mod.rs +++ b/crates/forge/bin/cmd/generate/mod.rs @@ -39,7 +39,7 @@ impl GenerateTestArgs { fs::create_dir_all("test")?; // Define the test file path - let test_file_path = Path::new("test").join(format!("{}.t.sol", contract_name)); + let test_file_path = Path::new("test").join(format!("{contract_name}.t.sol")); // Write the test content to the test file. fs::write(&test_file_path, test_content)?; diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 87010244ccfe6..5c2b56ea8ce14 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -43,7 +43,7 @@ pub struct InitArgs { impl InitArgs { pub fn run(self) -> Result<()> { - let InitArgs { root, template, branch, opts, offline, force, vscode } = self; + let Self { root, template, branch, opts, offline, force, vscode } = self; let DependencyInstallOpts { shallow, no_git, no_commit, quiet } = opts; // create the root dir if it does not exist diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index b76ca2878da60..1c782f8bd865d 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -37,7 +37,7 @@ pub struct InspectArgs { impl InspectArgs { pub fn run(self) -> Result<()> { - let InspectArgs { mut contract, field, build, pretty } = self; + let Self { mut contract, field, build, pretty } = self; trace!(target: "forge", ?field, ?contract, "running forge inspect"); diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index ccec7d5de4f12..57096f8592e6f 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -94,7 +94,7 @@ impl DependencyInstallOpts { /// /// Returns true if any dependency was installed. pub fn install_missing_dependencies(mut self, config: &mut Config) -> bool { - let DependencyInstallOpts { quiet, .. } = self; + let Self { quiet, .. } = self; let lib = config.install_lib_dir(); if self.git(config).has_missing_dependencies(Some(lib)).unwrap_or(false) { // The extra newline is needed, otherwise the compiler output will overwrite the message @@ -114,7 +114,7 @@ impl DependencyInstallOpts { /// Installs all dependencies pub fn install(self, config: &mut Config, dependencies: Vec) -> Result<()> { - let DependencyInstallOpts { no_git, no_commit, quiet, .. } = self; + let Self { no_git, no_commit, quiet, .. } = self; let git = self.git(config); diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index d3cada4b5025f..81188f35be786 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -60,7 +60,7 @@ pub enum SelectorsSubcommands { impl SelectorsSubcommands { pub async fn run(self) -> Result<()> { match self { - SelectorsSubcommands::Upload { contract, all, project_paths } => { + Self::Upload { contract, all, project_paths } => { let build_args = CoreBuildArgs { project_paths: project_paths.clone(), compiler: CompilerArgs { @@ -118,7 +118,7 @@ impl SelectorsSubcommands { } } } - SelectorsSubcommands::Collision { mut first_contract, mut second_contract, build } => { + Self::Collision { mut first_contract, mut second_contract, build } => { // Compile the project with the two contracts included let project = build.project()?; let mut compiler = ProjectCompiler::new().quiet(true); @@ -174,7 +174,7 @@ impl SelectorsSubcommands { println!("{table}"); } } - SelectorsSubcommands::List { contract, project_paths } => { + Self::List { contract, project_paths } => { println!("Listing selectors for contracts in the project..."); let build_args = CoreBuildArgs { project_paths: project_paths.clone(), @@ -199,7 +199,7 @@ impl SelectorsSubcommands { let suggestion = if let Some(suggestion) = foundry_cli::utils::did_you_mean(&contract, candidates).pop() { format!("\nDid you mean `{suggestion}`?") } else { - "".to_string() + String::new() }; eyre::eyre!( "Could not find artifact `{contract}` in the compiled artifacts{suggestion}", diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 5f91951d834ca..8cb5fbb062c84 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -131,7 +131,7 @@ impl FromStr for Format { fn from_str(s: &str) -> Result { match s { - "t" | "table" => Ok(Format::Table), + "t" | "table" => Ok(Self::Table), _ => Err(format!("Unrecognized format `{s}`")), } } @@ -211,7 +211,7 @@ impl FromStr for SnapshotEntry { cap.name("file").and_then(|file| { cap.name("sig").and_then(|sig| { if let Some(gas) = cap.name("gas") { - Some(SnapshotEntry { + Some(Self { contract_name: file.as_str().to_string(), signature: sig.as_str().to_string(), gas_used: TestKindReport::Standard { @@ -221,7 +221,7 @@ impl FromStr for SnapshotEntry { } else if let Some(runs) = cap.name("runs") { cap.name("avg") .and_then(|avg| cap.name("med").map(|med| (runs, avg, med))) - .map(|(runs, avg, med)| SnapshotEntry { + .map(|(runs, avg, med)| Self { contract_name: file.as_str().to_string(), signature: sig.as_str().to_string(), gas_used: TestKindReport::Fuzz { @@ -237,7 +237,7 @@ impl FromStr for SnapshotEntry { cap.name("reverts").map(|med| (runs, avg, med)) }) }) - .map(|(runs, calls, reverts)| SnapshotEntry { + .map(|(runs, calls, reverts)| Self { contract_name: file.as_str().to_string(), signature: sig.as_str().to_string(), gas_used: TestKindReport::Invariant { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index a441b8e6651b4..165a073747665 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -165,7 +165,7 @@ impl TestArgs { let output = project.compile_sparse(Box::new(filter.clone()))?; if output.has_compiler_errors() { - println!("{}", output); + println!("{output}"); eyre::bail!("Compilation failed"); } diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 1412cb15e4f66..e12b42f7b83e8 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -163,7 +163,7 @@ struct WatchTestState { } /// The `on_action` hook for `forge test --watch` -fn on_test(action: OnActionState) { +fn on_test(action: OnActionState<'_, WatchTestState>) { let OnActionState { args, runtime, action, wx, cmd, other } = action; let WatchTestState { project_root, no_reconfigure, last_test_files } = other; diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 29920d735e2ff..8b06f3074c3fe 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -81,7 +81,7 @@ pub struct LcovReporter<'a> { } impl<'a> LcovReporter<'a> { - pub fn new(destination: &'a mut (dyn Write + 'a)) -> LcovReporter<'a> { + pub fn new(destination: &'a mut (dyn Write + 'a)) -> Self { Self { destination } } } @@ -195,7 +195,7 @@ pub struct BytecodeReporter { } impl BytecodeReporter { - pub fn new(root: PathBuf, destdir: PathBuf) -> BytecodeReporter { + pub fn new(root: PathBuf, destdir: PathBuf) -> Self { Self { root, destdir } } } @@ -218,7 +218,7 @@ impl CoverageReporter for BytecodeReporter { let hits = hits .hits .get(&(code.offset as usize)) - .map(|h| format!("[{:03}]", h)) + .map(|h| format!("[{h:03}]")) .unwrap_or(" ".to_owned()); let source_id = source_element.index(); let source_path = source_id.and_then(|i| { @@ -246,13 +246,9 @@ impl CoverageReporter for BytecodeReporter { end )?; } else if let Some(source_id) = source_id { - writeln!( - formatted, - "{} {:40} // SRCID{}: ({}-{})", - hits, code, source_id, start, end - )?; + writeln!(formatted, "{hits} {code:40} // SRCID{source_id}: ({start}-{end})")?; } else { - writeln!(formatted, "{} {:40}", hits, code)?; + writeln!(formatted, "{hits} {code:40}")?; } } fs::write( @@ -273,7 +269,7 @@ struct LineNumberCache { impl LineNumberCache { pub fn new(root: PathBuf) -> Self { - LineNumberCache { root, line_offsets: HashMap::new() } + Self { root, line_offsets: HashMap::new() } } pub fn get_position(&mut self, path: &Path, offset: usize) -> eyre::Result<(usize, usize)> { diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 6a9334b1679c3..56ca432869d0a 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -1,3 +1,6 @@ +#![doc = include_str!("../README.md")] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + #[macro_use] extern crate tracing; diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index cd168c1d7a0f3..9b4a926aaa79b 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -442,13 +442,13 @@ pub enum TestKindReport { impl fmt::Display for TestKindReport { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - TestKindReport::Standard { gas } => { + Self::Standard { gas } => { write!(f, "(gas: {gas})") } - TestKindReport::Fuzz { runs, mean_gas, median_gas } => { + Self::Fuzz { runs, mean_gas, median_gas } => { write!(f, "(runs: {runs}, μ: {mean_gas}, ~: {median_gas})") } - TestKindReport::Invariant { runs, calls, reverts } => { + Self::Invariant { runs, calls, reverts } => { write!(f, "(runs: {runs}, calls: {calls}, reverts: {reverts})") } } @@ -459,11 +459,11 @@ impl TestKindReport { /// Returns the main gas value to compare against pub fn gas(&self) -> u64 { match self { - TestKindReport::Standard { gas } => *gas, + Self::Standard { gas } => *gas, // We use the median for comparisons - TestKindReport::Fuzz { median_gas, .. } => *median_gas, + Self::Fuzz { median_gas, .. } => *median_gas, // We return 0 since it's not applicable - TestKindReport::Invariant { .. } => 0, + Self::Invariant { .. } => 0, } } } @@ -497,11 +497,11 @@ impl TestKind { /// The gas consumed by this test pub fn report(&self) -> TestKindReport { match self { - TestKind::Standard(gas) => TestKindReport::Standard { gas: *gas }, - TestKind::Fuzz { runs, mean_gas, median_gas, .. } => { + Self::Standard(gas) => TestKindReport::Standard { gas: *gas }, + Self::Fuzz { runs, mean_gas, median_gas, .. } => { TestKindReport::Fuzz { runs: *runs, mean_gas: *mean_gas, median_gas: *median_gas } } - TestKind::Invariant { runs, calls, reverts } => { + Self::Invariant { runs, calls, reverts } => { TestKindReport::Invariant { runs: *runs, calls: *calls, reverts: *reverts } } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index e8812dce11a16..31a9ec1fae01c 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -446,7 +446,6 @@ forgetest!(can_set_gas_price, |prj, cmd| { forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); - dbg!(&remappings); similar_asserts::assert_eq!( remappings, vec![ diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index deedcc9abf83a..2f1f1368d1907 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -79,7 +79,7 @@ fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Resul retry.run(|| -> eyre::Result<()> { let output = cmd.unchecked_output(); let out = String::from_utf8_lossy(&output.stdout); - println!("{}", out); + println!("{out}"); if out.contains("Contract successfully verified") { return Ok(()) } diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index cd54526d68ddb..d9f5298b172be 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -39,9 +39,9 @@ pub enum ForgeTestProfile { impl fmt::Display for ForgeTestProfile { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ForgeTestProfile::Default => write!(f, "default"), - ForgeTestProfile::Cancun => write!(f, "cancun"), - ForgeTestProfile::MultiVersion => write!(f, "multi-version"), + Self::Default => write!(f, "default"), + Self::Cancun => write!(f, "cancun"), + Self::MultiVersion => write!(f, "multi-version"), } } } diff --git a/crates/linking/Cargo.toml b/crates/linking/Cargo.toml index 77c54ccf7da89..2587244a23340 100644 --- a/crates/linking/Cargo.toml +++ b/crates/linking/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-compilers = { workspace = true, features = ["full"] } semver = "1" diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index 980dfc8fd791a..25ef8fe1987fa 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -1,4 +1,9 @@ +//! # foundry-linking +//! +//! EVM bytecode linker. + #![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use alloy_primitives::{Address, Bytes, B256}; use foundry_compilers::{ @@ -47,7 +52,7 @@ impl<'a> Linker<'a> { pub fn new( root: impl Into, contracts: ArtifactContracts>, - ) -> Linker<'a> { + ) -> Self { Linker { root: root.into(), contracts } } @@ -397,7 +402,7 @@ mod tests { "incorrect library address for dependency {dep_identifier} of {identifier}" ); } else { - panic!("Library {} not found", dep_identifier); + panic!("Library {dep_identifier} not found"); } } } diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index a2c070c5342d2..671d37be87a0d 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [lib] proc-macro = true # proc-macro tests aren't fully supported by cargo-nextest archives diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index 136b65f5112a4..dbdaa208ce726 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -1,4 +1,9 @@ -#![warn(unused_crate_dependencies)] +//! # foundry-macros +//! +//! Internal Foundry proc-macros. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate proc_macro_error; diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 3d41ac7954786..9c98793926441 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] forge-verify.workspace = true foundry-cli.workspace = true diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 63b2de818bf7d..d9fe5640d952b 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -119,13 +119,13 @@ impl SendTransactionsKind { /// Returns an error if no matching signer is found or the address is not unlocked pub fn for_sender(&self, addr: &Address) -> Result> { match self { - SendTransactionsKind::Unlocked(unlocked) => { + Self::Unlocked(unlocked) => { if !unlocked.contains(addr) { bail!("Sender address {:?} is not unlocked", addr) } Ok(SendTransactionKind::Unlocked(*addr)) } - SendTransactionsKind::Raw(wallets) => { + Self::Raw(wallets) => { if let Some(wallet) = wallets.get(addr) { Ok(SendTransactionKind::Raw(wallet)) } else { @@ -138,8 +138,8 @@ impl SendTransactionsKind { /// How many signers are set pub fn signers_count(&self) -> usize { match self { - SendTransactionsKind::Unlocked(addr) => addr.len(), - SendTransactionsKind::Raw(signers) => signers.len(), + Self::Unlocked(addr) => addr.len(), + Self::Raw(signers) => signers.len(), } } } diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 90e72c66cadac..7a785b6e6466f 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -36,7 +36,7 @@ pub struct BuildData { } impl BuildData { - pub fn get_linker(&self) -> Linker { + pub fn get_linker(&self) -> Linker<'_> { Linker::new(self.project_root.clone(), self.output.artifact_ids().collect()) } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index bd0e2373663ca..3cea29f20279c 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -1,4 +1,9 @@ +//! # foundry-script +//! +//! Smart contract scripting. + #![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/script/src/multi_sequence.rs b/crates/script/src/multi_sequence.rs index ea6dfd0d4c5fa..24490bf017e9b 100644 --- a/crates/script/src/multi_sequence.rs +++ b/crates/script/src/multi_sequence.rs @@ -28,8 +28,8 @@ pub struct SensitiveMultiChainSequence { } impl SensitiveMultiChainSequence { - fn from_multi_sequence(sequence: MultiChainSequence) -> SensitiveMultiChainSequence { - SensitiveMultiChainSequence { + fn from_multi_sequence(sequence: MultiChainSequence) -> Self { + Self { deployments: sequence.deployments.into_iter().map(|sequence| sequence.into()).collect(), } } @@ -43,9 +43,9 @@ impl MultiChainSequence { config: &Config, dry_run: bool, ) -> Result { - let (path, sensitive_path) = MultiChainSequence::get_paths(config, sig, target, dry_run)?; + let (path, sensitive_path) = Self::get_paths(config, sig, target, dry_run)?; - Ok(MultiChainSequence { deployments, path, sensitive_path, timestamp: now().as_secs() }) + Ok(Self { deployments, path, sensitive_path, timestamp: now().as_secs() }) } /// Gets paths in the formats @@ -91,8 +91,8 @@ impl MultiChainSequence { /// Loads the sequences for the multi chain deployment. pub fn load(config: &Config, sig: &str, target: &ArtifactId, dry_run: bool) -> Result { - let (path, sensitive_path) = MultiChainSequence::get_paths(config, sig, target, dry_run)?; - let mut sequence: MultiChainSequence = foundry_compilers::utils::read_json_file(&path) + let (path, sensitive_path) = Self::get_paths(config, sig, target, dry_run)?; + let mut sequence: Self = foundry_compilers::utils::read_json_file(&path) .wrap_err("Multi-chain deployment not found.")?; let sensitive_sequence: SensitiveMultiChainSequence = foundry_compilers::utils::read_json_file(&sensitive_path) diff --git a/crates/script/src/progress.rs b/crates/script/src/progress.rs index c8fd065cb0587..6f028688b8c10 100644 --- a/crates/script/src/progress.rs +++ b/crates/script/src/progress.rs @@ -56,13 +56,7 @@ impl SequenceProgressState { txs.set_position(sequence.receipts.len() as u64); receipts.set_position(sequence.receipts.len() as u64); - let mut state = SequenceProgressState { - top_spinner, - txs, - receipts, - tx_spinners: Default::default(), - multi, - }; + let mut state = Self { top_spinner, txs, receipts, tx_spinners: Default::default(), multi }; for tx_hash in sequence.pending.iter() { state.tx_sent(*tx_hash); diff --git a/crates/script/src/providers.rs b/crates/script/src/providers.rs index aeb94fddf89ba..7f1aa0eb38c97 100644 --- a/crates/script/src/providers.rs +++ b/crates/script/src/providers.rs @@ -55,7 +55,7 @@ pub enum GasPrice { } impl ProviderInfo { - pub async fn new(rpc: &str, mut is_legacy: bool) -> Result { + pub async fn new(rpc: &str, mut is_legacy: bool) -> Result { let provider = Arc::new(get_http_provider(rpc)); let chain = provider.get_chain_id().await?; @@ -73,7 +73,7 @@ impl ProviderInfo { ) }; - Ok(ProviderInfo { provider, chain, gas_price }) + Ok(Self { provider, chain, gas_price }) } /// Returns the gas price to use diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 16f97536b0911..7189f8da44f0e 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -16,9 +16,9 @@ pub enum TxStatus { impl From for TxStatus { fn from(receipt: AnyTransactionReceipt) -> Self { if !receipt.inner.inner.inner.receipt.status { - TxStatus::Revert(receipt) + Self::Revert(receipt) } else { - TxStatus::Success(receipt) + Self::Success(receipt) } } } diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index f98326564ffb6..f653143359a01 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -32,22 +32,22 @@ pub enum ScriptSequenceKind { impl ScriptSequenceKind { pub fn save(&mut self, silent: bool, save_ts: bool) -> Result<()> { match self { - ScriptSequenceKind::Single(sequence) => sequence.save(silent, save_ts), - ScriptSequenceKind::Multi(sequence) => sequence.save(silent, save_ts), + Self::Single(sequence) => sequence.save(silent, save_ts), + Self::Multi(sequence) => sequence.save(silent, save_ts), } } pub fn sequences(&self) -> &[ScriptSequence] { match self { - ScriptSequenceKind::Single(sequence) => std::slice::from_ref(sequence), - ScriptSequenceKind::Multi(sequence) => &sequence.deployments, + Self::Single(sequence) => std::slice::from_ref(sequence), + Self::Multi(sequence) => &sequence.deployments, } } pub fn sequences_mut(&mut self) -> &mut [ScriptSequence] { match self { - ScriptSequenceKind::Single(sequence) => std::slice::from_mut(sequence), - ScriptSequenceKind::Multi(sequence) => &mut sequence.deployments, + Self::Single(sequence) => std::slice::from_mut(sequence), + Self::Multi(sequence) => &mut sequence.deployments, } } /// Updates underlying sequence paths to not be under /dry-run directory. @@ -58,11 +58,11 @@ impl ScriptSequenceKind { target: &ArtifactId, ) -> Result<()> { match self { - ScriptSequenceKind::Single(sequence) => { + Self::Single(sequence) => { sequence.paths = Some(ScriptSequence::get_paths(config, sig, target, sequence.chain, false)?); } - ScriptSequenceKind::Multi(sequence) => { + Self::Multi(sequence) => { (sequence.path, sequence.sensitive_path) = MultiChainSequence::get_paths(config, sig, target, false)?; } @@ -114,7 +114,7 @@ pub struct SensitiveScriptSequence { impl From for SensitiveScriptSequence { fn from(sequence: ScriptSequence) -> Self { - SensitiveScriptSequence { + Self { transactions: sequence .transactions .iter() @@ -133,8 +133,7 @@ impl ScriptSequence { chain_id: u64, dry_run: bool, ) -> Result { - let (path, sensitive_path) = - ScriptSequence::get_paths(config, sig, target, chain_id, dry_run)?; + let (path, sensitive_path) = Self::get_paths(config, sig, target, chain_id, dry_run)?; let mut script_sequence: Self = foundry_compilers::utils::read_json_file(&path) .wrap_err(format!("Deployment not found for chain `{chain_id}`."))?; diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index f5f9399d46a97..fd63734d182c7 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -41,7 +41,7 @@ pub struct TransactionWithMetadata { } fn default_string() -> Option { - Some("".to_string()) + Some(String::new()) } fn default_address() -> Option
{ diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 11dab9575a99a..1e719fecf8b64 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -77,7 +77,7 @@ impl VerifyBundle { let via_ir = config.via_ir; - VerifyBundle { + Self { num_of_optimizations, known_contracts, etherscan: Default::default(), diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index c34faf250c8f8..710050dab76b7 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -11,6 +11,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["project-util"] } diff --git a/crates/test-utils/src/filter.rs b/crates/test-utils/src/filter.rs index e24f87c17523c..003b0170fca84 100644 --- a/crates/test-utils/src/filter.rs +++ b/crates/test-utils/src/filter.rs @@ -13,7 +13,7 @@ pub struct Filter { impl Filter { pub fn new(test_pattern: &str, contract_pattern: &str, path_pattern: &str) -> Self { - Filter { + Self { test_regex: Regex::new(test_pattern) .unwrap_or_else(|_| panic!("Failed to parse test pattern: `{test_pattern}`")), contract_regex: Regex::new(contract_pattern).unwrap_or_else(|_| { @@ -60,7 +60,7 @@ impl Filter { } pub fn matches_all() -> Self { - Filter { + Self { test_regex: Regex::new(".*").unwrap(), contract_regex: Regex::new(".*").unwrap(), path_regex: Regex::new(".*").unwrap(), diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index a4b70f493c5ca..28bb4def123e3 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -1,4 +1,9 @@ -#![warn(unused_crate_dependencies, unreachable_pub)] +//! # foundry-test-utils +//! +//! Internal Foundry testing utilities. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 232417f875707..0bc4d399db527 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -60,7 +60,7 @@ impl ScriptTester { target_contract: &str, ) -> Self { init_tracing(); - ScriptTester::copy_testdata(project_root).unwrap(); + Self::copy_testdata(project_root).unwrap(); init_script_cmd(&mut cmd, project_root, target_contract, endpoint); let mut provider = None; @@ -68,7 +68,7 @@ impl ScriptTester { provider = Some(get_http_provider(endpoint)) } - ScriptTester { + Self { accounts_pub: vec![ Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(), Address::from_str("0x70997970C51812dc3A010C7d01b50e0d17dc79C8").unwrap(), @@ -297,17 +297,17 @@ impl ScriptOutcome { pub fn is_err(&self) -> bool { match self { - ScriptOutcome::OkNoEndpoint | - ScriptOutcome::OkSimulation | - ScriptOutcome::OkBroadcast | - ScriptOutcome::WarnSpecifyDeployer | - ScriptOutcome::OkRun => false, - ScriptOutcome::MissingSender | - ScriptOutcome::MissingWallet | - ScriptOutcome::StaticCallNotAllowed | - ScriptOutcome::UnsupportedLibraries | - ScriptOutcome::ErrorSelectForkOnBroadcast | - ScriptOutcome::ScriptFailed => true, + Self::OkNoEndpoint | + Self::OkSimulation | + Self::OkBroadcast | + Self::WarnSpecifyDeployer | + Self::OkRun => false, + Self::MissingSender | + Self::MissingWallet | + Self::StaticCallNotAllowed | + Self::UnsupportedLibraries | + Self::ErrorSelectForkOnBroadcast | + Self::ScriptFailed => true, } } } diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 0ada068fde28a..b45803e66404b 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -733,18 +733,18 @@ impl TestCommand { } /// Replaces the underlying command. - pub fn set_cmd(&mut self, cmd: Command) -> &mut TestCommand { + pub fn set_cmd(&mut self, cmd: Command) -> &mut Self { self.cmd = cmd; self } /// Resets the command to the default `forge` command. - pub fn forge_fuse(&mut self) -> &mut TestCommand { + pub fn forge_fuse(&mut self) -> &mut Self { self.set_cmd(self.project.forge_bin()) } /// Resets the command to the default `cast` command. - pub fn cast_fuse(&mut self) -> &mut TestCommand { + pub fn cast_fuse(&mut self) -> &mut Self { self.set_cmd(self.project.cast_bin()) } @@ -758,13 +758,13 @@ impl TestCommand { } /// Add an argument to pass to the command. - pub fn arg>(&mut self, arg: A) -> &mut TestCommand { + pub fn arg>(&mut self, arg: A) -> &mut Self { self.cmd.arg(arg); self } /// Add any number of arguments to the command. - pub fn args(&mut self, args: I) -> &mut TestCommand + pub fn args(&mut self, args: I) -> &mut Self where I: IntoIterator, A: AsRef, @@ -773,13 +773,13 @@ impl TestCommand { self } - pub fn stdin(&mut self, fun: impl FnOnce(ChildStdin) + 'static) -> &mut TestCommand { + pub fn stdin(&mut self, fun: impl FnOnce(ChildStdin) + 'static) -> &mut Self { self.stdin_fun = Some(Box::new(fun)); self } /// Convenience function to add `--root project.root()` argument - pub fn root_arg(&mut self) -> &mut TestCommand { + pub fn root_arg(&mut self) -> &mut Self { let root = self.project.root().to_path_buf(); self.arg("--root").arg(root) } @@ -809,7 +809,7 @@ impl TestCommand { /// Note that this does not need to be called normally, since the creation /// of this TestCommand causes its working directory to be set to the /// test's directory automatically. - pub fn current_dir>(&mut self, dir: P) -> &mut TestCommand { + pub fn current_dir>(&mut self, dir: P) -> &mut Self { self.cmd.current_dir(dir); self } diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 54d886f7cea6d..378a292b87998 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-config.workspace = true foundry-cli.workspace = true diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 8a2a49f9c4ae0..4863670186c4f 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -459,7 +459,7 @@ impl VerifyBytecodeArgs { if !self.json { println!( "{} with status {}", - format!("{:?} code matched", bytecode_type).green().bold(), + format!("{bytecode_type:?} code matched").green().bold(), res.1.unwrap().green().bold() ); } else { @@ -475,8 +475,7 @@ impl VerifyBytecodeArgs { println!( "{}", format!( - "{:?} code did not match - this may be due to varying compiler settings", - bytecode_type + "{bytecode_type:?} code did not match - this may be due to varying compiler settings" ) .red() .bold() @@ -491,8 +490,7 @@ impl VerifyBytecodeArgs { matched: false, verification_type: self.verification_type, message: Some(format!( - "{:?} code did not match - this may be due to varying compiler settings", - bytecode_type + "{bytecode_type:?} code did not match - this may be due to varying compiler settings" )), }; json_results.push(json_res); @@ -515,8 +513,8 @@ impl FromStr for VerificationType { fn from_str(s: &str) -> Result { match s { - "full" => Ok(VerificationType::Full), - "partial" => Ok(VerificationType::Partial), + "full" => Ok(Self::Full), + "partial" => Ok(Self::Partial), _ => eyre::bail!("Invalid verification type"), } } @@ -534,8 +532,8 @@ impl From for String { impl fmt::Display for VerificationType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - VerificationType::Full => write!(f, "full"), - VerificationType::Partial => write!(f, "partial"), + Self::Full => write!(f, "full"), + Self::Partial => write!(f, "partial"), } } } diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rs index 200abbf3d46e0..d3edcf62f87a2 100644 --- a/crates/verify/src/lib.rs +++ b/crates/verify/src/lib.rs @@ -1,4 +1,9 @@ +//! # foundry-verify +//! +//! Smart contract verification. + #![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate tracing; @@ -48,7 +53,7 @@ pub struct VerifierArgs { impl Default for VerifierArgs { fn default() -> Self { - VerifierArgs { verifier: VerificationProviderType::Etherscan, verifier_url: None } + Self { verifier: VerificationProviderType::Etherscan, verifier_url: None } } } diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index cc65078d3f7b9..7d29f614666f1 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -118,10 +118,10 @@ impl FromStr for VerificationProviderType { fn from_str(s: &str) -> Result { match s { - "e" | "etherscan" => Ok(VerificationProviderType::Etherscan), - "s" | "sourcify" => Ok(VerificationProviderType::Sourcify), - "b" | "blockscout" => Ok(VerificationProviderType::Blockscout), - "o" | "oklink" => Ok(VerificationProviderType::Oklink), + "e" | "etherscan" => Ok(Self::Etherscan), + "s" | "sourcify" => Ok(Self::Sourcify), + "b" | "blockscout" => Ok(Self::Blockscout), + "o" | "oklink" => Ok(Self::Oklink), _ => Err(format!("Unknown provider: {s}")), } } @@ -130,16 +130,16 @@ impl FromStr for VerificationProviderType { impl fmt::Display for VerificationProviderType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - VerificationProviderType::Etherscan => { + Self::Etherscan => { write!(f, "etherscan")?; } - VerificationProviderType::Sourcify => { + Self::Sourcify => { write!(f, "sourcify")?; } - VerificationProviderType::Blockscout => { + Self::Blockscout => { write!(f, "blockscout")?; } - VerificationProviderType::Oklink => { + Self::Oklink => { write!(f, "oklink")?; } }; @@ -160,19 +160,15 @@ impl VerificationProviderType { /// Returns the corresponding `VerificationProvider` for the key pub fn client(&self, key: &Option) -> Result> { match self { - VerificationProviderType::Etherscan => { + Self::Etherscan => { if key.as_ref().map_or(true, |key| key.is_empty()) { eyre::bail!("ETHERSCAN_API_KEY must be set") } Ok(Box::::default()) } - VerificationProviderType::Sourcify => { - Ok(Box::::default()) - } - VerificationProviderType::Blockscout => { - Ok(Box::::default()) - } - VerificationProviderType::Oklink => Ok(Box::::default()), + Self::Sourcify => Ok(Box::::default()), + Self::Blockscout => Ok(Box::::default()), + Self::Oklink => Ok(Box::::default()), } } } diff --git a/crates/verify/src/retry.rs b/crates/verify/src/retry.rs index 8ffc61b88dc57..528fd74975d8a 100644 --- a/crates/verify/src/retry.rs +++ b/crates/verify/src/retry.rs @@ -37,7 +37,7 @@ impl Default for RetryArgs { impl From for Retry { fn from(r: RetryArgs) -> Self { - Retry::new(r.retries, Some(Duration::from_secs(r.delay as u64))) + Self::new(r.retries, Some(Duration::from_secs(r.delay as u64))) } } diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index a8c7658deb4c0..5a0477253dfa4 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -9,7 +9,12 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] +foundry-config.workspace = true + alloy-primitives.workspace = true alloy-signer = { workspace = true, features = ["eip712"] } alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } @@ -25,15 +30,11 @@ alloy-signer-aws = { workspace = true, features = ["eip712"], optional = true } aws-config = { version = "1", optional = true } # default-features are necessary aws-sdk-kms = { version = "1", default-features = false, optional = true } -foundry-config.workspace = true -foundry-common.workspace = true - async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } derive_builder = "0.20.0" eyre.workspace = true hex = { workspace = true, features = ["serde"] } -itertools.workspace = true rpassword = "7" serde.workspace = true thiserror = "1" diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index 8b341cc3d5a98..e3cc67c6105f0 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -38,6 +38,6 @@ pub enum WalletSignerError { impl WalletSignerError { pub fn aws_unsupported() -> Self { - WalletSignerError::UnsupportedSigner("AWS KMS") + Self::UnsupportedSigner("AWS KMS") } } diff --git a/crates/wallets/src/lib.rs b/crates/wallets/src/lib.rs index 38ff5e7fa91a0..e3be0971e47a9 100644 --- a/crates/wallets/src/lib.rs +++ b/crates/wallets/src/lib.rs @@ -1,3 +1,10 @@ +//! # foundry-wallets +//! +//! Utilities for working with multiple signers. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + #[macro_use] extern crate tracing; diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index 9ab30e1ad4f49..0e0bbf709585e 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -70,10 +70,10 @@ impl WalletSigner { pub async fn available_senders(&self, max: usize) -> Result> { let mut senders = Vec::new(); match self { - WalletSigner::Local(local) => { + Self::Local(local) => { senders.push(local.address()); } - WalletSigner::Ledger(ledger) => { + Self::Ledger(ledger) => { for i in 0..max { if let Ok(address) = ledger.get_address_with_path(&LedgerHDPath::LedgerLive(i)).await @@ -89,7 +89,7 @@ impl WalletSigner { } } } - WalletSigner::Trezor(trezor) => { + Self::Trezor(trezor) => { for i in 0..max { if let Ok(address) = trezor.get_address_with_path(&TrezorHDPath::TrezorLive(i)).await @@ -99,7 +99,7 @@ impl WalletSigner { } } #[cfg(feature = "aws-kms")] - WalletSigner::Aws(aws) => { + Self::Aws(aws) => { senders.push(alloy_signer::Signer::address(aws)); } } From 11d9c1a06343d3e98dffb73c2a0618024f703b4e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:30:10 +0200 Subject: [PATCH 1038/1963] chore: fix rustdoc warnings (#8069) * ci * chore: fix rustdoc warnings --- .github/workflows/deny.yml | 38 +++---- .github/workflows/dependencies.yml | 103 +++++++++--------- .github/workflows/test.yml | 12 +- Cargo.toml | 2 +- crates/anvil/core/src/eth/block.rs | 6 +- crates/anvil/core/src/eth/mod.rs | 10 +- .../core/src/eth/transaction/optimism.rs | 2 +- crates/anvil/rpc/src/error.rs | 16 +-- crates/anvil/rpc/src/response.rs | 2 +- crates/anvil/server/src/ipc.rs | 6 +- crates/anvil/src/cmd.rs | 6 +- crates/anvil/src/config.rs | 11 +- crates/anvil/src/eth/api.rs | 6 +- crates/anvil/src/eth/backend/mem/mod.rs | 7 +- crates/anvil/src/eth/otterscan/api.rs | 10 +- crates/anvil/src/eth/pool/transactions.rs | 6 +- crates/anvil/src/service.rs | 14 +-- crates/anvil/src/tasks/mod.rs | 2 + crates/cast/src/rlp_converter.rs | 7 +- crates/cheatcodes/spec/src/cheatcode.rs | 2 +- crates/cheatcodes/src/env.rs | 2 +- crates/cheatcodes/src/evm.rs | 2 +- crates/cheatcodes/src/fs.rs | 2 +- crates/cheatcodes/src/json.rs | 2 +- crates/cheatcodes/src/lib.rs | 21 +++- crates/cheatcodes/src/script.rs | 4 +- crates/cheatcodes/src/string.rs | 2 +- crates/cheatcodes/src/test.rs | 2 +- crates/cheatcodes/src/toml.rs | 2 +- crates/cheatcodes/src/utils.rs | 2 +- crates/chisel/src/cmd.rs | 6 +- crates/chisel/src/dispatcher.rs | 2 +- crates/chisel/src/executor.rs | 15 +-- crates/chisel/src/lib.rs | 8 -- crates/chisel/src/session.rs | 2 +- crates/chisel/src/session_source.rs | 4 +- crates/cli/src/opts/build/core.rs | 4 +- crates/cli/src/opts/build/mod.rs | 2 +- crates/cli/src/opts/build/paths.rs | 2 +- crates/cli/src/opts/ethereum.rs | 6 +- crates/cli/src/utils/cmd.rs | 2 +- crates/cli/src/utils/mod.rs | 12 +- crates/common/src/errors/fs.rs | 35 +++--- crates/common/src/evm.rs | 4 +- crates/common/src/fmt/dynamic.rs | 4 +- crates/common/src/provider/tower.rs | 2 +- crates/common/src/selectors.rs | 61 ++++++----- crates/common/src/serde_helpers.rs | 6 +- crates/common/src/shell.rs | 4 +- crates/common/src/term.rs | 2 - crates/config/src/endpoints.rs | 4 +- crates/config/src/error.rs | 2 +- crates/config/src/etherscan.rs | 2 +- crates/config/src/fix.rs | 4 +- crates/config/src/inline/error.rs | 5 +- crates/config/src/inline/mod.rs | 8 +- crates/config/src/lib.rs | 96 ++++++++-------- crates/config/src/macros.rs | 10 +- crates/config/src/providers/mod.rs | 2 + crates/doc/src/parser/comment.rs | 5 +- crates/doc/src/preprocessor/inheritdoc.rs | 2 +- crates/doc/src/writer/as_doc.rs | 2 +- crates/evm/core/src/backend/in_memory_db.rs | 13 ++- crates/evm/core/src/backend/mod.rs | 10 +- crates/evm/core/src/decode.rs | 2 +- crates/evm/core/src/fork/cache.rs | 8 +- crates/evm/core/src/fork/mod.rs | 5 +- crates/evm/core/src/opts.rs | 6 +- crates/evm/coverage/src/lib.rs | 25 +++-- crates/evm/evm/src/executors/builder.rs | 10 +- crates/evm/evm/src/executors/mod.rs | 18 +-- crates/evm/evm/src/inspectors/stack.rs | 4 +- crates/evm/fuzz/src/strategies/int.rs | 1 - crates/evm/fuzz/src/strategies/uint.rs | 1 - .../evm/traces/src/identifier/signatures.rs | 6 +- crates/fmt/src/formatter.rs | 9 +- crates/fmt/src/helpers.rs | 10 +- crates/fmt/src/inline_config.rs | 6 +- crates/script/src/broadcast.rs | 5 +- crates/script/src/build.rs | 6 +- crates/script/src/sequence.rs | 4 +- crates/script/src/simulate.rs | 8 +- crates/verify/src/bytecode.rs | 6 +- crates/verify/src/etherscan/flatten.rs | 2 +- 84 files changed, 397 insertions(+), 402 deletions(-) diff --git a/.github/workflows/deny.yml b/.github/workflows/deny.yml index 277b1c9430b3e..e8e4d5b84b1e1 100644 --- a/.github/workflows/deny.yml +++ b/.github/workflows/deny.yml @@ -1,26 +1,26 @@ name: deny on: - push: - branches: [master] - paths: [Cargo.lock, deny.toml] - pull_request: - branches: [master] - paths: [Cargo.lock, deny.toml] + push: + branches: [master] + paths: [Cargo.lock, deny.toml] + pull_request: + branches: [master] + paths: [Cargo.lock, deny.toml] env: - CARGO_TERM_COLOR: always + CARGO_TERM_COLOR: always jobs: - cargo-deny: - name: cargo deny check - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check all - # Clear out arguments to not pass `--all-features` to `cargo deny`. - # many crates have an `openssl` feature which enables banned dependencies - arguments: "" + cargo-deny: + name: cargo deny check + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v1 + with: + command: check all + # Clear out arguments to not pass `--all-features` to `cargo deny`. + # many crates have an `openssl` feature which enables banned dependencies + arguments: "" diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index fd3daf853ea47..ad87a4858767f 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -1,64 +1,61 @@ -# Automatically run `cargo update` periodically +# Runs `cargo update` periodically. name: dependencies on: - schedule: - # Run weekly - - cron: "0 0 * * SUN" - workflow_dispatch: - # Needed so we can run it manually + schedule: + # Run weekly + - cron: "0 0 * * SUN" + workflow_dispatch: + # Needed so we can run it manually env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: cargo-update - TITLE: "chore(deps): weekly `cargo update`" - BODY: | - Automation to keep dependencies in `Cargo.lock` current. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: cargo-update + TITLE: "chore(deps): weekly `cargo update`" + BODY: | + Automation to keep dependencies in `Cargo.lock` current. -
cargo update log -

+

cargo update log +

- ```log - $cargo_update_log - ``` + ```log + $cargo_update_log + ``` -

-
+

+
jobs: - update: - name: Update - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - - - name: cargo update - # Remove first line that always just says "Updating crates.io index" - run: - cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a - cargo_update.log - - - name: craft commit message and PR body - id: msg - run: | - export cargo_update_log="$(cat cargo_update.log)" - - echo "commit_message<> $GITHUB_OUTPUT - printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - echo "body<> $GITHUB_OUTPUT - echo "$BODY" | envsubst >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - add-paths: ./Cargo.lock - commit-message: ${{ steps.msg.outputs.commit_message }} - title: ${{ env.TITLE }} - body: ${{ steps.msg.outputs.body }} - branch: ${{ env.BRANCH }} + update: + name: Update + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + + - name: cargo update + # Remove first line that always just says "Updating crates.io index" + run: cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log + + - name: craft commit message and PR body + id: msg + run: | + export cargo_update_log="$(cat cargo_update.log)" + + echo "commit_message<> $GITHUB_OUTPUT + printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + echo "body<> $GITHUB_OUTPUT + echo "$BODY" | envsubst >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + add-paths: ./Cargo.lock + commit-message: ${{ steps.msg.outputs.commit_message }} + title: ${{ env.TITLE }} + body: ${{ steps.msg.outputs.body }} + branch: ${{ env.BRANCH }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2914175065c3d..01dbc675e69d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,20 +94,18 @@ jobs: docs: runs-on: ubuntu-latest timeout-minutes: 30 - permissions: - contents: write - pages: write steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - run: cargo doc --workspace --all-features --no-deps --document-private-items + - name: Build documentation + run: cargo doc --workspace --all-features --no-deps --document-private-items env: - RUSTDOCFLAGS: - --cfg docsrs --show-type-layout --generate-link-to-definition --enable-index-page - -Zunstable-options + RUSTDOCFLAGS: --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition -Zunstable-options + - name: Doc index page redirection + run: echo '' > target/doc/index.html - name: Deploy documentation uses: peaceiris/actions-gh-pages@v3 if: github.event_name == 'push' && github.ref == 'refs/heads/master' diff --git a/Cargo.toml b/Cargo.toml index 7becafbc7dfc5..e3e35dd0d2be3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ rust-2018-idioms = "deny" unused-must-use = "deny" [workspace.lints.rustdoc] -# all = "warn" +all = "warn" # Speed up compilation time for dev builds by reducing emitted debug info. # NOTE: Debuggers may provide less useful information with this setting. diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index bf96a0df5a8dc..1b0895dcd5f57 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -30,10 +30,10 @@ pub struct Block { } impl Block { - /// Creates a new block + /// Creates a new block. /// - /// Note: if the `impersonate-tx` feature is enabled this will also accept - /// [MaybeImpersonatedTransaction] + /// Note: if the `impersonate-tx` feature is enabled this will also accept + /// `MaybeImpersonatedTransaction`. pub fn new( partial_header: PartialHeader, transactions: impl IntoIterator, diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index dd7d05c973a95..1d39a488f8eeb 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -620,26 +620,26 @@ pub enum EthRequest { /// Returns the number of transactions currently pending for inclusion in the next block(s), as /// well as the ones that are being scheduled for future execution only. - /// Ref: [Here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_status) + /// Ref: #[cfg_attr(feature = "serde", serde(rename = "txpool_status", with = "empty_params"))] TxPoolStatus(()), /// Returns a summary of all the transactions currently pending for inclusion in the next /// block(s), as well as the ones that are being scheduled for future execution only. - /// Ref: [Here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_inspect) + /// Ref: #[cfg_attr(feature = "serde", serde(rename = "txpool_inspect", with = "empty_params"))] TxPoolInspect(()), /// Returns the details of all transactions currently pending for inclusion in the next /// block(s), as well as the ones that are being scheduled for future execution only. - /// Ref: [Here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content) + /// Ref: #[cfg_attr(feature = "serde", serde(rename = "txpool_content", with = "empty_params"))] TxPoolContent(()), /// Otterscan's `ots_getApiLevel` endpoint /// Otterscan currently requires this endpoint, even though it's not part of the ots_* - /// https://github.com/otterscan/otterscan/blob/071d8c55202badf01804f6f8d53ef9311d4a9e47/src/useProvider.ts#L71 - /// Related upstream issue: https://github.com/otterscan/otterscan/issues/1081 + /// + /// Related upstream issue: #[cfg_attr(feature = "serde", serde(rename = "erigon_getHeaderByNumber"))] ErigonGetHeaderByNumber( #[cfg_attr( diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index dedaffaf34589..912bdf26c0845 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -286,7 +286,7 @@ impl DepositTransaction { len } - /// Decodes the inner [TxDeposit] fields from RLP bytes. + /// Decodes the inner fields from RLP bytes /// /// NOTE: This assumes a RLP header has already been decoded, and _just_ decodes the following /// RLP fields in the following order: diff --git a/crates/anvil/rpc/src/error.rs b/crates/anvil/rpc/src/error.rs index 0836b8a27469e..4eec040acf59c 100644 --- a/crates/anvil/rpc/src/error.rs +++ b/crates/anvil/rpc/src/error.rs @@ -14,32 +14,32 @@ pub struct RpcError { } impl RpcError { - /// New [Error] with the given [ErrorCode] + /// New [`RpcError`] with the given [`ErrorCode`]. pub const fn new(code: ErrorCode) -> Self { Self { message: Cow::Borrowed(code.message()), code, data: None } } - /// Creates a new `ParseError` + /// Creates a new `ParseError` error. pub const fn parse_error() -> Self { Self::new(ErrorCode::ParseError) } - /// Creates a new `MethodNotFound` + /// Creates a new `MethodNotFound` error. pub const fn method_not_found() -> Self { Self::new(ErrorCode::MethodNotFound) } - /// Creates a new `InvalidRequest` + /// Creates a new `InvalidRequest` error. pub const fn invalid_request() -> Self { Self::new(ErrorCode::InvalidRequest) } - /// Creates a new `InternalError` + /// Creates a new `InternalError` error. pub const fn internal_error() -> Self { Self::new(ErrorCode::InternalError) } - /// Creates a new `InvalidParams` + /// Creates a new `InvalidParams` error. pub fn invalid_params(message: M) -> Self where M: Into, @@ -47,7 +47,7 @@ impl RpcError { Self { code: ErrorCode::InvalidParams, message: message.into().into(), data: None } } - /// Creates a new `InternalError` with a message + /// Creates a new `InternalError` error with a message. pub fn internal_error_with(message: M) -> Self where M: Into, @@ -55,7 +55,7 @@ impl RpcError { Self { code: ErrorCode::InternalError, message: message.into().into(), data: None } } - /// Creates a new rpc error for when a transaction was rejected + /// Creates a new RPC error for when a transaction was rejected. pub fn transaction_rejected(message: M) -> Self where M: Into, diff --git a/crates/anvil/rpc/src/response.rs b/crates/anvil/rpc/src/response.rs index 49ad70d0dfd28..2fd01327d80a3 100644 --- a/crates/anvil/rpc/src/response.rs +++ b/crates/anvil/rpc/src/response.rs @@ -72,7 +72,7 @@ pub enum Response { } impl Response { - /// Creates new [Response] with the given [Error] + /// Creates new [`Response`] with the given [`RpcError`]. pub fn error(error: RpcError) -> Self { RpcResponse::new(Id::Null, ResponseResult::Error(error)).into() } diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index ddcf5a21f7502..8743f06424d0a 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -28,10 +28,10 @@ impl IpcEndpoint { Self { handler, path } } - /// Returns a stream of incoming connection handlers + /// Returns a stream of incoming connection handlers. /// - /// This establishes the ipc endpoint, converts the incoming connections into handled eth - /// connections, See [`PubSubConnection`] that should be spawned + /// This establishes the IPC endpoint, converts the incoming connections into handled + /// connections. #[instrument(target = "ipc", skip_all)] pub fn incoming(self) -> io::Result>> { let Self { handler, path } = self; diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 5febf290575d5..576c63a9f3e80 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -417,8 +417,7 @@ pub struct AnvilEvmArgs { /// /// default value: 330 /// - /// See --fork-url. - /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second + /// See also --fork-url and #[arg( long, requires = "fork_url", @@ -432,8 +431,7 @@ pub struct AnvilEvmArgs { /// /// default value: false /// - /// See --fork-url. - /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second + /// See also --fork-url and #[arg( long, requires = "fork_url", diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 24a354267e47a..1b332c3a3bb69 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -951,9 +951,9 @@ impl NodeConfig { } /// Configures everything related to forking based on the passed `eth_rpc_url`: - /// - returning a tuple of a [ForkedDatabase](ForkedDatabase) wrapped in an [Arc](Arc) - /// [RwLock](tokio::sync::RwLock) and [ClientFork](ClientFork) wrapped in an [Option](Option) - /// which can be used in a [Backend](mem::Backend) to fork from. + /// - returning a tuple of a [ForkedDatabase] wrapped in an [Arc] [RwLock](tokio::sync::RwLock) + /// and [ClientFork] wrapped in an [Option] which can be used in a [Backend](mem::Backend) to + /// fork from. /// - modifying some parameters of the passed `env` /// - mutating some members of `self` pub async fn setup_fork_db( @@ -973,9 +973,8 @@ impl NodeConfig { } /// Configures everything related to forking based on the passed `eth_rpc_url`: - /// - returning a tuple of a [ForkedDatabase](ForkedDatabase) and - /// [ClientForkConfig](ClientForkConfig) which can be used to build a - /// [ClientFork](ClientFork) to fork from. + /// - returning a tuple of a [ForkedDatabase] and [ClientForkConfig] which can be used to build + /// a [ClientFork] to fork from. /// - modifying some parameters of the passed `env` /// - mutating some members of `self` pub async fn setup_fork_db_config( diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 6d4da2af4b28c..1afb7cd339eff 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -146,7 +146,7 @@ impl EthApi { } } - /// Executes the [EthRequest] and returns an RPC [RpcResponse] + /// Executes the [EthRequest] and returns an RPC [ResponseResult]. pub async fn execute(&self, request: EthRequest) -> ResponseResult { trace!(target: "rpc::api", "executing eth request"); match request { @@ -2196,7 +2196,7 @@ impl EthApi { /// Estimates the gas usage of the `request` with the state. /// - /// This will execute the [CallRequest] and find the best gas limit via binary search + /// This will execute the transaction request and find the best gas limit via binary search. fn do_estimate_gas_with_state( &self, mut request: WithOtherFields, @@ -2643,7 +2643,7 @@ enum GasEstimationCallResult { EvmError(InstructionResult), } -/// Converts the result of a call to revm EVM into a [GasEstimationCallRes]. +/// Converts the result of a call to revm EVM into a [`GasEstimationCallResult`]. impl TryFrom, u128, State)>> for GasEstimationCallResult { type Error = BlockchainError; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 335d1620e7a49..81f4ea6397029 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1,4 +1,5 @@ -//! In memory blockchain backend +//! In-memory blockchain backend. + use self::state::trie_storage; use crate::{ config::PruneStateHistoryConfig, @@ -130,7 +131,7 @@ pub struct Backend { /// the evm during its execution. /// /// At time of writing, there are two different types of `Db`: - /// - [`MemDb`](crate::mem::MemDb): everything is stored in memory + /// - [`MemDb`](crate::mem::in_memory_db::MemDb): everything is stored in memory /// - [`ForkDb`](crate::mem::fork_db::ForkedDatabase): forks off a remote client, missing /// data is retrieved via RPC-calls /// @@ -141,7 +142,7 @@ pub struct Backend { /// potentially blocks for some time, even taking into account the rate limits of RPC /// endpoints. Therefor the `Db` is guarded by a `tokio::sync::RwLock` here so calls that /// need to read from it, while it's currently written to, don't block. E.g. a new block is - /// currently mined and a new [`Self::set_storage()`] request is being executed. + /// currently mined and a new [`Self::set_storage_at()`] request is being executed. db: Arc>>, /// stores all block related data in memory blockchain: Blockchain, diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index d2a1c7f0c1979..dac698a5a17df 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -13,10 +13,10 @@ use alloy_rpc_types_trace::parity::{Action, CreateAction, CreateOutput, TraceOut use itertools::Itertools; impl EthApi { - /// Otterscan currently requires this endpoint, even though it's not part of the ots_* - /// https://github.com/otterscan/otterscan/blob/071d8c55202badf01804f6f8d53ef9311d4a9e47/src/useProvider.ts#L71 + /// Otterscan currently requires this endpoint, even though it's not part of the `ots_*`. + /// Ref: /// - /// As a faster alternative to eth_getBlockByNumber (by excluding uncle block + /// As a faster alternative to `eth_getBlockByNumber` (by excluding uncle block /// information), which is not relevant in the context of an anvil node pub async fn erigon_get_header_by_number(&self, number: BlockNumber) -> Result> { node_info!("ots_getApiLevel"); @@ -24,8 +24,8 @@ impl EthApi { self.backend.block_by_number(number).await } - /// As per the latest Otterscan source code, at least version 8 is needed - /// https://github.com/otterscan/otterscan/blob/071d8c55202badf01804f6f8d53ef9311d4a9e47/src/params.ts#L1C2-L1C2 + /// As per the latest Otterscan source code, at least version 8 is needed. + /// Ref: pub async fn ots_get_api_level(&self) -> Result { node_info!("ots_getApiLevel"); diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 7a1e8e8ab3a8a..026268231a9b3 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -409,12 +409,12 @@ impl ReadyTransactions { id } - /// Adds a new transactions to the ready queue + /// Adds a new transactions to the ready queue. /// /// # Panics /// - /// if the pending transaction is not ready: [PendingTransaction::is_ready()] - /// or the transaction is already included + /// If the pending transaction is not ready ([`PendingPoolTransaction::is_ready`]) + /// or the transaction is already included. pub fn add_transaction( &mut self, tx: PendingPoolTransaction, diff --git a/crates/anvil/src/service.rs b/crates/anvil/src/service.rs index 6f8624d9431c6..0f70ad3b0b4a0 100644 --- a/crates/anvil/src/service.rs +++ b/crates/anvil/src/service.rs @@ -23,17 +23,17 @@ use tokio::{task::JoinHandle, time::Interval}; /// The type that drives the blockchain's state /// /// This service is basically an endless future that continuously polls the miner which returns -/// transactions for the next block, then those transactions are handed off to the -/// [backend](backend::mem::Backend) to construct a new block, if all transactions were successfully -/// included in a new block they get purged from the `Pool`. +/// transactions for the next block, then those transactions are handed off to the backend to +/// construct a new block, if all transactions were successfully included in a new block they get +/// purged from the `Pool`. pub struct NodeService { - /// the pool that holds all transactions + /// The pool that holds all transactions. pool: Arc, - /// creates new blocks + /// Creates new blocks. block_producer: BlockProducer, - /// the miner responsible to select transactions from the `pool´ + /// The miner responsible to select transactions from the `pool`. miner: Miner, - /// maintenance task for fee history related tasks + /// Maintenance task for fee history related tasks. fee_history: FeeHistoryService, /// Tracks all active filters filters: Filters, diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index a63b190163e12..499cb3e67cf0e 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -1,5 +1,7 @@ //! Task management support +#![allow(rustdoc::private_doc_tests)] + use crate::{shutdown::Shutdown, tasks::block_listener::BlockListener, EthApi}; use alloy_network::AnyNetwork; use alloy_primitives::B256; diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index d0d60c08290c6..cab852ab35f15 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -2,9 +2,10 @@ use alloy_rlp::{Buf, Decodable, Encodable, Header}; use serde_json::Value; use std::fmt; -/// Arbitrary nested data -/// Item::Array(vec![]); is equivalent to [] -/// Item::Array(vec![Item::Data(vec![])]); is equivalent to [""] or [null] +/// Arbitrary nested data. +/// +/// - `Item::Array(vec![])` is equivalent to `[]`. +/// - `Item::Array(vec![Item::Data(vec![])])` is equivalent to `[""]` or `[null]`. #[derive(Clone, Debug, PartialEq, Eq)] pub enum Item { Data(Vec), diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index 95aa9aa476578..91573d89ea200 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -2,7 +2,7 @@ use super::Function; use alloy_sol_types::SolCall; use serde::{Deserialize, Serialize}; -/// Cheatcode definition trait. Implemented by all [`Vm`] functions. +/// Cheatcode definition trait. Implemented by all [`Vm`](crate::Vm) functions. pub trait CheatcodeDef: std::fmt::Debug + Clone + SolCall { /// The static cheatcode definition. const CHEATCODE: &'static Cheatcode<'static>; diff --git a/crates/cheatcodes/src/env.rs b/crates/cheatcodes/src/env.rs index b8245dda1d00a..bba8069fb0ac5 100644 --- a/crates/cheatcodes/src/env.rs +++ b/crates/cheatcodes/src/env.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Environment`](crate::Group::Environment) cheatcodes. +//! Implementations of [`Environment`](spec::Group::Environment) cheatcodes. use crate::{string, Cheatcode, Cheatcodes, Error, Result, Vm::*}; use alloy_dyn_abi::DynSolType; diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 7eae7331ba9c4..e652bf28475a1 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Evm`](crate::Group::Evm) cheatcodes. +//! Implementations of [`Evm`](spec::Group::Evm) cheatcodes. use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_genesis::{Genesis, GenesisAccount}; diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 75e0d24678249..c50f2cf9702d3 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Filesystem`](crate::Group::Filesystem) cheatcodes. +//! Implementations of [`Filesystem`](spec::Group::Filesystem) cheatcodes. use super::string::parse; use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index 6b7dd0e97557c..d3c3e95963360 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Json`](crate::Group::Json) cheatcodes. +//! Implementations of [`Json`](spec::Group::Json) cheatcodes. use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 023ef877d7589..be13f0f8ede88 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -19,26 +19,37 @@ pub use config::CheatsConfig; pub use error::{Error, ErrorKind, Result}; pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; pub use spec::{CheatcodeDef, Vm}; +pub use Vm::ForgeContext; #[macro_use] mod error; + mod base64; + mod config; + mod env; +pub use env::set_execution_context; + mod evm; + mod fs; + mod inspector; + mod json; + mod script; +pub use script::{ScriptWallets, ScriptWalletsInner}; + mod string; + mod test; +pub use test::expect::ExpectedCallTracker; + mod toml; -mod utils; -pub use env::set_execution_context; -pub use script::ScriptWallets; -pub use test::expect::ExpectedCallTracker; -pub use Vm::ForgeContext; +mod utils; /// Cheatcode implementation. pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 8eacb52a8e47f..c9195f4492ebd 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Scripting`](crate::Group::Scripting) cheatcodes. +//! Implementations of [`Scripting`](spec::Group::Scripting) cheatcodes. use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, B256, U256}; @@ -83,7 +83,7 @@ pub struct ScriptWalletsInner { pub provided_sender: Option
, } -/// Clonable wrapper around [ScriptWalletsInner]. +/// Clonable wrapper around [`ScriptWalletsInner`]. #[derive(Debug, Clone)] pub struct ScriptWallets { /// Inner data. diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index c98560a72f068..07e9e89f5f6ef 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -1,4 +1,4 @@ -//! Implementations of [`String`](crate::Group::String) cheatcodes. +//! Implementations of [`String`](spec::Group::String) cheatcodes. use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 18487c0aaa82e..cab8b9f8b430d 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Testing`](crate::Group::Testing) cheatcodes. +//! Implementations of [`Testing`](spec::Group::Testing) cheatcodes. use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result, Vm::*}; use alloy_primitives::Address; diff --git a/crates/cheatcodes/src/toml.rs b/crates/cheatcodes/src/toml.rs index 886c38a4a5807..e1827dbef194d 100644 --- a/crates/cheatcodes/src/toml.rs +++ b/crates/cheatcodes/src/toml.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Toml`](crate::Group::Toml) cheatcodes. +//! Implementations of [`Toml`](spec::Group::Toml) cheatcodes. use crate::{ json::{ diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 95a7c6d32bc3a..4785e0197b2d9 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -1,4 +1,4 @@ -//! Implementations of [`Utils`](crate::Group::Utils) cheatcodes. +//! Implementations of [`Utilities`](spec::Group::Utilities) cheatcodes. use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{keccak256, Address, B256, U256}; diff --git a/crates/chisel/src/cmd.rs b/crates/chisel/src/cmd.rs index 86925fc1be416..c13272bc90e2b 100644 --- a/crates/chisel/src/cmd.rs +++ b/crates/chisel/src/cmd.rs @@ -19,10 +19,10 @@ pub enum ChiselCommand { /// Print the generated source contract Source, /// Save the current session to the cache - /// Takes: [session-id] + /// Takes: `` Save, /// Load a previous session from cache - /// Takes: + /// Takes: `` /// /// WARNING: This will overwrite the current session (though the current session will be /// optimistically cached) @@ -45,7 +45,7 @@ pub enum ChiselCommand { /// Export the current REPL session source to a Script file Export, /// Fetch an interface of a verified contract on Etherscan - /// Takes: + /// Takes: ` ` Fetch, /// Executes a shell command Exec, diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 33520e308bd12..5c13c8e01f8d5 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -942,7 +942,7 @@ impl ChiselDispatcher { Ok(()) } - /// Format a type that implements [fmt::Display] as a chisel error string. + /// Format a type that implements [std::fmt::Display] as a chisel error string. /// /// ### Takes /// diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index f9cce49942a7d..a177aa211fcf0 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -279,7 +279,7 @@ impl SessionSource { /// /// ### Takes /// - /// The final statement's program counter for the [ChiselInspector] + /// The final statement's program counter for the ChiselInspector /// /// ### Returns /// @@ -323,17 +323,8 @@ impl SessionSource { } } -/// Formats a [Token] into an inspection message -/// -/// ### Takes -/// -/// An owned [Token] -/// -/// ### Returns -/// -/// A formatted [Token] for use in inspection output. -/// -/// TODO: Verbosity option +/// Formats a value into an inspection message +// TODO: Verbosity option fn format_token(token: DynSolValue) -> String { match token { DynSolValue::Address(a) => { diff --git a/crates/chisel/src/lib.rs b/crates/chisel/src/lib.rs index d0085c327d2d5..9e7dcc9fb829f 100644 --- a/crates/chisel/src/lib.rs +++ b/crates/chisel/src/lib.rs @@ -1,30 +1,22 @@ #![doc = include_str!("../README.md")] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -/// REPL input dispatcher module pub mod dispatcher; -/// Builtin Chisel commands pub mod cmd; pub mod history; -/// Chisel Environment Module pub mod session; -/// Chisel Session Source wrapper pub mod session_source; -/// REPL contract runner pub mod runner; -/// REPL contract executor pub mod executor; -/// A Solidity Helper module for rustyline pub mod solidity_helper; -/// Prelude of all chisel modules pub mod prelude { pub use crate::{ cmd::*, dispatcher::*, runner::*, session::*, session_source::*, solidity_helper::*, diff --git a/crates/chisel/src/session.rs b/crates/chisel/src/session.rs index e0865e28a267a..2f293c1cd9172 100644 --- a/crates/chisel/src/session.rs +++ b/crates/chisel/src/session.rs @@ -247,7 +247,7 @@ impl ChiselSession { } /// Generic helper function that attempts to convert a type that has -/// an [Into] implementation into a formatted date string. +/// an [`Into`] implementation into a formatted date string. fn systemtime_strftime(dt: T, format: &str) -> Result where T: Into, diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index b8ba084cd62a2..500cd97ef00be 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -303,11 +303,11 @@ impl SessionSource { self } - /// Generates and foundry_compilers::CompilerInput from the source + /// Generates and [`SolcInput`] from the source. /// /// ### Returns /// - /// A [CompilerInput] object containing forge-std's `Vm` interface as well as the REPL contract + /// A [`SolcInput`] object containing forge-std's `Vm` interface as well as the REPL contract /// source. pub fn compiler_input(&self) -> SolcInput { let mut sources = Sources::new(); diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index a3143144dd328..3d45de22577d8 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -131,8 +131,8 @@ impl CoreBuildArgs { /// Returns the `Project` for the current workspace /// /// This loads the `foundry_config::Config` for the current workspace (see - /// [`utils::find_project_root_path`] and merges the cli `BuildArgs` into it before returning - /// [`foundry_config::Config::project()`] + /// `find_project_root_path` and merges the cli `BuildArgs` into it before returning + /// [`foundry_config::Config::project()`]). pub fn project(&self) -> Result> { let config = self.try_load_config_emit_warnings()?; Ok(config.project()?) diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index e752ae53fec68..2ed2ea4630dd3 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -39,7 +39,7 @@ pub struct CompilerArgs { /// /// Example keys: evm.assembly, ewasm, ir, irOptimized, metadata /// - /// For a full description, see https://docs.soliditylang.org/en/v0.8.13/using-the-compiler.html#input-description + /// For a full description, see #[arg(long, num_args(1..), value_name = "SELECTOR")] #[serde(skip_serializing_if = "Vec::is_empty")] pub extra_output: Vec, diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index 9497427518f34..9ec2dc0013665 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -64,7 +64,7 @@ pub struct ProjectPathsArgs { } impl ProjectPathsArgs { - /// Returns the root directory to use for configuring the [Project] + /// Returns the root directory to use for configuring the project. /// /// This will be the `--root` argument if provided, otherwise see [find_project_root_path()] /// diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 272d3a5a2aede..c4e8f08875df0 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -21,9 +21,11 @@ pub struct RpcOpts { #[arg(short = 'r', long = "rpc-url", env = "ETH_RPC_URL")] pub url: Option, - /// Use the Flashbots RPC URL with fast mode (https://rpc.flashbots.net/fast). + /// Use the Flashbots RPC URL with fast mode (). + /// /// This shares the transaction privately with all registered builders. - /// https://docs.flashbots.net/flashbots-protect/quick-start#faster-transactions + /// + /// See: #[arg(long)] pub flashbots: bool, diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 6c010655b8525..05e6ad0ae614c 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -192,7 +192,7 @@ pub fn has_batch_support(chain_id: u64) -> bool { /// Helpers for loading configuration. /// /// This is usually implicitly implemented on a "&CmdArgs" struct via impl macros defined in -/// `forge_config` (See [`forge_config::impl_figment_convert`] for more details) and the impl +/// `forge_config` (see [`foundry_config::impl_figment_convert`] for more details) and the impl /// definition on `T: Into + Into` below. /// /// Each function also has an `emit_warnings` form which does the same thing as its counterpart but diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 34333e5931081..a840a10c24c73 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -3,6 +3,7 @@ use alloy_primitives::U256; use alloy_provider::{network::AnyNetwork, Provider}; use alloy_transport::Transport; use eyre::{ContextCompat, Result}; +use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_config::{Chain, Config}; use std::{ ffi::OsStr, @@ -81,19 +82,18 @@ pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { Ok(s) } -/// Returns a [RetryProvider](foundry_common::RetryProvider) instantiated using [Config]'s +/// Returns a [RetryProvider] instantiated using [Config]'s /// RPC -pub fn get_provider(config: &Config) -> Result { +pub fn get_provider(config: &Config) -> Result { get_provider_builder(config)?.build() } -/// Returns a [ProviderBuilder](foundry_common::provider::ProviderBuilder) instantiated using -/// [Config] values. +/// Returns a [ProviderBuilder] instantiated using [Config] values. /// /// Defaults to `http://localhost:8545` and `Mainnet`. -pub fn get_provider_builder(config: &Config) -> Result { +pub fn get_provider_builder(config: &Config) -> Result { let url = config.get_rpc_url_or_localhost_http()?; - let mut builder = foundry_common::provider::ProviderBuilder::new(url.as_ref()); + let mut builder = ProviderBuilder::new(url.as_ref()); if let Ok(chain) = config.chain.unwrap_or_default().try_into() { builder = builder.chain(chain); diff --git a/crates/common/src/errors/fs.rs b/crates/common/src/errors/fs.rs index 1e466171e12c2..9ea84b9ce4444 100644 --- a/crates/common/src/errors/fs.rs +++ b/crates/common/src/errors/fs.rs @@ -3,36 +3,39 @@ use std::{ path::{Path, PathBuf}, }; -/// Various error variants for `std::fs` operations that serve as an addition to the io::Error which +#[allow(unused_imports)] +use std::fs::{self, File}; + +/// Various error variants for `fs` operations that serve as an addition to the io::Error which /// does not provide any information about the path. #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] pub enum FsPathError { - /// Provides additional path context for [`std::fs::write`]. + /// Provides additional path context for [`fs::write`]. #[error("failed to write to {path:?}: {source}")] Write { source: io::Error, path: PathBuf }, - /// Provides additional path context for [`std::fs::read`]. + /// Provides additional path context for [`fs::read`]. #[error("failed to read from {path:?}: {source}")] Read { source: io::Error, path: PathBuf }, - /// Provides additional path context for [`std::fs::copy`]. + /// Provides additional path context for [`fs::copy`]. #[error("failed to copy from {from:?} to {to:?}: {source}")] Copy { source: io::Error, from: PathBuf, to: PathBuf }, - /// Provides additional path context for [`std::fs::read_link`]. + /// Provides additional path context for [`fs::read_link`]. #[error("failed to read from {path:?}: {source}")] ReadLink { source: io::Error, path: PathBuf }, /// Provides additional path context for [`File::create`]. #[error("failed to create file {path:?}: {source}")] CreateFile { source: io::Error, path: PathBuf }, - /// Provides additional path context for [`std::fs::remove_file`]. + /// Provides additional path context for [`fs::remove_file`]. #[error("failed to remove file {path:?}: {source}")] RemoveFile { source: io::Error, path: PathBuf }, - /// Provides additional path context for [`std::fs::create_dir`]. + /// Provides additional path context for [`fs::create_dir`]. #[error("failed to create dir {path:?}: {source}")] CreateDir { source: io::Error, path: PathBuf }, - /// Provides additional path context for [`std::fs::remove_dir`]. + /// Provides additional path context for [`fs::remove_dir`]. #[error("failed to remove dir {path:?}: {source}")] RemoveDir { source: io::Error, path: PathBuf }, - /// Provides additional path context for [`std::fs::File::open`]. + /// Provides additional path context for [`File::open`]. #[error("failed to open file {path:?}: {source}")] Open { source: io::Error, path: PathBuf }, /// Provides additional path context for the file whose contents should be parsed as JSON. @@ -44,22 +47,22 @@ pub enum FsPathError { } impl FsPathError { - /// Returns the complementary error variant for [`std::fs::write`]. + /// Returns the complementary error variant for [`fs::write`]. pub fn write(source: io::Error, path: impl Into) -> Self { Self::Write { source, path: path.into() } } - /// Returns the complementary error variant for [`std::fs::read`]. + /// Returns the complementary error variant for [`fs::read`]. pub fn read(source: io::Error, path: impl Into) -> Self { Self::Read { source, path: path.into() } } - /// Returns the complementary error variant for [`std::fs::copy`]. + /// Returns the complementary error variant for [`fs::copy`]. pub fn copy(source: io::Error, from: impl Into, to: impl Into) -> Self { Self::Copy { source, from: from.into(), to: to.into() } } - /// Returns the complementary error variant for [`std::fs::read_link`]. + /// Returns the complementary error variant for [`fs::read_link`]. pub fn read_link(source: io::Error, path: impl Into) -> Self { Self::ReadLink { source, path: path.into() } } @@ -69,17 +72,17 @@ impl FsPathError { Self::CreateFile { source, path: path.into() } } - /// Returns the complementary error variant for [`std::fs::remove_file`]. + /// Returns the complementary error variant for [`fs::remove_file`]. pub fn remove_file(source: io::Error, path: impl Into) -> Self { Self::RemoveFile { source, path: path.into() } } - /// Returns the complementary error variant for [`std::fs::create_dir`]. + /// Returns the complementary error variant for [`fs::create_dir`]. pub fn create_dir(source: io::Error, path: impl Into) -> Self { Self::CreateDir { source, path: path.into() } } - /// Returns the complementary error variant for [`std::fs::remove_dir`]. + /// Returns the complementary error variant for [`fs::remove_dir`]. pub fn remove_dir(source: io::Error, path: impl Into) -> Self { Self::RemoveDir { source, path: path.into() } } diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index a0cc4d4b802f3..98355c890da59 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -117,13 +117,13 @@ pub struct EvmArgs { /// /// default value: 330 /// - /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second + /// See also --fork-url and #[arg(long, alias = "cups", value_name = "CUPS", help_heading = "Fork config")] pub compute_units_per_second: Option, /// Disables rate limiting for this node's provider. /// - /// See also --fork-url and https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second + /// See also --fork-url and #[arg( long, value_name = "NO_RATE_LIMITS", diff --git a/crates/common/src/fmt/dynamic.rs b/crates/common/src/fmt/dynamic.rs index 2e30f2f7e5ee5..19330d47446e1 100644 --- a/crates/common/src/fmt/dynamic.rs +++ b/crates/common/src/fmt/dynamic.rs @@ -85,7 +85,7 @@ impl DynValueFormatter { } } -/// Wrapper that implements [`Display`] for a [`DynSolValue`]. +/// Wrapper that implements [`Display`](fmt::Display) for a [`DynSolValue`]. struct DynValueDisplay<'a> { /// The value to display. value: &'a DynSolValue, @@ -94,7 +94,7 @@ struct DynValueDisplay<'a> { } impl<'a> DynValueDisplay<'a> { - /// Creates a new [`Display`] wrapper for the given value. + /// Creates a new [`Display`](fmt::Display) wrapper for the given value. #[inline] fn new(value: &'a DynSolValue, raw: bool) -> Self { Self { value, formatter: DynValueFormatter { raw } } diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs index 2f97d2f8fbd11..bb64ee8ab828b 100644 --- a/crates/common/src/provider/tower.rs +++ b/crates/common/src/provider/tower.rs @@ -31,7 +31,7 @@ pub struct RetryBackoffLayer { } impl RetryBackoffLayer { - /// Creates a new [RetryWithPolicyLayer] with the given parameters + /// Creates a new retry layer with the given parameters. pub fn new( max_rate_limit_retries: u32, max_timeout_retries: u32, diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index bf820a4125b2c..a051db1f0a30e 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -19,15 +19,15 @@ use std::{ const SELECTOR_LOOKUP_URL: &str = "https://api.openchain.xyz/signature-database/v1/lookup"; const SELECTOR_IMPORT_URL: &str = "https://api.openchain.xyz/signature-database/v1/import"; -/// The standard request timeout for API requests +/// The standard request timeout for API requests. const REQ_TIMEOUT: Duration = Duration::from_secs(15); -/// How many request can time out before we decide this is a spurious connection +/// How many request can time out before we decide this is a spurious connection. const MAX_TIMEDOUT_REQ: usize = 4usize; -/// A client that can request API data from `https://api.openchain.xyz` +/// A client that can request API data from OpenChain. #[derive(Clone, Debug)] -pub struct SignEthClient { +pub struct OpenChainClient { inner: reqwest::Client, /// Whether the connection is spurious, or API is down spurious_connection: Arc, @@ -37,7 +37,7 @@ pub struct SignEthClient { max_timedout_requests: usize, } -impl SignEthClient { +impl OpenChainClient { /// Creates a new client with default settings pub fn new() -> reqwest::Result { let inner = reqwest::Client::builder() @@ -113,7 +113,7 @@ impl SignEthClient { } if is_connectivity_err(err) { - warn!("spurious network detected for https://api.openchain.xyz"); + warn!("spurious network detected for OpenChain"); let previous = self.timedout_requests.fetch_add(1, Ordering::SeqCst); if previous >= self.max_timedout_requests { self.set_spurious(); @@ -138,7 +138,7 @@ impl SignEthClient { Ok(()) } - /// Decodes the given function or event selector using https://api.openchain.xyz + /// Decodes the given function or event selector using OpenChain pub async fn decode_selector( &self, selector: &str, @@ -151,7 +151,7 @@ impl SignEthClient { .ok_or_else(|| eyre::eyre!("No signature found")) } - /// Decodes the given function or event selectors using https://api.openchain.xyz + /// Decodes the given function or event selectors using OpenChain pub async fn decode_selectors( &self, selector_type: SelectorType, @@ -201,8 +201,6 @@ impl SignEthClient { result: ApiResult, } - // using openchain.xyz signature database over 4byte - // see https://github.com/foundry-rs/foundry/issues/1672 let url = format!( "{SELECTOR_LOOKUP_URL}?{ltype}={selectors_str}", ltype = match selector_type { @@ -238,7 +236,7 @@ impl SignEthClient { .collect()) } - /// Fetches a function signature given the selector using https://api.openchain.xyz + /// Fetches a function signature given the selector using OpenChain pub async fn decode_function_selector(&self, selector: &str) -> eyre::Result> { self.decode_selector(selector, SelectorType::Function).await } @@ -263,7 +261,7 @@ impl SignEthClient { .collect::>()) } - /// Fetches an event signature given the 32 byte topic using https://api.openchain.xyz + /// Fetches an event signature given the 32 byte topic using OpenChain pub async fn decode_event_topic(&self, topic: &str) -> eyre::Result> { self.decode_selector(topic, SelectorType::Event).await } @@ -271,10 +269,10 @@ impl SignEthClient { /// Pretty print calldata and if available, fetch possible function signatures /// /// ```no_run - /// use foundry_common::selectors::SignEthClient; + /// use foundry_common::selectors::OpenChainClient; /// /// # async fn foo() -> eyre::Result<()> { - /// let pretty_data = SignEthClient::new()? + /// let pretty_data = OpenChainClient::new()? /// .pretty_calldata( /// "0x70a08231000000000000000000000000d0074f4e6490ae3f888d1d4f7e3e43326bd3f0f5" /// .to_string(), @@ -320,7 +318,7 @@ impl SignEthClient { Ok(possible_info) } - /// uploads selectors to https://api.openchain.xyz using the given data + /// uploads selectors to OpenChain using the given data pub async fn import_selectors( &self, data: SelectorImportData, @@ -397,44 +395,47 @@ impl fmt::Display for PossibleSigs { } } +/// The type of selector fetched from OpenChain. #[derive(Clone, Copy)] pub enum SelectorType { + /// A function selector. Function, + /// An event selector. Event, } -/// Decodes the given function or event selector using https://api.openchain.xyz +/// Decodes the given function or event selector using OpenChain. pub async fn decode_selector( selector_type: SelectorType, selector: &str, ) -> eyre::Result> { - SignEthClient::new()?.decode_selector(selector, selector_type).await + OpenChainClient::new()?.decode_selector(selector, selector_type).await } -/// Decodes the given function or event selectors using https://api.openchain.xyz +/// Decodes the given function or event selectors using OpenChain. pub async fn decode_selectors( selector_type: SelectorType, selectors: impl IntoIterator>, ) -> eyre::Result>>> { - SignEthClient::new()?.decode_selectors(selector_type, selectors).await + OpenChainClient::new()?.decode_selectors(selector_type, selectors).await } -/// Fetches a function signature given the selector https://api.openchain.xyz +/// Fetches a function signature given the selector using OpenChain. pub async fn decode_function_selector(selector: &str) -> eyre::Result> { - SignEthClient::new()?.decode_function_selector(selector).await + OpenChainClient::new()?.decode_function_selector(selector).await } -/// Fetches all possible signatures and attempts to abi decode the calldata +/// Fetches all possible signatures and attempts to abi decode the calldata using OpenChain. pub async fn decode_calldata(calldata: &str) -> eyre::Result> { - SignEthClient::new()?.decode_calldata(calldata).await + OpenChainClient::new()?.decode_calldata(calldata).await } -/// Fetches an event signature given the 32 byte topic using https://api.openchain.xyz +/// Fetches an event signature given the 32 byte topic using OpenChain. pub async fn decode_event_topic(topic: &str) -> eyre::Result> { - SignEthClient::new()?.decode_event_topic(topic).await + OpenChainClient::new()?.decode_event_topic(topic).await } -/// Pretty print calldata and if available, fetch possible function signatures +/// Pretty print calldata and if available, fetch possible function signatures. /// /// ```no_run /// use foundry_common::selectors::pretty_calldata; @@ -453,7 +454,7 @@ pub async fn pretty_calldata( calldata: impl AsRef, offline: bool, ) -> eyre::Result { - SignEthClient::new()?.pretty_calldata(calldata, offline).await + OpenChainClient::new()?.pretty_calldata(calldata, offline).await } #[derive(Debug, Default, PartialEq, Eq, Serialize)] @@ -519,13 +520,13 @@ impl SelectorImportResponse { .iter() .for_each(|(k, v)| println!("Duplicated: Event {k}: {v}")); - println!("Selectors successfully uploaded to https://api.openchain.xyz"); + println!("Selectors successfully uploaded to OpenChain"); } } -/// uploads selectors to https://api.openchain.xyz using the given data +/// uploads selectors to OpenChain using the given data pub async fn import_selectors(data: SelectorImportData) -> eyre::Result { - SignEthClient::new()?.import_selectors(data).await + OpenChainClient::new()?.import_selectors(data).await } #[derive(Debug, Default, PartialEq)] diff --git a/crates/common/src/serde_helpers.rs b/crates/common/src/serde_helpers.rs index 776d049c4a946..a7cc8bee12308 100644 --- a/crates/common/src/serde_helpers.rs +++ b/crates/common/src/serde_helpers.rs @@ -82,11 +82,11 @@ where #[derive(Deserialize)] #[serde(untagged)] pub enum NumericSeq { - /// Single parameter sequence (e.g [1]) + /// Single parameter sequence (e.g `[1]`). Seq([Numeric; 1]), - /// U256 + /// `U256`. U256(U256), - /// Native u64 + /// Native `u64`. Num(u64), } diff --git a/crates/common/src/shell.rs b/crates/common/src/shell.rs index ac5ff1b969056..898b154fad9a4 100644 --- a/crates/common/src/shell.rs +++ b/crates/common/src/shell.rs @@ -103,14 +103,14 @@ impl Shell { /// Write a fragment to stdout /// - /// Caller is responsible for deciding whether [`Shell::verbosity`] is affects output. + /// Caller is responsible for deciding whether [`Shell`] verbosity affects output. pub fn write_stdout(&self, fragment: impl fmt::Display) -> io::Result<()> { self.output.write_stdout(fragment) } /// Write a fragment to stderr /// - /// Caller is responsible for deciding whether [`Shell::verbosity`] is affects output. + /// Caller is responsible for deciding whether [`Shell`] verbosity affects output. pub fn write_stderr(&self, fragment: impl fmt::Display) -> io::Result<()> { self.output.write_stderr(fragment) } diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 4057a504fe2d3..3fcc8f7fb9602 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -166,12 +166,10 @@ impl Reporter for SpinnerReporter { )); } - /// Invoked before a new [`Solc`] bin is installed fn on_solc_installation_start(&self, version: &Version) { self.send_msg(format!("Installing Solc version {version}")); } - /// Invoked before a new [`Solc`] bin was successfully installed fn on_solc_installation_success(&self, version: &Version) { self.send_msg(format!("Successfully installed Solc {version}")); } diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index f29e72545b55a..74157b0e918ce 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -233,7 +233,7 @@ pub struct RpcEndpointConfig { } impl RpcEndpointConfig { - /// Returns the url this type holds, see [RpcEndpoints::resolve()] + /// Returns the url this type holds, see [`RpcEndpoint::resolve`] pub fn resolve(self) -> Result { self.endpoint.resolve() } @@ -329,7 +329,7 @@ impl Default for RpcEndpointConfig { } } -/// Container type for _resolved_ endpoints, see [RpcEndpoints::resolve_all()] +/// Container type for _resolved_ endpoints, see [`RpcEndpoint::resolve`]. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ResolvedRpcEndpoints { /// contains all named endpoints and their URL or an error if we failed to resolve the env var diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index fe193171a33f6..0f6dae9bf0ad9 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -110,7 +110,7 @@ pub enum SolidityErrorCode { ContractExceeds24576Bytes, /// Warning after shanghai if init code size exceeds 49152 bytes ContractInitCodeSizeExceeds49152Bytes, - /// Warning that Function state mutability can be restricted to [view,pure] + /// Warning that Function state mutability can be restricted to view/pure. FunctionStateMutabilityCanBeRestricted, /// Warning: Unused local variable UnusedLocalVariable, diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index 8863ad059a796..c4f3fe700ea91 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -111,7 +111,7 @@ impl DerefMut for EtherscanConfigs { } } -/// Container type for _resolved_ etherscan keys, see [EtherscanConfigs::resolve_all()] +/// Container type for _resolved_ etherscan keys, see [`EtherscanConfigs::resolved`]. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ResolvedEtherscanConfigs { /// contains all named `ResolvedEtherscanConfig` or an error if we failed to resolve the env diff --git a/crates/config/src/fix.rs b/crates/config/src/fix.rs index a49097c8f34d4..73d52d979cbc8 100644 --- a/crates/config/src/fix.rs +++ b/crates/config/src/fix.rs @@ -1,4 +1,4 @@ -//! Helpers to automatically fix configuration warnings +//! Helpers to automatically fix configuration warnings. use crate::{Config, Warning}; use figment::providers::Env; @@ -51,7 +51,7 @@ impl DerefMut for TomlFile { } } -/// The error emitted when failing to insert a profile into [profile] +/// The error emitted when failing to insert into a profile. #[derive(Debug)] struct InsertProfileError { pub message: String, diff --git a/crates/config/src/inline/error.rs b/crates/config/src/inline/error.rs index e998a2156d8cd..ddcb6a61bdb89 100644 --- a/crates/config/src/inline/error.rs +++ b/crates/config/src/inline/error.rs @@ -1,4 +1,4 @@ -/// Errors returned by the [`InlineConfigParser`] trait. +/// Errors returned by the [`InlineConfigParser`](crate::InlineConfigParser) trait. #[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)] pub enum InlineConfigParserError { /// An invalid configuration property has been provided. @@ -16,8 +16,7 @@ pub enum InlineConfigParserError { ParseBool(String, String), } -/// Wrapper error struct that catches config parsing -/// errors [`InlineConfigParserError`], enriching them with context information +/// Wrapper error struct that catches config parsing errors, enriching them with context information /// reporting the misconfigured line. #[derive(Debug, thiserror::Error)] #[error("Inline config error detected at {line}")] diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index f2222901f9065..adc67424fc864 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -1,13 +1,15 @@ use crate::Config; -pub use conf_parser::{parse_config_bool, parse_config_u32, validate_profiles, InlineConfigParser}; -pub use error::{InlineConfigError, InlineConfigParserError}; -pub use natspec::NatSpec; use once_cell::sync::Lazy; use std::collections::HashMap; mod conf_parser; +pub use conf_parser::*; + mod error; +pub use error::*; + mod natspec; +pub use natspec::*; pub const INLINE_CONFIG_FUZZ_KEY: &str = "fuzz"; pub const INLINE_CONFIG_INVARIANT_KEY: &str = "invariant"; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 6d64e36251079..2d658894b3e3b 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -47,17 +47,19 @@ use std::{ str::FromStr, }; -// Macros useful for creating a figment. mod macros; -// Utilities for making it easier to handle tests. pub mod utils; -pub use crate::utils::*; +pub use utils::*; mod endpoints; pub use endpoints::{ResolvedRpcEndpoints, RpcEndpoint, RpcEndpoints}; mod etherscan; +use etherscan::{ + EtherscanConfigError, EtherscanConfigs, EtherscanEnvProvider, ResolvedEtherscanConfig, +}; + mod resolve; pub use resolve::UnresolvedEnvVarError; @@ -68,9 +70,11 @@ pub mod fmt; pub use fmt::FormatterConfig; pub mod fs_permissions; -pub use crate::fs_permissions::FsPermissions; +pub use fs_permissions::FsPermissions; +use fs_permissions::PathPermission; pub mod error; +use error::ExtractConfigError; pub use error::SolidityErrorCode; pub mod doc; @@ -79,36 +83,25 @@ pub use doc::DocConfig; mod warning; pub use warning::*; -// helpers for fixing configuration warnings pub mod fix; // reexport so cli types can implement `figment::Provider` to easily merge compiler arguments pub use alloy_chains::{Chain, NamedChain}; pub use figment; -/// config providers pub mod providers; +use providers::{remappings::RemappingsProvider, FallbackProfileProvider, WarningsProvider}; -/// compilers supported by foundry -pub mod language; +mod language; pub use language::Language; -use crate::{ - error::ExtractConfigError, - etherscan::{EtherscanConfigError, EtherscanConfigs, ResolvedEtherscanConfig}, -}; -use providers::*; - mod fuzz; pub use fuzz::{FuzzConfig, FuzzDictionaryConfig}; mod invariant; -use crate::fs_permissions::PathPermission; pub use invariant::InvariantConfig; -use providers::remappings::RemappingsProvider; mod inline; -use crate::etherscan::EtherscanEnvProvider; pub use inline::{validate_profiles, InlineConfig, InlineConfigError, InlineConfigParser, NatSpec}; /// Foundry configuration @@ -193,7 +186,7 @@ pub struct Config { /// auto-detection. /// /// **Note** for backwards compatibility reasons this also accepts solc_version from the toml - /// file, see [`BackwardsCompatProvider`] + /// file, see `BackwardsCompatTomlProvider`. pub solc: Option, /// The Vyper instance to use if any. pub vyper: Option, @@ -369,8 +362,7 @@ pub struct Config { /// Whether to compile in sparse mode /// /// If this option is enabled, only the required contracts/files will be selected to be - /// included in solc's output selection, see also - /// [OutputSelection](foundry_compilers::artifacts::output_selection::OutputSelection) + /// included in solc's output selection, see also [`OutputSelection`]. pub sparse_mode: bool, /// Generates additional build info json files for every new build, containing the /// `CompilerInput` and `CompilerOutput`. @@ -952,7 +944,7 @@ impl Config { Ok(MultiCompilerSettings { solc: self.solc_settings()?, vyper: self.vyper_settings()? }) } - /// Returns all configured [`Remappings`] + /// Returns all configured remappings. /// /// **Note:** this will add an additional `/=` remapping here, see /// [Self::get_source_dir_remapping()] @@ -1491,77 +1483,77 @@ impl Config { toml::to_string_pretty(&toml::Value::Table(wrapping_table)) } - /// Returns the path to the `foundry.toml` of this `Config` + /// Returns the path to the `foundry.toml` of this `Config`. pub fn get_config_path(&self) -> PathBuf { self.__root.0.join(Config::FILE_NAME) } - /// Returns the selected profile + /// Returns the selected profile. /// - /// If the `FOUNDRY_PROFILE` env variable is not set, this returns the `DEFAULT_PROFILE` + /// If the `FOUNDRY_PROFILE` env variable is not set, this returns the `DEFAULT_PROFILE`. pub fn selected_profile() -> Profile { Profile::from_env_or("FOUNDRY_PROFILE", Config::DEFAULT_PROFILE) } - /// Returns the path to foundry's global toml file that's stored at `~/.foundry/foundry.toml` + /// Returns the path to foundry's global TOML file: `~/.foundry/foundry.toml`. pub fn foundry_dir_toml() -> Option { Self::foundry_dir().map(|p| p.join(Config::FILE_NAME)) } - /// Returns the path to foundry's config dir `~/.foundry/` + /// Returns the path to foundry's config dir: `~/.foundry/`. pub fn foundry_dir() -> Option { dirs_next::home_dir().map(|p| p.join(Config::FOUNDRY_DIR_NAME)) } - /// Returns the path to foundry's cache dir `~/.foundry/cache` + /// Returns the path to foundry's cache dir: `~/.foundry/cache`. pub fn foundry_cache_dir() -> Option { Self::foundry_dir().map(|p| p.join("cache")) } - /// Returns the path to foundry rpc cache dir `~/.foundry/cache/rpc` + /// Returns the path to foundry rpc cache dir: `~/.foundry/cache/rpc`. pub fn foundry_rpc_cache_dir() -> Option { Some(Self::foundry_cache_dir()?.join("rpc")) } - /// Returns the path to foundry chain's cache dir `~/.foundry/cache/rpc/` + /// Returns the path to foundry chain's cache dir: `~/.foundry/cache/rpc/` pub fn foundry_chain_cache_dir(chain_id: impl Into) -> Option { Some(Self::foundry_rpc_cache_dir()?.join(chain_id.into().to_string())) } - /// Returns the path to foundry's etherscan cache dir `~/.foundry/cache/etherscan` + /// Returns the path to foundry's etherscan cache dir: `~/.foundry/cache/etherscan`. pub fn foundry_etherscan_cache_dir() -> Option { Some(Self::foundry_cache_dir()?.join("etherscan")) } - /// Returns the path to foundry's keystores dir `~/.foundry/keystores` + /// Returns the path to foundry's keystores dir: `~/.foundry/keystores`. pub fn foundry_keystores_dir() -> Option { Some(Self::foundry_dir()?.join("keystores")) } - /// Returns the path to foundry's etherscan cache dir for `chain_id` + /// Returns the path to foundry's etherscan cache dir for `chain_id`: /// `~/.foundry/cache/etherscan/` pub fn foundry_etherscan_chain_cache_dir(chain_id: impl Into) -> Option { Some(Self::foundry_etherscan_cache_dir()?.join(chain_id.into().to_string())) } - /// Returns the path to the cache dir of the `block` on the `chain` - /// `~/.foundry/cache/rpc// + /// Returns the path to the cache dir of the `block` on the `chain`: + /// `~/.foundry/cache/rpc//` pub fn foundry_block_cache_dir(chain_id: impl Into, block: u64) -> Option { Some(Self::foundry_chain_cache_dir(chain_id)?.join(format!("{block}"))) } - /// Returns the path to the cache file of the `block` on the `chain` + /// Returns the path to the cache file of the `block` on the `chain`: /// `~/.foundry/cache/rpc///storage.json` pub fn foundry_block_cache_file(chain_id: impl Into, block: u64) -> Option { Some(Self::foundry_block_cache_dir(chain_id, block)?.join("storage.json")) } - #[doc = r#"Returns the path to `foundry`'s data directory inside the user's data directory - |Platform | Value | Example | - | ------- | ------------------------------------- | -------------------------------- | - | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config/foundry | /home/alice/.config/foundry| - | macOS | `$HOME`/Library/Application Support/foundry | /Users/Alice/Library/Application Support/foundry | - | Windows | `{FOLDERID_RoamingAppData}/foundry` | C:\Users\Alice\AppData\Roaming/foundry | - "#] + /// Returns the path to `foundry`'s data directory inside the user's data directory. + /// + /// | Platform | Value | Example | + /// | ------- | --------------------------------------------- | ------------------------------------------------ | + /// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config/foundry | /home/alice/.config/foundry | + /// | macOS | `$HOME`/Library/Application Support/foundry | /Users/Alice/Library/Application Support/foundry | + /// | Windows | `{FOLDERID_RoamingAppData}/foundry` | C:\Users\Alice\AppData\Roaming/foundry | pub fn data_dir() -> eyre::Result { let path = dirs_next::data_dir().wrap_err("Failed to find data directory")?.join("foundry"); std::fs::create_dir_all(&path).wrap_err("Failed to create module directory")?; @@ -1573,7 +1565,7 @@ impl Config { /// and the first hit is used. /// /// If this search comes up empty, then it checks if a global `foundry.toml` exists at - /// `~/.foundry/foundry.tol`, see [`Self::foundry_dir_toml()`] + /// `~/.foundry/foundry.toml`, see [`Self::foundry_dir_toml`]. pub fn find_config_file() -> Option { fn find(path: &Path) -> Option { if path.is_absolute() { @@ -1596,7 +1588,7 @@ impl Config { .or_else(|| Self::foundry_dir_toml().filter(|p| p.exists())) } - /// Clears the foundry cache + /// Clears the foundry cache. pub fn clean_foundry_cache() -> eyre::Result<()> { if let Some(cache_dir) = Config::foundry_cache_dir() { let path = cache_dir.as_path(); @@ -1608,7 +1600,7 @@ impl Config { Ok(()) } - /// Clears the foundry cache for `chain` + /// Clears the foundry cache for `chain`. pub fn clean_foundry_chain_cache(chain: Chain) -> eyre::Result<()> { if let Some(cache_dir) = Config::foundry_chain_cache_dir(chain) { let path = cache_dir.as_path(); @@ -1620,7 +1612,7 @@ impl Config { Ok(()) } - /// Clears the foundry cache for `chain` and `block` + /// Clears the foundry cache for `chain` and `block`. pub fn clean_foundry_block_cache(chain: Chain, block: u64) -> eyre::Result<()> { if let Some(cache_dir) = Config::foundry_block_cache_dir(chain, block) { let path = cache_dir.as_path(); @@ -1632,7 +1624,7 @@ impl Config { Ok(()) } - /// Clears the foundry etherscan cache + /// Clears the foundry etherscan cache. pub fn clean_foundry_etherscan_cache() -> eyre::Result<()> { if let Some(cache_dir) = Config::foundry_etherscan_cache_dir() { let path = cache_dir.as_path(); @@ -1644,7 +1636,7 @@ impl Config { Ok(()) } - /// Clears the foundry etherscan cache for `chain` + /// Clears the foundry etherscan cache for `chain`. pub fn clean_foundry_etherscan_chain_cache(chain: Chain) -> eyre::Result<()> { if let Some(cache_dir) = Config::foundry_etherscan_chain_cache_dir(chain) { let path = cache_dir.as_path(); @@ -1656,7 +1648,7 @@ impl Config { Ok(()) } - /// List the data in the foundry cache + /// List the data in the foundry cache. pub fn list_foundry_cache() -> eyre::Result { if let Some(cache_dir) = Config::foundry_rpc_cache_dir() { let mut cache = Cache { chains: vec![] }; @@ -1679,7 +1671,7 @@ impl Config { } } - /// List the cached data for `chain` + /// List the cached data for `chain`. pub fn list_foundry_chain_cache(chain: Chain) -> eyre::Result { let block_explorer_data_size = match Config::foundry_etherscan_chain_cache_dir(chain) { Some(cache_dir) => Self::get_cached_block_explorer_data(&cache_dir)?, @@ -1701,7 +1693,7 @@ impl Config { } } - //The path provided to this function should point to a cached chain folder + /// The path provided to this function should point to a cached chain folder. fn get_cached_blocks(chain_path: &Path) -> eyre::Result> { let mut blocks = vec![]; if !chain_path.exists() { @@ -1724,7 +1716,7 @@ impl Config { Ok(blocks) } - //The path provided to this function should point to the etherscan cache for a chain + /// The path provided to this function should point to the etherscan cache for a chain. fn get_cached_block_explorer_data(chain_path: &Path) -> eyre::Result { if !chain_path.exists() { return Ok(0) diff --git a/crates/config/src/macros.rs b/crates/config/src/macros.rs index d7e206a978250..d4f3a59ba1f2c 100644 --- a/crates/config/src/macros.rs +++ b/crates/config/src/macros.rs @@ -1,7 +1,8 @@ -/// A macro to implement converters from a type to [`Config`] and [`figment::Figment`] +/// A macro to implement converters from a type to [`Config`](crate::Config) and +/// [`figment::Figment`]. /// /// This can be used to remove some boilerplate code that's necessary to add additional layer(s) to -/// the [`Config`]'s default `Figment`. +/// the `Config`'s default `Figment`. /// /// `impl_figment` takes the default `Config` and merges additional `Provider`, therefore the /// targeted type, requires an implementation of `figment::Profile`. @@ -9,7 +10,7 @@ /// # Example /// /// Use `impl_figment` on a type with a `root: Option` field, which will be used for -/// [`Config::figment_with_root()`] +/// [`Config::figment_with_root()`](crate::Config::figment_with_root). /// /// ```rust /// use std::path::PathBuf; @@ -183,7 +184,8 @@ macro_rules! merge_impl_figment_convert { }; } -/// A macro to implement converters from a type to [`Config`] and [`figment::Figment`] +/// A macro to implement converters from a type to [`Config`](crate::Config) and +/// [`figment::Figment`]. /// /// Via [Config::to_figment](crate::Config::to_figment) and the /// [Cast](crate::FigmentProviders::Cast) profile. diff --git a/crates/config/src/providers/mod.rs b/crates/config/src/providers/mod.rs index 9dbbf38eaaa47..d8fdbf438e4cc 100644 --- a/crates/config/src/providers/mod.rs +++ b/crates/config/src/providers/mod.rs @@ -1,3 +1,5 @@ +//! Config providers. + use crate::{Config, Warning, DEPRECATIONS}; use figment::{ value::{Dict, Map, Value}, diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index 55e69249d452d..0f8e91c79bd50 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -3,7 +3,7 @@ use solang_parser::doccomment::DocCommentTag; use std::collections::HashMap; /// The natspec comment tag explaining the purpose of the comment. -/// See: https://docs.soliditylang.org/en/v0.8.17/natspec-format.html#tags. +/// See: . #[derive(Clone, Debug, PartialEq)] pub enum CommentTag { /// A title that should describe the contract/interface @@ -54,7 +54,8 @@ impl CommentTag { } /// The natspec documentation comment. -/// https://docs.soliditylang.org/en/v0.8.17/natspec-format.html +/// +/// Ref: #[derive(Clone, Debug, PartialEq)] pub struct Comment { /// The doc comment tag. diff --git a/crates/doc/src/preprocessor/inheritdoc.rs b/crates/doc/src/preprocessor/inheritdoc.rs index 583df72ba863d..8d29a64fcf3a6 100644 --- a/crates/doc/src/preprocessor/inheritdoc.rs +++ b/crates/doc/src/preprocessor/inheritdoc.rs @@ -5,7 +5,7 @@ use crate::{ use forge_fmt::solang_ext::SafeUnwrap; use std::collections::HashMap; -/// [ContractInheritance] preprocessor id. +/// [`Inheritdoc`] preprocessor ID. pub const INHERITDOC_ID: PreprocessorId = PreprocessorId("inheritdoc"); /// The inheritdoc preprocessor. diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index 68e4451fae890..a21a59c1111c4 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -10,7 +10,7 @@ use itertools::Itertools; use solang_parser::pt::{Base, FunctionDefinition}; use std::path::{Path, PathBuf}; -/// The result of [Asdoc::as_doc] method. +/// The result of [`AsDoc::as_doc`]. pub type AsDocResult = Result; /// A trait for formatting a parse unit as documentation. diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index a3cb3aab4fa65..e8f371f61e7fc 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -1,4 +1,5 @@ -//! The in memory DB +//! In-memory database. + use crate::{backend::error::DatabaseError, snapshot::Snapshots}; use alloy_primitives::{Address, B256, U256}; use revm::{ @@ -7,14 +8,14 @@ use revm::{ Database, DatabaseCommit, }; -/// Type alias for an in memory database +/// Type alias for an in-memory database. /// -/// See `EmptyDBWrapper` +/// See [`EmptyDBWrapper`]. pub type FoundryEvmInMemoryDB = CacheDB; -/// In memory Database for anvil +/// In-memory [`Database`] for Anvil. /// -/// This acts like a wrapper type for [InMemoryDB] but is capable of applying snapshots +/// This acts like a wrapper type for [`FoundryEvmInMemoryDB`] but is capable of applying snapshots. #[derive(Debug)] pub struct MemDb { pub inner: FoundryEvmInMemoryDB, @@ -81,7 +82,7 @@ impl DatabaseCommit for MemDb { /// /// This will also _always_ return `Some(AccountInfo)`: /// -/// The [`Database`](revm::Database) implementation for `CacheDB` manages an `AccountState` for the +/// The [`Database`] implementation for `CacheDB` manages an `AccountState` for the /// `DbAccount`, this will be set to `AccountState::NotExisting` if the account does not exist yet. /// This is because there's a distinction between "non-existing" and "empty", /// see . diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index bb43c7243bc67..f9c1becc9697e 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -54,7 +54,7 @@ pub type LocalForkId = U256; /// This is used for fast lookup type ForkLookupIndex = usize; -/// All accounts that will have persistent storage across fork swaps. See also [`clone_data()`] +/// All accounts that will have persistent storage across fork swaps. const DEFAULT_PERSISTENT_ACCOUNTS: [Address; 3] = [CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, CALLER]; @@ -392,8 +392,8 @@ pub struct Backend { /// The journaled_state to use to initialize new forks with /// /// The way [`revm::JournaledState`] works is, that it holds the "hot" accounts loaded from the - /// underlying `Database` that feeds the Account and State data ([`revm::AccountInfo`])to the - /// journaled_state so it can apply changes to the state while the evm executes. + /// underlying `Database` that feeds the Account and State data to the journaled_state so it + /// can apply changes to the state while the EVM executes. /// /// In a way the `JournaledState` is something like a cache that /// 1. check if account is already loaded (hot) @@ -404,7 +404,7 @@ pub struct Backend { /// ([`DatabaseExt::select_fork`]). /// /// This will be an empty `JournaledState`, which will be populated with persistent accounts, - /// See [`Self::update_fork_db()`] and [`clone_data()`]. + /// See [`Self::update_fork_db()`]. fork_init_journaled_state: JournaledState, /// The currently active fork database /// @@ -1572,8 +1572,6 @@ pub struct BackendInner { /// All accounts that should be kept persistent when switching forks. /// This means all accounts stored here _don't_ use a separate storage section on each fork /// instead the use only one that's persistent across fork swaps. - /// - /// See also [`clone_data()`] pub persistent_accounts: HashSet
, /// The configured spec id pub spec_id: SpecId, diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 8b09316e30482..fa3d099ab5c5b 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -105,7 +105,7 @@ impl RevertDecoder { /// Tries to decode an error message from the given revert bytes. /// - /// See [`decode_revert`] for more information. + /// See [`decode`](Self::decode) for more information. pub fn maybe_decode(&self, err: &[u8], status: Option) -> Option { if err.len() < SELECTOR_LEN { if let Some(status) = status { diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs index fd768e3f74e39..9aea935858203 100644 --- a/crates/evm/core/src/fork/cache.rs +++ b/crates/evm/core/src/fork/cache.rs @@ -30,9 +30,9 @@ pub struct BlockchainDb { } impl BlockchainDb { - /// Creates a new instance of the [BlockchainDb] + /// Creates a new instance of the [BlockchainDb]. /// - /// if a `cache_path` is provided it attempts to load a previously stored [JsonBlockCacheData] + /// If a `cache_path` is provided it attempts to load a previously stored [JsonBlockCacheData] /// and will try to use the cached entries it holds. /// /// This will return a new and empty [MemDb] if @@ -99,7 +99,7 @@ impl BlockchainDb { &self.db.block_hashes } - /// Returns the [revm::Env] related metadata + /// Returns the Env related metadata pub fn meta(&self) -> &Arc> { &self.meta } @@ -327,7 +327,7 @@ impl DatabaseCommit for MemDb { } } -/// A [BlockCacheDB] that stores the cached content in a json file +/// A DB that stores the cached content in a json file #[derive(Debug)] pub struct JsonBlockCacheDB { /// Where this cache file is stored. diff --git a/crates/evm/core/src/fork/mod.rs b/crates/evm/core/src/fork/mod.rs index 61dd7bf47bf4b..a6387b0bb0608 100644 --- a/crates/evm/core/src/fork/mod.rs +++ b/crates/evm/core/src/fork/mod.rs @@ -8,7 +8,10 @@ mod init; pub use init::environment; mod cache; -pub use cache::{BlockchainDb, BlockchainDbMeta, JsonBlockCacheDB, MemDb}; +pub use cache::{ + BlockchainDb, BlockchainDbMeta, FlushJsonBlockCacheDB, JsonBlockCacheDB, JsonBlockCacheData, + MemDb, StorageInfo, +}; pub mod database; diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 2fe3d0390be5b..4ff429902e7eb 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -141,14 +141,14 @@ impl EvmOpts { /// storage caching for the [CreateFork] will be enabled if /// - `fork_url` is present /// - `fork_block_number` is present - /// - [StorageCachingConfig] allows the `fork_url` + chain id pair + /// - `StorageCachingConfig` allows the `fork_url` + chain ID pair /// - storage is allowed (`no_storage_caching = false`) /// /// If all these criteria are met, then storage caching is enabled and storage info will be - /// written to [Config::foundry_cache_dir()]///storage.json + /// written to `///storage.json`. /// /// for `mainnet` and `--fork-block-number 14435000` on mac the corresponding storage cache will - /// be at `~/.foundry/cache/mainnet/14435000/storage.json` + /// be at `~/.foundry/cache/mainnet/14435000/storage.json`. pub fn get_fork(&self, config: &Config, env: revm::primitives::Env) -> Option { let url = self.fork_url.clone()?; let enable_caching = config.enable_caching(&url, env.cfg.chain_id); diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 58bfb9cdb6b9e..15588296fd8f8 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -33,17 +33,17 @@ pub use inspector::CoverageCollector; /// "anchors"). A single coverage item may be referred to by multiple anchors. #[derive(Clone, Debug, Default)] pub struct CoverageReport { - /// A map of source IDs to the source path + /// A map of source IDs to the source path. pub source_paths: HashMap<(Version, usize), PathBuf>, - /// A map of source paths to source IDs + /// A map of source paths to source IDs. pub source_paths_to_ids: HashMap<(Version, PathBuf), usize>, /// All coverage items for the codebase, keyed by the compiler version. pub items: HashMap>, /// All item anchors for the codebase, keyed by their contract ID. pub anchors: HashMap, Vec)>, - /// All the bytecode hits for the codebase + /// All the bytecode hits for the codebase. pub bytecode_hits: HashMap, - /// The bytecode -> source mappings + /// The bytecode -> source mappings. pub source_maps: HashMap, } @@ -59,7 +59,7 @@ impl CoverageReport { self.source_paths_to_ids.get(&(version, path)).copied() } - /// Add the source maps + /// Add the source maps. pub fn add_source_maps( &mut self, source_maps: impl IntoIterator, @@ -67,12 +67,12 @@ impl CoverageReport { self.source_maps.extend(source_maps); } - /// Add coverage items to this report + /// Add coverage items to this report. pub fn add_items(&mut self, version: Version, items: impl IntoIterator) { self.items.entry(version).or_default().extend(items); } - /// Add anchors to this report + /// Add anchors to this report. pub fn add_anchors( &mut self, anchors: impl IntoIterator, Vec))>, @@ -80,7 +80,7 @@ impl CoverageReport { self.anchors.extend(anchors); } - /// Get coverage summaries by source file path + /// Get coverage summaries by source file path. pub fn summary_by_file(&self) -> impl Iterator { let mut summaries = BTreeMap::new(); @@ -99,7 +99,7 @@ impl CoverageReport { summaries.into_iter() } - /// Get coverage items by source file path + /// Get coverage items by source file path. pub fn items_by_source(&self) -> impl Iterator)> { let mut items_by_source: BTreeMap<_, Vec<_>> = BTreeMap::new(); @@ -117,10 +117,11 @@ impl CoverageReport { items_by_source.into_iter() } - /// Processes data from a [HitMap] and sets hit counts for coverage items in this coverage map. + /// Processes data from a [`HitMap`] and sets hit counts for coverage items in this coverage + /// map. /// /// This function should only be called *after* all the relevant sources have been processed and - /// added to the map (see [add_source]). + /// added to the map (see [`add_source`](Self::add_source)). pub fn add_hit_map( &mut self, contract_id: &ContractId, @@ -151,7 +152,7 @@ impl CoverageReport { } } -/// A collection of [HitMap]s +/// A collection of [`HitMap`]s. #[derive(Clone, Debug, Default)] pub struct HitMaps(pub HashMap); diff --git a/crates/evm/evm/src/executors/builder.rs b/crates/evm/evm/src/executors/builder.rs index 370c3bcf3e1c2..97cdc92187d4b 100644 --- a/crates/evm/evm/src/executors/builder.rs +++ b/crates/evm/evm/src/executors/builder.rs @@ -8,12 +8,12 @@ use revm::primitives::{Env, EnvWithHandlerCfg, SpecId}; /// /// By default, the [`Executor`] will be configured with an empty [`InspectorStack`]. /// -/// [`Cheatcodes`]: super::inspector::Cheatcodes -/// [`InspectorStack`]: super::inspector::InspectorStack +/// [`Cheatcodes`]: super::Cheatcodes +/// [`InspectorStack`]: super::InspectorStack #[derive(Clone, Debug)] #[must_use = "builders do nothing unless you call `build` on them"] pub struct ExecutorBuilder { - /// The configuration used to build an [InspectorStack]. + /// The configuration used to build an `InspectorStack`. stack: InspectorStackBuilder, /// The gas limit. gas_limit: Option, @@ -45,7 +45,7 @@ impl ExecutorBuilder { self } - /// Sets the EVM spec to use + /// Sets the EVM spec to use. #[inline] pub fn spec(mut self, spec: SpecId) -> Self { self.spec_id = spec; @@ -53,8 +53,6 @@ impl ExecutorBuilder { } /// Sets the executor gas limit. - /// - /// See [Executor::gas_limit] for more info on why you might want to set this. #[inline] pub fn gas_limit(mut self, gas_limit: U256) -> Self { self.gas_limit = Some(gas_limit); diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index ba1e5277c4c5f..f8a1bd495a1d4 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -452,21 +452,21 @@ impl Executor { self.ensure_success(address, reverted, state_changeset, should_fail).unwrap_or_default() } - /// This is the same as [Self::is_success] but intended for outcomes of [Self::call_raw] used in - /// fuzzing and invariant testing. + /// This is the same as [`Self::is_success`] but intended for outcomes of [`Self::call_raw`] + /// used in fuzzing and invariant testing. /// /// ## Background /// - /// Executing and failure checking [`Executor::ensure_success`] are two steps, for ds-test + /// Executing and failure checking `Executor::ensure_success` are two steps, for ds-test /// legacy reasons failures can be stored in a global variables and needs to be called via a /// solidity call `failed()(bool)`. /// - /// For fuzz tests we’re using the `CowBackend` which is a Cow of the executor’s backend which - /// lazily clones the backend when it’s mutated via cheatcodes like `snapshot`. Snapshots - /// make it even more complicated because now we also need to keep track of that global - /// variable when we revert to a snapshot (because it is stored in state). Now, the problem - /// is that the `CowBackend` is dropped after every call, so we need to keep track of the - /// snapshot failure in the [`RawCallResult`] instead. + /// For fuzz tests we’re using the `CowBackend` which lazily clones the backend when it’s + /// mutated via cheatcodes like `snapshot`. Snapshots make it even more complicated because + /// now we also need to keep track of that global variable when we revert to a snapshot + /// (because it is stored in state). Now, the problem is that the `CowBackend` is dropped + /// after every call, so we need to keep track of the snapshot failure in the + /// [`RawCallResult`] instead. pub fn is_raw_call_success( &self, address: Address, diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 022586ae2cdd8..1eb21d6dede8b 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -142,8 +142,6 @@ impl InspectorStackBuilder { } /// Builds the stack of inspectors to use when transacting/committing on the EVM. - /// - /// See also [`revm::Evm::inspect_ref`] and [`revm::Evm::commit_ref`]. pub fn build(self) -> InspectorStack { let Self { block, @@ -259,7 +257,7 @@ pub struct InspectorData { /// Used to adjust EVM state while in inner context. /// /// We need this to avoid breaking changes due to EVM behavior differences in isolated vs -/// non-isolated mode. For descriptions and workarounds for those changes see: https://github.com/foundry-rs/foundry/pull/7186#issuecomment-1959102195 +/// non-isolated mode. For descriptions and workarounds for those changes see: #[derive(Debug, Clone)] pub struct InnerContextData { /// The sender of the inner EVM context. diff --git a/crates/evm/fuzz/src/strategies/int.rs b/crates/evm/fuzz/src/strategies/int.rs index 3f8ff548bb6d3..3732de0617325 100644 --- a/crates/evm/fuzz/src/strategies/int.rs +++ b/crates/evm/fuzz/src/strategies/int.rs @@ -7,7 +7,6 @@ use proptest::{ use rand::Rng; /// Value tree for signed ints (up to int256). -/// This is very similar to [proptest::BinarySearch] pub struct IntValueTree { /// Lower base (by absolute value) lo: I256, diff --git a/crates/evm/fuzz/src/strategies/uint.rs b/crates/evm/fuzz/src/strategies/uint.rs index 77a080f8cdbd1..af133efa00826 100644 --- a/crates/evm/fuzz/src/strategies/uint.rs +++ b/crates/evm/fuzz/src/strategies/uint.rs @@ -7,7 +7,6 @@ use proptest::{ use rand::Rng; /// Value tree for unsigned ints (up to uint256). -/// This is very similar to [proptest::BinarySearch] pub struct UintValueTree { /// Lower base lo: U256, diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 976e9ea6979cd..cd69cf9475ad4 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -2,7 +2,7 @@ use alloy_json_abi::{Event, Function}; use foundry_common::{ abi::{get_event, get_func}, fs, - selectors::{SelectorType, SignEthClient}, + selectors::{OpenChainClient, SelectorType}, }; use serde::{Deserialize, Serialize}; use std::{ @@ -31,7 +31,7 @@ pub struct SignaturesIdentifier { /// Selectors that were unavailable during the session. unavailable: HashSet, /// The API client to fetch signatures from - sign_eth_api: SignEthClient, + sign_eth_api: OpenChainClient, /// whether traces should be decoded via `sign_eth_api` offline: bool, } @@ -42,7 +42,7 @@ impl SignaturesIdentifier { cache_path: Option, offline: bool, ) -> eyre::Result { - let sign_eth_api = SignEthClient::new()?; + let sign_eth_api = OpenChainClient::new()?; let identifier = if let Some(cache_path) = cache_path { let path = cache_path.join("signatures"); diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index d10cf4b382359..52a7890342820 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -393,7 +393,7 @@ impl<'a, W: Write> Formatter<'a, W> { Ok(out) } - /// Transform [Visitable] items to a list of chunks and then sort those chunks by [AttrSortKey] + /// Transform [Visitable] items to a list of chunks and then sort those chunks. fn items_to_chunks_sorted<'b>( &mut self, next_byte_offset: Option, @@ -585,8 +585,8 @@ impl<'a, W: Write> Formatter<'a, W> { Ok(false) } - /// Write a raw comment. This is like [`write_comment`] but won't do any formatting or worry - /// about whitespace behind the comment + /// Write a raw comment. This is like [`write_comment`](Self::write_comment) but won't do any + /// formatting or worry about whitespace behind the comment. fn write_raw_comment(&mut self, comment: &CommentWithMetadata) -> Result<()> { self.write_raw(&comment.comment)?; if comment.is_line() { @@ -1255,7 +1255,8 @@ impl<'a, W: Write> Formatter<'a, W> { /// Visit the yul string with an optional identifier. /// If the identifier is present, write the value in the format `:`. - /// Ref: https://docs.soliditylang.org/en/v0.8.15/yul.html#variable-declarations + /// + /// Ref: fn visit_yul_string_with_ident( &mut self, loc: Loc, diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index 1bed8069a23a7..26fb48c402011 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -10,15 +10,15 @@ use std::{fmt::Write, path::Path}; /// Result of parsing the source code #[derive(Debug)] pub struct Parsed<'a> { - /// The original source code + /// The original source code. pub src: &'a str, - /// The Parse Tree via [`solang`] + /// The parse tree. pub pt: SourceUnit, - /// Parsed comments + /// Parsed comments. pub comments: Comments, - /// Parsed inline config + /// Parsed inline config. pub inline_config: InlineConfig, - /// Invalid inline config items parsed + /// Invalid inline config items parsed. pub invalid_inline_config_items: Vec<(Loc, InvalidInlineConfigItem)>, } diff --git a/crates/fmt/src/inline_config.rs b/crates/fmt/src/inline_config.rs index 7593bb92c278f..9f0e548061106 100644 --- a/crates/fmt/src/inline_config.rs +++ b/crates/fmt/src/inline_config.rs @@ -61,8 +61,10 @@ impl DisabledRange { /// An inline config. Keeps track of disabled ranges. /// /// This is a list of Inline Config items for locations in a source file. This is -/// usually acquired by parsing the comments for an `forgefmt:` items. See -/// [`Comments::parse_inline_config_items`] for details. +/// usually acquired by parsing the comments for an `forgefmt:` items. +/// +/// See [`Comments::parse_inline_config_items`](crate::Comments::parse_inline_config_items) for +/// details. #[derive(Debug, Default)] pub struct InlineConfig { disabled_ranges: Vec, diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index d9fe5640d952b..aaf866a11f12c 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -144,8 +144,9 @@ impl SendTransactionsKind { } } -/// State after we have bundled all [TransactionWithMetadata] objects into a single -/// [ScriptSequenceKind] object containing one or more script sequences. +/// State after we have bundled all +/// [`TransactionWithMetadata`](crate::transaction::TransactionWithMetadata) objects into a single +/// [`ScriptSequenceKind`] object containing one or more script sequences. pub struct BundledState { pub args: ScriptArgs, pub script_config: ScriptConfig, diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 7a785b6e6466f..3f9a49960d4e8 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -27,11 +27,11 @@ use std::{path::PathBuf, str::FromStr, sync::Arc}; /// Container for the compiled contracts. #[derive(Debug)] pub struct BuildData { - /// Root of the project + /// Root of the project. pub project_root: PathBuf, - /// Linker which can be used to link contracts, owns [ArtifactContracts] map. + /// The compiler output. pub output: ProjectCompileOutput, - /// Id of target contract artifact. + /// ID of target contract artifact. pub target: ArtifactId, } diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index f653143359a01..f95262aaeedd6 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -216,8 +216,8 @@ impl ScriptSequence { } /// Gets paths in the formats - /// ./broadcast/[contract_filename]/[chain_id]/[sig]-[timestamp].json and - /// ./cache/[contract_filename]/[chain_id]/[sig]-[timestamp].json + /// `./broadcast/[contract_filename]/[chain_id]/[sig]-[timestamp].json` and + /// `./cache/[contract_filename]/[chain_id]/[sig]-[timestamp].json`. pub fn get_paths( config: &Config, sig: &str, diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index a27506810ed22..418dd036a9f9d 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -26,11 +26,11 @@ use std::{ sync::Arc, }; -/// Same as [ExecutedState], but also contains [ExecutionArtifacts] which are obtained from -/// [ScriptResult]. +/// Same as [ExecutedState](crate::execute::ExecutedState), but also contains [ExecutionArtifacts] +/// which are obtained from [ScriptResult]. /// -/// Can be either converted directly to [BundledState] via [PreSimulationState::resume] or driven to -/// it through [FilledTransactionsState]. +/// Can be either converted directly to [BundledState] or driven to it through +/// [FilledTransactionsState]. pub struct PreSimulationState { pub args: ScriptArgs, pub script_config: ScriptConfig, diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 4863670186c4f..b49af60063ebc 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -59,7 +59,8 @@ pub struct VerifyBytecodeArgs { #[clap(short = 'r', long, value_name = "RPC_URL", env = "ETH_RPC_URL")] pub rpc_url: Option, - /// Verfication Type: `full` or `partial`. Ref: https://docs.sourcify.dev/docs/full-vs-partial-match/ + /// Verfication Type: `full` or `partial`. + /// Ref: #[clap(long, default_value = "full", value_name = "TYPE")] pub verification_type: VerificationType, @@ -498,7 +499,8 @@ impl VerifyBytecodeArgs { } } -/// Enum to represent the type of verification: `full` or `partial`. Ref: https://docs.sourcify.dev/docs/full-vs-partial-match/ +/// Enum to represent the type of verification: `full` or `partial`. +/// Ref: #[derive(Debug, Clone, clap::ValueEnum, Default, PartialEq, Eq, Serialize, Deserialize, Copy)] pub enum VerificationType { #[default] diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index 1542f3a0e3b0d..fa888f92295a0 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -57,7 +57,7 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource { impl EtherscanFlattenedSource { /// Attempts to compile the flattened content locally with the compiler version. /// - /// This expects the completely flattened `content´ and will try to compile it using the + /// This expects the completely flattened content and will try to compile it using the /// provided compiler. If the compiler is missing it will be installed. /// /// # Errors From 66bea839570abf47cbc38f8e74eb8f9ef0d1c0df Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:55:30 +0200 Subject: [PATCH 1039/1963] ci: bump softprops/action-gh-release (#8070) --- .github/workflows/release.yml | 480 +++++++++++++++++----------------- 1 file changed, 239 insertions(+), 241 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3db72dfcf3693..6c78fed2af22f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,268 +1,266 @@ name: release on: - push: - tags: - - "v*.*.*" - schedule: - - cron: "0 0 * * *" - workflow_dispatch: + push: + tags: + - "v*.*.*" + schedule: + - cron: "0 0 * * *" + workflow_dispatch: env: - CARGO_TERM_COLOR: always - IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} + CARGO_TERM_COLOR: always + IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} jobs: - prepare: - name: Prepare release - runs-on: ubuntu-latest - timeout-minutes: 30 - outputs: - tag_name: ${{ steps.release_info.outputs.tag_name }} - release_name: ${{ steps.release_info.outputs.release_name }} - changelog: ${{ steps.build_changelog.outputs.changelog }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + prepare: + name: Prepare release + runs-on: ubuntu-latest + timeout-minutes: 30 + outputs: + tag_name: ${{ steps.release_info.outputs.tag_name }} + release_name: ${{ steps.release_info.outputs.release_name }} + changelog: ${{ steps.build_changelog.outputs.changelog }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Compute release name and tag - id: release_info - run: | - if [[ $IS_NIGHTLY ]]; then - echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT - echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT - else - echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT - echo "release_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT - fi + - name: Compute release name and tag + id: release_info + run: | + if [[ $IS_NIGHTLY ]]; then + echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT + echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT + else + echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT + echo "release_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT + fi - # Creates a `nightly-SHA` tag for this specific nightly - # This tag is used for this specific nightly version's release - # which allows users to roll back. It is also used to build - # the changelog. - - name: Create build-specific nightly tag - if: ${{ env.IS_NIGHTLY }} - uses: actions/github-script@v7 - env: - TAG_NAME: ${{ steps.release_info.outputs.tag_name }} - with: - script: | - const createTag = require('./.github/scripts/create-tag.js') - await createTag({ github, context }, process.env.TAG_NAME) + # Creates a `nightly-SHA` tag for this specific nightly + # This tag is used for this specific nightly version's release + # which allows users to roll back. It is also used to build + # the changelog. + - name: Create build-specific nightly tag + if: ${{ env.IS_NIGHTLY }} + uses: actions/github-script@v7 + env: + TAG_NAME: ${{ steps.release_info.outputs.tag_name }} + with: + script: | + const createTag = require('./.github/scripts/create-tag.js') + await createTag({ github, context }, process.env.TAG_NAME) - - name: Build changelog - id: build_changelog - uses: mikepenz/release-changelog-builder-action@v4 - with: - configuration: "./.github/changelog.json" - fromTag: ${{ env.IS_NIGHTLY && 'nightly' || '' }} - toTag: ${{ steps.release_info.outputs.tag_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build changelog + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v4 + with: + configuration: "./.github/changelog.json" + fromTag: ${{ env.IS_NIGHTLY && 'nightly' || '' }} + toTag: ${{ steps.release_info.outputs.tag_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - release-docker: - name: Release Docker - uses: ./.github/workflows/docker-publish.yml + release-docker: + name: Release Docker + uses: ./.github/workflows/docker-publish.yml - release: - name: ${{ matrix.target }} (${{ matrix.runner }}) - runs-on: ${{ matrix.runner }} - timeout-minutes: 240 - needs: prepare - strategy: - fail-fast: false - matrix: - include: - # `runner`: GHA runner label - # `target`: Rust build target triple - # `platform` and `arch`: Used in tarball names - # `svm`: target platform to use for the Solc binary: https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 - - runner: Linux-20.04 - target: x86_64-unknown-linux-gnu - svm_target_platform: linux-amd64 - platform: linux - arch: amd64 - - runner: Linux-20.04 - target: aarch64-unknown-linux-gnu - svm_target_platform: linux-aarch64 - platform: linux - arch: arm64 - - runner: macos-12-large - target: x86_64-apple-darwin - svm_target_platform: macosx-amd64 - platform: darwin - arch: amd64 - - runner: macos-latest-large - target: aarch64-apple-darwin - svm_target_platform: macosx-aarch64 - platform: darwin - arch: arm64 - - runner: Windows - target: x86_64-pc-windows-msvc - svm_target_platform: windows-amd64 - platform: win32 - arch: amd64 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - uses: Swatinem/rust-cache@v2 - with: - key: ${{ matrix.target }} - cache-on-failure: true + release: + name: ${{ matrix.target }} (${{ matrix.runner }}) + runs-on: ${{ matrix.runner }} + timeout-minutes: 240 + needs: prepare + strategy: + fail-fast: false + matrix: + include: + # `runner`: GHA runner label + # `target`: Rust build target triple + # `platform` and `arch`: Used in tarball names + # `svm`: target platform to use for the Solc binary: https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24 + - runner: Linux-20.04 + target: x86_64-unknown-linux-gnu + svm_target_platform: linux-amd64 + platform: linux + arch: amd64 + - runner: Linux-20.04 + target: aarch64-unknown-linux-gnu + svm_target_platform: linux-aarch64 + platform: linux + arch: arm64 + - runner: macos-12-large + target: x86_64-apple-darwin + svm_target_platform: macosx-amd64 + platform: darwin + arch: amd64 + - runner: macos-latest-large + target: aarch64-apple-darwin + svm_target_platform: macosx-aarch64 + platform: darwin + arch: arm64 + - runner: Windows + target: x86_64-pc-windows-msvc + svm_target_platform: windows-amd64 + platform: win32 + arch: amd64 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true - - name: Apple M1 setup - if: matrix.target == 'aarch64-apple-darwin' - run: | - echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV - echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV + - name: Apple M1 setup + if: matrix.target == 'aarch64-apple-darwin' + run: | + echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV + echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV - - name: Linux ARM setup - if: matrix.target == 'aarch64-unknown-linux-gnu' - run: | - sudo apt-get update -y - sudo apt-get install -y gcc-aarch64-linux-gnu - echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV + - name: Linux ARM setup + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update -y + sudo apt-get install -y gcc-aarch64-linux-gnu + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - - name: Build binaries - env: - SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} - shell: bash - run: | - set -eo pipefail - target="${{ matrix.target }}" - flags=() + - name: Build binaries + env: + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + shell: bash + run: | + set -eo pipefail + target="${{ matrix.target }}" + flags=() - # `jemalloc` and `keccak-asm` are not supported on MSVC or aarch64 Linux. - if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then - flags+=(--features asm-keccak,jemalloc) - fi + # `jemalloc` and `keccak-asm` are not supported on MSVC or aarch64 Linux. + if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then + flags+=(--features asm-keccak,jemalloc) + fi - [[ "$target" == *windows* ]] && exe=".exe" + [[ "$target" == *windows* ]] && exe=".exe" - cargo build --release --bins --target "$target" "${flags[@]}" + cargo build --release --bins --target "$target" "${flags[@]}" - bins=(anvil cast chisel forge) - for name in "${bins[@]}"; do - bin=./target/$target/release/$name$exe - file "$bin" || true - ldd "$bin" || true - $bin --version || true - done + bins=(anvil cast chisel forge) + for name in "${bins[@]}"; do + bin=./target/$target/release/$name$exe + file "$bin" || true + ldd "$bin" || true + $bin --version || true + done - - name: Archive binaries - id: artifacts - env: - PLATFORM_NAME: ${{ matrix.platform }} - TARGET: ${{ matrix.target }} - ARCH: ${{ matrix.arch }} - VERSION_NAME: - ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} - shell: bash - run: | - if [ "$PLATFORM_NAME" == "linux" ]; then - tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel - echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT - elif [ "$PLATFORM_NAME" == "darwin" ]; then - # We need to use gtar here otherwise the archive is corrupt. - # See: https://github.com/actions/virtual-environments/issues/2619 - gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel - echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT - else - cd ./target/${TARGET}/release - 7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe anvil.exe chisel.exe - mv "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../ - echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT - fi + - name: Archive binaries + id: artifacts + env: + PLATFORM_NAME: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} + ARCH: ${{ matrix.arch }} + VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + shell: bash + run: | + if [ "$PLATFORM_NAME" == "linux" ]; then + tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT + elif [ "$PLATFORM_NAME" == "darwin" ]; then + # We need to use gtar here otherwise the archive is corrupt. + # See: https://github.com/actions/virtual-environments/issues/2619 + gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT + else + cd ./target/${TARGET}/release + 7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe anvil.exe chisel.exe + mv "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../ + echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT + fi - - name: Build man page - id: man - if: matrix.target == 'x86_64-unknown-linux-gnu' - env: - PLATFORM_NAME: ${{ matrix.platform }} - TARGET: ${{ matrix.target }} - VERSION_NAME: - ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} - shell: bash - run: | - sudo apt-get -y install help2man - help2man -N ./target/${TARGET}/release/forge > forge.1 - help2man -N ./target/${TARGET}/release/cast > cast.1 - help2man -N ./target/${TARGET}/release/anvil > anvil.1 - help2man -N ./target/${TARGET}/release/chisel > chisel.1 - gzip forge.1 - gzip cast.1 - gzip anvil.1 - gzip chisel.1 - tar -czvf "foundry_man_${VERSION_NAME}.tar.gz" forge.1.gz cast.1.gz anvil.1.gz chisel.1.gz - echo "foundry_man=foundry_man_${VERSION_NAME}.tar.gz" >> $GITHUB_OUTPUT + - name: Build man page + id: man + if: matrix.target == 'x86_64-unknown-linux-gnu' + env: + PLATFORM_NAME: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} + VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + shell: bash + run: | + sudo apt-get -y install help2man + help2man -N ./target/${TARGET}/release/forge > forge.1 + help2man -N ./target/${TARGET}/release/cast > cast.1 + help2man -N ./target/${TARGET}/release/anvil > anvil.1 + help2man -N ./target/${TARGET}/release/chisel > chisel.1 + gzip forge.1 + gzip cast.1 + gzip anvil.1 + gzip chisel.1 + tar -czvf "foundry_man_${VERSION_NAME}.tar.gz" forge.1.gz cast.1.gz anvil.1.gz chisel.1.gz + echo "foundry_man=foundry_man_${VERSION_NAME}.tar.gz" >> $GITHUB_OUTPUT - # Creates the release for this specific version - - name: Create release - uses: softprops/action-gh-release@v1 - with: - name: ${{ needs.prepare.outputs.release_name }} - tag_name: ${{ needs.prepare.outputs.tag_name }} - prerelease: ${{ env.IS_NIGHTLY }} - body: ${{ needs.prepare.outputs.changelog }} - files: | - ${{ steps.artifacts.outputs.file_name }} - ${{ steps.man.outputs.foundry_man }} + # Creates the release for this specific version + - name: Create release + uses: softprops/action-gh-release@v2 + with: + name: ${{ needs.prepare.outputs.release_name }} + tag_name: ${{ needs.prepare.outputs.tag_name }} + prerelease: ${{ env.IS_NIGHTLY }} + body: ${{ needs.prepare.outputs.changelog }} + files: | + ${{ steps.artifacts.outputs.file_name }} + ${{ steps.man.outputs.foundry_man }} - # If this is a nightly release, it also updates the release - # tagged `nightly` for compatibility with `foundryup` - - name: Update nightly release - if: ${{ env.IS_NIGHTLY }} - uses: softprops/action-gh-release@v1 - with: - name: "Nightly" - tag_name: "nightly" - prerelease: true - body: ${{ needs.prepare.outputs.changelog }} - files: | - ${{ steps.artifacts.outputs.file_name }} - ${{ steps.man.outputs.foundry_man }} + # If this is a nightly release, it also updates the release + # tagged `nightly` for compatibility with `foundryup` + - name: Update nightly release + if: ${{ env.IS_NIGHTLY }} + uses: softprops/action-gh-release@v2 + with: + name: "Nightly" + tag_name: "nightly" + prerelease: true + body: ${{ needs.prepare.outputs.changelog }} + files: | + ${{ steps.artifacts.outputs.file_name }} + ${{ steps.man.outputs.foundry_man }} - cleanup: - name: Release cleanup - runs-on: ubuntu-latest - timeout-minutes: 30 - needs: release - if: always() - steps: - - uses: actions/checkout@v4 + cleanup: + name: Release cleanup + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: release + if: always() + steps: + - uses: actions/checkout@v4 - # Moves the `nightly` tag to `HEAD` - - name: Move nightly tag - if: ${{ env.IS_NIGHTLY }} - uses: actions/github-script@v7 - with: - script: | - const moveTag = require('./.github/scripts/move-tag.js') - await moveTag({ github, context }, 'nightly') + # Moves the `nightly` tag to `HEAD` + - name: Move nightly tag + if: ${{ env.IS_NIGHTLY }} + uses: actions/github-script@v7 + with: + script: | + const moveTag = require('./.github/scripts/move-tag.js') + await moveTag({ github, context }, 'nightly') - - name: Delete old nightlies - uses: actions/github-script@v7 - with: - script: | - const prunePrereleases = require('./.github/scripts/prune-prereleases.js') - await prunePrereleases({github, context}) + - name: Delete old nightlies + uses: actions/github-script@v7 + with: + script: | + const prunePrereleases = require('./.github/scripts/prune-prereleases.js') + await prunePrereleases({github, context}) - # If any of the jobs fail, this will create a high-priority issue to signal so. - issue: - name: Open an issue - runs-on: ubuntu-latest - needs: [prepare, release-docker, release, cleanup] - if: failure() - steps: - - uses: actions/checkout@v4 - - uses: JasonEtco/create-an-issue@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_URL: | - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - with: - update_existing: true - filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md + # If any of the jobs fail, this will create a high-priority issue to signal so. + issue: + name: Open an issue + runs-on: ubuntu-latest + needs: [prepare, release-docker, release, cleanup] + if: failure() + steps: + - uses: actions/checkout@v4 + - uses: JasonEtco/create-an-issue@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_URL: | + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + update_existing: true + filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md From 00854b602ef0e67379a2027ccc5d0aad553e5333 Mon Sep 17 00:00:00 2001 From: teddav Date: Wed, 5 Jun 2024 18:55:40 +0200 Subject: [PATCH 1040/1963] chore: update alloy and revm (#8057) * chore: update alloy and revm * rm * deny * update * patch instead --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 60 +++++++++++------------ Cargo.toml | 58 ++++++++++++---------- crates/anvil/src/eth/backend/fork.rs | 7 ++- crates/anvil/src/eth/backend/mem/mod.rs | 1 - crates/anvil/src/eth/backend/mem/state.rs | 4 +- crates/anvil/tests/it/api.rs | 10 +--- crates/anvil/tests/it/traces.rs | 5 +- crates/cast/bin/cmd/estimate.rs | 2 +- crates/evm/core/src/backend/mod.rs | 8 +-- crates/evm/core/src/utils.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 1 - deny.toml | 1 + 12 files changed, 81 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 920d46dd14f62..5c4b9c57f1864 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-eips", "alloy-primitives", @@ -92,7 +92,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -132,7 +132,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-primitives", "alloy-serde", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-primitives", "serde", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -227,9 +227,10 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-chains", + "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-network", @@ -261,7 +262,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -301,7 +302,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -325,7 +326,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -343,7 +344,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -360,7 +361,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -372,7 +373,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-primitives", "serde", @@ -382,7 +383,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -397,7 +398,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-consensus", "alloy-network", @@ -414,7 +415,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -433,7 +434,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-consensus", "alloy-network", @@ -449,7 +450,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-consensus", "alloy-network", @@ -540,7 +541,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -558,7 +559,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -572,7 +573,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -592,7 +593,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=5940871#5940871a103ed9332956959a9f2efcc2caa73bf0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -6388,8 +6389,7 @@ dependencies = [ [[package]] name = "revm" version = "9.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a2c336f9921588e50871c00024feb51a521eca50ce6d01494bb9c50f837c8ed" +source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" dependencies = [ "auto_impl", "cfg-if", @@ -6403,7 +6403,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=0d3f1f4#0d3f1f4e41bfa2e1e56d37994494934edf0a11ef" +source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=a278649#a2786496b2edcb06abed5a33682c532d070bf47c" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -6420,8 +6420,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a58182c7454179826f9dad2ca577661963092ce9d0fd0c9d682c1e9215a72e70" +source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" dependencies = [ "revm-primitives", "serde", @@ -6430,13 +6429,13 @@ dependencies = [ [[package]] name = "revm-precompile" version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc8af9aa737eef0509a50d9f3cc1a631557a00ef2e70a3aa8a75d9ee0ed275bb" +source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" dependencies = [ "aurora-engine-modexp", "c-kzg", "k256", "once_cell", + "p256", "revm-primitives", "ripemd", "secp256k1", @@ -6447,8 +6446,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9bf5d465e64b697da6a111cb19e798b5b2ebb18e5faf2ad48e9e8d47c64add2" +source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" dependencies = [ "alloy-primitives", "auto_impl", diff --git a/Cargo.toml b/Cargo.toml index e3e35dd0d2be3..d3809d541136d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,9 +156,9 @@ foundry-compilers = { version = "0.6.0", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "9", default-features = false } -revm-primitives = { version = "4", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "0d3f1f4", features = [ +revm = { version = "9.0.0", default-features = false } +revm-primitives = { version = "4.0.0", default-features = false } +revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "a278649", features = [ "serde", ] } @@ -166,29 +166,29 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "5940871", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" @@ -237,3 +237,9 @@ hyper = "1.0" reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" + +[patch.crates-io] +revm = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } +revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } +revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } +revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 04d62f48ba8f5..a04e134400412 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -2,7 +2,10 @@ use crate::eth::{backend::db::Db, error::BlockchainError}; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; -use alloy_provider::{ext::DebugApi, Provider}; +use alloy_provider::{ + ext::{DebugApi, TraceApi}, + Provider, +}; use alloy_rpc_types::{ request::TransactionRequest, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, @@ -183,7 +186,7 @@ impl ClientFork { block: Option, ) -> Result { let block = block.unwrap_or_default(); - let res = self.provider().estimate_gas(request).block_id(block.into()).await?; + let res = self.provider().estimate_gas(request).block(block.into()).await?; Ok(res) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 81f4ea6397029..895e7a3f93325 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1162,7 +1162,6 @@ impl Backend { access_list: access_list.unwrap_or_default().flattened(), blob_hashes: blob_versioned_hashes.unwrap_or_default(), optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, - ..Default::default() }; if env.block.basefee == revm::primitives::U256::ZERO { diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index fb8be9b99cdc3..dd52eedfa0e44 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -109,13 +109,13 @@ where *account, new_account_state .iter() - .map(|(key, value)| ((*key).into(), (*value))) + .map(|(key, value)| ((*key).into(), (*value).into())) .collect(), )?; } (None, Some(account_state_diff)) => { for (key, value) in account_state_diff.iter() { - cache_db.insert_account_storage(*account, (*key).into(), *value)?; + cache_db.insert_account_storage(*account, (*key).into(), (*value).into())?; } } }; diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 8dd9b570cab46..0f1d45d6fdf70 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -268,10 +268,7 @@ async fn can_call_with_state_override() { *simple_storage_contract.address(), AccountOverride { // The `lastSender` is in the first storage slot - state_diff: Some(HashMap::from([( - B256::ZERO, - U256::from_be_slice(B256::from(account.into_word()).as_slice()), - )])), + state_diff: Some(HashMap::from([(B256::ZERO, account.into_word())])), ..Default::default() }, )]); @@ -295,10 +292,7 @@ async fn can_call_with_state_override() { *simple_storage_contract.address(), AccountOverride { // The `lastSender` is in the first storage slot - state: Some(HashMap::from([( - B256::ZERO, - U256::from_be_slice(B256::from(account.into_word()).as_slice()), - )])), + state: Some(HashMap::from([(B256::ZERO, account.into_word())])), ..Default::default() }, )]); diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 011e489bba492..b06f7ce050459 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,7 +1,10 @@ use crate::{fork::fork_config, utils::http_provider_with_signer}; use alloy_network::{EthereumSigner, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes, U256}; -use alloy_provider::{ext::DebugApi, Provider}; +use alloy_provider::{ + ext::{DebugApi, TraceApi}, + Provider, +}; use alloy_rpc_types::{BlockNumberOrTag, TransactionRequest, WithOtherFields}; use alloy_rpc_types_trace::{ geth::{GethDebugTracingCallOptions, GethTrace}, diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index c48ce2d430302..d16cfac0f5999 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -104,7 +104,7 @@ impl EstimateArgs { .build_raw(sender) .await?; - let gas = provider.estimate_gas(&tx).block_id(block.unwrap_or_default()).await?; + let gas = provider.estimate_gas(&tx).block(block.unwrap_or_default()).await?; println!("{gas}"); Ok(()) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index f9c1becc9697e..1f6a615175527 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -17,8 +17,8 @@ use revm::{ inspectors::NoOpInspector, precompile::{PrecompileSpecId, Precompiles}, primitives::{ - Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, HashMap as Map, Log, - ResultAndState, SpecId, State, StorageSlot, TransactTo, KECCAK_EMPTY, + Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, EvmState, EvmStorageSlot, + HashMap as Map, Log, ResultAndState, SpecId, TransactTo, KECCAK_EMPTY, }, Database, DatabaseCommit, JournaledState, }; @@ -1361,7 +1361,7 @@ impl DatabaseExt for Backend { let slot = U256::from_be_bytes(slot.0); ( slot, - StorageSlot::new_changed( + EvmStorageSlot::new_changed( state_acc .storage .get(&slot) @@ -1893,7 +1893,7 @@ fn commit_transaction>( } /// Helper method which updates data in the state with the data from the database. -pub fn update_state(state: &mut State, db: &mut DB) -> Result<(), DB::Error> { +pub fn update_state(state: &mut EvmState, db: &mut DB) -> Result<(), DB::Error> { for (addr, acc) in state.iter_mut() { acc.info = db.basic(*addr)?.unwrap_or_default(); for (key, val) in acc.storage.iter_mut() { diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 230c068e61277..d8114f209e81e 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -16,7 +16,7 @@ use revm::{ }; use std::{cell::RefCell, rc::Rc, sync::Arc}; -pub use revm::primitives::State as StateChangeset; +pub use revm::primitives::EvmState as StateChangeset; /// Depending on the configured chain id and block number this should apply any specific changes /// diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index f8a1bd495a1d4..acb7cadea14c7 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -808,7 +808,6 @@ fn convert_executed_result( &env.tx.data, env.tx.transact_to.is_create(), &env.tx.access_list, - &env.tx.eof_initcodes, ); let result = match &out { diff --git a/deny.toml b/deny.toml index d69e73391da87..cdde3ec0cefc5 100644 --- a/deny.toml +++ b/deny.toml @@ -88,4 +88,5 @@ unknown-git = "deny" allow-git = [ "https://github.com/alloy-rs/alloy", "https://github.com/paradigmxyz/revm-inspectors", + "https://github.com/bluealloy/revm", ] From e764c316c96c8062e9bc52f78f7ee45ea359bc60 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 6 Jun 2024 13:30:37 +0200 Subject: [PATCH 1041/1963] perf(fuzz): use ahash for state (#8053) * perf(fuzz): use ahash for state * chore: clippy * fmt * Fix test --------- Co-authored-by: grandizzy --- Cargo.lock | 2 + Cargo.toml | 2 + crates/evm/evm/src/executors/mod.rs | 5 +- crates/evm/fuzz/Cargo.toml | 8 +- crates/evm/fuzz/src/inspector.rs | 3 +- crates/evm/fuzz/src/strategies/param.rs | 45 ++++----- crates/evm/fuzz/src/strategies/state.rs | 124 +++++++++++++----------- crates/forge/tests/cli/test_cmd.rs | 4 +- 8 files changed, 101 insertions(+), 92 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c4b9c57f1864..8d4cc5d111879 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,6 +45,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -3629,6 +3630,7 @@ dependencies = [ name = "foundry-evm-fuzz" version = "0.2.0" dependencies = [ + "ahash", "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index d3809d541136d..aca385035b3f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,6 +97,7 @@ scrypt.opt-level = 3 inherits = "dev" opt-level = 1 debug-assertions = false +overflow-checks = false strip = "debuginfo" panic = "abort" codegen-units = 16 @@ -200,6 +201,7 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc +ahash = "0.8" arrayvec = "0.7" base64 = "0.22" chrono = { version = "0.4", default-features = false, features = [ diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index acb7cadea14c7..ceb269a5391b8 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -50,7 +50,7 @@ pub use tracing::TracingExecutor; sol! { interface ITest { function setUp() external; - function failed() external view returns (bool); + function failed() external view returns (bool failed); } } @@ -515,8 +515,7 @@ impl Executor { let executor = Self::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); let call = executor.call_sol(CALLER, address, &ITest::failedCall {}, U256::ZERO, None); - if let Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { _0: failed } }) = - call + if let Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { failed } }) = call { debug!(failed, "DSTest::failed()"); success = !failed; diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 87d5d9ab306e2..4101c080f1b59 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -23,7 +23,12 @@ foundry-evm-traces.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } revm = { workspace = true, features = [ "std", "serde", @@ -43,3 +48,4 @@ serde = "1" thiserror = "1" tracing = "0.1" indexmap.workspace = true +ahash.workspace = true diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index fe5c134560bf8..052d87dac2dd1 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -1,5 +1,4 @@ use crate::{invariant::RandomCallGenerator, strategies::EvmFuzzState}; -use alloy_primitives::U256; use revm::{ interpreter::{CallInputs, CallOutcome, CallScheme, Interpreter}, Database, EvmContext, Inspector, @@ -62,7 +61,7 @@ impl Inspector for Fuzzer { impl Fuzzer { /// Collects `stack` and `memory` values into the fuzz dictionary. fn collect_data(&mut self, interpreter: &Interpreter) { - self.fuzz_state.collect_values(interpreter.stack().data().iter().map(U256::to_be_bytes)); + self.fuzz_state.collect_values(interpreter.stack().data().iter().copied().map(Into::into)); // TODO: disabled for now since it's flooding the dictionary // for index in 0..interpreter.shared_memory.len() / 32 { diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index df7fb28c09161..0b64418d613d7 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -128,33 +128,23 @@ pub fn fuzz_param_from_state( // Generate a bias and use it to pick samples or non-persistent values (50 / 50). // Use `Index` instead of `Selector` when selecting a value to avoid iterating over the // entire dictionary. - ((0..100).prop_flat_map(Just), any::()).prop_map( - move |(bias, index)| { - let state = state.dictionary_read(); - let values = match bias { - x if x < 50 => { - if let Some(sample_values) = state.samples(param.clone()) { - sample_values - } else { - state.values() - } - } - _ => state.values(), - }; - let index = index.index(values.len()); - *values.iter().nth(index).unwrap() - }, - ) + any::<(bool, prop::sample::Index)>().prop_map(move |(bias, index)| { + let state = state.dictionary_read(); + let values = if bias { state.samples(¶m) } else { None } + .unwrap_or_else(|| state.values()) + .as_slice(); + values[index.index(values.len())] + }) }; // Convert the value based on the parameter type match *param { - DynSolType::Address => value() - .prop_map(move |value| DynSolValue::Address(Address::from_word(value.into()))) - .boxed(), + DynSolType::Address => { + value().prop_map(move |value| DynSolValue::Address(Address::from_word(value))).boxed() + } DynSolType::Function => value() .prop_map(move |value| { - DynSolValue::Function(alloy_primitives::Function::from_word(value.into())) + DynSolValue::Function(alloy_primitives::Function::from_word(value)) }) .boxed(), DynSolType::FixedBytes(size @ 1..=32) => value() @@ -172,19 +162,17 @@ pub fn fuzz_param_from_state( }) .boxed(), DynSolType::Bytes => { - value().prop_map(move |value| DynSolValue::Bytes(value.into())).boxed() + value().prop_map(move |value| DynSolValue::Bytes(value.0.into())).boxed() } DynSolType::Int(n @ 8..=256) => match n / 8 { 32 => value() - .prop_map(move |value| { - DynSolValue::Int(I256::from_raw(U256::from_be_bytes(value)), 256) - }) + .prop_map(move |value| DynSolValue::Int(I256::from_raw(value.into()), 256)) .boxed(), 1..=31 => value() .prop_map(move |value| { // Generate a uintN in the correct range, then shift it to the range of intN // by subtracting 2^(N-1) - let uint = U256::from_be_bytes(value) % U256::from(1).wrapping_shl(n); + let uint = U256::from_be_bytes(value.0) % U256::from(1).wrapping_shl(n); let max_int_plus1 = U256::from(1).wrapping_shl(n - 1); let num = I256::from_raw(uint.wrapping_sub(max_int_plus1)); DynSolValue::Int(num, n) @@ -194,11 +182,12 @@ pub fn fuzz_param_from_state( }, DynSolType::Uint(n @ 8..=256) => match n / 8 { 32 => value() - .prop_map(move |value| DynSolValue::Uint(U256::from_be_bytes(value), 256)) + .prop_map(move |value| DynSolValue::Uint(U256::from_be_bytes(value.0), 256)) .boxed(), 1..=31 => value() .prop_map(move |value| { - DynSolValue::Uint(U256::from_be_bytes(value) % U256::from(1).wrapping_shl(n), n) + let uint = U256::from_be_bytes(value.0) % U256::from(1).wrapping_shl(n); + DynSolValue::Uint(uint, n) }) .boxed(), _ => unreachable!(), diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 3e4628d9a441d..59a037156c95d 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -18,6 +18,8 @@ use std::{ sync::Arc, }; +type AIndexSet = IndexSet>; + /// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). /// /// This is to limit the performance impact of fuzz tests that might deploy arbitrarily sized @@ -44,7 +46,7 @@ impl EvmFuzzState { Self { inner: Arc::new(RwLock::new(dictionary)) } } - pub fn collect_values(&self, values: impl IntoIterator) { + pub fn collect_values(&self, values: impl IntoIterator) { let mut dict = self.inner.write(); for value in values { dict.insert_value(value, true); @@ -93,9 +95,9 @@ impl EvmFuzzState { #[derive(Default)] pub struct FuzzDictionary { /// Collected state values. - state_values: IndexSet<[u8; 32]>, + state_values: AIndexSet, /// Addresses that already had their PUSH bytes collected. - addresses: IndexSet
, + addresses: AIndexSet
, /// Configuration for the dictionary. config: FuzzDictionaryConfig, /// New key indexes added to the dictionary since container initialization. @@ -103,7 +105,7 @@ pub struct FuzzDictionary { /// New address indexes added to the dictionary since container initialization. new_addreses: Vec, /// Sample typed values that are collected from call result and used across invariant runs. - sample_values: HashMap>, + sample_values: HashMap>, misses: usize, hits: usize, @@ -127,32 +129,33 @@ impl FuzzDictionary { /// Insert common values into the dictionary at initialization. fn prefill(&mut self) { - self.insert_value([0; 32], false); + self.insert_value(B256::ZERO, false); } /// Insert values from initial db state into fuzz dictionary. /// These values are persisted across invariant runs. fn insert_db_values(&mut self, db_state: Vec<(&Address, &DbAccount)>) { + let collected = false; for (address, account) in db_state { // Insert basic account information - self.insert_value(address.into_word().into(), false); + self.insert_value(address.into_word(), collected); // Insert push bytes - self.insert_push_bytes_values(address, &account.info, false); + self.insert_push_bytes_values(address, &account.info, collected); // Insert storage values. if self.config.include_storage { // Sort storage values before inserting to ensure deterministic dictionary. let values = account.storage.iter().collect::>(); for (slot, value) in values { - self.insert_storage_value(slot, value, false); + self.insert_storage_value(slot, value, collected); } } } - // need at least some state data if db is empty otherwise we can't select random data for - // state fuzzing + // We need at least some state data if DB is empty, + // otherwise we can't select random data for state fuzzing. if self.values().is_empty() { - // prefill with a random addresses - self.insert_value(Address::random().into_word().into(), false); + // Prefill with a random address. + self.insert_value(Address::random().into_word(), false); } } @@ -193,8 +196,8 @@ impl FuzzDictionary { // If we weren't able to decode event then we insert raw data in fuzz dictionary. if !log_decoded { - for topic in log.topics() { - self.insert_value(topic.0, true); + for &topic in log.topics() { + self.insert_value(topic, true); } let chunks = log.data.data.chunks_exact(32); let rem = chunks.remainder(); @@ -202,7 +205,7 @@ impl FuzzDictionary { self.insert_value(chunk.try_into().unwrap(), true); } if !rem.is_empty() { - self.insert_value(B256::right_padding_from(rem).0, true); + self.insert_value(B256::right_padding_from(rem), true); } } } @@ -214,15 +217,16 @@ impl FuzzDictionary { /// Insert values from call state changeset into fuzz dictionary. /// These values are removed at the end of current run. fn insert_state_values(&mut self, state_changeset: &StateChangeset) { + let collected = true; for (address, account) in state_changeset { // Insert basic account information. - self.insert_value(address.into_word().into(), true); + self.insert_value(address.into_word(), collected); // Insert push bytes. - self.insert_push_bytes_values(address, &account.info, true); + self.insert_push_bytes_values(address, &account.info, collected); // Insert storage values. if self.config.include_storage { for (slot, value) in &account.storage { - self.insert_storage_value(slot, &value.present_value, true); + self.insert_storage_value(slot, &value.present_value, collected); } } } @@ -239,7 +243,7 @@ impl FuzzDictionary { ) { if self.config.include_push_bytes && !self.addresses.contains(address) { // Insert push bytes - if let Some(code) = account_info.code.clone() { + if let Some(code) = &account_info.code { self.insert_address(*address, collected); self.collect_push_bytes(code.bytes_slice(), collected); } @@ -262,16 +266,16 @@ impl FuzzDictionary { } let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); - // Also add the value below and above the push value to the dictionary. if push_value != U256::ZERO { - // Never add 0 to the dictionary as it's always present, and it's a pretty - // common value that this is worth it. - self.insert_value(push_value.to_be_bytes(), collected); + // Never add 0 to the dictionary as it's always present. + self.insert_value(push_value.into(), collected); - self.insert_value((push_value - U256::from(1)).to_be_bytes(), collected); - } - if push_value != U256::MAX { - self.insert_value((push_value + U256::from(1)).to_be_bytes(), collected); + // Also add the value below and above the push value to the dictionary. + self.insert_value((push_value - U256::from(1)).into(), collected); + + if push_value != U256::MAX { + self.insert_value((push_value + U256::from(1)).into(), collected); + } } i += push_size; @@ -283,16 +287,16 @@ impl FuzzDictionary { /// Insert values from single storage slot and storage value into fuzz dictionary. /// If storage values are newly collected then they are removed at the end of current run. fn insert_storage_value(&mut self, storage_slot: &U256, storage_value: &U256, collected: bool) { - self.insert_value(B256::from(*storage_slot).0, collected); - self.insert_value(B256::from(*storage_value).0, collected); + self.insert_value(B256::from(*storage_slot), collected); + self.insert_value(B256::from(*storage_value), collected); // also add the value below and above the storage value to the dictionary. if *storage_value != U256::ZERO { let below_value = storage_value - U256::from(1); - self.insert_value(B256::from(below_value).0, collected); + self.insert_value(B256::from(below_value), collected); } if *storage_value != U256::MAX { let above_value = storage_value + U256::from(1); - self.insert_value(B256::from(above_value).0, collected); + self.insert_value(B256::from(above_value), collected); } } @@ -309,7 +313,7 @@ impl FuzzDictionary { /// Insert raw value into fuzz dictionary. /// If value is newly collected then it is removed by index at the end of current run. - fn insert_value(&mut self, value: [u8; 32], collected: bool) { + fn insert_value(&mut self, value: B256, collected: bool) { if self.state_values.len() < self.config.max_fuzz_dictionary_values { let (index, new_value) = self.state_values.insert_full(value); let counter = if new_value { &mut self.misses } else { &mut self.hits }; @@ -323,10 +327,13 @@ impl FuzzDictionary { /// Insert sample values that are reused across multiple runs. /// The number of samples is limited to invariant run depth. /// If collected samples limit is reached then values are inserted as regular values. - pub fn insert_sample_values(&mut self, sample_values: Vec, limit: u32) { + pub fn insert_sample_values( + &mut self, + sample_values: impl IntoIterator, + limit: u32, + ) { for sample in sample_values { if let (Some(sample_type), Some(sample_value)) = (sample.as_type(), sample.as_word()) { - let sample_value = sample_value.into(); if let Some(values) = self.sample_values.get_mut(&sample_type) { if values.len() < limit as usize { values.insert(sample_value); @@ -341,7 +348,7 @@ impl FuzzDictionary { } } - pub fn values(&self) -> &IndexSet<[u8; 32]> { + pub fn values(&self) -> &AIndexSet { &self.state_values } @@ -354,12 +361,12 @@ impl FuzzDictionary { } #[inline] - pub fn samples(&self, param_type: DynSolType) -> Option<&IndexSet<[u8; 32]>> { - self.sample_values.get(¶m_type) + pub fn samples(&self, param_type: &DynSolType) -> Option<&AIndexSet> { + self.sample_values.get(param_type) } #[inline] - pub fn addresses(&self) -> &IndexSet
{ + pub fn addresses(&self) -> &AIndexSet
{ &self.addresses } @@ -400,25 +407,30 @@ pub fn collect_created_contracts( ) -> eyre::Result<()> { let mut writable_targeted = targeted_contracts.targets.lock(); for (address, account) in state_changeset { - if !setup_contracts.contains_key(address) { - if let (true, Some(code)) = (&account.is_touched(), &account.info.code) { - if !code.is_empty() { - if let Some((artifact, contract)) = - project_contracts.find_by_deployed_code(&code.original_bytes()) - { - if let Some(functions) = - artifact_filters.get_targeted_functions(artifact, &contract.abi)? - { - created_contracts.push(*address); - writable_targeted.insert( - *address, - (artifact.name.clone(), contract.abi.clone(), functions), - ); - } - } - } - } + if setup_contracts.contains_key(address) { + continue; + } + if !account.is_touched() { + continue; + } + let Some(code) = &account.info.code else { + continue; + }; + if code.is_empty() { + continue; } + let Some((artifact, contract)) = + project_contracts.find_by_deployed_code(code.original_byte_slice()) + else { + continue; + }; + let Some(functions) = artifact_filters.get_targeted_functions(artifact, &contract.abi)? + else { + continue; + }; + created_contracts.push(*address); + writable_targeted + .insert(*address, (artifact.name.clone(), contract.abi.clone(), functions)); } Ok(()) } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index c9f76a3aa6115..0e4f24138b1fb 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -591,6 +591,6 @@ contract CounterTest is Test { let runs_split = &stderr[start_runs + 6..]; runs_split.find(',').map(|end_runs| &runs_split[..end_runs]) }); - // make sure there are only 54 runs (with proptest shrinking same test results in 292 runs) - assert_eq!(runs.unwrap().parse::().unwrap(), 54); + // make sure there are only 61 runs (with proptest shrinking same test results in 298 runs) + assert_eq!(runs.unwrap().parse::().unwrap(), 61); }); From 7e6ebaf09dcb1ca6f7087d87d20d8ef9435a3ec6 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 6 Jun 2024 15:29:58 +0200 Subject: [PATCH 1042/1963] fix: ensure suggested prio fee is at least 1e9 (#8081) --- crates/anvil/src/eth/api.rs | 16 +++++++--------- crates/anvil/src/eth/backend/mem/mod.rs | 8 ++++---- crates/anvil/src/eth/fees.rs | 3 +++ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 1afb7cd339eff..57acc197cb8d9 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -14,7 +14,7 @@ use crate::{ error::{ BlockchainError, FeeHistoryError, InvalidTransactionError, Result, ToRpcResponseResult, }, - fees::{FeeDetails, FeeHistoryCache}, + fees::{FeeDetails, FeeHistoryCache, MIN_SUGGESTED_PRIORITY_FEE}, macros::node_info, miner::FixedBlockTimeMiner, pool::{ @@ -1357,20 +1357,18 @@ impl EthApi { } /// Returns the suggested fee cap. + /// + /// Returns at least [MIN_SUGGESTED_PRIORITY_FEE] fn lowest_suggestion_tip(&self) -> u128 { let block_number = self.backend.best_number(); let latest_cached_block = self.fee_history_cache.lock().get(&block_number).cloned(); match latest_cached_block { - Some(block) => block.rewards.iter().copied().min().unwrap_or(1e9 as u128), - None => self - .fee_history_cache - .lock() - .values() - .flat_map(|b| b.rewards.clone()) - .min() - .unwrap_or(1e9 as u128), + Some(block) => block.rewards.iter().copied().min(), + None => self.fee_history_cache.lock().values().flat_map(|b| b.rewards.clone()).min(), } + .map(|fee| fee.max(MIN_SUGGESTED_PRIORITY_FEE)) + .unwrap_or(MIN_SUGGESTED_PRIORITY_FEE) } /// Creates a filter object, based on filter options, to notify when the state changes (logs). diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 895e7a3f93325..2619c75569b24 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -19,7 +19,7 @@ use crate::{ validate::TransactionValidator, }, error::{BlockchainError, ErrDetail, InvalidTransactionError}, - fees::{FeeDetails, FeeManager}, + fees::{FeeDetails, FeeManager, MIN_SUGGESTED_PRIORITY_FEE}, macros::node_info, pool::transactions::PoolTransaction, util::get_precompiles_for, @@ -1140,9 +1140,9 @@ impl Backend { env.block.basefee = U256::from(base); } - let gas_price = gas_price - .or(max_fee_per_gas) - .unwrap_or_else(|| self.fees().raw_gas_price().saturating_add(1e9 as u128)); + let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| { + self.fees().raw_gas_price().saturating_add(MIN_SUGGESTED_PRIORITY_FEE) + }); let caller = from.unwrap_or_default(); let to = to.as_ref().and_then(TxKind::to); env.tx = TxEnv { diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 922f149e3e665..e0c8685fd567f 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -31,6 +31,9 @@ pub const INITIAL_GAS_PRICE: u128 = 1_875_000_000; /// Bounds the amount the base fee can change between blocks. pub const BASE_FEE_CHANGE_DENOMINATOR: u128 = 8; +/// Minimum suggested priority fee +pub const MIN_SUGGESTED_PRIORITY_FEE: u128 = 1e9 as u128; + pub fn default_elasticity() -> f64 { 1f64 / BaseFeeParams::ethereum().elasticity_multiplier as f64 } From 11388608b48ce7bd4b46161810da72b230df97b4 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:01:55 +0530 Subject: [PATCH 1043/1963] fix(verify-bytecode): check contract name in cache (#8079) * fix(verify-bytecode): strongly check contract name when fetching from cache * nit * nits * nit * clippy --- crates/verify/src/bytecode.rs | 49 +++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index b49af60063ebc..ee7c5dddee188 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -225,11 +225,13 @@ impl VerifyBytecodeArgs { (VerificationType::Partial, _) => (VerificationType::Partial, true), }; + trace!(?verification_type, has_metadata); // Etherscan compilation metadata let etherscan_metadata = source_code.items.first().unwrap(); let local_bytecode = if let Some(local_bytecode) = self.build_using_cache(etherscan_metadata, &config) { + trace!("using cache"); local_bytecode } else { self.build_project(&config)? @@ -411,37 +413,44 @@ impl VerifyBytecodeArgs { for (key, value) in cached_artifacts { let name = self.contract.name.to_owned() + ".sol"; let version = etherscan_settings.compiler_version.to_owned(); + // Ignores vyper if version.starts_with("vyper:") { return None; } // Parse etherscan version string let version = version.split('+').next().unwrap_or("").trim_start_matches('v').to_string(); + + // Check if `out/directory` name matches the contract name if key.ends_with(name.as_str()) { - if let Some(artifact) = value.into_iter().next() { + let artifacts = + value.iter().flat_map(|(_, artifacts)| artifacts.iter()).collect::>(); + let name = name.replace(".sol", ".json"); + for artifact in artifacts { + // Check if ABI file matches the name + if !artifact.file.ends_with(&name) { + continue; + } + + // Check if Solidity version matches if let Ok(version) = Version::parse(&version) { - if let Some(artifact) = artifact.1.iter().find(|a| { - a.version.major == version.major && - a.version.minor == version.minor && - a.version.patch == version.patch - }) { - return artifact - .artifact - .bytecode - .as_ref() - .and_then(|bytes| bytes.bytes().to_owned()) - .cloned(); + if !(artifact.version.major == version.major && + artifact.version.minor == version.minor && + artifact.version.patch == version.patch) + { + continue; } } - let artifact = artifact.1.first().unwrap(); // Get the first artifact - let local_bytecode = if let Some(local_bytecode) = &artifact.artifact.bytecode { - local_bytecode.bytes() - } else { - None - }; - - return local_bytecode.map(|bytes| bytes.to_owned()); + + return artifact + .artifact + .bytecode + .as_ref() + .and_then(|bytes| bytes.bytes().to_owned()) + .cloned(); } + + return None } } From 0248a62892bb958c986b43d2444d318f960ad99b Mon Sep 17 00:00:00 2001 From: Dhairya Sethi <55102840+DhairyaSethi@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:40:11 +0530 Subject: [PATCH 1044/1963] feat(cheatcode): promptSecretUint (#8082) --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 4 ++++ crates/cheatcodes/src/fs.rs | 7 +++++++ crates/evm/traces/src/decoder/mod.rs | 2 +- testdata/cheats/Vm.sol | 1 + testdata/default/cheats/Prompt.t.sol | 3 +++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 3f2f3cb334617..786fc38b480ae 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6371,6 +6371,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "promptSecretUint", + "description": "Prompts the user for hidden uint256 in the terminal (usually pk).", + "declaration": "function promptSecretUint(string calldata promptText) external returns (uint256);", + "visibility": "external", + "mutability": "", + "signature": "promptSecretUint(string)", + "selector": "0x69ca02b7", + "selectorBytes": [ + 105, + 202, + 2, + 183 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "promptUint", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 410039852ec77..1538dc16ecd87 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1499,6 +1499,10 @@ interface Vm { #[cheatcode(group = Filesystem)] function promptSecret(string calldata promptText) external returns (string memory input); + /// Prompts the user for hidden uint256 in the terminal (usually pk). + #[cheatcode(group = Filesystem)] + function promptSecretUint(string calldata promptText) external returns (uint256); + /// Prompts the user for an address in the terminal. #[cheatcode(group = Filesystem)] function promptAddress(string calldata promptText) external returns (address); diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index c50f2cf9702d3..e4ee12513e4e4 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -426,6 +426,13 @@ impl Cheatcode for promptSecretCall { } } +impl Cheatcode for promptSecretUintCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { promptText: text } = self; + parse(&prompt(state, text, prompt_password)?, &DynSolType::Uint(256)) + } +} + impl Cheatcode for promptAddressCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { promptText: text } = self; diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 75ea3d2602a90..2dbdbd7bf1ceb 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -523,7 +523,7 @@ impl CallTraceDecoder { match func.name.as_str() { s if s.starts_with("env") => Some(""), "createWallet" | "deriveKey" => Some(""), - "promptSecret" => Some(""), + "promptSecret" | "promptSecretUint" => Some(""), "parseJson" if self.verbosity < 5 => Some(""), "readFile" if self.verbosity < 5 => Some(""), _ => None, diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index e1551362a5a58..23e1f699c89d1 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -314,6 +314,7 @@ interface Vm { function prompt(string calldata promptText) external returns (string memory input); function promptAddress(string calldata promptText) external returns (address); function promptSecret(string calldata promptText) external returns (string memory input); + function promptSecretUint(string calldata promptText) external returns (uint256); function promptUint(string calldata promptText) external returns (uint256); function randomAddress() external returns (address); function randomUint() external returns (uint256); diff --git a/testdata/default/cheats/Prompt.t.sol b/testdata/default/cheats/Prompt.t.sol index 9e461c2b527e0..33f83fea85ea4 100644 --- a/testdata/default/cheats/Prompt.t.sol +++ b/testdata/default/cheats/Prompt.t.sol @@ -15,6 +15,9 @@ contract PromptTest is DSTest { vm._expectCheatcodeRevert(); vm.promptSecret("test"); + + vm._expectCheatcodeRevert(); + uint256 test = vm.promptSecretUint("test"); } function testPrompt_Address() public { From 729a76629eb787354d17dfa6a9350ce45382c8b5 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 6 Jun 2024 19:06:14 +0200 Subject: [PATCH 1045/1963] feat: add `skip` key to foundry.toml (#8061) * feat: introduce 'skip' config key * update patch * conflicts * fix test * fmt * update patch * fix doc * update patch * update patch * rm patch * bump compilers * review fixes * fix tests --- Cargo.lock | 10 +- Cargo.toml | 4 +- crates/cli/src/opts/build/core.rs | 20 ++- crates/common/Cargo.toml | 2 - crates/common/src/compile.rs | 178 +++--------------------- crates/common/src/glob.rs | 94 ------------- crates/common/src/lib.rs | 1 - crates/config/Cargo.toml | 1 + crates/config/src/filter.rs | 204 ++++++++++++++++++++++++++++ crates/config/src/lib.rs | 43 +++++- crates/doc/Cargo.toml | 1 - crates/doc/src/builder.rs | 3 +- crates/forge/bin/cmd/bind.rs | 36 ++--- crates/forge/bin/cmd/build.rs | 27 +--- crates/forge/bin/cmd/fmt.rs | 4 +- crates/forge/bin/cmd/test/filter.rs | 3 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/tests/cli/build.rs | 29 ++++ crates/forge/tests/cli/config.rs | 1 + crates/script/src/lib.rs | 7 - crates/verify/src/bytecode.rs | 15 +- 21 files changed, 356 insertions(+), 329 deletions(-) delete mode 100644 crates/common/src/glob.rs create mode 100644 crates/config/src/filter.rs diff --git a/Cargo.lock b/Cargo.lock index 8d4cc5d111879..263fa9de3422d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3184,7 +3184,6 @@ dependencies = [ "derive_more", "eyre", "forge-fmt", - "foundry-common", "foundry-compilers", "foundry-config", "itertools 0.13.0", @@ -3437,8 +3436,6 @@ dependencies = [ "foundry-config", "foundry-linking", "foundry-macros", - "glob", - "globset", "num-format", "once_cell", "reqwest", @@ -3459,16 +3456,18 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe70a3860ec9f1861e5d82cbd4ffc55756975c0826dacf8ae4d6d696df8f7f53" +checksum = "f9a92aa3e4d0aa91fda44c1840c68d634fc126bdd06099516eb2b81035e5e6d0" dependencies = [ "alloy-json-abi", "alloy-primitives", "auto_impl", "cfg-if", + "derivative", "dirs 5.0.1", "dunce", + "dyn-clone", "fs_extra", "futures-util", "home", @@ -3509,6 +3508,7 @@ dependencies = [ "figment", "foundry-block-explorers", "foundry-compilers", + "glob", "globset", "number_prefix", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index aca385035b3f3..eac8025a4103e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,7 +153,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.3.0", default-features = false } -foundry-compilers = { version = "0.6.0", default-features = false } +foundry-compilers = { version = "0.6.2", default-features = false } ## revm # no default features to avoid c-kzg @@ -244,4 +244,4 @@ tower-http = "0.5" revm = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } -revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } +revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } \ No newline at end of file diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 3d45de22577d8..bf0fd019f694f 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -13,6 +13,7 @@ use foundry_config::{ value::{Dict, Map, Value}, Figment, Metadata, Profile, Provider, }, + filter::SkipBuildFilter, providers::remappings::Remappings, Config, }; @@ -118,6 +119,13 @@ pub struct CoreBuildArgs { #[serde(skip_serializing_if = "Option::is_none")] pub build_info_path: Option, + /// Skip building files whose names contain the given filter. + /// + /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. + #[arg(long, num_args(1..))] + #[serde(skip)] + pub skip: Option>, + #[command(flatten)] #[serde(flatten)] pub compiler: CompilerArgs, @@ -148,7 +156,7 @@ impl CoreBuildArgs { // Loads project's figment and merges the build cli arguments into it impl<'a> From<&'a CoreBuildArgs> for Figment { fn from(args: &'a CoreBuildArgs) -> Self { - let figment = if let Some(ref config_path) = args.project_paths.config_path { + let mut figment = if let Some(ref config_path) = args.project_paths.config_path { if !config_path.exists() { panic!("error: config-path `{}` does not exist", config_path.display()) } @@ -165,7 +173,15 @@ impl<'a> From<&'a CoreBuildArgs> for Figment { let mut remappings = Remappings::new_with_remappings(args.project_paths.get_remappings()); remappings .extend(figment.extract_inner::>("remappings").unwrap_or_default()); - figment.merge(("remappings", remappings.into_inner())).merge(args) + figment = figment.merge(("remappings", remappings.into_inner())).merge(args); + + if let Some(skip) = &args.skip { + let mut skip = skip.iter().map(|s| s.file_pattern().to_string()).collect::>(); + skip.extend(figment.extract_inner::>("skip").unwrap_or_default()); + figment = figment.merge(("skip", skip)); + }; + + figment } } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 5b11a1be90a0e..1a48e80acd658 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -42,8 +42,6 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" dunce = "1" eyre.workspace = true -glob = "0.3" -globset = "0.4" once_cell = "1" reqwest.workspace = true semver = "1" diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 13fb79be06b9d..4ab4b170d9d65 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,28 +1,25 @@ //! Support for compiling [foundry_compilers::Project] -use crate::{compact_to_contract, glob::GlobMatcher, term::SpinnerReporter, TestFunctionExt}; +use crate::{compact_to_contract, term::SpinnerReporter, TestFunctionExt}; use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, Table}; use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ - artifacts::{BytecodeObject, ContractBytecodeSome, Libraries}, - compilers::{solc::SolcCompiler, Compiler}, + artifacts::{BytecodeObject, ContractBytecodeSome, Libraries, Source}, + compilers::{solc::SolcCompiler, CompilationError, Compiler}, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, - Artifact, ArtifactId, FileFilter, Project, ProjectBuilder, ProjectCompileOutput, - ProjectPathsConfig, Solc, SolcConfig, SparseOutputFileFilter, + Artifact, ArtifactId, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, Solc, + SolcConfig, }; use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; use rustc_hash::FxHashMap; use std::{ collections::{BTreeMap, HashMap}, - convert::Infallible, fmt::Display, io::IsTerminal, path::{Path, PathBuf}, - result, - str::FromStr, time::Instant, }; @@ -31,7 +28,7 @@ use std::{ /// This is merely a wrapper for [`Project::compile()`] which also prints to stdout depending on its /// settings. #[must_use = "ProjectCompiler does nothing unless you call a `compile*` method"] -pub struct ProjectCompiler { +pub struct ProjectCompiler { /// Whether we are going to verify the contracts after compilation. verify: Option, @@ -47,21 +44,18 @@ pub struct ProjectCompiler { /// Whether to bail on compiler errors. bail: Option, - /// Files to exclude. - filter: Option>>, - /// Extra files to include, that are not necessarily in the project's source dir. files: Vec, } -impl Default for ProjectCompiler { +impl Default for ProjectCompiler { #[inline] fn default() -> Self { Self::new() } } -impl ProjectCompiler { +impl ProjectCompiler { /// Create a new builder with the default settings. #[inline] pub fn new() -> Self { @@ -71,7 +65,6 @@ impl ProjectCompiler { print_sizes: None, quiet: Some(crate::shell::verbosity().is_silent()), bail: None, - filter: None, files: Vec::new(), } } @@ -121,13 +114,6 @@ impl ProjectCompiler { self } - /// Sets the filter to use. - #[inline] - pub fn filter(mut self, filter: Box>) -> Self { - self.filter = Some(filter); - self - } - /// Sets extra files to include, that are not necessarily in the project's source dir. #[inline] pub fn files(mut self, files: impl IntoIterator) -> Self { @@ -136,7 +122,7 @@ impl ProjectCompiler { } /// Compiles the project. - pub fn compile( + pub fn compile( mut self, project: &Project, ) -> Result> { @@ -148,17 +134,17 @@ impl ProjectCompiler { } // Taking is fine since we don't need these in `compile_with`. - let filter = std::mem::take(&mut self.filter); let files = std::mem::take(&mut self.files); self.compile_with(|| { - if !files.is_empty() { - project.compile_files(files) - } else if let Some(filter) = filter { - project.compile_sparse(filter) + let sources = if !files.is_empty() { + Source::read_all(files)? } else { - project.compile() - } - .map_err(Into::into) + project.paths.read_input_files()? + }; + + foundry_compilers::project::ProjectCompiler::with_sources(project, sources)? + .compile() + .map_err(Into::into) }) } @@ -173,9 +159,9 @@ impl ProjectCompiler { /// ProjectCompiler::new().compile_with(|| Ok(prj.compile()?)).unwrap(); /// ``` #[instrument(target = "forge::compile", skip_all)] - fn compile_with(self, f: F) -> Result> + fn compile_with(self, f: F) -> Result> where - F: FnOnce() -> Result>, + F: FnOnce() -> Result>, { let quiet = self.quiet.unwrap_or(false); let bail = self.bail.unwrap_or(true); @@ -223,7 +209,7 @@ impl ProjectCompiler { } /// If configured, this will print sizes or names - fn handle_output(&self, output: &ProjectCompileOutput) { + fn handle_output(&self, output: &ProjectCompileOutput) { let print_names = self.print_names.unwrap_or(false); let print_sizes = self.print_sizes.unwrap_or(false); @@ -479,7 +465,7 @@ pub fn compile_target( project: &Project, quiet: bool, ) -> Result> { - ProjectCompiler::::new().quiet(quiet).files([target_path.into()]).compile(project) + ProjectCompiler::new().quiet(quiet).files([target_path.into()]).compile(project) } /// Compiles an Etherscan source from metadata by creating a project. @@ -563,125 +549,3 @@ pub fn etherscan_project( .no_artifacts() .build(compiler)?) } - -/// Bundles multiple `SkipBuildFilter` into a single `FileFilter` -#[derive(Clone, Debug)] -pub struct SkipBuildFilters { - /// All provided filters. - pub matchers: Vec, - /// Root of the project. - pub project_root: PathBuf, -} - -impl FileFilter for SkipBuildFilters { - /// Only returns a match if _no_ exclusion filter matches - fn is_match(&self, file: &Path) -> bool { - self.matchers.iter().all(|matcher| { - if !is_match_exclude(matcher, file) { - false - } else { - file.strip_prefix(&self.project_root) - .map_or(true, |stripped| is_match_exclude(matcher, stripped)) - } - }) - } -} - -impl FileFilter for &SkipBuildFilters { - fn is_match(&self, file: &Path) -> bool { - (*self).is_match(file) - } -} - -impl SkipBuildFilters { - /// Creates a new `SkipBuildFilters` from multiple `SkipBuildFilter`. - pub fn new( - filters: impl IntoIterator, - project_root: PathBuf, - ) -> Result { - let matchers = filters.into_iter().map(|m| m.compile()).collect::>(); - matchers.map(|filters| Self { matchers: filters, project_root }) - } -} - -/// A filter that excludes matching contracts from the build -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum SkipBuildFilter { - /// Exclude all `.t.sol` contracts - Tests, - /// Exclude all `.s.sol` contracts - Scripts, - /// Exclude if the file matches - Custom(String), -} - -impl SkipBuildFilter { - fn new(s: &str) -> Self { - match s { - "test" | "tests" => Self::Tests, - "script" | "scripts" => Self::Scripts, - s => Self::Custom(s.to_string()), - } - } - - /// Returns the pattern to match against a file - fn file_pattern(&self) -> &str { - match self { - Self::Tests => ".t.sol", - Self::Scripts => ".s.sol", - Self::Custom(s) => s.as_str(), - } - } - - fn compile(&self) -> Result { - self.file_pattern().parse().map_err(Into::into) - } -} - -impl FromStr for SkipBuildFilter { - type Err = Infallible; - - fn from_str(s: &str) -> result::Result { - Ok(Self::new(s)) - } -} - -/// Matches file only if the filter does not apply. -/// -/// This returns the inverse of `file.name.contains(pattern) || matcher.is_match(file)`. -fn is_match_exclude(matcher: &GlobMatcher, path: &Path) -> bool { - fn is_match(matcher: &GlobMatcher, path: &Path) -> Option { - let file_name = path.file_name()?.to_str()?; - Some(file_name.contains(matcher.as_str()) || matcher.is_match(path)) - } - - !is_match(matcher, path).unwrap_or_default() -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_build_filter() { - let tests = SkipBuildFilter::Tests.compile().unwrap(); - let scripts = SkipBuildFilter::Scripts.compile().unwrap(); - let custom = |s: &str| SkipBuildFilter::Custom(s.to_string()).compile().unwrap(); - - let file = Path::new("A.t.sol"); - assert!(!is_match_exclude(&tests, file)); - assert!(is_match_exclude(&scripts, file)); - assert!(!is_match_exclude(&custom("A.t"), file)); - - let file = Path::new("A.s.sol"); - assert!(is_match_exclude(&tests, file)); - assert!(!is_match_exclude(&scripts, file)); - assert!(!is_match_exclude(&custom("A.s"), file)); - - let file = Path::new("/home/test/Foo.sol"); - assert!(!is_match_exclude(&custom("*/test/**"), file)); - - let file = Path::new("/home/script/Contract.sol"); - assert!(!is_match_exclude(&custom("*/script/**"), file)); - } -} diff --git a/crates/common/src/glob.rs b/crates/common/src/glob.rs deleted file mode 100644 index 070f703675fd8..0000000000000 --- a/crates/common/src/glob.rs +++ /dev/null @@ -1,94 +0,0 @@ -//! Contains `globset::Glob` wrapper functions used for filtering. - -use std::{ - fmt, - path::{Path, PathBuf}, - str::FromStr, -}; - -/// Expand globs with a root path. -pub fn expand_globs( - root: &Path, - patterns: impl IntoIterator>, -) -> eyre::Result> { - let mut expanded = Vec::new(); - for pattern in patterns { - for paths in glob::glob(&root.join(pattern.as_ref()).display().to_string())? { - expanded.push(paths?); - } - } - Ok(expanded) -} - -/// A `globset::Glob` that creates its `globset::GlobMatcher` when its created, so it doesn't need -/// to be compiled when the filter functions `TestFilter` functions are called. -#[derive(Clone, Debug)] -pub struct GlobMatcher { - /// The compiled glob - pub matcher: globset::GlobMatcher, -} - -impl GlobMatcher { - /// Creates a new `GlobMatcher` from a `globset::Glob`. - pub fn new(glob: globset::Glob) -> Self { - Self { matcher: glob.compile_matcher() } - } - - /// Tests whether the given path matches this pattern or not. - /// - /// The glob `./test/*` won't match absolute paths like `test/Contract.sol`, which is common - /// format here, so we also handle this case here - pub fn is_match(&self, path: &Path) -> bool { - if self.matcher.is_match(path) { - return true; - } - - if !path.starts_with("./") && self.as_str().starts_with("./") { - return self.matcher.is_match(format!("./{}", path.display())); - } - - false - } - - /// Returns the `globset::Glob`. - pub fn glob(&self) -> &globset::Glob { - self.matcher.glob() - } - - /// Returns the `Glob` string used to compile this matcher. - pub fn as_str(&self) -> &str { - self.glob().glob() - } -} - -impl fmt::Display for GlobMatcher { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.glob().fmt(f) - } -} - -impl FromStr for GlobMatcher { - type Err = globset::Error; - - fn from_str(s: &str) -> Result { - s.parse::().map(Self::new) - } -} - -impl From for GlobMatcher { - fn from(glob: globset::Glob) -> Self { - Self::new(glob) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_match_glob_paths() { - let matcher: GlobMatcher = "./test/*".parse().unwrap(); - assert!(matcher.is_match(Path::new("test/Contract.sol"))); - assert!(matcher.is_match(Path::new("./test/Contract.sol"))); - } -} diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index fa1cecbbe85de..7b1c0ff76afc8 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -21,7 +21,6 @@ pub mod errors; pub mod evm; pub mod fmt; pub mod fs; -pub mod glob; pub mod provider; pub mod retry; pub mod selectors; diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index d5a1ddda6fa9a..c487c78c688e6 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -25,6 +25,7 @@ dunce = "1" eyre.workspace = true figment = { version = "0.10", features = ["toml", "env"] } globset = "0.4" +glob = "0.3" Inflector = "0.11" number_prefix = "0.4" once_cell = "1" diff --git a/crates/config/src/filter.rs b/crates/config/src/filter.rs new file mode 100644 index 0000000000000..385b442256aa7 --- /dev/null +++ b/crates/config/src/filter.rs @@ -0,0 +1,204 @@ +//! Helpers for constructing and using [FileFilter]s. + +use core::fmt; +use foundry_compilers::FileFilter; +use std::{ + convert::Infallible, + path::{Path, PathBuf}, + str::FromStr, +}; + +/// Expand globs with a root path. +pub fn expand_globs( + root: &Path, + patterns: impl IntoIterator>, +) -> eyre::Result> { + let mut expanded = Vec::new(); + for pattern in patterns { + for paths in glob::glob(&root.join(pattern.as_ref()).display().to_string())? { + expanded.push(paths?); + } + } + Ok(expanded) +} + +/// A `globset::Glob` that creates its `globset::GlobMatcher` when its created, so it doesn't need +/// to be compiled when the filter functions `TestFilter` functions are called. +#[derive(Clone, Debug)] +pub struct GlobMatcher { + /// The compiled glob + pub matcher: globset::GlobMatcher, +} + +impl GlobMatcher { + /// Creates a new `GlobMatcher` from a `globset::Glob`. + pub fn new(glob: globset::Glob) -> Self { + Self { matcher: glob.compile_matcher() } + } + + /// Tests whether the given path matches this pattern or not. + /// + /// The glob `./test/*` won't match absolute paths like `test/Contract.sol`, which is common + /// format here, so we also handle this case here + pub fn is_match(&self, path: &Path) -> bool { + if self.matcher.is_match(path) { + return true; + } + + if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) { + if file_name.contains(self.as_str()) { + return true; + } + } + + if !path.starts_with("./") && self.as_str().starts_with("./") { + return self.matcher.is_match(format!("./{}", path.display())); + } + + false + } + + /// Matches file only if the filter does not apply. + /// + /// This returns the inverse of `self.is_match(file)`. + fn is_match_exclude(&self, path: &Path) -> bool { + !self.is_match(path) + } + + /// Returns the `globset::Glob`. + pub fn glob(&self) -> &globset::Glob { + self.matcher.glob() + } + + /// Returns the `Glob` string used to compile this matcher. + pub fn as_str(&self) -> &str { + self.glob().glob() + } +} + +impl fmt::Display for GlobMatcher { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.glob().fmt(f) + } +} + +impl FromStr for GlobMatcher { + type Err = globset::Error; + + fn from_str(s: &str) -> Result { + s.parse::().map(Self::new) + } +} + +impl From for GlobMatcher { + fn from(glob: globset::Glob) -> Self { + Self::new(glob) + } +} + +/// Bundles multiple `SkipBuildFilter` into a single `FileFilter` +#[derive(Clone, Debug)] +pub struct SkipBuildFilters { + /// All provided filters. + pub matchers: Vec, + /// Root of the project. + pub project_root: PathBuf, +} + +impl FileFilter for SkipBuildFilters { + /// Only returns a match if _no_ exclusion filter matches + fn is_match(&self, file: &Path) -> bool { + self.matchers.iter().all(|matcher| { + if !matcher.is_match_exclude(file) { + false + } else { + file.strip_prefix(&self.project_root) + .map_or(true, |stripped| matcher.is_match_exclude(stripped)) + } + }) + } +} + +impl SkipBuildFilters { + /// Creates a new `SkipBuildFilters` from multiple `SkipBuildFilter`. + pub fn new>( + filters: impl IntoIterator, + project_root: PathBuf, + ) -> Self { + let matchers = filters.into_iter().map(|m| m.into()).collect(); + Self { matchers, project_root } + } +} + +/// A filter that excludes matching contracts from the build +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum SkipBuildFilter { + /// Exclude all `.t.sol` contracts + Tests, + /// Exclude all `.s.sol` contracts + Scripts, + /// Exclude if the file matches + Custom(String), +} + +impl SkipBuildFilter { + fn new(s: &str) -> Self { + match s { + "test" | "tests" => SkipBuildFilter::Tests, + "script" | "scripts" => SkipBuildFilter::Scripts, + s => SkipBuildFilter::Custom(s.to_string()), + } + } + + /// Returns the pattern to match against a file + pub fn file_pattern(&self) -> &str { + match self { + SkipBuildFilter::Tests => ".t.sol", + SkipBuildFilter::Scripts => ".s.sol", + SkipBuildFilter::Custom(s) => s.as_str(), + } + } +} + +impl FromStr for SkipBuildFilter { + type Err = Infallible; + + fn from_str(s: &str) -> Result { + Ok(Self::new(s)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_build_filter() { + let tests = GlobMatcher::from_str(SkipBuildFilter::Tests.file_pattern()).unwrap(); + let scripts = GlobMatcher::from_str(SkipBuildFilter::Scripts.file_pattern()).unwrap(); + let custom = |s| GlobMatcher::from_str(s).unwrap(); + + let file = Path::new("A.t.sol"); + assert!(!tests.is_match_exclude(file)); + assert!(scripts.is_match_exclude(file)); + assert!(!custom("A.t").is_match_exclude(file)); + + let file = Path::new("A.s.sol"); + assert!(tests.is_match_exclude(file)); + assert!(!scripts.is_match_exclude(file)); + assert!(!custom("A.s").is_match_exclude(file)); + + let file = Path::new("/home/test/Foo.sol"); + assert!(!custom("*/test/**").is_match_exclude(file)); + + let file = Path::new("/home/script/Contract.sol"); + assert!(!custom("*/script/**").is_match_exclude(file)); + } + + #[test] + fn can_match_glob_paths() { + let matcher: GlobMatcher = "./test/*".parse().unwrap(); + assert!(matcher.is_match(Path::new("test/Contract.sol"))); + assert!(matcher.is_match(Path::new("./test/Contract.sol"))); + } +} diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 2d658894b3e3b..781e6b5742431 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -80,6 +80,9 @@ pub use error::SolidityErrorCode; pub mod doc; pub use doc::DocConfig; +pub mod filter; +pub use filter::SkipBuildFilters; + mod warning; pub use warning::*; @@ -171,6 +174,9 @@ pub struct Config { pub allow_paths: Vec, /// additional solc include paths for `--include-path` pub include_paths: Vec, + /// glob patterns to skip + #[serde(with = "from_vec_glob")] + pub skip: Vec, /// whether to force a `project.clean()` pub force: bool, /// evm version to use @@ -773,7 +779,7 @@ impl Config { /// Creates a [Project] with the given `cached` and `no_artifacts` flags pub fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { - let project = Project::builder() + let mut builder = Project::builder() .artifacts(self.configured_artifacts_handler()) .paths(self.project_paths()) .settings(self.compiler_settings()?) @@ -787,8 +793,14 @@ impl Config { .set_offline(self.offline) .set_cached(cached && !self.build_info) .set_build_info(!no_artifacts && self.build_info) - .set_no_artifacts(no_artifacts) - .build(self.compiler()?)?; + .set_no_artifacts(no_artifacts); + + if !self.skip.is_empty() { + let filter = SkipBuildFilters::new(self.skip.clone(), self.__root.0.clone()); + builder = builder.sparse_output(filter); + } + + let project = builder.build(self.compiler()?)?; if self.force { self.cleanup(&project)?; @@ -1901,6 +1913,30 @@ pub(crate) mod from_opt_glob { } } +/// Ser/de `globset::Glob` explicitly to handle `Option` properly +pub(crate) mod from_vec_glob { + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + + pub fn serialize(value: &[globset::Glob], serializer: S) -> Result + where + S: Serializer, + { + let value = value.iter().map(|g| g.glob()).collect::>(); + value.serialize(serializer) + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let s: Vec = Vec::deserialize(deserializer)?; + s.into_iter() + .map(|s| globset::Glob::new(&s)) + .collect::, _>>() + .map_err(serde::de::Error::custom) + } +} + /// A helper wrapper around the root path used during Config detection #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] @@ -2065,6 +2101,7 @@ impl Default for Config { unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, lang: Language::Solidity, + skip: vec![], __non_exhaustive: (), __warnings: vec![], } diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index baf914347cd20..36b107a9ee763 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -15,7 +15,6 @@ workspace = true [dependencies] forge-fmt.workspace = true -foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index ae51e982cf451..3c8270a3a21c4 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -3,9 +3,8 @@ use crate::{ ParseSource, Parser, Preprocessor, }; use forge_fmt::{FormatterConfig, Visitable}; -use foundry_common::glob::expand_globs; use foundry_compilers::{utils::source_files_iter, SOLC_EXTENSIONS}; -use foundry_config::DocConfig; +use foundry_config::{filter::expand_globs, DocConfig}; use itertools::Itertools; use mdbook::MDBook; use rayon::prelude::*; diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index b4cd5ede89e61..dcf76fc2f4245 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -6,6 +6,7 @@ use eyre::{Result, WrapErr}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs::json_files}; use foundry_config::impl_figment_convert; +use regex::Regex; use std::{ fs, path::{Path, PathBuf}, @@ -32,10 +33,6 @@ pub struct BindArgs { #[arg(long)] pub select: Vec, - /// Create bindings only for contracts whose names do not match the specified filter(s) - #[arg(long, conflicts_with = "select")] - pub skip: Vec, - /// Explicitly generate bindings for all contracts /// /// By default all contracts ending with `Test` or `Script` are excluded. @@ -133,18 +130,25 @@ impl BindArgs { } /// Returns the filter to use for `MultiAbigen` - fn get_filter(&self) -> ContractFilter { + fn get_filter(&self) -> Result { if self.select_all { - return ContractFilter::All + return Ok(ContractFilter::All) } if !self.select.is_empty() { - return SelectContracts::default().extend_regex(self.select.clone()).into() + return Ok(SelectContracts::default().extend_regex(self.select.clone()).into()) } - if !self.skip.is_empty() { - return ExcludeContracts::default().extend_regex(self.skip.clone()).into() + if let Some(skip) = self.build_args.skip.as_ref().filter(|s| !s.is_empty()) { + return Ok(ExcludeContracts::default() + .extend_regex( + skip.clone() + .into_iter() + .map(|s| Regex::new(s.file_pattern())) + .collect::, _>>()?, + ) + .into()) } // This excludes all Test/Script and forge-std contracts - ExcludeContracts::default() + Ok(ExcludeContracts::default() .extend_pattern([ ".*Test.*", ".*Script", @@ -155,13 +159,13 @@ impl BindArgs { "[Vv]m.*", ]) .extend_names(["IMulticall3"]) - .into() + .into()) } /// Returns an iterator over the JSON files and the contract name in the `artifacts` directory. - fn get_json_files(&self, artifacts: &Path) -> impl Iterator { - let filter = self.get_filter(); - json_files(artifacts) + fn get_json_files(&self, artifacts: &Path) -> Result> { + let filter = self.get_filter()?; + Ok(json_files(artifacts) .filter_map(|path| { // Ignore the build info JSON. if path.to_str()?.contains("/build-info/") { @@ -181,13 +185,13 @@ impl BindArgs { Some((name, path)) }) - .filter(move |(name, _path)| filter.is_match(name)) + .filter(move |(name, _path)| filter.is_match(name))) } /// Instantiate the multi-abigen fn get_multi(&self, artifacts: &Path) -> Result { let abigens = self - .get_json_files(artifacts) + .get_json_files(artifacts)? .map(|(name, path)| { trace!(?path, "parsing Abigen from file"); let abi = Abigen::new(name, path.to_str().unwrap()) diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index c2fc8088f469e..e78ac283a9946 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -2,7 +2,7 @@ use super::{install, watch::WatchArgs}; use clap::Parser; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; -use foundry_common::compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}; +use foundry_common::compile::ProjectCompiler; use foundry_compilers::{Project, ProjectCompileOutput}; use foundry_config::{ figment::{ @@ -52,13 +52,6 @@ pub struct BuildArgs { #[serde(skip)] pub sizes: bool, - /// Skip building files whose names contain the given filter. - /// - /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. - #[arg(long, num_args(1..))] - #[serde(skip)] - pub skip: Option>, - #[command(flatten)] #[serde(flatten)] pub args: CoreBuildArgs, @@ -87,19 +80,12 @@ impl BuildArgs { let project = config.project()?; - let mut compiler = ProjectCompiler::new() + let compiler = ProjectCompiler::new() .print_names(self.names) .print_sizes(self.sizes) .quiet(self.format_json) .bail(!self.format_json); - if let Some(ref skip) = self.skip { - if !skip.is_empty() { - let filter = SkipBuildFilters::new(skip.clone(), project.root().clone())?; - compiler = compiler.filter(Box::new(filter)); - } - }; - let output = compiler.compile(&project)?; if self.format_json { @@ -160,21 +146,22 @@ impl Provider for BuildArgs { #[cfg(test)] mod tests { use super::*; + use foundry_config::filter::SkipBuildFilter; #[test] fn can_parse_build_filters() { let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "tests"]); - assert_eq!(args.skip, Some(vec![SkipBuildFilter::Tests])); + assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Tests])); let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "scripts"]); - assert_eq!(args.skip, Some(vec![SkipBuildFilter::Scripts])); + assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Scripts])); let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "tests", "--skip", "scripts"]); - assert_eq!(args.skip, Some(vec![SkipBuildFilter::Tests, SkipBuildFilter::Scripts])); + assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Tests, SkipBuildFilter::Scripts])); let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "tests", "scripts"]); - assert_eq!(args.skip, Some(vec![SkipBuildFilter::Tests, SkipBuildFilter::Scripts])); + assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Tests, SkipBuildFilter::Scripts])); } #[test] diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 34df8dbcf5e13..b62f6a7eb56d2 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -2,9 +2,9 @@ use clap::{Parser, ValueHint}; use eyre::Result; use forge_fmt::{format_to, parse, print_diagnostics_report}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; -use foundry_common::{fs, glob::expand_globs, term::cli_warn}; +use foundry_common::{fs, term::cli_warn}; use foundry_compilers::{compilers::solc::SolcLanguage, SOLC_EXTENSIONS}; -use foundry_config::impl_figment_convert_basic; +use foundry_config::{filter::expand_globs, impl_figment_convert_basic}; use rayon::prelude::*; use similar::{ChangeTag, TextDiff}; use std::{ diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index 1a7f355d7e753..7ececa7d4ae34 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -1,8 +1,7 @@ use clap::Parser; use forge::TestFilter; -use foundry_common::glob::GlobMatcher; use foundry_compilers::{FileFilter, ProjectPathsConfig}; -use foundry_config::Config; +use foundry_config::{filter::GlobMatcher, Config}; use std::{fmt, path::Path}; /// The filter to use during testing. diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 165a073747665..3f54e01e531b7 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -162,7 +162,7 @@ impl TestArgs { *selection = OutputSelection::common_output_selection(["abi".to_string()]); }); - let output = project.compile_sparse(Box::new(filter.clone()))?; + let output = project.compile()?; if output.has_compiler_errors() { println!("{output}"); diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 668e4be5e1deb..e2dca7e0aaa2f 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -1,4 +1,6 @@ +use foundry_config::Config; use foundry_test_utils::{forgetest, util::OutputExt}; +use globset::Glob; use std::path::PathBuf; // tests that json is printed when --json is passed @@ -40,3 +42,30 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { assert!(!stdout.contains("std"), "\n{stdout}"); assert!(stdout.contains("Counter"), "\n{stdout}"); }); + +// tests that skip key in config can be used to skip non-compilable contract +forgetest_init!(test_can_skip_contract, |prj, cmd| { + prj.add_source( + "InvalidContract", + r" +contract InvalidContract { + some_invalid_syntax +} +", + ) + .unwrap(); + + prj.add_source( + "ValidContract", + r" +contract ValidContract {} +", + ) + .unwrap(); + + let config = + Config { skip: vec![Glob::new("src/InvalidContract.sol").unwrap()], ..Default::default() }; + prj.write_config(config); + + cmd.args(["build"]).assert_success(); +}); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 31a9ec1fae01c..f26f8243ea20a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -137,6 +137,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, lang: Language::Solidity, + skip: vec![], __non_exhaustive: (), __warnings: vec![], }; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 3cea29f20279c..087834dce9d52 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -22,7 +22,6 @@ use forge_verify::RetryArgs; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ abi::{encode_function_args, get_func}, - compile::SkipBuildFilter, evm::{Breakpoints, EvmArgs}, shell, ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; @@ -180,12 +179,6 @@ pub struct ScriptArgs { )] pub with_gas_price: Option, - /// Skip building files whose names contain the given filter. - /// - /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. - #[arg(long, num_args(1..))] - pub skip: Option>, - #[command(flatten)] pub opts: CoreBuildArgs, diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index ee7c5dddee188..ebe63adc58a3a 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -8,16 +8,13 @@ use foundry_cli::{ opts::EtherscanOpts, utils::{self, read_constructor_args_file, LoadConfig}, }; -use foundry_common::{ - compile::{ProjectCompiler, SkipBuildFilter, SkipBuildFilters}, - provider::ProviderBuilder, -}; +use foundry_common::{compile::ProjectCompiler, provider::ProviderBuilder}; use foundry_compilers::{ artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode}, info::ContractInfo, Artifact, EvmVersion, }; -use foundry_config::{figment, impl_figment_convert, Chain, Config}; +use foundry_config::{figment, filter::SkipBuildFilter, impl_figment_convert, Chain, Config}; use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, utils::configure_tx_env, }; @@ -377,14 +374,8 @@ impl VerifyBytecodeArgs { fn build_project(&self, config: &Config) -> Result { let project = config.project()?; - let mut compiler = ProjectCompiler::new(); + let compiler = ProjectCompiler::new(); - if let Some(skip) = &self.skip { - if !skip.is_empty() { - let filter = SkipBuildFilters::new(skip.to_owned(), project.root().to_path_buf())?; - compiler = compiler.filter(Box::new(filter)); - } - } let output = compiler.compile(&project)?; let artifact = output From 3a024a19d03bddf12e921c94286b5af354e14e6a Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 6 Jun 2024 20:12:20 +0200 Subject: [PATCH 1046/1963] fix: update persistent accounts handling (#8083) --- crates/evm/core/src/backend/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 1f6a615175527..addfccb85faa3 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -767,7 +767,13 @@ impl Backend { let test_contract = match env.tx.transact_to { TransactTo::Call(to) => to, - TransactTo::Create => env.tx.caller.create(env.tx.nonce.unwrap_or_default()), + TransactTo::Create => { + let nonce = self + .basic_ref(env.tx.caller) + .map(|b| b.unwrap_or_default().nonce) + .unwrap_or_default(); + env.tx.caller.create(nonce) + } }; self.set_test_contract(test_contract); } From ca0f29b972786ffd1ddb136a8601b4d19bffe588 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 6 Jun 2024 20:12:32 +0200 Subject: [PATCH 1047/1963] fix(anvil): receipts root calculation (#8085) fix(anvil): update receipts root calculation --- crates/anvil/core/src/eth/transaction/mod.rs | 80 ++++++++++++++++++-- crates/anvil/src/eth/backend/executor.rs | 6 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- 3 files changed, 78 insertions(+), 10 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 0aa6b83309adb..712ac937d3a72 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -7,7 +7,7 @@ use alloy_consensus::{ TxEnvelope, TxLegacy, TxReceipt, }; use alloy_eips::eip2718::{Decodable2718, Encodable2718}; -use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256}; +use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ other::OtherFields, request::TransactionRequest, AccessList, AnyTransactionReceipt, @@ -1030,8 +1030,10 @@ pub struct TransactionInfo { pub struct DepositReceipt { #[serde(flatten)] pub inner: ReceiptWithBloom, + #[serde(default, with = "alloy_serde::num::u64_opt_via_ruint")] pub deposit_nonce: Option, - pub deposit_nonce_version: Option, + #[serde(default, with = "alloy_serde::num::u64_opt_via_ruint")] + pub deposit_receipt_version: Option, } impl DepositReceipt { @@ -1041,7 +1043,7 @@ impl DepositReceipt { self.inner.logs_bloom.length() + self.inner.receipt.logs.length() + self.deposit_nonce.map_or(0, |n| n.length()) + - self.deposit_nonce_version.map_or(0, |n| n.length()) + self.deposit_receipt_version.map_or(0, |n| n.length()) } /// Returns the rlp header for the receipt payload. @@ -1059,7 +1061,7 @@ impl DepositReceipt { if let Some(n) = self.deposit_nonce { n.encode(out); } - if let Some(n) = self.deposit_nonce_version { + if let Some(n) = self.deposit_receipt_version { n.encode(out); } } @@ -1088,7 +1090,7 @@ impl DepositReceipt { logs_bloom, }, deposit_nonce, - deposit_nonce_version, + deposit_receipt_version: deposit_nonce_version, }; let consumed = started_len - b.len(); @@ -1257,6 +1259,62 @@ impl Decodable for TypedReceipt { } } +impl Encodable2718 for TypedReceipt { + fn type_flag(&self) -> Option { + match self { + Self::Legacy(_) => None, + Self::EIP2930(_) => Some(1), + Self::EIP1559(_) => Some(2), + Self::EIP4844(_) => Some(3), + Self::Deposit(_) => Some(0x7E), + } + } + + fn encode_2718_len(&self) -> usize { + match self { + Self::Legacy(r) => ReceiptEnvelope::Legacy(r.clone()).encode_2718_len(), + Self::EIP2930(r) => ReceiptEnvelope::Eip2930(r.clone()).encode_2718_len(), + Self::EIP1559(r) => ReceiptEnvelope::Eip1559(r.clone()).encode_2718_len(), + Self::EIP4844(r) => ReceiptEnvelope::Eip4844(r.clone()).encode_2718_len(), + Self::Deposit(r) => 1 + r.length(), + } + } + + fn encode_2718(&self, out: &mut dyn BufMut) { + match self { + Self::Legacy(r) => ReceiptEnvelope::Legacy(r.clone()).encode_2718(out), + Self::EIP2930(r) => ReceiptEnvelope::Eip2930(r.clone()).encode_2718(out), + Self::EIP1559(r) => ReceiptEnvelope::Eip1559(r.clone()).encode_2718(out), + Self::EIP4844(r) => ReceiptEnvelope::Eip4844(r.clone()).encode_2718(out), + Self::Deposit(r) => { + out.put_u8(0x7E); + r.encode(out); + } + } + } +} + +impl Decodable2718 for TypedReceipt { + fn typed_decode(ty: u8, buf: &mut &[u8]) -> alloy_rlp::Result { + if ty == 0x7E { + return Ok(Self::Deposit(DepositReceipt::decode(buf)?)) + } + match ReceiptEnvelope::typed_decode(ty, buf)? { + ReceiptEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)), + ReceiptEnvelope::Eip1559(tx) => Ok(Self::EIP1559(tx)), + ReceiptEnvelope::Eip4844(tx) => Ok(Self::EIP4844(tx)), + _ => unreachable!(), + } + } + + fn fallback_decode(buf: &mut &[u8]) -> alloy_rlp::Result { + match ReceiptEnvelope::fallback_decode(buf)? { + ReceiptEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)), + _ => unreachable!(), + } + } +} + pub type ReceiptResponse = TransactionReceipt>; pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option { @@ -1300,8 +1358,16 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option TypedReceipt::EIP4844(receipt_with_bloom), 0x7E => TypedReceipt::Deposit(DepositReceipt { inner: receipt_with_bloom, - deposit_nonce: other.get("depositNonce").and_then(|v| v.as_u64()), - deposit_nonce_version: other.get("depositNonceVersion").and_then(|v| v.as_u64()), + deposit_nonce: other + .get_deserialized::("depositNonce") + .transpose() + .ok()? + .map(|v| v.to()), + deposit_receipt_version: other + .get_deserialized::("depositReceiptVersion") + .transpose() + .ok()? + .map(|v| v.to()), }), _ => return None, }, diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 4c7e01a477b5c..52c379da6f793 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -9,6 +9,7 @@ use crate::{ PrecompileFactory, }; use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; +use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{Bloom, BloomInput, Log, B256}; use anvil_core::eth::{ block::{Block, BlockInfo, PartialHeader}, @@ -65,7 +66,7 @@ impl ExecutedTransaction { TypedTransaction::Deposit(tx) => TypedReceipt::Deposit(DepositReceipt { inner: receipt_with_bloom, deposit_nonce: Some(tx.nonce), - deposit_nonce_version: Some(1), + deposit_receipt_version: Some(1), }), } } @@ -201,7 +202,8 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<' } let ommers: Vec
= Vec::new(); - let receipts_root = trie::ordered_trie_root(receipts.iter().map(alloy_rlp::encode)); + let receipts_root = + trie::ordered_trie_root(receipts.iter().map(Encodable2718::encoded_2718)); let partial_header = PartialHeader { parent_hash, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 2619c75569b24..d2a62ebc1cde2 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2063,7 +2063,7 @@ impl Backend { TypedReceipt::Deposit(r) => TypedReceipt::Deposit(DepositReceipt { inner: receipt_with_bloom, deposit_nonce: r.deposit_nonce, - deposit_nonce_version: r.deposit_nonce_version, + deposit_receipt_version: r.deposit_receipt_version, }), }; From 9c343de6037550e831de7aaad5589aadb400062c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 6 Jun 2024 20:26:08 +0200 Subject: [PATCH 1048/1963] feat: add `[vyper]` config section (#8086) * feat: add 'vyper_optimize' config setting * fix doc * [vyper] --- crates/config/src/language.rs | 39 ------------------------ crates/config/src/lib.rs | 52 +++++++++++++++++++++++--------- crates/config/src/vyper.rs | 15 +++++++++ crates/forge/tests/cli/config.rs | 5 ++- 4 files changed, 55 insertions(+), 56 deletions(-) delete mode 100644 crates/config/src/language.rs create mode 100644 crates/config/src/vyper.rs diff --git a/crates/config/src/language.rs b/crates/config/src/language.rs deleted file mode 100644 index dd1105e2d307e..0000000000000 --- a/crates/config/src/language.rs +++ /dev/null @@ -1,39 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::str::FromStr; - -/// Compilers supported by foundry. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub enum Language { - /// Solidity - Solidity, - /// Vyper - Vyper, -} - -impl Language { - /// Returns the language name as a string. - pub const fn as_str(&self) -> &'static str { - match self { - Self::Solidity => "solidity", - Self::Vyper => "vyper", - } - } -} - -impl std::fmt::Display for Language { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl FromStr for Language { - type Err = String; - - fn from_str(s: &str) -> Result { - match s { - "solidity" => Ok(Self::Solidity), - "vyper" => Ok(Self::Vyper), - s => Err(format!("Unknown language: {s}")), - } - } -} diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 781e6b5742431..9a3885fbbf358 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -95,9 +95,6 @@ pub use figment; pub mod providers; use providers::{remappings::RemappingsProvider, FallbackProfileProvider, WarningsProvider}; -mod language; -pub use language::Language; - mod fuzz; pub use fuzz::{FuzzConfig, FuzzDictionaryConfig}; @@ -107,6 +104,9 @@ pub use invariant::InvariantConfig; mod inline; pub use inline::{validate_profiles, InlineConfig, InlineConfigError, InlineConfigParser, NatSpec}; +mod vyper; +use vyper::VyperConfig; + /// Foundry configuration /// /// # Defaults @@ -194,8 +194,6 @@ pub struct Config { /// **Note** for backwards compatibility reasons this also accepts solc_version from the toml /// file, see `BackwardsCompatTomlProvider`. pub solc: Option, - /// The Vyper instance to use if any. - pub vyper: Option, /// whether to autodetect the solc compiler version to use pub auto_detect_solc: bool, /// Offline mode, if set, network access (downloading solc) is disallowed. @@ -407,9 +405,8 @@ pub struct Config { /// CREATE2 salt to use for the library deployment in scripts. pub create2_library_salt: B256, - /// Compiler to use - #[serde(with = "from_str_lowercase")] - pub lang: Language, + /// Configuration for Vyper compiler + pub vyper: VyperConfig, /// The root path where the config detection started from, `Config::with_root` #[doc(hidden)] @@ -454,7 +451,7 @@ impl Config { /// Standalone sections in the config which get integrated into the selected profile pub const STANDALONE_SECTIONS: &'static [&'static str] = - &["rpc_endpoints", "etherscan", "fmt", "doc", "fuzz", "invariant", "labels"]; + &["rpc_endpoints", "etherscan", "fmt", "doc", "fuzz", "invariant", "labels", "vyper"]; /// File name of config toml file pub const FILE_NAME: &'static str = "foundry.toml"; @@ -937,7 +934,7 @@ impl Config { /// Returns configured [Vyper] compiler. pub fn vyper_compiler(&self) -> Result, SolcError> { - let vyper = if let Some(path) = &self.vyper { + let vyper = if let Some(path) = &self.vyper.path { Some(Vyper::new(path)?) } else { Vyper::new("vyper").ok() @@ -1283,7 +1280,7 @@ impl Config { pub fn vyper_settings(&self) -> Result { Ok(VyperSettings { evm_version: Some(self.evm_version), - optimize: None, + optimize: self.vyper.optimize, bytecode_metadata: None, // TODO: We don't yet have a way to deserialize other outputs correctly, so request only // those for now. It should be enough to run tests and deploy contracts. @@ -2027,7 +2024,7 @@ impl Default for Config { gas_reports: vec!["*".to_string()], gas_reports_ignore: vec![], solc: None, - vyper: None, + vyper: Default::default(), auto_detect_solc: true, offline: false, optimizer: true, @@ -2100,7 +2097,6 @@ impl Default for Config { labels: Default::default(), unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, - lang: Language::Solidity, skip: vec![], __non_exhaustive: (), __warnings: vec![], @@ -2803,7 +2799,10 @@ mod tests { etherscan::ResolvedEtherscanConfigs, }; use figment::error::Kind::InvalidType; - use foundry_compilers::artifacts::{ModelCheckerEngine, YulDetails}; + use foundry_compilers::{ + artifacts::{ModelCheckerEngine, YulDetails}, + compilers::vyper::settings::VyperOptimizationMode, + }; use similar_asserts::assert_eq; use std::{collections::BTreeMap, fs::File, io::Write}; use tempfile::tempdir; @@ -4934,4 +4933,29 @@ mod tests { Ok(()) }); } + + #[test] + fn test_parse_vyper() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [vyper] + optimize = "codesize" + path = "/path/to/vyper" + "#, + )?; + + let config = Config::load(); + assert_eq!( + config.vyper, + VyperConfig { + optimize: Some(VyperOptimizationMode::Codesize), + path: Some("/path/to/vyper".into()) + } + ); + + Ok(()) + }); + } } diff --git a/crates/config/src/vyper.rs b/crates/config/src/vyper.rs new file mode 100644 index 0000000000000..79d3fc01dc4ea --- /dev/null +++ b/crates/config/src/vyper.rs @@ -0,0 +1,15 @@ +//! Vyper specific configuration types. + +use foundry_compilers::compilers::vyper::settings::VyperOptimizationMode; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct VyperConfig { + /// Vyper optimization mode. "gas", "none" or "codesize" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub optimize: Option, + /// The Vyper instance to use if any. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub path: Option, +} diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f26f8243ea20a..12b2a2b84e56f 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -9,7 +9,7 @@ use foundry_compilers::{ use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, fs_permissions::{FsAccessPermission, PathPermission}, - Config, FsPermissions, FuzzConfig, InvariantConfig, Language, SolcReq, + Config, FsPermissions, FuzzConfig, InvariantConfig, SolcReq, }; use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ @@ -43,7 +43,6 @@ forgetest!(can_extract_config_values, |prj, cmd| { gas_reports: vec!["Contract".to_string()], gas_reports_ignore: vec![], solc: Some(SolcReq::Local(PathBuf::from("custom-solc"))), - vyper: Some(PathBuf::from("custom-vyper")), auto_detect_solc: false, auto_detect_remappings: true, offline: true, @@ -136,7 +135,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { isolate: true, unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, - lang: Language::Solidity, + vyper: Default::default(), skip: vec![], __non_exhaustive: (), __warnings: vec![], From ebfdefb7dca2515ab15c5035aa4b31bd8e0d6081 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 6 Jun 2024 22:49:34 +0300 Subject: [PATCH 1049/1963] fix(invariant): prevent new values leaking between runs (#8080) * fix(invariant): prevent new values leaking between runs * Changes after review: remove collected flag keep len of values and addresses from db and use them to revert new values * Fix typo * SImplify revert: use truncate --- crates/evm/fuzz/src/strategies/state.rs | 105 +++++++++++------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 59a037156c95d..39dd3a4679490 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -49,7 +49,7 @@ impl EvmFuzzState { pub fn collect_values(&self, values: impl IntoIterator) { let mut dict = self.inner.write(); for value in values { - dict.insert_value(value, true); + dict.insert_value(value); } } @@ -69,12 +69,12 @@ impl EvmFuzzState { dict.insert_logs_values(target_abi, logs, run_depth); dict.insert_result_values(target_function, result, run_depth); }); - dict.insert_state_values(state_changeset); + dict.insert_new_state_values(state_changeset); } /// Removes all newly added entries from the dictionary. /// - /// Should be called between fuzz/invariant runs to avoid accumumlating data derived from fuzz + /// Should be called between fuzz/invariant runs to avoid accumulating data derived from fuzz /// inputs. pub fn revert(&self) { self.inner.write().revert(); @@ -100,10 +100,12 @@ pub struct FuzzDictionary { addresses: AIndexSet
, /// Configuration for the dictionary. config: FuzzDictionaryConfig, - /// New key indexes added to the dictionary since container initialization. - new_values: Vec, - /// New address indexes added to the dictionary since container initialization. - new_addreses: Vec, + /// Number of state values initially collected from db. + /// Used to revert new collected values at the end of each run. + db_state_values: usize, + /// Number of address values initially collected from db. + /// Used to revert new collected addresses at the end of each run. + db_addresses: usize, /// Sample typed values that are collected from call result and used across invariant runs. sample_values: HashMap>, @@ -129,24 +131,23 @@ impl FuzzDictionary { /// Insert common values into the dictionary at initialization. fn prefill(&mut self) { - self.insert_value(B256::ZERO, false); + self.insert_value(B256::ZERO); } /// Insert values from initial db state into fuzz dictionary. /// These values are persisted across invariant runs. fn insert_db_values(&mut self, db_state: Vec<(&Address, &DbAccount)>) { - let collected = false; for (address, account) in db_state { // Insert basic account information - self.insert_value(address.into_word(), collected); + self.insert_value(address.into_word()); // Insert push bytes - self.insert_push_bytes_values(address, &account.info, collected); + self.insert_push_bytes_values(address, &account.info); // Insert storage values. if self.config.include_storage { // Sort storage values before inserting to ensure deterministic dictionary. let values = account.storage.iter().collect::>(); for (slot, value) in values { - self.insert_storage_value(slot, value, collected); + self.insert_storage_value(slot, value); } } } @@ -155,8 +156,13 @@ impl FuzzDictionary { // otherwise we can't select random data for state fuzzing. if self.values().is_empty() { // Prefill with a random address. - self.insert_value(Address::random().into_word(), false); + self.insert_value(Address::random().into_word()); } + + // Record number of values and addresses inserted from db to be used for reverting at the + // end of each run. + self.db_state_values = self.state_values.len(); + self.db_addresses = self.addresses.len(); } /// Insert values collected from call result into fuzz dictionary. @@ -197,15 +203,15 @@ impl FuzzDictionary { // If we weren't able to decode event then we insert raw data in fuzz dictionary. if !log_decoded { for &topic in log.topics() { - self.insert_value(topic, true); + self.insert_value(topic); } let chunks = log.data.data.chunks_exact(32); let rem = chunks.remainder(); for chunk in chunks { - self.insert_value(chunk.try_into().unwrap(), true); + self.insert_value(chunk.try_into().unwrap()); } if !rem.is_empty() { - self.insert_value(B256::right_padding_from(rem), true); + self.insert_value(B256::right_padding_from(rem)); } } } @@ -216,17 +222,16 @@ impl FuzzDictionary { /// Insert values from call state changeset into fuzz dictionary. /// These values are removed at the end of current run. - fn insert_state_values(&mut self, state_changeset: &StateChangeset) { - let collected = true; + fn insert_new_state_values(&mut self, state_changeset: &StateChangeset) { for (address, account) in state_changeset { // Insert basic account information. - self.insert_value(address.into_word(), collected); + self.insert_value(address.into_word()); // Insert push bytes. - self.insert_push_bytes_values(address, &account.info, collected); + self.insert_push_bytes_values(address, &account.info); // Insert storage values. if self.config.include_storage { for (slot, value) in &account.storage { - self.insert_storage_value(slot, &value.present_value, collected); + self.insert_storage_value(slot, &value.present_value); } } } @@ -235,22 +240,17 @@ impl FuzzDictionary { /// Insert values from push bytes into fuzz dictionary. /// Values are collected only once for a given address. /// If values are newly collected then they are removed at the end of current run. - fn insert_push_bytes_values( - &mut self, - address: &Address, - account_info: &AccountInfo, - collected: bool, - ) { + fn insert_push_bytes_values(&mut self, address: &Address, account_info: &AccountInfo) { if self.config.include_push_bytes && !self.addresses.contains(address) { // Insert push bytes if let Some(code) = &account_info.code { - self.insert_address(*address, collected); - self.collect_push_bytes(code.bytes_slice(), collected); + self.insert_address(*address); + self.collect_push_bytes(code.bytes_slice()); } } } - fn collect_push_bytes(&mut self, code: &[u8], collected: bool) { + fn collect_push_bytes(&mut self, code: &[u8]) { let mut i = 0; let len = code.len().min(PUSH_BYTE_ANALYSIS_LIMIT); while i < len { @@ -268,13 +268,13 @@ impl FuzzDictionary { let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); if push_value != U256::ZERO { // Never add 0 to the dictionary as it's always present. - self.insert_value(push_value.into(), collected); + self.insert_value(push_value.into()); // Also add the value below and above the push value to the dictionary. - self.insert_value((push_value - U256::from(1)).into(), collected); + self.insert_value((push_value - U256::from(1)).into()); if push_value != U256::MAX { - self.insert_value((push_value + U256::from(1)).into(), collected); + self.insert_value((push_value + U256::from(1)).into()); } } @@ -286,41 +286,35 @@ impl FuzzDictionary { /// Insert values from single storage slot and storage value into fuzz dictionary. /// If storage values are newly collected then they are removed at the end of current run. - fn insert_storage_value(&mut self, storage_slot: &U256, storage_value: &U256, collected: bool) { - self.insert_value(B256::from(*storage_slot), collected); - self.insert_value(B256::from(*storage_value), collected); + fn insert_storage_value(&mut self, storage_slot: &U256, storage_value: &U256) { + self.insert_value(B256::from(*storage_slot)); + self.insert_value(B256::from(*storage_value)); // also add the value below and above the storage value to the dictionary. if *storage_value != U256::ZERO { let below_value = storage_value - U256::from(1); - self.insert_value(B256::from(below_value), collected); + self.insert_value(B256::from(below_value)); } if *storage_value != U256::MAX { let above_value = storage_value + U256::from(1); - self.insert_value(B256::from(above_value), collected); + self.insert_value(B256::from(above_value)); } } /// Insert address into fuzz dictionary. /// If address is newly collected then it is removed by index at the end of current run. - fn insert_address(&mut self, address: Address, collected: bool) { + fn insert_address(&mut self, address: Address) { if self.addresses.len() < self.config.max_fuzz_dictionary_addresses { - let (index, new_address) = self.addresses.insert_full(address); - if new_address && collected { - self.new_addreses.push(index); - } + self.addresses.insert(address); } } /// Insert raw value into fuzz dictionary. /// If value is newly collected then it is removed by index at the end of current run. - fn insert_value(&mut self, value: B256, collected: bool) { + fn insert_value(&mut self, value: B256) { if self.state_values.len() < self.config.max_fuzz_dictionary_values { - let (index, new_value) = self.state_values.insert_full(value); + let new_value = self.state_values.insert(value); let counter = if new_value { &mut self.misses } else { &mut self.hits }; *counter += 1; - if new_value && collected { - self.new_values.push(index); - } } } @@ -339,7 +333,7 @@ impl FuzzDictionary { values.insert(sample_value); } else { // Insert as state value (will be removed at the end of the run). - self.insert_value(sample_value, true); + self.insert_value(sample_value); } } else { self.sample_values.entry(sample_type).or_default().insert(sample_value); @@ -370,17 +364,10 @@ impl FuzzDictionary { &self.addresses } + /// Revert values and addresses collected during the run by truncating to initial db len. pub fn revert(&mut self) { - // Revert new values collected during the run. - for &value_index in &self.new_values { - self.state_values.swap_remove_index(value_index); - } - for &address_index in &self.new_addreses { - self.addresses.swap_remove_index(address_index); - } - - self.new_values.clear(); - self.new_addreses.clear(); + self.state_values.truncate(self.db_state_values); + self.addresses.truncate(self.db_addresses); } pub fn log_stats(&self) { From 169f83fcb8252fa37f642c1e77a22640e95f0864 Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:30:44 -0700 Subject: [PATCH 1050/1963] feat(forge): [ALPHA] add soldeer as an optional package manager. (#7161) * Soldeer integration * Making the sdependencies to be a recognized config * Updated soldeer version to 0.2.6 * updated soldeer version * Updated to soldeer 0.2.8 and simplified the command parsing on foundry * Update crates/forge/bin/cmd/soldeer.rs Co-authored-by: Oliver Nordbjerg * made the config more typed * added cli tests * chore: fmt * updated soldeer * solved the url dependency * updated soldeer version and added a test to confirm that it works with simplified version * removed the v from the forge dependency * Added custom type for soldeer config * moved the SoldeerConfig to the soldeer.rs and transformed it into AsRef * added constant_time_eq in deny.toml * Updated soldeer to v0.2.12 to disable TLS * clippy fixes * fmt * updated latest soldeer version * bugfix install dependency * bumped soldeer to v0.2.15 * clippy fixes --------- Co-authored-by: Oliver Nordbjerg Co-authored-by: Oliver Nordbjerg Co-authored-by: Matthias Seitz --- Cargo.lock | 225 +++++++++++++++++++++++++++++- Cargo.toml | 2 + crates/config/src/lib.rs | 20 ++- crates/config/src/soldeer.rs | 24 ++++ crates/forge/Cargo.toml | 4 + crates/forge/bin/cmd/mod.rs | 1 + crates/forge/bin/cmd/soldeer.rs | 37 +++++ crates/forge/bin/main.rs | 1 + crates/forge/bin/opts.rs | 5 +- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/main.rs | 1 + crates/forge/tests/cli/soldeer.rs | 182 ++++++++++++++++++++++++ crates/forge/tests/it/fork.rs | 2 +- crates/test-utils/src/macros.rs | 17 +++ deny.toml | 1 + 15 files changed, 516 insertions(+), 7 deletions(-) create mode 100644 crates/config/src/soldeer.rs create mode 100644 crates/forge/bin/cmd/soldeer.rs create mode 100644 crates/forge/tests/cli/soldeer.rs diff --git a/Cargo.lock b/Cargo.lock index 263fa9de3422d..6f3f8da5337e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1688,6 +1688,27 @@ dependencies = [ "either", ] +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "c-kzg" version = "1.0.2" @@ -1818,6 +1839,11 @@ name = "cc" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] [[package]] name = "cfg-if" @@ -1879,6 +1905,7 @@ dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", + "serde", "windows-targets 0.52.5", ] @@ -2163,6 +2190,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + [[package]] name = "const-hex" version = "1.12.0" @@ -2182,6 +2219,12 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "convert_case" version = "0.4.0" @@ -2706,6 +2749,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "email-address-parser" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe19a4967eca30062be4abaf813d929ba48b3bfb21830367f7e1baae37f213a" +dependencies = [ + "console_error_panic_hook", + "pest", + "pest_derive", + "quick-xml", + "wasm-bindgen", +] + [[package]] name = "ena" version = "0.14.3" @@ -3159,6 +3215,7 @@ dependencies = [ "similar", "similar-asserts", "solang-parser", + "soldeer", "strum", "svm-rs", "tempfile", @@ -4768,6 +4825,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -5638,6 +5704,17 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "paste" version = "1.0.15" @@ -5657,6 +5734,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest 0.10.7", + "hmac", + "password-hash", + "sha2", ] [[package]] @@ -6153,6 +6233,15 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-xml" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc440ee4802a86e357165021e3e255a9143724da31db1e2ea540214c96a0f82" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.36" @@ -6364,6 +6453,7 @@ dependencies = [ "js-sys", "log", "mime", + "mime_guess", "native-tls", "once_cell", "percent-encoding", @@ -6379,10 +6469,12 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.25.0", + "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "webpki-roots 0.26.1", "winreg", @@ -7131,6 +7223,19 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha256" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0" +dependencies = [ + "async-trait", + "bytes", + "hex", + "sha2", + "tokio", +] + [[package]] name = "sha3" version = "0.10.8" @@ -7238,6 +7343,15 @@ dependencies = [ "similar", ] +[[package]] +name = "simple-home-dir" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c433538e900807402974e89beb88a98bda36e6f70f09a7225cdf11d013b8efe8" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "simple_asn1" version = "0.6.2" @@ -7295,6 +7409,35 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "soldeer" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdc15c518ac6bcdc09565cfcda5d0926c65dd2153fea83fcaf1cd536b0d26f7" +dependencies = [ + "chrono", + "clap", + "email-address-parser", + "futures", + "once_cell", + "regex", + "reqwest", + "rpassword", + "serde", + "serde_derive", + "serde_json", + "sha256", + "simple-home-dir", + "tokio", + "toml 0.8.13", + "toml_edit 0.22.13", + "uuid 1.8.0", + "walkdir", + "yansi", + "zip 2.1.3", + "zip-extract", +] + [[package]] name = "spin" version = "0.5.2" @@ -7435,7 +7578,7 @@ dependencies = [ "sha2", "thiserror", "url", - "zip", + "zip 2.1.3", ] [[package]] @@ -8204,6 +8347,10 @@ name = "uuid" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", + "serde", +] [[package]] name = "valuable" @@ -8341,6 +8488,19 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "wasm-streams" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "watchexec" version = "2.3.2" @@ -8799,9 +8959,28 @@ dependencies = [ [[package]] name = "zip" -version = "2.1.1" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd56a4d5921bc2f99947ac5b3abe5f510b1be7376fdc5e9fce4a23c6a93e87c" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2 0.11.0", + "sha1", + "zstd", +] + +[[package]] +name = "zip" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775a2b471036342aa69bc5a602bc889cb0a06cda00477d0c69566757d5553d39" dependencies = [ "arbitrary", "crc32fast", @@ -8814,6 +8993,17 @@ dependencies = [ "zopfli", ] +[[package]] +name = "zip-extract" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e109e5a291403b4c1e514d39f8a22d3f98d257e691a52bb1f16051bb1ffed63e" +dependencies = [ + "log", + "thiserror", + "zip 0.6.6", +] + [[package]] name = "zopfli" version = "0.8.1" @@ -8827,3 +9017,32 @@ dependencies = [ "once_cell", "simd-adler32", ] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.10+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index eac8025a4103e..1751f6fa29279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -239,6 +239,8 @@ hyper = "1.0" reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" +# soldeer +soldeer = "0.2.15" [patch.crates-io] revm = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 9a3885fbbf358..eaaee87c27b11 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -104,6 +104,9 @@ pub use invariant::InvariantConfig; mod inline; pub use inline::{validate_profiles, InlineConfig, InlineConfigError, InlineConfigParser, NatSpec}; +pub mod soldeer; +use soldeer::SoldeerConfig; + mod vyper; use vyper::VyperConfig; @@ -408,6 +411,9 @@ pub struct Config { /// Configuration for Vyper compiler pub vyper: VyperConfig, + /// Soldeer dependencies + pub dependencies: Option, + /// The root path where the config detection started from, `Config::with_root` #[doc(hidden)] // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] @@ -450,8 +456,17 @@ impl Config { pub const PROFILE_SECTION: &'static str = "profile"; /// Standalone sections in the config which get integrated into the selected profile - pub const STANDALONE_SECTIONS: &'static [&'static str] = - &["rpc_endpoints", "etherscan", "fmt", "doc", "fuzz", "invariant", "labels", "vyper"]; + pub const STANDALONE_SECTIONS: &'static [&'static str] = &[ + "rpc_endpoints", + "etherscan", + "fmt", + "doc", + "fuzz", + "invariant", + "labels", + "dependencies", + "vyper", + ]; /// File name of config toml file pub const FILE_NAME: &'static str = "foundry.toml"; @@ -2098,6 +2113,7 @@ impl Default for Config { unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, skip: vec![], + dependencies: Default::default(), __non_exhaustive: (), __warnings: vec![], } diff --git a/crates/config/src/soldeer.rs b/crates/config/src/soldeer.rs new file mode 100644 index 0000000000000..5c1d01aa6cab3 --- /dev/null +++ b/crates/config/src/soldeer.rs @@ -0,0 +1,24 @@ +//! Configuration specific to the `forge soldeer` command and the `forge_soldeer` package + +use std::collections::BTreeMap; + +use serde::{Deserialize, Serialize}; + +/// Soldeer dependencies config structure +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct SoldeerDependency { + /// The version of the dependency + pub version: String, + + /// The url from where the dependency was retrieved + pub url: String, +} + +/// Type for Soldeer configs, under dependencies tag in the foundry.toml +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct SoldeerConfig(BTreeMap); +impl AsRef for SoldeerConfig { + fn as_ref(&self) -> &SoldeerConfig { + self + } +} diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index eec9496105208..dcd40a4aa06f6 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -99,9 +99,13 @@ hyper.workspace = true tower-http = { workspace = true, features = ["fs"] } opener = "0.6" +# soldeer +soldeer.workspace = true + [target.'cfg(unix)'.dependencies] tikv-jemallocator = { workspace = true, optional = true } + [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index c8d1dbb0e0064..d3e2f8b6d314c 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -59,6 +59,7 @@ pub mod remappings; pub mod remove; pub mod selectors; pub mod snapshot; +pub mod soldeer; pub mod test; pub mod tree; pub mod update; diff --git a/crates/forge/bin/cmd/soldeer.rs b/crates/forge/bin/cmd/soldeer.rs new file mode 100644 index 0000000000000..52e1240a06e13 --- /dev/null +++ b/crates/forge/bin/cmd/soldeer.rs @@ -0,0 +1,37 @@ +use clap::Parser; +use eyre::Result; + +use soldeer::commands::Subcommands; + +// CLI arguments for `forge soldeer`. +#[derive(Clone, Debug, Parser)] +#[clap(override_usage = "forge soldeer install [DEPENDENCY]~[VERSION] + forge soldeer push [DEPENDENCY]~[VERSION] + forge soldeer login + forge soldeer update + forge soldeer version")] +pub struct SoldeerArgs { + /// Command must be one of the following install/push/login/update/version. + #[command(subcommand)] + command: Subcommands, +} + +impl SoldeerArgs { + pub fn run(self) -> Result<()> { + match soldeer::run(self.command) { + Ok(_) => Ok(()), + Err(err) => Err(eyre::eyre!("Failed to run soldeer {}", err.message)), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use soldeer::commands::VersionDryRun; + + #[test] + fn test_soldeer_version() { + assert!(soldeer::run(Subcommands::VersionDryRun(VersionDryRun {})).is_ok()); + } +} diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 8db9036e186ba..aff2ad530d96b 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -111,6 +111,7 @@ fn main() -> Result<()> { GenerateSubcommands::Test(cmd) => cmd.run(), }, ForgeSubcommand::VerifyBytecode(cmd) => utils::block_on(cmd.run()), + ForgeSubcommand::Soldeer(cmd) => cmd.run(), } } diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 6ca78da0f44e1..a449bd75f46f5 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -2,7 +2,7 @@ use crate::cmd::{ bind::BindArgs, build::BuildArgs, cache::CacheArgs, clone::CloneArgs, config, coverage, create::CreateArgs, debug::DebugArgs, doc::DocArgs, flatten, fmt::FmtArgs, geiger, generate, init::InitArgs, inspect, install::InstallArgs, remappings::RemappingArgs, remove::RemoveArgs, - selectors::SelectorsSubcommands, snapshot, test, tree, update, + selectors::SelectorsSubcommands, snapshot, soldeer, test, tree, update, }; use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; @@ -161,6 +161,9 @@ pub enum ForgeSubcommand { /// Verify the deployed bytecode against its source. #[clap(visible_alias = "vb")] VerifyBytecode(VerifyBytecodeArgs), + + /// Soldeer dependency manager. + Soldeer(soldeer::SoldeerArgs), } #[cfg(test)] diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 12b2a2b84e56f..073a6e45135e4 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -137,6 +137,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, vyper: Default::default(), skip: vec![], + dependencies: Default::default(), __non_exhaustive: (), __warnings: vec![], }; diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 543b84dc7d9c0..0ac67d81b1761 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -15,6 +15,7 @@ mod debug; mod doc; mod multi_script; mod script; +mod soldeer; mod svm; mod test_cmd; mod verify; diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs new file mode 100644 index 0000000000000..7f762e8dd6a31 --- /dev/null +++ b/crates/forge/tests/cli/soldeer.rs @@ -0,0 +1,182 @@ +//! Contains various tests related to `forge soldeer`. + +use std::{ + fs::{self, OpenOptions}, + path::Path, +}; + +use foundry_test_utils::forgesoldeer; +use std::io::Write; +forgesoldeer!(install_dependency, |prj, cmd| { + let command = "install"; + let dependency = "forge-std~1.8.1"; + + cmd.arg("soldeer").args([command, dependency]); + cmd.execute(); + + // Making sure the path was created to the dependency and that foundry.toml exists + // meaning that the dependencies were installed correctly + let path_dep_forge = + prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); + assert!(path_dep_forge.exists()); + + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + let lock_contents = r#" +[[dependencies]] +name = "forge-std" +version = "1.8.1" +source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" +checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" +"#; + + let actual_lock_contents = read_file_to_string(&path_lock_file); + assert_eq!(lock_contents, actual_lock_contents); + + // Making sure the foundry contents are the right ones + let foundry_file = prj.root().join("foundry.toml"); + let foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + +[dependencies] +forge-std = { version = "1.8.1" } +"#; + + let actual_foundry_contents = read_file_to_string(&foundry_file); + assert_eq!(foundry_contents, actual_foundry_contents); +}); + +forgesoldeer!(update_dependencies, |prj, cmd| { + let command = "update"; + + // We need to write this into the foundry.toml to make the update install the dependency + let foundry_updates = r#" +[dependencies] +forge-std = { version = "1.8.1" } +"#; + let foundry_file = prj.root().join("foundry.toml"); + + let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); + + if let Err(e) = write!(file, "{foundry_updates}") { + eprintln!("Couldn't write to file: {e}"); + } + + cmd.arg("soldeer").arg(command); + cmd.execute(); + + // Making sure the path was created to the dependency and that foundry.toml exists + // meaning that the dependencies were installed correctly + let path_dep_forge = + prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); + assert!(path_dep_forge.exists()); + + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + let lock_contents = r#" +[[dependencies]] +name = "forge-std" +version = "1.8.1" +source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" +checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" +"#; + + let actual_lock_contents = read_file_to_string(&path_lock_file); + assert_eq!(lock_contents, actual_lock_contents); + + // Making sure the foundry contents are the right ones + let foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + +[dependencies] +forge-std = { version = "1.8.1" } +"#; + + let actual_foundry_contents = read_file_to_string(&foundry_file); + assert_eq!(foundry_contents, actual_foundry_contents); +}); + +forgesoldeer!(update_dependencies_simple_version, |prj, cmd| { + let command = "update"; + + // We need to write this into the foundry.toml to make the update install the dependency, this + // is he simplified version of version specification + let foundry_updates = r#" +[dependencies] +forge-std = "1.8.1" +"#; + let foundry_file = prj.root().join("foundry.toml"); + + let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); + + if let Err(e) = write!(file, "{foundry_updates}") { + eprintln!("Couldn't write to file: {e}"); + } + + cmd.arg("soldeer").arg(command); + cmd.execute(); + + // Making sure the path was created to the dependency and that foundry.toml exists + // meaning that the dependencies were installed correctly + let path_dep_forge = + prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); + assert!(path_dep_forge.exists()); + + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + let lock_contents = r#" +[[dependencies]] +name = "forge-std" +version = "1.8.1" +source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" +checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" +"#; + + let actual_lock_contents = read_file_to_string(&path_lock_file); + assert_eq!(lock_contents, actual_lock_contents); + + // Making sure the foundry contents are the right ones + let foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + +[dependencies] +forge-std = "1.8.1" +"#; + + let actual_foundry_contents = read_file_to_string(&foundry_file); + assert_eq!(foundry_contents, actual_foundry_contents); +}); + +forgesoldeer!(login, |prj, cmd| { + let command = "login"; + + cmd.arg("soldeer").arg(command); + let output = cmd.unchecked_output(); + + // On login, we can only check if the prompt is displayed in the stdout + let stdout = String::from_utf8(output.stdout).expect("Could not parse the output"); + assert!(stdout.contains("Please enter your email")); +}); + +fn read_file_to_string(path: &Path) -> String { + let contents: String = match fs::read_to_string(path) { + Ok(c) => c, + Err(_) => { + // Return empty string + String::new() + } + }; + contents +} diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 3f3576ac412e8..a6b215624414b 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -91,7 +91,7 @@ async fn test_transact_fork() { TestConfig::with_filter(runner, filter).run().await; } -/// Tests that we can create the same fork (provider,block) concurretnly in different tests +/// Tests that we can create the same fork (provider,block) concurrently in different tests #[tokio::test(flavor = "multi_thread")] async fn test_create_same_fork() { let runner = TEST_DATA_DEFAULT.runner(); diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index f05c8e36b8e42..1f19adffe1544 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -92,3 +92,20 @@ macro_rules! forgetest_init { } }; } + +/// Setup forge soldeer +#[macro_export] +macro_rules! forgesoldeer { + ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { + $crate::forgesoldeer!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); + }; + ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { + #[test] + $(#[$attr])* + fn $test() { + let (mut $prj, mut $cmd) = $crate::util::setup_forge(stringify!($test), $style); + $crate::util::initialize($prj.root()); + $e + } + }; +} diff --git a/deny.toml b/deny.toml index cdde3ec0cefc5..d585fd650a994 100644 --- a/deny.toml +++ b/deny.toml @@ -59,6 +59,7 @@ exceptions = [ { allow = ["CC0-1.0"], name = "notify" }, { allow = ["CC0-1.0"], name = "dunce" }, { allow = ["CC0-1.0"], name = "aurora-engine-modexp" }, + { allow = ["CC0-1.0"], name = "constant_time_eq" }, ] #copyleft = "deny" From 31b70cc241881c5bfdcd8d4dae236b173f6b2376 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 6 Jun 2024 23:46:12 +0200 Subject: [PATCH 1051/1963] feat(cast): alias keccak256 to keccak (#8090) --- crates/cast/bin/opts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 4a9a009926069..1a36d28937493 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -714,7 +714,7 @@ pub enum CastSubcommand { }, /// Hash arbitrary data using Keccak-256. - #[command(visible_alias = "k")] + #[command(visible_aliases = &["k", "keccak256"])] Keccak { /// The data to hash. data: Option, From a9a3c02bb241bf1968816edc6061aabeaf71e65f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 6 Jun 2024 23:46:22 +0200 Subject: [PATCH 1052/1963] fix(cast): return an error if wallet validation failed (#8089) --- crates/cast/bin/cmd/wallet/mod.rs | 8 +++----- crates/cast/tests/cli/main.rs | 23 +++++++++++++++-------- crates/test-utils/src/util.rs | 8 ++++---- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index b312e4a606fb3..def14c17e13cb 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -299,7 +299,7 @@ impl WalletSubcommands { if address == recovered_address { println!("Validation succeeded. Address {address} signed this message."); } else { - println!("Validation failed. Address {address} did not sign this message."); + eyre::bail!("Validation failed. Address {address} did not sign this message."); } } Self::Import { account_name, keystore_dir, unsafe_password, raw_wallet_options } => { @@ -428,11 +428,9 @@ flag to set your key via: #[cfg(test)] mod tests { - use std::str::FromStr; - - use alloy_primitives::address; - use super::*; + use alloy_primitives::address; + use std::str::FromStr; #[test] fn can_parse_wallet_sign_message() { diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 61594460fc32f..30922cfb4c1ae 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -77,15 +77,22 @@ casttest!(wallet_address_keystore_with_password_file, |_prj, cmd| { // tests that `cast wallet sign message` outputs the expected signature casttest!(wallet_sign_message_utf8_data, |_prj, cmd| { - cmd.args([ - "wallet", - "sign", - "--private-key", - "0x0000000000000000000000000000000000000000000000000000000000000001", - "test", - ]); + let pk = "0x0000000000000000000000000000000000000000000000000000000000000001"; + let address = "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf"; + let msg = "test"; + let expected = "0xfe28833983d6faa0715c7e8c3873c725ddab6fa5bf84d40e780676e463e6bea20fc6aea97dc273a98eb26b0914e224c8dd5c615ceaab69ddddcf9b0ae3de0e371c"; + + cmd.args(["wallet", "sign", "--private-key", pk, msg]); let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0xfe28833983d6faa0715c7e8c3873c725ddab6fa5bf84d40e780676e463e6bea20fc6aea97dc273a98eb26b0914e224c8dd5c615ceaab69ddddcf9b0ae3de0e371c"); + assert_eq!(output.trim(), expected); + + // Success. + cmd.cast_fuse() + .args(["wallet", "verify", "-a", address, msg, expected]) + .assert_non_empty_stdout(); + + // Fail. + cmd.cast_fuse().args(["wallet", "verify", "-a", address, "other msg", expected]).assert_err(); }); // tests that `cast wallet sign message` outputs the expected signature, given a 0x-prefixed data diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index b45803e66404b..e1a681db62f85 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -961,7 +961,7 @@ impl TestCommand { fs::write(format!("{}.stderr", name.display()), &output.stderr).unwrap(); } - /// Runs the command and asserts that it resulted in an error exit code. + /// Runs the command and asserts that it **failed** (resulted in an error exit code). #[track_caller] pub fn assert_err(&mut self) { let out = self.execute(); @@ -970,7 +970,7 @@ impl TestCommand { } } - /// Runs the command and asserts that something was printed to stderr. + /// Runs the command and asserts that it **failed** and something was printed to stderr. #[track_caller] pub fn assert_non_empty_stderr(&mut self) { let out = self.execute(); @@ -979,7 +979,7 @@ impl TestCommand { } } - /// Runs the command and asserts that something was printed to stdout. + /// Runs the command and asserts that it **succeeded** and something was printed to stdout. #[track_caller] pub fn assert_non_empty_stdout(&mut self) { let out = self.execute(); @@ -988,7 +988,7 @@ impl TestCommand { } } - /// Runs the command and asserts that nothing was printed to stdout. + /// Runs the command and asserts that it **failed** nothing was printed to stdout. #[track_caller] pub fn assert_empty_stdout(&mut self) { let out = self.execute(); From ad2ada4533a6443c0b5ef5795aa100e85c3f2faa Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:35:02 +0200 Subject: [PATCH 1053/1963] chore: remove excess underscores from config fields (#8088) --- crates/cheatcodes/src/config.rs | 8 ++--- crates/cli/src/opts/build/core.rs | 2 +- crates/cli/src/utils/cmd.rs | 10 +++--- crates/cli/src/utils/mod.rs | 2 +- crates/config/src/fs_permissions.rs | 8 ++--- crates/config/src/lib.rs | 55 +++++++++++++++-------------- crates/forge/bin/cmd/fmt.rs | 4 +-- crates/forge/bin/cmd/geiger/mod.rs | 2 +- crates/forge/bin/cmd/update.rs | 2 +- crates/forge/bin/cmd/watch.rs | 2 +- crates/forge/tests/cli/config.rs | 6 ++-- crates/forge/tests/it/repros.rs | 2 +- crates/script/src/simulate.rs | 2 +- 13 files changed, 52 insertions(+), 53 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 54ba1dad1d616..5be433688aa1f 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -63,7 +63,7 @@ impl CheatsConfig { script_wallets: Option, running_version: Option, ) -> Self { - let mut allowed_paths = vec![config.__root.0.clone()]; + let mut allowed_paths = vec![config.root.0.clone()]; allowed_paths.extend(config.libs.clone()); allowed_paths.extend(config.allow_paths.clone()); @@ -82,8 +82,8 @@ impl CheatsConfig { no_storage_caching: config.no_storage_caching, rpc_endpoints, paths: config.project_paths(), - fs_permissions: config.fs_permissions.clone().joined(&config.__root), - root: config.__root.0.clone(), + fs_permissions: config.fs_permissions.clone().joined(config.root.as_ref()), + root: config.root.0.clone(), allowed_paths, evm_opts, labels: config.labels.clone(), @@ -228,7 +228,7 @@ mod tests { fn config(root: &str, fs_permissions: FsPermissions) -> CheatsConfig { CheatsConfig::new( - &Config { __root: PathBuf::from(root).into(), fs_permissions, ..Default::default() }, + &Config { root: PathBuf::from(root).into(), fs_permissions, ..Default::default() }, Default::default(), None, None, diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index bf0fd019f694f..61986b8fac8ad 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -192,7 +192,7 @@ impl<'a> From<&'a CoreBuildArgs> for Config { // if `--config-path` is set we need to adjust the config's root path to the actual root // path for the project, otherwise it will the parent dir of the `--config-path` if args.project_paths.config_path.is_some() { - config.__root = args.project_paths.project_root().into(); + config.root = args.project_paths.project_root().into(); } config } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 05e6ad0ae614c..13da8d01df8dc 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -265,31 +265,31 @@ where fn load_config_emit_warnings(self) -> Config { let config = self.load_config(); - config.__warnings.iter().for_each(|w| cli_warn!("{w}")); + config.warnings.iter().for_each(|w| cli_warn!("{w}")); config } fn try_load_config_emit_warnings(self) -> Result { let config = self.try_load_config()?; - config.__warnings.iter().for_each(|w| cli_warn!("{w}")); + config.warnings.iter().for_each(|w| cli_warn!("{w}")); Ok(config) } fn load_config_and_evm_opts_emit_warnings(self) -> Result<(Config, EvmOpts)> { let (config, evm_opts) = self.load_config_and_evm_opts()?; - config.__warnings.iter().for_each(|w| cli_warn!("{w}")); + config.warnings.iter().for_each(|w| cli_warn!("{w}")); Ok((config, evm_opts)) } fn load_config_unsanitized_emit_warnings(self) -> Config { let config = self.load_config_unsanitized(); - config.__warnings.iter().for_each(|w| cli_warn!("{w}")); + config.warnings.iter().for_each(|w| cli_warn!("{w}")); config } fn try_load_config_unsanitized_emit_warnings(self) -> Result { let config = self.try_load_config_unsanitized()?; - config.__warnings.iter().for_each(|w| cli_warn!("{w}")); + config.warnings.iter().for_each(|w| cli_warn!("{w}")); Ok(config) } } diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index a840a10c24c73..3a3e65c5eca36 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -289,7 +289,7 @@ impl<'a> Git<'a> { #[inline] pub fn from_config(config: &'a Config) -> Self { - Self::new(config.__root.0.as_path()) + Self::new(config.root.0.as_path()) } pub fn root_of(relative_to: &Path) -> Result { diff --git a/crates/config/src/fs_permissions.rs b/crates/config/src/fs_permissions.rs index 6a75beb055f03..5260b7488f5ae 100644 --- a/crates/config/src/fs_permissions.rs +++ b/crates/config/src/fs_permissions.rs @@ -67,22 +67,20 @@ impl FsPermissions { } /// Updates all `allowed_paths` and joins ([`Path::join`]) the `root` with all entries - pub fn join_all(&mut self, root: impl AsRef) { - let root = root.as_ref(); + pub fn join_all(&mut self, root: &Path) { self.permissions.iter_mut().for_each(|perm| { perm.path = root.join(&perm.path); }) } /// Same as [`Self::join_all`] but consumes the type - pub fn joined(mut self, root: impl AsRef) -> Self { + pub fn joined(mut self, root: &Path) -> Self { self.join_all(root); self } /// Removes all existing permissions for the given path - pub fn remove(&mut self, path: impl AsRef) { - let path = path.as_ref(); + pub fn remove(&mut self, path: &Path) { self.permissions.retain(|permission| permission.path != path) } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index eaaee87c27b11..624edbebc7ee3 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -414,13 +414,17 @@ pub struct Config { /// Soldeer dependencies pub dependencies: Option, - /// The root path where the config detection started from, `Config::with_root` - #[doc(hidden)] - // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] + /// The root path where the config detection started from, [`Config::with_root`]. + // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] // representation, but will be deserialized from the `Figment` so that forge commands can // override it. - #[serde(rename = "root", default, skip_serializing)] - pub __root: RootPath, + #[serde(default, skip_serializing)] + pub root: RootPath, + + /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information + #[serde(rename = "__warnings", default, skip_serializing)] + pub warnings: Vec, + /// PRIVATE: This structure may grow, As such, constructing this structure should /// _always_ be done using a public constructor or update syntax: /// @@ -431,10 +435,7 @@ pub struct Config { /// ``` #[doc(hidden)] #[serde(skip)] - pub __non_exhaustive: (), - /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information - #[serde(default, skip_serializing)] - pub __warnings: Vec, + pub _non_exhaustive: (), } /// Mapping of fallback standalone sections. See [`FallbackProfileProvider`] @@ -558,7 +559,7 @@ impl Config { pub fn to_figment(self, providers: FigmentProviders) -> Figment { let mut c = self; let profile = Config::selected_profile(); - let mut figment = Figment::default().merge(DappHardhatDirProvider(&c.__root.0)); + let mut figment = Figment::default().merge(DappHardhatDirProvider(&c.root.0)); // merge global foundry.toml file if let Some(global_toml) = Config::foundry_dir_toml().filter(|p| p.exists()) { @@ -571,7 +572,7 @@ impl Config { // merge local foundry.toml file figment = Config::merge_toml_provider( figment, - TomlFileProvider::new(Some("FOUNDRY_CONFIG"), c.__root.0.join(Config::FILE_NAME)) + TomlFileProvider::new(Some("FOUNDRY_CONFIG"), c.root.0.join(Config::FILE_NAME)) .cached(), profile.clone(), ); @@ -620,7 +621,7 @@ impl Config { .extract_inner::>("libs") .map(Cow::Owned) .unwrap_or_else(|_| Cow::Borrowed(&c.libs)), - root: &c.__root.0, + root: &c.root.0, remappings: figment.extract_inner::>("remappings"), }; figment = figment.merge(remappings); @@ -638,7 +639,7 @@ impl Config { /// This joins all relative paths with the current root and attempts to make them canonic #[must_use] pub fn canonic(self) -> Self { - let root = self.__root.0.clone(); + let root = self.root.0.clone(); self.canonic_at(root) } @@ -808,7 +809,7 @@ impl Config { .set_no_artifacts(no_artifacts); if !self.skip.is_empty() { - let filter = SkipBuildFilters::new(self.skip.clone(), self.__root.0.clone()); + let filter = SkipBuildFilters::new(self.skip.clone(), self.root.0.clone()); builder = builder.sparse_output(filter); } @@ -926,7 +927,7 @@ impl Config { .artifacts(&self.out) .libs(self.libs.iter()) .remappings(self.get_all_remappings()) - .allowed_path(&self.__root.0) + .allowed_path(&self.root.0) .allowed_paths(&self.libs) .allowed_paths(&self.allow_paths) .include_paths(&self.include_paths); @@ -935,7 +936,7 @@ impl Config { builder = builder.build_infos(build_info_path); } - builder.build_with_root(&self.__root.0) + builder.build_with_root(&self.root.0) } /// Returns configuration for a compiler to use when setting up a [Project]. @@ -1183,7 +1184,7 @@ impl Config { /// Returns the remapping for the project's _test_ directory, but only if it exists pub fn get_test_dir_remapping(&self) -> Option { - if self.__root.0.join(&self.test).exists() { + if self.root.0.join(&self.test).exists() { get_dir_remapping(&self.test) } else { None @@ -1192,7 +1193,7 @@ impl Config { /// Returns the remapping for the project's _script_ directory, but only if it exists pub fn get_script_dir_remapping(&self) -> Option { - if self.__root.0.join(&self.script).exists() { + if self.root.0.join(&self.script).exists() { get_dir_remapping(&self.script) } else { None @@ -1360,7 +1361,7 @@ impl Config { let paths = ProjectPathsConfig::builder().build_with_root::<()>(&root); let artifacts: PathBuf = paths.artifacts.file_name().unwrap().into(); Config { - __root: paths.root.into(), + root: paths.root.into(), src: paths.sources.file_name().unwrap().into(), out: artifacts.clone(), libs: paths.libraries.into_iter().map(|lib| lib.file_name().unwrap().into()).collect(), @@ -1452,7 +1453,7 @@ impl Config { pub fn update_libs(&self) -> eyre::Result<()> { self.update(|doc| { let profile = self.profile.as_str().as_str(); - let root = &self.__root.0; + let root = &self.root.0; let libs: toml_edit::Value = self .libs .iter() @@ -1509,7 +1510,7 @@ impl Config { /// Returns the path to the `foundry.toml` of this `Config`. pub fn get_config_path(&self) -> PathBuf { - self.__root.0.join(Config::FILE_NAME) + self.root.0.join(Config::FILE_NAME) } /// Returns the selected profile. @@ -2006,7 +2007,7 @@ impl Provider for Config { fn data(&self) -> Result, figment::Error> { let mut data = Serialized::defaults(self).data()?; if let Some(entry) = data.get_mut(&self.profile) { - entry.insert("root".to_string(), Value::serialize(self.__root.clone())?); + entry.insert("root".to_string(), Value::serialize(self.root.clone())?); } Ok(data) } @@ -2023,7 +2024,7 @@ impl Default for Config { fs_permissions: FsPermissions::new([PathPermission::read("out")]), prague: false, isolate: false, - __root: Default::default(), + root: Default::default(), src: "src".into(), test: "test".into(), script: "script".into(), @@ -2114,8 +2115,8 @@ impl Default for Config { create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, skip: vec![], dependencies: Default::default(), - __non_exhaustive: (), - __warnings: vec![], + warnings: vec![], + _non_exhaustive: (), } } } @@ -2827,7 +2828,7 @@ mod tests { // Helper function to clear `__warnings` in config, since it will be populated during loading // from file, causing testing problem when comparing to those created from `default()`, etc. fn clear_warning(config: &mut Config) { - config.__warnings = vec![]; + config.warnings = vec![]; } #[test] @@ -4645,7 +4646,7 @@ mod tests { assert_eq!(loaded.src.file_name().unwrap(), "my-src"); assert_eq!(loaded.out.file_name().unwrap(), "my-out"); assert_eq!( - loaded.__warnings, + loaded.warnings, vec![Warning::UnknownSection { unknown_section: Profile::new("default"), source: Some("foundry.toml".into()) diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index b62f6a7eb56d2..c7d84eddb724d 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -48,7 +48,7 @@ impl FmtArgs { let config = self.try_load_config_emit_warnings()?; // Expand ignore globs and canonicalize from the get go - let ignored = expand_globs(&config.__root.0, config.fmt.ignore.iter())? + let ignored = expand_globs(&config.root.0, config.fmt.ignore.iter())? .iter() .flat_map(foundry_common::fs::canonicalize_path) .collect::>(); @@ -97,7 +97,7 @@ impl FmtArgs { let format = |source: String, path: Option<&Path>| -> Result<_> { let name = match path { Some(path) => { - path.strip_prefix(&config.__root.0).unwrap_or(path).display().to_string() + path.strip_prefix(&config.root.0).unwrap_or(path).display().to_string() } None => "stdin".to_string(), }; diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index 451c29dbd7924..da0397cc5204b 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -98,7 +98,7 @@ impl GeigerArgs { eprintln!("{}\n", "ffi enabled".red()); } - let root = config.__root.0; + let root = config.root.0; let sum = sources .par_iter() diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index 05f8e0eb20d37..5ddc5460a78c7 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -52,7 +52,7 @@ impl UpdateArgs { /// Returns `(root, paths)` where `root` is the root of the Git repository and `paths` are the /// relative paths of the dependencies. pub fn dependencies_paths(deps: &[Dependency], config: &Config) -> Result<(PathBuf, Vec)> { - let git_root = Git::root_of(&config.__root.0)?; + let git_root = Git::root_of(&config.root.0)?; let libs = config.install_lib_dir(); let mut paths = Vec::with_capacity(deps.len()); diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index e12b42f7b83e8..327804f2b5c7c 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -137,7 +137,7 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { args.watch.run_all; let state = WatchTestState { - project_root: config.__root.0, + project_root: config.root.0, no_reconfigure, last_test_files: Default::default(), }; diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 073a6e45135e4..bd5598470ba15 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -29,7 +29,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { // explicitly set all values let input = Config { profile: Config::DEFAULT_PROFILE, - __root: Default::default(), + root: Default::default(), src: "test-src".into(), test: "test-test".into(), script: "test-script".into(), @@ -138,8 +138,8 @@ forgetest!(can_extract_config_values, |prj, cmd| { vyper: Default::default(), skip: vec![], dependencies: Default::default(), - __non_exhaustive: (), - __warnings: vec![], + warnings: vec![], + _non_exhaustive: (), }; prj.write_config(input.clone()); let config = cmd.config(); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 0c0f1bc50c7cc..924a65b72a697 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -292,7 +292,7 @@ test_repro!(6538); // https://github.com/foundry-rs/foundry/issues/6554 test_repro!(6554; |config| { - let path = config.runner.config.__root.0.join("out/default/Issue6554.t.sol"); + let path = config.runner.config.root.0.join("out/default/Issue6554.t.sol"); let mut prj_config = Config::clone(&config.runner.config); prj_config.fs_permissions.add(PathPermission::read_write(path)); diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 418dd036a9f9d..2b1fb14cf7ad9 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -402,7 +402,7 @@ impl FilledTransactionsState { )?) }; - let commit = get_commit_hash(&self.script_config.config.__root.0); + let commit = get_commit_hash(&self.script_config.config.root.0); let libraries = self .build_data From c5f0ea71cbd2fee21743560ea5f6e3da7b551bd2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:35:40 +0200 Subject: [PATCH 1054/1963] chore: simplify anvil precompile handler (#8087) --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/evm.rs | 23 +++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d2a62ebc1cde2..238fe2ef9341d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -816,7 +816,7 @@ impl Backend { I: InspectorExt>, { let mut evm = new_evm_with_inspector_ref(db, env, inspector); - if let Some(ref factory) = self.precompile_factory { + if let Some(factory) = &self.precompile_factory { inject_precompiles(&mut evm, factory.precompiles()); } evm diff --git a/crates/anvil/src/evm.rs b/crates/anvil/src/evm.rs index e6c76dd60e345..0e0d30f772a2c 100644 --- a/crates/anvil/src/evm.rs +++ b/crates/anvil/src/evm.rs @@ -1,5 +1,5 @@ use alloy_primitives::Address; -use foundry_evm::revm::{precompile::Precompile, ContextPrecompile, ContextPrecompiles}; +use foundry_evm::revm::precompile::Precompile; use std::{fmt::Debug, sync::Arc}; /// Object-safe trait that enables injecting extra precompiles when using @@ -13,26 +13,17 @@ pub trait PrecompileFactory: Send + Sync + Unpin + Debug { /// /// This will add an additional handler that extends the default precompiles with the given set of /// precompiles. -pub fn inject_precompiles( +pub fn inject_precompiles( evm: &mut revm::Evm<'_, I, DB>, precompiles: Vec<(Address, Precompile)>, -) where - DB: revm::Database, -{ +) { evm.handler.append_handler_register_box(Box::new(move |handler| { let precompiles = precompiles.clone(); - let loaded_precompiles = handler.pre_execution().load_precompiles(); + let prev = handler.pre_execution.load_precompiles.clone(); handler.pre_execution.load_precompiles = Arc::new(move || { - let mut loaded_precompiles = loaded_precompiles.clone(); - loaded_precompiles.extend( - precompiles - .clone() - .into_iter() - .map(|(addr, p)| (addr, ContextPrecompile::Ordinary(p))), - ); - let mut default_precompiles = ContextPrecompiles::default(); - default_precompiles.extend(loaded_precompiles); - default_precompiles + let mut cx = prev(); + cx.extend(precompiles.iter().cloned().map(|(a, b)| (a, b.into()))); + cx }); })); } From 993951adeab9806b1eb12d189ac0f5aef9e87632 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 7 Jun 2024 00:49:05 +0200 Subject: [PATCH 1055/1963] fix: include Vyper sources when compiling scripts (#8091) --- crates/script/src/build.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 3f9a49960d4e8..342096fda3d13 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -16,9 +16,10 @@ use foundry_common::{ }; use foundry_compilers::{ artifacts::{BytecodeObject, Libraries}, + compilers::{multi::MultiCompilerLanguage, Language}, info::ContractInfo, utils::source_files_iter, - ArtifactId, ProjectCompileOutput, SOLC_EXTENSIONS, + ArtifactId, ProjectCompileOutput, }; use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; use foundry_linking::Linker; @@ -184,9 +185,11 @@ impl PreprocessedState { } }; - let sources_to_compile = - source_files_iter(project.paths.sources.as_path(), SOLC_EXTENSIONS) - .chain([target_path.to_path_buf()]); + let sources_to_compile = source_files_iter( + project.paths.sources.as_path(), + MultiCompilerLanguage::FILE_EXTENSIONS, + ) + .chain([target_path.to_path_buf()]); let output = ProjectCompiler::new() .quiet_if(args.opts.silent) From 08b2d3efe3ce1ebb1482e5b554f0335fe6cf89a5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:14:54 +0200 Subject: [PATCH 1056/1963] feat(cast): implement ERC-7201 as `cast index-erc7201` (#8092) --- crates/cast/bin/main.rs | 5 +++++ crates/cast/bin/opts.rs | 10 +++++++++ crates/cast/tests/cli/main.rs | 13 ++++++++++++ crates/common/src/lib.rs | 15 ++----------- crates/common/src/utils.rs | 40 +++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 crates/common/src/utils.rs diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 7baf543312040..4e85ef5610f3c 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -328,6 +328,11 @@ async fn main() -> Result<()> { CastSubcommand::Index { key_type, key, slot_number } => { println!("{}", SimpleCast::index(&key_type, &key, &slot_number)?); } + CastSubcommand::IndexErc7201 { id, formula_id } => { + eyre::ensure!(formula_id == "erc7201", "unsupported formula ID: {formula_id}"); + let id = stdin::unwrap_line(id)?; + println!("{}", foundry_common::erc7201(&id)); + } CastSubcommand::Implementation { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 1a36d28937493..5a15e1df1cc98 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -526,6 +526,16 @@ pub enum CastSubcommand { slot_number: String, }, + /// Compute storage slots as specified by `ERC-7201: Namespaced Storage Layout`. + #[command(name = "index-erc7201", alias = "index-erc-7201", visible_aliases = &["index7201", "in7201"])] + IndexErc7201 { + /// The arbitrary identifier. + id: Option, + /// The formula ID. Currently the only supported formula is `erc7201`. + #[arg(long, default_value = "erc7201")] + formula_id: String, + }, + /// Fetch the EIP-1967 implementation account #[command(visible_alias = "impl")] Implementation { diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 30922cfb4c1ae..016a15a814599 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -888,3 +888,16 @@ casttest!(ens_resolve_no_dot_eth, |_prj, cmd| { let (_out, err) = cmd.unchecked_output_lossy(); assert!(err.contains("not found"), "{err:?}"); }); + +casttest!(index7201, |_prj, cmd| { + let tests = + [("example.main", "0x183a6125c38840424c4a85fa12bab2ab606c4b6d0e7cc73c0c06ba5300eab500")]; + for (id, expected) in tests { + cmd.cast_fuse(); + assert_eq!(cmd.args(["index-erc7201", id]).stdout_lossy().trim(), expected); + } +}); + +casttest!(index_unknown_formula_id, |_prj, cmd| { + cmd.args(["index-7201", "test", "--formula-id", "unknown"]).assert_err(); +}); diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 7b1c0ff76afc8..16071f2212cee 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -29,21 +29,10 @@ pub mod shell; pub mod term; pub mod traits; pub mod transactions; +mod utils; pub use constants::*; pub use contracts::*; pub use traits::*; pub use transactions::*; - -/// Block on a future using the current tokio runtime on the current thread. -pub fn block_on(future: F) -> F::Output { - block_on_handle(&tokio::runtime::Handle::current(), future) -} - -/// Block on a future using the current tokio runtime on the current thread with the given handle. -pub fn block_on_handle( - handle: &tokio::runtime::Handle, - future: F, -) -> F::Output { - tokio::task::block_in_place(|| handle.block_on(future)) -} +pub use utils::*; diff --git a/crates/common/src/utils.rs b/crates/common/src/utils.rs new file mode 100644 index 0000000000000..2676807478b61 --- /dev/null +++ b/crates/common/src/utils.rs @@ -0,0 +1,40 @@ +//! Uncategorised utilities. + +use alloy_primitives::{keccak256, B256, U256}; + +/// Block on a future using the current tokio runtime on the current thread. +pub fn block_on(future: F) -> F::Output { + block_on_handle(&tokio::runtime::Handle::current(), future) +} + +/// Block on a future using the current tokio runtime on the current thread with the given handle. +pub fn block_on_handle( + handle: &tokio::runtime::Handle, + future: F, +) -> F::Output { + tokio::task::block_in_place(|| handle.block_on(future)) +} + +/// Computes the storage slot as specified by `ERC-7201`, using the `erc7201` formula ID. +/// +/// This is defined as: +/// +/// ```text +/// erc7201(id: string) = keccak256(keccak256(id) - 1) & ~0xff +/// ``` +/// +/// # Examples +/// +/// ``` +/// use alloy_primitives::b256; +/// use foundry_common::erc7201; +/// +/// assert_eq!( +/// erc7201("example.main"), +/// b256!("183a6125c38840424c4a85fa12bab2ab606c4b6d0e7cc73c0c06ba5300eab500"), +/// ); +/// ``` +pub fn erc7201(id: &str) -> B256 { + let x = U256::from_be_bytes(keccak256(id).0) - U256::from(1); + keccak256(x.to_be_bytes::<32>()) & B256::from(!U256::from(0xff)) +} From fb4b6f87903ecb7a6d9f94e3cdfb8b39a7294f03 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:37:16 +0200 Subject: [PATCH 1057/1963] chore: simplify PartialEq for ForgeContext (#8101) --- crates/cast/tests/cli/main.rs | 2 +- crates/cheatcodes/spec/src/lib.rs | 6 +++--- crates/cheatcodes/spec/src/vm.rs | 24 +++++++++++------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 016a15a814599..3c86ec4bbaf91 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -898,6 +898,6 @@ casttest!(index7201, |_prj, cmd| { } }); -casttest!(index_unknown_formula_id, |_prj, cmd| { +casttest!(index7201_unknown_formula_id, |_prj, cmd| { cmd.args(["index-7201", "test", "--formula-id", "unknown"]).assert_err(); }); diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index 37cf149cd3ade..fffc146a9d2c1 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -91,10 +91,10 @@ impl Cheatcodes<'static> { Vm::AccountAccessKind::ENUM.clone(), Vm::ForgeContext::ENUM.clone(), ]), - errors: Vm::VM_ERRORS.iter().map(|&x| x.clone()).collect(), + errors: Vm::VM_ERRORS.iter().copied().cloned().collect(), events: Cow::Borrowed(&[]), - // events: Vm::VM_EVENTS.iter().map(|&x| x.clone()).collect(), - cheatcodes: Vm::CHEATCODES.iter().map(|&x| x.clone()).collect(), + // events: Vm::VM_EVENTS.iter().copied().cloned().collect(), + cheatcodes: Vm::CHEATCODES.iter().copied().cloned().collect(), } } } diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 1538dc16ecd87..201bc90d7bf4b 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2163,21 +2163,19 @@ impl PartialEq for ForgeContext { // and script group case (any of dry run, broadcast or resume). fn eq(&self, other: &Self) -> bool { match (self, other) { - (_, &Self::TestGroup) => { - self == &Self::Test || self == &Self::Snapshot || self == &Self::Coverage + (_, Self::TestGroup) => { + matches!(self, Self::Test | Self::Snapshot | Self::Coverage) } - (_, &Self::ScriptGroup) => { - self == &Self::ScriptDryRun || - self == &Self::ScriptBroadcast || - self == &Self::ScriptResume + (_, Self::ScriptGroup) => { + matches!(self, Self::ScriptDryRun | Self::ScriptBroadcast | Self::ScriptResume) } - (&Self::Test, &Self::Test) | - (&Self::Snapshot, &Self::Snapshot) | - (&Self::Coverage, &Self::Coverage) | - (&Self::ScriptDryRun, &Self::ScriptDryRun) | - (&Self::ScriptBroadcast, &Self::ScriptBroadcast) | - (&Self::ScriptResume, &Self::ScriptResume) | - (&Self::Unknown, &Self::Unknown) => true, + (Self::Test, Self::Test) | + (Self::Snapshot, Self::Snapshot) | + (Self::Coverage, Self::Coverage) | + (Self::ScriptDryRun, Self::ScriptDryRun) | + (Self::ScriptBroadcast, Self::ScriptBroadcast) | + (Self::ScriptResume, Self::ScriptResume) | + (Self::Unknown, Self::Unknown) => true, _ => false, } } From 741873cd63b41105c38b5fc24e8b2f6131ae7e9c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:42:28 +0200 Subject: [PATCH 1058/1963] chore: avoid cloning test results channel (#8103) --- crates/forge/src/multi_runner.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 3c3eb2ad49b63..de37469d8a208 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -167,7 +167,7 @@ impl MultiContractRunner { find_time, ); - contracts.par_iter().for_each_with(tx, |tx, &(id, contract)| { + contracts.par_iter().for_each(|&(id, contract)| { let _guard = handle.enter(); let result = self.run_tests(id, contract, db.clone(), filter, &handle); let _ = tx.send((id.identifier(), result)); From a9c0755b76c643fe2b4af3f04e3da17a621cb25a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:55:13 +0200 Subject: [PATCH 1059/1963] chore: simplify proptest strategies (#8105) --- crates/evm/evm/src/executors/invariant/mod.rs | 12 +- .../evm/fuzz/src/invariant/call_override.rs | 8 +- crates/evm/fuzz/src/lib.rs | 7 +- crates/evm/fuzz/src/strategies/calldata.rs | 13 +- crates/evm/fuzz/src/strategies/invariants.rs | 54 +++------ crates/evm/fuzz/src/strategies/mod.rs | 31 +---- crates/evm/fuzz/src/strategies/param.rs | 113 ++++++++---------- 7 files changed, 83 insertions(+), 155 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 2474ed5aabc02..2c67c792db81e 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -22,7 +22,7 @@ use foundry_evm_fuzz::{ use foundry_evm_traces::CallTraceArena; use parking_lot::RwLock; use proptest::{ - strategy::{BoxedStrategy, Strategy}, + strategy::{Strategy, ValueTree}, test_runner::{TestCaseError, TestRunner}, }; use result::{assert_invariants, can_continue}; @@ -91,10 +91,6 @@ sol! { } } -/// Alias for (Dictionary for fuzzing, initial contracts to fuzz and an InvariantStrategy). -type InvariantPreparation = - (EvmFuzzState, FuzzRunIdentifiedContracts, BoxedStrategy); - /// Wrapper around any [`Executor`] implementor which provides fuzzing support using [`proptest`]. /// /// After instantiation, calling `fuzz` will proceed to hammer the deployed smart contracts with @@ -343,7 +339,8 @@ impl<'a> InvariantExecutor<'a> { &mut self, invariant_contract: &InvariantContract<'_>, fuzz_fixtures: &FuzzFixtures, - ) -> Result { + ) -> Result<(EvmFuzzState, FuzzRunIdentifiedContracts, impl Strategy)> + { // Finds out the chosen deployed contracts and/or senders. self.select_contract_artifacts(invariant_contract.address)?; let (targeted_senders, targeted_contracts) = @@ -360,8 +357,7 @@ impl<'a> InvariantExecutor<'a> { self.config.dictionary.dictionary_weight, fuzz_fixtures.clone(), ) - .no_shrink() - .boxed(); + .no_shrink(); // Allows `override_call_strat` to use the address given by the Fuzzer inspector during // EVM execution. diff --git a/crates/evm/fuzz/src/invariant/call_override.rs b/crates/evm/fuzz/src/invariant/call_override.rs index a65b0abc9f195..dddf591526f08 100644 --- a/crates/evm/fuzz/src/invariant/call_override.rs +++ b/crates/evm/fuzz/src/invariant/call_override.rs @@ -33,17 +33,15 @@ impl RandomCallGenerator { pub fn new( test_address: Address, runner: TestRunner, - strategy: SBoxedStrategy, + strategy: impl Strategy + Send + Sync + 'static, target_reference: Arc>, ) -> Self { - let strategy = weighted(0.9, strategy).sboxed(); - Self { test_address, runner: Arc::new(Mutex::new(runner)), - strategy, + strategy: weighted(0.9, strategy).sboxed(), target_reference, - last_sequence: Arc::new(RwLock::new(vec![])), + last_sequence: Arc::default(), replay: false, used: false, } diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 7da74601ff8c2..f675e775542e1 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -316,10 +316,7 @@ impl FuzzFixtures { /// Returns configured fixtures for `param_name` fuzzed parameter. pub fn param_fixtures(&self, param_name: &str) -> Option<&[DynSolValue]> { if let Some(param_fixtures) = self.inner.get(&normalize_fixture(param_name)) { - match param_fixtures { - DynSolValue::FixedArray(_) => param_fixtures.as_fixed_array(), - _ => param_fixtures.as_array(), - } + param_fixtures.as_fixed_array().or_else(|| param_fixtures.as_array()) } else { None } @@ -334,5 +331,5 @@ pub fn fixture_name(function_name: String) -> String { /// Normalize fixture parameter name, for example `_Owner` to `owner`. fn normalize_fixture(param_name: &str) -> String { - param_name.trim_matches(&['_']).to_ascii_lowercase() + param_name.trim_matches('_').to_ascii_lowercase() } diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index 760d661754813..c341cce9d934b 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -1,11 +1,11 @@ use crate::{ - strategies::{fuzz_param, fuzz_param_from_state, EvmFuzzState}, + strategies::{fuzz_param_from_state, fuzz_param_with_fixtures, EvmFuzzState}, FuzzFixtures, }; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::Bytes; -use proptest::prelude::{BoxedStrategy, Strategy}; +use proptest::prelude::Strategy; /// Given a function, it returns a strategy which generates valid calldata /// for that function's input types, following declared test fixtures. @@ -16,9 +16,10 @@ pub fn fuzz_calldata(func: Function, fuzz_fixtures: &FuzzFixtures) -> impl Strat .inputs .iter() .map(|input| { - fuzz_param( + fuzz_param_with_fixtures( &input.selector_type().parse().unwrap(), fuzz_fixtures.param_fixtures(&input.name), + &input.name, ) }) .collect::>(); @@ -36,7 +37,10 @@ pub fn fuzz_calldata(func: Function, fuzz_fixtures: &FuzzFixtures) -> impl Strat /// Given a function and some state, it returns a strategy which generated valid calldata for the /// given function's input types, based on state taken from the EVM. -pub fn fuzz_calldata_from_state(func: Function, state: &EvmFuzzState) -> BoxedStrategy { +pub fn fuzz_calldata_from_state( + func: Function, + state: &EvmFuzzState, +) -> impl Strategy { let strats = func .inputs .iter() @@ -54,7 +58,6 @@ pub fn fuzz_calldata_from_state(func: Function, state: &EvmFuzzState) -> BoxedSt .into() }) .no_shrink() - .boxed() } #[cfg(test)] diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 49971613ea799..1c143f9222033 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -16,7 +16,7 @@ pub fn override_call_strat( contracts: FuzzRunIdentifiedContracts, target: Arc>, fuzz_fixtures: FuzzFixtures, -) -> SBoxedStrategy { +) -> impl Strategy + Send + Sync + 'static { let contracts_ref = contracts.targets.clone(); proptest::prop_oneof![ 80 => proptest::strategy::LazyJust::new(move || *target.read()), @@ -44,7 +44,6 @@ pub fn override_call_strat( fuzz_contract_with_calldata(&fuzz_state, &fuzz_fixtures, target_address, func) }) }) - .sboxed() } /// Creates the invariant strategy. @@ -64,20 +63,6 @@ pub fn invariant_strat( dictionary_weight: u32, fuzz_fixtures: FuzzFixtures, ) -> impl Strategy { - // We only want to seed the first value, since we want to generate the rest as we mutate the - // state - generate_call(fuzz_state, senders, contracts, dictionary_weight, fuzz_fixtures) -} - -/// Strategy to generate a transaction where the `sender`, `target` and `calldata` are all generated -/// through specific strategies. -fn generate_call( - fuzz_state: EvmFuzzState, - senders: SenderFilters, - contracts: FuzzRunIdentifiedContracts, - dictionary_weight: u32, - fuzz_fixtures: FuzzFixtures, -) -> BoxedStrategy { let senders = Rc::new(senders); any::() .prop_flat_map(move |selector| { @@ -102,7 +87,6 @@ fn generate_call( }) }) .prop_map(|(sender, call_details)| BasicTxDetails { sender, call_details }) - .boxed() } /// Strategy to select a sender address: @@ -112,20 +96,16 @@ fn select_random_sender( fuzz_state: &EvmFuzzState, senders: Rc, dictionary_weight: u32, -) -> BoxedStrategy
{ +) -> impl Strategy { if !senders.targeted.is_empty() { - any::() - .prop_map(move |selector| *selector.select(&senders.targeted)) - .boxed() + any::().prop_map(move |index| *index.get(&senders.targeted)).boxed() } else { + assert!(dictionary_weight <= 100, "dictionary_weight must be <= 100"); proptest::prop_oneof![ - 100 - dictionary_weight => fuzz_param(&alloy_dyn_abi::DynSolType::Address, None) - .prop_map(move |addr| addr.as_address().unwrap()) - .boxed(), - dictionary_weight => fuzz_param_from_state(&alloy_dyn_abi::DynSolType::Address, fuzz_state) - .prop_map(move |addr| addr.as_address().unwrap()) - .boxed(), + 100 - dictionary_weight => fuzz_param(&alloy_dyn_abi::DynSolType::Address), + dictionary_weight => fuzz_param_from_state(&alloy_dyn_abi::DynSolType::Address, fuzz_state), ] + .prop_map(move |addr| addr.as_address().unwrap()) // Too many exclusions can slow down testing. .prop_filter("excluded sender", move |addr| !senders.excluded.contains(addr)) .boxed() @@ -139,15 +119,11 @@ fn select_random_sender( fn select_random_function( abi: &JsonAbi, targeted_functions: &[Function], -) -> BoxedStrategy { - if !targeted_functions.is_empty() { - let targeted_functions = targeted_functions.to_vec(); - let selector = any::() - .prop_map(move |selector| selector.select(&targeted_functions).clone()); - selector.boxed() +) -> impl Strategy { + let functions = if !targeted_functions.is_empty() { + targeted_functions.to_vec() } else { - let possible_funcs: Vec = abi - .functions() + abi.functions() .filter(|&func| { !matches!( func.state_mutability, @@ -155,11 +131,9 @@ fn select_random_function( ) }) .cloned() - .collect(); - let total_random = any::() - .prop_map(move |selector| selector.select(&possible_funcs).clone()); - total_random.boxed() - } + .collect() + }; + any::().prop_map(move |index| index.get(&functions).clone()) } /// Given a function, it returns a proptest strategy which generates valid abi-encoded calldata diff --git a/crates/evm/fuzz/src/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs index b49adf16cf359..bf284591b1816 100644 --- a/crates/evm/fuzz/src/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -5,7 +5,7 @@ mod uint; pub use uint::UintStrategy; mod param; -pub use param::{fuzz_param, fuzz_param_from_state}; +pub use param::{fuzz_param, fuzz_param_from_state, fuzz_param_with_fixtures}; mod calldata; pub use calldata::{fuzz_calldata, fuzz_calldata_from_state}; @@ -15,32 +15,3 @@ pub use state::{collect_created_contracts, EvmFuzzState}; mod invariants; pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call_strat}; - -/// Macro to create strategy with fixtures. -/// 1. A default strategy if no fixture defined for current parameter. -/// 2. A weighted strategy that use fixtures and default strategy values for current parameter. -/// -/// If fixture is not of the same type as fuzzed parameter then value is rejected and error raised. -macro_rules! fixture_strategy { - ($fixtures:ident, $strategy_value:expr, $default_strategy:expr) => { - if let Some(fixtures) = $fixtures { - proptest::prop_oneof![ - 50 => { - let custom_fixtures: Vec = - fixtures.iter().enumerate().map(|(_, value)| value.to_owned()).collect(); - let custom_fixtures_len = custom_fixtures.len(); - any::() - .prop_filter_map("invalid fixture", move |index| { - let index = index.index(custom_fixtures_len); - $strategy_value(custom_fixtures.get(index)) - }) - }, - 50 => $default_strategy - ].boxed() - } else { - $default_strategy.boxed() - } - }; -} - -pub(crate) use fixture_strategy; diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 0b64418d613d7..65229d6866a37 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -1,5 +1,4 @@ use super::state::EvmFuzzState; -use crate::strategies::fixture_strategy; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{Address, B256, I256, U256}; use proptest::prelude::*; @@ -7,6 +6,13 @@ use proptest::prelude::*; /// The max length of arrays we fuzz for is 256. const MAX_ARRAY_LEN: usize = 256; +/// Given a parameter type, returns a strategy for generating values for that type. +/// +/// See [`fuzz_param_with_fixtures`] for more information. +pub fn fuzz_param(param: &DynSolType) -> BoxedStrategy { + fuzz_param_inner(param, None) +} + /// Given a parameter type and configured fixtures for param name, returns a strategy for generating /// values for that type. Fixtures can be currently generated for uint, int, address, bytes and /// string types and are defined for parameter name. @@ -18,29 +24,48 @@ const MAX_ARRAY_LEN: usize = 256; /// `fixture_owner` function can be used in a fuzzed test function with a signature like /// `function testFuzz_ownerAddress(address owner, uint amount)`. /// -/// Fuzzer will reject value and raise error if the fixture type is not of the same type as -/// parameter to fuzz. +/// Raises an error if all the fixture types are not of the same type as the input parameter. /// /// Works with ABI Encoder v2 tuples. -pub fn fuzz_param( +pub fn fuzz_param_with_fixtures( param: &DynSolType, - fuzz_fixtures: Option<&[DynSolValue]>, + fixtures: Option<&[DynSolValue]>, + name: &str, ) -> BoxedStrategy { - match *param { - DynSolType::Address => { - fixture_strategy!( - fuzz_fixtures, - |fixture: Option<&DynSolValue>| { - if let Some(val @ DynSolValue::Address(_)) = fixture { - Some(val.clone()) - } else { - error!("{:?} is not a valid address fixture", fixture.unwrap()); - None - } + fuzz_param_inner(param, fixtures.map(|f| (f, name))) +} + +fn fuzz_param_inner( + param: &DynSolType, + mut fuzz_fixtures: Option<(&[DynSolValue], &str)>, +) -> BoxedStrategy { + if let Some((fixtures, name)) = fuzz_fixtures { + if !fixtures.iter().all(|f| f.matches(param)) { + error!("fixtures for {name:?} do not match type {param}"); + fuzz_fixtures = None; + } + } + let fuzz_fixtures = fuzz_fixtures.map(|(f, _)| f); + + let value = || { + let default_strategy = DynSolValue::type_strategy(param); + if let Some(fixtures) = fuzz_fixtures { + proptest::prop_oneof![ + 50 => { + let fixtures = fixtures.to_vec(); + any::() + .prop_map(move |index| index.get(&fixtures).clone()) }, - DynSolValue::type_strategy(&DynSolType::Address) - ) + 50 => default_strategy, + ] + .boxed() + } else { + default_strategy.boxed() } + }; + + match *param { + DynSolType::Address => value(), DynSolType::Int(n @ 8..=256) => super::IntStrategy::new(n, fuzz_fixtures) .prop_map(move |x| DynSolValue::Int(x, n)) .boxed(), @@ -48,64 +73,28 @@ pub fn fuzz_param( .prop_map(move |x| DynSolValue::Uint(x, n)) .boxed(), DynSolType::Function | DynSolType::Bool => DynSolValue::type_strategy(param).boxed(), - DynSolType::Bytes => { - fixture_strategy!( - fuzz_fixtures, - |fixture: Option<&DynSolValue>| { - if let Some(val @ DynSolValue::Bytes(_)) = fixture { - Some(val.clone()) - } else { - error!("{:?} is not a valid bytes fixture", fixture.unwrap()); - None - } - }, - DynSolValue::type_strategy(&DynSolType::Bytes) - ) - } - DynSolType::FixedBytes(size @ 1..=32) => fixture_strategy!( - fuzz_fixtures, - |fixture: Option<&DynSolValue>| { - if let Some(val @ DynSolValue::FixedBytes(_, _)) = fixture { - if let Some(val) = val.as_fixed_bytes() { - if val.1 == size { - return Some(DynSolValue::FixedBytes(B256::from_slice(val.0), val.1)) - } - } - } - error!("{:?} is not a valid fixed bytes fixture", fixture.unwrap()); - None - }, - DynSolValue::type_strategy(&DynSolType::FixedBytes(size)) - ), - DynSolType::String => fixture_strategy!( - fuzz_fixtures, - |fixture: Option<&DynSolValue>| { - if let Some(val @ DynSolValue::String(_)) = fixture { - Some(val.clone()) - } else { - error!("{:?} is not a valid string fixture", fixture.unwrap()); - None - } - }, - DynSolValue::type_strategy(&DynSolType::String).prop_map(move |value| { + DynSolType::Bytes => value(), + DynSolType::FixedBytes(_size @ 1..=32) => value(), + DynSolType::String => value() + .prop_map(move |value| { DynSolValue::String( value.as_str().unwrap().trim().trim_end_matches('\0').to_string(), ) }) - ), + .boxed(), DynSolType::Tuple(ref params) => params .iter() - .map(|p| fuzz_param(p, None)) + .map(|param| fuzz_param_inner(param, None)) .collect::>() .prop_map(DynSolValue::Tuple) .boxed(), DynSolType::FixedArray(ref param, size) => { - proptest::collection::vec(fuzz_param(param, None), size) + proptest::collection::vec(fuzz_param_inner(param, None), size) .prop_map(DynSolValue::FixedArray) .boxed() } DynSolType::Array(ref param) => { - proptest::collection::vec(fuzz_param(param, None), 0..MAX_ARRAY_LEN) + proptest::collection::vec(fuzz_param_inner(param, None), 0..MAX_ARRAY_LEN) .prop_map(DynSolValue::Array) .boxed() } From a09713bac7cbb3ce1a7ddbf66ef20f3baf4a403d Mon Sep 17 00:00:00 2001 From: morito Date: Fri, 7 Jun 2024 22:59:40 +0900 Subject: [PATCH 1060/1963] Support GCP KMS Signer (#8096) * Add Google Cloud KMS Signer * Add GCP Signer option and error * fix format * Fix error handling * deps: add a google-longrunning feature to gcloud-sdk * Fix format * Fix format --- Cargo.lock | 425 +++++++++++++++++++++++++--- Cargo.toml | 1 + crates/wallets/Cargo.toml | 8 + crates/wallets/src/error.rs | 10 + crates/wallets/src/raw_wallet.rs | 4 +- crates/wallets/src/wallet.rs | 15 +- crates/wallets/src/wallet_signer.rs | 55 ++++ 7 files changed, 480 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f3f8da5337e1..5bd074b35200f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,8 +251,8 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", - "pin-project", - "reqwest", + "pin-project 1.1.5", + "reqwest 0.12.4", "serde", "serde_json", "tokio", @@ -313,8 +313,8 @@ dependencies = [ "alloy-transport-ipc", "alloy-transport-ws", "futures", - "pin-project", - "reqwest", + "pin-project 1.1.5", + "reqwest 0.12.4", "serde", "serde_json", "tokio", @@ -413,6 +413,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "alloy-signer-gcp" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", + "gcloud-sdk", + "k256", + "spki", + "thiserror", + "tracing", +] + [[package]] name = "alloy-signer-ledger" version = "0.1.0" @@ -491,7 +508,7 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck 0.4.1", - "indexmap", + "indexmap 2.2.6", "proc-macro-error", "proc-macro2", "quote", @@ -564,7 +581,7 @@ source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0b dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest", + "reqwest 0.12.4", "serde_json", "tower", "tracing", @@ -582,7 +599,7 @@ dependencies = [ "bytes", "futures", "interprocess", - "pin-project", + "pin-project 1.1.5", "serde", "serde_json", "tempfile", @@ -616,7 +633,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more", - "hashbrown", + "hashbrown 0.14.5", "nybbles", "serde", "smallvec", @@ -738,7 +755,7 @@ dependencies = [ "anvil-server", "async-trait", "auto_impl", - "axum", + "axum 0.7.5", "bytes", "chrono", "clap", @@ -811,13 +828,13 @@ version = "0.2.0" dependencies = [ "anvil-rpc", "async-trait", - "axum", + "axum 0.7.5", "bytes", "clap", "futures", "interprocess", "parking_lot", - "pin-project", + "pin-project 1.1.5", "serde", "serde_json", "thiserror", @@ -990,6 +1007,19 @@ dependencies = [ "term", ] +[[package]] +name = "async-compression" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" +dependencies = [ + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", +] + [[package]] name = "async-priority-channel" version = "0.1.0" @@ -1414,6 +1444,34 @@ dependencies = [ "tracing", ] +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core 0.3.4", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "axum" version = "0.7.5" @@ -1421,7 +1479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.4.3", "base64 0.21.7", "bytes", "futures-util", @@ -1451,6 +1509,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + [[package]] name = "axum-core" version = "0.4.3" @@ -1878,7 +1953,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest", + "reqwest 0.12.4", "revm", "rustyline", "semver 1.0.23", @@ -2451,7 +2526,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -2777,6 +2852,15 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + [[package]] name = "endian-type" version = "0.1.2" @@ -3165,7 +3249,7 @@ dependencies = [ "alloy-transport", "anvil", "async-trait", - "axum", + "axum 0.7.5", "clap", "clap_complete", "clap_complete_fig", @@ -3206,7 +3290,7 @@ dependencies = [ "proptest", "rayon", "regex", - "reqwest", + "reqwest 0.12.4", "revm-inspectors", "rustc-hash", "semver 1.0.23", @@ -3338,7 +3422,7 @@ dependencies = [ "itertools 0.13.0", "once_cell", "regex", - "reqwest", + "reqwest 0.12.4", "revm-primitives", "semver 1.0.23", "serde", @@ -3368,7 +3452,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers", - "reqwest", + "reqwest 0.12.4", "semver 1.0.23", "serde", "serde_json", @@ -3495,7 +3579,7 @@ dependencies = [ "foundry-macros", "num-format", "once_cell", - "reqwest", + "reqwest 0.12.4", "rustc-hash", "semver 1.0.23", "serde", @@ -3571,7 +3655,7 @@ dependencies = [ "once_cell", "path-slash", "regex", - "reqwest", + "reqwest 0.12.4", "revm-primitives", "semver 1.0.23", "serde", @@ -3698,7 +3782,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap", + "indexmap 2.2.6", "itertools 0.13.0", "parking_lot", "proptest", @@ -3788,6 +3872,7 @@ dependencies = [ "alloy-primitives", "alloy-signer", "alloy-signer-aws", + "alloy-signer-gcp", "alloy-signer-ledger", "alloy-signer-trezor", "alloy-signer-wallet", @@ -3800,6 +3885,7 @@ dependencies = [ "derive_builder", "eyre", "foundry-config", + "gcloud-sdk", "rpassword", "serde", "thiserror", @@ -3949,6 +4035,49 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" +[[package]] +name = "gcemeta" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d460327b24cc34c86d53d60a90e9e6044817f7906ebd9baa5c3d0ee13e1ecf" +dependencies = [ + "bytes", + "hyper 0.14.28", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "gcloud-sdk" +version = "0.24.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa57d45d9a9778e0bf38deb6a4c9dbe293fa021d0b70b126b5dc593979b08569" +dependencies = [ + "async-trait", + "chrono", + "futures", + "gcemeta", + "hyper 0.14.28", + "jsonwebtoken", + "once_cell", + "prost", + "prost-types", + "reqwest 0.11.27", + "secret-vault-value", + "serde", + "serde_json", + "tokio", + "tonic", + "tower", + "tower-layer", + "tower-util", + "tracing", + "url", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -4239,7 +4368,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -4270,6 +4399,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.14.5" @@ -4525,6 +4660,18 @@ dependencies = [ "tower-service", ] +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper 0.14.28", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "hyper-tls" version = "0.6.0" @@ -4678,6 +4825,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -4685,7 +4842,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -5039,7 +5196,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -5849,7 +6006,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.2.6", ] [[package]] @@ -5933,13 +6090,33 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef0f924a5ee7ea9cbcea77529dba45f8a9ba9f622419fe3386ca581a3ae9d5a" +dependencies = [ + "pin-project-internal 0.4.30", +] + [[package]] name = "pin-project" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ - "pin-project-internal", + "pin-project-internal 1.1.5", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "851c8d0ce9bebe43790dedfc86614c23494ac9f423dd618d3a61fc693eafe61e" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -6189,6 +6366,38 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost", +] + [[package]] name = "protobuf" version = "3.3.0" @@ -6431,6 +6640,51 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "async-compression", + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", + "hyper-rustls 0.24.2", + "ipnet", + "js-sys", + "log", + "mime", + "mime_guess", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls 0.21.12", + "rustls-native-certs 0.6.3", + "rustls-pemfile 1.0.4", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-rustls 0.24.1", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "winreg 0.50.0", +] + [[package]] name = "reqwest" version = "0.12.4" @@ -6477,7 +6731,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots 0.26.1", - "winreg", + "winreg 0.52.0", ] [[package]] @@ -6551,7 +6805,7 @@ dependencies = [ "derive_more", "dyn-clone", "enumn", - "hashbrown", + "hashbrown 0.14.5", "hex", "once_cell", "serde", @@ -7019,6 +7273,19 @@ dependencies = [ "cc", ] +[[package]] +name = "secret-vault-value" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5f8cfb86d2019f64a4cfb49e499f401f406fbec946c1ffeea9d0504284347de" +dependencies = [ + "prost", + "prost-types", + "serde", + "serde_json", + "zeroize", +] + [[package]] name = "security-framework" version = "2.11.0" @@ -7112,7 +7379,7 @@ version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ - "indexmap", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -7571,7 +7838,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "once_cell", - "reqwest", + "reqwest 0.12.4", "semver 1.0.23", "serde", "serde_json", @@ -7640,6 +7907,27 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -7854,6 +8142,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-macros" version = "2.3.0" @@ -7963,7 +8261,7 @@ version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" dependencies = [ - "indexmap", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -7985,7 +8283,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap", + "indexmap 2.2.6", "toml_datetime", "winnow 0.5.40", ] @@ -7996,13 +8294,44 @@ version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ - "indexmap", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", "winnow 0.6.9", ] +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum 0.6.20", + "base64 0.21.7", + "bytes", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", + "hyper-timeout", + "percent-encoding", + "pin-project 1.1.5", + "prost", + "rustls-native-certs 0.7.0", + "rustls-pemfile 2.1.2", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.25.0", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "topological-sort" version = "0.2.2" @@ -8017,9 +8346,13 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", - "pin-project", + "indexmap 1.9.3", + "pin-project 1.1.5", "pin-project-lite", + "rand", + "slab", "tokio", + "tokio-util", "tower-layer", "tower-service", "tracing", @@ -8062,6 +8395,18 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +[[package]] +name = "tower-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1093c19826d33807c72511e68f73b4a0469a3f22c2bd5f7d5212178b4b89674" +dependencies = [ + "futures-core", + "futures-util", + "pin-project 0.4.30", + "tower-service", +] + [[package]] name = "tracing" version = "0.1.40" @@ -8864,6 +9209,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "winreg" version = "0.52.0" @@ -8987,7 +9342,7 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap", + "indexmap 2.2.6", "memchr", "thiserror", "zopfli", diff --git a/Cargo.toml b/Cargo.toml index 1751f6fa29279..2418bdf081ca6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,6 +184,7 @@ alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", defa alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 5a0477253dfa4..34dfda6d48678 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -30,6 +30,13 @@ alloy-signer-aws = { workspace = true, features = ["eip712"], optional = true } aws-config = { version = "1", optional = true } # default-features are necessary aws-sdk-kms = { version = "1", default-features = false, optional = true } +# gcp-kms +alloy-signer-gcp = { workspace = true, features = ["eip712"], optional = true } +gcloud-sdk = { version = "0.24", features = [ + "google-cloud-kms-v1", + "google-longrunning", +], optional = true } + async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } derive_builder = "0.20.0" @@ -47,3 +54,4 @@ tokio = { workspace = true, features = ["macros"] } default = ["rustls"] rustls = ["aws-sdk-kms?/rustls"] aws-kms = ["dep:alloy-signer-aws", "dep:aws-config", "dep:aws-sdk-kms"] +gcp-kms = ["dep:alloy-signer-gcp", "dep:gcloud-sdk"] diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index e3cc67c6105f0..c7ac55b82f22c 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -7,6 +7,9 @@ use hex::FromHexError; #[cfg(feature = "aws-kms")] use alloy_signer_aws::AwsSignerError; +#[cfg(feature = "gcp-kms")] +use alloy_signer_gcp::GcpSignerError; + #[derive(Debug, thiserror::Error)] pub enum PrivateKeyError { #[error("Failed to create wallet from private key. Private key is invalid hex: {0}")] @@ -27,6 +30,9 @@ pub enum WalletSignerError { #[cfg(feature = "aws-kms")] Aws(#[from] AwsSignerError), #[error(transparent)] + #[cfg(feature = "gcp-kms")] + Gcp(#[from] GcpSignerError), + #[error(transparent)] Io(#[from] std::io::Error), #[error(transparent)] InvalidHex(#[from] FromHexError), @@ -40,4 +46,8 @@ impl WalletSignerError { pub fn aws_unsupported() -> Self { Self::UnsupportedSigner("AWS KMS") } + + pub fn gcp_unsupported() -> Self { + Self::UnsupportedSigner("Google Cloud KMS") + } } diff --git a/crates/wallets/src/raw_wallet.rs b/crates/wallets/src/raw_wallet.rs index f8a9d447cf9de..3a5169cad9774 100644 --- a/crates/wallets/src/raw_wallet.rs +++ b/crates/wallets/src/raw_wallet.rs @@ -47,7 +47,7 @@ impl RawWalletOpts { return Ok(Some(PendingSigner::Interactive.unlock()?)); } if let Some(private_key) = &self.private_key { - return Ok(Some(utils::create_private_key_signer(private_key)?)) + return Ok(Some(utils::create_private_key_signer(private_key)?)); } if let Some(mnemonic) = &self.mnemonic { return Ok(Some(utils::create_mnemonic_signer( @@ -55,7 +55,7 @@ impl RawWalletOpts { self.mnemonic_passphrase.as_deref(), self.hd_path.as_deref(), self.mnemonic_index, - )?)) + )?)); } Ok(None) } diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 5b984d70120a8..ce049fe408608 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -11,6 +11,7 @@ use serde::Serialize; /// 3. Trezor /// 4. Keystore (via file path) /// 5. AWS KMS +/// 6. Google Cloud KMS #[derive(Clone, Debug, Default, Serialize, Parser)] #[command(next_help_heading = "Wallet options", about = None, long_about = None)] pub struct WalletOpts { @@ -80,6 +81,10 @@ pub struct WalletOpts { /// Use AWS Key Management Service. #[arg(long, help_heading = "Wallet options - remote", hide = !cfg!(feature = "aws-kms"))] pub aws: bool, + + /// Use Google Cloud Key Management Service. + #[arg(long, help_heading = "Wallet options - remote", hide = !cfg!(feature = "gcp-kms"))] + pub gcp: bool, } impl WalletOpts { @@ -95,6 +100,13 @@ impl WalletOpts { } else if self.aws { let key_id = std::env::var("AWS_KMS_KEY_ID")?; WalletSigner::from_aws(key_id).await? + } else if self.gcp { + let project_id = std::env::var("GCP_PROJECT_ID")?; + let location = std::env::var("GCP_LOCATION")?; + let keyring = std::env::var("GCP_KEYRING")?; + let key_name = std::env::var("GCP_KEY_NAME")?; + let key_version = std::env::var("GCP_KEY_VERSION")?.parse()?; + WalletSigner::from_gcp(project_id, location, keyring, key_name, key_version).await? } else if let Some(raw_wallet) = self.raw.signer()? { raw_wallet } else if let Some(path) = utils::maybe_get_keystore_path( @@ -119,7 +131,7 @@ impl WalletOpts { Error accessing local wallet. Did you set a private key, mnemonic or keystore? Run `cast send --help` or `forge create --help` and use the corresponding CLI flag to set your key via: ---private-key, --mnemonic-path, --aws, --interactive, --trezor or --ledger. +--private-key, --mnemonic-path, --aws, --gcp, --interactive, --trezor or --ledger. Alternatively, if you're using a local node with unlocked accounts, use the --unlocked flag and either set the `ETH_FROM` environment variable to the address of the unlocked account you want to use, or provide the --from flag with the address directly." @@ -199,6 +211,7 @@ mod tests { ledger: false, trezor: false, aws: false, + gcp: false, }; match wallet.signer().await { Ok(_) => { diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index 0e0bbf709585e..d0f1de4a27147 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -14,6 +14,15 @@ use std::path::PathBuf; #[cfg(feature = "aws-kms")] use {alloy_signer_aws::AwsSigner, aws_config::BehaviorVersion, aws_sdk_kms::Client as AwsClient}; +#[cfg(feature = "gcp-kms")] +use { + alloy_signer_gcp::{GcpKeyRingRef, GcpSigner, GcpSignerError, KeySpecifier}, + gcloud_sdk::{ + google::cloud::kms::v1::key_management_service_client::KeyManagementServiceClient, + GoogleApi, + }, +}; + pub type Result = std::result::Result; /// Wrapper enum around different signers. @@ -28,6 +37,9 @@ pub enum WalletSigner { /// Wrapper around AWS KMS signer. #[cfg(feature = "aws-kms")] Aws(AwsSigner), + /// Wrapper around Google Cloud KMS signer. + #[cfg(feature = "gcp-kms")] + Gcp(GcpSigner), } impl WalletSigner { @@ -57,6 +69,43 @@ impl WalletSigner { } } + pub async fn from_gcp( + project_id: String, + location: String, + keyring: String, + key_name: String, + key_version: u64, + ) -> Result { + #[cfg(feature = "gcp-kms")] + { + let keyring = GcpKeyRingRef::new(&project_id, &location, &keyring); + let client = match GoogleApi::from_function( + KeyManagementServiceClient::new, + "https://cloudkms.googleapis.com", + None, + ) + .await + { + Ok(c) => c, + Err(e) => return Err(WalletSignerError::from(GcpSignerError::GoogleKmsError(e))), + }; + + let specifier = KeySpecifier::new(keyring, &key_name, key_version); + + Ok(Self::Gcp(GcpSigner::new(client, specifier, None).await?)) + } + + #[cfg(not(feature = "gcp-kms"))] + { + let _ = project_id; + let _ = location; + let _ = keyring; + let _ = key_name; + let _ = key_version; + Err(WalletSignerError::gcp_unsupported()) + } + } + pub fn from_private_key(private_key: &B256) -> Result { Ok(Self::Local(LocalWallet::from_bytes(private_key)?)) } @@ -102,6 +151,10 @@ impl WalletSigner { Self::Aws(aws) => { senders.push(alloy_signer::Signer::address(aws)); } + #[cfg(feature = "gcp-kms")] + Self::Gcp(gcp) => { + senders.push(alloy_signer::Signer::address(gcp)); + } } Ok(senders) } @@ -136,6 +189,8 @@ macro_rules! delegate { Self::Trezor($inner) => $e, #[cfg(feature = "aws-kms")] Self::Aws($inner) => $e, + #[cfg(feature = "gcp-kms")] + Self::Gcp($inner) => $e, } }; } From f43d3ce8515af83cb75152dd84d2af220e0b894b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:07:49 +0300 Subject: [PATCH 1061/1963] feat(fuzz) - add test progress (#7914) * feat(forge) - add test progress * Code cleanup * Invariant progress bar cleanup * Display number of threads and shrink run counter * Add progress for regular fuzz tests too * Cleanup code, use rayon collect * Changes after review. Cleanup * Fix clippy --- Cargo.lock | 1 + crates/evm/evm/Cargo.toml | 1 + crates/evm/evm/src/executors/fuzz/mod.rs | 7 ++ crates/evm/evm/src/executors/invariant/mod.rs | 7 ++ .../evm/evm/src/executors/invariant/replay.rs | 4 +- .../evm/evm/src/executors/invariant/shrink.rs | 15 ++- crates/forge/bin/cmd/test/mod.rs | 7 +- crates/forge/src/lib.rs | 1 + crates/forge/src/multi_runner.rs | 59 +++++++-- crates/forge/src/progress.rs | 116 ++++++++++++++++++ crates/forge/src/runner.rs | 24 +++- 11 files changed, 228 insertions(+), 14 deletions(-) create mode 100644 crates/forge/src/progress.rs diff --git a/Cargo.lock b/Cargo.lock index 5bd074b35200f..a86b6e18acf41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3706,6 +3706,7 @@ dependencies = [ "foundry-evm-coverage", "foundry-evm-fuzz", "foundry-evm-traces", + "indicatif", "parking_lot", "proptest", "revm", diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index e3a1c9c6b56c4..3b00c9d66ad55 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -50,3 +50,4 @@ parking_lot = "0.12" proptest = "1" thiserror = "1" tracing = "0.1" +indicatif = "0.17" diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 163d5444d2062..6cd411f190334 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -14,6 +14,7 @@ use foundry_evm_fuzz::{ BaseCounterExample, CounterExample, FuzzCase, FuzzError, FuzzFixtures, FuzzTestResult, }; use foundry_evm_traces::CallTraceArena; +use indicatif::ProgressBar; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; use std::{borrow::Cow, cell::RefCell}; @@ -59,6 +60,7 @@ impl FuzzedExecutor { address: Address, should_fail: bool, rd: &RevertDecoder, + progress: Option<&ProgressBar>, ) -> FuzzTestResult { // Stores the first Fuzzcase let first_case: RefCell> = RefCell::default(); @@ -91,6 +93,11 @@ impl FuzzedExecutor { let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; + // If running with progress then increment current run. + if let Some(progress) = progress { + progress.inc(1); + }; + match fuzz_res { FuzzOutcome::Case(case) => { let mut first_case = first_case.borrow_mut(); diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 2c67c792db81e..c3229349355e9 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -20,6 +20,7 @@ use foundry_evm_fuzz::{ FuzzCase, FuzzFixtures, FuzzedCases, }; use foundry_evm_traces::CallTraceArena; +use indicatif::ProgressBar; use parking_lot::RwLock; use proptest::{ strategy::{Strategy, ValueTree}, @@ -135,6 +136,7 @@ impl<'a> InvariantExecutor<'a> { &mut self, invariant_contract: InvariantContract<'_>, fuzz_fixtures: &FuzzFixtures, + progress: Option<&ProgressBar>, ) -> Result { // Throw an error to abort test run if the invariant function accepts input params if !invariant_contract.invariant_function.inputs.is_empty() { @@ -314,6 +316,11 @@ impl<'a> InvariantExecutor<'a> { // Revert state to not persist values between runs. fuzz_state.revert(); + // If running with progress then increment completed runs. + if let Some(progress) = progress { + progress.inc(1); + } + Ok(()) }); diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index b6c2c6d9e32ce..466ae0cf1ef77 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -11,6 +11,7 @@ use foundry_evm_fuzz::{ BaseCounterExample, }; use foundry_evm_traces::{load_contracts, TraceKind, Traces}; +use indicatif::ProgressBar; use parking_lot::RwLock; use proptest::test_runner::TestError; use revm::primitives::U256; @@ -97,13 +98,14 @@ pub fn replay_error( logs: &mut Vec, traces: &mut Traces, coverage: &mut Option, + progress: Option<&ProgressBar>, ) -> Result> { match failed_case.test_error { // Don't use at the moment. TestError::Abort(_) => Ok(vec![]), TestError::Fail(_, ref calls) => { // Shrink sequence of failed calls. - let calls = shrink_sequence(failed_case, calls, &executor)?; + let calls = shrink_sequence(failed_case, calls, &executor, progress)?; set_up_inner_replay(&mut executor, &failed_case.inner_sequence); diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index 9d397bfe1c75f..d61a84592b84e 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -2,8 +2,9 @@ use crate::executors::{invariant::error::FailedInvariantCaseData, Executor}; use alloy_primitives::{Address, Bytes, U256}; use foundry_evm_core::constants::CALLER; use foundry_evm_fuzz::invariant::BasicTxDetails; +use indicatif::ProgressBar; use proptest::bits::{BitSetLike, VarBitSet}; -use std::borrow::Cow; +use std::{borrow::Cow, cmp::min}; #[derive(Clone, Copy, Debug)] struct Shrink { @@ -83,9 +84,17 @@ pub(crate) fn shrink_sequence( failed_case: &FailedInvariantCaseData, calls: &[BasicTxDetails], executor: &Executor, + progress: Option<&ProgressBar>, ) -> eyre::Result> { trace!(target: "forge::test", "Shrinking sequence of {} calls.", calls.len()); + // Reset run count and display shrinking message. + if let Some(progress) = progress { + progress.set_length(min(calls.len(), failed_case.shrink_run_limit as usize) as u64); + progress.reset(); + progress.set_message(" Shrink"); + } + // Special case test: the invariant is *unsatisfiable* - it took 0 calls to // break the invariant -- consider emitting a warning. let error_call_result = @@ -112,6 +121,10 @@ pub(crate) fn shrink_sequence( Ok((true, _)) if !shrinker.complicate() => break, _ => {} } + + if let Some(progress) = progress { + progress.inc(1); + } } Ok(shrinker.current().map(|idx| &calls[idx]).cloned().collect()) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3f54e01e531b7..d2de7ef232b99 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -135,6 +135,10 @@ pub struct TestArgs { /// Print detailed test summary table. #[arg(long, help_heading = "Display options", requires = "summary")] pub detailed: bool, + + /// Show test execution progress. + #[arg(long)] + pub show_progress: bool, } impl TestArgs { @@ -387,9 +391,10 @@ impl TestArgs { // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); let timer = Instant::now(); + let show_progress = self.show_progress; let handle = tokio::task::spawn_blocking({ let filter = filter.clone(); - move || runner.test(&filter, tx) + move || runner.test(&filter, tx, show_progress) }); // Set up trace identifiers. diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 56ca432869d0a..c46800067ce44 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -24,6 +24,7 @@ pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder}; mod runner; pub use runner::ContractRunner; +mod progress; pub mod result; // TODO: remove diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index de37469d8a208..1e2be6c7cb845 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,7 +1,8 @@ //! Forge test runner for multiple contracts. use crate::{ - result::SuiteResult, runner::LIBRARY_DEPLOYER, ContractRunner, TestFilter, TestOptions, + progress::TestsProgress, result::SuiteResult, runner::LIBRARY_DEPLOYER, ContractRunner, + TestFilter, TestOptions, }; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; @@ -140,7 +141,7 @@ impl MultiContractRunner { filter: &dyn TestFilter, ) -> impl Iterator { let (tx, rx) = mpsc::channel(); - self.test(filter, tx); + self.test(filter, tx, false); rx.into_iter() } @@ -150,7 +151,12 @@ impl MultiContractRunner { /// before executing all contracts and their tests in _parallel_. /// /// Each Executor gets its own instance of the `Backend`. - pub fn test(&mut self, filter: &dyn TestFilter, tx: mpsc::Sender<(String, SuiteResult)>) { + pub fn test( + &mut self, + filter: &dyn TestFilter, + tx: mpsc::Sender<(String, SuiteResult)>, + show_progress: bool, + ) { let handle = tokio::runtime::Handle::current(); trace!("running all tests"); @@ -167,11 +173,45 @@ impl MultiContractRunner { find_time, ); - contracts.par_iter().for_each(|&(id, contract)| { - let _guard = handle.enter(); - let result = self.run_tests(id, contract, db.clone(), filter, &handle); - let _ = tx.send((id.identifier(), result)); - }) + if show_progress { + let tests_progress = TestsProgress::new(contracts.len(), rayon::current_num_threads()); + // Collect test suite results to stream at the end of test run. + let results: Vec<(String, SuiteResult)> = contracts + .par_iter() + .map(|&(id, contract)| { + let _guard = handle.enter(); + tests_progress.inner.lock().start_suite_progress(&id.identifier()); + + let result = self.run_tests( + id, + contract, + db.clone(), + filter, + &handle, + Some(&tests_progress), + ); + + tests_progress + .inner + .lock() + .end_suite_progress(&id.identifier(), result.summary()); + + (id.identifier(), result) + }) + .collect(); + + tests_progress.inner.lock().clear(); + + results.iter().for_each(|result| { + let _ = tx.send(result.to_owned()); + }); + } else { + contracts.par_iter().for_each(|&(id, contract)| { + let _guard = handle.enter(); + let result = self.run_tests(id, contract, db.clone(), filter, &handle, None); + let _ = tx.send((id.identifier(), result)); + }) + } } fn run_tests( @@ -181,6 +221,7 @@ impl MultiContractRunner { db: Backend, filter: &dyn TestFilter, handle: &tokio::runtime::Handle, + progress: Option<&TestsProgress>, ) -> SuiteResult { let identifier = artifact_id.identifier(); let mut span_name = identifier.as_str(); @@ -222,7 +263,9 @@ impl MultiContractRunner { self.sender, &self.revert_decoder, self.debug, + progress, ); + let r = runner.run_tests(filter, &self.test_options, self.known_contracts.clone(), handle); debug!(duration=?r.duration, "executed all tests in contract"); diff --git a/crates/forge/src/progress.rs b/crates/forge/src/progress.rs new file mode 100644 index 0000000000000..8d047c4133d36 --- /dev/null +++ b/crates/forge/src/progress.rs @@ -0,0 +1,116 @@ +use indicatif::{MultiProgress, ProgressBar}; +use parking_lot::Mutex; +use std::{collections::HashMap, sync::Arc, time::Duration}; + +/// State of [ProgressBar]s displayed for the given test run. +/// Shows progress of all test suites matching filter. +/// For each test within the test suite an individual progress bar is displayed. +/// When a test suite completes, their progress is removed from overall progress and result summary +/// is displayed. +#[derive(Debug)] +pub struct TestsProgressState { + /// Main [MultiProgress] instance showing progress for all test suites. + multi: MultiProgress, + /// Progress bar counting completed / remaining test suites. + overall_progress: ProgressBar, + /// Individual test suites progress. + suites_progress: HashMap, +} + +impl TestsProgressState { + // Creates overall tests progress state. + pub fn new(suites_len: usize, threads_no: usize) -> Self { + let multi = MultiProgress::new(); + let overall_progress = multi.add(ProgressBar::new(suites_len as u64)); + overall_progress.set_style( + indicatif::ProgressStyle::with_template("{bar:40.cyan/blue} {pos:>7}/{len:7} {msg}") + .unwrap() + .progress_chars("##-"), + ); + overall_progress.set_message(format!("completed (with {} threads)", threads_no as u64)); + Self { multi, overall_progress, suites_progress: HashMap::default() } + } + + /// Creates new test suite progress and add it to overall progress. + pub fn start_suite_progress(&mut self, suite_name: &String) { + let suite_progress = self.multi.add(ProgressBar::new_spinner()); + suite_progress.set_style( + indicatif::ProgressStyle::with_template("{spinner} {wide_msg:.bold.dim}") + .unwrap() + .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "), + ); + suite_progress.set_message(format!("{suite_name} ")); + suite_progress.enable_steady_tick(Duration::from_millis(100)); + self.suites_progress.insert(suite_name.to_owned(), suite_progress); + } + + /// Prints suite result summary and removes it from overall progress. + pub fn end_suite_progress(&mut self, suite_name: &String, result_summary: String) { + if let Some(suite_progress) = self.suites_progress.remove(suite_name) { + self.multi.suspend(|| { + println!("{suite_name}\n ↪ {result_summary}"); + }); + suite_progress.finish_and_clear(); + // Increment test progress bar to reflect completed test suite. + self.overall_progress.inc(1); + } + } + + /// Creates progress entry for fuzz tests. + /// Set the prefix and total number of runs. Message is updated during execution with current + /// phase. Test progress is placed under test suite progress entry so all tests within suite + /// are grouped. + pub fn start_fuzz_progress( + &mut self, + suite_name: &str, + test_name: &String, + runs: u32, + ) -> Option { + if let Some(suite_progress) = self.suites_progress.get(suite_name) { + let fuzz_progress = + self.multi.insert_after(suite_progress, ProgressBar::new(runs as u64)); + fuzz_progress.set_style( + indicatif::ProgressStyle::with_template( + " ↪ {prefix:.bold.dim}: [{pos}/{len}]{msg} Runs", + ) + .unwrap() + .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "), + ); + fuzz_progress.set_prefix(test_name.to_string()); + Some(fuzz_progress) + } else { + None + } + } + + /// Removes overall test progress. + pub fn clear(&mut self) { + self.multi.clear().unwrap(); + } +} + +/// Clonable wrapper around [TestsProgressState]. +#[derive(Debug, Clone)] +pub struct TestsProgress { + pub inner: Arc>, +} + +impl TestsProgress { + pub fn new(suites_len: usize, threads_no: usize) -> Self { + Self { inner: Arc::new(Mutex::new(TestsProgressState::new(suites_len, threads_no))) } + } +} + +/// Helper function for creating fuzz test progress bar. +pub fn start_fuzz_progress( + tests_progress: Option<&TestsProgress>, + suite_name: &str, + test_name: &String, + runs: u32, +) -> Option { + if let Some(progress) = tests_progress { + progress.inner.lock().start_fuzz_progress(suite_name, test_name, runs) + } else { + None + } +} diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index dadd519631a00..46a6cad6829ee 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -3,6 +3,7 @@ use crate::{ fuzz::{invariant::BasicTxDetails, BaseCounterExample}, multi_runner::{is_matching_test, TestContract}, + progress::{start_fuzz_progress, TestsProgress}, result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, TestFilter, TestOptions, }; @@ -68,6 +69,8 @@ pub struct ContractRunner<'a> { pub sender: Address, /// Should generate debug traces pub debug: bool, + /// Overall test run progress. + progress: Option<&'a TestsProgress>, } impl<'a> ContractRunner<'a> { @@ -81,6 +84,7 @@ impl<'a> ContractRunner<'a> { sender: Option
, revert_decoder: &'a RevertDecoder, debug: bool, + progress: Option<&'a TestsProgress>, ) -> Self { Self { name, @@ -91,6 +95,7 @@ impl<'a> ContractRunner<'a> { sender: sender.unwrap_or_default(), revert_decoder, debug, + progress, } } } @@ -379,6 +384,7 @@ impl<'a> ContractRunner<'a> { let res = if func.is_invariant_test() { let runner = test_options.invariant_runner(self.name, &func.name); let invariant_config = test_options.invariant_config(self.name, &func.name); + self.run_invariant_test( runner, setup, @@ -391,6 +397,7 @@ impl<'a> ContractRunner<'a> { debug_assert!(func.is_test()); let runner = test_options.fuzz_runner(self.name, &func.name); let fuzz_config = test_options.fuzz_config(self.name, &func.name); + self.run_fuzz_test(func, should_fail, runner, setup, fuzz_config.clone()) } else { debug_assert!(func.is_test()); @@ -631,8 +638,11 @@ impl<'a> ContractRunner<'a> { } } + let progress = + start_fuzz_progress(self.progress, self.name, &func.name, invariant_config.runs); let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs, gas_report_traces } = - match evm.invariant_fuzz(invariant_contract.clone(), &fuzz_fixtures) { + match evm.invariant_fuzz(invariant_contract.clone(), &fuzz_fixtures, progress.as_ref()) + { Ok(x) => x, Err(e) => { return TestResult { @@ -670,6 +680,7 @@ impl<'a> ContractRunner<'a> { &mut logs, &mut traces, &mut coverage, + progress.as_ref(), ) { Ok(call_sequence) => { if !call_sequence.is_empty() { @@ -754,6 +765,7 @@ impl<'a> ContractRunner<'a> { } = setup; // Run fuzz test + let progress = start_fuzz_progress(self.progress, self.name, &func.name, fuzz_config.runs); let start = Instant::now(); let fuzzed_executor = FuzzedExecutor::new( self.executor.clone(), @@ -761,8 +773,14 @@ impl<'a> ContractRunner<'a> { self.sender, fuzz_config.clone(), ); - let result = - fuzzed_executor.fuzz(func, &fuzz_fixtures, address, should_fail, self.revert_decoder); + let result = fuzzed_executor.fuzz( + func, + &fuzz_fixtures, + address, + should_fail, + self.revert_decoder, + progress.as_ref(), + ); let mut debug = Default::default(); let mut breakpoints = Default::default(); From c4d18c5790d89011f186c9f8827a921fcd983589 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:54:26 +0200 Subject: [PATCH 1062/1963] chore: update lockfile --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a86b6e18acf41..05cf20bb599c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7689,7 +7689,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest", + "reqwest 0.12.4", "rpassword", "serde", "serde_derive", From a169ef75cc730f58bb1e2c4d9bc3b534951ad59c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:14:26 +0200 Subject: [PATCH 1063/1963] chore: propagate fmt parser errors (#8109) --- crates/cast/bin/cmd/interface.rs | 54 ++++++++++++++++++++- crates/cast/src/lib.rs | 71 +--------------------------- crates/fmt/src/formatter.rs | 10 +++- crates/fmt/src/helpers.rs | 41 +++++++++------- crates/fmt/src/lib.rs | 2 +- crates/forge/bin/cmd/fmt.rs | 9 ++-- crates/forge/bin/cmd/geiger/error.rs | 7 ++- crates/forge/bin/cmd/geiger/find.rs | 18 +++---- 8 files changed, 104 insertions(+), 108 deletions(-) diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 59956b78ef1e4..a402ea8af1121 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -1,6 +1,9 @@ -use cast::{AbiPath, SimpleCast}; +use alloy_chains::Chain; +use alloy_json_abi::ContractObject; +use alloy_primitives::Address; use clap::Parser; use eyre::{Context, Result}; +use foundry_block_explorers::Client; use foundry_cli::opts::EtherscanOpts; use foundry_common::fs; use foundry_config::Config; @@ -58,7 +61,42 @@ impl InterfaceArgs { } }; - let interfaces = SimpleCast::generate_interface(source).await?; + let items = match source { + AbiPath::Local { path, name } => { + let file = std::fs::read_to_string(&path).wrap_err("unable to read abi file")?; + let obj: ContractObject = serde_json::from_str(&file)?; + let abi = + obj.abi.ok_or_else(|| eyre::eyre!("could not find ABI in file {path}"))?; + let name = name.unwrap_or_else(|| "Interface".to_owned()); + vec![(abi, name)] + } + AbiPath::Etherscan { address, chain, api_key } => { + let client = Client::new(chain, api_key)?; + let source = client.contract_source_code(address).await?; + source + .items + .into_iter() + .map(|item| Ok((item.abi()?, item.contract_name))) + .collect::>>()? + } + }; + + let interfaces = items + .into_iter() + .map(|(contract_abi, name)| { + let source = match foundry_cli::utils::abi_to_solidity(&contract_abi, &name) { + Ok(generated_source) => generated_source, + Err(e) => { + warn!("Failed to format interface for {name}: {e}"); + contract_abi.to_sol(&name, None) + } + }; + Ok(InterfaceSource { + json_abi: serde_json::to_string_pretty(&contract_abi)?, + source, + }) + }) + .collect::>>()?; // put it all together let res = if json { @@ -85,3 +123,15 @@ impl InterfaceArgs { Ok(()) } } + +struct InterfaceSource { + json_abi: String, + source: String, +} + +// Local is a path to the directory containing the ABI files +// In case of etherscan, ABI is fetched from the address on the chain +enum AbiPath { + Local { path: String, name: Option }, + Etherscan { address: Address, chain: Chain, api_key: String }, +} diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 70e8523ecc5dc..2c48aa783abf9 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -3,7 +3,7 @@ use alloy_consensus::TxEnvelope; use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; -use alloy_json_abi::{ContractObject, Function}; +use alloy_json_abi::Function; use alloy_network::AnyNetwork; use alloy_primitives::{ utils::{keccak256, ParseUnits, Unit}, @@ -973,19 +973,6 @@ where } } -pub struct InterfaceSource { - pub name: String, - pub json_abi: String, - pub source: String, -} - -// Local is a path to the directory containing the ABI files -// In case of etherscan, ABI is fetched from the address on the chain -pub enum AbiPath { - Local { path: String, name: Option }, - Etherscan { address: Address, chain: Chain, api_key: String }, -} - pub struct SimpleCast; impl SimpleCast { @@ -1636,62 +1623,6 @@ impl SimpleCast { Ok(hex::encode_prefixed(calldata)) } - /// Generates an interface in solidity from either a local file ABI or a verified contract on - /// Etherscan. It returns a vector of [`InterfaceSource`] structs that contain the source of the - /// interface and their name. - /// - /// Note: This removes the constructor from the ABI before generating the interface. - /// - /// ```no_run - /// use cast::{AbiPath, SimpleCast as Cast}; - /// # async fn foo() -> eyre::Result<()> { - /// let path = - /// AbiPath::Local { path: "utils/testdata/interfaceTestABI.json".to_owned(), name: None }; - /// let interfaces = Cast::generate_interface(path).await?; - /// println!("interface {} {{\n {}\n}}", interfaces[0].name, interfaces[0].source); - /// # Ok(()) - /// # } - /// ``` - pub async fn generate_interface(address_or_path: AbiPath) -> Result> { - let (mut contract_abis, contract_names) = match address_or_path { - AbiPath::Local { path, name } => { - let file = std::fs::read_to_string(&path).wrap_err("unable to read abi file")?; - let obj: ContractObject = serde_json::from_str(&file)?; - let abi = - obj.abi.ok_or_else(|| eyre::eyre!("could not find ABI in file {path}"))?; - (vec![abi], vec![name.unwrap_or_else(|| "Interface".to_owned())]) - } - AbiPath::Etherscan { address, chain, api_key } => { - let client = Client::new(chain, api_key)?; - let source = client.contract_source_code(address).await?; - let names = source - .items - .iter() - .map(|item| item.contract_name.clone()) - .collect::>(); - - let abis = source.abis()?; - - (abis, names) - } - }; - contract_abis - .iter_mut() - .zip(contract_names) - .map(|(contract_abi, name)| { - // need to filter out the constructor - contract_abi.constructor.take(); - - let source = foundry_cli::utils::abi_to_solidity(contract_abi, &name)?; - Ok(InterfaceSource { - name, - json_abi: serde_json::to_string_pretty(contract_abi)?, - source, - }) - }) - .collect::>>() - } - /// Prints the slot number for the specified mapping type and input data. /// /// For value types `v`, slot number of `v` is `keccak256(concat(h(v), p))` where `h` is the diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 52a7890342820..94052d9a93dfb 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -6,6 +6,7 @@ use crate::{ comments::{ CommentPosition, CommentState, CommentStringExt, CommentType, CommentWithMetadata, Comments, }, + format_diagnostics_report, helpers::import_path_string, macros::*, solang_ext::{pt::*, *}, @@ -16,7 +17,8 @@ use crate::{ use alloy_primitives::Address; use foundry_config::fmt::{HexUnderscore, MultilineFuncHeaderStyle, SingleLineBlockStyle}; use itertools::{Either, Itertools}; -use std::{fmt::Write, str::FromStr}; +use solang_parser::diagnostics::Diagnostic; +use std::{fmt::Write, path::PathBuf, str::FromStr}; use thiserror::Error; type Result = std::result::Result; @@ -28,8 +30,11 @@ pub enum FormatterError { #[error(transparent)] Fmt(#[from] std::fmt::Error), /// Encountered invalid parse tree item. - #[error("Encountered invalid parse tree item at {0:?}")] + #[error("encountered invalid parse tree item at {0:?}")] InvalidParsedItem(Loc), + /// Failed to parse the source code + #[error("failed to parse file:\n{}", format_diagnostics_report(_0, _1.as_deref(), _2))] + Parse(String, Option, Vec), /// All other errors #[error(transparent)] Custom(Box), @@ -39,6 +44,7 @@ impl FormatterError { fn fmt() -> Self { Self::Fmt(std::fmt::Error) } + fn custom(err: impl std::error::Error + Send + Sync + 'static) -> Self { Self::Custom(Box::new(err)) } diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index 26fb48c402011..7f05a9c093bf1 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -22,8 +22,19 @@ pub struct Parsed<'a> { pub invalid_inline_config_items: Vec<(Loc, InvalidInlineConfigItem)>, } -/// Parse source code -pub fn parse(src: &str) -> Result, Vec> { +/// Parse source code. +pub fn parse(src: &str) -> Result, FormatterError> { + parse_raw(src).map_err(|diag| FormatterError::Parse(src.to_string(), None, diag)) +} + +/// Parse source code with a path for diagnostics. +pub fn parse2<'s>(src: &'s str, path: Option<&Path>) -> Result, FormatterError> { + parse_raw(src) + .map_err(|diag| FormatterError::Parse(src.to_string(), path.map(ToOwned::to_owned), diag)) +} + +/// Parse source code, returning a list of diagnostics on failure. +pub fn parse_raw(src: &str) -> Result, Vec> { let (pt, comments) = solang_parser::parse(src, 0)?; let comments = Comments::new(comments, src); let (inline_config_items, invalid_inline_config_items): (Vec<_>, Vec<_>) = @@ -46,10 +57,7 @@ pub fn format_to( /// Parse and format a string with default settings pub fn format(src: &str) -> Result { - let parsed = parse(src).map_err(|err| { - debug!(?err, "Parse error"); - FormatterError::Fmt(std::fmt::Error) - })?; + let parsed = parse(src)?; let mut output = String::new(); format_to(&mut output, parsed, FormatterConfig::default())?; @@ -75,18 +83,19 @@ pub fn offset_to_line_column(content: &str, start: usize) -> (usize, usize) { unreachable!("content.len() > start") } -/// Print the report of parser's diagnostics -pub fn print_diagnostics_report( +/// Formats parser diagnostics +pub fn format_diagnostics_report( content: &str, path: Option<&Path>, - diagnostics: Vec, -) -> std::io::Result<()> { + diagnostics: &[Diagnostic], +) -> String { if diagnostics.is_empty() { - return Ok(()); + return String::new(); } let filename = path.map(|p| p.file_name().unwrap().to_string_lossy().to_string()).unwrap_or_default(); + let mut s = Vec::new(); for diag in diagnostics { let (start, end) = (diag.loc.start(), diag.loc.end()); let mut report = Report::build(ReportKind::Error, &filename, start) @@ -94,16 +103,16 @@ pub fn print_diagnostics_report( .with_label( Label::new((&filename, start..end)) .with_color(Color::Red) - .with_message(format!("{}", diag.message.fg(Color::Red))), + .with_message(format!("{}", diag.message.as_str().fg(Color::Red))), ); - for note in diag.notes { - report = report.with_note(note.message); + for note in &diag.notes { + report = report.with_note(¬e.message); } - report.finish().print((&filename, Source::from(content)))?; + report.finish().write((&filename, Source::from(content)), &mut s).unwrap(); } - Ok(()) + String::from_utf8(s).unwrap() } pub fn import_path_string(path: &ImportPath) -> String { diff --git a/crates/fmt/src/lib.rs b/crates/fmt/src/lib.rs index 4d5fe17a7f04e..006b4db02abe8 100644 --- a/crates/fmt/src/lib.rs +++ b/crates/fmt/src/lib.rs @@ -21,7 +21,7 @@ pub use foundry_config::fmt::*; pub use comments::Comments; pub use formatter::{Formatter, FormatterError}; pub use helpers::{ - format, format_to, offset_to_line_column, parse, print_diagnostics_report, Parsed, + format, format_diagnostics_report, format_to, offset_to_line_column, parse, parse2, Parsed, }; pub use inline_config::InlineConfig; pub use visit::{Visitable, Visitor}; diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index c7d84eddb724d..55ba71780926d 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -1,6 +1,6 @@ use clap::{Parser, ValueHint}; -use eyre::Result; -use forge_fmt::{format_to, parse, print_diagnostics_report}; +use eyre::{Context, Result}; +use forge_fmt::{format_to, parse}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; use foundry_common::{fs, term::cli_warn}; use foundry_compilers::{compilers::solc::SolcLanguage, SOLC_EXTENSIONS}; @@ -102,9 +102,8 @@ impl FmtArgs { None => "stdin".to_string(), }; - let parsed = parse(&source).map_err(|diagnostics| { - let _ = print_diagnostics_report(&source, path, diagnostics); - eyre::eyre!("Failed to parse Solidity code for {name}. Leaving source unchanged.") + let parsed = parse(&source).wrap_err_with(|| { + format!("Failed to parse Solidity code for {name}. Leaving source unchanged.") })?; if !parsed.invalid_inline_config_items.is_empty() { diff --git a/crates/forge/bin/cmd/geiger/error.rs b/crates/forge/bin/cmd/geiger/error.rs index 77c6374ea7a76..010fb237ca070 100644 --- a/crates/forge/bin/cmd/geiger/error.rs +++ b/crates/forge/bin/cmd/geiger/error.rs @@ -1,12 +1,11 @@ +use forge_fmt::FormatterError; use foundry_common::errors::FsPathError; -use solang_parser::diagnostics::Diagnostic; -use std::path::PathBuf; /// Possible errors when scanning a solidity file #[derive(Debug, thiserror::Error)] pub enum ScanFileError { #[error(transparent)] Io(#[from] FsPathError), - #[error("Failed to parse {1:?}: {0:?}")] - ParseSol(Vec, PathBuf), + #[error(transparent)] + ParseSol(#[from] FormatterError), } diff --git a/crates/forge/bin/cmd/geiger/find.rs b/crates/forge/bin/cmd/geiger/find.rs index 3ea9c02341098..6629390caeea8 100644 --- a/crates/forge/bin/cmd/geiger/find.rs +++ b/crates/forge/bin/cmd/geiger/find.rs @@ -1,8 +1,8 @@ use super::{error::ScanFileError, visitor::CheatcodeVisitor}; use eyre::Result; -use forge_fmt::{offset_to_line_column, parse, Visitable}; +use forge_fmt::{offset_to_line_column, parse2, FormatterError, Visitable}; use foundry_common::fs; -use solang_parser::{diagnostics::Diagnostic, pt::Loc}; +use solang_parser::pt::Loc; use std::{ fmt, path::{Path, PathBuf}, @@ -12,14 +12,16 @@ use yansi::Paint; /// Scan a single file for `unsafe` cheatcode usage. pub fn find_cheatcodes_in_file(path: &Path) -> Result { let contents = fs::read_to_string(path)?; - let cheatcodes = find_cheatcodes_in_string(&contents) - .map_err(|diagnostic| ScanFileError::ParseSol(diagnostic, path.to_path_buf()))?; + let cheatcodes = find_cheatcodes_in_string(&contents, Some(path))?; Ok(SolFileMetrics { contents, cheatcodes, file: path.to_path_buf() }) } /// Scan a string for unsafe cheatcodes. -pub fn find_cheatcodes_in_string(src: &str) -> Result> { - let mut parsed = parse(src)?; +pub fn find_cheatcodes_in_string( + src: &str, + path: Option<&Path>, +) -> Result { + let mut parsed = parse2(src, path)?; let mut visitor = CheatcodeVisitor::default(); parsed.pt.visit(&mut visitor).unwrap(); Ok(visitor.cheatcodes) @@ -140,7 +142,7 @@ mod tests { } "; - let count = find_cheatcodes_in_string(s).unwrap(); + let count = find_cheatcodes_in_string(s, None).unwrap(); assert_eq!(count.ffi.len(), 1); assert!(!count.is_empty()); } @@ -156,7 +158,7 @@ mod tests { } "; - let count = find_cheatcodes_in_string(s).unwrap(); + let count = find_cheatcodes_in_string(s, None).unwrap(); assert_eq!(count.ffi.len(), 1); assert!(!count.is_empty()); } From e0785cf00fb5ce2006745a93cd9f121335be3f1d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:05:48 +0300 Subject: [PATCH 1064/1963] chore: add test for #2851 (#8112) chore: add test for 2851 --- crates/forge/tests/it/repros.rs | 7 +++++++ testdata/default/repros/Issue2851.t.sol | 28 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 testdata/default/repros/Issue2851.t.sol diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 924a65b72a697..4f70a1179e726 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -332,3 +332,10 @@ test_repro!(5739); // https://github.com/foundry-rs/foundry/issues/8004 test_repro!(8004); + +// https://github.com/foundry-rs/foundry/issues/2851 +test_repro!(2851, false, None, |res| { + let mut res = res.remove("default/repros/Issue2851.t.sol:Issue2851Test").unwrap(); + let test = res.test_results.remove("invariantNotZero()").unwrap(); + assert_eq!(test.status, TestStatus::Failure); +}); diff --git a/testdata/default/repros/Issue2851.t.sol b/testdata/default/repros/Issue2851.t.sol new file mode 100644 index 0000000000000..f90a5f7c5dc7d --- /dev/null +++ b/testdata/default/repros/Issue2851.t.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.1; + +import "ds-test/test.sol"; + +contract Backdoor { + uint256 public number = 1; + + function backdoor(uint256 newNumber) public payable { + uint256 x = newNumber - 1; + if (x == 6912213124124531) { + number = 0; + } + } +} + +// https://github.com/foundry-rs/foundry/issues/2851 +contract Issue2851Test is DSTest { + Backdoor back; + + function setUp() public { + back = new Backdoor(); + } + + function invariantNotZero() public { + assertEq(back.number(), 1); + } +} From 0b03a58b4a42b149a27e0b6cc1ff9559306f3603 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 7 Jun 2024 20:12:51 +0200 Subject: [PATCH 1065/1963] fix: bypass block gas limit if disabled (#8111) --- crates/anvil/src/eth/backend/executor.rs | 4 ++-- crates/anvil/tests/it/transaction.rs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 52c379da6f793..cccd260857110 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -270,9 +270,9 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator }; let env = self.env_for(&transaction.pending_transaction); - // check that we comply with the block's gas limit + // check that we comply with the block's gas limit, if not disabled let max_gas = self.gas_used.saturating_add(env.tx.gas_limit as u128); - if max_gas > env.block.gas_limit.to::() { + if !env.cfg.disable_block_gas_limit && max_gas > env.block.gas_limit.to::() { return Some(TransactionExecutionOutcome::Exhausted(transaction)) } diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index c693381c6f97a..c80f7b2b32a9c 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -227,6 +227,28 @@ async fn can_reject_too_high_gas_limits() { let _ = pending.unwrap(); } +// +#[tokio::test(flavor = "multi_thread")] +async fn can_mine_large_gas_limit() { + let (api, handle) = spawn(NodeConfig::test().disable_block_gas_limit(true)).await; + let provider = handle.http_provider(); + + let accounts = handle.dev_wallets().collect::>(); + let from = accounts[0].address(); + let to = accounts[1].address(); + + let gas_limit = api.gas_limit().to::(); + let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); + + let tx = + TransactionRequest::default().to(to).value(amount).from(from).with_gas_limit(gas_limit * 3); + + // send transaction with higher gas limit + let pending = provider.send_transaction(WithOtherFields::new(tx)).await.unwrap(); + + let _resp = pending.get_receipt().await.unwrap(); +} + #[tokio::test(flavor = "multi_thread")] async fn can_reject_underpriced_replacement() { let (api, handle) = spawn(NodeConfig::test()).await; From 91d68ac38f3c9ff71daaa43ea01ee6f00887639d Mon Sep 17 00:00:00 2001 From: tesseract <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Sat, 8 Jun 2024 01:23:07 -0700 Subject: [PATCH 1066/1963] feat: Add block id to cast (#8074) * add blockId to cast * Update opts.rs * Update main.rs * Update main.rs * update * tests --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/bin/main.rs | 14 ++++++++++++-- crates/cast/bin/opts.rs | 2 ++ crates/cast/tests/cli/main.rs | 25 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 4e85ef5610f3c..51c43527330af 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -253,10 +253,20 @@ async fn main() -> Result<()> { .await? ); } - CastSubcommand::BlockNumber { rpc } => { + CastSubcommand::BlockNumber { rpc, block } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!("{}", Cast::new(provider).block_number().await?); + let number = match block { + Some(id) => provider + .get_block(id, false) + .await? + .ok_or_else(|| eyre::eyre!("block {id:?} not found"))? + .header + .number + .ok_or_else(|| eyre::eyre!("block {id:?} has no block number"))?, + None => Cast::new(provider).block_number().await?, + }; + println!("{number}"); } CastSubcommand::Chain { rpc } => { let config = Config::from(&rpc); diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 5a15e1df1cc98..4efe4245a6efe 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -330,6 +330,8 @@ pub enum CastSubcommand { /// Get the latest block number. #[command(visible_alias = "bn")] BlockNumber { + /// The hash or tag to query. If not specified, the latest number is returned. + block: Option, #[command(flatten)] rpc: RpcOpts, }, diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 3c86ec4bbaf91..01677464e924c 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -901,3 +901,28 @@ casttest!(index7201, |_prj, cmd| { casttest!(index7201_unknown_formula_id, |_prj, cmd| { cmd.args(["index-7201", "test", "--formula-id", "unknown"]).assert_err(); }); + +casttest!(block_number, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + let s = cmd.args(["block-number", "--rpc-url", eth_rpc_url.as_str()]).stdout_lossy(); + assert!(s.trim().parse::().unwrap() > 0, "{s}") +}); + +casttest!(block_number_latest, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + let s = cmd.args(["block-number", "--rpc-url", eth_rpc_url.as_str(), "latest"]).stdout_lossy(); + assert!(s.trim().parse::().unwrap() > 0, "{s}") +}); + +casttest!(block_number_hash, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + let s = cmd + .args([ + "block-number", + "--rpc-url", + eth_rpc_url.as_str(), + "0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6", + ]) + .stdout_lossy(); + assert_eq!(s.trim().parse::().unwrap(), 1, "{s}") +}); From 91b12927d139bc736f65739543bd890696cbbb96 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 8 Jun 2024 18:03:05 +0300 Subject: [PATCH 1067/1963] fix(invariant): exclude default addresses from senders (#8118) * fix(invariant): exclude default addresses from senders * Changes after review: use array instead vec --- crates/evm/evm/src/executors/invariant/mod.rs | 12 ++++++++-- crates/forge/tests/it/invariant.rs | 19 ++++++++++++++++ .../common/InvariantExcludedSenders.t.sol | 22 +++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 testdata/default/fuzz/invariant/common/InvariantExcludedSenders.t.sol diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index c3229349355e9..6ca49545cd9d8 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -8,7 +8,9 @@ use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::InvariantConfig; use foundry_evm_core::{ - constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME}, + constants::{ + CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME, + }, utils::get_function, }; use foundry_evm_fuzz::{ @@ -492,8 +494,14 @@ impl<'a> InvariantExecutor<'a> { ) -> Result<(SenderFilters, FuzzRunIdentifiedContracts)> { let targeted_senders = self.call_sol_default(to, &IInvariantTest::targetSendersCall {}).targetedSenders; - let excluded_senders = + let mut excluded_senders = self.call_sol_default(to, &IInvariantTest::excludeSendersCall {}).excludedSenders; + // Extend with default excluded addresses - https://github.com/foundry-rs/foundry/issues/4163 + excluded_senders.extend([ + CHEATCODE_ADDRESS, + HARDHAT_CONSOLE_ADDRESS, + DEFAULT_CREATE2_DEPLOYER, + ]); let sender_filters = SenderFilters::new(targeted_senders, excluded_senders); let selected = diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 62e76c274be6e..2f6fde05ba12a 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -229,6 +229,10 @@ async fn test_invariant() { None, None, )], + ), + ( + "default/fuzz/invariant/common/InvariantExcludedSenders.t.sol:InvariantExcludedSendersTest", + vec![("invariant_check_sender()", true, None, None, None)], ) ]), ); @@ -668,3 +672,18 @@ async fn test_invariant_roll_fork_handler() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_excluded_senders() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantExcludedSenders.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.fail_on_revert = true; + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantExcludedSenders.t.sol:InvariantExcludedSendersTest", + vec![("invariant_check_sender()", true, None, None, None)], + )]), + ); +} diff --git a/testdata/default/fuzz/invariant/common/InvariantExcludedSenders.t.sol b/testdata/default/fuzz/invariant/common/InvariantExcludedSenders.t.sol new file mode 100644 index 0000000000000..8fe0bed2c6e7c --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantExcludedSenders.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; + +contract InvariantSenders { + function checkSender() external { + require(msg.sender != 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D, "sender cannot be cheatcode address"); + require(msg.sender != 0x000000000000000000636F6e736F6c652e6c6f67, "sender cannot be console address"); + require(msg.sender != 0x4e59b44847b379578588920cA78FbF26c0B4956C, "sender cannot be CREATE2 deployer"); + } +} + +contract InvariantExcludedSendersTest is DSTest { + InvariantSenders target; + + function setUp() public { + target = new InvariantSenders(); + } + + function invariant_check_sender() public view {} +} From 617931240f77e4751f04ae53e61ca855c78a5bbf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 13:20:43 +0200 Subject: [PATCH 1068/1963] chore(deps): weekly `cargo update` (#8120) Updating git repository `https://github.com/bluealloy/revm.git` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/revm-inspectors` Locking 37 packages to latest compatible versions Updating alloy-dyn-abi v0.7.4 -> v0.7.5 Updating alloy-json-abi v0.7.4 -> v0.7.5 Updating alloy-primitives v0.7.4 -> v0.7.5 Updating alloy-sol-macro v0.7.4 -> v0.7.5 Updating alloy-sol-macro-expander v0.7.4 -> v0.7.5 Updating alloy-sol-macro-input v0.7.4 -> v0.7.5 Updating alloy-sol-type-parser v0.7.4 -> v0.7.5 Updating alloy-sol-types v0.7.4 -> v0.7.5 Updating anstyle-query v1.0.3 -> v1.1.0 Updating aws-config v1.5.0 -> v1.5.1 Updating aws-sdk-kms v1.29.0 -> v1.30.0 Updating aws-sdk-sso v1.27.0 -> v1.29.0 Updating aws-sdk-ssooidc v1.28.0 -> v1.30.0 Updating aws-sdk-sts v1.28.0 -> v1.29.0 Updating aws-smithy-runtime v1.5.4 -> v1.5.5 Updating aws-smithy-runtime-api v1.6.1 -> v1.6.2 Updating aws-types v1.3.0 -> v1.3.1 Updating cc v1.0.98 -> v1.0.99 Updating clap v4.5.4 -> v4.5.6 Updating clap_builder v4.5.2 -> v4.5.6 Updating clap_complete v4.5.2 -> v4.5.5 Updating clap_complete_fig v4.5.0 -> v4.5.1 Updating clap_derive v4.5.4 -> v4.5.5 Updating clap_lex v0.7.0 -> v0.7.1 Updating evmole v0.3.3 -> v0.3.4 Removing heck v0.4.1 Updating hyper v0.14.28 -> v0.14.29 (latest: v1.3.1) Updating proc-macro2 v1.0.84 -> v1.0.85 Updating ruint v1.12.1 -> v1.12.3 Updating ruint-macro v1.2.0 -> v1.2.1 Updating strum_macros v0.26.3 -> v0.26.4 Updating syn-solidity v0.7.4 -> v0.7.5 Updating toml v0.8.13 -> v0.8.14 Updating toml_edit v0.22.13 -> v0.22.14 Updating unicode-width v0.1.12 -> v0.1.13 Updating utf8parse v0.2.1 -> v0.2.2 Updating webpki-roots v0.26.1 -> v0.26.2 Updating winnow v0.6.9 -> v0.6.13 note: pass `--verbose` to see 154 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 214 ++++++++++++++++++++++++++--------------------------- 1 file changed, 104 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05cf20bb599c2..5b5d98cabfb70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8425a283510106b1a6ad25dd4bb648ecde7da3fd2baeb9400a85ad62f51ec90b" +checksum = "efd2404399cb1b50572758e66e9b4bf088e5a3df9007be7126456c7e50af935f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -127,7 +127,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e30946aa6173020259055a44971f5cf40a7d76c931d209caeb51b333263df4f" +checksum = "7c3abf6446a292e19853aaca43590eeb48bf435dfd2c74200259e8f4872f6ce3" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -200,9 +200,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8aa973e647ec336810a9356af8aea787249c9d00b1525359f3db29a68d231b" +checksum = "5277af0cbcc483ee6ad2c1e818090b5928d27f04fd6580680f31c1cf8068bcc2" dependencies = [ "alloy-rlp", "arbitrary", @@ -486,9 +486,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dbd17d67f3e89478c8a634416358e539e577899666c927bc3d2b1328ee9b6ca" +checksum = "30708a79919b082f2692423c8cc72fc250477e4a2ecb0d4a7244cd3cdb299965" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -500,14 +500,14 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6da95adcf4760bb4b108fefa51d50096c5e5fdd29ee72fed3e86ee414f2e34" +checksum = "1c7a679ac01774ab7e00a567a918d4231ae692c5c8cedaf4e16956c3116d7896" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", "const-hex", - "heck 0.4.1", + "heck", "indexmap 2.2.6", "proc-macro-error", "proc-macro2", @@ -519,14 +519,14 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32c8da04c1343871fb6ce5a489218f9c85323c8340a36e9106b5fc98d4dd59d5" +checksum = "356da0c2228aa6675a5faaa08a3e4061b967f924753983d72b9a18d9a3fad44e" dependencies = [ "alloy-json-abi", "const-hex", "dunce", - "heck 0.5.0", + "heck", "proc-macro2", "quote", "serde_json", @@ -536,18 +536,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368cae4dc052cad1d8f72eb2ae0c38027116933eeb49213c200a9e9875f208d7" +checksum = "81fd4783b0a5840479013e9ce960d2eb7b3be381f722e0fe3d1f7c3bb6bd4ebd" dependencies = [ - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] name = "alloy-sol-types" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a64d2d2395c1ac636b62419a7b17ec39031d6b2367e66e9acbf566e6055e9c" +checksum = "6eb5e6234c0b62514992589fe1578f64d418dbc8ef5cd1ab2d7f2f568f599698" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -706,9 +706,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -1128,9 +1128,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1234b742ac4a40a7d3459c6e3c99818271976a5a6ae3732cb415f4a9a94da7b6" +checksum = "2ac9889352d632214df943e26740c46a0f3da6e329fbd28164fe7ae1b061da7b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1148,7 +1148,7 @@ dependencies = [ "fastrand", "hex", "http 0.2.12", - "hyper 0.14.28", + "hyper 0.14.29", "ring", "time", "tokio", @@ -1194,9 +1194,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.29.0" +version = "1.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d5f3e0faac32aa4edbcdcc10330e7b6b1fdbb2e83b44439f5696281e18d278" +checksum = "da951fb0dd1a02728a91c58af8464098766f1a0600af932dd3f8361b23e1bfc9" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1216,9 +1216,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.27.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef53f254e16c00cfbfd69fa6eca4d858b7c161878db2cd248410af402d1951e" +checksum = "da75cf91cbb46686a27436d639a720a3a198b148efa76dc2467b7e5374a67fc0" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1238,9 +1238,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.28.0" +version = "1.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1b673b2972c38463955e27d76c9d2ebb0452a9ce8059a0e2c9ed67efe69ef35" +checksum = "cf2ec8a6687299685ed0a4a3137c129cdb132b5235bc3aa3443f6cffe468b9ff" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1260,9 +1260,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.28.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a422d2f3080421ed23630ada0e474c76e4279c18b4a379bff2f1062e05cef466" +checksum = "458f1031e094b1411b59b49b19e4118f069e1fe13a9c5b8888e933daaf7ffdd6" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1356,9 +1356,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "607e8b53aeb2bc23fb332159d72a69650cd9643c161d76cd3b7f88ac00b5a1bb" +checksum = "d0d3965f6417a92a6d1009c5958a67042f57e46342afb37ca58f9ad26744ec73" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1370,7 +1370,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "http-body 1.0.0", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", @@ -1382,9 +1382,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d790d553d163c7d80a4e06e2906bf24b9172c9ebe045fc3a274e9358ab7bb" +checksum = "4179bd8a1c943e1aceb46c5b9fc014a561bd6c35a2153e816ba29076ee49d245" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1431,9 +1431,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fa328e19c849b20ef7ada4c9b581dd12351ff35ecc7642d06e69de4f98407c" +checksum = "6f734808d43702a67e57d478a12e227d4d038d0b90c9005a78c87890d3805922" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1457,7 +1457,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "itoa", "matchit", "memchr", @@ -1911,9 +1911,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" dependencies = [ "jobserver", "libc", @@ -2023,9 +2023,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" dependencies = [ "clap_builder", "clap_derive", @@ -2033,9 +2033,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" dependencies = [ "anstream", "anstyle", @@ -2048,18 +2048,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.2" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e" +checksum = "d2020fa13af48afc65a9a87335bda648309ab3d154cd03c7ff95b378c7ed39c4" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b3e65f91fabdd23cac3d57d39d5d938b4daabd070c335c006dccb866a61110" +checksum = "fb4bc503cddc1cd320736fb555d6598309ad07c2ddeaa23891a10ffb759ee612" dependencies = [ "clap", "clap_complete", @@ -2067,11 +2067,11 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.66", @@ -2079,9 +2079,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "clearscreen" @@ -3026,7 +3026,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.66", - "toml 0.8.13", + "toml 0.8.14", "walkdir", ] @@ -3078,9 +3078,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd4e05af4c306bcba507bd358feac33ec73f4314a89bd93758d035c629f2f5fe" +checksum = "5bdec28a767d874dd74270c882fb0aa31730af9138d41810fc63b8e7e49f6ddd" dependencies = [ "ruint", ] @@ -3165,7 +3165,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.13", + "toml 0.8.14", "uncased", "version_check", ] @@ -3306,8 +3306,8 @@ dependencies = [ "thiserror", "tikv-jemallocator", "tokio", - "toml 0.8.13", - "toml_edit 0.22.13", + "toml 0.8.14", + "toml_edit 0.22.14", "tower-http", "tracing", "tracing-subscriber", @@ -3336,7 +3336,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.13", + "toml 0.8.14", "tracing", ] @@ -3351,7 +3351,7 @@ dependencies = [ "similar-asserts", "solang-parser", "thiserror", - "toml 0.8.13", + "toml 0.8.14", "tracing", "tracing-subscriber", ] @@ -3494,7 +3494,7 @@ dependencies = [ "semver 1.0.23", "serde_json", "thiserror", - "toml 0.8.13", + "toml 0.8.14", "tracing", "walkdir", ] @@ -3632,7 +3632,7 @@ dependencies = [ "tokio", "tracing", "walkdir", - "winnow 0.6.9", + "winnow 0.6.13", "yansi", ] @@ -3665,8 +3665,8 @@ dependencies = [ "solang-parser", "tempfile", "thiserror", - "toml 0.8.13", - "toml_edit 0.22.13", + "toml 0.8.14", + "toml_edit 0.22.14", "tracing", "walkdir", ] @@ -4043,7 +4043,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d460327b24cc34c86d53d60a90e9e6044817f7906ebd9baa5c3d0ee13e1ecf" dependencies = [ "bytes", - "hyper 0.14.28", + "hyper 0.14.29", "serde", "serde_json", "thiserror", @@ -4061,7 +4061,7 @@ dependencies = [ "chrono", "futures", "gcemeta", - "hyper 0.14.28", + "hyper 0.14.29", "jsonwebtoken", "once_cell", "prost", @@ -4417,12 +4417,6 @@ dependencies = [ "serde", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -4586,9 +4580,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -4636,7 +4630,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.28", + "hyper 0.14.29", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -4667,7 +4661,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.28", + "hyper 0.14.29", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -6305,9 +6299,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -6656,7 +6650,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -6731,7 +6725,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.26.1", + "webpki-roots 0.26.2", "winreg 0.52.0", ] @@ -6891,9 +6885,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", "arbitrary", @@ -6916,9 +6910,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rusb" @@ -7697,8 +7691,8 @@ dependencies = [ "sha256", "simple-home-dir", "tokio", - "toml 0.8.13", - "toml_edit 0.22.13", + "toml 0.8.14", + "toml_edit 0.22.14", "uuid 1.8.0", "walkdir", "yansi", @@ -7799,11 +7793,11 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "rustversion", @@ -7886,9 +7880,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8db114c44cf843a8bacd37a146e37987a0b823a0e8bc4fdc610c9c72ab397a5" +checksum = "e6fe08d08d84f2c0a77f1e7c46518789d745c2e87a2721791ed7c3c9bc78df28" dependencies = [ "paste", "proc-macro2", @@ -8258,15 +8252,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -8291,15 +8285,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.9", + "winnow 0.6.13", ] [[package]] @@ -8316,7 +8310,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-timeout", "percent-encoding", "pin-project 1.1.5", @@ -8633,9 +8627,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -8674,9 +8668,9 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -8913,9 +8907,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +checksum = "3c452ad30530b54a4d8e71952716a212b08efd0f3562baa66c29a618b07da7c3" dependencies = [ "rustls-pki-types", ] @@ -9203,9 +9197,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.9" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] From db60cb31925dea531e82516d9a4a3d8ccb42f8be Mon Sep 17 00:00:00 2001 From: poma Date: Mon, 10 Jun 2024 20:01:16 +0300 Subject: [PATCH 1069/1963] Support WalletOpts in `cast wallet derive-private-key` command (#8119) * Support WalletOpts in `cast wallet derive-private-key` command * rename cast wallet `derive-private-key` to `private-key` * fix formatting * Add aliases * verbose flag * tests * Make output format more consistent with other subcommands * hide legacy aliases * derivation path --------- Co-authored-by: poma --- crates/cast/bin/cmd/wallet/mod.rs | 70 ++++++++++++++++++++++++------- crates/cast/tests/cli/main.rs | 40 ++++++++++++++++++ 2 files changed, 96 insertions(+), 14 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index def14c17e13cb..a22d6a6ec224a 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -149,8 +149,24 @@ pub enum WalletSubcommands { List(ListArgs), /// Derives private key from mnemonic - #[command(name = "derive-private-key", visible_aliases = &["--derive-private-key"])] - DerivePrivateKey { mnemonic: String, mnemonic_index: Option }, + #[command(name = "private-key", visible_alias = "pk", aliases = &["derive-private-key", "--derive-private-key"])] + PrivateKey { + /// If provided, the private key will be derived from the specified menomonic phrase. + #[arg(value_name = "MNEMONIC")] + mnemonic_override: Option, + + /// If provided, the private key will be derived using the + /// specified mnemonic index (if integer) or derivation path. + #[arg(value_name = "MNEMONIC_INDEX_OR_DERIVATION_PATH")] + mnemonic_index_or_derivation_path_override: Option, + + /// Verbose mode, print the address and private key. + #[arg(short = 'v', long)] + verbose: bool, + + #[command(flatten)] + wallet: WalletOpts, + }, /// Decrypt a keystore file to get the private key #[command(name = "decrypt-keystore", visible_alias = "dk")] @@ -363,18 +379,44 @@ flag to set your key via: Self::List(cmd) => { cmd.run().await?; } - Self::DerivePrivateKey { mnemonic, mnemonic_index } => { - let phrase = Mnemonic::::new_from_phrase(mnemonic.as_str())?.to_phrase(); - let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); - let derivation_path = "m/44'/60'/0'/0/"; - let index = mnemonic_index.unwrap_or_default(); - let wallet = builder - .clone() - .derivation_path(format!("{derivation_path}{index}"))? - .build()?; - println!("- Account:"); - println!("Address: {}", wallet.address()); - println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); + Self::PrivateKey { + wallet, + mnemonic_override, + mnemonic_index_or_derivation_path_override, + verbose, + } => { + let (index_override, derivation_path_override) = + match mnemonic_index_or_derivation_path_override { + Some(value) => match value.parse::() { + Ok(index) => (Some(index), None), + Err(_) => (None, Some(value)), + }, + None => (None, None), + }; + let wallet = WalletOpts { + raw: RawWalletOpts { + mnemonic: mnemonic_override.or(wallet.raw.mnemonic), + mnemonic_index: index_override.unwrap_or(wallet.raw.mnemonic_index), + hd_path: derivation_path_override.or(wallet.raw.hd_path), + ..wallet.raw + }, + ..wallet + } + .signer() + .await?; + match wallet { + WalletSigner::Local(wallet) => { + if verbose { + println!("Address: {}", wallet.address()); + println!("Private key: 0x{}", hex::encode(wallet.signer().to_bytes())); + } else { + println!("0x{}", hex::encode(wallet.signer().to_bytes())); + } + } + _ => { + eyre::bail!("Only local wallets are supported by this command."); + } + } } Self::DecryptKeystore { account_name, keystore_dir, unsafe_password } => { // Set up keystore directory diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 01677464e924c..5a6be401bb230 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -163,6 +163,46 @@ casttest!(wallet_list_local_accounts, |prj, cmd| { assert_eq!(list_output.matches('\n').count(), 10); }); +// tests that `cast wallet private-key` with arguments outputs the private key +casttest!(wallet_private_key_from_mnemonic_arg, |_prj, cmd| { + cmd.args([ + "wallet", + "private-key", + "test test test test test test test test test test test junk", + "1", + ]); + let output = cmd.stdout_lossy(); + assert_eq!(output.trim(), "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"); +}); + +// tests that `cast wallet private-key` with options outputs the private key +casttest!(wallet_private_key_from_mnemonic_option, |_prj, cmd| { + cmd.args([ + "wallet", + "private-key", + "--mnemonic", + "test test test test test test test test test test test junk", + "--mnemonic-index", + "1", + ]); + let output = cmd.stdout_lossy(); + assert_eq!(output.trim(), "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"); +}); + +// tests that `cast wallet private-key` with derivation path outputs the private key +casttest!(wallet_private_key_with_derivation_path, |_prj, cmd| { + cmd.args([ + "wallet", + "private-key", + "--mnemonic", + "test test test test test test test test test test test junk", + "--mnemonic-derivation-path", + "m/44'/60'/0'/0/1", + ]); + let output = cmd.stdout_lossy(); + assert_eq!(output.trim(), "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"); +}); + // tests that `cast wallet import` creates a keystore for a private key and that `cast wallet // decrypt-keystore` can access it casttest!(wallet_import_and_decrypt, |prj, cmd| { From 81896c5ca7075124b083ce97699cb1687910a757 Mon Sep 17 00:00:00 2001 From: tesseract <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:04:59 -0700 Subject: [PATCH 1070/1963] Feat: add solc & evm version to anvil readme (#7945) * Update README.md * add forge --- crates/anvil/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/anvil/README.md b/crates/anvil/README.md index cb62354fbc519..0e775441d6ee9 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -11,6 +11,15 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** - mining modes: auto, interval, manual, none - ... +## Supported Versions + +- **anvil**: + - **evm**: Cancun +- **forge**: + - **solc**: Latest + - **evm**: Cancun + + ## Installation `anvil` binary is available via [`foundryup`](../../README.md#installation). From edcb8ad30f5cedd19533326edbb8579013860bc4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 11 Jun 2024 12:23:11 +0200 Subject: [PATCH 1071/1963] feat: add too many warnings error variant (#8125) * feat: add too many warnings error variant * docs: add to readme --- crates/config/README.md | 2 +- crates/config/src/error.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/config/README.md b/crates/config/README.md index 25100a5df7795..482ec29acb4e1 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -103,7 +103,7 @@ eth_rpc_url = "https://example.com/" # Setting this option enables decoding of error traces from mainnet deployed / verfied contracts via etherscan etherscan_api_key = "YOURETHERSCANAPIKEY" # ignore solc warnings for missing license and exceeded contract size -# known error codes are: ["unreachable", "unused-return", "unused-param", "unused-var", "code-size", "shadowing", "func-mutability", "license", "pragma-solidity", "virtual-interfaces", "same-varname"] +# known error codes are: ["unreachable", "unused-return", "unused-param", "unused-var", "code-size", "shadowing", "func-mutability", "license", "pragma-solidity", "virtual-interfaces", "same-varname", "too-many-warnings"] # additional warnings can be added using their numeric error code: ["license", 1337] ignored_error_codes = ["license", "code-size"] ignored_warnings_from = ["path_to_ignore"] diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 0f6dae9bf0ad9..016e32c470ab8 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -136,6 +136,8 @@ pub enum SolidityErrorCode { PragmaSolidity, /// Uses transient opcodes TransientStorageUsed, + /// There are more than 256 warnings. Ignoring the rest. + TooManyWarnings, /// All other error codes Other(u64), } @@ -162,6 +164,7 @@ impl SolidityErrorCode { SolidityErrorCode::Unreachable => "unreachable", SolidityErrorCode::PragmaSolidity => "pragma-solidity", SolidityErrorCode::TransientStorageUsed => "transient-storage", + SolidityErrorCode::TooManyWarnings => "too-many-warnings", SolidityErrorCode::Other(code) => return Err(*code), }; Ok(s) @@ -187,6 +190,7 @@ impl From for u64 { SolidityErrorCode::Unreachable => 5740, SolidityErrorCode::PragmaSolidity => 3420, SolidityErrorCode::TransientStorageUsed => 2394, + SolidityErrorCode::TooManyWarnings => 4591, SolidityErrorCode::Other(code) => code, } } @@ -222,6 +226,7 @@ impl FromStr for SolidityErrorCode { "unreachable" => SolidityErrorCode::Unreachable, "pragma-solidity" => SolidityErrorCode::PragmaSolidity, "transient-storage" => SolidityErrorCode::TransientStorageUsed, + "too-many-warnings" => SolidityErrorCode::TooManyWarnings, _ => return Err(format!("Unknown variant {s}")), }; From 29e51120ac6e77a62242364a22108edea7274a2a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:25:15 +0300 Subject: [PATCH 1072/1963] fix(forge): preserve state of persisted accounts on rollFork(tx) / transact (#8129) * fix(forge): preserve state of persisted accounts on rollFork to tx / transact * Changes after review: cleaner way to check if account persistent --- crates/evm/core/src/backend/mod.rs | 36 +++++++++++++++----- crates/evm/evm/src/inspectors/stack.rs | 4 +-- crates/forge/tests/it/repros.rs | 3 ++ testdata/default/repros/Issue8006.t.sol | 44 +++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 testdata/default/repros/Issue8006.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index addfccb85faa3..b96829196a99d 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -900,6 +900,7 @@ impl Backend { ) -> eyre::Result> { trace!(?id, ?tx_hash, "replay until transaction"); + let persistent_accounts = self.inner.persistent_accounts.clone(); let fork_id = self.ensure_fork_id(id)?.clone(); let env = self.env_with_handler_cfg(env); @@ -929,6 +930,7 @@ impl Backend { journaled_state, fork, &fork_id, + &persistent_accounts, &mut NoOpInspector, )?; } @@ -1248,6 +1250,7 @@ impl DatabaseExt for Backend { inspector: &mut I, ) -> eyre::Result<()> { trace!(?maybe_id, ?transaction, "execute transaction"); + let persistent_accounts = self.inner.persistent_accounts.clone(); let id = self.ensure_fork(maybe_id)?; let fork_id = self.ensure_fork_id(id).cloned()?; @@ -1265,7 +1268,15 @@ impl DatabaseExt for Backend { let env = self.env_with_handler_cfg(env); let fork = self.inner.get_fork_by_id_mut(id)?; - commit_transaction(tx, env, journaled_state, fork, &fork_id, inspector) + commit_transaction( + tx, + env, + journaled_state, + fork, + &fork_id, + &persistent_accounts, + inspector, + ) } fn active_fork_id(&self) -> Option { @@ -1879,6 +1890,7 @@ fn commit_transaction>( journaled_state: &mut JournaledState, fork: &mut Fork, fork_id: &ForkId, + persistent_accounts: &HashSet
, inspector: I, ) -> eyre::Result<()> { configure_tx_env(&mut env.env, &tx); @@ -1894,16 +1906,23 @@ fn commit_transaction>( }; trace!(elapsed = ?now.elapsed(), "transacted transaction"); - apply_state_changeset(res.state, journaled_state, fork)?; + apply_state_changeset(res.state, journaled_state, fork, persistent_accounts)?; Ok(()) } /// Helper method which updates data in the state with the data from the database. -pub fn update_state(state: &mut EvmState, db: &mut DB) -> Result<(), DB::Error> { +/// Does not change state for persistent accounts (for roll fork to transaction and transact). +pub fn update_state( + state: &mut EvmState, + db: &mut DB, + persistent_accounts: Option<&HashSet
>, +) -> Result<(), DB::Error> { for (addr, acc) in state.iter_mut() { - acc.info = db.basic(*addr)?.unwrap_or_default(); - for (key, val) in acc.storage.iter_mut() { - val.present_value = db.storage(*addr, *key)?; + if !persistent_accounts.map_or(false, |accounts| accounts.contains(addr)) { + acc.info = db.basic(*addr)?.unwrap_or_default(); + for (key, val) in acc.storage.iter_mut() { + val.present_value = db.storage(*addr, *key)?; + } } } @@ -1916,12 +1935,13 @@ fn apply_state_changeset( state: Map, journaled_state: &mut JournaledState, fork: &mut Fork, + persistent_accounts: &HashSet
, ) -> Result<(), DatabaseError> { // commit the state and update the loaded accounts fork.db.commit(state); - update_state(&mut journaled_state.state, &mut fork.db)?; - update_state(&mut fork.journaled_state.state, &mut fork.db)?; + update_state(&mut journaled_state.state, &mut fork.db, Some(persistent_accounts))?; + update_state(&mut fork.journaled_state.state, &mut fork.db, Some(persistent_accounts))?; Ok(()) } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 1eb21d6dede8b..52949e8e194ea 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -515,7 +515,7 @@ impl InspectorStack { ecx.db.commit(res.state.clone()); // Update both states with new DB data after commit. - if let Err(e) = update_state(&mut ecx.journaled_state.state, &mut ecx.db) { + if let Err(e) = update_state(&mut ecx.journaled_state.state, &mut ecx.db, None) { let res = InterpreterResult { result: InstructionResult::Revert, output: Bytes::from(e.to_string()), @@ -523,7 +523,7 @@ impl InspectorStack { }; return (res, None) } - if let Err(e) = update_state(&mut res.state, &mut ecx.db) { + if let Err(e) = update_state(&mut res.state, &mut ecx.db, None) { let res = InterpreterResult { result: InstructionResult::Revert, output: Bytes::from(e.to_string()), diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 4f70a1179e726..9150da5f0b280 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -339,3 +339,6 @@ test_repro!(2851, false, None, |res| { let test = res.test_results.remove("invariantNotZero()").unwrap(); assert_eq!(test.status, TestStatus::Failure); }); + +// https://github.com/foundry-rs/foundry/issues/8006 +test_repro!(8006); diff --git a/testdata/default/repros/Issue8006.t.sol b/testdata/default/repros/Issue8006.t.sol new file mode 100644 index 0000000000000..1e2023bf194ad --- /dev/null +++ b/testdata/default/repros/Issue8006.t.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +interface IERC20 { + function totalSupply() external view returns (uint256 supply); +} + +contract Mock { + function totalSupply() external view returns (uint256 supply) { + return 1; + } +} + +// https://github.com/foundry-rs/foundry/issues/8006 +contract Issue5739Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + IERC20 dai; + bytes32 transaction = 0x67cbad73764049e228495a3f90144aab4a37cb4b5fd697dffc234aa5ed811ace; + + function setUp() public { + vm.createSelectFork("rpcAlias", 16261704); + dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); + } + + function testRollForkEtchNotCalled() public { + // dai not persistent so should not call mock code + vm.etch(address(dai), address(new Mock()).code); + assertEq(dai.totalSupply(), 1); + vm.rollFork(transaction); + assertEq(dai.totalSupply(), 5155217627191887307044676292); + } + + function testRollForkEtchCalled() public { + // make dai persistent so mock code is preserved + vm.etch(address(dai), address(new Mock()).code); + vm.makePersistent(address(dai)); + assertEq(dai.totalSupply(), 1); + vm.rollFork(transaction); + assertEq(dai.totalSupply(), 1); + } +} From 0636c5dc935ba69557261ed5eec936c9d2d856dc Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:28:00 +0300 Subject: [PATCH 1073/1963] chore: add roll fork invariant test with handler state (#8130) --- crates/forge/tests/it/invariant.rs | 45 ++++++++++++++----- .../invariant/common/InvariantRollFork.t.sol | 23 +++++++++- testdata/default/repros/Issue8006.t.sol | 2 +- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 2f6fde05ba12a..fbd906d0ca0f9 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -221,7 +221,7 @@ async fn test_invariant() { )], ), ( - "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkTest", + "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkBlockTest", vec![( "invariant_fork_handler_block()", false, @@ -230,6 +230,16 @@ async fn test_invariant() { None, )], ), + ( + "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkStateTest", + vec![( + "invariant_fork_handler_state()", + false, + Some("revert: wrong supply".into()), + None, + None, + )], + ), ( "default/fuzz/invariant/common/InvariantExcludedSenders.t.sol:InvariantExcludedSendersTest", vec![("invariant_check_sender()", true, None, None, None)], @@ -658,18 +668,31 @@ async fn test_invariant_roll_fork_handler() { Some(tempfile::tempdir().unwrap().into_path()); let results = runner.test_collect(&filter); + assert_multiple( &results, - BTreeMap::from([( - "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkTest", - vec![( - "invariant_fork_handler_block()", - false, - Some("revert: too many blocks mined".into()), - None, - None, - )], - )]), + BTreeMap::from([ + ( + "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkBlockTest", + vec![( + "invariant_fork_handler_block()", + false, + Some("revert: too many blocks mined".into()), + None, + None, + )], + ), + ( + "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkStateTest", + vec![( + "invariant_fork_handler_state()", + false, + Some("revert: wrong supply".into()), + None, + None, + )], + ), + ]), ); } diff --git a/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol b/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol index 7934a29160e4d..d74509cd45a75 100644 --- a/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol @@ -4,15 +4,21 @@ pragma solidity ^0.8.13; import "ds-test/test.sol"; import "cheats/Vm.sol"; +interface IERC20 { + function totalSupply() external view returns (uint256 supply); +} + contract RollForkHandler is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); + uint256 public totalSupply; function work() external { vm.rollFork(block.number + 1); + totalSupply = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F).totalSupply(); } } -contract InvariantRollForkTest is DSTest { +contract InvariantRollForkBlockTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); RollForkHandler forkHandler; @@ -27,3 +33,18 @@ contract InvariantRollForkTest is DSTest { require(block.number < 19812634, "too many blocks mined"); } } + +contract InvariantRollForkStateTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + RollForkHandler forkHandler; + + function setUp() public { + vm.createSelectFork("rpcAlias", 19812632); + forkHandler = new RollForkHandler(); + } + + /// forge-config: default.invariant.runs = 1 + function invariant_fork_handler_state() public { + require(forkHandler.totalSupply() < 3254378807384273078310283461, "wrong supply"); + } +} diff --git a/testdata/default/repros/Issue8006.t.sol b/testdata/default/repros/Issue8006.t.sol index 1e2023bf194ad..1a45ddf977cfa 100644 --- a/testdata/default/repros/Issue8006.t.sol +++ b/testdata/default/repros/Issue8006.t.sol @@ -15,7 +15,7 @@ contract Mock { } // https://github.com/foundry-rs/foundry/issues/8006 -contract Issue5739Test is DSTest { +contract Issue8006Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); IERC20 dai; bytes32 transaction = 0x67cbad73764049e228495a3f90144aab4a37cb4b5fd697dffc234aa5ed811ace; From 1ac4de029853655ec4a8e27fa0ca73132b273f73 Mon Sep 17 00:00:00 2001 From: Swanny Date: Tue, 11 Jun 2024 14:33:18 -0400 Subject: [PATCH 1074/1963] fix(forge): needs a aws-kms feature to allow for continued support of the --aws flag (#8131) --- crates/forge/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index dcd40a4aa06f6..28d679262f40e 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -135,6 +135,7 @@ rustls = [ openssl = ["foundry-cli/openssl", "reqwest/default-tls"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] +aws-kms = ["foundry-wallets/aws-kms"] [[bench]] name = "test" From 462b2ac6c038dc24b8f38b0c59b664d0740604c2 Mon Sep 17 00:00:00 2001 From: Swanny Date: Tue, 11 Jun 2024 14:33:36 -0400 Subject: [PATCH 1075/1963] fix(release): build forge and cast with aws support on release (#8132) * fix(release): build forge and cast with aws support on release * fix(release): add support for aws-kms features for docker and releases --- .github/workflows/release.yml | 4 +++- Dockerfile | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c78fed2af22f..c993c0d8dab20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -137,7 +137,9 @@ jobs: # `jemalloc` and `keccak-asm` are not supported on MSVC or aarch64 Linux. if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then - flags+=(--features asm-keccak,jemalloc) + flags+=(--features asm-keccak,jemalloc,cast/aws-kms,forge/aws-kms) + else + flags+=(--features cast/aws-kms,forge/aws-kms) fi [[ "$target" == *windows* ]] && exe=".exe" diff --git a/Dockerfile b/Dockerfile index e900ee1e81742..aba0b3986d32c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ COPY . . RUN git update-index --force-write-index RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/root/.cargo/git --mount=type=cache,target=/opt/foundry/target \ - source $HOME/.profile && cargo build --release \ + source $HOME/.profile && cargo build --release --features cast/aws-kms,forge/aws-kms \ && mkdir out \ && mv target/release/forge out/forge \ && mv target/release/cast out/cast \ From bc545937f543d153920bbe87d999c54f623d2f8e Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 12 Jun 2024 08:23:25 +0300 Subject: [PATCH 1076/1963] bump compilers (#8126) --- Cargo.lock | 8 +- Cargo.toml | 4 +- crates/common/src/compile.rs | 184 ++++++++++-------- crates/debugger/src/tui/draw.rs | 31 ++- crates/debugger/src/tui/mod.rs | 8 +- crates/evm/traces/src/identifier/etherscan.rs | 15 +- crates/forge/bin/cmd/bind.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 3 +- crates/forge/src/multi_runner.rs | 8 +- crates/forge/tests/cli/build.rs | 20 +- .../forge/tests/fixtures/compile_json.stdout | 9 +- crates/script/src/build.rs | 3 +- crates/test-utils/src/util.rs | 2 +- crates/verify/src/etherscan/flatten.rs | 5 +- 14 files changed, 165 insertions(+), 137 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b5d98cabfb70..91b6f3c50c6b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3444,9 +3444,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673c42208fee48238ef6833cf55295c9e9b5546383caf426da72d849fb43dc24" +checksum = "35344cf275788b0450c4b36d452b812d1122d622bafb29887ce244b8099a86ad" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3597,9 +3597,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a92aa3e4d0aa91fda44c1840c68d634fc126bdd06099516eb2b81035e5e6d0" +checksum = "81f9b10619d07d765a0336b1990ffcb1bb7b806a59b4d2e65cb78f5d77f373c5" dependencies = [ "alloy-json-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 2418bdf081ca6..65532c07434c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,8 +152,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.3.0", default-features = false } -foundry-compilers = { version = "0.6.2", default-features = false } +foundry-block-explorers = { version = "0.4.0", default-features = false } +foundry-compilers = { version = "0.7.0", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 4ab4b170d9d65..d26b362a9adb2 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -6,11 +6,10 @@ use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ artifacts::{BytecodeObject, ContractBytecodeSome, Libraries, Source}, - compilers::{solc::SolcCompiler, CompilationError, Compiler}, + compilers::{multi::MultiCompilerLanguage, solc::SolcCompiler, Compiler}, remappings::Remapping, report::{BasicStdoutReporter, NoReporter, Report}, - Artifact, ArtifactId, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, Solc, - SolcConfig, + Artifact, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig, }; use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; @@ -20,6 +19,7 @@ use std::{ fmt::Display, io::IsTerminal, path::{Path, PathBuf}, + sync::Arc, time::Instant, }; @@ -122,10 +122,7 @@ impl ProjectCompiler { } /// Compiles the project. - pub fn compile( - mut self, - project: &Project, - ) -> Result> { + pub fn compile(mut self, project: &Project) -> Result> { // TODO: Avoid process::exit if !project.paths.has_input_files() && self.files.is_empty() { println!("Nothing to compile"); @@ -159,9 +156,9 @@ impl ProjectCompiler { /// ProjectCompiler::new().compile_with(|| Ok(prj.compile()?)).unwrap(); /// ``` #[instrument(target = "forge::compile", skip_all)] - fn compile_with(self, f: F) -> Result> + fn compile_with(self, f: F) -> Result> where - F: FnOnce() -> Result>, + F: FnOnce() -> Result>, { let quiet = self.quiet.unwrap_or(false); let bail = self.bail.unwrap_or(true); @@ -209,7 +206,7 @@ impl ProjectCompiler { } /// If configured, this will print sizes or names - fn handle_output(&self, output: &ProjectCompileOutput) { + fn handle_output(&self, output: &ProjectCompileOutput) { let print_names = self.print_names.unwrap_or(false); let print_sizes = self.print_sizes.unwrap_or(false); @@ -274,90 +271,121 @@ impl ProjectCompiler { } } -/// Contract source code and bytecode. +#[derive(Clone, Debug)] +pub struct SourceData { + pub source: Arc, + pub language: MultiCompilerLanguage, +} + +#[derive(Clone, Debug)] +pub struct ArtifactData { + pub bytecode: ContractBytecodeSome, + pub build_id: String, + pub file_id: u32, +} + +/// Contract source code and bytecode data used for debugger. #[derive(Clone, Debug, Default)] pub struct ContractSources { - /// Map over artifacts' contract names -> vector of file IDs - pub ids_by_name: HashMap>, - /// Map over file_id -> source code - pub sources_by_id: FxHashMap, - /// Map over file_id -> contract name -> bytecode - pub artifacts_by_id: FxHashMap>, + /// Map over build_id -> file_id -> (source code, language) + pub sources_by_id: HashMap>, + /// Map over contract name -> Vec<(bytecode, build_id, file_id)> + pub artifacts_by_name: HashMap>, } impl ContractSources { /// Collects the contract sources and artifacts from the project compile output. pub fn from_project_output( output: &ProjectCompileOutput, - root: &Path, - libraries: &Libraries, + link_data: Option<(&Path, &Libraries)>, ) -> Result { - let linker = Linker::new(root, output.artifact_ids().collect()); - let mut sources = Self::default(); + + sources.insert(output, link_data)?; + + Ok(sources) + } + + pub fn insert( + &mut self, + output: &ProjectCompileOutput, + link_data: Option<(&Path, &Libraries)>, + ) -> Result<()> + where + C::Language: Into, + { + let link_data = link_data.map(|(root, libraries)| { + let linker = Linker::new(root, output.artifact_ids().collect()); + (linker, libraries) + }); + for (id, artifact) in output.artifact_ids() { if let Some(file_id) = artifact.id { - let abs_path = root.join(&id.source); - let source_code = std::fs::read_to_string(abs_path).wrap_err_with(|| { - format!("failed to read artifact source file for `{}`", id.identifier()) - })?; - let linked = linker.link(&id, libraries)?; - let contract = compact_to_contract(linked.into_contract_bytecode())?; - sources.insert(&id, file_id, source_code, contract); + let artifact = if let Some((linker, libraries)) = link_data.as_ref() { + linker.link(&id, libraries)?.into_contract_bytecode() + } else { + artifact.clone().into_contract_bytecode() + }; + let bytecode = compact_to_contract(artifact.clone().into_contract_bytecode())?; + + self.artifacts_by_name.entry(id.name.clone()).or_default().push(ArtifactData { + bytecode, + build_id: id.build_id.clone(), + file_id, + }); } else { warn!(id = id.identifier(), "source not found"); } } - Ok(sources) - } - /// Inserts a contract into the sources. - pub fn insert( - &mut self, - artifact_id: &ArtifactId, - file_id: u32, - source: String, - bytecode: ContractBytecodeSome, - ) { - self.ids_by_name.entry(artifact_id.name.clone()).or_default().push(file_id); - self.sources_by_id.insert(file_id, source); - self.artifacts_by_id.entry(file_id).or_default().insert(artifact_id.name.clone(), bytecode); - } + // Not all source files produce artifacts, so we are populating sources by using build + // infos. + let mut files: BTreeMap> = BTreeMap::new(); + for (build_id, build) in output.builds() { + for (source_id, path) in &build.source_id_to_path { + let source_code = if let Some(source) = files.get(path) { + source.clone() + } else { + let source = Source::read(path).wrap_err_with(|| { + format!("failed to read artifact source file for `{}`", path.display()) + })?; + files.insert(path.clone(), source.content.clone()); + source.content + }; + + self.sources_by_id.entry(build_id.clone()).or_default().insert( + *source_id, + SourceData { source: source_code, language: build.language.into() }, + ); + } + } - /// Returns the source for a contract by file ID. - pub fn get(&self, id: u32) -> Option<&String> { - self.sources_by_id.get(&id) + Ok(()) } /// Returns all sources for a contract by name. - pub fn get_sources<'a>( - &'a self, - name: &'a str, - ) -> Option> { - self.ids_by_name.get(name).map(|ids| { - ids.iter().filter_map(|id| { - Some(( - *id, - self.sources_by_id.get(id)?.as_ref(), - self.artifacts_by_id.get(id)?.get(name)?, - )) + pub fn get_sources( + &self, + name: &str, + ) -> Option> { + self.artifacts_by_name.get(name).map(|artifacts| { + artifacts.iter().filter_map(|artifact| { + let source = + self.sources_by_id.get(artifact.build_id.as_str())?.get(&artifact.file_id)?; + Some((artifact, source)) }) }) } - /// Returns all (name, source, bytecode) sets. - pub fn entries(&self) -> impl Iterator { - self.artifacts_by_id - .iter() - .filter_map(|(id, artifacts)| { - let source = self.sources_by_id.get(id)?; - Some( - artifacts - .iter() - .map(move |(name, bytecode)| (name.as_ref(), source.as_ref(), bytecode)), - ) + /// Returns all (name, bytecode, source) sets. + pub fn entries(&self) -> impl Iterator { + self.artifacts_by_name.iter().flat_map(|(name, artifacts)| { + artifacts.iter().filter_map(|artifact| { + let source = + self.sources_by_id.get(artifact.build_id.as_str())?.get(&artifact.file_id)?; + Some((name.as_str(), artifact, source)) }) - .flatten() + }) } } @@ -464,7 +492,7 @@ pub fn compile_target( target_path: &Path, project: &Project, quiet: bool, -) -> Result> { +) -> Result> { ProjectCompiler::new().quiet(quiet).files([target_path.into()]).compile(project) } @@ -472,7 +500,7 @@ pub fn compile_target( /// Returns the artifact_id, the file_id, and the bytecode pub async fn compile_from_source( metadata: &Metadata, -) -> Result<(ArtifactId, u32, ContractBytecodeSome)> { +) -> Result> { let root = tempfile::tempdir()?; let root_path = root.path(); let project = etherscan_project(metadata, root_path)?; @@ -483,23 +511,9 @@ pub async fn compile_from_source( eyre::bail!("{project_output}") } - let (artifact_id, file_id, contract) = project_output - .into_artifacts() - .find(|(artifact_id, _)| artifact_id.name == metadata.contract_name) - .map(|(aid, art)| { - (aid, art.source_file().expect("no source file").id, art.into_contract_bytecode()) - }) - .ok_or_else(|| { - eyre::eyre!( - "Unable to find bytecode in compiled output for contract: {}", - metadata.contract_name - ) - })?; - let bytecode = compact_to_contract(contract)?; - root.close()?; - Ok((artifact_id, file_id, bytecode)) + Ok(project_output) } /// Creates a [Project] from an Etherscan source. diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 8e55687a0aec1..2909ef803ed6b 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -3,7 +3,7 @@ use super::context::{BufferKind, DebuggerContext}; use crate::op::OpcodeParam; use alloy_primitives::U256; -use foundry_compilers::sourcemap::SourceElement; +use foundry_compilers::{compilers::multi::MultiCompilerLanguage, sourcemap::SourceElement}; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, @@ -344,32 +344,43 @@ impl DebuggerContext<'_> { let is_create = matches!(self.call_kind(), CallKind::Create | CallKind::Create2); let pc = self.current_step().pc; let Some((source_element, source_code)) = - files_source_code.find_map(|(file_id, source_code, contract_source)| { + files_source_code.find_map(|(artifact, source)| { let bytecode = if is_create { - &contract_source.bytecode + &artifact.bytecode.bytecode } else { - contract_source.deployed_bytecode.bytecode.as_ref()? + artifact.bytecode.deployed_bytecode.bytecode.as_ref()? }; - let source_map = bytecode.source_map()?.ok()?; + let source_map = bytecode.source_map()?.expect("failed to parse"); let pc_ic_map = if is_create { create_map } else { rt_map }; let ic = pc_ic_map.get(pc)?; - let source_element = source_map.get(ic)?; + + // Solc indexes source maps by instruction counter, but Vyper indexes by program + // counter. + let source_element = if matches!(source.language, MultiCompilerLanguage::Solc(_)) { + source_map.get(ic)? + } else { + source_map.get(pc)? + }; // if the source element has an index, find the sourcemap for that index - source_element + let res = source_element .index() // if index matches current file_id, return current source code .and_then(|index| { - (index == file_id).then(|| (source_element.clone(), source_code)) + (index == artifact.file_id) + .then(|| (source_element.clone(), source.source.as_str())) }) .or_else(|| { // otherwise find the source code for the element's index self.debugger .contracts_sources .sources_by_id + .get(&artifact.build_id)? .get(&source_element.index()?) - .map(|source_code| (source_element.clone(), source_code.as_ref())) - }) + .map(|source| (source_element.clone(), source.source.as_str())) + }); + + res }) else { return Err(format!("No source map for contract {contract_name}")); diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index d57c6e7a26ee9..c810440e5b133 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -66,12 +66,12 @@ impl Debugger { ) -> Self { let pc_ic_maps = contracts_sources .entries() - .filter_map(|(contract_name, _, contract)| { + .filter_map(|(name, artifact, _)| { Some(( - contract_name.to_owned(), + name.to_owned(), ( - PcIcMap::new(contract.bytecode.bytes()?), - PcIcMap::new(contract.deployed_bytecode.bytes()?), + PcIcMap::new(artifact.bytecode.bytecode.bytes()?), + PcIcMap::new(artifact.bytecode.deployed_bytecode.bytes()?), ), )) }) diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 977b69a42340a..794b3a9edd118 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -59,14 +59,11 @@ impl EtherscanIdentifier { /// Etherscan and compiles them locally, for usage in the debugger. pub async fn get_compiled_contracts(&self) -> eyre::Result { // TODO: Add caching so we dont double-fetch contracts. - let contracts_iter = self + let outputs_fut = self .contracts .iter() // filter out vyper files - .filter(|(_, metadata)| !metadata.is_vyper()); - - let outputs_fut = contracts_iter - .clone() + .filter(|(_, metadata)| !metadata.is_vyper()) .map(|(address, metadata)| { println!("Compiling: {} {address}", metadata.contract_name); let err_msg = @@ -76,15 +73,13 @@ impl EtherscanIdentifier { .collect::>(); // poll all the futures concurrently - let artifacts = join_all(outputs_fut).await; + let outputs = join_all(outputs_fut).await; let mut sources: ContractSources = Default::default(); // construct the map - for (results, (_, metadata)) in artifacts.into_iter().zip(contracts_iter) { - // get the inner type - let (artifact_id, file_id, bytecode) = results?; - sources.insert(&artifact_id, file_id, metadata.source_code(), bytecode); + for output in outputs { + sources.insert(&output?, None)?; } Ok(sources) diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index dcf76fc2f4245..8283ca7d81ccf 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -168,7 +168,7 @@ impl BindArgs { Ok(json_files(artifacts) .filter_map(|path| { // Ignore the build info JSON. - if path.to_str()?.contains("/build-info/") { + if path.to_str()?.contains("build-info") { return None; } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index d2de7ef232b99..c27e2053d6f1c 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -337,8 +337,7 @@ impl TestArgs { let sources = ContractSources::from_project_output( output_clone.as_ref().unwrap(), - project.root(), - &libraries, + Some((project.root(), &libraries)), )?; // Run the debugger. diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 1e2be6c7cb845..1c1206fa06a47 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -8,7 +8,9 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput}; +use foundry_compilers::{ + artifacts::Libraries, compilers::Compiler, Artifact, ArtifactId, ProjectCompileOutput, +}; use foundry_config::Config; use foundry_evm::{ backend::Backend, decode::RevertDecoder, executors::ExecutorBuilder, fork::CreateFork, @@ -356,10 +358,10 @@ impl MultiContractRunnerBuilder { /// Given an EVM, proceeds to return a runner which is able to execute all tests /// against that evm - pub fn build( + pub fn build( self, root: &Path, - output: ProjectCompileOutput, + output: ProjectCompileOutput, env: revm::primitives::Env, evm_opts: EvmOpts, ) -> Result { diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index e2dca7e0aaa2f..93b3137426780 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -1,7 +1,8 @@ +use foundry_common::fs::read_json_file; use foundry_config::Config; -use foundry_test_utils::{forgetest, util::OutputExt}; +use foundry_test_utils::forgetest; use globset::Glob; -use std::path::PathBuf; +use std::{collections::BTreeMap, path::PathBuf}; // tests that json is printed when --json is passed forgetest!(compile_json, |prj, cmd| { @@ -21,10 +22,17 @@ contract Dummy { // set up command cmd.args(["compile", "--format-json"]); - // run command and assert - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/compile_json.stdout"), - ); + // Exclude build_infos from output as IDs depend on root dir and are not deterministic. + let mut output: BTreeMap = + serde_json::from_str(&cmd.stdout_lossy()).unwrap(); + output.remove("build_infos"); + + let expected: BTreeMap = read_json_file( + &PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/compile_json.stdout"), + ) + .unwrap(); + + similar_asserts::assert_eq!(output, expected); }); // tests build output is as expected diff --git a/crates/forge/tests/fixtures/compile_json.stdout b/crates/forge/tests/fixtures/compile_json.stdout index f3eb33ea0d8cd..eff78e60c8d7a 100644 --- a/crates/forge/tests/fixtures/compile_json.stdout +++ b/crates/forge/tests/fixtures/compile_json.stdout @@ -1,4 +1,5 @@ { + "contracts": {}, "errors": [ { "sourceLocation": { @@ -11,10 +12,8 @@ "severity": "error", "errorCode": "7576", "message": "Undeclared identifier. Did you mean \"newNumber\"?", - "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n --> src/dummy.sol:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" + "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n --> src/jsonError.sol:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" } ], - "sources": {}, - "contracts": {}, - "build_infos": {} -} + "sources": {} +} \ No newline at end of file diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 342096fda3d13..f1a18d45fa8b6 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -136,8 +136,7 @@ impl LinkedBuildData { ) -> Result { let sources = ContractSources::from_project_output( &build_data.output, - &build_data.project_root, - &libraries, + Some((&build_data.project_root, &libraries)), )?; let known_contracts = diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index e1a681db62f85..6d2d5233a3c60 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1083,7 +1083,7 @@ static IGNORE_IN_FIXTURES: Lazy = Lazy::new(|| { Regex::new(&format!("({})", re.join("|"))).unwrap() }); -fn normalize_output(s: &str) -> String { +pub fn normalize_output(s: &str) -> String { let s = s.replace("\r\n", "\n").replace('\\', "/"); IGNORE_IN_FIXTURES.replace_all(&s, "").into_owned() } diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index fa888f92295a0..ac586b48cd13e 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -4,6 +4,7 @@ use eyre::{Context, Result}; use foundry_block_explorers::verify::CodeFormat; use foundry_compilers::{ artifacts::{BytecodeHash, Source}, + buildinfo::RawBuildInfo, compilers::{ solc::{SolcCompiler, SolcLanguage, SolcVersionedInput}, Compiler, CompilerInput, @@ -87,8 +88,8 @@ impl EtherscanFlattenedSource { let out = SolcCompiler::Specific(solc).compile(&input)?; if out.errors.iter().any(|e| e.is_error()) { - let mut o = AggregatedCompilerOutput::default(); - o.extend(version, out); + let mut o = AggregatedCompilerOutput::::default(); + o.extend(version.clone(), RawBuildInfo::new(&input, &out, false)?, out); let diags = o.diagnostics(&[], &[], Default::default()); eyre::bail!( From 481c74b140f8612997386f80bc33dc6f63a18f8d Mon Sep 17 00:00:00 2001 From: Zhuo Zhang <14835483+ZhangZhuoSJTU@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:53:56 -0400 Subject: [PATCH 1077/1963] fix(forge): fix the bug where source code incorrectly overlaps during debugging (#8134) --- crates/debugger/src/tui/draw.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 2909ef803ed6b..aa6ac13cf2d18 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -322,6 +322,14 @@ impl DebuggerContext<'_> { lines.push(u_num, line, u_text); } + // pad with empty to each line to ensure the previous text is cleared + for line in &mut lines.lines { + // note that the \n is not included in the line length + if area.width as usize > line.width() + 1 { + line.push_span(Span::raw(" ".repeat(area.width as usize - line.width() - 1))); + } + } + Text::from(lines.lines) } From f8160598b76ac6fabb0133fe62fab4c432ccb5c9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 12 Jun 2024 20:56:42 +0200 Subject: [PATCH 1078/1963] fix: remove hardcoded retries (#8141) --- crates/common/src/provider/tower.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs index bb64ee8ab828b..73088021d508f 100644 --- a/crates/common/src/provider/tower.rs +++ b/crates/common/src/provider/tower.rs @@ -55,7 +55,7 @@ impl tower::layer::Layer for RetryBackoffLayer { inner, policy: RateLimitRetryPolicy, max_rate_limit_retries: self.max_rate_limit_retries, - max_timeout_retries: self.max_timeout_retries, + _max_timeout_retries: self.max_timeout_retries, initial_backoff: self.initial_backoff, compute_units_per_second: self.compute_units_per_second, requests_enqueued: Arc::new(AtomicU32::new(0)), @@ -74,7 +74,7 @@ pub struct RetryBackoffService { /// The maximum number of retries for rate limit errors max_rate_limit_retries: u32, /// The maximum number of retries for timeout errors - max_timeout_retries: u32, + _max_timeout_retries: u32, /// The initial backoff in milliseconds initial_backoff: u64, /// The number of compute units per second for this service @@ -100,7 +100,6 @@ impl tower::Service for RetryBackoffService { Box::pin(async move { let ahead_in_queue = this.requests_enqueued.fetch_add(1, Ordering::SeqCst) as u64; let mut rate_limit_retry_number: u32 = 0; - let mut timeout_retries: u32 = 0; loop { let err; let fut = this.inner.call(request.clone()).await; @@ -157,11 +156,7 @@ impl tower::Service for RetryBackoffService { tokio::time::sleep(total_backoff).await; } else { - if timeout_retries < this.max_timeout_retries { - timeout_retries += 1; - continue; - } - + trace!("encountered non retryable error {err:?}"); this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); return Err(err) } From 82f0aaa34c7f3abc542abc34a02ca941f73bc517 Mon Sep 17 00:00:00 2001 From: morito Date: Thu, 13 Jun 2024 04:21:30 +0900 Subject: [PATCH 1079/1963] chore(deps): Bump alloy 14ed25d (#8128) * chore: bump alloy 14ed25d * Format files * format: Remove unnecessary trailing comma updates * Fix to update only alloy in Cargo.lock * common: Enable eth feature for allot-rpc-types * Enable eth feature for alloy-rpc-types * bump alloy * new retry changes --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 214 +++++++++++-------- Cargo.toml | 52 ++--- crates/anvil/core/src/eth/transaction/mod.rs | 14 +- crates/anvil/src/config.rs | 4 +- crates/anvil/src/eth/api.rs | 13 +- crates/anvil/src/eth/backend/executor.rs | 9 +- crates/anvil/src/eth/backend/fork.rs | 8 +- crates/anvil/src/eth/otterscan/api.rs | 2 +- crates/anvil/src/tasks/mod.rs | 2 +- crates/anvil/tests/it/anvil.rs | 7 +- crates/anvil/tests/it/anvil_api.rs | 37 ++-- crates/anvil/tests/it/api.rs | 15 +- crates/anvil/tests/it/eip4844.rs | 2 +- crates/anvil/tests/it/fork.rs | 44 ++-- crates/anvil/tests/it/gas.rs | 10 +- crates/anvil/tests/it/traces.rs | 2 +- crates/anvil/tests/it/transaction.rs | 10 +- crates/cast/Cargo.toml | 2 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/main.rs | 2 +- crates/cast/src/lib.rs | 5 +- crates/common/Cargo.toml | 2 +- crates/common/src/fmt/ui.rs | 4 +- crates/common/src/provider/retry.rs | 47 ++-- crates/common/src/transactions.rs | 2 +- crates/evm/core/src/fork/backend.rs | 6 +- crates/script/src/receipts.rs | 4 +- crates/verify/src/bytecode.rs | 2 +- 28 files changed, 297 insertions(+), 226 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91b6f3c50c6b5..dc6ee96381233 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-eips", "alloy-primitives", @@ -93,7 +93,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -101,7 +101,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-pubsub", - "alloy-rpc-types", + "alloy-rpc-types-eth", "alloy-sol-types", "alloy-transport", "futures", @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd2404399cb1b50572758e66e9b4bf088e5a3df9007be7126456c7e50af935f" +checksum = "cb6e6436a9530f25010d13653e206fab4c9feddacf21a54de8d7311b275bc56b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-primitives", "alloy-serde", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3abf6446a292e19853aaca43590eeb48bf435dfd2c74200259e8f4872f6ce3" +checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-primitives", "serde", @@ -183,13 +183,13 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types-eth", "alloy-signer", "alloy-sol-types", "async-trait", @@ -200,9 +200,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5277af0cbcc483ee6ad2c1e818090b5928d27f04fd6580680f31c1cf8068bcc2" +checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" dependencies = [ "alloy-rlp", "arbitrary", @@ -228,7 +228,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -238,7 +238,7 @@ dependencies = [ "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types", + "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-transport", "alloy-transport-http", @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -303,7 +303,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -327,45 +327,55 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +dependencies = [ + "alloy-rpc-types-eth", + "alloy-rpc-types-trace", + "alloy-serde", +] + +[[package]] +name = "alloy-rpc-types-engine" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-eips", - "alloy-genesis", "alloy-primitives", "alloy-rlp", + "alloy-rpc-types-eth", "alloy-serde", - "alloy-sol-types", - "itertools 0.12.1", + "jsonwebtoken", + "rand", "serde", - "serde_json", "thiserror", ] [[package]] -name = "alloy-rpc-types-engine" +name = "alloy-rpc-types-eth" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-eips", + "alloy-genesis", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types", "alloy-serde", - "jsonwebtoken", - "rand", + "alloy-sol-types", + "itertools 0.13.0", "serde", + "serde_json", "thiserror", ] [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types-eth", "alloy-serde", "serde", "serde_json", @@ -374,7 +384,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-primitives", "serde", @@ -384,7 +394,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -399,7 +409,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-network", @@ -416,7 +426,7 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-network", @@ -433,7 +443,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -452,7 +462,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-network", @@ -468,7 +478,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-consensus", "alloy-network", @@ -486,9 +496,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30708a79919b082f2692423c8cc72fc250477e4a2ecb0d4a7244cd3cdb299965" +checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -500,9 +510,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c7a679ac01774ab7e00a567a918d4231ae692c5c8cedaf4e16956c3116d7896" +checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -519,9 +529,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356da0c2228aa6675a5faaa08a3e4061b967f924753983d72b9a18d9a3fad44e" +checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" dependencies = [ "alloy-json-abi", "const-hex", @@ -536,18 +546,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fd4783b0a5840479013e9ce960d2eb7b3be381f722e0fe3d1f7c3bb6bd4ebd" +checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" dependencies = [ "winnow 0.6.13", ] [[package]] name = "alloy-sol-types" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eb5e6234c0b62514992589fe1578f64d418dbc8ef5cd1ab2d7f2f568f599698" +checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -559,7 +569,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -571,13 +581,12 @@ dependencies = [ "tokio", "tower", "url", - "wasm-bindgen-futures", ] [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -591,7 +600,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -611,15 +620,16 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=cc68b93#cc68b93605f4521c2b0bce1a7efaeff2046cf07c" +source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" dependencies = [ "alloy-pubsub", "alloy-transport", "futures", - "http 0.2.12", + "http 1.1.0", + "rustls 0.23.9", "serde_json", "tokio", - "tokio-tungstenite 0.20.1", + "tokio-tungstenite 0.23.0", "tracing", "ws_stream_wasm", ] @@ -2109,9 +2119,9 @@ dependencies = [ [[package]] name = "coins-bip32" -version = "0.8.7" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" +checksum = "66c43ff7fd9ff522219058808a259e61423335767b1071d5b346de60d9219657" dependencies = [ "bs58", "coins-core", @@ -2125,9 +2135,9 @@ dependencies = [ [[package]] name = "coins-bip39" -version = "0.8.7" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" +checksum = "4c4587c0b4064da887ed39a6522f577267d57e58bdd583178cd877d721b56a2e" dependencies = [ "bitvec", "coins-bip32", @@ -2141,19 +2151,18 @@ dependencies = [ [[package]] name = "coins-core" -version = "0.8.7" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" +checksum = "6b3aeeec621f4daec552e9d28befd58020a78cfc364827d06a753e8bc13c6c4b" dependencies = [ "base64 0.21.7", "bech32", "bs58", + "const-hex", "digest 0.10.7", "generic-array", - "hex", "ripemd", "serde", - "serde_derive", "sha2", "sha3", "thiserror", @@ -2161,15 +2170,15 @@ dependencies = [ [[package]] name = "coins-ledger" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e076e6e5d9708f0b90afe2dbe5a8ba406b5c794347661e6e44618388c7e3a31" +checksum = "166ef757aa936b45f3e5d39c344047f65ef7d25a50067246a498021a816d074b" dependencies = [ "async-trait", "byteorder", "cfg-if", + "const-hex", "getrandom", - "hex", "hidapi-rusb", "js-sys", "log", @@ -6378,7 +6387,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.66", @@ -6725,7 +6734,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.26.2", + "webpki-roots", "winreg 0.52.0", ] @@ -6746,11 +6755,10 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=a278649#a2786496b2edcb06abed5a33682c532d070bf47c" +source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=5cf339c#5cf339cada76e3dc38c864aab870d3cdb7b6860d" dependencies = [ "alloy-primitives", "alloy-rpc-types", - "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "colorchoice", @@ -6999,6 +7007,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls" +version = "0.23.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.4", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -7880,9 +7902,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fe08d08d84f2c0a77f1e7c46518789d745c2e87a2721791ed7c3c9bc78df28" +checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" dependencies = [ "paste", "proc-macro2", @@ -8189,6 +8211,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.9", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -8203,29 +8236,30 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", - "rustls 0.21.12", "tokio", - "tokio-rustls 0.24.1", - "tungstenite 0.20.1", - "webpki-roots 0.25.4", + "tungstenite 0.21.0", ] [[package]] name = "tokio-tungstenite" -version = "0.21.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +checksum = "becd34a233e7e31a3dbf7c7241b38320f57393dcae8e7324b0167d21b8e320b0" dependencies = [ "futures-util", "log", + "rustls 0.23.9", + "rustls-pki-types", "tokio", - "tungstenite 0.21.0", + "tokio-rustls 0.26.0", + "tungstenite 0.23.0", + "webpki-roots", ] [[package]] @@ -8496,18 +8530,17 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ "byteorder", "bytes", "data-encoding", - "http 0.2.12", + "http 1.1.0", "httparse", "log", "rand", - "rustls 0.21.12", "sha1", "thiserror", "url", @@ -8516,9 +8549,9 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.21.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8" dependencies = [ "byteorder", "bytes", @@ -8527,9 +8560,10 @@ dependencies = [ "httparse", "log", "rand", + "rustls 0.23.9", + "rustls-pki-types", "sha1", "thiserror", - "url", "utf-8", ] @@ -8899,12 +8933,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.25.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" - [[package]] name = "webpki-roots" version = "0.26.2" diff --git a/Cargo.toml b/Cargo.toml index 65532c07434c3..58b2a8972c91c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,7 +159,7 @@ foundry-compilers = { version = "0.7.0", default-features = false } # no default features to avoid c-kzg revm = { version = "9.0.0", default-features = false } revm-primitives = { version = "4.0.0", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "a278649", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "5cf339c", features = [ "serde", ] } @@ -167,30 +167,30 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "cc68b93", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" @@ -247,4 +247,4 @@ soldeer = "0.2.15" revm = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } -revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } \ No newline at end of file +revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 712ac937d3a72..013759d3b1e16 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -6,7 +6,7 @@ use alloy_consensus::{ AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, TxEnvelope, TxLegacy, TxReceipt, }; -use alloy_eips::eip2718::{Decodable2718, Encodable2718}; +use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ @@ -962,7 +962,7 @@ impl Encodable2718 for TypedTransaction { } impl Decodable2718 for TypedTransaction { - fn typed_decode(ty: u8, buf: &mut &[u8]) -> alloy_rlp::Result { + fn typed_decode(ty: u8, buf: &mut &[u8]) -> Result { if ty == 0x7E { return Ok(Self::Deposit(DepositTransaction::decode(buf)?)) } @@ -974,7 +974,7 @@ impl Decodable2718 for TypedTransaction { } } - fn fallback_decode(buf: &mut &[u8]) -> alloy_rlp::Result { + fn fallback_decode(buf: &mut &[u8]) -> Result { match TxEnvelope::fallback_decode(buf)? { TxEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)), _ => unreachable!(), @@ -1295,7 +1295,7 @@ impl Encodable2718 for TypedReceipt { } impl Decodable2718 for TypedReceipt { - fn typed_decode(ty: u8, buf: &mut &[u8]) -> alloy_rlp::Result { + fn typed_decode(ty: u8, buf: &mut &[u8]) -> Result { if ty == 0x7E { return Ok(Self::Deposit(DepositReceipt::decode(buf)?)) } @@ -1307,7 +1307,7 @@ impl Decodable2718 for TypedReceipt { } } - fn fallback_decode(buf: &mut &[u8]) -> alloy_rlp::Result { + fn fallback_decode(buf: &mut &[u8]) -> Result { match ReceiptEnvelope::fallback_decode(buf)? { ReceiptEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)), _ => unreachable!(), @@ -1506,7 +1506,7 @@ mod tests { let mut data = vec![]; let receipt = TypedReceipt::Legacy(ReceiptWithBloom { receipt: Receipt { - status: false, + status: false.into(), cumulative_gas_used: 0x1u128, logs: vec![Log { address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), @@ -1541,7 +1541,7 @@ mod tests { let expected = TypedReceipt::Legacy(ReceiptWithBloom { receipt: Receipt { - status: false, + status: false.into(), cumulative_gas_used: 0x1u128, logs: vec![Log { address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 1b332c3a3bb69..f9fe56c2c1d28 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1026,7 +1026,7 @@ impl NodeConfig { }; let block = provider - .get_block(BlockNumberOrTag::Number(fork_block_number).into(), false) + .get_block(BlockNumberOrTag::Number(fork_block_number).into(), false.into()) .await .expect("Failed to get fork block"); @@ -1282,7 +1282,7 @@ async fn find_latest_fork_block, T: Transport + Clone // walk back from the head of the chain, but at most 2 blocks, which should be more than enough // leeway for _ in 0..2 { - if let Some(block) = provider.get_block(num.into(), false).await? { + if let Some(block) = provider.get_block(num.into(), false.into()).await? { if block.header.hash.is_some() { break; } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 57acc197cb8d9..49e0db680cba7 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1197,7 +1197,7 @@ impl EthApi { let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?; if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return Ok(fork.uncle_by_block_number_and_index(number, idx.into()).await?); + return Ok(fork.uncle_by_block_number_and_index(number, idx.into()).await?) } } // It's impossible to have uncles outside of fork mode @@ -1923,7 +1923,14 @@ impl EthApi { if let Some(receipt) = self.backend.mined_transaction_receipt(tx.hash) { if let Some(output) = receipt.out { // insert revert reason if failure - if !receipt.inner.inner.as_receipt_with_bloom().receipt.status { + if !receipt + .inner + .inner + .as_receipt_with_bloom() + .receipt + .status + .coerce_status() + { if let Some(reason) = RevertDecoder::new().maybe_decode(&output, None) { @@ -2514,7 +2521,7 @@ impl EthApi { if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { if fork.predates_fork_inclusive(number) { - return Ok(fork.get_nonce(address, number).await?); + return Ok(fork.get_nonce(address, number).await?) } } } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index cccd260857110..163428eeb6c53 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -54,9 +54,12 @@ impl ExecutedTransaction { // successful return see [Return] let status_code = u8::from(self.exit_reason as u8 <= InstructionResult::SelfDestruct as u8); - let receipt_with_bloom: ReceiptWithBloom = - Receipt { status: status_code == 1, cumulative_gas_used: *cumulative_gas_used, logs } - .into(); + let receipt_with_bloom: ReceiptWithBloom = Receipt { + status: (status_code == 1).into(), + cumulative_gas_used: *cumulative_gas_used, + logs, + } + .into(); match &self.transaction.pending_transaction.transaction.transaction { TypedTransaction::Legacy(_) => TypedReceipt::Legacy(receipt_with_bloom), diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index a04e134400412..feecc94875c65 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -75,8 +75,10 @@ impl ClientFork { } let provider = self.provider(); - let block = - provider.get_block(block_number, false).await?.ok_or(BlockchainError::BlockNotFound)?; + let block = provider + .get_block(block_number, false.into()) + .await? + .ok_or(BlockchainError::BlockNotFound)?; let block_hash = block.header.hash.ok_or(BlockchainError::BlockNotFound)?; let timestamp = block.header.timestamp; let base_fee = block.header.base_fee_per_gas; @@ -482,7 +484,7 @@ impl ClientFork { &self, block_id: impl Into, ) -> Result, TransportError> { - if let Some(block) = self.provider().get_block(block_id.into(), true).await? { + if let Some(block) = self.provider().get_block(block_id.into(), true.into()).await? { let hash = block.header.hash.unwrap(); let block_number = block.header.number.unwrap(); let mut storage = self.storage_write(); diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index dac698a5a17df..a830855d423d6 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -66,7 +66,7 @@ impl EthApi { node_info!("ots_getTransactionError"); if let Some(receipt) = self.backend.mined_transaction_receipt(hash) { - if !receipt.inner.inner.as_receipt_with_bloom().receipt.status { + if !receipt.inner.inner.as_receipt_with_bloom().receipt.status.coerce_status() { return Ok(receipt.out.map(|b| b.0.into()).unwrap_or(Bytes::default())) } } diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index 499cb3e67cf0e..d2ceb0dcaf44b 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -74,7 +74,7 @@ impl TaskManager { let provider = provider.clone(); let api = api.clone(); async move { - if let Ok(Some(block)) = provider.get_block(hash.into(), false).await { + if let Ok(Some(block)) = provider.get_block(hash.into(), false.into()).await { let _ = api .anvil_reset(Some(Forking { json_rpc_url: None, diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 7aff5660e6ce9..b8aed751d2e6e 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -62,7 +62,7 @@ async fn test_can_set_genesis_timestamp() { assert_eq!( genesis_timestamp, - provider.get_block(0.into(), false).await.unwrap().unwrap().header.timestamp + provider.get_block(0.into(), false.into()).await.unwrap().unwrap().header.timestamp ); } @@ -71,5 +71,8 @@ async fn test_can_use_default_genesis_timestamp() { let (_api, handle) = spawn(NodeConfig::test()).await; let provider = handle.http_provider(); - assert_ne!(0u64, provider.get_block(0.into(), false).await.unwrap().unwrap().header.timestamp); + assert_ne!( + 0u64, + provider.get_block(0.into(), false.into()).await.unwrap().unwrap().header.timestamp + ); } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 0ebffe94acac6..11aa40bdc706b 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -287,14 +287,14 @@ async fn test_set_next_timestamp() { api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.number.unwrap(), 1); assert_eq!(block.header.timestamp, next_timestamp.as_secs()); api.evm_mine(None).await.unwrap(); - let next = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let next = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert_eq!(next.header.number.unwrap(), 2); assert!(next.header.timestamp > block.header.timestamp); @@ -314,12 +314,12 @@ async fn test_evm_set_time() { // mine a block api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert!(block.header.timestamp >= timestamp.as_secs()); api.evm_mine(None).await.unwrap(); - let next = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let next = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert!(next.header.timestamp > block.header.timestamp); } @@ -338,7 +338,7 @@ async fn test_evm_set_time_in_past() { // mine a block api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert!(block.header.timestamp >= timestamp.as_secs()); assert!(block.header.timestamp < now.as_secs()); @@ -353,42 +353,44 @@ async fn test_timestamp_interval() { let interval = 10; for _ in 0..5 { - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); // mock timestamp api.evm_set_block_timestamp_interval(interval).unwrap(); api.evm_mine(None).await.unwrap(); - let new_block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let new_block = + provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert_eq!(new_block.header.timestamp, block.header.timestamp + interval); } - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); let next_timestamp = block.header.timestamp + 50; api.evm_set_next_block_timestamp(next_timestamp).unwrap(); api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.timestamp, next_timestamp); api.evm_mine(None).await.unwrap(); - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); // interval also works after setting the next timestamp manually assert_eq!(block.header.timestamp, next_timestamp + interval); assert!(api.evm_remove_block_timestamp_interval().unwrap()); api.evm_mine(None).await.unwrap(); - let new_block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let new_block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); // offset is applied correctly after resetting the interval assert!(new_block.header.timestamp > block.header.timestamp); api.evm_mine(None).await.unwrap(); - let another_block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let another_block = + provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); // check interval is disabled assert!(another_block.header.timestamp - new_block.header.timestamp < interval); } @@ -429,7 +431,8 @@ async fn can_get_node_info() { let provider = handle.http_provider(); let block_number = provider.get_block_number().await.unwrap(); - let block = provider.get_block(BlockId::from(block_number), false).await.unwrap().unwrap(); + let block = + provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); let expected_node_info = NodeInfo { current_block_number: U64::from(0), @@ -463,7 +466,8 @@ async fn can_get_metadata() { let block_number = provider.get_block_number().await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); - let block = provider.get_block(BlockId::from(block_number), false).await.unwrap().unwrap(); + let block = + provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { latest_block_hash: block.header.hash.unwrap(), @@ -488,7 +492,8 @@ async fn can_get_metadata_on_fork() { let block_number = provider.get_block_number().await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); - let block = provider.get_block(BlockId::from(block_number), false).await.unwrap().unwrap(); + let block = + provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); let expected_metadata = AnvilMetadata { latest_block_hash: block.header.hash.unwrap(), @@ -541,7 +546,7 @@ async fn test_get_transaction_receipt() { let receipt = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); // the block should have the new base fee - let block = provider.get_block(BlockId::default(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.base_fee_per_gas.unwrap(), new_base_fee.to::()); // mine blocks diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 0f1d45d6fdf70..b7d6f51c593e8 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -113,11 +113,14 @@ async fn can_get_block_by_number() { provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); - let block = provider.get_block(BlockId::number(1), true).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::number(1), true.into()).await.unwrap().unwrap(); assert_eq!(block.transactions.len(), 1); - let block = - provider.get_block(BlockId::hash(block.header.hash.unwrap()), true).await.unwrap().unwrap(); + let block = provider + .get_block(BlockId::hash(block.header.hash.unwrap()), true.into()) + .await + .unwrap() + .unwrap(); assert_eq!(block.transactions.len(), 1); } @@ -132,7 +135,7 @@ async fn can_get_pending_block() { let provider = connect_pubsub_with_signer(&handle.http_endpoint(), signer).await; - let block = provider.get_block(BlockId::pending(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::pending(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.number.unwrap(), 1); let num = provider.get_block_number().await.unwrap(); @@ -147,12 +150,12 @@ async fn can_get_pending_block() { let num = provider.get_block_number().await.unwrap(); assert_eq!(num, 0); - let block = provider.get_block(BlockId::pending(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::pending(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.number.unwrap(), 1); assert_eq!(block.transactions.len(), 1); assert_eq!(block.transactions, BlockTransactions::Hashes(vec![*pending.tx_hash()])); - let block = provider.get_block(BlockId::pending(), true).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::pending(), true.into()).await.unwrap().unwrap(); assert_eq!(block.header.number.unwrap(), 1); assert_eq!(block.transactions.len(), 1); } diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index c9ab2943c5f9c..1d0df312b3ea4 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -198,7 +198,7 @@ async fn can_check_blob_fields_on_genesis() { let provider = http_provider(&handle.http_endpoint()); - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.blob_gas_used, Some(0)); assert_eq!(block.header.excess_blob_gas, Some(0)); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 19377e845fdef..3ef8665ea255f 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -482,8 +482,11 @@ async fn test_fork_timestamp() { let (api, handle) = spawn(fork_config()).await; let provider = handle.http_provider(); - let block = - provider.get_block(BlockId::Number(BLOCK_NUMBER.into()), false).await.unwrap().unwrap(); + let block = provider + .get_block(BlockId::Number(BLOCK_NUMBER.into()), false.into()) + .await + .unwrap() + .unwrap(); assert_eq!(block.header.timestamp, BLOCK_TIMESTAMP); let accounts: Vec<_> = handle.dev_wallets().collect(); @@ -493,10 +496,10 @@ async fn test_fork_timestamp() { TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let status = tx.inner.inner.inner.receipt.status; + let status = tx.inner.inner.inner.receipt.status.coerce_status(); assert!(status); - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); let elapsed = start.elapsed().as_secs() + 1; @@ -509,8 +512,11 @@ async fn test_fork_timestamp() { api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(BLOCK_NUMBER) })) .await .unwrap(); - let block = - provider.get_block(BlockId::Number(BLOCK_NUMBER.into()), false).await.unwrap().unwrap(); + let block = provider + .get_block(BlockId::Number(BLOCK_NUMBER.into()), false.into()) + .await + .unwrap() + .unwrap(); assert_eq!(block.header.timestamp, BLOCK_TIMESTAMP); let tx = @@ -518,7 +524,7 @@ async fn test_fork_timestamp() { let tx = WithOtherFields::new(tx); let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); // FIXME: Awaits endlessly here. - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); let elapsed = start.elapsed().as_secs() + 1; let diff = block.header.timestamp - BLOCK_TIMESTAMP; assert!(diff <= elapsed); @@ -534,7 +540,7 @@ async fn test_fork_timestamp() { let tx = WithOtherFields::new(tx); let _tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.timestamp, BLOCK_TIMESTAMP + 1); let tx = @@ -542,7 +548,7 @@ async fn test_fork_timestamp() { let tx = WithOtherFields::new(tx); let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); let elapsed = start.elapsed().as_secs() + 1; let diff = block.header.timestamp - (BLOCK_TIMESTAMP + 1); assert!(diff <= elapsed); @@ -621,7 +627,7 @@ async fn test_fork_nft_set_approve_all() { let tx = WithOtherFields::new(tx); api.anvil_impersonate_account(owner).await.unwrap(); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let status = tx.inner.inner.inner.receipt.status; + let status = tx.inner.inner.inner.receipt.status.coerce_status(); assert!(status); // transfer: impersonate real owner and transfer nft @@ -636,7 +642,7 @@ async fn test_fork_nft_set_approve_all() { .with_input(call.calldata().to_owned()); let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let status = tx.inner.inner.inner.receipt.status; + let status = tx.inner.inner.inner.receipt.status.coerce_status(); assert!(status); let real_owner = nouns.ownerOf(token_id).call().await.unwrap(); @@ -697,7 +703,7 @@ async fn test_fork_can_send_opensea_tx() { let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let status = tx.inner.inner.inner.receipt.status; + let status = tx.inner.inner.inner.receipt.status.coerce_status(); assert!(status); } @@ -725,7 +731,7 @@ async fn test_fork_init_base_fee() { let provider = handle.http_provider(); - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); // assert_eq!(block.header.number.unwrap(), 13184859u64); let init_base_fee = block.header.base_fee_per_gas.unwrap(); @@ -733,7 +739,7 @@ async fn test_fork_init_base_fee() { api.mine_one().await; - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); let next_base_fee = block.header.base_fee_per_gas.unwrap(); assert!(next_base_fee < init_base_fee); @@ -944,7 +950,7 @@ async fn can_impersonate_in_fork() { let res = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert_eq!(res.from, token_holder); - let status = res.inner.inner.inner.receipt.status; + let status = res.inner.inner.inner.receipt.status.coerce_status(); assert!(status); let balance = provider.get_balance(to).await.unwrap(); @@ -964,7 +970,7 @@ async fn test_total_difficulty_fork() { let difficulty = U256::from(13_680_435_288_526_144u128); let provider = handle.http_provider(); - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.total_difficulty, Some(total_difficulty)); assert_eq!(block.header.difficulty, difficulty); @@ -973,7 +979,7 @@ async fn test_total_difficulty_fork() { let next_total_difficulty = total_difficulty + difficulty; - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.total_difficulty, Some(next_total_difficulty)); assert_eq!(block.header.difficulty, U256::ZERO); } @@ -1065,7 +1071,7 @@ async fn test_fork_reset_moonbeam() { let tx = WithOtherFields::new(tx); api.anvil_impersonate_account(from).await.unwrap(); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let status = tx.inner.inner.inner.receipt.status; + let status = tx.inner.inner.inner.receipt.status.coerce_status(); assert!(status); // reset to check timestamp works after resetting @@ -1080,7 +1086,7 @@ async fn test_fork_reset_moonbeam() { TransactionRequest::default().to(Address::random()).value(U256::from(1337u64)).from(from); let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let status = tx.inner.inner.inner.receipt.status; + let status = tx.inner.inner.inner.receipt.status.coerce_status(); assert!(status); } diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index bca7102cbf6b9..f7ab590040977 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -27,7 +27,7 @@ async fn test_basefee_full_block() { provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); let base_fee = provider - .get_block(BlockId::latest(), false) + .get_block(BlockId::latest(), false.into()) .await .unwrap() .unwrap() @@ -38,7 +38,7 @@ async fn test_basefee_full_block() { provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); let next_base_fee = provider - .get_block(BlockId::latest(), false) + .get_block(BlockId::latest(), false.into()) .await .unwrap() .unwrap() @@ -77,7 +77,7 @@ async fn test_basefee_half_block() { provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); let next_base_fee = provider - .get_block(BlockId::latest(), false) + .get_block(BlockId::latest(), false.into()) .await .unwrap() .unwrap() @@ -104,7 +104,7 @@ async fn test_basefee_empty_block() { provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); let base_fee = provider - .get_block(BlockId::latest(), false) + .get_block(BlockId::latest(), false.into()) .await .unwrap() .unwrap() @@ -116,7 +116,7 @@ async fn test_basefee_empty_block() { api.mine_one().await; let next_base_fee = provider - .get_block(BlockId::latest(), false) + .get_block(BlockId::latest(), false.into()) .await .unwrap() .unwrap() diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index b06f7ce050459..38f7a61a18ee7 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -353,7 +353,7 @@ async fn test_trace_address_fork2() { api.anvil_impersonate_account(from).await.unwrap(); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - let status = tx.inner.inner.inner.receipt.status; + let status = tx.inner.inner.inner.receipt.status.coerce_status(); assert!(status); let traces = provider.trace_transaction(tx.transaction_hash).await.unwrap(); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index c80f7b2b32a9c..74c82133a754f 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -90,7 +90,7 @@ async fn can_order_transactions() { let lower_price = tx_lower.get_receipt().await.unwrap().transaction_hash; // get the block, await receipts - let block = provider.get_block(BlockId::latest(), false).await.unwrap().unwrap(); + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); assert_eq!(block.transactions, BlockTransactions::Hashes(vec![higher_price, lower_price])) } @@ -129,7 +129,7 @@ async fn can_respect_nonces() { // this will unblock the currently pending tx let higher_tx = higher_pending_tx.get_receipt().await.unwrap(); // Awaits endlessly here due to alloy/#389 - let block = provider.get_block(1.into(), false).await.unwrap().unwrap(); + let block = provider.get_block(1.into(), false.into()).await.unwrap().unwrap(); assert_eq!(2, block.transactions.len()); assert_eq!( BlockTransactions::Hashes(vec![tx.transaction_hash, higher_tx.transaction_hash]), @@ -170,7 +170,7 @@ async fn can_replace_transaction() { // mine exactly one block api.mine_one().await; - let block = provider.get_block(1.into(), false).await.unwrap().unwrap(); + let block = provider.get_block(1.into(), false.into()).await.unwrap().unwrap(); assert_eq!(block.transactions.len(), 1); assert_eq!(BlockTransactions::Hashes(vec![higher_tx_hash]), block.transactions); @@ -286,7 +286,7 @@ async fn can_reject_underpriced_replacement() { let higher_priced_receipt = higher_priced_pending_tx.get_receipt().await.unwrap(); // ensure that only the higher priced tx was mined - let block = provider.get_block(1.into(), false).await.unwrap().unwrap(); + let block = provider.get_block(1.into(), false.into()).await.unwrap().unwrap(); assert_eq!(1, block.transactions.len()); assert_eq!( BlockTransactions::Hashes(vec![higher_priced_receipt.transaction_hash]), @@ -552,7 +552,7 @@ async fn call_past_state() { assert_eq!(value._0, "initial value"); let hash = provider - .get_block(BlockId::Number(1.into()), false) + .get_block(BlockId::Number(1.into()), false.into()) .await .unwrap() .unwrap() diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 421bd6d4d7b48..ddcee1ba22b1d 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -39,7 +39,7 @@ alloy-primitives.workspace = true alloy-rlp.workspace = true alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } alloy-transport.workspace = true -alloy-rpc-types.workspace = true +alloy-rpc-types = { workspace = true, features = ["eth"] } alloy-json-rpc.workspace = true alloy-signer.workspace = true alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index d9ba45726e544..ccc70fd63a048 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -113,7 +113,7 @@ impl RunArgs { tx.block_number.ok_or_else(|| eyre::eyre!("tx may still be pending: {:?}", tx_hash))?; // fetch the block the transaction was mined in - let block = provider.get_block(tx_block_number.into(), true).await?; + let block = provider.get_block(tx_block_number.into(), true.into()).await?; // we need to fork off the parent block config.fork_block_number = Some(tx_block_number - 1); diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 51c43527330af..e17fd9d86e517 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -258,7 +258,7 @@ async fn main() -> Result<()> { let provider = utils::get_provider(&config)?; let number = match block { Some(id) => provider - .get_block(id, false) + .get_block(id, false.into()) .await? .ok_or_else(|| eyre::eyre!("block {id:?} not found"))? .header diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 2c48aa783abf9..002212fcd45bb 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -333,7 +333,7 @@ where let block = self .provider - .get_block(block, full) + .get_block(block, full.into()) .await? .ok_or_else(|| eyre::eyre!("block {:?} not found", block))?; @@ -855,7 +855,8 @@ where Some(block) => match block { BlockId::Number(block_number) => Ok(Some(block_number)), BlockId::Hash(hash) => { - let block = self.provider.get_block_by_hash(hash.block_hash, false).await?; + let block = + self.provider.get_block_by_hash(hash.block_hash, false.into()).await?; Ok(block.map(|block| block.header.number.unwrap()).map(BlockNumberOrTag::from)) } }, diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 1a48e80acd658..56f430c4ab32f 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -22,7 +22,7 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-rpc-types-engine.workspace = true -alloy-rpc-types.workspace = true +alloy-rpc-types = { workspace = true, features = ["eth"] } alloy-rpc-client.workspace = true alloy-provider.workspace = true alloy-transport.workspace = true diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index f2f647ae85949..63b2905a8f60d 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -209,7 +209,7 @@ blobGasUsed {}", serde_json::to_string(&logs).unwrap(), logs_bloom.pretty(), state_root.pretty(), - pretty_status(*status), + pretty_status(status.coerce_status()), transaction_hash.pretty(), transaction_index.pretty(), transaction_type, @@ -424,7 +424,7 @@ pub fn get_pretty_tx_receipt_attr( "logsBloom" | "logs_bloom" => Some(receipt.receipt.inner.inner.inner.logs_bloom.pretty()), "root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root.pretty()), "status" | "statusCode" | "status_code" => { - Some(pretty_status(receipt.receipt.inner.inner.inner.receipt.status)) + Some(pretty_status(receipt.receipt.inner.inner.inner.receipt.status.coerce_status())) } "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), "transactionIndex" | "transaction_index" => { diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs index b6adfb646be86..b7f3079bb0e12 100644 --- a/crates/common/src/provider/retry.rs +++ b/crates/common/src/provider/retry.rs @@ -30,24 +30,7 @@ impl RetryPolicy for RateLimitRetryPolicy { // The transport could not serialize the error itself. The request was malformed from // the start. TransportError::SerError(_) => false, - TransportError::DeserError { text, .. } => { - if let Ok(resp) = serde_json::from_str::(text) { - return should_retry_json_rpc_error(&resp) - } - - // some providers send invalid JSON RPC in the error case (no `id:u64`), but the - // text should be a `JsonRpcError` - #[derive(Deserialize)] - struct Resp { - error: ErrorPayload, - } - - if let Ok(resp) = serde_json::from_str::(text) { - return should_retry_json_rpc_error(&resp.error) - } - - false - } + TransportError::DeserError { text, .. } => should_retry_body(text), TransportError::ErrorResp(err) => should_retry_json_rpc_error(err), TransportError::NullResp => true, TransportError::UnsupportedFeature(_) => false, @@ -76,6 +59,26 @@ impl RetryPolicy for RateLimitRetryPolicy { } } +/// Tries to decode the error body as payload and check if it should be retried +fn should_retry_body(body: &str) -> bool { + if let Ok(resp) = serde_json::from_str::(body) { + return should_retry_json_rpc_error(&resp) + } + + // some providers send invalid JSON RPC in the error case (no `id:u64`), but the + // text should be a `JsonRpcError` + #[derive(Deserialize)] + struct Resp { + error: ErrorPayload, + } + + if let Ok(resp) = serde_json::from_str::(body) { + return should_retry_json_rpc_error(&resp.error) + } + + false +} + /// Analyzes the [TransportErrorKind] and decides if the request should be retried based on the /// variant. fn should_retry_transport_level_error(error: &TransportErrorKind) -> bool { @@ -88,8 +91,16 @@ fn should_retry_transport_level_error(error: &TransportErrorKind) -> bool { msg.contains("429 Too Many Requests") } + TransportErrorKind::HttpError(err) => { + if err.status == 429 { + return true + } + should_retry_body(&err.body) + } // If the backend is gone, or there's a completely custom error, we should assume it's not // retryable. + TransportErrorKind::PubsubUnavailable => false, + TransportErrorKind::BackendGone => false, _ => false, } } diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 98244ddb42038..50fcf7d992dfa 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -20,7 +20,7 @@ pub struct TransactionReceiptWithRevertReason { impl TransactionReceiptWithRevertReason { /// Returns if the status of the transaction is 0 (failure) pub fn is_failure(&self) -> bool { - !self.receipt.inner.inner.inner.receipt.status + !self.receipt.inner.inner.inner.receipt.status.coerce_status() } /// Updates the revert reason field using `eth_call` and returns an Err variant if the revert diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 4dda2a9942c0e..468be738d63eb 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -234,8 +234,10 @@ where fn request_full_block(&mut self, number: BlockId, sender: FullBlockSender) { let provider = self.provider.clone(); let fut = Box::pin(async move { - let block = - provider.get_block(number, true).await.wrap_err("could not fetch block {number:?}"); + let block = provider + .get_block(number, true.into()) + .await + .wrap_err("could not fetch block {number:?}"); (sender, block, number) }); diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 7189f8da44f0e..a080e2e0d3a0d 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -15,7 +15,7 @@ pub enum TxStatus { impl From for TxStatus { fn from(receipt: AnyTransactionReceipt) -> Self { - if !receipt.inner.inner.inner.receipt.status { + if !receipt.inner.inner.inner.receipt.status.coerce_status() { Self::Revert(receipt) } else { Self::Success(receipt) @@ -57,7 +57,7 @@ pub fn format_receipt(chain: Chain, receipt: &AnyTransactionReceipt) -> String { let gas_price = receipt.effective_gas_price; format!( "\n##### {chain}\n{status}Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n\n", - status = if !receipt.inner.inner.inner.receipt.status { + status = if !receipt.inner.inner.inner.receipt.status.coerce_status() { "❌ [Failed]" } else { "✅ [Success]" diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index ebe63adc58a3a..f6d2ea41941b5 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -286,7 +286,7 @@ impl VerifyBytecodeArgs { let mut executor = TracingExecutor::new(env.clone(), fork, Some(fork_config.evm_version), false); env.block.number = U256::from(simulation_block); - let block = provider.get_block(simulation_block.into(), true).await?; + let block = provider.get_block(simulation_block.into(), true.into()).await?; // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same // block. From c2b5b500b83c35b2384b098842b50e364319b4b8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 13 Jun 2024 01:28:14 +0200 Subject: [PATCH 1080/1963] perf: don't unnecessarily create CheatsConfig (#8143) --- crates/cheatcodes/src/inspector.rs | 51 +++++++++++++++++++++++++----- crates/cheatcodes/src/script.rs | 4 +-- crates/cheatcodes/src/utils.rs | 4 +-- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 968f2b4d77eb3..449ebdaae85a9 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -106,7 +106,7 @@ pub type BroadcastableTransactions = VecDeque; /// contract deployed on the live network is able to execute cheatcodes by simply calling the /// cheatcode address: by default, the caller, test contract and newly deployed contracts are /// allowed to execute cheatcodes -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct Cheatcodes { /// The block environment /// @@ -123,9 +123,6 @@ pub struct Cheatcodes { /// Address labels pub labels: HashMap, - /// Remembered private keys - pub script_wallets: Option, - /// Prank information pub prank: Option, @@ -210,13 +207,51 @@ pub struct Cheatcodes { pub breakpoints: Breakpoints, } +// This is not derived because calling this in `fn new` with `..Default::default()` creates a second +// `CheatsConfig` which is unused, and inside it `ProjectPathsConfig` is relatively expensive to +// create. +impl Default for Cheatcodes { + fn default() -> Self { + Self::new(Arc::default()) + } +} + impl Cheatcodes { /// Creates a new `Cheatcodes` with the given settings. - #[inline] pub fn new(config: Arc) -> Self { - let labels = config.labels.clone(); - let script_wallets = config.script_wallets.clone(); - Self { config, fs_commit: true, labels, script_wallets, ..Default::default() } + Self { + fs_commit: true, + labels: config.labels.clone(), + config, + block: Default::default(), + gas_price: Default::default(), + prank: Default::default(), + expected_revert: Default::default(), + fork_revert_diagnostic: Default::default(), + accesses: Default::default(), + recorded_account_diffs_stack: Default::default(), + recorded_logs: Default::default(), + last_call_gas: Default::default(), + mocked_calls: Default::default(), + expected_calls: Default::default(), + expected_emits: Default::default(), + allowed_mem_writes: Default::default(), + broadcast: Default::default(), + broadcastable_transactions: Default::default(), + context: Default::default(), + serialized_jsons: Default::default(), + eth_deals: Default::default(), + gas_metering: Default::default(), + gas_metering_create: Default::default(), + mapping_slots: Default::default(), + pc: Default::default(), + breakpoints: Default::default(), + } + } + + /// Returns the configured script wallets. + pub fn script_wallets(&self) -> Option<&ScriptWallets> { + self.config.script_wallets.as_ref() } fn apply_cheatcode( diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index c9195f4492ebd..97c65106a1605 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -137,7 +137,7 @@ fn broadcast( let mut new_origin = new_origin.cloned(); if new_origin.is_none() { - if let Some(script_wallets) = &ccx.state.script_wallets { + if let Some(script_wallets) = ccx.state.script_wallets() { let mut script_wallets = script_wallets.inner.lock(); if let Some(provided_sender) = script_wallets.provided_sender { new_origin = Some(provided_sender); @@ -176,7 +176,7 @@ fn broadcast_key( let result = broadcast(ccx, Some(&new_origin), single_call); if result.is_ok() { - if let Some(script_wallets) = &ccx.state.script_wallets { + if let Some(script_wallets) = ccx.state.script_wallets() { script_wallets.add_local_signer(wallet); } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 4785e0197b2d9..f4f3ab48583ca 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -92,7 +92,7 @@ impl Cheatcode for rememberKeyCall { let Self { privateKey } = self; let wallet = parse_wallet(privateKey)?; let address = wallet.address(); - if let Some(script_wallets) = &ccx.state.script_wallets { + if let Some(script_wallets) = ccx.state.script_wallets() { script_wallets.add_local_signer(wallet); } Ok(address.abi_encode()) @@ -214,7 +214,7 @@ pub(super) fn sign_with_wallet( signer: Option
, digest: &B256, ) -> Result { - let Some(script_wallets) = &ccx.state.script_wallets else { + let Some(script_wallets) = ccx.state.script_wallets() else { bail!("no wallets are available"); }; From 88011569efcebc9152267be217c8cfbedc32c07c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 13 Jun 2024 01:28:42 +0200 Subject: [PATCH 1081/1963] chore: improve test timings and cleanup (#8144) --- crates/forge/bin/cmd/snapshot.rs | 4 +- crates/forge/src/multi_runner.rs | 8 ++-- crates/forge/src/result.rs | 34 ++++++++-------- crates/forge/src/runner.rs | 68 ++++++++++++-------------------- 4 files changed, 47 insertions(+), 67 deletions(-) diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 8cb5fbb062c84..d35c1cdcb0ad7 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -214,7 +214,7 @@ impl FromStr for SnapshotEntry { Some(Self { contract_name: file.as_str().to_string(), signature: sig.as_str().to_string(), - gas_used: TestKindReport::Standard { + gas_used: TestKindReport::Unit { gas: gas.as_str().parse().unwrap(), }, }) @@ -455,7 +455,7 @@ mod tests { SnapshotEntry { contract_name: "Test".to_string(), signature: "deposit()".to_string(), - gas_used: TestKindReport::Standard { gas: 7222 } + gas_used: TestKindReport::Unit { gas: 7222 } } ); } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 1c1206fa06a47..270a25202a8e5 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -184,7 +184,7 @@ impl MultiContractRunner { let _guard = handle.enter(); tests_progress.inner.lock().start_suite_progress(&id.identifier()); - let result = self.run_tests( + let result = self.run_test_suite( id, contract, db.clone(), @@ -210,13 +210,13 @@ impl MultiContractRunner { } else { contracts.par_iter().for_each(|&(id, contract)| { let _guard = handle.enter(); - let result = self.run_tests(id, contract, db.clone(), filter, &handle, None); + let result = self.run_test_suite(id, contract, db.clone(), filter, &handle, None); let _ = tx.send((id.identifier(), result)); }) } } - fn run_tests( + fn run_test_suite( &self, artifact_id: &ArtifactId, contract: &TestContract, @@ -252,7 +252,7 @@ impl MultiContractRunner { if !enabled!(tracing::Level::TRACE) { span_name = get_contract_name(&identifier); } - let _guard = debug_span!("run_suite", name = span_name).entered(); + let _guard = debug_span!("suite", name = span_name).entered(); debug!("start executing all tests in contract"); diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 9b4a926aaa79b..84c5cdea8893c 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -434,15 +434,15 @@ impl TestResult { /// Data report by a test. #[derive(Clone, Debug, PartialEq, Eq)] pub enum TestKindReport { - Standard { gas: u64 }, + Unit { gas: u64 }, Fuzz { runs: usize, mean_gas: u64, median_gas: u64 }, Invariant { runs: usize, calls: usize, reverts: usize }, } impl fmt::Display for TestKindReport { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Standard { gas } => { + match *self { + Self::Unit { gas } => { write!(f, "(gas: {gas})") } Self::Fuzz { runs, mean_gas, median_gas } => { @@ -458,10 +458,10 @@ impl fmt::Display for TestKindReport { impl TestKindReport { /// Returns the main gas value to compare against pub fn gas(&self) -> u64 { - match self { - Self::Standard { gas } => *gas, + match *self { + Self::Unit { gas } => gas, // We use the median for comparisons - Self::Fuzz { median_gas, .. } => *median_gas, + Self::Fuzz { median_gas, .. } => median_gas, // We return 0 since it's not applicable Self::Invariant { .. } => 0, } @@ -471,11 +471,9 @@ impl TestKindReport { /// Various types of tests #[derive(Clone, Debug, Serialize, Deserialize)] pub enum TestKind { - /// A standard test that consists of calling the defined solidity function - /// - /// Holds the consumed gas - Standard(u64), - /// A solidity fuzz test, that stores all test cases + /// A unit test. + Unit { gas: u64 }, + /// A fuzz test. Fuzz { /// we keep this for the debugger first_case: FuzzCase, @@ -483,26 +481,26 @@ pub enum TestKind { mean_gas: u64, median_gas: u64, }, - /// A solidity invariant test, that stores all test cases + /// An invariant test. Invariant { runs: usize, calls: usize, reverts: usize }, } impl Default for TestKind { fn default() -> Self { - Self::Standard(0) + Self::Unit { gas: 0 } } } impl TestKind { /// The gas consumed by this test pub fn report(&self) -> TestKindReport { - match self { - Self::Standard(gas) => TestKindReport::Standard { gas: *gas }, - Self::Fuzz { runs, mean_gas, median_gas, .. } => { - TestKindReport::Fuzz { runs: *runs, mean_gas: *mean_gas, median_gas: *median_gas } + match *self { + Self::Unit { gas } => TestKindReport::Unit { gas }, + Self::Fuzz { first_case: _, runs, mean_gas, median_gas } => { + TestKindReport::Fuzz { runs, mean_gas, median_gas } } Self::Invariant { runs, calls, reverts } => { - TestKindReport::Invariant { runs: *runs, calls: *calls, reverts: *reverts } + TestKindReport::Invariant { runs, calls, reverts } } } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 46a6cad6829ee..51d904376d590 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -103,15 +103,15 @@ impl<'a> ContractRunner<'a> { impl<'a> ContractRunner<'a> { /// Deploys the test contract inside the runner from the sending account, and optionally runs /// the `setUp` function on the test contract. - pub fn setup(&mut self, setup: bool) -> TestSetup { - match self._setup(setup) { + pub fn setup(&mut self, call_setup: bool) -> TestSetup { + match self._setup(call_setup) { Ok(setup) => setup, Err(err) => TestSetup::failed(err.to_string()), } } - fn _setup(&mut self, setup: bool) -> Result { - trace!(?setup, "Setting test contract"); + fn _setup(&mut self, call_setup: bool) -> Result { + trace!(call_setup, "setting up"); // We max out their balance so that they can deploy and make calls. self.executor.set_balance(self.sender, U256::MAX)?; @@ -173,12 +173,12 @@ impl<'a> ContractRunner<'a> { self.executor.deploy_create2_deployer()?; // Optionally call the `setUp` function - let setup = if setup { - trace!("setting up"); + let result = if call_setup { + trace!("calling setUp"); let res = self.executor.setup(None, address, Some(self.revert_decoder)); let (setup_logs, setup_traces, labeled_addresses, reason, coverage) = match res { Ok(RawCallResult { traces, labels, logs, coverage, .. }) => { - trace!(contract=%address, "successfully setUp test"); + trace!(%address, "successfully called setUp"); (logs, traces, labels, None, coverage) } Err(EvmError::Execution(err)) => { @@ -215,7 +215,7 @@ impl<'a> ContractRunner<'a> { ) }; - Ok(setup) + Ok(result) } /// Collect fixtures from test contract. @@ -235,7 +235,8 @@ impl<'a> ContractRunner<'a> { /// current test. fn fuzz_fixtures(&mut self, address: Address) -> FuzzFixtures { let mut fixtures = HashMap::new(); - self.contract.abi.functions().filter(|func| func.is_fixture()).for_each(|func| { + let fixture_functions = self.contract.abi.functions().filter(|func| func.is_fixture()); + for func in fixture_functions { if func.inputs.is_empty() { // Read fixtures declared as functions. if let Ok(CallResult { raw: _, decoded_result }) = @@ -267,8 +268,7 @@ impl<'a> ContractRunner<'a> { } fixtures.insert(fixture_name(func.name.clone()), DynSolValue::Array(vals)); }; - }); - + } FuzzFixtures::new(fixtures) } @@ -287,7 +287,8 @@ impl<'a> ContractRunner<'a> { let setup_fns: Vec<_> = self.contract.abi.functions().filter(|func| func.name.is_setup()).collect(); - let needs_setup = setup_fns.len() == 1 && setup_fns[0].name == "setUp"; + // Whether to call the `setUp` function. + let call_setup = setup_fns.len() == 1 && setup_fns[0].name == "setUp"; // There is a single miss-cased `setUp` function, so we add a warning for &setup_fn in setup_fns.iter() { @@ -312,11 +313,13 @@ impl<'a> ContractRunner<'a> { let has_invariants = self.contract.abi.functions().any(|func| func.is_invariant_test()); // Invariant testing requires tracing to figure out what contracts were created. - let tmp_tracing = self.executor.inspector.tracer.is_none() && has_invariants && needs_setup; + let tmp_tracing = self.executor.inspector.tracer.is_none() && has_invariants && call_setup; if tmp_tracing { self.executor.set_tracing(true); } - let setup = self.setup(needs_setup); + let setup_time = Instant::now(); + let setup = self.setup(call_setup); + debug!("finished setting up in {:?}", setup_time.elapsed()); if tmp_tracing { self.executor.set_tracing(false); } @@ -330,10 +333,8 @@ impl<'a> ContractRunner<'a> { TestResult { status: TestStatus::Failure, reason: setup.reason, - counterexample: None, decoded_logs: decode_console_logs(&setup.logs), logs: setup.logs, - kind: TestKind::Standard(0), traces: setup.traces, coverage: setup.coverage, labeled_addresses: setup.labeled_addresses, @@ -367,6 +368,8 @@ impl<'a> ContractRunner<'a> { let test_results = functions .par_iter() .map(|&func| { + let start = Instant::now(); + let _guard = handle.enter(); let sig = func.signature(); @@ -381,7 +384,7 @@ impl<'a> ContractRunner<'a> { let setup = setup.clone(); let should_fail = func.is_test_fail(); - let res = if func.is_invariant_test() { + let mut res = if func.is_invariant_test() { let runner = test_options.invariant_runner(self.name, &func.name); let invariant_config = test_options.invariant_config(self.name, &func.name); @@ -404,6 +407,8 @@ impl<'a> ContractRunner<'a> { self.run_test(func, should_fail, setup) }; + res.duration = start.elapsed(); + (sig, res) }) .collect::>(); @@ -433,7 +438,6 @@ impl<'a> ContractRunner<'a> { // Run unit test let mut executor = self.executor.clone(); - let start: Instant = Instant::now(); let (raw_call_result, reason) = match executor.execute_test( self.sender, address, @@ -451,8 +455,6 @@ impl<'a> ContractRunner<'a> { decoded_logs: decode_console_logs(&logs), traces, labeled_addresses, - kind: TestKind::Standard(0), - duration: start.elapsed(), ..Default::default() } } @@ -463,8 +465,6 @@ impl<'a> ContractRunner<'a> { decoded_logs: decode_console_logs(&logs), traces, labeled_addresses, - kind: TestKind::Standard(0), - duration: start.elapsed(), ..Default::default() } } @@ -498,10 +498,6 @@ impl<'a> ContractRunner<'a> { should_fail, ); - // Record test execution time - let duration = start.elapsed(); - trace!(?duration, gas, reverted, should_fail, success); - TestResult { status: match success { true => TestStatus::Success, @@ -511,13 +507,13 @@ impl<'a> ContractRunner<'a> { counterexample: None, decoded_logs: decode_console_logs(&logs), logs, - kind: TestKind::Standard(gas.overflowing_sub(stipend).0), + kind: TestKind::Unit { gas: gas.wrapping_sub(stipend) }, traces, coverage, labeled_addresses, debug: debug_arena, breakpoints, - duration, + duration: std::time::Duration::default(), gas_report_traces: Vec::new(), } } @@ -532,12 +528,10 @@ impl<'a> ContractRunner<'a> { known_contracts: &ContractsByArtifact, identified_contracts: &ContractsByAddress, ) -> TestResult { - trace!(target: "forge::test::fuzz", "executing invariant test for {:?}", func.name); let TestSetup { address, logs, traces, labeled_addresses, coverage, fuzz_fixtures, .. } = setup; // First, run the test normally to see if it needs to be skipped. - let start = Instant::now(); if let Err(EvmError::SkipError) = self.executor.clone().execute_test( self.sender, address, @@ -554,7 +548,6 @@ impl<'a> ContractRunner<'a> { labeled_addresses, kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, coverage, - duration: start.elapsed(), ..Default::default() } }; @@ -631,7 +624,6 @@ impl<'a> ContractRunner<'a> { coverage, counterexample: Some(CounterExample::Sequence(call_sequence)), kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, - duration: start.elapsed(), ..Default::default() } } @@ -654,7 +646,6 @@ impl<'a> ContractRunner<'a> { traces, labeled_addresses, kind: TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }, - duration: start.elapsed(), ..Default::default() } } @@ -739,7 +730,6 @@ impl<'a> ContractRunner<'a> { coverage, traces, labeled_addresses: labeled_addresses.clone(), - duration: start.elapsed(), gas_report_traces, ..Default::default() // TODO collect debug traces on the last run or error } @@ -766,7 +756,6 @@ impl<'a> ContractRunner<'a> { // Run fuzz test let progress = start_fuzz_progress(self.progress, self.name, &func.name, fuzz_config.runs); - let start = Instant::now(); let fuzzed_executor = FuzzedExecutor::new( self.executor.clone(), runner.clone(), @@ -790,15 +779,12 @@ impl<'a> ContractRunner<'a> { if let Some("SKIPPED") = result.reason.as_deref() { return TestResult { status: TestStatus::Skipped, - reason: None, decoded_logs: decode_console_logs(&logs), traces, labeled_addresses, - kind: TestKind::Standard(0), debug, breakpoints, coverage, - duration: start.elapsed(), ..Default::default() } } @@ -853,10 +839,6 @@ impl<'a> ContractRunner<'a> { traces.extend(result.traces.map(|traces| (TraceKind::Execution, traces))); coverage = merge_coverages(coverage, result.coverage); - // Record test execution time - let duration = start.elapsed(); - trace!(?duration, success = %result.success); - TestResult { status: match result.success { true => TestStatus::Success, @@ -872,7 +854,7 @@ impl<'a> ContractRunner<'a> { labeled_addresses, debug, breakpoints, - duration, + duration: std::time::Duration::default(), gas_report_traces: result.gas_report_traces.into_iter().map(|t| vec![t]).collect(), } } From 8e9cb1daf164a526c33d4c72de7a6325fc40bbf7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 13 Jun 2024 03:46:58 +0200 Subject: [PATCH 1082/1963] chore(evm): clean up executor methods some more (#8104) * chore(evm): clean up executor methods some more * fix: rename _committing to transact_, further clarify the separation * chore: simplify is_success further * chore: don't clone executor in unit tests --- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/run.rs | 4 +- crates/chisel/src/runner.rs | 2 +- crates/evm/evm/src/executors/fuzz/mod.rs | 11 +- crates/evm/evm/src/executors/invariant/mod.rs | 10 +- .../evm/evm/src/executors/invariant/replay.rs | 2 +- .../evm/evm/src/executors/invariant/result.rs | 10 +- .../evm/evm/src/executors/invariant/shrink.rs | 15 +- crates/evm/evm/src/executors/mod.rs | 350 +++++++++--------- crates/forge/src/runner.rs | 18 +- crates/script/src/runner.rs | 4 +- crates/verify/src/bytecode.rs | 6 +- 12 files changed, 196 insertions(+), 238 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index afd6108c679fb..5f4975fcc79ac 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -170,7 +170,7 @@ impl CallArgs { TraceResult::try_from(deploy_result)? } TxKind::Call(to) => TraceResult::from_raw( - executor.call_raw_committing(sender, to, input, value)?, + executor.transact_raw(sender, to, input, value)?, TraceKind::Execution, ), }; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index ccc70fd63a048..451964045fd54 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -176,7 +176,7 @@ impl RunArgs { if let Some(to) = tx.to { trace!(tx=?tx.hash,?to, "executing previous call transaction"); - executor.commit_tx_with_env(env.clone()).wrap_err_with(|| { + executor.transact_with_env(env.clone()).wrap_err_with(|| { format!( "Failed to execute transaction: {:?} in block {}", tx.hash, env.block.number @@ -213,7 +213,7 @@ impl RunArgs { if let Some(to) = tx.to { trace!(tx=?tx.hash, to=?to, "executing call transaction"); - TraceResult::from_raw(executor.commit_tx_with_env(env)?, TraceKind::Execution) + TraceResult::from_raw(executor.transact_with_env(env)?, TraceKind::Execution) } else { trace!(tx=?tx.hash, "executing create transaction"); TraceResult::try_from(executor.deploy_with_env(env, None))? diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 6ffcb6770be45..ff4c9695e6524 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -189,7 +189,7 @@ impl ChiselRunner { if commit { // if explicitly requested we can now commit the call - res = self.executor.call_raw_committing(from, to, calldata, value)?; + res = self.executor.transact_raw(from, to, calldata, value)?; } let RawCallResult { result, reverted, logs, traces, labels, chisel_state, .. } = res; diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 6cd411f190334..b578a65f3bb26 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -16,7 +16,7 @@ use foundry_evm_fuzz::{ use foundry_evm_traces::CallTraceArena; use indicatif::ProgressBar; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; -use std::{borrow::Cow, cell::RefCell}; +use std::cell::RefCell; mod types; pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; @@ -202,7 +202,6 @@ impl FuzzedExecutor { .executor .call_raw(self.sender, address, calldata.clone(), U256::ZERO) .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; - let state_changeset = call.state_changeset.take().unwrap(); // When the `assume` cheatcode is called it returns a special string if call.result.as_ref() == MAGIC_ASSUME { @@ -214,13 +213,7 @@ impl FuzzedExecutor { .as_ref() .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); - let success = self.executor.is_raw_call_success( - address, - Cow::Owned(state_changeset), - &call, - should_fail, - ); - + let success = self.executor.is_raw_call_mut_success(address, &mut call, should_fail); if success { Ok(FuzzOutcome::Case(CaseOutcome { case: FuzzCase { calldata, gas: call.gas_used, stipend: call.stipend }, diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 6ca49545cd9d8..11291f1737f3c 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -155,7 +155,7 @@ impl<'a> InvariantExecutor<'a> { let failures = RefCell::new(InvariantFailures::new()); // Stores the calldata in the last run. - let last_run_calldata: RefCell> = RefCell::new(vec![]); + let last_run_inputs: RefCell> = RefCell::new(vec![]); // Stores additional traces for gas report. let gas_report_traces: RefCell>> = RefCell::default(); @@ -212,7 +212,7 @@ impl<'a> InvariantExecutor<'a> { // Execute call from the randomly generated sequence and commit state changes. let call_result = executor - .call_raw_committing( + .transact_raw( tx.sender, tx.call_details.target, tx.call_details.calldata.clone(), @@ -233,7 +233,7 @@ impl<'a> InvariantExecutor<'a> { } } else { // Collect data for fuzzing from the state changeset. - let mut state_changeset = call_result.state_changeset.to_owned().unwrap(); + let mut state_changeset = call_result.state_changeset.clone().unwrap(); if !call_result.reverted { collect_data( @@ -281,7 +281,7 @@ impl<'a> InvariantExecutor<'a> { .map_err(|e| TestCaseError::fail(e.to_string()))?; if !result.can_continue || current_run == self.config.depth - 1 { - last_run_calldata.borrow_mut().clone_from(&inputs); + last_run_inputs.borrow_mut().clone_from(&inputs); } if !result.can_continue { @@ -335,7 +335,7 @@ impl<'a> InvariantExecutor<'a> { error, cases: fuzz_cases.into_inner(), reverts, - last_run_inputs: last_run_calldata.take(), + last_run_inputs: last_run_inputs.into_inner(), gas_report_traces: gas_report_traces.into_inner(), }) } diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 466ae0cf1ef77..c21c26030588d 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -37,7 +37,7 @@ pub fn replay_run( // Replay each call from the sequence, collect logs, traces and coverage. for tx in inputs.iter() { - let call_result = executor.call_raw_committing( + let call_result = executor.transact_raw( tx.sender, tx.call_details.target, tx.call_details.calldata.clone(), diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index 2d08efb12d22b..9b3103b3d2fe0 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -68,12 +68,8 @@ pub(crate) fn assert_invariants( U256::ZERO, )?; - let success = executor.is_raw_call_success( - invariant_contract.address, - Cow::Owned(call_result.state_changeset.take().unwrap()), - &call_result, - false, - ); + let success = + executor.is_raw_call_mut_success(invariant_contract.address, &mut call_result, false); if !success { // We only care about invariants which we haven't broken yet. if invariant_failures.error.is_none() { @@ -111,7 +107,7 @@ pub(crate) fn can_continue( let mut call_results = None; let handlers_succeeded = || { - targeted_contracts.targets.lock().iter().all(|(address, ..)| { + targeted_contracts.targets.lock().keys().all(|address| { executor.is_success(*address, false, Cow::Borrowed(state_changeset), false) }) }; diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index d61a84592b84e..169955551bea1 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -4,7 +4,7 @@ use foundry_evm_core::constants::CALLER; use foundry_evm_fuzz::invariant::BasicTxDetails; use indicatif::ProgressBar; use proptest::bits::{BitSetLike, VarBitSet}; -use std::{borrow::Cow, cmp::min}; +use std::cmp::min; #[derive(Clone, Copy, Debug)] struct Shrink { @@ -145,7 +145,7 @@ pub fn check_sequence( // Apply the call sequence. for call_index in sequence { let tx = &calls[call_index]; - let call_result = executor.call_raw_committing( + let call_result = executor.transact_raw( tx.sender, tx.call_details.target, tx.call_details.calldata.clone(), @@ -160,13 +160,6 @@ pub fn check_sequence( // Check the invariant for call sequence. let mut call_result = executor.call_raw(CALLER, test_address, calldata, U256::ZERO)?; - Ok(( - executor.is_raw_call_success( - test_address, - Cow::Owned(call_result.state_changeset.take().unwrap()), - &call_result, - false, - ), - true, - )) + let success = executor.is_raw_call_mut_success(test_address, &mut call_result, false); + Ok((success, true)) } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index ceb269a5391b8..58057c93f6751 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -54,14 +54,17 @@ sol! { } } -/// A type that can execute calls +/// EVM executor. /// /// The executor can be configured with various `revm::Inspector`s, like `Cheatcodes`. /// -/// There are two ways of executing calls: -/// - `committing`: any state changes made during the call are recorded and are persisting -/// - `raw`: state changes only exist for the duration of the call and are discarded afterwards, in -/// other words: the state of the underlying database remains unchanged. +/// There are multiple ways of interacting the EVM: +/// - `call`: executes a transaction, but does not persist any state changes; similar to `eth_call`, +/// where the EVM state is unchanged after the call. +/// - `transact`: executes a transaction and persists the state changes +/// - `deploy`: a special case of `transact`, specialized for persisting the state of a contract +/// deployment +/// - `setup`: a special case of `transact`, used to set up the environment for a test #[derive(Clone, Debug)] pub struct Executor { /// The underlying `revm::Database` that contains the EVM storage. @@ -81,6 +84,7 @@ pub struct Executor { } impl Executor { + /// Creates a new `Executor` with the given arguments. #[inline] pub fn new( mut backend: Backend, @@ -104,7 +108,7 @@ impl Executor { Self { backend, env, inspector, gas_limit } } - /// Returns the spec id of the executor + /// Returns the spec ID of the executor. pub fn spec_id(&self) -> SpecId { self.env.handler_cfg.spec_id } @@ -153,17 +157,16 @@ impl Executor { pub fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<&mut Self> { let mut account = self.backend.basic_ref(address)?.unwrap_or_default(); account.nonce = nonce; - self.backend.insert_account_info(address, account); Ok(self) } - /// Gets the nonce of an account + /// Returns the nonce of an account. pub fn get_nonce(&self, address: Address) -> DatabaseResult { Ok(self.backend.basic_ref(address)?.map(|acc| acc.nonce).unwrap_or_default()) } - /// Returns true if account has no code. + /// Returns `true` if the account has no code. pub fn is_empty_code(&self, address: Address) -> DatabaseResult { Ok(self.backend.basic_ref(address)?.map(|acc| acc.is_empty_code_hash()).unwrap_or(true)) } @@ -192,6 +195,54 @@ impl Executor { self } + /// Deploys a contract and commits the new state to the underlying database. + /// + /// Executes a CREATE transaction with the contract `code` and persistent database state + /// modifications. + pub fn deploy( + &mut self, + from: Address, + code: Bytes, + value: U256, + rd: Option<&RevertDecoder>, + ) -> Result { + let env = self.build_test_env(from, TransactTo::Create, code, value); + self.deploy_with_env(env, rd) + } + + /// Deploys a contract using the given `env` and commits the new state to the underlying + /// database. + /// + /// # Panics + /// + /// Panics if `env.tx.transact_to` is not `TransactTo::Create(_)`. + pub fn deploy_with_env( + &mut self, + env: EnvWithHandlerCfg, + rd: Option<&RevertDecoder>, + ) -> Result { + assert!( + matches!(env.tx.transact_to, TransactTo::Create), + "Expected create transaction, got {:?}", + env.tx.transact_to + ); + trace!(sender=%env.tx.caller, "deploying contract"); + + let mut result = self.transact_with_env(env)?; + result = result.into_result(rd)?; + let Some(Output::Create(_, Some(address))) = result.out else { + panic!("Deployment succeeded, but no address was returned: {result:#?}"); + }; + + // also mark this library as persistent, this will ensure that the state of the library is + // persistent across fork swaps in forking mode + self.backend.add_persistent_account(address); + + debug!(%address, "deployed contract"); + + Ok(DeployResult { raw: result, address }) + } + /// Calls the `setUp()` function on a contract. /// /// This will commit any state changes to the underlying database. @@ -209,7 +260,7 @@ impl Executor { let from = from.unwrap_or(CALLER); self.backend.set_test_contract(to).set_caller(from); let calldata = Bytes::from_static(&ITest::setUpCall::SELECTOR); - let mut res = self.call_raw_committing(from, to, calldata, U256::ZERO)?; + let mut res = self.transact_raw(from, to, calldata, U256::ZERO)?; res = res.into_result(rd)?; // record any changes made to the block's environment during setup @@ -217,10 +268,8 @@ impl Executor { // and also the chainid, which can be set manually self.env.cfg.chain_id = res.env.cfg.chain_id; - if let Some(changeset) = res.state_changeset.as_ref() { - let success = self - .ensure_success(to, res.reverted, Cow::Borrowed(changeset), false) - .map_err(|err| EvmError::Eyre(eyre::eyre!(err)))?; + if let Some(changeset) = &res.state_changeset { + let success = self.is_raw_call_success(to, Cow::Borrowed(changeset), &res, false); if !success { return Err(res.into_execution_error("execution error".to_string()).into()); } @@ -230,10 +279,8 @@ impl Executor { } /// Performs a call to an account on the current state of the VM. - /// - /// The state after the call is persisted. - pub fn call_committing( - &mut self, + pub fn call( + &self, from: Address, to: Address, func: &Function, @@ -242,49 +289,28 @@ impl Executor { rd: Option<&RevertDecoder>, ) -> Result { let calldata = Bytes::from(func.abi_encode_input(args)?); - let result = self.call_raw_committing(from, to, calldata, value)?; + let result = self.call_raw(from, to, calldata, value)?; result.into_decoded_result(func, rd) } - /// Performs a raw call to an account on the current state of the VM. - /// - /// The state after the call is persisted. - pub fn call_raw_committing( - &mut self, + /// Performs a call to an account on the current state of the VM. + pub fn call_sol( + &self, from: Address, to: Address, - calldata: Bytes, - value: U256, - ) -> eyre::Result { - let env = self.build_test_env(from, TransactTo::Call(to), calldata, value); - let mut result = self.call_raw_with_env(env)?; - self.commit(&mut result); - Ok(result) - } - - /// Executes the test function call - pub fn execute_test( - &mut self, - from: Address, - test_contract: Address, - func: &Function, - args: &[DynSolValue], + args: &C, value: U256, rd: Option<&RevertDecoder>, - ) -> Result { - let calldata = Bytes::from(func.abi_encode_input(args)?); - - // execute the call - let env = self.build_test_env(from, TransactTo::Call(test_contract), calldata, value); - let result = self.call_raw_with_env(env)?; - result.into_decoded_result(func, rd) + ) -> Result, EvmError> { + let calldata = Bytes::from(args.abi_encode()); + let mut raw = self.call_raw(from, to, calldata, value)?; + raw = raw.into_result(rd)?; + Ok(CallResult { decoded_result: C::abi_decode_returns(&raw.result, false)?, raw }) } /// Performs a call to an account on the current state of the VM. - /// - /// The state after the call is not persisted. - pub fn call( - &self, + pub fn transact( + &mut self, from: Address, to: Address, func: &Function, @@ -293,69 +319,59 @@ impl Executor { rd: Option<&RevertDecoder>, ) -> Result { let calldata = Bytes::from(func.abi_encode_input(args)?); - let result = self.call_raw(from, to, calldata, value)?; + let result = self.transact_raw(from, to, calldata, value)?; result.into_decoded_result(func, rd) } - /// Performs a call to an account on the current state of the VM. - /// - /// The state after the call is not persisted. - pub fn call_sol( + /// Performs a raw call to an account on the current state of the VM. + pub fn call_raw( &self, from: Address, to: Address, - args: &C, + calldata: Bytes, value: U256, - rd: Option<&RevertDecoder>, - ) -> Result, EvmError> { - let calldata = Bytes::from(args.abi_encode()); - let mut raw = self.call_raw(from, to, calldata, value)?; - raw = raw.into_result(rd)?; - Ok(CallResult { decoded_result: C::abi_decode_returns(&raw.result, false)?, raw }) + ) -> eyre::Result { + let env = self.build_test_env(from, TransactTo::Call(to), calldata, value); + self.call_with_env(env) } /// Performs a raw call to an account on the current state of the VM. - /// - /// Any state modifications made by the call are not committed. - /// - /// This intended for fuzz calls, which try to minimize [Backend] clones by using a Cow of the - /// underlying [Backend] so it only gets cloned when cheatcodes that require mutable access are - /// used. - pub fn call_raw( - &self, + pub fn transact_raw( + &mut self, from: Address, to: Address, calldata: Bytes, value: U256, ) -> eyre::Result { - let mut inspector = self.inspector.clone(); - // Build VM - let mut env = self.build_test_env(from, TransactTo::Call(to), calldata, value); - let mut db = CowBackend::new(&self.backend); - let result = db.inspect(&mut env, &mut inspector)?; - - // Persist the snapshot failure recorded on the fuzz backend wrapper. - let has_snapshot_failure = db.has_snapshot_failure(); - convert_executed_result(env, inspector, result, has_snapshot_failure) + let env = self.build_test_env(from, TransactTo::Call(to), calldata, value); + self.transact_with_env(env) } - /// Execute the transaction configured in `env.tx` and commit the changes - pub fn commit_tx_with_env(&mut self, env: EnvWithHandlerCfg) -> eyre::Result { - let mut result = self.call_raw_with_env(env)?; - self.commit(&mut result); - Ok(result) + /// Execute the transaction configured in `env.tx`. + /// + /// The state after the call is **not** persisted. + pub fn call_with_env(&self, mut env: EnvWithHandlerCfg) -> eyre::Result { + let mut inspector = self.inspector.clone(); + let mut backend = CowBackend::new(&self.backend); + let result = backend.inspect(&mut env, &mut inspector)?; + convert_executed_result(env, inspector, result, backend.has_snapshot_failure()) } - /// Execute the transaction configured in `env.tx` - pub fn call_raw_with_env(&mut self, mut env: EnvWithHandlerCfg) -> eyre::Result { - // execute the call + /// Execute the transaction configured in `env.tx`. + pub fn transact_with_env(&mut self, mut env: EnvWithHandlerCfg) -> eyre::Result { let mut inspector = self.inspector.clone(); - let result = self.backend.inspect(&mut env, &mut inspector)?; - convert_executed_result(env, inspector, result, self.backend.has_snapshot_failure()) + let backend = &mut self.backend; + let result = backend.inspect(&mut env, &mut inspector)?; + let mut result = + convert_executed_result(env, inspector, result, backend.has_snapshot_failure())?; + self.commit(&mut result); + Ok(result) } - /// Commit the changeset to the database and adjust `self.inspector_config` - /// values according to the executed call result + /// Commit the changeset to the database and adjust `self.inspector_config` values according to + /// the executed call result. + /// + /// This should not be exposed to the user, as it should be called only by `transact*`. fn commit(&mut self, result: &mut RawCallResult) { // Persist changes to db. if let Some(changes) = &result.state_changeset { @@ -363,8 +379,8 @@ impl Executor { } // Persist cheatcode state. - let mut cheatcodes = result.cheatcodes.take(); - if let Some(cheats) = cheatcodes.as_mut() { + self.inspector.cheatcodes = result.cheatcodes.take(); + if let Some(cheats) = self.inspector.cheatcodes.as_mut() { // Clear broadcastable transactions cheats.broadcastable_transactions.clear(); debug!(target: "evm::executors", "cleared broadcastable transactions"); @@ -372,59 +388,55 @@ impl Executor { // corrected_nonce value is needed outside of this context (setUp), so we don't // reset it. } - self.inspector.cheatcodes = cheatcodes; // Persist the changed environment. self.inspector.set_env(&result.env); } - /// Deploys a contract using the given `env` and commits the new state to the underlying - /// database. + /// Checks if a call to a test contract was successful. /// - /// # Panics - /// - /// Panics if `env.tx.transact_to` is not `TransactTo::Create(_)`. - pub fn deploy_with_env( - &mut self, - env: EnvWithHandlerCfg, - rd: Option<&RevertDecoder>, - ) -> Result { - assert!( - matches!(env.tx.transact_to, TransactTo::Create), - "Expected create transaction, got {:?}", - env.tx.transact_to - ); - trace!(sender=%env.tx.caller, "deploying contract"); - - let mut result = self.call_raw_with_env(env)?; - self.commit(&mut result); - result = result.into_result(rd)?; - let Some(Output::Create(_, Some(address))) = result.out else { - panic!("Deployment succeeded, but no address was returned: {result:#?}"); - }; - - // also mark this library as persistent, this will ensure that the state of the library is - // persistent across fork swaps in forking mode - self.backend.add_persistent_account(address); - - debug!(%address, "deployed contract"); - - Ok(DeployResult { raw: result, address }) + /// This is the same as [`Self::is_success`], but will consume the `state_changeset` map to use + /// internally when calling `failed()`. + pub fn is_raw_call_mut_success( + &self, + address: Address, + call_result: &mut RawCallResult, + should_fail: bool, + ) -> bool { + self.is_raw_call_success( + address, + Cow::Owned(call_result.state_changeset.take().unwrap_or_default()), + call_result, + should_fail, + ) } - /// Deploys a contract and commits the new state to the underlying database. + /// Checks if a call to a test contract was successful. /// - /// Executes a CREATE transaction with the contract `code` and persistent database state - /// modifications. - pub fn deploy( - &mut self, - from: Address, - code: Bytes, - value: U256, - rd: Option<&RevertDecoder>, - ) -> Result { - let env = self.build_test_env(from, TransactTo::Create, code, value); - self.deploy_with_env(env, rd) + /// This is the same as [`Self::is_success`] but intended for outcomes of [`Self::call_raw`]. + /// + /// ## Background + /// + /// Executing and failure checking `Executor::is_success` are two steps, for ds-test + /// legacy reasons failures can be stored in a global variables and needs to be called via a + /// solidity call `failed()(bool)`. + /// + /// Snapshots make this task more complicated because now we also need to keep track of that + /// global variable when we revert to a snapshot (because it is stored in state). Now, the + /// problem is that the `CowBackend` is dropped after every call, so we need to keep track + /// of the snapshot failure in the [`RawCallResult`] instead. + pub fn is_raw_call_success( + &self, + address: Address, + state_changeset: Cow<'_, StateChangeset>, + call_result: &RawCallResult, + should_fail: bool, + ) -> bool { + if call_result.has_snapshot_failure { + // a failure occurred in a reverted snapshot, which is considered a failed test + return should_fail; + } + self.is_success(address, call_result.reverted, state_changeset, should_fail) } /// Check if a call to a test contract was successful. @@ -449,48 +461,19 @@ impl Executor { state_changeset: Cow<'_, StateChangeset>, should_fail: bool, ) -> bool { - self.ensure_success(address, reverted, state_changeset, should_fail).unwrap_or_default() + let success = self.is_success_raw(address, reverted, state_changeset); + should_fail ^ success } - /// This is the same as [`Self::is_success`] but intended for outcomes of [`Self::call_raw`] - /// used in fuzzing and invariant testing. - /// - /// ## Background - /// - /// Executing and failure checking `Executor::ensure_success` are two steps, for ds-test - /// legacy reasons failures can be stored in a global variables and needs to be called via a - /// solidity call `failed()(bool)`. - /// - /// For fuzz tests we’re using the `CowBackend` which lazily clones the backend when it’s - /// mutated via cheatcodes like `snapshot`. Snapshots make it even more complicated because - /// now we also need to keep track of that global variable when we revert to a snapshot - /// (because it is stored in state). Now, the problem is that the `CowBackend` is dropped - /// after every call, so we need to keep track of the snapshot failure in the - /// [`RawCallResult`] instead. - pub fn is_raw_call_success( - &self, - address: Address, - state_changeset: Cow<'_, StateChangeset>, - call_result: &RawCallResult, - should_fail: bool, - ) -> bool { - if call_result.has_snapshot_failure { - // a failure occurred in a reverted snapshot, which is considered a failed test - return should_fail - } - self.is_success(address, call_result.reverted, state_changeset, should_fail) - } - - fn ensure_success( + fn is_success_raw( &self, address: Address, reverted: bool, state_changeset: Cow<'_, StateChangeset>, - should_fail: bool, - ) -> Result { + ) -> bool { if self.backend.has_snapshot_failure() { // a failure occurred in a reverted snapshot, which is considered a failed test - return Ok(should_fail) + return false; } let mut success = !reverted; @@ -500,9 +483,9 @@ impl Executor { // We only clone the test contract and cheatcode accounts, // that's all we need to evaluate success. - for addr in [address, CHEATCODE_ADDRESS] { - let acc = self.backend.basic_ref(addr)?.unwrap_or_default(); - backend.insert_account_info(addr, acc); + for address in [address, CHEATCODE_ADDRESS] { + let Ok(acc) = self.backend.basic_ref(address) else { return false }; + backend.insert_account_info(address, acc.unwrap_or_default()); } // If this test failed any asserts, then this changeset will contain changes @@ -515,16 +498,17 @@ impl Executor { let executor = Self::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); let call = executor.call_sol(CALLER, address, &ITest::failedCall {}, U256::ZERO, None); - if let Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { failed } }) = call - { - debug!(failed, "DSTest::failed()"); - success = !failed; + match call { + Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { failed } }) => { + debug!(failed, "DSTest::failed()"); + success = !failed; + } + Err(err) => { + debug!(%err, "failed to call DSTest::failed()"); + } } } - - let result = should_fail ^ success; - debug!(should_fail, success, result); - Ok(result) + success } /// Creates the environment to use when executing a transaction in a test context diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 51d904376d590..fe4a675e8c8b8 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -38,7 +38,6 @@ use foundry_evm::{ use proptest::test_runner::TestRunner; use rayon::prelude::*; use std::{ - borrow::Cow, cmp::min, collections::{BTreeMap, HashMap}, time::Instant, @@ -437,8 +436,7 @@ impl<'a> ContractRunner<'a> { } = setup; // Run unit test - let mut executor = self.executor.clone(); - let (raw_call_result, reason) = match executor.execute_test( + let (mut raw_call_result, reason) = match self.executor.call( self.sender, address, func, @@ -470,15 +468,16 @@ impl<'a> ContractRunner<'a> { } }; + let success = + self.executor.is_raw_call_mut_success(setup.address, &mut raw_call_result, should_fail); + let RawCallResult { - reverted, gas_used: gas, stipend, logs: execution_logs, traces: execution_trace, coverage: execution_coverage, labels: new_labels, - state_changeset, debug, cheatcodes, .. @@ -491,13 +490,6 @@ impl<'a> ContractRunner<'a> { logs.extend(execution_logs); coverage = merge_coverages(coverage, execution_coverage); - let success = executor.is_success( - setup.address, - reverted, - Cow::Owned(state_changeset.unwrap()), - should_fail, - ); - TestResult { status: match success { true => TestStatus::Success, @@ -532,7 +524,7 @@ impl<'a> ContractRunner<'a> { setup; // First, run the test normally to see if it needs to be skipped. - if let Err(EvmError::SkipError) = self.executor.clone().execute_test( + if let Err(EvmError::SkipError) = self.executor.call( self.sender, address, func, diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 0321d0c5ec1db..e107180a8b282 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -92,7 +92,7 @@ impl ScriptRunner { let calldata = [salt.as_ref(), library.as_ref()].concat(); let result = self .executor - .call_raw_committing( + .transact_raw( self.evm_opts.sender, DEFAULT_CREATE2_DEPLOYER, calldata.clone().into(), @@ -301,7 +301,7 @@ impl ScriptRunner { // Otherwise don't re-execute, or some usecases might be broken: https://github.com/foundry-rs/foundry/issues/3921 if commit { gas_used = self.search_optimal_gas_usage(&res, from, to, &calldata, value)?; - res = self.executor.call_raw_committing(from, to, calldata, value)?; + res = self.executor.transact_raw(from, to, calldata, value)?; } let RawCallResult { result, reverted, logs, traces, labels, debug, transactions, .. } = res; diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index f6d2ea41941b5..15923334880e4 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -315,10 +315,10 @@ impl VerifyBytecodeArgs { if to != DEFAULT_CREATE2_DEPLOYER { eyre::bail!("Transaction `to` address is not the default create2 deployer i.e the tx is not a contract creation tx."); } - let result = executor.commit_tx_with_env(env_with_handler.to_owned())?; + let result = executor.transact_with_env(env_with_handler.clone())?; - if result.result.len() > 20 { - eyre::bail!("Failed to deploy contract using commit_tx_with_env on fork at block {} | Err: Call result is greater than 20 bytes, cannot be converted to Address", simulation_block); + if result.result.len() != 20 { + eyre::bail!("Failed to deploy contract on fork at block {simulation_block}: call result is not exactly 20 bytes"); } Address::from_slice(&result.result) From b7dcf4661ddb4fa0cf3519c800df2d5c96500a7e Mon Sep 17 00:00:00 2001 From: poma Date: Thu, 13 Jun 2024 04:50:31 +0300 Subject: [PATCH 1083/1963] Allow to specify entropy when generating new mnemonic with cast (#8145) * Allow to specify entropy when generating new mnemonic with cast * change print color to yellow, a standard warning color --------- Co-authored-by: poma --- crates/cast/bin/cmd/wallet/mod.rs | 18 ++++++++++++++---- crates/cast/tests/cli/main.rs | 7 +++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index a22d6a6ec224a..9daca4759fc4e 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -2,7 +2,7 @@ use alloy_dyn_abi::TypedData; use alloy_primitives::{Address, Signature, B256}; use alloy_signer::Signer; use alloy_signer_wallet::{ - coins_bip39::{English, Mnemonic}, + coins_bip39::{English, Entropy, Mnemonic}, LocalWallet, MnemonicBuilder, }; use clap::Parser; @@ -61,6 +61,10 @@ pub enum WalletSubcommands { /// Number of accounts to display #[arg(long, short, default_value = "1")] accounts: u8, + + /// Entropy to use for the mnemonic + #[arg(long, short, conflicts_with = "words")] + entropy: Option, }, /// Generate a vanity address. @@ -256,9 +260,15 @@ impl WalletSubcommands { } } } - Self::NewMnemonic { words, accounts } => { - let mut rng = thread_rng(); - let phrase = Mnemonic::::new_with_count(&mut rng, words)?.to_phrase(); + Self::NewMnemonic { words, accounts, entropy } => { + let phrase = if let Some(entropy) = entropy { + let entropy = Entropy::from_slice(&hex::decode(entropy)?)?; + println!("{}", "Generating mnemonic from provided entropy...".yellow()); + Mnemonic::::new_from_entropy(entropy).to_phrase() + } else { + let mut rng = thread_rng(); + Mnemonic::::new_with_count(&mut rng, words)?.to_phrase() + }; let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); let derivation_path = "m/44'/60'/0'/0/"; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 5a6be401bb230..7d7e338811ec1 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -163,6 +163,13 @@ casttest!(wallet_list_local_accounts, |prj, cmd| { assert_eq!(list_output.matches('\n').count(), 10); }); +// tests that `cast wallet new-mnemonic --entropy` outputs the expected mnemonic +casttest!(wallet_mnemonic_from_entropy, |_prj, cmd| { + cmd.args(["wallet", "new-mnemonic", "--entropy", "0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c"]); + let output = cmd.stdout_lossy(); + assert!(output.contains("test test test test test test test test test test test junk")); +}); + // tests that `cast wallet private-key` with arguments outputs the private key casttest!(wallet_private_key_from_mnemonic_arg, |_prj, cmd| { cmd.args([ From 65bdd3159b7898887541c56fed2dd32af3944fbe Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:44:50 -0700 Subject: [PATCH 1084/1963] fix: Soldeer: Fixed the url bug, it should be optional (#8155) * Fixed the url bug, it should be optional * added serde skip serializing --- crates/config/src/soldeer.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/config/src/soldeer.rs b/crates/config/src/soldeer.rs index 5c1d01aa6cab3..511559bb91398 100644 --- a/crates/config/src/soldeer.rs +++ b/crates/config/src/soldeer.rs @@ -11,7 +11,8 @@ pub struct SoldeerDependency { pub version: String, /// The url from where the dependency was retrieved - pub url: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, } /// Type for Soldeer configs, under dependencies tag in the foundry.toml From 6a85dbaa62f1c305f31cab37781232913055ae28 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 13 Jun 2024 22:24:54 +0300 Subject: [PATCH 1085/1963] feat: display source name in debugger (#8154) * feat: display source name in debugger * fmt * clippy * refactor --- Cargo.lock | 1 - crates/common/Cargo.toml | 1 - crates/common/src/compile.rs | 38 +++++++------------ crates/debugger/src/tui/draw.rs | 30 +++++++++------ crates/evm/traces/Cargo.toml | 1 + crates/evm/traces/src/identifier/etherscan.rs | 23 +++++++---- crates/forge/bin/cmd/test/mod.rs | 3 +- crates/script/src/build.rs | 3 +- 8 files changed, 52 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc6ee96381233..206103b789f0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3594,7 +3594,6 @@ dependencies = [ "serde", "serde_json", "similar-asserts", - "tempfile", "thiserror", "tokio", "tower", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 56f430c4ab32f..907f3b62579c9 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -47,7 +47,6 @@ reqwest.workspace = true semver = "1" serde_json.workspace = true serde.workspace = true -tempfile.workspace = true thiserror = "1" tokio.workspace = true tracing.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index d26b362a9adb2..3488e6482a00a 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -275,6 +275,7 @@ impl ProjectCompiler { pub struct SourceData { pub source: Arc, pub language: MultiCompilerLanguage, + pub name: String, } #[derive(Clone, Debug)] @@ -297,11 +298,12 @@ impl ContractSources { /// Collects the contract sources and artifacts from the project compile output. pub fn from_project_output( output: &ProjectCompileOutput, - link_data: Option<(&Path, &Libraries)>, + root: impl AsRef, + libraries: Option<&Libraries>, ) -> Result { let mut sources = Self::default(); - sources.insert(output, link_data)?; + sources.insert(output, root, libraries)?; Ok(sources) } @@ -309,12 +311,14 @@ impl ContractSources { pub fn insert( &mut self, output: &ProjectCompileOutput, - link_data: Option<(&Path, &Libraries)>, + root: impl AsRef, + libraries: Option<&Libraries>, ) -> Result<()> where C::Language: Into, { - let link_data = link_data.map(|(root, libraries)| { + let root = root.as_ref(); + let link_data = libraries.map(|libraries| { let linker = Linker::new(root, output.artifact_ids().collect()); (linker, libraries) }); @@ -355,7 +359,11 @@ impl ContractSources { self.sources_by_id.entry(build_id.clone()).or_default().insert( *source_id, - SourceData { source: source_code, language: build.language.into() }, + SourceData { + source: source_code, + language: build.language.into(), + name: path.strip_prefix(root).unwrap_or(path).to_string_lossy().to_string(), + }, ); } } @@ -496,26 +504,6 @@ pub fn compile_target( ProjectCompiler::new().quiet(quiet).files([target_path.into()]).compile(project) } -/// Compiles an Etherscan source from metadata by creating a project. -/// Returns the artifact_id, the file_id, and the bytecode -pub async fn compile_from_source( - metadata: &Metadata, -) -> Result> { - let root = tempfile::tempdir()?; - let root_path = root.path(); - let project = etherscan_project(metadata, root_path)?; - - let project_output = project.compile()?; - - if project_output.has_compiler_errors() { - eyre::bail!("{project_output}") - } - - root.close()?; - - Ok(project_output) -} - /// Creates a [Project] from an Etherscan source. pub fn etherscan_project( metadata: &Metadata, diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index aa6ac13cf2d18..06056034cd056 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -191,8 +191,8 @@ impl DebuggerContext<'_> { } fn draw_src(&self, f: &mut Frame<'_>, area: Rect) { - let text_output = self.src_text(area); - let title = match self.call_kind() { + let (text_output, source_name) = self.src_text(area); + let call_kind_text = match self.call_kind() { CallKind::Create | CallKind::Create2 => "Contract creation", CallKind::Call => "Contract call", CallKind::StaticCall => "Contract staticcall", @@ -200,15 +200,20 @@ impl DebuggerContext<'_> { CallKind::DelegateCall => "Contract delegatecall", CallKind::AuthCall => "Contract authcall", }; + let title = format!( + "{} {} ", + call_kind_text, + source_name.map(|s| format!("| {s}")).unwrap_or_default() + ); let block = Block::default().title(title).borders(Borders::ALL); let paragraph = Paragraph::new(text_output).block(block).wrap(Wrap { trim: false }); f.render_widget(paragraph, area); } - fn src_text(&self, area: Rect) -> Text<'_> { - let (source_element, source_code) = match self.src_map() { + fn src_text(&self, area: Rect) -> (Text<'_>, Option<&str>) { + let (source_element, source_code, source_file) = match self.src_map() { Ok(r) => r, - Err(e) => return Text::from(e), + Err(e) => return (Text::from(e), None), }; // We are handed a vector of SourceElements that give us a span of sourcecode that is @@ -330,10 +335,11 @@ impl DebuggerContext<'_> { } } - Text::from(lines.lines) + (Text::from(lines.lines), Some(source_file)) } - fn src_map(&self) -> Result<(SourceElement, &str), String> { + /// Returns source map, source code and source name of the current line. + fn src_map(&self) -> Result<(SourceElement, &str, &str), String> { let address = self.address(); let Some(contract_name) = self.debugger.identified_contracts.get(address) else { return Err(format!("Unknown contract at address {address}")); @@ -351,7 +357,7 @@ impl DebuggerContext<'_> { let is_create = matches!(self.call_kind(), CallKind::Create | CallKind::Create2); let pc = self.current_step().pc; - let Some((source_element, source_code)) = + let Some((source_element, source_code, source_file)) = files_source_code.find_map(|(artifact, source)| { let bytecode = if is_create { &artifact.bytecode.bytecode @@ -376,7 +382,7 @@ impl DebuggerContext<'_> { // if index matches current file_id, return current source code .and_then(|index| { (index == artifact.file_id) - .then(|| (source_element.clone(), source.source.as_str())) + .then(|| (source_element.clone(), source.source.as_str(), &source.name)) }) .or_else(|| { // otherwise find the source code for the element's index @@ -385,7 +391,9 @@ impl DebuggerContext<'_> { .sources_by_id .get(&artifact.build_id)? .get(&source_element.index()?) - .map(|source| (source_element.clone(), source.source.as_str())) + .map(|source| { + (source_element.clone(), source.source.as_str(), &source.name) + }) }); res @@ -394,7 +402,7 @@ impl DebuggerContext<'_> { return Err(format!("No source map for contract {contract_name}")); }; - Ok((source_element, source_code)) + Ok((source_element, source_code, source_file)) } fn draw_op_list(&self, f: &mut Frame<'_>, area: Rect) { diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index d6b13e3ccf85e..8c2ccb3ae9713 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -41,6 +41,7 @@ tokio = { workspace = true, features = ["time", "macros"] } tracing = "0.1" yansi.workspace = true rustc-hash.workspace = true +tempfile.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 794b3a9edd118..87d7e9c92d83d 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -4,13 +4,12 @@ use foundry_block_explorers::{ contract::{ContractMetadata, Metadata}, errors::EtherscanError, }; -use foundry_common::compile::{self, ContractSources}; +use foundry_common::compile::{etherscan_project, ContractSources}; use foundry_config::{Chain, Config}; use futures::{ future::{join_all, Future}, stream::{FuturesUnordered, Stream, StreamExt}, task::{Context, Poll}, - TryFutureExt, }; use std::{ borrow::Cow, @@ -64,11 +63,18 @@ impl EtherscanIdentifier { .iter() // filter out vyper files .filter(|(_, metadata)| !metadata.is_vyper()) - .map(|(address, metadata)| { + .map(|(address, metadata)| async move { println!("Compiling: {} {address}", metadata.contract_name); - let err_msg = - format!("Failed to compile contract {} from {address}", metadata.contract_name); - compile::compile_from_source(metadata).map_err(move |err| err.wrap_err(err_msg)) + let root = tempfile::tempdir()?; + let root_path = root.path(); + let project = etherscan_project(metadata, root_path)?; + let output = project.compile()?; + + if output.has_compiler_errors() { + eyre::bail!("{output}") + } + + Ok((project, output, root)) }) .collect::>(); @@ -78,8 +84,9 @@ impl EtherscanIdentifier { let mut sources: ContractSources = Default::default(); // construct the map - for output in outputs { - sources.insert(&output?, None)?; + for res in outputs { + let (project, output, _) = res?; + sources.insert(&output, project.root(), None)?; } Ok(sources) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index c27e2053d6f1c..6f65dcfec5b45 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -337,7 +337,8 @@ impl TestArgs { let sources = ContractSources::from_project_output( output_clone.as_ref().unwrap(), - Some((project.root(), &libraries)), + project.root(), + Some(&libraries), )?; // Run the debugger. diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index f1a18d45fa8b6..2fc0691d742f9 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -136,7 +136,8 @@ impl LinkedBuildData { ) -> Result { let sources = ContractSources::from_project_output( &build_data.output, - Some((&build_data.project_root, &libraries)), + &build_data.project_root, + Some(&libraries), )?; let known_contracts = From c2e529786c07ee7069cefcd4fe2db41f0e46cef6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 14 Jun 2024 03:09:21 +0300 Subject: [PATCH 1086/1963] feat(build): add option to build specific dir (#8149) * feat(build): add option to build specific dir * Changes after review: - use source_files_iter helper, build single files and child dirs as well - rename arg to paths, use 0.. pos arg * Changes after review: reuse MultiCompilerLanguage::FILE_EXTENSIONS --- crates/cli/src/opts/build/core.rs | 5 ++ crates/forge/bin/cmd/build.rs | 15 ++++- crates/forge/tests/cli/cmd.rs | 63 +++++++++++++++++++ .../can_build_path_with_one_file.stdout | 3 + .../can_build_path_with_three_files.stdout | 3 + .../can_build_path_with_two_files.stdout | 3 + 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 crates/forge/tests/fixtures/can_build_path_with_one_file.stdout create mode 100644 crates/forge/tests/fixtures/can_build_path_with_three_files.stdout create mode 100644 crates/forge/tests/fixtures/can_build_path_with_two_files.stdout diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 61986b8fac8ad..5f27afaa6f55f 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -126,6 +126,11 @@ pub struct CoreBuildArgs { #[serde(skip)] pub skip: Option>, + /// Build source files from specified paths. + #[arg(long, short, num_args(0..))] + #[serde(skip)] + pub paths: Option>, + #[command(flatten)] #[serde(flatten)] pub compiler: CompilerArgs, diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index e78ac283a9946..82d5c834e3e21 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -3,7 +3,11 @@ use clap::Parser; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::compile::ProjectCompiler; -use foundry_compilers::{Project, ProjectCompileOutput}; +use foundry_compilers::{ + compilers::{multi::MultiCompilerLanguage, Language}, + utils::source_files_iter, + Project, ProjectCompileOutput, +}; use foundry_config::{ figment::{ self, @@ -80,7 +84,16 @@ impl BuildArgs { let project = config.project()?; + // Collect sources to compile if build subdirectories specified. + let mut files = vec![]; + if let Some(dirs) = self.args.paths { + for dir in dirs { + files.extend(source_files_iter(dir, MultiCompilerLanguage::FILE_EXTENSIONS)); + } + } + let compiler = ProjectCompiler::new() + .files(files) .print_names(self.names) .print_sizes(self.sizes) .quiet(self.format_json) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index de2c242418a06..1c851dd090068 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1667,6 +1667,69 @@ function test_run() external {} ); }); +forgetest_init!(can_build_specific_paths, |prj, cmd| { + prj.wipe(); + prj.add_source( + "Counter.sol", + r" +contract Counter { +function count() external {} +}", + ) + .unwrap(); + prj.add_test( + "Foo.sol", + r" +contract Foo { +function test_foo() external {} +}", + ) + .unwrap(); + prj.add_test( + "Bar.sol", + r" +contract Bar { +function test_bar() external {} +}", + ) + .unwrap(); + + // Build 2 files within test dir + prj.clear(); + cmd.args(["build", "--paths", "test", "--force"]); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_build_path_with_two_files.stdout"), + ); + + // Build one file within src dir + prj.clear(); + cmd.forge_fuse(); + cmd.args(["build", "--paths", "src", "--force"]); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_build_path_with_one_file.stdout"), + ); + + // Build 3 files from test and src dirs + prj.clear(); + cmd.forge_fuse(); + cmd.args(["build", "--paths", "src", "test", "--force"]); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_build_path_with_three_files.stdout"), + ); + + // Build single test file + prj.clear(); + cmd.forge_fuse(); + cmd.args(["build", "--paths", "test/Bar.sol", "--force"]); + cmd.unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/can_build_path_with_one_file.stdout"), + ); +}); + // checks that build --sizes includes all contracts even if unchanged forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { prj.clear_cache(); diff --git a/crates/forge/tests/fixtures/can_build_path_with_one_file.stdout b/crates/forge/tests/fixtures/can_build_path_with_one_file.stdout new file mode 100644 index 0000000000000..3213db81a21d4 --- /dev/null +++ b/crates/forge/tests/fixtures/can_build_path_with_one_file.stdout @@ -0,0 +1,3 @@ +Compiling 1 files with 0.8.23 +Solc 0.8.23 finished in 33.25ms +Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_build_path_with_three_files.stdout b/crates/forge/tests/fixtures/can_build_path_with_three_files.stdout new file mode 100644 index 0000000000000..4235acf297591 --- /dev/null +++ b/crates/forge/tests/fixtures/can_build_path_with_three_files.stdout @@ -0,0 +1,3 @@ +Compiling 3 files with 0.8.23 +Solc 0.8.23 finished in 33.25ms +Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_build_path_with_two_files.stdout b/crates/forge/tests/fixtures/can_build_path_with_two_files.stdout new file mode 100644 index 0000000000000..cf59003407af9 --- /dev/null +++ b/crates/forge/tests/fixtures/can_build_path_with_two_files.stdout @@ -0,0 +1,3 @@ +Compiling 2 files with 0.8.23 +Solc 0.8.23 finished in 33.25ms +Compiler run successful! From 4240376a8c3e0457c340e57c044e4819ae4f849e Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 14 Jun 2024 22:25:06 +0530 Subject: [PATCH 1087/1963] migrate(`forge-bind`): to alloy (#7919) * migrate(forge-bind): to alloy - boilerplate and `SolMacroGen` type * tokens to `SolInput` * use SolInputKind * update alloy-core deps version and use expand * write cargo.toml * alloy: write_to_module * use `tokens_for_sol` from lib * write to single_file * nit * nit * add sol attr * nits * add alloy `Filter` and reuse get_json_files * fix: throw err instead of panic! * nits * check cargo toml * check existing alloy bindings * clippy nits * fmt * doc nits * clean up and nits * extract `sol_macro_gen` to separate crate * can specify alloy version * nit * warning nit * clippy nit * nit Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * pretty fmt before writing * nit: format! * populate bytecode attr * clippy * nit Co-authored-by: Matthias Seitz * fmt nits * clippy * parse path to `SolInput` directly * fix: artifact duplication * dedup faster * add sol attributes * fix: alloy dep * clippy * clippy nits --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Matthias Seitz --- Cargo.lock | 19 ++ Cargo.toml | 7 + crates/cast/bin/cmd/send.rs | 3 +- crates/cast/bin/cmd/wallet/mod.rs | 2 +- crates/forge/Cargo.toml | 3 + crates/forge/bin/cmd/bind.rs | 140 ++++++++- crates/forge/tests/cli/soldeer.rs | 8 +- crates/sol-macro-gen/Cargo.toml | 26 ++ crates/sol-macro-gen/src/lib.rs | 5 + crates/sol-macro-gen/src/sol_macro_gen.rs | 352 ++++++++++++++++++++++ 10 files changed, 549 insertions(+), 16 deletions(-) create mode 100644 crates/sol-macro-gen/Cargo.toml create mode 100644 crates/sol-macro-gen/src/lib.rs create mode 100644 crates/sol-macro-gen/src/sol_macro_gen.rs diff --git a/Cargo.lock b/Cargo.lock index 206103b789f0e..596b73f95ab85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3255,6 +3255,8 @@ dependencies = [ "alloy-rpc-types", "alloy-signer", "alloy-signer-wallet", + "alloy-sol-macro-expander", + "alloy-sol-macro-input", "alloy-transport", "anvil", "async-trait", @@ -3273,6 +3275,7 @@ dependencies = [ "forge-doc", "forge-fmt", "forge-script", + "forge-sol-macro-gen", "forge-verify", "foundry-block-explorers", "foundry-cli", @@ -3408,6 +3411,22 @@ dependencies = [ "yansi", ] +[[package]] +name = "forge-sol-macro-gen" +version = "0.2.0" +dependencies = [ + "alloy-json-abi", + "alloy-sol-macro-expander", + "alloy-sol-macro-input", + "eyre", + "foundry-common", + "prettyplease", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.66", +] + [[package]] name = "forge-verify" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 58b2a8972c91c..663b727cc3c4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,6 +135,7 @@ forge-doc = { path = "crates/doc" } forge-fmt = { path = "crates/fmt" } forge-verify = { path = "crates/verify" } forge-script = { path = "crates/script" } +forge-sol-macro-gen = { path = "crates/sol-macro-gen" } foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } foundry-cli = { path = "crates/cli" } @@ -195,6 +196,8 @@ alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" alloy-sol-types = "0.7.1" +alloy-sol-macro-input = "0.7.3" +alloy-sol-macro-expander = "0.7.3" syn-solidity = "0.7.1" alloy-chains = "0.1" alloy-trie = "0.4.1" @@ -202,6 +205,10 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc +proc-macro2 = "1.0.82" +quote = "1.0" +syn = "2.0" +prettyplease = "0.2.20" ahash = "0.8" arrayvec = "0.7" base64 = "0.22" diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index d4aee145bb4cb..b7d94402bb625 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -77,7 +77,8 @@ pub enum SendTxSubcommands { } impl SendTxArgs { - pub async fn run(self) -> Result<()> { + #[allow(dependency_on_unit_never_type_fallback)] + pub async fn run(self) -> Result<(), eyre::Report> { let Self { eth, to, diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 9daca4759fc4e..c468803ceb401 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -262,7 +262,7 @@ impl WalletSubcommands { } Self::NewMnemonic { words, accounts, entropy } => { let phrase = if let Some(entropy) = entropy { - let entropy = Entropy::from_slice(&hex::decode(entropy)?)?; + let entropy = Entropy::from_slice(hex::decode(entropy)?)?; println!("{}", "Generating mnemonic from provided entropy...".yellow()); Mnemonic::::new_from_entropy(entropy).to_phrase() } else { diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 28d679262f40e..995053feec43f 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -52,6 +52,7 @@ forge-doc.workspace = true forge-fmt.workspace = true forge-verify.workspace = true forge-script.workspace = true +forge-sol-macro-gen.workspace = true foundry-cli.workspace = true foundry-debugger.workspace = true @@ -63,6 +64,8 @@ alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } alloy-network.workspace = true alloy-transport.workspace = true alloy-signer.workspace = true +alloy-sol-macro-input.workspace = true +alloy-sol-macro-expander = { workspace = true, features = ["json"] } alloy-consensus.workspace = true alloy-chains.workspace = true diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 8283ca7d81ccf..f9e9a22a42e11 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -3,6 +3,7 @@ use ethers_contract_abigen::{ Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts, }; use eyre::{Result, WrapErr}; +use forge_sol_macro_gen::{MultiSolMacroGen, SolMacroGen}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs::json_files}; use foundry_config::impl_figment_convert; @@ -81,9 +82,13 @@ pub struct BindArgs { skip_extra_derives: bool, /// Generate bindings for the `alloy` library, instead of `ethers`. - #[arg(skip)] + #[arg(long, conflicts_with = "ethers")] alloy: bool, + /// Specify the alloy version. + #[arg(long, value_name = "ALLOY_VERSION")] + alloy_version: Option, + /// Generate bindings for the `ethers` library, instead of `alloy` (default, deprecated). #[arg(long)] ethers: bool, @@ -100,13 +105,10 @@ impl BindArgs { } if !self.alloy { - eprintln!("Warning: ethers bindings are deprecated and will be removed in the future"); - /* eprintln!( "Warning: `--ethers` (default) bindings are deprecated and will be removed in the future. \ Consider using `--alloy` instead." ); - */ } let config = self.try_load_config_emit_warnings()?; @@ -162,9 +164,34 @@ impl BindArgs { .into()) } + fn get_alloy_filter(&self) -> Result { + if self.select_all { + // Select all json files + return Ok(Filter::All); + } + if !self.select.is_empty() { + // Return json files that match the select regex + return Ok(Filter::Select(self.select.clone())); + } + + if let Some(skip) = self.build_args.skip.as_ref().filter(|s| !s.is_empty()) { + return Ok(Filter::Skip( + skip.clone() + .into_iter() + .map(|s| Regex::new(s.file_pattern())) + .collect::, _>>()?, + )); + } + + // Exclude defaults + Ok(Filter::skip_default()) + } + /// Returns an iterator over the JSON files and the contract name in the `artifacts` directory. fn get_json_files(&self, artifacts: &Path) -> Result> { let filter = self.get_filter()?; + let alloy_filter = self.get_alloy_filter()?; + let is_alloy = self.alloy; Ok(json_files(artifacts) .filter_map(|path| { // Ignore the build info JSON. @@ -185,7 +212,15 @@ impl BindArgs { Some((name, path)) }) - .filter(move |(name, _path)| filter.is_match(name))) + .filter( + move |(name, _path)| { + if is_alloy { + alloy_filter.is_match(name) + } else { + filter.is_match(name) + } + }, + )) } /// Instantiate the multi-abigen @@ -208,13 +243,32 @@ impl BindArgs { Ok(multi) } + fn get_solmacrogen(&self, artifacts: &Path) -> Result { + let mut dup = std::collections::HashSet::::new(); + let instances = self + .get_json_files(artifacts)? + .filter_map(|(name, path)| { + trace!(?path, "parsing SolMacroGen from file"); + if dup.insert(name.clone()) { + Some(SolMacroGen::new(path, name)) + } else { + None + } + }) + .collect::>(); + + let multi = MultiSolMacroGen::new(artifacts, instances); + eyre::ensure!(!multi.instances.is_empty(), "No contract artifacts found"); + Ok(multi) + } + /// Check that the existing bindings match the expected abigen output fn check_existing_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { if !self.alloy { return self.check_ethers(artifacts, bindings_root); } - todo!("alloy") + self.check_alloy(artifacts, bindings_root) } fn check_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { @@ -243,13 +297,30 @@ impl BindArgs { Ok(()) } + fn check_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + let mut bindings = self.get_solmacrogen(artifacts)?; + bindings.generate_bindings()?; + println!("Checking bindings for {} contracts", bindings.instances.len()); + bindings.check_consistency( + &self.crate_name, + &self.crate_version, + bindings_root, + self.single_file, + !self.skip_cargo_toml, + self.module, + self.alloy_version.clone(), + )?; + println!("OK."); + Ok(()) + } + /// Generate the bindings fn generate_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { if !self.alloy { return self.generate_ethers(artifacts, bindings_root); } - todo!("alloy") + self.generate_alloy(artifacts, bindings_root) } fn generate_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { @@ -271,4 +342,59 @@ impl BindArgs { bindings.write_to_module(bindings_root, self.single_file) } } + + fn generate_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + let mut solmacrogen = self.get_solmacrogen(artifacts)?; + println!("Generating bindings for {} contracts", solmacrogen.instances.len()); + + if !self.module { + trace!(single_file = self.single_file, "generating crate"); + solmacrogen.write_to_crate( + &self.crate_name, + &self.crate_version, + bindings_root, + self.single_file, + self.alloy_version.clone(), + )?; + } else { + trace!(single_file = self.single_file, "generating module"); + solmacrogen.write_to_module(bindings_root, self.single_file)?; + } + + Ok(()) + } +} + +pub enum Filter { + All, + Select(Vec), + Skip(Vec), +} + +impl Filter { + pub fn is_match(&self, name: &str) -> bool { + match self { + Self::All => true, + Self::Select(regexes) => regexes.iter().any(|regex| regex.is_match(name)), + Self::Skip(regexes) => !regexes.iter().any(|regex| regex.is_match(name)), + } + } + + pub fn skip_default() -> Self { + let skip = [ + ".*Test.*", + ".*Script", + "console[2]?", + "CommonBase", + "Components", + "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Toml|Storage(Safe)?)", + "[Vv]m.*", + "IMulticall3", + ] + .iter() + .map(|pattern| regex::Regex::new(pattern).unwrap()) + .collect::>(); + + Self::Skip(skip) + } } diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index 7f762e8dd6a31..6bbba534d9f64 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -171,12 +171,6 @@ forgesoldeer!(login, |prj, cmd| { }); fn read_file_to_string(path: &Path) -> String { - let contents: String = match fs::read_to_string(path) { - Ok(c) => c, - Err(_) => { - // Return empty string - String::new() - } - }; + let contents: String = fs::read_to_string(path).unwrap_or_default(); contents } diff --git a/crates/sol-macro-gen/Cargo.toml b/crates/sol-macro-gen/Cargo.toml new file mode 100644 index 0000000000000..c4da94041427e --- /dev/null +++ b/crates/sol-macro-gen/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "forge-sol-macro-gen" +description = "Contains types and methods for generating rust bindings using sol!" +publish = false + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +alloy-json-abi.workspace = true +alloy-sol-macro-input.workspace = true +alloy-sol-macro-expander = { workspace = true, features = ["json"] } +foundry-common.workspace = true + +proc-macro2.workspace = true +quote.workspace = true +syn.workspace = true +prettyplease.workspace = true + +serde_json.workspace = true +eyre.workspace = true diff --git a/crates/sol-macro-gen/src/lib.rs b/crates/sol-macro-gen/src/lib.rs new file mode 100644 index 0000000000000..0202827f25574 --- /dev/null +++ b/crates/sol-macro-gen/src/lib.rs @@ -0,0 +1,5 @@ +//! This crate constains the logic for Rust bindings generating from Solidity contracts + +pub mod sol_macro_gen; + +pub use sol_macro_gen::*; diff --git a/crates/sol-macro-gen/src/sol_macro_gen.rs b/crates/sol-macro-gen/src/sol_macro_gen.rs new file mode 100644 index 0000000000000..1cc8cc9107300 --- /dev/null +++ b/crates/sol-macro-gen/src/sol_macro_gen.rs @@ -0,0 +1,352 @@ +//! SolMacroGen and MultiSolMacroGen +//! +//! This type encapsulates the logic for expansion of a Rust TokenStream from Solidity tokens. It +//! uses the `expand` method from `alloy_sol_macro_expander` underneath. +//! +//! It holds info such as `path` to the ABI file, `name` of the file and the rust binding being +//! generated, and lastly the `expansion` itself, i.e the Rust binding for the provided ABI. +//! +//! It contains methods to read the json abi, generate rust bindings from the abi and ultimately +//! write the bindings to a crate or modules. + +use alloy_sol_macro_expander::expand::expand; +use alloy_sol_macro_input::{SolInput, SolInputKind}; +use eyre::{Context, Ok, OptionExt, Result}; +use foundry_common::fs; +use proc_macro2::{Span, TokenStream}; +use std::{ + fmt::Write, + path::{Path, PathBuf}, + str::FromStr, +}; + +pub struct SolMacroGen { + pub path: PathBuf, + pub name: String, + pub expansion: Option, +} + +impl SolMacroGen { + pub fn new(path: PathBuf, name: String) -> Self { + Self { path, name, expansion: None } + } + + pub fn get_sol_input(&self) -> Result { + let path = self.path.to_string_lossy().into_owned(); + let name = proc_macro2::Ident::new(&self.name, Span::call_site()); + let tokens = quote::quote! { + #name, + #path + }; + + let sol_input: SolInput = syn::parse2(tokens).wrap_err("Failed to parse SolInput {e}")?; + + Ok(sol_input) + } +} + +pub struct MultiSolMacroGen { + pub artifacts_path: PathBuf, + pub instances: Vec, +} + +impl MultiSolMacroGen { + pub fn new(artifacts_path: &Path, instances: Vec) -> Self { + Self { artifacts_path: artifacts_path.to_path_buf(), instances } + } + + pub fn populate_expansion(&mut self, bindings_path: &Path) -> Result<()> { + for instance in &mut self.instances { + let path = bindings_path.join(format!("{}.rs", instance.name.to_lowercase())); + let expansion = fs::read_to_string(path).wrap_err("Failed to read file")?; + + let tokens = TokenStream::from_str(&expansion) + .map_err(|e| eyre::eyre!("Failed to parse TokenStream: {e}"))?; + instance.expansion = Some(tokens); + } + Ok(()) + } + + pub fn generate_bindings(&mut self) -> Result<()> { + for instance in &mut self.instances { + let input = instance.get_sol_input()?.normalize_json()?; + + let SolInput { attrs: _attrs, path: _path, kind } = input; + + let tokens = match kind { + SolInputKind::Sol(mut file) => { + let sol_attr: syn::Attribute = syn::parse_quote! { + #[sol(rpc, alloy_sol_types = alloy::sol_types, alloy_contract = alloy::contract)] + }; + file.attrs.push(sol_attr); + expand(file).wrap_err("Failed to expand SolInput")? + } + _ => unreachable!(), + }; + + instance.expansion = Some(tokens); + } + + Ok(()) + } + + pub fn write_to_crate( + &mut self, + name: &str, + version: &str, + bindings_path: &Path, + single_file: bool, + alloy_version: Option, + ) -> Result<()> { + self.generate_bindings()?; + + let src = bindings_path.join("src"); + + let _ = fs::create_dir_all(&src); + + // Write Cargo.toml + let cargo_toml_path = bindings_path.join("Cargo.toml"); + let mut toml_contents = format!( + r#"[package] +name = "{}" +version = "{}" +edition = "2021" + +[dependencies] +"#, + name, version + ); + + let alloy_dep = if let Some(alloy_version) = alloy_version { + format!( + r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{}", features = ["sol-types", "contract"] }}"#, + alloy_version + ) + } else { + r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }}"#.to_string() + }; + write!(toml_contents, "{}", alloy_dep)?; + + fs::write(cargo_toml_path, toml_contents).wrap_err("Failed to write Cargo.toml")?; + + let mut lib_contents = String::new(); + if single_file { + write!( + &mut lib_contents, + r#"#![allow(unused_imports, clippy::all)] + //! This module contains the sol! generated bindings for solidity contracts. + //! This is autogenerated code. + //! Do not manually edit these files. + //! These files may be overwritten by the codegen system at any time."# + )?; + } else { + write!( + &mut lib_contents, + r#"#![allow(unused_imports)] + "# + )?; + }; + + // Write src + for instance in &self.instances { + let name = instance.name.to_lowercase(); + let contents = instance.expansion.as_ref().unwrap().to_string(); + + if !single_file { + let path = src.join(format!("{}.rs", name)); + let file = syn::parse_file(&contents)?; + let contents = prettyplease::unparse(&file); + + fs::write(path.clone(), contents).wrap_err("Failed to write file")?; + writeln!(&mut lib_contents, "pub mod {};", name)?; + } else { + write!(&mut lib_contents, "{}", contents)?; + } + } + + let lib_path = src.join("lib.rs"); + let lib_file = syn::parse_file(&lib_contents)?; + + let lib_contents = prettyplease::unparse(&lib_file); + + fs::write(lib_path, lib_contents).wrap_err("Failed to write lib.rs")?; + + Ok(()) + } + + pub fn write_to_module(&mut self, bindings_path: &Path, single_file: bool) -> Result<()> { + self.generate_bindings()?; + + let _ = fs::create_dir_all(bindings_path); + + let mut mod_contents = r#"#![allow(clippy::all)] + //! This module contains the sol! generated bindings for solidity contracts. + //! This is autogenerated code. + //! Do not manually edit these files. + //! These files may be overwritten by the codegen system at any time. + "# + .to_string(); + + for instance in &self.instances { + let name = instance.name.to_lowercase(); + if !single_file { + write!( + mod_contents, + r#"pub mod {}; + "#, + instance.name.to_lowercase() + )?; + let mut contents = + r#"//! This module was autogenerated by the alloy sol!. + //! More information can be found here . + "#.to_string(); + + write!(contents, "{}", instance.expansion.as_ref().unwrap())?; + let file = syn::parse_file(&contents)?; + + let contents = prettyplease::unparse(&file); + fs::write(bindings_path.join(format!("{}.rs", name)), contents) + .wrap_err("Failed to write file")?; + } else { + let mut contents = format!( + r#"//! This module was autogenerated by the alloy sol!. + //! More information can be found here . + pub use {}::*; + "#, + name + ); + write!(contents, "{}\n\n", instance.expansion.as_ref().unwrap())?; + write!(mod_contents, "{}", contents)?; + } + } + + let mod_path = bindings_path.join("mod.rs"); + let mod_file = syn::parse_file(&mod_contents)?; + let mod_contents = prettyplease::unparse(&mod_file); + + fs::write(mod_path, mod_contents).wrap_err("Failed to write mod.rs")?; + + Ok(()) + } + + /// Checks that the generated bindings are up to date with the latest version of + /// `sol!`. + /// + /// Returns `Ok(())` if the generated bindings are up to date, otherwise it returns + /// `Err(_)`. + #[allow(clippy::too_many_arguments)] + pub fn check_consistency( + &self, + name: &str, + version: &str, + crate_path: &Path, + single_file: bool, + check_cargo_toml: bool, + is_mod: bool, + alloy_version: Option, + ) -> Result<()> { + if check_cargo_toml { + self.check_cargo_toml(name, version, crate_path, alloy_version)?; + } + + let mut super_contents = String::new(); + if is_mod { + // mod.rs + write!( + &mut super_contents, + r#"#![allow(clippy::all)] + //! This module contains the sol! generated bindings for solidity contracts. + //! This is autogenerated code. + //! Do not manually edit these files. + //! These files may be overwritten by the codegen system at any time. + "# + )?; + } else { + // lib.rs + write!( + &mut super_contents, + r#"#![allow(unused_imports)] + "# + )?; + }; + if !single_file { + for instance in &self.instances { + let name = instance.name.to_lowercase(); + let path = crate_path.join(format!("src/{}.rs", name)); + let tokens = instance + .expansion + .as_ref() + .ok_or_eyre(format!("TokenStream for {path:?} does not exist"))? + .to_string(); + + self.check_file_contents(&path, &tokens)?; + + if !is_mod { + write!( + &mut super_contents, + r#"pub mod {}; + "#, + name + )?; + } + } + + let super_path = + if is_mod { crate_path.join("src/mod.rs") } else { crate_path.join("src/lib.rs") }; + self.check_file_contents(&super_path, &super_contents)?; + } + + Ok(()) + } + + fn check_file_contents(&self, file_path: &Path, expected_contents: &str) -> Result<()> { + eyre::ensure!( + file_path.is_file() && file_path.exists(), + "{} is not a file", + file_path.display() + ); + let file_contents = &fs::read_to_string(file_path).wrap_err("Failed to read file")?; + eyre::ensure!( + file_contents == expected_contents, + "File contents do not match expected contents for {file_path:?}" + ); + Ok(()) + } + + fn check_cargo_toml( + &self, + name: &str, + version: &str, + crate_path: &Path, + alloy_version: Option, + ) -> Result<()> { + eyre::ensure!(crate_path.is_dir(), "Crate path must be a directory"); + + let cargo_toml_path = crate_path.join("Cargo.toml"); + + eyre::ensure!(cargo_toml_path.is_file(), "Cargo.toml must exist"); + let cargo_toml_contents = + fs::read_to_string(cargo_toml_path).wrap_err("Failed to read Cargo.toml")?; + + let name_check = &format!("name = \"{}\"", name); + let version_check = &format!("version = \"{}\"", version); + let alloy_dep_check = if let Some(version) = alloy_version { + &format!( + r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{}", features = ["sol-types", "contract"] }}"#, + version + ) + } else { + &r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }}"#.to_string() + }; + let toml_consistent = cargo_toml_contents.contains(name_check) && + cargo_toml_contents.contains(version_check) && + cargo_toml_contents.contains(alloy_dep_check); + eyre::ensure!( + toml_consistent, + r#"The contents of Cargo.toml do not match the expected output of the latest `sol!` version. + This indicates that the existing bindings are outdated and need to be generated again."# + ); + + Ok(()) + } +} From b002fe8af68bdc3fb909a81c288bb93254b7b61e Mon Sep 17 00:00:00 2001 From: Ayene <2958807+ayenesimo1i@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:32:14 +0300 Subject: [PATCH 1088/1963] chore: add known error codes (#8166) add known error codes --- crates/config/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/README.md b/crates/config/README.md index 482ec29acb4e1..0ef55336a7dae 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -103,7 +103,7 @@ eth_rpc_url = "https://example.com/" # Setting this option enables decoding of error traces from mainnet deployed / verfied contracts via etherscan etherscan_api_key = "YOURETHERSCANAPIKEY" # ignore solc warnings for missing license and exceeded contract size -# known error codes are: ["unreachable", "unused-return", "unused-param", "unused-var", "code-size", "shadowing", "func-mutability", "license", "pragma-solidity", "virtual-interfaces", "same-varname", "too-many-warnings"] +# known error codes are: ["unreachable", "unused-return", "unused-param", "unused-var", "code-size", "shadowing", "func-mutability", "license", "pragma-solidity", "virtual-interfaces", "same-varname", "too-many-warnings", "constructor-visibility", "init-code-size", "missing-receive-ether", "unnamed-return", "transient-storage"] # additional warnings can be added using their numeric error code: ["license", 1337] ignored_error_codes = ["license", "code-size"] ignored_warnings_from = ["path_to_ignore"] From dbfa025dfbb4ffdae71797fc41f8f46db4018f13 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 14 Jun 2024 20:32:35 +0300 Subject: [PATCH 1089/1963] fix: enable cache when `--build-info` is enabled (#8164) fix: enable cache when --build-info is enabled --- crates/config/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 624edbebc7ee3..463ea82aa1181 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -804,7 +804,7 @@ impl Config { Severity::Error }) .set_offline(self.offline) - .set_cached(cached && !self.build_info) + .set_cached(cached) .set_build_info(!no_artifacts && self.build_info) .set_no_artifacts(no_artifacts); From a20cef190b21fd57c4610e98a1c5032fac568fbb Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Sat, 15 Jun 2024 00:26:22 +0530 Subject: [PATCH 1090/1963] fix(forge-bind): alloy deps and file consistency check (#8167) * fix(forge): alloy deps in bind * nit: braces Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * fix(bind): file consistency check * chore: unknown lints --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/bin/cmd/send.rs | 2 +- crates/sol-macro-gen/src/sol_macro_gen.rs | 29 ++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index b7d94402bb625..d684edcd48ac7 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -77,7 +77,7 @@ pub enum SendTxSubcommands { } impl SendTxArgs { - #[allow(dependency_on_unit_never_type_fallback)] + #[allow(unknown_lints, dependency_on_unit_never_type_fallback)] pub async fn run(self) -> Result<(), eyre::Report> { let Self { eth, diff --git a/crates/sol-macro-gen/src/sol_macro_gen.rs b/crates/sol-macro-gen/src/sol_macro_gen.rs index 1cc8cc9107300..6ef48f8cb0e5c 100644 --- a/crates/sol-macro-gen/src/sol_macro_gen.rs +++ b/crates/sol-macro-gen/src/sol_macro_gen.rs @@ -123,7 +123,7 @@ edition = "2021" alloy_version ) } else { - r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }}"#.to_string() + r#"alloy = { git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }"#.to_string() }; write!(toml_contents, "{}", alloy_dep)?; @@ -306,8 +306,16 @@ edition = "2021" file_path.display() ); let file_contents = &fs::read_to_string(file_path).wrap_err("Failed to read file")?; + + // Format both + let file_contents = syn::parse_file(file_contents)?; + let formatted_file = prettyplease::unparse(&file_contents); + + let expected_contents = syn::parse_file(expected_contents)?; + let formatted_exp = prettyplease::unparse(&expected_contents); + eyre::ensure!( - file_contents == expected_contents, + formatted_file == formatted_exp, "File contents do not match expected contents for {file_path:?}" ); Ok(()) @@ -328,19 +336,18 @@ edition = "2021" let cargo_toml_contents = fs::read_to_string(cargo_toml_path).wrap_err("Failed to read Cargo.toml")?; - let name_check = &format!("name = \"{}\"", name); - let version_check = &format!("version = \"{}\"", version); + let name_check = format!("name = \"{name}\""); + let version_check = format!("version = \"{version}\""); let alloy_dep_check = if let Some(version) = alloy_version { - &format!( - r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{}", features = ["sol-types", "contract"] }}"#, - version + format!( + r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{version}", features = ["sol-types", "contract"] }}"#, ) } else { - &r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }}"#.to_string() + r#"alloy = { git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }"#.to_string() }; - let toml_consistent = cargo_toml_contents.contains(name_check) && - cargo_toml_contents.contains(version_check) && - cargo_toml_contents.contains(alloy_dep_check); + let toml_consistent = cargo_toml_contents.contains(&name_check) && + cargo_toml_contents.contains(&version_check) && + cargo_toml_contents.contains(&alloy_dep_check); eyre::ensure!( toml_consistent, r#"The contents of Cargo.toml do not match the expected output of the latest `sol!` version. From 46cde380e9b7b2ceb012f7d6a03ef2607f1193e8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:22:51 +0200 Subject: [PATCH 1091/1963] perf: slightly improve inspector stack (#8169) --- crates/evm/evm/src/inspectors/chisel_state.rs | 2 +- crates/evm/evm/src/inspectors/logs.rs | 9 ++- crates/evm/evm/src/inspectors/stack.rs | 57 ++++++++++++------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/crates/evm/evm/src/inspectors/chisel_state.rs b/crates/evm/evm/src/inspectors/chisel_state.rs index 9aa933d388681..023389ed4dfff 100644 --- a/crates/evm/evm/src/inspectors/chisel_state.rs +++ b/crates/evm/evm/src/inspectors/chisel_state.rs @@ -22,7 +22,7 @@ impl ChiselState { } impl Inspector for ChiselState { - #[inline] + #[cold] fn step_end(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { // If we are at the final pc of the REPL contract execution, set the state. // Subtraction can't overflow because `pc` is always at least 1 in `step_end`. diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index f2bf3a114706e..bde558dbfa597 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, Bytes, Log}; +use alloy_primitives::{Bytes, Log}; use alloy_sol_types::{SolEvent, SolInterface, SolValue}; use foundry_common::{fmt::ConsoleFmt, ErrorExt}; use foundry_evm_core::{ @@ -70,6 +70,9 @@ impl Inspector for LogCollector { fn convert_hh_log_to_event(call: HardhatConsole::HardhatConsoleCalls) -> Log { // Convert the parameters of the call to their string representation using `ConsoleFmt`. let fmt = call.fmt(Default::default()); - Log::new(Address::default(), vec![Console::log::SIGNATURE_HASH], fmt.abi_encode().into()) - .unwrap_or_else(|| Log { ..Default::default() }) + Log::new_unchecked( + HARDHAT_CONSOLE_ADDRESS, + vec![Console::log::SIGNATURE_HASH], + fmt.abi_encode().into(), + ) } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 52949e8e194ea..c8497d93c896c 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -192,31 +192,25 @@ impl InspectorStackBuilder { /// dispatch. #[macro_export] macro_rules! call_inspectors { - ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr $(,)?) => {{$( - if let Some($id) = $inspector { - $call - } - )+}} + ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr $(,)?) => { + $( + if let Some($id) = $inspector { + $call + } + )+ + } } /// Same as [call_inspectors] macro, but with depth adjustment for isolated execution. macro_rules! call_inspectors_adjust_depth { (#[no_ret] [$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { - if $self.in_inner_context { - $data.journaled_state.depth += 1; - $( - if let Some($id) = $inspector { - $call - } - )+ - $data.journaled_state.depth -= 1; - } else { - $( - if let Some($id) = $inspector { - $call - } - )+ - } + $data.journaled_state.depth += $self.in_inner_context as usize; + $( + if let Some($id) = $inspector { + $call + } + )+ + $data.journaled_state.depth -= $self.in_inner_context as usize; }; ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { if $self.in_inner_context { @@ -303,6 +297,27 @@ impl InspectorStack { Self::default() } + /// Logs the status of the inspectors. + pub fn log_status(&self) { + trace!(enabled=%{ + let mut enabled = Vec::with_capacity(16); + macro_rules! push { + ($($id:ident),* $(,)?) => { + $( + if self.$id.is_some() { + enabled.push(stringify!($id)); + } + )* + }; + } + push!(cheatcodes, chisel_state, coverage, debugger, fuzzer, log_collector, printer, tracer); + if self.enable_isolation { + enabled.push("isolation"); + } + format!("[{}]", enabled.join(", ")) + }); + } + /// Set variables from an environment for the relevant inspectors. #[inline] pub fn set_env(&mut self, env: &Env) { @@ -624,7 +639,7 @@ impl Inspector<&mut DB> for InspectorStack { fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( #[no_ret] - [&mut self.tracer, &mut self.cheatcodes, &mut self.chisel_state, &mut self.printer], + [&mut self.tracer, &mut self.chisel_state, &mut self.printer], |inspector| inspector.step_end(interpreter, ecx), self, ecx From 41a6945ca3ef8139ee15c2c52986b085792be7fa Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 14 Jun 2024 23:06:06 +0300 Subject: [PATCH 1092/1963] feat(invariant): introduce `afterInvariant` function (#8106) * feat(invariant): introduce tearDown function * Add Tests * Fix tests * tearDown -> afterInvariant refactor * Group has_invariants with tmp_tracing --- crates/common/src/traits.rs | 15 +++++ .../evm/evm/src/executors/invariant/error.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 44 ++++++++++++++- .../evm/evm/src/executors/invariant/replay.rs | 27 +++++++-- .../evm/evm/src/executors/invariant/result.rs | 46 ++++++++++++---- .../evm/evm/src/executors/invariant/shrink.rs | 29 +++++++--- crates/evm/fuzz/src/invariant/mod.rs | 2 + crates/forge/src/runner.rs | 44 ++++++++++++--- crates/forge/tests/it/core.rs | 14 +++++ crates/forge/tests/it/invariant.rs | 55 +++++++++++++++++++ .../default/core/BadSigAfterInvariant.t.sol | 12 ++++ .../default/core/MultipleAfterInvariant.t.sol | 14 +++++ .../common/InvariantAfterInvariant.t.sol | 55 +++++++++++++++++++ 13 files changed, 324 insertions(+), 35 deletions(-) create mode 100644 testdata/default/core/BadSigAfterInvariant.t.sol create mode 100644 testdata/default/core/MultipleAfterInvariant.t.sol create mode 100644 testdata/default/fuzz/invariant/common/InvariantAfterInvariant.t.sol diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index 8ed1edbec304d..64d27563eba6e 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -34,6 +34,9 @@ pub trait TestFunctionExt { /// Returns whether this function is a `setUp` function. fn is_setup(&self) -> bool; + /// Returns whether this function is `afterInvariant` function. + fn is_after_invariant(&self) -> bool; + /// Returns whether this function is a fixture function. fn is_fixture(&self) -> bool; } @@ -60,6 +63,10 @@ impl TestFunctionExt for Function { self.name.is_setup() } + fn is_after_invariant(&self) -> bool { + self.name.is_after_invariant() + } + fn is_fixture(&self) -> bool { self.name.is_fixture() } @@ -86,6 +93,10 @@ impl TestFunctionExt for String { self.as_str().is_setup() } + fn is_after_invariant(&self) -> bool { + self.as_str().is_after_invariant() + } + fn is_fixture(&self) -> bool { self.as_str().is_fixture() } @@ -112,6 +123,10 @@ impl TestFunctionExt for str { self.eq_ignore_ascii_case("setup") } + fn is_after_invariant(&self) -> bool { + self.eq_ignore_ascii_case("afterinvariant") + } + fn is_fixture(&self) -> bool { self.starts_with("fixture") } diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 74f8d92ccf19c..22d751ed5b02c 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -88,7 +88,7 @@ impl FailedInvariantCaseData { debug_assert!(func.inputs.is_empty()); let origin = func.name.as_str(); Self { - test_error: proptest::test_runner::TestError::Fail( + test_error: TestError::Fail( format!("{origin}, reason: {revert_reason}").into(), calldata.to_vec(), ), diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 11291f1737f3c..4cbd8505d55b2 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -2,7 +2,7 @@ use crate::{ executors::{Executor, RawCallResult}, inspectors::Fuzzer, }; -use alloy_primitives::{Address, FixedBytes, Selector, U256}; +use alloy_primitives::{Address, Bytes, FixedBytes, Selector, U256}; use alloy_sol_types::{sol, SolCall}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; @@ -28,7 +28,7 @@ use proptest::{ strategy::{Strategy, ValueTree}, test_runner::{TestCaseError, TestRunner}, }; -use result::{assert_invariants, can_continue}; +use result::{assert_after_invariant, assert_invariants, can_continue}; use revm::primitives::HashMap; use shrink::shrink_sequence; use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; @@ -43,6 +43,7 @@ mod result; pub use result::InvariantFuzzTestResult; mod shrink; +use crate::executors::EvmError; pub use shrink::check_sequence; sol! { @@ -65,6 +66,8 @@ sol! { string[] artifacts; } + function afterInvariant() external; + #[derive(Default)] function excludeArtifacts() public view returns (string[] memory excludedArtifacts); @@ -302,6 +305,19 @@ impl<'a> InvariantExecutor<'a> { ); } + // Call `afterInvariant` only if it is declared and test didn't fail already. + if invariant_contract.call_after_invariant && failures.borrow().error.is_none() { + assert_after_invariant( + &invariant_contract, + &self.config, + &targeted_contracts, + &mut executor, + &mut failures.borrow_mut(), + &inputs, + ) + .map_err(|_| TestCaseError::Fail("Failed to call afterInvariant".into()))?; + } + // We clear all the targeted contracts created during this run. if !created_contracts.is_empty() { let mut writable_targeted = targeted_contracts.targets.lock(); @@ -690,3 +706,27 @@ fn collect_data( state_changeset.insert(tx.sender, changed); } } + +/// Calls the `afterInvariant()` function on a contract. +/// Returns call result and if call succeeded. +/// The state after the call is not persisted. +pub(crate) fn call_after_invariant_function( + executor: &Executor, + to: Address, +) -> std::result::Result<(RawCallResult, bool), EvmError> { + let calldata = Bytes::from_static(&IInvariantTest::afterInvariantCall::SELECTOR); + let mut call_result = executor.call_raw(CALLER, to, calldata, U256::ZERO)?; + let success = executor.is_raw_call_mut_success(to, &mut call_result, false); + Ok((call_result, success)) +} + +/// Calls the invariant function and returns call result and if succeeded. +pub(crate) fn call_invariant_function( + executor: &Executor, + address: Address, + calldata: Bytes, +) -> Result<(RawCallResult, bool)> { + let mut call_result = executor.call_raw(CALLER, address, calldata, U256::ZERO)?; + let success = executor.is_raw_call_mut_success(address, &mut call_result, false); + Ok((call_result, success)) +} diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index c21c26030588d..d3d974d29e86f 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -1,10 +1,12 @@ -use super::{error::FailedInvariantCaseData, shrink_sequence}; +use super::{ + call_after_invariant_function, call_invariant_function, error::FailedInvariantCaseData, + shrink_sequence, +}; use crate::executors::Executor; use alloy_dyn_abi::JsonAbiExt; use alloy_primitives::Log; use eyre::Result; use foundry_common::{ContractsByAddress, ContractsByArtifact}; -use foundry_evm_core::constants::CALLER; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ invariant::{BasicTxDetails, InvariantContract}, @@ -75,15 +77,22 @@ pub fn replay_run( // Checking after each call doesn't add valuable info for passing scenario // (invariant call result is always success) nor for failed scenarios // (invariant call result is always success until the last call that breaks it). - let invariant_result = executor.call_raw( - CALLER, + let (invariant_result, invariant_success) = call_invariant_function( + &executor, invariant_contract.address, invariant_contract.invariant_function.abi_encode_input(&[])?.into(), - U256::ZERO, )?; traces.push((TraceKind::Execution, invariant_result.traces.clone().unwrap())); logs.extend(invariant_result.logs); + // Collect after invariant logs and traces. + if invariant_contract.call_after_invariant && invariant_success { + let (after_invariant_result, _) = + call_after_invariant_function(&executor, invariant_contract.address)?; + traces.push((TraceKind::Execution, after_invariant_result.traces.clone().unwrap())); + logs.extend(after_invariant_result.logs); + } + Ok(counterexample_sequence) } @@ -105,7 +114,13 @@ pub fn replay_error( TestError::Abort(_) => Ok(vec![]), TestError::Fail(_, ref calls) => { // Shrink sequence of failed calls. - let calls = shrink_sequence(failed_case, calls, &executor, progress)?; + let calls = shrink_sequence( + failed_case, + calls, + &executor, + invariant_contract.call_after_invariant, + progress, + )?; set_up_inner_replay(&mut executor, &failed_case.inner_sequence); diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index 9b3103b3d2fe0..5ddcccaf0d3f1 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -1,14 +1,16 @@ -use super::{error::FailedInvariantCaseData, InvariantFailures, InvariantFuzzError}; +use super::{ + call_after_invariant_function, call_invariant_function, error::FailedInvariantCaseData, + InvariantFailures, InvariantFuzzError, +}; use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use eyre::Result; use foundry_config::InvariantConfig; -use foundry_evm_core::{constants::CALLER, utils::StateChangeset}; +use foundry_evm_core::utils::StateChangeset; use foundry_evm_fuzz::{ invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract}, FuzzedCases, }; -use revm::primitives::U256; use revm_inspectors::tracing::CallTraceArena; use std::borrow::Cow; @@ -60,16 +62,11 @@ pub(crate) fn assert_invariants( } } - let func = invariant_contract.invariant_function; - let mut call_result = executor.call_raw( - CALLER, + let (call_result, success) = call_invariant_function( + executor, invariant_contract.address, - func.abi_encode_input(&[])?.into(), - U256::ZERO, + invariant_contract.invariant_function.abi_encode_input(&[])?.into(), )?; - - let success = - executor.is_raw_call_mut_success(invariant_contract.address, &mut call_result, false); if !success { // We only care about invariants which we haven't broken yet. if invariant_failures.error.is_none() { @@ -151,3 +148,30 @@ pub(crate) fn can_continue( } Ok(RichInvariantResults::new(true, call_results)) } + +/// Given the executor state, asserts conditions within `afterInvariant` function. +/// If call fails then the invariant test is considered failed. +pub(crate) fn assert_after_invariant( + invariant_contract: &InvariantContract<'_>, + invariant_config: &InvariantConfig, + targeted_contracts: &FuzzRunIdentifiedContracts, + executor: &mut Executor, + invariant_failures: &mut InvariantFailures, + inputs: &[BasicTxDetails], +) -> Result { + let (call_result, success) = + call_after_invariant_function(executor, invariant_contract.address)?; + // Fail the test case if `afterInvariant` doesn't succeed. + if !success { + let case_data = FailedInvariantCaseData::new( + invariant_contract, + invariant_config, + targeted_contracts, + inputs, + call_result, + &[], + ); + invariant_failures.error = Some(InvariantFuzzError::BrokenInvariant(case_data)); + } + Ok(success) +} diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index 169955551bea1..5559ec821724d 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -1,6 +1,10 @@ -use crate::executors::{invariant::error::FailedInvariantCaseData, Executor}; +use crate::executors::{ + invariant::{ + call_after_invariant_function, call_invariant_function, error::FailedInvariantCaseData, + }, + Executor, +}; use alloy_primitives::{Address, Bytes, U256}; -use foundry_evm_core::constants::CALLER; use foundry_evm_fuzz::invariant::BasicTxDetails; use indicatif::ProgressBar; use proptest::bits::{BitSetLike, VarBitSet}; @@ -84,6 +88,7 @@ pub(crate) fn shrink_sequence( failed_case: &FailedInvariantCaseData, calls: &[BasicTxDetails], executor: &Executor, + call_after_invariant: bool, progress: Option<&ProgressBar>, ) -> eyre::Result> { trace!(target: "forge::test", "Shrinking sequence of {} calls.", calls.len()); @@ -97,9 +102,9 @@ pub(crate) fn shrink_sequence( // Special case test: the invariant is *unsatisfiable* - it took 0 calls to // break the invariant -- consider emitting a warning. - let error_call_result = - executor.call_raw(CALLER, failed_case.addr, failed_case.calldata.clone(), U256::ZERO)?; - if error_call_result.reverted { + let (_, success) = + call_invariant_function(executor, failed_case.addr, failed_case.calldata.clone())?; + if !success { return Ok(vec![]); } @@ -113,6 +118,7 @@ pub(crate) fn shrink_sequence( failed_case.addr, failed_case.calldata.clone(), failed_case.fail_on_revert, + call_after_invariant, ) { // If candidate sequence still fails then shrink more if possible. Ok((false, _)) if !shrinker.simplify() => break, @@ -133,7 +139,8 @@ pub(crate) fn shrink_sequence( /// Checks if the given call sequence breaks the invariant. /// Used in shrinking phase for checking candidate sequences and in replay failures phase to test /// persisted failures. -/// Returns the result of invariant check and if sequence was entirely applied. +/// Returns the result of invariant check (and afterInvariant call if needed) and if sequence was +/// entirely applied. pub fn check_sequence( mut executor: Executor, calls: &[BasicTxDetails], @@ -141,6 +148,7 @@ pub fn check_sequence( test_address: Address, calldata: Bytes, fail_on_revert: bool, + call_after_invariant: bool, ) -> eyre::Result<(bool, bool)> { // Apply the call sequence. for call_index in sequence { @@ -159,7 +167,12 @@ pub fn check_sequence( } // Check the invariant for call sequence. - let mut call_result = executor.call_raw(CALLER, test_address, calldata, U256::ZERO)?; - let success = executor.is_raw_call_mut_success(test_address, &mut call_result, false); + let (_, mut success) = call_invariant_function(&executor, test_address, calldata)?; + // Check after invariant result if invariant is success and `afterInvariant` function is + // declared. + if success && call_after_invariant { + (_, success) = call_after_invariant_function(&executor, test_address)?; + } + Ok((success, true)) } diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index e83c595498d29..26c94351e2dd7 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -71,6 +71,8 @@ pub struct InvariantContract<'a> { pub address: Address, /// Invariant function present in the test contract. pub invariant_function: &'a Function, + /// If true, `afterInvariant` function is called after each invariant run. + pub call_after_invariant: bool, /// ABI of the test contract. pub abi: &'a JsonAbi, } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index fe4a675e8c8b8..ffd22bf10b6e4 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -283,12 +283,10 @@ impl<'a> ContractRunner<'a> { let start = Instant::now(); let mut warnings = Vec::new(); + // Check if `setUp` function with valid signature declared. let setup_fns: Vec<_> = self.contract.abi.functions().filter(|func| func.name.is_setup()).collect(); - - // Whether to call the `setUp` function. let call_setup = setup_fns.len() == 1 && setup_fns[0].name == "setUp"; - // There is a single miss-cased `setUp` function, so we add a warning for &setup_fn in setup_fns.iter() { if setup_fn.name != "setUp" { @@ -298,7 +296,6 @@ impl<'a> ContractRunner<'a> { )); } } - // There are multiple setUp function, so we return a single test result for `setUp` if setup_fns.len() > 1 { return SuiteResult::new( @@ -309,9 +306,34 @@ impl<'a> ContractRunner<'a> { ) } - let has_invariants = self.contract.abi.functions().any(|func| func.is_invariant_test()); + // Check if `afterInvariant` function with valid signature declared. + let after_invariant_fns: Vec<_> = + self.contract.abi.functions().filter(|func| func.name.is_after_invariant()).collect(); + if after_invariant_fns.len() > 1 { + // Return a single test result failure if multiple functions declared. + return SuiteResult::new( + start.elapsed(), + [( + "afterInvariant()".to_string(), + TestResult::fail("multiple afterInvariant functions".to_string()), + )] + .into(), + warnings, + ) + } + let call_after_invariant = after_invariant_fns.first().map_or(false, |after_invariant_fn| { + let match_sig = after_invariant_fn.name == "afterInvariant"; + if !match_sig { + warnings.push(format!( + "Found invalid afterInvariant function \"{}\" did you mean \"afterInvariant()\"?", + after_invariant_fn.signature() + )); + } + match_sig + }); // Invariant testing requires tracing to figure out what contracts were created. + let has_invariants = self.contract.abi.functions().any(|func| func.is_invariant_test()); let tmp_tracing = self.executor.inspector.tracer.is_none() && has_invariants && call_setup; if tmp_tracing { self.executor.set_tracing(true); @@ -392,6 +414,7 @@ impl<'a> ContractRunner<'a> { setup, invariant_config.clone(), func, + call_after_invariant, &known_contracts, identified_contracts.as_ref().unwrap(), ) @@ -511,12 +534,14 @@ impl<'a> ContractRunner<'a> { } #[instrument(level = "debug", name = "invariant", skip_all)] + #[allow(clippy::too_many_arguments)] pub fn run_invariant_test( &self, runner: TestRunner, setup: TestSetup, invariant_config: InvariantConfig, func: &Function, + call_after_invariant: bool, known_contracts: &ContractsByArtifact, identified_contracts: &ContractsByAddress, ) -> TestResult { @@ -551,8 +576,12 @@ impl<'a> ContractRunner<'a> { identified_contracts, known_contracts, ); - let invariant_contract = - InvariantContract { address, invariant_function: func, abi: &self.contract.abi }; + let invariant_contract = InvariantContract { + address, + invariant_function: func, + call_after_invariant, + abi: &self.contract.abi, + }; let mut logs = logs.clone(); let mut traces = traces.clone(); @@ -584,6 +613,7 @@ impl<'a> ContractRunner<'a> { invariant_contract.address, invariant_contract.invariant_function.selector().to_vec().into(), invariant_config.fail_on_revert, + invariant_contract.call_after_invariant, ) { if !success { // If sequence still fails then replay error to collect traces and diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index b229f151f2d3b..4c6fae77c5aaf 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -75,6 +75,20 @@ async fn test_core() { None, )], ), + ( + "default/core/MultipleAfterInvariant.t.sol:MultipleAfterInvariant", + vec![( + "afterInvariant()", + false, + Some("multiple afterInvariant functions".to_string()), + None, + None, + )], + ), + ( + "default/core/BadSigAfterInvariant.t.sol:BadSigAfterInvariant", + vec![("testShouldPassWithWarning()", true, None, None, None)], + ), ]), ); } diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index fbd906d0ca0f9..f2a8d69f93e31 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -27,6 +27,7 @@ macro_rules! get_counterexample { async fn test_invariant() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"); let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options = TEST_DATA_DEFAULT.test_opts.clone(); runner.test_options.invariant.failure_persist_dir = Some(tempfile::tempdir().unwrap().into_path()); let results = runner.test_collect(&filter); @@ -243,6 +244,26 @@ async fn test_invariant() { ( "default/fuzz/invariant/common/InvariantExcludedSenders.t.sol:InvariantExcludedSendersTest", vec![("invariant_check_sender()", true, None, None, None)], + ), + ( + "default/fuzz/invariant/common/InvariantAfterInvariant.t.sol:InvariantAfterInvariantTest", + vec![ + ( + "invariant_after_invariant_failure()", + false, + Some("revert: afterInvariant failure".into()), + None, + None, + ), + ( + "invariant_failure()", + false, + Some("revert: invariant failure".into()), + None, + None, + ), + ("invariant_success()", true, None, None, None), + ], ) ]), ); @@ -710,3 +731,37 @@ async fn test_invariant_excluded_senders() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_after_invariant() { + // Check failure on passing invariant and failed `afterInvariant` condition + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAfterInvariant.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.failure_persist_dir = + Some(tempfile::tempdir().unwrap().into_path()); + + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantAfterInvariant.t.sol:InvariantAfterInvariantTest", + vec![ + ( + "invariant_after_invariant_failure()", + false, + Some("revert: afterInvariant failure".into()), + None, + None, + ), + ( + "invariant_failure()", + false, + Some("revert: invariant failure".into()), + None, + None, + ), + ("invariant_success()", true, None, None, None), + ], + )]), + ); +} diff --git a/testdata/default/core/BadSigAfterInvariant.t.sol b/testdata/default/core/BadSigAfterInvariant.t.sol new file mode 100644 index 0000000000000..6d303b04b380e --- /dev/null +++ b/testdata/default/core/BadSigAfterInvariant.t.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +contract BadSigAfterInvariant is DSTest { + function afterinvariant() public {} + + function testShouldPassWithWarning() public { + assert(true); + } +} diff --git a/testdata/default/core/MultipleAfterInvariant.t.sol b/testdata/default/core/MultipleAfterInvariant.t.sol new file mode 100644 index 0000000000000..446e76cbb3320 --- /dev/null +++ b/testdata/default/core/MultipleAfterInvariant.t.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +contract MultipleAfterInvariant is DSTest { + function afterInvariant() public {} + + function afterinvariant() public {} + + function testFailShouldBeMarkedAsFailedBecauseOfAfterInvariant() public { + assert(true); + } +} diff --git a/testdata/default/fuzz/invariant/common/InvariantAfterInvariant.t.sol b/testdata/default/fuzz/invariant/common/InvariantAfterInvariant.t.sol new file mode 100644 index 0000000000000..3030b43e077cc --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantAfterInvariant.t.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; + +struct FuzzSelector { + address addr; + bytes4[] selectors; +} + +contract AfterInvariantHandler { + uint256 public count; + + function inc() external { + count += 1; + } +} + +contract InvariantAfterInvariantTest is DSTest { + AfterInvariantHandler handler; + + function setUp() public { + handler = new AfterInvariantHandler(); + } + + function targetSelectors() public returns (FuzzSelector[] memory) { + FuzzSelector[] memory targets = new FuzzSelector[](1); + bytes4[] memory selectors = new bytes4[](1); + selectors[0] = handler.inc.selector; + targets[0] = FuzzSelector(address(handler), selectors); + return targets; + } + + function afterInvariant() public { + require(handler.count() < 10, "afterInvariant failure"); + } + + /// forge-config: default.invariant.runs = 1 + /// forge-config: default.invariant.depth = 11 + function invariant_after_invariant_failure() public view { + require(handler.count() < 20, "invariant after invariant failure"); + } + + /// forge-config: default.invariant.runs = 1 + /// forge-config: default.invariant.depth = 11 + function invariant_failure() public view { + require(handler.count() < 9, "invariant failure"); + } + + /// forge-config: default.invariant.runs = 1 + /// forge-config: default.invariant.depth = 5 + function invariant_success() public view { + require(handler.count() < 11, "invariant should not fail"); + } +} From 47b2ce24bd1dc4abba6424b06387f5bd424caa7a Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:08:48 +0530 Subject: [PATCH 1093/1963] fix(forge-bind): allow attrs and mod single_file imports (#8171) * fix(forge-bind): allow attrs and mod single_file imports * fmt nit * allow rustdoc::all * fix: file consistenct check * fix clippy --- crates/anvil/tests/it/main.rs | 1 + crates/sol-macro-gen/src/sol_macro_gen.rs | 88 +++++++++-------------- 2 files changed, 34 insertions(+), 55 deletions(-) diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 5337e5bbd30b0..559593b72f641 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -1,3 +1,4 @@ +#![allow(clippy::octal_escapes)] mod abi; mod anvil; mod anvil_api; diff --git a/crates/sol-macro-gen/src/sol_macro_gen.rs b/crates/sol-macro-gen/src/sol_macro_gen.rs index 6ef48f8cb0e5c..7867b6673415b 100644 --- a/crates/sol-macro-gen/src/sol_macro_gen.rs +++ b/crates/sol-macro-gen/src/sol_macro_gen.rs @@ -130,22 +130,15 @@ edition = "2021" fs::write(cargo_toml_path, toml_contents).wrap_err("Failed to write Cargo.toml")?; let mut lib_contents = String::new(); - if single_file { - write!( - &mut lib_contents, - r#"#![allow(unused_imports, clippy::all)] - //! This module contains the sol! generated bindings for solidity contracts. - //! This is autogenerated code. - //! Do not manually edit these files. - //! These files may be overwritten by the codegen system at any time."# - )?; - } else { - write!( - &mut lib_contents, - r#"#![allow(unused_imports)] - "# - )?; - }; + write!( + &mut lib_contents, + r#"#![allow(unused_imports, clippy::all, rustdoc::all)] + //! This module contains the sol! generated bindings for solidity contracts. + //! This is autogenerated code. + //! Do not manually edit these files. + //! These files may be overwritten by the codegen system at any time. + "# + )?; // Write src for instance in &self.instances { @@ -179,7 +172,7 @@ edition = "2021" let _ = fs::create_dir_all(bindings_path); - let mut mod_contents = r#"#![allow(clippy::all)] + let mut mod_contents = r#"#![allow(unused_imports, clippy::all, rustdoc::all)] //! This module contains the sol! generated bindings for solidity contracts. //! This is autogenerated code. //! Do not manually edit these files. @@ -190,16 +183,14 @@ edition = "2021" for instance in &self.instances { let name = instance.name.to_lowercase(); if !single_file { + // Module write!( mod_contents, r#"pub mod {}; "#, instance.name.to_lowercase() )?; - let mut contents = - r#"//! This module was autogenerated by the alloy sol!. - //! More information can be found here . - "#.to_string(); + let mut contents = String::new(); write!(contents, "{}", instance.expansion.as_ref().unwrap())?; let file = syn::parse_file(&contents)?; @@ -208,13 +199,8 @@ edition = "2021" fs::write(bindings_path.join(format!("{}.rs", name)), contents) .wrap_err("Failed to write file")?; } else { - let mut contents = format!( - r#"//! This module was autogenerated by the alloy sol!. - //! More information can be found here . - pub use {}::*; - "#, - name - ); + // Single File + let mut contents = String::new(); write!(contents, "{}\n\n", instance.expansion.as_ref().unwrap())?; write!(mod_contents, "{}", contents)?; } @@ -250,29 +236,23 @@ edition = "2021" } let mut super_contents = String::new(); - if is_mod { - // mod.rs - write!( - &mut super_contents, - r#"#![allow(clippy::all)] - //! This module contains the sol! generated bindings for solidity contracts. - //! This is autogenerated code. - //! Do not manually edit these files. - //! These files may be overwritten by the codegen system at any time. - "# - )?; - } else { - // lib.rs - write!( - &mut super_contents, - r#"#![allow(unused_imports)] + write!( + &mut super_contents, + r#"#![allow(unused_imports, clippy::all, rustdoc::all)] + //! This module contains the sol! generated bindings for solidity contracts. + //! This is autogenerated code. + //! Do not manually edit these files. + //! These files may be overwritten by the codegen system at any time. "# - )?; - }; + )?; if !single_file { for instance in &self.instances { let name = instance.name.to_lowercase(); - let path = crate_path.join(format!("src/{}.rs", name)); + let path = if is_mod { + crate_path.join(format!("{}.rs", name)) + } else { + crate_path.join(format!("src/{}.rs", name)) + }; let tokens = instance .expansion .as_ref() @@ -281,18 +261,16 @@ edition = "2021" self.check_file_contents(&path, &tokens)?; - if !is_mod { - write!( - &mut super_contents, - r#"pub mod {}; + write!( + &mut super_contents, + r#"pub mod {}; "#, - name - )?; - } + name + )?; } let super_path = - if is_mod { crate_path.join("src/mod.rs") } else { crate_path.join("src/lib.rs") }; + if is_mod { crate_path.join("mod.rs") } else { crate_path.join("src/lib.rs") }; self.check_file_contents(&super_path, &super_contents)?; } From fd878884eda640c2cc59a7fa66aef9288846ef0e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:51:40 +0200 Subject: [PATCH 1094/1963] chore(deps): weekly `cargo update` (#8172) * chore(deps): weekly `cargo update` Updating git repository `https://github.com/bluealloy/revm.git` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/paradigmxyz/revm-inspectors` Locking 45 packages to latest compatible versions Updating alloy-chains v0.1.18 -> v0.1.20 Updating aws-runtime v1.2.2 -> v1.2.3 Updating aws-sigv4 v1.2.1 -> v1.2.2 Updating aws-smithy-runtime-api v1.6.2 -> v1.7.0 Updating aws-smithy-types v1.1.10 -> v1.2.0 Updating clap v4.5.6 -> v4.5.7 Updating clap_builder v4.5.6 -> v4.5.7 Updating derive_more v0.99.17 -> v0.99.18 Updating fs4 v0.8.3 -> v0.8.4 Updating http-body-util v0.1.1 -> v0.1.2 Updating httparse v1.8.0 -> v1.9.3 Adding icu_collections v1.5.0 Adding icu_locid v1.5.0 Adding icu_locid_transform v1.5.0 Adding icu_locid_transform_data v1.5.0 Adding icu_normalizer v1.5.0 Adding icu_normalizer_data v1.5.0 Adding icu_properties v1.5.0 Adding icu_properties_data v1.5.0 Adding icu_provider v1.5.0 Adding icu_provider_macros v1.5.0 Updating idna v0.5.0 -> v1.0.0 Updating interprocess v2.1.1 -> v2.2.0 Adding litemap v0.7.3 Updating memchr v2.7.2 -> v2.7.4 Updating redox_syscall v0.5.1 -> v0.5.2 Updating regex v1.10.4 -> v1.10.5 Updating regex-automata v0.4.6 -> v0.4.7 Updating regex-lite v0.1.5 -> v0.1.6 Updating regex-syntax v0.8.3 -> v0.8.4 Updating rustls v0.23.9 -> v0.23.10 Adding stable_deref_trait v1.2.0 Adding synstructure v0.13.1 Adding tinystr v0.7.6 Removing unicode-bidi v0.3.15 Updating url v2.5.0 -> v2.5.1 Adding utf16_iter v1.0.5 Adding utf8_iter v1.0.4 Adding write16 v1.0.0 Adding writeable v0.5.5 Adding yoke v0.7.4 Adding yoke-derive v0.7.4 Adding zerofrom v0.1.4 Adding zerofrom-derive v0.1.4 Adding zerovec v0.10.2 Adding zerovec-derive v0.10.2 note: pass `--verbose` to see 158 unchanged dependencies behind latest * allow unicode --------- Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> Co-authored-by: Matthias Seitz --- Cargo.lock | 374 +++++++++++++++++++++++++++++++++++++++++++---------- deny.toml | 1 + 2 files changed, 307 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 596b73f95ab85..1865177e6cd71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.18" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fd095a9d70f4b1c5c102c84a4c782867a5c6416dbf6dcd42a63e7c7a89d3c8" +checksum = "d2feb5f466b3a786d5a622d8926418bc6a0d38bf632909f6ee9298a4a1d8c6e0" dependencies = [ "num_enum", "serde", @@ -626,7 +626,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.9", + "rustls 0.23.10", "serde_json", "tokio", "tokio-tungstenite 0.23.0", @@ -1181,9 +1181,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75588e7ee5e8496eed939adac2035a6dbab9f7eb2acdd9ab2d31856dab6f3955" +checksum = "36978815abdd7297662bf906adff132941a02ecf425bc78fac7d90653ce87560" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1293,9 +1293,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58b56f1cbe6fd4d0c2573df72868f20ab1c125ca9c9dbce17927a463433a2e57" +checksum = "31eed8d45759b2c5fe7fd304dd70739060e9e0de509209036eabea14d0720cce" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1392,9 +1392,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.6.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4179bd8a1c943e1aceb46c5b9fc014a561bd6c35a2153e816ba29076ee49d245" +checksum = "1b570ea39eb95bd32543f6e4032bce172cb6209b9bc8c83c770d08169e875afc" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1409,9 +1409,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.1.10" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6764ba7e1c5ede1c9f9e4046645534f06c2581402461c559b481a420330a83" +checksum = "cfe321a6b21f5d8eabd0ade9c55d3d0335f3c3157fc2b3e87f05f34b539e4df5" dependencies = [ "base64-simd", "bytes", @@ -1711,7 +1711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", - "regex-automata 0.4.6", + "regex-automata 0.4.7", "serde", ] @@ -2033,9 +2033,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -2043,9 +2043,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -2633,15 +2633,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -3929,9 +3929,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "fs4" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73969b81e8bc90a3828d913dd3973d80771bfb9d7fbe1a78a79122aad456af15" +checksum = "f7e180ac76c23b45e767bd7ae9579bc0bb458618c4bc71835926e098e61d15f8" dependencies = [ "rustix", "windows-sys 0.52.0", @@ -4369,8 +4369,8 @@ dependencies = [ "aho-corasick", "bstr 1.9.1", "log", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -4560,12 +4560,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http 1.1.0", "http-body 1.0.0", "pin-project-lite", @@ -4579,9 +4579,9 @@ checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a" [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" [[package]] name = "httpdate" @@ -4753,6 +4753,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -4761,12 +4879,14 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", + "smallvec", + "utf8_iter", ] [[package]] @@ -4779,7 +4899,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.6", + "regex-automata 0.4.7", "same-file", "walkdir", "winapi-util", @@ -4926,9 +5046,9 @@ dependencies = [ [[package]] name = "interprocess" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13f2533e1f1a70bec71ea7a85d1c0a4dab141c314035ce76e51a19a2f48be708" +checksum = "67bafc2f5dbdad79a6d925649758d5472647b416028099f0b829d1b67fdd47d3" dependencies = [ "doctest-file", "futures-core", @@ -5114,7 +5234,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", "string_cache", "term", "tiny-keccak", @@ -5128,7 +5248,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.6", + "regex-automata 0.4.7", ] [[package]] @@ -5190,6 +5310,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -5302,9 +5428,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -5878,7 +6004,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.5", ] @@ -6371,7 +6497,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", "rusty-fork", "tempfile", "unarray", @@ -6405,7 +6531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.12.1", "proc-macro2", "quote", "syn 2.0.66", @@ -6594,9 +6720,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -6614,14 +6740,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -6635,20 +6761,20 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] name = "regex-lite" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "regex-syntax" @@ -6658,9 +6784,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" @@ -7027,9 +7153,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.9" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ "once_cell", "ring", @@ -7772,6 +7898,12 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -7942,6 +8074,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -8133,6 +8276,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -8235,7 +8388,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.9", + "rustls 0.23.10", "rustls-pki-types", "tokio", ] @@ -8272,7 +8425,7 @@ checksum = "becd34a233e7e31a3dbf7c7241b38320f57393dcae8e7324b0167d21b8e320b0" dependencies = [ "futures-util", "log", - "rustls 0.23.9", + "rustls 0.23.10", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -8578,7 +8731,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.9", + "rustls 0.23.10", "rustls-pki-types", "sha1", "thiserror", @@ -8634,12 +8787,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-bom" version = "2.0.3" @@ -8697,9 +8844,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" dependencies = [ "form_urlencoded", "idna", @@ -8718,6 +8865,18 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -9270,6 +9429,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -9313,6 +9484,30 @@ dependencies = [ "is-terminal", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.34" @@ -9333,6 +9528,27 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -9353,6 +9569,28 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "zerovec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "zip" version = "0.6.6" diff --git a/deny.toml b/deny.toml index d585fd650a994..fa335ee73a584 100644 --- a/deny.toml +++ b/deny.toml @@ -40,6 +40,7 @@ allow = [ "ISC", "Unicode-DFS-2016", "OpenSSL", + "Unicode-3.0", "Unlicense", "WTFPL", "BSL-1.0", From 76e23be0f11b08b6e2fe10b6537ee6a5c4de4f67 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:40:09 +0200 Subject: [PATCH 1095/1963] chore(deps): bump alloy, revm (#8177) * chore(deps): bump alloy, revm * doctests --- Cargo.lock | 111 +++++++++++-------- Cargo.toml | 58 +++++----- crates/anvil/Cargo.toml | 14 ++- crates/anvil/core/src/eth/mod.rs | 3 +- crates/anvil/core/src/eth/transaction/mod.rs | 5 +- crates/anvil/src/cmd.rs | 2 +- crates/anvil/src/config.rs | 18 +-- crates/anvil/src/eth/api.rs | 3 +- crates/anvil/src/eth/backend/fork.rs | 3 +- crates/anvil/src/eth/backend/mem/mod.rs | 3 +- crates/anvil/src/eth/error.rs | 1 + crates/anvil/src/eth/otterscan/types.rs | 3 +- crates/anvil/src/eth/sign.rs | 6 +- crates/anvil/src/evm.rs | 4 +- crates/anvil/src/lib.rs | 6 +- crates/anvil/tests/it/anvil_api.rs | 7 +- crates/anvil/tests/it/api.rs | 17 +-- crates/anvil/tests/it/eip4844.rs | 3 +- crates/anvil/tests/it/fork.rs | 17 +-- crates/anvil/tests/it/gas.rs | 11 +- crates/anvil/tests/it/logs.rs | 8 +- crates/anvil/tests/it/optimism.rs | 9 +- crates/anvil/tests/it/otterscan.rs | 3 +- crates/anvil/tests/it/pubsub.rs | 13 ++- crates/anvil/tests/it/revert.rs | 3 +- crates/anvil/tests/it/sign.rs | 9 +- crates/anvil/tests/it/traces.rs | 9 +- crates/anvil/tests/it/transaction.rs | 6 +- crates/anvil/tests/it/txpool.rs | 3 +- crates/anvil/tests/it/utils.rs | 26 +++-- crates/cast/Cargo.toml | 17 +-- crates/cast/bin/cmd/mktx.rs | 4 +- crates/cast/bin/cmd/send.rs | 9 +- crates/cast/bin/cmd/wallet/mod.rs | 38 ++++--- crates/cast/bin/cmd/wallet/vanity.rs | 16 +-- crates/cast/bin/tx.rs | 3 +- crates/cast/src/lib.rs | 12 +- crates/cheatcodes/Cargo.toml | 2 +- crates/cheatcodes/src/error.rs | 4 +- crates/cheatcodes/src/script.rs | 6 +- crates/cheatcodes/src/utils.rs | 10 +- crates/common/Cargo.toml | 31 ++++-- crates/common/src/fmt/ui.rs | 4 +- crates/common/src/provider/mod.rs | 12 +- crates/common/src/transactions.rs | 6 +- crates/evm/core/Cargo.toml | 12 +- crates/evm/core/src/backend/mod.rs | 3 +- crates/evm/core/src/fork/backend.rs | 3 +- crates/forge/Cargo.toml | 16 +-- crates/forge/bin/cmd/create.rs | 7 +- crates/forge/tests/cli/create.rs | 6 +- crates/forge/tests/cli/utils.rs | 4 +- crates/script/Cargo.toml | 1 + crates/script/src/broadcast.rs | 11 +- crates/script/src/sequence.rs | 3 +- crates/script/src/transaction.rs | 3 +- crates/wallets/Cargo.toml | 2 +- crates/wallets/src/error.rs | 4 +- crates/wallets/src/utils.rs | 6 +- crates/wallets/src/wallet_signer.rs | 8 +- 60 files changed, 369 insertions(+), 278 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1865177e6cd71..b7080d1989a58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-eips", "alloy-primitives", @@ -93,7 +93,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-primitives", "alloy-serde", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-primitives", "serde", @@ -183,13 +183,14 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-primitives", "alloy-rpc-types-eth", + "alloy-serde", "alloy-signer", "alloy-sol-types", "async-trait", @@ -228,7 +229,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-chains", "alloy-consensus", @@ -240,6 +241,7 @@ dependencies = [ "alloy-rpc-client", "alloy-rpc-types-eth", "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-transport", "alloy-transport-http", "alloy-transport-ipc", @@ -263,7 +265,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -303,7 +305,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -327,17 +329,18 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-rpc-types-eth", "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-serde", ] [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-eips", @@ -354,11 +357,10 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-eips", - "alloy-genesis", "alloy-primitives", "alloy-rlp", "alloy-serde", @@ -372,7 +374,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -381,10 +383,21 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-rpc-types-txpool" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types-eth", + "alloy-serde", + "serde", +] + [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-primitives", "serde", @@ -394,7 +407,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -409,7 +422,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-network", @@ -426,7 +439,7 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-network", @@ -443,7 +456,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -460,38 +473,38 @@ dependencies = [ ] [[package]] -name = "alloy-signer-trezor" +name = "alloy-signer-local" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", "async-trait", - "semver 1.0.23", + "coins-bip32", + "coins-bip39", + "elliptic-curve", + "eth-keystore", + "k256", + "rand", "thiserror", - "tracing", - "trezor-client", ] [[package]] -name = "alloy-signer-wallet" +name = "alloy-signer-trezor" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", "async-trait", - "coins-bip32", - "coins-bip39", - "elliptic-curve", - "eth-keystore", - "k256", - "rand", + "semver 1.0.23", "thiserror", + "tracing", + "trezor-client", ] [[package]] @@ -569,7 +582,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -586,7 +599,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -600,7 +613,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -620,7 +633,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=00d81d7#00d81d7882a0bee4720d6d6a1db4c8f164ebb9d0" +source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -753,8 +766,9 @@ dependencies = [ "alloy-rpc-client", "alloy-rpc-types", "alloy-rpc-types-trace", + "alloy-serde", "alloy-signer", - "alloy-signer-wallet", + "alloy-signer-local", "alloy-sol-types", "alloy-transport", "alloy-transport-ipc", @@ -1861,8 +1875,9 @@ dependencies = [ "alloy-provider", "alloy-rlp", "alloy-rpc-types", + "alloy-serde", "alloy-signer", - "alloy-signer-wallet", + "alloy-signer-local", "alloy-sol-types", "alloy-transport", "async-trait", @@ -3253,8 +3268,9 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", + "alloy-serde", "alloy-signer", - "alloy-signer-wallet", + "alloy-signer-local", "alloy-sol-macro-expander", "alloy-sol-macro-input", "alloy-transport", @@ -3380,6 +3396,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", + "alloy-serde", "alloy-signer", "alloy-transport", "async-recursion", @@ -3499,7 +3516,7 @@ dependencies = [ "alloy-provider", "alloy-rpc-types", "alloy-signer", - "alloy-signer-wallet", + "alloy-signer-local", "alloy-sol-types", "base64 0.22.1", "const-hex", @@ -3590,6 +3607,7 @@ dependencies = [ "alloy-rpc-client", "alloy-rpc-types", "alloy-rpc-types-engine", + "alloy-serde", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3752,6 +3770,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", + "alloy-serde", "alloy-sol-types", "alloy-transport", "arrayvec", @@ -3902,8 +3921,8 @@ dependencies = [ "alloy-signer-aws", "alloy-signer-gcp", "alloy-signer-ledger", + "alloy-signer-local", "alloy-signer-trezor", - "alloy-signer-wallet", "alloy-sol-types", "async-trait", "aws-config", @@ -6885,7 +6904,7 @@ dependencies = [ [[package]] name = "revm" version = "9.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" dependencies = [ "auto_impl", "cfg-if", @@ -6899,7 +6918,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=5cf339c#5cf339cada76e3dc38c864aab870d3cdb7b6860d" +source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=79774a6#79774a6e4add9da9247130bf73305531092d0895" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -6915,7 +6934,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "5.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" dependencies = [ "revm-primitives", "serde", @@ -6924,7 +6943,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "7.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6941,7 +6960,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "4.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=a28a543#a28a5439b9cfb7494cbd670da10cbedcfe6c5854" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" dependencies = [ "alloy-primitives", "auto_impl", diff --git a/Cargo.toml b/Cargo.toml index 663b727cc3c4a..368d94521ed55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -160,7 +160,7 @@ foundry-compilers = { version = "0.7.0", default-features = false } # no default features to avoid c-kzg revm = { version = "9.0.0", default-features = false } revm-primitives = { version = "4.0.0", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "5cf339c", features = [ +revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "79774a6", features = [ "serde", ] } @@ -168,30 +168,30 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "00d81d7", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" @@ -251,7 +251,7 @@ tower-http = "0.5" soldeer = "0.2.15" [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } -revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } -revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } -revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "a28a543" } +revm = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } +revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } +revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } +revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 749db58dbad80..9d31ce6d632d6 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -51,12 +51,19 @@ alloy-network.workspace = true alloy-eips.workspace = true alloy-rlp.workspace = true alloy-signer = { workspace = true, features = ["eip712"] } -alloy-signer-wallet = { workspace = true, features = ["mnemonic"] } +alloy-signer-local = { workspace = true, features = ["mnemonic"] } alloy-sol-types = { workspace = true, features = ["std"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } -alloy-rpc-types.workspace = true +alloy-rpc-types = { workspace = true, features = ["txpool"] } alloy-rpc-types-trace.workspace = true -alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } +alloy-serde.workspace = true +alloy-provider = { workspace = true, features = [ + "reqwest", + "ws", + "ipc", + "debug-api", + "trace-api", +] } alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true @@ -109,6 +116,7 @@ tikv-jemallocator = { workspace = true, optional = true } alloy-json-abi.workspace = true alloy-rpc-client = { workspace = true, features = ["pubsub"] } alloy-transport-ipc = { workspace = true, features = ["mock"] } +alloy-provider = { workspace = true, features = ["txpool-api"] } alloy-transport-ws.workspace = true alloy-json-rpc.workspace = true alloy-pubsub.workspace = true diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 1d39a488f8eeb..0f6205f1435e9 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -7,9 +7,10 @@ use alloy_rpc_types::{ pubsub::{Params as SubscriptionParams, SubscriptionKind}, request::TransactionRequest, state::StateOverride, - BlockId, BlockNumberOrTag as BlockNumber, Filter, WithOtherFields, + BlockId, BlockNumberOrTag as BlockNumber, Filter, }; use alloy_rpc_types_trace::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}; +use alloy_serde::WithOtherFields; pub mod block; pub mod proof; diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 013759d3b1e16..81840bfa59d28 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -10,9 +10,10 @@ use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ - other::OtherFields, request::TransactionRequest, AccessList, AnyTransactionReceipt, - Signature as RpcSignature, Transaction as RpcTransaction, TransactionReceipt, WithOtherFields, + request::TransactionRequest, AccessList, AnyTransactionReceipt, Signature as RpcSignature, + Transaction as RpcTransaction, TransactionReceipt, }; +use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; use foundry_evm::traces::CallTraceNode; use revm::{ diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 576c63a9f3e80..ca86a06e163c2 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -5,7 +5,7 @@ use crate::{ }; use alloy_genesis::Genesis; use alloy_primitives::{utils::Unit, U256}; -use alloy_signer_wallet::coins_bip39::{English, Mnemonic}; +use alloy_signer_local::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; use clap::Parser; use core::fmt; diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index f9fe56c2c1d28..097513847229a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -20,9 +20,9 @@ use alloy_primitives::{hex, utils::Unit, U256}; use alloy_provider::Provider; use alloy_rpc_types::BlockNumberOrTag; use alloy_signer::Signer; -use alloy_signer_wallet::{ +use alloy_signer_local::{ coins_bip39::{English, Mnemonic}, - LocalWallet, MnemonicBuilder, + MnemonicBuilder, PrivateKeySigner, }; use alloy_transport::{Transport, TransportError}; use anvil_server::ServerConfig; @@ -99,13 +99,13 @@ pub struct NodeConfig { /// The hardfork to use pub hardfork: Option, /// Signer accounts that will be initialised with `genesis_balance` in the genesis block - pub genesis_accounts: Vec, + pub genesis_accounts: Vec, /// Native token balance of every genesis account in the genesis block pub genesis_balance: U256, /// Genesis block timestamp pub genesis_timestamp: Option, /// Signer accounts that can sign messages/transactions from the EVM node - pub signer_accounts: Vec, + pub signer_accounts: Vec, /// Configured block time for the EVM chain. Use `None` to mine a new block for every tx pub block_time: Option, /// Disable auto, interval mining mode uns use `MiningMode::None` instead @@ -206,7 +206,7 @@ Private Keys ); for (idx, wallet) in self.genesis_accounts.iter().enumerate() { - let hex = hex::encode(wallet.signer().to_bytes()); + let hex = hex::encode(wallet.credential().to_bytes()); let _ = write!(config_string, "\n({idx}) 0x{hex}"); } @@ -312,7 +312,7 @@ Genesis Timestamp for wallet in &self.genesis_accounts { available_accounts.push(format!("{:?}", wallet.address())); - private_keys.push(format!("0x{}", hex::encode(wallet.signer().to_bytes()))); + private_keys.push(format!("0x{}", hex::encode(wallet.credential().to_bytes()))); } if let Some(ref gen) = self.account_generator { @@ -588,14 +588,14 @@ impl NodeConfig { /// Sets the genesis accounts #[must_use] - pub fn with_genesis_accounts(mut self, accounts: Vec) -> Self { + pub fn with_genesis_accounts(mut self, accounts: Vec) -> Self { self.genesis_accounts = accounts; self } /// Sets the signer accounts #[must_use] - pub fn with_signer_accounts(mut self, accounts: Vec) -> Self { + pub fn with_signer_accounts(mut self, accounts: Vec) -> Self { self.signer_accounts = accounts; self } @@ -1243,7 +1243,7 @@ impl AccountGenerator { } impl AccountGenerator { - pub fn gen(&self) -> Vec { + pub fn gen(&self) -> Vec { let builder = MnemonicBuilder::::default().phrase(self.phrase.as_str()); // use the derivation path diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 49e0db680cba7..7f76e6a70e8f4 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -42,12 +42,13 @@ use alloy_rpc_types::{ txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, AccessList, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Log, - Transaction, WithOtherFields, + Transaction, }; use alloy_rpc_types_trace::{ geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, }; +use alloy_serde::WithOtherFields; use alloy_transport::TransportErrorKind; use anvil_core::{ eth::{ diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index feecc94875c65..25e001da0e214 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -9,12 +9,13 @@ use alloy_provider::{ use alloy_rpc_types::{ request::TransactionRequest, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, - Filter, Log, Transaction, WithOtherFields, + Filter, Log, Transaction, }; use alloy_rpc_types_trace::{ geth::{GethDebugTracingOptions, GethTrace}, parity::LocalizedTransactionTrace as Trace, }; +use alloy_serde::WithOtherFields; use alloy_transport::TransportError; use anvil_core::eth::transaction::{convert_to_anvil_receipt, ReceiptResponse}; use foundry_common::provider::{ProviderBuilder, RetryProvider}; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 238fe2ef9341d..0e130c8e5f612 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -39,12 +39,13 @@ use alloy_rpc_types::{ request::TransactionRequest, serde_helpers::JsonStorageKey, state::StateOverride, AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, - FilteredParams, Header as AlloyHeader, Log, Transaction, TransactionReceipt, WithOtherFields, + FilteredParams, Header as AlloyHeader, Log, Transaction, TransactionReceipt, }; use alloy_rpc_types_trace::{ geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, }; +use alloy_serde::WithOtherFields; use alloy_trie::{proof::ProofRetainer, HashBuilder, Nibbles}; use anvil_core::{ eth::{ diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index f7818585dd832..fe31fbc2a93ee 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -111,6 +111,7 @@ where InvalidHeader::PrevrandaoNotSet => Self::PrevrandaoNotSet, }, EVMError::Database(err) => err.into(), + EVMError::Precompile(err) => Self::Message(err), EVMError::Custom(err) => Self::Message(err), } } diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 7f85762575369..57abc0c4055ea 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -3,11 +3,12 @@ use crate::eth::{ error::{BlockchainError, Result}, }; use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256 as rU256, U256}; -use alloy_rpc_types::{Block, BlockTransactions, Transaction, WithOtherFields}; +use alloy_rpc_types::{Block, BlockTransactions, Transaction}; use alloy_rpc_types_trace::parity::{ Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, RewardAction, TraceOutput, }; +use alloy_serde::WithOtherFields; use anvil_core::eth::transaction::ReceiptResponse; use foundry_evm::traces::CallKind; use futures::future::join_all; diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index 949a517fa7690..c122d54ddf916 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -4,7 +4,7 @@ use alloy_dyn_abi::TypedData; use alloy_network::TxSignerSync; use alloy_primitives::{Address, Signature, B256}; use alloy_signer::Signer as AlloySigner; -use alloy_signer_wallet::LocalWallet; +use alloy_signer_local::PrivateKeySigner; use anvil_core::eth::transaction::{ optimism::{DepositTransaction, DepositTransactionRequest}, TypedTransaction, TypedTransactionRequest, @@ -47,11 +47,11 @@ pub trait Signer: Send + Sync { /// Maintains developer keys pub struct DevSigner { addresses: Vec
, - accounts: HashMap, + accounts: HashMap, } impl DevSigner { - pub fn new(accounts: Vec) -> Self { + pub fn new(accounts: Vec) -> Self { let addresses = accounts.iter().map(|wallet| wallet.address()).collect::>(); let accounts = addresses.iter().cloned().zip(accounts).collect(); Self { addresses, accounts } diff --git a/crates/anvil/src/evm.rs b/crates/anvil/src/evm.rs index 0e0d30f772a2c..794d2ce853ca9 100644 --- a/crates/anvil/src/evm.rs +++ b/crates/anvil/src/evm.rs @@ -33,12 +33,14 @@ mod tests { use crate::{evm::inject_precompiles, PrecompileFactory}; use alloy_primitives::Address; use foundry_evm::revm::primitives::{address, Bytes, Precompile, PrecompileResult, SpecId}; + use revm::primitives::PrecompileOutput; #[test] fn build_evm_with_extra_precompiles() { const PRECOMPILE_ADDR: Address = address!("0000000000000000000000000000000000000071"); + fn my_precompile(_bytes: &Bytes, _gas_limit: u64) -> PrecompileResult { - Ok((0, Bytes::new())) + Ok(PrecompileOutput { bytes: Bytes::new(), gas_used: 0 }) } #[derive(Debug)] diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index da08b0a4a32f3..471f7b05c500e 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -21,7 +21,7 @@ use crate::{ tasks::TaskManager, }; use alloy_primitives::{Address, U256}; -use alloy_signer_wallet::LocalWallet; +use alloy_signer_local::PrivateKeySigner; use eth::backend::fork::ClientFork; use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; @@ -165,7 +165,7 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle .alloc .values() .filter_map(|acc| acc.private_key) - .flat_map(|k| LocalWallet::from_bytes(&k)) + .flat_map(|k| PrivateKeySigner::from_bytes(&k)) .collect::>(); if !genesis_signers.is_empty() { signers.push(Box::new(DevSigner::new(genesis_signers))); @@ -332,7 +332,7 @@ impl NodeHandle { } /// Signer accounts that can sign messages/transactions from the EVM node - pub fn dev_wallets(&self) -> impl Iterator + '_ { + pub fn dev_wallets(&self) -> impl Iterator + '_ { self.config.signer_accounts.iter().cloned() } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 11aa40bdc706b..d83365eacf840 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -5,10 +5,11 @@ use crate::{ fork::fork_config, utils::http_provider_with_signer, }; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{address, fixed_bytes, Address, U256, U64}; use alloy_provider::{ext::TxPoolApi, Provider}; -use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionRequest}; +use alloy_serde::WithOtherFields; use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; use anvil_core::{ eth::EthRequest, @@ -632,7 +633,7 @@ async fn can_remove_pool_transactions() { let (api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); + let signer: EthereumWallet = wallet.clone().into(); let from = wallet.address(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index b7d6f51c593e8..13f8200ef1fcf 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -2,15 +2,16 @@ use crate::{ abi::{MulticallContract, SimpleStorage}, - utils::{connect_pubsub_with_signer, http_provider_with_signer}, + utils::{connect_pubsub_with_wallet, http_provider_with_signer}, }; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{Address, ChainId, B256, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ request::TransactionRequest, state::AccountOverride, BlockId, BlockNumberOrTag, - BlockTransactions, WithOtherFields, + BlockTransactions, }; +use alloy_serde::WithOtherFields; use anvil::{eth::api::CLIENT_VERSION, spawn, NodeConfig, CHAIN_ID}; use std::{collections::HashMap, time::Duration}; @@ -99,7 +100,7 @@ async fn can_get_block_by_number() { let (_api, handle) = spawn(NodeConfig::test()).await; let accounts: Vec<_> = handle.dev_wallets().collect(); - let signer: EthereumSigner = accounts[0].clone().into(); + let signer: EthereumWallet = accounts[0].clone().into(); let from = accounts[0].address(); let to = accounts[1].address(); @@ -129,11 +130,11 @@ async fn can_get_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; let accounts: Vec<_> = handle.dev_wallets().collect(); - let signer: EthereumSigner = accounts[0].clone().into(); + let signer: EthereumWallet = accounts[0].clone().into(); let from = accounts[0].address(); let to = accounts[1].address(); - let provider = connect_pubsub_with_signer(&handle.http_endpoint(), signer).await; + let provider = connect_pubsub_with_wallet(&handle.http_endpoint(), signer).await; let block = provider.get_block(BlockId::pending(), false.into()).await.unwrap().unwrap(); assert_eq!(block.header.number.unwrap(), 1); @@ -165,7 +166,7 @@ async fn can_call_on_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); + let signer: EthereumWallet = wallet.clone().into(); let sender = wallet.address(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); @@ -242,7 +243,7 @@ async fn can_call_on_pending_block() { async fn can_call_with_state_override() { let (api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); + let signer: EthereumWallet = wallet.clone().into(); let account = wallet.address(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 1d0df312b3ea4..19842aa75d1ab 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -4,7 +4,8 @@ use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK}; use alloy_network::TransactionBuilder; use alloy_primitives::U256; use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, TransactionRequest}; +use alloy_serde::WithOtherFields; use anvil::{spawn, Hardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 3ef8665ea255f..83c235f5c5753 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -4,14 +4,15 @@ use crate::{ abi::{Greeter, ERC721}, utils::{http_provider, http_provider_with_signer}, }; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{address, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ request::{TransactionInput, TransactionRequest}, - BlockId, BlockNumberOrTag, WithOtherFields, + BlockId, BlockNumberOrTag, }; -use alloy_signer_wallet::LocalWallet; +use alloy_serde::WithOtherFields; +use alloy_signer_local::PrivateKeySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; use foundry_common::provider::get_http_provider; @@ -421,7 +422,7 @@ async fn can_deploy_greeter_on_fork() { let (_api, handle) = spawn(fork_config().with_fork_block_number(Some(14723772u64))).await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.into(); + let signer: EthereumWallet = wallet.into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); @@ -570,13 +571,13 @@ async fn test_fork_can_send_tx() { let (api, handle) = spawn(fork_config().with_blocktime(Some(std::time::Duration::from_millis(800)))).await; - let wallet = LocalWallet::random(); + let wallet = PrivateKeySigner::random(); let signer = wallet.address(); let provider = handle.http_provider(); // let provider = SignerMiddleware::new(provider, wallet); api.anvil_set_balance(signer, U256::MAX).await.unwrap(); - api.anvil_impersonate_account(signer).await.unwrap(); // Added until SignerFiller for alloy-provider is fixed. + api.anvil_impersonate_account(signer).await.unwrap(); // Added until WalletFiller for alloy-provider is fixed. let balance = provider.get_balance(signer).await.unwrap(); assert_eq!(balance, U256::MAX); @@ -603,7 +604,7 @@ async fn test_fork_nft_set_approve_all() { .await; // create and fund a random wallet - let wallet = LocalWallet::random(); + let wallet = PrivateKeySigner::random(); let signer = wallet.address(); api.anvil_set_balance(signer, U256::from(1000e18)).await.unwrap(); @@ -1033,7 +1034,7 @@ async fn can_override_fork_chain_id() { .await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.into(); + let signer: EthereumWallet = wallet.into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); let greeter_contract = diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index f7ab590040977..af28983f1f994 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -1,10 +1,11 @@ //! Gas related tests use crate::utils::http_provider_with_signer; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, TransactionRequest}; +use alloy_serde::WithOtherFields; use anvil::{eth::fees::INITIAL_BASE_FEE, spawn, NodeConfig}; const GAS_TRANSFER: u128 = 21_000; @@ -17,7 +18,7 @@ async fn test_basefee_full_block() { .await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); + let signer: EthereumWallet = wallet.clone().into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); @@ -62,7 +63,7 @@ async fn test_basefee_half_block() { .await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); + let signer: EthereumWallet = wallet.clone().into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); @@ -94,7 +95,7 @@ async fn test_basefee_empty_block() { let (api, handle) = spawn(NodeConfig::test().with_base_fee(Some(INITIAL_BASE_FEE))).await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); + let signer: EthereumWallet = wallet.clone().into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index afcb340197fd3..40d032d7ccdcf 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -4,7 +4,7 @@ use crate::{ abi::SimpleStorage::{self}, utils::{http_provider_with_signer, ws_provider_with_signer}, }; -use alloy_network::EthereumSigner; +use alloy_network::EthereumWallet; use alloy_primitives::B256; use alloy_provider::Provider; use alloy_rpc_types::{BlockNumberOrTag, Filter}; @@ -17,7 +17,7 @@ async fn get_past_events() { let wallet = handle.dev_wallets().next().unwrap(); let account = wallet.address(); - let signer: EthereumSigner = wallet.into(); + let signer: EthereumWallet = wallet.into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); @@ -86,7 +86,7 @@ async fn get_all_events() { let wallet = handle.dev_wallets().next().unwrap(); let account = wallet.address(); - let signer: EthereumSigner = wallet.into(); + let signer: EthereumWallet = wallet.into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer); @@ -153,7 +153,7 @@ async fn watch_events() { let wallet = handle.dev_wallets().next().unwrap(); let account = wallet.address(); - let signer: EthereumSigner = wallet.into(); + let signer: EthereumWallet = wallet.into(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer.clone()); diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 60d506aee3237..3406e686526ca 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -2,10 +2,11 @@ use crate::utils::http_provider_with_signer; use alloy_eips::eip2718::Encodable2718; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{b256, U128, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest}; +use alloy_serde::WithOtherFields; use anvil::{spawn, Hardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] @@ -46,7 +47,7 @@ async fn test_send_value_deposit_transaction() { spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; let accounts: Vec<_> = handle.dev_wallets().collect(); - let signer: EthereumSigner = accounts[0].clone().into(); + let signer: EthereumWallet = accounts[0].clone().into(); let from = accounts[0].address(); let to = accounts[1].address(); @@ -94,7 +95,7 @@ async fn test_send_value_raw_deposit_transaction() { spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; let accounts: Vec<_> = handle.dev_wallets().collect(); - let signer: EthereumSigner = accounts[0].clone().into(); + let signer: EthereumWallet = accounts[0].clone().into(); let from = accounts[0].address(); let to = accounts[1].address(); diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 573fc1c7e75a4..dc0f297fd3554 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -3,7 +3,8 @@ use crate::abi::MulticallContract; use alloy_primitives::{address, Address, Bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions, TransactionRequest}; +use alloy_serde::WithOtherFields; use alloy_sol_types::{sol, SolCall, SolError}; use anvil::{ eth::otterscan::types::{ diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index d11208feb0616..fec22ca41cd48 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -1,11 +1,12 @@ //! tests for subscriptions -use crate::utils::{connect_pubsub, connect_pubsub_with_signer}; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use crate::utils::{connect_pubsub, connect_pubsub_with_wallet}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; use alloy_pubsub::Subscription; -use alloy_rpc_types::{Block as AlloyBlock, Filter, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{Block as AlloyBlock, Filter, TransactionRequest}; +use alloy_serde::WithOtherFields; use alloy_sol_types::sol; use anvil::{spawn, NodeConfig}; use futures::StreamExt; @@ -117,7 +118,7 @@ async fn test_sub_logs_impersonated() { let (api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); let provider = - connect_pubsub_with_signer(&handle.ws_endpoint(), EthereumSigner::from(wallet.clone())) + connect_pubsub_with_wallet(&handle.ws_endpoint(), EthereumWallet::from(wallet.clone())) .await; // impersonate account @@ -160,7 +161,7 @@ async fn test_filters_legacy() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); let provider = - connect_pubsub_with_signer(&handle.ws_endpoint(), EthereumSigner::from(wallet.clone())) + connect_pubsub_with_wallet(&handle.ws_endpoint(), EthereumWallet::from(wallet.clone())) .await; let from = wallet.address(); @@ -197,7 +198,7 @@ async fn test_filters() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); let provider = - connect_pubsub_with_signer(&handle.ws_endpoint(), EthereumSigner::from(wallet.clone())) + connect_pubsub_with_wallet(&handle.ws_endpoint(), EthereumWallet::from(wallet.clone())) .await; let from = wallet.address(); diff --git a/crates/anvil/tests/it/revert.rs b/crates/anvil/tests/it/revert.rs index 051f6be669a57..55762fd0f91be 100644 --- a/crates/anvil/tests/it/revert.rs +++ b/crates/anvil/tests/it/revert.rs @@ -2,7 +2,8 @@ use crate::abi::VendingMachine; use alloy_network::TransactionBuilder; use alloy_primitives::{bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::TransactionRequest; +use alloy_serde::WithOtherFields; use alloy_sol_types::sol; use anvil::{spawn, NodeConfig}; diff --git a/crates/anvil/tests/it/sign.rs b/crates/anvil/tests/it/sign.rs index c279619f2c6ca..0ff56f3641199 100644 --- a/crates/anvil/tests/it/sign.rs +++ b/crates/anvil/tests/it/sign.rs @@ -1,9 +1,10 @@ use crate::utils::http_provider_with_signer; use alloy_dyn_abi::TypedData; -use alloy_network::EthereumSigner; +use alloy_network::EthereumWallet; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::TransactionRequest; +use alloy_serde::WithOtherFields; use alloy_signer::Signer; use anvil::{spawn, NodeConfig}; @@ -310,7 +311,7 @@ async fn can_sign_transaction() { async fn rejects_different_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap().with_chain_id(Some(1)); - let provider = http_provider_with_signer(&handle.http_endpoint(), EthereumSigner::from(wallet)); + let provider = http_provider_with_signer(&handle.http_endpoint(), EthereumWallet::from(wallet)); let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100)); let tx = WithOtherFields::new(tx); @@ -324,7 +325,7 @@ async fn rejects_invalid_chain_id() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); let wallet = wallet.with_chain_id(Some(99u64)); - let provider = http_provider_with_signer(&handle.http_endpoint(), EthereumSigner::from(wallet)); + let provider = http_provider_with_signer(&handle.http_endpoint(), EthereumWallet::from(wallet)); let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100u64)); let tx = WithOtherFields::new(tx); let res = provider.send_transaction(tx).await; diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 38f7a61a18ee7..1c492730068e0 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,15 +1,16 @@ use crate::{fork::fork_config, utils::http_provider_with_signer}; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes, U256}; use alloy_provider::{ ext::{DebugApi, TraceApi}, Provider, }; -use alloy_rpc_types::{BlockNumberOrTag, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockNumberOrTag, TransactionRequest}; use alloy_rpc_types_trace::{ geth::{GethDebugTracingCallOptions, GethTrace}, parity::{Action, LocalizedTransactionTrace}, }; +use alloy_serde::WithOtherFields; use alloy_sol_types::sol; use anvil::{spawn, Hardfork, NodeConfig}; @@ -98,7 +99,7 @@ sol!( async fn test_transfer_debug_trace_call() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallets = handle.dev_wallets().collect::>(); - let deployer: EthereumSigner = wallets[0].clone().into(); + let deployer: EthereumWallet = wallets[0].clone().into(); let provider = http_provider_with_signer(&handle.http_endpoint(), deployer); let contract_addr = DebugTraceContract::deploy_builder(provider.clone()) @@ -107,7 +108,7 @@ async fn test_transfer_debug_trace_call() { .await .unwrap(); - let caller: EthereumSigner = wallets[1].clone().into(); + let caller: EthereumWallet = wallets[1].clone().into(); let caller_provider = http_provider_with_signer(&handle.http_endpoint(), caller); let contract = DebugTraceContract::new(contract_addr, caller_provider); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 74c82133a754f..1565e587b1a94 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -2,14 +2,14 @@ use crate::{ abi::{Greeter, MulticallContract, SimpleStorage}, utils::{connect_pubsub, http_provider_with_signer}, }; -use alloy_network::{EthereumSigner, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{Address, Bytes, FixedBytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ state::{AccountOverride, StateOverride}, AccessList, AccessListItem, BlockId, BlockNumberOrTag, BlockTransactions, TransactionRequest, - WithOtherFields, }; +use alloy_serde::WithOtherFields; use anvil::{spawn, Hardfork, NodeConfig}; use eyre::Ok; use futures::{future::join_all, FutureExt, StreamExt}; @@ -299,7 +299,7 @@ async fn can_deploy_greeter_http() { let (_api, handle) = spawn(NodeConfig::test()).await; let wallet = handle.dev_wallets().next().unwrap(); - let signer: EthereumSigner = wallet.clone().into(); + let signer: EthereumWallet = wallet.clone().into(); let alloy_provider = http_provider_with_signer(&handle.http_endpoint(), signer); diff --git a/crates/anvil/tests/it/txpool.rs b/crates/anvil/tests/it/txpool.rs index 0882d19775172..c329b27fa9130 100644 --- a/crates/anvil/tests/it/txpool.rs +++ b/crates/anvil/tests/it/txpool.rs @@ -3,7 +3,8 @@ use alloy_network::TransactionBuilder; use alloy_primitives::U256; use alloy_provider::{ext::TxPoolApi, Provider}; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::TransactionRequest; +use alloy_serde::WithOtherFields; use anvil::{spawn, NodeConfig}; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/anvil/tests/it/utils.rs b/crates/anvil/tests/it/utils.rs index 56c8037025a3e..3683775136d39 100644 --- a/crates/anvil/tests/it/utils.rs +++ b/crates/anvil/tests/it/utils.rs @@ -1,4 +1,4 @@ -use alloy_network::{Ethereum, EthereumSigner}; +use alloy_network::{Ethereum, EthereumWallet}; use foundry_common::provider::{ get_http_provider, ProviderBuilder, RetryProvider, RetryProviderWithSigner, }; @@ -9,19 +9,19 @@ pub fn http_provider(http_endpoint: &str) -> RetryProvider { pub fn http_provider_with_signer( http_endpoint: &str, - signer: EthereumSigner, + signer: EthereumWallet, ) -> RetryProviderWithSigner { ProviderBuilder::new(http_endpoint) - .build_with_signer(signer) + .build_with_wallet(signer) .expect("failed to build Alloy HTTP provider with signer") } pub fn ws_provider_with_signer( ws_endpoint: &str, - signer: EthereumSigner, + signer: EthereumWallet, ) -> RetryProviderWithSigner { ProviderBuilder::new(ws_endpoint) - .build_with_signer(signer) + .build_with_wallet(signer) .expect("failed to build Alloy WS provider with signer") } @@ -31,33 +31,35 @@ pub async fn connect_pubsub(conn_str: &str) -> RootProvider { } use alloy_provider::{ - fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SignerFiller}, + fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, WalletFiller}, Identity, RootProvider, }; use alloy_transport::BoxTransport; + type PubsubSigner = FillProvider< JoinFill< JoinFill, NonceFiller>, ChainIdFiller>, - SignerFiller, + WalletFiller, >, RootProvider, BoxTransport, Ethereum, >; -pub async fn connect_pubsub_with_signer(conn_str: &str, signer: EthereumSigner) -> PubsubSigner { + +pub async fn connect_pubsub_with_wallet(conn_str: &str, wallet: EthereumWallet) -> PubsubSigner { alloy_provider::ProviderBuilder::new() .with_recommended_fillers() - .signer(signer) + .wallet(wallet) .on_builtin(conn_str) .await .unwrap() } -pub async fn ipc_provider_with_signer( +pub async fn ipc_provider_with_wallet( ipc_endpoint: &str, - signer: EthereumSigner, + wallet: EthereumWallet, ) -> RetryProviderWithSigner { ProviderBuilder::new(ipc_endpoint) - .build_with_signer(signer) + .build_with_wallet(wallet) .expect("failed to build Alloy IPC provider with signer") } diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index ddcee1ba22b1d..02312eb784506 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -33,21 +33,22 @@ foundry-config.workspace = true foundry-evm.workspace = true foundry-wallets.workspace = true +alloy-chains.workspace = true +alloy-consensus = { workspace = true, features = ["serde", "kzg"] } +alloy-contract.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true +alloy-json-rpc.workspace = true +alloy-network.workspace = true alloy-primitives.workspace = true -alloy-rlp.workspace = true alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } -alloy-transport.workspace = true +alloy-rlp.workspace = true alloy-rpc-types = { workspace = true, features = ["eth"] } -alloy-json-rpc.workspace = true +alloy-serde.workspace = true +alloy-signer-local = { workspace = true, features = ["mnemonic", "keystore"] } alloy-signer.workspace = true -alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } -alloy-contract.workspace = true -alloy-consensus = { workspace = true, features = ["serde", "kzg"] } -alloy-network.workspace = true alloy-sol-types.workspace = true -alloy-chains.workspace = true +alloy-transport.workspace = true chrono.workspace = true evm-disassembler.workspace = true diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index cd0fdfecd0a7a..db8dbf0fe7259 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -1,5 +1,5 @@ use crate::tx::{self, CastTxBuilder}; -use alloy_network::{eip2718::Encodable2718, EthereumSigner, TransactionBuilder}; +use alloy_network::{eip2718::Encodable2718, EthereumWallet, TransactionBuilder}; use alloy_signer::Signer; use clap::Parser; use eyre::Result; @@ -90,7 +90,7 @@ impl MakeTxArgs { .build(from) .await?; - let tx = tx.build(&EthereumSigner::new(signer)).await?; + let tx = tx.build(&EthereumWallet::new(signer)).await?; let signed_tx = hex::encode(tx.encoded_2718()); println!("0x{signed_tx}"); diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index d684edcd48ac7..55094346f29fa 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -1,7 +1,8 @@ use crate::tx::{self, CastTxBuilder}; -use alloy_network::{AnyNetwork, EthereumSigner}; +use alloy_network::{AnyNetwork, EthereumWallet}; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::TransactionRequest; +use alloy_serde::WithOtherFields; use alloy_signer::Signer; use alloy_transport::Transport; use cast::Cast; @@ -157,9 +158,9 @@ impl SendTxArgs { tx::validate_from_address(eth.wallet.from, from)?; - let signer = EthereumSigner::from(signer); + let wallet = EthereumWallet::from(signer); let provider = ProviderBuilder::<_, _, AnyNetwork>::default() - .signer(signer) + .wallet(wallet) .on_provider(&provider); let (tx, _) = builder.build(from).await?; diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index c468803ceb401..2b50630c3da67 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,9 +1,9 @@ use alloy_dyn_abi::TypedData; use alloy_primitives::{Address, Signature, B256}; use alloy_signer::Signer; -use alloy_signer_wallet::{ +use alloy_signer_local::{ coins_bip39::{English, Entropy, Mnemonic}, - LocalWallet, MnemonicBuilder, + MnemonicBuilder, PrivateKeySigner, }; use clap::Parser; use eyre::{Context, Result}; @@ -218,8 +218,12 @@ impl WalletSubcommands { }; for _ in 0..number { - let (wallet, uuid) = - LocalWallet::new_keystore(&path, &mut rng, password.clone(), None)?; + let (wallet, uuid) = PrivateKeySigner::new_keystore( + &path, + &mut rng, + password.clone(), + None, + )?; if let Some(json) = json_values.as_mut() { json.push(json!({ @@ -241,17 +245,20 @@ impl WalletSubcommands { } } else { for _ in 0..number { - let wallet = LocalWallet::random_with(&mut rng); + let wallet = PrivateKeySigner::random_with(&mut rng); if let Some(json) = json_values.as_mut() { json.push(json!({ "address": wallet.address().to_checksum(None), - "private_key": format!("0x{}", hex::encode(wallet.signer().to_bytes())), + "private_key": format!("0x{}", hex::encode(wallet.credential().to_bytes())), })) } else { println!("Successfully created new keypair."); println!("Address: {}", wallet.address().to_checksum(None)); - println!("Private key: 0x{}", hex::encode(wallet.signer().to_bytes())); + println!( + "Private key: 0x{}", + hex::encode(wallet.credential().to_bytes()) + ); } } @@ -284,7 +291,7 @@ impl WalletSubcommands { for (i, wallet) in wallets.iter().enumerate() { println!("- Account {i}:"); println!("Address: {}", wallet.address()); - println!("Private key: 0x{}\n", hex::encode(wallet.signer().to_bytes())); + println!("Private key: 0x{}\n", hex::encode(wallet.credential().to_bytes())); } } Self::Vanity(cmd) => { @@ -363,7 +370,7 @@ flag to set your key via: ) })?; - let private_key = wallet.signer().to_bytes(); + let private_key = wallet.credential().to_bytes(); let password = if let Some(password) = unsafe_password { password } else { @@ -372,7 +379,7 @@ flag to set your key via: }; let mut rng = thread_rng(); - let (wallet, _) = LocalWallet::encrypt_keystore( + let (wallet, _) = PrivateKeySigner::encrypt_keystore( dir, &mut rng, private_key, @@ -418,9 +425,12 @@ flag to set your key via: WalletSigner::Local(wallet) => { if verbose { println!("Address: {}", wallet.address()); - println!("Private key: 0x{}", hex::encode(wallet.signer().to_bytes())); + println!( + "Private key: 0x{}", + hex::encode(wallet.credential().to_bytes()) + ); } else { - println!("0x{}", hex::encode(wallet.signer().to_bytes())); + println!("0x{}", hex::encode(wallet.credential().to_bytes())); } } _ => { @@ -451,9 +461,9 @@ flag to set your key via: rpassword::prompt_password("Enter password: ")? }; - let wallet = LocalWallet::decrypt_keystore(keypath, password)?; + let wallet = PrivateKeySigner::decrypt_keystore(keypath, password)?; - let private_key = B256::from_slice(&wallet.signer().to_bytes()); + let private_key = B256::from_slice(&wallet.credential().to_bytes()); let success_message = format!("{}'s private key is: {}", &account_name, private_key); diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 5bab0e318823e..1e94b5f9ae9bf 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,6 +1,6 @@ use alloy_primitives::Address; use alloy_signer::{k256::ecdsa::SigningKey, utils::secret_key_to_address}; -use alloy_signer_wallet::LocalWallet; +use alloy_signer_local::PrivateKeySigner; use clap::{builder::TypedValueParser, Parser}; use eyre::Result; use rayon::iter::{self, ParallelIterator}; @@ -63,16 +63,16 @@ struct Wallets { } impl WalletData { - pub fn new(wallet: &LocalWallet) -> Self { + pub fn new(wallet: &PrivateKeySigner) -> Self { Self { address: wallet.address().to_checksum(None), - private_key: format!("0x{}", hex::encode(wallet.signer().to_bytes())), + private_key: format!("0x{}", hex::encode(wallet.credential().to_bytes())), } } } impl VanityArgs { - pub fn run(self) -> Result { + pub fn run(self) -> Result { let Self { starts_with, ends_with, nonce, save_path } = self; let mut left_exact_hex = None; let mut left_regex = None; @@ -160,7 +160,7 @@ impl VanityArgs { String::new() }, wallet.address().to_checksum(None), - hex::encode(wallet.signer().to_bytes()), + hex::encode(wallet.credential().to_bytes()), ); Ok(wallet) @@ -170,7 +170,7 @@ impl VanityArgs { /// Saves the specified `wallet` to a 'vanity_addresses.json' file at the given `save_path`. /// If the file exists, the wallet data is appended to the existing content; /// otherwise, a new file is created. -fn save_wallet_to_file(wallet: &LocalWallet, path: &Path) -> Result<()> { +fn save_wallet_to_file(wallet: &PrivateKeySigner, path: &Path) -> Result<()> { let mut wallets = if path.exists() { let data = fs::read_to_string(path)?; serde_json::from_str::(&data).unwrap_or_default() @@ -185,7 +185,7 @@ fn save_wallet_to_file(wallet: &LocalWallet, path: &Path) -> Result<()> { } /// Generates random wallets until `matcher` matches the wallet address, returning the wallet. -pub fn find_vanity_address(matcher: T) -> Option { +pub fn find_vanity_address(matcher: T) -> Option { wallet_generator().find_any(create_matcher(matcher)).map(|(key, _)| key.into()) } @@ -194,7 +194,7 @@ pub fn find_vanity_address(matcher: T) -> Option pub fn find_vanity_address_with_nonce( matcher: T, nonce: u64, -) -> Option { +) -> Option { wallet_generator().find_any(create_nonce_matcher(matcher, nonce)).map(|(key, _)| key.into()) } diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 77ed93babd3f8..c0f1e1a97a3b2 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -3,7 +3,8 @@ use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; use alloy_primitives::{Address, TxKind}; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::TransactionRequest; +use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::Result; use foundry_cli::{ diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 002212fcd45bb..e84b5ee9523a1 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -14,7 +14,8 @@ use alloy_provider::{ PendingTransactionBuilder, Provider, }; use alloy_rlp::Decodable; -use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, TransactionRequest}; +use alloy_serde::WithOtherFields; use alloy_sol_types::sol; use alloy_transport::Transport; use base::{Base, NumberWithBase, ToBase}; @@ -94,7 +95,8 @@ where /// /// ``` /// use alloy_primitives::{Address, U256, Bytes}; - /// use alloy_rpc_types::{TransactionRequest, WithOtherFields}; + /// use alloy_rpc_types::{TransactionRequest}; + /// use alloy_serde::WithOtherFields; /// use cast::Cast; /// use alloy_provider::{RootProvider, ProviderBuilder, network::AnyNetwork}; /// use std::str::FromStr; @@ -175,7 +177,8 @@ where /// ``` /// use cast::{Cast}; /// use alloy_primitives::{Address, U256, Bytes}; - /// use alloy_rpc_types::{TransactionRequest, WithOtherFields}; + /// use alloy_rpc_types::{TransactionRequest}; + /// use alloy_serde::WithOtherFields; /// use alloy_provider::{RootProvider, ProviderBuilder, network::AnyNetwork}; /// use std::str::FromStr; /// use alloy_sol_types::{sol, SolCall}; @@ -236,7 +239,8 @@ where /// ``` /// use cast::{Cast}; /// use alloy_primitives::{Address, U256, Bytes}; - /// use alloy_rpc_types::{TransactionRequest, WithOtherFields}; + /// use alloy_serde::WithOtherFields; + /// use alloy_rpc_types::{TransactionRequest}; /// use alloy_provider::{RootProvider, ProviderBuilder, network::AnyNetwork}; /// use std::str::FromStr; /// use alloy_sol_types::{sol, SolCall}; diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 07474076595b4..41415c2f8925a 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -30,7 +30,7 @@ alloy-sol-types.workspace = true alloy-provider.workspace = true alloy-rpc-types.workspace = true alloy-signer.workspace = true -alloy-signer-wallet = { workspace = true, features = [ +alloy-signer-local = { workspace = true, features = [ "mnemonic-all-languages", "keystore", ] } diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 508e7173ee770..ec4459d3bb0b5 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -1,7 +1,7 @@ use crate::Vm; use alloy_primitives::{Address, Bytes}; use alloy_signer::Error as SignerError; -use alloy_signer_wallet::WalletError; +use alloy_signer_local::LocalSignerError; use alloy_sol_types::SolError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; @@ -299,7 +299,7 @@ impl_from!( std::str::Utf8Error, std::string::FromUtf8Error, UnresolvedEnvVarError, - WalletError, + LocalSignerError, SignerError, WalletSignerError, ); diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 97c65106a1605..1f84e2475f815 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -2,7 +2,7 @@ use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, B256, U256}; -use alloy_signer_wallet::LocalWallet; +use alloy_signer_local::PrivateKeySigner; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; use parking_lot::Mutex; use std::sync::Arc; @@ -107,12 +107,12 @@ impl ScriptWallets { /// Locks inner Mutex and adds a signer to the [MultiWallet]. pub fn add_private_key(&self, private_key: &B256) -> Result<()> { - self.add_local_signer(LocalWallet::from_bytes(private_key)?); + self.add_local_signer(PrivateKeySigner::from_bytes(private_key)?); Ok(()) } /// Locks inner Mutex and adds a signer to the [MultiWallet]. - pub fn add_local_signer(&self, wallet: LocalWallet) { + pub fn add_local_signer(&self, wallet: PrivateKeySigner) { self.inner.lock().multi_wallet.add_signer(WalletSigner::Local(wallet)); } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index f4f3ab48583ca..8d4c547dff138 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -3,12 +3,12 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_signer::{Signer, SignerSync}; -use alloy_signer_wallet::{ +use alloy_signer_local::{ coins_bip39::{ ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, Portuguese, Spanish, Wordlist, }, - LocalWallet, MnemonicBuilder, + MnemonicBuilder, PrivateKeySigner, }; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; @@ -268,8 +268,8 @@ pub(super) fn parse_private_key(private_key: &U256) -> Result { SigningKey::from_bytes((&bytes).into()).map_err(Into::into) } -pub(super) fn parse_wallet(private_key: &U256) -> Result { - parse_private_key(private_key).map(LocalWallet::from) +pub(super) fn parse_wallet(private_key: &U256) -> Result { + parse_private_key(private_key).map(PrivateKeySigner::from) } fn derive_key_str(mnemonic: &str, path: &str, index: u32, language: &str) -> Result { @@ -302,7 +302,7 @@ fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { .phrase(mnemonic) .derivation_path(derive_key_path(path, index))? .build()?; - let private_key = U256::from_be_bytes(wallet.signer().to_bytes().into()); + let private_key = U256::from_be_bytes(wallet.credential().to_bytes().into()); Ok(private_key.abi_encode()) } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 907f3b62579c9..c8c79534dc2ff 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -18,22 +18,31 @@ foundry-compilers.workspace = true foundry-config.workspace = true foundry-linking.workspace = true +alloy-consensus.workspace = true +alloy-contract.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } -alloy-rpc-types-engine.workspace = true -alloy-rpc-types = { workspace = true, features = ["eth"] } -alloy-rpc-client.workspace = true -alloy-provider.workspace = true -alloy-transport.workspace = true -alloy-transport-http = { workspace = true, features = ["reqwest", "reqwest-rustls-tls"] } -alloy-transport-ws.workspace = true -alloy-transport-ipc.workspace = true alloy-json-rpc.workspace = true +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } +alloy-provider.workspace = true alloy-pubsub.workspace = true +alloy-rpc-client.workspace = true +alloy-rpc-types = { workspace = true, features = ["eth"] } +alloy-rpc-types-engine.workspace = true +alloy-serde.workspace = true alloy-sol-types.workspace = true -alloy-contract.workspace = true -alloy-consensus.workspace = true +alloy-transport-http = { workspace = true, features = [ + "reqwest", + "reqwest-rustls-tls", +] } +alloy-transport-ipc.workspace = true +alloy-transport-ws.workspace = true +alloy-transport.workspace = true tower.workspace = true diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index 63b2905a8f60d..e192f3cad3ca5 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -4,9 +4,9 @@ use crate::TransactionReceiptWithRevertReason; use alloy_consensus::{AnyReceiptEnvelope, Receipt, ReceiptWithBloom, TxType}; use alloy_primitives::*; use alloy_rpc_types::{ - other::OtherFields, AnyTransactionReceipt, Block, BlockTransactions, Log, Transaction, - TransactionReceipt, + AnyTransactionReceipt, Block, BlockTransactions, Log, Transaction, TransactionReceipt, }; +use alloy_serde::OtherFields; use serde::Deserialize; /// length of the name column for pretty formatting `{:>20}{value}` diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index 388a795dddd32..ef7b62055c1df 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -8,8 +8,8 @@ use crate::{ provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, }; use alloy_provider::{ - fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SignerFiller}, - network::{AnyNetwork, EthereumSigner}, + fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, WalletFiller}, + network::{AnyNetwork, EthereumWallet}, Identity, ProviderBuilder as AlloyProviderBuilder, RootProvider, }; use alloy_rpc_client::ClientBuilder; @@ -34,7 +34,7 @@ pub type RetryProvider = RootProvider = FillProvider< JoinFill< JoinFill, NonceFiller>, ChainIdFiller>, - SignerFiller, + WalletFiller, >, RootProvider, N>, RetryBackoffService, @@ -268,8 +268,8 @@ impl ProviderBuilder { Ok(provider) } - /// Constructs the `RetryProvider` with a signer - pub fn build_with_signer(self, signer: EthereumSigner) -> Result { + /// Constructs the `RetryProvider` with a wallet. + pub fn build_with_wallet(self, wallet: EthereumWallet) -> Result { let Self { url, chain: _, @@ -301,7 +301,7 @@ impl ProviderBuilder { let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() .with_recommended_fillers() - .signer(signer) + .wallet(wallet) .on_provider(RootProvider::new(client)); Ok(provider) diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 50fcf7d992dfa..9a6ba190eca0d 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -1,6 +1,8 @@ -//! wrappers for transactions +//! Wrappers for transactions. + use alloy_provider::{network::AnyNetwork, Provider}; -use alloy_rpc_types::{AnyTransactionReceipt, BlockId, WithOtherFields}; +use alloy_rpc_types::{AnyTransactionReceipt, BlockId}; +use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::Result; use serde::{Deserialize, Serialize}; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index c0b1b3e3d0fb3..b8253b494e4a6 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -20,13 +20,19 @@ foundry-config.workspace = true foundry-macros.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } -alloy-json-abi.workspace = true -alloy-primitives = { workspace = true, features = ["serde", "getrandom", "arbitrary", "rlp"] } alloy-genesis.workspace = true +alloy-json-abi.workspace = true +alloy-primitives = { workspace = true, features = [ + "serde", + "getrandom", + "arbitrary", + "rlp", +] } alloy-provider.workspace = true -alloy-transport.workspace = true alloy-rpc-types.workspace = true +alloy-serde.workspace = true alloy-sol-types.workspace = true +alloy-transport.workspace = true revm = { workspace = true, features = [ "std", diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index b96829196a99d..257d72bdb89c1 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -9,7 +9,8 @@ use crate::{ }; use alloy_genesis::GenesisAccount; use alloy_primitives::{b256, keccak256, Address, B256, U256}; -use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction, WithOtherFields}; +use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; +use alloy_serde::WithOtherFields; use eyre::Context; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use revm::{ diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 468be738d63eb..6bd1caaa1cb68 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -5,7 +5,8 @@ use crate::{ }; use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; use alloy_provider::{network::AnyNetwork, Provider}; -use alloy_rpc_types::{Block, BlockId, Transaction, WithOtherFields}; +use alloy_rpc_types::{Block, BlockId, Transaction}; +use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 995053feec43f..493a8c0420882 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -56,18 +56,19 @@ forge-sol-macro-gen.workspace = true foundry-cli.workspace = true foundry-debugger.workspace = true +alloy-chains.workspace = true +alloy-consensus.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true +alloy-network.workspace = true alloy-primitives = { workspace = true, features = ["serde"] } -alloy-rpc-types.workspace = true alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } -alloy-network.workspace = true -alloy-transport.workspace = true +alloy-rpc-types.workspace = true +alloy-serde.workspace = true alloy-signer.workspace = true -alloy-sol-macro-input.workspace = true alloy-sol-macro-expander = { workspace = true, features = ["json"] } -alloy-consensus.workspace = true -alloy-chains.workspace = true +alloy-sol-macro-input.workspace = true +alloy-transport.workspace = true async-trait = "0.1" clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } @@ -108,7 +109,6 @@ soldeer.workspace = true [target.'cfg(unix)'.dependencies] tikv-jemallocator = { workspace = true, optional = true } - [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true @@ -125,7 +125,7 @@ svm = { package = "svm-rs", version = "0.5", default-features = false, features tempfile.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } -alloy-signer-wallet.workspace = true +alloy-signer-local.workspace = true [features] default = ["rustls", "jemalloc"] diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 3b0bc12bc25e3..13ab69da6228e 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -1,10 +1,11 @@ use alloy_chains::Chain; use alloy_dyn_abi::{DynSolValue, JsonAbiExt, Specifier}; use alloy_json_abi::{Constructor, JsonAbi}; -use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; +use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; use alloy_primitives::{Address, Bytes}; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; +use alloy_serde::WithOtherFields; use alloy_signer::Signer; use alloy_transport::{Transport, TransportError}; use clap::{Parser, ValueHint}; @@ -143,7 +144,7 @@ impl CreateArgs { let signer = self.eth.wallet.signer().await?; let deployer = signer.address(); let provider = ProviderBuilder::<_, _, AnyNetwork>::default() - .signer(EthereumSigner::new(signer)) + .wallet(EthereumWallet::new(signer)) .on_provider(provider); self.deploy(abi, bin, params, provider, chain_id, deployer).await } diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 20f0aa7cca5a4..c9484db0f21ce 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -135,7 +135,7 @@ forgetest_async!(can_create_template_contract, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let wallet = handle.dev_wallets().next().unwrap(); - let pk = hex::encode(wallet.signer().to_bytes()); + let pk = hex::encode(wallet.credential().to_bytes()); // explicitly byte code hash for consistent checks let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; @@ -201,7 +201,7 @@ forgetest_async!(can_create_with_constructor_args, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let wallet = handle.dev_wallets().next().unwrap(); - let pk = hex::encode(wallet.signer().to_bytes()); + let pk = hex::encode(wallet.credential().to_bytes()); // explicitly byte code hash for consistent checks let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; @@ -276,7 +276,7 @@ forgetest_async!(can_create_and_call, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let rpc = handle.http_endpoint(); let wallet = handle.dev_wallets().next().unwrap(); - let pk = hex::encode(wallet.signer().to_bytes()); + let pk = hex::encode(wallet.credential().to_bytes()); // explicitly byte code hash for consistent checks let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; diff --git a/crates/forge/tests/cli/utils.rs b/crates/forge/tests/cli/utils.rs index 75523e50a9d8b..094255195c1e3 100644 --- a/crates/forge/tests/cli/utils.rs +++ b/crates/forge/tests/cli/utils.rs @@ -2,7 +2,7 @@ use alloy_chains::NamedChain; use alloy_primitives::Address; -use alloy_signer_wallet::LocalWallet; +use alloy_signer_local::PrivateKeySigner; /// Returns the current millis since unix epoch. /// @@ -45,7 +45,7 @@ pub struct EnvExternalities { impl EnvExternalities { pub fn address(&self) -> Option
{ - let pk: LocalWallet = self.pk.parse().ok()?; + let pk: PrivateKeySigner = self.pk.parse().ok()?; Some(pk.address()) } diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 9c98793926441..4d97f3fc99056 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -46,6 +46,7 @@ dialoguer = { version = "0.11", default-features = false } indicatif = "0.17" alloy-signer.workspace = true +alloy-serde.workspace = true alloy-network.workspace = true alloy-provider.workspace = true alloy-chains.workspace = true diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index aaf866a11f12c..b7eb9f5b0bb6c 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -4,10 +4,11 @@ use crate::{ }; use alloy_chains::Chain; use alloy_eips::eip2718::Encodable2718; -use alloy_network::{AnyNetwork, EthereumSigner, TransactionBuilder}; +use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; use alloy_primitives::{utils::format_units, Address, TxHash}; use alloy_provider::{utils::Eip1559Estimation, Provider}; -use alloy_rpc_types::{TransactionRequest, WithOtherFields}; +use alloy_rpc_types::TransactionRequest; +use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::{bail, Context, Result}; use forge_verify::provider::VerificationProviderType; @@ -102,7 +103,7 @@ pub async fn send_transaction( #[derive(Clone)] pub enum SendTransactionKind<'a> { Unlocked(Address), - Raw(&'a EthereumSigner), + Raw(&'a EthereumWallet), } /// Represents how to send _all_ transactions @@ -110,7 +111,7 @@ pub enum SendTransactionsKind { /// Send via `eth_sendTransaction` and rely on the `from` address being unlocked. Unlocked(HashSet
), /// Send a signed transaction via `eth_sendRawTransaction` - Raw(HashMap), + Raw(HashMap), } impl SendTransactionsKind { @@ -223,7 +224,7 @@ impl BundledState { let signers = signers .into_iter() - .map(|(addr, signer)| (addr, EthereumSigner::new(signer))) + .map(|(addr, signer)| (addr, EthereumWallet::new(signer))) .collect(); SendTransactionsKind::Raw(signers) diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index f95262aaeedd6..0eee959513c75 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -4,7 +4,8 @@ use crate::{ verify::VerifyBundle, }; use alloy_primitives::{Address, TxHash}; -use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest, WithOtherFields}; +use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; +use alloy_serde::WithOtherFields; use eyre::{ContextCompat, Result, WrapErr}; use forge_verify::provider::VerificationProviderType; use foundry_cli::utils::{now, Git}; diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index fd63734d182c7..84657ebf3296b 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,7 +1,8 @@ use super::ScriptResult; use alloy_dyn_abi::JsonAbiExt; use alloy_primitives::{Address, Bytes, TxKind, B256}; -use alloy_rpc_types::{request::TransactionRequest, WithOtherFields}; +use alloy_rpc_types::request::TransactionRequest; +use alloy_serde::WithOtherFields; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{fmt::format_token_raw, ContractData, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 34dfda6d48678..dc013ae6265fd 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -17,7 +17,7 @@ foundry-config.workspace = true alloy-primitives.workspace = true alloy-signer = { workspace = true, features = ["eip712"] } -alloy-signer-wallet = { workspace = true, features = ["mnemonic", "keystore"] } +alloy-signer-local = { workspace = true, features = ["mnemonic", "keystore"] } alloy-signer-ledger = { workspace = true, features = ["eip712"] } alloy-signer-trezor.workspace = true alloy-network.workspace = true diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index c7ac55b82f22c..4e299b055606f 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -1,7 +1,7 @@ use alloy_signer::k256::ecdsa; use alloy_signer_ledger::LedgerError; +use alloy_signer_local::LocalSignerError; use alloy_signer_trezor::TrezorError; -use alloy_signer_wallet::WalletError; use hex::FromHexError; #[cfg(feature = "aws-kms")] @@ -21,7 +21,7 @@ pub enum PrivateKeyError { #[derive(Debug, thiserror::Error)] pub enum WalletSignerError { #[error(transparent)] - Local(#[from] WalletError), + Local(#[from] LocalSignerError), #[error(transparent)] Ledger(#[from] LedgerError), #[error(transparent)] diff --git a/crates/wallets/src/utils.rs b/crates/wallets/src/utils.rs index eaaf81e45403d..da19b6d9e3d2d 100644 --- a/crates/wallets/src/utils.rs +++ b/crates/wallets/src/utils.rs @@ -1,8 +1,8 @@ use crate::{error::PrivateKeyError, PendingSigner, WalletSigner}; use alloy_primitives::B256; use alloy_signer_ledger::HDPath as LedgerHDPath; +use alloy_signer_local::PrivateKeySigner; use alloy_signer_trezor::HDPath as TrezorHDPath; -use alloy_signer_wallet::LocalWallet; use eyre::{Context, Result}; use foundry_config::Config; use hex::FromHex; @@ -24,7 +24,7 @@ pub fn create_private_key_signer(private_key_str: &str) -> Result ensure_pk_not_env(private_key_str)?; eyre::bail!("Failed to decode private key") }; - match LocalWallet::from_bytes(&private_key) { + match PrivateKeySigner::from_bytes(&private_key) { Ok(pk) => Ok(WalletSigner::Local(pk)), Err(err) => { ensure_pk_not_env(private_key_str)?; @@ -141,7 +141,7 @@ pub fn create_keystore_signer( }?; if let Some(password) = password { - let wallet = LocalWallet::decrypt_keystore(path, password) + let wallet = PrivateKeySigner::decrypt_keystore(path, password) .wrap_err_with(|| format!("Failed to decrypt keystore {path:?}"))?; Ok((Some(WalletSigner::Local(wallet)), None)) } else { diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index d0f1de4a27147..f1f7bad88b5eb 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -5,8 +5,8 @@ use alloy_network::TxSigner; use alloy_primitives::{Address, ChainId, B256}; use alloy_signer::{Signature, Signer}; use alloy_signer_ledger::{HDPath as LedgerHDPath, LedgerSigner}; +use alloy_signer_local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner}; use alloy_signer_trezor::{HDPath as TrezorHDPath, TrezorSigner}; -use alloy_signer_wallet::{coins_bip39::English, LocalWallet, MnemonicBuilder}; use alloy_sol_types::{Eip712Domain, SolStruct}; use async_trait::async_trait; use std::path::PathBuf; @@ -29,7 +29,7 @@ pub type Result = std::result::Result; #[derive(Debug)] pub enum WalletSigner { /// Wrapper around local wallet. e.g. private key, mnemonic - Local(LocalWallet), + Local(PrivateKeySigner), /// Wrapper around Ledger signer. Ledger(LedgerSigner), /// Wrapper around Trezor signer. @@ -107,7 +107,7 @@ impl WalletSigner { } pub fn from_private_key(private_key: &B256) -> Result { - Ok(Self::Local(LocalWallet::from_bytes(private_key)?)) + Ok(Self::Local(PrivateKeySigner::from_bytes(private_key)?)) } /// Returns a list of addresses available to use with current signer @@ -263,7 +263,7 @@ impl PendingSigner { match self { Self::Keystore(path) => { let password = rpassword::prompt_password("Enter keystore password:")?; - Ok(WalletSigner::Local(LocalWallet::decrypt_keystore(path, password)?)) + Ok(WalletSigner::Local(PrivateKeySigner::decrypt_keystore(path, password)?)) } Self::Interactive => { let private_key = rpassword::prompt_password("Enter private key:")?; From fd185c85cacd04101195c7050d4084de488a8a98 Mon Sep 17 00:00:00 2001 From: sodamntired Date: Mon, 17 Jun 2024 16:00:36 +0300 Subject: [PATCH 1096/1963] feat: debug_getRawTransaction RPC endpoint (#8162) * feat: debug_getRawTransaction rpc endpoint * clippy happy * conflicts resolved * chore: tests + refactor * fix --- crates/anvil/core/src/eth/mod.rs | 35 ++++++++++++++ crates/anvil/src/eth/api.rs | 68 +++++++++++++++++++++++++++- crates/anvil/tests/it/transaction.rs | 25 +++++++++- 3 files changed, 125 insertions(+), 3 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 0f6205f1435e9..d2fa41a7be2c6 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -196,6 +196,18 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "eth_getTransactionByBlockNumberAndIndex"))] EthGetTransactionByBlockNumberAndIndex(BlockNumber, Index), + #[cfg_attr( + feature = "serde", + serde(rename = "eth_getRawTransactionByHash", with = "sequence") + )] + EthGetRawTransactionByHash(TxHash), + + #[cfg_attr(feature = "serde", serde(rename = "eth_getRawTransactionByBlockHashAndIndex"))] + EthGetRawTransactionByBlockHashAndIndex(TxHash, Index), + + #[cfg_attr(feature = "serde", serde(rename = "eth_getRawTransactionByBlockNumberAndIndex"))] + EthGetRawTransactionByBlockNumberAndIndex(BlockNumber, Index), + #[cfg_attr(feature = "serde", serde(rename = "eth_getTransactionReceipt", with = "sequence"))] EthGetTransactionReceipt(B256), @@ -266,6 +278,10 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "eth_syncing", with = "empty_params"))] EthSyncing(()), + /// geth's `debug_getRawTransaction` endpoint + #[cfg_attr(feature = "serde", serde(rename = "debug_getRawTransaction", with = "sequence"))] + DebugGetRawTransaction(TxHash), + /// geth's `debug_traceTransaction` endpoint #[cfg_attr(feature = "serde", serde(rename = "debug_traceTransaction"))] DebugTraceTransaction( @@ -1421,6 +1437,25 @@ mod tests { let _req = serde_json::from_value::(value).unwrap(); } + #[test] + fn test_serde_debug_raw_transaction() { + let s = r#"{"jsonrpc":"2.0","method":"debug_getRawTransaction","params":["0x3ed3a89bc10115a321aee238c02de214009f8532a65368e5df5eaf732ee7167c"],"id":1}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + + let s = r#"{"jsonrpc":"2.0","method":"eth_getRawTransactionByHash","params":["0x3ed3a89bc10115a321aee238c02de214009f8532a65368e5df5eaf732ee7167c"],"id":1}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + + let s = r#"{"jsonrpc":"2.0","method":"eth_getRawTransactionByBlockHashAndIndex","params":["0x3ed3a89bc10115a321aee238c02de214009f8532a65368e5df5eaf732ee7167c",1],"id":1}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + + let s = r#"{"jsonrpc":"2.0","method":"eth_getRawTransactionByBlockNumberAndIndex","params":["0x3ed3a89b",0],"id":1}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + } + #[test] fn test_serde_debug_trace_transaction() { let s = r#"{"method": "debug_traceTransaction", "params": diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 7f76e6a70e8f4..e28a8c4621f4e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -31,7 +31,7 @@ use crate::{ revm::primitives::{BlobExcessGasAndPrice, Output}, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; -use alloy_consensus::transaction::eip4844::TxEip4844Variant; +use alloy_consensus::{transaction::eip4844::TxEip4844Variant, TxEnvelope}; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; use alloy_network::eip2718::Decodable2718; @@ -235,6 +235,15 @@ impl EthApi { EthRequest::EthEstimateGas(call, block, overrides) => { self.estimate_gas(call, block, overrides).await.to_rpc_result() } + EthRequest::EthGetRawTransactionByHash(hash) => { + self.raw_transaction(hash).await.to_rpc_result() + } + EthRequest::EthGetRawTransactionByBlockHashAndIndex(hash, index) => { + self.raw_transaction_by_block_hash_and_index(hash, index).await.to_rpc_result() + } + EthRequest::EthGetRawTransactionByBlockNumberAndIndex(num, index) => { + self.raw_transaction_by_block_number_and_index(num, index).await.to_rpc_result() + } EthRequest::EthGetTransactionByBlockHashAndIndex(hash, index) => { self.transaction_by_block_hash_and_index(hash, index).await.to_rpc_result() } @@ -265,7 +274,10 @@ impl EthApi { EthRequest::EthFeeHistory(count, newest, reward_percentiles) => { self.fee_history(count, newest, reward_percentiles).await.to_rpc_result() } - + // non eth-standard rpc calls + EthRequest::DebugGetRawTransaction(hash) => { + self.raw_transaction(hash).await.to_rpc_result() + } // non eth-standard rpc calls EthRequest::DebugTraceTransaction(tx, opts) => { self.debug_trace_transaction(tx, opts).await.to_rpc_result() @@ -464,6 +476,19 @@ impl EthApi { Ok(block_request) } + async fn inner_raw_transaction(&self, hash: B256) -> Result> { + match self.pool.get_transaction(hash) { + Some(tx) => Ok(Some(tx.transaction.encoded_2718().into())), + None => match self.backend.transaction_by_hash(hash).await? { + Some(tx) => TxEnvelope::try_from(tx.inner) + .map_or(Err(BlockchainError::FailedToDecodeTransaction), |tx| { + Ok(Some(tx.encoded_2718().into())) + }), + None => Ok(None), + }, + } + } + /// Returns the current client version. /// /// Handler for ETH RPC call: `web3_clientVersion` @@ -906,6 +931,7 @@ impl EthApi { } let request = self.build_typed_tx_request(request, nonce)?; + // if the sender is currently impersonated we need to "bypass" signing let pending_transaction = if self.is_impersonated(from) { let bypass_signature = self.backend.cheats().bypass_signature(); @@ -1437,6 +1463,44 @@ impl EthApi { Ok(self.filters.uninstall_filter(id).await.is_some()) } + /// Returns EIP-2718 encoded raw transaction + /// + /// Handler for RPC call: `debug_getRawTransaction` + pub async fn raw_transaction(&self, hash: B256) -> Result> { + node_info!("debug_getRawTransaction"); + self.inner_raw_transaction(hash).await + } + + /// Returns EIP-2718 encoded raw transaction by block hash and index + /// + /// Handler for RPC call: `eth_getRawTransactionByBlockHashAndIndex` + pub async fn raw_transaction_by_block_hash_and_index( + &self, + block_hash: B256, + index: Index, + ) -> Result> { + node_info!("eth_getRawTransactionByBlockHashAndIndex"); + match self.backend.transaction_by_block_hash_and_index(block_hash, index).await? { + Some(tx) => self.inner_raw_transaction(tx.hash).await, + None => Ok(None), + } + } + + /// Returns EIP-2718 encoded raw transaction by block number and index + /// + /// Handler for RPC call: `eth_getRawTransactionByBlockNumberAndIndex` + pub async fn raw_transaction_by_block_number_and_index( + &self, + block_number: BlockNumber, + index: Index, + ) -> Result> { + node_info!("eth_getRawTransactionByBlockNumberAndIndex"); + match self.backend.transaction_by_block_number_and_index(block_number, index).await? { + Some(tx) => self.inner_raw_transaction(tx.hash).await, + None => Ok(None), + } + } + /// Returns traces for the transaction hash for geth's tracing endpoint /// /// Handler for RPC call: `debug_traceTransaction` diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 1565e587b1a94..10b99685491f1 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -723,7 +723,30 @@ async fn can_get_pending_transaction() { } #[tokio::test(flavor = "multi_thread")] -async fn test_first_noce_is_zero() { +async fn can_get_raw_transaction() { + let (api, handle) = spawn(NodeConfig::test()).await; + + // first test the pending tx, disable auto mine + api.anvil_set_auto_mine(false).await.unwrap(); + + let provider = handle.http_provider(); + + let from = handle.dev_wallets().next().unwrap().address(); + let tx = TransactionRequest::default().from(from).value(U256::from(1488)).to(Address::random()); + let tx = WithOtherFields::new(tx); + let tx = provider.send_transaction(tx).await.unwrap(); + + let res1 = api.raw_transaction(*tx.tx_hash()).await; + assert!(res1.is_ok()); + + api.mine_one().await; + let res2 = api.raw_transaction(*tx.tx_hash()).await; + + assert_eq!(res1.unwrap(), res2.unwrap()); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_first_nonce_is_zero() { let (api, handle) = spawn(NodeConfig::test()).await; api.anvil_set_auto_mine(false).await.unwrap(); From f6ad1e5d22ef725f12d062dd44d09ed22d4a2496 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:48:40 +0300 Subject: [PATCH 1097/1963] fix(invariant): weight invariant selectors by number of selectors (#8176) * fix(invariant): weight invariant selectors by number of selectors - Consolidate FuzzRunIdentifiedContracts logic - add function to flatten contracts function in order to be used by strategy - test * Changes after review: cleanup --- crates/evm/evm/src/executors/invariant/mod.rs | 28 ++--- crates/evm/fuzz/src/invariant/filters.rs | 3 +- crates/evm/fuzz/src/invariant/mod.rs | 89 +++++++++++++++ crates/evm/fuzz/src/strategies/invariants.rs | 67 ++++-------- crates/evm/fuzz/src/strategies/mod.rs | 2 +- crates/evm/fuzz/src/strategies/state.rs | 43 +------- crates/forge/tests/it/invariant.rs | 27 +++++ .../common/InvariantSelectorsWeight.t.sol | 101 ++++++++++++++++++ 8 files changed, 249 insertions(+), 111 deletions(-) create mode 100644 testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 4cbd8505d55b2..1eee0cafc6fdd 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -18,7 +18,7 @@ use foundry_evm_fuzz::{ ArtifactFilters, BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract, RandomCallGenerator, SenderFilters, TargetedContracts, }, - strategies::{collect_created_contracts, invariant_strat, override_call_strat, EvmFuzzState}, + strategies::{invariant_strat, override_call_strat, EvmFuzzState}, FuzzCase, FuzzFixtures, FuzzedCases, }; use foundry_evm_traces::CallTraceArena; @@ -251,17 +251,14 @@ impl<'a> InvariantExecutor<'a> { // Collect created contracts and add to fuzz targets only if targeted contracts // are updatable. - if targeted_contracts.is_updatable { - if let Err(error) = collect_created_contracts( - &state_changeset, - self.project_contracts, - self.setup_contracts, - &self.artifact_filters, - &targeted_contracts, - &mut created_contracts, - ) { - warn!(target: "forge::test", "{error}"); - } + if let Err(error) = &targeted_contracts.collect_created_contracts( + &state_changeset, + self.project_contracts, + self.setup_contracts, + &self.artifact_filters, + &mut created_contracts, + ) { + warn!(target: "forge::test", "{error}"); } fuzz_runs.push(FuzzCase { @@ -319,12 +316,7 @@ impl<'a> InvariantExecutor<'a> { } // We clear all the targeted contracts created during this run. - if !created_contracts.is_empty() { - let mut writable_targeted = targeted_contracts.targets.lock(); - for addr in created_contracts.iter() { - writable_targeted.remove(addr); - } - } + let _ = &targeted_contracts.clear_created_contracts(created_contracts); if gas_report_traces.borrow().len() < self.config.gas_report_samples as usize { gas_report_traces.borrow_mut().push(run_traces); diff --git a/crates/evm/fuzz/src/invariant/filters.rs b/crates/evm/fuzz/src/invariant/filters.rs index d0ebb33e5db1d..520e5b5afcd6e 100644 --- a/crates/evm/fuzz/src/invariant/filters.rs +++ b/crates/evm/fuzz/src/invariant/filters.rs @@ -25,8 +25,7 @@ impl ArtifactFilters { /// Gets all the targeted functions from `artifact`. Returns error, if selectors do not match /// the `artifact`. /// - /// An empty vector means that it targets any mutable function. See `select_random_function` for - /// more. + /// An empty vector means that it targets any mutable function. pub fn get_targeted_functions( &self, artifact: &ArtifactId, diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index 26c94351e2dd7..82938f6cc37c3 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -8,6 +8,8 @@ pub use call_override::RandomCallGenerator; mod filters; pub use filters::{ArtifactFilters, SenderFilters}; +use foundry_common::{ContractsByAddress, ContractsByArtifact}; +use foundry_evm_core::utils::StateChangeset; pub type TargetedContracts = BTreeMap)>; @@ -44,6 +46,93 @@ impl FuzzRunIdentifiedContracts { }; f(abi, abi_f); } + + /// Returns flatten target contract address and functions to be fuzzed. + /// Includes contract targeted functions if specified, else all mutable contract functions. + pub fn fuzzed_functions(&self) -> Vec<(Address, Function)> { + let mut fuzzed_functions = vec![]; + for (contract, (_, abi, functions)) in self.targets.lock().iter() { + if !abi.functions.is_empty() { + for function in abi_fuzzed_functions(abi, functions) { + fuzzed_functions.push((*contract, function.clone())); + } + } + } + fuzzed_functions + } + + /// If targets are updatable, collect all contracts created during an invariant run (which + /// haven't been discovered yet). + pub fn collect_created_contracts( + &self, + state_changeset: &StateChangeset, + project_contracts: &ContractsByArtifact, + setup_contracts: &ContractsByAddress, + artifact_filters: &ArtifactFilters, + created_contracts: &mut Vec
, + ) -> eyre::Result<()> { + if self.is_updatable { + let mut targets = self.targets.lock(); + for (address, account) in state_changeset { + if setup_contracts.contains_key(address) { + continue; + } + if !account.is_touched() { + continue; + } + let Some(code) = &account.info.code else { + continue; + }; + if code.is_empty() { + continue; + } + let Some((artifact, contract)) = + project_contracts.find_by_deployed_code(code.original_byte_slice()) + else { + continue; + }; + let Some(functions) = + artifact_filters.get_targeted_functions(artifact, &contract.abi)? + else { + continue; + }; + created_contracts.push(*address); + targets.insert(*address, (artifact.name.clone(), contract.abi.clone(), functions)); + } + } + Ok(()) + } + + /// Clears targeted contracts created during an invariant run. + pub fn clear_created_contracts(&self, created_contracts: Vec
) { + if !created_contracts.is_empty() { + let mut targets = self.targets.lock(); + for addr in created_contracts.iter() { + targets.remove(addr); + } + } + } +} + +/// Helper to retrieve functions to fuzz for specified abi. +/// Returns specified targeted functions if any, else mutable abi functions. +pub(crate) fn abi_fuzzed_functions( + abi: &JsonAbi, + targeted_functions: &[Function], +) -> Vec { + if !targeted_functions.is_empty() { + targeted_functions.to_vec() + } else { + abi.functions() + .filter(|&func| { + !matches!( + func.state_mutability, + alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View + ) + }) + .cloned() + .collect() + } } /// Details of a transaction generated by invariant strategy for fuzzing a target. diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 1c143f9222033..b3bb21372b10c 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -1,10 +1,13 @@ use super::{fuzz_calldata, fuzz_param_from_state}; use crate::{ - invariant::{BasicTxDetails, CallDetails, FuzzRunIdentifiedContracts, SenderFilters}, + invariant::{ + abi_fuzzed_functions, BasicTxDetails, CallDetails, FuzzRunIdentifiedContracts, + SenderFilters, + }, strategies::{fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, FuzzFixtures, }; -use alloy_json_abi::{Function, JsonAbi}; +use alloy_json_abi::Function; use alloy_primitives::Address; use parking_lot::RwLock; use proptest::prelude::*; @@ -37,7 +40,8 @@ pub fn override_call_strat( let (_, contract_specs) = contracts.iter().nth(rand_index).unwrap(); contract_specs }); - select_random_function(abi, functions) + let fuzzed_functions = abi_fuzzed_functions(abi, functions); + any::().prop_map(move |index| index.get(&fuzzed_functions).clone()) }; func.prop_flat_map(move |func| { @@ -64,27 +68,18 @@ pub fn invariant_strat( fuzz_fixtures: FuzzFixtures, ) -> impl Strategy { let senders = Rc::new(senders); - any::() - .prop_flat_map(move |selector| { - let (contract, func) = { - let contracts = contracts.targets.lock(); - let contracts = - contracts.iter().filter(|(_, (_, abi, _))| !abi.functions.is_empty()); - let (&contract, (_, abi, functions)) = selector.select(contracts); - - let func = select_random_function(abi, functions); - (contract, func) - }; - - let senders = senders.clone(); - let fuzz_state = fuzz_state.clone(); - let fuzz_fixtures = fuzz_fixtures.clone(); - func.prop_flat_map(move |func| { - let sender = select_random_sender(&fuzz_state, senders.clone(), dictionary_weight); - let contract = - fuzz_contract_with_calldata(&fuzz_state, &fuzz_fixtures, contract, func); - (sender, contract) - }) + any::() + .prop_flat_map(move |index| { + let (target_address, target_function) = + index.get(&contracts.fuzzed_functions()).clone(); + let sender = select_random_sender(&fuzz_state, senders.clone(), dictionary_weight); + let call_details = fuzz_contract_with_calldata( + &fuzz_state, + &fuzz_fixtures, + target_address, + target_function, + ); + (sender, call_details) }) .prop_map(|(sender, call_details)| BasicTxDetails { sender, call_details }) } @@ -112,30 +107,6 @@ fn select_random_sender( } } -/// Strategy to select a random mutable function from the abi. -/// -/// If `targeted_functions` is not empty, select one from it. Otherwise, take any -/// of the available abi functions. -fn select_random_function( - abi: &JsonAbi, - targeted_functions: &[Function], -) -> impl Strategy { - let functions = if !targeted_functions.is_empty() { - targeted_functions.to_vec() - } else { - abi.functions() - .filter(|&func| { - !matches!( - func.state_mutability, - alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View - ) - }) - .cloned() - .collect() - }; - any::().prop_map(move |index| index.get(&functions).clone()) -} - /// Given a function, it returns a proptest strategy which generates valid abi-encoded calldata /// for that function's input types. pub fn fuzz_contract_with_calldata( diff --git a/crates/evm/fuzz/src/strategies/mod.rs b/crates/evm/fuzz/src/strategies/mod.rs index bf284591b1816..1d8e647a52f3f 100644 --- a/crates/evm/fuzz/src/strategies/mod.rs +++ b/crates/evm/fuzz/src/strategies/mod.rs @@ -11,7 +11,7 @@ mod calldata; pub use calldata::{fuzz_calldata, fuzz_calldata_from_state}; mod state; -pub use state::{collect_created_contracts, EvmFuzzState}; +pub use state::EvmFuzzState; mod invariants; pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call_strat}; diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 39dd3a4679490..cf29c94209a5a 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,8 +1,7 @@ -use crate::invariant::{ArtifactFilters, BasicTxDetails, FuzzRunIdentifiedContracts}; +use crate::invariant::{BasicTxDetails, FuzzRunIdentifiedContracts}; use alloy_dyn_abi::{DynSolType, DynSolValue, EventExt, FunctionExt}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, Log, B256, U256}; -use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; use indexmap::IndexSet; @@ -381,43 +380,3 @@ impl FuzzDictionary { ); } } - -/// Collects all created contracts from a StateChangeset which haven't been discovered yet. Stores -/// them at `targeted_contracts` and `created_contracts`. -pub fn collect_created_contracts( - state_changeset: &StateChangeset, - project_contracts: &ContractsByArtifact, - setup_contracts: &ContractsByAddress, - artifact_filters: &ArtifactFilters, - targeted_contracts: &FuzzRunIdentifiedContracts, - created_contracts: &mut Vec
, -) -> eyre::Result<()> { - let mut writable_targeted = targeted_contracts.targets.lock(); - for (address, account) in state_changeset { - if setup_contracts.contains_key(address) { - continue; - } - if !account.is_touched() { - continue; - } - let Some(code) = &account.info.code else { - continue; - }; - if code.is_empty() { - continue; - } - let Some((artifact, contract)) = - project_contracts.find_by_deployed_code(code.original_byte_slice()) - else { - continue; - }; - let Some(functions) = artifact_filters.get_targeted_functions(artifact, &contract.abi)? - else { - continue; - }; - created_contracts.push(*address); - writable_targeted - .insert(*address, (artifact.name.clone(), contract.abi.clone(), functions)); - } - Ok(()) -} diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index f2a8d69f93e31..19500ab63df55 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -264,6 +264,10 @@ async fn test_invariant() { ), ("invariant_success()", true, None, None, None), ], + ), + ( + "default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol:InvariantSelectorsWeightTest", + vec![("invariant_selectors_weight()", true, None, None, None)], ) ]), ); @@ -765,3 +769,26 @@ async fn test_invariant_after_invariant() { )]), ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_selectors_weight() { + let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); + opts.fuzz.seed = Some(U256::from(119u32)); + + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantSelectorsWeight.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options = opts.clone(); + runner.test_options.invariant.runs = 1; + runner.test_options.invariant.depth = 30; + runner.test_options.invariant.failure_persist_dir = + Some(tempfile::tempdir().unwrap().into_path()); + + let results = runner.test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol:InvariantSelectorsWeightTest", + vec![("invariant_selectors_weight()", true, None, None, None)], + )]), + ) +} diff --git a/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol b/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol new file mode 100644 index 0000000000000..918fd7b019706 --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; + +contract HandlerWithOneSelector { + uint256 public hit1; + + function selector1() external { + hit1 += 1; + } +} + +contract HandlerWithFiveSelectors { + uint256 public hit2; + uint256 public hit3; + uint256 public hit4; + uint256 public hit5; + uint256 public hit6; + + function selector2() external { + hit2 += 1; + } + + function selector3() external { + hit3 += 1; + } + + function selector4() external { + hit4 += 1; + } + + function selector5() external { + hit5 += 1; + } + + function selector6() external { + hit6 += 1; + } +} + +contract HandlerWithFourSelectors { + uint256 public hit7; + uint256 public hit8; + uint256 public hit9; + uint256 public hit10; + + function selector7() external { + hit7 += 1; + } + + function selector8() external { + hit8 += 1; + } + + function selector9() external { + hit9 += 1; + } + + function selector10() external { + hit10 += 1; + } +} + +contract InvariantSelectorsWeightTest is DSTest { + HandlerWithOneSelector handlerOne; + HandlerWithFiveSelectors handlerTwo; + HandlerWithFourSelectors handlerThree; + + function setUp() public { + handlerOne = new HandlerWithOneSelector(); + handlerTwo = new HandlerWithFiveSelectors(); + handlerThree = new HandlerWithFourSelectors(); + } + + function afterInvariant() public { + // selector hits before and after https://github.com/foundry-rs/foundry/issues/2986 + // hit1: 11 | hit2: 4 | hit3: 0 | hit4: 0 | hit5: 4 | hit6: 1 | hit7: 2 | hit8: 2 | hit9: 2 | hit10: 4 + // hit1: 2 | hit2: 5 | hit3: 4 | hit4: 5 | hit5: 3 | hit6: 1 | hit7: 4 | hit8: 1 | hit9: 1 | hit10: 4 + + uint256 hit1 = handlerOne.hit1(); + uint256 hit2 = handlerTwo.hit2(); + uint256 hit3 = handlerTwo.hit3(); + uint256 hit4 = handlerTwo.hit4(); + uint256 hit5 = handlerTwo.hit5(); + uint256 hit6 = handlerTwo.hit6(); + uint256 hit7 = handlerThree.hit7(); + uint256 hit8 = handlerThree.hit8(); + uint256 hit9 = handlerThree.hit9(); + uint256 hit10 = handlerThree.hit10(); + + require( + hit1 > 0 && hit2 > 0 && hit3 > 0 && hit4 > 0 && hit5 > 0 && hit6 > 0 && hit7 > 0 && hit8 > 0 && hit9 > 0 + && hit10 > 0 + ); + } + + /// forge-config: default.invariant.runs = 1 + /// forge-config: default.invariant.depth = 30 + function invariant_selectors_weight() public view {} +} From f6730662831d0473f7207f4c0474a4bb6ee016eb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:28:44 +0200 Subject: [PATCH 1098/1963] perf: reduce clones in fuzzed_functions (#8178) --- crates/evm/fuzz/src/invariant/mod.rs | 26 +++++++++----------- crates/evm/fuzz/src/strategies/invariants.rs | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index 82938f6cc37c3..fdc0b9d56c311 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -1,5 +1,6 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes}; +use itertools::Either; use parking_lot::Mutex; use std::{collections::BTreeMap, sync::Arc}; @@ -116,22 +117,19 @@ impl FuzzRunIdentifiedContracts { /// Helper to retrieve functions to fuzz for specified abi. /// Returns specified targeted functions if any, else mutable abi functions. -pub(crate) fn abi_fuzzed_functions( - abi: &JsonAbi, - targeted_functions: &[Function], -) -> Vec { +pub(crate) fn abi_fuzzed_functions<'a>( + abi: &'a JsonAbi, + targeted_functions: &'a [Function], +) -> impl Iterator { if !targeted_functions.is_empty() { - targeted_functions.to_vec() + Either::Left(targeted_functions.iter()) } else { - abi.functions() - .filter(|&func| { - !matches!( - func.state_mutability, - alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View - ) - }) - .cloned() - .collect() + Either::Right(abi.functions().filter(|&func| { + !matches!( + func.state_mutability, + alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View + ) + })) } } diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index b3bb21372b10c..55af574c59895 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -40,7 +40,7 @@ pub fn override_call_strat( let (_, contract_specs) = contracts.iter().nth(rand_index).unwrap(); contract_specs }); - let fuzzed_functions = abi_fuzzed_functions(abi, functions); + let fuzzed_functions: Vec<_> = abi_fuzzed_functions(abi, functions).cloned().collect(); any::().prop_map(move |index| index.get(&fuzzed_functions).clone()) }; From 55ac4e4e918bb3cb17ff0b69d73c6a1190c80f78 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 17 Jun 2024 19:11:27 +0300 Subject: [PATCH 1099/1963] bump compilers (#8153) * [do not merge] patch compilers * fix import * fix doc * update patch * rm patch --- Cargo.lock | 85 ++++++++++++++++++++--- Cargo.toml | 4 +- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/cmd/storage.rs | 9 ++- crates/chisel/benches/session_source.rs | 2 +- crates/chisel/src/executor.rs | 2 +- crates/chisel/src/session_source.rs | 23 +++--- crates/chisel/tests/cache.rs | 2 +- crates/cli/src/opts/build/core.rs | 6 +- crates/cli/src/opts/build/mod.rs | 2 +- crates/cli/src/opts/build/paths.rs | 2 +- crates/common/src/compile.rs | 11 +-- crates/common/src/term.rs | 2 +- crates/config/src/lib.rs | 26 +++---- crates/config/src/providers/remappings.rs | 2 +- crates/config/src/utils.rs | 2 +- crates/config/src/vyper.rs | 2 +- crates/debugger/src/tui/draw.rs | 4 +- crates/doc/src/builder.rs | 2 +- crates/evm/coverage/src/anchors.rs | 2 +- crates/evm/coverage/src/lib.rs | 2 +- crates/evm/evm/src/executors/tracing.rs | 2 +- crates/forge/bin/cmd/clone.rs | 14 ++-- crates/forge/bin/cmd/coverage.rs | 3 +- crates/forge/bin/cmd/flatten.rs | 19 ++--- crates/forge/bin/cmd/fmt.rs | 2 +- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/tests/cli/cmd.rs | 2 +- crates/forge/tests/cli/config.rs | 4 +- crates/forge/tests/cli/create.rs | 2 +- crates/forge/tests/it/test_helpers.rs | 4 +- crates/verify/src/bytecode.rs | 4 +- crates/verify/src/etherscan/flatten.rs | 3 +- crates/verify/src/lib.rs | 2 +- crates/verify/src/provider.rs | 3 +- 36 files changed, 173 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7080d1989a58..3622135a90921 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3489,9 +3489,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35344cf275788b0450c4b36d452b812d1122d622bafb29887ce244b8099a86ad" +checksum = "328cd3498bd9a7615d3a2f2e0e94a5d2ffc1db54cb6b4e933d01f77272ff43e5" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3642,29 +3642,27 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f9b10619d07d765a0336b1990ffcb1bb7b806a59b4d2e65cb78f5d77f373c5" +checksum = "e2ea36984de5126fe2b05efb22d04148c39f244de1cc285493e3c2a4cfcc843a" dependencies = [ "alloy-json-abi", "alloy-primitives", "auto_impl", - "cfg-if", "derivative", "dirs 5.0.1", - "dunce", "dyn-clone", + "foundry-compilers-artifacts", + "foundry-compilers-core", "fs_extra", "futures-util", "home", "itertools 0.13.0", "md-5", - "memmap2 0.9.4", "once_cell", "path-slash", "rand", "rayon", - "regex", "semver 1.0.23", "serde", "serde_json", @@ -3676,11 +3674,80 @@ dependencies = [ "thiserror", "tokio", "tracing", - "walkdir", "winnow 0.6.13", "yansi", ] +[[package]] +name = "foundry-compilers-artifacts" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5795278ec3d726eb4ec932ea452a05c880780fbb677aef06f5eeab3d0e2ae075" +dependencies = [ + "foundry-compilers-artifacts-solc", + "foundry-compilers-artifacts-vyper", +] + +[[package]] +name = "foundry-compilers-artifacts-solc" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f19355ab89cd2b782c6d791d7cb16b7733074a7945443668183e7c258d007a" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "foundry-compilers-core", + "futures-util", + "md-5", + "path-slash", + "rayon", + "semver 1.0.23", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "walkdir", + "yansi", +] + +[[package]] +name = "foundry-compilers-artifacts-vyper" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05564ba0e04eb361e264e68d5e7d5b69e272d7d378f22c5c6a2edbe6d1cc3b58" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "foundry-compilers-artifacts-solc", + "path-slash", + "serde", +] + +[[package]] +name = "foundry-compilers-core" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "208e1a34268fbfccea0a8d4c974db01bfa44dac370724907ad404ccb79455b64" +dependencies = [ + "alloy-primitives", + "cfg-if", + "dunce", + "fs_extra", + "memmap2 0.9.4", + "once_cell", + "path-slash", + "regex", + "semver 1.0.23", + "serde", + "serde_json", + "svm-rs", + "tempfile", + "thiserror", + "tokio", + "walkdir", +] + [[package]] name = "foundry-config" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 368d94521ed55..c088c257355de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,8 +153,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.4.0", default-features = false } -foundry-compilers = { version = "0.7.0", default-features = false } +foundry-block-explorers = { version = "0.4.1", default-features = false } +foundry-compilers = { version = "0.8.0", default-features = false } ## revm # no default features to avoid c-kzg diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 5f4975fcc79ac..0499f5e7b2752 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -9,7 +9,7 @@ use foundry_cli::{ utils::{self, handle_traces, parse_ether_value, TraceResult}, }; use foundry_common::ens::NameOrAddress; -use foundry_compilers::EvmVersion; +use foundry_compilers::artifacts::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{executors::TracingExecutor, opts::EvmOpts}; use std::str::FromStr; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 451964045fd54..c830f5ab1aa4d 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -9,7 +9,7 @@ use foundry_cli::{ utils::{handle_traces, init_progress, TraceResult}, }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; -use foundry_compilers::EvmVersion; +use foundry_compilers::artifacts::EvmVersion; use foundry_config::{find_project_root_path, Config}; use foundry_evm::{ executors::{EvmError, TracingExecutor}, diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index aedf8447190ca..117130943dc52 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -19,9 +19,12 @@ use foundry_common::{ ens::NameOrAddress, }; use foundry_compilers::{ - artifacts::StorageLayout, - compilers::{solc::SolcCompiler, Compiler, CompilerSettings}, - Artifact, ConfigurableContractArtifact, Project, Solc, + artifacts::{ConfigurableContractArtifact, StorageLayout}, + compilers::{ + solc::{Solc, SolcCompiler}, + Compiler, CompilerSettings, + }, + Artifact, Project, }; use foundry_config::{ figment::{self, value::Dict, Metadata, Profile}, diff --git a/crates/chisel/benches/session_source.rs b/crates/chisel/benches/session_source.rs index 37f35f05ee579..f54944966d975 100644 --- a/crates/chisel/benches/session_source.rs +++ b/crates/chisel/benches/session_source.rs @@ -1,6 +1,6 @@ use chisel::session_source::{SessionSource, SessionSourceConfig}; use criterion::{criterion_group, Criterion}; -use foundry_compilers::Solc; +use foundry_compilers::solc::Solc; use once_cell::sync::Lazy; use semver::Version; use std::hint::black_box; diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index a177aa211fcf0..58059a0ac1286 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1392,7 +1392,7 @@ impl<'a> Iterator for InstructionIter<'a> { #[cfg(test)] mod tests { use super::*; - use foundry_compilers::{error::SolcError, Solc}; + use foundry_compilers::{error::SolcError, solc::Solc}; use semver::Version; use std::sync::Mutex; diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 500cd97ef00be..f83eefeae80ca 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -7,8 +7,8 @@ use eyre::Result; use forge_fmt::solang_ext::SafeUnwrap; use foundry_compilers::{ - artifacts::{Settings, Source, Sources}, - CompilerOutput, Solc, SolcInput, + artifacts::{CompilerOutput, Settings, SolcInput, Source, Sources}, + compilers::solc::Solc, }; use foundry_config::{Config, SolcReq}; use foundry_evm::{backend::Backend, opts::EvmOpts}; @@ -115,16 +115,15 @@ impl SessionSourceConfig { } } - let solc = - if let Some(solc) = Solc::find_svm_installed_version(version.to_string())? { - solc - } else { - if self.foundry_config.offline { - eyre::bail!("can't install missing solc {version} in offline mode") - } - println!("{}", format!("Installing solidity version {version}...").green()); - Solc::blocking_install(&version)? - }; + let solc = if let Some(solc) = Solc::find_svm_installed_version(&version)? { + solc + } else { + if self.foundry_config.offline { + eyre::bail!("can't install missing solc {version} in offline mode") + } + println!("{}", format!("Installing solidity version {version}...").green()); + Solc::blocking_install(&version)? + }; Ok(solc) } SolcReq::Local(solc) => { diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index 7be980ec83073..5f0864beeeb8a 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -1,5 +1,5 @@ use chisel::session::ChiselSession; -use foundry_compilers::EvmVersion; +use foundry_compilers::artifacts::EvmVersion; use foundry_config::{Config, SolcReq}; use semver::Version; use serial_test::serial; diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 5f27afaa6f55f..a6d9d9911e03f 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -3,8 +3,10 @@ use crate::{opts::CompilerArgs, utils::LoadConfig}; use clap::{Parser, ValueHint}; use eyre::Result; use foundry_compilers::{ - artifacts::RevertStrings, compilers::multi::MultiCompiler, remappings::Remapping, - utils::canonicalized, Project, + artifacts::{remappings::Remapping, RevertStrings}, + compilers::multi::MultiCompiler, + utils::canonicalized, + Project, }; use foundry_config::{ figment, diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index 2ed2ea4630dd3..4ffd1c3bff996 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -1,5 +1,5 @@ use clap::Parser; -use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, EvmVersion}; +use foundry_compilers::artifacts::{output_selection::ContractOutputSelection, EvmVersion}; use serde::Serialize; mod core; diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index 9ec2dc0013665..9553eedb0d98e 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -1,6 +1,6 @@ use clap::{Parser, ValueHint}; use eyre::Result; -use foundry_compilers::remappings::Remapping; +use foundry_compilers::artifacts::remappings::Remapping; use foundry_config::{ figment, figment::{ diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 3488e6482a00a..ffefe141a316f 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -5,11 +5,14 @@ use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ - artifacts::{BytecodeObject, ContractBytecodeSome, Libraries, Source}, - compilers::{multi::MultiCompilerLanguage, solc::SolcCompiler, Compiler}, - remappings::Remapping, + artifacts::{remappings::Remapping, BytecodeObject, ContractBytecodeSome, Libraries, Source}, + compilers::{ + multi::MultiCompilerLanguage, + solc::{Solc, SolcCompiler}, + Compiler, + }, report::{BasicStdoutReporter, NoReporter, Report}, - Artifact, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig, + Artifact, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, SolcConfig, }; use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 3fcc8f7fb9602..925456e4c65f2 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -1,6 +1,6 @@ //! terminal utils use foundry_compilers::{ - remappings::Remapping, + artifacts::remappings::Remapping, report::{self, BasicStdoutReporter, Reporter}, }; use once_cell::sync::Lazy; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 463ea82aa1181..e9396e3a4ca1e 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -19,20 +19,20 @@ use figment::{ use foundry_compilers::{ artifacts::{ output_selection::{ContractOutputSelection, OutputSelection}, - serde_helpers, BytecodeHash, DebuggingSettings, Libraries, ModelCheckerSettings, - ModelCheckerTarget, Optimizer, OptimizerDetails, RevertStrings, Settings, SettingsMetadata, - Severity, + remappings::{RelativeRemapping, Remapping}, + serde_helpers, BytecodeHash, DebuggingSettings, EvmVersion, Libraries, + ModelCheckerSettings, ModelCheckerTarget, Optimizer, OptimizerDetails, RevertStrings, + Settings, SettingsMetadata, Severity, }, cache::SOLIDITY_FILES_CACHE_FILENAME, compilers::{ multi::{MultiCompiler, MultiCompilerSettings}, - solc::SolcCompiler, + solc::{Solc, SolcCompiler}, vyper::{Vyper, VyperSettings}, Compiler, }, error::SolcError, - remappings::{RelativeRemapping, Remapping}, - ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc, + ConfigurableArtifacts, Project, ProjectPathsConfig, }; use inflector::Inflector; use regex::Regex; @@ -851,7 +851,7 @@ impl Config { if let Some(ref solc) = self.solc { let solc = match solc { SolcReq::Version(version) => { - if let Some(solc) = Solc::find_svm_installed_version(version.to_string())? { + if let Some(solc) = Solc::find_svm_installed_version(version)? { solc } else { if self.offline { @@ -913,12 +913,12 @@ impl Config { /// # Example /// /// ``` - /// use foundry_compilers::Solc; + /// use foundry_compilers::solc::Solc; /// use foundry_config::Config; /// let config = Config::load_with_root(".").sanitized(); /// let paths = config.project_paths::(); /// ``` - pub fn project_paths(&self) -> ProjectPathsConfig { + pub fn project_paths(&self) -> ProjectPathsConfig { let mut builder = ProjectPathsConfig::builder() .cache(self.cache_path.join(SOLIDITY_FILES_CACHE_FILENAME)) .sources(&self.src) @@ -1240,7 +1240,8 @@ impl Config { /// Returns all libraries with applied remappings. Same as `self.solc_settings()?.libraries`. pub fn libraries_with_remappings(&self) -> Result { - Ok(self.parsed_libraries()?.with_applied_remappings(&self.project_paths())) + let paths: ProjectPathsConfig = self.project_paths(); + Ok(self.parsed_libraries()?.apply(|libs| paths.apply_lib_remappings(libs))) } /// Returns the configured `solc` `Settings` that includes: @@ -2816,9 +2817,8 @@ mod tests { etherscan::ResolvedEtherscanConfigs, }; use figment::error::Kind::InvalidType; - use foundry_compilers::{ - artifacts::{ModelCheckerEngine, YulDetails}, - compilers::vyper::settings::VyperOptimizationMode, + use foundry_compilers::artifacts::{ + vyper::VyperOptimizationMode, ModelCheckerEngine, YulDetails, }; use similar_asserts::assert_eq; use std::{collections::BTreeMap, fs::File, io::Write}; diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 2bfbf4ca4e108..41b3fb80dacf4 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -3,7 +3,7 @@ use figment::{ value::{Dict, Map}, Error, Metadata, Profile, Provider, }; -use foundry_compilers::remappings::{RelativeRemapping, Remapping}; +use foundry_compilers::artifacts::remappings::{RelativeRemapping, Remapping}; use std::{ borrow::Cow, collections::{btree_map::Entry, BTreeMap, HashSet}, diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index cb23500088b4e..17af4789d5869 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -4,7 +4,7 @@ use crate::Config; use alloy_primitives::U256; use eyre::WrapErr; use figment::value::Value; -use foundry_compilers::{ +use foundry_compilers::artifacts::{ remappings::{Remapping, RemappingError}, EvmVersion, }; diff --git a/crates/config/src/vyper.rs b/crates/config/src/vyper.rs index 79d3fc01dc4ea..2af46b4b6576c 100644 --- a/crates/config/src/vyper.rs +++ b/crates/config/src/vyper.rs @@ -1,6 +1,6 @@ //! Vyper specific configuration types. -use foundry_compilers::compilers::vyper::settings::VyperOptimizationMode; +use foundry_compilers::artifacts::vyper::VyperOptimizationMode; use serde::{Deserialize, Serialize}; use std::path::PathBuf; diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 06056034cd056..7ac0c64e5c6e0 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -3,7 +3,9 @@ use super::context::{BufferKind, DebuggerContext}; use crate::op::OpcodeParam; use alloy_primitives::U256; -use foundry_compilers::{compilers::multi::MultiCompilerLanguage, sourcemap::SourceElement}; +use foundry_compilers::{ + artifacts::sourcemap::SourceElement, compilers::multi::MultiCompilerLanguage, +}; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index 3c8270a3a21c4..e21e80c22bd5b 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -3,7 +3,7 @@ use crate::{ ParseSource, Parser, Preprocessor, }; use forge_fmt::{FormatterConfig, Visitable}; -use foundry_compilers::{utils::source_files_iter, SOLC_EXTENSIONS}; +use foundry_compilers::{compilers::solc::SOLC_EXTENSIONS, utils::source_files_iter}; use foundry_config::{filter::expand_globs, DocConfig}; use itertools::Itertools; use mdbook::MDBook; diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index a31ef0237fd0e..ad4ad744d2072 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -1,6 +1,6 @@ use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; use eyre::ensure; -use foundry_compilers::sourcemap::{SourceElement, SourceMap}; +use foundry_compilers::artifacts::sourcemap::{SourceElement, SourceMap}; use foundry_evm_core::utils::IcPcMap; use revm::interpreter::opcode; use rustc_hash::{FxHashMap, FxHashSet}; diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 15588296fd8f8..22f4b9808e797 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -9,7 +9,7 @@ extern crate tracing; use alloy_primitives::{Bytes, B256}; -use foundry_compilers::sourcemap::SourceMap; +use foundry_compilers::artifacts::sourcemap::SourceMap; use semver::Version; use std::{ collections::{BTreeMap, HashMap}, diff --git a/crates/evm/evm/src/executors/tracing.rs b/crates/evm/evm/src/executors/tracing.rs index a175aecb6f739..08c5d92ef5b2f 100644 --- a/crates/evm/evm/src/executors/tracing.rs +++ b/crates/evm/evm/src/executors/tracing.rs @@ -1,5 +1,5 @@ use crate::executors::{Executor, ExecutorBuilder}; -use foundry_compilers::EvmVersion; +use foundry_compilers::artifacts::EvmVersion; use foundry_config::{utils::evm_spec_id, Chain, Config}; use foundry_evm_core::{backend::Backend, fork::CreateFork, opts::EvmOpts}; use revm::primitives::{Env, SpecId}; diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 822f595fb0212..97f6383e31c7e 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -10,9 +10,13 @@ use foundry_block_explorers::{ use foundry_cli::{opts::EtherscanOpts, p_println, utils::Git}; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ - artifacts::{output_selection::ContractOutputSelection, Settings, StorageLayout}, - remappings::{RelativeRemapping, Remapping}, - ConfigurableContractArtifact, ProjectCompileOutput, ProjectPathsConfig, Solc, + artifacts::{ + output_selection::ContractOutputSelection, + remappings::{RelativeRemapping, Remapping}, + ConfigurableContractArtifact, Settings, StorageLayout, + }, + compilers::solc::Solc, + ProjectCompileOutput, ProjectPathsConfig, }; use foundry_config::{Chain, Config}; use std::{ @@ -388,9 +392,9 @@ fn update_config_by_metadata( } // apply remapping on libraries - let path_config = config.project_paths(); + let path_config: ProjectPathsConfig = config.project_paths(); let libraries = libraries - .with_applied_remappings(&path_config) + .apply(|libs| path_config.apply_lib_remappings(libs)) .with_stripped_file_prefixes(&path_config.root); // update libraries diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index b6a549742c68e..dc9b25c148ec0 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -19,8 +19,7 @@ use foundry_cli::{ }; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ - artifacts::{CompactBytecode, CompactDeployedBytecode}, - sourcemap::SourceMap, + artifacts::{sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode}, Artifact, ArtifactId, Project, ProjectCompileOutput, }; use foundry_config::{Config, SolcReq}; diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 3cd5abb683bf7..64c4ea78f5d3f 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -4,8 +4,12 @@ use foundry_cli::{ opts::{CoreBuildArgs, ProjectPathsArgs}, utils::LoadConfig, }; -use foundry_common::{compile::compile_target, fs}; -use foundry_compilers::{compilers::solc::SolcLanguage, error::SolcError, flatten::Flattener}; +use foundry_common::fs; +use foundry_compilers::{ + compilers::solc::SolcLanguage, + error::SolcError, + flatten::{Flattener, FlattenerError}, +}; use std::path::PathBuf; /// CLI arguments for `forge flatten`. @@ -42,18 +46,17 @@ impl FlattenArgs { let project = config.create_project(false, true)?; let target_path = dunce::canonicalize(target_path)?; - let compiler_output = compile_target(&target_path, &project, false); + let flattener = Flattener::new(project.clone(), &target_path); - let flattened = match compiler_output { - Ok(compiler_output) => { - Flattener::new(&project, &compiler_output, &target_path).map(|f| f.flatten()) - } - Err(_) => { + let flattened = match flattener { + Ok(flattener) => Ok(flattener.flatten()), + Err(FlattenerError::Compilation(_)) => { // Fallback to the old flattening implementation if we couldn't compile the target // successfully. This would be the case if the target has invalid // syntax. (e.g. Solang) project.paths.clone().with_language::().flatten(&target_path) } + Err(FlattenerError::Other(err)) => Err(err), } .map_err(|err: SolcError| eyre::eyre!("Failed to flatten: {err}"))?; diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 55ba71780926d..bcfae7769d112 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -3,7 +3,7 @@ use eyre::{Context, Result}; use forge_fmt::{format_to, parse}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; use foundry_common::{fs, term::cli_warn}; -use foundry_compilers::{compilers::solc::SolcLanguage, SOLC_EXTENSIONS}; +use foundry_compilers::{compilers::solc::SolcLanguage, solc::SOLC_EXTENSIONS}; use foundry_config::{filter::expand_globs, impl_figment_convert_basic}; use rayon::prelude::*; use similar::{ChangeTag, TextDiff}; diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 5c2b56ea8ce14..f19bc1de2f2bf 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -3,7 +3,7 @@ use clap::{Parser, ValueHint}; use eyre::Result; use foundry_cli::{p_println, utils::Git}; use foundry_common::fs; -use foundry_compilers::remappings::Remapping; +use foundry_compilers::artifacts::remappings::Remapping; use foundry_config::Config; use std::path::{Path, PathBuf}; use yansi::Paint; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 1c851dd090068..016ac29f0f70b 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1,7 +1,7 @@ //! Contains various tests for checking forge's commands use crate::constants::*; -use foundry_compilers::{artifacts::Metadata, remappings::Remapping, ConfigurableContractArtifact}; +use foundry_compilers::artifacts::{remappings::Remapping, ConfigurableContractArtifact, Metadata}; use foundry_config::{ parse_with_profile, BasicConfig, Chain, Config, FuzzConfig, InvariantConfig, SolidityErrorCode, }; diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index bd5598470ba15..c7b3abd2ecc4f 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -4,7 +4,7 @@ use alloy_primitives::{Address, B256, U256}; use foundry_cli::utils as forge_utils; use foundry_compilers::{ artifacts::{BytecodeHash, OptimizerDetails, RevertStrings, YulDetails}, - Solc, + solc::Solc, }; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, @@ -13,7 +13,7 @@ use foundry_config::{ }; use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ - foundry_compilers::{remappings::Remapping, EvmVersion}, + foundry_compilers::artifacts::{remappings::Remapping, EvmVersion}, util::{pretty_err, OutputExt, TestCommand, OTHER_SOLC_VERSION}, }; use path_slash::PathBufExt; diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index c9484db0f21ce..0df24f88bf12e 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -6,7 +6,7 @@ use crate::{ }; use alloy_primitives::Address; use anvil::{spawn, NodeConfig}; -use foundry_compilers::{artifacts::BytecodeHash, remappings::Remapping}; +use foundry_compilers::artifacts::{remappings::Remapping, BytecodeHash}; use foundry_config::Config; use foundry_test_utils::{ forgetest, forgetest_async, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index d9f5298b172be..3bf2ae327bd68 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -6,8 +6,8 @@ use forge::{ TestOptionsBuilder, }; use foundry_compilers::{ - artifacts::{Libraries, Settings}, - EvmVersion, Project, ProjectCompileOutput, SolcConfig, + artifacts::{EvmVersion, Libraries, Settings}, + Project, ProjectCompileOutput, SolcConfig, }; use foundry_config::{ fs_permissions::PathPermission, Config, FsPermissions, FuzzConfig, FuzzDictionaryConfig, diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 15923334880e4..44b1f55425194 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -10,9 +10,9 @@ use foundry_cli::{ }; use foundry_common::{compile::ProjectCompiler, provider::ProviderBuilder}; use foundry_compilers::{ - artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode}, + artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode, EvmVersion}, info::ContractInfo, - Artifact, EvmVersion, + Artifact, }; use foundry_config::{figment, filter::SkipBuildFilter, impl_figment_convert, Chain, Config}; use foundry_evm::{ diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index ac586b48cd13e..92c0083e6c29f 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -9,7 +9,8 @@ use foundry_compilers::{ solc::{SolcCompiler, SolcLanguage, SolcVersionedInput}, Compiler, CompilerInput, }, - AggregatedCompilerOutput, Solc, + solc::Solc, + AggregatedCompilerOutput, }; use semver::{BuildMetadata, Version}; use std::{collections::BTreeMap, path::Path}; diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rs index d3edcf62f87a2..5edda5b085c37 100644 --- a/crates/verify/src/lib.rs +++ b/crates/verify/src/lib.rs @@ -17,7 +17,7 @@ use foundry_cli::{ utils::{self, LoadConfig}, }; use foundry_common::{compile::ProjectCompiler, ContractsByArtifact}; -use foundry_compilers::{info::ContractInfo, EvmVersion, Solc}; +use foundry_compilers::{artifacts::EvmVersion, compilers::solc::Solc, info::ContractInfo}; use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config, SolcReq}; use itertools::Itertools; use provider::VerificationProviderType; diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index 7d29f614666f1..12dfb23f66a9a 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -9,7 +9,8 @@ use foundry_common::compile::ProjectCompiler; use foundry_compilers::{ artifacts::{output_selection::OutputSelection, Metadata, Source}, compilers::{multi::MultiCompilerParsedSource, solc::SolcCompiler, CompilerSettings}, - Graph, Project, Solc, + solc::Solc, + Graph, Project, }; use foundry_config::Config; use semver::Version; From 35356b032ee8dfb8dc4a797ff06419ed56a4e980 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 17 Jun 2024 20:41:43 +0300 Subject: [PATCH 1100/1963] fix: make `paths` a positional argument (#8158) * fix: move paths to BuildArgs * tests * dirs -> paths --- crates/cli/src/opts/build/core.rs | 5 ----- crates/forge/bin/cmd/build.rs | 11 ++++++++--- crates/forge/tests/cli/cmd.rs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index a6d9d9911e03f..81fbdf4cbb41b 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -128,11 +128,6 @@ pub struct CoreBuildArgs { #[serde(skip)] pub skip: Option>, - /// Build source files from specified paths. - #[arg(long, short, num_args(0..))] - #[serde(skip)] - pub paths: Option>, - #[command(flatten)] #[serde(flatten)] pub compiler: CompilerArgs, diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 82d5c834e3e21..8e7f7c9a3987b 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -18,6 +18,7 @@ use foundry_config::{ Config, }; use serde::Serialize; +use std::path::PathBuf; use watchexec::config::{InitConfig, RuntimeConfig}; foundry_config::merge_impl_figment_convert!(BuildArgs, args); @@ -46,6 +47,10 @@ foundry_config::merge_impl_figment_convert!(BuildArgs, args); #[derive(Clone, Debug, Default, Serialize, Parser)] #[command(next_help_heading = "Build options", about = None, long_about = None)] // override doc pub struct BuildArgs { + /// Build source files from specified paths. + #[serde(skip)] + pub paths: Option>, + /// Print compiled contract names. #[arg(long)] #[serde(skip)] @@ -86,9 +91,9 @@ impl BuildArgs { // Collect sources to compile if build subdirectories specified. let mut files = vec![]; - if let Some(dirs) = self.args.paths { - for dir in dirs { - files.extend(source_files_iter(dir, MultiCompilerLanguage::FILE_EXTENSIONS)); + if let Some(paths) = self.paths { + for path in paths { + files.extend(source_files_iter(path, MultiCompilerLanguage::FILE_EXTENSIONS)); } } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 016ac29f0f70b..65f5f6ae81d44 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1696,7 +1696,7 @@ function test_bar() external {} // Build 2 files within test dir prj.clear(); - cmd.args(["build", "--paths", "test", "--force"]); + cmd.args(["build", "test", "--force"]); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests/fixtures/can_build_path_with_two_files.stdout"), @@ -1705,7 +1705,7 @@ function test_bar() external {} // Build one file within src dir prj.clear(); cmd.forge_fuse(); - cmd.args(["build", "--paths", "src", "--force"]); + cmd.args(["build", "src", "--force"]); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests/fixtures/can_build_path_with_one_file.stdout"), @@ -1714,7 +1714,7 @@ function test_bar() external {} // Build 3 files from test and src dirs prj.clear(); cmd.forge_fuse(); - cmd.args(["build", "--paths", "src", "test", "--force"]); + cmd.args(["build", "src", "test", "--force"]); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests/fixtures/can_build_path_with_three_files.stdout"), @@ -1723,7 +1723,7 @@ function test_bar() external {} // Build single test file prj.clear(); cmd.forge_fuse(); - cmd.args(["build", "--paths", "test/Bar.sol", "--force"]); + cmd.args(["build", "test/Bar.sol", "--force"]); cmd.unchecked_output().stdout_matches_path( PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests/fixtures/can_build_path_with_one_file.stdout"), From c8f771a05157c27dbd7397f46fa347d6c1abb752 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:36:29 +0530 Subject: [PATCH 1101/1963] chore(deps): pin alloy 0.1.1 (#8182) * chore(deps): pin alloy 0.1.1 * bump revm and apply patch --- Cargo.lock | 273 +++++++++++++++++++++++------------ Cargo.toml | 54 +++---- crates/cheatcodes/src/lib.rs | 2 +- 3 files changed, 212 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3622135a90921..aead342de9fae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,8 +79,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc7579e4fb5558af44810f542c90d1145dba8b92c08211c215196160c48d2ea" dependencies = [ "alloy-eips", "alloy-primitives", @@ -92,8 +93,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "860887f0f7e1e17db33ada75c3c516164a5e11aa89f0311f4d23b82abcf2d807" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -132,8 +134,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bdbc8d98cc36ebe17bb5b42d0873137bc76628a4ee0f7e7acad5b8fc59d3597" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -147,8 +150,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e10a047066076b32d52b3228e95a4f7793db7a204f648aa1a1ea675085bffd8" dependencies = [ "alloy-primitives", "alloy-serde", @@ -170,8 +174,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d06d33b79246313c4103ef9596c721674a926f1ddc8b605aa2bac4d8ba94ee34" dependencies = [ "alloy-primitives", "serde", @@ -182,8 +187,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef742b478a2db5c27063cde82128dfbecffcd38237d7f682a91d3ecf6aa1836c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -228,8 +234,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200b786259a17acf318b9c423afe9669bec24ce9cdf59de153ff9a4009914bb6" dependencies = [ "alloy-chains", "alloy-consensus", @@ -254,7 +261,7 @@ dependencies = [ "futures-utils-wasm", "lru", "pin-project 1.1.5", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde", "serde_json", "tokio", @@ -264,8 +271,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e6e6c1eab938a18a8e88d430cc9d548edf54c850a550873888285c85428eca" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -304,8 +312,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "328a6a14aba6152ddf6d01bac5e17a70dbe9d6f343bf402b995c30bac63a1fbf" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -316,7 +325,7 @@ dependencies = [ "alloy-transport-ws", "futures", "pin-project 1.1.5", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde", "serde_json", "tokio", @@ -328,8 +337,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3164e7d8a718a22ede70b2c1d2bb554a8b4bd8e56c07ab630b75c74c06c53752" dependencies = [ "alloy-rpc-types-eth", "alloy-rpc-types-trace", @@ -339,8 +349,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90c3de574f90d9b939e3ee666a74bea29fb1a2ae66f1569b111bb6a922b1c762" dependencies = [ "alloy-consensus", "alloy-eips", @@ -356,8 +367,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bce0676f144be1eae71122d1d417885a3b063add0353b35e46cdf1440d6b33b1" dependencies = [ "alloy-consensus", "alloy-eips", @@ -373,8 +385,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a39c52613dc4d9995ff284b496158594ae63f9bfc58b5ef04e48ec5da2e3d747" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -385,8 +398,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aeb7995e8859f3931b6199e13a533c9fde89affa900addb7218db2f15f9687d" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -396,8 +410,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c224916316519558d8c2b6a60dc7626688c08f1b8951774702562dbcb8666ee" dependencies = [ "alloy-primitives", "serde", @@ -406,8 +421,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "227c5fd0ed6e06e1ccc30593f8ff6d9fb907ac5f03a709a6d687f0943494a229" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -421,8 +437,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723009d673de375a1f2d5fe4a1b32fea144001578db54b2dd5c817eaa9f09c25" dependencies = [ "alloy-consensus", "alloy-network", @@ -438,8 +455,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97eae91202844e3cde7281d8343fd848bbae8bd53cf3f92450a66ba989c12b34" dependencies = [ "alloy-consensus", "alloy-network", @@ -455,8 +473,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d3a65e52c3c1848510d69e73e716139839f701134465bf44b77a7e43c1362f6" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -474,8 +493,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c44057ac1e8707f8c6a983db9f83ac1265c9e05be81d432acf2aad2880e1c0" dependencies = [ "alloy-consensus", "alloy-network", @@ -493,8 +513,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85f68408899f493c3fd432e680f7ab586a38b9d2c8c117190855157dac70d9c4" dependencies = [ "alloy-consensus", "alloy-network", @@ -581,8 +602,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3628d81530263fe837a09cd527022f5728202a669973f04270942f4d390b5f5" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -598,12 +620,13 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f35d34e7a51503c9ff267404a5850bd58f991b7ab524b892f364901e3576376" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.4", + "reqwest 0.12.5", "serde_json", "tower", "tracing", @@ -612,8 +635,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7d2f106151a583f7d258fe8cc846c5196da90a9f502d4b3516c56d63e1f25a2" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -632,8 +656,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=6cb3713#6cb3713a14c047cd5fcf17b99d27055341c41aaf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20a80da44d3709c4ceaf47745ad820eae8f121404b9ffd8e285522ac4eb06681" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -642,7 +667,7 @@ dependencies = [ "rustls 0.23.10", "serde_json", "tokio", - "tokio-tungstenite 0.23.0", + "tokio-tungstenite 0.23.1", "tracing", "ws_stream_wasm", ] @@ -1978,7 +2003,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest 0.12.4", + "reqwest 0.12.5", "revm", "rustyline", "semver 1.0.23", @@ -3318,7 +3343,7 @@ dependencies = [ "proptest", "rayon", "regex", - "reqwest 0.12.4", + "reqwest 0.12.5", "revm-inspectors", "rustc-hash", "semver 1.0.23", @@ -3467,7 +3492,7 @@ dependencies = [ "itertools 0.13.0", "once_cell", "regex", - "reqwest 0.12.4", + "reqwest 0.12.5", "revm-primitives", "semver 1.0.23", "serde", @@ -3497,7 +3522,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers", - "reqwest 0.12.4", + "reqwest 0.12.5", "semver 1.0.23", "serde", "serde_json", @@ -3625,7 +3650,7 @@ dependencies = [ "foundry-macros", "num-format", "once_cell", - "reqwest 0.12.4", + "reqwest 0.12.5", "rustc-hash", "semver 1.0.23", "serde", @@ -3767,7 +3792,7 @@ dependencies = [ "once_cell", "path-slash", "regex", - "reqwest 0.12.4", + "reqwest 0.12.5", "revm-primitives", "semver 1.0.23", "serde", @@ -4665,9 +4690,9 @@ checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a" [[package]] name = "httparse" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -4753,19 +4778,21 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", "hyper 1.3.1", "hyper-util", - "rustls 0.22.4", + "rustls 0.23.10", + "rustls-native-certs 0.7.0", "rustls-pki-types", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tower-service", + "webpki-roots", ] [[package]] @@ -5592,9 +5619,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -6685,6 +6712,53 @@ dependencies = [ "memchr", ] +[[package]] +name = "quinn" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls 0.23.10", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash", + "rustls 0.23.10", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -6921,9 +6995,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64 0.22.1", "bytes", @@ -6934,7 +7008,7 @@ dependencies = [ "http-body 1.0.0", "http-body-util", "hyper 1.3.1", - "hyper-rustls 0.26.0", + "hyper-rustls 0.27.2", "hyper-tls", "hyper-util", "ipnet", @@ -6946,17 +7020,18 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.22.4", + "quinn", + "rustls 0.23.10", "rustls-native-certs 0.7.0", "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tokio", "tokio-native-tls", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-util", "tower-service", "url", @@ -6971,7 +7046,7 @@ dependencies = [ [[package]] name = "revm" version = "9.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" +source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" dependencies = [ "auto_impl", "cfg-if", @@ -6985,7 +7060,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=79774a6#79774a6e4add9da9247130bf73305531092d0895" +source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=4fe17f0#4fe17f08797450d9d5df315e724d14c9f3749b3f" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7001,7 +7076,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "5.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" +source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" dependencies = [ "revm-primitives", "serde", @@ -7010,7 +7085,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "7.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" +source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -7027,7 +7102,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "4.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" +source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" dependencies = [ "alloy-primitives", "auto_impl", @@ -7859,9 +7934,9 @@ dependencies = [ [[package]] name = "simple-home-dir" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c433538e900807402974e89beb88a98bda36e6f70f09a7225cdf11d013b8efe8" +checksum = "c221cbc8c1ff6bdf949b12cc011456c510ec6840654b444c7374c78e928ce344" dependencies = [ "windows-sys 0.52.0", ] @@ -7935,7 +8010,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest 0.12.4", + "reqwest 0.12.5", "rpassword", "serde", "serde_derive", @@ -8091,7 +8166,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "once_cell", - "reqwest 0.12.4", + "reqwest 0.12.5", "semver 1.0.23", "serde", "serde_json", @@ -8505,9 +8580,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "becd34a233e7e31a3dbf7c7241b38320f57393dcae8e7324b0167d21b8e320b0" +checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" dependencies = [ "futures-util", "log", @@ -9198,9 +9273,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c452ad30530b54a4d8e71952716a212b08efd0f3562baa66c29a618b07da7c3" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] @@ -9759,10 +9834,30 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +version = "2.0.11+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" dependencies = [ "cc", "pkg-config", ] + +[[patch.unused]] +name = "revm" +version = "9.0.0" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" + +[[patch.unused]] +name = "revm-interpreter" +version = "5.0.0" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" + +[[patch.unused]] +name = "revm-precompile" +version = "7.0.0" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" + +[[patch.unused]] +name = "revm-primitives" +version = "4.0.0" +source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" diff --git a/Cargo.toml b/Cargo.toml index c088c257355de..719e5f3324667 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,9 +158,9 @@ foundry-compilers = { version = "0.8.0", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "9.0.0", default-features = false } -revm-primitives = { version = "4.0.0", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "79774a6", features = [ +revm = { version = "9.0.0", git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f", default-features = false } +revm-primitives = { version = "4.0.0", git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f", default-features = false } +revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "4fe17f0", features = [ "serde", ] } @@ -168,30 +168,30 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "6cb3713", default-features = false } +alloy-consensus = { version = "0.1.1", default-features = false } +alloy-contract = { version = "0.1.1", default-features = false } +alloy-eips = { version = "0.1.1", default-features = false } +alloy-genesis = { version = "0.1.1", default-features = false } +alloy-json-rpc = { version = "0.1.1", default-features = false } +alloy-network = { version = "0.1.1", default-features = false } +alloy-node-bindings = { version = "0.1.1", default-features = false } +alloy-provider = { version = "0.1.1", default-features = false } +alloy-pubsub = { version = "0.1.1", default-features = false } +alloy-rpc-client = { version = "0.1.1", default-features = false } +alloy-rpc-types-engine = { version = "0.1.1", default-features = false } +alloy-rpc-types-trace = { version = "0.1.1", default-features = false } +alloy-rpc-types = { version = "0.1.1", default-features = false } +alloy-serde = { version = "0.1.1", default-features = false } +alloy-signer = { version = "0.1.1", default-features = false } +alloy-signer-local = { version = "0.1.1", default-features = false } +alloy-signer-aws = { version = "0.1.1", default-features = false } +alloy-signer-gcp = { version = "0.1.1", default-features = false } +alloy-signer-ledger = { version = "0.1.1", default-features = false } +alloy-signer-trezor = { version = "0.1.1", default-features = false } +alloy-transport = { version = "0.1.1", default-features = false } +alloy-transport-http = { version = "0.1.1", default-features = false } +alloy-transport-ipc = { version = "0.1.1", default-features = false } +alloy-transport-ws = { version = "0.1.1", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index be13f0f8ede88..9e143e8db7744 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -151,6 +151,6 @@ impl<'cheats, 'evm, DB: DatabaseExt> std::ops::DerefMut for CheatsCtxt<'cheats, impl<'cheats, 'evm, DB: DatabaseExt> CheatsCtxt<'cheats, 'evm, DB> { #[inline] pub(crate) fn is_precompile(&self, address: &Address) -> bool { - self.precompiles.contains_key(address) + self.precompiles.contains(address) } } From 9e271d00370bfaf97e04e9dfdc8e6ece942fc600 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:38:53 +0200 Subject: [PATCH 1102/1963] perf: new-type TargetedContracts (#8180) --- .../evm/evm/src/executors/invariant/error.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 60 +++-- crates/evm/fuzz/src/invariant/mod.rs | 212 +++++++++++------- crates/evm/fuzz/src/strategies/invariants.rs | 27 +-- crates/evm/fuzz/src/strategies/state.rs | 6 +- crates/forge/tests/it/invariant.rs | 2 +- .../common/InvariantShrinkWithAssert.t.sol | 2 +- 7 files changed, 179 insertions(+), 132 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 22d751ed5b02c..7c47ac0a47c6b 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -80,7 +80,7 @@ impl FailedInvariantCaseData { ) -> Self { // Collect abis of fuzzed and invariant contracts to decode custom error. let revert_reason = RevertDecoder::new() - .with_abis(targeted_contracts.targets.lock().iter().map(|(_, (_, abi, _))| abi)) + .with_abis(targeted_contracts.targets.lock().iter().map(|(_, c)| &c.abi)) .with_abi(invariant_contract.abi) .decode(call_result.result.as_ref(), Some(call_result.exit_reason)); diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 1eee0cafc6fdd..0918b3ebac176 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -7,16 +7,13 @@ use alloy_sol_types::{sol, SolCall}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::InvariantConfig; -use foundry_evm_core::{ - constants::{ - CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME, - }, - utils::get_function, +use foundry_evm_core::constants::{ + CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME, }; use foundry_evm_fuzz::{ invariant::{ ArtifactFilters, BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract, - RandomCallGenerator, SenderFilters, TargetedContracts, + RandomCallGenerator, SenderFilters, TargetedContract, TargetedContracts, }, strategies::{invariant_strat, override_call_strat, EvmFuzzState}, FuzzCase, FuzzFixtures, FuzzedCases, @@ -31,7 +28,7 @@ use proptest::{ use result::{assert_after_invariant, assert_invariants, can_continue}; use revm::primitives::HashMap; use shrink::shrink_sequence; -use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; +use std::{cell::RefCell, collections::btree_map::Entry, sync::Arc}; mod error; pub use error::{InvariantFailures, InvariantFuzzError}; @@ -517,7 +514,7 @@ impl<'a> InvariantExecutor<'a> { let excluded = self.call_sol_default(to, &IInvariantTest::excludeContractsCall {}).excludedContracts; - let mut contracts: TargetedContracts = self + let contracts = self .setup_contracts .iter() .filter(|&(addr, (identifier, _))| { @@ -528,8 +525,11 @@ impl<'a> InvariantExecutor<'a> { (excluded.is_empty() || !excluded.contains(addr)) && self.artifact_filters.matches(identifier) }) - .map(|(addr, (identifier, abi))| (*addr, (identifier.clone(), abi.clone(), vec![]))) + .map(|(addr, (identifier, abi))| { + (*addr, TargetedContract::new(identifier.clone(), abi.clone())) + }) .collect(); + let mut contracts = TargetedContracts { inner: contracts }; self.target_interfaces(to, &mut contracts)?; @@ -561,7 +561,7 @@ impl<'a> InvariantExecutor<'a> { // the specified interfaces for the same address. For example: // `[(addr1, ["IERC20", "IOwnable"])]` and `[(addr1, ["IERC20"]), (addr1, ("IOwnable"))]` // should be equivalent. - let mut combined: TargetedContracts = BTreeMap::new(); + let mut combined = TargetedContracts::new(); // Loop through each address and its associated artifact identifiers. // We're borrowing here to avoid taking full ownership. @@ -577,18 +577,18 @@ impl<'a> InvariantExecutor<'a> { .entry(*addr) // If the entry exists, extends its ABI with the function list. .and_modify(|entry| { - let (_, contract_abi, _) = entry; - // Extend the ABI's function list with the new functions. - contract_abi.functions.extend(contract.abi.functions.clone()); + entry.abi.functions.extend(contract.abi.functions.clone()); }) // Otherwise insert it into the map. - .or_insert_with(|| (identifier.to_string(), contract.abi.clone(), vec![])); + .or_insert_with(|| { + TargetedContract::new(identifier.to_string(), contract.abi.clone()) + }); } } } - targeted_contracts.extend(combined); + targeted_contracts.extend(combined.inner); Ok(()) } @@ -623,26 +623,18 @@ impl<'a> InvariantExecutor<'a> { selectors: &[Selector], targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { - if let Some((name, abi, address_selectors)) = targeted_contracts.get_mut(&address) { - // The contract is already part of our filter, and all we do is specify that we're - // only looking at specific functions coming from `bytes4_array`. - for &selector in selectors { - address_selectors.push(get_function(name, selector, abi).cloned()?); + let contract = match targeted_contracts.entry(address) { + Entry::Occupied(entry) => entry.into_mut(), + Entry::Vacant(entry) => { + let (identifier, abi) = self.setup_contracts.get(&address).ok_or_else(|| { + eyre::eyre!( + "[targetSelectors] address does not have an associated contract: {address}" + ) + })?; + entry.insert(TargetedContract::new(identifier.clone(), abi.clone())) } - } else { - let (name, abi) = self.setup_contracts.get(&address).ok_or_else(|| { - eyre::eyre!( - "[targetSelectors] address does not have an associated contract: {address}" - ) - })?; - - let functions = selectors - .iter() - .map(|&selector| get_function(name, selector, abi).cloned()) - .collect::, _>>()?; - - targeted_contracts.insert(address, (name.to_string(), abi.clone(), functions)); - } + }; + contract.add_selectors(selectors.iter().copied())?; Ok(()) } diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index fdc0b9d56c311..9138443be221f 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -1,5 +1,5 @@ use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{Address, Bytes, Selector}; use itertools::Either; use parking_lot::Mutex; use std::{collections::BTreeMap, sync::Arc}; @@ -10,11 +10,10 @@ pub use call_override::RandomCallGenerator; mod filters; pub use filters::{ArtifactFilters, SenderFilters}; use foundry_common::{ContractsByAddress, ContractsByArtifact}; -use foundry_evm_core::utils::StateChangeset; - -pub type TargetedContracts = BTreeMap)>; +use foundry_evm_core::utils::{get_function, StateChangeset}; /// Contracts identified as targets during a fuzz run. +/// /// During execution, any newly created contract is added as target and used through the rest of /// the fuzz run if the collection is updatable (no `targetContract` specified in `setUp`). #[derive(Clone, Debug)] @@ -26,42 +25,11 @@ pub struct FuzzRunIdentifiedContracts { } impl FuzzRunIdentifiedContracts { + /// Creates a new `FuzzRunIdentifiedContracts` instance. pub fn new(targets: TargetedContracts, is_updatable: bool) -> Self { Self { targets: Arc::new(Mutex::new(targets)), is_updatable } } - /// Returns fuzzed contract abi and fuzzed function from address and provided calldata. - /// - /// Used to decode return values and logs in order to add values into fuzz dictionary. - pub fn with_fuzzed_artifacts( - &self, - tx: &BasicTxDetails, - f: impl FnOnce(Option<&JsonAbi>, Option<&Function>), - ) { - let targets = self.targets.lock(); - let (abi, abi_f) = match targets.get(&tx.call_details.target) { - Some((_, abi, _)) => { - (Some(abi), abi.functions().find(|f| f.selector() == tx.call_details.calldata[..4])) - } - None => (None, None), - }; - f(abi, abi_f); - } - - /// Returns flatten target contract address and functions to be fuzzed. - /// Includes contract targeted functions if specified, else all mutable contract functions. - pub fn fuzzed_functions(&self) -> Vec<(Address, Function)> { - let mut fuzzed_functions = vec![]; - for (contract, (_, abi, functions)) in self.targets.lock().iter() { - if !abi.functions.is_empty() { - for function in abi_fuzzed_functions(abi, functions) { - fuzzed_functions.push((*contract, function.clone())); - } - } - } - fuzzed_functions - } - /// If targets are updatable, collect all contracts created during an invariant run (which /// haven't been discovered yet). pub fn collect_created_contracts( @@ -72,34 +40,41 @@ impl FuzzRunIdentifiedContracts { artifact_filters: &ArtifactFilters, created_contracts: &mut Vec
, ) -> eyre::Result<()> { - if self.is_updatable { - let mut targets = self.targets.lock(); - for (address, account) in state_changeset { - if setup_contracts.contains_key(address) { - continue; - } - if !account.is_touched() { - continue; - } - let Some(code) = &account.info.code else { - continue; - }; - if code.is_empty() { - continue; - } - let Some((artifact, contract)) = - project_contracts.find_by_deployed_code(code.original_byte_slice()) - else { - continue; - }; - let Some(functions) = - artifact_filters.get_targeted_functions(artifact, &contract.abi)? - else { - continue; - }; - created_contracts.push(*address); - targets.insert(*address, (artifact.name.clone(), contract.abi.clone(), functions)); + if !self.is_updatable { + return Ok(()); + } + + let mut targets = self.targets.lock(); + for (address, account) in state_changeset { + if setup_contracts.contains_key(address) { + continue; } + if !account.is_touched() { + continue; + } + let Some(code) = &account.info.code else { + continue; + }; + if code.is_empty() { + continue; + } + let Some((artifact, contract)) = + project_contracts.find_by_deployed_code(code.original_byte_slice()) + else { + continue; + }; + let Some(functions) = + artifact_filters.get_targeted_functions(artifact, &contract.abi)? + else { + continue; + }; + created_contracts.push(*address); + let contract = TargetedContract { + identifier: artifact.name.clone(), + abi: contract.abi.clone(), + targeted_functions: functions, + }; + targets.insert(*address, contract); } Ok(()) } @@ -115,21 +90,102 @@ impl FuzzRunIdentifiedContracts { } } -/// Helper to retrieve functions to fuzz for specified abi. -/// Returns specified targeted functions if any, else mutable abi functions. -pub(crate) fn abi_fuzzed_functions<'a>( - abi: &'a JsonAbi, - targeted_functions: &'a [Function], -) -> impl Iterator { - if !targeted_functions.is_empty() { - Either::Left(targeted_functions.iter()) - } else { - Either::Right(abi.functions().filter(|&func| { - !matches!( - func.state_mutability, - alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View - ) - })) +/// A collection of contracts identified as targets for invariant testing. +#[derive(Clone, Debug, Default)] +pub struct TargetedContracts { + /// The inner map of targeted contracts. + pub inner: BTreeMap, +} + +impl TargetedContracts { + /// Returns a new `TargetedContracts` instance. + pub fn new() -> Self { + Self::default() + } + + /// Returns fuzzed contract abi and fuzzed function from address and provided calldata. + /// + /// Used to decode return values and logs in order to add values into fuzz dictionary. + pub fn fuzzed_artifacts(&self, tx: &BasicTxDetails) -> (Option<&JsonAbi>, Option<&Function>) { + match self.inner.get(&tx.call_details.target) { + Some(c) => ( + Some(&c.abi), + c.abi.functions().find(|f| f.selector() == tx.call_details.calldata[..4]), + ), + None => (None, None), + } + } + + /// Returns flatten target contract address and functions to be fuzzed. + /// Includes contract targeted functions if specified, else all mutable contract functions. + pub fn fuzzed_functions(&self) -> impl Iterator { + self.inner + .iter() + .filter(|(_, c)| !c.abi.functions.is_empty()) + .flat_map(|(contract, c)| c.abi_fuzzed_functions().map(move |f| (contract, f))) + } +} + +impl std::ops::Deref for TargetedContracts { + type Target = BTreeMap; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl std::ops::DerefMut for TargetedContracts { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} + +/// A contract identified as targets for invariant testing. +#[derive(Clone, Debug)] +pub struct TargetedContract { + /// The contract identifier. This is only used in error messages. + pub identifier: String, + /// The contract's ABI. + pub abi: JsonAbi, + /// The targeted functions of the contract. + pub targeted_functions: Vec, +} + +impl TargetedContract { + /// Returns a new `TargetedContract` instance. + pub fn new(identifier: String, abi: JsonAbi) -> Self { + Self { identifier, abi, targeted_functions: Vec::new() } + } + + /// Helper to retrieve functions to fuzz for specified abi. + /// Returns specified targeted functions if any, else mutable abi functions. + pub fn abi_fuzzed_functions(&self) -> impl Iterator { + if !self.targeted_functions.is_empty() { + Either::Left(self.targeted_functions.iter()) + } else { + Either::Right(self.abi.functions().filter(|&func| { + !matches!( + func.state_mutability, + alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View + ) + })) + } + } + + /// Returns the function for the given selector. + pub fn get_function(&self, selector: Selector) -> eyre::Result<&Function> { + get_function(&self.identifier, selector, &self.abi) + } + + /// Adds the specified selectors to the targeted functions. + pub fn add_selectors( + &mut self, + selectors: impl IntoIterator, + ) -> eyre::Result<()> { + for selector in selectors { + self.targeted_functions.push(self.get_function(selector)?.clone()); + } + Ok(()) } } diff --git a/crates/evm/fuzz/src/strategies/invariants.rs b/crates/evm/fuzz/src/strategies/invariants.rs index 55af574c59895..c7d04dd1ab02a 100644 --- a/crates/evm/fuzz/src/strategies/invariants.rs +++ b/crates/evm/fuzz/src/strategies/invariants.rs @@ -1,9 +1,6 @@ use super::{fuzz_calldata, fuzz_param_from_state}; use crate::{ - invariant::{ - abi_fuzzed_functions, BasicTxDetails, CallDetails, FuzzRunIdentifiedContracts, - SenderFilters, - }, + invariant::{BasicTxDetails, CallDetails, FuzzRunIdentifiedContracts, SenderFilters}, strategies::{fuzz_calldata_from_state, fuzz_param, EvmFuzzState}, FuzzFixtures, }; @@ -11,6 +8,7 @@ use alloy_json_abi::Function; use alloy_primitives::Address; use parking_lot::RwLock; use proptest::prelude::*; +use rand::seq::IteratorRandom; use std::{rc::Rc, sync::Arc}; /// Given a target address, we generate random calldata. @@ -32,15 +30,13 @@ pub fn override_call_strat( let func = { let contracts = contracts.targets.lock(); - let (_, abi, functions) = contracts.get(&target_address).unwrap_or_else(|| { + let contract = contracts.get(&target_address).unwrap_or_else(|| { // Choose a random contract if target selected by lazy strategy is not in fuzz run // identified contracts. This can happen when contract is created in `setUp` call // but is not included in targetContracts. - let rand_index = rand::thread_rng().gen_range(0..contracts.len()); - let (_, contract_specs) = contracts.iter().nth(rand_index).unwrap(); - contract_specs + contracts.values().choose(&mut rand::thread_rng()).unwrap() }); - let fuzzed_functions: Vec<_> = abi_fuzzed_functions(abi, functions).cloned().collect(); + let fuzzed_functions: Vec<_> = contract.abi_fuzzed_functions().cloned().collect(); any::().prop_map(move |index| index.get(&fuzzed_functions).clone()) }; @@ -68,16 +64,17 @@ pub fn invariant_strat( fuzz_fixtures: FuzzFixtures, ) -> impl Strategy { let senders = Rc::new(senders); - any::() - .prop_flat_map(move |index| { - let (target_address, target_function) = - index.get(&contracts.fuzzed_functions()).clone(); + any::() + .prop_flat_map(move |selector| { + let contracts = contracts.targets.lock(); + let functions = contracts.fuzzed_functions(); + let (target_address, target_function) = selector.select(functions); let sender = select_random_sender(&fuzz_state, senders.clone(), dictionary_weight); let call_details = fuzz_contract_with_calldata( &fuzz_state, &fuzz_fixtures, - target_address, - target_function, + *target_address, + target_function.clone(), ); (sender, call_details) }) diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index cf29c94209a5a..f4f1dde924827 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -64,10 +64,12 @@ impl EvmFuzzState { run_depth: u32, ) { let mut dict = self.inner.write(); - fuzzed_contracts.with_fuzzed_artifacts(tx, |target_abi, target_function| { + { + let targets = fuzzed_contracts.targets.lock(); + let (target_abi, target_function) = targets.fuzzed_artifacts(tx); dict.insert_logs_values(target_abi, logs, run_depth); dict.insert_result_values(target_function, result, run_depth); - }); + } dict.insert_new_state_values(state_changeset); } diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 19500ab63df55..b6e564d49f766 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -773,7 +773,7 @@ async fn test_invariant_after_invariant() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_selectors_weight() { let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); - opts.fuzz.seed = Some(U256::from(119u32)); + opts.fuzz.seed = Some(U256::from(100u32)); let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantSelectorsWeight.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); diff --git a/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol index c189e2507629d..d5dcfe6740a39 100644 --- a/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol @@ -86,7 +86,7 @@ contract InvariantShrinkWithAssert is DSTest { } function invariant_with_assert() public { - assertTrue(counter.number() != 3); + assertTrue(counter.number() != 3, "wrong counter"); } } From a131937c521936139fe46ba7c689ae69ed77ba6d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 18 Jun 2024 14:09:27 +0300 Subject: [PATCH 1103/1963] feat: cast etherscan-source --flatten (#8159) --- crates/cast/bin/main.rs | 11 +++++++---- crates/cast/bin/opts.rs | 8 ++++++-- crates/cast/src/lib.rs | 35 ++++++++++++++++++++++++++++++++- crates/common/src/compile.rs | 31 ++++++++++++++++------------- crates/forge/bin/cmd/flatten.rs | 11 ++++++----- 5 files changed, 70 insertions(+), 26 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index e17fd9d86e517..0f6673d4fea04 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -530,18 +530,21 @@ async fn main() -> Result<()> { CastSubcommand::RightShift { value, bits, base_in, base_out } => { println!("{}", SimpleCast::right_shift(&value, &bits, base_in.as_deref(), &base_out)?); } - CastSubcommand::EtherscanSource { address, directory, etherscan } => { + CastSubcommand::EtherscanSource { address, directory, etherscan, flatten } => { let config = Config::from(ðerscan); let chain = config.chain.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - match directory { - Some(dir) => { + match (directory, flatten) { + (Some(dir), false) => { SimpleCast::expand_etherscan_source_to_directory(chain, address, api_key, dir) .await? } - None => { + (None, false) => { println!("{}", SimpleCast::etherscan_source(chain, address, api_key).await?); } + (dir, true) => { + SimpleCast::etherscan_source_flatten(chain, address, api_key, dir).await?; + } } } CastSubcommand::Create2(cmd) => { diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 4efe4245a6efe..decd603748ba1 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -808,8 +808,12 @@ pub enum CastSubcommand { /// The contract's address. address: String, - /// The output directory to expand source tree into. - #[arg(short, value_hint = ValueHint::DirPath)] + /// Whether to flatten the source code. + #[arg(long, short)] + flatten: bool, + + /// The output directory/file to expand source tree into. + #[arg(short, value_hint = ValueHint::DirPath, alias = "path")] directory: Option, #[command(flatten)] diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index e84b5ee9523a1..4934d8dd30bd9 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -25,9 +25,11 @@ use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::Client; use foundry_common::{ abi::{encode_function_args, get_func}, + compile::etherscan_project, fmt::*, - TransactionReceiptWithRevertReason, + fs, TransactionReceiptWithRevertReason, }; +use foundry_compilers::flatten::Flattener; use foundry_config::Chain; use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; @@ -1847,6 +1849,37 @@ impl SimpleCast { Ok(()) } + /// Fetches the source code of verified contracts from etherscan, flattens it and writes it to + /// the given path or stdout. + pub async fn etherscan_source_flatten( + chain: Chain, + contract_address: String, + etherscan_api_key: String, + output_path: Option, + ) -> Result<()> { + let client = Client::new(chain, etherscan_api_key)?; + let metadata = client.contract_source_code(contract_address.parse()?).await?; + let Some(metadata) = metadata.items.first() else { + eyre::bail!("Empty contract source code") + }; + + let tmp = tempfile::tempdir()?; + let project = etherscan_project(metadata, tmp.path())?; + let target_path = project.find_contract_path(&metadata.contract_name)?; + + let flattened = Flattener::new(project, &target_path)?.flatten(); + + if let Some(path) = output_path { + fs::create_dir_all(path.parent().unwrap())?; + fs::write(&path, flattened)?; + println!("Flattened file written at {}", path.display()); + } else { + println!("{flattened}"); + } + + Ok(()) + } + /// Disassembles hex encoded bytecode into individual / human readable opcodes /// /// # Example diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index ffefe141a316f..3be317e51ccab 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -165,18 +165,8 @@ impl ProjectCompiler { { let quiet = self.quiet.unwrap_or(false); let bail = self.bail.unwrap_or(true); - #[allow(clippy::collapsible_else_if)] - let reporter = if quiet { - Report::new(NoReporter::default()) - } else { - if std::io::stdout().is_terminal() { - Report::new(SpinnerReporter::spawn()) - } else { - Report::new(BasicStdoutReporter::default()) - } - }; - let output = foundry_compilers::report::with_scoped(&reporter, || { + let output = with_compilation_reporter(self.quiet.unwrap_or(false), || { tracing::debug!("compiling project"); let timer = Instant::now(); @@ -187,9 +177,6 @@ impl ProjectCompiler { r })?; - // need to drop the reporter here, so that the spinner terminates - drop(reporter); - if bail && output.has_compiler_errors() { eyre::bail!("{output}") } @@ -554,3 +541,19 @@ pub fn etherscan_project( .no_artifacts() .build(compiler)?) } + +/// Configures the reporter and runs the given closure. +pub fn with_compilation_reporter(quiet: bool, f: impl FnOnce() -> O) -> O { + #[allow(clippy::collapsible_else_if)] + let reporter = if quiet { + Report::new(NoReporter::default()) + } else { + if std::io::stdout().is_terminal() { + Report::new(SpinnerReporter::spawn()) + } else { + Report::new(BasicStdoutReporter::default()) + } + }; + + foundry_compilers::report::with_scoped(&reporter, f) +} diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 64c4ea78f5d3f..c4a01133740e1 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -4,7 +4,7 @@ use foundry_cli::{ opts::{CoreBuildArgs, ProjectPathsArgs}, utils::LoadConfig, }; -use foundry_common::fs; +use foundry_common::{compile::with_compilation_reporter, fs}; use foundry_compilers::{ compilers::solc::SolcLanguage, error::SolcError, @@ -40,13 +40,14 @@ impl FlattenArgs { // flatten is a subset of `BuildArgs` so we can reuse that to get the config let build_args = CoreBuildArgs { project_paths, ..Default::default() }; - let mut config = build_args.try_load_config_emit_warnings()?; - // `Flattener` uses the typed AST for better flattening results. - config.ast = true; + let config = build_args.try_load_config_emit_warnings()?; let project = config.create_project(false, true)?; let target_path = dunce::canonicalize(target_path)?; - let flattener = Flattener::new(project.clone(), &target_path); + + let flattener = with_compilation_reporter(build_args.silent, || { + Flattener::new(project.clone(), &target_path) + }); let flattened = match flattener { Ok(flattener) => Ok(flattener.flatten()), From 6f41cd91255639d4e53059bc84f591d1b48583dc Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Tue, 18 Jun 2024 20:20:15 +0800 Subject: [PATCH 1104/1963] fix(anvil): block dumps (#8160) * implemented latest_block dump/load * update to dump/load all blocks instead of only latest * refactored state loading into storage.rs, and added load-dump cycle test * fix clippy errors for anvil * remove SerializableHeader and use Header (now serializable) * clippy happy --------- Co-authored-by: Matthias Seitz --- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- .../core/src/eth/transaction/optimism.rs | 3 +- crates/anvil/src/eth/backend/db.rs | 33 ++++++++++++ crates/anvil/src/eth/backend/mem/fork_db.rs | 6 ++- .../anvil/src/eth/backend/mem/in_memory_db.rs | 13 ++--- crates/anvil/src/eth/backend/mem/mod.rs | 15 +++--- crates/anvil/src/eth/backend/mem/storage.rs | 50 ++++++++++++++++++- 7 files changed, 104 insertions(+), 18 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 81840bfa59d28..83db644652b37 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -594,7 +594,7 @@ impl PendingTransaction { } /// Container type for signed, typed transactions. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TypedTransaction { /// Legacy transaction type Legacy(Signed), diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 912bdf26c0845..4a147297b4851 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -3,6 +3,7 @@ use alloy_primitives::{keccak256, Address, Bytes, ChainId, Signature, TxKind, B2 use alloy_rlp::{ length_of_length, Decodable, Encodable, Error as DecodeError, Header as RlpHeader, }; +use serde::{Deserialize, Serialize}; use std::mem; #[derive(Clone, Debug, PartialEq, Eq)] @@ -228,7 +229,7 @@ impl Encodable for DepositTransactionRequest { /// An op-stack deposit transaction. /// See -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct DepositTransaction { pub nonce: u64, pub source_hash: B256, diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 852956d734817..9182cdadb1d32 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -1,8 +1,10 @@ //! Helper types for working with [revm](foundry_evm::revm) use crate::revm::primitives::AccountInfo; +use alloy_consensus::Header; use alloy_primitives::{keccak256, Address, Bytes, B256, U256, U64}; use alloy_rpc_types::BlockId; +use anvil_core::eth::{block::Block, transaction::TypedTransaction}; use foundry_common::errors::FsPathError; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot}, @@ -116,6 +118,7 @@ pub trait Db: &self, at: BlockEnv, best_number: U64, + blocks: Vec, ) -> DatabaseResult>; /// Deserialize and add all chain data to the backend storage @@ -188,6 +191,7 @@ impl + Send + Sync + Clone + fmt::Debug> D &self, _at: BlockEnv, _best_number: U64, + _blocks: Vec, ) -> DatabaseResult> { Ok(None) } @@ -318,6 +322,8 @@ pub struct SerializableState { pub accounts: BTreeMap, /// The best block number of the state, can be different from block number (Arbitrum chain). pub best_block_number: Option, + #[serde(default)] + pub blocks: Vec, } impl SerializableState { @@ -344,3 +350,30 @@ pub struct SerializableAccountRecord { pub code: Bytes, pub storage: BTreeMap, } + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SerializableBlock { + pub header: Header, + pub transactions: Vec, + pub ommers: Vec
, +} + +impl From for SerializableBlock { + fn from(block: Block) -> Self { + Self { + header: block.header, + transactions: block.transactions.into_iter().map(Into::into).collect(), + ommers: block.ommers.into_iter().map(Into::into).collect(), + } + } +} + +impl From for Block { + fn from(block: SerializableBlock) -> Self { + Self { + header: block.header, + transactions: block.transactions.into_iter().map(Into::into).collect(), + ommers: block.ommers.into_iter().map(Into::into).collect(), + } + } +} diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 93070ef88ab4c..ae325f9750054 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -1,7 +1,7 @@ use crate::{ eth::backend::db::{ - Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableState, - StateDb, + Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableBlock, + SerializableState, StateDb, }, revm::primitives::AccountInfo, }; @@ -36,6 +36,7 @@ impl Db for ForkedDatabase { &self, at: BlockEnv, best_number: U64, + blocks: Vec, ) -> DatabaseResult> { let mut db = self.database().clone(); let accounts = self @@ -64,6 +65,7 @@ impl Db for ForkedDatabase { block: Some(at), accounts, best_block_number: Some(best_number), + blocks, })) } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 2049c9f902c96..6269727c104be 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -2,8 +2,8 @@ use crate::{ eth::backend::db::{ - Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableState, - StateDb, + Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableBlock, + SerializableState, StateDb, }, mem::state::state_root, revm::{db::DbAccount, primitives::AccountInfo}, @@ -37,6 +37,7 @@ impl Db for MemDb { &self, at: BlockEnv, best_number: U64, + blocks: Vec, ) -> DatabaseResult> { let accounts = self .inner @@ -65,6 +66,7 @@ impl Db for MemDb { block: Some(at), accounts, best_block_number: Some(best_number), + blocks, })) } @@ -137,7 +139,7 @@ mod tests { use foundry_evm::revm::primitives::{Bytecode, KECCAK_EMPTY}; use std::{collections::BTreeMap, str::FromStr}; - // verifies that all substantial aspects of a loaded account remain the state after an account + // verifies that all substantial aspects of a loaded account remain the same after an account // is dumped and reloaded #[test] fn test_dump_reload_cycle() { @@ -147,7 +149,6 @@ mod tests { let mut dump_db = MemDb::default(); let contract_code = Bytecode::new_raw(Bytes::from("fake contract code")); - dump_db.insert_account( test_addr, AccountInfo { @@ -157,10 +158,10 @@ mod tests { nonce: 1234, }, ); - dump_db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); - let state = dump_db.dump_state(Default::default(), U64::ZERO).unwrap().unwrap(); + // blocks dumping/loading tested in storage.rs + let state = dump_db.dump_state(Default::default(), U64::ZERO, Vec::new()).unwrap().unwrap(); let mut load_db = MemDb::default(); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0e130c8e5f612..d40c7a07dc046 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -737,7 +737,8 @@ impl Backend { pub async fn serialized_state(&self) -> Result { let at = self.env.read().block.clone(); let best_number = self.blockchain.storage.read().best_number; - let state = self.db.read().await.dump_state(at, best_number)?; + let blocks = self.blockchain.storage.read().serialized_blocks(); + let state = self.db.read().await.dump_state(at, best_number, blocks)?; state.ok_or_else(|| { RpcError::invalid_params("Dumping state not supported with the current configuration") .into() @@ -766,14 +767,16 @@ impl Backend { state.best_block_number.unwrap_or(block.number.to::()); } - if !self.db.write().await.load_state(state)? { - Err(RpcError::invalid_params( + if !self.db.write().await.load_state(state.clone())? { + return Err(RpcError::invalid_params( "Loading state not supported with the current configuration", ) - .into()) - } else { - Ok(true) + .into()); } + + self.blockchain.storage.write().load_blocks(state.blocks.clone()); + + Ok(true) } /// Deserialize and add all chain data to the backend storage diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 46365739e40af..5a8c3fe252ff2 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -1,7 +1,7 @@ //! In-memory blockchain storage use crate::eth::{ backend::{ - db::{MaybeFullDatabase, StateDb}, + db::{MaybeFullDatabase, SerializableBlock, StateDb}, mem::cache::DiskStateCache, }, pool::transactions::PoolTransaction, @@ -319,6 +319,21 @@ impl BlockchainStorage { } } } + + pub fn serialized_blocks(&self) -> Vec { + self.blocks.values().map(|block| block.clone().into()).collect() + } + + /// Deserialize and add all blocks data to the backend storage + pub fn load_blocks(&mut self, serializable_blocks: Vec) { + for serializable_block in serializable_blocks.iter() { + let block: Block = serializable_block.clone().into(); + let block_hash = block.header.hash_slow(); + let block_number = block.header.number; + self.blocks.insert(block_hash, block); + self.hashes.insert(U64::from(block_number), block_hash); + } + } } /// A simple in-memory blockchain @@ -427,7 +442,9 @@ pub struct MinedTransactionReceipt { mod tests { use super::*; use crate::eth::backend::db::Db; - use alloy_primitives::Address; + use alloy_primitives::{hex, Address}; + use alloy_rlp::Decodable; + use anvil_core::eth::transaction::TypedTransaction; use foundry_evm::{ backend::MemDb, revm::{ @@ -499,4 +516,33 @@ mod tests { assert_eq!(acc.balance, rU256::from(balance)); } } + + // verifies that blocks in BlockchainStorage remain the same when dumped and reloaded + #[test] + fn test_storage_dump_reload_cycle() { + let mut dump_storage = BlockchainStorage::empty(); + + let partial_header = PartialHeader { gas_limit: 123456, ..Default::default() }; + let bytes_first = &mut &hex::decode("f86b02843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba00eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5aea03a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18").unwrap()[..]; + let tx: MaybeImpersonatedTransaction = + TypedTransaction::decode(&mut &bytes_first[..]).unwrap().into(); + let block = Block::new::( + partial_header.clone(), + vec![tx.clone()], + vec![], + ); + let block_hash = block.header.hash_slow(); + dump_storage.blocks.insert(block_hash, block); + + let serialized_blocks = dump_storage.serialized_blocks(); + + let mut load_storage = BlockchainStorage::empty(); + + load_storage.load_blocks(serialized_blocks); + + let loaded_block = load_storage.blocks.get(&block_hash).unwrap(); + assert_eq!(loaded_block.header.gas_limit, partial_header.gas_limit); + let loaded_tx = loaded_block.transactions.first().unwrap(); + assert_eq!(loaded_tx, &tx); + } } From 67238345280957f53203b2ea54b3fb003c22a316 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:34:08 +0300 Subject: [PATCH 1105/1963] feat(invariant): add excludeSelectors() filter (#8185) * feat(invariant): add excludeSelectors() filter * Apply suggestions from code review Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Review changes: shorter err message --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/evm/evm/src/executors/invariant/mod.rs | 24 ++++++++--- crates/evm/fuzz/src/invariant/mod.rs | 19 ++++++--- crates/forge/tests/it/invariant.rs | 4 ++ .../invariant/target/ExcludeSelectors.t.sol | 41 +++++++++++++++++++ 4 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 0918b3ebac176..a260fcb566775 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -71,6 +71,9 @@ sol! { #[derive(Default)] function excludeContracts() public view returns (address[] memory excludedContracts); + #[derive(Default)] + function excludeSelectors() public view returns (FuzzSelector[] memory excludedSelectors); + #[derive(Default)] function excludeSenders() public view returns (address[] memory excludedSenders); @@ -605,22 +608,31 @@ impl<'a> InvariantExecutor<'a> { if selectors.is_empty() { continue; } - self.add_address_with_functions(*address, selectors, targeted_contracts)?; + self.add_address_with_functions(*address, selectors, false, targeted_contracts)?; } } + // Collect contract functions marked as target for fuzzing campaign. let selectors = self.call_sol_default(address, &IInvariantTest::targetSelectorsCall {}); for IInvariantTest::FuzzSelector { addr, selectors } in selectors.targetedSelectors { - self.add_address_with_functions(addr, &selectors, targeted_contracts)?; + self.add_address_with_functions(addr, &selectors, false, targeted_contracts)?; } + + // Collect contract functions excluded from fuzzing campaign. + let selectors = self.call_sol_default(address, &IInvariantTest::excludeSelectorsCall {}); + for IInvariantTest::FuzzSelector { addr, selectors } in selectors.excludedSelectors { + self.add_address_with_functions(addr, &selectors, true, targeted_contracts)?; + } + Ok(()) } - /// Adds the address and fuzzable functions to `TargetedContracts`. + /// Adds the address and fuzzed or excluded functions to `TargetedContracts`. fn add_address_with_functions( &self, address: Address, selectors: &[Selector], + should_exclude: bool, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { let contract = match targeted_contracts.entry(address) { @@ -628,13 +640,15 @@ impl<'a> InvariantExecutor<'a> { Entry::Vacant(entry) => { let (identifier, abi) = self.setup_contracts.get(&address).ok_or_else(|| { eyre::eyre!( - "[targetSelectors] address does not have an associated contract: {address}" + "[{}] address does not have an associated contract: {}", + if should_exclude { "excludeSelectors" } else { "targetSelectors" }, + address ) })?; entry.insert(TargetedContract::new(identifier.clone(), abi.clone())) } }; - contract.add_selectors(selectors.iter().copied())?; + contract.add_selectors(selectors.iter().copied(), should_exclude)?; Ok(()) } diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index 9138443be221f..d6b3e574d8b1d 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -73,6 +73,7 @@ impl FuzzRunIdentifiedContracts { identifier: artifact.name.clone(), abi: contract.abi.clone(), targeted_functions: functions, + excluded_functions: Vec::new(), }; targets.insert(*address, contract); } @@ -140,7 +141,7 @@ impl std::ops::DerefMut for TargetedContracts { } } -/// A contract identified as targets for invariant testing. +/// A contract identified as target for invariant testing. #[derive(Clone, Debug)] pub struct TargetedContract { /// The contract identifier. This is only used in error messages. @@ -149,16 +150,19 @@ pub struct TargetedContract { pub abi: JsonAbi, /// The targeted functions of the contract. pub targeted_functions: Vec, + /// The excluded functions of the contract. + pub excluded_functions: Vec, } impl TargetedContract { /// Returns a new `TargetedContract` instance. pub fn new(identifier: String, abi: JsonAbi) -> Self { - Self { identifier, abi, targeted_functions: Vec::new() } + Self { identifier, abi, targeted_functions: Vec::new(), excluded_functions: Vec::new() } } /// Helper to retrieve functions to fuzz for specified abi. - /// Returns specified targeted functions if any, else mutable abi functions. + /// Returns specified targeted functions if any, else mutable abi functions that are not + /// marked as excluded. pub fn abi_fuzzed_functions(&self) -> impl Iterator { if !self.targeted_functions.is_empty() { Either::Left(self.targeted_functions.iter()) @@ -167,7 +171,7 @@ impl TargetedContract { !matches!( func.state_mutability, alloy_json_abi::StateMutability::Pure | alloy_json_abi::StateMutability::View - ) + ) && !self.excluded_functions.contains(func) })) } } @@ -181,9 +185,14 @@ impl TargetedContract { pub fn add_selectors( &mut self, selectors: impl IntoIterator, + should_exclude: bool, ) -> eyre::Result<()> { for selector in selectors { - self.targeted_functions.push(self.get_function(selector)?.clone()); + if should_exclude { + self.excluded_functions.push(self.get_function(selector)?.clone()); + } else { + self.targeted_functions.push(self.get_function(selector)?.clone()); + } } Ok(()) } diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index b6e564d49f766..45bcda9d558fd 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -102,6 +102,10 @@ async fn test_invariant() { "default/fuzz/invariant/target/TargetSelectors.t.sol:TargetSelectors", vec![("invariantTrueWorld()", true, None, None, None)], ), + ( + "default/fuzz/invariant/target/ExcludeSelectors.t.sol:ExcludeSelectors", + vec![("invariantFalseWorld()", true, None, None, None)], + ), ( "default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol:ExcludeArtifacts", vec![("invariantShouldPass()", true, None, None, None)], diff --git a/testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol b/testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol new file mode 100644 index 0000000000000..526da0c67f971 --- /dev/null +++ b/testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +struct FuzzSelector { + address addr; + bytes4[] selectors; +} + +contract Hello { + bool public world = false; + + function change() public { + world = true; + } + + function real_change() public { + world = false; + } +} + +contract ExcludeSelectors is DSTest { + Hello hello; + + function setUp() public { + hello = new Hello(); + } + + function excludeSelectors() public returns (FuzzSelector[] memory) { + FuzzSelector[] memory targets = new FuzzSelector[](1); + bytes4[] memory selectors = new bytes4[](1); + selectors[0] = Hello.change.selector; + targets[0] = FuzzSelector(address(hello), selectors); + return targets; + } + + function invariantFalseWorld() public { + require(hello.world() == false, "true world"); + } +} From 272a09ff70f79d39f3e7e641d703600cced306a6 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:04:42 +0530 Subject: [PATCH 1106/1963] fix(cheatcodes): use `call.bytecode_address` in mockCalls (#8184) * fix(cheatcodes): handle delegatecalls in vm.mockCalls using `bytecode_address` * add: repro test * nit: forge fmt --- crates/cheatcodes/src/inspector.rs | 2 +- testdata/default/cheats/MockCall.t.sol | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 449ebdaae85a9..d7cfc3c5ece28 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -879,7 +879,7 @@ impl Inspector for Cheatcodes { } // Handle mocked calls - if let Some(mocks) = self.mocked_calls.get(&call.target_address) { + if let Some(mocks) = self.mocked_calls.get(&call.bytecode_address) { let ctx = MockCallDataContext { calldata: call.input.clone(), value: call.transfer_value() }; if let Some(return_data) = mocks.get(&ctx).or_else(|| { diff --git a/testdata/default/cheats/MockCall.t.sol b/testdata/default/cheats/MockCall.t.sol index a70b3572b4a85..df7ee89c7379b 100644 --- a/testdata/default/cheats/MockCall.t.sol +++ b/testdata/default/cheats/MockCall.t.sol @@ -42,6 +42,20 @@ contract NestedMock { } } +contract NestedMockDelegateCall { + Mock private inner; + + constructor(Mock _inner) { + inner = _inner; + } + + function sum() public returns (uint256) { + (, bytes memory dataA) = address(inner).delegatecall(abi.encodeWithSelector(Mock.numberA.selector)); + (, bytes memory dataB) = address(inner).delegatecall(abi.encodeWithSelector(Mock.numberB.selector)); + return abi.decode(dataA, (uint256)) + abi.decode(dataB, (uint256)); + } +} + contract MockCallTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); @@ -72,6 +86,18 @@ contract MockCallTest is DSTest { assertEq(target.sum(), 10); } + // Ref: https://github.com/foundry-rs/foundry/issues/8066 + function testMockNestedDelegate() public { + Mock inner = new Mock(); + NestedMockDelegateCall target = new NestedMockDelegateCall(inner); + + assertEq(target.sum(), 3); + + vm.mockCall(address(inner), abi.encodeWithSelector(inner.numberB.selector), abi.encode(9)); + + assertEq(target.sum(), 10); + } + function testMockSelector() public { Mock target = new Mock(); assertEq(target.add(5, 5), 10); From d744da25f3e4912f81a761a768f57141f824094e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 18 Jun 2024 15:22:51 +0200 Subject: [PATCH 1107/1963] chore: remove rU256 alias (#8188) --- crates/anvil/src/eth/backend/mem/storage.rs | 10 +++++----- crates/anvil/src/eth/otterscan/types.rs | 4 ++-- crates/cast/bin/cmd/logs.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 5a8c3fe252ff2..3531057ad1001 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -449,7 +449,7 @@ mod tests { backend::MemDb, revm::{ db::DatabaseRef, - primitives::{AccountInfo, U256 as rU256}, + primitives::{AccountInfo, U256}, }, }; @@ -468,7 +468,7 @@ mod tests { let mut state = MemDb::default(); let addr = Address::random(); - let info = AccountInfo::from_balance(rU256::from(1337)); + let info = AccountInfo::from_balance(U256::from(1337)); state.insert_account(addr, info); storage.insert(one, StateDb::new(state)); storage.insert(two, StateDb::new(MemDb::default())); @@ -482,7 +482,7 @@ mod tests { let loaded = storage.get(&one).unwrap(); let acc = loaded.basic_ref(addr).unwrap().unwrap(); - assert_eq!(acc.balance, rU256::from(1337u64)); + assert_eq!(acc.balance, U256::from(1337u64)); } #[tokio::test(flavor = "multi_thread")] @@ -496,7 +496,7 @@ mod tests { let hash = B256::from(U256::from(idx)); let addr = Address::from_word(hash); let balance = (idx * 2) as u64; - let info = AccountInfo::from_balance(rU256::from(balance)); + let info = AccountInfo::from_balance(U256::from(balance)); state.insert_account(addr, info); storage.insert(hash, StateDb::new(state)); } @@ -513,7 +513,7 @@ mod tests { let loaded = storage.get(&hash).unwrap(); let acc = loaded.basic_ref(addr).unwrap().unwrap(); let balance = (idx * 2) as u64; - assert_eq!(acc.balance, rU256::from(balance)); + assert_eq!(acc.balance, U256::from(balance)); } } diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 57abc0c4055ea..048e264a3233e 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -2,7 +2,7 @@ use crate::eth::{ backend::mem::{storage::MinedTransaction, Backend}, error::{BlockchainError, Result}, }; -use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256 as rU256, U256}; +use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256}; use alloy_rpc_types::{Block, BlockTransactions, Transaction}; use alloy_rpc_types_trace::parity::{ Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, @@ -295,7 +295,7 @@ impl OtsInternalOperation { .filter_map(|node| { let r#type = match node.trace.kind { _ if node.is_selfdestruct() => OtsInternalOperationType::SelfDestruct, - CallKind::Call if node.trace.value != rU256::ZERO => { + CallKind::Call if node.trace.value != U256::ZERO => { OtsInternalOperationType::Transfer } CallKind::Create => OtsInternalOperationType::Create, diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 3c538f21034c7..7d92ab935ee19 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -221,7 +221,7 @@ fn build_filter_topics(topics: Vec) -> Result { #[cfg(test)] mod tests { use super::*; - use alloy_primitives::{U160, U256 as rU256}; + use alloy_primitives::{U160, U256}; use alloy_rpc_types::ValueOrArray; const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"; @@ -286,7 +286,7 @@ mod tests { #[test] fn test_build_filter_sig_with_arguments() { let addr = Address::from_str(ADDRESS).unwrap(); - let addr = rU256::from(U160::from_be_bytes(addr.0 .0)); + let addr = U256::from(U160::from_be_bytes(addr.0 .0)); let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, address: vec![].into(), @@ -311,7 +311,7 @@ mod tests { #[test] fn test_build_filter_sig_with_skipped_arguments() { let addr = Address::from_str(ADDRESS).unwrap(); - let addr = rU256::from(U160::from_be_bytes(addr.0 .0)); + let addr = U256::from(U160::from_be_bytes(addr.0 .0)); let expected = Filter { block_option: FilterBlockOption::Range { from_block: None, to_block: None }, address: vec![].into(), From 77cc4296e80bcfc50c4ceb909fe20886a2b7116c Mon Sep 17 00:00:00 2001 From: Paul Peregud Date: Tue, 18 Jun 2024 15:23:06 +0200 Subject: [PATCH 1108/1963] pick a random value for prevrandao for each block (#8187) Co-authored-by: Pawel Peregud --- crates/anvil/src/eth/backend/mem/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d40c7a07dc046..bb3de1b091a53 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -941,6 +941,9 @@ impl Backend { env.block.blob_excess_gas_and_price = current_excess_blob_gas_and_price; env.block.timestamp = U256::from(self.time.next_timestamp()); + // pick a random value for prevrandao + env.block.prevrandao = Some(B256::random()); + let best_hash = self.blockchain.storage.read().best_hash; if self.prune_state_history_config.is_state_history_supported() { From 4d6c77c126334e3b403ebc4c0152884aa35dc2af Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:15:27 +0200 Subject: [PATCH 1109/1963] chore: fix patches (#8189) --- Cargo.lock | 20 -------------------- Cargo.toml | 12 ++++++------ 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aead342de9fae..481ff0646c7bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9841,23 +9841,3 @@ dependencies = [ "cc", "pkg-config", ] - -[[patch.unused]] -name = "revm" -version = "9.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" - -[[patch.unused]] -name = "revm-interpreter" -version = "5.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" - -[[patch.unused]] -name = "revm-precompile" -version = "7.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" - -[[patch.unused]] -name = "revm-primitives" -version = "4.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=dd98b3b#dd98b3bb977396d23966e0a2f40d97678d931573" diff --git a/Cargo.toml b/Cargo.toml index 719e5f3324667..9a327b7a3a499 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,8 +158,8 @@ foundry-compilers = { version = "0.8.0", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "9.0.0", git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f", default-features = false } -revm-primitives = { version = "4.0.0", git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f", default-features = false } +revm = { version = "9.0.0", default-features = false } +revm-primitives = { version = "4.0.0", default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "4fe17f0", features = [ "serde", ] } @@ -251,7 +251,7 @@ tower-http = "0.5" soldeer = "0.2.15" [patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } -revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } -revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } -revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "dd98b3b" } +revm = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } +revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } +revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } +revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } From 91074f1e9dec3b636db219d42f4441dbfb26b30f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 18 Jun 2024 20:19:27 +0200 Subject: [PATCH 1110/1963] perf: optimize load_contracts (#8190) --- .../evm/evm/src/executors/invariant/replay.rs | 11 +++---- crates/evm/traces/src/decoder/mod.rs | 9 +++--- crates/evm/traces/src/identifier/local.rs | 2 +- crates/evm/traces/src/lib.rs | 30 +++++++++---------- crates/forge/src/runner.rs | 13 ++++---- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index d3d974d29e86f..cf9fa12e81fc8 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -30,7 +30,7 @@ pub fn replay_run( logs: &mut Vec, traces: &mut Traces, coverage: &mut Option, - inputs: Vec, + inputs: &[BasicTxDetails], ) -> Result> { // We want traces for a failed case. executor.set_tracing(true); @@ -38,7 +38,7 @@ pub fn replay_run( let mut counterexample_sequence = vec![]; // Replay each call from the sequence, collect logs, traces and coverage. - for tx in inputs.iter() { + for tx in inputs { let call_result = executor.transact_raw( tx.sender, tx.call_details.target, @@ -57,10 +57,7 @@ pub fn replay_run( } // Identify newly generated contracts, if they exist. - ided_contracts.extend(load_contracts( - vec![(TraceKind::Execution, call_result.traces.clone().unwrap())], - known_contracts, - )); + ided_contracts.extend(load_contracts(call_result.traces.as_slice(), known_contracts)); // Create counter example to be used in failed case. counterexample_sequence.push(BaseCounterExample::from_invariant_call( @@ -133,7 +130,7 @@ pub fn replay_error( logs, traces, coverage, - calls, + &calls, ) } } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 2dbdbd7bf1ceb..ec1ea199ffdd9 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -200,7 +200,7 @@ impl CallTraceDecoder { /// /// Unknown contracts are contracts that either lack a label or an ABI. pub fn identify(&mut self, trace: &CallTraceArena, identifier: &mut impl TraceIdentifier) { - self.collect_identities(identifier.identify_addresses(self.addresses(trace))); + self.collect_identities(identifier.identify_addresses(self.trace_addresses(trace))); } /// Adds a single event to the decoder. @@ -230,7 +230,8 @@ impl CallTraceDecoder { self.revert_decoder.push_error(error); } - fn addresses<'a>( + /// Returns an iterator over the trace addresses. + pub fn trace_addresses<'a>( &'a self, arena: &'a CallTraceArena, ) -> impl Iterator)> + Clone + 'a { @@ -243,8 +244,8 @@ impl CallTraceDecoder { node.trace.kind.is_any_create().then_some(&node.trace.output[..]), ) }) - .filter(|(address, _)| { - !self.labels.contains_key(*address) || !self.contracts.contains_key(*address) + .filter(|&(address, _)| { + !self.labels.contains_key(address) || !self.contracts.contains_key(address) }) } diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index e82d733789f87..04680b01a91a4 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -95,7 +95,7 @@ impl<'a> LocalTraceIdentifier<'a> { /// artifact with a greater code length if the exact code length is not found. fn find_index(&self, len: usize) -> usize { let (Ok(mut idx) | Err(mut idx)) = - self.ordered_ids.binary_search_by(|(_, probe)| probe.cmp(&len)); + self.ordered_ids.binary_search_by_key(&len, |(_, probe)| *probe); // In case of multiple artifacts with the same code length, we need to find the first one. while idx > 0 && self.ordered_ids[idx - 1].1 == len { diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 052be9c053422..d352abfc8f43e 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -20,7 +20,7 @@ use yansi::{Color, Paint}; /// /// Identifiers figure out what ABIs and labels belong to all the addresses of the trace. pub mod identifier; -use identifier::LocalTraceIdentifier; +use identifier::{LocalTraceIdentifier, TraceIdentifier}; mod decoder; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; @@ -295,21 +295,19 @@ fn trace_color(trace: &CallTrace) -> Color { } /// Given a list of traces and artifacts, it returns a map connecting address to abi -pub fn load_contracts(traces: Traces, known_contracts: &ContractsByArtifact) -> ContractsByAddress { +pub fn load_contracts<'a>( + traces: impl IntoIterator, + known_contracts: &ContractsByArtifact, +) -> ContractsByAddress { let mut local_identifier = LocalTraceIdentifier::new(known_contracts); - let mut decoder = CallTraceDecoderBuilder::new().build(); - for (_, trace) in &traces { - decoder.identify(trace, &mut local_identifier); - } - - decoder - .contracts - .iter() - .filter_map(|(addr, name)| { - if let Ok(Some((_, contract))) = known_contracts.find_by_name_or_identifier(name) { - return Some((*addr, (name.clone(), contract.abi.clone()))); + let decoder = CallTraceDecoder::new(); + let mut contracts = ContractsByAddress::new(); + for trace in traces { + for address in local_identifier.identify_addresses(decoder.trace_addresses(trace)) { + if let (Some(contract), Some(abi)) = (address.contract, address.abi) { + contracts.insert(address.address, (contract, abi.into_owned())); } - None - }) - .collect() + } + } + contracts } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index ffd22bf10b6e4..d2213cd3796d3 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -384,8 +384,8 @@ impl<'a> ContractRunner<'a> { find_time, ); - let identified_contracts = - has_invariants.then(|| load_contracts(setup.traces.clone(), &known_contracts)); + let identified_contracts = has_invariants + .then(|| load_contracts(setup.traces.iter().map(|(_, t)| t), &known_contracts)); let test_results = functions .par_iter() .map(|&func| { @@ -596,13 +596,12 @@ impl<'a> ContractRunner<'a> { { // Create calls from failed sequence and check if invariant still broken. let txes = call_sequence - .clone() - .into_iter() + .iter() .map(|seq| BasicTxDetails { sender: seq.sender.unwrap_or_default(), call_details: CallDetails { target: seq.addr.unwrap_or_default(), - calldata: seq.calldata, + calldata: seq.calldata.clone(), }, }) .collect::>(); @@ -626,7 +625,7 @@ impl<'a> ContractRunner<'a> { &mut logs, &mut traces, &mut coverage, - txes, + &txes, ); return TestResult { status: TestStatus::Failure, @@ -728,7 +727,7 @@ impl<'a> ContractRunner<'a> { &mut logs, &mut traces, &mut coverage, - last_run_inputs.clone(), + &last_run_inputs, ) { error!(%err, "Failed to replay last invariant run"); } From 588a1d7cd887d17986066f7c3a641f85c9d6c743 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 19 Jun 2024 00:22:33 +0200 Subject: [PATCH 1111/1963] chore(deps): move more deps to workspace (#8192) --- Cargo.toml | 13 ++++++++++++- crates/anvil/Cargo.toml | 10 +++++----- crates/anvil/server/Cargo.toml | 8 ++++---- crates/cast/Cargo.toml | 8 ++++---- crates/cheatcodes/Cargo.toml | 8 ++++---- crates/chisel/Cargo.toml | 2 +- crates/cli/Cargo.toml | 4 ++-- crates/common/Cargo.toml | 14 +++++++------- crates/config/Cargo.toml | 14 +++++++------- crates/doc/Cargo.toml | 6 +++--- crates/evm/core/Cargo.toml | 20 ++++++++++---------- crates/evm/coverage/Cargo.toml | 6 +++--- crates/evm/evm/Cargo.toml | 8 ++++---- crates/evm/fuzz/Cargo.toml | 10 +++++----- crates/evm/traces/Cargo.toml | 10 +++++----- crates/fmt/Cargo.toml | 2 +- crates/forge/Cargo.toml | 14 +++++++------- crates/linking/Cargo.toml | 4 ++-- crates/script/Cargo.toml | 8 ++++---- crates/test-utils/Cargo.toml | 8 ++++---- crates/verify/Cargo.toml | 8 ++++---- crates/wallets/Cargo.toml | 4 ++-- 22 files changed, 100 insertions(+), 89 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a327b7a3a499..f40876ac8341f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -205,6 +205,9 @@ alloy-rlp = "0.3.3" solang-parser = "=0.3.3" ## misc +async-trait = "0.1" +auto_impl = "1" +walkdir = "2" proc-macro2 = "1.0.82" quote = "1.0" syn = "2.0" @@ -218,24 +221,32 @@ chrono = { version = "0.4", default-features = false, features = [ ] } color-eyre = "0.6" derive_more = "0.99" +dunce = "1" evm-disassembler = "0.5" eyre = "0.6" +figment = "0.10" +futures = "0.3" hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" -similar-asserts = "1.5" +once_cell = "1" +parking_lot = "0.12" rand = "0.8" rustc-hash = "1.1" +semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } +similar-asserts = "1.5" strum = "0.26" +thiserror = "1" toml = "0.8" tracing = "0.1" tracing-subscriber = "0.3" vergen = { version = "8", default-features = false } indexmap = "2.2" tikv-jemallocator = "0.5.4" +url = "2" num-format = "0.4.4" yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } tempfile = "3.10" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 9d31ce6d632d6..c374a8c8c940f 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -80,16 +80,16 @@ tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } # async tokio = { workspace = true, features = ["time"] } -parking_lot = "0.12" -futures = "0.3" -async-trait = "0.1" +parking_lot.workspace = true +futures.workspace = true +async-trait.workspace = true # misc flate2 = "1.0" serde_repr = "0.1" serde_json.workspace = true serde.workspace = true -thiserror = "1" +thiserror .workspace = true yansi.workspace = true tempfile.workspace = true itertools.workspace = true @@ -104,7 +104,7 @@ clap = { version = "4", features = [ ], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true -auto_impl = "1" +auto_impl.workspace = true ctrlc = { version = "3", optional = true } fdlimit = { version = "0.3", optional = true } clap_complete_fig = "4" diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index 051da35c7887e..282e090132dae 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -24,8 +24,8 @@ tower-http = { workspace = true, features = ["trace", "cors"] } tracing.workspace = true # async -parking_lot = "0.12" -futures = "0.3" +parking_lot.workspace = true +futures.workspace = true # ipc interprocess = { version = "2", optional = true, features = ["tokio"] } @@ -35,8 +35,8 @@ tokio-util = { version = "0.7", features = ["codec"], optional = true } # misc serde_json.workspace = true serde.workspace = true -async-trait = "0.1" -thiserror = "1" +async-trait.workspace = true +thiserror.workspace = true clap = { version = "4", features = ["derive", "env"], optional = true } pin-project = "1" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 02312eb784506..525c2c3f7cd18 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -53,7 +53,7 @@ alloy-transport.workspace = true chrono.workspace = true evm-disassembler.workspace = true eyre.workspace = true -futures = "0.3" +futures.workspace = true hex.workspace = true rand.workspace = true rayon.workspace = true @@ -70,12 +70,12 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" comfy-table = "7" -dunce = "1" +dunce.workspace = true indicatif = "0.17" itertools.workspace = true regex = { version = "1", default-features = false } rpassword = "7" -semver = "1" +semver.workspace = true tempfile.workspace = true tokio = { workspace = true, features = ["macros", "signal"] } tracing.workspace = true @@ -87,7 +87,7 @@ tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] foundry-test-utils.workspace = true -async-trait = "0.1" +async-trait.workspace = true criterion = "0.5" [features] diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 41415c2f8925a..b155a8643b5e5 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -34,7 +34,7 @@ alloy-signer-local = { workspace = true, features = [ "mnemonic-all-languages", "keystore", ] } -parking_lot = "0.12" +parking_lot.workspace = true eyre.workspace = true hex.workspace = true @@ -46,10 +46,10 @@ base64.workspace = true toml = { workspace = true, features = ["preserve_order"] } tracing.workspace = true k256.workspace = true -walkdir = "2" +walkdir.workspace = true p256 = "0.13.2" -thiserror = "1" -semver = "1" +thiserror.workspace = true +semver.workspace = true rustc-hash.workspace = true dialoguer = "0.11.0" rand = "0.8" diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index f527deb2e1db9..64e218f97f053 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -55,7 +55,7 @@ regex = "1" reqwest.workspace = true revm.workspace = true rustyline = "12" -semver = "1" +semver.workspace = true serde_json.workspace = true serde.workspace = true solang-parser.workspace = true diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 7b66c7045c4a8..f13dbe5f646ce 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -34,7 +34,7 @@ color-eyre.workspace = true dotenvy = "0.15" eyre.workspace = true indicatif = "0.17" -once_cell = "1" +once_cell.workspace = true regex = { version = "1", default-features = false } serde.workspace = true strsim = "0.10" @@ -45,7 +45,7 @@ tracing-subscriber = { workspace = true, features = ["registry", "env-filter", " tracing.workspace = true yansi.workspace = true hex.workspace = true -futures = "0.3" +futures.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index c8c79534dc2ff..953835abc4294 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -46,21 +46,21 @@ alloy-transport.workspace = true tower.workspace = true -async-trait = "0.1" +async-trait.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" -dunce = "1" +dunce.workspace = true eyre.workspace = true -once_cell = "1" +once_cell.workspace = true reqwest.workspace = true -semver = "1" +semver.workspace = true serde_json.workspace = true serde.workspace = true -thiserror = "1" +thiserror.workspace = true tokio.workspace = true tracing.workspace = true -url = "2" -walkdir = "2" +url.workspace = true +walkdir.workspace = true yansi.workspace = true rustc-hash.workspace = true num-format.workspace = true diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index c487c78c688e6..445d80940b7a4 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -21,32 +21,32 @@ revm-primitives.workspace = true solang-parser.workspace = true dirs-next = "2" -dunce = "1" +dunce.workspace = true eyre.workspace = true -figment = { version = "0.10", features = ["toml", "env"] } +figment = { workspace = true, features = ["toml", "env"] } globset = "0.4" glob = "0.3" Inflector = "0.11" number_prefix = "0.4" -once_cell = "1" +once_cell.workspace = true regex = "1" reqwest.workspace = true -semver = { version = "1", features = ["serde"] } +semver = { workspace = true, features = ["serde"] } serde_json.workspace = true serde_regex = "1" serde.workspace = true -thiserror = "1" +thiserror.workspace = true toml = { version = "0.8", features = ["preserve_order"] } toml_edit = "0.22.4" tracing.workspace = true -walkdir = "2" +walkdir.workspace = true [target.'cfg(target_os = "windows")'.dependencies] path-slash = "0.2.1" [dev-dependencies] similar-asserts.workspace = true -figment = { version = "0.10", features = ["test"] } +figment = { workspace = true, features = ["test"] } tempfile.workspace = true [features] diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 36b107a9ee763..ab74ef697a440 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -20,17 +20,17 @@ foundry-config.workspace = true alloy-primitives.workspace = true -auto_impl = "1" +auto_impl.workspace = true derive_more = "0.99" eyre.workspace = true itertools.workspace = true mdbook = { version = "0.4", default-features = false, features = ["search"] } -once_cell = "1" +once_cell.workspace = true rayon.workspace = true serde_json.workspace = true serde.workspace = true solang-parser.workspace = true -thiserror = "1" +thiserror.workspace = true toml.workspace = true tracing.workspace = true regex = "1.10.2" diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index b8253b494e4a6..d44f2cb4b0745 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -48,21 +48,21 @@ revm = { workspace = true, features = [ revm-inspectors.workspace = true arrayvec.workspace = true -auto_impl = "1" +auto_impl.workspace = true derive_more.workspace = true -eyre = "0.6" -futures = "0.3" +eyre.workspace = true +futures.workspace = true hex.workspace = true itertools.workspace = true -once_cell = "1" -parking_lot = "0.12" +once_cell.workspace = true +parking_lot.workspace = true rustc-hash.workspace = true -serde = "1" -serde_json = "1" -thiserror = "1" +serde.workspace = true +serde_json.workspace = true +thiserror.workspace = true tokio = { workspace = true, features = ["time", "macros"] } -tracing = "0.1" -url = "2" +tracing.workspace = true +url.workspace = true [dev-dependencies] foundry-test-utils.workspace = true diff --git a/crates/evm/coverage/Cargo.toml b/crates/evm/coverage/Cargo.toml index 6858159de43dd..777c37d99429a 100644 --- a/crates/evm/coverage/Cargo.toml +++ b/crates/evm/coverage/Cargo.toml @@ -19,9 +19,9 @@ foundry-compilers.workspace = true foundry-evm-core.workspace = true alloy-primitives.workspace = true -eyre = "0.6" +eyre.workspace = true revm.workspace = true -semver = "1" -tracing = "0.1" +semver.workspace = true +tracing.workspace = true rustc-hash.workspace = true rayon.workspace = true diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 3b00c9d66ad55..bcd933a4bc73d 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -45,9 +45,9 @@ revm = { workspace = true, default-features = false, features = [ revm-inspectors.workspace = true arrayvec.workspace = true -eyre = "0.6" -parking_lot = "0.12" +eyre.workspace = true +parking_lot.workspace = true proptest = "1" -thiserror = "1" -tracing = "0.1" +thiserror.workspace = true +tracing.workspace = true indicatif = "0.17" diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 4101c080f1b59..0106b1d2704c1 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -39,13 +39,13 @@ revm = { workspace = true, features = [ "arbitrary", ] } -eyre = "0.6" +eyre .workspace = true itertools.workspace = true -parking_lot = "0.12" +parking_lot.workspace = true proptest = "1" rand.workspace = true -serde = "1" -thiserror = "1" -tracing = "0.1" +serde.workspace = true +thiserror.workspace = true +tracing.workspace = true indexmap.workspace = true ahash.workspace = true diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 8c2ccb3ae9713..b076db127821c 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -31,14 +31,14 @@ alloy-primitives = { workspace = true, features = [ alloy-sol-types.workspace = true revm-inspectors.workspace = true -eyre = "0.6" -futures = "0.3" +eyre .workspace = true +futures.workspace = true hex.workspace = true itertools.workspace = true -once_cell = "1" -serde = "1" +once_cell.workspace = true +serde.workspace = true tokio = { workspace = true, features = ["time", "macros"] } -tracing = "0.1" +tracing.workspace = true yansi.workspace = true rustc-hash.workspace = true tempfile.workspace = true diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index 835b2e8b7547c..0bc3e06a6b806 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -20,7 +20,7 @@ alloy-primitives.workspace = true ariadne = "0.4" itertools.workspace = true solang-parser.workspace = true -thiserror = "1" +thiserror.workspace = true tracing.workspace = true [dev-dependencies] diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 493a8c0420882..23a4f22a62b88 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -70,26 +70,26 @@ alloy-sol-macro-expander = { workspace = true, features = ["json"] } alloy-sol-macro-input.workspace = true alloy-transport.workspace = true -async-trait = "0.1" +async-trait.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" dialoguer = { version = "0.11", default-features = false } -dunce = "1" -futures = "0.3" +dunce.workspace = true +futures.workspace = true hex.workspace = true indicatif = "0.17" itertools.workspace = true -once_cell = "1" -parking_lot = "0.12" +once_cell.workspace = true +parking_lot.workspace = true regex = { version = "1", default-features = false } reqwest = { workspace = true, features = ["json"] } -semver = "1" +semver.workspace = true serde_json.workspace = true similar = { version = "2", features = ["inline"] } solang-parser.workspace = true strum = { workspace = true, features = ["derive"] } -thiserror = "1" +thiserror.workspace = true tokio = { workspace = true, features = ["time"] } toml = { version = "0.8", features = ["preserve_order"] } toml_edit = "0.22.4" diff --git a/crates/linking/Cargo.toml b/crates/linking/Cargo.toml index 2587244a23340..15d0d113b74d8 100644 --- a/crates/linking/Cargo.toml +++ b/crates/linking/Cargo.toml @@ -15,6 +15,6 @@ workspace = true [dependencies] foundry-compilers = { workspace = true, features = ["full"] } -semver = "1" +semver.workspace = true alloy-primitives = { workspace = true, features = ["rlp"] } -thiserror = "1" +thiserror.workspace = true diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 4d97f3fc99056..a57a118174804 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -28,16 +28,16 @@ hex.workspace = true serde.workspace = true eyre.workspace = true serde_json.workspace = true -dunce = "1" +dunce.workspace = true foundry-compilers = { workspace = true, features = ["full"] } tracing.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } -semver = "1" -futures = "0.3" +semver.workspace = true +futures.workspace = true async-recursion = "1.0.5" itertools.workspace = true -parking_lot = "0.12" +parking_lot.workspace = true yansi.workspace = true revm-inspectors.workspace = true alloy-rpc-types.workspace = true diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 710050dab76b7..95ef8d6c9f314 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -24,14 +24,14 @@ alloy-provider.workspace = true eyre.workspace = true fd-lock = "4.0.0" -once_cell = "1" -parking_lot = "0.12" +once_cell.workspace = true +parking_lot.workspace = true similar-asserts.workspace = true regex = "1" serde_json.workspace = true -tracing = "0.1" +tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } -walkdir = "2" +walkdir.workspace = true rand.workspace = true [features] diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 378a292b87998..f308381d4643c 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -33,11 +33,11 @@ foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } reqwest = { workspace = true, features = ["json"] } -async-trait = "0.1" -futures = "0.3" -semver = "1" +async-trait.workspace = true +futures.workspace = true +semver.workspace = true regex = { version = "1", default-features = false } -once_cell = "1" +once_cell.workspace = true yansi.workspace = true itertools.workspace = true diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index dc013ae6265fd..183a978541df4 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -37,14 +37,14 @@ gcloud-sdk = { version = "0.24", features = [ "google-longrunning", ], optional = true } -async-trait = "0.1" +async-trait.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } derive_builder = "0.20.0" eyre.workspace = true hex = { workspace = true, features = ["serde"] } rpassword = "7" serde.workspace = true -thiserror = "1" +thiserror.workspace = true tracing.workspace = true [dev-dependencies] From 4af6cfaef200ad3ffa598ba419f79b15cb962e52 Mon Sep 17 00:00:00 2001 From: funnybird Date: Wed, 19 Jun 2024 17:20:08 +0800 Subject: [PATCH 1112/1963] feat(cast): ux upgrade cast block returning block time in readable format. (#8195) * feat(cast): support readable time for cast block * fix: remove `time` * Update crates/common/src/fmt/ui.rs * fmt --------- Co-authored-by: fenghaojiang Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 1 + crates/common/Cargo.toml | 1 + crates/common/src/fmt/ui.rs | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 481ff0646c7bf..da7aee4498854 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3639,6 +3639,7 @@ dependencies = [ "alloy-transport-ipc", "alloy-transport-ws", "async-trait", + "chrono", "clap", "comfy-table", "dunce", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 953835abc4294..afc8aa237d728 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -64,6 +64,7 @@ walkdir.workspace = true yansi.workspace = true rustc-hash.workspace = true num-format.workspace = true +chrono.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/src/fmt/ui.rs b/crates/common/src/fmt/ui.rs index e192f3cad3ca5..0fe8dccd175f1 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/src/fmt/ui.rs @@ -488,7 +488,7 @@ receiptsRoot {} sha3Uncles {} size {} stateRoot {} -timestamp {} +timestamp {} ({}) withdrawalsRoot {} totalDifficulty {}{}", block.header.base_fee_per_gas.pretty(), @@ -509,6 +509,9 @@ totalDifficulty {}{}", block.size.pretty(), block.header.state_root.pretty(), block.header.timestamp.pretty(), + chrono::DateTime::from_timestamp(block.header.timestamp as i64, 0) + .expect("block timestamp in range") + .to_rfc2822(), block.header.withdrawals_root.pretty(), block.header.total_difficulty.pretty(), block.other.pretty() From 864f5f4f851d0eaa968984bd9988273ad0306f03 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 19 Jun 2024 14:33:45 +0300 Subject: [PATCH 1113/1963] chore: fix flaky invariant tests (#8199) --- crates/forge/tests/it/invariant.rs | 328 ++++++------------ .../common/InvariantSelectorsWeight.t.sol | 69 +--- 2 files changed, 118 insertions(+), 279 deletions(-) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 45bcda9d558fd..019a56d148c02 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -24,48 +24,40 @@ macro_rules! get_counterexample { } #[tokio::test(flavor = "multi_thread")] -async fn test_invariant() { - let filter = Filter::new(".*", ".*", ".*fuzz/invariant/(target|targetAbi|common)"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options = TEST_DATA_DEFAULT.test_opts.clone(); - runner.test_options.invariant.failure_persist_dir = - Some(tempfile::tempdir().unwrap().into_path()); - let results = runner.test_collect(&filter); - +async fn test_invariant_with_alias() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantTest1.t.sol"); + let results = TEST_DATA_DEFAULT.runner().test_collect(&filter); assert_multiple( &results, - BTreeMap::from([ - ( - "default/fuzz/invariant/common/InvariantHandlerFailure.t.sol:InvariantHandlerFailure", - vec![("statefulFuzz_BrokenInvariant()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantInnerContract.t.sol:InvariantInnerContract", - vec![( - "invariantHideJesus()", + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantTest1.t.sol:InvariantTest", + vec![ + ("invariant_neverFalse()", false, Some("revert: false".into()), None, None), + ( + "statefulFuzz_neverFalseWithInvariantAlias()", false, - Some("revert: jesus betrayed".into()), + Some("revert: false".into()), None, None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantReentrancy.t.sol:InvariantReentrancy", - vec![("invariantNotStolen()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantTest1.t.sol:InvariantTest", - vec![ - ("invariant_neverFalse()", false, Some("revert: false".into()), None, None), - ( - "statefulFuzz_neverFalseWithInvariantAlias()", - false, - Some("revert: false".into()), - None, - None, - ), - ], - ), + ), + ], + )]), + ); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_filters() { + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.runs = 10; + + // Contracts filter tests. + assert_multiple( + &runner.test_collect(&Filter::new( + ".*", + ".*", + ".*fuzz/invariant/target/(ExcludeContracts|TargetContracts).t.sol", + )), + BTreeMap::from([ ( "default/fuzz/invariant/target/ExcludeContracts.t.sol:ExcludeContracts", vec![("invariantTrueWorld()", true, None, None, None)], @@ -74,18 +66,23 @@ async fn test_invariant() { "default/fuzz/invariant/target/TargetContracts.t.sol:TargetContracts", vec![("invariantTrueWorld()", true, None, None, None)], ), + ]), + ); + + // Senders filter tests. + assert_multiple( + &runner.test_collect(&Filter::new( + ".*", + ".*", + ".*fuzz/invariant/target/(ExcludeSenders|TargetSenders).t.sol", + )), + BTreeMap::from([ ( - "default/fuzz/invariant/target/TargetSenders.t.sol:TargetSenders", - vec![( - "invariantTrueWorld()", - false, - Some("revert: false world".into()), - None, - None, - )], + "default/fuzz/invariant/target/ExcludeSenders.t.sol:ExcludeSenders", + vec![("invariantTrueWorld()", true, None, None, None)], ), ( - "default/fuzz/invariant/target/TargetInterfaces.t.sol:TargetWorldInterfaces", + "default/fuzz/invariant/target/TargetSenders.t.sol:TargetSenders", vec![( "invariantTrueWorld()", false, @@ -94,18 +91,49 @@ async fn test_invariant() { None, )], ), + ]), + ); + + // Interfaces filter tests. + assert_multiple( + &runner.test_collect(&Filter::new( + ".*", + ".*", + ".*fuzz/invariant/target/TargetInterfaces.t.sol", + )), + BTreeMap::from([( + "default/fuzz/invariant/target/TargetInterfaces.t.sol:TargetWorldInterfaces", + vec![("invariantTrueWorld()", false, Some("revert: false world".into()), None, None)], + )]), + ); + + // Selectors filter tests. + assert_multiple( + &runner.test_collect(&Filter::new( + ".*", + ".*", + ".*fuzz/invariant/target/(ExcludeSelectors|TargetSelectors).t.sol", + )), + BTreeMap::from([ ( - "default/fuzz/invariant/target/ExcludeSenders.t.sol:ExcludeSenders", - vec![("invariantTrueWorld()", true, None, None, None)], + "default/fuzz/invariant/target/ExcludeSelectors.t.sol:ExcludeSelectors", + vec![("invariantFalseWorld()", true, None, None, None)], ), ( "default/fuzz/invariant/target/TargetSelectors.t.sol:TargetSelectors", vec![("invariantTrueWorld()", true, None, None, None)], ), - ( - "default/fuzz/invariant/target/ExcludeSelectors.t.sol:ExcludeSelectors", - vec![("invariantFalseWorld()", true, None, None, None)], - ), + ]), + ); + + // Artifacts filter tests. + assert_multiple( + &runner.test_collect(&Filter::new( + ".*", + ".*", + ".*fuzz/invariant/targetAbi/(ExcludeArtifacts|TargetArtifacts|TargetArtifactSelectors|TargetArtifactSelectors2).t.sol", + )), + BTreeMap::from([ ( "default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol:ExcludeArtifacts", vec![("invariantShouldPass()", true, None, None, None)], @@ -137,142 +165,6 @@ async fn test_invariant() { None, )], ), - ( - "default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithAssert", - vec![( - "invariant_with_assert()", - false, - Some("".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol:InvariantShrinkWithRequire", - vec![( - "invariant_with_require()", - false, - Some("revert: wrong counter".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantPreserveState.t.sol:InvariantPreserveState", - vec![("invariant_preserve_state()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol:InvariantCalldataDictionary", - vec![( - "invariant_owner_never_changes()", - false, - Some("".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantAssume.t.sol:InvariantAssume", - vec![("invariant_dummy()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantCustomError.t.sol:InvariantCustomError", - vec![("invariant_decode_error()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/target/FuzzedTargetContracts.t.sol:ExplicitTargetContract", - vec![("invariant_explicit_target()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/target/FuzzedTargetContracts.t.sol:DynamicTargetContract", - vec![("invariant_dynamic_targets()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantFixtures.t.sol:InvariantFixtures", - vec![( - "invariant_target_not_compromised()", - false, - Some("".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol:ShrinkBigSequenceTest", - vec![("invariant_shrink_big_sequence()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol:ShrinkFailOnRevertTest", - vec![("invariant_shrink_fail_on_revert()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantScrapeValues.t.sol:FindFromReturnValueTest", - vec![( - "invariant_value_not_found()", - false, - Some("revert: value from return found".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantScrapeValues.t.sol:FindFromLogValueTest", - vec![( - "invariant_value_not_found()", - false, - Some("revert: value from logs found".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkBlockTest", - vec![( - "invariant_fork_handler_block()", - false, - Some("revert: too many blocks mined".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantRollFork.t.sol:InvariantRollForkStateTest", - vec![( - "invariant_fork_handler_state()", - false, - Some("revert: wrong supply".into()), - None, - None, - )], - ), - ( - "default/fuzz/invariant/common/InvariantExcludedSenders.t.sol:InvariantExcludedSendersTest", - vec![("invariant_check_sender()", true, None, None, None)], - ), - ( - "default/fuzz/invariant/common/InvariantAfterInvariant.t.sol:InvariantAfterInvariantTest", - vec![ - ( - "invariant_after_invariant_failure()", - false, - Some("revert: afterInvariant failure".into()), - None, - None, - ), - ( - "invariant_failure()", - false, - Some("revert: invariant failure".into()), - None, - None, - ), - ("invariant_success()", true, None, None, None), - ], - ), - ( - "default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol:InvariantSelectorsWeightTest", - vec![("invariant_selectors_weight()", true, None, None, None)], - ) ]), ); } @@ -284,7 +176,6 @@ async fn test_invariant_override() { runner.test_options.invariant.fail_on_revert = false; runner.test_options.invariant.call_override = true; let results = runner.test_collect(&filter); - assert_multiple( &results, BTreeMap::from([( @@ -302,7 +193,6 @@ async fn test_invariant_fail_on_revert() { runner.test_options.invariant.runs = 1; runner.test_options.invariant.depth = 10; let results = runner.test_collect(&filter); - assert_multiple( &results, BTreeMap::from([( @@ -326,7 +216,6 @@ async fn test_invariant_storage() { runner.test_options.invariant.depth = 100 + (50 * cfg!(windows) as u32); runner.test_options.fuzz.seed = Some(U256::from(6u32)); let results = runner.test_collect(&filter); - assert_multiple( &results, BTreeMap::from([( @@ -341,6 +230,25 @@ async fn test_invariant_storage() { ); } +#[tokio::test(flavor = "multi_thread")] +async fn test_invariant_inner_contract() { + let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); + let results = TEST_DATA_DEFAULT.runner().test_collect(&filter); + assert_multiple( + &results, + BTreeMap::from([( + "default/fuzz/invariant/common/InvariantInnerContract.t.sol:InvariantInnerContract", + vec![( + "invariantHideJesus()", + false, + Some("revert: jesus betrayed".into()), + None, + None, + )], + )]), + ); +} + #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_shrink() { @@ -405,13 +313,10 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_shrink_big_sequence() { - let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); - opts.fuzz.seed = Some(U256::from(119u32)); - let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantShrinkBigSequence.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options = opts.clone(); + runner.test_options.fuzz.seed = Some(U256::from(119u32)); runner.test_options.invariant.runs = 1; runner.test_options.invariant.depth = 500; @@ -480,13 +385,10 @@ async fn test_shrink_big_sequence() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_shrink_fail_on_revert() { - let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); - opts.fuzz.seed = Some(U256::from(119u32)); - let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options = opts.clone(); + runner.test_options.fuzz.seed = Some(U256::from(119u32)); runner.test_options.invariant.fail_on_revert = true; runner.test_options.invariant.runs = 1; runner.test_options.invariant.depth = 100; @@ -656,8 +558,7 @@ async fn test_invariant_fixtures() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_scrape_values() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantScrapeValues.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - let results = runner.test_collect(&filter); + let results = TEST_DATA_DEFAULT.runner().test_collect(&filter); assert_multiple( &results, BTreeMap::from([ @@ -687,17 +588,10 @@ async fn test_invariant_scrape_values() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_roll_fork_handler() { - let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); - opts.fuzz.seed = Some(U256::from(119u32)); - let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantRollFork.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options = opts.clone(); - runner.test_options.invariant.failure_persist_dir = - Some(tempfile::tempdir().unwrap().into_path()); - + runner.test_options.fuzz.seed = Some(U256::from(119u32)); let results = runner.test_collect(&filter); - assert_multiple( &results, BTreeMap::from([ @@ -744,11 +638,7 @@ async fn test_invariant_excluded_senders() { async fn test_invariant_after_invariant() { // Check failure on passing invariant and failed `afterInvariant` condition let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAfterInvariant.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.failure_persist_dir = - Some(tempfile::tempdir().unwrap().into_path()); - - let results = runner.test_collect(&filter); + let results = TEST_DATA_DEFAULT.runner().test_collect(&filter); assert_multiple( &results, BTreeMap::from([( @@ -776,17 +666,11 @@ async fn test_invariant_after_invariant() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_selectors_weight() { - let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); - opts.fuzz.seed = Some(U256::from(100u32)); - let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantSelectorsWeight.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options = opts.clone(); + runner.test_options.fuzz.seed = Some(U256::from(119u32)); runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 30; - runner.test_options.invariant.failure_persist_dir = - Some(tempfile::tempdir().unwrap().into_path()); - + runner.test_options.invariant.depth = 10; let results = runner.test_collect(&filter); assert_multiple( &results, diff --git a/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol b/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol index 918fd7b019706..aea46f41859b0 100644 --- a/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.13; import "ds-test/test.sol"; -contract HandlerWithOneSelector { +contract HandlerOne { uint256 public hit1; function selector1() external { @@ -11,12 +11,11 @@ contract HandlerWithOneSelector { } } -contract HandlerWithFiveSelectors { +contract HandlerTwo { uint256 public hit2; uint256 public hit3; uint256 public hit4; uint256 public hit5; - uint256 public hit6; function selector2() external { hit2 += 1; @@ -33,69 +32,25 @@ contract HandlerWithFiveSelectors { function selector5() external { hit5 += 1; } - - function selector6() external { - hit6 += 1; - } -} - -contract HandlerWithFourSelectors { - uint256 public hit7; - uint256 public hit8; - uint256 public hit9; - uint256 public hit10; - - function selector7() external { - hit7 += 1; - } - - function selector8() external { - hit8 += 1; - } - - function selector9() external { - hit9 += 1; - } - - function selector10() external { - hit10 += 1; - } } contract InvariantSelectorsWeightTest is DSTest { - HandlerWithOneSelector handlerOne; - HandlerWithFiveSelectors handlerTwo; - HandlerWithFourSelectors handlerThree; + HandlerOne handlerOne; + HandlerTwo handlerTwo; function setUp() public { - handlerOne = new HandlerWithOneSelector(); - handlerTwo = new HandlerWithFiveSelectors(); - handlerThree = new HandlerWithFourSelectors(); + handlerOne = new HandlerOne(); + handlerTwo = new HandlerTwo(); } function afterInvariant() public { - // selector hits before and after https://github.com/foundry-rs/foundry/issues/2986 - // hit1: 11 | hit2: 4 | hit3: 0 | hit4: 0 | hit5: 4 | hit6: 1 | hit7: 2 | hit8: 2 | hit9: 2 | hit10: 4 - // hit1: 2 | hit2: 5 | hit3: 4 | hit4: 5 | hit5: 3 | hit6: 1 | hit7: 4 | hit8: 1 | hit9: 1 | hit10: 4 - - uint256 hit1 = handlerOne.hit1(); - uint256 hit2 = handlerTwo.hit2(); - uint256 hit3 = handlerTwo.hit3(); - uint256 hit4 = handlerTwo.hit4(); - uint256 hit5 = handlerTwo.hit5(); - uint256 hit6 = handlerTwo.hit6(); - uint256 hit7 = handlerThree.hit7(); - uint256 hit8 = handlerThree.hit8(); - uint256 hit9 = handlerThree.hit9(); - uint256 hit10 = handlerThree.hit10(); - - require( - hit1 > 0 && hit2 > 0 && hit3 > 0 && hit4 > 0 && hit5 > 0 && hit6 > 0 && hit7 > 0 && hit8 > 0 && hit9 > 0 - && hit10 > 0 - ); + // selector hits uniformly distributed, see https://github.com/foundry-rs/foundry/issues/2986 + assertEq(handlerOne.hit1(), 2); + assertEq(handlerTwo.hit2(), 2); + assertEq(handlerTwo.hit3(), 3); + assertEq(handlerTwo.hit4(), 1); + assertEq(handlerTwo.hit5(), 2); } - /// forge-config: default.invariant.runs = 1 - /// forge-config: default.invariant.depth = 30 function invariant_selectors_weight() public view {} } From dee33a00b2572784d63755b937db61de6954f2e8 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:17:56 +0200 Subject: [PATCH 1114/1963] feat(anvil): switch to `alloy` types (#8186) * update to use anvil rpc types Co-authored-by: moricho * remove redundant types * use Index from Alloy * update rev * switch to use alloy-rpc-types-anvil patch * use Index from `alloy_rpc_types_eth` instead of duplicate implementation in `alloy_rpc_types_anvil` * use Index from rpc_types * move namespaced imports of rpc-types-* to rpc-types metacrate * make sure to enable "eth" namespace because default features are not enabled --------- Co-authored-by: moricho --- Cargo.lock | 57 +++-- Cargo.toml | 3 +- crates/anvil/Cargo.toml | 5 +- crates/anvil/core/Cargo.toml | 3 +- crates/anvil/core/src/eth/mod.rs | 22 +- crates/anvil/core/src/types.rs | 216 +----------------- crates/anvil/src/eth/api.rs | 45 ++-- crates/anvil/src/eth/backend/fork.rs | 14 +- crates/anvil/src/eth/backend/mem/mod.rs | 32 +-- crates/anvil/src/eth/backend/mem/storage.rs | 10 +- crates/anvil/src/eth/otterscan/api.rs | 6 +- crates/anvil/src/eth/otterscan/types.rs | 10 +- crates/anvil/src/tasks/mod.rs | 3 +- crates/anvil/tests/it/anvil_api.rs | 25 +- crates/anvil/tests/it/fork.rs | 2 +- crates/anvil/tests/it/traces.rs | 10 +- crates/common/Cargo.toml | 3 +- .../common/src/provider/runtime_transport.rs | 2 +- 18 files changed, 139 insertions(+), 329 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da7aee4498854..a9c2d98265076 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,7 +86,7 @@ dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "c-kzg", "serde", ] @@ -140,7 +140,7 @@ checksum = "3bdbc8d98cc36ebe17bb5b42d0873137bc76628a4ee0f7e7acad5b8fc59d3597" dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "c-kzg", "derive_more", "once_cell", @@ -155,7 +155,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e10a047066076b32d52b3228e95a4f7793db7a204f648aa1a1ea675085bffd8" dependencies = [ "alloy-primitives", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", ] @@ -196,7 +196,7 @@ dependencies = [ "alloy-json-rpc", "alloy-primitives", "alloy-rpc-types-eth", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-signer", "alloy-sol-types", "async-trait", @@ -341,10 +341,22 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3164e7d8a718a22ede70b2c1d2bb554a8b4bd8e56c07ab630b75c74c06c53752" dependencies = [ + "alloy-rpc-types-anvil", + "alloy-rpc-types-engine", "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "alloy-rpc-types-anvil" +version = "0.1.1" +source = "git+https://github.com/alloy-rs/alloy?rev=8dc637e#8dc637e527e79b768380b9f95bd1a0d868deff63" +dependencies = [ + "alloy-primitives", + "alloy-serde 0.1.1 (git+https://github.com/alloy-rs/alloy?rev=8dc637e)", + "serde", ] [[package]] @@ -358,7 +370,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types-eth", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "jsonwebtoken", "rand", "serde", @@ -375,7 +387,7 @@ dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-sol-types", "itertools 0.13.0", "serde", @@ -391,7 +403,7 @@ checksum = "a39c52613dc4d9995ff284b496158594ae63f9bfc58b5ef04e48ec5da2e3d747" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", ] @@ -404,7 +416,7 @@ checksum = "4aeb7995e8859f3931b6199e13a533c9fde89affa900addb7218db2f15f9687d" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde", ] @@ -419,6 +431,16 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-serde" +version = "0.1.1" +source = "git+https://github.com/alloy-rs/alloy?rev=8dc637e#8dc637e527e79b768380b9f95bd1a0d868deff63" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", +] + [[package]] name = "alloy-signer" version = "0.1.1" @@ -790,8 +812,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-client", "alloy-rpc-types", - "alloy-rpc-types-trace", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -851,8 +872,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types", - "alloy-rpc-types-trace", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-trie", "bytes", "foundry-common", @@ -1900,7 +1920,7 @@ dependencies = [ "alloy-provider", "alloy-rlp", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -3293,7 +3313,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-signer", "alloy-signer-local", "alloy-sol-macro-expander", @@ -3421,7 +3441,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-signer", "alloy-transport", "async-recursion", @@ -3631,8 +3651,7 @@ dependencies = [ "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", - "alloy-rpc-types-engine", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3863,7 +3882,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "alloy-sol-types", "alloy-transport", "arrayvec", diff --git a/Cargo.toml b/Cargo.toml index f40876ac8341f..c1d82d44ec88b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,8 +178,6 @@ alloy-node-bindings = { version = "0.1.1", default-features = false } alloy-provider = { version = "0.1.1", default-features = false } alloy-pubsub = { version = "0.1.1", default-features = false } alloy-rpc-client = { version = "0.1.1", default-features = false } -alloy-rpc-types-engine = { version = "0.1.1", default-features = false } -alloy-rpc-types-trace = { version = "0.1.1", default-features = false } alloy-rpc-types = { version = "0.1.1", default-features = false } alloy-serde = { version = "0.1.1", default-features = false } alloy-signer = { version = "0.1.1", default-features = false } @@ -262,6 +260,7 @@ tower-http = "0.5" soldeer = "0.2.15" [patch.crates-io] +alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "8dc637e" } revm = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index c374a8c8c940f..f5ef2a5882cbb 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -54,8 +54,7 @@ alloy-signer = { workspace = true, features = ["eip712"] } alloy-signer-local = { workspace = true, features = ["mnemonic"] } alloy-sol-types = { workspace = true, features = ["std"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } -alloy-rpc-types = { workspace = true, features = ["txpool"] } -alloy-rpc-types-trace.workspace = true +alloy-rpc-types = { workspace = true, features = ["anvil", "trace", "txpool"] } alloy-serde.workspace = true alloy-provider = { workspace = true, features = [ "reqwest", @@ -89,7 +88,7 @@ flate2 = "1.0" serde_repr = "0.1" serde_json.workspace = true serde.workspace = true -thiserror .workspace = true +thiserror.workspace = true yansi.workspace = true tempfile.workspace = true itertools.workspace = true diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index aa7a323ed891c..8c2720c8f06a2 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -23,8 +23,7 @@ revm = { workspace = true, default-features = false, features = [ ] } alloy-primitives = { workspace = true, features = ["serde"] } -alloy-rpc-types.workspace = true -alloy-rpc-types-trace.workspace = true +alloy-rpc-types = { workspace = true, features = ["anvil", "trace"] } alloy-serde.workspace = true alloy-rlp.workspace = true alloy-eips.workspace = true diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index d2fa41a7be2c6..a35a7b6e6b297 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -1,15 +1,13 @@ -use crate::{ - eth::subscription::SubscriptionId, - types::{EvmMineOptions, Forking, Index}, -}; +use crate::eth::subscription::SubscriptionId; use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256}; use alloy_rpc_types::{ + anvil::{Forking, MineOptions}, pubsub::{Params as SubscriptionParams, SubscriptionKind}, request::TransactionRequest, state::StateOverride, - BlockId, BlockNumberOrTag as BlockNumber, Filter, + trace::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}, + BlockId, BlockNumberOrTag as BlockNumber, Filter, Index, }; -use alloy_rpc_types_trace::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}; use alloy_serde::WithOtherFields; pub mod block; @@ -609,7 +607,7 @@ pub enum EthRequest { /// Mine a single block #[cfg_attr(feature = "serde", serde(rename = "evm_mine"))] - EvmMine(#[cfg_attr(feature = "serde", serde(default))] Option>>), + EvmMine(#[cfg_attr(feature = "serde", serde(default))] Option>>), /// Mine a single block and return detailed data /// @@ -620,7 +618,7 @@ pub enum EthRequest { serde(rename = "anvil_mine_detailed", alias = "evm_mine_detailed",) )] EvmMineDetailed( - #[cfg_attr(feature = "serde", serde(default))] Option>>, + #[cfg_attr(feature = "serde", serde(default))] Option>>, ), /// Execute a transaction regardless of signature status @@ -1292,7 +1290,7 @@ mod tests { EthRequest::EvmMine(params) => { assert_eq!( params.unwrap().params.unwrap_or_default(), - EvmMineOptions::Options { timestamp: Some(100), blocks: Some(100) } + MineOptions::Options { timestamp: Some(100), blocks: Some(100) } ) } _ => unreachable!(), @@ -1329,7 +1327,7 @@ mod tests { EthRequest::EvmMineDetailed(params) => { assert_eq!( params.unwrap().params.unwrap_or_default(), - EvmMineOptions::Options { timestamp: Some(100), blocks: Some(100) } + MineOptions::Options { timestamp: Some(100), blocks: Some(100) } ) } _ => unreachable!(), @@ -1360,7 +1358,7 @@ mod tests { EthRequest::EvmMine(params) => { assert_eq!( params.unwrap().params.unwrap_or_default(), - EvmMineOptions::Timestamp(Some(1672937224)) + MineOptions::Timestamp(Some(1672937224)) ) } _ => unreachable!(), @@ -1373,7 +1371,7 @@ mod tests { EthRequest::EvmMine(params) => { assert_eq!( params.unwrap().params.unwrap_or_default(), - EvmMineOptions::Options { timestamp: Some(1672937224), blocks: None } + MineOptions::Options { timestamp: Some(1672937224), blocks: None } ) } _ => unreachable!(), diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 79a6c7a2c4d52..348686abc4ad7 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -1,77 +1,7 @@ -use alloy_primitives::{TxHash, B256, U256, U64}; -use revm::primitives::SpecId; -use std::collections::BTreeMap; +use alloy_primitives::{B256, U256}; #[cfg(feature = "serde")] -use serde::{de::Error, Deserializer, Serializer}; - -/// Represents the params to set forking which can take various forms -/// - untagged -/// - tagged `forking` -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct Forking { - pub json_rpc_url: Option, - pub block_number: Option, -} - -#[cfg(feature = "serde")] -impl<'de> serde::Deserialize<'de> for Forking { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - #[derive(serde::Deserialize)] - #[serde(rename_all = "camelCase")] - struct ForkOpts { - pub json_rpc_url: Option, - #[serde(default, with = "alloy_serde::num::u64_opt_via_ruint")] - pub block_number: Option, - } - - #[derive(serde::Deserialize)] - struct Tagged { - forking: ForkOpts, - } - #[derive(serde::Deserialize)] - #[serde(untagged)] - enum ForkingVariants { - Tagged(Tagged), - Fork(ForkOpts), - } - let f = match ForkingVariants::deserialize(deserializer)? { - ForkingVariants::Fork(ForkOpts { json_rpc_url, block_number }) => { - Self { json_rpc_url, block_number } - } - ForkingVariants::Tagged(f) => { - Self { json_rpc_url: f.forking.json_rpc_url, block_number: f.forking.block_number } - } - }; - Ok(f) - } -} - -/// Additional `evm_mine` options -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(untagged))] -pub enum EvmMineOptions { - Options { - #[cfg_attr(feature = "serde", serde(with = "alloy_serde::num::u64_opt_via_ruint"))] - timestamp: Option, - // If `blocks` is given, it will mine exactly blocks number of blocks, regardless of any - // other blocks mined or reverted during it's operation - blocks: Option, - }, - /// The timestamp the block should be mined with - #[cfg_attr(feature = "serde", serde(with = "alloy_serde::num::u64_opt_via_ruint"))] - Timestamp(Option), -} - -impl Default for EvmMineOptions { - fn default() -> Self { - Self::Options { timestamp: None, blocks: None } - } -} +use serde::Serializer; /// Represents the result of `eth_getWork` /// This may or may not include the block number @@ -96,145 +26,3 @@ impl serde::Serialize for Work { } } } - -/// A hex encoded or decimal index -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub struct Index(usize); - -impl From for usize { - fn from(idx: Index) -> Self { - idx.0 - } -} - -#[cfg(feature = "serde")] -impl<'a> serde::Deserialize<'a> for Index { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'a>, - { - use std::fmt; - - struct IndexVisitor; - - impl<'a> serde::de::Visitor<'a> for IndexVisitor { - type Value = Index; - - fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(formatter, "hex-encoded or decimal index") - } - - fn visit_u64(self, value: u64) -> Result - where - E: Error, - { - Ok(Index(value as usize)) - } - - fn visit_str(self, value: &str) -> Result - where - E: Error, - { - if let Some(val) = value.strip_prefix("0x") { - usize::from_str_radix(val, 16).map(Index).map_err(|e| { - Error::custom(format!("Failed to parse hex encoded index value: {e}")) - }) - } else { - value - .parse::() - .map(Index) - .map_err(|e| Error::custom(format!("Failed to parse numeric index: {e}"))) - } - } - - fn visit_string(self, value: String) -> Result - where - E: Error, - { - self.visit_str(value.as_ref()) - } - } - - deserializer.deserialize_any(IndexVisitor) - } -} - -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct NodeInfo { - pub current_block_number: U64, - pub current_block_timestamp: u64, - pub current_block_hash: B256, - pub hard_fork: SpecId, - pub transaction_order: String, - pub environment: NodeEnvironment, - pub fork_config: NodeForkConfig, -} - -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct NodeEnvironment { - pub base_fee: u128, - pub chain_id: u64, - pub gas_limit: u128, - pub gas_price: u128, -} - -#[derive(Clone, Debug, Default, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct NodeForkConfig { - pub fork_url: Option, - pub fork_block_number: Option, - pub fork_retry_backoff: Option, -} - -/// Anvil equivalent of `hardhat_metadata`. -/// Metadata about the current Anvil instance. -/// See -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct AnvilMetadata { - pub client_version: &'static str, - pub chain_id: u64, - pub instance_id: B256, - pub latest_block_number: u64, - pub latest_block_hash: B256, - pub forked_network: Option, - pub snapshots: BTreeMap, -} - -/// Information about the forked network. -/// See -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -pub struct ForkedNetwork { - pub chain_id: u64, - pub fork_block_number: u64, - pub fork_block_hash: TxHash, -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn serde_forking() { - let s = r#"{"forking": {"jsonRpcUrl": "https://ethereumpublicnode.com", - "blockNumber": "18441649" - } - }"#; - let f: Forking = serde_json::from_str(s).unwrap(); - assert_eq!( - f, - Forking { - json_rpc_url: Some("https://ethereumpublicnode.com".into()), - block_number: Some(18441649) - } - ); - } -} diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index e28a8c4621f4e..d147db76f34c3 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -37,17 +37,20 @@ use alloy_eips::eip2718::Encodable2718; use alloy_network::eip2718::Decodable2718; use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, B64, U256, U64}; use alloy_rpc_types::{ + anvil::{ + ForkedNetwork, Forking, Metadata, MineOptions, NodeEnvironment, NodeForkConfig, NodeInfo, + }, request::TransactionRequest, state::StateOverride, + trace::{ + geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace, + }, txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, AccessList, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, - BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Log, + BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Index, Log, Transaction, }; -use alloy_rpc_types_trace::{ - geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, - parity::LocalizedTransactionTrace, -}; use alloy_serde::WithOtherFields; use alloy_transport::TransportErrorKind; use anvil_core::{ @@ -59,10 +62,7 @@ use anvil_core::{ }, EthRequest, }, - types::{ - AnvilMetadata, EvmMineOptions, ForkedNetwork, Forking, Index, NodeEnvironment, - NodeForkConfig, NodeInfo, Work, - }, + types::Work, }; use anvil_rpc::{error::RpcError, response::ResponseResult}; use foundry_common::provider::ProviderBuilder; @@ -1812,21 +1812,22 @@ impl EthApi { let env = self.backend.env().read(); let fork_config = self.backend.get_fork(); let tx_order = self.transaction_order.read(); + let hard_fork: &str = env.handler_cfg.spec_id.into(); Ok(NodeInfo { - current_block_number: U64::from(self.backend.best_number()), + current_block_number: self.backend.best_number(), current_block_timestamp: env.block.timestamp.try_into().unwrap_or(u64::MAX), current_block_hash: self.backend.best_hash(), - hard_fork: env.handler_cfg.spec_id, + hard_fork: hard_fork.to_string(), transaction_order: match *tx_order { TransactionOrder::Fifo => "fifo".to_string(), TransactionOrder::Fees => "fees".to_string(), }, environment: NodeEnvironment { - base_fee: self.backend.base_fee(), + base_fee: U256::from(self.backend.base_fee()), chain_id: self.backend.chain_id().to::(), - gas_limit: self.backend.gas_limit(), - gas_price: self.gas_price(), + gas_limit: U256::from(self.backend.gas_limit()), + gas_price: U256::from(self.gas_price()), }, fork_config: fork_config .map(|fork| { @@ -1845,13 +1846,13 @@ impl EthApi { /// Retrieves metadata about the Anvil instance. /// /// Handler for RPC call: `anvil_metadata` - pub async fn anvil_metadata(&self) -> Result { + pub async fn anvil_metadata(&self) -> Result { node_info!("anvil_metadata"); let fork_config = self.backend.get_fork(); let snapshots = self.backend.list_snapshots(); - Ok(AnvilMetadata { - client_version: CLIENT_VERSION, + Ok(Metadata { + client_version: CLIENT_VERSION.to_string(), chain_id: self.backend.chain_id().to::(), latest_block_hash: self.backend.best_hash(), latest_block_number: self.backend.best_number(), @@ -1950,7 +1951,7 @@ impl EthApi { /// /// This will mine the blocks regardless of the configured mining mode. /// **Note**: ganache returns `0x0` here as placeholder for additional meta-data in the future. - pub async fn evm_mine(&self, opts: Option) -> Result { + pub async fn evm_mine(&self, opts: Option) -> Result { node_info!("evm_mine"); self.do_evm_mine(opts).await?; @@ -1967,7 +1968,7 @@ impl EthApi { /// **Note**: This behaves exactly as [Self::evm_mine] but returns different output, for /// compatibility reasons, this is a separate call since `evm_mine` is not an anvil original. /// and `ganache` may change the `0x0` placeholder. - pub async fn evm_mine_detailed(&self, opts: Option) -> Result> { + pub async fn evm_mine_detailed(&self, opts: Option) -> Result> { node_info!("evm_mine_detailed"); let mined_blocks = self.do_evm_mine(opts).await?; @@ -2203,13 +2204,13 @@ impl EthApi { } /// Executes the `evm_mine` and returns the number of blocks mined - async fn do_evm_mine(&self, opts: Option) -> Result { + async fn do_evm_mine(&self, opts: Option) -> Result { let mut blocks_to_mine = 1u64; if let Some(opts) = opts { let timestamp = match opts { - EvmMineOptions::Timestamp(timestamp) => timestamp, - EvmMineOptions::Options { timestamp, blocks } => { + MineOptions::Timestamp(timestamp) => timestamp, + MineOptions::Options { timestamp, blocks } => { if let Some(blocks) = blocks { blocks_to_mine = blocks; } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 25e001da0e214..21c89302ea68d 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -7,13 +7,13 @@ use alloy_provider::{ Provider, }; use alloy_rpc_types::{ - request::TransactionRequest, AccessListWithGasUsed, Block, BlockId, - BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, - Filter, Log, Transaction, -}; -use alloy_rpc_types_trace::{ - geth::{GethDebugTracingOptions, GethTrace}, - parity::LocalizedTransactionTrace as Trace, + request::TransactionRequest, + trace::{ + geth::{GethDebugTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace as Trace, + }, + AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + EIP1186AccountProofResponse, FeeHistory, Filter, Log, Transaction, }; use alloy_serde::WithOtherFields; use alloy_transport::TransportError; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index bb3de1b091a53..ec676276868f1 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -36,27 +36,27 @@ use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK; use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256, U64}; use alloy_rpc_types::{ - request::TransactionRequest, serde_helpers::JsonStorageKey, state::StateOverride, AccessList, - Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, + anvil::Forking, + request::TransactionRequest, + serde_helpers::JsonStorageKey, + state::StateOverride, + trace::{ + geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, + parity::LocalizedTransactionTrace, + }, + AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, - FilteredParams, Header as AlloyHeader, Log, Transaction, TransactionReceipt, -}; -use alloy_rpc_types_trace::{ - geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, - parity::LocalizedTransactionTrace, + FilteredParams, Header as AlloyHeader, Index, Log, Transaction, TransactionReceipt, }; use alloy_serde::WithOtherFields; use alloy_trie::{proof::ProofRetainer, HashBuilder, Nibbles}; -use anvil_core::{ - eth::{ - block::{Block, BlockInfo}, - transaction::{ - DepositReceipt, MaybeImpersonatedTransaction, PendingTransaction, ReceiptResponse, - TransactionInfo, TypedReceipt, TypedTransaction, - }, - utils::meets_eip155, +use anvil_core::eth::{ + block::{Block, BlockInfo}, + transaction::{ + DepositReceipt, MaybeImpersonatedTransaction, PendingTransaction, ReceiptResponse, + TransactionInfo, TypedReceipt, TypedTransaction, }, - types::{Forking, Index}, + utils::meets_eip155, }; use anvil_rpc::error::RpcError; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 3531057ad1001..308463d6dface 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -7,10 +7,12 @@ use crate::eth::{ pool::transactions::PoolTransaction, }; use alloy_primitives::{Bytes, TxHash, B256, U256, U64}; -use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionInfo as RethTransactionInfo}; -use alloy_rpc_types_trace::{ - geth::{DefaultFrame, GethDefaultTracingOptions}, - parity::LocalizedTransactionTrace, +use alloy_rpc_types::{ + trace::{ + geth::{DefaultFrame, GethDefaultTracingOptions}, + parity::LocalizedTransactionTrace, + }, + BlockId, BlockNumberOrTag, TransactionInfo as RethTransactionInfo, }; use anvil_core::eth::{ block::{Block, PartialHeader}, diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index a830855d423d6..10b77377026ba 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -8,8 +8,10 @@ use crate::eth::{ EthApi, }; use alloy_primitives::{Address, Bytes, B256, U256}; -use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag as BlockNumber}; -use alloy_rpc_types_trace::parity::{Action, CreateAction, CreateOutput, TraceOutput}; +use alloy_rpc_types::{ + trace::parity::{Action, CreateAction, CreateOutput, TraceOutput}, + Block, BlockId, BlockNumberOrTag as BlockNumber, +}; use itertools::Itertools; impl EthApi { diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 048e264a3233e..5e104e6036c00 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -3,10 +3,12 @@ use crate::eth::{ error::{BlockchainError, Result}, }; use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256}; -use alloy_rpc_types::{Block, BlockTransactions, Transaction}; -use alloy_rpc_types_trace::parity::{ - Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, - RewardAction, TraceOutput, +use alloy_rpc_types::{ + trace::parity::{ + Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, + RewardAction, TraceOutput, + }, + Block, BlockTransactions, Transaction, }; use alloy_serde::WithOtherFields; use anvil_core::eth::transaction::ReceiptResponse; diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index d2ceb0dcaf44b..8cf13e844927c 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -6,9 +6,8 @@ use crate::{shutdown::Shutdown, tasks::block_listener::BlockListener, EthApi}; use alloy_network::AnyNetwork; use alloy_primitives::B256; use alloy_provider::Provider; -use alloy_rpc_types::Block; +use alloy_rpc_types::{anvil::Forking, Block}; use alloy_transport::Transport; -use anvil_core::types::Forking; use futures::StreamExt; use std::{fmt, future::Future}; use tokio::{runtime::Handle, task::JoinHandle}; diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index d83365eacf840..359c0f39ce096 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -6,15 +6,15 @@ use crate::{ utils::http_provider_with_signer, }; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{address, fixed_bytes, Address, U256, U64}; +use alloy_primitives::{address, fixed_bytes, Address, U256}; use alloy_provider::{ext::TxPoolApi, Provider}; -use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionRequest}; +use alloy_rpc_types::{ + anvil::{ForkedNetwork, Forking, Metadata, NodeEnvironment, NodeForkConfig, NodeInfo}, + BlockId, BlockNumberOrTag, TransactionRequest, +}; use alloy_serde::WithOtherFields; use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; -use anvil_core::{ - eth::EthRequest, - types::{AnvilMetadata, ForkedNetwork, Forking, NodeEnvironment, NodeForkConfig, NodeInfo}, -}; +use anvil_core::eth::EthRequest; use foundry_evm::revm::primitives::SpecId; use std::{ str::FromStr, @@ -434,12 +434,13 @@ async fn can_get_node_info() { let block_number = provider.get_block_number().await.unwrap(); let block = provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); + let hard_fork: &str = SpecId::CANCUN.into(); let expected_node_info = NodeInfo { - current_block_number: U64::from(0), + current_block_number: 0_u64, current_block_timestamp: 1, current_block_hash: block.header.hash.unwrap(), - hard_fork: SpecId::CANCUN, + hard_fork: hard_fork.to_string(), transaction_order: "fees".to_owned(), environment: NodeEnvironment { base_fee: U256::from_str("0x3b9aca00").unwrap().to(), @@ -470,11 +471,11 @@ async fn can_get_metadata() { let block = provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); - let expected_metadata = AnvilMetadata { + let expected_metadata = Metadata { latest_block_hash: block.header.hash.unwrap(), latest_block_number: block_number, chain_id, - client_version: CLIENT_VERSION, + client_version: CLIENT_VERSION.to_string(), instance_id: api.instance_id(), forked_network: None, snapshots: Default::default(), @@ -496,11 +497,11 @@ async fn can_get_metadata_on_fork() { let block = provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); - let expected_metadata = AnvilMetadata { + let expected_metadata = Metadata { latest_block_hash: block.header.hash.unwrap(), latest_block_number: block_number, chain_id, - client_version: CLIENT_VERSION, + client_version: CLIENT_VERSION.to_string(), instance_id: api.instance_id(), forked_network: Some(ForkedNetwork { chain_id, diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 83c235f5c5753..a94dc4c4dfcfe 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -8,13 +8,13 @@ use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{address, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ + anvil::Forking, request::{TransactionInput, TransactionRequest}, BlockId, BlockNumberOrTag, }; use alloy_serde::WithOtherFields; use alloy_signer_local::PrivateKeySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; -use anvil_core::types::Forking; use foundry_common::provider::get_http_provider; use foundry_config::Config; use foundry_test_utils::rpc::{self, next_http_rpc_endpoint}; diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 1c492730068e0..ae75c261a8f1c 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -5,10 +5,12 @@ use alloy_provider::{ ext::{DebugApi, TraceApi}, Provider, }; -use alloy_rpc_types::{BlockNumberOrTag, TransactionRequest}; -use alloy_rpc_types_trace::{ - geth::{GethDebugTracingCallOptions, GethTrace}, - parity::{Action, LocalizedTransactionTrace}, +use alloy_rpc_types::{ + trace::{ + geth::{GethDebugTracingCallOptions, GethTrace}, + parity::{Action, LocalizedTransactionTrace}, + }, + BlockNumberOrTag, TransactionRequest, }; use alloy_serde::WithOtherFields; use alloy_sol_types::sol; diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index afc8aa237d728..f50435610ae65 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -32,8 +32,7 @@ alloy-primitives = { workspace = true, features = [ alloy-provider.workspace = true alloy-pubsub.workspace = true alloy-rpc-client.workspace = true -alloy-rpc-types = { workspace = true, features = ["eth"] } -alloy-rpc-types-engine.workspace = true +alloy-rpc-types = { workspace = true, features = ["eth", "engine"] } alloy-serde.workspace = true alloy-sol-types.workspace = true alloy-transport-http = { workspace = true, features = [ diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 72c4dadc9aba7..8ca90ca80a36c 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -4,7 +4,7 @@ use crate::REQUEST_TIMEOUT; use alloy_json_rpc::{RequestPacket, ResponsePacket}; use alloy_pubsub::{PubSubConnect, PubSubFrontend}; -use alloy_rpc_types_engine::{Claims, JwtSecret}; +use alloy_rpc_types::engine::{Claims, JwtSecret}; use alloy_transport::{ Authorization, BoxTransport, TransportError, TransportErrorKind, TransportFut, }; From d3d73ba8223ebf2294f7b4beefb37bf1718a069a Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:54:26 +0530 Subject: [PATCH 1115/1963] fix(verify-bytecode): use strong equality `==`, not `.starts_with` (#8200) --- crates/verify/src/bytecode.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 44b1f55425194..cc7a733995e70 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -567,7 +567,7 @@ fn try_match( has_metadata: bool, ) -> Result<(bool, Option)> { // 1. Try full match - if *match_type == VerificationType::Full && local_bytecode.starts_with(bytecode) { + if *match_type == VerificationType::Full && local_bytecode == bytecode { Ok((true, Some(VerificationType::Full))) } else { try_partial_match(local_bytecode, bytecode, constructor_args, is_runtime, has_metadata) @@ -591,7 +591,7 @@ fn try_partial_match( } // Now compare the creation code and bytecode - return Ok(local_bytecode.starts_with(bytecode)); + return Ok(local_bytecode == bytecode); } if is_runtime { @@ -601,7 +601,7 @@ fn try_partial_match( } // Now compare the local code and bytecode - return Ok(local_bytecode.starts_with(bytecode)); + return Ok(local_bytecode == bytecode); } // If not runtime, extract constructor args from the end of the bytecode @@ -613,7 +613,7 @@ fn try_partial_match( bytecode = extract_metadata_hash(bytecode)?; } - Ok(local_bytecode.starts_with(bytecode)) + Ok(local_bytecode == bytecode) } /// @dev This assumes that the metadata is at the end of the bytecode From 3df7d8a0140c2120ee974531fee4eed153dc33ee Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 19 Jun 2024 16:24:36 +0300 Subject: [PATCH 1116/1963] fix: `--isolate` fixes and daily CI job (#8194) * feat: add daily CI job for `--isolate` feature * fix tests * wip * fix tests * wip * wip * fix * update group name for nextest --- .github/scripts/matrices.py | 4 + .github/workflows/nextest.yml | 96 +++++++++++++++++++ .github/workflows/test-isolate.yml | 14 +++ .github/workflows/test.yml | 80 +--------------- crates/cast/Cargo.toml | 1 + crates/config/Cargo.toml | 1 + crates/config/src/lib.rs | 3 + crates/evm/core/src/utils.rs | 10 +- crates/evm/evm/src/inspectors/stack.rs | 10 +- crates/forge/Cargo.toml | 1 + crates/forge/tests/cli/ext_integration.rs | 33 +++++-- crates/forge/tests/cli/test_cmd.rs | 2 + crates/forge/tests/it/cheats.rs | 4 + .../common/InvariantReentrancy.t.sol | 2 +- 14 files changed, 167 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/nextest.yml create mode 100644 .github/workflows/test-isolate.yml diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index a71ff368391ac..51fc69123cdfc 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -65,6 +65,7 @@ def __init__( self.partition = partition +profile = os.environ.get("PROFILE") is_pr = os.environ.get("EVENT_NAME") == "pull_request" t_linux_x86 = Target("ubuntu-latest", "x86_64-unknown-linux-gnu", "linux-amd64") # TODO: Figure out how to make this work @@ -119,6 +120,9 @@ def main(): s = f"{partition}/{case.n_partitions}" name += f" ({s})" flags += f" --partition count:{s}" + + if profile == "isolate": + flags += " --features=isolate-by-default" name += os_str obj = Expanded( diff --git a/.github/workflows/nextest.yml b/.github/workflows/nextest.yml new file mode 100644 index 0000000000000..631dab90f82c3 --- /dev/null +++ b/.github/workflows/nextest.yml @@ -0,0 +1,96 @@ +# Reusable workflow for running tests via `cargo nextest` + +name: nextest + +on: + workflow_call: + inputs: + profile: + required: true + type: string + +concurrency: + group: tests-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + matrices: + name: build matrices + runs-on: ubuntu-latest + outputs: + test-matrix: ${{ steps.gen.outputs.test-matrix }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Generate matrices + id: gen + env: + EVENT_NAME: ${{ github.event_name }} + PROFILE: ${{ inputs.profile }} + run: | + output=$(python3 .github/scripts/matrices.py) + echo "::debug::test-matrix=$output" + echo "test-matrix=$output" >> $GITHUB_OUTPUT + + test: + name: test ${{ matrix.name }} + runs-on: ${{ matrix.runner_label }} + timeout-minutes: 60 + needs: matrices + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} + env: + ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD + CARGO_PROFILE_DEV_DEBUG: 0 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + target: ${{ matrix.target }} + - uses: taiki-e/install-action@nextest + + # External tests dependencies + - name: Setup Node.js + if: contains(matrix.name, 'external') + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install Bun + if: contains(matrix.name, 'external') && !contains(matrix.runner_label, 'windows') + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Setup Python + if: contains(matrix.name, 'external') + uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: Install Vyper + if: contains(matrix.name, 'external') + run: pip install vyper + + - name: Forge RPC cache + uses: actions/cache@v3 + with: + path: | + ~/.foundry/cache + ~/.config/.foundry/cache + key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Setup Git config + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "<>" + git config --global url."https://github.com/".insteadOf "git@github.com:" + - name: Test + env: + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + run: cargo nextest run ${{ matrix.flags }} \ No newline at end of file diff --git a/.github/workflows/test-isolate.yml b/.github/workflows/test-isolate.yml new file mode 100644 index 0000000000000..119a6bd55adec --- /dev/null +++ b/.github/workflows/test-isolate.yml @@ -0,0 +1,14 @@ +# Daily CI job to run tests with isolation mode enabled by default + +name: test-isolate + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + nextest: + uses: ./.github/workflows/nextest.yml + with: + profile: isolate diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01dbc675e69d1..bca1804ceb016 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,82 +14,10 @@ env: CARGO_TERM_COLOR: always jobs: - matrices: - name: build matrices - runs-on: ubuntu-latest - outputs: - test-matrix: ${{ steps.gen.outputs.test-matrix }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - name: Generate matrices - id: gen - env: - EVENT_NAME: ${{ github.event_name }} - run: | - output=$(python3 .github/scripts/matrices.py) - echo "::debug::test-matrix=$output" - echo "test-matrix=$output" >> $GITHUB_OUTPUT - - test: - name: test ${{ matrix.name }} - runs-on: ${{ matrix.runner_label }} - timeout-minutes: 60 - needs: matrices - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - CARGO_PROFILE_DEV_DEBUG: 0 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - target: ${{ matrix.target }} - - uses: taiki-e/install-action@nextest - - # External tests dependencies - - name: Setup Node.js - if: contains(matrix.name, 'external') - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Install Bun - if: contains(matrix.name, 'external') && !contains(matrix.runner_label, 'windows') - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - name: Setup Python - if: contains(matrix.name, 'external') - uses: actions/setup-python@v4 - with: - python-version: 3.11 - - name: Install Vyper - if: contains(matrix.name, 'external') - run: pip install vyper - - - name: Forge RPC cache - uses: actions/cache@v3 - with: - path: | - ~/.foundry/cache - ~/.config/.foundry/cache - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Setup Git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - git config --global url."https://github.com/".insteadOf "git@github.com:" - - name: Test - env: - SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} - run: cargo nextest run ${{ matrix.flags }} + nextest: + uses: ./.github/workflows/nextest.yml + with: + profile: default docs: runs-on: ubuntu-latest diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 525c2c3f7cd18..df69f21f22249 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -97,6 +97,7 @@ openssl = ["foundry-cli/openssl"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] aws-kms = ["foundry-wallets/aws-kms", "dep:aws-sdk-kms"] +isolate-by-default = ["foundry-config/isolate-by-default"] [[bench]] name = "vanity" diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 445d80940b7a4..81066206ab354 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -52,3 +52,4 @@ tempfile.workspace = true [features] default = ["rustls"] rustls = ["reqwest/rustls-tls-native-roots"] +isolate-by-default = [] diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index e9396e3a4ca1e..05e7462918956 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2024,7 +2024,10 @@ impl Default for Config { profile: Self::DEFAULT_PROFILE, fs_permissions: FsPermissions::new([PathPermission::read("out")]), prague: false, + #[cfg(not(feature = "isolate-by-default"))] isolate: false, + #[cfg(feature = "isolate-by-default")] + isolate: true, root: Default::default(), src: "src".into(), test: "test".into(), diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index d8114f209e81e..c09e8538bf86a 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -156,11 +156,6 @@ pub fn create2_handler_register>( .borrow_mut() .push((ctx.evm.journaled_state.depth(), call_inputs.clone())); - // Handle potential inspector override. - if let Some(outcome) = outcome { - return Ok(FrameOrResult::Result(FrameResult::Call(outcome))); - } - // Sanity check that CREATE2 deployer exists. let code_hash = ctx.evm.load_account(DEFAULT_CREATE2_DEPLOYER)?.0.info.code_hash; if code_hash == KECCAK_EMPTY { @@ -174,6 +169,11 @@ pub fn create2_handler_register>( }))) } + // Handle potential inspector override. + if let Some(outcome) = outcome { + return Ok(FrameOrResult::Result(FrameResult::Call(outcome))); + } + // Create CALL frame for CREATE2 factory invocation. let mut frame_or_result = ctx.evm.make_call_frame(&call_inputs); diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index c8497d93c896c..1858e91a7e7ed 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -16,7 +16,9 @@ use revm::{ CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, }, - primitives::{BlockEnv, Env, EnvWithHandlerCfg, ExecutionResult, Output, TransactTo}, + primitives::{ + BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, Output, TransactTo, + }, DatabaseCommit, EvmContext, Inspector, }; use std::{collections::HashMap, sync::Arc}; @@ -749,7 +751,11 @@ impl Inspector<&mut DB> for InspectorStack { ecx ); - if self.enable_isolation && !self.in_inner_context && ecx.journaled_state.depth == 1 { + if !matches!(create.scheme, CreateScheme::Create2 { .. }) && + self.enable_isolation && + !self.in_inner_context && + ecx.journaled_state.depth == 1 + { let (result, address) = self.transact_inner( ecx, TransactTo::Create, diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 23a4f22a62b88..29fd64ef4d6dc 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -139,6 +139,7 @@ openssl = ["foundry-cli/openssl", "reqwest/default-tls"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] aws-kms = ["foundry-wallets/aws-kms"] +isolate-by-default = ["foundry-config/isolate-by-default"] [[bench]] name = "test" diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 889000ad52f4f..2930b6b8ead2f 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -10,7 +10,13 @@ fn forge_std() { #[test] fn solmate() { - ExtTester::new("transmissions11", "solmate", "c892309933b25c03d32b1b0d674df7ae292ba925").run(); + let tester = + ExtTester::new("transmissions11", "solmate", "c892309933b25c03d32b1b0d674df7ae292ba925"); + + #[cfg(feature = "isolate-by-default")] + let tester = tester.args(["--nmc", "ReentrancyGuardTest"]); + + tester.run(); } #[test] @@ -36,15 +42,22 @@ fn prb_proxy() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn sablier_v2() { - ExtTester::new("sablier-labs", "v2-core", "84758a40077bf3ccb1c8f7bb8d00278e672fbfef") - // Skip fork tests. - .args(["--nmc", "Fork"]) - // Run tests without optimizations. - .env("FOUNDRY_PROFILE", "lite") - .install_command(&["bun", "install", "--prefer-offline"]) - // Try npm if bun fails / is not installed. - .install_command(&["npm", "install", "--prefer-offline"]) - .run(); + let tester = + ExtTester::new("sablier-labs", "v2-core", "84758a40077bf3ccb1c8f7bb8d00278e672fbfef") + // Skip fork tests. + .args(["--nmc", "Fork"]) + // Run tests without optimizations. + .env("FOUNDRY_PROFILE", "lite") + .install_command(&["bun", "install", "--prefer-offline"]) + // Try npm if bun fails / is not installed. + .install_command(&["npm", "install", "--prefer-offline"]); + + // This test reverts due to memory limit without isolation. This revert is not reached with + // isolation because memory is divided between separate EVMs created by inner calls. + #[cfg(feature = "isolate-by-default")] + let tester = tester.args(["--nmt", "test_RevertWhen_LoopCalculationOverflowsBlockGasLimit"]); + + tester.run(); } #[test] diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 0e4f24138b1fb..92d284720b4b7 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -209,6 +209,7 @@ contract MyTest is DSTest { }); // checks that forge test repeatedly produces the same output +#[cfg(not(feature = "isolate-by-default"))] forgetest_init!(can_test_repeatedly, |_prj, cmd| { cmd.arg("test"); cmd.assert_non_empty_stdout(); @@ -264,6 +265,7 @@ contract ContractTest is DSTest { }); // tests that libraries are handled correctly in multiforking mode +#[cfg(not(feature = "isolate-by-default"))] forgetest_init!(can_use_libs_in_multi_fork, |prj, cmd| { prj.wipe_contracts(); diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 47d6ebbb9ec5b..2bbbee90289cd 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -21,6 +21,10 @@ async fn test_cheats_local(test_data: &ForgeTestData) { filter = filter.exclude_tests("(Ffi|File|Line|Root)"); } + if cfg!(feature = "isolate-by-default") { + filter = filter.exclude_contracts("LastCallGasDefaultTest"); + } + let mut config = test_data.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); let runner = test_data.runner_with_config(config); diff --git a/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol b/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol index 06b4b21d761ff..f439b8ce1e485 100644 --- a/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol @@ -7,7 +7,7 @@ contract Malicious { function world() public { // add code so contract is accounted as valid sender // see https://github.com/foundry-rs/foundry/issues/4245 - payable(msg.sender).transfer(1); + payable(msg.sender).call(""); } } From bd5582b923d272dcc930e25f47947090f5e7d74e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:02:57 +0200 Subject: [PATCH 1117/1963] perf(cheatcodes): outline cold paths in inspector step (#8197) --- crates/cheatcodes/src/evm.rs | 15 + crates/cheatcodes/src/evm/mapping.rs | 2 +- crates/cheatcodes/src/evm/mock.rs | 3 +- crates/cheatcodes/src/inspector.rs | 916 ++++++++++++++------------- 4 files changed, 476 insertions(+), 460 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index e652bf28475a1..50265b4b12e0d 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -32,6 +32,21 @@ pub struct RecordAccess { pub writes: HashMap>, } +impl RecordAccess { + /// Records a read access to a storage slot. + pub fn record_read(&mut self, target: Address, slot: U256) { + self.reads.entry(target).or_default().push(slot); + } + + /// Records a write access to a storage slot. + /// + /// This also records a read internally as `SSTORE` does an implicit `SLOAD`. + pub fn record_write(&mut self, target: Address, slot: U256) { + self.record_read(target, slot); + self.writes.entry(target).or_default().push(slot); + } +} + /// Records `deal` cheatcodes #[derive(Clone, Debug)] pub struct DealRecord { diff --git a/crates/cheatcodes/src/evm/mapping.rs b/crates/cheatcodes/src/evm/mapping.rs index b506d2058fc3b..679609274ed6d 100644 --- a/crates/cheatcodes/src/evm/mapping.rs +++ b/crates/cheatcodes/src/evm/mapping.rs @@ -112,7 +112,7 @@ fn slot_child<'a>( mapping_slot(state, target)?.children.get(slot) } -#[inline] +#[cold] pub(crate) fn step(mapping_slots: &mut HashMap, interpreter: &Interpreter) { match interpreter.current_opcode() { opcode::KECCAK256 => { diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index b2c46f116f4b6..becf86f178f54 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -49,8 +49,7 @@ impl Cheatcode for clearMockedCallsCall { impl Cheatcode for mockCall_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; - // TODO: use ecx.load_account - let (acc, _) = ccx.ecx.journaled_state.load_account(*callee, &mut ccx.ecx.db)?; + let (acc, _) = ccx.ecx.load_account(*callee)?; // Etches a single byte onto the account if it is empty to circumvent the `extcodesize` // check Solidity might perform. diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index d7cfc3c5ece28..e719ffe837792 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -46,7 +46,7 @@ use std::{ sync::Arc, }; -macro_rules! try_or_continue { +macro_rules! try_or_return { ($e:expr) => { match $e { Ok(v) => v, @@ -254,6 +254,7 @@ impl Cheatcodes { self.config.script_wallets.as_ref() } + /// Decodes the input data and applies the cheatcode. fn apply_cheatcode( &mut self, ecx: &mut EvmContext, @@ -271,6 +272,7 @@ impl Cheatcodes { } e })?; + let caller = call.caller; // ensure the caller is allowed to execute cheatcodes, @@ -288,11 +290,12 @@ impl Cheatcodes { ) } - /// Determines the address of the contract and marks it as allowed - /// Returns the address of the contract created + /// Determines the address of the contract and marks it as allowed. + /// + /// Returns the address of the contract created. /// /// There may be cheatcodes in the constructor of the new contract, in order to allow them - /// automatically we need to determine the new address + /// automatically we need to determine the new address. fn allow_cheatcodes_on_create( &self, ecx: &mut InnerEvmContext, @@ -347,7 +350,7 @@ impl Cheatcodes { impl Inspector for Cheatcodes { #[inline] - fn initialize_interp(&mut self, _: &mut Interpreter, ecx: &mut EvmContext) { + fn initialize_interp(&mut self, _interpreter: &mut Interpreter, ecx: &mut EvmContext) { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. if let Some(block) = self.block.take() { @@ -358,424 +361,31 @@ impl Inspector for Cheatcodes { } } + #[inline] fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { - let ecx = &mut ecx.inner; self.pc = interpreter.program_counter(); - // reset gas if gas metering is turned off - match self.gas_metering { - Some(None) => { - // need to store gas metering - self.gas_metering = Some(Some(interpreter.gas)); - } - Some(Some(gas)) => { - match interpreter.current_opcode() { - opcode::CREATE | opcode::CREATE2 => { - // set we're about to enter CREATE frame to meter its gas on first opcode - // inside it - self.gas_metering_create = Some(None) - } - opcode::STOP | opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { - // If we are ending current execution frame, we want to just fully reset gas - // otherwise weird things with returning gas from a call happen - // ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/evm_impl.rs#L190 - // - // It would be nice if we had access to the interpreter in `call_end`, as we - // could just do this there instead. - match self.gas_metering_create { - None | Some(None) => { - interpreter.gas = Gas::new(0); - } - Some(Some(gas)) => { - // If this was CREATE frame, set correct gas limit. This is needed - // because CREATE opcodes deduct additional gas for code storage, - // and deducted amount is compared to gas limit. If we set this to - // 0, the CREATE would fail with out of gas. - // - // If we however set gas limit to the limit of outer frame, it would - // cause a panic after erasing gas cost post-create. Reason for this - // is pre-create REVM records `gas_limit - (gas_limit / 64)` as gas - // used, and erases costs by `remaining` gas post-create. - // gas used ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L254-L258 - // post-create erase ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L279 - interpreter.gas = Gas::new(gas.limit()); - - // reset CREATE gas metering because we're about to exit its frame - self.gas_metering_create = None - } - } - } - _ => { - // if just starting with CREATE opcodes, record its inner frame gas - if let Some(None) = self.gas_metering_create { - self.gas_metering_create = Some(Some(interpreter.gas)) - } - - // dont monitor gas changes, keep it constant - interpreter.gas = gas; - } - } - } - _ => {} + // `pauseGasMetering`: reset interpreter gas. + if self.gas_metering.is_some() { + self.meter_gas(interpreter); } - // Record writes and reads if `record` has been called - if let Some(storage_accesses) = &mut self.accesses { - match interpreter.current_opcode() { - opcode::SLOAD => { - let key = try_or_continue!(interpreter.stack().peek(0)); - storage_accesses - .reads - .entry(interpreter.contract().target_address) - .or_default() - .push(key); - } - opcode::SSTORE => { - let key = try_or_continue!(interpreter.stack().peek(0)); - - // An SSTORE does an SLOAD internally - storage_accesses - .reads - .entry(interpreter.contract().target_address) - .or_default() - .push(key); - storage_accesses - .writes - .entry(interpreter.contract().target_address) - .or_default() - .push(key); - } - _ => (), - } + // `record`: record storage reads and writes. + if self.accesses.is_some() { + self.record_accesses(interpreter); } - // Record account access via SELFDESTRUCT if `recordAccountAccesses` has been called - if let Some(account_accesses) = &mut self.recorded_account_diffs_stack { - if interpreter.current_opcode() == opcode::SELFDESTRUCT { - let target = try_or_continue!(interpreter.stack().peek(0)); - // load balance of this account - let value = ecx - .balance(interpreter.contract().target_address) - .map(|(b, _)| b) - .unwrap_or(U256::ZERO); - let account = Address::from_word(B256::from(target)); - // get previous balance and initialized status of the target account - // TODO: use load_account_exists - let (initialized, old_balance) = if let Ok((account, _)) = - ecx.journaled_state.load_account(account, &mut ecx.db) - { - (account.info.exists(), account.info.balance) - } else { - (false, U256::ZERO) - }; - // register access for the target account - let access = crate::Vm::AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: ecx.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(ecx.env.cfg.chain_id), - }, - accessor: interpreter.contract().target_address, - account, - kind: crate::Vm::AccountAccessKind::SelfDestruct, - initialized, - oldBalance: old_balance, - newBalance: old_balance + value, - value, - data: Bytes::new(), - reverted: false, - deployedCode: Bytes::new(), - storageAccesses: vec![], - depth: ecx.journaled_state.depth(), - }; - // Ensure that we're not selfdestructing a context recording was initiated on - if let Some(last) = account_accesses.last_mut() { - last.push(access); - } - } + // `startStateDiffRecording`: record granular ordered storage accesses. + if self.recorded_account_diffs_stack.is_some() { + self.record_state_diffs(interpreter, ecx); } - // Record granular ordered storage accesses if `startStateDiffRecording` has been called - if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { - match interpreter.current_opcode() { - opcode::SLOAD => { - let key = try_or_continue!(interpreter.stack().peek(0)); - let address = interpreter.contract().target_address; - - // Try to include present value for informational purposes, otherwise assume - // it's not set (zero value) - let mut present_value = U256::ZERO; - // Try to load the account and the slot's present value - if ecx.load_account(address).is_ok() { - if let Ok((previous, _)) = ecx.sload(address, key) { - present_value = previous; - } - } - let access = crate::Vm::StorageAccess { - account: interpreter.contract().target_address, - slot: key.into(), - isWrite: false, - previousValue: present_value.into(), - newValue: present_value.into(), - reverted: false, - }; - append_storage_access( - recorded_account_diffs_stack, - access, - ecx.journaled_state.depth(), - ); - } - opcode::SSTORE => { - let key = try_or_continue!(interpreter.stack().peek(0)); - let value = try_or_continue!(interpreter.stack().peek(1)); - let address = interpreter.contract().target_address; - // Try to load the account and the slot's previous value, otherwise, assume it's - // not set (zero value) - let mut previous_value = U256::ZERO; - if ecx.load_account(address).is_ok() { - if let Ok((previous, _)) = ecx.sload(address, key) { - previous_value = previous; - } - } - - let access = crate::Vm::StorageAccess { - account: address, - slot: key.into(), - isWrite: true, - previousValue: previous_value.into(), - newValue: value.into(), - reverted: false, - }; - append_storage_access( - recorded_account_diffs_stack, - access, - ecx.journaled_state.depth(), - ); - } - // Record account accesses via the EXT family of opcodes - opcode::EXTCODECOPY | - opcode::EXTCODESIZE | - opcode::EXTCODEHASH | - opcode::BALANCE => { - let kind = match interpreter.current_opcode() { - opcode::EXTCODECOPY => crate::Vm::AccountAccessKind::Extcodecopy, - opcode::EXTCODESIZE => crate::Vm::AccountAccessKind::Extcodesize, - opcode::EXTCODEHASH => crate::Vm::AccountAccessKind::Extcodehash, - opcode::BALANCE => crate::Vm::AccountAccessKind::Balance, - _ => unreachable!(), - }; - let address = Address::from_word(B256::from(try_or_continue!(interpreter - .stack() - .peek(0)))); - let balance; - let initialized; - // TODO: use ecx.load_account - if let Ok((acc, _)) = ecx.journaled_state.load_account(address, &mut ecx.db) { - initialized = acc.info.exists(); - balance = acc.info.balance; - } else { - initialized = false; - balance = U256::ZERO; - } - let account_access = crate::Vm::AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: ecx.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(ecx.env.cfg.chain_id), - }, - accessor: interpreter.contract().target_address, - account: address, - kind, - initialized, - oldBalance: balance, - newBalance: balance, - value: U256::ZERO, - data: Bytes::new(), - reverted: false, - deployedCode: Bytes::new(), - storageAccesses: vec![], - depth: ecx.journaled_state.depth(), - }; - // Record the EXT* call as an account access at the current depth - // (future storage accesses will be recorded in a new "Resume" context) - if let Some(last) = recorded_account_diffs_stack.last_mut() { - last.push(account_access); - } else { - recorded_account_diffs_stack.push(vec![account_access]); - } - } - _ => (), - } + // `expectSafeMemory`: check if the current opcode is allowed to interact with memory. + if !self.allowed_mem_writes.is_empty() { + self.check_mem_opcodes(interpreter, ecx.journaled_state.depth()); } - // If the allowed memory writes cheatcode is active at this context depth, check to see - // if the current opcode can either mutate directly or expand memory. If the opcode at - // the current program counter is a match, check if the modified memory lies within the - // allowed ranges. If not, revert and fail the test. - if let Some(ranges) = self.allowed_mem_writes.get(&ecx.journaled_state.depth()) { - // The `mem_opcode_match` macro is used to match the current opcode against a list of - // opcodes that can mutate memory (either directly or expansion via reading). If the - // opcode is a match, the memory offsets that are being written to are checked to be - // within the allowed ranges. If not, the test is failed and the transaction is - // reverted. For all opcodes that can mutate memory aside from MSTORE, - // MSTORE8, and MLOAD, the size and destination offset are on the stack, and - // the macro expands all of these cases. For MSTORE, MSTORE8, and MLOAD, the - // size of the memory write is implicit, so these cases are hard-coded. - macro_rules! mem_opcode_match { - ($(($opcode:ident, $offset_depth:expr, $size_depth:expr, $writes:expr)),* $(,)?) => { - match interpreter.current_opcode() { - //////////////////////////////////////////////////////////////// - // OPERATIONS THAT CAN EXPAND/MUTATE MEMORY BY WRITING // - //////////////////////////////////////////////////////////////// - - opcode::MSTORE => { - // The offset of the mstore operation is at the top of the stack. - let offset = try_or_continue!(interpreter.stack().peek(0)).saturating_to::(); - - // If none of the allowed ranges contain [offset, offset + 32), memory has been - // unexpectedly mutated. - if !ranges.iter().any(|range| { - range.contains(&offset) && range.contains(&(offset + 31)) - }) { - // SPECIAL CASE: When the compiler attempts to store the selector for - // `stopExpectSafeMemory`, this is allowed. It will do so at the current free memory - // pointer, which could have been updated to the exclusive upper bound during - // execution. - let value = try_or_continue!(interpreter.stack().peek(1)).to_be_bytes::<32>(); - let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; - if value[0..SELECTOR_LEN] == selector { - return - } - - disallowed_mem_write(offset, 32, interpreter, ranges); - return - } - } - opcode::MSTORE8 => { - // The offset of the mstore8 operation is at the top of the stack. - let offset = try_or_continue!(interpreter.stack().peek(0)).saturating_to::(); - - // If none of the allowed ranges contain the offset, memory has been - // unexpectedly mutated. - if !ranges.iter().any(|range| range.contains(&offset)) { - disallowed_mem_write(offset, 1, interpreter, ranges); - return - } - } - - //////////////////////////////////////////////////////////////// - // OPERATIONS THAT CAN EXPAND MEMORY BY READING // - //////////////////////////////////////////////////////////////// - - opcode::MLOAD => { - // The offset of the mload operation is at the top of the stack - let offset = try_or_continue!(interpreter.stack().peek(0)).saturating_to::(); - - // If the offset being loaded is >= than the memory size, the - // memory is being expanded. If none of the allowed ranges contain - // [offset, offset + 32), memory has been unexpectedly mutated. - if offset >= interpreter.shared_memory.len() as u64 && !ranges.iter().any(|range| { - range.contains(&offset) && range.contains(&(offset + 31)) - }) { - disallowed_mem_write(offset, 32, interpreter, ranges); - return - } - } - - //////////////////////////////////////////////////////////////// - // OPERATIONS WITH OFFSET AND SIZE ON STACK // - //////////////////////////////////////////////////////////////// - - opcode::CALL => { - // The destination offset of the operation is the fifth element on the stack. - let dest_offset = try_or_continue!(interpreter.stack().peek(5)).saturating_to::(); - - // The size of the data that will be copied is the sixth element on the stack. - let size = try_or_continue!(interpreter.stack().peek(6)).saturating_to::(); - - // If none of the allowed ranges contain [dest_offset, dest_offset + size), - // memory outside of the expected ranges has been touched. If the opcode - // only reads from memory, this is okay as long as the memory is not expanded. - let fail_cond = !ranges.iter().any(|range| { - range.contains(&dest_offset) && - range.contains(&(dest_offset + size.saturating_sub(1))) - }); - - // If the failure condition is met, set the output buffer to a revert string - // that gives information about the allowed ranges and revert. - if fail_cond { - // SPECIAL CASE: When a call to `stopExpectSafeMemory` is performed, this is allowed. - // It allocated calldata at the current free memory pointer, and will attempt to read - // from this memory region to perform the call. - let to = Address::from_word(try_or_continue!(interpreter.stack().peek(1)).to_be_bytes::<32>().into()); - if to == CHEATCODE_ADDRESS { - let args_offset = try_or_continue!(interpreter.stack().peek(3)).saturating_to::(); - let args_size = try_or_continue!(interpreter.stack().peek(4)).saturating_to::(); - let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; - let memory_word = interpreter.shared_memory.slice(args_offset, args_size); - if memory_word[0..SELECTOR_LEN] == selector { - return - } - } - - disallowed_mem_write(dest_offset, size, interpreter, ranges); - return - } - } - - $(opcode::$opcode => { - // The destination offset of the operation. - let dest_offset = try_or_continue!(interpreter.stack().peek($offset_depth)).saturating_to::(); - - // The size of the data that will be copied. - let size = try_or_continue!(interpreter.stack().peek($size_depth)).saturating_to::(); - - // If none of the allowed ranges contain [dest_offset, dest_offset + size), - // memory outside of the expected ranges has been touched. If the opcode - // only reads from memory, this is okay as long as the memory is not expanded. - let fail_cond = !ranges.iter().any(|range| { - range.contains(&dest_offset) && - range.contains(&(dest_offset + size.saturating_sub(1))) - }) && ($writes || - [dest_offset, (dest_offset + size).saturating_sub(1)].into_iter().any(|offset| { - offset >= interpreter.shared_memory.len() as u64 - }) - ); - - // If the failure condition is met, set the output buffer to a revert string - // that gives information about the allowed ranges and revert. - if fail_cond { - disallowed_mem_write(dest_offset, size, interpreter, ranges); - return - } - })* - _ => () - } - } - } - - // Check if the current opcode can write to memory, and if so, check if the memory - // being written to is registered as safe to modify. - mem_opcode_match!( - (CALLDATACOPY, 0, 2, true), - (CODECOPY, 0, 2, true), - (RETURNDATACOPY, 0, 2, true), - (EXTCODECOPY, 1, 3, true), - (CALLCODE, 5, 6, true), - (STATICCALL, 4, 5, true), - (DELEGATECALL, 4, 5, true), - (KECCAK256, 0, 1, false), - (LOG0, 0, 1, false), - (LOG1, 0, 1, false), - (LOG2, 0, 1, false), - (LOG3, 0, 1, false), - (LOG4, 0, 1, false), - (CREATE, 1, 2, false), - (CREATE2, 1, 2, false), - (RETURN, 0, 1, false), - (REVERT, 0, 1, false), - ) - } - - // Record writes with sstore (and sha3) if `StartMappingRecording` has been called + // `startMappingRecording`: record SSTORE and KECCAK256. if let Some(mapping_slots) = &mut self.mapping_slots { mapping::step(mapping_slots, interpreter); } @@ -786,7 +396,7 @@ impl Inspector for Cheatcodes { expect::handle_expect_emit(self, log); } - // Stores this log if `recordLogs` has been called + // `recordLogs` if let Some(storage_recorded_logs) = &mut self.recorded_logs { storage_recorded_logs.push(Vm::Log { topics: log.data.topics().to_vec(), @@ -1008,9 +618,7 @@ impl Inspector for Cheatcodes { // nonce, a non-zero KECCAK_EMPTY codehash, or non-empty code let initialized; let old_balance; - // TODO: use ecx.load_account - if let Ok((acc, _)) = ecx.journaled_state.load_account(call.target_address, &mut ecx.db) - { + if let Ok((acc, _)) = ecx.load_account(call.target_address) { initialized = acc.info.exists(); old_balance = acc.info.balance; } else { @@ -1176,10 +784,7 @@ impl Inspector for Cheatcodes { // Depending on the depth the cheat was called at, there may not be any pending // calls to update if execution has percolated up to a higher depth. if call_access.depth == ecx.journaled_state.depth() { - // TODO: use ecx.load_account - if let Ok((acc, _)) = - ecx.journaled_state.load_account(call.target_address, &mut ecx.db) - { + if let Ok((acc, _)) = ecx.load_account(call.target_address) { debug_assert!(access_is_call(call_access.kind)); call_access.newBalance = acc.info.balance; } @@ -1574,6 +1179,405 @@ impl InspectorExt for Cheatcodes { } } +impl Cheatcodes { + #[cold] + fn meter_gas(&mut self, interpreter: &mut Interpreter) { + match &self.gas_metering { + None => {} + // need to store gas metering + Some(None) => self.gas_metering = Some(Some(interpreter.gas)), + Some(Some(gas)) => { + match interpreter.current_opcode() { + opcode::CREATE | opcode::CREATE2 => { + // set we're about to enter CREATE frame to meter its gas on first opcode + // inside it + self.gas_metering_create = Some(None) + } + opcode::STOP | opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { + // If we are ending current execution frame, we want to just fully reset gas + // otherwise weird things with returning gas from a call happen + // ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/evm_impl.rs#L190 + // + // It would be nice if we had access to the interpreter in `call_end`, as we + // could just do this there instead. + match &self.gas_metering_create { + None | Some(None) => { + interpreter.gas = Gas::new(0); + } + Some(Some(gas)) => { + // If this was CREATE frame, set correct gas limit. This is needed + // because CREATE opcodes deduct additional gas for code storage, + // and deducted amount is compared to gas limit. If we set this to + // 0, the CREATE would fail with out of gas. + // + // If we however set gas limit to the limit of outer frame, it would + // cause a panic after erasing gas cost post-create. Reason for this + // is pre-create REVM records `gas_limit - (gas_limit / 64)` as gas + // used, and erases costs by `remaining` gas post-create. + // gas used ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L254-L258 + // post-create erase ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L279 + interpreter.gas = Gas::new(gas.limit()); + + // reset CREATE gas metering because we're about to exit its frame + self.gas_metering_create = None + } + } + } + _ => { + // if just starting with CREATE opcodes, record its inner frame gas + if let Some(None) = self.gas_metering_create { + self.gas_metering_create = Some(Some(interpreter.gas)) + } + + // dont monitor gas changes, keep it constant + interpreter.gas = *gas; + } + } + } + } + } + + /// Records storage slots reads and writes. + #[cold] + fn record_accesses(&mut self, interpreter: &mut Interpreter) { + let Some(access) = &mut self.accesses else { return }; + match interpreter.current_opcode() { + opcode::SLOAD => { + let key = try_or_return!(interpreter.stack().peek(0)); + access.record_read(interpreter.contract().target_address, key); + } + opcode::SSTORE => { + let key = try_or_return!(interpreter.stack().peek(0)); + access.record_write(interpreter.contract().target_address, key); + } + _ => {} + } + } + + #[cold] + fn record_state_diffs( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext, + ) { + let Some(account_accesses) = &mut self.recorded_account_diffs_stack else { return }; + match interpreter.current_opcode() { + opcode::SELFDESTRUCT => { + // Ensure that we're not selfdestructing a context recording was initiated on + let Some(last) = account_accesses.last_mut() else { return }; + + // get previous balance and initialized status of the target account + let target = try_or_return!(interpreter.stack().peek(0)); + let target = Address::from_word(B256::from(target)); + let (initialized, old_balance) = ecx + .load_account(target) + .map(|(account, _)| (account.info.exists(), account.info.balance)) + .unwrap_or_default(); + + // load balance of this account + let value = ecx + .balance(interpreter.contract().target_address) + .map(|(b, _)| b) + .unwrap_or(U256::ZERO); + + // register access for the target account + last.push(crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), + }, + accessor: interpreter.contract().target_address, + account: target, + kind: crate::Vm::AccountAccessKind::SelfDestruct, + initialized, + oldBalance: old_balance, + newBalance: old_balance + value, + value, + data: Bytes::new(), + reverted: false, + deployedCode: Bytes::new(), + storageAccesses: vec![], + depth: ecx.journaled_state.depth(), + }); + } + + opcode::SLOAD => { + let Some(last) = account_accesses.last_mut() else { return }; + + let key = try_or_return!(interpreter.stack().peek(0)); + let address = interpreter.contract().target_address; + + // Try to include present value for informational purposes, otherwise assume + // it's not set (zero value) + let mut present_value = U256::ZERO; + // Try to load the account and the slot's present value + if ecx.load_account(address).is_ok() { + if let Ok((previous, _)) = ecx.sload(address, key) { + present_value = previous; + } + } + let access = crate::Vm::StorageAccess { + account: interpreter.contract().target_address, + slot: key.into(), + isWrite: false, + previousValue: present_value.into(), + newValue: present_value.into(), + reverted: false, + }; + append_storage_access(last, access, ecx.journaled_state.depth()); + } + opcode::SSTORE => { + let Some(last) = account_accesses.last_mut() else { return }; + + let key = try_or_return!(interpreter.stack().peek(0)); + let value = try_or_return!(interpreter.stack().peek(1)); + let address = interpreter.contract().target_address; + // Try to load the account and the slot's previous value, otherwise, assume it's + // not set (zero value) + let mut previous_value = U256::ZERO; + if ecx.load_account(address).is_ok() { + if let Ok((previous, _)) = ecx.sload(address, key) { + previous_value = previous; + } + } + + let access = crate::Vm::StorageAccess { + account: address, + slot: key.into(), + isWrite: true, + previousValue: previous_value.into(), + newValue: value.into(), + reverted: false, + }; + append_storage_access(last, access, ecx.journaled_state.depth()); + } + + // Record account accesses via the EXT family of opcodes + opcode::EXTCODECOPY | opcode::EXTCODESIZE | opcode::EXTCODEHASH | opcode::BALANCE => { + let kind = match interpreter.current_opcode() { + opcode::EXTCODECOPY => crate::Vm::AccountAccessKind::Extcodecopy, + opcode::EXTCODESIZE => crate::Vm::AccountAccessKind::Extcodesize, + opcode::EXTCODEHASH => crate::Vm::AccountAccessKind::Extcodehash, + opcode::BALANCE => crate::Vm::AccountAccessKind::Balance, + _ => unreachable!(), + }; + let address = + Address::from_word(B256::from(try_or_return!(interpreter.stack().peek(0)))); + let initialized; + let balance; + if let Ok((acc, _)) = ecx.load_account(address) { + initialized = acc.info.exists(); + balance = acc.info.balance; + } else { + initialized = false; + balance = U256::ZERO; + } + let account_access = crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), + }, + accessor: interpreter.contract().target_address, + account: address, + kind, + initialized, + oldBalance: balance, + newBalance: balance, + value: U256::ZERO, + data: Bytes::new(), + reverted: false, + deployedCode: Bytes::new(), + storageAccesses: vec![], + depth: ecx.journaled_state.depth(), + }; + // Record the EXT* call as an account access at the current depth + // (future storage accesses will be recorded in a new "Resume" context) + if let Some(last) = account_accesses.last_mut() { + last.push(account_access); + } else { + account_accesses.push(vec![account_access]); + } + } + _ => {} + } + } + + /// Checks to see if the current opcode can either mutate directly or expand memory. + /// + /// If the opcode at the current program counter is a match, check if the modified memory lies + /// within the allowed ranges. If not, revert and fail the test. + #[cold] + fn check_mem_opcodes(&self, interpreter: &mut Interpreter, depth: u64) { + let Some(ranges) = self.allowed_mem_writes.get(&depth) else { + return; + }; + + // The `mem_opcode_match` macro is used to match the current opcode against a list of + // opcodes that can mutate memory (either directly or expansion via reading). If the + // opcode is a match, the memory offsets that are being written to are checked to be + // within the allowed ranges. If not, the test is failed and the transaction is + // reverted. For all opcodes that can mutate memory aside from MSTORE, + // MSTORE8, and MLOAD, the size and destination offset are on the stack, and + // the macro expands all of these cases. For MSTORE, MSTORE8, and MLOAD, the + // size of the memory write is implicit, so these cases are hard-coded. + macro_rules! mem_opcode_match { + ($(($opcode:ident, $offset_depth:expr, $size_depth:expr, $writes:expr)),* $(,)?) => { + match interpreter.current_opcode() { + //////////////////////////////////////////////////////////////// + // OPERATIONS THAT CAN EXPAND/MUTATE MEMORY BY WRITING // + //////////////////////////////////////////////////////////////// + + opcode::MSTORE => { + // The offset of the mstore operation is at the top of the stack. + let offset = try_or_return!(interpreter.stack().peek(0)).saturating_to::(); + + // If none of the allowed ranges contain [offset, offset + 32), memory has been + // unexpectedly mutated. + if !ranges.iter().any(|range| { + range.contains(&offset) && range.contains(&(offset + 31)) + }) { + // SPECIAL CASE: When the compiler attempts to store the selector for + // `stopExpectSafeMemory`, this is allowed. It will do so at the current free memory + // pointer, which could have been updated to the exclusive upper bound during + // execution. + let value = try_or_return!(interpreter.stack().peek(1)).to_be_bytes::<32>(); + let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; + if value[0..SELECTOR_LEN] == selector { + return + } + + disallowed_mem_write(offset, 32, interpreter, ranges); + return + } + } + opcode::MSTORE8 => { + // The offset of the mstore8 operation is at the top of the stack. + let offset = try_or_return!(interpreter.stack().peek(0)).saturating_to::(); + + // If none of the allowed ranges contain the offset, memory has been + // unexpectedly mutated. + if !ranges.iter().any(|range| range.contains(&offset)) { + disallowed_mem_write(offset, 1, interpreter, ranges); + return + } + } + + //////////////////////////////////////////////////////////////// + // OPERATIONS THAT CAN EXPAND MEMORY BY READING // + //////////////////////////////////////////////////////////////// + + opcode::MLOAD => { + // The offset of the mload operation is at the top of the stack + let offset = try_or_return!(interpreter.stack().peek(0)).saturating_to::(); + + // If the offset being loaded is >= than the memory size, the + // memory is being expanded. If none of the allowed ranges contain + // [offset, offset + 32), memory has been unexpectedly mutated. + if offset >= interpreter.shared_memory.len() as u64 && !ranges.iter().any(|range| { + range.contains(&offset) && range.contains(&(offset + 31)) + }) { + disallowed_mem_write(offset, 32, interpreter, ranges); + return + } + } + + //////////////////////////////////////////////////////////////// + // OPERATIONS WITH OFFSET AND SIZE ON STACK // + //////////////////////////////////////////////////////////////// + + opcode::CALL => { + // The destination offset of the operation is the fifth element on the stack. + let dest_offset = try_or_return!(interpreter.stack().peek(5)).saturating_to::(); + + // The size of the data that will be copied is the sixth element on the stack. + let size = try_or_return!(interpreter.stack().peek(6)).saturating_to::(); + + // If none of the allowed ranges contain [dest_offset, dest_offset + size), + // memory outside of the expected ranges has been touched. If the opcode + // only reads from memory, this is okay as long as the memory is not expanded. + let fail_cond = !ranges.iter().any(|range| { + range.contains(&dest_offset) && + range.contains(&(dest_offset + size.saturating_sub(1))) + }); + + // If the failure condition is met, set the output buffer to a revert string + // that gives information about the allowed ranges and revert. + if fail_cond { + // SPECIAL CASE: When a call to `stopExpectSafeMemory` is performed, this is allowed. + // It allocated calldata at the current free memory pointer, and will attempt to read + // from this memory region to perform the call. + let to = Address::from_word(try_or_return!(interpreter.stack().peek(1)).to_be_bytes::<32>().into()); + if to == CHEATCODE_ADDRESS { + let args_offset = try_or_return!(interpreter.stack().peek(3)).saturating_to::(); + let args_size = try_or_return!(interpreter.stack().peek(4)).saturating_to::(); + let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; + let memory_word = interpreter.shared_memory.slice(args_offset, args_size); + if memory_word[0..SELECTOR_LEN] == selector { + return + } + } + + disallowed_mem_write(dest_offset, size, interpreter, ranges); + return + } + } + + $(opcode::$opcode => { + // The destination offset of the operation. + let dest_offset = try_or_return!(interpreter.stack().peek($offset_depth)).saturating_to::(); + + // The size of the data that will be copied. + let size = try_or_return!(interpreter.stack().peek($size_depth)).saturating_to::(); + + // If none of the allowed ranges contain [dest_offset, dest_offset + size), + // memory outside of the expected ranges has been touched. If the opcode + // only reads from memory, this is okay as long as the memory is not expanded. + let fail_cond = !ranges.iter().any(|range| { + range.contains(&dest_offset) && + range.contains(&(dest_offset + size.saturating_sub(1))) + }) && ($writes || + [dest_offset, (dest_offset + size).saturating_sub(1)].into_iter().any(|offset| { + offset >= interpreter.shared_memory.len() as u64 + }) + ); + + // If the failure condition is met, set the output buffer to a revert string + // that gives information about the allowed ranges and revert. + if fail_cond { + disallowed_mem_write(dest_offset, size, interpreter, ranges); + return + } + })* + + _ => {} + } + } + } + + // Check if the current opcode can write to memory, and if so, check if the memory + // being written to is registered as safe to modify. + mem_opcode_match!( + (CALLDATACOPY, 0, 2, true), + (CODECOPY, 0, 2, true), + (RETURNDATACOPY, 0, 2, true), + (EXTCODECOPY, 1, 3, true), + (CALLCODE, 5, 6, true), + (STATICCALL, 4, 5, true), + (DELEGATECALL, 4, 5, true), + (KECCAK256, 0, 1, false), + (LOG0, 0, 1, false), + (LOG1, 0, 1, false), + (LOG2, 0, 1, false), + (LOG3, 0, 1, false), + (LOG4, 0, 1, false), + (CREATE, 1, 2, false), + (CREATE2, 1, 2, false), + (RETURN, 0, 1, false), + (REVERT, 0, 1, false), + ); + } +} + /// Helper that expands memory, stores a revert string pertaining to a disallowed memory write, /// and sets the return range to the revert string's location in memory. /// @@ -1644,47 +1648,45 @@ fn access_is_call(kind: crate::Vm::AccountAccessKind) -> bool { /// Appends an AccountAccess that resumes the recording of the current context. fn append_storage_access( - accesses: &mut [Vec], + last: &mut Vec, storage_access: crate::Vm::StorageAccess, storage_depth: u64, ) { - if let Some(last) = accesses.last_mut() { - // Assert that there's an existing record for the current context. - if !last.is_empty() && last.first().unwrap().depth < storage_depth { - // Three cases to consider: - // 1. If there hasn't been a context switch since the start of this context, then add - // the storage access to the current context record. - // 2. If there's an existing Resume record, then add the storage access to it. - // 3. Otherwise, create a new Resume record based on the current context. - if last.len() == 1 { - last.first_mut().unwrap().storageAccesses.push(storage_access); + // Assert that there's an existing record for the current context. + if !last.is_empty() && last.first().unwrap().depth < storage_depth { + // Three cases to consider: + // 1. If there hasn't been a context switch since the start of this context, then add the + // storage access to the current context record. + // 2. If there's an existing Resume record, then add the storage access to it. + // 3. Otherwise, create a new Resume record based on the current context. + if last.len() == 1 { + last.first_mut().unwrap().storageAccesses.push(storage_access); + } else { + let last_record = last.last_mut().unwrap(); + if last_record.kind as u8 == crate::Vm::AccountAccessKind::Resume as u8 { + last_record.storageAccesses.push(storage_access); } else { - let last_record = last.last_mut().unwrap(); - if last_record.kind as u8 == crate::Vm::AccountAccessKind::Resume as u8 { - last_record.storageAccesses.push(storage_access); - } else { - let entry = last.first().unwrap(); - let resume_record = crate::Vm::AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: entry.chainInfo.forkId, - chainId: entry.chainInfo.chainId, - }, - accessor: entry.accessor, - account: entry.account, - kind: crate::Vm::AccountAccessKind::Resume, - initialized: entry.initialized, - storageAccesses: vec![storage_access], - reverted: entry.reverted, - // The remaining fields are defaults - oldBalance: U256::ZERO, - newBalance: U256::ZERO, - value: U256::ZERO, - data: Bytes::new(), - deployedCode: Bytes::new(), - depth: entry.depth, - }; - last.push(resume_record); - } + let entry = last.first().unwrap(); + let resume_record = crate::Vm::AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: entry.chainInfo.forkId, + chainId: entry.chainInfo.chainId, + }, + accessor: entry.accessor, + account: entry.account, + kind: crate::Vm::AccountAccessKind::Resume, + initialized: entry.initialized, + storageAccesses: vec![storage_access], + reverted: entry.reverted, + // The remaining fields are defaults + oldBalance: U256::ZERO, + newBalance: U256::ZERO, + value: U256::ZERO, + data: Bytes::new(), + deployedCode: Bytes::new(), + depth: entry.depth, + }; + last.push(resume_record); } } } From 91a9767376d749419e2b81a1682ea962adddd5ce Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:44:08 +0200 Subject: [PATCH 1118/1963] test: unflake an anvil test (#8204) --- crates/anvil/tests/it/anvil_api.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 359c0f39ce096..e6289e0b0853c 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -631,7 +631,8 @@ async fn test_fork_revert_call_latest_block_timestamp() { #[tokio::test(flavor = "multi_thread")] async fn can_remove_pool_transactions() { - let (api, handle) = spawn(NodeConfig::test()).await; + let (api, handle) = + spawn(NodeConfig::test().with_blocktime(Some(Duration::from_secs(5)))).await; let wallet = handle.dev_wallets().next().unwrap(); let signer: EthereumWallet = wallet.clone().into(); From ffb1e03e3be396cb7058d90f200bd030dff2f1d9 Mon Sep 17 00:00:00 2001 From: Matt Solomon Date: Wed, 19 Jun 2024 07:47:58 -0700 Subject: [PATCH 1119/1963] chore: fix docstring and add tests for random cheats (#8202) --- crates/cheatcodes/assets/cheatcodes.json | 2 +- crates/cheatcodes/spec/src/vm.rs | 2 +- testdata/default/cheats/RandomUint.t.sol | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 786fc38b480ae..85b2766da128e 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6454,7 +6454,7 @@ { "func": { "id": "randomUint_1", - "description": "Returns random uin256 value between the provided range (min..=max).", + "description": "Returns random uin256 value between the provided range (=min..=max).", "declaration": "function randomUint(uint256 min, uint256 max) external returns (uint256);", "visibility": "external", "mutability": "", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 201bc90d7bf4b..f774fcbc7e1bb 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2148,7 +2148,7 @@ interface Vm { #[cheatcode(group = Utilities)] function randomUint() external returns (uint256); - /// Returns random uin256 value between the provided range (min..=max). + /// Returns random uin256 value between the provided range (=min..=max). #[cheatcode(group = Utilities)] function randomUint(uint256 min, uint256 max) external returns (uint256); diff --git a/testdata/default/cheats/RandomUint.t.sol b/testdata/default/cheats/RandomUint.t.sol index 5c5b1024aec6b..e1c7e09d3ce7d 100644 --- a/testdata/default/cheats/RandomUint.t.sol +++ b/testdata/default/cheats/RandomUint.t.sol @@ -7,9 +7,29 @@ import "cheats/Vm.sol"; contract RandomUint is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); + // All tests use `>=` and `<=` to verify that ranges are inclusive and that + // a value of zero may be generated. function testRandomUint() public { uint256 rand = vm.randomUint(); + assertTrue(rand >= 0); + } + + function testRandomUint(uint256 min, uint256 max) public { + if (min > max) { + (min, max) = (max, min); + } + uint256 rand = vm.randomUint(min, max); + assertTrue(rand >= min, "rand >= min"); + assertTrue(rand <= max, "rand <= max"); + } + + function testRandomUint(uint256 val) public { + uint256 rand = vm.randomUint(val, val); + assertTrue(rand == val); + } - assertTrue(rand > 0); + function testRandomAddress() public { + address rand = vm.randomAddress(); + assertTrue(rand >= address(0)); } } From 58596a773dcd1888497a27033417f25180085339 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:36:19 +0300 Subject: [PATCH 1120/1963] fix(invariant): show labels when failure replay (#8201) --- crates/forge/src/runner.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index d2213cd3796d3..201494b764086 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -640,11 +640,13 @@ impl<'a> ContractRunner<'a> { invariant_contract.invariant_function.name )) }, - decoded_logs: decode_console_logs(&logs), - traces, - coverage, counterexample: Some(CounterExample::Sequence(call_sequence)), + decoded_logs: decode_console_logs(&logs), + logs, kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, + coverage, + traces, + labeled_addresses, ..Default::default() } } @@ -750,7 +752,7 @@ impl<'a> ContractRunner<'a> { }, coverage, traces, - labeled_addresses: labeled_addresses.clone(), + labeled_addresses, gas_report_traces, ..Default::default() // TODO collect debug traces on the last run or error } From a6d29787f3e00dd4ef80d8a94c068135bd0ae020 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:36:29 +0200 Subject: [PATCH 1121/1963] chore(deps): bump alloy to `0.1.2`, remove patch (#8205) * remove patch, update to `0.1.2`, marking `0.1.*` for flexibility * revert `0.1.*`, pin to `0.1.2` --- Cargo.lock | 425 +++++++++++------------------------------------------ Cargo.toml | 45 +++--- 2 files changed, 111 insertions(+), 359 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9c2d98265076..0e37133b92158 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2feb5f466b3a786d5a622d8926418bc6a0d38bf632909f6ee9298a4a1d8c6e0" +checksum = "cd47e5f8545bdf53beb545d3c039b4afa16040bdf69c50100581579b08776afd" dependencies = [ "num_enum", "serde", @@ -79,23 +79,23 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc7579e4fb5558af44810f542c90d1145dba8b92c08211c215196160c48d2ea" +checksum = "a016bfa21193744d4c38b3f3ab845462284d129e5e23c7cc0fafca7e92d9db37" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "c-kzg", "serde", ] [[package]] name = "alloy-contract" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "860887f0f7e1e17db33ada75c3c516164a5e11aa89f0311f4d23b82abcf2d807" +checksum = "e47b2a620fd588d463ccf0f5931b41357664b293a8d31592768845a2a101bb9e" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -134,13 +134,13 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdbc8d98cc36ebe17bb5b42d0873137bc76628a4ee0f7e7acad5b8fc59d3597" +checksum = "32d6d8118b83b0489cfb7e6435106948add2b35217f4a5004ef895f613f60299" dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "c-kzg", "derive_more", "once_cell", @@ -150,14 +150,13 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e10a047066076b32d52b3228e95a4f7793db7a204f648aa1a1ea675085bffd8" +checksum = "894f33a7822abb018db56b10ab90398e63273ce1b5a33282afd186c132d764a6" dependencies = [ "alloy-primitives", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "serde", - "serde_json", ] [[package]] @@ -174,9 +173,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06d33b79246313c4103ef9596c721674a926f1ddc8b605aa2bac4d8ba94ee34" +checksum = "61f0ae6e93b885cc70fe8dae449e7fd629751dbee8f59767eaaa7285333c5727" dependencies = [ "alloy-primitives", "serde", @@ -187,16 +186,16 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef742b478a2db5c27063cde82128dfbecffcd38237d7f682a91d3ecf6aa1836c" +checksum = "dc122cbee2b8523854cc11d87bcd5773741602c553d2d2d106d82eeb9c16924a" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-primitives", "alloy-rpc-types-eth", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-signer", "alloy-sol-types", "async-trait", @@ -234,9 +233,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200b786259a17acf318b9c423afe9669bec24ce9cdf59de153ff9a4009914bb6" +checksum = "3d5af289798fe8783acd0c5f10644d9d26f54a12bc52a083e4f3b31718e9bf92" dependencies = [ "alloy-chains", "alloy-consensus", @@ -271,9 +270,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e6e6c1eab938a18a8e88d430cc9d548edf54c850a550873888285c85428eca" +checksum = "702f330b7da123a71465ab9d39616292f8344a2811c28f2cc8d8438a69d79e35" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -312,9 +311,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328a6a14aba6152ddf6d01bac5e17a70dbe9d6f343bf402b995c30bac63a1fbf" +checksum = "b40fcb53b2a9d0a78a4968b2eca8805a4b7011b9ee3fdfa2acaf137c5128f36b" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -337,40 +336,41 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3164e7d8a718a22ede70b2c1d2bb554a8b4bd8e56c07ab630b75c74c06c53752" +checksum = "50f2fbe956a3e0f0975c798f488dc6be96b669544df3737e18f4a325b42f4c86" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", ] [[package]] name = "alloy-rpc-types-anvil" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?rev=8dc637e#8dc637e527e79b768380b9f95bd1a0d868deff63" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87f724e6170f558b809a520e37bdb34d99123092b78118bff31fb5b21dc2a2e" dependencies = [ "alloy-primitives", - "alloy-serde 0.1.1 (git+https://github.com/alloy-rs/alloy?rev=8dc637e)", + "alloy-serde", "serde", ] [[package]] name = "alloy-rpc-types-engine" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90c3de574f90d9b939e3ee666a74bea29fb1a2ae66f1569b111bb6a922b1c762" +checksum = "cd473d98ec552f8229cd6d566bd2b0bbfc5bb4efcefbb5288c834aa8fd832020" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-rpc-types-eth", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "jsonwebtoken", "rand", "serde", @@ -379,15 +379,15 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bce0676f144be1eae71122d1d417885a3b063add0353b35e46cdf1440d6b33b1" +checksum = "083f443a83b9313373817236a8f4bea09cca862618e9177d822aee579640a5d6" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-sol-types", "itertools 0.13.0", "serde", @@ -397,44 +397,35 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a39c52613dc4d9995ff284b496158594ae63f9bfc58b5ef04e48ec5da2e3d747" +checksum = "4c7a838f9a34aae7022c6cb53ecf21bc0a5a30c82f8d9eb0afed701ab5fd88de" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "serde", "serde_json", + "thiserror", ] [[package]] name = "alloy-rpc-types-txpool" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aeb7995e8859f3931b6199e13a533c9fde89affa900addb7218db2f15f9687d" +checksum = "1572267dbc660843d87c02994029d1654c2c32867e186b266d1c03644b43af97" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "serde", ] [[package]] name = "alloy-serde" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c224916316519558d8c2b6a60dc7626688c08f1b8951774702562dbcb8666ee" -dependencies = [ - "alloy-primitives", - "serde", - "serde_json", -] - -[[package]] -name = "alloy-serde" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?rev=8dc637e#8dc637e527e79b768380b9f95bd1a0d868deff63" +checksum = "d94da1c0c4e27cc344b05626fe22a89dc6b8b531b9475f3b7691dbf6913e4109" dependencies = [ "alloy-primitives", "serde", @@ -443,9 +434,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227c5fd0ed6e06e1ccc30593f8ff6d9fb907ac5f03a709a6d687f0943494a229" +checksum = "58d876be3afd8b78979540084ff63995292a26aa527ad0d44276405780aa0ffd" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -459,9 +450,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723009d673de375a1f2d5fe4a1b32fea144001578db54b2dd5c817eaa9f09c25" +checksum = "a4d88815c5a7e666469cd8dc82b50c39e1b8f86c650e914fdc5c3bc1b2db57b6" dependencies = [ "alloy-consensus", "alloy-network", @@ -477,9 +468,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97eae91202844e3cde7281d8343fd848bbae8bd53cf3f92450a66ba989c12b34" +checksum = "51be98dc71e445331deea5a0f9ae33f83803c7dd22db4a6b18def0d23007c6e3" dependencies = [ "alloy-consensus", "alloy-network", @@ -495,9 +486,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3a65e52c3c1848510d69e73e716139839f701134465bf44b77a7e43c1362f6" +checksum = "5dfcac99cf316246bf3087207fb17ec1b027c62d4a6bd28eb0c6413d66fe66e5" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -515,9 +506,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c44057ac1e8707f8c6a983db9f83ac1265c9e05be81d432acf2aad2880e1c0" +checksum = "d40a37dc216c269b8a7244047cb1c18a9c69f7a0332ab2c4c2aa4cbb1a31468b" dependencies = [ "alloy-consensus", "alloy-network", @@ -535,9 +526,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85f68408899f493c3fd432e680f7ab586a38b9d2c8c117190855157dac70d9c4" +checksum = "ad954b6a08612616dab4611078a60d7dcff372780e7240058bea2c323d282d8b" dependencies = [ "alloy-consensus", "alloy-network", @@ -624,9 +615,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3628d81530263fe837a09cd527022f5728202a669973f04270942f4d390b5f5" +checksum = "245af9541f0a0dbd5258669c80dfe3af118164cacec978a520041fc130550deb" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -642,9 +633,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f35d34e7a51503c9ff267404a5850bd58f991b7ab524b892f364901e3576376" +checksum = "5619c017e1fdaa1db87f9182f4f0ed97c53d674957f4902fba655e972d359c6c" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -657,9 +648,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7d2f106151a583f7d258fe8cc846c5196da90a9f502d4b3516c56d63e1f25a2" +checksum = "173cefa110afac7a53cf2e75519327761f2344d305eea2993f3af1b2c1fc1c44" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -678,9 +669,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a80da44d3709c4ceaf47745ad820eae8f121404b9ffd8e285522ac4eb06681" +checksum = "9c0aff8af5be5e58856c5cdd1e46db2c67c7ecd3a652d9100b4822c96c899947" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -812,7 +803,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-client", "alloy-rpc-types", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -872,7 +863,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-trie", "bytes", "foundry-common", @@ -1240,9 +1231,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.2.3" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36978815abdd7297662bf906adff132941a02ecf425bc78fac7d90653ce87560" +checksum = "9a4a5e448145999d7de17bf44a886900ecb834953408dae8aaf90465ce91c1dd" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1803,9 +1794,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -1920,7 +1911,7 @@ dependencies = [ "alloy-provider", "alloy-rlp", "alloy-rpc-types", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -3313,7 +3304,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-signer", "alloy-signer-local", "alloy-sol-macro-expander", @@ -3441,7 +3432,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-signer", "alloy-transport", "async-recursion", @@ -3651,7 +3642,7 @@ dependencies = [ "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3882,7 +3873,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-serde", "alloy-sol-types", "alloy-transport", "arrayvec", @@ -4886,124 +4877,6 @@ dependencies = [ "cc", ] -[[package]] -name = "icu_collections" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - -[[package]] -name = "icu_normalizer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" - -[[package]] -name = "icu_properties" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" - -[[package]] -name = "icu_provider" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -5012,14 +4885,12 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "1.0.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "icu_normalizer", - "icu_properties", - "smallvec", - "utf8_iter", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -5443,12 +5314,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - [[package]] name = "lock_api" version = "0.4.12" @@ -8079,12 +7944,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" @@ -8255,17 +8114,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "system-configuration" version = "0.5.1" @@ -8457,16 +8305,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinytemplate" version = "1.2.1" @@ -8968,6 +8806,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-bom" version = "2.0.3" @@ -9025,9 +8869,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -9046,18 +8890,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" @@ -9610,18 +9442,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -9665,30 +9485,6 @@ dependencies = [ "is-terminal", ] -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - [[package]] name = "zerocopy" version = "0.7.34" @@ -9709,27 +9505,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - [[package]] name = "zeroize" version = "1.8.1" @@ -9750,28 +9525,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "zerovec" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "zip" version = "0.6.6" diff --git a/Cargo.toml b/Cargo.toml index c1d82d44ec88b..48178e69ce73f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,28 +168,28 @@ revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.1.1", default-features = false } -alloy-contract = { version = "0.1.1", default-features = false } -alloy-eips = { version = "0.1.1", default-features = false } -alloy-genesis = { version = "0.1.1", default-features = false } -alloy-json-rpc = { version = "0.1.1", default-features = false } -alloy-network = { version = "0.1.1", default-features = false } -alloy-node-bindings = { version = "0.1.1", default-features = false } -alloy-provider = { version = "0.1.1", default-features = false } -alloy-pubsub = { version = "0.1.1", default-features = false } -alloy-rpc-client = { version = "0.1.1", default-features = false } -alloy-rpc-types = { version = "0.1.1", default-features = false } -alloy-serde = { version = "0.1.1", default-features = false } -alloy-signer = { version = "0.1.1", default-features = false } -alloy-signer-local = { version = "0.1.1", default-features = false } -alloy-signer-aws = { version = "0.1.1", default-features = false } -alloy-signer-gcp = { version = "0.1.1", default-features = false } -alloy-signer-ledger = { version = "0.1.1", default-features = false } -alloy-signer-trezor = { version = "0.1.1", default-features = false } -alloy-transport = { version = "0.1.1", default-features = false } -alloy-transport-http = { version = "0.1.1", default-features = false } -alloy-transport-ipc = { version = "0.1.1", default-features = false } -alloy-transport-ws = { version = "0.1.1", default-features = false } +alloy-consensus = { version = "0.1.2", default-features = false } +alloy-contract = { version = "0.1.2", default-features = false } +alloy-eips = { version = "0.1.2", default-features = false } +alloy-genesis = { version = "0.1.2", default-features = false } +alloy-json-rpc = { version = "0.1.2", default-features = false } +alloy-network = { version = "0.1.2", default-features = false } +alloy-node-bindings = { version = "0.1.2", default-features = false } +alloy-provider = { version = "0.1.2", default-features = false } +alloy-pubsub = { version = "0.1.2", default-features = false } +alloy-rpc-client = { version = "0.1.2", default-features = false } +alloy-rpc-types = { version = "0.1.2", default-features = false } +alloy-serde = { version = "0.1.2", default-features = false } +alloy-signer = { version = "0.1.2", default-features = false } +alloy-signer-local = { version = "0.1.2", default-features = false } +alloy-signer-aws = { version = "0.1.2", default-features = false } +alloy-signer-gcp = { version = "0.1.2", default-features = false } +alloy-signer-ledger = { version = "0.1.2", default-features = false } +alloy-signer-trezor = { version = "0.1.2", default-features = false } +alloy-transport = { version = "0.1.2", default-features = false } +alloy-transport-http = { version = "0.1.2", default-features = false } +alloy-transport-ipc = { version = "0.1.2", default-features = false } +alloy-transport-ws = { version = "0.1.2", default-features = false } alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } alloy-dyn-abi = "0.7.1" alloy-json-abi = "0.7.1" @@ -260,7 +260,6 @@ tower-http = "0.5" soldeer = "0.2.15" [patch.crates-io] -alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "8dc637e" } revm = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } From 3abac322efdb69e27b6fe8748b72754ae878f64d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:35:50 +0200 Subject: [PATCH 1122/1963] perf: optimize inspector stack dispatching (#8206) --- .../core/src/eth/transaction/optimism.rs | 1 - crates/anvil/src/eth/api.rs | 1 - crates/anvil/src/eth/backend/mem/inspector.rs | 21 ++----- crates/evm/evm/src/inspectors/stack.rs | 58 +++++++++---------- 4 files changed, 32 insertions(+), 49 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 4a147297b4851..f2e4cff26c94d 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -108,7 +108,6 @@ impl DepositTransactionRequest { } /// Calculates a heuristic for the in-memory size of the [DepositTransaction] transaction. - #[inline] pub fn size(&self) -> usize { mem::size_of::() + // source_hash mem::size_of::
() + // from diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index d147db76f34c3..c3641ace00828 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2678,7 +2678,6 @@ fn ensure_return_ok(exit: InstructionResult, out: &Option) -> Result) -> u128 { match transaction_request_to_typed(request.clone()) { Some(request) => match request { diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 0fe0f26af79d0..9653912c9fe54 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -45,46 +45,39 @@ impl Inspector { } impl revm::Inspector for Inspector { - #[inline] fn initialize_interp(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors!([&mut self.tracer], |inspector| { inspector.initialize_interp(interp, ecx); }); } - #[inline] fn step(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors!([&mut self.tracer], |inspector| { inspector.step(interp, ecx); }); } - #[inline] fn step_end(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors!([&mut self.tracer], |inspector| { inspector.step_end(interp, ecx); }); } - #[inline] fn log(&mut self, ecx: &mut EvmContext, log: &Log) { call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { inspector.log(ecx, log); }); } - #[inline] fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { - call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { - if let Some(outcome) = inspector.call(ecx, inputs) { - return Some(outcome); - } - }); - + call_inspectors!( + #[ret] + [&mut self.tracer, Some(&mut self.log_collector)], + |inspector| inspector.call(ecx, inputs).map(Some), + ); None } - #[inline] fn call_end( &mut self, ecx: &mut EvmContext, @@ -98,7 +91,6 @@ impl revm::Inspector for Inspector { outcome } - #[inline] fn create( &mut self, ecx: &mut EvmContext, @@ -112,7 +104,6 @@ impl revm::Inspector for Inspector { None } - #[inline] fn create_end( &mut self, ecx: &mut EvmContext, @@ -126,7 +117,6 @@ impl revm::Inspector for Inspector { outcome } - #[inline] fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { if let Some(tracer) = &mut self.tracer { revm::Inspector::::selfdestruct(tracer, contract, target, value); @@ -137,7 +127,6 @@ impl revm::Inspector for Inspector { impl InspectorExt for Inspector {} /// Prints all the logs -#[inline] pub fn print_logs(logs: &[Log]) { for log in decode_console_logs(logs) { node_info!("{}", log); diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 1858e91a7e7ed..a7e08ab636aeb 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -197,45 +197,40 @@ macro_rules! call_inspectors { ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr $(,)?) => { $( if let Some($id) = $inspector { - $call + ({ #[inline(always)] #[cold] || $call })(); } )+ - } + }; + (#[ret] [$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr $(,)?) => { + $( + if let Some($id) = $inspector { + if let Some(result) = ({ #[inline(always)] #[cold] || $call })() { + return result; + } + } + )+ + }; } -/// Same as [call_inspectors] macro, but with depth adjustment for isolated execution. +/// Same as [`call_inspectors!`], but with depth adjustment for isolated execution. macro_rules! call_inspectors_adjust_depth { - (#[no_ret] [$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { + ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { + $data.journaled_state.depth += $self.in_inner_context as usize; + call_inspectors!([$($inspector),+], |$id| $call); + $data.journaled_state.depth -= $self.in_inner_context as usize; + }; + (#[ret] [$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { $data.journaled_state.depth += $self.in_inner_context as usize; $( if let Some($id) = $inspector { - $call + if let Some(result) = ({ #[inline(always)] #[cold] || $call })() { + $data.journaled_state.depth -= $self.in_inner_context as usize; + return result; + } } )+ $data.journaled_state.depth -= $self.in_inner_context as usize; }; - ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { - if $self.in_inner_context { - $data.journaled_state.depth += 1; - $( - if let Some($id) = $inspector { - if let Some(result) = $call { - $data.journaled_state.depth -= 1; - return result; - } - } - )+ - $data.journaled_state.depth -= 1; - } else { - $( - if let Some($id) = $inspector { - if let Some(result) = $call { - return result; - } - } - )+ - } - }; } /// The collected results of [`InspectorStack`]. @@ -432,6 +427,7 @@ impl InspectorStack { ) -> CallOutcome { let result = outcome.result.result; call_inspectors_adjust_depth!( + #[ret] [ &mut self.fuzzer, &mut self.debugger, @@ -613,7 +609,6 @@ impl InspectorStack { impl Inspector<&mut DB> for InspectorStack { fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( - #[no_ret] [&mut self.coverage, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.initialize_interp(interpreter, ecx), self, @@ -623,7 +618,6 @@ impl Inspector<&mut DB> for InspectorStack { fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( - #[no_ret] [ &mut self.fuzzer, &mut self.debugger, @@ -640,7 +634,6 @@ impl Inspector<&mut DB> for InspectorStack { fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { call_inspectors_adjust_depth!( - #[no_ret] [&mut self.tracer, &mut self.chisel_state, &mut self.printer], |inspector| inspector.step_end(interpreter, ecx), self, @@ -650,7 +643,6 @@ impl Inspector<&mut DB> for InspectorStack { fn log(&mut self, ecx: &mut EvmContext<&mut DB>, log: &Log) { call_inspectors_adjust_depth!( - #[no_ret] [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.log(ecx, log), self, @@ -669,6 +661,7 @@ impl Inspector<&mut DB> for InspectorStack { } call_inspectors_adjust_depth!( + #[ret] [ &mut self.fuzzer, &mut self.debugger, @@ -745,6 +738,7 @@ impl Inspector<&mut DB> for InspectorStack { } call_inspectors_adjust_depth!( + #[ret] [&mut self.debugger, &mut self.tracer, &mut self.coverage, &mut self.cheatcodes], |inspector| inspector.create(ecx, create).map(Some), self, @@ -785,6 +779,7 @@ impl Inspector<&mut DB> for InspectorStack { let result = outcome.result.result; call_inspectors_adjust_depth!( + #[ret] [&mut self.debugger, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| { let new_outcome = inspector.create_end(ecx, call, outcome.clone()); @@ -817,6 +812,7 @@ impl InspectorExt<&mut DB> for InspectorStack inputs: &mut CreateInputs, ) -> bool { call_inspectors_adjust_depth!( + #[ret] [&mut self.cheatcodes], |inspector| { inspector.should_use_create2_factory(ecx, inputs).then_some(true) }, self, From dbc4c5c8e427e9cb55a924b2c789b8c1b359f924 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:36:43 +0300 Subject: [PATCH 1123/1963] chore: consolidate TestResult logic (#8208) * chore: consolidate TestResult logic * Update crates/forge/src/result.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Changes after review: pass by value --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/forge/src/result.rs | 180 ++++++++++++++++++++++++- crates/forge/src/runner.rs | 263 ++++++------------------------------- 2 files changed, 217 insertions(+), 226 deletions(-) diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 84c5cdea8893c..ae25461b2db60 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,13 +1,18 @@ //! Test outcomes. -use crate::gas_report::GasReport; +use crate::{ + decode::decode_console_logs, + fuzz::{BaseCounterExample, FuzzedCases}, + gas_report::GasReport, +}; use alloy_primitives::{Address, Log}; +use eyre::Report; use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ coverage::HitMaps, debug::DebugArena, - executors::EvmError, - fuzz::{CounterExample, FuzzCase, FuzzFixtures}, + executors::{EvmError, RawCallResult}, + fuzz::{CounterExample, FuzzCase, FuzzFixtures, FuzzTestResult}, traces::{CallTraceArena, CallTraceDecoder, TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; @@ -416,10 +421,170 @@ impl fmt::Display for TestResult { } impl TestResult { + /// Creates a new test result starting from test setup results. + pub fn new(setup: TestSetup) -> Self { + Self { + labeled_addresses: setup.labeled_addresses, + logs: setup.logs, + traces: setup.traces, + coverage: setup.coverage, + ..Default::default() + } + } + + /// Creates a failed test result with given reason. pub fn fail(reason: String) -> Self { Self { status: TestStatus::Failure, reason: Some(reason), ..Default::default() } } + /// Creates a failed test setup result. + pub fn setup_fail(setup: TestSetup) -> Self { + Self { + status: TestStatus::Failure, + reason: setup.reason, + decoded_logs: decode_console_logs(&setup.logs), + logs: setup.logs, + traces: setup.traces, + coverage: setup.coverage, + labeled_addresses: setup.labeled_addresses, + ..Default::default() + } + } + + /// Returns the skipped result for single test (used in skipped fuzz test too). + pub fn single_skip(mut self) -> Self { + self.status = TestStatus::Skipped; + self.decoded_logs = decode_console_logs(&self.logs); + self.to_owned() + } + + /// Returns the failed result with reason for single test. + pub fn single_fail(mut self, err: EvmError) -> Self { + self.status = TestStatus::Failure; + self.reason = Some(err.to_string()); + self.to_owned() + } + + /// Returns the result for single test. Merges execution results (logs, labeled addresses, + /// traces and coverages) in initial setup results. + pub fn single_result( + mut self, + success: bool, + reason: Option, + raw_call_result: RawCallResult, + ) -> Self { + self.kind = + TestKind::Unit { gas: raw_call_result.gas_used.wrapping_sub(raw_call_result.stipend) }; + + // Record logs, labels, traces and merge coverages. + self.logs.extend(raw_call_result.logs); + self.labeled_addresses.extend(raw_call_result.labels); + self.traces.extend(raw_call_result.traces.map(|traces| (TraceKind::Execution, traces))); + self.merge_coverages(raw_call_result.coverage); + + self.status = match success { + true => TestStatus::Success, + false => TestStatus::Failure, + }; + self.reason = reason; + self.decoded_logs = decode_console_logs(&self.logs); + self.debug = raw_call_result.debug; + self.breakpoints = raw_call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); + self.duration = Duration::default(); + self.gas_report_traces = Vec::new(); + self.to_owned() + } + + /// Returns the result for a fuzzed test. Merges fuzz execution results (logs, labeled + /// addresses, traces and coverages) in initial setup results. + pub fn fuzz_result(mut self, result: FuzzTestResult) -> Self { + self.kind = TestKind::Fuzz { + median_gas: result.median_gas(false), + mean_gas: result.mean_gas(false), + first_case: result.first_case, + runs: result.gas_by_case.len(), + }; + + // Record logs, labels, traces and merge coverages. + self.logs.extend(result.logs); + self.labeled_addresses.extend(result.labeled_addresses); + self.traces.extend(result.traces.map(|traces| (TraceKind::Execution, traces))); + self.merge_coverages(result.coverage); + + self.status = match result.success { + true => TestStatus::Success, + false => TestStatus::Failure, + }; + self.reason = result.reason; + self.counterexample = result.counterexample; + self.decoded_logs = decode_console_logs(&self.logs); + self.duration = Duration::default(); + self.gas_report_traces = result.gas_report_traces.into_iter().map(|t| vec![t]).collect(); + self.to_owned() + } + + /// Returns the skipped result for invariant test. + pub fn invariant_skip(mut self) -> Self { + self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }; + self.status = TestStatus::Skipped; + self.decoded_logs = decode_console_logs(&self.logs); + self.to_owned() + } + + /// Returns the fail result for replayed invariant test. + pub fn invariant_replay_fail( + mut self, + replayed_entirely: bool, + invariant_name: &String, + call_sequence: Vec, + ) -> Self { + self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }; + self.status = TestStatus::Failure; + self.reason = if replayed_entirely { + Some(format!("{invariant_name} replay failure")) + } else { + Some(format!("{invariant_name} persisted failure revert")) + }; + self.counterexample = Some(CounterExample::Sequence(call_sequence)); + self.decoded_logs = decode_console_logs(&self.logs); + self.to_owned() + } + + /// Returns the fail result for invariant test setup. + pub fn invariant_setup_fail(mut self, e: Report) -> Self { + self.kind = TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }; + self.status = TestStatus::Failure; + self.reason = Some(format!("failed to set up invariant testing environment: {e}")); + self.decoded_logs = decode_console_logs(&self.logs); + self.to_owned() + } + + /// Returns the invariant test result. + pub fn invariant_result( + mut self, + gas_report_traces: Vec>, + success: bool, + reason: Option, + counterexample: Option, + cases: Vec, + reverts: usize, + ) -> Self { + self.kind = TestKind::Invariant { + runs: cases.len(), + calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), + reverts, + }; + self.status = match success { + true => TestStatus::Success, + false => TestStatus::Failure, + }; + self.reason = reason; + self.counterexample = counterexample; + self.decoded_logs = decode_console_logs(&self.logs); + self.gas_report_traces = gas_report_traces; + self.to_owned() + } + /// Returns `true` if this is the result of a fuzz test pub fn is_fuzz(&self) -> bool { matches!(self.kind, TestKind::Fuzz { .. }) @@ -429,6 +594,15 @@ impl TestResult { pub fn short_result(&self, name: &str) -> String { format!("{self} {name} {}", self.kind.report()) } + + /// Function to merge given coverage in current test result coverage. + fn merge_coverages(&mut self, other_coverage: Option) { + let old_coverage = std::mem::take(&mut self.coverage); + self.coverage = match (old_coverage, other_coverage) { + (Some(old_coverage), Some(other)) => Some(old_coverage.merged(other)), + (a, b) => a.or(b), + }; + } } /// Data report by a test. diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 201494b764086..c0bb78fa26b76 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -4,7 +4,7 @@ use crate::{ fuzz::{invariant::BasicTxDetails, BaseCounterExample}, multi_runner::{is_matching_test, TestContract}, progress::{start_fuzz_progress, TestsProgress}, - result::{SuiteResult, TestKind, TestResult, TestSetup, TestStatus}, + result::{SuiteResult, TestResult, TestSetup}, TestFilter, TestOptions, }; use alloy_dyn_abi::DynSolValue; @@ -18,8 +18,7 @@ use foundry_common::{ use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_evm::{ constants::CALLER, - coverage::HitMaps, - decode::{decode_console_logs, RevertDecoder}, + decode::RevertDecoder, executors::{ fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, invariant::{ @@ -349,20 +348,7 @@ impl<'a> ContractRunner<'a> { // The setup failed, so we return a single test result for `setUp` return SuiteResult::new( start.elapsed(), - [( - "setUp()".to_string(), - TestResult { - status: TestStatus::Failure, - reason: setup.reason, - decoded_logs: decode_console_logs(&setup.logs), - logs: setup.logs, - traces: setup.traces, - coverage: setup.coverage, - labeled_addresses: setup.labeled_addresses, - ..Default::default() - }, - )] - .into(), + [("setUp()".to_string(), TestResult::setup_fail(setup))].into(), warnings, ) } @@ -454,9 +440,8 @@ impl<'a> ContractRunner<'a> { /// similar to `eth_call`. #[instrument(level = "debug", name = "normal", skip_all)] pub fn run_test(&self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { - let TestSetup { - address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. - } = setup; + let address = setup.address; + let test_result = TestResult::new(setup); // Run unit test let (mut raw_call_result, reason) = match self.executor.call( @@ -469,68 +454,13 @@ impl<'a> ContractRunner<'a> { ) { Ok(res) => (res.raw, None), Err(EvmError::Execution(err)) => (err.raw, Some(err.reason)), - Err(EvmError::SkipError) => { - return TestResult { - status: TestStatus::Skipped, - reason: None, - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - ..Default::default() - } - } - Err(err) => { - return TestResult { - status: TestStatus::Failure, - reason: Some(err.to_string()), - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - ..Default::default() - } - } + Err(EvmError::SkipError) => return test_result.single_skip(), + Err(err) => return test_result.single_fail(err), }; let success = - self.executor.is_raw_call_mut_success(setup.address, &mut raw_call_result, should_fail); - - let RawCallResult { - gas_used: gas, - stipend, - logs: execution_logs, - traces: execution_trace, - coverage: execution_coverage, - labels: new_labels, - debug, - cheatcodes, - .. - } = raw_call_result; - - let breakpoints = cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); - let debug_arena = debug; - traces.extend(execution_trace.map(|traces| (TraceKind::Execution, traces))); - labeled_addresses.extend(new_labels); - logs.extend(execution_logs); - coverage = merge_coverages(coverage, execution_coverage); - - TestResult { - status: match success { - true => TestStatus::Success, - false => TestStatus::Failure, - }, - reason, - counterexample: None, - decoded_logs: decode_console_logs(&logs), - logs, - kind: TestKind::Unit { gas: gas.wrapping_sub(stipend) }, - traces, - coverage, - labeled_addresses, - debug: debug_arena, - breakpoints, - duration: std::time::Duration::default(), - gas_report_traces: Vec::new(), - } + self.executor.is_raw_call_mut_success(address, &mut raw_call_result, should_fail); + test_result.single_result(success, reason, raw_call_result) } #[instrument(level = "debug", name = "invariant", skip_all)] @@ -545,8 +475,9 @@ impl<'a> ContractRunner<'a> { known_contracts: &ContractsByArtifact, identified_contracts: &ContractsByAddress, ) -> TestResult { - let TestSetup { address, logs, traces, labeled_addresses, coverage, fuzz_fixtures, .. } = - setup; + let address = setup.address; + let fuzz_fixtures = setup.fuzz_fixtures.clone(); + let mut test_result = TestResult::new(setup); // First, run the test normally to see if it needs to be skipped. if let Err(EvmError::SkipError) = self.executor.call( @@ -557,16 +488,7 @@ impl<'a> ContractRunner<'a> { U256::ZERO, Some(self.revert_decoder), ) { - return TestResult { - status: TestStatus::Skipped, - reason: None, - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, - coverage, - ..Default::default() - } + return test_result.invariant_skip() }; let mut evm = InvariantExecutor::new( @@ -583,10 +505,6 @@ impl<'a> ContractRunner<'a> { abi: &self.contract.abi, }; - let mut logs = logs.clone(); - let mut traces = traces.clone(); - let mut coverage = coverage.clone(); - let failure_dir = invariant_config.clone().failure_dir(self.name); let failure_file = failure_dir.join(invariant_contract.invariant_function.clone().name); @@ -622,33 +540,16 @@ impl<'a> ContractRunner<'a> { self.executor.clone(), known_contracts, identified_contracts.clone(), - &mut logs, - &mut traces, - &mut coverage, + &mut test_result.logs, + &mut test_result.traces, + &mut test_result.coverage, &txes, ); - return TestResult { - status: TestStatus::Failure, - reason: if replayed_entirely { - Some(format!( - "{} replay failure", - invariant_contract.invariant_function.name - )) - } else { - Some(format!( - "{} persisted failure revert", - invariant_contract.invariant_function.name - )) - }, - counterexample: Some(CounterExample::Sequence(call_sequence)), - decoded_logs: decode_console_logs(&logs), - logs, - kind: TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }, - coverage, - traces, - labeled_addresses, - ..Default::default() - } + return test_result.invariant_replay_fail( + replayed_entirely, + &invariant_contract.invariant_function.name, + call_sequence, + ) } } } @@ -659,19 +560,7 @@ impl<'a> ContractRunner<'a> { match evm.invariant_fuzz(invariant_contract.clone(), &fuzz_fixtures, progress.as_ref()) { Ok(x) => x, - Err(e) => { - return TestResult { - status: TestStatus::Failure, - reason: Some(format!( - "failed to set up invariant testing environment: {e}" - )), - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - kind: TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }, - ..Default::default() - } - } + Err(e) => return test_result.invariant_setup_fail(e), }; let mut counterexample = None; @@ -691,9 +580,9 @@ impl<'a> ContractRunner<'a> { self.executor.clone(), known_contracts, identified_contracts.clone(), - &mut logs, - &mut traces, - &mut coverage, + &mut test_result.logs, + &mut test_result.traces, + &mut test_result.coverage, progress.as_ref(), ) { Ok(call_sequence) => { @@ -726,9 +615,9 @@ impl<'a> ContractRunner<'a> { self.executor.clone(), known_contracts, identified_contracts.clone(), - &mut logs, - &mut traces, - &mut coverage, + &mut test_result.logs, + &mut test_result.traces, + &mut test_result.coverage, &last_run_inputs, ) { error!(%err, "Failed to replay last invariant run"); @@ -736,26 +625,14 @@ impl<'a> ContractRunner<'a> { } } - TestResult { - status: match success { - true => TestStatus::Success, - false => TestStatus::Failure, - }, + test_result.invariant_result( + gas_report_traces, + success, reason, counterexample, - decoded_logs: decode_console_logs(&logs), - logs, - kind: TestKind::Invariant { - runs: cases.len(), - calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), - reverts, - }, - coverage, - traces, - labeled_addresses, - gas_report_traces, - ..Default::default() // TODO collect debug traces on the last run or error - } + cases, + reverts, + ) } #[instrument(level = "debug", name = "fuzz", skip_all)] @@ -767,15 +644,9 @@ impl<'a> ContractRunner<'a> { setup: TestSetup, fuzz_config: FuzzConfig, ) -> TestResult { - let TestSetup { - address, - mut logs, - mut traces, - mut labeled_addresses, - mut coverage, - fuzz_fixtures, - .. - } = setup; + let address = setup.address; + let fuzz_fixtures = setup.fuzz_fixtures.clone(); + let mut test_result = TestResult::new(setup); // Run fuzz test let progress = start_fuzz_progress(self.progress, self.name, &func.name, fuzz_config.runs); @@ -794,22 +665,10 @@ impl<'a> ContractRunner<'a> { progress.as_ref(), ); - let mut debug = Default::default(); - let mut breakpoints = Default::default(); - // Check the last test result and skip the test // if it's marked as so. if let Some("SKIPPED") = result.reason.as_deref() { - return TestResult { - status: TestStatus::Skipped, - decoded_logs: decode_console_logs(&logs), - traces, - labeled_addresses, - debug, - breakpoints, - coverage, - ..Default::default() - } + return test_result.single_skip() } // if should debug @@ -834,7 +693,7 @@ impl<'a> ContractRunner<'a> { calldata, ); - (debug, breakpoints) = match debug_result { + (test_result.debug, test_result.breakpoints) = match debug_result { Ok(fuzz_outcome) => match fuzz_outcome { FuzzOutcome::Case(CaseOutcome { debug, breakpoints, .. }) => { (debug, breakpoints) @@ -848,48 +707,6 @@ impl<'a> ContractRunner<'a> { Err(_) => (Default::default(), Default::default()), }; } - - let kind = TestKind::Fuzz { - median_gas: result.median_gas(false), - mean_gas: result.mean_gas(false), - first_case: result.first_case, - runs: result.gas_by_case.len(), - }; - - // Record logs, labels and traces - logs.extend(result.logs); - labeled_addresses.extend(result.labeled_addresses); - traces.extend(result.traces.map(|traces| (TraceKind::Execution, traces))); - coverage = merge_coverages(coverage, result.coverage); - - TestResult { - status: match result.success { - true => TestStatus::Success, - false => TestStatus::Failure, - }, - reason: result.reason, - counterexample: result.counterexample, - decoded_logs: decode_console_logs(&logs), - logs, - kind, - traces, - coverage, - labeled_addresses, - debug, - breakpoints, - duration: std::time::Duration::default(), - gas_report_traces: result.gas_report_traces.into_iter().map(|t| vec![t]).collect(), - } - } -} - -/// Utility function to merge coverage options -fn merge_coverages(mut coverage: Option, other: Option) -> Option { - let old_coverage = std::mem::take(&mut coverage); - match (old_coverage, other) { - (Some(old_coverage), Some(other)) => Some(old_coverage.merged(other)), - (None, Some(other)) => Some(other), - (Some(old_coverage), None) => Some(old_coverage), - (None, None) => None, + test_result.fuzz_result(result) } } From ebe4731b1f76a92fed00ef4d24d4e6c1989065a9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:14:43 +0300 Subject: [PATCH 1124/1963] chore: remove TestResult.to_owned (#8210) --- crates/forge/src/result.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index ae25461b2db60..cdd2caf51807e 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -455,14 +455,14 @@ impl TestResult { pub fn single_skip(mut self) -> Self { self.status = TestStatus::Skipped; self.decoded_logs = decode_console_logs(&self.logs); - self.to_owned() + self } /// Returns the failed result with reason for single test. pub fn single_fail(mut self, err: EvmError) -> Self { self.status = TestStatus::Failure; self.reason = Some(err.to_string()); - self.to_owned() + self } /// Returns the result for single test. Merges execution results (logs, labeled addresses, @@ -492,7 +492,7 @@ impl TestResult { self.breakpoints = raw_call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); self.duration = Duration::default(); self.gas_report_traces = Vec::new(); - self.to_owned() + self } /// Returns the result for a fuzzed test. Merges fuzz execution results (logs, labeled @@ -520,7 +520,7 @@ impl TestResult { self.decoded_logs = decode_console_logs(&self.logs); self.duration = Duration::default(); self.gas_report_traces = result.gas_report_traces.into_iter().map(|t| vec![t]).collect(); - self.to_owned() + self } /// Returns the skipped result for invariant test. @@ -528,7 +528,7 @@ impl TestResult { self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }; self.status = TestStatus::Skipped; self.decoded_logs = decode_console_logs(&self.logs); - self.to_owned() + self } /// Returns the fail result for replayed invariant test. @@ -547,7 +547,7 @@ impl TestResult { }; self.counterexample = Some(CounterExample::Sequence(call_sequence)); self.decoded_logs = decode_console_logs(&self.logs); - self.to_owned() + self } /// Returns the fail result for invariant test setup. @@ -556,7 +556,7 @@ impl TestResult { self.status = TestStatus::Failure; self.reason = Some(format!("failed to set up invariant testing environment: {e}")); self.decoded_logs = decode_console_logs(&self.logs); - self.to_owned() + self } /// Returns the invariant test result. @@ -582,7 +582,7 @@ impl TestResult { self.counterexample = counterexample; self.decoded_logs = decode_console_logs(&self.logs); self.gas_report_traces = gas_report_traces; - self.to_owned() + self } /// Returns `true` if this is the result of a fuzz test From bde40a8cb4ef80be34c8d6723321f80761b5b159 Mon Sep 17 00:00:00 2001 From: Frontier <103474701+frontier159@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:25:41 +1000 Subject: [PATCH 1125/1963] feat: add --no-request-size-limit option to anvil (#8209) * feat: add --no-request-size-limit option to anvil * chore: flip logic, fmt, improve cli help * nit --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/anvil/server/src/config.rs | 34 +++++++++++++++---------------- crates/anvil/server/src/lib.rs | 6 +++++- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/crates/anvil/server/src/config.rs b/crates/anvil/server/src/config.rs index ea97d24cd7674..dd15959b113a6 100644 --- a/crates/anvil/server/src/config.rs +++ b/crates/anvil/server/src/config.rs @@ -7,41 +7,39 @@ use std::str::FromStr; #[cfg_attr(feature = "clap", derive(clap::Parser), command(next_help_heading = "Server options"))] pub struct ServerConfig { /// The cors `allow_origin` header - #[cfg_attr( - feature = "clap", - arg( - long, - help = "Set the CORS allow_origin", - default_value = "*", - value_name = "ALLOW_ORIGIN" - ) - )] + #[cfg_attr(feature = "clap", arg(long, default_value = "*"))] pub allow_origin: HeaderValueWrapper, - /// Whether to enable CORS - #[cfg_attr( - feature = "clap", - arg(long, help = "Disable CORS", conflicts_with = "allow_origin") - )] + + /// Disable CORS. + #[cfg_attr(feature = "clap", arg(long, conflicts_with = "allow_origin"))] pub no_cors: bool, + + /// Disable the default request body size limit. At time of writing the default limit is 2MB. + #[cfg_attr(feature = "clap", arg(long))] + pub no_request_size_limit: bool, } impl ServerConfig { - /// Sets the "allow origin" header for cors + /// Sets the "allow origin" header for CORS. pub fn with_allow_origin(mut self, allow_origin: impl Into) -> Self { self.allow_origin = allow_origin.into(); self } - /// Whether to enable CORS + /// Whether to enable CORS. pub fn set_cors(mut self, cors: bool) -> Self { - self.no_cors = cors; + self.no_cors = !cors; self } } impl Default for ServerConfig { fn default() -> Self { - Self { allow_origin: "*".parse::().unwrap().into(), no_cors: false } + Self { + allow_origin: "*".parse::().unwrap().into(), + no_cors: false, + no_request_size_limit: false, + } } } diff --git a/crates/anvil/server/src/lib.rs b/crates/anvil/server/src/lib.rs index b60182505933e..07567466772e5 100644 --- a/crates/anvil/server/src/lib.rs +++ b/crates/anvil/server/src/lib.rs @@ -12,6 +12,7 @@ use anvil_rpc::{ response::{ResponseResult, RpcResponse}, }; use axum::{ + extract::DefaultBodyLimit, http::{header, HeaderValue, Method}, routing::{post, MethodRouter}, Router, @@ -56,7 +57,7 @@ fn router_inner( root_method_router: MethodRouter, state: S, ) -> Router { - let ServerConfig { allow_origin, no_cors } = config; + let ServerConfig { allow_origin, no_cors, no_request_size_limit } = config; let mut router = Router::new() .route("/", root_method_router) @@ -72,6 +73,9 @@ fn router_inner( .allow_methods([Method::GET, Method::POST]), ); } + if no_request_size_limit { + router = router.layer(DefaultBodyLimit::disable()); + } router } From 034393cc25fe84e35d89f5066775d9088db1de57 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:52:44 +0200 Subject: [PATCH 1126/1963] chore: fix more clippy (#8211) * chore: fix more clippy * chore: missing lints.workspace * docs --- Cargo.toml | 6 +- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- crates/anvil/server/src/pubsub.rs | 2 +- crates/anvil/src/eth/otterscan/types.rs | 8 +- crates/anvil/tests/it/eip4844.rs | 2 +- crates/anvil/tests/it/fork.rs | 4 +- crates/anvil/tests/it/main.rs | 1 - crates/cheatcodes/src/inspector.rs | 2 +- crates/chisel/src/executor.rs | 3 +- crates/chisel/src/session_source.rs | 2 +- crates/common/src/abi.rs | 3 +- crates/common/src/provider/mod.rs | 4 +- crates/common/src/selectors.rs | 2 +- crates/config/Cargo.toml | 3 + crates/config/src/cache.rs | 50 ++++---- crates/config/src/endpoints.rs | 56 +++++---- crates/config/src/error.rs | 114 +++++++++--------- crates/config/src/etherscan.rs | 26 ++--- crates/config/src/filter.rs | 12 +- crates/config/src/fmt.rs | 20 ++-- crates/config/src/fs_permissions.rs | 39 +++---- crates/config/src/fuzz.rs | 6 +- crates/config/src/inline/natspec.rs | 4 +- crates/config/src/invariant.rs | 4 +- crates/config/src/lib.rs | 115 +++++++++---------- crates/config/src/providers/mod.rs | 2 +- crates/config/src/resolve.rs | 2 +- crates/config/src/soldeer.rs | 7 +- crates/config/src/utils.rs | 4 +- crates/config/src/vyper.rs | 2 +- crates/doc/src/parser/comment.rs | 4 +- crates/doc/src/parser/item.rs | 2 +- crates/evm/core/src/utils.rs | 3 +- crates/evm/traces/src/lib.rs | 2 +- crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/flatten.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 2 +- crates/forge/bin/cmd/selectors.rs | 2 +- crates/forge/tests/it/config.rs | 3 +- crates/forge/tests/it/invariant.rs | 2 +- crates/forge/tests/it/test_helpers.rs | 2 +- crates/script/src/build.rs | 1 + crates/sol-macro-gen/Cargo.toml | 3 + crates/sol-macro-gen/src/sol_macro_gen.rs | 31 +++-- crates/verify/src/etherscan/flatten.rs | 2 +- 45 files changed, 279 insertions(+), 291 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 48178e69ce73f..5e6bbc4541ed9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,11 +41,13 @@ dbg-macro = "warn" manual-string-new = "warn" uninlined-format-args = "warn" use-self = "warn" +redundant-clone = "warn" +octal-escapes = "allow" [workspace.lints.rust] -rust-2018-idioms = "deny" +rust-2018-idioms = "warn" # unreachable-pub = "warn" -unused-must-use = "deny" +unused-must-use = "warn" [workspace.lints.rustdoc] all = "warn" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 83db644652b37..b22cc82fb1551 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1402,7 +1402,7 @@ mod tests { let signature = Signature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap(); let tx = TypedTransaction::Legacy(Signed::new_unchecked( - tx.clone(), + tx, signature, b256!("a517b206d2223278f860ea017d3626cacad4f52ff51030dc9a96b432f17f8d34"), )); diff --git a/crates/anvil/server/src/pubsub.rs b/crates/anvil/server/src/pubsub.rs index 2fe4358ef0ca8..8e5ac9b3849bb 100644 --- a/crates/anvil/server/src/pubsub.rs +++ b/crates/anvil/server/src/pubsub.rs @@ -167,7 +167,7 @@ where let pin = self.get_mut(); loop { // drive the websocket - while let Poll::Ready(Ok(())) = pin.connection.poll_ready_unpin(cx) { + while matches!(pin.connection.poll_ready_unpin(cx), Poll::Ready(Ok(()))) { // only start sending if socket is ready if let Some(msg) = pin.pending.pop_front() { if let Err(err) = pin.connection.start_send_unpin(msg) { diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 5e104e6036c00..2c2a0ad7ebc36 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -79,7 +79,7 @@ pub struct OtsSearchTransactions { /// Otterscan format for listing relevant internal operations. /// /// Ref: -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Eq, Serialize)] #[serde(rename_all = "camelCase")] pub struct OtsInternalOperation { pub r#type: OtsInternalOperationType, @@ -91,7 +91,7 @@ pub struct OtsInternalOperation { /// Types of internal operations recognized by Otterscan. /// /// Ref: -#[derive(Debug, PartialEq, Serialize_repr)] +#[derive(Debug, PartialEq, Eq, Serialize_repr)] #[repr(u8)] pub enum OtsInternalOperationType { Transfer = 0, @@ -101,7 +101,7 @@ pub enum OtsInternalOperationType { } /// Otterscan's representation of a trace -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Eq, Serialize)] pub struct OtsTrace { pub r#type: OtsTraceType, pub depth: usize, @@ -115,7 +115,7 @@ pub struct OtsTrace { /// The type of call being described by an Otterscan trace. Only CALL, STATICCALL and DELEGATECALL /// are represented -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Eq, Serialize)] #[serde(rename_all = "UPPERCASE")] pub enum OtsTraceType { Call, diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 19842aa75d1ab..40d5a63a6c3dc 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -21,7 +21,7 @@ async fn can_send_eip4844_transaction() { let eip1559_est = provider.estimate_eip1559_fees(None).await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let sidecar: SidecarBuilder = SidecarBuilder::from_slice("Hello World".as_bytes()); + let sidecar: SidecarBuilder = SidecarBuilder::from_slice(b"Hello World"); let sidecar = sidecar.build().unwrap(); let tx = TransactionRequest::default() diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index a94dc4c4dfcfe..8f3859f7f324a 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -5,7 +5,7 @@ use crate::{ utils::{http_provider, http_provider_with_signer}, }; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{address, Address, Bytes, TxKind, U256}; +use alloy_primitives::{address, bytes, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ anvil::Forking, @@ -1191,7 +1191,7 @@ async fn test_fork_execution_reverted() { .call( WithOtherFields::new(TransactionRequest { to: Some(TxKind::from(address!("Fd6CC4F251eaE6d02f9F7B41D1e80464D3d2F377"))), - input: TransactionInput::new("0x8f283b3c".as_bytes().into()), + input: TransactionInput::new(bytes!("8f283b3c")), ..Default::default() }), Some(target.into()), diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 559593b72f641..5337e5bbd30b0 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -1,4 +1,3 @@ -#![allow(clippy::octal_escapes)] mod abi; mod anvil; mod anvil_api; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index e719ffe837792..3e7e561be6ec5 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1225,7 +1225,7 @@ impl Cheatcodes { } _ => { // if just starting with CREATE opcodes, record its inner frame gas - if let Some(None) = self.gas_metering_create { + if self.gas_metering_create == Some(None) { self.gas_metering_create = Some(Some(interpreter.gas)) } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 58059a0ac1286..5aa2190df5890 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -417,8 +417,7 @@ fn format_token(token: DynSolValue) -> String { DynSolValue::Tuple(tokens) => { let displayed_types = tokens .iter() - .map(|t| t.sol_type_name().to_owned()) - .map(|t| t.unwrap_or_default().into_owned()) + .map(|t| t.sol_type_name().unwrap_or_default()) .collect::>() .join(", "); let mut out = diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index f83eefeae80ca..5ba75238a2ad1 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -520,7 +520,7 @@ contract {contract_name} {{ pt::Import::Rename(s, _, _) | pt::Import::GlobalSymbol(s, _, _) => { let s = match s { - pt::ImportPath::Filename(s) => s.string.clone(), + pt::ImportPath::Filename(s) => s.string, pt::ImportPath::Path(p) => p.to_string(), }; let path = PathBuf::from(s); diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index 6b7615b39c9f2..a7c545bc82c6b 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -198,8 +198,7 @@ mod tests { let param0 = B256::random(); let param1 = vec![3; 32]; let param2 = B256::random(); - let log = - LogData::new_unchecked(vec![event.selector(), param0, param2], param1.clone().into()); + let log = LogData::new_unchecked(vec![event.selector(), param0, param2], param1.into()); let event = get_indexed_event(event, &log); assert_eq!(event.inputs.len(), 3); diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index ef7b62055c1df..36efe75e87c04 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -255,7 +255,7 @@ impl ProviderBuilder { initial_backoff, compute_units_per_second, ); - let transport = RuntimeTransportBuilder::new(url.clone()) + let transport = RuntimeTransportBuilder::new(url) .with_timeout(timeout) .with_headers(headers) .with_jwt(jwt) @@ -291,7 +291,7 @@ impl ProviderBuilder { compute_units_per_second, ); - let transport = RuntimeTransportBuilder::new(url.clone()) + let transport = RuntimeTransportBuilder::new(url) .with_timeout(timeout) .with_headers(headers) .with_jwt(jwt) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index a051db1f0a30e..eb604537c732c 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -529,7 +529,7 @@ pub async fn import_selectors(data: SelectorImportData) -> eyre::Result, diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 81066206ab354..c29a5fd44c01b 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -10,6 +10,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-compilers = { workspace = true, features = ["svm-solc"] } diff --git a/crates/config/src/cache.rs b/crates/config/src/cache.rs index 58b3b8cbea30f..d087b5e6a2c2e 100644 --- a/crates/config/src/cache.rs +++ b/crates/config/src/cache.rs @@ -45,9 +45,9 @@ impl CachedChains { /// Whether the `endpoint` matches pub fn is_match(&self, chain: u64) -> bool { match self { - CachedChains::All => true, - CachedChains::None => false, - CachedChains::Chains(chains) => chains.iter().any(|c| c.id() == chain), + Self::All => true, + Self::None => false, + Self::Chains(chains) => chains.iter().any(|c| c.id() == chain), } } } @@ -58,9 +58,9 @@ impl Serialize for CachedChains { S: Serializer, { match self { - CachedChains::All => serializer.serialize_str("all"), - CachedChains::None => serializer.serialize_str("none"), - CachedChains::Chains(chains) => chains.serialize(serializer), + Self::All => serializer.serialize_str("all"), + Self::None => serializer.serialize_str("none"), + Self::Chains(chains) => chains.serialize(serializer), } } } @@ -79,11 +79,11 @@ impl<'de> Deserialize<'de> for CachedChains { match Chains::deserialize(deserializer)? { Chains::All(s) => match s.as_str() { - "all" => Ok(CachedChains::All), - "none" => Ok(CachedChains::None), + "all" => Ok(Self::All), + "none" => Ok(Self::None), s => Err(serde::de::Error::unknown_variant(s, &["all", "none"])), }, - Chains::Chains(chains) => Ok(CachedChains::Chains(chains)), + Chains::Chains(chains) => Ok(Self::Chains(chains)), } } } @@ -105,11 +105,9 @@ impl CachedEndpoints { pub fn is_match(&self, endpoint: impl AsRef) -> bool { let endpoint = endpoint.as_ref(); match self { - CachedEndpoints::All => true, - CachedEndpoints::Remote => { - !endpoint.contains("localhost:") && !endpoint.contains("127.0.0.1:") - } - CachedEndpoints::Pattern(re) => re.is_match(endpoint), + Self::All => true, + Self::Remote => !endpoint.contains("localhost:") && !endpoint.contains("127.0.0.1:"), + Self::Pattern(re) => re.is_match(endpoint), } } } @@ -117,9 +115,9 @@ impl CachedEndpoints { impl PartialEq for CachedEndpoints { fn eq(&self, other: &Self) -> bool { match (self, other) { - (CachedEndpoints::Pattern(a), CachedEndpoints::Pattern(b)) => a.as_str() == b.as_str(), - (&CachedEndpoints::All, &CachedEndpoints::All) => true, - (&CachedEndpoints::Remote, &CachedEndpoints::Remote) => true, + (Self::Pattern(a), Self::Pattern(b)) => a.as_str() == b.as_str(), + (&Self::All, &Self::All) => true, + (&Self::Remote, &Self::Remote) => true, _ => false, } } @@ -130,9 +128,9 @@ impl Eq for CachedEndpoints {} impl fmt::Display for CachedEndpoints { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - CachedEndpoints::All => f.write_str("all"), - CachedEndpoints::Remote => f.write_str("remote"), - CachedEndpoints::Pattern(s) => s.fmt(f), + Self::All => f.write_str("all"), + Self::Remote => f.write_str("remote"), + Self::Pattern(s) => s.fmt(f), } } } @@ -142,9 +140,9 @@ impl FromStr for CachedEndpoints { fn from_str(s: &str) -> Result { match s { - "all" => Ok(CachedEndpoints::All), - "remote" => Ok(CachedEndpoints::Remote), - _ => Ok(CachedEndpoints::Pattern(s.parse()?)), + "all" => Ok(Self::All), + "remote" => Ok(Self::Remote), + _ => Ok(Self::Pattern(s.parse()?)), } } } @@ -164,9 +162,9 @@ impl Serialize for CachedEndpoints { S: Serializer, { match self { - CachedEndpoints::All => serializer.serialize_str("all"), - CachedEndpoints::Remote => serializer.serialize_str("remote"), - CachedEndpoints::Pattern(pattern) => serializer.serialize_str(pattern.as_str()), + Self::All => serializer.serialize_str("all"), + Self::Remote => serializer.serialize_str("remote"), + Self::Pattern(pattern) => serializer.serialize_str(pattern.as_str()), } } } diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index 74157b0e918ce..eabc5acb196ec 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -68,16 +68,16 @@ impl RpcEndpointType { /// Returns the string variant pub fn as_endpoint_string(&self) -> Option<&RpcEndpoint> { match self { - RpcEndpointType::String(url) => Some(url), - RpcEndpointType::Config(_) => None, + Self::String(url) => Some(url), + Self::Config(_) => None, } } /// Returns the config variant pub fn as_endpoint_config(&self) -> Option<&RpcEndpointConfig> { match self { - RpcEndpointType::Config(config) => Some(config), - RpcEndpointType::String(_) => None, + Self::Config(config) => Some(config), + Self::String(_) => None, } } @@ -88,8 +88,8 @@ impl RpcEndpointType { /// Returns an error if the type holds a reference to an env var and the env var is not set pub fn resolve(self) -> Result { match self { - RpcEndpointType::String(url) => url.resolve(), - RpcEndpointType::Config(config) => config.endpoint.resolve(), + Self::String(url) => url.resolve(), + Self::Config(config) => config.endpoint.resolve(), } } } @@ -97,8 +97,8 @@ impl RpcEndpointType { impl fmt::Display for RpcEndpointType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - RpcEndpointType::String(url) => url.fmt(f), - RpcEndpointType::Config(config) => config.fmt(f), + Self::String(url) => url.fmt(f), + Self::Config(config) => config.fmt(f), } } } @@ -134,16 +134,16 @@ impl RpcEndpoint { /// Returns the url variant pub fn as_url(&self) -> Option<&str> { match self { - RpcEndpoint::Url(url) => Some(url), - RpcEndpoint::Env(_) => None, + Self::Url(url) => Some(url), + Self::Env(_) => None, } } /// Returns the env variant pub fn as_env(&self) -> Option<&str> { match self { - RpcEndpoint::Env(val) => Some(val), - RpcEndpoint::Url(_) => None, + Self::Env(val) => Some(val), + Self::Url(_) => None, } } @@ -154,8 +154,8 @@ impl RpcEndpoint { /// Returns an error if the type holds a reference to an env var and the env var is not set pub fn resolve(self) -> Result { match self { - RpcEndpoint::Url(url) => Ok(url), - RpcEndpoint::Env(val) => interpolate(&val), + Self::Url(url) => Ok(url), + Self::Env(val) => interpolate(&val), } } } @@ -163,8 +163,8 @@ impl RpcEndpoint { impl fmt::Display for RpcEndpoint { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - RpcEndpoint::Url(url) => url.fmt(f), - RpcEndpoint::Env(var) => var.fmt(f), + Self::Url(url) => url.fmt(f), + Self::Env(var) => var.fmt(f), } } } @@ -192,11 +192,7 @@ impl<'de> Deserialize<'de> for RpcEndpoint { D: Deserializer<'de>, { let val = String::deserialize(deserializer)?; - let endpoint = if RE_PLACEHOLDER.is_match(&val) { - RpcEndpoint::Env(val) - } else { - RpcEndpoint::Url(val) - }; + let endpoint = if RE_PLACEHOLDER.is_match(&val) { Self::Env(val) } else { Self::Url(val) }; Ok(endpoint) } @@ -204,13 +200,13 @@ impl<'de> Deserialize<'de> for RpcEndpoint { impl From for RpcEndpointType { fn from(endpoint: RpcEndpoint) -> Self { - RpcEndpointType::String(endpoint) + Self::String(endpoint) } } impl From for RpcEndpointConfig { fn from(endpoint: RpcEndpoint) -> Self { - RpcEndpointConfig { endpoint, ..Default::default() } + Self { endpoint, ..Default::default() } } } @@ -241,20 +237,20 @@ impl RpcEndpointConfig { impl fmt::Display for RpcEndpointConfig { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let RpcEndpointConfig { endpoint, retries, retry_backoff, compute_units_per_second } = self; + let Self { endpoint, retries, retry_backoff, compute_units_per_second } = self; - write!(f, "{}", endpoint)?; + write!(f, "{endpoint}")?; if let Some(retries) = retries { - write!(f, ", retries={}", retries)?; + write!(f, ", retries={retries}")?; } if let Some(retry_backoff) = retry_backoff { - write!(f, ", retry_backoff={}", retry_backoff)?; + write!(f, ", retry_backoff={retry_backoff}")?; } if let Some(compute_units_per_second) = compute_units_per_second { - write!(f, ", compute_units_per_second={}", compute_units_per_second)?; + write!(f, ", compute_units_per_second={compute_units_per_second}")?; } Ok(()) @@ -308,13 +304,13 @@ impl<'de> Deserialize<'de> for RpcEndpointConfig { let RpcEndpointConfigInner { endpoint, retries, retry_backoff, compute_units_per_second } = serde_json::from_value(value).map_err(serde::de::Error::custom)?; - Ok(RpcEndpointConfig { endpoint, retries, retry_backoff, compute_units_per_second }) + Ok(Self { endpoint, retries, retry_backoff, compute_units_per_second }) } } impl From for RpcEndpointType { fn from(config: RpcEndpointConfig) -> Self { - RpcEndpointType::Config(config) + Self::Config(config) } } diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 016e32c470ab8..3da1aee09e564 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -75,11 +75,11 @@ impl fmt::Display for FoundryConfigError { }; match self { - FoundryConfigError::Toml(err) => { + Self::Toml(err) => { f.write_str("foundry.toml error: ")?; fmt_err(err, f) } - FoundryConfigError::Other(err) => { + Self::Other(err) => { f.write_str("foundry config error: ")?; fmt_err(err, f) } @@ -90,9 +90,7 @@ impl fmt::Display for FoundryConfigError { impl Error for FoundryConfigError { fn source(&self) -> Option<&(dyn Error + 'static)> { match self { - FoundryConfigError::Other(error) | FoundryConfigError::Toml(error) => { - Error::source(error) - } + Self::Other(error) | Self::Toml(error) => Error::source(error), } } } @@ -148,31 +146,31 @@ impl SolidityErrorCode { /// Returns `Err(code)` if unknown error pub fn as_str(&self) -> Result<&'static str, u64> { let s = match self { - SolidityErrorCode::SpdxLicenseNotProvided => "license", - SolidityErrorCode::VisibilityForConstructorIsIgnored => "constructor-visibility", - SolidityErrorCode::ContractExceeds24576Bytes => "code-size", - SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes => "init-code-size", - SolidityErrorCode::FunctionStateMutabilityCanBeRestricted => "func-mutability", - SolidityErrorCode::UnusedLocalVariable => "unused-var", - SolidityErrorCode::UnusedFunctionParameter => "unused-param", - SolidityErrorCode::ReturnValueOfCallsNotUsed => "unused-return", - SolidityErrorCode::InterfacesExplicitlyVirtual => "virtual-interfaces", - SolidityErrorCode::PayableNoReceiveEther => "missing-receive-ether", - SolidityErrorCode::ShadowsExistingDeclaration => "shadowing", - SolidityErrorCode::DeclarationSameNameAsAnother => "same-varname", - SolidityErrorCode::UnnamedReturnVariable => "unnamed-return", - SolidityErrorCode::Unreachable => "unreachable", - SolidityErrorCode::PragmaSolidity => "pragma-solidity", - SolidityErrorCode::TransientStorageUsed => "transient-storage", - SolidityErrorCode::TooManyWarnings => "too-many-warnings", - SolidityErrorCode::Other(code) => return Err(*code), + Self::SpdxLicenseNotProvided => "license", + Self::VisibilityForConstructorIsIgnored => "constructor-visibility", + Self::ContractExceeds24576Bytes => "code-size", + Self::ContractInitCodeSizeExceeds49152Bytes => "init-code-size", + Self::FunctionStateMutabilityCanBeRestricted => "func-mutability", + Self::UnusedLocalVariable => "unused-var", + Self::UnusedFunctionParameter => "unused-param", + Self::ReturnValueOfCallsNotUsed => "unused-return", + Self::InterfacesExplicitlyVirtual => "virtual-interfaces", + Self::PayableNoReceiveEther => "missing-receive-ether", + Self::ShadowsExistingDeclaration => "shadowing", + Self::DeclarationSameNameAsAnother => "same-varname", + Self::UnnamedReturnVariable => "unnamed-return", + Self::Unreachable => "unreachable", + Self::PragmaSolidity => "pragma-solidity", + Self::TransientStorageUsed => "transient-storage", + Self::TooManyWarnings => "too-many-warnings", + Self::Other(code) => return Err(*code), }; Ok(s) } } impl From for u64 { - fn from(code: SolidityErrorCode) -> u64 { + fn from(code: SolidityErrorCode) -> Self { match code { SolidityErrorCode::SpdxLicenseNotProvided => 1878, SolidityErrorCode::VisibilityForConstructorIsIgnored => 2462, @@ -210,23 +208,23 @@ impl FromStr for SolidityErrorCode { fn from_str(s: &str) -> Result { let code = match s { - "license" => SolidityErrorCode::SpdxLicenseNotProvided, - "constructor-visibility" => SolidityErrorCode::VisibilityForConstructorIsIgnored, - "code-size" => SolidityErrorCode::ContractExceeds24576Bytes, - "init-code-size" => SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes, - "func-mutability" => SolidityErrorCode::FunctionStateMutabilityCanBeRestricted, - "unused-var" => SolidityErrorCode::UnusedLocalVariable, - "unused-param" => SolidityErrorCode::UnusedFunctionParameter, - "unused-return" => SolidityErrorCode::ReturnValueOfCallsNotUsed, - "virtual-interfaces" => SolidityErrorCode::InterfacesExplicitlyVirtual, - "missing-receive-ether" => SolidityErrorCode::PayableNoReceiveEther, - "shadowing" => SolidityErrorCode::ShadowsExistingDeclaration, - "same-varname" => SolidityErrorCode::DeclarationSameNameAsAnother, - "unnamed-return" => SolidityErrorCode::UnnamedReturnVariable, - "unreachable" => SolidityErrorCode::Unreachable, - "pragma-solidity" => SolidityErrorCode::PragmaSolidity, - "transient-storage" => SolidityErrorCode::TransientStorageUsed, - "too-many-warnings" => SolidityErrorCode::TooManyWarnings, + "license" => Self::SpdxLicenseNotProvided, + "constructor-visibility" => Self::VisibilityForConstructorIsIgnored, + "code-size" => Self::ContractExceeds24576Bytes, + "init-code-size" => Self::ContractInitCodeSizeExceeds49152Bytes, + "func-mutability" => Self::FunctionStateMutabilityCanBeRestricted, + "unused-var" => Self::UnusedLocalVariable, + "unused-param" => Self::UnusedFunctionParameter, + "unused-return" => Self::ReturnValueOfCallsNotUsed, + "virtual-interfaces" => Self::InterfacesExplicitlyVirtual, + "missing-receive-ether" => Self::PayableNoReceiveEther, + "shadowing" => Self::ShadowsExistingDeclaration, + "same-varname" => Self::DeclarationSameNameAsAnother, + "unnamed-return" => Self::UnnamedReturnVariable, + "unreachable" => Self::Unreachable, + "pragma-solidity" => Self::PragmaSolidity, + "transient-storage" => Self::TransientStorageUsed, + "too-many-warnings" => Self::TooManyWarnings, _ => return Err(format!("Unknown variant {s}")), }; @@ -237,23 +235,23 @@ impl FromStr for SolidityErrorCode { impl From for SolidityErrorCode { fn from(code: u64) -> Self { match code { - 1878 => SolidityErrorCode::SpdxLicenseNotProvided, - 2462 => SolidityErrorCode::VisibilityForConstructorIsIgnored, - 5574 => SolidityErrorCode::ContractExceeds24576Bytes, - 3860 => SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes, - 2018 => SolidityErrorCode::FunctionStateMutabilityCanBeRestricted, - 2072 => SolidityErrorCode::UnusedLocalVariable, - 5667 => SolidityErrorCode::UnusedFunctionParameter, - 9302 => SolidityErrorCode::ReturnValueOfCallsNotUsed, - 5815 => SolidityErrorCode::InterfacesExplicitlyVirtual, - 3628 => SolidityErrorCode::PayableNoReceiveEther, - 2519 => SolidityErrorCode::ShadowsExistingDeclaration, - 8760 => SolidityErrorCode::DeclarationSameNameAsAnother, - 6321 => SolidityErrorCode::UnnamedReturnVariable, - 5740 => SolidityErrorCode::Unreachable, - 3420 => SolidityErrorCode::PragmaSolidity, - 2394 => SolidityErrorCode::TransientStorageUsed, - other => SolidityErrorCode::Other(other), + 1878 => Self::SpdxLicenseNotProvided, + 2462 => Self::VisibilityForConstructorIsIgnored, + 5574 => Self::ContractExceeds24576Bytes, + 3860 => Self::ContractInitCodeSizeExceeds49152Bytes, + 2018 => Self::FunctionStateMutabilityCanBeRestricted, + 2072 => Self::UnusedLocalVariable, + 5667 => Self::UnusedFunctionParameter, + 9302 => Self::ReturnValueOfCallsNotUsed, + 5815 => Self::InterfacesExplicitlyVirtual, + 3628 => Self::PayableNoReceiveEther, + 2519 => Self::ShadowsExistingDeclaration, + 8760 => Self::DeclarationSameNameAsAnother, + 6321 => Self::UnnamedReturnVariable, + 5740 => Self::Unreachable, + 3420 => Self::PragmaSolidity, + 2394 => Self::TransientStorageUsed, + other => Self::Other(other), } } } diff --git a/crates/config/src/etherscan.rs b/crates/config/src/etherscan.rs index c4f3fe700ea91..9dde4b733a543 100644 --- a/crates/config/src/etherscan.rs +++ b/crates/config/src/etherscan.rs @@ -188,7 +188,7 @@ impl EtherscanConfig { self, alias: Option<&str>, ) -> Result { - let EtherscanConfig { chain, mut url, key } = self; + let Self { chain, mut url, key } = self; if let Some(url) = &mut url { *url = interpolate(url)?; @@ -294,7 +294,7 @@ impl ResolvedEtherscanConfig { self, ) -> Result { - let ResolvedEtherscanConfig { api_url, browser_url, key: api_key, chain } = self; + let Self { api_url, browser_url, key: api_key, chain } = self; let (mainnet_api, mainnet_url) = NamedChain::Mainnet.etherscan_urls().expect("exist; qed"); let cache = chain @@ -346,16 +346,16 @@ impl EtherscanApiKey { /// Returns the key variant pub fn as_key(&self) -> Option<&str> { match self { - EtherscanApiKey::Key(url) => Some(url), - EtherscanApiKey::Env(_) => None, + Self::Key(url) => Some(url), + Self::Env(_) => None, } } /// Returns the env variant pub fn as_env(&self) -> Option<&str> { match self { - EtherscanApiKey::Env(val) => Some(val), - EtherscanApiKey::Key(_) => None, + Self::Env(val) => Some(val), + Self::Key(_) => None, } } @@ -366,8 +366,8 @@ impl EtherscanApiKey { /// Returns an error if the type holds a reference to an env var and the env var is not set pub fn resolve(self) -> Result { match self { - EtherscanApiKey::Key(key) => Ok(key), - EtherscanApiKey::Env(val) => interpolate(&val), + Self::Key(key) => Ok(key), + Self::Env(val) => interpolate(&val), } } } @@ -387,11 +387,7 @@ impl<'de> Deserialize<'de> for EtherscanApiKey { D: Deserializer<'de>, { let val = String::deserialize(deserializer)?; - let endpoint = if RE_PLACEHOLDER.is_match(&val) { - EtherscanApiKey::Env(val) - } else { - EtherscanApiKey::Key(val) - }; + let endpoint = if RE_PLACEHOLDER.is_match(&val) { Self::Env(val) } else { Self::Key(val) }; Ok(endpoint) } @@ -400,8 +396,8 @@ impl<'de> Deserialize<'de> for EtherscanApiKey { impl fmt::Display for EtherscanApiKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - EtherscanApiKey::Key(key) => key.fmt(f), - EtherscanApiKey::Env(var) => var.fmt(f), + Self::Key(key) => key.fmt(f), + Self::Env(var) => var.fmt(f), } } } diff --git a/crates/config/src/filter.rs b/crates/config/src/filter.rs index 385b442256aa7..b7b3a3ab3ace3 100644 --- a/crates/config/src/filter.rs +++ b/crates/config/src/filter.rs @@ -144,18 +144,18 @@ pub enum SkipBuildFilter { impl SkipBuildFilter { fn new(s: &str) -> Self { match s { - "test" | "tests" => SkipBuildFilter::Tests, - "script" | "scripts" => SkipBuildFilter::Scripts, - s => SkipBuildFilter::Custom(s.to_string()), + "test" | "tests" => Self::Tests, + "script" | "scripts" => Self::Scripts, + s => Self::Custom(s.to_string()), } } /// Returns the pattern to match against a file pub fn file_pattern(&self) -> &str { match self { - SkipBuildFilter::Tests => ".t.sol", - SkipBuildFilter::Scripts => ".s.sol", - SkipBuildFilter::Custom(s) => s.as_str(), + Self::Tests => ".t.sol", + Self::Scripts => ".s.sol", + Self::Custom(s) => s.as_str(), } } } diff --git a/crates/config/src/fmt.rs b/crates/config/src/fmt.rs index a1cc66c080648..e1ebf720765bc 100644 --- a/crates/config/src/fmt.rs +++ b/crates/config/src/fmt.rs @@ -65,19 +65,19 @@ impl NumberUnderscore { /// Returns true if the option is `Preserve` #[inline] pub fn is_preserve(self) -> bool { - matches!(self, NumberUnderscore::Preserve) + matches!(self, Self::Preserve) } /// Returns true if the option is `Remove` #[inline] pub fn is_remove(self) -> bool { - matches!(self, NumberUnderscore::Remove) + matches!(self, Self::Remove) } /// Returns true if the option is `Remove` #[inline] pub fn is_thousands(self) -> bool { - matches!(self, NumberUnderscore::Thousands) + matches!(self, Self::Thousands) } } @@ -98,19 +98,19 @@ impl HexUnderscore { /// Returns true if the option is `Preserve` #[inline] pub fn is_preserve(self) -> bool { - matches!(self, HexUnderscore::Preserve) + matches!(self, Self::Preserve) } /// Returns true if the option is `Remove` #[inline] pub fn is_remove(self) -> bool { - matches!(self, HexUnderscore::Remove) + matches!(self, Self::Remove) } /// Returns true if the option is `Remove` #[inline] pub fn is_bytes(self) -> bool { - matches!(self, HexUnderscore::Bytes) + matches!(self, Self::Bytes) } } @@ -130,9 +130,9 @@ impl QuoteStyle { /// Get associated quotation mark with option pub fn quote(self) -> Option { match self { - QuoteStyle::Double => Some('"'), - QuoteStyle::Single => Some('\''), - QuoteStyle::Preserve => None, + Self::Double => Some('"'), + Self::Single => Some('\''), + Self::Preserve => None, } } } @@ -164,7 +164,7 @@ pub enum MultilineFuncHeaderStyle { impl Default for FormatterConfig { fn default() -> Self { - FormatterConfig { + Self { line_length: 120, tab_width: 4, bracket_spacing: false, diff --git a/crates/config/src/fs_permissions.rs b/crates/config/src/fs_permissions.rs index 5260b7488f5ae..1d2c35ff33bf9 100644 --- a/crates/config/src/fs_permissions.rs +++ b/crates/config/src/fs_permissions.rs @@ -148,8 +148,8 @@ pub enum FsAccessKind { impl fmt::Display for FsAccessKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - FsAccessKind::Read => f.write_str("read"), - FsAccessKind::Write => f.write_str("write"), + Self::Read => f.write_str("read"), + Self::Write => f.write_str("write"), } } } @@ -172,10 +172,10 @@ impl FsAccessPermission { /// Returns true if the access is allowed pub fn is_granted(&self, kind: FsAccessKind) -> bool { match (self, kind) { - (FsAccessPermission::ReadWrite, _) => true, - (FsAccessPermission::None, _) => false, - (FsAccessPermission::Read, FsAccessKind::Read) => true, - (FsAccessPermission::Write, FsAccessKind::Write) => true, + (Self::ReadWrite, _) => true, + (Self::None, _) => false, + (Self::Read, FsAccessKind::Read) => true, + (Self::Write, FsAccessKind::Write) => true, _ => false, } } @@ -186,10 +186,10 @@ impl FromStr for FsAccessPermission { fn from_str(s: &str) -> Result { match s { - "true" | "read-write" | "readwrite" => Ok(FsAccessPermission::ReadWrite), - "false" | "none" => Ok(FsAccessPermission::None), - "read" => Ok(FsAccessPermission::Read), - "write" => Ok(FsAccessPermission::Write), + "true" | "read-write" | "readwrite" => Ok(Self::ReadWrite), + "false" | "none" => Ok(Self::None), + "read" => Ok(Self::Read), + "write" => Ok(Self::Write), _ => Err(format!("Unknown variant {s}")), } } @@ -198,10 +198,10 @@ impl FromStr for FsAccessPermission { impl fmt::Display for FsAccessPermission { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - FsAccessPermission::ReadWrite => f.write_str("read-write"), - FsAccessPermission::None => f.write_str("none"), - FsAccessPermission::Read => f.write_str("read"), - FsAccessPermission::Write => f.write_str("write"), + Self::ReadWrite => f.write_str("read-write"), + Self::None => f.write_str("none"), + Self::Read => f.write_str("read"), + Self::Write => f.write_str("write"), } } } @@ -212,10 +212,10 @@ impl Serialize for FsAccessPermission { S: Serializer, { match self { - FsAccessPermission::ReadWrite => serializer.serialize_bool(true), - FsAccessPermission::None => serializer.serialize_bool(false), - FsAccessPermission::Read => serializer.serialize_str("read"), - FsAccessPermission::Write => serializer.serialize_str("write"), + Self::ReadWrite => serializer.serialize_bool(true), + Self::None => serializer.serialize_bool(false), + Self::Read => serializer.serialize_str("read"), + Self::Write => serializer.serialize_str("write"), } } } @@ -233,8 +233,7 @@ impl<'de> Deserialize<'de> for FsAccessPermission { } match Status::deserialize(deserializer)? { Status::Bool(enabled) => { - let status = - if enabled { FsAccessPermission::ReadWrite } else { FsAccessPermission::None }; + let status = if enabled { Self::ReadWrite } else { Self::None }; Ok(status) } Status::String(val) => val.parse().map_err(serde::de::Error::custom), diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index 7049a401a5f3e..2d23ad2aeb3eb 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -33,7 +33,7 @@ pub struct FuzzConfig { impl Default for FuzzConfig { fn default() -> Self { - FuzzConfig { + Self { runs: 256, max_test_rejects: 65536, seed: None, @@ -48,7 +48,7 @@ impl Default for FuzzConfig { impl FuzzConfig { /// Creates fuzz configuration to write failures in `{PROJECT_ROOT}/cache/fuzz` dir. pub fn new(cache_dir: PathBuf) -> Self { - FuzzConfig { + Self { runs: 256, max_test_rejects: 65536, seed: None, @@ -115,7 +115,7 @@ pub struct FuzzDictionaryConfig { impl Default for FuzzDictionaryConfig { fn default() -> Self { - FuzzDictionaryConfig { + Self { dictionary_weight: 40, include_storage: true, include_push_bytes: true, diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 27742eb56e4b9..de7182cbbc098 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -95,7 +95,7 @@ impl SolcParser { /// the provided contract_id. fn contract_root_node<'a>(&self, nodes: &'a [Node], contract_id: &str) -> Option<&'a Node> { for n in nodes.iter() { - if let NodeType::ContractDefinition = n.node_type { + if n.node_type == NodeType::ContractDefinition { let contract_data = &n.other; if let Value::String(contract_name) = contract_data.get("name")? { if contract_id.ends_with(contract_name) { @@ -126,7 +126,7 @@ impl SolcParser { /// /// Return None otherwise. fn get_fn_data(&self, node: &Node) -> Option<(String, String, String)> { - if let NodeType::FunctionDefinition = node.node_type { + if node.node_type == NodeType::FunctionDefinition { let fn_data = &node.other; let fn_name: String = self.get_fn_name(fn_data)?; let (fn_docs, docs_src_line): (String, String) = self.get_fn_docs(fn_data)?; diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 8c90e3cc340f4..698f63c269224 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -38,7 +38,7 @@ pub struct InvariantConfig { impl Default for InvariantConfig { fn default() -> Self { - InvariantConfig { + Self { runs: 256, depth: 500, fail_on_revert: false, @@ -55,7 +55,7 @@ impl Default for InvariantConfig { impl InvariantConfig { /// Creates invariant configuration to write failures in `{PROJECT_ROOT}/cache/fuzz` dir. pub fn new(cache_dir: PathBuf) -> Self { - InvariantConfig { + Self { runs: 256, depth: 500, fail_on_revert: false, diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 05e7462918956..ebafdf0d052cd 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -488,7 +488,7 @@ impl Config { /// See `Config::figment` #[track_caller] pub fn load() -> Self { - Config::from_provider(Config::figment()) + Self::from_provider(Self::figment()) } /// Returns the current `Config` with the given `providers` preset @@ -496,7 +496,7 @@ impl Config { /// See `Config::to_figment` #[track_caller] pub fn load_with_providers(providers: FigmentProviders) -> Self { - Config::default().to_figment(providers).extract().unwrap() + Self::default().to_figment(providers).extract().unwrap() } /// Returns the current `Config` @@ -504,7 +504,7 @@ impl Config { /// See `Config::figment_with_root` #[track_caller] pub fn load_with_root(root: impl Into) -> Self { - Config::from_provider(Config::figment_with_root(root)) + Self::from_provider(Self::figment_with_root(root)) } /// Extract a `Config` from `provider`, panicking if extraction fails. @@ -558,22 +558,21 @@ impl Config { /// This will merge various providers, such as env,toml,remappings into the figment. pub fn to_figment(self, providers: FigmentProviders) -> Figment { let mut c = self; - let profile = Config::selected_profile(); + let profile = Self::selected_profile(); let mut figment = Figment::default().merge(DappHardhatDirProvider(&c.root.0)); // merge global foundry.toml file - if let Some(global_toml) = Config::foundry_dir_toml().filter(|p| p.exists()) { - figment = Config::merge_toml_provider( + if let Some(global_toml) = Self::foundry_dir_toml().filter(|p| p.exists()) { + figment = Self::merge_toml_provider( figment, TomlFileProvider::new(None, global_toml).cached(), profile.clone(), ); } // merge local foundry.toml file - figment = Config::merge_toml_provider( + figment = Self::merge_toml_provider( figment, - TomlFileProvider::new(Some("FOUNDRY_CONFIG"), c.root.0.join(Config::FILE_NAME)) - .cached(), + TomlFileProvider::new(Some("FOUNDRY_CONFIG"), c.root.0.join(Self::FILE_NAME)).cached(), profile.clone(), ); @@ -596,7 +595,7 @@ impl Config { .ignore(&["PROFILE", "REMAPPINGS", "LIBRARIES", "FFI", "FS_PERMISSIONS"]) .map(|key| { let key = key.as_str(); - if Config::STANDALONE_SECTIONS.iter().any(|section| { + if Self::STANDALONE_SECTIONS.iter().any(|section| { key.starts_with(&format!("{}_", section.to_ascii_uppercase())) }) { key.replacen('_', ".", 1).into() @@ -1005,7 +1004,7 @@ impl Config { /// let rpc_jwt = config.get_rpc_jwt_secret().unwrap().unwrap(); /// # } /// ``` - pub fn get_rpc_jwt_secret(&self) -> Result>, UnresolvedEnvVarError> { + pub fn get_rpc_jwt_secret(&self) -> Result>, UnresolvedEnvVarError> { Ok(self.eth_rpc_jwt.as_ref().map(|jwt| Cow::Borrowed(jwt.as_str()))) } @@ -1024,7 +1023,7 @@ impl Config { /// let rpc_url = config.get_rpc_url().unwrap().unwrap(); /// # } /// ``` - pub fn get_rpc_url(&self) -> Option, UnresolvedEnvVarError>> { + pub fn get_rpc_url(&self) -> Option, UnresolvedEnvVarError>> { let maybe_alias = self.eth_rpc_url.as_ref().or(self.etherscan_api_key.as_ref())?; if let Some(alias) = self.get_rpc_url_with_alias(maybe_alias) { Some(alias) @@ -1051,7 +1050,7 @@ impl Config { pub fn get_rpc_url_with_alias( &self, maybe_alias: &str, - ) -> Option, UnresolvedEnvVarError>> { + ) -> Option, UnresolvedEnvVarError>> { let mut endpoints = self.rpc_endpoints.clone().resolved(); Some(endpoints.remove(maybe_alias)?.map(Cow::Owned)) } @@ -1070,7 +1069,7 @@ impl Config { pub fn get_rpc_url_or<'a>( &'a self, fallback: impl Into>, - ) -> Result, UnresolvedEnvVarError> { + ) -> Result, UnresolvedEnvVarError> { if let Some(url) = self.get_rpc_url() { url } else { @@ -1089,7 +1088,7 @@ impl Config { /// let rpc_url = config.get_rpc_url_or_localhost_http().unwrap(); /// # } /// ``` - pub fn get_rpc_url_or_localhost_http(&self) -> Result, UnresolvedEnvVarError> { + pub fn get_rpc_url_or_localhost_http(&self) -> Result, UnresolvedEnvVarError> { self.get_rpc_url_or("http://localhost:8545") } @@ -1330,7 +1329,7 @@ impl Config { /// let my_config = Config::figment().extract::(); /// ``` pub fn figment() -> Figment { - Config::default().into() + Self::default().into() } /// Returns the default figment enhanced with additional context extracted from the provided @@ -1361,7 +1360,7 @@ impl Config { let root = root.into(); let paths = ProjectPathsConfig::builder().build_with_root::<()>(&root); let artifacts: PathBuf = paths.artifacts.file_name().unwrap().into(); - Config { + Self { root: paths.root.into(), src: paths.sources.file_name().unwrap().into(), out: artifacts.clone(), @@ -1372,27 +1371,27 @@ impl Config { .map(|r| RelativeRemapping::new(r, &root)) .collect(), fs_permissions: FsPermissions::new([PathPermission::read(artifacts)]), - ..Config::default() + ..Self::default() } } /// Returns the default config but with hardhat paths pub fn hardhat() -> Self { - Config { + Self { src: "contracts".into(), out: "artifacts".into(), libs: vec!["node_modules".into()], - ..Config::default() + ..Self::default() } } /// Returns the default config that uses dapptools style paths pub fn dapptools() -> Self { - Config { + Self { chain: Some(Chain::from_id(99)), block_timestamp: 0, block_number: 0, - ..Config::default() + ..Self::default() } } @@ -1420,7 +1419,7 @@ impl Config { /// [Self::get_config_path()] and if the closure returns `true`. pub fn update_at(root: impl Into, f: F) -> eyre::Result<()> where - F: FnOnce(&Config, &mut toml_edit::DocumentMut) -> bool, + F: FnOnce(&Self, &mut toml_edit::DocumentMut) -> bool, { let config = Self::load_with_root(root).sanitized(); config.update(|doc| f(&config, doc)) @@ -1465,7 +1464,7 @@ impl Config { }) .collect(); let libs = toml_edit::value(libs); - doc[Config::PROFILE_SECTION][profile]["libs"] = libs; + doc[Self::PROFILE_SECTION][profile]["libs"] = libs; true }) } @@ -1487,7 +1486,7 @@ impl Config { // Config map always gets serialized as a table let value_table = value.as_table_mut().unwrap(); // remove standalone sections from inner table - let standalone_sections = Config::STANDALONE_SECTIONS + let standalone_sections = Self::STANDALONE_SECTIONS .iter() .filter_map(|section| { let section = section.to_string(); @@ -1496,7 +1495,7 @@ impl Config { .collect::>(); // wrap inner table in [profile.] let mut wrapping_table = [( - Config::PROFILE_SECTION.into(), + Self::PROFILE_SECTION.into(), toml::Value::Table([(self.profile.to_string(), value)].into_iter().collect()), )] .into_iter() @@ -1511,24 +1510,24 @@ impl Config { /// Returns the path to the `foundry.toml` of this `Config`. pub fn get_config_path(&self) -> PathBuf { - self.root.0.join(Config::FILE_NAME) + self.root.0.join(Self::FILE_NAME) } /// Returns the selected profile. /// /// If the `FOUNDRY_PROFILE` env variable is not set, this returns the `DEFAULT_PROFILE`. pub fn selected_profile() -> Profile { - Profile::from_env_or("FOUNDRY_PROFILE", Config::DEFAULT_PROFILE) + Profile::from_env_or("FOUNDRY_PROFILE", Self::DEFAULT_PROFILE) } /// Returns the path to foundry's global TOML file: `~/.foundry/foundry.toml`. pub fn foundry_dir_toml() -> Option { - Self::foundry_dir().map(|p| p.join(Config::FILE_NAME)) + Self::foundry_dir().map(|p| p.join(Self::FILE_NAME)) } /// Returns the path to foundry's config dir: `~/.foundry/`. pub fn foundry_dir() -> Option { - dirs_next::home_dir().map(|p| p.join(Config::FOUNDRY_DIR_NAME)) + dirs_next::home_dir().map(|p| p.join(Self::FOUNDRY_DIR_NAME)) } /// Returns the path to foundry's cache dir: `~/.foundry/cache`. @@ -1610,13 +1609,13 @@ impl Config { cwd = cwd.parent()?; } } - find(Env::var_or("FOUNDRY_CONFIG", Config::FILE_NAME).as_ref()) + find(Env::var_or("FOUNDRY_CONFIG", Self::FILE_NAME).as_ref()) .or_else(|| Self::foundry_dir_toml().filter(|p| p.exists())) } /// Clears the foundry cache. pub fn clean_foundry_cache() -> eyre::Result<()> { - if let Some(cache_dir) = Config::foundry_cache_dir() { + if let Some(cache_dir) = Self::foundry_cache_dir() { let path = cache_dir.as_path(); let _ = fs::remove_dir_all(path); } else { @@ -1628,7 +1627,7 @@ impl Config { /// Clears the foundry cache for `chain`. pub fn clean_foundry_chain_cache(chain: Chain) -> eyre::Result<()> { - if let Some(cache_dir) = Config::foundry_chain_cache_dir(chain) { + if let Some(cache_dir) = Self::foundry_chain_cache_dir(chain) { let path = cache_dir.as_path(); let _ = fs::remove_dir_all(path); } else { @@ -1640,7 +1639,7 @@ impl Config { /// Clears the foundry cache for `chain` and `block`. pub fn clean_foundry_block_cache(chain: Chain, block: u64) -> eyre::Result<()> { - if let Some(cache_dir) = Config::foundry_block_cache_dir(chain, block) { + if let Some(cache_dir) = Self::foundry_block_cache_dir(chain, block) { let path = cache_dir.as_path(); let _ = fs::remove_dir_all(path); } else { @@ -1652,7 +1651,7 @@ impl Config { /// Clears the foundry etherscan cache. pub fn clean_foundry_etherscan_cache() -> eyre::Result<()> { - if let Some(cache_dir) = Config::foundry_etherscan_cache_dir() { + if let Some(cache_dir) = Self::foundry_etherscan_cache_dir() { let path = cache_dir.as_path(); let _ = fs::remove_dir_all(path); } else { @@ -1664,7 +1663,7 @@ impl Config { /// Clears the foundry etherscan cache for `chain`. pub fn clean_foundry_etherscan_chain_cache(chain: Chain) -> eyre::Result<()> { - if let Some(cache_dir) = Config::foundry_etherscan_chain_cache_dir(chain) { + if let Some(cache_dir) = Self::foundry_etherscan_chain_cache_dir(chain) { let path = cache_dir.as_path(); let _ = fs::remove_dir_all(path); } else { @@ -1676,7 +1675,7 @@ impl Config { /// List the data in the foundry cache. pub fn list_foundry_cache() -> eyre::Result { - if let Some(cache_dir) = Config::foundry_rpc_cache_dir() { + if let Some(cache_dir) = Self::foundry_rpc_cache_dir() { let mut cache = Cache { chains: vec![] }; if !cache_dir.exists() { return Ok(cache) @@ -1699,7 +1698,7 @@ impl Config { /// List the cached data for `chain`. pub fn list_foundry_chain_cache(chain: Chain) -> eyre::Result { - let block_explorer_data_size = match Config::foundry_etherscan_chain_cache_dir(chain) { + let block_explorer_data_size = match Self::foundry_etherscan_chain_cache_dir(chain) { Some(cache_dir) => Self::get_cached_block_explorer_data(&cache_dir)?, None => { warn!("failed to access foundry_etherscan_chain_cache_dir"); @@ -1707,7 +1706,7 @@ impl Config { } }; - if let Some(cache_dir) = Config::foundry_chain_cache_dir(chain) { + if let Some(cache_dir) = Self::foundry_chain_cache_dir(chain) { let blocks = Self::get_cached_blocks(&cache_dir)?; Ok(ChainCache { name: chain.to_string(), @@ -1776,8 +1775,8 @@ impl Config { }; // use [profile.] as [] - let mut profiles = vec![Config::DEFAULT_PROFILE]; - if profile != Config::DEFAULT_PROFILE { + let mut profiles = vec![Self::DEFAULT_PROFILE]; + if profile != Self::DEFAULT_PROFILE { profiles.push(profile.clone()); } let provider = toml_provider.strict_select(profiles); @@ -1786,11 +1785,11 @@ impl Config { let provider = BackwardsCompatTomlProvider(ForcedSnakeCaseData(provider)); // merge the default profile as a base - if profile != Config::DEFAULT_PROFILE { - figment = figment.merge(provider.rename(Config::DEFAULT_PROFILE, profile.clone())); + if profile != Self::DEFAULT_PROFILE { + figment = figment.merge(provider.rename(Self::DEFAULT_PROFILE, profile.clone())); } // merge special keys into config - for standalone_key in Config::STANDALONE_SECTIONS { + for standalone_key in Self::STANDALONE_SECTIONS { if let Some((_, fallback)) = STANDALONE_FALLBACK_SECTIONS.iter().find(|(key, _)| standalone_key == key) { @@ -1834,7 +1833,7 @@ impl Config { } impl From for Figment { - fn from(c: Config) -> Figment { + fn from(c: Config) -> Self { c.to_figment(FigmentProviders::All) } } @@ -1897,7 +1896,7 @@ impl From for regex::Regex { impl From for RegexWrapper { fn from(re: Regex) -> Self { - RegexWrapper { inner: re } + Self { inner: re } } } @@ -1964,7 +1963,7 @@ impl Default for RootPath { impl> From

for RootPath { fn from(p: P) -> Self { - RootPath(p.into()) + Self(p.into()) } } @@ -2066,8 +2065,8 @@ impl Default for Config { always_use_create_2_factory: false, ffi: false, prompt_timeout: 120, - sender: Config::DEFAULT_SENDER, - tx_origin: Config::DEFAULT_SENDER, + sender: Self::DEFAULT_SENDER, + tx_origin: Self::DEFAULT_SENDER, initial_balance: U256::from(0xffffffffffffffffffffffffu128), block_number: 1, fork_block_number: None, @@ -2116,7 +2115,7 @@ impl Default for Config { doc: Default::default(), labels: Default::default(), unchecked_cheatcode_artifacts: false, - create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, + create2_library_salt: Self::DEFAULT_CREATE2_LIBRARY_SALT, skip: vec![], dependencies: Default::default(), warnings: vec![], @@ -2187,10 +2186,10 @@ impl<'de> Deserialize<'de> for GasLimit { } let gas = match Gas::deserialize(deserializer)? { - Gas::Number(num) => GasLimit(num), + Gas::Number(num) => Self(num), Gas::Text(s) => match s.as_str() { - "max" | "MAX" | "Max" | "u64::MAX" | "u64::Max" => GasLimit(u64::MAX), - s => GasLimit(s.parse().map_err(D::Error::custom)?), + "max" | "MAX" | "Max" | "u64::MAX" | "u64::Max" => Self(u64::MAX), + s => Self(s.parse().map_err(D::Error::custom)?), }, }; @@ -2216,8 +2215,8 @@ impl SolcReq { /// will try to get the version from the binary. fn try_version(&self) -> Result { match self { - SolcReq::Version(version) => Ok(version.clone()), - SolcReq::Local(path) => Solc::new(path).map(|solc| solc.version), + Self::Version(version) => Ok(version.clone()), + Self::Local(path) => Solc::new(path).map(|solc| solc.version), } } } @@ -2226,9 +2225,9 @@ impl> From for SolcReq { fn from(s: T) -> Self { let s = s.as_ref(); if let Ok(v) = Version::from_str(s) { - SolcReq::Version(v) + Self::Version(v) } else { - SolcReq::Local(s.into()) + Self::Local(s.into()) } } } @@ -2494,7 +2493,7 @@ impl Provider for DappEnvCompatProvider { } } -/// Renames a profile from `from` to `to +/// Renames a profile from `from` to `to`. /// /// For example given: /// diff --git a/crates/config/src/providers/mod.rs b/crates/config/src/providers/mod.rs index d8fdbf438e4cc..1f9f5c88ea895 100644 --- a/crates/config/src/providers/mod.rs +++ b/crates/config/src/providers/mod.rs @@ -128,7 +128,7 @@ pub struct FallbackProfileProvider

{ impl

FallbackProfileProvider

{ /// Creates a new fallback profile provider. pub fn new(provider: P, profile: impl Into, fallback: impl Into) -> Self { - FallbackProfileProvider { provider, profile: profile.into(), fallback: fallback.into() } + Self { provider, profile: profile.into(), fallback: fallback.into() } } } diff --git a/crates/config/src/resolve.rs b/crates/config/src/resolve.rs index 981ddc886db3c..746280f3d2b19 100644 --- a/crates/config/src/resolve.rs +++ b/crates/config/src/resolve.rs @@ -21,7 +21,7 @@ pub struct UnresolvedEnvVarError { impl UnresolvedEnvVarError { /// Tries to resolve a value - pub fn try_resolve(&self) -> Result { + pub fn try_resolve(&self) -> Result { interpolate(&self.unresolved) } } diff --git a/crates/config/src/soldeer.rs b/crates/config/src/soldeer.rs index 511559bb91398..e99fb2aaaabf8 100644 --- a/crates/config/src/soldeer.rs +++ b/crates/config/src/soldeer.rs @@ -16,10 +16,11 @@ pub struct SoldeerDependency { } /// Type for Soldeer configs, under dependencies tag in the foundry.toml -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct SoldeerConfig(BTreeMap); -impl AsRef for SoldeerConfig { - fn as_ref(&self) -> &SoldeerConfig { + +impl AsRef for SoldeerConfig { + fn as_ref(&self) -> &Self { self } } diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 17af4789d5869..af50a7bc1f7ed 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -274,10 +274,10 @@ pub enum Numeric { } impl From for U256 { - fn from(n: Numeric) -> U256 { + fn from(n: Numeric) -> Self { match n { Numeric::U256(n) => n, - Numeric::Num(n) => U256::from(n), + Numeric::Num(n) => Self::from(n), } } } diff --git a/crates/config/src/vyper.rs b/crates/config/src/vyper.rs index 2af46b4b6576c..7b2f0a54ddc5d 100644 --- a/crates/config/src/vyper.rs +++ b/crates/config/src/vyper.rs @@ -4,7 +4,7 @@ use foundry_compilers::artifacts::vyper::VyperOptimizationMode; use serde::{Deserialize, Serialize}; use std::path::PathBuf; -#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct VyperConfig { /// Vyper optimization mode. "gas", "none" or "codesize" #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index 0f8e91c79bd50..280dcfd0d712a 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; /// The natspec comment tag explaining the purpose of the comment. /// See: . -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum CommentTag { /// A title that should describe the contract/interface Title, @@ -56,7 +56,7 @@ impl CommentTag { /// The natspec documentation comment. /// /// Ref: -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Comment { /// The doc comment tag. pub tag: CommentTag, diff --git a/crates/doc/src/parser/item.rs b/crates/doc/src/parser/item.rs index b93f0d199491f..999758cebc992 100644 --- a/crates/doc/src/parser/item.rs +++ b/crates/doc/src/parser/item.rs @@ -147,7 +147,7 @@ impl ParseItem { } /// A wrapper type around pt token. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum ParseSource { /// Source contract definition. Contract(Box), diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index c09e8538bf86a..82663020cb605 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -184,9 +184,8 @@ pub fn create2_handler_register>( frame_or_result }); - let create2_overrides_inner = create2_overrides.clone(); + let create2_overrides_inner = create2_overrides; let old_handle = handler.execution.insert_call_outcome.clone(); - handler.execution.insert_call_outcome = Arc::new(move |ctx, frame, shared_memory, mut outcome| { // If we are on the depth of the latest override, handle the outcome. diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index d352abfc8f43e..729a1b6385806 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -242,7 +242,7 @@ async fn render_trace_log( .collect::>() .join(", "); - write!(s, "emit {}({params})", name.clone().cyan())?; + write!(s, "emit {}({params})", name.cyan())?; } } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 8e7f7c9a3987b..dcaa6e52f24a4 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -107,7 +107,7 @@ impl BuildArgs { let output = compiler.compile(&project)?; if self.format_json { - println!("{}", serde_json::to_string_pretty(&output.clone().output())?); + println!("{}", serde_json::to_string_pretty(&output.output())?); } Ok(output) diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index c4a01133740e1..e3cdd0b390186 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -55,7 +55,7 @@ impl FlattenArgs { // Fallback to the old flattening implementation if we couldn't compile the target // successfully. This would be the case if the target has invalid // syntax. (e.g. Solang) - project.paths.clone().with_language::().flatten(&target_path) + project.paths.with_language::().flatten(&target_path) } Err(FlattenerError::Other(err)) => Err(err), } diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 1c782f8bd865d..bea9393ff3a11 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -48,7 +48,7 @@ impl InspectArgs { } // Run Optimized? - let optimized = if let ContractArtifactField::AssemblyOptimized = field { + let optimized = if field == ContractArtifactField::AssemblyOptimized { true } else { build.compiler.optimize diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 81188f35be786..d09b5cdfbe846 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -177,7 +177,7 @@ impl SelectorsSubcommands { Self::List { contract, project_paths } => { println!("Listing selectors for contracts in the project..."); let build_args = CoreBuildArgs { - project_paths: project_paths.clone(), + project_paths, compiler: CompilerArgs { extra_output: vec![ContractOutputSelection::Abi], ..Default::default() diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 1b2a1398d1f6f..18ecba6de075f 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -76,8 +76,7 @@ impl TestConfig { result .traces .iter() - .map(|(_, a)| render_trace_arena(a, &call_trace_decoder)) - .collect::>(), + .map(|(_, a)| render_trace_arena(a, &call_trace_decoder)), ) .await .into_iter() diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 019a56d148c02..7712aa9a6f2a5 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -300,7 +300,7 @@ async fn test_shrink(opts: TestOptions, contract_pattern: &str) { ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol", ); let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options = opts.clone(); + runner.test_options = opts; match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 3bf2ae327bd68..cacfca10caf3b 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -229,7 +229,7 @@ impl ForgeTestData { .enable_isolation(opts.isolate) .sender(sender) .with_test_options(self.test_opts.clone()) - .build(root, output, env, opts.clone()) + .build(root, output, env, opts) .unwrap() } diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 2fc0691d742f9..48242ca19b027 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -185,6 +185,7 @@ impl PreprocessedState { } }; + #[allow(clippy::redundant_clone)] let sources_to_compile = source_files_iter( project.paths.sources.as_path(), MultiCompilerLanguage::FILE_EXTENSIONS, diff --git a/crates/sol-macro-gen/Cargo.toml b/crates/sol-macro-gen/Cargo.toml index c4da94041427e..c83a10152dd02 100644 --- a/crates/sol-macro-gen/Cargo.toml +++ b/crates/sol-macro-gen/Cargo.toml @@ -11,6 +11,9 @@ license.workspace = true homepage.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] alloy-json-abi.workspace = true alloy-sol-macro-input.workspace = true diff --git a/crates/sol-macro-gen/src/sol_macro_gen.rs b/crates/sol-macro-gen/src/sol_macro_gen.rs index 7867b6673415b..7309104fec615 100644 --- a/crates/sol-macro-gen/src/sol_macro_gen.rs +++ b/crates/sol-macro-gen/src/sol_macro_gen.rs @@ -108,24 +108,22 @@ impl MultiSolMacroGen { let cargo_toml_path = bindings_path.join("Cargo.toml"); let mut toml_contents = format!( r#"[package] -name = "{}" -version = "{}" +name = "{name}" +version = "{version}" edition = "2021" [dependencies] -"#, - name, version +"# ); let alloy_dep = if let Some(alloy_version) = alloy_version { format!( - r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{}", features = ["sol-types", "contract"] }}"#, - alloy_version + r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{alloy_version}", features = ["sol-types", "contract"] }}"# ) } else { r#"alloy = { git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }"#.to_string() }; - write!(toml_contents, "{}", alloy_dep)?; + write!(toml_contents, "{alloy_dep}")?; fs::write(cargo_toml_path, toml_contents).wrap_err("Failed to write Cargo.toml")?; @@ -146,14 +144,14 @@ edition = "2021" let contents = instance.expansion.as_ref().unwrap().to_string(); if !single_file { - let path = src.join(format!("{}.rs", name)); + let path = src.join(format!("{name}.rs")); let file = syn::parse_file(&contents)?; let contents = prettyplease::unparse(&file); fs::write(path.clone(), contents).wrap_err("Failed to write file")?; - writeln!(&mut lib_contents, "pub mod {};", name)?; + writeln!(&mut lib_contents, "pub mod {name};")?; } else { - write!(&mut lib_contents, "{}", contents)?; + write!(&mut lib_contents, "{contents}")?; } } @@ -196,13 +194,13 @@ edition = "2021" let file = syn::parse_file(&contents)?; let contents = prettyplease::unparse(&file); - fs::write(bindings_path.join(format!("{}.rs", name)), contents) + fs::write(bindings_path.join(format!("{name}.rs")), contents) .wrap_err("Failed to write file")?; } else { // Single File let mut contents = String::new(); write!(contents, "{}\n\n", instance.expansion.as_ref().unwrap())?; - write!(mod_contents, "{}", contents)?; + write!(mod_contents, "{contents}")?; } } @@ -249,9 +247,9 @@ edition = "2021" for instance in &self.instances { let name = instance.name.to_lowercase(); let path = if is_mod { - crate_path.join(format!("{}.rs", name)) + crate_path.join(format!("{name}.rs")) } else { - crate_path.join(format!("src/{}.rs", name)) + crate_path.join(format!("src/{name}.rs")) }; let tokens = instance .expansion @@ -263,9 +261,8 @@ edition = "2021" write!( &mut super_contents, - r#"pub mod {}; - "#, - name + r#"pub mod {name}; + "# )?; } diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index 92c0083e6c29f..9937e4d8ae06b 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -90,7 +90,7 @@ impl EtherscanFlattenedSource { let out = SolcCompiler::Specific(solc).compile(&input)?; if out.errors.iter().any(|e| e.is_error()) { let mut o = AggregatedCompilerOutput::::default(); - o.extend(version.clone(), RawBuildInfo::new(&input, &out, false)?, out); + o.extend(version, RawBuildInfo::new(&input, &out, false)?, out); let diags = o.diagnostics(&[], &[], Default::default()); eyre::bail!( From 731b3f4b2249aceda8639378636aded28f1053e7 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 20 Jun 2024 19:31:41 +0300 Subject: [PATCH 1127/1963] fix: update bytecode matching for coverage (#8214) * fix: update bytecode matching for coverage * clippy * chore: factor out common code --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/common/src/contracts.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 046a074257d8d..aeaec4652b381 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -118,24 +118,30 @@ impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. pub fn find_by_creation_code(&self, code: &[u8]) -> Option> { - self.iter().find(|(_, contract)| { - if let Some(bytecode) = contract.bytecode() { - bytecode_diff_score(bytecode.as_ref(), code) <= 0.1 - } else { - false - } - }) + self.find_by_code(code, ContractData::bytecode) } /// Finds a contract which has a similar deployed bytecode as `code`. pub fn find_by_deployed_code(&self, code: &[u8]) -> Option> { - self.iter().find(|(_, contract)| { - if let Some(deployed_bytecode) = contract.deployed_bytecode() { - bytecode_diff_score(deployed_bytecode.as_ref(), code) <= 0.1 - } else { - false - } - }) + self.find_by_code(code, ContractData::deployed_bytecode) + } + + fn find_by_code( + &self, + code: &[u8], + get: impl Fn(&ContractData) -> Option<&Bytes>, + ) -> Option> { + self.iter() + .filter_map(|(id, contract)| { + if let Some(deployed_bytecode) = get(contract) { + let score = bytecode_diff_score(deployed_bytecode.as_ref(), code); + (score <= 0.1).then_some((score, (id, contract))) + } else { + None + } + }) + .min_by(|(score1, _), (score2, _)| score1.partial_cmp(score2).unwrap()) + .map(|(_, data)| data) } /// Finds a contract which deployed bytecode exactly matches the given code. Accounts for link From 039734637cb07ea2da5adb54d205a4c1d74340f4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:38:26 +0200 Subject: [PATCH 1128/1963] chore: enable redundant-lifetimes lint (#8212) --- Cargo.toml | 3 ++- clippy.toml | 2 +- crates/forge/bin/cmd/fmt.rs | 5 +---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5e6bbc4541ed9..83db5606ffa8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ resolver = "2" version = "0.2.0" edition = "2021" # Remember to update clippy.toml as well -rust-version = "1.76" +rust-version = "1.79" authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" @@ -48,6 +48,7 @@ octal-escapes = "allow" rust-2018-idioms = "warn" # unreachable-pub = "warn" unused-must-use = "warn" +redundant-lifetimes = "warn" [workspace.lints.rustdoc] all = "warn" diff --git a/clippy.toml b/clippy.toml index 09acb653d14ac..b5a99df72b1e5 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,4 +1,4 @@ -msrv = "1.76" +msrv = "1.79" # bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, # so it is safe to ignore it as well ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index bcfae7769d112..c467048368f01 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -202,10 +202,7 @@ impl fmt::Display for Line { } } -fn format_diff_summary<'a, 'b, 'r>(name: &str, diff: &'r TextDiff<'a, 'b, '_, str>) -> String -where - 'r: 'a + 'b, -{ +fn format_diff_summary<'a>(name: &str, diff: &'a TextDiff<'a, 'a, '_, str>) -> String { let cap = 128; let mut diff_summary = String::with_capacity(cap); From 374fe6497ab86c05521b8e818e85588b77898120 Mon Sep 17 00:00:00 2001 From: aganisgash Date: Fri, 21 Jun 2024 00:48:05 +0800 Subject: [PATCH 1129/1963] fix: correct the hyperlinks related to JSON-RPC. (#8215) * Correct the hyperlinks related to JSON-RPC. * chore: revert testdata changes --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/anvil/README.md | 2 +- crates/anvil/tests/it/transaction.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/anvil/README.md b/crates/anvil/README.md index 0e775441d6ee9..64af769d9e1fc 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -5,7 +5,7 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** ## Features - Network forking: fork any EVM-compatible blockchain, same as in `forge` -- [Ethereum JSON-RPC](https://eth.wiki/json-rpc/API) support +- [Ethereum JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) support - Additional JSON-RPC endpoints, compatible with ganache and hardhat - snapshot/revert state - mining modes: auto, interval, manual, none diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 10b99685491f1..91a2ac6187563 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -879,7 +879,7 @@ async fn test_tx_receipt() { let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - // `to` field is none if it's a contract creation transaction: https://eth.wiki/json-rpc/API#eth_getTransactionReceipt + // `to` field is none if it's a contract creation transaction: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt assert!(tx.to.is_none()); assert!(tx.contract_address.is_some()); } From 3baa1d313f01873daf2062578569ab770d5b3ca5 Mon Sep 17 00:00:00 2001 From: aganisgash Date: Fri, 21 Jun 2024 02:20:07 +0800 Subject: [PATCH 1130/1963] fix: Re-edited to delete the language choose (#8218) Re-edited to delete the language choose --- crates/anvil/README.md | 2 +- crates/anvil/tests/it/transaction.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/anvil/README.md b/crates/anvil/README.md index 64af769d9e1fc..0942e0e8f0550 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -5,7 +5,7 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** ## Features - Network forking: fork any EVM-compatible blockchain, same as in `forge` -- [Ethereum JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) support +- [Ethereum JSON-RPC](https://ethereum.org/developers/docs/apis/json-rpc/) support - Additional JSON-RPC endpoints, compatible with ganache and hardhat - snapshot/revert state - mining modes: auto, interval, manual, none diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 91a2ac6187563..5f9abe80b6bdb 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -879,7 +879,7 @@ async fn test_tx_receipt() { let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - // `to` field is none if it's a contract creation transaction: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt + // `to` field is none if it's a contract creation transaction: https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionreceipt assert!(tx.to.is_none()); assert!(tx.contract_address.is_some()); } From cb3c142686d2b2fa43761fdc66eba2adcf7fe679 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 20 Jun 2024 20:39:10 +0200 Subject: [PATCH 1131/1963] ci: pin vyper to 0.3 (#8219) --- .github/workflows/nextest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nextest.yml b/.github/workflows/nextest.yml index 631dab90f82c3..1c5089db4cc90 100644 --- a/.github/workflows/nextest.yml +++ b/.github/workflows/nextest.yml @@ -73,7 +73,7 @@ jobs: python-version: 3.11 - name: Install Vyper if: contains(matrix.name, 'external') - run: pip install vyper + run: pip install vyper~=0.3.10 - name: Forge RPC cache uses: actions/cache@v3 @@ -93,4 +93,4 @@ jobs: - name: Test env: SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} - run: cargo nextest run ${{ matrix.flags }} \ No newline at end of file + run: cargo nextest run ${{ matrix.flags }} From 18b13163829c215523b03075b99c0b67f8e7feee Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:09:09 +0200 Subject: [PATCH 1132/1963] chore(deps): bump revm 10.0, un-git revm-inspectors (#8220) --- Cargo.lock | 23 ++++++++++++-------- Cargo.toml | 14 +++--------- crates/anvil/core/src/eth/transaction/mod.rs | 10 ++++----- crates/anvil/src/eth/api.rs | 9 ++++++-- crates/anvil/src/eth/backend/mem/mod.rs | 6 ++--- crates/cheatcodes/src/inspector.rs | 4 ++-- crates/evm/core/src/backend/mod.rs | 6 ++--- crates/evm/core/src/utils.rs | 4 ++-- crates/evm/evm/src/executors/mod.rs | 14 ++++++------ crates/evm/evm/src/inspectors/stack.rs | 14 +++++------- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e37133b92158..8f49b41f137a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6930,8 +6930,9 @@ dependencies = [ [[package]] name = "revm" -version = "9.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "355bde4e21578c241f9379fbb344a73d254969b5007239115e094dda1511cd34" dependencies = [ "auto_impl", "cfg-if", @@ -6945,7 +6946,8 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/revm-inspectors?rev=4fe17f0#4fe17f08797450d9d5df315e724d14c9f3749b3f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eba2e187811b160463663fd71881b4e5d653720ba00be0f1e85962d4db60341c" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -6960,8 +6962,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "5.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dfd24faa3cbbd96e0976103d1e174d6559b8036730f70415488ee21870d578" dependencies = [ "revm-primitives", "serde", @@ -6969,8 +6972,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "7.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c669c9b105dbb41133c17bf7f34d29368e358a7fee8fcc289e90dbfb024dfc4" dependencies = [ "aurora-engine-modexp", "c-kzg", @@ -6986,8 +6990,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "4.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "902184a7a781550858d4b96707098da357429f1e4545806fd5b589f455555cf2" dependencies = [ "alloy-primitives", "auto_impl", diff --git a/Cargo.toml b/Cargo.toml index 83db5606ffa8c..2d44d6d671d10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -161,11 +161,9 @@ foundry-compilers = { version = "0.8.0", default-features = false } ## revm # no default features to avoid c-kzg -revm = { version = "9.0.0", default-features = false } -revm-primitives = { version = "4.0.0", default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "4fe17f0", features = [ - "serde", -] } +revm = { version = "10.0.0", default-features = false } +revm-primitives = { version = "5.0.0", default-features = false } +revm-inspectors = { version = "0.1", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } @@ -261,9 +259,3 @@ tower = "0.4" tower-http = "0.5" # soldeer soldeer = "0.2.15" - -[patch.crates-io] -revm = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } -revm-interpreter = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } -revm-precompile = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } -revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7f" } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index b22cc82fb1551..c768d01a2c75e 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -18,7 +18,7 @@ use bytes::BufMut; use foundry_evm::traces::CallTraceNode; use revm::{ interpreter::InstructionResult, - primitives::{OptimismFields, TransactTo, TxEnv}, + primitives::{OptimismFields, TxEnv}, }; use serde::{Deserialize, Serialize}; use std::ops::{Deref, Mul}; @@ -446,10 +446,10 @@ impl PendingTransaction { /// Converts the [PendingTransaction] into the [TxEnv] context that [`revm`](foundry_evm) /// expects. pub fn to_revm_tx_env(&self) -> TxEnv { - fn transact_to(kind: &TxKind) -> TransactTo { + fn transact_to(kind: &TxKind) -> TxKind { match kind { - TxKind::Call(c) => TransactTo::Call(*c), - TxKind::Create => TransactTo::Create, + TxKind::Call(c) => TxKind::Call(*c), + TxKind::Create => TxKind::Create, } } @@ -542,7 +542,7 @@ impl PendingTransaction { } = tx.tx().tx(); TxEnv { caller, - transact_to: TransactTo::call(*to), + transact_to: TxKind::Call(*to), data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index c3641ace00828..ada503ceca8a5 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2738,7 +2738,7 @@ impl TryFrom, u128, State)>> for GasEs InstructionResult::OpcodeNotFound | InstructionResult::CallNotAllowedInsideStatic | InstructionResult::StateChangeDuringStaticCall | - InstructionResult::InvalidFEOpcode | + InstructionResult::InvalidEFOpcode | InstructionResult::InvalidJump | InstructionResult::NotActivated | InstructionResult::StackUnderflow | @@ -2754,10 +2754,15 @@ impl TryFrom, u128, State)>> for GasEs InstructionResult::FatalExternalError | InstructionResult::OutOfFunds | InstructionResult::CallTooDeep => Ok(Self::EvmError(exit)), + // Handle Revm EOF InstructionResults: Not supported yet InstructionResult::ReturnContractInNotInitEOF | InstructionResult::EOFOpcodeDisabledInLegacy | - InstructionResult::EOFFunctionStackOverflow => Ok(Self::EvmError(exit)), + InstructionResult::EOFFunctionStackOverflow | + InstructionResult::CreateInitCodeStartingEF00 | + InstructionResult::InvalidEOFInitCode | + InstructionResult::EofAuxDataOverflow | + InstructionResult::EofAuxDataTooSmall => Ok(Self::EvmError(exit)), }, } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ec676276868f1..a5e98abfbfed6 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -70,7 +70,7 @@ use foundry_evm::{ interpreter::InstructionResult, primitives::{ BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ExecutionResult, Output, SpecId, - TransactTo, TxEnv, KECCAK_EMPTY, + TxEnv, KECCAK_EMPTY, }, }, utils::new_evm_with_inspector_ref, @@ -1159,8 +1159,8 @@ impl Backend { gas_priority_fee: max_priority_fee_per_gas.map(U256::from), max_fee_per_blob_gas: max_fee_per_blob_gas.map(U256::from), transact_to: match to { - Some(addr) => TransactTo::Call(*addr), - None => TransactTo::Create, + Some(addr) => TxKind::Call(*addr), + None => TxKind::Create, }, value: value.unwrap_or_default(), data: input.into_input().unwrap_or_default(), diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 3e7e561be6ec5..ecec6424568d5 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -32,7 +32,7 @@ use revm::{ opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, - primitives::{BlockEnv, CreateScheme, TransactTo}, + primitives::{BlockEnv, CreateScheme}, EvmContext, InnerEvmContext, Inspector, }; use rustc_hash::FxHashMap; @@ -846,7 +846,7 @@ impl Inspector for Cheatcodes { // try to diagnose reverts in multi-fork mode where a call is made to an address that does // not exist - if let TransactTo::Call(test_contract) = ecx.env.tx.transact_to { + 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() && diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 257d72bdb89c1..ed7a9efb6fa6a 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -19,7 +19,7 @@ use revm::{ precompile::{PrecompileSpecId, Precompiles}, primitives::{ Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, EvmState, EvmStorageSlot, - HashMap as Map, Log, ResultAndState, SpecId, TransactTo, KECCAK_EMPTY, + HashMap as Map, Log, ResultAndState, SpecId, TxKind, KECCAK_EMPTY, }, Database, DatabaseCommit, JournaledState, }; @@ -767,8 +767,8 @@ impl Backend { self.set_spec_id(env.handler_cfg.spec_id); let test_contract = match env.tx.transact_to { - TransactTo::Call(to) => to, - TransactTo::Create => { + TxKind::Call(to) => to, + TxKind::Create => { let nonce = self .basic_ref(env.tx.caller) .map(|b| b.unwrap_or_default().nonce) diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 82663020cb605..58a088c06a4b7 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -11,7 +11,7 @@ use revm::{ return_ok, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, Gas, InstructionResult, InterpreterResult, }, - primitives::{CreateScheme, EVMError, SpecId, TransactTo, KECCAK_EMPTY}, + primitives::{CreateScheme, EVMError, SpecId, TxKind, KECCAK_EMPTY}, FrameOrResult, FrameResult, }; use std::{cell::RefCell, rc::Rc, sync::Arc}; @@ -95,7 +95,7 @@ pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { .collect(); env.tx.value = tx.value.to(); env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); - env.tx.transact_to = tx.to.map(TransactTo::Call).unwrap_or_else(TransactTo::create) + env.tx.transact_to = tx.to.map(TxKind::Call).unwrap_or(TxKind::Create) } /// Get the gas used, accounting for refunds diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 58057c93f6751..0959f2e21584a 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -30,7 +30,7 @@ use revm::{ interpreter::{return_ok, InstructionResult}, primitives::{ BlockEnv, Bytecode, Env, EnvWithHandlerCfg, ExecutionResult, Output, ResultAndState, - SpecId, TransactTo, TxEnv, + SpecId, TxEnv, TxKind, }, }; use std::{borrow::Cow, collections::HashMap}; @@ -206,7 +206,7 @@ impl Executor { value: U256, rd: Option<&RevertDecoder>, ) -> Result { - let env = self.build_test_env(from, TransactTo::Create, code, value); + let env = self.build_test_env(from, TxKind::Create, code, value); self.deploy_with_env(env, rd) } @@ -215,14 +215,14 @@ impl Executor { /// /// # Panics /// - /// Panics if `env.tx.transact_to` is not `TransactTo::Create(_)`. + /// Panics if `env.tx.transact_to` is not `TxKind::Create(_)`. pub fn deploy_with_env( &mut self, env: EnvWithHandlerCfg, rd: Option<&RevertDecoder>, ) -> Result { assert!( - matches!(env.tx.transact_to, TransactTo::Create), + matches!(env.tx.transact_to, TxKind::Create), "Expected create transaction, got {:?}", env.tx.transact_to ); @@ -331,7 +331,7 @@ impl Executor { calldata: Bytes, value: U256, ) -> eyre::Result { - let env = self.build_test_env(from, TransactTo::Call(to), calldata, value); + let env = self.build_test_env(from, TxKind::Call(to), calldata, value); self.call_with_env(env) } @@ -343,7 +343,7 @@ impl Executor { calldata: Bytes, value: U256, ) -> eyre::Result { - let env = self.build_test_env(from, TransactTo::Call(to), calldata, value); + let env = self.build_test_env(from, TxKind::Call(to), calldata, value); self.transact_with_env(env) } @@ -518,7 +518,7 @@ impl Executor { fn build_test_env( &self, caller: Address, - transact_to: TransactTo, + transact_to: TxKind, data: Bytes, value: U256, ) -> EnvWithHandlerCfg { diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index a7e08ab636aeb..8e235efe83de6 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -16,9 +16,7 @@ use revm::{ CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, }, - primitives::{ - BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, Output, TransactTo, - }, + primitives::{BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, Output, TxKind}, DatabaseCommit, EvmContext, Inspector, }; use std::{collections::HashMap, sync::Arc}; @@ -455,7 +453,7 @@ impl InspectorStack { fn transact_inner( &mut self, ecx: &mut EvmContext<&mut DB>, - transact_to: TransactTo, + transact_to: TxKind, caller: Address, input: Bytes, gas_limit: u64, @@ -477,7 +475,7 @@ impl InspectorStack { ecx.env.block.basefee = U256::ZERO; ecx.env.tx.caller = caller; - ecx.env.tx.transact_to = transact_to.clone(); + ecx.env.tx.transact_to = transact_to; ecx.env.tx.data = input; ecx.env.tx.value = value; ecx.env.tx.nonce = Some(nonce); @@ -495,7 +493,7 @@ impl InspectorStack { sender: ecx.env.tx.caller, original_origin: cached_env.tx.caller, original_sender_nonce: nonce, - is_create: matches!(transact_to, TransactTo::Create), + is_create: matches!(transact_to, TxKind::Create), }); self.in_inner_context = true; @@ -690,7 +688,7 @@ impl Inspector<&mut DB> for InspectorStack { { let (result, _) = self.transact_inner( ecx, - TransactTo::Call(call.target_address), + TxKind::Call(call.target_address), call.caller, call.input.clone(), call.gas_limit, @@ -752,7 +750,7 @@ impl Inspector<&mut DB> for InspectorStack { { let (result, address) = self.transact_inner( ecx, - TransactTo::Create, + TxKind::Create, create.caller, create.init_code.clone(), create.gas_limit, From d7eac74cfd786447cec9650048e2d2fac63fba0c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 20 Jun 2024 22:46:49 +0200 Subject: [PATCH 1133/1963] fix: use delay tick behaviour (#8221) --- crates/anvil/src/eth/miner.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index b559351fe3bf0..d928bdd94a77a 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -15,7 +15,7 @@ use std::{ task::{Context, Poll}, time::Duration, }; -use tokio::time::Interval; +use tokio::time::{Interval, MissedTickBehavior}; #[derive(Clone, Debug)] pub struct Miner { @@ -149,7 +149,11 @@ impl FixedBlockTimeMiner { /// Creates a new instance with an interval of `duration` pub fn new(duration: Duration) -> Self { let start = tokio::time::Instant::now() + duration; - Self { interval: tokio::time::interval_at(start, duration) } + let mut interval = tokio::time::interval_at(start, duration); + // we use delay here, to ensure ticks are not shortened and to tick at multiples of interval + // from when tick was called rather than from start + interval.set_missed_tick_behavior(MissedTickBehavior::Delay); + Self { interval } } fn poll(&mut self, pool: &Arc, cx: &mut Context<'_>) -> Poll>> { From cf8c80770e30c8ec6beca03c26c1d7af6d61bb2d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:44:39 +0200 Subject: [PATCH 1134/1963] ci: remove crate docs redirection --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bca1804ceb016..a4d3c23771e00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,8 +32,6 @@ jobs: run: cargo doc --workspace --all-features --no-deps --document-private-items env: RUSTDOCFLAGS: --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition -Zunstable-options - - name: Doc index page redirection - run: echo '' > target/doc/index.html - name: Deploy documentation uses: peaceiris/actions-gh-pages@v3 if: github.event_name == 'push' && github.ref == 'refs/heads/master' From 88b8d6381f24df38e8aa7fff71db8eb909ddc8e4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 21 Jun 2024 22:05:30 +0200 Subject: [PATCH 1135/1963] fix: breaking change in revm-inspectors --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/evm/traces/src/lib.rs | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f49b41f137a2..83965e839ea17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6945,9 +6945,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba2e187811b160463663fd71881b4e5d653720ba00be0f1e85962d4db60341c" +checksum = "1b0971cad2f8f1ecb10e270d80646e63bf19daef0dc0a17a45680d24bb346b7c" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 2d44d6d671d10..86748331f58aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -163,7 +163,7 @@ foundry-compilers = { version = "0.8.0", default-features = false } # no default features to avoid c-kzg revm = { version = "10.0.0", default-features = false } revm-primitives = { version = "5.0.0", default-features = false } -revm-inspectors = { version = "0.1", features = ["serde"] } +revm-inspectors = { version = "0.1.2", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 729a1b6385806..840b9253b29ec 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -12,10 +12,17 @@ use alloy_primitives::LogData; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CHEATCODE_ADDRESS; use futures::{future::BoxFuture, FutureExt}; +use revm_inspectors::tracing::types::TraceMemberOrder; use serde::{Deserialize, Serialize}; use std::fmt::Write; use yansi::{Color, Paint}; +pub use revm_inspectors::tracing::{ + types::{CallKind, CallTrace, CallTraceNode}, + CallTraceArena, GethTraceBuilder, ParityTraceBuilder, StackSnapshotType, TracingInspector, + TracingInspectorConfig, +}; + /// Call trace address identifiers. /// /// Identifiers figure out what ABIs and labels belong to all the addresses of the trace. @@ -25,13 +32,6 @@ use identifier::{LocalTraceIdentifier, TraceIdentifier}; mod decoder; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; -use revm_inspectors::tracing::types::LogCallOrder; -pub use revm_inspectors::tracing::{ - types::{CallKind, CallTrace, CallTraceNode}, - CallTraceArena, GethTraceBuilder, ParityTraceBuilder, StackSnapshotType, TracingInspector, - TracingInspectorConfig, -}; - pub type Traces = Vec<(TraceKind, CallTraceArena)>; #[derive(Default, Debug, Eq, PartialEq)] @@ -94,7 +94,7 @@ pub async fn render_trace_arena( let right_prefix = format!("{child}{PIPE}"); for child in &node.ordering { match child { - LogCallOrder::Log(index) => { + TraceMemberOrder::Log(index) => { let log = render_trace_log(&node.logs[*index], decoder).await?; // Prepend our tree structure symbols to each line of the displayed log @@ -107,7 +107,7 @@ pub async fn render_trace_arena( ) })?; } - LogCallOrder::Call(index) => { + TraceMemberOrder::Call(index) => { inner( arena, decoder, @@ -118,6 +118,7 @@ pub async fn render_trace_arena( ) .await?; } + TraceMemberOrder::Step(_) => {} } } From 90da4d2b6e3f9b0e5145afc5c4c8aba08e5755da Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 21 Jun 2024 22:09:15 +0200 Subject: [PATCH 1136/1963] ci: enable index page for crate docs --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a4d3c23771e00..982cb068cdd34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: - name: Build documentation run: cargo doc --workspace --all-features --no-deps --document-private-items env: - RUSTDOCFLAGS: --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition -Zunstable-options + RUSTDOCFLAGS: --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition --enable-index-page -Zunstable-options - name: Deploy documentation uses: peaceiris/actions-gh-pages@v3 if: github.event_name == 'push' && github.ref == 'refs/heads/master' From 0c3657e3c83f3c0b40ada4956c0f2d9fb3d178eb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:23:13 +0200 Subject: [PATCH 1137/1963] chore(evm): use u64 for gas limit (#8226) --- crates/evm/core/src/opts.rs | 8 ++++---- crates/evm/evm/src/executors/builder.rs | 23 +++++++++++------------ crates/evm/evm/src/executors/mod.rs | 16 +++++++++++----- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 4ff429902e7eb..d676c90b363ec 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -123,13 +123,13 @@ impl EvmOpts { difficulty: U256::from(self.env.block_difficulty), prevrandao: Some(self.env.block_prevrandao), basefee: U256::from(self.env.block_base_fee_per_gas), - gas_limit: self.gas_limit(), + gas_limit: U256::from(self.gas_limit()), ..Default::default() }, cfg, tx: TxEnv { gas_price: U256::from(self.env.gas_price.unwrap_or_default()), - gas_limit: self.gas_limit().to(), + gas_limit: self.gas_limit(), caller: self.sender, ..Default::default() }, @@ -156,8 +156,8 @@ impl EvmOpts { } /// Returns the gas limit to use - pub fn gas_limit(&self) -> U256 { - U256::from(self.env.block_gas_limit.unwrap_or(self.env.gas_limit)) + pub fn gas_limit(&self) -> u64 { + self.env.block_gas_limit.unwrap_or(self.env.gas_limit) } /// Returns the configured chain id, which will be diff --git a/crates/evm/evm/src/executors/builder.rs b/crates/evm/evm/src/executors/builder.rs index 97cdc92187d4b..69b798161eb2e 100644 --- a/crates/evm/evm/src/executors/builder.rs +++ b/crates/evm/evm/src/executors/builder.rs @@ -1,5 +1,4 @@ use crate::{executors::Executor, inspectors::InspectorStackBuilder}; -use alloy_primitives::U256; use foundry_evm_core::backend::Backend; use revm::primitives::{Env, EnvWithHandlerCfg, SpecId}; @@ -16,7 +15,7 @@ pub struct ExecutorBuilder { /// The configuration used to build an `InspectorStack`. stack: InspectorStackBuilder, /// The gas limit. - gas_limit: Option, + gas_limit: Option, /// The spec ID. spec_id: SpecId, } @@ -54,7 +53,7 @@ impl ExecutorBuilder { /// Sets the executor gas limit. #[inline] - pub fn gas_limit(mut self, gas_limit: U256) -> Self { + pub fn gas_limit(mut self, gas_limit: u64) -> Self { self.gas_limit = Some(gas_limit); self } @@ -63,14 +62,14 @@ impl ExecutorBuilder { #[inline] pub fn build(self, env: Env, db: Backend) -> Executor { let Self { mut stack, gas_limit, spec_id } = self; - stack.block = Some(env.block.clone()); - stack.gas_price = Some(env.tx.gas_price); - let gas_limit = gas_limit.unwrap_or(env.block.gas_limit); - Executor::new( - db, - EnvWithHandlerCfg::new_with_spec_id(Box::new(env), spec_id), - stack.build(), - gas_limit, - ) + if stack.block.is_none() { + stack.block = Some(env.block.clone()); + } + if stack.gas_price.is_none() { + stack.gas_price = Some(env.tx.gas_price); + } + let gas_limit = gas_limit.unwrap_or_else(|| env.block.gas_limit.saturating_to()); + let env = EnvWithHandlerCfg::new_with_spec_id(Box::new(env), spec_id); + Executor::new(db, env, stack.build(), gas_limit) } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 0959f2e21584a..753cd5318aa4e 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -80,17 +80,23 @@ pub struct Executor { /// The gas limit for calls and deployments. This is different from the gas limit imposed by /// the passed in environment, as those limits are used by the EVM for certain opcodes like /// `gaslimit`. - gas_limit: U256, + gas_limit: u64, } impl Executor { + /// Creates a new `ExecutorBuilder`. + #[inline] + pub fn builder() -> ExecutorBuilder { + ExecutorBuilder::new() + } + /// Creates a new `Executor` with the given arguments. #[inline] pub fn new( mut backend: Backend, env: EnvWithHandlerCfg, inspector: InspectorStack, - gas_limit: U256, + gas_limit: u64, ) -> Self { // Need to create a non-empty contract on the cheatcodes address so `extcodesize` checks // does not fail @@ -190,7 +196,7 @@ impl Executor { } #[inline] - pub fn set_gas_limit(&mut self, gas_limit: U256) -> &mut Self { + pub fn set_gas_limit(&mut self, gas_limit: u64) -> &mut Self { self.gas_limit = gas_limit; self } @@ -529,7 +535,7 @@ impl Executor { // the cheatcode handler if it is enabled block: BlockEnv { basefee: U256::ZERO, - gas_limit: self.gas_limit, + gas_limit: U256::from(self.gas_limit), ..self.env.block.clone() }, tx: TxEnv { @@ -540,7 +546,7 @@ impl Executor { // As above, we set the gas price to 0. gas_price: U256::ZERO, gas_priority_fee: None, - gas_limit: self.gas_limit.to(), + gas_limit: self.gas_limit, ..self.env.tx.clone() }, }; From 43eb061f74b43dcb56fcc641a37f15a9c2c34383 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 22 Jun 2024 17:34:42 +0200 Subject: [PATCH 1138/1963] docs: update Backend and MultiFork docs (#8229) --- crates/evm/core/src/backend/mod.rs | 10 ++++++++-- crates/evm/core/src/fork/multi.rs | 18 +++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index ed7a9efb6fa6a..faab0800c7955 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -385,6 +385,7 @@ struct _ObjectSafe(dyn DatabaseExt); /// snapshot is created before fork `B` is selected, then fork `A` will be the active fork again /// after reverting the snapshot. #[derive(Clone, Debug)] +#[must_use] pub struct Backend { /// The access point for managing forks forks: MultiFork, @@ -417,14 +418,19 @@ pub struct Backend { impl Backend { /// Creates a new Backend with a spawned multi fork thread. + /// + /// If `fork` is `Some` this will use a `fork` database, otherwise with an in-memory + /// database. pub fn spawn(fork: Option) -> Self { Self::new(MultiFork::spawn(), fork) } /// Creates a new instance of `Backend` /// - /// if `fork` is `Some` this will launch with a `fork` database, otherwise with an in-memory - /// database + /// If `fork` is `Some` this will use a `fork` database, otherwise with an in-memory + /// database. + /// + /// Prefer using [`spawn`](Self::spawn) instead. pub fn new(forks: MultiFork, fork: Option) -> Self { trace!(target: "backend", forking_mode=?fork.is_some(), "creating executor backend"); // Note: this will take of registering the `fork` diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 79b30c0ce8b94..8b18e2d7fe0c5 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -65,6 +65,7 @@ impl> From for ForkId { /// The Sender half of multi fork pair. /// Can send requests to the `MultiForkHandler` to create forks #[derive(Clone, Debug)] +#[must_use] pub struct MultiFork { /// Channel to send `Request`s to the handler handler: Sender, @@ -73,13 +74,6 @@ pub struct MultiFork { } impl MultiFork { - /// Creates a new pair multi fork pair - pub fn new() -> (Self, MultiForkHandler) { - let (handler, handler_rx) = channel(1); - let _shutdown = Arc::new(ShutDownMultiFork { handler: Some(handler.clone()) }); - (Self { handler, _shutdown }, MultiForkHandler::new(handler_rx)) - } - /// Creates a new pair and spawns the `MultiForkHandler` on a background thread. pub fn spawn() -> Self { trace!(target: "fork::multi", "spawning multifork"); @@ -109,6 +103,16 @@ impl MultiFork { fork } + /// Creates a new pair multi fork pair. + /// + /// Use [`spawn`](Self::spawn) instead. + #[doc(hidden)] + pub fn new() -> (Self, MultiForkHandler) { + let (handler, handler_rx) = channel(1); + let _shutdown = Arc::new(ShutDownMultiFork { handler: Some(handler.clone()) }); + (Self { handler, _shutdown }, MultiForkHandler::new(handler_rx)) + } + /// Returns a fork backend /// /// If no matching fork backend exists it will be created From 91d145cfd7bc4c4dae9533a7d3caed0a5fa83b6d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 23 Jun 2024 11:13:21 +0200 Subject: [PATCH 1139/1963] chore(deps): weekly `cargo update` (#8230) Locking 9 packages to latest compatible versions Updating alloy-chains v0.1.21 -> v0.1.22 Updating aws-types v1.3.1 -> v1.3.2 Updating clap_complete v4.5.5 -> v4.5.6 Updating displaydoc v0.2.4 -> v0.2.5 Updating lazy_static v1.4.0 -> v1.5.0 Updating proc-macro2 v1.0.85 -> v1.0.86 Updating proptest v1.4.0 -> v1.5.0 Removing spin v0.5.2 Updating subtle v2.5.0 -> v2.6.0 Updating syn v2.0.66 -> v2.0.67 note: pass `--verbose` to see 160 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 145 +++++++++++++++++++++++++---------------------------- 1 file changed, 69 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83965e839ea17..7f35562398f40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd47e5f8545bdf53beb545d3c039b4afa16040bdf69c50100581579b08776afd" +checksum = "04e9a1892803b02f53e25bea3e414ddd0501f12d97456c9d5ade4edf88f9516f" dependencies = [ "num_enum", "serde", @@ -306,7 +306,7 @@ checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -552,7 +552,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -569,7 +569,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "syn-solidity", "tiny-keccak", ] @@ -587,7 +587,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.66", + "syn 2.0.67", "syn-solidity", ] @@ -1097,7 +1097,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1119,7 +1119,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1130,7 +1130,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1177,7 +1177,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -1491,15 +1491,14 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f734808d43702a67e57d478a12e227d4d038d0b90c9005a78c87890d3805922" +checksum = "2009a9733865d0ebf428a314440bbe357cc10d0c16d86a8e15d32e9b47c1e80e" dependencies = [ "aws-credential-types", "aws-smithy-async", "aws-smithy-runtime-api", "aws-smithy-types", - "http 0.2.12", "rustc_version 0.4.0", "tracing", ] @@ -2109,9 +2108,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.5" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2020fa13af48afc65a9a87335bda648309ab3d154cd03c7ff95b378c7ed39c4" +checksum = "fbca90c87c2a04da41e95d1856e8bcd22f159bdbfa147314d2ce5218057b0e58" dependencies = [ "clap", ] @@ -2135,7 +2134,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2565,7 +2564,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2576,7 +2575,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2648,7 +2647,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2669,7 +2668,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2679,7 +2678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2692,7 +2691,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2793,13 +2792,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -2935,7 +2934,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3085,7 +3084,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.66", + "syn 2.0.67", "toml 0.8.14", "walkdir", ] @@ -3113,7 +3112,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.66", + "syn 2.0.67", "tempfile", "thiserror", "tiny-keccak", @@ -3477,7 +3476,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -3987,7 +3986,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4146,7 +4145,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -4634,7 +4633,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5257,11 +5256,11 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin", ] [[package]] @@ -5477,7 +5476,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5547,7 +5546,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5778,7 +5777,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -5901,7 +5900,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -6072,7 +6071,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -6131,7 +6130,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -6215,7 +6214,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -6273,7 +6272,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -6389,7 +6388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -6450,9 +6449,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -6465,7 +6464,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "version_check", "yansi", ] @@ -6483,9 +6482,9 @@ dependencies = [ [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", @@ -6532,7 +6531,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -7029,7 +7028,7 @@ dependencies = [ "cfg-if", "getrandom", "libc", - "spin 0.9.8", + "spin", "untrusted", "windows-sys 0.52.0", ] @@ -7415,7 +7414,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -7571,7 +7570,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -7582,7 +7581,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -7625,7 +7624,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -7671,7 +7670,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -7917,12 +7916,6 @@ dependencies = [ "zip-extract", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -7946,7 +7939,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" dependencies = [ "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -8018,7 +8011,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -8036,9 +8029,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "svm-rs" @@ -8086,9 +8079,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" dependencies = [ "proc-macro2", "quote", @@ -8104,7 +8097,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -8226,7 +8219,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -8372,7 +8365,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -8651,7 +8644,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -9012,7 +9005,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "wasm-bindgen-shared", ] @@ -9046,7 +9039,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9507,7 +9500,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] @@ -9527,7 +9520,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.67", ] [[package]] From e3267bdffaa4b2575a2456527d96f4d9d69c824c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:26:57 +0200 Subject: [PATCH 1140/1963] feat(evm): collect logs from execution result (#8231) --- crates/config/src/providers/remappings.rs | 2 +- crates/evm/core/src/fork/init.rs | 1 - crates/evm/evm/src/executors/invariant/mod.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 52 +++++++++---------- crates/evm/evm/src/inspectors/logs.rs | 1 - 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 41b3fb80dacf4..5b979d6611c97 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -151,7 +151,7 @@ impl<'a> RemappingsProvider<'a> { let mut all_remappings = Remappings::new_with_remappings(user_remappings); // scan all library dirs and autodetect remappings - // todo: if a lib specifies contexts for remappings manually, we need to figure out how to + // TODO: if a lib specifies contexts for remappings manually, we need to figure out how to // resolve that if self.auto_detect_remappings { let mut lib_remappings = BTreeMap::new(); diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index b69e02aad9db2..f60b99cb97087 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -10,7 +10,6 @@ use revm::primitives::{BlockEnv, CfgEnv, Env, TxEnv}; /// Initializes a REVM block environment based on a forked /// ethereum provider. -// todo(onbjerg): these bounds needed cus of the bounds in `Provider`, can simplify? pub async fn environment>( provider: &P, memory_limit: u64, diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index a260fcb566775..bdc3567bf787b 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -236,7 +236,7 @@ impl<'a> InvariantExecutor<'a> { } } else { // Collect data for fuzzing from the state changeset. - let mut state_changeset = call_result.state_changeset.clone().unwrap(); + let mut state_changeset = call_result.state_changeset.clone(); if !call_result.reverted { collect_data( diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 753cd5318aa4e..2dd101c4e5772 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -274,11 +274,10 @@ impl Executor { // and also the chainid, which can be set manually self.env.cfg.chain_id = res.env.cfg.chain_id; - if let Some(changeset) = &res.state_changeset { - let success = self.is_raw_call_success(to, Cow::Borrowed(changeset), &res, false); - if !success { - return Err(res.into_execution_error("execution error".to_string()).into()); - } + let success = + self.is_raw_call_success(to, Cow::Borrowed(&res.state_changeset), &res, false); + if !success { + return Err(res.into_execution_error("execution error".to_string()).into()); } Ok(res) @@ -380,9 +379,7 @@ impl Executor { /// This should not be exposed to the user, as it should be called only by `transact*`. fn commit(&mut self, result: &mut RawCallResult) { // Persist changes to db. - if let Some(changes) = &result.state_changeset { - self.backend.commit(changes.clone()); - } + self.backend.commit(result.state_changeset.clone()); // Persist cheatcode state. self.inspector.cheatcodes = result.cheatcodes.take(); @@ -411,7 +408,7 @@ impl Executor { ) -> bool { self.is_raw_call_success( address, - Cow::Owned(call_result.state_changeset.take().unwrap_or_default()), + Cow::Owned(std::mem::take(&mut call_result.state_changeset)), call_result, should_fail, ) @@ -667,7 +664,7 @@ pub struct RawCallResult { /// Scripted transactions generated from this call pub transactions: Option, /// The changeset of the state. - pub state_changeset: Option, + pub state_changeset: StateChangeset, /// The `revm::Env` after the call pub env: EnvWithHandlerCfg, /// The cheatcode states after execution @@ -694,7 +691,7 @@ impl Default for RawCallResult { coverage: None, debug: None, transactions: None, - state_changeset: None, + state_changeset: HashMap::default(), env: EnvWithHandlerCfg::new_with_spec_id(Box::default(), SpecId::LATEST), cheatcodes: Default::default(), out: None, @@ -778,19 +775,20 @@ impl std::ops::DerefMut for CallResult { fn convert_executed_result( env: EnvWithHandlerCfg, inspector: InspectorStack, - result: ResultAndState, + ResultAndState { result, state: state_changeset }: ResultAndState, has_snapshot_failure: bool, ) -> eyre::Result { - let ResultAndState { result: exec_result, state: state_changeset } = result; - let (exit_reason, gas_refunded, gas_used, out) = match exec_result { - ExecutionResult::Success { reason, gas_used, gas_refunded, output, .. } => { - (reason.into(), gas_refunded, gas_used, Some(output)) + let (exit_reason, gas_refunded, gas_used, out, exec_logs) = match result { + ExecutionResult::Success { reason, gas_used, gas_refunded, output, logs, .. } => { + (reason.into(), gas_refunded, gas_used, Some(output), logs) } ExecutionResult::Revert { gas_used, output } => { // Need to fetch the unused gas - (InstructionResult::Revert, 0_u64, gas_used, Some(Output::Call(output))) + (InstructionResult::Revert, 0_u64, gas_used, Some(Output::Call(output)), vec![]) + } + ExecutionResult::Halt { reason, gas_used } => { + (reason.into(), 0_u64, gas_used, None, vec![]) } - ExecutionResult::Halt { reason, gas_used } => (reason.into(), 0_u64, gas_used, None), }; let stipend = revm::interpreter::gas::validate_initial_tx_gas( env.spec_id(), @@ -804,15 +802,17 @@ fn convert_executed_result( _ => Bytes::new(), }; - let InspectorData { logs, labels, traces, coverage, debug, cheatcodes, chisel_state } = + let InspectorData { mut logs, labels, traces, coverage, debug, cheatcodes, chisel_state } = inspector.collect(); - let transactions = match cheatcodes.as_ref() { - Some(cheats) if !cheats.broadcastable_transactions.is_empty() => { - Some(cheats.broadcastable_transactions.clone()) - } - _ => None, - }; + if logs.is_empty() { + logs = exec_logs; + } + + let transactions = cheatcodes + .as_ref() + .map(|c| c.broadcastable_transactions.clone()) + .filter(|txs| !txs.is_empty()); Ok(RawCallResult { exit_reason, @@ -828,7 +828,7 @@ fn convert_executed_result( coverage, debug, transactions, - state_changeset: Some(state_changeset), + state_changeset, env, cheatcodes, out, diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index bde558dbfa597..ec95fb41ca5fc 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -42,7 +42,6 @@ impl Inspector for LogCollector { self.logs.push(log.clone()); } - #[inline] fn call( &mut self, _context: &mut EvmContext, From 7074d20dc711d1620fd3d715cc8cb6518b0da20a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 23 Jun 2024 14:57:07 +0200 Subject: [PATCH 1141/1963] chore(evm): make Executor fields private (#8233) --- crates/chisel/src/runner.rs | 23 ++-- crates/evm/core/src/backend/cow.rs | 2 +- crates/evm/evm/src/executors/fuzz/mod.rs | 4 +- crates/evm/evm/src/executors/invariant/mod.rs | 5 +- .../evm/evm/src/executors/invariant/replay.rs | 2 +- .../evm/evm/src/executors/invariant/result.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 119 +++++++++++------- crates/forge/src/runner.rs | 8 +- crates/script/src/runner.rs | 12 +- crates/script/src/simulate.rs | 2 +- crates/verify/src/bytecode.rs | 2 +- 11 files changed, 108 insertions(+), 73 deletions(-) diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index ff4c9695e6524..35fd167733680 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -125,19 +125,20 @@ impl ChiselRunner { value: U256, commit: bool, ) -> eyre::Result { - let fs_commit_changed = if let Some(cheatcodes) = &mut self.executor.inspector.cheatcodes { - let original_fs_commit = cheatcodes.fs_commit; - cheatcodes.fs_commit = false; - original_fs_commit != cheatcodes.fs_commit - } else { - false - }; + let fs_commit_changed = + if let Some(cheatcodes) = &mut self.executor.inspector_mut().cheatcodes { + let original_fs_commit = cheatcodes.fs_commit; + cheatcodes.fs_commit = false; + original_fs_commit != cheatcodes.fs_commit + } else { + false + }; let mut res = self.executor.call_raw(from, to, calldata.clone(), value)?; let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { // store the current gas limit and reset it later - let init_gas_limit = self.executor.env.tx.gas_limit; + let init_gas_limit = self.executor.env().tx.gas_limit; // the executor will return the _exact_ gas value this transaction consumed, setting // this value as gas limit will result in `OutOfGas` so to come up with a @@ -148,7 +149,7 @@ impl ChiselRunner { let mut last_highest_gas_limit = highest_gas_limit; while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; - self.executor.env.tx.gas_limit = mid_gas_limit; + self.executor.env_mut().tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw(from, to, calldata.clone(), value)?; match res.exit_reason { InstructionResult::Revert | @@ -174,13 +175,13 @@ impl ChiselRunner { } } // reset gas limit in the - self.executor.env.tx.gas_limit = init_gas_limit; + self.executor.env_mut().tx.gas_limit = init_gas_limit; } // if we changed `fs_commit` during gas limit search, re-execute the call with original // value if fs_commit_changed { - if let Some(cheatcodes) = &mut self.executor.inspector.cheatcodes { + if let Some(cheatcodes) = &mut self.executor.inspector_mut().cheatcodes { cheatcodes.fs_commit = !cheatcodes.fs_commit; } diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 9b53fb4ee29aa..583bf3416f7fb 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -51,7 +51,7 @@ pub struct CowBackend<'a> { impl<'a> CowBackend<'a> { /// Creates a new `CowBackend` with the given `Backend`. - pub fn new(backend: &'a Backend) -> Self { + pub fn new_borrowed(backend: &'a Backend) -> Self { Self { backend: Cow::Borrowed(backend), is_initialized: false, spec_id: SpecId::LATEST } } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index b578a65f3bb26..9cd406f621958 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -234,10 +234,10 @@ impl FuzzedExecutor { /// Stores fuzz state for use with [fuzz_calldata_from_state] pub fn build_fuzz_state(&self) -> EvmFuzzState { - if let Some(fork_db) = self.executor.backend.active_fork_db() { + if let Some(fork_db) = self.executor.backend().active_fork_db() { EvmFuzzState::new(fork_db, self.config.dictionary) } else { - EvmFuzzState::new(self.executor.backend.mem_db(), self.config.dictionary) + EvmFuzzState::new(self.executor.backend().mem_db(), self.config.dictionary) } } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index bdc3567bf787b..06a8ba0754a18 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -364,7 +364,8 @@ impl<'a> InvariantExecutor<'a> { self.select_contracts_and_senders(invariant_contract.address)?; // Stores fuzz state for use with [fuzz_calldata_from_state]. - let fuzz_state = EvmFuzzState::new(self.executor.backend.mem_db(), self.config.dictionary); + let fuzz_state = + EvmFuzzState::new(self.executor.backend().mem_db(), self.config.dictionary); // Creates the invariant strategy. let strat = invariant_strat( @@ -395,7 +396,7 @@ impl<'a> InvariantExecutor<'a> { )); } - self.executor.inspector.fuzzer = + self.executor.inspector_mut().fuzzer = Some(Fuzzer { call_generator, fuzz_state: fuzz_state.clone(), collect: true }); Ok((fuzz_state, targeted_contracts, strat)) diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index cf9fa12e81fc8..e985cf7ba17e2 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -138,7 +138,7 @@ pub fn replay_error( /// Sets up the calls generated by the internal fuzzer, if they exist. fn set_up_inner_replay(executor: &mut Executor, inner_sequence: &[Option]) { - if let Some(fuzzer) = &mut executor.inspector.fuzzer { + if let Some(fuzzer) = &mut executor.inspector_mut().fuzzer { if let Some(call_generator) = &mut fuzzer.call_generator { call_generator.last_sequence = Arc::new(RwLock::new(inner_sequence.to_owned())); call_generator.set_replay(true); diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index 5ddcccaf0d3f1..f45ec2c349a9d 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -56,7 +56,7 @@ pub(crate) fn assert_invariants( ) -> Result> { let mut inner_sequence = vec![]; - if let Some(fuzzer) = &executor.inspector.fuzzer { + if let Some(fuzzer) = &executor.inspector().fuzzer { if let Some(call_generator) = &fuzzer.call_generator { inner_sequence.extend(call_generator.last_sequence.read().iter().cloned()); } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 2dd101c4e5772..79ec0160cf570 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -72,11 +72,11 @@ pub struct Executor { // only interested in the database. REVM's `EVM` is a thin // wrapper around spawning a new EVM on every call anyway, // so the performance difference should be negligible. - pub backend: Backend, + backend: Backend, /// The EVM environment. - pub env: EnvWithHandlerCfg, + env: EnvWithHandlerCfg, /// The Revm inspector stack. - pub inspector: InspectorStack, + inspector: InspectorStack, /// The gas limit for calls and deployments. This is different from the gas limit imposed by /// the passed in environment, as those limits are used by the EVM for certain opcodes like /// `gaslimit`. @@ -99,7 +99,7 @@ impl Executor { gas_limit: u64, ) -> Self { // Need to create a non-empty contract on the cheatcodes address so `extcodesize` checks - // does not fail + // do not fail. backend.insert_account_info( CHEATCODE_ADDRESS, revm::primitives::AccountInfo { @@ -114,16 +114,51 @@ impl Executor { Self { backend, env, inspector, gas_limit } } - /// Returns the spec ID of the executor. + fn clone_with_backend(&self, backend: Backend) -> Self { + let env = EnvWithHandlerCfg::new_with_spec_id(Box::new(self.env().clone()), self.spec_id()); + Self::new(backend, env, self.inspector().clone(), self.gas_limit) + } + + /// Returns a reference to the EVM backend. + pub fn backend(&self) -> &Backend { + &self.backend + } + + /// Returns a mutable reference to the EVM backend. + pub fn backend_mut(&mut self) -> &mut Backend { + &mut self.backend + } + + /// Returns a reference to the EVM environment. + pub fn env(&self) -> &Env { + &self.env.env + } + + /// Returns a mutable reference to the EVM environment. + pub fn env_mut(&mut self) -> &mut Env { + &mut self.env.env + } + + /// Returns a reference to the EVM inspector. + pub fn inspector(&self) -> &InspectorStack { + &self.inspector + } + + /// Returns a mutable reference to the EVM inspector. + pub fn inspector_mut(&mut self) -> &mut InspectorStack { + &mut self.inspector + } + + /// Returns the EVM spec ID. pub fn spec_id(&self) -> SpecId { - self.env.handler_cfg.spec_id + self.env.spec_id() } /// Creates the default CREATE2 Contract Deployer for local tests and scripts. pub fn deploy_create2_deployer(&mut self) -> eyre::Result<()> { trace!("deploying local create2 deployer"); let create2_deployer_account = self - .backend + .backend() .basic_ref(DEFAULT_CREATE2_DEPLOYER)? .ok_or_else(|| DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; @@ -145,53 +180,52 @@ impl Executor { } /// Set the balance of an account. - pub fn set_balance(&mut self, address: Address, amount: U256) -> DatabaseResult<&mut Self> { + pub fn set_balance(&mut self, address: Address, amount: U256) -> DatabaseResult<()> { trace!(?address, ?amount, "setting account balance"); - let mut account = self.backend.basic_ref(address)?.unwrap_or_default(); + let mut account = self.backend().basic_ref(address)?.unwrap_or_default(); account.balance = amount; - - self.backend.insert_account_info(address, account); - Ok(self) + self.backend_mut().insert_account_info(address, account); + Ok(()) } /// Gets the balance of an account pub fn get_balance(&self, address: Address) -> DatabaseResult { - Ok(self.backend.basic_ref(address)?.map(|acc| acc.balance).unwrap_or_default()) + Ok(self.backend().basic_ref(address)?.map(|acc| acc.balance).unwrap_or_default()) } /// Set the nonce of an account. - pub fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<&mut Self> { - let mut account = self.backend.basic_ref(address)?.unwrap_or_default(); + pub fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()> { + let mut account = self.backend().basic_ref(address)?.unwrap_or_default(); account.nonce = nonce; - self.backend.insert_account_info(address, account); - Ok(self) + self.backend_mut().insert_account_info(address, account); + Ok(()) } /// Returns the nonce of an account. pub fn get_nonce(&self, address: Address) -> DatabaseResult { - Ok(self.backend.basic_ref(address)?.map(|acc| acc.nonce).unwrap_or_default()) + Ok(self.backend().basic_ref(address)?.map(|acc| acc.nonce).unwrap_or_default()) } /// Returns `true` if the account has no code. pub fn is_empty_code(&self, address: Address) -> DatabaseResult { - Ok(self.backend.basic_ref(address)?.map(|acc| acc.is_empty_code_hash()).unwrap_or(true)) + Ok(self.backend().basic_ref(address)?.map(|acc| acc.is_empty_code_hash()).unwrap_or(true)) } #[inline] pub fn set_tracing(&mut self, tracing: bool) -> &mut Self { - self.inspector.tracing(tracing); + self.inspector_mut().tracing(tracing); self } #[inline] pub fn set_debugger(&mut self, debugger: bool) -> &mut Self { - self.inspector.enable_debugger(debugger); + self.inspector_mut().enable_debugger(debugger); self } #[inline] pub fn set_trace_printer(&mut self, trace_printer: bool) -> &mut Self { - self.inspector.print(trace_printer); + self.inspector_mut().print(trace_printer); self } @@ -242,7 +276,7 @@ impl Executor { // also mark this library as persistent, this will ensure that the state of the library is // persistent across fork swaps in forking mode - self.backend.add_persistent_account(address); + self.backend_mut().add_persistent_account(address); debug!(%address, "deployed contract"); @@ -264,15 +298,15 @@ impl Executor { trace!(?from, ?to, "setting up contract"); let from = from.unwrap_or(CALLER); - self.backend.set_test_contract(to).set_caller(from); + self.backend_mut().set_test_contract(to).set_caller(from); let calldata = Bytes::from_static(&ITest::setUpCall::SELECTOR); let mut res = self.transact_raw(from, to, calldata, U256::ZERO)?; res = res.into_result(rd)?; // record any changes made to the block's environment during setup - self.env.block = res.env.block.clone(); + self.env_mut().block = res.env.block.clone(); // and also the chainid, which can be set manually - self.env.cfg.chain_id = res.env.cfg.chain_id; + self.env_mut().cfg.chain_id = res.env.cfg.chain_id; let success = self.is_raw_call_success(to, Cow::Borrowed(&res.state_changeset), &res, false); @@ -356,16 +390,16 @@ impl Executor { /// /// The state after the call is **not** persisted. pub fn call_with_env(&self, mut env: EnvWithHandlerCfg) -> eyre::Result { - let mut inspector = self.inspector.clone(); - let mut backend = CowBackend::new(&self.backend); + let mut inspector = self.inspector().clone(); + let mut backend = CowBackend::new_borrowed(self.backend()); let result = backend.inspect(&mut env, &mut inspector)?; convert_executed_result(env, inspector, result, backend.has_snapshot_failure()) } /// Execute the transaction configured in `env.tx`. pub fn transact_with_env(&mut self, mut env: EnvWithHandlerCfg) -> eyre::Result { - let mut inspector = self.inspector.clone(); - let backend = &mut self.backend; + let mut inspector = self.inspector().clone(); + let backend = self.backend_mut(); let result = backend.inspect(&mut env, &mut inspector)?; let mut result = convert_executed_result(env, inspector, result, backend.has_snapshot_failure())?; @@ -379,11 +413,11 @@ impl Executor { /// This should not be exposed to the user, as it should be called only by `transact*`. fn commit(&mut self, result: &mut RawCallResult) { // Persist changes to db. - self.backend.commit(result.state_changeset.clone()); + self.backend_mut().commit(result.state_changeset.clone()); // Persist cheatcode state. - self.inspector.cheatcodes = result.cheatcodes.take(); - if let Some(cheats) = self.inspector.cheatcodes.as_mut() { + self.inspector_mut().cheatcodes = result.cheatcodes.take(); + if let Some(cheats) = self.inspector_mut().cheatcodes.as_mut() { // Clear broadcastable transactions cheats.broadcastable_transactions.clear(); debug!(target: "evm::executors", "cleared broadcastable transactions"); @@ -393,7 +427,7 @@ impl Executor { } // Persist the changed environment. - self.inspector.set_env(&result.env); + self.inspector_mut().set_env(&result.env); } /// Checks if a call to a test contract was successful. @@ -474,7 +508,7 @@ impl Executor { reverted: bool, state_changeset: Cow<'_, StateChangeset>, ) -> bool { - if self.backend.has_snapshot_failure() { + if self.backend().has_snapshot_failure() { // a failure occurred in a reverted snapshot, which is considered a failed test return false; } @@ -482,12 +516,12 @@ impl Executor { let mut success = !reverted; if success { // Construct a new bare-bones backend to evaluate success. - let mut backend = self.backend.clone_empty(); + let mut backend = self.backend().clone_empty(); // We only clone the test contract and cheatcode accounts, // that's all we need to evaluate success. for address in [address, CHEATCODE_ADDRESS] { - let Ok(acc) = self.backend.basic_ref(address) else { return false }; + let Ok(acc) = self.backend().basic_ref(address) else { return false }; backend.insert_account_info(address, acc.unwrap_or_default()); } @@ -498,8 +532,7 @@ impl Executor { backend.commit(state_changeset.into_owned()); // Check if a DSTest assertion failed - let executor = - Self::new(backend, self.env.clone(), self.inspector.clone(), self.gas_limit); + let executor = self.clone_with_backend(backend); let call = executor.call_sol(CALLER, address, &ITest::failedCall {}, U256::ZERO, None); match call { Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { failed } }) => { @@ -526,14 +559,14 @@ impl Executor { value: U256, ) -> EnvWithHandlerCfg { let env = Env { - cfg: self.env.cfg.clone(), + cfg: self.env().cfg.clone(), // We always set the gas price to 0 so we can execute the transaction regardless of // network conditions - the actual gas price is kept in `self.block` and is applied by // the cheatcode handler if it is enabled block: BlockEnv { basefee: U256::ZERO, gas_limit: U256::from(self.gas_limit), - ..self.env.block.clone() + ..self.env().block.clone() }, tx: TxEnv { caller, @@ -544,11 +577,11 @@ impl Executor { gas_price: U256::ZERO, gas_priority_fee: None, gas_limit: self.gas_limit, - ..self.env.tx.clone() + ..self.env().tx.clone() }, }; - EnvWithHandlerCfg::new_with_spec_id(Box::new(env), self.env.handler_cfg.spec_id) + EnvWithHandlerCfg::new_with_spec_id(Box::new(env), self.spec_id()) } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index c0bb78fa26b76..25a6266d9e5fb 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -333,7 +333,8 @@ impl<'a> ContractRunner<'a> { // Invariant testing requires tracing to figure out what contracts were created. let has_invariants = self.contract.abi.functions().any(|func| func.is_invariant_test()); - let tmp_tracing = self.executor.inspector.tracer.is_none() && has_invariants && call_setup; + let tmp_tracing = + self.executor.inspector().tracer.is_none() && has_invariants && call_setup; if tmp_tracing { self.executor.set_tracing(true); } @@ -671,12 +672,11 @@ impl<'a> ContractRunner<'a> { return test_result.single_skip() } - // if should debug if self.debug { let mut debug_executor = self.executor.clone(); // turn the debug traces on - debug_executor.inspector.enable_debugger(true); - debug_executor.inspector.tracing(true); + debug_executor.inspector_mut().enable_debugger(true); + debug_executor.inspector_mut().tracing(true); let calldata = if let Some(counterexample) = result.counterexample.as_ref() { match counterexample { CounterExample::Single(ce) => ce.calldata.clone(), diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index e107180a8b282..9ecd80859bb89 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -145,7 +145,7 @@ impl ScriptRunner { // Optionally call the `setUp` function let (success, gas_used, labeled_addresses, transactions, debug) = if !setup { - self.executor.backend.set_test_contract(address); + self.executor.backend_mut().set_test_contract(address); ( true, 0, @@ -343,15 +343,15 @@ impl ScriptRunner { ) -> Result { let mut gas_used = res.gas_used; if matches!(res.exit_reason, return_ok!()) { - // store the current gas limit and reset it later - let init_gas_limit = self.executor.env.tx.gas_limit; + // Store the current gas limit and reset it later. + let init_gas_limit = self.executor.env().tx.gas_limit; let mut highest_gas_limit = gas_used * 3; let mut lowest_gas_limit = gas_used; let mut last_highest_gas_limit = highest_gas_limit; while (highest_gas_limit - lowest_gas_limit) > 1 { let mid_gas_limit = (highest_gas_limit + lowest_gas_limit) / 2; - self.executor.env.tx.gas_limit = mid_gas_limit; + self.executor.env_mut().tx.gas_limit = mid_gas_limit; let res = self.executor.call_raw(from, to, calldata.0.clone().into(), value)?; match res.exit_reason { InstructionResult::Revert | @@ -376,8 +376,8 @@ impl ScriptRunner { } } } - // reset gas limit in the - self.executor.env.tx.gas_limit = init_gas_limit; + // Reset gas limit in the executor. + self.executor.env_mut().tx.gas_limit = init_gas_limit; } Ok(gas_used) } diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 2b1fb14cf7ad9..d2546cda3899a 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -118,7 +118,7 @@ impl PreSimulationState { // Simulate mining the transaction if the user passes `--slow`. if self.args.slow { - runner.executor.env.block.number += U256::from(1); + runner.executor.env_mut().block.number += U256::from(1); } let is_fixed_gas_limit = tx.gas.is_some(); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index cc7a733995e70..79b7a7c8b5a07 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -329,7 +329,7 @@ impl VerifyBytecodeArgs { // State commited using deploy_with_env, now get the runtime bytecode from the db. let fork_runtime_code = executor - .backend + .backend_mut() .basic(contract_address)? .ok_or_else(|| { eyre::eyre!( From ba9fa2075c33e88e826de819f4d659d7a852ce0d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 23 Jun 2024 23:10:28 +0200 Subject: [PATCH 1142/1963] feat: improve test function classification (#8235) --- crates/cli/src/utils/mod.rs | 1 - crates/common/src/compile.rs | 20 +-- crates/common/src/traits.rs | 218 ++++++++++++++++++++-------- crates/evm/coverage/src/analysis.rs | 2 +- crates/forge/src/gas_report.rs | 3 +- crates/forge/src/multi_runner.rs | 6 +- crates/forge/src/runner.rs | 88 ++++++----- 7 files changed, 212 insertions(+), 126 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 3a3e65c5eca36..583bb07234823 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -67,7 +67,6 @@ impl> FoundryPathExt for T { } /// Initializes a tracing Subscriber for logging -#[allow(dead_code)] pub fn subscriber() { tracing_subscriber::Registry::default() .with(tracing_subscriber::EnvFilter::from_default_env()) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 3be317e51ccab..1b93eb4789fae 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -237,16 +237,16 @@ impl ProjectCompiler { for (name, artifact) in artifacts { let size = deployed_contract_size(artifact).unwrap_or_default(); - let dev_functions = - artifact.abi.as_ref().map(|abi| abi.functions()).into_iter().flatten().filter( - |func| { - func.name.is_test() || - func.name.eq("IS_TEST") || - func.name.eq("IS_SCRIPT") - }, - ); - - let is_dev_contract = dev_functions.count() > 0; + let is_dev_contract = artifact + .abi + .as_ref() + .map(|abi| { + abi.functions().any(|f| { + f.test_function_kind().is_known() || + matches!(f.name.as_str(), "IS_TEST" | "IS_SCRIPT") + }) + }) + .unwrap_or(false); size_report.contracts.insert(name, ContractInfo { size, is_dev_contract }); } diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index 64d27563eba6e..606b4861af92a 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -3,7 +3,7 @@ use alloy_json_abi::Function; use alloy_primitives::Bytes; use alloy_sol_types::SolError; -use std::path::Path; +use std::{fmt, path::Path}; /// Test filter. pub trait TestFilter: Send + Sync { @@ -19,116 +19,208 @@ pub trait TestFilter: Send + Sync { /// Extension trait for `Function`. pub trait TestFunctionExt { - /// Returns whether this function should be executed as invariant test. - fn is_invariant_test(&self) -> bool; - - /// Returns whether this function should be executed as fuzz test. - fn is_fuzz_test(&self) -> bool; + /// Returns the kind of test function. + fn test_function_kind(&self) -> TestFunctionKind { + TestFunctionKind::classify(self.tfe_as_str(), self.tfe_has_inputs()) + } - /// Returns whether this function is a test. - fn is_test(&self) -> bool; + /// Returns `true` if this function is a `setUp` function. + fn is_setup(&self) -> bool { + self.test_function_kind().is_setup() + } - /// Returns whether this function is a test that should fail. - fn is_test_fail(&self) -> bool; + /// Returns `true` if this function is a unit, fuzz, or invariant test. + fn is_any_test(&self) -> bool { + self.test_function_kind().is_any_test() + } - /// Returns whether this function is a `setUp` function. - fn is_setup(&self) -> bool; + /// Returns `true` if this function is a test that should fail. + fn is_any_test_fail(&self) -> bool { + self.test_function_kind().is_any_test_fail() + } - /// Returns whether this function is `afterInvariant` function. - fn is_after_invariant(&self) -> bool; + /// Returns `true` if this function is a unit test. + fn is_unit_test(&self) -> bool { + matches!(self.test_function_kind(), TestFunctionKind::UnitTest { .. }) + } - /// Returns whether this function is a fixture function. - fn is_fixture(&self) -> bool; -} + /// Returns `true` if this function is a fuzz test. + fn is_fuzz_test(&self) -> bool { + self.test_function_kind().is_fuzz_test() + } -impl TestFunctionExt for Function { + /// Returns `true` if this function is an invariant test. fn is_invariant_test(&self) -> bool { - self.name.is_invariant_test() + self.test_function_kind().is_invariant_test() } - fn is_fuzz_test(&self) -> bool { - // test functions that have inputs are considered fuzz tests as those inputs will be fuzzed - !self.inputs.is_empty() + /// Returns `true` if this function is an `afterInvariant` function. + fn is_after_invariant(&self) -> bool { + self.test_function_kind().is_after_invariant() } - fn is_test(&self) -> bool { - self.name.is_test() + /// Returns `true` if this function is a `fixture` function. + fn is_fixture(&self) -> bool { + self.test_function_kind().is_fixture() } - fn is_test_fail(&self) -> bool { - self.name.is_test_fail() + #[doc(hidden)] + fn tfe_as_str(&self) -> &str; + #[doc(hidden)] + fn tfe_has_inputs(&self) -> bool; +} + +impl TestFunctionExt for Function { + fn tfe_as_str(&self) -> &str { + self.name.as_str() } - fn is_setup(&self) -> bool { - self.name.is_setup() + fn tfe_has_inputs(&self) -> bool { + !self.inputs.is_empty() } +} - fn is_after_invariant(&self) -> bool { - self.name.is_after_invariant() +impl TestFunctionExt for String { + fn tfe_as_str(&self) -> &str { + self } - fn is_fixture(&self) -> bool { - self.name.is_fixture() + fn tfe_has_inputs(&self) -> bool { + false } } -impl TestFunctionExt for String { - fn is_invariant_test(&self) -> bool { - self.as_str().is_invariant_test() +impl TestFunctionExt for str { + fn tfe_as_str(&self) -> &str { + self } - fn is_fuzz_test(&self) -> bool { - self.as_str().is_fuzz_test() + fn tfe_has_inputs(&self) -> bool { + false } +} + +/// Test function kind. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum TestFunctionKind { + /// `setUp`. + Setup, + /// `test*`. `should_fail` is `true` for `testFail*`. + UnitTest { should_fail: bool }, + /// `test*`, with arguments. `should_fail` is `true` for `testFail*`. + FuzzTest { should_fail: bool }, + /// `invariant*` or `statefulFuzz*`. + InvariantTest, + /// `afterInvariant`. + AfterInvariant, + /// `fixture*`. + Fixture, + /// Unknown kind. + Unknown, +} - fn is_test(&self) -> bool { - self.as_str().is_test() +impl TestFunctionKind { + /// Classify a function. + #[inline] + pub fn classify(name: &str, has_inputs: bool) -> Self { + match () { + _ if name.starts_with("test") => { + let should_fail = name.starts_with("testFail"); + if has_inputs { + Self::FuzzTest { should_fail } + } else { + Self::UnitTest { should_fail } + } + } + _ if name.starts_with("invariant") || name.starts_with("statefulFuzz") => { + Self::InvariantTest + } + _ if name.eq_ignore_ascii_case("setup") => Self::Setup, + _ if name.eq_ignore_ascii_case("afterinvariant") => Self::AfterInvariant, + _ if name.starts_with("fixture") => Self::Fixture, + _ => Self::Unknown, + } } - fn is_test_fail(&self) -> bool { - self.as_str().is_test_fail() + /// Returns the name of the function kind. + pub const fn name(&self) -> &'static str { + match self { + Self::Setup => "setUp", + Self::UnitTest { should_fail: false } => "test", + Self::UnitTest { should_fail: true } => "testFail", + Self::FuzzTest { should_fail: false } => "fuzz", + Self::FuzzTest { should_fail: true } => "fuzz fail", + Self::InvariantTest => "invariant", + Self::AfterInvariant => "afterInvariant", + Self::Fixture => "fixture", + Self::Unknown => "unknown", + } } - fn is_setup(&self) -> bool { - self.as_str().is_setup() + /// Returns `true` if this function is a `setUp` function. + #[inline] + pub const fn is_setup(&self) -> bool { + matches!(self, Self::Setup) } - fn is_after_invariant(&self) -> bool { - self.as_str().is_after_invariant() + /// Returns `true` if this function is a unit, fuzz, or invariant test. + #[inline] + pub const fn is_any_test(&self) -> bool { + matches!(self, Self::UnitTest { .. } | Self::FuzzTest { .. } | Self::InvariantTest) } - fn is_fixture(&self) -> bool { - self.as_str().is_fixture() + /// Returns `true` if this function is a test that should fail. + #[inline] + pub const fn is_any_test_fail(&self) -> bool { + matches!(self, Self::UnitTest { should_fail: true } | Self::FuzzTest { should_fail: true }) } -} -impl TestFunctionExt for str { - fn is_invariant_test(&self) -> bool { - self.starts_with("invariant") || self.starts_with("statefulFuzz") + /// Returns `true` if this function is a unit test. + #[inline] + pub fn is_unit_test(&self) -> bool { + matches!(self, Self::UnitTest { .. }) } - fn is_fuzz_test(&self) -> bool { - unimplemented!("no naming convention for fuzz tests") + /// Returns `true` if this function is a fuzz test. + #[inline] + pub const fn is_fuzz_test(&self) -> bool { + matches!(self, Self::FuzzTest { .. }) } - fn is_test(&self) -> bool { - self.starts_with("test") + /// Returns `true` if this function is an invariant test. + #[inline] + pub const fn is_invariant_test(&self) -> bool { + matches!(self, Self::InvariantTest) } - fn is_test_fail(&self) -> bool { - self.starts_with("testFail") + /// Returns `true` if this function is an `afterInvariant` function. + #[inline] + pub const fn is_after_invariant(&self) -> bool { + matches!(self, Self::AfterInvariant) } - fn is_setup(&self) -> bool { - self.eq_ignore_ascii_case("setup") + /// Returns `true` if this function is a `fixture` function. + #[inline] + pub const fn is_fixture(&self) -> bool { + matches!(self, Self::Fixture) } - fn is_after_invariant(&self) -> bool { - self.eq_ignore_ascii_case("afterinvariant") + /// Returns `true` if this function kind is known. + #[inline] + pub const fn is_known(&self) -> bool { + !matches!(self, Self::Unknown) } - fn is_fixture(&self) -> bool { - self.starts_with("fixture") + /// Returns `true` if this function kind is unknown. + #[inline] + pub const fn is_unknown(&self) -> bool { + matches!(self, Self::Unknown) + } +} + +impl fmt::Display for TestFunctionKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.name().fmt(f) } } diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index bbfaa189754a8..48c7d01d60d9f 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -493,7 +493,7 @@ impl<'a> SourceAnalyzer<'a> { let is_test = items.iter().any(|item| { if let CoverageItemKind::Function { name } = &item.kind { - name.is_test() + name.is_any_test() } else { false } diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 058af0587dab9..bec7402ba1e9d 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -106,8 +106,7 @@ impl GasReport { } else if let Some(DecodedCallData { signature, .. }) = decoded.func { let name = signature.split('(').next().unwrap(); // ignore any test/setup functions - let should_include = !(name.is_test() || name.is_invariant_test() || name.is_setup()); - if should_include { + if !name.test_function_kind().is_known() { trace!(contract_name, signature, "adding gas info"); let gas_info = contract_info .functions diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 270a25202a8e5..ac4c51a69d1be 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -102,7 +102,7 @@ impl MultiContractRunner { .iter() .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) .flat_map(|(_, TestContract { abi, .. })| abi.functions()) - .filter(|func| func.is_test() || func.is_invariant_test()) + .filter(|func| func.is_any_test()) } /// Returns all matching tests grouped by contract grouped by file (file -> (contract -> tests)) @@ -392,7 +392,7 @@ impl MultiContractRunnerBuilder { // if it's a test, link it and add to deployable contracts if abi.constructor.as_ref().map(|c| c.inputs.is_empty()).unwrap_or(true) && - abi.functions().any(|func| func.name.is_test() || func.name.is_invariant_test()) + abi.functions().any(|func| func.name.is_any_test()) { let Some(bytecode) = contract.get_bytecode_bytes().map(|b| b.into_owned()).filter(|b| !b.is_empty()) @@ -434,5 +434,5 @@ pub fn matches_contract(id: &ArtifactId, abi: &JsonAbi, filter: &dyn TestFilter) /// Returns `true` if the function is a test function that matches the given filter. pub(crate) fn is_matching_test(func: &Function, filter: &dyn TestFilter) -> bool { - (func.is_test() || func.is_invariant_test()) && filter.matches_test(&func.signature()) + func.is_any_test() && filter.matches_test(&func.signature()) } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 25a6266d9e5fb..b2908978742e5 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -13,7 +13,7 @@ use alloy_primitives::{address, Address, Bytes, U256}; use eyre::Result; use foundry_common::{ contracts::{ContractsByAddress, ContractsByArtifact}, - TestFunctionExt, + TestFunctionExt, TestFunctionKind, }; use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_evm::{ @@ -278,7 +278,6 @@ impl<'a> ContractRunner<'a> { known_contracts: ContractsByArtifact, handle: &tokio::runtime::Handle, ) -> SuiteResult { - info!("starting tests"); let start = Instant::now(); let mut warnings = Vec::new(); @@ -381,39 +380,41 @@ impl<'a> ContractRunner<'a> { let _guard = handle.enter(); let sig = func.signature(); - let span = debug_span!("test", name = tracing::field::Empty).entered(); - if !span.is_disabled() { - if enabled!(tracing::Level::TRACE) { - span.record("name", &sig); - } else { - span.record("name", &func.name); - } - } + let kind = func.test_function_kind(); + + let _guard = debug_span!( + "test", + %kind, + name = if enabled!(tracing::Level::TRACE) { &sig } else { &func.name }, + ) + .entered(); let setup = setup.clone(); - let should_fail = func.is_test_fail(); - let mut res = if func.is_invariant_test() { - let runner = test_options.invariant_runner(self.name, &func.name); - let invariant_config = test_options.invariant_config(self.name, &func.name); - - self.run_invariant_test( - runner, - setup, - invariant_config.clone(), - func, - call_after_invariant, - &known_contracts, - identified_contracts.as_ref().unwrap(), - ) - } else if func.is_fuzz_test() { - debug_assert!(func.is_test()); - let runner = test_options.fuzz_runner(self.name, &func.name); - let fuzz_config = test_options.fuzz_config(self.name, &func.name); - - self.run_fuzz_test(func, should_fail, runner, setup, fuzz_config.clone()) - } else { - debug_assert!(func.is_test()); - self.run_test(func, should_fail, setup) + let mut res = match kind { + TestFunctionKind::UnitTest { should_fail } => { + self.run_unit_test(func, should_fail, setup) + } + TestFunctionKind::FuzzTest { should_fail } => { + let runner = test_options.fuzz_runner(self.name, &func.name); + let fuzz_config = test_options.fuzz_config(self.name, &func.name); + + self.run_fuzz_test(func, should_fail, runner, setup, fuzz_config.clone()) + } + TestFunctionKind::InvariantTest => { + let runner = test_options.invariant_runner(self.name, &func.name); + let invariant_config = test_options.invariant_config(self.name, &func.name); + + self.run_invariant_test( + runner, + setup, + invariant_config.clone(), + func, + call_after_invariant, + &known_contracts, + identified_contracts.as_ref().unwrap(), + ) + } + _ => unreachable!(), }; res.duration = start.elapsed(); @@ -423,24 +424,21 @@ impl<'a> ContractRunner<'a> { .collect::>(); let duration = start.elapsed(); - let suite_result = SuiteResult::new(duration, test_results, warnings); - info!( - duration=?suite_result.duration, - "done. {}/{} successful", - suite_result.passed(), - suite_result.test_results.len() - ); - suite_result + SuiteResult::new(duration, test_results, warnings) } - /// Runs a single test + /// Runs a single unit test. /// /// Calls the given functions and returns the `TestResult`. /// /// State modifications are not committed to the evm database but discarded after the call, /// similar to `eth_call`. - #[instrument(level = "debug", name = "normal", skip_all)] - pub fn run_test(&self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { + pub fn run_unit_test( + &self, + func: &Function, + should_fail: bool, + setup: TestSetup, + ) -> TestResult { let address = setup.address; let test_result = TestResult::new(setup); @@ -464,7 +462,6 @@ impl<'a> ContractRunner<'a> { test_result.single_result(success, reason, raw_call_result) } - #[instrument(level = "debug", name = "invariant", skip_all)] #[allow(clippy::too_many_arguments)] pub fn run_invariant_test( &self, @@ -636,7 +633,6 @@ impl<'a> ContractRunner<'a> { ) } - #[instrument(level = "debug", name = "fuzz", skip_all)] pub fn run_fuzz_test( &self, func: &Function, From 12db5ac90c2263e1f83d05bea1a7f299b1d7f022 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:08:05 +0200 Subject: [PATCH 1143/1963] chore: tweak tracing spans and events (#8237) --- crates/cheatcodes/src/inspector.rs | 69 ++++++++++++++----- crates/cheatcodes/src/lib.rs | 42 +---------- crates/evm/core/src/backend/cow.rs | 1 + crates/evm/core/src/backend/mod.rs | 1 + crates/evm/evm/src/executors/mod.rs | 15 ++-- .../src/executors/{tracing.rs => trace.rs} | 0 crates/forge/src/multi_runner.rs | 53 +++++++------- crates/forge/src/runner.rs | 53 +++++--------- 8 files changed, 112 insertions(+), 122 deletions(-) rename crates/evm/evm/src/executors/{tracing.rs => trace.rs} (100%) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index ecec6424568d5..507b644713954 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -17,7 +17,7 @@ use crate::{ }; use alloy_primitives::{Address, Bytes, Log, TxKind, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; -use alloy_sol_types::{SolInterface, SolValue}; +use alloy_sol_types::{SolCall, SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, SELECTOR_LEN}; use foundry_config::Config; use foundry_evm_core::{ @@ -431,7 +431,7 @@ impl Inspector for Cheatcodes { let prev = account.info.nonce; account.info.nonce = prev.saturating_sub(1); - debug!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); + trace!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); } } @@ -1441,8 +1441,7 @@ impl Cheatcodes { // pointer, which could have been updated to the exclusive upper bound during // execution. let value = try_or_return!(interpreter.stack().peek(1)).to_be_bytes::<32>(); - let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; - if value[0..SELECTOR_LEN] == selector { + if value[..SELECTOR_LEN] == stopExpectSafeMemoryCall::SELECTOR { return } @@ -1510,9 +1509,8 @@ impl Cheatcodes { if to == CHEATCODE_ADDRESS { let args_offset = try_or_return!(interpreter.stack().peek(3)).saturating_to::(); let args_size = try_or_return!(interpreter.stack().peek(4)).saturating_to::(); - let selector = stopExpectSafeMemoryCall {}.cheatcode().func.selector_bytes; let memory_word = interpreter.shared_memory.slice(args_offset, args_size); - if memory_word[0..SELECTOR_LEN] == selector { + if memory_word[..SELECTOR_LEN] == stopExpectSafeMemoryCall::SELECTOR { return } } @@ -1623,18 +1621,6 @@ fn check_if_fixed_gas_limit( && call_gas_limit > 2300 } -/// Dispatches the cheatcode call to the appropriate function. -fn apply_dispatch(calls: &Vm::VmCalls, ccx: &mut CheatsCtxt) -> Result { - macro_rules! match_ { - ($($variant:ident),*) => { - match calls { - $(Vm::VmCalls::$variant(cheat) => crate::Cheatcode::apply_traced(cheat, ccx),)* - } - }; - } - vm_calls!(match_) -} - /// Returns true if the kind of account access is a call. fn access_is_call(kind: crate::Vm::AccountAccessKind) -> bool { matches!( @@ -1691,3 +1677,50 @@ fn append_storage_access( } } } + +/// Dispatches the cheatcode call to the appropriate function. +fn apply_dispatch(calls: &Vm::VmCalls, ccx: &mut CheatsCtxt) -> Result { + macro_rules! dispatch { + ($($variant:ident),*) => { + match calls { + $(Vm::VmCalls::$variant(cheat) => crate::Cheatcode::apply_full(cheat, ccx),)* + } + }; + } + + let _guard = trace_span_and_call(calls); + let result = vm_calls!(dispatch); + trace_return(&result); + result +} + +fn trace_span_and_call(calls: &Vm::VmCalls) -> tracing::span::EnteredSpan { + let mut cheat = None; + let mut get_cheat = || *cheat.get_or_insert_with(|| calls_as_dyn_cheatcode(calls)); + let span = debug_span!(target: "cheatcodes", "apply", id = %get_cheat().id()); + let entered = span.entered(); + trace!(target: "cheatcodes", cheat = ?get_cheat().as_debug(), "applying"); + entered +} + +fn trace_return(result: &Result) { + trace!( + target: "cheatcodes", + return = %match result { + Ok(b) => hex::encode(b), + Err(e) => e.to_string(), + } + ); +} + +#[cold] +fn calls_as_dyn_cheatcode(calls: &Vm::VmCalls) -> &dyn DynCheatcode { + macro_rules! as_dyn { + ($($variant:ident),*) => { + match calls { + $(Vm::VmCalls::$variant(cheat) => cheat,)* + } + }; + } + vm_calls!(as_dyn) +} diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 9e143e8db7744..718b173426873 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -68,53 +68,17 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { self.apply(ccx.state) } - - #[inline] - fn apply_traced(&self, ccx: &mut CheatsCtxt) -> Result { - let _span = trace_span_and_call(self); - let result = self.apply_full(ccx); - trace_return(&result); - return result; - - // Separate and non-generic functions to avoid inline and monomorphization bloat. - #[inline(never)] - fn trace_span_and_call(cheat: &dyn DynCheatcode) -> tracing::span::EnteredSpan { - let span = debug_span!(target: "cheatcodes", "apply"); - if !span.is_disabled() { - if enabled!(tracing::Level::TRACE) { - span.record("cheat", tracing::field::debug(cheat.as_debug())); - } else { - span.record("id", cheat.cheatcode().func.id); - } - } - let entered = span.entered(); - trace!(target: "cheatcodes", "applying"); - entered - } - - #[inline(never)] - fn trace_return(result: &Result) { - trace!( - target: "cheatcodes", - return = match result { - Ok(b) => hex::encode(b), - Err(e) => e.to_string(), - } - ); - } - } } pub(crate) trait DynCheatcode { - fn cheatcode(&self) -> &'static foundry_cheatcodes_spec::Cheatcode<'static>; + fn id(&self) -> &'static str; fn as_debug(&self) -> &dyn std::fmt::Debug; } impl DynCheatcode for T { - fn cheatcode(&self) -> &'static foundry_cheatcodes_spec::Cheatcode<'static> { - T::CHEATCODE + fn id(&self) -> &'static str { + T::CHEATCODE.func.id } - fn as_debug(&self) -> &dyn std::fmt::Debug { self } diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 583bf3416f7fb..766070e997f5e 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -59,6 +59,7 @@ impl<'a> CowBackend<'a> { /// /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. + #[instrument(name = "inspect", level = "debug", skip_all)] pub fn inspect<'b, I: InspectorExt<&'b mut Self>>( &'b mut self, env: &mut EnvWithHandlerCfg, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index faab0800c7955..a59bcdc5b01a7 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -794,6 +794,7 @@ impl Backend { /// /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. + #[instrument(name = "inspect", level = "debug", skip_all)] pub fn inspect<'a, I: InspectorExt<&'a mut Self>>( &'a mut self, env: &mut EnvWithHandlerCfg, diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 79ec0160cf570..2114eb515d4ad 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -44,8 +44,8 @@ pub use fuzz::FuzzedExecutor; pub mod invariant; pub use invariant::InvariantExecutor; -mod tracing; -pub use tracing::TracingExecutor; +mod trace; +pub use trace::TracingExecutor; sol! { interface ITest { @@ -256,6 +256,7 @@ impl Executor { /// # Panics /// /// Panics if `env.tx.transact_to` is not `TxKind::Create(_)`. + #[instrument(name = "deploy", level = "debug", skip_all)] pub fn deploy_with_env( &mut self, env: EnvWithHandlerCfg, @@ -289,6 +290,7 @@ impl Executor { /// /// Ayn changes made during the setup call to env's block environment are persistent, for /// example `vm.chainId()` will change the `block.chainId` for all subsequent test calls. + #[instrument(name = "setup", level = "debug", skip_all)] pub fn setup( &mut self, from: Option

, @@ -389,6 +391,7 @@ impl Executor { /// Execute the transaction configured in `env.tx`. /// /// The state after the call is **not** persisted. + #[instrument(name = "call", level = "debug", skip_all)] pub fn call_with_env(&self, mut env: EnvWithHandlerCfg) -> eyre::Result { let mut inspector = self.inspector().clone(); let mut backend = CowBackend::new_borrowed(self.backend()); @@ -397,6 +400,7 @@ impl Executor { } /// Execute the transaction configured in `env.tx`. + #[instrument(name = "transact", level = "debug", skip_all)] pub fn transact_with_env(&mut self, mut env: EnvWithHandlerCfg) -> eyre::Result { let mut inspector = self.inspector().clone(); let backend = self.backend_mut(); @@ -411,6 +415,7 @@ impl Executor { /// the executed call result. /// /// This should not be exposed to the user, as it should be called only by `transact*`. + #[instrument(name = "commit", level = "debug", skip_all)] fn commit(&mut self, result: &mut RawCallResult) { // Persist changes to db. self.backend_mut().commit(result.state_changeset.clone()); @@ -420,7 +425,6 @@ impl Executor { if let Some(cheats) = self.inspector_mut().cheatcodes.as_mut() { // Clear broadcastable transactions cheats.broadcastable_transactions.clear(); - debug!(target: "evm::executors", "cleared broadcastable transactions"); // corrected_nonce value is needed outside of this context (setUp), so we don't // reset it. @@ -502,6 +506,7 @@ impl Executor { should_fail ^ success } + #[instrument(name = "is_success", level = "debug", skip_all)] fn is_success_raw( &self, address: Address, @@ -536,11 +541,11 @@ impl Executor { let call = executor.call_sol(CALLER, address, &ITest::failedCall {}, U256::ZERO, None); match call { Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { failed } }) => { - debug!(failed, "DSTest::failed()"); + trace!(failed, "DSTest::failed()"); success = !failed; } Err(err) => { - debug!(%err, "failed to call DSTest::failed()"); + trace!(%err, "failed to call DSTest::failed()"); } } } diff --git a/crates/evm/evm/src/executors/tracing.rs b/crates/evm/evm/src/executors/trace.rs similarity index 100% rename from crates/evm/evm/src/executors/tracing.rs rename to crates/evm/evm/src/executors/trace.rs diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index ac4c51a69d1be..f056d3cf1701c 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -78,9 +78,7 @@ impl MultiContractRunner { &'a self, filter: &'a dyn TestFilter, ) -> impl Iterator { - self.contracts - .iter() - .filter(|&(id, TestContract { abi, .. })| matches_contract(id, abi, filter)) + self.contracts.iter().filter(|&(id, c)| matches_contract(id, &c.abi, filter)) } /// Returns an iterator over all test functions that match the filter. @@ -89,7 +87,7 @@ impl MultiContractRunner { filter: &'a dyn TestFilter, ) -> impl Iterator { self.matching_contracts(filter) - .flat_map(|(_, TestContract { abi, .. })| abi.functions()) + .flat_map(|(_, c)| c.abi.functions()) .filter(|func| is_matching_test(func, filter)) } @@ -101,17 +99,18 @@ impl MultiContractRunner { self.contracts .iter() .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) - .flat_map(|(_, TestContract { abi, .. })| abi.functions()) + .flat_map(|(_, c)| c.abi.functions()) .filter(|func| func.is_any_test()) } /// Returns all matching tests grouped by contract grouped by file (file -> (contract -> tests)) pub fn list(&self, filter: &dyn TestFilter) -> BTreeMap>> { self.matching_contracts(filter) - .map(|(id, TestContract { abi, .. })| { + .map(|(id, c)| { let source = id.source.as_path().display().to_string(); let name = id.name.clone(); - let tests = abi + let tests = c + .abi .functions() .filter(|func| is_matching_test(func, filter)) .map(|func| func.name.clone()) @@ -159,7 +158,7 @@ impl MultiContractRunner { tx: mpsc::Sender<(String, SuiteResult)>, show_progress: bool, ) { - let handle = tokio::runtime::Handle::current(); + let tokio_handle = tokio::runtime::Handle::current(); trace!("running all tests"); // The DB backend that serves all the data. @@ -181,7 +180,7 @@ impl MultiContractRunner { let results: Vec<(String, SuiteResult)> = contracts .par_iter() .map(|&(id, contract)| { - let _guard = handle.enter(); + let _guard = tokio_handle.enter(); tests_progress.inner.lock().start_suite_progress(&id.identifier()); let result = self.run_test_suite( @@ -189,7 +188,7 @@ impl MultiContractRunner { contract, db.clone(), filter, - &handle, + &tokio_handle, Some(&tests_progress), ); @@ -209,8 +208,9 @@ impl MultiContractRunner { }); } else { contracts.par_iter().for_each(|&(id, contract)| { - let _guard = handle.enter(); - let result = self.run_test_suite(id, contract, db.clone(), filter, &handle, None); + let _guard = tokio_handle.enter(); + let result = + self.run_test_suite(id, contract, db.clone(), filter, &tokio_handle, None); let _ = tx.send((id.identifier(), result)); }) } @@ -222,7 +222,7 @@ impl MultiContractRunner { contract: &TestContract, db: Backend, filter: &dyn TestFilter, - handle: &tokio::runtime::Handle, + tokio_handle: &tokio::runtime::Handle, progress: Option<&TestsProgress>, ) -> SuiteResult { let identifier = artifact_id.identifier(); @@ -252,23 +252,26 @@ impl MultiContractRunner { if !enabled!(tracing::Level::TRACE) { span_name = get_contract_name(&identifier); } - let _guard = debug_span!("suite", name = span_name).entered(); + let span = debug_span!("suite", name = %span_name); + let span_local = span.clone(); + let _guard = span_local.enter(); debug!("start executing all tests in contract"); - let runner = ContractRunner::new( - &identifier, - executor, + let runner = ContractRunner { + name: &identifier, contract, - &self.libs_to_deploy, - self.evm_opts.initial_balance, - self.sender, - &self.revert_decoder, - self.debug, + libs_to_deploy: &self.libs_to_deploy, + executor, + revert_decoder: &self.revert_decoder, + initial_balance: self.evm_opts.initial_balance, + sender: self.sender.unwrap_or_default(), + debug: self.debug, progress, - ); - - let r = runner.run_tests(filter, &self.test_options, self.known_contracts.clone(), handle); + tokio_handle, + span, + }; + let r = runner.run_tests(filter, &self.test_options, self.known_contracts.clone()); debug!(duration=?r.duration, "executed all tests in contract"); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index b2908978742e5..a1cffc6d2c335 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -52,8 +52,9 @@ pub const LIBRARY_DEPLOYER: Address = address!("1F95D37F27EA0dEA9C252FC09D5A6eaA /// A type that executes all tests of a contract #[derive(Clone, Debug)] pub struct ContractRunner<'a> { + /// The name of the contract. pub name: &'a str, - /// The data of the contract being ran. + /// The data of the contract. pub contract: &'a TestContract, /// The libraries that need to be deployed before the contract. pub libs_to_deploy: &'a Vec, @@ -61,41 +62,18 @@ pub struct ContractRunner<'a> { pub executor: Executor, /// Revert decoder. Contains all known errors. pub revert_decoder: &'a RevertDecoder, - /// The initial balance of the test contract + /// The initial balance of the test contract. pub initial_balance: U256, - /// The address which will be used as the `from` field in all EVM calls + /// The address which will be used as the `from` field in all EVM calls. pub sender: Address, - /// Should generate debug traces + /// Whether debug traces should be generated. pub debug: bool, /// Overall test run progress. - progress: Option<&'a TestsProgress>, -} - -impl<'a> ContractRunner<'a> { - #[allow(clippy::too_many_arguments)] - pub fn new( - name: &'a str, - executor: Executor, - contract: &'a TestContract, - libs_to_deploy: &'a Vec, - initial_balance: U256, - sender: Option
, - revert_decoder: &'a RevertDecoder, - debug: bool, - progress: Option<&'a TestsProgress>, - ) -> Self { - Self { - name, - executor, - contract, - libs_to_deploy, - initial_balance, - sender: sender.unwrap_or_default(), - revert_decoder, - debug, - progress, - } - } + pub progress: Option<&'a TestsProgress>, + /// The handle to the tokio runtime. + pub tokio_handle: &'a tokio::runtime::Handle, + /// The span of the contract. + pub span: tracing::Span, } impl<'a> ContractRunner<'a> { @@ -276,7 +254,6 @@ impl<'a> ContractRunner<'a> { filter: &dyn TestFilter, test_options: &TestOptions, known_contracts: ContractsByArtifact, - handle: &tokio::runtime::Handle, ) -> SuiteResult { let start = Instant::now(); let mut warnings = Vec::new(); @@ -377,7 +354,13 @@ impl<'a> ContractRunner<'a> { .map(|&func| { let start = Instant::now(); - let _guard = handle.enter(); + let _guard = self.tokio_handle.enter(); + + let _guard; + let current_span = tracing::Span::current(); + if current_span.is_none() || current_span.id() != self.span.id() { + _guard = self.span.enter(); + } let sig = func.signature(); let kind = func.test_function_kind(); @@ -385,7 +368,7 @@ impl<'a> ContractRunner<'a> { let _guard = debug_span!( "test", %kind, - name = if enabled!(tracing::Level::TRACE) { &sig } else { &func.name }, + name = %if enabled!(tracing::Level::TRACE) { &sig } else { &func.name }, ) .entered(); From 0e09d885b91370ccfb220f05473b4f1fe7aff450 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:35:08 +0200 Subject: [PATCH 1144/1963] chore: tweak profiles, rename debug-fast to profiling, remove local (#8238) --- Cargo.lock | 153 +++++++++++++++++------------------ Cargo.toml | 53 +++++------- crates/anvil/Cargo.toml | 2 +- crates/anvil/README.md | 4 +- crates/cli/Cargo.toml | 9 +-- crates/cli/src/utils/mod.rs | 2 - crates/forge/Cargo.toml | 2 +- crates/test-utils/Cargo.toml | 2 +- 8 files changed, 106 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f35562398f40..49b7ae903794a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,7 +306,7 @@ checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -552,7 +552,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -569,7 +569,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", "syn-solidity", "tiny-keccak", ] @@ -587,7 +587,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.67", + "syn 2.0.68", "syn-solidity", ] @@ -1097,7 +1097,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -1119,7 +1119,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -1130,7 +1130,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -1177,7 +1177,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -1249,7 +1249,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.8.0", + "uuid 1.9.0", ] [[package]] @@ -1971,9 +1971,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" dependencies = [ "jobserver", "libc", @@ -2100,7 +2100,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", "terminal_size", "unicase", "unicode-width", @@ -2134,7 +2134,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -2563,8 +2563,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", - "syn 2.0.67", + "strsim", + "syn 2.0.68", ] [[package]] @@ -2575,7 +2575,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -2647,7 +2647,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -2668,7 +2668,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -2678,7 +2678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -2691,7 +2691,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -2798,7 +2798,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -2934,7 +2934,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -3084,7 +3084,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.67", + "syn 2.0.68", "toml 0.8.14", "walkdir", ] @@ -3112,7 +3112,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.67", + "syn 2.0.68", "tempfile", "thiserror", "tiny-keccak", @@ -3355,7 +3355,7 @@ dependencies = [ "regex", "reqwest 0.12.5", "revm-inspectors", - "rustc-hash", + "rustc-hash 2.0.0", "semver 1.0.23", "serde", "serde_json", @@ -3476,7 +3476,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -3570,7 +3570,7 @@ dependencies = [ "parking_lot", "rand", "revm", - "rustc-hash", + "rustc-hash 2.0.0", "semver 1.0.23", "serde_json", "thiserror", @@ -3617,12 +3617,11 @@ dependencies = [ "once_cell", "regex", "serde", - "strsim 0.10.0", + "strsim", "strum", "tempfile", "tokio", "tracing", - "tracing-error", "tracing-subscriber", "yansi", ] @@ -3661,7 +3660,7 @@ dependencies = [ "num-format", "once_cell", "reqwest 0.12.5", - "rustc-hash", + "rustc-hash 2.0.0", "semver 1.0.23", "serde", "serde_json", @@ -3891,7 +3890,7 @@ dependencies = [ "parking_lot", "revm", "revm-inspectors", - "rustc-hash", + "rustc-hash 2.0.0", "serde", "serde_json", "thiserror", @@ -3911,7 +3910,7 @@ dependencies = [ "foundry-evm-core", "rayon", "revm", - "rustc-hash", + "rustc-hash 2.0.0", "semver 1.0.23", "tracing", ] @@ -3961,7 +3960,7 @@ dependencies = [ "itertools 0.13.0", "once_cell", "revm-inspectors", - "rustc-hash", + "rustc-hash 2.0.0", "serde", "tempfile", "tokio", @@ -3986,7 +3985,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -4145,7 +4144,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -4633,7 +4632,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -5476,7 +5475,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -5546,7 +5545,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -5777,7 +5776,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -5900,7 +5899,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -6071,7 +6070,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -6130,7 +6129,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -6214,7 +6213,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -6272,7 +6271,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -6388,7 +6387,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -6464,7 +6463,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", "version_check", "yansi", ] @@ -6531,7 +6530,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -6606,7 +6605,7 @@ dependencies = [ "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash", + "rustc-hash 1.1.0", "rustls 0.23.10", "thiserror", "tokio", @@ -6622,7 +6621,7 @@ dependencies = [ "bytes", "rand", "ring", - "rustc-hash", + "rustc-hash 1.1.0", "rustls 0.23.10", "slab", "thiserror", @@ -7138,6 +7137,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -7414,7 +7419,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -7570,7 +7575,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -7581,7 +7586,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -7624,7 +7629,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -7670,7 +7675,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -7909,7 +7914,7 @@ dependencies = [ "tokio", "toml 0.8.14", "toml_edit 0.22.14", - "uuid 1.8.0", + "uuid 1.9.0", "walkdir", "yansi", "zip 2.1.3", @@ -7939,7 +7944,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" dependencies = [ "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -7980,12 +7985,6 @@ dependencies = [ "quote", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -7994,9 +7993,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] @@ -8011,7 +8010,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -8079,9 +8078,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.67" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -8097,7 +8096,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -8219,7 +8218,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -8365,7 +8364,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -8644,7 +8643,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -8906,9 +8905,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "3ea73390fe27785838dcbf75b91b1d84799e28f1ce71e6f372a5dc2200c80de5" dependencies = [ "getrandom", "serde", @@ -9005,7 +9004,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", "wasm-bindgen-shared", ] @@ -9039,7 +9038,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9500,7 +9499,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] @@ -9520,7 +9519,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.67", + "syn 2.0.68", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 86748331f58aa..91a876c941e7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,31 +95,20 @@ axum.opt-level = 3 # keystores scrypt.opt-level = 3 -# Local "release" mode, more optimized than dev but much faster to compile than release. -[profile.local] -inherits = "dev" -opt-level = 1 -debug-assertions = false -overflow-checks = false -strip = "debuginfo" -panic = "abort" -codegen-units = 16 - -# Like release, but with full debug symbols and with stack unwinds. Useful for e.g. `perf`. -[profile.debug-fast] -inherits = "local" -debug = true -strip = "none" -panic = "unwind" - -# Optimized release profile. [profile.release] opt-level = 3 +lto = "thin" debug = "line-tables-only" -lto = "fat" -strip = "debuginfo" +strip = true panic = "abort" -codegen-units = 1 +codegen-units = 16 + +# Use the `--profile profiling` flag to show symbols in release mode. +# e.g. `cargo build --profile profiling` +[profile.profiling] +inherits = "release" +debug = 1 +strip = false # Override packages which aren't perf-sensitive for faster compilation speed. [profile.release.package] @@ -158,6 +147,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.4.1", default-features = false } foundry-compilers = { version = "0.8.0", default-features = false } +solang-parser = "=0.3.3" ## revm # no default features to avoid c-kzg @@ -182,26 +172,27 @@ alloy-rpc-client = { version = "0.1.2", default-features = false } alloy-rpc-types = { version = "0.1.2", default-features = false } alloy-serde = { version = "0.1.2", default-features = false } alloy-signer = { version = "0.1.2", default-features = false } -alloy-signer-local = { version = "0.1.2", default-features = false } alloy-signer-aws = { version = "0.1.2", default-features = false } alloy-signer-gcp = { version = "0.1.2", default-features = false } alloy-signer-ledger = { version = "0.1.2", default-features = false } +alloy-signer-local = { version = "0.1.2", default-features = false } alloy-signer-trezor = { version = "0.1.2", default-features = false } alloy-transport = { version = "0.1.2", default-features = false } alloy-transport-http = { version = "0.1.2", default-features = false } alloy-transport-ipc = { version = "0.1.2", default-features = false } alloy-transport-ws = { version = "0.1.2", default-features = false } -alloy-primitives = { version = "0.7.1", features = ["getrandom", "rand"] } -alloy-dyn-abi = "0.7.1" -alloy-json-abi = "0.7.1" -alloy-sol-types = "0.7.1" -alloy-sol-macro-input = "0.7.3" + +alloy-dyn-abi = "0.7.3" +alloy-json-abi = "0.7.3" +alloy-primitives = { version = "0.7.3", features = ["getrandom", "rand"] } alloy-sol-macro-expander = "0.7.3" -syn-solidity = "0.7.1" +alloy-sol-macro-input = "0.7.3" +alloy-sol-types = "0.7.3" +syn-solidity = "0.7.3" + alloy-chains = "0.1" -alloy-trie = "0.4.1" alloy-rlp = "0.3.3" -solang-parser = "=0.3.3" +alloy-trie = "0.4.1" ## misc async-trait = "0.1" @@ -232,7 +223,7 @@ k256 = "0.13" once_cell = "1" parking_lot = "0.12" rand = "0.8" -rustc-hash = "1.1" +rustc-hash = "2.0" semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index f5ef2a5882cbb..a987879852b1e 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -75,7 +75,7 @@ tower.workspace = true # tracing tracing.workspace = true -tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # async tokio = { workspace = true, features = ["time"] } diff --git a/crates/anvil/README.md b/crates/anvil/README.md index 0942e0e8f0550..dd904c45c9e49 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -27,9 +27,7 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** ### Installing from source ```sh -git clone https://github.com/foundry-rs/foundry -cd foundry -cargo install --path ./crates/anvil --profile local --locked --force +cargo install --git https://github.com/foundry-rs/foundry --locked --force ``` ## Getting started diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index f13dbe5f646ce..e9d36fdeed532 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -33,19 +33,18 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } color-eyre.workspace = true dotenvy = "0.15" eyre.workspace = true +futures.workspace = true +hex.workspace = true indicatif = "0.17" once_cell.workspace = true regex = { version = "1", default-features = false } serde.workspace = true -strsim = "0.10" +strsim = "0.11" strum = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["macros"] } -tracing-error = "0.2" -tracing-subscriber = { workspace = true, features = ["registry", "env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["registry", "env-filter"] } tracing.workspace = true yansi.workspace = true -hex.workspace = true -futures.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 583bb07234823..a42c30553c804 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -12,7 +12,6 @@ use std::{ process::{Command, Output, Stdio}, time::{Duration, SystemTime, UNIX_EPOCH}, }; -use tracing_error::ErrorLayer; use tracing_subscriber::prelude::*; mod cmd; @@ -70,7 +69,6 @@ impl> FoundryPathExt for T { pub fn subscriber() { tracing_subscriber::Registry::default() .with(tracing_subscriber::EnvFilter::from_default_env()) - .with(ErrorLayer::default()) .with(tracing_subscriber::fmt::layer()) .init() } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 29fd64ef4d6dc..89e71544ad6d6 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -123,7 +123,7 @@ svm = { package = "svm-rs", version = "0.5", default-features = false, features "rustls", ] } tempfile.workspace = true -tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } alloy-signer-local.workspace = true diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 95ef8d6c9f314..9b762039acb0d 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -30,7 +30,7 @@ similar-asserts.workspace = true regex = "1" serde_json.workspace = true tracing.workspace = true -tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } walkdir.workspace = true rand.workspace = true From ffaea4b7830486d90c9381a700b1eb250eba0ac7 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:03:49 +0800 Subject: [PATCH 1145/1963] chore: cleanup invariant test code (#8236) * chore: cleanup invariant test code * Changes after review, RefCell invariant test data struct --- crates/evm/evm/src/executors/invariant/mod.rs | 333 +++++++++++------- .../evm/evm/src/executors/invariant/result.rs | 55 ++- 2 files changed, 241 insertions(+), 147 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 06a8ba0754a18..91d9028da599d 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -97,11 +97,141 @@ sol! { } } +/// Contains data collected during invariant test runs. +pub struct InvariantTestData { + // Consumed gas and calldata of every successful fuzz call. + pub fuzz_cases: Vec, + // Data related to reverts or failed assertions of the test. + pub failures: InvariantFailures, + // Calldata in the last invariant run. + pub last_run_inputs: Vec, + // Additional traces for gas report. + pub gas_report_traces: Vec>, + // Last call results of the invariant test. + pub last_call_results: Option, + + // Proptest runner to query for random values. + // The strategy only comes with the first `input`. We fill the rest of the `inputs` + // until the desired `depth` so we can use the evolving fuzz dictionary + // during the run. + pub branch_runner: TestRunner, +} + +/// Contains invariant test data. +pub struct InvariantTest { + // Fuzz state of invariant test. + pub fuzz_state: EvmFuzzState, + // Contracts fuzzed by the invariant test. + pub targeted_contracts: FuzzRunIdentifiedContracts, + // Data collected during invariant runs. + pub execution_data: RefCell, +} + +impl InvariantTest { + /// Instantiates an invariant test. + pub fn new( + fuzz_state: EvmFuzzState, + targeted_contracts: FuzzRunIdentifiedContracts, + failures: InvariantFailures, + last_call_results: Option, + branch_runner: TestRunner, + ) -> Self { + let mut fuzz_cases = vec![]; + if last_call_results.is_none() { + fuzz_cases.push(FuzzedCases::new(vec![])); + } + let execution_data = RefCell::new(InvariantTestData { + fuzz_cases, + failures, + last_run_inputs: vec![], + gas_report_traces: vec![], + last_call_results, + branch_runner, + }); + Self { fuzz_state, targeted_contracts, execution_data } + } + + /// Returns number of invariant test reverts. + pub fn reverts(&self) -> usize { + self.execution_data.borrow().failures.reverts + } + + /// Whether invariant test has errors or not. + pub fn has_errors(&self) -> bool { + self.execution_data.borrow().failures.error.is_none() + } + + /// Set invariant test error. + pub fn set_error(&self, error: InvariantFuzzError) { + self.execution_data.borrow_mut().failures.error = Some(error); + } + + /// Set last invariant test call results. + pub fn set_last_call_results(&self, call_result: Option) { + self.execution_data.borrow_mut().last_call_results = call_result; + } + + /// Set last invariant run call sequence. + pub fn set_last_run_inputs(&self, inputs: &Vec) { + self.execution_data.borrow_mut().last_run_inputs.clone_from(inputs); + } + + /// End invariant test run by collecting results, cleaning collected artifacts and reverting + /// created fuzz state. + pub fn end_run(&self, run: InvariantTestRun, gas_samples: usize) { + // We clear all the targeted contracts created during this run. + self.targeted_contracts.clear_created_contracts(run.created_contracts); + + let mut invariant_data = self.execution_data.borrow_mut(); + if invariant_data.gas_report_traces.len() < gas_samples { + invariant_data.gas_report_traces.push(run.run_traces); + } + invariant_data.fuzz_cases.push(FuzzedCases::new(run.fuzz_runs)); + + // Revert state to not persist values between runs. + self.fuzz_state.revert(); + } +} + +/// Contains data for an invariant test run. +pub struct InvariantTestRun { + // Invariant run call sequence. + pub inputs: Vec, + // Current invariant run executor. + pub executor: Executor, + // Invariant run stat reports (eg. gas usage). + pub fuzz_runs: Vec, + // Contracts created during current invariant run. + pub created_contracts: Vec
, + // Traces of each call of the invariant run call sequence. + pub run_traces: Vec, + // Current depth of invariant run. + pub depth: u32, + // Current assume rejects of the invariant run. + pub assume_rejects_counter: u32, +} + +impl InvariantTestRun { + /// Instantiates an invariant test run. + pub fn new(first_input: BasicTxDetails, executor: Executor, depth: usize) -> Self { + Self { + inputs: vec![first_input], + executor, + fuzz_runs: Vec::with_capacity(depth), + created_contracts: vec![], + run_traces: vec![], + depth: 0, + assume_rejects_counter: 0, + } + } +} + /// Wrapper around any [`Executor`] implementor which provides fuzzing support using [`proptest`]. /// -/// After instantiation, calling `fuzz` will proceed to hammer the deployed smart contracts with -/// inputs, until it finds a counterexample sequence. The provided [`TestRunner`] contains all the -/// configuration which can be overridden via [environment variables](proptest::test_runner::Config) +/// After instantiation, calling `invariant_fuzz` will proceed to hammer the deployed smart +/// contracts with inputs, until it finds a counterexample sequence. The provided [`TestRunner`] +/// contains all the configuration which can be overridden via [environment +/// variables](proptest::test_runner::Config) pub struct InvariantExecutor<'a> { pub executor: Executor, /// Proptest runner. @@ -148,73 +278,31 @@ impl<'a> InvariantExecutor<'a> { return Err(eyre!("Invariant test function should have no inputs")) } - let (fuzz_state, targeted_contracts, strat) = - self.prepare_fuzzing(&invariant_contract, fuzz_fixtures)?; + let (invariant_test, invariant_strategy) = + self.prepare_test(&invariant_contract, fuzz_fixtures)?; - // Stores the consumed gas and calldata of every successful fuzz call. - let fuzz_cases: RefCell> = RefCell::new(Default::default()); - - // Stores data related to reverts or failed assertions of the test. - let failures = RefCell::new(InvariantFailures::new()); - - // Stores the calldata in the last run. - let last_run_inputs: RefCell> = RefCell::new(vec![]); - - // Stores additional traces for gas report. - let gas_report_traces: RefCell>> = RefCell::default(); - - // Let's make sure the invariant is sound before actually starting the run: - // We'll assert the invariant in its initial state, and if it fails, we'll - // already know if we can early exit the invariant run. - // This does not count as a fuzz run. It will just register the revert. - let last_call_results = RefCell::new(assert_invariants( - &invariant_contract, - &self.config, - &targeted_contracts, - &self.executor, - &[], - &mut failures.borrow_mut(), - )?); - - if last_call_results.borrow().is_none() { - fuzz_cases.borrow_mut().push(FuzzedCases::new(vec![])); - } - - // The strategy only comes with the first `input`. We fill the rest of the `inputs` - // until the desired `depth` so we can use the evolving fuzz dictionary - // during the run. We need another proptest runner to query for random - // values. - let branch_runner = RefCell::new(self.runner.clone()); - let _ = self.runner.run(&strat, |first_input| { - let mut inputs = vec![first_input]; + let _ = self.runner.run(&invariant_strategy, |first_input| { + // Create current invariant run data. + let mut current_run = InvariantTestRun::new( + first_input, + // Before each run, we must reset the backend state. + self.executor.clone(), + self.config.depth as usize, + ); // We stop the run immediately if we have reverted, and `fail_on_revert` is set. - if self.config.fail_on_revert && failures.borrow().reverts > 0 { + if self.config.fail_on_revert && invariant_test.reverts() > 0 { return Err(TestCaseError::fail("Revert occurred.")) } - // Before each run, we must reset the backend state. - let mut executor = self.executor.clone(); - - // Used for stat reports (eg. gas usage). - let mut fuzz_runs = Vec::with_capacity(self.config.depth as usize); - - // Created contracts during a run. - let mut created_contracts = vec![]; - - // Traces of each call of the sequence. - let mut run_traces = Vec::new(); - - let mut current_run = 0; - let mut assume_rejects_counter = 0; - - while current_run < self.config.depth { - let tx = inputs.last().ok_or_else(|| { + while current_run.depth < self.config.depth { + let tx = current_run.inputs.last().ok_or_else(|| { TestCaseError::fail("No input generated to call fuzzed target.") })?; // Execute call from the randomly generated sequence and commit state changes. - let call_result = executor + let call_result = current_run + .executor .transact_raw( tx.sender, tx.call_details.target, @@ -226,10 +314,10 @@ impl<'a> InvariantExecutor<'a> { })?; if call_result.result.as_ref() == MAGIC_ASSUME { - inputs.pop(); - assume_rejects_counter += 1; - if assume_rejects_counter > self.config.max_assume_rejects { - failures.borrow_mut().error = Some(InvariantFuzzError::MaxAssumeRejects( + current_run.inputs.pop(); + current_run.assume_rejects_counter += 1; + if current_run.assume_rejects_counter > self.config.max_assume_rejects { + invariant_test.set_error(InvariantFuzzError::MaxAssumeRejects( self.config.max_assume_rejects, )); return Err(TestCaseError::fail("Max number of vm.assume rejects reached.")) @@ -240,28 +328,29 @@ impl<'a> InvariantExecutor<'a> { if !call_result.reverted { collect_data( + &invariant_test, &mut state_changeset, - &targeted_contracts, tx, &call_result, - &fuzz_state, self.config.depth, ); } // Collect created contracts and add to fuzz targets only if targeted contracts // are updatable. - if let Err(error) = &targeted_contracts.collect_created_contracts( - &state_changeset, - self.project_contracts, - self.setup_contracts, - &self.artifact_filters, - &mut created_contracts, - ) { + if let Err(error) = + &invariant_test.targeted_contracts.collect_created_contracts( + &state_changeset, + self.project_contracts, + self.setup_contracts, + &self.artifact_filters, + &mut current_run.created_contracts, + ) + { warn!(target: "forge::test", "{error}"); } - fuzz_runs.push(FuzzCase { + current_run.fuzz_runs.push(FuzzCase { calldata: tx.call_details.calldata.clone(), gas: call_result.gas_used, stipend: call_result.stipend, @@ -269,62 +358,49 @@ impl<'a> InvariantExecutor<'a> { let result = can_continue( &invariant_contract, + &invariant_test, + &mut current_run, &self.config, call_result, - &executor, - &inputs, - &mut failures.borrow_mut(), - &targeted_contracts, &state_changeset, - &mut run_traces, ) .map_err(|e| TestCaseError::fail(e.to_string()))?; - if !result.can_continue || current_run == self.config.depth - 1 { - last_run_inputs.borrow_mut().clone_from(&inputs); + if !result.can_continue || current_run.depth == self.config.depth - 1 { + invariant_test.set_last_run_inputs(¤t_run.inputs); } if !result.can_continue { break } - *last_call_results.borrow_mut() = result.call_result; - current_run += 1; + invariant_test.set_last_call_results(result.call_result); + current_run.depth += 1; } // Generates the next call from the run using the recently updated // dictionary. - inputs.push( - strat - .new_tree(&mut branch_runner.borrow_mut()) + current_run.inputs.push( + invariant_strategy + .new_tree(&mut invariant_test.execution_data.borrow_mut().branch_runner) .map_err(|_| TestCaseError::Fail("Could not generate case".into()))? .current(), ); } // Call `afterInvariant` only if it is declared and test didn't fail already. - if invariant_contract.call_after_invariant && failures.borrow().error.is_none() { + if invariant_contract.call_after_invariant && invariant_test.has_errors() { assert_after_invariant( &invariant_contract, + &invariant_test, + ¤t_run, &self.config, - &targeted_contracts, - &mut executor, - &mut failures.borrow_mut(), - &inputs, ) .map_err(|_| TestCaseError::Fail("Failed to call afterInvariant".into()))?; } - // We clear all the targeted contracts created during this run. - let _ = &targeted_contracts.clear_created_contracts(created_contracts); - - if gas_report_traces.borrow().len() < self.config.gas_report_samples as usize { - gas_report_traces.borrow_mut().push(run_traces); - } - fuzz_cases.borrow_mut().push(FuzzedCases::new(fuzz_runs)); - - // Revert state to not persist values between runs. - fuzz_state.revert(); + // End current invariant test run. + invariant_test.end_run(current_run, self.config.gas_report_samples as usize); // If running with progress then increment completed runs. if let Some(progress) = progress { @@ -335,29 +411,26 @@ impl<'a> InvariantExecutor<'a> { }); trace!(?fuzz_fixtures); - fuzz_state.log_stats(); - - let (reverts, error) = failures.into_inner().into_inner(); + invariant_test.fuzz_state.log_stats(); + let result = invariant_test.execution_data.into_inner(); Ok(InvariantFuzzTestResult { - error, - cases: fuzz_cases.into_inner(), - reverts, - last_run_inputs: last_run_inputs.into_inner(), - gas_report_traces: gas_report_traces.into_inner(), + error: result.failures.error, + cases: result.fuzz_cases, + reverts: result.failures.reverts, + last_run_inputs: result.last_run_inputs, + gas_report_traces: result.gas_report_traces, }) } /// Prepares certain structures to execute the invariant tests: - /// * Fuzz dictionary - /// * Targeted contracts + /// * Invariant Fuzz Test. /// * Invariant Strategy - fn prepare_fuzzing( + fn prepare_test( &mut self, invariant_contract: &InvariantContract<'_>, fuzz_fixtures: &FuzzFixtures, - ) -> Result<(EvmFuzzState, FuzzRunIdentifiedContracts, impl Strategy)> - { + ) -> Result<(InvariantTest, impl Strategy)> { // Finds out the chosen deployed contracts and/or senders. self.select_contract_artifacts(invariant_contract.address)?; let (targeted_senders, targeted_contracts) = @@ -399,7 +472,30 @@ impl<'a> InvariantExecutor<'a> { self.executor.inspector_mut().fuzzer = Some(Fuzzer { call_generator, fuzz_state: fuzz_state.clone(), collect: true }); - Ok((fuzz_state, targeted_contracts, strat)) + // Let's make sure the invariant is sound before actually starting the run: + // We'll assert the invariant in its initial state, and if it fails, we'll + // already know if we can early exit the invariant run. + // This does not count as a fuzz run. It will just register the revert. + let mut failures = InvariantFailures::new(); + let last_call_results = assert_invariants( + invariant_contract, + &self.config, + &targeted_contracts, + &self.executor, + &[], + &mut failures, + )?; + + Ok(( + InvariantTest::new( + fuzz_state, + targeted_contracts, + failures, + last_call_results, + self.runner.clone(), + ), + strat, + )) } /// Fills the `InvariantExecutor` with the artifact identifier filters (in `path:name` string @@ -669,11 +765,10 @@ impl<'a> InvariantExecutor<'a> { /// before inserting it into the dictionary. Otherwise, we flood the dictionary with /// randomly generated addresses. fn collect_data( + invariant_test: &InvariantTest, state_changeset: &mut HashMap, - fuzzed_contracts: &FuzzRunIdentifiedContracts, tx: &BasicTxDetails, call_result: &RawCallResult, - fuzz_state: &EvmFuzzState, run_depth: u32, ) { // Verify it has no code. @@ -691,8 +786,8 @@ fn collect_data( } // Collect values from fuzzed call result and add them to fuzz dictionary. - fuzz_state.collect_values_from_call( - fuzzed_contracts, + invariant_test.fuzz_state.collect_values_from_call( + &invariant_test.targeted_contracts, tx, &call_result.result, &call_result.logs, diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index f45ec2c349a9d..9e773445549b5 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -1,6 +1,6 @@ use super::{ call_after_invariant_function, call_invariant_function, error::FailedInvariantCaseData, - InvariantFailures, InvariantFuzzError, + InvariantFailures, InvariantFuzzError, InvariantTest, InvariantTestRun, }; use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; @@ -89,59 +89,60 @@ pub(crate) fn assert_invariants( /// Verifies that the invariant run execution can continue. /// Returns the mapping of (Invariant Function Name -> Call Result, Logs, Traces) if invariants were /// asserted. -#[allow(clippy::too_many_arguments)] pub(crate) fn can_continue( invariant_contract: &InvariantContract<'_>, + invariant_test: &InvariantTest, + invariant_run: &mut InvariantTestRun, invariant_config: &InvariantConfig, call_result: RawCallResult, - executor: &Executor, - calldata: &[BasicTxDetails], - failures: &mut InvariantFailures, - targeted_contracts: &FuzzRunIdentifiedContracts, state_changeset: &StateChangeset, - run_traces: &mut Vec, ) -> Result { let mut call_results = None; let handlers_succeeded = || { - targeted_contracts.targets.lock().keys().all(|address| { - executor.is_success(*address, false, Cow::Borrowed(state_changeset), false) + invariant_test.targeted_contracts.targets.lock().keys().all(|address| { + invariant_run.executor.is_success( + *address, + false, + Cow::Borrowed(state_changeset), + false, + ) }) }; // Assert invariants if the call did not revert and the handlers did not fail. if !call_result.reverted && handlers_succeeded() { if let Some(traces) = call_result.traces { - run_traces.push(traces); + invariant_run.run_traces.push(traces); } call_results = assert_invariants( invariant_contract, invariant_config, - targeted_contracts, - executor, - calldata, - failures, + &invariant_test.targeted_contracts, + &invariant_run.executor, + &invariant_run.inputs, + &mut invariant_test.execution_data.borrow_mut().failures, )?; if call_results.is_none() { return Ok(RichInvariantResults::new(false, None)); } } else { // Increase the amount of reverts. - failures.reverts += 1; + let mut invariant_data = invariant_test.execution_data.borrow_mut(); + invariant_data.failures.reverts += 1; // If fail on revert is set, we must return immediately. if invariant_config.fail_on_revert { let case_data = FailedInvariantCaseData::new( invariant_contract, invariant_config, - targeted_contracts, - calldata, + &invariant_test.targeted_contracts, + &invariant_run.inputs, call_result, &[], ); - failures.revert_reason = Some(case_data.revert_reason.clone()); - let error = InvariantFuzzError::Revert(case_data); - failures.error = Some(error); + invariant_data.failures.revert_reason = Some(case_data.revert_reason.clone()); + invariant_data.failures.error = Some(InvariantFuzzError::Revert(case_data)); return Ok(RichInvariantResults::new(false, None)); } @@ -153,25 +154,23 @@ pub(crate) fn can_continue( /// If call fails then the invariant test is considered failed. pub(crate) fn assert_after_invariant( invariant_contract: &InvariantContract<'_>, + invariant_test: &InvariantTest, + invariant_run: &InvariantTestRun, invariant_config: &InvariantConfig, - targeted_contracts: &FuzzRunIdentifiedContracts, - executor: &mut Executor, - invariant_failures: &mut InvariantFailures, - inputs: &[BasicTxDetails], ) -> Result { let (call_result, success) = - call_after_invariant_function(executor, invariant_contract.address)?; + call_after_invariant_function(&invariant_run.executor, invariant_contract.address)?; // Fail the test case if `afterInvariant` doesn't succeed. if !success { let case_data = FailedInvariantCaseData::new( invariant_contract, invariant_config, - targeted_contracts, - inputs, + &invariant_test.targeted_contracts, + &invariant_run.inputs, call_result, &[], ); - invariant_failures.error = Some(InvariantFuzzError::BrokenInvariant(case_data)); + invariant_test.set_error(InvariantFuzzError::BrokenInvariant(case_data)); } Ok(success) } From 2238c22aa7da06c9730afe354b2832598b91575b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 24 Jun 2024 18:13:03 +0200 Subject: [PATCH 1146/1963] fix: use tx.into_signed directly (#8243) --- crates/anvil/src/eth/sign.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index c122d54ddf916..d921b18d35e46 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -1,5 +1,5 @@ use crate::eth::error::BlockchainError; -use alloy_consensus::{SignableTransaction, Signed}; +use alloy_consensus::SignableTransaction; use alloy_dyn_abi::TypedData; use alloy_network::TxSignerSync; use alloy_primitives::{Address, Signature, B256}; @@ -121,21 +121,15 @@ pub fn build_typed_transaction( signature: Signature, ) -> Result { let tx = match request { - TypedTransactionRequest::Legacy(tx) => { - let sighash = tx.signature_hash(); - TypedTransaction::Legacy(Signed::new_unchecked(tx, signature, sighash)) - } + TypedTransactionRequest::Legacy(tx) => TypedTransaction::Legacy(tx.into_signed(signature)), TypedTransactionRequest::EIP2930(tx) => { - let sighash = tx.signature_hash(); - TypedTransaction::EIP2930(Signed::new_unchecked(tx, signature, sighash)) + TypedTransaction::EIP2930(tx.into_signed(signature)) } TypedTransactionRequest::EIP1559(tx) => { - let sighash = tx.signature_hash(); - TypedTransaction::EIP1559(Signed::new_unchecked(tx, signature, sighash)) + TypedTransaction::EIP1559(tx.into_signed(signature)) } TypedTransactionRequest::EIP4844(tx) => { - let sighash = tx.signature_hash(); - TypedTransaction::EIP4844(Signed::new_unchecked(tx, signature, sighash)) + TypedTransaction::EIP4844(tx.into_signed(signature)) } TypedTransactionRequest::Deposit(tx) => { let DepositTransactionRequest { From abd8d55c36e4b717de844b43395b22150a813a9e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:45:39 +0200 Subject: [PATCH 1147/1963] fix: overflow in randomUint (#8239) --- crates/cheatcodes/src/utils.rs | 7 ++++--- testdata/default/cheats/RandomUint.t.sol | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 8d4c547dff138..66129800d0713 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -158,11 +158,12 @@ impl Cheatcode for randomUint_0Call { impl Cheatcode for randomUint_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { min, max } = self; + let Self { min, max } = *self; + ensure!(min <= max, "min must be less than or equal to max"); // Generate random between range min..=max let mut rng = rand::thread_rng(); - let range = *max - *min + U256::from(1); - let random_number = rng.gen::() % range + *min; + let range = max - min + U256::from(1); + let random_number = rng.gen::() % range + min; Ok(random_number.abi_encode()) } } diff --git a/testdata/default/cheats/RandomUint.t.sol b/testdata/default/cheats/RandomUint.t.sol index e1c7e09d3ce7d..287f8821992b3 100644 --- a/testdata/default/cheats/RandomUint.t.sol +++ b/testdata/default/cheats/RandomUint.t.sol @@ -15,9 +15,7 @@ contract RandomUint is DSTest { } function testRandomUint(uint256 min, uint256 max) public { - if (min > max) { - (min, max) = (max, min); - } + vm.assume(max >= min); uint256 rand = vm.randomUint(min, max); assertTrue(rand >= min, "rand >= min"); assertTrue(rand <= max, "rand <= max"); From a1be7093ab6e9e022784276f3053d34ddb32fba7 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 24 Jun 2024 19:22:07 +0200 Subject: [PATCH 1148/1963] fix: use inclusive check for logs range fetch in fork (#8245) --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index a5e98abfbfed6..7c6fcdf90ba56 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1385,7 +1385,7 @@ impl Backend { to_on_fork = fork.block_number(); } - if fork.predates_fork(from) { + if fork.predates_fork_inclusive(from) { // this data is only available on the forked client let filter = filter.clone().from_block(from).to_block(to_on_fork); all_logs = fork.logs(&filter).await?; From 86786f0fec3447f2430a445af4eb10cb1e25de4e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:19:45 +0200 Subject: [PATCH 1149/1963] feat: extract ABIs and formatting code into separate crates (#8240) * feat: extract ABIs and formatting code into separate crates * reorder * features * hex * doctests --- Cargo.lock | 48 +++++++++---- Cargo.toml | 3 +- crates/cast/Cargo.toml | 1 - crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/create2.rs | 2 +- crates/cast/bin/cmd/logs.rs | 3 +- crates/cast/bin/cmd/mktx.rs | 1 + crates/cast/bin/cmd/wallet/mod.rs | 2 +- crates/cast/bin/cmd/wallet/vanity.rs | 2 +- crates/cast/bin/main.rs | 2 +- crates/cast/bin/tx.rs | 2 +- crates/cast/src/lib.rs | 6 +- crates/cast/src/rlp_converter.rs | 1 + crates/cheatcodes/Cargo.toml | 1 - crates/cheatcodes/src/error.rs | 2 +- crates/cheatcodes/src/fs.rs | 2 +- crates/cheatcodes/src/inspector.rs | 2 +- crates/cheatcodes/src/json.rs | 2 +- crates/cheatcodes/src/string.rs | 2 +- crates/cheatcodes/src/test/assert.rs | 8 +-- crates/cheatcodes/src/test/expect.rs | 2 +- crates/cheatcodes/src/utils.rs | 3 +- crates/cli/Cargo.toml | 1 - crates/cli/src/utils/abi.rs | 2 +- crates/common/Cargo.toml | 7 +- crates/common/fmt/Cargo.toml | 31 +++++++++ crates/common/{src/fmt => fmt/src}/console.rs | 0 crates/common/{src/fmt => fmt/src}/dynamic.rs | 10 +-- .../common/{src/fmt/mod.rs => fmt/src/exp.rs} | 69 ++++++++++++++++--- crates/common/fmt/src/lib.rs | 13 ++++ crates/common/{src/fmt => fmt/src}/ui.rs | 65 +++-------------- crates/common/src/calc.rs | 56 --------------- crates/common/src/lib.rs | 3 +- crates/common/src/transactions.rs | 48 +++++++++++++ crates/evm/abi/Cargo.toml | 29 ++++++++ .../src/abi => abi/src}/HardhatConsole.json | 0 .../src/console/hardhat.rs} | 9 +-- .../abi/console.rs => abi/src/console/mod.rs} | 3 + crates/evm/abi/src/lib.rs | 7 ++ crates/evm/core/Cargo.toml | 5 +- crates/evm/core/src/abi/mod.rs | 12 ---- crates/evm/core/src/debug.rs | 2 +- crates/evm/core/src/decode.rs | 2 +- crates/evm/core/src/lib.rs | 6 +- crates/evm/traces/Cargo.toml | 3 +- crates/evm/traces/src/decoder/precompiles.rs | 2 +- .../evm/traces/src/identifier/signatures.rs | 1 + crates/evm/traces/src/lib.rs | 2 +- crates/forge/Cargo.toml | 1 - crates/forge/bin/cmd/clone.rs | 6 +- crates/forge/bin/cmd/create.rs | 4 +- crates/forge/bin/cmd/selectors.rs | 1 + crates/forge/tests/cli/cmd.rs | 1 + crates/forge/tests/cli/create.rs | 2 +- crates/forge/tests/cli/script.rs | 2 +- crates/macros/src/console_fmt.rs | 12 ++-- crates/script/Cargo.toml | 1 - crates/script/src/lib.rs | 2 +- crates/script/src/sequence.rs | 2 +- crates/script/src/transaction.rs | 2 +- crates/script/src/verify.rs | 3 +- crates/verify/Cargo.toml | 1 - crates/verify/src/etherscan/mod.rs | 1 + crates/wallets/Cargo.toml | 1 - crates/wallets/src/error.rs | 2 +- crates/wallets/src/utils.rs | 3 +- crates/wallets/src/wallet_signer.rs | 2 +- 67 files changed, 307 insertions(+), 229 deletions(-) create mode 100644 crates/common/fmt/Cargo.toml rename crates/common/{src/fmt => fmt/src}/console.rs (100%) rename crates/common/{src/fmt => fmt/src}/dynamic.rs (96%) rename crates/common/{src/fmt/mod.rs => fmt/src/exp.rs} (53%) create mode 100644 crates/common/fmt/src/lib.rs rename crates/common/{src/fmt => fmt/src}/ui.rs (92%) create mode 100644 crates/evm/abi/Cargo.toml rename crates/evm/{core/src/abi => abi/src}/HardhatConsole.json (100%) rename crates/evm/{core/src/abi/hardhat_console.rs => abi/src/console/hardhat.rs} (99%) rename crates/evm/{core/src/abi/console.rs => abi/src/console/mod.rs} (98%) create mode 100644 crates/evm/abi/src/lib.rs delete mode 100644 crates/evm/core/src/abi/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 49b7ae903794a..fdaefa35d2e0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1922,7 +1922,6 @@ dependencies = [ "clap_complete", "clap_complete_fig", "comfy-table", - "const-hex", "criterion", "dunce", "evm-disassembler", @@ -3316,7 +3315,6 @@ dependencies = [ "clap_complete", "clap_complete_fig", "comfy-table", - "const-hex", "criterion", "dialoguer", "dunce", @@ -3436,7 +3434,6 @@ dependencies = [ "alloy-transport", "async-recursion", "clap", - "const-hex", "dialoguer", "dunce", "eyre", @@ -3489,7 +3486,6 @@ dependencies = [ "alloy-rpc-types", "async-trait", "clap", - "const-hex", "eyre", "foundry-block-explorers", "foundry-cli", @@ -3554,7 +3550,6 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "base64 0.22.1", - "const-hex", "dialoguer", "eyre", "foundry-cheatcodes-spec", @@ -3602,7 +3597,6 @@ dependencies = [ "alloy-transport", "clap", "color-eyre", - "const-hex", "dotenvy", "eyre", "forge-fmt", @@ -3630,7 +3624,6 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ - "alloy-consensus", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -3647,12 +3640,12 @@ dependencies = [ "alloy-transport-ipc", "alloy-transport-ws", "async-trait", - "chrono", "clap", "comfy-table", "dunce", "eyre", "foundry-block-explorers", + "foundry-common-fmt", "foundry-compilers", "foundry-config", "foundry-linking", @@ -3674,6 +3667,23 @@ dependencies = [ "yansi", ] +[[package]] +name = "foundry-common-fmt" +version = "0.2.0" +dependencies = [ + "alloy-consensus", + "alloy-dyn-abi", + "alloy-primitives", + "alloy-rpc-types", + "alloy-serde", + "chrono", + "foundry-macros", + "serde", + "serde_json", + "similar-asserts", + "yansi", +] + [[package]] name = "foundry-compilers" version = "0.8.0" @@ -3861,6 +3871,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "foundry-evm-abi" +version = "0.2.0" +dependencies = [ + "alloy-primitives", + "alloy-sol-types", + "derive_more", + "foundry-common-fmt", + "foundry-macros", + "foundry-test-utils", + "itertools 0.13.0", + "once_cell", + "rustc-hash 2.0.0", +] + [[package]] name = "foundry-evm-core" version = "0.2.0" @@ -3876,17 +3901,14 @@ dependencies = [ "alloy-transport", "arrayvec", "auto_impl", - "const-hex", - "derive_more", "eyre", "foundry-cheatcodes-spec", "foundry-common", "foundry-config", - "foundry-macros", + "foundry-evm-abi", "foundry-test-utils", "futures", "itertools 0.13.0", - "once_cell", "parking_lot", "revm", "revm-inspectors", @@ -3949,7 +3971,6 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-types", - "const-hex", "eyre", "foundry-block-explorers", "foundry-common", @@ -4029,7 +4050,6 @@ dependencies = [ "aws-config", "aws-sdk-kms", "clap", - "const-hex", "derive_builder", "eyre", "foundry-config", diff --git a/Cargo.toml b/Cargo.toml index 91a876c941e7e..80df56818f002 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,9 +132,11 @@ foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } foundry-cli = { path = "crates/cli" } foundry-common = { path = "crates/common" } +foundry-common-fmt = { path = "crates/common/fmt" } foundry-config = { path = "crates/config" } foundry-debugger = { path = "crates/debugger" } foundry-evm = { path = "crates/evm/evm" } +foundry-evm-abi = { path = "crates/evm/abi" } foundry-evm-core = { path = "crates/evm/core" } foundry-evm-coverage = { path = "crates/evm/coverage" } foundry-evm-fuzz = { path = "crates/evm/fuzz" } @@ -216,7 +218,6 @@ evm-disassembler = "0.5" eyre = "0.6" figment = "0.10" futures = "0.3" -hex = { package = "const-hex", version = "1.6", features = ["hex"] } itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index df69f21f22249..602ec57ae4952 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -54,7 +54,6 @@ chrono.workspace = true evm-disassembler.workspace = true eyre.workspace = true futures.workspace = true -hex.workspace = true rand.workspace = true rayon.workspace = true serde_json.workspace = true diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 0499f5e7b2752..a6d3d793dc8ef 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -189,7 +189,7 @@ impl CallArgs { #[cfg(test)] mod tests { use super::*; - use alloy_primitives::Address; + use alloy_primitives::{hex, Address}; #[test] fn can_parse_call_data() { diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 8c3b12dad78e3..0f751fc89f06e 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_primitives::{hex, keccak256, Address, B256, U256}; use clap::Parser; use eyre::{Result, WrapErr}; use rand::{rngs::StdRng, RngCore, SeedableRng}; diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 7d92ab935ee19..c51bad8cc7d9c 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -1,7 +1,7 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, Specifier}; use alloy_json_abi::Event; use alloy_network::AnyNetwork; -use alloy_primitives::{Address, B256}; +use alloy_primitives::{hex::FromHex, Address, B256}; use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, FilterBlockOption, FilterSet, Topic}; use cast::Cast; use clap::Parser; @@ -9,7 +9,6 @@ use eyre::Result; use foundry_cli::{opts::EthereumOpts, utils}; use foundry_common::ens::NameOrAddress; use foundry_config::Config; -use hex::FromHex; use itertools::Itertools; use std::{io, str::FromStr}; diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index db8dbf0fe7259..48c91dd77ffb1 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -1,5 +1,6 @@ use crate::tx::{self, CastTxBuilder}; use alloy_network::{eip2718::Encodable2718, EthereumWallet, TransactionBuilder}; +use alloy_primitives::hex; use alloy_signer::Signer; use clap::Parser; use eyre::Result; diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 2b50630c3da67..64f048b2cfa7f 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,5 +1,5 @@ use alloy_dyn_abi::TypedData; -use alloy_primitives::{Address, Signature, B256}; +use alloy_primitives::{hex, Address, Signature, B256}; use alloy_signer::Signer; use alloy_signer_local::{ coins_bip39::{English, Entropy, Mnemonic}, diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 1e94b5f9ae9bf..692f54a857050 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,4 +1,4 @@ -use alloy_primitives::Address; +use alloy_primitives::{hex, Address}; use alloy_signer::{k256::ecdsa::SigningKey, utils::secret_key_to_address}; use alloy_signer_local::PrivateKeySigner; use clap::{builder::TypedValueParser, Parser}; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 0f6673d4fea04..b42e4231d0c0e 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{keccak256, Address, B256}; +use alloy_primitives::{hex, keccak256, Address, B256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, BlockNumberOrTag::Latest}; use cast::{Cast, SimpleCast}; diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index c0f1e1a97a3b2..6edb8c5b272a6 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,7 +1,7 @@ use alloy_consensus::{SidecarBuilder, SimpleCoder}; use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; -use alloy_primitives::{Address, TxKind}; +use alloy_primitives::{hex, Address, TxKind}; use alloy_provider::Provider; use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 4934d8dd30bd9..836cfd94b9afc 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -6,6 +6,7 @@ use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt}; use alloy_json_abi::Function; use alloy_network::AnyNetwork; use alloy_primitives::{ + hex, utils::{keccak256, ParseUnits, Unit}, Address, Keccak256, TxHash, TxKind, B256, I256, U256, }; @@ -27,7 +28,7 @@ use foundry_common::{ abi::{encode_function_args, get_func}, compile::etherscan_project, fmt::*, - fs, TransactionReceiptWithRevertReason, + fs, get_pretty_tx_receipt_attr, TransactionReceiptWithRevertReason, }; use foundry_compilers::flatten::Flattener; use foundry_config::Chain; @@ -1477,7 +1478,7 @@ impl SimpleCast { /// /// ``` /// use cast::SimpleCast as Cast; - /// use hex; + /// use alloy_primitives::hex; /// /// // Passing `input = false` will decode the data as the output type. /// // The input data types and the full function sig are ignored, i.e. @@ -1520,6 +1521,7 @@ impl SimpleCast { /// /// ``` /// use cast::SimpleCast as Cast; + /// use alloy_primitives::hex; /// /// // Passing `input = false` will decode the data as the output type. /// // The input data types and the full function sig are ignored, i.e. diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index cab852ab35f15..0b90891ecdc4e 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -1,3 +1,4 @@ +use alloy_primitives::hex; use alloy_rlp::{Buf, Decodable, Encodable, Header}; use serde_json::Value; use std::fmt; diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index b155a8643b5e5..7e2e366e96edf 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -37,7 +37,6 @@ alloy-signer-local = { workspace = true, features = [ parking_lot.workspace = true eyre.workspace = true -hex.workspace = true itertools.workspace = true jsonpath_lib.workspace = true revm.workspace = true diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index ec4459d3bb0b5..5d38bbc34d8c6 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -1,5 +1,5 @@ use crate::Vm; -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{hex, Address, Bytes}; use alloy_signer::Error as SignerError; use alloy_signer_local::LocalSignerError; use alloy_sol_types::SolError; diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index e4ee12513e4e4..a126d8dc9e909 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -4,7 +4,7 @@ use super::string::parse; use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::DynSolType; use alloy_json_abi::ContractObject; -use alloy_primitives::{Bytes, U256}; +use alloy_primitives::{hex, Bytes, U256}; use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; use foundry_common::fs; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 507b644713954..a2d85c83b2ca0 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -15,7 +15,7 @@ use crate::{ CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, Vm, Vm::AccountAccess, }; -use alloy_primitives::{Address, Bytes, Log, TxKind, B256, U256}; +use alloy_primitives::{hex, Address, Bytes, Log, TxKind, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolCall, SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, SELECTOR_LEN}; diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index d3c3e95963360..4ecd595f4d65c 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -2,7 +2,7 @@ use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::{Address, B256, I256}; +use alloy_primitives::{hex, Address, B256, I256}; use alloy_sol_types::SolValue; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index 07e9e89f5f6ef..c808bc04f6ceb 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -2,7 +2,7 @@ use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::U256; +use alloy_primitives::{hex, U256}; use alloy_sol_types::SolValue; // address diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index c7dce14731069..4d4a779c78f19 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -1,10 +1,8 @@ -use std::fmt::{Debug, Display}; - -use alloy_primitives::{I256, U256}; +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use alloy_primitives::{hex, I256, U256}; use foundry_evm_core::abi::{format_units_int, format_units_uint}; use itertools::Itertools; - -use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use std::fmt::{Debug, Display}; const EQ_REL_DELTA_RESOLUTION: U256 = U256::from_limbs([18, 0, 0, 0]); diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 3b777bd8a487d..eba665856b117 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,5 +1,5 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::{address, Address, Bytes, LogData as RawLog, U256}; +use alloy_primitives::{address, hex, Address, Bytes, LogData as RawLog, U256}; use alloy_sol_types::{SolError, SolValue}; use revm::interpreter::{return_ok, InstructionResult}; use spec::Vm; diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 66129800d0713..733ed36837279 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -311,8 +311,7 @@ fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { mod tests { use super::*; use crate::CheatsConfig; - use alloy_primitives::FixedBytes; - use hex::FromHex; + use alloy_primitives::{hex::FromHex, FixedBytes}; use p256::ecdsa::signature::hazmat::PrehashVerifier; use std::{path::PathBuf, sync::Arc}; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index e9d36fdeed532..d8ca1f53da9ef 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -34,7 +34,6 @@ color-eyre.workspace = true dotenvy = "0.15" eyre.workspace = true futures.workspace = true -hex.workspace = true indicatif = "0.17" once_cell.workspace = true regex = { version = "1", default-features = false } diff --git a/crates/cli/src/utils/abi.rs b/crates/cli/src/utils/abi.rs index a52bdc15898e7..e903804ded91e 100644 --- a/crates/cli/src/utils/abi.rs +++ b/crates/cli/src/utils/abi.rs @@ -1,6 +1,6 @@ use alloy_chains::Chain; use alloy_json_abi::Function; -use alloy_primitives::Address; +use alloy_primitives::{hex, Address}; use alloy_provider::{network::AnyNetwork, Provider}; use alloy_transport::Transport; use eyre::{OptionExt, Result}; diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index f50435610ae65..3865453e6f3fd 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -14,11 +14,11 @@ workspace = true [dependencies] foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } +foundry-common-fmt.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-linking.workspace = true -alloy-consensus.workspace = true alloy-contract.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-json-abi.workspace = true @@ -50,8 +50,10 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table = "7" dunce.workspace = true eyre.workspace = true +num-format.workspace = true once_cell.workspace = true reqwest.workspace = true +rustc-hash.workspace = true semver.workspace = true serde_json.workspace = true serde.workspace = true @@ -61,9 +63,6 @@ tracing.workspace = true url.workspace = true walkdir.workspace = true yansi.workspace = true -rustc-hash.workspace = true -num-format.workspace = true -chrono.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/fmt/Cargo.toml b/crates/common/fmt/Cargo.toml new file mode 100644 index 0000000000000..285c3052dc0c6 --- /dev/null +++ b/crates/common/fmt/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "foundry-common-fmt" +description = "Common formatting utilities for Foundry" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[lints] +workspace = true + +[dependencies] +alloy-primitives.workspace = true +alloy-dyn-abi = { workspace = true, features = ["eip712"] } +yansi.workspace = true + +# ui +alloy-consensus.workspace = true +alloy-rpc-types = { workspace = true, features = ["eth"] } +alloy-serde.workspace = true +serde.workspace = true +serde_json.workspace = true +chrono.workspace = true + +[dev-dependencies] +foundry-macros.workspace = true +similar-asserts.workspace = true diff --git a/crates/common/src/fmt/console.rs b/crates/common/fmt/src/console.rs similarity index 100% rename from crates/common/src/fmt/console.rs rename to crates/common/fmt/src/console.rs diff --git a/crates/common/src/fmt/dynamic.rs b/crates/common/fmt/src/dynamic.rs similarity index 96% rename from crates/common/src/fmt/dynamic.rs rename to crates/common/fmt/src/dynamic.rs index 19330d47446e1..5055e65618b66 100644 --- a/crates/common/src/fmt/dynamic.rs +++ b/crates/common/fmt/src/dynamic.rs @@ -1,7 +1,6 @@ use super::{format_int_exp, format_uint_exp}; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::hex; -use eyre::Result; use std::fmt; /// [`DynSolValue`] formatter. @@ -111,13 +110,8 @@ impl fmt::Display for DynValueDisplay<'_> { /// Parses string input as Token against the expected ParamType pub fn parse_tokens<'a, I: IntoIterator>( params: I, -) -> Result> { - let mut tokens = Vec::new(); - for (param, value) in params { - let token = DynSolType::coerce_str(param, value)?; - tokens.push(token); - } - Ok(tokens) +) -> alloy_dyn_abi::Result> { + params.into_iter().map(|(param, value)| DynSolType::coerce_str(param, value)).collect() } /// Pretty-prints a slice of tokens using [`format_token`]. diff --git a/crates/common/src/fmt/mod.rs b/crates/common/fmt/src/exp.rs similarity index 53% rename from crates/common/src/fmt/mod.rs rename to crates/common/fmt/src/exp.rs index a43fe7dea0889..84444615e6d09 100644 --- a/crates/common/src/fmt/mod.rs +++ b/crates/common/fmt/src/exp.rs @@ -1,17 +1,40 @@ -//! Helpers for formatting Ethereum types. - -use crate::calc::to_exp_notation; use alloy_primitives::{Sign, I256, U256}; use yansi::Paint; -mod console; -pub use console::{console_format, ConsoleFmt, FormatSpec}; +/// Returns the number expressed as a string in exponential notation +/// with the given precision (number of significant figures), +/// optionally removing trailing zeros from the mantissa. +/// +/// Examples: +/// +/// ```text +/// precision = 4, trim_end_zeroes = false +/// 1234124124 -> 1.234e9 +/// 10000000 -> 1.000e7 +/// precision = 3, trim_end_zeroes = true +/// 1234124124 -> 1.23e9 +/// 10000000 -> 1e7 +/// ``` +#[inline] +pub fn to_exp_notation(value: U256, precision: usize, trim_end_zeros: bool, sign: Sign) -> String { + let stringified = value.to_string(); + let exponent = stringified.len() - 1; + let mut mantissa = stringified.chars().take(precision).collect::(); -mod dynamic; -pub use dynamic::{format_token, format_token_raw, format_tokens, parse_tokens}; + // optionally remove trailing zeros + if trim_end_zeros { + mantissa = mantissa.trim_end_matches('0').to_string(); + } -mod ui; -pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, get_pretty_tx_receipt_attr, UIfmt}; + // Place a decimal point only if needed + // e.g. 1234 -> 1.234e3 (needed) + // 5 -> 5 (not needed) + if mantissa.len() > 1 { + mantissa.insert(1, '.'); + } + + format!("{sign}{mantissa}e{exponent}") +} /// Formats a U256 number to string, adding an exponential notation _hint_ if it /// is larger than `10_000`, with a precision of `4` figures, and trimming the @@ -21,7 +44,7 @@ pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, get_pretty_tx_receipt_at /// /// ``` /// use alloy_primitives::U256; -/// use foundry_common::fmt::format_uint_exp as f; +/// use foundry_common_fmt::format_uint_exp as f; /// /// # yansi::disable(); /// assert_eq!(f(U256::from(0)), "0"); @@ -47,7 +70,7 @@ pub fn format_uint_exp(num: U256) -> String { /// /// ``` /// use alloy_primitives::I256; -/// use foundry_common::fmt::format_int_exp as f; +/// use foundry_common_fmt::format_int_exp as f; /// /// # yansi::disable(); /// assert_eq!(f(I256::try_from(0).unwrap()), "0"); @@ -74,3 +97,27 @@ pub fn format_int_exp(num: I256) -> String { let exp = to_exp_notation(abs, 4, true, sign); format!("{sign}{abs} {}", format!("[{exp}]").dim()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_format_to_exponential_notation() { + let value = 1234124124u64; + + let formatted = to_exp_notation(U256::from(value), 4, false, Sign::Positive); + assert_eq!(formatted, "1.234e9"); + + let formatted = to_exp_notation(U256::from(value), 3, true, Sign::Positive); + assert_eq!(formatted, "1.23e9"); + + let value = 10000000u64; + + let formatted = to_exp_notation(U256::from(value), 4, false, Sign::Positive); + assert_eq!(formatted, "1.000e7"); + + let formatted = to_exp_notation(U256::from(value), 3, true, Sign::Positive); + assert_eq!(formatted, "1e7"); + } +} diff --git a/crates/common/fmt/src/lib.rs b/crates/common/fmt/src/lib.rs new file mode 100644 index 0000000000000..5271b73c755be --- /dev/null +++ b/crates/common/fmt/src/lib.rs @@ -0,0 +1,13 @@ +//! Helpers for formatting Ethereum types. + +mod console; +pub use console::{console_format, ConsoleFmt, FormatSpec}; + +mod dynamic; +pub use dynamic::{format_token, format_token_raw, format_tokens, parse_tokens}; + +mod exp; +pub use exp::{format_int_exp, format_uint_exp, to_exp_notation}; + +mod ui; +pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, EthValue, UIfmt}; diff --git a/crates/common/src/fmt/ui.rs b/crates/common/fmt/src/ui.rs similarity index 92% rename from crates/common/src/fmt/ui.rs rename to crates/common/fmt/src/ui.rs index 0fe8dccd175f1..c7fa9c6e726e1 100644 --- a/crates/common/src/fmt/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -1,8 +1,7 @@ //! Helper trait and functions to format Ethereum types. -use crate::TransactionReceiptWithRevertReason; -use alloy_consensus::{AnyReceiptEnvelope, Receipt, ReceiptWithBloom, TxType}; -use alloy_primitives::*; +use alloy_consensus::{AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom, TxType}; +use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, B256, I256, U256, U64}; use alloy_rpc_types::{ AnyTransactionReceipt, Block, BlockTransactions, Log, Transaction, TransactionReceipt, }; @@ -17,7 +16,7 @@ const NAME_COLUMN_LEN: usize = 20usize; /// # Examples /// /// ``` -/// use foundry_common::fmt::UIfmt; +/// use foundry_common_fmt::UIfmt; /// /// let boolean: bool = true; /// let string = boolean.pretty(); @@ -147,8 +146,13 @@ impl UIfmt for [u8] { } } -pub fn pretty_status(status: bool) -> String { - if status { "1 (success)" } else { "0 (failed)" }.to_string() +impl UIfmt for Eip658Value { + fn pretty(&self) -> String { + match self { + Self::Eip658(status) => if *status { "1 (success)" } else { "0 (failed)" }.to_string(), + Self::PostState(state) => state.pretty(), + } + } } impl UIfmt for AnyTransactionReceipt { @@ -209,7 +213,7 @@ blobGasUsed {}", serde_json::to_string(&logs).unwrap(), logs_bloom.pretty(), state_root.pretty(), - pretty_status(status.coerce_status()), + status.pretty(), transaction_hash.pretty(), transaction_index.pretty(), transaction_type, @@ -333,21 +337,6 @@ value {}{}", } } -impl UIfmt for TransactionReceiptWithRevertReason { - fn pretty(&self) -> String { - if let Some(revert_reason) = &self.revert_reason { - format!( - "{} -revertReason {}", - self.receipt.pretty(), - revert_reason - ) - } else { - self.receipt.pretty() - } - } -} - /// Various numerical ethereum types used for pretty printing #[derive(Clone, Debug, Deserialize)] #[serde(untagged)] @@ -404,38 +393,6 @@ pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option Option { - match attr { - "blockHash" | "block_hash" => Some(receipt.receipt.block_hash.pretty()), - "blockNumber" | "block_number" => Some(receipt.receipt.block_number.pretty()), - "contractAddress" | "contract_address" => Some(receipt.receipt.contract_address.pretty()), - "cumulativeGasUsed" | "cumulative_gas_used" => { - Some(receipt.receipt.inner.inner.inner.receipt.cumulative_gas_used.pretty()) - } - "effectiveGasPrice" | "effective_gas_price" => { - Some(receipt.receipt.effective_gas_price.to_string()) - } - "gasUsed" | "gas_used" => Some(receipt.receipt.gas_used.to_string()), - "logs" => Some(receipt.receipt.inner.inner.inner.receipt.logs.as_slice().pretty()), - "logsBloom" | "logs_bloom" => Some(receipt.receipt.inner.inner.inner.logs_bloom.pretty()), - "root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root.pretty()), - "status" | "statusCode" | "status_code" => { - Some(pretty_status(receipt.receipt.inner.inner.inner.receipt.status.coerce_status())) - } - "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), - "transactionIndex" | "transaction_index" => { - Some(receipt.receipt.transaction_index.pretty()) - } - "type" | "transaction_type" => Some(receipt.receipt.inner.inner.r#type.to_string()), - "revertReason" | "revert_reason" => Some(receipt.revert_reason.pretty()), - _ => None, - } -} - /// Returns the `UiFmt::pretty()` formatted attribute of the given block pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option { match attr { diff --git a/crates/common/src/calc.rs b/crates/common/src/calc.rs index bde75635ce7fe..2d7d6fb9ebdc7 100644 --- a/crates/common/src/calc.rs +++ b/crates/common/src/calc.rs @@ -1,7 +1,5 @@ //! Commonly used calculations. -use alloy_primitives::{Sign, U256}; - /// Returns the mean of the slice. #[inline] pub fn mean(values: &[u64]) -> u64 { @@ -28,41 +26,6 @@ pub fn median_sorted(values: &[u64]) -> u64 { } } -/// Returns the number expressed as a string in exponential notation -/// with the given precision (number of significant figures), -/// optionally removing trailing zeros from the mantissa. -/// -/// Examples: -/// -/// ```text -/// precision = 4, trim_end_zeroes = false -/// 1234124124 -> 1.234e9 -/// 10000000 -> 1.000e7 -/// precision = 3, trim_end_zeroes = true -/// 1234124124 -> 1.23e9 -/// 10000000 -> 1e7 -/// ``` -#[inline] -pub fn to_exp_notation(value: U256, precision: usize, trim_end_zeros: bool, sign: Sign) -> String { - let stringified = value.to_string(); - let exponent = stringified.len() - 1; - let mut mantissa = stringified.chars().take(precision).collect::(); - - // optionally remove trailing zeros - if trim_end_zeros { - mantissa = mantissa.trim_end_matches('0').to_string(); - } - - // Place a decimal point only if needed - // e.g. 1234 -> 1.234e3 (needed) - // 5 -> 5 (not needed) - if mantissa.len() > 1 { - mantissa.insert(1, '.'); - } - - format!("{sign}{mantissa}e{exponent}") -} - #[cfg(test)] mod tests { use super::*; @@ -106,23 +69,4 @@ mod tests { let m = median_sorted(&values); assert_eq!(m, 45); } - - #[test] - fn test_format_to_exponential_notation() { - let value = 1234124124u64; - - let formatted = to_exp_notation(U256::from(value), 4, false, Sign::Positive); - assert_eq!(formatted, "1.234e9"); - - let formatted = to_exp_notation(U256::from(value), 3, true, Sign::Positive); - assert_eq!(formatted, "1.23e9"); - - let value = 10000000u64; - - let formatted = to_exp_notation(U256::from(value), 4, false, Sign::Positive); - assert_eq!(formatted, "1.000e7"); - - let formatted = to_exp_notation(U256::from(value), 3, true, Sign::Positive); - assert_eq!(formatted, "1e7"); - } } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 16071f2212cee..a33a7b2231565 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -11,6 +11,8 @@ extern crate self as foundry_common; #[macro_use] extern crate tracing; +pub use foundry_common_fmt as fmt; + pub mod abi; pub mod calc; pub mod compile; @@ -19,7 +21,6 @@ pub mod contracts; pub mod ens; pub mod errors; pub mod evm; -pub mod fmt; pub mod fs; pub mod provider; pub mod retry; diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 9a6ba190eca0d..2693c8ac249bc 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -5,6 +5,7 @@ use alloy_rpc_types::{AnyTransactionReceipt, BlockId}; use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::Result; +use foundry_common_fmt::UIfmt; use serde::{Deserialize, Serialize}; /// Helper type to carry a transaction along with an optional revert reason @@ -75,6 +76,21 @@ impl From for AnyTransactionReceipt { } } +impl UIfmt for TransactionReceiptWithRevertReason { + fn pretty(&self) -> String { + if let Some(revert_reason) = &self.revert_reason { + format!( + "{} +revertReason {}", + self.receipt.pretty(), + revert_reason + ) + } else { + self.receipt.pretty() + } + } +} + fn extract_revert_reason>(error_string: S) -> Option { let message_substr = "execution reverted: "; error_string @@ -83,6 +99,38 @@ fn extract_revert_reason>(error_string: S) -> Option { .map(|index| error_string.as_ref().split_at(index + message_substr.len()).1.to_string()) } +/// Returns the `UiFmt::pretty()` formatted attribute of the transaction receipt +pub fn get_pretty_tx_receipt_attr( + receipt: &TransactionReceiptWithRevertReason, + attr: &str, +) -> Option { + match attr { + "blockHash" | "block_hash" => Some(receipt.receipt.block_hash.pretty()), + "blockNumber" | "block_number" => Some(receipt.receipt.block_number.pretty()), + "contractAddress" | "contract_address" => Some(receipt.receipt.contract_address.pretty()), + "cumulativeGasUsed" | "cumulative_gas_used" => { + Some(receipt.receipt.inner.inner.inner.receipt.cumulative_gas_used.pretty()) + } + "effectiveGasPrice" | "effective_gas_price" => { + Some(receipt.receipt.effective_gas_price.to_string()) + } + "gasUsed" | "gas_used" => Some(receipt.receipt.gas_used.to_string()), + "logs" => Some(receipt.receipt.inner.inner.inner.receipt.logs.as_slice().pretty()), + "logsBloom" | "logs_bloom" => Some(receipt.receipt.inner.inner.inner.logs_bloom.pretty()), + "root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root.pretty()), + "status" | "statusCode" | "status_code" => { + Some(receipt.receipt.inner.inner.inner.receipt.status.pretty()) + } + "transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()), + "transactionIndex" | "transaction_index" => { + Some(receipt.receipt.transaction_index.pretty()) + } + "type" | "transaction_type" => Some(receipt.receipt.inner.inner.r#type.to_string()), + "revertReason" | "revert_reason" => Some(receipt.revert_reason.pretty()), + _ => None, + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/evm/abi/Cargo.toml b/crates/evm/abi/Cargo.toml new file mode 100644 index 0000000000000..892963acdc0dd --- /dev/null +++ b/crates/evm/abi/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "foundry-evm-abi" +description = "Solidity ABI-related utilities and `sol!` definitions" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[lints] +workspace = true + +[dependencies] +foundry-common-fmt.workspace = true +foundry-macros.workspace = true + +alloy-primitives.workspace = true +alloy-sol-types = { workspace = true, features = ["json"] } + +derive_more.workspace = true +itertools.workspace = true +once_cell.workspace = true +rustc-hash.workspace = true + +[dev-dependencies] +foundry-test-utils.workspace = true diff --git a/crates/evm/core/src/abi/HardhatConsole.json b/crates/evm/abi/src/HardhatConsole.json similarity index 100% rename from crates/evm/core/src/abi/HardhatConsole.json rename to crates/evm/abi/src/HardhatConsole.json diff --git a/crates/evm/core/src/abi/hardhat_console.rs b/crates/evm/abi/src/console/hardhat.rs similarity index 99% rename from crates/evm/core/src/abi/hardhat_console.rs rename to crates/evm/abi/src/console/hardhat.rs index 4b9aa3ba2a898..1e5f7c87ee0d3 100644 --- a/crates/evm/core/src/abi/hardhat_console.rs +++ b/crates/evm/abi/src/console/hardhat.rs @@ -1,14 +1,15 @@ use alloy_primitives::Selector; use alloy_sol_types::sol; +use foundry_common_fmt::*; use foundry_macros::ConsoleFmt; use once_cell::sync::Lazy; -use revm::primitives::HashMap; +use rustc_hash::FxHashMap; sol!( #[sol(abi)] #[derive(ConsoleFmt)] HardhatConsole, - "src/abi/HardhatConsole.json" + "src/HardhatConsole.json" ); /// Patches the given Hardhat `console` function selector to its ABI-normalized form. @@ -38,8 +39,8 @@ pub fn hh_console_selector(input: &[u8]) -> Option<&'static Selector> { /// `hardhat/console.log` logs its events manually, and in functions that accept integers they're /// encoded as `abi.encodeWithSignature("log(int)", p0)`, which is not the canonical ABI encoding /// for `int` that Solc (and [`sol!`]) uses. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { - HashMap::from([ +pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { + FxHashMap::from_iter([ // log(bool,uint256,uint256,address) ([241, 97, 178, 33], [0, 221, 135, 185]), // log(uint256,address,address,string) diff --git a/crates/evm/core/src/abi/console.rs b/crates/evm/abi/src/console/mod.rs similarity index 98% rename from crates/evm/core/src/abi/console.rs rename to crates/evm/abi/src/console/mod.rs index e9757a4768de8..3f10c769e7927 100644 --- a/crates/evm/core/src/abi/console.rs +++ b/crates/evm/abi/src/console/mod.rs @@ -3,6 +3,9 @@ use alloy_sol_types::sol; use derive_more::Display; use itertools::Itertools; +mod hardhat; +pub use hardhat::*; + // TODO: Use `UiFmt` sol! { diff --git a/crates/evm/abi/src/lib.rs b/crates/evm/abi/src/lib.rs new file mode 100644 index 0000000000000..6a31fe5509b22 --- /dev/null +++ b/crates/evm/abi/src/lib.rs @@ -0,0 +1,7 @@ +//! Solidity ABI-related utilities and [`sol!`](alloy_sol_types::sol) definitions. + +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + +mod console; +pub use console::*; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index d44f2cb4b0745..7369e55032fb3 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -17,7 +17,7 @@ workspace = true foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true foundry-config.workspace = true -foundry-macros.workspace = true +foundry-evm-abi.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } alloy-genesis.workspace = true @@ -49,12 +49,9 @@ revm-inspectors.workspace = true arrayvec.workspace = true auto_impl.workspace = true -derive_more.workspace = true eyre.workspace = true futures.workspace = true -hex.workspace = true itertools.workspace = true -once_cell.workspace = true parking_lot.workspace = true rustc-hash.workspace = true serde.workspace = true diff --git a/crates/evm/core/src/abi/mod.rs b/crates/evm/core/src/abi/mod.rs deleted file mode 100644 index 54f35c966af29..0000000000000 --- a/crates/evm/core/src/abi/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Several ABI-related utilities for executors. - -pub use foundry_cheatcodes_spec::Vm; - -mod console; -pub use console::{format_units_int, format_units_uint, Console}; - -mod hardhat_console; -pub use hardhat_console::{ - hh_console_selector, patch_hh_console_selector, HardhatConsole, - HARDHAT_CONSOLE_SELECTOR_PATCHES, -}; diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs index 21705f1289678..bde6e338c754e 100644 --- a/crates/evm/core/src/debug.rs +++ b/crates/evm/core/src/debug.rs @@ -1,5 +1,5 @@ use crate::opcodes; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{hex, Address, Bytes, U256}; use arrayvec::ArrayVec; use revm::interpreter::OpCode; use revm_inspectors::tracing::types::CallKind; diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index fa3d099ab5c5b..4a2fadb816cc9 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -3,7 +3,7 @@ use crate::abi::{Console, Vm}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::{Error, JsonAbi}; -use alloy_primitives::{Log, Selector}; +use alloy_primitives::{hex, Log, Selector}; use alloy_sol_types::{SolCall, SolError, SolEventInterface, SolInterface, SolValue}; use foundry_common::SELECTOR_LEN; use itertools::Itertools; diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index c2c2e200663d9..43bf5f3d4b311 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -12,9 +12,13 @@ use revm_inspectors::access_list::AccessListInspector; #[macro_use] extern crate tracing; +pub mod abi { + pub use foundry_cheatcodes_spec::Vm; + pub use foundry_evm_abi::*; +} + mod ic; -pub mod abi; pub mod backend; pub mod constants; pub mod debug; diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index b076db127821c..dfb3cbe7f7419 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -31,9 +31,8 @@ alloy-primitives = { workspace = true, features = [ alloy-sol-types.workspace = true revm-inspectors.workspace = true -eyre .workspace = true +eyre.workspace = true futures.workspace = true -hex.workspace = true itertools.workspace = true once_cell.workspace = true serde.workspace = true diff --git a/crates/evm/traces/src/decoder/precompiles.rs b/crates/evm/traces/src/decoder/precompiles.rs index 1475208f40c88..17c92ba6c1189 100644 --- a/crates/evm/traces/src/decoder/precompiles.rs +++ b/crates/evm/traces/src/decoder/precompiles.rs @@ -1,5 +1,5 @@ use crate::{CallTrace, DecodedCallData}; -use alloy_primitives::{B256, U256}; +use alloy_primitives::{hex, B256, U256}; use alloy_sol_types::{abi, sol, SolCall}; use itertools::Itertools; diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index cd69cf9475ad4..ff9ef0084d685 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -1,4 +1,5 @@ use alloy_json_abi::{Event, Function}; +use alloy_primitives::hex; use foundry_common::{ abi::{get_event, get_func}, fs, diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 840b9253b29ec..2803de3ca6779 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -8,7 +8,7 @@ #[macro_use] extern crate tracing; -use alloy_primitives::LogData; +use alloy_primitives::{hex, LogData}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_core::constants::CHEATCODE_ADDRESS; use futures::{future::BoxFuture, FutureExt}; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 89e71544ad6d6..93b15ed61d000 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -77,7 +77,6 @@ clap_complete_fig = "4" dialoguer = { version = "0.11", default-features = false } dunce.workspace = true futures.workspace = true -hex.workspace = true indicatif = "0.17" itertools.workspace = true once_cell.workspace = true diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 97f6383e31c7e..2a5f0b83e92a9 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -611,9 +611,9 @@ impl EtherscanClient for Client { #[cfg(test)] mod tests { use super::*; + use alloy_primitives::hex; use foundry_compilers::Artifact; use foundry_test_utils::rpc::next_etherscan_api_key; - use hex::ToHex; use std::collections::BTreeMap; fn assert_successful_compilation(root: &PathBuf) -> ProjectCompileOutput { @@ -631,9 +631,9 @@ mod tests { if name == contract_name { let compiled_creation_code = contract.get_bytecode_object().expect("creation code not found"); - let compiled_creation_code: String = compiled_creation_code.encode_hex(); assert!( - compiled_creation_code.starts_with(stripped_creation_code), + hex::encode(compiled_creation_code.as_ref()) + .starts_with(stripped_creation_code), "inconsistent creation code" ); } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 13ab69da6228e..62740cce9bfc2 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -2,7 +2,7 @@ use alloy_chains::Chain; use alloy_dyn_abi::{DynSolValue, JsonAbiExt, Specifier}; use alloy_json_abi::{Constructor, JsonAbi}; use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{hex, Address, Bytes}; use alloy_provider::{Provider, ProviderBuilder}; use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -363,7 +363,7 @@ impl CreateArgs { params.push((ty, arg)); } let params = params.iter().map(|(ty, arg)| (ty, arg.as_str())); - parse_tokens(params) + parse_tokens(params).map_err(Into::into) } } diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index d09b5cdfbe846..c1626e99fc7af 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -1,3 +1,4 @@ +use alloy_primitives::hex; use clap::Parser; use comfy_table::Table; use eyre::Result; diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 65f5f6ae81d44..b13f74799344b 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1,6 +1,7 @@ //! Contains various tests for checking forge's commands use crate::constants::*; +use alloy_primitives::hex; use foundry_compilers::artifacts::{remappings::Remapping, ConfigurableContractArtifact, Metadata}; use foundry_config::{ parse_with_profile, BasicConfig, Chain, Config, FuzzConfig, InvariantConfig, SolidityErrorCode, diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 0df24f88bf12e..a5c9b12b81afb 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -4,7 +4,7 @@ use crate::{ constants::*, utils::{self, EnvExternalities}, }; -use alloy_primitives::Address; +use alloy_primitives::{hex, Address}; use anvil::{spawn, NodeConfig}; use foundry_compilers::artifacts::{remappings::Remapping, BytecodeHash}; use foundry_config::Config; diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 61aff4db03acb..de3a3b544199c 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1,7 +1,7 @@ //! Contains various tests related to `forge script`. use crate::constants::TEMPLATE_CONTRACT; -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; use foundry_test_utils::{rpc, util::OutputExt, ScriptOutcome, ScriptTester}; use regex::Regex; diff --git a/crates/macros/src/console_fmt.rs b/crates/macros/src/console_fmt.rs index 3ee0077d97399..2522afb2c5b92 100644 --- a/crates/macros/src/console_fmt.rs +++ b/crates/macros/src/console_fmt.rs @@ -10,7 +10,7 @@ pub fn console_fmt(input: &DeriveInput) -> TokenStream { Data::Union(_) => return quote!(compile_error!("Unions are unsupported");), }; quote! { - impl ::foundry_common::fmt::ConsoleFmt for #name { + impl ConsoleFmt for #name { #tokens } } @@ -19,7 +19,7 @@ pub fn console_fmt(input: &DeriveInput) -> TokenStream { fn derive_struct(s: &DataStruct) -> TokenStream { let imp = impl_struct(s).unwrap_or_else(|| quote!(String::new())); quote! { - fn fmt(&self, _spec: ::foundry_common::fmt::FormatSpec) -> String { + fn fmt(&self, _spec: FormatSpec) -> String { #imp } } @@ -56,12 +56,12 @@ fn impl_struct(s: &DataStruct) -> Option { let first = args.next().unwrap(); let first = first.value(); quote! { - ::foundry_common::fmt::console_format((#first).as_str(), &[#(#args)*]) + console_format((#first).as_str(), &[#(#args)*]) } } else { // console_format("", [...args]) quote! { - ::foundry_common::fmt::console_format("", &[#args]) + console_format("", &[#args]) } }; @@ -92,12 +92,12 @@ fn derive_enum(e: &DataEnum) -> TokenStream { let field = fields.into_iter().next().unwrap(); let fields = Group::new(delimiter, quote!(#field)); quote! { - Self::#name #fields => ::foundry_common::fmt::ConsoleFmt::fmt(#field, spec), + Self::#name #fields => ConsoleFmt::fmt(#field, spec), } }); quote! { - fn fmt(&self, spec: ::foundry_common::fmt::FormatSpec) -> String { + fn fmt(&self, spec: FormatSpec) -> String { match self { #(#arms)* diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index a57a118174804..3ef1f6b68bcf2 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -24,7 +24,6 @@ foundry-cheatcodes.workspace = true foundry-wallets.workspace = true foundry-linking.workspace = true -hex.workspace = true serde.workspace = true eyre.workspace = true serde_json.workspace = true diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 087834dce9d52..9c75729ed453c 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -11,7 +11,7 @@ extern crate tracing; use self::transaction::AdditionalContract; use crate::runner::ScriptRunner; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Bytes, Log, TxKind, U256}; +use alloy_primitives::{hex, Address, Bytes, Log, TxKind, U256}; use alloy_signer::Signer; use broadcast::next_nonce; use build::PreprocessedState; diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 0eee959513c75..70128bdb44fec 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -3,7 +3,7 @@ use crate::{ transaction::{AdditionalContract, TransactionWithMetadata}, verify::VerifyBundle, }; -use alloy_primitives::{Address, TxHash}; +use alloy_primitives::{hex, Address, TxHash}; use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; use alloy_serde::WithOtherFields; use eyre::{ContextCompat, Result, WrapErr}; diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 84657ebf3296b..96f4bb2a26d42 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,6 +1,6 @@ use super::ScriptResult; use alloy_dyn_abi::JsonAbiExt; -use alloy_primitives::{Address, Bytes, TxKind, B256}; +use alloy_primitives::{hex, Address, Bytes, TxKind, B256}; use alloy_rpc_types::request::TransactionRequest; use alloy_serde::WithOtherFields; use eyre::{ContextCompat, Result, WrapErr}; diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 1e719fecf8b64..10c877ce6a419 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -1,6 +1,5 @@ use crate::{build::LinkedBuildData, sequence::ScriptSequenceKind, ScriptArgs, ScriptConfig}; - -use alloy_primitives::Address; +use alloy_primitives::{hex, Address}; use eyre::Result; use forge_verify::{RetryArgs, VerifierArgs, VerifyArgs}; use foundry_cli::opts::{EtherscanOpts, ProjectPathsArgs}; diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index f308381d4643c..02da2115775c6 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -19,7 +19,6 @@ foundry-cli.workspace = true foundry-common.workspace = true foundry-evm.workspace = true serde_json.workspace = true -hex.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-rpc-types.workspace = true diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index b0698d58b4fb7..1ef5d4b20faf6 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -1,6 +1,7 @@ use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; use crate::{provider::VerificationContext, retry::RETRY_CHECK_ON_VERIFY}; use alloy_json_abi::Function; +use alloy_primitives::hex; use alloy_provider::Provider; use eyre::{eyre, Context, OptionExt, Result}; use foundry_block_explorers::{ diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 183a978541df4..f0e3ddc11796f 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -41,7 +41,6 @@ async-trait.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } derive_builder = "0.20.0" eyre.workspace = true -hex = { workspace = true, features = ["serde"] } rpassword = "7" serde.workspace = true thiserror.workspace = true diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index 4e299b055606f..a5ee5ec1cf3f5 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -1,8 +1,8 @@ +use alloy_primitives::hex::FromHexError; use alloy_signer::k256::ecdsa; use alloy_signer_ledger::LedgerError; use alloy_signer_local::LocalSignerError; use alloy_signer_trezor::TrezorError; -use hex::FromHexError; #[cfg(feature = "aws-kms")] use alloy_signer_aws::AwsSignerError; diff --git a/crates/wallets/src/utils.rs b/crates/wallets/src/utils.rs index da19b6d9e3d2d..40f88b6d4af68 100644 --- a/crates/wallets/src/utils.rs +++ b/crates/wallets/src/utils.rs @@ -1,11 +1,10 @@ use crate::{error::PrivateKeyError, PendingSigner, WalletSigner}; -use alloy_primitives::B256; +use alloy_primitives::{hex::FromHex, B256}; use alloy_signer_ledger::HDPath as LedgerHDPath; use alloy_signer_local::PrivateKeySigner; use alloy_signer_trezor::HDPath as TrezorHDPath; use eyre::{Context, Result}; use foundry_config::Config; -use hex::FromHex; use std::{ fs, path::{Path, PathBuf}, diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index f1f7bad88b5eb..75441f6838b5b 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -2,7 +2,7 @@ use crate::error::WalletSignerError; use alloy_consensus::SignableTransaction; use alloy_dyn_abi::TypedData; use alloy_network::TxSigner; -use alloy_primitives::{Address, ChainId, B256}; +use alloy_primitives::{hex, Address, ChainId, B256}; use alloy_signer::{Signature, Signer}; use alloy_signer_ledger::{HDPath as LedgerHDPath, LedgerSigner}; use alloy_signer_local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner}; From c9046f17e3c99f163cf019afecbb903c5f5750a5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:53:15 +0200 Subject: [PATCH 1150/1963] feat: add feature to enable tracy (#8247) --- Cargo.lock | 98 ++++++++++++++++++++++++++++++++++++- crates/cli/Cargo.toml | 4 ++ crates/cli/src/utils/mod.rs | 9 ++-- 3 files changed, 105 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdaefa35d2e0c..06ece26b7e83a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3617,6 +3617,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "tracing-tracy", "yansi", ] @@ -4246,6 +4247,20 @@ dependencies = [ "url", ] +[[package]] +name = "generator" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186014d53bc231d0090ef8d6f03e0920c54d85a5ed22f4f2f74315ec56cf83fb" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows 0.54.0", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -4452,7 +4467,7 @@ dependencies = [ "bitflags 2.5.0", "gix-path", "libc", - "windows", + "windows 0.48.0", ] [[package]] @@ -4883,7 +4898,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -5354,6 +5369,19 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + [[package]] name = "lru" version = "0.12.3" @@ -7442,6 +7470,12 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -8715,6 +8749,37 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "tracing-tracy" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6024d04f84a69fd0d1dc1eee3a2b070bd246530a0582f9982ae487cb6c703614" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracy-client", +] + +[[package]] +name = "tracy-client" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59fb931a64ff88984f86d3e9bcd1ae8843aa7fe44dd0f8097527bc172351741d" +dependencies = [ + "loom", + "once_cell", + "tracy-client-sys", +] + +[[package]] +name = "tracy-client-sys" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d104d610dfa9dd154535102cc9c6164ae1fa37842bc2d9e83f9ac82b0ae0882" +dependencies = [ + "cc", +] + [[package]] name = "trezor-client" version = "0.1.3" @@ -9207,6 +9272,16 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core 0.54.0", + "windows-targets 0.52.5", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -9216,6 +9291,25 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-sys" version = "0.45.0" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index d8ca1f53da9ef..9c8b3fab80b9a 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -45,6 +45,8 @@ tracing-subscriber = { workspace = true, features = ["registry", "env-filter"] } tracing.workspace = true yansi.workspace = true +tracing-tracy = { version = "0.11", optional = true } + [dev-dependencies] tempfile.workspace = true @@ -52,3 +54,5 @@ tempfile.workspace = true default = ["rustls"] rustls = ["foundry-wallets/rustls"] openssl = ["foundry-compilers/openssl"] + +tracy = ["dep:tracing-tracy"] diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index a42c30553c804..15864b016504d 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -67,10 +67,11 @@ impl> FoundryPathExt for T { /// Initializes a tracing Subscriber for logging pub fn subscriber() { - tracing_subscriber::Registry::default() - .with(tracing_subscriber::EnvFilter::from_default_env()) - .with(tracing_subscriber::fmt::layer()) - .init() + let registry = tracing_subscriber::Registry::default() + .with(tracing_subscriber::EnvFilter::from_default_env()); + #[cfg(feature = "tracy")] + let registry = registry.with(tracing_tracy::TracyLayer::default()); + registry.with(tracing_subscriber::fmt::layer()).init() } pub fn abi_to_solidity(abi: &JsonAbi, name: &str) -> Result { From 32f01e3003bc4a98691282c5a03661214e3f5645 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:46:07 +0200 Subject: [PATCH 1151/1963] chore: clean up ds-test failure related code (#8244) * feat: add feature to enable tracy * perf: add more early returns in is_success logic * try * readd snapshot check * update * com * docs * clean * chore: remove extra checks * fix --- crates/evm/core/src/backend/mod.rs | 108 +++++----------------------- crates/evm/evm/src/executors/mod.rs | 78 ++++++++++++-------- 2 files changed, 65 insertions(+), 121 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index a59bcdc5b01a7..1185b0d6f3ef3 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -8,7 +8,7 @@ use crate::{ InspectorExt, }; use alloy_genesis::GenesisAccount; -use alloy_primitives::{b256, keccak256, Address, B256, U256}; +use alloy_primitives::{keccak256, uint, Address, B256, U256}; use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; use alloy_serde::WithOtherFields; use eyre::Context; @@ -59,10 +59,12 @@ type ForkLookupIndex = usize; const DEFAULT_PERSISTENT_ACCOUNTS: [Address; 3] = [CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, CALLER]; -/// Slot corresponding to "failed" in bytes on the cheatcodes (HEVM) address. -/// Not prefixed with 0x. -const GLOBAL_FAILURE_SLOT: B256 = - b256!("6661696c65640000000000000000000000000000000000000000000000000000"); +/// `bytes32("failed")`, as a storage slot key into [`CHEATCODE_ADDRESS`]. +/// +/// Used by all `forge-std` test contracts and newer `DSTest` test contracts as a global marker for +/// a failed test. +pub const GLOBAL_FAIL_SLOT: U256 = + uint!(0x6661696c65640000000000000000000000000000000000000000000000000000_U256); /// An extension trait that allows us to easily extend the `revm::Inspector` capabilities #[auto_impl::auto_impl(&mut)] @@ -537,10 +539,8 @@ impl Backend { /// This will also grant cheatcode access to the test account pub fn set_test_contract(&mut self, acc: Address) -> &mut Self { trace!(?acc, "setting test account"); - self.add_persistent_account(acc); self.allow_cheatcode_access(acc); - self.inner.test_contract_address = Some(acc); self } @@ -559,11 +559,6 @@ impl Backend { self } - /// Returns the address of the set `DSTest` contract - pub fn test_contract_address(&self) -> Option
{ - self.inner.test_contract_address - } - /// Returns the set caller address pub fn caller_address(&self) -> Option
{ self.inner.caller @@ -583,80 +578,12 @@ impl Backend { self.inner.has_snapshot_failure = has_snapshot_failure } - /// Checks if the test contract associated with this backend failed, See - /// [Self::is_failed_test_contract] - pub fn is_failed(&self) -> bool { - self.has_snapshot_failure() || - self.test_contract_address() - .map(|addr| self.is_failed_test_contract(addr)) - .unwrap_or_default() - } - - /// Checks if the given test function failed - /// - /// DSTest will not revert inside its `assertEq`-like functions which allows - /// to test multiple assertions in 1 test function while also preserving logs. - /// Instead, it stores whether an `assert` failed in a boolean variable that we can read - pub fn is_failed_test_contract(&self, address: Address) -> bool { - /* - contract DSTest { - bool public IS_TEST = true; - // slot 0 offset 1 => second byte of slot0 - bool private _failed; - } - */ - let value = self.storage_ref(address, U256::ZERO).unwrap_or_default(); - value.as_le_bytes()[1] != 0 - } - - /// Checks if the given test function failed by looking at the present value of the test - /// contract's `JournaledState` - /// - /// See [`Self::is_failed_test_contract()]` - /// - /// Note: we assume the test contract is either `forge-std/Test` or `DSTest` - pub fn is_failed_test_contract_state( - &self, - address: Address, - current_state: &JournaledState, - ) -> bool { - if let Some(account) = current_state.state.get(&address) { - let value = account - .storage - .get(&revm::primitives::U256::ZERO) - .cloned() - .unwrap_or_default() - .present_value(); - return value.as_le_bytes()[1] != 0; - } - - false - } - - /// In addition to the `_failed` variable, `DSTest::fail()` stores a failure - /// in "failed" - /// See - pub fn is_global_failure(&self, current_state: &JournaledState) -> bool { - if let Some(account) = current_state.state.get(&CHEATCODE_ADDRESS) { - let slot: U256 = GLOBAL_FAILURE_SLOT.into(); - let value = account.storage.get(&slot).cloned().unwrap_or_default().present_value(); - return value == revm::primitives::U256::from(1); - } - - false - } - /// When creating or switching forks, we update the AccountInfo of the contract pub(crate) fn update_fork_db( &self, active_journaled_state: &mut JournaledState, target_fork: &mut Fork, ) { - debug_assert!( - self.inner.test_contract_address.is_some(), - "Test contract address must be set" - ); - self.update_fork_db_contracts( self.inner.persistent_accounts.iter().copied(), active_journaled_state, @@ -973,10 +900,17 @@ impl DatabaseExt for Backend { if action.is_keep() { self.inner.snapshots.insert_at(snapshot.clone(), id); } - // need to check whether there's a global failure which means an error occurred either - // during the snapshot or even before - if self.is_global_failure(current_state) { - self.set_snapshot_failure(true); + + // https://github.com/foundry-rs/foundry/issues/3055 + // Check if an error occurred either during or before the snapshot. + // DSTest contracts don't have snapshot functionality, so this slot is enough to check + // for failure here. + if let Some(account) = current_state.state.get(&CHEATCODE_ADDRESS) { + if let Some(slot) = account.storage.get(&GLOBAL_FAIL_SLOT) { + if !slot.present_value.is_zero() { + self.set_snapshot_failure(true); + } + } } // merge additional logs @@ -1585,11 +1519,6 @@ pub struct BackendInner { /// check if the `_failed` variable is set, /// additionally pub has_snapshot_failure: bool, - /// Tracks the address of a Test contract - /// - /// This address can be used to inspect the state of the contract when a test is being - /// executed. E.g. the `_failed` variable of `DSTest` - pub test_contract_address: Option
, /// Tracks the caller of the test function pub caller: Option
, /// Tracks numeric identifiers for forks @@ -1778,7 +1707,6 @@ impl Default for BackendInner { forks: vec![], snapshots: Default::default(), has_snapshot_failure: false, - test_contract_address: None, caller: None, next_fork_id: Default::default(), persistent_accounts: Default::default(), diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 2114eb515d4ad..ff621a5e20f9b 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -14,7 +14,7 @@ use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log, U256}; use alloy_sol_types::{sol, SolCall}; use foundry_evm_core::{ - backend::{Backend, CowBackend, DatabaseError, DatabaseExt, DatabaseResult}, + backend::{Backend, CowBackend, DatabaseError, DatabaseExt, DatabaseResult, GLOBAL_FAIL_SLOT}, constants::{ CALLER, CHEATCODE_ADDRESS, CHEATCODE_CONTRACT_HASH, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, @@ -434,7 +434,7 @@ impl Executor { self.inspector_mut().set_env(&result.env); } - /// Checks if a call to a test contract was successful. + /// Returns `true` if a test can be considered successful. /// /// This is the same as [`Self::is_success`], but will consume the `state_changeset` map to use /// internally when calling `failed()`. @@ -452,20 +452,9 @@ impl Executor { ) } - /// Checks if a call to a test contract was successful. + /// Returns `true` if a test can be considered successful. /// - /// This is the same as [`Self::is_success`] but intended for outcomes of [`Self::call_raw`]. - /// - /// ## Background - /// - /// Executing and failure checking `Executor::is_success` are two steps, for ds-test - /// legacy reasons failures can be stored in a global variables and needs to be called via a - /// solidity call `failed()(bool)`. - /// - /// Snapshots make this task more complicated because now we also need to keep track of that - /// global variable when we revert to a snapshot (because it is stored in state). Now, the - /// problem is that the `CowBackend` is dropped after every call, so we need to keep track - /// of the snapshot failure in the [`RawCallResult`] instead. + /// This is the same as [`Self::is_success`], but intended for outcomes of [`Self::call_raw`]. pub fn is_raw_call_success( &self, address: Address, @@ -480,21 +469,27 @@ impl Executor { self.is_success(address, call_result.reverted, state_changeset, should_fail) } - /// Check if a call to a test contract was successful. + /// Returns `true` if a test can be considered successful. /// - /// This function checks both the VM status of the call, DSTest's `failed` status and the - /// `globalFailed` flag which is stored in `failed` inside the `CHEATCODE_ADDRESS` contract. + /// If the call succeeded, we also have to check the global and local failure flags. /// - /// DSTest will not revert inside its `assertEq`-like functions which allows - /// to test multiple assertions in 1 test function while also preserving logs. + /// These are set by the test contract itself when an assertion fails, using the internal `fail` + /// function. The global flag is located in [`CHEATCODE_ADDRESS`] at slot [`GLOBAL_FAIL_SLOT`], + /// and the local flag is located in the test contract at an unspecified slot. /// - /// If an `assert` is violated, the contract's `failed` variable is set to true, and the - /// `globalFailure` flag inside the `CHEATCODE_ADDRESS` is also set to true, this way, failing - /// asserts from any contract are tracked as well. + /// This behavior is inherited from Dapptools, where initially only a public + /// `failed` variable was used to track test failures, and later, a global failure flag was + /// introduced to track failures across multiple contracts in + /// [ds-test#30](https://github.com/dapphub/ds-test/pull/30). /// - /// In order to check whether a test failed, we therefore need to evaluate the contract's - /// `failed` variable and the `globalFailure` flag, which happens by calling - /// `contract.failed()`. + /// The assumption is that the test runner calls `failed` on the test contract to determine if + /// it failed. However, we want to avoid this as much as possible, as it is relatively + /// expensive to set up an EVM call just for checking a single boolean flag. + /// + /// See: + /// - Newer DSTest: + /// - Older DSTest: + /// - forge-std: pub fn is_success( &self, address: Address, @@ -513,13 +508,34 @@ impl Executor { reverted: bool, state_changeset: Cow<'_, StateChangeset>, ) -> bool { + // The call reverted. + if reverted { + return false; + } + + // A failure occurred in a reverted snapshot, which is considered a failed test. if self.backend().has_snapshot_failure() { - // a failure occurred in a reverted snapshot, which is considered a failed test return false; } - let mut success = !reverted; - if success { + // Check the global failure slot. + // TODO: Wire this up + let legacy = true; + if !legacy { + if let Some(acc) = state_changeset.get(&CHEATCODE_ADDRESS) { + if let Some(failed_slot) = acc.storage.get(&GLOBAL_FAIL_SLOT) { + return failed_slot.present_value().is_zero(); + } + } + let Ok(failed_slot) = self.backend().storage_ref(CHEATCODE_ADDRESS, GLOBAL_FAIL_SLOT) + else { + return false; + }; + return failed_slot.is_zero(); + } + + // Finally, resort to calling `DSTest::failed`. + { // Construct a new bare-bones backend to evaluate success. let mut backend = self.backend().clone_empty(); @@ -542,14 +558,14 @@ impl Executor { match call { Ok(CallResult { raw: _, decoded_result: ITest::failedReturn { failed } }) => { trace!(failed, "DSTest::failed()"); - success = !failed; + !failed } Err(err) => { trace!(%err, "failed to call DSTest::failed()"); + true } } } - success } /// Creates the environment to use when executing a transaction in a test context From 764fae6d770186cf3ad424262619926983ec840b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 25 Jun 2024 23:39:35 +0800 Subject: [PATCH 1152/1963] fix(invariant): do not continue test runs if invariant fails (#8253) --- crates/evm/evm/src/executors/invariant/mod.rs | 3 ++- crates/evm/evm/src/executors/invariant/result.rs | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 91d9028da599d..212171f67a66c 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -370,8 +370,9 @@ impl<'a> InvariantExecutor<'a> { invariant_test.set_last_run_inputs(¤t_run.inputs); } + // If test cannot continue then stop current run and exit test suite. if !result.can_continue { - break + return Err(TestCaseError::fail("Test cannot continue.")) } invariant_test.set_last_call_results(result.call_result); diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index 9e773445549b5..aba35147631a5 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -86,9 +86,8 @@ pub(crate) fn assert_invariants( Ok(Some(call_result)) } -/// Verifies that the invariant run execution can continue. -/// Returns the mapping of (Invariant Function Name -> Call Result, Logs, Traces) if invariants were -/// asserted. +/// Returns if invariant test can continue and last successful call result of the invariant test +/// function (if it can continue). pub(crate) fn can_continue( invariant_contract: &InvariantContract<'_>, invariant_test: &InvariantTest, From 374a6453bd37d839ce530c705a21e1572572c1fa Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 25 Jun 2024 23:47:38 +0800 Subject: [PATCH 1153/1963] fix(invariant): exit early if invariant fails in initial state (#8252) --- .../evm/evm/src/executors/invariant/error.rs | 2 - crates/evm/evm/src/executors/invariant/mod.rs | 7 ++- crates/forge/tests/cli/test_cmd.rs | 46 +++++++++++++++++-- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index 7c47ac0a47c6b..b8cff9b1d3c4b 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -11,8 +11,6 @@ use proptest::test_runner::TestError; pub struct InvariantFailures { /// Total number of reverts. pub reverts: usize, - /// How many different invariants have been broken. - pub broken_invariants_count: usize, /// The latest revert reason of a run. pub revert_reason: Option, /// Maps a broken invariant to its specific error. diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 212171f67a66c..88590a96155f9 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -158,7 +158,7 @@ impl InvariantTest { /// Whether invariant test has errors or not. pub fn has_errors(&self) -> bool { - self.execution_data.borrow().failures.error.is_none() + self.execution_data.borrow().failures.error.is_some() } /// Set invariant test error. @@ -390,7 +390,7 @@ impl<'a> InvariantExecutor<'a> { } // Call `afterInvariant` only if it is declared and test didn't fail already. - if invariant_contract.call_after_invariant && invariant_test.has_errors() { + if invariant_contract.call_after_invariant && !invariant_test.has_errors() { assert_after_invariant( &invariant_contract, &invariant_test, @@ -486,6 +486,9 @@ impl<'a> InvariantExecutor<'a> { &[], &mut failures, )?; + if let Some(error) = failures.error { + return Err(eyre!(error.revert_reason().unwrap_or_default())) + } Ok(( InvariantTest::new( diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 92d284720b4b7..52584ab4402c9 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -589,10 +589,50 @@ contract CounterTest is Test { cmd.args(["test"]); let (stderr, _) = cmd.unchecked_output_lossy(); + // make sure there are only 61 runs (with proptest shrinking same test results in 298 runs) + assert_eq!(extract_number_of_runs(stderr), 61); +}); + +forgetest_init!(should_exit_early_on_invariant_failure, |prj, cmd| { + prj.wipe_contracts(); + prj.add_test( + "CounterInvariant.t.sol", + r#"pragma solidity 0.8.24; +import {Test} from "forge-std/Test.sol"; + +contract Counter { + uint256 public number = 0; + + function inc() external { + number += 1; + } +} + +contract CounterTest is Test { + Counter public counter; + + function setUp() public { + counter = new Counter(); + } + + function invariant_early_exit() public view { + assertTrue(counter.number() == 10, "wrong count"); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]); + let (stderr, _) = cmd.unchecked_output_lossy(); + // make sure invariant test exit early with 0 runs + assert_eq!(extract_number_of_runs(stderr), 0); +}); + +fn extract_number_of_runs(stderr: String) -> usize { let runs = stderr.find("runs:").and_then(|start_runs| { let runs_split = &stderr[start_runs + 6..]; runs_split.find(',').map(|end_runs| &runs_split[..end_runs]) }); - // make sure there are only 61 runs (with proptest shrinking same test results in 298 runs) - assert_eq!(runs.unwrap().parse::().unwrap(), 61); -}); + runs.unwrap().parse::().unwrap() +} From 7bef9caccfe62761225be66e84bea2810e656c96 Mon Sep 17 00:00:00 2001 From: HuyHuynh <63286199+huyhuynh3103@users.noreply.github.com> Date: Wed, 26 Jun 2024 03:04:41 +0700 Subject: [PATCH 1154/1963] Fix: Check empty input bytecode in `find_by_deployed_code_exact` (#8257) * fix: find by deployed code extract * chore: add unit test * chore: minor refactor --- crates/common/src/contracts.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index aeaec4652b381..f56ee9b7a8f0d 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -147,6 +147,11 @@ impl ContractsByArtifact { /// Finds a contract which deployed bytecode exactly matches the given code. Accounts for link /// references and immutables. pub fn find_by_deployed_code_exact(&self, code: &[u8]) -> Option> { + // Immediately return None if the code is empty. + if code.is_empty() { + return None; + } + self.iter().find(|(_, contract)| { let Some(deployed_bytecode) = &contract.deployed_bytecode else { return false; @@ -403,4 +408,11 @@ mod tests { let a_99 = &b"a".repeat(99)[..]; assert!(bytecode_diff_score(a_100, a_99) <= 0.01); } + + #[test] + fn find_by_deployed_code_exact_with_empty_deployed() { + let contracts = ContractsByArtifact::new(vec![]); + + assert!(contracts.find_by_deployed_code_exact(&[]).is_none()); + } } From fbd225194dff17352ba740cb3d6f2ad082030dd1 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 26 Jun 2024 13:02:57 +0400 Subject: [PATCH 1155/1963] refactor: reduce code duplication for assertion cheats and introduce `legacy_assertions` flag (#8251) * wip * refactor: reduce code duplication for assertion cheatcodes + legacy_assertions config option * fix * fix --- crates/cheatcodes/src/config.rs | 4 + crates/cheatcodes/src/test/assert.rs | 1012 ++++++-------------------- crates/config/src/lib.rs | 4 + crates/forge/tests/cli/config.rs | 1 + 4 files changed, 215 insertions(+), 806 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 5be433688aa1f..359dec34a3002 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -52,6 +52,8 @@ pub struct CheatsConfig { pub available_artifacts: Option, /// Version of the script/test contract which is currently running. pub running_version: Option, + /// Whether to enable legacy (non-reverting) assertions. + pub legacy_assertions: bool, } impl CheatsConfig { @@ -90,6 +92,7 @@ impl CheatsConfig { script_wallets, available_artifacts, running_version, + legacy_assertions: config.legacy_assertions, } } @@ -217,6 +220,7 @@ impl Default for CheatsConfig { script_wallets: None, available_artifacts: Default::default(), running_version: Default::default(), + legacy_assertions: Default::default(), } } } diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index 4d4a779c78f19..fe9f3b39b51f1 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -1,4 +1,4 @@ -use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use crate::{Cheatcodes, Result, Vm::*}; use alloy_primitives::{hex, I256, U256}; use foundry_evm_core::abi::{format_units_int, format_units_uint}; use itertools::Itertools; @@ -165,871 +165,271 @@ impl EqRelAssertionError { type ComparisonResult<'a, T> = Result, ComparisonAssertionError<'a, T>>; -impl Cheatcode for assertTrue_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_true(self.condition).map_err(|e| e.to_string())?) - } -} - -impl Cheatcode for assertTrue_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_true(self.condition).map_err(|_| self.error.to_string())?) - } -} - -impl Cheatcode for assertFalse_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_false(self.condition).map_err(|e| e.to_string())?) - } -} - -impl Cheatcode for assertFalse_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_false(self.condition).map_err(|_| self.error.to_string())?) - } -} - -impl Cheatcode for assertEq_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_4Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_5Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_6Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_7Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_8Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_9Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_10Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_11Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_12Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_13Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertEq_14Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_15Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_16Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_17Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_18Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_19Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_20Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_21Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_22Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_23Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_24Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_25Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_eq(left, right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_26Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - let left = left.iter().map(hex::encode_prefixed).collect::>(); - let right = right.iter().map(hex::encode_prefixed).collect::>(); - Ok(assert_eq(&left, &right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEq_27Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - let left = left.iter().map(hex::encode_prefixed).collect::>(); - let right = right.iter().map(hex::encode_prefixed).collect::>(); - Ok(assert_eq(&left, &right).map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertEqDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_eq(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertEqDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_eq(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertEqDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_eq(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertEqDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_eq(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertNotEq_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_4Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_5Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_6Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_7Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_8Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_9Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_10Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_11Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_12Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_13Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)) - .map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertNotEq_14Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_15Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_16Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_17Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_18Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_19Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_20Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_21Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_22Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_23Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_24Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_25Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_not_eq(left, right) - .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_26Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - let left = left.iter().map(hex::encode_prefixed).collect::>(); - let right = right.iter().map(hex::encode_prefixed).collect::>(); - Ok(assert_not_eq(&left, &right) - .map_err(|e| format!("assertion failed: {}", e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEq_27Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - let left = left.iter().map(hex::encode_prefixed).collect::>(); - let right = right.iter().map(hex::encode_prefixed).collect::>(); - Ok(assert_not_eq(&left, &right) - .map_err(|e| format!("{}: {}", error, e.format_for_arrays()))?) - } -} - -impl Cheatcode for assertNotEqDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_not_eq(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertNotEqDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_not_eq(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertNotEqDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_not_eq(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertNotEqDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_not_eq(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGt_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_gt(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertGt_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_gt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertGt_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_gt(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertGt_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_gt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertGtDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_gt(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGtDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_gt(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGtDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_gt(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGtDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_gt(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGe_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_ge(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertGe_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_ge(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertGe_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_ge(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertGe_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_ge(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } -} - -impl Cheatcode for assertGeDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_ge(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGeDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_ge(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGeDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_ge(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertGeDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_ge(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } -} - -impl Cheatcode for assertLt_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_lt(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} - -impl Cheatcode for assertLt_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_lt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) +fn handle_assertion_result( + result: core::result::Result, E>, + state: &mut Cheatcodes, + error_formatter: impl Fn(&E) -> String, + error_msg: Option<&str>, + format_error: bool, +) -> Result { + match result { + Ok(_) => Ok(Default::default()), + Err(err) => { + let error_msg = error_msg.unwrap_or("assertion failed").to_string(); + let msg = if format_error { + format!("{error_msg}: {}", error_formatter(&err)) + } else { + error_msg + }; + if !state.config.legacy_assertions { + Err(msg.into()) + } else { + Ok(Default::default()) + } + } } } -impl Cheatcode for assertLt_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_lt(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } -} +/// Implements [crate::Cheatcode] for pairs of cheatcodes. +/// +/// Accepts a list of pairs of cheatcodes, where the first cheatcode is the one that doesn't contain +/// a custom error message, and the second one contains it at `error` field. +/// +/// Passed `args` are the common arguments for both cheatcode structs (excluding `error` field). +/// +/// Macro also accepts an optional closure that formats the error returned by the assertion. +macro_rules! impl_assertions { + (|$($arg:ident),*| $body:expr, $format_error:literal, $(($no_error:ident, $with_error:ident)),* $(,)?) => { + impl_assertions!(@args_tt |($($arg),*)| $body, |e| e.to_string(), $format_error, $(($no_error, $with_error),)*); + }; + (|$($arg:ident),*| $body:expr, $(($no_error:ident, $with_error:ident)),* $(,)?) => { + impl_assertions!(@args_tt |($($arg),*)| $body, |e| e.to_string(), true, $(($no_error, $with_error),)*); + }; + (|$($arg:ident),*| $body:expr, $error_formatter:expr, $(($no_error:ident, $with_error:ident)),* $(,)?) => { + impl_assertions!(@args_tt |($($arg),*)| $body, $error_formatter, true, $(($no_error, $with_error)),*); + }; + // We convert args to `tt` and later expand them back into tuple to allow usage of expanded args inside of + // each assertion type context. + (@args_tt |$args:tt| $body:expr, $error_formatter:expr, $format_error:literal, $(($no_error:ident, $with_error:ident)),* $(,)?) => { + $( + impl_assertions!(@impl $no_error, $with_error, $args, $body, $error_formatter, $format_error); + )* + }; + (@impl $no_error:ident, $with_error:ident, ($($arg:ident),*), $body:expr, $error_formatter:expr, $format_error:literal) => { + impl crate::Cheatcode for $no_error { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { $($arg),* } = self; + handle_assertion_result($body, state, $error_formatter, None, $format_error) + } + } -impl Cheatcode for assertLt_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_lt(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } + impl crate::Cheatcode for $with_error { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { $($arg),*, error} = self; + handle_assertion_result($body, state, $error_formatter, Some(error), $format_error) + } + } + }; } -impl Cheatcode for assertLtDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_lt(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |condition| assert_true(*condition), + false, + (assertTrue_0Call, assertTrue_1Call), } -impl Cheatcode for assertLtDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_lt(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |condition| assert_false(*condition), + false, + (assertFalse_0Call, assertFalse_1Call), } -impl Cheatcode for assertLtDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_lt(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right| assert_eq(left, right), + |e| e.format_for_values(), + (assertEq_0Call, assertEq_1Call), + (assertEq_2Call, assertEq_3Call), + (assertEq_4Call, assertEq_5Call), + (assertEq_6Call, assertEq_7Call), + (assertEq_8Call, assertEq_9Call), + (assertEq_10Call, assertEq_11Call), } -impl Cheatcode for assertLtDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_lt(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right| assert_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)), + |e| e.format_for_values(), + (assertEq_12Call, assertEq_13Call), } -impl Cheatcode for assertLe_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_le(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } +impl_assertions! { + |left, right| assert_eq(left, right), + |e| e.format_for_arrays(), + (assertEq_14Call, assertEq_15Call), + (assertEq_16Call, assertEq_17Call), + (assertEq_18Call, assertEq_19Call), + (assertEq_20Call, assertEq_21Call), + (assertEq_22Call, assertEq_23Call), + (assertEq_24Call, assertEq_25Call), } -impl Cheatcode for assertLe_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_le(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } +impl_assertions! { + |left, right| assert_eq( + &left.iter().map(hex::encode_prefixed).collect::>(), + &right.iter().map(hex::encode_prefixed).collect::>(), + ), + |e| e.format_for_arrays(), + (assertEq_26Call, assertEq_27Call), } -impl Cheatcode for assertLe_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right } = self; - Ok(assert_le(left, right) - .map_err(|e| format!("assertion failed: {}", e.format_for_values()))?) - } +impl_assertions! { + |left, right, decimals| assert_eq(left, right), + |e| e.format_with_decimals(decimals), + (assertEqDecimal_0Call, assertEqDecimal_1Call), + (assertEqDecimal_2Call, assertEqDecimal_3Call), } -impl Cheatcode for assertLe_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { left, right, error } = self; - Ok(assert_le(left, right).map_err(|e| format!("{}: {}", error, e.format_for_values()))?) - } +impl_assertions! { + |left, right| assert_not_eq(left, right), + |e| e.format_for_values(), + (assertNotEq_0Call, assertNotEq_1Call), + (assertNotEq_2Call, assertNotEq_3Call), + (assertNotEq_4Call, assertNotEq_5Call), + (assertNotEq_6Call, assertNotEq_7Call), + (assertNotEq_8Call, assertNotEq_9Call), + (assertNotEq_10Call, assertNotEq_11Call), } -impl Cheatcode for assertLeDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_le(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right| assert_not_eq(&hex::encode_prefixed(left), &hex::encode_prefixed(right)), + |e| e.format_for_values(), + (assertNotEq_12Call, assertNotEq_13Call), } -impl Cheatcode for assertLeDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_le(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right| assert_not_eq(left, right), + |e| e.format_for_arrays(), + (assertNotEq_14Call, assertNotEq_15Call), + (assertNotEq_16Call, assertNotEq_17Call), + (assertNotEq_18Call, assertNotEq_19Call), + (assertNotEq_20Call, assertNotEq_21Call), + (assertNotEq_22Call, assertNotEq_23Call), + (assertNotEq_24Call, assertNotEq_25Call), } -impl Cheatcode for assertLeDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_le(&self.left, &self.right) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right| assert_not_eq( + &left.iter().map(hex::encode_prefixed).collect::>(), + &right.iter().map(hex::encode_prefixed).collect::>(), + ), + |e| e.format_for_arrays(), + (assertNotEq_26Call, assertNotEq_27Call), } -impl Cheatcode for assertLeDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(assert_le(&self.left, &self.right) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right, decimals| assert_not_eq(left, right), + |e| e.format_with_decimals(decimals), + (assertNotEqDecimal_0Call, assertNotEqDecimal_1Call), + (assertNotEqDecimal_2Call, assertNotEqDecimal_3Call), } -impl Cheatcode for assertApproxEqAbs_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("assertion failed: {e}"))?) - } +impl_assertions! { + |left, right| assert_gt(left, right), + |e| e.format_for_values(), + (assertGt_0Call, assertGt_1Call), + (assertGt_2Call, assertGt_3Call), } -impl Cheatcode for assertApproxEqAbs_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("{}: {}", self.error, e))?) - } +impl_assertions! { + |left, right, decimals| assert_gt(left, right), + |e| e.format_with_decimals(decimals), + (assertGtDecimal_0Call, assertGtDecimal_1Call), + (assertGtDecimal_2Call, assertGtDecimal_3Call), } -impl Cheatcode for assertApproxEqAbs_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("assertion failed: {e}"))?) - } +impl_assertions! { + |left, right| assert_ge(left, right), + |e| e.format_for_values(), + (assertGe_0Call, assertGe_1Call), + (assertGe_2Call, assertGe_3Call), } -impl Cheatcode for assertApproxEqAbs_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("{}: {}", self.error, e))?) - } +impl_assertions! { + |left, right, decimals| assert_ge(left, right), + |e| e.format_with_decimals(decimals), + (assertGeDecimal_0Call, assertGeDecimal_1Call), + (assertGeDecimal_2Call, assertGeDecimal_3Call), } -impl Cheatcode for assertApproxEqAbsDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right| assert_lt(left, right), + |e| e.format_for_values(), + (assertLt_0Call, assertLt_1Call), + (assertLt_2Call, assertLt_3Call), } -impl Cheatcode for assertApproxEqAbsDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right, decimals| assert_lt(left, right), + |e| e.format_with_decimals(decimals), + (assertLtDecimal_0Call, assertLtDecimal_1Call), + (assertLtDecimal_2Call, assertLtDecimal_3Call), } -impl Cheatcode for assertApproxEqAbsDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right| assert_le(left, right), + |e| e.format_for_values(), + (assertLe_0Call, assertLe_1Call), + (assertLe_2Call, assertLe_3Call), } -impl Cheatcode for assertApproxEqAbsDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_abs(self.left, self.right, self.maxDelta) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right, decimals| assert_le(left, right), + |e| e.format_with_decimals(decimals), + (assertLeDecimal_0Call, assertLeDecimal_1Call), + (assertLeDecimal_2Call, assertLeDecimal_3Call), } -impl Cheatcode for assertApproxEqRel_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("assertion failed: {e}"))?) - } +impl_assertions! { + |left, right, maxDelta| uint_assert_approx_eq_abs(*left, *right, *maxDelta), + (assertApproxEqAbs_0Call, assertApproxEqAbs_1Call), } -impl Cheatcode for assertApproxEqRel_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("{}: {}", self.error, e))?) - } +impl_assertions! { + |left, right, maxDelta| int_assert_approx_eq_abs(*left, *right, *maxDelta), + (assertApproxEqAbs_2Call, assertApproxEqAbs_3Call), } -impl Cheatcode for assertApproxEqRel_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("assertion failed: {e}"))?) - } +impl_assertions! { + |left, right, decimals, maxDelta| uint_assert_approx_eq_abs(*left, *right, *maxDelta), + |e| e.format_with_decimals(decimals), + (assertApproxEqAbsDecimal_0Call, assertApproxEqAbsDecimal_1Call), } -impl Cheatcode for assertApproxEqRel_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("{}: {}", self.error, e))?) - } +impl_assertions! { + |left, right, decimals, maxDelta| int_assert_approx_eq_abs(*left, *right, *maxDelta), + |e| e.format_with_decimals(decimals), + (assertApproxEqAbsDecimal_2Call, assertApproxEqAbsDecimal_3Call), } -impl Cheatcode for assertApproxEqRelDecimal_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right, maxPercentDelta| uint_assert_approx_eq_rel(*left, *right, *maxPercentDelta), + (assertApproxEqRel_0Call, assertApproxEqRel_1Call), } -impl Cheatcode for assertApproxEqRelDecimal_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(uint_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right, maxPercentDelta| int_assert_approx_eq_rel(*left, *right, *maxPercentDelta), + (assertApproxEqRel_2Call, assertApproxEqRel_3Call), } -impl Cheatcode for assertApproxEqRelDecimal_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("assertion failed: {}", e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right, decimals, maxPercentDelta| uint_assert_approx_eq_rel(*left, *right, *maxPercentDelta), + |e| e.format_with_decimals(decimals), + (assertApproxEqRelDecimal_0Call, assertApproxEqRelDecimal_1Call), } -impl Cheatcode for assertApproxEqRelDecimal_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - Ok(int_assert_approx_eq_rel(self.left, self.right, self.maxPercentDelta) - .map_err(|e| format!("{}: {}", self.error, e.format_with_decimals(&self.decimals)))?) - } +impl_assertions! { + |left, right, decimals, maxPercentDelta| int_assert_approx_eq_rel(*left, *right, *maxPercentDelta), + |e| e.format_with_decimals(decimals), + (assertApproxEqRelDecimal_2Call, assertApproxEqRelDecimal_3Call), } fn assert_true(condition: bool) -> Result, SimpleAssertionError> { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ebafdf0d052cd..c097078fbab80 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -421,6 +421,9 @@ pub struct Config { #[serde(default, skip_serializing)] pub root: RootPath, + /// Whether to enable legacy (non-reverting) assertions. + pub legacy_assertions: bool, + /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information #[serde(rename = "__warnings", default, skip_serializing)] pub warnings: Vec, @@ -2118,6 +2121,7 @@ impl Default for Config { create2_library_salt: Self::DEFAULT_CREATE2_LIBRARY_SALT, skip: vec![], dependencies: Default::default(), + legacy_assertions: false, warnings: vec![], _non_exhaustive: (), } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index c7b3abd2ecc4f..ab9a6c2abff0a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -139,6 +139,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { skip: vec![], dependencies: Default::default(), warnings: vec![], + legacy_assertions: false, _non_exhaustive: (), }; prj.write_config(input.clone()); From c8db1e4b56fe469e353d8f6c697db499988c9483 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 26 Jun 2024 23:34:31 +0400 Subject: [PATCH 1156/1963] feat: `CheatcodesExecutor` + `vm.deployCode` (#8181) * wip * wip * wip * clean up * fix vm.transact traces * clean up * clippy * cargo cheats * review fixes * clippy * tests * clippy * cargo cheats * const -> static * fmt * clippy * fix doc * chore: fmt * fix: doc * fix: doc * increase depth for failing test * review fixes * reduce diff * rename * call_with_executor * chore: keep dbext methods with auto_impl attribute --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 40 ++++ crates/cheatcodes/spec/src/vm.rs | 12 ++ crates/cheatcodes/src/evm.rs | 72 +++---- crates/cheatcodes/src/evm/fork.rs | 68 +++--- crates/cheatcodes/src/evm/mock.rs | 4 +- crates/cheatcodes/src/evm/prank.rs | 8 +- crates/cheatcodes/src/fs.rs | 57 ++++- crates/cheatcodes/src/inspector.rs | 232 ++++++++++++++------ crates/cheatcodes/src/lib.rs | 20 +- crates/cheatcodes/src/script.rs | 14 +- crates/cheatcodes/src/test.rs | 6 +- crates/cheatcodes/src/test/expect.rs | 26 +-- crates/cheatcodes/src/utils.rs | 6 +- crates/evm/core/src/backend/cow.rs | 4 +- crates/evm/core/src/backend/mod.rs | 27 +-- crates/evm/core/src/utils.rs | 21 +- crates/evm/evm/src/inspectors/stack.rs | 260 ++++++++++++++++++----- crates/forge/tests/it/invariant.rs | 2 +- crates/forge/tests/it/main.rs | 1 + crates/forge/tests/it/test_helpers.rs | 68 ++++-- crates/forge/tests/it/vyper.rs | 10 + testdata/cheats/Vm.sol | 2 + testdata/default/cheats/DeployCode.t.sol | 42 ++++ testdata/default/vyper/Counter.vy | 12 ++ testdata/default/vyper/CounterTest.vy | 16 ++ testdata/default/vyper/ICounter.vyi | 12 ++ 26 files changed, 788 insertions(+), 254 deletions(-) create mode 100644 crates/forge/tests/it/vyper.rs create mode 100644 testdata/default/cheats/DeployCode.t.sol create mode 100644 testdata/default/vyper/Counter.vy create mode 100644 testdata/default/vyper/CounterTest.vy create mode 100644 testdata/default/vyper/ICounter.vyi diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 85b2766da128e..2a125df98c5f7 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3551,6 +3551,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "deployCode_0", + "description": "Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.", + "declaration": "function deployCode(string calldata artifactPath) external returns (address deployedAddress);", + "visibility": "external", + "mutability": "", + "signature": "deployCode(string)", + "selector": "0x9a8325a0", + "selectorBytes": [ + 154, + 131, + 37, + 160 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "deployCode_1", + "description": "Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.\nAdditionaly accepts abi-encoded constructor arguments.", + "declaration": "function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress);", + "visibility": "external", + "mutability": "", + "signature": "deployCode(string,bytes)", + "selector": "0x29ce9dde", + "selectorBytes": [ + 41, + 206, + 157, + 222 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "deriveKey_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index f774fcbc7e1bb..cd8aa08c509c6 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1474,6 +1474,18 @@ interface Vm { #[cheatcode(group = Filesystem)] function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); + /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the + /// artifact in the form of :: where and parts are optional. + #[cheatcode(group = Filesystem)] + function deployCode(string calldata artifactPath) external returns (address deployedAddress); + + /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the + /// artifact in the form of :: where and parts are optional. + /// + /// Additionaly accepts abi-encoded constructor arguments. + #[cheatcode(group = Filesystem)] + function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress); + /// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of :: where and parts are optional. #[cheatcode(group = Filesystem)] diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 50265b4b12e0d..4e559687dbc1e 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -67,14 +67,14 @@ impl Cheatcode for addrCall { } impl Cheatcode for getNonce_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; get_nonce(ccx, account) } } impl Cheatcode for loadCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, slot } = *self; ensure_not_precompile!(&target, ccx); ccx.ecx.load_account(target)?; @@ -84,7 +84,7 @@ impl Cheatcode for loadCall { } impl Cheatcode for loadAllocsCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { pathToAllocsJson } = self; let path = Path::new(pathToAllocsJson); @@ -110,7 +110,7 @@ impl Cheatcode for loadAllocsCall { } impl Cheatcode for dumpStateCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { pathToStateJson } = self; let path = Path::new(pathToStateJson); @@ -156,28 +156,28 @@ impl Cheatcode for dumpStateCall { } impl Cheatcode for sign_0Call { - fn apply_full(&self, _: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { let Self { privateKey, digest } = self; super::utils::sign(privateKey, digest) } } impl Cheatcode for sign_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { digest } = self; super::utils::sign_with_wallet(ccx, None, digest) } } impl Cheatcode for sign_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { signer, digest } = self; super::utils::sign_with_wallet(ccx, Some(*signer), digest) } } impl Cheatcode for signP256Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey, digest } = self; super::utils::sign_p256(privateKey, digest, ccx.state) } @@ -255,7 +255,7 @@ impl Cheatcode for lastCallGasCall { } impl Cheatcode for chainIdCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newChainId } = self; ensure!(*newChainId <= U256::from(u64::MAX), "chain ID must be less than 2^64 - 1"); ccx.ecx.env.cfg.chain_id = newChainId.to(); @@ -264,7 +264,7 @@ impl Cheatcode for chainIdCall { } impl Cheatcode for coinbaseCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newCoinbase } = self; ccx.ecx.env.block.coinbase = *newCoinbase; Ok(Default::default()) @@ -272,7 +272,7 @@ impl Cheatcode for coinbaseCall { } impl Cheatcode for difficultyCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newDifficulty } = self; ensure!( ccx.ecx.spec_id() < SpecId::MERGE, @@ -285,7 +285,7 @@ impl Cheatcode for difficultyCall { } impl Cheatcode for feeCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newBasefee } = self; ccx.ecx.env.block.basefee = *newBasefee; Ok(Default::default()) @@ -293,7 +293,7 @@ impl Cheatcode for feeCall { } impl Cheatcode for prevrandao_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newPrevrandao } = self; ensure!( ccx.ecx.spec_id() >= SpecId::MERGE, @@ -306,7 +306,7 @@ impl Cheatcode for prevrandao_0Call { } impl Cheatcode for prevrandao_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newPrevrandao } = self; ensure!( ccx.ecx.spec_id() >= SpecId::MERGE, @@ -319,7 +319,7 @@ impl Cheatcode for prevrandao_1Call { } impl Cheatcode for blobhashesCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { hashes } = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, @@ -332,7 +332,7 @@ impl Cheatcode for blobhashesCall { } impl Cheatcode for getBlobhashesCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, @@ -344,7 +344,7 @@ impl Cheatcode for getBlobhashesCall { } impl Cheatcode for rollCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newHeight } = self; ccx.ecx.env.block.number = *newHeight; Ok(Default::default()) @@ -352,14 +352,14 @@ impl Cheatcode for rollCall { } impl Cheatcode for getBlockNumberCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; Ok(ccx.ecx.env.block.number.abi_encode()) } } impl Cheatcode for txGasPriceCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newGasPrice } = self; ccx.ecx.env.tx.gas_price = *newGasPrice; Ok(Default::default()) @@ -367,7 +367,7 @@ impl Cheatcode for txGasPriceCall { } impl Cheatcode for warpCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newTimestamp } = self; ccx.ecx.env.block.timestamp = *newTimestamp; Ok(Default::default()) @@ -375,14 +375,14 @@ impl Cheatcode for warpCall { } impl Cheatcode for getBlockTimestampCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; Ok(ccx.ecx.env.block.timestamp.abi_encode()) } } impl Cheatcode for blobBaseFeeCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newBlobBaseFee } = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, @@ -395,14 +395,14 @@ impl Cheatcode for blobBaseFeeCall { } impl Cheatcode for getBlobBaseFeeCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; Ok(ccx.ecx.env.block.get_blob_excess_gas().unwrap_or(0).abi_encode()) } } impl Cheatcode for dealCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account: address, newBalance: new_balance } = *self; let account = journaled_account(ccx.ecx, address)?; let old_balance = std::mem::replace(&mut account.info.balance, new_balance); @@ -413,7 +413,7 @@ impl Cheatcode for dealCall { } impl Cheatcode for etchCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, newRuntimeBytecode } = self; ensure_not_precompile!(target, ccx); ccx.ecx.load_account(*target)?; @@ -424,7 +424,7 @@ impl Cheatcode for etchCall { } impl Cheatcode for resetNonceCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; let account = journaled_account(ccx.ecx, *account)?; // Per EIP-161, EOA nonces start at 0, but contract nonces @@ -439,7 +439,7 @@ impl Cheatcode for resetNonceCall { } impl Cheatcode for setNonceCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account, newNonce } = *self; let account = journaled_account(ccx.ecx, account)?; // nonce must increment only @@ -455,7 +455,7 @@ impl Cheatcode for setNonceCall { } impl Cheatcode for setNonceUnsafeCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account, newNonce } = *self; let account = journaled_account(ccx.ecx, account)?; account.info.nonce = newNonce; @@ -464,7 +464,7 @@ impl Cheatcode for setNonceUnsafeCall { } impl Cheatcode for storeCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, slot, value } = *self; ensure_not_precompile!(&target, ccx); // ensure the account is touched @@ -475,7 +475,7 @@ impl Cheatcode for storeCall { } impl Cheatcode for coolCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target } = self; if let Some(account) = ccx.ecx.journaled_state.state.get_mut(target) { account.unmark_touch(); @@ -486,21 +486,21 @@ impl Cheatcode for coolCall { } impl Cheatcode for readCallersCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; read_callers(ccx.state, &ccx.ecx.env.tx.caller) } } impl Cheatcode for snapshotCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; Ok(ccx.ecx.db.snapshot(&ccx.ecx.journaled_state, &ccx.ecx.env).abi_encode()) } } impl Cheatcode for revertToCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; let result = if let Some(journaled_state) = ccx.ecx.db.revert( *snapshotId, @@ -519,7 +519,7 @@ impl Cheatcode for revertToCall { } impl Cheatcode for revertToAndDeleteCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; let result = if let Some(journaled_state) = ccx.ecx.db.revert( *snapshotId, @@ -538,14 +538,14 @@ impl Cheatcode for revertToAndDeleteCall { } impl Cheatcode for deleteSnapshotCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; let result = ccx.ecx.db.delete_snapshot(*snapshotId); Ok(result.abi_encode()) } } impl Cheatcode for deleteSnapshotsCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; ccx.ecx.db.delete_snapshots(); Ok(Default::default()) diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index a767520288f21..70b7591f8a82e 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -7,7 +7,7 @@ use foundry_common::provider::ProviderBuilder; use foundry_evm_core::fork::CreateFork; impl Cheatcode for activeForkCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; ccx.ecx .db @@ -18,49 +18,49 @@ impl Cheatcode for activeForkCall { } impl Cheatcode for createFork_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias } = self; create_fork(ccx, urlOrAlias, None) } } impl Cheatcode for createFork_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, blockNumber } = self; create_fork(ccx, urlOrAlias, Some(blockNumber.saturating_to())) } } impl Cheatcode for createFork_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, txHash } = self; create_fork_at_transaction(ccx, urlOrAlias, txHash) } } impl Cheatcode for createSelectFork_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias } = self; create_select_fork(ccx, urlOrAlias, None) } } impl Cheatcode for createSelectFork_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, blockNumber } = self; create_select_fork(ccx, urlOrAlias, Some(blockNumber.saturating_to())) } } impl Cheatcode for createSelectFork_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, txHash } = self; create_select_fork_at_transaction(ccx, urlOrAlias, txHash) } } impl Cheatcode for rollFork_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { blockNumber } = self; persist_caller(ccx); ccx.ecx.db.roll_fork( @@ -74,7 +74,7 @@ impl Cheatcode for rollFork_0Call { } impl Cheatcode for rollFork_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { txHash } = self; persist_caller(ccx); ccx.ecx.db.roll_fork_to_transaction( @@ -88,7 +88,7 @@ impl Cheatcode for rollFork_1Call { } impl Cheatcode for rollFork_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, blockNumber } = self; persist_caller(ccx); ccx.ecx.db.roll_fork( @@ -102,7 +102,7 @@ impl Cheatcode for rollFork_2Call { } impl Cheatcode for rollFork_3Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, txHash } = self; persist_caller(ccx); ccx.ecx.db.roll_fork_to_transaction( @@ -116,7 +116,7 @@ impl Cheatcode for rollFork_3Call { } impl Cheatcode for selectForkCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId } = self; persist_caller(ccx); check_broadcast(ccx.state)?; @@ -127,35 +127,43 @@ impl Cheatcode for selectForkCall { } impl Cheatcode for transact_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + executor: &mut E, + ) -> Result { let Self { txHash } = *self; ccx.ecx.db.transact( None, txHash, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state, - ccx.state, + &mut executor.get_inspector(ccx.state), )?; Ok(Default::default()) } } impl Cheatcode for transact_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + executor: &mut E, + ) -> Result { let Self { forkId, txHash } = *self; ccx.ecx.db.transact( Some(forkId), txHash, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state, - ccx.state, + &mut executor.get_inspector(ccx.state), )?; Ok(Default::default()) } } impl Cheatcode for allowCheatcodesCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; ccx.ecx.db.allow_cheatcode_access(*account); Ok(Default::default()) @@ -163,7 +171,7 @@ impl Cheatcode for allowCheatcodesCall { } impl Cheatcode for makePersistent_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; ccx.ecx.db.add_persistent_account(*account); Ok(Default::default()) @@ -171,7 +179,7 @@ impl Cheatcode for makePersistent_0Call { } impl Cheatcode for makePersistent_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account0, account1 } = self; ccx.ecx.db.add_persistent_account(*account0); ccx.ecx.db.add_persistent_account(*account1); @@ -180,7 +188,7 @@ impl Cheatcode for makePersistent_1Call { } impl Cheatcode for makePersistent_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account0, account1, account2 } = self; ccx.ecx.db.add_persistent_account(*account0); ccx.ecx.db.add_persistent_account(*account1); @@ -190,15 +198,17 @@ impl Cheatcode for makePersistent_2Call { } impl Cheatcode for makePersistent_3Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { accounts } = self; - ccx.ecx.db.extend_persistent_accounts(accounts.iter().copied()); + for account in accounts { + ccx.ecx.db.add_persistent_account(*account); + } Ok(Default::default()) } } impl Cheatcode for revokePersistent_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; ccx.ecx.db.remove_persistent_account(account); Ok(Default::default()) @@ -206,22 +216,24 @@ impl Cheatcode for revokePersistent_0Call { } impl Cheatcode for revokePersistent_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { accounts } = self; - ccx.ecx.db.remove_persistent_accounts(accounts.iter().copied()); + for account in accounts { + ccx.ecx.db.remove_persistent_account(account); + } Ok(Default::default()) } } impl Cheatcode for isPersistentCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; Ok(ccx.ecx.db.is_persistent(account).abi_encode()) } } impl Cheatcode for rpcCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { method, params } = self; let url = ccx.ecx.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; @@ -239,7 +251,7 @@ impl Cheatcode for rpcCall { } impl Cheatcode for eth_getLogsCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { fromBlock, toBlock, target, topics } = self; let (Ok(from_block), Ok(to_block)) = (u64::try_from(fromBlock), u64::try_from(toBlock)) else { diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index becf86f178f54..0949cbf4f973d 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -47,7 +47,7 @@ impl Cheatcode for clearMockedCallsCall { } impl Cheatcode for mockCall_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; let (acc, _) = ccx.ecx.load_account(*callee)?; @@ -65,7 +65,7 @@ impl Cheatcode for mockCall_0Call { } impl Cheatcode for mockCall_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, msgValue, data, returnData } = self; ccx.ecx.load_account(*callee)?; mock_call(ccx.state, callee, data, Some(msgValue), returnData, InstructionResult::Return); diff --git a/crates/cheatcodes/src/evm/prank.rs b/crates/cheatcodes/src/evm/prank.rs index 4e4ef81f759f3..fe5418b3157f8 100644 --- a/crates/cheatcodes/src/evm/prank.rs +++ b/crates/cheatcodes/src/evm/prank.rs @@ -45,28 +45,28 @@ impl Prank { } impl Cheatcode for prank_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender } = self; prank(ccx, msgSender, None, true) } } impl Cheatcode for startPrank_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender } = self; prank(ccx, msgSender, None, false) } } impl Cheatcode for prank_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender, txOrigin } = self; prank(ccx, msgSender, Some(txOrigin), true) } } impl Cheatcode for startPrank_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender, txOrigin } = self; prank(ccx, msgSender, Some(txOrigin), false) } diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index a126d8dc9e909..045ebea27e45f 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -1,7 +1,7 @@ //! Implementations of [`Filesystem`](spec::Group::Filesystem) cheatcodes. use super::string::parse; -use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_dyn_abi::DynSolType; use alloy_json_abi::ContractObject; use alloy_primitives::{hex, Bytes, U256}; @@ -9,6 +9,8 @@ use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; +use foundry_evm_core::backend::DatabaseExt; +use revm::interpreter::CreateInputs; use semver::Version; use std::{ collections::hash_map::Entry, @@ -262,6 +264,59 @@ impl Cheatcode for getDeployedCodeCall { } } +impl Cheatcode for deployCode_0Call { + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + executor: &mut E, + ) -> Result { + let Self { artifactPath: path } = self; + let bytecode = get_artifact_code(ccx.state, path, false)?; + let output = executor + .exec_create( + CreateInputs { + caller: ccx.caller, + scheme: revm::primitives::CreateScheme::Create, + value: U256::ZERO, + init_code: bytecode, + gas_limit: ccx.gas_limit, + }, + ccx.state, + ccx.ecx, + ) + .unwrap(); + + Ok(output.address.unwrap().abi_encode()) + } +} + +impl Cheatcode for deployCode_1Call { + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + executor: &mut E, + ) -> Result { + let Self { artifactPath: path, constructorArgs } = self; + let mut bytecode = get_artifact_code(ccx.state, path, false)?.to_vec(); + bytecode.extend_from_slice(constructorArgs); + let output = executor + .exec_create( + CreateInputs { + caller: ccx.caller, + scheme: revm::primitives::CreateScheme::Create, + value: U256::ZERO, + init_code: bytecode.into(), + gas_limit: ccx.gas_limit, + }, + ccx.state, + ccx.ecx, + ) + .unwrap(); + + Ok(output.address.unwrap().abi_encode()) + } +} + /// Returns the path to the json artifact depending on the input /// /// Can parse following input formats: diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index a2d85c83b2ca0..300ada83d7c10 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1,4 +1,4 @@ -//! Cheatcode EVM [Inspector]. +//! Cheatcode EVM inspector. use crate::{ evm::{ @@ -24,6 +24,7 @@ use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseExt, RevertDiagnostic}, constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, + utils::new_evm_with_existing_context, InspectorExt, }; use itertools::Itertools; @@ -32,7 +33,7 @@ use revm::{ opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, - primitives::{BlockEnv, CreateScheme}, + primitives::{BlockEnv, CreateScheme, EVMError}, EvmContext, InnerEvmContext, Inspector, }; use rustc_hash::FxHashMap; @@ -46,6 +47,85 @@ use std::{ sync::Arc, }; +/// Helper trait for obtaining complete [revm::Inspector] instance from mutable reference to +/// [Cheatcodes]. +/// +/// This is needed for cases when inspector itself needs mutable access to [Cheatcodes] state and +/// allows us to correctly execute arbitrary EVM frames from inside cheatcode implementations. +pub trait CheatcodesExecutor { + /// Core trait method accepting mutable reference to [Cheatcodes] and returning + /// [revm::Inspector]. + fn get_inspector<'a, DB: DatabaseExt>( + &'a mut self, + cheats: &'a mut Cheatcodes, + ) -> impl InspectorExt + 'a; + + /// Obtains [revm::Inspector] instance and executes the given CREATE frame. + fn exec_create( + &mut self, + inputs: CreateInputs, + cheats: &mut Cheatcodes, + ecx: &mut InnerEvmContext, + ) -> Result> { + let inspector = self.get_inspector(cheats); + let error = std::mem::replace(&mut ecx.error, Ok(())); + let l1_block_info = std::mem::take(&mut ecx.l1_block_info); + + let inner = revm::InnerEvmContext { + env: ecx.env.clone(), + journaled_state: std::mem::replace( + &mut ecx.journaled_state, + revm::JournaledState::new(Default::default(), Default::default()), + ), + db: &mut ecx.db as &mut dyn DatabaseExt, + error, + l1_block_info, + }; + + let mut evm = new_evm_with_existing_context(inner, inspector); + + evm.context.evm.inner.journaled_state.depth += 1; + + let first_frame_or_result = + evm.handler.execution().create(&mut evm.context, Box::new(inputs))?; + + let mut result = match first_frame_or_result { + revm::FrameOrResult::Frame(first_frame) => evm.run_the_loop(first_frame)?, + revm::FrameOrResult::Result(result) => result, + }; + + evm.handler.execution().last_frame_return(&mut evm.context, &mut result)?; + + let outcome = match result { + revm::FrameResult::Call(_) | revm::FrameResult::EOFCreate(_) => unreachable!(), + revm::FrameResult::Create(create) => create, + }; + + evm.context.evm.inner.journaled_state.depth -= 1; + + ecx.journaled_state = evm.context.evm.inner.journaled_state; + ecx.env = evm.context.evm.inner.env; + ecx.l1_block_info = evm.context.evm.inner.l1_block_info; + ecx.error = evm.context.evm.inner.error; + + Ok(outcome) + } +} + +/// Basic implementation of [CheatcodesExecutor] that simply returns the [Cheatcodes] instance as an +/// inspector. +#[derive(Debug, Default, Clone, Copy)] +struct TransparentCheatcodesExecutor; + +impl CheatcodesExecutor for TransparentCheatcodesExecutor { + fn get_inspector<'a, DB: DatabaseExt>( + &'a mut self, + cheats: &'a mut Cheatcodes, + ) -> impl InspectorExt + 'a { + cheats + } +} + macro_rules! try_or_return { ($e:expr) => { match $e { @@ -255,10 +335,11 @@ impl Cheatcodes { } /// Decodes the input data and applies the cheatcode. - fn apply_cheatcode( + fn apply_cheatcode( &mut self, ecx: &mut EvmContext, call: &CallInputs, + executor: &mut E, ) -> Result { // decode the cheatcode call let decoded = Vm::VmCalls::abi_decode(&call.input, false).map_err(|e| { @@ -285,8 +366,10 @@ impl Cheatcodes { state: self, ecx: &mut ecx.inner, precompiles: &mut ecx.precompiles, + gas_limit: call.gas_limit, caller, }, + executor, ) } @@ -346,67 +429,13 @@ impl Cheatcodes { } } } -} - -impl Inspector for Cheatcodes { - #[inline] - fn initialize_interp(&mut self, _interpreter: &mut Interpreter, ecx: &mut EvmContext) { - // When the first interpreter is initialized we've circumvented the balance and gas checks, - // so we apply our actual block data with the correct fees and all. - if let Some(block) = self.block.take() { - ecx.env.block = block; - } - if let Some(gas_price) = self.gas_price.take() { - ecx.env.tx.gas_price = gas_price; - } - } - - #[inline] - fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { - self.pc = interpreter.program_counter(); - - // `pauseGasMetering`: reset interpreter gas. - if self.gas_metering.is_some() { - self.meter_gas(interpreter); - } - - // `record`: record storage reads and writes. - if self.accesses.is_some() { - self.record_accesses(interpreter); - } - - // `startStateDiffRecording`: record granular ordered storage accesses. - if self.recorded_account_diffs_stack.is_some() { - self.record_state_diffs(interpreter, ecx); - } - - // `expectSafeMemory`: check if the current opcode is allowed to interact with memory. - if !self.allowed_mem_writes.is_empty() { - self.check_mem_opcodes(interpreter, ecx.journaled_state.depth()); - } - - // `startMappingRecording`: record SSTORE and KECCAK256. - if let Some(mapping_slots) = &mut self.mapping_slots { - mapping::step(mapping_slots, interpreter); - } - } - - fn log(&mut self, _context: &mut EvmContext, log: &Log) { - if !self.expected_emits.is_empty() { - expect::handle_expect_emit(self, log); - } - - // `recordLogs` - if let Some(storage_recorded_logs) = &mut self.recorded_logs { - storage_recorded_logs.push(Vm::Log { - topics: log.data.topics().to_vec(), - data: log.data.data.clone(), - emitter: log.address, - }); - } - } - fn call(&mut self, ecx: &mut EvmContext, call: &mut CallInputs) -> Option { + pub fn call_with_executor( + &mut self, + ecx: &mut EvmContext, + call: &mut CallInputs, + executor: &mut impl CheatcodesExecutor, + ) -> Option { let gas = Gas::new(call.gas_limit); // At the root call to test function or script `run()`/`setUp()` functions, we are @@ -436,7 +465,7 @@ impl Inspector for Cheatcodes { } if call.target_address == CHEATCODE_ADDRESS { - return match self.apply_cheatcode(ecx, call) { + return match self.apply_cheatcode(ecx, call, executor) { Ok(retdata) => Some(CallOutcome { result: InterpreterResult { result: InstructionResult::Return, @@ -658,6 +687,73 @@ impl Inspector for Cheatcodes { None } +} + +impl Inspector for Cheatcodes { + #[inline] + fn initialize_interp(&mut self, _interpreter: &mut Interpreter, ecx: &mut EvmContext) { + // When the first interpreter is initialized we've circumvented the balance and gas checks, + // so we apply our actual block data with the correct fees and all. + if let Some(block) = self.block.take() { + ecx.env.block = block; + } + if let Some(gas_price) = self.gas_price.take() { + ecx.env.tx.gas_price = gas_price; + } + } + + #[inline] + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + self.pc = interpreter.program_counter(); + + // `pauseGasMetering`: reset interpreter gas. + if self.gas_metering.is_some() { + self.meter_gas(interpreter); + } + + // `record`: record storage reads and writes. + if self.accesses.is_some() { + self.record_accesses(interpreter); + } + + // `startStateDiffRecording`: record granular ordered storage accesses. + if self.recorded_account_diffs_stack.is_some() { + self.record_state_diffs(interpreter, ecx); + } + + // `expectSafeMemory`: check if the current opcode is allowed to interact with memory. + if !self.allowed_mem_writes.is_empty() { + self.check_mem_opcodes(interpreter, ecx.journaled_state.depth()); + } + + // `startMappingRecording`: record SSTORE and KECCAK256. + if let Some(mapping_slots) = &mut self.mapping_slots { + mapping::step(mapping_slots, interpreter); + } + } + + fn log(&mut self, _context: &mut EvmContext, log: &Log) { + if !self.expected_emits.is_empty() { + expect::handle_expect_emit(self, log); + } + + // `recordLogs` + if let Some(storage_recorded_logs) = &mut self.recorded_logs { + storage_recorded_logs.push(Vm::Log { + topics: log.data.topics().to_vec(), + data: log.data.data.clone(), + emitter: log.address, + }); + } + } + + fn call( + &mut self, + context: &mut EvmContext, + inputs: &mut CallInputs, + ) -> Option { + Self::call_with_executor(self, context, inputs, &mut TransparentCheatcodesExecutor) + } fn call_end( &mut self, @@ -1679,11 +1775,15 @@ fn append_storage_access( } /// Dispatches the cheatcode call to the appropriate function. -fn apply_dispatch(calls: &Vm::VmCalls, ccx: &mut CheatsCtxt) -> Result { +fn apply_dispatch( + calls: &Vm::VmCalls, + ccx: &mut CheatsCtxt, + executor: &mut E, +) -> Result { macro_rules! dispatch { ($($variant:ident),*) => { match calls { - $(Vm::VmCalls::$variant(cheat) => crate::Cheatcode::apply_full(cheat, ccx),)* + $(Vm::VmCalls::$variant(cheat) => crate::Cheatcode::apply_full(cheat, ccx, executor),)* } }; } diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 718b173426873..85ce8d78c51d8 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -17,7 +17,9 @@ use revm::{ContextPrecompiles, InnerEvmContext}; pub use config::CheatsConfig; pub use error::{Error, ErrorKind, Result}; -pub use inspector::{BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, Context}; +pub use inspector::{ + BroadcastableTransaction, BroadcastableTransactions, Cheatcodes, CheatcodesExecutor, Context, +}; pub use spec::{CheatcodeDef, Vm}; pub use Vm::ForgeContext; @@ -65,9 +67,21 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { /// /// Implement this function if you need access to the EVM data. #[inline(always)] - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { self.apply(ccx.state) } + + /// Applies this cheatcode to the given context and executor. + /// + /// Implement this function if you need access to the executor. + #[inline(always)] + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + _executor: &mut E, + ) -> Result { + self.apply_stateful(ccx) + } } pub(crate) trait DynCheatcode { @@ -94,6 +108,8 @@ pub(crate) struct CheatsCtxt<'cheats, 'evm, DB: DatabaseExt> { pub(crate) precompiles: &'evm mut ContextPrecompiles, /// The original `msg.sender`. pub(crate) caller: Address, + /// Gas limit of the current cheatcode call. + pub(crate) gas_limit: u64, } impl<'cheats, 'evm, DB: DatabaseExt> std::ops::Deref for CheatsCtxt<'cheats, 'evm, DB> { diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 1f84e2475f815..af4457f8edb10 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -8,49 +8,49 @@ use parking_lot::Mutex; use std::sync::Arc; impl Cheatcode for broadcast_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; broadcast(ccx, None, true) } } impl Cheatcode for broadcast_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { signer } = self; broadcast(ccx, Some(signer), true) } } impl Cheatcode for broadcast_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; broadcast_key(ccx, privateKey, true) } } impl Cheatcode for startBroadcast_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; broadcast(ccx, None, false) } } impl Cheatcode for startBroadcast_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { signer } = self; broadcast(ccx, Some(signer), false) } } impl Cheatcode for startBroadcast_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; broadcast_key(ccx, privateKey, false) } } impl Cheatcode for stopBroadcastCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; let Some(broadcast) = ccx.state.broadcast.take() else { bail!("no broadcast in progress to stop"); diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index cab8b9f8b430d..4bccabda253e2 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -20,14 +20,14 @@ impl Cheatcode for assumeCall { } impl Cheatcode for breakpoint_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { char } = self; breakpoint(ccx.state, &ccx.caller, char, true) } } impl Cheatcode for breakpoint_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { char, value } = self; breakpoint(ccx.state, &ccx.caller, char, *value) } @@ -64,7 +64,7 @@ impl Cheatcode for sleepCall { } impl Cheatcode for skipCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { skipTest } = *self; if skipTest { // Skip should not work if called deeper than at test level. diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index eba665856b117..9c070a7ca8874 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -197,7 +197,7 @@ impl Cheatcode for expectCallMinGas_1Call { } impl Cheatcode for expectEmit_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { checkTopic1, checkTopic2, checkTopic3, checkData } = *self; expect_emit( ccx.state, @@ -209,7 +209,7 @@ impl Cheatcode for expectEmit_0Call { } impl Cheatcode for expectEmit_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { checkTopic1, checkTopic2, checkTopic3, checkData, emitter } = *self; expect_emit( ccx.state, @@ -221,69 +221,69 @@ impl Cheatcode for expectEmit_1Call { } impl Cheatcode for expectEmit_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 4], None) } } impl Cheatcode for expectEmit_3Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { emitter } = *self; expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 4], Some(emitter)) } } impl Cheatcode for expectRevert_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false) } } impl Cheatcode for expectRevert_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert(ccx.state, Some(revertData.as_ref()), ccx.ecx.journaled_state.depth(), false) } } impl Cheatcode for expectRevert_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), false) } } impl Cheatcode for _expectCheatcodeRevert_0Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true) } } impl Cheatcode for _expectCheatcodeRevert_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert(ccx.state, Some(revertData.as_ref()), ccx.ecx.journaled_state.depth(), true) } } impl Cheatcode for _expectCheatcodeRevert_2Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), true) } } impl Cheatcode for expectSafeMemoryCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { min, max } = *self; expect_safe_memory(ccx.state, min, max, ccx.ecx.journaled_state.depth()) } } impl Cheatcode for stopExpectSafeMemoryCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; ccx.state.allowed_mem_writes.remove(&ccx.ecx.journaled_state.depth()); Ok(Default::default()) @@ -291,7 +291,7 @@ impl Cheatcode for stopExpectSafeMemoryCall { } impl Cheatcode for expectSafeMemoryCallCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { min, max } = *self; expect_safe_memory(ccx.state, min, max, ccx.ecx.journaled_state.depth() + 1) } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 733ed36837279..8bea510eb9a7c 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -46,14 +46,14 @@ impl Cheatcode for createWallet_2Call { } impl Cheatcode for getNonce_1Call { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { wallet } = self; super::evm::get_nonce(ccx, &wallet.addr) } } impl Cheatcode for sign_3Call { - fn apply_full(&self, _: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { let Self { wallet, digest } = self; sign(&wallet.privateKey, digest) } @@ -88,7 +88,7 @@ impl Cheatcode for deriveKey_3Call { } impl Cheatcode for rememberKeyCall { - fn apply_full(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; let wallet = parse_wallet(privateKey)?; let address = wallet.address(); diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 766070e997f5e..2866f4ec14c80 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -178,13 +178,13 @@ impl<'a> DatabaseExt for CowBackend<'a> { self.backend_mut(env).roll_fork_to_transaction(id, transaction, env, journaled_state) } - fn transact>( + fn transact( &mut self, id: Option, transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: &mut I, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { self.backend_mut(env).transact(id, transaction, env, journaled_state, inspector) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 1185b0d6f3ef3..8cf58bfbdbe9c 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -68,7 +68,7 @@ pub const GLOBAL_FAIL_SLOT: U256 = /// An extension trait that allows us to easily extend the `revm::Inspector` capabilities #[auto_impl::auto_impl(&mut)] -pub trait DatabaseExt: Database { +pub trait DatabaseExt: Database + DatabaseCommit { /// Creates a new snapshot at the current point of execution. /// /// A snapshot is associated with a new unique id that's created for the snapshot. @@ -192,16 +192,14 @@ pub trait DatabaseExt: Database { ) -> eyre::Result<()>; /// Fetches the given transaction for the fork and executes it, committing the state in the DB - fn transact>( + fn transact( &mut self, id: Option, transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: &mut I, - ) -> eyre::Result<()> - where - Self: Sized; + inspector: &mut dyn InspectorExt, + ) -> eyre::Result<()>; /// Returns the `ForkId` that's currently used in the database, if fork mode is on fn active_fork_id(&self) -> Option; @@ -279,7 +277,8 @@ pub trait DatabaseExt: Database { /// Marks the given account as persistent. fn add_persistent_account(&mut self, account: Address) -> bool; - /// Removes persistent status from all given accounts + /// Removes persistent status from all given accounts. + #[auto_impl(keep_default_for(&, &mut, Rc, Arc, Box))] fn remove_persistent_accounts(&mut self, accounts: impl IntoIterator) where Self: Sized, @@ -290,6 +289,7 @@ pub trait DatabaseExt: Database { } /// Extends the persistent accounts with the accounts the iterator yields. + #[auto_impl(keep_default_for(&, &mut, Rc, Arc, Box))] fn extend_persistent_accounts(&mut self, accounts: impl IntoIterator) where Self: Sized, @@ -1183,13 +1183,13 @@ impl DatabaseExt for Backend { Ok(()) } - fn transact>( + fn transact( &mut self, maybe_id: Option, transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: &mut I, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { trace!(?maybe_id, ?transaction, "execute transaction"); let persistent_accounts = self.inner.persistent_accounts.clone(); @@ -1835,10 +1835,13 @@ fn commit_transaction>( let res = { let fork = fork.clone(); let journaled_state = journaled_state.clone(); + let depth = journaled_state.depth; let db = Backend::new_with_fork(fork_id, fork, journaled_state); - crate::utils::new_evm_with_inspector(db, env, inspector) - .transact() - .wrap_err("backend: failed committing transaction")? + + let mut evm = crate::utils::new_evm_with_inspector(db, env, inspector); + // Adjust inner EVM depth to ensure that inspectors receive accurate data. + evm.context.evm.inner.journaled_state.depth = depth + 1; + evm.transact().wrap_err("backend: failed committing transaction")? }; trace!(elapsed = ?now.elapsed(), "transacted transaction"); diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 58a088c06a4b7..2fc202c0dc189 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,7 +1,7 @@ pub use crate::ic::*; use crate::{constants::DEFAULT_CREATE2_DEPLOYER, InspectorExt}; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Selector, U256}; +use alloy_primitives::{Address, Selector, TxKind, U256}; use alloy_rpc_types::{Block, Transaction}; use foundry_config::NamedChain; use revm::{ @@ -11,7 +11,7 @@ use revm::{ return_ok, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, Gas, InstructionResult, InterpreterResult, }, - primitives::{CreateScheme, EVMError, SpecId, TxKind, KECCAK_EMPTY}, + primitives::{CreateScheme, EVMError, HandlerCfg, SpecId, KECCAK_EMPTY}, FrameOrResult, FrameResult, }; use std::{cell::RefCell, rc::Rc, sync::Arc}; @@ -267,6 +267,23 @@ where new_evm_with_inspector(WrapDatabaseRef(db), env, inspector) } +pub fn new_evm_with_existing_context<'a, DB, I>( + inner: revm::InnerEvmContext, + inspector: I, +) -> revm::Evm<'a, I, DB> +where + DB: revm::Database, + I: InspectorExt, +{ + let handler_cfg = HandlerCfg::new(inner.spec_id()); + let context = + revm::Context::new(revm::EvmContext { inner, precompiles: Default::default() }, inspector); + let mut handler = revm::Handler::new(handler_cfg); + handler.append_handler_register_plain(revm::inspector_handle_register); + handler.append_handler_register_plain(create2_handler_register); + revm::Evm::new(context, handler) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 8e235efe83de6..e290a55fc7c15 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -2,7 +2,8 @@ use super::{ Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Debugger, Fuzzer, LogCollector, StackSnapshotType, TracingInspector, TracingInspectorConfig, }; -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{Address, Bytes, Log, TxKind, U256}; +use foundry_cheatcodes::CheatcodesExecutor; use foundry_evm_core::{ backend::{update_state, DatabaseExt}, debug::DebugArena, @@ -16,10 +17,16 @@ use revm::{ CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, }, - primitives::{BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, Output, TxKind}, - DatabaseCommit, EvmContext, Inspector, + primitives::{ + BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, Output, TransactTo, + }, + EvmContext, Inspector, +}; +use std::{ + collections::HashMap, + ops::{Deref, DerefMut}, + sync::Arc, }; -use std::{collections::HashMap, sync::Arc}; #[derive(Clone, Debug, Default)] #[must_use = "builders do nothing unless you call `build` on them"] @@ -264,9 +271,23 @@ pub struct InnerContextData { /// /// If a call to an inspector returns a value other than [InstructionResult::Continue] (or /// equivalent) the remaining inspectors are not called. +/// +/// Stack is divided into [Cheatcodes] and `InspectorStackInner`. This is done to allow assembling +/// `InspectorStackRefMut` inside [Cheatcodes] to allow usage of it as [revm::Inspector]. This gives +/// us ability to create and execute separate EVM frames from inside cheatcodes while still having +/// access to entire stack of inspectors and correctly handling traces, logs, debugging info +/// collection, etc. #[derive(Clone, Debug, Default)] pub struct InspectorStack { pub cheatcodes: Option, + pub inner: InspectorStackInner, +} + +/// All used inpectors besides [Cheatcodes]. +/// +/// See [`InspectorStack`]. +#[derive(Default, Clone, Debug)] +pub struct InspectorStackInner { pub chisel_state: Option, pub coverage: Option, pub debugger: Option, @@ -281,6 +302,23 @@ pub struct InspectorStack { pub inner_context_data: Option, } +/// Struct keeping mutable references to both parts of [InspectorStack] and implementing +/// [revm::Inspector]. This struct can be obtained via [InspectorStack::as_mut] or via +/// [CheatcodesExecutor::get_inspector] method implemented for [InspectorStackInner]. +pub struct InspectorStackRefMut<'a> { + pub cheatcodes: Option<&'a mut Cheatcodes>, + pub inner: &'a mut InspectorStackInner, +} + +impl CheatcodesExecutor for InspectorStackInner { + fn get_inspector<'a, DB: DatabaseExt>( + &'a mut self, + cheats: &'a mut Cheatcodes, + ) -> impl InspectorExt + 'a { + InspectorStackRefMut { cheatcodes: Some(cheats), inner: self } + } +} + impl InspectorStack { /// Creates a new inspector stack. /// @@ -402,24 +440,53 @@ impl InspectorStack { /// Collects all the data gathered during inspection into a single struct. #[inline] pub fn collect(self) -> InspectorData { + let Self { + cheatcodes, + inner: + InspectorStackInner { chisel_state, coverage, debugger, log_collector, tracer, .. }, + } = self; + InspectorData { - logs: self.log_collector.map(|logs| logs.logs).unwrap_or_default(), - labels: self - .cheatcodes + logs: log_collector.map(|logs| logs.logs).unwrap_or_default(), + labels: cheatcodes .as_ref() .map(|cheatcodes| cheatcodes.labels.clone()) .unwrap_or_default(), - traces: self.tracer.map(|tracer| tracer.get_traces().clone()), - debug: self.debugger.map(|debugger| debugger.arena), - coverage: self.coverage.map(|coverage| coverage.maps), - cheatcodes: self.cheatcodes, - chisel_state: self.chisel_state.and_then(|state| state.state), + traces: tracer.map(|tracer| tracer.get_traces().clone()), + debug: debugger.map(|debugger| debugger.arena), + coverage: coverage.map(|coverage| coverage.maps), + cheatcodes, + chisel_state: chisel_state.and_then(|state| state.state), } } + fn as_mut(&mut self) -> InspectorStackRefMut<'_> { + InspectorStackRefMut { cheatcodes: self.cheatcodes.as_mut(), inner: &mut self.inner } + } +} + +impl<'a> InspectorStackRefMut<'a> { + /// Adjusts the EVM data for the inner EVM context. + /// Should be called on the top-level call of inner context (depth == 0 && + /// self.in_inner_context) Decreases sender nonce for CALLs to keep backwards compatibility + /// Updates tx.origin to the value before entering inner context + fn adjust_evm_data_for_inner_context(&mut self, ecx: &mut EvmContext) { + let inner_context_data = + self.inner_context_data.as_ref().expect("should be called in inner context"); + let sender_acc = ecx + .journaled_state + .state + .get_mut(&inner_context_data.sender) + .expect("failed to load sender"); + if !inner_context_data.is_create { + sender_acc.info.nonce = inner_context_data.original_sender_nonce; + } + ecx.env.tx.caller = inner_context_data.original_origin; + } + fn do_call_end( &mut self, - ecx: &mut EvmContext<&mut DB>, + ecx: &mut EvmContext, inputs: &CallInputs, outcome: CallOutcome, ) -> CallOutcome { @@ -450,10 +517,10 @@ impl InspectorStack { outcome } - fn transact_inner( + fn transact_inner( &mut self, - ecx: &mut EvmContext<&mut DB>, - transact_to: TxKind, + ecx: &mut EvmContext, + transact_to: TransactTo, caller: Address, input: Bytes, gas_limit: u64, @@ -499,7 +566,11 @@ impl InspectorStack { let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); let res = { - let mut evm = crate::utils::new_evm_with_inspector(&mut *ecx.db, env, &mut *self); + let mut evm = crate::utils::new_evm_with_inspector( + &mut ecx.db as &mut dyn DatabaseExt, + env, + &mut *self, + ); let res = evm.transact(); // need to reset the env in case it was modified via cheatcodes during execution @@ -576,36 +647,10 @@ impl InspectorStack { }; (InterpreterResult { result, output, gas }, address) } - - /// Adjusts the EVM data for the inner EVM context. - /// Should be called on the top-level call of inner context (depth == 0 && - /// self.in_inner_context) Decreases sender nonce for CALLs to keep backwards compatibility - /// Updates tx.origin to the value before entering inner context - fn adjust_evm_data_for_inner_context( - &mut self, - ecx: &mut EvmContext<&mut DB>, - ) { - let inner_context_data = - self.inner_context_data.as_ref().expect("should be called in inner context"); - let sender_acc = ecx - .journaled_state - .state - .get_mut(&inner_context_data.sender) - .expect("failed to load sender"); - if !inner_context_data.is_create { - sender_acc.info.nonce = inner_context_data.original_sender_nonce; - } - ecx.env.tx.caller = inner_context_data.original_origin; - } } -// NOTE: `&mut DB` is required because we recurse inside of `transact_inner` and we need to use the -// same reference to the DB, otherwise there's infinite recursion and Rust fails to instatiate this -// implementation. This currently works because internally we only use `&mut DB` anyways, but if -// this ever needs to be changed, this can be reverted back to using just `DB`, and instead using -// dynamic dispatch (`&mut dyn ...`) in `transact_inner`. -impl Inspector<&mut DB> for InspectorStack { - fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { +impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { + fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors_adjust_depth!( [&mut self.coverage, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.initialize_interp(interpreter, ecx), @@ -614,7 +659,7 @@ impl Inspector<&mut DB> for InspectorStack { ); } - fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors_adjust_depth!( [ &mut self.fuzzer, @@ -630,7 +675,7 @@ impl Inspector<&mut DB> for InspectorStack { ); } - fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut DB>) { + fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors_adjust_depth!( [&mut self.tracer, &mut self.chisel_state, &mut self.printer], |inspector| inspector.step_end(interpreter, ecx), @@ -639,7 +684,7 @@ impl Inspector<&mut DB> for InspectorStack { ); } - fn log(&mut self, ecx: &mut EvmContext<&mut DB>, log: &Log) { + fn log(&mut self, ecx: &mut EvmContext, log: &Log) { call_inspectors_adjust_depth!( [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.log(ecx, log), @@ -648,11 +693,7 @@ impl Inspector<&mut DB> for InspectorStack { ); } - fn call( - &mut self, - ecx: &mut EvmContext<&mut DB>, - call: &mut CallInputs, - ) -> Option { + fn call(&mut self, ecx: &mut EvmContext, call: &mut CallInputs) -> Option { if self.in_inner_context && ecx.journaled_state.depth == 0 { self.adjust_evm_data_for_inner_context(ecx); return None; @@ -665,7 +706,6 @@ impl Inspector<&mut DB> for InspectorStack { &mut self.debugger, &mut self.tracer, &mut self.log_collector, - &mut self.cheatcodes, &mut self.printer, ], |inspector| { @@ -681,6 +721,14 @@ impl Inspector<&mut DB> for InspectorStack { ecx ); + if let Some(cheatcodes) = self.cheatcodes.as_deref_mut() { + if let Some(output) = cheatcodes.call_with_executor(ecx, call, self.inner) { + if output.result.result != InstructionResult::Continue { + return Some(output) + } + } + } + if self.enable_isolation && call.scheme == CallScheme::Call && !self.in_inner_context && @@ -702,7 +750,7 @@ impl Inspector<&mut DB> for InspectorStack { fn call_end( &mut self, - ecx: &mut EvmContext<&mut DB>, + ecx: &mut EvmContext, inputs: &CallInputs, outcome: CallOutcome, ) -> CallOutcome { @@ -727,7 +775,7 @@ impl Inspector<&mut DB> for InspectorStack { fn create( &mut self, - ecx: &mut EvmContext<&mut DB>, + ecx: &mut EvmContext, create: &mut CreateInputs, ) -> Option { if self.in_inner_context && ecx.journaled_state.depth == 0 { @@ -764,7 +812,7 @@ impl Inspector<&mut DB> for InspectorStack { fn create_end( &mut self, - ecx: &mut EvmContext<&mut DB>, + ecx: &mut EvmContext, call: &CreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { @@ -803,10 +851,10 @@ impl Inspector<&mut DB> for InspectorStack { } } -impl InspectorExt<&mut DB> for InspectorStack { +impl<'a, DB: DatabaseExt> InspectorExt for InspectorStackRefMut<'a> { fn should_use_create2_factory( &mut self, - ecx: &mut EvmContext<&mut DB>, + ecx: &mut EvmContext, inputs: &mut CreateInputs, ) -> bool { call_inspectors_adjust_depth!( @@ -820,3 +868,97 @@ impl InspectorExt<&mut DB> for InspectorStack false } } + +impl Inspector for InspectorStack { + fn call( + &mut self, + context: &mut EvmContext, + inputs: &mut CallInputs, + ) -> Option { + self.as_mut().call(context, inputs) + } + + fn call_end( + &mut self, + context: &mut EvmContext, + inputs: &CallInputs, + outcome: CallOutcome, + ) -> CallOutcome { + self.as_mut().call_end(context, inputs, outcome) + } + + fn create( + &mut self, + context: &mut EvmContext, + create: &mut CreateInputs, + ) -> Option { + self.as_mut().create(context, create) + } + + fn create_end( + &mut self, + context: &mut EvmContext, + call: &CreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { + self.as_mut().create_end(context, call, outcome) + } + + fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + self.as_mut().initialize_interp(interpreter, ecx) + } + + fn log(&mut self, ecx: &mut EvmContext, log: &Log) { + self.as_mut().log(ecx, log) + } + + fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { + Inspector::::selfdestruct(&mut self.as_mut(), contract, target, value) + } + + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + self.as_mut().step(interpreter, ecx) + } + + fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + self.as_mut().step_end(interpreter, ecx) + } +} + +impl InspectorExt for InspectorStack { + fn should_use_create2_factory( + &mut self, + ecx: &mut EvmContext, + inputs: &mut CreateInputs, + ) -> bool { + self.as_mut().should_use_create2_factory(ecx, inputs) + } +} + +impl<'a> Deref for InspectorStackRefMut<'a> { + type Target = &'a mut InspectorStackInner; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl DerefMut for InspectorStackRefMut<'_> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} + +impl Deref for InspectorStack { + type Target = InspectorStackInner; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl DerefMut for InspectorStack { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 7712aa9a6f2a5..537569745aaf4 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -318,7 +318,7 @@ async fn test_shrink_big_sequence() { let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.fuzz.seed = Some(U256::from(119u32)); runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 500; + runner.test_options.invariant.depth = 1000; let initial_counterexample = runner .test_collect(&filter) diff --git a/crates/forge/tests/it/main.rs b/crates/forge/tests/it/main.rs index 48c0d66351ab7..aaa129796a39a 100644 --- a/crates/forge/tests/it/main.rs +++ b/crates/forge/tests/it/main.rs @@ -10,3 +10,4 @@ mod inline; mod invariant; mod repros; mod spec; +mod vyper; diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index cacfca10caf3b..27143e90ca61a 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -7,7 +7,8 @@ use forge::{ }; use foundry_compilers::{ artifacts::{EvmVersion, Libraries, Settings}, - Project, ProjectCompileOutput, SolcConfig, + utils::RuntimeOrHandle, + Project, ProjectCompileOutput, SolcConfig, Vyper, }; use foundry_config::{ fs_permissions::PathPermission, Config, FsPermissions, FuzzConfig, FuzzDictionaryConfig, @@ -28,6 +29,7 @@ use std::{ pub const RE_PATH_SEPARATOR: &str = "/"; const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); +static VYPER: Lazy = Lazy::new(|| std::env::temp_dir().join("vyper")); /// Profile for the tests group. Used to configure separate configurations for test runs. pub enum ForgeTestProfile { @@ -173,8 +175,8 @@ impl ForgeTestData { /// /// Uses [get_compiled] to lazily compile the project. pub fn new(profile: ForgeTestProfile) -> Self { - let project = profile.project(); - let output = get_compiled(&project); + let mut project = profile.project(); + let output = get_compiled(&mut project); let test_opts = profile.test_opts(&output); let config = profile.config(); let evm_opts = profile.evm_opts(); @@ -259,7 +261,41 @@ impl ForgeTestData { } } -pub fn get_compiled(project: &Project) -> ProjectCompileOutput { +/// Installs Vyper if it's not already present. +pub fn get_vyper() -> Vyper { + if let Ok(vyper) = Vyper::new("vyper") { + return vyper; + } + if let Ok(vyper) = Vyper::new(&*VYPER) { + return vyper; + } + RuntimeOrHandle::new().block_on(async { + #[cfg(target_family = "unix")] + use std::{fs::Permissions, os::unix::fs::PermissionsExt}; + + let url = match svm::platform() { + svm::Platform::MacOsAarch64 => "https://github.com/vyperlang/vyper/releases/download/v0.4.0rc6/vyper.0.4.0rc6+commit.33719560.darwin", + svm::Platform::LinuxAmd64 => "https://github.com/vyperlang/vyper/releases/download/v0.4.0rc6/vyper.0.4.0rc6+commit.33719560.linux", + svm::Platform::WindowsAmd64 => "https://github.com/vyperlang/vyper/releases/download/v0.4.0rc6/vyper.0.4.0rc6+commit.33719560.windows.exe", + _ => panic!("unsupported") + }; + + let res = reqwest::Client::builder().build().unwrap().get(url).send().await.unwrap(); + + assert!(res.status().is_success()); + + let bytes = res.bytes().await.unwrap(); + + std::fs::write(&*VYPER, bytes).unwrap(); + + #[cfg(target_family = "unix")] + std::fs::set_permissions(&*VYPER, Permissions::from_mode(0o755)).unwrap(); + + Vyper::new(&*VYPER).unwrap() + }) +} + +pub fn get_compiled(project: &mut Project) -> ProjectCompileOutput { let lock_file_path = project.sources_path().join(".lock"); // Compile only once per test run. // We need to use a file lock because `cargo-nextest` runs tests in different processes. @@ -268,21 +304,27 @@ pub fn get_compiled(project: &Project) -> ProjectCompileOutput { let mut lock = fd_lock::new_lock(&lock_file_path); let read = lock.read().unwrap(); let out; - if project.cache_path().exists() && std::fs::read(&lock_file_path).unwrap() == b"1" { - out = project.compile(); - drop(read); - } else { + + let mut write = None; + if !project.cache_path().exists() || std::fs::read(&lock_file_path).unwrap() != b"1" { drop(read); - let mut write = lock.write().unwrap(); - write.write_all(b"1").unwrap(); - out = project.compile(); - drop(write); + write = Some(lock.write().unwrap()); + } + + if project.compiler.vyper.is_none() { + project.compiler.vyper = Some(get_vyper()); } - let out = out.unwrap(); + out = project.compile().unwrap(); + if out.has_compiler_errors() { panic!("Compiled with errors:\n{out}"); } + + if let Some(ref mut write) = write { + write.write_all(b"1").unwrap(); + } + out } diff --git a/crates/forge/tests/it/vyper.rs b/crates/forge/tests/it/vyper.rs new file mode 100644 index 0000000000000..c40b87541bfb9 --- /dev/null +++ b/crates/forge/tests/it/vyper.rs @@ -0,0 +1,10 @@ +//! Integration tests for EVM specifications. + +use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; +use foundry_test_utils::Filter; + +#[tokio::test(flavor = "multi_thread")] +async fn test_basic_vyper_test() { + let filter = Filter::new("", "CounterTest", ".*vyper"); + TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter).run().await; +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 23e1f699c89d1..4a0ec81c60790 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -173,6 +173,8 @@ interface Vm { function deal(address account, uint256 newBalance) external; function deleteSnapshot(uint256 snapshotId) external returns (bool success); function deleteSnapshots() external; + function deployCode(string calldata artifactPath) 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); diff --git a/testdata/default/cheats/DeployCode.t.sol b/testdata/default/cheats/DeployCode.t.sol new file mode 100644 index 0000000000000..330e826511da7 --- /dev/null +++ b/testdata/default/cheats/DeployCode.t.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract TestContract {} + +contract TestContractWithArgs { + uint256 public a; + uint256 public b; + + constructor(uint256 _a, uint256 _b) { + a = _a; + b = _b; + } +} + +contract DeployCodeTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + address public constant overrideAddress = 0x0000000000000000000000000000000000000064; + + event Payload(address sender, address target, bytes data); + + function testDeployCode() public { + address addrDefault = address(new TestContract()); + address addrDeployCode = vm.deployCode("cheats/DeployCode.t.sol:TestContract"); + + assertEq(addrDefault.code, addrDeployCode.code); + } + + function testDeployCodeWithArgs() public { + address withNew = address(new TestContractWithArgs(1, 2)); + TestContractWithArgs withDeployCode = + TestContractWithArgs(vm.deployCode("cheats/DeployCode.t.sol:TestContractWithArgs", abi.encode(3, 4))); + + assertEq(withNew.code, address(withDeployCode).code); + assertEq(withDeployCode.a(), 3); + assertEq(withDeployCode.b(), 4); + } +} diff --git a/testdata/default/vyper/Counter.vy b/testdata/default/vyper/Counter.vy new file mode 100644 index 0000000000000..772bddd11919c --- /dev/null +++ b/testdata/default/vyper/Counter.vy @@ -0,0 +1,12 @@ +from . import ICounter +implements: ICounter + +number: public(uint256) + +@external +def set_number(new_number: uint256): + self.number = new_number + +@external +def increment(): + self.number += 1 diff --git a/testdata/default/vyper/CounterTest.vy b/testdata/default/vyper/CounterTest.vy new file mode 100644 index 0000000000000..b6cc517d25dd6 --- /dev/null +++ b/testdata/default/vyper/CounterTest.vy @@ -0,0 +1,16 @@ +from . import ICounter + +interface Vm: + def deployCode(artifact_name: String[1024], args: Bytes[1024] = b"") -> address: nonpayable + +vm: constant(Vm) = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D) +counter: ICounter + +@external +def setUp(): + self.counter = ICounter(extcall vm.deployCode("vyper/Counter.vy")) + +@external +def test_increment(): + extcall self.counter.increment() + assert staticcall self.counter.number() == 1 diff --git a/testdata/default/vyper/ICounter.vyi b/testdata/default/vyper/ICounter.vyi new file mode 100644 index 0000000000000..e600c71c87e19 --- /dev/null +++ b/testdata/default/vyper/ICounter.vyi @@ -0,0 +1,12 @@ +@view +@external +def number() -> uint256: + ... + +@external +def set_number(new_number: uint256): + ... + +@external +def increment(): + ... \ No newline at end of file From 52c20864ba2af1e36ceaaae634db695dcba981b4 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 27 Jun 2024 09:47:13 +0400 Subject: [PATCH 1157/1963] refactor: use `revm-inspectors` traces for debugger (#8249) * move calldata to DebugNode * refactor: use tracer from inspectors for debugger * fix: rm hex * clippy * bump inspectors * newline * docs * fix * fmt --- Cargo.lock | 7 +- Cargo.toml | 3 +- crates/cli/src/utils/cmd.rs | 13 +- crates/debugger/Cargo.toml | 1 + crates/debugger/src/lib.rs | 3 + crates/debugger/src/node.rs | 85 ++++++ crates/debugger/src/tui/builder.rs | 17 +- crates/debugger/src/tui/context.rs | 48 +++- crates/debugger/src/tui/draw.rs | 119 +++++---- crates/debugger/src/tui/mod.rs | 8 +- crates/evm/core/Cargo.toml | 1 - crates/evm/core/src/debug.rs | 242 ------------------ crates/evm/core/src/lib.rs | 1 - crates/evm/evm/Cargo.toml | 1 - crates/evm/evm/src/executors/fuzz/mod.rs | 14 +- crates/evm/evm/src/executors/fuzz/types.rs | 5 - .../evm/evm/src/executors/invariant/replay.rs | 4 +- crates/evm/evm/src/executors/mod.rs | 17 +- crates/evm/evm/src/inspectors/debugger.rs | 150 ----------- crates/evm/evm/src/inspectors/mod.rs | 3 - crates/evm/evm/src/inspectors/stack.rs | 57 ++--- crates/evm/evm/src/lib.rs | 2 +- crates/evm/fuzz/src/lib.rs | 5 +- crates/forge/bin/cmd/test/mod.rs | 4 +- crates/forge/src/result.rs | 6 +- crates/forge/src/runner.rs | 51 +--- crates/script/src/execute.rs | 15 +- crates/script/src/lib.rs | 4 +- crates/script/src/runner.rs | 38 +-- 29 files changed, 280 insertions(+), 644 deletions(-) create mode 100644 crates/debugger/src/node.rs delete mode 100644 crates/evm/core/src/debug.rs delete mode 100644 crates/evm/evm/src/inspectors/debugger.rs diff --git a/Cargo.lock b/Cargo.lock index 06ece26b7e83a..07ace0506a4b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3842,6 +3842,7 @@ dependencies = [ "ratatui", "revm", "revm-inspectors", + "serde", "tracing", ] @@ -3853,7 +3854,6 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-types", - "arrayvec", "eyre", "foundry-cheatcodes", "foundry-common", @@ -3900,7 +3900,6 @@ dependencies = [ "alloy-serde", "alloy-sol-types", "alloy-transport", - "arrayvec", "auto_impl", "eyre", "foundry-cheatcodes-spec", @@ -6991,9 +6990,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b0971cad2f8f1ecb10e270d80646e63bf19daef0dc0a17a45680d24bb346b7c" +checksum = "f3e260c899e462b4e189a3bfcf5a947bc3506f8bd89183859604bca009b57530" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 80df56818f002..fa1f011480575 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,7 +155,7 @@ solang-parser = "=0.3.3" # no default features to avoid c-kzg revm = { version = "10.0.0", default-features = false } revm-primitives = { version = "5.0.0", default-features = false } -revm-inspectors = { version = "0.1.2", features = ["serde"] } +revm-inspectors = { version = "0.2", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } @@ -205,7 +205,6 @@ quote = "1.0" syn = "2.0" prettyplease = "0.2.20" ahash = "0.8" -arrayvec = "0.7" base64 = "0.22" chrono = { version = "0.4", default-features = false, features = [ "clock", diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 13da8d01df8dc..8c9c124f6173c 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -11,7 +11,6 @@ use foundry_compilers::{ use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, NamedChain}; use foundry_debugger::Debugger; use foundry_evm::{ - debug::DebugArena, executors::{DeployResult, EvmError, RawCallResult}, opts::EvmOpts, traces::{ @@ -315,20 +314,14 @@ pub fn read_constructor_args_file(constructor_args_path: PathBuf) -> Result, - pub debug: Option, pub gas_used: u64, } impl TraceResult { /// Create a new [`TraceResult`] from a [`RawCallResult`]. pub fn from_raw(raw: RawCallResult, trace_kind: TraceKind) -> Self { - let RawCallResult { gas_used, traces, reverted, debug, .. } = raw; - Self { - success: !reverted, - traces: traces.map(|arena| vec![(trace_kind, arena)]), - debug, - gas_used, - } + let RawCallResult { gas_used, traces, reverted, .. } = raw; + Self { success: !reverted, traces: traces.map(|arena| vec![(trace_kind, arena)]), gas_used } } } @@ -391,7 +384,7 @@ pub async fn handle_traces( Default::default() }; let mut debugger = Debugger::builder() - .debug_arena(result.debug.as_ref().expect("missing debug arena")) + .traces(result.traces.expect("missing traces")) .decoder(&decoder) .sources(sources) .build(); diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index 812c6fdada920..094f2aa1fb6b7 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -26,3 +26,4 @@ eyre.workspace = true ratatui = { version = "0.26", default-features = false, features = ["crossterm"] } revm.workspace = true tracing.workspace = true +serde.workspace = true diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index ed5da934271a2..678ae8672d360 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -12,3 +12,6 @@ mod op; mod tui; pub use tui::{Debugger, DebuggerBuilder, ExitReason}; + +mod node; +pub use node::DebugNode; diff --git a/crates/debugger/src/node.rs b/crates/debugger/src/node.rs new file mode 100644 index 0000000000000..83477f006c8c0 --- /dev/null +++ b/crates/debugger/src/node.rs @@ -0,0 +1,85 @@ +use alloy_primitives::{Address, Bytes}; +use foundry_evm_traces::{CallKind, CallTraceArena}; +use revm_inspectors::tracing::types::{CallTraceStep, TraceMemberOrder}; +use serde::{Deserialize, Serialize}; + +/// Represents a part of the execution frame before the next call or end of the execution. +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct DebugNode { + /// Execution context. + /// + /// Note that this is the address of the *code*, not necessarily the address of the storage. + pub address: Address, + /// The kind of call this is. + pub kind: CallKind, + /// Calldata of the call. + pub calldata: Bytes, + /// The debug steps. + pub steps: Vec, +} + +impl DebugNode { + /// Creates a new debug node. + pub fn new( + address: Address, + kind: CallKind, + steps: Vec, + calldata: Bytes, + ) -> Self { + Self { address, kind, steps, calldata } + } +} + +/// Flattens given [CallTraceArena] into a list of [DebugNode]s. +/// +/// This is done by recursively traversing the call tree and collecting the steps in-between the +/// calls. +pub fn flatten_call_trace(arena: CallTraceArena, out: &mut Vec) { + #[derive(Debug, Clone, Copy)] + struct PendingNode { + node_idx: usize, + steps_count: usize, + } + + fn inner(arena: &CallTraceArena, node_idx: usize, out: &mut Vec) { + let mut pending = PendingNode { node_idx, steps_count: 0 }; + let node = &arena.nodes()[node_idx]; + for order in node.ordering.iter() { + match order { + TraceMemberOrder::Call(idx) => { + out.push(pending); + pending.steps_count = 0; + inner(arena, node.children[*idx], out); + } + TraceMemberOrder::Step(_) => { + pending.steps_count += 1; + } + _ => {} + } + } + out.push(pending); + } + let mut nodes = Vec::new(); + inner(&arena, 0, &mut nodes); + + let mut arena_nodes = arena.into_nodes(); + + for pending in nodes { + let steps = { + let other_steps = + arena_nodes[pending.node_idx].trace.steps.split_off(pending.steps_count); + std::mem::replace(&mut arena_nodes[pending.node_idx].trace.steps, other_steps) + }; + + // Skip nodes with empty steps as there's nothing to display for them. + if steps.is_empty() { + continue + } + + let call = &arena_nodes[pending.node_idx].trace; + let calldata = if call.kind.is_any_create() { Bytes::new() } else { call.data.clone() }; + let node = DebugNode::new(call.address, call.kind, steps, calldata); + + out.push(node); + } +} diff --git a/crates/debugger/src/tui/builder.rs b/crates/debugger/src/tui/builder.rs index 6289b0b8814fa..70055243ea38a 100644 --- a/crates/debugger/src/tui/builder.rs +++ b/crates/debugger/src/tui/builder.rs @@ -1,10 +1,9 @@ //! TUI debugger builder. -use crate::Debugger; +use crate::{node::flatten_call_trace, DebugNode, Debugger}; use alloy_primitives::Address; use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm_core::debug::{DebugArena, DebugNodeFlat}; -use foundry_evm_traces::CallTraceDecoder; +use foundry_evm_traces::{CallTraceArena, CallTraceDecoder, Traces}; use std::collections::HashMap; /// Debugger builder. @@ -12,7 +11,7 @@ use std::collections::HashMap; #[must_use = "builders do nothing unless you call `build` on them"] pub struct DebuggerBuilder { /// Debug traces returned from the EVM execution. - debug_arena: Vec, + debug_arena: Vec, /// Identified contracts. identified_contracts: HashMap, /// Map of source files. @@ -30,17 +29,17 @@ impl DebuggerBuilder { /// Extends the debug arena. #[inline] - pub fn debug_arenas(mut self, arena: &[DebugArena]) -> Self { - for arena in arena { - self = self.debug_arena(arena); + pub fn traces(mut self, traces: Traces) -> Self { + for (_, arena) in traces { + self = self.trace_arena(arena); } self } /// Extends the debug arena. #[inline] - pub fn debug_arena(mut self, arena: &DebugArena) -> Self { - arena.flatten_to(0, &mut self.debug_arena); + pub fn trace_arena(mut self, arena: CallTraceArena) -> Self { + flatten_call_trace(arena, &mut self.debug_arena); self } diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index 22ea7d5d32271..f4696c46e6973 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -1,10 +1,10 @@ //! Debugger context and event handler implementation. -use crate::{Debugger, ExitReason}; -use alloy_primitives::Address; +use crate::{DebugNode, Debugger, ExitReason}; +use alloy_primitives::{hex, Address}; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; -use foundry_evm_core::debug::{DebugNodeFlat, DebugStep}; -use revm_inspectors::tracing::types::CallKind; +use revm::interpreter::opcode; +use revm_inspectors::tracing::types::{CallKind, CallTraceStep}; use std::ops::ControlFlow; /// This is currently used to remember last scroll position so screen doesn't wiggle as much. @@ -84,11 +84,11 @@ impl<'a> DebuggerContext<'a> { self.gen_opcode_list(); } - pub(crate) fn debug_arena(&self) -> &[DebugNodeFlat] { + pub(crate) fn debug_arena(&self) -> &[DebugNode] { &self.debugger.debug_arena } - pub(crate) fn debug_call(&self) -> &DebugNodeFlat { + pub(crate) fn debug_call(&self) -> &DebugNode { &self.debug_arena()[self.draw_memory.inner_call_index] } @@ -103,19 +103,21 @@ impl<'a> DebuggerContext<'a> { } /// Returns the current debug steps. - pub(crate) fn debug_steps(&self) -> &[DebugStep] { + pub(crate) fn debug_steps(&self) -> &[CallTraceStep] { &self.debug_call().steps } /// Returns the current debug step. - pub(crate) fn current_step(&self) -> &DebugStep { + pub(crate) fn current_step(&self) -> &CallTraceStep { &self.debug_steps()[self.current_step] } fn gen_opcode_list(&mut self) { self.opcode_list.clear(); let debug_steps = &self.debugger.debug_arena[self.draw_memory.inner_call_index].steps; - self.opcode_list.extend(debug_steps.iter().map(DebugStep::pretty_opcode)); + for (i, step) in debug_steps.iter().enumerate() { + self.opcode_list.push(pretty_opcode(step, debug_steps.get(i + 1))); + } } fn gen_opcode_list_if_necessary(&mut self) { @@ -127,8 +129,8 @@ impl<'a> DebuggerContext<'a> { fn active_buffer(&self) -> &[u8] { match self.active_buffer { - BufferKind::Memory => &self.current_step().memory, - BufferKind::Calldata => &self.current_step().calldata, + BufferKind::Memory => self.current_step().memory.as_bytes(), + BufferKind::Calldata => &self.debug_call().calldata, BufferKind::Returndata => &self.current_step().returndata, } } @@ -186,7 +188,8 @@ impl DebuggerContext<'_> { }), // Scroll down the stack KeyCode::Char('J') => self.repeat(|this| { - let max_stack = this.current_step().stack.len().saturating_sub(1); + let max_stack = + this.current_step().stack.as_ref().map_or(0, |s| s.len()).saturating_sub(1); if this.draw_memory.current_stack_startline < max_stack { this.draw_memory.current_stack_startline += 1; } @@ -345,3 +348,24 @@ fn buffer_as_number(s: &str) -> usize { const MAX: usize = 100_000; s.parse().unwrap_or(MIN).clamp(MIN, MAX) } + +fn pretty_opcode(step: &CallTraceStep, next_step: Option<&CallTraceStep>) -> String { + let op = step.op; + let instruction = op.get(); + let push_size = if (opcode::PUSH1..=opcode::PUSH32).contains(&instruction) { + (instruction - opcode::PUSH0) as usize + } else { + 0 + }; + if push_size == 0 { + return step.op.to_string(); + } + + // Get push byte as the top-most stack item on the next step + if let Some(pushed) = next_step.and_then(|s| s.stack.as_ref()).and_then(|s| s.last()) { + let bytes = &pushed.to_be_bytes_vec()[32 - push_size..]; + format!("{op}(0x{})", hex::encode(bytes)) + } else { + op.to_string() + } +} diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 7ac0c64e5c6e0..e53910626835a 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -429,7 +429,7 @@ impl DebuggerContext<'_> { "Address: {} | PC: {} | Gas used in call: {}", self.address(), self.current_step().pc, - self.current_step().total_gas_used, + self.current_step().gas_used, ); let block = Block::default().title(title).borders(Borders::ALL); let list = List::new(items) @@ -443,58 +443,67 @@ impl DebuggerContext<'_> { fn draw_stack(&self, f: &mut Frame<'_>, area: Rect) { let step = self.current_step(); - let stack = &step.stack; + let stack = step.stack.as_ref(); + let stack_len = stack.map_or(0, |s| s.len()); - let min_len = decimal_digits(stack.len()).max(2); + let min_len = decimal_digits(stack_len).max(2); - let params = OpcodeParam::of(step.instruction); + let params = OpcodeParam::of(step.op.get()); let text: Vec> = stack - .iter() - .rev() - .enumerate() - .skip(self.draw_memory.current_stack_startline) - .map(|(i, stack_item)| { - let param = params.iter().find(|param| param.index == i); - - let mut spans = Vec::with_capacity(1 + 32 * 2 + 3); - - // Stack index. - spans.push(Span::styled(format!("{i:0min_len$}| "), Style::new().fg(Color::White))); - - // Item hex bytes. - hex_bytes_spans(&stack_item.to_be_bytes::<32>(), &mut spans, |_, _| { - if param.is_some() { - Style::new().fg(Color::Cyan) - } else { - Style::new().fg(Color::White) - } - }); + .map(|stack| { + stack + .iter() + .rev() + .enumerate() + .skip(self.draw_memory.current_stack_startline) + .map(|(i, stack_item)| { + let param = params.iter().find(|param| param.index == i); + + let mut spans = Vec::with_capacity(1 + 32 * 2 + 3); + + // Stack index. + spans.push(Span::styled( + format!("{i:0min_len$}| "), + Style::new().fg(Color::White), + )); + + // Item hex bytes. + hex_bytes_spans(&stack_item.to_be_bytes::<32>(), &mut spans, |_, _| { + if param.is_some() { + Style::new().fg(Color::Cyan) + } else { + Style::new().fg(Color::White) + } + }); - if self.stack_labels { - if let Some(param) = param { - spans.push(Span::raw("| ")); - spans.push(Span::raw(param.name)); - } - } + if self.stack_labels { + if let Some(param) = param { + spans.push(Span::raw("| ")); + spans.push(Span::raw(param.name)); + } + } - spans.push(Span::raw("\n")); + spans.push(Span::raw("\n")); - Line::from(spans) + Line::from(spans) + }) + .collect() }) - .collect(); + .unwrap_or_default(); - let title = format!("Stack: {}", stack.len()); + let title = format!("Stack: {stack_len}"); let block = Block::default().title(title).borders(Borders::ALL); let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true }); f.render_widget(paragraph, area); } fn draw_buffer(&self, f: &mut Frame<'_>, area: Rect) { + let call = self.debug_call(); let step = self.current_step(); let buf = match self.active_buffer { BufferKind::Memory => step.memory.as_ref(), - BufferKind::Calldata => step.calldata.as_ref(), + BufferKind::Calldata => call.calldata.as_ref(), BufferKind::Returndata => step.returndata.as_ref(), }; @@ -506,18 +515,20 @@ impl DebuggerContext<'_> { let mut write_offset = None; let mut write_size = None; let mut color = None; - let stack_len = step.stack.len(); + let stack_len = step.stack.as_ref().map_or(0, |s| s.len()); if stack_len > 0 { - if let Some(accesses) = get_buffer_accesses(step.instruction, &step.stack) { - if let Some(read_access) = accesses.read { - offset = Some(read_access.1.offset); - size = Some(read_access.1.size); - color = Some(Color::Cyan); - } - if let Some(write_access) = accesses.write { - if self.active_buffer == BufferKind::Memory { - write_offset = Some(write_access.offset); - write_size = Some(write_access.size); + if let Some(stack) = step.stack.as_ref() { + if let Some(accesses) = get_buffer_accesses(step.op.get(), stack) { + if let Some(read_access) = accesses.read { + offset = Some(read_access.1.offset); + size = Some(read_access.1.size); + color = Some(Color::Cyan); + } + if let Some(write_access) = accesses.write { + if self.active_buffer == BufferKind::Memory { + write_offset = Some(write_access.offset); + write_size = Some(write_access.size); + } } } } @@ -530,13 +541,15 @@ impl DebuggerContext<'_> { if self.current_step > 0 { let prev_step = self.current_step - 1; let prev_step = &self.debug_steps()[prev_step]; - if let Some(write_access) = - get_buffer_accesses(prev_step.instruction, &prev_step.stack).and_then(|a| a.write) - { - if self.active_buffer == BufferKind::Memory { - offset = Some(write_access.offset); - size = Some(write_access.size); - color = Some(Color::Green); + if let Some(stack) = prev_step.stack.as_ref() { + if let Some(write_access) = + get_buffer_accesses(prev_step.op.get(), stack).and_then(|a| a.write) + { + if self.active_buffer == BufferKind::Memory { + offset = Some(write_access.offset); + size = Some(write_access.size); + color = Some(Color::Green); + } } } } diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index c810440e5b133..facbd9e69f130 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -8,7 +8,7 @@ use crossterm::{ }; use eyre::Result; use foundry_common::{compile::ContractSources, evm::Breakpoints}; -use foundry_evm_core::{debug::DebugNodeFlat, utils::PcIcMap}; +use foundry_evm_core::utils::PcIcMap; use ratatui::{ backend::{Backend, CrosstermBackend}, Terminal, @@ -28,6 +28,8 @@ pub use builder::DebuggerBuilder; mod context; use context::DebuggerContext; +use crate::DebugNode; + mod draw; type DebuggerTerminal = Terminal>; @@ -41,7 +43,7 @@ pub enum ExitReason { /// The TUI debugger. pub struct Debugger { - debug_arena: Vec, + debug_arena: Vec, identified_contracts: HashMap, /// Source map of contract sources contracts_sources: ContractSources, @@ -59,7 +61,7 @@ impl Debugger { /// Creates a new debugger. pub fn new( - debug_arena: Vec, + debug_arena: Vec, identified_contracts: HashMap, contracts_sources: ContractSources, breakpoints: Breakpoints, diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 7369e55032fb3..45d710e5580d1 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -47,7 +47,6 @@ revm = { workspace = true, features = [ ] } revm-inspectors.workspace = true -arrayvec.workspace = true auto_impl.workspace = true eyre.workspace = true futures.workspace = true diff --git a/crates/evm/core/src/debug.rs b/crates/evm/core/src/debug.rs deleted file mode 100644 index bde6e338c754e..0000000000000 --- a/crates/evm/core/src/debug.rs +++ /dev/null @@ -1,242 +0,0 @@ -use crate::opcodes; -use alloy_primitives::{hex, Address, Bytes, U256}; -use arrayvec::ArrayVec; -use revm::interpreter::OpCode; -use revm_inspectors::tracing::types::CallKind; -use serde::{Deserialize, Serialize}; - -/// An arena of [DebugNode]s -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct DebugArena { - /// The arena of nodes - pub arena: Vec, -} - -impl Default for DebugArena { - fn default() -> Self { - Self::new() - } -} - -impl DebugArena { - /// Creates a new debug arena. - pub const fn new() -> Self { - Self { arena: Vec::new() } - } - - /// Pushes a new debug node into the arena - pub fn push_node(&mut self, mut new_node: DebugNode) -> usize { - fn recursively_push( - arena: &mut Vec, - entry: usize, - mut new_node: DebugNode, - ) -> usize { - match new_node.depth { - // We found the parent node, add the new node as a child - _ if arena[entry].depth == new_node.depth - 1 => { - let id = arena.len(); - new_node.location = arena[entry].children.len(); - new_node.parent = Some(entry); - arena[entry].children.push(id); - arena.push(new_node); - id - } - // We haven't found the parent node, go deeper - _ => { - let child = *arena[entry].children.last().expect("Disconnected debug node"); - recursively_push(arena, child, new_node) - } - } - } - - if self.arena.is_empty() { - // This is the initial node at depth 0, so we just insert it. - self.arena.push(new_node); - 0 - } else if new_node.depth == 0 { - // This is another node at depth 0, for example instructions between calls. We insert - // it as a child of the original root node. - let id = self.arena.len(); - new_node.location = self.arena[0].children.len(); - new_node.parent = Some(0); - self.arena[0].children.push(id); - self.arena.push(new_node); - id - } else { - // We try to find the parent of this node recursively - recursively_push(&mut self.arena, 0, new_node) - } - } - - /// Recursively traverses the tree of debug nodes and flattens it into a [Vec] where each - /// item contains: - /// - /// - The address of the contract being executed - /// - A [Vec] of debug steps along that contract's execution path - /// - An enum denoting the type of call this is - /// - /// This makes it easy to pretty print the execution steps. - pub fn flatten(&self, entry: usize) -> Vec { - let mut flattened = Vec::new(); - self.flatten_to(entry, &mut flattened); - flattened - } - - /// Recursively traverses the tree of debug nodes and flattens it into the given list. - /// - /// See [`flatten`](Self::flatten) for more information. - pub fn flatten_to(&self, entry: usize, out: &mut Vec) { - let node = &self.arena[entry]; - - if !node.steps.is_empty() { - out.push(node.flat()); - } - - for child in &node.children { - self.flatten_to(*child, out); - } - } -} - -/// A node in the arena. -#[derive(Clone, Debug, Default, Serialize, Deserialize)] -pub struct DebugNode { - /// Parent node index in the arena. - pub parent: Option, - /// Children node indexes in the arena. - pub children: Vec, - /// Location in parent. - pub location: usize, - /// Execution context. - /// - /// Note that this is the address of the *code*, not necessarily the address of the storage. - pub address: Address, - /// The kind of call this is. - pub kind: CallKind, - /// Depth of the call. - pub depth: usize, - /// The debug steps. - pub steps: Vec, -} - -impl From for DebugNodeFlat { - #[inline] - fn from(node: DebugNode) -> Self { - node.into_flat() - } -} - -impl From<&DebugNode> for DebugNodeFlat { - #[inline] - fn from(node: &DebugNode) -> Self { - node.flat() - } -} - -impl DebugNode { - /// Creates a new debug node. - pub fn new(address: Address, depth: usize, steps: Vec) -> Self { - Self { address, depth, steps, ..Default::default() } - } - - /// Flattens this node into a [`DebugNodeFlat`]. - pub fn flat(&self) -> DebugNodeFlat { - DebugNodeFlat { address: self.address, kind: self.kind, steps: self.steps.clone() } - } - - /// Flattens this node into a [`DebugNodeFlat`]. - pub fn into_flat(self) -> DebugNodeFlat { - DebugNodeFlat { address: self.address, kind: self.kind, steps: self.steps } - } -} - -/// Flattened [`DebugNode`] from an arena. -#[derive(Clone, Debug, Default, Serialize, Deserialize)] -pub struct DebugNodeFlat { - /// Execution context. - /// - /// Note that this is the address of the *code*, not necessarily the address of the storage. - pub address: Address, - /// The kind of call this is. - pub kind: CallKind, - /// The debug steps. - pub steps: Vec, -} - -impl DebugNodeFlat { - /// Creates a new debug node flat. - pub fn new(address: Address, kind: CallKind, steps: Vec) -> Self { - Self { address, kind, steps } - } -} - -/// A `DebugStep` is a snapshot of the EVM's runtime state. -/// -/// It holds the current program counter (where in the program you are), -/// the stack and memory (prior to the opcodes execution), any bytes to be -/// pushed onto the stack, and the instruction counter for use with sourcemap. -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct DebugStep { - /// Stack *prior* to running the associated opcode - pub stack: Vec, - /// Memory *prior* to running the associated opcode - pub memory: Bytes, - /// Calldata *prior* to running the associated opcode - pub calldata: Bytes, - /// Returndata *prior* to running the associated opcode - pub returndata: Bytes, - /// Opcode to be executed - pub instruction: u8, - /// Optional bytes that are being pushed onto the stack. - /// Empty if the opcode is not a push or PUSH0. - #[serde(serialize_with = "hex::serialize", deserialize_with = "deserialize_arrayvec_hex")] - pub push_bytes: ArrayVec, - /// The program counter at this step. - /// - /// Note: To map this step onto source code using a source map, you must convert the program - /// counter to an instruction counter. - pub pc: usize, - /// Cumulative gas usage - pub total_gas_used: u64, -} - -impl Default for DebugStep { - fn default() -> Self { - Self { - stack: vec![], - memory: Default::default(), - calldata: Default::default(), - returndata: Default::default(), - instruction: revm::interpreter::opcode::INVALID, - push_bytes: Default::default(), - pc: 0, - total_gas_used: 0, - } - } -} - -impl DebugStep { - /// Pretty print the step's opcode - pub fn pretty_opcode(&self) -> String { - let instruction = OpCode::new(self.instruction).map_or("INVALID", |op| op.as_str()); - if !self.push_bytes.is_empty() { - format!("{instruction}(0x{})", hex::encode(&self.push_bytes)) - } else { - instruction.to_string() - } - } - - /// Returns `true` if the opcode modifies memory. - pub fn opcode_modifies_memory(&self) -> bool { - OpCode::new(self.instruction).map_or(false, opcodes::modifies_memory) - } -} - -fn deserialize_arrayvec_hex<'de, D: serde::Deserializer<'de>>( - deserializer: D, -) -> Result, D::Error> { - let bytes: Vec = hex::deserialize(deserializer)?; - let mut array = ArrayVec::new(); - array.try_extend_from_slice(&bytes).map_err(serde::de::Error::custom)?; - Ok(array) -} diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 43bf5f3d4b311..12297e8064024 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -21,7 +21,6 @@ mod ic; pub mod backend; pub mod constants; -pub mod debug; pub mod decode; pub mod fork; pub mod opcodes; diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index bcd933a4bc73d..39b48d1107bad 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -44,7 +44,6 @@ revm = { workspace = true, default-features = false, features = [ ] } revm-inspectors.workspace = true -arrayvec.workspace = true eyre.workspace = true parking_lot.workspace = true proptest = "1" diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 9cd406f621958..5de2590148f4a 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -3,6 +3,7 @@ use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; +use foundry_common::evm::Breakpoints; use foundry_config::FuzzConfig; use foundry_evm_core::{ constants::MAGIC_ASSUME, @@ -80,6 +81,9 @@ impl FuzzedExecutor { // Stores coverage information for all fuzz cases let coverage: RefCell> = RefCell::default(); + // Stores breakpoints for the last fuzz case. + let breakpoints: RefCell> = RefCell::default(); + let state = self.build_fuzz_state(); let dictionary_weight = self.config.dictionary.dictionary_weight.min(100); @@ -110,6 +114,7 @@ impl FuzzedExecutor { traces.borrow_mut().pop(); } traces.borrow_mut().push(call_traces); + breakpoints.borrow_mut().replace(case.breakpoints); } match &mut *coverage.borrow_mut() { @@ -140,7 +145,11 @@ impl FuzzedExecutor { let (calldata, call) = counterexample.into_inner(); let mut traces = traces.into_inner(); - let last_run_traces = if run_result.is_ok() { traces.pop() } else { call.traces.clone() }; + let (last_run_traces, last_run_breakpoints) = if run_result.is_ok() { + (traces.pop(), breakpoints.into_inner()) + } else { + (call.traces.clone(), call.cheatcodes.map(|c| c.breakpoints)) + }; let mut result = FuzzTestResult { first_case: first_case.take().unwrap_or_default(), @@ -152,6 +161,7 @@ impl FuzzedExecutor { logs: call.logs, labeled_addresses: call.labels, traces: last_run_traces, + breakpoints: last_run_breakpoints, gas_report_traces: traces, coverage: coverage.into_inner(), }; @@ -219,12 +229,10 @@ impl FuzzedExecutor { case: FuzzCase { calldata, gas: call.gas_used, stipend: call.stipend }, traces: call.traces, coverage: call.coverage, - debug: call.debug, breakpoints, })) } else { Ok(FuzzOutcome::CounterExample(CounterExampleOutcome { - debug: call.debug.clone(), exit_reason: call.exit_reason, counterexample: (calldata, call), breakpoints, diff --git a/crates/evm/evm/src/executors/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs index b15cf3faae3ca..93931f5b0a96b 100644 --- a/crates/evm/evm/src/executors/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -1,7 +1,6 @@ use crate::executors::RawCallResult; use alloy_primitives::Bytes; use foundry_common::evm::Breakpoints; -use foundry_evm_core::debug::DebugArena; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::FuzzCase; use foundry_evm_traces::CallTraceArena; @@ -16,8 +15,6 @@ pub struct CaseOutcome { pub traces: Option, /// The coverage info collected during the call pub coverage: Option, - /// The debug nodes of the call - pub debug: Option, /// Breakpoints char pc map pub breakpoints: Breakpoints, } @@ -29,8 +26,6 @@ pub struct CounterExampleOutcome { pub counterexample: (Bytes, RawCallResult), /// The status of the call pub exit_reason: InstructionResult, - /// The debug nodes of the call - pub debug: Option, /// Breakpoints char pc map pub breakpoints: Breakpoints, } diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index e985cf7ba17e2..391bf998804b5 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -33,7 +33,9 @@ pub fn replay_run( inputs: &[BasicTxDetails], ) -> Result> { // We want traces for a failed case. - executor.set_tracing(true); + if executor.inspector().tracer.is_none() { + executor.set_tracing(true, false); + } let mut counterexample_sequence = vec![]; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index ff621a5e20f9b..09fd620f5f232 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -19,7 +19,6 @@ use foundry_evm_core::{ CALLER, CHEATCODE_ADDRESS, CHEATCODE_CONTRACT_HASH, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, }, - debug::DebugArena, decode::RevertDecoder, utils::StateChangeset, }; @@ -212,14 +211,8 @@ impl Executor { } #[inline] - pub fn set_tracing(&mut self, tracing: bool) -> &mut Self { - self.inspector_mut().tracing(tracing); - self - } - - #[inline] - pub fn set_debugger(&mut self, debugger: bool) -> &mut Self { - self.inspector_mut().enable_debugger(debugger); + pub fn set_tracing(&mut self, tracing: bool, debug: bool) -> &mut Self { + self.inspector_mut().tracing(tracing, debug); self } @@ -713,8 +706,6 @@ pub struct RawCallResult { pub traces: Option, /// The coverage info collected during the call pub coverage: Option, - /// The debug nodes of the call - pub debug: Option, /// Scripted transactions generated from this call pub transactions: Option, /// The changeset of the state. @@ -743,7 +734,6 @@ impl Default for RawCallResult { labels: HashMap::new(), traces: None, coverage: None, - debug: None, transactions: None, state_changeset: HashMap::default(), env: EnvWithHandlerCfg::new_with_spec_id(Box::default(), SpecId::LATEST), @@ -856,7 +846,7 @@ fn convert_executed_result( _ => Bytes::new(), }; - let InspectorData { mut logs, labels, traces, coverage, debug, cheatcodes, chisel_state } = + let InspectorData { mut logs, labels, traces, coverage, cheatcodes, chisel_state } = inspector.collect(); if logs.is_empty() { @@ -880,7 +870,6 @@ fn convert_executed_result( labels, traces, coverage, - debug, transactions, state_changeset, env, diff --git a/crates/evm/evm/src/inspectors/debugger.rs b/crates/evm/evm/src/inspectors/debugger.rs deleted file mode 100644 index c970cd67103e0..0000000000000 --- a/crates/evm/evm/src/inspectors/debugger.rs +++ /dev/null @@ -1,150 +0,0 @@ -use alloy_primitives::Address; -use arrayvec::ArrayVec; -use foundry_common::ErrorExt; -use foundry_evm_core::{ - backend::DatabaseExt, - debug::{DebugArena, DebugNode, DebugStep}, - utils::gas_used, -}; -use revm::{ - interpreter::{ - opcode, CallInputs, CallOutcome, CreateInputs, CreateOutcome, Gas, InstructionResult, - Interpreter, InterpreterResult, - }, - EvmContext, Inspector, -}; -use revm_inspectors::tracing::types::CallKind; - -/// An inspector that collects debug nodes on every step of the interpreter. -#[derive(Clone, Debug, Default)] -pub struct Debugger { - /// The arena of [DebugNode]s - pub arena: DebugArena, - /// The ID of the current [DebugNode]. - pub head: usize, - /// The current execution address. - pub context: Address, -} - -impl Debugger { - /// Enters a new execution context. - pub fn enter(&mut self, depth: usize, address: Address, kind: CallKind) { - self.context = address; - self.head = self.arena.push_node(DebugNode { depth, address, kind, ..Default::default() }); - } - - /// Exits the current execution context, replacing it with the previous one. - pub fn exit(&mut self) { - if let Some(parent_id) = self.arena.arena[self.head].parent { - let DebugNode { depth, address, kind, .. } = self.arena.arena[parent_id]; - self.enter(depth, address, kind); - } - } -} - -impl Inspector for Debugger { - fn step(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext) { - let pc = interp.program_counter(); - let op = interp.current_opcode(); - - // Extract the push bytes - let push_size = if (opcode::PUSH1..=opcode::PUSH32).contains(&op) { - (op - opcode::PUSH0) as usize - } else { - 0 - }; - let push_bytes = (push_size > 0).then(|| { - let start = pc + 1; - let end = start + push_size; - let slice = &interp.contract.bytecode.bytecode()[start..end]; - debug_assert!(slice.len() <= 32); - let mut array = ArrayVec::new(); - array.try_extend_from_slice(slice).unwrap(); - array - }); - - let total_gas_used = gas_used( - ecx.spec_id(), - interp.gas.limit().saturating_sub(interp.gas.remaining()), - interp.gas.refunded() as u64, - ); - - // Reuse the memory from the previous step if the previous opcode did not modify it. - let memory = self.arena.arena[self.head] - .steps - .last() - .filter(|step| !step.opcode_modifies_memory()) - .map(|step| step.memory.clone()) - .unwrap_or_else(|| interp.shared_memory.context_memory().to_vec().into()); - - self.arena.arena[self.head].steps.push(DebugStep { - pc, - stack: interp.stack().data().clone(), - memory, - calldata: interp.contract().input.clone(), - returndata: interp.return_data_buffer.clone(), - instruction: op, - push_bytes: push_bytes.unwrap_or_default(), - total_gas_used, - }); - } - - fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { - self.enter( - ecx.journaled_state.depth() as usize, - inputs.bytecode_address, - inputs.scheme.into(), - ); - - None - } - - fn call_end( - &mut self, - _context: &mut EvmContext, - _inputs: &CallInputs, - outcome: CallOutcome, - ) -> CallOutcome { - self.exit(); - - outcome - } - - fn create( - &mut self, - ecx: &mut EvmContext, - inputs: &mut CreateInputs, - ) -> Option { - if let Err(err) = ecx.load_account(inputs.caller) { - let gas = Gas::new(inputs.gas_limit); - return Some(CreateOutcome::new( - InterpreterResult { - result: InstructionResult::Revert, - output: err.abi_encode_revert(), - gas, - }, - None, - )); - } - - let nonce = ecx.journaled_state.account(inputs.caller).info.nonce; - self.enter( - ecx.journaled_state.depth() as usize, - inputs.created_address(nonce), - CallKind::Create, - ); - - None - } - - fn create_end( - &mut self, - _context: &mut EvmContext, - _inputs: &CreateInputs, - outcome: CreateOutcome, - ) -> CreateOutcome { - self.exit(); - - outcome - } -} diff --git a/crates/evm/evm/src/inspectors/mod.rs b/crates/evm/evm/src/inspectors/mod.rs index 786786b28e926..41008397a1cbc 100644 --- a/crates/evm/evm/src/inspectors/mod.rs +++ b/crates/evm/evm/src/inspectors/mod.rs @@ -10,9 +10,6 @@ pub use revm_inspectors::access_list::AccessListInspector; mod chisel_state; pub use chisel_state::ChiselState; -mod debugger; -pub use debugger::Debugger; - mod logs; pub use logs::LogCollector; diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index e290a55fc7c15..b098d878a96d4 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -1,12 +1,11 @@ use super::{ - Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Debugger, Fuzzer, LogCollector, + Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Fuzzer, LogCollector, StackSnapshotType, TracingInspector, TracingInspectorConfig, }; use alloy_primitives::{Address, Bytes, Log, TxKind, U256}; use foundry_cheatcodes::CheatcodesExecutor; use foundry_evm_core::{ backend::{update_state, DatabaseExt}, - debug::DebugArena, InspectorExt, }; use foundry_evm_coverage::HitMaps; @@ -47,7 +46,7 @@ pub struct InspectorStackBuilder { pub fuzzer: Option, /// Whether to enable tracing. pub trace: Option, - /// Whether to enable the debugger. + /// Whether to enable debug traces. pub debug: Option, /// Whether logs should be collected. pub logs: Option, @@ -177,9 +176,8 @@ impl InspectorStackBuilder { } stack.collect_coverage(coverage.unwrap_or(false)); stack.collect_logs(logs.unwrap_or(true)); - stack.enable_debugger(debug.unwrap_or(false)); stack.print(print.unwrap_or(false)); - stack.tracing(trace.unwrap_or(false)); + stack.tracing(trace.unwrap_or(false), debug.unwrap_or(false)); stack.enable_isolation(enable_isolation); @@ -243,7 +241,6 @@ pub struct InspectorData { pub logs: Vec, pub labels: HashMap, pub traces: Option, - pub debug: Option, pub coverage: Option, pub cheatcodes: Option, pub chisel_state: Option<(Vec, Vec, InstructionResult)>, @@ -290,7 +287,6 @@ pub struct InspectorStack { pub struct InspectorStackInner { pub chisel_state: Option, pub coverage: Option, - pub debugger: Option, pub fuzzer: Option, pub log_collector: Option, pub printer: Option, @@ -343,7 +339,7 @@ impl InspectorStack { )* }; } - push!(cheatcodes, chisel_state, coverage, debugger, fuzzer, log_collector, printer, tracer); + push!(cheatcodes, chisel_state, coverage, fuzzer, log_collector, printer, tracer); if self.enable_isolation { enabled.push("isolation"); } @@ -398,12 +394,6 @@ impl InspectorStack { self.coverage = yes.then(Default::default); } - /// Set whether to enable the debugger. - #[inline] - pub fn enable_debugger(&mut self, yes: bool) { - self.debugger = yes.then(Default::default); - } - /// Set whether to enable call isolation. #[inline] pub fn enable_isolation(&mut self, yes: bool) { @@ -424,15 +414,21 @@ impl InspectorStack { /// Set whether to enable the tracer. #[inline] - pub fn tracing(&mut self, yes: bool) { + pub fn tracing(&mut self, yes: bool, debug: bool) { self.tracer = yes.then(|| { TracingInspector::new(TracingInspectorConfig { - record_steps: false, - record_memory_snapshots: false, - record_stack_snapshots: StackSnapshotType::None, + record_steps: debug, + record_memory_snapshots: debug, + record_stack_snapshots: if debug { + StackSnapshotType::Full + } else { + StackSnapshotType::None + }, record_state_diff: false, exclude_precompile_calls: false, record_logs: true, + record_opcodes_filter: None, + record_returndata_snapshots: debug, }) }); } @@ -442,8 +438,7 @@ impl InspectorStack { pub fn collect(self) -> InspectorData { let Self { cheatcodes, - inner: - InspectorStackInner { chisel_state, coverage, debugger, log_collector, tracer, .. }, + inner: InspectorStackInner { chisel_state, coverage, log_collector, tracer, .. }, } = self; InspectorData { @@ -453,7 +448,6 @@ impl InspectorStack { .map(|cheatcodes| cheatcodes.labels.clone()) .unwrap_or_default(), traces: tracer.map(|tracer| tracer.get_traces().clone()), - debug: debugger.map(|debugger| debugger.arena), coverage: coverage.map(|coverage| coverage.maps), cheatcodes, chisel_state: chisel_state.and_then(|state| state.state), @@ -493,13 +487,7 @@ impl<'a> InspectorStackRefMut<'a> { let result = outcome.result.result; call_inspectors_adjust_depth!( #[ret] - [ - &mut self.fuzzer, - &mut self.debugger, - &mut self.tracer, - &mut self.cheatcodes, - &mut self.printer, - ], + [&mut self.fuzzer, &mut self.tracer, &mut self.cheatcodes, &mut self.printer,], |inspector| { let new_outcome = inspector.call_end(ecx, inputs, outcome.clone()); @@ -663,7 +651,6 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { call_inspectors_adjust_depth!( [ &mut self.fuzzer, - &mut self.debugger, &mut self.tracer, &mut self.coverage, &mut self.cheatcodes, @@ -701,13 +688,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { call_inspectors_adjust_depth!( #[ret] - [ - &mut self.fuzzer, - &mut self.debugger, - &mut self.tracer, - &mut self.log_collector, - &mut self.printer, - ], + [&mut self.fuzzer, &mut self.tracer, &mut self.log_collector, &mut self.printer,], |inspector| { let mut out = None; if let Some(output) = inspector.call(ecx, call) { @@ -785,7 +766,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { call_inspectors_adjust_depth!( #[ret] - [&mut self.debugger, &mut self.tracer, &mut self.coverage, &mut self.cheatcodes], + [&mut self.tracer, &mut self.coverage, &mut self.cheatcodes], |inspector| inspector.create(ecx, create).map(Some), self, ecx @@ -826,7 +807,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { call_inspectors_adjust_depth!( #[ret] - [&mut self.debugger, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], + [&mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| { let new_outcome = inspector.create_end(ecx, call, outcome.clone()); diff --git a/crates/evm/evm/src/lib.rs b/crates/evm/evm/src/lib.rs index 598012770a450..8bbd7f1414d84 100644 --- a/crates/evm/evm/src/lib.rs +++ b/crates/evm/evm/src/lib.rs @@ -11,7 +11,7 @@ extern crate tracing; pub mod executors; pub mod inspectors; -pub use foundry_evm_core::{backend, constants, debug, decode, fork, opts, utils, InspectorExt}; +pub use foundry_evm_core::{backend, constants, decode, fork, opts, utils, InspectorExt}; pub use foundry_evm_coverage as coverage; pub use foundry_evm_fuzz as fuzz; pub use foundry_evm_traces as traces; diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index f675e775542e1..e3ee6a05ed027 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -10,7 +10,7 @@ extern crate tracing; use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; use alloy_primitives::{Address, Bytes, Log}; -use foundry_common::{calc, contracts::ContractsByAddress}; +use foundry_common::{calc, contracts::ContractsByAddress, evm::Breakpoints}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::CallTraceArena; use itertools::Itertools; @@ -181,6 +181,9 @@ pub struct FuzzTestResult { /// Raw coverage info pub coverage: Option, + + /// Breakpoints for debugger. Correspond to the same fuzz case as `traces`. + pub breakpoints: Option, } impl FuzzTestResult { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 6f65dcfec5b45..6b2931de34817 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -343,7 +343,9 @@ impl TestArgs { // Run the debugger. let mut builder = Debugger::builder() - .debug_arenas(test_result.debug.as_slice()) + .traces( + test_result.traces.iter().filter(|(t, _)| t.is_execution()).cloned().collect(), + ) .sources(sources) .breakpoints(test_result.breakpoints.clone()); if let Some(decoder) = &outcome.last_run_decoder { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index cdd2caf51807e..e7c0b6101eb9b 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -10,7 +10,6 @@ use eyre::Report; use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ coverage::HitMaps, - debug::DebugArena, executors::{EvmError, RawCallResult}, fuzz::{CounterExample, FuzzCase, FuzzFixtures, FuzzTestResult}, traces::{CallTraceArena, CallTraceDecoder, TraceKind, Traces}, @@ -378,9 +377,6 @@ pub struct TestResult { /// Labeled addresses pub labeled_addresses: HashMap, - /// The debug nodes of the call - pub debug: Option, - pub duration: Duration, /// pc breakpoint char map @@ -488,7 +484,6 @@ impl TestResult { }; self.reason = reason; self.decoded_logs = decode_console_logs(&self.logs); - self.debug = raw_call_result.debug; self.breakpoints = raw_call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); self.duration = Duration::default(); self.gas_report_traces = Vec::new(); @@ -520,6 +515,7 @@ impl TestResult { self.decoded_logs = decode_console_logs(&self.logs); self.duration = Duration::default(); self.gas_report_traces = result.gas_report_traces.into_iter().map(|t| vec![t]).collect(); + self.breakpoints = result.breakpoints.unwrap_or_default(); self } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index a1cffc6d2c335..59f903c9c6530 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -20,7 +20,7 @@ use foundry_evm::{ constants::CALLER, decode::RevertDecoder, executors::{ - fuzz::{CaseOutcome, CounterExampleOutcome, FuzzOutcome, FuzzedExecutor}, + fuzz::FuzzedExecutor, invariant::{ check_sequence, replay_error, replay_run, InvariantExecutor, InvariantFuzzError, InvariantFuzzTestResult, @@ -312,13 +312,13 @@ impl<'a> ContractRunner<'a> { let tmp_tracing = self.executor.inspector().tracer.is_none() && has_invariants && call_setup; if tmp_tracing { - self.executor.set_tracing(true); + self.executor.set_tracing(true, false); } let setup_time = Instant::now(); let setup = self.setup(call_setup); debug!("finished setting up in {:?}", setup_time.elapsed()); if tmp_tracing { - self.executor.set_tracing(false); + self.executor.set_tracing(false, false); } if setup.reason.is_some() { @@ -626,16 +626,12 @@ impl<'a> ContractRunner<'a> { ) -> TestResult { let address = setup.address; let fuzz_fixtures = setup.fuzz_fixtures.clone(); - let mut test_result = TestResult::new(setup); + let test_result = TestResult::new(setup); // Run fuzz test let progress = start_fuzz_progress(self.progress, self.name, &func.name, fuzz_config.runs); - let fuzzed_executor = FuzzedExecutor::new( - self.executor.clone(), - runner.clone(), - self.sender, - fuzz_config.clone(), - ); + let fuzzed_executor = + FuzzedExecutor::new(self.executor.clone(), runner, self.sender, fuzz_config); let result = fuzzed_executor.fuzz( func, &fuzz_fixtures, @@ -651,41 +647,6 @@ impl<'a> ContractRunner<'a> { return test_result.single_skip() } - if self.debug { - let mut debug_executor = self.executor.clone(); - // turn the debug traces on - debug_executor.inspector_mut().enable_debugger(true); - debug_executor.inspector_mut().tracing(true); - let calldata = if let Some(counterexample) = result.counterexample.as_ref() { - match counterexample { - CounterExample::Single(ce) => ce.calldata.clone(), - _ => unimplemented!(), - } - } else { - result.first_case.calldata.clone() - }; - // rerun the last relevant test with traces - let debug_result = - FuzzedExecutor::new(debug_executor, runner, self.sender, fuzz_config).single_fuzz( - address, - should_fail, - calldata, - ); - - (test_result.debug, test_result.breakpoints) = match debug_result { - Ok(fuzz_outcome) => match fuzz_outcome { - FuzzOutcome::Case(CaseOutcome { debug, breakpoints, .. }) => { - (debug, breakpoints) - } - FuzzOutcome::CounterExample(CounterExampleOutcome { - debug, - breakpoints, - .. - }) => (debug, breakpoints), - }, - Err(_) => (Default::default(), Default::default()), - }; - } test_result.fuzz_result(result) } } diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 2b57468e276bd..3552e3977f97d 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -154,7 +154,6 @@ impl PreExecutionState { setup_result.gas_used = script_result.gas_used; setup_result.logs.extend(script_result.logs); setup_result.traces.extend(script_result.traces); - setup_result.debug = script_result.debug; setup_result.labeled_addresses.extend(script_result.labeled_addresses); setup_result.returned = script_result.returned; setup_result.breakpoints = script_result.breakpoints; @@ -490,12 +489,18 @@ impl PreSimulationState { Ok(()) } - pub fn run_debugger(&self) -> Result<()> { + pub fn run_debugger(self) -> Result<()> { let mut debugger = Debugger::builder() - .debug_arenas(self.execution_result.debug.as_deref().unwrap_or_default()) + .traces( + self.execution_result + .traces + .into_iter() + .filter(|(t, _)| t.is_execution()) + .collect(), + ) .decoder(&self.execution_artifacts.decoder) - .sources(self.build_data.sources.clone()) - .breakpoints(self.execution_result.breakpoints.clone()) + .sources(self.build_data.sources) + .breakpoints(self.execution_result.breakpoints) .build(); debugger.try_run()?; Ok(()) diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 9c75729ed453c..c1ae8882e35d3 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -37,7 +37,6 @@ use foundry_config::{ use foundry_evm::{ backend::Backend, constants::DEFAULT_CREATE2_DEPLOYER, - debug::DebugArena, executors::ExecutorBuilder, inspectors::{ cheatcodes::{BroadcastableTransactions, ScriptWallets}, @@ -235,7 +234,7 @@ impl ScriptArgs { .await?; if pre_simulation.args.debug { - pre_simulation.run_debugger()?; + return pre_simulation.run_debugger() } if pre_simulation.args.json { @@ -462,7 +461,6 @@ pub struct ScriptResult { pub success: bool, pub logs: Vec, pub traces: Traces, - pub debug: Option>, pub gas_used: u64, pub labeled_addresses: HashMap, pub transactions: Option, diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 9ecd80859bb89..a4f437644dbcd 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -134,8 +134,7 @@ impl ScriptRunner { // Deploy an instance of the contract let DeployResult { address, - raw: - RawCallResult { mut logs, traces: constructor_traces, debug: constructor_debug, .. }, + raw: RawCallResult { mut logs, traces: constructor_traces, .. }, } = self .executor .deploy(CALLER, code, U256::ZERO, None) @@ -144,15 +143,9 @@ impl ScriptRunner { traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); // Optionally call the `setUp` function - let (success, gas_used, labeled_addresses, transactions, debug) = if !setup { + let (success, gas_used, labeled_addresses, transactions) = if !setup { self.executor.backend_mut().set_test_contract(address); - ( - true, - 0, - Default::default(), - Some(library_transactions), - vec![constructor_debug].into_iter().collect(), - ) + (true, 0, Default::default(), Some(library_transactions)) } else { match self.executor.setup(Some(self.evm_opts.sender), address, None) { Ok(RawCallResult { @@ -160,7 +153,6 @@ impl ScriptRunner { traces: setup_traces, labels, logs: setup_logs, - debug, gas_used, transactions: setup_transactions, .. @@ -172,13 +164,7 @@ impl ScriptRunner { library_transactions.extend(txs); } - ( - !reverted, - gas_used, - labels, - Some(library_transactions), - vec![constructor_debug, debug].into_iter().collect(), - ) + (!reverted, gas_used, labels, Some(library_transactions)) } Err(EvmError::Execution(err)) => { let RawCallResult { @@ -186,7 +172,6 @@ impl ScriptRunner { traces: setup_traces, labels, logs: setup_logs, - debug, gas_used, transactions, .. @@ -198,13 +183,7 @@ impl ScriptRunner { library_transactions.extend(txs); } - ( - !reverted, - gas_used, - labels, - Some(library_transactions), - vec![constructor_debug, debug].into_iter().collect(), - ) + (!reverted, gas_used, labels, Some(library_transactions)) } Err(e) => return Err(e.into()), } @@ -220,7 +199,6 @@ impl ScriptRunner { transactions, logs, traces, - debug, address: None, ..Default::default() }, @@ -249,7 +227,7 @@ impl ScriptRunner { value.unwrap_or(U256::ZERO), None, ); - let (address, RawCallResult { gas_used, logs, traces, debug, .. }) = match res { + let (address, RawCallResult { gas_used, logs, traces, .. }) = match res { Ok(DeployResult { address, raw }) => (address, raw), Err(EvmError::Execution(err)) => { let ExecutionErr { raw, reason } = *err; @@ -268,7 +246,6 @@ impl ScriptRunner { traces: traces .map(|traces| vec![(TraceKind::Execution, traces)]) .unwrap_or_default(), - debug: debug.map(|debug| vec![debug]), address: Some(address), ..Default::default() }) @@ -304,7 +281,7 @@ impl ScriptRunner { res = self.executor.transact_raw(from, to, calldata, value)?; } - let RawCallResult { result, reverted, logs, traces, labels, debug, transactions, .. } = res; + let RawCallResult { result, reverted, logs, traces, labels, transactions, .. } = res; let breakpoints = res.cheatcodes.map(|cheats| cheats.breakpoints).unwrap_or_default(); Ok(ScriptResult { @@ -319,7 +296,6 @@ impl ScriptRunner { vec![(TraceKind::Execution, traces)] }) .unwrap_or_default(), - debug: debug.map(|d| vec![d]), labeled_addresses: labels, transactions, address: None, From 67b1410a2e0a1eadabb2b6fdf6b0c88f3d3c0eac Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:15:34 +0200 Subject: [PATCH 1158/1963] feat(coverage): exit early if tests failed (#8268) --- crates/forge/bin/cmd/coverage.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index dc9b25c148ec0..b00fa100c99a7 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -252,6 +252,8 @@ impl CoverageArgs { .run_tests(runner, config.clone(), verbosity, &self.test.filter(&config)) .await?; + outcome.ensure_ok()?; + // Add hit data to the coverage report let data = outcome.results.iter().flat_map(|(_, suite)| { let mut hits = Vec::new(); From 92481a5ddab4e5ad471e2f7e0bafa0daf0a0d509 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:44:41 +0800 Subject: [PATCH 1159/1963] feat(invariant): collect coverage during runs (#8265) * fix(invariant): collect coverage during runs * Collect coverage only if in forge coverage execution * Do not check exec context --- crates/evm/evm/src/executors/fuzz/mod.rs | 78 +++++++++---------- crates/evm/evm/src/executors/invariant/mod.rs | 16 ++++ .../evm/evm/src/executors/invariant/result.rs | 3 + crates/forge/src/result.rs | 2 +- crates/forge/src/runner.rs | 19 ++--- 5 files changed, 69 insertions(+), 49 deletions(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 5de2590148f4a..36fbe392be952 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -22,6 +22,23 @@ use std::cell::RefCell; mod types; pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; +/// Contains data collected during fuzz test runs. +#[derive(Default)] +pub struct FuzzTestData { + // Stores the first fuzz case. + pub first_case: Option, + // Stored gas usage per fuzz case. + pub gas_by_case: Vec<(u64, u64)>, + // Stores the result and calldata of the last failed call, if any. + pub counterexample: (Bytes, RawCallResult), + // Stores up to `max_traces_to_collect` traces. + pub traces: Vec, + // Stores breakpoints for the last fuzz case. + pub breakpoints: Option, + // Stores coverage information for all fuzz cases. + pub coverage: Option, +} + /// Wrapper around an [`Executor`] which provides fuzzing support using [`proptest`]. /// /// After instantiation, calling `fuzz` will proceed to hammer the deployed smart contract with @@ -63,35 +80,16 @@ impl FuzzedExecutor { rd: &RevertDecoder, progress: Option<&ProgressBar>, ) -> FuzzTestResult { - // Stores the first Fuzzcase - let first_case: RefCell> = RefCell::default(); - - // gas usage per case - let gas_by_case: RefCell> = RefCell::default(); - - // Stores the result and calldata of the last failed call, if any. - let counterexample: RefCell<(Bytes, RawCallResult)> = RefCell::default(); - - // We want to collect at least one trace which will be displayed to user. - let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize; - - // Stores up to `max_traces_to_collect` traces. - let traces: RefCell> = RefCell::default(); - - // Stores coverage information for all fuzz cases - let coverage: RefCell> = RefCell::default(); - - // Stores breakpoints for the last fuzz case. - let breakpoints: RefCell> = RefCell::default(); - + // Stores the fuzz test execution data. + let execution_data = RefCell::new(FuzzTestData::default()); let state = self.build_fuzz_state(); - let dictionary_weight = self.config.dictionary.dictionary_weight.min(100); - let strat = proptest::prop_oneof![ 100 - dictionary_weight => fuzz_calldata(func.clone(), fuzz_fixtures), dictionary_weight => fuzz_calldata_from_state(func.clone(), &state), ]; + // We want to collect at least one trace which will be displayed to user. + let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize; debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { @@ -104,20 +102,21 @@ impl FuzzedExecutor { match fuzz_res { FuzzOutcome::Case(case) => { - let mut first_case = first_case.borrow_mut(); - gas_by_case.borrow_mut().push((case.case.gas, case.case.stipend)); - if first_case.is_none() { - first_case.replace(case.case); + let mut data = execution_data.borrow_mut(); + data.gas_by_case.push((case.case.gas, case.case.stipend)); + if data.first_case.is_none() { + data.first_case.replace(case.case); } if let Some(call_traces) = case.traces { - if traces.borrow().len() == max_traces_to_collect { - traces.borrow_mut().pop(); + if data.traces.len() == max_traces_to_collect { + data.traces.pop(); } - traces.borrow_mut().push(call_traces); - breakpoints.borrow_mut().replace(case.breakpoints); + data.traces.push(call_traces); + data.breakpoints.replace(case.breakpoints); } - match &mut *coverage.borrow_mut() { + // Collect and merge coverage if `forge snapshot` context. + match &mut data.coverage { Some(prev) => prev.merge(case.coverage.unwrap()), opt => *opt = case.coverage, } @@ -135,25 +134,26 @@ impl FuzzedExecutor { // to run at least one more case to find a minimal failure // case. let reason = rd.maybe_decode(&outcome.1.result, Some(status)); - *counterexample.borrow_mut() = outcome; + execution_data.borrow_mut().counterexample = outcome; // HACK: we have to use an empty string here to denote `None`. Err(TestCaseError::fail(reason.unwrap_or_default())) } } }); - let (calldata, call) = counterexample.into_inner(); + let fuzz_result = execution_data.into_inner(); + let (calldata, call) = fuzz_result.counterexample; - let mut traces = traces.into_inner(); + let mut traces = fuzz_result.traces; let (last_run_traces, last_run_breakpoints) = if run_result.is_ok() { - (traces.pop(), breakpoints.into_inner()) + (traces.pop(), fuzz_result.breakpoints) } else { (call.traces.clone(), call.cheatcodes.map(|c| c.breakpoints)) }; let mut result = FuzzTestResult { - first_case: first_case.take().unwrap_or_default(), - gas_by_case: gas_by_case.take(), + first_case: fuzz_result.first_case.unwrap_or_default(), + gas_by_case: fuzz_result.gas_by_case, success: run_result.is_ok(), reason: None, counterexample: None, @@ -163,7 +163,7 @@ impl FuzzedExecutor { traces: last_run_traces, breakpoints: last_run_breakpoints, gas_report_traces: traces, - coverage: coverage.into_inner(), + coverage: fuzz_result.coverage, }; match run_result { diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 88590a96155f9..f417edbb2a749 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -32,6 +32,7 @@ use std::{cell::RefCell, collections::btree_map::Entry, sync::Arc}; mod error; pub use error::{InvariantFailures, InvariantFuzzError}; +use foundry_evm_coverage::HitMaps; mod replay; pub use replay::{replay_error, replay_run}; @@ -109,6 +110,8 @@ pub struct InvariantTestData { pub gas_report_traces: Vec>, // Last call results of the invariant test. pub last_call_results: Option, + // Coverage information collected from all fuzzed calls. + pub coverage: Option, // Proptest runner to query for random values. // The strategy only comes with the first `input`. We fill the rest of the `inputs` @@ -146,6 +149,7 @@ impl InvariantTest { last_run_inputs: vec![], gas_report_traces: vec![], last_call_results, + coverage: None, branch_runner, }); Self { fuzz_state, targeted_contracts, execution_data } @@ -176,6 +180,14 @@ impl InvariantTest { self.execution_data.borrow_mut().last_run_inputs.clone_from(inputs); } + /// Merge current collected coverage with the new coverage from last fuzzed call. + pub fn merge_coverage(&self, new_coverage: Option) { + match &mut self.execution_data.borrow_mut().coverage { + Some(prev) => prev.merge(new_coverage.unwrap()), + opt => *opt = new_coverage, + } + } + /// End invariant test run by collecting results, cleaning collected artifacts and reverting /// created fuzz state. pub fn end_run(&self, run: InvariantTestRun, gas_samples: usize) { @@ -313,6 +325,9 @@ impl<'a> InvariantExecutor<'a> { TestCaseError::fail(format!("Could not make raw evm call: {e}")) })?; + // Collect coverage from last fuzzed call. + invariant_test.merge_coverage(call_result.coverage.clone()); + if call_result.result.as_ref() == MAGIC_ASSUME { current_run.inputs.pop(); current_run.assume_rejects_counter += 1; @@ -421,6 +436,7 @@ impl<'a> InvariantExecutor<'a> { reverts: result.failures.reverts, last_run_inputs: result.last_run_inputs, gas_report_traces: result.gas_report_traces, + coverage: result.coverage, }) } diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index aba35147631a5..bd34687c33bbc 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -7,6 +7,7 @@ use alloy_dyn_abi::JsonAbiExt; use eyre::Result; use foundry_config::InvariantConfig; use foundry_evm_core::utils::StateChangeset; +use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ invariant::{BasicTxDetails, FuzzRunIdentifiedContracts, InvariantContract}, FuzzedCases, @@ -27,6 +28,8 @@ pub struct InvariantFuzzTestResult { pub last_run_inputs: Vec, /// Additional traces used for gas report construction. pub gas_report_traces: Vec>, + /// The coverage info collected during the invariant test runs. + pub coverage: Option, } /// Enriched results of an invariant run check. diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index e7c0b6101eb9b..42ef35788c31b 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -592,7 +592,7 @@ impl TestResult { } /// Function to merge given coverage in current test result coverage. - fn merge_coverages(&mut self, other_coverage: Option) { + pub fn merge_coverages(&mut self, other_coverage: Option) { let old_coverage = std::mem::take(&mut self.coverage); self.coverage = match (old_coverage, other_coverage) { (Some(old_coverage), Some(other)) => Some(old_coverage.merged(other)), diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 59f903c9c6530..f19f2d43c2229 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -23,7 +23,6 @@ use foundry_evm::{ fuzz::FuzzedExecutor, invariant::{ check_sequence, replay_error, replay_run, InvariantExecutor, InvariantFuzzError, - InvariantFuzzTestResult, }, CallResult, EvmError, ExecutionErr, Executor, RawCallResult, }, @@ -537,18 +536,20 @@ impl<'a> ContractRunner<'a> { let progress = start_fuzz_progress(self.progress, self.name, &func.name, invariant_config.runs); - let InvariantFuzzTestResult { error, cases, reverts, last_run_inputs, gas_report_traces } = + let invariant_result = match evm.invariant_fuzz(invariant_contract.clone(), &fuzz_fixtures, progress.as_ref()) { Ok(x) => x, Err(e) => return test_result.invariant_setup_fail(e), }; + // Merge coverage collected during invariant run with test setup coverage. + test_result.merge_coverages(invariant_result.coverage); let mut counterexample = None; - let success = error.is_none(); - let reason = error.as_ref().and_then(|err| err.revert_reason()); + let success = invariant_result.error.is_none(); + let reason = invariant_result.error.as_ref().and_then(|err| err.revert_reason()); - match error { + match invariant_result.error { // If invariants were broken, replay the error to collect logs and traces Some(error) => match error { InvariantFuzzError::BrokenInvariant(case_data) | @@ -599,7 +600,7 @@ impl<'a> ContractRunner<'a> { &mut test_result.logs, &mut test_result.traces, &mut test_result.coverage, - &last_run_inputs, + &invariant_result.last_run_inputs, ) { error!(%err, "Failed to replay last invariant run"); } @@ -607,12 +608,12 @@ impl<'a> ContractRunner<'a> { } test_result.invariant_result( - gas_report_traces, + invariant_result.gas_report_traces, success, reason, counterexample, - cases, - reverts, + invariant_result.cases, + invariant_result.reverts, ) } From bf5189535d566911891821416f3aa163b7808eca Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:45:45 +0200 Subject: [PATCH 1160/1963] chore: remove an unnecessary debug log (#8270) --- crates/evm/evm/src/executors/fuzz/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 36fbe392be952..4fcf4e857fb9f 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -91,7 +91,6 @@ impl FuzzedExecutor { // We want to collect at least one trace which will be displayed to user. let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize; - debug!(func=?func.name, should_fail, "fuzzing"); let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; From d3572af7be6db2264f19bf7db2130deb11569269 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 27 Jun 2024 18:06:23 +0400 Subject: [PATCH 1161/1963] fix: correctly adjust depth when calling cheatcodes with `--isolate` (#8273) fix: correctly adjust depth when calling cheatcodes with --isolate --- crates/evm/evm/src/inspectors/stack.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index b098d878a96d4..a4930ca452446 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -702,13 +702,16 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ecx ); + ecx.journaled_state.depth += self.in_inner_context as usize; if let Some(cheatcodes) = self.cheatcodes.as_deref_mut() { if let Some(output) = cheatcodes.call_with_executor(ecx, call, self.inner) { if output.result.result != InstructionResult::Continue { + ecx.journaled_state.depth -= self.in_inner_context as usize; return Some(output) } } } + ecx.journaled_state.depth -= self.in_inner_context as usize; if self.enable_isolation && call.scheme == CallScheme::Call && From 2000af45c8324953f549c852bc3a2f8eda505ad8 Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Thu, 27 Jun 2024 22:33:25 +0800 Subject: [PATCH 1162/1963] fix: `trace_debugTransaction` is inconsistent with geth's responses for tracer 'callTracer' (#6884) * fix: add CallTracer in anvil * fix: extra if let * try impl geth_trace * fix: return empty for non supported tracers * fix: types import * fix: rustfmt * fix * fix: type * fix: change to return Result * fix: clippy * fix: match * fix: merge * chore: simplify --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/anvil/src/eth/backend/mem/mod.rs | 8 +-- crates/anvil/src/eth/backend/mem/storage.rs | 61 ++++++++++++++++++--- crates/evm/traces/src/lib.rs | 4 +- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 7c6fcdf90ba56..58bd30f8a6c3f 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1921,8 +1921,8 @@ impl Backend { hash: B256, opts: GethDebugTracingOptions, ) -> Result { - if let Some(traces) = self.mined_geth_trace_transaction(hash, opts.clone()) { - return Ok(GethTrace::Default(traces)); + if let Some(trace) = self.mined_geth_trace_transaction(hash, opts.clone()) { + return trace; } if let Some(fork) = self.get_fork() { @@ -1936,8 +1936,8 @@ impl Backend { &self, hash: B256, opts: GethDebugTracingOptions, - ) -> Option { - self.blockchain.storage.read().transactions.get(&hash).map(|tx| tx.geth_trace(opts.config)) + ) -> Option> { + self.blockchain.storage.read().transactions.get(&hash).map(|tx| tx.geth_trace(opts)) } /// Returns the traces for the given block diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 308463d6dface..312c529d610c2 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -4,12 +4,16 @@ use crate::eth::{ db::{MaybeFullDatabase, SerializableBlock, StateDb}, mem::cache::DiskStateCache, }, + error::BlockchainError, pool::transactions::PoolTransaction, }; use alloy_primitives::{Bytes, TxHash, B256, U256, U64}; use alloy_rpc_types::{ trace::{ - geth::{DefaultFrame, GethDefaultTracingOptions}, + geth::{ + FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType, + GethDebugTracingOptions, GethTrace, NoopFrame, + }, parity::LocalizedTransactionTrace, }, BlockId, BlockNumberOrTag, TransactionInfo as RethTransactionInfo, @@ -18,9 +22,10 @@ use anvil_core::eth::{ block::{Block, PartialHeader}, transaction::{MaybeImpersonatedTransaction, ReceiptResponse, TransactionInfo, TypedReceipt}, }; +use anvil_rpc::error::RpcError; use foundry_evm::{ revm::primitives::Env, - traces::{GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig}, + traces::{FourByteInspector, GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig}, }; use parking_lot::RwLock; use std::{ @@ -421,13 +426,51 @@ impl MinedTransaction { }) } - pub fn geth_trace(&self, opts: GethDefaultTracingOptions) -> DefaultFrame { - GethTraceBuilder::new(self.info.traces.clone(), TracingInspectorConfig::default_geth()) - .geth_traces( - self.receipt.cumulative_gas_used() as u64, - self.info.out.clone().unwrap_or_default().0.into(), - opts, - ) + pub fn geth_trace(&self, opts: GethDebugTracingOptions) -> Result { + let GethDebugTracingOptions { config, tracer, tracer_config, .. } = opts; + + if let Some(tracer) = tracer { + match tracer { + GethDebugTracerType::BuiltInTracer(tracer) => match tracer { + GethDebugBuiltInTracerType::FourByteTracer => { + let inspector = FourByteInspector::default(); + return Ok(FourByteFrame::from(inspector).into()) + } + GethDebugBuiltInTracerType::CallTracer => { + return match tracer_config.into_call_config() { + Ok(call_config) => Ok(GethTraceBuilder::new( + self.info.traces.clone(), + TracingInspectorConfig::from_geth_config(&config), + ) + .geth_call_traces( + call_config, + self.receipt.cumulative_gas_used() as u64, + ) + .into()), + Err(e) => Err(RpcError::invalid_params(e.to_string()).into()), + }; + } + GethDebugBuiltInTracerType::PreStateTracer | + GethDebugBuiltInTracerType::NoopTracer | + GethDebugBuiltInTracerType::MuxTracer => {} + }, + GethDebugTracerType::JsTracer(_code) => {} + } + + return Ok(NoopFrame::default().into()); + } + + // default structlog tracer + Ok(GethTraceBuilder::new( + self.info.traces.clone(), + TracingInspectorConfig::from_geth_config(&config), + ) + .geth_traces( + self.receipt.cumulative_gas_used() as u64, + self.info.out.clone().unwrap_or_default(), + opts.config, + ) + .into()) } } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 2803de3ca6779..b3ce89578c7ca 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -19,8 +19,8 @@ use yansi::{Color, Paint}; pub use revm_inspectors::tracing::{ types::{CallKind, CallTrace, CallTraceNode}, - CallTraceArena, GethTraceBuilder, ParityTraceBuilder, StackSnapshotType, TracingInspector, - TracingInspectorConfig, + CallTraceArena, FourByteInspector, GethTraceBuilder, ParityTraceBuilder, StackSnapshotType, + TracingInspector, TracingInspectorConfig, }; /// Call trace address identifiers. From f9674c3ea80ec9cd92e5f96a75542b3a26fa4752 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 27 Jun 2024 19:11:06 +0400 Subject: [PATCH 1163/1963] chore: reduce verbosity for ext tests (#8275) --- crates/test-utils/src/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 6d2d5233a3c60..47ab824434faa 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -192,7 +192,7 @@ impl ExtTester { // Run the tests. test_cmd.arg("test"); test_cmd.args(&self.args); - test_cmd.args(["--fuzz-runs=32", "--ffi", "-vvvvv"]); + test_cmd.args(["--fuzz-runs=32", "--ffi", "-vvv"]); test_cmd.envs(self.envs.iter().map(|(k, v)| (k, v))); if let Some(fork_block) = self.fork_block { From c4a984fbf2c48b793c8cd53af84f56009dd1070c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:24:59 +0200 Subject: [PATCH 1164/1963] feat(forge): prettify `ir` and `irOptimized` inspect outputs (#8272) --- crates/config/src/lib.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 38 +++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index c097078fbab80..f2010734aeb04 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -294,7 +294,7 @@ pub struct Config { pub block_difficulty: u64, /// Before merge the `block.max_hash`, after merge it is `block.prevrandao`. pub block_prevrandao: B256, - /// the `block.gaslimit` value during EVM execution + /// The `block.gaslimit` value during EVM execution. pub block_gas_limit: Option, /// The memory limit per EVM execution in bytes. /// If this limit is exceeded, a `MemoryLimitOOG` result is thrown. diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index bea9393ff3a11..a6f1625560278 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -14,6 +14,8 @@ use foundry_compilers::{ info::ContractInfo, utils::canonicalize, }; +use once_cell::sync::Lazy; +use regex::Regex; use std::fmt; /// CLI arguments for `forge inspect`. @@ -111,10 +113,10 @@ impl InspectArgs { print_json(&artifact.devdoc)?; } ContractArtifactField::Ir => { - print_json_str(&artifact.ir, None)?; + print_yul(artifact.ir.as_deref(), self.pretty)?; } ContractArtifactField::IrOptimized => { - print_json_str(&artifact.ir_optimized, None)?; + print_yul(artifact.ir_optimized.as_deref(), self.pretty)?; } ContractArtifactField::Metadata => { print_json(&artifact.metadata)?; @@ -369,6 +371,28 @@ fn print_json(obj: &impl serde::Serialize) -> Result<()> { } fn print_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result<()> { + println!("{}", get_json_str(obj, key)?); + Ok(()) +} + +fn print_yul(yul: Option<&str>, pretty: bool) -> Result<()> { + let Some(yul) = yul else { + eyre::bail!("Could not get IR output"); + }; + + static YUL_COMMENTS: Lazy = + Lazy::new(|| Regex::new(r"(///.*\n\s*)|(\s*/\*\*.*\*/)").unwrap()); + + if pretty { + println!("{}", YUL_COMMENTS.replace_all(yul, "")); + } else { + println!("{yul}"); + } + + Ok(()) +} + +fn get_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result { let value = serde_json::to_value(obj)?; let mut value_ref = &value; if let Some(key) = key { @@ -376,11 +400,11 @@ fn print_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result<()> value_ref = value2; } } - match value_ref.as_str() { - Some(s) => println!("{s}"), - None => println!("{value_ref:#}"), - } - Ok(()) + let s = match value_ref.as_str() { + Some(s) => s.to_string(), + None => format!("{value_ref:#}"), + }; + Ok(s) } #[cfg(test)] From 93d47aa6d5c1ac3493b497b6d7e5da345777e32b Mon Sep 17 00:00:00 2001 From: Serge Radinovich <47865535+sergerad@users.noreply.github.com> Date: Fri, 28 Jun 2024 19:21:07 +1200 Subject: [PATCH 1165/1963] feat(anvil): fork from transaction hash (#8228) * add --fork-transaction-hash * reinstate with_fork_block_number() * move forkchoice to config module and add comments * partially get txn replay implemented * unexpected tx hash test * Reinstate with_fork_block_number() * fix miner poll logic * get full block * rm todos * fix miner poll logic * rpc to typed conversion * initial tests pass * move forkchoice struct * try_from * fin tests * rename replays and rm unwrap * choice to block num usage * lint * none on constructor * break out miner constructor * add derive fn * single line w force txns * chore: touchups --------- Co-authored-by: Matthias Seitz --- crates/anvil/core/src/eth/transaction/mod.rs | 103 +++++++++++++++- crates/anvil/src/cmd.rs | 28 ++++- crates/anvil/src/config.rs | 117 ++++++++++++++++--- crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/backend/fork.rs | 4 +- crates/anvil/src/eth/backend/mem/mod.rs | 4 +- crates/anvil/src/eth/miner.rs | 41 ++++++- crates/anvil/src/eth/pool/transactions.rs | 15 +++ crates/anvil/src/lib.rs | 10 +- crates/anvil/tests/it/fork.rs | 81 ++++++++++++- 10 files changed, 371 insertions(+), 34 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index c768d01a2c75e..13207a936ab09 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -4,14 +4,14 @@ use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRe use alloy_consensus::{ transaction::eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, - TxEnvelope, TxLegacy, TxReceipt, + TxEnvelope, TxLegacy, TxReceipt, TxType, }; use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ - request::TransactionRequest, AccessList, AnyTransactionReceipt, Signature as RpcSignature, - Transaction as RpcTransaction, TransactionReceipt, + request::TransactionRequest, AccessList, AnyTransactionReceipt, ConversionError, + Signature as RpcSignature, Transaction as RpcTransaction, TransactionReceipt, }; use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; @@ -893,6 +893,103 @@ impl TypedTransaction { } } +impl TryFrom for TypedTransaction { + type Error = ConversionError; + + fn try_from(tx: RpcTransaction) -> Result { + // TODO(sergerad): Handle Arbitrum system transactions? + match tx.transaction_type.unwrap_or_default().try_into()? { + TxType::Legacy => { + let legacy = TxLegacy { + chain_id: tx.chain_id, + nonce: tx.nonce, + gas_price: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, + gas_limit: tx.gas, + value: tx.value, + input: tx.input, + to: tx.to.map_or(TxKind::Create, TxKind::Call), + }; + let signature = tx + .signature + .ok_or(ConversionError::MissingSignature)? + .try_into() + .map_err(ConversionError::SignatureError)?; + Ok(Self::Legacy(Signed::new_unchecked(legacy, signature, tx.hash))) + } + TxType::Eip1559 => { + let eip1559 = TxEip1559 { + chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, + nonce: tx.nonce, + max_fee_per_gas: tx + .max_fee_per_gas + .ok_or(ConversionError::MissingMaxFeePerGas)?, + max_priority_fee_per_gas: tx + .max_priority_fee_per_gas + .ok_or(ConversionError::MissingMaxPriorityFeePerGas)?, + gas_limit: tx.gas, + value: tx.value, + input: tx.input, + to: tx.to.map_or(TxKind::Create, TxKind::Call), + access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, + }; + let signature = tx + .signature + .ok_or(ConversionError::MissingSignature)? + .try_into() + .map_err(ConversionError::SignatureError)?; + Ok(Self::EIP1559(Signed::new_unchecked(eip1559, signature, tx.hash))) + } + TxType::Eip2930 => { + let eip2930 = TxEip2930 { + chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, + nonce: tx.nonce, + gas_price: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, + gas_limit: tx.gas, + value: tx.value, + input: tx.input, + to: tx.to.map_or(TxKind::Create, TxKind::Call), + access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, + }; + let signature = tx + .signature + .ok_or(ConversionError::MissingSignature)? + .try_into() + .map_err(ConversionError::SignatureError)?; + Ok(Self::EIP2930(Signed::new_unchecked(eip2930, signature, tx.hash))) + } + TxType::Eip4844 => { + let eip4844 = TxEip4844 { + chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, + nonce: tx.nonce, + gas_limit: tx.gas, + max_fee_per_gas: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, + max_priority_fee_per_gas: tx + .max_priority_fee_per_gas + .ok_or(ConversionError::MissingMaxPriorityFeePerGas)?, + max_fee_per_blob_gas: tx + .max_fee_per_blob_gas + .ok_or(ConversionError::MissingMaxFeePerBlobGas)?, + to: tx.to.ok_or(ConversionError::MissingTo)?, + value: tx.value, + access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, + blob_versioned_hashes: tx + .blob_versioned_hashes + .ok_or(ConversionError::MissingBlobVersionedHashes)?, + input: tx.input, + }; + Ok(Self::EIP4844(Signed::new_unchecked( + TxEip4844Variant::TxEip4844(eip4844), + tx.signature + .ok_or(ConversionError::MissingSignature)? + .try_into() + .map_err(ConversionError::SignatureError)?, + tx.hash, + ))) + } + } + } +} + impl Encodable for TypedTransaction { fn encode(&self, out: &mut dyn bytes::BufMut) { match self { diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index ca86a06e163c2..892d714626cbe 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -1,10 +1,10 @@ use crate::{ - config::DEFAULT_MNEMONIC, + config::{ForkChoice, DEFAULT_MNEMONIC}, eth::{backend::db::SerializableState, pool::transactions::TransactionOrder, EthApi}, AccountGenerator, Hardfork, NodeConfig, CHAIN_ID, }; use alloy_genesis::Genesis; -use alloy_primitives::{utils::Unit, U256}; +use alloy_primitives::{utils::Unit, B256, U256}; use alloy_signer_local::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; use clap::Parser; @@ -204,10 +204,14 @@ impl NodeArgs { .with_genesis_balance(genesis_balance) .with_genesis_timestamp(self.timestamp) .with_port(self.port) - .with_fork_block_number( - self.evm_opts - .fork_block_number - .or_else(|| self.evm_opts.fork_url.as_ref().and_then(|f| f.block)), + .with_fork_choice( + match (self.evm_opts.fork_block_number, self.evm_opts.fork_transaction_hash) { + (Some(block), None) => Some(ForkChoice::Block(block)), + (None, Some(hash)) => Some(ForkChoice::Transaction(hash)), + _ => Some(ForkChoice::Block( + self.evm_opts.fork_url.as_ref().and_then(|f| f.block).unwrap(), + )), + }, ) .with_fork_headers(self.evm_opts.fork_headers) .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from).map(U256::from)) @@ -394,6 +398,18 @@ pub struct AnvilEvmArgs { #[arg(long, requires = "fork_url", value_name = "BLOCK", help_heading = "Fork config")] pub fork_block_number: Option, + /// Fetch state from a specific transaction hash over a remote endpoint. + /// + /// See --fork-url. + #[arg( + long, + requires = "fork_url", + value_name = "TRANSACTION", + help_heading = "Fork config", + conflicts_with = "fork_block_number" + )] + pub fork_transaction_hash: Option, + /// Initial retry backoff on encountering errors. /// /// See --fork-url. diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 097513847229a..59c0acda34fa0 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -9,16 +9,16 @@ use crate::{ time::duration_since_unix_epoch, }, fees::{INITIAL_BASE_FEE, INITIAL_GAS_PRICE}, - pool::transactions::TransactionOrder, + pool::transactions::{PoolTransaction, TransactionOrder}, }, mem::{self, in_memory_db::MemDb}, FeeManager, Hardfork, PrecompileFactory, }; use alloy_genesis::Genesis; use alloy_network::AnyNetwork; -use alloy_primitives::{hex, utils::Unit, U256}; +use alloy_primitives::{hex, utils::Unit, BlockNumber, TxHash, U256}; use alloy_provider::Provider; -use alloy_rpc_types::BlockNumberOrTag; +use alloy_rpc_types::{BlockNumberOrTag, Transaction}; use alloy_signer::Signer; use alloy_signer_local::{ coins_bip39::{English, Mnemonic}, @@ -26,8 +26,10 @@ use alloy_signer_local::{ }; use alloy_transport::{Transport, TransportError}; use anvil_server::ServerConfig; +use eyre::Result; use foundry_common::{ - provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, + provider::{ProviderBuilder, RetryProvider}, + ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, }; use foundry_config::Config; use foundry_evm::{ @@ -36,6 +38,7 @@ use foundry_evm::{ revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv}, utils::apply_chain_and_block_specific_env_changes, }; +use itertools::Itertools; use parking_lot::RwLock; use rand::thread_rng; use revm::primitives::BlobExcessGasAndPrice; @@ -118,8 +121,8 @@ pub struct NodeConfig { pub silent: bool, /// url of the rpc server that should be used for any rpc calls pub eth_rpc_url: Option, - /// pins the block number for the state fork - pub fork_block_number: Option, + /// pins the block number or transaction hash for the state fork + pub fork_choice: Option, /// headers to use with `eth_rpc_url` pub fork_headers: Vec, /// specifies chain id for cache to skip fetching from remote in offline-start mode @@ -391,7 +394,7 @@ impl Default for NodeConfig { max_transactions: 1_000, silent: false, eth_rpc_url: None, - fork_block_number: None, + fork_choice: None, account_generator: None, base_fee: None, blob_excess_gas_and_price: None, @@ -694,10 +697,25 @@ impl NodeConfig { self } - /// Sets the `fork_block_number` to use to fork off from + /// Sets the `fork_choice` to use to fork off from based on a block number #[must_use] - pub fn with_fork_block_number>(mut self, fork_block_number: Option) -> Self { - self.fork_block_number = fork_block_number.map(Into::into); + pub fn with_fork_block_number>(self, fork_block_number: Option) -> Self { + self.with_fork_choice(fork_block_number.map(Into::into)) + } + + /// Sets the `fork_choice` to use to fork off from based on a transaction hash + #[must_use] + pub fn with_fork_transaction_hash>( + self, + fork_transaction_hash: Option, + ) -> Self { + self.with_fork_choice(fork_transaction_hash.map(Into::into)) + } + + /// Sets the `fork_choice` to use to fork off from + #[must_use] + pub fn with_fork_choice>(mut self, fork_choice: Option) -> Self { + self.fork_choice = fork_choice.map(Into::into); self } @@ -997,9 +1015,13 @@ impl NodeConfig { .expect("Failed to establish provider to fork url"), ); - let (fork_block_number, fork_chain_id) = if let Some(fork_block_number) = - self.fork_block_number + let (fork_block_number, fork_chain_id, force_transactions) = if let Some(fork_choice) = + &self.fork_choice { + let (fork_block_number, force_transactions) = + derive_block_and_transactions(fork_choice, &provider).await.expect( + "Failed to derive fork block number and force transactions from fork choice", + ); let chain_id = if let Some(chain_id) = self.fork_chain_id { Some(chain_id) } else if self.hardfork.is_none() { @@ -1017,12 +1039,12 @@ impl NodeConfig { None }; - (fork_block_number, chain_id) + (fork_block_number, chain_id, force_transactions) } else { // pick the last block number but also ensure it's not pending anymore let bn = find_latest_fork_block(&provider).await.expect("Failed to get fork block number"); - (bn, None) + (bn, None, None) }; let block = provider @@ -1159,6 +1181,7 @@ latest block number: {latest_block}" total_difficulty: block.header.total_difficulty.unwrap_or_default(), blob_gas_used: block.header.blob_gas_used, blob_excess_gas_and_price: env.block.blob_excess_gas_and_price.clone(), + force_transactions, }; let mut db = ForkedDatabase::new(backend, block_chain_db); @@ -1170,6 +1193,72 @@ latest block number: {latest_block}" } } +/// If the fork choice is a block number, simply return it with an empty list of transactions. +/// If the fork choice is a transaction hash, determine the block that the transaction was mined in, +/// and return the block number before the fork block along with all transactions in the fork block +/// that are before (and including) the fork transaction. +async fn derive_block_and_transactions( + fork_choice: &ForkChoice, + provider: &Arc, +) -> eyre::Result<(BlockNumber, Option>)> { + match fork_choice { + ForkChoice::Block(block_number) => Ok((block_number.to_owned(), None)), + ForkChoice::Transaction(transaction_hash) => { + // Determine the block that this transaction was mined in + let transaction = provider + .get_transaction_by_hash(transaction_hash.0.into()) + .await? + .ok_or(eyre::eyre!("Failed to get fork transaction by hash"))?; + let transaction_block_number = transaction.block_number.unwrap(); + + // Get the block pertaining to the fork transaction + let transaction_block = provider + .get_block_by_number(transaction_block_number.into(), true) + .await? + .ok_or(eyre::eyre!("Failed to get fork block by number"))?; + + // Filter out transactions that are after the fork transaction + let filtered_transactions: Vec<&Transaction> = transaction_block + .transactions + .as_transactions() + .ok_or(eyre::eyre!("Failed to get transactions from full fork block"))? + .iter() + .take_while_inclusive(|&transaction| transaction.hash != transaction_hash.0) + .collect(); + + // Convert the transactions to PoolTransactions + let force_transactions = filtered_transactions + .iter() + .map(|&transaction| PoolTransaction::try_from(transaction.clone())) + .collect::, _>>()?; + Ok((transaction_block_number.saturating_sub(1), Some(force_transactions))) + } + } +} + +/// Fork delimiter used to specify which block or transaction to fork from +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ForkChoice { + /// Block number to fork from + Block(BlockNumber), + /// Transaction hash to fork from + Transaction(TxHash), +} + +/// Convert a transaction hash into a ForkChoice +impl From for ForkChoice { + fn from(tx_hash: TxHash) -> Self { + Self::Transaction(tx_hash) + } +} + +/// Convert a decimal block number into a ForkChoice +impl From for ForkChoice { + fn from(block: u64) -> Self { + Self::Block(block) + } +} + #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct PruneStateHistoryConfig { pub enabled: bool, diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index ada503ceca8a5..d130eb7f89f80 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -91,7 +91,7 @@ pub struct EthApi { pool: Arc, /// Holds all blockchain related data /// In-Memory only for now - pub(super) backend: Arc, + pub backend: Arc, /// Whether this node is mining is_mining: bool, /// available signers diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 21c89302ea68d..cabb96cd5da5f 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -1,6 +1,6 @@ //! Support for forking off another client -use crate::eth::{backend::db::Db, error::BlockchainError}; +use crate::eth::{backend::db::Db, error::BlockchainError, pool::transactions::PoolTransaction}; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; use alloy_provider::{ ext::{DebugApi, TraceApi}, @@ -601,6 +601,8 @@ pub struct ClientForkConfig { pub compute_units_per_second: u64, /// total difficulty of the chain until this block pub total_difficulty: U256, + /// Transactions to force include in the forked chain + pub force_transactions: Option>, } impl ClientForkConfig { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 58bd30f8a6c3f..3b2592518db50 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2150,7 +2150,7 @@ impl Backend { Ok(None) } - fn mined_transaction_by_block_hash_and_index( + pub fn mined_transaction_by_block_hash_and_index( &self, block_hash: B256, index: Index, @@ -2189,7 +2189,7 @@ impl Backend { Ok(None) } - fn mined_transaction_by_hash(&self, hash: B256) -> Option> { + pub fn mined_transaction_by_hash(&self, hash: B256) -> Option> { let (info, block) = { let storage = self.blockchain.storage.read(); let MinedTransaction { info, block_hash, .. } = diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index d928bdd94a77a..c446fc3530923 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -25,12 +25,32 @@ pub struct Miner { /// /// This will register the task so we can manually wake it up if the mining mode was changed inner: Arc, + /// Transactions included into the pool before any others are. + /// Done once on startup. + force_transactions: Option>>, } impl Miner { - /// Returns a new miner with that operates in the given `mode` + /// Returns a new miner with that operates in the given `mode`. pub fn new(mode: MiningMode) -> Self { - Self { mode: Arc::new(RwLock::new(mode)), inner: Default::default() } + Self { + mode: Arc::new(RwLock::new(mode)), + inner: Default::default(), + force_transactions: None, + } + } + + /// Provide transactions that will cause a block to be mined with transactions + /// as soon as the miner is polled. + /// Providing an empty list of transactions will cause the miner to mine an empty block assuming + /// there are not other transactions in the pool. + pub fn with_forced_transactions( + mut self, + force_transactions: Option>, + ) -> Self { + self.force_transactions = + force_transactions.map(|tx| tx.into_iter().map(Arc::new).collect()); + self } /// Returns the write lock of the mining mode @@ -67,7 +87,22 @@ impl Miner { cx: &mut Context<'_>, ) -> Poll>> { self.inner.register(cx); - self.mode.write().poll(pool, cx) + match self.mode.write().poll(pool, cx) { + Poll::Ready(next) => { + if let Some(transactions) = self.force_transactions.take() { + Poll::Ready(transactions.into_iter().chain(next).collect()) + } else { + Poll::Ready(next) + } + } + Poll::Pending => { + if let Some(transactions) = self.force_transactions.take() { + Poll::Ready(transactions) + } else { + Poll::Pending + } + } + } } } diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 026268231a9b3..502ee1e7886fa 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -1,5 +1,6 @@ use crate::eth::{error::PoolError, util::hex_fmt_many}; use alloy_primitives::{Address, TxHash}; +use alloy_rpc_types::Transaction as RpcTransaction; use anvil_core::eth::transaction::{PendingTransaction, TypedTransaction}; use parking_lot::RwLock; use std::{ @@ -107,6 +108,20 @@ impl fmt::Debug for PoolTransaction { } } +impl TryFrom for PoolTransaction { + type Error = eyre::Error; + fn try_from(transaction: RpcTransaction) -> Result { + let typed_transaction = TypedTransaction::try_from(transaction)?; + let pending_transaction = PendingTransaction::new(typed_transaction)?; + Ok(Self { + pending_transaction, + requires: vec![], + provides: vec![], + priority: TransactionPriority(0), + }) + } +} + /// A waiting pool of transaction that are pending, but not yet ready to be included in a new block. /// /// Keeps a set of transactions that are waiting for other transactions diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 471f7b05c500e..a27774dfb0ce2 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -45,7 +45,7 @@ use tokio::{ mod service; mod config; -pub use config::{AccountGenerator, NodeConfig, CHAIN_ID, VERSION_MESSAGE}; +pub use config::{AccountGenerator, ForkChoice, NodeConfig, CHAIN_ID, VERSION_MESSAGE}; mod hardfork; pub use hardfork::Hardfork; @@ -156,7 +156,13 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle let listener = pool.add_ready_listener(); MiningMode::instant(max_transactions, listener) }; - let miner = Miner::new(mode); + + let miner = match &fork { + Some(fork) => { + Miner::new(mode).with_forced_transactions(fork.config.read().force_transactions.clone()) + } + _ => Miner::new(mode), + }; let dev_signer: Box = Box::new(DevSigner::new(signer_accounts)); let mut signers = vec![dev_signer]; diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 8f3859f7f324a..8559b019cb573 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -5,7 +5,7 @@ use crate::{ utils::{http_provider, http_provider_with_signer}, }; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{address, bytes, Address, Bytes, TxKind, U256}; +use alloy_primitives::{address, bytes, Address, Bytes, TxHash, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ anvil::Forking, @@ -19,7 +19,7 @@ use foundry_common::provider::get_http_provider; use foundry_config::Config; use foundry_test_utils::rpc::{self, next_http_rpc_endpoint}; use futures::StreamExt; -use std::{sync::Arc, time::Duration}; +use std::{sync::Arc, thread::sleep, time::Duration}; const BLOCK_NUMBER: u64 = 14_608_400u64; const DEAD_BALANCE_AT_BLOCK_NUMBER: u128 = 12_556_069_338_441_120_059_867u128; @@ -1203,3 +1203,80 @@ async fn test_fork_execution_reverted() { let err = resp.unwrap_err(); assert!(err.to_string().contains("execution reverted")); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_immutable_fork_transaction_hash() { + use std::str::FromStr; + + // Fork to a block with a specific transaction + let fork_tx_hash = + TxHash::from_str("39d64ebf9eb3f07ede37f8681bc3b61928817276c4c4680b6ef9eac9f88b6786") + .unwrap(); + let (api, _) = spawn( + fork_config() + .with_blocktime(Some(Duration::from_millis(500))) + .with_fork_transaction_hash(Some(fork_tx_hash)) + .with_eth_rpc_url(Some("https://rpc.immutable.com".to_string())), + ) + .await; + + let fork_block_number = 8521008; + + // Make sure the fork starts from previous block + let mut block_number = api.block_number().unwrap().to::(); + assert_eq!(block_number, fork_block_number - 1); + + // Wait for fork to pass the target block + while block_number < fork_block_number { + sleep(Duration::from_millis(250)); + block_number = api.block_number().unwrap().to::(); + } + + let block = api + .block_by_number(BlockNumberOrTag::Number(fork_block_number - 1)) + .await + .unwrap() + .unwrap(); + assert_eq!(block.transactions.len(), 14); + let block = api + .block_by_number_full(BlockNumberOrTag::Number(fork_block_number)) + .await + .unwrap() + .unwrap(); + assert_eq!(block.transactions.len(), 3); + + // Validate the transactions preceding the target transaction exist + let expected_transactions = [ + TxHash::from_str("1bfe33136edc3d26bd01ce75c8f5ae14fffe8b142d30395cb4b6d3dc3043f400") + .unwrap(), + TxHash::from_str("8c0ce5fb9ec2c8e03f7fcc69c7786393c691ce43b58a06d74d6733679308fc01") + .unwrap(), + fork_tx_hash, + ]; + for expected in [ + (expected_transactions[0], address!("8C1aB379E7263d37049505626D2F975288F5dF12")), + (expected_transactions[1], address!("df918d9D02d5C7Df6825a7046dBF3D10F705Aa76")), + (expected_transactions[2], address!("5Be88952ce249024613e0961eB437f5E9424A90c")), + ] { + let tx = api.backend.mined_transaction_by_hash(expected.0).unwrap(); + assert_eq!(tx.inner.from, expected.1); + } + + // Validate the order of transactions in the new block + for expected in [ + (expected_transactions[0], 0), + (expected_transactions[1], 1), + (expected_transactions[2], 2), + ] { + let tx = api + .backend + .mined_block_by_number(BlockNumberOrTag::Number(fork_block_number)) + .and_then(|b| b.header.hash) + .and_then(|hash| { + api.backend.mined_transaction_by_block_hash_and_index(hash, expected.1.into()) + }) + .unwrap(); + assert_eq!(tx.inner.hash.to_string(), expected.0.to_string()); + } +} From 4ee6d4801340dbcb8be3b841be6face13fdf4352 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 28 Jun 2024 09:38:44 +0200 Subject: [PATCH 1166/1963] chore: make clippy happy (#8286) --- crates/common/src/selectors.rs | 20 ++++---------------- crates/script/src/transaction.rs | 6 ++---- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index eb604537c732c..59305f20b6c6e 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -61,16 +61,10 @@ impl OpenChainClient { .get(url) .send() .await - .map_err(|err| { - self.on_reqwest_err(&err); - err - })? + .inspect_err(|err| self.on_reqwest_err(err))? .text() .await - .map_err(|err| { - self.on_reqwest_err(&err); - err - }) + .inspect_err(|err| self.on_reqwest_err(err)) } /// Sends a new post request @@ -85,16 +79,10 @@ impl OpenChainClient { .json(body) .send() .await - .map_err(|err| { - self.on_reqwest_err(&err); - err - })? + .inspect_err(|err| self.on_reqwest_err(err))? .json() .await - .map_err(|err| { - self.on_reqwest_err(&err); - err - }) + .inspect_err(|err| self.on_reqwest_err(err)) } fn on_reqwest_err(&self, err: &reqwest::Error) { diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 96f4bb2a26d42..de91ab3e3b0f2 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -152,7 +152,7 @@ impl TransactionWithMetadata { let constructor_args = &creation_code[bytecode.len()..]; let Some(constructor) = info.abi.constructor() else { return Ok(()) }; - let values = constructor.abi_decode_input(constructor_args, false).map_err(|e| { + let values = constructor.abi_decode_input(constructor_args, false).inspect_err(|_| { error!( contract=?self.contract_name, signature=%format!("constructor({})", constructor.inputs.iter().map(|p| &p.ty).format(",")), @@ -161,7 +161,6 @@ impl TransactionWithMetadata { "Failed to decode constructor arguments", ); debug!(full_data=%hex::encode(data), bytecode=%hex::encode(creation_code)); - e })?; self.arguments = Some(values.iter().map(format_token_raw).collect()); @@ -195,14 +194,13 @@ impl TransactionWithMetadata { if let Some(function) = function { self.function = Some(function.signature()); - let values = function.abi_decode_input(data, false).map_err(|e| { + let values = function.abi_decode_input(data, false).inspect_err(|_| { error!( contract=?self.contract_name, signature=?function, data=hex::encode(data), "Failed to decode function arguments", ); - e })?; self.arguments = Some(values.iter().map(format_token_raw).collect()); } From b0e562faf3f7096743605793e3e2d8c8fd4b7c04 Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Fri, 28 Jun 2024 00:42:57 -0700 Subject: [PATCH 1167/1963] Update prune-prereleases.js to keep 30 nightlies around (#8282) --- .github/scripts/prune-prereleases.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/prune-prereleases.js b/.github/scripts/prune-prereleases.js index bbdb0696f516e..d0d6bf465e81a 100644 --- a/.github/scripts/prune-prereleases.js +++ b/.github/scripts/prune-prereleases.js @@ -36,7 +36,7 @@ module.exports = async ({ github, context }) => { // Pruning rules: // 1. only keep the earliest (by created_at) release of the month - // 2. to keep the newest 3 nightlies + // 2. to keep the newest 30 nightlies (to make sure nightlies are kept until the next monthly release) // Notes: // - This addresses https://github.com/foundry-rs/foundry/issues/6732 // - Name of the release may deviate from created_at due to the usage of different timezones. @@ -47,7 +47,7 @@ module.exports = async ({ github, context }) => { const groups = groupBy(nightlies, i => i.created_at.slice(0, 7)); const nightliesToPrune = Object.values(groups) .reduce((acc, cur) => acc.concat(cur.slice(0, -1)), []) // rule 1 - .slice(3); // rule 2 + .slice(30); // rule 2 for (const nightly of nightliesToPrune) { console.log(`Deleting nightly: ${nightly.tag_name}`); From b3c872bb07d8601c42043b83993e5c1c2e1a2b5c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 28 Jun 2024 17:31:29 +0200 Subject: [PATCH 1168/1963] fix: vm rpc encoding (#8288) * fix: vm rpc encoding * fix test * convert fixedbytes to bytes * forge fmt * take size from fixed bytes * convert addr to bytes --- crates/cheatcodes/src/evm/fork.rs | 13 ++++++++++-- crates/forge/tests/it/repros.rs | 3 +++ testdata/default/repros/Issue8287.t.sol | 27 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 testdata/default/repros/Issue8287.t.sol diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 70b7591f8a82e..a5a16065ed241 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,4 +1,5 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use alloy_dyn_abi::DynSolValue; use alloy_primitives::{B256, U256}; use alloy_provider::Provider; use alloy_rpc_types::Filter; @@ -243,8 +244,16 @@ impl Cheatcode for rpcCall { foundry_common::block_on(provider.raw_request(method.clone().into(), params_json)) .map_err(|err| fmt_err!("{method:?}: {err}"))?; - let result_as_tokens = crate::json::json_value_to_token(&result) - .map_err(|err| fmt_err!("failed to parse result: {err}"))?; + let result_as_tokens = match crate::json::json_value_to_token(&result) + .map_err(|err| fmt_err!("failed to parse result: {err}"))? + { + DynSolValue::FixedBytes(bytes, size) => { + // converted fixed bytes to bytes to prevent evm encoding issues: + DynSolValue::Bytes(bytes.as_slice()[..size].to_vec()) + } + DynSolValue::Address(addr) => DynSolValue::Bytes(addr.to_vec()), + val => val, + }; Ok(result_as_tokens.abi_encode()) } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 9150da5f0b280..edda3f69771be 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -342,3 +342,6 @@ test_repro!(2851, false, None, |res| { // https://github.com/foundry-rs/foundry/issues/8006 test_repro!(8006); + +// https://github.com/foundry-rs/foundry/issues/8287 +test_repro!(8287); diff --git a/testdata/default/repros/Issue8287.t.sol b/testdata/default/repros/Issue8287.t.sol new file mode 100644 index 0000000000000..cedcb4043ceaf --- /dev/null +++ b/testdata/default/repros/Issue8287.t.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/8287 +contract Issue8287Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testRpcBalance() public { + uint256 f2 = vm.createSelectFork("rpcAlias", 10); + bytes memory data = vm.rpc("eth_getBalance", "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x0\"]"); + string memory m = vm.toString(data); + assertEq(m, "0x2086ac351052600000"); + } + + function testRpcStorage() public { + uint256 f2 = vm.createSelectFork("rpcAlias", 10); + bytes memory data = vm.rpc( + "eth_getStorageAt", + "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e\",\"0x0\"]" + ); + string memory m = vm.toString(data); + assertEq(m, "0x0000000000000000000000000000000000000000000000000000000000000000"); + } +} From 48b95f90832792d60d130bf6a883b84d3598b2b4 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Date: Fri, 28 Jun 2024 17:33:30 +0200 Subject: [PATCH 1169/1963] feat: implement EOF methods in Inspector trait (#8123) * feat: implement EOF methods in Inspector trait * create and eofcreate refactored * create_end and eofcreate_end refactored * log_debug_fn * move allow_cheatcodes_fn from CreateParams to create_common arg * pass caller value * fix tests that require modified CreateInputs.caller to be propagated * use FnMut bounds for closures and remove dyn aliases * fix end_common * fix tests * log_debug_fn uses CreateScheme instead of full input * introduce CommonCreateInput trait * introduce CommonEndInput trait * recover referecens to ecx.inner * end_common -> create_end_common and docs * move legacy/EOF traits and types to inspector::utils * updates for latest revm * add missing inspector::utils mod def * fix build --- crates/anvil/src/eth/backend/mem/inspector.rs | 33 +- crates/cheatcodes/src/inspector.rs | 473 +++++++++--------- crates/cheatcodes/src/inspector/utils.rs | 111 ++++ crates/evm/evm/src/inspectors/stack.rs | 76 ++- 4 files changed, 465 insertions(+), 228 deletions(-) create mode 100644 crates/cheatcodes/src/inspector/utils.rs diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 9653912c9fe54..8510222d7132b 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -7,7 +7,9 @@ use foundry_evm::{ decode::decode_console_logs, inspectors::{LogCollector, TracingInspector}, revm::{ - interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter}, + interpreter::{ + CallInputs, CallOutcome, CreateInputs, CreateOutcome, EOFCreateInputs, Interpreter, + }, primitives::U256, EvmContext, }, @@ -117,6 +119,35 @@ impl revm::Inspector for Inspector { outcome } + #[inline] + fn eofcreate( + &mut self, + ecx: &mut EvmContext, + inputs: &mut EOFCreateInputs, + ) -> Option { + if let Some(tracer) = &mut self.tracer { + if let Some(out) = tracer.eofcreate(ecx, inputs) { + return Some(out); + } + } + None + } + + #[inline] + fn eofcreate_end( + &mut self, + ecx: &mut EvmContext, + inputs: &EOFCreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { + if let Some(tracer) = &mut self.tracer { + return tracer.eofcreate_end(ecx, inputs, outcome); + } + + outcome + } + + #[inline] fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { if let Some(tracer) = &mut self.tracer { revm::Inspector::::selfdestruct(tracer, contract, target, value); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 300ada83d7c10..bd6485d0c1df3 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -7,6 +7,7 @@ use crate::{ prank::Prank, DealRecord, RecordAccess, }, + inspector::utils::CommonCreateInput, script::{Broadcast, ScriptWallets}, test::expect::{ self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, @@ -30,8 +31,8 @@ use foundry_evm_core::{ use itertools::Itertools; use revm::{ interpreter::{ - opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, - InstructionResult, Interpreter, InterpreterAction, InterpreterResult, + opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, EOFCreateInputs, + Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, primitives::{BlockEnv, CreateScheme, EVMError}, EvmContext, InnerEvmContext, Inspector, @@ -47,6 +48,8 @@ use std::{ sync::Arc, }; +mod utils; + /// Helper trait for obtaining complete [revm::Inspector] instance from mutable reference to /// [Cheatcodes]. /// @@ -373,34 +376,20 @@ impl Cheatcodes { ) } - /// Determines the address of the contract and marks it as allowed. - /// - /// Returns the address of the contract created. + /// Grants cheat code access for new contracts if the caller also has + /// cheatcode access or the new contract is created in top most call. /// /// There may be cheatcodes in the constructor of the new contract, in order to allow them /// automatically we need to determine the new address. fn allow_cheatcodes_on_create( &self, ecx: &mut InnerEvmContext, - inputs: &CreateInputs, - ) -> Address { - let old_nonce = ecx - .journaled_state - .state - .get(&inputs.caller) - .map(|acc| acc.info.nonce) - .unwrap_or_default(); - let created_address = inputs.created_address(old_nonce); - - if ecx.journaled_state.depth > 1 && !ecx.db.has_cheatcode_access(&inputs.caller) { - // we only grant cheat code access for new contracts if the caller also has - // cheatcode access and the new contract is created in top most call - return created_address; + caller: Address, + created_address: Address, + ) { + if ecx.journaled_state.depth <= 1 || ecx.db.has_cheatcode_access(&caller) { + ecx.db.allow_cheatcode_access(created_address); } - - ecx.db.allow_cheatcode_access(created_address); - - created_address } /// Called when there was a revert. @@ -430,6 +419,222 @@ impl Cheatcodes { } } + // common create functionality for both legacy and EOF. + fn create_common( + &mut self, + ecx: &mut EvmContext, + mut input: Input, + ) -> Option + where + DB: DatabaseExt, + Input: CommonCreateInput, + { + let ecx = &mut ecx.inner; + let gas = Gas::new(input.gas_limit()); + + // Apply our prank + if let Some(prank) = &self.prank { + if ecx.journaled_state.depth() >= prank.depth && input.caller() == prank.prank_caller { + // At the target depth we set `msg.sender` + if ecx.journaled_state.depth() == prank.depth { + input.set_caller(prank.new_caller); + } + + // At the target depth, or deeper, we set `tx.origin` + if let Some(new_origin) = prank.new_origin { + ecx.env.tx.caller = new_origin; + } + } + } + + // Apply our broadcast + if let Some(broadcast) = &self.broadcast { + if ecx.journaled_state.depth() >= broadcast.depth && + input.caller() == broadcast.original_caller + { + if let Err(err) = + ecx.journaled_state.load_account(broadcast.new_origin, &mut ecx.db) + { + return Some(CreateOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: Error::encode(err), + gas, + }, + address: None, + }) + } + + ecx.env.tx.caller = broadcast.new_origin; + + if ecx.journaled_state.depth() == broadcast.depth { + input.set_caller(broadcast.new_origin); + let is_fixed_gas_limit = check_if_fixed_gas_limit(ecx, input.gas_limit()); + + let account = &ecx.journaled_state.state()[&broadcast.new_origin]; + self.broadcastable_transactions.push_back(BroadcastableTransaction { + rpc: ecx.db.active_fork_url(), + transaction: TransactionRequest { + from: Some(broadcast.new_origin), + to: None, + value: Some(input.value()), + input: TransactionInput::new(input.init_code()), + nonce: Some(account.info.nonce), + gas: if is_fixed_gas_limit { + Some(input.gas_limit() as u128) + } else { + None + }, + ..Default::default() + }, + }); + + input.log_debug(self, &input.scheme().unwrap_or(CreateScheme::Create)); + } + } + } + + // Allow cheatcodes from the address of the new contract + let address = input.allow_cheatcodes(self, ecx); + + // If `recordAccountAccesses` has been called, record the create + if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + recorded_account_diffs_stack.push(vec![AccountAccess { + chainInfo: crate::Vm::ChainInfo { + forkId: ecx.db.active_fork_id().unwrap_or_default(), + chainId: U256::from(ecx.env.cfg.chain_id), + }, + accessor: input.caller(), + account: address, + kind: crate::Vm::AccountAccessKind::Create, + initialized: true, + oldBalance: U256::ZERO, // updated on (eof)create_end + newBalance: U256::ZERO, // updated on (eof)create_end + value: input.value(), + data: input.init_code(), + reverted: false, + deployedCode: Bytes::new(), // updated on (eof)create_end + storageAccesses: vec![], // updated on (eof)create_end + depth: ecx.journaled_state.depth(), + }]); + } + + None + } + + // common create_end functionality for both legacy and EOF. + fn create_end_common( + &mut self, + ecx: &mut EvmContext, + mut outcome: CreateOutcome, + ) -> CreateOutcome + where + DB: DatabaseExt, + { + let ecx = &mut ecx.inner; + + // Clean up pranks + if let Some(prank) = &self.prank { + if ecx.journaled_state.depth() == prank.depth { + ecx.env.tx.caller = prank.prank_origin; + + // Clean single-call prank once we have returned to the original depth + if prank.single_call { + std::mem::take(&mut self.prank); + } + } + } + + // Clean up broadcasts + if let Some(broadcast) = &self.broadcast { + if ecx.journaled_state.depth() == broadcast.depth { + ecx.env.tx.caller = broadcast.original_origin; + + // Clean single-call broadcast once we have returned to the original depth + if broadcast.single_call { + std::mem::take(&mut self.broadcast); + } + } + } + + // 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) + { + let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); + return match expect::handle_expect_revert( + true, + expected_revert.reason.as_deref(), + outcome.result.result, + outcome.result.output.clone(), + ) { + Ok((address, retdata)) => { + outcome.result.result = InstructionResult::Return; + outcome.result.output = retdata; + outcome.address = address; + outcome + } + Err(err) => { + outcome.result.result = InstructionResult::Revert; + outcome.result.output = err.abi_encode().into(); + outcome + } + }; + } + } + + // If `startStateDiffRecording` has been called, update the `reverted` status of the + // previous call depth's recorded accesses, if any + if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { + // The root call cannot be recorded. + if ecx.journaled_state.depth() > 0 { + let mut last_depth = + recorded_account_diffs_stack.pop().expect("missing CREATE account accesses"); + // Update the reverted status of all deeper calls if this call reverted, in + // accordance with EVM behavior + if outcome.result.is_revert() { + last_depth.iter_mut().for_each(|element| { + element.reverted = true; + element + .storageAccesses + .iter_mut() + .for_each(|storage_access| storage_access.reverted = true); + }) + } + let create_access = last_depth.first_mut().expect("empty AccountAccesses"); + // Assert that we're at the correct depth before recording post-create state + // changes. Depending on what depth the cheat was called at, there + // may not be any pending calls to update if execution has + // percolated up to a higher depth. + if create_access.depth == ecx.journaled_state.depth() { + debug_assert_eq!( + create_access.kind as u8, + crate::Vm::AccountAccessKind::Create as u8 + ); + if let Some(address) = outcome.address { + if let Ok((created_acc, _)) = + ecx.journaled_state.load_account(address, &mut ecx.db) + { + create_access.newBalance = created_acc.info.balance; + create_access.deployedCode = + created_acc.info.code.clone().unwrap_or_default().original_bytes(); + } + } + } + // Merge the last depth's AccountAccesses into the AccountAccesses at the current + // depth, or push them back onto the pending vector if higher depths were not + // recorded. This preserves ordering of accesses. + if let Some(last) = recorded_account_diffs_stack.last_mut() { + last.append(&mut last_depth); + } else { + recorded_account_diffs_stack.push(last_depth); + } + } + } + outcome + } + pub fn call_with_executor( &mut self, ecx: &mut EvmContext, @@ -628,7 +833,8 @@ impl Cheatcodes { account.info.nonce += 1; debug!(target: "cheatcodes", address=%broadcast.new_origin, nonce=prev+1, prev, "incremented nonce"); } else if broadcast.single_call { - let msg = "`staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead"; + let msg = + "`staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead"; return Some(CallOutcome { result: InterpreterResult { result: InstructionResult::Revert, @@ -1039,216 +1245,33 @@ impl Inspector for Cheatcodes { ecx: &mut EvmContext, call: &mut CreateInputs, ) -> Option { - let ecx = &mut ecx.inner; - let gas = Gas::new(call.gas_limit); - - // Apply our prank - if let Some(prank) = &self.prank { - if ecx.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { - // At the target depth we set `msg.sender` - if ecx.journaled_state.depth() == prank.depth { - call.caller = prank.new_caller; - } - - // At the target depth, or deeper, we set `tx.origin` - if let Some(new_origin) = prank.new_origin { - ecx.env.tx.caller = new_origin; - } - } - } - - // Apply our broadcast - if let Some(broadcast) = &self.broadcast { - if ecx.journaled_state.depth() >= broadcast.depth && - call.caller == broadcast.original_caller - { - if let Err(err) = - ecx.journaled_state.load_account(broadcast.new_origin, &mut ecx.db) - { - return Some(CreateOutcome { - result: InterpreterResult { - result: InstructionResult::Revert, - output: Error::encode(err), - gas, - }, - address: None, - }) - } - - ecx.env.tx.caller = broadcast.new_origin; - - if ecx.journaled_state.depth() == broadcast.depth { - call.caller = broadcast.new_origin; - let is_fixed_gas_limit = check_if_fixed_gas_limit(ecx, call.gas_limit); - - let account = &ecx.journaled_state.state()[&broadcast.new_origin]; - - self.broadcastable_transactions.push_back(BroadcastableTransaction { - rpc: ecx.db.active_fork_url(), - transaction: TransactionRequest { - from: Some(broadcast.new_origin), - to: None, - value: Some(call.value), - input: TransactionInput::new(call.init_code.clone()), - nonce: Some(account.info.nonce), - gas: if is_fixed_gas_limit { - Some(call.gas_limit as u128) - } else { - None - }, - ..Default::default() - }, - }); - - let kind = match call.scheme { - CreateScheme::Create => "create", - CreateScheme::Create2 { .. } => "create2", - }; - debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable {kind}"); - } - } - } - - // allow cheatcodes from the address of the new contract - // Compute the address *after* any possible broadcast updates, so it's based on the updated - // call inputs - let address = self.allow_cheatcodes_on_create(ecx, call); - // If `recordAccountAccesses` has been called, record the create - if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { - // Record the create context as an account access and create a new vector to record all - // subsequent account accesses - recorded_account_diffs_stack.push(vec![AccountAccess { - chainInfo: crate::Vm::ChainInfo { - forkId: ecx.db.active_fork_id().unwrap_or_default(), - chainId: U256::from(ecx.env.cfg.chain_id), - }, - accessor: call.caller, - account: address, - kind: crate::Vm::AccountAccessKind::Create, - initialized: true, - oldBalance: U256::ZERO, // updated on create_end - newBalance: U256::ZERO, // updated on create_end - value: call.value, - data: call.init_code.clone(), - reverted: false, - deployedCode: Bytes::new(), // updated on create_end - storageAccesses: vec![], // updated on create_end - depth: ecx.journaled_state.depth(), - }]); - } - - None + self.create_common(ecx, call) } fn create_end( &mut self, ecx: &mut EvmContext, _call: &CreateInputs, - mut outcome: CreateOutcome, + outcome: CreateOutcome, ) -> CreateOutcome { - let ecx = &mut ecx.inner; - - // Clean up pranks - if let Some(prank) = &self.prank { - if ecx.journaled_state.depth() == prank.depth { - ecx.env.tx.caller = prank.prank_origin; - - // Clean single-call prank once we have returned to the original depth - if prank.single_call { - std::mem::take(&mut self.prank); - } - } - } - - // Clean up broadcasts - if let Some(broadcast) = &self.broadcast { - if ecx.journaled_state.depth() == broadcast.depth { - ecx.env.tx.caller = broadcast.original_origin; - - // Clean single-call broadcast once we have returned to the original depth - if broadcast.single_call { - std::mem::take(&mut self.broadcast); - } - } - } - - // 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) - { - let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - return match expect::handle_expect_revert( - true, - expected_revert.reason.as_deref(), - outcome.result.result, - outcome.result.output.clone(), - ) { - Ok((address, retdata)) => { - outcome.result.result = InstructionResult::Return; - outcome.result.output = retdata; - outcome.address = address; - outcome - } - Err(err) => { - outcome.result.result = InstructionResult::Revert; - outcome.result.output = err.abi_encode().into(); - outcome - } - }; - } - } + self.create_end_common(ecx, outcome) + } - // If `startStateDiffRecording` has been called, update the `reverted` status of the - // previous call depth's recorded accesses, if any - if let Some(recorded_account_diffs_stack) = &mut self.recorded_account_diffs_stack { - // The root call cannot be recorded. - if ecx.journaled_state.depth() > 0 { - let mut last_depth = - recorded_account_diffs_stack.pop().expect("missing CREATE account accesses"); - // Update the reverted status of all deeper calls if this call reverted, in - // accordance with EVM behavior - if outcome.result.is_revert() { - last_depth.iter_mut().for_each(|element| { - element.reverted = true; - element - .storageAccesses - .iter_mut() - .for_each(|storage_access| storage_access.reverted = true); - }) - } - let create_access = last_depth.first_mut().expect("empty AccountAccesses"); - // Assert that we're at the correct depth before recording post-create state - // changes. Depending on what depth the cheat was called at, there - // may not be any pending calls to update if execution has - // percolated up to a higher depth. - if create_access.depth == ecx.journaled_state.depth() { - debug_assert_eq!( - create_access.kind as u8, - crate::Vm::AccountAccessKind::Create as u8 - ); - if let Some(address) = outcome.address { - if let Ok((created_acc, _)) = - ecx.journaled_state.load_account(address, &mut ecx.db) - { - create_access.newBalance = created_acc.info.balance; - create_access.deployedCode = - created_acc.info.code.clone().unwrap_or_default().original_bytes(); - } - } - } - // Merge the last depth's AccountAccesses into the AccountAccesses at the current - // depth, or push them back onto the pending vector if higher depths were not - // recorded. This preserves ordering of accesses. - if let Some(last) = recorded_account_diffs_stack.last_mut() { - last.append(&mut last_depth); - } else { - recorded_account_diffs_stack.push(last_depth); - } - } - } + fn eofcreate( + &mut self, + ecx: &mut EvmContext, + call: &mut EOFCreateInputs, + ) -> Option { + self.create_common(ecx, call) + } - outcome + fn eofcreate_end( + &mut self, + ecx: &mut EvmContext, + _call: &EOFCreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { + self.create_end_common(ecx, outcome) } } diff --git a/crates/cheatcodes/src/inspector/utils.rs b/crates/cheatcodes/src/inspector/utils.rs new file mode 100644 index 0000000000000..dfccd4b55552c --- /dev/null +++ b/crates/cheatcodes/src/inspector/utils.rs @@ -0,0 +1,111 @@ +use crate::inspector::Cheatcodes; +use alloy_primitives::{Address, Bytes, U256}; +use foundry_evm_core::backend::DatabaseExt; +use revm::{ + interpreter::{CreateInputs, CreateScheme, EOFCreateInputs, EOFCreateKind}, + InnerEvmContext, +}; + +/// Common behaviour of legacy and EOF create inputs. +pub(crate) trait CommonCreateInput { + fn caller(&self) -> Address; + fn gas_limit(&self) -> u64; + fn value(&self) -> U256; + fn init_code(&self) -> Bytes; + fn scheme(&self) -> Option; + fn set_caller(&mut self, caller: Address); + fn log_debug(&self, cheatcode: &mut Cheatcodes, scheme: &CreateScheme); + fn allow_cheatcodes( + &self, + cheatcodes: &mut Cheatcodes, + ecx: &mut InnerEvmContext, + ) -> Address; + fn computed_created_address(&self) -> Option
; +} + +impl CommonCreateInput for &mut CreateInputs { + fn caller(&self) -> Address { + self.caller + } + fn gas_limit(&self) -> u64 { + self.gas_limit + } + fn value(&self) -> U256 { + self.value + } + fn init_code(&self) -> Bytes { + self.init_code.clone() + } + fn scheme(&self) -> Option { + Some(self.scheme) + } + fn set_caller(&mut self, caller: Address) { + self.caller = caller; + } + fn log_debug(&self, cheatcode: &mut Cheatcodes, scheme: &CreateScheme) { + let kind = match scheme { + CreateScheme::Create => "create", + CreateScheme::Create2 { .. } => "create2", + }; + debug!(target: "cheatcodes", tx=?cheatcode.broadcastable_transactions.back().unwrap(), "broadcastable {kind}"); + } + fn allow_cheatcodes( + &self, + cheatcodes: &mut Cheatcodes, + ecx: &mut InnerEvmContext, + ) -> Address { + let old_nonce = ecx + .journaled_state + .state + .get(&self.caller) + .map(|acc| acc.info.nonce) + .unwrap_or_default(); + let created_address = self.created_address(old_nonce); + cheatcodes.allow_cheatcodes_on_create(ecx, self.caller, created_address); + created_address + } + fn computed_created_address(&self) -> Option
{ + None + } +} + +impl CommonCreateInput for &mut EOFCreateInputs { + fn caller(&self) -> Address { + self.caller + } + fn gas_limit(&self) -> u64 { + self.gas_limit + } + fn value(&self) -> U256 { + self.value + } + fn init_code(&self) -> Bytes { + match &self.kind { + EOFCreateKind::Tx { initdata } => initdata.clone(), + EOFCreateKind::Opcode { initcode, .. } => initcode.raw.clone(), + } + } + fn scheme(&self) -> Option { + None + } + fn set_caller(&mut self, caller: Address) { + self.caller = caller; + } + fn log_debug(&self, cheatcode: &mut Cheatcodes, _scheme: &CreateScheme) { + debug!(target: "cheatcodes", tx=?cheatcode.broadcastable_transactions.back().unwrap(), "broadcastable eofcreate"); + } + fn allow_cheatcodes( + &self, + cheatcodes: &mut Cheatcodes, + ecx: &mut InnerEvmContext, + ) -> Address { + let created_address = + <&mut EOFCreateInputs as CommonCreateInput>::computed_created_address(self) + .unwrap_or_default(); + cheatcodes.allow_cheatcodes_on_create(ecx, self.caller, created_address); + created_address + } + fn computed_created_address(&self) -> Option
{ + self.kind.created_address().copied() + } +} diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index a4930ca452446..cd394cfb86785 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -13,8 +13,8 @@ use foundry_evm_traces::CallTraceArena; use revm::{ inspectors::CustomPrintTracer, interpreter::{ - CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult, - Interpreter, InterpreterResult, + CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, EOFCreateInputs, + EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterResult, }, primitives::{ BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, Output, TransactTo, @@ -828,6 +828,78 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { outcome } + fn eofcreate( + &mut self, + ecx: &mut EvmContext, + create: &mut EOFCreateInputs, + ) -> Option { + if self.in_inner_context && ecx.journaled_state.depth == 0 { + self.adjust_evm_data_for_inner_context(ecx); + return None; + } + + call_inspectors_adjust_depth!( + #[ret] + [&mut self.tracer, &mut self.coverage, &mut self.cheatcodes], + |inspector| inspector.eofcreate(ecx, create).map(Some), + self, + ecx + ); + + if self.enable_isolation && !self.in_inner_context && ecx.journaled_state.depth == 1 { + let init_code = match &create.kind { + EOFCreateKind::Tx { initdata } => initdata.clone(), + EOFCreateKind::Opcode { initcode, .. } => initcode.raw.clone(), + }; + + let (result, address) = self.transact_inner( + ecx, + TxKind::Create, + create.caller, + init_code, + create.gas_limit, + create.value, + ); + return Some(CreateOutcome { result, address }) + } + + None + } + + fn eofcreate_end( + &mut self, + ecx: &mut EvmContext, + call: &EOFCreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { + // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. + // Avoid processing twice. + if self.in_inner_context && ecx.journaled_state.depth == 0 { + return outcome + } + + let result = outcome.result.result; + + call_inspectors_adjust_depth!( + #[ret] + [&mut self.tracer, &mut self.cheatcodes, &mut self.printer], + |inspector| { + let new_outcome = inspector.eofcreate_end(ecx, call, outcome.clone()); + + // If the inspector returns a different status or a revert with a non-empty message, + // we assume it wants to tell us something + let different = new_outcome.result.result != result || + (new_outcome.result.result == InstructionResult::Revert && + new_outcome.output() != outcome.output()); + different.then_some(new_outcome) + }, + self, + ecx + ); + + outcome + } + fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { call_inspectors!([&mut self.tracer, &mut self.printer], |inspector| { Inspector::::selfdestruct(inspector, contract, target, value) From 88c9b7f2a801fbfc6a0095a7342cfa919dac36fc Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:34:15 +0200 Subject: [PATCH 1170/1963] fix(cheatcodes): fallback to string if invalid 0x hex (#8290) --- crates/cheatcodes/src/json.rs | 16 +++++++------- crates/forge/tests/it/repros.rs | 3 +++ testdata/default/repros/Issue8277.t.sol | 28 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 testdata/default/repros/Issue8277.t.sol diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index 4ecd595f4d65c..eea16997172aa 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -448,15 +448,15 @@ pub(super) fn json_value_to_token(value: &Value) -> Result { s = format!("0{val}"); val = &s[..]; } - let bytes = hex::decode(val)?; - Ok(match bytes.len() { - 20 => DynSolValue::Address(Address::from_slice(&bytes)), - 32 => DynSolValue::FixedBytes(B256::from_slice(&bytes), 32), - _ => DynSolValue::Bytes(bytes), - }) - } else { - Ok(DynSolValue::String(string.to_owned())) + if let Ok(bytes) = hex::decode(val) { + return Ok(match bytes.len() { + 20 => DynSolValue::Address(Address::from_slice(&bytes)), + 32 => DynSolValue::FixedBytes(B256::from_slice(&bytes), 32), + _ => DynSolValue::Bytes(bytes), + }); + } } + Ok(DynSolValue::String(string.to_owned())) } } } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index edda3f69771be..94a06c48845f7 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -343,5 +343,8 @@ test_repro!(2851, false, None, |res| { // https://github.com/foundry-rs/foundry/issues/8006 test_repro!(8006); +// https://github.com/foundry-rs/foundry/issues/8277 +test_repro!(8277); + // https://github.com/foundry-rs/foundry/issues/8287 test_repro!(8287); diff --git a/testdata/default/repros/Issue8277.t.sol b/testdata/default/repros/Issue8277.t.sol new file mode 100644 index 0000000000000..aebdbd8ffe6be --- /dev/null +++ b/testdata/default/repros/Issue8277.t.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/8277 +contract Issue8277Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + struct MyJson { + string s; + } + + function test_hexprefixednonhexstring() public { + { + bytes memory b = vm.parseJson("{\"a\": \"0x834629f473876e5f0d3d9d269af3dabcb0d7d520-identifier-0\"}"); + MyJson memory decoded = abi.decode(b, (MyJson)); + assertEq(decoded.s, "0x834629f473876e5f0d3d9d269af3dabcb0d7d520-identifier-0"); + } + + { + bytes memory b = vm.parseJson("{\"b\": \"0xBTC\"}"); + MyJson memory decoded = abi.decode(b, (MyJson)); + assertEq(decoded.s, "0xBTC"); + } + } +} From dd81d799be31e4436b667138a5a1714c5823cdf2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 29 Jun 2024 00:57:43 +0200 Subject: [PATCH 1171/1963] test: update snekmate rev (#8295) * test: update snekmate rev * chore: bump vyper --- .github/workflows/nextest.yml | 2 +- crates/forge/tests/cli/ext_integration.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nextest.yml b/.github/workflows/nextest.yml index 1c5089db4cc90..8803540806de3 100644 --- a/.github/workflows/nextest.yml +++ b/.github/workflows/nextest.yml @@ -73,7 +73,7 @@ jobs: python-version: 3.11 - name: Install Vyper if: contains(matrix.name, 'external') - run: pip install vyper~=0.3.10 + run: pip install vyper~=0.4.0 - name: Forge RPC cache uses: actions/cache@v3 diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 2930b6b8ead2f..570990bf8fd3e 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -94,7 +94,7 @@ fn lil_web3() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn snekmate() { - ExtTester::new("pcaversaccio", "snekmate", "1aa50098720d49e04b257a4aa5138b3d737a0667") + ExtTester::new("pcaversaccio", "snekmate", "316088761ca7605216b5bfbbecca8d694c61ed98") .install_command(&["pnpm", "install", "--prefer-offline"]) // Try npm if pnpm fails / is not installed. .install_command(&["npm", "install", "--prefer-offline"]) From 8b5653662ff49e92ba63df0394e756b87e336ae5 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 29 Jun 2024 02:59:44 +0400 Subject: [PATCH 1172/1963] feat: `legacy_assertions` config option (#8263) * apply_full * feat: legacy_assertions flag * forge fmt * fix test * fix docs * fix: test * legacy_assertions -> assertions_revert * legacy_assertions * fix: enable legacy assertions for legacy ext tests * update README --- Cargo.lock | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/src/config.rs | 6 +- crates/cheatcodes/src/fs.rs | 6 +- crates/cheatcodes/src/inspector.rs | 99 ++++++++++++++------ crates/cheatcodes/src/lib.rs | 4 +- crates/cheatcodes/src/test/assert.rs | 37 +++++--- crates/chisel/src/executor.rs | 1 + crates/config/README.md | 5 + crates/config/src/lib.rs | 8 +- crates/evm/evm/src/executors/builder.rs | 19 +++- crates/evm/evm/src/executors/mod.rs | 29 +++--- crates/forge/src/multi_runner.rs | 1 + crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/ext_integration.rs | 2 + crates/forge/tests/it/core.rs | 63 +++++++++++++ crates/script/src/lib.rs | 3 +- testdata/default/core/LegacyAssertions.t.sol | 24 +++++ 18 files changed, 242 insertions(+), 68 deletions(-) create mode 100644 testdata/default/core/LegacyAssertions.t.sol diff --git a/Cargo.lock b/Cargo.lock index 07ace0506a4b6..5b79dd3c084c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3556,6 +3556,7 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", + "foundry-evm-abi", "foundry-evm-core", "foundry-wallets", "itertools 0.13.0", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 7e2e366e96edf..09cd319b8d7d0 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -21,6 +21,7 @@ foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm-core.workspace = true foundry-wallets.workspace = true +foundry-evm-abi.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 359dec34a3002..9a9e59ccec7b3 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -53,7 +53,7 @@ pub struct CheatsConfig { /// Version of the script/test contract which is currently running. pub running_version: Option, /// Whether to enable legacy (non-reverting) assertions. - pub legacy_assertions: bool, + pub assertions_revert: bool, } impl CheatsConfig { @@ -92,7 +92,7 @@ impl CheatsConfig { script_wallets, available_artifacts, running_version, - legacy_assertions: config.legacy_assertions, + assertions_revert: config.assertions_revert, } } @@ -220,7 +220,7 @@ impl Default for CheatsConfig { script_wallets: None, available_artifacts: Default::default(), running_version: Default::default(), - legacy_assertions: Default::default(), + assertions_revert: true, } } } diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 045ebea27e45f..129f8a22e939e 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -281,8 +281,7 @@ impl Cheatcode for deployCode_0Call { init_code: bytecode, gas_limit: ccx.gas_limit, }, - ccx.state, - ccx.ecx, + ccx, ) .unwrap(); @@ -308,8 +307,7 @@ impl Cheatcode for deployCode_1Call { init_code: bytecode.into(), gas_limit: ccx.gas_limit, }, - ccx.state, - ccx.ecx, + ccx, ) .unwrap(); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index bd6485d0c1df3..91d6df148cb75 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -21,6 +21,7 @@ use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolCall, SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, SELECTOR_LEN}; use foundry_config::Config; +use foundry_evm_abi::Console; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseExt, RevertDiagnostic}, @@ -63,55 +64,91 @@ pub trait CheatcodesExecutor { cheats: &'a mut Cheatcodes, ) -> impl InspectorExt + 'a; - /// Obtains [revm::Inspector] instance and executes the given CREATE frame. - fn exec_create( + /// Constructs [revm::Evm] and runs a given closure with it. + fn with_evm( &mut self, - inputs: CreateInputs, - cheats: &mut Cheatcodes, - ecx: &mut InnerEvmContext, - ) -> Result> { - let inspector = self.get_inspector(cheats); - let error = std::mem::replace(&mut ecx.error, Ok(())); - let l1_block_info = std::mem::take(&mut ecx.l1_block_info); + ccx: &mut CheatsCtxt, + f: F, + ) -> Result> + where + F: for<'a, 'b> FnOnce( + &mut revm::Evm< + '_, + &'b mut dyn InspectorExt<&'a mut dyn DatabaseExt>, + &'a mut dyn DatabaseExt, + >, + ) -> Result>, + { + let mut inspector = self.get_inspector(ccx.state); + let error = std::mem::replace(&mut ccx.ecx.error, Ok(())); + let l1_block_info = std::mem::take(&mut ccx.ecx.l1_block_info); let inner = revm::InnerEvmContext { - env: ecx.env.clone(), + env: ccx.ecx.env.clone(), journaled_state: std::mem::replace( - &mut ecx.journaled_state, + &mut ccx.ecx.journaled_state, revm::JournaledState::new(Default::default(), Default::default()), ), - db: &mut ecx.db as &mut dyn DatabaseExt, + db: &mut ccx.ecx.db as &mut dyn DatabaseExt, error, l1_block_info, }; - let mut evm = new_evm_with_existing_context(inner, inspector); + let mut evm = new_evm_with_existing_context(inner, &mut inspector as _); - evm.context.evm.inner.journaled_state.depth += 1; + let res = f(&mut evm)?; - let first_frame_or_result = - evm.handler.execution().create(&mut evm.context, Box::new(inputs))?; + ccx.ecx.journaled_state = evm.context.evm.inner.journaled_state; + ccx.ecx.env = evm.context.evm.inner.env; + ccx.ecx.l1_block_info = evm.context.evm.inner.l1_block_info; + ccx.ecx.error = evm.context.evm.inner.error; - let mut result = match first_frame_or_result { - revm::FrameOrResult::Frame(first_frame) => evm.run_the_loop(first_frame)?, - revm::FrameOrResult::Result(result) => result, - }; + Ok(res) + } + + /// Obtains [revm::Evm] instance and executes the given CREATE frame. + fn exec_create( + &mut self, + inputs: CreateInputs, + ccx: &mut CheatsCtxt, + ) -> Result> { + self.with_evm(ccx, |evm| { + evm.context.evm.inner.journaled_state.depth += 1; - evm.handler.execution().last_frame_return(&mut evm.context, &mut result)?; + let first_frame_or_result = + evm.handler.execution().create(&mut evm.context, Box::new(inputs))?; - let outcome = match result { - revm::FrameResult::Call(_) | revm::FrameResult::EOFCreate(_) => unreachable!(), - revm::FrameResult::Create(create) => create, - }; + let mut result = match first_frame_or_result { + revm::FrameOrResult::Frame(first_frame) => evm.run_the_loop(first_frame)?, + revm::FrameOrResult::Result(result) => result, + }; + + evm.handler.execution().last_frame_return(&mut evm.context, &mut result)?; - evm.context.evm.inner.journaled_state.depth -= 1; + let outcome = match result { + revm::FrameResult::Call(_) | revm::FrameResult::EOFCreate(_) => unreachable!(), + revm::FrameResult::Create(create) => create, + }; + + evm.context.evm.inner.journaled_state.depth -= 1; + + Ok(outcome) + }) + } + + fn console_log( + &mut self, + ccx: &mut CheatsCtxt, + message: String, + ) -> Result<(), EVMError> { + self.with_evm(ccx, |evm| { + let log = + Log { address: CHEATCODE_ADDRESS, data: (&Console::log { val: message }).into() }; - ecx.journaled_state = evm.context.evm.inner.journaled_state; - ecx.env = evm.context.evm.inner.env; - ecx.l1_block_info = evm.context.evm.inner.l1_block_info; - ecx.error = evm.context.evm.inner.error; + evm.context.external.log(&mut evm.context.evm, &log); - Ok(outcome) + Ok(()) + }) } } diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 85ce8d78c51d8..5b46fd7e5a851 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -98,8 +98,8 @@ impl DynCheatcode for T { } } -/// The cheatcode context, used in [`Cheatcode`]. -pub(crate) struct CheatsCtxt<'cheats, 'evm, DB: DatabaseExt> { +/// The cheatcode context, used in `Cheatcode`. +pub struct CheatsCtxt<'cheats, 'evm, DB: DatabaseExt> { /// The cheatcodes inspector state. pub(crate) state: &'cheats mut Cheatcodes, /// The EVM data. diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index fe9f3b39b51f1..3f85b6e5c1c66 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -1,6 +1,10 @@ -use crate::{Cheatcodes, Result, Vm::*}; +use crate::{CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{hex, I256, U256}; -use foundry_evm_core::abi::{format_units_int, format_units_uint}; +use foundry_evm_core::{ + abi::{format_units_int, format_units_uint}, + backend::{DatabaseExt, GLOBAL_FAIL_SLOT}, + constants::CHEATCODE_ADDRESS, +}; use itertools::Itertools; use std::fmt::{Debug, Display}; @@ -165,10 +169,11 @@ impl EqRelAssertionError { type ComparisonResult<'a, T> = Result, ComparisonAssertionError<'a, T>>; -fn handle_assertion_result( - result: core::result::Result, E>, - state: &mut Cheatcodes, - error_formatter: impl Fn(&E) -> String, +fn handle_assertion_result( + result: core::result::Result, ERR>, + ccx: &mut CheatsCtxt, + executor: &mut E, + error_formatter: impl Fn(&ERR) -> String, error_msg: Option<&str>, format_error: bool, ) -> Result { @@ -181,9 +186,11 @@ fn handle_assertion_result( } else { error_msg }; - if !state.config.legacy_assertions { + if ccx.state.config.assertions_revert { Err(msg.into()) } else { + executor.console_log(ccx, msg)?; + ccx.ecx.sstore(CHEATCODE_ADDRESS, GLOBAL_FAIL_SLOT, U256::from(1))?; Ok(Default::default()) } } @@ -217,16 +224,24 @@ macro_rules! impl_assertions { }; (@impl $no_error:ident, $with_error:ident, ($($arg:ident),*), $body:expr, $error_formatter:expr, $format_error:literal) => { impl crate::Cheatcode for $no_error { - fn apply(&self, state: &mut Cheatcodes) -> Result { + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + executor: &mut E, + ) -> Result { let Self { $($arg),* } = self; - handle_assertion_result($body, state, $error_formatter, None, $format_error) + handle_assertion_result($body, ccx, executor, $error_formatter, None, $format_error) } } impl crate::Cheatcode for $with_error { - fn apply(&self, state: &mut Cheatcodes) -> Result { + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + executor: &mut E, + ) -> Result { let Self { $($arg),*, error} = self; - handle_assertion_result($body, state, $error_formatter, Some(error), $format_error) + handle_assertion_result($body, ccx, executor, $error_formatter, Some(error), $format_error) } } }; diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 5aa2190df5890..268e4b20955f9 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -315,6 +315,7 @@ impl SessionSource { }) .gas_limit(self.config.evm_opts.gas_limit()) .spec(self.config.foundry_config.evm_spec_id()) + .legacy_assertions(self.config.foundry_config.legacy_assertions) .build(env, backend); // Create a [ChiselRunner] with a default balance of [U256::MAX] and diff --git a/crates/config/README.md b/crates/config/README.md index 0ef55336a7dae..b490daceafeed 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -179,6 +179,11 @@ root = "root" # following example enables read-write access for the project dir : # `fs_permissions = [{ access = "read-write", path = "./"}]` fs_permissions = [{ access = "read", path = "./out"}] +# whether failed assertions should revert +# note that this only applies to native (cheatcode) assertions, invoked on Vm contract +assertions_revert = true +# whether `failed()` should be invoked to check if the test have failed +legacy_assertions = false [fuzz] runs = 256 max_test_rejects = 65536 diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f2010734aeb04..5a55f1da8e03a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -421,7 +421,12 @@ pub struct Config { #[serde(default, skip_serializing)] pub root: RootPath, - /// Whether to enable legacy (non-reverting) assertions. + /// Whether failed assertions should revert. + /// + /// Note that this only applies to native (cheatcode) assertions, invoked on Vm contract. + pub assertions_revert: bool, + + /// Whether `failed()` should be invoked to check if the test have failed. pub legacy_assertions: bool, /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information @@ -2121,6 +2126,7 @@ impl Default for Config { create2_library_salt: Self::DEFAULT_CREATE2_LIBRARY_SALT, skip: vec![], dependencies: Default::default(), + assertions_revert: true, legacy_assertions: false, warnings: vec![], _non_exhaustive: (), diff --git a/crates/evm/evm/src/executors/builder.rs b/crates/evm/evm/src/executors/builder.rs index 69b798161eb2e..fee3c249ad90a 100644 --- a/crates/evm/evm/src/executors/builder.rs +++ b/crates/evm/evm/src/executors/builder.rs @@ -18,12 +18,18 @@ pub struct ExecutorBuilder { gas_limit: Option, /// The spec ID. spec_id: SpecId, + legacy_assertions: bool, } impl Default for ExecutorBuilder { #[inline] fn default() -> Self { - Self { stack: InspectorStackBuilder::new(), gas_limit: None, spec_id: SpecId::LATEST } + Self { + stack: InspectorStackBuilder::new(), + gas_limit: None, + spec_id: SpecId::LATEST, + legacy_assertions: false, + } } } @@ -58,10 +64,17 @@ impl ExecutorBuilder { self } + /// Sets the `legacy_assertions` flag. + #[inline] + pub fn legacy_assertions(mut self, legacy_assertions: bool) -> Self { + self.legacy_assertions = legacy_assertions; + self + } + /// Builds the executor as configured. #[inline] pub fn build(self, env: Env, db: Backend) -> Executor { - let Self { mut stack, gas_limit, spec_id } = self; + let Self { mut stack, gas_limit, spec_id, legacy_assertions } = self; if stack.block.is_none() { stack.block = Some(env.block.clone()); } @@ -70,6 +83,6 @@ impl ExecutorBuilder { } let gas_limit = gas_limit.unwrap_or_else(|| env.block.gas_limit.saturating_to()); let env = EnvWithHandlerCfg::new_with_spec_id(Box::new(env), spec_id); - Executor::new(db, env, stack.build(), gas_limit) + Executor::new(db, env, stack.build(), gas_limit, legacy_assertions) } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 09fd620f5f232..160c37f6f28ae 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -80,6 +80,8 @@ pub struct Executor { /// the passed in environment, as those limits are used by the EVM for certain opcodes like /// `gaslimit`. gas_limit: u64, + /// Whether `failed()` should be called on the test contract to determine if the test failed. + legacy_assertions: bool, } impl Executor { @@ -96,6 +98,7 @@ impl Executor { env: EnvWithHandlerCfg, inspector: InspectorStack, gas_limit: u64, + legacy_assertions: bool, ) -> Self { // Need to create a non-empty contract on the cheatcodes address so `extcodesize` checks // do not fail. @@ -110,12 +113,12 @@ impl Executor { }, ); - Self { backend, env, inspector, gas_limit } + Self { backend, env, inspector, gas_limit, legacy_assertions } } fn clone_with_backend(&self, backend: Backend) -> Self { let env = EnvWithHandlerCfg::new_with_spec_id(Box::new(self.env().clone()), self.spec_id()); - Self::new(backend, env, self.inspector().clone(), self.gas_limit) + Self::new(backend, env, self.inspector().clone(), self.gas_limit, self.legacy_assertions) } /// Returns a reference to the EVM backend. @@ -512,19 +515,21 @@ impl Executor { } // Check the global failure slot. - // TODO: Wire this up - let legacy = true; - if !legacy { - if let Some(acc) = state_changeset.get(&CHEATCODE_ADDRESS) { - if let Some(failed_slot) = acc.storage.get(&GLOBAL_FAIL_SLOT) { - return failed_slot.present_value().is_zero(); + if let Some(acc) = state_changeset.get(&CHEATCODE_ADDRESS) { + if let Some(failed_slot) = acc.storage.get(&GLOBAL_FAIL_SLOT) { + if !failed_slot.present_value().is_zero() { + return false; } } - let Ok(failed_slot) = self.backend().storage_ref(CHEATCODE_ADDRESS, GLOBAL_FAIL_SLOT) - else { + } + if let Ok(failed_slot) = self.backend().storage_ref(CHEATCODE_ADDRESS, GLOBAL_FAIL_SLOT) { + if !failed_slot.is_zero() { return false; - }; - return failed_slot.is_zero(); + } + } + + if !self.legacy_assertions { + return true; } // Finally, resort to calling `DSTest::failed`. diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index f056d3cf1701c..d0b8fd41a00fa 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -247,6 +247,7 @@ impl MultiContractRunner { }) .spec(self.evm_spec) .gas_limit(self.evm_opts.gas_limit()) + .legacy_assertions(self.config.legacy_assertions) .build(self.env.clone(), db); if !enabled!(tracing::Level::TRACE) { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index ab9a6c2abff0a..6cdd179b349c9 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -139,6 +139,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { skip: vec![], dependencies: Default::default(), warnings: vec![], + assertions_revert: true, legacy_assertions: false, _non_exhaustive: (), }; diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 570990bf8fd3e..c693f47301082 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -69,6 +69,7 @@ fn solady() { #[cfg_attr(windows, ignore = "weird git fail")] fn geb() { ExtTester::new("reflexer-labs", "geb", "1a59f16a377386c49f520006ed0f7fd9d128cb09") + .env("FOUNDRY_LEGACY_ASSERTIONS", "true") .args(["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"]) .run(); } @@ -117,6 +118,7 @@ fn mds1_multicall() { fn drai() { ExtTester::new("mds1", "drai", "f31ce4fb15bbb06c94eefea2a3a43384c75b95cf") .args(["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"]) + .env("FOUNDRY_LEGACY_ASSERTIONS", "true") .fork_block(13633752) .run(); } diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 4c6fae77c5aaf..17d9f59d88fad 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -89,6 +89,23 @@ async fn test_core() { "default/core/BadSigAfterInvariant.t.sol:BadSigAfterInvariant", vec![("testShouldPassWithWarning()", true, None, None, None)], ), + ( + "default/core/LegacyAssertions.t.sol:NoAssertionsRevertTest", + vec![( + "testMultipleAssertFailures()", + false, + Some("assertion failed: 1 != 2".to_string()), + None, + None, + )], + ), + ( + "default/core/LegacyAssertions.t.sol:LegacyAssertionsTest", + vec![ + ("testFlagNotSetSuccess()", true, None, None, None), + ("testFlagSetFailure()", true, None, None, None), + ], + ), ]), ); } @@ -740,3 +757,49 @@ async fn test_trace() { } } } + +#[tokio::test(flavor = "multi_thread")] +async fn test_assertions_revert_false() { + let filter = Filter::new(".*", ".*NoAssertionsRevertTest", ".*"); + let mut config = TEST_DATA_DEFAULT.config.clone(); + config.assertions_revert = false; + let mut runner = TEST_DATA_DEFAULT.runner_with_config(config); + let results = runner.test_collect(&filter); + + assert_multiple( + &results, + BTreeMap::from([( + "default/core/LegacyAssertions.t.sol:NoAssertionsRevertTest", + vec![( + "testMultipleAssertFailures()", + false, + None, + Some(vec![ + "assertion failed: 1 != 2".to_string(), + "assertion failed: 5 >= 4".to_string(), + ]), + None, + )], + )]), + ); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_legacy_assertions() { + let filter = Filter::new(".*", ".*LegacyAssertions", ".*"); + let mut config = TEST_DATA_DEFAULT.config.clone(); + config.legacy_assertions = true; + let mut runner = TEST_DATA_DEFAULT.runner_with_config(config); + let results = runner.test_collect(&filter); + + assert_multiple( + &results, + BTreeMap::from([( + "default/core/LegacyAssertions.t.sol:LegacyAssertionsTest", + vec![ + ("testFlagNotSetSuccess()", true, None, None, None), + ("testFlagSetFailure()", false, None, None, None), + ], + )]), + ); +} diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index c1ae8882e35d3..f03e15fa29885 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -576,7 +576,8 @@ impl ScriptConfig { let mut builder = ExecutorBuilder::new() .inspectors(|stack| stack.trace(true)) .spec(self.config.evm_spec_id()) - .gas_limit(self.evm_opts.gas_limit()); + .gas_limit(self.evm_opts.gas_limit()) + .legacy_assertions(self.config.legacy_assertions); if let Some((known_contracts, script_wallets, target)) = cheats_data { builder = builder.inspectors(|stack| { diff --git a/testdata/default/core/LegacyAssertions.t.sol b/testdata/default/core/LegacyAssertions.t.sol new file mode 100644 index 0000000000000..9bbc56e8eae5b --- /dev/null +++ b/testdata/default/core/LegacyAssertions.t.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract NoAssertionsRevertTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testMultipleAssertFailures() public { + vm.assertEq(uint256(1), uint256(2)); + vm.assertLt(uint256(5), uint256(4)); + } +} + +contract LegacyAssertionsTest { + bool public failed; + + function testFlagNotSetSuccess() public {} + + function testFlagSetFailure() public { + failed = true; + } +} From 3e79baf182f5d20300d3e57ea04d8cd47185dec5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 29 Jun 2024 01:33:36 +0200 Subject: [PATCH 1173/1963] feat: reduce default gas limit to ~1B (#8274) * feat: reduce default gas limit to ~1B * com --- crates/config/README.md | 7 +-- crates/config/src/lib.rs | 55 ++++------------------- crates/config/src/utils.rs | 34 +++++++------- crates/evm/evm/src/inspectors/stack.rs | 18 ++++---- crates/forge/tests/cli/ext_integration.rs | 16 ++++--- 5 files changed, 49 insertions(+), 81 deletions(-) diff --git a/crates/config/README.md b/crates/config/README.md index b490daceafeed..fae78bfab46c3 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -124,9 +124,10 @@ initial_balance = '0xffffffffffffffffffffffff' block_number = 0 fork_block_number = 0 chain_id = 1 -# NOTE due to a toml-rs limitation, this value needs to be a string if the desired gas limit exceeds `i64::MAX` (9223372036854775807) -# `gas_limit = "Max"` is equivalent to `gas_limit = "18446744073709551615"` -gas_limit = 9223372036854775807 +# NOTE due to a toml-rs limitation, this value needs to be a string if the desired gas limit exceeds 2**63-1 (9223372036854775807). +# `gas_limit = "max"` is equivalent to `gas_limit = "18446744073709551615"`. This is not recommended +# as it will make infinite loops effectively hang during execution. +gas_limit = 1073741824 gas_price = 0 block_base_fee_per_gas = 0 block_coinbase = '0x0000000000000000000000000000000000000000' diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 5a55f1da8e03a..b30a3a2394024 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -38,7 +38,7 @@ use inflector::Inflector; use regex::Regex; use revm_primitives::{FixedBytes, SpecId}; use semver::Version; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Serialize, Serializer}; use std::{ borrow::Cow, collections::HashMap, @@ -2075,11 +2075,11 @@ impl Default for Config { prompt_timeout: 120, sender: Self::DEFAULT_SENDER, tx_origin: Self::DEFAULT_SENDER, - initial_balance: U256::from(0xffffffffffffffffffffffffu128), + initial_balance: U256::from((1u128 << 96) - 1), block_number: 1, fork_block_number: None, chain: None, - gas_limit: i64::MAX.into(), + gas_limit: (1u64 << 30).into(), // ~1B code_size_limit: None, gas_price: None, block_base_fee_per_gas: 0, @@ -2138,29 +2138,14 @@ impl Default for Config { /// /// Due to this limitation this type will be serialized/deserialized as String if it's larger than /// `i64` -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct GasLimit(pub u64); +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)] +pub struct GasLimit(#[serde(deserialize_with = "crate::deserialize_u64_or_max")] pub u64); impl From for GasLimit { fn from(gas: u64) -> Self { Self(gas) } } -impl From for GasLimit { - fn from(gas: i64) -> Self { - Self(gas as u64) - } -} -impl From for GasLimit { - fn from(gas: i32) -> Self { - Self(gas as u64) - } -} -impl From for GasLimit { - fn from(gas: u32) -> Self { - Self(gas as u64) - } -} impl From for u64 { fn from(gas: GasLimit) -> Self { @@ -2173,7 +2158,9 @@ impl Serialize for GasLimit { where S: Serializer, { - if self.0 > i64::MAX as u64 { + if self.0 == u64::MAX { + serializer.serialize_str("max") + } else if self.0 > i64::MAX as u64 { serializer.serialize_str(&self.0.to_string()) } else { serializer.serialize_u64(self.0) @@ -2181,32 +2168,6 @@ impl Serialize for GasLimit { } } -impl<'de> Deserialize<'de> for GasLimit { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - use serde::de::Error; - - #[derive(Deserialize)] - #[serde(untagged)] - enum Gas { - Number(u64), - Text(String), - } - - let gas = match Gas::deserialize(deserializer)? { - Gas::Number(num) => Self(num), - Gas::Text(s) => match s.as_str() { - "max" | "MAX" | "Max" | "u64::MAX" | "u64::Max" => Self(u64::MAX), - s => Self(s.parse().map_err(D::Error::custom)?), - }, - }; - - Ok(gas) - } -} - /// Variants for selecting the [`Solc`] instance #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged)] diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index af50a7bc1f7ed..b58565c4cecb7 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -236,31 +236,31 @@ where } } -/// Deserialize an usize or -pub(crate) fn deserialize_usize_or_max<'de, D>(deserializer: D) -> Result +/// Deserialize a `u64` or "max" for `u64::MAX`. +pub(crate) fn deserialize_u64_or_max<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, { #[derive(Deserialize)] #[serde(untagged)] enum Val { - Number(usize), - Text(String), + Number(u64), + String(String), } - let num = match Val::deserialize(deserializer)? { - Val::Number(num) => num, - Val::Text(s) => { - match s.as_str() { - "max" | "MAX" | "Max" => { - // toml limitation - i64::MAX as usize - } - s => s.parse::().map_err(D::Error::custom).unwrap(), - } - } - }; - Ok(num) + match Val::deserialize(deserializer)? { + Val::Number(num) => Ok(num), + Val::String(s) if s.eq_ignore_ascii_case("max") => Ok(u64::MAX), + Val::String(s) => s.parse::().map_err(D::Error::custom), + } +} + +/// Deserialize a `usize` or "max" for `usize::MAX`. +pub(crate) fn deserialize_usize_or_max<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + deserialize_u64_or_max(deserializer)?.try_into().map_err(D::Error::custom) } /// Helper type to parse both `u64` and `U256` diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index cd394cfb86785..1d1e8f21ca970 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -926,6 +926,16 @@ impl<'a, DB: DatabaseExt> InspectorExt for InspectorStackRefMut<'a> { } impl Inspector for InspectorStack { + #[inline] + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + self.as_mut().step(interpreter, ecx) + } + + #[inline] + fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + self.as_mut().step_end(interpreter, ecx) + } + fn call( &mut self, context: &mut EvmContext, @@ -971,14 +981,6 @@ impl Inspector for InspectorStack { fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { Inspector::::selfdestruct(&mut self.as_mut(), contract, target, value) } - - fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { - self.as_mut().step(interpreter, ecx) - } - - fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { - self.as_mut().step_end(interpreter, ecx) - } } impl InspectorExt for InspectorStack { diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index c693f47301082..8aadad62f140c 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -10,11 +10,12 @@ fn forge_std() { #[test] fn solmate() { - let tester = + let mut tester = ExtTester::new("transmissions11", "solmate", "c892309933b25c03d32b1b0d674df7ae292ba925"); - #[cfg(feature = "isolate-by-default")] - let tester = tester.args(["--nmc", "ReentrancyGuardTest"]); + if cfg!(feature = "isolate-by-default") { + tester = tester.args(["--nmc", "ReentrancyGuardTest"]); + } tester.run(); } @@ -42,10 +43,12 @@ fn prb_proxy() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn sablier_v2() { - let tester = + let mut tester = ExtTester::new("sablier-labs", "v2-core", "84758a40077bf3ccb1c8f7bb8d00278e672fbfef") // Skip fork tests. .args(["--nmc", "Fork"]) + // Increase the gas limit: https://github.com/sablier-labs/v2-core/issues/956 + .args(["--gas-limit", u64::MAX.to_string().as_str()]) // Run tests without optimizations. .env("FOUNDRY_PROFILE", "lite") .install_command(&["bun", "install", "--prefer-offline"]) @@ -54,8 +57,9 @@ fn sablier_v2() { // This test reverts due to memory limit without isolation. This revert is not reached with // isolation because memory is divided between separate EVMs created by inner calls. - #[cfg(feature = "isolate-by-default")] - let tester = tester.args(["--nmt", "test_RevertWhen_LoopCalculationOverflowsBlockGasLimit"]); + if cfg!(feature = "isolate-by-default") { + tester = tester.args(["--nmt", "test_RevertWhen_LoopCalculationOverflowsBlockGasLimit"]); + } tester.run(); } From e3021017b643e43e42a4c420b636a2ae947bf89f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 29 Jun 2024 03:25:12 +0200 Subject: [PATCH 1174/1963] chore(cast): improve vanity help (#8296) --- crates/cast/bin/cmd/wallet/vanity.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 692f54a857050..714eaa908506b 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -18,7 +18,7 @@ pub type GeneratedWallet = (SigningKey, Address); /// CLI arguments for `cast wallet vanity`. #[derive(Clone, Debug, Parser)] pub struct VanityArgs { - /// Prefix for the vanity address. + /// Prefix regex pattern or hex string. #[arg( long, required_unless_present = "ends_with", @@ -27,7 +27,7 @@ pub struct VanityArgs { )] pub starts_with: Option, - /// Suffix for the vanity address. + /// Suffix regex pattern or hex string. #[arg(long, value_parser = HexAddressValidator, value_name = "HEX")] pub ends_with: Option, @@ -151,8 +151,8 @@ impl VanityArgs { } println!( - "Successfully found vanity address in {} seconds.{}{}\nAddress: {}\nPrivate Key: 0x{}", - timer.elapsed().as_secs(), + "Successfully found vanity address in {:.3} seconds.{}{}\nAddress: {}\nPrivate Key: 0x{}", + timer.elapsed().as_secs_f64(), if nonce.is_some() { "\nContract address: " } else { "" }, if nonce.is_some() { wallet.address().create(nonce.unwrap()).to_checksum(None) From e74bf0e144e19bb863f46723eb4f70cf7aaae7d3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 29 Jun 2024 07:35:35 +0200 Subject: [PATCH 1175/1963] chore: use is_zero directly (#8297) --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/eth/otterscan/types.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 3b2592518db50..5db5c879c21d5 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1171,7 +1171,7 @@ impl Backend { optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, }; - if env.block.basefee == revm::primitives::U256::ZERO { + if env.block.basefee.is_zero() { // this is an edge case because the evm fails if `tx.effective_gas_price < base_fee` // 0 is only possible if it's manually set env.cfg.disable_base_fee = true; diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 2c2a0ad7ebc36..2c3f19a9ee981 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -297,7 +297,7 @@ impl OtsInternalOperation { .filter_map(|node| { let r#type = match node.trace.kind { _ if node.is_selfdestruct() => OtsInternalOperationType::SelfDestruct, - CallKind::Call if node.trace.value != U256::ZERO => { + CallKind::Call if !node.trace.value.is_zero() => { OtsInternalOperationType::Transfer } CallKind::Create => OtsInternalOperationType::Create, From ed79650445b500b4dd81c6efce5e2286073da9a0 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 29 Jun 2024 07:51:13 +0200 Subject: [PATCH 1176/1963] fix: forkchoice match checks (#8299) --- crates/anvil/src/cmd.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 892d714626cbe..a8417d3332da4 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -208,9 +208,9 @@ impl NodeArgs { match (self.evm_opts.fork_block_number, self.evm_opts.fork_transaction_hash) { (Some(block), None) => Some(ForkChoice::Block(block)), (None, Some(hash)) => Some(ForkChoice::Transaction(hash)), - _ => Some(ForkChoice::Block( - self.evm_opts.fork_url.as_ref().and_then(|f| f.block).unwrap(), - )), + _ => { + self.evm_opts.fork_url.as_ref().and_then(|f| f.block).map(ForkChoice::Block) + } }, ) .with_fork_headers(self.evm_opts.fork_headers) From 844f3f585fe1026a0597856c0db2082d74bfd6ea Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 29 Jun 2024 19:20:57 +0200 Subject: [PATCH 1177/1963] perf: borrow output when building test runner (#8294) * chore: borrow output when building test runner * chore: strip always * chore: lenient stripping * fix * fix: don't actually strip always --- crates/common/src/compile.rs | 2 -- crates/forge/bin/cmd/clone.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 4 ++-- crates/forge/bin/cmd/test/mod.rs | 14 +++----------- crates/forge/src/multi_runner.rs | 15 ++++++++++++--- crates/forge/tests/it/test_helpers.rs | 25 ++++++++++++++----------- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 1b93eb4789fae..72b94fcd706e6 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -292,9 +292,7 @@ impl ContractSources { libraries: Option<&Libraries>, ) -> Result { let mut sources = Self::default(); - sources.insert(output, root, libraries)?; - Ok(sources) } diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 2a5f0b83e92a9..66a2d3a73086a 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -571,7 +571,7 @@ pub fn find_main_contract<'a>( rv = Some((PathBuf::from(f), a)); } } - rv.ok_or(eyre::eyre!("contract not found")) + rv.ok_or_else(|| eyre::eyre!("contract not found")) } #[cfg(test)] diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index b00fa100c99a7..b6086b9739f76 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -90,7 +90,7 @@ impl CoverageArgs { let report = self.prepare(&project, &output)?; p_println!(!self.test.build_args().silent => "Running tests..."); - self.collect(project, output, report, Arc::new(config), evm_opts).await + self.collect(project, &output, report, Arc::new(config), evm_opts).await } /// Builds the project. @@ -222,7 +222,7 @@ impl CoverageArgs { async fn collect( self, project: Project, - output: ProjectCompileOutput, + output: &ProjectCompileOutput, mut report: CoverageReport, config: Arc, evm_opts: EvmOpts, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 6b2931de34817..1ac0c1c1f8d51 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -294,12 +294,7 @@ impl TestArgs { // Prepare the test builder let should_debug = self.debug.is_some(); - - // Clone the output only if we actually need it later for the debugger. - let output_clone = should_debug.then(|| output.clone()); - let config = Arc::new(config); - let runner = MultiContractRunnerBuilder::new(config.clone()) .set_debug(should_debug) .initial_balance(evm_opts.initial_balance) @@ -308,7 +303,7 @@ impl TestArgs { .with_fork(evm_opts.get_fork(&config, env.clone())) .with_test_options(test_options) .enable_isolation(evm_opts.isolate) - .build(project_root, output, env, evm_opts)?; + .build(project_root, &output, env, evm_opts)?; if let Some(debug_test_pattern) = &self.debug { let test_pattern = &mut filter.args_mut().test_pattern; @@ -335,11 +330,8 @@ impl TestArgs { return Err(eyre::eyre!("no tests were executed")); }; - let sources = ContractSources::from_project_output( - output_clone.as_ref().unwrap(), - project.root(), - Some(&libraries), - )?; + let sources = + ContractSources::from_project_output(&output, project.root(), Some(&libraries))?; // Run the debugger. let mut builder = Debugger::builder() diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index d0b8fd41a00fa..8d09c74613ee5 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -365,12 +365,21 @@ impl MultiContractRunnerBuilder { pub fn build( self, root: &Path, - output: ProjectCompileOutput, + output: &ProjectCompileOutput, env: revm::primitives::Env, evm_opts: EvmOpts, ) -> Result { - let output = output.with_stripped_file_prefixes(root); - let linker = Linker::new(root, output.artifact_ids().collect()); + let contracts = output + .artifact_ids() + .map(|(mut id, v)| { + // TODO: Use ArtifactId::with_stripped_file_prefixes + if let Ok(stripped) = id.source.strip_prefix(root) { + id.source = stripped.to_path_buf(); + } + (id, v) + }) + .collect(); + let linker = Linker::new(root, contracts); // Build revert decoder from ABIs of all artifacts. let abis = linker diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 27143e90ca61a..2507f9145ffd4 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -175,6 +175,8 @@ impl ForgeTestData { /// /// Uses [get_compiled] to lazily compile the project. pub fn new(profile: ForgeTestProfile) -> Self { + init_tracing(); + let mut project = profile.project(); let output = get_compiled(&mut project); let test_opts = profile.test_opts(&output); @@ -220,9 +222,6 @@ impl ForgeTestData { opts.isolate = true; } - let env = opts.local_evm_env(); - let output = self.output.clone(); - let sender = config.sender; let mut builder = self.base_runner(); @@ -231,7 +230,7 @@ impl ForgeTestData { .enable_isolation(opts.isolate) .sender(sender) .with_test_options(self.test_opts.clone()) - .build(root, output, env, opts) + .build(root, &self.output, opts.local_evm_env(), opts) .unwrap() } @@ -240,7 +239,7 @@ impl ForgeTestData { let mut opts = self.evm_opts.clone(); opts.verbosity = 5; self.base_runner() - .build(self.project.root(), self.output.clone(), opts.local_evm_env(), opts) + .build(self.project.root(), &self.output, opts.local_evm_env(), opts) .unwrap() } @@ -256,7 +255,7 @@ impl ForgeTestData { self.base_runner() .with_fork(fork) - .build(self.project.root(), self.output.clone(), env, opts) + .build(self.project.root(), &self.output, env, opts) .unwrap() } } @@ -273,12 +272,16 @@ pub fn get_vyper() -> Vyper { #[cfg(target_family = "unix")] use std::{fs::Permissions, os::unix::fs::PermissionsExt}; - let url = match svm::platform() { - svm::Platform::MacOsAarch64 => "https://github.com/vyperlang/vyper/releases/download/v0.4.0rc6/vyper.0.4.0rc6+commit.33719560.darwin", - svm::Platform::LinuxAmd64 => "https://github.com/vyperlang/vyper/releases/download/v0.4.0rc6/vyper.0.4.0rc6+commit.33719560.linux", - svm::Platform::WindowsAmd64 => "https://github.com/vyperlang/vyper/releases/download/v0.4.0rc6/vyper.0.4.0rc6+commit.33719560.windows.exe", - _ => panic!("unsupported") + let suffix = match svm::platform() { + svm::Platform::MacOsAarch64 => "darwin", + svm::Platform::LinuxAmd64 => "linux", + svm::Platform::WindowsAmd64 => "windows.exe", + platform => panic!( + "unsupported platform {platform:?} for installing vyper, \ + install it manually and add it to $PATH" + ), }; + let url = format!("https://github.com/vyperlang/vyper/releases/download/v0.4.0/vyper.0.4.0+commit.e9db8d9f.{suffix}"); let res = reqwest::Client::builder().build().unwrap().get(url).send().await.unwrap(); From 07b0ec31ab37203b6fe8a9ece64d8d1ef359b171 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 29 Jun 2024 20:01:25 +0200 Subject: [PATCH 1178/1963] chore(deps): bump foundry-compilers (#8291) * chore(deps): bump foundry-compilers * bumpies --- Cargo.lock | 25 ++++++++++++----------- Cargo.toml | 4 ++-- crates/cli/src/utils/cmd.rs | 2 +- crates/config/src/lib.rs | 1 + crates/config/src/providers/remappings.rs | 6 ++---- crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/multi_runner.rs | 8 +------- crates/forge/tests/cli/cmd.rs | 8 ++++---- crates/linking/src/lib.rs | 6 +++--- crates/verify/src/etherscan/flatten.rs | 6 +++--- crates/verify/src/etherscan/mod.rs | 2 +- crates/verify/src/provider.rs | 4 ++-- 14 files changed, 36 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b79dd3c084c2..24150d6bd78b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3520,9 +3520,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328cd3498bd9a7615d3a2f2e0e94a5d2ffc1db54cb6b4e933d01f77272ff43e5" +checksum = "6ecb3c05dbf9454cf58c6c440f84c5d2c8f4e94edb4b16f87cfad9e4d818065a" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3688,9 +3688,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2ea36984de5126fe2b05efb22d04148c39f244de1cc285493e3c2a4cfcc843a" +checksum = "7f506a672502997fbc778f1d30eb4a06a58654049ccc6cd0bdb93a785175f682" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3726,9 +3726,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5795278ec3d726eb4ec932ea452a05c880780fbb677aef06f5eeab3d0e2ae075" +checksum = "2c352516419487416dde3250dbb56b576e0605429eb7b7b16f26849d924ee519" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3736,9 +3736,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f19355ab89cd2b782c6d791d7cb16b7733074a7945443668183e7c258d007a" +checksum = "49104d442d6f0266c07edbdd23baa9a1db0f01d04bfdc69b6ac060a57e6f3e27" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3759,22 +3759,23 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05564ba0e04eb361e264e68d5e7d5b69e272d7d378f22c5c6a2edbe6d1cc3b58" +checksum = "7f012d22d0690ad6b6bbcc8d70467325212ddea3457e8efda6affe17fb5ae938" dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers-artifacts-solc", + "foundry-compilers-core", "path-slash", "serde", ] [[package]] name = "foundry-compilers-core" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "208e1a34268fbfccea0a8d4c974db01bfa44dac370724907ad404ccb79455b64" +checksum = "23760fd6df67a9878ed0fe91e024bf1ff3b7358369cf54129539a8493177c6e7" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index fa1f011480575..d1c125ef1ea99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -147,8 +147,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.4.1", default-features = false } -foundry-compilers = { version = "0.8.0", default-features = false } +foundry-block-explorers = { version = "0.5.0", default-features = false } +foundry-compilers = { version = "0.9.0", default-features = false } solang-parser = "=0.3.3" ## revm diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 8c9c124f6173c..48847f84d20a1 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -33,7 +33,7 @@ pub fn remove_contract( path: &Path, name: &str, ) -> Result<(JsonAbi, CompactBytecode, CompactDeployedBytecode)> { - let contract = if let Some(contract) = output.remove(path.to_string_lossy(), name) { + let contract = if let Some(contract) = output.remove(path, name) { contract } else { let mut err = format!("could not find artifact: `{name}`"); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index b30a3a2394024..481edfaaaaaf4 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1313,6 +1313,7 @@ impl Config { "evm.bytecode".to_string(), "evm.deployedBytecode".to_string(), ]), + search_paths: None, }) } diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 5b979d6611c97..171967934f44a 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -164,10 +164,8 @@ impl<'a> RemappingsProvider<'a> { .lib_paths .iter() .map(|lib| self.root.join(lib)) - .inspect(|lib| { - trace!("find all remappings in lib path: {:?}", lib); - }) - .flat_map(Remapping::find_many) + .inspect(|lib| trace!(?lib, "find all remappings")) + .flat_map(|lib| Remapping::find_many(&lib)) { // this is an additional safety check for weird auto-detected remappings if ["lib/", "src/", "contracts/"].contains(&r.name.as_str()) { diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index dcaa6e52f24a4..e17a2cfaaba03 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -91,7 +91,7 @@ impl BuildArgs { // Collect sources to compile if build subdirectories specified. let mut files = vec![]; - if let Some(paths) = self.paths { + if let Some(paths) = &self.paths { for path in paths { files.extend(source_files_iter(path, MultiCompilerLanguage::FILE_EXTENSIONS)); } diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index f19bc1de2f2bf..1882eca60c64a 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -201,7 +201,7 @@ fn init_git_repo(git: Git<'_>, no_commit: bool) -> Result<()> { fn init_vscode(root: &Path) -> Result<()> { let remappings_file = root.join("remappings.txt"); if !remappings_file.exists() { - let mut remappings = Remapping::find_many(root.join("lib")) + let mut remappings = Remapping::find_many(&root.join("lib")) .into_iter() .map(|r| r.into_relative(root).to_relative_remapping().to_string()) .collect::>(); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1ac0c1c1f8d51..4fd667e27836e 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -217,7 +217,7 @@ impl TestArgs { // Always recompile all sources to ensure that `getCode` cheatcode can use any artifact. test_sources.extend(source_files_iter( - project.paths.sources, + &project.paths.sources, MultiCompilerLanguage::FILE_EXTENSIONS, )); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 8d09c74613ee5..405024277c50b 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -371,13 +371,7 @@ impl MultiContractRunnerBuilder { ) -> Result { let contracts = output .artifact_ids() - .map(|(mut id, v)| { - // TODO: Use ArtifactId::with_stripped_file_prefixes - if let Ok(stripped) = id.source.strip_prefix(root) { - id.source = stripped.to_path_buf(); - } - (id, v) - }) + .map(|(id, v)| (id.with_stripped_file_prefixes(root), v)) .collect(); let linker = Linker::new(root, contracts); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index b13f74799344b..f136fb95a6c08 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -577,7 +577,7 @@ forgetest_init!(can_emit_extra_output, |prj, cmd| { let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON); let artifact: ConfigurableContractArtifact = - foundry_compilers::utils::read_json_file(artifact_path).unwrap(); + foundry_compilers::utils::read_json_file(&artifact_path).unwrap(); assert!(artifact.metadata.is_some()); cmd.forge_fuse().args(["build", "--extra-output-files", "metadata", "--force"]).root_arg(); @@ -585,7 +585,7 @@ forgetest_init!(can_emit_extra_output, |prj, cmd| { let metadata_path = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json")); - let _artifact: Metadata = foundry_compilers::utils::read_json_file(metadata_path).unwrap(); + let _artifact: Metadata = foundry_compilers::utils::read_json_file(&metadata_path).unwrap(); }); // checks that extra output works @@ -595,7 +595,7 @@ forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| { let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON); let artifact: ConfigurableContractArtifact = - foundry_compilers::utils::read_json_file(artifact_path).unwrap(); + foundry_compilers::utils::read_json_file(&artifact_path).unwrap(); assert!(artifact.metadata.is_some()); assert!(artifact.ir.is_some()); assert!(artifact.ir_optimized.is_some()); @@ -614,7 +614,7 @@ forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| { let metadata_path = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json")); - let _artifact: Metadata = foundry_compilers::utils::read_json_file(metadata_path).unwrap(); + let _artifact: Metadata = foundry_compilers::utils::read_json_file(&metadata_path).unwrap(); let iropt = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.iropt")); std::fs::read_to_string(iropt).unwrap(); diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index 25ef8fe1987fa..1ef9c9add01e9 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -232,7 +232,7 @@ impl<'a> Linker<'a> { let (file, name) = self.convert_artifact_id_to_lib_path(id); for (_, bytecode) in &mut needed_libraries { - bytecode.to_mut().link(file.to_string_lossy(), name.clone(), address); + bytecode.to_mut().link(&file.to_string_lossy(), &name, address); } libraries.libs.entry(file).or_default().insert(name, address.to_checksum(None)); @@ -253,12 +253,12 @@ impl<'a> Linker<'a> { for (name, address) in libs { let address = Address::from_str(address).map_err(LinkerError::InvalidAddress)?; if let Some(bytecode) = contract.bytecode.as_mut() { - bytecode.to_mut().link(file.to_string_lossy(), name, address); + bytecode.to_mut().link(&file.to_string_lossy(), name, address); } if let Some(deployed_bytecode) = contract.deployed_bytecode.as_mut().and_then(|b| b.to_mut().bytecode.as_mut()) { - deployed_bytecode.link(file.to_string_lossy(), name, address); + deployed_bytecode.link(&file.to_string_lossy(), name, address); } } } diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index 9937e4d8ae06b..ffe1496cad5d7 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -3,7 +3,7 @@ use crate::provider::VerificationContext; use eyre::{Context, Result}; use foundry_block_explorers::verify::CodeFormat; use foundry_compilers::{ - artifacts::{BytecodeHash, Source}, + artifacts::{BytecodeHash, Source, Sources}, buildinfo::RawBuildInfo, compilers::{ solc::{SolcCompiler, SolcLanguage, SolcVersionedInput}, @@ -13,7 +13,7 @@ use foundry_compilers::{ AggregatedCompilerOutput, }; use semver::{BuildMetadata, Version}; -use std::{collections::BTreeMap, path::Path}; +use std::path::Path; #[derive(Debug)] pub struct EtherscanFlattenedSource; @@ -81,7 +81,7 @@ impl EtherscanFlattenedSource { let solc = Solc::find_or_install(&version)?; let input = SolcVersionedInput::build( - BTreeMap::from([("contract.sol".into(), Source::new(content))]), + Sources::from([("contract.sol".into(), Source::new(content))]), Default::default(), SolcLanguage::Solidity, version.clone(), diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 1ef5d4b20faf6..3c5722f428adc 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -401,7 +401,7 @@ impl EtherscanVerificationProvider { let output = context.project.compile_file(&context.target_path)?; let artifact = output - .find(context.target_path.to_string_lossy(), &context.target_name) + .find(&context.target_path, &context.target_name) .ok_or_eyre("Contract artifact wasn't found locally")?; let bytecode = artifact .get_bytecode_object() diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index 12dfb23f66a9a..46ca0b9447bff 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -55,7 +55,7 @@ impl VerificationContext { .compile(&project)?; let artifact = output - .find(self.target_path.to_string_lossy(), &self.target_name) + .find(&self.target_path, &self.target_name) .ok_or_eyre("failed to find target artifact when compiling for abi")?; artifact.abi.clone().ok_or_eyre("target artifact does not have an ABI") @@ -74,7 +74,7 @@ impl VerificationContext { .compile(&project)?; let artifact = output - .find(self.target_path.to_string_lossy(), &self.target_name) + .find(&self.target_path, &self.target_name) .ok_or_eyre("failed to find target artifact when compiling for metadata")?; artifact.metadata.clone().ok_or_eyre("target artifact does not have an ABI") From e65b5b9a5fb71ee06753e43a56c0f03c4aeb4c07 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 30 Jun 2024 03:14:14 +0300 Subject: [PATCH 1179/1963] chore: update fixtures after forge-std release (#8302) * chore: update fixtures after forge-std release * fix --- crates/forge/tests/fixtures/can_test_repeatedly.stdout | 2 +- .../fixtures/include_custom_types_in_traces.stdout | 10 +++++----- crates/forge/tests/fixtures/repro_6531.stdout | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout index 7095a50f0305c..5a29d4dd7a9e8 100644 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ b/crates/forge/tests/fixtures/can_test_repeatedly.stdout @@ -2,7 +2,7 @@ No files changed, compilation skipped Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) -[PASS] test_Increment() (gas: 31325) +[PASS] test_Increment() (gas: 31303) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms Ran 1 test suite: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout index 571cc69274595..9b289543f112e 100644 --- a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout +++ b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout @@ -3,14 +3,14 @@ Solc 0.8.23 finished in 798.51ms Compiler run successful! Ran 2 tests for test/Contract.t.sol:CustomTypesTest -[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231) +[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) Traces: - [231] CustomTypesTest::testErr() + [254] CustomTypesTest::testErr() └─ ← [Revert] PoolNotInitialized() -[PASS] testEvent() (gas: 1312) +[PASS] testEvent() (gas: 1268) Traces: - [1312] CustomTypesTest::testEvent() + [1268] CustomTypesTest::testEvent() ├─ emit MyEvent(a: 100) └─ ← [Stop] @@ -20,6 +20,6 @@ Ran 1 test suite: 1 tests passed, 1 failed, 0 skipped (2 total tests) Failing tests: Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest -[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231) +[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) Encountered a total of 1 failing tests, 1 tests succeeded diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout index 35c27c9483e17..47a6bb237b468 100644 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ b/crates/forge/tests/fixtures/repro_6531.stdout @@ -3,9 +3,9 @@ Compiling 1 files with 0.8.23 Compiler run successful! Ran 1 test for test/Contract.t.sol:USDTCallingTest -[PASS] test() (gas: 9559) +[PASS] test() (gas: 9537) Traces: - [9559] USDTCallingTest::test() + [9537] USDTCallingTest::test() ├─ [0] VM::createSelectFork("") │ └─ ← [Return] 0 ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] From 8ca3b68f315ff82208510fb9558e79fb289805d7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 30 Jun 2024 07:04:06 +0200 Subject: [PATCH 1180/1963] chore(deps): bump revm-inspectors (#8300) * chore(deps): bump revm-inspectors * fix * fix2 * inline * fix3 --- Cargo.lock | 4 +-- Cargo.toml | 2 +- crates/anvil/src/eth/otterscan/types.rs | 4 ++- crates/debugger/src/tui/context.rs | 2 +- crates/debugger/src/tui/draw.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 37 +++++++++++++------------ crates/evm/traces/src/decoder/mod.rs | 2 +- crates/evm/traces/src/lib.rs | 2 +- crates/forge/src/runner.rs | 14 ++++------ 9 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 24150d6bd78b2..451f610928f61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6992,9 +6992,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e260c899e462b4e189a3bfcf5a947bc3506f8bd89183859604bca009b57530" +checksum = "4d2f41673ae4d4f2d0624c99844f096f82d39b93134ac8d4bbe9683c87459eeb" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index d1c125ef1ea99..3437fd18df9c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,7 +155,7 @@ solang-parser = "=0.3.3" # no default features to avoid c-kzg revm = { version = "10.0.0", default-features = false } revm-primitives = { version = "5.0.0", default-features = false } -revm-inspectors = { version = "0.2", features = ["serde"] } +revm-inspectors = { version = "0.3", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs index 2c3f19a9ee981..8aeccf8c75306 100644 --- a/crates/anvil/src/eth/otterscan/types.rs +++ b/crates/anvil/src/eth/otterscan/types.rs @@ -306,11 +306,13 @@ impl OtsInternalOperation { }; let mut from = node.trace.caller; let mut to = node.trace.address; + let mut value = node.trace.value; if node.is_selfdestruct() { from = node.trace.address; to = node.trace.selfdestruct_refund_target.unwrap_or_default(); + value = node.trace.selfdestruct_transferred_value.unwrap_or_default(); } - Some(Self { r#type, from, to, value: node.trace.value }) + Some(Self { r#type, from, to, value }) }) .collect() } diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index f4696c46e6973..a6bcfbb929365 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -129,7 +129,7 @@ impl<'a> DebuggerContext<'a> { fn active_buffer(&self) -> &[u8] { match self.active_buffer { - BufferKind::Memory => self.current_step().memory.as_bytes(), + BufferKind::Memory => self.current_step().memory.as_ref().unwrap().as_bytes(), BufferKind::Calldata => &self.debug_call().calldata, BufferKind::Returndata => &self.current_step().returndata, } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index e53910626835a..956e4fdd4ebb9 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -502,7 +502,7 @@ impl DebuggerContext<'_> { let call = self.debug_call(); let step = self.current_step(); let buf = match self.active_buffer { - BufferKind::Memory => step.memory.as_ref(), + BufferKind::Memory => step.memory.as_ref().unwrap().as_ref(), BufferKind::Calldata => call.calldata.as_ref(), BufferKind::Returndata => step.returndata.as_ref(), }; diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 1d1e8f21ca970..aba7ef4f9e563 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -415,22 +415,24 @@ impl InspectorStack { /// Set whether to enable the tracer. #[inline] pub fn tracing(&mut self, yes: bool, debug: bool) { - self.tracer = yes.then(|| { - TracingInspector::new(TracingInspectorConfig { - record_steps: debug, - record_memory_snapshots: debug, - record_stack_snapshots: if debug { - StackSnapshotType::Full - } else { - StackSnapshotType::None - }, - record_state_diff: false, - exclude_precompile_calls: false, - record_logs: true, - record_opcodes_filter: None, - record_returndata_snapshots: debug, - }) - }); + if !yes { + self.tracer = None; + return; + } + *self.tracer.get_or_insert_with(Default::default).config_mut() = TracingInspectorConfig { + record_steps: debug, + record_memory_snapshots: debug, + record_stack_snapshots: if debug { + StackSnapshotType::Full + } else { + StackSnapshotType::None + }, + record_state_diff: false, + exclude_precompile_calls: false, + record_logs: true, + record_opcodes_filter: None, + record_returndata_snapshots: debug, + }; } /// Collects all the data gathered during inspection into a single struct. @@ -447,13 +449,14 @@ impl InspectorStack { .as_ref() .map(|cheatcodes| cheatcodes.labels.clone()) .unwrap_or_default(), - traces: tracer.map(|tracer| tracer.get_traces().clone()), + traces: tracer.map(|tracer| tracer.into_traces()), coverage: coverage.map(|coverage| coverage.maps), cheatcodes, chisel_state: chisel_state.and_then(|state| state.state), } } + #[inline(always)] fn as_mut(&mut self) -> InspectorStackRefMut<'_> { InspectorStackRefMut { cheatcodes: self.cheatcodes.as_mut(), inner: &mut self.inner } } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index ec1ea199ffdd9..0b452f0834089 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -575,7 +575,7 @@ impl CallTraceDecoder { let events_it = nodes .iter() - .flat_map(|node| node.logs.iter().filter_map(|log| log.topics().first())) + .flat_map(|node| node.logs.iter().filter_map(|log| log.raw_log.topics().first())) .unique(); identifier.write().await.identify_events(events_it).await; diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index b3ce89578c7ca..35106b61ba90e 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -95,7 +95,7 @@ pub async fn render_trace_arena( for child in &node.ordering { match child { TraceMemberOrder::Log(index) => { - let log = render_trace_log(&node.logs[*index], decoder).await?; + let log = render_trace_log(&node.logs[*index].raw_log, decoder).await?; // Prepend our tree structure symbols to each line of the displayed log log.lines().enumerate().try_for_each(|(i, line)| { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index f19f2d43c2229..501ae62662acf 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -307,18 +307,16 @@ impl<'a> ContractRunner<'a> { }); // Invariant testing requires tracing to figure out what contracts were created. + // We also want to disable `debug` for setup since we won't be using those traces. let has_invariants = self.contract.abi.functions().any(|func| func.is_invariant_test()); - let tmp_tracing = - self.executor.inspector().tracer.is_none() && has_invariants && call_setup; - if tmp_tracing { - self.executor.set_tracing(true, false); - } + let prev_tracer = self.executor.inspector_mut().tracer.take(); + self.executor.set_tracing(prev_tracer.is_some() || has_invariants, false); + let setup_time = Instant::now(); let setup = self.setup(call_setup); debug!("finished setting up in {:?}", setup_time.elapsed()); - if tmp_tracing { - self.executor.set_tracing(false, false); - } + + self.executor.inspector_mut().tracer = prev_tracer; if setup.reason.is_some() { // The setup failed, so we return a single test result for `setUp` From c2fb7bdf26cd985dd18feb8936dabeafc82d8347 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 30 Jun 2024 07:26:44 +0200 Subject: [PATCH 1181/1963] docs(cast): improve vanity help naming (#8306) --- crates/cast/bin/cmd/wallet/vanity.rs | 62 ++++++++++------------------ 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 714eaa908506b..5b597b3f0f52d 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -1,8 +1,9 @@ use alloy_primitives::{hex, Address}; use alloy_signer::{k256::ecdsa::SigningKey, utils::secret_key_to_address}; use alloy_signer_local::PrivateKeySigner; -use clap::{builder::TypedValueParser, Parser}; +use clap::Parser; use eyre::Result; +use itertools::Either; use rayon::iter::{self, ParallelIterator}; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -19,16 +20,11 @@ pub type GeneratedWallet = (SigningKey, Address); #[derive(Clone, Debug, Parser)] pub struct VanityArgs { /// Prefix regex pattern or hex string. - #[arg( - long, - required_unless_present = "ends_with", - value_parser = HexAddressValidator, - value_name = "HEX" - )] + #[arg(long, value_name = "PATTERN", required_unless_present = "ends_with")] pub starts_with: Option, /// Suffix regex pattern or hex string. - #[arg(long, value_parser = HexAddressValidator, value_name = "HEX")] + #[arg(long, value_name = "PATTERN")] pub ends_with: Option, // 2^64-1 is max possible nonce per [eip-2681](https://eips.ethereum.org/EIPS/eip-2681). @@ -74,24 +70,22 @@ impl WalletData { impl VanityArgs { pub fn run(self) -> Result { let Self { starts_with, ends_with, nonce, save_path } = self; + let mut left_exact_hex = None; let mut left_regex = None; - let mut right_exact_hex = None; - let mut right_regex = None; - if let Some(prefix) = starts_with { - if let Ok(decoded) = hex::decode(&prefix) { - left_exact_hex = Some(decoded) - } else { - left_regex = Some(Regex::new(&format!(r"^{prefix}"))?); + match parse_pattern(&prefix, true)? { + Either::Left(left) => left_exact_hex = Some(left), + Either::Right(re) => left_regex = Some(re), } } + let mut right_exact_hex = None; + let mut right_regex = None; if let Some(suffix) = ends_with { - if let Ok(decoded) = hex::decode(&suffix) { - right_exact_hex = Some(decoded) - } else { - right_regex = Some(Regex::new(&format!(r"{suffix}$"))?); + match parse_pattern(&suffix, false)? { + Either::Left(right) => right_exact_hex = Some(right), + Either::Right(re) => right_regex = Some(re), } } @@ -331,29 +325,15 @@ impl VanityMatcher for RegexMatcher { } } -/// Parse 40 byte addresses -#[derive(Clone, Copy, Debug, Default)] -pub struct HexAddressValidator; - -impl TypedValueParser for HexAddressValidator { - type Value = String; - - fn parse_ref( - &self, - _cmd: &clap::Command, - _arg: Option<&clap::Arg>, - value: &std::ffi::OsStr, - ) -> Result { - if value.len() > 40 { - return Err(clap::Error::raw( - clap::error::ErrorKind::InvalidValue, - "vanity patterns length exceeded. cannot be more than 40 characters", - )) +fn parse_pattern(pattern: &str, is_start: bool) -> Result, Regex>> { + if let Ok(decoded) = hex::decode(pattern) { + if decoded.len() > 20 { + return Err(eyre::eyre!("Hex pattern must be less than 20 bytes")); } - let value = value.to_str().ok_or_else(|| { - clap::Error::raw(clap::error::ErrorKind::InvalidUtf8, "address must be valid utf8") - })?; - Ok(value.to_string()) + Ok(Either::Left(decoded)) + } else { + let (prefix, suffix) = if is_start { ("^", "") } else { ("", "$") }; + Ok(Either::Right(Regex::new(&format!("{prefix}{pattern}{suffix}"))?)) } } From 539742eb11c73bf8197579a23419f058ce72e1b1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 30 Jun 2024 07:30:13 +0200 Subject: [PATCH 1182/1963] chore(deps): weekly `cargo update` (#8303) Locking 44 packages to latest compatible versions Updating alloy-chains v0.1.22 -> v0.1.23 Updating alloy-consensus v0.1.2 -> v0.1.3 Updating alloy-contract v0.1.2 -> v0.1.3 Updating alloy-eips v0.1.2 -> v0.1.3 Updating alloy-genesis v0.1.2 -> v0.1.3 Updating alloy-json-rpc v0.1.2 -> v0.1.3 Updating alloy-network v0.1.2 -> v0.1.3 Updating alloy-provider v0.1.2 -> v0.1.3 Updating alloy-pubsub v0.1.2 -> v0.1.3 Updating alloy-rlp v0.3.5 -> v0.3.7 Updating alloy-rlp-derive v0.3.5 -> v0.3.7 Updating alloy-rpc-client v0.1.2 -> v0.1.3 Updating alloy-rpc-types v0.1.2 -> v0.1.3 Updating alloy-rpc-types-anvil v0.1.2 -> v0.1.3 Updating alloy-rpc-types-engine v0.1.2 -> v0.1.3 Updating alloy-rpc-types-eth v0.1.2 -> v0.1.3 Updating alloy-rpc-types-trace v0.1.2 -> v0.1.3 Updating alloy-rpc-types-txpool v0.1.2 -> v0.1.3 Updating alloy-serde v0.1.2 -> v0.1.3 Updating alloy-signer v0.1.2 -> v0.1.3 Updating alloy-signer-aws v0.1.2 -> v0.1.3 Updating alloy-signer-gcp v0.1.2 -> v0.1.3 Updating alloy-signer-ledger v0.1.2 -> v0.1.3 Updating alloy-signer-local v0.1.2 -> v0.1.3 Updating alloy-signer-trezor v0.1.2 -> v0.1.3 Updating alloy-transport v0.1.2 -> v0.1.3 Updating alloy-transport-http v0.1.2 -> v0.1.3 Updating alloy-transport-ipc v0.1.2 -> v0.1.3 Updating alloy-transport-ws v0.1.2 -> v0.1.3 Updating bitflags v2.5.0 -> v2.6.0 Updating cc v1.0.100 -> v1.0.102 Updating clap v4.5.7 -> v4.5.8 Updating clap_builder v4.5.7 -> v4.5.8 Updating clap_complete v4.5.6 -> v4.5.7 Updating clap_derive v4.5.5 -> v4.5.8 Updating either v1.12.0 -> v1.13.0 Updating evmole v0.3.4 -> v0.3.6 Updating log v0.4.21 -> v0.4.22 Updating mime_guess v2.0.4 -> v2.0.5 Updating num-bigint v0.4.5 -> v0.4.6 Updating serde_json v1.0.117 -> v1.0.118 Updating subtle v2.6.0 -> v2.6.1 Updating tinyvec v1.6.0 -> v1.6.1 Updating uuid v1.9.0 -> v1.9.1 note: pass `--verbose` to see 166 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 212 ++++++++++++++++++++++++++--------------------------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 451f610928f61..8342975883f6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e9a1892803b02f53e25bea3e414ddd0501f12d97456c9d5ade4edf88f9516f" +checksum = "1752d7d62e2665da650a36d84abbf239f812534475d51f072a49a533513b7cdd" dependencies = [ "num_enum", "serde", @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a016bfa21193744d4c38b3f3ab845462284d129e5e23c7cc0fafca7e92d9db37" +checksum = "3f63a6c9eb45684a5468536bc55379a2af0f45ffa5d756e4e4964532737e1836" dependencies = [ "alloy-eips", "alloy-primitives", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e47b2a620fd588d463ccf0f5931b41357664b293a8d31592768845a2a101bb9e" +checksum = "0c26b7d34cb76f826558e9409a010e25257f7bfb5aa5e3dd0042c564664ae159" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -134,9 +134,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d6d8118b83b0489cfb7e6435106948add2b35217f4a5004ef895f613f60299" +checksum = "aa4b0fc6a572ef2eebda0a31a5e393d451abda703fec917c75d9615d8c978cf2" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "894f33a7822abb018db56b10ab90398e63273ce1b5a33282afd186c132d764a6" +checksum = "48450f9c6f0821c1eee00ed912942492ed4f11dd69532825833de23ecc7a2256" dependencies = [ "alloy-primitives", "alloy-serde", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61f0ae6e93b885cc70fe8dae449e7fd629751dbee8f59767eaaa7285333c5727" +checksum = "d484c2a934d0a4d86f8ad4db8113cb1d607707a6c54f6e78f4f1b4451b47aa70" dependencies = [ "alloy-primitives", "serde", @@ -186,9 +186,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc122cbee2b8523854cc11d87bcd5773741602c553d2d2d106d82eeb9c16924a" +checksum = "7a20eba9bc551037f0626d6d29e191888638d979943fa4e842e9e6fc72bf0565" dependencies = [ "alloy-consensus", "alloy-eips", @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d5af289798fe8783acd0c5f10644d9d26f54a12bc52a083e4f3b31718e9bf92" +checksum = "ad5d89acb7339fad13bc69e7b925232f242835bfd91c82fcb9326b36481bd0f0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702f330b7da123a71465ab9d39616292f8344a2811c28f2cc8d8438a69d79e35" +checksum = "034258dfaa51c278e1f7fcc46e587d10079ec9372866fa48c5df9d908fc1f6b1" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -289,9 +289,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b155716bab55763c95ba212806cf43d05bcc70e5f35b02bad20cf5ec7fe11fed" +checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -300,9 +300,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" +checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" dependencies = [ "proc-macro2", "quote", @@ -311,9 +311,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40fcb53b2a9d0a78a4968b2eca8805a4b7011b9ee3fdfa2acaf137c5128f36b" +checksum = "479ce003e8c74bbbc7d4235131c1d6b7eaf14a533ae850295b90d240340989cb" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -336,9 +336,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f2fbe956a3e0f0975c798f488dc6be96b669544df3737e18f4a325b42f4c86" +checksum = "0dfa1dd3e0bc3a3d89744fba8d1511216e83257160da2cd028a18b7d9c026030" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -350,9 +350,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87f724e6170f558b809a520e37bdb34d99123092b78118bff31fb5b21dc2a2e" +checksum = "f67aec11f9f3bc5e96c2b7f342dba6e9541a8a48d2cfbe27b6b195136aa18eee" dependencies = [ "alloy-primitives", "alloy-serde", @@ -361,9 +361,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd473d98ec552f8229cd6d566bd2b0bbfc5bb4efcefbb5288c834aa8fd832020" +checksum = "cc40df2dda7561d1406d0bee1d19c8787483a2cf2ee8011c05909475e7bc102d" dependencies = [ "alloy-consensus", "alloy-eips", @@ -379,9 +379,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "083f443a83b9313373817236a8f4bea09cca862618e9177d822aee579640a5d6" +checksum = "13bd7aa9ff9e67f1ba7ee0dd8cebfc95831d1649b0e4eeefae940dc3681079fa" dependencies = [ "alloy-consensus", "alloy-eips", @@ -397,9 +397,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7a838f9a34aae7022c6cb53ecf21bc0a5a30c82f8d9eb0afed701ab5fd88de" +checksum = "535d26db98ac320a0d1637faf3e210328c3df3b1998abd7e72343d3857058efe" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -411,9 +411,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1572267dbc660843d87c02994029d1654c2c32867e186b266d1c03644b43af97" +checksum = "5971c92989c6a5588d3f6d1e99e5328fba6e68694efbe969d6ec96ae5b9d1037" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d94da1c0c4e27cc344b05626fe22a89dc6b8b531b9475f3b7691dbf6913e4109" +checksum = "8913f9e825068d77c516188c221c44f78fd814fce8effe550a783295a2757d19" dependencies = [ "alloy-primitives", "serde", @@ -434,9 +434,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58d876be3afd8b78979540084ff63995292a26aa527ad0d44276405780aa0ffd" +checksum = "f740e13eb4c6a0e4d0e49738f1e86f31ad2d7ef93be499539f492805000f7237" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -450,9 +450,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4d88815c5a7e666469cd8dc82b50c39e1b8f86c650e914fdc5c3bc1b2db57b6" +checksum = "3e9573e8a5339fefc515b3e336fae177e2080225a4ea49cd5ab24de4b0bdc81d" dependencies = [ "alloy-consensus", "alloy-network", @@ -468,9 +468,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51be98dc71e445331deea5a0f9ae33f83803c7dd22db4a6b18def0d23007c6e3" +checksum = "4911b3b4e104af7ed40bf51031a6f0f2400788759f6073a5d90003db6bb88fe6" dependencies = [ "alloy-consensus", "alloy-network", @@ -486,9 +486,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfcac99cf316246bf3087207fb17ec1b027c62d4a6bd28eb0c6413d66fe66e5" +checksum = "3eb31f033976724d10f90633477436f5e3757b04283c475a750a77e82422aa36" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -506,9 +506,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40a37dc216c269b8a7244047cb1c18a9c69f7a0332ab2c4c2aa4cbb1a31468b" +checksum = "87db68d926887393a1d0f9c43833b44446ea29d603291e7b20e5d115f31aa4e3" dependencies = [ "alloy-consensus", "alloy-network", @@ -526,9 +526,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad954b6a08612616dab4611078a60d7dcff372780e7240058bea2c323d282d8b" +checksum = "39c0c55911ca291f842f7d18a06a993679fe672d5d02049c665fa01aafa2b31a" dependencies = [ "alloy-consensus", "alloy-network", @@ -615,9 +615,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245af9541f0a0dbd5258669c80dfe3af118164cacec978a520041fc130550deb" +checksum = "dd9773e4ec6832346171605c776315544bd06e40f803e7b5b7824b325d5442ca" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -633,9 +633,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5619c017e1fdaa1db87f9182f4f0ed97c53d674957f4902fba655e972d359c6c" +checksum = "ff8ef947b901c0d4e97370f9fa25844cf8b63b1a58fd4011ee82342dc8a9fc6b" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -648,9 +648,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173cefa110afac7a53cf2e75519327761f2344d305eea2993f3af1b2c1fc1c44" +checksum = "bb40ee66887a66d875a5bb5e01cee4c9a467c263ef28c865cd4b0ebf15f705af" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -669,9 +669,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c0aff8af5be5e58856c5cdd1e46db2c67c7ecd3a652d9100b4822c96c899947" +checksum = "3d92049d6642a18c9849ce7659430151e7c92b51552a0cabdc038c1af4cd7308" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1249,7 +1249,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.9.0", + "uuid 1.9.1", ] [[package]] @@ -1690,9 +1690,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" dependencies = [ "arbitrary", "serde", @@ -1970,9 +1970,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.100" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" +checksum = "779e6b7d17797c0b42023d417228c02889300190e700cb074c3438d9c541d332" dependencies = [ "jobserver", "libc", @@ -2082,9 +2082,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" dependencies = [ "clap_builder", "clap_derive", @@ -2092,9 +2092,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" dependencies = [ "anstream", "anstyle", @@ -2107,9 +2107,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbca90c87c2a04da41e95d1856e8bcd22f159bdbfa147314d2ce5218057b0e58" +checksum = "1d598e88f6874d4b888ed40c71efbcbf4076f1dfbae128a08a8c9e45f710605d" dependencies = [ "clap", ] @@ -2126,9 +2126,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", "proc-macro2", @@ -2476,7 +2476,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "crossterm_winapi", "libc", "mio", @@ -2846,9 +2846,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elasticlunr-rs" @@ -3136,9 +3136,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bdec28a767d874dd74270c882fb0aa31730af9138d41810fc63b8e7e49f6ddd" +checksum = "ce047d502545e3a726948bb8a532b8ea1446238f829e01448c802b2f10edbe70" dependencies = [ "ruint", ] @@ -4334,7 +4334,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "bstr 1.9.1", "gix-path", "libc", @@ -4380,7 +4380,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "bstr 1.9.1", "gix-features", "gix-path", @@ -4465,7 +4465,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "gix-path", "libc", "windows 0.48.0", @@ -5326,7 +5326,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -5366,9 +5366,9 @@ checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "loom" @@ -5535,9 +5535,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" dependencies = [ "mime", "unicase", @@ -5648,7 +5648,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cfg-if", "cfg_aliases", "libc", @@ -5723,9 +5723,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -5931,7 +5931,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -6536,7 +6536,7 @@ checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand", @@ -6617,7 +6617,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "memchr", "pulldown-cmark-escape", "unicase", @@ -6761,7 +6761,7 @@ version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f44c9e68fd46eda15c646fbb85e1040b657a58cdc8c98db1d97a55930d991eef" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cassowary", "compact_str", "crossterm", @@ -6816,7 +6816,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -7043,7 +7043,7 @@ checksum = "902184a7a781550858d4b96707098da357429f1e4545806fd5b589f455555cf2" dependencies = [ "alloy-primitives", "auto_impl", - "bitflags 2.5.0", + "bitflags 2.6.0", "bitvec", "c-kzg", "cfg-if", @@ -7222,7 +7222,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -7364,7 +7364,7 @@ version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cfg-if", "clipboard-win", "fd-lock 3.0.13", @@ -7563,7 +7563,7 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -7646,9 +7646,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" dependencies = [ "indexmap 2.2.6", "itoa", @@ -7969,7 +7969,7 @@ dependencies = [ "tokio", "toml 0.8.14", "toml_edit 0.22.14", - "uuid 1.9.0", + "uuid 1.9.1", "walkdir", "yansi", "zip 2.1.3", @@ -8083,9 +8083,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" @@ -8369,9 +8369,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" dependencies = [ "tinyvec_macros", ] @@ -8635,7 +8635,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "bytes", "futures-util", "http 1.1.0", @@ -8991,9 +8991,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea73390fe27785838dcbf75b91b1d84799e28f1ce71e6f372a5dc2200c80de5" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "getrandom", "serde", From 7603d1916cb0762556811647dac1c93f81157a63 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 30 Jun 2024 12:47:56 +0200 Subject: [PATCH 1183/1963] fix: suppress compile reporting for forge flatten (#8313) --- crates/forge/bin/cmd/flatten.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index e3cdd0b390186..f538be5a8c8fa 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -45,9 +45,8 @@ impl FlattenArgs { let target_path = dunce::canonicalize(target_path)?; - let flattener = with_compilation_reporter(build_args.silent, || { - Flattener::new(project.clone(), &target_path) - }); + let flattener = + with_compilation_reporter(true, || Flattener::new(project.clone(), &target_path)); let flattened = match flattener { Ok(flattener) => Ok(flattener.flatten()), From d96955d4596e1c23828e30c65bd247ccc40cc0af Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 30 Jun 2024 13:48:43 +0300 Subject: [PATCH 1184/1963] perf: only instantiate Vyper when necessary (#8307) --- crates/config/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 481edfaaaaaf4..58b1090ff0373 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -32,7 +32,7 @@ use foundry_compilers::{ Compiler, }, error::SolcError, - ConfigurableArtifacts, Project, ProjectPathsConfig, + ConfigurableArtifacts, Project, ProjectPathsConfig, VyperLanguage, }; use inflector::Inflector; use regex::Regex; @@ -957,6 +957,10 @@ impl Config { /// Returns configured [Vyper] compiler. pub fn vyper_compiler(&self) -> Result, SolcError> { + // Only instantiate Vyper if there are any Vyper files in the project. + if self.project_paths::().input_files_iter().next().is_none() { + return Ok(None) + } let vyper = if let Some(path) = &self.vyper.path { Some(Vyper::new(path)?) } else { From 82c04040cbcf4fd487a86285ea684750048758c2 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 30 Jun 2024 13:52:54 +0300 Subject: [PATCH 1185/1963] chore: pin forge-std in tests + CI job to bump it (#8308) --- .github/workflows/bump-forge-std.yml | 25 +++++++++++++++++++++++++ crates/test-utils/src/util.rs | 11 +++++++++++ testdata/forge-std-rev | 1 + 3 files changed, 37 insertions(+) create mode 100644 .github/workflows/bump-forge-std.yml create mode 100644 testdata/forge-std-rev diff --git a/.github/workflows/bump-forge-std.yml b/.github/workflows/bump-forge-std.yml new file mode 100644 index 0000000000000..137e8c465e914 --- /dev/null +++ b/.github/workflows/bump-forge-std.yml @@ -0,0 +1,25 @@ +# Daily CI job to update forge-std version used for tests if new release has been published + +name: bump-forge-std + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + update-tag: + name: update forge-std tag + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Fetch and update forge-std tag + run: curl 'https://api.github.com/repos/foundry-rs/forge-std/tags' | jq '.[0].commit.sha' -jr > testdata/forge-std-rev + - name: Create pull request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: "chore: bump forge-std version used for tests" + title: "chore(tests): bump forge-std version" + body: | + New release of forge-std has been published, bump forge-std version used in tests. Likely some fixtures need to be updated. + branch: chore/bump-forge-std diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 47ab824434faa..9c857bc40789e 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -27,6 +27,9 @@ use std::{ static CURRENT_DIR_LOCK: Lazy> = Lazy::new(|| Mutex::new(())); +/// The commit of forge-std to use. +const FORGE_STD_REVISION: &str = include_str!("../../../testdata/forge-std-rev"); + /// Stores whether `stdout` is a tty / terminal. pub static IS_TTY: Lazy = Lazy::new(|| std::io::stdout().is_terminal()); @@ -250,6 +253,14 @@ pub fn initialize(target: &Path) { eprintln!("- initializing template dir in {}", prj.root().display()); cmd.args(["init", "--force"]).assert_success(); + // checkout forge-std + assert!(Command::new("git") + .current_dir(prj.root().join("lib/forge-std")) + .args(["checkout", FORGE_STD_REVISION]) + .output() + .expect("failed to checkout forge-std") + .status + .success()); cmd.forge_fuse().args(["build", "--use", SOLC_VERSION]).assert_success(); // Remove the existing template, if any. diff --git a/testdata/forge-std-rev b/testdata/forge-std-rev new file mode 100644 index 0000000000000..919eb58dc2627 --- /dev/null +++ b/testdata/forge-std-rev @@ -0,0 +1 @@ +8948d45d3d9022c508b83eb5d26fd3a7a93f2f32 \ No newline at end of file From 21c40c73d672be6f7f4b0f5bf37a404d865ac83a Mon Sep 17 00:00:00 2001 From: Valentin B <703631+beeb@users.noreply.github.com> Date: Sun, 30 Jun 2024 16:16:39 +0200 Subject: [PATCH 1186/1963] chore: update dev shell flake (#8314) Updated to latest Rust toolchain version (v1.79). The rust overlay doesn't use `flake-utils` anymore. Switched to solc 0.8.23 since that's the default for the tests. Moved around the deps to be more in line with recommendations (`buildInputs` for things that get linked and `nativeBuildInputs` for what's needed during compilation only, `packages` for things that are not needed at compile time). --- flake.lock | 36 +++++++++++++++++++++++------------- flake.nix | 16 ++++++---------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/flake.lock b/flake.lock index 9ad80af8be7a5..45ed6bb432ffb 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1711655175, - "narHash": "sha256-1xiaYhC3ul4y+i3eicYxeERk8ZkrNjLkrFSb/UW36Zw=", + "lastModified": 1719468428, + "narHash": "sha256-vN5xJAZ4UGREEglh3lfbbkIj+MPEYMuqewMn4atZFaQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "64c81edb4b97a51c5bbc54c191763ac71a6517ee", + "rev": "1e3deb3d8a86a870d925760db1a5adecc64d329d", "type": "github" }, "original": { @@ -44,19 +44,16 @@ }, "rust-overlay": { "inputs": { - "flake-utils": [ - "flake-utils" - ], "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1711678273, - "narHash": "sha256-7lIB0hMRnfzx/9oSIwTnwXmVnbvVGRoadOCW+1HI5zY=", + "lastModified": 1719714047, + "narHash": "sha256-MeNPopLLv63EZj5L43j4TZkmW4wj1ouoc/h/E20sl/U=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "42a168449605950935f15ea546f6f770e5f7f629", + "rev": "cb216719ce89a43dfb3d1b86a9575e89f4b727a4", "type": "github" }, "original": { @@ -72,14 +69,15 @@ ], "nixpkgs": [ "nixpkgs" - ] + ], + "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" }, "locked": { - "lastModified": 1711538161, - "narHash": "sha256-rETVdEIQ2PyEcNgzXXFSiYAYl0koCeGDIWp9XYBTxoQ=", + "lastModified": 1717442267, + "narHash": "sha256-6TnQvA6Q/xC3r1M+wGC5gnDc/5XfOPjC8X6LlGDWDNc=", "owner": "hellwolf", "repo": "solc.nix", - "rev": "a995838545a7383a0b37776e969743b1346d5479", + "rev": "2ac2862f224aa0d67cbc6b3246392489f8a50596", "type": "github" }, "original": { @@ -88,6 +86,18 @@ "type": "github" } }, + "solc-macos-amd64-list-json": { + "flake": false, + "locked": { + "narHash": "sha256-Prwz95BgMHcWd72VwVbcH17LsV9f24K2QMcUiWUQZzI=", + "type": "file", + "url": "https://github.com/ethereum/solc-bin/raw/f743ca7/macosx-amd64/list.json" + }, + "original": { + "type": "file", + "url": "https://github.com/ethereum/solc-bin/raw/f743ca7/macosx-amd64/list.json" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 46ddb920c2064..ff783b4956e4e 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,6 @@ url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; }; }; solc = { @@ -21,7 +20,6 @@ outputs = { self, nixpkgs, rust-overlay, flake-utils, solc }: flake-utils.lib.eachDefaultSystem (system: let - overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default solc.overlay ]; @@ -35,17 +33,15 @@ devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ pkg-config - libusb1 - ] ++ lib.optionals pkgs.stdenv.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.AppKit - ]; - buildInputs = [ - pkgs.rust-analyzer-unwrapped + solc_0_8_23 + (solc.mkDefault pkgs solc_0_8_23) toolchain ]; + buildInputs = lib.optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.AppKit + ]; packages = with pkgs; [ - solc_0_8_20 - (solc.mkDefault pkgs solc_0_8_20) + rust-analyzer-unwrapped ]; # Environment variables From bd72b05f5e86014fce412a3e9356de9d1cda7c60 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 30 Jun 2024 18:29:27 +0200 Subject: [PATCH 1187/1963] fix: set next block timestamp as late as possible (#8311) --- crates/anvil/src/eth/backend/mem/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 5db5c879c21d5..9ccbb3bd9446c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -939,7 +939,6 @@ impl Backend { env.block.number = env.block.number.saturating_add(U256::from(1)); env.block.basefee = U256::from(current_base_fee); env.block.blob_excess_gas_and_price = current_excess_blob_gas_and_price; - env.block.timestamp = U256::from(self.time.next_timestamp()); // pick a random value for prevrandao env.block.prevrandao = Some(B256::random()); @@ -954,6 +953,12 @@ impl Backend { let (executed_tx, block_hash) = { let mut db = self.db.write().await; + + // finally set the next block timestamp, this is done just before execution, because + // there can be concurrent requests that can delay acquiring the db lock and we want + // to ensure the timestamp is as close as possible to the actual execution. + env.block.timestamp = U256::from(self.time.next_timestamp()); + let executor = TransactionExecutor { db: &mut *db, validator: self, From 90588120933f587ec61bb141efe306efd79f5f0d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 1 Jul 2024 00:37:17 +0200 Subject: [PATCH 1188/1963] feat(cheatcodes): add rpc with url overload (#8316) --- crates/cheatcodes/assets/cheatcodes.json | 60 ++++++++++++++++-------- crates/cheatcodes/spec/src/vm.rs | 6 +++ crates/cheatcodes/src/evm/fork.rs | 50 +++++++++++++------- testdata/cheats/Vm.sol | 3 +- testdata/default/cheats/Fork2.t.sol | 6 +++ 5 files changed, 86 insertions(+), 39 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 2a125df98c5f7..f2dde361978a4 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7011,26 +7011,6 @@ "status": "stable", "safety": "unsafe" }, - { - "func": { - "id": "rpc", - "description": "Performs an Ethereum JSON-RPC request to the current fork URL.", - "declaration": "function rpc(string calldata method, string calldata params) external returns (bytes memory data);", - "visibility": "external", - "mutability": "", - "signature": "rpc(string,string)", - "selector": "0x1206c8a8", - "selectorBytes": [ - 18, - 6, - 200, - 168 - ] - }, - "group": "evm", - "status": "stable", - "safety": "safe" - }, { "func": { "id": "rpcUrl", @@ -7091,6 +7071,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "rpc_0", + "description": "Performs an Ethereum JSON-RPC request to the current fork URL.", + "declaration": "function rpc(string calldata method, string calldata params) external returns (bytes memory data);", + "visibility": "external", + "mutability": "", + "signature": "rpc(string,string)", + "selector": "0x1206c8a8", + "selectorBytes": [ + 18, + 6, + 200, + 168 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "rpc_1", + "description": "Performs an Ethereum JSON-RPC request to the given endpoint.", + "declaration": "function rpc(string calldata urlOrAlias, string calldata method, string calldata params) external returns (bytes memory data);", + "visibility": "external", + "mutability": "", + "signature": "rpc(string,string,string)", + "selector": "0x0199a220", + "selectorBytes": [ + 1, + 153, + 162, + 32 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "selectFork", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index cd8aa08c509c6..62c25ac3d4bbb 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -611,6 +611,12 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function rpc(string calldata method, string calldata params) external returns (bytes memory data); + /// Performs an Ethereum JSON-RPC request to the given endpoint. + #[cheatcode(group = Evm, safety = Safe)] + function rpc(string calldata urlOrAlias, string calldata method, string calldata params) + external + returns (bytes memory data); + /// Gets all the logs according to specified filter. #[cheatcode(group = Evm, safety = Safe)] function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index a5a16065ed241..a8cc830009fec 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -233,29 +233,20 @@ impl Cheatcode for isPersistentCall { } } -impl Cheatcode for rpcCall { +impl Cheatcode for rpc_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { method, params } = self; let url = ccx.ecx.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; - let provider = ProviderBuilder::new(&url).build()?; - let params_json: serde_json::Value = serde_json::from_str(params)?; - let result = - foundry_common::block_on(provider.raw_request(method.clone().into(), params_json)) - .map_err(|err| fmt_err!("{method:?}: {err}"))?; - - let result_as_tokens = match crate::json::json_value_to_token(&result) - .map_err(|err| fmt_err!("failed to parse result: {err}"))? - { - DynSolValue::FixedBytes(bytes, size) => { - // converted fixed bytes to bytes to prevent evm encoding issues: - DynSolValue::Bytes(bytes.as_slice()[..size].to_vec()) - } - DynSolValue::Address(addr) => DynSolValue::Bytes(addr.to_vec()), - val => val, - }; + rpc_call(&url, method, params) + } +} - Ok(result_as_tokens.abi_encode()) +impl Cheatcode for rpc_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { urlOrAlias, method, params } = self; + let url = state.config.rpc_url(urlOrAlias)?; + rpc_call(&url, method, params) } } @@ -392,3 +383,26 @@ fn check_broadcast(state: &Cheatcodes) -> Result<()> { fn persist_caller(ccx: &mut CheatsCtxt) { ccx.ecx.db.add_persistent_account(ccx.caller); } + +/// Performs an Ethereum JSON-RPC request to the given endpoint. +fn rpc_call(url: &str, method: &str, params: &str) -> Result { + let provider = ProviderBuilder::new(url).build()?; + let params_json: serde_json::Value = serde_json::from_str(params)?; + let result = + foundry_common::block_on(provider.raw_request(method.to_string().into(), params_json)) + .map_err(|err| fmt_err!("{method:?}: {err}"))?; + + let result_as_tokens = match crate::json::json_value_to_token(&result) + .map_err(|err| fmt_err!("failed to parse result: {err}"))? + { + // Convert fixed bytes to bytes to prevent encoding issues. + // See: + DynSolValue::FixedBytes(bytes, size) => { + DynSolValue::Bytes(bytes.as_slice()[..size].to_vec()) + } + DynSolValue::Address(addr) => DynSolValue::Bytes(addr.to_vec()), + val => val, + }; + + Ok(result_as_tokens.abi_encode()) +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 4a0ec81c60790..b9ee72e1b5ba2 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -346,10 +346,11 @@ interface Vm { function rollFork(bytes32 txHash) external; function rollFork(uint256 forkId, uint256 blockNumber) external; function rollFork(uint256 forkId, bytes32 txHash) external; - function rpc(string calldata method, string calldata params) external returns (bytes memory data); function rpcUrl(string calldata rpcAlias) external view returns (string memory json); 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 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); diff --git a/testdata/default/cheats/Fork2.t.sol b/testdata/default/cheats/Fork2.t.sol index 4b40533347655..da382e90e399b 100644 --- a/testdata/default/cheats/Fork2.t.sol +++ b/testdata/default/cheats/Fork2.t.sol @@ -228,6 +228,12 @@ contract ForkTest is DSTest { bytes memory result = vm.rpc("eth_getBalance", file); assertEq(hex"10b7c11bcb51e6", result); } + + function testRpcWithUrl() public { + bytes memory result = vm.rpc("rpcAlias", "eth_blockNumber", "[]"); + uint256 decodedResult = vm.parseUint(vm.toString(result)); + assertGt(decodedResult, 20_000_000); + } } contract DummyContract { From 11e4e4e91469269af0d3f1ad546d6982a0d869bc Mon Sep 17 00:00:00 2001 From: HuyHuynh <63286199+huyhuynh3103@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:20:11 +0700 Subject: [PATCH 1189/1963] chore(verify-bytecode: refactor code for preventing code duplications (#8292) * fix: find by deployed code extract * chore: add unit test * chore: minor refactor * feat: minor refactor * feat: remove unused imports * feat: remove unused imports * test: fix unit test * fix: check whether tx is tx creation --- crates/verify/src/bytecode.rs | 53 ++++++++++++++++------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 79b7a7c8b5a07..763219500d351 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -189,7 +189,7 @@ impl VerifyBytecodeArgs { let receipt = provider .get_transaction_receipt(creation_data.transaction_hash) .await - .or_else(|e| eyre::bail!("Couldn't fetch transacrion receipt from RPC: {:?}", e))?; + .or_else(|e| eyre::bail!("Couldn't fetch transaction receipt from RPC: {:?}", e))?; let receipt = if let Some(receipt) = receipt { receipt @@ -199,17 +199,19 @@ impl VerifyBytecodeArgs { creation_data.transaction_hash ); }; + // Extract creation code - let maybe_creation_code = if receipt.contract_address == Some(self.address) { - &transaction.input - } else if transaction.to == Some(DEFAULT_CREATE2_DEPLOYER) { - &transaction.input[32..] - } else { - eyre::bail!( - "Could not extract the creation code for contract at address {}", - self.address - ); - }; + let maybe_creation_code = + if receipt.to.is_none() && receipt.contract_address == Some(self.address) { + &transaction.input + } else if receipt.to == Some(DEFAULT_CREATE2_DEPLOYER) { + &transaction.input[32..] + } else { + eyre::bail!( + "Could not extract the creation code for contract at address {}", + self.address + ); + }; // If bytecode_hash is disabled then its always partial verification let (verification_type, has_metadata) = @@ -583,36 +585,29 @@ fn try_partial_match( has_metadata: bool, ) -> Result { // 1. Check length of constructor args - if constructor_args.is_empty() { + if constructor_args.is_empty() || is_runtime { // Assume metadata is at the end of the bytecode - if has_metadata { - local_bytecode = extract_metadata_hash(local_bytecode)?; - bytecode = extract_metadata_hash(bytecode)?; - } - - // Now compare the creation code and bytecode - return Ok(local_bytecode == bytecode); - } - - if is_runtime { - if has_metadata { - local_bytecode = extract_metadata_hash(local_bytecode)?; - bytecode = extract_metadata_hash(bytecode)?; - } - - // Now compare the local code and bytecode - return Ok(local_bytecode == bytecode); + return try_extract_and_compare_bytecode(local_bytecode, bytecode, has_metadata) } // If not runtime, extract constructor args from the end of the bytecode bytecode = &bytecode[..bytecode.len() - constructor_args.len()]; local_bytecode = &local_bytecode[..local_bytecode.len() - constructor_args.len()]; + try_extract_and_compare_bytecode(local_bytecode, bytecode, has_metadata) +} + +fn try_extract_and_compare_bytecode( + mut local_bytecode: &[u8], + mut bytecode: &[u8], + has_metadata: bool, +) -> Result { if has_metadata { local_bytecode = extract_metadata_hash(local_bytecode)?; bytecode = extract_metadata_hash(bytecode)?; } + // Now compare the local code and bytecode Ok(local_bytecode == bytecode) } From 8f4a998307316478d6d10f6a0e29d08136661a3c Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Mon, 1 Jul 2024 05:05:28 -0700 Subject: [PATCH 1190/1963] Updating soldeer to version 0.2.16 (#8320) --- Cargo.lock | 16 ++++++++++++++-- Cargo.toml | 2 +- crates/forge/tests/cli/soldeer.rs | 18 +++++++++++------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8342975883f6f..6df19d1f1fc19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7949,9 +7949,9 @@ dependencies = [ [[package]] name = "soldeer" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdc15c518ac6bcdc09565cfcda5d0926c65dd2153fea83fcaf1cd536b0d26f7" +checksum = "75abb7ac158a52b280cb6bc3019ab5786cc6a07cf85d71c9b952c649e33a55f6" dependencies = [ "chrono", "clap", @@ -7972,6 +7972,7 @@ dependencies = [ "uuid 1.9.1", "walkdir", "yansi", + "yash-fnmatch", "zip 2.1.3", "zip-extract", ] @@ -9597,6 +9598,17 @@ dependencies = [ "is-terminal", ] +[[package]] +name = "yash-fnmatch" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697c20b479d2e6419e9a073bfdd20e90cbd8540d6c683ee46712e13de650e54f" +dependencies = [ + "regex", + "regex-syntax 0.8.4", + "thiserror", +] + [[package]] name = "zerocopy" version = "0.7.34" diff --git a/Cargo.toml b/Cargo.toml index 3437fd18df9c3..6fc79ca555294 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -249,4 +249,4 @@ reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" # soldeer -soldeer = "0.2.15" +soldeer = "0.2.16" diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index 6bbba534d9f64..7ac57a0742cec 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -11,6 +11,8 @@ forgesoldeer!(install_dependency, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; + let foundry_file = prj.root().join("foundry.toml"); + cmd.arg("soldeer").args([command, dependency]); cmd.execute(); @@ -34,16 +36,18 @@ checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" assert_eq!(lock_contents, actual_lock_contents); // Making sure the foundry contents are the right ones - let foundry_file = prj.root().join("foundry.toml"); - let foundry_contents = r#"[profile.default] -src = "src" -out = "out" -libs = ["lib"] + let foundry_contents = r#" +# Full reference https://github.com/foundry-rs/foundry/tree/master/crates/config -# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options +[profile.default] +script = "script" +solc = "0.8.26" +src = "src" +test = "test" +libs = ["dependencies"] [dependencies] -forge-std = { version = "1.8.1" } +forge-std = "1.8.1" "#; let actual_foundry_contents = read_file_to_string(&foundry_file); From 432b23bef4758487bd83ffeef6c691755ae17818 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:19:37 +0200 Subject: [PATCH 1191/1963] chore: tweak profiles once more (#8317) --- Cargo.toml | 44 ++++++++++++++++++++++++--------------- crates/cli/src/handler.rs | 6 ++---- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6fc79ca555294..a8cbc88ce1923 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,33 @@ all = "warn" # NOTE: Debuggers may provide less useful information with this setting. # Uncomment this section if you're using a debugger. [profile.dev] -debug = 1 +# https://davidlattimore.github.io/posts/2024/02/04/speeding-up-the-rust-edit-build-run-cycle.html +debug = "line-tables-only" +split-debuginfo = "unpacked" + +[profile.release] +opt-level = 3 +lto = "thin" +debug = "line-tables-only" +strip = "symbols" +panic = "abort" +codegen-units = 16 + +# Use the `--profile profiling` flag to show symbols in release mode. +# e.g. `cargo build --profile profiling` +[profile.profiling] +inherits = "release" +debug = 2 +split-debuginfo = "unpacked" +strip = false + +[profile.bench] +inherits = "profiling" + +[profile.maxperf] +inherits = "release" +lto = "fat" +codegen-units = 1 # Speed up tests and dev build. [profile.dev.package] @@ -95,26 +121,10 @@ axum.opt-level = 3 # keystores scrypt.opt-level = 3 -[profile.release] -opt-level = 3 -lto = "thin" -debug = "line-tables-only" -strip = true -panic = "abort" -codegen-units = 16 - -# Use the `--profile profiling` flag to show symbols in release mode. -# e.g. `cargo build --profile profiling` -[profile.profiling] -inherits = "release" -debug = 1 -strip = false - # Override packages which aren't perf-sensitive for faster compilation speed. [profile.release.package] mdbook.opt-level = 1 protobuf.opt-level = 1 -toml_edit.opt-level = 1 trezor-client.opt-level = 1 [workspace.dependencies] diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index d6e34f3b8e1ae..4f69c2ca445c9 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -48,13 +48,11 @@ impl EyreHandler for Handler { /// /// Panics are always caught by the more debug-centric handler. pub fn install() { - // If the user has not explicitly overridden "RUST_BACKTRACE", then produce full backtraces. if std::env::var_os("RUST_BACKTRACE").is_none() { - std::env::set_var("RUST_BACKTRACE", "full"); + std::env::set_var("RUST_BACKTRACE", "1"); } - let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok(); - if debug_enabled { + if std::env::var_os("FOUNDRY_DEBUG").is_some() { if let Err(e) = color_eyre::install() { debug!("failed to install color eyre error hook: {e}"); } From dc4ddda7df04a497d4f1f331b695db4598448691 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 1 Jul 2024 20:24:10 +0200 Subject: [PATCH 1192/1963] fix: only force include txs on first ready poll (#8325) --- crates/anvil/src/eth/miner.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index c446fc3530923..ddd27185075a3 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -12,7 +12,7 @@ use std::{ fmt, pin::Pin, sync::Arc, - task::{Context, Poll}, + task::{ready, Context, Poll}, time::Duration, }; use tokio::time::{Interval, MissedTickBehavior}; @@ -87,21 +87,12 @@ impl Miner { cx: &mut Context<'_>, ) -> Poll>> { self.inner.register(cx); - match self.mode.write().poll(pool, cx) { - Poll::Ready(next) => { - if let Some(transactions) = self.force_transactions.take() { - Poll::Ready(transactions.into_iter().chain(next).collect()) - } else { - Poll::Ready(next) - } - } - Poll::Pending => { - if let Some(transactions) = self.force_transactions.take() { - Poll::Ready(transactions) - } else { - Poll::Pending - } - } + let next = ready!(self.mode.write().poll(pool, cx)); + if let Some(mut transactions) = self.force_transactions.take() { + transactions.extend(next); + Poll::Ready(transactions) + } else { + Poll::Ready(next) } } } From afcf5b1bae7b066d0180cbc0a95be41993f16d96 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 1 Jul 2024 20:24:25 +0200 Subject: [PATCH 1193/1963] chore: include tx in setup output (#8324) --- crates/anvil/src/config.rs | 23 +++++++++++++++++++++++ crates/anvil/src/eth/backend/fork.rs | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 59c0acda34fa0..80bba839fde8a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -245,6 +245,10 @@ Chain ID: {} fork.block_hash(), fork.chain_id() ); + + if let Some(tx_hash) = fork.transaction_hash() { + let _ = writeln!(config_string, "Transaction hash: {tx_hash}"); + } } else { let _ = write!( config_string, @@ -1169,6 +1173,7 @@ latest block number: {latest_block}" eth_rpc_url, block_number: fork_block_number, block_hash, + transaction_hash: self.fork_choice.and_then(|fc| fc.transaction_hash()), provider, chain_id, override_chain_id, @@ -1245,6 +1250,24 @@ pub enum ForkChoice { Transaction(TxHash), } +impl ForkChoice { + /// Returns the block number to fork from + pub fn block_number(&self) -> Option { + match self { + Self::Block(block_number) => Some(*block_number), + Self::Transaction(_) => None, + } + } + + /// Returns the transaction hash to fork from + pub fn transaction_hash(&self) -> Option { + match self { + Self::Block(_) => None, + Self::Transaction(transaction_hash) => Some(*transaction_hash), + } + } +} + /// Convert a transaction hash into a ForkChoice impl From for ForkChoice { fn from(tx_hash: TxHash) -> Self { diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index cabb96cd5da5f..539b11a4dc8a0 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -118,6 +118,11 @@ impl ClientFork { self.config.read().block_number } + /// Returns the transaction hash we forked off of, if any. + pub fn transaction_hash(&self) -> Option { + self.config.read().transaction_hash + } + pub fn total_difficulty(&self) -> U256 { self.config.read().total_difficulty } @@ -579,6 +584,8 @@ pub struct ClientForkConfig { pub block_number: u64, /// The hash of the forked block pub block_hash: B256, + /// The transaction hash we forked off of, if any. + pub transaction_hash: Option, // TODO make provider agnostic pub provider: Arc, pub chain_id: u64, From 20b3da1f22e9f62f6e3406a5d582ad4aa509122c Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:55:12 +0200 Subject: [PATCH 1194/1963] feat(coverage): add option to ignore directories and files from coverage report (#8321) * feat: add option to ignore directories from coverage report * add docs, rename no-coverage-path to ignore-coverage-path * cargo fmt * small refactor * revert formatting changes * revert formatting * path_pattern_ignore_coverage -> coverage_pattern_inverse * use regex instead of glob * re-enable ignoring of sources after report * fix formatting * add basic filter test * remove redundant Path cast * use HashMap::retain * greatly simplify, remove CoverageFilter * move constants out of filter map --------- Co-authored-by: dimazhornyk Co-authored-by: Dima Zhornyk <55756184+dimazhornyk@users.noreply.github.com> --- crates/config/README.md | 1 + crates/config/src/lib.rs | 4 + crates/evm/coverage/src/lib.rs | 21 +++++- crates/forge/bin/cmd/coverage.rs | 21 ++++-- crates/forge/bin/cmd/test/filter.rs | 18 ++++- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/coverage.rs | 112 ++++++++++++++++++++++++++++ crates/forge/tests/cli/test_cmd.rs | 2 + 8 files changed, 171 insertions(+), 9 deletions(-) diff --git a/crates/config/README.md b/crates/config/README.md index fae78bfab46c3..337195276b72d 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -114,6 +114,7 @@ match_contract = "Foo" no_match_contract = "Bar" match_path = "*/Foo*" no_match_path = "*/Bar*" +no_match_coverage = "Baz" ffi = false always_use_create_2_factory = false prompt_timeout = 120 diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 58b1090ff0373..3efdc44cf9327 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -252,6 +252,9 @@ pub struct Config { /// Only run tests in source files that do not match the specified glob pattern. #[serde(rename = "no_match_path", with = "from_opt_glob")] pub path_pattern_inverse: Option, + /// Only show coverage for files that do not match the specified regex pattern. + #[serde(rename = "no_match_coverage")] + pub coverage_pattern_inverse: Option, /// Configuration for fuzz testing pub fuzz: FuzzConfig, /// Configuration for invariant testing @@ -2073,6 +2076,7 @@ impl Default for Config { contract_pattern_inverse: None, path_pattern: None, path_pattern_inverse: None, + coverage_pattern_inverse: None, fuzz: FuzzConfig::new("cache/fuzz".into()), invariant: InvariantConfig::new("cache/invariant".into()), always_use_create_2_factory: false, diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 22f4b9808e797..90486b3cc5158 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -9,18 +9,17 @@ extern crate tracing; use alloy_primitives::{Bytes, B256}; +use eyre::{Context, Result}; use foundry_compilers::artifacts::sourcemap::SourceMap; use semver::Version; use std::{ collections::{BTreeMap, HashMap}, fmt::Display, ops::{AddAssign, Deref, DerefMut}, - path::PathBuf, + path::{Path, PathBuf}, sync::Arc, }; -use eyre::{Context, Result}; - pub mod analysis; pub mod anchors; @@ -150,6 +149,22 @@ impl CoverageReport { } Ok(()) } + + /// Removes all the coverage items that should be ignored by the filter. + /// + /// This function should only be called after all the sources were used, otherwise, the output + /// will be missing the ones that are dependent on them. + pub fn filter_out_ignored_sources(&mut self, filter: impl Fn(&Path) -> bool) { + self.items.retain(|version, items| { + items.retain(|item| { + self.source_paths + .get(&(version.clone(), item.loc.source_id)) + .map(|path| filter(path)) + .unwrap_or(false) + }); + !items.is_empty() + }); + } } /// A collection of [`HitMap`]s. diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index b6086b9739f76..cf50f7a971d39 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -26,7 +26,11 @@ use foundry_config::{Config, SolcReq}; use rayon::prelude::*; use rustc_hash::FxHashMap; use semver::Version; -use std::{collections::HashMap, path::PathBuf, sync::Arc}; +use std::{ + collections::HashMap, + path::{Path, PathBuf}, + sync::Arc, +}; use yansi::Paint; // Loads project's figment and merges the build cli arguments into it @@ -247,10 +251,8 @@ impl CoverageArgs { let known_contracts = runner.known_contracts.clone(); - let outcome = self - .test - .run_tests(runner, config.clone(), verbosity, &self.test.filter(&config)) - .await?; + let filter = self.test.filter(&config); + let outcome = self.test.run_tests(runner, config.clone(), verbosity, &filter).await?; outcome.ensure_ok()?; @@ -288,6 +290,15 @@ impl CoverageArgs { } } + // Filter out ignored sources from the report + let file_pattern = filter.args().coverage_pattern_inverse.as_ref(); + let file_root = &filter.paths().root; + report.filter_out_ignored_sources(|path: &Path| { + file_pattern.map_or(true, |re| { + !re.is_match(&path.strip_prefix(file_root).unwrap_or(path).to_string_lossy()) + }) + }); + // Output final report for report_kind in self.report { match report_kind { diff --git a/crates/forge/bin/cmd/test/filter.rs b/crates/forge/bin/cmd/test/filter.rs index 7ececa7d4ae34..ec2e9b01b50e8 100644 --- a/crates/forge/bin/cmd/test/filter.rs +++ b/crates/forge/bin/cmd/test/filter.rs @@ -1,5 +1,5 @@ use clap::Parser; -use forge::TestFilter; +use foundry_common::TestFilter; use foundry_compilers::{FileFilter, ProjectPathsConfig}; use foundry_config::{filter::GlobMatcher, Config}; use std::{fmt, path::Path}; @@ -38,6 +38,10 @@ pub struct FilterArgs { value_name = "GLOB" )] pub path_pattern_inverse: Option, + + /// Only show coverage for files that do not match the specified regex pattern. + #[arg(long = "no-match-coverage", visible_alias = "nmco", value_name = "REGEX")] + pub coverage_pattern_inverse: Option, } impl FilterArgs { @@ -71,6 +75,9 @@ impl FilterArgs { if self.path_pattern_inverse.is_none() { self.path_pattern_inverse = config.path_pattern_inverse.clone().map(Into::into); } + if self.coverage_pattern_inverse.is_none() { + self.coverage_pattern_inverse = config.coverage_pattern_inverse.clone().map(Into::into); + } ProjectPathsAwareFilter { args_filter: self, paths: config.project_paths() } } } @@ -84,6 +91,7 @@ impl fmt::Debug for FilterArgs { .field("no-match-contract", &self.contract_pattern_inverse.as_ref().map(|r| r.as_str())) .field("match-path", &self.path_pattern.as_ref().map(|g| g.as_str())) .field("no-match-path", &self.path_pattern_inverse.as_ref().map(|g| g.as_str())) + .field("no-match-coverage", &self.coverage_pattern_inverse.as_ref().map(|g| g.as_str())) .finish_non_exhaustive() } } @@ -152,6 +160,9 @@ impl fmt::Display for FilterArgs { if let Some(p) = &self.path_pattern_inverse { writeln!(f, "\tno-match-path: `{}`", p.as_str())?; } + if let Some(p) = &self.coverage_pattern_inverse { + writeln!(f, "\tno-match-coverage: `{}`", p.as_str())?; + } Ok(()) } } @@ -178,6 +189,11 @@ impl ProjectPathsAwareFilter { pub fn args_mut(&mut self) -> &mut FilterArgs { &mut self.args_filter } + + /// Returns the project paths. + pub fn paths(&self) -> &ProjectPathsConfig { + &self.paths + } } impl FileFilter for ProjectPathsAwareFilter { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 6cdd179b349c9..63df640060c96 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -64,6 +64,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { contract_pattern_inverse: None, path_pattern: None, path_pattern_inverse: None, + coverage_pattern_inverse: None, fuzz: FuzzConfig { runs: 1000, max_test_rejects: 100203, diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 546a1103849d2..42cd7f60d4c66 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -76,3 +76,115 @@ contract AContractTest is DSTest { }; assert!(lcov_data.lines().any(valid_line), "{lcov_data}"); }); + +forgetest!(test_no_match_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + int public i; + + function init() public { + i = 0; + } + + function foo() public { + i = 1; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + AContract a; + + function setUp() public { + a = new AContract(); + a.init(); + } + + function testFoo() public { + a.foo(); + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "BContract.sol", + r#" +contract BContract { + int public i; + + function init() public { + i = 0; + } + + function foo() public { + i = 1; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "BContractTest.sol", + r#" +import "./test.sol"; +import {BContract} from "./BContract.sol"; + +contract BContractTest is DSTest { + BContract a; + + function setUp() public { + a = new BContract(); + a.init(); + } + + function testFoo() public { + a.foo(); + } +} + "#, + ) + .unwrap(); + + let lcov_info = prj.root().join("lcov.info"); + cmd.arg("coverage").args([ + "--no-match-coverage".to_string(), + "AContract".to_string(), // Filter out `AContract` + "--report".to_string(), + "lcov".to_string(), + "--report-file".to_string(), + lcov_info.to_str().unwrap().to_string(), + ]); + cmd.assert_success(); + assert!(lcov_info.exists()); + + let lcov_data = std::fs::read_to_string(lcov_info).unwrap(); + // BContract.init must be hit at least once + let re = Regex::new(r"FNDA:(\d+),BContract\.init").unwrap(); + let valid_line = |line| { + re.captures(line) + .map_or(false, |caps| caps.get(1).unwrap().as_str().parse::().unwrap() > 0) + }; + assert!(lcov_data.lines().any(valid_line), "{lcov_data}"); + + // AContract.init must not be hit + let re = Regex::new(r"FNDA:(\d+),AContract\.init").unwrap(); + let valid_line = |line| { + re.captures(line) + .map_or(false, |caps| caps.get(1).unwrap().as_str().parse::().unwrap() > 0) + }; + assert!(!lcov_data.lines().any(valid_line), "{lcov_data}"); +}); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 52584ab4402c9..d0f5ad16b1d97 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -21,6 +21,7 @@ forgetest!(can_set_filter_values, |prj, cmd| { contract_pattern_inverse: None, path_pattern: Some(glob.clone()), path_pattern_inverse: None, + coverage_pattern_inverse: None, ..Default::default() }; prj.write_config(config); @@ -33,6 +34,7 @@ forgetest!(can_set_filter_values, |prj, cmd| { assert_eq!(config.contract_pattern_inverse, None); assert_eq!(config.path_pattern.unwrap(), glob); assert_eq!(config.path_pattern_inverse, None); + assert_eq!(config.coverage_pattern_inverse, None); }); // tests that warning is displayed when there are no tests in project From f56616f7867299bf727262d430726d56478701a3 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 2 Jul 2024 13:17:47 +0300 Subject: [PATCH 1195/1963] feat(anvil): more flexible configuration `LogCollector` (#8328) * wip * separate console.log events under node::console * rename * fix * fix: clippy + docs --- crates/anvil/src/cmd.rs | 5 +++++ crates/anvil/src/config.rs | 11 ++++++++++ crates/anvil/src/eth/backend/executor.rs | 4 ++++ crates/anvil/src/eth/backend/mem/inspector.rs | 20 +++++++++++++------ crates/anvil/src/eth/backend/mem/mod.rs | 5 +++++ crates/anvil/src/logging.rs | 12 +++++++++-- 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index a8417d3332da4..f867030230a25 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -230,6 +230,7 @@ impl NodeArgs { .with_transaction_order(self.order) .with_genesis(self.init) .with_steps_tracing(self.evm_opts.steps_tracing) + .with_print_logs(!self.evm_opts.disable_console_log) .with_auto_impersonate(self.evm_opts.auto_impersonate) .with_ipc(self.ipc) .with_code_size_limit(self.evm_opts.code_size_limit) @@ -507,6 +508,10 @@ pub struct AnvilEvmArgs { #[arg(long, visible_alias = "tracing")] pub steps_tracing: bool, + /// Disable printing of `console.log` invocations to stdout. + #[arg(long, visible_alias = "no-console-log")] + pub disable_console_log: bool, + /// Enable autoImpersonate on startup #[arg(long, visible_alias = "auto-impersonate")] pub auto_impersonate: bool, diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 80bba839fde8a..863e3e9d3ad0c 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -155,6 +155,8 @@ pub struct NodeConfig { pub ipc_path: Option>, /// Enable transaction/call steps tracing for debug calls returning geth-style traces pub enable_steps_tracing: bool, + /// Enable printing of `console.log` invocations. + pub print_logs: bool, /// Enable auto impersonation of accounts on startup pub enable_auto_impersonate: bool, /// Configure the code size limit @@ -404,6 +406,7 @@ impl Default for NodeConfig { blob_excess_gas_and_price: None, enable_tracing: true, enable_steps_tracing: false, + print_logs: true, enable_auto_impersonate: false, no_storage_caching: false, server_config: Default::default(), @@ -789,6 +792,13 @@ impl NodeConfig { self } + /// Sets whether to print `console.log` invocations to stdout. + #[must_use] + pub fn with_print_logs(mut self, print_logs: bool) -> Self { + self.print_logs = print_logs; + self + } + /// Sets whether to enable autoImpersonate #[must_use] pub fn with_auto_impersonate(mut self, enable_auto_impersonate: bool) -> Self { @@ -949,6 +959,7 @@ impl NodeConfig { fees, Arc::new(RwLock::new(fork)), self.enable_steps_tracing, + self.print_logs, self.prune_history, self.transaction_block_keeper, self.block_time, diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 163428eeb6c53..23d890cfa7268 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -104,6 +104,7 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> /// Cumulative blob gas used by all executed transactions pub blob_gas_used: u128, pub enable_steps_tracing: bool, + pub print_logs: bool, /// Precompiles to inject to the EVM. pub precompile_factory: Option>, } @@ -304,6 +305,9 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator if self.enable_steps_tracing { inspector = inspector.with_steps_tracing(); } + if self.print_logs { + inspector = inspector.with_log_collector(); + } let exec_result = { let mut evm = diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 8510222d7132b..ed419dd98645a 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -1,6 +1,6 @@ //! Anvil specific [`revm::Inspector`] implementation -use crate::{eth::macros::node_info, revm::Database}; +use crate::revm::Database; use alloy_primitives::{Address, Log}; use foundry_evm::{ call_inspectors, @@ -22,7 +22,7 @@ use foundry_evm::{ pub struct Inspector { pub tracer: Option, /// collects all `console.sol` logs - pub log_collector: LogCollector, + pub log_collector: Option, } impl Inspector { @@ -30,7 +30,9 @@ impl Inspector { /// /// This will log all `console.sol` logs pub fn print_logs(&self) { - print_logs(&self.log_collector.logs) + if let Some(collector) = &self.log_collector { + print_logs(&collector.logs); + } } /// Configures the `Tracer` [`revm::Inspector`] @@ -44,6 +46,12 @@ impl Inspector { self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all())); self } + + /// Configures the `Tracer` [`revm::Inspector`] + pub fn with_log_collector(mut self) -> Self { + self.log_collector = Some(Default::default()); + self + } } impl revm::Inspector for Inspector { @@ -66,7 +74,7 @@ impl revm::Inspector for Inspector { } fn log(&mut self, ecx: &mut EvmContext, log: &Log) { - call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| { + call_inspectors!([&mut self.tracer, &mut self.log_collector], |inspector| { inspector.log(ecx, log); }); } @@ -74,7 +82,7 @@ impl revm::Inspector for Inspector { fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { call_inspectors!( #[ret] - [&mut self.tracer, Some(&mut self.log_collector)], + [&mut self.tracer, &mut self.log_collector], |inspector| inspector.call(ecx, inputs).map(Some), ); None @@ -160,6 +168,6 @@ impl InspectorExt for Inspector {} /// Prints all the logs pub fn print_logs(logs: &[Log]) { for log in decode_console_logs(logs) { - node_info!("{}", log); + tracing::info!(target: crate::logging::EVM_CONSOLE_LOG_TARGET, "{}", log); } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 9ccbb3bd9446c..06be3700609cc 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -166,6 +166,7 @@ pub struct Backend { /// keeps track of active snapshots at a specific block active_snapshots: Arc>>, enable_steps_tracing: bool, + print_logs: bool, /// How to keep history state prune_state_history_config: PruneStateHistoryConfig, /// max number of blocks with transactions in memory @@ -187,6 +188,7 @@ impl Backend { fees: FeeManager, fork: Arc>>, enable_steps_tracing: bool, + print_logs: bool, prune_state_history_config: PruneStateHistoryConfig, transaction_block_keeper: Option, automine_block_time: Option, @@ -239,6 +241,7 @@ impl Backend { genesis, active_snapshots: Arc::new(Mutex::new(Default::default())), enable_steps_tracing, + print_logs, prune_state_history_config, transaction_block_keeper, node_config, @@ -898,6 +901,7 @@ impl Backend { gas_used: 0, blob_gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, + print_logs: self.print_logs, precompile_factory: self.precompile_factory.clone(), }; @@ -969,6 +973,7 @@ impl Backend { gas_used: 0, blob_gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, + print_logs: self.print_logs, precompile_factory: self.precompile_factory.clone(), }; let executed_tx = executor.execute(); diff --git a/crates/anvil/src/logging.rs b/crates/anvil/src/logging.rs index ba97ab7ef47d2..098cf62a8b473 100644 --- a/crates/anvil/src/logging.rs +++ b/crates/anvil/src/logging.rs @@ -8,6 +8,9 @@ use tracing_subscriber::{layer::Context, Layer}; /// The target that identifies the events intended to be logged to stdout pub(crate) const NODE_USER_LOG_TARGET: &str = "node::user"; +/// The target that identifies the events coming from the `console.log` invocations. +pub(crate) const EVM_CONSOLE_LOG_TARGET: &str = "node::console"; + /// A logger that listens for node related events and displays them. /// /// This layer is intended to be used as filter for `NODE_USER_LOG_TARGET` events that will @@ -30,7 +33,10 @@ where S: tracing::Subscriber, { fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { - if self.state.is_enabled() && metadata.target() == NODE_USER_LOG_TARGET { + if self.state.is_enabled() && + (metadata.target() == NODE_USER_LOG_TARGET || + metadata.target() == EVM_CONSOLE_LOG_TARGET) + { Interest::always() } else { Interest::never() @@ -38,7 +44,9 @@ where } fn enabled(&self, metadata: &Metadata<'_>, _ctx: Context<'_, S>) -> bool { - self.state.is_enabled() && metadata.target() == NODE_USER_LOG_TARGET + self.state.is_enabled() && + (metadata.target() == NODE_USER_LOG_TARGET || + metadata.target() == EVM_CONSOLE_LOG_TARGET) } } From df1112a1e4f531d9b287d7f4f49fd7bd2ddbb9eb Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:43:09 +0200 Subject: [PATCH 1196/1963] chore(template): update script template to deploy `Counter` contract (#8330) update script template to deploy Counter contract --- crates/forge/assets/CounterTemplate.s.sol | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/forge/assets/CounterTemplate.s.sol b/crates/forge/assets/CounterTemplate.s.sol index df9ee8b02ce4d..cdc1fe9a1ba25 100644 --- a/crates/forge/assets/CounterTemplate.s.sol +++ b/crates/forge/assets/CounterTemplate.s.sol @@ -2,11 +2,18 @@ pragma solidity ^0.8.13; import {Script, console} from "forge-std/Script.sol"; +import {Counter} from "../src/Counter.sol"; contract CounterScript is Script { + Counter public counter; + function setUp() public {} function run() public { - vm.broadcast(); + vm.startBroadcast(); + + counter = new Counter(); + + vm.stopBroadcast(); } } From 6e3443e337f69c70d3562183e6b05dfd8b7a4e12 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:05:15 +0200 Subject: [PATCH 1197/1963] chore(evm): extract create2 deployer deployer constant (#8331) --- crates/evm/core/src/constants.rs | 13 +++++++++++++ crates/evm/evm/src/executors/mod.rs | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/evm/core/src/constants.rs b/crates/evm/core/src/constants.rs index 67fa2d338b2e3..5e49a01e7b143 100644 --- a/crates/evm/core/src/constants.rs +++ b/crates/evm/core/src/constants.rs @@ -37,9 +37,22 @@ pub const MAGIC_ASSUME: &[u8] = b"FOUNDRY::ASSUME"; /// Magic return value returned by the `skip` cheatcode. pub const MAGIC_SKIP: &[u8] = b"FOUNDRY::SKIP"; +/// The address that deploys the default CREATE2 deployer contract. +pub const DEFAULT_CREATE2_DEPLOYER_DEPLOYER: Address = + address!("3fAB184622Dc19b6109349B94811493BF2a45362"); /// The default CREATE2 deployer. pub const DEFAULT_CREATE2_DEPLOYER: Address = address!("4e59b44847b379578588920ca78fbf26c0b4956c"); /// The initcode of the default CREATE2 deployer. pub const DEFAULT_CREATE2_DEPLOYER_CODE: &[u8] = &hex!("604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); /// The runtime code of the default CREATE2 deployer. pub const DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE: &[u8] = &hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn create2_deployer() { + assert_eq!(DEFAULT_CREATE2_DEPLOYER_DEPLOYER.create(0), DEFAULT_CREATE2_DEPLOYER); + } +} diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 160c37f6f28ae..17d8727e8bbc0 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -17,7 +17,7 @@ use foundry_evm_core::{ backend::{Backend, CowBackend, DatabaseError, DatabaseExt, DatabaseResult, GLOBAL_FAIL_SLOT}, constants::{ CALLER, CHEATCODE_ADDRESS, CHEATCODE_CONTRACT_HASH, DEFAULT_CREATE2_DEPLOYER, - DEFAULT_CREATE2_DEPLOYER_CODE, + DEFAULT_CREATE2_DEPLOYER_CODE, DEFAULT_CREATE2_DEPLOYER_DEPLOYER, }, decode::RevertDecoder, utils::StateChangeset, @@ -164,14 +164,14 @@ impl Executor { .basic_ref(DEFAULT_CREATE2_DEPLOYER)? .ok_or_else(|| DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; - // if the deployer is not currently deployed, deploy the default one + // If the deployer is not currently deployed, deploy the default one. if create2_deployer_account.code.map_or(true, |code| code.is_empty()) { - let creator = "0x3fAB184622Dc19b6109349B94811493BF2a45362".parse().unwrap(); + let creator = DEFAULT_CREATE2_DEPLOYER_DEPLOYER; // Probably 0, but just in case. let initial_balance = self.get_balance(creator)?; - self.set_balance(creator, U256::MAX)?; + let res = self.deploy(creator, DEFAULT_CREATE2_DEPLOYER_CODE.into(), U256::ZERO, None)?; trace!(create2=?res.address, "deployed local create2 deployer"); From 899905c2ce688410da51f5e540d1540768525329 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 2 Jul 2024 17:51:43 +0200 Subject: [PATCH 1198/1963] chore: increase tx timeout (#8333) --- crates/script/src/receipts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index a080e2e0d3a0d..4cf718f8b5ab7 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -41,7 +41,7 @@ pub async fn check_tx_status( // If the tx is present in the mempool, run the pending tx future, and // assume the next drop is really really real Ok(PendingTransactionBuilder::new(provider, hash) - .with_timeout(Some(Duration::from_secs(120))) + .with_timeout(Some(Duration::from_secs(180))) .get_receipt() .await .map_or(TxStatus::Dropped, |r| r.into())) From 6001dbaba3b2fc5be67ba3410e54d10e487c1f84 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 2 Jul 2024 19:02:14 +0300 Subject: [PATCH 1199/1963] `foundry-fork-db` integration (#8329) * initial commit * [wip] use alloy-fork-db * fix: tests * foundry-fork-db * fmt * fix: deny.toml --- Cargo.lock | 27 +- Cargo.toml | 1 + crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/api.rs | 6 +- crates/anvil/src/eth/backend/db.rs | 5 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 4 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 3 +- crates/anvil/src/eth/backend/mem/mod.rs | 19 +- crates/anvil/src/lib.rs | 2 +- crates/cheatcodes/src/error.rs | 9 +- crates/evm/core/Cargo.toml | 2 +- crates/evm/core/src/backend/cow.rs | 7 +- crates/evm/core/src/backend/error.rs | 91 +- crates/evm/core/src/backend/in_memory_db.rs | 3 +- crates/evm/core/src/backend/mod.rs | 99 ++- crates/evm/core/src/fork/backend.rs | 817 ------------------ crates/evm/core/src/fork/cache.rs | 620 ------------- crates/evm/core/src/fork/database.rs | 6 +- crates/evm/core/src/fork/mod.rs | 9 - crates/evm/core/src/fork/multi.rs | 3 +- crates/evm/evm/src/executors/mod.rs | 14 +- deny.toml | 2 + 22 files changed, 170 insertions(+), 1581 deletions(-) delete mode 100644 crates/evm/core/src/fork/backend.rs delete mode 100644 crates/evm/core/src/fork/cache.rs diff --git a/Cargo.lock b/Cargo.lock index 6df19d1f1fc19..ff3c4969a3e63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3908,6 +3908,7 @@ dependencies = [ "foundry-common", "foundry-config", "foundry-evm-abi", + "foundry-fork-db", "foundry-test-utils", "futures", "itertools 0.13.0", @@ -3920,7 +3921,6 @@ dependencies = [ "thiserror", "tokio", "tracing", - "url", ] [[package]] @@ -3991,6 +3991,30 @@ dependencies = [ "yansi", ] +[[package]] +name = "foundry-fork-db" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3f9c9e02b19933218eb39c7234dcb0cc20e461258ced030f6fd6ac254a8637" +dependencies = [ + "alloy-primitives", + "alloy-provider", + "alloy-rpc-types", + "alloy-serde", + "alloy-transport", + "eyre", + "futures", + "parking_lot", + "revm", + "rustc-hash 2.0.0", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "url", +] + [[package]] name = "foundry-linking" version = "0.2.0" @@ -7024,6 +7048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c669c9b105dbb41133c17bf7f34d29368e358a7fee8fcc289e90dbfb024dfc4" dependencies = [ "aurora-engine-modexp", + "blst", "c-kzg", "k256", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index a8cbc88ce1923..8d13a7859163b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,6 +159,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.5.0", default-features = false } foundry-compilers = { version = "0.9.0", default-features = false } +foundry-fork-db = "0.1" solang-parser = "=0.3.3" ## revm diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 863e3e9d3ad0c..93857d80aef19 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -33,8 +33,8 @@ use foundry_common::{ }; use foundry_config::Config; use foundry_evm::{ + backend::{BlockchainDb, BlockchainDbMeta, SharedBackend}, constants::DEFAULT_CREATE2_DEPLOYER, - fork::{BlockchainDb, BlockchainDbMeta, SharedBackend}, revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv}, utils::apply_chain_and_block_specific_env_changes, }; diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index d130eb7f89f80..0493dc8016330 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1560,7 +1560,7 @@ impl EthApi { /// Handler for ETH RPC call: `anvil_impersonateAccount` pub async fn anvil_impersonate_account(&self, address: Address) -> Result<()> { node_info!("anvil_impersonateAccount"); - self.backend.impersonate(address).await?; + self.backend.impersonate(address); Ok(()) } @@ -1569,7 +1569,7 @@ impl EthApi { /// Handler for ETH RPC call: `anvil_stopImpersonatingAccount` pub async fn anvil_stop_impersonating_account(&self, address: Address) -> Result<()> { node_info!("anvil_stopImpersonatingAccount"); - self.backend.stop_impersonating(address).await?; + self.backend.stop_impersonating(address); Ok(()) } @@ -1578,7 +1578,7 @@ impl EthApi { /// Handler for ETH RPC call: `anvil_autoImpersonateAccount` pub async fn anvil_auto_impersonate_account(&self, enabled: bool) -> Result<()> { node_info!("anvil_autoImpersonateAccount"); - self.backend.auto_impersonate_account(enabled).await; + self.backend.auto_impersonate_account(enabled); Ok(()) } diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 9182cdadb1d32..48b0eaaf5b139 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -7,8 +7,9 @@ use alloy_rpc_types::BlockId; use anvil_core::eth::{block::Block, transaction::TypedTransaction}; use foundry_common::errors::FsPathError; use foundry_evm::{ - backend::{DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot}, - fork::BlockchainDb, + backend::{ + BlockchainDb, DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot, + }, revm::{ db::{CacheDB, DatabaseRef, DbAccount}, primitives::{BlockEnv, Bytecode, HashMap, KECCAK_EMPTY}, diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index ae325f9750054..cf86699c5b1ca 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -8,8 +8,8 @@ use crate::{ use alloy_primitives::{Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ - backend::{DatabaseResult, RevertSnapshotAction, StateSnapshot}, - fork::{database::ForkDbSnapshot, BlockchainDb}, + backend::{BlockchainDb, DatabaseResult, RevertSnapshotAction, StateSnapshot}, + fork::database::ForkDbSnapshot, revm::Database, }; diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 6269727c104be..b6c3db12c2b1b 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -11,8 +11,7 @@ use crate::{ use alloy_primitives::{Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ - backend::{DatabaseResult, StateSnapshot}, - fork::BlockchainDb, + backend::{BlockchainDb, DatabaseResult, StateSnapshot}, hashbrown::HashMap, }; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 06be3700609cc..728535fc2e7ee 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -61,7 +61,7 @@ use anvil_core::eth::{ use anvil_rpc::error::RpcError; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ - backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, + backend::{BackendError, BackendResult, DatabaseError, DatabaseResult, RevertSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, decode::RevertDecoder, inspectors::AccessListInspector, @@ -273,7 +273,7 @@ impl Backend { /// Applies the configured genesis settings /// /// This will fund, create the genesis accounts - async fn apply_genesis(&self) -> DatabaseResult<()> { + async fn apply_genesis(&self) -> BackendResult<()> { trace!(target: "backend", "setting genesis balances"); if self.fork.read().is_some() { @@ -287,7 +287,7 @@ impl Backend { genesis_accounts_futures.push(tokio::task::spawn(async move { let db = db.read().await; let info = db.basic_ref(address)?.unwrap_or_default(); - Ok::<_, DatabaseError>((address, info)) + Ok::<_, BackendError>((address, info)) })); } @@ -302,7 +302,7 @@ impl Backend { fork_genesis_infos.clear(); for res in genesis_accounts { - let (address, mut info) = res.map_err(DatabaseError::display)??; + let (address, mut info) = res.map_err(BackendError::display)??; info.balance = self.genesis.balance; db.insert_account(address, info.clone()); @@ -329,26 +329,25 @@ impl Backend { /// Sets the account to impersonate /// /// Returns `true` if the account is already impersonated - pub async fn impersonate(&self, addr: Address) -> DatabaseResult { + pub fn impersonate(&self, addr: Address) -> bool { if self.cheats.impersonated_accounts().contains(&addr) { - return Ok(true); + return true } // Ensure EIP-3607 is disabled let mut env = self.env.write(); env.cfg.disable_eip3607 = true; - Ok(self.cheats.impersonate(addr)) + self.cheats.impersonate(addr) } /// Removes the account that from the impersonated set /// /// If the impersonated `addr` is a contract then we also reset the code here - pub async fn stop_impersonating(&self, addr: Address) -> DatabaseResult<()> { + pub fn stop_impersonating(&self, addr: Address) { self.cheats.stop_impersonating(&addr); - Ok(()) } /// If set to true will make every account impersonated - pub async fn auto_impersonate_account(&self, enabled: bool) { + pub fn auto_impersonate_account(&self, enabled: bool) { self.cheats.set_auto_impersonate_account(enabled); } diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index a27774dfb0ce2..3f9f574f0756c 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -128,7 +128,7 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle let backend = Arc::new(config.setup().await); if config.enable_auto_impersonate { - backend.auto_impersonate_account(true).await; + backend.auto_impersonate_account(true); } let fork = backend.get_fork(); diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 5d38bbc34d8c6..5509efa2d1626 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -5,7 +5,7 @@ use alloy_signer_local::LocalSignerError; use alloy_sol_types::SolError; use foundry_common::errors::FsPathError; use foundry_config::UnresolvedEnvVarError; -use foundry_evm_core::backend::DatabaseError; +use foundry_evm_core::backend::{BackendError, DatabaseError}; use foundry_wallets::error::WalletSignerError; use k256::ecdsa::signature::Error as SignatureError; use revm::primitives::EVMError; @@ -290,6 +290,7 @@ impl_from!( FsPathError, hex::FromHexError, eyre::Error, + BackendError, DatabaseError, jsonpath_lib::JsonPathError, serde_json::Error, @@ -304,10 +305,10 @@ impl_from!( WalletSignerError, ); -impl From> for Error { +impl> From> for Error { #[inline] - fn from(err: EVMError) -> Self { - Self::display(DatabaseError::from(err)) + fn from(err: EVMError) -> Self { + Self::display(BackendError::from(err)) } } diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 45d710e5580d1..6fbf674535f65 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -33,6 +33,7 @@ alloy-rpc-types.workspace = true alloy-serde.workspace = true alloy-sol-types.workspace = true alloy-transport.workspace = true +foundry-fork-db.workspace = true revm = { workspace = true, features = [ "std", @@ -58,7 +59,6 @@ serde_json.workspace = true thiserror.workspace = true tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true -url.workspace = true [dev-dependencies] foundry-test-utils.workspace = true diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 2866f4ec14c80..6a3e6f3687594 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -1,9 +1,9 @@ //! A wrapper around `Backend` that is clone-on-write used for fuzzing. +use super::BackendError; use crate::{ backend::{ - diagnostic::RevertDiagnostic, error::DatabaseError, Backend, DatabaseExt, LocalForkId, - RevertSnapshotAction, + diagnostic::RevertDiagnostic, Backend, DatabaseExt, LocalForkId, RevertSnapshotAction, }, fork::{CreateFork, ForkId}, InspectorExt, @@ -11,6 +11,7 @@ use crate::{ use alloy_genesis::GenesisAccount; use alloy_primitives::{Address, B256, U256}; use eyre::WrapErr; +use foundry_fork_db::DatabaseError; use revm::{ db::DatabaseRef, primitives::{ @@ -217,7 +218,7 @@ impl<'a> DatabaseExt for CowBackend<'a> { &mut self, allocs: &BTreeMap, journaled_state: &mut JournaledState, - ) -> Result<(), DatabaseError> { + ) -> Result<(), BackendError> { self.backend_mut(&Env::default()).load_allocs(allocs, journaled_state) } diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index 2f40bd4569942..c3143b03e1253 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -1,45 +1,22 @@ -use alloy_primitives::{Address, B256, U256}; -use alloy_rpc_types::BlockId; -use futures::channel::mpsc::{SendError, TrySendError}; +use alloy_primitives::Address; +pub use foundry_fork_db::{DatabaseError, DatabaseResult}; use revm::primitives::EVMError; -use std::{ - convert::Infallible, - sync::{mpsc::RecvError, Arc}, -}; +use std::convert::Infallible; -/// Result alias with `DatabaseError` as error -pub type DatabaseResult = Result; +pub type BackendResult = Result; /// Errors that can happen when working with [`revm::Database`] #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] -pub enum DatabaseError { +pub enum BackendError { #[error("{0}")] Message(String), #[error("cheatcodes are not enabled for {0}; see `vm.allowCheatcodes(address)`")] NoCheats(Address), + #[error(transparent)] + Backend(#[from] DatabaseError), #[error("failed to fetch account info for {0}")] MissingAccount(Address), - #[error("missing bytecode for code hash {0}")] - MissingCode(B256), - #[error(transparent)] - Recv(#[from] RecvError), - #[error(transparent)] - Send(#[from] SendError), - #[error("failed to get account for {0}: {1}")] - GetAccount(Address, Arc), - #[error("failed to get storage for {0} at {1}: {2}")] - GetStorage(Address, U256, Arc), - #[error("failed to get block hash for {0}: {1}")] - GetBlockHash(u64, Arc), - #[error("failed to get full block for {0:?}: {1}")] - GetFullBlock(BlockId, Arc), - #[error("block {0:?} does not exist")] - BlockNotFound(BlockId), - #[error("failed to get transaction {0}: {1}")] - GetTransaction(B256, Arc), - #[error("transaction {0} not found")] - TransactionNotFound(B256), #[error( "CREATE2 Deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) not present on this chain.\n\ For a production environment, you can deploy it using the pre-signed transaction from \ @@ -51,7 +28,7 @@ pub enum DatabaseError { Other(String), } -impl DatabaseError { +impl BackendError { /// Create a new error with a message pub fn msg(msg: impl Into) -> Self { Self::Message(msg.into()) @@ -61,63 +38,29 @@ impl DatabaseError { pub fn display(msg: impl std::fmt::Display) -> Self { Self::Message(msg.to_string()) } - - fn get_rpc_error(&self) -> Option<&eyre::Error> { - match self { - Self::GetAccount(_, err) => Some(err), - Self::GetStorage(_, _, err) => Some(err), - Self::GetBlockHash(_, err) => Some(err), - Self::GetFullBlock(_, err) => Some(err), - Self::GetTransaction(_, err) => Some(err), - // Enumerate explicitly to make sure errors are updated if a new one is added. - Self::NoCheats(_) | - Self::MissingAccount(_) | - Self::MissingCode(_) | - Self::Recv(_) | - Self::Send(_) | - Self::Message(_) | - Self::BlockNotFound(_) | - Self::TransactionNotFound(_) | - Self::MissingCreate2Deployer => None, - Self::Other(_) => None, - } - } - - /// Whether the error is potentially caused by the user forking from an older block in a - /// non-archive node. - pub fn is_possibly_non_archive_node_error(&self) -> bool { - static GETH_MESSAGE: &str = "missing trie node"; - - self.get_rpc_error() - .map(|err| err.to_string().to_lowercase().contains(GETH_MESSAGE)) - .unwrap_or(false) - } } -impl From for DatabaseError { +impl From for BackendError { fn from(value: tokio::task::JoinError) -> Self { Self::display(value) } } -impl From> for DatabaseError { - fn from(value: TrySendError) -> Self { - value.into_send_error().into() - } -} - -impl From for DatabaseError { +impl From for BackendError { fn from(value: Infallible) -> Self { match value {} } } // Note: this is mostly necessary to use some revm internals that return an [EVMError] -impl From> for DatabaseError { - fn from(err: EVMError) -> Self { +impl> From> for BackendError { + fn from(err: EVMError) -> Self { match err { - EVMError::Database(err) => err, - err => Self::Other(err.to_string()), + EVMError::Database(err) => err.into(), + EVMError::Custom(err) => Self::msg(err), + EVMError::Header(err) => Self::msg(err.to_string()), + EVMError::Precompile(err) => Self::msg(err), + EVMError::Transaction(err) => Self::msg(err.to_string()), } } } diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index e8f371f61e7fc..be63f230073c0 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -1,7 +1,8 @@ //! In-memory database. -use crate::{backend::error::DatabaseError, snapshot::Snapshots}; +use crate::snapshot::Snapshots; use alloy_primitives::{Address, B256, U256}; +use foundry_fork_db::DatabaseError; use revm::{ db::{CacheDB, DatabaseRef, EmptyDB}, primitives::{Account, AccountInfo, Bytecode, HashMap as Map}, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 8cf58bfbdbe9c..d544c01af484b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -2,7 +2,7 @@ use crate::{ constants::{CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, TEST_CONTRACT_ADDRESS}, - fork::{CreateFork, ForkId, MultiFork, SharedBackend}, + fork::{CreateFork, ForkId, MultiFork}, snapshot::Snapshots, utils::configure_tx_env, InspectorExt, @@ -13,6 +13,7 @@ use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; use alloy_serde::WithOtherFields; use eyre::Context; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; +pub use foundry_fork_db::{cache::BlockchainDbMeta, BlockchainDb, SharedBackend}; use revm::{ db::{CacheDB, DatabaseRef}, inspectors::NoOpInspector, @@ -32,7 +33,7 @@ mod diagnostic; pub use diagnostic::RevertDiagnostic; mod error; -pub use error::{DatabaseError, DatabaseResult}; +pub use error::{BackendError, BackendResult, DatabaseError, DatabaseResult}; mod cow; pub use cow::CowBackend; @@ -266,7 +267,7 @@ pub trait DatabaseExt: Database + DatabaseCommit { &mut self, allocs: &BTreeMap, journaled_state: &mut JournaledState, - ) -> Result<(), DatabaseError>; + ) -> Result<(), BackendError>; /// Returns true if the given account is currently marked as persistent. fn is_persistent(&self, acc: &Address) -> bool; @@ -315,16 +316,16 @@ pub trait DatabaseExt: Database + DatabaseCommit { /// Ensures that `account` is allowed to execute cheatcodes /// /// Returns an error if [`Self::has_cheatcode_access`] returns `false` - fn ensure_cheatcode_access(&self, account: &Address) -> Result<(), DatabaseError> { + fn ensure_cheatcode_access(&self, account: &Address) -> Result<(), BackendError> { if !self.has_cheatcode_access(account) { - return Err(DatabaseError::NoCheats(*account)); + return Err(BackendError::NoCheats(*account)); } Ok(()) } /// Same as [`Self::ensure_cheatcode_access()`] but only enforces it if the backend is currently /// in forking mode - fn ensure_cheatcode_access_forking_mode(&self, account: &Address) -> Result<(), DatabaseError> { + fn ensure_cheatcode_access_forking_mode(&self, account: &Address) -> Result<(), BackendError> { if self.is_forked_mode() { return self.ensure_cheatcode_access(account); } @@ -758,7 +759,7 @@ impl Backend { /// This account data then would not match the account data of a fork if it exists. /// So when the first fork is initialized we replace these accounts with the actual account as /// it exists on the fork. - fn prepare_init_journal_state(&mut self) -> Result<(), DatabaseError> { + fn prepare_init_journal_state(&mut self) -> Result<(), BackendError> { let loaded_accounts = self .fork_init_journaled_state .state @@ -786,7 +787,7 @@ impl Backend { // otherwise we need to replace the account's info with the one from the fork's // database let fork_account = Database::basic(&mut fork.db, loaded_account)? - .ok_or(DatabaseError::MissingAccount(loaded_account))?; + .ok_or(BackendError::MissingAccount(loaded_account))?; init_account.info = fork_account; } fork.journaled_state = journaled_state; @@ -814,10 +815,8 @@ impl Backend { } else { let block = fork.db.db.get_full_block(BlockNumberOrTag::Latest)?; - let number = block - .header - .number - .ok_or_else(|| DatabaseError::BlockNotFound(BlockNumberOrTag::Latest.into()))?; + let number = + block.header.number.ok_or_else(|| BackendError::msg("missing block number"))?; Ok((number, block)) } @@ -1030,7 +1029,7 @@ impl DatabaseExt for Backend { // Initialize caller with its fork info if let Some(mut acc) = caller_account { let fork_account = Database::basic(&mut target_fork.db, caller)? - .ok_or(DatabaseError::MissingAccount(caller))?; + .ok_or(BackendError::MissingAccount(caller))?; acc.info = fork_account; target_fork.journaled_state.state.insert(caller, acc); @@ -1298,7 +1297,7 @@ impl DatabaseExt for Backend { &mut self, allocs: &BTreeMap, journaled_state: &mut JournaledState, - ) -> Result<(), DatabaseError> { + ) -> Result<(), BackendError> { // Loop through all of the allocs defined in the map and commit them to the journal. for (addr, acc) in allocs.iter() { // Fetch the account from the journaled state. Will create a new account if it does @@ -1422,7 +1421,7 @@ impl Database for Backend { type Error = DatabaseError; fn basic(&mut self, address: Address) -> Result, Self::Error> { if let Some(db) = self.active_fork_db_mut() { - db.basic(address) + Ok(db.basic(address)?) } else { Ok(self.mem_db.basic(address)?) } @@ -1430,7 +1429,7 @@ impl Database for Backend { fn code_by_hash(&mut self, code_hash: B256) -> Result { if let Some(db) = self.active_fork_db_mut() { - db.code_by_hash(code_hash) + Ok(db.code_by_hash(code_hash)?) } else { Ok(self.mem_db.code_by_hash(code_hash)?) } @@ -1438,7 +1437,7 @@ impl Database for Backend { fn storage(&mut self, address: Address, index: U256) -> Result { if let Some(db) = self.active_fork_db_mut() { - Database::storage(db, address, index) + Ok(Database::storage(db, address, index)?) } else { Ok(Database::storage(&mut self.mem_db, address, index)?) } @@ -1446,7 +1445,7 @@ impl Database for Backend { fn block_hash(&mut self, number: U256) -> Result { if let Some(db) = self.active_fork_db_mut() { - db.block_hash(number) + Ok(db.block_hash(number)?) } else { Ok(self.mem_db.block_hash(number)?) } @@ -1875,7 +1874,7 @@ fn apply_state_changeset( journaled_state: &mut JournaledState, fork: &mut Fork, persistent_accounts: &HashSet
, -) -> Result<(), DatabaseError> { +) -> Result<(), BackendError> { // commit the state and update the loaded accounts fork.db.commit(state); @@ -1884,3 +1883,65 @@ fn apply_state_changeset( Ok(()) } + +#[cfg(test)] +mod tests { + use crate::{backend::Backend, fork::CreateFork, opts::EvmOpts}; + use alloy_primitives::{Address, U256}; + use alloy_provider::Provider; + use foundry_common::provider::get_http_provider; + use foundry_config::{Config, NamedChain}; + use foundry_fork_db::cache::{BlockchainDb, BlockchainDbMeta}; + use revm::DatabaseRef; + + const ENDPOINT: Option<&str> = option_env!("ETH_RPC_URL"); + + #[tokio::test(flavor = "multi_thread")] + async fn can_read_write_cache() { + let Some(endpoint) = ENDPOINT else { return }; + + let provider = get_http_provider(endpoint); + + let block_num = provider.get_block_number().await.unwrap(); + + let config = Config::figment(); + let mut evm_opts = config.extract::().unwrap(); + evm_opts.fork_block_number = Some(block_num); + + let (env, _block) = evm_opts.fork_evm_env(endpoint).await.unwrap(); + + let fork = CreateFork { + enable_caching: true, + url: endpoint.to_string(), + env: env.clone(), + evm_opts, + }; + + let backend = Backend::spawn(Some(fork)); + + // some rng contract from etherscan + let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); + + let idx = U256::from(0u64); + let _value = backend.storage_ref(address, idx); + let _account = backend.basic_ref(address); + + // fill some slots + let num_slots = 10u64; + for idx in 1..num_slots { + let _ = backend.storage_ref(address, U256::from(idx)); + } + drop(backend); + + let meta = + BlockchainDbMeta { cfg_env: env.cfg, block_env: env.block, hosts: Default::default() }; + + let db = BlockchainDb::new( + meta, + Some(Config::foundry_block_cache_dir(NamedChain::Mainnet, block_num).unwrap()), + ); + assert!(db.accounts().read().contains_key(&address)); + assert!(db.storage().read().contains_key(&address)); + assert_eq!(db.storage().read().get(&address).unwrap().len(), num_slots as usize); + } +} diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs deleted file mode 100644 index 6bd1caaa1cb68..0000000000000 --- a/crates/evm/core/src/fork/backend.rs +++ /dev/null @@ -1,817 +0,0 @@ -//! Smart caching and deduplication of requests when using a forking provider -use crate::{ - backend::{DatabaseError, DatabaseResult}, - fork::{cache::FlushJsonBlockCacheDB, BlockchainDb}, -}; -use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; -use alloy_provider::{network::AnyNetwork, Provider}; -use alloy_rpc_types::{Block, BlockId, Transaction}; -use alloy_serde::WithOtherFields; -use alloy_transport::Transport; -use eyre::WrapErr; -use foundry_common::NON_ARCHIVE_NODE_WARNING; -use futures::{ - channel::mpsc::{channel, Receiver, Sender}, - stream::Stream, - task::{Context, Poll}, - Future, FutureExt, -}; -use revm::{ - db::DatabaseRef, - primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, -}; -use rustc_hash::FxHashMap; -use std::{ - collections::{hash_map::Entry, HashMap, VecDeque}, - future::IntoFuture, - marker::PhantomData, - pin::Pin, - sync::{ - mpsc::{channel as oneshot_channel, Sender as OneshotSender}, - Arc, - }, -}; - -// Various future/request type aliases - -type AccountFuture = - Pin, Address)> + Send>>; -type StorageFuture = Pin, Address, U256)> + Send>>; -type BlockHashFuture = Pin, u64)> + Send>>; -type FullBlockFuture = - Pin, Err>, BlockId)> + Send>>; -type TransactionFuture = Pin< - Box< - dyn Future, Err>, B256)> - + Send, - >, ->; - -type AccountInfoSender = OneshotSender>; -type StorageSender = OneshotSender>; -type BlockHashSender = OneshotSender>; -type FullBlockSender = OneshotSender>; -type TransactionSender = OneshotSender>>; - -/// Request variants that are executed by the provider -enum ProviderRequest { - Account(AccountFuture), - Storage(StorageFuture), - BlockHash(BlockHashFuture), - FullBlock(FullBlockFuture), - Transaction(TransactionFuture), -} - -/// The Request type the Backend listens for -#[derive(Debug)] -enum BackendRequest { - /// Fetch the account info - Basic(Address, AccountInfoSender), - /// Fetch a storage slot - Storage(Address, U256, StorageSender), - /// Fetch a block hash - BlockHash(u64, BlockHashSender), - /// Fetch an entire block with transactions - FullBlock(BlockId, FullBlockSender), - /// Fetch a transaction - Transaction(B256, TransactionSender), - /// Sets the pinned block to fetch data from - SetPinnedBlock(BlockId), -} - -/// Handles an internal provider and listens for requests. -/// -/// This handler will remain active as long as it is reachable (request channel still open) and -/// requests are in progress. -#[must_use = "futures do nothing unless polled"] -pub struct BackendHandler { - provider: P, - transport: PhantomData, - /// Stores all the data. - db: BlockchainDb, - /// Requests currently in progress - pending_requests: Vec>, - /// Listeners that wait for a `get_account` related response - account_requests: HashMap>, - /// Listeners that wait for a `get_storage_at` response - storage_requests: HashMap<(Address, U256), Vec>, - /// Listeners that wait for a `get_block` response - block_requests: FxHashMap>, - /// Incoming commands. - incoming: Receiver, - /// unprocessed queued requests - queued_requests: VecDeque, - /// The block to fetch data from. - // This is an `Option` so that we can have less code churn in the functions below - block_id: Option, -} - -impl BackendHandler -where - T: Transport + Clone, - P: Provider + Clone + Unpin + 'static, -{ - fn new( - provider: P, - db: BlockchainDb, - rx: Receiver, - block_id: Option, - ) -> Self { - Self { - provider, - db, - pending_requests: Default::default(), - account_requests: Default::default(), - storage_requests: Default::default(), - block_requests: Default::default(), - queued_requests: Default::default(), - incoming: rx, - block_id, - transport: PhantomData, - } - } - - /// handle the request in queue in the future. - /// - /// We always check: - /// 1. if the requested value is already stored in the cache, then answer the sender - /// 2. otherwise, fetch it via the provider but check if a request for that value is already in - /// progress (e.g. another Sender just requested the same account) - fn on_request(&mut self, req: BackendRequest) { - match req { - BackendRequest::Basic(addr, sender) => { - trace!(target: "backendhandler", "received request basic address={:?}", addr); - let acc = self.db.accounts().read().get(&addr).cloned(); - if let Some(basic) = acc { - let _ = sender.send(Ok(basic)); - } else { - self.request_account(addr, sender); - } - } - BackendRequest::BlockHash(number, sender) => { - let hash = self.db.block_hashes().read().get(&U256::from(number)).cloned(); - if let Some(hash) = hash { - let _ = sender.send(Ok(hash)); - } else { - self.request_hash(number, sender); - } - } - BackendRequest::FullBlock(number, sender) => { - self.request_full_block(number, sender); - } - BackendRequest::Transaction(tx, sender) => { - self.request_transaction(tx, sender); - } - BackendRequest::Storage(addr, idx, sender) => { - // account is already stored in the cache - let value = - self.db.storage().read().get(&addr).and_then(|acc| acc.get(&idx).copied()); - if let Some(value) = value { - let _ = sender.send(Ok(value)); - } else { - // account present but not storage -> fetch storage - self.request_account_storage(addr, idx, sender); - } - } - BackendRequest::SetPinnedBlock(block_id) => { - self.block_id = Some(block_id); - } - } - } - - /// process a request for account's storage - fn request_account_storage(&mut self, address: Address, idx: U256, listener: StorageSender) { - match self.storage_requests.entry((address, idx)) { - Entry::Occupied(mut entry) => { - entry.get_mut().push(listener); - } - Entry::Vacant(entry) => { - trace!(target: "backendhandler", %address, %idx, "preparing storage request"); - entry.insert(vec![listener]); - let provider = self.provider.clone(); - let block_id = self.block_id.unwrap_or_default(); - let fut = Box::pin(async move { - let storage = provider - .get_storage_at(address, idx) - .block_id(block_id) - .await - .map_err(Into::into); - (storage, address, idx) - }); - self.pending_requests.push(ProviderRequest::Storage(fut)); - } - } - } - - /// returns the future that fetches the account data - fn get_account_req(&self, address: Address) -> ProviderRequest { - trace!(target: "backendhandler", "preparing account request, address={:?}", address); - let provider = self.provider.clone(); - let block_id = self.block_id.unwrap_or_default(); - let fut = Box::pin(async move { - let balance = provider.get_balance(address).block_id(block_id).into_future(); - let nonce = provider.get_transaction_count(address).block_id(block_id).into_future(); - let code = provider.get_code_at(address).block_id(block_id).into_future(); - let resp = tokio::try_join!(balance, nonce, code).map_err(Into::into); - (resp, address) - }); - ProviderRequest::Account(fut) - } - - /// process a request for an account - fn request_account(&mut self, address: Address, listener: AccountInfoSender) { - match self.account_requests.entry(address) { - Entry::Occupied(mut entry) => { - entry.get_mut().push(listener); - } - Entry::Vacant(entry) => { - entry.insert(vec![listener]); - self.pending_requests.push(self.get_account_req(address)); - } - } - } - - /// process a request for an entire block - fn request_full_block(&mut self, number: BlockId, sender: FullBlockSender) { - let provider = self.provider.clone(); - let fut = Box::pin(async move { - let block = provider - .get_block(number, true.into()) - .await - .wrap_err("could not fetch block {number:?}"); - (sender, block, number) - }); - - self.pending_requests.push(ProviderRequest::FullBlock(fut)); - } - - /// process a request for a transactions - fn request_transaction(&mut self, tx: B256, sender: TransactionSender) { - let provider = self.provider.clone(); - let fut = Box::pin(async move { - let block = provider - .get_transaction_by_hash(tx) - .await - .wrap_err_with(|| format!("could not get transaction {tx}")) - .and_then(|maybe| { - maybe.ok_or_else(|| eyre::eyre!("could not get transaction {tx}")) - }); - (sender, block, tx) - }); - - self.pending_requests.push(ProviderRequest::Transaction(fut)); - } - - /// process a request for a block hash - fn request_hash(&mut self, number: u64, listener: BlockHashSender) { - match self.block_requests.entry(number) { - Entry::Occupied(mut entry) => { - entry.get_mut().push(listener); - } - Entry::Vacant(entry) => { - trace!(target: "backendhandler", number, "preparing block hash request"); - entry.insert(vec![listener]); - let provider = self.provider.clone(); - let fut = Box::pin(async move { - let block = provider - .get_block_by_number(number.into(), false) - .await - .wrap_err("failed to get block"); - - let block_hash = match block { - Ok(Some(block)) => Ok(block - .header - .hash - .expect("empty block hash on mined block, this should never happen")), - Ok(None) => { - warn!(target: "backendhandler", ?number, "block not found"); - // if no block was returned then the block does not exist, in which case - // we return empty hash - Ok(KECCAK_EMPTY) - } - Err(err) => { - error!(target: "backendhandler", %err, ?number, "failed to get block"); - Err(err) - } - }; - (block_hash, number) - }); - self.pending_requests.push(ProviderRequest::BlockHash(fut)); - } - } - } -} - -impl Future for BackendHandler -where - T: Transport + Clone + Unpin, - P: Provider + Clone + Unpin + 'static, -{ - type Output = (); - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let pin = self.get_mut(); - loop { - // Drain queued requests first. - while let Some(req) = pin.queued_requests.pop_front() { - pin.on_request(req) - } - - // receive new requests to delegate to the underlying provider - loop { - match Pin::new(&mut pin.incoming).poll_next(cx) { - Poll::Ready(Some(req)) => { - pin.queued_requests.push_back(req); - } - Poll::Ready(None) => { - trace!(target: "backendhandler", "last sender dropped, ready to drop (&flush cache)"); - return Poll::Ready(()); - } - Poll::Pending => break, - } - } - - // poll all requests in progress - for n in (0..pin.pending_requests.len()).rev() { - let mut request = pin.pending_requests.swap_remove(n); - match &mut request { - ProviderRequest::Account(fut) => { - if let Poll::Ready((resp, addr)) = fut.poll_unpin(cx) { - // get the response - let (balance, nonce, code) = match resp { - Ok(res) => res, - Err(err) => { - let err = Arc::new(err); - if let Some(listeners) = pin.account_requests.remove(&addr) { - listeners.into_iter().for_each(|l| { - let _ = l.send(Err(DatabaseError::GetAccount( - addr, - Arc::clone(&err), - ))); - }) - } - continue; - } - }; - - // convert it to revm-style types - let (code, code_hash) = if !code.is_empty() { - (code.clone(), keccak256(&code)) - } else { - (Bytes::default(), KECCAK_EMPTY) - }; - - // update the cache - let acc = AccountInfo { - nonce, - balance, - code: Some(Bytecode::new_raw(code)), - code_hash, - }; - pin.db.accounts().write().insert(addr, acc.clone()); - - // notify all listeners - if let Some(listeners) = pin.account_requests.remove(&addr) { - listeners.into_iter().for_each(|l| { - let _ = l.send(Ok(acc.clone())); - }) - } - continue; - } - } - ProviderRequest::Storage(fut) => { - if let Poll::Ready((resp, addr, idx)) = fut.poll_unpin(cx) { - let value = match resp { - Ok(value) => value, - Err(err) => { - // notify all listeners - let err = Arc::new(err); - if let Some(listeners) = - pin.storage_requests.remove(&(addr, idx)) - { - listeners.into_iter().for_each(|l| { - let _ = l.send(Err(DatabaseError::GetStorage( - addr, - idx, - Arc::clone(&err), - ))); - }) - } - continue; - } - }; - - // update the cache - pin.db.storage().write().entry(addr).or_default().insert(idx, value); - - // notify all listeners - if let Some(listeners) = pin.storage_requests.remove(&(addr, idx)) { - listeners.into_iter().for_each(|l| { - let _ = l.send(Ok(value)); - }) - } - continue; - } - } - ProviderRequest::BlockHash(fut) => { - if let Poll::Ready((block_hash, number)) = fut.poll_unpin(cx) { - let value = match block_hash { - Ok(value) => value, - Err(err) => { - let err = Arc::new(err); - // notify all listeners - if let Some(listeners) = pin.block_requests.remove(&number) { - listeners.into_iter().for_each(|l| { - let _ = l.send(Err(DatabaseError::GetBlockHash( - number, - Arc::clone(&err), - ))); - }) - } - continue; - } - }; - - // update the cache - pin.db.block_hashes().write().insert(U256::from(number), value); - - // notify all listeners - if let Some(listeners) = pin.block_requests.remove(&number) { - listeners.into_iter().for_each(|l| { - let _ = l.send(Ok(value)); - }) - } - continue; - } - } - ProviderRequest::FullBlock(fut) => { - if let Poll::Ready((sender, resp, number)) = fut.poll_unpin(cx) { - let msg = match resp { - Ok(Some(block)) => Ok(block), - Ok(None) => Err(DatabaseError::BlockNotFound(number)), - Err(err) => { - let err = Arc::new(err); - Err(DatabaseError::GetFullBlock(number, err)) - } - }; - let _ = sender.send(msg); - continue; - } - } - ProviderRequest::Transaction(fut) => { - if let Poll::Ready((sender, tx, tx_hash)) = fut.poll_unpin(cx) { - let msg = match tx { - Ok(tx) => Ok(tx), - Err(err) => { - let err = Arc::new(err); - Err(DatabaseError::GetTransaction(tx_hash, err)) - } - }; - let _ = sender.send(msg); - continue; - } - } - } - // not ready, insert and poll again - pin.pending_requests.push(request); - } - - // If no new requests have been queued, break to - // be polled again later. - if pin.queued_requests.is_empty() { - return Poll::Pending; - } - } - } -} - -/// A cloneable backend type that shares access to the backend data with all its clones. -/// -/// This backend type is connected to the `BackendHandler` via a mpsc channel. The `BackendHandler` -/// is spawned on a tokio task and listens for incoming commands on the receiver half of the -/// channel. A `SharedBackend` holds a sender for that channel, which is `Clone`, so there can be -/// multiple `SharedBackend`s communicating with the same `BackendHandler`, hence this `Backend` -/// type is thread safe. -/// -/// All `Backend` trait functions are delegated as a `BackendRequest` via the channel to the -/// `BackendHandler`. All `BackendRequest` variants include a sender half of an additional channel -/// that is used by the `BackendHandler` to send the result of an executed `BackendRequest` back to -/// `SharedBackend`. -/// -/// The `BackendHandler` holds a `Provider` to look up missing accounts or storage slots -/// from remote (e.g. infura). It detects duplicate requests from multiple `SharedBackend`s and -/// bundles them together, so that always only one provider request is executed. For example, there -/// are two `SharedBackend`s, `A` and `B`, both request the basic account info of account -/// `0xasd9sa7d...` at the same time. After the `BackendHandler` receives the request from `A`, it -/// sends a new provider request to the provider's endpoint, then it reads the identical request -/// from `B` and simply adds it as an additional listener for the request already in progress, -/// instead of sending another one. So that after the provider returns the response all listeners -/// (`A` and `B`) get notified. -// **Note**: the implementation makes use of [tokio::task::block_in_place()] when interacting with -// the underlying [BackendHandler] which runs on a separate spawned tokio task. -// [tokio::task::block_in_place()] -// > Runs the provided blocking function on the current thread without blocking the executor. -// This prevents issues (hangs) we ran into were the [SharedBackend] itself is called from a spawned -// task. -#[derive(Clone, Debug)] -pub struct SharedBackend { - /// channel used for sending commands related to database operations - backend: Sender, - /// Ensures that the underlying cache gets flushed once the last `SharedBackend` is dropped. - /// - /// There is only one instance of the type, so as soon as the last `SharedBackend` is deleted, - /// `FlushJsonBlockCacheDB` is also deleted and the cache is flushed. - cache: Arc, -} - -impl SharedBackend { - /// _Spawns_ a new `BackendHandler` on a `tokio::task` that listens for requests from any - /// `SharedBackend`. Missing values get inserted in the `db`. - /// - /// The spawned `BackendHandler` finishes once the last `SharedBackend` connected to it is - /// dropped. - /// - /// NOTE: this should be called with `Arc` - pub async fn spawn_backend( - provider: P, - db: BlockchainDb, - pin_block: Option, - ) -> Self - where - T: Transport + Clone + Unpin, - P: Provider + Unpin + 'static + Clone, - { - let (shared, handler) = Self::new(provider, db, pin_block); - // spawn the provider handler to a task - trace!(target: "backendhandler", "spawning Backendhandler task"); - tokio::spawn(handler); - shared - } - - /// Same as `Self::spawn_backend` but spawns the `BackendHandler` on a separate `std::thread` in - /// its own `tokio::Runtime` - pub fn spawn_backend_thread( - provider: P, - db: BlockchainDb, - pin_block: Option, - ) -> Self - where - T: Transport + Clone + Unpin, - P: Provider + Unpin + 'static + Clone, - { - let (shared, handler) = Self::new(provider, db, pin_block); - - // spawn a light-weight thread with a thread-local async runtime just for - // sending and receiving data from the remote client - std::thread::Builder::new() - .name("fork-backend".into()) - .spawn(move || { - let rt = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .expect("failed to build tokio runtime"); - - rt.block_on(handler); - }) - .expect("failed to spawn thread"); - trace!(target: "backendhandler", "spawned Backendhandler thread"); - - shared - } - - /// Returns a new `SharedBackend` and the `BackendHandler` - pub fn new( - provider: P, - db: BlockchainDb, - pin_block: Option, - ) -> (Self, BackendHandler) - where - T: Transport + Clone + Unpin, - P: Provider + Unpin + 'static + Clone, - { - let (backend, backend_rx) = channel(1); - let cache = Arc::new(FlushJsonBlockCacheDB(Arc::clone(db.cache()))); - let handler = BackendHandler::new(provider, db, backend_rx, pin_block); - (Self { backend, cache }, handler) - } - - /// Updates the pinned block to fetch data from - pub fn set_pinned_block(&self, block: impl Into) -> eyre::Result<()> { - let req = BackendRequest::SetPinnedBlock(block.into()); - self.backend.clone().try_send(req).map_err(|e| eyre::eyre!("{:?}", e)) - } - - /// Returns the full block for the given block identifier - pub fn get_full_block(&self, block: impl Into) -> DatabaseResult { - tokio::task::block_in_place(|| { - let (sender, rx) = oneshot_channel(); - let req = BackendRequest::FullBlock(block.into(), sender); - self.backend.clone().try_send(req)?; - rx.recv()? - }) - } - - /// Returns the transaction for the hash - pub fn get_transaction(&self, tx: B256) -> DatabaseResult> { - tokio::task::block_in_place(|| { - let (sender, rx) = oneshot_channel(); - let req = BackendRequest::Transaction(tx, sender); - self.backend.clone().try_send(req)?; - rx.recv()? - }) - } - - fn do_get_basic(&self, address: Address) -> DatabaseResult> { - tokio::task::block_in_place(|| { - let (sender, rx) = oneshot_channel(); - let req = BackendRequest::Basic(address, sender); - self.backend.clone().try_send(req)?; - rx.recv()?.map(Some) - }) - } - - fn do_get_storage(&self, address: Address, index: U256) -> DatabaseResult { - tokio::task::block_in_place(|| { - let (sender, rx) = oneshot_channel(); - let req = BackendRequest::Storage(address, index, sender); - self.backend.clone().try_send(req)?; - rx.recv()? - }) - } - - fn do_get_block_hash(&self, number: u64) -> DatabaseResult { - tokio::task::block_in_place(|| { - let (sender, rx) = oneshot_channel(); - let req = BackendRequest::BlockHash(number, sender); - self.backend.clone().try_send(req)?; - rx.recv()? - }) - } - - /// Flushes the DB to disk if caching is enabled - pub(crate) fn flush_cache(&self) { - self.cache.0.flush(); - } -} - -impl DatabaseRef for SharedBackend { - type Error = DatabaseError; - - fn basic_ref(&self, address: Address) -> Result, Self::Error> { - trace!(target: "sharedbackend", %address, "request basic"); - self.do_get_basic(address).map_err(|err| { - error!(target: "sharedbackend", %err, %address, "Failed to send/recv `basic`"); - if err.is_possibly_non_archive_node_error() { - error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); - } - err - }) - } - - fn code_by_hash_ref(&self, hash: B256) -> Result { - Err(DatabaseError::MissingCode(hash)) - } - - fn storage_ref(&self, address: Address, index: U256) -> Result { - trace!(target: "sharedbackend", "request storage {:?} at {:?}", address, index); - self.do_get_storage(address, index).map_err(|err| { - error!(target: "sharedbackend", %err, %address, %index, "Failed to send/recv `storage`"); - if err.is_possibly_non_archive_node_error() { - error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); - } - err - }) - } - - fn block_hash_ref(&self, number: U256) -> Result { - if number > U256::from(u64::MAX) { - return Ok(KECCAK_EMPTY); - } - let number: U256 = number; - let number = number.to(); - trace!(target: "sharedbackend", "request block hash for number {:?}", number); - self.do_get_block_hash(number).map_err(|err| { - error!(target: "sharedbackend", %err, %number, "Failed to send/recv `block_hash`"); - if err.is_possibly_non_archive_node_error() { - error!(target: "sharedbackend", "{NON_ARCHIVE_NODE_WARNING}"); - } - err - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - backend::Backend, - fork::{BlockchainDbMeta, CreateFork, JsonBlockCacheDB}, - opts::EvmOpts, - }; - use foundry_common::provider::get_http_provider; - use foundry_config::{Config, NamedChain}; - use std::{collections::BTreeSet, path::PathBuf}; - - const ENDPOINT: Option<&str> = option_env!("ETH_RPC_URL"); - - #[tokio::test(flavor = "multi_thread")] - async fn shared_backend() { - let Some(endpoint) = ENDPOINT else { return }; - - let provider = get_http_provider(endpoint); - let meta = BlockchainDbMeta { - cfg_env: Default::default(), - block_env: Default::default(), - hosts: BTreeSet::from([endpoint.to_string()]), - }; - - let db = BlockchainDb::new(meta, None); - let backend = SharedBackend::spawn_backend(Arc::new(provider), db.clone(), None).await; - - // some rng contract from etherscan - let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); - - let idx = U256::from(0u64); - let value = backend.storage_ref(address, idx).unwrap(); - let account = backend.basic_ref(address).unwrap().unwrap(); - - let mem_acc = db.accounts().read().get(&address).unwrap().clone(); - assert_eq!(account.balance, mem_acc.balance); - assert_eq!(account.nonce, mem_acc.nonce); - let slots = db.storage().read().get(&address).unwrap().clone(); - assert_eq!(slots.len(), 1); - assert_eq!(slots.get(&idx).copied().unwrap(), value); - - let num = U256::from(10u64); - let hash = backend.block_hash_ref(num).unwrap(); - let mem_hash = *db.block_hashes().read().get(&num).unwrap(); - assert_eq!(hash, mem_hash); - - let max_slots = 5; - let handle = std::thread::spawn(move || { - for i in 1..max_slots { - let idx = U256::from(i); - let _ = backend.storage_ref(address, idx); - } - }); - handle.join().unwrap(); - let slots = db.storage().read().get(&address).unwrap().clone(); - assert_eq!(slots.len() as u64, max_slots); - } - - #[test] - fn can_read_cache() { - let cache_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/storage.json"); - let json = JsonBlockCacheDB::load(cache_path).unwrap(); - assert!(!json.db().accounts.read().is_empty()); - } - - #[tokio::test(flavor = "multi_thread")] - async fn can_read_write_cache() { - let Some(endpoint) = ENDPOINT else { return }; - - let provider = get_http_provider(endpoint); - - let block_num = provider.get_block_number().await.unwrap(); - - let config = Config::figment(); - let mut evm_opts = config.extract::().unwrap(); - evm_opts.fork_block_number = Some(block_num); - - let (env, _block) = evm_opts.fork_evm_env(endpoint).await.unwrap(); - - let fork = CreateFork { - enable_caching: true, - url: endpoint.to_string(), - env: env.clone(), - evm_opts, - }; - - let backend = Backend::spawn(Some(fork)); - - // some rng contract from etherscan - let address: Address = "63091244180ae240c87d1f528f5f269134cb07b3".parse().unwrap(); - - let idx = U256::from(0u64); - let _value = backend.storage_ref(address, idx); - let _account = backend.basic_ref(address); - - // fill some slots - let num_slots = 10u64; - for idx in 1..num_slots { - let _ = backend.storage_ref(address, U256::from(idx)); - } - drop(backend); - - let meta = - BlockchainDbMeta { cfg_env: env.cfg, block_env: env.block, hosts: Default::default() }; - - let db = BlockchainDb::new( - meta, - Some(Config::foundry_block_cache_dir(NamedChain::Mainnet, block_num).unwrap()), - ); - assert!(db.accounts().read().contains_key(&address)); - assert!(db.storage().read().contains_key(&address)); - assert_eq!(db.storage().read().get(&address).unwrap().len(), num_slots as usize); - } -} diff --git a/crates/evm/core/src/fork/cache.rs b/crates/evm/core/src/fork/cache.rs deleted file mode 100644 index 9aea935858203..0000000000000 --- a/crates/evm/core/src/fork/cache.rs +++ /dev/null @@ -1,620 +0,0 @@ -//! Cache related abstraction -use crate::backend::StateSnapshot; -use alloy_primitives::{Address, B256, U256}; -use parking_lot::RwLock; -use revm::{ - primitives::{Account, AccountInfo, AccountStatus, HashMap as Map, KECCAK_EMPTY}, - DatabaseCommit, -}; -use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; -use std::{ - collections::BTreeSet, - fs, - io::{BufWriter, Write}, - path::PathBuf, - sync::Arc, -}; -use url::Url; - -pub type StorageInfo = Map; - -/// A shareable Block database -#[derive(Clone, Debug)] -pub struct BlockchainDb { - /// Contains all the data - db: Arc, - /// metadata of the current config - meta: Arc>, - /// the cache that can be flushed - cache: Arc, -} - -impl BlockchainDb { - /// Creates a new instance of the [BlockchainDb]. - /// - /// If a `cache_path` is provided it attempts to load a previously stored [JsonBlockCacheData] - /// and will try to use the cached entries it holds. - /// - /// This will return a new and empty [MemDb] if - /// - `cache_path` is `None` - /// - the file the `cache_path` points to, does not exist - /// - the file contains malformed data, or if it couldn't be read - /// - the provided `meta` differs from [BlockchainDbMeta] that's stored on disk - pub fn new(meta: BlockchainDbMeta, cache_path: Option) -> Self { - Self::new_db(meta, cache_path, false) - } - - /// Creates a new instance of the [BlockchainDb] and skips check when comparing meta - /// This is useful for offline-start mode when we don't want to fetch metadata of `block`. - /// - /// if a `cache_path` is provided it attempts to load a previously stored [JsonBlockCacheData] - /// and will try to use the cached entries it holds. - /// - /// This will return a new and empty [MemDb] if - /// - `cache_path` is `None` - /// - the file the `cache_path` points to, does not exist - /// - the file contains malformed data, or if it couldn't be read - /// - the provided `meta` differs from [BlockchainDbMeta] that's stored on disk - pub fn new_skip_check(meta: BlockchainDbMeta, cache_path: Option) -> Self { - Self::new_db(meta, cache_path, true) - } - - fn new_db(meta: BlockchainDbMeta, cache_path: Option, skip_check: bool) -> Self { - trace!(target: "forge::cache", cache=?cache_path, "initialising blockchain db"); - // read cache and check if metadata matches - let cache = cache_path - .as_ref() - .and_then(|p| { - JsonBlockCacheDB::load(p).ok().filter(|cache| { - if skip_check { - return true - } - let mut existing = cache.meta().write(); - existing.hosts.extend(meta.hosts.clone()); - if meta != *existing { - warn!(target: "cache", "non-matching block metadata"); - false - } else { - true - } - }) - }) - .unwrap_or_else(|| JsonBlockCacheDB::new(Arc::new(RwLock::new(meta)), cache_path)); - - Self { db: Arc::clone(cache.db()), meta: Arc::clone(cache.meta()), cache: Arc::new(cache) } - } - - /// Returns the map that holds the account related info - pub fn accounts(&self) -> &RwLock> { - &self.db.accounts - } - - /// Returns the map that holds the storage related info - pub fn storage(&self) -> &RwLock> { - &self.db.storage - } - - /// Returns the map that holds all the block hashes - pub fn block_hashes(&self) -> &RwLock> { - &self.db.block_hashes - } - - /// Returns the Env related metadata - pub fn meta(&self) -> &Arc> { - &self.meta - } - - /// Returns the inner cache - pub fn cache(&self) -> &Arc { - &self.cache - } - - /// Returns the underlying storage - pub fn db(&self) -> &Arc { - &self.db - } -} - -/// relevant identifying markers in the context of [BlockchainDb] -#[derive(Clone, Debug, Eq, Serialize)] -pub struct BlockchainDbMeta { - pub cfg_env: revm::primitives::CfgEnv, - pub block_env: revm::primitives::BlockEnv, - /// all the hosts used to connect to - pub hosts: BTreeSet, -} - -impl BlockchainDbMeta { - /// Creates a new instance - pub fn new(env: revm::primitives::Env, url: String) -> Self { - let host = Url::parse(&url) - .ok() - .and_then(|url| url.host().map(|host| host.to_string())) - .unwrap_or(url); - - Self { cfg_env: env.cfg.clone(), block_env: env.block, hosts: BTreeSet::from([host]) } - } -} - -// ignore hosts to not invalidate the cache when different endpoints are used, as it's commonly the -// case for http vs ws endpoints -impl PartialEq for BlockchainDbMeta { - fn eq(&self, other: &Self) -> bool { - self.cfg_env == other.cfg_env && self.block_env == other.block_env - } -} - -impl<'de> Deserialize<'de> for BlockchainDbMeta { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - /// A backwards compatible representation of [revm::primitives::CfgEnv] - /// - /// This prevents deserialization errors of cache files caused by breaking changes to the - /// default [revm::primitives::CfgEnv], for example enabling an optional feature. - /// By hand rolling deserialize impl we can prevent cache file issues - struct CfgEnvBackwardsCompat { - inner: revm::primitives::CfgEnv, - } - - impl<'de> Deserialize<'de> for CfgEnvBackwardsCompat { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let mut value = serde_json::Value::deserialize(deserializer)?; - - // we check for breaking changes here - if let Some(obj) = value.as_object_mut() { - let default_value = - serde_json::to_value(revm::primitives::CfgEnv::default()).unwrap(); - for (key, value) in default_value.as_object().unwrap() { - if !obj.contains_key(key) { - obj.insert(key.to_string(), value.clone()); - } - } - } - - let cfg_env: revm::primitives::CfgEnv = - serde_json::from_value(value).map_err(serde::de::Error::custom)?; - Ok(Self { inner: cfg_env }) - } - } - - /// A backwards compatible representation of [revm::primitives::BlockEnv] - /// - /// This prevents deserialization errors of cache files caused by breaking changes to the - /// default [revm::primitives::BlockEnv], for example enabling an optional feature. - /// By hand rolling deserialize impl we can prevent cache file issues - struct BlockEnvBackwardsCompat { - inner: revm::primitives::BlockEnv, - } - - impl<'de> Deserialize<'de> for BlockEnvBackwardsCompat { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let mut value = serde_json::Value::deserialize(deserializer)?; - - // we check for any missing fields here - if let Some(obj) = value.as_object_mut() { - let default_value = - serde_json::to_value(revm::primitives::BlockEnv::default()).unwrap(); - for (key, value) in default_value.as_object().unwrap() { - if !obj.contains_key(key) { - obj.insert(key.to_string(), value.clone()); - } - } - } - - let cfg_env: revm::primitives::BlockEnv = - serde_json::from_value(value).map_err(serde::de::Error::custom)?; - Ok(Self { inner: cfg_env }) - } - } - - // custom deserialize impl to not break existing cache files - #[derive(Deserialize)] - struct Meta { - cfg_env: CfgEnvBackwardsCompat, - block_env: BlockEnvBackwardsCompat, - /// all the hosts used to connect to - #[serde(alias = "host")] - hosts: Hosts, - } - - #[derive(Deserialize)] - #[serde(untagged)] - enum Hosts { - Multi(BTreeSet), - Single(String), - } - - let Meta { cfg_env, block_env, hosts } = Meta::deserialize(deserializer)?; - Ok(Self { - cfg_env: cfg_env.inner, - block_env: block_env.inner, - hosts: match hosts { - Hosts::Multi(hosts) => hosts, - Hosts::Single(host) => BTreeSet::from([host]), - }, - }) - } -} - -/// In Memory cache containing all fetched accounts and storage slots -/// and their values from RPC -#[derive(Debug, Default)] -pub struct MemDb { - /// Account related data - pub accounts: RwLock>, - /// Storage related data - pub storage: RwLock>, - /// All retrieved block hashes - pub block_hashes: RwLock>, -} - -impl MemDb { - /// Clears all data stored in this db - pub fn clear(&self) { - self.accounts.write().clear(); - self.storage.write().clear(); - self.block_hashes.write().clear(); - } - - // Inserts the account, replacing it if it exists already - pub fn do_insert_account(&self, address: Address, account: AccountInfo) { - self.accounts.write().insert(address, account); - } - - /// The implementation of [DatabaseCommit::commit()] - pub fn do_commit(&self, changes: Map) { - let mut storage = self.storage.write(); - let mut accounts = self.accounts.write(); - for (add, mut acc) in changes { - if acc.is_empty() || acc.is_selfdestructed() { - accounts.remove(&add); - storage.remove(&add); - } else { - // insert account - if let Some(code_hash) = acc - .info - .code - .as_ref() - .filter(|code| !code.is_empty()) - .map(|code| code.hash_slow()) - { - acc.info.code_hash = code_hash; - } else if acc.info.code_hash.is_zero() { - acc.info.code_hash = KECCAK_EMPTY; - } - accounts.insert(add, acc.info); - - let acc_storage = storage.entry(add).or_default(); - if acc.status.contains(AccountStatus::Created) { - acc_storage.clear(); - } - for (index, value) in acc.storage { - if value.present_value().is_zero() { - acc_storage.remove(&index); - } else { - acc_storage.insert(index, value.present_value()); - } - } - if acc_storage.is_empty() { - storage.remove(&add); - } - } - } - } -} - -impl Clone for MemDb { - fn clone(&self) -> Self { - Self { - storage: RwLock::new(self.storage.read().clone()), - accounts: RwLock::new(self.accounts.read().clone()), - block_hashes: RwLock::new(self.block_hashes.read().clone()), - } - } -} - -impl DatabaseCommit for MemDb { - fn commit(&mut self, changes: Map) { - self.do_commit(changes) - } -} - -/// A DB that stores the cached content in a json file -#[derive(Debug)] -pub struct JsonBlockCacheDB { - /// Where this cache file is stored. - /// - /// If this is a [None] then caching is disabled - cache_path: Option, - /// Object that's stored in a json file - data: JsonBlockCacheData, -} - -impl JsonBlockCacheDB { - /// Creates a new instance. - fn new(meta: Arc>, cache_path: Option) -> Self { - Self { cache_path, data: JsonBlockCacheData { meta, data: Arc::new(Default::default()) } } - } - - /// Loads the contents of the diskmap file and returns the read object - /// - /// # Errors - /// This will fail if - /// - the `path` does not exist - /// - the format does not match [JsonBlockCacheData] - pub fn load(path: impl Into) -> eyre::Result { - let path = path.into(); - trace!(target: "cache", ?path, "reading json cache"); - let contents = std::fs::read_to_string(&path).map_err(|err| { - warn!(?err, ?path, "Failed to read cache file"); - err - })?; - let data = serde_json::from_str(&contents).map_err(|err| { - warn!(target: "cache", ?err, ?path, "Failed to deserialize cache data"); - err - })?; - Ok(Self { cache_path: Some(path), data }) - } - - /// Returns the [MemDb] it holds access to - pub fn db(&self) -> &Arc { - &self.data.data - } - - /// Metadata stored alongside the data - pub fn meta(&self) -> &Arc> { - &self.data.meta - } - - /// Returns `true` if this is a transient cache and nothing will be flushed - pub fn is_transient(&self) -> bool { - self.cache_path.is_none() - } - - /// Flushes the DB to disk if caching is enabled. - #[instrument(level = "warn", skip_all, fields(path = ?self.cache_path))] - pub fn flush(&self) { - let Some(path) = &self.cache_path else { return }; - trace!(target: "cache", "saving json cache"); - - if let Some(parent) = path.parent() { - let _ = fs::create_dir_all(parent); - } - - let file = match fs::File::create(path) { - Ok(file) => file, - Err(e) => return warn!(target: "cache", %e, "Failed to open json cache for writing"), - }; - - let mut writer = BufWriter::new(file); - if let Err(e) = serde_json::to_writer(&mut writer, &self.data) { - return warn!(target: "cache", %e, "Failed to write to json cache") - } - if let Err(e) = writer.flush() { - return warn!(target: "cache", %e, "Failed to flush to json cache") - } - - trace!(target: "cache", "saved json cache"); - } -} - -/// The Data the [JsonBlockCacheDB] can read and flush -/// -/// This will be deserialized in a JSON object with the keys: -/// `["meta", "accounts", "storage", "block_hashes"]` -#[derive(Debug)] -pub struct JsonBlockCacheData { - pub meta: Arc>, - pub data: Arc, -} - -impl Serialize for JsonBlockCacheData { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut map = serializer.serialize_map(Some(4))?; - - map.serialize_entry("meta", &*self.meta.read())?; - map.serialize_entry("accounts", &*self.data.accounts.read())?; - map.serialize_entry("storage", &*self.data.storage.read())?; - map.serialize_entry("block_hashes", &*self.data.block_hashes.read())?; - - map.end() - } -} - -impl<'de> Deserialize<'de> for JsonBlockCacheData { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - #[derive(Deserialize)] - struct Data { - meta: BlockchainDbMeta, - #[serde(flatten)] - data: StateSnapshot, - } - - let Data { meta, data: StateSnapshot { accounts, storage, block_hashes } } = - Data::deserialize(deserializer)?; - - Ok(Self { - meta: Arc::new(RwLock::new(meta)), - data: Arc::new(MemDb { - accounts: RwLock::new(accounts), - storage: RwLock::new(storage), - block_hashes: RwLock::new(block_hashes), - }), - }) - } -} - -/// A type that flushes a `JsonBlockCacheDB` on drop -/// -/// This type intentionally does not implement `Clone` since it's intended that there's only once -/// instance that will flush the cache. -#[derive(Debug)] -pub struct FlushJsonBlockCacheDB(pub Arc); - -impl Drop for FlushJsonBlockCacheDB { - fn drop(&mut self) { - trace!(target: "fork::cache", "flushing cache"); - self.0.flush(); - trace!(target: "fork::cache", "flushed cache"); - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_deserialize_cache() { - let s = r#"{ - "meta": { - "cfg_env": { - "chain_id": 1337, - "perf_analyse_created_bytecodes": "Analyse", - "limit_contract_code_size": 18446744073709551615, - "memory_limit": 4294967295, - "disable_block_gas_limit": false, - "disable_eip3607": false, - "disable_base_fee": false - }, - "block_env": { - "number": "0xed3ddf", - "coinbase": "0x0000000000000000000000000000000000000000", - "timestamp": "0x6324bc3f", - "difficulty": "0x0", - "basefee": "0x2e5fda223", - "gas_limit": "0x1c9c380", - "prevrandao": "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - "hosts": [ - "eth-mainnet.alchemyapi.io" - ] - }, - "accounts": { - "0xb8ffc3cd6e7cf5a098a1c92f48009765b24088dc": { - "balance": "0x0", - "nonce": 10, - "code_hash": "0x3ac64c95eedf82e5d821696a12daac0e1b22c8ee18a9fd688b00cfaf14550aad", - "code": { - "LegacyAnalyzed": { - "bytecode": "0x00", - "original_len": 0, - "jump_table": { - "order": "bitvec::order::Lsb0", - "head": { - "width": 8, - "index": 0 - }, - "bits": 1, - "data": [0] - } - } - } - } - }, - "storage": { - "0xa354f35829ae975e850e23e9615b11da1b3dc4de": { - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e564": "0x5553444320795661756c74000000000000000000000000000000000000000000", - "0x10": "0x37fd60ff8346", - "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563": "0xb", - "0x6": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", - "0x5": "0x36ff5b93162e", - "0x14": "0x29d635a8e000", - "0x11": "0x63224c73", - "0x2": "0x6" - } - }, - "block_hashes": { - "0xed3deb": "0xbf7be3174b261ea3c377b6aba4a1e05d5fae7eee7aab5691087c20cf353e9877", - "0xed3de9": "0xba1c3648e0aee193e7d00dffe4e9a5e420016b4880455641085a4731c1d32eef", - "0xed3de8": "0x61d1491c03a9295fb13395cca18b17b4fa5c64c6b8e56ee9cc0a70c3f6cf9855", - "0xed3de7": "0xb54560b5baeccd18350d56a3bee4035432294dc9d2b7e02f157813e1dee3a0be", - "0xed3dea": "0x816f124480b9661e1631c6ec9ee39350bda79f0cbfc911f925838d88e3d02e4b" - } -}"#; - - let cache: JsonBlockCacheData = serde_json::from_str(s).unwrap(); - assert_eq!(cache.data.accounts.read().len(), 1); - assert_eq!(cache.data.storage.read().len(), 1); - assert_eq!(cache.data.block_hashes.read().len(), 5); - - let _s = serde_json::to_string(&cache).unwrap(); - } - - #[test] - fn can_deserialize_cache_post_4844() { - let s = r#"{ - "meta": { - "cfg_env": { - "chain_id": 1, - "kzg_settings": "Default", - "perf_analyse_created_bytecodes": "Analyse", - "limit_contract_code_size": 18446744073709551615, - "memory_limit": 134217728, - "disable_block_gas_limit": false, - "disable_eip3607": true, - "disable_base_fee": false, - "optimism": false - }, - "block_env": { - "number": "0x11c99bc", - "coinbase": "0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97", - "timestamp": "0x65627003", - "gas_limit": "0x1c9c380", - "basefee": "0x64288ff1f", - "difficulty": "0xc6b1a299886016dea3865689f8393b9bf4d8f4fe8c0ad25f0058b3569297c057", - "prevrandao": "0xc6b1a299886016dea3865689f8393b9bf4d8f4fe8c0ad25f0058b3569297c057", - "blob_excess_gas_and_price": { - "excess_blob_gas": 0, - "blob_gasprice": 1 - } - }, - "hosts": [ - "eth-mainnet.alchemyapi.io" - ] - }, - "accounts": { - "0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97": { - "balance": "0x8e0c373cfcdfd0eb", - "nonce": 128912, - "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", - "code": { - "LegacyAnalyzed": { - "bytecode": "0x00", - "original_len": 0, - "jump_table": { - "order": "bitvec::order::Lsb0", - "head": { - "width": 8, - "index": 0 - }, - "bits": 1, - "data": [0] - } - } - } - } - }, - "storage": {}, - "block_hashes": {} -}"#; - - let cache: JsonBlockCacheData = serde_json::from_str(s).unwrap(); - assert_eq!(cache.data.accounts.read().len(), 1); - - let _s = serde_json::to_string(&cache).unwrap(); - } -} diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 2712b57798c1a..590f6717e09a3 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -1,12 +1,12 @@ //! A revm database that forks off a remote client use crate::{ - backend::{DatabaseError, RevertSnapshotAction, StateSnapshot}, - fork::{BlockchainDb, SharedBackend}, + backend::{RevertSnapshotAction, StateSnapshot}, snapshot::Snapshots, }; use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types::BlockId; +use foundry_fork_db::{BlockchainDb, DatabaseError, SharedBackend}; use parking_lot::Mutex; use revm::{ db::{CacheDB, DatabaseRef}, @@ -264,7 +264,7 @@ impl DatabaseRef for ForkDbSnapshot { #[cfg(test)] mod tests { use super::*; - use crate::fork::BlockchainDbMeta; + use crate::backend::BlockchainDbMeta; use foundry_common::provider::get_http_provider; use std::collections::BTreeSet; diff --git a/crates/evm/core/src/fork/mod.rs b/crates/evm/core/src/fork/mod.rs index a6387b0bb0608..9401c2d32ed58 100644 --- a/crates/evm/core/src/fork/mod.rs +++ b/crates/evm/core/src/fork/mod.rs @@ -1,18 +1,9 @@ use super::opts::EvmOpts; use revm::primitives::Env; -mod backend; -pub use backend::{BackendHandler, SharedBackend}; - mod init; pub use init::environment; -mod cache; -pub use cache::{ - BlockchainDb, BlockchainDbMeta, FlushJsonBlockCacheDB, JsonBlockCacheDB, JsonBlockCacheData, - MemDb, StorageInfo, -}; - pub mod database; mod multi; diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 8b18e2d7fe0c5..8840a89f800df 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -3,11 +3,12 @@ //! The design is similar to the single `SharedBackend`, `BackendHandler` but supports multiple //! concurrently active pairs at once. -use crate::fork::{BackendHandler, BlockchainDb, BlockchainDbMeta, CreateFork, SharedBackend}; +use super::CreateFork; use foundry_common::provider::{ runtime_transport::RuntimeTransport, tower::RetryBackoffService, ProviderBuilder, RetryProvider, }; use foundry_config::Config; +use foundry_fork_db::{cache::BlockchainDbMeta, BackendHandler, BlockchainDb, SharedBackend}; use futures::{ channel::mpsc::{channel, Receiver, Sender}, stream::{Fuse, Stream}, diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 17d8727e8bbc0..32403dceb51f8 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -14,7 +14,7 @@ use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, Log, U256}; use alloy_sol_types::{sol, SolCall}; use foundry_evm_core::{ - backend::{Backend, CowBackend, DatabaseError, DatabaseExt, DatabaseResult, GLOBAL_FAIL_SLOT}, + backend::{Backend, BackendError, BackendResult, CowBackend, DatabaseExt, GLOBAL_FAIL_SLOT}, constants::{ CALLER, CHEATCODE_ADDRESS, CHEATCODE_CONTRACT_HASH, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, DEFAULT_CREATE2_DEPLOYER_DEPLOYER, @@ -162,7 +162,7 @@ impl Executor { let create2_deployer_account = self .backend() .basic_ref(DEFAULT_CREATE2_DEPLOYER)? - .ok_or_else(|| DatabaseError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; + .ok_or_else(|| BackendError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; // If the deployer is not currently deployed, deploy the default one. if create2_deployer_account.code.map_or(true, |code| code.is_empty()) { @@ -182,7 +182,7 @@ impl Executor { } /// Set the balance of an account. - pub fn set_balance(&mut self, address: Address, amount: U256) -> DatabaseResult<()> { + pub fn set_balance(&mut self, address: Address, amount: U256) -> BackendResult<()> { trace!(?address, ?amount, "setting account balance"); let mut account = self.backend().basic_ref(address)?.unwrap_or_default(); account.balance = amount; @@ -191,12 +191,12 @@ impl Executor { } /// Gets the balance of an account - pub fn get_balance(&self, address: Address) -> DatabaseResult { + pub fn get_balance(&self, address: Address) -> BackendResult { Ok(self.backend().basic_ref(address)?.map(|acc| acc.balance).unwrap_or_default()) } /// Set the nonce of an account. - pub fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()> { + pub fn set_nonce(&mut self, address: Address, nonce: u64) -> BackendResult<()> { let mut account = self.backend().basic_ref(address)?.unwrap_or_default(); account.nonce = nonce; self.backend_mut().insert_account_info(address, account); @@ -204,12 +204,12 @@ impl Executor { } /// Returns the nonce of an account. - pub fn get_nonce(&self, address: Address) -> DatabaseResult { + pub fn get_nonce(&self, address: Address) -> BackendResult { Ok(self.backend().basic_ref(address)?.map(|acc| acc.nonce).unwrap_or_default()) } /// Returns `true` if the account has no code. - pub fn is_empty_code(&self, address: Address) -> DatabaseResult { + pub fn is_empty_code(&self, address: Address) -> BackendResult { Ok(self.backend().basic_ref(address)?.map(|acc| acc.is_empty_code_hash()).unwrap_or(true)) } diff --git a/deny.toml b/deny.toml index fa335ee73a584..da6c5b4689908 100644 --- a/deny.toml +++ b/deny.toml @@ -61,6 +61,8 @@ exceptions = [ { allow = ["CC0-1.0"], name = "dunce" }, { allow = ["CC0-1.0"], name = "aurora-engine-modexp" }, { allow = ["CC0-1.0"], name = "constant_time_eq" }, + { allow = ["CC0-1.0"], name = "secp256k1" }, + { allow = ["CC0-1.0"], name = "secp256k1-sys" }, ] #copyleft = "deny" From 7226aa06bbb473bfa7fabc0c92215c0938017d0c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 2 Jul 2024 19:49:37 +0300 Subject: [PATCH 1200/1963] feat: better dropped tx check (#8335) * feat: better dropped tx check * review fixes --- crates/script/src/receipts.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 4cf718f8b5ab7..c0fbd56119db0 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -38,13 +38,24 @@ pub async fn check_tx_status( return Ok(receipt.into()); } - // If the tx is present in the mempool, run the pending tx future, and - // assume the next drop is really really real - Ok(PendingTransactionBuilder::new(provider, hash) - .with_timeout(Some(Duration::from_secs(180))) - .get_receipt() - .await - .map_or(TxStatus::Dropped, |r| r.into())) + loop { + if let Ok(receipt) = PendingTransactionBuilder::new(provider, hash) + .with_timeout(Some(Duration::from_secs(120))) + .get_receipt() + .await + { + return Ok(receipt.into()) + } + + if provider.get_transaction_by_hash(hash).await?.is_some() { + trace!("tx is still known to the node, waiting for receipt"); + } else { + trace!("eth_getTransactionByHash returned null, assuming dropped"); + break + } + } + + Ok(TxStatus::Dropped) } .await; From 8dd7ad2b22a8d7aca13f2e9d73c121a41da28baf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 08:06:45 +0200 Subject: [PATCH 1201/1963] chore(tests): bump forge-std version (#8336) --- testdata/forge-std-rev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/forge-std-rev b/testdata/forge-std-rev index 919eb58dc2627..9b2bd83b3f144 100644 --- a/testdata/forge-std-rev +++ b/testdata/forge-std-rev @@ -1 +1 @@ -8948d45d3d9022c508b83eb5d26fd3a7a93f2f32 \ No newline at end of file +07263d193d621c4b2b0ce8b4d54af58f6957d97d \ No newline at end of file From b1345a2097c104aa1c4f39dbddf54b13a642e7b0 Mon Sep 17 00:00:00 2001 From: James Kim Date: Wed, 3 Jul 2024 10:39:18 -0400 Subject: [PATCH 1202/1963] fix(anvil): anvil_setLoggingEnabled should correctly enabled / disable logging (#8327) * fix anvil_setLoggingEnabled * fix fmt issues --- crates/anvil/src/logging.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/anvil/src/logging.rs b/crates/anvil/src/logging.rs index 098cf62a8b473..e738254cbbec5 100644 --- a/crates/anvil/src/logging.rs +++ b/crates/anvil/src/logging.rs @@ -33,11 +33,9 @@ where S: tracing::Subscriber, { fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { - if self.state.is_enabled() && - (metadata.target() == NODE_USER_LOG_TARGET || - metadata.target() == EVM_CONSOLE_LOG_TARGET) + if metadata.target() == NODE_USER_LOG_TARGET || metadata.target() == EVM_CONSOLE_LOG_TARGET { - Interest::always() + Interest::sometimes() } else { Interest::never() } From 0dceb536da7129c8e58b2c30c7059e247467838f Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Wed, 3 Jul 2024 09:33:46 -0700 Subject: [PATCH 1203/1963] Soldeer release v0.2.17 (#8344) * Soldeer release v0.2.17 * solved failing test --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/forge/tests/cli/soldeer.rs | 13 +++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff3c4969a3e63..64a30260d834b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7974,9 +7974,9 @@ dependencies = [ [[package]] name = "soldeer" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75abb7ac158a52b280cb6bc3019ab5786cc6a07cf85d71c9b952c649e33a55f6" +checksum = "ef46372c17d5650cb18b7f374c45732334fa0867de6c7f14c1fc6973559cd3ff" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 8d13a7859163b..5c3ae60d585bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,4 +260,4 @@ reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" # soldeer -soldeer = "0.2.16" +soldeer = "0.2.17" diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index 7ac57a0742cec..cf1e0e5d34aa3 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -36,15 +36,12 @@ checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" assert_eq!(lock_contents, actual_lock_contents); // Making sure the foundry contents are the right ones - let foundry_contents = r#" -# Full reference https://github.com/foundry-rs/foundry/tree/master/crates/config - -[profile.default] -script = "script" -solc = "0.8.26" + let foundry_contents = r#"[profile.default] src = "src" -test = "test" -libs = ["dependencies"] +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options [dependencies] forge-std = "1.8.1" From 278e16cb3d5e036c30a6b1c089d6c27df23f3462 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 4 Jul 2024 07:29:52 +0300 Subject: [PATCH 1204/1963] feat(forge): option to replay last test run failures only (#8338) * feat(forge): option to replay last test run failures * Changes after review: rename option to --rerun Small change in the way test match is extracted --- crates/config/src/lib.rs | 6 +++ crates/forge/bin/cmd/test/mod.rs | 50 ++++++++++++++++--- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/test_cmd.rs | 41 +++++++++++++++ .../fixtures/replay_last_run_failures.stdout | 15 ++++++ 5 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 crates/forge/tests/fixtures/replay_last_run_failures.stdout diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 3efdc44cf9327..d6ec26b924014 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -255,6 +255,8 @@ pub struct Config { /// Only show coverage for files that do not match the specified regex pattern. #[serde(rename = "no_match_coverage")] pub coverage_pattern_inverse: Option, + /// Path where last test run failures are recorded. + pub test_failures_file: PathBuf, /// Configuration for fuzz testing pub fuzz: FuzzConfig, /// Configuration for invariant testing @@ -836,6 +838,9 @@ impl Config { pub fn cleanup(&self, project: &Project) -> Result<(), SolcError> { project.cleanup()?; + // Remove last test run failures file. + let _ = fs::remove_file(&self.test_failures_file); + // Remove fuzz and invariant cache directories. let remove_test_dir = |test_dir: &Option| { if let Some(test_dir) = test_dir { @@ -2077,6 +2082,7 @@ impl Default for Config { path_pattern: None, path_pattern_inverse: None, coverage_pattern_inverse: None, + test_failures_file: "cache/test-failures".into(), fuzz: FuzzConfig::new("cache/fuzz".into()), invariant: InvariantConfig::new("cache/invariant".into()), always_use_create_2_factory: false, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 4fd667e27836e..fe709e028074c 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -17,7 +17,7 @@ use foundry_cli::{ use foundry_common::{ compile::{ContractSources, ProjectCompiler}, evm::EvmArgs, - shell, + fs, shell, }; use foundry_compilers::{ artifacts::output_selection::OutputSelection, @@ -116,9 +116,18 @@ pub struct TestArgs { #[arg(long)] pub max_threads: Option, + /// Show test execution progress. + #[arg(long)] + pub show_progress: bool, + #[command(flatten)] filter: FilterArgs, + /// Re-run recorded test failures from last run. + /// If no failure recorded then regular test run is performed. + #[arg(long)] + pub rerun: bool, + #[command(flatten)] evm_opts: EvmArgs, @@ -135,10 +144,6 @@ pub struct TestArgs { /// Print detailed test summary table. #[arg(long, help_heading = "Display options", requires = "summary")] pub detailed: bool, - - /// Show test execution progress. - #[arg(long)] - pub show_progress: bool, } impl TestArgs { @@ -565,12 +570,20 @@ impl TestArgs { } } + // Persist test run failures to enable replaying. + persist_run_failures(&config, &outcome); + Ok(outcome) } /// Returns the flattened [`FilterArgs`] arguments merged with [`Config`]. + /// Loads and applies filter from file if only last test run failures performed. pub fn filter(&self, config: &Config) -> ProjectPathsAwareFilter { - self.filter.clone().merge_with_config(config) + let mut filter = self.filter.clone(); + if self.rerun { + filter.test_pattern = last_run_failures(config); + } + filter.merge_with_config(config) } /// Returns whether `BuildArgs` was configured with `--watch` @@ -640,6 +653,31 @@ fn list( Ok(TestOutcome::empty(false)) } +/// Load persisted filter (with last test run failures) from file. +fn last_run_failures(config: &Config) -> Option { + match fs::read_to_string(&config.test_failures_file) { + Ok(filter) => Some(Regex::new(&filter).unwrap()), + Err(_) => None, + } +} + +/// Persist filter with last test run failures (only if there's any failure). +fn persist_run_failures(config: &Config, outcome: &TestOutcome) { + if outcome.failed() > 0 && fs::create_file(&config.test_failures_file).is_ok() { + let mut filter = String::new(); + let mut failures = outcome.failures().peekable(); + while let Some((test_name, _)) = failures.next() { + if let Some(test_match) = test_name.split("(").next() { + filter.push_str(test_match); + if failures.peek().is_some() { + filter.push('|'); + } + } + } + let _ = fs::write(&config.test_failures_file, filter); + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 63df640060c96..ede77beb067c9 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -65,6 +65,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { path_pattern: None, path_pattern_inverse: None, coverage_pattern_inverse: None, + test_failures_file: "test-cache/test-failures".into(), fuzz: FuzzConfig { runs: 1000, max_test_rejects: 100203, diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index d0f5ad16b1d97..c72456d1f57eb 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -638,3 +638,44 @@ fn extract_number_of_runs(stderr: String) -> usize { }); runs.unwrap().parse::().unwrap() } + +forgetest_init!(should_replay_failures_only, |prj, cmd| { + prj.wipe_contracts(); + prj.add_test( + "ReplayFailures.t.sol", + r#"pragma solidity 0.8.24; +import {Test} from "forge-std/Test.sol"; + +contract ReplayFailuresTest is Test { + function testA() public pure { + require(2 > 1); + } + + function testB() public pure { + require(1 > 2, "testB failed"); + } + + function testC() public pure { + require(2 > 1); + } + + function testD() public pure { + require(1 > 2, "testD failed"); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]); + cmd.assert_err(); + // Test failure filter should be persisted. + assert!(prj.root().join("cache/test-failures").exists()); + + // Perform only the 2 failing tests from last run. + cmd.forge_fuse(); + cmd.args(["test", "--rerun"]).unchecked_output().stdout_matches_path( + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/replay_last_run_failures.stdout"), + ); +}); diff --git a/crates/forge/tests/fixtures/replay_last_run_failures.stdout b/crates/forge/tests/fixtures/replay_last_run_failures.stdout new file mode 100644 index 0000000000000..d94983059658d --- /dev/null +++ b/crates/forge/tests/fixtures/replay_last_run_failures.stdout @@ -0,0 +1,15 @@ +No files changed, compilation skipped + +Ran 2 tests for test/ReplayFailures.t.sol:ReplayFailuresTest +[FAIL. Reason: revert: testB failed] testB() (gas: 303) +[FAIL. Reason: revert: testD failed] testD() (gas: 314) +Suite result: FAILED. 0 passed; 2 failed; 0 skipped; finished in 555.95µs (250.31µs CPU time) + +Ran 1 test suite in 3.24ms (555.95µs CPU time): 0 tests passed, 2 failed, 0 skipped (2 total tests) + +Failing tests: +Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest +[FAIL. Reason: revert: testB failed] testB() (gas: 303) +[FAIL. Reason: revert: testD failed] testD() (gas: 314) + +Encountered a total of 2 failing tests, 0 tests succeeded From 0dc2a93e3ac7c3e2a45f0d14677e50155f40f422 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Thu, 4 Jul 2024 14:16:37 +0700 Subject: [PATCH 1205/1963] feat(cheatcodes): add vm.setBlockhash (#8258) * intitial * add set_blockhash method to DatabaseExt trait * cargo cheats * remove additional ; * update to Evm group * remove err handling * adjust signature and add implementation for cheatcode * lint * update * fix test * fmt * refactor based on reviews * update docs for setBlockhash * empty * Update crates/forge/tests/it/invariant.rs Co-authored-by: Matthias Seitz * add docs * cargo cheats --------- Co-authored-by: Matthias Seitz --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 5 +++++ crates/cheatcodes/src/evm.rs | 14 +++++++++++++ crates/evm/core/src/backend/cow.rs | 4 ++++ crates/evm/core/src/backend/mod.rs | 24 ++++++++++++++++++++++ testdata/cheats/Vm.sol | 1 + testdata/default/cheats/SetBlockhash.t.sol | 16 +++++++++++++++ 7 files changed, 84 insertions(+) create mode 100644 testdata/default/cheats/SetBlockhash.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index f2dde361978a4..f4fe4f91d6435 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7451,6 +7451,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "setBlockhash", + "description": "Set blockhash for the current block.\nIt only sets the blockhash for blocks where `block.number - 256 <= number < block.number`.", + "declaration": "function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;", + "visibility": "external", + "mutability": "", + "signature": "setBlockhash(uint256,bytes32)", + "selector": "0x5314b54a", + "selectorBytes": [ + 83, + 20, + 181, + 74 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "setEnv", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 62c25ac3d4bbb..5bb36619d3de7 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -430,6 +430,11 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function getBlobBaseFee() external view returns (uint256 blobBaseFee); + /// Set blockhash for the current block. + /// It only sets the blockhash for blocks where `block.number - 256 <= number < block.number`. + #[cheatcode(group = Evm, safety = Unsafe)] + function setBlockhash(uint256 blockNumber, bytes32 blockHash) external; + // -------- Account State -------- /// Sets an address' balance. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 4e559687dbc1e..0b42391f8b317 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -567,6 +567,20 @@ impl Cheatcode for stopAndReturnStateDiffCall { } } +impl Cheatcode for setBlockhashCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { blockNumber, blockHash } = *self; + ensure!( + blockNumber <= ccx.ecx.env.block.number, + "block number must be less than or equal to the current block number" + ); + + ccx.ecx.db.set_blockhash(blockNumber, blockHash); + + Ok(Default::default()) + } +} + pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { let (account, _) = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?; Ok(account.info.nonce.abi_encode()) diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 6a3e6f3687594..b0ca3876667b5 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -245,6 +245,10 @@ impl<'a> DatabaseExt for CowBackend<'a> { fn has_cheatcode_access(&self, account: &Address) -> bool { self.backend.has_cheatcode_access(account) } + + fn set_blockhash(&mut self, block_number: U256, block_hash: B256) { + self.backend.to_mut().set_blockhash(block_number, block_hash); + } } impl<'a> DatabaseRef for CowBackend<'a> { diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index d544c01af484b..d55e0d6f940ee 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -331,6 +331,22 @@ pub trait DatabaseExt: Database + DatabaseCommit { } Ok(()) } + + /// Set the blockhash for a given block number. + /// + /// # Arguments + /// + /// * `number` - The block number to set the blockhash for + /// * `hash` - The blockhash to set + /// + /// # Note + /// + /// This function mimics the EVM limits of the `blockhash` operation: + /// - It sets the blockhash for blocks where `block.number - 256 <= number < block.number` + /// - Setting a blockhash for the current block (number == block.number) has no effect + /// - Setting a blockhash for future blocks (number > block.number) has no effect + /// - Setting a blockhash for blocks older than `block.number - 256` has no effect + fn set_blockhash(&mut self, block_number: U256, block_hash: B256); } struct _ObjectSafe(dyn DatabaseExt); @@ -1369,6 +1385,14 @@ impl DatabaseExt for Backend { fn has_cheatcode_access(&self, account: &Address) -> bool { self.inner.cheatcode_access_accounts.contains(account) } + + fn set_blockhash(&mut self, block_number: U256, block_hash: B256) { + if let Some(db) = self.active_fork_db_mut() { + db.block_hashes.insert(block_number, block_hash); + } else { + self.mem_db.block_hashes.insert(block_number, block_hash); + } + } } impl DatabaseRef for Backend { diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index b9ee72e1b5ba2..2995403968d79 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -368,6 +368,7 @@ interface Vm { 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 setBlockhash(uint256 blockNumber, bytes32 blockHash) external; function setEnv(string calldata name, string calldata value) external; function setNonce(address account, uint64 newNonce) external; function setNonceUnsafe(address account, uint64 newNonce) external; diff --git a/testdata/default/cheats/SetBlockhash.t.sol b/testdata/default/cheats/SetBlockhash.t.sol new file mode 100644 index 0000000000000..f6c2af5f668ba --- /dev/null +++ b/testdata/default/cheats/SetBlockhash.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract SetBlockhash is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testSetBlockhash() public { + bytes32 blockHash = 0x1234567890123456789012345678901234567890123456789012345678901234; + vm.setBlockhash(block.number - 1, blockHash); + bytes32 expected = blockhash(block.number - 1); + assertEq(blockHash, expected); + } +} From 63fe89cd7af23b4c03980f74a5f1c82783f287a3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 4 Jul 2024 13:26:50 +0200 Subject: [PATCH 1206/1963] fix: order of personal sign (#8350) --- crates/anvil/core/src/eth/mod.rs | 9 +++++++-- crates/anvil/src/eth/api.rs | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index a35a7b6e6b297..8a832b79e857c 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -141,9 +141,14 @@ pub enum EthRequest { EthGetProof(Address, Vec, Option), /// The sign method calculates an Ethereum specific signature with: - #[cfg_attr(feature = "serde", serde(rename = "eth_sign", alias = "personal_sign"))] + #[cfg_attr(feature = "serde", serde(rename = "eth_sign"))] EthSign(Address, Bytes), + /// The sign method calculates an Ethereum specific signature, equivalent to eth_sign: + /// + #[cfg_attr(feature = "serde", serde(rename = "personal_sign"))] + PersonalSign(Bytes, Address), + #[cfg_attr(feature = "serde", serde(rename = "eth_signTransaction", with = "sequence"))] EthSignTransaction(Box>), @@ -1562,7 +1567,7 @@ true}]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); let s = r#"{"method": "personal_sign", "params": -["0xd84de507f3fada7df80908082d3239466db55a71", "0x00"]}"#; +["0x00", "0xd84de507f3fada7df80908082d3239466db55a71"]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 0493dc8016330..a0cc94249134a 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -211,6 +211,9 @@ impl EthApi { self.get_proof(addr, keys, block).await.to_rpc_result() } EthRequest::EthSign(addr, content) => self.sign(addr, content).await.to_rpc_result(), + EthRequest::PersonalSign(content, addr) => { + self.sign(addr, content).await.to_rpc_result() + } EthRequest::EthSignTransaction(request) => { self.sign_transaction(*request).await.to_rpc_result() } From 3d0e423462636dfb3363d077420a75995aaa5d54 Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Thu, 4 Jul 2024 08:27:03 -0700 Subject: [PATCH 1207/1963] Fixes dependency version format error (#8353) * Soldeer release v0.2.17 * solved failing test * Fixing the config error if the dependency is a string and not a map * Adding untagged * fixing fmt * Adding a bit of documentation --- crates/config/src/soldeer.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/config/src/soldeer.rs b/crates/config/src/soldeer.rs index e99fb2aaaabf8..e5df0dcaf6a01 100644 --- a/crates/config/src/soldeer.rs +++ b/crates/config/src/soldeer.rs @@ -4,9 +4,9 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; -/// Soldeer dependencies config structure +/// Soldeer dependencies config structure when it's defined as a map #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct SoldeerDependency { +pub struct MapDependency { /// The version of the dependency pub version: String, @@ -17,10 +17,21 @@ pub struct SoldeerDependency { /// Type for Soldeer configs, under dependencies tag in the foundry.toml #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct SoldeerConfig(BTreeMap); +pub struct SoldeerConfig(BTreeMap); impl AsRef for SoldeerConfig { fn as_ref(&self) -> &Self { self } } + +/// Enum to cover both available formats for defining a dependency +/// `dep = { version = "1.1", url = "https://my-dependency" }` +/// or +/// `dep = "1.1"` +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SoldeerDependencyValue { + Map(MapDependency), + Str(String), +} From c08b6582d950e9d333eb62338ed7aba4ca585782 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:06:30 +0200 Subject: [PATCH 1208/1963] chore: regenerate HardhatConsole and patches (#8357) chore: regenerate HardhatConsole --- crates/evm/abi/src/HardhatConsole.json | 2 +- crates/evm/abi/src/console.py | 77 +++ crates/evm/abi/src/console/hardhat.rs | 516 +------------------ crates/evm/abi/src/console/patches.rs | 674 +++++++++++++++++++++++++ crates/evm/evm/src/inspectors/stack.rs | 4 +- 5 files changed, 757 insertions(+), 516 deletions(-) create mode 100755 crates/evm/abi/src/console.py create mode 100644 crates/evm/abi/src/console/patches.rs diff --git a/crates/evm/abi/src/HardhatConsole.json b/crates/evm/abi/src/HardhatConsole.json index 4013d875357ea..54e6d46dff349 100644 --- a/crates/evm/abi/src/HardhatConsole.json +++ b/crates/evm/abi/src/HardhatConsole.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"bool","name":"p2","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"uint256","name":"p3","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"bool","name":"p1","type":"bool"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"string","name":"p1","type":"string"},{"internalType":"string","name":"p2","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"bool","name":"p3","type":"bool"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"address","name":"p2","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"},{"internalType":"address","name":"p1","type":"address"},{"internalType":"uint256","name":"p2","type":"uint256"},{"internalType":"string","name":"p3","type":"string"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"},{"internalType":"uint256","name":"p1","type":"uint256"},{"internalType":"string","name":"p2","type":"string"},{"internalType":"address","name":"p3","type":"address"}],"name":"log","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"p0","type":"address"}],"name":"logAddress","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"p0","type":"bool"}],"name":"logBool","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"p0","type":"bytes"}],"name":"logBytes","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes1","name":"p0","type":"bytes1"}],"name":"logBytes1","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes10","name":"p0","type":"bytes10"}],"name":"logBytes10","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes11","name":"p0","type":"bytes11"}],"name":"logBytes11","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes12","name":"p0","type":"bytes12"}],"name":"logBytes12","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes13","name":"p0","type":"bytes13"}],"name":"logBytes13","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes14","name":"p0","type":"bytes14"}],"name":"logBytes14","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes15","name":"p0","type":"bytes15"}],"name":"logBytes15","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16","name":"p0","type":"bytes16"}],"name":"logBytes16","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes17","name":"p0","type":"bytes17"}],"name":"logBytes17","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes18","name":"p0","type":"bytes18"}],"name":"logBytes18","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes19","name":"p0","type":"bytes19"}],"name":"logBytes19","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes2","name":"p0","type":"bytes2"}],"name":"logBytes2","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes20","name":"p0","type":"bytes20"}],"name":"logBytes20","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes21","name":"p0","type":"bytes21"}],"name":"logBytes21","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes22","name":"p0","type":"bytes22"}],"name":"logBytes22","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes23","name":"p0","type":"bytes23"}],"name":"logBytes23","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes24","name":"p0","type":"bytes24"}],"name":"logBytes24","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes25","name":"p0","type":"bytes25"}],"name":"logBytes25","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes26","name":"p0","type":"bytes26"}],"name":"logBytes26","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes27","name":"p0","type":"bytes27"}],"name":"logBytes27","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes28","name":"p0","type":"bytes28"}],"name":"logBytes28","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes29","name":"p0","type":"bytes29"}],"name":"logBytes29","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes3","name":"p0","type":"bytes3"}],"name":"logBytes3","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes30","name":"p0","type":"bytes30"}],"name":"logBytes30","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes31","name":"p0","type":"bytes31"}],"name":"logBytes31","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"p0","type":"bytes32"}],"name":"logBytes32","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"p0","type":"bytes4"}],"name":"logBytes4","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes5","name":"p0","type":"bytes5"}],"name":"logBytes5","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes6","name":"p0","type":"bytes6"}],"name":"logBytes6","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes7","name":"p0","type":"bytes7"}],"name":"logBytes7","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes8","name":"p0","type":"bytes8"}],"name":"logBytes8","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes9","name":"p0","type":"bytes9"}],"name":"logBytes9","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"p0","type":"int256"}],"name":"logInt","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"p0","type":"string"}],"name":"logString","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"p0","type":"uint256"}],"name":"logUint","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"p0","type":"int256"}],"outputs":[],"stateMutability":"view","type":"function","name":"log"},{"inputs":[{"internalType":"string","name":"p0","type":"string"},{"internalType":"int256","name":"p1","type":"int256"}],"outputs":[],"stateMutability":"view","type":"function","name":"log"}] \ No newline at end of file +[{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes10","name":"","type":"bytes10"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes11","name":"","type":"bytes11"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes25","name":"","type":"bytes25"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"int256","name":"","type":"int256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes3","name":"","type":"bytes3"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes17","name":"","type":"bytes17"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes27","name":"","type":"bytes27"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"int256","name":"","type":"int256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes29","name":"","type":"bytes29"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes7","name":"","type":"bytes7"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes8","name":"","type":"bytes8"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes20","name":"","type":"bytes20"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes19","name":"","type":"bytes19"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes16","name":"","type":"bytes16"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes1","name":"","type":"bytes1"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes12","name":"","type":"bytes12"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes9","name":"","type":"bytes9"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes14","name":"","type":"bytes14"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes13","name":"","type":"bytes13"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes5","name":"","type":"bytes5"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes23","name":"","type":"bytes23"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes6","name":"","type":"bytes6"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes31","name":"","type":"bytes31"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes18","name":"","type":"bytes18"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes28","name":"","type":"bytes28"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes22","name":"","type":"bytes22"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes15","name":"","type":"bytes15"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes2","name":"","type":"bytes2"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes21","name":"","type":"bytes21"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes30","name":"","type":"bytes30"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes24","name":"","type":"bytes24"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes26","name":"","type":"bytes26"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"address","name":"","type":"address"}],"name":"log","outputs":[],"stateMutability":"pure","type":"function"}] \ No newline at end of file diff --git a/crates/evm/abi/src/console.py b/crates/evm/abi/src/console.py new file mode 100755 index 0000000000000..e0ca8aa8991a0 --- /dev/null +++ b/crates/evm/abi/src/console.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 + +import json +import re +import subprocess +import sys + + +def main(): + if len(sys.argv) < 4: + print( + f"Usage: {sys.argv[0]} " + ) + sys.exit(1) + [console_file, abi_file, patches_file] = sys.argv[1:4] + + # Parse signatures from `console.sol`'s string literals + console_sol = open(console_file).read() + sig_strings = re.findall( + r'"(log.*?)"', + console_sol, + ) + raw_sigs = [s.strip().strip('"') for s in sig_strings] + sigs = [ + s.replace("string", "string memory").replace("bytes)", "bytes memory)") + for s in raw_sigs + ] + sigs = list(set(sigs)) + + # Get HardhatConsole ABI + s = "interface HardhatConsole{\n" + for sig in sigs: + s += f"function {sig} external pure;\n" + s += "\n}" + r = subprocess.run( + ["solc", "-", "--combined-json", "abi"], + input=s.encode("utf8"), + capture_output=True, + ) + combined = json.loads(r.stdout.strip()) + abi = combined["contracts"][":HardhatConsole"]["abi"] + open(abi_file, "w").write(json.dumps(abi, separators=(",", ":"), indent=None)) + + # Make patches + patches = [] + for raw_sig in raw_sigs: + patched = raw_sig.replace("int", "int256") + if raw_sig != patched: + patches.append([raw_sig, patched]) + + # Generate the Rust patches map + codegen = "[\n" + for [original, patched] in patches: + codegen += f" // `{original}` -> `{patched}`\n" + + original_selector = selector(original) + patched_selector = selector(patched) + codegen += f" // `{original_selector.hex()}` -> `{patched_selector.hex()}`\n" + + codegen += ( + f" ({list(iter(original_selector))}, {list(iter(patched_selector))}),\n" + ) + codegen += "]\n" + open(patches_file, "w").write(codegen) + + +def keccak256(s): + r = subprocess.run(["cast", "keccak256", s], capture_output=True) + return bytes.fromhex(r.stdout.decode("utf8").strip()[2:]) + + +def selector(s): + return keccak256(s)[:4] + + +if __name__ == "__main__": + main() diff --git a/crates/evm/abi/src/console/hardhat.rs b/crates/evm/abi/src/console/hardhat.rs index 1e5f7c87ee0d3..bdacddba5619c 100644 --- a/crates/evm/abi/src/console/hardhat.rs +++ b/crates/evm/abi/src/console/hardhat.rs @@ -38,519 +38,9 @@ pub fn hh_console_selector(input: &[u8]) -> Option<&'static Selector> { /// /// `hardhat/console.log` logs its events manually, and in functions that accept integers they're /// encoded as `abi.encodeWithSignature("log(int)", p0)`, which is not the canonical ABI encoding -/// for `int` that Solc (and [`sol!`]) uses. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = Lazy::new(|| { - FxHashMap::from_iter([ - // log(bool,uint256,uint256,address) - ([241, 97, 178, 33], [0, 221, 135, 185]), - // log(uint256,address,address,string) - ([121, 67, 220, 102], [3, 28, 111, 115]), - // log(uint256,bool,address,uint256) - ([65, 181, 239, 59], [7, 130, 135, 245]), - // log(bool,address,bool,uint256) - ([76, 182, 15, 209], [7, 131, 21, 2]), - // log(bool,uint256,address) - ([196, 210, 53, 7], [8, 142, 249, 210]), - // log(uint256,address,address,bool) - ([1, 85, 11, 4], [9, 31, 250, 245]), - // log(address,bool,uint256,string) - ([155, 88, 142, 204], [10, 166, 207, 173]), - // log(bool,bool,uint256,uint256) - ([70, 103, 222, 142], [11, 176, 14, 171]), - // log(bool,address,address,uint256) - ([82, 132, 189, 108], [12, 102, 209, 190]), - // log(uint256,address,uint256,uint256) - ([202, 154, 62, 180], [12, 156, 217, 193]), - // log(string,address,uint256) - ([7, 200, 18, 23], [13, 38, 185, 37]), - // log(address,string,uint256,bool) - ([126, 37, 13, 91], [14, 247, 224, 80]), - // log(address,uint256,address,uint256) - ([165, 217, 135, 104], [16, 15, 101, 14]), - // log(string,string,uint256,address) - ([93, 79, 70, 128], [16, 35, 247, 178]), - // log(bool,string,uint256) - ([192, 56, 42, 172], [16, 147, 238, 17]), - // log(bool,bool,uint256) - ([176, 19, 101, 187], [18, 242, 22, 2]), - // log(bool,address,uint256,address) - ([104, 241, 88, 181], [19, 107, 5, 221]), - // log(bool,uint256,address,uint256) - ([202, 165, 35, 106], [21, 55, 220, 135]), - // log(bool,string,uint256,address) - ([91, 34, 185, 56], [21, 150, 161, 206]), - // log(address,string,string,uint256) - ([161, 79, 208, 57], [21, 159, 137, 39]), - // log(uint256,address,uint256,address) - ([253, 178, 236, 212], [21, 193, 39, 181]), - // log(uint256,uint256,address,bool) - ([168, 232, 32, 174], [21, 202, 196, 118]), - // log(bool,string,bool,uint256) - ([141, 111, 156, 165], [22, 6, 163, 147]), - // log(address,address,uint256) - ([108, 54, 109, 114], [23, 254, 97, 133]), - // log(uint256,uint256,uint256,uint256) - ([92, 160, 173, 62], [25, 63, 184, 0]), - // log(bool,string,uint256,string) - ([119, 161, 171, 237], [26, 217, 109, 230]), - // log(bool,uint256,address,string) - ([24, 9, 19, 65], [27, 179, 176, 154]), - // log(string,uint256,address) - ([227, 132, 159, 121], [28, 126, 196, 72]), - // log(uint256,bool) - ([30, 109, 212, 236], [28, 157, 126, 179]), - // log(address,uint256,address,string) - ([93, 113, 243, 158], [29, 169, 134, 234]), - // log(address,string,uint256,uint256) - ([164, 201, 42, 96], [29, 200, 225, 184]), - // log(uint256,bool,uint256) - ([90, 77, 153, 34], [32, 9, 128, 20]), - // log(uint256,bool,bool) - ([213, 206, 172, 224], [32, 113, 134, 80]), - // log(address,uint256,uint256,address) - ([30, 246, 52, 52], [32, 227, 152, 77]), - // log(uint256,string,string,string) - ([87, 221, 10, 17], [33, 173, 6, 131]), - // log(address,uint256,bool,uint256) - ([105, 143, 67, 146], [34, 246, 185, 153]), - // log(uint256,address,address,address) - ([85, 71, 69, 249], [36, 136, 180, 20]), - // log(string,bool,string,uint256) - ([52, 203, 48, 141], [36, 249, 20, 101]), - // log(bool,uint256,address,address) - ([138, 47, 144, 170], [38, 245, 96, 168]), - // log(uint256,uint256,string,string) - ([124, 3, 42, 50], [39, 216, 175, 210]), - // log(bool,string,uint256,uint256) - ([142, 74, 232, 110], [40, 134, 63, 203]), - // log(uint256,bool,string,uint256) - ([145, 95, 219, 40], [44, 29, 7, 70]), - // log(address,uint256,uint256,uint256) - ([61, 14, 157, 228], [52, 240, 230, 54]), - // log(uint256,bool,address) - ([66, 78, 255, 191], [53, 8, 95, 123]), - // log(string,uint256,bool,bool) - ([227, 127, 243, 208], [53, 76, 54, 214]), - // log(bool,uint256,uint256) - ([59, 92, 3, 224], [55, 16, 51, 103]), - // log(bool,uint256,uint256,uint256) - ([50, 223, 165, 36], [55, 75, 180, 178]), - // log(uint256,string,uint256) - ([91, 109, 232, 63], [55, 170, 125, 76]), - // log(address,bool,uint256,uint256) - ([194, 16, 160, 30], [56, 111, 245, 244]), - // log(address,address,bool,uint256) - ([149, 214, 95, 17], [57, 113, 231, 140]), - // log(bool,uint256) - ([54, 75, 106, 146], [57, 145, 116, 211]), - // log(uint256,string,uint256,address) - ([171, 123, 217, 253], [59, 34, 121, 180]), - // log(address,uint256,bool,bool) - ([254, 161, 213, 90], [59, 245, 229, 55]), - // log(uint256,address,string,string) - ([141, 119, 134, 36], [62, 18, 140, 163]), - // log(string,address,bool,uint256) - ([197, 209, 187, 139], [62, 159, 134, 106]), - // log(uint256,uint256,string,address) - ([67, 50, 133, 162], [66, 210, 29, 183]), - // log(address,string,uint256,string) - ([93, 19, 101, 201], [68, 136, 48, 168]), - // log(uint256,bool,address,bool) - ([145, 251, 18, 66], [69, 77, 84, 165]), - // log(address,string,address,uint256) - ([140, 25, 51, 169], [69, 127, 227, 207]), - // log(uint256,address,string,uint256) - ([160, 196, 20, 232], [70, 130, 107, 93]), - // log(uint256,uint256,bool) - ([103, 87, 15, 247], [71, 102, 218, 114]), - // log(address,uint256,address,address) - ([236, 36, 132, 111], [71, 141, 28, 98]), - // log(address,uint256,uint256,string) - ([137, 52, 13, 171], [74, 40, 192, 23]), - // log(bool,bool,address,uint256) - ([96, 147, 134, 231], [76, 18, 61, 87]), - // log(uint256,string,bool) - ([70, 167, 208, 206], [76, 237, 167, 90]), - // log(string,uint256,address,uint256) - ([88, 73, 122, 254], [79, 4, 253, 198]), - // log(address,string,bool,uint256) - ([231, 32, 82, 28], [81, 94, 56, 182]), - // log(bool,address,uint256,string) - ([160, 104, 88, 51], [81, 240, 159, 248]), - // log(bool,bool,uint256,address) - ([11, 255, 149, 13], [84, 167, 169, 160]), - // log(uint256,uint256,address,address) - ([202, 147, 155, 32], [86, 165, 209, 177]), - // log(string,string,uint256) - ([243, 98, 202, 89], [88, 33, 239, 161]), - // log(string,uint256,string) - ([163, 245, 199, 57], [89, 112, 224, 137]), - // log(uint256,uint256,uint256,string) - ([120, 173, 122, 12], [89, 207, 203, 227]), - // log(string,address,uint256,string) - ([76, 85, 242, 52], [90, 71, 118, 50]), - // log(uint256,address,uint256) - ([136, 67, 67, 170], [90, 155, 94, 213]), - // log(string,uint256,string,string) - ([108, 152, 218, 226], [90, 184, 78, 31]), - // log(uint256,address,bool,uint256) - ([123, 8, 232, 235], [90, 189, 153, 42]), - // log(address,uint256,string,address) - ([220, 121, 38, 4], [92, 67, 13, 71]), - // log(uint256,uint256,address) - ([190, 51, 73, 27], [92, 150, 179, 49]), - // log(string,bool,address,uint256) - ([40, 223, 78, 150], [93, 8, 187, 5]), - // log(string,string,uint256,string) - ([141, 20, 44, 221], [93, 26, 151, 26]), - // log(uint256,uint256,string,uint256) - ([56, 148, 22, 61], [93, 162, 151, 235]), - // log(string,uint256,address,address) - ([234, 200, 146, 129], [94, 162, 183, 174]), - // log(uint256,address,uint256,bool) - ([25, 246, 115, 105], [95, 116, 58, 124]), - // log(bool,address,uint256) - ([235, 112, 75, 175], [95, 123, 154, 251]), - // log(uint256,string,address,address) - ([127, 165, 69, 139], [97, 104, 237, 97]), - // log(bool,bool,uint256,bool) - ([171, 92, 193, 196], [97, 158, 77, 14]), - // log(address,string,uint256,address) - ([223, 215, 216, 11], [99, 24, 54, 120]), - // log(uint256,address,string) - ([206, 131, 4, 123], [99, 203, 65, 249]), - // log(string,address,uint256,address) - ([163, 102, 236, 128], [99, 251, 139, 197]), - // log(uint256,string) - ([15, 163, 243, 69], [100, 63, 208, 223]), - // log(string,bool,uint256,uint256) - ([93, 191, 240, 56], [100, 181, 187, 103]), - // log(address,uint256,uint256,bool) - ([236, 75, 168, 162], [102, 241, 188, 103]), - // log(address,uint256,bool) - ([229, 74, 225, 68], [103, 130, 9, 168]), - // log(address,string,uint256) - ([28, 218, 242, 138], [103, 221, 111, 241]), - // log(uint256,bool,string,string) - ([164, 51, 252, 253], [104, 200, 184, 189]), - // log(uint256,string,uint256,bool) - ([135, 90, 110, 46], [105, 26, 143, 116]), - // log(uint256,address) - ([88, 235, 134, 12], [105, 39, 108, 134]), - // log(uint256,bool,bool,address) - ([83, 6, 34, 93], [105, 100, 11, 89]), - // log(bool,uint256,string,uint256) - ([65, 128, 1, 27], [106, 17, 153, 226]), - // log(bool,string,uint256,bool) - ([32, 187, 201, 175], [107, 14, 93, 83]), - // log(uint256,uint256,address,string) - ([214, 162, 209, 222], [108, 222, 64, 184]), - // log(bool,bool,bool,uint256) - ([194, 72, 131, 77], [109, 112, 69, 193]), - // log(uint256,uint256,string) - ([125, 105, 14, 230], [113, 208, 74, 242]), - // log(uint256,address,address,uint256) - ([154, 60, 191, 150], [115, 110, 251, 182]), - // log(string,bool,uint256,string) - ([66, 185, 162, 39], [116, 45, 110, 231]), - // log(uint256,bool,bool,uint256) - ([189, 37, 173, 89], [116, 100, 206, 35]), - // log(string,uint256,uint256,bool) - ([247, 60, 126, 61], [118, 38, 219, 146]), - // log(uint256,uint256,string,bool) - ([178, 46, 175, 6], [122, 246, 171, 37]), - // log(uint256,string,address) - ([31, 144, 242, 74], [122, 250, 201, 89]), - // log(address,uint256,address) - ([151, 236, 163, 148], [123, 192, 216, 72]), - // log(bool,string,string,uint256) - ([93, 219, 37, 146], [123, 224, 195, 235]), - // log(bool,address,uint256,uint256) - ([155, 254, 114, 188], [123, 241, 129, 161]), - // log(string,uint256,string,address) - ([187, 114, 53, 233], [124, 70, 50, 164]), - // log(string,string,address,uint256) - ([74, 129, 165, 106], [124, 195, 198, 7]), - // log(string,uint256,string,bool) - ([233, 159, 130, 207], [125, 36, 73, 29]), - // log(bool,bool,uint256,string) - ([80, 97, 137, 55], [125, 212, 208, 224]), - // log(bool,uint256,bool,uint256) - ([211, 222, 85, 147], [127, 155, 188, 162]), - // log(address,bool,string,uint256) - ([158, 18, 123, 110], [128, 230, 162, 11]), - // log(string,uint256,address,bool) - ([17, 6, 168, 247], [130, 17, 42, 66]), - // log(uint256,string,uint256,uint256) - ([192, 4, 56, 7], [130, 194, 91, 116]), - // log(address,uint256) - ([34, 67, 207, 163], [131, 9, 232, 168]), - // log(string,uint256,uint256,string) - ([165, 78, 212, 189], [133, 75, 52, 150]), - // log(uint256,bool,string) - ([139, 14, 20, 254], [133, 119, 80, 33]), - // log(address,uint256,string,string) - ([126, 86, 198, 147], [136, 168, 196, 6]), - // log(uint256,bool,uint256,address) - ([79, 64, 5, 142], [136, 203, 96, 65]), - // log(uint256,uint256,address,uint256) - ([97, 11, 168, 192], [136, 246, 228, 178]), - // log(string,bool,uint256,bool) - ([60, 197, 181, 211], [138, 247, 207, 138]), - // log(address,bool,bool,uint256) - ([207, 181, 135, 86], [140, 78, 93, 230]), - // log(address,address,uint256,address) - ([214, 198, 82, 118], [141, 166, 222, 245]), - // log(string,bool,bool,uint256) - ([128, 117, 49, 232], [142, 63, 120, 169]), - // log(bool,uint256,uint256,string) - ([218, 6, 102, 200], [142, 105, 251, 93]), - // log(string,string,string,uint256) - ([159, 208, 9, 245], [142, 175, 176, 43]), - // log(string,address,address,uint256) - ([110, 183, 148, 61], [142, 243, 243, 153]), - // log(uint256,string,address,bool) - ([249, 63, 255, 55], [144, 195, 10, 86]), - // log(uint256,address,bool,string) - ([99, 240, 226, 66], [144, 251, 6, 170]), - // log(bool,uint256,bool,string) - ([182, 213, 105, 212], [145, 67, 219, 177]), - // log(uint256,bool,uint256,bool) - ([210, 171, 196, 253], [145, 160, 46, 42]), - // log(string,address,string,uint256) - ([143, 98, 75, 233], [145, 209, 17, 46]), - // log(string,bool,uint256,address) - ([113, 211, 133, 13], [147, 94, 9, 191]), - // log(address,address,address,uint256) - ([237, 94, 172, 135], [148, 37, 13, 119]), - // log(uint256,uint256,bool,address) - ([225, 23, 116, 79], [154, 129, 106, 131]), - // log(bool,uint256,bool,address) - ([66, 103, 199, 248], [154, 205, 54, 22]), - // log(address,address,uint256,bool) - ([194, 246, 136, 236], [155, 66, 84, 226]), - // log(uint256,address,bool) - ([122, 208, 18, 142], [155, 110, 192, 66]), - // log(uint256,string,address,string) - ([248, 152, 87, 127], [156, 58, 223, 161]), - // log(address,bool,uint256) - ([44, 70, 141, 21], [156, 79, 153, 251]), - // log(uint256,address,string,address) - ([203, 229, 142, 253], [156, 186, 143, 255]), - // log(string,uint256,address,string) - ([50, 84, 194, 232], [159, 251, 47, 147]), - // log(address,uint256,address,bool) - ([241, 129, 161, 233], [161, 188, 201, 179]), - // log(uint256,bool,address,address) - ([134, 237, 193, 12], [161, 239, 76, 187]), - // log(address,uint256,string) - ([186, 249, 104, 73], [161, 242, 232, 170]), - // log(address,uint256,bool,address) - ([35, 229, 73, 114], [163, 27, 253, 204]), - // log(uint256,uint256,bool,string) - ([239, 217, 203, 238], [165, 180, 252, 153]), - // log(bool,string,address,uint256) - ([27, 11, 149, 91], [165, 202, 218, 148]), - // log(address,bool,address,uint256) - ([220, 113, 22, 210], [167, 92, 89, 222]), - // log(string,uint256,uint256,uint256) - ([8, 238, 86, 102], [167, 168, 120, 83]), - // log(uint256,uint256,bool,bool) - ([148, 190, 59, 177], [171, 8, 90, 230]), - // log(string,uint256,bool,string) - ([118, 204, 96, 100], [171, 247, 58, 152]), - // log(uint256,bool,address,string) - ([162, 48, 118, 30], [173, 224, 82, 199]), - // log(uint256,string,bool,address) - ([121, 111, 40, 160], [174, 46, 197, 129]), - // log(uint256,string,string,uint256) - ([118, 236, 99, 94], [176, 40, 201, 189]), - // log(uint256,string,string) - ([63, 87, 194, 149], [177, 21, 97, 31]), - // log(uint256,string,string,bool) - ([18, 134, 43, 152], [179, 166, 182, 189]), - // log(bool,uint256,address,bool) - ([101, 173, 244, 8], [180, 195, 20, 255]), - // log(string,uint256) - ([151, 16, 169, 208], [182, 14, 114, 204]), - // log(address,uint256,uint256) - ([135, 134, 19, 94], [182, 155, 202, 246]), - // log(uint256,bool,bool,bool) - ([78, 108, 83, 21], [182, 245, 119, 161]), - // log(uint256,string,uint256,string) - ([162, 188, 12, 153], [183, 185, 20, 202]), - // log(uint256,string,bool,bool) - ([81, 188, 43, 193], [186, 83, 93, 156]), - // log(uint256,address,address) - ([125, 119, 166, 27], [188, 253, 155, 224]), - // log(address,address,uint256,uint256) - ([84, 253, 243, 228], [190, 85, 52, 129]), - // log(bool,uint256,uint256,bool) - ([164, 29, 129, 222], [190, 152, 67, 83]), - // log(address,uint256,string,uint256) - ([245, 18, 207, 155], [191, 1, 248, 145]), - // log(bool,address,string,uint256) - ([11, 153, 252, 34], [194, 31, 100, 199]), - // log(string,string,uint256,bool) - ([230, 86, 88, 202], [195, 168, 166, 84]), - // log(bool,uint256,string) - ([200, 57, 126, 176], [195, 252, 57, 112]), - // log(address,bool,uint256,bool) - ([133, 205, 197, 175], [196, 100, 62, 32]), - // log(uint256,uint256,uint256,bool) - ([100, 82, 185, 203], [197, 152, 209, 133]), - // log(address,uint256,bool,string) - ([142, 142, 78, 117], [197, 173, 133, 249]), - // log(string,uint256,string,uint256) - ([160, 196, 178, 37], [198, 126, 169, 209]), - // log(uint256,bool,uint256,uint256) - ([86, 130, 141, 164], [198, 172, 199, 168]), - // log(string,bool,uint256) - ([41, 27, 185, 208], [201, 89, 88, 214]), - // log(string,uint256,uint256) - ([150, 156, 221, 3], [202, 71, 196, 235]), - // log(string,uint256,bool) - ([241, 2, 238, 5], [202, 119, 51, 177]), - // log(uint256,address,string,bool) - ([34, 164, 121, 166], [204, 50, 171, 7]), - // log(address,bool,uint256,address) - ([13, 140, 230, 30], [204, 247, 144, 161]), - // log(bool,uint256,bool,bool) - ([158, 1, 247, 65], [206, 181, 244, 215]), - // log(uint256,string,bool,uint256) - ([164, 180, 138, 127], [207, 0, 152, 128]), - // log(address,uint256,string,bool) - ([164, 2, 79, 17], [207, 24, 16, 92]), - // log(uint256,uint256,uint256) - ([231, 130, 10, 116], [209, 237, 122, 60]), - // log(uint256,string,bool,string) - ([141, 72, 156, 160], [210, 212, 35, 205]), - // log(uint256,string,string,address) - ([204, 152, 138, 160], [213, 131, 198, 2]), - // log(bool,address,uint256,bool) - ([238, 141, 134, 114], [214, 1, 159, 28]), - // log(string,string,bool,uint256) - ([134, 129, 138, 122], [214, 174, 250, 210]), - // log(uint256,address,uint256,string) - ([62, 211, 189, 40], [221, 176, 101, 33]), - // log(uint256,bool,bool,string) - ([49, 138, 229, 155], [221, 219, 149, 97]), - // log(uint256,bool,uint256,string) - ([232, 221, 188, 86], [222, 3, 231, 116]), - // log(string,uint256,bool,address) - ([229, 84, 157, 145], [224, 233, 91, 152]), - // log(string,uint256,uint256,address) - ([190, 215, 40, 191], [226, 29, 226, 120]), - // log(uint256,address,bool,bool) - ([126, 39, 65, 13], [227, 81, 20, 15]), - // log(bool,bool,string,uint256) - ([23, 139, 70, 133], [227, 169, 202, 47]), - // log(string,uint256,bool,uint256) - ([85, 14, 110, 245], [228, 27, 111, 111]), - // log(bool,uint256,string,bool) - ([145, 210, 248, 19], [229, 231, 11, 43]), - // log(uint256,string,address,uint256) - ([152, 231, 243, 243], [232, 211, 1, 141]), - // log(bool,uint256,bool) - ([27, 173, 201, 235], [232, 222, 251, 169]), - // log(uint256,uint256,bool,uint256) - ([108, 100, 124, 140], [235, 127, 111, 210]), - // log(uint256,bool,string,bool) - ([52, 110, 184, 199], [235, 146, 141, 127]), - // log(address,address,string,uint256) - ([4, 40, 147, 0], [239, 28, 239, 231]), - // log(uint256,bool,string,address) - ([73, 110, 43, 180], [239, 82, 144, 24]), - // log(uint256,address,bool,address) - ([182, 49, 48, 148], [239, 114, 197, 19]), - // log(string,string,uint256,uint256) - ([213, 207, 23, 208], [244, 93, 125, 44]), - // log(bool,uint256,string,string) - ([211, 42, 101, 72], [245, 188, 34, 73]), - // log(uint256,uint256) - ([108, 15, 105, 128], [246, 102, 113, 90]), - // log(uint256) and logUint(uint256) - ([245, 177, 187, 169], [248, 44, 80, 241]), - // log(string,address,uint256,uint256) - ([218, 163, 148, 189], [248, 245, 27, 30]), - // log(uint256,uint256,uint256,address) - ([224, 133, 63, 105], [250, 129, 133, 175]), - // log(string,address,uint256,bool) - ([90, 193, 193, 60], [252, 72, 69, 240]), - // log(address,address,uint256,string) - ([157, 209, 46, 173], [253, 180, 249, 144]), - // log(bool,uint256,string,address) - ([165, 199, 13, 41], [254, 221, 31, 255]), - // logInt(int256) - ([78, 12, 29, 29], [101, 37, 181, 245]), - // logBytes(bytes) - ([11, 231, 127, 86], [225, 123, 249, 86]), - // logBytes1(bytes1) - ([110, 24, 161, 40], [111, 65, 113, 201]), - // logBytes2(bytes2) - ([233, 182, 34, 150], [155, 94, 148, 62]), - // logBytes3(bytes3) - ([45, 131, 73, 38], [119, 130, 250, 45]), - // logBytes4(bytes4) - ([224, 95, 72, 209], [251, 163, 173, 57]), - // logBytes5(bytes5) - ([166, 132, 128, 141], [85, 131, 190, 46]), - // logBytes6(bytes6) - ([174, 132, 165, 145], [73, 66, 173, 198]), - // logBytes7(bytes7) - ([78, 213, 126, 40], [69, 116, 175, 171]), - // logBytes8(bytes8) - ([79, 132, 37, 46], [153, 2, 228, 127]), - // logBytes9(bytes9) - ([144, 189, 140, 208], [80, 161, 56, 223]), - // logBytes10(bytes10) - ([1, 61, 23, 139], [157, 194, 168, 151]), - // logBytes11(bytes11) - ([4, 0, 74, 46], [220, 8, 182, 167]), - // logBytes12(bytes12) - ([134, 160, 106, 189], [118, 86, 214, 199]), - // logBytes13(bytes13) - ([148, 82, 158, 52], [52, 193, 216, 27]), - // logBytes14(bytes14) - ([146, 102, 240, 127], [60, 234, 186, 101]), - // logBytes15(bytes15) - ([218, 149, 116, 224], [89, 26, 61, 162]), - // logBytes16(bytes16) - ([102, 92, 97, 4], [31, 141, 115, 18]), - // logBytes17(bytes17) - ([51, 159, 103, 58], [248, 154, 83, 47]), - // logBytes18(bytes18) - ([196, 210, 61, 154], [216, 101, 38, 66]), - // logBytes19(bytes19) - ([94, 107, 90, 51], [0, 245, 107, 201]), - // logBytes20(bytes20) - ([81, 136, 227, 233], [236, 184, 86, 126]), - // logBytes21(bytes21) - ([233, 218, 53, 96], [48, 82, 192, 143]), - // logBytes22(bytes22) - ([213, 250, 232, 156], [128, 122, 180, 52]), - // logBytes23(bytes23) - ([171, 161, 207, 13], [73, 121, 176, 55]), - // logBytes24(bytes24) - ([241, 179, 91, 52], [9, 119, 174, 252]), - // logBytes25(bytes25) - ([11, 132, 188, 88], [174, 169, 150, 63]), - // logBytes26(bytes26) - ([248, 177, 73, 241], [211, 99, 86, 40]), - // logBytes27(bytes27) - ([58, 55, 87, 221], [252, 55, 47, 159]), - // logBytes28(bytes28) - ([200, 42, 234, 238], [56, 47, 154, 52]), - // logBytes29(bytes29) - ([75, 105, 195, 213], [122, 24, 118, 65]), - // logBytes30(bytes30) - ([238, 18, 196, 237], [196, 52, 14, 246]), - // logBytes31(bytes31) - ([194, 133, 77, 146], [129, 252, 134, 72]), - // logBytes32(bytes32) - ([39, 183, 207, 133], [45, 33, 214, 247]), - ]) -}); +/// for `int` that Solidity and [`sol!`] use. +pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = + Lazy::new(|| FxHashMap::from_iter(include!("./patches.rs"))); #[cfg(test)] mod tests { diff --git a/crates/evm/abi/src/console/patches.rs b/crates/evm/abi/src/console/patches.rs new file mode 100644 index 0000000000000..ad63a9fe6d3da --- /dev/null +++ b/crates/evm/abi/src/console/patches.rs @@ -0,0 +1,674 @@ +[ + // `log(int)` -> `log(int256)` + // `4e0c1d1d` -> `2d5b6cb9` + ([78, 12, 29, 29], [45, 91, 108, 185]), + // `log(uint)` -> `log(uint256)` + // `f5b1bba9` -> `f82c50f1` + ([245, 177, 187, 169], [248, 44, 80, 241]), + // `log(uint)` -> `log(uint256)` + // `f5b1bba9` -> `f82c50f1` + ([245, 177, 187, 169], [248, 44, 80, 241]), + // `log(int)` -> `log(int256)` + // `4e0c1d1d` -> `2d5b6cb9` + ([78, 12, 29, 29], [45, 91, 108, 185]), + // `log(uint,uint)` -> `log(uint256,uint256)` + // `6c0f6980` -> `f666715a` + ([108, 15, 105, 128], [246, 102, 113, 90]), + // `log(uint,string)` -> `log(uint256,string)` + // `0fa3f345` -> `643fd0df` + ([15, 163, 243, 69], [100, 63, 208, 223]), + // `log(uint,bool)` -> `log(uint256,bool)` + // `1e6dd4ec` -> `1c9d7eb3` + ([30, 109, 212, 236], [28, 157, 126, 179]), + // `log(uint,address)` -> `log(uint256,address)` + // `58eb860c` -> `69276c86` + ([88, 235, 134, 12], [105, 39, 108, 134]), + // `log(string,uint)` -> `log(string,uint256)` + // `9710a9d0` -> `b60e72cc` + ([151, 16, 169, 208], [182, 14, 114, 204]), + // `log(string,int)` -> `log(string,int256)` + // `af7faa38` -> `3ca6268e` + ([175, 127, 170, 56], [60, 166, 38, 142]), + // `log(bool,uint)` -> `log(bool,uint256)` + // `364b6a92` -> `399174d3` + ([54, 75, 106, 146], [57, 145, 116, 211]), + // `log(address,uint)` -> `log(address,uint256)` + // `2243cfa3` -> `8309e8a8` + ([34, 67, 207, 163], [131, 9, 232, 168]), + // `log(uint,uint,uint)` -> `log(uint256,uint256,uint256)` + // `e7820a74` -> `d1ed7a3c` + ([231, 130, 10, 116], [209, 237, 122, 60]), + // `log(uint,uint,string)` -> `log(uint256,uint256,string)` + // `7d690ee6` -> `71d04af2` + ([125, 105, 14, 230], [113, 208, 74, 242]), + // `log(uint,uint,bool)` -> `log(uint256,uint256,bool)` + // `67570ff7` -> `4766da72` + ([103, 87, 15, 247], [71, 102, 218, 114]), + // `log(uint,uint,address)` -> `log(uint256,uint256,address)` + // `be33491b` -> `5c96b331` + ([190, 51, 73, 27], [92, 150, 179, 49]), + // `log(uint,string,uint)` -> `log(uint256,string,uint256)` + // `5b6de83f` -> `37aa7d4c` + ([91, 109, 232, 63], [55, 170, 125, 76]), + // `log(uint,string,string)` -> `log(uint256,string,string)` + // `3f57c295` -> `b115611f` + ([63, 87, 194, 149], [177, 21, 97, 31]), + // `log(uint,string,bool)` -> `log(uint256,string,bool)` + // `46a7d0ce` -> `4ceda75a` + ([70, 167, 208, 206], [76, 237, 167, 90]), + // `log(uint,string,address)` -> `log(uint256,string,address)` + // `1f90f24a` -> `7afac959` + ([31, 144, 242, 74], [122, 250, 201, 89]), + // `log(uint,bool,uint)` -> `log(uint256,bool,uint256)` + // `5a4d9922` -> `20098014` + ([90, 77, 153, 34], [32, 9, 128, 20]), + // `log(uint,bool,string)` -> `log(uint256,bool,string)` + // `8b0e14fe` -> `85775021` + ([139, 14, 20, 254], [133, 119, 80, 33]), + // `log(uint,bool,bool)` -> `log(uint256,bool,bool)` + // `d5ceace0` -> `20718650` + ([213, 206, 172, 224], [32, 113, 134, 80]), + // `log(uint,bool,address)` -> `log(uint256,bool,address)` + // `424effbf` -> `35085f7b` + ([66, 78, 255, 191], [53, 8, 95, 123]), + // `log(uint,address,uint)` -> `log(uint256,address,uint256)` + // `884343aa` -> `5a9b5ed5` + ([136, 67, 67, 170], [90, 155, 94, 213]), + // `log(uint,address,string)` -> `log(uint256,address,string)` + // `ce83047b` -> `63cb41f9` + ([206, 131, 4, 123], [99, 203, 65, 249]), + // `log(uint,address,bool)` -> `log(uint256,address,bool)` + // `7ad0128e` -> `9b6ec042` + ([122, 208, 18, 142], [155, 110, 192, 66]), + // `log(uint,address,address)` -> `log(uint256,address,address)` + // `7d77a61b` -> `bcfd9be0` + ([125, 119, 166, 27], [188, 253, 155, 224]), + // `log(string,uint,uint)` -> `log(string,uint256,uint256)` + // `969cdd03` -> `ca47c4eb` + ([150, 156, 221, 3], [202, 71, 196, 235]), + // `log(string,uint,string)` -> `log(string,uint256,string)` + // `a3f5c739` -> `5970e089` + ([163, 245, 199, 57], [89, 112, 224, 137]), + // `log(string,uint,bool)` -> `log(string,uint256,bool)` + // `f102ee05` -> `ca7733b1` + ([241, 2, 238, 5], [202, 119, 51, 177]), + // `log(string,uint,address)` -> `log(string,uint256,address)` + // `e3849f79` -> `1c7ec448` + ([227, 132, 159, 121], [28, 126, 196, 72]), + // `log(string,string,uint)` -> `log(string,string,uint256)` + // `f362ca59` -> `5821efa1` + ([243, 98, 202, 89], [88, 33, 239, 161]), + // `log(string,bool,uint)` -> `log(string,bool,uint256)` + // `291bb9d0` -> `c95958d6` + ([41, 27, 185, 208], [201, 89, 88, 214]), + // `log(string,address,uint)` -> `log(string,address,uint256)` + // `07c81217` -> `0d26b925` + ([7, 200, 18, 23], [13, 38, 185, 37]), + // `log(bool,uint,uint)` -> `log(bool,uint256,uint256)` + // `3b5c03e0` -> `37103367` + ([59, 92, 3, 224], [55, 16, 51, 103]), + // `log(bool,uint,string)` -> `log(bool,uint256,string)` + // `c8397eb0` -> `c3fc3970` + ([200, 57, 126, 176], [195, 252, 57, 112]), + // `log(bool,uint,bool)` -> `log(bool,uint256,bool)` + // `1badc9eb` -> `e8defba9` + ([27, 173, 201, 235], [232, 222, 251, 169]), + // `log(bool,uint,address)` -> `log(bool,uint256,address)` + // `c4d23507` -> `088ef9d2` + ([196, 210, 53, 7], [8, 142, 249, 210]), + // `log(bool,string,uint)` -> `log(bool,string,uint256)` + // `c0382aac` -> `1093ee11` + ([192, 56, 42, 172], [16, 147, 238, 17]), + // `log(bool,bool,uint)` -> `log(bool,bool,uint256)` + // `b01365bb` -> `12f21602` + ([176, 19, 101, 187], [18, 242, 22, 2]), + // `log(bool,address,uint)` -> `log(bool,address,uint256)` + // `eb704baf` -> `5f7b9afb` + ([235, 112, 75, 175], [95, 123, 154, 251]), + // `log(address,uint,uint)` -> `log(address,uint256,uint256)` + // `8786135e` -> `b69bcaf6` + ([135, 134, 19, 94], [182, 155, 202, 246]), + // `log(address,uint,string)` -> `log(address,uint256,string)` + // `baf96849` -> `a1f2e8aa` + ([186, 249, 104, 73], [161, 242, 232, 170]), + // `log(address,uint,bool)` -> `log(address,uint256,bool)` + // `e54ae144` -> `678209a8` + ([229, 74, 225, 68], [103, 130, 9, 168]), + // `log(address,uint,address)` -> `log(address,uint256,address)` + // `97eca394` -> `7bc0d848` + ([151, 236, 163, 148], [123, 192, 216, 72]), + // `log(address,string,uint)` -> `log(address,string,uint256)` + // `1cdaf28a` -> `67dd6ff1` + ([28, 218, 242, 138], [103, 221, 111, 241]), + // `log(address,bool,uint)` -> `log(address,bool,uint256)` + // `2c468d15` -> `9c4f99fb` + ([44, 70, 141, 21], [156, 79, 153, 251]), + // `log(address,address,uint)` -> `log(address,address,uint256)` + // `6c366d72` -> `17fe6185` + ([108, 54, 109, 114], [23, 254, 97, 133]), + // `log(uint,uint,uint,uint)` -> `log(uint256,uint256,uint256,uint256)` + // `5ca0ad3e` -> `193fb800` + ([92, 160, 173, 62], [25, 63, 184, 0]), + // `log(uint,uint,uint,string)` -> `log(uint256,uint256,uint256,string)` + // `78ad7a0c` -> `59cfcbe3` + ([120, 173, 122, 12], [89, 207, 203, 227]), + // `log(uint,uint,uint,bool)` -> `log(uint256,uint256,uint256,bool)` + // `6452b9cb` -> `c598d185` + ([100, 82, 185, 203], [197, 152, 209, 133]), + // `log(uint,uint,uint,address)` -> `log(uint256,uint256,uint256,address)` + // `e0853f69` -> `fa8185af` + ([224, 133, 63, 105], [250, 129, 133, 175]), + // `log(uint,uint,string,uint)` -> `log(uint256,uint256,string,uint256)` + // `3894163d` -> `5da297eb` + ([56, 148, 22, 61], [93, 162, 151, 235]), + // `log(uint,uint,string,string)` -> `log(uint256,uint256,string,string)` + // `7c032a32` -> `27d8afd2` + ([124, 3, 42, 50], [39, 216, 175, 210]), + // `log(uint,uint,string,bool)` -> `log(uint256,uint256,string,bool)` + // `b22eaf06` -> `7af6ab25` + ([178, 46, 175, 6], [122, 246, 171, 37]), + // `log(uint,uint,string,address)` -> `log(uint256,uint256,string,address)` + // `433285a2` -> `42d21db7` + ([67, 50, 133, 162], [66, 210, 29, 183]), + // `log(uint,uint,bool,uint)` -> `log(uint256,uint256,bool,uint256)` + // `6c647c8c` -> `eb7f6fd2` + ([108, 100, 124, 140], [235, 127, 111, 210]), + // `log(uint,uint,bool,string)` -> `log(uint256,uint256,bool,string)` + // `efd9cbee` -> `a5b4fc99` + ([239, 217, 203, 238], [165, 180, 252, 153]), + // `log(uint,uint,bool,bool)` -> `log(uint256,uint256,bool,bool)` + // `94be3bb1` -> `ab085ae6` + ([148, 190, 59, 177], [171, 8, 90, 230]), + // `log(uint,uint,bool,address)` -> `log(uint256,uint256,bool,address)` + // `e117744f` -> `9a816a83` + ([225, 23, 116, 79], [154, 129, 106, 131]), + // `log(uint,uint,address,uint)` -> `log(uint256,uint256,address,uint256)` + // `610ba8c0` -> `88f6e4b2` + ([97, 11, 168, 192], [136, 246, 228, 178]), + // `log(uint,uint,address,string)` -> `log(uint256,uint256,address,string)` + // `d6a2d1de` -> `6cde40b8` + ([214, 162, 209, 222], [108, 222, 64, 184]), + // `log(uint,uint,address,bool)` -> `log(uint256,uint256,address,bool)` + // `a8e820ae` -> `15cac476` + ([168, 232, 32, 174], [21, 202, 196, 118]), + // `log(uint,uint,address,address)` -> `log(uint256,uint256,address,address)` + // `ca939b20` -> `56a5d1b1` + ([202, 147, 155, 32], [86, 165, 209, 177]), + // `log(uint,string,uint,uint)` -> `log(uint256,string,uint256,uint256)` + // `c0043807` -> `82c25b74` + ([192, 4, 56, 7], [130, 194, 91, 116]), + // `log(uint,string,uint,string)` -> `log(uint256,string,uint256,string)` + // `a2bc0c99` -> `b7b914ca` + ([162, 188, 12, 153], [183, 185, 20, 202]), + // `log(uint,string,uint,bool)` -> `log(uint256,string,uint256,bool)` + // `875a6e2e` -> `691a8f74` + ([135, 90, 110, 46], [105, 26, 143, 116]), + // `log(uint,string,uint,address)` -> `log(uint256,string,uint256,address)` + // `ab7bd9fd` -> `3b2279b4` + ([171, 123, 217, 253], [59, 34, 121, 180]), + // `log(uint,string,string,uint)` -> `log(uint256,string,string,uint256)` + // `76ec635e` -> `b028c9bd` + ([118, 236, 99, 94], [176, 40, 201, 189]), + // `log(uint,string,string,string)` -> `log(uint256,string,string,string)` + // `57dd0a11` -> `21ad0683` + ([87, 221, 10, 17], [33, 173, 6, 131]), + // `log(uint,string,string,bool)` -> `log(uint256,string,string,bool)` + // `12862b98` -> `b3a6b6bd` + ([18, 134, 43, 152], [179, 166, 182, 189]), + // `log(uint,string,string,address)` -> `log(uint256,string,string,address)` + // `cc988aa0` -> `d583c602` + ([204, 152, 138, 160], [213, 131, 198, 2]), + // `log(uint,string,bool,uint)` -> `log(uint256,string,bool,uint256)` + // `a4b48a7f` -> `cf009880` + ([164, 180, 138, 127], [207, 0, 152, 128]), + // `log(uint,string,bool,string)` -> `log(uint256,string,bool,string)` + // `8d489ca0` -> `d2d423cd` + ([141, 72, 156, 160], [210, 212, 35, 205]), + // `log(uint,string,bool,bool)` -> `log(uint256,string,bool,bool)` + // `51bc2bc1` -> `ba535d9c` + ([81, 188, 43, 193], [186, 83, 93, 156]), + // `log(uint,string,bool,address)` -> `log(uint256,string,bool,address)` + // `796f28a0` -> `ae2ec581` + ([121, 111, 40, 160], [174, 46, 197, 129]), + // `log(uint,string,address,uint)` -> `log(uint256,string,address,uint256)` + // `98e7f3f3` -> `e8d3018d` + ([152, 231, 243, 243], [232, 211, 1, 141]), + // `log(uint,string,address,string)` -> `log(uint256,string,address,string)` + // `f898577f` -> `9c3adfa1` + ([248, 152, 87, 127], [156, 58, 223, 161]), + // `log(uint,string,address,bool)` -> `log(uint256,string,address,bool)` + // `f93fff37` -> `90c30a56` + ([249, 63, 255, 55], [144, 195, 10, 86]), + // `log(uint,string,address,address)` -> `log(uint256,string,address,address)` + // `7fa5458b` -> `6168ed61` + ([127, 165, 69, 139], [97, 104, 237, 97]), + // `log(uint,bool,uint,uint)` -> `log(uint256,bool,uint256,uint256)` + // `56828da4` -> `c6acc7a8` + ([86, 130, 141, 164], [198, 172, 199, 168]), + // `log(uint,bool,uint,string)` -> `log(uint256,bool,uint256,string)` + // `e8ddbc56` -> `de03e774` + ([232, 221, 188, 86], [222, 3, 231, 116]), + // `log(uint,bool,uint,bool)` -> `log(uint256,bool,uint256,bool)` + // `d2abc4fd` -> `91a02e2a` + ([210, 171, 196, 253], [145, 160, 46, 42]), + // `log(uint,bool,uint,address)` -> `log(uint256,bool,uint256,address)` + // `4f40058e` -> `88cb6041` + ([79, 64, 5, 142], [136, 203, 96, 65]), + // `log(uint,bool,string,uint)` -> `log(uint256,bool,string,uint256)` + // `915fdb28` -> `2c1d0746` + ([145, 95, 219, 40], [44, 29, 7, 70]), + // `log(uint,bool,string,string)` -> `log(uint256,bool,string,string)` + // `a433fcfd` -> `68c8b8bd` + ([164, 51, 252, 253], [104, 200, 184, 189]), + // `log(uint,bool,string,bool)` -> `log(uint256,bool,string,bool)` + // `346eb8c7` -> `eb928d7f` + ([52, 110, 184, 199], [235, 146, 141, 127]), + // `log(uint,bool,string,address)` -> `log(uint256,bool,string,address)` + // `496e2bb4` -> `ef529018` + ([73, 110, 43, 180], [239, 82, 144, 24]), + // `log(uint,bool,bool,uint)` -> `log(uint256,bool,bool,uint256)` + // `bd25ad59` -> `7464ce23` + ([189, 37, 173, 89], [116, 100, 206, 35]), + // `log(uint,bool,bool,string)` -> `log(uint256,bool,bool,string)` + // `318ae59b` -> `dddb9561` + ([49, 138, 229, 155], [221, 219, 149, 97]), + // `log(uint,bool,bool,bool)` -> `log(uint256,bool,bool,bool)` + // `4e6c5315` -> `b6f577a1` + ([78, 108, 83, 21], [182, 245, 119, 161]), + // `log(uint,bool,bool,address)` -> `log(uint256,bool,bool,address)` + // `5306225d` -> `69640b59` + ([83, 6, 34, 93], [105, 100, 11, 89]), + // `log(uint,bool,address,uint)` -> `log(uint256,bool,address,uint256)` + // `41b5ef3b` -> `078287f5` + ([65, 181, 239, 59], [7, 130, 135, 245]), + // `log(uint,bool,address,string)` -> `log(uint256,bool,address,string)` + // `a230761e` -> `ade052c7` + ([162, 48, 118, 30], [173, 224, 82, 199]), + // `log(uint,bool,address,bool)` -> `log(uint256,bool,address,bool)` + // `91fb1242` -> `454d54a5` + ([145, 251, 18, 66], [69, 77, 84, 165]), + // `log(uint,bool,address,address)` -> `log(uint256,bool,address,address)` + // `86edc10c` -> `a1ef4cbb` + ([134, 237, 193, 12], [161, 239, 76, 187]), + // `log(uint,address,uint,uint)` -> `log(uint256,address,uint256,uint256)` + // `ca9a3eb4` -> `0c9cd9c1` + ([202, 154, 62, 180], [12, 156, 217, 193]), + // `log(uint,address,uint,string)` -> `log(uint256,address,uint256,string)` + // `3ed3bd28` -> `ddb06521` + ([62, 211, 189, 40], [221, 176, 101, 33]), + // `log(uint,address,uint,bool)` -> `log(uint256,address,uint256,bool)` + // `19f67369` -> `5f743a7c` + ([25, 246, 115, 105], [95, 116, 58, 124]), + // `log(uint,address,uint,address)` -> `log(uint256,address,uint256,address)` + // `fdb2ecd4` -> `15c127b5` + ([253, 178, 236, 212], [21, 193, 39, 181]), + // `log(uint,address,string,uint)` -> `log(uint256,address,string,uint256)` + // `a0c414e8` -> `46826b5d` + ([160, 196, 20, 232], [70, 130, 107, 93]), + // `log(uint,address,string,string)` -> `log(uint256,address,string,string)` + // `8d778624` -> `3e128ca3` + ([141, 119, 134, 36], [62, 18, 140, 163]), + // `log(uint,address,string,bool)` -> `log(uint256,address,string,bool)` + // `22a479a6` -> `cc32ab07` + ([34, 164, 121, 166], [204, 50, 171, 7]), + // `log(uint,address,string,address)` -> `log(uint256,address,string,address)` + // `cbe58efd` -> `9cba8fff` + ([203, 229, 142, 253], [156, 186, 143, 255]), + // `log(uint,address,bool,uint)` -> `log(uint256,address,bool,uint256)` + // `7b08e8eb` -> `5abd992a` + ([123, 8, 232, 235], [90, 189, 153, 42]), + // `log(uint,address,bool,string)` -> `log(uint256,address,bool,string)` + // `63f0e242` -> `90fb06aa` + ([99, 240, 226, 66], [144, 251, 6, 170]), + // `log(uint,address,bool,bool)` -> `log(uint256,address,bool,bool)` + // `7e27410d` -> `e351140f` + ([126, 39, 65, 13], [227, 81, 20, 15]), + // `log(uint,address,bool,address)` -> `log(uint256,address,bool,address)` + // `b6313094` -> `ef72c513` + ([182, 49, 48, 148], [239, 114, 197, 19]), + // `log(uint,address,address,uint)` -> `log(uint256,address,address,uint256)` + // `9a3cbf96` -> `736efbb6` + ([154, 60, 191, 150], [115, 110, 251, 182]), + // `log(uint,address,address,string)` -> `log(uint256,address,address,string)` + // `7943dc66` -> `031c6f73` + ([121, 67, 220, 102], [3, 28, 111, 115]), + // `log(uint,address,address,bool)` -> `log(uint256,address,address,bool)` + // `01550b04` -> `091ffaf5` + ([1, 85, 11, 4], [9, 31, 250, 245]), + // `log(uint,address,address,address)` -> `log(uint256,address,address,address)` + // `554745f9` -> `2488b414` + ([85, 71, 69, 249], [36, 136, 180, 20]), + // `log(string,uint,uint,uint)` -> `log(string,uint256,uint256,uint256)` + // `08ee5666` -> `a7a87853` + ([8, 238, 86, 102], [167, 168, 120, 83]), + // `log(string,uint,uint,string)` -> `log(string,uint256,uint256,string)` + // `a54ed4bd` -> `854b3496` + ([165, 78, 212, 189], [133, 75, 52, 150]), + // `log(string,uint,uint,bool)` -> `log(string,uint256,uint256,bool)` + // `f73c7e3d` -> `7626db92` + ([247, 60, 126, 61], [118, 38, 219, 146]), + // `log(string,uint,uint,address)` -> `log(string,uint256,uint256,address)` + // `bed728bf` -> `e21de278` + ([190, 215, 40, 191], [226, 29, 226, 120]), + // `log(string,uint,string,uint)` -> `log(string,uint256,string,uint256)` + // `a0c4b225` -> `c67ea9d1` + ([160, 196, 178, 37], [198, 126, 169, 209]), + // `log(string,uint,string,string)` -> `log(string,uint256,string,string)` + // `6c98dae2` -> `5ab84e1f` + ([108, 152, 218, 226], [90, 184, 78, 31]), + // `log(string,uint,string,bool)` -> `log(string,uint256,string,bool)` + // `e99f82cf` -> `7d24491d` + ([233, 159, 130, 207], [125, 36, 73, 29]), + // `log(string,uint,string,address)` -> `log(string,uint256,string,address)` + // `bb7235e9` -> `7c4632a4` + ([187, 114, 53, 233], [124, 70, 50, 164]), + // `log(string,uint,bool,uint)` -> `log(string,uint256,bool,uint256)` + // `550e6ef5` -> `e41b6f6f` + ([85, 14, 110, 245], [228, 27, 111, 111]), + // `log(string,uint,bool,string)` -> `log(string,uint256,bool,string)` + // `76cc6064` -> `abf73a98` + ([118, 204, 96, 100], [171, 247, 58, 152]), + // `log(string,uint,bool,bool)` -> `log(string,uint256,bool,bool)` + // `e37ff3d0` -> `354c36d6` + ([227, 127, 243, 208], [53, 76, 54, 214]), + // `log(string,uint,bool,address)` -> `log(string,uint256,bool,address)` + // `e5549d91` -> `e0e95b98` + ([229, 84, 157, 145], [224, 233, 91, 152]), + // `log(string,uint,address,uint)` -> `log(string,uint256,address,uint256)` + // `58497afe` -> `4f04fdc6` + ([88, 73, 122, 254], [79, 4, 253, 198]), + // `log(string,uint,address,string)` -> `log(string,uint256,address,string)` + // `3254c2e8` -> `9ffb2f93` + ([50, 84, 194, 232], [159, 251, 47, 147]), + // `log(string,uint,address,bool)` -> `log(string,uint256,address,bool)` + // `1106a8f7` -> `82112a42` + ([17, 6, 168, 247], [130, 17, 42, 66]), + // `log(string,uint,address,address)` -> `log(string,uint256,address,address)` + // `eac89281` -> `5ea2b7ae` + ([234, 200, 146, 129], [94, 162, 183, 174]), + // `log(string,string,uint,uint)` -> `log(string,string,uint256,uint256)` + // `d5cf17d0` -> `f45d7d2c` + ([213, 207, 23, 208], [244, 93, 125, 44]), + // `log(string,string,uint,string)` -> `log(string,string,uint256,string)` + // `8d142cdd` -> `5d1a971a` + ([141, 20, 44, 221], [93, 26, 151, 26]), + // `log(string,string,uint,bool)` -> `log(string,string,uint256,bool)` + // `e65658ca` -> `c3a8a654` + ([230, 86, 88, 202], [195, 168, 166, 84]), + // `log(string,string,uint,address)` -> `log(string,string,uint256,address)` + // `5d4f4680` -> `1023f7b2` + ([93, 79, 70, 128], [16, 35, 247, 178]), + // `log(string,string,string,uint)` -> `log(string,string,string,uint256)` + // `9fd009f5` -> `8eafb02b` + ([159, 208, 9, 245], [142, 175, 176, 43]), + // `log(string,string,bool,uint)` -> `log(string,string,bool,uint256)` + // `86818a7a` -> `d6aefad2` + ([134, 129, 138, 122], [214, 174, 250, 210]), + // `log(string,string,address,uint)` -> `log(string,string,address,uint256)` + // `4a81a56a` -> `7cc3c607` + ([74, 129, 165, 106], [124, 195, 198, 7]), + // `log(string,bool,uint,uint)` -> `log(string,bool,uint256,uint256)` + // `5dbff038` -> `64b5bb67` + ([93, 191, 240, 56], [100, 181, 187, 103]), + // `log(string,bool,uint,string)` -> `log(string,bool,uint256,string)` + // `42b9a227` -> `742d6ee7` + ([66, 185, 162, 39], [116, 45, 110, 231]), + // `log(string,bool,uint,bool)` -> `log(string,bool,uint256,bool)` + // `3cc5b5d3` -> `8af7cf8a` + ([60, 197, 181, 211], [138, 247, 207, 138]), + // `log(string,bool,uint,address)` -> `log(string,bool,uint256,address)` + // `71d3850d` -> `935e09bf` + ([113, 211, 133, 13], [147, 94, 9, 191]), + // `log(string,bool,string,uint)` -> `log(string,bool,string,uint256)` + // `34cb308d` -> `24f91465` + ([52, 203, 48, 141], [36, 249, 20, 101]), + // `log(string,bool,bool,uint)` -> `log(string,bool,bool,uint256)` + // `807531e8` -> `8e3f78a9` + ([128, 117, 49, 232], [142, 63, 120, 169]), + // `log(string,bool,address,uint)` -> `log(string,bool,address,uint256)` + // `28df4e96` -> `5d08bb05` + ([40, 223, 78, 150], [93, 8, 187, 5]), + // `log(string,address,uint,uint)` -> `log(string,address,uint256,uint256)` + // `daa394bd` -> `f8f51b1e` + ([218, 163, 148, 189], [248, 245, 27, 30]), + // `log(string,address,uint,string)` -> `log(string,address,uint256,string)` + // `4c55f234` -> `5a477632` + ([76, 85, 242, 52], [90, 71, 118, 50]), + // `log(string,address,uint,bool)` -> `log(string,address,uint256,bool)` + // `5ac1c13c` -> `fc4845f0` + ([90, 193, 193, 60], [252, 72, 69, 240]), + // `log(string,address,uint,address)` -> `log(string,address,uint256,address)` + // `a366ec80` -> `63fb8bc5` + ([163, 102, 236, 128], [99, 251, 139, 197]), + // `log(string,address,string,uint)` -> `log(string,address,string,uint256)` + // `8f624be9` -> `91d1112e` + ([143, 98, 75, 233], [145, 209, 17, 46]), + // `log(string,address,bool,uint)` -> `log(string,address,bool,uint256)` + // `c5d1bb8b` -> `3e9f866a` + ([197, 209, 187, 139], [62, 159, 134, 106]), + // `log(string,address,address,uint)` -> `log(string,address,address,uint256)` + // `6eb7943d` -> `8ef3f399` + ([110, 183, 148, 61], [142, 243, 243, 153]), + // `log(bool,uint,uint,uint)` -> `log(bool,uint256,uint256,uint256)` + // `32dfa524` -> `374bb4b2` + ([50, 223, 165, 36], [55, 75, 180, 178]), + // `log(bool,uint,uint,string)` -> `log(bool,uint256,uint256,string)` + // `da0666c8` -> `8e69fb5d` + ([218, 6, 102, 200], [142, 105, 251, 93]), + // `log(bool,uint,uint,bool)` -> `log(bool,uint256,uint256,bool)` + // `a41d81de` -> `be984353` + ([164, 29, 129, 222], [190, 152, 67, 83]), + // `log(bool,uint,uint,address)` -> `log(bool,uint256,uint256,address)` + // `f161b221` -> `00dd87b9` + ([241, 97, 178, 33], [0, 221, 135, 185]), + // `log(bool,uint,string,uint)` -> `log(bool,uint256,string,uint256)` + // `4180011b` -> `6a1199e2` + ([65, 128, 1, 27], [106, 17, 153, 226]), + // `log(bool,uint,string,string)` -> `log(bool,uint256,string,string)` + // `d32a6548` -> `f5bc2249` + ([211, 42, 101, 72], [245, 188, 34, 73]), + // `log(bool,uint,string,bool)` -> `log(bool,uint256,string,bool)` + // `91d2f813` -> `e5e70b2b` + ([145, 210, 248, 19], [229, 231, 11, 43]), + // `log(bool,uint,string,address)` -> `log(bool,uint256,string,address)` + // `a5c70d29` -> `fedd1fff` + ([165, 199, 13, 41], [254, 221, 31, 255]), + // `log(bool,uint,bool,uint)` -> `log(bool,uint256,bool,uint256)` + // `d3de5593` -> `7f9bbca2` + ([211, 222, 85, 147], [127, 155, 188, 162]), + // `log(bool,uint,bool,string)` -> `log(bool,uint256,bool,string)` + // `b6d569d4` -> `9143dbb1` + ([182, 213, 105, 212], [145, 67, 219, 177]), + // `log(bool,uint,bool,bool)` -> `log(bool,uint256,bool,bool)` + // `9e01f741` -> `ceb5f4d7` + ([158, 1, 247, 65], [206, 181, 244, 215]), + // `log(bool,uint,bool,address)` -> `log(bool,uint256,bool,address)` + // `4267c7f8` -> `9acd3616` + ([66, 103, 199, 248], [154, 205, 54, 22]), + // `log(bool,uint,address,uint)` -> `log(bool,uint256,address,uint256)` + // `caa5236a` -> `1537dc87` + ([202, 165, 35, 106], [21, 55, 220, 135]), + // `log(bool,uint,address,string)` -> `log(bool,uint256,address,string)` + // `18091341` -> `1bb3b09a` + ([24, 9, 19, 65], [27, 179, 176, 154]), + // `log(bool,uint,address,bool)` -> `log(bool,uint256,address,bool)` + // `65adf408` -> `b4c314ff` + ([101, 173, 244, 8], [180, 195, 20, 255]), + // `log(bool,uint,address,address)` -> `log(bool,uint256,address,address)` + // `8a2f90aa` -> `26f560a8` + ([138, 47, 144, 170], [38, 245, 96, 168]), + // `log(bool,string,uint,uint)` -> `log(bool,string,uint256,uint256)` + // `8e4ae86e` -> `28863fcb` + ([142, 74, 232, 110], [40, 134, 63, 203]), + // `log(bool,string,uint,string)` -> `log(bool,string,uint256,string)` + // `77a1abed` -> `1ad96de6` + ([119, 161, 171, 237], [26, 217, 109, 230]), + // `log(bool,string,uint,bool)` -> `log(bool,string,uint256,bool)` + // `20bbc9af` -> `6b0e5d53` + ([32, 187, 201, 175], [107, 14, 93, 83]), + // `log(bool,string,uint,address)` -> `log(bool,string,uint256,address)` + // `5b22b938` -> `1596a1ce` + ([91, 34, 185, 56], [21, 150, 161, 206]), + // `log(bool,string,string,uint)` -> `log(bool,string,string,uint256)` + // `5ddb2592` -> `7be0c3eb` + ([93, 219, 37, 146], [123, 224, 195, 235]), + // `log(bool,string,bool,uint)` -> `log(bool,string,bool,uint256)` + // `8d6f9ca5` -> `1606a393` + ([141, 111, 156, 165], [22, 6, 163, 147]), + // `log(bool,string,address,uint)` -> `log(bool,string,address,uint256)` + // `1b0b955b` -> `a5cada94` + ([27, 11, 149, 91], [165, 202, 218, 148]), + // `log(bool,bool,uint,uint)` -> `log(bool,bool,uint256,uint256)` + // `4667de8e` -> `0bb00eab` + ([70, 103, 222, 142], [11, 176, 14, 171]), + // `log(bool,bool,uint,string)` -> `log(bool,bool,uint256,string)` + // `50618937` -> `7dd4d0e0` + ([80, 97, 137, 55], [125, 212, 208, 224]), + // `log(bool,bool,uint,bool)` -> `log(bool,bool,uint256,bool)` + // `ab5cc1c4` -> `619e4d0e` + ([171, 92, 193, 196], [97, 158, 77, 14]), + // `log(bool,bool,uint,address)` -> `log(bool,bool,uint256,address)` + // `0bff950d` -> `54a7a9a0` + ([11, 255, 149, 13], [84, 167, 169, 160]), + // `log(bool,bool,string,uint)` -> `log(bool,bool,string,uint256)` + // `178b4685` -> `e3a9ca2f` + ([23, 139, 70, 133], [227, 169, 202, 47]), + // `log(bool,bool,bool,uint)` -> `log(bool,bool,bool,uint256)` + // `c248834d` -> `6d7045c1` + ([194, 72, 131, 77], [109, 112, 69, 193]), + // `log(bool,bool,address,uint)` -> `log(bool,bool,address,uint256)` + // `609386e7` -> `4c123d57` + ([96, 147, 134, 231], [76, 18, 61, 87]), + // `log(bool,address,uint,uint)` -> `log(bool,address,uint256,uint256)` + // `9bfe72bc` -> `7bf181a1` + ([155, 254, 114, 188], [123, 241, 129, 161]), + // `log(bool,address,uint,string)` -> `log(bool,address,uint256,string)` + // `a0685833` -> `51f09ff8` + ([160, 104, 88, 51], [81, 240, 159, 248]), + // `log(bool,address,uint,bool)` -> `log(bool,address,uint256,bool)` + // `ee8d8672` -> `d6019f1c` + ([238, 141, 134, 114], [214, 1, 159, 28]), + // `log(bool,address,uint,address)` -> `log(bool,address,uint256,address)` + // `68f158b5` -> `136b05dd` + ([104, 241, 88, 181], [19, 107, 5, 221]), + // `log(bool,address,string,uint)` -> `log(bool,address,string,uint256)` + // `0b99fc22` -> `c21f64c7` + ([11, 153, 252, 34], [194, 31, 100, 199]), + // `log(bool,address,bool,uint)` -> `log(bool,address,bool,uint256)` + // `4cb60fd1` -> `07831502` + ([76, 182, 15, 209], [7, 131, 21, 2]), + // `log(bool,address,address,uint)` -> `log(bool,address,address,uint256)` + // `5284bd6c` -> `0c66d1be` + ([82, 132, 189, 108], [12, 102, 209, 190]), + // `log(address,uint,uint,uint)` -> `log(address,uint256,uint256,uint256)` + // `3d0e9de4` -> `34f0e636` + ([61, 14, 157, 228], [52, 240, 230, 54]), + // `log(address,uint,uint,string)` -> `log(address,uint256,uint256,string)` + // `89340dab` -> `4a28c017` + ([137, 52, 13, 171], [74, 40, 192, 23]), + // `log(address,uint,uint,bool)` -> `log(address,uint256,uint256,bool)` + // `ec4ba8a2` -> `66f1bc67` + ([236, 75, 168, 162], [102, 241, 188, 103]), + // `log(address,uint,uint,address)` -> `log(address,uint256,uint256,address)` + // `1ef63434` -> `20e3984d` + ([30, 246, 52, 52], [32, 227, 152, 77]), + // `log(address,uint,string,uint)` -> `log(address,uint256,string,uint256)` + // `f512cf9b` -> `bf01f891` + ([245, 18, 207, 155], [191, 1, 248, 145]), + // `log(address,uint,string,string)` -> `log(address,uint256,string,string)` + // `7e56c693` -> `88a8c406` + ([126, 86, 198, 147], [136, 168, 196, 6]), + // `log(address,uint,string,bool)` -> `log(address,uint256,string,bool)` + // `a4024f11` -> `cf18105c` + ([164, 2, 79, 17], [207, 24, 16, 92]), + // `log(address,uint,string,address)` -> `log(address,uint256,string,address)` + // `dc792604` -> `5c430d47` + ([220, 121, 38, 4], [92, 67, 13, 71]), + // `log(address,uint,bool,uint)` -> `log(address,uint256,bool,uint256)` + // `698f4392` -> `22f6b999` + ([105, 143, 67, 146], [34, 246, 185, 153]), + // `log(address,uint,bool,string)` -> `log(address,uint256,bool,string)` + // `8e8e4e75` -> `c5ad85f9` + ([142, 142, 78, 117], [197, 173, 133, 249]), + // `log(address,uint,bool,bool)` -> `log(address,uint256,bool,bool)` + // `fea1d55a` -> `3bf5e537` + ([254, 161, 213, 90], [59, 245, 229, 55]), + // `log(address,uint,bool,address)` -> `log(address,uint256,bool,address)` + // `23e54972` -> `a31bfdcc` + ([35, 229, 73, 114], [163, 27, 253, 204]), + // `log(address,uint,address,uint)` -> `log(address,uint256,address,uint256)` + // `a5d98768` -> `100f650e` + ([165, 217, 135, 104], [16, 15, 101, 14]), + // `log(address,uint,address,string)` -> `log(address,uint256,address,string)` + // `5d71f39e` -> `1da986ea` + ([93, 113, 243, 158], [29, 169, 134, 234]), + // `log(address,uint,address,bool)` -> `log(address,uint256,address,bool)` + // `f181a1e9` -> `a1bcc9b3` + ([241, 129, 161, 233], [161, 188, 201, 179]), + // `log(address,uint,address,address)` -> `log(address,uint256,address,address)` + // `ec24846f` -> `478d1c62` + ([236, 36, 132, 111], [71, 141, 28, 98]), + // `log(address,string,uint,uint)` -> `log(address,string,uint256,uint256)` + // `a4c92a60` -> `1dc8e1b8` + ([164, 201, 42, 96], [29, 200, 225, 184]), + // `log(address,string,uint,string)` -> `log(address,string,uint256,string)` + // `5d1365c9` -> `448830a8` + ([93, 19, 101, 201], [68, 136, 48, 168]), + // `log(address,string,uint,bool)` -> `log(address,string,uint256,bool)` + // `7e250d5b` -> `0ef7e050` + ([126, 37, 13, 91], [14, 247, 224, 80]), + // `log(address,string,uint,address)` -> `log(address,string,uint256,address)` + // `dfd7d80b` -> `63183678` + ([223, 215, 216, 11], [99, 24, 54, 120]), + // `log(address,string,string,uint)` -> `log(address,string,string,uint256)` + // `a14fd039` -> `159f8927` + ([161, 79, 208, 57], [21, 159, 137, 39]), + // `log(address,string,bool,uint)` -> `log(address,string,bool,uint256)` + // `e720521c` -> `515e38b6` + ([231, 32, 82, 28], [81, 94, 56, 182]), + // `log(address,string,address,uint)` -> `log(address,string,address,uint256)` + // `8c1933a9` -> `457fe3cf` + ([140, 25, 51, 169], [69, 127, 227, 207]), + // `log(address,bool,uint,uint)` -> `log(address,bool,uint256,uint256)` + // `c210a01e` -> `386ff5f4` + ([194, 16, 160, 30], [56, 111, 245, 244]), + // `log(address,bool,uint,string)` -> `log(address,bool,uint256,string)` + // `9b588ecc` -> `0aa6cfad` + ([155, 88, 142, 204], [10, 166, 207, 173]), + // `log(address,bool,uint,bool)` -> `log(address,bool,uint256,bool)` + // `85cdc5af` -> `c4643e20` + ([133, 205, 197, 175], [196, 100, 62, 32]), + // `log(address,bool,uint,address)` -> `log(address,bool,uint256,address)` + // `0d8ce61e` -> `ccf790a1` + ([13, 140, 230, 30], [204, 247, 144, 161]), + // `log(address,bool,string,uint)` -> `log(address,bool,string,uint256)` + // `9e127b6e` -> `80e6a20b` + ([158, 18, 123, 110], [128, 230, 162, 11]), + // `log(address,bool,bool,uint)` -> `log(address,bool,bool,uint256)` + // `cfb58756` -> `8c4e5de6` + ([207, 181, 135, 86], [140, 78, 93, 230]), + // `log(address,bool,address,uint)` -> `log(address,bool,address,uint256)` + // `dc7116d2` -> `a75c59de` + ([220, 113, 22, 210], [167, 92, 89, 222]), + // `log(address,address,uint,uint)` -> `log(address,address,uint256,uint256)` + // `54fdf3e4` -> `be553481` + ([84, 253, 243, 228], [190, 85, 52, 129]), + // `log(address,address,uint,string)` -> `log(address,address,uint256,string)` + // `9dd12ead` -> `fdb4f990` + ([157, 209, 46, 173], [253, 180, 249, 144]), + // `log(address,address,uint,bool)` -> `log(address,address,uint256,bool)` + // `c2f688ec` -> `9b4254e2` + ([194, 246, 136, 236], [155, 66, 84, 226]), + // `log(address,address,uint,address)` -> `log(address,address,uint256,address)` + // `d6c65276` -> `8da6def5` + ([214, 198, 82, 118], [141, 166, 222, 245]), + // `log(address,address,string,uint)` -> `log(address,address,string,uint256)` + // `04289300` -> `ef1cefe7` + ([4, 40, 147, 0], [239, 28, 239, 231]), + // `log(address,address,bool,uint)` -> `log(address,address,bool,uint256)` + // `95d65f11` -> `3971e78c` + ([149, 214, 95, 17], [57, 113, 231, 140]), + // `log(address,address,address,uint)` -> `log(address,address,address,uint256)` + // `ed5eac87` -> `94250d77` + ([237, 94, 172, 135], [148, 37, 13, 119]), +] diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index aba7ef4f9e563..adec3d8b98c69 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -490,7 +490,7 @@ impl<'a> InspectorStackRefMut<'a> { let result = outcome.result.result; call_inspectors_adjust_depth!( #[ret] - [&mut self.fuzzer, &mut self.tracer, &mut self.cheatcodes, &mut self.printer,], + [&mut self.fuzzer, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| { let new_outcome = inspector.call_end(ecx, inputs, outcome.clone()); @@ -691,7 +691,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { call_inspectors_adjust_depth!( #[ret] - [&mut self.fuzzer, &mut self.tracer, &mut self.log_collector, &mut self.printer,], + [&mut self.fuzzer, &mut self.tracer, &mut self.log_collector, &mut self.printer], |inspector| { let mut out = None; if let Some(output) = inspector.call(ecx, call) { From 9bac92848f666563bb42fe0ef8c0c87ead97696d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:14:30 +0200 Subject: [PATCH 1209/1963] test: use known contracts when decoding traces (#8358) --- crates/forge/tests/it/config.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 18ecba6de075f..17087e5da5ef4 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -71,7 +71,9 @@ impl TestConfig { { let logs = decode_console_logs(&result.logs); let outcome = if self.should_fail { "fail" } else { "pass" }; - let call_trace_decoder = CallTraceDecoderBuilder::default().build(); + let call_trace_decoder = CallTraceDecoderBuilder::default() + .with_known_contracts(&self.runner.known_contracts) + .build(); let decoded_traces = join_all( result .traces From f7494da07ab76db88e9c853d14ee50eb33fdbb09 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:50:07 +0200 Subject: [PATCH 1210/1963] ci: add required checks to merge (#8359) --- .github/workflows/test.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 982cb068cdd34..c8758b2362a0f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,3 +103,21 @@ jobs: with: cache-on-failure: true - run: cargo hack check + + ci-success: + runs-on: ubuntu-latest + if: always() + needs: + - nextest + - docs + - doctest + - clippy + - rustfmt + - forge-fmt + - crate-checks + timeout-minutes: 30 + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} From 63b407fab4b64444429f6d991b98535e1f51dd74 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 4 Jul 2024 20:16:21 +0200 Subject: [PATCH 1211/1963] chore: add some additional etherscan api keys (#8360) --- crates/test-utils/src/rpc.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 63a701a4f82fc..8ed6fb8d5eed6 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -60,6 +60,9 @@ static ETHERSCAN_MAINNET_KEYS: Lazy> = Lazy::new(|| { "4FYHTY429IXYMJNS4TITKDMUKW5QRYDX61", "QYKNT5RHASZ7PGQE68FNQWH99IXVTVVD2I", "VXMQ117UN58Y4RHWUB8K1UGCEA7UQEWK55", + "C7I2G4JTA5EPYS42Z8IZFEIMQNI5GXIJEV", + "A15KZUMZXXCK1P25Y1VP1WGIVBBHIZDS74", + "3IA6ASNQXN8WKN7PNFX7T72S9YG56X9FPG", ]; keys.shuffle(&mut rand::thread_rng()); From 042b490510c1469939001192ae525cdd478e9563 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 4 Jul 2024 21:17:49 +0300 Subject: [PATCH 1212/1963] chore: `threads` and `show_progress` per profile config (#8341) * chore: allow max threads and show progress set per profile * Changes after review: max_threads to threads/jobs * Use short -j for jobs instead json * Update crates/config/README.md Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Use usize for number of threads --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/config/README.md | 4 ++++ crates/config/src/lib.rs | 6 ++++++ crates/forge/bin/cmd/test/mod.rs | 34 ++++++++++++++++++++------------ crates/forge/tests/cli/config.rs | 2 ++ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/crates/config/README.md b/crates/config/README.md index 337195276b72d..99f02e5e68f2e 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -115,6 +115,10 @@ no_match_contract = "Bar" match_path = "*/Foo*" no_match_path = "*/Bar*" no_match_coverage = "Baz" +# Number of threads to use. Not set or zero specifies the number of logical cores. +threads = 0 +# whether to show test execution progress +show_progress = true ffi = false always_use_create_2_factory = false prompt_timeout = 120 diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d6ec26b924014..89924d5c8b80d 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -257,6 +257,10 @@ pub struct Config { pub coverage_pattern_inverse: Option, /// Path where last test run failures are recorded. pub test_failures_file: PathBuf, + /// Max concurrent threads to use. + pub threads: Option, + /// Whether to show test execution progress. + pub show_progress: bool, /// Configuration for fuzz testing pub fuzz: FuzzConfig, /// Configuration for invariant testing @@ -2083,6 +2087,8 @@ impl Default for Config { path_pattern_inverse: None, coverage_pattern_inverse: None, test_failures_file: "cache/test-failures".into(), + threads: None, + show_progress: false, fuzz: FuzzConfig::new("cache/fuzz".into()), invariant: InvariantConfig::new("cache/invariant".into()), always_use_create_2_factory: false, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index fe709e028074c..f80227668f201 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -85,7 +85,7 @@ pub struct TestArgs { allow_failure: bool, /// Output test results in JSON format. - #[arg(long, short, help_heading = "Display options")] + #[arg(long, help_heading = "Display options")] json: bool, /// Stop running tests after the first failure. @@ -113,8 +113,8 @@ pub struct TestArgs { /// Max concurrent threads to use. /// Default value is the number of available CPUs. - #[arg(long)] - pub max_threads: Option, + #[arg(long, short = 'j', visible_alias = "jobs")] + pub threads: Option, /// Show test execution progress. #[arg(long)] @@ -236,17 +236,17 @@ impl TestArgs { /// /// Returns the test results for all matching tests. pub async fn execute_tests(self) -> Result { + // Merge all configs. + let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; + // Set number of max threads to execute tests. // If not specified then the number of threads determined by rayon will be used. - if let Some(test_threads) = self.max_threads { + if let Some(test_threads) = config.threads { trace!(target: "forge::test", "execute tests with {} max threads", test_threads); - rayon::ThreadPoolBuilder::new().num_threads(test_threads as usize).build_global()?; + rayon::ThreadPoolBuilder::new().num_threads(test_threads).build_global()?; } - // Merge all configs - let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; - - // Explicitly enable isolation for gas reports for more correct gas accounting + // Explicitly enable isolation for gas reports for more correct gas accounting. if self.gas_report { evm_opts.isolate = true; } else { @@ -289,7 +289,7 @@ impl TestArgs { .profiles(profiles) .build(&output, project_root)?; - // Determine print verbosity and executor verbosity + // Determine print verbosity and executor verbosity. let verbosity = evm_opts.verbosity; if self.gas_report && evm_opts.verbosity < 3 { evm_opts.verbosity = 3; @@ -297,7 +297,7 @@ impl TestArgs { let env = evm_opts.evm_env().await?; - // Prepare the test builder + // Prepare the test builder. let should_debug = self.debug.is_some(); let config = Arc::new(config); let runner = MultiContractRunnerBuilder::new(config.clone()) @@ -325,7 +325,7 @@ impl TestArgs { let outcome = self.run_tests(runner, config, verbosity, &filter).await?; if should_debug { - // Get first non-empty suite result. We will have only one such entry + // Get first non-empty suite result. We will have only one such entry. let Some((_, test_result)) = outcome .results .iter() @@ -390,7 +390,7 @@ impl TestArgs { // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); let timer = Instant::now(); - let show_progress = self.show_progress; + let show_progress = config.show_progress; let handle = tokio::task::spawn_blocking({ let filter = filter.clone(); move || runner.test(&filter, tx, show_progress) @@ -627,6 +627,14 @@ impl Provider for TestArgs { dict.insert("etherscan_api_key".to_string(), etherscan_api_key.to_string().into()); } + if self.show_progress { + dict.insert("show_progress".to_string(), true.into()); + } + + if let Some(threads) = self.threads { + dict.insert("threads".to_string(), threads.into()); + } + Ok(Map::from([(Config::selected_profile(), dict)])) } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index ede77beb067c9..699d48caf5148 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -66,6 +66,8 @@ forgetest!(can_extract_config_values, |prj, cmd| { path_pattern_inverse: None, coverage_pattern_inverse: None, test_failures_file: "test-cache/test-failures".into(), + threads: None, + show_progress: false, fuzz: FuzzConfig { runs: 1000, max_test_rejects: 100203, From eff3f43577e1dd3bc14d9256dacc5f766bfec447 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 4 Jul 2024 23:06:03 +0200 Subject: [PATCH 1213/1963] test: relax unix time test once again (#8362) --- testdata/default/cheats/UnixTime.t.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testdata/default/cheats/UnixTime.t.sol b/testdata/default/cheats/UnixTime.t.sol index 786c1ef5929db..a6b683967fa79 100644 --- a/testdata/default/cheats/UnixTime.t.sol +++ b/testdata/default/cheats/UnixTime.t.sol @@ -8,21 +8,21 @@ contract UnixTimeTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); // This is really wide because CI sucks. - uint256 constant errMargin = 500; + uint256 constant errMargin = 1000; function testUnixTimeAgainstDate() public { string[] memory inputs = new string[](2); inputs[0] = "date"; - // OS X does not support precision more than 1 second + // OS X does not support precision more than 1 second. inputs[1] = "+%s000"; bytes memory res = vm.ffi(inputs); uint256 date = vm.parseUint(string(res)); - // Limit precision to 1000 ms + // Limit precision to 1000 ms. uint256 time = vm.unixTime() / 1000 * 1000; - assertEq(date, time, ".unixTime() is inaccurate"); + vm.assertApproxEqAbs(date, time, errMargin, ".unixTime() is inaccurate vs date"); } function testUnixTime() public { From 56dbd20c7179570c53b6c17ff34daa7273a4ddae Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 5 Jul 2024 01:09:07 +0200 Subject: [PATCH 1214/1963] fix(cheatcodes): overflow in randomNumber w/range (#8361) --- crates/cheatcodes/src/utils.rs | 9 +++++++-- testdata/default/cheats/RandomUint.t.sol | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 8bea510eb9a7c..08e2553417145 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -162,8 +162,13 @@ impl Cheatcode for randomUint_1Call { ensure!(min <= max, "min must be less than or equal to max"); // Generate random between range min..=max let mut rng = rand::thread_rng(); - let range = max - min + U256::from(1); - let random_number = rng.gen::() % range + min; + let exclusive_modulo = max - min; + let mut random_number = rng.gen::(); + if exclusive_modulo != U256::MAX { + let inclusive_modulo = exclusive_modulo + U256::from(1); + random_number %= inclusive_modulo; + } + random_number += min; Ok(random_number.abi_encode()) } } diff --git a/testdata/default/cheats/RandomUint.t.sol b/testdata/default/cheats/RandomUint.t.sol index 287f8821992b3..e679f9bfd9688 100644 --- a/testdata/default/cheats/RandomUint.t.sol +++ b/testdata/default/cheats/RandomUint.t.sol @@ -7,27 +7,27 @@ import "cheats/Vm.sol"; contract RandomUint is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - // All tests use `>=` and `<=` to verify that ranges are inclusive and that - // a value of zero may be generated. function testRandomUint() public { - uint256 rand = vm.randomUint(); - assertTrue(rand >= 0); + vm.randomUint(); } - function testRandomUint(uint256 min, uint256 max) public { - vm.assume(max >= min); - uint256 rand = vm.randomUint(min, max); - assertTrue(rand >= min, "rand >= min"); - assertTrue(rand <= max, "rand <= max"); + function testRandomUintRangeOverflow() public { + vm.randomUint(0, uint256(int256(-1))); } - function testRandomUint(uint256 val) public { + function testRandomUintSame(uint256 val) public { uint256 rand = vm.randomUint(val, val); assertTrue(rand == val); } + function testRandomUintRange(uint256 min, uint256 max) public { + vm.assume(max >= min); + uint256 rand = vm.randomUint(min, max); + assertTrue(rand >= min, "rand >= min"); + assertTrue(rand <= max, "rand <= max"); + } + function testRandomAddress() public { - address rand = vm.randomAddress(); - assertTrue(rand >= address(0)); + vm.randomAddress(); } } From 9048dbfa01823b42eabd9893c089f8b79fd799ef Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 5 Jul 2024 04:48:01 +0300 Subject: [PATCH 1215/1963] fix: flaky assertion test (#8363) --- testdata/default/cheats/Assert.t.sol | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/testdata/default/cheats/Assert.t.sol b/testdata/default/cheats/Assert.t.sol index b33af6292ce31..971bb5e27cf7d 100644 --- a/testdata/default/cheats/Assert.t.sol +++ b/testdata/default/cheats/Assert.t.sol @@ -53,16 +53,12 @@ contract AssertionsTest is DSTest { } function _formatWithDecimals(int256 value, uint256 decimals) internal returns (string memory) { - string memory intPart = vm.toString(value / int256(10 ** decimals)); - int256 mod = value % int256(10 ** decimals); - string memory decimalPart = vm.toString(mod > 0 ? mod : -mod); - - // Add - if we have something like 0.123 - if ((value < 0) && keccak256(abi.encode(intPart)) == keccak256(abi.encode("0"))) { - intPart = string.concat("-", intPart); + string memory formatted = _formatWithDecimals(_abs(value), decimals); + if (value < 0) { + formatted = string.concat("-", formatted); } - return _prefixDecWithZeroes(intPart, decimalPart, decimals); + return formatted; } function testFuzzAssertEqNotEq(uint256 left, uint256 right, uint256 decimals) public { From 480db91db9c52eb437c007fbe26903553f2ba0b4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 5 Jul 2024 07:42:53 +0200 Subject: [PATCH 1216/1963] docs: fix doc lint (#8364) * docs: fix doc lint * escape quote --- crates/debugger/src/tui/draw.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 956e4fdd4ebb9..3d22bf30528a4 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -682,13 +682,14 @@ struct BufferAccesses { /// The memory_access variable stores the index on the stack that indicates the buffer /// offset/size accessed by the given opcode: -/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) -/// >= 1: the stack index -/// 0: no memory access -/// -1: a fixed size of 32 bytes -/// -2: a fixed size of 1 byte +/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) +/// \>= 1: the stack index +/// 0: no memory access +/// -1: a fixed size of 32 bytes +/// -2: a fixed size of 1 byte +/// /// The return value is a tuple about accessed buffer region by the given opcode: -/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) +/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { let buffer_access = match op { opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => { From 09306b31d45049e3cce56ccfc0d5ecf0c5f113d0 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 5 Jul 2024 07:55:36 +0200 Subject: [PATCH 1217/1963] feat(traces): use `TraceWriter`, delegating the formatting of the print trace to `revm-inspectors` (#8224) * change to fork * update fork * add mutability to extend call traces, add decoder.decode * clippy fixes * extend_trace -> extend_traces * update to latest rev * add docs * remove redundant clone * clean up * ignore ts_get_internal_operations_contract_selfdestruct_london for now as it is not supported by revm-inspector, uses &mut and only pass into the trace extender what is necessary * fix clippy * fix: otterscan selfdestruct * bump revm-inspectors * split decode_trace_arena and render_trace_arena * revert unnecessary LogData -> CallLog change * convert render_trace_arena to sync * Update crates/forge/bin/cmd/test/mod.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * move clone to inside should_include * fix clippy * unify DecodedCallTrace and DecodedCallLog<'a> into DecodedItem<'a> * fix clippy * clone * rm * unify * chore: simplify precompiles --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 1 - crates/chisel/src/dispatcher.rs | 6 +- crates/chisel/src/runner.rs | 4 +- crates/cli/src/utils/cmd.rs | 6 +- crates/evm/traces/Cargo.toml | 1 - crates/evm/traces/src/decoder/mod.rs | 73 +++--- crates/evm/traces/src/decoder/precompiles.rs | 22 +- crates/evm/traces/src/lib.rs | 242 ++----------------- crates/forge/bin/cmd/test/mod.rs | 11 +- crates/forge/src/gas_report.rs | 8 +- crates/forge/tests/it/config.rs | 22 +- crates/forge/tests/it/repros.rs | 2 +- crates/script/src/execute.rs | 5 +- crates/script/src/simulate.rs | 12 +- 14 files changed, 110 insertions(+), 305 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64a30260d834b..18b3b86d419ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3988,7 +3988,6 @@ dependencies = [ "tempfile", "tokio", "tracing", - "yansi", ] [[package]] diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 5c13c8e01f8d5..909b7525c9f53 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -17,6 +17,7 @@ use foundry_config::{Config, RpcEndpoint}; use foundry_evm::{ decode::decode_console_logs, traces::{ + decode_trace_arena, identifier::{SignaturesIdentifier, TraceIdentifiers}, render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, @@ -932,10 +933,11 @@ impl ChiselDispatcher { } println!("{}", "Traces:".green()); - for (kind, trace) in &result.traces { + for (kind, trace) in &mut result.traces { // Display all Setup + Execution traces. if matches!(kind, TraceKind::Setup | TraceKind::Execution) { - println!("{}", render_trace_arena(trace, decoder).await?); + decode_trace_arena(trace, decoder).await?; + println!("{}", render_trace_arena(trace)); } } diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index 35fd167733680..e78454ee363b5 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -7,7 +7,7 @@ use alloy_primitives::{Address, Bytes, Log, U256}; use eyre::Result; use foundry_evm::{ executors::{DeployResult, Executor, RawCallResult}, - traces::{CallTraceArena, TraceKind}, + traces::{TraceKind, Traces}, }; use revm::interpreter::{return_ok, InstructionResult}; use std::collections::HashMap; @@ -39,7 +39,7 @@ pub struct ChiselResult { /// Transaction logs pub logs: Vec, /// Call traces - pub traces: Vec<(TraceKind, CallTraceArena)>, + pub traces: Traces, /// Amount of gas used in the transaction pub gas_used: u64, /// Map of addresses to their labels diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 48847f84d20a1..7b6bd70e2b51c 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -14,6 +14,7 @@ use foundry_evm::{ executors::{DeployResult, EvmError, RawCallResult}, opts::EvmOpts, traces::{ + decode_trace_arena, identifier::{EtherscanIdentifier, SignaturesIdentifier}, render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, @@ -397,11 +398,12 @@ pub async fn handle_traces( } pub async fn print_traces(result: &mut TraceResult, decoder: &CallTraceDecoder) -> Result<()> { - let traces = result.traces.as_ref().expect("No traces found"); + let traces = result.traces.as_mut().expect("No traces found"); println!("Traces:"); for (_, arena) in traces { - println!("{}", render_trace_arena(arena, decoder).await?); + decode_trace_arena(arena, decoder).await?; + println!("{}", render_trace_arena(arena)); } println!(); diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index dfb3cbe7f7419..25cd93213f1c1 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -38,7 +38,6 @@ once_cell.workspace = true serde.workspace = true tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true -yansi.workspace = true rustc-hash.workspace = true tempfile.workspace = true diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 0b452f0834089..ef0bd6bcde5dc 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -2,7 +2,7 @@ use crate::{ identifier::{ AddressIdentity, LocalTraceIdentifier, SingleSignaturesIdentifier, TraceIdentifier, }, - CallTrace, CallTraceArena, CallTraceNode, DecodedCallData, DecodedCallLog, DecodedCallTrace, + CallTrace, CallTraceArena, CallTraceNode, DecodedCallData, }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Error, Event, Function, JsonAbi}; @@ -20,6 +20,7 @@ use foundry_evm_core::{ }; use itertools::Itertools; use once_cell::sync::OnceCell; +use revm_inspectors::tracing::types::{DecodedCallLog, DecodedCallTrace}; use rustc_hash::FxHashMap; use std::collections::{hash_map::Entry, BTreeMap, HashMap}; @@ -291,31 +292,33 @@ impl CallTraceDecoder { } } + /// Populates the traces with decoded data by mutating the + /// [CallTrace] in place. See [CallTraceDecoder::decode_function] and + /// [CallTraceDecoder::decode_event] for more details. + pub async fn populate_traces(&self, traces: &mut Vec) { + for node in traces { + node.trace.decoded = self.decode_function(&node.trace).await; + for log in node.logs.iter_mut() { + log.decoded = self.decode_event(&log.raw_log).await; + } + } + } + + /// Decodes a call trace. pub async fn decode_function(&self, trace: &CallTrace) -> DecodedCallTrace { - // Decode precompile - if let Some((label, func)) = precompiles::decode(trace, 1) { - return DecodedCallTrace { - label: Some(label), - return_data: None, - contract: None, - func: Some(func), - }; + if let Some(trace) = precompiles::decode(trace, 1) { + return trace; } - // Set label let label = self.labels.get(&trace.address).cloned(); - // Set contract name - let contract = self.contracts.get(&trace.address).cloned(); - let cdata = &trace.data; if trace.address == DEFAULT_CREATE2_DEPLOYER { return DecodedCallTrace { label, + call_data: Some(DecodedCallData { signature: "create2".to_string(), args: vec![] }), return_data: (!trace.status.is_ok()) .then(|| self.revert_decoder.decode(&trace.output, Some(trace.status))), - contract, - func: Some(DecodedCallData { signature: "create2".to_string(), args: vec![] }), }; } @@ -336,14 +339,13 @@ impl CallTraceDecoder { } }; let [func, ..] = &functions[..] else { - return DecodedCallTrace { label, return_data: None, contract, func: None }; + return DecodedCallTrace { label, call_data: None, return_data: None }; }; DecodedCallTrace { label, - func: Some(self.decode_function_input(trace, func)), + call_data: Some(self.decode_function_input(trace, func)), return_data: self.decode_function_output(trace, functions), - contract, } } else { let has_receive = self.receive_contracts.contains(&trace.address); @@ -352,13 +354,12 @@ impl CallTraceDecoder { let args = if cdata.is_empty() { Vec::new() } else { vec![cdata.to_string()] }; DecodedCallTrace { label, + call_data: Some(DecodedCallData { signature, args }), return_data: if !trace.success { Some(self.revert_decoder.decode(&trace.output, Some(trace.status))) } else { None }, - contract, - func: Some(DecodedCallData { signature, args }), } } } @@ -533,8 +534,8 @@ impl CallTraceDecoder { } /// Decodes an event. - pub async fn decode_event<'a>(&self, log: &'a LogData) -> DecodedCallLog<'a> { - let &[t0, ..] = log.topics() else { return DecodedCallLog::Raw(log) }; + pub async fn decode_event(&self, log: &LogData) -> DecodedCallLog { + let &[t0, ..] = log.topics() else { return DecodedCallLog { name: None, params: None } }; let mut events = Vec::new(); let events = match self.events.get(&(t0, log.topics().len() - 1)) { @@ -551,22 +552,24 @@ impl CallTraceDecoder { for event in events { if let Ok(decoded) = event.decode_log(log, false) { let params = reconstruct_params(event, &decoded); - return DecodedCallLog::Decoded( - event.name.clone(), - params - .into_iter() - .zip(event.inputs.iter()) - .map(|(param, input)| { - // undo patched names - let name = input.name.clone(); - (name, self.apply_label(¶m)) - }) - .collect(), - ); + return DecodedCallLog { + name: Some(event.name.clone()), + params: Some( + params + .into_iter() + .zip(event.inputs.iter()) + .map(|(param, input)| { + // undo patched names + let name = input.name.clone(); + (name, self.apply_label(¶m)) + }) + .collect(), + ), + }; } } - DecodedCallLog::Raw(log) + DecodedCallLog { name: None, params: None } } /// Prefetches function and event signatures into the identifier cache diff --git a/crates/evm/traces/src/decoder/precompiles.rs b/crates/evm/traces/src/decoder/precompiles.rs index 17c92ba6c1189..654bc194aed53 100644 --- a/crates/evm/traces/src/decoder/precompiles.rs +++ b/crates/evm/traces/src/decoder/precompiles.rs @@ -2,6 +2,7 @@ use crate::{CallTrace, DecodedCallData}; use alloy_primitives::{hex, B256, U256}; use alloy_sol_types::{abi, sol, SolCall}; use itertools::Itertools; +use revm_inspectors::tracing::types::DecodedCallTrace; sol! { /// EVM precompiles interface. For illustration purposes only, as precompiles don't follow the @@ -42,16 +43,14 @@ macro_rules! tri { } /// Tries to decode a precompile call. Returns `Some` if successful. -pub(super) fn decode(trace: &CallTrace, _chain_id: u64) -> Option<(String, DecodedCallData)> { - let [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, x @ 0x01..=0x0a] = - trace.address.0 .0 - else { - return None - }; +pub(super) fn decode(trace: &CallTrace, _chain_id: u64) -> Option { + if !trace.address[..19].iter().all(|&x| x == 0) { + return None; + } let data = &trace.data; - let (signature, args) = match x { + let (signature, args) = match trace.address.last().unwrap() { 0x01 => { let (sig, ecrecoverCall { hash, v, r, s }) = tri!(abi_decode_call(data)); (sig, vec![hash.to_string(), v.to_string(), r.to_string(), s.to_string()]) @@ -71,10 +70,15 @@ pub(super) fn decode(trace: &CallTrace, _chain_id: u64) -> Option<(String, Decod 0x08 => (ecpairingCall::SIGNATURE, tri!(decode_ecpairing(data))), 0x09 => (blake2fCall::SIGNATURE, tri!(decode_blake2f(data))), 0x0a => (pointEvaluationCall::SIGNATURE, tri!(decode_kzg(data))), - 0x00 | 0x0b.. => unreachable!(), + 0x00 | 0x0b.. => return None, }; - Some(("PRECOMPILES".into(), DecodedCallData { signature: signature.to_string(), args })) + Some(DecodedCallTrace { + label: Some("PRECOMPILES".to_string()), + call_data: Some(DecodedCallData { signature: signature.to_string(), args }), + // TODO: Decode return data too. + return_data: None, + }) } // Note: we use the ABI decoder, but this is not necessarily ABI-encoded data. It's just a diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 35106b61ba90e..3b53fbafbe970 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -8,19 +8,16 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{hex, LogData}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; -use foundry_evm_core::constants::CHEATCODE_ADDRESS; -use futures::{future::BoxFuture, FutureExt}; -use revm_inspectors::tracing::types::TraceMemberOrder; use serde::{Deserialize, Serialize}; -use std::fmt::Write; -use yansi::{Color, Paint}; pub use revm_inspectors::tracing::{ - types::{CallKind, CallTrace, CallTraceNode}, + types::{ + CallKind, CallLog, CallTrace, CallTraceNode, DecodedCallData, DecodedCallLog, + DecodedCallTrace, + }, CallTraceArena, FourByteInspector, GethTraceBuilder, ParityTraceBuilder, StackSnapshotType, - TracingInspector, TracingInspectorConfig, + TraceWriter, TracingInspector, TracingInspectorConfig, }; /// Call trace address identifiers. @@ -34,220 +31,24 @@ pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; pub type Traces = Vec<(TraceKind, CallTraceArena)>; -#[derive(Default, Debug, Eq, PartialEq)] -pub struct DecodedCallData { - pub signature: String, - pub args: Vec, -} - -#[derive(Default, Debug)] -pub struct DecodedCallTrace { - pub label: Option, - pub return_data: Option, - pub func: Option, - pub contract: Option, -} - -#[derive(Debug)] -pub enum DecodedCallLog<'a> { - /// A raw log. - Raw(&'a LogData), - /// A decoded log. - /// - /// The first member of the tuple is the event name, and the second is a vector of decoded - /// parameters. - Decoded(String, Vec<(String, String)>), -} - -const PIPE: &str = " │ "; -const EDGE: &str = " └─ "; -const BRANCH: &str = " ├─ "; -const CALL: &str = "→ "; -const RETURN: &str = "← "; - -/// Render a collection of call traces. +/// Decode a collection of call traces. /// /// The traces will be decoded using the given decoder, if possible. -pub async fn render_trace_arena( - arena: &CallTraceArena, +pub async fn decode_trace_arena( + arena: &mut CallTraceArena, decoder: &CallTraceDecoder, -) -> Result { +) -> Result<(), std::fmt::Error> { decoder.prefetch_signatures(arena.nodes()).await; + decoder.populate_traces(arena.nodes_mut()).await; - fn inner<'a>( - arena: &'a [CallTraceNode], - decoder: &'a CallTraceDecoder, - s: &'a mut String, - idx: usize, - left: &'a str, - child: &'a str, - ) -> BoxFuture<'a, Result<(), std::fmt::Error>> { - async move { - let node = &arena[idx]; - - // Display trace header - let (trace, return_data) = render_trace(&node.trace, decoder).await?; - writeln!(s, "{left}{trace}")?; - - // Display logs and subcalls - let left_prefix = format!("{child}{BRANCH}"); - let right_prefix = format!("{child}{PIPE}"); - for child in &node.ordering { - match child { - TraceMemberOrder::Log(index) => { - let log = render_trace_log(&node.logs[*index].raw_log, decoder).await?; - - // Prepend our tree structure symbols to each line of the displayed log - log.lines().enumerate().try_for_each(|(i, line)| { - writeln!( - s, - "{}{}", - if i == 0 { &left_prefix } else { &right_prefix }, - line - ) - })?; - } - TraceMemberOrder::Call(index) => { - inner( - arena, - decoder, - s, - node.children[*index], - &left_prefix, - &right_prefix, - ) - .await?; - } - TraceMemberOrder::Step(_) => {} - } - } - - // Display trace return data - let color = trace_color(&node.trace); - write!( - s, - "{child}{EDGE}{}{}", - RETURN.fg(color), - format!("[{:?}] ", node.trace.status).fg(color) - )?; - match return_data { - Some(val) => write!(s, "{val}"), - None if node.trace.kind.is_any_create() => { - write!(s, "{} bytes of code", node.trace.output.len()) - } - None if node.trace.output.is_empty() => Ok(()), - None => write!(s, "{}", node.trace.output), - }?; - writeln!(s)?; - - Ok(()) - } - .boxed() - } - - let mut s = String::new(); - inner(arena.nodes(), decoder, &mut s, 0, " ", " ").await?; - Ok(s) -} - -/// Render a call trace. -/// -/// The trace will be decoded using the given decoder, if possible. -pub async fn render_trace( - trace: &CallTrace, - decoder: &CallTraceDecoder, -) -> Result<(String, Option), std::fmt::Error> { - let mut s = String::new(); - write!(&mut s, "[{}] ", trace.gas_used)?; - let address = trace.address.to_checksum(None); - - let decoded = decoder.decode_function(trace).await; - if trace.kind.is_any_create() { - write!( - &mut s, - "{}{} {}@{}", - CALL.yellow(), - "new".yellow(), - decoded.label.as_deref().unwrap_or(""), - address - )?; - } else { - let (func_name, inputs) = match &decoded.func { - Some(DecodedCallData { signature, args }) => { - let name = signature.split('(').next().unwrap(); - (name.to_string(), args.join(", ")) - } - None => { - debug!(target: "evm::traces", trace=?trace, "unhandled raw calldata"); - if trace.data.len() < 4 { - ("fallback".to_string(), hex::encode(&trace.data)) - } else { - let (selector, data) = trace.data.split_at(4); - (hex::encode(selector), hex::encode(data)) - } - } - }; - - let action = match trace.kind { - CallKind::Call => "", - CallKind::StaticCall => " [staticcall]", - CallKind::CallCode => " [callcode]", - CallKind::DelegateCall => " [delegatecall]", - CallKind::Create | CallKind::Create2 => unreachable!(), - CallKind::AuthCall => " [authcall]", - }; - - let color = trace_color(trace); - write!( - &mut s, - "{addr}::{func_name}{opt_value}({inputs}){action}", - addr = decoded.label.as_deref().unwrap_or(&address).fg(color), - func_name = func_name.fg(color), - opt_value = if trace.value.is_zero() { - String::new() - } else { - format!("{{value: {}}}", trace.value) - }, - action = action.yellow(), - )?; - } - - Ok((s, decoded.return_data)) + Ok(()) } -/// Render a trace log. -async fn render_trace_log( - log: &LogData, - decoder: &CallTraceDecoder, -) -> Result { - let mut s = String::new(); - let decoded = decoder.decode_event(log).await; - - match decoded { - DecodedCallLog::Raw(log) => { - for (i, topic) in log.topics().iter().enumerate() { - writeln!( - s, - "{:>13}: {}", - if i == 0 { "emit topic 0".to_string() } else { format!("topic {i}") }, - format!("{topic:?}").cyan() - )?; - } - - write!(s, " data: {}", hex::encode_prefixed(&log.data).cyan())?; - } - DecodedCallLog::Decoded(name, params) => { - let params = params - .iter() - .map(|(name, value)| format!("{name}: {value}")) - .collect::>() - .join(", "); - - write!(s, "emit {}({params})", name.cyan())?; - } - } - - Ok(s) +/// Render a collection of call traces to a string. +pub fn render_trace_arena(arena: &CallTraceArena) -> String { + let mut w = TraceWriter::new(Vec::::new()); + w.write_arena(arena).expect("Failed to write traces"); + String::from_utf8(w.into_writer()).expect("trace writer wrote invalid UTF-8") } /// Specifies the kind of trace. @@ -284,17 +85,6 @@ impl TraceKind { } } -/// Chooses the color of the trace depending on the destination address and status of the call. -fn trace_color(trace: &CallTrace) -> Color { - if trace.address == CHEATCODE_ADDRESS { - Color::Blue - } else if trace.success { - Color::Green - } else { - Color::Red - } -} - /// Given a list of traces and artifacts, it returns a map connecting address to abi pub fn load_contracts<'a>( traces: impl IntoIterator, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index f80227668f201..00659b6734a30 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -7,7 +7,10 @@ use forge::{ gas_report::GasReport, multi_runner::matches_contract, result::{SuiteResult, TestOutcome, TestStatus}, - traces::{identifier::SignaturesIdentifier, CallTraceDecoderBuilder, TraceKind}, + traces::{ + decode_trace_arena, identifier::SignaturesIdentifier, render_trace_arena, + CallTraceDecoderBuilder, TraceKind, + }, MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, TestOptionsBuilder, }; use foundry_cli::{ @@ -49,7 +52,6 @@ mod summary; use summary::TestSummaryReporter; pub use filter::FilterArgs; -use forge::traces::render_trace_arena; // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); @@ -474,7 +476,7 @@ impl TestArgs { // Identify addresses and decode traces. let mut decoded_traces = Vec::with_capacity(result.traces.len()); - for (kind, arena) in &result.traces { + for (kind, arena) in &mut result.traces.clone() { if identify_addresses { decoder.identify(arena, &mut identifier); } @@ -495,7 +497,8 @@ impl TestArgs { }; if should_include { - decoded_traces.push(render_trace_arena(arena, &decoder).await?); + decode_trace_arena(arena, &decoder).await?; + decoded_traces.push(render_trace_arena(arena)); } } diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index bec7402ba1e9d..56f59fffc7771 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -89,21 +89,21 @@ impl GasReport { return; } - let decoded = decoder.decode_function(&node.trace).await; - - let Some(name) = &decoded.contract else { return }; + let Some(name) = decoder.contracts.get(&node.trace.address) else { return }; let contract_name = name.rsplit(':').next().unwrap_or(name); if !self.should_report(contract_name) { return; } + let decoded = || decoder.decode_function(&node.trace); + let contract_info = self.contracts.entry(name.to_string()).or_default(); if trace.kind.is_any_create() { trace!(contract_name, "adding create gas info"); contract_info.gas = trace.gas_used; contract_info.size = trace.data.len(); - } else if let Some(DecodedCallData { signature, .. }) = decoded.func { + } else if let Some(DecodedCallData { signature, .. }) = decoded().await.call_data { let name = signature.split('(').next().unwrap(); // ignore any test/setup functions if !name.test_function_kind().is_known() { diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 17087e5da5ef4..21f0d2e17260d 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -7,7 +7,7 @@ use forge::{ use foundry_evm::{ decode::decode_console_logs, revm::primitives::SpecId, - traces::{render_trace_arena, CallTraceDecoderBuilder}, + traces::{decode_trace_arena, render_trace_arena, CallTraceDecoderBuilder}, }; use foundry_test_utils::{init_tracing, Filter}; use futures::future::join_all; @@ -65,7 +65,7 @@ impl TestConfig { eyre::bail!("empty test result"); } for (_, SuiteResult { test_results, .. }) in suite_result { - for (test_name, result) in test_results { + for (test_name, mut result) in test_results { if self.should_fail && (result.status == TestStatus::Success) || !self.should_fail && (result.status == TestStatus::Failure) { @@ -74,16 +74,18 @@ impl TestConfig { let call_trace_decoder = CallTraceDecoderBuilder::default() .with_known_contracts(&self.runner.known_contracts) .build(); - let decoded_traces = join_all( - result - .traces - .iter() - .map(|(_, a)| render_trace_arena(a, &call_trace_decoder)), - ) + let decoded_traces = join_all(result.traces.iter_mut().map(|(_, arena)| { + let decoder = &call_trace_decoder; + async move { + decode_trace_arena(arena, decoder) + .await + .expect("Failed to decode traces"); + render_trace_arena(arena) + } + })) .await .into_iter() - .map(|x| x.unwrap()) - .collect::>(); + .collect::>(); eyre::bail!( "Test {} did not {} as expected.\nReason: {:?}\nLogs:\n{}\n\nTraces:\n{}", test_name, diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 94a06c48845f7..b251c3d911efa 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -278,7 +278,7 @@ test_repro!(6501, false, None, |res| { assert_eq!(trace.depth, 1); assert!(trace.success); assert_eq!( - decoded.func, + decoded.call_data, Some(DecodedCallData { signature: expected.0.into(), args: expected.1.into_iter().map(ToOwned::to_owned).collect(), diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 3552e3977f97d..bfa9de0d2bc1c 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -24,6 +24,7 @@ use foundry_evm::{ decode::decode_console_logs, inspectors::cheatcodes::BroadcastableTransactions, traces::{ + decode_trace_arena, identifier::{SignaturesIdentifier, TraceIdentifiers}, render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, @@ -428,7 +429,9 @@ impl PreSimulationState { } || !result.success; if should_include { - shell::println(render_trace_arena(trace, decoder).await?)?; + let mut trace = trace.clone(); + decode_trace_arena(&mut trace, decoder).await?; + shell::println(render_trace_arena(&trace))?; } } shell::println(String::new())?; diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index d2546cda3899a..4a5f44117320c 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -18,7 +18,7 @@ use eyre::{Context, Result}; use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; use foundry_cli::utils::{has_different_gas_calc, now}; use foundry_common::{get_contract_name, shell, ContractData}; -use foundry_evm::traces::render_trace_arena; +use foundry_evm::traces::{decode_trace_arena, render_trace_arena}; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; use std::{ @@ -154,15 +154,13 @@ impl PreSimulationState { let mut abort = false; for res in join_all(futs).await { - let (tx, traces) = res?; + let (tx, mut traces) = res?; // Transaction will be `None`, if execution didn't pass. if tx.is_none() || self.script_config.evm_opts.verbosity > 3 { - for (_, trace) in &traces { - println!( - "{}", - render_trace_arena(trace, &self.execution_artifacts.decoder).await? - ); + for (_, trace) in &mut traces { + decode_trace_arena(trace, &self.execution_artifacts.decoder).await?; + println!("{}", render_trace_arena(trace)); } } From 642f13f5b0cdac4c0b83b1fecade8393febe1c33 Mon Sep 17 00:00:00 2001 From: Federico Magnani <83358457+fedemagnani@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:12:33 +0200 Subject: [PATCH 1218/1963] feat(anvil): use Alloy otterscan types (#8318) * deprecate src/eth/otterscan/types.rs * fmt * Revert "fmt" This reverts commit bf1969f19c9009710eb5e08b26f3ae9f2070b3eb. * (less) fmt * requested changes * CallType into String * clippy + comment --------- Co-authored-by: drun Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Matthias Seitz --- crates/anvil/core/src/eth/transaction/mod.rs | 47 ++- crates/anvil/src/eth/backend/mem/storage.rs | 34 +- crates/anvil/src/eth/otterscan/api.rs | 259 +++++++++++-- crates/anvil/src/eth/otterscan/mod.rs | 1 - crates/anvil/src/eth/otterscan/types.rs | 360 ------------------- crates/anvil/tests/it/otterscan.rs | 60 ++-- 6 files changed, 315 insertions(+), 446 deletions(-) delete mode 100644 crates/anvil/src/eth/otterscan/types.rs diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 13207a936ab09..dc758a52aad75 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -10,8 +10,8 @@ use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ - request::TransactionRequest, AccessList, AnyTransactionReceipt, ConversionError, - Signature as RpcSignature, Transaction as RpcTransaction, TransactionReceipt, + request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, AnyTransactionReceipt, + ConversionError, Signature as RpcSignature, Transaction as RpcTransaction, TransactionReceipt, }; use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; @@ -70,7 +70,7 @@ pub fn transaction_request_to_typed( gas_limit: gas.unwrap_or_default(), is_system_tx: other.get_deserialized::("isSystemTx")?.ok()?, input: input.into_input().unwrap_or_default(), - })) + })); } match ( @@ -198,7 +198,7 @@ impl MaybeImpersonatedTransaction { #[cfg(feature = "impersonated-tx")] pub fn recover(&self) -> Result { if let Some(sender) = self.impersonated_sender { - return Ok(sender) + return Ok(sender); } self.transaction.recover() } @@ -211,7 +211,7 @@ impl MaybeImpersonatedTransaction { pub fn hash(&self) -> B256 { if self.transaction.is_impersonated() { if let Some(sender) = self.impersonated_sender { - return self.transaction.impersonated_hash(sender) + return self.transaction.impersonated_hash(sender); } } self.transaction.hash() @@ -1016,7 +1016,7 @@ impl Decodable for TypedTransaction { // Legacy TX if header.list { - return Ok(TxEnvelope::decode(buf)?.into()) + return Ok(TxEnvelope::decode(buf)?.into()); } // Check byte after header @@ -1062,7 +1062,7 @@ impl Encodable2718 for TypedTransaction { impl Decodable2718 for TypedTransaction { fn typed_decode(ty: u8, buf: &mut &[u8]) -> Result { if ty == 0x7E { - return Ok(Self::Deposit(DepositTransaction::decode(buf)?)) + return Ok(Self::Deposit(DepositTransaction::decode(buf)?)); } match TxEnvelope::typed_decode(ty, buf)? { TxEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)), @@ -1245,6 +1245,37 @@ impl TypedReceipt { } } +impl From> for ReceiptWithBloom { + fn from(value: TypedReceipt) -> Self { + match value { + TypedReceipt::Legacy(r) | + TypedReceipt::EIP1559(r) | + TypedReceipt::EIP2930(r) | + TypedReceipt::EIP4844(r) => r, + TypedReceipt::Deposit(r) => r.inner, + } + } +} + +impl From> for OtsReceipt { + fn from(value: TypedReceipt) -> Self { + let r#type = match value { + TypedReceipt::Legacy(_) => 0x00, + TypedReceipt::EIP2930(_) => 0x01, + TypedReceipt::EIP1559(_) => 0x02, + TypedReceipt::EIP4844(_) => 0x03, + TypedReceipt::Deposit(_) => 0x7E, + } as u8; + let receipt = ReceiptWithBloom::::from(value); + let status = receipt.status(); + let cumulative_gas_used = receipt.cumulative_gas_used() as u64; + let logs = receipt.receipt.logs.into_iter().map(|x| x.inner).collect(); + let logs_bloom = receipt.logs_bloom; + + Self { status, cumulative_gas_used, logs: Some(logs), logs_bloom: Some(logs_bloom), r#type } + } +} + impl TypedReceipt { pub fn cumulative_gas_used(&self) -> u128 { self.as_receipt_with_bloom().cumulative_gas_used() @@ -1395,7 +1426,7 @@ impl Encodable2718 for TypedReceipt { impl Decodable2718 for TypedReceipt { fn typed_decode(ty: u8, buf: &mut &[u8]) -> Result { if ty == 0x7E { - return Ok(Self::Deposit(DepositReceipt::decode(buf)?)) + return Ok(Self::Deposit(DepositReceipt::decode(buf)?)); } match ReceiptEnvelope::typed_decode(ty, buf)? { ReceiptEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)), diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 312c529d610c2..8a92e242df802 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -14,6 +14,7 @@ use alloy_rpc_types::{ FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingOptions, GethTrace, NoopFrame, }, + otterscan::{InternalOperation, OperationType}, parity::LocalizedTransactionTrace, }, BlockId, BlockNumberOrTag, TransactionInfo as RethTransactionInfo, @@ -25,7 +26,9 @@ use anvil_core::eth::{ use anvil_rpc::error::RpcError; use foundry_evm::{ revm::primitives::Env, - traces::{FourByteInspector, GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig}, + traces::{ + CallKind, FourByteInspector, GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig, + }, }; use parking_lot::RwLock; use std::{ @@ -164,7 +167,7 @@ impl InMemoryBlockStates { if let Some(state) = self.on_disk_states.get_mut(hash) { if let Some(cached) = self.disk_cache.read(*hash) { state.init_from_snapshot(cached); - return Some(state) + return Some(state); } } None @@ -426,6 +429,31 @@ impl MinedTransaction { }) } + pub fn ots_internal_operations(&self) -> Vec { + self.info + .traces + .iter() + .filter_map(|node| { + let r#type = match node.trace.kind { + _ if node.is_selfdestruct() => OperationType::OpSelfDestruct, + CallKind::Call if !node.trace.value.is_zero() => OperationType::OpTransfer, + CallKind::Create => OperationType::OpCreate, + CallKind::Create2 => OperationType::OpCreate2, + _ => return None, + }; + let mut from = node.trace.caller; + let mut to = node.trace.address; + let mut value = node.trace.value; + if node.is_selfdestruct() { + from = node.trace.address; + to = node.trace.selfdestruct_refund_target.unwrap_or_default(); + value = node.trace.selfdestruct_transferred_value.unwrap_or_default(); + } + Some(InternalOperation { r#type, from, to, value }) + }) + .collect() + } + pub fn geth_trace(&self, opts: GethDebugTracingOptions) -> Result { let GethDebugTracingOptions { config, tracer, tracer_config, .. } = opts; @@ -434,7 +462,7 @@ impl MinedTransaction { GethDebugTracerType::BuiltInTracer(tracer) => match tracer { GethDebugBuiltInTracerType::FourByteTracer => { let inspector = FourByteInspector::default(); - return Ok(FourByteFrame::from(inspector).into()) + return Ok(FourByteFrame::from(inspector).into()); } GethDebugBuiltInTracerType::CallTracer => { return match tracer_config.into_call_config() { diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 10b77377026ba..4609cc7ac809a 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -1,7 +1,3 @@ -use super::types::{ - OtsBlockDetails, OtsBlockTransactions, OtsContractCreator, OtsInternalOperation, - OtsSearchTransactions, OtsTrace, -}; use crate::eth::{ error::{BlockchainError, Result}, macros::node_info, @@ -9,11 +5,70 @@ use crate::eth::{ }; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_rpc_types::{ - trace::parity::{Action, CreateAction, CreateOutput, TraceOutput}, - Block, BlockId, BlockNumberOrTag as BlockNumber, + trace::{ + otterscan::{ + BlockDetails, ContractCreator, InternalOperation, OtsBlock, OtsBlockTransactions, + OtsReceipt, OtsTransactionReceipt, TraceEntry, TransactionsWithReceipts, + }, + parity::{ + Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, + RewardAction, TraceOutput, + }, + }, + Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, }; use itertools::Itertools; +use futures::future::join_all; + +pub fn mentions_address(trace: LocalizedTransactionTrace, address: Address) -> Option { + match (trace.trace.action, trace.trace.result) { + (Action::Call(CallAction { from, to, .. }), _) if from == address || to == address => { + trace.transaction_hash + } + (_, Some(TraceOutput::Create(CreateOutput { address: created_address, .. }))) + if created_address == address => + { + trace.transaction_hash + } + (Action::Create(CreateAction { from, .. }), _) if from == address => trace.transaction_hash, + (Action::Reward(RewardAction { author, .. }), _) if author == address => { + trace.transaction_hash + } + _ => None, + } +} + +/// Converts the list of traces for a transaction into the expected Otterscan format, as +/// specified in the [`ots_traceTransaction`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_tracetransaction) spec +pub fn batch_build_ots_traces(traces: Vec) -> Vec { + traces + .into_iter() + .filter_map(|trace| match trace.trace.action { + Action::Call(call) => { + let ots_type = match call.call_type { + CallType::Call => "CALL", + CallType::CallCode => "CALLCODE", + CallType::DelegateCall => "DELEGATECALL", + CallType::StaticCall => "STATICCALL", + CallType::AuthCall => "AUTHCALL", + CallType::None => "NONE", + } + .to_string(); + Some(TraceEntry { + r#type: ots_type, + depth: trace.trace.trace_address.len() as u32, + from: call.from, + to: call.to, + value: call.value, + input: call.input.0.into(), + }) + } + Action::Create(_) | Action::Selfdestruct(_) | Action::Reward(_) => None, + }) + .collect() +} + impl EthApi { /// Otterscan currently requires this endpoint, even though it's not part of the `ots_*`. /// Ref: @@ -37,15 +92,12 @@ impl EthApi { /// Trace internal ETH transfers, contracts creation (CREATE/CREATE2) and self-destructs for a /// certain transaction. - pub async fn ots_get_internal_operations( - &self, - hash: B256, - ) -> Result> { + pub async fn ots_get_internal_operations(&self, hash: B256) -> Result> { node_info!("ots_getInternalOperations"); self.backend .mined_transaction(hash) - .map(OtsInternalOperation::batch_build) + .map(|tx| tx.ots_internal_operations()) .ok_or_else(|| BlockchainError::DataUnavailable) } @@ -57,10 +109,10 @@ impl EthApi { } /// Trace a transaction and generate a trace call tree. - pub async fn ots_trace_transaction(&self, hash: B256) -> Result> { + pub async fn ots_trace_transaction(&self, hash: B256) -> Result> { node_info!("ots_traceTransaction"); - Ok(OtsTrace::batch_build(self.backend.trace_transaction(hash).await?)) + Ok(batch_build_ots_traces(self.backend.trace_transaction(hash).await?)) } /// Given a transaction hash, returns its raw revert reason. @@ -69,7 +121,7 @@ impl EthApi { if let Some(receipt) = self.backend.mined_transaction_receipt(hash) { if !receipt.inner.inner.as_receipt_with_bloom().receipt.status.coerce_status() { - return Ok(receipt.out.map(|b| b.0.into()).unwrap_or(Bytes::default())) + return Ok(receipt.out.map(|b| b.0.into()).unwrap_or(Bytes::default())); } } @@ -79,12 +131,11 @@ impl EthApi { /// For simplicity purposes, we return the entire block instead of emptying the values that /// Otterscan doesn't want. This is the original purpose of the endpoint (to save bandwidth), /// but it doesn't seem necessary in the context of an anvil node - pub async fn ots_get_block_details(&self, number: BlockNumber) -> Result { + pub async fn ots_get_block_details(&self, number: BlockNumber) -> Result { node_info!("ots_getBlockDetails"); if let Some(block) = self.backend.block_by_number(number).await? { - let ots_block = OtsBlockDetails::build(block, &self.backend).await?; - + let ots_block = self.build_ots_block_details(block).await?; Ok(ots_block) } else { Err(BlockchainError::BlockNotFound) @@ -94,12 +145,11 @@ impl EthApi { /// For simplicity purposes, we return the entire block instead of emptying the values that /// Otterscan doesn't want. This is the original purpose of the endpoint (to save bandwidth), /// but it doesn't seem necessary in the context of an anvil node - pub async fn ots_get_block_details_by_hash(&self, hash: B256) -> Result { + pub async fn ots_get_block_details_by_hash(&self, hash: B256) -> Result { node_info!("ots_getBlockDetailsByHash"); if let Some(block) = self.backend.block_by_hash(hash).await? { - let ots_block = OtsBlockDetails::build(block, &self.backend).await?; - + let ots_block = self.build_ots_block_details(block).await?; Ok(ots_block) } else { Err(BlockchainError::BlockNotFound) @@ -117,7 +167,7 @@ impl EthApi { node_info!("ots_getBlockTransactions"); match self.backend.block_by_number_full(number.into()).await? { - Some(block) => OtsBlockTransactions::build(block, &self.backend, page, page_size).await, + Some(block) => self.build_ots_block_tx(block, page, page_size).await, None => Err(BlockchainError::BlockNotFound), } } @@ -128,7 +178,7 @@ impl EthApi { address: Address, block_number: u64, page_size: usize, - ) -> Result { + ) -> Result { node_info!("ots_searchTransactionsBefore"); let best = self.backend.best_number(); @@ -147,11 +197,11 @@ impl EthApi { let hashes = traces .into_iter() .rev() - .filter_map(|trace| OtsSearchTransactions::mentions_address(trace, address)) + .filter_map(|trace| mentions_address(trace, address)) .unique(); if res.len() >= page_size { - break + break; } res.extend(hashes); @@ -162,7 +212,7 @@ impl EthApi { } } - OtsSearchTransactions::build(res, &self.backend, first_page, last_page).await + self.build_ots_search_transactions(res, first_page, last_page).await } /// Address history navigation. searches forward from certain point in time. @@ -171,7 +221,7 @@ impl EthApi { address: Address, block_number: u64, page_size: usize, - ) -> Result { + ) -> Result { node_info!("ots_searchTransactionsAfter"); let best = self.backend.best_number(); @@ -194,11 +244,11 @@ impl EthApi { let hashes = traces .into_iter() .rev() - .filter_map(|trace| OtsSearchTransactions::mentions_address(trace, address)) + .filter_map(|trace| mentions_address(trace, address)) .unique(); if res.len() >= page_size { - break + break; } res.extend(hashes); @@ -211,7 +261,7 @@ impl EthApi { // Results are always sent in reverse chronological order, according to the Otterscan spec res.reverse(); - OtsSearchTransactions::build(res, &self.backend, first_page, last_page).await + self.build_ots_search_transactions(res, first_page, last_page).await } /// Given a sender address and a nonce, returns the tx hash or null if not found. It returns @@ -231,7 +281,7 @@ impl EthApi { if let Some(txs) = self.backend.mined_transactions_by_block_number(n.into()).await { for tx in txs { if U256::from(tx.nonce) == nonce && tx.from == address { - return Ok(Some(tx.hash)) + return Ok(Some(tx.hash)); } } } @@ -242,10 +292,7 @@ impl EthApi { /// Given an ETH contract address, returns the tx hash and the direct address who created the /// contract. - pub async fn ots_get_contract_creator( - &self, - addr: Address, - ) -> Result> { + pub async fn ots_get_contract_creator(&self, addr: Address) -> Result> { node_info!("ots_getContractCreator"); let from = self.get_fork().map(|f| f.block_number()).unwrap_or_default(); @@ -260,10 +307,14 @@ impl EthApi { Action::Create(CreateAction { from, .. }), Some(TraceOutput::Create(CreateOutput { address, .. })), ) if address == addr => { - return Ok(Some(OtsContractCreator { - hash: trace.transaction_hash.unwrap(), - creator: from, - })) + let tx = self + .backend + .transaction_by_hash(trace.transaction_hash.unwrap()) + .await + .unwrap() + .unwrap() + .inner; + return Ok(Some(ContractCreator { tx, creator: from })); } _ => {} } @@ -273,4 +324,136 @@ impl EthApi { Ok(None) } + /// The response for ots_getBlockDetails includes an `issuance` object that requires computing + /// the total gas spent in a given block. + /// + /// The only way to do this with the existing API is to explicitly fetch all receipts, to get + /// their `gas_used`. This would be extremely inefficient in a real blockchain RPC, but we can + /// get away with that in this context. + /// + /// The [original spec](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) + /// also mentions we can hardcode `transactions` and `logsBloom` to an empty array to save + /// bandwidth, because fields weren't intended to be used in the Otterscan UI at this point. + /// + /// This has two problems though: + /// - It makes the endpoint too specific to Otterscan's implementation + /// - It breaks the abstraction built in `OtsBlock` which computes `transaction_count` + /// based on the existing list. + /// + /// Therefore we keep it simple by keeping the data in the response + pub async fn build_ots_block_details(&self, block: Block) -> Result { + if block.transactions.is_uncle() { + return Err(BlockchainError::DataUnavailable); + } + let receipts_futs = + block.transactions.hashes().map(|hash| async { self.transaction_receipt(*hash).await }); + + // fetch all receipts + let receipts = join_all(receipts_futs) + .await + .into_iter() + .map(|r| match r { + Ok(Some(r)) => Ok(r), + _ => Err(BlockchainError::DataUnavailable), + }) + .collect::>>()?; + + let total_fees = receipts + .iter() + .fold(0, |acc, receipt| acc + receipt.gas_used * receipt.effective_gas_price); + + Ok(BlockDetails { + block: block.into(), + total_fees: U256::from(total_fees), + // issuance has no meaningful value in anvil's backend. just default to 0 + issuance: Default::default(), + }) + } + + /// Fetches all receipts for the blocks's transactions, as required by the + /// [`ots_getBlockTransactions`] endpoint spec, and returns the final response object. + /// + /// [`ots_getBlockTransactions`]: https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails + pub async fn build_ots_block_tx( + &self, + mut block: Block, + page: usize, + page_size: usize, + ) -> Result { + if block.transactions.is_uncle() { + return Err(BlockchainError::DataUnavailable); + } + + block.transactions = match block.transactions { + BlockTransactions::Full(txs) => BlockTransactions::Full( + txs.into_iter().skip(page * page_size).take(page_size).collect(), + ), + BlockTransactions::Hashes(txs) => BlockTransactions::Hashes( + txs.into_iter().skip(page * page_size).take(page_size).collect(), + ), + BlockTransactions::Uncle => unreachable!(), + }; + + let receipt_futs = block.transactions.hashes().map(|hash| self.transaction_receipt(*hash)); + + let receipts = join_all(receipt_futs) + .await + .into_iter() + .map(|r| match r { + Ok(Some(r)) => { + let timestamp = + self.backend.get_block(r.block_number.unwrap()).unwrap().header.timestamp; + let receipt = r.map_inner(OtsReceipt::from); + let res = OtsTransactionReceipt { receipt, timestamp: Some(timestamp) }; + Ok(res) + } + _ => Err(BlockchainError::DataUnavailable), + }) + .collect::>>()?; + + let fullblock: OtsBlock = block.into(); + + Ok(OtsBlockTransactions { fullblock, receipts }) + } + + pub async fn build_ots_search_transactions( + &self, + hashes: Vec, + first_page: bool, + last_page: bool, + ) -> Result { + let txs_futs = hashes.iter().map(|hash| async { self.transaction_by_hash(*hash).await }); + + let txs = join_all(txs_futs) + .await + .into_iter() + .map(|t| match t { + Ok(Some(t)) => Ok(t.inner), + _ => Err(BlockchainError::DataUnavailable), + }) + .collect::>()?; + + let receipts = join_all(hashes.iter().map(|hash| async { + match self.transaction_receipt(*hash).await { + Ok(Some(receipt)) => { + let timestamp = self + .backend + .get_block(receipt.block_number.unwrap()) + .unwrap() + .header + .timestamp; + let receipt = receipt.map_inner(OtsReceipt::from); + let res = OtsTransactionReceipt { receipt, timestamp: Some(timestamp) }; + Ok(res) + } + Ok(None) => Err(BlockchainError::DataUnavailable), + Err(e) => Err(e), + } + })) + .await + .into_iter() + .collect::>>()?; + + Ok(TransactionsWithReceipts { txs, receipts, first_page, last_page }) + } } diff --git a/crates/anvil/src/eth/otterscan/mod.rs b/crates/anvil/src/eth/otterscan/mod.rs index 8389f117b5571..e5fdf85eed770 100644 --- a/crates/anvil/src/eth/otterscan/mod.rs +++ b/crates/anvil/src/eth/otterscan/mod.rs @@ -1,2 +1 @@ pub mod api; -pub mod types; diff --git a/crates/anvil/src/eth/otterscan/types.rs b/crates/anvil/src/eth/otterscan/types.rs deleted file mode 100644 index 8aeccf8c75306..0000000000000 --- a/crates/anvil/src/eth/otterscan/types.rs +++ /dev/null @@ -1,360 +0,0 @@ -use crate::eth::{ - backend::mem::{storage::MinedTransaction, Backend}, - error::{BlockchainError, Result}, -}; -use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256}; -use alloy_rpc_types::{ - trace::parity::{ - Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, - RewardAction, TraceOutput, - }, - Block, BlockTransactions, Transaction, -}; -use alloy_serde::WithOtherFields; -use anvil_core::eth::transaction::ReceiptResponse; -use foundry_evm::traces::CallKind; -use futures::future::join_all; -use serde::Serialize; -use serde_repr::Serialize_repr; - -/// Patched Block struct, to include the additional `transactionCount` field expected by Otterscan -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct OtsBlock { - #[serde(flatten)] - pub block: Block, - pub transaction_count: usize, -} - -/// Block structure with additional details regarding fees and issuance -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct OtsBlockDetails { - pub block: OtsBlock, - pub total_fees: U256, - pub issuance: Issuance, -} - -/// Issuance information for a block. Expected by Otterscan in ots_getBlockDetails calls -#[derive(Debug, Default, Serialize)] -pub struct Issuance { - block_reward: U256, - uncle_reward: U256, - issuance: U256, -} - -/// Holds both transactions and receipts for a block -#[derive(Clone, Serialize, Debug)] -pub struct OtsBlockTransactions { - pub fullblock: OtsBlock, - pub receipts: Vec, -} - -/// Patched Receipt struct, to include the additional `timestamp` field expected by Otterscan -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct OtsTransactionReceipt { - #[serde(flatten)] - receipt: ReceiptResponse, - timestamp: u64, -} - -/// Information about the creator address and transaction for a contract -#[derive(Debug, Serialize)] -pub struct OtsContractCreator { - pub hash: B256, - pub creator: Address, -} - -/// Paginated search results of an account's history -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct OtsSearchTransactions { - pub txs: Vec>, - pub receipts: Vec, - pub first_page: bool, - pub last_page: bool, -} - -/// Otterscan format for listing relevant internal operations. -/// -/// Ref: -#[derive(Debug, PartialEq, Eq, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct OtsInternalOperation { - pub r#type: OtsInternalOperationType, - pub from: Address, - pub to: Address, - pub value: U256, -} - -/// Types of internal operations recognized by Otterscan. -/// -/// Ref: -#[derive(Debug, PartialEq, Eq, Serialize_repr)] -#[repr(u8)] -pub enum OtsInternalOperationType { - Transfer = 0, - SelfDestruct = 1, - Create = 2, - Create2 = 3, -} - -/// Otterscan's representation of a trace -#[derive(Debug, PartialEq, Eq, Serialize)] -pub struct OtsTrace { - pub r#type: OtsTraceType, - pub depth: usize, - pub from: Address, - pub to: Address, - pub value: U256, - pub input: Bytes, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub output: Option, -} - -/// The type of call being described by an Otterscan trace. Only CALL, STATICCALL and DELEGATECALL -/// are represented -#[derive(Debug, PartialEq, Eq, Serialize)] -#[serde(rename_all = "UPPERCASE")] -pub enum OtsTraceType { - Call, - StaticCall, - DelegateCall, -} - -impl OtsBlockDetails { - /// The response for ots_getBlockDetails includes an `issuance` object that requires computing - /// the total gas spent in a given block. - /// - /// The only way to do this with the existing API is to explicitly fetch all receipts, to get - /// their `gas_used`. This would be extremely inefficient in a real blockchain RPC, but we can - /// get away with that in this context. - /// - /// The [original spec](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) - /// also mentions we can hardcode `transactions` and `logsBloom` to an empty array to save - /// bandwidth, because fields weren't intended to be used in the Otterscan UI at this point. - /// - /// This has two problems though: - /// - It makes the endpoint too specific to Otterscan's implementation - /// - It breaks the abstraction built in `OtsBlock` which computes `transaction_count` - /// based on the existing list. - /// - /// Therefore we keep it simple by keeping the data in the response - pub async fn build(block: Block, backend: &Backend) -> Result { - if block.transactions.is_uncle() { - return Err(BlockchainError::DataUnavailable); - } - let receipts_futs = block - .transactions - .hashes() - .map(|hash| async { backend.transaction_receipt(*hash).await }); - - // fetch all receipts - let receipts = join_all(receipts_futs) - .await - .into_iter() - .map(|r| match r { - Ok(Some(r)) => Ok(r), - _ => Err(BlockchainError::DataUnavailable), - }) - .collect::>>()?; - - let total_fees = receipts - .iter() - .fold(0, |acc, receipt| acc + receipt.gas_used * receipt.effective_gas_price); - - Ok(Self { - block: block.into(), - total_fees: U256::from(total_fees), - // issuance has no meaningful value in anvil's backend. just default to 0 - issuance: Default::default(), - }) - } -} - -/// Converts a regular block into the patched OtsBlock format -/// which includes the `transaction_count` field -impl From for OtsBlock { - fn from(block: Block) -> Self { - Self { transaction_count: block.transactions.len(), block } - } -} - -impl OtsBlockTransactions { - /// Fetches all receipts for the blocks's transactions, as required by the - /// [`ots_getBlockTransactions`] endpoint spec, and returns the final response object. - /// - /// [`ots_getBlockTransactions`]: https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails - pub async fn build( - mut block: Block, - backend: &Backend, - page: usize, - page_size: usize, - ) -> Result { - if block.transactions.is_uncle() { - return Err(BlockchainError::DataUnavailable); - } - - block.transactions = match block.transactions { - BlockTransactions::Full(txs) => BlockTransactions::Full( - txs.into_iter().skip(page * page_size).take(page_size).collect(), - ), - BlockTransactions::Hashes(txs) => BlockTransactions::Hashes( - txs.into_iter().skip(page * page_size).take(page_size).collect(), - ), - BlockTransactions::Uncle => unreachable!(), - }; - - let receipt_futs = - block.transactions.hashes().map(|hash| backend.transaction_receipt(*hash)); - - let receipts = join_all(receipt_futs) - .await - .into_iter() - .map(|r| match r { - Ok(Some(r)) => Ok(r), - _ => Err(BlockchainError::DataUnavailable), - }) - .collect::>()?; - - let fullblock: OtsBlock = block.into(); - - Ok(Self { fullblock, receipts }) - } -} - -impl OtsSearchTransactions { - /// Constructs the final response object for both [`ots_searchTransactionsBefore` and - /// `ots_searchTransactionsAfter`](lrequires not only the transactions, but also the - /// corresponding receipts, which are fetched here before constructing the final) - pub async fn build( - hashes: Vec, - backend: &Backend, - first_page: bool, - last_page: bool, - ) -> Result { - let txs_futs = hashes.iter().map(|hash| async { backend.transaction_by_hash(*hash).await }); - - let txs: Vec<_> = join_all(txs_futs) - .await - .into_iter() - .map(|t| match t { - Ok(Some(t)) => Ok(t), - _ => Err(BlockchainError::DataUnavailable), - }) - .collect::>()?; - - join_all(hashes.iter().map(|hash| async { - match backend.transaction_receipt(*hash).await { - Ok(Some(receipt)) => { - let timestamp = - backend.get_block(receipt.block_number.unwrap()).unwrap().header.timestamp; - Ok(OtsTransactionReceipt { receipt, timestamp }) - } - Ok(None) => Err(BlockchainError::DataUnavailable), - Err(e) => Err(e), - } - })) - .await - .into_iter() - .collect::>>() - .map(|receipts| Self { txs, receipts, first_page, last_page }) - } - - pub fn mentions_address( - trace: LocalizedTransactionTrace, - address: Address, - ) -> Option> { - match (trace.trace.action, trace.trace.result) { - (Action::Call(CallAction { from, to, .. }), _) if from == address || to == address => { - trace.transaction_hash - } - (_, Some(TraceOutput::Create(CreateOutput { address: created_address, .. }))) - if created_address == address => - { - trace.transaction_hash - } - (Action::Create(CreateAction { from, .. }), _) if from == address => { - trace.transaction_hash - } - (Action::Reward(RewardAction { author, .. }), _) if author == address => { - trace.transaction_hash - } - _ => None, - } - } -} - -impl OtsInternalOperation { - /// Converts a batch of traces into a batch of internal operations, to comply with the spec for - /// [`ots_getInternalOperations`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getinternaloperations) - pub fn batch_build(traces: MinedTransaction) -> Vec { - traces - .info - .traces - .iter() - .filter_map(|node| { - let r#type = match node.trace.kind { - _ if node.is_selfdestruct() => OtsInternalOperationType::SelfDestruct, - CallKind::Call if !node.trace.value.is_zero() => { - OtsInternalOperationType::Transfer - } - CallKind::Create => OtsInternalOperationType::Create, - CallKind::Create2 => OtsInternalOperationType::Create2, - _ => return None, - }; - let mut from = node.trace.caller; - let mut to = node.trace.address; - let mut value = node.trace.value; - if node.is_selfdestruct() { - from = node.trace.address; - to = node.trace.selfdestruct_refund_target.unwrap_or_default(); - value = node.trace.selfdestruct_transferred_value.unwrap_or_default(); - } - Some(Self { r#type, from, to, value }) - }) - .collect() - } -} - -impl OtsTrace { - /// Converts the list of traces for a transaction into the expected Otterscan format, as - /// specified in the [`ots_traceTransaction`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_tracetransaction) spec - pub fn batch_build(traces: Vec) -> Vec { - traces - .into_iter() - .filter_map(|trace| match trace.trace.action { - Action::Call(call) => { - if let Ok(ots_type) = call.call_type.try_into() { - Some(Self { - r#type: ots_type, - depth: trace.trace.trace_address.len(), - from: call.from, - to: call.to, - value: call.value, - input: call.input.0.into(), - output: None, - }) - } else { - None - } - } - Action::Create(_) | Action::Selfdestruct(_) | Action::Reward(_) => None, - }) - .collect() - } -} - -impl TryFrom for OtsTraceType { - type Error = (); - - fn try_from(value: CallType) -> std::result::Result { - match value { - CallType::Call => Ok(Self::Call), - CallType::StaticCall => Ok(Self::StaticCall), - CallType::DelegateCall => Ok(Self::DelegateCall), - _ => Err(()), - } - } -} diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index dc0f297fd3554..63453a37e8786 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -3,15 +3,13 @@ use crate::abi::MulticallContract; use alloy_primitives::{address, Address, Bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{BlockNumberOrTag, BlockTransactions, TransactionRequest}; +use alloy_rpc_types::{ + trace::otterscan::{InternalOperation, OperationType, TraceEntry}, + BlockNumberOrTag, BlockTransactions, TransactionRequest, +}; use alloy_serde::WithOtherFields; use alloy_sol_types::{sol, SolCall, SolError}; -use anvil::{ - eth::otterscan::types::{ - OtsInternalOperation, OtsInternalOperationType, OtsTrace, OtsTraceType, - }, - spawn, Hardfork, NodeConfig, -}; +use anvil::{spawn, Hardfork, NodeConfig}; use std::collections::VecDeque; #[tokio::test(flavor = "multi_thread")] @@ -50,8 +48,8 @@ async fn ots_get_internal_operations_contract_deploy() { let res = api.ots_get_internal_operations(contract_receipt.transaction_hash).await.unwrap(); assert_eq!( res, - [OtsInternalOperation { - r#type: OtsInternalOperationType::Create, + [InternalOperation { + r#type: OperationType::OpCreate, from: sender, to: contract_receipt.contract_address.unwrap(), value: U256::from(0) @@ -78,12 +76,7 @@ async fn ots_get_internal_operations_contract_transfer() { let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!( res, - [OtsInternalOperation { - r#type: OtsInternalOperationType::Transfer, - from, - to, - value: amount - }], + [InternalOperation { r#type: OperationType::OpTransfer, from, to, value: amount }], ); } @@ -114,8 +107,8 @@ async fn ots_get_internal_operations_contract_create2() { let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!( res, - [OtsInternalOperation { - r#type: OtsInternalOperationType::Create2, + [InternalOperation { + r#type: OperationType::OpCreate2, from: address!("4e59b44847b379578588920cA78FbF26c0B4956C"), to: address!("347bcdad821abc09b8c275881b368de36476b62c"), value: U256::from(0), @@ -166,8 +159,8 @@ async fn ots_get_internal_operations_contract_selfdestruct(hardfork: Hardfork) { let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!( res, - [OtsInternalOperation { - r#type: OtsInternalOperationType::SelfDestruct, + [InternalOperation { + r#type: OperationType::OpSelfDestruct, from: contract_address, to: expected_to, value: expected_value, @@ -243,50 +236,45 @@ async fn test_call_ots_trace_transaction() { let res = api.ots_trace_transaction(receipt.transaction_hash).await.unwrap(); let expected = vec![ - OtsTrace { - r#type: OtsTraceType::Call, + TraceEntry { + r#type: "CALL".to_string(), depth: 0, from: sender, to: contract_address, value: U256::from(1337), input: Contract::runCall::SELECTOR.into(), - output: None, }, - OtsTrace { - r#type: OtsTraceType::StaticCall, + TraceEntry { + r#type: "STATICCALL".to_string(), depth: 1, from: contract_address, to: contract_address, value: U256::ZERO, input: Contract::do_staticcallCall::SELECTOR.into(), - output: None, }, - OtsTrace { - r#type: OtsTraceType::Call, + TraceEntry { + r#type: "CALL".to_string(), depth: 1, from: contract_address, to: contract_address, value: U256::ZERO, input: Contract::do_callCall::SELECTOR.into(), - output: None, }, - OtsTrace { - r#type: OtsTraceType::Call, + TraceEntry { + r#type: "CALL".to_string(), depth: 2, from: contract_address, to: sender, value: U256::from(1337), input: Bytes::new(), - output: None, }, - OtsTrace { - r#type: OtsTraceType::DelegateCall, + TraceEntry { + r#type: "DELEGATECALL".to_string(), depth: 2, from: contract_address, to: contract_address, value: U256::ZERO, input: Contract::do_delegatecallCall::SELECTOR.into(), - output: None, }, ]; assert_eq!(res, expected); @@ -399,7 +387,7 @@ async fn ots_get_block_transactions() { result.receipts.iter().enumerate().for_each(|(i, receipt)| { let expected = hashes.pop_front(); - assert_eq!(expected, Some(receipt.transaction_hash)); + assert_eq!(expected, Some(receipt.receipt.transaction_hash)); assert_eq!(expected, result.fullblock.block.transactions.hashes().nth(i).copied()); }); } @@ -528,5 +516,5 @@ async fn ots_get_contract_creator() { let creator = api.ots_get_contract_creator(contract_address).await.unwrap().unwrap(); assert_eq!(creator.creator, sender); - assert_eq!(creator.hash, receipt.transaction_hash); + assert_eq!(creator.tx.hash, receipt.transaction_hash); } From 7cb51ec470013dd1ac262dac24f968543c874be7 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 5 Jul 2024 13:04:30 +0200 Subject: [PATCH 1219/1963] test: add test for pk parsing (#8366) --- crates/wallets/src/utils.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/wallets/src/utils.rs b/crates/wallets/src/utils.rs index 40f88b6d4af68..ab1871d6b90b0 100644 --- a/crates/wallets/src/utils.rs +++ b/crates/wallets/src/utils.rs @@ -147,3 +147,17 @@ pub fn create_keystore_signer( Ok((None, Some(PendingSigner::Keystore(path.clone())))) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_private_key_signer() { + let pk = B256::random(); + let pk_str = pk.to_string(); + assert!(create_private_key_signer(&pk_str).is_ok()); + // skip 0x + assert!(create_private_key_signer(&pk_str[2..]).is_ok()); + } +} From 4dc946788005dd292d61e60c3ba7c17c41785144 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 5 Jul 2024 13:42:52 +0200 Subject: [PATCH 1220/1963] docs: add note about evm_version (#8369) --- crates/forge/bin/cmd/clone.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 66a2d3a73086a..f2c07294a835f 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -288,7 +288,8 @@ impl CloneArgs { /// It will update the following fields: /// - `auto_detect_solc` to `false` /// - `solc_version` to the value from the metadata -/// - `evm_version` to the value from the metadata +/// - `evm_version` to the value from the metadata, if the metadata's evm_version is "Default", then +/// this is derived from the solc version this contract was compiled with. /// - `via_ir` to the value from the metadata /// - `libraries` to the value from the metadata /// - `metadata` to the value from the metadata From 161605a6d0a8999191e3d6765394affe2c7a8bc5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 5 Jul 2024 14:26:18 +0200 Subject: [PATCH 1221/1963] test: ignore 502 in can_clone_keep_directory_structure (#8372) --- crates/forge/tests/cli/cmd.rs | 16 +++++++++++++++- crates/test-utils/src/util.rs | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index f136fb95a6c08..23cb3ca8a0f74 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -507,7 +507,21 @@ forgetest!(can_clone_keep_directory_structure, |prj, cmd| { "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", ]) .arg(prj.root()); - cmd.assert_non_empty_stdout(); + let out = cmd.unchecked_output(); + if out.stdout_lossy().contains("502 Bad Gateway") { + // etherscan nginx proxy issue, skip this test: + // + // stdout: + // Downloading the source code of 0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf from + // Etherscan... 2024-07-05T11:40:11.801765Z ERROR etherscan: Failed to deserialize + // response: expected value at line 1 column 1 res="\r\n502 Bad + // Gateway\r\n\r\n

502 Bad + // Gateway

\r\n
nginx
\r\n\r\n\r\n" + + eprintln!("Skipping test due to 502 Bad Gateway: {}", cmd.make_error_message(&out, false)); + return + } + cmd.ensure_success(&out).unwrap(); let s = read_string(&foundry_toml); let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 9c857bc40789e..b897aacb63409 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1027,7 +1027,7 @@ impl TestCommand { eyre::eyre!("{}", self.make_error_message(out, expected_fail)) } - fn make_error_message(&self, out: &Output, expected_fail: bool) -> String { + pub fn make_error_message(&self, out: &Output, expected_fail: bool) -> String { let msg = if expected_fail { "expected failure but command succeeded!" } else { @@ -1071,6 +1071,12 @@ pub trait OutputExt { /// Ensure the command wrote the expected data to `stderr`. fn stderr_matches_path(&self, expected_path: impl AsRef); + + /// Returns the stderr as lossy string + fn stderr_lossy(&self) -> String; + + /// Returns the stdout as lossy string + fn stdout_lossy(&self) -> String; } /// Patterns to remove from fixtures before comparing output @@ -1118,6 +1124,14 @@ impl OutputExt for Output { let err = lossy_string(&self.stderr); similar_asserts::assert_eq!(normalize_output(&err), normalize_output(&expected)); } + + fn stderr_lossy(&self) -> String { + lossy_string(&self.stderr) + } + + fn stdout_lossy(&self) -> String { + lossy_string(&self.stdout) + } } /// Returns the fixture path depending on whether the current terminal is tty From 1bac1b3d79243cea755800bf396c30a3d74741bf Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 5 Jul 2024 15:40:38 +0300 Subject: [PATCH 1222/1963] fix: join paths when passing args to forge build (#8371) * fix: join paths when passing args to forge build * fmt --------- Co-authored-by: Matthias Seitz --- crates/forge/bin/cmd/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index e17a2cfaaba03..1538ca7715499 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -93,6 +93,8 @@ impl BuildArgs { let mut files = vec![]; if let Some(paths) = &self.paths { for path in paths { + let joined = project.root().join(path); + let path = if joined.exists() { &joined } else { path }; files.extend(source_files_iter(path, MultiCompilerLanguage::FILE_EXTENSIONS)); } } From 3ae4f505822e66c7bf74a448df65af4533e46dc1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 6 Jul 2024 09:15:20 +0200 Subject: [PATCH 1223/1963] fix: set both tx input fields (#8373) --- crates/cast/bin/tx.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 6edb8c5b272a6..b37c743f812ce 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,9 +1,9 @@ use alloy_consensus::{SidecarBuilder, SimpleCoder}; use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; -use alloy_primitives::{hex, Address, TxKind}; +use alloy_primitives::{hex, Address, Bytes, TxKind}; use alloy_provider::Provider; -use alloy_rpc_types::TransactionRequest; +use alloy_rpc_types::{TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::Result; @@ -232,7 +232,11 @@ where let from = from.into().resolve(&self.provider).await?; self.tx.set_kind(self.state.kind); - self.tx.set_input(self.state.input); + + // we set both fields to the same value because some nodes only accept the legacy `data` field: + let input = Bytes::from(self.state.input); + self.tx.input = TransactionInput { input: Some(input.clone()), data: Some(input) }; + self.tx.set_from(from); self.tx.set_chain_id(self.chain.id()); From 8b694bbcabaedffc0337bf8dea9a135da5694ef9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 08:26:05 +0000 Subject: [PATCH 1224/1963] chore(deps): weekly `cargo update` (#8381) Locking 43 packages to latest compatible versions Updating aws-config v1.5.1 -> v1.5.4 Updating aws-runtime v1.3.0 -> v1.3.1 Updating aws-sdk-kms v1.30.0 -> v1.35.0 Updating aws-sdk-sso v1.29.0 -> v1.34.0 Updating aws-sdk-ssooidc v1.30.0 -> v1.35.0 Updating aws-sdk-sts v1.29.0 -> v1.34.0 Updating aws-sigv4 v1.2.2 -> v1.2.3 Updating aws-smithy-http v0.60.8 -> v0.60.9 Updating aws-smithy-runtime v1.5.5 -> v1.6.1 Updating aws-smithy-runtime-api v1.7.0 -> v1.7.1 Updating aws-types v1.3.2 -> v1.3.3 Updating castaway v0.2.2 -> v0.2.3 Updating cc v1.0.102 -> v1.0.104 Updating gcloud-sdk v0.24.7 -> v0.24.8 Updating hyper v1.3.1 -> v1.4.0 Updating hyper-util v0.1.5 -> v0.1.6 Updating oorandom v11.1.3 -> v11.1.4 Updating pest v2.7.10 -> v2.7.11 Updating pest_derive v2.7.10 -> v2.7.11 Updating pest_generator v2.7.10 -> v2.7.11 Updating pest_meta v2.7.10 -> v2.7.11 Updating revm-inspectors v0.3.0 -> v0.3.1 Updating rustls-native-certs v0.7.0 -> v0.7.1 Updating rustls-webpki v0.102.4 -> v0.102.5 Updating scc v2.1.1 -> v2.1.2 Updating serde v1.0.203 -> v1.0.204 Updating serde_derive v1.0.203 -> v1.0.204 Updating serde_json v1.0.118 -> v1.0.120 Updating stability v0.2.0 -> v0.2.1 Updating syn v2.0.68 -> v2.0.69 Updating tinyvec v1.6.1 -> v1.7.0 Updating windows-targets v0.52.5 -> v0.52.6 Updating windows_aarch64_gnullvm v0.52.5 -> v0.52.6 Updating windows_aarch64_msvc v0.52.5 -> v0.52.6 Updating windows_i686_gnu v0.52.5 -> v0.52.6 Updating windows_i686_gnullvm v0.52.5 -> v0.52.6 Updating windows_i686_msvc v0.52.5 -> v0.52.6 Updating windows_x86_64_gnu v0.52.5 -> v0.52.6 Updating windows_x86_64_gnullvm v0.52.5 -> v0.52.6 Updating windows_x86_64_msvc v0.52.5 -> v0.52.6 Updating zerocopy v0.7.34 -> v0.7.35 Updating zerocopy-derive v0.7.34 -> v0.7.35 Updating zstd-sys v2.0.11+zstd.1.5.6 -> v2.0.12+zstd.1.5.6 note: pass `--verbose` to see 161 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 323 +++++++++++++++++++++++++++-------------------------- 1 file changed, 162 insertions(+), 161 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18b3b86d419ea..13a22a7d2ada6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,7 +306,7 @@ checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -552,7 +552,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -569,7 +569,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "syn-solidity", "tiny-keccak", ] @@ -587,7 +587,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.68", + "syn 2.0.69", "syn-solidity", ] @@ -832,7 +832,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 1.3.1", + "hyper 1.4.0", "itertools 0.13.0", "k256", "parking_lot", @@ -1097,7 +1097,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1119,7 +1119,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1130,7 +1130,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1177,7 +1177,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -1188,9 +1188,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.5.1" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac9889352d632214df943e26740c46a0f3da6e329fbd28164fe7ae1b061da7b" +checksum = "caf6cfe2881cb1fcbba9ae946fb9a6480d3b7a714ca84c74925014a89ef3387a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1231,9 +1231,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a4a5e448145999d7de17bf44a886900ecb834953408dae8aaf90465ce91c1dd" +checksum = "87c5f920ffd1e0526ec9e70e50bf444db50b204395a0fa7016bbf9e31ea1698f" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1254,9 +1254,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.30.0" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da951fb0dd1a02728a91c58af8464098766f1a0600af932dd3f8361b23e1bfc9" +checksum = "b16bbfeaffab8514ae56938de28de5b5c698e7146549f1085cb772ccf1f42aa8" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1276,9 +1276,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.29.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da75cf91cbb46686a27436d639a720a3a198b148efa76dc2467b7e5374a67fc0" +checksum = "cdcfae7bf8b8f14cade7579ffa8956fcee91dc23633671096b4b5de7d16f682a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1298,9 +1298,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.30.0" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2ec8a6687299685ed0a4a3137c129cdb132b5235bc3aa3443f6cffe468b9ff" +checksum = "33b30def8f02ba81276d5dbc22e7bf3bed20d62d1b175eef82680d6bdc7a6f4c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1320,9 +1320,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.29.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458f1031e094b1411b59b49b19e4118f069e1fe13a9c5b8888e933daaf7ffdd6" +checksum = "0804f840ad31537d5d1a4ec48d59de5e674ad05f1db7d3def2c9acadaf1f7e60" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1343,9 +1343,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31eed8d45759b2c5fe7fd304dd70739060e9e0de509209036eabea14d0720cce" +checksum = "5df1b0fa6be58efe9d4ccc257df0a53b89cd8909e86591a13ca54817c87517be" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1377,9 +1377,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.8" +version = "0.60.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a7de001a1b9a25601016d8057ea16e31a45fdca3751304c8edf4ad72e706c08" +checksum = "d9cd0ae3d97daa0a2bf377a4d8e8e1362cae590c4a1aad0d40058ebca18eb91e" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -1416,9 +1416,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.5.5" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d3965f6417a92a6d1009c5958a67042f57e46342afb37ca58f9ad26744ec73" +checksum = "3df4217d39fe940066174e6238310167bf466bfbebf3be0661e53cacccde6313" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1430,6 +1430,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "http-body 1.0.0", + "httparse", "hyper 0.14.29", "hyper-rustls 0.24.2", "once_cell", @@ -1442,9 +1443,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b570ea39eb95bd32543f6e4032bce172cb6209b9bc8c83c770d08169e875afc" +checksum = "30819352ed0a04ecf6a2f3477e344d2d1ba33d43e0f09ad9047c12e0d923616f" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1491,9 +1492,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2009a9733865d0ebf428a314440bbe357cc10d0c16d86a8e15d32e9b47c1e80e" +checksum = "5221b91b3e441e6675310829fd8984801b772cb1546ef6c0e54dec9f1ac13fef" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1545,7 +1546,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.0", "hyper-util", "itoa", "matchit", @@ -1961,18 +1962,18 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "castaway" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" +checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5" dependencies = [ "rustversion", ] [[package]] name = "cc" -version = "1.0.102" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "779e6b7d17797c0b42023d417228c02889300190e700cb074c3438d9c541d332" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" dependencies = [ "jobserver", "libc", @@ -2040,7 +2041,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2133,7 +2134,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2563,7 +2564,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2574,7 +2575,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2646,7 +2647,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2667,7 +2668,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2677,7 +2678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2690,7 +2691,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2797,7 +2798,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -2933,7 +2934,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -3083,7 +3084,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.68", + "syn 2.0.69", "toml 0.8.14", "walkdir", ] @@ -3111,7 +3112,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.68", + "syn 2.0.69", "tempfile", "thiserror", "tiny-keccak", @@ -3339,7 +3340,7 @@ dependencies = [ "futures", "globset", "humantime-serde", - "hyper 1.3.1", + "hyper 1.4.0", "indicatif", "itertools 0.13.0", "mockall", @@ -3473,7 +3474,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4031,7 +4032,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4189,7 +4190,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4245,9 +4246,9 @@ dependencies = [ [[package]] name = "gcloud-sdk" -version = "0.24.7" +version = "0.24.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa57d45d9a9778e0bf38deb6a4c9dbe293fa021d0b70b126b5dc593979b08569" +checksum = "1afe2a62202f8f8eb624638f7e5b8f0988a540dd8dbb69e098daeb277273b2ab" dependencies = [ "async-trait", "chrono", @@ -4691,7 +4692,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -4810,9 +4811,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" dependencies = [ "bytes", "futures-channel", @@ -4852,10 +4853,10 @@ checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.3.1", + "hyper 1.4.0", "hyper-util", "rustls 0.23.10", - "rustls-native-certs 0.7.0", + "rustls-native-certs 0.7.1", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -4883,7 +4884,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.0", "hyper-util", "native-tls", "tokio", @@ -4893,16 +4894,16 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.3.1", + "hyper 1.4.0", "pin-project-lite", "socket2", "tokio", @@ -5547,7 +5548,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -5617,7 +5618,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -5848,7 +5849,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -5896,9 +5897,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "open-fastrlp" @@ -5971,7 +5972,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -6074,7 +6075,7 @@ dependencies = [ "libc", "redox_syscall 0.5.2", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -6142,7 +6143,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -6172,9 +6173,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" dependencies = [ "memchr", "thiserror", @@ -6183,9 +6184,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" +checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" dependencies = [ "pest", "pest_generator", @@ -6193,22 +6194,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" +checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] name = "pest_meta" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" +checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" dependencies = [ "once_cell", "pest", @@ -6285,7 +6286,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -6343,7 +6344,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -6459,7 +6460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -6535,7 +6536,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "version_check", "yansi", ] @@ -6602,7 +6603,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -6962,7 +6963,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.0", "hyper-rustls 0.27.2", "hyper-tls", "hyper-util", @@ -6977,7 +6978,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.10", - "rustls-native-certs 0.7.0", + "rustls-native-certs 0.7.1", "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", @@ -7015,9 +7016,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d2f41673ae4d4f2d0624c99844f096f82d39b93134ac8d4bbe9683c87459eeb" +checksum = "3aede4aaaa0c5b446ce1a951629d7929ea48473a0f307bd8d999ecdeb55c420b" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7274,7 +7275,7 @@ dependencies = [ "log", "ring", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] @@ -7288,7 +7289,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] @@ -7307,9 +7308,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", "rustls-pemfile 2.1.2", @@ -7355,9 +7356,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ "ring", "rustls-pki-types", @@ -7455,9 +7456,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ad2bbb0ae5100a07b7a6f2ed7ab5fd0045551a4c507989b7a620046ea3efdc" +checksum = "af947d0ca10a2f3e00c7ec1b515b7c83e5cb3fa62d4c11a64301d9eec54440e9" dependencies = [ "sdd", ] @@ -7492,7 +7493,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -7639,22 +7640,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -7665,14 +7666,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] name = "serde_json" -version = "1.0.118" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "indexmap 2.2.6", "itoa", @@ -7708,7 +7709,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -7754,7 +7755,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -8019,12 +8020,12 @@ dependencies = [ [[package]] name = "stability" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" +checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -8090,7 +8091,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -8158,9 +8159,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", @@ -8176,7 +8177,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -8298,7 +8299,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -8394,9 +8395,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" dependencies = [ "tinyvec_macros", ] @@ -8444,7 +8445,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -8616,7 +8617,7 @@ dependencies = [ "percent-encoding", "pin-project 1.1.5", "prost", - "rustls-native-certs 0.7.0", + "rustls-native-certs 0.7.1", "rustls-pemfile 2.1.2", "rustls-pki-types", "tokio", @@ -8723,7 +8724,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -9115,7 +9116,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "wasm-bindgen-shared", ] @@ -9149,7 +9150,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9305,7 +9306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" dependencies = [ "windows-core 0.54.0", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -9314,7 +9315,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -9324,7 +9325,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" dependencies = [ "windows-result", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -9333,7 +9334,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -9360,7 +9361,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -9395,18 +9396,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -9423,9 +9424,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -9441,9 +9442,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -9459,15 +9460,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -9483,9 +9484,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -9501,9 +9502,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -9519,9 +9520,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -9537,9 +9538,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -9635,22 +9636,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -9670,7 +9671,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.69", ] [[package]] @@ -9755,9 +9756,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.11+zstd.1.5.6" +version = "2.0.12+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" +checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" dependencies = [ "cc", "pkg-config", From 0116be1bb3f73a6365290ba2894813815d02159d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 8 Jul 2024 23:21:53 +0200 Subject: [PATCH 1225/1963] chore: don't build OpenChain client if offline (#8390) --- crates/common/src/selectors.rs | 6 ++-- .../evm/traces/src/identifier/signatures.rs | 30 +++++++------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 59305f20b6c6e..c22ee3076578c 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -4,6 +4,7 @@ use crate::abi::abi_decode_calldata; use alloy_json_abi::JsonAbi; +use eyre::Context; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{ @@ -39,14 +40,15 @@ pub struct OpenChainClient { impl OpenChainClient { /// Creates a new client with default settings - pub fn new() -> reqwest::Result { + pub fn new() -> eyre::Result { let inner = reqwest::Client::builder() .default_headers(HeaderMap::from_iter([( HeaderName::from_static("user-agent"), HeaderValue::from_static("forge"), )])) .timeout(REQ_TIMEOUT) - .build()?; + .build() + .wrap_err("failed to build OpenChain client")?; Ok(Self { inner, spurious_connection: Arc::new(Default::default()), diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index ff9ef0084d685..2a2f6a2f24733 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -22,19 +22,17 @@ struct CachedSignatures { } /// An identifier that tries to identify functions and events using signatures found at -/// `https://openchain.xyz`. +/// `https://openchain.xyz` or a local cache. #[derive(Debug)] pub struct SignaturesIdentifier { - /// Cached selectors for functions and events + /// Cached selectors for functions and events. cached: CachedSignatures, - /// Location where to save `CachedSignatures` + /// Location where to save `CachedSignatures`. cached_path: Option, /// Selectors that were unavailable during the session. unavailable: HashSet, - /// The API client to fetch signatures from - sign_eth_api: OpenChainClient, - /// whether traces should be decoded via `sign_eth_api` - offline: bool, + /// The OpenChain client to fetch signatures from. + client: Option, } impl SignaturesIdentifier { @@ -43,7 +41,7 @@ impl SignaturesIdentifier { cache_path: Option, offline: bool, ) -> eyre::Result { - let sign_eth_api = OpenChainClient::new()?; + let client = if !offline { Some(OpenChainClient::new()?) } else { None }; let identifier = if let Some(cache_path) = cache_path { let path = cache_path.join("signatures"); @@ -58,20 +56,13 @@ impl SignaturesIdentifier { } CachedSignatures::default() }; - Self { - cached, - cached_path: Some(path), - unavailable: HashSet::new(), - sign_eth_api, - offline, - } + Self { cached, cached_path: Some(path), unavailable: HashSet::new(), client } } else { Self { cached: Default::default(), cached_path: None, unavailable: HashSet::new(), - sign_eth_api, - offline, + client, } }; @@ -110,15 +101,14 @@ impl SignaturesIdentifier { let hex_identifiers: Vec = identifiers.into_iter().map(hex::encode_prefixed).collect(); - if !self.offline { + if let Some(client) = &self.client { let query: Vec<_> = hex_identifiers .iter() .filter(|v| !cache.contains_key(v.as_str())) .filter(|v| !self.unavailable.contains(v.as_str())) .collect(); - if let Ok(res) = self.sign_eth_api.decode_selectors(selector_type, query.clone()).await - { + if let Ok(res) = client.decode_selectors(selector_type, query.clone()).await { for (hex_id, selector_result) in query.into_iter().zip(res.into_iter()) { let mut found = false; if let Some(decoded_results) = selector_result { From 2ba3400c76f3a6e9b9a5d5595ac2ebd38b4bce58 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 9 Jul 2024 07:42:17 +0300 Subject: [PATCH 1226/1963] feat(invariant): exclude precompiles from senders (#8367) * fix(invariant): exclude precompiles from senders * More robust shrink test, use same test contract / bytecode --- crates/evm/core/src/lib.rs | 1 + crates/evm/core/src/precompiles.rs | 45 +++++++++++++++++ crates/evm/evm/src/executors/invariant/mod.rs | 9 +++- crates/evm/traces/src/decoder/mod.rs | 14 ++++++ crates/evm/traces/src/decoder/precompiles.rs | 28 ++++++----- crates/forge/tests/cli/test_cmd.rs | 49 +++++++++++++++++++ crates/forge/tests/it/invariant.rs | 20 +++----- .../common/InvariantShrinkWithAssert.t.sol | 20 -------- 8 files changed, 140 insertions(+), 46 deletions(-) create mode 100644 crates/evm/core/src/precompiles.rs diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 12297e8064024..dd05568411be4 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -25,6 +25,7 @@ pub mod decode; pub mod fork; pub mod opcodes; pub mod opts; +pub mod precompiles; pub mod snapshot; pub mod utils; diff --git a/crates/evm/core/src/precompiles.rs b/crates/evm/core/src/precompiles.rs new file mode 100644 index 0000000000000..03ab18dffd964 --- /dev/null +++ b/crates/evm/core/src/precompiles.rs @@ -0,0 +1,45 @@ +use alloy_primitives::{address, Address}; + +/// The ECRecover precompile address. +pub const EC_RECOVER: Address = address!("0000000000000000000000000000000000000001"); + +/// The SHA-256 precompile address. +pub const SHA_256: Address = address!("0000000000000000000000000000000000000002"); + +/// The RIPEMD-160 precompile address. +pub const RIPEMD_160: Address = address!("0000000000000000000000000000000000000003"); + +/// The Identity precompile address. +pub const IDENTITY: Address = address!("0000000000000000000000000000000000000004"); + +/// The ModExp precompile address. +pub const MOD_EXP: Address = address!("0000000000000000000000000000000000000005"); + +/// The ECAdd precompile address. +pub const EC_ADD: Address = address!("0000000000000000000000000000000000000006"); + +/// The ECMul precompile address. +pub const EC_MUL: Address = address!("0000000000000000000000000000000000000007"); + +/// The ECPairing precompile address. +pub const EC_PAIRING: Address = address!("0000000000000000000000000000000000000008"); + +/// The Blake2F precompile address. +pub const BLAKE_2F: Address = address!("0000000000000000000000000000000000000009"); + +/// The PointEvaluation precompile address. +pub const POINT_EVALUATION: Address = address!("000000000000000000000000000000000000000a"); + +/// Precompile addresses. +pub const PRECOMPILES: &[Address] = &[ + EC_RECOVER, + SHA_256, + RIPEMD_160, + IDENTITY, + MOD_EXP, + EC_ADD, + EC_MUL, + EC_PAIRING, + BLAKE_2F, + POINT_EVALUATION, +]; diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index f417edbb2a749..7dcdc15680e1a 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -7,8 +7,11 @@ use alloy_sol_types::{sol, SolCall}; use eyre::{eyre, ContextCompat, Result}; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::InvariantConfig; -use foundry_evm_core::constants::{ - CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME, +use foundry_evm_core::{ + constants::{ + CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME, + }, + precompiles::PRECOMPILES, }; use foundry_evm_fuzz::{ invariant::{ @@ -627,6 +630,8 @@ impl<'a> InvariantExecutor<'a> { HARDHAT_CONSOLE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, ]); + // Extend with precompiles - https://github.com/foundry-rs/foundry/issues/4287 + excluded_senders.extend(PRECOMPILES); let sender_filters = SenderFilters::new(targeted_senders, excluded_senders); let selected = diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index ef0bd6bcde5dc..513954f07d444 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -17,6 +17,10 @@ use foundry_evm_core::{ TEST_CONTRACT_ADDRESS, }, decode::RevertDecoder, + precompiles::{ + BLAKE_2F, EC_ADD, EC_MUL, EC_PAIRING, EC_RECOVER, IDENTITY, MOD_EXP, POINT_EVALUATION, + RIPEMD_160, SHA_256, + }, }; use itertools::Itertools; use once_cell::sync::OnceCell; @@ -160,6 +164,16 @@ impl CallTraceDecoder { (DEFAULT_CREATE2_DEPLOYER, "Create2Deployer".to_string()), (CALLER, "DefaultSender".to_string()), (TEST_CONTRACT_ADDRESS, "DefaultTestContract".to_string()), + (EC_RECOVER, "ECRecover".to_string()), + (SHA_256, "SHA-256".to_string()), + (RIPEMD_160, "RIPEMD-160".to_string()), + (IDENTITY, "Identity".to_string()), + (MOD_EXP, "ModExp".to_string()), + (EC_ADD, "ECAdd".to_string()), + (EC_MUL, "ECMul".to_string()), + (EC_PAIRING, "ECPairing".to_string()), + (BLAKE_2F, "Blake2F".to_string()), + (POINT_EVALUATION, "PointEvaluation".to_string()), ] .into(), receive_contracts: Default::default(), diff --git a/crates/evm/traces/src/decoder/precompiles.rs b/crates/evm/traces/src/decoder/precompiles.rs index 654bc194aed53..0719f29b77aef 100644 --- a/crates/evm/traces/src/decoder/precompiles.rs +++ b/crates/evm/traces/src/decoder/precompiles.rs @@ -1,6 +1,10 @@ use crate::{CallTrace, DecodedCallData}; use alloy_primitives::{hex, B256, U256}; use alloy_sol_types::{abi, sol, SolCall}; +use foundry_evm_core::precompiles::{ + BLAKE_2F, EC_ADD, EC_MUL, EC_PAIRING, EC_RECOVER, IDENTITY, MOD_EXP, POINT_EVALUATION, + RIPEMD_160, SHA_256, +}; use itertools::Itertools; use revm_inspectors::tracing::types::DecodedCallTrace; @@ -50,27 +54,27 @@ pub(super) fn decode(trace: &CallTrace, _chain_id: u64) -> Option { + let (signature, args) = match trace.address { + EC_RECOVER => { let (sig, ecrecoverCall { hash, v, r, s }) = tri!(abi_decode_call(data)); (sig, vec![hash.to_string(), v.to_string(), r.to_string(), s.to_string()]) } - 0x02 => (sha256Call::SIGNATURE, vec![data.to_string()]), - 0x03 => (ripemdCall::SIGNATURE, vec![data.to_string()]), - 0x04 => (identityCall::SIGNATURE, vec![data.to_string()]), - 0x05 => (modexpCall::SIGNATURE, tri!(decode_modexp(data))), - 0x06 => { + SHA_256 => (sha256Call::SIGNATURE, vec![data.to_string()]), + RIPEMD_160 => (ripemdCall::SIGNATURE, vec![data.to_string()]), + IDENTITY => (identityCall::SIGNATURE, vec![data.to_string()]), + MOD_EXP => (modexpCall::SIGNATURE, tri!(decode_modexp(data))), + EC_ADD => { let (sig, ecaddCall { x1, y1, x2, y2 }) = tri!(abi_decode_call(data)); (sig, vec![x1.to_string(), y1.to_string(), x2.to_string(), y2.to_string()]) } - 0x07 => { + EC_MUL => { let (sig, ecmulCall { x1, y1, s }) = tri!(abi_decode_call(data)); (sig, vec![x1.to_string(), y1.to_string(), s.to_string()]) } - 0x08 => (ecpairingCall::SIGNATURE, tri!(decode_ecpairing(data))), - 0x09 => (blake2fCall::SIGNATURE, tri!(decode_blake2f(data))), - 0x0a => (pointEvaluationCall::SIGNATURE, tri!(decode_kzg(data))), - 0x00 | 0x0b.. => return None, + EC_PAIRING => (ecpairingCall::SIGNATURE, tri!(decode_ecpairing(data))), + BLAKE_2F => (blake2fCall::SIGNATURE, tri!(decode_blake2f(data))), + POINT_EVALUATION => (pointEvaluationCall::SIGNATURE, tri!(decode_kzg(data))), + _ => return None, }; Some(DecodedCallTrace { diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index c72456d1f57eb..0e05940d51ee5 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -679,3 +679,52 @@ contract ReplayFailuresTest is Test { .join("tests/fixtures/replay_last_run_failures.stdout"), ); }); + +// +forgetest_init!(should_show_precompile_labels, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "Contract.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; +contract PrecompileLabelsTest is Test { + function testPrecompileLabels() public { + vm.deal(address(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D), 1 ether); + vm.deal(address(0x000000000000000000636F6e736F6c652e6c6f67), 1 ether); + vm.deal(address(0x4e59b44847b379578588920cA78FbF26c0B4956C), 1 ether); + vm.deal(address(0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38), 1 ether); + vm.deal(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84), 1 ether); + vm.deal(address(1), 1 ether); + vm.deal(address(2), 1 ether); + vm.deal(address(3), 1 ether); + vm.deal(address(4), 1 ether); + vm.deal(address(5), 1 ether); + vm.deal(address(6), 1 ether); + vm.deal(address(7), 1 ether); + vm.deal(address(8), 1 ether); + vm.deal(address(9), 1 ether); + vm.deal(address(10), 1 ether); + } +} + "#, + ) + .unwrap(); + + let output = cmd.args(["test", "-vvvv"]).stdout_lossy(); + assert!(output.contains("VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D]")); + assert!(output.contains("console: [0x000000000000000000636F6e736F6c652e6c6f67]")); + assert!(output.contains("Create2Deployer: [0x4e59b44847b379578588920cA78FbF26c0B4956C]")); + assert!(output.contains("DefaultSender: [0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38]")); + assert!(output.contains("DefaultTestContract: [0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84]")); + assert!(output.contains("ECRecover: [0x0000000000000000000000000000000000000001]")); + assert!(output.contains("SHA-256: [0x0000000000000000000000000000000000000002]")); + assert!(output.contains("RIPEMD-160: [0x0000000000000000000000000000000000000003]")); + assert!(output.contains("Identity: [0x0000000000000000000000000000000000000004]")); + assert!(output.contains("ModExp: [0x0000000000000000000000000000000000000005]")); + assert!(output.contains("ECAdd: [0x0000000000000000000000000000000000000006]")); + assert!(output.contains("ECMul: [0x0000000000000000000000000000000000000007]")); + assert!(output.contains("ECPairing: [0x0000000000000000000000000000000000000008]")); + assert!(output.contains("Blake2F: [0x0000000000000000000000000000000000000009]")); + assert!(output.contains("PointEvaluation: [0x000000000000000000000000000000000000000A]")); +}); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 537569745aaf4..4d6c091ee842f 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -2,7 +2,7 @@ use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_primitives::U256; -use forge::{fuzz::CounterExample, TestOptions}; +use forge::fuzz::CounterExample; use foundry_test_utils::Filter; use std::collections::BTreeMap; @@ -285,20 +285,16 @@ async fn test_invariant_shrink() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_assert_shrink() { - let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); - opts.fuzz.seed = Some(U256::from(119u32)); - // ensure assert and require shrinks to same sequence of 3 or less - test_shrink(opts.clone(), "InvariantShrinkWithAssert").await; - test_shrink(opts.clone(), "InvariantShrinkWithRequire").await; + test_shrink("invariant_with_assert").await; + test_shrink("invariant_with_require").await; } -async fn test_shrink(opts: TestOptions, contract_pattern: &str) { - let filter = Filter::new( - ".*", - contract_pattern, - ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol", - ); +async fn test_shrink(test_pattern: &str) { + let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); + opts.fuzz.seed = Some(U256::from(100u32)); + let filter = + Filter::new(test_pattern, ".*", ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options = opts; diff --git a/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol index d5dcfe6740a39..34d11ccb3ab3a 100644 --- a/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol @@ -88,26 +88,6 @@ contract InvariantShrinkWithAssert is DSTest { function invariant_with_assert() public { assertTrue(counter.number() != 3, "wrong counter"); } -} - -contract InvariantShrinkWithRequire is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - Counter public counter; - Handler handler; - - function setUp() public { - counter = new Counter(); - handler = new Handler(counter); - } - - function targetSelectors() public returns (FuzzSelector[] memory) { - FuzzSelector[] memory targets = new FuzzSelector[](1); - bytes4[] memory selectors = new bytes4[](2); - selectors[0] = handler.increment.selector; - selectors[1] = handler.setNumber.selector; - targets[0] = FuzzSelector(address(handler), selectors); - return targets; - } function invariant_with_require() public { require(counter.number() != 3, "wrong counter"); From 6499cf215fa7a580a629cd36bed16a9c5f7b02f4 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 9 Jul 2024 19:48:23 +1000 Subject: [PATCH 1227/1963] chore(anvil): fix install cmd in README (#8393) fix install cmd Signed-off-by: Sally MacFarlane --- crates/anvil/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/README.md b/crates/anvil/README.md index dd904c45c9e49..efb0f9e2e5c9a 100644 --- a/crates/anvil/README.md +++ b/crates/anvil/README.md @@ -27,7 +27,7 @@ A local Ethereum node, akin to Ganache, designed for development with [**Forge** ### Installing from source ```sh -cargo install --git https://github.com/foundry-rs/foundry --locked --force +cargo install --git https://github.com/foundry-rs/foundry anvil --locked --force ``` ## Getting started From 687625dbde7645b9e611858d02f416ffb9fb9955 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:44:54 +0300 Subject: [PATCH 1228/1963] chore: fix clippy (#8394) --- crates/anvil/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 93857d80aef19..2f4ed5e4608b7 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1375,7 +1375,7 @@ impl AccountGenerator { let mut wallets = Vec::with_capacity(self.amount); for idx in 0..self.amount { let builder = - builder.clone().derivation_path(&format!("{derivation_path}{idx}")).unwrap(); + builder.clone().derivation_path(format!("{derivation_path}{idx}")).unwrap(); let wallet = builder.build().unwrap().with_chain_id(Some(self.chain_id)); wallets.push(wallet) } From f5576269f2eea594a72e62d38ec46bc94eb43ab7 Mon Sep 17 00:00:00 2001 From: Azleal Date: Tue, 9 Jul 2024 19:11:48 +0800 Subject: [PATCH 1229/1963] fuzz console log & test cases (#8387) * fuze console log & test cases test fuzz console.log * rename to show_fuzz_logs rename to show_fuzz_logs * add logs field in FuzzTestData add logs field in FuzzTestData add logs field in FuzzTestData * rename to show_logs * removed `decoded_logs` in FuzzTestResult & refactored some code fmt * fmt --------- Co-authored-by: Matthias Seitz --- crates/config/src/fuzz.rs | 8 +- crates/evm/evm/src/executors/fuzz/mod.rs | 19 ++-- crates/evm/evm/src/executors/fuzz/types.rs | 4 +- crates/evm/fuzz/src/lib.rs | 3 - crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/test_cmd.rs | 125 +++++++++++++++++++++ crates/forge/tests/it/test_helpers.rs | 1 + 7 files changed, 148 insertions(+), 13 deletions(-) diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index 2d23ad2aeb3eb..fb04383228a9f 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -1,7 +1,8 @@ //! Configuration for fuzz testing. use crate::inline::{ - parse_config_u32, InlineConfigParser, InlineConfigParserError, INLINE_CONFIG_FUZZ_KEY, + parse_config_bool, parse_config_u32, InlineConfigParser, InlineConfigParserError, + INLINE_CONFIG_FUZZ_KEY, }; use alloy_primitives::U256; use serde::{Deserialize, Serialize}; @@ -29,6 +30,8 @@ pub struct FuzzConfig { pub failure_persist_dir: Option, /// Name of the file to record fuzz failures, defaults to `failures`. pub failure_persist_file: Option, + /// show `console.log` in fuzz test, defaults to `false` + pub show_logs: bool, } impl Default for FuzzConfig { @@ -41,6 +44,7 @@ impl Default for FuzzConfig { gas_report_samples: 256, failure_persist_dir: None, failure_persist_file: None, + show_logs: false, } } } @@ -56,6 +60,7 @@ impl FuzzConfig { gas_report_samples: 256, failure_persist_dir: Some(cache_dir), failure_persist_file: Some("failures".to_string()), + show_logs: false, } } } @@ -84,6 +89,7 @@ impl InlineConfigParser for FuzzConfig { conf_clone.dictionary.dictionary_weight = parse_config_u32(key, value)? } "failure-persist-file" => conf_clone.failure_persist_file = Some(value), + "show-logs" => conf_clone.show_logs = parse_config_bool(key, value)?, _ => Err(InlineConfigParserError::InvalidConfigProperty(key))?, } } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 4fcf4e857fb9f..76f01541d5e84 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,14 +1,11 @@ use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{Address, Bytes, Log, U256}; use eyre::Result; use foundry_common::evm::Breakpoints; use foundry_config::FuzzConfig; -use foundry_evm_core::{ - constants::MAGIC_ASSUME, - decode::{decode_console_logs, RevertDecoder}, -}; +use foundry_evm_core::{constants::MAGIC_ASSUME, decode::RevertDecoder}; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ strategies::{fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, @@ -37,6 +34,8 @@ pub struct FuzzTestData { pub breakpoints: Option, // Stores coverage information for all fuzz cases. pub coverage: Option, + // Stores logs for all fuzz cases + pub logs: Vec, } /// Wrapper around an [`Executor`] which provides fuzzing support using [`proptest`]. @@ -90,6 +89,7 @@ impl FuzzedExecutor { ]; // We want to collect at least one trace which will be displayed to user. let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize; + let show_logs = self.config.show_logs; let run_result = self.runner.clone().run(&strat, |calldata| { let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; @@ -113,7 +113,9 @@ impl FuzzedExecutor { data.traces.push(call_traces); data.breakpoints.replace(case.breakpoints); } - + if show_logs { + data.logs.extend(case.logs); + } // Collect and merge coverage if `forge snapshot` context. match &mut data.coverage { Some(prev) => prev.merge(case.coverage.unwrap()), @@ -133,6 +135,7 @@ impl FuzzedExecutor { // to run at least one more case to find a minimal failure // case. let reason = rd.maybe_decode(&outcome.1.result, Some(status)); + execution_data.borrow_mut().logs.extend(outcome.1.logs.clone()); execution_data.borrow_mut().counterexample = outcome; // HACK: we have to use an empty string here to denote `None`. Err(TestCaseError::fail(reason.unwrap_or_default())) @@ -156,8 +159,7 @@ impl FuzzedExecutor { success: run_result.is_ok(), reason: None, counterexample: None, - decoded_logs: decode_console_logs(&call.logs), - logs: call.logs, + logs: fuzz_result.logs, labeled_addresses: call.labels, traces: last_run_traces, breakpoints: last_run_breakpoints, @@ -229,6 +231,7 @@ impl FuzzedExecutor { traces: call.traces, coverage: call.coverage, breakpoints, + logs: call.logs, })) } else { Ok(FuzzOutcome::CounterExample(CounterExampleOutcome { diff --git a/crates/evm/evm/src/executors/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs index 93931f5b0a96b..7ec707eff66a9 100644 --- a/crates/evm/evm/src/executors/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -1,5 +1,5 @@ use crate::executors::RawCallResult; -use alloy_primitives::Bytes; +use alloy_primitives::{Bytes, Log}; use foundry_common::evm::Breakpoints; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::FuzzCase; @@ -17,6 +17,8 @@ pub struct CaseOutcome { pub coverage: Option, /// Breakpoints char pc map pub breakpoints: Breakpoints, + /// logs of a single fuzz test case + pub logs: Vec, } /// Returned by a single fuzz when a counterexample has been discovered diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index e3ee6a05ed027..8f24cba3048ce 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -163,9 +163,6 @@ pub struct FuzzTestResult { /// be printed to the user. pub logs: Vec, - /// The decoded DSTest logging events and Hardhat's `console.log` from [logs](Self::logs). - pub decoded_logs: Vec, - /// Labeled addresses pub labeled_addresses: HashMap, diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 699d48caf5148..e28415e305964 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -74,6 +74,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { seed: Some(U256::from(1000)), failure_persist_dir: Some("test-cache/fuzz".into()), failure_persist_file: Some("failures".to_string()), + show_logs: false, ..Default::default() }, invariant: InvariantConfig { diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 0e05940d51ee5..dbbd348d302b5 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -728,3 +728,128 @@ contract PrecompileLabelsTest is Test { assert!(output.contains("Blake2F: [0x0000000000000000000000000000000000000009]")); assert!(output.contains("PointEvaluation: [0x000000000000000000000000000000000000000A]")); }); + +// tests that `forge test` with config `show_logs: true` for fuzz tests will +// display `console.log` info +forgetest_init!(should_show_logs_when_fuzz_test, |prj, cmd| { + prj.wipe_contracts(); + + // run fuzz test 3 times + let config = Config { + fuzz: { FuzzConfig { runs: 3, show_logs: true, ..Default::default() } }, + ..Default::default() + }; + prj.write_config(config); + let config = cmd.config(); + assert_eq!(config.fuzz.runs, 3); + + prj.add_test( + "ContractFuzz.t.sol", + r#"pragma solidity 0.8.24; + import {Test, console2} from "forge-std/Test.sol"; + contract ContractFuzz is Test { + function testFuzzConsoleLog(uint256 x) public pure { + console2.log("inside fuzz test, x is:", x); + } + } + "#, + ) + .unwrap(); + cmd.args(["test", "-vv"]); + let stdout = cmd.stdout_lossy(); + assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); +}); + +// tests that `forge test` with inline config `show_logs = true` for fuzz tests will +// display `console.log` info +forgetest_init!(should_show_logs_when_fuzz_test_inline_config, |prj, cmd| { + prj.wipe_contracts(); + + // run fuzz test 3 times + let config = + Config { fuzz: { FuzzConfig { runs: 3, ..Default::default() } }, ..Default::default() }; + prj.write_config(config); + let config = cmd.config(); + assert_eq!(config.fuzz.runs, 3); + + prj.add_test( + "ContractFuzz.t.sol", + r#"pragma solidity 0.8.24; + import {Test, console2} from "forge-std/Test.sol"; + contract ContractFuzz is Test { + + /// forge-config: default.fuzz.show-logs = true + function testFuzzConsoleLog(uint256 x) public pure { + console2.log("inside fuzz test, x is:", x); + } + } + "#, + ) + .unwrap(); + cmd.args(["test", "-vv"]); + let stdout = cmd.stdout_lossy(); + assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); +}); + +// tests that `forge test` with config `show_logs: false` for fuzz tests will not display +// `console.log` info +forgetest_init!(should_not_show_logs_when_fuzz_test, |prj, cmd| { + prj.wipe_contracts(); + + // run fuzz test 3 times + let config = Config { + fuzz: { FuzzConfig { runs: 3, show_logs: false, ..Default::default() } }, + ..Default::default() + }; + prj.write_config(config); + let config = cmd.config(); + assert_eq!(config.fuzz.runs, 3); + + prj.add_test( + "ContractFuzz.t.sol", + r#"pragma solidity 0.8.24; + import {Test, console2} from "forge-std/Test.sol"; + contract ContractFuzz is Test { + + function testFuzzConsoleLog(uint256 x) public pure { + console2.log("inside fuzz test, x is:", x); + } + } + "#, + ) + .unwrap(); + cmd.args(["test", "-vv"]); + let stdout = cmd.stdout_lossy(); + assert!(!stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); +}); + +// tests that `forge test` with inline config `show_logs = false` for fuzz tests will not +// display `console.log` info +forgetest_init!(should_not_show_logs_when_fuzz_test_inline_config, |prj, cmd| { + prj.wipe_contracts(); + + // run fuzz test 3 times + let config = + Config { fuzz: { FuzzConfig { runs: 3, ..Default::default() } }, ..Default::default() }; + prj.write_config(config); + let config = cmd.config(); + assert_eq!(config.fuzz.runs, 3); + + prj.add_test( + "ContractFuzz.t.sol", + r#"pragma solidity 0.8.24; + import {Test, console2} from "forge-std/Test.sol"; + contract ContractFuzz is Test { + + /// forge-config: default.fuzz.show-logs = false + function testFuzzConsoleLog(uint256 x) public pure { + console2.log("inside fuzz test, x is:", x); + } + } + "#, + ) + .unwrap(); + cmd.args(["test", "-vv"]); + let stdout = cmd.stdout_lossy(); + assert!(!stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); +}); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 2507f9145ffd4..75da92141c313 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -93,6 +93,7 @@ impl ForgeTestProfile { gas_report_samples: 256, failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), failure_persist_file: Some("testfailure".to_string()), + show_logs: false, }) .invariant(InvariantConfig { runs: 256, From 6df404622e3f1f3525ad08a85e8528ac36bc6158 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:22:35 +0300 Subject: [PATCH 1230/1963] chore: decode test logs only once and if needed (#8396) --- crates/forge/src/result.rs | 12 ------------ crates/forge/tests/it/config.rs | 2 +- crates/forge/tests/it/fuzz.rs | 7 ++++--- crates/forge/tests/it/repros.rs | 7 +++++-- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 42ef35788c31b..8352432e47696 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -1,7 +1,6 @@ //! Test outcomes. use crate::{ - decode::decode_console_logs, fuzz::{BaseCounterExample, FuzzedCases}, gas_report::GasReport, }; @@ -356,9 +355,6 @@ pub struct TestResult { /// be printed to the user. pub logs: Vec, - /// The decoded DSTest logging events and Hardhat's `console.log` from [logs](Self::logs). - pub decoded_logs: Vec, - /// What kind of test this was pub kind: TestKind, @@ -438,7 +434,6 @@ impl TestResult { Self { status: TestStatus::Failure, reason: setup.reason, - decoded_logs: decode_console_logs(&setup.logs), logs: setup.logs, traces: setup.traces, coverage: setup.coverage, @@ -450,7 +445,6 @@ impl TestResult { /// Returns the skipped result for single test (used in skipped fuzz test too). pub fn single_skip(mut self) -> Self { self.status = TestStatus::Skipped; - self.decoded_logs = decode_console_logs(&self.logs); self } @@ -483,7 +477,6 @@ impl TestResult { false => TestStatus::Failure, }; self.reason = reason; - self.decoded_logs = decode_console_logs(&self.logs); self.breakpoints = raw_call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); self.duration = Duration::default(); self.gas_report_traces = Vec::new(); @@ -512,7 +505,6 @@ impl TestResult { }; self.reason = result.reason; self.counterexample = result.counterexample; - self.decoded_logs = decode_console_logs(&self.logs); self.duration = Duration::default(); self.gas_report_traces = result.gas_report_traces.into_iter().map(|t| vec![t]).collect(); self.breakpoints = result.breakpoints.unwrap_or_default(); @@ -523,7 +515,6 @@ impl TestResult { pub fn invariant_skip(mut self) -> Self { self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }; self.status = TestStatus::Skipped; - self.decoded_logs = decode_console_logs(&self.logs); self } @@ -542,7 +533,6 @@ impl TestResult { Some(format!("{invariant_name} persisted failure revert")) }; self.counterexample = Some(CounterExample::Sequence(call_sequence)); - self.decoded_logs = decode_console_logs(&self.logs); self } @@ -551,7 +541,6 @@ impl TestResult { self.kind = TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }; self.status = TestStatus::Failure; self.reason = Some(format!("failed to set up invariant testing environment: {e}")); - self.decoded_logs = decode_console_logs(&self.logs); self } @@ -576,7 +565,6 @@ impl TestResult { }; self.reason = reason; self.counterexample = counterexample; - self.decoded_logs = decode_console_logs(&self.logs); self.gas_report_traces = gas_report_traces; self } diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 21f0d2e17260d..9cabd998a01a8 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -125,7 +125,7 @@ pub fn assert_multiple( "We did not run as many test functions as we expected for {contract_name}" ); for (test_name, should_pass, reason, expected_logs, expected_warning_count) in tests { - let logs = &actuals[*contract_name].test_results[*test_name].decoded_logs; + let logs = &decode_console_logs(&actuals[*contract_name].test_results[*test_name].logs); let warnings_count = &actuals[*contract_name].warnings.len(); diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 4f8a6d41272b9..f1c5edaaa58da 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -3,6 +3,7 @@ use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_primitives::{Bytes, U256}; use forge::{ + decode::decode_console_logs, fuzz::CounterExample, result::{SuiteResult, TestStatus}, }; @@ -31,7 +32,7 @@ async fn test_fuzz() { "Test {} did not pass as expected.\nReason: {:?}\nLogs:\n{}", test_name, result.reason, - result.decoded_logs.join("\n") + decode_console_logs(&result.logs).join("\n") ), _ => assert_eq!( result.status, @@ -39,7 +40,7 @@ async fn test_fuzz() { "Test {} did not fail as expected.\nReason: {:?}\nLogs:\n{}", test_name, result.reason, - result.decoded_logs.join("\n") + decode_console_logs(&result.logs).join("\n") ), } } @@ -67,7 +68,7 @@ async fn test_successful_fuzz_cases() { "Test {} did not pass as expected.\nReason: {:?}\nLogs:\n{}", test_name, result.reason, - result.decoded_logs.join("\n") + decode_console_logs(&result.logs).join("\n") ), _ => {} } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index b251c3d911efa..2310824ed7e57 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -9,7 +9,7 @@ use crate::{ use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; use alloy_json_abi::Event; use alloy_primitives::{address, Address, U256}; -use forge::result::TestStatus; +use forge::{decode::decode_console_logs, result::TestStatus}; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_evm::{ constants::HARDHAT_CONSOLE_ADDRESS, @@ -252,7 +252,10 @@ test_repro!(6501, false, None, |res| { let mut res = res.remove("default/repros/Issue6501.t.sol:Issue6501Test").unwrap(); let test = res.test_results.remove("test_hhLogs()").unwrap(); assert_eq!(test.status, TestStatus::Success); - assert_eq!(test.decoded_logs, ["a".to_string(), "1".to_string(), "b 2".to_string()]); + assert_eq!( + decode_console_logs(&test.logs), + ["a".to_string(), "1".to_string(), "b 2".to_string()] + ); let (kind, traces) = test.traces.last().unwrap().clone(); let nodes = traces.into_nodes(); From 1b1965404ba4dc3f7b4e22ddb38bd9a391e08425 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 9 Jul 2024 15:33:08 +0300 Subject: [PATCH 1231/1963] feat: contract-level inline configs (#8388) * feat: contract-level inline configs * clippy * Fix solang parser * fixes --------- Co-authored-by: Matthias Seitz --- crates/config/src/inline/conf_parser.rs | 20 +-- crates/config/src/inline/mod.rs | 15 +- crates/config/src/inline/natspec.rs | 145 ++++++++++++++----- crates/forge/src/lib.rs | 45 +++--- crates/forge/tests/it/inline.rs | 39 ++++- testdata/default/inline/FuzzInlineConf.t.sol | 12 ++ 6 files changed, 196 insertions(+), 80 deletions(-) diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index 1f6fca6c7ac55..c2b7b39f73d53 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -37,29 +37,17 @@ where /// - `Err(InlineConfigParserError)` in case of wrong configuration. fn try_merge(&self, configs: &[String]) -> Result, InlineConfigParserError>; - /// Validates all configurations contained in a natspec that apply - /// to the current configuration key. - /// - /// i.e. Given the `invariant` config key and a natspec comment of the form, - /// ```solidity - /// /// forge-config: default.invariant.runs = 500 - /// /// forge-config: default.invariant.depth = 500 - /// /// forge-config: ci.invariant.depth = 500 - /// /// forge-config: ci.fuzz.runs = 10 - /// ``` - /// would validate the whole `invariant` configuration. - fn validate_configs(natspec: &NatSpec) -> Result<(), InlineConfigError> { + /// Validates and merges the natspec configs into the current config. + fn merge(&self, natspec: &NatSpec) -> Result, InlineConfigError> { let config_key = Self::config_key(); let configs = natspec.config_lines().filter(|l| l.contains(&config_key)).collect::>(); - Self::default().try_merge(&configs).map_err(|e| { + self.try_merge(&configs).map_err(|e| { let line = natspec.debug_context(); InlineConfigError { line, source: e } - })?; - - Ok(()) + }) } /// Given a list of config lines, returns all available pairs (key, value) matching the current diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index adc67424fc864..9bdf1d5d0ad40 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -25,9 +25,12 @@ static INLINE_CONFIG_PREFIX_SELECTED_PROFILE: Lazy = Lazy::new(|| { /// to create configs directly bound to a solidity test. #[derive(Clone, Debug, Default)] pub struct InlineConfig { + /// Contract-level configurations, used for functions that do not have a specific + /// configuration. + contract_level: HashMap, /// Maps a (test-contract, test-function) pair /// to a specific configuration provided by the user. - configs: HashMap<(String, String), T>, + fn_level: HashMap<(String, String), T>, } impl InlineConfig { @@ -35,18 +38,22 @@ impl InlineConfig { /// Configuration is identified by the pair "contract", "function". pub fn get(&self, contract_id: &str, fn_name: &str) -> Option<&T> { let key = (contract_id.to_string(), fn_name.to_string()); - self.configs.get(&key) + self.fn_level.get(&key).or_else(|| self.contract_level.get(contract_id)) + } + + pub fn insert_contract(&mut self, contract_id: impl Into, config: T) { + self.contract_level.insert(contract_id.into(), config); } /// Inserts an inline configuration, for a test function. /// Configuration is identified by the pair "contract", "function". - pub fn insert(&mut self, contract_id: C, fn_name: F, config: T) + pub fn insert_fn(&mut self, contract_id: C, fn_name: F, config: T) where C: Into, F: Into, { let key = (contract_id.into(), fn_name.into()); - self.configs.insert(key, config); + self.fn_level.insert(key, config); } } diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index de7182cbbc098..6dd6b696c0150 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -4,7 +4,7 @@ use foundry_compilers::{ ProjectCompileOutput, }; use serde_json::Value; -use solang_parser::pt; +use solang_parser::{helpers::CodeLocation, pt}; use std::{collections::BTreeMap, path::Path}; /// Convenient struct to hold in-line per-test configurations @@ -12,8 +12,8 @@ use std::{collections::BTreeMap, path::Path}; pub struct NatSpec { /// The parent contract of the natspec pub contract: String, - /// The function annotated with the natspec - pub function: String, + /// The function annotated with the natspec. None if the natspec is contract-level + pub function: Option, /// The line the natspec appears, in the form /// `row:col:length` i.e. `10:21:122` pub line: String, @@ -41,7 +41,7 @@ impl NatSpec { let mut used_solc_ast = false; if let Some(ast) = &artifact.ast { if let Some(node) = solc.contract_root_node(&ast.nodes, &contract) { - solc.parse(&mut natspecs, &contract, node); + solc.parse(&mut natspecs, &contract, node, true); used_solc_ast = true; } } @@ -60,7 +60,7 @@ impl NatSpec { /// context, for debugging purposes 🐞 /// i.e. `test/Counter.t.sol:CounterTest:testFuzz_SetNumber` pub fn debug_context(&self) -> String { - format!("{}:{}", self.contract, self.function) + format!("{}:{}", self.contract, self.function.as_deref().unwrap_or_default()) } /// Returns a list of configuration lines that match the current profile @@ -109,12 +109,23 @@ impl SolcParser { /// Implements a DFS over a compiler output node and its children. /// If a natspec is found it is added to `natspecs` - fn parse(&self, natspecs: &mut Vec, contract: &str, node: &Node) { + fn parse(&self, natspecs: &mut Vec, contract: &str, node: &Node, root: bool) { + // If we're at the root contract definition node, try parsing contract-level natspec + if root { + if let Some((docs, line)) = self.get_node_docs(&node.other) { + natspecs.push(NatSpec { contract: contract.into(), function: None, docs, line }) + } + } for n in node.nodes.iter() { if let Some((function, docs, line)) = self.get_fn_data(n) { - natspecs.push(NatSpec { contract: contract.into(), function, line, docs }) + natspecs.push(NatSpec { + contract: contract.into(), + function: Some(function), + line, + docs, + }) } - self.parse(natspecs, contract, n); + self.parse(natspecs, contract, n, false); } } @@ -129,7 +140,7 @@ impl SolcParser { if node.node_type == NodeType::FunctionDefinition { let fn_data = &node.other; let fn_name: String = self.get_fn_name(fn_data)?; - let (fn_docs, docs_src_line): (String, String) = self.get_fn_docs(fn_data)?; + let (fn_docs, docs_src_line) = self.get_node_docs(fn_data)?; return Some((fn_name, fn_docs, docs_src_line)) } @@ -149,8 +160,8 @@ impl SolcParser { /// textual natspec representation, the second item is the natspec src line, in the form /// "raw:col:length". /// - `None` in case the function has not natspec comments. - fn get_fn_docs(&self, fn_data: &BTreeMap) -> Option<(String, String)> { - if let Value::Object(fn_docs) = fn_data.get("documentation")? { + fn get_node_docs(&self, data: &BTreeMap) -> Option<(String, String)> { + if let Value::Object(fn_docs) = data.get("documentation")? { if let Value::String(comment) = fn_docs.get("text")? { if comment.contains(INLINE_CONFIG_PREFIX) { let mut src_line = fn_docs @@ -189,32 +200,55 @@ impl SolangParser { } let Ok((pt, comments)) = solang_parser::parse(src, 0) else { return }; + + // Collects natspects from the given range. + let mut handle_docs = |contract: &str, func: Option<&str>, start, end| { + let docs = solang_parser::doccomment::parse_doccomments(&comments, start, end); + natspecs.extend( + docs.into_iter() + .flat_map(|doc| doc.into_comments()) + .filter(|doc| doc.value.contains(INLINE_CONFIG_PREFIX)) + .map(|doc| NatSpec { + // not possible to obtain correct value due to solang-parser bug + // https://github.com/hyperledger/solang/issues/1658 + line: "0:0:0".to_string(), + contract: contract.to_string(), + function: func.map(|f| f.to_string()), + docs: doc.value, + }), + ); + }; + + let mut prev_item_end = 0; for item in &pt.0 { - let pt::SourceUnitPart::ContractDefinition(c) = item else { continue }; - let Some(id) = c.name.as_ref() else { continue }; + let pt::SourceUnitPart::ContractDefinition(c) = item else { + prev_item_end = item.loc().end(); + continue + }; + let Some(id) = c.name.as_ref() else { + prev_item_end = item.loc().end(); + continue + }; if id.name != contract_name { + prev_item_end = item.loc().end(); continue }; + + // Handle doc comments in between the previous contract and the current one. + handle_docs(contract_id, None, prev_item_end, item.loc().start()); + let mut prev_end = c.loc.start(); for part in &c.parts { let pt::ContractPart::FunctionDefinition(f) = part else { continue }; let start = f.loc.start(); - // Parse doc comments in between the previous function and the current one. - let docs = solang_parser::doccomment::parse_doccomments(&comments, prev_end, start); - let docs = docs - .into_iter() - .flat_map(|doc| doc.into_comments()) - .filter(|doc| doc.value.contains(INLINE_CONFIG_PREFIX)); - for doc in docs { - natspecs.push(NatSpec { - contract: contract_id.to_string(), - function: f.name.as_ref().map(|id| id.to_string()).unwrap_or_default(), - line: "0:0:0".to_string(), - docs: doc.value, - }); + // Handle doc comments in between the previous function and the current one. + if let Some(name) = &f.name { + handle_docs(contract_id, Some(name.name.as_str()), prev_end, start); } prev_end = f.loc.end(); } + + prev_item_end = item.loc().end(); } } } @@ -253,28 +287,28 @@ function f2() {} /** forge-config: default.fuzz.runs = 800 */ function f3() {} // f1 NatSpec { contract: id(), - function: "f1".to_string(), + function: Some("f1".to_string()), line: default_line(), docs: "forge-config: default.fuzz.runs = 600\nforge-config: default.fuzz.runs = 601".to_string(), }, // f2 NatSpec { contract: id(), - function: "f2".to_string(), + function: Some("f2".to_string()), line: default_line(), docs: "forge-config: default.fuzz.runs = 700".to_string(), }, // f3 NatSpec { contract: id(), - function: "f3".to_string(), + function: Some("f3".to_string()), line: default_line(), docs: "forge-config: default.fuzz.runs = 800".to_string(), }, // f4 NatSpec { contract: id(), - function: "f4".to_string(), + function: Some("f4".to_string()), line: default_line(), docs: "forge-config: default.fuzz.runs = 1024\nforge-config: default.fuzz.max-test-rejects = 500".to_string(), }, @@ -310,7 +344,7 @@ contract FuzzInlineConf is DSTest { [ NatSpec { contract: id(), - function: "testInlineConfFuzz".to_string(), + function: Some("testInlineConfFuzz".to_string()), line: default_line(), docs: "forge-config: default.fuzz.runs = 1024\nforge-config: default.fuzz.max-test-rejects = 500".to_string(), }, @@ -366,7 +400,7 @@ contract FuzzInlineConf is DSTest { let mut fn_data: BTreeMap = BTreeMap::new(); let doc_without_src_field = json!({ "text": "forge-config:default.fuzz.runs=600" }); fn_data.insert("documentation".into(), doc_without_src_field); - let (_, src_line) = SolcParser::new().get_fn_docs(&fn_data).expect("Some docs"); + let (_, src_line) = SolcParser::new().get_node_docs(&fn_data).expect("Some docs"); assert_eq!(src_line, "".to_string()); } @@ -376,7 +410,7 @@ contract FuzzInlineConf is DSTest { let doc_without_src_field = json!({ "text": "forge-config:default.fuzz.runs=600", "src": "73:21:12" }); fn_data.insert("documentation".into(), doc_without_src_field); - let (_, src_line) = SolcParser::new().get_fn_docs(&fn_data).expect("Some docs"); + let (_, src_line) = SolcParser::new().get_node_docs(&fn_data).expect("Some docs"); assert_eq!(src_line, "73:21:12".to_string()); } @@ -395,7 +429,7 @@ contract FuzzInlineConf is DSTest { NatSpec { contract: "dir/TestContract.t.sol:FuzzContract".to_string(), - function: "test_myFunction".to_string(), + function: Some("test_myFunction".to_string()), line: "10:12:111".to_string(), docs: conf.to_string(), } @@ -428,7 +462,7 @@ contract FuzzInlineConf2 is DSTest { natspecs, [NatSpec { contract: id(), - function: "testInlineConfFuzz1".to_string(), + function: Some("testInlineConfFuzz1".to_string()), line: default_line(), docs: "forge-config: default.fuzz.runs = 1".to_string(), },] @@ -441,11 +475,50 @@ contract FuzzInlineConf2 is DSTest { natspecs, [NatSpec { contract: id(), - function: "testInlineConfFuzz2".to_string(), + function: Some("testInlineConfFuzz2".to_string()), line: default_line(), // should not get config from previous contract docs: "forge-config: default.fuzz.runs = 2".to_string(), },] ); } + + #[test] + fn parse_contract_level_config() { + let src = r#" +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity >=0.8.0; + +import "ds-test/test.sol"; + +/// forge-config: default.fuzz.runs = 1 +contract FuzzInlineConf is DSTest { + /// forge-config: default.fuzz.runs = 3 + function testInlineConfFuzz1() {} + + function testInlineConfFuzz2() {} +}"#; + let mut natspecs = vec![]; + let solang = SolangParser::new(); + let id = || "inline/FuzzInlineConf.t.sol:FuzzInlineConf".to_string(); + let default_line = || "0:0:0".to_string(); + solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); + assert_eq!( + natspecs, + [ + NatSpec { + contract: id(), + function: None, + line: default_line(), + docs: "forge-config: default.fuzz.runs = 1".to_string(), + }, + NatSpec { + contract: id(), + function: Some("testInlineConfFuzz1".to_string()), + line: default_line(), + docs: "forge-config: default.fuzz.runs = 3".to_string(), + } + ] + ); + } } diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index c46800067ce44..6ad91ab6620c6 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -60,28 +60,37 @@ impl TestOptions { let mut inline_invariant = InlineConfig::::default(); let mut inline_fuzz = InlineConfig::::default(); - for natspec in natspecs { - // Perform general validation - validate_profiles(&natspec, &profiles)?; - FuzzConfig::validate_configs(&natspec)?; - InvariantConfig::validate_configs(&natspec)?; + // Validate all natspecs + for natspec in &natspecs { + validate_profiles(natspec, &profiles)?; + } + + // Firstly, apply contract-level configurations + for natspec in natspecs.iter().filter(|n| n.function.is_none()) { + if let Some(fuzz) = base_fuzz.merge(natspec)? { + inline_fuzz.insert_contract(&natspec.contract, fuzz); + } + + if let Some(invariant) = base_invariant.merge(natspec)? { + inline_invariant.insert_contract(&natspec.contract, invariant); + } + } + for (natspec, f) in natspecs.iter().filter_map(|n| n.function.as_ref().map(|f| (n, f))) { // Apply in-line configurations for the current profile - let configs: Vec = natspec.current_profile_configs().collect(); - let c: &str = &natspec.contract; - let f: &str = &natspec.function; - let line: String = natspec.debug_context(); - - match base_fuzz.try_merge(&configs) { - Ok(Some(conf)) => inline_fuzz.insert(c, f, conf), - Ok(None) => { /* No inline config found, do nothing */ } - Err(e) => Err(InlineConfigError { line: line.clone(), source: e })?, + let c = &natspec.contract; + + // We might already have inserted contract-level configs above, so respect data already + // present in inline configs. + let base_fuzz = inline_fuzz.get(c, f).unwrap_or(&base_fuzz); + let base_invariant = inline_invariant.get(c, f).unwrap_or(&base_invariant); + + if let Some(fuzz) = base_fuzz.merge(natspec)? { + inline_fuzz.insert_fn(c, f, fuzz); } - match base_invariant.try_merge(&configs) { - Ok(Some(conf)) => inline_invariant.insert(c, f, conf), - Ok(None) => { /* No inline config found, do nothing */ } - Err(e) => Err(InlineConfigError { line: line.clone(), source: e })?, + if let Some(invariant) = base_invariant.merge(natspec)? { + inline_invariant.insert_fn(c, f, invariant); } } diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 09d4fb3230339..ed7729f7f9d8d 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -10,12 +10,39 @@ async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); let result = runner.test_collect(&filter); - let suite_result = result.get("default/inline/FuzzInlineConf.t.sol:FuzzInlineConf").unwrap(); - let test_result = suite_result.test_results.get("testInlineConfFuzz(uint8)").unwrap(); - match test_result.kind { - TestKind::Fuzz { runs, .. } => assert_eq!(runs, 1024), - _ => unreachable!(), - } + let results = result + .into_iter() + .flat_map(|(path, r)| { + r.test_results.into_iter().map(move |(name, t)| { + let runs = match t.kind { + TestKind::Fuzz { runs, .. } => runs, + _ => unreachable!(), + }; + (path.clone(), name, runs) + }) + }) + .collect::>(); + + assert_eq!( + results, + vec![ + ( + "default/inline/FuzzInlineConf.t.sol:FuzzInlineConf".to_string(), + "testInlineConfFuzz(uint8)".to_string(), + 1024 + ), + ( + "default/inline/FuzzInlineConf.t.sol:FuzzInlineConf2".to_string(), + "testInlineConfFuzz1(uint8)".to_string(), + 1 + ), + ( + "default/inline/FuzzInlineConf.t.sol:FuzzInlineConf2".to_string(), + "testInlineConfFuzz2(uint8)".to_string(), + 10 + ), + ] + ); } #[tokio::test(flavor = "multi_thread")] diff --git a/testdata/default/inline/FuzzInlineConf.t.sol b/testdata/default/inline/FuzzInlineConf.t.sol index f6cf60fe71f17..3789313128000 100644 --- a/testdata/default/inline/FuzzInlineConf.t.sol +++ b/testdata/default/inline/FuzzInlineConf.t.sol @@ -12,3 +12,15 @@ contract FuzzInlineConf is DSTest { require(true, "this is not going to revert"); } } + +/// forge-config: default.fuzz.runs = 10 +contract FuzzInlineConf2 is DSTest { + /// forge-config: default.fuzz.runs = 1 + function testInlineConfFuzz1(uint8 x) public { + require(true, "this is not going to revert"); + } + + function testInlineConfFuzz2(uint8 x) public { + require(true, "this is not going to revert"); + } +} From 7c4482fc9541f11b57575e2d8bf7bd190b61bda6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:43:27 +0200 Subject: [PATCH 1232/1963] chore(deps): cargo update (#8397) * chore(deps): cargo update Locking 45 packages to latest compatible versions Updating alloy-consensus v0.1.3 -> v0.1.4 Updating alloy-contract v0.1.3 -> v0.1.4 Updating alloy-dyn-abi v0.7.6 -> v0.7.7 Updating alloy-eips v0.1.3 -> v0.1.4 Updating alloy-genesis v0.1.3 -> v0.1.4 Updating alloy-json-abi v0.7.6 -> v0.7.7 Updating alloy-json-rpc v0.1.3 -> v0.1.4 Updating alloy-network v0.1.3 -> v0.1.4 Updating alloy-primitives v0.7.6 -> v0.7.7 Updating alloy-provider v0.1.3 -> v0.1.4 Updating alloy-pubsub v0.1.3 -> v0.1.4 Updating alloy-rpc-client v0.1.3 -> v0.1.4 Updating alloy-rpc-types v0.1.3 -> v0.1.4 Updating alloy-rpc-types-anvil v0.1.3 -> v0.1.4 Updating alloy-rpc-types-engine v0.1.3 -> v0.1.4 Updating alloy-rpc-types-eth v0.1.3 -> v0.1.4 Updating alloy-rpc-types-trace v0.1.3 -> v0.1.4 Updating alloy-rpc-types-txpool v0.1.3 -> v0.1.4 Updating alloy-serde v0.1.3 -> v0.1.4 Updating alloy-signer v0.1.3 -> v0.1.4 Updating alloy-signer-aws v0.1.3 -> v0.1.4 Updating alloy-signer-gcp v0.1.3 -> v0.1.4 Updating alloy-signer-ledger v0.1.3 -> v0.1.4 Updating alloy-signer-local v0.1.3 -> v0.1.4 Updating alloy-signer-trezor v0.1.3 -> v0.1.4 Updating alloy-sol-macro v0.7.6 -> v0.7.7 Updating alloy-sol-macro-expander v0.7.6 -> v0.7.7 Updating alloy-sol-macro-input v0.7.6 -> v0.7.7 Updating alloy-sol-type-parser v0.7.6 -> v0.7.7 Updating alloy-sol-types v0.7.6 -> v0.7.7 Updating alloy-transport v0.1.3 -> v0.1.4 Updating alloy-transport-http v0.1.3 -> v0.1.4 Updating alloy-transport-ipc v0.1.3 -> v0.1.4 Updating alloy-transport-ws v0.1.3 -> v0.1.4 Updating async-trait v0.1.80 -> v0.1.81 Updating cc v1.0.104 -> v1.1.0 Updating clap v4.5.8 -> v4.5.9 Updating clap_builder v4.5.8 -> v4.5.9 Updating rustls v0.23.10 -> v0.23.11 Updating syn v2.0.69 -> v2.0.70 Updating syn-solidity v0.7.6 -> v0.7.7 Updating tinyvec v1.7.0 -> v1.8.0 Updating toml_edit v0.22.14 -> v0.22.15 Updating unicode-truncate v1.0.0 -> v1.1.0 Updating uuid v1.9.1 -> v1.10.0 * updates * chore: update deny to lessen spam --- Cargo.lock | 311 +++++++++++++------------- crates/anvil/src/eth/otterscan/api.rs | 52 +++-- crates/anvil/tests/it/otterscan.rs | 9 +- crates/forge/tests/it/repros.rs | 5 +- deny.toml | 4 +- 5 files changed, 197 insertions(+), 184 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13a22a7d2ada6..0a207fb3b1af7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f63a6c9eb45684a5468536bc55379a2af0f45ffa5d756e4e4964532737e1836" +checksum = "da374e868f54c7f4ad2ad56829827badca388efd645f8cf5fccc61c2b5343504" dependencies = [ "alloy-eips", "alloy-primitives", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c26b7d34cb76f826558e9409a010e25257f7bfb5aa5e3dd0042c564664ae159" +checksum = "7dc6957ff706f9e5f6fd42f52a93e4bce476b726c92d077b348de28c4a76730c" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6e6436a9530f25010d13653e206fab4c9feddacf21a54de8d7311b275bc56b" +checksum = "413902aa18a97569e60f679c23f46a18db1656d87ab4d4e49d0e1e52042f66df" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -134,9 +134,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4b0fc6a572ef2eebda0a31a5e393d451abda703fec917c75d9615d8c978cf2" +checksum = "f76ecab54890cdea1e4808fc0891c7e6cfcf71fe1a9fe26810c7280ef768f4ed" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48450f9c6f0821c1eee00ed912942492ed4f11dd69532825833de23ecc7a2256" +checksum = "bca15afde1b6d15e3fc1c97421262b1bbb37aee45752e3c8b6d6f13f776554ff" dependencies = [ "alloy-primitives", "alloy-serde", @@ -161,9 +161,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" +checksum = "bc05b04ac331a9f07e3a4036ef7926e49a8bf84a99a1ccfc7e2ab55a5fcbb372" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d484c2a934d0a4d86f8ad4db8113cb1d607707a6c54f6e78f4f1b4451b47aa70" +checksum = "6d6f34930b7e3e2744bcc79056c217f00cb2abb33bc5d4ff88da7623c5bb078b" dependencies = [ "alloy-primitives", "serde", @@ -186,9 +186,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a20eba9bc551037f0626d6d29e191888638d979943fa4e842e9e6fc72bf0565" +checksum = "25f6895fc31b48fa12306ef9b4f78b7764f8bd6d7d91cdb0a40e233704a0f23f" dependencies = [ "alloy-consensus", "alloy-eips", @@ -206,9 +206,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" +checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" dependencies = [ "alloy-rlp", "arbitrary", @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad5d89acb7339fad13bc69e7b925232f242835bfd91c82fcb9326b36481bd0f0" +checksum = "9c538bfa893d07e27cb4f3c1ab5f451592b7c526d511d62b576a2ce59e146e4a" dependencies = [ "alloy-chains", "alloy-consensus", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034258dfaa51c278e1f7fcc46e587d10079ec9372866fa48c5df9d908fc1f6b1" +checksum = "0a7341322d9bc0e49f6e9fd9f2eb8e30f73806f2dd12cbb3d6bab2694c921f87" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -306,14 +306,14 @@ checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] name = "alloy-rpc-client" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ce003e8c74bbbc7d4235131c1d6b7eaf14a533ae850295b90d240340989cb" +checksum = "5ba31bae67773fd5a60020bea900231f8396202b7feca4d0c70c6b59308ab4a8" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -336,9 +336,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dfa1dd3e0bc3a3d89744fba8d1511216e83257160da2cd028a18b7d9c026030" +checksum = "184a7a42c7ba9141cc9e76368356168c282c3bc3d9e5d78f3556bdfe39343447" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -350,9 +350,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67aec11f9f3bc5e96c2b7f342dba6e9541a8a48d2cfbe27b6b195136aa18eee" +checksum = "8c7cf4356a9d00df76d6e90d002e2a7b5edc1c8476e90e6f17ab868d99db6435" dependencies = [ "alloy-primitives", "alloy-serde", @@ -361,9 +361,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc40df2dda7561d1406d0bee1d19c8787483a2cf2ee8011c05909475e7bc102d" +checksum = "6e765962e3b82fd6f276a0873b5bd897e5d75a25f78fa9a6a21bd350d8e98a4e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -379,9 +379,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd7aa9ff9e67f1ba7ee0dd8cebfc95831d1649b0e4eeefae940dc3681079fa" +checksum = "ab4123ee21f99ba4bd31bfa36ba89112a18a500f8b452f02b35708b1b951e2b9" dependencies = [ "alloy-consensus", "alloy-eips", @@ -397,9 +397,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d26db98ac320a0d1637faf3e210328c3df3b1998abd7e72343d3857058efe" +checksum = "567933b1d95fd42cb70b75126e32afec2e5e2c3c16e7100a3f83dc1c80f4dc0e" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -411,9 +411,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971c92989c6a5588d3f6d1e99e5328fba6e68694efbe969d6ec96ae5b9d1037" +checksum = "3115f4eb1bb9ae9aaa0b24ce875a1d86d6689b16438a12377832def2b09e373c" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8913f9e825068d77c516188c221c44f78fd814fce8effe550a783295a2757d19" +checksum = "9416c52959e66ead795a11f4a86c248410e9e368a0765710e57055b8a1774dd6" dependencies = [ "alloy-primitives", "serde", @@ -434,9 +434,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f740e13eb4c6a0e4d0e49738f1e86f31ad2d7ef93be499539f492805000f7237" +checksum = "b33753c09fa1ad85e5b092b8dc2372f1e337a42e84b9b4cff9fede75ba4adb32" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -450,9 +450,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9573e8a5339fefc515b3e336fae177e2080225a4ea49cd5ab24de4b0bdc81d" +checksum = "63ce17bfd5aa38e14b9c83b553d93c76e1bd5641a2db45f381f81619fd3e54ca" dependencies = [ "alloy-consensus", "alloy-network", @@ -468,9 +468,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4911b3b4e104af7ed40bf51031a6f0f2400788759f6073a5d90003db6bb88fe6" +checksum = "2804c1d4fae0341195def6c5eb6efc65756cdf8cd3c0087ad2afff7972f8a115" dependencies = [ "alloy-consensus", "alloy-network", @@ -486,9 +486,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb31f033976724d10f90633477436f5e3757b04283c475a750a77e82422aa36" +checksum = "575e4c924b23132234c75bd1f8f3871c1bc12ba462f76af9b59249515a38253e" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -506,9 +506,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87db68d926887393a1d0f9c43833b44446ea29d603291e7b20e5d115f31aa4e3" +checksum = "6dfc9c26fe6c6f1bad818c9a976de9044dd12e1f75f1f156a801ee3e8148c1b6" dependencies = [ "alloy-consensus", "alloy-network", @@ -526,9 +526,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c0c55911ca291f842f7d18a06a993679fe672d5d02049c665fa01aafa2b31a" +checksum = "fd82e86e4a6604fd11f84b170638d16dcdac9db6c2b5f5b91a3941b7e7af7f94" dependencies = [ "alloy-consensus", "alloy-network", @@ -543,23 +543,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" +checksum = "2b40397ddcdcc266f59f959770f601ce1280e699a91fc1862f29cef91707cd09" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" +checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -569,16 +569,16 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" +checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" dependencies = [ "alloy-json-abi", "const-hex", @@ -587,24 +587,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.69", + "syn 2.0.70", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" +checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" dependencies = [ + "serde", "winnow 0.6.13", ] [[package]] name = "alloy-sol-types" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" +checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -615,9 +616,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd9773e4ec6832346171605c776315544bd06e40f803e7b5b7824b325d5442ca" +checksum = "01b51a291f949f755e6165c3ed562883175c97423703703355f4faa4b7d0a57c" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -628,14 +629,15 @@ dependencies = [ "thiserror", "tokio", "tower", + "tracing", "url", ] [[package]] name = "alloy-transport-http" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8ef947b901c0d4e97370f9fa25844cf8b63b1a58fd4011ee82342dc8a9fc6b" +checksum = "86d65871f9f1cafe1ed25cde2f1303be83e6473e995a2d56c275ae4fcce6119c" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -648,9 +650,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb40ee66887a66d875a5bb5e01cee4c9a467c263ef28c865cd4b0ebf15f705af" +checksum = "cd7fbc8b6282ce41b01cbddef7bffb133fe6e1bf65dcd39770d45a905c051179" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -669,15 +671,15 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d92049d6642a18c9849ce7659430151e7c92b51552a0cabdc038c1af4cd7308" +checksum = "aec83fd052684556c78c54df111433493267234d82321c2236560c752f595f20" dependencies = [ "alloy-pubsub", "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.10", + "rustls 0.23.11", "serde_json", "tokio", "tokio-tungstenite 0.23.1", @@ -1097,7 +1099,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -1119,18 +1121,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -1177,7 +1179,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -1249,7 +1251,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.9.1", + "uuid 1.10.0", ] [[package]] @@ -1971,9 +1973,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.104" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" +checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" dependencies = [ "jobserver", "libc", @@ -2083,9 +2085,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -2093,9 +2095,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -2134,7 +2136,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2564,7 +2566,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2575,7 +2577,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2647,7 +2649,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2668,7 +2670,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2678,7 +2680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2691,7 +2693,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2798,7 +2800,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -2934,7 +2936,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -3084,7 +3086,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.69", + "syn 2.0.70", "toml 0.8.14", "walkdir", ] @@ -3112,7 +3114,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.69", + "syn 2.0.70", "tempfile", "thiserror", "tiny-keccak", @@ -3369,7 +3371,7 @@ dependencies = [ "tikv-jemallocator", "tokio", "toml 0.8.14", - "toml_edit 0.22.14", + "toml_edit 0.22.15", "tower-http", "tracing", "tracing-subscriber", @@ -3474,7 +3476,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -3826,7 +3828,7 @@ dependencies = [ "tempfile", "thiserror", "toml 0.8.14", - "toml_edit 0.22.14", + "toml_edit 0.22.15", "tracing", "walkdir", ] @@ -4032,7 +4034,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -4190,7 +4192,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -4692,7 +4694,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -4855,7 +4857,7 @@ dependencies = [ "http 1.1.0", "hyper 1.4.0", "hyper-util", - "rustls 0.23.10", + "rustls 0.23.11", "rustls-native-certs 0.7.1", "rustls-pki-types", "tokio", @@ -5548,7 +5550,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -5618,7 +5620,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -5849,7 +5851,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -5972,7 +5974,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -6143,7 +6145,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -6202,7 +6204,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -6286,7 +6288,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -6344,7 +6346,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -6460,7 +6462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -6536,7 +6538,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", "version_check", "yansi", ] @@ -6603,7 +6605,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -6679,7 +6681,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 1.1.0", - "rustls 0.23.10", + "rustls 0.23.11", "thiserror", "tokio", "tracing", @@ -6695,7 +6697,7 @@ dependencies = [ "rand", "ring", "rustc-hash 1.1.0", - "rustls 0.23.10", + "rustls 0.23.11", "slab", "thiserror", "tinyvec", @@ -6977,7 +6979,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.10", + "rustls 0.23.11", "rustls-native-certs 0.7.1", "rustls-pemfile 2.1.2", "rustls-pki-types", @@ -7282,9 +7284,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.10" +version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", "ring", @@ -7493,7 +7495,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -7655,7 +7657,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -7666,7 +7668,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -7709,7 +7711,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -7755,7 +7757,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -7993,8 +7995,8 @@ dependencies = [ "simple-home-dir", "tokio", "toml 0.8.14", - "toml_edit 0.22.14", - "uuid 1.9.1", + "toml_edit 0.22.15", + "uuid 1.10.0", "walkdir", "yansi", "yash-fnmatch", @@ -8025,7 +8027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -8091,7 +8093,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -8159,9 +8161,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.69" +version = "2.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" dependencies = [ "proc-macro2", "quote", @@ -8170,14 +8172,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" +checksum = "c837dc8852cb7074e46b444afb81783140dab12c58867b49fb3898fbafedf7ea" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -8299,7 +8301,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -8395,9 +8397,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -8445,7 +8447,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -8485,7 +8487,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.10", + "rustls 0.23.11", "rustls-pki-types", "tokio", ] @@ -8522,7 +8524,7 @@ checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" dependencies = [ "futures-util", "log", - "rustls 0.23.10", + "rustls 0.23.11", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -8562,7 +8564,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.14", + "toml_edit 0.22.15", ] [[package]] @@ -8587,9 +8589,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" dependencies = [ "indexmap 2.2.6", "serde", @@ -8724,7 +8726,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -8859,7 +8861,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.10", + "rustls 0.23.11", "rustls-pki-types", "sha1", "thiserror", @@ -8950,11 +8952,12 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-truncate" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5fbabedabe362c618c714dbefda9927b5afc8e2a8102f47f081089a9019226" +checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" dependencies = [ - "itertools 0.12.1", + "itertools 0.13.0", + "unicode-segmentation", "unicode-width", ] @@ -9017,9 +9020,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom", "serde", @@ -9116,7 +9119,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", "wasm-bindgen-shared", ] @@ -9150,7 +9153,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9651,7 +9654,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] @@ -9671,7 +9674,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.69", + "syn 2.0.70", ] [[package]] diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 4609cc7ac809a..f174d79f59cdc 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -44,27 +44,35 @@ pub fn mentions_address(trace: LocalizedTransactionTrace, address: Address) -> O pub fn batch_build_ots_traces(traces: Vec) -> Vec { traces .into_iter() - .filter_map(|trace| match trace.trace.action { - Action::Call(call) => { - let ots_type = match call.call_type { - CallType::Call => "CALL", - CallType::CallCode => "CALLCODE", - CallType::DelegateCall => "DELEGATECALL", - CallType::StaticCall => "STATICCALL", - CallType::AuthCall => "AUTHCALL", - CallType::None => "NONE", - } - .to_string(); - Some(TraceEntry { - r#type: ots_type, + .filter_map(|trace| { + let output = trace + .trace + .result + .map(|r| match r { + TraceOutput::Call(output) => output.output, + TraceOutput::Create(output) => output.code, + }) + .unwrap_or_default(); + match trace.trace.action { + Action::Call(call) => Some(TraceEntry { + r#type: match call.call_type { + CallType::Call => "CALL", + CallType::CallCode => "CALLCODE", + CallType::DelegateCall => "DELEGATECALL", + CallType::StaticCall => "STATICCALL", + CallType::AuthCall => "AUTHCALL", + CallType::None => "NONE", + } + .to_string(), depth: trace.trace.trace_address.len() as u32, from: call.from, to: call.to, value: call.value, - input: call.input.0.into(), - }) + input: call.input, + output, + }), + Action::Create(_) | Action::Selfdestruct(_) | Action::Reward(_) => None, } - Action::Create(_) | Action::Selfdestruct(_) | Action::Reward(_) => None, }) .collect() } @@ -307,14 +315,10 @@ impl EthApi { Action::Create(CreateAction { from, .. }), Some(TraceOutput::Create(CreateOutput { address, .. })), ) if address == addr => { - let tx = self - .backend - .transaction_by_hash(trace.transaction_hash.unwrap()) - .await - .unwrap() - .unwrap() - .inner; - return Ok(Some(ContractCreator { tx, creator: from })); + return Ok(Some(ContractCreator { + hash: trace.transaction_hash.unwrap(), + creator: from, + })); } _ => {} } diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 63453a37e8786..37da4f00006e5 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -8,7 +8,7 @@ use alloy_rpc_types::{ BlockNumberOrTag, BlockTransactions, TransactionRequest, }; use alloy_serde::WithOtherFields; -use alloy_sol_types::{sol, SolCall, SolError}; +use alloy_sol_types::{sol, SolCall, SolError, SolValue}; use anvil::{spawn, Hardfork, NodeConfig}; use std::collections::VecDeque; @@ -243,6 +243,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::from(1337), input: Contract::runCall::SELECTOR.into(), + output: Bytes::new(), }, TraceEntry { r#type: "STATICCALL".to_string(), @@ -251,6 +252,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::ZERO, input: Contract::do_staticcallCall::SELECTOR.into(), + output: true.abi_encode().into(), }, TraceEntry { r#type: "CALL".to_string(), @@ -259,6 +261,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::ZERO, input: Contract::do_callCall::SELECTOR.into(), + output: Bytes::new(), }, TraceEntry { r#type: "CALL".to_string(), @@ -267,6 +270,7 @@ async fn test_call_ots_trace_transaction() { to: sender, value: U256::from(1337), input: Bytes::new(), + output: Bytes::new(), }, TraceEntry { r#type: "DELEGATECALL".to_string(), @@ -275,6 +279,7 @@ async fn test_call_ots_trace_transaction() { to: contract_address, value: U256::ZERO, input: Contract::do_delegatecallCall::SELECTOR.into(), + output: Bytes::new(), }, ]; assert_eq!(res, expected); @@ -516,5 +521,5 @@ async fn ots_get_contract_creator() { let creator = api.ots_get_contract_creator(contract_address).await.unwrap().unwrap(); assert_eq!(creator.creator, sender); - assert_eq!(creator.tx.hash, receipt.transaction_hash); + assert_eq!(creator.hash, receipt.transaction_hash); } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 2310824ed7e57..b7b6c1063cf0c 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -8,7 +8,7 @@ use crate::{ }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; use alloy_json_abi::Event; -use alloy_primitives::{address, Address, U256}; +use alloy_primitives::{address, b256, Address, U256}; use forge::{decode::decode_console_logs, result::TestStatus}; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_evm::{ @@ -132,6 +132,9 @@ test_repro!(3347, false, None, |res| { assert_eq!( decoded, DecodedEvent { + selector: Some(b256!( + "78b9a1f3b55d6797ab2c4537e83ee04ff0c65a1ca1bb39d79a62e0a78d5a8a57" + )), indexed: vec![], body: vec![ DynSolValue::Uint(U256::from(1), 256), diff --git a/deny.toml b/deny.toml index da6c5b4689908..ee4610d64d097 100644 --- a/deny.toml +++ b/deny.toml @@ -10,7 +10,7 @@ yanked = "warn" # https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html [bans] # Lint level for when multiple versions of the same crate are detected -multiple-versions = "warn" +multiple-versions = "allow" # Lint level for when a crate version requirement is `*` wildcards = "allow" highlight = "all" @@ -40,7 +40,6 @@ allow = [ "ISC", "Unicode-DFS-2016", "OpenSSL", - "Unicode-3.0", "Unlicense", "WTFPL", "BSL-1.0", @@ -55,7 +54,6 @@ exceptions = [ # so we prefer to not have dependencies using it # https://tldrlegal.com/license/creative-commons-cc0-1.0-universal { allow = ["CC0-1.0"], name = "tiny-keccak" }, - { allow = ["CC0-1.0"], name = "to_method" }, { allow = ["CC0-1.0"], name = "trezor-client" }, { allow = ["CC0-1.0"], name = "notify" }, { allow = ["CC0-1.0"], name = "dunce" }, From b1b815123b625939b833a8b5bd68031448411f4b Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:53:15 +0200 Subject: [PATCH 1233/1963] refactor(common): use alloy retry layer (#8368) * use alloy retry layer in RetryProvider * nits * rm built-in retry layer * rm `timeout_retry` * bump alloy --------- Co-authored-by: Matthias Seitz --- Cargo.toml | 44 +++--- crates/anvil/src/config.rs | 4 +- crates/anvil/src/eth/backend/fork.rs | 4 +- crates/common/src/provider/mod.rs | 35 ++--- crates/common/src/provider/retry.rs | 152 --------------------- crates/common/src/provider/tower.rs | 191 --------------------------- crates/evm/core/src/fork/multi.rs | 3 +- 7 files changed, 37 insertions(+), 396 deletions(-) delete mode 100644 crates/common/src/provider/retry.rs delete mode 100644 crates/common/src/provider/tower.rs diff --git a/Cargo.toml b/Cargo.toml index 5c3ae60d585bc..3d525aa84bfc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,28 +172,28 @@ revm-inspectors = { version = "0.3", features = ["serde"] } ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.1.2", default-features = false } -alloy-contract = { version = "0.1.2", default-features = false } -alloy-eips = { version = "0.1.2", default-features = false } -alloy-genesis = { version = "0.1.2", default-features = false } -alloy-json-rpc = { version = "0.1.2", default-features = false } -alloy-network = { version = "0.1.2", default-features = false } -alloy-node-bindings = { version = "0.1.2", default-features = false } -alloy-provider = { version = "0.1.2", default-features = false } -alloy-pubsub = { version = "0.1.2", default-features = false } -alloy-rpc-client = { version = "0.1.2", default-features = false } -alloy-rpc-types = { version = "0.1.2", default-features = false } -alloy-serde = { version = "0.1.2", default-features = false } -alloy-signer = { version = "0.1.2", default-features = false } -alloy-signer-aws = { version = "0.1.2", default-features = false } -alloy-signer-gcp = { version = "0.1.2", default-features = false } -alloy-signer-ledger = { version = "0.1.2", default-features = false } -alloy-signer-local = { version = "0.1.2", default-features = false } -alloy-signer-trezor = { version = "0.1.2", default-features = false } -alloy-transport = { version = "0.1.2", default-features = false } -alloy-transport-http = { version = "0.1.2", default-features = false } -alloy-transport-ipc = { version = "0.1.2", default-features = false } -alloy-transport-ws = { version = "0.1.2", default-features = false } +alloy-consensus = { version = "0.1.4", default-features = false } +alloy-contract = { version = "0.1.4", default-features = false } +alloy-eips = { version = "0.1.4", default-features = false } +alloy-genesis = { version = "0.1.4", default-features = false } +alloy-json-rpc = { version = "0.1.4", default-features = false } +alloy-network = { version = "0.1.4", default-features = false } +alloy-node-bindings = { version = "0.1.4", default-features = false } +alloy-provider = { version = "0.1.4", default-features = false } +alloy-pubsub = { version = "0.1.4", default-features = false } +alloy-rpc-client = { version = "0.1.4", default-features = false } +alloy-rpc-types = { version = "0.1.4", default-features = false } +alloy-serde = { version = "0.1.4", default-features = false } +alloy-signer = { version = "0.1.4", default-features = false } +alloy-signer-aws = { version = "0.1.4", default-features = false } +alloy-signer-gcp = { version = "0.1.4", default-features = false } +alloy-signer-ledger = { version = "0.1.4", default-features = false } +alloy-signer-local = { version = "0.1.4", default-features = false } +alloy-signer-trezor = { version = "0.1.4", default-features = false } +alloy-transport = { version = "0.1.4", default-features = false } +alloy-transport-http = { version = "0.1.4", default-features = false } +alloy-transport-ipc = { version = "0.1.4", default-features = false } +alloy-transport-ws = { version = "0.1.4", default-features = false } alloy-dyn-abi = "0.7.3" alloy-json-abi = "0.7.3" diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 2f4ed5e4608b7..569beaa9a945b 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1020,10 +1020,10 @@ impl NodeConfig { let provider = Arc::new( ProviderBuilder::new(ð_rpc_url) .timeout(self.fork_request_timeout) - .timeout_retry(self.fork_request_retries) + // .timeout_retry(self.fork_request_retries) .initial_backoff(self.fork_retry_backoff.as_millis() as u64) .compute_units_per_second(self.compute_units_per_second) - .max_retry(10) + .max_retry(self.fork_request_retries) .initial_backoff(1000) .headers(self.fork_headers.clone()) .build() diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 539b11a4dc8a0..17121e59c1f9e 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -623,8 +623,8 @@ impl ClientForkConfig { self.provider = Arc::new( ProviderBuilder::new(url.as_str()) .timeout(self.timeout) - .timeout_retry(self.retries) - .max_retry(10) + // .timeout_retry(self.retries) + .max_retry(self.retries) .initial_backoff(self.backoff.as_millis() as u64) .compute_units_per_second(self.compute_units_per_second) .build() diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index 36efe75e87c04..7bb943eac0bc4 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -1,8 +1,6 @@ //! Provider-related instantiation and usage utilities. -pub mod retry; pub mod runtime_transport; -pub mod tower; use crate::{ provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT, @@ -13,7 +11,10 @@ use alloy_provider::{ Identity, ProviderBuilder as AlloyProviderBuilder, RootProvider, }; use alloy_rpc_client::ClientBuilder; -use alloy_transport::utils::guess_local_url; +use alloy_transport::{ + layers::{RetryBackoffLayer, RetryBackoffService}, + utils::guess_local_url, +}; use eyre::{Result, WrapErr}; use foundry_config::NamedChain; use reqwest::Url; @@ -24,7 +25,6 @@ use std::{ str::FromStr, time::Duration, }; -use tower::{RetryBackoffLayer, RetryBackoffService}; use url::ParseError; /// Helper type alias for a retry provider @@ -77,7 +77,6 @@ pub struct ProviderBuilder { url: Result, chain: NamedChain, max_retry: u32, - timeout_retry: u32, initial_backoff: u64, timeout: Duration, /// available CUPS @@ -128,7 +127,6 @@ impl ProviderBuilder { url, chain: NamedChain::Mainnet, max_retry: 8, - timeout_retry: 8, initial_backoff: 800, timeout: REQUEST_TIMEOUT, // alchemy max cpus @@ -175,12 +173,6 @@ impl ProviderBuilder { self } - /// How often to retry a failed request due to connection issues - pub fn timeout_retry(mut self, timeout_retry: u32) -> Self { - self.timeout_retry = timeout_retry; - self - } - /// The starting backoff delay to use after the first failed request pub fn initial_backoff(mut self, initial_backoff: u64) -> Self { self.initial_backoff = initial_backoff; @@ -239,7 +231,6 @@ impl ProviderBuilder { url, chain: _, max_retry, - timeout_retry, initial_backoff, timeout, compute_units_per_second, @@ -249,12 +240,9 @@ impl ProviderBuilder { } = self; let url = url?; - let retry_layer = RetryBackoffLayer::new( - max_retry, - timeout_retry, - initial_backoff, - compute_units_per_second, - ); + let retry_layer = + RetryBackoffLayer::new(max_retry, initial_backoff, compute_units_per_second); + let transport = RuntimeTransportBuilder::new(url) .with_timeout(timeout) .with_headers(headers) @@ -274,7 +262,6 @@ impl ProviderBuilder { url, chain: _, max_retry, - timeout_retry, initial_backoff, timeout, compute_units_per_second, @@ -284,12 +271,8 @@ impl ProviderBuilder { } = self; let url = url?; - let retry_layer = RetryBackoffLayer::new( - max_retry, - timeout_retry, - initial_backoff, - compute_units_per_second, - ); + let retry_layer = + RetryBackoffLayer::new(max_retry, initial_backoff, compute_units_per_second); let transport = RuntimeTransportBuilder::new(url) .with_timeout(timeout) diff --git a/crates/common/src/provider/retry.rs b/crates/common/src/provider/retry.rs deleted file mode 100644 index b7f3079bb0e12..0000000000000 --- a/crates/common/src/provider/retry.rs +++ /dev/null @@ -1,152 +0,0 @@ -//! An utility trait for retrying requests based on the error type. See [TransportError]. -use alloy_json_rpc::ErrorPayload; -use alloy_transport::{TransportError, TransportErrorKind}; -use serde::Deserialize; - -/// [RetryPolicy] defines logic for which [TransportError] instances should -/// the client retry the request and try to recover from. -pub trait RetryPolicy: Send + Sync + std::fmt::Debug { - /// Whether to retry the request based on the given `error` - fn should_retry(&self, error: &TransportError) -> bool; - - /// Providers may include the `backoff` in the error response directly - fn backoff_hint(&self, error: &TransportError) -> Option; -} - -/// Implements [RetryPolicy] that will retry requests that errored with -/// status code 429 i.e. TOO_MANY_REQUESTS -/// -/// Infura often fails with a `"header not found"` rpc error which is apparently linked to load -/// balancing, which are retried as well. -#[derive(Clone, Debug, Default)] -pub struct RateLimitRetryPolicy; - -impl RetryPolicy for RateLimitRetryPolicy { - fn should_retry(&self, error: &TransportError) -> bool { - match error { - // There was a transport-level error. This is either a non-retryable error, - // or a server error that should be retried. - TransportError::Transport(err) => should_retry_transport_level_error(err), - // The transport could not serialize the error itself. The request was malformed from - // the start. - TransportError::SerError(_) => false, - TransportError::DeserError { text, .. } => should_retry_body(text), - TransportError::ErrorResp(err) => should_retry_json_rpc_error(err), - TransportError::NullResp => true, - TransportError::UnsupportedFeature(_) => false, - TransportError::LocalUsageError(_) => false, - } - } - - /// Provides a backoff hint if the error response contains it - fn backoff_hint(&self, error: &TransportError) -> Option { - if let TransportError::ErrorResp(resp) = error { - let data = resp.try_data_as::(); - if let Some(Ok(data)) = data { - // if daily rate limit exceeded, infura returns the requested backoff in the error - // response - let backoff_seconds = &data["rate"]["backoff_seconds"]; - // infura rate limit error - if let Some(seconds) = backoff_seconds.as_u64() { - return Some(std::time::Duration::from_secs(seconds)) - } - if let Some(seconds) = backoff_seconds.as_f64() { - return Some(std::time::Duration::from_secs(seconds as u64 + 1)) - } - } - } - None - } -} - -/// Tries to decode the error body as payload and check if it should be retried -fn should_retry_body(body: &str) -> bool { - if let Ok(resp) = serde_json::from_str::(body) { - return should_retry_json_rpc_error(&resp) - } - - // some providers send invalid JSON RPC in the error case (no `id:u64`), but the - // text should be a `JsonRpcError` - #[derive(Deserialize)] - struct Resp { - error: ErrorPayload, - } - - if let Ok(resp) = serde_json::from_str::(body) { - return should_retry_json_rpc_error(&resp.error) - } - - false -} - -/// Analyzes the [TransportErrorKind] and decides if the request should be retried based on the -/// variant. -fn should_retry_transport_level_error(error: &TransportErrorKind) -> bool { - match error { - // Missing batch response errors can be retried. - TransportErrorKind::MissingBatchResponse(_) => true, - TransportErrorKind::Custom(err) => { - // currently http error responses are not standard in alloy - let msg = err.to_string(); - msg.contains("429 Too Many Requests") - } - - TransportErrorKind::HttpError(err) => { - if err.status == 429 { - return true - } - should_retry_body(&err.body) - } - // If the backend is gone, or there's a completely custom error, we should assume it's not - // retryable. - TransportErrorKind::PubsubUnavailable => false, - TransportErrorKind::BackendGone => false, - _ => false, - } -} - -/// Analyzes the [ErrorPayload] and decides if the request should be retried based on the -/// error code or the message. -fn should_retry_json_rpc_error(error: &ErrorPayload) -> bool { - let ErrorPayload { code, message, .. } = error; - // alchemy throws it this way - if *code == 429 { - return true - } - - // This is an infura error code for `exceeded project rate limit` - if *code == -32005 { - return true - } - - // alternative alchemy error for specific IPs - if *code == -32016 && message.contains("rate limit") { - return true - } - - // quick node error `"credits limited to 6000/sec"` - // - if *code == -32012 && message.contains("credits") { - return true - } - - // quick node rate limit error: `100/second request limit reached - reduce calls per second or - // upgrade your account at quicknode.com` - if *code == -32007 && message.contains("request limit reached") { - return true - } - - match message.as_str() { - // this is commonly thrown by infura and is apparently a load balancer issue, see also - "header not found" => true, - // also thrown by infura if out of budget for the day and ratelimited - "daily request count exceeded, request rate limited" => true, - msg => { - msg.contains("rate limit") || - msg.contains("rate exceeded") || - msg.contains("too many requests") || - msg.contains("credits limited") || - msg.contains("request limit") - } - } -} diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs deleted file mode 100644 index 73088021d508f..0000000000000 --- a/crates/common/src/provider/tower.rs +++ /dev/null @@ -1,191 +0,0 @@ -//! Alloy-related tower middleware for retrying rate-limited requests -//! and applying backoff. -use std::{ - sync::{ - atomic::{AtomicU32, Ordering}, - Arc, - }, - task::{Context, Poll}, -}; - -use alloy_json_rpc::{RequestPacket, ResponsePacket}; -use alloy_transport::{TransportError, TransportErrorKind, TransportFut}; - -use super::{ - retry::{RateLimitRetryPolicy, RetryPolicy}, - runtime_transport::RuntimeTransport, -}; - -/// An Alloy Tower Layer that is responsible for retrying requests based on the -/// error type. See [TransportError]. -#[derive(Debug, Clone)] -pub struct RetryBackoffLayer { - /// The maximum number of retries for rate limit errors - max_rate_limit_retries: u32, - /// The maximum number of retries for timeout errors - max_timeout_retries: u32, - /// The initial backoff in milliseconds - initial_backoff: u64, - /// The number of compute units per second for this provider - compute_units_per_second: u64, -} - -impl RetryBackoffLayer { - /// Creates a new retry layer with the given parameters. - pub fn new( - max_rate_limit_retries: u32, - max_timeout_retries: u32, - initial_backoff: u64, - compute_units_per_second: u64, - ) -> Self { - Self { - max_rate_limit_retries, - max_timeout_retries, - initial_backoff, - compute_units_per_second, - } - } -} - -impl tower::layer::Layer for RetryBackoffLayer { - type Service = RetryBackoffService; - - fn layer(&self, inner: S) -> Self::Service { - RetryBackoffService { - inner, - policy: RateLimitRetryPolicy, - max_rate_limit_retries: self.max_rate_limit_retries, - _max_timeout_retries: self.max_timeout_retries, - initial_backoff: self.initial_backoff, - compute_units_per_second: self.compute_units_per_second, - requests_enqueued: Arc::new(AtomicU32::new(0)), - } - } -} - -/// An Alloy Tower Service that is responsible for retrying requests based on the -/// error type. See [TransportError] and [RateLimitRetryPolicy]. -#[derive(Debug, Clone)] -pub struct RetryBackoffService { - /// The inner service - inner: S, - /// The retry policy - policy: RateLimitRetryPolicy, - /// The maximum number of retries for rate limit errors - max_rate_limit_retries: u32, - /// The maximum number of retries for timeout errors - _max_timeout_retries: u32, - /// The initial backoff in milliseconds - initial_backoff: u64, - /// The number of compute units per second for this service - compute_units_per_second: u64, - /// The number of requests currently enqueued - requests_enqueued: Arc, -} - -// impl tower service -impl tower::Service for RetryBackoffService { - type Response = ResponsePacket; - type Error = TransportError; - type Future = TransportFut<'static>; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - // Our middleware doesn't care about backpressure, so it's ready as long - // as the inner service is ready. - self.inner.poll_ready(cx) - } - - fn call(&mut self, request: RequestPacket) -> Self::Future { - let mut this = self.clone(); - Box::pin(async move { - let ahead_in_queue = this.requests_enqueued.fetch_add(1, Ordering::SeqCst) as u64; - let mut rate_limit_retry_number: u32 = 0; - loop { - let err; - let fut = this.inner.call(request.clone()).await; - - match fut { - Ok(res) => { - if let Some(e) = res.as_error() { - err = TransportError::ErrorResp(e.clone()) - } else { - this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); - return Ok(res) - } - } - Err(e) => err = e, - } - - let should_retry = this.policy.should_retry(&err); - if should_retry { - rate_limit_retry_number += 1; - if rate_limit_retry_number > this.max_rate_limit_retries { - return Err(TransportErrorKind::custom_str("Max retries exceeded")) - } - trace!("retrying request due to {:?}", err); - - let current_queued_reqs = this.requests_enqueued.load(Ordering::SeqCst) as u64; - - // try to extract the requested backoff from the error or compute the next - // backoff based on retry count - let backoff_hint = this.policy.backoff_hint(&err); - let next_backoff = backoff_hint - .unwrap_or_else(|| std::time::Duration::from_millis(this.initial_backoff)); - - // requests are usually weighted and can vary from 10 CU to several 100 CU, - // cheaper requests are more common some example alchemy - // weights: - // - `eth_getStorageAt`: 17 - // - `eth_getBlockByNumber`: 16 - // - `eth_newFilter`: 20 - // - // (coming from forking mode) assuming here that storage request will be the - // driver for Rate limits we choose `17` as the average cost - // of any request - const AVG_COST: u64 = 17u64; - let seconds_to_wait_for_compute_budget = compute_unit_offset_in_secs( - AVG_COST, - this.compute_units_per_second, - current_queued_reqs, - ahead_in_queue, - ); - let total_backoff = next_backoff + - std::time::Duration::from_secs(seconds_to_wait_for_compute_budget); - - trace!(?total_backoff, budget_backoff = ?seconds_to_wait_for_compute_budget, default_backoff = ?next_backoff, ?backoff_hint, "backing off due to rate limit"); - - tokio::time::sleep(total_backoff).await; - } else { - trace!("encountered non retryable error {err:?}"); - this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); - return Err(err) - } - } - }) - } -} - -/// Calculates an offset in seconds by taking into account the number of currently queued requests, -/// number of requests that were ahead in the queue when the request was first issued, the average -/// cost a weighted request (heuristic), and the number of available compute units per seconds. -/// -/// Returns the number of seconds (the unit the remote endpoint measures compute budget) a request -/// is supposed to wait to not get rate limited. The budget per second is -/// `compute_units_per_second`, assuming an average cost of `avg_cost` this allows (in theory) -/// `compute_units_per_second / avg_cost` requests per seconds without getting rate limited. -/// By taking into account the number of concurrent request and the position in queue when the -/// request was first issued and determine the number of seconds a request is supposed to wait, if -/// at all -fn compute_unit_offset_in_secs( - avg_cost: u64, - compute_units_per_second: u64, - current_queued_requests: u64, - ahead_in_queue: u64, -) -> u64 { - let request_capacity_per_second = compute_units_per_second.saturating_div(avg_cost); - if current_queued_requests > request_capacity_per_second { - current_queued_requests.min(ahead_in_queue).saturating_div(request_capacity_per_second) - } else { - 0 - } -} diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 8840a89f800df..372794ed1eb71 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -4,8 +4,9 @@ //! concurrently active pairs at once. use super::CreateFork; +use alloy_transport::layers::RetryBackoffService; use foundry_common::provider::{ - runtime_transport::RuntimeTransport, tower::RetryBackoffService, ProviderBuilder, RetryProvider, + runtime_transport::RuntimeTransport, ProviderBuilder, RetryProvider, }; use foundry_config::Config; use foundry_fork_db::{cache::BlockchainDbMeta, BackendHandler, BlockchainDb, SharedBackend}; From 82ff8ee338818e6a6dc356e4c72ab72d31965375 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:49:52 +0200 Subject: [PATCH 1234/1963] chore(deps): bump watchexec to 4 (#7864) * chore(deps): bump watchexec to 4 * feat: implement the test spawn hook * chore: lockfile * chore: update * doc * chore: ignore gix CVEs in deny.toml * chore: clippy --- Cargo.lock | 439 +++++++++++++------------ crates/forge/Cargo.toml | 7 +- crates/forge/bin/cmd/build.rs | 5 +- crates/forge/bin/cmd/snapshot.rs | 3 +- crates/forge/bin/cmd/test/mod.rs | 5 +- crates/forge/bin/cmd/watch.rs | 544 +++++++++++++------------------ deny.toml | 5 + 7 files changed, 470 insertions(+), 538 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a207fb3b1af7..9138a000ee0dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -834,7 +834,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 1.4.0", + "hyper 1.4.1", "itertools 0.13.0", "k256", "parking_lot", @@ -1084,9 +1084,9 @@ dependencies = [ [[package]] name = "async-priority-channel" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21678992e1b21bebfe2bc53ab5f5f68c106eddab31b24e0bb06e9b715a86640" +checksum = "acde96f444d31031f760c5c43dc786b97d3e1cb2ee49dd06898383fe9a999758" dependencies = [ "event-listener", ] @@ -1210,7 +1210,7 @@ dependencies = [ "fastrand", "hex", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.30", "ring", "time", "tokio", @@ -1433,7 +1433,7 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.0", "httparse", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", @@ -1519,7 +1519,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "itoa", "matchit", "memchr", @@ -1548,7 +1548,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.4.0", + "hyper 1.4.1", "hyper-util", "itoa", "matchit", @@ -1767,15 +1767,6 @@ dependencies = [ "serde", ] -[[package]] -name = "btoi" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd6407f73a9b8b6162d8a2ef999fe6afd7cc15902ebf42c5cd296addf17e0ad" -dependencies = [ - "num-traits", -] - [[package]] name = "build_const" version = "0.2.2" @@ -2147,11 +2138,11 @@ checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "clearscreen" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f3f22f1a586604e62efd23f78218f3ccdecf7a33c4500db2d37d85a24fe994" +checksum = "2f8c93eb5f77c9050c7750e14f13ef1033a40a0aac70c6371535b6763a01438c" dependencies = [ - "nix 0.26.4", + "nix 0.28.0", "terminfo", "thiserror", "which", @@ -2288,18 +2279,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "command-group" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5080df6b0f0ecb76cab30808f00d937ba725cebe266a3da8cd89dff92f2a9916" -dependencies = [ - "async-trait", - "nix 0.26.4", - "tokio", - "winapi", -] - [[package]] name = "compact_str" version = "0.7.1" @@ -2313,6 +2292,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.8" @@ -2547,9 +2535,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -2557,9 +2545,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", @@ -2571,9 +2559,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", @@ -3123,9 +3111,14 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.5.3" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] [[package]] name = "evm-disassembler" @@ -3156,6 +3149,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "faster-hex" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" + [[package]] name = "fastrand" version = "2.1.0" @@ -3317,6 +3316,7 @@ dependencies = [ "clap", "clap_complete", "clap_complete_fig", + "clearscreen", "comfy-table", "criterion", "dialoguer", @@ -3342,12 +3342,12 @@ dependencies = [ "futures", "globset", "humantime-serde", - "hyper 1.4.0", + "hyper 1.4.1", "indicatif", "itertools 0.13.0", "mockall", "once_cell", - "opener 0.6.1", + "opener", "parking_lot", "paste", "path-slash", @@ -3377,6 +3377,8 @@ dependencies = [ "tracing-subscriber", "vergen", "watchexec", + "watchexec-events", + "watchexec-signals", "yansi", ] @@ -3784,7 +3786,7 @@ dependencies = [ "cfg-if", "dunce", "fs_extra", - "memmap2 0.9.4", + "memmap2", "once_cell", "path-slash", "regex", @@ -4238,7 +4240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d460327b24cc34c86d53d60a90e9e6044817f7906ebd9baa5c3d0ee13e1ecf" dependencies = [ "bytes", - "hyper 0.14.29", + "hyper 0.14.30", "serde", "serde_json", "thiserror", @@ -4256,7 +4258,7 @@ dependencies = [ "chrono", "futures", "gcemeta", - "hyper 0.14.29", + "hyper 0.14.30", "jsonwebtoken", "once_cell", "prost", @@ -4320,23 +4322,23 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gix-actor" -version = "0.20.0" +version = "0.31.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848efa0f1210cea8638f95691c82a46f98a74b9e3524f01d4955ebc25a8f84f3" +checksum = "d9b8ee65074b2bbb91d9d97c15d172ea75043aefebf9869b5b329149dc76501c" dependencies = [ "bstr 1.9.1", - "btoi", "gix-date", + "gix-utils", "itoa", - "nom", "thiserror", + "winnow 0.6.13", ] [[package]] name = "gix-config" -version = "0.22.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d252a0eddb6df74600d3d8872dc9fe98835a7da43110411d705b682f49d4ac1" +checksum = "7580e05996e893347ad04e1eaceb92e1c0e6a3ffe517171af99bf6b6df0ca6e5" dependencies = [ "bstr 1.9.1", "gix-config-value", @@ -4345,20 +4347,19 @@ dependencies = [ "gix-path", "gix-ref", "gix-sec", - "log", "memchr", - "nom", "once_cell", "smallvec", "thiserror", "unicode-bom", + "winnow 0.6.13", ] [[package]] name = "gix-config-value" -version = "0.12.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" +checksum = "fbd06203b1a9b33a78c88252a625031b094d9e1b647260070c25b09910c0a804" dependencies = [ "bitflags 2.6.0", "bstr 1.9.1", @@ -4369,9 +4370,9 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.5.1" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc164145670e9130a60a21670d9b6f0f4f8de04e5dd256c51fa5a0340c625902" +checksum = "9eed6931f21491ee0aeb922751bd7ec97b4b2fe8fbfedcb678e2a2dce5f3b8c0" dependencies = [ "bstr 1.9.1", "itoa", @@ -4381,30 +4382,34 @@ dependencies = [ [[package]] name = "gix-features" -version = "0.29.0" +version = "0.38.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf69b0f5c701cc3ae22d3204b671907668f6437ca88862d355eaf9bc47a4f897" +checksum = "ac7045ac9fe5f9c727f38799d002a7ed3583cd777e3322a7c4b43e3cf437dc69" dependencies = [ "gix-hash", + "gix-trace", + "gix-utils", "libc", + "prodash", "sha1_smol", "walkdir", ] [[package]] name = "gix-fs" -version = "0.1.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b37a1832f691fdc09910bd267f9a2e413737c1f9ec68c6e31f9e802616278a9" +checksum = "e2184c40e7910529677831c8b481acf788ffd92427ed21fad65b6aa637e631b8" dependencies = [ "gix-features", + "gix-utils", ] [[package]] name = "gix-glob" -version = "0.7.0" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c07c98204529ac3f24b34754540a852593d2a4c7349008df389240266627a72a" +checksum = "c2a29ad0990cf02c48a7aac76ed0dbddeb5a0d070034b83675cc3bbf937eace4" dependencies = [ "bitflags 2.6.0", "bstr 1.9.1", @@ -4414,19 +4419,19 @@ dependencies = [ [[package]] name = "gix-hash" -version = "0.11.4" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b422ff2ad9a0628baaad6da468cf05385bf3f5ab495ad5a33cce99b9f41092f" +checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" dependencies = [ - "hex", + "faster-hex", "thiserror", ] [[package]] name = "gix-lock" -version = "5.0.1" +version = "13.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c693d7f05730fa74a7c467150adc7cea393518410c65f0672f80226b8111555" +checksum = "e7c359f81f01b8352063319bcb39789b7ea0887b406406381106e38c4a34d049" dependencies = [ "gix-tempfile", "gix-utils", @@ -4435,28 +4440,28 @@ dependencies = [ [[package]] name = "gix-object" -version = "0.29.2" +version = "0.42.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d96bd620fd08accdd37f70b2183cfa0b001b4f1c6ade8b7f6e15cb3d9e261ce" +checksum = "25da2f46b4e7c2fa7b413ce4dffb87f69eaf89c2057e386491f4c55cadbfe386" dependencies = [ "bstr 1.9.1", - "btoi", "gix-actor", + "gix-date", "gix-features", "gix-hash", + "gix-utils", "gix-validate", - "hex", "itoa", - "nom", "smallvec", "thiserror", + "winnow 0.6.13", ] [[package]] name = "gix-path" -version = "0.8.4" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18609c8cbec8508ea97c64938c33cd305b75dfc04a78d0c3b78b8b3fd618a77c" +checksum = "ca987128ffb056d732bd545db5db3d8b103d252fbf083c2567bb0796876619a4" dependencies = [ "bstr 1.9.1", "gix-trace", @@ -4467,11 +4472,12 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.29.1" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e03989e9d49954368e1b526578230fc7189d1634acdfbe79e9ba1de717e15d5" +checksum = "fd4aba68b925101cb45d6df328979af0681364579db889098a0de75b36c77b65" dependencies = [ "gix-actor", + "gix-date", "gix-features", "gix-fs", "gix-hash", @@ -4479,29 +4485,30 @@ dependencies = [ "gix-object", "gix-path", "gix-tempfile", + "gix-utils", "gix-validate", - "memmap2 0.5.10", - "nom", + "memmap2", "thiserror", + "winnow 0.6.13", ] [[package]] name = "gix-sec" -version = "0.8.4" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" +checksum = "fddc27984a643b20dd03e97790555804f98cf07404e0e552c0ad8133266a79a1" dependencies = [ "bitflags 2.6.0", "gix-path", "libc", - "windows 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "gix-tempfile" -version = "5.0.3" +version = "13.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71a0d32f34e71e86586124225caefd78dabc605d0486de580d717653addf182" +checksum = "a761d76594f4443b675e85928e4902dec333273836bd386906f01e7e346a0d11" dependencies = [ "gix-fs", "libc", @@ -4528,9 +4535,9 @@ dependencies = [ [[package]] name = "gix-validate" -version = "0.7.7" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba9b3737b2cef3dcd014633485f0034b0f1a931ee54aeb7d8f87f177f3c89040" +checksum = "82c27dd34a49b1addf193c92070bcbf3beaf6e10f16a78544de6372e146a0acf" dependencies = [ "bstr 1.9.1", "thiserror", @@ -4789,9 +4796,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.29" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -4813,9 +4820,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -4839,7 +4846,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.30", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -4855,7 +4862,7 @@ checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.0", + "hyper 1.4.1", "hyper-util", "rustls 0.23.11", "rustls-native-certs 0.7.1", @@ -4872,7 +4879,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.29", + "hyper 0.14.30", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -4886,7 +4893,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.4.0", + "hyper 1.4.1", "hyper-util", "native-tls", "tokio", @@ -4905,7 +4912,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.4.0", + "hyper 1.4.1", "pin-project-lite", "socket2", "tokio", @@ -4971,15 +4978,16 @@ dependencies = [ [[package]] name = "ignore-files" -version = "1.3.1" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a4d73056a8d335492938cabeef794f38968ef43e6db9bc946638cfd6281003b" +checksum = "99f84e7f847462c582abc4c2aef6ede285ad6e8f66aeec83b47f5481706ddeba" dependencies = [ "dunce", "futures", "gix-config", "ignore", "miette", + "normalize-path", "project-origins", "radix_trie", "thiserror", @@ -5486,7 +5494,7 @@ dependencies = [ "log", "memchr", "once_cell", - "opener 0.7.1", + "opener", "pulldown-cmark", "regex", "serde", @@ -5503,15 +5511,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "memmap2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - [[package]] name = "memmap2" version = "0.9.4" @@ -5532,21 +5531,21 @@ dependencies = [ [[package]] name = "miette" -version = "5.10.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ + "cfg-if", "miette-derive", - "once_cell", "thiserror", "unicode-width", ] [[package]] name = "miette-derive" -version = "5.10.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", @@ -5707,20 +5706,21 @@ dependencies = [ [[package]] name = "notify" -version = "5.2.0" +version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486" +checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "crossbeam-channel", "filetime", "fsevent-sys", "inotify", "kqueue", "libc", + "log", "mio", "walkdir", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -5928,17 +5928,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "opener" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c62dcb6174f9cb326eac248f07e955d5d559c272730b6c03e396b443b562788" -dependencies = [ - "bstr 1.9.1", - "normpath", - "winapi", -] - [[package]] name = "opener" version = "0.7.1" @@ -6057,6 +6046,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + [[package]] name = "parking_lot" version = "0.12.3" @@ -6543,11 +6538,31 @@ dependencies = [ "yansi", ] +[[package]] +name = "process-wrap" +version = "8.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ee68ae331824036479c84060534b18254c864fa73366c58d86db3b7b811619" +dependencies = [ + "futures", + "indexmap 2.2.6", + "nix 0.28.0", + "tokio", + "tracing", + "windows 0.56.0", +] + +[[package]] +name = "prodash" +version = "28.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744a264d26b88a6a7e37cbad97953fa233b94d585236310bcbc88474b4092d79" + [[package]] name = "project-origins" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629e0d57f265ca8238345cb616eea8847b8ecb86b5d97d155be2c8963a314379" +checksum = "735c6b4b1c67863c2211cac24badb0dca9fabfe1098209834fc5e0f92eda6c2c" dependencies = [ "futures", "tokio", @@ -6921,7 +6936,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -6965,7 +6980,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.4.0", + "hyper 1.4.1", "hyper-rustls 0.27.2", "hyper-tls", "hyper-util", @@ -8614,7 +8629,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-timeout", "percent-encoding", "pin-project 1.1.5", @@ -9042,9 +9057,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.3.1" +version = "8.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" +checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" dependencies = [ "anyhow", "cfg-if", @@ -9179,52 +9194,67 @@ dependencies = [ [[package]] name = "watchexec" -version = "2.3.2" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5931215e14de2355a3039477138ae08a905abd7ad0265519fd79717ff1380f88" +checksum = "c635816bdb583dcd1cf58935899df38b5c5ffb1b9d0cc89f8d3c7b33e2c005e3" dependencies = [ "async-priority-channel", "async-recursion", "atomic-take", - "clearscreen", - "command-group", "futures", "ignore-files", "miette", - "nix 0.26.4", + "nix 0.28.0", "normalize-path", "notify", "once_cell", + "process-wrap", "project-origins", "thiserror", "tokio", "tracing", "watchexec-events", "watchexec-signals", + "watchexec-supervisor", ] [[package]] name = "watchexec-events" -version = "1.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01603bbe02fd75918f010dadad456d47eda14fb8fdcab276b0b4b8362f142ae3" +checksum = "1ce015ba32ff91a7f796cea3798e7998d3645411f03fc373ef0e7c7e564291bc" dependencies = [ - "nix 0.26.4", + "nix 0.28.0", "notify", "watchexec-signals", ] [[package]] name = "watchexec-signals" -version = "1.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2a5df96c388901c94ca04055fcd51d4196ca3e971c5e805bd4a4b61dd6a7e5" +checksum = "8f7ccc54db7df8cbbe3251508321e46986ce179af4c4a03b4c70bda539d72755" dependencies = [ "miette", - "nix 0.26.4", + "nix 0.28.0", "thiserror", ] +[[package]] +name = "watchexec-supervisor" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97efb9292bebdf72a777a0d6e400b69b32b4f3daee1ddd30214317a18ff20ab" +dependencies = [ + "futures", + "nix 0.28.0", + "process-wrap", + "tokio", + "tracing", + "watchexec-events", + "watchexec-signals", +] + [[package]] name = "web-sys" version = "0.3.69" @@ -9246,14 +9276,14 @@ dependencies = [ [[package]] name = "which" -version = "4.4.2" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" dependencies = [ "either", "home", - "once_cell", "rustix", + "winsafe", ] [[package]] @@ -9295,20 +9325,21 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.48.0" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" dependencies = [ - "windows-targets 0.48.5", + "windows-core 0.54.0", + "windows-targets 0.52.6", ] [[package]] name = "windows" -version = "0.54.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" dependencies = [ - "windows-core 0.54.0", + "windows-core 0.56.0", "windows-targets 0.52.6", ] @@ -9332,21 +9363,46 @@ dependencies = [ ] [[package]] -name = "windows-result" -version = "0.1.2" +name = "windows-core" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", "windows-targets 0.52.6", ] [[package]] -name = "windows-sys" -version = "0.45.0" +name = "windows-implement" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "windows-interface" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ - "windows-targets 0.42.2", + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -9367,21 +9423,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -9413,12 +9454,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.6", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -9431,12 +9466,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -9449,12 +9478,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -9473,12 +9496,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -9491,12 +9508,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -9509,12 +9520,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -9527,12 +9532,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -9583,6 +9582,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "ws_stream_wasm" version = "0.7.4" diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 93b15ed61d000..790f8da9ef35f 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -92,7 +92,10 @@ thiserror.workspace = true tokio = { workspace = true, features = ["time"] } toml = { version = "0.8", features = ["preserve_order"] } toml_edit = "0.22.4" -watchexec = "2.3.2" +watchexec = "4.1" +watchexec-events = "3.0" +watchexec-signals = "3.0" +clearscreen = "3.0" evm-disassembler.workspace = true rustc-hash.workspace = true @@ -100,7 +103,7 @@ rustc-hash.workspace = true axum = { workspace = true, features = ["ws"] } hyper.workspace = true tower-http = { workspace = true, features = ["fs"] } -opener = "0.6" +opener = "0.7" # soldeer soldeer.workspace = true diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 1538ca7715499..f242d3d191d65 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -19,7 +19,6 @@ use foundry_config::{ }; use serde::Serialize; use std::path::PathBuf; -use watchexec::config::{InitConfig, RuntimeConfig}; foundry_config::merge_impl_figment_convert!(BuildArgs, args); @@ -131,11 +130,11 @@ impl BuildArgs { /// Returns the [`watchexec::InitConfig`] and [`watchexec::RuntimeConfig`] necessary to /// bootstrap a new [`watchexe::Watchexec`] loop. - pub(crate) fn watchexec_config(&self) -> Result<(InitConfig, RuntimeConfig)> { + pub(crate) fn watchexec_config(&self) -> Result { // use the path arguments or if none where provided the `src` dir self.watch.watchexec_config(|| { let config = Config::from(self); - vec![config.src, config.test, config.script] + [config.src, config.test, config.script] }) } } diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index d35c1cdcb0ad7..6c102c9d6fc5c 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -14,7 +14,6 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; /// A regex that matches a basic snapshot entry like @@ -89,7 +88,7 @@ impl SnapshotArgs { /// Returns the [`watchexec::InitConfig`] and [`watchexec::RuntimeConfig`] necessary to /// bootstrap a new [`watchexe::Watchexec`] loop. - pub(crate) fn watchexec_config(&self) -> Result<(InitConfig, RuntimeConfig)> { + pub(crate) fn watchexec_config(&self) -> Result { self.test.watchexec_config() } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 00659b6734a30..80c9eadc70ce7 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -44,7 +44,6 @@ use std::{ sync::{mpsc::channel, Arc}, time::Instant, }; -use watchexec::config::{InitConfig, RuntimeConfig}; use yansi::Paint; mod filter; @@ -596,10 +595,10 @@ impl TestArgs { /// Returns the [`watchexec::InitConfig`] and [`watchexec::RuntimeConfig`] necessary to /// bootstrap a new [`watchexe::Watchexec`] loop. - pub(crate) fn watchexec_config(&self) -> Result<(InitConfig, RuntimeConfig)> { + pub(crate) fn watchexec_config(&self) -> Result { self.watch.watchexec_config(|| { let config = Config::from(self); - vec![config.src, config.test] + [config.src, config.test] }) } } diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 327804f2b5c7c..0dfb734688e65 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -3,17 +3,29 @@ use clap::Parser; use eyre::Result; use foundry_cli::utils::{self, FoundryPathExt}; use foundry_config::Config; -use std::{collections::HashSet, convert::Infallible, path::PathBuf, sync::Arc}; +use parking_lot::Mutex; +use std::{ + collections::HashSet, + path::PathBuf, + sync::{ + atomic::{AtomicU8, Ordering}, + Arc, + }, + time::Duration, +}; +use tokio::process::Command as TokioCommand; use watchexec::{ - action::{Action, Outcome, PreSpawn}, - command::Command, - config::{InitConfig, RuntimeConfig}, - event::{Event, Priority, ProcessEnd}, - handler::SyncFnHandler, + action::ActionHandler, + command::{Command, Program}, + job::{CommandState, Job}, paths::summarise_events_to_env, - signal::source::MainSignal, Watchexec, }; +use watchexec_events::{Event, Priority, ProcessEnd}; +use watchexec_signals::Signal; +use yansi::{Color, Paint}; + +type SpawnHook = Arc; #[derive(Clone, Debug, Default, Parser)] #[command(next_help_heading = "Watch options")] @@ -21,12 +33,7 @@ pub struct WatchArgs { /// Watch the given files or directories for changes. /// /// If no paths are provided, the source and test directories of the project are watched. - #[arg( - long, - short, - num_args(0..), - value_name = "PATH", - )] + #[arg(long, short, num_args(0..), value_name = "PATH")] pub watch: Option>, /// Do not restart the command while it's still running. @@ -57,207 +64,264 @@ pub struct WatchArgs { } impl WatchArgs { - /// Returns new [InitConfig] and [RuntimeConfig] based on the [WatchArgs] + /// Creates a new [`watchexec::Config`]. /// /// If paths were provided as arguments the these will be used as the watcher's pathset, - /// otherwise the path the closure returns will be used - pub fn watchexec_config( + /// otherwise the path the closure returns will be used. + pub fn watchexec_config, P: Into>( &self, - f: impl FnOnce() -> Vec, - ) -> Result<(InitConfig, RuntimeConfig)> { - let init = init()?; - let mut runtime = runtime(self)?; + default_paths: impl FnOnce() -> PS, + ) -> Result { + self.watchexec_config_generic(default_paths, None) + } - // contains all the arguments `--watch p1, p2, p3` - let has_paths = self.watch.as_ref().map(|paths| !paths.is_empty()).unwrap_or_default(); + /// Creates a new [`watchexec::Config`] with a custom command spawn hook. + /// + /// If paths were provided as arguments the these will be used as the watcher's pathset, + /// otherwise the path the closure returns will be used. + pub fn watchexec_config_with_override, P: Into>( + &self, + default_paths: impl FnOnce() -> PS, + spawn_hook: impl Fn(&[Event], &mut TokioCommand) + Send + Sync + 'static, + ) -> Result { + self.watchexec_config_generic(default_paths, Some(Arc::new(spawn_hook))) + } - if !has_paths { - // use alternative pathset, but only those that exists - runtime.pathset(f().into_iter().filter(|p| p.exists())); + fn watchexec_config_generic, P: Into>( + &self, + default_paths: impl FnOnce() -> PS, + spawn_hook: Option, + ) -> Result { + let mut paths = self.watch.as_deref().unwrap_or_default(); + let storage: Vec<_>; + if paths.is_empty() { + storage = default_paths().into_iter().map(Into::into).filter(|p| p.exists()).collect(); + paths = &storage; } - Ok((init, runtime)) + self.watchexec_config_inner(paths, spawn_hook) } -} -/// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge -/// build` -pub async fn watch_build(args: BuildArgs) -> Result<()> { - let (init, mut runtime) = args.watchexec_config()?; - let cmd = cmd_args(args.watch.watch.as_ref().map(|paths| paths.len()).unwrap_or_default()); + fn watchexec_config_inner( + &self, + paths: &[PathBuf], + spawn_hook: Option, + ) -> Result { + let config = watchexec::Config::default(); - trace!("watch build cmd={:?}", cmd); - runtime.command(watch_command(cmd.clone())); + config.on_error(|err| eprintln!("[[{err:?}]]")); - let wx = Watchexec::new(init, runtime.clone())?; - on_action(args.watch, runtime, Arc::clone(&wx), cmd, (), |_| {}); + if let Some(delay) = &self.watch_delay { + config.throttle(utils::parse_delay(delay)?); + } - // start executing the command immediately - wx.send_event(Event::default(), Priority::default()).await?; - wx.main().await??; + config.pathset(paths.iter().map(|p| p.as_path())); + + let n_path_args = self.watch.as_deref().unwrap_or_default().len(); + let base_command = Arc::new(watch_command(cmd_args(n_path_args))); + + let id = watchexec::Id::default(); + let quit_again = Arc::new(AtomicU8::new(0)); + let stop_timeout = Duration::from_secs(5); + let no_restart = self.no_restart; + let stop_signal = Signal::Terminate; + config.on_action(move |mut action| { + let base_command = base_command.clone(); + let job = action.get_or_create_job(id, move || base_command.clone()); + + let events = action.events.clone(); + let spawn_hook = spawn_hook.clone(); + job.set_spawn_hook(move |command, _| { + // https://github.com/watchexec/watchexec/blob/72f069a8477c679e45f845219276b0bfe22fed79/crates/cli/src/emits.rs#L9 + let env = summarise_events_to_env(events.iter()); + for (k, v) in env { + command.command_mut().env(format!("WATCHEXEC_{k}_PATH"), v); + } - Ok(()) -} + if let Some(spawn_hook) = &spawn_hook { + spawn_hook(&events, command.command_mut()); + } + }); + + let clear_screen = || { + let _ = clearscreen::clear(); + }; + + let quit = |mut action: ActionHandler| { + match quit_again.fetch_add(1, Ordering::Relaxed) { + 0 => { + eprintln!( + "[Waiting {stop_timeout:?} for processes to exit before stopping... \ + Ctrl-C again to exit faster]" + ); + action.quit_gracefully(stop_signal, stop_timeout); + } + 1 => action.quit_gracefully(Signal::ForceStop, Duration::ZERO), + _ => action.quit(), + } -/// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge -/// snapshot` -pub async fn watch_snapshot(args: SnapshotArgs) -> Result<()> { - let (init, mut runtime) = args.watchexec_config()?; - let cmd = cmd_args(args.test.watch.watch.as_ref().map(|paths| paths.len()).unwrap_or_default()); + action + }; - trace!("watch snapshot cmd={:?}", cmd); - runtime.command(watch_command(cmd.clone())); - let wx = Watchexec::new(init, runtime.clone())?; + let signals = action.signals().collect::>(); - on_action(args.test.watch.clone(), runtime, Arc::clone(&wx), cmd, (), |_| {}); + if signals.contains(&Signal::Terminate) || signals.contains(&Signal::Interrupt) { + return quit(action); + } - // start executing the command immediately - wx.send_event(Event::default(), Priority::default()).await?; - wx.main().await??; + // Only filesystem events below here (or empty synthetic events). + if action.paths().next().is_none() && !action.events.iter().any(|e| e.is_empty()) { + debug!("no filesystem or synthetic events, skip without doing more"); + return action; + } - Ok(()) -} + job.run({ + let job = job.clone(); + move |context| { + if context.current.is_running() && no_restart { + return; + } + job.restart_with_signal(stop_signal, stop_timeout); + job.run({ + let job = job.clone(); + move |context| { + clear_screen(); + setup_process(job, &context.command) + } + }); + } + }); -/// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge -/// test` -pub async fn watch_test(args: TestArgs) -> Result<()> { - let (init, mut runtime) = args.watchexec_config()?; - let cmd = cmd_args(args.watch.watch.as_ref().map(|paths| paths.len()).unwrap_or_default()); - trace!("watch test cmd={:?}", cmd); - runtime.command(watch_command(cmd.clone())); - let wx = Watchexec::new(init, runtime.clone())?; + action + }); - let config: Config = args.build_args().into(); + Ok(config) + } +} - let filter = args.filter(&config); +fn setup_process(job: Job, _command: &Command) { + tokio::spawn(async move { + job.to_wait().await; + job.run(move |context| end_of_process(context.current)); + }); +} - // marker to check whether to override the command - let no_reconfigure = filter.args().test_pattern.is_some() || - filter.args().path_pattern.is_some() || - filter.args().contract_pattern.is_some() || - args.watch.run_all; +fn end_of_process(state: &CommandState) { + let CommandState::Finished { status, started, finished } = state else { + return; + }; - let state = WatchTestState { - project_root: config.root.0, - no_reconfigure, - last_test_files: Default::default(), + let duration = *finished - *started; + let timings = true; + let timing = if timings { format!(", lasted {duration:?}") } else { String::new() }; + let (msg, fg) = match status { + ProcessEnd::ExitError(code) => (format!("Command exited with {code}{timing}"), Color::Red), + ProcessEnd::ExitSignal(sig) => { + (format!("Command killed by {sig:?}{timing}"), Color::Magenta) + } + ProcessEnd::ExitStop(sig) => (format!("Command stopped by {sig:?}{timing}"), Color::Blue), + ProcessEnd::Continued => (format!("Command continued{timing}"), Color::Cyan), + ProcessEnd::Exception(ex) => { + (format!("Command ended by exception {ex:#x}{timing}"), Color::Yellow) + } + ProcessEnd::Success => (format!("Command was successful{timing}"), Color::Green), }; - on_action(args.watch.clone(), runtime, Arc::clone(&wx), cmd, state, on_test); - // start executing the command immediately - wx.send_event(Event::default(), Priority::default()).await?; - wx.main().await??; + let quiet = false; + if !quiet { + eprintln!("{}", format!("[{msg}]").paint(fg.foreground())); + } +} +/// Runs the given [`watchexec::Config`]. +pub async fn run(config: watchexec::Config) -> Result<()> { + let wx = Watchexec::with_config(config)?; + wx.send_event(Event::default(), Priority::Urgent).await?; + wx.main().await??; Ok(()) } -#[derive(Clone, Debug)] -struct WatchTestState { - /// the root directory of the project - project_root: PathBuf, - /// marks whether we can reconfigure the watcher command with the `--match-path` arg - no_reconfigure: bool, - /// Tracks the last changed test files, if any so that if a non-test file was modified we run - /// this file instead *Note:* this is a vec, so we can also watch out for changes - /// introduced by `forge fmt` - last_test_files: HashSet, +/// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge +/// build` +pub async fn watch_build(args: BuildArgs) -> Result<()> { + let config = args.watchexec_config()?; + run(config).await } -/// The `on_action` hook for `forge test --watch` -fn on_test(action: OnActionState<'_, WatchTestState>) { - let OnActionState { args, runtime, action, wx, cmd, other } = action; - let WatchTestState { project_root, no_reconfigure, last_test_files } = other; +/// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge +/// snapshot` +pub async fn watch_snapshot(args: SnapshotArgs) -> Result<()> { + let config = args.watchexec_config()?; + run(config).await +} - if no_reconfigure { - // nothing to reconfigure - return - } +/// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge +/// test` +pub async fn watch_test(args: TestArgs) -> Result<()> { + let config: Config = args.build_args().into(); + let filter = args.filter(&config); + // Marker to check whether to override the command. + let _no_reconfigure = filter.args().test_pattern.is_some() || + filter.args().path_pattern.is_some() || + filter.args().contract_pattern.is_some() || + args.watch.run_all; - let mut cmd = cmd.clone(); - - let mut changed_sol_test_files: HashSet<_> = action - .events - .iter() - .flat_map(|e| e.paths()) - .filter(|(path, _)| path.is_sol_test()) - .filter_map(|(path, _)| path.to_str()) - .map(str::to_string) - .collect(); - - // replace `--match-path` | `-mp` argument - if let Some(pos) = cmd.iter().position(|arg| arg == "--match-path" || arg == "-mp") { - // --match-path requires 1 argument - cmd.drain(pos..=(pos + 1)); - } + let last_test_files = Mutex::new(HashSet::::new()); + let project_root = config.root.0.to_string_lossy().into_owned(); + let config = args.watch.watchexec_config_with_override( + || [&config.test, &config.src], + move |events, command| { + let mut changed_sol_test_files: HashSet<_> = events + .iter() + .flat_map(|e| e.paths()) + .filter(|(path, _)| path.is_sol_test()) + .filter_map(|(path, _)| path.to_str()) + .map(str::to_string) + .collect(); + + if changed_sol_test_files.len() > 1 { + // Run all tests if multiple files were changed at once, for example when running + // `forge fmt`. + return; + } - if changed_sol_test_files.len() > 1 || - (changed_sol_test_files.is_empty() && last_test_files.is_empty()) - { - // this could happen if multiple files were changed at once, for example `forge fmt` was - // run, or if no test files were changed and no previous test files were modified in which - // case we simply run all - let mut config = runtime.clone(); - config.command(watch_command(cmd.clone())); - // re-register the action - on_action( - args.clone(), - config, - wx, - cmd, - WatchTestState { - project_root, - no_reconfigure, - last_test_files: changed_sol_test_files, - }, - on_test, - ); - return - } + if changed_sol_test_files.is_empty() { + // Reuse the old test files if a non-test file was changed. + let last = last_test_files.lock(); + if last.is_empty() { + return; + } + changed_sol_test_files = last.clone(); + } - if changed_sol_test_files.is_empty() { - // reuse the old test files if a non-test file was changed - changed_sol_test_files = last_test_files; - } + // append `--match-path` glob + let mut file = changed_sol_test_files.iter().next().expect("test file present").clone(); - // append `--match-path` glob - let mut file = changed_sol_test_files.clone().into_iter().next().expect("test file present"); + // remove the project root dir from the detected file + if let Some(f) = file.strip_prefix(&project_root) { + file = f.trim_start_matches('/').to_string(); + } - // remove the project root dir from the detected file - if let Some(root) = project_root.as_os_str().to_str() { - if let Some(f) = file.strip_prefix(root) { - file = f.trim_start_matches('/').to_string(); - } - } + trace!(?file, "reconfigure test command"); + + command.arg("--match-path").arg(&file); + }, + )?; + run(config).await?; - let mut new_cmd = cmd.clone(); - new_cmd.push("--match-path".to_string()); - new_cmd.push(file); - trace!("reconfigure test command {:?}", new_cmd); - - // reconfigure the executor with a new runtime - let mut config = runtime.clone(); - config.command(watch_command(new_cmd)); - - // re-register the action - on_action( - args.clone(), - config, - wx, - cmd, - WatchTestState { project_root, no_reconfigure, last_test_files: changed_sol_test_files }, - on_test, - ); + Ok(()) } -/// Converts a list of arguments to a `watchexec::Command` +/// Converts a list of arguments to a `watchexec::Command`. /// -/// The first index in `args`, is expected to be the path to the executable, See `cmd_args` +/// The first index in `args` is the path to the executable. /// /// # Panics -/// if `args` is empty +/// +/// Panics if `args` is empty. fn watch_command(mut args: Vec) -> Command { debug_assert!(!args.is_empty()); let prog = args.remove(0); - Command::Exec { prog, args } + Command { program: Program::Exec { prog: prog.into(), args }, options: Default::default() } } /// Returns the env args without the `--watch` flag from the args for the Watchexec command @@ -299,148 +363,6 @@ fn clean_cmd_args(num: usize, mut cmd_args: Vec) -> Vec { cmd_args } -/// Returns the Initialisation configuration for [`Watchexec`]. -pub fn init() -> Result { - let mut config = InitConfig::default(); - config.on_error(SyncFnHandler::from(|data| { - trace!("[[{:?}]]", data); - Ok::<_, Infallible>(()) - })); - - Ok(config) -} - -/// Contains all necessary context to reconfigure a [`Watchexec`] on the fly -struct OnActionState<'a, T: Clone> { - args: &'a WatchArgs, - runtime: &'a RuntimeConfig, - action: &'a Action, - cmd: &'a Vec, - wx: Arc, - // additional context to inject - other: T, -} - -/// Registers the `on_action` hook on the `RuntimeConfig` currently in use in the `Watchexec` -/// -/// **Note** this is a bit weird since we're installing the hook on the config that's already used -/// in `Watchexec` but necessary if we want to have access to it in order to -/// [`Watchexec::reconfigure`] -fn on_action( - args: WatchArgs, - mut config: RuntimeConfig, - wx: Arc, - cmd: Vec, - other: T, - f: F, -) where - F: for<'a> Fn(OnActionState<'a, T>) + Send + 'static, - T: Clone + Send + 'static, -{ - let on_busy = if args.no_restart { "do-nothing" } else { "restart" }; - let runtime = config.clone(); - let w = Arc::clone(&wx); - config.on_action(move |action: Action| { - let fut = async { Ok::<(), Infallible>(()) }; - let signals: Vec = action.events.iter().flat_map(|e| e.signals()).collect(); - let has_paths = action.events.iter().flat_map(|e| e.paths()).next().is_some(); - - if signals.contains(&MainSignal::Terminate) || signals.contains(&MainSignal::Interrupt) { - action.outcome(Outcome::both(Outcome::Stop, Outcome::Exit)); - return fut - } - - if !has_paths { - if !signals.is_empty() { - let mut out = Outcome::DoNothing; - for sig in signals { - out = Outcome::both(out, Outcome::Signal(sig)); - } - - action.outcome(out); - return fut - } - - let completion = action.events.iter().flat_map(|e| e.completions()).next(); - if let Some(status) = completion { - match status { - Some(ProcessEnd::ExitError(code)) => { - trace!("Command exited with {code}") - } - Some(ProcessEnd::ExitSignal(sig)) => { - trace!("Command killed by {:?}", sig) - } - Some(ProcessEnd::ExitStop(sig)) => { - trace!("Command stopped by {:?}", sig) - } - Some(ProcessEnd::Continued) => trace!("Command continued"), - Some(ProcessEnd::Exception(ex)) => { - trace!("Command ended by exception {:#x}", ex) - } - Some(ProcessEnd::Success) => trace!("Command was successful"), - None => trace!("Command completed"), - }; - - action.outcome(Outcome::DoNothing); - return fut - } - } - - f(OnActionState { - args: &args, - runtime: &runtime, - action: &action, - wx: w.clone(), - cmd: &cmd, - other: other.clone(), - }); - - // mattsse: could be made into flag to never clear the shell - let clear = false; - let when_running = match (clear, on_busy) { - (_, "do-nothing") => Outcome::DoNothing, - (true, "restart") => { - Outcome::both(Outcome::Stop, Outcome::both(Outcome::Clear, Outcome::Start)) - } - (false, "restart") => Outcome::both(Outcome::Stop, Outcome::Start), - _ => Outcome::DoNothing, - }; - - let when_idle = - if clear { Outcome::both(Outcome::Clear, Outcome::Start) } else { Outcome::Start }; - - action.outcome(Outcome::if_running(when_running, when_idle)); - - fut - }); - - let _ = wx.reconfigure(config); -} - -/// Returns the Runtime configuration for [`Watchexec`]. -pub fn runtime(args: &WatchArgs) -> Result { - let mut config = RuntimeConfig::default(); - - config.pathset(args.watch.clone().unwrap_or_default()); - - if let Some(delay) = &args.watch_delay { - config.action_throttle(utils::parse_delay(delay)?); - } - - config.on_pre_spawn(move |prespawn: PreSpawn| async move { - let envs = summarise_events_to_env(prespawn.events.iter()); - if let Some(mut command) = prespawn.command().await { - for (k, v) in envs { - command.env(format!("CARGO_WATCH_{k}_PATH"), v); - } - } - - Ok::<(), Infallible>(()) - }); - - Ok(config) -} - #[cfg(test)] mod tests { use super::*; diff --git a/deny.toml b/deny.toml index ee4610d64d097..18fcd55652da0 100644 --- a/deny.toml +++ b/deny.toml @@ -4,6 +4,11 @@ [advisories] version = 2 yanked = "warn" +ignore = [ + # https://github.com/watchexec/watchexec/issues/852 + "RUSTSEC-2024-0350", + "RUSTSEC-2024-0351", +] # This section is considered when running `cargo deny check bans`. # More documentation about the 'bans' section can be found here: From 1e0603f9239deec110753ff57032f8b3cba3c4a9 Mon Sep 17 00:00:00 2001 From: James Kim Date: Wed, 10 Jul 2024 06:03:32 -0400 Subject: [PATCH 1235/1963] feat(anvil): add callTracer support for debug_traceCall (#8375) * apply state/block overrides and add callTracer support * remove state/block override logic * pass default config to TracingInspector * fix comments * add integration tests * refactor handler * add comments * fix clippy * update test to check for address --------- Co-authored-by: Matthias Seitz --- crates/anvil/core/src/eth/mod.rs | 4 +- crates/anvil/src/eth/api.rs | 10 +- crates/anvil/src/eth/backend/mem/inspector.rs | 5 + crates/anvil/src/eth/backend/mem/mod.rs | 68 +++++++++- crates/anvil/tests/it/traces.rs | 122 +++++++++++++++++- 5 files changed, 195 insertions(+), 14 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 8a832b79e857c..8e3a8e59648e4 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -5,7 +5,7 @@ use alloy_rpc_types::{ pubsub::{Params as SubscriptionParams, SubscriptionKind}, request::TransactionRequest, state::StateOverride, - trace::geth::{GethDebugTracingOptions, GethDefaultTracingOptions}, + trace::geth::{GethDebugTracingCallOptions, GethDebugTracingOptions}, BlockId, BlockNumberOrTag as BlockNumber, Filter, Index, }; use alloy_serde::WithOtherFields; @@ -297,7 +297,7 @@ pub enum EthRequest { DebugTraceCall( WithOtherFields, #[cfg_attr(feature = "serde", serde(default))] Option, - #[cfg_attr(feature = "serde", serde(default))] GethDefaultTracingOptions, + #[cfg_attr(feature = "serde", serde(default))] GethDebugTracingCallOptions, ), /// Trace transaction endpoint for parity's `trace_transaction` diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index a0cc94249134a..346fb27bd1dd4 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -43,7 +43,7 @@ use alloy_rpc_types::{ request::TransactionRequest, state::StateOverride, trace::{ - geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, + geth::{GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, }, txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, @@ -1523,8 +1523,8 @@ impl EthApi { &self, request: WithOtherFields, block_number: Option, - opts: GethDefaultTracingOptions, - ) -> Result { + opts: GethDebugTracingCallOptions, + ) -> Result { node_info!("debug_traceCall"); let block_request = self.block_request(block_number).await?; let fees = FeeDetails::new( @@ -1535,7 +1535,9 @@ impl EthApi { )? .or_zero_fees(); - self.backend.call_with_tracing(request, fees, Some(block_request), opts).await + let result: std::result::Result = + self.backend.call_with_tracing(request, fees, Some(block_request), opts).await; + result } /// Returns traces for the transaction hash via parity's tracing endpoint diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index ed419dd98645a..43ba00810b944 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -41,6 +41,11 @@ impl Inspector { self } + pub fn with_config(mut self, config: TracingInspectorConfig) -> Self { + self.tracer = Some(TracingInspector::new(config)); + self + } + /// Enables steps recording for `Tracer`. pub fn with_steps_tracing(mut self) -> Self { self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all())); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 728535fc2e7ee..9bb431e2e79f9 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -41,7 +41,10 @@ use alloy_rpc_types::{ serde_helpers::JsonStorageKey, state::StateOverride, trace::{ - geth::{DefaultFrame, GethDebugTracingOptions, GethDefaultTracingOptions, GethTrace}, + geth::{ + GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingCallOptions, + GethDebugTracingOptions, GethTrace, NoopFrame, + }, parity::LocalizedTransactionTrace, }, AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, @@ -73,6 +76,7 @@ use foundry_evm::{ TxEnv, KECCAK_EMPTY, }, }, + traces::TracingInspectorConfig, utils::new_evm_with_inspector_ref, InspectorExt, }; @@ -1223,12 +1227,58 @@ impl Backend { request: WithOtherFields, fee_details: FeeDetails, block_request: Option, - opts: GethDefaultTracingOptions, - ) -> Result { + opts: GethDebugTracingCallOptions, + ) -> Result { + let GethDebugTracingCallOptions { tracing_options, block_overrides: _, state_overrides: _ } = + opts; + let GethDebugTracingOptions { config, tracer, tracer_config, .. } = tracing_options; + self.with_database_at(block_request, |state, block| { - let mut inspector = Inspector::default().with_steps_tracing(); let block_number = block.number; + if let Some(tracer) = tracer { + return match tracer { + GethDebugTracerType::BuiltInTracer(tracer) => match tracer { + GethDebugBuiltInTracerType::CallTracer => { + let call_config = tracer_config + .into_call_config() + .map_err(|e| (RpcError::invalid_params(e.to_string())))?; + + let mut inspector = Inspector::default().with_config( + TracingInspectorConfig::from_geth_call_config(&call_config), + ); + + let env = self.build_call_env(request, fee_details, block); + let mut evm = + self.new_evm_with_inspector_ref(state, env, &mut inspector); + let ResultAndState { result, state: _ } = evm.transact()?; + + drop(evm); + let tracing_inspector = inspector.tracer.expect("tracer disappeared"); + + Ok(tracing_inspector + .into_geth_builder() + .geth_call_traces(call_config, result.gas_used()) + .into()) + } + GethDebugBuiltInTracerType::NoopTracer => Ok(NoopFrame::default().into()), + GethDebugBuiltInTracerType::FourByteTracer | + GethDebugBuiltInTracerType::PreStateTracer | + GethDebugBuiltInTracerType::MuxTracer => { + Err(RpcError::invalid_params("unsupported tracer type").into()) + } + }, + + GethDebugTracerType::JsTracer(_code) => { + Err(RpcError::invalid_params("unsupported tracer type").into()) + } + } + } + + // defaults to StructLog tracer used since no tracer is specified + let mut inspector = + Inspector::default().with_config(TracingInspectorConfig::from_geth_config(&config)); + let env = self.build_call_env(request, fee_details, block); let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); let ResultAndState { result, state: _ } = evm.transact()?; @@ -1244,10 +1294,16 @@ impl Backend { }; drop(evm); - let tracer = inspector.tracer.expect("tracer disappeared"); + let tracing_inspector = inspector.tracer.expect("tracer disappeared"); let return_value = out.as_ref().map(|o| o.data().clone()).unwrap_or_default(); - let res = tracer.into_geth_builder().geth_traces(gas_used, return_value, opts); + trace!(target: "backend", ?exit_reason, ?out, %gas_used, %block_number, "trace call"); + + let res = tracing_inspector + .into_geth_builder() + .geth_traces(gas_used, return_value, config) + .into(); + Ok(res) }) .await? diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index ae75c261a8f1c..8a4d2a83d0dd1 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,4 +1,8 @@ -use crate::{fork::fork_config, utils::http_provider_with_signer}; +use crate::{ + abi::{MulticallContract, SimpleStorage}, + fork::fork_config, + utils::http_provider_with_signer, +}; use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes, U256}; use alloy_provider::{ @@ -7,7 +11,10 @@ use alloy_provider::{ }; use alloy_rpc_types::{ trace::{ - geth::{GethDebugTracingCallOptions, GethTrace}, + geth::{ + CallConfig, GethDebugBuiltInTracerType, GethDebugTracerType, + GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, + }, parity::{Action, LocalizedTransactionTrace}, }, BlockNumberOrTag, TransactionRequest, @@ -138,6 +145,117 @@ async fn test_transfer_debug_trace_call() { } } +#[tokio::test(flavor = "multi_thread")] +async fn test_call_tracer_debug_trace_call() { + let (_api, handle) = spawn(NodeConfig::test()).await; + let wallets = handle.dev_wallets().collect::>(); + let deployer: EthereumWallet = wallets[0].clone().into(); + let provider = http_provider_with_signer(&handle.http_endpoint(), deployer); + + let multicall_contract = MulticallContract::deploy(&provider).await.unwrap(); + + let simple_storage_contract = + SimpleStorage::deploy(&provider, "init value".to_string()).await.unwrap(); + + let set_value = simple_storage_contract.setValue("bar".to_string()); + let set_value_calldata = set_value.calldata(); + + let internal_call_tx_builder = multicall_contract.aggregate(vec![MulticallContract::Call { + target: *simple_storage_contract.address(), + callData: set_value_calldata.to_owned(), + }]); + + let internal_call_tx_calldata = internal_call_tx_builder.calldata().to_owned(); + + // calling SimpleStorage contract through Multicall should result in an internal call + let internal_call_tx = TransactionRequest::default() + .from(wallets[1].address()) + .to(*multicall_contract.address()) + .with_input(internal_call_tx_calldata); + + let internal_call_tx_traces = handle + .http_provider() + .debug_trace_call( + internal_call_tx.clone(), + BlockNumberOrTag::Latest, + GethDebugTracingCallOptions::default().with_tracing_options( + GethDebugTracingOptions::default() + .with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer)) + .with_call_config(CallConfig::default().with_log()), + ), + ) + .await + .unwrap(); + + match internal_call_tx_traces { + GethTrace::CallTracer(call_frame) => { + assert!(call_frame.calls.len() == 1); + assert!( + call_frame.calls.first().unwrap().to.unwrap() == *simple_storage_contract.address() + ); + assert!(call_frame.calls.first().unwrap().logs.len() == 1); + } + _ => { + unreachable!() + } + } + + // only_top_call option - should not return any internal calls + let internal_call_only_top_call_tx_traces = handle + .http_provider() + .debug_trace_call( + internal_call_tx.clone(), + BlockNumberOrTag::Latest, + GethDebugTracingCallOptions::default().with_tracing_options( + GethDebugTracingOptions::default() + .with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer)) + .with_call_config(CallConfig::default().with_log().only_top_call()), + ), + ) + .await + .unwrap(); + + match internal_call_only_top_call_tx_traces { + GethTrace::CallTracer(call_frame) => { + assert!(call_frame.calls.is_empty()); + } + _ => { + unreachable!() + } + } + + // directly calling the SimpleStorage contract should not result in any internal calls + let direct_call_tx = TransactionRequest::default() + .from(wallets[1].address()) + .to(*simple_storage_contract.address()) + .with_input(set_value_calldata.to_owned()); + + let direct_call_tx_traces = handle + .http_provider() + .debug_trace_call( + direct_call_tx, + BlockNumberOrTag::Latest, + GethDebugTracingCallOptions::default().with_tracing_options( + GethDebugTracingOptions::default() + .with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer)) + .with_call_config(CallConfig::default().with_log()), + ), + ) + .await + .unwrap(); + + match direct_call_tx_traces { + GethTrace::CallTracer(call_frame) => { + assert!(call_frame.calls.is_empty()); + assert!(call_frame.to.unwrap() == *simple_storage_contract.address()); + assert!(call_frame.logs.len() == 1); + } + _ => { + unreachable!() + } + } +} + // #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork() { From 0c07675027656949379e70cabf8330a2442c3291 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 10 Jul 2024 19:00:40 +0400 Subject: [PATCH 1236/1963] chore(deps): bump alloy-core (#8401) --- Cargo.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3d525aa84bfc9..ac7bee7e0f3d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -195,13 +195,13 @@ alloy-transport-http = { version = "0.1.4", default-features = false } alloy-transport-ipc = { version = "0.1.4", default-features = false } alloy-transport-ws = { version = "0.1.4", default-features = false } -alloy-dyn-abi = "0.7.3" -alloy-json-abi = "0.7.3" -alloy-primitives = { version = "0.7.3", features = ["getrandom", "rand"] } -alloy-sol-macro-expander = "0.7.3" -alloy-sol-macro-input = "0.7.3" -alloy-sol-types = "0.7.3" -syn-solidity = "0.7.3" +alloy-dyn-abi = "0.7.7" +alloy-json-abi = "0.7.7" +alloy-primitives = { version = "0.7.7", features = ["getrandom", "rand"] } +alloy-sol-macro-expander = "0.7.7" +alloy-sol-macro-input = "0.7.7" +alloy-sol-types = "0.7.7" +syn-solidity = "0.7.7" alloy-chains = "0.1" alloy-rlp = "0.3.3" From 72e44fb87c38b2acfa2b0b136fc1bc833f71e674 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:13:24 +0200 Subject: [PATCH 1237/1963] docs: remove mention of install location of `solc` in favor of detailed explanation in Foundry Book (#8403) remove mention of install location, moving to https://book.getfoundry.sh/faq#im-getting-solc-errors --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ca5e9a6ee2b4..bdb5ad8a04c90 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ If you're experiencing any issues while installing, check out [Getting Help](#ge ### Features - **Fast & flexible compilation pipeline** - - Automatic Solidity compiler version detection & installation (under `~/.svm`) + - Automatic Solidity compiler version detection & installation - **Incremental compilation & caching**: Only changed files are re-compiled - Parallel compilation - Non-standard directory structures support (e.g. [Hardhat repos](https://twitter.com/gakonst/status/1461289225337421829)) From d0ba6a2e650ece15b801752c829426b002891e35 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 11 Jul 2024 10:00:49 +0400 Subject: [PATCH 1238/1963] refactor(tests): add snapbox (#8406) * refactor(tests): add snapbox * update some cast tests * fix * use str * rm fixtures --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 31 +++++ crates/cast/tests/cli/main.rs | 31 +++-- crates/forge/tests/cli/build.rs | 24 +--- crates/forge/tests/cli/create.rs | 123 +++++++++++------- crates/forge/tests/cli/test_cmd.rs | 2 +- .../can_create_template_contract-2nd.stdout | 4 - .../can_create_template_contract.stdout | 6 - .../can_create_using_unlocked-2nd.stdout | 4 - .../fixtures/can_create_using_unlocked.stdout | 6 - .../can_create_with_constructor_args.stdout | 6 - ..._create_with_tuple_constructor_args.stdout | 6 - .../forge/tests/fixtures/compile_json.stdout | 3 +- crates/test-utils/Cargo.toml | 1 + crates/test-utils/src/lib.rs | 2 + crates/test-utils/src/util.rs | 9 +- 15 files changed, 141 insertions(+), 117 deletions(-) delete mode 100644 crates/forge/tests/fixtures/can_create_template_contract-2nd.stdout delete mode 100644 crates/forge/tests/fixtures/can_create_template_contract.stdout delete mode 100644 crates/forge/tests/fixtures/can_create_using_unlocked-2nd.stdout delete mode 100644 crates/forge/tests/fixtures/can_create_using_unlocked.stdout delete mode 100644 crates/forge/tests/fixtures/can_create_with_constructor_args.stdout delete mode 100644 crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout diff --git a/Cargo.lock b/Cargo.lock index 9138a000ee0dd..aaa5f5ef207a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4056,6 +4056,7 @@ dependencies = [ "regex", "serde_json", "similar-asserts", + "snapbox", "tracing", "tracing-subscriber", "walkdir", @@ -5689,6 +5690,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "normalize-path" version = "0.2.1" @@ -7965,6 +7972,30 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "snapbox" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "699c824ef8c2061c39efb3af4f334310b3acbfb2a50c6d1f867e4d95dcff94be" +dependencies = [ + "anstream", + "anstyle", + "normalize-line-endings", + "serde", + "serde_json", + "similar", + "snapbox-macros", +] + +[[package]] +name = "snapbox-macros" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f4c14672714436c09254801c934b203196a51182a5107fb76591c7cc56424d" +dependencies = [ + "anstream", +] + [[package]] name = "socket2" version = "0.5.7" diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 7d7e338811ec1..8349f6d3ec5d4 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -4,6 +4,7 @@ use alloy_primitives::{address, b256, Address, B256}; use foundry_test_utils::{ casttest, rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}, + str, util::OutputExt, }; use std::{fs, io::Write, path::Path, str::FromStr}; @@ -103,9 +104,10 @@ casttest!(wallet_sign_message_hex_data, |_prj, cmd| { "--private-key", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", - ]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0x23a42ca5616ee730ff3735890c32fc7b9491a9f633faca9434797f2c845f5abf4d9ba23bd7edb8577acebaa3644dc5a4995296db420522bb40060f1693c33c9b1c"); + ]).assert_success().stdout_eq(str![[r#" +0x23a42ca5616ee730ff3735890c32fc7b9491a9f633faca9434797f2c845f5abf4d9ba23bd7edb8577acebaa3644dc5a4995296db420522bb40060f1693c33c9b1c + +"#]]); }); // tests that `cast wallet sign typed-data` outputs the expected signature, given a JSON string @@ -117,9 +119,10 @@ casttest!(wallet_sign_typed_data_string, |_prj, cmd| { "0x0000000000000000000000000000000000000000000000000000000000000001", "--data", "{\"types\": {\"EIP712Domain\": [{\"name\": \"name\",\"type\": \"string\"},{\"name\": \"version\",\"type\": \"string\"},{\"name\": \"chainId\",\"type\": \"uint256\"},{\"name\": \"verifyingContract\",\"type\": \"address\"}],\"Message\": [{\"name\": \"data\",\"type\": \"string\"}]},\"primaryType\": \"Message\",\"domain\": {\"name\": \"example.metamask.io\",\"version\": \"1\",\"chainId\": \"1\",\"verifyingContract\": \"0x0000000000000000000000000000000000000000\"},\"message\": {\"data\": \"Hello!\"}}", - ]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0x06c18bdc8163219fddc9afaf5a0550e381326474bb757c86dc32317040cf384e07a2c72ce66c1a0626b6750ca9b6c035bf6f03e7ed67ae2d1134171e9085c0b51b"); + ]).assert_success().stdout_eq(str![[r#" +0x06c18bdc8163219fddc9afaf5a0550e381326474bb757c86dc32317040cf384e07a2c72ce66c1a0626b6750ca9b6c035bf6f03e7ed67ae2d1134171e9085c0b51b + +"#]]); }); // tests that `cast wallet sign typed-data` outputs the expected signature, given a JSON file @@ -137,9 +140,10 @@ casttest!(wallet_sign_typed_data_file, |_prj, cmd| { .into_string() .unwrap() .as_str(), - ]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0x06c18bdc8163219fddc9afaf5a0550e381326474bb757c86dc32317040cf384e07a2c72ce66c1a0626b6750ca9b6c035bf6f03e7ed67ae2d1134171e9085c0b51b"); + ]).assert_success().stdout_eq(str![[r#" +0x06c18bdc8163219fddc9afaf5a0550e381326474bb757c86dc32317040cf384e07a2c72ce66c1a0626b6750ca9b6c035bf6f03e7ed67ae2d1134171e9085c0b51b + +"#]]); }); // tests that `cast wallet list` outputs the local accounts @@ -177,9 +181,12 @@ casttest!(wallet_private_key_from_mnemonic_arg, |_prj, cmd| { "private-key", "test test test test test test test test test test test junk", "1", - ]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"); + ]) + .assert_success() + .stdout_eq(str![[r#" +0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d + +"#]]); }); // tests that `cast wallet private-key` with options outputs the private key diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 93b3137426780..acbb545603614 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -1,8 +1,6 @@ -use foundry_common::fs::read_json_file; use foundry_config::Config; -use foundry_test_utils::forgetest; +use foundry_test_utils::{file, forgetest, str}; use globset::Glob; -use std::{collections::BTreeMap, path::PathBuf}; // tests that json is printed when --json is passed forgetest!(compile_json, |prj, cmd| { @@ -20,26 +18,14 @@ contract Dummy { .unwrap(); // set up command - cmd.args(["compile", "--format-json"]); - - // Exclude build_infos from output as IDs depend on root dir and are not deterministic. - let mut output: BTreeMap = - serde_json::from_str(&cmd.stdout_lossy()).unwrap(); - output.remove("build_infos"); - - let expected: BTreeMap = read_json_file( - &PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/compile_json.stdout"), - ) - .unwrap(); - - similar_asserts::assert_eq!(output, expected); + cmd.args(["compile", "--format-json"]) + .assert() + .stdout_eq(file!["../fixtures/compile_json.stdout": Json]); }); // tests build output is as expected forgetest_init!(exact_build_output, |prj, cmd| { - cmd.args(["build", "--force"]); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiling"), "\n{stdout}"); + cmd.args(["build", "--force"]).assert_success().stdout_eq(str!["Compiling[..]\n..."]); }); // tests build output is as expected diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index a5c9b12b81afb..6aaa4f536c44a 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -9,10 +9,10 @@ use anvil::{spawn, NodeConfig}; use foundry_compilers::artifacts::{remappings::Remapping, BytecodeHash}; use foundry_config::Config; use foundry_test_utils::{ - forgetest, forgetest_async, - util::{OutputExt, TestCommand, TestProject}, + forgetest, forgetest_async, str, + util::{TestCommand, TestProject}, }; -use std::{path::PathBuf, str::FromStr}; +use std::str::FromStr; /// This will insert _dummy_ contract that uses a library /// @@ -150,15 +150,22 @@ forgetest_async!(can_create_template_contract, |prj, cmd| { pk.as_str(), ]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_template_contract.stdout"), - ); + cmd.assert().stdout_eq(str![[r#" +... +Compiler run successful! +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +Transaction hash: [..] - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_template_contract-2nd.stdout"), - ); +"#]]); + + cmd.assert().stdout_eq(str![[r#" +No files changed, compilation skipped +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 +Transaction hash: [..] + +"#]]); }); // tests that we can deploy the template contract @@ -183,15 +190,21 @@ forgetest_async!(can_create_using_unlocked, |prj, cmd| { "--unlocked", ]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_using_unlocked.stdout"), - ); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_using_unlocked-2nd.stdout"), - ); + cmd.assert().stdout_eq(str![[r#" +... +Compiler run successful! +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +Transaction hash: [..] + +"#]]); + cmd.assert().stdout_eq(str![[r#" +No files changed, compilation skipped +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 +Transaction hash: [..] + +"#]]); }); // tests that we can deploy with constructor args @@ -221,21 +234,26 @@ contract ConstructorContract { ) .unwrap(); - cmd.forge_fuse().args([ - "create", - "./src/ConstructorContract.sol:ConstructorContract", - "--rpc-url", - rpc.as_str(), - "--private-key", - pk.as_str(), - "--constructor-args", - "My Constructor", - ]); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_with_constructor_args.stdout"), - ); + cmd.forge_fuse() + .args([ + "create", + "./src/ConstructorContract.sol:ConstructorContract", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + "--constructor-args", + "My Constructor", + ]) + .assert_success() + .stdout_eq(str![[r#" +... +Compiler run successful! +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +Transaction hash: [..] + +"#]]); prj.add_source( "TupleArrayConstructorContract", @@ -252,21 +270,26 @@ contract TupleArrayConstructorContract { ) .unwrap(); - cmd.forge_fuse().args([ - "create", - "./src/TupleArrayConstructorContract.sol:TupleArrayConstructorContract", - "--rpc-url", - rpc.as_str(), - "--private-key", - pk.as_str(), - "--constructor-args", - "[(1,2), (2,3), (3,4)]", - ]); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_create_with_tuple_constructor_args.stdout"), - ); + cmd.forge_fuse() + .args([ + "create", + "./src/TupleArrayConstructorContract.sol:TupleArrayConstructorContract", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + "--constructor-args", + "[(1,2), (2,3), (3,4)]", + ]) + .assert() + .stdout_eq(str![[r#" +... +Compiler run successful! +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 +Transaction hash: [..] + +"#]]); }); // diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index dbbd348d302b5..01db02fddc304 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -548,7 +548,7 @@ contract Dummy { .unwrap(); cmd.args(["test", "--match-path", "src/dummy.sol"]); - cmd.assert_success() + cmd.assert_success(); }); forgetest_init!(should_not_shrink_fuzz_failure, |prj, cmd| { diff --git a/crates/forge/tests/fixtures/can_create_template_contract-2nd.stdout b/crates/forge/tests/fixtures/can_create_template_contract-2nd.stdout deleted file mode 100644 index c04ae5bd577d2..0000000000000 --- a/crates/forge/tests/fixtures/can_create_template_contract-2nd.stdout +++ /dev/null @@ -1,4 +0,0 @@ -No files changed, compilation skipped -Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 -Transaction hash: 0x3d78b08c411f05d5e79adc92a4c814e0f818d1a09c111b0ab688270f35a07ae7 diff --git a/crates/forge/tests/fixtures/can_create_template_contract.stdout b/crates/forge/tests/fixtures/can_create_template_contract.stdout deleted file mode 100644 index 533c927275012..0000000000000 --- a/crates/forge/tests/fixtures/can_create_template_contract.stdout +++ /dev/null @@ -1,6 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 2.27s -Compiler run successful! -Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -Transaction hash: 0x4c3d9f7c4cc26876b43a11ba7ff218374471786a8ae8bf5574deb1d97fc1e851 diff --git a/crates/forge/tests/fixtures/can_create_using_unlocked-2nd.stdout b/crates/forge/tests/fixtures/can_create_using_unlocked-2nd.stdout deleted file mode 100644 index c04ae5bd577d2..0000000000000 --- a/crates/forge/tests/fixtures/can_create_using_unlocked-2nd.stdout +++ /dev/null @@ -1,4 +0,0 @@ -No files changed, compilation skipped -Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 -Transaction hash: 0x3d78b08c411f05d5e79adc92a4c814e0f818d1a09c111b0ab688270f35a07ae7 diff --git a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout b/crates/forge/tests/fixtures/can_create_using_unlocked.stdout deleted file mode 100644 index 1f8b60d6f40e1..0000000000000 --- a/crates/forge/tests/fixtures/can_create_using_unlocked.stdout +++ /dev/null @@ -1,6 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 1.95s -Compiler run successful! -Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -Transaction hash: 0x4c3d9f7c4cc26876b43a11ba7ff218374471786a8ae8bf5574deb1d97fc1e851 diff --git a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout deleted file mode 100644 index 299ad2f2d85f9..0000000000000 --- a/crates/forge/tests/fixtures/can_create_with_constructor_args.stdout +++ /dev/null @@ -1,6 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 2.82s -Compiler run successful! -Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -Transaction hash: 0x294df85109c991ec2760cd51e5ddc869bf5dc3b249b296305ffcd1a0563b2eea diff --git a/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout b/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout deleted file mode 100644 index a0a574c959dbd..0000000000000 --- a/crates/forge/tests/fixtures/can_create_with_tuple_constructor_args.stdout +++ /dev/null @@ -1,6 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 26.44ms -Compiler run successful! -Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 -Transaction hash: 0x69625b76d83634603a9dbc5b836ef89bafdd9fc7c180fc6d636c5088353cf501 diff --git a/crates/forge/tests/fixtures/compile_json.stdout b/crates/forge/tests/fixtures/compile_json.stdout index eff78e60c8d7a..2a794cc4a8a95 100644 --- a/crates/forge/tests/fixtures/compile_json.stdout +++ b/crates/forge/tests/fixtures/compile_json.stdout @@ -15,5 +15,6 @@ "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n --> src/jsonError.sol:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" } ], - "sources": {} + "sources": {}, + "build_infos": ["{...}"] } \ No newline at end of file diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 9b762039acb0d..e3cb1f5429d42 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -33,6 +33,7 @@ tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } walkdir.workspace = true rand.workspace = true +snapbox = { version = "0.6.9", features = ["json"] } [features] # feature for integration tests that test external projects diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 28bb4def123e3..3782aba7d502e 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -28,6 +28,8 @@ pub use script::{ScriptOutcome, ScriptTester}; // re-exports for convenience pub use foundry_compilers; +pub use snapbox::{file, str}; + /// Initializes tracing for tests. pub fn init_tracing() { let _ = tracing_subscriber::FmtSubscriber::builder() diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index b897aacb63409..56d492ebdff8f 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -12,6 +12,7 @@ use foundry_config::Config; use once_cell::sync::Lazy; use parking_lot::Mutex; use regex::Regex; +use snapbox::cmd::OutputAssert; use std::{ env, ffi::OsStr, @@ -921,8 +922,8 @@ impl TestCommand { /// Runs the command and asserts that it resulted in success #[track_caller] - pub fn assert_success(&mut self) { - self.output(); + pub fn assert_success(&mut self) -> OutputAssert { + self.assert().success() } /// Executes command, applies stdin function and returns output @@ -1055,6 +1056,10 @@ stderr: lossy_string(&out.stderr), ) } + + pub fn assert(&mut self) -> OutputAssert { + OutputAssert::new(self.execute()) + } } /// Extension trait for [`Output`]. From cfba82c1c3f863328bac8b66f855ca8907237576 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 11 Jul 2024 15:54:07 +0400 Subject: [PATCH 1239/1963] feat: more flexible JSON parsing (#8345) * support struct parsing * wip * support eip712 strings * feat: "vm.parseJsonType" * chore: docs * clippy * serialize * forge bind-json * make lib internal * fixes * fix docs * rm redundant filter * clippy * generate more helpers * add test * typo * refactor a bit * fmt * config section * add out arg * rm cfg(ignore) * increase depth for failing test * move proptest to workspace * use write * review fixes * fix tests * use GlobMatcher in config * fix tests * fmt --- Cargo.lock | 1 + Cargo.toml | 2 + crates/cheatcodes/Cargo.toml | 3 + crates/cheatcodes/assets/cheatcodes.json | 100 ++++ crates/cheatcodes/spec/src/vm.rs | 24 + crates/cheatcodes/src/error.rs | 1 + crates/cheatcodes/src/json.rs | 365 +++++++++--- crates/cheatcodes/src/string.rs | 2 +- crates/cheatcodes/src/toml.rs | 14 +- crates/config/src/bind_json.rs | 27 + crates/config/src/filter.rs | 22 + crates/config/src/lib.rs | 35 +- crates/evm/evm/Cargo.toml | 2 +- crates/evm/fuzz/Cargo.toml | 2 +- crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/bind_json.rs | 539 ++++++++++++++++++ crates/forge/bin/cmd/eip712.rs | 241 ++++++++ crates/forge/bin/cmd/mod.rs | 2 + crates/forge/bin/main.rs | 2 + crates/forge/bin/opts.rs | 14 +- crates/forge/tests/cli/bind_json.rs | 54 ++ crates/forge/tests/cli/build.rs | 6 +- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/main.rs | 1 + crates/forge/tests/it/invariant.rs | 2 +- testdata/cheats/Vm.sol | 5 + testdata/default/cheats/Json.t.sol | 126 +++- testdata/default/cheats/Toml.t.sol | 2 +- .../fixtures/Json/nested_json_struct.json | 35 ++ 29 files changed, 1513 insertions(+), 119 deletions(-) create mode 100644 crates/config/src/bind_json.rs create mode 100644 crates/forge/bin/cmd/bind_json.rs create mode 100644 crates/forge/bin/cmd/eip712.rs create mode 100644 crates/forge/tests/cli/bind_json.rs create mode 100644 testdata/fixtures/Json/nested_json_struct.json diff --git a/Cargo.lock b/Cargo.lock index aaa5f5ef207a5..56af557d64da8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3569,6 +3569,7 @@ dependencies = [ "k256", "p256", "parking_lot", + "proptest", "rand", "revm", "rustc-hash 2.0.0", diff --git a/Cargo.toml b/Cargo.toml index ac7bee7e0f3d4..a64a6688cbfab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -261,3 +261,5 @@ tower = "0.4" tower-http = "0.5" # soldeer soldeer = "0.2.17" + +proptest = "1" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 09cd319b8d7d0..f04254b1812b6 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -53,3 +53,6 @@ semver.workspace = true rustc-hash.workspace = true dialoguer = "0.11.0" rand = "0.8" + +[dev-dependencies] +proptest.workspace = true \ No newline at end of file diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index f4fe4f91d6435..9c7e36965be0a 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5791,6 +5791,66 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "parseJsonTypeArray", + "description": "Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`.", + "declaration": "function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonTypeArray(string,string,string)", + "selector": "0x0175d535", + "selectorBytes": [ + 1, + 117, + 213, + 53 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonType_0", + "description": "Parses a string of JSON data and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonType(string,string)", + "selector": "0xa9da313b", + "selectorBytes": [ + 169, + 218, + 49, + 59 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseJsonType_1", + "description": "Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseJsonType(string,string,string)", + "selector": "0xe3f5ae33", + "selectorBytes": [ + 227, + 245, + 174, + 51 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "parseJsonUint", @@ -7351,6 +7411,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "serializeJsonType_0", + "description": "See `serializeJson`.", + "declaration": "function serializeJsonType(string calldata typeDescription, bytes memory value) external pure returns (string memory json);", + "visibility": "external", + "mutability": "pure", + "signature": "serializeJsonType(string,bytes)", + "selector": "0x6d4f96a6", + "selectorBytes": [ + 109, + 79, + 150, + 166 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "serializeJsonType_1", + "description": "See `serializeJson`.", + "declaration": "function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes memory value) external returns (string memory json);", + "visibility": "external", + "mutability": "", + "signature": "serializeJsonType(string,string,string,bytes)", + "selector": "0x6f93bccb", + "selectorBytes": [ + 111, + 147, + 188, + 203 + ] + }, + "group": "json", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "serializeString_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 5bb36619d3de7..54f1fe8fe77f7 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1878,6 +1878,19 @@ interface Vm { pure returns (bytes32[] memory); + /// Parses a string of JSON data and coerces it to type corresponding to `typeDescription`. + #[cheatcode(group = Json)] + function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory); + /// Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`. + #[cheatcode(group = Json)] + function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory); + /// Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`. + #[cheatcode(group = Json)] + function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription) + external + pure + returns (bytes memory); + /// Returns an array of all the keys in a JSON object. #[cheatcode(group = Json)] function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys); @@ -1968,6 +1981,17 @@ interface Vm { function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values) external returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeJsonType(string calldata typeDescription, bytes memory value) + external + pure + returns (string memory json); + /// See `serializeJson`. + #[cheatcode(group = Json)] + function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes memory value) + external + returns (string memory json); // NOTE: Please read https://book.getfoundry.sh/cheatcodes/write-json to understand how // to use the JSON writing cheats. diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 5509efa2d1626..26aba73480884 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -286,6 +286,7 @@ macro_rules! impl_from { impl_from!( alloy_sol_types::Error, + alloy_dyn_abi::Error, alloy_primitives::SignatureError, FsPathError, hex::FromHexError, diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index eea16997172aa..48c14e2a3ddc1 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -1,13 +1,13 @@ //! Implementations of [`Json`](spec::Group::Json) cheatcodes. use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*}; -use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_dyn_abi::{eip712_parser::EncodeType, DynSolType, DynSolValue, Resolver}; use alloy_primitives::{hex, Address, B256, I256}; use alloy_sol_types::SolValue; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; -use serde_json::Value; -use std::{borrow::Cow, collections::BTreeMap, fmt::Write}; +use serde_json::{Map, Value}; +use std::{borrow::Cow, collections::BTreeMap}; impl Cheatcode for keyExistsCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { @@ -47,7 +47,7 @@ impl Cheatcode for parseJsonUintCall { impl Cheatcode for parseJsonUintArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce(json, key, &DynSolType::Uint(256)) + parse_json_coerce(json, key, &DynSolType::Array(Box::new(DynSolType::Uint(256)))) } } @@ -61,7 +61,7 @@ impl Cheatcode for parseJsonIntCall { impl Cheatcode for parseJsonIntArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce(json, key, &DynSolType::Int(256)) + parse_json_coerce(json, key, &DynSolType::Array(Box::new(DynSolType::Int(256)))) } } @@ -75,7 +75,7 @@ impl Cheatcode for parseJsonBoolCall { impl Cheatcode for parseJsonBoolArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce(json, key, &DynSolType::Bool) + parse_json_coerce(json, key, &DynSolType::Array(Box::new(DynSolType::Bool))) } } @@ -89,7 +89,7 @@ impl Cheatcode for parseJsonAddressCall { impl Cheatcode for parseJsonAddressArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce(json, key, &DynSolType::Address) + parse_json_coerce(json, key, &DynSolType::Array(Box::new(DynSolType::Address))) } } @@ -103,7 +103,7 @@ impl Cheatcode for parseJsonStringCall { impl Cheatcode for parseJsonStringArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce(json, key, &DynSolType::String) + parse_json_coerce(json, key, &DynSolType::Array(Box::new(DynSolType::String))) } } @@ -117,7 +117,7 @@ impl Cheatcode for parseJsonBytesCall { impl Cheatcode for parseJsonBytesArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce(json, key, &DynSolType::Bytes) + parse_json_coerce(json, key, &DynSolType::Array(Box::new(DynSolType::Bytes))) } } @@ -131,7 +131,29 @@ impl Cheatcode for parseJsonBytes32Call { impl Cheatcode for parseJsonBytes32ArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { json, key } = self; - parse_json_coerce(json, key, &DynSolType::FixedBytes(32)) + parse_json_coerce(json, key, &DynSolType::Array(Box::new(DynSolType::FixedBytes(32)))) + } +} + +impl Cheatcode for parseJsonType_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, typeDescription } = self; + parse_json_coerce(json, "$", &resolve_type(typeDescription)?).map(|v| v.abi_encode()) + } +} + +impl Cheatcode for parseJsonType_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key, typeDescription } = self; + parse_json_coerce(json, key, &resolve_type(typeDescription)?).map(|v| v.abi_encode()) + } +} + +impl Cheatcode for parseJsonTypeArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { json, key, typeDescription } = self; + let ty = resolve_type(typeDescription)?; + parse_json_coerce(json, key, &DynSolType::Array(Box::new(ty))).map(|v| v.abi_encode()) } } @@ -145,106 +167,162 @@ impl Cheatcode for parseJsonKeysCall { impl Cheatcode for serializeJsonCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, value } = self; - serialize_json(state, objectKey, None, value) + *state.serialized_jsons.entry(objectKey.into()).or_default() = serde_json::from_str(value)?; + Ok(value.abi_encode()) } } impl Cheatcode for serializeBool_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + serialize_json(state, objectKey, valueKey, (*value).into()) } } impl Cheatcode for serializeUint_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + serialize_json(state, objectKey, valueKey, (*value).into()) } } impl Cheatcode for serializeInt_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + serialize_json(state, objectKey, valueKey, (*value).into()) } } impl Cheatcode for serializeAddress_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + serialize_json(state, objectKey, valueKey, (*value).into()) } } impl Cheatcode for serializeBytes32_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), &value.to_string()) + serialize_json(state, objectKey, valueKey, DynSolValue::FixedBytes(*value, 32)) } } impl Cheatcode for serializeString_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), value) + serialize_json(state, objectKey, valueKey, value.clone().into()) } } impl Cheatcode for serializeBytes_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; - serialize_json(state, objectKey, Some(valueKey), &hex::encode_prefixed(value)) + serialize_json(state, objectKey, valueKey, value.to_vec().into()) } } impl Cheatcode for serializeBool_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values, false)) + serialize_json( + state, + objectKey, + valueKey, + DynSolValue::Array(values.iter().copied().map(DynSolValue::Bool).collect()), + ) } } impl Cheatcode for serializeUint_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values, false)) + serialize_json( + state, + objectKey, + valueKey, + DynSolValue::Array(values.iter().map(|v| DynSolValue::Uint(*v, 256)).collect()), + ) } } impl Cheatcode for serializeInt_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values, false)) + serialize_json( + state, + objectKey, + valueKey, + DynSolValue::Array(values.iter().map(|v| DynSolValue::Int(*v, 256)).collect()), + ) } } impl Cheatcode for serializeAddress_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) + serialize_json( + state, + objectKey, + valueKey, + DynSolValue::Array(values.iter().copied().map(DynSolValue::Address).collect()), + ) } } impl Cheatcode for serializeBytes32_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) + serialize_json( + state, + objectKey, + valueKey, + DynSolValue::Array(values.iter().map(|v| DynSolValue::FixedBytes(*v, 32)).collect()), + ) } } impl Cheatcode for serializeString_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) + serialize_json( + state, + objectKey, + valueKey, + DynSolValue::Array(values.iter().cloned().map(DynSolValue::String).collect()), + ) } } impl Cheatcode for serializeBytes_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, values } = self; - let values = values.iter().map(hex::encode_prefixed); - serialize_json(state, objectKey, Some(valueKey), &array_str(values, true)) + serialize_json( + state, + objectKey, + valueKey, + DynSolValue::Array( + values.iter().cloned().map(Into::into).map(DynSolValue::Bytes).collect(), + ), + ) + } +} + +impl Cheatcode for serializeJsonType_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { typeDescription, value } = self; + let ty = resolve_type(typeDescription)?; + let value = ty.abi_decode(value)?; + let value = serialize_value_as_json(value)?; + Ok(value.to_string().abi_encode()) + } +} + +impl Cheatcode for serializeJsonType_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { objectKey, valueKey, typeDescription, value } = self; + let ty = resolve_type(typeDescription)?; + let value = ty.abi_decode(value)?; + serialize_json(state, objectKey, valueKey, value) } } @@ -252,7 +330,7 @@ impl Cheatcode for serializeUintToHexCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { objectKey, valueKey, value } = self; let hex = format!("0x{value:x}"); - serialize_json(state, objectKey, Some(valueKey), &hex) + serialize_json(state, objectKey, valueKey, hex.into()) } } @@ -298,29 +376,75 @@ pub(super) fn parse_json(json: &str, path: &str) -> Result { } pub(super) fn parse_json_coerce(json: &str, path: &str, ty: &DynSolType) -> Result { - let value = parse_json_str(json)?; - let values = select(&value, path)?; - ensure!(!values.is_empty(), "no matching value found at {path:?}"); + let json = parse_json_str(json)?; + let [value] = select(&json, path)?[..] else { + bail!("path {path:?} must return exactly one JSON value"); + }; - ensure!( - values.iter().all(|value| !value.is_object()), - "values at {path:?} must not be JSON objects" - ); + parse_json_as(value, ty).map(|v| v.abi_encode()) +} +/// Parses given [serde_json::Value] as a [DynSolValue]. +pub(super) fn parse_json_as(value: &Value, ty: &DynSolType) -> Result { let to_string = |v: &Value| { let mut s = v.to_string(); s.retain(|c: char| c != '"'); s }; - if let Some(array) = values[0].as_array() { - debug!(target: "cheatcodes", %ty, "parsing array"); - string::parse_array(array.iter().map(to_string), ty) - } else { - debug!(target: "cheatcodes", %ty, "parsing string"); - string::parse(&to_string(values[0]), ty) + + match (value, ty) { + (Value::Array(array), ty) => parse_json_array(array, ty), + (Value::Object(object), ty) => parse_json_map(object, ty), + (Value::String(s), DynSolType::String) => Ok(DynSolValue::String(s.clone())), + _ => string::parse_value(&to_string(value), ty), + } +} + +pub(super) fn parse_json_array(array: &[Value], ty: &DynSolType) -> Result { + match ty { + DynSolType::Tuple(types) => { + ensure!(array.len() == types.len(), "array length mismatch"); + let values = array + .iter() + .zip(types) + .map(|(e, ty)| parse_json_as(e, ty)) + .collect::>>()?; + + Ok(DynSolValue::Tuple(values)) + } + DynSolType::Array(inner) => { + let values = + array.iter().map(|e| parse_json_as(e, inner)).collect::>>()?; + Ok(DynSolValue::Array(values)) + } + DynSolType::FixedArray(inner, len) => { + ensure!(array.len() == *len, "array length mismatch"); + let values = + array.iter().map(|e| parse_json_as(e, inner)).collect::>>()?; + Ok(DynSolValue::FixedArray(values)) + } + _ => bail!("expected {ty}, found array"), } } +pub(super) fn parse_json_map(map: &Map, ty: &DynSolType) -> Result { + let Some((name, fields, types)) = ty.as_custom_struct() else { + bail!("expected {ty}, found JSON object"); + }; + + let mut values = Vec::with_capacity(fields.len()); + for (field, ty) in fields.iter().zip(types.iter()) { + let Some(value) = map.get(field) else { bail!("field {field:?} not found in JSON object") }; + values.push(parse_json_as(value, ty)?); + } + + Ok(DynSolValue::CustomStruct { + name: name.to_string(), + prop_names: fields.to_vec(), + tuple: values, + }) +} + pub(super) fn parse_json_keys(json: &str, key: &str) -> Result { let json = parse_json_str(json)?; let values = select(&json, key)?; @@ -376,7 +500,8 @@ pub(super) fn canonicalize_json_path(path: &str) -> Cow<'_, str> { } } -/// Converts a JSON [`Value`] to a [`DynSolValue`]. +/// Converts a JSON [`Value`] to a [`DynSolValue`] by trying to guess encoded type. For safer +/// decoding, use [`parse_json_as`]. /// /// The function is designed to run recursively, so that in case of an object /// it will call itself to convert each of it's value and encode the whole as a @@ -461,7 +586,50 @@ pub(super) fn json_value_to_token(value: &Value) -> Result { } } -/// Serializes a key:value pair to a specific object. If the key is Some(valueKey), the value is +/// Serializes given [DynSolValue] into a [serde_json::Value]. +fn serialize_value_as_json(value: DynSolValue) -> Result { + match value { + DynSolValue::Bool(b) => Ok(Value::Bool(b)), + DynSolValue::String(s) => { + // Strings are allowed to contain strigified JSON objects, so we try to parse it like + // one first. + if let Ok(map) = serde_json::from_str(&s) { + Ok(Value::Object(map)) + } else { + Ok(Value::String(s)) + } + } + DynSolValue::Bytes(b) => Ok(Value::String(hex::encode_prefixed(b))), + DynSolValue::FixedBytes(b, size) => Ok(Value::String(hex::encode_prefixed(&b[..size]))), + DynSolValue::Int(i, _) => { + // let serde handle number parsing + let n = serde_json::from_str(&i.to_string())?; + Ok(Value::Number(n)) + } + DynSolValue::Uint(i, _) => { + // let serde handle number parsing + let n = serde_json::from_str(&i.to_string())?; + Ok(Value::Number(n)) + } + DynSolValue::Address(a) => Ok(Value::String(a.to_string())), + DynSolValue::Array(e) | DynSolValue::FixedArray(e) => { + Ok(Value::Array(e.into_iter().map(serialize_value_as_json).collect::>()?)) + } + DynSolValue::CustomStruct { name: _, prop_names, tuple } => { + let values = + tuple.into_iter().map(serialize_value_as_json).collect::>>()?; + let map = prop_names.into_iter().zip(values).collect(); + + Ok(Value::Object(map)) + } + DynSolValue::Tuple(values) => Ok(Value::Array( + values.into_iter().map(serialize_value_as_json).collect::>()?, + )), + DynSolValue::Function(_) => bail!("cannot serialize function pointer"), + } +} + +/// Serializes a key:value pair to a specific object. If the key is valueKey, the value is /// expected to be an object, which will be set as the root object for the provided object key, /// overriding the whole root object if the object key already exists. By calling this function /// multiple times, the user can serialize multiple KV pairs to the same object. The value can be of @@ -472,44 +640,99 @@ pub(super) fn json_value_to_token(value: &Value) -> Result { fn serialize_json( state: &mut Cheatcodes, object_key: &str, - value_key: Option<&str>, - value: &str, + value_key: &str, + value: DynSolValue, ) -> Result { + let value = serialize_value_as_json(value)?; let map = state.serialized_jsons.entry(object_key.into()).or_default(); - if let Some(value_key) = value_key { - let parsed_value = - serde_json::from_str(value).unwrap_or_else(|_| Value::String(value.into())); - map.insert(value_key.into(), parsed_value); - } else { - *map = serde_json::from_str(value) - .map_err(|err| fmt_err!("failed to parse JSON object: {err}"))?; - } + map.insert(value_key.into(), value); let stringified = serde_json::to_string(map).unwrap(); Ok(stringified.abi_encode()) } -fn array_str(values: I, quoted: bool) -> String -where - I: IntoIterator, - I::IntoIter: ExactSizeIterator, - T: std::fmt::Display, -{ - let iter = values.into_iter(); - let mut s = String::with_capacity(2 + iter.len() * 32); - s.push('['); - for (i, item) in iter.enumerate() { - if i > 0 { - s.push(','); +/// Resolves a [DynSolType] from user input. +fn resolve_type(type_description: &str) -> Result { + if let Ok(ty) = DynSolType::parse(type_description) { + return Ok(ty); + }; + + if let Ok(encoded) = EncodeType::parse(type_description) { + let main_type = encoded.types[0].type_name; + let mut resolver = Resolver::default(); + for t in encoded.types { + resolver.ingest(t.to_owned()); + } + + return Ok(resolver.resolve(main_type)?) + }; + + bail!("type description should be a valid Solidity type or a EIP712 `encodeType` string") +} + +#[cfg(test)] +mod tests { + use super::*; + use alloy_primitives::FixedBytes; + use proptest::strategy::Strategy; + + fn contains_tuple(value: &DynSolValue) -> bool { + match value { + DynSolValue::Tuple(_) | DynSolValue::CustomStruct { .. } => true, + DynSolValue::Array(v) | DynSolValue::FixedArray(v) => { + v.first().map_or(false, contains_tuple) + } + _ => false, + } + } + + /// [DynSolValue::Bytes] of length 32 and 20 are converted to [DynSolValue::FixedBytes] and + /// [DynSolValue::Address] respectively. Thus, we can't distinguish between address and bytes of + /// length 20 during decoding. Because of that, there are issues with handling of arrays of + /// those types. + fn fixup_guessable(value: DynSolValue) -> DynSolValue { + match value { + DynSolValue::Array(mut v) | DynSolValue::FixedArray(mut v) => { + if let Some(DynSolValue::Bytes(_)) = v.first() { + v.retain(|v| { + let len = v.as_bytes().unwrap().len(); + len != 32 && len != 20 + }) + } + DynSolValue::Array(v.into_iter().map(fixup_guessable).collect()) + } + DynSolValue::FixedBytes(v, _) => DynSolValue::FixedBytes(v, 32), + DynSolValue::Bytes(v) if v.len() == 32 => { + DynSolValue::FixedBytes(FixedBytes::from_slice(&v), 32) + } + DynSolValue::Bytes(v) if v.len() == 20 => DynSolValue::Address(Address::from_slice(&v)), + _ => value, } + } + + fn guessable_types() -> impl proptest::strategy::Strategy { + proptest::arbitrary::any::() + .prop_map(fixup_guessable) + .prop_filter("tuples are not supported", |v| !contains_tuple(v)) + .prop_filter("filter out values without type", |v| v.as_type().is_some()) + } - if quoted { - s.push('"'); + // Tests to ensure that conversion [DynSolValue] -> [serde_json::Value] -> [DynSolValue] + proptest::proptest! { + #[test] + fn test_json_roundtrip_guessed(v in guessable_types()) { + let json = serialize_value_as_json(v.clone()).unwrap(); + let value = json_value_to_token(&json).unwrap(); + + // do additional abi_encode -> abi_decode to avoid zero signed integers getting decoded as unsigned and causing assert_eq to fail. + let decoded = v.as_type().unwrap().abi_decode(&value.abi_encode()).unwrap(); + assert_eq!(decoded, v); } - write!(s, "{item}").unwrap(); - if quoted { - s.push('"'); + + #[test] + fn test_json_roundtrip(v in proptest::arbitrary::any::().prop_filter("filter out values without type", |v| v.as_type().is_some())) { + let json = serialize_value_as_json(v.clone()).unwrap(); + let value = parse_json_as(&json, &v.as_type().unwrap()).unwrap(); + assert_eq!(value, v); } } - s.push(']'); - s } diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index c808bc04f6ceb..7b7d9b505356b 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -166,7 +166,7 @@ where } #[instrument(target = "cheatcodes", level = "debug", skip(ty), fields(%ty), ret)] -fn parse_value(s: &str, ty: &DynSolType) -> Result { +pub(super) fn parse_value(s: &str, ty: &DynSolType) -> Result { match ty.coerce_str(s) { Ok(value) => Ok(value), Err(e) => match parse_value_fallback(s, ty) { diff --git a/crates/cheatcodes/src/toml.rs b/crates/cheatcodes/src/toml.rs index e1827dbef194d..e83a183905472 100644 --- a/crates/cheatcodes/src/toml.rs +++ b/crates/cheatcodes/src/toml.rs @@ -45,7 +45,7 @@ impl Cheatcode for parseTomlUintCall { impl Cheatcode for parseTomlUintArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; - parse_toml_coerce(toml, key, &DynSolType::Uint(256)) + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(DynSolType::Uint(256)))) } } @@ -59,7 +59,7 @@ impl Cheatcode for parseTomlIntCall { impl Cheatcode for parseTomlIntArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; - parse_toml_coerce(toml, key, &DynSolType::Int(256)) + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(DynSolType::Int(256)))) } } @@ -73,7 +73,7 @@ impl Cheatcode for parseTomlBoolCall { impl Cheatcode for parseTomlBoolArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; - parse_toml_coerce(toml, key, &DynSolType::Bool) + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(DynSolType::Bool))) } } @@ -87,7 +87,7 @@ impl Cheatcode for parseTomlAddressCall { impl Cheatcode for parseTomlAddressArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; - parse_toml_coerce(toml, key, &DynSolType::Address) + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(DynSolType::Address))) } } @@ -101,7 +101,7 @@ impl Cheatcode for parseTomlStringCall { impl Cheatcode for parseTomlStringArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; - parse_toml_coerce(toml, key, &DynSolType::String) + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(DynSolType::String))) } } @@ -115,7 +115,7 @@ impl Cheatcode for parseTomlBytesCall { impl Cheatcode for parseTomlBytesArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; - parse_toml_coerce(toml, key, &DynSolType::Bytes) + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(DynSolType::Bytes))) } } @@ -129,7 +129,7 @@ impl Cheatcode for parseTomlBytes32Call { impl Cheatcode for parseTomlBytes32ArrayCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; - parse_toml_coerce(toml, key, &DynSolType::FixedBytes(32)) + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(DynSolType::FixedBytes(32)))) } } diff --git a/crates/config/src/bind_json.rs b/crates/config/src/bind_json.rs new file mode 100644 index 0000000000000..71d8d41aa911b --- /dev/null +++ b/crates/config/src/bind_json.rs @@ -0,0 +1,27 @@ +use crate::filter::GlobMatcher; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +/// Contains the config for `forge bind-json` +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct BindJsonConfig { + /// Path for the generated bindings file. + pub out: PathBuf, + /// Globs to include. + /// + /// If provided, only the files matching the globs will be included. Otherwise, defaults to + /// including all project files. + pub include: Vec, + /// Globs to ignore + pub exclude: Vec, +} + +impl Default for BindJsonConfig { + fn default() -> Self { + Self { + out: PathBuf::from("utils/JsonBindings.sol"), + exclude: Vec::new(), + include: Vec::new(), + } + } +} diff --git a/crates/config/src/filter.rs b/crates/config/src/filter.rs index b7b3a3ab3ace3..0d00b613f26fd 100644 --- a/crates/config/src/filter.rs +++ b/crates/config/src/filter.rs @@ -2,6 +2,7 @@ use core::fmt; use foundry_compilers::FileFilter; +use serde::{Deserialize, Serialize}; use std::{ convert::Infallible, path::{Path, PathBuf}, @@ -96,6 +97,27 @@ impl From for GlobMatcher { } } +impl Serialize for GlobMatcher { + fn serialize(&self, serializer: S) -> Result { + self.glob().glob().serialize(serializer) + } +} + +impl<'de> Deserialize<'de> for GlobMatcher { + fn deserialize>(deserializer: D) -> Result { + let s = String::deserialize(deserializer)?; + s.parse().map_err(serde::de::Error::custom) + } +} + +impl PartialEq for GlobMatcher { + fn eq(&self, other: &Self) -> bool { + self.as_str() == other.as_str() + } +} + +impl Eq for GlobMatcher {} + /// Bundles multiple `SkipBuildFilter` into a single `FileFilter` #[derive(Clone, Debug)] pub struct SkipBuildFilters { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 89924d5c8b80d..e59c44a57b95e 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -16,6 +16,7 @@ use figment::{ value::{Dict, Map, Value}, Error, Figment, Metadata, Profile, Provider, }; +use filter::GlobMatcher; use foundry_compilers::{ artifacts::{ output_selection::{ContractOutputSelection, OutputSelection}, @@ -110,6 +111,9 @@ use soldeer::SoldeerConfig; mod vyper; use vyper::VyperConfig; +mod bind_json; +use bind_json::BindJsonConfig; + /// Foundry configuration /// /// # Defaults @@ -178,8 +182,7 @@ pub struct Config { /// additional solc include paths for `--include-path` pub include_paths: Vec, /// glob patterns to skip - #[serde(with = "from_vec_glob")] - pub skip: Vec, + pub skip: Vec, /// whether to force a `project.clean()` pub force: bool, /// evm version to use @@ -389,6 +392,8 @@ pub struct Config { pub fmt: FormatterConfig, /// Configuration for `forge doc` pub doc: DocConfig, + /// Configuration for `forge bind-json` + pub bind_json: BindJsonConfig, /// Configures the permissions of cheat codes that touch the file system. /// /// This includes what operations can be executed (read, write) @@ -484,6 +489,7 @@ impl Config { "labels", "dependencies", "vyper", + "bind_json", ]; /// File name of config toml file @@ -1951,30 +1957,6 @@ pub(crate) mod from_opt_glob { } } -/// Ser/de `globset::Glob` explicitly to handle `Option` properly -pub(crate) mod from_vec_glob { - use serde::{Deserialize, Deserializer, Serialize, Serializer}; - - pub fn serialize(value: &[globset::Glob], serializer: S) -> Result - where - S: Serializer, - { - let value = value.iter().map(|g| g.glob()).collect::>(); - value.serialize(serializer) - } - - pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> - where - D: Deserializer<'de>, - { - let s: Vec = Vec::deserialize(deserializer)?; - s.into_iter() - .map(|s| globset::Glob::new(&s)) - .collect::, _>>() - .map_err(serde::de::Error::custom) - } -} - /// A helper wrapper around the root path used during Config detection #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] @@ -2142,6 +2124,7 @@ impl Default for Config { build_info_path: None, fmt: Default::default(), doc: Default::default(), + bind_json: Default::default(), labels: Default::default(), unchecked_cheatcode_artifacts: false, create2_library_salt: Self::DEFAULT_CREATE2_LIBRARY_SALT, diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 39b48d1107bad..5250ea448ac40 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -46,7 +46,7 @@ revm-inspectors.workspace = true eyre.workspace = true parking_lot.workspace = true -proptest = "1" +proptest.workspace = true thiserror.workspace = true tracing.workspace = true indicatif = "0.17" diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 0106b1d2704c1..124514b561fe3 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -42,7 +42,7 @@ revm = { workspace = true, features = [ eyre .workspace = true itertools.workspace = true parking_lot.workspace = true -proptest = "1" +proptest.workspace = true rand.workspace = true serde.workspace = true thiserror.workspace = true diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 790f8da9ef35f..02bc6d0c8a648 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -40,7 +40,7 @@ revm-inspectors.workspace = true comfy-table = "7" eyre.workspace = true -proptest = "1" +proptest.workspace = true rayon.workspace = true serde.workspace = true tracing.workspace = true diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs new file mode 100644 index 0000000000000..bd2d0ea30d673 --- /dev/null +++ b/crates/forge/bin/cmd/bind_json.rs @@ -0,0 +1,539 @@ +use super::eip712::Resolver; +use clap::{Parser, ValueHint}; +use eyre::Result; +use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; +use foundry_common::{compile::with_compilation_reporter, fs}; +use foundry_compilers::{ + artifacts::{ + output_selection::OutputSelection, ContractDefinitionPart, Source, SourceUnit, + SourceUnitPart, Sources, + }, + multi::{MultiCompilerLanguage, MultiCompilerParsedSource}, + project::ProjectCompiler, + solc::SolcLanguage, + CompilerSettings, Graph, Project, +}; +use foundry_config::Config; +use itertools::Itertools; +use rayon::prelude::*; +use solang_parser::pt as solang_ast; +use std::{ + collections::{BTreeMap, BTreeSet}, + fmt, + fmt::Write, + path::PathBuf, + sync::Arc, +}; + +foundry_config::impl_figment_convert!(BindJsonArgs, opts); + +/// CLI arguments for `forge bind-json`. +#[derive(Clone, Debug, Parser)] +pub struct BindJsonArgs { + /// The path to write bindings to. + #[arg(value_hint = ValueHint::FilePath, value_name = "PATH")] + pub out: Option, + + #[command(flatten)] + opts: CoreBuildArgs, +} + +impl BindJsonArgs { + pub fn run(self) -> Result<()> { + self.preprocess()?.compile()?.find_structs()?.resolve_imports_and_aliases().write()?; + + Ok(()) + } + + /// In cases when user moves/renames/deletes structs, compiler will start failing because + /// generated bindings will be referencing non-existing structs or importing non-existing + /// files. + /// + /// Because of that, we need a little bit of preprocessing to make sure that bindings will still + /// be valid. + /// + /// The strategy is: + /// 1. Replace bindings file with an empty one to get rid of potentially invalid imports. + /// 2. Remove all function bodies to get rid of `serialize`/`deserialize` invocations. + /// 3. Remove all `immutable` attributes to avoid errors because of erased constructors + /// initializing them. + /// + /// After that we'll still have enough information for bindings but compilation should succeed + /// in most of the cases. + fn preprocess(self) -> Result { + let config = self.try_load_config_emit_warnings()?; + let project = config.create_project(false, true)?; + + let target_path = config.root.0.join(self.out.as_ref().unwrap_or(&config.bind_json.out)); + + let sources = project.paths.read_input_files()?; + let graph = Graph::::resolve_sources(&project.paths, sources)?; + + // We only generate bindings for a single Solidity version to avoid conflicts. + let mut sources = graph + // resolve graph into mapping language -> version -> sources + .into_sources_by_version(project.offline, &project.locked_versions, &project.compiler)? + .0 + .into_iter() + // we are only interested in Solidity sources + .find(|(lang, _)| *lang == MultiCompilerLanguage::Solc(SolcLanguage::Solidity)) + .ok_or_else(|| eyre::eyre!("no Solidity sources"))? + .1 + .into_iter() + // For now, we are always picking the latest version. + .max_by(|(v1, _), (v2, _)| v1.cmp(v2)) + .unwrap() + .1; + + // Insert empty bindings file + sources.insert(target_path.clone(), Source::new("library JsonBindings {}")); + + let sources = Sources( + sources + .0 + .into_par_iter() + .map(|(path, source)| { + let mut locs_to_update = Vec::new(); + let mut content = Arc::unwrap_or_clone(source.content); + let (parsed, _) = solang_parser::parse(&content, 0) + .map_err(|errors| eyre::eyre!("Parser failed: {errors:?}"))?; + + // All function definitions in the file + let mut functions = Vec::new(); + + for part in &parsed.0 { + if let solang_ast::SourceUnitPart::FunctionDefinition(def) = part { + functions.push(def); + } + if let solang_ast::SourceUnitPart::ContractDefinition(contract) = part { + for part in &contract.parts { + match part { + solang_ast::ContractPart::FunctionDefinition(def) => { + functions.push(def); + } + // Remove `immutable` attributes + solang_ast::ContractPart::VariableDefinition(def) => { + for attr in &def.attrs { + if let solang_ast::VariableAttribute::Immutable(loc) = + attr + { + locs_to_update.push(( + loc.start(), + loc.end(), + String::new(), + )); + } + } + } + _ => {} + } + } + }; + } + + for def in functions { + // If there's no body block, keep the function as is + let Some(solang_ast::Statement::Block { loc, .. }) = def.body else { + continue; + }; + let new_body = match def.ty { + solang_ast::FunctionTy::Modifier => "{ _; }", + _ => "{ revert(); }", + }; + let start = loc.start(); + let end = loc.end(); + locs_to_update.push((start, end + 1, new_body.to_string())); + } + + locs_to_update.sort_by_key(|(start, _, _)| *start); + + let mut shift = 0_i64; + + for (start, end, new) in locs_to_update { + let start = ((start as i64) - shift) as usize; + let end = ((end as i64) - shift) as usize; + + content.replace_range(start..end, new.as_str()); + shift += (end - start) as i64; + shift -= new.len() as i64; + } + + Ok((path, Source::new(content))) + }) + .collect::>>()?, + ); + + Ok(PreprocessedState { sources, target_path, project, config }) + } +} + +/// A single struct definition for which we need to generate bindings. +#[derive(Debug, Clone)] +struct StructToWrite { + /// Name of the struct definition. + name: String, + /// Name of the contract containing the struct definition. None if the struct is defined at the + /// file level. + contract_name: Option, + /// Import alias for the contract or struct, depending on whether the struct is imported + /// directly, or via a contract. + import_alias: Option, + /// Path to the file containing the struct definition. + path: PathBuf, + /// EIP712 schema for the struct. + schema: String, + /// Name of the struct definition used in function names and schema_* variables. + name_in_fns: String, +} + +impl StructToWrite { + /// Returns the name of the imported item. If struct is definied at the file level, returns the + /// struct name, otherwise returns the parent contract name. + fn struct_or_contract_name(&self) -> &str { + self.contract_name.as_deref().unwrap_or(&self.name) + } + + /// Same as [StructToWrite::struct_or_contract_name] but with alias applied. + fn struct_or_contract_name_with_alias(&self) -> &str { + self.import_alias.as_deref().unwrap_or(self.struct_or_contract_name()) + } + + /// Path which can be used to reference this struct in input/output parameters. Either + /// StructName or ParantName.StructName + fn full_path(&self) -> String { + if self.contract_name.is_some() { + format!("{}.{}", self.struct_or_contract_name_with_alias(), self.name) + } else { + self.struct_or_contract_name_with_alias().to_string() + } + } + + fn import_item(&self) -> String { + if let Some(alias) = &self.import_alias { + format!("{} as {}", self.struct_or_contract_name(), alias) + } else { + self.struct_or_contract_name().to_string() + } + } +} + +#[derive(Debug)] +struct PreprocessedState { + sources: Sources, + target_path: PathBuf, + project: Project, + config: Config, +} + +impl PreprocessedState { + fn compile(self) -> Result { + let Self { sources, target_path, mut project, config } = self; + + project.settings.update_output_selection(|selection| { + *selection = OutputSelection::ast_output_selection(); + }); + + let output = with_compilation_reporter(false, || { + ProjectCompiler::with_sources(&project, sources)?.compile() + })?; + + if output.has_compiler_errors() { + eyre::bail!("{output}"); + } + + // Collect ASTs by getting them from sources and converting into strongly typed + // `SourceUnit`s. Also strips root from paths. + let asts = output + .into_output() + .sources + .into_iter() + .filter_map(|(path, mut sources)| Some((path, sources.swap_remove(0).source_file.ast?))) + .map(|(path, ast)| { + Ok(( + path.strip_prefix(project.root()).unwrap_or(&path).to_path_buf(), + serde_json::from_str::(&serde_json::to_string(&ast)?)?, + )) + }) + .collect::>>()?; + + Ok(CompiledState { asts, target_path, config, project }) + } +} + +#[derive(Debug, Clone)] +struct CompiledState { + asts: BTreeMap, + target_path: PathBuf, + config: Config, + project: Project, +} + +impl CompiledState { + fn find_structs(self) -> Result { + let Self { asts, target_path, config, project } = self; + + // construct mapping (file, id) -> (struct definition, optional parent contract name) + let structs = asts + .iter() + .flat_map(|(path, ast)| { + let mut structs = Vec::new(); + // we walk AST directly instead of using visitors because we need to distinguish + // between file-level and contract-level struct definitions + for node in &ast.nodes { + match node { + SourceUnitPart::StructDefinition(def) => { + structs.push((def, None)); + } + SourceUnitPart::ContractDefinition(contract) => { + for node in &contract.nodes { + if let ContractDefinitionPart::StructDefinition(def) = node { + structs.push((def, Some(contract.name.clone()))); + } + } + } + _ => {} + } + } + structs.into_iter().map(|(def, parent)| ((path.as_path(), def.id), (def, parent))) + }) + .collect::>(); + + // Resolver for EIP712 schemas + let resolver = Resolver::new(&asts); + + let mut structs_to_write = Vec::new(); + + let include = config.bind_json.include; + let exclude = config.bind_json.exclude; + + for ((path, id), (def, contract_name)) in structs { + // For some structs there's no schema (e.g. if they contain a mapping), so we just skip + // those. + let Some(schema) = resolver.resolve_struct_eip712(id, &mut Default::default(), true)? + else { + continue + }; + + if !include.is_empty() { + if !include.iter().any(|matcher| matcher.is_match(path)) { + continue; + } + } else { + // Exclude library files by default + if project.paths.has_library_ancestor(path) { + continue; + } + } + + if exclude.iter().any(|matcher| matcher.is_match(path)) { + continue; + } + + structs_to_write.push(StructToWrite { + name: def.name.clone(), + contract_name, + path: path.to_path_buf(), + schema, + + // will be filled later + import_alias: None, + name_in_fns: String::new(), + }) + } + + Ok(StructsState { structs_to_write, target_path }) + } +} + +#[derive(Debug)] +struct StructsState { + structs_to_write: Vec, + target_path: PathBuf, +} + +impl StructsState { + /// We manage 2 namespsaces for JSON bindings: + /// - Namespace of imported items. This includes imports of contracts containing structs and + /// structs defined at the file level. + /// - Namespace of struct names used in function names and schema_* variables. + /// + /// Both of those might contain conflicts, so we need to resolve them. + fn resolve_imports_and_aliases(self) -> ResolvedState { + let Self { mut structs_to_write, target_path } = self; + + // firstly, we resolve imported names conflicts + // construct mapping name -> paths from which items with such name are imported + let mut names_to_paths = BTreeMap::new(); + + for s in &structs_to_write { + names_to_paths + .entry(s.struct_or_contract_name()) + .or_insert_with(BTreeSet::new) + .insert(s.path.as_path()); + } + + // now resolve aliases for names which need them and construct mapping (name, file) -> alias + let mut aliases = BTreeMap::new(); + + for (name, paths) in names_to_paths { + if paths.len() <= 1 { + // no alias needed + continue + } + + for (i, path) in paths.into_iter().enumerate() { + aliases + .entry(name.to_string()) + .or_insert_with(BTreeMap::new) + .insert(path.to_path_buf(), format!("{name}_{i}")); + } + } + + for s in &mut structs_to_write { + let name = s.struct_or_contract_name(); + if aliases.contains_key(name) { + s.import_alias = Some(aliases[name][&s.path].clone()); + } + } + + // Each struct needs a name by which we are referencing it in function names (e.g. + // deserializeFoo) Those might also have conflicts, so we manage a separate + // namespace for them + let mut name_to_structs_indexes = BTreeMap::new(); + + for (idx, s) in structs_to_write.iter().enumerate() { + name_to_structs_indexes.entry(&s.name).or_insert_with(Vec::new).push(idx); + } + + // Keeps `Some` for structs that will be referenced by name other than their definition + // name. + let mut fn_names = vec![None; structs_to_write.len()]; + + for (name, indexes) in name_to_structs_indexes { + if indexes.len() > 1 { + for (i, idx) in indexes.into_iter().enumerate() { + fn_names[idx] = Some(format!("{name}_{i}")); + } + } + } + + for (s, fn_name) in structs_to_write.iter_mut().zip(fn_names.into_iter()) { + s.name_in_fns = fn_name.unwrap_or(s.name.clone()); + } + + ResolvedState { structs_to_write, target_path } + } +} + +struct ResolvedState { + structs_to_write: Vec, + target_path: PathBuf, +} + +impl ResolvedState { + fn write(self) -> Result { + let mut result = String::new(); + self.write_imports(&mut result)?; + self.write_vm(&mut result); + self.write_library(&mut result)?; + + if let Some(parent) = self.target_path.parent() { + fs::create_dir_all(parent)?; + } + fs::write(&self.target_path, &result)?; + + println!("Bindings written to {}", self.target_path.display()); + + Ok(result) + } + + fn write_imports(&self, result: &mut String) -> fmt::Result { + let mut grouped_imports = BTreeMap::new(); + + for struct_to_write in &self.structs_to_write { + let item = struct_to_write.import_item(); + grouped_imports + .entry(struct_to_write.path.as_path()) + .or_insert_with(BTreeSet::new) + .insert(item); + } + + result.push_str("// Automatically generated by forge bind-json.\n\npragma solidity >=0.6.2 <0.9.0;\npragma experimental ABIEncoderV2;\n\n"); + + for (path, names) in grouped_imports { + writeln!( + result, + "import {{{}}} from \"{}\";", + names.iter().join(", "), + path.display() + )?; + } + + Ok(()) + } + + /// Writes minimal VM interface to not depend on forge-std version + fn write_vm(&self, result: &mut String) { + result.push_str(r#" +interface Vm { + 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 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); +} + "#); + } + + fn write_library(&self, result: &mut String) -> fmt::Result { + result.push_str( + r#" +library JsonBindings { + Vm constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); + +"#, + ); + // write schema constants + for struct_to_write in &self.structs_to_write { + writeln!( + result, + " string constant schema_{} = \"{}\";", + struct_to_write.name_in_fns, struct_to_write.schema + )?; + } + + // write serialization functions + for struct_to_write in &self.structs_to_write { + write!( + result, + r#" + function serialize({path} memory value) internal pure returns (string memory) {{ + return vm.serializeJsonType(schema_{name_in_fns}, abi.encode(value)); + }} + + function serialize({path} memory value, string memory objectKey, string memory valueKey) internal returns (string memory) {{ + return vm.serializeJsonType(objectKey, valueKey, schema_{name_in_fns}, abi.encode(value)); + }} + + function deserialize{name_in_fns}(string memory json) public pure returns ({path} memory) {{ + return abi.decode(vm.parseJsonType(json, schema_{name_in_fns}), ({path})); + }} + + function deserialize{name_in_fns}(string memory json, string memory path) public pure returns ({path} memory) {{ + return abi.decode(vm.parseJsonType(json, path, schema_{name_in_fns}), ({path})); + }} + + function deserialize{name_in_fns}Array(string memory json, string memory path) public pure returns ({path}[] memory) {{ + return abi.decode(vm.parseJsonTypeArray(json, path, schema_{name_in_fns}), ({path}[])); + }} +"#, + name_in_fns = struct_to_write.name_in_fns, + path = struct_to_write.full_path() + )?; + } + + result.push_str("}\n"); + + Ok(()) + } +} diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs new file mode 100644 index 0000000000000..636c305806dc8 --- /dev/null +++ b/crates/forge/bin/cmd/eip712.rs @@ -0,0 +1,241 @@ +use clap::{Parser, ValueHint}; +use eyre::{Ok, OptionExt, Result}; +use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; +use foundry_common::compile::ProjectCompiler; +use foundry_compilers::{ + artifacts::{ + output_selection::OutputSelection, + visitor::{Visitor, Walk}, + ContractDefinition, EnumDefinition, SourceUnit, StructDefinition, TypeDescriptions, + TypeName, + }, + CompilerSettings, +}; +use std::{collections::BTreeMap, path::PathBuf}; + +foundry_config::impl_figment_convert!(Eip712Args, opts); + +/// CLI arguments for `forge eip712`. +#[derive(Clone, Debug, Parser)] +pub struct Eip712Args { + /// The path to the file from which to read struct definitions. + #[arg(value_hint = ValueHint::FilePath, value_name = "PATH")] + pub target_path: PathBuf, + + #[command(flatten)] + opts: CoreBuildArgs, +} + +impl Eip712Args { + pub fn run(self) -> Result<()> { + let config = self.try_load_config_emit_warnings()?; + let mut project = config.create_project(false, true)?; + let target_path = dunce::canonicalize(self.target_path)?; + project.settings.update_output_selection(|selection| { + *selection = OutputSelection::ast_output_selection(); + }); + + let output = ProjectCompiler::new().files([target_path.clone()]).compile(&project)?; + + // Collect ASTs by getting them from sources and converting into strongly typed + // `SourceUnit`s. + let asts = output + .into_output() + .sources + .into_iter() + .filter_map(|(path, mut sources)| Some((path, sources.swap_remove(0).source_file.ast?))) + .map(|(path, ast)| { + Ok((path, serde_json::from_str::(&serde_json::to_string(&ast)?)?)) + }) + .collect::>>()?; + + let resolver = Resolver::new(&asts); + + let target_ast = asts + .get(&target_path) + .ok_or_else(|| eyre::eyre!("Could not find AST for target file {target_path:?}"))?; + + let structs_in_target = { + let mut collector = StructCollector::default(); + target_ast.walk(&mut collector); + collector.0 + }; + + for (id, _) in structs_in_target { + if let Some(resolved) = + resolver.resolve_struct_eip712(id, &mut Default::default(), true)? + { + println!("{resolved}"); + println!(); + } + } + + Ok(()) + } +} + +/// AST [Visitor] used for collecting struct definitions. +#[derive(Debug, Clone, Default)] +pub struct StructCollector(pub BTreeMap); + +impl Visitor for StructCollector { + fn visit_struct_definition(&mut self, def: &StructDefinition) { + self.0.insert(def.id, def.clone()); + } +} + +/// Collects mapping from AST id of type definition to representation of this type for EIP-712 +/// encoding. +/// +/// For now, maps contract definitions to `address` and enums to `uint8`. +#[derive(Debug, Clone, Default)] +struct SimpleCustomTypesCollector(BTreeMap); + +impl Visitor for SimpleCustomTypesCollector { + fn visit_contract_definition(&mut self, def: &ContractDefinition) { + self.0.insert(def.id, "address".to_string()); + } + + fn visit_enum_definition(&mut self, def: &EnumDefinition) { + self.0.insert(def.id, "uint8".to_string()); + } +} + +pub struct Resolver { + simple_types: BTreeMap, + structs: BTreeMap, +} + +impl Resolver { + pub fn new(asts: &BTreeMap) -> Self { + let simple_types = { + let mut collector = SimpleCustomTypesCollector::default(); + asts.values().for_each(|ast| ast.walk(&mut collector)); + + collector.0 + }; + + let structs = { + let mut collector = StructCollector::default(); + asts.values().for_each(|ast| ast.walk(&mut collector)); + collector.0 + }; + + Self { simple_types, structs } + } + + /// Converts a given struct definition into EIP-712 `encodeType` representation. + /// + /// Returns `None` if struct contains any fields that are not supported by EIP-712 (e.g. + /// mappings or function pointers). + pub fn resolve_struct_eip712( + &self, + id: usize, + subtypes: &mut BTreeMap, + append_subtypes: bool, + ) -> Result> { + let def = &self.structs[&id]; + let mut result = format!("{}(", def.name); + + for (idx, member) in def.members.iter().enumerate() { + let Some(ty) = self.resolve_type( + member.type_name.as_ref().ok_or_eyre("missing type name")?, + subtypes, + )? + else { + return Ok(None) + }; + + result.push_str(&ty); + result.push(' '); + result.push_str(&member.name); + + if idx < def.members.len() - 1 { + result.push(','); + } + } + + result.push(')'); + + if !append_subtypes { + return Ok(Some(result)) + } + + for subtype_id in subtypes.values().copied().collect::>() { + if subtype_id == id { + continue + } + let Some(encoded_subtype) = self.resolve_struct_eip712(subtype_id, subtypes, false)? + else { + return Ok(None) + }; + result.push_str(&encoded_subtype); + } + + Ok(Some(result)) + } + + /// Converts given [TypeName] into a type which can be converted to [DynSolType]. + /// + /// Returns `None` if the type is not supported for EIP712 encoding. + pub fn resolve_type( + &self, + type_name: &TypeName, + subtypes: &mut BTreeMap, + ) -> Result> { + match type_name { + TypeName::FunctionTypeName(_) | TypeName::Mapping(_) => Ok(None), + TypeName::ElementaryTypeName(ty) => Ok(Some(ty.name.clone())), + TypeName::ArrayTypeName(ty) => { + let Some(inner) = self.resolve_type(&ty.base_type, subtypes)? else { + return Ok(None) + }; + let len = parse_array_length(&ty.type_descriptions)?; + + Ok(Some(format!("{inner}[{}]", len.unwrap_or("")))) + } + TypeName::UserDefinedTypeName(ty) => { + if let Some(name) = self.simple_types.get(&(ty.referenced_declaration as usize)) { + Ok(Some(name.clone())) + } else if let Some(def) = self.structs.get(&(ty.referenced_declaration as usize)) { + let name = + // If we've already seen struct with this ID, just use assigned name. + if let Some((name, _)) = subtypes.iter().find(|(_, id)| **id == def.id) { + name.clone() + // Otherwise, try assigning a new name. + } else { + let mut i = 0; + let mut name = def.name.clone(); + while subtypes.contains_key(&name) { + i += 1; + name = format!("{}_{i}", def.name); + } + + subtypes.insert(name.clone(), def.id); + name + }; + + return Ok(Some(name)) + } else { + return Ok(None) + } + } + } + } +} + +fn parse_array_length(type_description: &TypeDescriptions) -> Result> { + let type_string = + type_description.type_string.as_ref().ok_or_eyre("missing typeString for array type")?; + let Some(inside_brackets) = + type_string.rsplit_once("[").and_then(|(_, right)| right.split("]").next()) + else { + eyre::bail!("failed to parse array type string: {type_string}") + }; + + if inside_brackets.is_empty() { + Ok(None) + } else { + Ok(Some(inside_brackets)) + } +} diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index d3e2f8b6d314c..ff63fa7cbc0eb 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -40,6 +40,7 @@ //! ``` pub mod bind; +pub mod bind_json; pub mod build; pub mod cache; pub mod clone; @@ -48,6 +49,7 @@ pub mod coverage; pub mod create; pub mod debug; pub mod doc; +pub mod eip712; pub mod flatten; pub mod fmt; pub mod geiger; diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index aff2ad530d96b..4484be629e256 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -112,6 +112,8 @@ fn main() -> Result<()> { }, ForgeSubcommand::VerifyBytecode(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Soldeer(cmd) => cmd.run(), + ForgeSubcommand::Eip712(cmd) => cmd.run(), + ForgeSubcommand::BindJson(cmd) => cmd.run(), } } diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index a449bd75f46f5..b86d19c17728d 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -1,8 +1,8 @@ use crate::cmd::{ - bind::BindArgs, build::BuildArgs, cache::CacheArgs, clone::CloneArgs, config, coverage, - create::CreateArgs, debug::DebugArgs, doc::DocArgs, flatten, fmt::FmtArgs, geiger, generate, - init::InitArgs, inspect, install::InstallArgs, remappings::RemappingArgs, remove::RemoveArgs, - selectors::SelectorsSubcommands, snapshot, soldeer, test, tree, update, + bind::BindArgs, bind_json, build::BuildArgs, cache::CacheArgs, clone::CloneArgs, config, + coverage, create::CreateArgs, debug::DebugArgs, doc::DocArgs, eip712, flatten, fmt::FmtArgs, + geiger, generate, init::InitArgs, inspect, install::InstallArgs, remappings::RemappingArgs, + remove::RemoveArgs, selectors::SelectorsSubcommands, snapshot, soldeer, test, tree, update, }; use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; @@ -164,6 +164,12 @@ pub enum ForgeSubcommand { /// Soldeer dependency manager. Soldeer(soldeer::SoldeerArgs), + + /// Generate EIP-712 struct encodings for structs from a given file. + Eip712(eip712::Eip712Args), + + /// Generate bindings for serialization/deserialization of project structs via JSON cheatcodes. + BindJson(bind_json::BindJsonArgs), } #[cfg(test)] diff --git a/crates/forge/tests/cli/bind_json.rs b/crates/forge/tests/cli/bind_json.rs new file mode 100644 index 0000000000000..bdc8f0fa19ec9 --- /dev/null +++ b/crates/forge/tests/cli/bind_json.rs @@ -0,0 +1,54 @@ +// tests complete bind-json workflow +// ensures that we can run forge-bind even if files are depending on yet non-existent bindings and +// that generated bindings are correct +forgetest_init!(test_bind_json, |prj, cmd| { + prj.add_test( + "JsonBindings", + r#" +import {JsonBindings} from "utils/JsonBindings.sol"; +import {Test} from "forge-std/Test.sol"; + +struct TopLevelStruct { + uint256 param1; + int8 param2; +} + +contract BindJsonTest is Test { + using JsonBindings for *; + + struct ContractLevelStruct { + address[][] param1; + address addrParam; + } + + function testTopLevel() public { + string memory json = '{"param1": 1, "param2": -1}'; + TopLevelStruct memory topLevel = json.deserializeTopLevelStruct(); + assertEq(topLevel.param1, 1); + assertEq(topLevel.param2, -1); + + json = topLevel.serialize(); + TopLevelStruct memory deserialized = json.deserializeTopLevelStruct(); + assertEq(keccak256(abi.encode(deserialized)), keccak256(abi.encode(topLevel))); + } + + function testContractLevel() public { + ContractLevelStruct memory contractLevel = ContractLevelStruct({ + param1: new address[][](2), + addrParam: address(0xBEEF) + }); + + string memory json = contractLevel.serialize(); + assertEq(json, '{"param1":[[],[]],"addrParam":"0x000000000000000000000000000000000000bEEF"}'); + + ContractLevelStruct memory deserialized = json.deserializeContractLevelStruct(); + assertEq(keccak256(abi.encode(deserialized)), keccak256(abi.encode(contractLevel))); + } +} +"#, + ) + .unwrap(); + + cmd.arg("bind-json").assert_success(); + cmd.forge_fuse().args(["test"]).assert_success(); +}); diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index acbb545603614..6cb17d0d4872b 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -57,8 +57,10 @@ contract ValidContract {} ) .unwrap(); - let config = - Config { skip: vec![Glob::new("src/InvalidContract.sol").unwrap()], ..Default::default() }; + let config = Config { + skip: vec![Glob::new("src/InvalidContract.sol").unwrap().into()], + ..Default::default() + }; prj.write_config(config); cmd.args(["build"]).assert_success(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index e28415e305964..f966d6024118d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -134,6 +134,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { build_info_path: None, fmt: Default::default(), doc: Default::default(), + bind_json: Default::default(), fs_permissions: Default::default(), labels: Default::default(), prague: true, diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 0ac67d81b1761..b8bc3db5add4d 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -4,6 +4,7 @@ extern crate foundry_test_utils; pub mod constants; pub mod utils; +mod bind_json; mod build; mod cache; mod cmd; diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 4d6c091ee842f..c0e657d0687eb 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -387,7 +387,7 @@ async fn test_shrink_fail_on_revert() { runner.test_options.fuzz.seed = Some(U256::from(119u32)); runner.test_options.invariant.fail_on_revert = true; runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 100; + runner.test_options.invariant.depth = 200; match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 2995403968d79..cf72e88475d8e 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -285,6 +285,9 @@ interface Vm { 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 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); @@ -363,6 +366,8 @@ interface Vm { 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); diff --git a/testdata/default/cheats/Json.t.sol b/testdata/default/cheats/Json.t.sol index ca53b18012978..0604ef9078f1c 100644 --- a/testdata/default/cheats/Json.t.sol +++ b/testdata/default/cheats/Json.t.sol @@ -5,7 +5,89 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; import "../logs/console.sol"; +library JsonStructs { + address constant HEVM_ADDRESS = address(bytes20(uint160(uint256(keccak256("hevm cheat code"))))); + Vm constant vm = Vm(HEVM_ADDRESS); + + // forge eip712 testdata/default/cheats/Json.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^FlatJson + string constant schema_FlatJson = + "FlatJson(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + // forge eip712 testdata/default/cheats/Json.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^NestedJson + string constant schema_NestedJson = + "NestedJson(FlatJson[] members,AnotherFlatJson inner,string name)AnotherFlatJson(bytes4 fixedBytes)FlatJson(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + function deserializeFlatJson(string memory json) internal pure returns (ParseJsonTest.FlatJson memory) { + return abi.decode(vm.parseJsonType(json, schema_FlatJson), (ParseJsonTest.FlatJson)); + } + + function deserializeFlatJson(string memory json, string memory path) + internal + pure + returns (ParseJsonTest.FlatJson memory) + { + return abi.decode(vm.parseJsonType(json, path, schema_FlatJson), (ParseJsonTest.FlatJson)); + } + + function deserializeFlatJsonArray(string memory json, string memory path) + internal + pure + returns (ParseJsonTest.FlatJson[] memory) + { + return abi.decode(vm.parseJsonTypeArray(json, path, schema_FlatJson), (ParseJsonTest.FlatJson[])); + } + + function deserializeNestedJson(string memory json) internal pure returns (ParseJsonTest.NestedJson memory) { + return abi.decode(vm.parseJsonType(json, schema_NestedJson), (ParseJsonTest.NestedJson)); + } + + function deserializeNestedJson(string memory json, string memory path) + internal + pure + returns (ParseJsonTest.NestedJson memory) + { + return abi.decode(vm.parseJsonType(json, path, schema_NestedJson), (ParseJsonTest.NestedJson)); + } + + function deserializeNestedJsonArray(string memory json, string memory path) + internal + pure + returns (ParseJsonTest.NestedJson[] memory) + { + return abi.decode(vm.parseJsonType(json, path, schema_NestedJson), (ParseJsonTest.NestedJson[])); + } + + function serialize(ParseJsonTest.FlatJson memory instance) internal pure returns (string memory) { + return vm.serializeJsonType(schema_FlatJson, abi.encode(instance)); + } + + function serialize(ParseJsonTest.NestedJson memory instance) internal pure returns (string memory) { + return vm.serializeJsonType(schema_NestedJson, abi.encode(instance)); + } +} + contract ParseJsonTest is DSTest { + using JsonStructs for *; + + struct FlatJson { + uint256 a; + int24[][] arr; + string str; + bytes b; + address addr; + bytes32 fixedBytes; + } + + struct AnotherFlatJson { + bytes4 fixedBytes; + } + + struct NestedJson { + FlatJson[] members; + AnotherFlatJson inner; + string name; + } + Vm constant vm = Vm(HEVM_ADDRESS); string json; @@ -97,7 +179,7 @@ contract ParseJsonTest is DSTest { } function test_coercionRevert() public { - vm._expectCheatcodeRevert("values at \".nestedObject\" must not be JSON objects"); + vm._expectCheatcodeRevert("expected uint256, found JSON object"); vm.parseJsonUint(json, ".nestedObject"); } @@ -206,6 +288,44 @@ contract ParseJsonTest is DSTest { vm._expectCheatcodeRevert("key \".*\" must return exactly one JSON object"); vm.parseJsonKeys(jsonString, ".*"); } + + // forge eip712 testdata/default/cheats/Json.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^FlatJson + string constant schema_FlatJson = + "FlatJson(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + // forge eip712 testdata/default/cheats/Json.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^NestedJson + string constant schema_NestedJson = + "NestedJson(FlatJson[] members,AnotherFlatJson inner,string name)AnotherFlatJson(bytes4 fixedBytes)FlatJson(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + function test_parseJsonType() public { + string memory readJson = vm.readFile("fixtures/Json/nested_json_struct.json"); + NestedJson memory data = readJson.deserializeNestedJson(); + assertEq(data.members.length, 2); + + FlatJson memory expected = FlatJson({ + a: 200, + arr: new int24[][](0), + str: "some other string", + b: hex"0000000000000000000000000000000000000000", + addr: 0x167D91deaEEE3021161502873d3bcc6291081648, + fixedBytes: 0xed1c7beb1f00feaaaec5636950d6edb25a8d4fedc8deb2711287b64c4d27719d + }); + + assertEq(keccak256(abi.encode(data.members[1])), keccak256(abi.encode(expected))); + assertEq(bytes32(data.inner.fixedBytes), bytes32(bytes4(0x12345678))); + + FlatJson[] memory members = JsonStructs.deserializeFlatJsonArray(readJson, ".members"); + + assertEq(keccak256(abi.encode(members)), keccak256(abi.encode(data.members))); + } + + function test_parseJsonType_roundtrip() public { + string memory readJson = vm.readFile("fixtures/Json/nested_json_struct.json"); + NestedJson memory data = readJson.deserializeNestedJson(); + string memory serialized = data.serialize(); + NestedJson memory deserialized = serialized.deserializeNestedJson(); + assertEq(keccak256(abi.encode(data)), keccak256(abi.encode(deserialized))); + } } contract WriteJsonTest is DSTest { @@ -277,13 +397,13 @@ contract WriteJsonTest is DSTest { // Github issue: https://github.com/foundry-rs/foundry/issues/5745 function test_serializeRootObject() public { string memory serialized = vm.serializeJson(json1, '{"foo": "bar"}'); - assertEq(serialized, '{"foo":"bar"}'); + assertEq(serialized, '{"foo": "bar"}'); serialized = vm.serializeBool(json1, "boolean", true); assertEq(vm.parseJsonString(serialized, ".foo"), "bar"); assertEq(vm.parseJsonBool(serialized, ".boolean"), true); string memory overwritten = vm.serializeJson(json1, '{"value": 123}'); - assertEq(overwritten, '{"value":123}'); + assertEq(overwritten, '{"value": 123}'); } struct simpleJson { diff --git a/testdata/default/cheats/Toml.t.sol b/testdata/default/cheats/Toml.t.sol index 40667743f8d65..a01b29af62cb6 100644 --- a/testdata/default/cheats/Toml.t.sol +++ b/testdata/default/cheats/Toml.t.sol @@ -116,7 +116,7 @@ contract ParseTomlTest is DSTest { } function test_coercionRevert() public { - vm._expectCheatcodeRevert("values at \".nestedObject\" must not be JSON objects"); + vm._expectCheatcodeRevert("expected uint256, found JSON object"); vm.parseTomlUint(toml, ".nestedObject"); } diff --git a/testdata/fixtures/Json/nested_json_struct.json b/testdata/fixtures/Json/nested_json_struct.json new file mode 100644 index 0000000000000..ac6fe7692bb90 --- /dev/null +++ b/testdata/fixtures/Json/nested_json_struct.json @@ -0,0 +1,35 @@ +{ + "members": [ + { + "a": 100, + "arr": [ + [ + 1, + -2, + -5 + ], + [ + 1000, + 2000, + 0 + ] + ], + "str": "some string", + "b": "0x", + "addr": "0x0000000000000000000000000000000000000000", + "fixedBytes": "0x8ae3fc6bd1b150a73ec4afe3ef136fa2f88e9c96131c883c5e4a4714811c1598" + }, + { + "a": 200, + "arr": [], + "str": "some other string", + "b": "0x0000000000000000000000000000000000000000", + "addr": "0x167D91deaEEE3021161502873d3bcc6291081648", + "fixedBytes": "0xed1c7beb1f00feaaaec5636950d6edb25a8d4fedc8deb2711287b64c4d27719d" + } + ], + "inner": { + "fixedBytes": "0x12345678" + }, + "name": "test" +} \ No newline at end of file From 6818c846ad54455721deae0adc10efbf87a0f11f Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:03:06 +0300 Subject: [PATCH 1240/1963] fix(verify-etherscan): continue verification even if errors occur (#8407) * fix(verify-etherscan): continue verification even if errors occur * Apply suggestion Co-authored-by: Matthias Seitz --------- Co-authored-by: Matthias Seitz --- crates/common/src/retry.rs | 32 +++++++++++++++++++++++++++++- crates/script/src/sequence.rs | 16 ++++++++++++--- crates/verify/src/etherscan/mod.rs | 20 +++++++++++-------- 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs index 1f8949aa023ed..7f649c7ed35a4 100644 --- a/crates/common/src/retry.rs +++ b/crates/common/src/retry.rs @@ -1,8 +1,17 @@ //! Retry utilities. -use eyre::{Error, Result}; +use eyre::{Error, Report, Result}; use std::{future::Future, time::Duration}; +/// Error type for Retry. +#[derive(Debug, thiserror::Error)] +pub enum RetryError { + /// Keeps retrying operation. + Retry(E), + /// Stops retrying operation immediately. + Break(E), +} + /// A type that keeps track of attempts. #[derive(Clone, Debug)] pub struct Retry { @@ -51,6 +60,27 @@ impl Retry { } } + /// Runs the given async closure in a loop, retrying if it fails up to the specified number of + /// times or immediately returning an error if the closure returned [`RetryError::Break`]. + pub async fn run_async_until_break(mut self, mut callback: F) -> Result + where + F: FnMut() -> Fut, + Fut: Future>, + { + loop { + match callback().await { + Err(RetryError::Retry(e)) if self.retries > 0 => { + self.handle_err(e); + if let Some(delay) = self.delay { + tokio::time::sleep(delay).await; + } + } + Err(RetryError::Retry(e) | RetryError::Break(e)) => return Err(e), + Ok(t) => return Ok(t), + }; + } + } + fn handle_err(&mut self, err: Error) { self.retries -= 1; warn!("erroneous attempt ({} tries remaining): {}", self.retries, err.root_cause()); diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 70128bdb44fec..5a8e789a60b01 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -6,7 +6,7 @@ use crate::{ use alloy_primitives::{hex, Address, TxHash}; use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; use alloy_serde::WithOtherFields; -use eyre::{ContextCompat, Result, WrapErr}; +use eyre::{eyre, ContextCompat, Result, WrapErr}; use forge_verify::provider::VerificationProviderType; use foundry_cli::utils::{now, Git}; use foundry_common::{fs, shell, SELECTOR_LEN}; @@ -307,9 +307,19 @@ impl ScriptSequence { self.check_unverified(unverifiable_contracts, verify); let num_verifications = future_verifications.len(); - println!("##\nStart verification for ({num_verifications}) contracts",); + let mut num_of_successful_verifications = 0; + println!("##\nStart verification for ({num_verifications}) contracts"); for verification in future_verifications { - verification.await?; + match verification.await { + Ok(_) => { + num_of_successful_verifications += 1; + } + Err(err) => eprintln!("Error during verification: {err:#}"), + } + } + + if num_of_successful_verifications < num_verifications { + return Err(eyre!("Not all ({num_of_successful_verifications} / {num_verifications}) contracts were verified!")) } println!("All ({num_verifications}) contracts were verified!"); diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 3c5722f428adc..6fd6ffb7e3bbe 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -11,7 +11,11 @@ use foundry_block_explorers::{ Client, }; use foundry_cli::utils::{self, read_constructor_args_file, LoadConfig}; -use foundry_common::{abi::encode_function_args, retry::Retry, shell}; +use foundry_common::{ + abi::encode_function_args, + retry::{Retry, RetryError}, + shell, +}; use foundry_compilers::{artifacts::BytecodeObject, Artifact}; use foundry_config::{Chain, Config}; use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; @@ -150,12 +154,13 @@ impl VerificationProvider for EtherscanVerificationProvider { )?; let retry: Retry = args.retry.into(); retry - .run_async(|| { + .run_async_until_break(|| { async { let resp = etherscan .check_contract_verification_status(args.id.clone()) .await - .wrap_err("Failed to request verification status")?; + .wrap_err("Failed to request verification status") + .map_err(RetryError::Retry)?; trace!(target: "forge::verify", ?resp, "Received verification response"); @@ -165,11 +170,11 @@ impl VerificationProvider for EtherscanVerificationProvider { ); if resp.result == "Pending in queue" { - return Err(eyre!("Verification is still pending...",)) + return Err(RetryError::Retry(eyre!("Verification is still pending...",))) } if resp.result == "Unable to verify" { - return Err(eyre!("Unable to verify.",)) + return Err(RetryError::Retry(eyre!("Unable to verify.",))) } if resp.result == "Already Verified" { @@ -178,8 +183,7 @@ impl VerificationProvider for EtherscanVerificationProvider { } if resp.status == "0" { - println!("Contract failed to verify."); - std::process::exit(1); + return Err(RetryError::Break(eyre!("Contract failed to verify.",))) } if resp.result == "Pass - Verified" { @@ -191,7 +195,7 @@ impl VerificationProvider for EtherscanVerificationProvider { .boxed() }) .await - .wrap_err("Checking verification result failed:") + .wrap_err("Checking verification result failed") } } From 6bb5c8ea8dcd00ccbc1811f1175cabed3cb4c116 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 11 Jul 2024 20:20:33 +0400 Subject: [PATCH 1241/1963] feat: identify internal function invocations in traces (#8222) * fix: small debugger updates * [wip] feat: identify internal function invocations in traces * fmt * doc * correctly enable tracing * correctly enable tracing * collect contract definition locs * feat: print traces in format of Contract::function * wip * refactor * clippy * fix doc * track input/output values * clippy * clean up * TraceMode * small fixes * add doc * clippy * safer decofing from stack and memory * use Into> * TraceMode::None * fmt * review fixes * --decode-internal for single fn * use Vec * TraceMode builder * optional --decode-internal and tests * update doc * InternalTraceMode --- Cargo.lock | 6 +- crates/cast/bin/cmd/call.rs | 8 +- crates/cast/bin/cmd/run.rs | 9 +- crates/chisel/src/executor.rs | 4 +- crates/cli/src/utils/cmd.rs | 11 + crates/common/Cargo.toml | 1 - crates/common/src/compile.rs | 138 +------- crates/common/src/contracts.rs | 3 - crates/debugger/Cargo.toml | 1 - crates/debugger/src/tui/builder.rs | 4 +- crates/debugger/src/tui/draw.rs | 100 ++---- crates/debugger/src/tui/mod.rs | 22 +- crates/evm/core/src/ic.rs | 1 + .../evm/evm/src/executors/invariant/replay.rs | 4 +- crates/evm/evm/src/executors/mod.rs | 6 +- crates/evm/evm/src/executors/trace.rs | 10 +- crates/evm/evm/src/inspectors/stack.rs | 47 +-- crates/evm/traces/Cargo.toml | 4 + crates/evm/traces/src/debug/mod.rs | 324 ++++++++++++++++++ crates/evm/traces/src/debug/sources.rs | 288 ++++++++++++++++ crates/evm/traces/src/decoder/mod.rs | 21 +- crates/evm/traces/src/identifier/etherscan.rs | 5 +- crates/evm/traces/src/lib.rs | 113 ++++++ crates/forge/bin/cmd/coverage.rs | 3 +- crates/forge/bin/cmd/test/mod.rs | 86 ++++- crates/forge/src/multi_runner.rs | 29 +- crates/forge/src/runner.rs | 8 +- crates/forge/tests/cli/test_cmd.rs | 121 ++++++- crates/script/src/build.rs | 6 +- crates/script/src/lib.rs | 7 +- crates/verify/src/bytecode.rs | 2 +- 31 files changed, 1075 insertions(+), 317 deletions(-) create mode 100644 crates/evm/traces/src/debug/mod.rs create mode 100644 crates/evm/traces/src/debug/sources.rs diff --git a/Cargo.lock b/Cargo.lock index 56af557d64da8..6790a61d01563 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3656,7 +3656,6 @@ dependencies = [ "foundry-common-fmt", "foundry-compilers", "foundry-config", - "foundry-linking", "foundry-macros", "num-format", "once_cell", @@ -3845,7 +3844,6 @@ dependencies = [ "eyre", "foundry-common", "foundry-compilers", - "foundry-evm-core", "foundry-evm-traces", "ratatui", "revm", @@ -3985,12 +3983,16 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm-core", + "foundry-linking", "futures", "itertools 0.13.0", "once_cell", + "rayon", + "revm", "revm-inspectors", "rustc-hash 2.0.0", "serde", + "solang-parser", "tempfile", "tokio", "tracing", diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index a6d3d793dc8ef..d6025fe9ca3e5 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -43,6 +43,9 @@ pub struct CallArgs { #[arg(long, requires = "trace")] debug: bool, + #[arg(long, requires = "trace")] + decode_internal: bool, + /// Labels to apply to the traces; format: `address:label`. /// Can only be used with `--trace`. #[arg(long, requires = "trace")] @@ -106,6 +109,7 @@ impl CallArgs { trace, evm_version, debug, + decode_internal, labels, data, } = self; @@ -159,7 +163,7 @@ impl CallArgs { } let (env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; - let mut executor = TracingExecutor::new(env, fork, evm_version, debug); + let mut executor = TracingExecutor::new(env, fork, evm_version, debug, decode_internal); let value = tx.value.unwrap_or_default(); let input = tx.inner.input.into_input().unwrap_or_default(); @@ -175,7 +179,7 @@ impl CallArgs { ), }; - handle_traces(trace, &config, chain, labels, debug).await?; + handle_traces(trace, &config, chain, labels, debug, decode_internal).await?; return Ok(()); } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index c830f5ab1aa4d..b7f31cfc75141 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -27,6 +27,10 @@ pub struct RunArgs { #[arg(long, short)] debug: bool, + /// Whether to identify internal functions in traces. + #[arg(long)] + decode_internal: bool, + /// Print out opcode traces. #[arg(long, short)] trace_printer: bool, @@ -142,7 +146,8 @@ impl RunArgs { } } - let mut executor = TracingExecutor::new(env.clone(), fork, evm_version, self.debug); + let mut executor = + TracingExecutor::new(env.clone(), fork, evm_version, self.debug, self.decode_internal); let mut env = EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), executor.spec_id()); @@ -220,7 +225,7 @@ impl RunArgs { } }; - handle_traces(result, &config, chain, self.label, self.debug).await?; + handle_traces(result, &config, chain, self.label, self.debug, self.decode_internal).await?; Ok(()) } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 268e4b20955f9..a0b9fc391e9b9 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -13,7 +13,7 @@ use eyre::{Result, WrapErr}; use foundry_compilers::Artifact; use foundry_evm::{ backend::Backend, decode::decode_console_logs, executors::ExecutorBuilder, - inspectors::CheatsConfig, + inspectors::CheatsConfig, traces::TraceMode, }; use solang_parser::pt::{self, CodeLocation}; use std::str::FromStr; @@ -302,7 +302,7 @@ impl SessionSource { // Build a new executor let executor = ExecutorBuilder::new() .inspectors(|stack| { - stack.chisel_state(final_pc).trace(true).cheatcodes( + stack.chisel_state(final_pc).trace_mode(TraceMode::Call).cheatcodes( CheatsConfig::new( &self.config.foundry_config, self.config.evm_opts.clone(), diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 7b6bd70e2b51c..3b5d2bdf80461 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -14,6 +14,7 @@ use foundry_evm::{ executors::{DeployResult, EvmError, RawCallResult}, opts::EvmOpts, traces::{ + debug::DebugTraceIdentifier, decode_trace_arena, identifier::{EtherscanIdentifier, SignaturesIdentifier}, render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, @@ -351,6 +352,7 @@ pub async fn handle_traces( chain: Option, labels: Vec, debug: bool, + decode_internal: bool, ) -> Result<()> { let labels = labels.iter().filter_map(|label_str| { let mut iter = label_str.split(':'); @@ -378,6 +380,15 @@ pub async fn handle_traces( } } + if decode_internal { + let sources = if let Some(etherscan_identifier) = ðerscan_identifier { + etherscan_identifier.get_compiled_contracts().await? + } else { + Default::default() + }; + decoder.debug_identifier = Some(DebugTraceIdentifier::new(sources)); + } + if debug { let sources = if let Some(etherscan_identifier) = etherscan_identifier { etherscan_identifier.get_compiled_contracts().await? diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 3865453e6f3fd..b9c872c652cfc 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -17,7 +17,6 @@ foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } foundry-common-fmt.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true -foundry-linking.workspace = true alloy-contract.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 72b94fcd706e6..116a00b62225e 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,28 +1,24 @@ //! Support for compiling [foundry_compilers::Project] -use crate::{compact_to_contract, term::SpinnerReporter, TestFunctionExt}; +use crate::{term::SpinnerReporter, TestFunctionExt}; use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, Table}; -use eyre::{Context, Result}; +use eyre::Result; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ - artifacts::{remappings::Remapping, BytecodeObject, ContractBytecodeSome, Libraries, Source}, + artifacts::{remappings::Remapping, BytecodeObject, Source}, compilers::{ - multi::MultiCompilerLanguage, solc::{Solc, SolcCompiler}, Compiler, }, report::{BasicStdoutReporter, NoReporter, Report}, Artifact, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, SolcConfig, }; -use foundry_linking::Linker; use num_format::{Locale, ToFormattedString}; -use rustc_hash::FxHashMap; use std::{ - collections::{BTreeMap, HashMap}, + collections::BTreeMap, fmt::Display, io::IsTerminal, path::{Path, PathBuf}, - sync::Arc, time::Instant, }; @@ -261,130 +257,6 @@ impl ProjectCompiler { } } -#[derive(Clone, Debug)] -pub struct SourceData { - pub source: Arc, - pub language: MultiCompilerLanguage, - pub name: String, -} - -#[derive(Clone, Debug)] -pub struct ArtifactData { - pub bytecode: ContractBytecodeSome, - pub build_id: String, - pub file_id: u32, -} - -/// Contract source code and bytecode data used for debugger. -#[derive(Clone, Debug, Default)] -pub struct ContractSources { - /// Map over build_id -> file_id -> (source code, language) - pub sources_by_id: HashMap>, - /// Map over contract name -> Vec<(bytecode, build_id, file_id)> - pub artifacts_by_name: HashMap>, -} - -impl ContractSources { - /// Collects the contract sources and artifacts from the project compile output. - pub fn from_project_output( - output: &ProjectCompileOutput, - root: impl AsRef, - libraries: Option<&Libraries>, - ) -> Result { - let mut sources = Self::default(); - sources.insert(output, root, libraries)?; - Ok(sources) - } - - pub fn insert( - &mut self, - output: &ProjectCompileOutput, - root: impl AsRef, - libraries: Option<&Libraries>, - ) -> Result<()> - where - C::Language: Into, - { - let root = root.as_ref(); - let link_data = libraries.map(|libraries| { - let linker = Linker::new(root, output.artifact_ids().collect()); - (linker, libraries) - }); - - for (id, artifact) in output.artifact_ids() { - if let Some(file_id) = artifact.id { - let artifact = if let Some((linker, libraries)) = link_data.as_ref() { - linker.link(&id, libraries)?.into_contract_bytecode() - } else { - artifact.clone().into_contract_bytecode() - }; - let bytecode = compact_to_contract(artifact.clone().into_contract_bytecode())?; - - self.artifacts_by_name.entry(id.name.clone()).or_default().push(ArtifactData { - bytecode, - build_id: id.build_id.clone(), - file_id, - }); - } else { - warn!(id = id.identifier(), "source not found"); - } - } - - // Not all source files produce artifacts, so we are populating sources by using build - // infos. - let mut files: BTreeMap> = BTreeMap::new(); - for (build_id, build) in output.builds() { - for (source_id, path) in &build.source_id_to_path { - let source_code = if let Some(source) = files.get(path) { - source.clone() - } else { - let source = Source::read(path).wrap_err_with(|| { - format!("failed to read artifact source file for `{}`", path.display()) - })?; - files.insert(path.clone(), source.content.clone()); - source.content - }; - - self.sources_by_id.entry(build_id.clone()).or_default().insert( - *source_id, - SourceData { - source: source_code, - language: build.language.into(), - name: path.strip_prefix(root).unwrap_or(path).to_string_lossy().to_string(), - }, - ); - } - } - - Ok(()) - } - - /// Returns all sources for a contract by name. - pub fn get_sources( - &self, - name: &str, - ) -> Option> { - self.artifacts_by_name.get(name).map(|artifacts| { - artifacts.iter().filter_map(|artifact| { - let source = - self.sources_by_id.get(artifact.build_id.as_str())?.get(&artifact.file_id)?; - Some((artifact, source)) - }) - }) - } - - /// Returns all (name, bytecode, source) sets. - pub fn entries(&self) -> impl Iterator { - self.artifacts_by_name.iter().flat_map(|(name, artifacts)| { - artifacts.iter().filter_map(|artifact| { - let source = - self.sources_by_id.get(artifact.build_id.as_str())?.get(&artifact.file_id)?; - Some((name.as_str(), artifact, source)) - }) - }) - } -} - // https://eips.ethereum.org/EIPS/eip-170 const CONTRACT_SIZE_LIMIT: usize = 24576; @@ -501,7 +373,7 @@ pub fn etherscan_project( let sources_path = target_path.join(&metadata.contract_name); metadata.source_tree().write_to(&target_path)?; - let mut settings = metadata.source_code.settings()?.unwrap_or_default(); + let mut settings = metadata.settings()?; // make remappings absolute with our root for remapping in settings.remappings.iter_mut() { diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index f56ee9b7a8f0d..7e07f9db64712 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -88,9 +88,6 @@ pub struct ContractsByArtifact(Arc>); impl ContractsByArtifact { /// Creates a new instance by collecting all artifacts with present bytecode from an iterator. - /// - /// It is recommended to use this method with an output of - /// [foundry_linking::Linker::get_linked_artifacts]. pub fn new(artifacts: impl IntoIterator) -> Self { let map = artifacts .into_iter() diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index 094f2aa1fb6b7..9f96eb7f06dae 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -15,7 +15,6 @@ workspace = true [dependencies] foundry-common.workspace = true foundry-compilers.workspace = true -foundry-evm-core.workspace = true foundry-evm-traces.workspace = true revm-inspectors.workspace = true diff --git a/crates/debugger/src/tui/builder.rs b/crates/debugger/src/tui/builder.rs index 70055243ea38a..81632dcca6480 100644 --- a/crates/debugger/src/tui/builder.rs +++ b/crates/debugger/src/tui/builder.rs @@ -2,8 +2,8 @@ use crate::{node::flatten_call_trace, DebugNode, Debugger}; use alloy_primitives::Address; -use foundry_common::{compile::ContractSources, evm::Breakpoints, get_contract_name}; -use foundry_evm_traces::{CallTraceArena, CallTraceDecoder, Traces}; +use foundry_common::{evm::Breakpoints, get_contract_name}; +use foundry_evm_traces::{debug::ContractSources, CallTraceArena, CallTraceDecoder, Traces}; use std::collections::HashMap; /// Debugger builder. diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 3d22bf30528a4..6ee71dd6dbedf 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -3,9 +3,8 @@ use super::context::{BufferKind, DebuggerContext}; use crate::op::OpcodeParam; use alloy_primitives::U256; -use foundry_compilers::{ - artifacts::sourcemap::SourceElement, compilers::multi::MultiCompilerLanguage, -}; +use foundry_compilers::artifacts::sourcemap::SourceElement; +use foundry_evm_traces::debug::SourceData; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, @@ -213,7 +212,7 @@ impl DebuggerContext<'_> { } fn src_text(&self, area: Rect) -> (Text<'_>, Option<&str>) { - let (source_element, source_code, source_file) = match self.src_map() { + let (source_element, source) = match self.src_map() { Ok(r) => r, Err(e) => return (Text::from(e), None), }; @@ -224,15 +223,16 @@ impl DebuggerContext<'_> { // minus `sum(push_bytes[..pc])`. let offset = source_element.offset() as usize; let len = source_element.length() as usize; - let max = source_code.len(); + let max = source.source.len(); // Split source into before, relevant, and after chunks, split by line, for formatting. let actual_start = offset.min(max); let actual_end = (offset + len).min(max); - let mut before: Vec<_> = source_code[..actual_start].split_inclusive('\n').collect(); - let actual: Vec<_> = source_code[actual_start..actual_end].split_inclusive('\n').collect(); - let mut after: VecDeque<_> = source_code[actual_end..].split_inclusive('\n').collect(); + let mut before: Vec<_> = source.source[..actual_start].split_inclusive('\n').collect(); + let actual: Vec<_> = + source.source[actual_start..actual_end].split_inclusive('\n').collect(); + let mut after: VecDeque<_> = source.source[actual_end..].split_inclusive('\n').collect(); let num_lines = before.len() + actual.len() + after.len(); let height = area.height as usize; @@ -279,7 +279,7 @@ impl DebuggerContext<'_> { // Highlighted text: cyan, bold. let h_text = Style::new().fg(Color::Cyan).add_modifier(Modifier::BOLD); - let mut lines = SourceLines::new(decimal_digits(num_lines)); + let mut lines = SourceLines::new(start_line, end_line); // We check if there is other text on the same line before the highlight starts. if let Some(last) = before.pop() { @@ -337,74 +337,24 @@ impl DebuggerContext<'_> { } } - (Text::from(lines.lines), Some(source_file)) + (Text::from(lines.lines), source.path.to_str()) } /// Returns source map, source code and source name of the current line. - fn src_map(&self) -> Result<(SourceElement, &str, &str), String> { + fn src_map(&self) -> Result<(SourceElement, &SourceData), String> { let address = self.address(); let Some(contract_name) = self.debugger.identified_contracts.get(address) else { return Err(format!("Unknown contract at address {address}")); }; - let Some(mut files_source_code) = - self.debugger.contracts_sources.get_sources(contract_name) - else { - return Err(format!("No source map index for contract {contract_name}")); - }; - - let Some((create_map, rt_map)) = self.debugger.pc_ic_maps.get(contract_name) else { - return Err(format!("No PC-IC maps for contract {contract_name}")); - }; - - let is_create = matches!(self.call_kind(), CallKind::Create | CallKind::Create2); - let pc = self.current_step().pc; - let Some((source_element, source_code, source_file)) = - files_source_code.find_map(|(artifact, source)| { - let bytecode = if is_create { - &artifact.bytecode.bytecode - } else { - artifact.bytecode.deployed_bytecode.bytecode.as_ref()? - }; - let source_map = bytecode.source_map()?.expect("failed to parse"); - - let pc_ic_map = if is_create { create_map } else { rt_map }; - let ic = pc_ic_map.get(pc)?; - - // Solc indexes source maps by instruction counter, but Vyper indexes by program - // counter. - let source_element = if matches!(source.language, MultiCompilerLanguage::Solc(_)) { - source_map.get(ic)? - } else { - source_map.get(pc)? - }; - // if the source element has an index, find the sourcemap for that index - let res = source_element - .index() - // if index matches current file_id, return current source code - .and_then(|index| { - (index == artifact.file_id) - .then(|| (source_element.clone(), source.source.as_str(), &source.name)) - }) - .or_else(|| { - // otherwise find the source code for the element's index - self.debugger - .contracts_sources - .sources_by_id - .get(&artifact.build_id)? - .get(&source_element.index()?) - .map(|source| { - (source_element.clone(), source.source.as_str(), &source.name) - }) - }); - - res - }) - else { - return Err(format!("No source map for contract {contract_name}")); - }; - - Ok((source_element, source_code, source_file)) + self.debugger + .contracts_sources + .find_source_mapping( + contract_name, + self.current_step().pc, + self.debug_call().kind.is_any_create(), + ) + .ok_or_else(|| format!("No source map for contract {contract_name}")) } fn draw_op_list(&self, f: &mut Frame<'_>, area: Rect) { @@ -638,12 +588,13 @@ impl DebuggerContext<'_> { /// Wrapper around a list of [`Line`]s that prepends the line number on each new line. struct SourceLines<'a> { lines: Vec>, + start_line: usize, max_line_num: usize, } impl<'a> SourceLines<'a> { - fn new(max_line_num: usize) -> Self { - Self { lines: Vec::new(), max_line_num } + fn new(start_line: usize, end_line: usize) -> Self { + Self { lines: Vec::new(), start_line, max_line_num: decimal_digits(end_line) } } fn push(&mut self, line_number_style: Style, line: &'a str, line_style: Style) { @@ -653,8 +604,11 @@ impl<'a> SourceLines<'a> { fn push_raw(&mut self, line_number_style: Style, spans: &[Span<'a>]) { let mut line_spans = Vec::with_capacity(4); - let line_number = - format!("{number: >width$} ", number = self.lines.len() + 1, width = self.max_line_num); + let line_number = format!( + "{number: >width$} ", + number = self.start_line + self.lines.len() + 1, + width = self.max_line_num + ); line_spans.push(Span::styled(line_number, line_number_style)); // Space between line number and line text. diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index facbd9e69f130..6b522250b8aae 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -7,14 +7,14 @@ use crossterm::{ terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; use eyre::Result; -use foundry_common::{compile::ContractSources, evm::Breakpoints}; -use foundry_evm_core::utils::PcIcMap; +use foundry_common::evm::Breakpoints; +use foundry_evm_traces::debug::ContractSources; use ratatui::{ backend::{Backend, CrosstermBackend}, Terminal, }; use std::{ - collections::{BTreeMap, HashMap}, + collections::HashMap, io, ops::ControlFlow, sync::{mpsc, Arc}, @@ -47,8 +47,6 @@ pub struct Debugger { identified_contracts: HashMap, /// Source map of contract sources contracts_sources: ContractSources, - /// A mapping of source -> (PC -> IC map for deploy code, PC -> IC map for runtime code) - pc_ic_maps: BTreeMap, breakpoints: Breakpoints, } @@ -66,19 +64,7 @@ impl Debugger { contracts_sources: ContractSources, breakpoints: Breakpoints, ) -> Self { - let pc_ic_maps = contracts_sources - .entries() - .filter_map(|(name, artifact, _)| { - Some(( - name.to_owned(), - ( - PcIcMap::new(artifact.bytecode.bytecode.bytes()?), - PcIcMap::new(artifact.bytecode.deployed_bytecode.bytes()?), - ), - )) - }) - .collect(); - Self { debug_arena, identified_contracts, contracts_sources, pc_ic_maps, breakpoints } + Self { debug_arena, identified_contracts, contracts_sources, breakpoints } } /// Starts the debugger TUI. Terminates the current process on failure or user exit. diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index c2792ab87ba4d..acb9cc50e6b34 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -4,6 +4,7 @@ use rustc_hash::FxHashMap; /// Maps from program counter to instruction counter. /// /// Inverse of [`IcPcMap`]. +#[derive(Debug, Clone)] pub struct PcIcMap { pub inner: FxHashMap, } diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 391bf998804b5..9de5bf5317141 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -12,7 +12,7 @@ use foundry_evm_fuzz::{ invariant::{BasicTxDetails, InvariantContract}, BaseCounterExample, }; -use foundry_evm_traces::{load_contracts, TraceKind, Traces}; +use foundry_evm_traces::{load_contracts, TraceKind, TraceMode, Traces}; use indicatif::ProgressBar; use parking_lot::RwLock; use proptest::test_runner::TestError; @@ -34,7 +34,7 @@ pub fn replay_run( ) -> Result> { // We want traces for a failed case. if executor.inspector().tracer.is_none() { - executor.set_tracing(true, false); + executor.set_tracing(TraceMode::Call); } let mut counterexample_sequence = vec![]; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 32403dceb51f8..16e760375129e 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -23,7 +23,7 @@ use foundry_evm_core::{ utils::StateChangeset, }; use foundry_evm_coverage::HitMaps; -use foundry_evm_traces::CallTraceArena; +use foundry_evm_traces::{CallTraceArena, TraceMode}; use revm::{ db::{DatabaseCommit, DatabaseRef}, interpreter::{return_ok, InstructionResult}, @@ -214,8 +214,8 @@ impl Executor { } #[inline] - pub fn set_tracing(&mut self, tracing: bool, debug: bool) -> &mut Self { - self.inspector_mut().tracing(tracing, debug); + pub fn set_tracing(&mut self, mode: TraceMode) -> &mut Self { + self.inspector_mut().tracing(mode); self } diff --git a/crates/evm/evm/src/executors/trace.rs b/crates/evm/evm/src/executors/trace.rs index 08c5d92ef5b2f..cc3e687766f8f 100644 --- a/crates/evm/evm/src/executors/trace.rs +++ b/crates/evm/evm/src/executors/trace.rs @@ -2,6 +2,7 @@ use crate::executors::{Executor, ExecutorBuilder}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{utils::evm_spec_id, Chain, Config}; use foundry_evm_core::{backend::Backend, fork::CreateFork, opts::EvmOpts}; +use foundry_evm_traces::{InternalTraceMode, TraceMode}; use revm::primitives::{Env, SpecId}; use std::ops::{Deref, DerefMut}; @@ -16,13 +17,20 @@ impl TracingExecutor { fork: Option, version: Option, debug: bool, + decode_internal: bool, ) -> Self { let db = Backend::spawn(fork); + let trace_mode = + TraceMode::Call.with_debug(debug).with_decode_internal(if decode_internal { + InternalTraceMode::Full + } else { + InternalTraceMode::None + }); Self { // configures a bare version of the evm executor: no cheatcode inspector is enabled, // tracing will be enabled only for the targeted transaction executor: ExecutorBuilder::new() - .inspectors(|stack| stack.trace(true).debug(debug)) + .inspectors(|stack| stack.trace_mode(trace_mode)) .spec(evm_spec_id(&version.unwrap_or_default())) .build(env, db), } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index adec3d8b98c69..8a2e7468baf31 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -1,6 +1,6 @@ use super::{ Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Fuzzer, LogCollector, - StackSnapshotType, TracingInspector, TracingInspectorConfig, + TracingInspector, }; use alloy_primitives::{Address, Bytes, Log, TxKind, U256}; use foundry_cheatcodes::CheatcodesExecutor; @@ -9,7 +9,7 @@ use foundry_evm_core::{ InspectorExt, }; use foundry_evm_coverage::HitMaps; -use foundry_evm_traces::CallTraceArena; +use foundry_evm_traces::{CallTraceArena, TraceMode}; use revm::{ inspectors::CustomPrintTracer, interpreter::{ @@ -45,9 +45,7 @@ pub struct InspectorStackBuilder { /// The fuzzer inspector and its state, if it exists. pub fuzzer: Option, /// Whether to enable tracing. - pub trace: Option, - /// Whether to enable debug traces. - pub debug: Option, + pub trace_mode: TraceMode, /// Whether logs should be collected. pub logs: Option, /// Whether coverage info should be collected. @@ -118,13 +116,6 @@ impl InspectorStackBuilder { self } - /// Set whether to enable the debugger. - #[inline] - pub fn debug(mut self, yes: bool) -> Self { - self.debug = Some(yes); - self - } - /// Set whether to enable the trace printer. #[inline] pub fn print(mut self, yes: bool) -> Self { @@ -134,8 +125,10 @@ impl InspectorStackBuilder { /// Set whether to enable the tracer. #[inline] - pub fn trace(mut self, yes: bool) -> Self { - self.trace = Some(yes); + pub fn trace_mode(mut self, mode: TraceMode) -> Self { + if self.trace_mode < mode { + self.trace_mode = mode + } self } @@ -154,8 +147,7 @@ impl InspectorStackBuilder { gas_price, cheatcodes, fuzzer, - trace, - debug, + trace_mode, logs, coverage, print, @@ -177,7 +169,7 @@ impl InspectorStackBuilder { stack.collect_coverage(coverage.unwrap_or(false)); stack.collect_logs(logs.unwrap_or(true)); stack.print(print.unwrap_or(false)); - stack.tracing(trace.unwrap_or(false), debug.unwrap_or(false)); + stack.tracing(trace_mode); stack.enable_isolation(enable_isolation); @@ -414,25 +406,12 @@ impl InspectorStack { /// Set whether to enable the tracer. #[inline] - pub fn tracing(&mut self, yes: bool, debug: bool) { - if !yes { + pub fn tracing(&mut self, mode: TraceMode) { + if let Some(config) = mode.into_config() { + *self.tracer.get_or_insert_with(Default::default).config_mut() = config; + } else { self.tracer = None; - return; } - *self.tracer.get_or_insert_with(Default::default).config_mut() = TracingInspectorConfig { - record_steps: debug, - record_memory_snapshots: debug, - record_stack_snapshots: if debug { - StackSnapshotType::Full - } else { - StackSnapshotType::None - }, - record_state_diff: false, - exclude_precompile_calls: false, - record_logs: true, - record_opcodes_filter: None, - record_returndata_snapshots: debug, - }; } /// Collects all the data gathered during inspection into a single struct. diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 25cd93213f1c1..92426806537b3 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -17,6 +17,7 @@ workspace = true foundry-block-explorers.workspace = true foundry-common.workspace = true foundry-compilers.workspace = true +foundry-linking.workspace = true foundry-config.workspace = true foundry-evm-core.workspace = true @@ -40,6 +41,9 @@ tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true rustc-hash.workspace = true tempfile.workspace = true +rayon.workspace = true +solang-parser.workspace = true +revm.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/evm/traces/src/debug/mod.rs b/crates/evm/traces/src/debug/mod.rs new file mode 100644 index 0000000000000..a651a3acc5cb3 --- /dev/null +++ b/crates/evm/traces/src/debug/mod.rs @@ -0,0 +1,324 @@ +mod sources; +use crate::CallTraceNode; +use alloy_dyn_abi::{ + parser::{Parameters, Storage}, + DynSolType, DynSolValue, Specifier, +}; +use alloy_primitives::U256; +use foundry_common::fmt::format_token; +use foundry_compilers::artifacts::sourcemap::{Jump, SourceElement}; +use revm::interpreter::OpCode; +use revm_inspectors::tracing::types::{CallTraceStep, DecodedInternalCall, DecodedTraceStep}; +pub use sources::{ArtifactData, ContractSources, SourceData}; + +#[derive(Clone, Debug)] +pub struct DebugTraceIdentifier { + /// Source map of contract sources + contracts_sources: ContractSources, +} + +impl DebugTraceIdentifier { + pub fn new(contracts_sources: ContractSources) -> Self { + Self { contracts_sources } + } + + /// Identifies internal function invocations in a given [CallTraceNode]. + /// + /// Accepts the node itself and identified name of the contract which node corresponds to. + pub fn identify_node_steps(&self, node: &mut CallTraceNode, contract_name: &str) { + DebugStepsWalker::new(node, &self.contracts_sources, contract_name).walk(); + } +} + +/// Walks through the [CallTraceStep]s attempting to match JUMPs to internal functions. +/// +/// This is done by looking up jump kinds in the source maps. The structure of internal function +/// call always looks like this: +/// - JUMP +/// - JUMPDEST +/// ... function steps ... +/// - JUMP +/// - JUMPDEST +/// +/// The assumption we rely on is that first JUMP into function will be marked as [Jump::In] in +/// source map, and second JUMP out of the function will be marked as [Jump::Out]. +/// +/// Also, we rely on JUMPDEST after first JUMP pointing to the source location of the body of +/// function which was entered. We pass this source part to [parse_function_from_loc] to extract the +/// function name. +/// +/// When we find a [Jump::In] and identify the function name, we push it to the stack. +/// +/// When we find a [Jump::Out] we try to find a matching [Jump::In] in the stack. A match is found +/// when source location of the JUMP-in matches the source location of final JUMPDEST (this would be +/// the location of the function invocation), or when source location of first JUMODEST matches the +/// source location of the JUMP-out (this would be the location of function body). +/// +/// When a match is found, all items which were pushed after the matched function are removed. There +/// is a lot of such items due to source maps getting malformed during optimization. +struct DebugStepsWalker<'a> { + node: &'a mut CallTraceNode, + current_step: usize, + stack: Vec<(String, usize)>, + sources: &'a ContractSources, + contract_name: &'a str, +} + +impl<'a> DebugStepsWalker<'a> { + pub fn new( + node: &'a mut CallTraceNode, + sources: &'a ContractSources, + contract_name: &'a str, + ) -> Self { + Self { node, current_step: 0, stack: Vec::new(), sources, contract_name } + } + + fn current_step(&self) -> &CallTraceStep { + &self.node.trace.steps[self.current_step] + } + + fn src_map(&self, step: usize) -> Option<(SourceElement, &SourceData)> { + self.sources.find_source_mapping( + self.contract_name, + self.node.trace.steps[step].pc, + self.node.trace.kind.is_any_create(), + ) + } + + fn prev_src_map(&self) -> Option<(SourceElement, &SourceData)> { + if self.current_step == 0 { + return None; + } + + self.src_map(self.current_step - 1) + } + + fn current_src_map(&self) -> Option<(SourceElement, &SourceData)> { + self.src_map(self.current_step) + } + + fn is_same_loc(&self, step: usize, other: usize) -> bool { + let Some((loc, _)) = self.src_map(step) else { + return false; + }; + let Some((other_loc, _)) = self.src_map(other) else { + return false; + }; + + loc.offset() == other_loc.offset() && + loc.length() == other_loc.length() && + loc.index() == other_loc.index() + } + + /// Invoked when current step is a JUMPDEST preceeded by a JUMP marked as [Jump::In]. + fn jump_in(&mut self) { + // This usually means that this is a jump into the external function which is an + // entrypoint for the current frame. We don't want to include this to avoid + // duplicating traces. + if self.is_same_loc(self.current_step, self.current_step - 1) { + return; + } + + let Some((source_element, source)) = self.current_src_map() else { + return; + }; + + if let Some(name) = parse_function_from_loc(source, &source_element) { + self.stack.push((name, self.current_step - 1)); + } + } + + /// Invoked when current step is a JUMPDEST preceeded by a JUMP marked as [Jump::Out]. + fn jump_out(&mut self) { + let Some((i, _)) = self.stack.iter().enumerate().rfind(|(_, (_, step_idx))| { + self.is_same_loc(*step_idx, self.current_step) || + self.is_same_loc(step_idx + 1, self.current_step - 1) + }) else { + return + }; + // We've found a match, remove all records between start and end, those + // are considered invalid. + let (func_name, start_idx) = self.stack.split_off(i).swap_remove(0); + + // Try to decode function inputs and outputs from the stack and memory. + let (inputs, outputs) = self + .src_map(start_idx + 1) + .map(|(source_element, source)| { + let start = source_element.offset() as usize; + let end = start + source_element.length() as usize; + let fn_definition = source.source[start..end].replace('\n', ""); + let (inputs, outputs) = parse_types(&fn_definition); + + ( + inputs.and_then(|t| { + try_decode_args_from_step(&t, &self.node.trace.steps[start_idx + 1]) + }), + outputs.and_then(|t| try_decode_args_from_step(&t, self.current_step())), + ) + }) + .unwrap_or_default(); + + self.node.trace.steps[start_idx].decoded = Some(DecodedTraceStep::InternalCall( + DecodedInternalCall { func_name, args: inputs, return_data: outputs }, + self.current_step, + )); + } + + fn process(&mut self) { + // We are only interested in JUMPs. + if self.current_step().op != OpCode::JUMP && self.current_step().op != OpCode::JUMPDEST { + return; + } + + let Some((prev_source_element, _)) = self.prev_src_map() else { + return; + }; + + match prev_source_element.jump() { + Jump::In => self.jump_in(), + Jump::Out => self.jump_out(), + _ => {} + }; + } + + fn step(&mut self) { + self.process(); + self.current_step += 1; + } + + pub fn walk(mut self) { + while self.current_step < self.node.trace.steps.len() { + self.step(); + } + } +} + +/// Tries to parse the function name from the source code and detect the contract name which +/// contains the given function. +/// +/// Returns string in the format `Contract::function`. +fn parse_function_from_loc(source: &SourceData, loc: &SourceElement) -> Option { + let start = loc.offset() as usize; + let end = start + loc.length() as usize; + let source_part = &source.source[start..end]; + if !source_part.starts_with("function") { + return None; + } + let function_name = source_part.split_once("function")?.1.split('(').next()?.trim(); + let contract_name = source.find_contract_name(start, end)?; + + Some(format!("{contract_name}::{function_name}")) +} + +/// Parses function input and output types into [Parameters]. +fn parse_types(source: &str) -> (Option>, Option>) { + let inputs = source.find('(').and_then(|params_start| { + let params_end = params_start + source[params_start..].find(')')?; + Parameters::parse(&source[params_start..params_end + 1]).ok() + }); + let outputs = source.find("returns").and_then(|returns_start| { + let return_params_start = returns_start + source[returns_start..].find('(')?; + let return_params_end = return_params_start + source[return_params_start..].find(')')?; + Parameters::parse(&source[return_params_start..return_params_end + 1]).ok() + }); + + (inputs, outputs) +} + +/// Given [Parameters] and [CallTraceStep], tries to decode parameters by using stack and memory. +fn try_decode_args_from_step(args: &Parameters<'_>, step: &CallTraceStep) -> Option> { + let params = &args.params; + + if params.is_empty() { + return Some(vec![]); + } + + let types = params.iter().map(|p| p.resolve().ok().map(|t| (t, p.storage))).collect::>(); + + let stack = step.stack.as_ref()?; + + if stack.len() < types.len() { + return None; + } + + let inputs = &stack[stack.len() - types.len()..]; + + let decoded = inputs + .iter() + .zip(types.iter()) + .map(|(input, type_and_storage)| { + type_and_storage + .as_ref() + .and_then(|(type_, storage)| { + match (type_, storage) { + // HACK: alloy parser treats user-defined types as uint8: https://github.com/alloy-rs/core/pull/386 + // + // filter out `uint8` params which are marked as storage or memory as this + // is not possible in Solidity and means that type is user-defined + (DynSolType::Uint(8), Some(Storage::Memory | Storage::Storage)) => None, + (_, Some(Storage::Memory)) => decode_from_memory( + type_, + step.memory.as_ref()?.as_bytes(), + input.try_into().ok()?, + ), + // Read other types from stack + _ => type_.abi_decode(&input.to_be_bytes::<32>()).ok(), + } + }) + .as_ref() + .map(format_token) + .unwrap_or_else(|| "".to_string()) + }) + .collect(); + + Some(decoded) +} + +/// Decodes given [DynSolType] from memory. +fn decode_from_memory(ty: &DynSolType, memory: &[u8], location: usize) -> Option { + let first_word = memory.get(location..location + 32)?; + + match ty { + // For `string` and `bytes` layout is a word with length followed by the data + DynSolType::String | DynSolType::Bytes => { + let length: usize = U256::from_be_slice(first_word).try_into().ok()?; + let data = memory.get(location + 32..location + 32 + length)?; + + match ty { + DynSolType::Bytes => Some(DynSolValue::Bytes(data.to_vec())), + DynSolType::String => { + Some(DynSolValue::String(String::from_utf8_lossy(data).to_string())) + } + _ => unreachable!(), + } + } + // Dynamic arrays are encoded as a word with length followed by words with elements + // Fixed arrays are encoded as words with elements + DynSolType::Array(inner) | DynSolType::FixedArray(inner, _) => { + let (length, start) = match ty { + DynSolType::FixedArray(_, length) => (*length, location), + DynSolType::Array(_) => { + (U256::from_be_slice(first_word).try_into().ok()?, location + 32) + } + _ => unreachable!(), + }; + let mut decoded = Vec::with_capacity(length); + + for i in 0..length { + let offset = start + i * 32; + let location = match inner.as_ref() { + // Arrays of variable length types are arrays of pointers to the values + DynSolType::String | DynSolType::Bytes | DynSolType::Array(_) => { + U256::from_be_slice(memory.get(offset..offset + 32)?).try_into().ok()? + } + _ => offset, + }; + + decoded.push(decode_from_memory(inner, memory, location)?); + } + + Some(DynSolValue::Array(decoded)) + } + _ => ty.abi_decode(first_word).ok(), + } +} diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs new file mode 100644 index 0000000000000..feb87038190bb --- /dev/null +++ b/crates/evm/traces/src/debug/sources.rs @@ -0,0 +1,288 @@ +use eyre::{Context, Result}; +use foundry_common::compact_to_contract; +use foundry_compilers::{ + artifacts::{ + sourcemap::{SourceElement, SourceMap}, + Bytecode, ContractBytecodeSome, Libraries, Source, + }, + multi::MultiCompilerLanguage, + Artifact, Compiler, ProjectCompileOutput, +}; +use foundry_evm_core::utils::PcIcMap; +use foundry_linking::Linker; +use rayon::prelude::*; +use rustc_hash::FxHashMap; +use solang_parser::pt::SourceUnitPart; +use std::{ + collections::{BTreeMap, HashMap}, + path::{Path, PathBuf}, + sync::Arc, +}; + +#[derive(Clone, Debug)] +pub struct SourceData { + pub source: Arc, + pub language: MultiCompilerLanguage, + pub path: PathBuf, + /// Maps contract name to (start, end) of the contract definition in the source code. + /// This is useful for determining which contract contains given function definition. + contract_definitions: Vec<(String, usize, usize)>, +} + +impl SourceData { + pub fn new(source: Arc, language: MultiCompilerLanguage, path: PathBuf) -> Self { + let mut contract_definitions = Vec::new(); + + match language { + MultiCompilerLanguage::Vyper(_) => { + // Vyper contracts have the same name as the file name. + if let Some(name) = path.file_name().map(|s| s.to_string_lossy().to_string()) { + contract_definitions.push((name, 0, source.len())); + } + } + MultiCompilerLanguage::Solc(_) => { + if let Ok((parsed, _)) = solang_parser::parse(&source, 0) { + for item in parsed.0 { + let SourceUnitPart::ContractDefinition(contract) = item else { + continue; + }; + let Some(name) = contract.name else { + continue; + }; + contract_definitions.push(( + name.name, + name.loc.start(), + contract.loc.end(), + )); + } + } + } + } + + Self { source, language, path, contract_definitions } + } + + /// Finds name of contract that contains given loc. + pub fn find_contract_name(&self, start: usize, end: usize) -> Option<&str> { + self.contract_definitions + .iter() + .find(|(_, s, e)| start >= *s && end <= *e) + .map(|(name, _, _)| name.as_str()) + } +} + +#[derive(Clone, Debug)] +pub struct ArtifactData { + pub source_map: Option, + pub source_map_runtime: Option, + pub pc_ic_map: Option, + pub pc_ic_map_runtime: Option, + pub build_id: String, + pub file_id: u32, +} + +impl ArtifactData { + fn new(bytecode: ContractBytecodeSome, build_id: String, file_id: u32) -> Result { + let parse = |b: &Bytecode| { + // Only parse source map if it's not empty. + let source_map = if b.source_map.as_ref().map_or(true, |s| s.is_empty()) { + Ok(None) + } else { + b.source_map().transpose() + }; + + // Only parse bytecode if it's not empty. + let pc_ic_map = if let Some(bytes) = b.bytes() { + (!bytes.is_empty()).then(|| PcIcMap::new(bytes)) + } else { + None + }; + + source_map.map(|source_map| (source_map, pc_ic_map)) + }; + let (source_map, pc_ic_map) = parse(&bytecode.bytecode)?; + let (source_map_runtime, pc_ic_map_runtime) = bytecode + .deployed_bytecode + .bytecode + .map(|b| parse(&b)) + .unwrap_or_else(|| Ok((None, None)))?; + + Ok(Self { source_map, source_map_runtime, pc_ic_map, pc_ic_map_runtime, build_id, file_id }) + } +} + +/// Container with artifacts data useful for identifying individual execution steps. +#[derive(Clone, Debug, Default)] +pub struct ContractSources { + /// Map over build_id -> file_id -> (source code, language) + pub sources_by_id: HashMap>>, + /// Map over contract name -> Vec<(bytecode, build_id, file_id)> + pub artifacts_by_name: HashMap>, +} + +impl ContractSources { + /// Collects the contract sources and artifacts from the project compile output. + pub fn from_project_output( + output: &ProjectCompileOutput, + root: impl AsRef, + libraries: Option<&Libraries>, + ) -> Result { + let mut sources = Self::default(); + sources.insert(output, root, libraries)?; + Ok(sources) + } + + pub fn insert( + &mut self, + output: &ProjectCompileOutput, + root: impl AsRef, + libraries: Option<&Libraries>, + ) -> Result<()> + where + C::Language: Into, + { + let root = root.as_ref(); + let link_data = libraries.map(|libraries| { + let linker = Linker::new(root, output.artifact_ids().collect()); + (linker, libraries) + }); + + let artifacts: Vec<_> = output + .artifact_ids() + .collect::>() + .par_iter() + .map(|(id, artifact)| { + let mut artifacts = Vec::new(); + if let Some(file_id) = artifact.id { + let artifact = if let Some((linker, libraries)) = link_data.as_ref() { + linker.link(id, libraries)?.into_contract_bytecode() + } else { + (*artifact).clone().into_contract_bytecode() + }; + let bytecode = compact_to_contract(artifact.into_contract_bytecode())?; + + artifacts.push(( + id.name.clone(), + ArtifactData::new(bytecode, id.build_id.clone(), file_id)?, + )); + } else { + warn!(id = id.identifier(), "source not found"); + }; + + Ok(artifacts) + }) + .collect::>>()? + .into_iter() + .flatten() + .collect(); + + for (name, artifact) in artifacts { + self.artifacts_by_name.entry(name).or_default().push(artifact); + } + + // Not all source files produce artifacts, so we are populating sources by using build + // infos. + let mut files: BTreeMap> = BTreeMap::new(); + for (build_id, build) in output.builds() { + for (source_id, path) in &build.source_id_to_path { + let source_data = if let Some(source_data) = files.get(path) { + source_data.clone() + } else { + let source = Source::read(path).wrap_err_with(|| { + format!("failed to read artifact source file for `{}`", path.display()) + })?; + + let stripped = path.strip_prefix(root).unwrap_or(path).to_path_buf(); + + let source_data = Arc::new(SourceData::new( + source.content.clone(), + build.language.into(), + stripped, + )); + + files.insert(path.clone(), source_data.clone()); + + source_data + }; + + self.sources_by_id + .entry(build_id.clone()) + .or_default() + .insert(*source_id, source_data); + } + } + + Ok(()) + } + + /// Returns all sources for a contract by name. + pub fn get_sources( + &self, + name: &str, + ) -> Option> { + self.artifacts_by_name.get(name).map(|artifacts| { + artifacts.iter().filter_map(|artifact| { + let source = + self.sources_by_id.get(artifact.build_id.as_str())?.get(&artifact.file_id)?; + Some((artifact, source.as_ref())) + }) + }) + } + + /// Returns all (name, bytecode, source) sets. + pub fn entries(&self) -> impl Iterator { + self.artifacts_by_name.iter().flat_map(|(name, artifacts)| { + artifacts.iter().filter_map(|artifact| { + let source = + self.sources_by_id.get(artifact.build_id.as_str())?.get(&artifact.file_id)?; + Some((name.as_str(), artifact, source.as_ref())) + }) + }) + } + + pub fn find_source_mapping( + &self, + contract_name: &str, + pc: usize, + init_code: bool, + ) -> Option<(SourceElement, &SourceData)> { + self.get_sources(contract_name)?.find_map(|(artifact, source)| { + let source_map = if init_code { + artifact.source_map.as_ref() + } else { + artifact.source_map_runtime.as_ref() + }?; + + // Solc indexes source maps by instruction counter, but Vyper indexes by program + // counter. + let source_element = if matches!(source.language, MultiCompilerLanguage::Solc(_)) { + let pc_ic_map = if init_code { + artifact.pc_ic_map.as_ref() + } else { + artifact.pc_ic_map_runtime.as_ref() + }?; + let ic = pc_ic_map.get(pc)?; + + source_map.get(ic)? + } else { + source_map.get(pc)? + }; + // if the source element has an index, find the sourcemap for that index + let res = source_element + .index() + // if index matches current file_id, return current source code + .and_then(|index| { + (index == artifact.file_id).then(|| (source_element.clone(), source)) + }) + .or_else(|| { + // otherwise find the source code for the element's index + self.sources_by_id + .get(&artifact.build_id)? + .get(&source_element.index()?) + .map(|source| (source_element.clone(), source.as_ref())) + }); + + res + }) + } +} diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 513954f07d444..0a64cf5d1b1f8 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -1,4 +1,5 @@ use crate::{ + debug::DebugTraceIdentifier, identifier::{ AddressIdentity, LocalTraceIdentifier, SingleSignaturesIdentifier, TraceIdentifier, }, @@ -8,7 +9,7 @@ use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt use alloy_json_abi::{Error, Event, Function, JsonAbi}; use alloy_primitives::{Address, LogData, Selector, B256}; use foundry_common::{ - abi::get_indexed_event, fmt::format_token, ContractsByArtifact, SELECTOR_LEN, + abi::get_indexed_event, fmt::format_token, get_contract_name, ContractsByArtifact, SELECTOR_LEN, }; use foundry_evm_core::{ abi::{Console, HardhatConsole, Vm, HARDHAT_CONSOLE_SELECTOR_PATCHES}, @@ -88,6 +89,13 @@ impl CallTraceDecoderBuilder { self } + /// Sets the debug identifier for the decoder. + #[inline] + pub fn with_debug_identifier(mut self, identifier: DebugTraceIdentifier) -> Self { + self.decoder.debug_identifier = Some(identifier); + self + } + /// Build the decoder. #[inline] pub fn build(self) -> CallTraceDecoder { @@ -124,6 +132,9 @@ pub struct CallTraceDecoder { pub signature_identifier: Option, /// Verbosity level pub verbosity: u8, + + /// Optional identifier of individual trace steps. + pub debug_identifier: Option, } impl CallTraceDecoder { @@ -196,6 +207,8 @@ impl CallTraceDecoder { signature_identifier: None, verbosity: 0, + + debug_identifier: None, } } @@ -315,6 +328,12 @@ impl CallTraceDecoder { for log in node.logs.iter_mut() { log.decoded = self.decode_event(&log.raw_log).await; } + + if let Some(debug) = self.debug_identifier.as_ref() { + if let Some(identified) = self.contracts.get(&node.trace.address) { + debug.identify_node_steps(node, get_contract_name(identified)) + } + } } } diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 87d7e9c92d83d..4a34b31b36517 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -1,10 +1,11 @@ use super::{AddressIdentity, TraceIdentifier}; +use crate::debug::ContractSources; use alloy_primitives::Address; use foundry_block_explorers::{ contract::{ContractMetadata, Metadata}, errors::EtherscanError, }; -use foundry_common::compile::{etherscan_project, ContractSources}; +use foundry_common::compile::etherscan_project; use foundry_config::{Chain, Config}; use futures::{ future::{join_all, Future}, @@ -85,7 +86,7 @@ impl EtherscanIdentifier { // construct the map for res in outputs { - let (project, output, _) = res?; + let (project, output, _root) = res?; sources.insert(&output, project.root(), None)?; } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 3b53fbafbe970..c098fe4be1609 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -9,6 +9,8 @@ extern crate tracing; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use revm::interpreter::OpCode; +use revm_inspectors::tracing::OpcodeFilter; use serde::{Deserialize, Serialize}; pub use revm_inspectors::tracing::{ @@ -29,6 +31,9 @@ use identifier::{LocalTraceIdentifier, TraceIdentifier}; mod decoder; pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; +pub mod debug; +pub use debug::DebugTraceIdentifier; + pub type Traces = Vec<(TraceKind, CallTraceArena)>; /// Decode a collection of call traces. @@ -102,3 +107,111 @@ pub fn load_contracts<'a>( } contracts } + +/// Different kinds of internal functions tracing. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)] +pub enum InternalTraceMode { + #[default] + None, + /// Traces internal functions without decoding inputs/outputs from memory. + Simple, + /// Same as `Simple`, but also tracks memory snapshots. + Full, +} + +impl From for TraceMode { + fn from(mode: InternalTraceMode) -> Self { + match mode { + InternalTraceMode::None => Self::None, + InternalTraceMode::Simple => Self::JumpSimple, + InternalTraceMode::Full => Self::Jump, + } + } +} + +// Different kinds of traces used by different foundry components. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)] +pub enum TraceMode { + /// Disabled tracing. + #[default] + None, + /// Simple call trace, no steps tracing required. + Call, + /// Call trace with tracing for JUMP and JUMPDEST opcode steps. + /// + /// Used for internal functions identification. Does not track memory snapshots. + JumpSimple, + /// Call trace with tracing for JUMP and JUMPDEST opcode steps. + /// + /// Same as `JumpSimple`, but tracks memory snapshots as well. + Jump, + /// Call trace with complete steps tracing. + /// + /// Used by debugger. + Debug, +} + +impl TraceMode { + pub const fn is_none(self) -> bool { + matches!(self, Self::None) + } + + pub const fn is_call(self) -> bool { + matches!(self, Self::Call) + } + + pub const fn is_jump_simple(self) -> bool { + matches!(self, Self::JumpSimple) + } + + pub const fn is_jump(self) -> bool { + matches!(self, Self::Jump) + } + + pub const fn is_debug(self) -> bool { + matches!(self, Self::Debug) + } + + pub fn with_debug(self, yes: bool) -> Self { + if yes { + std::cmp::max(self, Self::Debug) + } else { + self + } + } + + pub fn with_decode_internal(self, mode: InternalTraceMode) -> Self { + std::cmp::max(self, mode.into()) + } + + pub fn with_verbosity(self, verbosiy: u8) -> Self { + if verbosiy >= 3 { + std::cmp::max(self, Self::Call) + } else { + self + } + } + + pub fn into_config(self) -> Option { + if self.is_none() { + None + } else { + TracingInspectorConfig { + record_steps: self >= Self::JumpSimple, + record_memory_snapshots: self >= Self::Jump, + record_stack_snapshots: if self >= Self::JumpSimple { + StackSnapshotType::Full + } else { + StackSnapshotType::None + }, + record_logs: true, + record_state_diff: false, + record_returndata_snapshots: self.is_debug(), + record_opcodes_filter: (self.is_jump() || self.is_jump_simple()) + .then(|| OpcodeFilter::new().enabled(OpCode::JUMP).enabled(OpCode::JUMPDEST)), + exclude_precompile_calls: false, + } + .into() + } + } +} diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index cf50f7a971d39..c82e24621273f 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -252,7 +252,8 @@ impl CoverageArgs { let known_contracts = runner.known_contracts.clone(); let filter = self.test.filter(&config); - let outcome = self.test.run_tests(runner, config.clone(), verbosity, &filter).await?; + let outcome = + self.test.run_tests(runner, config.clone(), verbosity, &filter, output).await?; outcome.ensure_ok()?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 80c9eadc70ce7..248d676db8de5 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -8,8 +8,10 @@ use forge::{ multi_runner::matches_contract, result::{SuiteResult, TestOutcome, TestStatus}, traces::{ - decode_trace_arena, identifier::SignaturesIdentifier, render_trace_arena, - CallTraceDecoderBuilder, TraceKind, + debug::{ContractSources, DebugTraceIdentifier}, + decode_trace_arena, + identifier::SignaturesIdentifier, + render_trace_arena, CallTraceDecoderBuilder, InternalTraceMode, TraceKind, }, MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, TestOptionsBuilder, }; @@ -17,15 +19,12 @@ use foundry_cli::{ opts::CoreBuildArgs, utils::{self, LoadConfig}, }; -use foundry_common::{ - compile::{ContractSources, ProjectCompiler}, - evm::EvmArgs, - fs, shell, -}; +use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell}; use foundry_compilers::{ artifacts::output_selection::OutputSelection, compilers::{multi::MultiCompilerLanguage, CompilerSettings, Language}, utils::source_files_iter, + ProjectCompileOutput, }; use foundry_config::{ figment, @@ -77,6 +76,20 @@ pub struct TestArgs { #[arg(long, value_name = "TEST_FUNCTION")] debug: Option, + /// Whether to identify internal functions in traces. + /// + /// If no argument is passed to this flag, it will trace internal functions scope and decode + /// stack parameters, but parameters stored in memory (such as bytes or arrays) will not be + /// decoded. + /// + /// To decode memory parameters, you should pass an argument with a test function name, + /// similarly to --debug and --match-test. + /// + /// If more than one test matches your specified criteria, you must add additional filters + /// until only one test is found (see --match-contract and --match-path). + #[arg(long, value_name = "TEST_FUNCTION")] + decode_internal: Option>, + /// Print a gas report. #[arg(long, env = "FORGE_GAS_REPORT")] gas_report: bool, @@ -298,11 +311,25 @@ impl TestArgs { let env = evm_opts.evm_env().await?; + // Choose the internal function tracing mode, if --decode-internal is provided. + let decode_internal = if let Some(maybe_fn) = self.decode_internal.as_ref() { + if maybe_fn.is_some() { + // If function filter is provided, we enable full tracing. + InternalTraceMode::Full + } else { + // If no function filter is provided, we enable simple tracing. + InternalTraceMode::Simple + } + } else { + InternalTraceMode::None + }; + // Prepare the test builder. let should_debug = self.debug.is_some(); let config = Arc::new(config); let runner = MultiContractRunnerBuilder::new(config.clone()) .set_debug(should_debug) + .set_decode_internal(decode_internal) .initial_balance(evm_opts.initial_balance) .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) @@ -311,19 +338,29 @@ impl TestArgs { .enable_isolation(evm_opts.isolate) .build(project_root, &output, env, evm_opts)?; - if let Some(debug_test_pattern) = &self.debug { - let test_pattern = &mut filter.args_mut().test_pattern; - if test_pattern.is_some() { - eyre::bail!( - "Cannot specify both --debug and --match-test. \ - Use --match-contract and --match-path to further limit the search instead." - ); + let mut maybe_override_mt = |flag, maybe_regex: Option<&Regex>| { + if let Some(regex) = maybe_regex { + let test_pattern = &mut filter.args_mut().test_pattern; + if test_pattern.is_some() { + eyre::bail!( + "Cannot specify both --{flag} and --match-test. \ + Use --match-contract and --match-path to further limit the search instead." + ); + } + *test_pattern = Some(regex.clone()); } - *test_pattern = Some(debug_test_pattern.clone()); - } + + Ok(()) + }; + + maybe_override_mt("debug", self.debug.as_ref())?; + maybe_override_mt( + "decode-internal", + self.decode_internal.as_ref().and_then(|v| v.as_ref()), + )?; let libraries = runner.libraries.clone(); - let outcome = self.run_tests(runner, config, verbosity, &filter).await?; + let outcome = self.run_tests(runner, config, verbosity, &filter, &output).await?; if should_debug { // Get first non-empty suite result. We will have only one such entry. @@ -346,9 +383,11 @@ impl TestArgs { ) .sources(sources) .breakpoints(test_result.breakpoints.clone()); + if let Some(decoder) = &outcome.last_run_decoder { builder = builder.decoder(decoder); } + let mut debugger = builder.build(); debugger.try_run()?; } @@ -363,6 +402,7 @@ impl TestArgs { config: Arc, verbosity: u8, filter: &ProjectPathsAwareFilter, + output: &ProjectCompileOutput, ) -> eyre::Result { if self.list { return list(runner, filter, self.json); @@ -371,7 +411,9 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); let num_filtered = runner.matching_test_functions(filter).count(); - if self.debug.is_some() && num_filtered != 1 { + if (self.debug.is_some() || self.decode_internal.as_ref().map_or(false, |v| v.is_some())) && + num_filtered != 1 + { eyre::bail!( "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n\n\ Use --match-contract and --match-path to further limit the search.\n\ @@ -388,6 +430,8 @@ impl TestArgs { let remote_chain_id = runner.evm_opts.get_remote_chain_id().await; let known_contracts = runner.known_contracts.clone(); + let libraries = runner.libraries.clone(); + // Run tests. let (tx, rx) = channel::<(String, SuiteResult)>(); let timer = Instant::now(); @@ -417,6 +461,12 @@ impl TestArgs { config.offline, )?); } + + if self.decode_internal.is_some() { + let sources = + ContractSources::from_project_output(output, &config.root, Some(&libraries))?; + builder = builder.with_debug_identifier(DebugTraceIdentifier::new(sources)); + } let mut decoder = builder.build(); let mut gas_report = self diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 405024277c50b..9ac3069a61d5f 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -13,8 +13,14 @@ use foundry_compilers::{ }; use foundry_config::Config; use foundry_evm::{ - backend::Backend, decode::RevertDecoder, executors::ExecutorBuilder, fork::CreateFork, - inspectors::CheatsConfig, opts::EvmOpts, revm, + backend::Backend, + decode::RevertDecoder, + executors::ExecutorBuilder, + fork::CreateFork, + inspectors::CheatsConfig, + opts::EvmOpts, + revm, + traces::{InternalTraceMode, TraceMode}, }; use foundry_linking::{LinkOutput, Linker}; use rayon::prelude::*; @@ -60,6 +66,8 @@ pub struct MultiContractRunner { pub coverage: bool, /// Whether to collect debug info pub debug: bool, + /// Whether to enable steps tracking in the tracer. + pub decode_internal: InternalTraceMode, /// Settings related to fuzz and/or invariant tests pub test_options: TestOptions, /// Whether to enable call isolation @@ -236,12 +244,16 @@ impl MultiContractRunner { Some(artifact_id.version.clone()), ); + let trace_mode = TraceMode::default() + .with_debug(self.debug) + .with_decode_internal(self.decode_internal) + .with_verbosity(self.evm_opts.verbosity); + let executor = ExecutorBuilder::new() .inspectors(|stack| { stack .cheatcodes(Arc::new(cheats_config)) - .trace(self.evm_opts.verbosity >= 3 || self.debug) - .debug(self.debug) + .trace_mode(trace_mode) .coverage(self.coverage) .enable_isolation(self.isolation) }) @@ -299,6 +311,8 @@ pub struct MultiContractRunnerBuilder { pub coverage: bool, /// Whether or not to collect debug info pub debug: bool, + /// Whether to enable steps tracking in the tracer. + pub decode_internal: InternalTraceMode, /// Whether to enable call isolation pub isolation: bool, /// Settings related to fuzz and/or invariant tests @@ -317,6 +331,7 @@ impl MultiContractRunnerBuilder { debug: Default::default(), isolation: Default::default(), test_options: Default::default(), + decode_internal: Default::default(), } } @@ -355,6 +370,11 @@ impl MultiContractRunnerBuilder { self } + pub fn set_decode_internal(mut self, mode: InternalTraceMode) -> Self { + self.decode_internal = mode; + self + } + pub fn enable_isolation(mut self, enable: bool) -> Self { self.isolation = enable; self @@ -425,6 +445,7 @@ impl MultiContractRunnerBuilder { config: self.config, coverage: self.coverage, debug: self.debug, + decode_internal: self.decode_internal, test_options: self.test_options.unwrap_or_default(), isolation: self.isolation, known_contracts, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 501ae62662acf..2198921be605a 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -31,7 +31,7 @@ use foundry_evm::{ invariant::{CallDetails, InvariantContract}, CounterExample, FuzzFixtures, }, - traces::{load_contracts, TraceKind}, + traces::{load_contracts, TraceKind, TraceMode}, }; use proptest::test_runner::TestRunner; use rayon::prelude::*; @@ -309,8 +309,11 @@ impl<'a> ContractRunner<'a> { // Invariant testing requires tracing to figure out what contracts were created. // We also want to disable `debug` for setup since we won't be using those traces. let has_invariants = self.contract.abi.functions().any(|func| func.is_invariant_test()); + let prev_tracer = self.executor.inspector_mut().tracer.take(); - self.executor.set_tracing(prev_tracer.is_some() || has_invariants, false); + if prev_tracer.is_some() || has_invariants { + self.executor.set_tracing(TraceMode::Call); + } let setup_time = Instant::now(); let setup = self.setup(call_setup); @@ -645,7 +648,6 @@ impl<'a> ContractRunner<'a> { if let Some("SKIPPED") = result.reason.as_deref() { return test_result.single_skip() } - test_result.fuzz_result(result) } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 01db02fddc304..5608cc1c5e124 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -3,7 +3,7 @@ use alloy_primitives::U256; use foundry_config::{Config, FuzzConfig}; use foundry_test_utils::{ - rpc, + rpc, str, util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, }; use std::{path::PathBuf, str::FromStr}; @@ -853,3 +853,122 @@ forgetest_init!(should_not_show_logs_when_fuzz_test_inline_config, |prj, cmd| { let stdout = cmd.stdout_lossy(); assert!(!stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); }); + +// tests internal functions trace +forgetest_init!(internal_functions_trace, |prj, cmd| { + prj.wipe_contracts(); + prj.clear(); + + // Disable optimizer because for simple contract most functions will get inlined. + prj.write_config(Config { optimizer: false, ..Default::default() }); + + prj.add_test( + "Simple", + r#"pragma solidity 0.8.24; + import {Test, console2} from "forge-std/Test.sol"; +contract SimpleContract { + uint256 public num; + address public addr; + + function _setNum(uint256 _num) internal returns(uint256 prev) { + prev = num; + num = _num; + } + + function _setAddr(address _addr) internal returns(address prev) { + prev = addr; + addr = _addr; + } + + function increment() public { + _setNum(num + 1); + } + + function setValues(uint256 _num, address _addr) public { + _setNum(_num); + _setAddr(_addr); + } +} + +contract SimpleContractTest is Test { + function test() public { + SimpleContract c = new SimpleContract(); + c.increment(); + c.setValues(100, address(0x123)); + } +} + "#, + ) + .unwrap(); + cmd.args(["test", "-vvvv", "--decode-internal"]).assert_success().stdout_eq(str![[r#" +... +Traces: + [250463] SimpleContractTest::test() + ├─ [171014] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 854 bytes of code + ├─ [22638] SimpleContract::increment() + │ ├─ [20150] SimpleContract::_setNum(1) + │ │ └─ ← 0 + │ └─ ← [Stop] + ├─ [23219] SimpleContract::setValues(100, 0x0000000000000000000000000000000000000123) + │ ├─ [250] SimpleContract::_setNum(100) + │ │ └─ ← 1 + │ ├─ [22339] SimpleContract::_setAddr(0x0000000000000000000000000000000000000123) + │ │ └─ ← 0x0000000000000000000000000000000000000000 + │ └─ ← [Stop] + └─ ← [Stop] +... +"#]]); +}); + +// tests internal functions trace with memory decoding +forgetest_init!(internal_functions_trace_memory, |prj, cmd| { + prj.wipe_contracts(); + prj.clear(); + + // Disable optimizer because for simple contract most functions will get inlined. + prj.write_config(Config { optimizer: false, ..Default::default() }); + + prj.add_test( + "Simple", + r#"pragma solidity 0.8.24; +import {Test, console2} from "forge-std/Test.sol"; + +contract SimpleContract { + string public str = "initial value"; + + function _setStr(string memory _str) internal returns(string memory prev) { + prev = str; + str = _str; + } + + function setStr(string memory _str) public { + _setStr(_str); + } +} + +contract SimpleContractTest is Test { + function test() public { + SimpleContract c = new SimpleContract(); + c.setStr("new value"); + } +} + "#, + ) + .unwrap(); + cmd.args(["test", "-vvvv", "--decode-internal", "test"]).assert_success().stdout_eq(str![[ + r#" +... +Traces: + [421960] SimpleContractTest::test() + ├─ [385978] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 1814 bytes of code + ├─ [2534] SimpleContract::setStr("new value") + │ ├─ [1600] SimpleContract::_setStr("new value") + │ │ └─ ← "initial value" + │ └─ ← [Stop] + └─ ← [Stop] +... +"# + ]]); +}); diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 48242ca19b027..14feb42ff00e0 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -10,9 +10,7 @@ use alloy_provider::Provider; use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; use foundry_common::{ - compile::{ContractSources, ProjectCompiler}, - provider::try_get_http_provider, - ContractData, ContractsByArtifact, + compile::ProjectCompiler, provider::try_get_http_provider, ContractData, ContractsByArtifact, }; use foundry_compilers::{ artifacts::{BytecodeObject, Libraries}, @@ -21,7 +19,7 @@ use foundry_compilers::{ utils::source_files_iter, ArtifactId, ProjectCompileOutput, }; -use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; +use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::debug::ContractSources}; use foundry_linking::Linker; use std::{path::PathBuf, str::FromStr, sync::Arc}; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index f03e15fa29885..af7000672b3f4 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -43,7 +43,7 @@ use foundry_evm::{ CheatsConfig, }, opts::EvmOpts, - traces::Traces, + traces::{TraceMode, Traces}, }; use foundry_wallets::MultiWalletOpts; use serde::{Deserialize, Serialize}; @@ -574,7 +574,9 @@ impl ScriptConfig { // We need to enable tracing to decode contract names: local or external. let mut builder = ExecutorBuilder::new() - .inspectors(|stack| stack.trace(true)) + .inspectors(|stack| { + stack.trace_mode(if debug { TraceMode::Debug } else { TraceMode::Call }) + }) .spec(self.config.evm_spec_id()) .gas_limit(self.evm_opts.gas_limit()) .legacy_assertions(self.config.legacy_assertions); @@ -582,7 +584,6 @@ impl ScriptConfig { if let Some((known_contracts, script_wallets, target)) = cheats_data { builder = builder.inspectors(|stack| { stack - .debug(debug) .cheatcodes( CheatsConfig::new( &self.config, diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 763219500d351..17bc65734fbfa 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -286,7 +286,7 @@ impl VerifyBytecodeArgs { TracingExecutor::get_fork_material(&fork_config, evm_opts).await?; let mut executor = - TracingExecutor::new(env.clone(), fork, Some(fork_config.evm_version), false); + TracingExecutor::new(env.clone(), fork, Some(fork_config.evm_version), false, false); env.block.number = U256::from(simulation_block); let block = provider.get_block(simulation_block.into(), true.into()).await?; From 309a2f982abf19640b2095145063b70972381ad9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:10:03 +0300 Subject: [PATCH 1242/1963] fix(coverage): treat assert/require as lines instead branch (#8413) * fix(coverage): treat assert/require as lines instead branch * Changes after review: use snapbox assertion * More cov tests ported * Nicer pattern match --- crates/evm/coverage/src/analysis.rs | 32 +------- crates/forge/tests/cli/coverage.rs | 116 +++++++++++++++++----------- 2 files changed, 73 insertions(+), 75 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 48c7d01d60d9f..d499b48825f53 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -294,7 +294,10 @@ impl<'a> ContractVisitor<'a> { // tupleexpression // yulfunctioncall match node.node_type { - NodeType::Assignment | NodeType::UnaryOperation => { + NodeType::Assignment | + NodeType::UnaryOperation | + NodeType::FunctionCall | + NodeType::Conditional => { self.push_item(CoverageItem { kind: CoverageItemKind::Statement, loc: self.source_location_for(&node.src), @@ -322,33 +325,6 @@ impl<'a> ContractVisitor<'a> { Ok(()) } - NodeType::FunctionCall => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); - - let expr: Option = node.attribute("expression"); - if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { - // Might be a require/assert call - let name: Option = expr.and_then(|expr| expr.attribute("name")); - if let Some("assert" | "require") = name.as_deref() { - self.push_branches(&node.src, self.branch_id); - self.branch_id += 1; - } - } - - Ok(()) - } - NodeType::Conditional => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); - Ok(()) - } // Does not count towards coverage NodeType::FunctionCallOptions | NodeType::Identifier | diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 42cd7f60d4c66..cd9777c4c36ff 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1,4 +1,4 @@ -use regex::Regex; +use foundry_test_utils::str; forgetest!(basic_coverage, |_prj, cmd| { cmd.args(["coverage"]); @@ -57,24 +57,15 @@ contract AContractTest is DSTest { ) .unwrap(); - let lcov_info = prj.root().join("lcov.info"); - cmd.arg("coverage").args([ - "--report".to_string(), - "lcov".to_string(), - "--report-file".to_string(), - lcov_info.to_str().unwrap().to_string(), - ]); - cmd.assert_success(); - assert!(lcov_info.exists()); - - let lcov_data = std::fs::read_to_string(lcov_info).unwrap(); - // AContract.init must be hit at least once - let re = Regex::new(r"FNDA:(\d+),AContract\.init").unwrap(); - let valid_line = |line| { - re.captures(line) - .map_or(false, |caps| caps.get(1).unwrap().as_str().parse::().unwrap() > 0) - }; - assert!(lcov_data.lines().any(valid_line), "{lcov_data}"); + // Assert 100% coverage (init function coverage called in setUp is accounted). + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | + +"#]]); }); forgetest!(test_no_match_coverage, |prj, cmd| { @@ -159,32 +150,63 @@ contract BContractTest is DSTest { ) .unwrap(); - let lcov_info = prj.root().join("lcov.info"); - cmd.arg("coverage").args([ - "--no-match-coverage".to_string(), - "AContract".to_string(), // Filter out `AContract` - "--report".to_string(), - "lcov".to_string(), - "--report-file".to_string(), - lcov_info.to_str().unwrap().to_string(), - ]); - cmd.assert_success(); - assert!(lcov_info.exists()); - - let lcov_data = std::fs::read_to_string(lcov_info).unwrap(); - // BContract.init must be hit at least once - let re = Regex::new(r"FNDA:(\d+),BContract\.init").unwrap(); - let valid_line = |line| { - re.captures(line) - .map_or(false, |caps| caps.get(1).unwrap().as_str().parse::().unwrap() > 0) - }; - assert!(lcov_data.lines().any(valid_line), "{lcov_data}"); - - // AContract.init must not be hit - let re = Regex::new(r"FNDA:(\d+),AContract\.init").unwrap(); - let valid_line = |line| { - re.captures(line) - .map_or(false, |caps| caps.get(1).unwrap().as_str().parse::().unwrap() > 0) - }; - assert!(!lcov_data.lines().any(valid_line), "{lcov_data}"); + // Assert AContract is not included in report. + cmd.arg("coverage") + .args([ + "--no-match-coverage".to_string(), + "AContract".to_string(), // Filter out `AContract` + ]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/BContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | + +"#]]); +}); + +forgetest!(test_assert_require_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + function checkA() external pure returns (bool) { + assert(10 > 2); + require(10 > 2, "true"); + return true; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + function testA() external { + AContract a = new AContract(); + bool result = a.checkA(); + assertTrue(result); + } +} + "#, + ) + .unwrap(); + + // Assert 100% coverage (assert and require properly covered). + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (3/3) | 100.00% (3/3) | 100.00% (0/0) | 100.00% (1/1) | +| Total | 100.00% (3/3) | 100.00% (3/3) | 100.00% (0/0) | 100.00% (1/1) | + +"#]]); }); From 1bfbaff7e86e2477fc267a0c0315de63aa026606 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 11 Jul 2024 21:28:28 +0400 Subject: [PATCH 1243/1963] fix(cast): correctly handle legacy chains (#8420) fix: correctly handle legacy chains --- crates/cast/bin/tx.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index b37c743f812ce..9a731187a570d 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -94,6 +94,7 @@ where let chain = utils::get_chain(config.chain, &provider).await?; let etherscan_api_key = config.get_etherscan_api_key(Some(chain)); + let legacy = tx_opts.legacy || chain.is_legacy(); if let Some(gas_limit) = tx_opts.gas_limit { tx.set_gas_limit(gas_limit.to()); @@ -104,14 +105,14 @@ where } if let Some(gas_price) = tx_opts.gas_price { - if tx_opts.legacy { + if legacy { tx.set_gas_price(gas_price.to()); } else { tx.set_max_fee_per_gas(gas_price.to()); } } - if !tx_opts.legacy { + if !legacy { if let Some(priority_fee) = tx_opts.priority_gas_price { tx.set_max_priority_fee_per_gas(priority_fee.to()); } @@ -128,7 +129,7 @@ where Ok(Self { provider, tx, - legacy: tx_opts.legacy || chain.is_legacy(), + legacy, blob: tx_opts.blob, chain, etherscan_api_key, From ef62fdbab638a275fc19a2ff8fe8951c3bd1d9aa Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:36:50 +0300 Subject: [PATCH 1244/1963] fix(evm): always decode EVM reverts (#8419) --- crates/evm/traces/src/decoder/mod.rs | 69 +++++++++++++++------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 0a64cf5d1b1f8..c8d1e461abbe8 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -350,8 +350,7 @@ impl CallTraceDecoder { return DecodedCallTrace { label, call_data: Some(DecodedCallData { signature: "create2".to_string(), args: vec![] }), - return_data: (!trace.status.is_ok()) - .then(|| self.revert_decoder.decode(&trace.output, Some(trace.status))), + return_data: self.default_return_data(trace), }; } @@ -372,7 +371,11 @@ impl CallTraceDecoder { } }; let [func, ..] = &functions[..] else { - return DecodedCallTrace { label, call_data: None, return_data: None }; + return DecodedCallTrace { + label, + call_data: None, + return_data: self.default_return_data(trace), + }; }; DecodedCallTrace { @@ -388,11 +391,7 @@ impl CallTraceDecoder { DecodedCallTrace { label, call_data: Some(DecodedCallData { signature, args }), - return_data: if !trace.success { - Some(self.revert_decoder.decode(&trace.output, Some(trace.status))) - } else { - None - }, + return_data: self.default_return_data(trace), } } } @@ -410,7 +409,7 @@ impl CallTraceDecoder { if args.is_none() { if let Ok(v) = func.abi_decode_input(&trace.data[SELECTOR_LEN..], false) { - args = Some(v.iter().map(|value| self.apply_label(value)).collect()); + args = Some(v.iter().map(|value| self.format_value(value)).collect()); } } } @@ -523,34 +522,32 @@ impl CallTraceDecoder { /// Decodes a function's output into the given trace. fn decode_function_output(&self, trace: &CallTrace, funcs: &[Function]) -> Option { - let data = &trace.output; - if trace.success { - if trace.address == CHEATCODE_ADDRESS { - if let Some(decoded) = - funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)) - { - return Some(decoded); - } - } + if !trace.success { + return self.default_return_data(trace); + } - if let Some(values) = - funcs.iter().find_map(|func| func.abi_decode_output(data, false).ok()) + if trace.address == CHEATCODE_ADDRESS { + if let Some(decoded) = funcs.iter().find_map(|func| self.decode_cheatcode_outputs(func)) { - // Functions coming from an external database do not have any outputs specified, - // and will lead to returning an empty list of values. - if values.is_empty() { - return None; - } + return Some(decoded); + } + } - return Some( - values.iter().map(|value| self.apply_label(value)).format(", ").to_string(), - ); + if let Some(values) = + funcs.iter().find_map(|func| func.abi_decode_output(&trace.output, false).ok()) + { + // Functions coming from an external database do not have any outputs specified, + // and will lead to returning an empty list of values. + if values.is_empty() { + return None; } - None - } else { - Some(self.revert_decoder.decode(data, Some(trace.status))) + return Some( + values.iter().map(|value| self.format_value(value)).format(", ").to_string(), + ); } + + None } /// Custom decoding for cheatcode outputs. @@ -566,6 +563,11 @@ impl CallTraceDecoder { .map(Into::into) } + /// The default decoded return data for a trace. + fn default_return_data(&self, trace: &CallTrace) -> Option { + (!trace.success).then(|| self.revert_decoder.decode(&trace.output, Some(trace.status))) + } + /// Decodes an event. pub async fn decode_event(&self, log: &LogData) -> DecodedCallLog { let &[t0, ..] = log.topics() else { return DecodedCallLog { name: None, params: None } }; @@ -594,7 +596,7 @@ impl CallTraceDecoder { .map(|(param, input)| { // undo patched names let name = input.name.clone(); - (name, self.apply_label(¶m)) + (name, self.format_value(¶m)) }) .collect(), ), @@ -628,7 +630,8 @@ impl CallTraceDecoder { identifier.write().await.identify_functions(funcs_it).await; } - fn apply_label(&self, value: &DynSolValue) -> String { + /// Pretty-prints a value. + fn format_value(&self, value: &DynSolValue) -> String { if let DynSolValue::Address(addr) = value { if let Some(label) = self.labels.get(addr) { return format!("{label}: [{addr}]"); From 5b8416363c7c1aab6d3cda0da6e7c65594ad8a12 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:06:23 +0300 Subject: [PATCH 1245/1963] fix(coverage): lcov avoid double reporting for line hit (#8400) --- crates/forge/src/coverage.rs | 7 ++-- crates/forge/tests/cli/coverage.rs | 63 +++++++++++++++++++++++++++++- crates/test-utils/src/lib.rs | 2 +- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 8b06f3074c3fe..cab9374884356 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -116,10 +116,9 @@ impl<'a> CoverageReporter for LcovReporter<'a> { if hits == 0 { "-".to_string() } else { hits.to_string() } )?; } - // Statements are not in the LCOV format - CoverageItemKind::Statement => { - writeln!(self.destination, "DA:{line},{hits}")?; - } + // Statements are not in the LCOV format. + // We don't add them in order to avoid doubling line hits. + _ => {} } } diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index cd9777c4c36ff..f56bfd43726da 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1,4 +1,4 @@ -use foundry_test_utils::str; +use foundry_test_utils::{assert_data_eq, str}; forgetest!(basic_coverage, |_prj, cmd| { cmd.args(["coverage"]); @@ -210,3 +210,64 @@ contract AContractTest is DSTest { "#]]); }); + +forgetest!(test_line_hit_not_doubled, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + int public i; + + function foo() public { + i = 1; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + function testFoo() public { + AContract a = new AContract(); + a.foo(); + } +} + "#, + ) + .unwrap(); + + let lcov_info = prj.root().join("lcov.info"); + cmd.arg("coverage").args([ + "--report".to_string(), + "lcov".to_string(), + "--report-file".to_string(), + lcov_info.to_str().unwrap().to_string(), + ]); + cmd.assert_success(); + assert!(lcov_info.exists()); + + // We want to make sure DA:8,1 is added only once so line hit is not doubled. + assert_data_eq!( + std::fs::read_to_string(lcov_info).unwrap(), + str![[r#"TN: +SF:src/AContract.sol +FN:7,AContract.foo +FNDA:1,AContract.foo +DA:8,1 +FNF:1 +FNH:1 +LF:1 +LH:1 +BRF:0 +BRH:0 +end[..] +"#]] + ); +}); diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 3782aba7d502e..2a00932789ba5 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -28,7 +28,7 @@ pub use script::{ScriptOutcome, ScriptTester}; // re-exports for convenience pub use foundry_compilers; -pub use snapbox::{file, str}; +pub use snapbox::{assert_data_eq, file, str}; /// Initializes tracing for tests. pub fn init_tracing() { From 758630e0d65486a8d377ac194a4394d81db6fa68 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 12 Jul 2024 18:54:03 +0400 Subject: [PATCH 1246/1963] fix(anvil): return correct data for queries at forked block (#8428) * add test * fix * rm unused --- crates/anvil/src/eth/backend/genesis.rs | 84 ++----------------------- crates/anvil/src/eth/backend/mem/mod.rs | 36 +++-------- crates/anvil/tests/it/fork.rs | 21 +++++++ 3 files changed, 34 insertions(+), 107 deletions(-) diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index ebe6e6f6ef1fa..305f5b892596e 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -1,17 +1,14 @@ //! Genesis settings -use crate::eth::backend::db::{Db, MaybeFullDatabase}; +use crate::eth::backend::db::Db; use alloy_genesis::{Genesis, GenesisAccount}; -use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::{Address, U256}; use foundry_evm::{ - backend::{DatabaseError, DatabaseResult, StateSnapshot}, - revm::{ - db::DatabaseRef, - primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, - }, + backend::DatabaseResult, + revm::primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }; use parking_lot::Mutex; -use std::{collections::HashMap, sync::Arc}; +use std::sync::Arc; use tokio::sync::RwLockWriteGuard; /// Genesis settings @@ -77,75 +74,4 @@ impl GenesisConfig { code, } } - - /// Returns a database wrapper that points to the genesis and is aware of all provided - /// [AccountInfo] - pub(crate) fn state_db_at_genesis<'a>( - &self, - db: Box, - ) -> AtGenesisStateDb<'a> { - AtGenesisStateDb { - genesis: self.genesis_init.clone(), - accounts: self.account_infos().collect(), - db, - } - } -} - -/// A Database implementation that is at the genesis state. -/// -/// This is only used in forking mode where we either need to fetch the state from remote if the -/// account was not provided via custom genesis, which would override anything available from remote -/// starting at the genesis, Note: "genesis" in the context of the Backend means, the block the -/// backend was created, which is `0` in normal mode and `fork block` in forking mode. -pub(crate) struct AtGenesisStateDb<'a> { - genesis: Option, - accounts: HashMap, - db: Box, -} - -impl<'a> DatabaseRef for AtGenesisStateDb<'a> { - type Error = DatabaseError; - fn basic_ref(&self, address: Address) -> DatabaseResult> { - if let Some(acc) = self.accounts.get(&(address)).cloned() { - return Ok(Some(acc)) - } - self.db.basic_ref(address) - } - - fn code_by_hash_ref(&self, code_hash: B256) -> DatabaseResult { - if let Some((_, acc)) = self.accounts.iter().find(|(_, acc)| acc.code_hash == code_hash) { - return Ok(acc.code.clone().unwrap_or_default()) - } - self.db.code_by_hash_ref(code_hash) - } - - fn storage_ref(&self, address: Address, index: U256) -> DatabaseResult { - if let Some(acc) = self.genesis.as_ref().and_then(|genesis| genesis.alloc.get(&(address))) { - if let Some(storage) = acc.storage.as_ref() { - return Ok(U256::from_be_bytes( - storage.get(&B256::from(index)).copied().unwrap_or_default().0, - )) - } - } - self.db.storage_ref(address, index) - } - - fn block_hash_ref(&self, number: U256) -> DatabaseResult { - self.db.block_hash_ref(number) - } -} - -impl<'a> MaybeFullDatabase for AtGenesisStateDb<'a> { - fn clear_into_snapshot(&mut self) -> StateSnapshot { - self.db.clear_into_snapshot() - } - - fn clear(&mut self) { - self.db.clear() - } - - fn init_from_snapshot(&mut self, snapshot: StateSnapshot) { - self.db.init_from_snapshot(snapshot) - } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 9bb431e2e79f9..e157ffac8dcc7 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1788,19 +1788,18 @@ impl Backend { let block_number: U256 = U256::from(self.convert_block_number(block_number)); if block_number < self.env.read().block.number { + if let Some((block_hash, block)) = self + .block_by_number(BlockNumber::Number(block_number.to::())) + .await? + .and_then(|block| Some((block.header.hash?, block))) { - let mut states = self.states.write(); - - if let Some((state, block)) = self - .get_block(block_number.to::()) - .and_then(|block| Some((states.get(&block.header.hash_slow())?, block))) - { + if let Some(state) = self.states.write().get(&block_hash) { let block = BlockEnv { - number: U256::from(block.header.number), - coinbase: block.header.beneficiary, + number: block_number, + coinbase: block.header.miner, timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, - prevrandao: Some(block.header.mix_hash), + prevrandao: block.header.mix_hash, basefee: U256::from(block.header.base_fee_per_gas.unwrap_or_default()), gas_limit: U256::from(block.header.gas_limit), ..Default::default() @@ -1809,25 +1808,6 @@ impl Backend { } } - // there's an edge case in forking mode if the requested `block_number` is __exactly__ - // the forked block, which should be fetched from remote but since we allow genesis - // accounts this may not be accurate data because an account could be provided via - // genesis - // So this provides calls the given provided function `f` with a genesis aware database - if let Some(fork) = self.get_fork() { - if block_number == U256::from(fork.block_number()) { - let mut block = self.env.read().block.clone(); - let db = self.db.read().await; - let gen_db = self.genesis.state_db_at_genesis(Box::new(&*db)); - - block.number = block_number; - block.timestamp = U256::from(fork.timestamp()); - block.basefee = U256::from(fork.base_fee().unwrap_or_default()); - - return Ok(f(Box::new(&gen_db), block)); - } - } - warn!(target: "backend", "Not historic state found for block={}", block_number); return Err(BlockchainError::BlockOutOfRange( self.env.read().block.number.to::(), diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 8559b019cb573..0fe196075ca96 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1280,3 +1280,24 @@ async fn test_immutable_fork_transaction_hash() { assert_eq!(tx.inner.hash.to_string(), expected.0.to_string()); } } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_query_at_fork_block() { + let (api, handle) = spawn(fork_config()).await; + let provider = handle.http_provider(); + let info = api.anvil_node_info().await.unwrap(); + let number = info.fork_config.fork_block_number.unwrap(); + assert_eq!(number, BLOCK_NUMBER); + + let address = Address::random(); + + let balance = provider.get_balance(address).await.unwrap(); + api.evm_mine(None).await.unwrap(); + api.anvil_set_balance(address, balance + U256::from(1)).await.unwrap(); + + let balance_before = + provider.get_balance(address).block_id(BlockId::number(number)).await.unwrap(); + + assert_eq!(balance_before, balance); +} From 86d583f3e2dac0825c2b8b718fc528907aecb05e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:53:25 +0300 Subject: [PATCH 1247/1963] fix(coverage): proper branch handling for if statement (#8414) * fix(coverage): proper instruction mapping for first branch * Add tests --- crates/evm/coverage/src/analysis.rs | 94 +++++++++------ crates/evm/coverage/src/anchors.rs | 2 +- crates/evm/coverage/src/lib.rs | 34 +----- crates/forge/tests/cli/coverage.rs | 179 ++++++++++++++++++++++++++++ 4 files changed, 237 insertions(+), 72 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index d499b48825f53..aec4c96c25d0d 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -160,7 +160,7 @@ impl<'a> ContractVisitor<'a> { self.visit_expression( &node .attribute("condition") - .ok_or_else(|| eyre::eyre!("while statement had no condition"))?, + .ok_or_else(|| eyre::eyre!("if statement had no condition"))?, )?; let body = node @@ -211,32 +211,63 @@ impl<'a> ContractVisitor<'a> { let branch_id = self.branch_id; // We increase the branch ID here such that nested branches do not use the same - // branch ID as we do + // branch ID as we do. self.branch_id += 1; - // The relevant source range for the branch is the `if(...)` statement itself and - // the true body of the if statement. The false body of the statement (if any) is - // processed as its own thing. If this source range is not processed like this, it - // is virtually impossible to correctly map instructions back to branches that - // include more complex logic like conditional logic. - self.push_branches( - &foundry_compilers::artifacts::ast::LowFidelitySourceLocation { - start: node.src.start, - length: true_body - .src - .length - .map(|length| true_body.src.start - node.src.start + length), - index: node.src.index, - }, - branch_id, - ); - - // Process the true branch - self.visit_block_or_statement(&true_body)?; - - // Process the false branch - if let Some(false_body) = node.attribute("falseBody") { - self.visit_block_or_statement(&false_body)?; + // The relevant source range for the true branch is the `if(...)` statement itself + // and the true body of the if statement. The false body of the + // statement (if any) is processed as its own thing. If this source + // range is not processed like this, it is virtually impossible to + // correctly map instructions back to branches that include more + // complex logic like conditional logic. + let true_branch_loc = &ast::LowFidelitySourceLocation { + start: node.src.start, + length: true_body + .src + .length + .map(|length| true_body.src.start - node.src.start + length), + index: node.src.index, + }; + + // Add the coverage item for branch 0 (true body). + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, + loc: self.source_location_for(true_branch_loc), + hits: 0, + }); + + match node.attribute::("falseBody") { + // Both if/else statements. + Some(false_body) => { + // Add the coverage item for branch 1 (false body). + // The relevant source range for the false branch is the `else` statement + // itself and the false body of the else statement. + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, + loc: self.source_location_for(&ast::LowFidelitySourceLocation { + start: node.src.start, + length: false_body.src.length.map(|length| { + false_body.src.start - true_body.src.start + length + }), + index: node.src.index, + }), + hits: 0, + }); + // Process the true body. + self.visit_block_or_statement(&true_body)?; + // Process the false body. + self.visit_block_or_statement(&false_body)?; + } + None => { + // Add the coverage item for branch 1 (same true body). + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, + loc: self.source_location_for(true_branch_loc), + hits: 0, + }); + // Process the true body. + self.visit_block_or_statement(&true_body)?; + } } Ok(()) @@ -393,19 +424,6 @@ impl<'a> ContractVisitor<'a> { line: self.source[..loc.start].lines().count(), } } - - fn push_branches(&mut self, loc: &ast::LowFidelitySourceLocation, branch_id: usize) { - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, - loc: self.source_location_for(loc), - hits: 0, - }); - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, - loc: self.source_location_for(loc), - hits: 0, - }); - } } /// [`SourceAnalyzer`] result type. diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index ad4ad744d2072..983cc77d4a1b7 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -149,7 +149,7 @@ pub fn find_anchor_branch( ItemAnchor { item_id, // The first branch is the opcode directly after JUMPI - instruction: pc + 2, + instruction: pc + 1, }, ItemAnchor { item_id, instruction: pc_jump }, )); diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 90486b3cc5158..67822bd8eaaff 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -90,8 +90,7 @@ impl CoverageReport { else { continue; }; - let mut summary = summaries.entry(path).or_default(); - summary += item; + *summaries.entry(path).or_default() += item; } } @@ -424,34 +423,3 @@ impl AddAssign<&CoverageItem> for CoverageSummary { } } } - -impl AddAssign<&CoverageItem> for &mut CoverageSummary { - fn add_assign(&mut self, item: &CoverageItem) { - match item.kind { - CoverageItemKind::Line => { - self.line_count += 1; - if item.hits > 0 { - self.line_hits += 1; - } - } - CoverageItemKind::Statement => { - self.statement_count += 1; - if item.hits > 0 { - self.statement_hits += 1; - } - } - CoverageItemKind::Branch { .. } => { - self.branch_count += 1; - if item.hits > 0 { - self.branch_hits += 1; - } - } - CoverageItemKind::Function { .. } => { - self.function_count += 1; - if item.hits > 0 { - self.function_hits += 1; - } - } - } - } -} diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index f56bfd43726da..f8ee05ba1b8c0 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -271,3 +271,182 @@ end[..] "#]] ); }); + +forgetest!(test_branch_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "Foo.sol", + r#" +contract Foo { + error Gte1(uint256 number, uint256 firstElement); + + enum Status { + NULL, + OPEN, + CLOSED + } + + struct Item { + Status status; + uint256 value; + } + + mapping(uint256 => Item) internal items; + uint256 public nextId = 1; + + function getItem(uint256 id) public view returns (Item memory item) { + item = items[id]; + } + + function addItem(uint256 value) public returns (uint256 id) { + id = nextId; + items[id] = Item(Status.OPEN, value); + nextId++; + } + + function closeIfEqValue(uint256 id, uint256 value) public { + if (items[id].value == value) { + items[id].status = Status.CLOSED; + } + } + + function incrementIfEqValue(uint256 id, uint256 value) public { + if (items[id].value == value) { + items[id].value = value + 1; + } + } + + function foo(uint256 a) external pure { + if (a < 10) { + if (a == 1) { + assert(a == 1); + } else { + assert(a == 5); + } + } else { + assert(a == 60); + } + } + + function countOdd(uint256[] memory arr) external pure returns (uint256 count) { + uint256 length = arr.length; + for (uint256 i = 0; i < length; ++i) { + if (arr[i] % 2 == 1) { + count++; + arr[0]; + } + } + } + + function checkLt(uint256 number, uint256[] memory arr) external pure returns (bool) { + if (number >= arr[0]) { + revert Gte1(number, arr[0]); + } + return true; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "FooTest.sol", + r#" +import "./test.sol"; +import {Foo} from "./Foo.sol"; + +interface Vm { + function expectRevert(bytes calldata revertData) external; +} + +contract FooTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Foo internal foo = new Foo(); + + function test_issue_7784() external view { + foo.foo(1); + foo.foo(5); + foo.foo(60); + } + + function test_issue_4310() external { + uint256[] memory arr = new uint256[](3); + arr[0] = 78; + arr[1] = 493; + arr[2] = 700; + uint256 count = foo.countOdd(arr); + assertEq(count, 1); + + arr = new uint256[](4); + arr[0] = 78; + arr[1] = 493; + arr[2] = 700; + arr[3] = 1729; + count = foo.countOdd(arr); + assertEq(count, 2); + } + + function test_issue_4315() external { + uint256 value = 42; + uint256 id = foo.addItem(value); + assertEq(id, 1); + assertEq(foo.nextId(), 2); + Foo.Item memory item = foo.getItem(id); + assertEq(uint8(item.status), uint8(Foo.Status.OPEN)); + assertEq(item.value, value); + + foo = new Foo(); + id = foo.addItem(value); + foo.closeIfEqValue(id, 903); + item = foo.getItem(id); + assertEq(uint8(item.status), uint8(Foo.Status.OPEN)); + + foo = new Foo(); + foo.addItem(value); + foo.closeIfEqValue(id, 42); + item = foo.getItem(id); + assertEq(uint8(item.status), uint8(Foo.Status.CLOSED)); + + foo = new Foo(); + id = foo.addItem(value); + foo.incrementIfEqValue(id, 903); + item = foo.getItem(id); + assertEq(item.value, 42); + + foo = new Foo(); + id = foo.addItem(value); + foo.incrementIfEqValue(id, 42); + item = foo.getItem(id); + assertEq(item.value, 43); + } + + function test_issue_4309() external { + uint256[] memory arr = new uint256[](1); + arr[0] = 1; + uint256 number = 2; + vm.expectRevert(abi.encodeWithSelector(Foo.Gte1.selector, number, arr[0])); + foo.checkLt(number, arr); + + number = 1; + vm.expectRevert(abi.encodeWithSelector(Foo.Gte1.selector, number, arr[0])); + foo.checkLt(number, arr); + + number = 0; + bool result = foo.checkLt(number, arr); + assertTrue(result); + } +} + "#, + ) + .unwrap(); + + // Assert 100% coverage. + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|-----------------|-----------------|-----------------|---------------| +| src/Foo.sol | 100.00% (20/20) | 100.00% (23/23) | 100.00% (12/12) | 100.00% (7/7) | +| Total | 100.00% (20/20) | 100.00% (23/23) | 100.00% (12/12) | 100.00% (7/7) | + +"#]]); +}); From 547e9757e37cc970ddae7ba84fb8f501a2367d0d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 12 Jul 2024 22:22:29 +0400 Subject: [PATCH 1248/1963] fix: correctly apply genesis (#8431) * Add test * fix: correctly apply genesis during fork reset --- crates/anvil/src/config.rs | 1 - crates/anvil/src/eth/backend/genesis.rs | 7 ---- crates/anvil/src/eth/backend/mem/mod.rs | 35 ++++---------------- crates/anvil/tests/it/fork.rs | 44 ++++++++++++++++++++++++- crates/evm/core/src/backend/error.rs | 2 +- 5 files changed, 50 insertions(+), 39 deletions(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 569beaa9a945b..ef6b2503d79da 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -947,7 +947,6 @@ impl NodeConfig { timestamp: self.get_genesis_timestamp(), balance: self.genesis_balance, accounts: self.genesis_accounts.iter().map(|acc| acc.address()).collect(), - fork_genesis_account_infos: Arc::new(Default::default()), genesis_init: self.genesis.clone(), }; diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index 305f5b892596e..ee459204d0cd5 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -7,8 +7,6 @@ use foundry_evm::{ backend::DatabaseResult, revm::primitives::{AccountInfo, Bytecode, KECCAK_EMPTY}, }; -use parking_lot::Mutex; -use std::sync::Arc; use tokio::sync::RwLockWriteGuard; /// Genesis settings @@ -20,11 +18,6 @@ pub struct GenesisConfig { pub balance: U256, /// All accounts that should be initialised at genesis pub accounts: Vec
, - /// The account object stored in the [`revm::Database`] - /// - /// We store this for forking mode so we can cheaply reset the dev accounts and don't - /// need to fetch them again. - pub fork_genesis_account_infos: Arc>>, /// The `genesis.json` if provided pub genesis_init: Option, } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index e157ffac8dcc7..cf7cf6f9fe373 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -64,7 +64,7 @@ use anvil_core::eth::{ use anvil_rpc::error::RpcError; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ - backend::{BackendError, BackendResult, DatabaseError, DatabaseResult, RevertSnapshotAction}, + backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, decode::RevertDecoder, inspectors::AccessListInspector, @@ -277,7 +277,7 @@ impl Backend { /// Applies the configured genesis settings /// /// This will fund, create the genesis accounts - async fn apply_genesis(&self) -> BackendResult<()> { + async fn apply_genesis(&self) -> Result<(), DatabaseError> { trace!(target: "backend", "setting genesis balances"); if self.fork.read().is_some() { @@ -291,7 +291,7 @@ impl Backend { genesis_accounts_futures.push(tokio::task::spawn(async move { let db = db.read().await; let info = db.basic_ref(address)?.unwrap_or_default(); - Ok::<_, BackendError>((address, info)) + Ok::<_, DatabaseError>((address, info)) })); } @@ -299,19 +299,10 @@ impl Backend { let mut db = self.db.write().await; - // in fork mode we only set the balance, this way the accountinfo is fetched from the - // remote client, preserving code and nonce. The reason for that is private keys for dev - // accounts are commonly known and are used on testnets - let mut fork_genesis_infos = self.genesis.fork_genesis_account_infos.lock(); - fork_genesis_infos.clear(); - for res in genesis_accounts { - let (address, mut info) = res.map_err(BackendError::display)??; + let (address, mut info) = res.unwrap()?; info.balance = self.genesis.balance; db.insert_account(address, info.clone()); - - // store the fetched AccountInfo, so we can cheaply reset in [Self::reset_fork()] - fork_genesis_infos.push(info); } } else { let mut db = self.db.write().await; @@ -459,23 +450,9 @@ impl Backend { fork.total_difficulty(), ); self.states.write().clear(); + self.db.write().await.clear(); - // insert back all genesis accounts, by reusing cached `AccountInfo`s we don't need to - // fetch the data via RPC again - let mut db = self.db.write().await; - - // clear database - db.clear(); - - let fork_genesis_infos = self.genesis.fork_genesis_account_infos.lock(); - for (address, info) in - self.genesis.accounts.iter().copied().zip(fork_genesis_infos.iter().cloned()) - { - db.insert_account(address, info); - } - - // reset the genesis.json alloc - self.genesis.apply_genesis_json_alloc(db)?; + self.apply_genesis().await?; Ok(()) } else { diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 0fe196075ca96..b27b361b26e78 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -4,7 +4,7 @@ use crate::{ abi::{Greeter, ERC721}, utils::{http_provider, http_provider_with_signer}, }; -use alloy_network::{EthereumWallet, TransactionBuilder}; +use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder}; use alloy_primitives::{address, bytes, Address, Bytes, TxHash, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ @@ -1301,3 +1301,45 @@ async fn test_fork_query_at_fork_block() { assert_eq!(balance_before, balance); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_reset_dev_account_nonce() { + let config: NodeConfig = fork_config(); + let address = config.genesis_accounts[0].address(); + let (api, handle) = spawn(config).await; + let provider = handle.http_provider(); + let info = api.anvil_node_info().await.unwrap(); + let number = info.fork_config.fork_block_number.unwrap(); + assert_eq!(number, BLOCK_NUMBER); + + let nonce_before = provider.get_transaction_count(address).await.unwrap(); + + // Reset to older block with other nonce + api.anvil_reset(Some(Forking { + json_rpc_url: None, + block_number: Some(BLOCK_NUMBER - 1_000_000), + })) + .await + .unwrap(); + + let nonce_after = provider.get_transaction_count(address).await.unwrap(); + + assert!(nonce_before > nonce_after); + + let receipt = provider + .send_transaction(WithOtherFields::new( + TransactionRequest::default() + .from(address) + .to(address) + .nonce(nonce_after) + .gas_limit(21000u128), + )) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + + assert!(receipt.status()); +} diff --git a/crates/evm/core/src/backend/error.rs b/crates/evm/core/src/backend/error.rs index c3143b03e1253..15649d9e1c7e8 100644 --- a/crates/evm/core/src/backend/error.rs +++ b/crates/evm/core/src/backend/error.rs @@ -14,7 +14,7 @@ pub enum BackendError { #[error("cheatcodes are not enabled for {0}; see `vm.allowCheatcodes(address)`")] NoCheats(Address), #[error(transparent)] - Backend(#[from] DatabaseError), + Database(#[from] DatabaseError), #[error("failed to fetch account info for {0}")] MissingAccount(Address), #[error( From 5902a6fa87600cf0cbe44e689c97479c16fd474e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:47:48 +0300 Subject: [PATCH 1249/1963] fix(coverage): require should be branch (#8433) --- crates/evm/coverage/src/analysis.rs | 33 +++++++++++-- crates/forge/tests/cli/coverage.rs | 76 +++++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 9 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index aec4c96c25d0d..ac05148ce13b3 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -325,10 +325,7 @@ impl<'a> ContractVisitor<'a> { // tupleexpression // yulfunctioncall match node.node_type { - NodeType::Assignment | - NodeType::UnaryOperation | - NodeType::FunctionCall | - NodeType::Conditional => { + NodeType::Assignment | NodeType::UnaryOperation | NodeType::Conditional => { self.push_item(CoverageItem { kind: CoverageItemKind::Statement, loc: self.source_location_for(&node.src), @@ -336,6 +333,34 @@ impl<'a> ContractVisitor<'a> { }); Ok(()) } + NodeType::FunctionCall => { + self.push_item(CoverageItem { + kind: CoverageItemKind::Statement, + loc: self.source_location_for(&node.src), + hits: 0, + }); + + let expr: Option = node.attribute("expression"); + if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { + // Might be a require call, add branch coverage. + let name: Option = expr.and_then(|expr| expr.attribute("name")); + if let Some("require") = name.as_deref() { + let branch_id = self.branch_id; + self.branch_id += 1; + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, + loc: self.source_location_for(&node.src), + hits: 0, + }); + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, + loc: self.source_location_for(&node.src), + hits: 0, + }); + } + } + Ok(()) + } NodeType::BinaryOperation => { self.push_item(CoverageItem { kind: CoverageItemKind::Statement, diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index f8ee05ba1b8c0..2bd663891c07f 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -167,7 +167,7 @@ contract BContractTest is DSTest { "#]]); }); -forgetest!(test_assert_require_coverage, |prj, cmd| { +forgetest!(test_assert_coverage, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -175,7 +175,6 @@ forgetest!(test_assert_require_coverage, |prj, cmd| { contract AContract { function checkA() external pure returns (bool) { assert(10 > 2); - require(10 > 2, "true"); return true; } } @@ -200,17 +199,84 @@ contract AContractTest is DSTest { ) .unwrap(); - // Assert 100% coverage (assert and require properly covered). + // Assert 100% coverage (assert properly covered). cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (3/3) | 100.00% (3/3) | 100.00% (0/0) | 100.00% (1/1) | -| Total | 100.00% (3/3) | 100.00% (3/3) | 100.00% (0/0) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | +| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | "#]]); }); +forgetest!(test_require_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + function checkRequire(bool doNotRevert) public view { + require(doNotRevert, "reverted"); + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +interface Vm { + function expectRevert(bytes calldata revertData) external; +} + +contract AContractTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + function testRequireRevert() external { + AContract a = new AContract(); + vm.expectRevert(abi.encodePacked("reverted")); + a.checkRequire(false); + } + + function testRequireNoRevert() external { + AContract a = new AContract(); + a.checkRequire(true); + } +} + "#, + ) + .unwrap(); + + // Assert 50% branch coverage if only revert tested. + cmd.arg("coverage") + .args(["--mt".to_string(), "testRequireRevert".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|--------------|---------------| +| src/AContract.sol | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | + +"#]]); + + // Assert 100% branch coverage. + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (1/1) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | +| Total | 100.00% (1/1) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | + +"#]], + ); +}); + forgetest!(test_line_hit_not_doubled, |prj, cmd| { prj.insert_ds_test(); prj.add_source( From 69a9d23d4295e914081e42b77bf85d6fefc5978b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 14 Jul 2024 07:31:20 +0200 Subject: [PATCH 1250/1963] chore(deps): weekly `cargo update` (#8437) Locking 17 packages to latest compatible versions Updating aws-sdk-kms v1.35.0 -> v1.36.0 Updating aws-sdk-sso v1.34.0 -> v1.35.0 Updating aws-sdk-ssooidc v1.35.0 -> v1.36.0 Updating aws-sdk-sts v1.34.0 -> v1.35.0 Updating aws-smithy-runtime v1.6.1 -> v1.6.2 Updating bytes v1.6.0 -> v1.6.1 Updating cc v1.1.0 -> v1.1.2 Updating clap_complete v4.5.7 -> v4.5.8 Updating http-body v1.0.0 -> v1.0.1 Adding prost v0.13.1 Adding prost-derive v0.13.1 Adding prost-types v0.13.1 Updating secret-vault-value v0.3.8 -> v0.3.9 Updating snapbox v0.6.11 -> v0.6.13 Updating syn v2.0.70 -> v2.0.71 Updating thiserror v1.0.61 -> v1.0.62 Updating thiserror-impl v1.0.61 -> v1.0.62 note: pass `--verbose` to see 147 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 222 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 127 insertions(+), 95 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6790a61d01563..9869a2658dd67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,7 +306,7 @@ checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -552,7 +552,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -569,7 +569,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", "syn-solidity", "tiny-keccak", ] @@ -587,7 +587,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.70", + "syn 2.0.71", "syn-solidity", ] @@ -1099,7 +1099,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -1121,7 +1121,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -1132,7 +1132,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -1179,7 +1179,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -1256,9 +1256,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bbfeaffab8514ae56938de28de5b5c698e7146549f1085cb772ccf1f42aa8" +checksum = "6bf39203c9fa4b177c5b58ebf19fc97bbfece1e17c3171c7c5e356ca5f6ea42c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1278,9 +1278,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.34.0" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdcfae7bf8b8f14cade7579ffa8956fcee91dc23633671096b4b5de7d16f682a" +checksum = "fc3ef4ee9cdd19ec6e8b10d963b79637844bbf41c31177b77a188eaa941e69f7" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1300,9 +1300,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b30def8f02ba81276d5dbc22e7bf3bed20d62d1b175eef82680d6bdc7a6f4c" +checksum = "527f3da450ea1f09f95155dba6153bd0d83fe0923344a12e1944dfa5d0b32064" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1322,9 +1322,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.34.0" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0804f840ad31537d5d1a4ec48d59de5e674ad05f1db7d3def2c9acadaf1f7e60" +checksum = "94316606a4aa2cb7a302388411b8776b3fbd254e8506e2dc43918286d8212e9b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1418,9 +1418,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df4217d39fe940066174e6238310167bf466bfbebf3be0661e53cacccde6313" +checksum = "ce87155eba55e11768b8c1afa607f3e864ae82f03caf63258b37455b0ad02537" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1431,7 +1431,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "http-body 1.0.0", + "http-body 1.0.1", "httparse", "hyper 0.14.30", "hyper-rustls 0.24.2", @@ -1472,7 +1472,7 @@ dependencies = [ "http 0.2.12", "http 1.1.0", "http-body 0.4.6", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "itoa", "num-integer", @@ -1546,7 +1546,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "hyper 1.4.1", "hyper-util", @@ -1598,7 +1598,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "mime", "pin-project-lite", @@ -1799,9 +1799,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" dependencies = [ "serde", ] @@ -1964,9 +1964,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" +checksum = "47de7e88bbbd467951ae7f5a6f34f70d1b4d9cfce53d5fd70f74ebe118b3db56" dependencies = [ "jobserver", "libc", @@ -2101,9 +2101,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d598e88f6874d4b888ed40c71efbcbf4076f1dfbae128a08a8c9e45f710605d" +checksum = "5b4be9c4c4b1f30b78d8a750e0822b6a6102d97e62061c583a6c1dea2dfb33ae" dependencies = [ "clap", ] @@ -2127,7 +2127,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2554,7 +2554,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2565,7 +2565,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2637,7 +2637,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2658,7 +2658,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2668,7 +2668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2681,7 +2681,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2788,7 +2788,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -2924,7 +2924,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -3074,7 +3074,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.70", + "syn 2.0.71", "toml 0.8.14", "walkdir", ] @@ -3102,7 +3102,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.70", + "syn 2.0.71", "tempfile", "thiserror", "tiny-keccak", @@ -3478,7 +3478,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -4039,7 +4039,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -4198,7 +4198,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -4265,8 +4265,8 @@ dependencies = [ "hyper 0.14.30", "jsonwebtoken", "once_cell", - "prost", - "prost-types", + "prost 0.12.6", + "prost-types 0.12.6", "reqwest 0.11.27", "secret-vault-value", "serde", @@ -4705,7 +4705,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -4743,9 +4743,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http 1.1.0", @@ -4760,7 +4760,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -4832,7 +4832,7 @@ dependencies = [ "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "httparse", "httpdate", "itoa", @@ -4915,7 +4915,7 @@ dependencies = [ "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "hyper 1.4.1", "pin-project-lite", "socket2", @@ -5553,7 +5553,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -5623,7 +5623,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -5861,7 +5861,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -5973,7 +5973,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -6150,7 +6150,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -6209,7 +6209,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -6293,7 +6293,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -6351,7 +6351,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -6467,7 +6467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -6543,7 +6543,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", "version_check", "yansi", ] @@ -6617,7 +6617,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.6", +] + +[[package]] +name = "prost" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +dependencies = [ + "bytes", + "prost-derive 0.13.1", ] [[package]] @@ -6630,7 +6640,20 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", +] + +[[package]] +name = "prost-derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +dependencies = [ + "anyhow", + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.71", ] [[package]] @@ -6639,7 +6662,16 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost", + "prost 0.12.6", +] + +[[package]] +name = "prost-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +dependencies = [ + "prost 0.13.1", ] [[package]] @@ -6988,7 +7020,7 @@ dependencies = [ "futures-core", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "hyper 1.4.1", "hyper-rustls 0.27.2", @@ -7520,7 +7552,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -7598,12 +7630,12 @@ dependencies = [ [[package]] name = "secret-vault-value" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f8cfb86d2019f64a4cfb49e499f401f406fbec946c1ffeea9d0504284347de" +checksum = "bc32a777b53b3433b974c9c26b6d502a50037f8da94e46cb8ce2ced2cfdfaea0" dependencies = [ - "prost", - "prost-types", + "prost 0.13.1", + "prost-types 0.13.1", "serde", "serde_json", "zeroize", @@ -7682,7 +7714,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -7693,7 +7725,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -7736,7 +7768,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -7782,7 +7814,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -7977,9 +8009,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snapbox" -version = "0.6.11" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "699c824ef8c2061c39efb3af4f334310b3acbfb2a50c6d1f867e4d95dcff94be" +checksum = "0d656960fa127e80ade23c321d8c573bb9ba462c3a69e62ede635fc180ffc6cc" dependencies = [ "anstream", "anstyle", @@ -8076,7 +8108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -8142,7 +8174,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -8210,9 +8242,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.70" +version = "2.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" dependencies = [ "proc-macro2", "quote", @@ -8228,7 +8260,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -8335,22 +8367,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -8496,7 +8528,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -8667,7 +8699,7 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project 1.1.5", - "prost", + "prost 0.12.6", "rustls-native-certs 0.7.1", "rustls-pemfile 2.1.2", "rustls-pki-types", @@ -8716,7 +8748,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body 1.0.1", "http-body-util", "http-range-header", "httpdate", @@ -8775,7 +8807,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -9168,7 +9200,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", "wasm-bindgen-shared", ] @@ -9202,7 +9234,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9416,7 +9448,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -9427,7 +9459,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -9693,7 +9725,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] @@ -9713,7 +9745,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.71", ] [[package]] From ec4c4aa6b8d77e7971ff59da8f55c363b7d2af72 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 14 Jul 2024 14:09:08 +0400 Subject: [PATCH 1251/1963] fix(anvil): return correct values for `eth_feeHistory` (#8436) * add test * fix(anvil): return correct last block data in feeHistory --- crates/anvil/src/eth/fees.rs | 38 ++++++++++++++++-------------------- crates/anvil/src/lib.rs | 8 ++------ crates/anvil/tests/it/gas.rs | 8 ++++++++ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index e0c8685fd567f..ab65fcc46bd7b 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -2,6 +2,7 @@ use crate::eth::{ backend::{info::StorageInfo, notifications::NewBlockNotifications}, error::BlockchainError, }; +use alloy_consensus::Header; use alloy_eips::{ calc_next_block_base_fee, eip1559::BaseFeeParams, eip4844::MAX_DATA_GAS_PER_BLOCK, }; @@ -190,8 +191,6 @@ pub struct FeeHistoryService { cache: FeeHistoryCache, /// number of items to consider fee_history_limit: u64, - // current fee info - fees: FeeManager, /// a type that can fetch ethereum-storage data storage_info: StorageInfo, } @@ -200,16 +199,9 @@ impl FeeHistoryService { pub fn new( new_blocks: NewBlockNotifications, cache: FeeHistoryCache, - fees: FeeManager, storage_info: StorageInfo, ) -> Self { - Self { - new_blocks, - cache, - fee_history_limit: MAX_FEE_HISTORY_CACHE_SIZE, - fees, - storage_info, - } + Self { new_blocks, cache, fee_history_limit: MAX_FEE_HISTORY_CACHE_SIZE, storage_info } } /// Returns the configured history limit @@ -218,13 +210,17 @@ impl FeeHistoryService { } /// Inserts a new cache entry for the given block - pub(crate) fn insert_cache_entry_for_block(&self, hash: B256) { - let (result, block_number) = self.create_cache_entry(hash); + pub(crate) fn insert_cache_entry_for_block(&self, hash: B256, header: &Header) { + let (result, block_number) = self.create_cache_entry(hash, header); self.insert_cache_entry(result, block_number); } /// Create a new history entry for the block - fn create_cache_entry(&self, hash: B256) -> (FeeHistoryCacheItem, Option) { + fn create_cache_entry( + &self, + hash: B256, + header: &Header, + ) -> (FeeHistoryCacheItem, Option) { // percentile list from 0.0 to 100.0 with a 0.5 resolution. // this will create 200 percentile points let reward_percentiles: Vec = { @@ -239,16 +235,18 @@ impl FeeHistoryService { }; let mut block_number: Option = None; - let base_fee = self.fees.base_fee(); - let excess_blob_gas_and_price = self.fees.excess_blob_gas_and_price(); + let base_fee = header.base_fee_per_gas.unwrap_or_default(); + let excess_blob_gas = header.excess_blob_gas; + let blob_gas_used = header.blob_gas_used; + let base_fee_per_blob_gas = header.blob_fee(); let mut item = FeeHistoryCacheItem { base_fee, gas_used_ratio: 0f64, blob_gas_used_ratio: 0f64, rewards: Vec::new(), - excess_blob_gas: excess_blob_gas_and_price.as_ref().map(|g| g.excess_blob_gas as u128), - base_fee_per_blob_gas: excess_blob_gas_and_price.as_ref().map(|g| g.blob_gasprice), - blob_gas_used: excess_blob_gas_and_price.as_ref().map(|_| 0), + excess_blob_gas, + base_fee_per_blob_gas, + blob_gas_used, }; let current_block = self.storage_info.block(hash); @@ -345,10 +343,8 @@ impl Future for FeeHistoryService { let pin = self.get_mut(); while let Poll::Ready(Some(notification)) = pin.new_blocks.poll_next_unpin(cx) { - let hash = notification.hash; - // add the imported block. - pin.insert_cache_entry_for_block(hash); + pin.insert_cache_entry_for_block(notification.hash, notification.header.as_ref()); } Poll::Pending diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 3f9f574f0756c..56005dd603ec9 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -178,19 +178,15 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle } } - let fees = backend.fees().clone(); let fee_history_cache = Arc::new(Mutex::new(Default::default())); let fee_history_service = FeeHistoryService::new( backend.new_block_notifications(), Arc::clone(&fee_history_cache), - fees, StorageInfo::new(Arc::clone(&backend)), ); // create an entry for the best block - if let Some(best_block) = - backend.get_block(backend.best_number()).map(|block| block.header.hash_slow()) - { - fee_history_service.insert_cache_entry_for_block(best_block); + if let Some(header) = backend.get_block(backend.best_number()).map(|block| block.header) { + fee_history_service.insert_cache_entry_for_block(header.hash_slow(), &header); } let filters = Filters::default(); diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index af28983f1f994..ae9c9c201eced 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -191,5 +191,13 @@ async fn test_can_use_fee_history() { let receipt = provider.send_transaction(tx.clone()).await.unwrap().get_receipt().await.unwrap(); assert!(receipt.inner.inner.is_success()); + + let fee_history_after = provider.get_fee_history(1, Default::default(), &[]).await.unwrap(); + let latest_fee_history_fee = fee_history_after.base_fee_per_gas.first().unwrap(); + let latest_block = + provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + assert_eq!(latest_block.header.base_fee_per_gas.unwrap(), *latest_fee_history_fee); + assert_eq!(latest_fee_history_fee, next_base_fee); } } From 0e07ca51a2947f86d099645fb6eb6d0e47a4410d Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Sun, 14 Jul 2024 13:56:55 +0300 Subject: [PATCH 1252/1963] feat(template): improve workflow template (#8439) Co-authored-by: Matthias Seitz --- crates/forge/assets/workflowTemplate.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/forge/assets/workflowTemplate.yml b/crates/forge/assets/workflowTemplate.yml index 9282e82944e8d..762a2966f7a69 100644 --- a/crates/forge/assets/workflowTemplate.yml +++ b/crates/forge/assets/workflowTemplate.yml @@ -1,6 +1,9 @@ -name: test +name: CI -on: workflow_dispatch +on: + push: + pull_request: + workflow_dispatch: env: FOUNDRY_PROFILE: ci @@ -22,9 +25,17 @@ jobs: with: version: nightly - - name: Run Forge build + - name: Show Forge version run: | forge --version + + - name: Run Forge fmt + run: | + forge fmt --check + id: fmt + + - name: Run Forge build + run: | forge build --sizes id: build From 6de15b0136ccb7dcac412d6b97bb3269ac2361c3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:31:42 +0300 Subject: [PATCH 1253/1963] fix(coverage): add coverage only for function call kind (#8440) fix(coverage): count covearge only for function call kind --- crates/evm/coverage/src/analysis.rs | 50 +++++++++++--------- crates/forge/tests/cli/coverage.rs | 72 +++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 22 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index ac05148ce13b3..4349578013c4d 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -334,31 +334,37 @@ impl<'a> ContractVisitor<'a> { Ok(()) } NodeType::FunctionCall => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); + // Do not count other kinds of calls towards coverage (like `typeConversion` + // and `structConstructorCall`). + let kind: Option = node.attribute("kind"); + if let Some("functionCall") = kind.as_deref() { + self.push_item(CoverageItem { + kind: CoverageItemKind::Statement, + loc: self.source_location_for(&node.src), + hits: 0, + }); - let expr: Option = node.attribute("expression"); - if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { - // Might be a require call, add branch coverage. - let name: Option = expr.and_then(|expr| expr.attribute("name")); - if let Some("require") = name.as_deref() { - let branch_id = self.branch_id; - self.branch_id += 1; - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, - loc: self.source_location_for(&node.src), - hits: 0, - }); - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, - loc: self.source_location_for(&node.src), - hits: 0, - }); + let expr: Option = node.attribute("expression"); + if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { + // Might be a require call, add branch coverage. + let name: Option = expr.and_then(|expr| expr.attribute("name")); + if let Some("require") = name.as_deref() { + let branch_id = self.branch_id; + self.branch_id += 1; + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, + loc: self.source_location_for(&node.src), + hits: 0, + }); + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, + loc: self.source_location_for(&node.src), + hits: 0, + }); + } } } + Ok(()) } NodeType::BinaryOperation => { diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 2bd663891c07f..6d07225afe38b 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -516,3 +516,75 @@ contract FooTest is DSTest { "#]]); }); + +forgetest!(test_function_call_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + struct Custom { + bool a; + uint256 b; + } + + function coverMe() external returns (bool) { + // Next lines should not be counted in coverage. + string(""); + uint256(1); + address(this); + bool(false); + Custom(true, 10); + // Next lines should be counted in coverage. + uint256 a = uint256(1); + Custom memory cust = Custom(false, 100); + privateWithNoBody(); + privateWithBody(); + publicWithNoBody(); + publicWithBody(); + return true; + } + + function privateWithNoBody() private {} + + function privateWithBody() private returns (bool) { + return true; + } + + function publicWithNoBody() private {} + + function publicWithBody() private returns (bool) { + return true; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + function testTypeConversionCoverage() external { + AContract a = new AContract(); + a.coverMe(); + } +} + "#, + ) + .unwrap(); + + // Assert 100% coverage and only 9 lines reported (comments, type conversions and struct + // constructor calls are not included). + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | +| Total | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | + +"#]]); +}); From 9faa0578981538aa0bcd70811f654bb5938347fc Mon Sep 17 00:00:00 2001 From: EdwardJES <107906898+EdwardJES@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:19:02 +1000 Subject: [PATCH 1254/1963] fix: vm dumpState consistent ordering (#8445) * use btree map to enforce ordering * rm unused import --- crates/cheatcodes/src/evm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 0b42391f8b317..33b0642011590 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -148,7 +148,7 @@ impl Cheatcode for dumpStateCall { }, ) }) - .collect::>(); + .collect::>(); write_json_file(path, &alloc)?; Ok(Default::default()) From b98590c702e8faf8ee51b0e2a85509d691a3d141 Mon Sep 17 00:00:00 2001 From: lightclient <14004106+lightclient@users.noreply.github.com> Date: Mon, 15 Jul 2024 05:36:58 -0600 Subject: [PATCH 1255/1963] feat(cheatcodes): add event expecter which supports anonymous events (#8429) feat(cheatcodes): add event expecter which supports anonymous events with no indexed topics --- crates/cheatcodes/assets/cheatcodes.json | 80 ++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 21 +++++ crates/cheatcodes/src/test/expect.rs | 115 ++++++++++++++++------- crates/forge/tests/it/repros.rs | 4 + testdata/cheats/Vm.sol | 4 + testdata/default/repros/Issue7457.t.sol | 111 ++++++++++++++++++++++ 6 files changed, 303 insertions(+), 32 deletions(-) create mode 100644 testdata/default/repros/Issue7457.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 9c7e36965be0a..a6a9c94795ee1 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4531,6 +4531,86 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "expectEmitAnonymous_0", + "description": "Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).\nCall this function, then emit an anonymous event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data (as specified by the booleans).", + "declaration": "function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmitAnonymous(bool,bool,bool,bool,bool)", + "selector": "0xc948db5e", + "selectorBytes": [ + 201, + 72, + 219, + 94 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmitAnonymous_1", + "description": "Same as the previous method, but also checks supplied address against emitting contract.", + "declaration": "function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmitAnonymous(bool,bool,bool,bool,bool,address)", + "selector": "0x71c95899", + "selectorBytes": [ + 113, + 201, + 88, + 153 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmitAnonymous_2", + "description": "Prepare an expected anonymous log with all topic and data checks enabled.\nCall this function, then emit an anonymous event, then call a function. Internally after the call, we check if\nlogs were emitted in the expected order with the expected topics and data.", + "declaration": "function expectEmitAnonymous() external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmitAnonymous()", + "selector": "0x2e5f270c", + "selectorBytes": [ + 46, + 95, + 39, + 12 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmitAnonymous_3", + "description": "Same as the previous method, but also checks supplied address against emitting contract.", + "declaration": "function expectEmitAnonymous(address emitter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmitAnonymous(address)", + "selector": "0x6fc68705", + "selectorBytes": [ + 111, + 198, + 135, + 5 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "expectEmit_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 54f1fe8fe77f7..a009c9f598e25 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -773,6 +773,27 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectEmit(address emitter) external; + /// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). + /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if + /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans). + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; + + /// Same as the previous method, but also checks supplied address against emitting contract. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) + external; + + /// Prepare an expected anonymous log with all topic and data checks enabled. + /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if + /// logs were emitted in the expected order with the expected topics and data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmitAnonymous() external; + + /// Same as the previous method, but also checks supplied address against emitting contract. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmitAnonymous(address emitter) external; + /// Expects an error on next call with any revert data. #[cheatcode(group = Testing, safety = Unsafe)] function expectRevert() external; diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 9c070a7ca8874..f2b7cbc065466 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -84,13 +84,16 @@ pub struct ExpectedEmit { pub log: Option, /// The checks to perform: /// ```text - /// ┌───────┬───────┬───────┬────┐ - /// │topic 1│topic 2│topic 3│data│ - /// └───────┴───────┴───────┴────┘ + /// ┌───────┬───────┬───────┬───────┬────┐ + /// │topic 0│topic 1│topic 2│topic 3│data│ + /// └───────┴───────┴───────┴───────┴────┘ /// ``` - pub checks: [bool; 4], + pub checks: [bool; 5], /// If present, check originating address against this pub address: Option
, + /// If present, relax the requirement that topic 0 must be present. This allows anonymous + /// events with no indexed topics to be matched. + pub anonymous: bool, /// Whether the log was actually found in the subcalls pub found: bool, } @@ -202,8 +205,9 @@ impl Cheatcode for expectEmit_0Call { expect_emit( ccx.state, ccx.ecx.journaled_state.depth(), - [checkTopic1, checkTopic2, checkTopic3, checkData], + [true, checkTopic1, checkTopic2, checkTopic3, checkData], None, + false, ) } } @@ -214,8 +218,9 @@ impl Cheatcode for expectEmit_1Call { expect_emit( ccx.state, ccx.ecx.journaled_state.depth(), - [checkTopic1, checkTopic2, checkTopic3, checkData], + [true, checkTopic1, checkTopic2, checkTopic3, checkData], Some(emitter), + false, ) } } @@ -223,14 +228,54 @@ impl Cheatcode for expectEmit_1Call { impl Cheatcode for expectEmit_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 4], None) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, false) } } impl Cheatcode for expectEmit_3Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { emitter } = *self; - expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 4], Some(emitter)) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), false) + } +} + +impl Cheatcode for expectEmitAnonymous_0Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData } = *self; + expect_emit( + ccx.state, + ccx.ecx.journaled_state.depth(), + [checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData], + None, + true, + ) + } +} + +impl Cheatcode for expectEmitAnonymous_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData, emitter } = *self; + expect_emit( + ccx.state, + ccx.ecx.journaled_state.depth(), + [checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData], + Some(emitter), + true, + ) + } +} + +impl Cheatcode for expectEmitAnonymous_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, true) + } +} + +impl Cheatcode for expectEmitAnonymous_3Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { emitter } = *self; + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), true) } } @@ -384,8 +429,9 @@ fn expect_call( fn expect_emit( state: &mut Cheatcodes, depth: u64, - checks: [bool; 4], + checks: [bool; 5], address: Option
, + anonymous: bool, ) -> Result { state.expected_emits.push_back(ExpectedEmit { depth, @@ -393,6 +439,7 @@ fn expect_emit( address, found: false, log: None, + anonymous, }); Ok(Default::default()) } @@ -412,7 +459,7 @@ pub(crate) fn handle_expect_emit(state: &mut Cheatcodes, log: &alloy_primitives: return } - // if there's anything to fill, we need to pop back. + // If there's anything to fill, we need to pop back. // Otherwise, if there are any events that are unmatched, we try to match to match them // in the order declared, so we start popping from the front (like a queue). let mut event_to_fill_or_check = @@ -424,38 +471,42 @@ pub(crate) fn handle_expect_emit(state: &mut Cheatcodes, log: &alloy_primitives: .expect("we should have an emit to fill or check"); let Some(expected) = &event_to_fill_or_check.log else { - // Fill the event. - event_to_fill_or_check.log = Some(log.data.clone()); + // Unless the caller is trying to match an anonymous event, the first topic must be + // filled. + // TODO: failing this check should probably cause a warning + if event_to_fill_or_check.anonymous || log.topics().first().is_some() { + event_to_fill_or_check.log = Some(log.data.clone()); + } state.expected_emits.push_back(event_to_fill_or_check); return }; - let expected_topic_0 = expected.topics().first(); - let log_topic_0 = log.topics().first(); - - if expected_topic_0 - .zip(log_topic_0) - .map_or(false, |(a, b)| a == b && expected.topics().len() == log.topics().len()) - { - // Match topics - event_to_fill_or_check.found = log + event_to_fill_or_check.found = || -> bool { + // Topic count must match. + if expected.topics().len() != log.topics().len() { + return false + } + // Match topics according to the checks. + if !log .topics() .iter() - .skip(1) .enumerate() .filter(|(i, _)| event_to_fill_or_check.checks[*i]) - .all(|(i, topic)| topic == &expected.topics()[i + 1]); - - // Maybe match source address - if let Some(addr) = event_to_fill_or_check.address { - event_to_fill_or_check.found &= addr == log.address; + .all(|(i, topic)| topic == &expected.topics()[i]) + { + return false } - - // Maybe match data - if event_to_fill_or_check.checks[3] { - event_to_fill_or_check.found &= expected.data.as_ref() == log.data.data.as_ref(); + // Maybe match source address. + if event_to_fill_or_check.address.map_or(false, |addr| addr != log.address) { + return false; } - } + // Maybe match data. + if event_to_fill_or_check.checks[4] && expected.data.as_ref() != log.data.data.as_ref() { + return false + } + + true + }(); // If we found the event, we can push it to the back of the queue // and begin expecting the next event. diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index b7b6c1063cf0c..f1b1c8a96ef4b 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -331,6 +331,10 @@ test_repro!(6634; |config| { config.runner.config = Arc::new(prj_config); }); +// https://github.com/foundry-rs/foundry/issues/7457 +test_repro!(7457); + +// https://github.com/foundry-rs/foundry/issues/7481 test_repro!(7481); // https://github.com/foundry-rs/foundry/issues/5739 diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index cf72e88475d8e..9c008c4254f4a 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -222,6 +222,10 @@ interface Vm { 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() 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() external; diff --git a/testdata/default/repros/Issue7457.t.sol b/testdata/default/repros/Issue7457.t.sol new file mode 100644 index 0000000000000..8d9d6f0753d5c --- /dev/null +++ b/testdata/default/repros/Issue7457.t.sol @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +interface ITarget { + event AnonymousEventEmpty() anonymous; + event AnonymousEventNonIndexed(uint256 a) anonymous; + + event DifferentAnonymousEventEmpty() anonymous; + event DifferentAnonymousEventNonIndexed(string a) anonymous; + + event AnonymousEventWith1Topic(uint256 indexed a, uint256 b) anonymous; + event AnonymousEventWith2Topics(uint256 indexed a, uint256 indexed b, uint256 c) anonymous; + event AnonymousEventWith3Topics(uint256 indexed a, uint256 indexed b, uint256 indexed c, uint256 d) anonymous; + event AnonymousEventWith4Topics( + uint256 indexed a, uint256 indexed b, uint256 indexed c, uint256 indexed d, uint256 e + ) anonymous; +} + +contract Target is ITarget { + function emitAnonymousEventEmpty() external { + emit AnonymousEventEmpty(); + } + + function emitAnonymousEventNonIndexed(uint256 a) external { + emit AnonymousEventNonIndexed(a); + } + + function emitAnonymousEventWith1Topic(uint256 a, uint256 b) external { + emit AnonymousEventWith1Topic(a, b); + } + + function emitAnonymousEventWith2Topics(uint256 a, uint256 b, uint256 c) external { + emit AnonymousEventWith2Topics(a, b, c); + } + + function emitAnonymousEventWith3Topics(uint256 a, uint256 b, uint256 c, uint256 d) external { + emit AnonymousEventWith3Topics(a, b, c, d); + } + + function emitAnonymousEventWith4Topics(uint256 a, uint256 b, uint256 c, uint256 d, uint256 e) external { + emit AnonymousEventWith4Topics(a, b, c, d, e); + } +} + +// https://github.com/foundry-rs/foundry/issues/7457 +contract Issue7457Test is DSTest, ITarget { + Vm constant vm = Vm(HEVM_ADDRESS); + + Target public target; + + function setUp() external { + target = new Target(); + } + + function testEmitEvent() public { + vm.expectEmitAnonymous(false, false, false, false, true); + emit AnonymousEventEmpty(); + target.emitAnonymousEventEmpty(); + } + + function testFailEmitEventNonIndexed() public { + vm.expectEmit(false, false, false, true); + emit AnonymousEventNonIndexed(1); + target.emitAnonymousEventNonIndexed(1); + } + + function testEmitEventNonIndexed() public { + vm.expectEmitAnonymous(false, false, false, false, true); + emit AnonymousEventNonIndexed(1); + target.emitAnonymousEventNonIndexed(1); + } + + // function testFailEmitDifferentEvent() public { + // vm.expectEmitAnonymous(false, false, false, true); + // emit DifferentAnonymousEventEmpty(); + // target.emitAnonymousEventEmpty(); + // } + + function testFailEmitDifferentEventNonIndexed() public { + vm.expectEmitAnonymous(false, false, false, false, true); + emit DifferentAnonymousEventNonIndexed("1"); + target.emitAnonymousEventNonIndexed(1); + } + + function testEmitEventWith1Topic() public { + vm.expectEmitAnonymous(true, false, false, false, true); + emit AnonymousEventWith1Topic(1, 2); + target.emitAnonymousEventWith1Topic(1, 2); + } + + function testEmitEventWith2Topics() public { + vm.expectEmitAnonymous(true, true, false, false, true); + emit AnonymousEventWith2Topics(1, 2, 3); + target.emitAnonymousEventWith2Topics(1, 2, 3); + } + + function testEmitEventWith3Topics() public { + vm.expectEmitAnonymous(true, true, true, false, true); + emit AnonymousEventWith3Topics(1, 2, 3, 4); + target.emitAnonymousEventWith3Topics(1, 2, 3, 4); + } + + function testEmitEventWith4Topics() public { + vm.expectEmitAnonymous(true, true, true, true, true); + emit AnonymousEventWith4Topics(1, 2, 3, 4, 5); + target.emitAnonymousEventWith4Topics(1, 2, 3, 4, 5); + } +} From dad390189d0a2b3861e074f3d49d22c9e2e8fd7e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:59:21 +0300 Subject: [PATCH 1256/1963] feat(coverage): report try-catch coverage (#8448) --- crates/evm/coverage/src/analysis.rs | 44 ++++++++--- crates/forge/tests/cli/coverage.rs | 113 ++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 9 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 4349578013c4d..1541f0b492681 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -126,10 +126,8 @@ impl<'a> ContractVisitor<'a> { }); Ok(()) } - // Skip placeholder statements as they are never referenced in source maps. NodeType::PlaceholderStatement => Ok(()), - // Return with eventual subcall NodeType::Return => { self.push_item(CoverageItem { @@ -142,7 +140,6 @@ impl<'a> ContractVisitor<'a> { } Ok(()) } - // Variable declaration NodeType::VariableDeclarationStatement => { self.push_item(CoverageItem { @@ -160,7 +157,7 @@ impl<'a> ContractVisitor<'a> { self.visit_expression( &node .attribute("condition") - .ok_or_else(|| eyre::eyre!("if statement had no condition"))?, + .ok_or_else(|| eyre::eyre!("while statement had no condition"))?, )?; let body = node @@ -199,7 +196,7 @@ impl<'a> ContractVisitor<'a> { self.visit_expression( &node .attribute("condition") - .ok_or_else(|| eyre::eyre!("while statement had no condition"))?, + .ok_or_else(|| eyre::eyre!("if statement had no condition"))?, )?; let true_body: Node = node @@ -300,15 +297,44 @@ impl<'a> ContractVisitor<'a> { Ok(()) } - // Try-catch statement + // Try-catch statement. Coverage is reported for expression, for each clause and their + // bodies (if any). NodeType::TryStatement => { - // TODO: Clauses - // TODO: This is branching, right? self.visit_expression( &node .attribute("externalCall") .ok_or_else(|| eyre::eyre!("try statement had no call"))?, - ) + )?; + + // Add coverage for each Try-catch clause. + for clause in node + .attribute::>("clauses") + .ok_or_else(|| eyre::eyre!("try statement had no clause"))? + { + // Add coverage for clause statement. + self.push_item(CoverageItem { + kind: CoverageItemKind::Statement, + loc: self.source_location_for(&clause.src), + hits: 0, + }); + self.visit_statement(&clause)?; + + // Add coverage for clause body only if it is not empty. + if let Some(block) = clause.attribute::("block") { + let statements: Vec = + block.attribute("statements").unwrap_or_default(); + if !statements.is_empty() { + self.push_item(CoverageItem { + kind: CoverageItemKind::Statement, + loc: self.source_location_for(&block.src), + hits: 0, + }); + self.visit_block(&block)?; + } + } + } + + Ok(()) } _ => { warn!("unexpected node type, expected a statement: {:?}", node.node_type); diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 6d07225afe38b..15e55de0e7e76 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -588,3 +588,116 @@ contract AContractTest is DSTest { "#]]); }); + +forgetest!(test_try_catch_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "Foo.sol", + r#" +contract Foo { + address public owner; + + constructor(address _owner) { + require(_owner != address(0), "invalid address"); + assert(_owner != 0x0000000000000000000000000000000000000001); + owner = _owner; + } + + function myFunc(uint256 x) public pure returns (string memory) { + require(x != 0, "require failed"); + return "my func was called"; + } +} + +contract Bar { + event Log(string message); + event LogBytes(bytes data); + + Foo public foo; + + constructor() { + foo = new Foo(msg.sender); + } + + function tryCatchExternalCall(uint256 _i) public { + try foo.myFunc(_i) returns (string memory result) { + emit Log(result); + } catch { + emit Log("external call failed"); + } + } + + function tryCatchNewContract(address _owner) public { + try new Foo(_owner) returns (Foo foo_) { + emit Log("Foo created"); + } catch Error(string memory reason) { + emit Log(reason); + } catch (bytes memory reason) {} + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "FooTest.sol", + r#" +import "./test.sol"; +import {Bar, Foo} from "./Foo.sol"; + +interface Vm { + function expectRevert() external; +} + +contract FooTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_happy_foo_coverage() external { + vm.expectRevert(); + Foo foo = new Foo(address(0)); + vm.expectRevert(); + foo = new Foo(address(1)); + foo = new Foo(address(2)); + } + + function test_happy_path_coverage() external { + Bar bar = new Bar(); + bar.tryCatchNewContract(0x0000000000000000000000000000000000000002); + bar.tryCatchExternalCall(1); + } + + function test_coverage() external { + Bar bar = new Bar(); + bar.tryCatchNewContract(0x0000000000000000000000000000000000000000); + bar.tryCatchNewContract(0x0000000000000000000000000000000000000001); + bar.tryCatchExternalCall(0); + } +} + "#, + ) + .unwrap(); + + // Assert coverage not 100% for happy paths only. + cmd.arg("coverage").args(["--mt".to_string(), "happy".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|----------------|----------------|---------------|---------------| +| src/Foo.sol | 66.67% (10/15) | 66.67% (14/21) | 100.00% (4/4) | 100.00% (5/5) | +| Total | 66.67% (10/15) | 66.67% (14/21) | 100.00% (4/4) | 100.00% (5/5) | + +"#]], + ); + + // Assert 100% branch coverage (including clauses without body). + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|-----------------|-----------------|---------------|---------------| +| src/Foo.sol | 100.00% (15/15) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | +| Total | 100.00% (15/15) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | + +"#]], + ); +}); From ea7817c6679abc3bcfc476c20ced4fe6200d8928 Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:53:23 -0700 Subject: [PATCH 1257/1963] Updated the soldeer version to 0.2.18 and added extra CLI tests (#8441) * Updated the soldeer version to 0.2.18 and added extra CLI tests * Forgot to push the root files * solving fmt * Updated git handling to match the rust way --- Cargo.lock | 4 +- Cargo.toml | 2 +- crates/config/src/soldeer.rs | 4 ++ crates/forge/bin/cmd/soldeer.rs | 3 + crates/forge/tests/cli/soldeer.rs | 98 +++++++++++++++++++++++++++++-- 5 files changed, 102 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9869a2658dd67..4619dbf0c16ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8057,9 +8057,9 @@ dependencies = [ [[package]] name = "soldeer" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef46372c17d5650cb18b7f374c45732334fa0867de6c7f14c1fc6973559cd3ff" +checksum = "d584c27ebf7ad3e2557d029a07b19fa0d192d67bd73eea1e1695936eb5666e34" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index a64a6688cbfab..f726796afe5d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,6 +260,6 @@ reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" # soldeer -soldeer = "0.2.17" +soldeer = "0.2.19" proptest = "1" diff --git a/crates/config/src/soldeer.rs b/crates/config/src/soldeer.rs index e5df0dcaf6a01..3bb8e9a3b74a8 100644 --- a/crates/config/src/soldeer.rs +++ b/crates/config/src/soldeer.rs @@ -13,6 +13,10 @@ pub struct MapDependency { /// The url from where the dependency was retrieved #[serde(default, skip_serializing_if = "Option::is_none")] pub url: Option, + + /// The commit in case git is used as dependency retrieval + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rev: Option, } /// Type for Soldeer configs, under dependencies tag in the foundry.toml diff --git a/crates/forge/bin/cmd/soldeer.rs b/crates/forge/bin/cmd/soldeer.rs index 52e1240a06e13..9c8579fe7a4e9 100644 --- a/crates/forge/bin/cmd/soldeer.rs +++ b/crates/forge/bin/cmd/soldeer.rs @@ -6,6 +6,9 @@ use soldeer::commands::Subcommands; // CLI arguments for `forge soldeer`. #[derive(Clone, Debug, Parser)] #[clap(override_usage = "forge soldeer install [DEPENDENCY]~[VERSION] + forge soldeer install [DEPENDENCY]~[VERSION] + forge soldeer install [DEPENDENCY]~[VERSION] --rev + forge soldeer install [DEPENDENCY]~[VERSION] --rev forge soldeer push [DEPENDENCY]~[VERSION] forge soldeer login forge soldeer update diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index cf1e0e5d34aa3..1a62578d1b67a 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -47,8 +47,96 @@ libs = ["lib"] forge-std = "1.8.1" "#; - let actual_foundry_contents = read_file_to_string(&foundry_file); - assert_eq!(foundry_contents, actual_foundry_contents); + assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); +}); + +forgesoldeer!(install_dependency_git, |prj, cmd| { + let command = "install"; + let dependency = "forge-std~1.8.1"; + let git = "git@gitlab.com:mario4582928/Mario.git"; + + let foundry_file = prj.root().join("foundry.toml"); + + cmd.arg("soldeer").args([command, dependency, git]); + cmd.execute(); + + // Making sure the path was created to the dependency and that README.md exists + // meaning that the dependencies were installed correctly + let path_dep_forge = prj.root().join("dependencies").join("forge-std-1.8.1").join("README.md"); + assert!(path_dep_forge.exists()); + + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + let lock_contents = r#" +[[dependencies]] +name = "forge-std" +version = "1.8.1" +source = "git@gitlab.com:mario4582928/Mario.git" +checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c" +"#; + + let actual_lock_contents = read_file_to_string(&path_lock_file); + assert_eq!(lock_contents, actual_lock_contents); + + // Making sure the foundry contents are the right ones + let foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + +[dependencies] +forge-std = { version = "1.8.1", git = "git@gitlab.com:mario4582928/Mario.git", rev = "22868f426bd4dd0e682b5ec5f9bd55507664240c" } +"#; + + assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); +}); + +forgesoldeer!(install_dependency_git_commit, |prj, cmd| { + let command = "install"; + let dependency = "forge-std~1.8.1"; + let git = "git@gitlab.com:mario4582928/Mario.git"; + let rev_flag = "--rev"; + let commit = "7a0663eaf7488732f39550be655bad6694974cb3"; + + let foundry_file = prj.root().join("foundry.toml"); + + cmd.arg("soldeer").args([command, dependency, git, rev_flag, commit]); + cmd.execute(); + + // Making sure the path was created to the dependency and that README.md exists + // meaning that the dependencies were installed correctly + let path_dep_forge = + prj.root().join("dependencies").join("forge-std-1.8.1").join("JustATest2.md"); + assert!(path_dep_forge.exists()); + + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + let lock_contents = r#" +[[dependencies]] +name = "forge-std" +version = "1.8.1" +source = "git@gitlab.com:mario4582928/Mario.git" +checksum = "7a0663eaf7488732f39550be655bad6694974cb3" +"#; + + let actual_lock_contents = read_file_to_string(&path_lock_file); + assert_eq!(lock_contents, actual_lock_contents); + + // Making sure the foundry contents are the right ones + let foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + +[dependencies] +forge-std = { version = "1.8.1", git = "git@gitlab.com:mario4582928/Mario.git", rev = "7a0663eaf7488732f39550be655bad6694974cb3" } +"#; + + assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); }); forgesoldeer!(update_dependencies, |prj, cmd| { @@ -101,8 +189,7 @@ libs = ["lib"] forge-std = { version = "1.8.1" } "#; - let actual_foundry_contents = read_file_to_string(&foundry_file); - assert_eq!(foundry_contents, actual_foundry_contents); + assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); }); forgesoldeer!(update_dependencies_simple_version, |prj, cmd| { @@ -156,8 +243,7 @@ libs = ["lib"] forge-std = "1.8.1" "#; - let actual_foundry_contents = read_file_to_string(&foundry_file); - assert_eq!(foundry_contents, actual_foundry_contents); + assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); }); forgesoldeer!(login, |prj, cmd| { From 3cbe211ea5ea1dde6922a234c70e5fe657b3bea1 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:57:44 +0100 Subject: [PATCH 1258/1963] fix(verify-bytecode): json print message with correct verification type (#8402) * fix(verify-bytecode): json print message with correct verification type * replace `input` of creation tx with local creation code before runtime match. --- crates/verify/src/bytecode.rs | 39 +++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 17bc65734fbfa..dfa8c31a96bb4 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -179,6 +179,7 @@ impl VerifyBytecodeArgs { // Get creation tx hash let creation_data = etherscan.contract_creation_data(self.address).await?; + trace!(creation_tx_hash = ?creation_data.transaction_hash); let mut transaction = provider .get_transaction_by_hash(creation_data.transaction_hash) .await @@ -237,6 +238,7 @@ impl VerifyBytecodeArgs { }; // Append constructor args to the local_bytecode + trace!(%constructor_args); let mut local_bytecode_vec = local_bytecode.to_vec(); local_bytecode_vec.extend_from_slice(&constructor_args); @@ -259,6 +261,21 @@ impl VerifyBytecodeArgs { &config, ); + // If the creation code does not match, the runtime also won't match. Hence return. + if !did_match { + self.print_result( + (did_match, with_status), + BytecodeType::Runtime, + &mut json_results, + etherscan_metadata, + &config, + ); + if self.json { + println!("{}", serde_json::to_string(&json_results)?); + } + return Ok(()); + } + // Get contract creation block let simulation_block = match self.block { Some(BlockId::Number(BlockNumberOrTag::Number(block))) => block, @@ -308,6 +325,20 @@ impl VerifyBytecodeArgs { env.block.gas_limit = U256::from(block.header.gas_limit); } + // Replace the `input` with local creation code in the creation tx. + if let Some(to) = transaction.to { + if to == DEFAULT_CREATE2_DEPLOYER { + let mut input = transaction.input[..32].to_vec(); // Salt + input.extend_from_slice(&local_bytecode_vec); + transaction.input = Bytes::from(input); + + // Deploy default CREATE2 deployer + executor.deploy_create2_deployer()?; + } + } else { + transaction.input = Bytes::from(local_bytecode_vec); + } + configure_tx_env(&mut env, &transaction); let env_with_handler = @@ -350,9 +381,9 @@ impl VerifyBytecodeArgs { let onchain_runtime_code = provider.get_code_at(self.address).block_id(BlockId::number(simulation_block)).await?; - // Compare the runtime bytecode with the locally built bytecode + // Compare the onchain runtime bytecode with the runtime code from the fork. let (did_match, with_status) = try_match( - fork_runtime_code.bytecode(), + &fork_runtime_code.original_bytes(), &onchain_runtime_code, &constructor_args, &verification_type, @@ -491,7 +522,7 @@ impl VerifyBytecodeArgs { let json_res = JsonResult { bytecode_type, matched: false, - verification_type: self.verification_type, + verification_type: res.1.unwrap(), message: Some(format!( "{bytecode_type:?} code did not match - this may be due to varying compiler settings" )), @@ -573,7 +604,7 @@ fn try_match( Ok((true, Some(VerificationType::Full))) } else { try_partial_match(local_bytecode, bytecode, constructor_args, is_runtime, has_metadata) - .map(|matched| (matched, matched.then_some(VerificationType::Partial))) + .map(|matched| (matched, Some(VerificationType::Partial))) } } From 4345e3e9771e4b222cfa7b83d6dc8035ff3e5d0a Mon Sep 17 00:00:00 2001 From: matthewliu10 <84545219+matthewliu10@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:42:49 -0400 Subject: [PATCH 1259/1963] feat: support absolute paths when matching paths (#7362) * added support for absolute paths when running forge test --match-path (#7350) * Changed how canonicalize() is called Co-authored-by: Arsenii Kulikov * optimize * upgrade tests to use snapbox * Update test_cmd.rs --------- Co-authored-by: Arsenii Kulikov Co-authored-by: zerosnacks Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/config/src/filter.rs | 32 +++++++++++++++-- crates/forge/tests/cli/test_cmd.rs | 55 ++++++++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 6 deletions(-) diff --git a/crates/config/src/filter.rs b/crates/config/src/filter.rs index 0d00b613f26fd..e2f542b67f130 100644 --- a/crates/config/src/filter.rs +++ b/crates/config/src/filter.rs @@ -56,6 +56,14 @@ impl GlobMatcher { return self.matcher.is_match(format!("./{}", path.display())); } + if path.is_relative() && Path::new(self.glob().glob()).is_absolute() { + if let Ok(canonicalized_path) = dunce::canonicalize(path) { + return self.matcher.is_match(&canonicalized_path); + } else { + return false; + } + } + false } @@ -218,9 +226,27 @@ mod tests { } #[test] - fn can_match_glob_paths() { + fn can_match_relative_glob_paths() { let matcher: GlobMatcher = "./test/*".parse().unwrap(); - assert!(matcher.is_match(Path::new("test/Contract.sol"))); - assert!(matcher.is_match(Path::new("./test/Contract.sol"))); + + // Absolute path that should match the pattern + assert!(matcher.is_match(Path::new("test/Contract.t.sol"))); + + // Relative path that should match the pattern + assert!(matcher.is_match(Path::new("./test/Contract.t.sol"))); + } + + #[test] + fn can_match_absolute_glob_paths() { + let matcher: GlobMatcher = "/home/user/projects/project/test/*".parse().unwrap(); + + // Absolute path that should match the pattern + assert!(matcher.is_match(Path::new("/home/user/projects/project/test/Contract.t.sol"))); + + // Absolute path that should not match the pattern + assert!(!matcher.is_match(Path::new("/home/user/other/project/test/Contract.t.sol"))); + + // Relative path that should not match an absolute pattern + assert!(!matcher.is_match(Path::new("projects/project/test/Contract.t.sol"))); } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 5608cc1c5e124..a3239e3f52ddd 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -155,7 +155,7 @@ forgetest!(can_test_with_match_path, |prj, cmd| { r#" import "./test.sol"; contract ATest is DSTest { - function testArray(uint64[2] calldata values) external { + function testPass() external { assertTrue(true); } } @@ -176,8 +176,57 @@ contract FailTest is DSTest { ) .unwrap(); - cmd.args(["test", "--match-path", "*src/ATest.t.sol"]); - assert!(cmd.stdout_lossy().contains("[PASS]") && !cmd.stdout_lossy().contains("[FAIL]")); + cmd.args(["test", "--match-path", "*src/ATest.t.sol"]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/ATest.t.sol:ATest +[PASS] testPass() (gas: 190) +... +Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) +... +"#]]); +}); + +// tests that using the --match-path option works with absolute paths +forgetest!(can_test_with_match_path_absolute, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source( + "ATest.t.sol", + r#" +import "./test.sol"; +contract ATest is DSTest { + function testPass() external { + assertTrue(true); + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "FailTest.t.sol", + r#" +import "./test.sol"; +contract FailTest is DSTest { + function testNothing() external { + assertTrue(false); + } +} + "#, + ) + .unwrap(); + + let test_path = prj.root().join("src/ATest.t.sol"); + let test_path = test_path.to_string_lossy(); + + cmd.args(["test", "--match-path", test_path.as_ref()]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/ATest.t.sol:ATest +[PASS] testPass() (gas: 190) +... +Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) +... +"#]]); }); // tests that `forge test` will pick up tests that are stored in the `test = ` config value From dafccd37a066e21b36e12f00a79122478e4f5164 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:26:06 +0300 Subject: [PATCH 1260/1963] feat(cast): improve to/from rlp (#8454) --- crates/cast/bin/opts.rs | 18 ++++++++++++++---- crates/cast/src/lib.rs | 2 +- crates/cast/src/rlp_converter.rs | 12 +++++++----- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index decd603748ba1..975ce2041aff1 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -259,18 +259,28 @@ pub enum CastSubcommand { }, /// RLP encodes hex data, or an array of hex data. + /// + /// Accepts a hex-encoded string, or an array of hex-encoded strings. + /// Can be arbitrarily recursive. + /// + /// Examples: + /// - `cast to-rlp "[]"` -> `0xc0` + /// - `cast to-rlp "0x22"` -> `0x22` + /// - `cast to-rlp "[\"0x61\"]"` -> `0xc161` + /// - `cast to-rlp "[\"0xf1\", \"f2\"]"` -> `0xc481f181f2` #[command(visible_aliases = &["--to-rlp"])] ToRlp { /// The value to convert. + /// + /// This is a hex-encoded string, or an array of hex-encoded strings. + /// Can be arbitrarily recursive. value: Option, }, - /// Decodes RLP encoded data. - /// - /// Input must be hexadecimal. + /// Decodes RLP hex-encoded data. #[command(visible_aliases = &["--from-rlp"])] FromRlp { - /// The value to convert. + /// The RLP hex-encoded data. value: Option, }, diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 836cfd94b9afc..e1a70b36c8324 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1355,7 +1355,7 @@ impl SimpleCast { /// assert_eq!(Cast::to_rlp("[]").unwrap(), "0xc0".to_string()); /// assert_eq!(Cast::to_rlp("0x22").unwrap(), "0x22".to_string()); /// assert_eq!(Cast::to_rlp("[\"0x61\"]",).unwrap(), "0xc161".to_string()); - /// assert_eq!(Cast::to_rlp("[\"0xf1\",\"f2\"]").unwrap(), "0xc481f181f2".to_string()); + /// assert_eq!(Cast::to_rlp("[\"0xf1\", \"f2\"]").unwrap(), "0xc481f181f2".to_string()); /// # Ok::<_, eyre::Report>(()) /// ``` pub fn to_rlp(value: &str) -> Result { diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index 0b90891ecdc4e..ad17874380468 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -1,5 +1,6 @@ -use alloy_primitives::hex; +use alloy_primitives::{hex, U256}; use alloy_rlp::{Buf, Decodable, Encodable, Header}; +use eyre::Context; use serde_json::Value; use std::fmt; @@ -49,11 +50,12 @@ impl Item { return match value { Value::Null => Ok(Self::Data(vec![])), Value::Bool(_) => { - eyre::bail!("RLP input should not contain booleans") + eyre::bail!("RLP input can not contain booleans") } - // If a value is passed without quotes we cast it to string - Value::Number(n) => Ok(Self::value_to_item(&Value::String(n.to_string()))?), - Value::String(s) => Ok(Self::Data(hex::decode(s).expect("Could not decode hex"))), + Value::Number(n) => { + Ok(Self::Data(n.to_string().parse::()?.to_be_bytes_trimmed_vec())) + } + Value::String(s) => Ok(Self::Data(hex::decode(s).wrap_err("Could not decode hex")?)), Value::Array(values) => values.iter().map(Self::value_to_item).collect(), Value::Object(_) => { eyre::bail!("RLP input can not contain objects") From cb9dfae298fe0b5a5cdef2536955f50b8c7f0bf5 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 17 Jul 2024 00:52:37 +0200 Subject: [PATCH 1261/1963] anvil/eth: Use the raw `v` signature value instead of `bool` (#7918) * anvil/eth: Use the raw `v` signature value instead of `bool` Instead of converting the boolean corresponding to the y parity byte to a u64/U256, use the raw `v` value for the `v` field when available. * anvil/eth: Use proper Parity signature in impersonate The correct `v` value must be used when using a dummy signature, depending on the transaction type (the Legacy transactions being the ones needing a special case). * anvil/eth: Use proper signature for creating txs This fixes wrong hash being computed for transactions. --------- Co-authored-by: zerosnacks --- crates/anvil/core/src/eth/transaction/mod.rs | 42 +++++++++----------- crates/anvil/src/eth/api.rs | 31 +++++++++++++-- crates/anvil/src/eth/backend/cheats.rs | 22 +--------- 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index dc758a52aad75..1084945de5afd 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -7,7 +7,9 @@ use alloy_consensus::{ TxEnvelope, TxLegacy, TxReceipt, TxType, }; use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; -use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64}; +use alloy_primitives::{ + Address, Bloom, Bytes, Log, Parity, Signature, TxHash, TxKind, B256, U256, U64, +}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, AnyTransactionReceipt, @@ -25,13 +27,6 @@ use std::ops::{Deref, Mul}; pub mod optimism; -/// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC -#[cfg(feature = "impersonated-tx")] -pub fn impersonated_signature() -> Signature { - Signature::from_scalars_and_parity(B256::with_last_byte(1), B256::with_last_byte(1), false) - .unwrap() -} - /// Converts a [TransactionRequest] into a [TypedTransactionRequest]. /// Should be removed once the call builder abstraction for providers is in place. pub fn transaction_request_to_typed( @@ -203,16 +198,23 @@ impl MaybeImpersonatedTransaction { self.transaction.recover() } + /// Returns whether the transaction is impersonated + /// + /// Note: this is feature gated so it does not conflict with the `Deref`ed + /// [TypedTransaction::hash] function by default. + #[cfg(feature = "impersonated-tx")] + pub fn is_impersonated(&self) -> bool { + self.impersonated_sender.is_some() + } + /// Returns the hash of the transaction /// /// Note: this is feature gated so it does not conflict with the `Deref`ed /// [TypedTransaction::hash] function by default. #[cfg(feature = "impersonated-tx")] pub fn hash(&self) -> B256 { - if self.transaction.is_impersonated() { - if let Some(sender) = self.impersonated_sender { - return self.transaction.impersonated_hash(sender); - } + if let Some(sender) = self.impersonated_sender { + return self.transaction.impersonated_hash(sender) } self.transaction.hash() } @@ -288,7 +290,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), - v: U256::from(t.signature().v().y_parity_byte()), + v: U256::from(t.signature().v().to_u64()), y_parity: None, }), access_list: None, @@ -315,7 +317,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), - v: U256::from(t.signature().v().y_parity_byte()), + v: U256::from(t.signature().v().to_u64()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), access_list: Some(t.tx().access_list.clone()), @@ -342,7 +344,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), - v: U256::from(t.signature().v().y_parity_byte()), + v: U256::from(t.signature().v().to_u64()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), access_list: Some(t.tx().access_list.clone()), @@ -369,7 +371,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( signature: Some(RpcSignature { r: t.signature().r(), s: t.signature().s(), - v: U256::from(t.signature().v().y_parity_byte()), + v: U256::from(t.signature().v().to_u64()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), access_list: Some(t.tx().tx().access_list.clone()), @@ -832,12 +834,6 @@ impl TypedTransaction { } } - /// Returns true if the transaction was impersonated (using the impersonate Signature) - #[cfg(feature = "impersonated-tx")] - pub fn is_impersonated(&self) -> bool { - self.signature() == impersonated_signature() - } - /// Returns the hash if the transaction is impersonated (using a fake signature) /// /// This appends the `address` before hashing it @@ -886,7 +882,7 @@ impl TypedTransaction { Self::Deposit(_) => Signature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), - false, + Parity::Parity(false), ) .unwrap(), } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 346fb27bd1dd4..150e54b068b96 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -35,7 +35,7 @@ use alloy_consensus::{transaction::eip4844::TxEip4844Variant, TxEnvelope}; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; use alloy_network::eip2718::Decodable2718; -use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, B64, U256, U64}; +use alloy_primitives::{Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64}; use alloy_rpc_types::{ anvil::{ ForkedNetwork, Forking, Metadata, MineOptions, NodeEnvironment, NodeForkConfig, NodeInfo, @@ -52,6 +52,7 @@ use alloy_rpc_types::{ Transaction, }; use alloy_serde::WithOtherFields; +use alloy_signer::Signature; use alloy_transport::TransportErrorKind; use anvil_core::{ eth::{ @@ -448,7 +449,7 @@ impl EthApi { alloy_primitives::Signature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), - false, + Parity::Parity(false), ) .unwrap(); return build_typed_transaction(request, nil_signature) @@ -937,7 +938,7 @@ impl EthApi { // if the sender is currently impersonated we need to "bypass" signing let pending_transaction = if self.is_impersonated(from) { - let bypass_signature = self.backend.cheats().bypass_signature(); + let bypass_signature = self.impersonated_signature(&request); let transaction = sign::build_typed_transaction(request, bypass_signature)?; self.ensure_typed_transaction_supported(&transaction)?; trace!(target : "node", ?from, "eth_sendTransaction: impersonating"); @@ -2084,7 +2085,7 @@ impl EthApi { let request = self.build_typed_tx_request(request, nonce)?; - let bypass_signature = self.backend.cheats().bypass_signature(); + let bypass_signature = self.impersonated_signature(&request); let transaction = sign::build_typed_transaction(request, bypass_signature)?; self.ensure_typed_transaction_supported(&transaction)?; @@ -2581,6 +2582,28 @@ impl EthApi { self.backend.cheats().is_impersonated(addr) } + /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC + fn impersonated_signature(&self, request: &TypedTransactionRequest) -> Signature { + match request { + // Only the legacy transaction type requires v to be in {27, 28}, thus + // requiring the use of Parity::NonEip155 + TypedTransactionRequest::Legacy(_) => Signature::from_scalars_and_parity( + B256::with_last_byte(1), + B256::with_last_byte(1), + Parity::NonEip155(false), + ), + TypedTransactionRequest::EIP2930(_) | + TypedTransactionRequest::EIP1559(_) | + TypedTransactionRequest::EIP4844(_) | + TypedTransactionRequest::Deposit(_) => Signature::from_scalars_and_parity( + B256::with_last_byte(1), + B256::with_last_byte(1), + Parity::Parity(false), + ), + } + .unwrap() + } + /// Returns the nonce of the `address` depending on the `block_number` async fn get_transaction_count( &self, diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index dbc58670f62f3..5b498f963c845 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -1,7 +1,6 @@ //! Support for "cheat codes" / bypass functions -use alloy_primitives::{Address, Signature}; -use anvil_core::eth::transaction::impersonated_signature; +use alloy_primitives::Address; use parking_lot::RwLock; use std::{collections::HashSet, sync::Arc}; @@ -48,11 +47,6 @@ impl CheatsManager { } } - /// Returns the signature to use to bypass transaction signing - pub fn bypass_signature(&self) -> Signature { - self.state.read().bypass_signature - } - /// Sets the auto impersonation flag which if set to true will make the `is_impersonated` /// function always return true pub fn set_auto_impersonate_account(&self, enabled: bool) { @@ -67,22 +61,10 @@ impl CheatsManager { } /// Container type for all the state variables -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct CheatsState { /// All accounts that are currently impersonated pub impersonated_accounts: HashSet
, - /// The signature used for the `eth_sendUnsignedTransaction` cheat code - pub bypass_signature: Signature, /// If set to true will make the `is_impersonated` function always return true pub auto_impersonate_accounts: bool, } - -impl Default for CheatsState { - fn default() -> Self { - Self { - impersonated_accounts: Default::default(), - bypass_signature: impersonated_signature(), - auto_impersonate_accounts: false, - } - } -} From 65b3cb031336bccbfe7c32c26b8869d1b8654f68 Mon Sep 17 00:00:00 2001 From: rakita Date: Wed, 17 Jul 2024 14:20:41 +0200 Subject: [PATCH 1262/1963] feat(EOF): enable EOF inspector (#8305) * feat(EOF): enable EOF inspector * fmt nightly * bump inspectors * update revm * fix test * rm compilers patch * bump alloy and revm (#8460) * bump alloy and revm * fix test * rm patch * update lock --------- Co-authored-by: Arsenii Kulikov --- Cargo.lock | 197 ++++++++++++------ Cargo.toml | 52 ++--- crates/anvil/core/src/eth/transaction/mod.rs | 13 +- crates/anvil/src/eth/api.rs | 4 +- crates/anvil/src/eth/backend/db.rs | 2 +- crates/anvil/src/eth/backend/mem/inspector.rs | 4 +- crates/anvil/src/eth/backend/mem/mod.rs | 6 +- crates/anvil/src/eth/backend/mem/state.rs | 2 +- crates/anvil/tests/it/optimism.rs | 8 +- crates/anvil/tests/it/otterscan.rs | 12 +- crates/cheatcodes/Cargo.toml | 1 - crates/cheatcodes/src/inspector.rs | 39 ++-- crates/cheatcodes/src/test/assert.rs | 2 +- crates/common/fmt/src/ui.rs | 8 +- crates/config/src/lib.rs | 2 +- crates/debugger/src/tui/draw.rs | 1 + crates/evm/core/src/backend/cow.rs | 4 +- crates/evm/core/src/backend/in_memory_db.rs | 6 +- crates/evm/core/src/backend/mod.rs | 4 +- crates/evm/core/src/fork/database.rs | 8 +- crates/evm/core/src/lib.rs | 3 + crates/evm/core/src/utils.rs | 17 +- crates/evm/evm/src/executors/mod.rs | 1 + crates/evm/evm/src/inspectors/logs.rs | 17 +- crates/evm/evm/src/inspectors/stack.rs | 61 ++++-- crates/forge/src/gas_report.rs | 5 +- crates/forge/tests/cli/config.rs | 2 +- 27 files changed, 288 insertions(+), 193 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4619dbf0c16ef..0ce89dfa8d907 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da374e868f54c7f4ad2ad56829827badca388efd645f8cf5fccc61c2b5343504" +checksum = "f58047cc851e58c26224521d1ecda466e3d746ebca0274cd5427aa660a88c353" dependencies = [ "alloy-eips", "alloy-primitives", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dc6957ff706f9e5f6fd42f52a93e4bce476b726c92d077b348de28c4a76730c" +checksum = "fa5d42d9f87896536234b0fac1a84ad9d9dc7a4b27839cac35d0899e64ddf083" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -134,15 +134,17 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76ecab54890cdea1e4808fc0891c7e6cfcf71fe1a9fe26810c7280ef768f4ed" +checksum = "d32a3e14fa0d152d00bd8daf605eb74ad397efb0f54bd7155585823dddb4401e" dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-serde", + "arbitrary", "c-kzg", "derive_more", + "k256", "once_cell", "serde", "sha2", @@ -150,9 +152,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca15afde1b6d15e3fc1c97421262b1bbb37aee45752e3c8b6d6f13f776554ff" +checksum = "20cb76c8a3913f2466c5488f3a915e3a15d15596bdc935558c1a9be75e9ec508" dependencies = [ "alloy-primitives", "alloy-serde", @@ -173,9 +175,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d6f34930b7e3e2744bcc79056c217f00cb2abb33bc5d4ff88da7623c5bb078b" +checksum = "0e76a9feec2352c78545d1a37415699817bae8dc41654bd1bfe57d6cdd5433bd" dependencies = [ "alloy-primitives", "serde", @@ -186,9 +188,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f6895fc31b48fa12306ef9b4f78b7764f8bd6d7d91cdb0a40e233704a0f23f" +checksum = "3223d71dc78f464b2743418d0be8b5c894313e272105a6206ad5e867d67b3ce2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -233,9 +235,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c538bfa893d07e27cb4f3c1ab5f451592b7c526d511d62b576a2ce59e146e4a" +checksum = "f29da7457d853cb8199ec04b227d5d2ef598be3e59fc2bbad70c8be213292f32" dependencies = [ "alloy-chains", "alloy-consensus", @@ -270,9 +272,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a7341322d9bc0e49f6e9fd9f2eb8e30f73806f2dd12cbb3d6bab2694c921f87" +checksum = "f64acfec654ade392cecfa9bba0408eb2a337d55f1b857925da79970cb70f3d6" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -311,9 +313,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba31bae67773fd5a60020bea900231f8396202b7feca4d0c70c6b59308ab4a8" +checksum = "f8a9e609524fa31c2c70eb24c0da60796809193ad4787a6dfe6d0db0d3ac112d" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -336,9 +338,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "184a7a42c7ba9141cc9e76368356168c282c3bc3d9e5d78f3556bdfe39343447" +checksum = "7e5d76f1e8b22f48b7b8f985782b68e7eb3938780e50e8b646a53e41a598cdf5" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -346,13 +348,14 @@ dependencies = [ "alloy-rpc-types-trace", "alloy-rpc-types-txpool", "alloy-serde", + "serde", ] [[package]] name = "alloy-rpc-types-anvil" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7cf4356a9d00df76d6e90d002e2a7b5edc1c8476e90e6f17ab868d99db6435" +checksum = "4282c002a4ae9f57887dae57083fcca6dca09cb6685bf98b8582ea93cb3df97d" dependencies = [ "alloy-primitives", "alloy-serde", @@ -361,9 +364,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e765962e3b82fd6f276a0873b5bd897e5d75a25f78fa9a6a21bd350d8e98a4e" +checksum = "73445fbc5c02258e3d0d977835c92366a4d91545fd456c3fc8601c61810bc9f6" dependencies = [ "alloy-consensus", "alloy-eips", @@ -379,9 +382,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4123ee21f99ba4bd31bfa36ba89112a18a500f8b452f02b35708b1b951e2b9" +checksum = "605fa8462732bb8fd0645a9941e12961e079d45ae6a44634c826f8229c187bdf" dependencies = [ "alloy-consensus", "alloy-eips", @@ -397,9 +400,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567933b1d95fd42cb70b75126e32afec2e5e2c3c16e7100a3f83dc1c80f4dc0e" +checksum = "5f561a8cdd377b6ac3beab805b9df5ec2c7d99bb6139aab23c317f26df6fb346" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -411,9 +414,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3115f4eb1bb9ae9aaa0b24ce875a1d86d6689b16438a12377832def2b09e373c" +checksum = "c06a4bd39910631c11148c5b2c55e2c61f8626affd2a612e382c668d5e5971ce" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -423,20 +426,21 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9416c52959e66ead795a11f4a86c248410e9e368a0765710e57055b8a1774dd6" +checksum = "15c5b9057acc02aee1b8aac2b5a0729cb0f73d080082c111313e5d1f92a96630" dependencies = [ "alloy-primitives", + "arbitrary", "serde", "serde_json", ] [[package]] name = "alloy-signer" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b33753c09fa1ad85e5b092b8dc2372f1e337a42e84b9b4cff9fede75ba4adb32" +checksum = "37f10592696f4ab8b687d5a8ab55e998a14ea0ca5f8eb20ad74a96ad671bb54a" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -450,9 +454,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63ce17bfd5aa38e14b9c83b553d93c76e1bd5641a2db45f381f81619fd3e54ca" +checksum = "49300a7aecbd28c364fbad6a9f886264f79ff4fed9a67c8caa27c39f99d52b2d" dependencies = [ "alloy-consensus", "alloy-network", @@ -468,9 +472,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2804c1d4fae0341195def6c5eb6efc65756cdf8cd3c0087ad2afff7972f8a115" +checksum = "5ce638c267429ea7513be9fffc47d949d1f425a33c8813fc6a145e03b999e79f" dependencies = [ "alloy-consensus", "alloy-network", @@ -486,9 +490,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "575e4c924b23132234c75bd1f8f3871c1bc12ba462f76af9b59249515a38253e" +checksum = "5a9450ae05631ac2a5eb180d91d7162bf71ea7a2bb6833cc7c25997e5a11dc38" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -506,9 +510,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dfc9c26fe6c6f1bad818c9a976de9044dd12e1f75f1f156a801ee3e8148c1b6" +checksum = "0b537f3e55f30753578f4623d5f66ddad8fa582af3fa6b15bad23dd1b9775228" dependencies = [ "alloy-consensus", "alloy-network", @@ -526,9 +530,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd82e86e4a6604fd11f84b170638d16dcdac9db6c2b5f5b91a3941b7e7af7f94" +checksum = "c6efa624373339e7cbdd597a785a69c5fcbc10d5368797a18b7cb3476eadf8c9" dependencies = [ "alloy-consensus", "alloy-network", @@ -616,9 +620,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01b51a291f949f755e6165c3ed562883175c97423703703355f4faa4b7d0a57c" +checksum = "5b44b0f6f4a2593b258fa7b6cae8968e6a4c404d9ef4f5bc74401f2d04fa23fa" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -635,9 +639,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d65871f9f1cafe1ed25cde2f1303be83e6473e995a2d56c275ae4fcce6119c" +checksum = "6d8f1eefa8cb9e7550740ee330feba4fed303a77ad3085707546f9152a88c380" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -650,9 +654,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7fbc8b6282ce41b01cbddef7bffb133fe6e1bf65dcd39770d45a905c051179" +checksum = "31007c56dc65bd81392112dda4a14c20ac7e30bb4cb2e9176192e8d9fab1983f" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -671,9 +675,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aec83fd052684556c78c54df111433493267234d82321c2236560c752f595f20" +checksum = "15ccc1c8f8ae415e93ec0e7851bd4cdf4afdd48793d13a91b860317da1f36104" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1723,6 +1727,19 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +dependencies = [ + "ff", + "group", + "pairing", + "rand_core", + "subtle", +] + [[package]] name = "blst" version = "0.3.12" @@ -3210,6 +3227,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ + "bitvec", "rand_core", "subtle", ] @@ -3561,7 +3579,6 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", - "foundry-evm-abi", "foundry-evm-core", "foundry-wallets", "itertools 0.13.0", @@ -4000,9 +4017,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3f9c9e02b19933218eb39c7234dcb0cc20e461258ced030f6fd6ac254a8637" +checksum = "734f01574b6804ed6985d042684235c6c1007228eff8b2b488c260e3caf742d5" dependencies = [ "alloy-primitives", "alloy-provider", @@ -5297,6 +5314,21 @@ dependencies = [ "libc", ] +[[package]] +name = "kzg-rs" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9920cd4460ce3cbca19c62f3bb9a9611562478a4dc9d2c556f4a7d049c5b6b" +dependencies = [ + "bls12_381", + "glob", + "hex", + "once_cell", + "serde", + "serde_derive", + "serde_yaml", +] + [[package]] name = "lalrpop" version = "0.20.2" @@ -6030,6 +6062,15 @@ dependencies = [ "sha2", ] +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -7060,9 +7101,9 @@ dependencies = [ [[package]] name = "revm" -version = "10.0.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355bde4e21578c241f9379fbb344a73d254969b5007239115e094dda1511cd34" +checksum = "c6cfb48bce8ca2113e157bdbddbd5eeb09daac1c903d79ec17085897c38c7c91" dependencies = [ "auto_impl", "cfg-if", @@ -7075,9 +7116,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.3.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3aede4aaaa0c5b446ce1a951629d7929ea48473a0f307bd8d999ecdeb55c420b" +checksum = "d485a7ccfbbcaf2d0c08c3d866dae279c6f71d7357862cbea637f23f27b7b695" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7092,9 +7133,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "6.0.0" +version = "8.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dfd24faa3cbbd96e0976103d1e174d6559b8036730f70415488ee21870d578" +checksum = "e6b0daddea06fc6da5346acc39b32a357bbe3579e9e3d94117d9ae125cd596fc" dependencies = [ "revm-primitives", "serde", @@ -7102,13 +7143,14 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "8.0.0" +version = "9.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c669c9b105dbb41133c17bf7f34d29368e358a7fee8fcc289e90dbfb024dfc4" +checksum = "ef55228211251d7b6c7707c3ee13bb70dea4d2fd81ec4034521e4fe31010b2ea" dependencies = [ "aurora-engine-modexp", "blst", "c-kzg", + "cfg-if", "k256", "once_cell", "p256", @@ -7121,10 +7163,11 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "5.0.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "902184a7a781550858d4b96707098da357429f1e4545806fd5b589f455555cf2" +checksum = "2fc4311037ee093ec50ec734e1424fcb3e12d535c6cef683b75d1c064639630c" dependencies = [ + "alloy-eips", "alloy-primitives", "auto_impl", "bitflags 2.6.0", @@ -7136,6 +7179,7 @@ dependencies = [ "enumn", "hashbrown 0.14.5", "hex", + "kzg-rs", "once_cell", "serde", ] @@ -7792,6 +7836,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.2.6", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "serial_test" version = "3.1.1" @@ -8892,9 +8949,9 @@ dependencies = [ [[package]] name = "trezor-client" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f62c95b37f6c769bd65a0d0beb8b2b003e72998003b896a616a6777c645c05ed" +checksum = "10636211ab89c96ed2824adc5ec0d081e1080aeacc24c37abb318dcb31dcc779" dependencies = [ "byteorder", "hex", @@ -9054,6 +9111,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "untrusted" version = "0.9.0" diff --git a/Cargo.toml b/Cargo.toml index f726796afe5d8..02a78a204a86f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,41 +159,41 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.5.0", default-features = false } foundry-compilers = { version = "0.9.0", default-features = false } -foundry-fork-db = "0.1" +foundry-fork-db = "0.2" solang-parser = "=0.3.3" ## revm # no default features to avoid c-kzg -revm = { version = "10.0.0", default-features = false } -revm-primitives = { version = "5.0.0", default-features = false } -revm-inspectors = { version = "0.3", features = ["serde"] } +revm = { version = "12.1.0", default-features = false } +revm-primitives = { version = "7.1.0", default-features = false } +revm-inspectors = { version = "0.5", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.1.4", default-features = false } -alloy-contract = { version = "0.1.4", default-features = false } -alloy-eips = { version = "0.1.4", default-features = false } -alloy-genesis = { version = "0.1.4", default-features = false } -alloy-json-rpc = { version = "0.1.4", default-features = false } -alloy-network = { version = "0.1.4", default-features = false } -alloy-node-bindings = { version = "0.1.4", default-features = false } -alloy-provider = { version = "0.1.4", default-features = false } -alloy-pubsub = { version = "0.1.4", default-features = false } -alloy-rpc-client = { version = "0.1.4", default-features = false } -alloy-rpc-types = { version = "0.1.4", default-features = false } -alloy-serde = { version = "0.1.4", default-features = false } -alloy-signer = { version = "0.1.4", default-features = false } -alloy-signer-aws = { version = "0.1.4", default-features = false } -alloy-signer-gcp = { version = "0.1.4", default-features = false } -alloy-signer-ledger = { version = "0.1.4", default-features = false } -alloy-signer-local = { version = "0.1.4", default-features = false } -alloy-signer-trezor = { version = "0.1.4", default-features = false } -alloy-transport = { version = "0.1.4", default-features = false } -alloy-transport-http = { version = "0.1.4", default-features = false } -alloy-transport-ipc = { version = "0.1.4", default-features = false } -alloy-transport-ws = { version = "0.1.4", default-features = false } +alloy-consensus = { version = "0.2.0", default-features = false } +alloy-contract = { version = "0.2.0", default-features = false } +alloy-eips = { version = "0.2.0", default-features = false } +alloy-genesis = { version = "0.2.0", default-features = false } +alloy-json-rpc = { version = "0.2.0", default-features = false } +alloy-network = { version = "0.2.0", default-features = false } +alloy-node-bindings = { version = "0.2.0", default-features = false } +alloy-provider = { version = "0.2.0", default-features = false } +alloy-pubsub = { version = "0.2.0", default-features = false } +alloy-rpc-client = { version = "0.2.0", default-features = false } +alloy-rpc-types = { version = "0.2.0", default-features = false } +alloy-serde = { version = "0.2.0", default-features = false } +alloy-signer = { version = "0.2.0", default-features = false } +alloy-signer-aws = { version = "0.2.0", default-features = false } +alloy-signer-gcp = { version = "0.2.0", default-features = false } +alloy-signer-ledger = { version = "0.2.0", default-features = false } +alloy-signer-local = { version = "0.2.0", default-features = false } +alloy-signer-trezor = { version = "0.2.0", default-features = false } +alloy-transport = { version = "0.2.0", default-features = false } +alloy-transport-http = { version = "0.2.0", default-features = false } +alloy-transport-ipc = { version = "0.2.0", default-features = false } +alloy-transport-ws = { version = "0.2.0", default-features = false } alloy-dyn-abi = "0.7.7" alloy-json-abi = "0.7.7" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 1084945de5afd..509e8327eedb2 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -298,6 +298,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( max_fee_per_blob_gas: None, blob_versioned_hashes: None, other: Default::default(), + authorization_list: None, }, TypedTransaction::EIP2930(t) => RpcTransaction { hash, @@ -325,6 +326,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( max_fee_per_blob_gas: None, blob_versioned_hashes: None, other: Default::default(), + authorization_list: None, }, TypedTransaction::EIP1559(t) => RpcTransaction { hash, @@ -352,6 +354,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( max_fee_per_blob_gas: None, blob_versioned_hashes: None, other: Default::default(), + authorization_list: None, }, TypedTransaction::EIP4844(t) => RpcTransaction { hash, @@ -379,6 +382,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas), blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), other: Default::default(), + authorization_list: None, }, TypedTransaction::Deposit(t) => RpcTransaction { hash, @@ -401,6 +405,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( max_fee_per_blob_gas: None, blob_versioned_hashes: None, other: Default::default(), + authorization_list: None, }, } } @@ -496,7 +501,7 @@ impl PendingTransaction { gas_price: U256::from(*gas_price), gas_priority_fee: None, gas_limit: *gas_limit as u64, - access_list: access_list.flattened(), + access_list: access_list.clone().into(), ..Default::default() } } @@ -523,7 +528,7 @@ impl PendingTransaction { gas_price: U256::from(*max_fee_per_gas), gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), gas_limit: *gas_limit as u64, - access_list: access_list.flattened(), + access_list: access_list.clone().into(), ..Default::default() } } @@ -554,7 +559,7 @@ impl PendingTransaction { max_fee_per_blob_gas: Some(U256::from(*max_fee_per_blob_gas)), blob_hashes: blob_versioned_hashes.clone(), gas_limit: *gas_limit as u64, - access_list: access_list.flattened(), + access_list: access_list.clone().into(), ..Default::default() } } @@ -1459,6 +1464,7 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option Option TypedReceipt::Legacy(receipt_with_bloom), 0x01 => TypedReceipt::EIP2930(receipt_with_bloom), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 150e54b068b96..fe7ebeaa24093 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2766,7 +2766,9 @@ impl TryFrom, u128, State)>> for GasEs InstructionResult::OpcodeNotFound | InstructionResult::CallNotAllowedInsideStatic | InstructionResult::StateChangeDuringStaticCall | - InstructionResult::InvalidEFOpcode | + InstructionResult::InvalidExtDelegateCallTarget | + InstructionResult::InvalidEXTCALLTarget | + InstructionResult::InvalidFEOpcode | InstructionResult::InvalidJump | InstructionResult::NotActivated | InstructionResult::StackUnderflow | diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 48b0eaaf5b139..fb9b6078204b8 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -291,7 +291,7 @@ impl DatabaseRef for StateDb { self.0.storage_ref(address, index) } - fn block_hash_ref(&self, number: U256) -> DatabaseResult { + fn block_hash_ref(&self, number: u64) -> DatabaseResult { self.0.block_hash_ref(number) } } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 43ba00810b944..68336935f4bb7 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -78,9 +78,9 @@ impl revm::Inspector for Inspector { }); } - fn log(&mut self, ecx: &mut EvmContext, log: &Log) { + fn log(&mut self, interp: &mut Interpreter, ecx: &mut EvmContext, log: &Log) { call_inspectors!([&mut self.tracer, &mut self.log_collector], |inspector| { - inspector.log(ecx, log); + inspector.log(interp, ecx, log); }); } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index cf7cf6f9fe373..f89ba6a50568d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1156,9 +1156,10 @@ impl Backend { data: input.into_input().unwrap_or_default(), chain_id: None, nonce, - access_list: access_list.unwrap_or_default().flattened(), + access_list: access_list.unwrap_or_default().into(), blob_hashes: blob_versioned_hashes.unwrap_or_default(), optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, + authorization_list: None, }; if env.block.basefee.is_zero() { @@ -2110,6 +2111,7 @@ impl Backend { state_root: Some(block.header.state_root), blob_gas_price: Some(blob_gas_price), blob_gas_used, + authorization_list: None, }; Some(MinedTransactionReceipt { inner, out: info.out.map(|o| o.0.into()) }) @@ -2261,7 +2263,7 @@ impl Backend { let account_proof = AccountProof { address, balance: account.info.balance, - nonce: U64::from(account.info.nonce), + nonce: account.info.nonce, code_hash: account.info.code_hash, storage_hash: storage_root(&account.storage), account_proof: proof, diff --git a/crates/anvil/src/eth/backend/mem/state.rs b/crates/anvil/src/eth/backend/mem/state.rs index dd52eedfa0e44..9d66fac289dec 100644 --- a/crates/anvil/src/eth/backend/mem/state.rs +++ b/crates/anvil/src/eth/backend/mem/state.rs @@ -83,7 +83,7 @@ where let mut account_info = cache_db.basic_ref(*account)?.unwrap_or_default(); if let Some(nonce) = account_overrides.nonce { - account_info.nonce = nonce.to::(); + account_info.nonce = nonce; } if let Some(code) = &account_overrides.code { account_info.code = Some(Bytecode::new_raw(code.to_vec().into())); diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 3406e686526ca..c355d11e889dc 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -3,7 +3,7 @@ use crate::utils::http_provider_with_signer; use alloy_eips::eip2718::Encodable2718; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{b256, U128, U256}; +use alloy_primitives::{b256, U256}; use alloy_provider::Provider; use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -29,7 +29,7 @@ async fn test_deposits_not_supported_if_optimism_disabled() { source_hash: Some(b256!( "0000000000000000000000000000000000000000000000000000000000000000" )), - mint: Some(U128::from(0)), + mint: Some(0), is_system_tx: Some(true), } .into(), @@ -67,7 +67,7 @@ async fn test_send_value_deposit_transaction() { source_hash: Some(b256!( "0000000000000000000000000000000000000000000000000000000000000000" )), - mint: Some(U128::from(0)), + mint: Some(0), is_system_tx: Some(true), } .into(), @@ -119,7 +119,7 @@ async fn test_send_value_raw_deposit_transaction() { source_hash: Some(b256!( "0000000000000000000000000000000000000000000000000000000000000000" )), - mint: Some(U128::from(0)), + mint: Some(0), is_system_tx: Some(true), } .into(), diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 37da4f00006e5..d0536a0326d7e 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -5,7 +5,7 @@ use alloy_primitives::{address, Address, Bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ trace::otterscan::{InternalOperation, OperationType, TraceEntry}, - BlockNumberOrTag, BlockTransactions, TransactionRequest, + BlockNumberOrTag, TransactionRequest, }; use alloy_serde::WithOtherFields; use alloy_sol_types::{sol, SolCall, SolError, SolValue}; @@ -331,13 +331,11 @@ async fn ots_get_block_details() { let tx = TransactionRequest::default().to(Address::random()).value(U256::from(100)); let tx = WithOtherFields::new(tx); - let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let result = api.ots_get_block_details(1.into()).await.unwrap(); assert_eq!(result.block.transaction_count, 1); - let hash = result.block.block.transactions.hashes().next().unwrap(); - assert_eq!(*hash, receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] @@ -353,12 +351,6 @@ async fn ots_get_block_details_by_hash() { let result = api.ots_get_block_details_by_hash(block_hash).await.unwrap(); assert_eq!(result.block.transaction_count, 1); - let hash = match result.block.block.transactions { - BlockTransactions::Full(txs) => txs[0].hash, - BlockTransactions::Hashes(hashes) => hashes[0], - BlockTransactions::Uncle => unreachable!(), - }; - assert_eq!(hash, receipt.transaction_hash); } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index f04254b1812b6..93636c3f2f6d3 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -21,7 +21,6 @@ foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm-core.workspace = true foundry-wallets.workspace = true -foundry-evm-abi.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 91d6df148cb75..4a95fb75d8386 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -21,7 +21,6 @@ use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolCall, SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, SELECTOR_LEN}; use foundry_config::Config; -use foundry_evm_abi::Console; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseExt, RevertDiagnostic}, @@ -92,6 +91,7 @@ pub trait CheatcodesExecutor { db: &mut ccx.ecx.db as &mut dyn DatabaseExt, error, l1_block_info, + valid_authorizations: std::mem::take(&mut ccx.ecx.valid_authorizations), }; let mut evm = new_evm_with_existing_context(inner, &mut inspector as _); @@ -102,6 +102,7 @@ pub trait CheatcodesExecutor { ccx.ecx.env = evm.context.evm.inner.env; ccx.ecx.l1_block_info = evm.context.evm.inner.l1_block_info; ccx.ecx.error = evm.context.evm.inner.error; + ccx.ecx.valid_authorizations = evm.context.evm.inner.valid_authorizations; Ok(res) } @@ -136,19 +137,8 @@ pub trait CheatcodesExecutor { }) } - fn console_log( - &mut self, - ccx: &mut CheatsCtxt, - message: String, - ) -> Result<(), EVMError> { - self.with_evm(ccx, |evm| { - let log = - Log { address: CHEATCODE_ADDRESS, data: (&Console::log { val: message }).into() }; - - evm.context.external.log(&mut evm.context.evm, &log); - - Ok(()) - }) + fn console_log(&mut self, ccx: &mut CheatsCtxt, message: String) { + self.get_inspector::(ccx.state).console_log(message); } } @@ -499,7 +489,7 @@ impl Cheatcodes { gas, }, address: None, - }) + }); } ecx.env.tx.caller = broadcast.new_origin; @@ -730,7 +720,7 @@ impl Cheatcodes { let ecx = &mut ecx.inner; if call.target_address == HARDHAT_CONSOLE_ADDRESS { - return None + return None; } // Handle expected calls @@ -779,7 +769,7 @@ impl Cheatcodes { gas, }, memory_offset: call.return_memory_offset.clone(), - }) + }); } } @@ -837,7 +827,7 @@ impl Cheatcodes { gas, }, memory_offset: call.return_memory_offset.clone(), - }) + }); } let is_fixed_gas_limit = check_if_fixed_gas_limit(ecx, call.gas_limit); @@ -879,7 +869,7 @@ impl Cheatcodes { gas, }, memory_offset: call.return_memory_offset.clone(), - }) + }); } } } @@ -902,6 +892,9 @@ impl Cheatcodes { CallScheme::CallCode => crate::Vm::AccountAccessKind::CallCode, CallScheme::DelegateCall => crate::Vm::AccountAccessKind::DelegateCall, CallScheme::StaticCall => crate::Vm::AccountAccessKind::StaticCall, + CallScheme::ExtCall => crate::Vm::AccountAccessKind::Call, + CallScheme::ExtStaticCall => crate::Vm::AccountAccessKind::StaticCall, + CallScheme::ExtDelegateCall => crate::Vm::AccountAccessKind::DelegateCall, }; // Record this call by pushing it to a new pending vector; all subsequent calls at // that depth will be pushed to the same vector. When the call ends, the @@ -975,7 +968,7 @@ impl Inspector for Cheatcodes { } } - fn log(&mut self, _context: &mut EvmContext, log: &Log) { + fn log(&mut self, _interpreter: &mut Interpreter, _context: &mut EvmContext, log: &Log) { if !self.expected_emits.is_empty() { expect::handle_expect_emit(self, log); } @@ -1086,7 +1079,7 @@ impl Inspector for Cheatcodes { // Exit early for calls to cheatcodes as other logic is not relevant for cheatcode // invocations if cheatcode_call { - return outcome + return outcome; } // Record the gas usage of the call, this allows the `lastCallGas` cheatcode to @@ -1161,7 +1154,7 @@ impl Inspector for Cheatcodes { if self.expected_emits.iter().any(|expected| !expected.found) { outcome.result.result = InstructionResult::Revert; outcome.result.output = "log != expected log".abi_encode().into(); - return outcome + return outcome; } else { // All emits were found, we're good. // Clear the queue, as we expect the user to declare more events for the next call @@ -1179,7 +1172,7 @@ impl Inspector for Cheatcodes { if outcome.result.is_revert() { if let Some(err) = diag { outcome.result.output = Error::encode(err.to_error_msg(&self.labels)); - return outcome + return outcome; } } diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index 3f85b6e5c1c66..4ab97c031e5a8 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -189,7 +189,7 @@ fn handle_assertion_result( if ccx.state.config.assertions_revert { Err(msg.into()) } else { - executor.console_log(ccx, msg)?; + executor.console_log(ccx, msg); ccx.ecx.sstore(CHEATCODE_ADDRESS, GLOBAL_FAIL_SLOT, U256::from(1))?; Ok(Default::default()) } diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index c7fa9c6e726e1..b9deffc7eda2a 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -181,6 +181,7 @@ impl UIfmt for AnyTransactionReceipt { }, blob_gas_price, blob_gas_used, + authorization_list, }, other, } = self; @@ -202,7 +203,8 @@ transactionHash {} transactionIndex {} type {} blobGasPrice {} -blobGasUsed {}", +blobGasUsed {} +authorizationList {}", block_hash.pretty(), block_number.pretty(), contract_address.pretty(), @@ -219,6 +221,10 @@ blobGasUsed {}", transaction_type, blob_gas_price.pretty(), blob_gas_used.pretty(), + authorization_list + .as_ref() + .map(|l| serde_json::to_string(&l).unwrap()) + .unwrap_or_default(), ); if let Some(to) = to { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index e59c44a57b95e..f82975c670ee9 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -907,7 +907,7 @@ impl Config { #[inline] pub fn evm_spec_id(&self) -> SpecId { if self.prague { - return SpecId::PRAGUE + return SpecId::PRAGUE_EOF } evm_spec_id(&self.evm_version) } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 6ee71dd6dbedf..d74a085a07490 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -200,6 +200,7 @@ impl DebuggerContext<'_> { CallKind::CallCode => "Contract callcode", CallKind::DelegateCall => "Contract delegatecall", CallKind::AuthCall => "Contract authcall", + CallKind::EOFCreate => "EOF contract creation", }; let title = format!( "{} {} ", diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index b0ca3876667b5..9ca63c5136603 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -266,7 +266,7 @@ impl<'a> DatabaseRef for CowBackend<'a> { DatabaseRef::storage_ref(self.backend.as_ref(), address, index) } - fn block_hash_ref(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: u64) -> Result { DatabaseRef::block_hash_ref(self.backend.as_ref(), number) } } @@ -286,7 +286,7 @@ impl<'a> Database for CowBackend<'a> { DatabaseRef::storage_ref(self, address, index) } - fn block_hash(&mut self, number: U256) -> Result { + fn block_hash(&mut self, number: u64) -> Result { DatabaseRef::block_hash_ref(self, number) } } diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index be63f230073c0..e819c5313c2a3 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -44,7 +44,7 @@ impl DatabaseRef for MemDb { DatabaseRef::storage_ref(&self.inner, address, index) } - fn block_hash_ref(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: u64) -> Result { DatabaseRef::block_hash_ref(&self.inner, number) } } @@ -65,7 +65,7 @@ impl Database for MemDb { Database::storage(&mut self.inner, address, index) } - fn block_hash(&mut self, number: U256) -> Result { + fn block_hash(&mut self, number: u64) -> Result { Database::block_hash(&mut self.inner, number) } } @@ -111,7 +111,7 @@ impl DatabaseRef for EmptyDBWrapper { Ok(self.0.storage_ref(address, index)?) } - fn block_hash_ref(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: u64) -> Result { Ok(self.0.block_hash_ref(number)?) } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index d55e0d6f940ee..7839bb262e93b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1422,7 +1422,7 @@ impl DatabaseRef for Backend { } } - fn block_hash_ref(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: u64) -> Result { if let Some(db) = self.active_fork_db() { db.block_hash_ref(number) } else { @@ -1467,7 +1467,7 @@ impl Database for Backend { } } - fn block_hash(&mut self, number: U256) -> Result { + fn block_hash(&mut self, number: u64) -> Result { if let Some(db) = self.active_fork_db_mut() { Ok(db.block_hash(number)?) } else { diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 590f6717e09a3..de6b2a6b9f22e 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -167,7 +167,7 @@ impl Database for ForkedDatabase { Database::storage(&mut self.cache_db, address, index) } - fn block_hash(&mut self, number: U256) -> Result { + fn block_hash(&mut self, number: u64) -> Result { Database::block_hash(&mut self.cache_db, number) } } @@ -187,7 +187,7 @@ impl DatabaseRef for ForkedDatabase { DatabaseRef::storage_ref(&self.cache_db, address, index) } - fn block_hash_ref(&self, number: U256) -> Result { + fn block_hash_ref(&self, number: u64) -> Result { self.cache_db.block_hash_ref(number) } } @@ -253,8 +253,8 @@ impl DatabaseRef for ForkDbSnapshot { } } - fn block_hash_ref(&self, number: U256) -> Result { - match self.snapshot.block_hashes.get(&number).copied() { + fn block_hash_ref(&self, number: u64) -> Result { + match self.snapshot.block_hashes.get(&U256::from(number)).copied() { None => self.local.block_hash_ref(number), Some(block_hash) => Ok(block_hash), } diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index dd05568411be4..ed10c5d751465 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -44,6 +44,9 @@ pub trait InspectorExt: Inspector { ) -> bool { false } + + // Simulates `console.log` invocation. + fn console_log(&mut self, _input: String) {} } impl InspectorExt for NoOpInspector {} diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 2fc202c0dc189..76a738c525405 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -77,22 +77,7 @@ pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { env.tx.gas_price = U256::from(tx.gas_price.unwrap_or_default()); env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); env.tx.nonce = Some(tx.nonce); - env.tx.access_list = tx - .access_list - .clone() - .unwrap_or_default() - .0 - .into_iter() - .map(|item| { - ( - item.address, - item.storage_keys - .into_iter() - .map(|key| alloy_primitives::U256::from_be_bytes(key.0)) - .collect(), - ) - }) - .collect(); + env.tx.access_list = tx.access_list.clone().unwrap_or_default().0.into_iter().collect(); env.tx.value = tx.value.to(); env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); env.tx.transact_to = tx.to.map(TxKind::Call).unwrap_or(TxKind::Create) diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 16e760375129e..66010a33cfc75 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -844,6 +844,7 @@ fn convert_executed_result( &env.tx.data, env.tx.transact_to.is_create(), &env.tx.access_list, + 0, ); let result = match &out { diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index ec95fb41ca5fc..03b677fcdf844 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -4,9 +4,12 @@ use foundry_common::{fmt::ConsoleFmt, ErrorExt}; use foundry_evm_core::{ abi::{patch_hh_console_selector, Console, HardhatConsole}, constants::HARDHAT_CONSOLE_ADDRESS, + InspectorExt, }; use revm::{ - interpreter::{CallInputs, CallOutcome, Gas, InstructionResult, InterpreterResult}, + interpreter::{ + CallInputs, CallOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, + }, Database, EvmContext, Inspector, }; @@ -38,7 +41,7 @@ impl LogCollector { } impl Inspector for LogCollector { - fn log(&mut self, _context: &mut EvmContext, log: &Log) { + fn log(&mut self, _interp: &mut Interpreter, _context: &mut EvmContext, log: &Log) { self.logs.push(log.clone()); } @@ -65,6 +68,16 @@ impl Inspector for LogCollector { } } +impl InspectorExt for LogCollector { + fn console_log(&mut self, input: String) { + self.logs.push(Log::new_unchecked( + HARDHAT_CONSOLE_ADDRESS, + vec![Console::log::SIGNATURE_HASH], + input.abi_encode().into(), + )); + } +} + /// Converts a call to Hardhat's `console.log` to a DSTest `log(string)` event. fn convert_hh_log_to_event(call: HardhatConsole::HardhatConsoleCalls) -> Log { // Convert the parameters of the call to their string representation using `ConsoleFmt`. diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 8a2e7468baf31..c61fab4e85087 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -560,7 +560,7 @@ impl<'a> InspectorStackRefMut<'a> { // Should we match, encode and propagate error as a revert reason? let result = InterpreterResult { result: InstructionResult::Revert, output: Bytes::new(), gas }; - return (result, None) + return (result, None); }; // Commit changes after transaction @@ -573,7 +573,7 @@ impl<'a> InspectorStackRefMut<'a> { output: Bytes::from(e.to_string()), gas, }; - return (res, None) + return (res, None); } if let Err(e) = update_state(&mut res.state, &mut ecx.db, None) { let res = InterpreterResult { @@ -581,7 +581,7 @@ impl<'a> InspectorStackRefMut<'a> { output: Bytes::from(e.to_string()), gas, }; - return (res, None) + return (res, None); } // Merge transaction journal into the active journal. @@ -653,10 +653,10 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ); } - fn log(&mut self, ecx: &mut EvmContext, log: &Log) { + fn log(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext, log: &Log) { call_inspectors_adjust_depth!( [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], - |inspector| inspector.log(ecx, log), + |inspector| inspector.log(interpreter, ecx, log), self, ecx ); @@ -689,7 +689,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { if let Some(output) = cheatcodes.call_with_executor(ecx, call, self.inner) { if output.result.result != InstructionResult::Continue { ecx.journaled_state.depth -= self.in_inner_context as usize; - return Some(output) + return Some(output); } } } @@ -708,7 +708,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { call.gas_limit, call.value.get(), ); - return Some(CallOutcome { result, memory_offset: call.return_memory_offset.clone() }) + return Some(CallOutcome { result, memory_offset: call.return_memory_offset.clone() }); } None @@ -723,7 +723,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. // Avoid processing twice. if self.in_inner_context && ecx.journaled_state.depth == 0 { - return outcome + return outcome; } let outcome = self.do_call_end(ecx, inputs, outcome); @@ -770,7 +770,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { create.gas_limit, create.value, ); - return Some(CreateOutcome { result, address }) + return Some(CreateOutcome { result, address }); } None @@ -785,7 +785,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. // Avoid processing twice. if self.in_inner_context && ecx.journaled_state.depth == 0 { - return outcome + return outcome; } let result = outcome.result.result; @@ -828,10 +828,14 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ecx ); - if self.enable_isolation && !self.in_inner_context && ecx.journaled_state.depth == 1 { - let init_code = match &create.kind { + if matches!(create.kind, EOFCreateKind::Tx { .. }) && + self.enable_isolation && + !self.in_inner_context && + ecx.journaled_state.depth == 1 + { + let init_code = match &mut create.kind { EOFCreateKind::Tx { initdata } => initdata.clone(), - EOFCreateKind::Opcode { initcode, .. } => initcode.raw.clone(), + EOFCreateKind::Opcode { .. } => unreachable!(), }; let (result, address) = self.transact_inner( @@ -842,7 +846,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { create.gas_limit, create.value, ); - return Some(CreateOutcome { result, address }) + return Some(CreateOutcome { result, address }); } None @@ -857,7 +861,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. // Avoid processing twice. if self.in_inner_context && ecx.journaled_state.depth == 0 { - return outcome + return outcome; } let result = outcome.result.result; @@ -905,6 +909,12 @@ impl<'a, DB: DatabaseExt> InspectorExt for InspectorStackRefMut<'a> { false } + + fn console_log(&mut self, input: String) { + call_inspectors!([&mut self.log_collector], |inspector| InspectorExt::::console_log( + inspector, input + )); + } } impl Inspector for InspectorStack { @@ -952,12 +962,29 @@ impl Inspector for InspectorStack { self.as_mut().create_end(context, call, outcome) } + fn eofcreate( + &mut self, + context: &mut EvmContext, + create: &mut EOFCreateInputs, + ) -> Option { + self.as_mut().eofcreate(context, create) + } + + fn eofcreate_end( + &mut self, + context: &mut EvmContext, + call: &EOFCreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { + self.as_mut().eofcreate_end(context, call, outcome) + } + fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { self.as_mut().initialize_interp(interpreter, ecx) } - fn log(&mut self, ecx: &mut EvmContext, log: &Log) { - self.as_mut().log(ecx, log) + fn log(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext, log: &Log) { + self.as_mut().log(interpreter, ecx, log) } fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 56f59fffc7771..4fb4388448cb6 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -84,7 +84,8 @@ impl GasReport { if trace.depth > 1 && (trace.kind == CallKind::Call || trace.kind == CallKind::Create || - trace.kind == CallKind::Create2) + trace.kind == CallKind::Create2 || + trace.kind == CallKind::EOFCreate) { return; } @@ -143,7 +144,7 @@ impl Display for GasReport { for (name, contract) in &self.contracts { if contract.functions.is_empty() { trace!(name, "gas report contract without functions"); - continue + continue; } let mut table = Table::new(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f966d6024118d..f259579d616f7 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -107,7 +107,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { etherscan_api_key: None, etherscan: Default::default(), verbosity: 4, - remappings: vec![Remapping::from_str("forge-std=lib/forge-std/").unwrap().into()], + remappings: vec![Remapping::from_str("forge-std/=lib/forge-std/").unwrap().into()], libraries: vec![ "src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6".to_string() ], From af97b2c75cbcfaba23462998ae75ca082bcca1f2 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:10:56 +0300 Subject: [PATCH 1263/1963] perf(invariant): do not include reverts in counterexample (#8459) --- .../evm/evm/src/executors/invariant/result.rs | 4 +++ crates/forge/tests/it/invariant.rs | 18 +++++++++++++ .../common/InvariantSequenceNoReverts.t.sol | 25 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 testdata/default/fuzz/invariant/common/InvariantSequenceNoReverts.t.sol diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index bd34687c33bbc..c6a15930cbaef 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -147,6 +147,10 @@ pub(crate) fn can_continue( invariant_data.failures.error = Some(InvariantFuzzError::Revert(case_data)); return Ok(RichInvariantResults::new(false, None)); + } else if call_result.reverted { + // If we don't fail test on revert then remove last reverted call from inputs. + // This improves shrinking performance as irrelevant calls won't be checked again. + invariant_run.inputs.pop(); } } Ok(RichInvariantResults::new(true, call_results)) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index c0e657d0687eb..72c3e7bd7b84b 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -676,3 +676,21 @@ async fn test_invariant_selectors_weight() { )]), ) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_no_reverts_in_counterexample() { + let filter = + Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantSequenceNoReverts.t.sol"); + let mut runner = TEST_DATA_DEFAULT.runner(); + runner.test_options.invariant.fail_on_revert = false; + // Use original counterexample to test sequence len. + runner.test_options.invariant.shrink_run_limit = 0; + + match get_counterexample!(runner, &filter) { + CounterExample::Single(_) => panic!("CounterExample should be a sequence."), + CounterExample::Sequence(sequence) => { + // ensure original counterexample len is 10 (even without shrinking) + assert_eq!(sequence.len(), 10); + } + }; +} diff --git a/testdata/default/fuzz/invariant/common/InvariantSequenceNoReverts.t.sol b/testdata/default/fuzz/invariant/common/InvariantSequenceNoReverts.t.sol new file mode 100644 index 0000000000000..993d806f81b38 --- /dev/null +++ b/testdata/default/fuzz/invariant/common/InvariantSequenceNoReverts.t.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "ds-test/test.sol"; + +contract SequenceNoReverts { + uint256 public count; + + function work(uint256 x) public { + require(x % 2 != 0); + count++; + } +} + +contract SequenceNoRevertsTest is DSTest { + SequenceNoReverts target; + + function setUp() public { + target = new SequenceNoReverts(); + } + + function invariant_no_reverts() public view { + require(target.count() < 10, "condition met"); + } +} From 31628d1457f28405c8aa98751ac933f10a95b1c1 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Thu, 18 Jul 2024 16:22:35 -0300 Subject: [PATCH 1264/1963] feat(anvil): add mined transactions to state dump (#8411) --- crates/anvil/core/src/eth/transaction/mod.rs | 4 +- crates/anvil/src/eth/backend/db.rs | 43 +++++++++++++++++-- crates/anvil/src/eth/backend/mem/fork_db.rs | 4 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 9 +++- crates/anvil/src/eth/backend/mem/mod.rs | 4 +- crates/anvil/src/eth/backend/mem/storage.rs | 19 +++++++- 6 files changed, 72 insertions(+), 11 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 509e8327eedb2..49b02d8922bcf 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -169,7 +169,7 @@ pub enum TypedTransactionRequest { /// /// This is a helper that carries the `impersonated` sender so that the right hash /// [TypedTransaction::impersonated_hash] can be created. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct MaybeImpersonatedTransaction { pub transaction: TypedTransaction, pub impersonated_sender: Option
, @@ -1110,7 +1110,7 @@ pub struct TransactionEssentials { } /// Represents all relevant information of an executed transaction -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct TransactionInfo { pub transaction_hash: B256, pub transaction_index: u64, diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index fb9b6078204b8..e6d9541f32c1e 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -1,10 +1,13 @@ //! Helper types for working with [revm](foundry_evm::revm) -use crate::revm::primitives::AccountInfo; +use crate::{mem::storage::MinedTransaction, revm::primitives::AccountInfo}; use alloy_consensus::Header; use alloy_primitives::{keccak256, Address, Bytes, B256, U256, U64}; use alloy_rpc_types::BlockId; -use anvil_core::eth::{block::Block, transaction::TypedTransaction}; +use anvil_core::eth::{ + block::Block, + transaction::{MaybeImpersonatedTransaction, TransactionInfo, TypedReceipt}, +}; use foundry_common::errors::FsPathError; use foundry_evm::{ backend::{ @@ -120,6 +123,7 @@ pub trait Db: at: BlockEnv, best_number: U64, blocks: Vec, + transactions: Vec, ) -> DatabaseResult>; /// Deserialize and add all chain data to the backend storage @@ -193,6 +197,7 @@ impl + Send + Sync + Clone + fmt::Debug> D _at: BlockEnv, _best_number: U64, _blocks: Vec, + _transaction: Vec, ) -> DatabaseResult> { Ok(None) } @@ -325,6 +330,8 @@ pub struct SerializableState { pub best_block_number: Option, #[serde(default)] pub blocks: Vec, + #[serde(default)] + pub transactions: Vec, } impl SerializableState { @@ -355,7 +362,7 @@ pub struct SerializableAccountRecord { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SerializableBlock { pub header: Header, - pub transactions: Vec, + pub transactions: Vec, pub ommers: Vec
, } @@ -378,3 +385,33 @@ impl From for Block { } } } + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SerializableTransaction { + pub info: TransactionInfo, + pub receipt: TypedReceipt, + pub block_hash: B256, + pub block_number: u64, +} + +impl From for SerializableTransaction { + fn from(transaction: MinedTransaction) -> Self { + Self { + info: transaction.info, + receipt: transaction.receipt, + block_hash: transaction.block_hash, + block_number: transaction.block_number, + } + } +} + +impl From for MinedTransaction { + fn from(transaction: SerializableTransaction) -> Self { + Self { + info: transaction.info, + receipt: transaction.receipt, + block_hash: transaction.block_hash, + block_number: transaction.block_number, + } + } +} diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index cf86699c5b1ca..a179f50c3b494 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -1,7 +1,7 @@ use crate::{ eth::backend::db::{ Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableBlock, - SerializableState, StateDb, + SerializableState, SerializableTransaction, StateDb, }, revm::primitives::AccountInfo, }; @@ -37,6 +37,7 @@ impl Db for ForkedDatabase { at: BlockEnv, best_number: U64, blocks: Vec, + transactions: Vec, ) -> DatabaseResult> { let mut db = self.database().clone(); let accounts = self @@ -66,6 +67,7 @@ impl Db for ForkedDatabase { accounts, best_block_number: Some(best_number), blocks, + transactions, })) } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index b6c3db12c2b1b..059c00f326bf5 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -3,7 +3,7 @@ use crate::{ eth::backend::db::{ Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableBlock, - SerializableState, StateDb, + SerializableState, SerializableTransaction, StateDb, }, mem::state::state_root, revm::{db::DbAccount, primitives::AccountInfo}, @@ -37,6 +37,7 @@ impl Db for MemDb { at: BlockEnv, best_number: U64, blocks: Vec, + transactions: Vec, ) -> DatabaseResult> { let accounts = self .inner @@ -66,6 +67,7 @@ impl Db for MemDb { accounts, best_block_number: Some(best_number), blocks, + transactions, })) } @@ -160,7 +162,10 @@ mod tests { dump_db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); // blocks dumping/loading tested in storage.rs - let state = dump_db.dump_state(Default::default(), U64::ZERO, Vec::new()).unwrap().unwrap(); + let state = dump_db + .dump_state(Default::default(), U64::ZERO, Vec::new(), Vec::new()) + .unwrap() + .unwrap(); let mut load_db = MemDb::default(); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f89ba6a50568d..8fa94673fd530 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -721,7 +721,8 @@ impl Backend { let at = self.env.read().block.clone(); let best_number = self.blockchain.storage.read().best_number; let blocks = self.blockchain.storage.read().serialized_blocks(); - let state = self.db.read().await.dump_state(at, best_number, blocks)?; + let transactions = self.blockchain.storage.read().serialized_transactions(); + let state = self.db.read().await.dump_state(at, best_number, blocks, transactions)?; state.ok_or_else(|| { RpcError::invalid_params("Dumping state not supported with the current configuration") .into() @@ -758,6 +759,7 @@ impl Backend { } self.blockchain.storage.write().load_blocks(state.blocks.clone()); + self.blockchain.storage.write().load_transactions(state.transactions.clone()); Ok(true) } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 8a92e242df802..692e669e58f54 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -1,7 +1,7 @@ //! In-memory blockchain storage use crate::eth::{ backend::{ - db::{MaybeFullDatabase, SerializableBlock, StateDb}, + db::{MaybeFullDatabase, SerializableBlock, SerializableTransaction, StateDb}, mem::cache::DiskStateCache, }, error::BlockchainError, @@ -334,6 +334,10 @@ impl BlockchainStorage { self.blocks.values().map(|block| block.clone().into()).collect() } + pub fn serialized_transactions(&self) -> Vec { + self.transactions.values().map(|tx: &MinedTransaction| tx.clone().into()).collect() + } + /// Deserialize and add all blocks data to the backend storage pub fn load_blocks(&mut self, serializable_blocks: Vec) { for serializable_block in serializable_blocks.iter() { @@ -344,6 +348,14 @@ impl BlockchainStorage { self.hashes.insert(U64::from(block_number), block_hash); } } + + /// Deserialize and add all blocks data to the backend storage + pub fn load_transactions(&mut self, serializable_transactions: Vec) { + for serializable_transaction in serializable_transactions.iter() { + let transaction: MinedTransaction = serializable_transaction.clone().into(); + self.transactions.insert(transaction.info.transaction_hash, transaction); + } + } } /// A simple in-memory blockchain @@ -590,7 +602,8 @@ mod tests { } } - // verifies that blocks in BlockchainStorage remain the same when dumped and reloaded + // verifies that blocks and transactions in BlockchainStorage remain the same when dumped and + // reloaded #[test] fn test_storage_dump_reload_cycle() { let mut dump_storage = BlockchainStorage::empty(); @@ -608,10 +621,12 @@ mod tests { dump_storage.blocks.insert(block_hash, block); let serialized_blocks = dump_storage.serialized_blocks(); + let serialized_transactions = dump_storage.serialized_transactions(); let mut load_storage = BlockchainStorage::empty(); load_storage.load_blocks(serialized_blocks); + load_storage.load_transactions(serialized_transactions); let loaded_block = load_storage.blocks.get(&block_hash).unwrap(); assert_eq!(loaded_block.header.gas_limit, partial_header.gas_limit); From e90348416c3a831ab75bb43f6fa5f0a0be4106c4 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 18 Jul 2024 23:02:09 +0300 Subject: [PATCH 1265/1963] fix(fork): preserve block number and timestamp when changing fork (#8466) * fix(fork): preserve block number and timestamp when changing fork * Minor test update, could have been failing if forks created at different blocks --- crates/evm/core/src/backend/mod.rs | 12 ++- crates/evm/core/src/fork/multi.rs | 124 ++++++++++++++---------- crates/forge/tests/it/repros.rs | 3 + testdata/default/repros/Issue8168.t.sol | 39 ++++++++ 4 files changed, 127 insertions(+), 51 deletions(-) create mode 100644 testdata/default/repros/Issue8168.t.sol diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 7839bb262e93b..23c54e6e21545 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1024,6 +1024,16 @@ impl DatabaseExt for Backend { return Ok(()); } + // Update block number and timestamp of active fork (if any) with current env values, + // in order to preserve values changed by using `roll` and `warp` cheatcodes. + if let Some(active_fork_id) = self.active_fork_id() { + self.forks.update_block( + self.ensure_fork_id(active_fork_id).cloned()?, + env.block.number, + env.block.timestamp, + )?; + } + let fork_id = self.ensure_fork_id(id).cloned()?; let idx = self.inner.ensure_fork_index(&fork_id)?; let fork_env = self @@ -1100,7 +1110,7 @@ impl DatabaseExt for Backend { } self.active_fork_ids = Some((id, idx)); - // update the environment accordingly + // Update current environment with environment of newly selected fork. update_current_env_with_fork_env(env, fork_env); Ok(()) diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 372794ed1eb71..001c654699685 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -1,9 +1,10 @@ -//! Support for running multiple fork backends +//! Support for running multiple fork backends. //! //! The design is similar to the single `SharedBackend`, `BackendHandler` but supports multiple //! concurrently active pairs at once. use super::CreateFork; +use alloy_primitives::U256; use alloy_transport::layers::RetryBackoffService; use foundry_common::provider::{ runtime_transport::RuntimeTransport, ProviderBuilder, RetryProvider, @@ -65,13 +66,13 @@ impl> From for ForkId { } /// The Sender half of multi fork pair. -/// Can send requests to the `MultiForkHandler` to create forks +/// Can send requests to the `MultiForkHandler` to create forks. #[derive(Clone, Debug)] #[must_use] pub struct MultiFork { - /// Channel to send `Request`s to the handler + /// Channel to send `Request`s to the handler. handler: Sender, - /// Ensures that all rpc resources get flushed properly + /// Ensures that all rpc resources get flushed properly. _shutdown: Arc, } @@ -81,8 +82,8 @@ impl MultiFork { trace!(target: "fork::multi", "spawning multifork"); let (fork, mut handler) = Self::new(); - // spawn a light-weight thread with a thread-local async runtime just for - // sending and receiving data from the remote client(s) + // Spawn a light-weight thread with a thread-local async runtime just for + // sending and receiving data from the remote client(s). std::thread::Builder::new() .name("multi-fork-backend".into()) .spawn(move || { @@ -92,10 +93,10 @@ impl MultiFork { .expect("failed to build tokio runtime"); rt.block_on(async move { - // flush cache every 60s, this ensures that long-running fork tests get their - // cache flushed from time to time + // Flush cache every 60s, this ensures that long-running fork tests get their + // cache flushed from time to time. // NOTE: we install the interval here because the `tokio::timer::Interval` - // requires a rt + // requires a rt. handler.set_flush_cache_interval(Duration::from_secs(60)); handler.await }); @@ -115,9 +116,9 @@ impl MultiFork { (Self { handler, _shutdown }, MultiForkHandler::new(handler_rx)) } - /// Returns a fork backend + /// Returns a fork backend. /// - /// If no matching fork backend exists it will be created + /// If no matching fork backend exists it will be created. pub fn create_fork(&self, fork: CreateFork) -> eyre::Result<(ForkId, SharedBackend, Env)> { trace!("Creating new fork, url={}, block={:?}", fork.url, fork.evm_opts.fork_block_number); let (sender, rx) = oneshot_channel(); @@ -126,9 +127,9 @@ impl MultiFork { rx.recv()? } - /// Rolls the block of the fork + /// Rolls the block of the fork. /// - /// If no matching fork backend exists it will be created + /// If no matching fork backend exists it will be created. pub fn roll_fork( &self, fork: ForkId, @@ -141,7 +142,7 @@ impl MultiFork { rx.recv()? } - /// Returns the `Env` of the given fork, if any + /// Returns the `Env` of the given fork, if any. pub fn get_env(&self, fork: ForkId) -> eyre::Result> { trace!(?fork, "getting env config"); let (sender, rx) = oneshot_channel(); @@ -150,7 +151,16 @@ impl MultiFork { Ok(rx.recv()?) } - /// Returns the corresponding fork if it exists + /// Updates block number and timestamp of given fork with new values. + pub fn update_block(&self, fork: ForkId, number: U256, timestamp: U256) -> eyre::Result<()> { + trace!(?fork, ?number, ?timestamp, "update fork block"); + self.handler + .clone() + .try_send(Request::UpdateBlock(fork, number, timestamp)) + .map_err(|e| eyre::eyre!("{:?}", e)) + } + + /// Returns the corresponding fork if it exists. /// /// Returns `None` if no matching fork backend is available. pub fn get_fork(&self, id: impl Into) -> eyre::Result> { @@ -162,7 +172,7 @@ impl MultiFork { Ok(rx.recv()?) } - /// Returns the corresponding fork url if it exists + /// Returns the corresponding fork url if it exists. /// /// Returns `None` if no matching fork is available. pub fn get_fork_url(&self, id: impl Into) -> eyre::Result> { @@ -180,37 +190,39 @@ type CreateFuture = type CreateSender = OneshotSender>; type GetEnvSender = OneshotSender>; -/// Request that's send to the handler +/// Request that's send to the handler. #[derive(Debug)] enum Request { - /// Creates a new ForkBackend + /// Creates a new ForkBackend. CreateFork(Box, CreateSender), - /// Returns the Fork backend for the `ForkId` if it exists + /// Returns the Fork backend for the `ForkId` if it exists. GetFork(ForkId, OneshotSender>), - /// Adjusts the block that's being forked, by creating a new fork at the new block + /// Adjusts the block that's being forked, by creating a new fork at the new block. RollFork(ForkId, u64, CreateSender), - /// Returns the environment of the fork + /// Returns the environment of the fork. GetEnv(ForkId, GetEnvSender), + /// Updates the block number and timestamp of the fork. + UpdateBlock(ForkId, U256, U256), /// Shutdowns the entire `MultiForkHandler`, see `ShutDownMultiFork` ShutDown(OneshotSender<()>), - /// Returns the Fork Url for the `ForkId` if it exists + /// Returns the Fork Url for the `ForkId` if it exists. GetForkUrl(ForkId, OneshotSender>), } enum ForkTask { - /// Contains the future that will establish a new fork + /// Contains the future that will establish a new fork. Create(CreateFuture, ForkId, CreateSender, Vec), } -/// The type that manages connections in the background +/// The type that manages connections in the background. #[must_use = "futures do nothing unless polled"] pub struct MultiForkHandler { /// Incoming requests from the `MultiFork`. incoming: Fuse>, - /// All active handlers + /// All active handlers. /// - /// It's expected that this list will be rather small (<10) + /// It's expected that this list will be rather small (<10). handlers: Vec<(ForkId, Handler)>, // tasks currently in progress @@ -222,7 +234,7 @@ pub struct MultiForkHandler { /// block number. forks: HashMap, - /// Optional periodic interval to flush rpc cache + /// Optional periodic interval to flush rpc cache. flush_cache_interval: Option, } @@ -237,7 +249,7 @@ impl MultiForkHandler { } } - /// Sets the interval after which all rpc caches should be flushed periodically + /// Sets the interval after which all rpc caches should be flushed periodically. pub fn set_flush_cache_interval(&mut self, period: Duration) -> &mut Self { self.flush_cache_interval = Some(tokio::time::interval_at(tokio::time::Instant::now() + period, period)); @@ -261,13 +273,13 @@ impl MultiForkHandler { let fork_id = ForkId::new(&fork.url, fork.evm_opts.fork_block_number); trace!(?fork_id, "created new forkId"); - // there could already be a task for the requested fork in progress + // There could already be a task for the requested fork in progress. if let Some(in_progress) = self.find_in_progress_task(&fork_id) { in_progress.push(sender); return; } - // need to create a new fork + // Need to create a new fork. let task = Box::pin(create_fork(fork)); self.pending_tasks.push(ForkTask::Create(task, fork_id, sender, Vec::new())); } @@ -282,7 +294,7 @@ impl MultiForkHandler { self.forks.insert(fork_id.clone(), fork.clone()); let _ = sender.send(Ok((fork_id.clone(), fork.backend.clone(), fork.opts.env.clone()))); - // notify all additional senders and track unique forkIds + // Notify all additional senders and track unique forkIds. for sender in additional_senders { let next_fork_id = fork.inc_senders(fork_id.clone()); self.forks.insert(next_fork_id.clone(), fork.clone()); @@ -290,6 +302,15 @@ impl MultiForkHandler { } } + /// Update fork block number and timestamp. Used to preserve values set by `roll` and `warp` + /// cheatcodes when new fork selected. + fn update_block(&mut self, fork_id: ForkId, block_number: U256, block_timestamp: U256) { + if let Some(fork) = self.forks.get_mut(&fork_id) { + fork.opts.env.block.number = block_number; + fork.opts.env.block.timestamp = block_timestamp; + } + } + fn on_request(&mut self, req: Request) { match req { Request::CreateFork(fork, sender) => self.create_fork(*fork, sender), @@ -310,9 +331,12 @@ impl MultiForkHandler { Request::GetEnv(fork_id, sender) => { let _ = sender.send(self.forks.get(&fork_id).map(|fork| fork.opts.env.clone())); } + Request::UpdateBlock(fork_id, block_number, block_timestamp) => { + self.update_block(fork_id, block_number, block_timestamp); + } Request::ShutDown(sender) => { trace!(target: "fork::multi", "received shutdown signal"); - // we're emptying all fork backends, this way we ensure all caches get flushed + // We're emptying all fork backends, this way we ensure all caches get flushed. self.forks.clear(); self.handlers.clear(); let _ = sender.send(()); @@ -325,22 +349,22 @@ impl MultiForkHandler { } } -// Drives all handler to completion -// This future will finish once all underlying BackendHandler are completed +// Drives all handler to completion. +// This future will finish once all underlying BackendHandler are completed. impl Future for MultiForkHandler { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let pin = self.get_mut(); - // receive new requests + // Receive new requests. loop { match Pin::new(&mut pin.incoming).poll_next(cx) { Poll::Ready(Some(req)) => { pin.on_request(req); } Poll::Ready(None) => { - // channel closed, but we still need to drive the fork handlers to completion + // Channel closed, but we still need to drive the fork handlers to completion. trace!(target: "fork::multi", "request channel closed"); break; } @@ -348,7 +372,7 @@ impl Future for MultiForkHandler { } } - // advance all tasks + // Advance all tasks. for n in (0..pin.pending_tasks.len()).rev() { let task = pin.pending_tasks.swap_remove(n); match task { @@ -387,7 +411,7 @@ impl Future for MultiForkHandler { } } - // advance all handlers + // Advance all handlers. for n in (0..pin.handlers.len()).rev() { let (id, mut handler) = pin.handlers.swap_remove(n); match handler.poll_unpin(cx) { @@ -405,7 +429,7 @@ impl Future for MultiForkHandler { return Poll::Ready(()); } - // periodically flush cached RPC state + // Periodically flush cached RPC state. if pin .flush_cache_interval .as_mut() @@ -415,7 +439,7 @@ impl Future for MultiForkHandler { { trace!(target: "fork::multi", "tick flushing caches"); let forks = pin.forks.values().map(|f| f.backend.clone()).collect::>(); - // flush this on new thread to not block here + // Flush this on new thread to not block here. std::thread::Builder::new() .name("flusher".into()) .spawn(move || { @@ -431,12 +455,12 @@ impl Future for MultiForkHandler { /// Tracks the created Fork #[derive(Debug, Clone)] struct CreatedFork { - /// How the fork was initially created + /// How the fork was initially created. opts: CreateFork, - /// Copy of the sender + /// Copy of the sender. backend: SharedBackend, /// How many consumers there are, since a `SharedBacked` can be used by multiple - /// consumers + /// consumers. num_senders: Arc, } @@ -445,7 +469,7 @@ impl CreatedFork { Self { opts, backend, num_senders: Arc::new(AtomicUsize::new(1)) } } - /// Increment senders and return unique identifier of the fork + /// Increment senders and return unique identifier of the fork. fn inc_senders(&self, fork_id: ForkId) -> ForkId { format!( "{}-{}", @@ -458,7 +482,7 @@ impl CreatedFork { /// A type that's used to signaling the `MultiForkHandler` when it's time to shut down. /// -/// This is essentially a sync on drop, so that the `MultiForkHandler` can flush all rpc cashes +/// This is essentially a sync on drop, so that the `MultiForkHandler` can flush all rpc cashes. /// /// This type intentionally does not implement `Clone` since it's intended that there's only once /// instance. @@ -481,9 +505,9 @@ impl Drop for ShutDownMultiFork { } } -/// Creates a new fork +/// Creates a new fork. /// -/// This will establish a new `Provider` to the endpoint and return the Fork Backend +/// This will establish a new `Provider` to the endpoint and return the Fork Backend. async fn create_fork(mut fork: CreateFork) -> eyre::Result<(ForkId, CreatedFork, Handler)> { let provider = Arc::new( ProviderBuilder::new(fork.url.as_str()) @@ -493,16 +517,16 @@ async fn create_fork(mut fork: CreateFork) -> eyre::Result<(ForkId, CreatedFork, .build()?, ); - // initialise the fork environment + // Initialise the fork environment. let (env, block) = fork.evm_opts.fork_evm_env(&fork.url).await?; fork.env = env; let meta = BlockchainDbMeta::new(fork.env.clone(), fork.url.clone()); - // we need to use the block number from the block because the env's number can be different on + // We need to use the block number from the block because the env's number can be different on // some L2s (e.g. Arbitrum). let number = block.header.number.unwrap_or(meta.block_env.number.to()); - // determine the cache path if caching is enabled + // Determine the cache path if caching is enabled. let cache_path = if fork.enable_caching { Config::foundry_block_cache_dir(meta.cfg_env.chain_id, number) } else { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index f1b1c8a96ef4b..9216d275488d3 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -358,3 +358,6 @@ test_repro!(8277); // https://github.com/foundry-rs/foundry/issues/8287 test_repro!(8287); + +// https://github.com/foundry-rs/foundry/issues/8168 +test_repro!(8168); diff --git a/testdata/default/repros/Issue8168.t.sol b/testdata/default/repros/Issue8168.t.sol new file mode 100644 index 0000000000000..b9bd5757abc70 --- /dev/null +++ b/testdata/default/repros/Issue8168.t.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/8168 +contract Issue8168Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testForkWarpRollPreserved() public { + uint256 fork1 = vm.createFork("rpcAlias"); + uint256 fork2 = vm.createFork("rpcAlias"); + + vm.selectFork(fork1); + uint256 initial_fork1_number = block.number; + uint256 initial_fork1_ts = block.timestamp; + vm.warp(block.timestamp + 1000); + vm.roll(block.number + 100); + assertEq(block.timestamp, initial_fork1_ts + 1000); + assertEq(block.number, initial_fork1_number + 100); + + vm.selectFork(fork2); + uint256 initial_fork2_number = block.number; + uint256 initial_fork2_ts = block.timestamp; + vm.warp(block.timestamp + 2000); + vm.roll(block.number + 200); + assertEq(block.timestamp, initial_fork2_ts + 2000); + assertEq(block.number, initial_fork2_number + 200); + + vm.selectFork(fork1); + assertEq(block.timestamp, initial_fork1_ts + 1000); + assertEq(block.number, initial_fork1_number + 100); + + vm.selectFork(fork2); + assertEq(block.timestamp, initial_fork2_ts + 2000); + assertEq(block.number, initial_fork2_number + 200); + } +} From 1a44006ad72982f215a2162fd11b5659402ff6a8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 19 Jul 2024 08:15:54 +0300 Subject: [PATCH 1266/1963] feat(coverage): Add support for remaining Yul types (#8461) * feat(coverage): Add support for remaining Yul types * Add YulFunctionDefinition support --- crates/evm/coverage/src/analysis.rs | 66 ++++++++-- crates/forge/tests/cli/coverage.rs | 197 ++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+), 11 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 1541f0b492681..b110f6e69efe5 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -38,7 +38,7 @@ impl<'a> ContractVisitor<'a> { self.visit_function_definition(node)?; } NodeType::ModifierDefinition => { - self.visit_modifier_definition(node)?; + self.visit_modifier_or_yul_fn_definition(node)?; } _ => {} } @@ -70,7 +70,7 @@ impl<'a> ContractVisitor<'a> { } } - fn visit_modifier_definition(&mut self, node: &Node) -> eyre::Result<()> { + fn visit_modifier_or_yul_fn_definition(&mut self, node: &Node) -> eyre::Result<()> { let name: String = node.attribute("name").ok_or_else(|| eyre::eyre!("Modifier has no name"))?; @@ -98,7 +98,6 @@ impl<'a> ContractVisitor<'a> { } fn visit_statement(&mut self, node: &Node) -> eyre::Result<()> { - // TODO: YulSwitch, YulForLoop, YulFunctionDefinition, YulVariableDeclaration match node.node_type { // Blocks NodeType::Block | NodeType::UncheckedBlock | NodeType::YulBlock => { @@ -118,7 +117,8 @@ impl<'a> ContractVisitor<'a> { NodeType::YulAssignment | NodeType::YulBreak | NodeType::YulContinue | - NodeType::YulLeave => { + NodeType::YulLeave | + NodeType::YulVariableDeclaration => { self.push_item(CoverageItem { kind: CoverageItemKind::Statement, loc: self.source_location_for(&node.src), @@ -336,6 +336,52 @@ impl<'a> ContractVisitor<'a> { Ok(()) } + NodeType::YulSwitch => { + // Add coverage for each case statement amd their bodies. + for case in node + .attribute::>("cases") + .ok_or_else(|| eyre::eyre!("yul switch had no case"))? + { + self.push_item(CoverageItem { + kind: CoverageItemKind::Statement, + loc: self.source_location_for(&case.src), + hits: 0, + }); + self.visit_statement(&case)?; + + if let Some(body) = case.body { + self.push_item(CoverageItem { + kind: CoverageItemKind::Statement, + loc: self.source_location_for(&body.src), + hits: 0, + }); + self.visit_block(&body)? + } + } + Ok(()) + } + NodeType::YulForLoop => { + if let Some(condition) = node.attribute("condition") { + self.visit_expression(&condition)?; + } + if let Some(pre) = node.attribute::("pre") { + self.visit_block(&pre)? + } + if let Some(post) = node.attribute::("post") { + self.visit_block(&post)? + } + + if let Some(body) = &node.body { + self.push_item(CoverageItem { + kind: CoverageItemKind::Statement, + loc: self.source_location_for(&body.src), + hits: 0, + }); + self.visit_block(body)? + } + Ok(()) + } + NodeType::YulFunctionDefinition => self.visit_modifier_or_yul_fn_definition(node), _ => { warn!("unexpected node type, expected a statement: {:?}", node.node_type); Ok(()) @@ -344,14 +390,11 @@ impl<'a> ContractVisitor<'a> { } fn visit_expression(&mut self, node: &Node) -> eyre::Result<()> { - // TODO - // elementarytypenameexpression - // memberaccess - // newexpression - // tupleexpression - // yulfunctioncall match node.node_type { - NodeType::Assignment | NodeType::UnaryOperation | NodeType::Conditional => { + NodeType::Assignment | + NodeType::UnaryOperation | + NodeType::Conditional | + NodeType::YulFunctionCall => { self.push_item(CoverageItem { kind: CoverageItemKind::Statement, loc: self.source_location_for(&node.src), @@ -443,6 +486,7 @@ impl<'a> ContractVisitor<'a> { NodeType::RevertStatement | NodeType::TryStatement | NodeType::VariableDeclarationStatement | + NodeType::YulVariableDeclaration | NodeType::WhileStatement => self.visit_statement(node), // Skip placeholder statements as they are never referenced in source maps. NodeType::PlaceholderStatement => Ok(()), diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 15e55de0e7e76..d33cbb47f7343 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -701,3 +701,200 @@ contract FooTest is DSTest { "#]], ); }); + +forgetest!(test_yul_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "Foo.sol", + r#" +contract Foo { + uint256[] dynamicArray; + + function readDynamicArrayLength() public view returns (uint256 length) { + assembly { + length := sload(dynamicArray.slot) + } + } + + function switchAndIfStatements(uint256 n) public pure { + uint256 y; + assembly { + switch n + case 0 { y := 0 } + case 1 { y := 1 } + default { y := n } + + if y { y := 2 } + } + } + + function yulForLoop(uint256 n) public { + uint256 y; + assembly { + for { let i := 0 } lt(i, n) { i := add(i, 1) } { y := add(y, 1) } + + let j := 0 + for {} lt(j, n) { j := add(j, 1) } { j := add(j, 2) } + } + } + + function hello() public pure returns (bool, uint256, bytes32) { + bool x; + uint256 y; + bytes32 z; + + assembly { + x := 1 + y := 0xa + z := "Hello World!" + } + + return (x, y, z); + } + + function inlineFunction() public returns (uint256) { + uint256 result; + assembly { + function sum(a, b) -> c { + c := add(a, b) + } + + function multiply(a, b) -> c { + for { let i := 0 } lt(i, b) { i := add(i, 1) } { c := add(c, a) } + } + + result := sum(2, 3) + result := multiply(result, 5) + } + return result; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "FooTest.sol", + r#" +import "./test.sol"; +import {Foo} from "./Foo.sol"; + +contract FooTest is DSTest { + function test_foo_coverage() external { + Foo foo = new Foo(); + foo.switchAndIfStatements(0); + foo.switchAndIfStatements(1); + foo.switchAndIfStatements(2); + foo.yulForLoop(2); + foo.hello(); + foo.readDynamicArrayLength(); + foo.inlineFunction(); + } +} + "#, + ) + .unwrap(); + + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|-----------------|-----------------|---------------|---------------| +| src/Foo.sol | 100.00% (23/23) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | +| Total | 100.00% (23/23) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | + +"#]], + ); +}); + +forgetest!(test_misc_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "Foo.sol", + r#" +struct Custom { + int256 f1; +} + +contract A { + function f(Custom memory custom) public returns (int256) { + return custom.f1; + } +} + +contract B { + uint256 public x; + + constructor(uint256 a) payable { + x = a; + } +} + +contract C { + function create() public { + B b = new B{value: 1}(2); + b = (new B{value: 1})(2); + b = (new B){value: 1}(2); + } +} + +contract D { + uint256 index; + + function g() public { + (uint256 x,, uint256 y) = (7, true, 2); + (x, y) = (y, x); + (index,,) = (7, true, 2); + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "FooTest.sol", + r#" +import "./test.sol"; +import "./Foo.sol"; + +interface Vm { + function deal(address account, uint256 newBalance) external; +} + +contract FooTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_member_access_coverage() external { + A a = new A(); + Custom memory cust = Custom(1); + a.f(cust); + } + + function test_new_expression_coverage() external { + B b = new B(1); + b.x(); + C c = new C(); + vm.deal(address(c), 100 ether); + c.create(); + } + + function test_tuple_coverage() external { + D d = new D(); + d.g(); + } +} + "#, + ) + .unwrap(); + + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|---------------|---------------|---------------|---------------| +| src/Foo.sol | 100.00% (8/8) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | +| Total | 100.00% (8/8) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | + +"#]], + ); +}); From 582be2bc2d08d545045d3ec3164c4c6939111c9b Mon Sep 17 00:00:00 2001 From: EdwardJES <107906898+EdwardJES@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:25:02 +1000 Subject: [PATCH 1267/1963] feat(anvil): add `trace_filter` endpoint (#8458) * begin api * add trace filter param * filtering over blocks * add filtered traces * use trace block * begin filtering on trace actions * finish trace filtering * filter by all trace actions * begin adding trace to eth API * begin tests * block bound working * default block ranges working * filtering by address * use latest block * test passing * test passing * fix test * add comments * small comment change * fix typo * add sanity check for block range * add after and count --- crates/anvil/core/src/eth/mod.rs | 9 +- crates/anvil/src/eth/api.rs | 13 +++ crates/anvil/src/eth/backend/mem/mod.rs | 62 ++++++++++- crates/anvil/tests/it/traces.rs | 142 ++++++++++++++++++++++++ 4 files changed, 224 insertions(+), 2 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 8e3a8e59648e4..b13408d3caea9 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -5,7 +5,10 @@ use alloy_rpc_types::{ pubsub::{Params as SubscriptionParams, SubscriptionKind}, request::TransactionRequest, state::StateOverride, - trace::geth::{GethDebugTracingCallOptions, GethDebugTracingOptions}, + trace::{ + filter::TraceFilter, + geth::{GethDebugTracingCallOptions, GethDebugTracingOptions}, + }, BlockId, BlockNumberOrTag as BlockNumber, Filter, Index, }; use alloy_serde::WithOtherFields; @@ -314,6 +317,10 @@ pub enum EthRequest { )] TraceBlock(BlockNumber), + // Return filtered traces over blocks + #[cfg_attr(feature = "serde", serde(rename = "trace_filter",))] + TraceFilter(TraceFilter), + // Custom endpoints, they're not extracted to a separate type out of serde convenience /// send transactions impersonating specific account and contract addresses. #[cfg_attr( diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index fe7ebeaa24093..cd3a8dadab700 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -43,6 +43,7 @@ use alloy_rpc_types::{ request::TransactionRequest, state::StateOverride, trace::{ + filter::TraceFilter, geth::{GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace}, parity::LocalizedTransactionTrace, }, @@ -292,6 +293,7 @@ impl EthApi { } EthRequest::TraceTransaction(tx) => self.trace_transaction(tx).await.to_rpc_result(), EthRequest::TraceBlock(block) => self.trace_block(block).await.to_rpc_result(), + EthRequest::TraceFilter(filter) => self.trace_filter(filter).await.to_rpc_result(), EthRequest::ImpersonateAccount(addr) => { self.anvil_impersonate_account(addr).await.to_rpc_result() } @@ -1556,6 +1558,17 @@ impl EthApi { node_info!("trace_block"); self.backend.trace_block(block).await } + + /// Returns filtered traces over blocks + /// + /// Handler for RPC call: `trace_filter` + pub async fn trace_filter( + &self, + filter: TraceFilter, + ) -> Result> { + node_info!("trace_filter"); + self.backend.trace_filter(filter).await + } } // == impl EthApi anvil endpoints == diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 8fa94673fd530..6abfbea2869b2 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -41,11 +41,15 @@ use alloy_rpc_types::{ serde_helpers::JsonStorageKey, state::StateOverride, trace::{ + filter::TraceFilter, geth::{ GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, NoopFrame, }, - parity::LocalizedTransactionTrace, + parity::{ + Action::{Call, Create, Reward, Selfdestruct}, + LocalizedTransactionTrace, + }, }, AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, @@ -62,6 +66,7 @@ use anvil_core::eth::{ utils::meets_eip155, }; use anvil_rpc::error::RpcError; + use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, @@ -2006,6 +2011,61 @@ impl Backend { Ok(None) } + // Returns the traces matching a given filter + pub async fn trace_filter( + &self, + filter: TraceFilter, + ) -> Result, BlockchainError> { + let matcher = filter.matcher(); + let start = filter.from_block.unwrap_or(0); + let end = filter.to_block.unwrap_or(self.best_number()); + + let dist = end.saturating_sub(start); + if dist == 0 { + return Err(BlockchainError::RpcError(RpcError::invalid_params( + "invalid block range, ensure that to block is greater than from block".to_string(), + ))); + } + if dist > 300 { + return Err(BlockchainError::RpcError(RpcError::invalid_params( + "block range too large, currently limited to 300".to_string(), + ))); + } + + // Accumulate tasks for block range + let mut trace_tasks = vec![]; + for num in start..=end { + trace_tasks.push(self.trace_block(num.into())); + } + + // Execute tasks and filter traces + let traces = futures::future::try_join_all(trace_tasks).await?; + let filtered_traces = + traces.into_iter().flatten().filter(|trace| match &trace.trace.action { + Call(call) => matcher.matches(call.from, Some(call.to)), + Create(create) => matcher.matches(create.from, None), + Selfdestruct(self_destruct) => { + matcher.matches(self_destruct.address, Some(self_destruct.refund_address)) + } + Reward(reward) => matcher.matches(reward.author, None), + }); + + // Apply after and count + let filtered_traces: Vec<_> = if let Some(after) = filter.after { + filtered_traces.skip(after as usize).collect() + } else { + filtered_traces.collect() + }; + + let filtered_traces: Vec<_> = if let Some(count) = filter.count { + filtered_traces.into_iter().take(count as usize).collect() + } else { + filtered_traces + }; + + Ok(filtered_traces) + } + /// Returns all receipts of the block pub fn mined_receipts(&self, hash: B256) -> Option> { let block = self.mined_block_by_hash(hash)?; diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 8a4d2a83d0dd1..7f2846d5c38c6 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -11,6 +11,7 @@ use alloy_provider::{ }; use alloy_rpc_types::{ trace::{ + filter::{TraceFilter, TraceFilterMode}, geth::{ CallConfig, GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, @@ -716,3 +717,144 @@ async fn test_trace_address_fork2() { } }) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_trace_filter() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.ws_provider(); + + let accounts = handle.dev_wallets().collect::>(); + let from = accounts[0].address(); + let to = accounts[1].address(); + let from_two = accounts[2].address(); + let to_two = accounts[3].address(); + + // Test default block ranges. + // From will be earliest, to will be best/latest + let tracer = TraceFilter { + from_block: None, + to_block: None, + from_address: vec![], + to_address: vec![], + mode: TraceFilterMode::Intersection, + after: None, + count: None, + }; + + for i in 0..=5 { + let tx = TransactionRequest::default().to(to).value(U256::from(i)).from(from); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + } + + let traces = api.trace_filter(tracer).await.unwrap(); + assert_eq!(traces.len(), 5); + + // Test filtering by address + let tracer = TraceFilter { + from_block: Some(provider.get_block_number().await.unwrap()), + to_block: None, + from_address: vec![from_two], + to_address: vec![to_two], + mode: TraceFilterMode::Intersection, + after: None, + count: None, + }; + + for i in 0..=5 { + let tx = TransactionRequest::default().to(to).value(U256::from(i)).from(from); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + + let tx = TransactionRequest::default().to(to_two).value(U256::from(i)).from(from_two); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + } + + let traces = api.trace_filter(tracer).await.unwrap(); + assert_eq!(traces.len(), 5); + + // Test for the following actions: + // Create (deploy the contract) + // Call (goodbye function) + // SelfDestruct (side-effect of goodbye) + let contract_addr = + SuicideContract::deploy_builder(provider.clone()).from(from).deploy().await.unwrap(); + let contract = SuicideContract::new(contract_addr, provider.clone()); + + // Test TraceActions + let tracer = TraceFilter { + from_block: Some(provider.get_block_number().await.unwrap()), + to_block: None, + from_address: vec![from, contract_addr], + to_address: vec![], // Leave as 0 address + mode: TraceFilterMode::Union, + after: None, + count: None, + }; + + // Execute call + let call = contract.goodbye().from(from); + let call = call.send().await.unwrap(); + call.get_receipt().await.unwrap(); + + // Mine transactions to filter against + for i in 0..=5 { + let tx = TransactionRequest::default().to(to_two).value(U256::from(i)).from(from_two); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + } + + let traces = api.trace_filter(tracer).await.unwrap(); + assert_eq!(traces.len(), 3); + + // Test Range Error + let latest = provider.get_block_number().await.unwrap(); + let tracer = TraceFilter { + from_block: Some(latest), + to_block: Some(latest + 301), + from_address: vec![], + to_address: vec![], + mode: TraceFilterMode::Union, + after: None, + count: None, + }; + + let traces = api.trace_filter(tracer).await; + assert!(traces.is_err()); + + // Test invalid block range + let latest = provider.get_block_number().await.unwrap(); + let tracer = TraceFilter { + from_block: Some(latest + 10), + to_block: Some(latest), + from_address: vec![], + to_address: vec![], + mode: TraceFilterMode::Union, + after: None, + count: None, + }; + + let traces = api.trace_filter(tracer).await; + assert!(traces.is_err()); + + // Test after and count + let tracer = TraceFilter { + from_block: Some(provider.get_block_number().await.unwrap()), + to_block: None, + from_address: vec![], + to_address: vec![], + mode: TraceFilterMode::Union, + after: Some(3), + count: Some(5), + }; + + for i in 0..=10 { + let tx = TransactionRequest::default().to(to).value(U256::from(i)).from(from); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + } + + let traces = api.trace_filter(tracer).await.unwrap(); + assert_eq!(traces.len(), 5); +} From 37ea1e99ec4b5f6416697ab4218396f978fe6d3e Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 19 Jul 2024 22:41:27 +0800 Subject: [PATCH 1268/1963] feat: better EOF/Prague support (#8471) * wip * [wip] better EOF support * clippy * fix tests * fix tests * bump block-explorers * bump inspectors * fix offsets for ext*calls --- Cargo.lock | 32 +++++----- Cargo.toml | 4 +- crates/anvil/src/hardfork.rs | 9 +++ crates/common/src/compile.rs | 6 +- crates/config/src/lib.rs | 21 +++++- crates/debugger/src/op.rs | 59 ++++++++++++----- crates/debugger/src/tui/context.rs | 67 +++++++++++--------- crates/debugger/src/tui/draw.rs | 16 ++++- crates/evm/traces/src/lib.rs | 1 + crates/forge/bin/cmd/coverage.rs | 3 +- crates/forge/tests/cli/config.rs | 2 + crates/test-utils/src/util.rs | 4 +- crates/verify/src/etherscan/standard_json.rs | 4 +- 13 files changed, 155 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ce89dfa8d907..01a2d97f73890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3543,9 +3543,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ecb3c05dbf9454cf58c6c440f84c5d2c8f4e94edb4b16f87cfad9e4d818065a" +checksum = "3306c1dfb236a3f7c86f7f6c9a88843d621cea96add97fdefbdc53ef3ecf6dfe" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3710,9 +3710,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f506a672502997fbc778f1d30eb4a06a58654049ccc6cd0bdb93a785175f682" +checksum = "ea06d58fce261a37f7c90ec4d2f14af729825bf7abbda14b64f8d728bc701480" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3748,9 +3748,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c352516419487416dde3250dbb56b576e0605429eb7b7b16f26849d924ee519" +checksum = "a0a0b1e385a5f9d88b0d6c9c8c1a5d89e33e5465e62096034abcd0dfd48a8618" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3758,9 +3758,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49104d442d6f0266c07edbdd23baa9a1db0f01d04bfdc69b6ac060a57e6f3e27" +checksum = "7ff1e9120d86202a81a7729f33fabfc77c12beca7233765d36c49ebcd8da100b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3772,6 +3772,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", + "serde_repr", "thiserror", "tokio", "tracing", @@ -3781,23 +3782,24 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f012d22d0690ad6b6bbcc8d70467325212ddea3457e8efda6affe17fb5ae938" +checksum = "8b88e8a09b7689253885c5171512987d6dea96ac328b2384f6a0233a332ec8d9" dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers-artifacts-solc", "foundry-compilers-core", "path-slash", + "semver 1.0.23", "serde", ] [[package]] name = "foundry-compilers-core" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23760fd6df67a9878ed0fe91e024bf1ff3b7358369cf54129539a8493177c6e7" +checksum = "f6ad521e38281f70e99a5487883179b4bfb74c855abebe5d5390d8e6d993503a" dependencies = [ "alloy-primitives", "cfg-if", @@ -6691,7 +6693,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.71", @@ -7116,9 +7118,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d485a7ccfbbcaf2d0c08c3d866dae279c6f71d7357862cbea637f23f27b7b695" +checksum = "af2dc001e37ac3b061dc9087876aea91e28756c188a97cd99416d23a5562ca73" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/Cargo.toml b/Cargo.toml index 02a78a204a86f..354f1549b279a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -157,8 +157,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.5.0", default-features = false } -foundry-compilers = { version = "0.9.0", default-features = false } +foundry-block-explorers = { version = "0.5.1", default-features = false } +foundry-compilers = { version = "0.10.0", default-features = false } foundry-fork-db = "0.2" solang-parser = "=0.3.3" diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index 3c6eb0aa8c212..de4c43c186575 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -21,6 +21,8 @@ pub enum Hardfork { Paris, Shanghai, Cancun, + Prague, + PragueEOF, #[default] Latest, } @@ -45,6 +47,8 @@ impl Hardfork { Self::Paris => 15537394, Self::Shanghai => 17034870, Self::Cancun | Self::Latest => 19426587, + // TODO: add block after activation + Self::Prague | Self::PragueEOF => unreachable!(), } } } @@ -72,6 +76,8 @@ impl FromStr for Hardfork { "paris" | "merge" | "15" => Self::Paris, "shanghai" | "16" => Self::Shanghai, "cancun" | "17" => Self::Cancun, + "prague" | "18" => Self::Prague, + "pragueeof" | "19" | "prague-eof" => Self::PragueEOF, "latest" => Self::Latest, _ => return Err(format!("Unknown hardfork {s}")), }; @@ -99,6 +105,9 @@ impl From for SpecId { Hardfork::Paris => Self::MERGE, Hardfork::Shanghai => Self::SHANGHAI, Hardfork::Cancun | Hardfork::Latest => Self::CANCUN, + Hardfork::Prague => Self::PRAGUE, + // TODO: switch to latest after activation + Hardfork::PragueEOF => Self::PRAGUE_EOF, } } } diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 116a00b62225e..0c39dd8734982 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -11,6 +11,7 @@ use foundry_compilers::{ Compiler, }, report::{BasicStdoutReporter, NoReporter, Report}, + solc::SolcSettings, Artifact, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, SolcConfig, }; use num_format::{Locale, ToFormattedString}; @@ -405,7 +406,10 @@ pub fn etherscan_project( let compiler = SolcCompiler::Specific(solc); Ok(ProjectBuilder::::default() - .settings(SolcConfig::builder().settings(settings).build().settings) + .settings(SolcSettings { + settings: SolcConfig::builder().settings(settings).build().settings, + ..Default::default() + }) .paths(paths) .ephemeral() .no_artifacts() diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f82975c670ee9..f5222a78dbf12 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -21,7 +21,7 @@ use foundry_compilers::{ artifacts::{ output_selection::{ContractOutputSelection, OutputSelection}, remappings::{RelativeRemapping, Remapping}, - serde_helpers, BytecodeHash, DebuggingSettings, EvmVersion, Libraries, + serde_helpers, BytecodeHash, DebuggingSettings, EofVersion, EvmVersion, Libraries, ModelCheckerSettings, ModelCheckerTarget, Optimizer, OptimizerDetails, RevertStrings, Settings, SettingsMetadata, Severity, }, @@ -33,6 +33,7 @@ use foundry_compilers::{ Compiler, }, error::SolcError, + solc::{CliSettings, SolcSettings}, ConfigurableArtifacts, Project, ProjectPathsConfig, VyperLanguage, }; use inflector::Inflector; @@ -443,6 +444,14 @@ pub struct Config { /// Whether `failed()` should be invoked to check if the test have failed. pub legacy_assertions: bool, + /// Optional additional CLI arguments to pass to `solc` binary. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub extra_args: Vec, + + /// Optional EOF version. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub eof_version: Option, + /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information #[serde(rename = "__warnings", default, skip_serializing)] pub warnings: Vec, @@ -1277,7 +1286,7 @@ impl Config { /// - all libraries /// - the optimizer (including details, if configured) /// - evm version - pub fn solc_settings(&self) -> Result { + pub fn solc_settings(&self) -> Result { // By default if no targets are specifically selected the model checker uses all targets. // This might be too much here, so only enable assertion checks. // If users wish to enable all options they need to do so explicitly. @@ -1310,6 +1319,7 @@ impl Config { remappings: Vec::new(), // Set with `with_extra_output` below. output_selection: Default::default(), + eof_version: self.eof_version, } .with_extra_output(self.configured_artifacts_handler().output_selection()); @@ -1318,7 +1328,10 @@ impl Config { settings = settings.with_ast(); } - Ok(settings) + let cli_settings = + CliSettings { extra_args: self.extra_args.clone(), ..Default::default() }; + + Ok(SolcSettings { settings, cli_settings }) } /// Returns the configured [VyperSettings] that includes: @@ -2133,6 +2146,8 @@ impl Default for Config { assertions_revert: true, legacy_assertions: false, warnings: vec![], + extra_args: vec![], + eof_version: None, _non_exhaustive: (), } } diff --git a/crates/debugger/src/op.rs b/crates/debugger/src/op.rs index 486fbe09fbeb0..bc8e96ccb3997 100644 --- a/crates/debugger/src/op.rs +++ b/crates/debugger/src/op.rs @@ -1,3 +1,6 @@ +use alloy_primitives::Bytes; +use revm::interpreter::opcode; + /// Named parameter of an EVM opcode. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub(crate) struct OpcodeParam { @@ -8,10 +11,35 @@ pub(crate) struct OpcodeParam { } impl OpcodeParam { - /// Returns the list of named parameters for the given opcode. + /// Returns the list of named parameters for the given opcode, accounts for special opcodes + /// requiring immediate bytes to determine stack items. #[inline] - pub(crate) fn of(op: u8) -> &'static [Self] { - MAP[op as usize] + pub(crate) fn of(op: u8, immediate: Option<&Bytes>) -> Option> { + match op { + // Handle special cases requiring immediate bytes + opcode::DUPN => immediate + .and_then(|i| i.first().copied()) + .map(|i| vec![Self { name: "dup_value", index: i as usize }]), + opcode::SWAPN => immediate.and_then(|i| { + i.first().map(|i| { + vec![ + Self { name: "a", index: 1 }, + Self { name: "swap_value", index: *i as usize }, + ] + }) + }), + opcode::EXCHANGE => immediate.and_then(|i| { + i.first().map(|imm| { + let n = (imm >> 4) + 1; + let m = (imm & 0xf) + 1; + vec![ + Self { name: "value1", index: n as usize }, + Self { name: "value2", index: m as usize }, + ] + }) + }), + _ => Some(MAP[op as usize].to_vec()), + } } } @@ -41,11 +69,12 @@ const fn map_opcode(op: u8) -> &'static [OpcodeParam] { // https://www.evm.codes // https://github.com/smlxl/evm.codes - // https://github.com/smlxl/evm.codes/blob/HEAD/opcodes.json + // https://github.com/klkvr/evm.codes + // https://github.com/klkvr/evm.codes/blob/HEAD/opcodes.json // jq -rf opcodes.jq opcodes.json /* def mkargs(input): - input | split(" | ") | to_entries | map("\(.key): \(.value)") | join(", "); + input | split(" | ") | to_entries | map("\(.key): \"\(.value)\"") | join(", "); to_entries[] | "0x\(.key)(\(mkargs(.value.input)))," */ @@ -265,10 +294,10 @@ const fn map_opcode(op: u8) -> &'static [OpcodeParam] { 0xcd(), 0xce(), 0xcf(), - 0xd0(), + 0xd0(0: "offset"), 0xd1(), 0xd2(), - 0xd3(), + 0xd3(0: "memOffset", 1: "offset", 2: "size"), 0xd4(), 0xd5(), 0xd6(), @@ -282,8 +311,8 @@ const fn map_opcode(op: u8) -> &'static [OpcodeParam] { 0xde(), 0xdf(), 0xe0(), - 0xe1(), - 0xe2(), + 0xe1(0: "condition"), + 0xe2(0: "case"), 0xe3(), 0xe4(), 0xe5(), @@ -293,9 +322,9 @@ const fn map_opcode(op: u8) -> &'static [OpcodeParam] { 0xe9(), 0xea(), 0xeb(), - 0xec(), + 0xec(0: "value", 1: "salt", 2: "offset", 3: "size"), 0xed(), - 0xee(), + 0xee(0: "offset", 1: "size"), 0xef(), 0xf0(0: "value", 1: "offset", 2: "size"), 0xf1(0: "gas", 1: "address", 2: "value", 3: "argsOffset", 4: "argsSize", 5: "retOffset", 6: "retSize"), @@ -304,11 +333,11 @@ const fn map_opcode(op: u8) -> &'static [OpcodeParam] { 0xf4(0: "gas", 1: "address", 2: "argsOffset", 3: "argsSize", 4: "retOffset", 5: "retSize"), 0xf5(0: "value", 1: "offset", 2: "size", 3: "salt"), 0xf6(), - 0xf7(), - 0xf8(), - 0xf9(), + 0xf7(0: "offset"), + 0xf8(0: "address", 1: "argsOffset", 2: "argsSize", 3: "value"), + 0xf9(0: "address", 1: "argsOffset", 2: "argsSize"), 0xfa(0: "gas", 1: "address", 2: "argsOffset", 3: "argsSize", 4: "retOffset", 5: "retSize"), - 0xfb(), + 0xfb(0: "address", 1: "argsOffset", 2: "argsSize"), 0xfc(), 0xfd(0: "offset", 1: "size"), 0xfe(), diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index a6bcfbb929365..6792145fe245d 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -3,7 +3,7 @@ use crate::{DebugNode, Debugger, ExitReason}; use alloy_primitives::{hex, Address}; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; -use revm::interpreter::opcode; +use revm::interpreter::OpCode; use revm_inspectors::tracing::types::{CallKind, CallTraceStep}; use std::ops::ControlFlow; @@ -115,8 +115,8 @@ impl<'a> DebuggerContext<'a> { fn gen_opcode_list(&mut self) { self.opcode_list.clear(); let debug_steps = &self.debugger.debug_arena[self.draw_memory.inner_call_index].steps; - for (i, step) in debug_steps.iter().enumerate() { - self.opcode_list.push(pretty_opcode(step, debug_steps.get(i + 1))); + for step in debug_steps { + self.opcode_list.push(pretty_opcode(step)); } } @@ -230,20 +230,20 @@ impl DebuggerContext<'_> { // Step forward KeyCode::Char('s') => self.repeat(|this| { - let remaining_ops = &this.opcode_list[this.current_step..]; - if let Some((i, _)) = remaining_ops.iter().enumerate().skip(1).find(|&(i, op)| { - let prev = &remaining_ops[i - 1]; - let prev_is_jump = prev.contains("JUMP") && prev != "JUMPDEST"; - let is_jumpdest = op == "JUMPDEST"; - prev_is_jump && is_jumpdest - }) { - this.current_step += i; + let remaining_steps = &this.debug_steps()[this.current_step..]; + if let Some((i, _)) = + remaining_steps.iter().enumerate().skip(1).find(|(i, step)| { + let prev = &remaining_steps[*i - 1]; + is_jump(step, prev) + }) + { + this.current_step += i } }), // Step backwards KeyCode::Char('a') => self.repeat(|this| { - let ops = &this.opcode_list[..this.current_step]; + let ops = &this.debug_steps()[..this.current_step]; this.current_step = ops .iter() .enumerate() @@ -251,9 +251,7 @@ impl DebuggerContext<'_> { .rev() .find(|&(i, op)| { let prev = &ops[i - 1]; - let prev_is_jump = prev.contains("JUMP") && prev != "JUMPDEST"; - let is_jumpdest = op == "JUMPDEST"; - prev_is_jump && is_jumpdest + is_jump(op, prev) }) .map(|(i, _)| i) .unwrap_or_default(); @@ -349,23 +347,34 @@ fn buffer_as_number(s: &str) -> usize { s.parse().unwrap_or(MIN).clamp(MIN, MAX) } -fn pretty_opcode(step: &CallTraceStep, next_step: Option<&CallTraceStep>) -> String { - let op = step.op; - let instruction = op.get(); - let push_size = if (opcode::PUSH1..=opcode::PUSH32).contains(&instruction) { - (instruction - opcode::PUSH0) as usize +fn pretty_opcode(step: &CallTraceStep) -> String { + if let Some(immediate) = step.immediate_bytes.as_ref().filter(|b| !b.is_empty()) { + format!("{}(0x{})", step.op, hex::encode(immediate)) } else { - 0 - }; - if push_size == 0 { - return step.op.to_string(); + step.op.to_string() } +} + +fn is_jump(step: &CallTraceStep, prev: &CallTraceStep) -> bool { + if !matches!( + prev.op, + OpCode::JUMP | + OpCode::JUMPI | + OpCode::JUMPF | + OpCode::RJUMP | + OpCode::RJUMPI | + OpCode::RJUMPV | + OpCode::CALLF | + OpCode::RETF + ) { + return false + } + + let immediate_len = prev.immediate_bytes.as_ref().map_or(0, |b| b.len()); - // Get push byte as the top-most stack item on the next step - if let Some(pushed) = next_step.and_then(|s| s.stack.as_ref()).and_then(|s| s.last()) { - let bytes = &pushed.to_be_bytes_vec()[32 - push_size..]; - format!("{op}(0x{})", hex::encode(bytes)) + if step.pc != prev.pc + 1 + immediate_len { + true } else { - op.to_string() + step.code_section_idx != prev.code_section_idx } } diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index d74a085a07490..509b986fdb323 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -377,10 +377,11 @@ impl DebuggerContext<'_> { .collect::>(); let title = format!( - "Address: {} | PC: {} | Gas used in call: {}", + "Address: {} | PC: {} | Gas used in call: {} | Code section: {}", self.address(), self.current_step().pc, self.current_step().gas_used, + self.current_step().code_section_idx, ); let block = Block::default().title(title).borders(Borders::ALL); let list = List::new(items) @@ -399,7 +400,7 @@ impl DebuggerContext<'_> { let min_len = decimal_digits(stack_len).max(2); - let params = OpcodeParam::of(step.op.get()); + let params = OpcodeParam::of(step.op.get(), step.immediate_bytes.as_ref()); let text: Vec> = stack .map(|stack| { @@ -409,7 +410,9 @@ impl DebuggerContext<'_> { .enumerate() .skip(self.draw_memory.current_stack_startline) .map(|(i, stack_item)| { - let param = params.iter().find(|param| param.index == i); + let param = params + .as_ref() + .and_then(|params| params.iter().find(|param| param.index == i)); let mut spans = Vec::with_capacity(1 + 32 * 2 + 3); @@ -665,6 +668,13 @@ fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { opcode::CALL | opcode::CALLCODE => (Some((BufferKind::Memory, 4, 5)), None), opcode::DELEGATECALL | opcode::STATICCALL => (Some((BufferKind::Memory, 3, 4)), None), opcode::MCOPY => (Some((BufferKind::Memory, 2, 3)), Some((1, 3))), + opcode::RETURNDATALOAD => (Some((BufferKind::Returndata, 1, -1)), None), + opcode::EOFCREATE => (Some((BufferKind::Memory, 3, 4)), None), + opcode::RETURNCONTRACT => (Some((BufferKind::Memory, 1, 2)), None), + opcode::DATACOPY => (None, Some((1, 3))), + opcode::EXTCALL | opcode::EXTSTATICCALL | opcode::EXTDELEGATECALL => { + (Some((BufferKind::Memory, 2, 3)), None) + } _ => Default::default(), }; diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index c098fe4be1609..4677a02bc9fd8 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -210,6 +210,7 @@ impl TraceMode { record_opcodes_filter: (self.is_jump() || self.is_jump_simple()) .then(|| OpcodeFilter::new().enabled(OpCode::JUMP).enabled(OpCode::JUMPDEST)), exclude_precompile_calls: false, + record_immediate_bytes: self.is_debug(), } .into() } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index c82e24621273f..487c0a7f15802 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -127,7 +127,8 @@ impl CoverageArgs { // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 // And also in new releases of solidity: // https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 - project.settings.solc = project.settings.solc.with_via_ir_minimum_optimization() + project.settings.solc.settings = + project.settings.solc.settings.with_via_ir_minimum_optimization() } else { project.settings.solc.optimizer.disable(); project.settings.solc.optimizer.runs = None; diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f259579d616f7..a5ec38ec1e83f 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -147,6 +147,8 @@ forgetest!(can_extract_config_values, |prj, cmd| { warnings: vec![], assertions_revert: true, legacy_assertions: false, + extra_args: vec![], + eof_version: None, _non_exhaustive: (), }; prj.write_config(input.clone()); diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 56d492ebdff8f..c1c2df0b01439 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1,11 +1,11 @@ use crate::init_tracing; use eyre::{Result, WrapErr}; use foundry_compilers::{ - artifacts::Settings, cache::CompilerCache, compilers::multi::MultiCompiler, error::Result as SolcResult, project_util::{copy_dir, TempProject}, + solc::SolcSettings, ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, }; use foundry_config::Config; @@ -547,7 +547,7 @@ impl TestProject { #[track_caller] pub fn assert_create_dirs_exists(&self) { self.paths().create_all().unwrap_or_else(|_| panic!("Failed to create project paths")); - CompilerCache::::default() + CompilerCache::::default() .write(&self.paths().cache) .expect("Failed to create cache"); self.assert_all_paths_exist(); diff --git a/crates/verify/src/etherscan/standard_json.rs b/crates/verify/src/etherscan/standard_json.rs index 944ee6b101cf5..cab3010fa638c 100644 --- a/crates/verify/src/etherscan/standard_json.rs +++ b/crates/verify/src/etherscan/standard_json.rs @@ -2,7 +2,7 @@ use super::{EtherscanSourceProvider, VerifyArgs}; use crate::provider::VerificationContext; use eyre::{Context, Result}; use foundry_block_explorers::verify::CodeFormat; -use foundry_compilers::artifacts::StandardJsonCompilerInput; +use foundry_compilers::{artifacts::StandardJsonCompilerInput, solc::SolcLanguage}; #[derive(Debug)] pub struct EtherscanStandardJsonSource; @@ -29,7 +29,7 @@ impl EtherscanSourceProvider for EtherscanStandardJsonSource { .collect(); // remove all incompatible settings - input.settings.sanitize(&context.compiler_version); + input.settings.sanitize(&context.compiler_version, SolcLanguage::Solidity); let source = serde_json::to_string(&input).wrap_err("Failed to parse standard json input")?; From dc382f42a36a58523004dcf15de1653e0ad27fb4 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 19 Jul 2024 23:00:13 +0800 Subject: [PATCH 1269/1963] fix: cargo deny (#8479) --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01a2d97f73890..1b5439e59bcf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4482,9 +4482,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca987128ffb056d732bd545db5db3d8b103d252fbf083c2567bb0796876619a4" +checksum = "8d23d5bbda31344d8abc8de7c075b3cf26e5873feba7c4a15d916bce67382bd9" dependencies = [ "bstr 1.9.1", "gix-trace", From 94b6c6bf857b52d11b90f0ce248ff67ca45460b1 Mon Sep 17 00:00:00 2001 From: Luca Provini Date: Fri, 19 Jul 2024 21:51:10 +0200 Subject: [PATCH 1270/1963] feat: ethGetAccount (#8477) * feat: ethGetAccount * adding await --- crates/anvil/core/src/eth/mod.rs | 3 +++ crates/anvil/src/eth/api.rs | 28 ++++++++++++++++++++++++- crates/anvil/src/eth/backend/fork.rs | 10 +++++++++ crates/anvil/src/eth/backend/mem/mod.rs | 19 ++++++++++++++++- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index b13408d3caea9..185e723f384cc 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -86,6 +86,9 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "eth_getBalance"))] EthGetBalance(Address, Option), + #[cfg_attr(feature = "serde", serde(rename = "eth_getAccount"))] + EthGetAccount(Address, Option), + #[cfg_attr(feature = "serde", serde(rename = "eth_getStorageAt"))] EthGetStorageAt(Address, U256, Option), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index cd3a8dadab700..d6f0dc03e9039 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -31,7 +31,7 @@ use crate::{ revm::primitives::{BlobExcessGasAndPrice, Output}, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; -use alloy_consensus::{transaction::eip4844::TxEip4844Variant, TxEnvelope}; +use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account, TxEnvelope}; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; use alloy_network::eip2718::Decodable2718; @@ -155,6 +155,9 @@ impl EthApi { match request { EthRequest::Web3ClientVersion(()) => self.client_version().to_rpc_result(), EthRequest::Web3Sha3(content) => self.sha3(content).to_rpc_result(), + EthRequest::EthGetAccount(addr, block) => { + self.get_account(addr, block).await.to_rpc_result() + } EthRequest::EthGetBalance(addr, block) => { self.balance(addr, block).await.to_rpc_result() } @@ -658,6 +661,29 @@ impl EthApi { self.backend.get_balance(address, Some(block_request)).await } + /// Returns the ethereum account. + /// + /// Handler for ETH RPC call: `eth_getAccount` + pub async fn get_account( + &self, + address: Address, + block_number: Option, + ) -> Result { + node_info!("eth_getAccount"); + let block_request = self.block_request(block_number).await?; + + // check if the number predates the fork, if in fork mode + if let BlockRequest::Number(number) = block_request { + if let Some(fork) = self.get_fork() { + if fork.predates_fork(number) { + return Ok(fork.get_account(address, number).await?) + } + } + } + + self.backend.get_account_at_block(address, Some(block_request)).await + } + /// Returns content of the storage at given address. /// /// Handler for ETH RPC call: `eth_getStorageAt` diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 17121e59c1f9e..d4b51ae9602e7 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -1,6 +1,7 @@ //! Support for forking off another client use crate::eth::{backend::db::Db, error::BlockchainError, pool::transactions::PoolTransaction}; +use alloy_consensus::Account; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; use alloy_provider::{ ext::{DebugApi, TraceApi}, @@ -266,6 +267,15 @@ impl ClientFork { self.provider().get_transaction_count(address).block_id(block.into()).await } + pub async fn get_account( + &self, + address: Address, + blocknumber: u64, + ) -> Result { + trace!(target: "backend::fork", "get_account={:?}", address); + self.provider().get_account(address).await.block_id(blocknumber.into()).await + } + pub async fn transaction_by_block_number_and_index( &self, number: u64, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 6abfbea2869b2..6cd04f4bcca88 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -32,7 +32,7 @@ use crate::{ revm::{db::DatabaseRef, primitives::AccountInfo}, NodeConfig, PrecompileFactory, }; -use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; +use alloy_consensus::{Account, Header, Receipt, ReceiptWithBloom}; use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK; use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256, U64}; use alloy_rpc_types::{ @@ -1865,6 +1865,23 @@ impl Backend { .await? } + pub async fn get_account_at_block( + &self, + address: Address, + block_request: Option, + ) -> Result { + self.with_database_at(block_request, |block_db, _| { + let db = block_db.maybe_as_full_db().ok_or(BlockchainError::DataUnavailable)?; + let account = db.get(&address).cloned().unwrap_or_default(); + let storage_root = storage_root(&account.storage); + let code_hash = account.info.code_hash; + let balance = account.info.balance; + let nonce = account.info.nonce; + Ok(Account { balance, nonce, code_hash, storage_root }) + }) + .await? + } + pub fn get_balance_with_state( &self, state: D, From e436daafbe9844f8ec5e1f93b45692180ecdf4fc Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 20 Jul 2024 15:50:25 +0800 Subject: [PATCH 1271/1963] feat: support for EIP-7702 in Anvil (#8476) feat: EIP-7702 support in Anvil Co-authored-by: Matthias Seitz --- crates/anvil/core/src/eth/transaction/mod.rs | 183 ++++++++++++++----- crates/anvil/src/eth/api.rs | 1 + crates/anvil/src/eth/backend/executor.rs | 1 + crates/anvil/src/eth/backend/mem/mod.rs | 20 +- crates/anvil/src/eth/error.rs | 5 + crates/anvil/src/eth/fees.rs | 4 + crates/anvil/tests/it/eip7702.rs | 79 ++++++++ crates/anvil/tests/it/main.rs | 1 + 8 files changed, 248 insertions(+), 46 deletions(-) create mode 100644 crates/anvil/tests/it/eip7702.rs diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 49b02d8922bcf..5aeb2cd0d7d3b 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -2,7 +2,10 @@ use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest}; use alloy_consensus::{ - transaction::eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, + transaction::{ + eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, + TxEip7702, + }, AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, TxEnvelope, TxLegacy, TxReceipt, TxType, }; @@ -279,7 +282,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( block_number: None, transaction_index: None, from, - to: None, + to: t.tx().to.to().copied(), value: t.tx().value, gas_price: Some(t.tx().gas_price), max_fee_per_gas: Some(t.tx().gas_price), @@ -307,7 +310,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( block_number: None, transaction_index: None, from, - to: None, + to: t.tx().to.to().copied(), value: t.tx().value, gas_price: Some(t.tx().gas_price), max_fee_per_gas: Some(t.tx().gas_price), @@ -335,7 +338,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( block_number: None, transaction_index: None, from, - to: None, + to: t.tx().to.to().copied(), value: t.tx().value, gas_price: None, max_fee_per_gas: Some(t.tx().max_fee_per_gas), @@ -363,7 +366,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( block_number: None, transaction_index: None, from, - to: None, + to: Some(t.tx().tx().to), value: t.tx().tx().value, gas_price: Some(t.tx().tx().max_fee_per_gas), max_fee_per_gas: Some(t.tx().tx().max_fee_per_gas), @@ -384,6 +387,32 @@ pub fn to_alloy_transaction_with_hash_and_sender( other: Default::default(), authorization_list: None, }, + TypedTransaction::EIP7702(t) => RpcTransaction { + hash, + nonce: t.tx().nonce, + block_hash: None, + block_number: None, + transaction_index: None, + from, + to: t.tx().to.to().copied(), + value: t.tx().value, + gas_price: Some(t.tx().max_fee_per_gas), + max_fee_per_gas: Some(t.tx().max_fee_per_gas), + max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas), + gas: t.tx().gas_limit, + input: t.tx().input.clone(), + chain_id: Some(t.tx().chain_id), + signature: Some(RpcSignature { + r: t.signature().r(), + s: t.signature().s(), + v: U256::from(t.signature().v().to_u64()), + y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), + }), + access_list: Some(t.tx().access_list.clone()), + transaction_type: Some(4), + authorization_list: Some(t.tx().authorization_list.clone()), + ..Default::default() + }, TypedTransaction::Deposit(t) => RpcTransaction { hash, nonce: t.nonce, @@ -391,7 +420,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( block_number: None, transaction_index: None, from, - to: None, + to: t.kind.to().copied(), value: t.value, gas_price: None, max_fee_per_gas: None, @@ -563,6 +592,34 @@ impl PendingTransaction { ..Default::default() } } + TypedTransaction::EIP7702(tx) => { + let TxEip7702 { + chain_id, + nonce, + gas_limit, + max_fee_per_gas, + max_priority_fee_per_gas, + to, + value, + access_list, + authorization_list, + input, + } = tx.tx(); + TxEnv { + caller, + transact_to: *to, + data: input.clone(), + chain_id: Some(*chain_id), + nonce: Some(*nonce), + value: *value, + gas_price: U256::from(*max_fee_per_gas), + gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), + gas_limit: *gas_limit as u64, + access_list: access_list.clone().into(), + authorization_list: Some(authorization_list.clone().into()), + ..Default::default() + } + } TypedTransaction::Deposit(tx) => { let chain_id = tx.chain_id(); let DepositTransaction { @@ -611,6 +668,8 @@ pub enum TypedTransaction { EIP1559(Signed), /// EIP-4844 transaction EIP4844(Signed), + /// EIP-7702 transaction + EIP7702(Signed), /// op-stack deposit transaction Deposit(DepositTransaction), } @@ -618,7 +677,7 @@ pub enum TypedTransaction { impl TypedTransaction { /// Returns true if the transaction uses dynamic fees: EIP1559 or EIP4844 pub fn is_dynamic_fee(&self) -> bool { - matches!(self, Self::EIP1559(_)) || matches!(self, Self::EIP4844(_)) + matches!(self, Self::EIP1559(_) | Self::EIP4844(_) | Self::EIP7702(_)) } pub fn gas_price(&self) -> u128 { @@ -627,6 +686,7 @@ impl TypedTransaction { Self::EIP2930(tx) => tx.tx().gas_price, Self::EIP1559(tx) => tx.tx().max_fee_per_gas, Self::EIP4844(tx) => tx.tx().tx().max_fee_per_gas, + Self::EIP7702(tx) => tx.tx().max_fee_per_gas, Self::Deposit(_) => 0, } } @@ -637,6 +697,7 @@ impl TypedTransaction { Self::EIP2930(tx) => tx.tx().gas_limit, Self::EIP1559(tx) => tx.tx().gas_limit, Self::EIP4844(tx) => tx.tx().tx().gas_limit, + Self::EIP7702(tx) => tx.tx().gas_limit, Self::Deposit(tx) => tx.gas_limit, } } @@ -647,6 +708,7 @@ impl TypedTransaction { Self::EIP2930(tx) => tx.tx().value, Self::EIP1559(tx) => tx.tx().value, Self::EIP4844(tx) => tx.tx().tx().value, + Self::EIP7702(tx) => tx.tx().value, Self::Deposit(tx) => tx.value, }) } @@ -657,6 +719,7 @@ impl TypedTransaction { Self::EIP2930(tx) => &tx.tx().input, Self::EIP1559(tx) => &tx.tx().input, Self::EIP4844(tx) => &tx.tx().tx().input, + Self::EIP7702(tx) => &tx.tx().input, Self::Deposit(tx) => &tx.input, } } @@ -668,6 +731,7 @@ impl TypedTransaction { Self::EIP2930(_) => Some(1), Self::EIP1559(_) => Some(2), Self::EIP4844(_) => Some(3), + Self::EIP7702(_) => Some(4), Self::Deposit(_) => Some(0x7E), } } @@ -710,7 +774,7 @@ impl TypedTransaction { input: t.tx().input.clone(), nonce: t.tx().nonce, gas_limit: t.tx().gas_limit, - gas_price: Some(U256::from(t.tx().gas_price)), + gas_price: Some(t.tx().gas_price), max_fee_per_gas: None, max_priority_fee_per_gas: None, max_fee_per_blob_gas: None, @@ -724,7 +788,7 @@ impl TypedTransaction { input: t.tx().input.clone(), nonce: t.tx().nonce, gas_limit: t.tx().gas_limit, - gas_price: Some(U256::from(t.tx().gas_price)), + gas_price: Some(t.tx().gas_price), max_fee_per_gas: None, max_priority_fee_per_gas: None, max_fee_per_blob_gas: None, @@ -739,8 +803,8 @@ impl TypedTransaction { nonce: t.tx().nonce, gas_limit: t.tx().gas_limit, gas_price: None, - max_fee_per_gas: Some(U256::from(t.tx().max_fee_per_gas)), - max_priority_fee_per_gas: Some(U256::from(t.tx().max_priority_fee_per_gas)), + max_fee_per_gas: Some(t.tx().max_fee_per_gas), + max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas), max_fee_per_blob_gas: None, blob_versioned_hashes: None, value: t.tx().value, @@ -752,21 +816,35 @@ impl TypedTransaction { input: t.tx().tx().input.clone(), nonce: t.tx().tx().nonce, gas_limit: t.tx().tx().gas_limit, - gas_price: Some(U256::from(t.tx().tx().max_fee_per_blob_gas)), - max_fee_per_gas: Some(U256::from(t.tx().tx().max_fee_per_gas)), - max_priority_fee_per_gas: Some(U256::from(t.tx().tx().max_priority_fee_per_gas)), - max_fee_per_blob_gas: Some(U256::from(t.tx().tx().max_fee_per_blob_gas)), + gas_price: Some(t.tx().tx().max_fee_per_blob_gas), + max_fee_per_gas: Some(t.tx().tx().max_fee_per_gas), + max_priority_fee_per_gas: Some(t.tx().tx().max_priority_fee_per_gas), + max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas), blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), value: t.tx().tx().value, chain_id: Some(t.tx().tx().chain_id), access_list: t.tx().tx().access_list.clone(), }, + Self::EIP7702(t) => TransactionEssentials { + kind: t.tx().to, + input: t.tx().input.clone(), + nonce: t.tx().nonce, + gas_limit: t.tx().gas_limit, + gas_price: Some(t.tx().max_fee_per_gas), + max_fee_per_gas: Some(t.tx().max_fee_per_gas), + max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas), + max_fee_per_blob_gas: None, + blob_versioned_hashes: None, + value: t.tx().value, + chain_id: Some(t.tx().chain_id), + access_list: t.tx().access_list.clone(), + }, Self::Deposit(t) => TransactionEssentials { kind: t.kind, input: t.input.clone(), nonce: t.nonce, gas_limit: t.gas_limit, - gas_price: Some(U256::from(0)), + gas_price: Some(0), max_fee_per_gas: None, max_priority_fee_per_gas: None, max_fee_per_blob_gas: None, @@ -784,6 +862,7 @@ impl TypedTransaction { Self::EIP2930(t) => t.tx().nonce, Self::EIP1559(t) => t.tx().nonce, Self::EIP4844(t) => t.tx().tx().nonce, + Self::EIP7702(t) => t.tx().nonce, Self::Deposit(t) => t.nonce, } } @@ -794,6 +873,7 @@ impl TypedTransaction { Self::EIP2930(t) => Some(t.tx().chain_id), Self::EIP1559(t) => Some(t.tx().chain_id), Self::EIP4844(t) => Some(t.tx().tx().chain_id), + Self::EIP7702(t) => Some(t.tx().chain_id), Self::Deposit(t) => t.chain_id(), } } @@ -835,6 +915,7 @@ impl TypedTransaction { Self::EIP2930(t) => *t.hash(), Self::EIP1559(t) => *t.hash(), Self::EIP4844(t) => *t.hash(), + Self::EIP7702(t) => *t.hash(), Self::Deposit(t) => t.hash(), } } @@ -857,6 +938,7 @@ impl TypedTransaction { Self::EIP2930(tx) => tx.recover_signer(), Self::EIP1559(tx) => tx.recover_signer(), Self::EIP4844(tx) => tx.recover_signer(), + Self::EIP7702(tx) => tx.recover_signer(), Self::Deposit(tx) => tx.recover(), } } @@ -868,6 +950,7 @@ impl TypedTransaction { Self::EIP2930(tx) => tx.tx().to, Self::EIP1559(tx) => tx.tx().to, Self::EIP4844(tx) => TxKind::Call(tx.tx().tx().to), + Self::EIP7702(tx) => tx.tx().to, Self::Deposit(tx) => tx.kind, } } @@ -884,6 +967,7 @@ impl TypedTransaction { Self::EIP2930(tx) => *tx.signature(), Self::EIP1559(tx) => *tx.signature(), Self::EIP4844(tx) => *tx.signature(), + Self::EIP7702(tx) => *tx.signature(), Self::Deposit(_) => Signature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), @@ -993,20 +1077,11 @@ impl TryFrom for TypedTransaction { impl Encodable for TypedTransaction { fn encode(&self, out: &mut dyn bytes::BufMut) { - match self { - Self::Legacy(tx) => TxEnvelope::from(tx.clone()).encode(out), - Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode(out), - Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode(out), - Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode(out), - Self::Deposit(tx) => { - let tx_payload_len = tx.fields_len(); - let tx_header_len = Header { list: false, payload_length: tx_payload_len }.length(); - Header { list: false, payload_length: 1 + tx_payload_len + tx_header_len } - .encode(out); - out.put_u8(0x7E); - tx.encode(out); - } + if !self.is_legacy() { + Header { list: false, payload_length: self.encode_2718_len() }.encode(out); } + + self.encode_2718(out); } } @@ -1042,6 +1117,10 @@ impl Encodable2718 for TypedTransaction { Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), + Self::EIP7702(tx) => { + let payload_length = tx.tx().fields_len() + tx.signature().rlp_vrs_len(); + Header { list: true, payload_length }.length() + payload_length + 1 + } Self::Deposit(tx) => 1 + tx.length(), } } @@ -1052,6 +1131,7 @@ impl Encodable2718 for TypedTransaction { Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), + Self::EIP7702(tx) => tx.tx().encode_with_signature(tx.signature(), out, false), Self::Deposit(tx) => { out.put_u8(0x7E); tx.encode(out); @@ -1062,8 +1142,10 @@ impl Encodable2718 for TypedTransaction { impl Decodable2718 for TypedTransaction { fn typed_decode(ty: u8, buf: &mut &[u8]) -> Result { - if ty == 0x7E { - return Ok(Self::Deposit(DepositTransaction::decode(buf)?)); + match ty { + 0x04 => return Ok(Self::EIP7702(TxEip7702::decode_signed_fields(buf)?)), + 0x7E => return Ok(Self::Deposit(DepositTransaction::decode(buf)?)), + _ => {} } match TxEnvelope::typed_decode(ty, buf)? { TxEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)), @@ -1099,10 +1181,10 @@ pub struct TransactionEssentials { pub input: Bytes, pub nonce: u64, pub gas_limit: u128, - pub gas_price: Option, - pub max_fee_per_gas: Option, - pub max_priority_fee_per_gas: Option, - pub max_fee_per_blob_gas: Option, + pub gas_price: Option, + pub max_fee_per_gas: Option, + pub max_priority_fee_per_gas: Option, + pub max_fee_per_blob_gas: Option, pub blob_versioned_hashes: Option>, pub value: U256, pub chain_id: Option, @@ -1233,6 +1315,8 @@ pub enum TypedReceipt { EIP1559(ReceiptWithBloom), #[serde(rename = "0x3", alias = "0x03")] EIP4844(ReceiptWithBloom), + #[serde(rename = "0x4", alias = "0x04")] + EIP7702(ReceiptWithBloom), #[serde(rename = "0x7E", alias = "0x7e")] Deposit(DepositReceipt), } @@ -1240,7 +1324,11 @@ pub enum TypedReceipt { impl TypedReceipt { pub fn as_receipt_with_bloom(&self) -> &ReceiptWithBloom { match self { - Self::Legacy(r) | Self::EIP1559(r) | Self::EIP2930(r) | Self::EIP4844(r) => r, + Self::Legacy(r) | + Self::EIP1559(r) | + Self::EIP2930(r) | + Self::EIP4844(r) | + Self::EIP7702(r) => r, Self::Deposit(r) => &r.inner, } } @@ -1252,7 +1340,8 @@ impl From> for ReceiptWithBloom { TypedReceipt::Legacy(r) | TypedReceipt::EIP1559(r) | TypedReceipt::EIP2930(r) | - TypedReceipt::EIP4844(r) => r, + TypedReceipt::EIP4844(r) | + TypedReceipt::EIP7702(r) => r, TypedReceipt::Deposit(r) => r.inner, } } @@ -1265,6 +1354,7 @@ impl From> for OtsReceipt { TypedReceipt::EIP2930(_) => 0x01, TypedReceipt::EIP1559(_) => 0x02, TypedReceipt::EIP4844(_) => 0x03, + TypedReceipt::EIP7702(_) => 0x04, TypedReceipt::Deposit(_) => 0x7E, } as u8; let receipt = ReceiptWithBloom::::from(value); @@ -1396,6 +1486,7 @@ impl Encodable2718 for TypedReceipt { Self::EIP2930(_) => Some(1), Self::EIP1559(_) => Some(2), Self::EIP4844(_) => Some(3), + Self::EIP7702(_) => Some(4), Self::Deposit(_) => Some(0x7E), } } @@ -1406,20 +1497,22 @@ impl Encodable2718 for TypedReceipt { Self::EIP2930(r) => ReceiptEnvelope::Eip2930(r.clone()).encode_2718_len(), Self::EIP1559(r) => ReceiptEnvelope::Eip1559(r.clone()).encode_2718_len(), Self::EIP4844(r) => ReceiptEnvelope::Eip4844(r.clone()).encode_2718_len(), + Self::EIP7702(r) => 1 + r.length(), Self::Deposit(r) => 1 + r.length(), } } fn encode_2718(&self, out: &mut dyn BufMut) { + if let Some(ty) = self.type_flag() { + out.put_u8(ty); + } match self { - Self::Legacy(r) => ReceiptEnvelope::Legacy(r.clone()).encode_2718(out), - Self::EIP2930(r) => ReceiptEnvelope::Eip2930(r.clone()).encode_2718(out), - Self::EIP1559(r) => ReceiptEnvelope::Eip1559(r.clone()).encode_2718(out), - Self::EIP4844(r) => ReceiptEnvelope::Eip4844(r.clone()).encode_2718(out), - Self::Deposit(r) => { - out.put_u8(0x7E); - r.encode(out); - } + Self::Legacy(r) | + Self::EIP2930(r) | + Self::EIP1559(r) | + Self::EIP4844(r) | + Self::EIP7702(r) => r.encode(out), + Self::Deposit(r) => r.encode(out), } } } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index d6f0dc03e9039..cd7485d5fa592 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2708,6 +2708,7 @@ impl EthApi { TypedTransaction::EIP2930(_) => self.backend.ensure_eip2930_active(), TypedTransaction::EIP1559(_) => self.backend.ensure_eip1559_active(), TypedTransaction::EIP4844(_) => self.backend.ensure_eip4844_active(), + TypedTransaction::EIP7702(_) => self.backend.ensure_eip7702_active(), TypedTransaction::Deposit(_) => self.backend.ensure_op_deposits_active(), TypedTransaction::Legacy(_) => Ok(()), } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 23d890cfa7268..d56db9069f812 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -66,6 +66,7 @@ impl ExecutedTransaction { TypedTransaction::EIP2930(_) => TypedReceipt::EIP2930(receipt_with_bloom), TypedTransaction::EIP1559(_) => TypedReceipt::EIP1559(receipt_with_bloom), TypedTransaction::EIP4844(_) => TypedReceipt::EIP4844(receipt_with_bloom), + TypedTransaction::EIP7702(_) => TypedReceipt::EIP7702(receipt_with_bloom), TypedTransaction::Deposit(tx) => TypedReceipt::Deposit(DepositReceipt { inner: receipt_with_bloom, deposit_nonce: Some(tx.nonce), diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 6cd04f4bcca88..f56cf69e34230 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -580,6 +580,11 @@ impl Backend { (self.spec_id() as u8) >= (SpecId::CANCUN as u8) } + /// Returns true for post Prague + pub fn is_eip7702(&self) -> bool { + (self.spec_id() as u8) >= (SpecId::PRAGUE as u8) + } + /// Returns true if op-stack deposits are active pub fn is_optimism(&self) -> bool { self.env.read().handler_cfg.is_optimism @@ -608,6 +613,13 @@ impl Backend { Err(BlockchainError::EIP4844TransactionUnsupportedAtHardfork) } + pub fn ensure_eip7702_active(&self) -> Result<(), BlockchainError> { + if self.is_eip7702() { + return Ok(()); + } + Err(BlockchainError::EIP4844TransactionUnsupportedAtHardfork) + } + /// Returns an error if op-stack deposits are not active pub fn ensure_op_deposits_active(&self) -> Result<(), BlockchainError> { if self.is_optimism() { @@ -2135,6 +2147,11 @@ impl Backend { .base_fee_per_gas .unwrap_or_else(|| self.base_fee()) .saturating_add(t.tx().tx().max_priority_fee_per_gas), + TypedTransaction::EIP7702(t) => block + .header + .base_fee_per_gas + .unwrap_or_else(|| self.base_fee()) + .saturating_add(t.tx().max_priority_fee_per_gas), TypedTransaction::Deposit(_) => 0_u128, }; @@ -2169,6 +2186,7 @@ impl Backend { TypedReceipt::Legacy(_) => TypedReceipt::Legacy(receipt_with_bloom), TypedReceipt::EIP2930(_) => TypedReceipt::EIP2930(receipt_with_bloom), TypedReceipt::EIP4844(_) => TypedReceipt::EIP4844(receipt_with_bloom), + TypedReceipt::EIP7702(_) => TypedReceipt::EIP7702(receipt_with_bloom), TypedReceipt::Deposit(r) => TypedReceipt::Deposit(DepositReceipt { inner: receipt_with_bloom, deposit_nonce: r.deposit_nonce, @@ -2482,7 +2500,7 @@ impl TransactionValidator for Backend { // Light checks first: see if the blob fee cap is too low. if let Some(max_fee_per_blob_gas) = tx.essentials().max_fee_per_blob_gas { if let Some(blob_gas_and_price) = &env.block.blob_excess_gas_and_price { - if max_fee_per_blob_gas.to::() < blob_gas_and_price.blob_gasprice { + if max_fee_per_blob_gas < blob_gas_and_price.blob_gasprice { warn!(target: "backend", "max fee per blob gas={}, too low, block blob gas price={}", max_fee_per_blob_gas, blob_gas_and_price.blob_gasprice); return Err(InvalidTransactionError::BlobFeeCapTooLow); } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index fe31fbc2a93ee..b8b475deba006 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -85,6 +85,8 @@ pub enum BlockchainError { EIP2930TransactionUnsupportedAtHardfork, #[error("EIP-4844 fields received but is not supported by the current hardfork.\n\nYou can use it by running anvil with '--hardfork cancun' or later.")] EIP4844TransactionUnsupportedAtHardfork, + #[error("EIP-7702 fields received but is not supported by the current hardfork.\n\nYou can use it by running anvil with '--hardfork prague' or later.")] + EIP7702TransactionUnsupportedAtHardfork, #[error("op-stack deposit tx received but is not supported.\n\nYou can use it by running anvil with '--optimism'.")] DepositTransactionUnsupported, #[error("Excess blob gas not set.")] @@ -418,6 +420,9 @@ impl ToRpcResponseResult for Result { err @ BlockchainError::EIP4844TransactionUnsupportedAtHardfork => { RpcError::invalid_params(err.to_string()) } + err @ BlockchainError::EIP7702TransactionUnsupportedAtHardfork => { + RpcError::invalid_params(err.to_string()) + } err @ BlockchainError::DepositTransactionUnsupported => { RpcError::invalid_params(err.to_string()) } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index ab65fcc46bd7b..45b33ad0fcdf6 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -285,6 +285,10 @@ impl FeeHistoryService { .tx() .max_priority_fee_per_gas .min(t.tx().tx().max_fee_per_gas.saturating_sub(base_fee)), + Some(TypedTransaction::EIP7702(t)) => t + .tx() + .max_priority_fee_per_gas + .min(t.tx().max_fee_per_gas.saturating_sub(base_fee)), Some(TypedTransaction::Deposit(_)) => 0, None => 0, }; diff --git a/crates/anvil/tests/it/eip7702.rs b/crates/anvil/tests/it/eip7702.rs new file mode 100644 index 0000000000000..2e7439e5d7f29 --- /dev/null +++ b/crates/anvil/tests/it/eip7702.rs @@ -0,0 +1,79 @@ +use crate::utils::http_provider; +use alloy_consensus::{transaction::TxEip7702, SignableTransaction}; +use alloy_eips::eip7702::OptionalNonce; +use alloy_network::{ReceiptResponse, TransactionBuilder, TxSignerSync}; +use alloy_primitives::{bytes, TxKind}; +use alloy_provider::Provider; +use alloy_rpc_types::{Authorization, TransactionRequest}; +use alloy_serde::WithOtherFields; +use alloy_signer::SignerSync; +use anvil::{spawn, Hardfork, NodeConfig}; + +#[tokio::test(flavor = "multi_thread")] +async fn can_send_eip7702_tx() { + let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Prague)); + let (_api, handle) = spawn(node_config).await; + let provider = http_provider(&handle.http_endpoint()); + + let wallets = handle.dev_wallets().collect::>(); + + // deploy simple contract forwarding calldata to LOG0 + // PUSH7(CALLDATASIZE PUSH0 PUSH0 CALLDATACOPY CALLDATASIZE PUSH0 LOG0) PUSH0 MSTORE PUSH1(7) + // PUSH1(25) RETURN + let logger_bytecode = bytes!("66365f5f37365fa05f5260076019f3"); + + let eip1559_est = provider.estimate_eip1559_fees(None).await.unwrap(); + + let from = wallets[0].address(); + let tx = TransactionRequest::default() + .with_from(from) + .into_create() + .with_nonce(0) + .with_max_fee_per_gas(eip1559_est.max_fee_per_gas) + .with_max_priority_fee_per_gas(eip1559_est.max_priority_fee_per_gas) + .with_input(logger_bytecode); + + let receipt = provider + .send_transaction(WithOtherFields::new(tx)) + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + + assert!(receipt.status()); + + let contract = receipt.contract_address.unwrap(); + let authorization = Authorization { + chain_id: 31337, + address: contract, + nonce: OptionalNonce::new(Some(provider.get_transaction_count(from).await.unwrap())), + }; + let signature = wallets[0].sign_hash_sync(&authorization.signature_hash()).unwrap(); + let authorization = authorization.into_signed(signature); + + let log_data = bytes!("11112222"); + let mut tx = TxEip7702 { + max_fee_per_gas: eip1559_est.max_fee_per_gas, + max_priority_fee_per_gas: eip1559_est.max_priority_fee_per_gas, + gas_limit: 100000, + chain_id: 31337, + to: TxKind::Call(from), + input: bytes!("11112222"), + authorization_list: vec![authorization], + ..Default::default() + }; + let signature = wallets[1].sign_transaction_sync(&mut tx).unwrap(); + + let tx = tx.into_signed(signature); + let mut encoded = Vec::new(); + tx.tx().encode_with_signature(tx.signature(), &mut encoded, false); + + let receipt = + provider.send_raw_transaction(&encoded).await.unwrap().get_receipt().await.unwrap(); + let log = &receipt.inner.inner.logs()[0]; + // assert that log was from EOA which signed authorization + assert_eq!(log.address(), from); + assert_eq!(log.topics().len(), 0); + assert_eq!(log.data().data, log_data); +} diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 5337e5bbd30b0..f3f5eca157707 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -3,6 +3,7 @@ mod anvil; mod anvil_api; mod api; mod eip4844; +mod eip7702; mod fork; mod gas; mod genesis; From 1bae886dd7ad2b7f3f582d850c6051cf0c20ce2f Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Sat, 20 Jul 2024 01:18:34 -0700 Subject: [PATCH 1272/1963] fix(cast): mktx: add missing --path argument for blob txs (#8483) Co-authored-by: Matthias Seitz --- crates/cast/bin/cmd/mktx.rs | 17 +++++++++++++++-- crates/cast/bin/cmd/send.rs | 8 +++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index 48c91dd77ffb1..4a343af6da38c 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -10,7 +10,7 @@ use foundry_cli::{ }; use foundry_common::ens::NameOrAddress; use foundry_config::Config; -use std::str::FromStr; +use std::{path::PathBuf, str::FromStr}; /// CLI arguments for `cast mktx`. #[derive(Debug, Parser)] @@ -33,6 +33,16 @@ pub struct MakeTxArgs { #[command(flatten)] tx: TransactionOpts, + /// The path of blob data to be sent. + #[arg( + long, + value_name = "BLOB_DATA_PATH", + conflicts_with = "legacy", + requires = "blob", + help_heading = "Transaction options" + )] + path: Option, + #[command(flatten)] eth: EthereumOpts, } @@ -55,7 +65,9 @@ pub enum MakeTxSubcommands { impl MakeTxArgs { pub async fn run(self) -> Result<()> { - let Self { to, mut sig, mut args, command, tx, eth } = self; + let Self { to, mut sig, mut args, command, tx, path, eth } = self; + + let blob_data = if let Some(path) = path { Some(std::fs::read(path)?) } else { None }; let code = if let Some(MakeTxSubcommands::Create { code, @@ -88,6 +100,7 @@ impl MakeTxArgs { .with_tx_kind(tx_kind) .with_code_sig_and_args(code, sig, args) .await? + .with_blob_data(blob_data)? .build(from) .await?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 55094346f29fa..cdafbc8a3447e 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -57,7 +57,13 @@ pub struct SendTxArgs { eth: EthereumOpts, /// The path of blob data to be sent. - #[arg(long, value_name = "BLOB_DATA_PATH", conflicts_with = "legacy", requires = "blob")] + #[arg( + long, + value_name = "BLOB_DATA_PATH", + conflicts_with = "legacy", + requires = "blob", + help_heading = "Transaction options" + )] path: Option, } From fc807dfbbf07de9b1f00f3ba4daa423a6064e91c Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 20 Jul 2024 16:52:38 +0300 Subject: [PATCH 1273/1963] fix(cheatcodes): reset interpreter gas to the value of gas spent (#8481) * fix(cheatcodes): do not record gas changes if exec frame not started * Fix * Fmt * Use gas.spent(), enable repro test --- crates/cheatcodes/src/inspector.rs | 30 ++- crates/forge/tests/it/repros.rs | 3 + testdata/default/repros/Issue8383.t.sol | 322 ++++++++++++++++++++++++ 3 files changed, 342 insertions(+), 13 deletions(-) create mode 100644 testdata/default/repros/Issue8383.t.sol diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 4a95fb75d8386..c989659e115bd 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1333,25 +1333,29 @@ impl Cheatcodes { fn meter_gas(&mut self, interpreter: &mut Interpreter) { match &self.gas_metering { None => {} - // need to store gas metering + // Need to store gas metering. Some(None) => self.gas_metering = Some(Some(interpreter.gas)), Some(Some(gas)) => { match interpreter.current_opcode() { opcode::CREATE | opcode::CREATE2 => { - // set we're about to enter CREATE frame to meter its gas on first opcode - // inside it + // Set we're about to enter CREATE frame to meter its gas on first opcode + // inside it. self.gas_metering_create = Some(None) } opcode::STOP | opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { - // If we are ending current execution frame, we want to just fully reset gas - // otherwise weird things with returning gas from a call happen - // ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/evm_impl.rs#L190 - // - // It would be nice if we had access to the interpreter in `call_end`, as we - // could just do this there instead. match &self.gas_metering_create { None | Some(None) => { - interpreter.gas = Gas::new(0); + // If we are ending current execution frame, we want to reset + // interpreter gas to the value of gas spent during frame, so only + // the consumed gas is erased. + // ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/evm_impl.rs#L190 + // + // It would be nice if we had access to the interpreter in + // `call_end`, as we could just do this there instead. + interpreter.gas = Gas::new(interpreter.gas.spent()); + + // Make sure CREATE gas metering is resetted. + self.gas_metering_create = None } Some(Some(gas)) => { // If this was CREATE frame, set correct gas limit. This is needed @@ -1367,18 +1371,18 @@ impl Cheatcodes { // post-create erase ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L279 interpreter.gas = Gas::new(gas.limit()); - // reset CREATE gas metering because we're about to exit its frame + // Reset CREATE gas metering because we're about to exit its frame. self.gas_metering_create = None } } } _ => { - // if just starting with CREATE opcodes, record its inner frame gas + // If just starting with CREATE opcodes, record its inner frame gas. if self.gas_metering_create == Some(None) { self.gas_metering_create = Some(Some(interpreter.gas)) } - // dont monitor gas changes, keep it constant + // Don't monitor gas changes, keep it constant. interpreter.gas = *gas; } } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 9216d275488d3..1268300e44273 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -361,3 +361,6 @@ test_repro!(8287); // https://github.com/foundry-rs/foundry/issues/8168 test_repro!(8168); + +// https://github.com/foundry-rs/foundry/issues/8383 +test_repro!(8383); diff --git a/testdata/default/repros/Issue8383.t.sol b/testdata/default/repros/Issue8383.t.sol new file mode 100644 index 0000000000000..a002b4b3dc1d2 --- /dev/null +++ b/testdata/default/repros/Issue8383.t.sol @@ -0,0 +1,322 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/8383 +contract Issue8383Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + address internal _verifier; + + mapping(bytes32 => bool) internal _vectorTested; + mapping(bytes32 => bool) internal _vectorResult; + + function setUp() public { + _verifier = address(new P256Verifier()); + } + + function _verifyViaVerifier(bytes32 hash, uint256 r, uint256 s, uint256 x, uint256 y) internal returns (bool) { + return _verifyViaVerifier(hash, bytes32(r), bytes32(s), bytes32(x), bytes32(y)); + } + + function _verifyViaVerifier(bytes32 hash, bytes32 r, bytes32 s, bytes32 x, bytes32 y) internal returns (bool) { + bytes memory payload = abi.encode(hash, r, s, x, y); + if (uint256(y) & 0xff == 0) { + bytes memory truncatedPayload = abi.encodePacked(hash, r, s, x, bytes31(y)); + _verifierCall(truncatedPayload); + } + if (uint256(keccak256(abi.encode(payload, "1"))) & 0x1f == 0) { + uint256 r = uint256(keccak256(abi.encode(payload, "2"))); + payload = abi.encodePacked(payload, new bytes(r & 0xff)); + } + bytes32 payloadHash = keccak256(payload); + if (_vectorTested[payloadHash]) return _vectorResult[payloadHash]; + _vectorTested[payloadHash] = true; + return (_vectorResult[payloadHash] = _verifierCall(payload)); + } + + function _verifierCall(bytes memory payload) internal returns (bool) { + (bool success, bytes memory result) = _verifier.call(payload); + return abi.decode(result, (bool)); + } + + function testP256VerifyOutOfBounds() public { + vm.pauseGasMetering(); + uint256 p = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF; + _verifyViaVerifier(bytes32(0), 1, 1, 1, 1); + _verifyViaVerifier(bytes32(0), 1, 1, 0, 1); + _verifyViaVerifier(bytes32(0), 1, 1, 1, 0); + _verifyViaVerifier(bytes32(0), 1, 1, 1, p); + _verifyViaVerifier(bytes32(0), 1, 1, p, 1); + _verifyViaVerifier(bytes32(0), 1, 1, p - 1, 1); + vm.resumeGasMetering(); + } +} + +contract P256Verifier { + uint256 private constant GX = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296; + uint256 private constant GY = 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5; + uint256 private constant P = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF; // `A = P - 3`. + uint256 private constant N = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551; + uint256 private constant B = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B; + + fallback() external payable { + assembly { + // For this implementation, we will use the memory without caring about + // the free memory pointer or zero pointer. + // The slots `0x00`, `0x20`, `0x40`, `0x60`, will not be accessed for the `Points[16]` array, + // and can be used for storing other variables. + + mstore(0x40, P) // Set `0x40` to `P`. + + function jAdd(x1, y1, z1, x2, y2, z2) -> x3, y3, z3 { + if iszero(z1) { + x3 := x2 + y3 := y2 + z3 := z2 + leave + } + if iszero(z2) { + x3 := x1 + y3 := y1 + z3 := z1 + leave + } + let p := mload(0x40) + let zz1 := mulmod(z1, z1, p) + let zz2 := mulmod(z2, z2, p) + let u1 := mulmod(x1, zz2, p) + let u2 := mulmod(x2, zz1, p) + let s1 := mulmod(y1, mulmod(zz2, z2, p), p) + let s2 := mulmod(y2, mulmod(zz1, z1, p), p) + let h := addmod(u2, sub(p, u1), p) + let hh := mulmod(h, h, p) + let hhh := mulmod(h, hh, p) + let r := addmod(s2, sub(p, s1), p) + x3 := addmod(addmod(mulmod(r, r, p), sub(p, hhh), p), sub(p, mulmod(2, mulmod(u1, hh, p), p)), p) + y3 := addmod(mulmod(r, addmod(mulmod(u1, hh, p), sub(p, x3), p), p), sub(p, mulmod(s1, hhh, p)), p) + z3 := mulmod(h, mulmod(z1, z2, p), p) + } + + function setJPoint(i, x, y, z) { + // We will multiply by `0x80` (i.e. `shl(7, i)`) instead + // since the memory expansion costs are cheaper than doing `mul(0x60, i)`. + // Also help combine the lookup expression for `u1` and `u2` in `jMultShamir`. + i := shl(7, i) + mstore(i, x) + mstore(add(i, returndatasize()), y) + mstore(add(i, 0x40), z) + } + + function setJPointDouble(i, j) { + j := shl(7, j) + let x := mload(j) + let y := mload(add(j, returndatasize())) + let z := mload(add(j, 0x40)) + let p := mload(0x40) + let yy := mulmod(y, y, p) + let zz := mulmod(z, z, p) + let s := mulmod(4, mulmod(x, yy, p), p) + let m := addmod(mulmod(3, mulmod(x, x, p), p), mulmod(mload(returndatasize()), mulmod(zz, zz, p), p), p) + let x2 := addmod(mulmod(m, m, p), sub(p, mulmod(2, s, p)), p) + let y2 := addmod(mulmod(m, addmod(s, sub(p, x2), p), p), sub(p, mulmod(8, mulmod(yy, yy, p), p)), p) + let z2 := mulmod(2, mulmod(y, z, p), p) + setJPoint(i, x2, y2, z2) + } + + function setJPointAdd(i, j, k) { + j := shl(7, j) + k := shl(7, k) + let x, y, z := + jAdd( + mload(j), + mload(add(j, returndatasize())), + mload(add(j, 0x40)), + mload(k), + mload(add(k, returndatasize())), + mload(add(k, 0x40)) + ) + setJPoint(i, x, y, z) + } + + let r := calldataload(0x20) + let n := N + + { + let s := calldataload(0x40) + if lt(shr(1, n), s) { s := sub(n, s) } + + // Perform `modExp(s, N - 2, N)`. + // After which, we can abuse `returndatasize()` to get `0x20`. + mstore(0x800, 0x20) + mstore(0x820, 0x20) + mstore(0x840, 0x20) + mstore(0x860, s) + mstore(0x880, sub(n, 2)) + mstore(0x8a0, n) + + let p := mload(0x40) + mstore(0x20, xor(3, p)) // Set `0x20` to `A`. + let Qx := calldataload(0x60) + let Qy := calldataload(0x80) + + if iszero( + and( // The arguments of `and` are evaluated last to first. + and( + and(gt(calldatasize(), 0x9f), and(lt(iszero(r), lt(r, n)), lt(iszero(s), lt(s, n)))), + eq( + mulmod(Qy, Qy, p), + addmod(mulmod(addmod(mulmod(Qx, Qx, p), mload(returndatasize()), p), Qx, p), B, p) + ) + ), + and( + // We need to check that the `returndatasize` is indeed 32, + // so that we can return false if the chain does not have the modexp precompile. + eq(returndatasize(), 0x20), + staticcall(gas(), 0x05, 0x800, 0xc0, returndatasize(), 0x20) + ) + ) + ) { + // POC Note: + // Changing this to `return(0x80, 0x20)` fixes it. + // Alternatively, adding `if mload(0x8c0) { invalid() }` just before the return also fixes it. + return(0x8c0, 0x20) + } + + setJPoint(0x01, Qx, Qy, 1) + setJPoint(0x04, GX, GY, 1) + setJPointDouble(0x02, 0x01) + setJPointDouble(0x08, 0x04) + setJPointAdd(0x03, 0x01, 0x02) + setJPointAdd(0x05, 0x01, 0x04) + setJPointAdd(0x06, 0x02, 0x04) + setJPointAdd(0x07, 0x03, 0x04) + setJPointAdd(0x09, 0x01, 0x08) + setJPointAdd(0x0a, 0x02, 0x08) + setJPointAdd(0x0b, 0x03, 0x08) + setJPointAdd(0x0c, 0x04, 0x08) + setJPointAdd(0x0d, 0x01, 0x0c) + setJPointAdd(0x0e, 0x02, 0x0c) + setJPointAdd(0x0f, 0x03, 0x0c) + } + + let i := 0 + let u1 := mulmod(calldataload(0x00), mload(0x00), n) + let u2 := mulmod(r, mload(0x00), n) + let y := 0 + let z := 0 + let x := 0 + let p := mload(0x40) + for {} 1 {} { + if z { + let yy := mulmod(y, y, p) + let zz := mulmod(z, z, p) + let s := mulmod(4, mulmod(x, yy, p), p) + let m := + addmod(mulmod(3, mulmod(x, x, p), p), mulmod(mload(returndatasize()), mulmod(zz, zz, p), p), p) + let x2 := addmod(mulmod(m, m, p), sub(p, mulmod(2, s, p)), p) + let y2 := addmod(mulmod(m, addmod(s, sub(p, x2), p), p), sub(p, mulmod(8, mulmod(yy, yy, p), p)), p) + let z2 := mulmod(2, mulmod(y, z, p), p) + yy := mulmod(y2, y2, p) + zz := mulmod(z2, z2, p) + s := mulmod(4, mulmod(x2, yy, p), p) + m := + addmod(mulmod(3, mulmod(x2, x2, p), p), mulmod(mload(returndatasize()), mulmod(zz, zz, p), p), p) + x := addmod(mulmod(m, m, p), sub(p, mulmod(2, s, p)), p) + z := mulmod(2, mulmod(y2, z2, p), p) + y := addmod(mulmod(m, addmod(s, sub(p, x), p), p), sub(p, mulmod(8, mulmod(yy, yy, p), p)), p) + } + for { let o := or(and(shr(245, shl(i, u1)), 0x600), and(shr(247, shl(i, u2)), 0x180)) } o {} { + let z2 := mload(add(o, 0x40)) + if iszero(z2) { break } + if iszero(z) { + x := mload(o) + y := mload(add(o, returndatasize())) + z := z2 + break + } + let zz1 := mulmod(z, z, p) + let zz2 := mulmod(z2, z2, p) + let u1_ := mulmod(x, zz2, p) + let s1 := mulmod(y, mulmod(zz2, z2, p), p) + let h := addmod(mulmod(mload(o), zz1, p), sub(p, u1_), p) + let hh := mulmod(h, h, p) + let hhh := mulmod(h, hh, p) + let r_ := addmod(mulmod(mload(add(o, returndatasize())), mulmod(zz1, z, p), p), sub(p, s1), p) + x := addmod(addmod(mulmod(r_, r_, p), sub(p, hhh), p), sub(p, mulmod(2, mulmod(u1_, hh, p), p)), p) + y := addmod(mulmod(r_, addmod(mulmod(u1_, hh, p), sub(p, x), p), p), sub(p, mulmod(s1, hhh, p)), p) + z := mulmod(h, mulmod(z, z2, p), p) + break + } + // Just unroll twice. Fully unrolling will only save around 1% to 2% gas, but make the + // bytecode very bloated, which may incur more runtime costs after Verkle. + // See: https://notes.ethereum.org/%40vbuterin/verkle_tree_eip + // It's very unlikely that Verkle will come before the P256 precompile. But who knows? + if z { + let yy := mulmod(y, y, p) + let zz := mulmod(z, z, p) + let s := mulmod(4, mulmod(x, yy, p), p) + let m := + addmod(mulmod(3, mulmod(x, x, p), p), mulmod(mload(returndatasize()), mulmod(zz, zz, p), p), p) + let x2 := addmod(mulmod(m, m, p), sub(p, mulmod(2, s, p)), p) + let y2 := addmod(mulmod(m, addmod(s, sub(p, x2), p), p), sub(p, mulmod(8, mulmod(yy, yy, p), p)), p) + let z2 := mulmod(2, mulmod(y, z, p), p) + yy := mulmod(y2, y2, p) + zz := mulmod(z2, z2, p) + s := mulmod(4, mulmod(x2, yy, p), p) + m := + addmod(mulmod(3, mulmod(x2, x2, p), p), mulmod(mload(returndatasize()), mulmod(zz, zz, p), p), p) + x := addmod(mulmod(m, m, p), sub(p, mulmod(2, s, p)), p) + z := mulmod(2, mulmod(y2, z2, p), p) + y := addmod(mulmod(m, addmod(s, sub(p, x), p), p), sub(p, mulmod(8, mulmod(yy, yy, p), p)), p) + } + for { let o := or(and(shr(243, shl(i, u1)), 0x600), and(shr(245, shl(i, u2)), 0x180)) } o {} { + let z2 := mload(add(o, 0x40)) + if iszero(z2) { break } + if iszero(z) { + x := mload(o) + y := mload(add(o, returndatasize())) + z := z2 + break + } + let zz1 := mulmod(z, z, p) + let zz2 := mulmod(z2, z2, p) + let u1_ := mulmod(x, zz2, p) + let s1 := mulmod(y, mulmod(zz2, z2, p), p) + let h := addmod(mulmod(mload(o), zz1, p), sub(p, u1_), p) + let hh := mulmod(h, h, p) + let hhh := mulmod(h, hh, p) + let r_ := addmod(mulmod(mload(add(o, returndatasize())), mulmod(zz1, z, p), p), sub(p, s1), p) + x := addmod(addmod(mulmod(r_, r_, p), sub(p, hhh), p), sub(p, mulmod(2, mulmod(u1_, hh, p), p)), p) + y := addmod(mulmod(r_, addmod(mulmod(u1_, hh, p), sub(p, x), p), p), sub(p, mulmod(s1, hhh, p)), p) + z := mulmod(h, mulmod(z, z2, p), p) + break + } + i := add(i, 4) + if eq(i, 256) { break } + } + + if iszero(z) { + mstore(returndatasize(), iszero(r)) + return(returndatasize(), 0x20) + } + + // Perform `modExp(z, P - 2, P)`. + // `0x800`, `0x820, `0x840` are still set to `0x20`. + mstore(0x860, z) + mstore(0x880, sub(p, 2)) + mstore(0x8a0, p) + + mstore( + returndatasize(), + and( // The arguments of `and` are evaluated last to first. + eq(mod(mulmod(x, mulmod(mload(returndatasize()), mload(returndatasize()), p), p), n), r), + staticcall(gas(), 0x05, 0x800, 0xc0, returndatasize(), returndatasize()) + ) + ) + return(returndatasize(), returndatasize()) + } + } +} From f15aad0a0c12b84dd98baa63aa0cf373f28f6800 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 21 Jul 2024 02:33:37 +0000 Subject: [PATCH 1274/1963] chore(deps): weekly `cargo update` (#8486) Locking 19 packages to latest compatible versions Updating cc v1.1.2 -> v1.1.6 Updating openssl v0.10.64 -> v0.10.65 Updating openssl-sys v0.9.102 -> v0.9.103 Updating portable-atomic v1.6.0 -> v1.7.0 Updating redox_syscall v0.5.2 -> v0.5.3 Updating scc v2.1.2 -> v2.1.4 Updating sdd v0.2.0 -> v1.7.0 Updating security-framework v2.11.0 -> v2.11.1 Updating security-framework-sys v2.11.0 -> v2.11.1 Updating thiserror v1.0.62 -> v1.0.63 Updating thiserror-impl v1.0.62 -> v1.0.63 Updating tokio v1.38.0 -> v1.38.1 Updating toml v0.8.14 -> v0.8.15 Updating toml_edit v0.22.15 -> v0.22.16 Updating tracing-tracy v0.11.0 -> v0.11.1 Updating tracy-client v0.17.0 -> v0.17.1 Updating tracy-client-sys v0.22.2 -> v0.23.0 Updating winnow v0.6.13 -> v0.6.14 Updating zip v2.1.3 -> v2.1.5 note: pass `--verbose` to see 144 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 125 ++++++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b5439e59bcf2..328b8f59d1a39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,7 +129,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -602,7 +602,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" dependencies = [ "serde", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -1981,13 +1981,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47de7e88bbbd467951ae7f5a6f34f70d1b4d9cfce53d5fd70f74ebe118b3db56" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" dependencies = [ "jobserver", "libc", - "once_cell", ] [[package]] @@ -3092,7 +3091,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.71", - "toml 0.8.14", + "toml 0.8.15", "walkdir", ] @@ -3243,7 +3242,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.14", + "toml 0.8.15", "uncased", "version_check", ] @@ -3388,8 +3387,8 @@ dependencies = [ "thiserror", "tikv-jemallocator", "tokio", - "toml 0.8.14", - "toml_edit 0.22.15", + "toml 0.8.15", + "toml_edit 0.22.16", "tower-http", "tracing", "tracing-subscriber", @@ -3420,7 +3419,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.14", + "toml 0.8.15", "tracing", ] @@ -3435,7 +3434,7 @@ dependencies = [ "similar-asserts", "solang-parser", "thiserror", - "toml 0.8.14", + "toml 0.8.15", "tracing", "tracing-subscriber", ] @@ -3593,7 +3592,7 @@ dependencies = [ "semver 1.0.23", "serde_json", "thiserror", - "toml 0.8.14", + "toml 0.8.15", "tracing", "walkdir", ] @@ -3742,7 +3741,7 @@ dependencies = [ "thiserror", "tokio", "tracing", - "winnow 0.6.13", + "winnow 0.6.14", "yansi", ] @@ -3848,8 +3847,8 @@ dependencies = [ "solang-parser", "tempfile", "thiserror", - "toml 0.8.14", - "toml_edit 0.22.15", + "toml 0.8.15", + "toml_edit 0.22.16", "tracing", "walkdir", ] @@ -4354,7 +4353,7 @@ dependencies = [ "gix-utils", "itoa", "thiserror", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -4375,7 +4374,7 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -4477,7 +4476,7 @@ dependencies = [ "itoa", "smallvec", "thiserror", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -4512,7 +4511,7 @@ dependencies = [ "gix-validate", "memmap2", "thiserror", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -5986,9 +5985,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "c2823eb4c6453ed64055057ea8bd416eda38c71018723869dd043a3b1186115e" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -6018,9 +6017,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.102" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -6123,7 +6122,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.2", + "redox_syscall 0.5.3", "smallvec", "windows-targets 0.52.6", ] @@ -6455,9 +6454,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" [[package]] name = "powerfmt" @@ -6693,7 +6692,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.71", @@ -6938,9 +6937,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ "bitflags 2.6.0", ] @@ -7561,9 +7560,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.2" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af947d0ca10a2f3e00c7ec1b515b7c83e5cb3fa62d4c11a64301d9eec54440e9" +checksum = "a4465c22496331e20eb047ff46e7366455bc01c0c02015c4a376de0b2cd3a1af" dependencies = [ "sdd", ] @@ -7637,9 +7636,9 @@ dependencies = [ [[package]] name = "sdd" -version = "0.2.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d" +checksum = "85f05a494052771fc5bd0619742363b5e24e5ad72ab3111ec2e27925b8edc5f3" [[package]] name = "sec1" @@ -7689,9 +7688,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", "core-foundation", @@ -7702,9 +7701,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -8134,13 +8133,13 @@ dependencies = [ "sha256", "simple-home-dir", "tokio", - "toml 0.8.14", - "toml_edit 0.22.15", + "toml 0.8.15", + "toml_edit 0.22.16", "uuid 1.10.0", "walkdir", "yansi", "yash-fnmatch", - "zip 2.1.3", + "zip 2.1.5", "zip-extract", ] @@ -8272,7 +8271,7 @@ dependencies = [ "sha2", "thiserror", "url", - "zip 2.1.3", + "zip 2.1.5", ] [[package]] @@ -8426,18 +8425,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -8552,9 +8551,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", @@ -8696,15 +8695,15 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.15", + "toml_edit 0.22.16", ] [[package]] @@ -8729,15 +8728,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.15" +version = "0.22.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" +checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -8920,9 +8919,9 @@ dependencies = [ [[package]] name = "tracing-tracy" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6024d04f84a69fd0d1dc1eee3a2b070bd246530a0582f9982ae487cb6c703614" +checksum = "9be7f8874d6438e4263f9874c84eded5095bda795d9c7da6ea0192e1750d3ffe" dependencies = [ "tracing-core", "tracing-subscriber", @@ -8931,9 +8930,9 @@ dependencies = [ [[package]] name = "tracy-client" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fb931a64ff88984f86d3e9bcd1ae8843aa7fe44dd0f8097527bc172351741d" +checksum = "63de1e1d4115534008d8fd5788b39324d6f58fc707849090533828619351d855" dependencies = [ "loom", "once_cell", @@ -8942,9 +8941,9 @@ dependencies = [ [[package]] name = "tracy-client-sys" -version = "0.22.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d104d610dfa9dd154535102cc9c6164ae1fa37842bc2d9e83f9ac82b0ae0882" +checksum = "98b98232a2447ce0a58f9a0bfb5f5e39647b5c597c994b63945fcccd1306fafb" dependencies = [ "cc", ] @@ -9686,9 +9685,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" dependencies = [ "memchr", ] @@ -9834,9 +9833,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.1.3" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775a2b471036342aa69bc5a602bc889cb0a06cda00477d0c69566757d5553d39" +checksum = "b895748a3ebcb69b9d38dcfdf21760859a4b0d0b0015277640c2ef4c69640e6f" dependencies = [ "arbitrary", "crc32fast", From fe2acca4e379793539db80e032d76ffe0110298b Mon Sep 17 00:00:00 2001 From: Shun Kakinoki <39187513+shunkakinoki@users.noreply.github.com> Date: Sun, 21 Jul 2024 19:32:42 +0900 Subject: [PATCH 1275/1963] chore: 7702 error type correction (#8487) chore: 7702 active error correction Just realized this while going through https://github.com/foundry-rs/foundry/pull/8476 (sorry, nits! --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f56cf69e34230..429cefcae834e 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -617,7 +617,7 @@ impl Backend { if self.is_eip7702() { return Ok(()); } - Err(BlockchainError::EIP4844TransactionUnsupportedAtHardfork) + Err(BlockchainError::EIP7702TransactionUnsupportedAtHardfork) } /// Returns an error if op-stack deposits are not active From 2544793db0896f8f34e661195f8ad90a76dfc279 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 22 Jul 2024 18:50:28 +0800 Subject: [PATCH 1276/1963] feat: `cast decode-eof` & `forge inspect eof` (#8478) * feat: cast decode-eof & forge inspect eof * add docs * clippy * fix tests * review fixes --- Cargo.lock | 2 + Cargo.toml | 1 + crates/cast/Cargo.toml | 2 +- crates/cast/bin/main.rs | 4 ++ crates/cast/bin/opts.rs | 6 ++- crates/cast/src/lib.rs | 19 +++++++++ crates/common/Cargo.toml | 2 +- crates/common/fmt/Cargo.toml | 2 + crates/common/fmt/src/eof.rs | 75 +++++++++++++++++++++++++++++++++ crates/common/fmt/src/lib.rs | 3 ++ crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/inspect.rs | 68 ++++++++++++++++++++++++------ 12 files changed, 169 insertions(+), 17 deletions(-) create mode 100644 crates/common/fmt/src/eof.rs diff --git a/Cargo.lock b/Cargo.lock index 328b8f59d1a39..42579ff894484 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3700,7 +3700,9 @@ dependencies = [ "alloy-rpc-types", "alloy-serde", "chrono", + "comfy-table", "foundry-macros", + "revm-primitives", "serde", "serde_json", "similar-asserts", diff --git a/Cargo.toml b/Cargo.toml index 354f1549b279a..83e270668db41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -263,3 +263,4 @@ tower-http = "0.5" soldeer = "0.2.19" proptest = "1" +comfy-table = "7" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 602ec57ae4952..1d899bbba2f49 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -68,7 +68,7 @@ foundry-cli.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } clap_complete = "4" clap_complete_fig = "4" -comfy-table = "7" +comfy-table.workspace = true dunce.workspace = true indicatif = "0.17" itertools.workspace = true diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index b42e4231d0c0e..ff4f799cdbddb 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -567,6 +567,10 @@ async fn main() -> Result<()> { println!("{}", serde_json::to_string_pretty(&tx)?); } + CastSubcommand::DecodeEof { eof } => { + let eof = stdin::unwrap_line(eof)?; + println!("{}", SimpleCast::decode_eof(&eof)?); + } }; Ok(()) } diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 975ce2041aff1..5b3c09c8a8696 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -905,7 +905,7 @@ pub enum CastSubcommand { }, /// Decodes a raw signed EIP 2718 typed transaction - #[command(visible_alias = "dt")] + #[command(visible_aliases = &["dt", "decode-tx"])] DecodeTransaction { tx: Option }, /// Extracts function selectors and arguments from bytecode @@ -918,6 +918,10 @@ pub enum CastSubcommand { #[arg(long, short)] resolve: bool, }, + + /// Decodes EOF container bytes + #[command()] + DecodeEof { eof: Option }, } /// CLI arguments for `cast --to-base`. diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index e1a70b36c8324..46610d6303b7d 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -34,6 +34,7 @@ use foundry_compilers::flatten::Flattener; use foundry_config::Chain; use futures::{future::Either, FutureExt, StreamExt}; use rayon::prelude::*; +use revm::primitives::Eof; use std::{ borrow::Cow, io, @@ -1990,6 +1991,24 @@ impl SimpleCast { let tx = TxEnvelope::decode_2718(&mut tx_hex.as_slice())?; Ok(tx) } + + /// Decodes EOF container bytes + /// Pretty prints the decoded EOF container contents + /// + /// # Example + /// + /// ``` + /// use cast::SimpleCast as Cast; + /// + /// let eof = "0xef0001010004020001005604002000008000046080806040526004361015e100035f80fd5f3560e01c63773d45e01415e1ffee6040600319360112e10028600435906024358201809211e100066020918152f3634e487b7160e01b5f52601160045260245ffd5f80fd0000000000000000000000000124189fc71496f8660db5189f296055ed757632"; + /// let decoded = Cast::decode_eof(&eof)?; + /// println!("{}", decoded); + /// # Ok::<(), eyre::Report>(()) + pub fn decode_eof(eof: &str) -> Result { + let eof_hex = hex::decode(eof)?; + let eof = Eof::decode(eof_hex.into())?; + Ok(pretty_eof(&eof)?) + } } fn strip_0x(s: &str) -> &str { diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index b9c872c652cfc..094f32bed6528 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -46,7 +46,7 @@ tower.workspace = true async-trait.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } -comfy-table = "7" +comfy-table.workspace = true dunce.workspace = true eyre.workspace = true num-format.workspace = true diff --git a/crates/common/fmt/Cargo.toml b/crates/common/fmt/Cargo.toml index 285c3052dc0c6..fabe35a7a1a1d 100644 --- a/crates/common/fmt/Cargo.toml +++ b/crates/common/fmt/Cargo.toml @@ -25,6 +25,8 @@ alloy-serde.workspace = true serde.workspace = true serde_json.workspace = true chrono.workspace = true +revm-primitives.workspace = true +comfy-table.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/fmt/src/eof.rs b/crates/common/fmt/src/eof.rs new file mode 100644 index 0000000000000..639e175b45eaa --- /dev/null +++ b/crates/common/fmt/src/eof.rs @@ -0,0 +1,75 @@ +use comfy_table::{ContentArrangement, Table}; +use revm_primitives::{ + eof::{EofBody, EofHeader}, + Eof, +}; +use std::fmt::{self, Write}; + +pub fn pretty_eof(eof: &Eof) -> Result { + let Eof { + header: + EofHeader { + types_size, + code_sizes, + container_sizes, + data_size, + sum_code_sizes: _, + sum_container_sizes: _, + }, + body: + EofBody { types_section, code_section, container_section, data_section, is_data_filled: _ }, + raw: _, + } = eof; + + let mut result = String::new(); + + let mut table = Table::new(); + table.add_row(vec!["type_size", &types_size.to_string()]); + table.add_row(vec!["num_code_sections", &code_sizes.len().to_string()]); + if !code_sizes.is_empty() { + table.add_row(vec!["code_sizes", &format!("{code_sizes:?}")]); + } + table.add_row(vec!["num_container_sections", &container_sizes.len().to_string()]); + if !container_sizes.is_empty() { + table.add_row(vec!["container_sizes", &format!("{container_sizes:?}")]); + } + table.add_row(vec!["data_size", &data_size.to_string()]); + + write!(result, "Header:\n{table}")?; + + if !code_section.is_empty() { + let mut table = Table::new(); + table.set_content_arrangement(ContentArrangement::Dynamic); + table.set_header(vec!["", "Inputs", "Outputs", "Max stack height", "Code"]); + for (idx, (code, type_section)) in code_section.iter().zip(types_section).enumerate() { + table.add_row(vec![ + &idx.to_string(), + &type_section.inputs.to_string(), + &type_section.outputs.to_string(), + &type_section.max_stack_size.to_string(), + &code.to_string(), + ]); + } + + write!(result, "\n\nCode sections:\n{table}")?; + } + + if !container_section.is_empty() { + let mut table = Table::new(); + table.set_content_arrangement(ContentArrangement::Dynamic); + for (idx, container) in container_section.iter().enumerate() { + table.add_row(vec![&idx.to_string(), &container.to_string()]); + } + + write!(result, "\n\nContainer sections:\n{table}")?; + } + + if !data_section.is_empty() { + let mut table = Table::new(); + table.set_content_arrangement(ContentArrangement::Dynamic); + table.add_row(vec![&data_section.to_string()]); + write!(result, "\n\nData section:\n{table}")?; + } + + Ok(result) +} diff --git a/crates/common/fmt/src/lib.rs b/crates/common/fmt/src/lib.rs index 5271b73c755be..c020908097779 100644 --- a/crates/common/fmt/src/lib.rs +++ b/crates/common/fmt/src/lib.rs @@ -11,3 +11,6 @@ pub use exp::{format_int_exp, format_uint_exp, to_exp_notation}; mod ui; pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, EthValue, UIfmt}; + +mod eof; +pub use eof::pretty_eof; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 02bc6d0c8a648..eb3e94406a080 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -38,7 +38,7 @@ ethers-contract-abigen = { workspace = true, features = ["providers"] } revm-inspectors.workspace = true -comfy-table = "7" +comfy-table.workspace = true eyre.workspace = true proptest.workspace = true rayon.workspace = true diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index a6f1625560278..ac0ed41b3f342 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -1,15 +1,17 @@ +use alloy_primitives::Address; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; -use eyre::Result; +use eyre::{Context, Result}; +use forge::revm::primitives::Eof; use foundry_cli::opts::{CompilerArgs, CoreBuildArgs}; -use foundry_common::compile::ProjectCompiler; +use foundry_common::{compile::ProjectCompiler, fmt::pretty_eof}; use foundry_compilers::{ artifacts::{ output_selection::{ BytecodeOutputSelection, ContractOutputSelection, DeployedBytecodeOutputSelection, EvmOutputSelection, EwasmOutputSelection, }, - StorageLayout, + CompactBytecode, StorageLayout, }, info::ContractInfo, utils::canonicalize, @@ -39,7 +41,7 @@ pub struct InspectArgs { impl InspectArgs { pub fn run(self) -> Result<()> { - let Self { mut contract, field, build, pretty } = self; + let Self { contract, field, build, pretty } = self; trace!(target: "forge", ?field, ?contract, "running forge inspect"); @@ -64,16 +66,16 @@ impl InspectArgs { // Build the project let project = modified_build_args.project()?; - let mut compiler = ProjectCompiler::new().quiet(true); - if let Some(contract_path) = &mut contract.path { - let target_path = canonicalize(&*contract_path)?; - *contract_path = target_path.to_string_lossy().to_string(); - compiler = compiler.files([target_path]); - } - let output = compiler.compile(&project)?; + let compiler = ProjectCompiler::new().quiet(true); + let target_path = if let Some(path) = &contract.path { + canonicalize(project.root().join(path))? + } else { + project.find_contract_path(&contract.name)? + }; + let mut output = compiler.files([target_path.clone()]).compile(&project)?; // Find the artifact - let artifact = output.find_contract(&contract).ok_or_else(|| { + let artifact = output.remove(&target_path, &contract.name).ok_or_else(|| { eyre::eyre!("Could not find artifact `{contract}` in the compiled artifacts") })?; @@ -160,6 +162,12 @@ impl InspectArgs { } print_json(&out)?; } + ContractArtifactField::Eof => { + print_eof(artifact.deployed_bytecode.and_then(|b| b.bytecode))?; + } + ContractArtifactField::EofInit => { + print_eof(artifact.bytecode)?; + } }; Ok(()) @@ -214,6 +222,8 @@ pub enum ContractArtifactField { Ewasm, Errors, Events, + Eof, + EofInit, } macro_rules! impl_value_enum { @@ -300,6 +310,8 @@ impl_value_enum! { Ewasm => "ewasm" | "e-wasm", Errors => "errors" | "er", Events => "events" | "ev", + Eof => "eof" | "eof-container" | "eof-deployed", + EofInit => "eof-init" | "eof-initcode" | "eof-initcontainer", } } @@ -324,6 +336,10 @@ impl From for ContractOutputSelection { Caf::Ewasm => Self::Ewasm(EwasmOutputSelection::All), Caf::Errors => Self::Abi, Caf::Events => Self::Abi, + Caf::Eof => Self::Evm(EvmOutputSelection::DeployedByteCode( + DeployedBytecodeOutputSelection::All, + )), + Caf::EofInit => Self::Evm(EvmOutputSelection::ByteCode(BytecodeOutputSelection::All)), } } } @@ -347,7 +363,9 @@ impl PartialEq for ContractArtifactField { (Self::IrOptimized, Cos::IrOptimized) | (Self::Metadata, Cos::Metadata) | (Self::UserDoc, Cos::UserDoc) | - (Self::Ewasm, Cos::Ewasm(_)) + (Self::Ewasm, Cos::Ewasm(_)) | + (Self::Eof, Cos::Evm(Eos::DeployedByteCode(_))) | + (Self::EofInit, Cos::Evm(Eos::ByteCode(_))) ) } } @@ -407,6 +425,30 @@ fn get_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result) -> Result<()> { + let Some(mut bytecode) = bytecode else { eyre::bail!("No bytecode") }; + + // Replace link references with zero address. + if bytecode.object.is_unlinked() { + for (file, references) in bytecode.link_references.clone() { + for (name, _) in references { + bytecode.link(&file, &name, Address::ZERO); + } + } + } + + let Some(bytecode) = bytecode.object.into_bytes() else { + eyre::bail!("Failed to link bytecode"); + }; + + let eof = Eof::decode(bytecode).wrap_err("Failed to decode EOF")?; + + println!("{}", pretty_eof(&eof)?); + + Ok(()) +} + #[cfg(test)] mod tests { use super::*; From 62cdea8ff9e6efef011f77e295823b5f2dbeb3a1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 22 Jul 2024 21:05:40 +0200 Subject: [PATCH 1277/1963] fix: disable block gas limit for call --trace (#8496) --- crates/cast/bin/cmd/call.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index d6025fe9ca3e5..65ec11d6e6be0 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -162,7 +162,13 @@ impl CallArgs { config.fork_block_number = Some(block_number); } - let (env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; + let (mut env, fork, chain) = + TracingExecutor::get_fork_material(&config, evm_opts).await?; + + // modify settings that usually set in eth_call + env.cfg.disable_block_gas_limit = true; + env.block.gas_limit = U256::MAX; + let mut executor = TracingExecutor::new(env, fork, evm_version, debug, decode_internal); let value = tx.value.unwrap_or_default(); From 5af9d16ecb620192d4fe5ae61d33e429b7f5aff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ca=C3=ADque=20Porfirio?= <56317416+caiquejjx@users.noreply.github.com> Date: Tue, 23 Jul 2024 13:11:18 -0300 Subject: [PATCH 1278/1963] feat: add mixed mining mode (#8280) * feat: add mixed mining mode * feat: add mixed mining usage * fix: ensure unique txs * chore: undo comment deletion * touchups --------- Co-authored-by: Matthias Seitz --- crates/anvil/src/cmd.rs | 4 ++++ crates/anvil/src/config.rs | 14 ++++++++++++++ crates/anvil/src/eth/miner.rs | 33 +++++++++++++++++++++++++++++++++ crates/anvil/src/lib.rs | 8 +++++++- 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index f867030230a25..e12c6b13ad33d 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -98,6 +98,9 @@ pub struct NodeArgs { #[arg(long, visible_alias = "no-mine", conflicts_with = "block_time")] pub no_mining: bool, + #[arg(long, visible_alias = "mixed-mining", requires = "block_time")] + pub mixed_mining: bool, + /// The hosts the server will listen on. #[arg( long, @@ -200,6 +203,7 @@ impl NodeArgs { .with_hardfork(self.hardfork) .with_blocktime(self.block_time) .with_no_mining(self.no_mining) + .with_mixed_mining(self.mixed_mining, self.block_time) .with_account_generator(self.account_generator()) .with_genesis_balance(genesis_balance) .with_genesis_timestamp(self.timestamp) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index ef6b2503d79da..4ae1be0e97bfc 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -113,6 +113,8 @@ pub struct NodeConfig { pub block_time: Option, /// Disable auto, interval mining mode uns use `MiningMode::None` instead pub no_mining: bool, + /// Enables auto and interval mining mode + pub mixed_mining: bool, /// port to use for the server pub port: u16, /// maximum number of transactions in a block @@ -395,6 +397,7 @@ impl Default for NodeConfig { genesis_balance: Unit::ETHER.wei().saturating_mul(U256::from(100u64)), block_time: None, no_mining: false, + mixed_mining: false, port: NODE_PORT, // TODO make this something dependent on block capacity max_transactions: 1_000, @@ -633,6 +636,17 @@ impl NodeConfig { self } + #[must_use] + pub fn with_mixed_mining>( + mut self, + mixed_mining: bool, + block_time: Option, + ) -> Self { + self.block_time = block_time.map(Into::into); + self.mixed_mining = mixed_mining; + self + } + /// If set to `true` auto mining will be disabled #[must_use] pub fn with_no_mining(mut self, no_mining: bool) -> Self { diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index ddd27185075a3..defb6624a7877 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -132,6 +132,9 @@ pub enum MiningMode { Auto(ReadyTransactionMiner), /// A miner that constructs a new block every `interval` tick FixedBlockTime(FixedBlockTimeMiner), + + /// A minner that uses both Auto and FixedBlockTime + Mixed(ReadyTransactionMiner, FixedBlockTimeMiner), } impl MiningMode { @@ -147,6 +150,13 @@ impl MiningMode { Self::FixedBlockTime(FixedBlockTimeMiner::new(duration)) } + pub fn mixed(max_transactions: usize, listener: Receiver, duration: Duration) -> Self { + Self::Mixed( + ReadyTransactionMiner { max_transactions, has_pending_txs: None, rx: listener.fuse() }, + FixedBlockTimeMiner::new(duration), + ) + } + /// polls the [Pool] and returns those transactions that should be put in a block, if any. pub fn poll( &mut self, @@ -157,6 +167,29 @@ impl MiningMode { Self::None => Poll::Pending, Self::Auto(miner) => miner.poll(pool, cx), Self::FixedBlockTime(miner) => miner.poll(pool, cx), + Self::Mixed(auto, fixed) => { + let auto_txs = auto.poll(pool, cx); + let fixed_txs = fixed.poll(pool, cx); + + match (auto_txs, fixed_txs) { + // Both auto and fixed transactions are ready, combine them + (Poll::Ready(mut auto_txs), Poll::Ready(fixed_txs)) => { + for tx in fixed_txs { + // filter unique transactions + if auto_txs.iter().any(|auto_tx| auto_tx.hash() == tx.hash()) { + continue; + } + auto_txs.push(tx); + } + Poll::Ready(auto_txs) + } + // Only auto transactions are ready, return them + (Poll::Ready(auto_txs), Poll::Pending) => Poll::Ready(auto_txs), + // Only fixed transactions are ready or both are pending, + // return fixed transactions or pending status + (Poll::Pending, fixed_txs) => fixed_txs, + } + } } } } diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 56005dd603ec9..dc7e0969f99cf 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -142,13 +142,19 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle no_mining, transaction_order, genesis, + mixed_mining, .. } = config.clone(); let pool = Arc::new(Pool::default()); let mode = if let Some(block_time) = block_time { - MiningMode::interval(block_time) + if mixed_mining { + let listener = pool.add_ready_listener(); + MiningMode::mixed(max_transactions, listener, block_time) + } else { + MiningMode::interval(block_time) + } } else if no_mining { MiningMode::None } else { From 781fe52e592ef578a277ed76ce8f6ff99c034436 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 25 Jul 2024 03:09:59 +0800 Subject: [PATCH 1279/1963] chore: make clippy happy (#8515) --- crates/debugger/src/tui/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 6b522250b8aae..155973e15830f 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -136,6 +136,8 @@ impl Debugger { } } +// TODO: Update once on 1.82 +#[allow(deprecated)] type PanicHandler = Box) + 'static + Sync + Send>; /// Handles terminal state. From 2b301a7c25cfe3d58063f81e2e022b8b51083785 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 25 Jul 2024 03:35:14 +0800 Subject: [PATCH 1280/1963] fix: respect profiles in inline configs (#8514) * exclude internal fns tests for test-isolate * fix: respect profiles when merging inline configs --- crates/config/src/inline/conf_parser.rs | 8 +++++--- crates/forge/tests/cli/test_cmd.rs | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs index c2b7b39f73d53..e6944965499d8 100644 --- a/crates/config/src/inline/conf_parser.rs +++ b/crates/config/src/inline/conf_parser.rs @@ -37,12 +37,14 @@ where /// - `Err(InlineConfigParserError)` in case of wrong configuration. fn try_merge(&self, configs: &[String]) -> Result, InlineConfigParserError>; - /// Validates and merges the natspec configs into the current config. + /// Validates and merges the natspec configs for current profile into the current config. fn merge(&self, natspec: &NatSpec) -> Result, InlineConfigError> { let config_key = Self::config_key(); - let configs = - natspec.config_lines().filter(|l| l.contains(&config_key)).collect::>(); + let configs = natspec + .current_profile_configs() + .filter(|l| l.contains(&config_key)) + .collect::>(); self.try_merge(&configs).map_err(|e| { let line = natspec.debug_context(); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index a3239e3f52ddd..23f77f56b793c 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -904,6 +904,7 @@ forgetest_init!(should_not_show_logs_when_fuzz_test_inline_config, |prj, cmd| { }); // tests internal functions trace +#[cfg(not(feature = "isolate-by-default"))] forgetest_init!(internal_functions_trace, |prj, cmd| { prj.wipe_contracts(); prj.clear(); @@ -971,6 +972,7 @@ Traces: }); // tests internal functions trace with memory decoding +#[cfg(not(feature = "isolate-by-default"))] forgetest_init!(internal_functions_trace_memory, |prj, cmd| { prj.wipe_contracts(); prj.clear(); From 6c5816773e5ea2ef7c652b735c9df46a53d134bb Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Wed, 24 Jul 2024 14:03:36 -0700 Subject: [PATCH 1281/1963] feat(cast,common): calldata-decode, abi-decode, and 4byte-decode json flag (#8494) * add calldata-decode json flag * use print_tokens for calldata-decate, abi-decode, and 4byte-decode * fix clippy --- crates/cast/bin/main.rs | 18 +++++++----------- crates/cast/bin/opts.rs | 12 ++++++++++++ crates/common/fmt/src/dynamic.rs | 17 +++++++++++++++++ crates/common/fmt/src/lib.rs | 4 +++- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index ff4f799cdbddb..044cc25ffd59f 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -12,7 +12,7 @@ use foundry_cli::{handler, prompt, stdin, utils}; use foundry_common::{ abi::get_event, ens::{namehash, ProviderEnsExt}, - fmt::{format_tokens, format_uint_exp}, + fmt::{format_uint_exp, print_tokens}, fs, selectors::{ decode_calldata, decode_event_topic, decode_function_selector, decode_selectors, @@ -163,10 +163,9 @@ async fn main() -> Result<()> { } // ABI encoding & decoding - CastSubcommand::AbiDecode { sig, calldata, input } => { + CastSubcommand::AbiDecode { sig, calldata, input, json } => { let tokens = SimpleCast::abi_decode(&sig, &calldata, input)?; - let tokens = format_tokens(&tokens); - tokens.for_each(|t| println!("{t}")); + print_tokens(&tokens, json) } CastSubcommand::AbiEncode { sig, packed, args } => { if !packed { @@ -175,10 +174,9 @@ async fn main() -> Result<()> { println!("{}", SimpleCast::abi_encode_packed(&sig, &args)?); } } - CastSubcommand::CalldataDecode { sig, calldata } => { + CastSubcommand::CalldataDecode { sig, calldata, json } => { let tokens = SimpleCast::calldata_decode(&sig, &calldata, true)?; - let tokens = format_tokens(&tokens); - tokens.for_each(|t| println!("{t}")); + print_tokens(&tokens, json) } CastSubcommand::CalldataEncode { sig, args } => { println!("{}", SimpleCast::calldata_encode(sig, &args)?); @@ -425,7 +423,7 @@ async fn main() -> Result<()> { println!("{sig}"); } } - CastSubcommand::FourByteDecode { calldata } => { + CastSubcommand::FourByteDecode { calldata, json } => { let calldata = stdin::unwrap_line(calldata)?; let sigs = decode_calldata(&calldata).await?; sigs.iter().enumerate().for_each(|(i, sig)| println!("{}) \"{sig}\"", i + 1)); @@ -440,9 +438,7 @@ async fn main() -> Result<()> { }; let tokens = SimpleCast::calldata_decode(sig, &calldata, true)?; - for token in format_tokens(&tokens) { - println!("{token}"); - } + print_tokens(&tokens, json) } CastSubcommand::FourByteEvent { topic } => { let topic = stdin::unwrap_line(topic)?; diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 5b3c09c8a8696..395b4fe2792f8 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -490,6 +490,10 @@ pub enum CastSubcommand { /// The ABI-encoded calldata. calldata: String, + + /// Print the decoded calldata as JSON. + #[arg(long, short, help_heading = "Display options")] + json: bool, }, /// Decode ABI-encoded input or output data. @@ -508,6 +512,10 @@ pub enum CastSubcommand { /// Whether to decode the input or output data. #[arg(long, short, help_heading = "Decode input data instead of output data")] input: bool, + + /// Print the decoded calldata as JSON. + #[arg(long, short, help_heading = "Display options")] + json: bool, }, /// ABI encode the given function argument, excluding the selector. @@ -594,6 +602,10 @@ pub enum CastSubcommand { FourByteDecode { /// The ABI-encoded calldata. calldata: Option, + + /// Print the decoded calldata as JSON. + #[arg(long, short, help_heading = "Display options")] + json: bool, }, /// Get the event signature for a given topic 0 from https://openchain.xyz. diff --git a/crates/common/fmt/src/dynamic.rs b/crates/common/fmt/src/dynamic.rs index 5055e65618b66..4c59989e9702b 100644 --- a/crates/common/fmt/src/dynamic.rs +++ b/crates/common/fmt/src/dynamic.rs @@ -119,6 +119,23 @@ pub fn format_tokens(tokens: &[DynSolValue]) -> impl Iterator + ' tokens.iter().map(format_token) } +/// Pretty-prints a slice of tokens using [`format_token_raw`]. +pub fn format_tokens_raw(tokens: &[DynSolValue]) -> impl Iterator + '_ { + tokens.iter().map(format_token_raw) +} + +/// Prints slice of tokens using [`format_tokens`] or [`format_tokens_raw`] depending on `json` +/// parameter. +pub fn print_tokens(tokens: &[DynSolValue], json: bool) { + if json { + let tokens: Vec = format_tokens_raw(tokens).collect(); + println!("{}", serde_json::to_string_pretty(&tokens).unwrap()); + } else { + let tokens = format_tokens(tokens); + tokens.for_each(|t| println!("{t}")); + } +} + /// Pretty-prints the given value into a string suitable for user output. pub fn format_token(value: &DynSolValue) -> String { DynValueDisplay::new(value, false).to_string() diff --git a/crates/common/fmt/src/lib.rs b/crates/common/fmt/src/lib.rs index c020908097779..f6f792e999742 100644 --- a/crates/common/fmt/src/lib.rs +++ b/crates/common/fmt/src/lib.rs @@ -4,7 +4,9 @@ mod console; pub use console::{console_format, ConsoleFmt, FormatSpec}; mod dynamic; -pub use dynamic::{format_token, format_token_raw, format_tokens, parse_tokens}; +pub use dynamic::{ + format_token, format_token_raw, format_tokens, format_tokens_raw, parse_tokens, print_tokens, +}; mod exp; pub use exp::{format_int_exp, format_uint_exp, to_exp_notation}; From 0ad127a36ad716b09d180bb60b47c8eff1349202 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 25 Jul 2024 05:06:14 +0800 Subject: [PATCH 1282/1963] fix: some verify-bytecode fixes (#8513) * fix: some verify-bytecode fixes * update constructor args handling * --encoded-constructor-args * warn on length mismatch --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 1 + crates/common/src/abi.rs | 17 ++- crates/verify/Cargo.toml | 1 + crates/verify/src/bytecode.rs | 241 +++++++++++++++++----------------- 4 files changed, 132 insertions(+), 128 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42579ff894484..a0797e8ad68d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3502,6 +3502,7 @@ dependencies = [ name = "forge-verify" version = "0.2.0" dependencies = [ + "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", "alloy-provider", diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index a7c545bc82c6b..bcf82b1cddd4c 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -1,13 +1,23 @@ //! ABI related helper functions. use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Event, Function}; +use alloy_json_abi::{Event, Function, Param}; use alloy_primitives::{hex, Address, LogData}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; use foundry_config::Chain; use std::{future::Future, pin::Pin}; +pub fn encode_args(inputs: &[Param], args: I) -> Result> +where + I: IntoIterator, + S: AsRef, +{ + std::iter::zip(inputs, args) + .map(|(input, arg)| coerce_value(&input.selector_type(), arg.as_ref())) + .collect() +} + /// Given a function and a vector of string arguments, it proceeds to convert the args to alloy /// [DynSolValue]s and then ABI encode them. pub fn encode_function_args(func: &Function, args: I) -> Result> @@ -15,10 +25,7 @@ where I: IntoIterator, S: AsRef, { - let params = std::iter::zip(&func.inputs, args) - .map(|(input, arg)| coerce_value(&input.selector_type(), arg.as_ref())) - .collect::>>()?; - func.abi_encode_input(params.as_slice()).map_err(Into::into) + Ok(func.abi_encode_input(&encode_args(&func.inputs, args)?)?) } /// Given a function and a vector of string arguments, it proceeds to convert the args to alloy diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 02da2115775c6..97ff5e425abca 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -22,6 +22,7 @@ serde_json.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-rpc-types.workspace = true +alloy-dyn-abi.workspace = true revm-primitives.workspace = true serde.workspace = true eyre.workspace = true diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index dfa8c31a96bb4..a0b3a7c844c73 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -1,4 +1,5 @@ -use alloy_primitives::{Address, Bytes, U256}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{hex, Address, Bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, BlockNumberOrTag}; use clap::{Parser, ValueHint}; @@ -8,11 +9,10 @@ use foundry_cli::{ opts::EtherscanOpts, utils::{self, read_constructor_args_file, LoadConfig}, }; -use foundry_common::{compile::ProjectCompiler, provider::ProviderBuilder}; +use foundry_common::{abi::encode_args, compile::ProjectCompiler, provider::ProviderBuilder}; use foundry_compilers::{ - artifacts::{BytecodeHash, BytecodeObject, CompactContractBytecode, EvmVersion}, + artifacts::{BytecodeHash, CompactContractBytecode, EvmVersion}, info::ContractInfo, - Artifact, }; use foundry_config::{figment, filter::SkipBuildFilter, impl_figment_convert, Chain, Config}; use foundry_evm::{ @@ -42,25 +42,33 @@ pub struct VerifyBytecodeArgs { /// The constructor args to generate the creation code. #[clap( long, - conflicts_with = "constructor_args_path", + num_args(1..), + conflicts_with_all = &["constructor_args_path", "encoded_constructor_args"], value_name = "ARGS", - visible_alias = "encoded-constructor-args" )] - pub constructor_args: Option, + pub constructor_args: Option>, + + /// The ABI-encoded constructor arguments. + #[arg( + long, + conflicts_with_all = &["constructor_args_path", "constructor_args"], + value_name = "HEX", + )] + pub encoded_constructor_args: Option, /// The path to a file containing the constructor arguments. - #[clap(long, value_hint = ValueHint::FilePath, value_name = "PATH")] + #[arg( + long, + value_hint = ValueHint::FilePath, + value_name = "PATH", + conflicts_with_all = &["constructor_args", "encoded_constructor_args"] + )] pub constructor_args_path: Option, /// The rpc url to use for verification. #[clap(short = 'r', long, value_name = "RPC_URL", env = "ETH_RPC_URL")] pub rpc_url: Option, - /// Verfication Type: `full` or `partial`. - /// Ref: - #[clap(long, default_value = "full", value_name = "TYPE")] - pub verification_type: VerificationType, - #[clap(flatten)] pub etherscan_opts: EtherscanOpts, @@ -86,14 +94,13 @@ impl figment::Provider for VerifyBytecodeArgs { fn data( &self, ) -> Result, figment::Error> { - let mut dict = figment::value::Dict::new(); + let mut dict = self.etherscan_opts.dict(); if let Some(block) = &self.block { dict.insert("block".into(), figment::value::Value::serialize(block)?); } if let Some(rpc_url) = &self.rpc_url { dict.insert("eth_rpc_url".into(), rpc_url.to_string().into()); } - dict.insert("verification_type".into(), self.verification_type.to_string().into()); Ok(figment::value::Map::from([(Config::selected_profile(), dict)])) } @@ -149,31 +156,60 @@ impl VerifyBytecodeArgs { eyre::bail!("Contract name mismatch"); } + // Obtain Etherscan compilation metadata + let etherscan_metadata = source_code.items.first().unwrap(); + + // Obtain local artifact + let artifact = + if let Ok(local_bytecode) = self.build_using_cache(etherscan_metadata, &config) { + trace!("using cache"); + local_bytecode + } else { + self.build_project(&config)? + }; + // Get the constructor args from etherscan - let constructor_args = if let Some(args) = source_code.items.first() { + let mut constructor_args = if let Some(args) = source_code.items.first() { args.constructor_arguments.clone() } else { eyre::bail!("No constructor arguments found for contract at address {}", self.address); }; - // Get user provided constructor args - let provided_constructor_args = if let Some(args) = self.constructor_args.to_owned() { - args - } else if let Some(path) = self.constructor_args_path.to_owned() { + // Get and encode user provided constructor args + let provided_constructor_args = if let Some(path) = self.constructor_args_path.to_owned() { // Read from file - let res = read_constructor_args_file(path)?; - // Convert res to Bytes - res.join("") + Some(read_constructor_args_file(path)?) } else { - constructor_args.to_string() - }; + self.constructor_args.to_owned() + } + .map(|args| { + if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) { + if constructor.inputs.len() != args.len() { + eyre::bail!( + "Mismatch of constructor arguments length. Expected {}, got {}", + constructor.inputs.len(), + args.len() + ); + } + encode_args(&constructor.inputs, &args) + .map(|args| DynSolValue::Tuple(args).abi_encode()) + } else { + Ok(Vec::new()) + } + }) + .transpose()? + .or(self.encoded_constructor_args.to_owned().map(hex::decode).transpose()?); - // Constructor args mismatch - if provided_constructor_args != constructor_args.to_string() && !self.json { - println!( - "{}", - "The provided constructor args do not match the constructor args from etherscan. This will result in a mismatch - Using the args from etherscan".red().bold(), - ); + if let Some(provided) = provided_constructor_args { + if provided != constructor_args && !self.json { + println!( + "{}", + format!("The provided constructor args do not match the constructor args from etherscan ({constructor_args}).") + .yellow() + .bold(), + ); + } + constructor_args = provided.into(); } // Get creation tx hash @@ -215,27 +251,12 @@ impl VerifyBytecodeArgs { }; // If bytecode_hash is disabled then its always partial verification - let (verification_type, has_metadata) = - match (&self.verification_type, config.bytecode_hash) { - (VerificationType::Full, BytecodeHash::None) => (VerificationType::Partial, false), - (VerificationType::Partial, BytecodeHash::None) => { - (VerificationType::Partial, false) - } - (VerificationType::Full, _) => (VerificationType::Full, true), - (VerificationType::Partial, _) => (VerificationType::Partial, true), - }; + let has_metadata = config.bytecode_hash == BytecodeHash::None; - trace!(?verification_type, has_metadata); - // Etherscan compilation metadata - let etherscan_metadata = source_code.items.first().unwrap(); - - let local_bytecode = - if let Some(local_bytecode) = self.build_using_cache(etherscan_metadata, &config) { - trace!("using cache"); - local_bytecode - } else { - self.build_project(&config)? - }; + let local_bytecode = artifact + .bytecode + .and_then(|b| b.into_bytes()) + .ok_or_eyre("Unlinked bytecode is not supported for verification")?; // Append constructor args to the local_bytecode trace!(%constructor_args); @@ -243,18 +264,17 @@ impl VerifyBytecodeArgs { local_bytecode_vec.extend_from_slice(&constructor_args); // Cmp creation code with locally built bytecode and maybe_creation_code - let (did_match, with_status) = try_match( + let match_type = match_bytecodes( local_bytecode_vec.as_slice(), maybe_creation_code, &constructor_args, - &verification_type, false, has_metadata, - )?; + ); let mut json_results: Vec = vec![]; self.print_result( - (did_match, with_status), + match_type, BytecodeType::Creation, &mut json_results, etherscan_metadata, @@ -262,9 +282,9 @@ impl VerifyBytecodeArgs { ); // If the creation code does not match, the runtime also won't match. Hence return. - if !did_match { + if match_type.is_none() { self.print_result( - (did_match, with_status), + None, BytecodeType::Runtime, &mut json_results, etherscan_metadata, @@ -382,17 +402,16 @@ impl VerifyBytecodeArgs { provider.get_code_at(self.address).block_id(BlockId::number(simulation_block)).await?; // Compare the onchain runtime bytecode with the runtime code from the fork. - let (did_match, with_status) = try_match( + let match_type = match_bytecodes( &fork_runtime_code.original_bytes(), &onchain_runtime_code, &constructor_args, - &verification_type, true, has_metadata, - )?; + ); self.print_result( - (did_match, with_status), + match_type, BytecodeType::Runtime, &mut json_results, etherscan_metadata, @@ -405,41 +424,34 @@ impl VerifyBytecodeArgs { Ok(()) } - fn build_project(&self, config: &Config) -> Result { + fn build_project(&self, config: &Config) -> Result { let project = config.project()?; let compiler = ProjectCompiler::new(); - let output = compiler.compile(&project)?; + let mut output = compiler.compile(&project)?; let artifact = output - .find_contract(&self.contract) + .remove_contract(&self.contract) .ok_or_eyre("Build Error: Contract artifact not found locally")?; - let local_bytecode = artifact - .get_bytecode_object() - .ok_or_eyre("Contract artifact does not have bytecode")?; - - let local_bytecode = match local_bytecode.as_ref() { - BytecodeObject::Bytecode(bytes) => bytes, - BytecodeObject::Unlinked(_) => { - eyre::bail!("Unlinked bytecode is not supported for verification") - } - }; - - Ok(local_bytecode.to_owned()) + Ok(artifact.into_contract_bytecode()) } - fn build_using_cache(&self, etherscan_settings: &Metadata, config: &Config) -> Option { - let project = config.project().ok()?; - let cache = project.read_cache_file().ok()?; - let cached_artifacts = cache.read_artifacts::().ok()?; + fn build_using_cache( + &self, + etherscan_settings: &Metadata, + config: &Config, + ) -> Result { + let project = config.project()?; + let cache = project.read_cache_file()?; + let cached_artifacts = cache.read_artifacts::()?; for (key, value) in cached_artifacts { let name = self.contract.name.to_owned() + ".sol"; let version = etherscan_settings.compiler_version.to_owned(); // Ignores vyper if version.starts_with("vyper:") { - return None; + eyre::bail!("Vyper contracts are not supported") } // Parse etherscan version string let version = @@ -447,10 +459,8 @@ impl VerifyBytecodeArgs { // Check if `out/directory` name matches the contract name if key.ends_with(name.as_str()) { - let artifacts = - value.iter().flat_map(|(_, artifacts)| artifacts.iter()).collect::>(); let name = name.replace(".sol", ".json"); - for artifact in artifacts { + for artifact in value.into_values().flatten() { // Check if ABI file matches the name if !artifact.file.ends_with(&name) { continue; @@ -466,46 +476,34 @@ impl VerifyBytecodeArgs { } } - return artifact - .artifact - .bytecode - .as_ref() - .and_then(|bytes| bytes.bytes().to_owned()) - .cloned(); + return Ok(artifact.artifact) } - - return None } } - None + eyre::bail!("couldn't find cached artifact for contract {}", self.contract.name) } fn print_result( &self, - res: (bool, Option), + res: Option, bytecode_type: BytecodeType, json_results: &mut Vec, etherscan_config: &Metadata, config: &Config, ) { - if res.0 { + if let Some(res) = res { if !self.json { println!( "{} with status {}", format!("{bytecode_type:?} code matched").green().bold(), - res.1.unwrap().green().bold() + res.green().bold() ); } else { - let json_res = JsonResult { - bytecode_type, - matched: true, - verification_type: res.1.unwrap(), - message: None, - }; + let json_res = JsonResult { bytecode_type, match_type: Some(res), message: None }; json_results.push(json_res); } - } else if !res.0 && !self.json { + } else if !self.json { println!( "{}", format!( @@ -518,11 +516,10 @@ impl VerifyBytecodeArgs { for mismatch in mismatches { println!("{}", mismatch.red().bold()); } - } else if !res.0 && self.json { + } else { let json_res = JsonResult { bytecode_type, - matched: false, - verification_type: res.1.unwrap(), + match_type: res, message: Some(format!( "{bytecode_type:?} code did not match - this may be due to varying compiler settings" )), @@ -585,36 +582,34 @@ pub enum BytecodeType { #[derive(Debug, Serialize, Deserialize)] pub struct JsonResult { pub bytecode_type: BytecodeType, - pub matched: bool, - pub verification_type: VerificationType, + pub match_type: Option, #[serde(skip_serializing_if = "Option::is_none")] pub message: Option, } -fn try_match( +fn match_bytecodes( local_bytecode: &[u8], bytecode: &[u8], constructor_args: &[u8], - match_type: &VerificationType, is_runtime: bool, has_metadata: bool, -) -> Result<(bool, Option)> { +) -> Option { // 1. Try full match - if *match_type == VerificationType::Full && local_bytecode == bytecode { - Ok((true, Some(VerificationType::Full))) + if local_bytecode == bytecode { + Some(VerificationType::Full) } else { - try_partial_match(local_bytecode, bytecode, constructor_args, is_runtime, has_metadata) - .map(|matched| (matched, Some(VerificationType::Partial))) + is_partial_match(local_bytecode, bytecode, constructor_args, is_runtime, has_metadata) + .then_some(VerificationType::Partial) } } -fn try_partial_match( +fn is_partial_match( mut local_bytecode: &[u8], mut bytecode: &[u8], constructor_args: &[u8], is_runtime: bool, has_metadata: bool, -) -> Result { +) -> bool { // 1. Check length of constructor args if constructor_args.is_empty() || is_runtime { // Assume metadata is at the end of the bytecode @@ -632,24 +627,24 @@ fn try_extract_and_compare_bytecode( mut local_bytecode: &[u8], mut bytecode: &[u8], has_metadata: bool, -) -> Result { +) -> bool { if has_metadata { - local_bytecode = extract_metadata_hash(local_bytecode)?; - bytecode = extract_metadata_hash(bytecode)?; + local_bytecode = extract_metadata_hash(local_bytecode); + bytecode = extract_metadata_hash(bytecode); } // Now compare the local code and bytecode - Ok(local_bytecode == bytecode) + local_bytecode == bytecode } /// @dev This assumes that the metadata is at the end of the bytecode -fn extract_metadata_hash(bytecode: &[u8]) -> Result<&[u8]> { +fn extract_metadata_hash(bytecode: &[u8]) -> &[u8] { // Get the last two bytes of the bytecode to find the length of CBOR metadata let metadata_len = &bytecode[bytecode.len() - 2..]; let metadata_len = u16::from_be_bytes([metadata_len[0], metadata_len[1]]); // Now discard the metadata from the bytecode - Ok(&bytecode[..bytecode.len() - 2 - metadata_len as usize]) + &bytecode[..bytecode.len() - 2 - metadata_len as usize] } fn find_mismatch_in_settings( From 644bb31ec0972d67256441842201590598801bcf Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:08:48 +0300 Subject: [PATCH 1283/1963] fix(coverage): proper instruction for 1st branch anchor (#8512) --- crates/evm/coverage/src/analysis.rs | 2 +- crates/evm/coverage/src/anchors.rs | 2 +- crates/forge/tests/cli/coverage.rs | 106 ++++++++++++++++++++++------ 3 files changed, 87 insertions(+), 23 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index b110f6e69efe5..3eb16332d02e8 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -417,7 +417,7 @@ impl<'a> ContractVisitor<'a> { if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { // Might be a require call, add branch coverage. let name: Option = expr.and_then(|expr| expr.attribute("name")); - if let Some("require") = name.as_deref() { + if let Some("require" | "assert") = name.as_deref() { let branch_id = self.branch_id; self.branch_id += 1; self.push_item(CoverageItem { diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index 983cc77d4a1b7..ad4ad744d2072 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -149,7 +149,7 @@ pub fn find_anchor_branch( ItemAnchor { item_id, // The first branch is the opcode directly after JUMPI - instruction: pc + 1, + instruction: pc + 2, }, ItemAnchor { item_id, instruction: pc_jump }, )); diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index d33cbb47f7343..f9d591fe2df37 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -173,8 +173,8 @@ forgetest!(test_assert_coverage, |prj, cmd| { "AContract.sol", r#" contract AContract { - function checkA() external pure returns (bool) { - assert(10 > 2); + function checkA(uint256 a) external pure returns (bool) { + assert(a > 2); return true; } } @@ -188,26 +188,66 @@ contract AContract { import "./test.sol"; import {AContract} from "./AContract.sol"; +interface Vm { + function expectRevert() external; +} + contract AContractTest is DSTest { - function testA() external { + Vm constant vm = Vm(HEVM_ADDRESS); + function testAssertBranch() external { AContract a = new AContract(); - bool result = a.checkA(); + bool result = a.checkA(10); assertTrue(result); } + + function testAssertRevertBranch() external { + AContract a = new AContract(); + vm.expectRevert(); + a.checkA(1); + } } "#, ) .unwrap(); + // Assert 50% branch coverage for assert failure. + cmd.arg("coverage") + .args(["--mt".to_string(), "testAssertRevertBranch".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|--------------|--------------|--------------|---------------| +| src/AContract.sol | 50.00% (1/2) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 50.00% (1/2) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | + +"#]]); + + // Assert 50% branch coverage for proper assert. + cmd.forge_fuse() + .arg("coverage") + .args(["--mt".to_string(), "testAssertBranch".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|--------------|---------------| +| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 100.00% (2/2) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | + +"#]]); + // Assert 100% coverage (assert properly covered). - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | -| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | +| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | -"#]]); +"#]], + ); }); forgetest!(test_require_coverage, |prj, cmd| { @@ -262,6 +302,20 @@ contract AContractTest is DSTest { | src/AContract.sol | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | | Total | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +"#]]); + + // Assert 50% branch coverage if only happy path tested. + cmd.forge_fuse() + .arg("coverage") + .args(["--mt".to_string(), "testRequireNoRevert".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|--------------|---------------| +| src/AContract.sol | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | + "#]]); // Assert 100% branch coverage. @@ -384,7 +438,7 @@ contract Foo { function foo(uint256 a) external pure { if (a < 10) { - if (a == 1) { + if (a < 3) { assert(a == 1); } else { assert(a == 5); @@ -423,16 +477,23 @@ import {Foo} from "./Foo.sol"; interface Vm { function expectRevert(bytes calldata revertData) external; + function expectRevert() external; } contract FooTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); Foo internal foo = new Foo(); - function test_issue_7784() external view { + function test_issue_7784() external { foo.foo(1); + vm.expectRevert(); + foo.foo(2); + vm.expectRevert(); + foo.foo(4); foo.foo(5); foo.foo(60); + vm.expectRevert(); + foo.foo(70); } function test_issue_4310() external { @@ -506,13 +567,16 @@ contract FooTest is DSTest { ) .unwrap(); - // Assert 100% coverage. + // TODO: fix following issues for 100% coverage + // https://github.com/foundry-rs/foundry/issues/4309 + // https://github.com/foundry-rs/foundry/issues/4310 + // https://github.com/foundry-rs/foundry/issues/4315 cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------|-----------------|-----------------|-----------------|---------------| -| src/Foo.sol | 100.00% (20/20) | 100.00% (23/23) | 100.00% (12/12) | 100.00% (7/7) | -| Total | 100.00% (20/20) | 100.00% (23/23) | 100.00% (12/12) | 100.00% (7/7) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|-----------------|-----------------|----------------|---------------| +| src/Foo.sol | 100.00% (20/20) | 100.00% (23/23) | 83.33% (15/18) | 100.00% (7/7) | +| Total | 100.00% (20/20) | 100.00% (23/23) | 83.33% (15/18) | 100.00% (7/7) | "#]]); }); @@ -681,10 +745,10 @@ contract FooTest is DSTest { cmd.arg("coverage").args(["--mt".to_string(), "happy".to_string()]).assert_success().stdout_eq( str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------|----------------|----------------|---------------|---------------| -| src/Foo.sol | 66.67% (10/15) | 66.67% (14/21) | 100.00% (4/4) | 100.00% (5/5) | -| Total | 66.67% (10/15) | 66.67% (14/21) | 100.00% (4/4) | 100.00% (5/5) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|----------------|----------------|--------------|---------------| +| src/Foo.sol | 66.67% (10/15) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | +| Total | 66.67% (10/15) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | "#]], ); @@ -695,8 +759,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|---------------|---------------| -| src/Foo.sol | 100.00% (15/15) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | -| Total | 100.00% (15/15) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | +| src/Foo.sol | 100.00% (15/15) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | +| Total | 100.00% (15/15) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | "#]], ); From 4e4f35c1d536b4a371ddc5a666258c260fd31b53 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:53:40 +0300 Subject: [PATCH 1284/1963] chore: fix flaky can_test_repeatedly test (#8519) --- crates/forge/tests/cli/test_cmd.rs | 53 ++++++++++++++----- .../tests/fixtures/can_test_repeatedly.stdout | 8 --- .../suggest_when_no_tests_match.stdout | 9 ---- .../forge/tests/fixtures/warn_no_tests.stdout | 1 - .../tests/fixtures/warn_no_tests_match.stdout | 7 --- crates/test-utils/src/util.rs | 6 +++ 6 files changed, 45 insertions(+), 39 deletions(-) delete mode 100644 crates/forge/tests/fixtures/can_test_repeatedly.stdout delete mode 100644 crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout delete mode 100644 crates/forge/tests/fixtures/warn_no_tests.stdout delete mode 100644 crates/forge/tests/fixtures/warn_no_tests_match.stdout diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 23f77f56b793c..1f2e22a15854a 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -50,9 +50,11 @@ contract Dummy {} cmd.args(["test"]); // run command and assert - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/warn_no_tests.stdout"), - ); + cmd.assert_failure().stdout_eq(str![[r#" +... +No tests found in project! Forge looks for functions that starts with `test`. + +"#]]); }); // tests that warning is displayed with pattern when no tests match @@ -71,9 +73,17 @@ contract Dummy {} cmd.args(["--match-path", "*TestE*", "--no-match-path", "*TestF*"]); // run command and assert - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/warn_no_tests_match.stdout"), - ); + cmd.assert_failure().stdout_eq(str![[r#" +... +No tests match the provided pattern: + match-test: `testA.*` + no-match-test: `testB.*` + match-contract: `TestC.*` + no-match-contract: `TestD.*` + match-path: `*TestE*` + no-match-path: `*TestF*` + +"#]]); }); // tests that suggestion is provided with pattern when no tests match @@ -96,10 +106,19 @@ contract TestC { cmd.args(["--match-path", "*TestE*", "--no-match-path", "*TestF*"]); // run command and assert - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/suggest_when_no_tests_match.stdout"), - ); + cmd.assert_failure().stdout_eq(str![[r#" +... +No tests match the provided pattern: + match-test: `testA.*` + no-match-test: `testB.*` + match-contract: `TestC.*` + no-match-contract: `TestD.*` + match-path: `*TestE*` + no-match-path: `*TestF*` + +Did you mean `test1`? + +"#]]); }); // tests that direct import paths are handled correctly @@ -266,10 +285,16 @@ forgetest_init!(can_test_repeatedly, |_prj, cmd| { cmd.assert_non_empty_stdout(); for _ in 0..5 { - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_test_repeatedly.stdout"), - ); + cmd.assert_success().stdout_eq(str![[r#" +... +Ran 2 tests for test/Counter.t.sol:CounterTest +[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: [..], ~: [..]) +[PASS] test_Increment() (gas: 31303) +Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in [..] ([..] CPU time) + +Ran 1 test suite in [..] ([..] CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests) + +"#]]); } }); diff --git a/crates/forge/tests/fixtures/can_test_repeatedly.stdout b/crates/forge/tests/fixtures/can_test_repeatedly.stdout deleted file mode 100644 index 5a29d4dd7a9e8..0000000000000 --- a/crates/forge/tests/fixtures/can_test_repeatedly.stdout +++ /dev/null @@ -1,8 +0,0 @@ -No files changed, compilation skipped - -Ran 2 tests for test/Counter.t.sol:CounterTest -[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) -[PASS] test_Increment() (gas: 31303) -Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms - -Ran 1 test suite: 2 tests passed, 0 failed, 0 skipped (2 total tests) diff --git a/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout b/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout deleted file mode 100644 index 1cf6ad73f8952..0000000000000 --- a/crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout +++ /dev/null @@ -1,9 +0,0 @@ -No tests match the provided pattern: - match-test: `testA.*` - no-match-test: `testB.*` - match-contract: `TestC.*` - no-match-contract: `TestD.*` - match-path: `*TestE*` - no-match-path: `*TestF*` - -Did you mean `test1`? diff --git a/crates/forge/tests/fixtures/warn_no_tests.stdout b/crates/forge/tests/fixtures/warn_no_tests.stdout deleted file mode 100644 index a9a7e7fc67111..0000000000000 --- a/crates/forge/tests/fixtures/warn_no_tests.stdout +++ /dev/null @@ -1 +0,0 @@ -No tests found in project! Forge looks for functions that starts with `test`. diff --git a/crates/forge/tests/fixtures/warn_no_tests_match.stdout b/crates/forge/tests/fixtures/warn_no_tests_match.stdout deleted file mode 100644 index 4b4080f15faec..0000000000000 --- a/crates/forge/tests/fixtures/warn_no_tests_match.stdout +++ /dev/null @@ -1,7 +0,0 @@ -No tests match the provided pattern: - match-test: `testA.*` - no-match-test: `testB.*` - match-contract: `TestC.*` - no-match-contract: `TestD.*` - match-path: `*TestE*` - no-match-path: `*TestF*` diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index c1c2df0b01439..9b6380e0771fe 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -926,6 +926,12 @@ impl TestCommand { self.assert().success() } + /// Runs the command and asserts that it failed. + #[track_caller] + pub fn assert_failure(&mut self) -> OutputAssert { + self.assert().failure() + } + /// Executes command, applies stdin function and returns output #[track_caller] pub fn execute(&mut self) -> Output { From 4845380050c55929c0f9309e20552e1412c4a0d2 Mon Sep 17 00:00:00 2001 From: James Kim Date: Thu, 25 Jul 2024 11:41:16 -0400 Subject: [PATCH 1285/1963] fix(anvil): remove override for block.basefee when building transaction env (#8517) * remove override for block.basefee * disable basefee check for env * add tests * fix --- crates/anvil/src/eth/backend/mem/mod.rs | 9 ++-- crates/anvil/tests/it/api.rs | 65 +++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 429cefcae834e..804ef74f41fa3 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1152,9 +1152,12 @@ impl Backend { // impls and providers env.cfg.disable_block_gas_limit = true; - if let Some(base) = max_fee_per_gas { - env.block.basefee = U256::from(base); - } + // The basefee should be ignored for calls against state for + // - eth_call + // - eth_estimateGas + // - eth_createAccessList + // - tracing + env.cfg.disable_base_fee = true; let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| { self.fees().raw_gas_price().saturating_add(MIN_SUGGESTED_PRIORITY_FEE) diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 13f8200ef1fcf..9e640beb908ca 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -161,6 +161,39 @@ async fn can_get_pending_block() { assert_eq!(block.transactions.len(), 1); } +#[tokio::test(flavor = "multi_thread")] +async fn can_estimate_gas_with_undersized_max_fee_per_gas() { + let (api, handle) = spawn(NodeConfig::test()).await; + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumWallet = wallet.clone().into(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + api.anvil_set_auto_mine(true).await.unwrap(); + + let init_value = "toto".to_string(); + + let simple_storage_contract = + SimpleStorage::deploy(&provider, init_value.clone()).await.unwrap(); + + let undersized_max_fee_per_gas = 1_u128; + + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + let latest_block_base_fee_per_gas = latest_block.header.base_fee_per_gas.unwrap(); + + assert!(undersized_max_fee_per_gas < latest_block_base_fee_per_gas); + + let estimated_gas = simple_storage_contract + .setValue("new_value".to_string()) + .max_fee_per_gas(undersized_max_fee_per_gas) + .from(wallet.address()) + .estimate_gas() + .await + .unwrap(); + + assert!(estimated_gas > 0); +} + #[tokio::test(flavor = "multi_thread")] async fn can_call_on_pending_block() { let (api, handle) = spawn(NodeConfig::test()).await; @@ -239,6 +272,38 @@ async fn can_call_on_pending_block() { } } +#[tokio::test(flavor = "multi_thread")] +async fn can_call_with_undersized_max_fee_per_gas() { + let (api, handle) = spawn(NodeConfig::test()).await; + let wallet = handle.dev_wallets().next().unwrap(); + let signer: EthereumWallet = wallet.clone().into(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer); + + api.anvil_set_auto_mine(true).await.unwrap(); + + let init_value = "toto".to_string(); + + let simple_storage_contract = + SimpleStorage::deploy(&provider, init_value.clone()).await.unwrap(); + + let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + let latest_block_base_fee_per_gas = latest_block.header.base_fee_per_gas.unwrap(); + let undersized_max_fee_per_gas = 1_u128; + + assert!(undersized_max_fee_per_gas < latest_block_base_fee_per_gas); + + let last_sender = simple_storage_contract + .lastSender() + .max_fee_per_gas(undersized_max_fee_per_gas) + .from(wallet.address()) + .call() + .await + .unwrap() + ._0; + assert_eq!(last_sender, Address::ZERO); +} + #[tokio::test(flavor = "multi_thread")] async fn can_call_with_state_override() { let (api, handle) = spawn(NodeConfig::test()).await; From 9444c6217a258cb4fd6ac38597ea282d6642ec7c Mon Sep 17 00:00:00 2001 From: 0xKitsune <77890308+0xKitsune@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:27:30 -0400 Subject: [PATCH 1286/1963] Update `ScriptArgs::preprocess()` visibility to `pub` (#8524) update preprocess visibility --- crates/script/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index af7000672b3f4..b6370b43206c1 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -195,7 +195,7 @@ pub struct ScriptArgs { } impl ScriptArgs { - async fn preprocess(self) -> Result { + pub async fn preprocess(self) -> Result { let script_wallets = ScriptWallets::new(self.wallets.get_multi_wallet().await?, self.evm_opts.sender); From e606f5328ded4486029eff51362dc7a140f6e561 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 26 Jul 2024 17:01:06 +0800 Subject: [PATCH 1287/1963] fix: etherscan identifier for scripts (#8528) --- crates/script/src/execute.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index bfa9de0d2bc1c..8f92f01bd55db 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -332,14 +332,6 @@ impl ExecutedState { self.script_config.evm_opts.get_remote_chain_id().await, )?; - // Decoding traces using etherscan is costly as we run into rate limits, - // causing scripts to run for a very long time unnecessarily. - // Therefore, we only try and use etherscan if the user has provided an API key. - let should_use_etherscan_traces = self.script_config.config.etherscan_api_key.is_some(); - if !should_use_etherscan_traces { - identifier.etherscan = None; - } - for (_, trace) in &self.execution_result.traces { decoder.identify(trace, &mut identifier); } From 1f9b52c7ccc79728d6551ecbe67a3436e8b2ad2b Mon Sep 17 00:00:00 2001 From: teddav Date: Fri, 26 Jul 2024 11:29:13 +0200 Subject: [PATCH 1288/1963] feat: sendRawTransaction cheatcode (#4931) * feat: sendRawTransaction cheatcode * added unit tests * clippy + forge fmt * rebase * rename cheatcode to broadcastrawtransaction * revert anvil to sendrawtransaction + rename enum to Unsigned * better TransactionMaybeSigned * fix: ci * fixes * review fixes * add newline * Update crates/common/src/transactions.rs * Update crates/script/src/broadcast.rs * revm now uses Alloys AccessList: https://github.com/bluealloy/revm/pull/1552/files * only broadcast if you can transact, reorder cheatcode to be in broadcast section + document its behavior * update spec --------- Co-authored-by: Arsenii Kulikov Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: zerosnacks Co-authored-by: Matthias Seitz --- Cargo.lock | 4 + crates/cheatcodes/Cargo.toml | 4 +- crates/cheatcodes/assets/cheatcodes.json | 20 + crates/cheatcodes/spec/src/vm.rs | 4 + crates/cheatcodes/src/evm.rs | 35 +- crates/cheatcodes/src/inspector.rs | 12 +- crates/common/Cargo.toml | 1 + crates/common/src/transactions.rs | 89 ++++- crates/evm/core/src/backend/cow.rs | 11 + crates/evm/core/src/backend/mod.rs | 61 ++- crates/script/Cargo.toml | 1 + crates/script/src/broadcast.rs | 128 ++++--- crates/script/src/build.rs | 2 +- crates/script/src/execute.rs | 4 +- crates/script/src/lib.rs | 6 +- crates/script/src/runner.rs | 6 +- crates/script/src/sequence.rs | 13 +- crates/script/src/simulate.rs | 97 ++--- crates/script/src/transaction.rs | 35 +- docs/dev/cheatcodes.md | 2 +- testdata/cheats/Vm.sol | 1 + .../cheats/BroadcastRawTransaction.t.sol | 346 ++++++++++++++++++ 22 files changed, 737 insertions(+), 145 deletions(-) create mode 100644 testdata/default/cheats/BroadcastRawTransaction.t.sol diff --git a/Cargo.lock b/Cargo.lock index a0797e8ad68d8..dccf91eef047d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3444,6 +3444,7 @@ name = "forge-script" version = "0.2.0" dependencies = [ "alloy-chains", + "alloy-consensus", "alloy-dyn-abi", "alloy-eips", "alloy-json-abi", @@ -3563,11 +3564,13 @@ dependencies = [ name = "foundry-cheatcodes" version = "0.2.0" dependencies = [ + "alloy-consensus", "alloy-dyn-abi", "alloy-genesis", "alloy-json-abi", "alloy-primitives", "alloy-provider", + "alloy-rlp", "alloy-rpc-types", "alloy-signer", "alloy-signer-local", @@ -3649,6 +3652,7 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ + "alloy-consensus", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 93636c3f2f6d3..60304a47dd0d4 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -28,13 +28,15 @@ alloy-primitives.workspace = true alloy-genesis.workspace = true alloy-sol-types.workspace = true alloy-provider.workspace = true -alloy-rpc-types.workspace = true +alloy-rpc-types = { workspace = true, features = ["k256"] } alloy-signer.workspace = true alloy-signer-local = { workspace = true, features = [ "mnemonic-all-languages", "keystore", ] } parking_lot.workspace = true +alloy-consensus = { workspace = true, features = ["k256"] } +alloy-rlp.workspace = true eyre.workspace = true itertools.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index a6a9c94795ee1..ec12113eb31ba 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3051,6 +3051,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "broadcastRawTransaction", + "description": "Takes a signed transaction and broadcasts it to the network.", + "declaration": "function broadcastRawTransaction(bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "broadcastRawTransaction(bytes)", + "selector": "0x8c0c72e0", + "selectorBytes": [ + 140, + 12, + 114, + 224 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "broadcast_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index a009c9f598e25..ff9a92e58930c 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1759,6 +1759,10 @@ interface Vm { #[cheatcode(group = Scripting)] function stopBroadcast() external; + /// Takes a signed transaction and broadcasts it to the network. + #[cheatcode(group = Scripting)] + function broadcastRawTransaction(bytes calldata data) external; + // ======== Utilities ======== // -------- Strings -------- diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 33b0642011590..97923a948791c 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1,8 +1,12 @@ //! Implementations of [`Evm`](spec::Group::Evm) cheatcodes. -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; +use crate::{ + BroadcastableTransaction, Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*, +}; +use alloy_consensus::TxEnvelope; use alloy_genesis::{Genesis, GenesisAccount}; use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_rlp::Decodable; use alloy_sol_types::SolValue; use foundry_common::fs::{read_json_file, write_json_file}; use foundry_evm_core::{ @@ -567,6 +571,35 @@ impl Cheatcode for stopAndReturnStateDiffCall { } } +impl Cheatcode for broadcastRawTransactionCall { + fn apply_full( + &self, + ccx: &mut CheatsCtxt, + executor: &mut E, + ) -> Result { + let mut data = self.data.as_ref(); + let tx = TxEnvelope::decode(&mut data).map_err(|err| { + fmt_err!("broadcastRawTransaction: error decoding transaction ({err})") + })?; + + ccx.ecx.db.transact_from_tx( + tx.clone().into(), + &ccx.ecx.env, + &mut ccx.ecx.journaled_state, + &mut executor.get_inspector(ccx.state), + )?; + + if ccx.state.broadcast.is_some() { + ccx.state.broadcastable_transactions.push_back(BroadcastableTransaction { + rpc: ccx.db.active_fork_url(), + transaction: tx.try_into()?, + }); + } + + Ok(Default::default()) + } +} + impl Cheatcode for setBlockhashCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { blockNumber, blockHash } = *self; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index c989659e115bd..13cc02df373be 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -19,7 +19,7 @@ use crate::{ use alloy_primitives::{hex, Address, Bytes, Log, TxKind, B256, U256}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolCall, SolInterface, SolValue}; -use foundry_common::{evm::Breakpoints, SELECTOR_LEN}; +use foundry_common::{evm::Breakpoints, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_config::Config; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, @@ -188,12 +188,12 @@ impl Context { } /// Helps collecting transactions from different forks. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct BroadcastableTransaction { /// The optional RPC URL. pub rpc: Option, /// The transaction to broadcast. - pub transaction: TransactionRequest, + pub transaction: TransactionMaybeSigned, } /// List of transactions that can be broadcasted. @@ -513,7 +513,8 @@ impl Cheatcodes { None }, ..Default::default() - }, + } + .into(), }); input.log_debug(self, &input.scheme().unwrap_or(CreateScheme::Create)); @@ -849,7 +850,8 @@ impl Cheatcodes { None }, ..Default::default() - }, + } + .into(), }); debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable call"); diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 094f32bed6528..5c843979a97e6 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -41,6 +41,7 @@ alloy-transport-http = { workspace = true, features = [ alloy-transport-ipc.workspace = true alloy-transport-ws.workspace = true alloy-transport.workspace = true +alloy-consensus = { workspace = true, features = ["k256"] } tower.workspace = true diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 2693c8ac249bc..c927d575dcc10 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -1,7 +1,9 @@ //! Wrappers for transactions. +use alloy_consensus::{Transaction, TxEnvelope}; +use alloy_primitives::{Address, TxKind, U256}; use alloy_provider::{network::AnyNetwork, Provider}; -use alloy_rpc_types::{AnyTransactionReceipt, BlockId}; +use alloy_rpc_types::{AnyTransactionReceipt, BlockId, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::Result; @@ -144,3 +146,88 @@ mod tests { assert_eq!(extract_revert_reason(error_string_2), None); } } + +/// Used for broadcasting transactions +/// A transaction can either be a [`TransactionRequest`] waiting to be signed +/// or a [`TxEnvelope`], already signed +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TransactionMaybeSigned { + Signed { + #[serde(flatten)] + tx: TxEnvelope, + from: Address, + }, + Unsigned(WithOtherFields), +} + +impl TransactionMaybeSigned { + /// Creates a new (unsigned) transaction for broadcast + pub fn new(tx: WithOtherFields) -> Self { + Self::Unsigned(tx) + } + + /// Creates a new signed transaction for broadcast. + pub fn new_signed( + tx: TxEnvelope, + ) -> core::result::Result { + let from = tx.recover_signer()?; + Ok(Self::Signed { tx, from }) + } + + pub fn as_unsigned_mut(&mut self) -> Option<&mut WithOtherFields> { + match self { + Self::Unsigned(tx) => Some(tx), + _ => None, + } + } + + pub fn from(&self) -> Option
{ + match self { + Self::Signed { from, .. } => Some(*from), + Self::Unsigned(tx) => tx.from, + } + } + + pub fn input(&self) -> Option<&[u8]> { + match self { + Self::Signed { tx, .. } => Some(tx.input()), + Self::Unsigned(tx) => tx.input.input().map(|i| i.as_ref()), + } + } + + pub fn to(&self) -> Option { + match self { + Self::Signed { tx, .. } => Some(tx.to()), + Self::Unsigned(tx) => tx.to, + } + } + + pub fn value(&self) -> Option { + match self { + Self::Signed { tx, .. } => Some(tx.value()), + Self::Unsigned(tx) => tx.value, + } + } + + pub fn gas(&self) -> Option { + match self { + Self::Signed { tx, .. } => Some(tx.gas_limit()), + Self::Unsigned(tx) => tx.gas, + } + } +} + +impl From for TransactionMaybeSigned { + fn from(tx: TransactionRequest) -> Self { + Self::new(WithOtherFields::new(tx)) + } +} + +impl TryFrom for TransactionMaybeSigned { + type Error = alloy_primitives::SignatureError; + + fn try_from(tx: TxEnvelope) -> core::result::Result { + Self::new_signed(tx) + } +} diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 9ca63c5136603..2dcd985ae9124 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -10,6 +10,7 @@ use crate::{ }; use alloy_genesis::GenesisAccount; use alloy_primitives::{Address, B256, U256}; +use alloy_rpc_types::TransactionRequest; use eyre::WrapErr; use foundry_fork_db::DatabaseError; use revm::{ @@ -190,6 +191,16 @@ impl<'a> DatabaseExt for CowBackend<'a> { self.backend_mut(env).transact(id, transaction, env, journaled_state, inspector) } + fn transact_from_tx( + &mut self, + transaction: TransactionRequest, + env: &Env, + journaled_state: &mut JournaledState, + inspector: &mut dyn InspectorExt, + ) -> eyre::Result<()> { + self.backend_mut(env).transact_from_tx(transaction, env, journaled_state, inspector) + } + fn active_fork_id(&self) -> Option { self.backend.active_fork_id() } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 23c54e6e21545..7c2ed11c4b239 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -4,12 +4,14 @@ use crate::{ constants::{CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, TEST_CONTRACT_ADDRESS}, fork::{CreateFork, ForkId, MultiFork}, snapshot::Snapshots, - utils::configure_tx_env, + utils::{configure_tx_env, new_evm_with_inspector}, InspectorExt, }; use alloy_genesis::GenesisAccount; -use alloy_primitives::{keccak256, uint, Address, B256, U256}; -use alloy_rpc_types::{Block, BlockNumberOrTag, BlockTransactions, Transaction}; +use alloy_primitives::{keccak256, uint, Address, TxKind, B256, U256}; +use alloy_rpc_types::{ + Block, BlockNumberOrTag, BlockTransactions, Transaction, TransactionRequest, +}; use alloy_serde::WithOtherFields; use eyre::Context; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; @@ -20,7 +22,7 @@ use revm::{ precompile::{PrecompileSpecId, Precompiles}, primitives::{ Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, EvmState, EvmStorageSlot, - HashMap as Map, Log, ResultAndState, SpecId, TxKind, KECCAK_EMPTY, + HashMap as Map, Log, ResultAndState, SpecId, KECCAK_EMPTY, }, Database, DatabaseCommit, JournaledState, }; @@ -202,6 +204,15 @@ pub trait DatabaseExt: Database + DatabaseCommit { inspector: &mut dyn InspectorExt, ) -> eyre::Result<()>; + /// Executes a given TransactionRequest, commits the new state to the DB + fn transact_from_tx( + &mut self, + transaction: TransactionRequest, + env: &Env, + journaled_state: &mut JournaledState, + inspector: &mut dyn InspectorExt, + ) -> eyre::Result<()>; + /// Returns the `ForkId` that's currently used in the database, if fork mode is on fn active_fork_id(&self) -> Option; @@ -1246,6 +1257,48 @@ impl DatabaseExt for Backend { ) } + fn transact_from_tx( + &mut self, + tx: TransactionRequest, + env: &Env, + journaled_state: &mut JournaledState, + inspector: &mut dyn InspectorExt, + ) -> eyre::Result<()> { + trace!(?tx, "execute signed transaction"); + + let mut env = env.clone(); + + env.tx.caller = + tx.from.ok_or_else(|| eyre::eyre!("transact_from_tx: No `from` field found"))?; + env.tx.gas_limit = + tx.gas.ok_or_else(|| eyre::eyre!("transact_from_tx: No `gas` field found"))? as u64; + env.tx.gas_price = U256::from(tx.gas_price.or(tx.max_fee_per_gas).unwrap_or_default()); + env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); + env.tx.nonce = tx.nonce; + env.tx.access_list = tx.access_list.clone().unwrap_or_default().0.into_iter().collect(); + env.tx.value = + tx.value.ok_or_else(|| eyre::eyre!("transact_from_tx: No `value` field found"))?; + env.tx.data = tx.input.into_input().unwrap_or_default(); + env.tx.transact_to = + tx.to.ok_or_else(|| eyre::eyre!("transact_from_tx: No `to` field found"))?; + env.tx.chain_id = tx.chain_id; + + self.commit(journaled_state.state.clone()); + + let res = { + let db = self.clone(); + let env = self.env_with_handler_cfg(env); + let mut evm = new_evm_with_inspector(db, env, inspector); + evm.context.evm.journaled_state.depth = journaled_state.depth + 1; + evm.transact()? + }; + + self.commit(res.state); + update_state(&mut journaled_state.state, self, None)?; + + Ok(()) + } + fn active_fork_id(&self) -> Option { self.active_fork_ids.map(|(id, _)| id) } diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 3ef1f6b68bcf2..9c042661775ce 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -53,6 +53,7 @@ alloy-dyn-abi.workspace = true alloy-primitives.workspace = true alloy-eips.workspace = true alloy-transport.workspace = true +alloy-consensus.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index b7eb9f5b0bb6c..a1113bb2dbd2f 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -3,6 +3,7 @@ use crate::{ verify::BroadcastedState, ScriptArgs, ScriptConfig, }; use alloy_chains::Chain; +use alloy_consensus::TxEnvelope; use alloy_eips::eip2718::Encodable2718; use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; use alloy_primitives::{utils::format_units, Address, TxHash}; @@ -16,7 +17,7 @@ use foundry_cheatcodes::ScriptWallets; use foundry_cli::utils::{has_batch_support, has_different_gas_calc}; use foundry_common::{ provider::{get_http_provider, try_get_http_provider, RetryProvider}, - shell, + shell, TransactionMaybeSigned, }; use foundry_config::Config; use futures::{future::join_all, StreamExt}; @@ -55,45 +56,49 @@ pub async fn next_nonce(caller: Address, provider_url: &str) -> eyre::Result, - mut tx: WithOtherFields, - kind: SendTransactionKind<'_>, + mut kind: SendTransactionKind<'_>, sequential_broadcast: bool, is_fixed_gas_limit: bool, estimate_via_rpc: bool, estimate_multiplier: u64, ) -> Result { - let from = tx.from.expect("no sender"); + if let SendTransactionKind::Raw(tx, _) | SendTransactionKind::Unlocked(tx) = &mut kind { + if sequential_broadcast { + let from = tx.from.expect("no sender"); - if sequential_broadcast { - let nonce = provider.get_transaction_count(from).await?; + let nonce = provider.get_transaction_count(from).await?; - let tx_nonce = tx.nonce.expect("no nonce"); - if nonce != tx_nonce { - bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") + let tx_nonce = tx.nonce.expect("no nonce"); + if nonce != tx_nonce { + bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") + } } - } - // Chains which use `eth_estimateGas` are being sent sequentially and require their - // gas to be re-estimated right before broadcasting. - if !is_fixed_gas_limit && estimate_via_rpc { - estimate_gas(&mut tx, &provider, estimate_multiplier).await?; + // Chains which use `eth_estimateGas` are being sent sequentially and require their + // gas to be re-estimated right before broadcasting. + if !is_fixed_gas_limit && estimate_via_rpc { + estimate_gas(tx, &provider, estimate_multiplier).await?; + } } let pending = match kind { - SendTransactionKind::Unlocked(addr) => { - debug!("sending transaction from unlocked account {:?}: {:?}", addr, tx); + SendTransactionKind::Unlocked(tx) => { + debug!("sending transaction from unlocked account {:?}", tx); // Submit the transaction provider.send_transaction(tx).await? } - SendTransactionKind::Raw(signer) => { + SendTransactionKind::Raw(tx, signer) => { debug!("sending transaction: {:?}", tx); - let signed = tx.build(signer).await?; // Submit the raw transaction provider.send_raw_transaction(signed.encoded_2718().as_ref()).await? } + SendTransactionKind::Signed(tx) => { + debug!("sending transaction: {:?}", tx); + provider.send_raw_transaction(tx.encoded_2718().as_ref()).await? + } }; Ok(*pending.tx_hash()) @@ -102,8 +107,9 @@ pub async fn send_transaction( /// How to send a single transaction #[derive(Clone)] pub enum SendTransactionKind<'a> { - Unlocked(Address), - Raw(&'a EthereumWallet), + Unlocked(WithOtherFields), + Raw(WithOtherFields, &'a EthereumWallet), + Signed(TxEnvelope), } /// Represents how to send _all_ transactions @@ -118,31 +124,27 @@ impl SendTransactionsKind { /// Returns the [`SendTransactionKind`] for the given address /// /// Returns an error if no matching signer is found or the address is not unlocked - pub fn for_sender(&self, addr: &Address) -> Result> { + pub fn for_sender( + &self, + addr: &Address, + tx: WithOtherFields, + ) -> Result> { match self { Self::Unlocked(unlocked) => { if !unlocked.contains(addr) { bail!("Sender address {:?} is not unlocked", addr) } - Ok(SendTransactionKind::Unlocked(*addr)) + Ok(SendTransactionKind::Unlocked(tx)) } Self::Raw(wallets) => { if let Some(wallet) = wallets.get(addr) { - Ok(SendTransactionKind::Raw(wallet)) + Ok(SendTransactionKind::Raw(tx, wallet)) } else { bail!("No matching signer for {:?} found", addr) } } } } - - /// How many signers are set - pub fn signers_count(&self) -> usize { - match self { - Self::Unlocked(addr) => addr.len(), - Self::Raw(signers) => signers.len(), - } - } } /// State after we have bundled all @@ -189,11 +191,7 @@ impl BundledState { .sequence .sequences() .iter() - .flat_map(|sequence| { - sequence - .transactions() - .map(|tx| (tx.from().expect("No sender for onchain transaction!"))) - }) + .flat_map(|sequence| sequence.transactions().map(|tx| tx.from().expect("missing from"))) .collect::>(); if required_addresses.contains(&Config::DEFAULT_SENDER) { @@ -203,7 +201,7 @@ impl BundledState { } let send_kind = if self.args.unlocked { - SendTransactionsKind::Unlocked(required_addresses) + SendTransactionsKind::Unlocked(required_addresses.clone()) } else { let signers = self.script_wallets.into_multi_wallet().into_signers()?; let mut missing_addresses = Vec::new(); @@ -279,29 +277,38 @@ impl BundledState { .iter() .skip(already_broadcasted) .map(|tx_with_metadata| { - let tx = tx_with_metadata.tx(); - let from = tx.from().expect("No sender for onchain transaction!"); - - let kind = send_kind.for_sender(&from)?; let is_fixed_gas_limit = tx_with_metadata.is_fixed_gas_limit; - let mut tx = tx.clone(); - tx.set_chain_id(sequence.chain); - - // Set TxKind::Create explicityly to satify `check_reqd_fields` in alloy - if tx.to().is_none() { - tx.set_create(); - } - - if let Some(gas_price) = gas_price { - tx.set_gas_price(gas_price); - } else { - let eip1559_fees = eip1559_fees.expect("was set above"); - tx.set_max_priority_fee_per_gas(eip1559_fees.max_priority_fee_per_gas); - tx.set_max_fee_per_gas(eip1559_fees.max_fee_per_gas); - } - - Ok((tx, kind, is_fixed_gas_limit)) + let kind = match tx_with_metadata.tx().clone() { + TransactionMaybeSigned::Signed { tx, .. } => { + SendTransactionKind::Signed(tx) + } + TransactionMaybeSigned::Unsigned(mut tx) => { + let from = tx.from.expect("No sender for onchain transaction!"); + + tx.set_chain_id(sequence.chain); + + // Set TxKind::Create explicitly to satify `check_reqd_fields` in + // alloy + if tx.to.is_none() { + tx.set_create(); + } + + if let Some(gas_price) = gas_price { + tx.set_gas_price(gas_price); + } else { + let eip1559_fees = eip1559_fees.expect("was set above"); + tx.set_max_priority_fee_per_gas( + eip1559_fees.max_priority_fee_per_gas, + ); + tx.set_max_fee_per_gas(eip1559_fees.max_fee_per_gas); + } + + send_kind.for_sender(&from, tx)? + } + }; + + Ok((kind, is_fixed_gas_limit)) }) .collect::>>()?; @@ -315,7 +322,7 @@ impl BundledState { // Or if we need to invoke eth_estimateGas before sending transactions. let sequential_broadcast = estimate_via_rpc || self.args.slow || - send_kind.signers_count() != 1 || + required_addresses.len() != 1 || !has_batch_support(sequence.chain); // We send transactions and wait for receipts in batches. @@ -330,10 +337,9 @@ impl BundledState { batch_number * batch_size, batch_number * batch_size + std::cmp::min(batch_size, batch.len()) - 1 )); - for (tx, kind, is_fixed_gas_limit) in batch { + for (kind, is_fixed_gas_limit) in batch { let fut = send_transaction( provider.clone(), - tx.clone(), kind.clone(), sequential_broadcast, *is_fixed_gas_limit, diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 14feb42ff00e0..b0c5a2947a4d1 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -291,7 +291,7 @@ impl CompiledState { s.transactions .iter() .skip(s.receipts.len()) - .map(|t| t.transaction.from.expect("from is missing in script artifact")) + .map(|t| t.transaction.from().expect("from is missing in script artifact")) }); let available_signers = self diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 8f92f01bd55db..1eff7e0de63a9 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -189,8 +189,8 @@ impl PreExecutionState { self.args.evm_opts.sender.is_none() { for tx in txs.iter() { - if tx.transaction.to.is_none() { - let sender = tx.transaction.from.expect("no sender"); + if tx.transaction.to().is_none() { + let sender = tx.transaction.from().expect("no sender"); if let Some(ns) = new_sender { if sender != ns { shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index b6370b43206c1..97a33541f3d1d 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -386,11 +386,9 @@ impl ScriptArgs { for (data, to) in result.transactions.iter().flat_map(|txes| { txes.iter().filter_map(|tx| { tx.transaction - .input - .clone() - .into_input() + .input() .filter(|data| data.len() > max_size) - .map(|data| (data, tx.transaction.to)) + .map(|data| (data, tx.transaction.to())) }) }) { let mut offset = 0; diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index a4f437644dbcd..7b7a2375bb752 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -78,7 +78,8 @@ impl ScriptRunner { input: Some(code.clone()).into(), nonce: Some(sender_nonce + library_transactions.len() as u64), ..Default::default() - }, + } + .into(), }) }), ScriptPredeployLibraries::Create2(libraries, salt) => { @@ -112,7 +113,8 @@ impl ScriptRunner { nonce: Some(sender_nonce + library_transactions.len() as u64), to: Some(TxKind::Call(DEFAULT_CREATE2_DEPLOYER)), ..Default::default() - }, + } + .into(), }); } diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 5a8e789a60b01..53212f4ebf3bb 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -4,12 +4,11 @@ use crate::{ verify::VerifyBundle, }; use alloy_primitives::{hex, Address, TxHash}; -use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; -use alloy_serde::WithOtherFields; +use alloy_rpc_types::AnyTransactionReceipt; use eyre::{eyre, ContextCompat, Result, WrapErr}; use forge_verify::provider::VerificationProviderType; use foundry_cli::utils::{now, Git}; -use foundry_common::{fs, shell, SELECTOR_LEN}; +use foundry_common::{fs, shell, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_compilers::ArtifactId; use foundry_config::Config; use serde::{Deserialize, Serialize}; @@ -284,10 +283,8 @@ impl ScriptSequence { } // Verify contract created directly from the transaction - if let (Some(address), Some(data)) = - (receipt.contract_address, tx.tx().input.input()) - { - match verify.get_verify_args(address, offset, &data.0, &self.libraries) { + if let (Some(address), Some(data)) = (receipt.contract_address, tx.tx().input()) { + match verify.get_verify_args(address, offset, data, &self.libraries) { Some(verify) => future_verifications.push(verify.run()), None => unverifiable_contracts.push(address), }; @@ -363,7 +360,7 @@ impl ScriptSequence { } /// Returns the list of the transactions without the metadata. - pub fn transactions(&self) -> impl Iterator> { + pub fn transactions(&self) -> impl Iterator { self.transactions.iter().map(|tx| tx.tx()) } diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 4a5f44117320c..077c507e24a3c 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -13,7 +13,7 @@ use crate::{ ScriptArgs, ScriptConfig, ScriptResult, }; use alloy_network::TransactionBuilder; -use alloy_primitives::{utils::format_units, Address, TxKind, U256}; +use alloy_primitives::{utils::format_units, Address, Bytes, TxKind, U256}; use eyre::{Context, Result}; use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; use foundry_cli::utils::{has_different_gas_calc, now}; @@ -99,14 +99,14 @@ impl PreSimulationState { let mut runner = runners.get(&rpc).expect("invalid rpc url").write(); let mut tx = transaction.transaction; - let to = if let Some(TxKind::Call(to)) = tx.to { Some(to) } else { None }; + let to = if let Some(TxKind::Call(to)) = tx.to() { Some(to) } else { None }; let result = runner .simulate( - tx.from + tx.from() .expect("transaction doesn't have a `from` address at execution time"), to, - tx.input.clone().into_input(), - tx.value, + tx.input().map(Bytes::copy_from_slice), + tx.value(), ) .wrap_err("Internal EVM error during simulation")?; @@ -121,18 +121,25 @@ impl PreSimulationState { runner.executor.env_mut().block.number += U256::from(1); } - let is_fixed_gas_limit = tx.gas.is_some(); - match tx.gas { - // If tx.gas is already set that means it was specified in script - Some(gas) => { - println!("Gas limit was set in script to {gas}"); + let is_fixed_gas_limit = if let Some(tx) = tx.as_unsigned_mut() { + match tx.gas { + // If tx.gas is already set that means it was specified in script + Some(gas) => { + println!("Gas limit was set in script to {gas}"); + true + } + // We inflate the gas used by the user specified percentage + None => { + let gas = result.gas_used * self.args.gas_estimate_multiplier / 100; + tx.gas = Some(gas as u128); + false + } } - // We inflate the gas used by the user specified percentage - None => { - let gas = result.gas_used * self.args.gas_estimate_multiplier / 100; - tx.gas = Some(gas as u128); - } - } + } else { + // for pre-signed transactions we can't alter gas limit + true + }; + let tx = TransactionWithMetadata::new( tx, rpc, @@ -271,40 +278,48 @@ impl FilledTransactionsState { let tx_rpc = tx.rpc.clone(); let provider_info = manager.get_or_init_provider(&tx.rpc, self.args.legacy).await?; - // Handles chain specific requirements. - tx.transaction.set_chain_id(provider_info.chain); + if let Some(tx) = tx.transaction.as_unsigned_mut() { + // Handles chain specific requirements for unsigned transactions. + tx.set_chain_id(provider_info.chain); + } if !self.args.skip_simulation { let tx = tx.tx_mut(); if has_different_gas_calc(provider_info.chain) { - trace!("estimating with different gas calculation"); - let gas = tx.gas.expect("gas is set by simulation."); - - // We are trying to show the user an estimation of the total gas usage. - // - // However, some transactions might depend on previous ones. For - // example, tx1 might deploy a contract that tx2 uses. That - // will result in the following `estimate_gas` call to fail, - // since tx1 hasn't been broadcasted yet. - // - // Not exiting here will not be a problem when actually broadcasting, because - // for chains where `has_different_gas_calc` returns true, - // we await each transaction before broadcasting the next - // one. - if let Err(err) = - estimate_gas(tx, &provider_info.provider, self.args.gas_estimate_multiplier) - .await - { - trace!("gas estimation failed: {err}"); - - // Restore gas value, since `estimate_gas` will remove it. - tx.set_gas_limit(gas); + // only estimate gas for unsigned transactions + if let Some(tx) = tx.as_unsigned_mut() { + trace!("estimating with different gas calculation"); + let gas = tx.gas.expect("gas is set by simulation."); + + // We are trying to show the user an estimation of the total gas usage. + // + // However, some transactions might depend on previous ones. For + // example, tx1 might deploy a contract that tx2 uses. That + // will result in the following `estimate_gas` call to fail, + // since tx1 hasn't been broadcasted yet. + // + // Not exiting here will not be a problem when actually broadcasting, + // because for chains where `has_different_gas_calc` + // returns true, we await each transaction before + // broadcasting the next one. + if let Err(err) = estimate_gas( + tx, + &provider_info.provider, + self.args.gas_estimate_multiplier, + ) + .await + { + trace!("gas estimation failed: {err}"); + + // Restore gas value, since `estimate_gas` will remove it. + tx.set_gas_limit(gas); + } } } let total_gas = total_gas_per_rpc.entry(tx_rpc.clone()).or_insert(0); - *total_gas += tx.gas.expect("gas is set"); + *total_gas += tx.gas().expect("gas is set"); } new_sequence.push_back(tx); diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index de91ab3e3b0f2..0ef2559d94a9b 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,10 +1,8 @@ use super::ScriptResult; use alloy_dyn_abi::JsonAbiExt; use alloy_primitives::{hex, Address, Bytes, TxKind, B256}; -use alloy_rpc_types::request::TransactionRequest; -use alloy_serde::WithOtherFields; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{fmt::format_token_raw, ContractData, SELECTOR_LEN}; +use foundry_common::{fmt::format_token_raw, ContractData, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; use itertools::Itertools; use revm_inspectors::tracing::types::CallKind; @@ -20,7 +18,7 @@ pub struct AdditionalContract { pub init_code: Bytes, } -#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct TransactionWithMetadata { pub hash: Option, @@ -36,7 +34,7 @@ pub struct TransactionWithMetadata { pub arguments: Option>, #[serde(skip)] pub rpc: String, - pub transaction: WithOtherFields, + pub transaction: TransactionMaybeSigned, pub additional_contracts: Vec, pub is_fixed_gas_limit: bool, } @@ -54,12 +52,23 @@ fn default_vec_of_strings() -> Option> { } impl TransactionWithMetadata { - pub fn from_tx_request(transaction: TransactionRequest) -> Self { - Self { transaction: WithOtherFields::new(transaction), ..Default::default() } + pub fn from_tx_request(transaction: TransactionMaybeSigned) -> Self { + Self { + transaction, + hash: Default::default(), + opcode: Default::default(), + contract_name: Default::default(), + contract_address: Default::default(), + function: Default::default(), + arguments: Default::default(), + is_fixed_gas_limit: Default::default(), + additional_contracts: Default::default(), + rpc: Default::default(), + } } pub fn new( - transaction: TransactionRequest, + transaction: TransactionMaybeSigned, rpc: String, result: &ScriptResult, local_contracts: &BTreeMap, @@ -72,7 +81,7 @@ impl TransactionWithMetadata { metadata.is_fixed_gas_limit = is_fixed_gas_limit; // Specify if any contract was directly created with this transaction - if let Some(TxKind::Call(to)) = metadata.transaction.to { + if let Some(TxKind::Call(to)) = metadata.transaction.to() { if to == DEFAULT_CREATE2_DEPLOYER { metadata.set_create( true, @@ -130,7 +139,7 @@ impl TransactionWithMetadata { self.contract_name = info.map(|info| info.name.clone()); self.contract_address = Some(address); - let Some(data) = self.transaction.input.input() else { return Ok(()) }; + let Some(data) = self.transaction.input() else { return Ok(()) }; let Some(info) = info else { return Ok(()) }; let Some(bytecode) = info.bytecode() else { return Ok(()) }; @@ -177,7 +186,7 @@ impl TransactionWithMetadata { self.opcode = CallKind::Call; self.contract_address = Some(target); - let Some(data) = self.transaction.input.input() else { return Ok(()) }; + let Some(data) = self.transaction.input() else { return Ok(()) }; if data.len() < SELECTOR_LEN { return Ok(()); } @@ -208,11 +217,11 @@ impl TransactionWithMetadata { Ok(()) } - pub fn tx(&self) -> &WithOtherFields { + pub fn tx(&self) -> &TransactionMaybeSigned { &self.transaction } - pub fn tx_mut(&mut self) -> &mut WithOtherFields { + pub fn tx_mut(&mut self) -> &mut TransactionMaybeSigned { &mut self.transaction } diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index ca4226be31f48..9ca0368d33c07 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -170,4 +170,4 @@ update of the files. [`cheatcodes/spec/src/vm.rs`]: ../../crates/cheatcodes/spec/src/vm.rs [`cheatcodes`]: ../../crates/cheatcodes/ [`spec::Cheatcodes::new`]: ../../crates/cheatcodes/spec/src/lib.rs#L74 -[`testdata/cheats/`]: ../../testdata/cheats/ +[`testdata/cheats/`]: ../../testdata/default/cheats/ diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 9c008c4254f4a..dfe466d3aadaf 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -148,6 +148,7 @@ interface Vm { function blobhashes(bytes32[] calldata hashes) external; function breakpoint(string calldata char) external; function breakpoint(string calldata char, bool value) external; + function broadcastRawTransaction(bytes calldata data) external; function broadcast() external; function broadcast(address signer) external; function broadcast(uint256 privateKey) external; diff --git a/testdata/default/cheats/BroadcastRawTransaction.t.sol b/testdata/default/cheats/BroadcastRawTransaction.t.sol new file mode 100644 index 0000000000000..7425e9d3773a5 --- /dev/null +++ b/testdata/default/cheats/BroadcastRawTransaction.t.sol @@ -0,0 +1,346 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract BroadcastRawTransactionTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_revert_not_a_tx() public { + vm.expectRevert("broadcastRawTransaction: error decoding transaction (unexpected string)"); + vm.broadcastRawTransaction(hex"0102"); + } + + function test_revert_missing_signature() public { + vm.expectRevert("broadcastRawTransaction: error decoding transaction (input too short)"); + vm.broadcastRawTransaction(hex"dd806483030d40940993863c19b0defb183ca2b502db7d1b331ded757b80"); + } + + function test_revert_wrong_chainid() public { + vm.expectRevert("transaction validation error: invalid chain ID"); + vm.broadcastRawTransaction( + hex"f860806483030d40946fd0a0cff9a87adf51695b40b4fa267855a8f4c6118025a03ebeabbcfe43c2c982e99b376b5fb6e765059d7f215533c8751218cac99bbd80a00a56cf5c382442466770a756e81272d06005c9e90fb8dbc5b53af499d5aca856" + ); + } + + function test_execute_signed_tx() public { + vm.fee(1); + vm.chainId(1); + + address from = 0x5316812db67073C4d4af8BB3000C5B86c2877e94; + address to = 0x6Fd0A0CFF9A87aDF51695b40b4fA267855a8F4c6; + + uint256 balance = 1 ether; + uint256 amountSent = 17; + + vm.deal(address(from), balance); + assertEq(address(from).balance, balance); + assertEq(address(to).balance, 0); + + /* + Signed transaction: + TransactionRequest { from: Some(0x5316812db67073c4d4af8bb3000c5b86c2877e94), to: Some(Address(0x6fd0a0cff9a87adf51695b40b4fa267855a8f4c6)), gas: Some(200000), gas_price: Some(100), value: Some(17), data: None, nonce: Some(0), chain_id: Some(1) } + */ + vm.broadcastRawTransaction( + hex"f860806483030d40946fd0a0cff9a87adf51695b40b4fa267855a8f4c6118025a03ebeabbcfe43c2c982e99b376b5fb6e765059d7f215533c8751218cac99bbd80a00a56cf5c382442466770a756e81272d06005c9e90fb8dbc5b53af499d5aca856" + ); + + uint256 gasPrice = 100; + assertEq(address(from).balance, balance - (gasPrice * 21_000) - amountSent); + assertEq(address(to).balance, amountSent); + } + + function test_execute_signed_tx2() public { + vm.fee(1); + vm.chainId(1); + + address from = 0x5316812db67073C4d4af8BB3000C5B86c2877e94; + address to = 0x6Fd0A0CFF9A87aDF51695b40b4fA267855a8F4c6; + address random = address(uint160(uint256(keccak256(abi.encodePacked("random"))))); + + uint256 balance = 1 ether; + uint256 amountSent = 17; + + vm.deal(address(from), balance); + assertEq(address(from).balance, balance); + assertEq(address(to).balance, 0); + + /* + Signed transaction: + TransactionRequest { from: Some(0x5316812db67073c4d4af8bb3000c5b86c2877e94), to: Some(Address(0x6fd0a0cff9a87adf51695b40b4fa267855a8f4c6)), gas: Some(200000), gas_price: Some(100), value: Some(17), data: None, nonce: Some(0), chain_id: Some(1) } + */ + vm.broadcastRawTransaction( + hex"f860806483030d40946fd0a0cff9a87adf51695b40b4fa267855a8f4c6118025a03ebeabbcfe43c2c982e99b376b5fb6e765059d7f215533c8751218cac99bbd80a00a56cf5c382442466770a756e81272d06005c9e90fb8dbc5b53af499d5aca856" + ); + + uint256 gasPrice = 100; + assertEq(address(from).balance, balance - (gasPrice * 21_000) - amountSent); + assertEq(address(to).balance, amountSent); + assertEq(address(random).balance, 0); + + uint256 value = 5; + + vm.prank(to); + (bool success,) = random.call{value: value}(""); + require(success); + assertEq(address(to).balance, amountSent - value); + assertEq(address(random).balance, value); + } + + // this test is to make sure that the journaledstate is correctly handled + // i ran into an issue where the test would fail after running `broadcastRawTransaction` + // because there was an issue in the journaledstate + function test_execute_signed_tx_with_revert() public { + vm.fee(1); + vm.chainId(1); + + address from = 0x5316812db67073C4d4af8BB3000C5B86c2877e94; + address to = 0x6Fd0A0CFF9A87aDF51695b40b4fA267855a8F4c6; + + uint256 balance = 1 ether; + uint256 amountSent = 17; + + vm.deal(address(from), balance); + assertEq(address(from).balance, balance); + assertEq(address(to).balance, 0); + + /* + Signed transaction: + TransactionRequest { from: Some(0x5316812db67073c4d4af8bb3000c5b86c2877e94), to: Some(Address(0x6fd0a0cff9a87adf51695b40b4fa267855a8f4c6)), gas: Some(200000), gas_price: Some(100), value: Some(17), data: None, nonce: Some(0), chain_id: Some(1) } + */ + vm.broadcastRawTransaction( + hex"f860806483030d40946fd0a0cff9a87adf51695b40b4fa267855a8f4c6118025a03ebeabbcfe43c2c982e99b376b5fb6e765059d7f215533c8751218cac99bbd80a00a56cf5c382442466770a756e81272d06005c9e90fb8dbc5b53af499d5aca856" + ); + + uint256 gasPrice = 100; + assertEq(address(from).balance, balance - (gasPrice * 21_000) - amountSent); + assertEq(address(to).balance, amountSent); + + vm.expectRevert(); + assert(3 == 4); + } + + function test_execute_multiple_signed_tx() public { + vm.fee(1); + vm.chainId(1); + + address alice = 0x7ED31830602f9F7419307235c0610Fb262AA0375; + address bob = 0x70CF146aB98ffD5dE24e75dd7423F16181Da8E13; + address charlie = 0xae0900Cf97f8C233c64F7089cEC7d5457215BB8d; + + // this is the runtime code of "MyERC20" (see below) + // this is equivalent to: + // type(MyERC20).runtimeCode + bytes memory code = + hex"608060405234801561001057600080fd5b50600436106100625760003560e01c8063095ea7b31461006757806323b872dd1461008f57806370a08231146100a257806394bf804d146100d9578063a9059cbb146100ee578063dd62ed3e14610101575b600080fd5b61007a61007536600461051d565b61013a565b60405190151581526020015b60405180910390f35b61007a61009d366004610547565b610152565b6100cb6100b0366004610583565b6001600160a01b031660009081526020819052604090205490565b604051908152602001610086565b6100ec6100e73660046105a5565b610176565b005b61007a6100fc36600461051d565b610184565b6100cb61010f3660046105d1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600033610148818585610192565b5060019392505050565b600033610160858285610286565b61016b858585610318565b506001949350505050565b6101808183610489565b5050565b600033610148818585610318565b6001600160a01b0383166101f95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084015b60405180910390fd5b6001600160a01b03821661025a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016101f0565b6001600160a01b0392831660009081526001602090815260408083209490951682529290925291902055565b6001600160a01b03838116600090815260016020908152604080832093861683529290522054600019811461031257818110156103055760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016101f0565b6103128484848403610192565b50505050565b6001600160a01b03831661037c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016101f0565b6001600160a01b0382166103de5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016101f0565b6001600160a01b038316600090815260208190526040902054818110156104565760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016101f0565b6001600160a01b039384166000908152602081905260408082209284900390925592909316825291902080549091019055565b6001600160a01b0382166104df5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016101f0565b6001600160a01b03909116600090815260208190526040902080549091019055565b80356001600160a01b038116811461051857600080fd5b919050565b6000806040838503121561053057600080fd5b61053983610501565b946020939093013593505050565b60008060006060848603121561055c57600080fd5b61056584610501565b925061057360208501610501565b9150604084013590509250925092565b60006020828403121561059557600080fd5b61059e82610501565b9392505050565b600080604083850312156105b857600080fd5b823591506105c860208401610501565b90509250929050565b600080604083850312156105e457600080fd5b6105ed83610501565b91506105c86020840161050156fea2646970667358221220e1fee5cd1c5bbf066a9ce9228e1baf7e7fcb77b5050506c7d614aaf8608b42e364736f6c63430008110033"; + + // this is equivalent to: + // MyERC20 token = new MyERC20{ salt: bytes32(uint256(1)) }(); + // address: 0x5bf11839f61ef5cceeaf1f4153e44df5d02825f7 + MyERC20 token = MyERC20(address(uint160(uint256(keccak256(abi.encodePacked("mytoken")))))); + vm.etch(address(token), code); + + token.mint(100, alice); + + assertEq(token.balanceOf(alice), 100); + assertEq(token.balanceOf(bob), 0); + assertEq(token.balanceOf(charlie), 0); + + vm.deal(alice, 10 ether); + + /* + Signed transaction: + { + from: '0x7ED31830602f9F7419307235c0610Fb262AA0375', + to: '0x5bF11839F61EF5ccEEaf1F4153e44df5D02825f7', + value: 0, + data: '0x095ea7b300000000000000000000000070cf146ab98ffd5de24e75dd7423f16181da8e130000000000000000000000000000000000000000000000000000000000000032', + nonce: 0, + gasPrice: 100, + gasLimit: 200000, + chainId: 1 + } + */ + // this would be equivalent to using those cheatcodes: + // vm.prank(alice); + // token.approve(bob, 50); + vm.broadcastRawTransaction( + hex"f8a5806483030d40945bf11839f61ef5cceeaf1f4153e44df5d02825f780b844095ea7b300000000000000000000000070cf146ab98ffd5de24e75dd7423f16181da8e13000000000000000000000000000000000000000000000000000000000000003225a0e25b9ef561d9a413b21755cc0e4bb6e80f2a88a8a52305690956130d612074dfa07bfd418bc2ad3c3f435fa531cdcdc64887f64ed3fb0d347d6b0086e320ad4eb1" + ); + + assertEq(token.allowance(alice, bob), 50); + + vm.deal(bob, 1 ether); + vm.prank(bob); + token.transferFrom(alice, charlie, 20); + + assertEq(token.balanceOf(bob), 0); + assertEq(token.balanceOf(charlie), 20); + + vm.deal(charlie, 1 ether); + + /* + Signed transaction: + { + from: '0xae0900Cf97f8C233c64F7089cEC7d5457215BB8d', + to: '0x5bF11839F61EF5ccEEaf1F4153e44df5D02825f7', + value: 0, + data: '0xa9059cbb00000000000000000000000070cf146ab98ffd5de24e75dd7423f16181da8e130000000000000000000000000000000000000000000000000000000000000005', + nonce: 0, + gasPrice: 100, + gasLimit: 200000, + chainId: 1 + } + */ + // this would be equivalent to using those cheatcodes: + // vm.prank(charlie); + // token.transfer(bob, 5); + vm.broadcastRawTransaction( + hex"f8a5806483030d40945bf11839f61ef5cceeaf1f4153e44df5d02825f780b844a9059cbb00000000000000000000000070cf146ab98ffd5de24e75dd7423f16181da8e13000000000000000000000000000000000000000000000000000000000000000525a0941562f519e33dfe5b44ebc2b799686cebeaeacd617dd89e393620b380797da2a0447dfd38d9444ccd571b000482c81674733761753430c81ee6669e9542c266a1" + ); + + assertEq(token.balanceOf(alice), 80); + assertEq(token.balanceOf(bob), 5); + assertEq(token.balanceOf(charlie), 15); + } +} + +contract MyERC20 { + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + function mint(uint256 amount, address to) public { + _mint(to, amount); + } + + function balanceOf(address account) public view returns (uint256) { + return _balances[account]; + } + + function transfer(address to, uint256 amount) public returns (bool) { + address owner = msg.sender; + _transfer(owner, to, amount); + return true; + } + + function allowance(address owner, address spender) public view returns (uint256) { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public returns (bool) { + address owner = msg.sender; + _approve(owner, spender, amount); + return true; + } + + function transferFrom(address from, address to, uint256 amount) public returns (bool) { + address spender = msg.sender; + _spendAllowance(from, spender, amount); + _transfer(from, to, amount); + return true; + } + + function _transfer(address from, address to, uint256 amount) internal { + require(from != address(0), "ERC20: transfer from the zero address"); + require(to != address(0), "ERC20: transfer to the zero address"); + + uint256 fromBalance = _balances[from]; + require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[from] = fromBalance - amount; + _balances[to] += amount; + } + } + + function _mint(address account, uint256 amount) internal { + require(account != address(0), "ERC20: mint to the zero address"); + unchecked { + _balances[account] += amount; + } + } + + function _approve(address owner, address spender, uint256 amount) internal { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + _allowances[owner][spender] = amount; + } + + function _spendAllowance(address owner, address spender, uint256 amount) internal { + uint256 currentAllowance = allowance(owner, spender); + if (currentAllowance != type(uint256).max) { + require(currentAllowance >= amount, "ERC20: insufficient allowance"); + unchecked { + _approve(owner, spender, currentAllowance - amount); + } + } + } +} + +contract ScriptBroadcastRawTransactionBroadcast is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function runSignedTxBroadcast() public { + uint256 pk_to = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80; + vm.startBroadcast(pk_to); + + address from = 0x73E1A965542AFA4B412467761b1CED8A764E1D3B; + address to = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + address random = address(uint160(uint256(keccak256(abi.encodePacked("random"))))); + + assert(address(from).balance == 1 ether); + assert(address(to).balance == 1 ether); + assert(address(random).balance == 0); + + /* + TransactionRequest { + from: Some( + 0x73e1a965542afa4b412467761b1ced8a764e1d3b, + ), + to: Some( + Address( + 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266, + ), + ), + gas: Some( + 200000, + ), + gas_price: Some( + 10000000000, + ), + value: Some( + 1234, + ), + data: None, + nonce: Some( + 0, + ), + chain_id: Some( + 31337, + ), + } + */ + vm.broadcastRawTransaction( + hex"f869808502540be40083030d4094f39fd6e51aad88f6f4ce6ab8827279cfffb922668204d28082f4f6a061ce3c0f4280cb79c1eb0060a9a491cca1ba48ed32f141e3421ccb60c9dbe444a07fcd35cbec5f81427ac20f60484f4da9d00f59652f5053cd13ee90b992e94ab3" + ); + + uint256 value = 34; + (bool success,) = random.call{value: value}(""); + require(success); + + vm.stopBroadcast(); + + uint256 gasPrice = 10 * 1e9; + assert(address(from).balance == 1 ether - (gasPrice * 21_000) - 1234); + assert(address(to).balance == 1 ether + 1234 - value); + assert(address(random).balance == value); + } + + function runDeployCreate2Deployer() public { + vm.startBroadcast(); + vm.broadcastRawTransaction( + hex"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222" + ); + vm.stopBroadcast(); + } +} From cc88da946ddd2aa04ce6eb902b5cec1fb0401edd Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:53:11 +0200 Subject: [PATCH 1289/1963] ci: fix conditional release features (#8529) --- .github/workflows/release.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c993c0d8dab20..35ca11d93490e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -133,18 +133,16 @@ jobs: run: | set -eo pipefail target="${{ matrix.target }}" - flags=() + flags=(--release --bins --no-default-features --features rustls,aws-kms) # `jemalloc` and `keccak-asm` are not supported on MSVC or aarch64 Linux. if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then - flags+=(--features asm-keccak,jemalloc,cast/aws-kms,forge/aws-kms) - else - flags+=(--features cast/aws-kms,forge/aws-kms) + flags+=(--features asm-keccak,jemalloc) fi [[ "$target" == *windows* ]] && exe=".exe" - cargo build --release --bins --target "$target" "${flags[@]}" + cargo build --target "$target" "${flags[@]}" bins=(anvil cast chisel forge) for name in "${bins[@]}"; do From 4a41367398ddc35faf705f5d93e7e1a4eae3884d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:26:21 +0300 Subject: [PATCH 1290/1963] feat(test): allow custom txes before unit and fuzz test (#8497) * feat(test): allow performing txes before unit test * Changes after review: - do not unwrap func - check if `beforeTestSelectors` exists - move logic in prepare_unit_test fn - apply same logic to fuzz tests * Review: Before test is not a test kind * Changes after review: beforeTestSetup new fn signature * Remove obsolete struct from test * Update crates/forge/src/runner.rs Co-authored-by: Matthias Seitz * Changes after review: avoid executor clone * Fix Cow::Borrowed usage --------- Co-authored-by: Matthias Seitz --- crates/common/src/traits.rs | 5 + crates/evm/evm/src/executors/invariant/mod.rs | 53 +++++----- crates/evm/evm/src/executors/mod.rs | 13 +++ crates/forge/src/result.rs | 12 ++- crates/forge/src/runner.rs | 98 ++++++++++++++++--- crates/forge/tests/it/repros.rs | 3 + testdata/default/repros/Issue1543.t.sol | 91 +++++++++++++++++ 7 files changed, 232 insertions(+), 43 deletions(-) create mode 100644 testdata/default/repros/Issue1543.t.sol diff --git a/crates/common/src/traits.rs b/crates/common/src/traits.rs index 606b4861af92a..f5f3ea14ce460 100644 --- a/crates/common/src/traits.rs +++ b/crates/common/src/traits.rs @@ -44,6 +44,11 @@ pub trait TestFunctionExt { matches!(self.test_function_kind(), TestFunctionKind::UnitTest { .. }) } + /// Returns `true` if this function is a `beforeTestSetup` function. + fn is_before_test_setup(&self) -> bool { + self.tfe_as_str().eq_ignore_ascii_case("beforetestsetup") + } + /// Returns `true` if this function is a fuzz test. fn is_fuzz_test(&self) -> bool { self.test_function_kind().is_fuzz_test() diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 7dcdc15680e1a..91143f4b232e3 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -532,6 +532,7 @@ impl<'a> InvariantExecutor<'a> { /// targetArtifactSelectors > excludeArtifacts > targetArtifacts pub fn select_contract_artifacts(&mut self, invariant_address: Address) -> Result<()> { let result = self + .executor .call_sol_default(invariant_address, &IInvariantTest::targetArtifactSelectorsCall {}); // Insert them into the executor `targeted_abi`. @@ -542,10 +543,12 @@ impl<'a> InvariantExecutor<'a> { self.artifact_filters.targeted.entry(identifier).or_default().extend(selectors); } - let selected = - self.call_sol_default(invariant_address, &IInvariantTest::targetArtifactsCall {}); - let excluded = - self.call_sol_default(invariant_address, &IInvariantTest::excludeArtifactsCall {}); + let selected = self + .executor + .call_sol_default(invariant_address, &IInvariantTest::targetArtifactsCall {}); + let excluded = self + .executor + .call_sol_default(invariant_address, &IInvariantTest::excludeArtifactsCall {}); // Insert `excludeArtifacts` into the executor `excluded_abi`. for contract in excluded.excludedArtifacts { @@ -620,10 +623,14 @@ impl<'a> InvariantExecutor<'a> { &self, to: Address, ) -> Result<(SenderFilters, FuzzRunIdentifiedContracts)> { - let targeted_senders = - self.call_sol_default(to, &IInvariantTest::targetSendersCall {}).targetedSenders; - let mut excluded_senders = - self.call_sol_default(to, &IInvariantTest::excludeSendersCall {}).excludedSenders; + let targeted_senders = self + .executor + .call_sol_default(to, &IInvariantTest::targetSendersCall {}) + .targetedSenders; + let mut excluded_senders = self + .executor + .call_sol_default(to, &IInvariantTest::excludeSendersCall {}) + .excludedSenders; // Extend with default excluded addresses - https://github.com/foundry-rs/foundry/issues/4163 excluded_senders.extend([ CHEATCODE_ADDRESS, @@ -634,10 +641,14 @@ impl<'a> InvariantExecutor<'a> { excluded_senders.extend(PRECOMPILES); let sender_filters = SenderFilters::new(targeted_senders, excluded_senders); - let selected = - self.call_sol_default(to, &IInvariantTest::targetContractsCall {}).targetedContracts; - let excluded = - self.call_sol_default(to, &IInvariantTest::excludeContractsCall {}).excludedContracts; + let selected = self + .executor + .call_sol_default(to, &IInvariantTest::targetContractsCall {}) + .targetedContracts; + let excluded = self + .executor + .call_sol_default(to, &IInvariantTest::excludeContractsCall {}) + .excludedContracts; let contracts = self .setup_contracts @@ -678,6 +689,7 @@ impl<'a> InvariantExecutor<'a> { targeted_contracts: &mut TargetedContracts, ) -> Result<()> { let interfaces = self + .executor .call_sol_default(invariant_address, &IInvariantTest::targetInterfacesCall {}) .targetedInterfaces; @@ -735,13 +747,15 @@ impl<'a> InvariantExecutor<'a> { } // Collect contract functions marked as target for fuzzing campaign. - let selectors = self.call_sol_default(address, &IInvariantTest::targetSelectorsCall {}); + let selectors = + self.executor.call_sol_default(address, &IInvariantTest::targetSelectorsCall {}); for IInvariantTest::FuzzSelector { addr, selectors } in selectors.targetedSelectors { self.add_address_with_functions(addr, &selectors, false, targeted_contracts)?; } // Collect contract functions excluded from fuzzing campaign. - let selectors = self.call_sol_default(address, &IInvariantTest::excludeSelectorsCall {}); + let selectors = + self.executor.call_sol_default(address, &IInvariantTest::excludeSelectorsCall {}); for IInvariantTest::FuzzSelector { addr, selectors } in selectors.excludedSelectors { self.add_address_with_functions(addr, &selectors, true, targeted_contracts)?; } @@ -773,17 +787,6 @@ impl<'a> InvariantExecutor<'a> { contract.add_selectors(selectors.iter().copied(), should_exclude)?; Ok(()) } - - fn call_sol_default(&self, to: Address, args: &C) -> C::Return - where - C::Return: Default, - { - self.executor - .call_sol(CALLER, to, args, U256::ZERO, None) - .map(|c| c.decoded_result) - .inspect_err(|e| warn!(target: "forge::test", "failed calling {:?}: {e}", C::SIGNATURE)) - .unwrap_or_default() - } } /// Collects data from call for fuzzing. However, it first verifies that the sender is not an EOA diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 66010a33cfc75..2f08b2f42efdd 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -50,6 +50,9 @@ sol! { interface ITest { function setUp() external; function failed() external view returns (bool failed); + + #[derive(Default)] + function beforeTestSetup(bytes4 testSelector) public view returns (bytes[] memory beforeTestCalldata); } } @@ -602,6 +605,16 @@ impl Executor { EnvWithHandlerCfg::new_with_spec_id(Box::new(env), self.spec_id()) } + + pub fn call_sol_default(&self, to: Address, args: &C) -> C::Return + where + C::Return: Default, + { + self.call_sol(CALLER, to, args, U256::ZERO, None) + .map(|c| c.decoded_result) + .inspect_err(|e| warn!(target: "forge::test", "failed calling {:?}: {e}", C::SIGNATURE)) + .unwrap_or_default() + } } /// Represents the context after an execution error occurred. diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 8352432e47696..e7953575f3b50 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -449,9 +449,9 @@ impl TestResult { } /// Returns the failed result with reason for single test. - pub fn single_fail(mut self, err: EvmError) -> Self { + pub fn single_fail(mut self, reason: Option) -> Self { self.status = TestStatus::Failure; - self.reason = Some(err.to_string()); + self.reason = reason; self } @@ -579,6 +579,14 @@ impl TestResult { format!("{self} {name} {}", self.kind.report()) } + /// Function to merge logs, addresses, traces and coverage from a call result into test result. + pub fn merge_call_result(&mut self, call_result: &RawCallResult) { + self.logs.extend(call_result.logs.clone()); + self.labeled_addresses.extend(call_result.labels.clone()); + self.traces.extend(call_result.traces.clone().map(|traces| (TraceKind::Execution, traces))); + self.merge_coverages(call_result.coverage.clone()); + } + /// Function to merge given coverage in current test result coverage. pub fn merge_coverages(&mut self, other_coverage: Option) { let old_coverage = std::mem::take(&mut self.coverage); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 2198921be605a..6ed06e525e399 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -24,7 +24,7 @@ use foundry_evm::{ invariant::{ check_sequence, replay_error, replay_run, InvariantExecutor, InvariantFuzzError, }, - CallResult, EvmError, ExecutionErr, Executor, RawCallResult, + CallResult, EvmError, ExecutionErr, Executor, ITest, RawCallResult, }, fuzz::{ fixture_name, @@ -36,6 +36,7 @@ use foundry_evm::{ use proptest::test_runner::TestRunner; use rayon::prelude::*; use std::{ + borrow::Cow, cmp::min, collections::{BTreeMap, HashMap}, time::Instant, @@ -270,6 +271,7 @@ impl<'a> ContractRunner<'a> { )); } } + // There are multiple setUp function, so we return a single test result for `setUp` if setup_fns.len() > 1 { return SuiteResult::new( @@ -412,21 +414,26 @@ impl<'a> ContractRunner<'a> { /// Runs a single unit test. /// - /// Calls the given functions and returns the `TestResult`. + /// Applies before test txes (if any), runs current test and returns the `TestResult`. /// - /// State modifications are not committed to the evm database but discarded after the call, - /// similar to `eth_call`. + /// Before test txes are applied in order and state modifications committed to the EVM database + /// (therefore the unit test call will be made on modified state). + /// State modifications of before test txes and unit test function call are discarded after + /// test ends, similar to `eth_call`. pub fn run_unit_test( &self, func: &Function, should_fail: bool, setup: TestSetup, ) -> TestResult { - let address = setup.address; - let test_result = TestResult::new(setup); + // Prepare unit test execution. + let (executor, test_result, address) = match self.prepare_test(func, setup) { + Ok(res) => res, + Err(res) => return res, + }; - // Run unit test - let (mut raw_call_result, reason) = match self.executor.call( + // Run current unit test. + let (mut raw_call_result, reason) = match executor.call( self.sender, address, func, @@ -437,11 +444,10 @@ impl<'a> ContractRunner<'a> { Ok(res) => (res.raw, None), Err(EvmError::Execution(err)) => (err.raw, Some(err.reason)), Err(EvmError::SkipError) => return test_result.single_skip(), - Err(err) => return test_result.single_fail(err), + Err(err) => return test_result.single_fail(Some(err.to_string())), }; - let success = - self.executor.is_raw_call_mut_success(address, &mut raw_call_result, should_fail); + let success = executor.is_raw_call_mut_success(address, &mut raw_call_result, should_fail); test_result.single_result(success, reason, raw_call_result) } @@ -618,6 +624,15 @@ impl<'a> ContractRunner<'a> { ) } + /// Runs a fuzzed test. + /// + /// Applies the before test txes (if any), fuzzes the current function and returns the + /// `TestResult`. + /// + /// Before test txes are applied in order and state modifications committed to the EVM database + /// (therefore the fuzz test will use the modified state). + /// State modifications of before test txes and fuzz test are discarded after test ends, + /// similar to `eth_call`. pub fn run_fuzz_test( &self, func: &Function, @@ -626,14 +641,18 @@ impl<'a> ContractRunner<'a> { setup: TestSetup, fuzz_config: FuzzConfig, ) -> TestResult { - let address = setup.address; + let progress = start_fuzz_progress(self.progress, self.name, &func.name, fuzz_config.runs); + + // Prepare fuzz test execution. let fuzz_fixtures = setup.fuzz_fixtures.clone(); - let test_result = TestResult::new(setup); + let (executor, test_result, address) = match self.prepare_test(func, setup) { + Ok(res) => res, + Err(res) => return res, + }; - // Run fuzz test - let progress = start_fuzz_progress(self.progress, self.name, &func.name, fuzz_config.runs); + // Run fuzz test. let fuzzed_executor = - FuzzedExecutor::new(self.executor.clone(), runner, self.sender, fuzz_config); + FuzzedExecutor::new(executor.into_owned(), runner, self.sender, fuzz_config); let result = fuzzed_executor.fuzz( func, &fuzz_fixtures, @@ -650,4 +669,51 @@ impl<'a> ContractRunner<'a> { } test_result.fuzz_result(result) } + + /// Prepares single unit test and fuzz test execution: + /// - set up the test result and executor + /// - check if before test txes are configured and apply them in order + /// + /// Before test txes are arrays of arbitrary calldata obtained by calling the `beforeTest` + /// function with test selector as a parameter. + /// + /// Unit tests within same contract (or even current test) are valid options for before test tx + /// configuration. Test execution stops if any of before test txes fails. + fn prepare_test( + &self, + func: &Function, + setup: TestSetup, + ) -> Result<(Cow<'_, Executor>, TestResult, Address), TestResult> { + let address = setup.address; + let mut executor = Cow::Borrowed(&self.executor); + let mut test_result = TestResult::new(setup); + + // Apply before test configured functions (if any). + if self.contract.abi.functions().filter(|func| func.name.is_before_test_setup()).count() == + 1 + { + for calldata in executor + .call_sol_default( + address, + &ITest::beforeTestSetupCall { testSelector: func.selector() }, + ) + .beforeTestCalldata + { + // Apply before test configured calldata. + match executor.to_mut().transact_raw(self.sender, address, calldata, U256::ZERO) { + Ok(call_result) => { + // Merge tx result traces in unit test result. + test_result.merge_call_result(&call_result); + + // To continue unit test execution the call should not revert. + if call_result.reverted { + return Err(test_result.single_fail(None)) + } + } + Err(_) => return Err(test_result.single_fail(None)), + } + } + } + Ok((executor, test_result, address)) + } } diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 1268300e44273..a74933f6f9a1d 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -364,3 +364,6 @@ test_repro!(8168); // https://github.com/foundry-rs/foundry/issues/8383 test_repro!(8383); + +// https://github.com/foundry-rs/foundry/issues/1543 +test_repro!(1543); diff --git a/testdata/default/repros/Issue1543.t.sol b/testdata/default/repros/Issue1543.t.sol new file mode 100644 index 0000000000000..e8b4806ed1209 --- /dev/null +++ b/testdata/default/repros/Issue1543.t.sol @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; + +contract SelfDestructor { + function kill() external { + selfdestruct(payable(msg.sender)); + } +} + +// https://github.com/foundry-rs/foundry/issues/1543 +contract Issue1543Test is DSTest { + SelfDestructor killer; + uint256 a; + uint256 b; + + function setUp() public { + killer = new SelfDestructor(); + } + + function beforeTestSetup(bytes4 testSelector) public pure returns (bytes[] memory beforeTestCalldata) { + if (testSelector == this.testKill.selector) { + beforeTestCalldata = new bytes[](1); + beforeTestCalldata[0] = abi.encodePacked(this.kill_contract.selector); + } + + if (testSelector == this.testA.selector) { + beforeTestCalldata = new bytes[](3); + beforeTestCalldata[0] = abi.encodePacked(this.testA.selector); + beforeTestCalldata[1] = abi.encodePacked(this.testA.selector); + beforeTestCalldata[2] = abi.encodePacked(this.testA.selector); + } + + if (testSelector == this.testB.selector) { + beforeTestCalldata = new bytes[](1); + beforeTestCalldata[0] = abi.encodePacked(this.setB.selector); + } + + if (testSelector == this.testC.selector) { + beforeTestCalldata = new bytes[](2); + beforeTestCalldata[0] = abi.encodePacked(this.testA.selector); + beforeTestCalldata[1] = abi.encodeWithSignature("setBWithValue(uint256)", 111); + } + } + + function kill_contract() external { + uint256 killer_size = getSize(address(killer)); + require(killer_size == 106); + killer.kill(); + } + + function testKill() public view { + uint256 killer_size = getSize(address(killer)); + require(killer_size == 0); + } + + function getSize(address c) public view returns (uint32) { + uint32 size; + assembly { + size := extcodesize(c) + } + return size; + } + + function testA() public { + require(a <= 3); + a += 1; + } + + function testSimpleA() public view { + require(a == 0); + } + + function setB() public { + b = 100; + } + + function testB() public { + require(b == 100); + } + + function setBWithValue(uint256 value) public { + b = value; + } + + function testC(uint256 h) public { + assertEq(a, 1); + assertEq(b, 111); + } +} From f7f1240b971887ff5958bcde2961b99311896d28 Mon Sep 17 00:00:00 2001 From: Paul Razvan Berg Date: Fri, 26 Jul 2024 17:24:23 +0300 Subject: [PATCH 1291/1963] docs: document unit for --with-gas-price (#8370) * docs: document unit for --with-gas-price * chore: apply same doc style to clarify string with denoms can be used * Apply suggestions from code review --------- Co-authored-by: Enrique Ortiz Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cli/src/opts/transaction.rs | 5 ++++- crates/script/src/lib.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index d424626c4df92..5cf126685db15 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -10,7 +10,10 @@ pub struct TransactionOpts { #[arg(long, env = "ETH_GAS_LIMIT")] pub gas_limit: Option, - /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions. + /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions, either + /// specified in wei, or as a string with a unit type. + /// + /// Examples: 1ether, 10gwei, 0.01ether #[arg( long, env = "ETH_GAS_PRICE", diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 97a33541f3d1d..6ca1d46102e13 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -169,7 +169,10 @@ pub struct ScriptArgs { #[arg(long)] pub json: bool, - /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions. + /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions, either + /// specified in wei, or as a string with a unit type. + /// + /// Examples: 1ether, 10gwei, 0.01ether #[arg( long, env = "ETH_GAS_PRICE", From f5e4ec8ad6c7282f09deb75b94a728336d1dbefe Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:02:52 +0200 Subject: [PATCH 1292/1963] chore: decode only ASCII reverts (#8531) --- crates/cheatcodes/src/test/expect.rs | 11 +++++++---- crates/evm/core/src/decode.rs | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index f2b7cbc065466..4dc53550832c2 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -582,10 +582,13 @@ pub(crate) fn handle_expect_revert( Ok(success_return()) } else { let stringify = |data: &[u8]| { - String::abi_decode(data, false) - .ok() - .or_else(|| std::str::from_utf8(data).ok().map(ToOwned::to_owned)) - .unwrap_or_else(|| hex::encode_prefixed(data)) + if let Ok(s) = String::abi_decode(data, false) { + return s; + } + if data.is_ascii() { + return std::str::from_utf8(data).unwrap().to_owned(); + } + hex::encode_prefixed(data) }; Err(fmt_err!( "Error != expected error: {} != {}", diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 4a2fadb816cc9..0c52ea3c7eeda 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -171,9 +171,9 @@ impl RevertDecoder { return Some(s); } - // UTF-8-encoded string. - if let Ok(s) = std::str::from_utf8(err) { - return Some(s.to_string()); + // ASCII string. + if err.is_ascii() { + return Some(std::str::from_utf8(err).unwrap().to_string()); } // Generic custom error. From 0ade1fd5db835d60d94b9b47a1052a1d6160d6ed Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:05:03 +0200 Subject: [PATCH 1293/1963] test: consolidate RPC URLs, remove flaky ones (#8534) * test: consolidate RPC URLs, remove flaky ones * chore: clippy --- .github/scripts/format.sh | 7 ++ .github/workflows/test.yml | 6 +- crates/forge/tests/it/fork.rs | 4 +- crates/forge/tests/it/test_helpers.rs | 24 +++--- crates/test-utils/src/rpc.rs | 85 +++++++++++++------ testdata/default/cheats/Fork.t.sol | 12 +-- testdata/default/cheats/Fork2.t.sol | 14 +-- testdata/default/cheats/RpcUrls.t.sol | 17 +--- testdata/default/fork/ForkSame_1.t.sol | 2 +- testdata/default/fork/ForkSame_2.t.sol | 2 +- testdata/default/fork/Transact.t.sol | 4 +- .../invariant/common/InvariantRollFork.t.sol | 4 +- testdata/default/repros/Issue2623.t.sol | 2 +- testdata/default/repros/Issue2629.t.sol | 4 +- testdata/default/repros/Issue2723.t.sol | 2 +- testdata/default/repros/Issue2956.t.sol | 4 +- testdata/default/repros/Issue2984.t.sol | 4 +- testdata/default/repros/Issue3077.t.sol | 2 +- testdata/default/repros/Issue3110.t.sol | 2 +- testdata/default/repros/Issue3119.t.sol | 2 +- testdata/default/repros/Issue3192.t.sol | 4 +- testdata/default/repros/Issue3220.t.sol | 4 +- testdata/default/repros/Issue3221.t.sol | 4 +- testdata/default/repros/Issue3223.t.sol | 4 +- testdata/default/repros/Issue3653.t.sol | 2 +- testdata/default/repros/Issue3674.t.sol | 4 +- testdata/default/repros/Issue3703.t.sol | 6 +- testdata/default/repros/Issue4586.t.sol | 2 +- testdata/default/repros/Issue4640.t.sol | 2 +- testdata/default/repros/Issue5739.t.sol | 2 +- testdata/default/repros/Issue5929.t.sol | 2 +- testdata/default/repros/Issue5935.t.sol | 7 +- testdata/default/repros/Issue6032.t.sol | 2 +- testdata/default/repros/Issue6538.t.sol | 2 +- testdata/default/repros/Issue6616.t.sol | 4 +- testdata/default/repros/Issue6759.t.sol | 6 +- testdata/default/repros/Issue7481.t.sol | 2 +- testdata/default/repros/Issue8004.t.sol | 10 +-- testdata/default/repros/Issue8006.t.sol | 2 +- testdata/default/repros/Issue8168.t.sol | 4 +- testdata/default/repros/Issue8287.t.sol | 4 +- 41 files changed, 152 insertions(+), 130 deletions(-) create mode 100755 .github/scripts/format.sh diff --git a/.github/scripts/format.sh b/.github/scripts/format.sh new file mode 100755 index 0000000000000..aefb4c0ea2b47 --- /dev/null +++ b/.github/scripts/format.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -eo pipefail + +# We have to ignore at shell level because testdata/ is not a valid Foundry project, +# so running `forge fmt` with `--root testdata` won't actually check anything +shopt -s extglob +cargo run --bin forge -- fmt "$@" $(find testdata -name '*.sol' ! -name Vm.sol) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c8758b2362a0f..9e6db23aea698 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -86,11 +86,7 @@ jobs: cache-on-failure: true - name: forge fmt shell: bash - # We have to ignore at shell level because testdata/ is not a valid Foundry project, - # so running `forge fmt` with `--root testdata` won't actually check anything - run: | - shopt -s extglob - cargo run --bin forge -- fmt --check $(find testdata -name '*.sol' ! -name Vm.sol) + run: ./.github/scripts/format.sh --check crate-checks: runs-on: ubuntu-latest diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index a6b215624414b..26c45aa184e52 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -110,8 +110,8 @@ async fn test_storage_caching_config() { Filter::new("testStorageCaching", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; - let cache_dir = Config::foundry_block_cache_dir(Chain::mainnet(), 19800000); - assert!(!cache_dir.unwrap().exists()); + let cache_dir = Config::foundry_block_cache_dir(Chain::mainnet(), 19800000).unwrap(); + let _ = fs::remove_file(cache_dir); // no_storage_caching set to false: storage should be cached let mut config = TEST_DATA_DEFAULT.config.clone(); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 75da92141c313..480a924a07fc8 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -1,5 +1,6 @@ //! Test helpers for Forge integration tests. +use alloy_chains::NamedChain; use alloy_primitives::U256; use forge::{ revm::primitives::SpecId, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, @@ -18,7 +19,7 @@ use foundry_evm::{ constants::CALLER, opts::{Env, EvmOpts}, }; -use foundry_test_utils::{fd_lock, init_tracing}; +use foundry_test_utils::{fd_lock, init_tracing, rpc::next_rpc_endpoint}; use once_cell::sync::Lazy; use std::{ env, fmt, @@ -357,18 +358,13 @@ pub fn manifest_root() -> &'static Path { /// the RPC endpoints used during tests pub fn rpc_endpoints() -> RpcEndpoints { RpcEndpoints::new([ - ( - "rpcAlias", - RpcEndpoint::Url( - "https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf".to_string(), - ), - ), - ( - "rpcAliasSepolia", - RpcEndpoint::Url( - "https://eth-sepolia.g.alchemy.com/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf".to_string(), - ), - ), - ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".to_string())), + ("mainnet", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Mainnet))), + ("mainnet2", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Mainnet))), + ("sepolia", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Sepolia))), + ("optimism", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Optimism))), + ("arbitrum", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Arbitrum))), + ("polygon", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Polygon))), + ("avaxTestnet", RpcEndpoint::Url("https://api.avax-test.network/ext/bc/C/rpc".into())), + ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".into())), ]) } diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 8ed6fb8d5eed6..8d4229da79bb8 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -1,5 +1,6 @@ //! RPC API keys utilities. +use foundry_config::NamedChain; use once_cell::sync::Lazy; use rand::seq::SliceRandom; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -18,7 +19,7 @@ static INFURA_KEYS: Lazy> = Lazy::new(|| { }); // List of alchemy keys for mainnet -static ALCHEMY_MAINNET_KEYS: Lazy> = Lazy::new(|| { +static ALCHEMY_KEYS: Lazy> = Lazy::new(|| { let mut keys = vec![ "ib1f4u1ojm-9lJJypwkeZeG-75TJRB7O", "7mTtk6IW4DwroGnKmG_bOWri2hyaGYhX", @@ -44,6 +45,9 @@ static ALCHEMY_MAINNET_KEYS: Lazy> = Lazy::new(|| { "sDNCLu_e99YZRkbWlVHiuM3BQ5uxYCZU", "M6lfpxTBrywHOvKXOS4yb7cTTpa25ZQ9", "UK8U_ogrbYB4lQFTGJHHDrbiS4UPnac6", + "Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", + "UVatYU2Ax0rX6bDiqddeTRDdcCxzdpoE", + "bVjX9v-FpmUhf5R_oHIgwJx2kXvYPRbx", ]; keys.shuffle(&mut rand::thread_rng()); @@ -79,55 +83,43 @@ fn next() -> usize { } fn num_keys() -> usize { - INFURA_KEYS.len() + ALCHEMY_MAINNET_KEYS.len() + INFURA_KEYS.len() + ALCHEMY_KEYS.len() } /// Returns the next _mainnet_ rpc endpoint in inline /// /// This will rotate all available rpc endpoints pub fn next_http_rpc_endpoint() -> String { - next_rpc_endpoint("mainnet") + next_rpc_endpoint(NamedChain::Mainnet) } /// Returns the next _mainnet_ rpc endpoint in inline /// /// This will rotate all available rpc endpoints pub fn next_ws_rpc_endpoint() -> String { - next_ws_endpoint("mainnet") + next_ws_endpoint(NamedChain::Mainnet) } /// Returns the next HTTP RPC endpoint. -pub fn next_rpc_endpoint(network: &str) -> String { - let idx = next() % num_keys(); - if idx < INFURA_KEYS.len() { - format!("https://{network}.infura.io/v3/{}", INFURA_KEYS[idx]) - } else { - let idx = idx - INFURA_KEYS.len(); - format!("https://eth-{network}.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) - } +pub fn next_rpc_endpoint(chain: NamedChain) -> String { + next_url(false, chain) } /// Returns the next WS RPC endpoint. -pub fn next_ws_endpoint(network: &str) -> String { - let idx = next() % num_keys(); - if idx < INFURA_KEYS.len() { - format!("wss://{network}.infura.io/v3/{}", INFURA_KEYS[idx]) - } else { - let idx = idx - INFURA_KEYS.len(); - format!("wss://eth-{network}.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) - } +pub fn next_ws_endpoint(chain: NamedChain) -> String { + next_url(true, chain) } /// Returns endpoint that has access to archive state pub fn next_http_archive_rpc_endpoint() -> String { - let idx = next() % ALCHEMY_MAINNET_KEYS.len(); - format!("https://eth-mainnet.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) + let idx = next() % ALCHEMY_KEYS.len(); + format!("https://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) } /// Returns endpoint that has access to archive state pub fn next_ws_archive_rpc_endpoint() -> String { - let idx = next() % ALCHEMY_MAINNET_KEYS.len(); - format!("wss://eth-mainnet.alchemyapi.io/v2/{}", ALCHEMY_MAINNET_KEYS[idx]) + let idx = next() % ALCHEMY_KEYS.len(); + format!("wss://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) } /// Returns the next etherscan api key @@ -136,6 +128,51 @@ pub fn next_etherscan_api_key() -> String { ETHERSCAN_MAINNET_KEYS[idx].to_string() } +fn next_url(is_ws: bool, chain: NamedChain) -> String { + use NamedChain::*; + + let idx = next() % num_keys(); + let is_infura = idx < INFURA_KEYS.len(); + + let key = if is_infura { INFURA_KEYS[idx] } else { ALCHEMY_KEYS[idx - INFURA_KEYS.len()] }; + + // Nowhere near complete. + let prefix = if is_infura { + match chain { + Optimism => "optimism", + Arbitrum => "arbitrum", + Polygon => "polygon", + _ => "", + } + } else { + match chain { + Optimism => "opt", + Arbitrum => "arb", + Polygon => "polygon", + _ => "eth", + } + }; + let network = if is_infura { + match chain { + Mainnet | Optimism | Arbitrum | Polygon => "mainnet", + _ => chain.as_str(), + } + } else { + match chain { + Mainnet | Optimism | Arbitrum | Polygon => "mainnet", + _ => chain.as_str(), + } + }; + let full = if prefix.is_empty() { network.to_string() } else { format!("{prefix}-{network}") }; + + match (is_ws, is_infura) { + (false, true) => format!("https://{full}.infura.io/v3/{key}"), + (true, true) => format!("wss://{full}.infura.io/v3/{key}"), + (false, false) => format!("https://{full}.g.alchemy.com/v2/{key}"), + (true, false) => format!("wss://{full}.g.alchemy.com/v2/{key}"), + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/testdata/default/cheats/Fork.t.sol b/testdata/default/cheats/Fork.t.sol index cb6a4e3ff9c04..873fbec13921c 100644 --- a/testdata/default/cheats/Fork.t.sol +++ b/testdata/default/cheats/Fork.t.sol @@ -23,8 +23,8 @@ contract ForkTest is DSTest { // this will create two _different_ forks during setup function setUp() public { - forkA = vm.createFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", mainblock); - forkB = vm.createFork("https://eth-mainnet.alchemyapi.io/v2/9VWGraLx0tMiSWx05WH-ywgSVmMxs66W", mainblock - 1); + forkA = vm.createFork("mainnet", mainblock); + forkB = vm.createFork("mainnet2", mainblock - 1); testValue = 999; } @@ -35,7 +35,7 @@ contract ForkTest is DSTest { // ensures we can create and select in one step function testCreateSelect() public { - uint256 fork = vm.createSelectFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf"); + uint256 fork = vm.createSelectFork("mainnet"); assertEq(fork, vm.activeFork()); } @@ -114,12 +114,12 @@ contract ForkTest is DSTest { // ensures forks change chain ids automatically function testCanAutoUpdateChainId() public { - vm.createSelectFork("https://polygon-pokt.nodies.app"); // Polygon mainnet RPC URL - assertEq(block.chainid, 137); + vm.createSelectFork("sepolia"); + assertEq(block.chainid, 11155111); } // ensures forks storage is cached at block function testStorageCaching() public { - vm.createSelectFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 19800000); + vm.createSelectFork("mainnet", 19800000); } } diff --git a/testdata/default/cheats/Fork2.t.sol b/testdata/default/cheats/Fork2.t.sol index da382e90e399b..3e8f68a6cd6d1 100644 --- a/testdata/default/cheats/Fork2.t.sol +++ b/testdata/default/cheats/Fork2.t.sol @@ -35,8 +35,8 @@ contract ForkTest is DSTest { // this will create two _different_ forks during setup function setUp() public { - mainnetFork = vm.createFork("rpcAlias"); - optimismFork = vm.createFork("https://opt-mainnet.g.alchemy.com/v2/UVatYU2Ax0rX6bDiqddeTRDdcCxzdpoE"); + mainnetFork = vm.createFork("mainnet"); + optimismFork = vm.createFork("optimism"); } // ensures forks use different ids @@ -57,7 +57,7 @@ contract ForkTest is DSTest { } function testCanCreateSelect() public { - uint256 anotherFork = vm.createSelectFork("rpcAlias"); + uint256 anotherFork = vm.createSelectFork("mainnet"); assertEq(anotherFork, vm.activeFork()); } @@ -75,12 +75,12 @@ contract ForkTest is DSTest { // test that we can switch between forks, and "roll" blocks function testCanRollFork() public { vm.selectFork(mainnetFork); - uint256 otherMain = vm.createFork("rpcAlias", block.number - 1); + uint256 otherMain = vm.createFork("mainnet", block.number - 1); vm.selectFork(otherMain); uint256 mainBlock = block.number; uint256 forkedBlock = 14608400; - uint256 otherFork = vm.createFork("rpcAlias", forkedBlock); + uint256 otherFork = vm.createFork("mainnet", forkedBlock); vm.selectFork(otherFork); assertEq(block.number, forkedBlock); @@ -101,7 +101,7 @@ contract ForkTest is DSTest { uint256 block = 16261704; // fork until previous block - uint256 fork = vm.createSelectFork("rpcAlias", block - 1); + uint256 fork = vm.createSelectFork("mainnet", block - 1); // block transactions in order: https://beaconcha.in/block/16261704#transactions // run transactions from current block until tx @@ -230,7 +230,7 @@ contract ForkTest is DSTest { } function testRpcWithUrl() public { - bytes memory result = vm.rpc("rpcAlias", "eth_blockNumber", "[]"); + bytes memory result = vm.rpc("mainnet", "eth_blockNumber", "[]"); uint256 decodedResult = vm.parseUint(vm.toString(result)); assertGt(decodedResult, 20_000_000); } diff --git a/testdata/default/cheats/RpcUrls.t.sol b/testdata/default/cheats/RpcUrls.t.sol index 4e3ceba58115c..f7b9808604054 100644 --- a/testdata/default/cheats/RpcUrls.t.sol +++ b/testdata/default/cheats/RpcUrls.t.sol @@ -9,8 +9,8 @@ contract RpcUrlTest is DSTest { // returns the correct url function testCanGetRpcUrl() public { - string memory url = vm.rpcUrl("rpcAlias"); // note: this alias is pre-configured in the test runner - assertEq(url, "https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf"); + string memory url = vm.rpcUrl("mainnet"); + assertEq(bytes(url).length, 69); } // returns an error if env alias does not exist @@ -27,21 +27,12 @@ contract RpcUrlTest is DSTest { ); string[2][] memory _urls = vm.rpcUrls(); - string memory url = vm.rpcUrl("rpcAlias"); + string memory url = vm.rpcUrl("mainnet"); vm.setEnv("RPC_ENV_ALIAS", url); string memory envUrl = vm.rpcUrl("rpcEnvAlias"); assertEq(url, envUrl); string[2][] memory allUrls = vm.rpcUrls(); - assertEq(allUrls.length, 3); - - string[2] memory val = allUrls[0]; - assertEq(val[0], "rpcAlias"); - - string[2] memory env = allUrls[1]; - assertEq(env[0], "rpcAliasSepolia"); - - string[2] memory env2 = allUrls[2]; - assertEq(env2[0], "rpcEnvAlias"); + assertGe(allUrls.length, 2); } } diff --git a/testdata/default/fork/ForkSame_1.t.sol b/testdata/default/fork/ForkSame_1.t.sol index bff9678f65c0b..bbb73fcaafa03 100644 --- a/testdata/default/fork/ForkSame_1.t.sol +++ b/testdata/default/fork/ForkSame_1.t.sol @@ -11,7 +11,7 @@ contract ForkTest is DSTest { // this will create two _different_ forks during setup function setUp() public { - forkA = vm.createFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 15_977_624); + forkA = vm.createFork("mainnet", 15_977_624); } function testDummy() public { diff --git a/testdata/default/fork/ForkSame_2.t.sol b/testdata/default/fork/ForkSame_2.t.sol index bff9678f65c0b..bbb73fcaafa03 100644 --- a/testdata/default/fork/ForkSame_2.t.sol +++ b/testdata/default/fork/ForkSame_2.t.sol @@ -11,7 +11,7 @@ contract ForkTest is DSTest { // this will create two _different_ forks during setup function setUp() public { - forkA = vm.createFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 15_977_624); + forkA = vm.createFork("mainnet", 15_977_624); } function testDummy() public { diff --git a/testdata/default/fork/Transact.t.sol b/testdata/default/fork/Transact.t.sol index ec803906dd2fa..0e3d9c9cb763a 100644 --- a/testdata/default/fork/Transact.t.sol +++ b/testdata/default/fork/Transact.t.sol @@ -20,7 +20,7 @@ contract TransactOnForkTest is DSTest { function testTransact() public { // A random block https://etherscan.io/block/17134913 - uint256 fork = vm.createFork("rpcAlias", 17134913); + uint256 fork = vm.createFork("mainnet", 17134913); vm.selectFork(fork); // a random transfer transaction in the next block: https://etherscan.io/tx/0xaf6201d435b216a858c580e20512a16136916d894aa33260650e164e3238c771 bytes32 tx = 0xaf6201d435b216a858c580e20512a16136916d894aa33260650e164e3238c771; @@ -48,7 +48,7 @@ contract TransactOnForkTest is DSTest { function testTransactCooperatesWithCheatcodes() public { // A random block https://etherscan.io/block/16260609 - uint256 fork = vm.createFork("rpcAlias", 16260609); + uint256 fork = vm.createFork("mainnet", 16260609); vm.selectFork(fork); // a random ERC20 USDT transfer transaction in the next block: https://etherscan.io/tx/0x33350512fec589e635865cbdb38fa3a20a2aa160c52611f1783d0ba24ad13c8c diff --git a/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol b/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol index d74509cd45a75..d15619b635f18 100644 --- a/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantRollFork.t.sol @@ -23,7 +23,7 @@ contract InvariantRollForkBlockTest is DSTest { RollForkHandler forkHandler; function setUp() public { - vm.createSelectFork("rpcAlias", 19812632); + vm.createSelectFork("mainnet", 19812632); forkHandler = new RollForkHandler(); } @@ -39,7 +39,7 @@ contract InvariantRollForkStateTest is DSTest { RollForkHandler forkHandler; function setUp() public { - vm.createSelectFork("rpcAlias", 19812632); + vm.createSelectFork("mainnet", 19812632); forkHandler = new RollForkHandler(); } diff --git a/testdata/default/repros/Issue2623.t.sol b/testdata/default/repros/Issue2623.t.sol index 8534aeeafabff..1d1c2b35bbb64 100644 --- a/testdata/default/repros/Issue2623.t.sol +++ b/testdata/default/repros/Issue2623.t.sol @@ -9,7 +9,7 @@ contract Issue2623Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testRollFork() public { - uint256 fork = vm.createFork("rpcAlias", 10); + uint256 fork = vm.createFork("mainnet", 10); vm.selectFork(fork); assertEq(block.number, 10); diff --git a/testdata/default/repros/Issue2629.t.sol b/testdata/default/repros/Issue2629.t.sol index a1f430858380e..ffff50722c4a2 100644 --- a/testdata/default/repros/Issue2629.t.sol +++ b/testdata/default/repros/Issue2629.t.sol @@ -11,13 +11,13 @@ contract Issue2629Test is DSTest { function testSelectFork() public { address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; - uint256 f1 = vm.createSelectFork("rpcAlias", 9); + uint256 f1 = vm.createSelectFork("mainnet", 9); vm.selectFork(f1); assertEq(block.number, 9); assertEq(coinbase.balance, 11250000000000000000); - uint256 f2 = vm.createFork("rpcAlias", 10); + uint256 f2 = vm.createFork("mainnet", 10); vm.selectFork(f2); assertEq(block.number, 10); diff --git a/testdata/default/repros/Issue2723.t.sol b/testdata/default/repros/Issue2723.t.sol index c260f9467252e..70e522296dac3 100644 --- a/testdata/default/repros/Issue2723.t.sol +++ b/testdata/default/repros/Issue2723.t.sol @@ -11,7 +11,7 @@ contract Issue2723Test is DSTest { function testRollFork() public { address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; - vm.createSelectFork("rpcAlias", 9); + vm.createSelectFork("mainnet", 9); assertEq(block.number, 9); assertEq(coinbase.balance, 11250000000000000000); diff --git a/testdata/default/repros/Issue2956.t.sol b/testdata/default/repros/Issue2956.t.sol index 9d9e5f9ac5862..b69d17fb3cb8f 100644 --- a/testdata/default/repros/Issue2956.t.sol +++ b/testdata/default/repros/Issue2956.t.sol @@ -11,8 +11,8 @@ contract Issue2956Test is DSTest { uint256 fork2; function setUp() public { - fork1 = vm.createFork("rpcAliasSepolia", 5565573); - fork2 = vm.createFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); + fork1 = vm.createFork("sepolia", 5565573); + fork2 = vm.createFork("avaxTestnet", 12880747); } function testForkNonce() public { diff --git a/testdata/default/repros/Issue2984.t.sol b/testdata/default/repros/Issue2984.t.sol index 8e55d5dae4b17..1a181ad533c2a 100644 --- a/testdata/default/repros/Issue2984.t.sol +++ b/testdata/default/repros/Issue2984.t.sol @@ -11,7 +11,7 @@ contract Issue2984Test is DSTest { uint256 snapshot; function setUp() public { - fork = vm.createSelectFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); + fork = vm.createSelectFork("avaxTestnet", 12880747); snapshot = vm.snapshot(); } @@ -20,6 +20,6 @@ contract Issue2984Test is DSTest { } function testForkSelectSnapshot() public { - uint256 fork2 = vm.createSelectFork("https://api.avax-test.network/ext/bc/C/rpc", 12880749); + uint256 fork2 = vm.createSelectFork("avaxTestnet", 12880749); } } diff --git a/testdata/default/repros/Issue3077.t.sol b/testdata/default/repros/Issue3077.t.sol index cc76b57b6fb2e..b67316294abdf 100644 --- a/testdata/default/repros/Issue3077.t.sol +++ b/testdata/default/repros/Issue3077.t.sol @@ -15,7 +15,7 @@ abstract contract ZeroState is DSTest { function setUp() public virtual { vm.startPrank(deployer); - mainnetFork = vm.createFork("rpcAlias"); + mainnetFork = vm.createFork("mainnet"); vm.selectFork(mainnetFork); vm.rollFork(block.number - 20); // deploy tokens diff --git a/testdata/default/repros/Issue3110.t.sol b/testdata/default/repros/Issue3110.t.sol index 7a2622427a615..f9ca984bdbe8a 100644 --- a/testdata/default/repros/Issue3110.t.sol +++ b/testdata/default/repros/Issue3110.t.sol @@ -17,7 +17,7 @@ abstract contract ZeroState is DSTest { vm.label(deployer, "Deployer"); vm.startPrank(deployer); - mainnetFork = vm.createFork("rpcAlias"); + mainnetFork = vm.createFork("mainnet"); vm.selectFork(mainnetFork); vm.rollFork(block.number - 20); diff --git a/testdata/default/repros/Issue3119.t.sol b/testdata/default/repros/Issue3119.t.sol index 5c94b4c5fde56..3e82985c295bf 100644 --- a/testdata/default/repros/Issue3119.t.sol +++ b/testdata/default/repros/Issue3119.t.sol @@ -12,7 +12,7 @@ contract Issue3119Test is DSTest { address public alice = vm.addr(2); function testRollFork() public { - uint256 fork = vm.createFork("rpcAlias"); + uint256 fork = vm.createFork("mainnet"); vm.selectFork(fork); FortressSwap fortressSwap = new FortressSwap(address(owner)); diff --git a/testdata/default/repros/Issue3192.t.sol b/testdata/default/repros/Issue3192.t.sol index 0deb22f49e084..1f693b1aad1ed 100644 --- a/testdata/default/repros/Issue3192.t.sol +++ b/testdata/default/repros/Issue3192.t.sol @@ -11,8 +11,8 @@ contract Issue3192Test is DSTest { uint256 fork2; function setUp() public { - fork1 = vm.createFork("rpcAlias", 7475589); - fork2 = vm.createFork("rpcAlias", 12880747); + fork1 = vm.createFork("mainnet", 7475589); + fork2 = vm.createFork("mainnet", 12880747); vm.selectFork(fork1); } diff --git a/testdata/default/repros/Issue3220.t.sol b/testdata/default/repros/Issue3220.t.sol index b88d997c12051..30e75027a9ac7 100644 --- a/testdata/default/repros/Issue3220.t.sol +++ b/testdata/default/repros/Issue3220.t.sol @@ -14,9 +14,9 @@ contract Issue3220Test is DSTest { uint256 counter; function setUp() public { - fork1 = vm.createFork("rpcAlias", 7475589); + fork1 = vm.createFork("mainnet", 7475589); vm.selectFork(fork1); - fork2 = vm.createFork("rpcAlias", 12880747); + fork2 = vm.createFork("mainnet", 12880747); } function testForkRevert() public { diff --git a/testdata/default/repros/Issue3221.t.sol b/testdata/default/repros/Issue3221.t.sol index 4a9dd7be40997..628f9d0e180c1 100644 --- a/testdata/default/repros/Issue3221.t.sol +++ b/testdata/default/repros/Issue3221.t.sol @@ -11,8 +11,8 @@ contract Issue3221Test is DSTest { uint256 fork2; function setUp() public { - fork1 = vm.createFork("rpcAliasSepolia", 5565573); - fork2 = vm.createFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); + fork1 = vm.createFork("sepolia", 5565573); + fork2 = vm.createFork("avaxTestnet", 12880747); } function testForkNonce() public { diff --git a/testdata/default/repros/Issue3223.t.sol b/testdata/default/repros/Issue3223.t.sol index d4c5da751f26b..cd43cb8ef1b90 100644 --- a/testdata/default/repros/Issue3223.t.sol +++ b/testdata/default/repros/Issue3223.t.sol @@ -11,8 +11,8 @@ contract Issue3223Test is DSTest { uint256 fork2; function setUp() public { - fork1 = vm.createFork("rpcAliasSepolia", 2362365); - fork2 = vm.createFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); + fork1 = vm.createFork("sepolia", 2362365); + fork2 = vm.createFork("avaxTestnet", 12880747); } function testForkNonce() public { diff --git a/testdata/default/repros/Issue3653.t.sol b/testdata/default/repros/Issue3653.t.sol index b86f84c3e735d..8cfcc2d0e8765 100644 --- a/testdata/default/repros/Issue3653.t.sol +++ b/testdata/default/repros/Issue3653.t.sol @@ -11,7 +11,7 @@ contract Issue3653Test is DSTest { Token token; constructor() { - fork = vm.createSelectFork("rpcAlias", 1000000); + fork = vm.createSelectFork("mainnet", 1000000); token = new Token(); vm.makePersistent(address(token)); } diff --git a/testdata/default/repros/Issue3674.t.sol b/testdata/default/repros/Issue3674.t.sol index 813f73b5d8f0b..0b680342adad9 100644 --- a/testdata/default/repros/Issue3674.t.sol +++ b/testdata/default/repros/Issue3674.t.sol @@ -9,9 +9,9 @@ contract Issue3674Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testNonceCreateSelect() public { - vm.createSelectFork("rpcAliasSepolia"); + vm.createSelectFork("sepolia"); - vm.createSelectFork("https://api.avax-test.network/ext/bc/C/rpc"); + vm.createSelectFork("avaxTestnet"); assert(vm.getNonce(msg.sender) > 0x17); } } diff --git a/testdata/default/repros/Issue3703.t.sol b/testdata/default/repros/Issue3703.t.sol index 06ce6bcbe92af..b6dc39f265a07 100644 --- a/testdata/default/repros/Issue3703.t.sol +++ b/testdata/default/repros/Issue3703.t.sol @@ -9,10 +9,8 @@ contract Issue3703Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function setUp() public { - uint256 fork = vm.createSelectFork( - "https://polygon-mainnet.g.alchemy.com/v2/bVjX9v-FpmUhf5R_oHIgwJx2kXvYPRbx", - bytes32(0xbed0c8c1b9ff8bf0452979d170c52893bb8954f18a904aa5bcbd0f709be050b9) - ); + uint256 fork = + vm.createSelectFork("polygon", bytes32(0xbed0c8c1b9ff8bf0452979d170c52893bb8954f18a904aa5bcbd0f709be050b9)); } function poolState(address poolAddr, uint256 expectedSqrtPriceX96, uint256 expectedLiquidity) private { diff --git a/testdata/default/repros/Issue4586.t.sol b/testdata/default/repros/Issue4586.t.sol index a41ba7a0485ea..29284ee1b423b 100644 --- a/testdata/default/repros/Issue4586.t.sol +++ b/testdata/default/repros/Issue4586.t.sol @@ -13,7 +13,7 @@ contract Issue4586Test is DSTest { InvariantHandler handler; function setUp() public { - vm.createSelectFork("rpcAlias", initialBlock); + vm.createSelectFork("mainnet", initialBlock); handler = new InvariantHandler(); } diff --git a/testdata/default/repros/Issue4640.t.sol b/testdata/default/repros/Issue4640.t.sol index a875d000de979..eaa87c12c1710 100644 --- a/testdata/default/repros/Issue4640.t.sol +++ b/testdata/default/repros/Issue4640.t.sol @@ -10,7 +10,7 @@ contract Issue4640Test is DSTest { function testArbitrumBlockNumber() public { // - vm.createSelectFork("https://arb-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 75219831); + vm.createSelectFork("arbitrum", 75219831); // L1 block number assertEq(block.number, 16939475); } diff --git a/testdata/default/repros/Issue5739.t.sol b/testdata/default/repros/Issue5739.t.sol index 2864c0cbffb32..eafbabd9395cf 100644 --- a/testdata/default/repros/Issue5739.t.sol +++ b/testdata/default/repros/Issue5739.t.sol @@ -14,7 +14,7 @@ contract Issue5739Test is DSTest { IERC20 dai; function setUp() public { - vm.createSelectFork("rpcAlias", 19000000); + vm.createSelectFork("mainnet", 19000000); dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); } diff --git a/testdata/default/repros/Issue5929.t.sol b/testdata/default/repros/Issue5929.t.sol index f1009f03b93c4..cce676d253935 100644 --- a/testdata/default/repros/Issue5929.t.sol +++ b/testdata/default/repros/Issue5929.t.sol @@ -9,7 +9,7 @@ contract Issue5929Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function test_transact_not_working() public { - vm.createSelectFork("rpcAlias", 15625301); + vm.createSelectFork("mainnet", 15625301); // https://etherscan.io/tx/0x96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143 vm.transact(hex"96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143"); } diff --git a/testdata/default/repros/Issue5935.t.sol b/testdata/default/repros/Issue5935.t.sol index 95b6f8fd5b3a9..f783d12da49a1 100644 --- a/testdata/default/repros/Issue5935.t.sol +++ b/testdata/default/repros/Issue5935.t.sol @@ -12,15 +12,12 @@ contract SimpleStorage { } } -/// @dev start anvil --port 35353 contract Issue5935Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testFork() public { - uint256 forkId1 = - vm.createFork("https://eth-mainnet.alchemyapi.io/v2/QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", 18234083); - uint256 forkId2 = - vm.createFork("https://eth-mainnet.alchemyapi.io/v2/QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", 18234083); + uint256 forkId1 = vm.createFork("mainnet", 18234083); + uint256 forkId2 = vm.createFork("mainnet", 18234083); vm.selectFork(forkId1); SimpleStorage myContract = new SimpleStorage(); myContract.set(42); diff --git a/testdata/default/repros/Issue6032.t.sol b/testdata/default/repros/Issue6032.t.sol index fc230c47e183e..75002a136aeed 100644 --- a/testdata/default/repros/Issue6032.t.sol +++ b/testdata/default/repros/Issue6032.t.sol @@ -15,7 +15,7 @@ contract Issue6032Test is DSTest { address counterAddress = address(counter); // Enter the fork - vm.createSelectFork("rpcAlias"); + vm.createSelectFork("mainnet"); assert(counterAddress.code.length > 0); // `Counter` is not deployed on the fork, which is expected. diff --git a/testdata/default/repros/Issue6538.t.sol b/testdata/default/repros/Issue6538.t.sol index d83bbc850f5e1..2b8beb578cb04 100644 --- a/testdata/default/repros/Issue6538.t.sol +++ b/testdata/default/repros/Issue6538.t.sol @@ -10,7 +10,7 @@ contract Issue6538Test is DSTest { function test_transact() public { bytes32 lastHash = 0xdbdce1d5c14a6ca17f0e527ab762589d6a73f68697606ae0bb90df7ac9ec5087; - vm.createSelectFork("rpcAlias", lastHash); + vm.createSelectFork("mainnet", lastHash); bytes32 txhash = 0xadbe5cf9269a001d50990d0c29075b402bcc3a0b0f3258821881621b787b35c6; vm.transact(txhash); } diff --git a/testdata/default/repros/Issue6616.t.sol b/testdata/default/repros/Issue6616.t.sol index 24fa00e214eec..f31a79ee6495f 100644 --- a/testdata/default/repros/Issue6616.t.sol +++ b/testdata/default/repros/Issue6616.t.sol @@ -9,12 +9,12 @@ contract Issue6616Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testCreateForkRollLatestBlock() public { - vm.createSelectFork("rpcAlias"); + vm.createSelectFork("mainnet"); uint256 startBlock = block.number; // this will create new forks and exit once a new latest block is found for (uint256 i; i < 10; i++) { vm.sleep(5000); - vm.createSelectFork("rpcAlias"); + vm.createSelectFork("mainnet"); if (block.number > startBlock) break; } assertGt(block.number, startBlock); diff --git a/testdata/default/repros/Issue6759.t.sol b/testdata/default/repros/Issue6759.t.sol index a8039035e99d0..e528c63e1d82c 100644 --- a/testdata/default/repros/Issue6759.t.sol +++ b/testdata/default/repros/Issue6759.t.sol @@ -9,9 +9,9 @@ contract Issue6759Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testCreateMulti() public { - uint256 fork1 = vm.createFork("rpcAlias", 10); - uint256 fork2 = vm.createFork("rpcAlias", 10); - uint256 fork3 = vm.createFork("rpcAlias", 10); + uint256 fork1 = vm.createFork("mainnet", 10); + uint256 fork2 = vm.createFork("mainnet", 10); + uint256 fork3 = vm.createFork("mainnet", 10); assert(fork1 != fork2); assert(fork1 != fork3); assert(fork2 != fork3); diff --git a/testdata/default/repros/Issue7481.t.sol b/testdata/default/repros/Issue7481.t.sol index eb568dc946668..441758b4ff56e 100644 --- a/testdata/default/repros/Issue7481.t.sol +++ b/testdata/default/repros/Issue7481.t.sol @@ -10,7 +10,7 @@ contract Issue7481Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testFailTransact() public { - vm.createSelectFork("rpcAlias", 19514903); + vm.createSelectFork("mainnet", 19514903); // Transfer some funds to sender of tx being transacted to ensure that it appears in journaled state payable(address(0x5C60cD7a3D50877Bfebd484750FBeb245D936dAD)).call{value: 1}(""); diff --git a/testdata/default/repros/Issue8004.t.sol b/testdata/default/repros/Issue8004.t.sol index 3e077e2a27ec0..229dde5ad3a22 100644 --- a/testdata/default/repros/Issue8004.t.sol +++ b/testdata/default/repros/Issue8004.t.sol @@ -9,18 +9,18 @@ contract NonPersistentHelper is DSTest { uint256 public curState; function createSelectFork() external { - vm.createSelectFork("rpcAlias"); + vm.createSelectFork("mainnet"); curState += 1; } function createSelectForkAtBlock() external { - vm.createSelectFork("rpcAlias", 19000000); + vm.createSelectFork("mainnet", 19000000); curState += 1; } function createSelectForkAtTx() external { vm.createSelectFork( - "rpcAlias", vm.parseBytes32("0xb5c978f15d01fcc9b4d78967e8189e35ecc21ff4e78315ea5d616f3467003c84") + "mainnet", vm.parseBytes32("0xb5c978f15d01fcc9b4d78967e8189e35ecc21ff4e78315ea5d616f3467003c84") ); curState += 1; } @@ -66,7 +66,7 @@ contract Issue8004CreateSelectForkTest is DSTest { } function testNonPersistentHelperSelectFork() external { - uint256 forkId = vm.createFork("rpcAlias"); + uint256 forkId = vm.createFork("mainnet"); helper.selectFork(forkId); assertEq(helper.curState(), 1); } @@ -78,7 +78,7 @@ contract Issue8004RollForkTest is DSTest { uint256 forkId; function setUp() public { - forkId = vm.createSelectFork("rpcAlias"); + forkId = vm.createSelectFork("mainnet"); helper = new NonPersistentHelper(); } diff --git a/testdata/default/repros/Issue8006.t.sol b/testdata/default/repros/Issue8006.t.sol index 1a45ddf977cfa..078117d40e291 100644 --- a/testdata/default/repros/Issue8006.t.sol +++ b/testdata/default/repros/Issue8006.t.sol @@ -21,7 +21,7 @@ contract Issue8006Test is DSTest { bytes32 transaction = 0x67cbad73764049e228495a3f90144aab4a37cb4b5fd697dffc234aa5ed811ace; function setUp() public { - vm.createSelectFork("rpcAlias", 16261704); + vm.createSelectFork("mainnet", 16261704); dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); } diff --git a/testdata/default/repros/Issue8168.t.sol b/testdata/default/repros/Issue8168.t.sol index b9bd5757abc70..f11cef7bc15bd 100644 --- a/testdata/default/repros/Issue8168.t.sol +++ b/testdata/default/repros/Issue8168.t.sol @@ -9,8 +9,8 @@ contract Issue8168Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testForkWarpRollPreserved() public { - uint256 fork1 = vm.createFork("rpcAlias"); - uint256 fork2 = vm.createFork("rpcAlias"); + uint256 fork1 = vm.createFork("mainnet"); + uint256 fork2 = vm.createFork("mainnet"); vm.selectFork(fork1); uint256 initial_fork1_number = block.number; diff --git a/testdata/default/repros/Issue8287.t.sol b/testdata/default/repros/Issue8287.t.sol index cedcb4043ceaf..86901c0fda926 100644 --- a/testdata/default/repros/Issue8287.t.sol +++ b/testdata/default/repros/Issue8287.t.sol @@ -9,14 +9,14 @@ contract Issue8287Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testRpcBalance() public { - uint256 f2 = vm.createSelectFork("rpcAlias", 10); + uint256 f2 = vm.createSelectFork("mainnet", 10); bytes memory data = vm.rpc("eth_getBalance", "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x0\"]"); string memory m = vm.toString(data); assertEq(m, "0x2086ac351052600000"); } function testRpcStorage() public { - uint256 f2 = vm.createSelectFork("rpcAlias", 10); + uint256 f2 = vm.createSelectFork("mainnet", 10); bytes memory data = vm.rpc( "eth_getStorageAt", "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e\",\"0x0\"]" From df5f45c8c1a7e138203f1f479940f1500752b3dc Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 26 Jul 2024 23:11:12 +0800 Subject: [PATCH 1294/1963] chore(deps): bump foundry-compilers (#8535) chore(deps): bump compilers --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 2 +- crates/config/src/lib.rs | 9 --------- crates/config/src/utils.rs | 1 + crates/forge/tests/cli/config.rs | 1 - 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dccf91eef047d..29d6286536db5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3716,9 +3716,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea06d58fce261a37f7c90ec4d2f14af729825bf7abbda14b64f8d728bc701480" +checksum = "f7c47e9b1b142be502b089e9699922110b6f15906f739b8e612755167da4f5a1" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3754,9 +3754,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0a0b1e385a5f9d88b0d6c9c8c1a5d89e33e5465e62096034abcd0dfd48a8618" +checksum = "8a8e5d34b4b594806808c200340b24fa1a60b9f65b76ecf0df406c52c0e4019a" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3764,9 +3764,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff1e9120d86202a81a7729f33fabfc77c12beca7233765d36c49ebcd8da100b" +checksum = "17c7481a171c86d76cdd257eeb99e15d532f94502efa51f76858e2196d85840e" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3788,9 +3788,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b88e8a09b7689253885c5171512987d6dea96ac328b2384f6a0233a332ec8d9" +checksum = "32523fa23051d11d534493c93e00a482e27abbbb615ca6d646ebe30b749624db" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3803,9 +3803,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ad521e38281f70e99a5487883179b4bfb74c855abebe5d5390d8e6d993503a" +checksum = "1e03290dd4cd78b076a43e6f8528f240d3ec74c0a56795830327d6dd781a7ac0" dependencies = [ "alloy-primitives", "cfg-if", @@ -6699,7 +6699,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.12.1", "proc-macro2", "quote", "syn 2.0.71", diff --git a/Cargo.toml b/Cargo.toml index 83e270668db41..a33e01642d920 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.5.1", default-features = false } -foundry-compilers = { version = "0.10.0", default-features = false } +foundry-compilers = { version = "0.10.1", default-features = false } foundry-fork-db = "0.2" solang-parser = "=0.3.3" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f5222a78dbf12..d9c7625810274 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -400,11 +400,6 @@ pub struct Config { /// This includes what operations can be executed (read, write) pub fs_permissions: FsPermissions, - /// Temporary config to enable [SpecId::PRAGUE] - /// - /// Should be removed once EvmVersion Prague is supported by solc - pub prague: bool, - /// Whether to enable call isolation. /// /// Useful for more correct gas accounting and EVM behavior in general. @@ -915,9 +910,6 @@ impl Config { /// Returns the [SpecId] derived from the configured [EvmVersion] #[inline] pub fn evm_spec_id(&self) -> SpecId { - if self.prague { - return SpecId::PRAGUE_EOF - } evm_spec_id(&self.evm_version) } @@ -2042,7 +2034,6 @@ impl Default for Config { Self { profile: Self::DEFAULT_PROFILE, fs_permissions: FsPermissions::new([PathPermission::read("out")]), - prague: false, #[cfg(not(feature = "isolate-by-default"))] isolate: false, #[cfg(feature = "isolate-by-default")] diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index b58565c4cecb7..d8d23711c3bdd 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -310,6 +310,7 @@ pub fn evm_spec_id(evm_version: &EvmVersion) -> SpecId { EvmVersion::Paris => SpecId::MERGE, EvmVersion::Shanghai => SpecId::SHANGHAI, EvmVersion::Cancun => SpecId::CANCUN, + EvmVersion::Prague => SpecId::PRAGUE_EOF, } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index a5ec38ec1e83f..fcec5f15a84a7 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -137,7 +137,6 @@ forgetest!(can_extract_config_values, |prj, cmd| { bind_json: Default::default(), fs_permissions: Default::default(), labels: Default::default(), - prague: true, isolate: true, unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, From a416c1001c7dba772d008a5fc43e43b024a9d684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Sat, 27 Jul 2024 08:36:28 +0200 Subject: [PATCH 1295/1963] feat(cheatcodes): add `vm.getFoundryVersion()` (#8530) * feat: implement `vm.getFoundryVersion` * test: implement dummy test for `vm.getFoundryVersion` * chore: modify implementation to return cargo version and build timestamp * test: modify test * docs: add sample output * chore: cargo cheats * fix: failing test and vergen setup * test: update getFoundryVersion * docs: mention built timestamps issue --------- Co-authored-by: Matthias Seitz --- Cargo.lock | 2 ++ crates/cheatcodes/Cargo.toml | 10 ++++++- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++ crates/cheatcodes/build.rs | 3 +++ crates/cheatcodes/spec/src/vm.rs | 9 +++++++ crates/cheatcodes/src/test.rs | 17 ++++++++++++ testdata/cheats/Vm.sol | 1 + .../default/cheats/GetFoundryVersion.t.sol | 26 +++++++++++++++++++ 8 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 crates/cheatcodes/build.rs create mode 100644 testdata/default/cheats/GetFoundryVersion.t.sol diff --git a/Cargo.lock b/Cargo.lock index 29d6286536db5..a5f35ad65f9f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3576,6 +3576,7 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "base64 0.22.1", + "chrono", "dialoguer", "eyre", "foundry-cheatcodes-spec", @@ -3598,6 +3599,7 @@ dependencies = [ "thiserror", "toml 0.8.15", "tracing", + "vergen", "walkdir", ] diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 60304a47dd0d4..80336d4e8f64a 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -14,6 +14,13 @@ exclude.workspace = true [lints] workspace = true +[build-dependencies] +vergen = { workspace = true, default-features = false, features = [ + "build", + "git", + "gitcl", +] } + [dependencies] foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true @@ -54,6 +61,7 @@ semver.workspace = true rustc-hash.workspace = true dialoguer = "0.11.0" rand = "0.8" +chrono.workspace = true [dev-dependencies] -proptest.workspace = true \ No newline at end of file +proptest.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index ec12113eb31ba..61f6264777059 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4991,6 +4991,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getFoundryVersion", + "description": "Returns the Foundry version.\nFormat: ++\nSample output: 0.2.0+faa94c384+202407110019\nNote: Build timestamps may vary slightly across platforms due to separate CI jobs.\nFor reliable version comparisons, use YYYYMMDD0000 format (e.g., >= 202407110000)\nto compare timestamps while ignoring minor time differences.", + "declaration": "function getFoundryVersion() external view returns (string memory version);", + "visibility": "external", + "mutability": "view", + "signature": "getFoundryVersion()", + "selector": "0xea991bb5", + "selectorBytes": [ + 234, + 153, + 27, + 181 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "getLabel", diff --git a/crates/cheatcodes/build.rs b/crates/cheatcodes/build.rs new file mode 100644 index 0000000000000..c2f550fb6f829 --- /dev/null +++ b/crates/cheatcodes/build.rs @@ -0,0 +1,3 @@ +fn main() { + vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); +} diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index ff9a92e58930c..935d44e53a4e0 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -702,6 +702,15 @@ interface Vm { #[cheatcode(group = Testing, safety = Safe)] function breakpoint(string calldata char, bool value) external; + /// Returns the Foundry version. + /// Format: ++ + /// Sample output: 0.2.0+faa94c384+202407110019 + /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs. + /// For reliable version comparisons, use YYYYMMDD0000 format (e.g., >= 202407110000) + /// to compare timestamps while ignoring minor time differences. + #[cheatcode(group = Testing, safety = Safe)] + function getFoundryVersion() external view returns (string memory version); + /// Returns the RPC url for the given alias. #[cheatcode(group = Testing, safety = Safe)] function rpcUrl(string calldata rpcAlias) external view returns (string memory json); diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 4bccabda253e2..279150dff89f4 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -1,5 +1,8 @@ //! Implementations of [`Testing`](spec::Group::Testing) cheatcodes. +use chrono::DateTime; +use std::env; + use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result, Vm::*}; use alloy_primitives::Address; use alloy_sol_types::SolValue; @@ -33,6 +36,20 @@ impl Cheatcode for breakpoint_1Call { } } +impl Cheatcode for getFoundryVersionCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self {} = self; + let cargo_version = env!("CARGO_PKG_VERSION"); + let git_sha = env!("VERGEN_GIT_SHA"); + let build_timestamp = DateTime::parse_from_rfc3339(env!("VERGEN_BUILD_TIMESTAMP")) + .expect("Invalid build timestamp format") + .format("%Y%m%d%H%M") + .to_string(); + let foundry_version = format!("{cargo_version}+{git_sha}+{build_timestamp}"); + Ok(foundry_version.abi_encode()) + } +} + impl Cheatcode for rpcUrlCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { rpcAlias } = self; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index dfe466d3aadaf..f42fb22983ea8 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -245,6 +245,7 @@ interface Vm { function getBlockTimestamp() external view returns (uint256 timestamp); function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); + 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 getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length); diff --git a/testdata/default/cheats/GetFoundryVersion.t.sol b/testdata/default/cheats/GetFoundryVersion.t.sol new file mode 100644 index 0000000000000..6f850561d71b5 --- /dev/null +++ b/testdata/default/cheats/GetFoundryVersion.t.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract GetFoundryVersionTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testGetFoundryVersion() public view { + string memory fullVersionString = vm.getFoundryVersion(); + + string[] memory versionComponents = vm.split(fullVersionString, "+"); + require(versionComponents.length == 3, "Invalid version format"); + + string memory semanticVersion = versionComponents[0]; + require(bytes(semanticVersion).length > 0, "Semantic version is empty"); + + string memory commitHash = versionComponents[1]; + require(bytes(commitHash).length > 0, "Commit hash is empty"); + + uint256 buildUnixTimestamp = vm.parseUint(versionComponents[2]); + uint256 minimumAcceptableTimestamp = 202406111234; + require(buildUnixTimestamp >= minimumAcceptableTimestamp, "Build timestamp is too old"); + } +} From bdd1137374cda2bfbb2a3d126c476e2dfd1864a7 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 27 Jul 2024 08:38:53 +0200 Subject: [PATCH 1296/1963] ci: enable anvil default feature for release (#8540) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 35ca11d93490e..83d216c7f03d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -133,7 +133,7 @@ jobs: run: | set -eo pipefail target="${{ matrix.target }}" - flags=(--release --bins --no-default-features --features rustls,aws-kms) + flags=(--release --bins --no-default-features --features rustls,aws-kms,cli) # `jemalloc` and `keccak-asm` are not supported on MSVC or aarch64 Linux. if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then From 66bc49e354b1d5e29f0c7c62a4b79722c9811579 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 28 Jul 2024 09:08:16 +0000 Subject: [PATCH 1297/1963] chore(deps): weekly `cargo update` (#8544) Locking 59 packages to latest compatible versions Updating anstream v0.6.14 -> v0.6.15 Updating anstyle v1.0.7 -> v1.0.8 Updating anstyle-parse v0.2.4 -> v0.2.5 Updating anstyle-query v1.1.0 -> v1.1.1 Updating anstyle-wincon v3.0.3 -> v3.0.4 Updating async-compression v0.4.11 -> v0.4.12 Updating aws-sdk-kms v1.36.0 -> v1.37.0 Updating aws-sdk-sso v1.35.0 -> v1.36.0 Updating aws-sdk-ssooidc v1.36.0 -> v1.37.0 Updating aws-sdk-sts v1.35.0 -> v1.36.0 Updating blst v0.3.12 -> v0.3.13 Removing bstr v0.2.17 Removing bstr v1.9.1 Adding bstr v1.10.0 Updating clap v4.5.9 -> v4.5.11 Updating clap_builder v4.5.9 -> v4.5.11 Updating clap_complete v4.5.8 -> v4.5.11 Updating clap_complete_fig v4.5.1 -> v4.5.2 Updating clap_derive v4.5.8 -> v4.5.11 Updating clap_lex v0.7.1 -> v0.7.2 Updating colorchoice v1.0.1 -> v1.0.2 Updating env_filter v0.1.0 -> v0.1.2 Updating env_logger v0.11.3 -> v0.11.5 Updating evmole v0.3.6 -> v0.3.7 Updating generator v0.8.1 -> v0.8.2 Updating gix-actor v0.31.4 -> v0.31.5 Updating gix-config-value v0.14.6 -> v0.14.7 Updating gix-glob v0.16.3 -> v0.16.4 Updating gix-sec v0.10.6 -> v0.10.7 Updating interprocess v2.2.0 -> v2.2.1 Updating is_terminal_polyfill v1.70.0 -> v1.70.1 Updating jobserver v0.1.31 -> v0.1.32 Adding mio v1.0.1 Updating openssl v0.10.65 -> v0.10.66 Updating predicates v3.1.0 -> v3.1.2 Updating predicates-core v1.0.6 -> v1.0.8 Updating predicates-tree v1.0.9 -> v1.0.11 Updating quinn-udp v0.5.2 -> v0.5.4 Updating revm-inspectors v0.5.3 -> v0.5.4 Updating rustls v0.23.11 -> v0.23.12 Updating rustls-webpki v0.102.5 -> v0.102.6 Updating scc v2.1.4 -> v2.1.5 Updating serde_spanned v0.6.6 -> v0.6.7 Updating sha1_smol v1.0.0 -> v1.0.1 Updating similar v2.5.0 -> v2.6.0 Updating snapbox v0.6.13 -> v0.6.16 Updating snapbox-macros v0.3.9 -> v0.3.10 Updating syn v2.0.71 -> v2.0.72 Updating tokio v1.38.1 -> v1.39.2 Updating tokio-macros v2.3.0 -> v2.4.0 Updating toml v0.8.15 -> v0.8.16 Updating toml_datetime v0.6.6 -> v0.6.7 Updating toml_edit v0.22.16 -> v0.22.17 Updating version_check v0.9.4 -> v0.9.5 Updating windows v0.54.0 -> v0.58.0 Updating windows-core v0.54.0 -> v0.58.0 Adding windows-implement v0.58.0 Adding windows-interface v0.58.0 Adding windows-result v0.2.0 Adding windows-strings v0.1.0 Updating winnow v0.6.14 -> v0.6.16 note: pass `--verbose` to see 150 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 506 +++++++++++++++++++++++++++++------------------------ 1 file changed, 274 insertions(+), 232 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5f35ad65f9f4..1a37ebd14bd4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,7 +129,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.14", + "winnow 0.6.16", ] [[package]] @@ -308,7 +308,7 @@ checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -556,7 +556,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -573,7 +573,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", "syn-solidity", "tiny-keccak", ] @@ -591,7 +591,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.71", + "syn 2.0.72", "syn-solidity", ] @@ -602,7 +602,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" dependencies = [ "serde", - "winnow 0.6.14", + "winnow 0.6.16", ] [[package]] @@ -683,7 +683,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.11", + "rustls 0.23.12", "serde_json", "tokio", "tokio-tungstenite 0.23.1", @@ -743,9 +743,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -758,33 +758,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -1075,9 +1075,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" +checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa" dependencies = [ "flate2", "futures-core", @@ -1103,7 +1103,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -1125,7 +1125,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -1136,7 +1136,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -1183,7 +1183,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -1260,9 +1260,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf39203c9fa4b177c5b58ebf19fc97bbfece1e17c3171c7c5e356ca5f6ea42c" +checksum = "d91f43512620f4b0d9e67ccf7d768fab5ed310ac2229ebb9422177abe99c36ba" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1282,9 +1282,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc3ef4ee9cdd19ec6e8b10d963b79637844bbf41c31177b77a188eaa941e69f7" +checksum = "6acca681c53374bf1d9af0e317a41d12a44902ca0f2d1e10e5cb5bb98ed74f35" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1304,9 +1304,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527f3da450ea1f09f95155dba6153bd0d83fe0923344a12e1944dfa5d0b32064" +checksum = "b79c6bdfe612503a526059c05c9ccccbf6bd9530b003673cb863e547fd7c0c9a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1326,9 +1326,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94316606a4aa2cb7a302388411b8776b3fbd254e8506e2dc43918286d8212e9b" +checksum = "32e6ecdb2bd756f3b2383e6f0588dc10a4e65f5d551e70a56e0bfe0c884673ce" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1742,9 +1742,9 @@ dependencies = [ [[package]] name = "blst" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62dc83a094a71d43eeadd254b1ec2d24cb6a0bb6cadce00df51f0db594711a32" +checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874" dependencies = [ "cc", "glob", @@ -1764,20 +1764,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata 0.1.10", -] - -[[package]] -name = "bstr" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", "regex-automata 0.4.7", @@ -2092,9 +2081,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" dependencies = [ "clap_builder", "clap_derive", @@ -2102,9 +2091,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" dependencies = [ "anstream", "anstyle", @@ -2117,18 +2106,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.8" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4be9c4c4b1f30b78d8a750e0822b6a6102d97e62061c583a6c1dea2dfb33ae" +checksum = "c6ae69fbb0833c6fcd5a8d4b8609f108c7ad95fc11e248d853ff2c42a90df26a" dependencies = [ "clap", ] [[package]] name = "clap_complete_fig" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4bc503cddc1cd320736fb555d6598309ad07c2ddeaa23891a10ffb759ee612" +checksum = "d494102c8ff3951810c72baf96910b980fb065ca5d3101243e6a8dc19747c86b" dependencies = [ "clap", "clap_complete", @@ -2136,21 +2125,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "clearscreen" @@ -2279,9 +2268,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "comfy-table" @@ -2486,7 +2475,7 @@ dependencies = [ "bitflags 2.6.0", "crossterm_winapi", "libc", - "mio", + "mio 0.8.11", "parking_lot", "signal-hook", "signal-hook-mio", @@ -2570,7 +2559,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -2581,7 +2570,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -2653,7 +2642,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -2674,7 +2663,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -2684,7 +2673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -2697,7 +2686,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -2804,7 +2793,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -2940,14 +2929,14 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] name = "env_filter" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ "log", "regex", @@ -2955,9 +2944,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ "anstream", "anstyle", @@ -3090,8 +3079,8 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.71", - "toml 0.8.15", + "syn 2.0.72", + "toml 0.8.16", "walkdir", ] @@ -3118,7 +3107,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.71", + "syn 2.0.72", "tempfile", "thiserror", "tiny-keccak", @@ -3148,9 +3137,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce047d502545e3a726948bb8a532b8ea1446238f829e01448c802b2f10edbe70" +checksum = "628b1881ed2b7f83a32418f6de735c49292065dfc225067687ee1d4fc59a134e" dependencies = [ "ruint", ] @@ -3242,7 +3231,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.15", + "toml 0.8.16", "uncased", "version_check", ] @@ -3387,8 +3376,8 @@ dependencies = [ "thiserror", "tikv-jemallocator", "tokio", - "toml 0.8.15", - "toml_edit 0.22.16", + "toml 0.8.16", + "toml_edit 0.22.17", "tower-http", "tracing", "tracing-subscriber", @@ -3419,7 +3408,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.15", + "toml 0.8.16", "tracing", ] @@ -3434,7 +3423,7 @@ dependencies = [ "similar-asserts", "solang-parser", "thiserror", - "toml 0.8.15", + "toml 0.8.16", "tracing", "tracing-subscriber", ] @@ -3496,7 +3485,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -3597,7 +3586,7 @@ dependencies = [ "semver 1.0.23", "serde_json", "thiserror", - "toml 0.8.15", + "toml 0.8.16", "tracing", "vergen", "walkdir", @@ -3750,7 +3739,7 @@ dependencies = [ "thiserror", "tokio", "tracing", - "winnow 0.6.14", + "winnow 0.6.16", "yansi", ] @@ -3856,8 +3845,8 @@ dependencies = [ "solang-parser", "tempfile", "thiserror", - "toml 0.8.15", - "toml_edit 0.22.16", + "toml 0.8.16", + "toml_edit 0.22.17", "tracing", "walkdir", ] @@ -4066,7 +4055,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -4225,7 +4214,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -4309,16 +4298,15 @@ dependencies = [ [[package]] name = "generator" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186014d53bc231d0090ef8d6f03e0920c54d85a5ed22f4f2f74315ec56cf83fb" +checksum = "979f00864edc7516466d6b3157706e06c032f22715700ddd878228a91d02bc56" dependencies = [ - "cc", "cfg-if", "libc", "log", "rustversion", - "windows 0.54.0", + "windows 0.58.0", ] [[package]] @@ -4353,16 +4341,16 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gix-actor" -version = "0.31.4" +version = "0.31.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b8ee65074b2bbb91d9d97c15d172ea75043aefebf9869b5b329149dc76501c" +checksum = "a0e454357e34b833cc3a00b6efbbd3dd4d18b24b9fb0c023876ec2645e8aa3f2" dependencies = [ - "bstr 1.9.1", + "bstr", "gix-date", "gix-utils", "itoa", "thiserror", - "winnow 0.6.14", + "winnow 0.6.16", ] [[package]] @@ -4371,7 +4359,7 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7580e05996e893347ad04e1eaceb92e1c0e6a3ffe517171af99bf6b6df0ca6e5" dependencies = [ - "bstr 1.9.1", + "bstr", "gix-config-value", "gix-features", "gix-glob", @@ -4383,17 +4371,17 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow 0.6.14", + "winnow 0.6.16", ] [[package]] name = "gix-config-value" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd06203b1a9b33a78c88252a625031b094d9e1b647260070c25b09910c0a804" +checksum = "b328997d74dd15dc71b2773b162cb4af9a25c424105e4876e6d0686ab41c383e" dependencies = [ "bitflags 2.6.0", - "bstr 1.9.1", + "bstr", "gix-path", "libc", "thiserror", @@ -4405,7 +4393,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eed6931f21491ee0aeb922751bd7ec97b4b2fe8fbfedcb678e2a2dce5f3b8c0" dependencies = [ - "bstr 1.9.1", + "bstr", "itoa", "thiserror", "time", @@ -4438,12 +4426,12 @@ dependencies = [ [[package]] name = "gix-glob" -version = "0.16.3" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a29ad0990cf02c48a7aac76ed0dbddeb5a0d070034b83675cc3bbf937eace4" +checksum = "fa7df15afa265cc8abe92813cd354d522f1ac06b29ec6dfa163ad320575cb447" dependencies = [ "bitflags 2.6.0", - "bstr 1.9.1", + "bstr", "gix-features", "gix-path", ] @@ -4475,7 +4463,7 @@ version = "0.42.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25da2f46b4e7c2fa7b413ce4dffb87f69eaf89c2057e386491f4c55cadbfe386" dependencies = [ - "bstr 1.9.1", + "bstr", "gix-actor", "gix-date", "gix-features", @@ -4485,7 +4473,7 @@ dependencies = [ "itoa", "smallvec", "thiserror", - "winnow 0.6.14", + "winnow 0.6.16", ] [[package]] @@ -4494,7 +4482,7 @@ version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d23d5bbda31344d8abc8de7c075b3cf26e5873feba7c4a15d916bce67382bd9" dependencies = [ - "bstr 1.9.1", + "bstr", "gix-trace", "home", "once_cell", @@ -4520,14 +4508,14 @@ dependencies = [ "gix-validate", "memmap2", "thiserror", - "winnow 0.6.14", + "winnow 0.6.16", ] [[package]] name = "gix-sec" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fddc27984a643b20dd03e97790555804f98cf07404e0e552c0ad8133266a79a1" +checksum = "1547d26fa5693a7f34f05b4a3b59a90890972922172653bcb891ab3f09f436df" dependencies = [ "bitflags 2.6.0", "gix-path", @@ -4570,7 +4558,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82c27dd34a49b1addf193c92070bcbf3beaf6e10f16a78544de6372e146a0acf" dependencies = [ - "bstr 1.9.1", + "bstr", "thiserror", ] @@ -4587,7 +4575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", - "bstr 1.9.1", + "bstr", "log", "regex-automata 0.4.7", "regex-syntax 0.8.4", @@ -4732,7 +4720,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -4895,7 +4883,7 @@ dependencies = [ "http 1.1.0", "hyper 1.4.1", "hyper-util", - "rustls 0.23.11", + "rustls 0.23.12", "rustls-native-certs 0.7.1", "rustls-pki-types", "tokio", @@ -5149,9 +5137,9 @@ dependencies = [ [[package]] name = "interprocess" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67bafc2f5dbdad79a6d925649758d5472647b416028099f0b829d1b67fdd47d3" +checksum = "d2f4e4a06d42fab3e85ab1b419ad32b09eab58b901d40c57935ff92db3287a13" dependencies = [ "doctest-file", "futures-core", @@ -5181,9 +5169,9 @@ dependencies = [ [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -5229,9 +5217,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] @@ -5595,7 +5583,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -5641,6 +5629,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "mockall" version = "0.12.1" @@ -5665,7 +5665,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -5770,7 +5770,7 @@ dependencies = [ "kqueue", "libc", "log", - "mio", + "mio 0.8.11", "walkdir", "windows-sys 0.48.0", ] @@ -5903,7 +5903,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -5986,7 +5986,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8df34be653210fbe9ffaff41d3b92721c56ce82dfee58ee684f9afb5e3a90c0" dependencies = [ - "bstr 1.9.1", + "bstr", "dbus", "normpath", "windows-sys 0.52.0", @@ -5994,9 +5994,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.65" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2823eb4c6453ed64055057ea8bd416eda38c71018723869dd043a3b1186115e" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -6015,7 +6015,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6201,7 +6201,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6260,7 +6260,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6344,7 +6344,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6402,7 +6402,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6487,9 +6487,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "predicates" -version = "3.1.0" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" dependencies = [ "anstyle", "predicates-core", @@ -6497,15 +6497,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" [[package]] name = "predicates-tree" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" dependencies = [ "predicates-core", "termtree", @@ -6518,7 +6518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6594,7 +6594,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", "version_check", "yansi", ] @@ -6691,7 +6691,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6701,10 +6701,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -6789,7 +6789,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 1.1.0", - "rustls 0.23.11", + "rustls 0.23.12", "thiserror", "tokio", "tracing", @@ -6805,7 +6805,7 @@ dependencies = [ "rand", "ring", "rustc-hash 1.1.0", - "rustls 0.23.11", + "rustls 0.23.12", "slab", "thiserror", "tinyvec", @@ -6814,14 +6814,13 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" dependencies = [ "libc", "once_cell", "socket2", - "tracing", "windows-sys 0.52.0", ] @@ -7087,7 +7086,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.11", + "rustls 0.23.12", "rustls-native-certs 0.7.1", "rustls-pemfile 2.1.2", "rustls-pki-types", @@ -7126,9 +7125,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2dc001e37ac3b061dc9087876aea91e28756c188a97cd99416d23a5562ca73" +checksum = "5296ccad8d7ccbeb6c5a037a57bfe1ff27e81d8c4efbd3ae7df0a554eb1a818a" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7388,21 +7387,21 @@ dependencies = [ "log", "ring", "rustls-pki-types", - "rustls-webpki 0.102.5", + "rustls-webpki 0.102.6", "subtle", "zeroize", ] [[package]] name = "rustls" -version = "0.23.11" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.5", + "rustls-webpki 0.102.6", "subtle", "zeroize", ] @@ -7469,9 +7468,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.5" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring", "rustls-pki-types", @@ -7569,9 +7568,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.4" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4465c22496331e20eb047ff46e7366455bc01c0c02015c4a376de0b2cd3a1af" +checksum = "1fadf67e3cf23f8b11a6c8c48a16cb2437381503615acd91094ec7b4686a5a53" dependencies = [ "sdd", ] @@ -7606,7 +7605,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -7768,7 +7767,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -7779,7 +7778,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -7822,14 +7821,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -7881,7 +7880,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -7897,9 +7896,9 @@ dependencies = [ [[package]] name = "sha1_smol" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" [[package]] name = "sha2" @@ -7983,7 +7982,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", - "mio", + "mio 0.8.11", "signal-hook", ] @@ -8014,11 +8013,11 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "similar" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" dependencies = [ - "bstr 0.2.17", + "bstr", "unicode-segmentation", ] @@ -8076,9 +8075,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snapbox" -version = "0.6.13" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d656960fa127e80ade23c321d8c573bb9ba462c3a69e62ede635fc180ffc6cc" +checksum = "027c936207f85d10d015e21faf5c676c7e08c453ed371adf55c0874c443ca77a" dependencies = [ "anstream", "anstyle", @@ -8091,9 +8090,9 @@ dependencies = [ [[package]] name = "snapbox-macros" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f4c14672714436c09254801c934b203196a51182a5107fb76591c7cc56424d" +checksum = "16569f53ca23a41bb6f62e0a5084aa1661f4814a67fa33696a79073e03a664af" dependencies = [ "anstream", ] @@ -8142,8 +8141,8 @@ dependencies = [ "sha256", "simple-home-dir", "tokio", - "toml 0.8.15", - "toml_edit 0.22.16", + "toml 0.8.16", + "toml_edit 0.22.17", "uuid 1.10.0", "walkdir", "yansi", @@ -8175,7 +8174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -8241,7 +8240,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -8309,9 +8308,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.71" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -8327,7 +8326,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -8449,7 +8448,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -8560,21 +8559,20 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.1", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -8589,13 +8587,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -8635,7 +8633,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.11", + "rustls 0.23.12", "rustls-pki-types", "tokio", ] @@ -8672,7 +8670,7 @@ checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" dependencies = [ "futures-util", "log", - "rustls 0.23.11", + "rustls 0.23.12", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -8704,22 +8702,22 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.16", + "toml_edit 0.22.17", ] [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" dependencies = [ "serde", ] @@ -8737,15 +8735,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.14", + "winnow 0.6.16", ] [[package]] @@ -8874,7 +8872,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -9009,7 +9007,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.11", + "rustls 0.23.12", "rustls-pki-types", "sha1", "thiserror", @@ -9208,9 +9206,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vsimd" @@ -9273,7 +9271,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -9307,7 +9305,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9464,21 +9462,21 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.54.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" dependencies = [ - "windows-core 0.54.0", + "windows-core 0.56.0", "windows-targets 0.52.6", ] [[package]] name = "windows" -version = "0.56.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ - "windows-core 0.56.0", + "windows-core 0.58.0", "windows-targets 0.52.6", ] @@ -9493,23 +9491,26 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.54.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" dependencies = [ - "windows-result", + "windows-implement 0.56.0", + "windows-interface 0.56.0", + "windows-result 0.1.2", "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.56.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "windows-implement", - "windows-interface", - "windows-result", + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings", "windows-targets 0.52.6", ] @@ -9521,7 +9522,18 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] @@ -9532,7 +9544,18 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] @@ -9544,6 +9567,25 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -9694,9 +9736,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.14" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" +checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" dependencies = [ "memchr", ] @@ -9798,7 +9840,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] @@ -9818,7 +9860,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.71", + "syn 2.0.72", ] [[package]] From 741db53f3dfdcbe8c935e52492e5a0b7058f4169 Mon Sep 17 00:00:00 2001 From: "Nathan H. Leung" Date: Sun, 28 Jul 2024 02:20:28 -0700 Subject: [PATCH 1298/1963] fix(cheatcodes): clarify vm.expectRevert error message (#8463) --- crates/cheatcodes/src/test/expect.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 4dc53550832c2..80d2417ec3752 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -555,7 +555,7 @@ pub(crate) fn handle_expect_revert( } }; - ensure!(!matches!(status, return_ok!()), "call did not revert as expected"); + ensure!(!matches!(status, return_ok!()), "next call did not revert as expected"); // If None, accept any revert let Some(expected_revert) = expected_revert else { From 682286017eea36ee6309fc659a41167f265c56db Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 28 Jul 2024 12:18:09 +0200 Subject: [PATCH 1299/1963] fix(cheatcodes): get artifact code panic (#8546) --- crates/cheatcodes/src/fs.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 129f8a22e939e..177037c905b6b 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -387,10 +387,10 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result>(); - let artifact = match filtered.len() { - 0 => Err(fmt_err!("No matching artifact found")), - 1 => Ok(filtered[0]), - _ => { + let artifact = match &filtered[..] { + [] => Err(fmt_err!("No matching artifact found")), + [artifact] => Ok(artifact), + filtered => { // If we know the current script/test contract solc version, try to filter by it state .config @@ -398,11 +398,10 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result>(); - - (filtered.len() == 1).then_some(filtered[0]) + (filtered.len() == 1).then(|| filtered[0]) }) .ok_or_else(|| fmt_err!("Multiple matching artifacts found")) } From adc2132633b873a66d87831e503ba4d1f61d2100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:34:19 +0200 Subject: [PATCH 1300/1963] feat(cheatcodes): implement EIP-2098 in `vm.sign` (#8538) * feat: implement EIP-2098 in vm.sign * fix: clippy * test: fix * fix: forge-fmt * chore: implement new cheatcode vm.signEIP2098 * fix: typos * fix: another typo * fix * test: update sign tests * fix: typo * chore: rename `vm.signEIP2098()` into `vm.signCompact()` * chore: update `encode_compact_signature` impl * chore: update `signCompact` tests * chore: factorize * chore: rename fns * chore: nit * fix: issue * chore: nits --- crates/cheatcodes/assets/cheatcodes.json | 80 ++++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 40 ++++++++++++ crates/cheatcodes/src/evm.rs | 33 +++++++++- crates/cheatcodes/src/utils.rs | 35 ++++++++--- testdata/cheats/Vm.sol | 4 ++ testdata/default/cheats/Sign.t.sol | 24 +++++++ testdata/default/cheats/Wallet.t.sol | 26 ++++++++ 7 files changed, 231 insertions(+), 11 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 61f6264777059..c66f3a5ecc84e 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7751,6 +7751,86 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "signCompact_0", + "description": "Signs `digest` with `privateKey` using the secp256k1 curve.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.", + "declaration": "function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);", + "visibility": "external", + "mutability": "pure", + "signature": "signCompact(uint256,bytes32)", + "selector": "0xcc2a781f", + "selectorBytes": [ + 204, + 42, + 120, + 31 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "signCompact_1", + "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.\nIf `--sender` is provided, the signer with provided address is used, otherwise,\nif exactly one signer is provided to the script, that signer is used.\nRaises error if signer passed through `--sender` does not match any unlocked signers or\nif `--sender` is not provided and not exactly one signer is passed to the script.", + "declaration": "function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);", + "visibility": "external", + "mutability": "pure", + "signature": "signCompact(bytes32)", + "selector": "0xa282dc4b", + "selectorBytes": [ + 162, + 130, + 220, + 75 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "signCompact_2", + "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.\nRaises error if none of the signers passed into the script have provided address.", + "declaration": "function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);", + "visibility": "external", + "mutability": "pure", + "signature": "signCompact(address,bytes32)", + "selector": "0x8e2f97bf", + "selectorBytes": [ + 142, + 47, + 151, + 191 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "signCompact_3", + "description": "Signs data with a `Wallet`.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.", + "declaration": "function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);", + "visibility": "external", + "mutability": "", + "signature": "signCompact((address,uint256,uint256,uint256),bytes32)", + "selector": "0x3d0e292f", + "selectorBytes": [ + 61, + 14, + 41, + 47 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "signP256", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 935d44e53a4e0..685a6f751ff1f 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -286,6 +286,14 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + /// Signs `digest` with `privateKey` using the secp256k1 curve. + /// + /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the + /// signature's `s` value, and the recovery id `v` in a single bytes32. + /// This format reduces the signature size from 65 to 64 bytes. + #[cheatcode(group = Evm, safety = Safe)] + function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + /// Signs `digest` with signer provided to script using the secp256k1 curve. /// /// If `--sender` is provided, the signer with provided address is used, otherwise, @@ -296,12 +304,36 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the + /// signature's `s` value, and the recovery id `v` in a single bytes32. + /// This format reduces the signature size from 65 to 64 bytes. + /// + /// If `--sender` is provided, the signer with provided address is used, otherwise, + /// if exactly one signer is provided to the script, that signer is used. + /// + /// Raises error if signer passed through `--sender` does not match any unlocked signers or + /// if `--sender` is not provided and not exactly one signer is passed to the script. + #[cheatcode(group = Evm, safety = Safe)] + function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + /// Signs `digest` with signer provided to script using the secp256k1 curve. /// /// Raises error if none of the signers passed into the script have provided address. #[cheatcode(group = Evm, safety = Safe)] function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the + /// signature's `s` value, and the recovery id `v` in a single bytes32. + /// This format reduces the signature size from 65 to 64 bytes. + /// + /// Raises error if none of the signers passed into the script have provided address. + #[cheatcode(group = Evm, safety = Safe)] + function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + /// Signs `digest` with `privateKey` using the secp256r1 curve. #[cheatcode(group = Evm, safety = Safe)] function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); @@ -2153,6 +2185,14 @@ interface Vm { #[cheatcode(group = Utilities)] function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); + /// Signs data with a `Wallet`. + /// + /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the + /// signature's `s` value, and the recovery id `v` in a single bytes32. + /// This format reduces the signature size from 65 to 64 bytes. + #[cheatcode(group = Utilities)] + function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs); + /// Derive a private key from a provided mnenomic string (or mnenomic file path) /// at the derivation path `m/44'/60'/0'/0/{index}`. #[cheatcode(group = Utilities)] diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 97923a948791c..5e24070a8caa7 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -162,21 +162,48 @@ impl Cheatcode for dumpStateCall { impl Cheatcode for sign_0Call { fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { let Self { privateKey, digest } = self; - super::utils::sign(privateKey, digest) + let sig = super::utils::sign(privateKey, digest)?; + Ok(super::utils::encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_0Call { + fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { + let Self { privateKey, digest } = self; + let sig = super::utils::sign(privateKey, digest)?; + Ok(super::utils::encode_compact_sig(sig)) } } impl Cheatcode for sign_1Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { digest } = self; - super::utils::sign_with_wallet(ccx, None, digest) + let sig = super::utils::sign_with_wallet(ccx, None, digest)?; + Ok(super::utils::encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { digest } = self; + let sig = super::utils::sign_with_wallet(ccx, None, digest)?; + Ok(super::utils::encode_compact_sig(sig)) } } impl Cheatcode for sign_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { signer, digest } = self; - super::utils::sign_with_wallet(ccx, Some(*signer), digest) + let sig = super::utils::sign_with_wallet(ccx, Some(*signer), digest)?; + Ok(super::utils::encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { signer, digest } = self; + let sig = super::utils::sign_with_wallet(ccx, Some(*signer), digest)?; + Ok(super::utils::encode_compact_sig(sig)) } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 08e2553417145..67b154ff246b5 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -55,7 +55,16 @@ impl Cheatcode for getNonce_1Call { impl Cheatcode for sign_3Call { fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { let Self { wallet, digest } = self; - sign(&wallet.privateKey, digest) + let sig = sign(&wallet.privateKey, digest)?; + Ok(encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_3Call { + fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { + let Self { wallet, digest } = self; + let sig = sign(&wallet.privateKey, digest)?; + Ok(encode_compact_sig(sig)) } } @@ -201,25 +210,35 @@ fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes .abi_encode()) } -fn encode_vrs(sig: alloy_primitives::Signature) -> Vec { - let v = sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte()); +pub(super) fn encode_full_sig(sig: alloy_primitives::Signature) -> Vec { + // Retrieve v, r and s from signature. + let v = U256::from(sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte())); + let r = B256::from(sig.r()); + let s = B256::from(sig.s()); + (v, r, s).abi_encode() +} - (U256::from(v), B256::from(sig.r()), B256::from(sig.s())).abi_encode() +pub(super) fn encode_compact_sig(sig: alloy_primitives::Signature) -> Vec { + // Implement EIP-2098 compact signature. + let r = B256::from(sig.r()); + let mut vs = sig.s(); + vs.set_bit(255, sig.v().y_parity()); + (r, vs).abi_encode() } -pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { +pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. let wallet = parse_wallet(private_key)?; let sig = wallet.sign_hash_sync(digest)?; debug_assert_eq!(sig.recover_address_from_prehash(digest)?, wallet.address()); - Ok(encode_vrs(sig)) + Ok(sig) } pub(super) fn sign_with_wallet( ccx: &mut CheatsCtxt, signer: Option
, digest: &B256, -) -> Result { +) -> Result { let Some(script_wallets) = ccx.state.script_wallets() else { bail!("no wallets are available"); }; @@ -244,7 +263,7 @@ pub(super) fn sign_with_wallet( let sig = foundry_common::block_on(wallet.sign_hash(digest))?; debug_assert_eq!(sig.recover_address_from_prehash(digest)?, signer); - Ok(encode_vrs(sig)) + Ok(sig) } pub(super) fn sign_p256(private_key: &U256, digest: &B256, _state: &mut Cheatcodes) -> Result { diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index f42fb22983ea8..4a9d9cd69a274 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -383,6 +383,10 @@ interface Vm { function setEnv(string calldata name, string calldata value) external; function setNonce(address account, uint64 newNonce) external; function setNonceUnsafe(address account, uint64 newNonce) external; + function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs); function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); diff --git a/testdata/default/cheats/Sign.t.sol b/testdata/default/cheats/Sign.t.sol index e46439b58d16d..a257d62919efb 100644 --- a/testdata/default/cheats/Sign.t.sol +++ b/testdata/default/cheats/Sign.t.sol @@ -13,11 +13,35 @@ contract SignTest is DSTest { (uint8 v, bytes32 r, bytes32 s) = vm.sign(pk, digest); address expected = vm.addr(pk); address actual = ecrecover(digest, v, r, s); + assertEq(actual, expected, "digest signer did not match"); + } + + function testSignCompactDigest(uint248 pk, bytes32 digest) public { + vm.assume(pk != 0); + + (bytes32 r, bytes32 vs) = vm.signCompact(pk, digest); + + // Extract `s` from `vs`. + // Shift left by 1 bit to clear the leftmost bit, then shift right by 1 bit to restore the original position. + // This effectively clears the leftmost bit of `vs`, giving us `s`. + bytes32 s = bytes32((uint256(vs) << 1) >> 1); + // Extract `v` from `vs`. + // We shift `vs` right by 255 bits to isolate the leftmost bit. + // Converting this to uint8 gives us the parity bit (0 or 1). + // Adding 27 converts this parity bit to the correct `v` value (27 or 28). + uint8 v = uint8(uint256(vs) >> 255) + 27; + + address expected = vm.addr(pk); + address actual = ecrecover(digest, v, r, s); assertEq(actual, expected, "digest signer did not match"); } function testSignMessage(uint248 pk, bytes memory message) public { testSignDigest(pk, keccak256(message)); } + + function testSignCompactMessage(uint248 pk, bytes memory message) public { + testSignCompactDigest(pk, keccak256(message)); + } } diff --git a/testdata/default/cheats/Wallet.t.sol b/testdata/default/cheats/Wallet.t.sol index 8ecb707aec920..5a7035876cd0c 100644 --- a/testdata/default/cheats/Wallet.t.sol +++ b/testdata/default/cheats/Wallet.t.sol @@ -104,10 +104,36 @@ contract WalletTest is DSTest { assertEq(recovered, wallet.addr); } + function testSignCompactWithWalletDigest(uint256 pkSeed, bytes32 digest) public { + uint256 pk = bound(pkSeed, 1, Q - 1); + + Vm.Wallet memory wallet = vm.createWallet(pk); + + (bytes32 r, bytes32 vs) = vm.signCompact(wallet, digest); + + // Extract `s` from `vs`. + // Shift left by 1 bit to clear the leftmost bit, then shift right by 1 bit to restore the original position. + // This effectively clears the leftmost bit of `vs`, giving us `s`. + bytes32 s = bytes32((uint256(vs) << 1) >> 1); + + // Extract `v` from `vs`. + // We shift `vs` right by 255 bits to isolate the leftmost bit. + // Converting this to uint8 gives us the parity bit (0 or 1). + // Adding 27 converts this parity bit to the correct `v` value (27 or 28). + uint8 v = uint8(uint256(vs) >> 255) + 27; + + address recovered = ecrecover(digest, v, r, s); + assertEq(recovered, wallet.addr); + } + function testSignWithWalletMessage(uint256 pkSeed, bytes memory message) public { testSignWithWalletDigest(pkSeed, keccak256(message)); } + function testSignCompactWithWalletMessage(uint256 pkSeed, bytes memory message) public { + testSignCompactWithWalletDigest(pkSeed, keccak256(message)); + } + function testGetNonceWallet(uint256 pkSeed) public { uint256 pk = bound(pkSeed, 1, Q - 1); From 108b8d1d2426424a4a1ced998db5a8640fd5ab8d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 29 Jul 2024 17:34:46 +0800 Subject: [PATCH 1301/1963] fix(`verify-bytecode`): extract constructor arguments from creation code (#8547) fix verify-bytecode: extract constructor arguments from creation code --- crates/verify/src/bytecode.rs | 109 ++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 51 deletions(-) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index a0b3a7c844c73..5834e961f1795 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -147,6 +147,44 @@ impl VerifyBytecodeArgs { }; let etherscan = Client::new(chain, key)?; + // Get creation tx hash + let creation_data = etherscan.contract_creation_data(self.address).await?; + + trace!(creation_tx_hash = ?creation_data.transaction_hash); + let mut transaction = provider + .get_transaction_by_hash(creation_data.transaction_hash) + .await + .or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))? + .ok_or_else(|| { + eyre::eyre!("Transaction not found for hash {}", creation_data.transaction_hash) + })?; + let receipt = provider + .get_transaction_receipt(creation_data.transaction_hash) + .await + .or_else(|e| eyre::bail!("Couldn't fetch transaction receipt from RPC: {:?}", e))?; + + let receipt = if let Some(receipt) = receipt { + receipt + } else { + eyre::bail!( + "Receipt not found for transaction hash {}", + creation_data.transaction_hash + ); + }; + + // Extract creation code + let maybe_creation_code = + if receipt.to.is_none() && receipt.contract_address == Some(self.address) { + &transaction.input + } else if receipt.to == Some(DEFAULT_CREATE2_DEPLOYER) { + &transaction.input[32..] + } else { + eyre::bail!( + "Could not extract the creation code for contract at address {}", + self.address + ); + }; + // Get the constructor args using `source_code` endpoint let source_code = etherscan.contract_source_code(self.address).await?; @@ -168,6 +206,11 @@ impl VerifyBytecodeArgs { self.build_project(&config)? }; + let local_bytecode = artifact + .bytecode + .and_then(|b| b.into_bytes()) + .ok_or_eyre("Unlinked bytecode is not supported for verification")?; + // Get the constructor args from etherscan let mut constructor_args = if let Some(args) = source_code.items.first() { args.constructor_arguments.clone() @@ -201,63 +244,27 @@ impl VerifyBytecodeArgs { .or(self.encoded_constructor_args.to_owned().map(hex::decode).transpose()?); if let Some(provided) = provided_constructor_args { - if provided != constructor_args && !self.json { - println!( - "{}", - format!("The provided constructor args do not match the constructor args from etherscan ({constructor_args}).") - .yellow() - .bold(), - ); - } constructor_args = provided.into(); - } - - // Get creation tx hash - let creation_data = etherscan.contract_creation_data(self.address).await?; - - trace!(creation_tx_hash = ?creation_data.transaction_hash); - let mut transaction = provider - .get_transaction_by_hash(creation_data.transaction_hash) - .await - .or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))? - .ok_or_else(|| { - eyre::eyre!("Transaction not found for hash {}", creation_data.transaction_hash) - })?; - let receipt = provider - .get_transaction_receipt(creation_data.transaction_hash) - .await - .or_else(|e| eyre::bail!("Couldn't fetch transaction receipt from RPC: {:?}", e))?; - - let receipt = if let Some(receipt) = receipt { - receipt } else { - eyre::bail!( - "Receipt not found for transaction hash {}", - creation_data.transaction_hash - ); - }; - - // Extract creation code - let maybe_creation_code = - if receipt.to.is_none() && receipt.contract_address == Some(self.address) { - &transaction.input - } else if receipt.to == Some(DEFAULT_CREATE2_DEPLOYER) { - &transaction.input[32..] - } else { - eyre::bail!( - "Could not extract the creation code for contract at address {}", - self.address - ); - }; + // In some cases, Etherscan will return incorrect constructor arguments. If this + // happens, try extracting arguments ourselves. + if !maybe_creation_code.ends_with(&constructor_args) { + trace!("mismatch of constructor args with etherscan"); + // If local bytecode is longer than on-chain one, this is probably not a match. + if maybe_creation_code.len() >= local_bytecode.len() { + constructor_args = + Bytes::copy_from_slice(&maybe_creation_code[local_bytecode.len()..]); + trace!( + "setting constructor args to latest {} bytes of bytecode", + constructor_args.len() + ); + } + } + } // If bytecode_hash is disabled then its always partial verification let has_metadata = config.bytecode_hash == BytecodeHash::None; - let local_bytecode = artifact - .bytecode - .and_then(|b| b.into_bytes()) - .ok_or_eyre("Unlinked bytecode is not supported for verification")?; - // Append constructor args to the local_bytecode trace!(%constructor_args); let mut local_bytecode_vec = local_bytecode.to_vec(); From 9b1c48d608031d5f7fe14f9314b5dafdc26d7ca6 Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Mon, 29 Jul 2024 17:49:59 +0800 Subject: [PATCH 1302/1963] add `--max-persisted-states` to configure `max_on_disk_limit` (#8412) * set to limit * revert old changes * add max_persisted_states * fix fmt * add tests * fix * fix --------- Co-authored-by: Matthias Seitz --- crates/anvil/src/cmd.rs | 15 ++++++++ crates/anvil/src/config.rs | 14 ++++++++ crates/anvil/src/eth/backend/mem/mod.rs | 9 +++-- crates/anvil/src/eth/backend/mem/storage.rs | 39 ++++++++++++++++----- 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index e12c6b13ad33d..2897cebdda93a 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -162,9 +162,17 @@ pub struct NodeArgs { /// Don't keep full chain history. /// If a number argument is specified, at most this number of states is kept in memory. + /// + /// If enabled, no state will be persisted on disk, so `max_persisted_states` will be 0. #[arg(long)] pub prune_history: Option>, + /// Max number of states to persist on disk. + /// + /// Note that `prune_history` will overwrite `max_persisted_states` to 0. + #[arg(long)] + pub max_persisted_states: Option, + /// Number of blocks with transactions to keep in memory. #[arg(long)] pub transaction_block_keeper: Option, @@ -241,6 +249,7 @@ impl NodeArgs { .set_pruned_history(self.prune_history) .with_init_state(self.load_state.or_else(|| self.state.and_then(|s| s.state))) .with_transaction_block_keeper(self.transaction_block_keeper) + .with_max_persisted_states(self.max_persisted_states) .with_optimism(self.evm_opts.optimism) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) @@ -780,6 +789,12 @@ mod tests { assert_eq!(args.prune_history, Some(Some(100))); } + #[test] + fn can_parse_max_persisted_states_config() { + let args: NodeArgs = NodeArgs::parse_from(["anvil", "--max-persisted-states", "500"]); + assert_eq!(args.max_persisted_states, (Some(500))); + } + #[test] fn can_parse_disable_block_gas_limit() { let args: NodeArgs = NodeArgs::parse_from(["anvil", "--disable-block-gas-limit"]); diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 4ae1be0e97bfc..28080f628845e 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -167,6 +167,8 @@ pub struct NodeConfig { /// /// If set to `Some(num)` keep latest num state in memory only. pub prune_history: PruneStateHistoryConfig, + /// Max number of states cached on disk. + pub max_persisted_states: Option, /// The file where to load the state from pub init_state: Option, /// max number of blocks with transactions in memory @@ -427,6 +429,7 @@ impl Default for NodeConfig { ipc_path: None, code_size_limit: None, prune_history: Default::default(), + max_persisted_states: None, init_state: None, transaction_block_keeper: None, disable_default_create2_deployer: false, @@ -552,6 +555,16 @@ impl NodeConfig { self } + /// Sets max number of states to cache on disk. + #[must_use] + pub fn with_max_persisted_states>( + mut self, + max_persisted_states: Option, + ) -> Self { + self.max_persisted_states = max_persisted_states.map(Into::into); + self + } + /// Sets max number of blocks with transactions to keep in memory #[must_use] pub fn with_transaction_block_keeper>( @@ -974,6 +987,7 @@ impl NodeConfig { self.enable_steps_tracing, self.print_logs, self.prune_history, + self.max_persisted_states, self.transaction_block_keeper, self.block_time, Arc::new(tokio::sync::RwLock::new(self.clone())), diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 804ef74f41fa3..8f51ae04e3081 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -99,7 +99,7 @@ use std::{ sync::Arc, time::Duration, }; -use storage::{Blockchain, MinedTransaction}; +use storage::{Blockchain, MinedTransaction, DEFAULT_HISTORY_LIMIT}; use tokio::sync::RwLock as AsyncRwLock; pub mod cache; @@ -199,6 +199,7 @@ impl Backend { enable_steps_tracing: bool, print_logs: bool, prune_state_history_config: PruneStateHistoryConfig, + max_persisted_states: Option, transaction_block_keeper: Option, automine_block_time: Option, node_config: Arc>, @@ -225,9 +226,13 @@ impl Backend { // if prune state history is enabled, configure the state cache only for memory prune_state_history_config .max_memory_history - .map(InMemoryBlockStates::new) + .map(|limit| InMemoryBlockStates::new(limit, 0)) .unwrap_or_default() .memory_only() + } else if max_persisted_states.is_some() { + max_persisted_states + .map(|limit| InMemoryBlockStates::new(DEFAULT_HISTORY_LIMIT, limit)) + .unwrap_or_default() } else { Default::default() }; diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 692e669e58f54..aaa2f29e725a2 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -40,7 +40,7 @@ use std::{ // === various limits in number of blocks === -const DEFAULT_HISTORY_LIMIT: usize = 500; +pub const DEFAULT_HISTORY_LIMIT: usize = 500; const MIN_HISTORY_LIMIT: usize = 10; // 1hr of up-time at lowest 1s interval const MAX_ON_DISK_HISTORY_LIMIT: usize = 3_600; @@ -69,13 +69,13 @@ pub struct InMemoryBlockStates { impl InMemoryBlockStates { /// Creates a new instance with limited slots - pub fn new(limit: usize) -> Self { + pub fn new(in_memory_limit: usize, on_disk_limit: usize) -> Self { Self { states: Default::default(), on_disk_states: Default::default(), - in_memory_limit: limit, - min_in_memory_limit: limit.min(MIN_HISTORY_LIMIT), - max_on_disk_limit: MAX_ON_DISK_HISTORY_LIMIT, + in_memory_limit, + min_in_memory_limit: in_memory_limit.min(MIN_HISTORY_LIMIT), + max_on_disk_limit: on_disk_limit, oldest_on_disk: Default::default(), present: Default::default(), disk_cache: Default::default(), @@ -205,7 +205,7 @@ impl fmt::Debug for InMemoryBlockStates { impl Default for InMemoryBlockStates { fn default() -> Self { // enough in memory to store `DEFAULT_HISTORY_LIMIT` blocks in memory - Self::new(DEFAULT_HISTORY_LIMIT) + Self::new(DEFAULT_HISTORY_LIMIT, MAX_ON_DISK_HISTORY_LIMIT) } } @@ -545,9 +545,32 @@ mod tests { assert_eq!(storage.in_memory_limit, DEFAULT_HISTORY_LIMIT * 3); } + #[test] + fn test_init_state_limits() { + let mut storage = InMemoryBlockStates::default(); + assert_eq!(storage.in_memory_limit, DEFAULT_HISTORY_LIMIT); + assert_eq!(storage.min_in_memory_limit, MIN_HISTORY_LIMIT); + assert_eq!(storage.max_on_disk_limit, MAX_ON_DISK_HISTORY_LIMIT); + + storage = storage.memory_only(); + assert!(storage.is_memory_only()); + + storage = InMemoryBlockStates::new(1, 0); + assert!(storage.is_memory_only()); + assert_eq!(storage.in_memory_limit, 1); + assert_eq!(storage.min_in_memory_limit, 1); + assert_eq!(storage.max_on_disk_limit, 0); + + storage = InMemoryBlockStates::new(1, 2); + assert!(!storage.is_memory_only()); + assert_eq!(storage.in_memory_limit, 1); + assert_eq!(storage.min_in_memory_limit, 1); + assert_eq!(storage.max_on_disk_limit, 2); + } + #[tokio::test(flavor = "multi_thread")] async fn can_read_write_cached_state() { - let mut storage = InMemoryBlockStates::new(1); + let mut storage = InMemoryBlockStates::new(1, MAX_ON_DISK_HISTORY_LIMIT); let one = B256::from(U256::from(1)); let two = B256::from(U256::from(2)); @@ -573,7 +596,7 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn can_decrease_state_cache_size() { let limit = 15; - let mut storage = InMemoryBlockStates::new(limit); + let mut storage = InMemoryBlockStates::new(limit, MAX_ON_DISK_HISTORY_LIMIT); let num_states = 30; for idx in 0..num_states { From dc23de3f5a880c0487bc11fd60b9152f9d7b12bb Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:53:33 +0300 Subject: [PATCH 1303/1963] fix(anvil): apply Arbitrum specifics to API block (#8542) --- crates/anvil/src/eth/backend/mem/mod.rs | 23 ++++++++++++++++++++--- crates/anvil/tests/it/fork.rs | 5 +++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 8f51ae04e3081..b235646b514cd 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -67,6 +67,7 @@ use anvil_core::eth::{ }; use anvil_rpc::error::RpcError; +use alloy_chains::NamedChain; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, @@ -1645,7 +1646,7 @@ impl Backend { Some(block.into_full_block(transactions.into_iter().map(|t| t.inner).collect())) } - /// Takes a block as it's stored internally and returns the eth api conform block format + /// Takes a block as it's stored internally and returns the eth api conform block format. pub fn convert_block(&self, block: Block) -> AlloyBlock { let size = U256::from(alloy_rlp::encode(&block).len() as u32); @@ -1676,7 +1677,7 @@ impl Backend { parent_beacon_block_root, } = header; - AlloyBlock { + let mut block = AlloyBlock { header: AlloyHeader { hash: Some(hash), parent_hash, @@ -1709,7 +1710,23 @@ impl Backend { uncles: vec![], withdrawals: None, other: Default::default(), - } + }; + + // If Arbitrum, apply chain specifics to converted block. + if let Ok( + NamedChain::Arbitrum | + NamedChain::ArbitrumGoerli | + NamedChain::ArbitrumNova | + NamedChain::ArbitrumTestnet, + ) = NamedChain::try_from(self.env.read().env.cfg.chain_id) + { + // Block number is the best number. + block.header.number = Some(self.best_number()); + // Set `l1BlockNumber` field. + block.other.insert("l1BlockNumber".to_string(), number.into()); + } + + block } /// Converts the `BlockNumber` into a numeric value diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index b27b361b26e78..8a4542b488d84 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1165,6 +1165,11 @@ async fn test_arbitrum_fork_block_number() { let block_number = api.block_number().unwrap().to::(); assert_eq!(block_number, initial_block_number + 1); + // test block by number API call returns proper block number and `l1BlockNumber` is set + let block_by_number = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert_eq!(block_by_number.header.number.unwrap(), initial_block_number + 1); + assert!(block_by_number.other.get("l1BlockNumber").is_some()); + // revert to recorded snapshot and check block number assert!(api.evm_revert(snapshot).await.unwrap()); let block_number = api.block_number().unwrap().to::(); From d5ff3d3ecb86643bc40c72ad0687d1e1d0d05ab4 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:04:21 +0200 Subject: [PATCH 1304/1963] fix: add `Mantle` + `Mantle testnet` as exceptions for gas calculation during deployment (#8553) --- crates/cli/src/utils/cmd.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 3b5d2bdf80461..c7f9c1c2ba3d9 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -164,13 +164,15 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { return matches!( chain, NamedChain::Arbitrum | - NamedChain::ArbitrumTestnet | NamedChain::ArbitrumGoerli | NamedChain::ArbitrumSepolia | - NamedChain::Moonbeam | - NamedChain::Moonriver | + NamedChain::ArbitrumTestnet | + NamedChain::Mantle | + NamedChain::MantleTestnet | NamedChain::Moonbase | - NamedChain::MoonbeamDev + NamedChain::Moonbeam | + NamedChain::MoonbeamDev | + NamedChain::Moonriver ); } false From d1b25134ad0144cc14f6a44a6c6df5f5423e7253 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:22:23 +0300 Subject: [PATCH 1305/1963] fix(coverage): proper single path branch support (#8552) --- crates/evm/coverage/src/analysis.rs | 117 +++++++++++++++------------- crates/evm/coverage/src/lib.rs | 10 ++- crates/forge/src/coverage.rs | 7 ++ crates/forge/tests/cli/coverage.rs | 86 +++++++++++++++++--- 4 files changed, 158 insertions(+), 62 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 3eb16332d02e8..e28346181857f 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -211,59 +211,64 @@ impl<'a> ContractVisitor<'a> { // branch ID as we do. self.branch_id += 1; - // The relevant source range for the true branch is the `if(...)` statement itself - // and the true body of the if statement. The false body of the - // statement (if any) is processed as its own thing. If this source - // range is not processed like this, it is virtually impossible to - // correctly map instructions back to branches that include more - // complex logic like conditional logic. - let true_branch_loc = &ast::LowFidelitySourceLocation { - start: node.src.start, - length: true_body - .src - .length - .map(|length| true_body.src.start - node.src.start + length), - index: node.src.index, - }; - - // Add the coverage item for branch 0 (true body). - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, - loc: self.source_location_for(true_branch_loc), - hits: 0, - }); - match node.attribute::("falseBody") { // Both if/else statements. Some(false_body) => { - // Add the coverage item for branch 1 (false body). - // The relevant source range for the false branch is the `else` statement - // itself and the false body of the else statement. - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, - loc: self.source_location_for(&ast::LowFidelitySourceLocation { - start: node.src.start, - length: false_body.src.length.map(|length| { - false_body.src.start - true_body.src.start + length + // Add branch coverage items only if one of true/branch bodies contains + // statements. + if has_statements(&true_body) || has_statements(&false_body) { + // Add the coverage item for branch 0 (true body). + // The relevant source range for the true branch is the `if(...)` + // statement itself and the true body of the if statement. + // + // The false body of the statement is processed as its own thing. + // If this source range is not processed like this, it is virtually + // impossible to correctly map instructions back to branches that + // include more complex logic like conditional logic. + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, + loc: self.source_location_for(&ast::LowFidelitySourceLocation { + start: node.src.start, + length: true_body.src.length.map(|length| { + true_body.src.start - node.src.start + length + }), + index: node.src.index, }), - index: node.src.index, - }), - hits: 0, - }); - // Process the true body. - self.visit_block_or_statement(&true_body)?; - // Process the false body. - self.visit_block_or_statement(&false_body)?; + hits: 0, + }); + // Add the coverage item for branch 1 (false body). + // The relevant source range for the false branch is the `else` + // statement itself and the false body of the else statement. + self.push_item(CoverageItem { + kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, + loc: self.source_location_for(&ast::LowFidelitySourceLocation { + start: node.src.start, + length: false_body.src.length.map(|length| { + false_body.src.start - true_body.src.start + length + }), + index: node.src.index, + }), + hits: 0, + }); + + // Process the true body. + self.visit_block_or_statement(&true_body)?; + // Process the false body. + self.visit_block_or_statement(&false_body)?; + } } None => { - // Add the coverage item for branch 1 (same true body). - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, - loc: self.source_location_for(true_branch_loc), - hits: 0, - }); - // Process the true body. - self.visit_block_or_statement(&true_body)?; + // Add single branch coverage only if it contains statements. + if has_statements(&true_body) { + // Add the coverage item for branch 0 (true body). + self.push_item(CoverageItem { + kind: CoverageItemKind::SinglePathBranch { branch_id }, + loc: self.source_location_for(&true_body.src), + hits: 0, + }); + // Process the true body. + self.visit_block_or_statement(&true_body)?; + } } } @@ -321,9 +326,7 @@ impl<'a> ContractVisitor<'a> { // Add coverage for clause body only if it is not empty. if let Some(block) = clause.attribute::("block") { - let statements: Vec = - block.attribute("statements").unwrap_or_default(); - if !statements.is_empty() { + if has_statements(&block) { self.push_item(CoverageItem { kind: CoverageItemKind::Statement, loc: self.source_location_for(&block.src), @@ -502,8 +505,12 @@ impl<'a> ContractVisitor<'a> { let source_location = &item.loc; // Push a line item if we haven't already - if matches!(item.kind, CoverageItemKind::Statement | CoverageItemKind::Branch { .. }) && - self.last_line < source_location.line + if matches!( + item.kind, + CoverageItemKind::Statement | + CoverageItemKind::Branch { .. } | + CoverageItemKind::SinglePathBranch { .. } + ) && self.last_line < source_location.line { self.items.push(CoverageItem { kind: CoverageItemKind::Line, @@ -527,6 +534,12 @@ impl<'a> ContractVisitor<'a> { } } +/// Helper function to check if a given node contains any statement. +fn has_statements(node: &Node) -> bool { + let statements: Vec = node.attribute("statements").unwrap_or_default(); + !statements.is_empty() +} + /// [`SourceAnalyzer`] result type. #[derive(Debug)] pub struct SourceAnalysis { diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 67822bd8eaaff..24390aa12124c 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -295,6 +295,11 @@ pub enum CoverageItemKind { /// The first path has ID 0, the next ID 1, and so on. path_id: usize, }, + /// A branch in the code. + SinglePathBranch { + /// The ID that identifies the branch. + branch_id: usize, + }, /// A function in the code. Function { /// The name of the function. @@ -324,6 +329,9 @@ impl Display for CoverageItem { CoverageItemKind::Branch { branch_id, path_id } => { write!(f, "Branch (branch: {branch_id}, path: {path_id})")?; } + CoverageItemKind::SinglePathBranch { branch_id } => { + write!(f, "Branch (branch: {branch_id}, path: 0)")?; + } CoverageItemKind::Function { name } => { write!(f, r#"Function "{name}""#)?; } @@ -408,7 +416,7 @@ impl AddAssign<&CoverageItem> for CoverageSummary { self.statement_hits += 1; } } - CoverageItemKind::Branch { .. } => { + CoverageItemKind::Branch { .. } | CoverageItemKind::SinglePathBranch { .. } => { self.branch_count += 1; if item.hits > 0 { self.branch_hits += 1; diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index cab9374884356..cc83e132975c8 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -116,6 +116,13 @@ impl<'a> CoverageReporter for LcovReporter<'a> { if hits == 0 { "-".to_string() } else { hits.to_string() } )?; } + CoverageItemKind::SinglePathBranch { branch_id } => { + writeln!( + self.destination, + "BRDA:{line},{branch_id},0,{}", + if hits == 0 { "-".to_string() } else { hits.to_string() } + )?; + } // Statements are not in the LCOV format. // We don't add them in order to avoid doubling line hits. _ => {} diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index f9d591fe2df37..e8999a7f3aad8 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -464,6 +464,27 @@ contract Foo { } return true; } + + function checkEmptyStatements(uint256 number, uint256[] memory arr) external pure returns (bool) { + // Check that empty statements are covered. + if (number >= arr[0]) { + // Do nothing + } else { + // Do nothing. + } + if (number >= arr[0]) {} + + return true; + } + + function singlePathCoverage(uint256 number) external pure { + if (number < 10) { + if (number < 5) { + number++; + } + number++; + } + } } "#, ) @@ -562,23 +583,70 @@ contract FooTest is DSTest { bool result = foo.checkLt(number, arr); assertTrue(result); } + + function test_issue_4314() external { + uint256[] memory arr = new uint256[](1); + arr[0] = 1; + foo.checkEmptyStatements(0, arr); + } + + function test_single_path_child_branch() external { + foo.singlePathCoverage(1); + } + + function test_single_path_parent_branch() external { + foo.singlePathCoverage(9); + } + + function test_single_path_branch() external { + foo.singlePathCoverage(15); + } } "#, ) .unwrap(); - // TODO: fix following issues for 100% coverage - // https://github.com/foundry-rs/foundry/issues/4309 - // https://github.com/foundry-rs/foundry/issues/4310 - // https://github.com/foundry-rs/foundry/issues/4315 - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + // Assert no coverage for single path branch. 2 branches (parent and child) not covered. + cmd.arg("coverage") + .args([ + "--nmt".to_string(), + "test_single_path_child_branch|test_single_path_parent_branch".to_string(), + ]) + .assert_success() + .stdout_eq(str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------|-----------------|-----------------|----------------|---------------| -| src/Foo.sol | 100.00% (20/20) | 100.00% (23/23) | 83.33% (15/18) | 100.00% (7/7) | -| Total | 100.00% (20/20) | 100.00% (23/23) | 83.33% (15/18) | 100.00% (7/7) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|----------------|----------------|----------------|---------------| +| src/Foo.sol | 88.89% (24/27) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | +| Total | 88.89% (24/27) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | "#]]); + + // Assert no coverage for single path child branch. 1 branch (child) not covered. + cmd.forge_fuse() + .arg("coverage") + .args(["--nmt".to_string(), "test_single_path_child_branch".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|----------------|----------------|----------------|---------------| +| src/Foo.sol | 96.30% (26/27) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | +| Total | 96.30% (26/27) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | + +"#]]); + + // Assert 100% coverage. + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|-----------------|-----------------|-----------------|---------------| +| src/Foo.sol | 100.00% (27/27) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | +| Total | 100.00% (27/27) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | + +"#]], + ); }); forgetest!(test_function_call_coverage, |prj, cmd| { From 5161091748185e047ef6f368bec2ce22f5a0b65b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:32:49 +0300 Subject: [PATCH 1306/1963] chore: potential fix flaky test_invariant_assert_shrink (#8554) --- crates/forge/tests/it/invariant.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 72c3e7bd7b84b..e4bf14ecdc735 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -285,23 +285,27 @@ async fn test_invariant_shrink() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_assert_shrink() { - // ensure assert and require shrinks to same sequence of 3 or less - test_shrink("invariant_with_assert").await; - test_shrink("invariant_with_require").await; + // ensure assert shrinks to same sequence of 2 as require + check_shrink_sequence("invariant_with_assert", 2).await; } -async fn test_shrink(test_pattern: &str) { - let mut opts = TEST_DATA_DEFAULT.test_opts.clone(); - opts.fuzz.seed = Some(U256::from(100u32)); +#[tokio::test(flavor = "multi_thread")] +#[cfg_attr(windows, ignore = "for some reason there's different rng")] +async fn test_invariant_require_shrink() { + // ensure require shrinks to same sequence of 2 as assert + check_shrink_sequence("invariant_with_require", 2).await; +} + +async fn check_shrink_sequence(test_pattern: &str, expected_len: usize) { let filter = Filter::new(test_pattern, ".*", ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options = opts; + runner.test_options.fuzz.seed = Some(U256::from(100u32)); match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), CounterExample::Sequence(sequence) => { - assert!(sequence.len() <= 3); + assert_eq!(sequence.len(), expected_len); } }; } From fdfaafd629faa2eea3362a8370eef7c1f8074710 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:33:08 +0200 Subject: [PATCH 1307/1963] feat(cheatcodes): display cheatcode name in error message (#8533) * feat(cheatcodes): display cheatcode name in error message * fix: tests * fix * rm * fix * fix --- Cargo.lock | 1 + crates/cheatcodes/Cargo.toml | 19 +++---- crates/cheatcodes/README.md | 2 +- crates/cheatcodes/src/error.rs | 29 +++++----- crates/cheatcodes/src/evm.rs | 20 +++---- crates/cheatcodes/src/fs.rs | 10 ++-- crates/cheatcodes/src/inspector.rs | 53 ++++++++++++++----- crates/cheatcodes/src/lib.rs | 4 ++ crates/cheatcodes/src/string.rs | 4 +- crates/cheatcodes/src/test/expect.rs | 5 +- .../cheats/BroadcastRawTransaction.t.sol | 6 +-- testdata/default/cheats/Etch.t.sol | 2 +- testdata/default/cheats/Fs.t.sol | 10 ---- testdata/default/cheats/GetCode.t.sol | 2 +- testdata/default/cheats/GetDeployedCode.t.sol | 2 +- testdata/default/cheats/Load.t.sol | 8 +-- testdata/default/cheats/Store.t.sol | 8 +-- 17 files changed, 100 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a37ebd14bd4d..cd11b96f3bda2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3577,6 +3577,7 @@ dependencies = [ "itertools 0.13.0", "jsonpath_lib", "k256", + "memchr", "p256", "parking_lot", "proptest", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 80336d4e8f64a..c061a6381db5a 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -45,23 +45,24 @@ parking_lot.workspace = true alloy-consensus = { workspace = true, features = ["k256"] } alloy-rlp.workspace = true +base64.workspace = true +chrono.workspace = true +dialoguer = "0.11.0" eyre.workspace = true itertools.workspace = true jsonpath_lib.workspace = true +k256.workspace = true +memchr = "2.7" +p256 = "0.13.2" +rand = "0.8" revm.workspace = true +rustc-hash.workspace = true +semver.workspace = true serde_json.workspace = true -base64.workspace = true +thiserror.workspace = true toml = { workspace = true, features = ["preserve_order"] } tracing.workspace = true -k256.workspace = true walkdir.workspace = true -p256 = "0.13.2" -thiserror.workspace = true -semver.workspace = true -rustc-hash.workspace = true -dialoguer = "0.11.0" -rand = "0.8" -chrono.workspace = true [dev-dependencies] proptest.workspace = true diff --git a/crates/cheatcodes/README.md b/crates/cheatcodes/README.md index dfe53bcebea18..790f2553a3919 100644 --- a/crates/cheatcodes/README.md +++ b/crates/cheatcodes/README.md @@ -27,7 +27,7 @@ the Foundry cheatcodes externally. For example, here are some tools that make use of the JSON interface: - Internally, this is used to generate [a simple Solidity interface](../../testdata/cheats/Vm.sol) for testing -- (WIP) Used by [`forge-std`](https://github.com/foundry-rs/forge-std) to generate [user-friendly Solidity interfaces](https://github.com/foundry-rs/forge-std/blob/master/src/Vm.sol) +- Used by [`forge-std`](https://github.com/foundry-rs/forge-std) to generate [user-friendly Solidity interfaces](https://github.com/foundry-rs/forge-std/blob/master/src/Vm.sol) - (WIP) Used by [the Foundry book](https://github.com/foundry-rs/book) to generate [the cheatcodes reference](https://book.getfoundry.sh/cheatcodes) - ... diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 26aba73480884..85be519bfd5e2 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -68,17 +68,14 @@ macro_rules! ensure { macro_rules! ensure_not_precompile { ($address:expr, $ctxt:expr) => { if $ctxt.is_precompile($address) { - return Err($crate::error::precompile_error( - ::CHEATCODE.func.id, - $address, - )) + return Err($crate::error::precompile_error($address)); } }; } #[cold] -pub(crate) fn precompile_error(id: &'static str, address: &Address) -> Error { - fmt_err!("cannot call `{id}` on precompile {address}") +pub(crate) fn precompile_error(address: &Address) -> Error { + fmt_err!("cannot use precompile {address} as an argument") } /// Error thrown by cheatcodes. @@ -158,7 +155,7 @@ impl Error { } /// Returns the kind of this error. - #[inline(always)] + #[inline] pub fn kind(&self) -> ErrorKind<'_> { let data = self.data(); if self.is_str { @@ -170,32 +167,38 @@ impl Error { } /// Returns the raw data of this error. - #[inline(always)] + #[inline] pub fn data(&self) -> &[u8] { unsafe { &*self.data } } - #[inline(always)] + /// Returns `true` if this error is a human-readable string. + #[inline] + pub fn is_str(&self) -> bool { + self.is_str + } + + #[inline] fn new_str(data: &'static str) -> Self { Self::_new(true, false, data.as_bytes()) } - #[inline(always)] + #[inline] fn new_string(data: String) -> Self { Self::_new(true, true, Box::into_raw(data.into_boxed_str().into_boxed_bytes())) } - #[inline(always)] + #[inline] fn new_bytes(data: &'static [u8]) -> Self { Self::_new(false, false, data) } - #[inline(always)] + #[inline] fn new_vec(data: Vec) -> Self { Self::_new(false, true, Box::into_raw(data.into_boxed_slice())) } - #[inline(always)] + #[inline] fn _new(is_str: bool, drop: bool, data: *const [u8]) -> Self { debug_assert!(!data.is_null()); Self { is_str, drop, data } diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 5e24070a8caa7..2d40319200e9f 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -275,13 +275,10 @@ impl Cheatcode for resumeGasMeteringCall { impl Cheatcode for lastCallGasCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - ensure!(state.last_call_gas.is_some(), "`lastCallGas` is only available after a call"); - Ok(state - .last_call_gas - .as_ref() - // This should never happen, as we ensure `last_call_gas` is `Some` above. - .expect("`lastCallGas` is only available after a call") - .abi_encode()) + let Some(last_call_gas) = &state.last_call_gas else { + bail!("no external call was made yet"); + }; + Ok(last_call_gas.abi_encode()) } } @@ -354,7 +351,7 @@ impl Cheatcode for blobhashesCall { let Self { hashes } = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, - "`blobhash` is not supported before the Cancun hard fork; \ + "`blobhashes` is not supported before the Cancun hard fork; \ see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844" ); ccx.ecx.env.tx.blob_hashes.clone_from(hashes); @@ -367,7 +364,7 @@ impl Cheatcode for getBlobhashesCall { let Self {} = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, - "`blobhash` is not supported before the Cancun hard fork; \ + "`getBlobhashes` is not supported before the Cancun hard fork; \ see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844" ); Ok(ccx.ecx.env.tx.blob_hashes.clone().abi_encode()) @@ -605,9 +602,8 @@ impl Cheatcode for broadcastRawTransactionCall { executor: &mut E, ) -> Result { let mut data = self.data.as_ref(); - let tx = TxEnvelope::decode(&mut data).map_err(|err| { - fmt_err!("broadcastRawTransaction: error decoding transaction ({err})") - })?; + let tx = TxEnvelope::decode(&mut data) + .map_err(|err| fmt_err!("failed to decode RLP-encoded transaction: {err}"))?; ccx.ecx.db.transact_from_tx( tx.clone().into(), diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 177037c905b6b..5467cfcf6b8cd 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -352,7 +352,7 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result Result>(); let artifact = match &filtered[..] { - [] => Err(fmt_err!("No matching artifact found")), + [] => Err(fmt_err!("no matching artifact found")), [artifact] => Ok(artifact), filtered => { // If we know the current script/test contract solc version, try to filter by it @@ -403,7 +403,7 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result>(); (filtered.len() == 1).then(|| filtered[0]) }) - .ok_or_else(|| fmt_err!("Multiple matching artifacts found")) + .ok_or_else(|| fmt_err!("multiple matching artifacts found")) } }?; @@ -414,7 +414,7 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result Result(&data)?; let maybe_bytecode = if deployed { artifact.deployed_bytecode } else { artifact.bytecode }; - maybe_bytecode.ok_or_else(|| fmt_err!("No bytecode for contract. Is it abstract or unlinked?")) + maybe_bytecode.ok_or_else(|| fmt_err!("no bytecode for contract; is it abstract or unlinked?")) } impl Cheatcode for ffiCall { diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 13cc02df373be..0d377a382d96d 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -592,6 +592,7 @@ impl Cheatcodes { { let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); return match expect::handle_expect_revert( + false, true, expected_revert.reason.as_deref(), outcome.result.result, @@ -1035,7 +1036,7 @@ impl Inspector for Cheatcodes { // Handle expected reverts if let Some(expected_revert) = &self.expected_revert { if ecx.journaled_state.depth() <= expected_revert.depth { - let needs_processing: bool = match expected_revert.kind { + let needs_processing = match expected_revert.kind { ExpectedRevertKind::Default => !cheatcode_call, // `pending_processing` == true means that we're in the `call_end` hook for // `vm.expectCheatcodeRevert` and shouldn't expect revert here @@ -1047,6 +1048,7 @@ impl Inspector for Cheatcodes { if needs_processing { let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); return match expect::handle_expect_revert( + cheatcode_call, false, expected_revert.reason.as_deref(), outcome.result.result, @@ -1071,9 +1073,7 @@ impl Inspector for Cheatcodes { if let ExpectedRevertKind::Cheatcode { pending_processing } = &mut self.expected_revert.as_mut().unwrap().kind { - if *pending_processing { - *pending_processing = false; - } + *pending_processing = false; } } } @@ -1847,22 +1847,49 @@ fn apply_dispatch( }; } - let _guard = trace_span_and_call(calls); - let result = vm_calls!(dispatch); - trace_return(&result); + let mut dyn_cheat = DynCheatCache::new(calls); + let _guard = trace_span_and_call(&mut dyn_cheat); + let mut result = vm_calls!(dispatch); + fill_and_trace_return(&mut dyn_cheat, &mut result); result } -fn trace_span_and_call(calls: &Vm::VmCalls) -> tracing::span::EnteredSpan { - let mut cheat = None; - let mut get_cheat = || *cheat.get_or_insert_with(|| calls_as_dyn_cheatcode(calls)); - let span = debug_span!(target: "cheatcodes", "apply", id = %get_cheat().id()); +// Caches the result of `calls_as_dyn_cheatcode`. +// TODO: Remove this once Cheatcode is object-safe, as caching would not be necessary anymore. +struct DynCheatCache<'a> { + calls: &'a Vm::VmCalls, + slot: Option<&'a dyn DynCheatcode>, +} + +impl<'a> DynCheatCache<'a> { + fn new(calls: &'a Vm::VmCalls) -> Self { + Self { calls, slot: None } + } + + fn get(&mut self) -> &dyn DynCheatcode { + *self.slot.get_or_insert_with(|| calls_as_dyn_cheatcode(self.calls)) + } +} + +fn trace_span_and_call(dyn_cheat: &mut DynCheatCache) -> tracing::span::EnteredSpan { + let span = debug_span!(target: "cheatcodes", "apply", id = %dyn_cheat.get().id()); let entered = span.entered(); - trace!(target: "cheatcodes", cheat = ?get_cheat().as_debug(), "applying"); + trace!(target: "cheatcodes", cheat = ?dyn_cheat.get().as_debug(), "applying"); entered } -fn trace_return(result: &Result) { +fn fill_and_trace_return(dyn_cheat: &mut DynCheatCache, result: &mut Result) { + if let Err(e) = result { + if e.is_str() { + let name = dyn_cheat.get().name(); + // Skip showing the cheatcode name for: + // - assertions: too verbose, and can already be inferred from the error message + // - `rpcUrl`: forge-std relies on it in `getChainWithUpdatedRpcUrl` + if !name.contains("assert") && name != "rpcUrl" { + *e = fmt_err!("vm.{name}: {e}"); + } + } + } trace!( target: "cheatcodes", return = %match result { diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 5b46fd7e5a851..b03dbc2d7d2c7 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -85,11 +85,15 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { } pub(crate) trait DynCheatcode { + fn name(&self) -> &'static str; fn id(&self) -> &'static str; fn as_debug(&self) -> &dyn std::fmt::Debug; } impl DynCheatcode for T { + fn name(&self) -> &'static str { + T::CHEATCODE.func.signature.split('(').next().unwrap() + } fn id(&self) -> &'static str { T::CHEATCODE.func.id } diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index 7b7d9b505356b..e7435d541048c 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -186,9 +186,7 @@ fn parse_value_fallback(s: &str, ty: &DynSolType) -> Option false, s if s.eq_ignore_ascii_case("true") => true, s if s.eq_ignore_ascii_case("false") => false, - _ => { - return None; - } + _ => return None, }; return Some(Ok(DynSolValue::Bool(b))); } diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 80d2417ec3752..4c5bfe928b4a8 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -542,6 +542,7 @@ fn expect_revert( } pub(crate) fn handle_expect_revert( + is_cheatcode: bool, is_create: bool, expected_revert: Option<&[u8]>, status: InstructionResult, @@ -578,7 +579,9 @@ pub(crate) fn handle_expect_revert( } } - if actual_revert == expected_revert { + if actual_revert == expected_revert || + (is_cheatcode && memchr::memmem::find(&actual_revert, expected_revert).is_some()) + { Ok(success_return()) } else { let stringify = |data: &[u8]| { diff --git a/testdata/default/cheats/BroadcastRawTransaction.t.sol b/testdata/default/cheats/BroadcastRawTransaction.t.sol index 7425e9d3773a5..43e4ff6323e89 100644 --- a/testdata/default/cheats/BroadcastRawTransaction.t.sol +++ b/testdata/default/cheats/BroadcastRawTransaction.t.sol @@ -8,17 +8,17 @@ contract BroadcastRawTransactionTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function test_revert_not_a_tx() public { - vm.expectRevert("broadcastRawTransaction: error decoding transaction (unexpected string)"); + vm._expectCheatcodeRevert("failed to decode RLP-encoded transaction: unexpected string"); vm.broadcastRawTransaction(hex"0102"); } function test_revert_missing_signature() public { - vm.expectRevert("broadcastRawTransaction: error decoding transaction (input too short)"); + vm._expectCheatcodeRevert("failed to decode RLP-encoded transaction: input too short"); vm.broadcastRawTransaction(hex"dd806483030d40940993863c19b0defb183ca2b502db7d1b331ded757b80"); } function test_revert_wrong_chainid() public { - vm.expectRevert("transaction validation error: invalid chain ID"); + vm._expectCheatcodeRevert("transaction validation error: invalid chain ID"); vm.broadcastRawTransaction( hex"f860806483030d40946fd0a0cff9a87adf51695b40b4fa267855a8f4c6118025a03ebeabbcfe43c2c982e99b376b5fb6e765059d7f215533c8751218cac99bbd80a00a56cf5c382442466770a756e81272d06005c9e90fb8dbc5b53af499d5aca856" ); diff --git a/testdata/default/cheats/Etch.t.sol b/testdata/default/cheats/Etch.t.sol index 6e58fc13bac28..fbd0e62b90bdb 100644 --- a/testdata/default/cheats/Etch.t.sol +++ b/testdata/default/cheats/Etch.t.sol @@ -17,7 +17,7 @@ contract EtchTest is DSTest { function testEtchNotAvailableOnPrecompiles() public { address target = address(1); bytes memory code = hex"1010"; - vm._expectCheatcodeRevert(bytes("cannot call `etch` on precompile 0x0000000000000000000000000000000000000001")); + vm._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); vm.etch(target, code); } } diff --git a/testdata/default/cheats/Fs.t.sol b/testdata/default/cheats/Fs.t.sol index c48adefec5a22..cb407641ec36b 100644 --- a/testdata/default/cheats/Fs.t.sol +++ b/testdata/default/cheats/Fs.t.sol @@ -233,16 +233,6 @@ contract FsTest is DSTest { vm.fsMetadata("/etc/hosts"); } - // not testing file cheatcodes per se - function testCheatCodeErrorPrefix() public { - try vm.readFile("/etc/hosts") { - emit log("Error: reading /etc/hosts should revert"); - fail(); - } catch (bytes memory err) { - assertEq(err, abi.encodeWithSignature("CheatcodeError(string)", FOUNDRY_READ_ERR)); - } - } - function testExists() public { string memory validFilePath = "fixtures/File/read.txt"; assertTrue(vm.exists(validFilePath)); diff --git a/testdata/default/cheats/GetCode.t.sol b/testdata/default/cheats/GetCode.t.sol index 73980d7b29810..b155a1873ddfe 100644 --- a/testdata/default/cheats/GetCode.t.sol +++ b/testdata/default/cheats/GetCode.t.sol @@ -79,7 +79,7 @@ contract GetCodeTest is DSTest { bytes memory code = vm.getCode("cheats/GetCode.t.sol:TestContract:0.8.18"); assertEq(type(TestContract).creationCode, code); - vm._expectCheatcodeRevert("No matching artifact found"); + vm._expectCheatcodeRevert("no matching artifact found"); vm.getCode("cheats/GetCode.t.sol:TestContract:0.8.19"); } diff --git a/testdata/default/cheats/GetDeployedCode.t.sol b/testdata/default/cheats/GetDeployedCode.t.sol index 8d95b243ce564..220e3f3c87529 100644 --- a/testdata/default/cheats/GetDeployedCode.t.sol +++ b/testdata/default/cheats/GetDeployedCode.t.sol @@ -45,7 +45,7 @@ contract GetDeployedCodeTest is DSTest { assertEq(address(test).code, code); - vm._expectCheatcodeRevert("No matching artifact found"); + vm._expectCheatcodeRevert("no matching artifact found"); vm.getDeployedCode("cheats/GetDeployedCode.t.sol:TestContract:0.8.19"); } } diff --git a/testdata/default/cheats/Load.t.sol b/testdata/default/cheats/Load.t.sol index 37a2c80b298cc..0ed1cbbc20211 100644 --- a/testdata/default/cheats/Load.t.sol +++ b/testdata/default/cheats/Load.t.sol @@ -27,12 +27,8 @@ contract LoadTest is DSTest { } function testLoadNotAvailableOnPrecompiles() public { - vm.expectRevert(bytes("cannot call `load` on precompile 0x0000000000000000000000000000000000000001")); - uint256 val = this.load(address(1), bytes32(0)); - } - - function load(address target, bytes32 slot) public returns (uint256) { - return uint256(vm.load(target, slot)); + vm._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); + vm.load(address(1), bytes32(0)); } function testLoadOtherStorage() public { diff --git a/testdata/default/cheats/Store.t.sol b/testdata/default/cheats/Store.t.sol index 059952fca7ff2..5159a4ab8635b 100644 --- a/testdata/default/cheats/Store.t.sol +++ b/testdata/default/cheats/Store.t.sol @@ -30,12 +30,8 @@ contract StoreTest is DSTest { assertEq(store.slot0(), 10, "initial value for slot 0 is incorrect"); assertEq(store.slot1(), 20, "initial value for slot 1 is incorrect"); - vm.expectRevert(bytes("cannot call `store` on precompile 0x0000000000000000000000000000000000000001")); - this._store(address(1), bytes32(0), bytes32(uint256(1))); - } - - function _store(address target, bytes32 slot, bytes32 value) public { - vm.store(target, slot, value); + vm._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); + vm.store(address(1), bytes32(0), bytes32(uint256(1))); } function testStoreFuzzed(uint256 slot0, uint256 slot1) public { From bb4b2a37b88d5471f8b406ec8ac95e7fd03bc427 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 30 Jul 2024 17:46:59 +0800 Subject: [PATCH 1308/1963] fix(verify-bytecode): fix metadata extraction and add tests (#8560) * fix(verify-bytecode): fix metadata extraction and add tests * fix * fix * clippy * clippy + fmt * move to tests/ --- Cargo.lock | 1 + crates/forge/tests/cli/main.rs | 1 + crates/forge/tests/cli/verify_bytecode.rs | 85 +++++++++++++++++++++++ crates/verify/Cargo.toml | 2 + crates/verify/src/bytecode.rs | 46 ++++++------ 5 files changed, 111 insertions(+), 24 deletions(-) create mode 100644 crates/forge/tests/cli/verify_bytecode.rs diff --git a/Cargo.lock b/Cargo.lock index cd11b96f3bda2..7e714b9b5705e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3498,6 +3498,7 @@ dependencies = [ "alloy-provider", "alloy-rpc-types", "async-trait", + "ciborium", "clap", "eyre", "foundry-block-explorers", diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index b8bc3db5add4d..e8c6f1cc085f7 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -20,5 +20,6 @@ mod soldeer; mod svm; mod test_cmd; mod verify; +mod verify_bytecode; mod ext_integration; diff --git a/crates/forge/tests/cli/verify_bytecode.rs b/crates/forge/tests/cli/verify_bytecode.rs new file mode 100644 index 0000000000000..846fcc47d80cf --- /dev/null +++ b/crates/forge/tests/cli/verify_bytecode.rs @@ -0,0 +1,85 @@ +use foundry_compilers::artifacts::{BytecodeHash, EvmVersion}; +use foundry_config::Config; +use foundry_test_utils::{ + forgetest_async, + rpc::{next_etherscan_api_key, next_http_archive_rpc_endpoint}, + util::OutputExt, + TestCommand, TestProject, +}; + +fn test_verify_bytecode( + prj: TestProject, + mut cmd: TestCommand, + addr: &str, + contract_name: &str, + config: Config, + expected_matches: (&str, &str), +) { + let etherscan_key = next_etherscan_api_key(); + let rpc_url = next_http_archive_rpc_endpoint(); + + // fetch and flatten source code + let source_code = cmd + .cast_fuse() + .args(["etherscan-source", addr, "--flatten", "--etherscan-api-key", ðerscan_key]) + .assert_success() + .get_output() + .stdout_lossy(); + + prj.add_source(contract_name, &source_code).unwrap(); + prj.write_config(config); + + let output = cmd + .forge_fuse() + .args([ + "verify-bytecode", + addr, + contract_name, + "--etherscan-api-key", + ðerscan_key, + "--rpc-url", + &rpc_url, + ]) + .assert_success() + .get_output() + .stdout_lossy(); + + assert!(output + .contains(format!("Creation code matched with status {}", expected_matches.0).as_str())); + assert!(output + .contains(format!("Runtime code matched with status {}", expected_matches.1).as_str())); +} + +forgetest_async!(can_verify_bytecode_no_metadata, |prj, cmd| { + test_verify_bytecode( + prj, + cmd, + "0xba2492e52F45651B60B8B38d4Ea5E2390C64Ffb1", + "SystemConfig", + Config { + evm_version: EvmVersion::London, + optimizer_runs: 999999, + optimizer: true, + cbor_metadata: false, + bytecode_hash: BytecodeHash::None, + ..Default::default() + }, + ("full", "full"), + ); +}); + +forgetest_async!(can_verify_bytecode_with_metadata, |prj, cmd| { + test_verify_bytecode( + prj, + cmd, + "0xb8901acb165ed027e32754e0ffe830802919727f", + "L1_ETH_Bridge", + Config { + evm_version: EvmVersion::Paris, + optimizer_runs: 50000, + optimizer: true, + ..Default::default() + }, + ("partial", "partial"), + ); +}); diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 97ff5e425abca..3ef9b4fb425d9 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -41,6 +41,8 @@ once_cell.workspace = true yansi.workspace = true itertools.workspace = true +ciborium = "0.2" + [dev-dependencies] tokio = { workspace = true, features = ["macros"] } foundry-test-utils.workspace = true diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 5834e961f1795..aa3ffbe0ed56d 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -11,14 +11,14 @@ use foundry_cli::{ }; use foundry_common::{abi::encode_args, compile::ProjectCompiler, provider::ProviderBuilder}; use foundry_compilers::{ - artifacts::{BytecodeHash, CompactContractBytecode, EvmVersion}, + artifacts::{CompactContractBytecode, EvmVersion}, info::ContractInfo, }; use foundry_config::{figment, filter::SkipBuildFilter, impl_figment_convert, Chain, Config}; use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, utils::configure_tx_env, }; -use revm_primitives::{db::Database, EnvWithHandlerCfg, HandlerCfg, SpecId}; +use revm_primitives::{db::Database, EnvWithHandlerCfg, HandlerCfg}; use semver::Version; use serde::{Deserialize, Serialize}; use std::{fmt, path::PathBuf, str::FromStr}; @@ -262,9 +262,6 @@ impl VerifyBytecodeArgs { } } - // If bytecode_hash is disabled then its always partial verification - let has_metadata = config.bytecode_hash == BytecodeHash::None; - // Append constructor args to the local_bytecode trace!(%constructor_args); let mut local_bytecode_vec = local_bytecode.to_vec(); @@ -276,7 +273,6 @@ impl VerifyBytecodeArgs { maybe_creation_code, &constructor_args, false, - has_metadata, ); let mut json_results: Vec = vec![]; @@ -369,7 +365,7 @@ impl VerifyBytecodeArgs { configure_tx_env(&mut env, &transaction); let env_with_handler = - EnvWithHandlerCfg::new(Box::new(env.clone()), HandlerCfg::new(SpecId::LATEST)); + EnvWithHandlerCfg::new(Box::new(env.clone()), HandlerCfg::new(config.evm_spec_id())); let contract_address = if let Some(to) = transaction.to { if to != DEFAULT_CREATE2_DEPLOYER { @@ -414,7 +410,6 @@ impl VerifyBytecodeArgs { &onchain_runtime_code, &constructor_args, true, - has_metadata, ); self.print_result( @@ -599,13 +594,12 @@ fn match_bytecodes( bytecode: &[u8], constructor_args: &[u8], is_runtime: bool, - has_metadata: bool, ) -> Option { // 1. Try full match if local_bytecode == bytecode { Some(VerificationType::Full) } else { - is_partial_match(local_bytecode, bytecode, constructor_args, is_runtime, has_metadata) + is_partial_match(local_bytecode, bytecode, constructor_args, is_runtime) .then_some(VerificationType::Partial) } } @@ -615,30 +609,23 @@ fn is_partial_match( mut bytecode: &[u8], constructor_args: &[u8], is_runtime: bool, - has_metadata: bool, ) -> bool { // 1. Check length of constructor args if constructor_args.is_empty() || is_runtime { // Assume metadata is at the end of the bytecode - return try_extract_and_compare_bytecode(local_bytecode, bytecode, has_metadata) + return try_extract_and_compare_bytecode(local_bytecode, bytecode) } // If not runtime, extract constructor args from the end of the bytecode bytecode = &bytecode[..bytecode.len() - constructor_args.len()]; local_bytecode = &local_bytecode[..local_bytecode.len() - constructor_args.len()]; - try_extract_and_compare_bytecode(local_bytecode, bytecode, has_metadata) + try_extract_and_compare_bytecode(local_bytecode, bytecode) } -fn try_extract_and_compare_bytecode( - mut local_bytecode: &[u8], - mut bytecode: &[u8], - has_metadata: bool, -) -> bool { - if has_metadata { - local_bytecode = extract_metadata_hash(local_bytecode); - bytecode = extract_metadata_hash(bytecode); - } +fn try_extract_and_compare_bytecode(mut local_bytecode: &[u8], mut bytecode: &[u8]) -> bool { + local_bytecode = extract_metadata_hash(local_bytecode); + bytecode = extract_metadata_hash(bytecode); // Now compare the local code and bytecode local_bytecode == bytecode @@ -650,8 +637,19 @@ fn extract_metadata_hash(bytecode: &[u8]) -> &[u8] { let metadata_len = &bytecode[bytecode.len() - 2..]; let metadata_len = u16::from_be_bytes([metadata_len[0], metadata_len[1]]); - // Now discard the metadata from the bytecode - &bytecode[..bytecode.len() - 2 - metadata_len as usize] + if metadata_len as usize <= bytecode.len() { + if ciborium::from_reader::( + &bytecode[bytecode.len() - 2 - metadata_len as usize..bytecode.len() - 2], + ) + .is_ok() + { + &bytecode[..bytecode.len() - 2 - metadata_len as usize] + } else { + bytecode + } + } else { + bytecode + } } fn find_mismatch_in_settings( From 26a7559758c192911dd39ce7d621a18ef0d419e6 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:53:38 +0200 Subject: [PATCH 1309/1963] fix: error `intrinsic gas too low` when deploying contract on Mantle / Mantle Sepolia (follow-up) (#8562) * temp patch alloy-chains * not working yet, re-add as exception? * revert to alloy-chains 0.1, includes upstream fix * update --- Cargo.lock | 50 +++++++++++++++++++++---------------- crates/cli/src/utils/cmd.rs | 1 + 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e714b9b5705e..2a3f0809012f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1752d7d62e2665da650a36d84abbf239f812534475d51f072a49a533513b7cdd" +checksum = "47ff94ce0f141c2671c23d02c7b88990dd432856639595c5d010663d017c2c58" dependencies = [ "num_enum", "serde", @@ -1970,9 +1970,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" dependencies = [ "jobserver", "libc", @@ -2923,9 +2923,9 @@ checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" [[package]] name = "enumn" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" +checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", @@ -5889,18 +5889,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6477,9 +6477,13 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "2288c0e17cc8d342c712bb43a257a80ebffce59cdb33d5000d8348f3ec02528b" +dependencies = [ + "zerocopy", + "zerocopy-derive", +] [[package]] name = "precomputed-hash" @@ -7570,9 +7574,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.5" +version = "2.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fadf67e3cf23f8b11a6c8c48a16cb2437381503615acd91094ec7b4686a5a53" +checksum = "05ccfb12511cdb770157ace92d7dda771e498445b78f9886e8cdbc5140a4eced" dependencies = [ "sdd", ] @@ -7646,9 +7650,9 @@ dependencies = [ [[package]] name = "sdd" -version = "1.7.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85f05a494052771fc5bd0619742363b5e24e5ad72ab3111ec2e27925b8edc5f3" +checksum = "177258b64c0faaa9ffd3c65cd3262c2bc7e2588dbbd9c1641d0346145c1bbda8" [[package]] name = "sec1" @@ -7785,12 +7789,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "indexmap 2.2.6", "itoa", + "memchr", "ryu", "serde", ] @@ -7979,9 +7984,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", "mio 0.8.11", @@ -9415,9 +9420,9 @@ dependencies = [ [[package]] name = "which" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +checksum = "3d9c5ed668ee1f17edb3b627225343d210006a90bb1e3745ce1f30b1fb115075" dependencies = [ "either", "home", @@ -9831,6 +9836,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index c7f9c1c2ba3d9..6abd11fcee9d2 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -169,6 +169,7 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { NamedChain::ArbitrumTestnet | NamedChain::Mantle | NamedChain::MantleTestnet | + NamedChain::MantleSepolia | NamedChain::Moonbase | NamedChain::Moonbeam | NamedChain::MoonbeamDev | From 53bf620da067d87311aec194a05ba1b840c2665a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:51:10 +0200 Subject: [PATCH 1310/1963] docs(`forge script`): improve `Mac Mismatch` error referring to failure to decrypt of keystore (#8572) * docs(`forge script`): improve `Mac Mismatch` error referring to failure to decrypt of keystore * chore: rename error --- Cargo.lock | 1 + crates/wallets/Cargo.toml | 1 + crates/wallets/src/error.rs | 2 ++ crates/wallets/src/wallet_signer.rs | 12 +++++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 2a3f0809012f7..f378f0e726730 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4103,6 +4103,7 @@ dependencies = [ "aws-sdk-kms", "clap", "derive_builder", + "eth-keystore", "eyre", "foundry-config", "gcloud-sdk", diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index f0e3ddc11796f..89c1ed2e9700b 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -45,6 +45,7 @@ rpassword = "7" serde.workspace = true thiserror.workspace = true tracing.workspace = true +eth-keystore = "0.5.0" [dev-dependencies] tokio = { workspace = true, features = ["macros"] } diff --git a/crates/wallets/src/error.rs b/crates/wallets/src/error.rs index a5ee5ec1cf3f5..9deb037b71fb8 100644 --- a/crates/wallets/src/error.rs +++ b/crates/wallets/src/error.rs @@ -22,6 +22,8 @@ pub enum PrivateKeyError { pub enum WalletSignerError { #[error(transparent)] Local(#[from] LocalSignerError), + #[error("Failed to decrypt keystore: incorrect password")] + IncorrectKeystorePassword, #[error(transparent)] Ledger(#[from] LedgerError), #[error(transparent)] diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index 75441f6838b5b..a7bc1a312a364 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -263,7 +263,17 @@ impl PendingSigner { match self { Self::Keystore(path) => { let password = rpassword::prompt_password("Enter keystore password:")?; - Ok(WalletSigner::Local(PrivateKeySigner::decrypt_keystore(path, password)?)) + match PrivateKeySigner::decrypt_keystore(path, password) { + Ok(signer) => Ok(WalletSigner::Local(signer)), + Err(e) => match e { + // Catch the `MacMismatch` error, which indicates an incorrect password and + // return a more user-friendly `IncorrectKeystorePassword`. + alloy_signer_local::LocalSignerError::EthKeystoreError( + eth_keystore::KeystoreError::MacMismatch, + ) => Err(WalletSignerError::IncorrectKeystorePassword), + _ => Err(WalletSignerError::Local(e)), + }, + } } Self::Interactive => { let private_key = rpassword::prompt_password("Enter private key:")?; From c99854277c346fa6de7a8f9837230b36fd85850e Mon Sep 17 00:00:00 2001 From: James Kim Date: Wed, 31 Jul 2024 19:11:20 +0900 Subject: [PATCH 1311/1963] fix(anvil): fix incorrect op-stack deposit tx hashes (#8567) * fix encoding and hash for deposit tx * rename * add it test * remove comments * fix suggested changes --- crates/anvil/core/src/eth/transaction/mod.rs | 29 ++++- .../core/src/eth/transaction/optimism.rs | 110 ++++++++++++++++-- crates/anvil/tests/it/optimism.rs | 72 +++++++++++- 3 files changed, 197 insertions(+), 14 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 5aeb2cd0d7d3b..878f4bf0fe5db 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -925,7 +925,7 @@ impl TypedTransaction { /// This appends the `address` before hashing it #[cfg(feature = "impersonated-tx")] pub fn impersonated_hash(&self, sender: Address) -> B256 { - let mut buffer = Vec::::new(); + let mut buffer = Vec::new(); Encodable::encode(self, &mut buffer); buffer.extend_from_slice(sender.as_ref()); B256::from_slice(alloy_primitives::utils::keccak256(&buffer).as_slice()) @@ -1101,7 +1101,7 @@ impl Decodable for TypedTransaction { if ty != 0x7E { Ok(TxEnvelope::decode(buf)?.into()) } else { - Ok(Self::Deposit(DepositTransaction::decode(&mut h_decode_copy)?)) + Ok(Self::Deposit(DepositTransaction::decode_2718(buf)?)) } } } @@ -1133,8 +1133,7 @@ impl Encodable2718 for TypedTransaction { Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), Self::EIP7702(tx) => tx.tx().encode_with_signature(tx.signature(), out, false), Self::Deposit(tx) => { - out.put_u8(0x7E); - tx.encode(out); + tx.encode_2718(out); } } } @@ -1697,6 +1696,28 @@ mod tests { assert_eq!(from, address!("A83C816D4f9b2783761a22BA6FADB0eB0606D7B2")); } + #[test] + fn test_decode_encode_deposit_tx() { + // https://sepolia-optimism.etherscan.io/tx/0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7 + let tx_hash: TxHash = "0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7" + .parse::() + .unwrap(); + + // https://sepolia-optimism.etherscan.io/getRawTx?tx=0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7 + let raw_tx = alloy_primitives::hex::decode( + "7ef861a0dfd7ae78bf3c414cfaa77f13c0205c82eb9365e217b2daa3448c3156b69b27ac94778f2146f48179643473b82931c4cd7b8f153efd94778f2146f48179643473b82931c4cd7b8f153efd872386f26fc10000872386f26fc10000830186a08080", + ) + .unwrap(); + let dep_tx = TypedTransaction::decode(&mut raw_tx.as_slice()).unwrap(); + + let mut encoded = Vec::new(); + dep_tx.encode_2718(&mut encoded); + + assert_eq!(raw_tx, encoded); + + assert_eq!(tx_hash, dep_tx.hash()); + } + #[test] fn can_recover_sender_not_normalized() { let bytes = hex::decode("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap(); diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index f2e4cff26c94d..fb987ae3d059f 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -1,11 +1,14 @@ -use alloy_consensus::{SignableTransaction, Signed, Transaction, TxType}; +use alloy_consensus::{SignableTransaction, Signed, Transaction}; use alloy_primitives::{keccak256, Address, Bytes, ChainId, Signature, TxKind, B256, U256}; use alloy_rlp::{ length_of_length, Decodable, Encodable, Error as DecodeError, Header as RlpHeader, }; +use bytes::BufMut; use serde::{Deserialize, Serialize}; use std::mem; +pub const DEPOSIT_TX_TYPE_ID: u8 = 0x7E; + #[derive(Clone, Debug, PartialEq, Eq)] pub struct DepositTransactionRequest { pub source_hash: B256, @@ -20,13 +23,17 @@ pub struct DepositTransactionRequest { impl DepositTransactionRequest { pub fn hash(&self) -> B256 { - B256::from_slice(alloy_primitives::keccak256(alloy_rlp::encode(self)).as_slice()) + let mut encoded = Vec::new(); + encoded.put_u8(DEPOSIT_TX_TYPE_ID); + self.encode(&mut encoded); + + B256::from_slice(alloy_primitives::keccak256(encoded).as_slice()) } /// Encodes only the transaction's fields into the desired buffer, without a RLP header. pub(crate) fn encode_fields(&self, out: &mut dyn alloy_rlp::BufMut) { - self.from.encode(out); self.source_hash.encode(out); + self.from.encode(out); self.kind.encode(out); self.mint.encode(out); self.value.encode(out); @@ -103,8 +110,8 @@ impl DepositTransactionRequest { } /// Get transaction type - pub(crate) const fn tx_type(&self) -> TxType { - TxType::Eip1559 + pub(crate) const fn tx_type(&self) -> u8 { + DEPOSIT_TX_TYPE_ID } /// Calculates a heuristic for the in-memory size of the [DepositTransaction] transaction. @@ -121,7 +128,7 @@ impl DepositTransactionRequest { /// Encodes the legacy transaction in RLP for signing. pub(crate) fn encode_for_signing(&self, out: &mut dyn alloy_rlp::BufMut) { - out.put_u8(self.tx_type() as u8); + out.put_u8(self.tx_type()); alloy_rlp::Header { list: true, payload_length: self.fields_len() }.encode(out); self.encode_fields(out); } @@ -247,7 +254,9 @@ impl DepositTransaction { } pub fn hash(&self) -> B256 { - B256::from_slice(alloy_primitives::keccak256(alloy_rlp::encode(self)).as_slice()) + let mut encoded = Vec::new(); + self.encode_2718(&mut encoded); + B256::from_slice(alloy_primitives::keccak256(encoded).as_slice()) } // /// Recovers the Ethereum address which was used to sign the transaction. @@ -259,9 +268,13 @@ impl DepositTransaction { None } + pub(crate) fn encode_2718(&self, out: &mut dyn alloy_rlp::BufMut) { + out.put_u8(DEPOSIT_TX_TYPE_ID); + self.encode(out); + } + /// Encodes only the transaction's fields into the desired buffer, without a RLP header. pub(crate) fn encode_fields(&self, out: &mut dyn alloy_rlp::BufMut) { - self.nonce.encode(out); self.source_hash.encode(out); self.from.encode(out); self.kind.encode(out); @@ -286,6 +299,20 @@ impl DepositTransaction { len } + pub fn decode_2718(buf: &mut &[u8]) -> Result { + use bytes::Buf; + + let tx_type = *buf.first().ok_or(alloy_rlp::Error::Custom("empty slice"))?; + + if tx_type != DEPOSIT_TX_TYPE_ID { + return Err(alloy_rlp::Error::Custom("invalid tx type: expected deposit tx type")); + } + + // Skip the tx type byte + buf.advance(1); + Self::decode(buf) + } + /// Decodes the inner fields from RLP bytes /// /// NOTE: This assumes a RLP header has already been decoded, and _just_ decodes the following @@ -325,7 +352,6 @@ impl Decodable for DepositTransaction { fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { let header = RlpHeader::decode(buf)?; let remaining_len = buf.len(); - if header.payload_length > remaining_len { return Err(alloy_rlp::Error::InputTooShort); } @@ -333,3 +359,69 @@ impl Decodable for DepositTransaction { Self::decode_inner(buf) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_encode_decode() { + let tx = DepositTransaction { + nonce: 0, + source_hash: B256::default(), + from: Address::default(), + kind: TxKind::Call(Address::default()), + mint: U256::from(100), + value: U256::from(100), + gas_limit: 50000, + is_system_tx: false, + input: Bytes::default(), + }; + + let encoded_tx: Vec = alloy_rlp::encode(&tx); + + let decoded_tx = DepositTransaction::decode(&mut encoded_tx.as_slice()).unwrap(); + + assert_eq!(tx, decoded_tx); + } + #[test] + fn test_encode_decode_2718() { + let tx = DepositTransaction { + nonce: 0, + source_hash: B256::default(), + from: Address::default(), + kind: TxKind::Call(Address::default()), + mint: U256::from(100), + value: U256::from(100), + gas_limit: 50000, + is_system_tx: false, + input: Bytes::default(), + }; + + let mut encoded_tx: Vec = Vec::new(); + tx.encode_2718(&mut encoded_tx); + + let decoded_tx = DepositTransaction::decode_2718(&mut encoded_tx.as_slice()).unwrap(); + + assert_eq!(tx, decoded_tx); + } + + #[test] + fn test_tx_request_hash_equals_tx_hash() { + let tx = DepositTransaction { + nonce: 0, + source_hash: B256::default(), + from: Address::default(), + kind: TxKind::Call(Address::default()), + mint: U256::from(100), + value: U256::from(100), + gas_limit: 50000, + is_system_tx: false, + input: Bytes::default(), + }; + + let tx_request = DepositTransactionRequest::from(tx.clone()); + + assert_eq!(tx.hash(), tx_request.hash()); + } +} diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index c355d11e889dc..8e23d7ded8f62 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -3,7 +3,7 @@ use crate::utils::http_provider_with_signer; use alloy_eips::eip2718::Encodable2718; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{b256, U256}; +use alloy_primitives::{b256, Address, TxHash, U256}; use alloy_provider::Provider; use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -144,3 +144,73 @@ async fn test_send_value_raw_deposit_transaction() { let after_balance_to = provider.get_balance(to).await.unwrap(); assert_eq!(after_balance_to, before_balance_to + send_value); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_deposit_transaction_hash_matches_sepolia() { + // enable the Optimism flag + let (api, handle) = + spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; + + let accounts: Vec<_> = handle.dev_wallets().collect(); + let signer: EthereumWallet = accounts[0].clone().into(); + let sender_addr = accounts[0].address(); + + // https://sepolia-optimism.etherscan.io/tx/0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7 + let tx_hash: TxHash = "0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7" + .parse::() + .unwrap(); + + // https://sepolia-optimism.etherscan.io/getRawTx?tx=0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7 + let raw_deposit_tx = alloy_primitives::hex::decode( + "7ef861a0dfd7ae78bf3c414cfaa77f13c0205c82eb9365e217b2daa3448c3156b69b27ac94778f2146f48179643473b82931c4cd7b8f153efd94778f2146f48179643473b82931c4cd7b8f153efd872386f26fc10000872386f26fc10000830186a08080", + ) + .unwrap(); + let deposit_tx_from = "0x778F2146F48179643473B82931c4CD7B8F153eFd".parse::
().unwrap(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), signer.clone()); + + // TODO: necessary right now because transaction validation fails for deposit tx + // with `from` account that doesn't have sufficient ETH balance. + // Should update the tx validation logic for deposit tx to + // 1. check if `tx.value > account.balance + tx.mint` + // 2. don't check `account.balance > gas * price + value` (the gas costs have been prepaid on + // L1) + // source: https://specs.optimism.io/protocol/deposits.html#execution + let fund_account_tx = TransactionRequest::default() + .with_chain_id(31337) + .with_nonce(0) + .with_from(sender_addr) + .with_to(deposit_tx_from) + .with_value(U256::from(1e18)) + .with_gas_limit(21_000) + .with_max_fee_per_gas(20_000_000_000) + .with_max_priority_fee_per_gas(1_000_000_000); + + provider + .send_transaction(WithOtherFields::new(fund_account_tx)) + .await + .unwrap() + .register() + .await + .unwrap(); + + // mine block + api.evm_mine(None).await.unwrap(); + + let pending = provider + .send_raw_transaction(raw_deposit_tx.as_slice()) + .await + .unwrap() + .register() + .await + .unwrap(); + + // mine block + api.evm_mine(None).await.unwrap(); + + let receipt = + provider.get_transaction_receipt(pending.tx_hash().to_owned()).await.unwrap().unwrap(); + + assert_eq!(pending.tx_hash(), &tx_hash); + assert_eq!(receipt.transaction_hash, tx_hash); +} From 0951fb55bf31789f1c6a24d944deea3eca09fd3a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 1 Aug 2024 18:19:30 +0300 Subject: [PATCH 1312/1963] fix(fmt): surround with returns in fn with format disabled (#8582) fix(fmt): surround returns if fn format disabled --- crates/fmt/src/formatter.rs | 12 +++++++++++- .../FunctionDefinitionWithFunctionReturns/fmt.sol | 8 ++++++++ .../original.sol | 8 ++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 94052d9a93dfb..7dda996f8062c 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1537,7 +1537,17 @@ impl<'a, W: Write> Formatter<'a, W> { let returns_start_loc = func.returns.first().unwrap().0; let returns_loc = returns_start_loc.with_end_from(&func.returns.last().unwrap().0); if fmt.inline_config.is_disabled(returns_loc) { - fmt.indented(1, |fmt| fmt.visit_source(returns_loc))?; + fmt.indented(1, |fmt| { + fmt.surrounded( + SurroundingChunk::new("returns (", Some(returns_loc.start()), None), + SurroundingChunk::new(")", None, returns_end), + |fmt, _| { + fmt.visit_source(returns_loc)?; + Ok(()) + }, + )?; + Ok(()) + })?; } else { let mut returns = fmt.items_to_chunks( returns_end, diff --git a/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol index 556db3698eaf5..7b751e22ec26a 100644 --- a/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol +++ b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol @@ -11,3 +11,11 @@ contract ReturnFnFormat { ) {} } + +// https://github.com/foundry-rs/foundry/issues/7920 +contract ReturnFnDisableFormat { + // forgefmt: disable-next-line + function disableFnFormat() external returns (uint256) { + return 0; + } +} diff --git a/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol index 79008d44ae3a7..0c785cde81b14 100644 --- a/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol +++ b/crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol @@ -10,4 +10,12 @@ contract ReturnFnFormat { internal pure returns (uint256) ) {} +} + +// https://github.com/foundry-rs/foundry/issues/7920 +contract ReturnFnDisableFormat { + // forgefmt: disable-next-line + function disableFnFormat() external returns (uint256) { + return 0; + } } \ No newline at end of file From 626221f5ef44b4af950a08e09bd714650d9eb77d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 1 Aug 2024 19:38:15 +0200 Subject: [PATCH 1313/1963] chore: bump compilers 0.10.2 (#8583) chore: bump compilrs 0.10.2 --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f378f0e726730..72854e5183f81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3709,9 +3709,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c47e9b1b142be502b089e9699922110b6f15906f739b8e612755167da4f5a1" +checksum = "97b8ffe1d5a00cd78a9461262377270d88b8d6a8a5f51b402996242bccef3994" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3747,9 +3747,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a8e5d34b4b594806808c200340b24fa1a60b9f65b76ecf0df406c52c0e4019a" +checksum = "9cdb80803e20447fc8c3f4ec97d47ad5fa37286648bb8224edbbc553ebe1a0f4" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3757,9 +3757,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c7481a171c86d76cdd257eeb99e15d532f94502efa51f76858e2196d85840e" +checksum = "3280cf657d802358856a397cb8465b18a0a6c09b1fa6422842e422a9aa21276d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3781,9 +3781,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32523fa23051d11d534493c93e00a482e27abbbb615ca6d646ebe30b749624db" +checksum = "22ecc61aa540bff773d4441a94e0f158769fcedd61f61d3e91608a76d6bcd7aa" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3796,9 +3796,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e03290dd4cd78b076a43e6f8528f240d3ec74c0a56795830327d6dd781a7ac0" +checksum = "a14603a33a217e64cc38977c215b01b37b48a0cae0a739a9f9b3555f16938704" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index a33e01642d920..7c437ab639b53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.5.1", default-features = false } -foundry-compilers = { version = "0.10.1", default-features = false } +foundry-compilers = { version = "0.10.2", default-features = false } foundry-fork-db = "0.2" solang-parser = "=0.3.3" From d856669d9b614a83834c664f443e18194fcdc781 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 2 Aug 2024 14:44:22 +0200 Subject: [PATCH 1314/1963] chore: bump alloy 0.2.1 (#8586) --- Cargo.lock | 280 +++++++++++++----------- Cargo.toml | 44 ++-- crates/anvil/src/eth/api.rs | 7 +- crates/anvil/src/eth/backend/fork.rs | 9 +- crates/anvil/src/eth/backend/mem/mod.rs | 16 +- crates/anvil/src/eth/otterscan/api.rs | 8 +- crates/anvil/tests/it/otterscan.rs | 2 +- crates/anvil/tests/it/traces.rs | 2 +- crates/anvil/tests/it/transaction.rs | 2 +- crates/common/fmt/src/ui.rs | 2 +- 10 files changed, 201 insertions(+), 171 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72854e5183f81..1498a39a5583d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,7 +48,7 @@ dependencies = [ "getrandom", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58047cc851e58c26224521d1ecda466e3d746ebca0274cd5427aa660a88c353" +checksum = "04c309895995eaa4bfcc345f5515a39c7df9447798645cc8bf462b6c5bf1dc96" dependencies = [ "alloy-eips", "alloy-primitives", @@ -93,13 +93,14 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5d42d9f87896536234b0fac1a84ad9d9dc7a4b27839cac35d0899e64ddf083" +checksum = "3f4e0ef72b0876ae3068b2ed7dfae9ae1779ce13cfaec2ee1f08f5bd0348dc57" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-network", + "alloy-network-primitives", "alloy-primitives", "alloy-provider", "alloy-pubsub", @@ -129,14 +130,14 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] name = "alloy-eips" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a3e14fa0d152d00bd8daf605eb74ad397efb0f54bd7155585823dddb4401e" +checksum = "d9431c99a3b3fe606ede4b3d4043bdfbcb780c45b8d8d226c3804e2b75cfbe68" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -146,15 +147,16 @@ dependencies = [ "derive_more", "k256", "once_cell", + "rand", "serde", "sha2", ] [[package]] name = "alloy-genesis" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cb76c8a3913f2466c5488f3a915e3a15d15596bdc935558c1a9be75e9ec508" +checksum = "79614dfe86144328da11098edcc7bc1a3f25ad8d3134a9eb9e857e06f0d9840d" dependencies = [ "alloy-primitives", "alloy-serde", @@ -175,11 +177,12 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e76a9feec2352c78545d1a37415699817bae8dc41654bd1bfe57d6cdd5433bd" +checksum = "57e2865c4c3bb4cdad3f0d9ec1ab5c0c657ba69a375651bd35e32fb6c180ccc2" dependencies = [ "alloy-primitives", + "alloy-sol-types", "serde", "serde_json", "thiserror", @@ -188,13 +191,14 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3223d71dc78f464b2743418d0be8b5c894313e272105a6206ad5e867d67b3ce2" +checksum = "6e701fc87ef9a3139154b0b4ccb935b565d27ffd9de020fe541bf2dec5ae4ede" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-json-rpc", + "alloy-network-primitives", "alloy-primitives", "alloy-rpc-types-eth", "alloy-serde", @@ -206,6 +210,17 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-network-primitives" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec9d5a0f9170b10988b6774498a022845e13eda94318440d17709d50687f67f9" +dependencies = [ + "alloy-primitives", + "alloy-serde", + "serde", +] + [[package]] name = "alloy-primitives" version = "0.7.7" @@ -235,15 +250,16 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29da7457d853cb8199ec04b227d5d2ef598be3e59fc2bbad70c8be213292f32" +checksum = "3f9c0ab10b93de601a6396fc7ff2ea10d3b28c46f079338fa562107ebf9857c8" dependencies = [ "alloy-chains", "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-network", + "alloy-network-primitives", "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", @@ -272,9 +288,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64acfec654ade392cecfa9bba0408eb2a337d55f1b857925da79970cb70f3d6" +checksum = "3f5da2c55cbaf229bad3c5f8b00b5ab66c74ef093e5f3a753d874cfecf7d2281" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -313,9 +329,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8a9e609524fa31c2c70eb24c0da60796809193ad4787a6dfe6d0db0d3ac112d" +checksum = "5b38e3ffdb285df5d9f60cb988d336d9b8e3505acb78750c3bc60336a7af41d3" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -338,9 +354,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e5d76f1e8b22f48b7b8f985782b68e7eb3938780e50e8b646a53e41a598cdf5" +checksum = "e6c31a3750b8f5a350d17354e46a52b0f2f19ec5f2006d816935af599dedc521" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -353,9 +369,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4282c002a4ae9f57887dae57083fcca6dca09cb6685bf98b8582ea93cb3df97d" +checksum = "52ab6509cd38b2e8c8da726e0f61c1e314a81df06a38d37ddec8bced3f8d25ed" dependencies = [ "alloy-primitives", "alloy-serde", @@ -364,9 +380,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73445fbc5c02258e3d0d977835c92366a4d91545fd456c3fc8601c61810bc9f6" +checksum = "ff63f51b2fb2f547df5218527fd0653afb1947bf7fead5b3ce58c75d170b30f7" dependencies = [ "alloy-consensus", "alloy-eips", @@ -382,12 +398,13 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "605fa8462732bb8fd0645a9941e12961e079d45ae6a44634c826f8229c187bdf" +checksum = "81e18424d962d7700a882fe423714bd5b9dde74c7a7589d4255ea64068773aef" dependencies = [ "alloy-consensus", "alloy-eips", + "alloy-network-primitives", "alloy-primitives", "alloy-rlp", "alloy-serde", @@ -400,9 +417,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f561a8cdd377b6ac3beab805b9df5ec2c7d99bb6139aab23c317f26df6fb346" +checksum = "a86eeb49ea0cc79f249faa1d35c20541bb1c317a59b5962cb07b1890355b0064" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -414,9 +431,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06a4bd39910631c11148c5b2c55e2c61f8626affd2a612e382c668d5e5971ce" +checksum = "c2342fed8175642b15a37a51f8729b05b2469281fbeb816f0ccbb0087e2dd74a" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -426,9 +443,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c5b9057acc02aee1b8aac2b5a0729cb0f73d080082c111313e5d1f92a96630" +checksum = "e33feda6a53e6079895aed1d08dcb98a1377b000d80d16370fbbdb8155d547ef" dependencies = [ "alloy-primitives", "arbitrary", @@ -438,9 +455,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37f10592696f4ab8b687d5a8ab55e998a14ea0ca5f8eb20ad74a96ad671bb54a" +checksum = "740a25b92e849ed7b0fa013951fe2f64be9af1ad5abe805037b44fb7770c5c47" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -454,9 +471,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49300a7aecbd28c364fbad6a9f886264f79ff4fed9a67c8caa27c39f99d52b2d" +checksum = "8b1a47bd8487fb2d715f8a203c3bfe7de0b7443eeacb00bd96d8d4eb0d67e184" dependencies = [ "alloy-consensus", "alloy-network", @@ -472,9 +489,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce638c267429ea7513be9fffc47d949d1f425a33c8813fc6a145e03b999e79f" +checksum = "0850956080821ee646461fde2ff17640a2babcd206046a867eda94d9a266fad9" dependencies = [ "alloy-consensus", "alloy-network", @@ -490,9 +507,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9450ae05631ac2a5eb180d91d7162bf71ea7a2bb6833cc7c25997e5a11dc38" +checksum = "0f4f7e76cb4f63dbb56857a74665510517a013fe18da82082f7c66c6d321531e" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -510,9 +527,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b537f3e55f30753578f4623d5f66ddad8fa582af3fa6b15bad23dd1b9775228" +checksum = "1b0707d4f63e4356a110b30ef3add8732ab6d181dd7be4607bf79b8777105cee" dependencies = [ "alloy-consensus", "alloy-network", @@ -530,9 +547,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6efa624373339e7cbdd597a785a69c5fcbc10d5368797a18b7cb3476eadf8c9" +checksum = "81147fb1a384f878653524b9473af71ef2820846bd64a473f26e49fca8e5f8f9" dependencies = [ "alloy-consensus", "alloy-network", @@ -569,7 +586,7 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.2.6", + "indexmap 2.3.0", "proc-macro-error", "proc-macro2", "quote", @@ -602,7 +619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" dependencies = [ "serde", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] @@ -620,9 +637,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b44b0f6f4a2593b258fa7b6cae8968e6a4c404d9ef4f5bc74401f2d04fa23fa" +checksum = "3d0590afbdacf2f8cca49d025a2466f3b6584a016a8b28f532f29f8da1007bae" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -639,9 +656,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d8f1eefa8cb9e7550740ee330feba4fed303a77ad3085707546f9152a88c380" +checksum = "2437d145d80ea1aecde8574d2058cceb8b3c9cba05f6aea8e67907c660d46698" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -654,9 +671,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31007c56dc65bd81392112dda4a14c20ac7e30bb4cb2e9176192e8d9fab1983f" +checksum = "804494366e20468776db4e18f9eb5db7db0fe14f1271eb6dbf155d867233405c" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -675,9 +692,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15ccc1c8f8ae415e93ec0e7851bd4cdf4afdd48793d13a91b860317da1f36104" +checksum = "af855163e7df008799941aa6dd324a43ef2bf264b08ba4b22d44aad6ced65300" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1793,9 +1810,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.16.1" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" +checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" [[package]] name = "byteorder" @@ -1805,9 +1822,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -2081,9 +2098,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -2091,9 +2108,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -2106,9 +2123,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.11" +version = "4.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ae69fbb0833c6fcd5a8d4b8609f108c7ad95fc11e248d853ff2c42a90df26a" +checksum = "a8670053e87c316345e384ca1f3eba3006fc6355ed8b8a1140d104e109e3df34" dependencies = [ "clap", ] @@ -2125,9 +2142,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck", "proc-macro2", @@ -3080,7 +3097,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.72", - "toml 0.8.16", + "toml 0.8.19", "walkdir", ] @@ -3231,7 +3248,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.16", + "toml 0.8.19", "uncased", "version_check", ] @@ -3376,8 +3393,8 @@ dependencies = [ "thiserror", "tikv-jemallocator", "tokio", - "toml 0.8.16", - "toml_edit 0.22.17", + "toml 0.8.19", + "toml_edit 0.22.20", "tower-http", "tracing", "tracing-subscriber", @@ -3408,7 +3425,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror", - "toml 0.8.16", + "toml 0.8.19", "tracing", ] @@ -3423,7 +3440,7 @@ dependencies = [ "similar-asserts", "solang-parser", "thiserror", - "toml 0.8.16", + "toml 0.8.19", "tracing", "tracing-subscriber", ] @@ -3588,7 +3605,7 @@ dependencies = [ "semver 1.0.23", "serde_json", "thiserror", - "toml 0.8.16", + "toml 0.8.19", "tracing", "vergen", "walkdir", @@ -3741,7 +3758,7 @@ dependencies = [ "thiserror", "tokio", "tracing", - "winnow 0.6.16", + "winnow 0.6.18", "yansi", ] @@ -3847,8 +3864,8 @@ dependencies = [ "solang-parser", "tempfile", "thiserror", - "toml 0.8.16", - "toml_edit 0.22.17", + "toml 0.8.19", + "toml_edit 0.22.20", "tracing", "walkdir", ] @@ -3976,7 +3993,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap 2.2.6", + "indexmap 2.3.0", "itertools 0.13.0", "parking_lot", "proptest", @@ -4353,7 +4370,7 @@ dependencies = [ "gix-utils", "itoa", "thiserror", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] @@ -4374,7 +4391,7 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] @@ -4476,7 +4493,7 @@ dependencies = [ "itoa", "smallvec", "thiserror", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] @@ -4511,7 +4528,7 @@ dependencies = [ "gix-validate", "memmap2", "thiserror", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] @@ -4607,7 +4624,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -5073,9 +5090,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -5456,9 +5473,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ "hashbrown 0.14.5", ] @@ -6284,7 +6301,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap 2.3.0", ] [[package]] @@ -6478,12 +6495,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.19" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2288c0e17cc8d342c712bb43a257a80ebffce59cdb33d5000d8348f3ec02528b" +checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" dependencies = [ - "zerocopy", - "zerocopy-derive", + "zerocopy 0.6.6", ] [[package]] @@ -6613,7 +6629,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38ee68ae331824036479c84060534b18254c864fa73366c58d86db3b7b811619" dependencies = [ "futures", - "indexmap 2.2.6", + "indexmap 2.3.0", "nix 0.28.0", "tokio", "tracing", @@ -7132,9 +7148,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5296ccad8d7ccbeb6c5a037a57bfe1ff27e81d8c4efbd3ae7df0a554eb1a818a" +checksum = "54a785dafff303a335980e317669c4e9800cdd5dd2830c6880c3247022761e88" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7790,11 +7806,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "itoa", "memchr", "ryu", @@ -7859,7 +7875,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "itoa", "ryu", "serde", @@ -8149,13 +8165,13 @@ dependencies = [ "sha256", "simple-home-dir", "tokio", - "toml 0.8.16", - "toml_edit 0.22.17", + "toml 0.8.19", + "toml_edit 0.22.20", "uuid 1.10.0", "walkdir", "yansi", "yash-fnmatch", - "zip 2.1.5", + "zip 2.1.6", "zip-extract", ] @@ -8287,7 +8303,7 @@ dependencies = [ "sha2", "thiserror", "url", - "zip 2.1.5", + "zip 2.1.6", ] [[package]] @@ -8710,22 +8726,22 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.17", + "toml_edit 0.22.20", ] [[package]] name = "toml_datetime" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] @@ -8736,22 +8752,22 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.17" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] @@ -9744,9 +9760,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.16" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] @@ -9831,14 +9847,34 @@ dependencies = [ "thiserror", ] +[[package]] +name = "zerocopy" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +dependencies = [ + "byteorder", + "zerocopy-derive 0.6.6", +] + [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] @@ -9893,16 +9929,16 @@ dependencies = [ [[package]] name = "zip" -version = "2.1.5" +version = "2.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b895748a3ebcb69b9d38dcfdf21760859a4b0d0b0015277640c2ef4c69640e6f" +checksum = "40dd8c92efc296286ce1fbd16657c5dbefff44f1b4ca01cc5f517d8b7b3d3e2e" dependencies = [ "arbitrary", "crc32fast", "crossbeam-utils", "displaydoc", "flate2", - "indexmap 2.2.6", + "indexmap 2.3.0", "memchr", "thiserror", "zopfli", diff --git a/Cargo.toml b/Cargo.toml index 7c437ab639b53..d1646a070bee8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,28 +172,28 @@ revm-inspectors = { version = "0.5", features = ["serde"] } ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.2.0", default-features = false } -alloy-contract = { version = "0.2.0", default-features = false } -alloy-eips = { version = "0.2.0", default-features = false } -alloy-genesis = { version = "0.2.0", default-features = false } -alloy-json-rpc = { version = "0.2.0", default-features = false } -alloy-network = { version = "0.2.0", default-features = false } -alloy-node-bindings = { version = "0.2.0", default-features = false } -alloy-provider = { version = "0.2.0", default-features = false } -alloy-pubsub = { version = "0.2.0", default-features = false } -alloy-rpc-client = { version = "0.2.0", default-features = false } -alloy-rpc-types = { version = "0.2.0", default-features = false } -alloy-serde = { version = "0.2.0", default-features = false } -alloy-signer = { version = "0.2.0", default-features = false } -alloy-signer-aws = { version = "0.2.0", default-features = false } -alloy-signer-gcp = { version = "0.2.0", default-features = false } -alloy-signer-ledger = { version = "0.2.0", default-features = false } -alloy-signer-local = { version = "0.2.0", default-features = false } -alloy-signer-trezor = { version = "0.2.0", default-features = false } -alloy-transport = { version = "0.2.0", default-features = false } -alloy-transport-http = { version = "0.2.0", default-features = false } -alloy-transport-ipc = { version = "0.2.0", default-features = false } -alloy-transport-ws = { version = "0.2.0", default-features = false } +alloy-consensus = { version = "0.2.1", default-features = false } +alloy-contract = { version = "0.2.1", default-features = false } +alloy-eips = { version = "0.2.1", default-features = false } +alloy-genesis = { version = "0.2.1", default-features = false } +alloy-json-rpc = { version = "0.2.1", default-features = false } +alloy-network = { version = "0.2.1", default-features = false } +alloy-node-bindings = { version = "0.2.1", default-features = false } +alloy-provider = { version = "0.2.1", default-features = false } +alloy-pubsub = { version = "0.2.1", default-features = false } +alloy-rpc-client = { version = "0.2.1", default-features = false } +alloy-rpc-types = { version = "0.2.1", default-features = false } +alloy-serde = { version = "0.2.1", default-features = false } +alloy-signer = { version = "0.2.1", default-features = false } +alloy-signer-aws = { version = "0.2.1", default-features = false } +alloy-signer-gcp = { version = "0.2.1", default-features = false } +alloy-signer-ledger = { version = "0.2.1", default-features = false } +alloy-signer-local = { version = "0.2.1", default-features = false } +alloy-signer-trezor = { version = "0.2.1", default-features = false } +alloy-transport = { version = "0.2.1", default-features = false } +alloy-transport-http = { version = "0.2.1", default-features = false } +alloy-transport-ipc = { version = "0.2.1", default-features = false } +alloy-transport-ws = { version = "0.2.1", default-features = false } alloy-dyn-abi = "0.7.7" alloy-json-abi = "0.7.7" diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index cd7485d5fa592..4f853cd0c7615 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -48,7 +48,7 @@ use alloy_rpc_types::{ parity::LocalizedTransactionTrace, }, txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, - AccessList, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, + AccessList, AccessListResult, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Index, Log, Transaction, }; @@ -1084,7 +1084,7 @@ impl EthApi { &self, mut request: WithOtherFields, block_number: Option, - ) -> Result { + ) -> Result { node_info!("eth_createAccessList"); let block_request = self.block_request(block_number).await?; // check if the number predates the fork, if in fork mode @@ -1117,9 +1117,10 @@ impl EthApi { )?; ensure_return_ok(exit, &out)?; - Ok(AccessListWithGasUsed { + Ok(AccessListResult { access_list: AccessList(access_list.0), gas_used: U256::from(gas_used), + error: None, }) }) .await? diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index d4b51ae9602e7..7f8146daa945b 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -2,6 +2,7 @@ use crate::eth::{backend::db::Db, error::BlockchainError, pool::transactions::PoolTransaction}; use alloy_consensus::Account; +use alloy_eips::eip2930::AccessListResult; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; use alloy_provider::{ ext::{DebugApi, TraceApi}, @@ -13,7 +14,7 @@ use alloy_rpc_types::{ geth::{GethDebugTracingOptions, GethTrace}, parity::LocalizedTransactionTrace as Trace, }, - AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, Log, Transaction, }; use alloy_serde::WithOtherFields; @@ -205,7 +206,7 @@ impl ClientFork { &self, request: &WithOtherFields, block: Option, - ) -> Result { + ) -> Result { self.provider().create_access_list(request).block_id(block.unwrap_or_default().into()).await } @@ -273,7 +274,7 @@ impl ClientFork { blocknumber: u64, ) -> Result { trace!(target: "backend::fork", "get_account={:?}", address); - self.provider().get_account(address).await.block_id(blocknumber.into()).await + self.provider().get_account(address).block_id(blocknumber.into()).await } pub async fn transaction_by_block_number_and_index( @@ -577,7 +578,7 @@ impl ClientFork { }; let mut transactions = Vec::with_capacity(block_txs_len); for tx in block.transactions.hashes() { - if let Some(tx) = storage.transactions.get(tx).cloned() { + if let Some(tx) = storage.transactions.get(&tx).cloned() { transactions.push(tx.inner); } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index b235646b514cd..ff7ec5b5cb72c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -46,10 +46,7 @@ use alloy_rpc_types::{ GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, NoopFrame, }, - parity::{ - Action::{Call, Create, Reward, Selfdestruct}, - LocalizedTransactionTrace, - }, + parity::LocalizedTransactionTrace, }, AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, @@ -2095,14 +2092,7 @@ impl Backend { // Execute tasks and filter traces let traces = futures::future::try_join_all(trace_tasks).await?; let filtered_traces = - traces.into_iter().flatten().filter(|trace| match &trace.trace.action { - Call(call) => matcher.matches(call.from, Some(call.to)), - Create(create) => matcher.matches(create.from, None), - Selfdestruct(self_destruct) => { - matcher.matches(self_destruct.address, Some(self_destruct.refund_address)) - } - Reward(reward) => matcher.matches(reward.author, None), - }); + traces.into_iter().flatten().filter(|trace| matcher.matches(&trace.trace)); // Apply after and count let filtered_traces: Vec<_> = if let Some(after) = filter.after { @@ -2126,7 +2116,7 @@ impl Backend { let mut receipts = Vec::new(); let storage = self.blockchain.storage.read(); for tx in block.transactions.hashes() { - let receipt = storage.transactions.get(tx)?.receipt.clone(); + let receipt = storage.transactions.get(&tx)?.receipt.clone(); receipts.push(receipt); } Some(receipts) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index f174d79f59cdc..9b6b54a80fa45 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -349,8 +349,10 @@ impl EthApi { if block.transactions.is_uncle() { return Err(BlockchainError::DataUnavailable); } - let receipts_futs = - block.transactions.hashes().map(|hash| async { self.transaction_receipt(*hash).await }); + let receipts_futs = block + .transactions + .hashes() + .map(|hash| async move { self.transaction_receipt(hash).await }); // fetch all receipts let receipts = join_all(receipts_futs) @@ -398,7 +400,7 @@ impl EthApi { BlockTransactions::Uncle => unreachable!(), }; - let receipt_futs = block.transactions.hashes().map(|hash| self.transaction_receipt(*hash)); + let receipt_futs = block.transactions.hashes().map(|hash| self.transaction_receipt(hash)); let receipts = join_all(receipt_futs) .await diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index d0536a0326d7e..fc153f9631cd3 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -385,7 +385,7 @@ async fn ots_get_block_transactions() { result.receipts.iter().enumerate().for_each(|(i, receipt)| { let expected = hashes.pop_front(); assert_eq!(expected, Some(receipt.receipt.transaction_hash)); - assert_eq!(expected, result.fullblock.block.transactions.hashes().nth(i).copied()); + assert_eq!(expected, result.fullblock.block.transactions.hashes().nth(i)); }); } diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 7f2846d5c38c6..ac6f90fe3f9be 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -806,7 +806,7 @@ async fn test_trace_filter() { } let traces = api.trace_filter(tracer).await.unwrap(); - assert_eq!(traces.len(), 3); + assert_eq!(traces.len(), 8); // Test Range Error let latest = provider.get_block_number().await.unwrap(); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 5f9abe80b6bdb..0737209c1dc57 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -1233,6 +1233,6 @@ async fn can_mine_multiple_in_block() { let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - let txs = block.transactions.hashes().copied().collect::>(); + let txs = block.transactions.hashes().collect::>(); assert_eq!(txs, vec![first, second]); } diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index b9deffc7eda2a..77bb228512291 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -278,7 +278,7 @@ transactions: {}", } } -impl UIfmt for BlockTransactions { +impl UIfmt for BlockTransactions { fn pretty(&self) -> String { match self { Self::Hashes(hashes) => hashes.pretty(), From c600237f3e54604274bfdcba627f347493fd21d2 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:04:26 +0300 Subject: [PATCH 1315/1963] fix(fmt): preserve function declaration if fmt disabled (#8587) * fix(fmt): preserve function declaration if fmt disabled * Add test for #3789 --- crates/fmt/src/formatter.rs | 83 +++++++++++++++---- crates/fmt/testdata/InlineDisable/fmt.sol | 17 ++++ .../fmt/testdata/InlineDisable/original.sol | 17 ++++ 3 files changed, 103 insertions(+), 14 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 7dda996f8062c..705e578c97ca5 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1459,7 +1459,8 @@ impl<'a, W: Write> Formatter<'a, W> { self.extend_loc_until(&mut loc, ')'); loc }; - if self.inline_config.is_disabled(params_loc) { + let params_disabled = self.inline_config.is_disabled(params_loc); + if params_disabled { let chunk = self.chunked(func.loc.start(), None, |fmt| fmt.visit_source(params_loc))?; params_multiline = chunk.content.contains('\n'); self.write_chunk(&chunk)?; @@ -1519,7 +1520,16 @@ impl<'a, W: Write> Formatter<'a, W> { .loc() .with_end_from(&func.attributes.last().unwrap().loc()); if fmt.inline_config.is_disabled(attrs_loc) { - fmt.indented(1, |fmt| fmt.visit_source(attrs_loc))?; + // If params are also disabled then write functions attributes on the same line. + if params_disabled { + fmt.write_whitespace_separator(false)?; + let attrs_src = + String::from_utf8(self.source.as_bytes()[attrs_loc.range()].to_vec()) + .map_err(FormatterError::custom)?; + fmt.write_raw(attrs_src)?; + } else { + fmt.indented(1, |fmt| fmt.visit_source(attrs_loc))?; + } } else { fmt.write_postfix_comments_before(attrs_loc.start())?; fmt.write_whitespace_separator(multiline)?; @@ -1537,17 +1547,11 @@ impl<'a, W: Write> Formatter<'a, W> { let returns_start_loc = func.returns.first().unwrap().0; let returns_loc = returns_start_loc.with_end_from(&func.returns.last().unwrap().0); if fmt.inline_config.is_disabled(returns_loc) { - fmt.indented(1, |fmt| { - fmt.surrounded( - SurroundingChunk::new("returns (", Some(returns_loc.start()), None), - SurroundingChunk::new(")", None, returns_end), - |fmt, _| { - fmt.visit_source(returns_loc)?; - Ok(()) - }, - )?; - Ok(()) - })?; + fmt.write_whitespace_separator(false)?; + let returns_src = + String::from_utf8(self.source.as_bytes()[returns_loc.range()].to_vec()) + .map_err(FormatterError::custom)?; + fmt.write_raw(format!("returns ({returns_src})"))?; } else { let mut returns = fmt.items_to_chunks( returns_end, @@ -3036,6 +3040,58 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { match &mut func.body { Some(body) => { let body_loc = body.loc(); + // Handle case where block / statements starts on disabled line. + if fmt.inline_config.is_disabled(body_loc.with_end(body_loc.start())) { + match body { + Statement::Block { statements, .. } if !statements.is_empty() => { + // TODO: move this logic in `visit_body` fn and reuse it. + // Retain enabled statements. + statements.retain(|stmt| { + !fmt.inline_config.is_disabled( + body_loc.with_end(CodeLocation::loc(stmt).start()), + ) + }); + + // Disabled statement stops where first enabled statement starts or + // where body ends (if no statement enabled). + let disabled_stmts_end = match statements.first() { + Some(stmt) => CodeLocation::loc(stmt).start(), + None => body_loc.end(), + }; + + // Write non formatted statements. This includes the curly bracket + // block start, comments and any other disabled statement. + let disabled_stmts_src = String::from_utf8( + fmt.source.as_bytes() + [body_loc.with_end(disabled_stmts_end).range()] + .to_vec(), + ) + .map_err(FormatterError::custom)?; + fmt.write_whitespace_separator(false)?; + fmt.write_raw(disabled_stmts_src.trim_end())?; + // Remove all comments as they're already included in disabled src. + let _ = fmt.comments.remove_all_comments_before(disabled_stmts_end); + + // Write enabled statements. + fmt.indented(1, |fmt| { + fmt.write_lined_visitable( + body_loc.with_start(disabled_stmts_end), + statements.iter_mut(), + |_, _| false, + )?; + Ok(()) + })?; + + // Write curly bracket block end. + fmt.write_whitespace_separator(true)?; + write_chunk!(fmt, body_loc.end(), "}}")?; + + return Ok(()) + } + _ => {} + } + } + let byte_offset = body_loc.start(); let body = fmt.visit_to_chunk(byte_offset, Some(body_loc.end()), body)?; fmt.write_whitespace_separator( @@ -3045,7 +3101,6 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { } None => fmt.write_semicolon()?, } - Ok(()) })?; diff --git a/crates/fmt/testdata/InlineDisable/fmt.sol b/crates/fmt/testdata/InlineDisable/fmt.sol index 31667c5e99a43..9211929e7d026 100644 --- a/crates/fmt/testdata/InlineDisable/fmt.sol +++ b/crates/fmt/testdata/InlineDisable/fmt.sol @@ -489,3 +489,20 @@ error TopLevelCustomErrorArgWithoutName (string); event Event1(uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a); // forgefmt: disable-stop + +function setNumber(uint256 newNumber /* param1 */, uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf /* param2 */) public view returns (bool,bool) { /* inline*/ number1 = newNumber1; // forgefmt: disable-line + number = newNumber; + return (true, true); +} + +function setNumber1(uint256 newNumber /* param1 */, uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf /* param2 */) public view returns (bool,bool) { /* inline*/ number1 = newNumber1; // forgefmt: disable-line +} + +// forgefmt: disable-next-line +function setNumber1(uint256 newNumber , uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf) public view returns (bool,bool) { number1 = newNumber1; +} + +function setNumber(uint256 newNumber, uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf) public { // forgefmt: disable-line + number = newNumber; + number1 = newNumber1; // forgefmt: disable-line +} diff --git a/crates/fmt/testdata/InlineDisable/original.sol b/crates/fmt/testdata/InlineDisable/original.sol index 83d4ee172b00d..7731678940cbf 100644 --- a/crates/fmt/testdata/InlineDisable/original.sol +++ b/crates/fmt/testdata/InlineDisable/original.sol @@ -467,3 +467,20 @@ error TopLevelCustomErrorArgWithoutName (string); event Event1(uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a, uint256 indexed a); // forgefmt: disable-stop + +function setNumber(uint256 newNumber /* param1 */, uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf /* param2 */) public view returns (bool,bool) { /* inline*/ number1 = newNumber1; // forgefmt: disable-line + number = newNumber; + return (true, true); +} + +function setNumber1(uint256 newNumber /* param1 */, uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf /* param2 */) public view returns (bool,bool) { /* inline*/ number1 = newNumber1; // forgefmt: disable-line +} + +// forgefmt: disable-next-line +function setNumber1(uint256 newNumber , uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf) public view returns (bool,bool) { number1 = newNumber1; +} + +function setNumber(uint256 newNumber, uint256 sjdfasdfasdfasdfasfsdfsadfasdfasdfasdfsadjfkhasdfljkahsdfkjasdkfhsaf) public { // forgefmt: disable-line + number = newNumber; + number1 = newNumber1; // forgefmt: disable-line +} From f348df381762c2379501c9ff42b8a4c86dd9c469 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 2 Aug 2024 19:01:03 +0300 Subject: [PATCH 1316/1963] fix(fmt): write prefix comments in if block (#8589) --- crates/fmt/src/formatter.rs | 1 + crates/fmt/testdata/Repros/fmt.sol | 21 +++++++++++++++++++++ crates/fmt/testdata/Repros/original.sol | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 705e578c97ca5..5a3b7f1243c99 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1630,6 +1630,7 @@ impl<'a, W: Write> Formatter<'a, W> { SurroundingChunk::new("if (", Some(loc.start()), Some(cond.loc().start())), SurroundingChunk::new(")", None, Some(if_branch.loc().start())), |fmt, _| { + fmt.write_prefix_comments_before(cond.loc().end())?; cond.visit(fmt)?; fmt.write_postfix_comments_before(if_branch.loc().start()) }, diff --git a/crates/fmt/testdata/Repros/fmt.sol b/crates/fmt/testdata/Repros/fmt.sol index dc1ac24eb3a05..b2e232c1936c8 100644 --- a/crates/fmt/testdata/Repros/fmt.sol +++ b/crates/fmt/testdata/Repros/fmt.sol @@ -17,3 +17,24 @@ function one() external { ) }); } + +// https://github.com/foundry-rs/foundry/issues/3979 +contract Format { + bool public test; + + function testing(uint256 amount) public payable { + if ( + // This is a comment + msg.value == amount + ) { + test = true; + } else { + test = false; + } + + if ( + // Another one + block.timestamp >= amount + ) {} + } +} diff --git a/crates/fmt/testdata/Repros/original.sol b/crates/fmt/testdata/Repros/original.sol index cee4fc97a6af8..23e96ac63a641 100644 --- a/crates/fmt/testdata/Repros/original.sol +++ b/crates/fmt/testdata/Repros/original.sol @@ -17,3 +17,24 @@ function one() external { ) }); } + +// https://github.com/foundry-rs/foundry/issues/3979 +contract Format { + bool public test; + + function testing(uint256 amount) public payable { + if ( + // This is a comment + msg.value == amount + ) { + test = true; + } else { + test = false; + } + + if ( + // Another one + block.timestamp >= amount + ) {} + } +} From cce36f85c80946bd4a1868411aa99eda879a0e43 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 2 Aug 2024 22:37:38 +0200 Subject: [PATCH 1317/1963] feat(cheatcodes): extract crypto cheats into their own category (#8578) --- crates/cheatcodes/assets/cheatcodes.json | 122 +++---- .../cheatcodes/assets/cheatcodes.schema.json | 7 + crates/cheatcodes/spec/src/cheatcode.rs | 8 + crates/cheatcodes/spec/src/vm.rs | 142 ++++---- crates/cheatcodes/src/crypto.rs | 343 ++++++++++++++++++ crates/cheatcodes/src/evm.rs | 64 +--- crates/cheatcodes/src/lib.rs | 2 + crates/cheatcodes/src/script.rs | 2 +- crates/cheatcodes/src/utils.rs | 308 +--------------- testdata/cheats/Vm.sol | 4 +- 10 files changed, 506 insertions(+), 496 deletions(-) create mode 100644 crates/cheatcodes/src/crypto.rs diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index c66f3a5ecc84e..6549b31af167b 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3467,7 +3467,7 @@ 210 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -3487,7 +3487,7 @@ 182 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -3507,7 +3507,7 @@ 98 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -3627,7 +3627,7 @@ 139 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -3647,7 +3647,7 @@ 27 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -3667,7 +3667,7 @@ 109 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -3687,7 +3687,7 @@ 31 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -5114,7 +5114,7 @@ { "func": { "id": "getNonce_1", - "description": "Get a `Wallet`'s nonce.", + "description": "Get the nonce of a `Wallet`.", "declaration": "function getNonce(Wallet calldata wallet) external returns (uint64 nonce);", "visibility": "external", "mutability": "", @@ -5127,7 +5127,7 @@ 173 ] }, - "group": "utilities", + "group": "evm", "status": "stable", "safety": "safe" }, @@ -6907,7 +6907,7 @@ 100 ] }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -7754,6 +7754,26 @@ { "func": { "id": "signCompact_0", + "description": "Signs data with a `Wallet`.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.", + "declaration": "function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);", + "visibility": "external", + "mutability": "", + "signature": "signCompact((address,uint256,uint256,uint256),bytes32)", + "selector": "0x3d0e292f", + "selectorBytes": [ + 61, + 14, + 41, + 47 + ] + }, + "group": "crypto", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "signCompact_1", "description": "Signs `digest` with `privateKey` using the secp256k1 curve.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.", "declaration": "function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);", "visibility": "external", @@ -7767,13 +7787,13 @@ 31 ] }, - "group": "evm", + "group": "crypto", "status": "stable", "safety": "safe" }, { "func": { - "id": "signCompact_1", + "id": "signCompact_2", "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.\nIf `--sender` is provided, the signer with provided address is used, otherwise,\nif exactly one signer is provided to the script, that signer is used.\nRaises error if signer passed through `--sender` does not match any unlocked signers or\nif `--sender` is not provided and not exactly one signer is passed to the script.", "declaration": "function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);", "visibility": "external", @@ -7787,13 +7807,13 @@ 75 ] }, - "group": "evm", + "group": "crypto", "status": "stable", "safety": "safe" }, { "func": { - "id": "signCompact_2", + "id": "signCompact_3", "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.\nRaises error if none of the signers passed into the script have provided address.", "declaration": "function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);", "visibility": "external", @@ -7807,27 +7827,7 @@ 191 ] }, - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "signCompact_3", - "description": "Signs data with a `Wallet`.\nReturns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the\nsignature's `s` value, and the recovery id `v` in a single bytes32.\nThis format reduces the signature size from 65 to 64 bytes.", - "declaration": "function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);", - "visibility": "external", - "mutability": "", - "signature": "signCompact((address,uint256,uint256,uint256),bytes32)", - "selector": "0x3d0e292f", - "selectorBytes": [ - 61, - 14, - 41, - 47 - ] - }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, @@ -7847,13 +7847,33 @@ 64 ] }, - "group": "evm", + "group": "crypto", "status": "stable", "safety": "safe" }, { "func": { "id": "sign_0", + "description": "Signs data with a `Wallet`.", + "declaration": "function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);", + "visibility": "external", + "mutability": "", + "signature": "sign((address,uint256,uint256,uint256),bytes32)", + "selector": "0xb25c5a25", + "selectorBytes": [ + 178, + 92, + 90, + 37 + ] + }, + "group": "crypto", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "sign_1", "description": "Signs `digest` with `privateKey` using the secp256k1 curve.", "declaration": "function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", "visibility": "external", @@ -7867,13 +7887,13 @@ 164 ] }, - "group": "evm", + "group": "crypto", "status": "stable", "safety": "safe" }, { "func": { - "id": "sign_1", + "id": "sign_2", "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nIf `--sender` is provided, the signer with provided address is used, otherwise,\nif exactly one signer is provided to the script, that signer is used.\nRaises error if signer passed through `--sender` does not match any unlocked signers or\nif `--sender` is not provided and not exactly one signer is passed to the script.", "declaration": "function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", "visibility": "external", @@ -7887,13 +7907,13 @@ 51 ] }, - "group": "evm", + "group": "crypto", "status": "stable", "safety": "safe" }, { "func": { - "id": "sign_2", + "id": "sign_3", "description": "Signs `digest` with signer provided to script using the secp256k1 curve.\nRaises error if none of the signers passed into the script have provided address.", "declaration": "function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);", "visibility": "external", @@ -7907,27 +7927,7 @@ 5 ] }, - "group": "evm", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "sign_3", - "description": "Signs data with a `Wallet`.", - "declaration": "function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);", - "visibility": "external", - "mutability": "", - "signature": "sign((address,uint256,uint256,uint256),bytes32)", - "selector": "0xb25c5a25", - "selectorBytes": [ - 178, - 92, - 90, - 37 - ] - }, - "group": "utilities", + "group": "crypto", "status": "stable", "safety": "safe" }, diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index cd66ecdc42ba7..9301196d9cffb 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -305,6 +305,13 @@ "toml" ] }, + { + "description": "Cryptography-related cheatcodes.\n\nExamples: `sign*`.\n\nSafety: safe.", + "type": "string", + "enum": [ + "crypto" + ] + }, { "description": "Generic, uncategorized utilities.\n\nExamples: `toString`, `parse*`, `serialize*`.\n\nSafety: safe.", "type": "string", diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index 91573d89ea200..207cac1590ce4 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -114,6 +114,12 @@ pub enum Group { /// /// Safety: safe. Toml, + /// Cryptography-related cheatcodes. + /// + /// Examples: `sign*`. + /// + /// Safety: safe. + Crypto, /// Generic, uncategorized utilities. /// /// Examples: `toString`, `parse*`, `serialize*`. @@ -137,6 +143,7 @@ impl Group { Self::String | Self::Json | Self::Toml | + Self::Crypto | Self::Utilities => Some(Safety::Safe), } } @@ -153,6 +160,7 @@ impl Group { Self::String => "string", Self::Json => "json", Self::Toml => "toml", + Self::Crypto => "crypto", Self::Utilities => "utilities", } } diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 685a6f751ff1f..a4dc636902f17 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -274,6 +274,10 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function getNonce(address account) external view returns (uint64 nonce); + /// Get the nonce of a `Wallet`. + #[cheatcode(group = Evm, safety = Safe)] + function getNonce(Wallet calldata wallet) external returns (uint64 nonce); + /// Loads a storage slot from an address. #[cheatcode(group = Evm, safety = Safe)] function load(address target, bytes32 slot) external view returns (bytes32 data); @@ -282,62 +286,6 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function loadAllocs(string calldata pathToAllocsJson) external; - /// Signs `digest` with `privateKey` using the secp256k1 curve. - #[cheatcode(group = Evm, safety = Safe)] - function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); - - /// Signs `digest` with `privateKey` using the secp256k1 curve. - /// - /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the - /// signature's `s` value, and the recovery id `v` in a single bytes32. - /// This format reduces the signature size from 65 to 64 bytes. - #[cheatcode(group = Evm, safety = Safe)] - function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); - - /// Signs `digest` with signer provided to script using the secp256k1 curve. - /// - /// If `--sender` is provided, the signer with provided address is used, otherwise, - /// if exactly one signer is provided to the script, that signer is used. - /// - /// Raises error if signer passed through `--sender` does not match any unlocked signers or - /// if `--sender` is not provided and not exactly one signer is passed to the script. - #[cheatcode(group = Evm, safety = Safe)] - function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); - - /// Signs `digest` with signer provided to script using the secp256k1 curve. - /// - /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the - /// signature's `s` value, and the recovery id `v` in a single bytes32. - /// This format reduces the signature size from 65 to 64 bytes. - /// - /// If `--sender` is provided, the signer with provided address is used, otherwise, - /// if exactly one signer is provided to the script, that signer is used. - /// - /// Raises error if signer passed through `--sender` does not match any unlocked signers or - /// if `--sender` is not provided and not exactly one signer is passed to the script. - #[cheatcode(group = Evm, safety = Safe)] - function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs); - - /// Signs `digest` with signer provided to script using the secp256k1 curve. - /// - /// Raises error if none of the signers passed into the script have provided address. - #[cheatcode(group = Evm, safety = Safe)] - function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); - - /// Signs `digest` with signer provided to script using the secp256k1 curve. - /// - /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the - /// signature's `s` value, and the recovery id `v` in a single bytes32. - /// This format reduces the signature size from 65 to 64 bytes. - /// - /// Raises error if none of the signers passed into the script have provided address. - #[cheatcode(group = Evm, safety = Safe)] - function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); - - /// Signs `digest` with `privateKey` using the secp256r1 curve. - #[cheatcode(group = Evm, safety = Safe)] - function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); - // -------- Record Storage -------- /// Records all storage reads and writes. @@ -2163,26 +2111,24 @@ interface Vm { #[cheatcode(group = Toml)] function writeToml(string calldata json, string calldata path, string calldata valueKey) external; + // ======== Cryptography ======== + // -------- Key Management -------- /// Derives a private key from the name, labels the account with that name, and returns the wallet. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function createWallet(string calldata walletLabel) external returns (Wallet memory wallet); /// Generates a wallet from the private key and returns the wallet. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function createWallet(uint256 privateKey) external returns (Wallet memory wallet); /// Generates a wallet from the private key, labels the account with that name, and returns the wallet. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet); - /// Get a `Wallet`'s nonce. - #[cheatcode(group = Utilities)] - function getNonce(Wallet calldata wallet) external returns (uint64 nonce); - /// Signs data with a `Wallet`. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); /// Signs data with a `Wallet`. @@ -2190,37 +2136,93 @@ interface Vm { /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the /// signature's `s` value, and the recovery id `v` in a single bytes32. /// This format reduces the signature size from 65 to 64 bytes. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs); + /// Signs `digest` with `privateKey` using the secp256k1 curve. + #[cheatcode(group = Crypto)] + function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + + /// Signs `digest` with `privateKey` using the secp256k1 curve. + /// + /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the + /// signature's `s` value, and the recovery id `v` in a single bytes32. + /// This format reduces the signature size from 65 to 64 bytes. + #[cheatcode(group = Crypto)] + function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// If `--sender` is provided, the signer with provided address is used, otherwise, + /// if exactly one signer is provided to the script, that signer is used. + /// + /// Raises error if signer passed through `--sender` does not match any unlocked signers or + /// if `--sender` is not provided and not exactly one signer is passed to the script. + #[cheatcode(group = Crypto)] + function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the + /// signature's `s` value, and the recovery id `v` in a single bytes32. + /// This format reduces the signature size from 65 to 64 bytes. + /// + /// If `--sender` is provided, the signer with provided address is used, otherwise, + /// if exactly one signer is provided to the script, that signer is used. + /// + /// Raises error if signer passed through `--sender` does not match any unlocked signers or + /// if `--sender` is not provided and not exactly one signer is passed to the script. + #[cheatcode(group = Crypto)] + function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// Raises error if none of the signers passed into the script have provided address. + #[cheatcode(group = Crypto)] + function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); + + /// Signs `digest` with signer provided to script using the secp256k1 curve. + /// + /// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the + /// signature's `s` value, and the recovery id `v` in a single bytes32. + /// This format reduces the signature size from 65 to 64 bytes. + /// + /// Raises error if none of the signers passed into the script have provided address. + #[cheatcode(group = Crypto)] + function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + + /// Signs `digest` with `privateKey` using the secp256r1 curve. + #[cheatcode(group = Crypto)] + function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); + /// Derive a private key from a provided mnenomic string (or mnenomic file path) /// at the derivation path `m/44'/60'/0'/0/{index}`. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey); /// Derive a private key from a provided mnenomic string (or mnenomic file path) /// at `{derivationPath}{index}`. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index) external pure returns (uint256 privateKey); /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language /// at the derivation path `m/44'/60'/0'/0/{index}`. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function deriveKey(string calldata mnemonic, uint32 index, string calldata language) external pure returns (uint256 privateKey); /// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language /// at `{derivationPath}{index}`. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) external pure returns (uint256 privateKey); /// Adds a private key to the local forge wallet and returns the address. - #[cheatcode(group = Utilities)] + #[cheatcode(group = Crypto)] function rememberKey(uint256 privateKey) external returns (address keyAddr); // -------- Uncategorized Utilities -------- diff --git a/crates/cheatcodes/src/crypto.rs b/crates/cheatcodes/src/crypto.rs new file mode 100644 index 0000000000000..aea346279cc86 --- /dev/null +++ b/crates/cheatcodes/src/crypto.rs @@ -0,0 +1,343 @@ +//! Implementations of [`Crypto`](spec::Group::Crypto) Cheatcodes. + +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_signer::{Signer, SignerSync}; +use alloy_signer_local::{ + coins_bip39::{ + ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, + Portuguese, Spanish, Wordlist, + }, + MnemonicBuilder, PrivateKeySigner, +}; +use alloy_sol_types::SolValue; +use k256::{ + ecdsa::SigningKey, + elliptic_curve::{sec1::ToEncodedPoint, Curve}, + Secp256k1, +}; +use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; + +/// The BIP32 default derivation path prefix. +const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; + +impl Cheatcode for createWallet_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { walletLabel } = self; + create_wallet(&U256::from_be_bytes(keccak256(walletLabel).0), Some(walletLabel), state) + } +} + +impl Cheatcode for createWallet_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { privateKey } = self; + create_wallet(privateKey, None, state) + } +} + +impl Cheatcode for createWallet_2Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { privateKey, walletLabel } = self; + create_wallet(privateKey, Some(walletLabel), state) + } +} + +impl Cheatcode for sign_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { wallet, digest } = self; + let sig = sign(&wallet.privateKey, digest)?; + Ok(encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { wallet, digest } = self; + let sig = sign(&wallet.privateKey, digest)?; + Ok(encode_compact_sig(sig)) + } +} + +impl Cheatcode for deriveKey_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, index } = self; + derive_key::(mnemonic, DEFAULT_DERIVATION_PATH_PREFIX, *index) + } +} + +impl Cheatcode for deriveKey_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, derivationPath, index } = self; + derive_key::(mnemonic, derivationPath, *index) + } +} + +impl Cheatcode for deriveKey_2Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, index, language } = self; + derive_key_str(mnemonic, DEFAULT_DERIVATION_PATH_PREFIX, *index, language) + } +} + +impl Cheatcode for deriveKey_3Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { mnemonic, derivationPath, index, language } = self; + derive_key_str(mnemonic, derivationPath, *index, language) + } +} + +impl Cheatcode for rememberKeyCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { privateKey } = self; + let wallet = parse_wallet(privateKey)?; + let address = wallet.address(); + if let Some(script_wallets) = state.script_wallets() { + script_wallets.add_local_signer(wallet); + } + Ok(address.abi_encode()) + } +} + +impl Cheatcode for sign_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { privateKey, digest } = self; + let sig = sign(privateKey, digest)?; + Ok(encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { privateKey, digest } = self; + let sig = sign(privateKey, digest)?; + Ok(encode_compact_sig(sig)) + } +} + +impl Cheatcode for sign_2Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { digest } = self; + let sig = sign_with_wallet(state, None, digest)?; + Ok(encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_2Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { digest } = self; + let sig = sign_with_wallet(state, None, digest)?; + Ok(encode_compact_sig(sig)) + } +} + +impl Cheatcode for sign_3Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { signer, digest } = self; + let sig = sign_with_wallet(state, Some(*signer), digest)?; + Ok(encode_full_sig(sig)) + } +} + +impl Cheatcode for signCompact_3Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { signer, digest } = self; + let sig = sign_with_wallet(state, Some(*signer), digest)?; + Ok(encode_compact_sig(sig)) + } +} + +impl Cheatcode for signP256Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { privateKey, digest } = self; + sign_p256(privateKey, digest) + } +} + +/// Using a given private key, return its public ETH address, its public key affine x and y +/// coordinates, and its private key (see the 'Wallet' struct) +/// +/// If 'label' is set to 'Some()', assign that label to the associated ETH address in state +fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes) -> Result { + let key = parse_private_key(private_key)?; + let addr = alloy_signer::utils::secret_key_to_address(&key); + + let pub_key = key.verifying_key().as_affine().to_encoded_point(false); + let pub_key_x = U256::from_be_bytes((*pub_key.x().unwrap()).into()); + let pub_key_y = U256::from_be_bytes((*pub_key.y().unwrap()).into()); + + if let Some(label) = label { + state.labels.insert(addr, label.into()); + } + + Ok(Wallet { addr, publicKeyX: pub_key_x, publicKeyY: pub_key_y, privateKey: *private_key } + .abi_encode()) +} + +fn encode_full_sig(sig: alloy_primitives::Signature) -> Vec { + // Retrieve v, r and s from signature. + let v = U256::from(sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte())); + let r = B256::from(sig.r()); + let s = B256::from(sig.s()); + (v, r, s).abi_encode() +} + +fn encode_compact_sig(sig: alloy_primitives::Signature) -> Vec { + // Implement EIP-2098 compact signature. + let r = B256::from(sig.r()); + let mut vs = sig.s(); + vs.set_bit(255, sig.v().y_parity()); + (r, vs).abi_encode() +} + +fn sign(private_key: &U256, digest: &B256) -> Result { + // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. + let wallet = parse_wallet(private_key)?; + let sig = wallet.sign_hash_sync(digest)?; + debug_assert_eq!(sig.recover_address_from_prehash(digest)?, wallet.address()); + Ok(sig) +} + +fn sign_with_wallet( + state: &mut Cheatcodes, + signer: Option
, + digest: &B256, +) -> Result { + let Some(script_wallets) = state.script_wallets() else { + bail!("no wallets are available"); + }; + + let mut script_wallets = script_wallets.inner.lock(); + let maybe_provided_sender = script_wallets.provided_sender; + let signers = script_wallets.multi_wallet.signers()?; + + let signer = if let Some(signer) = signer { + signer + } else if let Some(provided_sender) = maybe_provided_sender { + provided_sender + } else if signers.len() == 1 { + *signers.keys().next().unwrap() + } else { + bail!("could not determine signer"); + }; + + let wallet = signers + .get(&signer) + .ok_or_else(|| fmt_err!("signer with address {signer} is not available"))?; + + let sig = foundry_common::block_on(wallet.sign_hash(digest))?; + debug_assert_eq!(sig.recover_address_from_prehash(digest)?, signer); + Ok(sig) +} + +fn sign_p256(private_key: &U256, digest: &B256) -> Result { + ensure!(*private_key != U256::ZERO, "private key cannot be 0"); + let n = U256::from_limbs(*p256::NistP256::ORDER.as_words()); + ensure!( + *private_key < n, + format!("private key must be less than the secp256r1 curve order ({})", n), + ); + let bytes = private_key.to_be_bytes(); + let signing_key = P256SigningKey::from_bytes((&bytes).into())?; + let signature: Signature = signing_key.sign_prehash(digest.as_slice())?; + let r_bytes: [u8; 32] = signature.r().to_bytes().into(); + let s_bytes: [u8; 32] = signature.s().to_bytes().into(); + + Ok((r_bytes, s_bytes).abi_encode()) +} + +fn parse_private_key(private_key: &U256) -> Result { + ensure!(*private_key != U256::ZERO, "private key cannot be 0"); + ensure!( + *private_key < U256::from_limbs(*Secp256k1::ORDER.as_words()), + "private key must be less than the secp256k1 curve order \ + (115792089237316195423570985008687907852837564279074904382605163141518161494337)", + ); + let bytes = private_key.to_be_bytes(); + SigningKey::from_bytes((&bytes).into()).map_err(Into::into) +} + +pub(super) fn parse_wallet(private_key: &U256) -> Result { + parse_private_key(private_key).map(PrivateKeySigner::from) +} + +fn derive_key_str(mnemonic: &str, path: &str, index: u32, language: &str) -> Result { + match language { + "chinese_simplified" => derive_key::(mnemonic, path, index), + "chinese_traditional" => derive_key::(mnemonic, path, index), + "czech" => derive_key::(mnemonic, path, index), + "english" => derive_key::(mnemonic, path, index), + "french" => derive_key::(mnemonic, path, index), + "italian" => derive_key::(mnemonic, path, index), + "japanese" => derive_key::(mnemonic, path, index), + "korean" => derive_key::(mnemonic, path, index), + "portuguese" => derive_key::(mnemonic, path, index), + "spanish" => derive_key::(mnemonic, path, index), + _ => Err(fmt_err!("unsupported mnemonic language: {language:?}")), + } +} + +fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { + fn derive_key_path(path: &str, index: u32) -> String { + let mut out = path.to_string(); + if !out.ends_with('/') { + out.push('/'); + } + out.push_str(&index.to_string()); + out + } + + let wallet = MnemonicBuilder::::default() + .phrase(mnemonic) + .derivation_path(derive_key_path(path, index))? + .build()?; + let private_key = U256::from_be_bytes(wallet.credential().to_bytes().into()); + Ok(private_key.abi_encode()) +} + +#[cfg(test)] +mod tests { + use super::*; + use alloy_primitives::{hex::FromHex, FixedBytes}; + use p256::ecdsa::signature::hazmat::PrehashVerifier; + + #[test] + fn test_sign_p256() { + use p256::ecdsa::VerifyingKey; + + let pk_u256: U256 = "1".parse().unwrap(); + let signing_key = P256SigningKey::from_bytes(&pk_u256.to_be_bytes().into()).unwrap(); + let digest = FixedBytes::from_hex( + "0x44acf6b7e36c1342c2c5897204fe09504e1e2efb1a900377dbc4e7a6a133ec56", + ) + .unwrap(); + + let result = sign_p256(&pk_u256, &digest).unwrap(); + let result_bytes: [u8; 64] = result.try_into().unwrap(); + let signature = Signature::from_bytes(&result_bytes.into()).unwrap(); + let verifying_key = VerifyingKey::from(&signing_key); + assert!(verifying_key.verify_prehash(digest.as_slice(), &signature).is_ok()); + } + + #[test] + fn test_sign_p256_pk_too_large() { + // max n from https://neuromancer.sk/std/secg/secp256r1 + let pk = + "0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551".parse().unwrap(); + let digest = FixedBytes::from_hex( + "0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad", + ) + .unwrap(); + let result = sign_p256(&pk, &digest); + assert_eq!(result.err().unwrap().to_string(), "private key must be less than the secp256r1 curve order (115792089210356248762697446949407573529996955224135760342422259061068512044369)"); + } + + #[test] + fn test_sign_p256_pk_0() { + let digest = FixedBytes::from_hex( + "0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad", + ) + .unwrap(); + let result = sign_p256(&U256::ZERO, &digest); + assert_eq!(result.err().unwrap().to_string(), "private key cannot be 0"); + } +} diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 2d40319200e9f..1c93afd0f265b 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -65,7 +65,7 @@ pub struct DealRecord { impl Cheatcode for addrCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { privateKey } = self; - let wallet = super::utils::parse_wallet(privateKey)?; + let wallet = super::crypto::parse_wallet(privateKey)?; Ok(wallet.address().abi_encode()) } } @@ -77,6 +77,13 @@ impl Cheatcode for getNonce_0Call { } } +impl Cheatcode for getNonce_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { wallet } = self; + get_nonce(ccx, &wallet.addr) + } +} + impl Cheatcode for loadCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, slot } = *self; @@ -159,61 +166,6 @@ impl Cheatcode for dumpStateCall { } } -impl Cheatcode for sign_0Call { - fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { - let Self { privateKey, digest } = self; - let sig = super::utils::sign(privateKey, digest)?; - Ok(super::utils::encode_full_sig(sig)) - } -} - -impl Cheatcode for signCompact_0Call { - fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { - let Self { privateKey, digest } = self; - let sig = super::utils::sign(privateKey, digest)?; - Ok(super::utils::encode_compact_sig(sig)) - } -} - -impl Cheatcode for sign_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { digest } = self; - let sig = super::utils::sign_with_wallet(ccx, None, digest)?; - Ok(super::utils::encode_full_sig(sig)) - } -} - -impl Cheatcode for signCompact_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { digest } = self; - let sig = super::utils::sign_with_wallet(ccx, None, digest)?; - Ok(super::utils::encode_compact_sig(sig)) - } -} - -impl Cheatcode for sign_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { signer, digest } = self; - let sig = super::utils::sign_with_wallet(ccx, Some(*signer), digest)?; - Ok(super::utils::encode_full_sig(sig)) - } -} - -impl Cheatcode for signCompact_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { signer, digest } = self; - let sig = super::utils::sign_with_wallet(ccx, Some(*signer), digest)?; - Ok(super::utils::encode_compact_sig(sig)) - } -} - -impl Cheatcode for signP256Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { privateKey, digest } = self; - super::utils::sign_p256(privateKey, digest, ccx.state) - } -} - impl Cheatcode for recordCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index b03dbc2d7d2c7..4bd0b22a3436e 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -30,6 +30,8 @@ mod base64; mod config; +mod crypto; + mod env; pub use env::set_execution_context; diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index af4457f8edb10..82eef2354994a 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -171,7 +171,7 @@ fn broadcast_key( private_key: &U256, single_call: bool, ) -> Result { - let wallet = super::utils::parse_wallet(private_key)?; + let wallet = super::crypto::parse_wallet(private_key)?; let new_origin = wallet.address(); let result = broadcast(ccx, Some(&new_origin), single_call); diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 67b154ff246b5..6edd700ec7952 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -1,113 +1,12 @@ //! Implementations of [`Utilities`](spec::Group::Utilities) cheatcodes. -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; -use alloy_primitives::{keccak256, Address, B256, U256}; -use alloy_signer::{Signer, SignerSync}; -use alloy_signer_local::{ - coins_bip39::{ - ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, - Portuguese, Spanish, Wordlist, - }, - MnemonicBuilder, PrivateKeySigner, -}; +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use alloy_primitives::{Address, U256}; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; -use k256::{ - ecdsa::SigningKey, - elliptic_curve::{sec1::ToEncodedPoint, Curve}, - Secp256k1, -}; -use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; use rand::Rng; -/// The BIP32 default derivation path prefix. -const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; - -impl Cheatcode for createWallet_0Call { - fn apply(&self, state: &mut Cheatcodes) -> Result { - let Self { walletLabel } = self; - create_wallet(&U256::from_be_bytes(keccak256(walletLabel).0), Some(walletLabel), state) - } -} - -impl Cheatcode for createWallet_1Call { - fn apply(&self, state: &mut Cheatcodes) -> Result { - let Self { privateKey } = self; - create_wallet(privateKey, None, state) - } -} - -impl Cheatcode for createWallet_2Call { - fn apply(&self, state: &mut Cheatcodes) -> Result { - let Self { privateKey, walletLabel } = self; - create_wallet(privateKey, Some(walletLabel), state) - } -} - -impl Cheatcode for getNonce_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { wallet } = self; - super::evm::get_nonce(ccx, &wallet.addr) - } -} - -impl Cheatcode for sign_3Call { - fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { - let Self { wallet, digest } = self; - let sig = sign(&wallet.privateKey, digest)?; - Ok(encode_full_sig(sig)) - } -} - -impl Cheatcode for signCompact_3Call { - fn apply_stateful(&self, _: &mut CheatsCtxt) -> Result { - let Self { wallet, digest } = self; - let sig = sign(&wallet.privateKey, digest)?; - Ok(encode_compact_sig(sig)) - } -} - -impl Cheatcode for deriveKey_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { mnemonic, index } = self; - derive_key::(mnemonic, DEFAULT_DERIVATION_PATH_PREFIX, *index) - } -} - -impl Cheatcode for deriveKey_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { mnemonic, derivationPath, index } = self; - derive_key::(mnemonic, derivationPath, *index) - } -} - -impl Cheatcode for deriveKey_2Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { mnemonic, index, language } = self; - derive_key_str(mnemonic, DEFAULT_DERIVATION_PATH_PREFIX, *index, language) - } -} - -impl Cheatcode for deriveKey_3Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { mnemonic, derivationPath, index, language } = self; - derive_key_str(mnemonic, derivationPath, *index, language) - } -} - -impl Cheatcode for rememberKeyCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { privateKey } = self; - let wallet = parse_wallet(privateKey)?; - let address = wallet.address(); - if let Some(script_wallets) = ccx.state.script_wallets() { - script_wallets.add_local_signer(wallet); - } - Ok(address.abi_encode()) - } -} - impl Cheatcode for labelCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { account, newLabel } = self; @@ -189,206 +88,3 @@ impl Cheatcode for randomAddressCall { Ok(addr.abi_encode()) } } - -/// Using a given private key, return its public ETH address, its public key affine x and y -/// coordinates, and its private key (see the 'Wallet' struct) -/// -/// If 'label' is set to 'Some()', assign that label to the associated ETH address in state -fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes) -> Result { - let key = parse_private_key(private_key)?; - let addr = alloy_signer::utils::secret_key_to_address(&key); - - let pub_key = key.verifying_key().as_affine().to_encoded_point(false); - let pub_key_x = U256::from_be_bytes((*pub_key.x().unwrap()).into()); - let pub_key_y = U256::from_be_bytes((*pub_key.y().unwrap()).into()); - - if let Some(label) = label { - state.labels.insert(addr, label.into()); - } - - Ok(Wallet { addr, publicKeyX: pub_key_x, publicKeyY: pub_key_y, privateKey: *private_key } - .abi_encode()) -} - -pub(super) fn encode_full_sig(sig: alloy_primitives::Signature) -> Vec { - // Retrieve v, r and s from signature. - let v = U256::from(sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte())); - let r = B256::from(sig.r()); - let s = B256::from(sig.s()); - (v, r, s).abi_encode() -} - -pub(super) fn encode_compact_sig(sig: alloy_primitives::Signature) -> Vec { - // Implement EIP-2098 compact signature. - let r = B256::from(sig.r()); - let mut vs = sig.s(); - vs.set_bit(255, sig.v().y_parity()); - (r, vs).abi_encode() -} - -pub(super) fn sign(private_key: &U256, digest: &B256) -> Result { - // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. - let wallet = parse_wallet(private_key)?; - let sig = wallet.sign_hash_sync(digest)?; - debug_assert_eq!(sig.recover_address_from_prehash(digest)?, wallet.address()); - Ok(sig) -} - -pub(super) fn sign_with_wallet( - ccx: &mut CheatsCtxt, - signer: Option
, - digest: &B256, -) -> Result { - let Some(script_wallets) = ccx.state.script_wallets() else { - bail!("no wallets are available"); - }; - - let mut script_wallets = script_wallets.inner.lock(); - let maybe_provided_sender = script_wallets.provided_sender; - let signers = script_wallets.multi_wallet.signers()?; - - let signer = if let Some(signer) = signer { - signer - } else if let Some(provided_sender) = maybe_provided_sender { - provided_sender - } else if signers.len() == 1 { - *signers.keys().next().unwrap() - } else { - bail!("could not determine signer"); - }; - - let wallet = signers - .get(&signer) - .ok_or_else(|| fmt_err!("signer with address {signer} is not available"))?; - - let sig = foundry_common::block_on(wallet.sign_hash(digest))?; - debug_assert_eq!(sig.recover_address_from_prehash(digest)?, signer); - Ok(sig) -} - -pub(super) fn sign_p256(private_key: &U256, digest: &B256, _state: &mut Cheatcodes) -> Result { - ensure!(*private_key != U256::ZERO, "private key cannot be 0"); - let n = U256::from_limbs(*p256::NistP256::ORDER.as_words()); - ensure!( - *private_key < n, - format!("private key must be less than the secp256r1 curve order ({})", n), - ); - let bytes = private_key.to_be_bytes(); - let signing_key = P256SigningKey::from_bytes((&bytes).into())?; - let signature: Signature = signing_key.sign_prehash(digest.as_slice())?; - let r_bytes: [u8; 32] = signature.r().to_bytes().into(); - let s_bytes: [u8; 32] = signature.s().to_bytes().into(); - - Ok((r_bytes, s_bytes).abi_encode()) -} - -pub(super) fn parse_private_key(private_key: &U256) -> Result { - ensure!(*private_key != U256::ZERO, "private key cannot be 0"); - ensure!( - *private_key < U256::from_limbs(*Secp256k1::ORDER.as_words()), - "private key must be less than the secp256k1 curve order \ - (115792089237316195423570985008687907852837564279074904382605163141518161494337)", - ); - let bytes = private_key.to_be_bytes(); - SigningKey::from_bytes((&bytes).into()).map_err(Into::into) -} - -pub(super) fn parse_wallet(private_key: &U256) -> Result { - parse_private_key(private_key).map(PrivateKeySigner::from) -} - -fn derive_key_str(mnemonic: &str, path: &str, index: u32, language: &str) -> Result { - match language { - "chinese_simplified" => derive_key::(mnemonic, path, index), - "chinese_traditional" => derive_key::(mnemonic, path, index), - "czech" => derive_key::(mnemonic, path, index), - "english" => derive_key::(mnemonic, path, index), - "french" => derive_key::(mnemonic, path, index), - "italian" => derive_key::(mnemonic, path, index), - "japanese" => derive_key::(mnemonic, path, index), - "korean" => derive_key::(mnemonic, path, index), - "portuguese" => derive_key::(mnemonic, path, index), - "spanish" => derive_key::(mnemonic, path, index), - _ => Err(fmt_err!("unsupported mnemonic language: {language:?}")), - } -} - -fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { - fn derive_key_path(path: &str, index: u32) -> String { - let mut out = path.to_string(); - if !out.ends_with('/') { - out.push('/'); - } - out.push_str(&index.to_string()); - out - } - - let wallet = MnemonicBuilder::::default() - .phrase(mnemonic) - .derivation_path(derive_key_path(path, index))? - .build()?; - let private_key = U256::from_be_bytes(wallet.credential().to_bytes().into()); - Ok(private_key.abi_encode()) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::CheatsConfig; - use alloy_primitives::{hex::FromHex, FixedBytes}; - use p256::ecdsa::signature::hazmat::PrehashVerifier; - use std::{path::PathBuf, sync::Arc}; - - fn cheats() -> Cheatcodes { - let config = CheatsConfig { - ffi: true, - root: PathBuf::from(&env!("CARGO_MANIFEST_DIR")), - ..Default::default() - }; - Cheatcodes { config: Arc::new(config), ..Default::default() } - } - - #[test] - fn test_sign_p256() { - use p256::ecdsa::VerifyingKey; - - let pk_u256: U256 = "1".parse().unwrap(); - let signing_key = P256SigningKey::from_bytes(&pk_u256.to_be_bytes().into()).unwrap(); - let digest = FixedBytes::from_hex( - "0x44acf6b7e36c1342c2c5897204fe09504e1e2efb1a900377dbc4e7a6a133ec56", - ) - .unwrap(); - let mut cheats = cheats(); - - let result = sign_p256(&pk_u256, &digest, &mut cheats).unwrap(); - let result_bytes: [u8; 64] = result.try_into().unwrap(); - let signature = Signature::from_bytes(&result_bytes.into()).unwrap(); - let verifying_key = VerifyingKey::from(&signing_key); - assert!(verifying_key.verify_prehash(digest.as_slice(), &signature).is_ok()); - } - - #[test] - fn test_sign_p256_pk_too_large() { - // max n from https://neuromancer.sk/std/secg/secp256r1 - let pk = - "0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551".parse().unwrap(); - let digest = FixedBytes::from_hex( - "0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad", - ) - .unwrap(); - let mut cheats = cheats(); - let result = sign_p256(&pk, &digest, &mut cheats); - assert_eq!(result.err().unwrap().to_string(), "private key must be less than the secp256r1 curve order (115792089210356248762697446949407573529996955224135760342422259061068512044369)"); - } - - #[test] - fn test_sign_p256_pk_0() { - let digest = FixedBytes::from_hex( - "0x54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad", - ) - .unwrap(); - let mut cheats = cheats(); - let result = sign_p256(&U256::ZERO, &digest, &mut cheats); - assert_eq!(result.err().unwrap().to_string(), "private key cannot be 0"); - } -} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 4a9d9cd69a274..0e731d88ebf7f 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -383,15 +383,15 @@ interface Vm { function setEnv(string calldata name, string calldata value) external; function setNonce(address account, uint64 newNonce) external; function setNonceUnsafe(address account, uint64 newNonce) external; + function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs); function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs); function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); - function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs); function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); + function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); - function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); function skip(bool skipTest) external; function sleep(uint256 duration) external; function snapshot() external returns (uint256 snapshotId); From 00ff3673a1c8cd41076779f717d2827c16a004af Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 3 Aug 2024 01:03:00 +0200 Subject: [PATCH 1318/1963] test: future proof deposit weth test (#8593) --- testdata/default/fork/LaunchFork.t.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testdata/default/fork/LaunchFork.t.sol b/testdata/default/fork/LaunchFork.t.sol index da5b365dad464..710ac97f51d97 100644 --- a/testdata/default/fork/LaunchFork.t.sol +++ b/testdata/default/fork/LaunchFork.t.sol @@ -72,7 +72,8 @@ contract ForkTest is DSTest { function testDepositWeth() public { IWETH WETH = IWETH(WETH_TOKEN_ADDR); + uint256 current = WETH.balanceOf(address(this)); WETH.deposit{value: 1000}(); - assertEq(WETH.balanceOf(address(this)), 1000, "WETH balance is not equal to deposited amount."); + assertEq(WETH.balanceOf(address(this)) - current, 1000, "WETH balance is not equal to deposited amount."); } } From 910850011c09437b57e99f8b94b25f03610f9e8a Mon Sep 17 00:00:00 2001 From: Evan Gray <56235822+evan-gray@users.noreply.github.com> Date: Fri, 2 Aug 2024 23:12:58 -0400 Subject: [PATCH 1319/1963] fix(anvil): support overlapping anvil_mine calls (#8594) * fix(anvil): support overlapping anvil_mine calls * no manual drop --------- Co-authored-by: Matthias Seitz --- crates/anvil/src/eth/backend/mem/mod.rs | 4 +++ crates/anvil/tests/it/api.rs | 42 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ff7ec5b5cb72c..c3285e25f97c3 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -183,6 +183,8 @@ pub struct Backend { slots_in_an_epoch: u64, /// Precompiles to inject to the EVM. precompile_factory: Option>, + /// Prevent race conditions during mining + mining: Arc>, } impl Backend { @@ -259,6 +261,7 @@ impl Backend { node_config, slots_in_an_epoch, precompile_factory, + mining: Arc::new(tokio::sync::Mutex::new(())), }; if let Some(interval_block_time) = automine_block_time { @@ -927,6 +930,7 @@ impl Backend { &self, pool_transactions: Vec>, ) -> MinedBlockOutcome { + let _mining_guard = self.mining.lock().await; trace!(target: "backend", "creating new block with {} transactions", pool_transactions.len()); let (outcome, header, block_hash) = { diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 9e640beb908ca..8843efddc419c 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -13,6 +13,7 @@ use alloy_rpc_types::{ }; use alloy_serde::WithOtherFields; use anvil::{eth::api::CLIENT_VERSION, spawn, NodeConfig, CHAIN_ID}; +use futures::join; use std::{collections::HashMap, time::Duration}; #[tokio::test(flavor = "multi_thread")] @@ -375,3 +376,44 @@ async fn can_call_with_state_override() { // `value` *is* changed with state assert_eq!(value, ""); } + +#[tokio::test(flavor = "multi_thread")] +async fn can_mine_while_mining() { + let (api, _) = spawn(NodeConfig::test()).await; + + let total_blocks = 200; + + let block_number = api + .block_by_number(BlockNumberOrTag::Latest) + .await + .unwrap() + .unwrap() + .header + .number + .unwrap(); + assert_eq!(block_number, 0); + + let block = api.block_by_number(BlockNumberOrTag::Number(block_number)).await.unwrap().unwrap(); + assert_eq!(block.header.number.unwrap(), 0); + + let result = join!( + api.anvil_mine(Some(U256::from(total_blocks / 2)), None), + api.anvil_mine(Some(U256::from(total_blocks / 2)), None) + ); + result.0.unwrap(); + result.1.unwrap(); + tokio::time::sleep(Duration::from_millis(100)).await; + + let block_number = api + .block_by_number(BlockNumberOrTag::Latest) + .await + .unwrap() + .unwrap() + .header + .number + .unwrap(); + assert_eq!(block_number, total_blocks); + + let block = api.block_by_number(BlockNumberOrTag::Number(block_number)).await.unwrap().unwrap(); + assert_eq!(block.header.number.unwrap(), total_blocks); +} From d54e94e54e5c655ec00b75e5cbd2b6036a3b12ba Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Sat, 3 Aug 2024 05:58:21 +0200 Subject: [PATCH 1320/1963] fix: add `--compiler-version` as alias of `use` in `forge create` (#8588) add compiler-version as alias of `use` --- crates/cli/src/opts/build/core.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 81fbdf4cbb41b..d575f9ae896a5 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -58,7 +58,12 @@ pub struct CoreBuildArgs { /// Specify the solc version, or a path to a local solc, to build with. /// /// Valid values are in the format `x.y.z`, `solc:x.y.z` or `path/to/solc`. - #[arg(long = "use", help_heading = "Compiler options", value_name = "SOLC_VERSION")] + #[arg( + long = "use", + alias = "compiler-version", + help_heading = "Compiler options", + value_name = "SOLC_VERSION" + )] #[serde(skip)] pub use_solc: Option, From 2cb388d4b31874a02cd9cd8efa289cdb7af7bf8a Mon Sep 17 00:00:00 2001 From: Ryan Schneider Date: Fri, 2 Aug 2024 21:00:30 -0700 Subject: [PATCH 1321/1963] feat(cast) tx: pretty print new transaction fields (#8569) --- crates/common/fmt/src/ui.rs | 397 ++++++++++++++++++++++++++++++++++-- 1 file changed, 378 insertions(+), 19 deletions(-) diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 77bb228512291..bd969fecdca33 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -3,7 +3,8 @@ use alloy_consensus::{AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom, TxType}; use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, B256, I256, U256, U64}; use alloy_rpc_types::{ - AnyTransactionReceipt, Block, BlockTransactions, Log, Transaction, TransactionReceipt, + AccessListItem, AnyTransactionReceipt, Block, BlockTransactions, Log, Transaction, + TransactionReceipt, }; use alloy_serde::OtherFields; use serde::Deserialize; @@ -306,10 +307,188 @@ impl UIfmt for OtherFields { } } +impl UIfmt for AccessListItem { + fn pretty(&self) -> String { + let mut s = String::with_capacity(42 + self.storage_keys.len() * 66); + s.push_str(self.address.pretty().as_str()); + s.push_str(" => "); + s.push_str(self.storage_keys.pretty().as_str()); + s + } +} + impl UIfmt for Transaction { fn pretty(&self) -> String { - format!( - " + match self.transaction_type { + Some(1) => format!( + " +accessList {} +blockHash {} +blockNumber {} +chainId {} +from {} +gasLimit {} +gasPrice {} +hash {} +input {} +nonce {} +r {} +s {} +to {} +transactionIndex {} +type {} +value {} +yParity {}{}", + self.access_list.as_deref().unwrap().pretty(), + self.block_hash.pretty(), + self.block_number.pretty(), + self.chain_id.pretty(), + self.from.pretty(), + self.gas.pretty(), + self.gas_price.pretty(), + self.hash.pretty(), + self.input.pretty(), + self.nonce.pretty(), + self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), + self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), + self.to.pretty(), + self.transaction_index.pretty(), + self.transaction_type.unwrap(), + self.value.pretty(), + self.signature.map(|s| s.v).pretty(), + self.other.pretty() + ), + Some(2) => format!( + " +accessList {} +blockHash {} +blockNumber {} +chainId {} +from {} +gasLimit {} +hash {} +input {} +maxFeePerGas {} +maxPriorityFeePerGas {} +nonce {} +r {} +s {} +to {} +transactionIndex {} +type {} +value {} +yParity {}{}", + self.access_list.as_deref().unwrap().pretty(), + self.block_hash.pretty(), + self.block_number.pretty(), + self.chain_id.pretty(), + self.from.pretty(), + self.gas.pretty(), + self.hash.pretty(), + self.input.pretty(), + self.max_fee_per_gas.pretty(), + self.max_priority_fee_per_gas.pretty(), + self.nonce.pretty(), + self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), + self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), + self.to.pretty(), + self.transaction_index.pretty(), + self.transaction_type.unwrap(), + self.value.pretty(), + self.signature.map(|s| s.v).pretty(), + self.other.pretty() + ), + Some(3) => format!( + " +accessList {} +blobVersionedHashes {} +blockHash {} +blockNumber {} +chainId {} +from {} +gasLimit {} +hash {} +input {} +maxFeePerBlobGas {} +maxFeePerGas {} +maxPriorityFeePerGas {} +nonce {} +r {} +s {} +to {} +transactionIndex {} +type {} +value {} +yParity {}{}", + self.access_list.as_deref().unwrap().pretty(), + self.blob_versioned_hashes.as_deref().unwrap().pretty(), + self.block_hash.pretty(), + self.block_number.pretty(), + self.chain_id.pretty(), + self.from.pretty(), + self.gas.pretty(), + self.hash.pretty(), + self.input.pretty(), + self.max_fee_per_blob_gas.pretty(), + self.max_fee_per_gas.pretty(), + self.max_priority_fee_per_gas.pretty(), + self.nonce.pretty(), + self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), + self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), + self.to.pretty(), + self.transaction_index.pretty(), + self.transaction_type.unwrap(), + self.value.pretty(), + self.signature.map(|s| s.v).pretty(), + self.other.pretty() + ), + Some(4) => format!( + " +accessList {} +authorizationList {} +blockHash {} +blockNumber {} +chainId {} +from {} +gasLimit {} +hash {} +input {} +maxFeePerGas {} +maxPriorityFeePerGas {} +nonce {} +r {} +s {} +to {} +transactionIndex {} +type {} +value {} +yParity {}{}", + self.access_list.as_deref().unwrap().pretty(), + self.authorization_list + .as_ref() + .map(|l| serde_json::to_string(&l).unwrap()) + .unwrap_or_default(), + self.block_hash.pretty(), + self.block_number.pretty(), + self.chain_id.pretty(), + self.from.pretty(), + self.gas.pretty(), + self.hash.pretty(), + self.input.pretty(), + self.max_fee_per_gas.pretty(), + self.max_priority_fee_per_gas.pretty(), + self.nonce.pretty(), + self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), + self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), + self.to.pretty(), + self.transaction_index.pretty(), + self.transaction_type.unwrap(), + self.value.pretty(), + self.signature.map(|s| s.v).pretty(), + self.other.pretty() + ), + _ => format!( + " blockHash {} blockNumber {} from {} @@ -324,22 +503,23 @@ to {} transactionIndex {} v {} value {}{}", - self.block_hash.pretty(), - self.block_number.pretty(), - self.from.pretty(), - self.gas.pretty(), - self.gas_price.pretty(), - self.hash.pretty(), - self.input.pretty(), - self.nonce, - self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), - self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), - self.to.pretty(), - self.transaction_index.pretty(), - self.signature.map(|s| s.v).pretty(), - self.value.pretty(), - self.other.pretty() - ) + self.block_hash.pretty(), + self.block_number.pretty(), + self.from.pretty(), + self.gas.pretty(), + self.gas_price.pretty(), + self.hash.pretty(), + self.input.pretty(), + self.nonce, + self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), + self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), + self.to.pretty(), + self.transaction_index.pretty(), + self.signature.map(|s| s.v).pretty(), + self.value.pretty(), + self.other.pretty() + ), + } } } @@ -560,6 +740,185 @@ txType 0 ); } + #[test] + fn can_pretty_print_eip2930() { + let s = r#"{ + "type": "0x1", + "blockHash": "0x2b27fe2bbc8ce01ac7ae8bf74f793a197cf7edbe82727588811fa9a2c4776f81", + "blockNumber": "0x12b1d", + "from": "0x2b371c0262ceab27face32fbb5270ddc6aa01ba4", + "gas": "0x6bdf", + "gasPrice": "0x3b9aca00", + "hash": "0xbddbb685774d8a3df036ed9fb920b48f876090a57e9e90ee60921e0510ef7090", + "input": "0x9c0e3f7a0000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000002a", + "nonce": "0x1c", + "to": "0x8e730df7c70d33118d9e5f79ab81aed0be6f6635", + "transactionIndex": "0x2", + "value": "0x0", + "v": "0x1", + "r": "0x2a98c51c2782f664d3ce571fef0491b48f5ebbc5845fa513192e6e6b24ecdaa1", + "s": "0x29b8e0c67aa9c11327e16556c591dc84a7aac2f6fc57c7f93901be8ee867aebc", + "chainId": "0x66a", + "accessList": [ + { "address": "0x2b371c0262ceab27face32fbb5270ddc6aa01ba4", "storageKeys": ["0x1122334455667788990011223344556677889900112233445566778899001122", "0x0000000000000000000000000000000000000000000000000000000000000000"] }, + { "address": "0x8e730df7c70d33118d9e5f79ab81aed0be6f6635", "storageKeys": [] } + ] + } + "#; + + let tx: Transaction = serde_json::from_str(s).unwrap(); + assert_eq!(tx.pretty().trim(), + r" +accessList [ + 0x2b371c0262CEAb27fAcE32FBB5270dDc6Aa01ba4 => [ + 0x1122334455667788990011223344556677889900112233445566778899001122 + 0x0000000000000000000000000000000000000000000000000000000000000000 + ] + 0x8E730Df7C70D33118D9e5F79ab81aEd0bE6F6635 => [] +] +blockHash 0x2b27fe2bbc8ce01ac7ae8bf74f793a197cf7edbe82727588811fa9a2c4776f81 +blockNumber 76573 +chainId 1642 +from 0x2b371c0262CEAb27fAcE32FBB5270dDc6Aa01ba4 +gasLimit 27615 +gasPrice 1000000000 +hash 0xbddbb685774d8a3df036ed9fb920b48f876090a57e9e90ee60921e0510ef7090 +input 0x9c0e3f7a0000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000002a +nonce 28 +r 0x2a98c51c2782f664d3ce571fef0491b48f5ebbc5845fa513192e6e6b24ecdaa1 +s 0x29b8e0c67aa9c11327e16556c591dc84a7aac2f6fc57c7f93901be8ee867aebc +to 0x8E730Df7C70D33118D9e5F79ab81aEd0bE6F6635 +transactionIndex 2 +type 1 +value 0 +yParity 1 +".trim() + ); + } + + #[test] + fn can_pretty_print_eip1559() { + let s = r#"{ + "type": "0x2", + "blockHash": "0x61abbe5e22738de0462046f5a5d6c4cd6bc1f3a6398e4457d5e293590e721125", + "blockNumber": "0x7647", + "from": "0xbaadf00d42264eeb3fafe6799d0b56cf55df0f00", + "gas": "0x186a0", + "hash": "0xa7231d4da0576fade5d3b9481f4cd52459ec59b9bbdbf4f60d6cd726b2a3a244", + "input": "0x48600055323160015500", + "nonce": "0x12c", + "to": null, + "transactionIndex": "0x41", + "value": "0x0", + "v": "0x1", + "yParity": "0x1", + "r": "0x396864e5f9132327defdb1449504252e1fa6bce73feb8cd6f348a342b198af34", + "s": "0x44dbba72e6d3304104848277143252ee43627c82f02d1ef8e404e1bf97c70158", + "gasPrice": "0x4a817c800", + "maxFeePerGas": "0x4a817c800", + "maxPriorityFeePerGas": "0x4a817c800", + "chainId": "0x66a", + "accessList": [ + { + "address": "0xc141a9a7463e6c4716d9fc0c056c054f46bb2993", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + } + ] + } +"#; + let tx: Transaction = serde_json::from_str(s).unwrap(); + assert_eq!( + tx.pretty().trim(), + r" +accessList [ + 0xC141a9A7463e6C4716d9FC0C056C054F46Bb2993 => [ + 0x0000000000000000000000000000000000000000000000000000000000000000 + ] +] +blockHash 0x61abbe5e22738de0462046f5a5d6c4cd6bc1f3a6398e4457d5e293590e721125 +blockNumber 30279 +chainId 1642 +from 0xBaaDF00d42264eEb3FAFe6799d0b56cf55DF0F00 +gasLimit 100000 +hash 0xa7231d4da0576fade5d3b9481f4cd52459ec59b9bbdbf4f60d6cd726b2a3a244 +input 0x48600055323160015500 +maxFeePerGas 20000000000 +maxPriorityFeePerGas 20000000000 +nonce 300 +r 0x396864e5f9132327defdb1449504252e1fa6bce73feb8cd6f348a342b198af34 +s 0x44dbba72e6d3304104848277143252ee43627c82f02d1ef8e404e1bf97c70158 +to +transactionIndex 65 +type 2 +value 0 +yParity 1 +" + .trim() + ); + } + + #[test] + fn can_pretty_print_eip4884() { + let s = r#"{ + "blockHash": "0xfc2715ff196e23ae613ed6f837abd9035329a720a1f4e8dce3b0694c867ba052", + "blockNumber": "0x2a1cb", + "from": "0xad01b55d7c3448b8899862eb335fbb17075d8de2", + "gas": "0x5208", + "gasPrice": "0x1d1a94a201c", + "maxFeePerGas": "0x1d1a94a201c", + "maxPriorityFeePerGas": "0x1d1a94a201c", + "maxFeePerBlobGas": "0x3e8", + "hash": "0x5ceec39b631763ae0b45a8fb55c373f38b8fab308336ca1dc90ecd2b3cf06d00", + "input": "0x", + "nonce": "0x1b483", + "to": "0x000000000000000000000000000000000000f1c1", + "transactionIndex": "0x0", + "value": "0x0", + "type": "0x3", + "accessList": [], + "chainId": "0x1a1f0ff42", + "blobVersionedHashes": [ + "0x01a128c46fc61395706686d6284f83c6c86dfc15769b9363171ea9d8566e6e76" + ], + "v": "0x0", + "r": "0x343c6239323a81ef61293cb4a4d37b6df47fbf68114adb5dd41581151a077da1", + "s": "0x48c21f6872feaf181d37cc4f9bbb356d3f10b352ceb38d1c3b190d749f95a11b", + "yParity": "0x0" + } +"#; + let tx: Transaction = serde_json::from_str(s).unwrap(); + assert_eq!( + tx.pretty().trim(), + r" +accessList [] +blobVersionedHashes [ + 0x01a128c46fc61395706686d6284f83c6c86dfc15769b9363171ea9d8566e6e76 +] +blockHash 0xfc2715ff196e23ae613ed6f837abd9035329a720a1f4e8dce3b0694c867ba052 +blockNumber 172491 +chainId 7011893058 +from 0xAD01b55d7c3448B8899862eb335FBb17075d8DE2 +gasLimit 21000 +hash 0x5ceec39b631763ae0b45a8fb55c373f38b8fab308336ca1dc90ecd2b3cf06d00 +input 0x +maxFeePerBlobGas 1000 +maxFeePerGas 2000000000028 +maxPriorityFeePerGas 2000000000028 +nonce 111747 +r 0x343c6239323a81ef61293cb4a4d37b6df47fbf68114adb5dd41581151a077da1 +s 0x48c21f6872feaf181d37cc4f9bbb356d3f10b352ceb38d1c3b190d749f95a11b +to 0x000000000000000000000000000000000000f1C1 +transactionIndex 0 +type 3 +value 0 +yParity 0 +" + .trim() + ); + } + #[test] fn print_block_w_txs() { let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":[{"hash":"0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067","nonce":"0x2","blockHash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","blockNumber":"0x3","transactionIndex":"0x0","from":"0xfdcedc3bfca10ecb0890337fbdd1977aba84807a","to":"0xdca8ce283150ab773bcbeb8d38289bdb5661de1e","value":"0x0","gas":"0x15f90","gasPrice":"0x4a817c800","input":"0x","v":"0x25","r":"0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88","s":"0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e"}],"uncles":[]}"#; From 55bf41564f605cae3ca4c95ac5d468b1f14447f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Sat, 3 Aug 2024 07:40:01 +0200 Subject: [PATCH 1322/1963] feat(forge): modify `events` in `forge inspect` to return event signature (#8561) * feat(forge): add `eventIdentifiers` to `forge inspect` * chore: remove quotes from output * fix: test * fix: output 32 bytes of the event identifier * fix: add back `0x` prefix * chore: modify forge inspect events instead of implementing a new cmd --- crates/forge/bin/cmd/inspect.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index ac0ed41b3f342..c1c9f7db83e14 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -1,4 +1,4 @@ -use alloy_primitives::Address; +use alloy_primitives::{hex, keccak256, Address}; use clap::Parser; use comfy_table::{presets::ASCII_MARKDOWN, Table}; use eyre::{Context, Result}; @@ -133,7 +133,7 @@ impl InspectArgs { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { let abi = &abi; - // Print the signature of all errors + // Print the signature of all errors. for er in abi.errors.iter().flat_map(|(_, errors)| errors) { let types = er.inputs.iter().map(|p| p.ty.clone()).collect::>(); let sig = format!("{:x}", er.selector()); @@ -150,13 +150,13 @@ impl InspectArgs { let mut out = serde_json::Map::new(); if let Some(abi) = &artifact.abi { let abi = &abi; - - // print the signature of all events including anonymous + // Print the topic of all events including anonymous. for ev in abi.events.iter().flat_map(|(_, events)| events) { let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::>(); + let topic = hex::encode(keccak256(ev.signature())); out.insert( format!("{}({})", ev.name, types.join(",")), - format!("{:?}", ev.signature()).into(), + format!("0x{topic}").into(), ); } } From 0b73b426d3aeb1563eeab4d5f2f8134d1c3902e3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 Aug 2024 07:31:48 +0000 Subject: [PATCH 1323/1963] chore(deps): weekly `cargo update` (#8598) --- Cargo.lock | 88 ++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1498a39a5583d..0fccb0dd37d41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,7 +48,7 @@ dependencies = [ "getrandom", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47ff94ce0f141c2671c23d02c7b88990dd432856639595c5d010663d017c2c58" +checksum = "3312b2a48f29abe7c3ea7c7fbc1f8cc6ea09b85d74b6232e940df35f2f3826fd" dependencies = [ "num_enum", "serde", @@ -3286,9 +3286,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -5769,11 +5769,11 @@ checksum = "f5438dd2b2ff4c6df6e1ce22d825ed2fa93ee2922235cc45186991717f0a892d" [[package]] name = "normpath" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804" +checksum = "c8911957c4b1549ac0dc74e30db9c8b0e66ddcd6d7acc33098f4c63a64a6d7ed" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6495,11 +6495,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy 0.6.6", + "zerocopy", ] [[package]] @@ -6988,9 +6988,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -7111,7 +7111,7 @@ dependencies = [ "quinn", "rustls 0.23.12", "rustls-native-certs 0.7.1", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "rustls-pki-types", "serde", "serde_json", @@ -7448,7 +7448,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "rustls-pki-types", "schannel", "security-framework", @@ -7465,9 +7465,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64 0.22.1", "rustls-pki-types", @@ -7591,9 +7591,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.6" +version = "2.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ccfb12511cdb770157ace92d7dda771e498445b78f9886e8cdbc5140a4eced" +checksum = "a870e34715d5d59c8536040d4d4e7a41af44d527dc50237036ba4090db7996fc" dependencies = [ "sdd", ] @@ -8394,12 +8394,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] @@ -8790,7 +8791,7 @@ dependencies = [ "pin-project 1.1.5", "prost 0.12.6", "rustls-native-certs 0.7.1", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "rustls-pki-types", "tokio", "tokio-rustls 0.25.0", @@ -9471,11 +9472,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -9628,6 +9629,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -9847,34 +9857,14 @@ dependencies = [ "thiserror", ] -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", + "byteorder", + "zerocopy-derive", ] [[package]] @@ -9990,9 +9980,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", From 42d44bf4841b897107e0a8c41b44154cb3a65ce5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:01:07 +0300 Subject: [PATCH 1324/1963] fix(coverage): account if/else statements without brackets (#8608) fix(coverage): recognize if/else statements without brackets --- crates/evm/coverage/src/analysis.rs | 19 +++++-- crates/forge/tests/cli/coverage.rs | 83 +++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 3 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index e28346181857f..15e2bab30c0d6 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -534,10 +534,23 @@ impl<'a> ContractVisitor<'a> { } } -/// Helper function to check if a given node contains any statement. +/// Helper function to check if a given node is or contains any statement. fn has_statements(node: &Node) -> bool { - let statements: Vec = node.attribute("statements").unwrap_or_default(); - !statements.is_empty() + match node.node_type { + NodeType::DoWhileStatement | + NodeType::EmitStatement | + NodeType::ExpressionStatement | + NodeType::ForStatement | + NodeType::IfStatement | + NodeType::RevertStatement | + NodeType::TryStatement | + NodeType::VariableDeclarationStatement | + NodeType::WhileStatement => true, + _ => { + let statements: Vec = node.attribute("statements").unwrap_or_default(); + !statements.is_empty() + } + } } /// [`SourceAnalyzer`] result type. diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index e8999a7f3aad8..a2ee110ee8362 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1030,3 +1030,86 @@ contract FooTest is DSTest { "#]], ); }); + +// https://github.com/foundry-rs/foundry/issues/8605 +forgetest!(test_single_statement_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + event IsTrue(bool isTrue); + event IsFalse(bool isFalse); + + function ifElseStatementIgnored(bool flag) external { + if (flag) emit IsTrue(true); + else emit IsFalse(false); + + if (flag) flag = true; + else flag = false; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + function testTrueCoverage() external { + AContract a = new AContract(); + a.ifElseStatementIgnored(true); + } + + function testFalseCoverage() external { + AContract a = new AContract(); + a.ifElseStatementIgnored(false); + } +} + "#, + ) + .unwrap(); + + // Assert 50% coverage for true branches. + cmd.arg("coverage") + .args(["--mt".to_string(), "testTrueCoverage".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|--------------|--------------|--------------|---------------| +| src/AContract.sol | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| Total | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | + +"#]]); + + // Assert 50% coverage for false branches. + cmd.forge_fuse() + .arg("coverage") + .args(["--mt".to_string(), "testFalseCoverage".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|--------------|--------------|---------------| +| src/AContract.sol | 100.00% (4/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| Total | 100.00% (4/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | + +"#]]); + + // Assert 100% coverage (true/false branches properly covered). + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (4/4) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | +| Total | 100.00% (4/4) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | + +"#]], + ); +}); From f2518c92c8743777a4941a91e4eb56dd3a96ff0f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:52:56 +0200 Subject: [PATCH 1325/1963] ci: enable asm-keccak on more platforms (#8609) --- .github/workflows/release.yml | 6 ++-- Cargo.lock | 52 ++++++++++++++++------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83d216c7f03d1..9c846ed8c8338 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -133,11 +133,11 @@ jobs: run: | set -eo pipefail target="${{ matrix.target }}" - flags=(--release --bins --no-default-features --features rustls,aws-kms,cli) + flags=(--release --bins --no-default-features --features rustls,aws-kms,cli,asm-keccak) - # `jemalloc` and `keccak-asm` are not supported on MSVC or aarch64 Linux. + # `jemalloc` is not fully supported on MSVC or aarch64 Linux. if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then - flags+=(--features asm-keccak,jemalloc) + flags+=(--features jemalloc) fi [[ "$target" == *windows* ]] && exe=".exe" diff --git a/Cargo.lock b/Cargo.lock index 0fccb0dd37d41..3d1e00b943c16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2833,9 +2833,9 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dunce" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "dyn-clone" @@ -3379,7 +3379,7 @@ dependencies = [ "regex", "reqwest 0.12.5", "revm-inspectors", - "rustc-hash 2.0.0", + "rustc-hash", "semver 1.0.23", "serde", "serde_json", @@ -3601,7 +3601,7 @@ dependencies = [ "proptest", "rand", "revm", - "rustc-hash 2.0.0", + "rustc-hash", "semver 1.0.23", "serde_json", "thiserror", @@ -3691,7 +3691,7 @@ dependencies = [ "num-format", "once_cell", "reqwest 0.12.5", - "rustc-hash 2.0.0", + "rustc-hash", "semver 1.0.23", "serde", "serde_json", @@ -3925,7 +3925,7 @@ dependencies = [ "foundry-test-utils", "itertools 0.13.0", "once_cell", - "rustc-hash 2.0.0", + "rustc-hash", ] [[package]] @@ -3954,7 +3954,7 @@ dependencies = [ "parking_lot", "revm", "revm-inspectors", - "rustc-hash 2.0.0", + "rustc-hash", "serde", "serde_json", "thiserror", @@ -3973,7 +3973,7 @@ dependencies = [ "foundry-evm-core", "rayon", "revm", - "rustc-hash 2.0.0", + "rustc-hash", "semver 1.0.23", "tracing", ] @@ -4025,7 +4025,7 @@ dependencies = [ "rayon", "revm", "revm-inspectors", - "rustc-hash 2.0.0", + "rustc-hash", "serde", "solang-parser", "tempfile", @@ -4048,7 +4048,7 @@ dependencies = [ "futures", "parking_lot", "revm", - "rustc-hash 2.0.0", + "rustc-hash", "serde", "serde_json", "thiserror", @@ -5304,9 +5304,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" +checksum = "422fbc7ff2f2f5bdffeb07718e5a5324dca72b0c9293d50df4026652385e3314" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -6803,16 +6803,17 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash 1.1.0", + "rustc-hash", "rustls 0.23.12", + "socket2", "thiserror", "tokio", "tracing", @@ -6820,14 +6821,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" dependencies = [ "bytes", "rand", "ring", - "rustc-hash 1.1.0", + "rustc-hash", "rustls 0.23.12", "slab", "thiserror", @@ -6844,6 +6845,7 @@ dependencies = [ "libc", "once_cell", "socket2", + "tracing", "windows-sys 0.52.0", ] @@ -7340,12 +7342,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-hash" version = "2.0.0" @@ -7591,9 +7587,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.7" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a870e34715d5d59c8536040d4d4e7a41af44d527dc50237036ba4090db7996fc" +checksum = "8d777f59627453628a9a5be1ee8d948745b94b1dfc2d0c3099cbd9e08ab89e7c" dependencies = [ "sdd", ] @@ -7960,9 +7956,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" +checksum = "57d79b758b7cb2085612b11a235055e485605a5103faccdd633f35bd7aee69dd" dependencies = [ "cc", "cfg-if", From 57c621d88917116b06ddc094cc6dfb0c1c7b5462 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 00:38:25 +0000 Subject: [PATCH 1326/1963] chore(tests): bump forge-std version (#8610) chore: bump forge-std version used for tests Co-authored-by: DaniPopes --- testdata/forge-std-rev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/forge-std-rev b/testdata/forge-std-rev index 9b2bd83b3f144..239d2091e283b 100644 --- a/testdata/forge-std-rev +++ b/testdata/forge-std-rev @@ -1 +1 @@ -07263d193d621c4b2b0ce8b4d54af58f6957d97d \ No newline at end of file +1714bee72e286e73f76e320d110e0eaf5c4e649d \ No newline at end of file From 1ba907bbcca6eb9bfc8fe5d3471d73f2309407c5 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 6 Aug 2024 12:08:34 +0200 Subject: [PATCH 1327/1963] feat: add default `T-needs-triage` label to default feature / bug form (#8612) * add T-needs-triage labels * fix regression --- .github/ISSUE_TEMPLATE/BUG-FORM.yml | 2 +- .github/ISSUE_TEMPLATE/FEATURE-FORM.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG-FORM.yml b/.github/ISSUE_TEMPLATE/BUG-FORM.yml index 8067de8661809..b2575134d782d 100644 --- a/.github/ISSUE_TEMPLATE/BUG-FORM.yml +++ b/.github/ISSUE_TEMPLATE/BUG-FORM.yml @@ -1,6 +1,6 @@ name: Bug report description: File a bug report -labels: ["T-bug"] +labels: ["T-bug", "T-needs-triage"] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/FEATURE-FORM.yml b/.github/ISSUE_TEMPLATE/FEATURE-FORM.yml index d7df540307ceb..581eb5c0d5eed 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE-FORM.yml +++ b/.github/ISSUE_TEMPLATE/FEATURE-FORM.yml @@ -1,6 +1,6 @@ name: Feature request description: Suggest a feature -labels: ["T-feature"] +labels: ["T-feature", "T-needs-triage"] body: - type: markdown attributes: From e9c8bf5f30b697cd4d7ab6e059acb353ed62fa8c Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Tue, 6 Aug 2024 19:52:55 +0800 Subject: [PATCH 1328/1963] Add "%ne" format support for forge console log (#8543) * wip * fix * fix sign * fix --------- Co-authored-by: Matthias Seitz --- crates/common/fmt/src/console.rs | 131 ++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 27 deletions(-) diff --git a/crates/common/fmt/src/console.rs b/crates/common/fmt/src/console.rs index efade2e436a6e..45f12ffbfa107 100644 --- a/crates/common/fmt/src/console.rs +++ b/crates/common/fmt/src/console.rs @@ -1,5 +1,6 @@ use super::UIfmt; use alloy_primitives::{Address, Bytes, FixedBytes, I256, U256}; +use std::iter::Peekable; /// A format specifier. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] @@ -13,21 +14,45 @@ pub enum FormatSpec { Integer, /// %o format spec Object, - /// %e format spec - Exponential, + /// %e format spec with an optional precision + Exponential(Option), /// %x format spec Hexadecimal, } impl FormatSpec { - fn from_char(ch: char) -> Option { - match ch { + fn from_chars(iter: &mut Peekable) -> Option + where + I: Iterator, + { + match iter.next()? { 's' => Some(Self::String), 'd' => Some(Self::Number), 'i' => Some(Self::Integer), 'o' => Some(Self::Object), - 'e' => Some(Self::Exponential), + 'e' => Some(Self::Exponential(None)), 'x' => Some(Self::Hexadecimal), + ch if ch.is_ascii_digit() => { + let mut num = ch.to_string(); + while let Some(&ch) = iter.peek() { + if ch.is_ascii_digit() { + num.push(ch); + iter.next(); + } else { + break; + } + } + if let Some(&ch) = iter.peek() { + if ch == 'e' { + iter.next(); + Some(Self::Exponential(Some(num.parse().ok()?))) + } else { + None + } + } else { + None + } + } _ => None, } } @@ -46,7 +71,7 @@ impl ConsoleFmt for String { FormatSpec::Object => format!("'{}'", self.clone()), FormatSpec::Number | FormatSpec::Integer | - FormatSpec::Exponential | + FormatSpec::Exponential(_) | FormatSpec::Hexadecimal => Self::from("NaN"), } } @@ -58,7 +83,7 @@ impl ConsoleFmt for bool { FormatSpec::String => self.pretty(), FormatSpec::Object => format!("'{}'", self.pretty()), FormatSpec::Number => (*self as i32).to_string(), - FormatSpec::Integer | FormatSpec::Exponential | FormatSpec::Hexadecimal => { + FormatSpec::Integer | FormatSpec::Exponential(_) | FormatSpec::Hexadecimal => { String::from("NaN") } } @@ -75,7 +100,7 @@ impl ConsoleFmt for U256 { let hex = format!("{self:x}"); format!("0x{}", hex.trim_start_matches('0')) } - FormatSpec::Exponential => { + FormatSpec::Exponential(None) => { let log = self.pretty().len() - 1; let exp10 = Self::from(10).pow(Self::from(log)); let amount = *self; @@ -88,6 +113,18 @@ impl ConsoleFmt for U256 { format!("{integer}e{log}") } } + FormatSpec::Exponential(Some(precision)) => { + let exp10 = Self::from(10).pow(Self::from(precision)); + let amount = *self; + let integer = amount / exp10; + let decimal = (amount % exp10).to_string(); + let decimal = format!("{decimal:0>precision$}").trim_end_matches('0').to_string(); + if !decimal.is_empty() { + format!("{integer}.{decimal}") + } else { + format!("{integer}") + } + } } } } @@ -102,7 +139,7 @@ impl ConsoleFmt for I256 { let hex = format!("{self:x}"); format!("0x{}", hex.trim_start_matches('0')) } - FormatSpec::Exponential => { + FormatSpec::Exponential(None) => { let amount = *self; let sign = if amount.is_negative() { "-" } else { "" }; let log = if amount.is_negative() { @@ -117,7 +154,20 @@ impl ConsoleFmt for I256 { if !decimal.is_empty() { format!("{sign}{integer}.{decimal}e{log}") } else { - format!("{integer}e{log}") + format!("{sign}{integer}e{log}") + } + } + FormatSpec::Exponential(Some(precision)) => { + let amount = *self; + let sign = if amount.is_negative() { "-" } else { "" }; + let exp10 = Self::exp10(precision); + let integer = (amount / exp10).twos_complement(); + let decimal = (amount % exp10).twos_complement().to_string(); + let decimal = format!("{decimal:0>precision$}").trim_end_matches('0').to_string(); + if !decimal.is_empty() { + format!("{sign}{integer}.{decimal}") + } else { + format!("{sign}{integer}") } } } @@ -129,7 +179,7 @@ impl ConsoleFmt for Address { match spec { FormatSpec::String | FormatSpec::Hexadecimal => self.pretty(), FormatSpec::Object => format!("'{}'", self.pretty()), - FormatSpec::Number | FormatSpec::Integer | FormatSpec::Exponential => { + FormatSpec::Number | FormatSpec::Integer | FormatSpec::Exponential(_) => { String::from("NaN") } } @@ -165,7 +215,7 @@ impl ConsoleFmt for [u8] { match spec { FormatSpec::String | FormatSpec::Hexadecimal => self.pretty(), FormatSpec::Object => format!("'{}'", self.pretty()), - FormatSpec::Number | FormatSpec::Integer | FormatSpec::Exponential => { + FormatSpec::Number | FormatSpec::Integer | FormatSpec::Exponential(_) => { String::from("NaN") } } @@ -233,31 +283,37 @@ fn format_spec<'a>( ) -> Option<&'a dyn ConsoleFmt> { let mut expect_fmt = false; let mut current_value = values.next(); + let mut chars = s.chars().peekable(); - for (i, ch) in s.char_indices() { - // no more values - if current_value.is_none() { - result.push_str(&s[i..].replace("%%", "%")); - break - } - + while let Some(ch) = chars.next() { if expect_fmt { expect_fmt = false; - if let Some(spec) = FormatSpec::from_char(ch) { + let mut iter = std::iter::once(ch).chain(chars.by_ref()).peekable(); + if let Some(spec) = FormatSpec::from_chars(&mut iter) { // format and write the value - let string = current_value.unwrap().fmt(spec); - result.push_str(&string); - current_value = values.next(); + if let Some(value) = current_value { + let string = value.fmt(spec); + result.push_str(&string); + current_value = values.next(); + } } else { // invalid specifier or a second `%`, in both cases we ignore + result.push('%'); result.push(ch); } - } else { - expect_fmt = ch == '%'; - // push when not a `%` or it's the last char - if !expect_fmt || i == s.len() - 1 { + } else if ch == '%' { + if let Some(&next_ch) = chars.peek() { + if next_ch == '%' { + result.push('%'); + chars.next(); + } else { + expect_fmt = true; + } + } else { result.push(ch); } + } else { + result.push(ch); } } @@ -388,10 +444,20 @@ mod tests { assert_eq!("100", fmt_1("%d", &I256::try_from(100).unwrap())); assert_eq!("100", fmt_1("%i", &I256::try_from(100).unwrap())); assert_eq!("1e2", fmt_1("%e", &I256::try_from(100).unwrap())); + assert_eq!("-1e2", fmt_1("%e", &I256::try_from(-100).unwrap())); assert_eq!("-1.0023e6", fmt_1("%e", &I256::try_from(-1002300).unwrap())); assert_eq!("-1.23e5", fmt_1("%e", &I256::try_from(-123000).unwrap())); assert_eq!("1.0023e6", fmt_1("%e", &I256::try_from(1002300).unwrap())); assert_eq!("1.23e5", fmt_1("%e", &I256::try_from(123000).unwrap())); + + // %ne + assert_eq!("10", fmt_1("%1e", &I256::try_from(100).unwrap())); + assert_eq!("-1", fmt_1("%2e", &I256::try_from(-100).unwrap())); + assert_eq!("123000", fmt_1("%0e", &I256::try_from(123000).unwrap())); + assert_eq!("12300", fmt_1("%1e", &I256::try_from(123000).unwrap())); + assert_eq!("0.0123", fmt_1("%7e", &I256::try_from(123000).unwrap())); + assert_eq!("-0.0123", fmt_1("%7e", &I256::try_from(-123000).unwrap())); + assert_eq!("0x64", fmt_1("%x", &I256::try_from(100).unwrap())); assert_eq!( "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9c", @@ -430,6 +496,17 @@ mod tests { "foo 0xdEADBEeF00000000000000000000000000000000 %s true and 21 foo %", logf3!(log3) ); + + // %ne + let log4 = Log1 { p_0: String::from("%5e"), p_1: U256::from(123456789) }; + assert_eq!("1234.56789", logf1!(log4)); + + let log5 = Log1 { p_0: String::from("foo %3e bar"), p_1: U256::from(123456789) }; + assert_eq!("foo 123456.789 bar", logf1!(log5)); + + let log6 = + Log2 { p_0: String::from("%e and %12e"), p_1: false, p_2: U256::from(123456789) }; + assert_eq!("NaN and 0.000123456789", logf2!(log6)); } #[test] From fbdd40d0c296413352693f677de38864eebbf0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:49:22 +0200 Subject: [PATCH 1329/1963] feat(`cast interface`): allow retrieving abi from contract name (#8585) * feat(`cast interface`): allow retrieving abi from contract name * fix: cast tests * test: add test that fetches weth interface from etherscan * Revert "fix: cast tests" This reverts commit c0ec3e968e0e0d3a3775c73b129a17515118c914. * fix: cast tests on macos --------- Co-authored-by: Matthias Seitz --- crates/cast/bin/cmd/interface.rs | 156 +++++++++++++++++++------------ crates/cast/bin/cmd/logs.rs | 20 ++-- crates/cast/tests/cli/main.rs | 34 +++++++ 3 files changed, 140 insertions(+), 70 deletions(-) diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index a402ea8af1121..caf9ac5ddfe42 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -1,24 +1,31 @@ -use alloy_chains::Chain; -use alloy_json_abi::ContractObject; +use alloy_json_abi::{ContractObject, JsonAbi}; use alloy_primitives::Address; use clap::Parser; use eyre::{Context, Result}; use foundry_block_explorers::Client; use foundry_cli::opts::EtherscanOpts; -use foundry_common::fs; -use foundry_config::Config; +use foundry_common::{compile::ProjectCompiler, fs}; +use foundry_compilers::{info::ContractInfo, utils::canonicalize}; +use foundry_config::{find_project_root_path, load_config_with_root, Config}; use itertools::Itertools; -use std::path::{Path, PathBuf}; +use serde_json::Value; +use std::{ + path::{Path, PathBuf}, + str::FromStr, +}; /// CLI arguments for `cast interface`. #[derive(Clone, Debug, Parser)] pub struct InterfaceArgs { - /// The contract address, or the path to an ABI file. - /// - /// If an address is specified, then the ABI is fetched from Etherscan. - path_or_address: String, + /// The target contract, which can be one of: + /// - A file path to an ABI JSON file. + /// - A contract identifier in the form `:` or just ``. + /// - An Ethereum address, for which the ABI will be fetched from Etherscan. + contract: String, /// The name to use for the generated interface. + /// + /// Only relevant when retrieving the ABI from a file. #[arg(long, short)] name: Option, @@ -47,61 +54,32 @@ pub struct InterfaceArgs { impl InterfaceArgs { pub async fn run(self) -> Result<()> { - let Self { path_or_address, name, pragma, output: output_location, etherscan, json } = self; - let source = if Path::new(&path_or_address).exists() { - AbiPath::Local { path: path_or_address, name } + let Self { contract, name, pragma, output: output_location, etherscan, json } = self; + + // Determine if the target contract is an ABI file, a local contract or an Ethereum address. + let abis = if Path::new(&contract).is_file() && + fs::read_to_string(&contract) + .ok() + .and_then(|content| serde_json::from_str::(&content).ok()) + .is_some() + { + load_abi_from_file(&contract, name)? } else { - let config = Config::from(ðerscan); - let chain = config.chain.unwrap_or_default(); - let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - AbiPath::Etherscan { - chain, - api_key, - address: path_or_address.parse().wrap_err("invalid path or address")?, + match Address::from_str(&contract) { + Ok(address) => fetch_abi_from_etherscan(address, ðerscan).await?, + Err(_) => load_abi_from_artifact(&contract)?, } }; - let items = match source { - AbiPath::Local { path, name } => { - let file = std::fs::read_to_string(&path).wrap_err("unable to read abi file")?; - let obj: ContractObject = serde_json::from_str(&file)?; - let abi = - obj.abi.ok_or_else(|| eyre::eyre!("could not find ABI in file {path}"))?; - let name = name.unwrap_or_else(|| "Interface".to_owned()); - vec![(abi, name)] - } - AbiPath::Etherscan { address, chain, api_key } => { - let client = Client::new(chain, api_key)?; - let source = client.contract_source_code(address).await?; - source - .items - .into_iter() - .map(|item| Ok((item.abi()?, item.contract_name))) - .collect::>>()? - } - }; + // Retrieve interfaces from the array of ABIs. + let interfaces = get_interfaces(abis)?; - let interfaces = items - .into_iter() - .map(|(contract_abi, name)| { - let source = match foundry_cli::utils::abi_to_solidity(&contract_abi, &name) { - Ok(generated_source) => generated_source, - Err(e) => { - warn!("Failed to format interface for {name}: {e}"); - contract_abi.to_sol(&name, None) - } - }; - Ok(InterfaceSource { - json_abi: serde_json::to_string_pretty(&contract_abi)?, - source, - }) - }) - .collect::>>()?; - - // put it all together + // Print result or write to file. let res = if json { + // Format as JSON. interfaces.iter().map(|iface| &iface.json_abi).format("\n").to_string() } else { + // Format as Solidity. format!( "// SPDX-License-Identifier: UNLICENSED\n\ pragma solidity {pragma};\n\n\ @@ -110,7 +88,6 @@ impl InterfaceArgs { ) }; - // print or write to file if let Some(loc) = output_location { if let Some(parent) = loc.parent() { fs::create_dir_all(parent)?; @@ -120,6 +97,7 @@ impl InterfaceArgs { } else { print!("{res}"); } + Ok(()) } } @@ -129,9 +107,63 @@ struct InterfaceSource { source: String, } -// Local is a path to the directory containing the ABI files -// In case of etherscan, ABI is fetched from the address on the chain -enum AbiPath { - Local { path: String, name: Option }, - Etherscan { address: Address, chain: Chain, api_key: String }, +/// Load the ABI from a file. +fn load_abi_from_file(path: &str, name: Option) -> Result> { + let file = std::fs::read_to_string(path).wrap_err("unable to read abi file")?; + let obj: ContractObject = serde_json::from_str(&file)?; + let abi = obj.abi.ok_or_else(|| eyre::eyre!("could not find ABI in file {path}"))?; + let name = name.unwrap_or_else(|| "Interface".to_owned()); + Ok(vec![(abi, name)]) +} + +/// Load the ABI from the artifact of a locally compiled contract. +fn load_abi_from_artifact(path_or_contract: &str) -> Result> { + let root = find_project_root_path(None)?; + let config = load_config_with_root(Some(root)); + let project = config.project()?; + let compiler = ProjectCompiler::new().quiet(true); + + let contract = ContractInfo::new(path_or_contract); + let target_path = if let Some(path) = &contract.path { + canonicalize(project.root().join(path))? + } else { + project.find_contract_path(&contract.name)? + }; + let mut output = compiler.files([target_path.clone()]).compile(&project)?; + + let artifact = output.remove(&target_path, &contract.name).ok_or_else(|| { + eyre::eyre!("Could not find artifact `{contract}` in the compiled artifacts") + })?; + let abi = artifact.abi.as_ref().ok_or_else(|| eyre::eyre!("Failed to fetch lossless ABI"))?; + Ok(vec![(abi.clone(), contract.name)]) +} + +/// Fetches the ABI of a contract from Etherscan. +async fn fetch_abi_from_etherscan( + address: Address, + etherscan: &EtherscanOpts, +) -> Result> { + let config = Config::from(etherscan); + let chain = config.chain.unwrap_or_default(); + let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); + let client = Client::new(chain, api_key)?; + let source = client.contract_source_code(address).await?; + source.items.into_iter().map(|item| Ok((item.abi()?, item.contract_name))).collect() +} + +/// Converts a vector of tuples containing the ABI and contract name into a vector of +/// `InterfaceSource` objects. +fn get_interfaces(abis: Vec<(JsonAbi, String)>) -> Result> { + abis.into_iter() + .map(|(contract_abi, name)| { + let source = match foundry_cli::utils::abi_to_solidity(&contract_abi, &name) { + Ok(generated_source) => generated_source, + Err(e) => { + warn!("Failed to format interface for {name}: {e}"); + contract_abi.to_sol(&name, None) + } + }; + Ok(InterfaceSource { json_abi: serde_json::to_string_pretty(&contract_abi)?, source }) + }) + .collect() } diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index c51bad8cc7d9c..51b95cffcace6 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -391,9 +391,10 @@ mod tests { ) .err() .unwrap() - .to_string(); + .to_string() + .to_lowercase(); - assert_eq!(err, "parser error:\n1234\n^\nInvalid string length"); + assert_eq!(err, "parser error:\n1234\n^\ninvalid string length"); } #[test] @@ -401,9 +402,10 @@ mod tests { let err = build_filter(None, None, None, Some("asdasdasd".to_string()), vec![]) .err() .unwrap() - .to_string(); + .to_string() + .to_lowercase(); - assert_eq!(err, "Odd number of digits"); + assert_eq!(err, "odd number of digits"); } #[test] @@ -411,9 +413,10 @@ mod tests { let err = build_filter(None, None, None, Some(ADDRESS.to_string()), vec![]) .err() .unwrap() - .to_string(); + .to_string() + .to_lowercase(); - assert_eq!(err, "Invalid string length"); + assert_eq!(err, "invalid string length"); } #[test] @@ -427,8 +430,9 @@ mod tests { ) .err() .unwrap() - .to_string(); + .to_string() + .to_lowercase(); - assert_eq!(err, "Invalid string length"); + assert_eq!(err, "invalid string length"); } } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 8349f6d3ec5d4..91d04f031c960 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -910,6 +910,40 @@ interface Interface { assert_eq!(output.trim(), s); }); +// tests that fetches WETH interface from etherscan +// +casttest!(fetch_weth_interface_from_etherscan, |_prj, cmd| { + let weth_address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; + let api_key = "ZUB97R31KSYX7NYVW6224Q6EYY6U56H591"; + cmd.args(["interface", "--etherscan-api-key", api_key, weth_address]); + let output = cmd.stdout_lossy(); + + let weth_interface = r#"// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.4; + +interface WETH9 { + event Approval(address indexed src, address indexed guy, uint256 wad); + event Deposit(address indexed dst, uint256 wad); + event Transfer(address indexed src, address indexed dst, uint256 wad); + event Withdrawal(address indexed src, uint256 wad); + + fallback() external payable; + + function allowance(address, address) external view returns (uint256); + function approve(address guy, uint256 wad) external returns (bool); + function balanceOf(address) external view returns (uint256); + function decimals() external view returns (uint8); + function deposit() external payable; + function name() external view returns (string memory); + function symbol() external view returns (string memory); + function totalSupply() external view returns (uint256); + function transfer(address dst, uint256 wad) external returns (bool); + function transferFrom(address src, address dst, uint256 wad) external returns (bool); + function withdraw(uint256 wad) external; +}"#; + assert_eq!(output.trim(), weth_interface); +}); + const ENS_NAME: &str = "emo.eth"; const ENS_NAMEHASH: B256 = b256!("0a21aaf2f6414aa664deb341d1114351fdb023cad07bf53b28e57c26db681910"); From 78f86c325fddfc084c5739a946a365fe798b26c6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:25:58 +0300 Subject: [PATCH 1330/1963] chore(coverage): cleanup creation / push item (#8616) --- crates/evm/coverage/src/analysis.rs | 147 ++++++++-------------------- 1 file changed, 43 insertions(+), 104 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 15e2bab30c0d6..c25bd79ded340 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -59,11 +59,7 @@ impl<'a> ContractVisitor<'a> { match &node.body { Some(body) => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Function { name }, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Function { name }, &node.src); self.visit_block(body) } _ => Ok(()), @@ -76,11 +72,7 @@ impl<'a> ContractVisitor<'a> { match &node.body { Some(body) => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Function { name }, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Function { name }, &node.src); self.visit_block(body) } _ => Ok(()), @@ -119,22 +111,14 @@ impl<'a> ContractVisitor<'a> { NodeType::YulContinue | NodeType::YulLeave | NodeType::YulVariableDeclaration => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &node.src); Ok(()) } // Skip placeholder statements as they are never referenced in source maps. NodeType::PlaceholderStatement => Ok(()), // Return with eventual subcall NodeType::Return => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &node.src); if let Some(expr) = node.attribute("expression") { self.visit_expression(&expr)?; } @@ -142,11 +126,7 @@ impl<'a> ContractVisitor<'a> { } // Variable declaration NodeType::VariableDeclarationStatement => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &node.src); if let Some(expr) = node.attribute("initialValue") { self.visit_expression(&expr)?; } @@ -225,31 +205,29 @@ impl<'a> ContractVisitor<'a> { // If this source range is not processed like this, it is virtually // impossible to correctly map instructions back to branches that // include more complex logic like conditional logic. - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, - loc: self.source_location_for(&ast::LowFidelitySourceLocation { + self.push_item_kind( + CoverageItemKind::Branch { branch_id, path_id: 0 }, + &ast::LowFidelitySourceLocation { start: node.src.start, length: true_body.src.length.map(|length| { true_body.src.start - node.src.start + length }), index: node.src.index, - }), - hits: 0, - }); + }, + ); // Add the coverage item for branch 1 (false body). // The relevant source range for the false branch is the `else` // statement itself and the false body of the else statement. - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, - loc: self.source_location_for(&ast::LowFidelitySourceLocation { + self.push_item_kind( + CoverageItemKind::Branch { branch_id, path_id: 1 }, + &ast::LowFidelitySourceLocation { start: node.src.start, length: false_body.src.length.map(|length| { false_body.src.start - true_body.src.start + length }), index: node.src.index, - }), - hits: 0, - }); + }, + ); // Process the true body. self.visit_block_or_statement(&true_body)?; @@ -261,11 +239,10 @@ impl<'a> ContractVisitor<'a> { // Add single branch coverage only if it contains statements. if has_statements(&true_body) { // Add the coverage item for branch 0 (true body). - self.push_item(CoverageItem { - kind: CoverageItemKind::SinglePathBranch { branch_id }, - loc: self.source_location_for(&true_body.src), - hits: 0, - }); + self.push_item_kind( + CoverageItemKind::SinglePathBranch { branch_id }, + &true_body.src, + ); // Process the true body. self.visit_block_or_statement(&true_body)?; } @@ -293,11 +270,7 @@ impl<'a> ContractVisitor<'a> { // branch ID as we do self.branch_id += 1; - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Branch { branch_id, path_id: 0 }, &node.src); self.visit_block(body)?; Ok(()) @@ -317,21 +290,13 @@ impl<'a> ContractVisitor<'a> { .ok_or_else(|| eyre::eyre!("try statement had no clause"))? { // Add coverage for clause statement. - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&clause.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &clause.src); self.visit_statement(&clause)?; // Add coverage for clause body only if it is not empty. if let Some(block) = clause.attribute::("block") { if has_statements(&block) { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&block.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &block.src); self.visit_block(&block)?; } } @@ -345,19 +310,11 @@ impl<'a> ContractVisitor<'a> { .attribute::>("cases") .ok_or_else(|| eyre::eyre!("yul switch had no case"))? { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&case.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &case.src); self.visit_statement(&case)?; if let Some(body) = case.body { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&body.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &body.src); self.visit_block(&body)? } } @@ -375,11 +332,7 @@ impl<'a> ContractVisitor<'a> { } if let Some(body) = &node.body { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&body.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &body.src); self.visit_block(body)? } Ok(()) @@ -398,11 +351,7 @@ impl<'a> ContractVisitor<'a> { NodeType::UnaryOperation | NodeType::Conditional | NodeType::YulFunctionCall => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &node.src); Ok(()) } NodeType::FunctionCall => { @@ -410,11 +359,7 @@ impl<'a> ContractVisitor<'a> { // and `structConstructorCall`). let kind: Option = node.attribute("kind"); if let Some("functionCall") = kind.as_deref() { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &node.src); let expr: Option = node.attribute("expression"); if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { @@ -423,16 +368,14 @@ impl<'a> ContractVisitor<'a> { if let Some("require" | "assert") = name.as_deref() { let branch_id = self.branch_id; self.branch_id += 1; - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 0 }, - loc: self.source_location_for(&node.src), - hits: 0, - }); - self.push_item(CoverageItem { - kind: CoverageItemKind::Branch { branch_id, path_id: 1 }, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind( + CoverageItemKind::Branch { branch_id, path_id: 0 }, + &node.src, + ); + self.push_item_kind( + CoverageItemKind::Branch { branch_id, path_id: 1 }, + &node.src, + ); } } } @@ -440,11 +383,7 @@ impl<'a> ContractVisitor<'a> { Ok(()) } NodeType::BinaryOperation => { - self.push_item(CoverageItem { - kind: CoverageItemKind::Statement, - loc: self.source_location_for(&node.src), - hits: 0, - }); + self.push_item_kind(CoverageItemKind::Statement, &node.src); // visit left and right expressions // There could possibly a function call in the left or right expression @@ -500,24 +439,24 @@ impl<'a> ContractVisitor<'a> { } } - /// Pushes a coverage item to the internal collection, and might push a line item as well. - fn push_item(&mut self, item: CoverageItem) { - let source_location = &item.loc; - + /// Creates a coverage item for a given kind and source location. Pushes item to the internal + /// collection (plus additional coverage line if item is a statement). + fn push_item_kind(&mut self, kind: CoverageItemKind, src: &ast::LowFidelitySourceLocation) { + let item = CoverageItem { kind, loc: self.source_location_for(src), hits: 0 }; // Push a line item if we haven't already if matches!( item.kind, CoverageItemKind::Statement | CoverageItemKind::Branch { .. } | CoverageItemKind::SinglePathBranch { .. } - ) && self.last_line < source_location.line + ) && self.last_line < item.loc.line { self.items.push(CoverageItem { kind: CoverageItemKind::Line, - loc: source_location.clone(), + loc: item.loc.clone(), hits: 0, }); - self.last_line = source_location.line; + self.last_line = item.loc.line; } self.items.push(item); From 4351742481c98adaa9ca3e8642e619aa986b3cee Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:01:58 +0300 Subject: [PATCH 1331/1963] fix(coverage): use first opcode for if block with statements (#8615) * fix(coverage): use first opcode for if block anchor * Better naming --- crates/evm/coverage/src/analysis.rs | 45 +++++++------ crates/evm/coverage/src/anchors.rs | 41 +++++++----- crates/evm/coverage/src/lib.rs | 4 +- crates/forge/src/coverage.rs | 2 +- crates/forge/tests/cli/coverage.rs | 97 +++++++++++++++++++++++++++-- 5 files changed, 147 insertions(+), 42 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index c25bd79ded340..cb557eeb6f5b6 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -197,29 +197,25 @@ impl<'a> ContractVisitor<'a> { // Add branch coverage items only if one of true/branch bodies contains // statements. if has_statements(&true_body) || has_statements(&false_body) { - // Add the coverage item for branch 0 (true body). - // The relevant source range for the true branch is the `if(...)` - // statement itself and the true body of the if statement. - // - // The false body of the statement is processed as its own thing. - // If this source range is not processed like this, it is virtually - // impossible to correctly map instructions back to branches that - // include more complex logic like conditional logic. + // The branch instruction is mapped to the first opcode within the true + // body source range. self.push_item_kind( - CoverageItemKind::Branch { branch_id, path_id: 0 }, - &ast::LowFidelitySourceLocation { - start: node.src.start, - length: true_body.src.length.map(|length| { - true_body.src.start - node.src.start + length - }), - index: node.src.index, + CoverageItemKind::Branch { + branch_id, + path_id: 0, + is_first_opcode: true, }, + &true_body.src, ); // Add the coverage item for branch 1 (false body). // The relevant source range for the false branch is the `else` // statement itself and the false body of the else statement. self.push_item_kind( - CoverageItemKind::Branch { branch_id, path_id: 1 }, + CoverageItemKind::Branch { + branch_id, + path_id: 1, + is_first_opcode: false, + }, &ast::LowFidelitySourceLocation { start: node.src.start, length: false_body.src.length.map(|length| { @@ -270,7 +266,10 @@ impl<'a> ContractVisitor<'a> { // branch ID as we do self.branch_id += 1; - self.push_item_kind(CoverageItemKind::Branch { branch_id, path_id: 0 }, &node.src); + self.push_item_kind( + CoverageItemKind::Branch { branch_id, path_id: 0, is_first_opcode: false }, + &node.src, + ); self.visit_block(body)?; Ok(()) @@ -369,11 +368,19 @@ impl<'a> ContractVisitor<'a> { let branch_id = self.branch_id; self.branch_id += 1; self.push_item_kind( - CoverageItemKind::Branch { branch_id, path_id: 0 }, + CoverageItemKind::Branch { + branch_id, + path_id: 0, + is_first_opcode: false, + }, &node.src, ); self.push_item_kind( - CoverageItemKind::Branch { branch_id, path_id: 1 }, + CoverageItemKind::Branch { + branch_id, + path_id: 1, + is_first_opcode: false, + }, &node.src, ); } diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index ad4ad744d2072..9e82ec1cbc9fb 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -24,27 +24,34 @@ pub fn find_anchors( } let item = &items[item_id]; + let find_anchor_by_first_opcode = |item: &CoverageItem| match find_anchor_simple( + source_map, ic_pc_map, item_id, &item.loc, + ) { + Ok(anchor) => Some(anchor), + Err(e) => { + warn!("Could not find anchor for item {item}: {e}"); + None + } + }; match item.kind { - CoverageItemKind::Branch { path_id, .. } => { - match find_anchor_branch(bytecode, source_map, item_id, &item.loc) { - Ok(anchors) => match path_id { - 0 => Some(anchors.0), - 1 => Some(anchors.1), - _ => panic!("Too many paths for branch"), - }, - Err(e) => { - warn!("Could not find anchor for item {item}: {e}"); - None + CoverageItemKind::Branch { path_id, is_first_opcode, .. } => { + if is_first_opcode { + find_anchor_by_first_opcode(item) + } else { + match find_anchor_branch(bytecode, source_map, item_id, &item.loc) { + Ok(anchors) => match path_id { + 0 => Some(anchors.0), + 1 => Some(anchors.1), + _ => panic!("Too many paths for branch"), + }, + Err(e) => { + warn!("Could not find anchor for item {item}: {e}"); + None + } } } } - _ => match find_anchor_simple(source_map, ic_pc_map, item_id, &item.loc) { - Ok(anchor) => Some(anchor), - Err(e) => { - warn!("Could not find anchor for item {item}: {e}"); - None - } - }, + _ => find_anchor_by_first_opcode(item), } }) .collect() diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 24390aa12124c..b9f6913a6b01c 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -294,6 +294,8 @@ pub enum CoverageItemKind { /// /// The first path has ID 0, the next ID 1, and so on. path_id: usize, + /// If true, then the branch anchor is the first opcode within the branch source range. + is_first_opcode: bool, }, /// A branch in the code. SinglePathBranch { @@ -326,7 +328,7 @@ impl Display for CoverageItem { CoverageItemKind::Statement => { write!(f, "Statement")?; } - CoverageItemKind::Branch { branch_id, path_id } => { + CoverageItemKind::Branch { branch_id, path_id, .. } => { write!(f, "Branch (branch: {branch_id}, path: {path_id})")?; } CoverageItemKind::SinglePathBranch { branch_id } => { diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index cc83e132975c8..df0d06d0320e3 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -109,7 +109,7 @@ impl<'a> CoverageReporter for LcovReporter<'a> { CoverageItemKind::Line => { writeln!(self.destination, "DA:{line},{hits}")?; } - CoverageItemKind::Branch { branch_id, path_id } => { + CoverageItemKind::Branch { branch_id, path_id, .. } => { writeln!( self.destination, "BRDA:{line},{branch_id},{path_id},{}", diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index a2ee110ee8362..078e06d9512a0 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1094,10 +1094,10 @@ contract AContractTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|--------------|--------------|---------------| -| src/AContract.sol | 100.00% (4/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | -| Total | 100.00% (4/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|--------------|--------------|--------------|---------------| +| src/AContract.sol | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| Total | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | "#]]); @@ -1113,3 +1113,92 @@ contract AContractTest is DSTest { "#]], ); }); + +// https://github.com/foundry-rs/foundry/issues/8604 +forgetest!(test_branch_with_calldata_reads, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + event IsTrue(bool isTrue); + event IsFalse(bool isFalse); + + function execute(bool[] calldata isTrue) external { + for (uint256 i = 0; i < isTrue.length; i++) { + if (isTrue[i]) { + emit IsTrue(isTrue[i]); + } else { + emit IsFalse(!isTrue[i]); + } + } + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + function testTrueCoverage() external { + AContract a = new AContract(); + bool[] memory isTrue = new bool[](1); + isTrue[0] = true; + a.execute(isTrue); + } + + function testFalseCoverage() external { + AContract a = new AContract(); + bool[] memory isFalse = new bool[](1); + isFalse[0] = false; + a.execute(isFalse); + } +} + "#, + ) + .unwrap(); + + // Assert 50% coverage for true branches. + cmd.arg("coverage") + .args(["--mt".to_string(), "testTrueCoverage".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|--------------|--------------|--------------|---------------| +| src/AContract.sol | 75.00% (3/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 75.00% (3/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | + +"#]]); + + // Assert 50% coverage for false branches. + cmd.forge_fuse() + .arg("coverage") + .args(["--mt".to_string(), "testFalseCoverage".to_string()]) + .assert_success() + .stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|--------------|--------------|--------------|---------------| +| src/AContract.sol | 50.00% (2/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 50.00% (2/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | + +"#]]); + + // Assert 100% coverage (true/false branches properly covered). + cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( + str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (4/4) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | +| Total | 100.00% (4/4) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | + +"#]], + ); +}); From 75342b1b7f79b63914150ca6e884ee68c7c3d199 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 7 Aug 2024 17:35:56 +0300 Subject: [PATCH 1332/1963] chore(coverage): remove SinglePathBranch kind, use Branch kind (#8619) chore(coverage): remove SinglePathBranch kind, use Branch with first opcode --- crates/evm/coverage/src/analysis.rs | 14 +++++++------- crates/evm/coverage/src/lib.rs | 10 +--------- crates/forge/src/coverage.rs | 7 ------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index cb557eeb6f5b6..daf676c2ca9c4 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -236,7 +236,11 @@ impl<'a> ContractVisitor<'a> { if has_statements(&true_body) { // Add the coverage item for branch 0 (true body). self.push_item_kind( - CoverageItemKind::SinglePathBranch { branch_id }, + CoverageItemKind::Branch { + branch_id, + path_id: 0, + is_first_opcode: true, + }, &true_body.src, ); // Process the true body. @@ -451,12 +455,8 @@ impl<'a> ContractVisitor<'a> { fn push_item_kind(&mut self, kind: CoverageItemKind, src: &ast::LowFidelitySourceLocation) { let item = CoverageItem { kind, loc: self.source_location_for(src), hits: 0 }; // Push a line item if we haven't already - if matches!( - item.kind, - CoverageItemKind::Statement | - CoverageItemKind::Branch { .. } | - CoverageItemKind::SinglePathBranch { .. } - ) && self.last_line < item.loc.line + if matches!(item.kind, CoverageItemKind::Statement | CoverageItemKind::Branch { .. }) && + self.last_line < item.loc.line { self.items.push(CoverageItem { kind: CoverageItemKind::Line, diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index b9f6913a6b01c..4481813aca8a6 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -297,11 +297,6 @@ pub enum CoverageItemKind { /// If true, then the branch anchor is the first opcode within the branch source range. is_first_opcode: bool, }, - /// A branch in the code. - SinglePathBranch { - /// The ID that identifies the branch. - branch_id: usize, - }, /// A function in the code. Function { /// The name of the function. @@ -331,9 +326,6 @@ impl Display for CoverageItem { CoverageItemKind::Branch { branch_id, path_id, .. } => { write!(f, "Branch (branch: {branch_id}, path: {path_id})")?; } - CoverageItemKind::SinglePathBranch { branch_id } => { - write!(f, "Branch (branch: {branch_id}, path: 0)")?; - } CoverageItemKind::Function { name } => { write!(f, r#"Function "{name}""#)?; } @@ -418,7 +410,7 @@ impl AddAssign<&CoverageItem> for CoverageSummary { self.statement_hits += 1; } } - CoverageItemKind::Branch { .. } | CoverageItemKind::SinglePathBranch { .. } => { + CoverageItemKind::Branch { .. } => { self.branch_count += 1; if item.hits > 0 { self.branch_hits += 1; diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index df0d06d0320e3..135636d3cac9d 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -116,13 +116,6 @@ impl<'a> CoverageReporter for LcovReporter<'a> { if hits == 0 { "-".to_string() } else { hits.to_string() } )?; } - CoverageItemKind::SinglePathBranch { branch_id } => { - writeln!( - self.destination, - "BRDA:{line},{branch_id},0,{}", - if hits == 0 { "-".to_string() } else { hits.to_string() } - )?; - } // Statements are not in the LCOV format. // We don't add them in order to avoid doubling line hits. _ => {} From 8390f2d6f6b030caf00f337ad28f73f7100967ce Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 8 Aug 2024 01:52:42 +0200 Subject: [PATCH 1333/1963] perf: configure provider poll interval (#8624) --- crates/common/src/provider/mod.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index 7bb943eac0bc4..49cadd95c16a3 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -27,6 +27,13 @@ use std::{ }; use url::ParseError; +/// The assumed block time for unknown chains. +/// We assume that these are chains have a faster block time. +const DEFAULT_UNKNOWN_CHAIN_BLOCK_TIME: Duration = Duration::from_secs(3); + +/// The factor to scale the block time by to get the poll interval. +const POLL_INTERVAL_BLOCK_TIME_SCALE_FACTOR: f32 = 0.6; + /// Helper type alias for a retry provider pub type RetryProvider = RootProvider, N>; @@ -229,7 +236,7 @@ impl ProviderBuilder { pub fn build(self) -> Result { let Self { url, - chain: _, + chain, max_retry, initial_backoff, timeout, @@ -250,6 +257,15 @@ impl ProviderBuilder { .build(); let client = ClientBuilder::default().layer(retry_layer).transport(transport, is_local); + if !is_local { + client.set_poll_interval( + chain + .average_blocktime_hint() + .unwrap_or(DEFAULT_UNKNOWN_CHAIN_BLOCK_TIME) + .mul_f32(POLL_INTERVAL_BLOCK_TIME_SCALE_FACTOR), + ); + } + let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() .on_provider(RootProvider::new(client)); @@ -260,7 +276,7 @@ impl ProviderBuilder { pub fn build_with_wallet(self, wallet: EthereumWallet) -> Result { let Self { url, - chain: _, + chain, max_retry, initial_backoff, timeout, @@ -282,6 +298,15 @@ impl ProviderBuilder { let client = ClientBuilder::default().layer(retry_layer).transport(transport, is_local); + if !is_local { + client.set_poll_interval( + chain + .average_blocktime_hint() + .unwrap_or(DEFAULT_UNKNOWN_CHAIN_BLOCK_TIME) + .mul_f32(POLL_INTERVAL_BLOCK_TIME_SCALE_FACTOR), + ); + } + let provider = AlloyProviderBuilder::<_, _, AnyNetwork>::default() .with_recommended_fillers() .wallet(wallet) From 7f0f5b4c1aa75dc4fd2eb15aca9757491d885902 Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Wed, 7 Aug 2024 17:00:15 -0700 Subject: [PATCH 1334/1963] feat(cast): call json flag (#8618) * add call json flag * update json param to option * address comments --- crates/cast/bin/cmd/call.rs | 7 ++++++- crates/cast/src/lib.rs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 65ec11d6e6be0..4cec6f0f0f478 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -62,6 +62,10 @@ pub struct CallArgs { #[arg(long, short)] block: Option, + /// Print the decoded output as JSON. + #[arg(long, short, help_heading = "Display options")] + json: bool, + #[command(subcommand)] command: Option, @@ -112,6 +116,7 @@ impl CallArgs { decode_internal, labels, data, + json, } = self; if let Some(data) = data { @@ -190,7 +195,7 @@ impl CallArgs { return Ok(()); } - println!("{}", Cast::new(provider).call(&tx, func.as_ref(), block).await?); + println!("{}", Cast::new(provider).call(&tx, func.as_ref(), block, json).await?); Ok(()) } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 46610d6303b7d..93e3c4a0fb638 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -118,7 +118,7 @@ where /// let tx = TransactionRequest::default().to(to).input(bytes.into()); /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(alloy_provider); - /// let data = cast.call(&tx, None, None).await?; + /// let data = cast.call(&tx, None, None, false).await?; /// println!("{}", data); /// # Ok(()) /// # } @@ -128,6 +128,7 @@ where req: &WithOtherFields, func: Option<&Function>, block: Option, + json: bool, ) -> Result { let res = self.provider.call(req).block(block.unwrap_or_default()).await?; @@ -168,6 +169,9 @@ where // handle case when return type is not specified Ok(if decoded.is_empty() { format!("{res}\n") + } else if json { + let tokens = decoded.iter().map(format_token_raw).collect::>(); + serde_json::to_string_pretty(&tokens).unwrap() } else { // seth compatible user-friendly return type conversions decoded.iter().map(format_token).collect::>().join("\n") From 5a3176966b6703c0d363c853b2caf7419e4d82ba Mon Sep 17 00:00:00 2001 From: francesco-gaglione <94604837+francesco-gaglione@users.noreply.github.com> Date: Thu, 8 Aug 2024 02:20:25 +0200 Subject: [PATCH 1335/1963] Forge doc --watch implementation (#8592) * First doc --watch implementation * refactored doc watch implementation * Removed static paths * fix fmt * Update crates/forge/bin/cmd/watch.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/forge/bin/cmd/watch.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/forge/bin/cmd/doc/mod.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/forge/bin/cmd/watch.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * removed unnecessary clones * chore: nits --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/forge/bin/cmd/doc/mod.rs | 30 ++++++++++++++++++++++-------- crates/forge/bin/cmd/watch.rs | 11 ++++++++++- crates/forge/bin/main.rs | 9 ++++++++- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index e561dcc5cc4f2..ad4375bfb7509 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -1,3 +1,4 @@ +use super::watch::WatchArgs; use clap::{Parser, ValueHint}; use eyre::Result; use forge_doc::{ @@ -5,7 +6,7 @@ use forge_doc::{ }; use foundry_cli::opts::GH_REPO_PREFIX_REGEX; use foundry_common::compile::ProjectCompiler; -use foundry_config::{find_project_root_path, load_config_with_root}; +use foundry_config::{find_project_root_path, load_config_with_root, Config}; use std::{path::PathBuf, process::Command}; mod server; @@ -47,6 +48,9 @@ pub struct DocArgs { #[arg(long, requires = "serve")] hostname: Option, + #[command(flatten)] + pub watch: WatchArgs, + /// Port for serving documentation. #[arg(long, short, requires = "serve")] port: Option, @@ -62,14 +66,14 @@ pub struct DocArgs { } impl DocArgs { - pub fn run(self) -> Result<()> { - let root = self.root.clone().unwrap_or(find_project_root_path(None)?); - let config = load_config_with_root(Some(root.clone())); + pub async fn run(self) -> Result<()> { + let config = self.config()?; + let root = &config.root.0; let project = config.project()?; let compiler = ProjectCompiler::new().quiet(true); let _output = compiler.compile(&project)?; - let mut doc_config = config.doc.clone(); + let mut doc_config = config.doc; if let Some(out) = self.out { doc_config.out = out; } @@ -91,7 +95,7 @@ impl DocArgs { } } - let commit = foundry_cli::utils::Git::new(&root).commit_hash(false, "HEAD").ok(); + let commit = foundry_cli::utils::Git::new(root).commit_hash(false, "HEAD").ok(); let mut builder = DocBuilder::new( root.clone(), @@ -113,14 +117,14 @@ impl DocArgs { // If deployment docgen is enabled, add the [Deployments] preprocessor if let Some(deployments) = self.deployments { - builder = builder.with_preprocessor(Deployments { root, deployments }); + builder = builder.with_preprocessor(Deployments { root: root.clone(), deployments }); } builder.build()?; if self.serve { Server::new(doc_config.out) - .with_hostname(self.hostname.unwrap_or("localhost".to_owned())) + .with_hostname(self.hostname.unwrap_or_else(|| "localhost".into())) .with_port(self.port.unwrap_or(3000)) .open(self.open) .serve()?; @@ -128,4 +132,14 @@ impl DocArgs { Ok(()) } + + /// Returns whether watch mode is enabled + pub fn is_watch(&self) -> bool { + self.watch.watch.is_some() + } + + pub fn config(&self) -> Result { + let root = self.root.clone().unwrap_or(find_project_root_path(None)?); + Ok(load_config_with_root(Some(root))) + } } diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 0dfb734688e65..09eb8c66683bd 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -1,4 +1,4 @@ -use super::{build::BuildArgs, snapshot::SnapshotArgs, test::TestArgs}; +use super::{build::BuildArgs, doc::DocArgs, snapshot::SnapshotArgs, test::TestArgs}; use clap::Parser; use eyre::Result; use foundry_cli::utils::{self, FoundryPathExt}; @@ -311,6 +311,15 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { Ok(()) } +/// Executes a [`Watchexec`] that listens for changes in the project's sources directory +pub async fn watch_doc(args: DocArgs) -> Result<()> { + let src_path = args.config()?.src; + let config = args.watch.watchexec_config(|| [src_path])?; + run(config).await?; + + Ok(()) +} + /// Converts a list of arguments to a `watchexec::Command`. /// /// The first index in `args` is the path to the executable. diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 4484be629e256..dc4a18dd6840a 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -105,7 +105,14 @@ fn main() -> Result<()> { } Ok(()) } - ForgeSubcommand::Doc(cmd) => cmd.run(), + ForgeSubcommand::Doc(cmd) => { + if cmd.is_watch() { + utils::block_on(watch::watch_doc(cmd)) + } else { + utils::block_on(cmd.run())?; + Ok(()) + } + } ForgeSubcommand::Selectors { command } => utils::block_on(command.run()), ForgeSubcommand::Generate(cmd) => match cmd.sub { GenerateSubcommands::Test(cmd) => cmd.run(), From 960878a412c839c4d199d68c094156383ee18acf Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 8 Aug 2024 19:42:18 +0800 Subject: [PATCH 1336/1963] fix: add Mandala + Karura + Acala as exceptions for gas calculation during deployment (#8625) * add Mandala & Karura & Acala * update alloy-chains * fix --- Cargo.lock | 4 ++-- crates/cli/src/utils/cmd.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d1e00b943c16..57bb59ae59ef5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3312b2a48f29abe7c3ea7c7fbc1f8cc6ea09b85d74b6232e940df35f2f3826fd" +checksum = "01828af9e8fb20a85b1caf6570d84ee93595d6cbd9e8ea96bda3a4e27a55a4fa" dependencies = [ "num_enum", "serde", diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 6abd11fcee9d2..1e4af95dfdf55 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -163,13 +163,18 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { if let Some(chain) = Chain::from(chain_id).named() { return matches!( chain, - NamedChain::Arbitrum | + NamedChain::Acala | + NamedChain::AcalaMandalaTestnet | + NamedChain::AcalaTestnet | + NamedChain::Arbitrum | NamedChain::ArbitrumGoerli | NamedChain::ArbitrumSepolia | NamedChain::ArbitrumTestnet | + NamedChain::Karura | + NamedChain::KaruraTestnet | NamedChain::Mantle | - NamedChain::MantleTestnet | NamedChain::MantleSepolia | + NamedChain::MantleTestnet | NamedChain::Moonbase | NamedChain::Moonbeam | NamedChain::MoonbeamDev | From 4cdebf77b2757d50768f188e886a55feaf4316fd Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Thu, 8 Aug 2024 12:44:00 +0100 Subject: [PATCH 1337/1963] `eth_getBlockReceipts` should accept block hashes (#8623) * eth_getBlockReceipts using BlockID * fix block receipt * Update crates/anvil/src/eth/backend/mem/mod.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/anvil/src/eth/api.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * code review --------- Co-authored-by: joaocosta9 Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/anvil/core/src/eth/mod.rs | 2 +- crates/anvil/src/eth/api.rs | 5 +---- crates/anvil/src/eth/backend/mem/mod.rs | 7 +++++-- crates/anvil/tests/it/fork.rs | 12 +++++++++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 185e723f384cc..7c86baad32ae4 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -221,7 +221,7 @@ pub enum EthRequest { EthGetTransactionReceipt(B256), #[cfg_attr(feature = "serde", serde(rename = "eth_getBlockReceipts", with = "sequence"))] - EthGetBlockReceipts(BlockNumber), + EthGetBlockReceipts(BlockId), #[cfg_attr(feature = "serde", serde(rename = "eth_getUncleByBlockHashAndIndex"))] EthGetUncleByBlockHashAndIndex(B256, Index), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 4f853cd0c7615..822bc57f13f8e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1217,10 +1217,7 @@ impl EthApi { /// Returns block receipts by block number. /// /// Handler for ETH RPC call: `eth_getBlockReceipts` - pub async fn block_receipts( - &self, - number: BlockNumber, - ) -> Result>> { + pub async fn block_receipts(&self, number: BlockId) -> Result>> { node_info!("eth_getBlockReceipts"); self.backend.block_receipts(number).await } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index c3285e25f97c3..da0a22883217c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2236,14 +2236,17 @@ impl Backend { /// Returns the blocks receipts for the given number pub async fn block_receipts( &self, - number: BlockNumber, + number: BlockId, ) -> Result>, BlockchainError> { if let Some(receipts) = self.mined_block_receipts(number) { return Ok(Some(receipts)); } if let Some(fork) = self.get_fork() { - let number = self.convert_block_number(Some(number)); + let number = match self.ensure_block_number(Some(number)).await { + Err(_) => return Ok(None), + Ok(n) => n, + }; if fork.predates_fork_inclusive(number) { let receipts = fork.block_receipts(number).await?; diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 8a4542b488d84..884bc06054669 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -5,7 +5,7 @@ use crate::{ utils::{http_provider, http_provider_with_signer}, }; use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder}; -use alloy_primitives::{address, bytes, Address, Bytes, TxHash, TxKind, U256}; +use alloy_primitives::{address, b256, bytes, Address, Bytes, TxHash, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ anvil::Forking, @@ -1015,12 +1015,18 @@ async fn test_block_receipts() { let (api, _) = spawn(fork_config()).await; // Receipts from the forked block (14608400) - let receipts = api.block_receipts(BlockNumberOrTag::Number(BLOCK_NUMBER)).await.unwrap(); + let receipts = api.block_receipts(BlockNumberOrTag::Number(BLOCK_NUMBER).into()).await.unwrap(); assert!(receipts.is_some()); // Receipts from a block in the future (14608401) - let receipts = api.block_receipts(BlockNumberOrTag::Number(BLOCK_NUMBER + 1)).await.unwrap(); + let receipts = + api.block_receipts(BlockNumberOrTag::Number(BLOCK_NUMBER + 1).into()).await.unwrap(); assert!(receipts.is_none()); + + // Receipts from a block hash (14608400) + let hash = b256!("4c1c76f89cfe4eb503b09a0993346dd82865cac9d76034efc37d878c66453f0a"); + let receipts = api.block_receipts(BlockId::Hash(hash.into())).await.unwrap(); + assert!(receipts.is_some()); } #[tokio::test(flavor = "multi_thread")] From 5ee33c85bb76a08e94622f6922802376d30032bc Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:43:36 +0300 Subject: [PATCH 1338/1963] fix(fmt): fix disable line for first / last block lines (#8602) * fix(fmt): fix disable line for first / last block lines * Fix win spacing * Reuse visit_block in visit_fn * Fix win failure --- crates/fmt/src/formatter.rs | 171 ++++++++++++------ crates/fmt/testdata/InlineDisable/fmt.sol | 3 +- crates/fmt/testdata/Repros/fmt.sol | 68 +++++++ crates/fmt/testdata/Repros/original.sol | 66 +++++++ .../common/InvariantPreserveState.t.sol | 5 +- 5 files changed, 256 insertions(+), 57 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 5a3b7f1243c99..e7625dc112dfb 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -246,6 +246,17 @@ impl<'a, W: Write> Formatter<'a, W> { Ok(()) } + /// Write unformatted src and comments for given location. + fn write_raw_src(&mut self, loc: Loc) -> Result<()> { + let disabled_stmts_src = String::from_utf8(self.source.as_bytes()[loc.range()].to_vec()) + .map_err(FormatterError::custom)?; + self.write_raw(disabled_stmts_src.trim_end())?; + self.write_whitespace_separator(true)?; + // Remove comments as they're already included in disabled src. + let _ = self.comments.remove_all_comments_before(loc.end()); + Ok(()) + } + /// Returns number of blank lines in source between two byte indexes fn blank_lines(&self, start: usize, end: usize) -> usize { // because of sorting import statements, start can be greater than end @@ -1192,22 +1203,114 @@ impl<'a, W: Write> Formatter<'a, W> { } } - write_chunk!(self, "{{")?; + // Determine if any of start / end of the block is disabled and block lines boundaries. + let is_start_disabled = self.inline_config.is_disabled(loc.with_end(loc.start())); + let is_end_disabled = self.inline_config.is_disabled(loc.with_start(loc.end())); + let end_of_first_line = self.find_next_line(loc.start()).unwrap_or_default(); + let end_of_last_line = self.find_next_line(loc.end()).unwrap_or_default(); - if let Some(statement) = statements.first() { - self.write_whitespace_separator(true)?; - self.write_postfix_comments_before(CodeLocation::loc(statement).start())?; + // Write first line of the block: + // - as it is until the end of line, if format disabled + // - start block if line formatted + if is_start_disabled { + self.write_raw_src(loc.with_end(end_of_first_line))?; + } else { + write_chunk!(self, "{{")?; } - self.indented(1, |fmt| { - fmt.write_lined_visitable(loc, statements.iter_mut(), |_, _| false)?; - Ok(()) - })?; + // Write comments and close block if no statement. + if statements.is_empty() { + self.indented(1, |fmt| { + fmt.write_prefix_comments_before(loc.end())?; + fmt.write_postfix_comments_before(loc.end())?; + Ok(()) + })?; + + write_chunk!(self, "}}")?; + return Ok(true) + } + + // Determine writable statements by excluding statements from disabled start / end lines. + // We check the position of last statement from first line (if disabled) and position of + // first statement from last line (if disabled) and slice accordingly. + let writable_statments = match ( + statements.iter().rposition(|stmt| { + is_start_disabled && + self.find_next_line(stmt.loc().end()).unwrap_or_default() == + end_of_first_line + }), + statements.iter().position(|stmt| { + is_end_disabled && + self.find_next_line(stmt.loc().end()).unwrap_or_default() == end_of_last_line + }), + ) { + // We have statements on both disabled start / end lines. + (Some(start), Some(end)) => { + if start == end || start + 1 == end { + None + } else { + Some(&mut statements[start + 1..end]) + } + } + // We have statements only on disabled start line. + (Some(start), None) => { + if start + 1 == statements.len() { + None + } else { + Some(&mut statements[start + 1..]) + } + } + // We have statements only on disabled end line. + (None, Some(end)) => { + if end == 0 { + None + } else { + Some(&mut statements[..end]) + } + } + // No statements on disabled start / end line. + (None, None) => Some(statements), + }; - if !statements.is_empty() { + // Write statements that are not on any disabled first / last block line. + let mut statements_loc = loc; + if let Some(writable_statements) = writable_statments { + if let Some(first_statement) = writable_statements.first() { + statements_loc = statements_loc.with_start(first_statement.loc().start()); + self.write_whitespace_separator(true)?; + self.write_postfix_comments_before(statements_loc.start())?; + } + // If last line is disabled then statements location ends where last block line starts. + if is_end_disabled { + if let Some(last_statement) = writable_statements.last() { + statements_loc = statements_loc.with_end( + self.find_next_line(last_statement.loc().end()).unwrap_or_default(), + ); + } + } + self.indented(1, |fmt| { + fmt.write_lined_visitable( + statements_loc, + writable_statements.iter_mut(), + |_, _| false, + )?; + Ok(()) + })?; self.write_whitespace_separator(true)?; } - write_chunk!(self, loc.end(), "}}")?; + + // Write last line of the block: + // - as it is from where statements location ends until the end of last line, if format + // disabled + // - close block if line formatted + if is_end_disabled { + self.write_raw_src(loc.with_start(statements_loc.end()).with_end(end_of_last_line))?; + } else { + if end_of_first_line != end_of_last_line { + self.write_whitespace_separator(true)?; + } + write_chunk!(self, loc.end(), "}}")?; + } Ok(false) } @@ -3045,51 +3148,15 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { if fmt.inline_config.is_disabled(body_loc.with_end(body_loc.start())) { match body { Statement::Block { statements, .. } if !statements.is_empty() => { - // TODO: move this logic in `visit_body` fn and reuse it. - // Retain enabled statements. - statements.retain(|stmt| { - !fmt.inline_config.is_disabled( - body_loc.with_end(CodeLocation::loc(stmt).start()), - ) - }); - - // Disabled statement stops where first enabled statement starts or - // where body ends (if no statement enabled). - let disabled_stmts_end = match statements.first() { - Some(stmt) => CodeLocation::loc(stmt).start(), - None => body_loc.end(), - }; - - // Write non formatted statements. This includes the curly bracket - // block start, comments and any other disabled statement. - let disabled_stmts_src = String::from_utf8( - fmt.source.as_bytes() - [body_loc.with_end(disabled_stmts_end).range()] - .to_vec(), - ) - .map_err(FormatterError::custom)?; fmt.write_whitespace_separator(false)?; - fmt.write_raw(disabled_stmts_src.trim_end())?; - // Remove all comments as they're already included in disabled src. - let _ = fmt.comments.remove_all_comments_before(disabled_stmts_end); - - // Write enabled statements. - fmt.indented(1, |fmt| { - fmt.write_lined_visitable( - body_loc.with_start(disabled_stmts_end), - statements.iter_mut(), - |_, _| false, - )?; - Ok(()) - })?; - - // Write curly bracket block end. - fmt.write_whitespace_separator(true)?; - write_chunk!(fmt, body_loc.end(), "}}")?; - + fmt.visit_block(body_loc, statements, false, false)?; return Ok(()) } - _ => {} + _ => { + // Attrs should be written on same line if first line is disabled + // and there's no statement. + attrs_multiline = false + } } } diff --git a/crates/fmt/testdata/InlineDisable/fmt.sol b/crates/fmt/testdata/InlineDisable/fmt.sol index 9211929e7d026..d7adea60b32da 100644 --- a/crates/fmt/testdata/InlineDisable/fmt.sol +++ b/crates/fmt/testdata/InlineDisable/fmt.sol @@ -90,8 +90,7 @@ function testFunc(uint256 num, bytes32 data , address receiver) function testAttrs(uint256 num, bytes32 data, address receiver) // forgefmt: disable-next-line - public payable attr1 Cool( "hello" ) -{} + public payable attr1 Cool( "hello" ) {} // forgefmt: disable-next-line function testParams(uint256 num, bytes32 data , address receiver) diff --git a/crates/fmt/testdata/Repros/fmt.sol b/crates/fmt/testdata/Repros/fmt.sol index b2e232c1936c8..d4daa364c265a 100644 --- a/crates/fmt/testdata/Repros/fmt.sol +++ b/crates/fmt/testdata/Repros/fmt.sol @@ -38,3 +38,71 @@ contract Format { ) {} } } + +// https://github.com/foundry-rs/foundry/issues/3830 +contract TestContract { + function test(uint256 a) public { + if (a > 1) { + a = 2; + } // forgefmt: disable-line + } + + function test1() public { + assembly{ sstore( 1, 1) /* inline comment*/ // forgefmt: disable-line + sstore(2, 2) + } + } + + function test2() public { + assembly{ sstore( 1, 1) // forgefmt: disable-line + sstore(2, 2) + sstore(3, 3)// forgefmt: disable-line + sstore(4, 4) + } + } + + function test3() public { + // forgefmt: disable-next-line + assembly{ sstore( 1, 1) + sstore(2, 2) + sstore(3, 3)// forgefmt: disable-line + sstore(4, 4) + }// forgefmt: disable-line + } + + function test4() public { + // forgefmt: disable-next-line + assembly{ + sstore(1, 1) + sstore(2, 2) + sstore(3, 3)// forgefmt: disable-line + sstore(4, 4) + }// forgefmt: disable-line + if (condition) execute(); // comment7 + } + + function test5() public { + assembly { sstore(0, 0) }// forgefmt: disable-line + } + + function test6() returns (bool) { // forgefmt: disable-line + if ( true ) { // forgefmt: disable-line + } + return true ; } // forgefmt: disable-line + + function test7() returns (bool) { // forgefmt: disable-line + if (true) { // forgefmt: disable-line + uint256 a = 1; // forgefmt: disable-line + } + return true; + } + + function test8() returns (bool) { // forgefmt: disable-line + if ( true ) { // forgefmt: disable-line + uint256 a = 1; + } else { + uint256 b = 1; // forgefmt: disable-line + } + return true; + } +} diff --git a/crates/fmt/testdata/Repros/original.sol b/crates/fmt/testdata/Repros/original.sol index 23e96ac63a641..33c4d216f456b 100644 --- a/crates/fmt/testdata/Repros/original.sol +++ b/crates/fmt/testdata/Repros/original.sol @@ -38,3 +38,69 @@ contract Format { ) {} } } + +// https://github.com/foundry-rs/foundry/issues/3830 +contract TestContract { + function test(uint256 a) public { + if (a > 1) { + a = 2; + } // forgefmt: disable-line + } + + function test1() public { + assembly { sstore( 1, 1) /* inline comment*/ // forgefmt: disable-line + sstore(2, 2) + } + } + + function test2() public { + assembly { sstore( 1, 1) // forgefmt: disable-line + sstore(2, 2) + sstore(3, 3) // forgefmt: disable-line + sstore(4, 4) + } + } + + function test3() public { + // forgefmt: disable-next-line + assembly{ sstore( 1, 1) + sstore(2, 2) + sstore(3, 3) // forgefmt: disable-line + sstore(4, 4) + }// forgefmt: disable-line + } + + function test4() public { + // forgefmt: disable-next-line + assembly { + sstore( 1, 1) + sstore(2, 2) + sstore(3, 3) // forgefmt: disable-line + sstore(4, 4) + }// forgefmt: disable-line + if (condition) execute(); // comment7 + } + + function test5() public { + assembly { sstore(0, 0) }// forgefmt: disable-line + } + + function test6() returns (bool) { // forgefmt: disable-line + if ( true ) { // forgefmt: disable-line + } + return true ; } // forgefmt: disable-line + + function test7() returns (bool) { // forgefmt: disable-line + if (true) { // forgefmt: disable-line + uint256 a = 1; // forgefmt: disable-line + } + return true ; } + + function test8() returns (bool) { // forgefmt: disable-line + if ( true ) { // forgefmt: disable-line + uint256 a = 1; + } else { + uint256 b = 1; // forgefmt: disable-line + } + return true ; } +} diff --git a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol index 5469801362a98..b91cda739fc58 100644 --- a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol @@ -15,9 +15,8 @@ contract Handler is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function thisFunctionReverts() external { - if (block.number < 10) {} else { - revert(); - } + if (block.number < 10) {} + else revert(); } function advanceTime(uint256 blocks) external { From b574cdfff47942f154c5b9782dd2231d8cf9da30 Mon Sep 17 00:00:00 2001 From: cui <523516579@qq.com> Date: Thu, 8 Aug 2024 20:45:25 +0800 Subject: [PATCH 1339/1963] fix(cast run): print custom error when revert (#8620) fix(cast run): print custom revert Co-authored-by: Matthias Seitz --- crates/cheatcodes/src/test/expect.rs | 2 +- crates/evm/core/src/decode.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 4c5bfe928b4a8..b68ae700a57b4 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -585,7 +585,7 @@ pub(crate) fn handle_expect_revert( Ok(success_return()) } else { let stringify = |data: &[u8]| { - if let Ok(s) = String::abi_decode(data, false) { + if let Ok(s) = String::abi_decode(data, true) { return s; } if data.is_ascii() { diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 0c52ea3c7eeda..29f448bcebd58 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -167,7 +167,7 @@ impl RevertDecoder { } // ABI-encoded `string`. - if let Ok(s) = String::abi_decode(err, false) { + if let Ok(s) = String::abi_decode(err, true) { return Some(s); } From 1f33c6f834a9edec8d12c69830686a3dc8d5e6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:50:22 +0200 Subject: [PATCH 1340/1963] feat(cheatcodes): add deterministic random value generation with seed (#8622) * feat(cheatcodes): add ability to set seed for `vm.randomUint()` * chore: move `vm.randomAddress` test to its own contract * feat(cheatcodes): add ability to set seed for `vm.randomAddress()` * feat: use global seed instead of introducing new cheatcodes * chore: clean up * chore: clean up tests * feat: add `fuzz.seed` as inline parameter in tests * chore: trim 0x prefix * chore: nit * test: update random tests * fix: inline parsing on fuzz seed * test: set seed and update random tests * chore: remove inline config for seed * chore: clean up * chore: clean up tests * test: remove deterministic tests from testdata * test: implement forgetest to test that forge test with a seed produces deterministic random values * test: fix tests * chore: clean up * test: remove seed * fix: clippy and forge-fmt * chore: clean up * chore: rename test contract * fix: lint * chore: move rng to state instead of creating a new one when calling `vm.random*` cheats * chore: nit * test: update tests * fix: clippy * chore: nit * chore: clean up * Update crates/cheatcodes/src/inspector.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * test: only check outputs are the same or different * chore: clean up * chore: nits --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/src/config.rs | 6 +- crates/cheatcodes/src/fs.rs | 2 +- crates/cheatcodes/src/inspector.rs | 12 ++++ crates/cheatcodes/src/utils.rs | 14 ++-- crates/forge/tests/cli/test_cmd.rs | 78 ++++++++++++++++++++- testdata/default/cheats/RandomAddress.t.sol | 13 ++++ testdata/default/cheats/RandomUint.t.sol | 4 -- 7 files changed, 114 insertions(+), 15 deletions(-) create mode 100644 testdata/default/cheats/RandomAddress.t.sol diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 9a9e59ccec7b3..715e26dc57bb9 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -1,6 +1,6 @@ use super::Result; use crate::{script::ScriptWallets, Vm::Rpc}; -use alloy_primitives::Address; +use alloy_primitives::{Address, U256}; use foundry_common::{fs::normalize_path, ContractsByArtifact}; use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ @@ -54,6 +54,8 @@ pub struct CheatsConfig { pub running_version: Option, /// Whether to enable legacy (non-reverting) assertions. pub assertions_revert: bool, + /// Optional seed for the RNG algorithm. + pub seed: Option, } impl CheatsConfig { @@ -93,6 +95,7 @@ impl CheatsConfig { available_artifacts, running_version, assertions_revert: config.assertions_revert, + seed: config.fuzz.seed, } } @@ -221,6 +224,7 @@ impl Default for CheatsConfig { available_artifacts: Default::default(), running_version: Default::default(), assertions_revert: true, + seed: None, } } } diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 5467cfcf6b8cd..7f07674d07437 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -618,7 +618,7 @@ mod tests { root: PathBuf::from(&env!("CARGO_MANIFEST_DIR")), ..Default::default() }; - Cheatcodes { config: Arc::new(config), ..Default::default() } + Cheatcodes::new(Arc::new(config)) } #[test] diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 0d377a382d96d..f1af752a4454e 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -29,6 +29,7 @@ use foundry_evm_core::{ InspectorExt, }; use itertools::Itertools; +use rand::{rngs::StdRng, Rng, SeedableRng}; use revm::{ interpreter::{ opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, EOFCreateInputs, @@ -315,6 +316,9 @@ pub struct Cheatcodes { /// Breakpoints supplied by the `breakpoint` cheatcode. /// `char -> (address, pc)` pub breakpoints: Breakpoints, + + /// Optional RNG algorithm. + rng: Option, } // This is not derived because calling this in `fn new` with `..Default::default()` creates a second @@ -356,6 +360,7 @@ impl Cheatcodes { mapping_slots: Default::default(), pc: Default::default(), breakpoints: Default::default(), + rng: Default::default(), } } @@ -926,6 +931,13 @@ impl Cheatcodes { None } + + pub fn rng(&mut self) -> &mut impl Rng { + self.rng.get_or_insert_with(|| match self.config.seed { + Some(seed) => StdRng::from_seed(seed.to_be_bytes::<32>()), + None => StdRng::from_entropy(), + }) + } } impl Inspector for Cheatcodes { diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 6edd700ec7952..5fa55ba8fdd0e 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -55,22 +55,21 @@ impl Cheatcode for ensNamehashCall { } impl Cheatcode for randomUint_0Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { + fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - // Use thread_rng to get a random number - let mut rng = rand::thread_rng(); + let rng = state.rng(); let random_number: U256 = rng.gen(); Ok(random_number.abi_encode()) } } impl Cheatcode for randomUint_1Call { - fn apply(&self, _state: &mut Cheatcodes) -> Result { + fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { min, max } = *self; ensure!(min <= max, "min must be less than or equal to max"); // Generate random between range min..=max - let mut rng = rand::thread_rng(); let exclusive_modulo = max - min; + let rng = state.rng(); let mut random_number = rng.gen::(); if exclusive_modulo != U256::MAX { let inclusive_modulo = exclusive_modulo + U256::from(1); @@ -82,9 +81,10 @@ impl Cheatcode for randomUint_1Call { } impl Cheatcode for randomAddressCall { - fn apply(&self, _state: &mut Cheatcodes) -> Result { + fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - let addr = Address::random(); + let rng = state.rng(); + let addr = Address::random_with(rng); Ok(addr.abi_encode()) } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 1f2e22a15854a..97e4c97cfbe62 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -6,6 +6,7 @@ use foundry_test_utils::{ rpc, str, util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, }; +use similar_asserts::assert_eq; use std::{path::PathBuf, str::FromStr}; // tests that test filters are handled correctly @@ -597,7 +598,7 @@ contract GasWaster { contract GasLimitTest is Test { function test() public { vm.createSelectFork(""); - + GasWaster waster = new GasWaster(); waster.waste(); } @@ -613,7 +614,7 @@ contract GasLimitTest is Test { forgetest!(test_match_path, |prj, cmd| { prj.add_source( "dummy", - r" + r" contract Dummy { function testDummy() public {} } @@ -1048,3 +1049,76 @@ Traces: "# ]]); }); + +// tests that `forge test` with a seed produces deterministic random values for uint and addresses. +forgetest_init!(deterministic_randomness_with_seed, |prj, cmd| { + prj.wipe_contracts(); + prj.add_test( + "DeterministicRandomnessTest.t.sol", + r#" +import {Test, console} from "forge-std/Test.sol"; + +contract DeterministicRandomnessTest is Test { + + function testDeterministicRandomUint() public { + console.log(vm.randomUint()); + console.log(vm.randomUint()); + console.log(vm.randomUint()); + } + + function testDeterministicRandomUintRange() public { + uint256 min = 0; + uint256 max = 1000000000; + console.log(vm.randomUint(min, max)); + console.log(vm.randomUint(min, max)); + console.log(vm.randomUint(min, max)); + } + + function testDeterministicRandomAddress() public { + console.log(vm.randomAddress()); + console.log(vm.randomAddress()); + console.log(vm.randomAddress()); + } +} +"#, + ) + .unwrap(); + + // Extracts the test result section from the DeterministicRandomnessTest contract output. + fn extract_test_result(out: &str) -> &str { + let start = out + .find("for test/DeterministicRandomnessTest.t.sol:DeterministicRandomnessTest") + .unwrap(); + let end = out.find("Suite result: ok.").unwrap(); + &out[start..end] + } + + // Run the test twice with the same seed and verify the outputs are the same. + let seed1 = "0xa1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2"; + cmd.args(["test", "--fuzz-seed", seed1, "-vv"]).assert_success(); + let out1 = cmd.stdout_lossy(); + let res1 = extract_test_result(&out1); + + cmd.forge_fuse(); + cmd.args(["test", "--fuzz-seed", seed1, "-vv"]).assert_success(); + let out2 = cmd.stdout_lossy(); + let res2 = extract_test_result(&out2); + + assert_eq!(res1, res2); + + // Run the test with another seed and verify the output differs. + let seed2 = "0xb1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2"; + cmd.forge_fuse(); + cmd.args(["test", "--fuzz-seed", seed2, "-vv"]).assert_success(); + let out3 = cmd.stdout_lossy(); + let res3 = extract_test_result(&out3); + assert_ne!(res3, res1); + + // Run the test without a seed and verify the outputs differs once again. + cmd.forge_fuse(); + cmd.args(["test", "-vv"]).assert_success(); + let out4 = cmd.stdout_lossy(); + let res4 = extract_test_result(&out4); + assert_ne!(res4, res1); + assert_ne!(res4, res3); +}); diff --git a/testdata/default/cheats/RandomAddress.t.sol b/testdata/default/cheats/RandomAddress.t.sol new file mode 100644 index 0000000000000..74c5e20405704 --- /dev/null +++ b/testdata/default/cheats/RandomAddress.t.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract RandomAddress is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testRandomAddress() public { + vm.randomAddress(); + } +} diff --git a/testdata/default/cheats/RandomUint.t.sol b/testdata/default/cheats/RandomUint.t.sol index e679f9bfd9688..68a65dc0f86a1 100644 --- a/testdata/default/cheats/RandomUint.t.sol +++ b/testdata/default/cheats/RandomUint.t.sol @@ -26,8 +26,4 @@ contract RandomUint is DSTest { assertTrue(rand >= min, "rand >= min"); assertTrue(rand <= max, "rand <= max"); } - - function testRandomAddress() public { - vm.randomAddress(); - } } From 14e50ed89293806c02b1cb5bce3c91c5e9e40b1b Mon Sep 17 00:00:00 2001 From: francesco-gaglione <94604837+francesco-gaglione@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:53:53 +0200 Subject: [PATCH 1341/1963] extended JsonResult structure (#8565) * extended JsonResult structure * removed breakpoints in JsonResult * chore: nits --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/script/src/execute.rs | 16 +++++++--------- crates/script/src/lib.rs | 14 +++++++++----- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 1eff7e0de63a9..caa3fb2c20645 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -1,10 +1,9 @@ +use super::{runner::ScriptRunner, JsonResult, NestedValue, ScriptResult}; use crate::{ build::{CompiledState, LinkedBuildData}, simulate::PreSimulationState, ScriptArgs, ScriptConfig, }; - -use super::{runner::ScriptRunner, JsonResult, NestedValue, ScriptResult}; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; use alloy_primitives::{Address, Bytes}; @@ -382,14 +381,13 @@ impl PreSimulationState { pub fn show_json(&self) -> Result<()> { let result = &self.execution_result; - let console_logs = decode_console_logs(&result.logs); - let output = JsonResult { - logs: console_logs, - gas_used: result.gas_used, - returns: self.execution_artifacts.returns.clone(), + let json_result = JsonResult { + logs: decode_console_logs(&result.logs), + returns: &self.execution_artifacts.returns, + result, }; - let j = serde_json::to_string(&output)?; - shell::println(j)?; + let json = serde_json::to_string(&json_result)?; + shell::println(json)?; if !self.execution_result.success { return Err(eyre::eyre!( diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 6ca1d46102e13..e2f86ce3bcbac 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -457,16 +457,19 @@ impl Provider for ScriptArgs { } } -#[derive(Default)] +#[derive(Default, Serialize)] pub struct ScriptResult { pub success: bool, + #[serde(rename = "raw_logs")] pub logs: Vec, pub traces: Traces, pub gas_used: u64, pub labeled_addresses: HashMap, + #[serde(skip)] pub transactions: Option, pub returned: Bytes, pub address: Option
, + #[serde(skip)] pub breakpoints: Breakpoints, } @@ -490,11 +493,12 @@ impl ScriptResult { } } -#[derive(Serialize, Deserialize)] -struct JsonResult { +#[derive(Serialize)] +struct JsonResult<'a> { logs: Vec, - gas_used: u64, - returns: HashMap, + returns: &'a HashMap, + #[serde(flatten)] + result: &'a ScriptResult, } #[derive(Clone, Serialize, Deserialize)] From 56cd9a94434a5de63ef0fd655b0d6d856f1e45c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ca=C3=ADque=20Porfirio?= <56317416+caiquejjx@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:09:52 -0300 Subject: [PATCH 1342/1963] feat: add `auth` field to `RPCEndpointConfig` (#8570) * add auth parsing in RPC config * add comment explaining auth param * add missing field in test * fix formatting * fix formatting * fix failing test * fix failing test * undo wrong formatting * remove reminiscent ; * auth option as enum to be able to resolve env vars * add test for auth resolving and new field to resolved endpoint --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: Matthias Seitz --- crates/config/src/endpoints.rs | 96 +++++++++++++++++++++++++++++++--- crates/config/src/lib.rs | 72 +++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 6 deletions(-) diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index eabc5acb196ec..78cda4f7343b4 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -41,7 +41,20 @@ impl RpcEndpoints { /// Returns all (alias -> url) pairs pub fn resolved(self) -> ResolvedRpcEndpoints { ResolvedRpcEndpoints { - endpoints: self.endpoints.into_iter().map(|(name, e)| (name, e.resolve())).collect(), + endpoints: self + .endpoints + .clone() + .into_iter() + .map(|(name, e)| (name, e.resolve())) + .collect(), + auths: self + .endpoints + .into_iter() + .map(|(name, e)| match e.auth { + Some(auth) => (name, auth.resolve().map(Some)), + None => (name, Ok(None)), + }) + .collect(), } } } @@ -210,6 +223,58 @@ impl From for RpcEndpointConfig { } } +/// The auth token to be used for RPC endpoints +/// It works in the same way as the `RpcEndpoint` type, where it can be a raw string or a reference +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum RpcAuth { + Raw(String), + Env(String), +} + +impl RpcAuth { + /// Returns the auth token this type holds + /// + /// # Error + /// + /// Returns an error if the type holds a reference to an env var and the env var is not set + pub fn resolve(self) -> Result { + match self { + Self::Raw(raw_auth) => Ok(raw_auth), + Self::Env(var) => interpolate(&var), + } + } +} + +impl fmt::Display for RpcAuth { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Raw(url) => url.fmt(f), + Self::Env(var) => var.fmt(f), + } + } +} + +impl Serialize for RpcAuth { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&self.to_string()) + } +} + +impl<'de> Deserialize<'de> for RpcAuth { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let val = String::deserialize(deserializer)?; + let auth = if RE_PLACEHOLDER.is_match(&val) { Self::Env(val) } else { Self::Raw(val) }; + + Ok(auth) + } +} + /// Rpc endpoint configuration variant #[derive(Debug, Clone, PartialEq, Eq)] pub struct RpcEndpointConfig { @@ -226,6 +291,9 @@ pub struct RpcEndpointConfig { /// /// See also pub compute_units_per_second: Option, + + /// Token to be used as authentication + pub auth: Option, } impl RpcEndpointConfig { @@ -237,7 +305,7 @@ impl RpcEndpointConfig { impl fmt::Display for RpcEndpointConfig { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let Self { endpoint, retries, retry_backoff, compute_units_per_second } = self; + let Self { endpoint, retries, retry_backoff, compute_units_per_second, auth } = self; write!(f, "{endpoint}")?; @@ -253,6 +321,10 @@ impl fmt::Display for RpcEndpointConfig { write!(f, ", compute_units_per_second={compute_units_per_second}")?; } + if let Some(auth) = auth { + write!(f, ", auth={auth}")?; + } + Ok(()) } } @@ -274,6 +346,7 @@ impl Serialize for RpcEndpointConfig { map.serialize_entry("retries", &self.retries)?; map.serialize_entry("retry_backoff", &self.retry_backoff)?; map.serialize_entry("compute_units_per_second", &self.compute_units_per_second)?; + map.serialize_entry("auth", &self.auth)?; map.end() } } @@ -299,12 +372,18 @@ impl<'de> Deserialize<'de> for RpcEndpointConfig { retries: Option, retry_backoff: Option, compute_units_per_second: Option, + auth: Option, } - let RpcEndpointConfigInner { endpoint, retries, retry_backoff, compute_units_per_second } = - serde_json::from_value(value).map_err(serde::de::Error::custom)?; + let RpcEndpointConfigInner { + endpoint, + retries, + retry_backoff, + compute_units_per_second, + auth, + } = serde_json::from_value(value).map_err(serde::de::Error::custom)?; - Ok(Self { endpoint, retries, retry_backoff, compute_units_per_second }) + Ok(Self { endpoint, retries, retry_backoff, compute_units_per_second, auth }) } } @@ -321,6 +400,7 @@ impl Default for RpcEndpointConfig { retries: None, retry_backoff: None, compute_units_per_second: None, + auth: None, } } } @@ -331,6 +411,7 @@ pub struct ResolvedRpcEndpoints { /// contains all named endpoints and their URL or an error if we failed to resolve the env var /// alias endpoints: BTreeMap>, + auths: BTreeMap, UnresolvedEnvVarError>>, } impl ResolvedRpcEndpoints { @@ -364,7 +445,8 @@ mod tests { "endpoint": "http://localhost:8545", "retries": 5, "retry_backoff": 250, - "compute_units_per_second": 100 + "compute_units_per_second": 100, + "auth": "Bearer 123" }"#; let config: RpcEndpointConfig = serde_json::from_str(s).unwrap(); assert_eq!( @@ -374,6 +456,7 @@ mod tests { retries: Some(5), retry_backoff: Some(250), compute_units_per_second: Some(100), + auth: Some(RpcAuth::Raw("Bearer 123".to_string())), } ); @@ -386,6 +469,7 @@ mod tests { retries: None, retry_backoff: None, compute_units_per_second: None, + auth: None, } ); } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d9c7625810274..7033cc31a0dc9 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2799,6 +2799,7 @@ mod tests { endpoints::{RpcEndpointConfig, RpcEndpointType}, etherscan::ResolvedEtherscanConfigs, }; + use endpoints::RpcAuth; use figment::error::Kind::InvalidType; use foundry_compilers::artifacts::{ vyper::VyperOptimizationMode, ModelCheckerEngine, YulDetails, @@ -3449,6 +3450,7 @@ mod tests { retries: Some(3), retry_backoff: Some(1000), compute_units_per_second: Some(1000), + auth: None, }) ), ]), @@ -3471,6 +3473,76 @@ mod tests { }) } + #[test] + fn test_resolve_auth() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [profile.default] + eth_rpc_url = "optimism" + [rpc_endpoints] + optimism = "https://example.com/" + mainnet = { endpoint = "${_CONFIG_MAINNET}", retries = 3, retry_backoff = 1000, compute_units_per_second = 1000, auth = "Bearer ${_CONFIG_AUTH}" } + "#, + )?; + + let config = Config::load(); + + jail.set_env("_CONFIG_AUTH", "123456"); + jail.set_env("_CONFIG_MAINNET", "https://eth-mainnet.alchemyapi.io/v2/123455"); + + assert_eq!( + RpcEndpoints::new([ + ( + "optimism", + RpcEndpointType::String(RpcEndpoint::Url( + "https://example.com/".to_string() + )) + ), + ( + "mainnet", + RpcEndpointType::Config(RpcEndpointConfig { + endpoint: RpcEndpoint::Env("${_CONFIG_MAINNET}".to_string()), + retries: Some(3), + retry_backoff: Some(1000), + compute_units_per_second: Some(1000), + auth: Some(RpcAuth::Env("Bearer ${_CONFIG_AUTH}".to_string())), + }) + ), + ]), + config.rpc_endpoints + ); + let resolved = config.rpc_endpoints.resolved(); + assert_eq!( + RpcEndpoints::new([ + ( + "optimism", + RpcEndpointType::String(RpcEndpoint::Url( + "https://example.com/".to_string() + )) + ), + ( + "mainnet", + RpcEndpointType::Config(RpcEndpointConfig { + endpoint: RpcEndpoint::Url( + "https://eth-mainnet.alchemyapi.io/v2/123455".to_string() + ), + retries: Some(3), + retry_backoff: Some(1000), + compute_units_per_second: Some(1000), + auth: Some(RpcAuth::Raw("Bearer 123456".to_string())), + }) + ), + ]) + .resolved(), + resolved + ); + + Ok(()) + }); + } + #[test] fn test_resolve_endpoints() { figment::Jail::expect_with(|jail| { From 1197fbea0b0f9dde45579a61a5ff956fc0aee426 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 8 Aug 2024 23:01:54 +0200 Subject: [PATCH 1343/1963] chore: bump revm 13 (#8628) --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57bb59ae59ef5..5b38c834b0955 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4035,9 +4035,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734f01574b6804ed6985d042684235c6c1007228eff8b2b488c260e3caf742d5" +checksum = "48e1217b5063138a87feb51bd9ac71857d370f06f1aa3d8c22b73aae0e49f4c3" dependencies = [ "alloy-primitives", "alloy-provider", @@ -7135,9 +7135,9 @@ dependencies = [ [[package]] name = "revm" -version = "12.1.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cfb48bce8ca2113e157bdbddbd5eeb09daac1c903d79ec17085897c38c7c91" +checksum = "6b2f635bbbf4002b1b5c0219f841ec1a317723883ed7662c0d138617539a6087" dependencies = [ "auto_impl", "cfg-if", @@ -7150,9 +7150,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a785dafff303a335980e317669c4e9800cdd5dd2830c6880c3247022761e88" +checksum = "43cbb1576a147317c6990cf69d6cd5ef402df99f638616ba911006e9ec45866b" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7167,9 +7167,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "8.1.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b0daddea06fc6da5346acc39b32a357bbe3579e9e3d94117d9ae125cd596fc" +checksum = "f2ad04c7d87dc3421a5ccca76e56dbd0b29a358c03bb41fe9e80976e9d3f397d" dependencies = [ "revm-primitives", "serde", @@ -7177,9 +7177,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "9.2.0" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef55228211251d7b6c7707c3ee13bb70dea4d2fd81ec4034521e4fe31010b2ea" +checksum = "3526a4ba5ec400e7bbe71affbc10fe2e67c1cd1fb782bab988873d09a102e271" dependencies = [ "aurora-engine-modexp", "blst", @@ -7197,9 +7197,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "7.1.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fc4311037ee093ec50ec734e1424fcb3e12d535c6cef683b75d1c064639630c" +checksum = "4093d98a26601f0a793871c5bc7928410592f76b1f03fc89fde77180c554643c" dependencies = [ "alloy-eips", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index d1646a070bee8..e7ff9087f580c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -164,8 +164,8 @@ solang-parser = "=0.3.3" ## revm # no default features to avoid c-kzg -revm = { version = "12.1.0", default-features = false } -revm-primitives = { version = "7.1.0", default-features = false } +revm = { version = "13.0.0", default-features = false } +revm-primitives = { version = "8.0.0", default-features = false } revm-inspectors = { version = "0.5", features = ["serde"] } ## ethers From f6c6b3585ff103d592257d82171104012d3465d0 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 9 Aug 2024 13:12:56 +0300 Subject: [PATCH 1344/1963] chore: simplify assert/require shrink test (#8634) --- crates/forge/tests/it/invariant.rs | 2 + .../common/InvariantShrinkWithAssert.t.sol | 67 +------------------ 2 files changed, 4 insertions(+), 65 deletions(-) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index e4bf14ecdc735..bd9286713b1de 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -301,6 +301,8 @@ async fn check_shrink_sequence(test_pattern: &str, expected_len: usize) { Filter::new(test_pattern, ".*", ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.fuzz.seed = Some(U256::from(100u32)); + runner.test_options.invariant.runs = 1; + runner.test_options.invariant.depth = 15; match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), diff --git a/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol index 34d11ccb3ab3a..fa4a6e945804e 100644 --- a/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol @@ -2,20 +2,10 @@ pragma solidity ^0.8.13; import "ds-test/test.sol"; -import "cheats/Vm.sol"; - -struct FuzzSelector { - address addr; - bytes4[] selectors; -} contract Counter { uint256 public number; - function setNumber(uint256 newNumber) public { - number = newNumber; - } - function increment() public { number++; } @@ -23,73 +13,20 @@ contract Counter { function decrement() public { number--; } - - function double() public { - number *= 2; - } - - function half() public { - number /= 2; - } - - function triple() public { - number *= 3; - } - - function third() public { - number /= 3; - } - - function quadruple() public { - number *= 4; - } - - function quarter() public { - number /= 4; - } -} - -contract Handler is DSTest { - Counter public counter; - - constructor(Counter _counter) { - counter = _counter; - counter.setNumber(0); - } - - function increment() public { - counter.increment(); - } - - function setNumber(uint256 x) public { - counter.setNumber(x); - } } contract InvariantShrinkWithAssert is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); Counter public counter; - Handler handler; function setUp() public { counter = new Counter(); - handler = new Handler(counter); - } - - function targetSelectors() public returns (FuzzSelector[] memory) { - FuzzSelector[] memory targets = new FuzzSelector[](1); - bytes4[] memory selectors = new bytes4[](2); - selectors[0] = handler.increment.selector; - selectors[1] = handler.setNumber.selector; - targets[0] = FuzzSelector(address(handler), selectors); - return targets; } function invariant_with_assert() public { - assertTrue(counter.number() != 3, "wrong counter"); + assertTrue(counter.number() < 2, "wrong counter"); } function invariant_with_require() public { - require(counter.number() != 3, "wrong counter"); + require(counter.number() < 2, "wrong counter"); } } From a52011523e2d40205a64d705d50f7716b725d941 Mon Sep 17 00:00:00 2001 From: Joseph Zhao <65984904+programskillforverification@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:43:07 +0800 Subject: [PATCH 1345/1963] feat(forge script): set both tx input fields (#8532) * initial fix * fix error * make script tests pass * Update crates/script/src/runner.rs Co-authored-by: Matthias Seitz * Update crates/script/src/runner.rs Co-authored-by: Matthias Seitz * Update crates/script/src/runner.rs Co-authored-by: Matthias Seitz * change style --------- Co-authored-by: Matthias Seitz --- crates/script/src/runner.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 7b7a2375bb752..5841802566f75 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -1,7 +1,7 @@ use super::ScriptResult; use crate::build::ScriptPredeployLibraries; use alloy_primitives::{Address, Bytes, TxKind, U256}; -use alloy_rpc_types::TransactionRequest; +use alloy_rpc_types::{TransactionInput, TransactionRequest}; use eyre::Result; use foundry_cheatcodes::BroadcastableTransaction; use foundry_config::Config; @@ -75,7 +75,7 @@ impl ScriptRunner { rpc: self.evm_opts.fork_url.clone(), transaction: TransactionRequest { from: Some(self.evm_opts.sender), - input: Some(code.clone()).into(), + input: TransactionInput::both(code.clone()), nonce: Some(sender_nonce + library_transactions.len() as u64), ..Default::default() } @@ -109,7 +109,7 @@ impl ScriptRunner { rpc: self.evm_opts.fork_url.clone(), transaction: TransactionRequest { from: Some(self.evm_opts.sender), - input: Some(calldata.into()).into(), + input: TransactionInput::both(calldata.clone().into()), nonce: Some(sender_nonce + library_transactions.len() as u64), to: Some(TxKind::Call(DEFAULT_CREATE2_DEPLOYER)), ..Default::default() From 21fae5ed4e3a21809946ae1d5642d653eb8b63f4 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 9 Aug 2024 13:44:17 +0300 Subject: [PATCH 1346/1963] fix(fmt): preserve format of disabled item (#8633) --- crates/fmt/src/formatter.rs | 21 ++++++++++++++++++++- crates/fmt/testdata/Repros/fmt.sol | 25 +++++++++++++++++++++++++ crates/fmt/testdata/Repros/original.sol | 25 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index e7625dc112dfb..e36a403e5551b 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -405,7 +405,26 @@ impl<'a, W: Write> Formatter<'a, W> { while let Some((loc, item)) = items.next() { let chunk_next_byte_offset = items.peek().map(|(loc, _)| loc.start()).or(next_byte_offset); - out.push(self.visit_to_chunk(loc.start(), chunk_next_byte_offset, item)?); + + let chunk = if self.inline_config.is_disabled(loc) { + // If item format is disabled, we determine last disabled line from item and create + // chunk with raw src. + let mut disabled_loc = loc; + self.chunked(disabled_loc.start(), chunk_next_byte_offset, |fmt| { + while fmt.inline_config.is_disabled(disabled_loc) { + if let Some(next_line) = fmt.find_next_line(disabled_loc.end()) { + disabled_loc = disabled_loc.with_end(next_line); + } else { + break; + } + } + fmt.write_raw_src(disabled_loc)?; + Ok(()) + })? + } else { + self.visit_to_chunk(loc.start(), chunk_next_byte_offset, item)? + }; + out.push(chunk); } Ok(out) } diff --git a/crates/fmt/testdata/Repros/fmt.sol b/crates/fmt/testdata/Repros/fmt.sol index d4daa364c265a..4c305b3e5ccfa 100644 --- a/crates/fmt/testdata/Repros/fmt.sol +++ b/crates/fmt/testdata/Repros/fmt.sol @@ -106,3 +106,28 @@ contract TestContract { return true; } } + +// https://github.com/foundry-rs/foundry/issues/5825 +library MyLib { + bytes32 private constant TYPE_HASH = keccak256( + // forgefmt: disable-start + "MyStruct(" + "uint8 myEnum," + "address myAddress" + ")" + // forgefmt: disable-end + ); + + bytes32 private constant TYPE_HASH_1 = keccak256( + "MyStruct(" "uint8 myEnum," "address myAddress" ")" // forgefmt: disable-line + ); + + // forgefmt: disable-start + bytes32 private constant TYPE_HASH_2 = keccak256( + "MyStruct(" + "uint8 myEnum," + "address myAddress" + ")" + ); + // forgefmt: disable-end +} diff --git a/crates/fmt/testdata/Repros/original.sol b/crates/fmt/testdata/Repros/original.sol index 33c4d216f456b..3c09cd92063b4 100644 --- a/crates/fmt/testdata/Repros/original.sol +++ b/crates/fmt/testdata/Repros/original.sol @@ -104,3 +104,28 @@ contract TestContract { } return true ; } } + +// https://github.com/foundry-rs/foundry/issues/5825 +library MyLib { + bytes32 private constant TYPE_HASH = keccak256( + // forgefmt: disable-start + "MyStruct(" + "uint8 myEnum," + "address myAddress" + ")" + // forgefmt: disable-end + ); + + bytes32 private constant TYPE_HASH_1 = keccak256( + "MyStruct(" "uint8 myEnum," "address myAddress" ")" // forgefmt: disable-line + ); + + // forgefmt: disable-start + bytes32 private constant TYPE_HASH_2 = keccak256( + "MyStruct(" + "uint8 myEnum," + "address myAddress" + ")" + ); + // forgefmt: disable-end +} From 1902f754950c57286155d39e3e0eba1e23f64ff4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 9 Aug 2024 15:57:59 +0200 Subject: [PATCH 1347/1963] fix: bad unwrap for pretty fmt (#8636) --- crates/common/fmt/src/ui.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index bd969fecdca33..f13e0f0218d00 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -339,7 +339,7 @@ transactionIndex {} type {} value {} yParity {}{}", - self.access_list.as_deref().unwrap().pretty(), + self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), self.block_hash.pretty(), self.block_number.pretty(), self.chain_id.pretty(), @@ -378,7 +378,7 @@ transactionIndex {} type {} value {} yParity {}{}", - self.access_list.as_deref().unwrap().pretty(), + self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), self.block_hash.pretty(), self.block_number.pretty(), self.chain_id.pretty(), @@ -420,8 +420,8 @@ transactionIndex {} type {} value {} yParity {}{}", - self.access_list.as_deref().unwrap().pretty(), - self.blob_versioned_hashes.as_deref().unwrap().pretty(), + self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), + self.blob_versioned_hashes.as_deref().unwrap_or(&[]).pretty(), self.block_hash.pretty(), self.block_number.pretty(), self.chain_id.pretty(), @@ -463,7 +463,7 @@ transactionIndex {} type {} value {} yParity {}{}", - self.access_list.as_deref().unwrap().pretty(), + self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), self.authorization_list .as_ref() .map(|l| serde_json::to_string(&l).unwrap()) From 77158ccee1cc0be8b647021b868a14314676a81a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:35:39 +0300 Subject: [PATCH 1348/1963] fix(fmt): write single param on multiline if `params_first` (#8637) fix(fmt): write single param on multiline --- crates/fmt/src/formatter.rs | 4 ++++ crates/fmt/testdata/FunctionDefinition/all.fmt.sol | 4 +++- crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index e36a403e5551b..6cd054d56d4f8 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1626,6 +1626,10 @@ impl<'a, W: Write> Formatter<'a, W> { ¶ms, ",", )?; + // Write new line if we have only one parameter and params on multiline set. + if params.len() == 1 && params_multiline { + writeln!(fmt.buf())?; + } fmt.write_chunks_separated(¶ms, ",", params_multiline)?; Ok(()) }, diff --git a/crates/fmt/testdata/FunctionDefinition/all.fmt.sol b/crates/fmt/testdata/FunctionDefinition/all.fmt.sol index 6d90880679199..86577d44b3b81 100644 --- a/crates/fmt/testdata/FunctionDefinition/all.fmt.sol +++ b/crates/fmt/testdata/FunctionDefinition/all.fmt.sol @@ -717,7 +717,9 @@ contract FunctionOverrides is a = 1; } - function oneParam(uint256 x) + function oneParam( + uint256 x + ) override( FunctionInterfaces, FunctionDefinitions, diff --git a/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol b/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol index 50f539c329cae..8208c15d21fc3 100644 --- a/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol +++ b/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol @@ -697,7 +697,9 @@ contract FunctionOverrides is a = 1; } - function oneParam(uint256 x) + function oneParam( + uint256 x + ) override( FunctionInterfaces, FunctionDefinitions, From 03c20289eff8d90e891f9605fd5729ae677bf303 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 10 Aug 2024 19:19:12 +0800 Subject: [PATCH 1349/1963] fix(anvil): correctly print logs (#8642) --- crates/anvil/src/eth/backend/mem/inspector.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 68336935f4bb7..2095e9d5034a7 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -41,7 +41,7 @@ impl Inspector { self } - pub fn with_config(mut self, config: TracingInspectorConfig) -> Self { + pub fn with_tracing_config(mut self, config: TracingInspectorConfig) -> Self { self.tracer = Some(TracingInspector::new(config)); self } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index da0a22883217c..180554e834002 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -851,7 +851,7 @@ impl Backend { } let db = self.db.read().await; - let mut inspector = Inspector::default(); + let mut inspector = self.build_inspector(); let mut evm = self.new_evm_with_inspector_ref(&**db, env, &mut inspector); let ResultAndState { result, state } = evm.transact()?; let (exit_reason, gas_used, out, logs) = match result { @@ -1200,6 +1200,17 @@ impl Backend { env } + /// Builds [`Inspector`] with the configured options + fn build_inspector(&self) -> Inspector { + let mut inspector = Inspector::default(); + + if self.print_logs { + inspector = inspector.with_log_collector(); + } + + inspector + } + pub fn call_with_state( &self, state: D, @@ -1210,7 +1221,7 @@ impl Backend { where D: DatabaseRef, { - let mut inspector = Inspector::default(); + let mut inspector = self.build_inspector(); let env = self.build_call_env(request, fee_details, block_env); let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); @@ -1251,7 +1262,7 @@ impl Backend { .into_call_config() .map_err(|e| (RpcError::invalid_params(e.to_string())))?; - let mut inspector = Inspector::default().with_config( + let mut inspector = self.build_inspector().with_tracing_config( TracingInspectorConfig::from_geth_call_config(&call_config), ); @@ -1283,8 +1294,9 @@ impl Backend { } // defaults to StructLog tracer used since no tracer is specified - let mut inspector = - Inspector::default().with_config(TracingInspectorConfig::from_geth_config(&config)); + let mut inspector = self + .build_inspector() + .with_tracing_config(TracingInspectorConfig::from_geth_config(&config)); let env = self.build_call_env(request, fee_details, block); let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); From a0a002020be4c40946fe122fe6ff752b21cb2885 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 11 Aug 2024 20:53:14 +0000 Subject: [PATCH 1350/1963] chore(deps): weekly `cargo update` (#8647) --- Cargo.lock | 114 +++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b38c834b0955..b97f66881a2d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01828af9e8fb20a85b1caf6570d84ee93595d6cbd9e8ea96bda3a4e27a55a4fa" +checksum = "5b515e82c8468ddb6ff8db21c78a5997442f113fd8471fd5b2261b2602dd0c67" dependencies = [ "num_enum", "serde", @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" +checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -318,9 +318,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" +checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", @@ -1211,9 +1211,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf6cfe2881cb1fcbba9ae946fb9a6480d3b7a714ca84c74925014a89ef3387a" +checksum = "4e95816a168520d72c0e7680c405a5a8c1fb6a035b4bc4b9d7b0de8e1a941697" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1231,7 +1231,6 @@ dependencies = [ "fastrand", "hex", "http 0.2.12", - "hyper 0.14.30", "ring", "time", "tokio", @@ -1254,9 +1253,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5f920ffd1e0526ec9e70e50bf444db50b204395a0fa7016bbf9e31ea1698f" +checksum = "f42c2d4218de4dcd890a109461e2f799a1a2ba3bcd2cde9af88360f5df9266c6" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1269,6 +1268,7 @@ dependencies = [ "fastrand", "http 0.2.12", "http-body 0.4.6", + "once_cell", "percent-encoding", "pin-project-lite", "tracing", @@ -1277,9 +1277,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91f43512620f4b0d9e67ccf7d768fab5ed310ac2229ebb9422177abe99c36ba" +checksum = "9d073fcc95d01301c115011f8f23bc436d66f01b8265d149e994a2d8318c903c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1299,9 +1299,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6acca681c53374bf1d9af0e317a41d12a44902ca0f2d1e10e5cb5bb98ed74f35" +checksum = "1074e818fbe4f9169242d78448b15be8916a79daa38ea1231f2e2e10d993fcd2" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1321,9 +1321,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79c6bdfe612503a526059c05c9ccccbf6bd9530b003673cb863e547fd7c0c9a" +checksum = "29755c51e33fa3f678598f64324a169cf4b7d3c4865d2709d4308f53366a92a4" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1343,9 +1343,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e6ecdb2bd756f3b2383e6f0588dc10a4e65f5d551e70a56e0bfe0c884673ce" +checksum = "6e52dc3fd7dfa6c01a69cf3903e00aa467261639138a05b06cd92314d2c8fb07" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1466,9 +1466,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30819352ed0a04ecf6a2f3477e344d2d1ba33d43e0f09ad9047c12e0d923616f" +checksum = "e086682a53d3aa241192aa110fa8dfce98f2f5ac2ead0de84d41582c7e8fdb96" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1987,9 +1987,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" dependencies = [ "jobserver", "libc", @@ -2098,9 +2098,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" dependencies = [ "clap_builder", "clap_derive", @@ -2108,9 +2108,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -2123,9 +2123,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.12" +version = "4.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8670053e87c316345e384ca1f3eba3006fc6355ed8b8a1140d104e109e3df34" +checksum = "1d11bff0290e9a266fc9b4ce6fa96c2bf2ca3f9724c41c10202ac1daf7a087f8" dependencies = [ "clap", ] @@ -3255,14 +3255,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", + "libredox", + "windows-sys 0.59.0", ] [[package]] @@ -4942,9 +4942,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-channel", @@ -5416,6 +5416,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", + "redox_syscall", ] [[package]] @@ -6002,14 +6003,14 @@ dependencies = [ [[package]] name = "opener" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8df34be653210fbe9ffaff41d3b92721c56ce82dfee58ee684f9afb5e3a90c0" +checksum = "d0812e5e4df08da354c851a3376fead46db31c2214f849d3de356d774d057681" dependencies = [ "bstr", "dbus", "normpath", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6151,7 +6152,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall", "smallvec", "windows-targets 0.52.6", ] @@ -6959,15 +6960,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.5.3" @@ -7471,9 +7463,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" @@ -7587,9 +7579,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.8" +version = "2.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d777f59627453628a9a5be1ee8d948745b94b1dfc2d0c3099cbd9e08ab89e7c" +checksum = "c76e6f627d67cd14a317d7909585f4d06609acafd7891432ea45ce519211a8e9" dependencies = [ "sdd", ] @@ -7663,9 +7655,9 @@ dependencies = [ [[package]] name = "sdd" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177258b64c0faaa9ffd3c65cd3262c2bc7e2588dbbd9c1641d0346145c1bbda8" +checksum = "f081bcf2e6c4d1d88d2b8d1c9d8a308993eafbdabb851050be4b2ff14d2c5649" [[package]] name = "sec1" @@ -7771,18 +7763,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" dependencies = [ "proc-macro2", "quote", @@ -8390,15 +8382,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] From 515a4cc8aba1627a717a1057ff4f09c8cd3bf51f Mon Sep 17 00:00:00 2001 From: Kris Kaczor Date: Mon, 12 Aug 2024 12:14:27 +0400 Subject: [PATCH 1351/1963] Add --disable-code-size-limit flag for anvil (#8646) Add --disable-code-size-limit flag --- crates/anvil/src/cmd.rs | 29 +++++++++++++++++++++++++++-- crates/anvil/src/config.rs | 8 ++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 2897cebdda93a..a2802e0591773 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -246,6 +246,7 @@ impl NodeArgs { .with_auto_impersonate(self.evm_opts.auto_impersonate) .with_ipc(self.ipc) .with_code_size_limit(self.evm_opts.code_size_limit) + .disable_code_size_limit(self.evm_opts.disable_code_size_limit) .set_pruned_history(self.prune_history) .with_init_state(self.load_state.or_else(|| self.state.and_then(|s| s.state))) .with_transaction_block_keeper(self.transaction_block_keeper) @@ -495,11 +496,20 @@ pub struct AnvilEvmArgs { )] pub disable_block_gas_limit: bool, - /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. By - /// default, it is 0x6000 (~25kb). + /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. To + /// disable entirely, use `--disable-code-size-limit`. By default, it is 0x6000 (~25kb). #[arg(long, value_name = "CODE_SIZE", help_heading = "Environment config")] pub code_size_limit: Option, + /// Disable EIP-170: Contract code size limit. + #[arg( + long, + value_name = "DISABLE_CODE_SIZE_LIMIT", + conflicts_with = "code_size_limit", + help_heading = "Environment config" + )] + pub disable_code_size_limit: bool, + /// The gas price. #[arg(long, help_heading = "Environment config")] pub gas_price: Option, @@ -805,6 +815,21 @@ mod tests { assert!(args.is_err()); } + #[test] + fn can_parse_disable_code_size_limit() { + let args: NodeArgs = NodeArgs::parse_from(["anvil", "--disable-code-size-limit"]); + assert!(args.evm_opts.disable_code_size_limit); + + let args = NodeArgs::try_parse_from([ + "anvil", + "--disable-code-size-limit", + "--code-size-limit", + "100", + ]); + // can't be used together + assert!(args.is_err()); + } + #[test] fn can_parse_host() { let args = NodeArgs::parse_from(["anvil"]); diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 28080f628845e..5e8ef0f9a1b61 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -482,6 +482,14 @@ impl NodeConfig { self.code_size_limit = code_size_limit; self } + /// Disables code size limit + #[must_use] + pub fn disable_code_size_limit(mut self, disable_code_size_limit: bool) -> Self { + if disable_code_size_limit { + self.code_size_limit = Some(usize::MAX); + } + self + } /// Sets the init state if any #[must_use] From e36bc81b1dad51d6601ea2ba214b6c86ea200197 Mon Sep 17 00:00:00 2001 From: cui <523516579@qq.com> Date: Tue, 13 Aug 2024 22:10:45 +0800 Subject: [PATCH 1352/1963] fix: allow result large err (#8656) --- crates/config/src/fix.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/config/src/fix.rs b/crates/config/src/fix.rs index 73d52d979cbc8..f3ec1271feafb 100644 --- a/crates/config/src/fix.rs +++ b/crates/config/src/fix.rs @@ -69,6 +69,7 @@ impl std::error::Error for InsertProfileError {} impl TomlFile { /// Insert a name as `[profile.name]`. Creating the `[profile]` table where necessary and /// throwing an error if there exists a conflict + #[allow(clippy::result_large_err)] fn insert_profile( &mut self, profile_str: &str, From 1c71ab19f28e98e05db393aa6fd827730c9bf4ac Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 13 Aug 2024 08:40:33 -0700 Subject: [PATCH 1353/1963] fix(coverage): relax deployed bytecode accepted score (#8657) --- crates/common/src/contracts.rs | 8 ++-- crates/forge/tests/cli/coverage.rs | 69 ++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 7e07f9db64712..38f73a7133f5c 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -115,24 +115,26 @@ impl ContractsByArtifact { /// Finds a contract which has a similar bytecode as `code`. pub fn find_by_creation_code(&self, code: &[u8]) -> Option> { - self.find_by_code(code, ContractData::bytecode) + self.find_by_code(code, 0.1, ContractData::bytecode) } /// Finds a contract which has a similar deployed bytecode as `code`. pub fn find_by_deployed_code(&self, code: &[u8]) -> Option> { - self.find_by_code(code, ContractData::deployed_bytecode) + self.find_by_code(code, 0.15, ContractData::deployed_bytecode) } + /// Finds a contract based on provided bytecode and accepted match score. fn find_by_code( &self, code: &[u8], + accepted_score: f64, get: impl Fn(&ContractData) -> Option<&Bytes>, ) -> Option> { self.iter() .filter_map(|(id, contract)| { if let Some(deployed_bytecode) = get(contract) { let score = bytecode_diff_score(deployed_bytecode.as_ref(), code); - (score <= 0.1).then_some((score, (id, contract))) + (score <= accepted_score).then_some((score, (id, contract))) } else { None } diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 078e06d9512a0..1b668afacd531 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1202,3 +1202,72 @@ contract AContractTest is DSTest { "#]], ); }); + +forgetest!(test_identical_bytecodes, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + uint256 public number; + address public immutable usdc1; + address public immutable usdc2; + address public immutable usdc3; + address public immutable usdc4; + address public immutable usdc5; + address public immutable usdc6; + + constructor() { + address a = 0x176211869cA2b568f2A7D4EE941E073a821EE1ff; + usdc1 = a; + usdc2 = a; + usdc3 = a; + usdc4 = a; + usdc5 = a; + usdc6 = a; + } + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + AContract public counter; + + function setUp() public { + counter = new AContract(); + counter.setNumber(0); + } + + function test_Increment() public { + counter.increment(); + assertEq(counter.number(), 1); + } +} + "#, + ) + .unwrap(); + + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | +| Total | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | + +"#]]); +}); From 224fe9cbf76084c176dabf7d3b2edab5df1ab818 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:26:02 -0700 Subject: [PATCH 1354/1963] fix(fmt): apply multi statement block config to else block (#8661) fix(fmt): apply multi statement block to else clauses --- crates/fmt/src/formatter.rs | 2 +- crates/fmt/testdata/Repros/fmt.sol | 14 ++++++++++++++ crates/fmt/testdata/Repros/original.sol | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 6cd054d56d4f8..396348201042b 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1782,7 +1782,7 @@ impl<'a, W: Write> Formatter<'a, W> { self.visit_if(*loc, cond, if_branch, else_branch, false)?; } else { let else_branch_is_single_line = - self.visit_stmt_as_block(else_branch, if_branch_is_single_line)?; + self.visit_stmt_as_block(else_branch, attempt_single_line)?; if single_line_stmt_wide && !else_branch_is_single_line { bail!(FormatterError::fmt()) } diff --git a/crates/fmt/testdata/Repros/fmt.sol b/crates/fmt/testdata/Repros/fmt.sol index 4c305b3e5ccfa..0842c7956bf6f 100644 --- a/crates/fmt/testdata/Repros/fmt.sol +++ b/crates/fmt/testdata/Repros/fmt.sol @@ -131,3 +131,17 @@ library MyLib { ); // forgefmt: disable-end } + +contract IfElseTest { + function setNumber(uint256 newNumber) public { + number = newNumber; + if (newNumber = 1) { + number = 1; + } else if (newNumber = 2) { + // number = 2; + } + else { + newNumber = 3; + } + } +} diff --git a/crates/fmt/testdata/Repros/original.sol b/crates/fmt/testdata/Repros/original.sol index 3c09cd92063b4..ef75931e233e6 100644 --- a/crates/fmt/testdata/Repros/original.sol +++ b/crates/fmt/testdata/Repros/original.sol @@ -129,3 +129,17 @@ library MyLib { ); // forgefmt: disable-end } + +contract IfElseTest { + function setNumber(uint256 newNumber) public { + number = newNumber; + if (newNumber = 1) { + number = 1; + } else if (newNumber = 2) { + // number = 2; + } + else { + newNumber = 3; + } + } +} From 3e3b30c61c6b24c0d3e336503b67358f612a6f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Thu, 15 Aug 2024 00:40:31 +0200 Subject: [PATCH 1355/1963] fix: `cast --to-ascii` does not work if input has trailing whitespaces (#8670) * fix: `cast --to-ascii` removes trailing whitespaces on stdin * fix: remove extra break line returned by `cast call` * Update crates/cast/bin/main.rs Co-authored-by: Matthias Seitz * Update crates/cast/src/lib.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/cast/bin/main.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: Matthias Seitz Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/bin/main.rs | 2 +- crates/cast/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 044cc25ffd59f..8bc0b986632b3 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -66,7 +66,7 @@ async fn main() -> Result<()> { } CastSubcommand::ToAscii { hexdata } => { let value = stdin::unwrap(hexdata, false)?; - println!("{}", SimpleCast::to_ascii(&value)?); + println!("{}", SimpleCast::to_ascii(value.trim())?); } CastSubcommand::ToUtf8 { hexdata } => { let value = stdin::unwrap(hexdata, false)?; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 93e3c4a0fb638..7c2d970a7abb4 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -168,7 +168,7 @@ where // handle case when return type is not specified Ok(if decoded.is_empty() { - format!("{res}\n") + res.to_string() } else if json { let tokens = decoded.iter().map(format_token_raw).collect::>(); serde_json::to_string_pretty(&tokens).unwrap() @@ -1503,7 +1503,7 @@ impl SimpleCast { /// decoded[1].as_address().unwrap().to_string().to_lowercase(), /// decoded[2].as_uint().unwrap().0.to_string(), /// decoded[3].as_uint().unwrap().0.to_string(), - /// hex::encode(decoded[4].as_bytes().unwrap()) + /// hex::encode(decoded[4].as_bytes().unwrap()) /// ] /// .into_iter() /// .collect::>(); From b34b0f720c8b2b281b3dccdf5cab6e9479ebce2b Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Thu, 15 Aug 2024 16:21:55 +0200 Subject: [PATCH 1356/1963] fix(anvil): get_transaction_count forking (#8675) --- crates/anvil/src/eth/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 822bc57f13f8e..fbd37a3f2a4ee 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2651,7 +2651,7 @@ impl EthApi { if let BlockRequest::Number(number) = block_request { if let Some(fork) = self.get_fork() { - if fork.predates_fork_inclusive(number) { + if fork.predates_fork(number) { return Ok(fork.get_nonce(address, number).await?) } } From 6928687de81b5eb840ad825acb0af01a984d677e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:15:36 -0700 Subject: [PATCH 1357/1963] alloy update (#8660) * Take 1 * cargo * Latest alloy * Fix revm --- Cargo.lock | 751 ++++++++----------- Cargo.toml | 28 +- crates/anvil/core/src/eth/transaction/mod.rs | 22 + crates/anvil/src/eth/backend/fork.rs | 2 +- crates/anvil/src/pubsub.rs | 4 +- crates/anvil/tests/it/eip7702.rs | 7 +- crates/anvil/tests/it/traces.rs | 11 +- crates/cheatcodes/src/evm.rs | 4 +- crates/cheatcodes/src/evm/mock.rs | 2 +- crates/cheatcodes/src/inspector.rs | 22 +- crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/utils.rs | 2 +- crates/evm/evm/src/inspectors/stack.rs | 1 - crates/forge/bin/cmd/create.rs | 8 +- crates/wallets/Cargo.toml | 2 +- 15 files changed, 380 insertions(+), 488 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b97f66881a2d9..6fd1aa9cde8f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,8 +80,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04c309895995eaa4bfcc345f5515a39c7df9447798645cc8bf462b6c5bf1dc96" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-eips", "alloy-primitives", @@ -94,8 +93,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f4e0ef72b0876ae3068b2ed7dfae9ae1779ce13cfaec2ee1f08f5bd0348dc57" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -125,7 +123,7 @@ dependencies = [ "arbitrary", "const-hex", "derive_arbitrary", - "derive_more", + "derive_more 0.99.18", "itoa", "proptest", "serde", @@ -136,15 +134,14 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9431c99a3b3fe606ede4b3d4043bdfbcb780c45b8d8d226c3804e2b75cfbe68" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-serde", "arbitrary", "c-kzg", - "derive_more", + "derive_more 1.0.0", "k256", "once_cell", "rand", @@ -155,8 +152,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79614dfe86144328da11098edcc7bc1a3f25ad8d3134a9eb9e857e06f0d9840d" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "alloy-serde", @@ -178,8 +174,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e2865c4c3bb4cdad3f0d9ec1ab5c0c657ba69a375651bd35e32fb6c180ccc2" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -192,8 +187,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e701fc87ef9a3139154b0b4ccb935b565d27ffd9de020fe541bf2dec5ae4ede" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -213,8 +207,7 @@ dependencies = [ [[package]] name = "alloy-network-primitives" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec9d5a0f9170b10988b6774498a022845e13eda94318440d17709d50687f67f9" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "alloy-serde", @@ -233,7 +226,7 @@ dependencies = [ "cfg-if", "const-hex", "derive_arbitrary", - "derive_more", + "derive_more 0.99.18", "ethereum_ssz", "getrandom", "hex-literal", @@ -251,8 +244,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9c0ab10b93de601a6396fc7ff2ea10d3b28c46f079338fa562107ebf9857c8" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-chains", "alloy-consensus", @@ -278,9 +270,10 @@ dependencies = [ "futures-utils-wasm", "lru", "pin-project 1.1.5", - "reqwest 0.12.5", + "reqwest", "serde", "serde_json", + "thiserror", "tokio", "tracing", "url", @@ -289,8 +282,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5da2c55cbaf229bad3c5f8b00b5ab66c74ef093e5f3a753d874cfecf7d2281" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -324,14 +316,13 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] name = "alloy-rpc-client" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b38e3ffdb285df5d9f60cb988d336d9b8e3505acb78750c3bc60336a7af41d3" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -342,7 +333,7 @@ dependencies = [ "alloy-transport-ws", "futures", "pin-project 1.1.5", - "reqwest 0.12.5", + "reqwest", "serde", "serde_json", "tokio", @@ -355,8 +346,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c31a3750b8f5a350d17354e46a52b0f2f19ec5f2006d816935af599dedc521" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -370,8 +360,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ab6509cd38b2e8c8da726e0f61c1e314a81df06a38d37ddec8bced3f8d25ed" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "alloy-serde", @@ -381,8 +370,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff63f51b2fb2f547df5218527fd0653afb1947bf7fead5b3ce58c75d170b30f7" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -399,8 +387,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81e18424d962d7700a882fe423714bd5b9dde74c7a7589d4255ea64068773aef" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -418,8 +405,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a86eeb49ea0cc79f249faa1d35c20541bb1c317a59b5962cb07b1890355b0064" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -432,8 +418,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2342fed8175642b15a37a51f8729b05b2469281fbeb816f0ccbb0087e2dd74a" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -444,8 +429,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33feda6a53e6079895aed1d08dcb98a1377b000d80d16370fbbdb8155d547ef" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-primitives", "arbitrary", @@ -456,8 +440,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740a25b92e849ed7b0fa013951fe2f64be9af1ad5abe805037b44fb7770c5c47" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -472,8 +455,7 @@ dependencies = [ [[package]] name = "alloy-signer-aws" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1a47bd8487fb2d715f8a203c3bfe7de0b7443eeacb00bd96d8d4eb0d67e184" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-network", @@ -490,8 +472,7 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0850956080821ee646461fde2ff17640a2babcd206046a867eda94d9a266fad9" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-network", @@ -508,8 +489,7 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4f7e76cb4f63dbb56857a74665510517a013fe18da82082f7c66c6d321531e" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -528,8 +508,7 @@ dependencies = [ [[package]] name = "alloy-signer-local" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b0707d4f63e4356a110b30ef3add8732ab6d181dd7be4607bf79b8777105cee" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-network", @@ -548,8 +527,7 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81147fb1a384f878653524b9473af71ef2820846bd64a473f26e49fca8e5f8f9" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-consensus", "alloy-network", @@ -573,7 +551,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -586,11 +564,11 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.3.0", + "indexmap 2.4.0", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", "syn-solidity", "tiny-keccak", ] @@ -608,7 +586,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.72", + "syn 2.0.74", "syn-solidity", ] @@ -638,8 +616,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d0590afbdacf2f8cca49d025a2466f3b6584a016a8b28f532f29f8da1007bae" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -657,12 +634,11 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2437d145d80ea1aecde8574d2058cceb8b3c9cba05f6aea8e67907c660d46698" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.5", + "reqwest", "serde_json", "tower", "tracing", @@ -672,8 +648,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804494366e20468776db4e18f9eb5db7db0fe14f1271eb6dbf155d867233405c" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -693,8 +668,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af855163e7df008799941aa6dd324a43ef2bf264b08ba4b22d44aad6ced65300" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -716,7 +690,7 @@ checksum = "03704f265cbbb943b117ecb5055fd46e8f41e7dc8a58b1aed20bcd40ace38c15" dependencies = [ "alloy-primitives", "alloy-rlp", - "derive_more", + "derive_more 0.99.18", "hashbrown 0.14.5", "nybbles", "serde", @@ -839,7 +813,7 @@ dependencies = [ "anvil-server", "async-trait", "auto_impl", - "axum 0.7.5", + "axum", "bytes", "chrono", "clap", @@ -911,7 +885,7 @@ version = "0.2.0" dependencies = [ "anvil-rpc", "async-trait", - "axum 0.7.5", + "axum", "bytes", "clap", "futures", @@ -1120,7 +1094,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1142,7 +1116,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1153,7 +1127,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1182,6 +1156,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "aurora-engine-modexp" version = "1.1.0" @@ -1200,7 +1180,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1449,7 +1429,7 @@ dependencies = [ "aws-smithy-types", "bytes", "fastrand", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "http-body 1.0.1", @@ -1527,34 +1507,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "axum" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" -dependencies = [ - "async-trait", - "axum-core 0.3.4", - "bitflags 1.3.2", - "bytes", - "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper 0.1.2", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "axum" version = "0.7.5" @@ -1562,7 +1514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", - "axum-core 0.4.3", + "axum-core", "base64 0.21.7", "bytes", "futures-util", @@ -1592,23 +1544,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "axum-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "mime", - "rustversion", - "tower-layer", - "tower-service", -] - [[package]] name = "axum-core" version = "0.4.3" @@ -1987,12 +1922,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.8" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" +checksum = "5fb8dd288a69fc53a1996d7ecfbf4a20d59065bff137ce7e56bbd620de191189" dependencies = [ "jobserver", "libc", + "shlex", ] [[package]] @@ -2007,6 +1943,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chisel" version = "0.2.0" @@ -2028,7 +1970,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest 0.12.5", + "reqwest", "revm", "rustyline", "semver 1.0.23", @@ -2123,9 +2065,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.14" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d11bff0290e9a266fc9b4ce6fa96c2bf2ca3f9724c41c10202ac1daf7a087f8" +checksum = "9c677cd0126f3026d8b093fa29eae5d812fde5c05bc66dbb29d0374eea95113a" dependencies = [ "clap", ] @@ -2149,7 +2091,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2184,9 +2126,9 @@ dependencies = [ [[package]] name = "coins-bip32" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c43ff7fd9ff522219058808a259e61423335767b1071d5b346de60d9219657" +checksum = "2073678591747aed4000dd468b97b14d7007f7936851d3f2f01846899f5ebf08" dependencies = [ "bs58", "coins-core", @@ -2200,9 +2142,9 @@ dependencies = [ [[package]] name = "coins-bip39" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4587c0b4064da887ed39a6522f577267d57e58bdd583178cd877d721b56a2e" +checksum = "74b169b26623ff17e9db37a539fe4f15342080df39f129ef7631df7683d6d9d4" dependencies = [ "bitvec", "coins-bip32", @@ -2216,9 +2158,9 @@ dependencies = [ [[package]] name = "coins-core" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b3aeeec621f4daec552e9d28befd58020a78cfc364827d06a753e8bc13c6c4b" +checksum = "62b962ad8545e43a28e14e87377812ba9ae748dd4fd963f4c10e9fcc6d13475b" dependencies = [ "base64 0.21.7", "bech32", @@ -2235,9 +2177,9 @@ dependencies = [ [[package]] name = "coins-ledger" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "166ef757aa936b45f3e5d39c344047f65ef7d25a50067246a498021a816d074b" +checksum = "ab9bc0994d0aa0f4ade5f3a9baf4a8d936f250278c85a1124b401860454246ab" dependencies = [ "async-trait", "byteorder", @@ -2389,15 +2331,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -2547,12 +2489,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" +checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3" dependencies = [ - "nix 0.28.0", - "windows-sys 0.52.0", + "nix 0.29.0", + "windows-sys 0.59.0", ] [[package]] @@ -2576,7 +2518,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2587,16 +2529,17 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] name = "dashmap" -version = "5.5.3" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" dependencies = [ "cfg-if", + "crossbeam-utils", "hashbrown 0.14.5", "lock_api", "once_cell", @@ -2659,7 +2602,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2680,7 +2623,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2690,7 +2633,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2703,7 +2646,27 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.72", + "syn 2.0.74", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", ] [[package]] @@ -2810,7 +2773,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2923,15 +2886,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "endian-type" version = "0.1.2" @@ -2946,7 +2900,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3096,7 +3050,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.72", + "syn 2.0.74", "toml 0.8.19", "walkdir", ] @@ -3124,7 +3078,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.72", + "syn 2.0.74", "tempfile", "thiserror", "tiny-keccak", @@ -3335,7 +3289,7 @@ dependencies = [ "alloy-transport", "anvil", "async-trait", - "axum 0.7.5", + "axum", "clap", "clap_complete", "clap_complete_fig", @@ -3377,7 +3331,7 @@ dependencies = [ "proptest", "rayon", "regex", - "reqwest 0.12.5", + "reqwest", "revm-inspectors", "rustc-hash", "semver 1.0.23", @@ -3411,7 +3365,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "auto_impl", - "derive_more", + "derive_more 0.99.18", "eyre", "forge-fmt", "foundry-compilers", @@ -3502,7 +3456,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3529,7 +3483,7 @@ dependencies = [ "itertools 0.13.0", "once_cell", "regex", - "reqwest 0.12.5", + "reqwest", "revm-primitives", "semver 1.0.23", "serde", @@ -3559,7 +3513,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "foundry-compilers", - "reqwest 0.12.5", + "reqwest", "semver 1.0.23", "serde", "serde_json", @@ -3690,7 +3644,7 @@ dependencies = [ "foundry-macros", "num-format", "once_cell", - "reqwest 0.12.5", + "reqwest", "rustc-hash", "semver 1.0.23", "serde", @@ -3854,7 +3808,7 @@ dependencies = [ "once_cell", "path-slash", "regex", - "reqwest 0.12.5", + "reqwest", "revm-primitives", "semver 1.0.23", "serde", @@ -3919,7 +3873,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-sol-types", - "derive_more", + "derive_more 0.99.18", "foundry-common-fmt", "foundry-macros", "foundry-test-utils", @@ -3993,7 +3947,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap 2.3.0", + "indexmap 2.4.0", "itertools 0.13.0", "parking_lot", "proptest", @@ -4074,7 +4028,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4234,7 +4188,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4273,37 +4227,22 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" -[[package]] -name = "gcemeta" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d460327b24cc34c86d53d60a90e9e6044817f7906ebd9baa5c3d0ee13e1ecf" -dependencies = [ - "bytes", - "hyper 0.14.30", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", -] - [[package]] name = "gcloud-sdk" -version = "0.24.8" +version = "0.25.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1afe2a62202f8f8eb624638f7e5b8f0988a540dd8dbb69e098daeb277273b2ab" +checksum = "77045256cd0d2075e09d62c4c9f27c2b664e2cc806d7ddf3a4293bb0c20b4728" dependencies = [ "async-trait", + "bytes", "chrono", "futures", - "gcemeta", - "hyper 0.14.30", + "hyper 1.4.1", "jsonwebtoken", "once_cell", - "prost 0.12.6", - "prost-types 0.12.6", - "reqwest 0.11.27", + "prost", + "prost-types", + "reqwest", "secret-vault-value", "serde", "serde_json", @@ -4624,7 +4563,26 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.3.0", + "indexmap 2.4.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -4684,6 +4642,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -4740,7 +4704,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4843,7 +4807,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -4866,6 +4830,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2 0.4.5", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -4914,14 +4879,15 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper 0.14.30", + "hyper 1.4.1", + "hyper-util", "pin-project-lite", "tokio", - "tokio-io-timeout", + "tower-service", ] [[package]] @@ -5090,9 +5056,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -5178,11 +5144,11 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi", + "hermit-abi 0.4.0", "libc", "windows-sys 0.52.0", ] @@ -5246,9 +5212,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -5604,7 +5570,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -5652,11 +5618,11 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -5686,7 +5652,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -5742,7 +5708,19 @@ checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.6.0", "cfg-if", - "cfg_aliases", + "cfg_aliases 0.1.1", + "libc", +] + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "cfg_aliases 0.2.1", "libc", ] @@ -5902,7 +5880,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] @@ -5924,7 +5902,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -6036,7 +6014,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -6222,7 +6200,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -6281,7 +6259,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -6302,7 +6280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.3.0", + "indexmap 2.4.0", ] [[package]] @@ -6365,7 +6343,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -6423,7 +6401,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -6542,7 +6520,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -6618,7 +6596,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", "version_check", "yansi", ] @@ -6630,7 +6608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38ee68ae331824036479c84060534b18254c864fa73366c58d86db3b7b811619" dependencies = [ "futures", - "indexmap 2.3.0", + "indexmap 2.4.0", "nix 0.28.0", "tokio", "tracing", @@ -6685,16 +6663,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "prost" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" -dependencies = [ - "bytes", - "prost-derive 0.12.6", -] - [[package]] name = "prost" version = "0.13.1" @@ -6702,20 +6670,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" dependencies = [ "bytes", - "prost-derive 0.13.1", -] - -[[package]] -name = "prost-derive" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" -dependencies = [ - "anyhow", - "itertools 0.12.1", - "proc-macro2", - "quote", - "syn 2.0.72", + "prost-derive", ] [[package]] @@ -6728,16 +6683,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.72", -] - -[[package]] -name = "prost-types" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" -dependencies = [ - "prost 0.12.6", + "syn 2.0.74", ] [[package]] @@ -6746,7 +6692,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" dependencies = [ - "prost 0.13.1", + "prost", ] [[package]] @@ -7030,57 +6976,13 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "async-compression", - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", - "hyper-rustls 0.24.2", - "ipnet", - "js-sys", - "log", - "mime", - "mime_guess", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.12", - "rustls-native-certs 0.6.3", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", - "tokio", - "tokio-rustls 0.24.1", - "tokio-util", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams", - "web-sys", - "winreg 0.50.0", -] - [[package]] name = "reqwest" version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ + "async-compression", "base64 0.22.1", "bytes", "futures-channel", @@ -7122,14 +7024,13 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots", - "winreg 0.52.0", + "winreg", ] [[package]] name = "revm" version = "13.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b2f635bbbf4002b1b5c0219f841ec1a317723883ed7662c0d138617539a6087" +source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" dependencies = [ "auto_impl", "cfg-if", @@ -7160,8 +7061,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "9.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ad04c7d87dc3421a5ccca76e56dbd0b29a358c03bb41fe9e80976e9d3f397d" +source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" dependencies = [ "revm-primitives", "serde", @@ -7170,8 +7070,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "10.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526a4ba5ec400e7bbe71affbc10fe2e67c1cd1fb782bab988873d09a102e271" +source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" dependencies = [ "aurora-engine-modexp", "blst", @@ -7190,8 +7089,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4093d98a26601f0a793871c5bc7928410592f76b1f03fc89fde77180c554643c" +source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" dependencies = [ "alloy-eips", "alloy-primitives", @@ -7200,7 +7098,7 @@ dependencies = [ "bitvec", "c-kzg", "cfg-if", - "derive_more", + "derive_more 0.99.18", "dyn-clone", "enumn", "hashbrown 0.14.5", @@ -7389,26 +7287,13 @@ dependencies = [ "sct", ] -[[package]] -name = "rustls" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" -dependencies = [ - "log", - "ring", - "rustls-pki-types", - "rustls-webpki 0.102.6", - "subtle", - "zeroize", -] - [[package]] name = "rustls" version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ + "log", "once_cell", "ring", "rustls-pki-types", @@ -7560,7 +7445,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if", - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "scale-info-derive", ] @@ -7579,9 +7464,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.12" +version = "2.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c76e6f627d67cd14a317d7909585f4d06609acafd7891432ea45ce519211a8e9" +checksum = "79da19444d9da7a9a82b80ecf059eceba6d3129d84a8610fd25ff2364f255466" dependencies = [ "sdd", ] @@ -7616,7 +7501,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -7655,9 +7540,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f081bcf2e6c4d1d88d2b8d1c9d8a308993eafbdabb851050be4b2ff14d2c5649" +checksum = "0495e4577c672de8254beb68d01a9b62d0e8a13c099edecdbedccce3223cd29f" [[package]] name = "sec1" @@ -7698,8 +7583,8 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc32a777b53b3433b974c9c26b6d502a50037f8da94e46cb8ce2ced2cfdfaea0" dependencies = [ - "prost 0.13.1", - "prost-types 0.13.1", + "prost", + "prost-types", "serde", "serde_json", "zeroize", @@ -7763,22 +7648,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.205" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" +checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.205" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" +checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -7789,16 +7674,16 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "itoa", "memchr", "ryu", @@ -7833,7 +7718,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -7863,7 +7748,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -7892,7 +7777,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -8145,7 +8030,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest 0.12.5", + "reqwest", "rpassword", "serde", "serde_derive", @@ -8186,7 +8071,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -8252,7 +8137,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -8284,7 +8169,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "once_cell", - "reqwest 0.12.5", + "reqwest", "semver 1.0.23", "serde", "serde_json", @@ -8320,9 +8205,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" dependencies = [ "proc-macro2", "quote", @@ -8338,7 +8223,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -8353,27 +8238,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" @@ -8461,7 +8325,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -8579,7 +8443,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.1", + "mio 1.0.2", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -8588,16 +8452,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.4.0" @@ -8606,7 +8460,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -8629,17 +8483,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" -dependencies = [ - "rustls 0.22.4", - "rustls-pki-types", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.0" @@ -8719,7 +8562,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -8741,7 +8584,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "toml_datetime", "winnow 0.5.40", ] @@ -8752,7 +8595,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -8761,28 +8604,30 @@ dependencies = [ [[package]] name = "tonic" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" dependencies = [ "async-stream", "async-trait", - "axum 0.6.20", - "base64 0.21.7", + "axum", + "base64 0.22.1", "bytes", - "h2", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project 1.1.5", - "prost 0.12.6", + "prost", "rustls-native-certs 0.7.1", "rustls-pemfile 2.1.3", - "rustls-pki-types", + "socket2", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-stream", "tower", "tower-layer", @@ -8843,15 +8688,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tower-util" @@ -8885,7 +8730,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -9265,34 +9110,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -9302,9 +9148,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9312,22 +9158,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" @@ -9407,9 +9253,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -9535,7 +9381,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -9546,7 +9392,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -9557,7 +9403,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -9568,7 +9414,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -9765,16 +9611,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "winreg" version = "0.52.0" @@ -9863,7 +9699,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -9883,7 +9719,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -9916,7 +9752,7 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap 2.3.0", + "indexmap 2.4.0", "memchr", "thiserror", "zopfli", @@ -9975,3 +9811,8 @@ dependencies = [ "cc", "pkg-config", ] + +[[patch.unused]] +name = "alloy-node-bindings" +version = "0.2.1" +source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" diff --git a/Cargo.toml b/Cargo.toml index e7ff9087f580c..9ca9d49b7ce0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -182,7 +182,7 @@ alloy-node-bindings = { version = "0.2.1", default-features = false } alloy-provider = { version = "0.2.1", default-features = false } alloy-pubsub = { version = "0.2.1", default-features = false } alloy-rpc-client = { version = "0.2.1", default-features = false } -alloy-rpc-types = { version = "0.2.1", default-features = false } +alloy-rpc-types = { version = "0.2.1", default-features = true } alloy-serde = { version = "0.2.1", default-features = false } alloy-signer = { version = "0.2.1", default-features = false } alloy-signer-aws = { version = "0.2.1", default-features = false } @@ -264,3 +264,29 @@ soldeer = "0.2.19" proptest = "1" comfy-table = "7" + +[patch.crates-io] +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } +revm = { git = "https://github.com/bluealloy/revm", rev = "228b034" } +revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "228b034" } \ No newline at end of file diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 878f4bf0fe5db..4320b423af009 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1071,6 +1071,28 @@ impl TryFrom for TypedTransaction { tx.hash, ))) } + TxType::Eip7702 => { + let eip7702 = TxEip7702 { + chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, + nonce: tx.nonce, + gas_limit: tx.gas, + max_fee_per_gas: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, + max_priority_fee_per_gas: tx + .max_priority_fee_per_gas + .ok_or(ConversionError::MissingMaxPriorityFeePerGas)?, + to: tx.to.map_or(TxKind::Create, TxKind::Call), + value: tx.value, + access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, + input: tx.input, + authorization_list: tx.authorization_list.unwrap_or_default(), + }; + let signature = tx + .signature + .ok_or(ConversionError::MissingSignature)? + .try_into() + .map_err(ConversionError::SignatureError)?; + Ok(Self::EIP7702(Signed::new_unchecked(eip7702, signature, tx.hash))) + } } } } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 7f8146daa945b..0a63ad453522f 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -417,7 +417,7 @@ impl ClientFork { // Since alloy doesn't indicate in the result whether the block exists, // this is being temporarily implemented in anvil. if self.predates_fork_inclusive(number) { - let receipts = self.provider().get_block_receipts(BlockNumber::Number(number)).await?; + let receipts = self.provider().get_block_receipts(BlockId::from(number)).await?; let receipts = receipts .map(|r| { r.into_iter() diff --git a/crates/anvil/src/pubsub.rs b/crates/anvil/src/pubsub.rs index 21a5c631c9c0c..b28cdba8ae84c 100644 --- a/crates/anvil/src/pubsub.rs +++ b/crates/anvil/src/pubsub.rs @@ -3,7 +3,7 @@ use crate::{ StorageInfo, }; use alloy_primitives::{TxHash, B256}; -use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log}; +use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log, Transaction}; use anvil_core::eth::{block::Block, subscription::SubscriptionId, transaction::TypedReceipt}; use anvil_rpc::{request::Version, response::ResponseResult}; use futures::{channel::mpsc::Receiver, ready, Stream, StreamExt}; @@ -112,7 +112,7 @@ impl EthSubscription { } Self::PendingTransactions(tx, id) => { let res = ready!(tx.poll_next_unpin(cx)) - .map(SubscriptionResult::TransactionHash) + .map(SubscriptionResult::::TransactionHash) .map(to_rpc_result) .map(|result| { let params = EthSubscriptionParams { subscription: id.clone(), result }; diff --git a/crates/anvil/tests/it/eip7702.rs b/crates/anvil/tests/it/eip7702.rs index 2e7439e5d7f29..a23feceb2bc58 100644 --- a/crates/anvil/tests/it/eip7702.rs +++ b/crates/anvil/tests/it/eip7702.rs @@ -1,8 +1,7 @@ use crate::utils::http_provider; use alloy_consensus::{transaction::TxEip7702, SignableTransaction}; -use alloy_eips::eip7702::OptionalNonce; use alloy_network::{ReceiptResponse, TransactionBuilder, TxSignerSync}; -use alloy_primitives::{bytes, TxKind}; +use alloy_primitives::{bytes, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{Authorization, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -45,9 +44,9 @@ async fn can_send_eip7702_tx() { let contract = receipt.contract_address.unwrap(); let authorization = Authorization { - chain_id: 31337, + chain_id: U256::from(31337u64), address: contract, - nonce: OptionalNonce::new(Some(provider.get_transaction_count(from).await.unwrap())), + nonce: provider.get_transaction_count(from).await.unwrap(), }; let signature = wallets[0].sign_hash_sync(&authorization.signature_hash()).unwrap(); let authorization = authorization.into_signed(signature); diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index ac6f90fe3f9be..9e09f8fcf639f 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -3,6 +3,7 @@ use crate::{ fork::fork_config, utils::http_provider_with_signer, }; +use alloy_eips::BlockId; use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes, U256}; use alloy_provider::{ @@ -18,7 +19,7 @@ use alloy_rpc_types::{ }, parity::{Action, LocalizedTransactionTrace}, }, - BlockNumberOrTag, TransactionRequest, + TransactionRequest, }; use alloy_serde::WithOtherFields; use alloy_sol_types::sol; @@ -132,7 +133,7 @@ async fn test_transfer_debug_trace_call() { let traces = handle .http_provider() - .debug_trace_call(tx, BlockNumberOrTag::Latest, GethDebugTracingCallOptions::default()) + .debug_trace_call(tx, BlockId::latest(), GethDebugTracingCallOptions::default()) .await .unwrap(); @@ -178,7 +179,7 @@ async fn test_call_tracer_debug_trace_call() { .http_provider() .debug_trace_call( internal_call_tx.clone(), - BlockNumberOrTag::Latest, + BlockId::latest(), GethDebugTracingCallOptions::default().with_tracing_options( GethDebugTracingOptions::default() .with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer)) @@ -206,7 +207,7 @@ async fn test_call_tracer_debug_trace_call() { .http_provider() .debug_trace_call( internal_call_tx.clone(), - BlockNumberOrTag::Latest, + BlockId::latest(), GethDebugTracingCallOptions::default().with_tracing_options( GethDebugTracingOptions::default() .with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer)) @@ -235,7 +236,7 @@ async fn test_call_tracer_debug_trace_call() { .http_provider() .debug_trace_call( direct_call_tx, - BlockNumberOrTag::Latest, + BlockId::latest(), GethDebugTracingCallOptions::default().with_tracing_options( GethDebugTracingOptions::default() .with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer)) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 1c93afd0f265b..5cb05ec2bfa7d 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -89,7 +89,7 @@ impl Cheatcode for loadCall { let Self { target, slot } = *self; ensure_not_precompile!(&target, ccx); ccx.ecx.load_account(target)?; - let (val, _) = ccx.ecx.sload(target, slot.into())?; + let val = ccx.ecx.sload(target, slot.into())?; Ok(val.abi_encode()) } } @@ -590,7 +590,7 @@ impl Cheatcode for setBlockhashCall { } pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { - let (account, _) = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?; + let account = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?; Ok(account.info.nonce.abi_encode()) } diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 0949cbf4f973d..1a6ffb46a51fb 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -49,7 +49,7 @@ impl Cheatcode for clearMockedCallsCall { impl Cheatcode for mockCall_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; - let (acc, _) = ccx.ecx.load_account(*callee)?; + let acc = ccx.ecx.load_account(*callee)?; // Etches a single byte onto the account if it is empty to circumvent the `extcodesize` // check Solidity might perform. diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index f1af752a4454e..02c97ac273798 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -92,7 +92,6 @@ pub trait CheatcodesExecutor { db: &mut ccx.ecx.db as &mut dyn DatabaseExt, error, l1_block_info, - valid_authorizations: std::mem::take(&mut ccx.ecx.valid_authorizations), }; let mut evm = new_evm_with_existing_context(inner, &mut inspector as _); @@ -103,7 +102,6 @@ pub trait CheatcodesExecutor { ccx.ecx.env = evm.context.evm.inner.env; ccx.ecx.l1_block_info = evm.context.evm.inner.l1_block_info; ccx.ecx.error = evm.context.evm.inner.error; - ccx.ecx.valid_authorizations = evm.context.evm.inner.valid_authorizations; Ok(res) } @@ -647,7 +645,7 @@ impl Cheatcodes { crate::Vm::AccountAccessKind::Create as u8 ); if let Some(address) = outcome.address { - if let Ok((created_acc, _)) = + if let Ok(created_acc) = ecx.journaled_state.load_account(address, &mut ecx.db) { create_access.newBalance = created_acc.info.balance; @@ -888,7 +886,7 @@ impl Cheatcodes { // nonce, a non-zero KECCAK_EMPTY codehash, or non-empty code let initialized; let old_balance; - if let Ok((acc, _)) = ecx.load_account(call.target_address) { + if let Ok(acc) = ecx.load_account(call.target_address) { initialized = acc.info.exists(); old_balance = acc.info.balance; } else { @@ -1130,7 +1128,7 @@ impl Inspector for Cheatcodes { // Depending on the depth the cheat was called at, there may not be any pending // calls to update if execution has percolated up to a higher depth. if call_access.depth == ecx.journaled_state.depth() { - if let Ok((acc, _)) = ecx.load_account(call.target_address) { + if let Ok(acc) = ecx.load_account(call.target_address) { debug_assert!(access_is_call(call_access.kind)); call_access.newBalance = acc.info.balance; } @@ -1438,13 +1436,13 @@ impl Cheatcodes { let target = Address::from_word(B256::from(target)); let (initialized, old_balance) = ecx .load_account(target) - .map(|(account, _)| (account.info.exists(), account.info.balance)) + .map(|account| (account.info.exists(), account.info.balance)) .unwrap_or_default(); // load balance of this account let value = ecx .balance(interpreter.contract().target_address) - .map(|(b, _)| b) + .map(|b| b.data) .unwrap_or(U256::ZERO); // register access for the target account @@ -1479,8 +1477,8 @@ impl Cheatcodes { let mut present_value = U256::ZERO; // Try to load the account and the slot's present value if ecx.load_account(address).is_ok() { - if let Ok((previous, _)) = ecx.sload(address, key) { - present_value = previous; + if let Ok(previous) = ecx.sload(address, key) { + present_value = previous.data; } } let access = crate::Vm::StorageAccess { @@ -1503,8 +1501,8 @@ impl Cheatcodes { // not set (zero value) let mut previous_value = U256::ZERO; if ecx.load_account(address).is_ok() { - if let Ok((previous, _)) = ecx.sload(address, key) { - previous_value = previous; + if let Ok(previous) = ecx.sload(address, key) { + previous_value = previous.data; } } @@ -1532,7 +1530,7 @@ impl Cheatcodes { Address::from_word(B256::from(try_or_return!(interpreter.stack().peek(0)))); let initialized; let balance; - if let Ok((acc, _)) = ecx.load_account(address) { + if let Ok(acc) = ecx.load_account(address) { initialized = acc.info.exists(); balance = acc.info.balance; } else { diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 7c2ed11c4b239..f33b772af2c8b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1381,7 +1381,7 @@ impl DatabaseExt for Backend { for (addr, acc) in allocs.iter() { // Fetch the account from the journaled state. Will create a new account if it does // not already exist. - let (state_acc, _) = journaled_state.load_account(*addr, self)?; + let mut state_acc = journaled_state.load_account(*addr, self)?; // Set the account's bytecode and code hash, if the `bytecode` field is present. if let Some(bytecode) = acc.code.as_ref() { diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 76a738c525405..8860b1683a4c6 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -142,7 +142,7 @@ pub fn create2_handler_register>( .push((ctx.evm.journaled_state.depth(), call_inputs.clone())); // Sanity check that CREATE2 deployer exists. - let code_hash = ctx.evm.load_account(DEFAULT_CREATE2_DEPLOYER)?.0.info.code_hash; + let code_hash = ctx.evm.load_account(DEFAULT_CREATE2_DEPLOYER)?.info.code_hash; if code_hash == KECCAK_EMPTY { return Ok(FrameOrResult::Result(FrameResult::Call(CallOutcome { result: InterpreterResult { diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index c61fab4e85087..a6f2f3a1f55d4 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -504,7 +504,6 @@ impl<'a> InspectorStackRefMut<'a> { .journaled_state .load_account(caller, &mut ecx.db) .expect("failed to load caller") - .0 .info .nonce; diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 62740cce9bfc2..eb30edd29d73f 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -3,7 +3,7 @@ use alloy_dyn_abi::{DynSolValue, JsonAbiExt, Specifier}; use alloy_json_abi::{Constructor, JsonAbi}; use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes}; -use alloy_provider::{Provider, ProviderBuilder}; +use alloy_provider::{PendingTransactionError, Provider, ProviderBuilder}; use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_signer::Signer; @@ -586,6 +586,12 @@ pub enum ContractDeploymentError { RpcError(#[from] TransportError), } +impl From for ContractDeploymentError { + fn from(_err: PendingTransactionError) -> Self { + Self::ContractNotDeployed + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 89c1ed2e9700b..8f6b606b4a117 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -32,7 +32,7 @@ aws-sdk-kms = { version = "1", default-features = false, optional = true } # gcp-kms alloy-signer-gcp = { workspace = true, features = ["eip712"], optional = true } -gcloud-sdk = { version = "0.24", features = [ +gcloud-sdk = { version = "0.25", features = [ "google-cloud-kms-v1", "google-longrunning", ], optional = true } From 62def0d68897aae7c2172eabed8085f631625003 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 16 Aug 2024 03:48:14 +0800 Subject: [PATCH 1358/1963] feat: `vm.publicKeyP256` (#8679) * publicKeyP256 * clippy * fix error * update doc * update error message * add coauthor Co-authored-by: protocolwhisper --------- Co-authored-by: protocolwhisper --- Cargo.lock | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++ crates/cheatcodes/spec/src/vm.rs | 4 ++ crates/cheatcodes/src/crypto.rs | 49 ++++++++++++++++-------- testdata/cheats/Vm.sol | 1 + 6 files changed, 59 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fd1aa9cde8f2..13450d26c69ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3539,6 +3539,7 @@ dependencies = [ "base64 0.22.1", "chrono", "dialoguer", + "ecdsa", "eyre", "foundry-cheatcodes-spec", "foundry-common", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index c061a6381db5a..8af927f349d3e 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -54,6 +54,7 @@ jsonpath_lib.workspace = true k256.workspace = true memchr = "2.7" p256 = "0.13.2" +ecdsa = "0.16" rand = "0.8" revm.workspace = true rustc-hash.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 6549b31af167b..80c8516f6dde2 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6631,6 +6631,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "publicKeyP256", + "description": "Derives secp256r1 public key from the provided `privateKey`.", + "declaration": "function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);", + "visibility": "external", + "mutability": "pure", + "signature": "publicKeyP256(uint256)", + "selector": "0xc453949e", + "selectorBytes": [ + 196, + 83, + 148, + 158 + ] + }, + "group": "crypto", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "randomAddress", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index a4dc636902f17..8e0b51ec35c2d 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2195,6 +2195,10 @@ interface Vm { #[cheatcode(group = Crypto)] function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); + /// Derives secp256r1 public key from the provided `privateKey`. + #[cheatcode(group = Crypto)] + function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY); + /// Derive a private key from a provided mnenomic string (or mnenomic file path) /// at the derivation path `m/44'/60'/0'/0/{index}`. #[cheatcode(group = Crypto)] diff --git a/crates/cheatcodes/src/crypto.rs b/crates/cheatcodes/src/crypto.rs index aea346279cc86..f080938ac5a28 100644 --- a/crates/cheatcodes/src/crypto.rs +++ b/crates/cheatcodes/src/crypto.rs @@ -13,8 +13,7 @@ use alloy_signer_local::{ use alloy_sol_types::SolValue; use k256::{ ecdsa::SigningKey, - elliptic_curve::{sec1::ToEncodedPoint, Curve}, - Secp256k1, + elliptic_curve::{bigint::ArrayEncoding, sec1::ToEncodedPoint}, }; use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; @@ -153,6 +152,18 @@ impl Cheatcode for signP256Call { } } +impl Cheatcode for publicKeyP256Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { privateKey } = self; + let pub_key = + parse_private_key_p256(privateKey)?.verifying_key().as_affine().to_encoded_point(false); + let pub_key_x = U256::from_be_bytes((*pub_key.x().unwrap()).into()); + let pub_key_y = U256::from_be_bytes((*pub_key.y().unwrap()).into()); + + Ok((pub_key_x, pub_key_y).abi_encode()) + } +} + /// Using a given private key, return its public ETH address, its public key affine x and y /// coordinates, and its private key (see the 'Wallet' struct) /// @@ -230,14 +241,7 @@ fn sign_with_wallet( } fn sign_p256(private_key: &U256, digest: &B256) -> Result { - ensure!(*private_key != U256::ZERO, "private key cannot be 0"); - let n = U256::from_limbs(*p256::NistP256::ORDER.as_words()); - ensure!( - *private_key < n, - format!("private key must be less than the secp256r1 curve order ({})", n), - ); - let bytes = private_key.to_be_bytes(); - let signing_key = P256SigningKey::from_bytes((&bytes).into())?; + let signing_key = parse_private_key_p256(private_key)?; let signature: Signature = signing_key.sign_prehash(digest.as_slice())?; let r_bytes: [u8; 32] = signature.r().to_bytes().into(); let s_bytes: [u8; 32] = signature.s().to_bytes().into(); @@ -245,15 +249,26 @@ fn sign_p256(private_key: &U256, digest: &B256) -> Result { Ok((r_bytes, s_bytes).abi_encode()) } -fn parse_private_key(private_key: &U256) -> Result { +fn validate_private_key(private_key: &U256) -> Result<()> { ensure!(*private_key != U256::ZERO, "private key cannot be 0"); + let order = U256::from_be_slice(&C::ORDER.to_be_byte_array()); ensure!( - *private_key < U256::from_limbs(*Secp256k1::ORDER.as_words()), - "private key must be less than the secp256k1 curve order \ - (115792089237316195423570985008687907852837564279074904382605163141518161494337)", + *private_key < U256::from_be_slice(&C::ORDER.to_be_byte_array()), + "private key must be less than the {curve:?} curve order ({order})", + curve = C::default(), ); - let bytes = private_key.to_be_bytes(); - SigningKey::from_bytes((&bytes).into()).map_err(Into::into) + + Ok(()) +} + +fn parse_private_key(private_key: &U256) -> Result { + validate_private_key::(private_key)?; + Ok(SigningKey::from_bytes((&private_key.to_be_bytes()).into())?) +} + +fn parse_private_key_p256(private_key: &U256) -> Result { + validate_private_key::(private_key)?; + Ok(P256SigningKey::from_bytes((&private_key.to_be_bytes()).into())?) } pub(super) fn parse_wallet(private_key: &U256) -> Result { @@ -328,7 +343,7 @@ mod tests { ) .unwrap(); let result = sign_p256(&pk, &digest); - assert_eq!(result.err().unwrap().to_string(), "private key must be less than the secp256r1 curve order (115792089210356248762697446949407573529996955224135760342422259061068512044369)"); + assert_eq!(result.err().unwrap().to_string(), "private key must be less than the NistP256 curve order (115792089210356248762697446949407573529996955224135760342422259061068512044369)"); } #[test] diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 0e731d88ebf7f..8004efb1dad70 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -327,6 +327,7 @@ interface Vm { function promptSecret(string calldata promptText) external returns (string memory input); function promptSecretUint(string calldata promptText) external returns (uint256); function promptUint(string calldata promptText) external returns (uint256); + function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY); function randomAddress() external returns (address); function randomUint() external returns (uint256); function randomUint(uint256 min, uint256 max) external returns (uint256); From 80fd75b657d474d66351f60e891e2b5432145e77 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 17 Aug 2024 02:35:39 +0800 Subject: [PATCH 1359/1963] feat(cast): `cast wallet sign-auth` + `cast send --auth` (#8683) * Take 1 * update match * cast send --authorize * Add test * clippy * Fix test * fix test --------- Co-authored-by: grandizzy --- Cargo.lock | 9 +- Cargo.toml | 4 +- crates/anvil/src/eth/backend/mem/mod.rs | 3 +- crates/cast/Cargo.toml | 1 + crates/cast/bin/cmd/access_list.rs | 4 +- crates/cast/bin/cmd/call.rs | 9 +- crates/cast/bin/cmd/estimate.rs | 4 +- crates/cast/bin/cmd/mktx.rs | 2 +- crates/cast/bin/cmd/send.rs | 4 +- crates/cast/bin/cmd/wallet/mod.rs | 41 ++++++++ crates/cast/bin/tx.rs | 132 +++++++++++++++++++++--- crates/cast/tests/cli/main.rs | 43 ++++++++ crates/cli/src/opts/transaction.rs | 6 ++ crates/test-utils/src/macros.rs | 12 ++- crates/wallets/src/wallet.rs | 17 +-- 15 files changed, 242 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13450d26c69ed..b81c6670f87cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1867,6 +1867,7 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "alloy-transport", + "anvil", "async-trait", "aws-sdk-kms", "chrono", @@ -7031,7 +7032,7 @@ dependencies = [ [[package]] name = "revm" version = "13.0.0" -source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" +source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" dependencies = [ "auto_impl", "cfg-if", @@ -7062,7 +7063,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "9.0.0" -source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" +source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" dependencies = [ "revm-primitives", "serde", @@ -7071,7 +7072,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "10.0.0" -source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" +source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" dependencies = [ "aurora-engine-modexp", "blst", @@ -7090,7 +7091,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "8.0.0" -source = "git+https://github.com/bluealloy/revm?rev=228b034#228b0343f372c69924023721c00f2d0e01e72a86" +source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" dependencies = [ "alloy-eips", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 9ca9d49b7ce0f..e78d0049231fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -288,5 +288,5 @@ alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -revm = { git = "https://github.com/bluealloy/revm", rev = "228b034" } -revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "228b034" } \ No newline at end of file +revm = { git = "https://github.com/bluealloy/revm", rev = "caadc71" } +revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "caadc71" } \ No newline at end of file diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 180554e834002..9d21b9bf2a44e 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1137,6 +1137,7 @@ impl Backend { nonce, access_list, blob_versioned_hashes, + authorization_list, sidecar: _, chain_id: _, transaction_type: _, @@ -1188,7 +1189,7 @@ impl Backend { access_list: access_list.unwrap_or_default().into(), blob_hashes: blob_versioned_hashes.unwrap_or_default(), optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, - authorization_list: None, + authorization_list: authorization_list.map(Into::into), }; if env.block.basefee.is_zero() { diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 1d899bbba2f49..edc3fbe8d6089 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -85,6 +85,7 @@ evmole = "0.3.1" tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] +anvil.workspace = true foundry-test-utils.workspace = true async-trait.workspace = true criterion = "0.5" diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 2a672bffd6779..fcaf848acbd4f 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -1,4 +1,4 @@ -use crate::tx::CastTxBuilder; +use crate::tx::{CastTxBuilder, SenderKind}; use alloy_primitives::TxKind; use alloy_rpc_types::BlockId; use cast::Cast; @@ -53,7 +53,7 @@ impl AccessListArgs { let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let sender = eth.wallet.sender().await; + let sender = SenderKind::from_wallet_opts(eth.wallet).await?; let tx_kind = if let Some(to) = to { TxKind::Call(to.resolve(&provider).await?) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 4cec6f0f0f478..e9db0084e2ecf 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -1,4 +1,4 @@ -use crate::tx::CastTxBuilder; +use crate::tx::{CastTxBuilder, SenderKind}; use alloy_primitives::{TxKind, U256}; use alloy_rpc_types::{BlockId, BlockNumberOrTag}; use cast::{traces::TraceKind, Cast}; @@ -125,7 +125,8 @@ impl CallArgs { let mut config = Config::from(ð); let provider = utils::get_provider(&config)?; - let sender = eth.wallet.sender().await; + let sender = SenderKind::from_wallet_opts(eth.wallet).await?; + let from = sender.address(); let tx_kind = if let Some(to) = to { TxKind::Call(to.resolve(&provider).await?) @@ -181,11 +182,11 @@ impl CallArgs { let trace = match tx_kind { TxKind::Create => { - let deploy_result = executor.deploy(sender, input, value, None); + let deploy_result = executor.deploy(from, input, value, None); TraceResult::try_from(deploy_result)? } TxKind::Call(to) => TraceResult::from_raw( - executor.transact_raw(sender, to, input, value)?, + executor.transact_raw(from, to, input, value)?, TraceKind::Execution, ), }; diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index d16cfac0f5999..84812c8cc4447 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,4 +1,4 @@ -use crate::tx::CastTxBuilder; +use crate::tx::{CastTxBuilder, SenderKind}; use alloy_primitives::{TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::BlockId; @@ -71,7 +71,7 @@ impl EstimateArgs { let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let sender = eth.wallet.sender().await; + let sender = SenderKind::from_wallet_opts(eth.wallet).await?; let tx_kind = if let Some(to) = to { TxKind::Call(to.resolve(&provider).await?) diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index 4a343af6da38c..4c7a55cb122e6 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -101,7 +101,7 @@ impl MakeTxArgs { .with_code_sig_and_args(code, sig, args) .await? .with_blob_data(blob_data)? - .build(from) + .build(&signer) .await?; let tx = tx.build(&EthereumWallet::new(signer)).await?; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index cdafbc8a3447e..82c7f15d90464 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -164,13 +164,13 @@ impl SendTxArgs { tx::validate_from_address(eth.wallet.from, from)?; + let (tx, _) = builder.build(&signer).await?; + let wallet = EthereumWallet::from(signer); let provider = ProviderBuilder::<_, _, AnyNetwork>::default() .wallet(wallet) .on_provider(&provider); - let (tx, _) = builder.build(from).await?; - cast_send(provider, tx, cast_async, confirmations, to_json).await } } diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 64f048b2cfa7f..893a0f0ecdb4d 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,12 +1,16 @@ +use alloy_chains::Chain; use alloy_dyn_abi::TypedData; use alloy_primitives::{hex, Address, Signature, B256}; +use alloy_provider::Provider; use alloy_signer::Signer; use alloy_signer_local::{ coins_bip39::{English, Entropy, Mnemonic}, MnemonicBuilder, PrivateKeySigner, }; +use cast::revm::primitives::{Authorization, U256}; use clap::Parser; use eyre::{Context, Result}; +use foundry_cli::{opts::RpcOpts, utils}; use foundry_common::fs; use foundry_config::Config; use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner}; @@ -116,6 +120,25 @@ pub enum WalletSubcommands { wallet: WalletOpts, }, + /// EIP-7702 sign authorization. + #[command(visible_alias = "sa")] + SignAuth { + /// Address to sign authorization for. + address: Address, + + #[command(flatten)] + rpc: RpcOpts, + + #[arg(long)] + nonce: Option, + + #[arg(long)] + chain: Option, + + #[command(flatten)] + wallet: WalletOpts, + }, + /// Verify the signature of a message. #[command(visible_alias = "v")] Verify { @@ -327,6 +350,24 @@ impl WalletSubcommands { }; println!("0x{}", hex::encode(sig.as_bytes())); } + Self::SignAuth { rpc, nonce, chain, wallet, address } => { + let wallet = wallet.signer().await?; + let provider = utils::get_provider(&Config::from(&rpc))?; + let nonce = if let Some(nonce) = nonce { + nonce + } else { + provider.get_transaction_count(wallet.address()).await? + }; + let chain_id = if let Some(chain) = chain { + chain.id() + } else { + provider.get_chain_id().await? + }; + let auth = Authorization { chain_id: U256::from(chain_id), address, nonce }; + let signature = wallet.sign_hash(&auth.signature_hash()).await?; + let auth = auth.into_signed(signature); + println!("{}", hex::encode_prefixed(alloy_rlp::encode(&auth))); + } Self::Verify { message, signature, address } => { let recovered_address = Self::recover_address_from_message(&message, &signature)?; if address == recovered_address { diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 9a731187a570d..f6a9cbd53de99 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,11 +1,14 @@ use alloy_consensus::{SidecarBuilder, SimpleCoder}; use alloy_json_abi::Function; use alloy_network::{AnyNetwork, TransactionBuilder}; -use alloy_primitives::{hex, Address, Bytes, TxKind}; +use alloy_primitives::{hex, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{TransactionInput, TransactionRequest}; +use alloy_rlp::Decodable; +use alloy_rpc_types::{Authorization, TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; +use alloy_signer::Signer; use alloy_transport::Transport; +use cast::revm::primitives::SignedAuthorization; use eyre::Result; use foundry_cli::{ opts::TransactionOpts, @@ -13,6 +16,73 @@ use foundry_cli::{ }; use foundry_common::ens::NameOrAddress; use foundry_config::{Chain, Config}; +use foundry_wallets::{WalletOpts, WalletSigner}; + +/// Different sender kinds used by [`CastTxBuilder`]. +pub enum SenderKind<'a> { + /// An address without signer. Used for read-only calls and transactions sent through unlocked + /// accounts. + Address(Address), + /// A refersnce to a signer. + Signer(&'a WalletSigner), + /// An owned signer. + OwnedSigner(WalletSigner), +} + +impl SenderKind<'_> { + /// Resolves the name to an Ethereum Address. + pub fn address(&self) -> Address { + match self { + Self::Address(addr) => *addr, + Self::Signer(signer) => signer.address(), + Self::OwnedSigner(signer) => signer.address(), + } + } + + /// Resolves the sender from the wallet options. + /// + /// This function prefers the `from` field and may return a different address from the + /// configured signer + /// If from is specified, returns it + /// If from is not specified, but there is a signer configured, returns the signer's address + /// If from is not specified and there is no signer configured, returns zero address + pub async fn from_wallet_opts(opts: WalletOpts) -> Result { + if let Some(from) = opts.from { + Ok(from.into()) + } else if let Ok(signer) = opts.signer().await { + Ok(Self::OwnedSigner(signer)) + } else { + Ok(Address::ZERO.into()) + } + } + + /// Returns the signer if available. + pub fn as_signer(&self) -> Option<&WalletSigner> { + match self { + Self::Signer(signer) => Some(signer), + Self::OwnedSigner(signer) => Some(signer), + _ => None, + } + } +} + +impl From
for SenderKind<'_> { + fn from(addr: Address) -> Self { + Self::Address(addr) + } +} + +impl<'a> From<&'a WalletSigner> for SenderKind<'a> { + fn from(signer: &'a WalletSigner) -> Self { + Self::Signer(signer) + } +} + +impl From for SenderKind<'_> { + fn from(signer: WalletSigner) -> Self { + Self::OwnedSigner(signer) + } +} /// Prevents a misconfigured hwlib from sending a transaction that defies user-specified --from pub fn validate_from_address( @@ -76,6 +146,7 @@ pub struct CastTxBuilder { tx: WithOtherFields, legacy: bool, blob: bool, + auth: Option, chain: Chain, etherscan_api_key: Option, state: S, @@ -133,6 +204,7 @@ where blob: tx_opts.blob, chain, etherscan_api_key, + auth: tx_opts.auth, state: InitState, _t: std::marker::PhantomData, }) @@ -147,6 +219,7 @@ where blob: self.blob, chain: self.chain, etherscan_api_key: self.etherscan_api_key, + auth: self.auth, state: TxKindState { kind }, _t: self._t, } @@ -196,6 +269,7 @@ where blob: self.blob, chain: self.chain, etherscan_api_key: self.etherscan_api_key, + auth: self.auth, state: InputState { kind: self.state.kind, input, func }, _t: self._t, }) @@ -211,31 +285,32 @@ where /// to be broadcasted. pub async fn build( self, - from: impl Into, + sender: impl Into>, ) -> Result<(WithOtherFields, Option)> { - self._build(from, true).await + self._build(sender, true).await } /// Builds [TransactionRequest] without filling missing fields. Used for read-only calls such as /// eth_call, eth_estimateGas, etc pub async fn build_raw( self, - from: impl Into, + sender: impl Into>, ) -> Result<(WithOtherFields, Option)> { - self._build(from, false).await + self._build(sender, false).await } async fn _build( mut self, - from: impl Into, + sender: impl Into>, fill: bool, ) -> Result<(WithOtherFields, Option)> { - let from = from.into().resolve(&self.provider).await?; + let sender = sender.into(); + let from = sender.address(); self.tx.set_kind(self.state.kind); // we set both fields to the same value because some nodes only accept the legacy `data` field: - let input = Bytes::from(self.state.input); + let input = Bytes::copy_from_slice(&self.state.input); self.tx.input = TransactionInput { input: Some(input.clone()), data: Some(input) }; self.tx.set_from(from); @@ -269,16 +344,47 @@ where } } + let nonce = if let Some(nonce) = self.tx.nonce { + nonce + } else { + let nonce = self.provider.get_transaction_count(from).await?; + self.tx.nonce = Some(nonce); + nonce + }; + + self.resolve_auth(sender, nonce).await?; + if self.tx.gas.is_none() { self.tx.gas = Some(self.provider.estimate_gas(&self.tx).await?); } - if self.tx.nonce.is_none() { - self.tx.nonce = Some(self.provider.get_transaction_count(from).await?); - } - Ok((self.tx, self.state.func)) } + + /// Parses the passed --auth value and sets the authorization list on the transaction. + async fn resolve_auth(&mut self, sender: SenderKind<'_>, nonce: u64) -> Result<()> { + let Some(auth) = &self.auth else { return Ok(()) }; + + let auth = hex::decode(auth)?; + let auth = if let Ok(address) = Address::try_from(auth.as_slice()) { + let auth = + Authorization { chain_id: U256::from(self.chain.id()), nonce: nonce + 1, address }; + + let Some(signer) = sender.as_signer() else { + eyre::bail!("No signer available to sign authorization"); + }; + let signature = signer.sign_hash(&auth.signature_hash()).await?; + + auth.into_signed(signature) + } else if let Ok(auth) = SignedAuthorization::decode(&mut auth.as_ref()) { + auth + } else { + eyre::bail!("Failed to decode authorization"); + }; + self.tx.set_authorization_list(vec![auth]); + + Ok(()) + } } impl CastTxBuilder diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 91d04f031c960..d0ff5a88124bb 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,6 +1,7 @@ //! Contains various tests for checking cast commands use alloy_primitives::{address, b256, Address, B256}; +use anvil::{Hardfork, NodeConfig}; use foundry_test_utils::{ casttest, rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}, @@ -146,6 +147,23 @@ casttest!(wallet_sign_typed_data_file, |_prj, cmd| { "#]]); }); +// tests that `cast wallet sign-auth message` outputs the expected signature +casttest!(wallet_sign_auth, |_prj, cmd| { + cmd.args([ + "wallet", + "sign-auth", + "--private-key", + "0x0000000000000000000000000000000000000000000000000000000000000001", + "--nonce", + "100", + "--chain", + "1", + "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf"]).assert_success().stdout_eq(str![[r#" +0xf85a01947e5f4552091a69125d5dfcb7b8c2659029395bdf6401a0ad489ee0314497c3f06567f3080a46a63908edc1c7cdf2ac2d609ca911212086a065a6ba951c8748dd8634740fe498efb61770097d99ff5fdcb9a863b62ea899f6 + +"#]]); +}); + // tests that `cast wallet list` outputs the local accounts casttest!(wallet_list_local_accounts, |prj, cmd| { let keystore_path = prj.root().join("keystore"); @@ -1014,3 +1032,28 @@ casttest!(block_number_hash, |_prj, cmd| { .stdout_lossy(); assert_eq!(s.trim().parse::().unwrap(), 1, "{s}") }); + +casttest!(send_eip7702, async |_prj, cmd| { + let (_api, handle) = + anvil::spawn(NodeConfig::test().with_hardfork(Some(Hardfork::PragueEOF))).await; + let endpoint = handle.http_endpoint(); + cmd.args([ + "send", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "--auth", + "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &endpoint, + ]) + .assert_success(); + + cmd.cast_fuse() + .args(["code", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "--rpc-url", &endpoint]) + .assert_success() + .stdout_eq(str![[r#" +0xef010070997970c51812dc3a010c7d01b50e0d17dc79c8 + +"#]]); +}); diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index 5cf126685db15..c443146b57db6 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -56,6 +56,12 @@ pub struct TransactionOpts { /// Gas price for EIP-4844 blob transaction. #[arg(long, conflicts_with = "legacy", value_parser = parse_ether_value, env = "ETH_BLOB_GAS_PRICE", value_name = "BLOB_PRICE")] pub blob_gas_price: Option, + + /// EIP-7702 authorization list. + /// + /// Can be either a hex-encoded signed authorization or an address. + #[arg(long, conflicts_with_all = &["legacy", "blob"])] + pub auth: Option, } #[cfg(test)] diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index 1f19adffe1544..064a94ef2d6d0 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -63,8 +63,8 @@ macro_rules! forgetest_async { #[macro_export] macro_rules! casttest { - ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { - $crate::casttest!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); + ($(#[$attr:meta])* $test:ident, $($async:ident)? |$prj:ident, $cmd:ident| $e:expr) => { + $crate::casttest!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $($async)? |$prj, $cmd| $e); }; ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { #[test] @@ -74,6 +74,14 @@ macro_rules! casttest { $e } }; + ($(#[$attr:meta])* $test:ident, $style:expr, async |$prj:ident, $cmd:ident| $e:expr) => { + #[tokio::test(flavor = "multi_thread")] + $(#[$attr])* + async fn $test() { + let (mut $prj, mut $cmd) = $crate::util::setup_cast(stringify!($test), $style); + $e + } + }; } /// Same as `forgetest` but returns an already initialized project workspace (`forge init`) diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index ce049fe408608..14a9f74221105 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -1,6 +1,5 @@ use crate::{raw_wallet::RawWalletOpts, utils, wallet_signer::WalletSigner}; use alloy_primitives::Address; -use alloy_signer::Signer; use clap::Parser; use eyre::Result; use serde::Serialize; @@ -140,21 +139,6 @@ of the unlocked account you want to use, or provide the --from flag with the add Ok(signer) } - - /// This function prefers the `from` field and may return a different address from the - /// configured signer - /// If from is specified, returns it - /// If from is not specified, but there is a signer configured, returns the signer's address - /// If from is not specified and there is no signer configured, returns zero address - pub async fn sender(&self) -> Address { - if let Some(from) = self.from { - from - } else if let Ok(signer) = self.signer().await { - signer.address() - } else { - Address::ZERO - } - } } impl From for WalletOpts { @@ -165,6 +149,7 @@ impl From for WalletOpts { #[cfg(test)] mod tests { + use alloy_signer::Signer; use std::{path::Path, str::FromStr}; use super::*; From f8aa4afec04cc0b7d364a5d78f0cde9e64fd14bf Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 17 Aug 2024 02:41:29 +0800 Subject: [PATCH 1360/1963] feat: `--alphanet` flag and config option (#8680) * --alphanet * fix tests * fix doc * anvil support * better cast and anvil * fix doc --- crates/anvil/src/cmd.rs | 5 ++ crates/anvil/src/config.rs | 16 +++++- crates/anvil/src/eth/backend/executor.rs | 3 +- crates/anvil/src/eth/backend/mem/inspector.rs | 14 +++++- crates/anvil/src/eth/backend/mem/mod.rs | 7 ++- crates/cast/bin/cmd/call.rs | 47 +++++++++++++++--- crates/cast/bin/cmd/run.rs | 49 ++++++++++++++++--- crates/common/src/evm.rs | 9 ++++ crates/config/src/lib.rs | 6 ++- crates/config/src/utils.rs | 5 +- crates/evm/core/src/lib.rs | 4 ++ crates/evm/core/src/opts.rs | 3 ++ crates/evm/core/src/precompiles.rs | 30 +++++++++++- crates/evm/core/src/utils.rs | 32 ++++++++++-- crates/evm/evm/src/executors/trace.rs | 9 ++-- crates/evm/evm/src/inspectors/stack.rs | 27 ++++++++++ crates/forge/bin/cmd/test/mod.rs | 1 + crates/forge/src/multi_runner.rs | 12 +++++ crates/forge/tests/cli/config.rs | 1 + crates/script/src/lib.rs | 4 +- crates/verify/src/bytecode.rs | 12 +++-- 21 files changed, 264 insertions(+), 32 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index a2802e0591773..e21f12d365f5a 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -252,6 +252,7 @@ impl NodeArgs { .with_transaction_block_keeper(self.transaction_block_keeper) .with_max_persisted_states(self.max_persisted_states) .with_optimism(self.evm_opts.optimism) + .with_alphanet(self.evm_opts.alphanet) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) .with_memory_limit(self.evm_opts.memory_limit) @@ -550,6 +551,10 @@ pub struct AnvilEvmArgs { /// The memory limit per EVM execution in bytes. #[arg(long)] pub memory_limit: Option, + + /// Enable Alphanet features + #[arg(long, visible_alias = "alphanet")] + pub alphanet: bool, } /// Resolves an alias passed as fork-url to the matching url defined in the rpc_endpoints section diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 5e8ef0f9a1b61..a94d5b827d001 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -183,6 +183,8 @@ pub struct NodeConfig { pub memory_limit: Option, /// Factory used by `anvil` to extend the EVM's precompiles. pub precompile_factory: Option>, + /// Enable Alphanet features. + pub alphanet: bool, } impl NodeConfig { @@ -437,6 +439,7 @@ impl Default for NodeConfig { slots_in_an_epoch: 32, memory_limit: None, precompile_factory: None, + alphanet: false, } } } @@ -471,8 +474,11 @@ impl NodeConfig { } } - /// Returns the base fee to use + /// Returns the hardfork to use pub fn get_hardfork(&self) -> Hardfork { + if self.alphanet { + return Hardfork::PragueEOF; + } self.hardfork.unwrap_or_default() } @@ -918,6 +924,13 @@ impl NodeConfig { self } + /// Sets whether to enable Alphanet support + #[must_use] + pub fn with_alphanet(mut self, alphanet: bool) -> Self { + self.alphanet = alphanet; + self + } + /// Configures everything related to env, backend and database and returns the /// [Backend](mem::Backend) /// @@ -994,6 +1007,7 @@ impl NodeConfig { Arc::new(RwLock::new(fork)), self.enable_steps_tracing, self.print_logs, + self.alphanet, self.prune_history, self.max_persisted_states, self.transaction_block_keeper, diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index d56db9069f812..b46f29c38a979 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -105,6 +105,7 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> /// Cumulative blob gas used by all executed transactions pub blob_gas_used: u128, pub enable_steps_tracing: bool, + pub alphanet: bool, pub print_logs: bool, /// Precompiles to inject to the EVM. pub precompile_factory: Option>, @@ -302,7 +303,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator let nonce = account.nonce; // records all call and step traces - let mut inspector = Inspector::default().with_tracing(); + let mut inspector = Inspector::default().with_tracing().with_alphanet(self.alphanet); if self.enable_steps_tracing { inspector = inspector.with_steps_tracing(); } diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 2095e9d5034a7..56e53acc3452b 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -23,6 +23,8 @@ pub struct Inspector { pub tracer: Option, /// collects all `console.sol` logs pub log_collector: Option, + /// Whether to enable Alphanet support + pub alphanet: bool, } impl Inspector { @@ -57,6 +59,12 @@ impl Inspector { self.log_collector = Some(Default::default()); self } + + /// Enables Alphanet features + pub fn with_alphanet(mut self, yes: bool) -> Self { + self.alphanet = yes; + self + } } impl revm::Inspector for Inspector { @@ -168,7 +176,11 @@ impl revm::Inspector for Inspector { } } -impl InspectorExt for Inspector {} +impl InspectorExt for Inspector { + fn is_alphanet(&self) -> bool { + self.alphanet + } +} /// Prints all the logs pub fn print_logs(logs: &[Log]) { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 9d21b9bf2a44e..5180e4a0484d1 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -174,6 +174,7 @@ pub struct Backend { active_snapshots: Arc>>, enable_steps_tracing: bool, print_logs: bool, + alphanet: bool, /// How to keep history state prune_state_history_config: PruneStateHistoryConfig, /// max number of blocks with transactions in memory @@ -198,6 +199,7 @@ impl Backend { fork: Arc>>, enable_steps_tracing: bool, print_logs: bool, + alphanet: bool, prune_state_history_config: PruneStateHistoryConfig, max_persisted_states: Option, transaction_block_keeper: Option, @@ -256,6 +258,7 @@ impl Backend { active_snapshots: Arc::new(Mutex::new(Default::default())), enable_steps_tracing, print_logs, + alphanet, prune_state_history_config, transaction_block_keeper, node_config, @@ -908,6 +911,7 @@ impl Backend { enable_steps_tracing: self.enable_steps_tracing, print_logs: self.print_logs, precompile_factory: self.precompile_factory.clone(), + alphanet: self.alphanet, }; // create a new pending block @@ -980,6 +984,7 @@ impl Backend { blob_gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, print_logs: self.print_logs, + alphanet: self.alphanet, precompile_factory: self.precompile_factory.clone(), }; let executed_tx = executor.execute(); @@ -1203,7 +1208,7 @@ impl Backend { /// Builds [`Inspector`] with the configured options fn build_inspector(&self) -> Inspector { - let mut inspector = Inspector::default(); + let mut inspector = Inspector::default().with_alphanet(self.alphanet); if self.print_logs { inspector = inspector.with_log_collector(); diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index e9db0084e2ecf..9a553e38507ca 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -10,7 +10,14 @@ use foundry_cli::{ }; use foundry_common::ens::NameOrAddress; use foundry_compilers::artifacts::EvmVersion; -use foundry_config::{find_project_root_path, Config}; +use foundry_config::{ + figment::{ + self, + value::{Dict, Map}, + Figment, Metadata, Profile, + }, + Config, +}; use foundry_evm::{executors::TracingExecutor, opts::EvmOpts}; use std::str::FromStr; @@ -66,6 +73,10 @@ pub struct CallArgs { #[arg(long, short, help_heading = "Display options")] json: bool, + /// Enable Alphanet features. + #[arg(long)] + pub alphanet: bool, + #[command(subcommand)] command: Option, @@ -102,6 +113,10 @@ pub enum CallSubcommands { impl CallArgs { pub async fn run(self) -> Result<()> { + let figment = Into::::into(&self.eth).merge(&self); + let evm_opts = figment.extract::()?; + let mut config = Config::try_from(figment)?.sanitized(); + let Self { to, mut sig, @@ -117,13 +132,13 @@ impl CallArgs { labels, data, json, + .. } = self; if let Some(data) = data { sig = Some(data); } - let mut config = Config::from(ð); let provider = utils::get_provider(&config)?; let sender = SenderKind::from_wallet_opts(eth.wallet).await?; let from = sender.address(); @@ -160,22 +175,20 @@ impl CallArgs { .await?; if trace { - let figment = - Config::figment_with_root(find_project_root_path(None).unwrap()).merge(eth.rpc); - let evm_opts = figment.extract::()?; if let Some(BlockId::Number(BlockNumberOrTag::Number(block_number))) = self.block { // Override Config `fork_block_number` (if set) with CLI value. config.fork_block_number = Some(block_number); } - let (mut env, fork, chain) = + let (mut env, fork, chain, alphanet) = TracingExecutor::get_fork_material(&config, evm_opts).await?; // modify settings that usually set in eth_call env.cfg.disable_block_gas_limit = true; env.block.gas_limit = U256::MAX; - let mut executor = TracingExecutor::new(env, fork, evm_version, debug, decode_internal); + let mut executor = + TracingExecutor::new(env, fork, evm_version, debug, decode_internal, alphanet); let value = tx.value.unwrap_or_default(); let input = tx.inner.input.into_input().unwrap_or_default(); @@ -202,6 +215,26 @@ impl CallArgs { } } +impl figment::Provider for CallArgs { + fn metadata(&self) -> Metadata { + Metadata::named("CallArgs") + } + + fn data(&self) -> Result, figment::Error> { + let mut map = Map::new(); + + if self.alphanet { + map.insert("alphanet".into(), self.alphanet.into()); + } + + if let Some(evm_version) = self.evm_version { + map.insert("evm_version".into(), figment::value::Value::serialize(evm_version)?); + } + + Ok(Map::from([(Config::selected_profile(), map)])) + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index b7f31cfc75141..7a5e7980ceeee 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -10,7 +10,14 @@ use foundry_cli::{ }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::artifacts::EvmVersion; -use foundry_config::{find_project_root_path, Config}; +use foundry_config::{ + figment::{ + self, + value::{Dict, Map}, + Figment, Metadata, Profile, + }, + Config, +}; use foundry_evm::{ executors::{EvmError, TracingExecutor}, opts::EvmOpts, @@ -75,6 +82,10 @@ pub struct RunArgs { /// See also, https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second #[arg(long, value_name = "NO_RATE_LIMITS", visible_alias = "no-rpc-rate-limit")] pub no_rate_limit: bool, + + /// Enables Alphanet features. + #[arg(long)] + pub alphanet: bool, } impl RunArgs { @@ -84,8 +95,7 @@ impl RunArgs { /// /// Note: This executes the transaction(s) as is: Cheatcodes are disabled pub async fn run(self) -> Result<()> { - let figment = - Config::figment_with_root(find_project_root_path(None).unwrap()).merge(self.rpc); + let figment = Into::::into(&self.rpc).merge(&self); let evm_opts = figment.extract::()?; let mut config = Config::try_from(figment)?.sanitized(); @@ -122,7 +132,8 @@ impl RunArgs { // we need to fork off the parent block config.fork_block_number = Some(tx_block_number - 1); - let (mut env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?; + let (mut env, fork, chain, alphanet) = + TracingExecutor::get_fork_material(&config, evm_opts).await?; let mut evm_version = self.evm_version; @@ -146,8 +157,14 @@ impl RunArgs { } } - let mut executor = - TracingExecutor::new(env.clone(), fork, evm_version, self.debug, self.decode_internal); + let mut executor = TracingExecutor::new( + env.clone(), + fork, + evm_version, + self.debug, + self.decode_internal, + alphanet, + ); let mut env = EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), executor.spec_id()); @@ -230,3 +247,23 @@ impl RunArgs { Ok(()) } } + +impl figment::Provider for RunArgs { + fn metadata(&self) -> Metadata { + Metadata::named("RunArgs") + } + + fn data(&self) -> Result, figment::Error> { + let mut map = Map::new(); + + if self.alphanet { + map.insert("alphanet".into(), self.alphanet.into()); + } + + if let Some(evm_version) = self.evm_version { + map.insert("evm_version".into(), figment::value::Value::serialize(evm_version)?); + } + + Ok(Map::from([(Config::selected_profile(), map)])) + } +} diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 98355c890da59..43f2d5c534772 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -144,6 +144,11 @@ pub struct EvmArgs { #[arg(long)] #[serde(skip)] pub isolate: bool, + + /// Whether to enable Alphanet features. + #[arg(long)] + #[serde(skip)] + pub alphanet: bool, } // Make this set of options a `figment::Provider` so that it can be merged into the `Config` @@ -170,6 +175,10 @@ impl Provider for EvmArgs { dict.insert("isolate".to_string(), self.isolate.into()); } + if self.alphanet { + dict.insert("alphanet".to_string(), self.alphanet.into()); + } + if self.always_use_create_2_factory { dict.insert( "always_use_create_2_factory".to_string(), diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 7033cc31a0dc9..ca7226e18da42 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -447,6 +447,9 @@ pub struct Config { #[serde(default, skip_serializing_if = "Option::is_none")] pub eof_version: Option, + /// Whether to enable Alphanet features. + pub alphanet: bool, + /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information #[serde(rename = "__warnings", default, skip_serializing)] pub warnings: Vec, @@ -910,7 +913,7 @@ impl Config { /// Returns the [SpecId] derived from the configured [EvmVersion] #[inline] pub fn evm_spec_id(&self) -> SpecId { - evm_spec_id(&self.evm_version) + evm_spec_id(&self.evm_version, self.alphanet) } /// Returns whether the compiler version should be auto-detected @@ -2139,6 +2142,7 @@ impl Default for Config { warnings: vec![], extra_args: vec![], eof_version: None, + alphanet: false, _non_exhaustive: (), } } diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index d8d23711c3bdd..dff36e4fda40c 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -296,7 +296,10 @@ impl FromStr for Numeric { /// Returns the [SpecId] derived from [EvmVersion] #[inline] -pub fn evm_spec_id(evm_version: &EvmVersion) -> SpecId { +pub fn evm_spec_id(evm_version: &EvmVersion, alphanet: bool) -> SpecId { + if alphanet { + return SpecId::PRAGUE_EOF; + } match evm_version { EvmVersion::Homestead => SpecId::HOMESTEAD, EvmVersion::TangerineWhistle => SpecId::TANGERINE, diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index ed10c5d751465..26b392c433f39 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -47,6 +47,10 @@ pub trait InspectorExt: Inspector { // Simulates `console.log` invocation. fn console_log(&mut self, _input: String) {} + + fn is_alphanet(&self) -> bool { + false + } } impl InspectorExt for NoOpInspector {} diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index d676c90b363ec..f9e674e09a26b 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -63,6 +63,9 @@ pub struct EvmOpts { /// Whether to disable block gas limit checks. pub disable_block_gas_limit: bool, + + /// whether to enable Alphanet features. + pub alphanet: bool, } impl EvmOpts { diff --git a/crates/evm/core/src/precompiles.rs b/crates/evm/core/src/precompiles.rs index 03ab18dffd964..2544258d34433 100644 --- a/crates/evm/core/src/precompiles.rs +++ b/crates/evm/core/src/precompiles.rs @@ -1,4 +1,8 @@ -use alloy_primitives::{address, Address}; +use alloy_primitives::{address, Address, Bytes, B256}; +use revm::{ + precompile::{secp256r1::p256_verify as revm_p256_verify, PrecompileWithAddress}, + primitives::{Precompile, PrecompileResult}, +}; /// The ECRecover precompile address. pub const EC_RECOVER: Address = address!("0000000000000000000000000000000000000001"); @@ -42,4 +46,28 @@ pub const PRECOMPILES: &[Address] = &[ EC_PAIRING, BLAKE_2F, POINT_EVALUATION, + ALPHANET_P256_ADDRESS, ]; + +/// [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212) secp256r1 precompile address on Alphanet. +/// +/// +pub const ALPHANET_P256_ADDRESS: Address = address!("0000000000000000000000000000000000000014"); + +/// Wrapper around revm P256 precompile, matching EIP-7212 spec. +/// +/// Per Optimism implementation, P256 precompile returns empty bytes on failure, but per EIP-7212 it +/// should be 32 bytes of zeros instead. +pub fn p256_verify(input: &Bytes, gas_limit: u64) -> PrecompileResult { + revm_p256_verify(input, gas_limit).map(|mut result| { + if result.bytes.is_empty() { + result.bytes = B256::default().into(); + } + + result + }) +} + +/// [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212#specification) secp256r1 precompile. +pub const ALPHANET_P256: PrecompileWithAddress = + PrecompileWithAddress(ALPHANET_P256_ADDRESS, Precompile::Standard(p256_verify)); diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 8860b1683a4c6..21284e78035b4 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,5 +1,5 @@ pub use crate::ic::*; -use crate::{constants::DEFAULT_CREATE2_DEPLOYER, InspectorExt}; +use crate::{constants::DEFAULT_CREATE2_DEPLOYER, precompiles::ALPHANET_P256, InspectorExt}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Selector, TxKind, U256}; use alloy_rpc_types::{Block, Transaction}; @@ -207,6 +207,20 @@ pub fn create2_handler_register>( }); } +/// Adds Alphanet P256 precompile to the list of loaded precompiles. +pub fn alphanet_handler_register>( + handler: &mut EvmHandler<'_, I, DB>, +) { + let prev = handler.pre_execution.load_precompiles.clone(); + handler.pre_execution.load_precompiles = Arc::new(move || { + let mut loaded_precompiles = prev(); + + loaded_precompiles.extend([ALPHANET_P256]); + + loaded_precompiles + }); +} + /// Creates a new EVM with the given inspector. pub fn new_evm_with_inspector<'a, DB, I>( db: DB, @@ -232,10 +246,15 @@ where .build() */ - let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); let mut handler = revm::Handler::new(handler_cfg); handler.append_handler_register_plain(revm::inspector_handle_register); + if inspector.is_alphanet() { + handler.append_handler_register_plain(alphanet_handler_register); + } handler.append_handler_register_plain(create2_handler_register); + + let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); + revm::Evm::new(context, handler) } @@ -261,11 +280,16 @@ where I: InspectorExt, { let handler_cfg = HandlerCfg::new(inner.spec_id()); - let context = - revm::Context::new(revm::EvmContext { inner, precompiles: Default::default() }, inspector); + let mut handler = revm::Handler::new(handler_cfg); handler.append_handler_register_plain(revm::inspector_handle_register); + if inspector.is_alphanet() { + handler.append_handler_register_plain(alphanet_handler_register); + } handler.append_handler_register_plain(create2_handler_register); + + let context = + revm::Context::new(revm::EvmContext { inner, precompiles: Default::default() }, inspector); revm::Evm::new(context, handler) } diff --git a/crates/evm/evm/src/executors/trace.rs b/crates/evm/evm/src/executors/trace.rs index cc3e687766f8f..69c68442b65cd 100644 --- a/crates/evm/evm/src/executors/trace.rs +++ b/crates/evm/evm/src/executors/trace.rs @@ -18,6 +18,7 @@ impl TracingExecutor { version: Option, debug: bool, decode_internal: bool, + alphanet: bool, ) -> Self { let db = Backend::spawn(fork); let trace_mode = @@ -30,8 +31,8 @@ impl TracingExecutor { // configures a bare version of the evm executor: no cheatcode inspector is enabled, // tracing will be enabled only for the targeted transaction executor: ExecutorBuilder::new() - .inspectors(|stack| stack.trace_mode(trace_mode)) - .spec(evm_spec_id(&version.unwrap_or_default())) + .inspectors(|stack| stack.trace_mode(trace_mode).alphanet(alphanet)) + .spec(evm_spec_id(&version.unwrap_or_default(), alphanet)) .build(env, db), } } @@ -45,7 +46,7 @@ impl TracingExecutor { pub async fn get_fork_material( config: &Config, mut evm_opts: EvmOpts, - ) -> eyre::Result<(Env, Option, Option)> { + ) -> eyre::Result<(Env, Option, Option, bool)> { evm_opts.fork_url = Some(config.get_rpc_url_or_localhost_http()?.into_owned()); evm_opts.fork_block_number = config.fork_block_number; @@ -53,7 +54,7 @@ impl TracingExecutor { let fork = evm_opts.get_fork(config, env.clone()); - Ok((env, fork, evm_opts.get_remote_chain_id().await)) + Ok((env, fork, evm_opts.get_remote_chain_id().await, evm_opts.alphanet)) } } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index a6f2f3a1f55d4..7199983658744 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -58,6 +58,8 @@ pub struct InspectorStackBuilder { /// In isolation mode all top-level calls are executed as a separate transaction in a separate /// EVM context, enabling more precise gas accounting and transaction state changes. pub enable_isolation: bool, + /// Whether to enable Alphanet features. + pub alphanet: bool, } impl InspectorStackBuilder { @@ -140,6 +142,14 @@ impl InspectorStackBuilder { self } + /// Set whether to enable Alphanet features. + /// For description of call isolation, see [`InspectorStack::enable_isolation`]. + #[inline] + pub fn alphanet(mut self, yes: bool) -> Self { + self.alphanet = yes; + self + } + /// Builds the stack of inspectors to use when transacting/committing on the EVM. pub fn build(self) -> InspectorStack { let Self { @@ -153,6 +163,7 @@ impl InspectorStackBuilder { print, chisel_state, enable_isolation, + alphanet, } = self; let mut stack = InspectorStack::new(); @@ -172,6 +183,7 @@ impl InspectorStackBuilder { stack.tracing(trace_mode); stack.enable_isolation(enable_isolation); + stack.alphanet(alphanet); // environment, must come after all of the inspectors if let Some(block) = block { @@ -284,6 +296,7 @@ pub struct InspectorStackInner { pub printer: Option, pub tracer: Option, pub enable_isolation: bool, + pub alphanet: bool, /// Flag marking if we are in the inner EVM context. pub in_inner_context: bool, @@ -392,6 +405,12 @@ impl InspectorStack { self.enable_isolation = yes; } + /// Set whether to enable call isolation. + #[inline] + pub fn alphanet(&mut self, yes: bool) { + self.alphanet = yes; + } + /// Set whether to enable the log collector. #[inline] pub fn collect_logs(&mut self, yes: bool) { @@ -914,6 +933,10 @@ impl<'a, DB: DatabaseExt> InspectorExt for InspectorStackRefMut<'a> { inspector, input )); } + + fn is_alphanet(&self) -> bool { + self.inner.alphanet + } } impl Inspector for InspectorStack { @@ -999,6 +1022,10 @@ impl InspectorExt for InspectorStack { ) -> bool { self.as_mut().should_use_create2_factory(ecx, inputs) } + + fn is_alphanet(&self) -> bool { + self.alphanet + } } impl<'a> Deref for InspectorStackRefMut<'a> { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 248d676db8de5..ab868f5bc9d06 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -336,6 +336,7 @@ impl TestArgs { .with_fork(evm_opts.get_fork(&config, env.clone())) .with_test_options(test_options) .enable_isolation(evm_opts.isolate) + .alphanet(evm_opts.alphanet) .build(project_root, &output, env, evm_opts)?; let mut maybe_override_mt = |flag, maybe_regex: Option<&Regex>| { diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 9ac3069a61d5f..4df00f7944eee 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -72,6 +72,8 @@ pub struct MultiContractRunner { pub test_options: TestOptions, /// Whether to enable call isolation pub isolation: bool, + /// Whether to enable Alphanet features. + pub alphanet: bool, /// Known contracts linked with computed library addresses. pub known_contracts: ContractsByArtifact, /// Libraries to deploy. @@ -256,6 +258,7 @@ impl MultiContractRunner { .trace_mode(trace_mode) .coverage(self.coverage) .enable_isolation(self.isolation) + .alphanet(self.alphanet) }) .spec(self.evm_spec) .gas_limit(self.evm_opts.gas_limit()) @@ -315,6 +318,8 @@ pub struct MultiContractRunnerBuilder { pub decode_internal: InternalTraceMode, /// Whether to enable call isolation pub isolation: bool, + /// Whether to enable Alphanet features. + pub alphanet: bool, /// Settings related to fuzz and/or invariant tests pub test_options: Option, } @@ -332,6 +337,7 @@ impl MultiContractRunnerBuilder { isolation: Default::default(), test_options: Default::default(), decode_internal: Default::default(), + alphanet: Default::default(), } } @@ -380,6 +386,11 @@ impl MultiContractRunnerBuilder { self } + pub fn alphanet(mut self, enable: bool) -> Self { + self.alphanet = enable; + self + } + /// Given an EVM, proceeds to return a runner which is able to execute all tests /// against that evm pub fn build( @@ -448,6 +459,7 @@ impl MultiContractRunnerBuilder { decode_internal: self.decode_internal, test_options: self.test_options.unwrap_or_default(), isolation: self.isolation, + alphanet: self.alphanet, known_contracts, libs_to_deploy, libraries, diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index fcec5f15a84a7..0e38e15e7d87b 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -148,6 +148,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { legacy_assertions: false, extra_args: vec![], eof_version: None, + alphanet: false, _non_exhaustive: (), }; prj.write_config(input.clone()); diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index e2f86ce3bcbac..1b2618f91e875 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -580,7 +580,9 @@ impl ScriptConfig { // We need to enable tracing to decode contract names: local or external. let mut builder = ExecutorBuilder::new() .inspectors(|stack| { - stack.trace_mode(if debug { TraceMode::Debug } else { TraceMode::Call }) + stack + .trace_mode(if debug { TraceMode::Debug } else { TraceMode::Call }) + .alphanet(self.evm_opts.alphanet) }) .spec(self.config.evm_spec_id()) .gas_limit(self.evm_opts.gas_limit()) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index aa3ffbe0ed56d..11da12c43173d 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -322,11 +322,17 @@ impl VerifyBytecodeArgs { fork_config.fork_block_number = Some(simulation_block - 1); fork_config.evm_version = etherscan_metadata.evm_version()?.unwrap_or(EvmVersion::default()); - let (mut env, fork, _chain) = + let (mut env, fork, _chain, alphanet) = TracingExecutor::get_fork_material(&fork_config, evm_opts).await?; - let mut executor = - TracingExecutor::new(env.clone(), fork, Some(fork_config.evm_version), false, false); + let mut executor = TracingExecutor::new( + env.clone(), + fork, + Some(fork_config.evm_version), + false, + false, + alphanet, + ); env.block.number = U256::from(simulation_block); let block = provider.get_block(simulation_block.into(), true.into()).await?; From 0bb5864d86096410a0d2c4d511f825caebb8c480 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 18 Aug 2024 00:53:01 +0800 Subject: [PATCH 1361/1963] fix: update formatting for fixed bytes (#8687) * fix: update formatting for fixed bytes * fix: update formatting for fixed bytes --- Cargo.lock | 5 ----- Cargo.toml | 2 -- crates/common/fmt/src/dynamic.rs | 4 +++- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b81c6670f87cc..495ede8255078 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9813,8 +9813,3 @@ dependencies = [ "cc", "pkg-config", ] - -[[patch.unused]] -name = "alloy-node-bindings" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" diff --git a/Cargo.toml b/Cargo.toml index e78d0049231fa..238bc38bd9683 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,7 +178,6 @@ alloy-eips = { version = "0.2.1", default-features = false } alloy-genesis = { version = "0.2.1", default-features = false } alloy-json-rpc = { version = "0.2.1", default-features = false } alloy-network = { version = "0.2.1", default-features = false } -alloy-node-bindings = { version = "0.2.1", default-features = false } alloy-provider = { version = "0.2.1", default-features = false } alloy-pubsub = { version = "0.2.1", default-features = false } alloy-rpc-client = { version = "0.2.1", default-features = false } @@ -272,7 +271,6 @@ alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } diff --git a/crates/common/fmt/src/dynamic.rs b/crates/common/fmt/src/dynamic.rs index 4c59989e9702b..e13d6ab96d89d 100644 --- a/crates/common/fmt/src/dynamic.rs +++ b/crates/common/fmt/src/dynamic.rs @@ -15,7 +15,9 @@ impl DynValueFormatter { DynSolValue::Address(inner) => write!(f, "{inner}"), DynSolValue::Function(inner) => write!(f, "{inner}"), DynSolValue::Bytes(inner) => f.write_str(&hex::encode_prefixed(inner)), - DynSolValue::FixedBytes(inner, _) => write!(f, "{inner}"), + DynSolValue::FixedBytes(word, size) => { + f.write_str(&hex::encode_prefixed(&word[..*size])) + } DynSolValue::Uint(inner, _) => { if self.raw { write!(f, "{inner}") From 8549aadc66bac1b480a303e7dc3fb9309dffb325 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 00:50:13 +0000 Subject: [PATCH 1362/1963] chore(deps): weekly `cargo update` (#8690) --- Cargo.lock | 192 ++++++++++++++++++++++++++--------------------------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 495ede8255078..207ee83d34c3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -316,7 +316,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -551,7 +551,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -568,7 +568,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", "syn-solidity", "tiny-keccak", ] @@ -586,7 +586,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.74", + "syn 2.0.75", "syn-solidity", ] @@ -1051,9 +1051,9 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "ascii-canvas" @@ -1094,7 +1094,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1116,7 +1116,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1127,7 +1127,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1180,7 +1180,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1257,9 +1257,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.38.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d073fcc95d01301c115011f8f23bc436d66f01b8265d149e994a2d8318c903c" +checksum = "70ebbbc319551583b9233a74b359ede7349102e779fc12371d2478e80b50d218" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1279,9 +1279,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.37.0" +version = "1.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1074e818fbe4f9169242d78448b15be8916a79daa38ea1231f2e2e10d993fcd2" +checksum = "11822090cf501c316c6f75711d77b96fba30658e3867a7762e5e2f5d32d31e81" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1301,9 +1301,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.38.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29755c51e33fa3f678598f64324a169cf4b7d3c4865d2709d4308f53366a92a4" +checksum = "78a2a06ff89176123945d1bbe865603c4d7101bea216a550bb4d2e4e9ba74d74" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1323,9 +1323,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.37.0" +version = "1.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e52dc3fd7dfa6c01a69cf3903e00aa467261639138a05b06cd92314d2c8fb07" +checksum = "a20a91795850826a6f456f4a48eff1dfa59a0e69bdbf5b8c50518fd372106574" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1419,9 +1419,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.6.2" +version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce87155eba55e11768b8c1afa607f3e864ae82f03caf63258b37455b0ad02537" +checksum = "0abbf454960d0db2ad12684a1640120e7557294b0ff8e2f11236290a1b293225" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1463,9 +1463,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe321a6b21f5d8eabd0ade9c55d3d0335f3c3157fc2b3e87f05f34b539e4df5" +checksum = "6cee7cadb433c781d3299b916fbf620fea813bf38f49db282fb6858141a05cc8" dependencies = [ "base64-simd", "bytes", @@ -1745,9 +1745,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.16.3" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" +checksum = "6fd4c6dcc3b0aea2f5c0b4b82c2b15fe39ddbc76041a310848f4706edf76bb31" [[package]] name = "byteorder" @@ -1811,9 +1811,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +checksum = "3054fea8a20d8ff3968d5b22cc27501d2b08dc4decdb31b184323f00c5ef23bb" dependencies = [ "serde", ] @@ -1923,9 +1923,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.11" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb8dd288a69fc53a1996d7ecfbf4a20d59065bff137ce7e56bbd620de191189" +checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" dependencies = [ "jobserver", "libc", @@ -2041,9 +2041,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.15" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", "clap_derive", @@ -2066,9 +2066,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.16" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c677cd0126f3026d8b093fa29eae5d812fde5c05bc66dbb29d0374eea95113a" +checksum = "1ee158892bd7ce77aa15c208abbdb73e155d191c287a659b57abd5adb92feb03" dependencies = [ "clap", ] @@ -2092,7 +2092,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2519,7 +2519,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2530,7 +2530,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2603,7 +2603,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2624,7 +2624,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2634,7 +2634,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2647,7 +2647,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2667,7 +2667,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2774,7 +2774,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2901,7 +2901,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3051,7 +3051,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.74", + "syn 2.0.75", "toml 0.8.19", "walkdir", ] @@ -3079,7 +3079,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.74", + "syn 2.0.75", "tempfile", "thiserror", "tiny-keccak", @@ -3457,7 +3457,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4030,7 +4030,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4190,7 +4190,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4706,7 +4706,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -5356,9 +5356,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a" [[package]] name = "libdbus-sys" @@ -5572,7 +5572,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -5654,7 +5654,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -5904,7 +5904,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -6016,7 +6016,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -6202,7 +6202,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -6261,7 +6261,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -6345,7 +6345,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -6403,7 +6403,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -6522,7 +6522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -6598,7 +6598,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", "version_check", "yansi", ] @@ -6685,7 +6685,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -7466,9 +7466,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.14" +version = "2.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79da19444d9da7a9a82b80ecf059eceba6d3129d84a8610fd25ff2364f255466" +checksum = "aeb7ac86243095b70a7920639507b71d51a63390d1ba26c4f60a552fbb914a37" dependencies = [ "sdd", ] @@ -7503,7 +7503,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -7650,22 +7650,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.207" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.207" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -7676,14 +7676,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] name = "serde_json" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ "indexmap 2.4.0", "itoa", @@ -7720,7 +7720,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -7779,7 +7779,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -7974,9 +7974,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snapbox" -version = "0.6.16" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "027c936207f85d10d015e21faf5c676c7e08c453ed371adf55c0874c443ca77a" +checksum = "840b73eb3148bc3cbc10ebe00ec9bc6d96033e658d022c4adcbf3f35596fd64a" dependencies = [ "anstream", "anstyle", @@ -8073,7 +8073,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -8139,7 +8139,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -8207,9 +8207,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.74" +version = "2.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" dependencies = [ "proc-macro2", "quote", @@ -8225,7 +8225,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -8327,7 +8327,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -8438,9 +8438,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" dependencies = [ "backtrace", "bytes", @@ -8462,7 +8462,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -8732,7 +8732,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -9132,7 +9132,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", "wasm-bindgen-shared", ] @@ -9166,7 +9166,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9274,9 +9274,9 @@ dependencies = [ [[package]] name = "which" -version = "6.0.2" +version = "6.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d9c5ed668ee1f17edb3b627225343d210006a90bb1e3745ce1f30b1fb115075" +checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" dependencies = [ "either", "home", @@ -9383,7 +9383,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -9394,7 +9394,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -9405,7 +9405,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -9416,7 +9416,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -9701,7 +9701,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -9721,7 +9721,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] From c0a27282604ea5de1ff3d4ce415fe628ccb1ea51 Mon Sep 17 00:00:00 2001 From: greged93 <82421016+greged93@users.noreply.github.com> Date: Mon, 19 Aug 2024 10:51:40 -0700 Subject: [PATCH 1363/1963] fix(anvil): storage diff (#8691) fix the inspector for steps tracing --- crates/anvil/src/eth/backend/executor.rs | 2 +- crates/anvil/src/eth/backend/mem/inspector.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index b46f29c38a979..c84ad52007c24 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -81,7 +81,7 @@ impl ExecutedTransaction { pub struct ExecutedTransactions { /// The block created after executing the `included` transactions pub block: BlockInfo, - /// All transactions included in the + /// All transactions included in the block pub included: Vec>, /// All transactions that were invalid at the point of their execution and were not included in /// the block diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index 56e53acc3452b..b354a9a5c1236 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -50,7 +50,7 @@ impl Inspector { /// Enables steps recording for `Tracer`. pub fn with_steps_tracing(mut self) -> Self { - self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all())); + self.tracer = Some(TracingInspector::new(TracingInspectorConfig::all().with_state_diffs())); self } From 1710187c614f01598116e67aaf4cda76e7b532ec Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Tue, 20 Aug 2024 04:15:46 +0800 Subject: [PATCH 1364/1963] fix comment of `--sender` (#8692) mod comment of --sender --- crates/common/src/evm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 43f2d5c534772..d7f026552510e 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -85,7 +85,7 @@ pub struct EvmArgs { #[serde(skip_serializing_if = "Option::is_none")] pub initial_balance: Option, - /// The address which will be executing tests. + /// The address which will be executing tests/scripts. #[arg(long, value_name = "ADDRESS")] #[serde(skip_serializing_if = "Option::is_none")] pub sender: Option
, From afd86803fc89a95e05427f82b9fbeae0a7c7b049 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 21 Aug 2024 02:41:07 +0800 Subject: [PATCH 1365/1963] fix: console.log formatting (#8702) * fix: console.log formatting * no deref * clippy --- crates/common/fmt/src/console.rs | 110 ++++++++++++++++--------------- 1 file changed, 58 insertions(+), 52 deletions(-) diff --git a/crates/common/fmt/src/console.rs b/crates/common/fmt/src/console.rs index 45f12ffbfa107..7473ccdec76c7 100644 --- a/crates/common/fmt/src/console.rs +++ b/crates/common/fmt/src/console.rs @@ -21,17 +21,17 @@ pub enum FormatSpec { } impl FormatSpec { - fn from_chars(iter: &mut Peekable) -> Option + fn from_chars(iter: &mut Peekable) -> Result where I: Iterator, { - match iter.next()? { - 's' => Some(Self::String), - 'd' => Some(Self::Number), - 'i' => Some(Self::Integer), - 'o' => Some(Self::Object), - 'e' => Some(Self::Exponential(None)), - 'x' => Some(Self::Hexadecimal), + match iter.next().ok_or_else(String::new)? { + 's' => Ok(Self::String), + 'd' => Ok(Self::Number), + 'i' => Ok(Self::Integer), + 'o' => Ok(Self::Object), + 'e' => Ok(Self::Exponential(None)), + 'x' => Ok(Self::Hexadecimal), ch if ch.is_ascii_digit() => { let mut num = ch.to_string(); while let Some(&ch) = iter.peek() { @@ -44,16 +44,17 @@ impl FormatSpec { } if let Some(&ch) = iter.peek() { if ch == 'e' { + let num = num.parse().map_err(|_| num)?; iter.next(); - Some(Self::Exponential(Some(num.parse().ok()?))) + Ok(Self::Exponential(Some(num))) } else { - None + Err(num) } } else { - None + Err(num) } } - _ => None, + ch => Err(String::from(ch)), } } } @@ -248,29 +249,25 @@ impl ConsoleFmt for [u8] { /// assert_eq!(formatted, "foo has 3 characters"); /// ``` pub fn console_format(spec: &str, values: &[&dyn ConsoleFmt]) -> String { - let mut values = values.iter().copied(); + let mut values = values.iter().copied().peekable(); let mut result = String::with_capacity(spec.len()); // for the first space - let mut write_space = true; - let last_value = if spec.is_empty() { - // we still want to print any remaining values - write_space = false; - values.next() + let mut write_space = if spec.is_empty() { + false } else { - format_spec(spec, &mut values, &mut result) + format_spec(spec, &mut values, &mut result); + true }; // append any remaining values with the standard format - if let Some(v) = last_value { - for v in std::iter::once(v).chain(values) { - let fmt = v.fmt(FormatSpec::String); - if write_space { - result.push(' '); - } - result.push_str(&fmt); - write_space = true; + for v in values { + let fmt = v.fmt(FormatSpec::String); + if write_space { + result.push(' '); } + result.push_str(&fmt); + write_space = true; } result @@ -278,46 +275,48 @@ pub fn console_format(spec: &str, values: &[&dyn ConsoleFmt]) -> String { fn format_spec<'a>( s: &str, - values: &mut impl Iterator, + values: &mut Peekable>, result: &mut String, -) -> Option<&'a dyn ConsoleFmt> { +) { let mut expect_fmt = false; - let mut current_value = values.next(); let mut chars = s.chars().peekable(); - while let Some(ch) = chars.next() { + while chars.peek().is_some() { if expect_fmt { expect_fmt = false; - let mut iter = std::iter::once(ch).chain(chars.by_ref()).peekable(); - if let Some(spec) = FormatSpec::from_chars(&mut iter) { - // format and write the value - if let Some(value) = current_value { - let string = value.fmt(spec); - result.push_str(&string); - current_value = values.next(); + match FormatSpec::from_chars(&mut chars) { + Ok(spec) => { + let value = values.next().expect("value existence is checked"); + // format and write the value + result.push_str(&value.fmt(spec)); } - } else { - // invalid specifier or a second `%`, in both cases we ignore - result.push('%'); - result.push(ch); - } - } else if ch == '%' { - if let Some(&next_ch) = chars.peek() { - if next_ch == '%' { + Err(consumed) => { + // on parser failure, write '%' and consumed characters result.push('%'); - chars.next(); + result.push_str(&consumed); + } + } + } else { + let ch = chars.next().unwrap(); + if ch == '%' { + if let Some(&next_ch) = chars.peek() { + if next_ch == '%' { + result.push('%'); + chars.next(); + } else if values.peek().is_some() { + // only try formatting if there are values to format + expect_fmt = true; + } else { + result.push(ch); + } } else { - expect_fmt = true; + result.push(ch); } } else { result.push(ch); } - } else { - result.push(ch); } } - - current_value } #[cfg(test)] @@ -468,6 +467,13 @@ mod tests { fmt_1("%x", &I256::try_from(-100000000000i64).unwrap()) ); assert_eq!("100", fmt_1("%o", &I256::try_from(100).unwrap())); + + // make sure that %byte values are not consumed when there are no values + assert_eq!("%333d%3e%5F", console_format("%333d%3e%5F", &[])); + assert_eq!( + "%5d123456.789%2f%3f%e1", + console_format("%5d%3e%2f%3f%e1", &[&U256::from(123456789)]) + ); } #[test] From f808d08a76672b3e26bc41bd3d9666ca01f52a53 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:33:21 +0300 Subject: [PATCH 1366/1963] fix(coverage): ensure contract hash to record coverage for is not zero (#8698) --- crates/evm/coverage/src/inspector.rs | 20 ++++++++--- crates/forge/tests/cli/coverage.rs | 50 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index 4e25ddb51a041..73d2ff148fa9c 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -1,4 +1,5 @@ use crate::{HitMap, HitMaps}; +use alloy_primitives::B256; use revm::{interpreter::Interpreter, Database, EvmContext, Inspector}; #[derive(Clone, Debug, Default)] @@ -10,15 +11,26 @@ pub struct CoverageCollector { impl Inspector for CoverageCollector { #[inline] fn initialize_interp(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { - let hash = interp.contract.hash.expect("Contract hash is None"); self.maps - .entry(hash) + .entry(get_contract_hash(interp)) .or_insert_with(|| HitMap::new(interp.contract.bytecode.original_bytes())); } #[inline] fn step(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { - let hash = interp.contract.hash.expect("Contract hash is None"); - self.maps.entry(hash).and_modify(|map| map.hit(interp.program_counter())); + self.maps + .entry(get_contract_hash(interp)) + .and_modify(|map| map.hit(interp.program_counter())); + } +} + +/// Helper function for extracting contract hash used to record coverage hit map. +/// If contract hash available in interpreter contract is zero (contract not yet created but going +/// to be created in current tx) then it hash is calculated from contract bytecode. +fn get_contract_hash(interp: &mut Interpreter) -> B256 { + let mut hash = interp.contract.hash.expect("Contract hash is None"); + if hash == B256::ZERO { + hash = interp.contract.bytecode.hash_slow(); } + hash } diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 1b668afacd531..381a31c12c210 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1271,3 +1271,53 @@ contract AContractTest is DSTest { "#]]); }); + +forgetest!(test_constructors_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + bool public active; + + constructor() { + active = true; + } +} + +contract BContract { + bool public active; + + constructor() { + active = true; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import "./AContract.sol"; + +contract AContractTest is DSTest { + function test_constructors() public { + AContract a = new AContract(); + BContract b = new BContract(); + } +} + "#, + ) + .unwrap(); + + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | + +"#]]); +}); From facd7f98378556653f16bc229f531dd80a548f9b Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 21 Aug 2024 02:00:55 -0700 Subject: [PATCH 1367/1963] feat(`forge verify-bytecode`): support alternative block explorers + predeploys (#8510) --- crates/forge/bin/cmd/create.rs | 2 +- crates/forge/bin/main.rs | 2 +- crates/forge/bin/opts.rs | 10 +- crates/forge/tests/cli/verify_bytecode.rs | 239 ++++++- crates/verify/src/bytecode.rs | 825 +++++++++------------- crates/verify/src/etherscan/mod.rs | 42 +- crates/verify/src/lib.rs | 388 +--------- crates/verify/src/provider.rs | 9 +- crates/verify/src/sourcify.rs | 8 +- crates/verify/src/types.rs | 44 ++ crates/verify/src/utils.rs | 423 +++++++++++ crates/verify/src/verify.rs | 367 ++++++++++ 12 files changed, 1434 insertions(+), 925 deletions(-) create mode 100644 crates/verify/src/types.rs create mode 100644 crates/verify/src/utils.rs create mode 100644 crates/verify/src/verify.rs diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index eb30edd29d73f..b549b39a0bfd9 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -202,7 +202,7 @@ impl CreateArgs { let context = verify.resolve_context().await?; - verify.verification_provider()?.preflight_check(verify, context).await?; + verify.verification_provider()?.preflight_verify_check(verify, context).await?; Ok(()) } diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index dc4a18dd6840a..81ee0b86775c6 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -55,6 +55,7 @@ fn main() -> Result<()> { ForgeSubcommand::Debug(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::VerifyContract(args) => utils::block_on(args.run()), ForgeSubcommand::VerifyCheck(args) => utils::block_on(args.run()), + ForgeSubcommand::VerifyBytecode(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Clone(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Cache(cmd) => match cmd.sub { CacheSubcommands::Clean(cmd) => cmd.run(), @@ -117,7 +118,6 @@ fn main() -> Result<()> { ForgeSubcommand::Generate(cmd) => match cmd.sub { GenerateSubcommands::Test(cmd) => cmd.run(), }, - ForgeSubcommand::VerifyBytecode(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Soldeer(cmd) => cmd.run(), ForgeSubcommand::Eip712(cmd) => cmd.run(), ForgeSubcommand::BindJson(cmd) => cmd.run(), diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index b86d19c17728d..fbe1f67df88ad 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -6,7 +6,7 @@ use crate::cmd::{ }; use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; -use forge_verify::{bytecode::VerifyBytecodeArgs, VerifyArgs, VerifyCheckArgs}; +use forge_verify::{VerifyArgs, VerifyBytecodeArgs, VerifyCheckArgs}; use std::path::PathBuf; const VERSION_MESSAGE: &str = concat!( @@ -87,6 +87,10 @@ pub enum ForgeSubcommand { #[command(visible_alias = "vc")] VerifyCheck(VerifyCheckArgs), + /// Verify the deployed bytecode against its source on Etherscan. + #[clap(visible_alias = "vb")] + VerifyBytecode(VerifyBytecodeArgs), + /// Deploy a smart contract. #[command(visible_alias = "c")] Create(CreateArgs), @@ -158,10 +162,6 @@ pub enum ForgeSubcommand { /// Generate scaffold files. Generate(generate::GenerateArgs), - /// Verify the deployed bytecode against its source. - #[clap(visible_alias = "vb")] - VerifyBytecode(VerifyBytecodeArgs), - /// Soldeer dependency manager. Soldeer(soldeer::SoldeerArgs), diff --git a/crates/forge/tests/cli/verify_bytecode.rs b/crates/forge/tests/cli/verify_bytecode.rs index 846fcc47d80cf..2b28570e75b33 100644 --- a/crates/forge/tests/cli/verify_bytecode.rs +++ b/crates/forge/tests/cli/verify_bytecode.rs @@ -7,12 +7,16 @@ use foundry_test_utils::{ TestCommand, TestProject, }; +#[allow(clippy::too_many_arguments)] fn test_verify_bytecode( prj: TestProject, mut cmd: TestCommand, addr: &str, contract_name: &str, + constructor_args: Option>, config: Config, + verifier: &str, + verifier_url: &str, expected_matches: (&str, &str), ) { let etherscan_key = next_etherscan_api_key(); @@ -29,6 +33,68 @@ fn test_verify_bytecode( prj.add_source(contract_name, &source_code).unwrap(); prj.write_config(config); + let mut args = vec![ + "verify-bytecode", + addr, + contract_name, + "--etherscan-api-key", + ðerscan_key, + "--verifier", + verifier, + "--verifier-url", + verifier_url, + "--rpc-url", + &rpc_url, + ]; + + if let Some(constructor_args) = constructor_args { + args.push("--constructor-args"); + args.extend(constructor_args.iter()); + } + + let output = cmd.forge_fuse().args(args).assert_success().get_output().stdout_lossy(); + + assert!(output + .contains(format!("Creation code matched with status {}", expected_matches.0).as_str())); + assert!(output + .contains(format!("Runtime code matched with status {}", expected_matches.1).as_str())); +} + +#[allow(clippy::too_many_arguments)] +fn test_verify_bytecode_with_ignore( + prj: TestProject, + mut cmd: TestCommand, + addr: &str, + contract_name: &str, + config: Config, + verifier: &str, + verifier_url: &str, + expected_matches: (&str, &str), + ignore: &str, + chain: &str, +) { + let etherscan_key = next_etherscan_api_key(); + let rpc_url = next_http_archive_rpc_endpoint(); + + // fetch and flatten source code + let source_code = cmd + .cast_fuse() + .args([ + "etherscan-source", + addr, + "--flatten", + "--etherscan-api-key", + ðerscan_key, + "--chain", + chain, + ]) + .assert_success() + .get_output() + .stdout_lossy(); + + prj.add_source(contract_name, &source_code).unwrap(); + prj.write_config(config); + let output = cmd .forge_fuse() .args([ @@ -37,25 +103,44 @@ fn test_verify_bytecode( contract_name, "--etherscan-api-key", ðerscan_key, + "--verifier", + verifier, + "--verifier-url", + verifier_url, "--rpc-url", &rpc_url, + "--ignore", + ignore, ]) .assert_success() .get_output() .stdout_lossy(); - assert!(output - .contains(format!("Creation code matched with status {}", expected_matches.0).as_str())); - assert!(output - .contains(format!("Runtime code matched with status {}", expected_matches.1).as_str())); -} + if ignore == "creation" { + assert!(!output.contains( + format!("Creation code matched with status {}", expected_matches.0).as_str() + )); + } else { + assert!(output.contains( + format!("Creation code matched with status {}", expected_matches.0).as_str() + )); + } + if ignore == "runtime" { + assert!(!output + .contains(format!("Runtime code matched with status {}", expected_matches.1).as_str())); + } else { + assert!(output + .contains(format!("Runtime code matched with status {}", expected_matches.1).as_str())); + } +} forgetest_async!(can_verify_bytecode_no_metadata, |prj, cmd| { test_verify_bytecode( prj, cmd, "0xba2492e52F45651B60B8B38d4Ea5E2390C64Ffb1", "SystemConfig", + None, Config { evm_version: EvmVersion::London, optimizer_runs: 999999, @@ -64,7 +149,9 @@ forgetest_async!(can_verify_bytecode_no_metadata, |prj, cmd| { bytecode_hash: BytecodeHash::None, ..Default::default() }, - ("full", "full"), + "etherscan", + "https://api.etherscan.io/api", + ("partial", "partial"), ); }); @@ -74,12 +161,152 @@ forgetest_async!(can_verify_bytecode_with_metadata, |prj, cmd| { cmd, "0xb8901acb165ed027e32754e0ffe830802919727f", "L1_ETH_Bridge", + None, Config { evm_version: EvmVersion::Paris, optimizer_runs: 50000, optimizer: true, ..Default::default() }, + "etherscan", + "https://api.etherscan.io/api", + ("partial", "partial"), + ); +}); + +// Test non-CREATE2 deployed contract with blockscout +forgetest_async!(can_verify_bytecode_with_blockscout, |prj, cmd| { + test_verify_bytecode( + prj, + cmd, + "0x70f44C13944d49a236E3cD7a94f48f5daB6C619b", + "StrategyManager", + None, + Config { + evm_version: EvmVersion::London, + optimizer: true, + optimizer_runs: 200, + ..Default::default() + }, + "blockscout", + "https://eth.blockscout.com/api", ("partial", "partial"), ); }); + +// Test CREATE2 deployed contract with blockscout +forgetest_async!(can_vb_create2_with_blockscout, |prj, cmd| { + test_verify_bytecode( + prj, + cmd, + "0xba2492e52F45651B60B8B38d4Ea5E2390C64Ffb1", + "SystemConfig", + None, + Config { + evm_version: EvmVersion::London, + optimizer_runs: 999999, + optimizer: true, + cbor_metadata: false, + bytecode_hash: BytecodeHash::None, + ..Default::default() + }, + "blockscout", + "https://eth.blockscout.com/api", + ("partial", "partial"), + ); +}); + +// Test `--constructor-args` +forgetest_async!(can_verify_bytecode_with_constructor_args, |prj, cmd| { + let constructor_args = vec![ + "0x39053D51B77DC0d36036Fc1fCc8Cb819df8Ef37A", + "0x91E677b07F7AF907ec9a428aafA9fc14a0d3A338", + "0xD92145c07f8Ed1D392c1B88017934E301CC1c3Cd", + ]; + test_verify_bytecode( + prj, + cmd, + "0x70f44C13944d49a236E3cD7a94f48f5daB6C619b", + "StrategyManager", + Some(constructor_args), + Config { + evm_version: EvmVersion::London, + optimizer: true, + optimizer_runs: 200, + ..Default::default() + }, + "etherscan", + "https://api.etherscan.io/api", + ("partial", "partial"), + ); +}); + +// `--ignore` tests +forgetest_async!(can_ignore_creation, |prj, cmd| { + test_verify_bytecode_with_ignore( + prj, + cmd, + "0xba2492e52F45651B60B8B38d4Ea5E2390C64Ffb1", + "SystemConfig", + Config { + evm_version: EvmVersion::London, + optimizer_runs: 999999, + optimizer: true, + cbor_metadata: false, + bytecode_hash: BytecodeHash::None, + ..Default::default() + }, + "etherscan", + "https://api.etherscan.io/api", + ("ignored", "partial"), + "creation", + "1", + ); +}); + +forgetest_async!(can_ignore_runtime, |prj, cmd| { + test_verify_bytecode_with_ignore( + prj, + cmd, + "0xba2492e52F45651B60B8B38d4Ea5E2390C64Ffb1", + "SystemConfig", + Config { + evm_version: EvmVersion::London, + optimizer_runs: 999999, + optimizer: true, + cbor_metadata: false, + bytecode_hash: BytecodeHash::None, + ..Default::default() + }, + "etherscan", + "https://api.etherscan.io/api", + ("partial", "ignored"), + "runtime", + "1", + ); +}); + +// Test predeploy contracts +// TODO: Add test utils for base such as basescan keys and alchemy keys. +// WETH9 Predeploy +// forgetest_async!(can_verify_predeploys, |prj, cmd| { +// test_verify_bytecode_with_ignore( +// prj, +// cmd, +// "0x4200000000000000000000000000000000000006", +// "WETH9", +// Config { +// evm_version: EvmVersion::default(), +// optimizer: true, +// optimizer_runs: 10000, +// cbor_metadata: true, +// bytecode_hash: BytecodeHash::Bzzr1, +// ..Default::default() +// }, +// "etherscan", +// "https://api.basescan.org/api", +// ("ignored", "partial"), +// "creation", +// "base", +// ); +// }); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 11da12c43173d..b1e4f7e520d80 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -1,27 +1,26 @@ -use alloy_dyn_abi::DynSolValue; +//! The `forge verify-bytecode` command. +use crate::{ + etherscan::EtherscanVerificationProvider, + utils::{ + check_and_encode_args, check_explorer_args, configure_env_block, maybe_predeploy_contract, + BytecodeType, JsonResult, + }, + verify::VerifierArgs, +}; use alloy_primitives::{hex, Address, Bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, BlockNumberOrTag}; +use alloy_rpc_types::{BlockId, BlockNumberOrTag, Transaction}; use clap::{Parser, ValueHint}; use eyre::{OptionExt, Result}; -use foundry_block_explorers::{contract::Metadata, Client}; use foundry_cli::{ opts::EtherscanOpts, utils::{self, read_constructor_args_file, LoadConfig}, }; -use foundry_common::{abi::encode_args, compile::ProjectCompiler, provider::ProviderBuilder}; -use foundry_compilers::{ - artifacts::{CompactContractBytecode, EvmVersion}, - info::ContractInfo, -}; -use foundry_config::{figment, filter::SkipBuildFilter, impl_figment_convert, Chain, Config}; -use foundry_evm::{ - constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, utils::configure_tx_env, -}; -use revm_primitives::{db::Database, EnvWithHandlerCfg, HandlerCfg}; -use semver::Version; -use serde::{Deserialize, Serialize}; -use std::{fmt, path::PathBuf, str::FromStr}; +use foundry_compilers::{artifacts::EvmVersion, info::ContractInfo}; +use foundry_config::{figment, impl_figment_convert, Config}; +use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, utils::configure_tx_env}; +use revm_primitives::AccountInfo; +use std::path::PathBuf; use yansi::Paint; impl_figment_convert!(VerifyBytecodeArgs); @@ -70,20 +69,26 @@ pub struct VerifyBytecodeArgs { pub rpc_url: Option, #[clap(flatten)] - pub etherscan_opts: EtherscanOpts, - - /// Skip building files whose names contain the given filter. - /// - /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. - #[arg(long, num_args(1..))] - pub skip: Option>, + pub etherscan: EtherscanOpts, - /// The path to the project's root directory. - pub root: Option, + /// Verifier options. + #[clap(flatten)] + pub verifier: VerifierArgs, /// Suppress logs and emit json results to stdout #[clap(long, default_value = "false")] pub json: bool, + + /// The project's root path. + /// + /// By default root of the Git repository, if in one, + /// or the current working directory. + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + pub root: Option, + + /// Ignore verification for creation or runtime bytecode. + #[clap(long, value_name = "BYTECODE_TYPE")] + pub ignore: Option, } impl figment::Provider for VerifyBytecodeArgs { @@ -94,7 +99,7 @@ impl figment::Provider for VerifyBytecodeArgs { fn data( &self, ) -> Result, figment::Error> { - let mut dict = self.etherscan_opts.dict(); + let mut dict = self.etherscan.dict(); if let Some(block) = &self.block { dict.insert("block".into(), figment::value::Value::serialize(block)?); } @@ -112,8 +117,28 @@ impl VerifyBytecodeArgs { pub async fn run(mut self) -> Result<()> { // Setup let config = self.load_config_emit_warnings(); - let provider = ProviderBuilder::new(&config.get_rpc_url_or_localhost_http()?).build()?; + let provider = utils::get_provider(&config)?; + // If chain is not set, we try to get it from the RPC. + // If RPC is not set, the default chain is used. + let chain = match config.get_rpc_url() { + Some(_) => utils::get_chain(config.chain, &provider).await?, + None => config.chain.unwrap_or_default(), + }; + + // Set Etherscan options. + self.etherscan.chain = Some(chain); + self.etherscan.key = config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); + + // Etherscan client + let etherscan = EtherscanVerificationProvider.client( + self.etherscan.chain.unwrap_or_default(), + self.verifier.verifier_url.as_deref(), + self.etherscan.key().as_deref(), + &config, + )?; + + // Get the bytecode at the address, bailing if it doesn't exist. let code = provider.get_code_at(self.address).await?; if code.is_empty() { eyre::bail!("No bytecode found at address {}", self.address); @@ -127,29 +152,158 @@ impl VerifyBytecodeArgs { ); } - // If chain is not set, we try to get it from the RPC - // If RPC is not set, the default chain is used - let chain = if config.get_rpc_url().is_some() { - let chain_id = provider.get_chain_id().await?; - Chain::from(chain_id) + let mut json_results: Vec = vec![]; + + // Get creation tx hash. + let creation_data = etherscan.contract_creation_data(self.address).await; + + // Check if contract is a predeploy + let (creation_data, maybe_predeploy) = maybe_predeploy_contract(creation_data)?; + + trace!(maybe_predeploy = ?maybe_predeploy); + + // Get the constructor args using `source_code` endpoint. + let source_code = etherscan.contract_source_code(self.address).await?; + + // Check if the contract name matches. + let name = source_code.items.first().map(|item| item.contract_name.to_owned()); + if name.as_ref() != Some(&self.contract.name) { + eyre::bail!("Contract name mismatch"); + } + + // Obtain Etherscan compilation metadata. + let etherscan_metadata = source_code.items.first().unwrap(); + + // Obtain local artifact + let artifact = if let Ok(local_bytecode) = + crate::utils::build_using_cache(&self, etherscan_metadata, &config) + { + trace!("using cache"); + local_bytecode } else { - config.chain.unwrap_or_default() + crate::utils::build_project(&self, &config)? }; - // Set Etherscan options - self.etherscan_opts.chain = Some(chain); - self.etherscan_opts.key = - config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); + // Get local bytecode (creation code) + let local_bytecode = artifact + .bytecode + .as_ref() + .and_then(|b| b.to_owned().into_bytes()) + .ok_or_eyre("Unlinked bytecode is not supported for verification")?; + + // Get and encode user provided constructor args + let provided_constructor_args = if let Some(path) = self.constructor_args_path.to_owned() { + // Read from file + Some(read_constructor_args_file(path)?) + } else { + self.constructor_args.to_owned() + } + .map(|args| check_and_encode_args(&artifact, args)) + .transpose()? + .or(self.encoded_constructor_args.to_owned().map(hex::decode).transpose()?); - // If etherscan key is not set, we can't proceed with etherscan verification - let Some(key) = self.etherscan_opts.key.clone() else { - eyre::bail!("Etherscan API key is required for verification"); + let mut constructor_args = if let Some(provided) = provided_constructor_args { + provided.into() + } else { + // If no constructor args were provided, try to retrieve them from the explorer. + check_explorer_args(source_code.clone())? }; - let etherscan = Client::new(chain, key)?; - // Get creation tx hash - let creation_data = etherscan.contract_creation_data(self.address).await?; + if maybe_predeploy { + if !self.json { + println!( + "{}", + format!("Attempting to verify predeployed contract at {:?}. Ignoring creation code verification.", self.address) + .yellow() + .bold() + ) + } + + // Append constructor args to the local_bytecode. + trace!(%constructor_args); + let mut local_bytecode_vec = local_bytecode.to_vec(); + local_bytecode_vec.extend_from_slice(&constructor_args); + + // Deploy at genesis + let gen_blk_num = 0_u64; + let (mut fork_config, evm_opts) = config.clone().load_config_and_evm_opts()?; + let (mut env, mut executor) = crate::utils::get_tracing_executor( + &mut fork_config, + gen_blk_num, + etherscan_metadata.evm_version()?.unwrap_or(EvmVersion::default()), + evm_opts, + ) + .await?; + + env.block.number = U256::ZERO; // Genesis block + let genesis_block = provider.get_block(gen_blk_num.into(), true.into()).await?; + + // Setup genesis tx and env. + let deployer = Address::with_last_byte(0x1); + let mut gen_tx = Transaction { + from: deployer, + to: None, + input: Bytes::from(local_bytecode_vec), + ..Default::default() + }; + + if let Some(ref block) = genesis_block { + configure_env_block(&mut env, block); + gen_tx.max_fee_per_gas = Some(block.header.base_fee_per_gas.unwrap_or_default()); + gen_tx.gas = block.header.gas_limit; + gen_tx.gas_price = Some(block.header.base_fee_per_gas.unwrap_or_default()); + } + configure_tx_env(&mut env, &gen_tx); + + // Seed deployer account with funds + let account_info = AccountInfo { + balance: U256::from(100 * 10_u128.pow(18)), + nonce: 0, + ..Default::default() + }; + executor.backend_mut().insert_account_info(deployer, account_info); + + let fork_address = + crate::utils::deploy_contract(&mut executor, &env, config.evm_spec_id(), &gen_tx)?; + + // Compare runtime bytecode + let (deployed_bytecode, onchain_runtime_code) = crate::utils::get_runtime_codes( + &mut executor, + &provider, + self.address, + fork_address, + None, + ) + .await?; + + let match_type = crate::utils::match_bytecodes( + &deployed_bytecode.original_bytes(), + &onchain_runtime_code, + &constructor_args, + true, + config.bytecode_hash, + ); + + crate::utils::print_result( + &self, + match_type, + BytecodeType::Runtime, + &mut json_results, + etherscan_metadata, + &config, + ); + + if self.json { + println!("{}", serde_json::to_string(&json_results)?); + } + + return Ok(()); + } + + // We can unwrap directly as maybe_predeploy is false + let creation_data = creation_data.unwrap(); + // Get transaction and receipt. trace!(creation_tx_hash = ?creation_data.transaction_hash); let mut transaction = provider .get_transaction_by_hash(creation_data.transaction_hash) @@ -162,7 +316,6 @@ impl VerifyBytecodeArgs { .get_transaction_receipt(creation_data.transaction_hash) .await .or_else(|e| eyre::bail!("Couldn't fetch transaction receipt from RPC: {:?}", e))?; - let receipt = if let Some(receipt) = receipt { receipt } else { @@ -172,7 +325,7 @@ impl VerifyBytecodeArgs { ); }; - // Extract creation code + // Extract creation code from creation tx input. let maybe_creation_code = if receipt.to.is_none() && receipt.contract_address == Some(self.address) { &transaction.input @@ -185,127 +338,73 @@ impl VerifyBytecodeArgs { ); }; - // Get the constructor args using `source_code` endpoint - let source_code = etherscan.contract_source_code(self.address).await?; - - // Check if the contract name matches - let name = source_code.items.first().map(|item| item.contract_name.to_owned()); - if name.as_ref() != Some(&self.contract.name) { - eyre::bail!("Contract name mismatch"); - } - - // Obtain Etherscan compilation metadata - let etherscan_metadata = source_code.items.first().unwrap(); - - // Obtain local artifact - let artifact = - if let Ok(local_bytecode) = self.build_using_cache(etherscan_metadata, &config) { - trace!("using cache"); - local_bytecode - } else { - self.build_project(&config)? - }; - - let local_bytecode = artifact - .bytecode - .and_then(|b| b.into_bytes()) - .ok_or_eyre("Unlinked bytecode is not supported for verification")?; - - // Get the constructor args from etherscan - let mut constructor_args = if let Some(args) = source_code.items.first() { - args.constructor_arguments.clone() - } else { - eyre::bail!("No constructor arguments found for contract at address {}", self.address); - }; - - // Get and encode user provided constructor args - let provided_constructor_args = if let Some(path) = self.constructor_args_path.to_owned() { - // Read from file - Some(read_constructor_args_file(path)?) - } else { - self.constructor_args.to_owned() - } - .map(|args| { - if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) { - if constructor.inputs.len() != args.len() { - eyre::bail!( - "Mismatch of constructor arguments length. Expected {}, got {}", - constructor.inputs.len(), - args.len() - ); - } - encode_args(&constructor.inputs, &args) - .map(|args| DynSolValue::Tuple(args).abi_encode()) - } else { - Ok(Vec::new()) - } - }) - .transpose()? - .or(self.encoded_constructor_args.to_owned().map(hex::decode).transpose()?); - - if let Some(provided) = provided_constructor_args { - constructor_args = provided.into(); - } else { - // In some cases, Etherscan will return incorrect constructor arguments. If this - // happens, try extracting arguments ourselves. - if !maybe_creation_code.ends_with(&constructor_args) { - trace!("mismatch of constructor args with etherscan"); - // If local bytecode is longer than on-chain one, this is probably not a match. - if maybe_creation_code.len() >= local_bytecode.len() { - constructor_args = - Bytes::copy_from_slice(&maybe_creation_code[local_bytecode.len()..]); - trace!( - "setting constructor args to latest {} bytes of bytecode", - constructor_args.len() - ); - } + // In some cases, Etherscan will return incorrect constructor arguments. If this + // happens, try extracting arguments ourselves. + if !maybe_creation_code.ends_with(&constructor_args) { + trace!("mismatch of constructor args with etherscan"); + // If local bytecode is longer than on-chain one, this is probably not a match. + if maybe_creation_code.len() >= local_bytecode.len() { + constructor_args = + Bytes::copy_from_slice(&maybe_creation_code[local_bytecode.len()..]); + trace!( + target: "forge::verify", + "setting constructor args to latest {} bytes of bytecode", + constructor_args.len() + ); } } - // Append constructor args to the local_bytecode + // Append constructor args to the local_bytecode. trace!(%constructor_args); let mut local_bytecode_vec = local_bytecode.to_vec(); local_bytecode_vec.extend_from_slice(&constructor_args); - // Cmp creation code with locally built bytecode and maybe_creation_code - let match_type = match_bytecodes( - local_bytecode_vec.as_slice(), - maybe_creation_code, - &constructor_args, - false, - ); - - let mut json_results: Vec = vec![]; - self.print_result( - match_type, - BytecodeType::Creation, - &mut json_results, - etherscan_metadata, - &config, - ); + trace!(ignore = ?self.ignore); + // Check if `--ignore` is set to `creation`. + if !self.ignore.is_some_and(|b| b.is_creation()) { + // Compare creation code with locally built bytecode and `maybe_creation_code`. + let match_type = crate::utils::match_bytecodes( + local_bytecode_vec.as_slice(), + maybe_creation_code, + &constructor_args, + false, + config.bytecode_hash, + ); - // If the creation code does not match, the runtime also won't match. Hence return. - if match_type.is_none() { - self.print_result( - None, - BytecodeType::Runtime, + crate::utils::print_result( + &self, + match_type, + BytecodeType::Creation, &mut json_results, etherscan_metadata, &config, ); - if self.json { - println!("{}", serde_json::to_string(&json_results)?); + + // If the creation code does not match, the runtime also won't match. Hence return. + if match_type.is_none() { + crate::utils::print_result( + &self, + None, + BytecodeType::Runtime, + &mut json_results, + etherscan_metadata, + &config, + ); + if self.json { + println!("{}", serde_json::to_string(&json_results)?); + } + return Ok(()); } - return Ok(()); } - // Get contract creation block - let simulation_block = match self.block { - Some(BlockId::Number(BlockNumberOrTag::Number(block))) => block, - Some(_) => eyre::bail!("Invalid block number"), - None => { - let provider = utils::get_provider(&config)?; - provider + if !self.ignore.is_some_and(|b| b.is_runtime()) { + // Get contract creation block. + let simulation_block = match self.block { + Some(BlockId::Number(BlockNumberOrTag::Number(block))) => block, + Some(_) => eyre::bail!("Invalid block number"), + None => { + let provider = utils::get_provider(&config)?; + provider .get_transaction_by_hash(creation_data.transaction_hash) .await.or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))?.ok_or_else(|| { eyre::eyre!("Transaction not found for hash {}", creation_data.transaction_hash) @@ -313,378 +412,90 @@ impl VerifyBytecodeArgs { .block_number.ok_or_else(|| { eyre::eyre!("Failed to get block number of the contract creation tx, specify using the --block flag") })? - } - }; + } + }; - // Fork the chain at `simulation_block` - - let (mut fork_config, evm_opts) = config.clone().load_config_and_evm_opts()?; - fork_config.fork_block_number = Some(simulation_block - 1); - fork_config.evm_version = - etherscan_metadata.evm_version()?.unwrap_or(EvmVersion::default()); - let (mut env, fork, _chain, alphanet) = - TracingExecutor::get_fork_material(&fork_config, evm_opts).await?; - - let mut executor = TracingExecutor::new( - env.clone(), - fork, - Some(fork_config.evm_version), - false, - false, - alphanet, - ); - env.block.number = U256::from(simulation_block); - let block = provider.get_block(simulation_block.into(), true.into()).await?; - - // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same - // block. - let prev_block_id = BlockId::number(simulation_block - 1); - let prev_block_nonce = provider - .get_transaction_count(creation_data.contract_creator) - .block_id(prev_block_id) + // Fork the chain at `simulation_block`. + let (mut fork_config, evm_opts) = config.clone().load_config_and_evm_opts()?; + let (mut env, mut executor) = crate::utils::get_tracing_executor( + &mut fork_config, + simulation_block - 1, // env.fork_block_number + etherscan_metadata.evm_version()?.unwrap_or(EvmVersion::default()), + evm_opts, + ) .await?; - transaction.nonce = prev_block_nonce; - - if let Some(ref block) = block { - env.block.timestamp = U256::from(block.header.timestamp); - env.block.coinbase = block.header.miner; - env.block.difficulty = block.header.difficulty; - env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); - env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); - env.block.gas_limit = U256::from(block.header.gas_limit); - } - - // Replace the `input` with local creation code in the creation tx. - if let Some(to) = transaction.to { - if to == DEFAULT_CREATE2_DEPLOYER { - let mut input = transaction.input[..32].to_vec(); // Salt - input.extend_from_slice(&local_bytecode_vec); - transaction.input = Bytes::from(input); + env.block.number = U256::from(simulation_block); + let block = provider.get_block(simulation_block.into(), true.into()).await?; - // Deploy default CREATE2 deployer - executor.deploy_create2_deployer()?; - } - } else { - transaction.input = Bytes::from(local_bytecode_vec); - } - - configure_tx_env(&mut env, &transaction); + // Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same + // block. + let prev_block_id = BlockId::number(simulation_block - 1); - let env_with_handler = - EnvWithHandlerCfg::new(Box::new(env.clone()), HandlerCfg::new(config.evm_spec_id())); + // Use `transaction.from` instead of `creation_data.contract_creator` to resolve + // blockscout creation data discrepancy in case of CREATE2. + let prev_block_nonce = + provider.get_transaction_count(transaction.from).block_id(prev_block_id).await?; + transaction.nonce = prev_block_nonce; - let contract_address = if let Some(to) = transaction.to { - if to != DEFAULT_CREATE2_DEPLOYER { - eyre::bail!("Transaction `to` address is not the default create2 deployer i.e the tx is not a contract creation tx."); + if let Some(ref block) = block { + configure_env_block(&mut env, block) } - let result = executor.transact_with_env(env_with_handler.clone())?; - - if result.result.len() != 20 { - eyre::bail!("Failed to deploy contract on fork at block {simulation_block}: call result is not exactly 20 bytes"); - } - - Address::from_slice(&result.result) - } else { - let deploy_result = executor.deploy_with_env(env_with_handler, None)?; - deploy_result.address - }; - - // State commited using deploy_with_env, now get the runtime bytecode from the db. - let fork_runtime_code = executor - .backend_mut() - .basic(contract_address)? - .ok_or_else(|| { - eyre::eyre!( - "Failed to get runtime code for contract deployed on fork at address {}", - contract_address - ) - })? - .code - .ok_or_else(|| { - eyre::eyre!( - "Bytecode does not exist for contract deployed on fork at address {}", - contract_address - ) - })?; - - let onchain_runtime_code = - provider.get_code_at(self.address).block_id(BlockId::number(simulation_block)).await?; - - // Compare the onchain runtime bytecode with the runtime code from the fork. - let match_type = match_bytecodes( - &fork_runtime_code.original_bytes(), - &onchain_runtime_code, - &constructor_args, - true, - ); - - self.print_result( - match_type, - BytecodeType::Runtime, - &mut json_results, - etherscan_metadata, - &config, - ); - - if self.json { - println!("{}", serde_json::to_string(&json_results)?); - } - Ok(()) - } - - fn build_project(&self, config: &Config) -> Result { - let project = config.project()?; - let compiler = ProjectCompiler::new(); - - let mut output = compiler.compile(&project)?; - let artifact = output - .remove_contract(&self.contract) - .ok_or_eyre("Build Error: Contract artifact not found locally")?; + // Replace the `input` with local creation code in the creation tx. + if let Some(to) = transaction.to { + if to == DEFAULT_CREATE2_DEPLOYER { + let mut input = transaction.input[..32].to_vec(); // Salt + input.extend_from_slice(&local_bytecode_vec); + transaction.input = Bytes::from(input); - Ok(artifact.into_contract_bytecode()) - } - - fn build_using_cache( - &self, - etherscan_settings: &Metadata, - config: &Config, - ) -> Result { - let project = config.project()?; - let cache = project.read_cache_file()?; - let cached_artifacts = cache.read_artifacts::()?; - - for (key, value) in cached_artifacts { - let name = self.contract.name.to_owned() + ".sol"; - let version = etherscan_settings.compiler_version.to_owned(); - // Ignores vyper - if version.starts_with("vyper:") { - eyre::bail!("Vyper contracts are not supported") - } - // Parse etherscan version string - let version = - version.split('+').next().unwrap_or("").trim_start_matches('v').to_string(); - - // Check if `out/directory` name matches the contract name - if key.ends_with(name.as_str()) { - let name = name.replace(".sol", ".json"); - for artifact in value.into_values().flatten() { - // Check if ABI file matches the name - if !artifact.file.ends_with(&name) { - continue; - } - - // Check if Solidity version matches - if let Ok(version) = Version::parse(&version) { - if !(artifact.version.major == version.major && - artifact.version.minor == version.minor && - artifact.version.patch == version.patch) - { - continue; - } - } - - return Ok(artifact.artifact) + // Deploy default CREATE2 deployer + executor.deploy_create2_deployer()?; } - } - } - - eyre::bail!("couldn't find cached artifact for contract {}", self.contract.name) - } - - fn print_result( - &self, - res: Option, - bytecode_type: BytecodeType, - json_results: &mut Vec, - etherscan_config: &Metadata, - config: &Config, - ) { - if let Some(res) = res { - if !self.json { - println!( - "{} with status {}", - format!("{bytecode_type:?} code matched").green().bold(), - res.green().bold() - ); } else { - let json_res = JsonResult { bytecode_type, match_type: Some(res), message: None }; - json_results.push(json_res); - } - } else if !self.json { - println!( - "{}", - format!( - "{bytecode_type:?} code did not match - this may be due to varying compiler settings" - ) - .red() - .bold() - ); - let mismatches = find_mismatch_in_settings(etherscan_config, config); - for mismatch in mismatches { - println!("{}", mismatch.red().bold()); + transaction.input = Bytes::from(local_bytecode_vec); } - } else { - let json_res = JsonResult { - bytecode_type, - match_type: res, - message: Some(format!( - "{bytecode_type:?} code did not match - this may be due to varying compiler settings" - )), - }; - json_results.push(json_res); - } - } -} - -/// Enum to represent the type of verification: `full` or `partial`. -/// Ref: -#[derive(Debug, Clone, clap::ValueEnum, Default, PartialEq, Eq, Serialize, Deserialize, Copy)] -pub enum VerificationType { - #[default] - #[serde(rename = "full")] - Full, - #[serde(rename = "partial")] - Partial, -} -impl FromStr for VerificationType { - type Err = eyre::Error; - - fn from_str(s: &str) -> Result { - match s { - "full" => Ok(Self::Full), - "partial" => Ok(Self::Partial), - _ => eyre::bail!("Invalid verification type"), - } - } -} + configure_tx_env(&mut env, &transaction); + + let fork_address = crate::utils::deploy_contract( + &mut executor, + &env, + config.evm_spec_id(), + &transaction, + )?; + + // State commited using deploy_with_env, now get the runtime bytecode from the db. + let (fork_runtime_code, onchain_runtime_code) = crate::utils::get_runtime_codes( + &mut executor, + &provider, + self.address, + fork_address, + Some(simulation_block), + ) + .await?; -impl From for String { - fn from(v: VerificationType) -> Self { - match v { - VerificationType::Full => "full".to_string(), - VerificationType::Partial => "partial".to_string(), - } - } -} + // Compare the onchain runtime bytecode with the runtime code from the fork. + let match_type = crate::utils::match_bytecodes( + &fork_runtime_code.original_bytes(), + &onchain_runtime_code, + &constructor_args, + true, + config.bytecode_hash, + ); -impl fmt::Display for VerificationType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Full => write!(f, "full"), - Self::Partial => write!(f, "partial"), + crate::utils::print_result( + &self, + match_type, + BytecodeType::Runtime, + &mut json_results, + etherscan_metadata, + &config, + ); } - } -} - -/// Enum to represent the type of bytecode being verified -#[derive(Debug, Serialize, Deserialize, Clone, Copy)] -pub enum BytecodeType { - #[serde(rename = "creation")] - Creation, - #[serde(rename = "runtime")] - Runtime, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct JsonResult { - pub bytecode_type: BytecodeType, - pub match_type: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub message: Option, -} - -fn match_bytecodes( - local_bytecode: &[u8], - bytecode: &[u8], - constructor_args: &[u8], - is_runtime: bool, -) -> Option { - // 1. Try full match - if local_bytecode == bytecode { - Some(VerificationType::Full) - } else { - is_partial_match(local_bytecode, bytecode, constructor_args, is_runtime) - .then_some(VerificationType::Partial) - } -} - -fn is_partial_match( - mut local_bytecode: &[u8], - mut bytecode: &[u8], - constructor_args: &[u8], - is_runtime: bool, -) -> bool { - // 1. Check length of constructor args - if constructor_args.is_empty() || is_runtime { - // Assume metadata is at the end of the bytecode - return try_extract_and_compare_bytecode(local_bytecode, bytecode) - } - - // If not runtime, extract constructor args from the end of the bytecode - bytecode = &bytecode[..bytecode.len() - constructor_args.len()]; - local_bytecode = &local_bytecode[..local_bytecode.len() - constructor_args.len()]; - - try_extract_and_compare_bytecode(local_bytecode, bytecode) -} -fn try_extract_and_compare_bytecode(mut local_bytecode: &[u8], mut bytecode: &[u8]) -> bool { - local_bytecode = extract_metadata_hash(local_bytecode); - bytecode = extract_metadata_hash(bytecode); - - // Now compare the local code and bytecode - local_bytecode == bytecode -} - -/// @dev This assumes that the metadata is at the end of the bytecode -fn extract_metadata_hash(bytecode: &[u8]) -> &[u8] { - // Get the last two bytes of the bytecode to find the length of CBOR metadata - let metadata_len = &bytecode[bytecode.len() - 2..]; - let metadata_len = u16::from_be_bytes([metadata_len[0], metadata_len[1]]); - - if metadata_len as usize <= bytecode.len() { - if ciborium::from_reader::( - &bytecode[bytecode.len() - 2 - metadata_len as usize..bytecode.len() - 2], - ) - .is_ok() - { - &bytecode[..bytecode.len() - 2 - metadata_len as usize] - } else { - bytecode + if self.json { + println!("{}", serde_json::to_string(&json_results)?); } - } else { - bytecode - } -} - -fn find_mismatch_in_settings( - etherscan_settings: &Metadata, - local_settings: &Config, -) -> Vec { - let mut mismatches: Vec = vec![]; - if etherscan_settings.evm_version != local_settings.evm_version.to_string().to_lowercase() { - let str = format!( - "EVM version mismatch: local={}, onchain={}", - local_settings.evm_version, etherscan_settings.evm_version - ); - mismatches.push(str); - } - let local_optimizer: u64 = if local_settings.optimizer { 1 } else { 0 }; - if etherscan_settings.optimization_used != local_optimizer { - let str = format!( - "Optimizer mismatch: local={}, onchain={}", - local_settings.optimizer, etherscan_settings.optimization_used - ); - mismatches.push(str); - } - if etherscan_settings.runs != local_settings.optimizer_runs as u64 { - let str = format!( - "Optimizer runs mismatch: local={}, onchain={}", - local_settings.optimizer_runs, etherscan_settings.runs - ); - mismatches.push(str); + Ok(()) } - - mismatches } diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 6fd6ffb7e3bbe..3109a3d081869 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -1,5 +1,8 @@ -use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; -use crate::{provider::VerificationContext, retry::RETRY_CHECK_ON_VERIFY}; +use crate::{ + provider::{VerificationContext, VerificationProvider}, + retry::RETRY_CHECK_ON_VERIFY, + verify::{VerifyArgs, VerifyCheckArgs}, +}; use alloy_json_abi::Function; use alloy_primitives::hex; use alloy_provider::Provider; @@ -10,7 +13,7 @@ use foundry_block_explorers::{ verify::{CodeFormat, VerifyContract}, Client, }; -use foundry_cli::utils::{self, read_constructor_args_file, LoadConfig}; +use foundry_cli::utils::{get_provider, read_constructor_args_file, LoadConfig}; use foundry_common::{ abi::encode_function_args, retry::{Retry, RetryError}, @@ -26,6 +29,7 @@ use semver::{BuildMetadata, Version}; use std::fmt::Debug; mod flatten; + mod standard_json; pub static RE_BUILD_COMMIT: Lazy = @@ -48,17 +52,17 @@ trait EtherscanSourceProvider: Send + Sync + Debug { #[async_trait::async_trait] impl VerificationProvider for EtherscanVerificationProvider { - async fn preflight_check( + async fn preflight_verify_check( &mut self, args: VerifyArgs, context: VerificationContext, ) -> Result<()> { - let _ = self.prepare_request(&args, &context).await?; + let _ = self.prepare_verify_request(&args, &context).await?; Ok(()) } async fn verify(&mut self, args: VerifyArgs, context: VerificationContext) -> Result<()> { - let (etherscan, verify_args) = self.prepare_request(&args, &context).await?; + let (etherscan, verify_args) = self.prepare_verify_request(&args, &context).await?; if !args.skip_is_verified_check && self.is_contract_verified(ðerscan, &verify_args).await? @@ -72,7 +76,7 @@ impl VerificationProvider for EtherscanVerificationProvider { return Ok(()) } - trace!(target: "forge::verify", ?verify_args, "submitting verification request"); + trace!(?verify_args, "submitting verification request"); let retry: Retry = args.retry.into(); let resp = retry @@ -87,11 +91,11 @@ impl VerificationProvider for EtherscanVerificationProvider { .wrap_err_with(|| { // valid json let args = serde_json::to_string(&verify_args).unwrap(); - error!(target: "forge::verify", ?args, "Failed to submit verification"); + error!(?args, "Failed to submit verification"); format!("Failed to submit contract verification, payload:\n{args}") })?; - trace!(target: "forge::verify", ?resp, "Received verification response"); + trace!(?resp, "Received verification response"); if resp.status == "0" { if resp.result == "Contract source code already verified" @@ -162,7 +166,7 @@ impl VerificationProvider for EtherscanVerificationProvider { .wrap_err("Failed to request verification status") .map_err(RetryError::Retry)?; - trace!(target: "forge::verify", ?resp, "Received verification response"); + trace!(?resp, "Received verification response"); eprintln!( "Contract verification status:\nResponse: `{}`\nDetails: `{}`", @@ -209,8 +213,8 @@ impl EtherscanVerificationProvider { } } - /// Configures the API request to the etherscan API using the given [`VerifyArgs`]. - async fn prepare_request( + /// Configures the API request to the Etherscan API using the given [`VerifyArgs`]. + async fn prepare_verify_request( &mut self, args: &VerifyArgs, context: &VerificationContext, @@ -227,7 +231,7 @@ impl EtherscanVerificationProvider { Ok((etherscan, verify_args)) } - /// Queries the etherscan API to verify if the contract is already verified. + /// Queries the Etherscan API to verify if the contract is already verified. async fn is_contract_verified( &self, etherscan: &Client, @@ -245,7 +249,7 @@ impl EtherscanVerificationProvider { Ok(true) } - /// Create an etherscan client + /// Create an Etherscan client. pub(crate) fn client( &self, chain: Chain, @@ -284,10 +288,10 @@ impl EtherscanVerificationProvider { builder .with_api_key(etherscan_key.unwrap_or_default()) .build() - .wrap_err("Failed to create etherscan client") + .wrap_err("Failed to create Etherscan client") } - /// Creates the `VerifyContract` etherscan request in order to verify the contract + /// Creates the `VerifyContract` Etherscan request in order to verify the contract /// /// If `--flatten` is set to `true` then this will send with [`CodeFormat::SingleFile`] /// otherwise this will use the [`CodeFormat::StandardJsonInput`] @@ -317,7 +321,7 @@ impl EtherscanVerificationProvider { // we explicitly set this __undocumented__ argument to true if provided by the user, // though this info is also available in the compiler settings of the standard json // object if standard json is used - // unclear how etherscan interprets this field in standard-json mode + // unclear how Etherscan interprets this field in standard-json mode verify_args = verify_args.via_ir(true); } @@ -377,7 +381,7 @@ impl EtherscanVerificationProvider { args: &VerifyArgs, context: &VerificationContext, ) -> Result { - let provider = utils::get_provider(&context.config)?; + let provider = get_provider(&context.config)?; let client = self.client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), @@ -575,6 +579,6 @@ mod tests { let context = args.resolve_context().await.unwrap(); let mut etherscan = EtherscanVerificationProvider::default(); - etherscan.preflight_check(args, context).await.unwrap(); + etherscan.preflight_verify_check(args, context).await.unwrap(); }); } diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rs index 5edda5b085c37..9d2372964850e 100644 --- a/crates/verify/src/lib.rs +++ b/crates/verify/src/lib.rs @@ -1,396 +1,26 @@ -//! # foundry-verify -//! //! Smart contract verification. #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#[macro_use] -extern crate tracing; - -use alloy_primitives::Address; -use alloy_provider::Provider; -use clap::{Parser, ValueHint}; -use eyre::Result; -use foundry_cli::{ - opts::{EtherscanOpts, RpcOpts}, - utils::{self, LoadConfig}, -}; -use foundry_common::{compile::ProjectCompiler, ContractsByArtifact}; -use foundry_compilers::{artifacts::EvmVersion, compilers::solc::Solc, info::ContractInfo}; -use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config, SolcReq}; -use itertools::Itertools; -use provider::VerificationProviderType; -use reqwest::Url; -use revm_primitives::HashSet; -use std::path::PathBuf; - mod etherscan; -use etherscan::EtherscanVerificationProvider; pub mod provider; -use provider::VerificationProvider; pub mod bytecode; -pub mod retry; -mod sourcify; +pub use bytecode::VerifyBytecodeArgs; +pub mod retry; pub use retry::RetryArgs; -use crate::provider::VerificationContext; - -/// Verification provider arguments -#[derive(Clone, Debug, Parser)] -pub struct VerifierArgs { - /// The contract verification provider to use. - #[arg(long, help_heading = "Verifier options", default_value = "etherscan", value_enum)] - pub verifier: VerificationProviderType, - - /// The verifier URL, if using a custom provider - #[arg(long, help_heading = "Verifier options", env = "VERIFIER_URL")] - pub verifier_url: Option, -} - -impl Default for VerifierArgs { - fn default() -> Self { - Self { verifier: VerificationProviderType::Etherscan, verifier_url: None } - } -} - -/// CLI arguments for `forge verify`. -#[derive(Clone, Debug, Parser)] -pub struct VerifyArgs { - /// The address of the contract to verify. - pub address: Address, - - /// The contract identifier in the form `:`. - pub contract: Option, - - /// The ABI-encoded constructor arguments. - #[arg( - long, - conflicts_with = "constructor_args_path", - value_name = "ARGS", - visible_alias = "encoded-constructor-args" - )] - pub constructor_args: Option, - - /// The path to a file containing the constructor arguments. - #[arg(long, value_hint = ValueHint::FilePath, value_name = "PATH")] - pub constructor_args_path: Option, - - /// Try to extract constructor arguments from on-chain creation code. - #[arg(long)] - pub guess_constructor_args: bool, - - /// The `solc` version to use to build the smart contract. - #[arg(long, value_name = "VERSION")] - pub compiler_version: Option, - - /// The number of optimization runs used to build the smart contract. - #[arg(long, visible_alias = "optimizer-runs", value_name = "NUM")] - pub num_of_optimizations: Option, - - /// Flatten the source code before verifying. - #[arg(long)] - pub flatten: bool, - - /// Do not compile the flattened smart contract before verifying (if --flatten is passed). - #[arg(short, long)] - pub force: bool, - - /// Do not check if the contract is already verified before verifying. - #[arg(long)] - pub skip_is_verified_check: bool, - - /// Wait for verification result after submission. - #[arg(long)] - pub watch: bool, - - /// Set pre-linked libraries. - #[arg(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")] - pub libraries: Vec, - - /// The project's root path. - /// - /// By default root of the Git repository, if in one, - /// or the current working directory. - #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] - pub root: Option, - - /// Prints the standard json compiler input. - /// - /// The standard json compiler input can be used to manually submit contract verification in - /// the browser. - #[arg(long, conflicts_with = "flatten")] - pub show_standard_json_input: bool, - - /// Use the Yul intermediate representation compilation pipeline. - #[arg(long)] - pub via_ir: bool, - - /// The EVM version to use. - /// - /// Overrides the version specified in the config. - #[arg(long)] - pub evm_version: Option, - - #[command(flatten)] - pub etherscan: EtherscanOpts, - - #[command(flatten)] - pub rpc: RpcOpts, - - #[command(flatten)] - pub retry: RetryArgs, - - #[command(flatten)] - pub verifier: VerifierArgs, -} - -impl_figment_convert!(VerifyArgs); - -impl figment::Provider for VerifyArgs { - fn metadata(&self) -> figment::Metadata { - figment::Metadata::named("Verify Provider") - } - - fn data( - &self, - ) -> Result, figment::Error> { - let mut dict = self.etherscan.dict(); - dict.extend(self.rpc.dict()); - - if let Some(root) = self.root.as_ref() { - dict.insert("root".to_string(), figment::value::Value::serialize(root)?); - } - if let Some(optimizer_runs) = self.num_of_optimizations { - dict.insert("optimizer".to_string(), figment::value::Value::serialize(true)?); - dict.insert( - "optimizer_runs".to_string(), - figment::value::Value::serialize(optimizer_runs)?, - ); - } - if let Some(evm_version) = self.evm_version { - dict.insert("evm_version".to_string(), figment::value::Value::serialize(evm_version)?); - } - if self.via_ir { - dict.insert("via_ir".to_string(), figment::value::Value::serialize(self.via_ir)?); - } - Ok(figment::value::Map::from([(Config::selected_profile(), dict)])) - } -} - -impl VerifyArgs { - /// Run the verify command to submit the contract's source code for verification on etherscan - pub async fn run(mut self) -> Result<()> { - let config = self.load_config_emit_warnings(); - - if self.guess_constructor_args && config.get_rpc_url().is_none() { - eyre::bail!( - "You have to provide a valid RPC URL to use --guess-constructor-args feature" - ) - } - - // If chain is not set, we try to get it from the RPC - // If RPC is not set, the default chain is used - let chain = match config.get_rpc_url() { - Some(_) => { - let provider = utils::get_provider(&config)?; - utils::get_chain(config.chain, provider).await? - } - None => config.chain.unwrap_or_default(), - }; - - let context = self.resolve_context().await?; - - self.etherscan.chain = Some(chain); - self.etherscan.key = config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); - - if self.show_standard_json_input { - let args = EtherscanVerificationProvider::default() - .create_verify_request(&self, &context) - .await?; - println!("{}", args.source); - return Ok(()) - } - - let verifier_url = self.verifier.verifier_url.clone(); - println!("Start verifying contract `{}` deployed on {chain}", self.address); - self.verifier.verifier.client(&self.etherscan.key())?.verify(self, context).await.map_err(|err| { - if let Some(verifier_url) = verifier_url { - match Url::parse(&verifier_url) { - Ok(url) => { - if is_host_only(&url) { - return err.wrap_err(format!( - "Provided URL `{verifier_url}` is host only.\n Did you mean to use the API endpoint`{verifier_url}/api` ?" - )) - } - } - Err(url_err) => { - return err.wrap_err(format!( - "Invalid URL {verifier_url} provided: {url_err}" - )) - } - } - } - - err - }) - } - - /// Returns the configured verification provider - pub fn verification_provider(&self) -> Result> { - self.verifier.verifier.client(&self.etherscan.key()) - } - - /// Resolves [VerificationContext] object either from entered contract name or by trying to - /// match bytecode located at given address. - pub async fn resolve_context(&self) -> Result { - let mut config = self.load_config_emit_warnings(); - config.libraries.extend(self.libraries.clone()); - - let project = config.project()?; - - if let Some(ref contract) = self.contract { - let contract_path = if let Some(ref path) = contract.path { - project.root().join(PathBuf::from(path)) - } else { - project.find_contract_path(&contract.name)? - }; - - let version = if let Some(ref version) = self.compiler_version { - version.trim_start_matches('v').parse()? - } else if let Some(ref solc) = config.solc { - match solc { - SolcReq::Version(version) => version.to_owned(), - SolcReq::Local(solc) => Solc::new(solc)?.version, - } - } else if let Some(entry) = project - .read_cache_file() - .ok() - .and_then(|mut cache| cache.files.remove(&contract_path)) - { - let unique_versions = entry - .artifacts - .get(&contract.name) - .map(|artifacts| artifacts.keys().collect::>()) - .unwrap_or_default(); - - if unique_versions.is_empty() { - eyre::bail!("No matching artifact found for {}", contract.name); - } else if unique_versions.len() > 1 { - warn!( - "Ambiguous compiler versions found in cache: {}", - unique_versions.iter().join(", ") - ); - eyre::bail!("Compiler version has to be set in `foundry.toml`. If the project was not deployed with foundry, specify the version through `--compiler-version` flag.") - } - - unique_versions.into_iter().next().unwrap().to_owned() - } else { - eyre::bail!("If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml") - }; - - VerificationContext::new(contract_path, contract.name.clone(), version, config) - } else { - if config.get_rpc_url().is_none() { - eyre::bail!("You have to provide a contract name or a valid RPC URL") - } - let provider = utils::get_provider(&config)?; - let code = provider.get_code_at(self.address).await?; - - let output = ProjectCompiler::new().compile(&project)?; - let contracts = ContractsByArtifact::new( - output.artifact_ids().map(|(id, artifact)| (id, artifact.clone().into())), - ); - - let Some((artifact_id, _)) = contracts.find_by_deployed_code_exact(&code) else { - eyre::bail!(format!( - "Bytecode at {} does not match any local contracts", - self.address - )) - }; - - VerificationContext::new( - artifact_id.source.clone(), - artifact_id.name.split('.').next().unwrap().to_owned(), - artifact_id.version.clone(), - config, - ) - } - } -} - -/// Check verification status arguments -#[derive(Clone, Debug, Parser)] -pub struct VerifyCheckArgs { - /// The verification ID. - /// - /// For Etherscan - Submission GUID. - /// - /// For Sourcify - Contract Address. - id: String, - - #[command(flatten)] - retry: RetryArgs, - - #[command(flatten)] - etherscan: EtherscanOpts, - - #[command(flatten)] - verifier: VerifierArgs, -} - -impl_figment_convert_cast!(VerifyCheckArgs); - -impl VerifyCheckArgs { - /// Run the verify command to submit the contract's source code for verification on etherscan - pub async fn run(self) -> Result<()> { - println!("Checking verification status on {}", self.etherscan.chain.unwrap_or_default()); - self.verifier.verifier.client(&self.etherscan.key())?.check(self).await - } -} - -impl figment::Provider for VerifyCheckArgs { - fn metadata(&self) -> figment::Metadata { - figment::Metadata::named("Verify Check Provider") - } - - fn data( - &self, - ) -> Result, figment::Error> { - self.etherscan.data() - } -} +mod sourcify; -/// Returns `true` if the URL only consists of host. -/// -/// This is used to check user input url for missing /api path -#[inline] -fn is_host_only(url: &Url) -> bool { - matches!(url.path(), "/" | "") -} +pub mod verify; +pub use verify::{VerifierArgs, VerifyArgs, VerifyCheckArgs}; -#[cfg(test)] -mod tests { - use super::*; +mod types; - #[test] - fn test_host_only() { - assert!(!is_host_only(&Url::parse("https://blockscout.net/api").unwrap())); - assert!(is_host_only(&Url::parse("https://blockscout.net/").unwrap())); - assert!(is_host_only(&Url::parse("https://blockscout.net").unwrap())); - } +mod utils; - #[test] - fn can_parse_verify_contract() { - let args: VerifyArgs = VerifyArgs::parse_from([ - "foundry-cli", - "0x0000000000000000000000000000000000000000", - "src/Domains.sol:Domains", - "--via-ir", - ]); - assert!(args.via_ir); - } -} +#[macro_use] +extern crate tracing; diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index 46ca0b9447bff..1506585abf257 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -1,6 +1,7 @@ -use super::{ - etherscan::EtherscanVerificationProvider, sourcify::SourcifyVerificationProvider, VerifyArgs, - VerifyCheckArgs, +use crate::{ + etherscan::EtherscanVerificationProvider, + sourcify::SourcifyVerificationProvider, + verify::{VerifyArgs, VerifyCheckArgs}, }; use alloy_json_abi::JsonAbi; use async_trait::async_trait; @@ -101,7 +102,7 @@ pub trait VerificationProvider { /// [`VerifyArgs`] are valid to begin with. This should prevent situations where there's a /// contract deployment that's executed before the verify request and the subsequent verify task /// fails due to misconfiguration. - async fn preflight_check( + async fn preflight_verify_check( &mut self, args: VerifyArgs, context: VerificationContext, diff --git a/crates/verify/src/sourcify.rs b/crates/verify/src/sourcify.rs index 58cb2b4b93d74..81fadd09e5b74 100644 --- a/crates/verify/src/sourcify.rs +++ b/crates/verify/src/sourcify.rs @@ -1,5 +1,7 @@ -use super::{provider::VerificationProvider, VerifyArgs, VerifyCheckArgs}; -use crate::provider::VerificationContext; +use crate::{ + provider::{VerificationContext, VerificationProvider}, + verify::{VerifyArgs, VerifyCheckArgs}, +}; use async_trait::async_trait; use eyre::Result; use foundry_common::{fs, retry::Retry}; @@ -17,7 +19,7 @@ pub struct SourcifyVerificationProvider; #[async_trait] impl VerificationProvider for SourcifyVerificationProvider { - async fn preflight_check( + async fn preflight_verify_check( &mut self, args: VerifyArgs, context: VerificationContext, diff --git a/crates/verify/src/types.rs b/crates/verify/src/types.rs new file mode 100644 index 0000000000000..20d86499642d7 --- /dev/null +++ b/crates/verify/src/types.rs @@ -0,0 +1,44 @@ +use eyre::Result; +use serde::{Deserialize, Serialize}; +use std::{fmt, str::FromStr}; + +/// Enum to represent the type of verification: `full` or `partial`. +/// Ref: +#[derive(Debug, Clone, clap::ValueEnum, Default, PartialEq, Eq, Serialize, Deserialize, Copy)] +pub enum VerificationType { + #[default] + #[serde(rename = "full")] + Full, + #[serde(rename = "partial")] + Partial, +} + +impl FromStr for VerificationType { + type Err = eyre::Error; + + fn from_str(s: &str) -> Result { + match s { + "full" => Ok(Self::Full), + "partial" => Ok(Self::Partial), + _ => eyre::bail!("Invalid verification type"), + } + } +} + +impl From for String { + fn from(v: VerificationType) -> Self { + match v { + VerificationType::Full => "full".to_string(), + VerificationType::Partial => "partial".to_string(), + } + } +} + +impl fmt::Display for VerificationType { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Full => write!(f, "full"), + Self::Partial => write!(f, "partial"), + } + } +} diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs new file mode 100644 index 0000000000000..d5545df6714b9 --- /dev/null +++ b/crates/verify/src/utils.rs @@ -0,0 +1,423 @@ +use crate::{bytecode::VerifyBytecodeArgs, types::VerificationType}; +use alloy_dyn_abi::DynSolValue; +use alloy_primitives::{Address, Bytes, U256}; +use alloy_provider::Provider; +use alloy_rpc_types::{Block, BlockId, Transaction}; +use clap::ValueEnum; +use eyre::{OptionExt, Result}; +use foundry_block_explorers::{ + contract::{ContractCreationData, ContractMetadata, Metadata}, + errors::EtherscanError, +}; +use foundry_common::{abi::encode_args, compile::ProjectCompiler, provider::RetryProvider}; +use foundry_compilers::artifacts::{BytecodeHash, CompactContractBytecode, EvmVersion}; +use foundry_config::Config; +use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, opts::EvmOpts}; +use reqwest::Url; +use revm_primitives::{ + db::Database, + env::{EnvWithHandlerCfg, HandlerCfg}, + Bytecode, Env, SpecId, +}; +use semver::Version; +use serde::{Deserialize, Serialize}; +use yansi::Paint; + +/// Enum to represent the type of bytecode being verified +#[derive(Debug, Serialize, Deserialize, Clone, Copy, ValueEnum)] +pub enum BytecodeType { + #[serde(rename = "creation")] + Creation, + #[serde(rename = "runtime")] + Runtime, +} + +impl BytecodeType { + /// Check if the bytecode type is creation + pub fn is_creation(&self) -> bool { + matches!(self, Self::Creation) + } + + /// Check if the bytecode type is runtime + pub fn is_runtime(&self) -> bool { + matches!(self, Self::Runtime) + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct JsonResult { + pub bytecode_type: BytecodeType, + pub match_type: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +pub fn match_bytecodes( + local_bytecode: &[u8], + bytecode: &[u8], + constructor_args: &[u8], + is_runtime: bool, + bytecode_hash: BytecodeHash, +) -> Option { + // 1. Try full match + if local_bytecode == bytecode { + // If the bytecode_hash = 'none' in Config. Then it's always a partial match according to + // sourcify definitions. Ref: https://docs.sourcify.dev/docs/full-vs-partial-match/. + if bytecode_hash == BytecodeHash::None { + return Some(VerificationType::Partial); + } + + Some(VerificationType::Full) + } else { + is_partial_match(local_bytecode, bytecode, constructor_args, is_runtime) + .then_some(VerificationType::Partial) + } +} + +pub fn build_project( + args: &VerifyBytecodeArgs, + config: &Config, +) -> Result { + let project = config.project()?; + let compiler = ProjectCompiler::new(); + + let mut output = compiler.compile(&project)?; + + let artifact = output + .remove_contract(&args.contract) + .ok_or_eyre("Build Error: Contract artifact not found locally")?; + + Ok(artifact.into_contract_bytecode()) +} + +pub fn build_using_cache( + args: &VerifyBytecodeArgs, + etherscan_settings: &Metadata, + config: &Config, +) -> Result { + let project = config.project()?; + let cache = project.read_cache_file()?; + let cached_artifacts = cache.read_artifacts::()?; + + for (key, value) in cached_artifacts { + let name = args.contract.name.to_owned() + ".sol"; + let version = etherscan_settings.compiler_version.to_owned(); + // Ignores vyper + if version.starts_with("vyper:") { + eyre::bail!("Vyper contracts are not supported") + } + // Parse etherscan version string + let version = version.split('+').next().unwrap_or("").trim_start_matches('v').to_string(); + + // Check if `out/directory` name matches the contract name + if key.ends_with(name.as_str()) { + let name = name.replace(".sol", ".json"); + for artifact in value.into_values().flatten() { + // Check if ABI file matches the name + if !artifact.file.ends_with(&name) { + continue; + } + + // Check if Solidity version matches + if let Ok(version) = Version::parse(&version) { + if !(artifact.version.major == version.major && + artifact.version.minor == version.minor && + artifact.version.patch == version.patch) + { + continue; + } + } + + return Ok(artifact.artifact) + } + } + } + + eyre::bail!("couldn't find cached artifact for contract {}", args.contract.name) +} + +pub fn print_result( + args: &VerifyBytecodeArgs, + res: Option, + bytecode_type: BytecodeType, + json_results: &mut Vec, + etherscan_config: &Metadata, + config: &Config, +) { + if let Some(res) = res { + if !args.json { + println!( + "{} with status {}", + format!("{bytecode_type:?} code matched").green().bold(), + res.green().bold() + ); + } else { + let json_res = JsonResult { bytecode_type, match_type: Some(res), message: None }; + json_results.push(json_res); + } + } else if !args.json { + println!( + "{}", + format!( + "{bytecode_type:?} code did not match - this may be due to varying compiler settings" + ) + .red() + .bold() + ); + let mismatches = find_mismatch_in_settings(etherscan_config, config); + for mismatch in mismatches { + println!("{}", mismatch.red().bold()); + } + } else { + let json_res = JsonResult { + bytecode_type, + match_type: res, + message: Some(format!( + "{bytecode_type:?} code did not match - this may be due to varying compiler settings" + )), + }; + json_results.push(json_res); + } +} + +fn is_partial_match( + mut local_bytecode: &[u8], + mut bytecode: &[u8], + constructor_args: &[u8], + is_runtime: bool, +) -> bool { + // 1. Check length of constructor args + if constructor_args.is_empty() || is_runtime { + // Assume metadata is at the end of the bytecode + return try_extract_and_compare_bytecode(local_bytecode, bytecode) + } + + // If not runtime, extract constructor args from the end of the bytecode + bytecode = &bytecode[..bytecode.len() - constructor_args.len()]; + local_bytecode = &local_bytecode[..local_bytecode.len() - constructor_args.len()]; + + try_extract_and_compare_bytecode(local_bytecode, bytecode) +} + +fn try_extract_and_compare_bytecode(mut local_bytecode: &[u8], mut bytecode: &[u8]) -> bool { + local_bytecode = extract_metadata_hash(local_bytecode); + bytecode = extract_metadata_hash(bytecode); + + // Now compare the local code and bytecode + local_bytecode == bytecode +} + +/// @dev This assumes that the metadata is at the end of the bytecode +fn extract_metadata_hash(bytecode: &[u8]) -> &[u8] { + // Get the last two bytes of the bytecode to find the length of CBOR metadata + let metadata_len = &bytecode[bytecode.len() - 2..]; + let metadata_len = u16::from_be_bytes([metadata_len[0], metadata_len[1]]); + + if metadata_len as usize <= bytecode.len() { + if ciborium::from_reader::( + &bytecode[bytecode.len() - 2 - metadata_len as usize..bytecode.len() - 2], + ) + .is_ok() + { + &bytecode[..bytecode.len() - 2 - metadata_len as usize] + } else { + bytecode + } + } else { + bytecode + } +} + +fn find_mismatch_in_settings( + etherscan_settings: &Metadata, + local_settings: &Config, +) -> Vec { + let mut mismatches: Vec = vec![]; + if etherscan_settings.evm_version != local_settings.evm_version.to_string().to_lowercase() { + let str = format!( + "EVM version mismatch: local={}, onchain={}", + local_settings.evm_version, etherscan_settings.evm_version + ); + mismatches.push(str); + } + let local_optimizer: u64 = if local_settings.optimizer { 1 } else { 0 }; + if etherscan_settings.optimization_used != local_optimizer { + let str = format!( + "Optimizer mismatch: local={}, onchain={}", + local_settings.optimizer, etherscan_settings.optimization_used + ); + mismatches.push(str); + } + if etherscan_settings.runs != local_settings.optimizer_runs as u64 { + let str = format!( + "Optimizer runs mismatch: local={}, onchain={}", + local_settings.optimizer_runs, etherscan_settings.runs + ); + mismatches.push(str); + } + + mismatches +} + +pub fn maybe_predeploy_contract( + creation_data: Result, +) -> Result<(Option, bool), eyre::ErrReport> { + let mut maybe_predeploy = false; + match creation_data { + Ok(creation_data) => Ok((Some(creation_data), maybe_predeploy)), + // Ref: https://explorer.mode.network/api?module=contract&action=getcontractcreation&contractaddresses=0xC0d3c0d3c0D3c0d3C0D3c0D3C0d3C0D3C0D30010 + Err(EtherscanError::EmptyResult { status, message }) + if status == "1" && message == "OK" => + { + maybe_predeploy = true; + Ok((None, maybe_predeploy)) + } + // Ref: https://api.basescan.org/api?module=contract&action=getcontractcreation&contractaddresses=0xC0d3c0d3c0D3c0d3C0D3c0D3C0d3C0D3C0D30010&apiKey=YourAPIKey + Err(EtherscanError::Serde { error: _, content }) if content.contains("GENESIS") => { + maybe_predeploy = true; + Ok((None, maybe_predeploy)) + } + Err(e) => eyre::bail!("Error fetching creation data from verifier-url: {:?}", e), + } +} + +pub fn check_and_encode_args( + artifact: &CompactContractBytecode, + args: Vec, +) -> Result, eyre::ErrReport> { + if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) { + if constructor.inputs.len() != args.len() { + eyre::bail!( + "Mismatch of constructor arguments length. Expected {}, got {}", + constructor.inputs.len(), + args.len() + ); + } + encode_args(&constructor.inputs, &args).map(|args| DynSolValue::Tuple(args).abi_encode()) + } else { + Ok(Vec::new()) + } +} + +pub fn check_explorer_args(source_code: ContractMetadata) -> Result { + if let Some(args) = source_code.items.first() { + Ok(args.constructor_arguments.clone()) + } else { + eyre::bail!("No constructor arguments found from block explorer"); + } +} + +pub async fn get_tracing_executor( + fork_config: &mut Config, + fork_blk_num: u64, + evm_version: EvmVersion, + evm_opts: EvmOpts, +) -> Result<(Env, TracingExecutor)> { + fork_config.fork_block_number = Some(fork_blk_num); + fork_config.evm_version = evm_version; + + let (env, fork, _chain, is_alphanet) = + TracingExecutor::get_fork_material(fork_config, evm_opts).await?; + + let executor = TracingExecutor::new( + env.clone(), + fork, + Some(fork_config.evm_version), + false, + false, + is_alphanet, + ); + + Ok((env, executor)) +} + +pub fn configure_env_block(env: &mut Env, block: &Block) { + env.block.timestamp = U256::from(block.header.timestamp); + env.block.coinbase = block.header.miner; + env.block.difficulty = block.header.difficulty; + env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); + env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); + env.block.gas_limit = U256::from(block.header.gas_limit); +} + +pub fn deploy_contract( + executor: &mut TracingExecutor, + env: &Env, + spec_id: SpecId, + transaction: &Transaction, +) -> Result { + let env_with_handler = EnvWithHandlerCfg::new(Box::new(env.clone()), HandlerCfg::new(spec_id)); + + if let Some(to) = transaction.to { + if to != DEFAULT_CREATE2_DEPLOYER { + eyre::bail!("Transaction `to` address is not the default create2 deployer i.e the tx is not a contract creation tx."); + } + let result = executor.transact_with_env(env_with_handler)?; + + trace!(transact_result = ?result.exit_reason); + if result.result.len() != 20 { + eyre::bail!( + "Failed to deploy contract on fork at block: call result is not exactly 20 bytes" + ); + } + + Ok(Address::from_slice(&result.result)) + } else { + let deploy_result = executor.deploy_with_env(env_with_handler, None)?; + trace!(deploy_result = ?deploy_result.raw.exit_reason); + Ok(deploy_result.address) + } +} + +pub async fn get_runtime_codes( + executor: &mut TracingExecutor, + provider: &RetryProvider, + address: Address, + fork_address: Address, + block: Option, +) -> Result<(Bytecode, Bytes)> { + let fork_runtime_code = executor + .backend_mut() + .basic(fork_address)? + .ok_or_else(|| { + eyre::eyre!( + "Failed to get runtime code for contract deployed on fork at address {}", + fork_address + ) + })? + .code + .ok_or_else(|| { + eyre::eyre!( + "Bytecode does not exist for contract deployed on fork at address {}", + fork_address + ) + })?; + + let onchain_runtime_code = if let Some(block) = block { + provider.get_code_at(address).block_id(BlockId::number(block)).await? + } else { + provider.get_code_at(address).await? + }; + + Ok((fork_runtime_code, onchain_runtime_code)) +} + +/// Returns `true` if the URL only consists of host. +/// +/// This is used to check user input url for missing /api path +#[inline] +pub fn is_host_only(url: &Url) -> bool { + matches!(url.path(), "/" | "") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_host_only() { + assert!(!is_host_only(&Url::parse("https://blockscout.net/api").unwrap())); + assert!(is_host_only(&Url::parse("https://blockscout.net/").unwrap())); + assert!(is_host_only(&Url::parse("https://blockscout.net").unwrap())); + } +} diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs new file mode 100644 index 0000000000000..4a3abaa36cdc7 --- /dev/null +++ b/crates/verify/src/verify.rs @@ -0,0 +1,367 @@ +//! The `forge verify-bytecode` command. + +use crate::{ + etherscan::EtherscanVerificationProvider, + provider::{VerificationProvider, VerificationProviderType}, + utils::is_host_only, + RetryArgs, +}; +use alloy_primitives::Address; +use alloy_provider::Provider; +use clap::{Parser, ValueHint}; +use eyre::Result; +use foundry_cli::{ + opts::{EtherscanOpts, RpcOpts}, + utils::{self, LoadConfig}, +}; +use foundry_common::{compile::ProjectCompiler, ContractsByArtifact}; +use foundry_compilers::{artifacts::EvmVersion, compilers::solc::Solc, info::ContractInfo}; +use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, Config, SolcReq}; +use itertools::Itertools; +use reqwest::Url; +use revm_primitives::HashSet; +use std::path::PathBuf; + +use crate::provider::VerificationContext; + +/// Verification provider arguments +#[derive(Clone, Debug, Parser)] +pub struct VerifierArgs { + /// The contract verification provider to use. + #[arg(long, help_heading = "Verifier options", default_value = "etherscan", value_enum)] + pub verifier: VerificationProviderType, + + /// The verifier URL, if using a custom provider + #[arg(long, help_heading = "Verifier options", env = "VERIFIER_URL")] + pub verifier_url: Option, +} + +impl Default for VerifierArgs { + fn default() -> Self { + Self { verifier: VerificationProviderType::Etherscan, verifier_url: None } + } +} + +/// CLI arguments for `forge verify`. +#[derive(Clone, Debug, Parser)] +pub struct VerifyArgs { + /// The address of the contract to verify. + pub address: Address, + + /// The contract identifier in the form `:`. + pub contract: Option, + + /// The ABI-encoded constructor arguments. + #[arg( + long, + conflicts_with = "constructor_args_path", + value_name = "ARGS", + visible_alias = "encoded-constructor-args" + )] + pub constructor_args: Option, + + /// The path to a file containing the constructor arguments. + #[arg(long, value_hint = ValueHint::FilePath, value_name = "PATH")] + pub constructor_args_path: Option, + + /// Try to extract constructor arguments from on-chain creation code. + #[arg(long)] + pub guess_constructor_args: bool, + + /// The `solc` version to use to build the smart contract. + #[arg(long, value_name = "VERSION")] + pub compiler_version: Option, + + /// The number of optimization runs used to build the smart contract. + #[arg(long, visible_alias = "optimizer-runs", value_name = "NUM")] + pub num_of_optimizations: Option, + + /// Flatten the source code before verifying. + #[arg(long)] + pub flatten: bool, + + /// Do not compile the flattened smart contract before verifying (if --flatten is passed). + #[arg(short, long)] + pub force: bool, + + /// Do not check if the contract is already verified before verifying. + #[arg(long)] + pub skip_is_verified_check: bool, + + /// Wait for verification result after submission. + #[arg(long)] + pub watch: bool, + + /// Set pre-linked libraries. + #[arg(long, help_heading = "Linker options", env = "DAPP_LIBRARIES")] + pub libraries: Vec, + + /// The project's root path. + /// + /// By default root of the Git repository, if in one, + /// or the current working directory. + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + pub root: Option, + + /// Prints the standard json compiler input. + /// + /// The standard json compiler input can be used to manually submit contract verification in + /// the browser. + #[arg(long, conflicts_with = "flatten")] + pub show_standard_json_input: bool, + + /// Use the Yul intermediate representation compilation pipeline. + #[arg(long)] + pub via_ir: bool, + + /// The EVM version to use. + /// + /// Overrides the version specified in the config. + #[arg(long)] + pub evm_version: Option, + + #[command(flatten)] + pub etherscan: EtherscanOpts, + + #[command(flatten)] + pub rpc: RpcOpts, + + #[command(flatten)] + pub retry: RetryArgs, + + #[command(flatten)] + pub verifier: VerifierArgs, +} + +impl_figment_convert!(VerifyArgs); + +impl figment::Provider for VerifyArgs { + fn metadata(&self) -> figment::Metadata { + figment::Metadata::named("Verify Provider") + } + + fn data( + &self, + ) -> Result, figment::Error> { + let mut dict = self.etherscan.dict(); + dict.extend(self.rpc.dict()); + + if let Some(root) = self.root.as_ref() { + dict.insert("root".to_string(), figment::value::Value::serialize(root)?); + } + if let Some(optimizer_runs) = self.num_of_optimizations { + dict.insert("optimizer".to_string(), figment::value::Value::serialize(true)?); + dict.insert( + "optimizer_runs".to_string(), + figment::value::Value::serialize(optimizer_runs)?, + ); + } + if let Some(evm_version) = self.evm_version { + dict.insert("evm_version".to_string(), figment::value::Value::serialize(evm_version)?); + } + if self.via_ir { + dict.insert("via_ir".to_string(), figment::value::Value::serialize(self.via_ir)?); + } + Ok(figment::value::Map::from([(Config::selected_profile(), dict)])) + } +} + +impl VerifyArgs { + /// Run the verify command to submit the contract's source code for verification on etherscan + pub async fn run(mut self) -> Result<()> { + let config = self.load_config_emit_warnings(); + + if self.guess_constructor_args && config.get_rpc_url().is_none() { + eyre::bail!( + "You have to provide a valid RPC URL to use --guess-constructor-args feature" + ) + } + + // If chain is not set, we try to get it from the RPC. + // If RPC is not set, the default chain is used. + let chain = match config.get_rpc_url() { + Some(_) => { + let provider = utils::get_provider(&config)?; + utils::get_chain(config.chain, provider).await? + } + None => config.chain.unwrap_or_default(), + }; + + let context = self.resolve_context().await?; + + // Set Etherscan options. + self.etherscan.chain = Some(chain); + self.etherscan.key = config.get_etherscan_config_with_chain(Some(chain))?.map(|c| c.key); + + if self.show_standard_json_input { + let args = EtherscanVerificationProvider::default() + .create_verify_request(&self, &context) + .await?; + println!("{}", args.source); + return Ok(()) + } + + let verifier_url = self.verifier.verifier_url.clone(); + println!("Start verifying contract `{}` deployed on {chain}", self.address); + self.verifier.verifier.client(&self.etherscan.key())?.verify(self, context).await.map_err(|err| { + if let Some(verifier_url) = verifier_url { + match Url::parse(&verifier_url) { + Ok(url) => { + if is_host_only(&url) { + return err.wrap_err(format!( + "Provided URL `{verifier_url}` is host only.\n Did you mean to use the API endpoint`{verifier_url}/api` ?" + )) + } + } + Err(url_err) => { + return err.wrap_err(format!( + "Invalid URL {verifier_url} provided: {url_err}" + )) + } + } + } + + err + }) + } + + /// Returns the configured verification provider + pub fn verification_provider(&self) -> Result> { + self.verifier.verifier.client(&self.etherscan.key()) + } + + /// Resolves [VerificationContext] object either from entered contract name or by trying to + /// match bytecode located at given address. + pub async fn resolve_context(&self) -> Result { + let mut config = self.load_config_emit_warnings(); + config.libraries.extend(self.libraries.clone()); + + let project = config.project()?; + + if let Some(ref contract) = self.contract { + let contract_path = if let Some(ref path) = contract.path { + project.root().join(PathBuf::from(path)) + } else { + project.find_contract_path(&contract.name)? + }; + + let version = if let Some(ref version) = self.compiler_version { + version.trim_start_matches('v').parse()? + } else if let Some(ref solc) = config.solc { + match solc { + SolcReq::Version(version) => version.to_owned(), + SolcReq::Local(solc) => Solc::new(solc)?.version, + } + } else if let Some(entry) = project + .read_cache_file() + .ok() + .and_then(|mut cache| cache.files.remove(&contract_path)) + { + let unique_versions = entry + .artifacts + .get(&contract.name) + .map(|artifacts| artifacts.keys().collect::>()) + .unwrap_or_default(); + + if unique_versions.is_empty() { + eyre::bail!("No matching artifact found for {}", contract.name); + } else if unique_versions.len() > 1 { + warn!( + "Ambiguous compiler versions found in cache: {}", + unique_versions.iter().join(", ") + ); + eyre::bail!("Compiler version has to be set in `foundry.toml`. If the project was not deployed with foundry, specify the version through `--compiler-version` flag.") + } + + unique_versions.into_iter().next().unwrap().to_owned() + } else { + eyre::bail!("If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml") + }; + + VerificationContext::new(contract_path, contract.name.clone(), version, config) + } else { + if config.get_rpc_url().is_none() { + eyre::bail!("You have to provide a contract name or a valid RPC URL") + } + let provider = utils::get_provider(&config)?; + let code = provider.get_code_at(self.address).await?; + + let output = ProjectCompiler::new().compile(&project)?; + let contracts = ContractsByArtifact::new( + output.artifact_ids().map(|(id, artifact)| (id, artifact.clone().into())), + ); + + let Some((artifact_id, _)) = contracts.find_by_deployed_code_exact(&code) else { + eyre::bail!(format!( + "Bytecode at {} does not match any local contracts", + self.address + )) + }; + + VerificationContext::new( + artifact_id.source.clone(), + artifact_id.name.split('.').next().unwrap().to_owned(), + artifact_id.version.clone(), + config, + ) + } + } +} + +/// Check verification status arguments +#[derive(Clone, Debug, Parser)] +pub struct VerifyCheckArgs { + /// The verification ID. + /// + /// For Etherscan - Submission GUID. + /// + /// For Sourcify - Contract Address. + pub id: String, + + #[command(flatten)] + pub retry: RetryArgs, + + #[command(flatten)] + pub etherscan: EtherscanOpts, + + #[command(flatten)] + pub verifier: VerifierArgs, +} + +impl_figment_convert_cast!(VerifyCheckArgs); + +impl VerifyCheckArgs { + /// Run the verify command to submit the contract's source code for verification on etherscan + pub async fn run(self) -> Result<()> { + println!("Checking verification status on {}", self.etherscan.chain.unwrap_or_default()); + self.verifier.verifier.client(&self.etherscan.key())?.check(self).await + } +} + +impl figment::Provider for VerifyCheckArgs { + fn metadata(&self) -> figment::Metadata { + figment::Metadata::named("Verify Check Provider") + } + + fn data( + &self, + ) -> Result, figment::Error> { + self.etherscan.data() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn can_parse_verify_contract() { + let args: VerifyArgs = VerifyArgs::parse_from([ + "foundry-cli", + "0x0000000000000000000000000000000000000000", + "src/Domains.sol:Domains", + "--via-ir", + ]); + assert!(args.via_ir); + } +} From ddb49a40305a9b10f0be97efae7f0c66bf720e13 Mon Sep 17 00:00:00 2001 From: justinmoore-next Date: Wed, 21 Aug 2024 23:37:56 +0800 Subject: [PATCH 1368/1963] feat(cast): add `cast hash-message` (#8706) * feat(cast): add `cast hash-message` * Update crates/cast/bin/opts.rs --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/bin/main.rs | 10 +++++++++- crates/cast/bin/opts.rs | 7 +++++++ crates/cast/tests/cli/main.rs | 11 +++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 8bc0b986632b3..c3bd5039f3762 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{hex, keccak256, Address, B256}; +use alloy_primitives::{eip191_hash_message, hex, keccak256, Address, B256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, BlockNumberOrTag::Latest}; use cast::{Cast, SimpleCast}; @@ -515,6 +515,14 @@ async fn main() -> Result<()> { } }; } + CastSubcommand::HashMessage { message } => { + let message = stdin::unwrap_line(message)?; + let input = match message.strip_prefix("0x") { + Some(hex_str) => hex::decode(hex_str)?, + None => message.as_bytes().to_vec(), + }; + println!("{}", eip191_hash_message(input)); + } CastSubcommand::SigEvent { event_string } => { let event_string = stdin::unwrap_line(event_string)?; let parsed_event = get_event(&event_string)?; diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/opts.rs index 395b4fe2792f8..7274585059684 100644 --- a/crates/cast/bin/opts.rs +++ b/crates/cast/bin/opts.rs @@ -754,6 +754,13 @@ pub enum CastSubcommand { data: Option, }, + /// Hash a message according to EIP-191. + #[command(visible_aliases = &["--hash-message", "hm"])] + HashMessage { + /// The message to hash. + message: Option, + }, + /// Perform an ENS lookup. #[command(visible_alias = "rn")] ResolveName { diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index d0ff5a88124bb..fcbeaf4226775 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1057,3 +1057,14 @@ casttest!(send_eip7702, async |_prj, cmd| { "#]]); }); + +casttest!(hash_message, |_prj, cmd| { + let tests = [ + ("hello", "0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750"), + ("0x68656c6c6f", "0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750"), + ]; + for (message, expected) in tests { + cmd.cast_fuse(); + assert_eq!(cmd.args(["hash-message", message]).stdout_lossy().trim(), expected); + } +}); From 503fbeefe3e10ce624ed5ef80da029aa6bb7eab6 Mon Sep 17 00:00:00 2001 From: James Kim Date: Wed, 21 Aug 2024 16:15:43 -0400 Subject: [PATCH 1369/1963] fix(anvil): for deposit transactions apply tx.mint value in tx validation (#8704) * apply mint value before checking sufficient funds conditions * remove comment * update log * add docs link * add docs link --- .../core/src/eth/transaction/optimism.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 34 +++++-- crates/anvil/tests/it/optimism.rs | 89 ++++++++++--------- 3 files changed, 74 insertions(+), 51 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index fb987ae3d059f..5c4f354810113 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -268,7 +268,7 @@ impl DepositTransaction { None } - pub(crate) fn encode_2718(&self, out: &mut dyn alloy_rlp::BufMut) { + pub fn encode_2718(&self, out: &mut dyn alloy_rlp::BufMut) { out.put_u8(DEPOSIT_TX_TYPE_ID); self.encode(out); } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 5180e4a0484d1..a089a9d2b8b71 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2573,16 +2573,32 @@ impl TransactionValidator for Backend { let max_cost = tx.max_cost(); let value = tx.value(); - // check sufficient funds: `gas * price + value` - let req_funds = max_cost.checked_add(value.to()).ok_or_else(|| { - warn!(target: "backend", "[{:?}] cost too high", - tx.hash()); - InvalidTransactionError::InsufficientFunds - })?; - if account.balance < U256::from(req_funds) { - warn!(target: "backend", "[{:?}] insufficient allowance={}, required={} account={:?}", tx.hash(), account.balance, req_funds, *pending.sender()); - return Err(InvalidTransactionError::InsufficientFunds); + + match &tx.transaction { + TypedTransaction::Deposit(deposit_tx) => { + // Deposit transactions + // https://specs.optimism.io/protocol/deposits.html#execution + // 1. no gas cost check required since already have prepaid gas from L1 + // 2. increment account balance by deposited amount before checking for sufficient + // funds `tx.value <= existing account value + deposited value` + if value > account.balance + deposit_tx.mint { + warn!(target: "backend", "[{:?}] insufficient balance={}, required={} account={:?}", tx.hash(), account.balance + deposit_tx.mint, value, *pending.sender()); + return Err(InvalidTransactionError::InsufficientFunds); + } + } + _ => { + // check sufficient funds: `gas * price + value` + let req_funds = max_cost.checked_add(value.to()).ok_or_else(|| { + warn!(target: "backend", "[{:?}] cost too high", tx.hash()); + InvalidTransactionError::InsufficientFunds + })?; + if account.balance < U256::from(req_funds) { + warn!(target: "backend", "[{:?}] insufficient allowance={}, required={} account={:?}", tx.hash(), account.balance, req_funds, *pending.sender()); + return Err(InvalidTransactionError::InsufficientFunds); + } + } } + Ok(()) } diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 8e23d7ded8f62..f5f4a41ca7fa8 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -1,13 +1,14 @@ //! Tests for OP chain support. -use crate::utils::http_provider_with_signer; +use crate::utils::{http_provider, http_provider_with_signer}; use alloy_eips::eip2718::Encodable2718; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{b256, Address, TxHash, U256}; +use alloy_primitives::{b256, Address, TxHash, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest}; use alloy_serde::WithOtherFields; use anvil::{spawn, Hardfork, NodeConfig}; +use anvil_core::eth::transaction::optimism::DepositTransaction; #[tokio::test(flavor = "multi_thread")] async fn test_deposits_not_supported_if_optimism_disabled() { @@ -148,13 +149,11 @@ async fn test_send_value_raw_deposit_transaction() { #[tokio::test(flavor = "multi_thread")] async fn test_deposit_transaction_hash_matches_sepolia() { // enable the Optimism flag - let (api, handle) = + let (_api, handle) = spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; let accounts: Vec<_> = handle.dev_wallets().collect(); let signer: EthereumWallet = accounts[0].clone().into(); - let sender_addr = accounts[0].address(); - // https://sepolia-optimism.etherscan.io/tx/0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7 let tx_hash: TxHash = "0xbf8b5f08c43e4b860715cd64fc0849bbce0d0ea20a76b269e7bc8886d112fca7" .parse::() @@ -165,52 +164,60 @@ async fn test_deposit_transaction_hash_matches_sepolia() { "7ef861a0dfd7ae78bf3c414cfaa77f13c0205c82eb9365e217b2daa3448c3156b69b27ac94778f2146f48179643473b82931c4cd7b8f153efd94778f2146f48179643473b82931c4cd7b8f153efd872386f26fc10000872386f26fc10000830186a08080", ) .unwrap(); - let deposit_tx_from = "0x778F2146F48179643473B82931c4CD7B8F153eFd".parse::
().unwrap(); let provider = http_provider_with_signer(&handle.http_endpoint(), signer.clone()); - // TODO: necessary right now because transaction validation fails for deposit tx - // with `from` account that doesn't have sufficient ETH balance. - // Should update the tx validation logic for deposit tx to - // 1. check if `tx.value > account.balance + tx.mint` - // 2. don't check `account.balance > gas * price + value` (the gas costs have been prepaid on - // L1) - // source: https://specs.optimism.io/protocol/deposits.html#execution - let fund_account_tx = TransactionRequest::default() - .with_chain_id(31337) - .with_nonce(0) - .with_from(sender_addr) - .with_to(deposit_tx_from) - .with_value(U256::from(1e18)) - .with_gas_limit(21_000) - .with_max_fee_per_gas(20_000_000_000) - .with_max_priority_fee_per_gas(1_000_000_000); - - provider - .send_transaction(WithOtherFields::new(fund_account_tx)) + let receipt = provider + .send_raw_transaction(raw_deposit_tx.as_slice()) .await .unwrap() - .register() + .get_receipt() .await .unwrap(); - // mine block - api.evm_mine(None).await.unwrap(); + assert_eq!(receipt.transaction_hash, tx_hash); +} - let pending = provider - .send_raw_transaction(raw_deposit_tx.as_slice()) - .await - .unwrap() - .register() - .await - .unwrap(); +#[tokio::test(flavor = "multi_thread")] +async fn test_deposit_tx_checks_sufficient_funds_after_applying_deposited_value() { + // enable the Optimism flag + let (_api, handle) = + spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; - // mine block - api.evm_mine(None).await.unwrap(); + let provider = http_provider(&handle.http_endpoint()); - let receipt = - provider.get_transaction_receipt(pending.tx_hash().to_owned()).await.unwrap().unwrap(); + let sender = Address::random(); + let recipient = Address::random(); + let send_value = 1_000_000_000_u128; - assert_eq!(pending.tx_hash(), &tx_hash); - assert_eq!(receipt.transaction_hash, tx_hash); + let sender_prev_balance = provider.get_balance(sender).await.unwrap(); + assert_eq!(sender_prev_balance, U256::from(0)); + + let recipient_prev_balance = provider.get_balance(recipient).await.unwrap(); + assert_eq!(recipient_prev_balance, U256::from(0)); + + let deposit_tx = DepositTransaction { + source_hash: b256!("0000000000000000000000000000000000000000000000000000000000000000"), + from: sender, + nonce: 0, + kind: TxKind::Call(recipient), + mint: U256::from(send_value), + value: U256::from(send_value), + gas_limit: 21_000, + is_system_tx: false, + input: Vec::new().into(), + }; + + let mut tx_buffer = Vec::new(); + deposit_tx.encode_2718(&mut tx_buffer); + + provider.send_raw_transaction(&tx_buffer).await.unwrap().get_receipt().await.unwrap(); + + let sender_new_balance = provider.get_balance(sender).await.unwrap(); + // sender should've sent the entire deposited value to recipient + assert_eq!(sender_new_balance, U256::from(0)); + + let recipient_new_balance = provider.get_balance(recipient).await.unwrap(); + // recipient should've received the entire deposited value + assert_eq!(recipient_new_balance, U256::from(send_value)); } From fa0e0c2ca3ae75895dd19173a02faf88509c0608 Mon Sep 17 00:00:00 2001 From: Juan Pablo Villaplana Corrales Date: Wed, 21 Aug 2024 15:03:04 -0600 Subject: [PATCH 1370/1963] =?UTF-8?q?Issue=20#8664=20|=20Bug=20?= =?UTF-8?q?=F0=9F=90=9B:=20--match-path=20does=20not=20work=20with=20watch?= =?UTF-8?q?=20mode:=20cannot=20be=20used=20multiple=20times=20#8664=20(#87?= =?UTF-8?q?09)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Issue #8664 | Bug 🐛: --match-path does not work with watch mode: cannot be used multiple times #8664 * reuse _no_reconfigure var * Remove undescore var name and also remove no needed extra lines * fmt --------- Co-authored-by: Arsenii Kulikov --- crates/forge/bin/cmd/watch.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 09eb8c66683bd..10562ba1295c5 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -260,7 +260,7 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { let config: Config = args.build_args().into(); let filter = args.filter(&config); // Marker to check whether to override the command. - let _no_reconfigure = filter.args().test_pattern.is_some() || + let no_reconfigure = filter.args().test_pattern.is_some() || filter.args().path_pattern.is_some() || filter.args().contract_pattern.is_some() || args.watch.run_all; @@ -303,7 +303,10 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { trace!(?file, "reconfigure test command"); - command.arg("--match-path").arg(&file); + // Before appending `--match-path`, check if it already exists + if !no_reconfigure { + command.arg("--match-path").arg(file); + } }, )?; run(config).await?; From 41cddf7b438068ca5fa9fa9ad9deda678c444a67 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 22 Aug 2024 06:40:32 +0300 Subject: [PATCH 1371/1963] chore: move more tests to snapbox (#8708) --- crates/forge/tests/cli/build.rs | 31 +++- crates/forge/tests/cli/cmd.rs | 124 ++++++++++------ crates/forge/tests/cli/config.rs | 18 ++- crates/forge/tests/cli/script.rs | 111 +++++++++++---- crates/forge/tests/cli/test_cmd.rs | 134 +++++++++++------- .../can_build_path_with_one_file.stdout | 3 - .../can_build_path_with_three_files.stdout | 3 - .../can_build_path_with_two_files.stdout | 3 - .../fixtures/can_build_skip_contracts.stdout | 3 - .../tests/fixtures/can_build_skip_glob.stdout | 3 - .../tests/fixtures/can_check_snapshot.stdout | 9 -- ...can_detect_dirty_git_status_on_init.stderr | 10 -- ...n_execute_script_and_skip_contracts.stdout | 12 -- .../can_execute_script_command.stdout | 8 -- .../can_execute_script_command_fqn.stdout | 8 -- ...an_execute_script_command_with_args.stdout | 10 -- ...xecute_script_command_with_returned.stdout | 12 -- ...can_execute_script_command_with_sig.stdout | 8 -- .../can_run_test_in_custom_test_folder.stdout | 9 -- .../fixtures/can_set_yul_optimizer.stderr | 8 -- .../can_use_libs_in_multi_fork.stdout | 9 -- .../forge/tests/fixtures/compile_json.stdout | 20 --- .../include_custom_types_in_traces.stdout | 25 ---- .../fixtures/replay_last_run_failures.stdout | 15 -- crates/forge/tests/fixtures/repro_6531.stdout | 17 --- ...xactly_once_with_changed_versions.1.stdout | 9 -- ...xactly_once_with_changed_versions.2.stdout | 9 -- 27 files changed, 283 insertions(+), 348 deletions(-) delete mode 100644 crates/forge/tests/fixtures/can_build_path_with_one_file.stdout delete mode 100644 crates/forge/tests/fixtures/can_build_path_with_three_files.stdout delete mode 100644 crates/forge/tests/fixtures/can_build_path_with_two_files.stdout delete mode 100644 crates/forge/tests/fixtures/can_build_skip_contracts.stdout delete mode 100644 crates/forge/tests/fixtures/can_build_skip_glob.stdout delete mode 100644 crates/forge/tests/fixtures/can_check_snapshot.stdout delete mode 100644 crates/forge/tests/fixtures/can_detect_dirty_git_status_on_init.stderr delete mode 100644 crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout delete mode 100644 crates/forge/tests/fixtures/can_execute_script_command.stdout delete mode 100644 crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout delete mode 100644 crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout delete mode 100644 crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout delete mode 100644 crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout delete mode 100644 crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout delete mode 100644 crates/forge/tests/fixtures/can_set_yul_optimizer.stderr delete mode 100644 crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout delete mode 100644 crates/forge/tests/fixtures/compile_json.stdout delete mode 100644 crates/forge/tests/fixtures/include_custom_types_in_traces.stdout delete mode 100644 crates/forge/tests/fixtures/replay_last_run_failures.stdout delete mode 100644 crates/forge/tests/fixtures/repro_6531.stdout delete mode 100644 crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout delete mode 100644 crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 6cb17d0d4872b..779c7aa076286 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -1,5 +1,5 @@ use foundry_config::Config; -use foundry_test_utils::{file, forgetest, str}; +use foundry_test_utils::{forgetest, str}; use globset::Glob; // tests that json is printed when --json is passed @@ -18,9 +18,32 @@ contract Dummy { .unwrap(); // set up command - cmd.args(["compile", "--format-json"]) - .assert() - .stdout_eq(file!["../fixtures/compile_json.stdout": Json]); + cmd.args(["compile", "--format-json"]).assert_success().stdout_eq(str![[r#" +... +{ + "errors": [ + { + "sourceLocation": { + "file": "src/jsonError.sol", + "start": 184, + "end": 193 + }, + "type": "DeclarationError", + "component": "general", + "severity": "error", + "errorCode": "7576", + "message": "Undeclared identifier. Did you mean /"newNumber/"?", + "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean /"newNumber/"?/n --> src/jsonError.sol:7:18:/n |/n7 | number = newnumber; // error here/n | ^^^^^^^^^/n/n" + } + ], + "sources": {}, + "contracts": {}, + "build_infos": [ + { +... +} +... +"#]]); }); // tests build output is as expected diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 23cb3ca8a0f74..cdfd90a732f8f 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -13,8 +13,8 @@ use foundry_test_utils::{ }; use semver::Version; use std::{ - env, fs, - path::{Path, PathBuf}, + fs, + path::Path, process::{Command, Stdio}, str::FromStr, }; @@ -234,11 +234,20 @@ forgetest!(can_detect_dirty_git_status_on_init, |prj, cmd| { fs::create_dir_all(&nested).unwrap(); cmd.current_dir(&nested); - cmd.arg("init"); - cmd.unchecked_output().stderr_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_detect_dirty_git_status_on_init.stderr"), - ); + cmd.arg("init").assert_failure().stderr_eq(str![[r#" +... +Error:[..] +The target directory is a part of or on its own an already initialized git repository, +and it requires clean working and staging areas, including no untracked files. + +Check the current git repository's status with `git status`. +Then, you can track files with `git add ...` and then commit them with `git commit`, +ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag. + +If none of the previous steps worked, please open an issue at: +https://github.com/foundry-rs/foundry/issues/new/choose +... +"#]]); // ensure nothing was emitted, dir is empty assert!(!nested.read_dir().map(|mut i| i.next().is_some()).unwrap_or_default()); @@ -748,11 +757,13 @@ contract ATest is DSTest { ) .unwrap(); - cmd.arg("snapshot"); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_check_snapshot.stdout"), - ); + cmd.args(["snapshot"]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/ATest.t.sol:ATest +[PASS] testExample() (gas: 168) +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in [..] +... +"#]]); cmd.arg("--check"); let _ = cmd.output(); @@ -1646,11 +1657,15 @@ forgetest_init!(can_build_skip_contracts, |prj, cmd| { prj.clear(); // only builds the single template contract `src/*` - cmd.args(["build", "--skip", "tests", "--skip", "scripts"]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_build_skip_contracts.stdout"), - ); + cmd.args(["build", "--skip", "tests", "--skip", "scripts"]).assert_success().stdout_eq(str![[ + r#" +... +Compiling 1 files [..] +[..] +Compiler run successful! +... +"# + ]]); // re-run command let out = cmd.stdout_lossy(); @@ -1671,15 +1686,26 @@ function test_run() external {} // only builds the single template contract `src/*` even if `*.t.sol` or `.s.sol` is absent prj.clear(); - cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**", "--force"]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_build_skip_glob.stdout"), - ); + cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**", "--force"]) + .assert_success() + .stdout_eq(str![[r#" +... +Compiling 1 files [..] +[..] +Compiler run successful! +... +"#]]); - cmd.forge_fuse().args(["build", "--skip", "./test/**", "--skip", "./script/**", "--force"]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/can_build_skip_glob.stdout"), - ); + cmd.forge_fuse() + .args(["build", "--skip", "./test/**", "--skip", "./script/**", "--force"]) + .assert_success() + .stdout_eq(str![[r#" +... +Compiling 1 files [..] +[..] +Compiler run successful! +... +"#]]); }); forgetest_init!(can_build_specific_paths, |prj, cmd| { @@ -1711,38 +1737,46 @@ function test_bar() external {} // Build 2 files within test dir prj.clear(); - cmd.args(["build", "test", "--force"]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_build_path_with_two_files.stdout"), - ); + cmd.args(["build", "test", "--force"]).assert_success().stdout_eq(str![[r#" +... +Compiling 2 files with Solc 0.8.23 +[..] +Compiler run successful! +... +"#]]); // Build one file within src dir prj.clear(); cmd.forge_fuse(); - cmd.args(["build", "src", "--force"]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_build_path_with_one_file.stdout"), - ); + cmd.args(["build", "src", "--force"]).assert_success().stdout_eq(str![[r#" +... +Compiling 1 files with Solc 0.8.23 +[..] +Compiler run successful! +... +"#]]); // Build 3 files from test and src dirs prj.clear(); cmd.forge_fuse(); - cmd.args(["build", "src", "test", "--force"]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_build_path_with_three_files.stdout"), - ); + cmd.args(["build", "src", "test", "--force"]).assert_success().stdout_eq(str![[r#" +... +Compiling 3 files with Solc 0.8.23 +[..] +Compiler run successful! +... +"#]]); // Build single test file prj.clear(); cmd.forge_fuse(); - cmd.args(["build", "test/Bar.sol", "--force"]); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_build_path_with_one_file.stdout"), - ); + cmd.args(["build", "test/Bar.sol", "--force"]).assert_success().stdout_eq(str![[r#" +... +Compiling 1 files with Solc 0.8.23 +[..] +Compiler run successful! +... +"#]]); }); // checks that build --sizes includes all contracts even if unchanged diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 0e38e15e7d87b..78c76a22a8d4d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -14,7 +14,7 @@ use foundry_config::{ use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ foundry_compilers::artifacts::{remappings::Remapping, EvmVersion}, - util::{pretty_err, OutputExt, TestCommand, OTHER_SOLC_VERSION}, + util::{pretty_err, TestCommand, OTHER_SOLC_VERSION}, }; use path_slash::PathBufExt; use similar_asserts::assert_eq; @@ -399,11 +399,17 @@ contract Foo { ) .unwrap(); - cmd.arg("build"); - cmd.unchecked_output().stderr_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_set_yul_optimizer.stderr"), - ); + cmd.arg("build").assert_failure().stderr_eq(str![[r#" +... +Error:[..] +Compiler run failed: +Error (6553): The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. + --> src/foo.sol:6:8: + | +6 | assembly { + | ^ (Relevant source part starts here and spans across multiple lines). +... +"#]]); // disable yul optimizer explicitly let config = Config { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index de3a3b544199c..68ccec8953f7b 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3,7 +3,7 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; -use foundry_test_utils::{rpc, util::OutputExt, ScriptOutcome, ScriptTester}; +use foundry_test_utils::{rpc, ScriptOutcome, ScriptTester}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; @@ -53,11 +53,15 @@ contract Demo { ) .unwrap(); - cmd.arg("script").arg(script); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_execute_script_command.stdout"), - ); + cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" +... +Script ran successfully. +Gas used: 22815 + +== Logs == + script ran +... +"#]]); }); // Tests that the `run` command works correctly when path *and* script name is specified @@ -76,11 +80,17 @@ contract Demo { ) .unwrap(); - cmd.arg("script").arg(format!("{}:Demo", script.display())); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_execute_script_command_fqn.stdout"), - ); + cmd.arg("script").arg(format!("{}:Demo", script.display())).assert_success().stdout_eq(str![[ + r#" +... +Script ran successfully. +Gas used: 22815 + +== Logs == + script ran +... +"# + ]]); }); // Tests that the run command can run arbitrary functions @@ -99,10 +109,16 @@ contract Demo { ) .unwrap(); - cmd.arg("script").arg(script).arg("--sig").arg("myFunction()"); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_execute_script_command_with_sig.stdout"), + cmd.arg("script").arg(script).arg("--sig").arg("myFunction()").assert_success().stdout_eq( + str![[r#" +... +Script ran successfully. +Gas used: 22815 + +== Logs == + script ran +... +"#]], ); }); @@ -272,11 +288,24 @@ contract Demo { ) .unwrap(); - cmd.arg("script").arg(script).arg("--sig").arg("run(uint256,uint256)").arg("1").arg("2"); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_execute_script_command_with_args.stdout"), - ); + cmd.arg("script") + .arg(script) + .arg("--sig") + .arg("run(uint256,uint256)") + .arg("1") + .arg("2") + .assert_success() + .stdout_eq(str![[r#" +... +Script ran successfully. +Gas used: 25301 + +== Logs == + script ran + 1 + 2 +... +"#]]); }); // Tests that the run command can run functions with return values @@ -294,11 +323,20 @@ contract Demo { }"#, ) .unwrap(); - cmd.arg("script").arg(script); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_execute_script_command_with_returned.stdout"), - ); + + cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" +... +Script ran successfully. +Gas used: 22900 + +== Return == +result: uint256 255 +1: uint8 3 + +== Logs == + script ran +... +"#]]); }); forgetest_async!(can_broadcast_script_skipping_simulation, |prj, cmd| { @@ -930,12 +968,23 @@ contract Demo { }"#, ) .unwrap(); - cmd.arg("script").arg(script).args(["--skip", "tests", "--skip", TEMPLATE_CONTRACT]); - - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_execute_script_and_skip_contracts.stdout"), - ); + cmd.arg("script") + .arg(script) + .args(["--skip", "tests", "--skip", TEMPLATE_CONTRACT]) + .assert_success() + .stdout_eq(str![[r#" +... +Script ran successfully. +Gas used: 22900 + +== Return == +result: uint256 255 +1: uint8 3 + +== Logs == + script ran +... +"#]]); }); forgetest_async!(can_run_script_with_empty_setup, |prj, cmd| { diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 97e4c97cfbe62..7c0499916e22d 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -4,7 +4,7 @@ use alloy_primitives::U256; use foundry_config::{Config, FuzzConfig}; use foundry_test_utils::{ rpc, str, - util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, + util::{OTHER_SOLC_VERSION, SOLC_VERSION}, }; use similar_asserts::assert_eq; use std::{path::PathBuf, str::FromStr}; @@ -272,11 +272,12 @@ contract MyTest is DSTest { ) .unwrap(); - cmd.arg("test"); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_run_test_in_custom_test_folder.stdout"), - ); + cmd.arg("test").assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest +[PASS] testTrue() (gas: 168) +... +"#]]); }); // checks that forge test repeatedly produces the same output @@ -325,20 +326,37 @@ contract ContractTest is DSTest { let config = Config { solc: Some(SOLC_VERSION.into()), ..Default::default() }; prj.write_config(config); - cmd.arg("test"); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout"), - ); + cmd.arg("test").assert_success().stdout_eq(str![[r#" +... +Compiling 2 files with Solc 0.8.23 +Solc 0.8.23 finished in [..] +Compiler run successful! + +Ran 1 test for src/Contract.t.sol:ContractTest +[PASS] testExample() (gas: 190) +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in [..] + +Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) +... +"#]]); // pin version let config = Config { solc: Some(OTHER_SOLC_VERSION.into()), ..Default::default() }; prj.write_config(config); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout"), - ); + cmd.forge_fuse().arg("test").assert_success().stdout_eq(str![[r#" +... +Compiling 2 files with Solc 0.8.22 +Solc 0.8.22 finished in [..] +Compiler run successful! + +Ran 1 test for src/Contract.t.sol:ContractTest +[PASS] testExample() (gas: 190) +Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in [..] + +Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) +... +"#]]); }); // tests that libraries are handled correctly in multiforking mode @@ -388,11 +406,12 @@ contract ContractTest is Test { ) .unwrap(); - cmd.arg("test"); - cmd.unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/can_use_libs_in_multi_fork.stdout"), - ); + cmd.arg("test").assert_success().stdout_eq(str![[r#" +... +Ran 1 test for test/Contract.t.sol:ContractTest +[PASS] test() (gas: 70360) +... +"#]]); }); static FAILING_TEST: &str = r#" @@ -453,13 +472,21 @@ contract USDTCallingTest is Test { ) .unwrap(); - let expected = std::fs::read_to_string( - PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/repro_6531.stdout"), - ) - .unwrap() - .replace("", &endpoint); + cmd.args(["test", "-vvvv"]).assert_success().stdout_eq(str![[r#" +... +Compiler run successful! - cmd.args(["test", "-vvvv"]).unchecked_output().stdout_matches_content(&expected); +Ran 1 test for test/Contract.t.sol:USDTCallingTest +[PASS] test() (gas: 9537) +Traces: + [9537] USDTCallingTest::test() + ├─ [0] VM::createSelectFork("[..]") + │ └─ ← [Return] 0 + ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] + │ └─ ← [Return] "Tether USD" + └─ ← [Stop][..] +... +"#]]); }); // @@ -486,10 +513,21 @@ contract CustomTypesTest is Test { ) .unwrap(); - cmd.args(["test", "-vvvv"]).unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/include_custom_types_in_traces.stdout"), - ); + cmd.args(["test", "-vvvv"]).assert_failure().stdout_eq(str![[r#" +... +Ran 2 tests for test/Contract.t.sol:CustomTypesTest +[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) +Traces: + [254] CustomTypesTest::testErr() + └─ ← [Revert] PoolNotInitialized() + +[PASS] testEvent() (gas: 1268) +Traces: + [1268] CustomTypesTest::testEvent() + ├─ emit MyEvent(a: 100) + └─ ← [Stop][..] +... +"#]]); }); forgetest_init!(can_test_selfdestruct_with_isolation, |prj, cmd| { @@ -664,10 +702,12 @@ contract CounterTest is Test { ) .unwrap(); - cmd.args(["test"]); - let (stderr, _) = cmd.unchecked_output_lossy(); // make sure there are only 61 runs (with proptest shrinking same test results in 298 runs) - assert_eq!(extract_number_of_runs(stderr), 61); + cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" +... +[..]testAddOne(uint256) (runs: 61, μ: [..], ~: [..]) +... +"#]]); }); forgetest_init!(should_exit_early_on_invariant_failure, |prj, cmd| { @@ -700,20 +740,14 @@ contract CounterTest is Test { ) .unwrap(); - cmd.args(["test"]); - let (stderr, _) = cmd.unchecked_output_lossy(); // make sure invariant test exit early with 0 runs - assert_eq!(extract_number_of_runs(stderr), 0); + cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" +... +[..]invariant_early_exit() (runs: 0, calls: 0, reverts: 0) +... +"#]]); }); -fn extract_number_of_runs(stderr: String) -> usize { - let runs = stderr.find("runs:").and_then(|start_runs| { - let runs_split = &stderr[start_runs + 6..]; - runs_split.find(',').map(|end_runs| &runs_split[..end_runs]) - }); - runs.unwrap().parse::().unwrap() -} - forgetest_init!(should_replay_failures_only, |prj, cmd| { prj.wipe_contracts(); prj.add_test( @@ -748,11 +782,13 @@ contract ReplayFailuresTest is Test { assert!(prj.root().join("cache/test-failures").exists()); // Perform only the 2 failing tests from last run. - cmd.forge_fuse(); - cmd.args(["test", "--rerun"]).unchecked_output().stdout_matches_path( - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/replay_last_run_failures.stdout"), - ); + cmd.forge_fuse().args(["test", "--rerun"]).assert_failure().stdout_eq(str![[r#" +... +Ran 2 tests for test/ReplayFailures.t.sol:ReplayFailuresTest +[FAIL. Reason: revert: testB failed] testB() (gas: 303) +[FAIL. Reason: revert: testD failed] testD() (gas: 314) +... +"#]]); }); // diff --git a/crates/forge/tests/fixtures/can_build_path_with_one_file.stdout b/crates/forge/tests/fixtures/can_build_path_with_one_file.stdout deleted file mode 100644 index 3213db81a21d4..0000000000000 --- a/crates/forge/tests/fixtures/can_build_path_with_one_file.stdout +++ /dev/null @@ -1,3 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 33.25ms -Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_build_path_with_three_files.stdout b/crates/forge/tests/fixtures/can_build_path_with_three_files.stdout deleted file mode 100644 index 4235acf297591..0000000000000 --- a/crates/forge/tests/fixtures/can_build_path_with_three_files.stdout +++ /dev/null @@ -1,3 +0,0 @@ -Compiling 3 files with 0.8.23 -Solc 0.8.23 finished in 33.25ms -Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_build_path_with_two_files.stdout b/crates/forge/tests/fixtures/can_build_path_with_two_files.stdout deleted file mode 100644 index cf59003407af9..0000000000000 --- a/crates/forge/tests/fixtures/can_build_path_with_two_files.stdout +++ /dev/null @@ -1,3 +0,0 @@ -Compiling 2 files with 0.8.23 -Solc 0.8.23 finished in 33.25ms -Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_build_skip_contracts.stdout b/crates/forge/tests/fixtures/can_build_skip_contracts.stdout deleted file mode 100644 index 43949fcce59e1..0000000000000 --- a/crates/forge/tests/fixtures/can_build_skip_contracts.stdout +++ /dev/null @@ -1,3 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 34.45ms -Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_build_skip_glob.stdout b/crates/forge/tests/fixtures/can_build_skip_glob.stdout deleted file mode 100644 index 3213db81a21d4..0000000000000 --- a/crates/forge/tests/fixtures/can_build_skip_glob.stdout +++ /dev/null @@ -1,3 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 33.25ms -Compiler run successful! diff --git a/crates/forge/tests/fixtures/can_check_snapshot.stdout b/crates/forge/tests/fixtures/can_check_snapshot.stdout deleted file mode 100644 index bce1c6972521f..0000000000000 --- a/crates/forge/tests/fixtures/can_check_snapshot.stdout +++ /dev/null @@ -1,9 +0,0 @@ -Compiling 2 files with 0.8.23 -Solc 0.8.23 finished in 424.55ms -Compiler run successful! - -Ran 1 test for src/ATest.t.sol:ATest -[PASS] testExample() (gas: 168) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.42ms - -Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_detect_dirty_git_status_on_init.stderr b/crates/forge/tests/fixtures/can_detect_dirty_git_status_on_init.stderr deleted file mode 100644 index de86b264db43d..0000000000000 --- a/crates/forge/tests/fixtures/can_detect_dirty_git_status_on_init.stderr +++ /dev/null @@ -1,10 +0,0 @@ -Error: -The target directory is a part of or on its own an already initialized git repository, -and it requires clean working and staging areas, including no untracked files. - -Check the current git repository's status with `git status`. -Then, you can track files with `git add ...` and then commit them with `git commit`, -ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag. - -If none of the previous steps worked, please open an issue at: -https://github.com/foundry-rs/foundry/issues/new/choose diff --git a/crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout b/crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout deleted file mode 100644 index fdc8e739fbd6e..0000000000000 --- a/crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout +++ /dev/null @@ -1,12 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 -Compiler run successful! -Script ran successfully. -Gas used: 22900 - -== Return == -result: uint256 255 -1: uint8 3 - -== Logs == - script ran diff --git a/crates/forge/tests/fixtures/can_execute_script_command.stdout b/crates/forge/tests/fixtures/can_execute_script_command.stdout deleted file mode 100644 index a9717c19df4cc..0000000000000 --- a/crates/forge/tests/fixtures/can_execute_script_command.stdout +++ /dev/null @@ -1,8 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 23.34ms -Compiler run successful! -Script ran successfully. -Gas used: 22815 - -== Logs == - script ran diff --git a/crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout b/crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout deleted file mode 100644 index 1156e916e40d4..0000000000000 --- a/crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout +++ /dev/null @@ -1,8 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 23.70ms -Compiler run successful! -Script ran successfully. -Gas used: 22815 - -== Logs == - script ran diff --git a/crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout b/crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout deleted file mode 100644 index feb193073eb93..0000000000000 --- a/crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout +++ /dev/null @@ -1,10 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 35.28ms -Compiler run successful! -Script ran successfully. -Gas used: 25301 - -== Logs == - script ran - 1 - 2 diff --git a/crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout b/crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout deleted file mode 100644 index 62aa01b138bae..0000000000000 --- a/crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout +++ /dev/null @@ -1,12 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 1.27s -Compiler run successful! -Script ran successfully. -Gas used: 22900 - -== Return == -result: uint256 255 -1: uint8 3 - -== Logs == - script ran diff --git a/crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout b/crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout deleted file mode 100644 index 13a94c698e96f..0000000000000 --- a/crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout +++ /dev/null @@ -1,8 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 24.49ms -Compiler run successful! -Script ran successfully. -Gas used: 22815 - -== Logs == - script ran diff --git a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout b/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout deleted file mode 100644 index cd92d6ebeed8b..0000000000000 --- a/crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout +++ /dev/null @@ -1,9 +0,0 @@ -Compiling 2 files with 0.8.23 -Solc 0.8.23 finished in 185.25ms -Compiler run successful! - -Ran 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest -[PASS] testTrue() (gas: 168) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93ms - -Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/can_set_yul_optimizer.stderr b/crates/forge/tests/fixtures/can_set_yul_optimizer.stderr deleted file mode 100644 index 0dd4db95b6eb7..0000000000000 --- a/crates/forge/tests/fixtures/can_set_yul_optimizer.stderr +++ /dev/null @@ -1,8 +0,0 @@ -Error: -Compiler run failed: -Error (6553): The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. - --> src/Foo.sol:6:8: - | -6 | assembly { - | ^ (Relevant source part starts here and spans across multiple lines). - diff --git a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout b/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout deleted file mode 100644 index 70c72887aaea4..0000000000000 --- a/crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout +++ /dev/null @@ -1,9 +0,0 @@ -Compiling 2 files with 0.8.23 -Solc 0.8.23 finished in 1.95s -Compiler run successful! - -Ran 1 test for test/Contract.t.sol:ContractTest -[PASS] test() (gas: 70360) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s - -Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/compile_json.stdout b/crates/forge/tests/fixtures/compile_json.stdout deleted file mode 100644 index 2a794cc4a8a95..0000000000000 --- a/crates/forge/tests/fixtures/compile_json.stdout +++ /dev/null @@ -1,20 +0,0 @@ -{ - "contracts": {}, - "errors": [ - { - "sourceLocation": { - "file": "src/jsonError.sol", - "start": 184, - "end": 193 - }, - "type": "DeclarationError", - "component": "general", - "severity": "error", - "errorCode": "7576", - "message": "Undeclared identifier. Did you mean \"newNumber\"?", - "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n --> src/jsonError.sol:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" - } - ], - "sources": {}, - "build_infos": ["{...}"] -} \ No newline at end of file diff --git a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout b/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout deleted file mode 100644 index 9b289543f112e..0000000000000 --- a/crates/forge/tests/fixtures/include_custom_types_in_traces.stdout +++ /dev/null @@ -1,25 +0,0 @@ -Compiling 1 files with 0.8.23 -Solc 0.8.23 finished in 798.51ms -Compiler run successful! - -Ran 2 tests for test/Contract.t.sol:CustomTypesTest -[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) -Traces: - [254] CustomTypesTest::testErr() - └─ ← [Revert] PoolNotInitialized() - -[PASS] testEvent() (gas: 1268) -Traces: - [1268] CustomTypesTest::testEvent() - ├─ emit MyEvent(a: 100) - └─ ← [Stop] - -Suite result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms - -Ran 1 test suite: 1 tests passed, 1 failed, 0 skipped (2 total tests) - -Failing tests: -Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest -[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) - -Encountered a total of 1 failing tests, 1 tests succeeded diff --git a/crates/forge/tests/fixtures/replay_last_run_failures.stdout b/crates/forge/tests/fixtures/replay_last_run_failures.stdout deleted file mode 100644 index d94983059658d..0000000000000 --- a/crates/forge/tests/fixtures/replay_last_run_failures.stdout +++ /dev/null @@ -1,15 +0,0 @@ -No files changed, compilation skipped - -Ran 2 tests for test/ReplayFailures.t.sol:ReplayFailuresTest -[FAIL. Reason: revert: testB failed] testB() (gas: 303) -[FAIL. Reason: revert: testD failed] testD() (gas: 314) -Suite result: FAILED. 0 passed; 2 failed; 0 skipped; finished in 555.95µs (250.31µs CPU time) - -Ran 1 test suite in 3.24ms (555.95µs CPU time): 0 tests passed, 2 failed, 0 skipped (2 total tests) - -Failing tests: -Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest -[FAIL. Reason: revert: testB failed] testB() (gas: 303) -[FAIL. Reason: revert: testD failed] testD() (gas: 314) - -Encountered a total of 2 failing tests, 0 tests succeeded diff --git a/crates/forge/tests/fixtures/repro_6531.stdout b/crates/forge/tests/fixtures/repro_6531.stdout deleted file mode 100644 index 47a6bb237b468..0000000000000 --- a/crates/forge/tests/fixtures/repro_6531.stdout +++ /dev/null @@ -1,17 +0,0 @@ -Compiling 1 files with 0.8.23 - -Compiler run successful! - -Ran 1 test for test/Contract.t.sol:USDTCallingTest -[PASS] test() (gas: 9537) -Traces: - [9537] USDTCallingTest::test() - ├─ [0] VM::createSelectFork("") - │ └─ ← [Return] 0 - ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] - │ └─ ← [Return] "Tether USD" - └─ ← [Stop] - -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s - -Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout deleted file mode 100644 index c98d9f93e42f4..0000000000000 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout +++ /dev/null @@ -1,9 +0,0 @@ -Compiling 2 files with 0.8.23 -Solc 0.8.23 finished in 185.25ms -Compiler run successful! - -Ran 1 test for src/Contract.t.sol:ContractTest -[PASS] testExample() (gas: 190) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms - -Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) diff --git a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout b/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout deleted file mode 100644 index abfd712db4c1e..0000000000000 --- a/crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout +++ /dev/null @@ -1,9 +0,0 @@ -Compiling 2 files with 0.8.22 -Solc 0.8.22 finished in 185.25ms -Compiler run successful! - -Ran 1 test for src/Contract.t.sol:ContractTest -[PASS] testExample() (gas: 190) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms - -Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) From 154057a1d61efd59065f6112f9d19d83194b6eec Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Wed, 21 Aug 2024 23:35:31 -0700 Subject: [PATCH 1372/1963] fix(cast): json quoted strings (#8681) * fix quoted strings * fix test integration * address comments --------- Co-authored-by: Matthias Seitz --- crates/common/fmt/src/dynamic.rs | 8 +++++++- crates/forge/tests/cli/script.rs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/common/fmt/src/dynamic.rs b/crates/common/fmt/src/dynamic.rs index e13d6ab96d89d..498d209f7a328 100644 --- a/crates/common/fmt/src/dynamic.rs +++ b/crates/common/fmt/src/dynamic.rs @@ -38,7 +38,13 @@ impl DynValueFormatter { f.write_str("]") } DynSolValue::Tuple(values) => self.tuple(values, f), - DynSolValue::String(inner) => write!(f, "{inner:?}"), // escape strings + DynSolValue::String(inner) => { + if self.raw { + write!(f, "{}", inner.escape_debug()) + } else { + write!(f, "{inner:?}") // escape strings + } + } DynSolValue::Bool(inner) => write!(f, "{inner}"), DynSolValue::CustomStruct { name, prop_names, tuple } => { if self.raw { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 68ccec8953f7b..f64bce20556db 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -865,7 +865,7 @@ contract Script0 is Script { "true".to_string(), "0x616263646566".to_string(), "(10, 99)".to_string(), - "\"hello\"".to_string(), + "hello".to_string(), ] ); }); @@ -948,7 +948,7 @@ contract Script0 is Script { "0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string(), "true".to_string(), "0x616263646566".to_string(), - "\"hello\"".to_string(), + "hello".to_string(), ] ); }); From 3b9c29dcc54f50ee0ad1f1a33a0456168562f739 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 22 Aug 2024 17:44:13 +0800 Subject: [PATCH 1373/1963] fix(script): correctly populate both fields for `TransactionRequest`s (#8714) fix(script): correctly populate both fields for TransactionRequests --- crates/script/src/execute.rs | 12 +++++++++++- crates/script/src/runner.rs | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index caa3fb2c20645..410d896105cf2 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -8,6 +8,7 @@ use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; use alloy_primitives::{Address, Bytes}; use alloy_provider::Provider; +use alloy_rpc_types::TransactionInput; use async_recursion::async_recursion; use eyre::{OptionExt, Result}; use foundry_cheatcodes::ScriptWallets; @@ -284,7 +285,16 @@ impl ExecutedState { let decoder = self.build_trace_decoder(&self.build_data.known_contracts).await?; - let txs = self.execution_result.transactions.clone().unwrap_or_default(); + let mut txs = self.execution_result.transactions.clone().unwrap_or_default(); + + // Ensure that unsigned transactions have both `data` and `input` populated to avoid + // issues with eth_estimateGas and eth_sendTransaction requests. + for tx in &mut txs { + if let Some(req) = tx.transaction.as_unsigned_mut() { + req.input = + TransactionInput::maybe_both(std::mem::take(&mut req.input).into_input()); + } + } let rpc_data = RpcData::from_transactions(&txs); if rpc_data.is_multi_chain() { diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 5841802566f75..2b3fc5253b9cc 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -1,7 +1,7 @@ use super::ScriptResult; use crate::build::ScriptPredeployLibraries; use alloy_primitives::{Address, Bytes, TxKind, U256}; -use alloy_rpc_types::{TransactionInput, TransactionRequest}; +use alloy_rpc_types::TransactionRequest; use eyre::Result; use foundry_cheatcodes::BroadcastableTransaction; use foundry_config::Config; @@ -75,7 +75,7 @@ impl ScriptRunner { rpc: self.evm_opts.fork_url.clone(), transaction: TransactionRequest { from: Some(self.evm_opts.sender), - input: TransactionInput::both(code.clone()), + input: code.clone().into(), nonce: Some(sender_nonce + library_transactions.len() as u64), ..Default::default() } @@ -109,7 +109,7 @@ impl ScriptRunner { rpc: self.evm_opts.fork_url.clone(), transaction: TransactionRequest { from: Some(self.evm_opts.sender), - input: TransactionInput::both(calldata.clone().into()), + input: calldata.into(), nonce: Some(sender_nonce + library_transactions.len() as u64), to: Some(TxKind::Call(DEFAULT_CREATE2_DEPLOYER)), ..Default::default() From 33aae9e9a8d27cc0d88c423a3f8888f9b14dffa0 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 22 Aug 2024 18:43:09 +0800 Subject: [PATCH 1374/1963] feat: add transaction timeout config (#8669) * feat: add transaction timeout config * clipppy * fix doc --- crates/cast/bin/cmd/send.rs | 16 ++++++++-- crates/cast/bin/main.rs | 2 +- crates/cast/src/lib.rs | 5 +++- crates/config/src/lib.rs | 4 +++ crates/forge/bin/cmd/create.rs | 51 +++++++++++++++++++++++++++----- crates/forge/tests/cli/config.rs | 1 + crates/script/src/broadcast.rs | 18 +++++++++-- crates/script/src/lib.rs | 7 +++++ crates/script/src/progress.rs | 8 +++-- crates/script/src/receipts.rs | 3 +- 10 files changed, 98 insertions(+), 17 deletions(-) diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 82c7f15d90464..573bb2bd1e206 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -50,6 +50,10 @@ pub struct SendTxArgs { #[arg(long, requires = "from")] unlocked: bool, + /// Timeout for sending the transaction. + #[arg(long, env = "ETH_TIMEOUT")] + pub timeout: Option, + #[command(flatten)] tx: TransactionOpts, @@ -98,6 +102,7 @@ impl SendTxArgs { command, unlocked, path, + timeout, } = self; let blob_data = if let Some(path) = path { Some(std::fs::read(path)?) } else { None }; @@ -126,6 +131,8 @@ impl SendTxArgs { .await? .with_blob_data(blob_data)?; + let timeout = timeout.unwrap_or(config.transaction_timeout); + // Case 1: // Default to sending via eth_sendTransaction if the --unlocked flag is passed. // This should be the only way this RPC method is used as it requires a local node @@ -152,7 +159,7 @@ impl SendTxArgs { let (tx, _) = builder.build(config.sender).await?; - cast_send(provider, tx, cast_async, confirmations, to_json).await + cast_send(provider, tx, cast_async, confirmations, timeout, to_json).await // Case 2: // An option to use a local signer was provided. // If we cannot successfully instantiate a local signer, then we will assume we don't have @@ -171,7 +178,7 @@ impl SendTxArgs { .wallet(wallet) .on_provider(&provider); - cast_send(provider, tx, cast_async, confirmations, to_json).await + cast_send(provider, tx, cast_async, confirmations, timeout, to_json).await } } } @@ -181,6 +188,7 @@ async fn cast_send, T: Transport + Clone>( tx: WithOtherFields, cast_async: bool, confs: u64, + timeout: u64, to_json: bool, ) -> Result<()> { let cast = Cast::new(provider); @@ -191,7 +199,9 @@ async fn cast_send, T: Transport + Clone>( if cast_async { println!("{tx_hash:#x}"); } else { - let receipt = cast.receipt(format!("{tx_hash:#x}"), None, confs, false, to_json).await?; + let receipt = cast + .receipt(format!("{tx_hash:#x}"), None, confs, Some(timeout), false, to_json) + .await?; println!("{receipt}"); } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index c3bd5039f3762..501955827fce7 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -396,7 +396,7 @@ async fn main() -> Result<()> { println!( "{}", Cast::new(provider) - .receipt(tx_hash, field, confirmations, cast_async, json) + .receipt(tx_hash, field, confirmations, None, cast_async, json) .await? ); } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 7c2d970a7abb4..95952bfbb7ce8 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -42,6 +42,7 @@ use std::{ path::PathBuf, str::FromStr, sync::atomic::{AtomicBool, Ordering}, + time::Duration, }; use tokio::signal::ctrl_c; @@ -690,7 +691,7 @@ where /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let tx_hash = "0xf8d1713ea15a81482958fb7ddf884baee8d3bcc478c5f2f604e008dc788ee4fc"; - /// let receipt = cast.receipt(tx_hash.to_string(), None, 1, false, false).await?; + /// let receipt = cast.receipt(tx_hash.to_string(), None, 1, None, false, false).await?; /// println!("{}", receipt); /// # Ok(()) /// # } @@ -700,6 +701,7 @@ where tx_hash: String, field: Option, confs: u64, + timeout: Option, cast_async: bool, to_json: bool, ) -> Result { @@ -716,6 +718,7 @@ where } else { PendingTransactionBuilder::new(self.provider.root(), tx_hash) .with_required_confirmations(confs) + .with_timeout(timeout.map(Duration::from_secs)) .get_receipt() .await? } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ca7226e18da42..cedf96e6e45e9 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -450,6 +450,9 @@ pub struct Config { /// Whether to enable Alphanet features. pub alphanet: bool, + /// Timeout for transactions in seconds. + pub transaction_timeout: u64, + /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information #[serde(rename = "__warnings", default, skip_serializing)] pub warnings: Vec, @@ -2143,6 +2146,7 @@ impl Default for Config { extra_args: vec![], eof_version: None, alphanet: false, + transaction_timeout: 120, _non_exhaustive: (), } } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index b549b39a0bfd9..3bcf6b36cbde1 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -20,9 +20,19 @@ use foundry_common::{ fmt::parse_tokens, }; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalize}; +use foundry_config::{ + figment::{ + self, + value::{Dict, Map}, + Metadata, Profile, + }, + merge_impl_figment_convert, Config, +}; use serde_json::json; use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc}; +merge_impl_figment_convert!(CreateArgs, opts, eth); + /// CLI arguments for `forge create`. #[derive(Clone, Debug, Parser)] pub struct CreateArgs { @@ -65,6 +75,10 @@ pub struct CreateArgs { #[arg(long, requires = "verify")] show_standard_json_input: bool, + /// Timeout to use for broadcasting transactions. + #[arg(long, env = "ETH_TIMEOUT")] + pub timeout: Option, + #[command(flatten)] opts: CoreBuildArgs, @@ -84,8 +98,9 @@ pub struct CreateArgs { impl CreateArgs { /// Executes the command to create a contract pub async fn run(mut self) -> Result<()> { + let config = self.try_load_config_emit_warnings()?; // Find Project & Compile - let project = self.opts.project()?; + let project = config.project()?; let target_path = if let Some(ref mut path) = self.contract.path { canonicalize(project.root().join(path))? @@ -114,7 +129,6 @@ impl CreateArgs { }; // Add arguments to constructor - let config = self.eth.try_load_config_emit_warnings()?; let provider = utils::get_provider(&config)?; let params = match abi.constructor { Some(ref v) => { @@ -138,7 +152,8 @@ impl CreateArgs { if self.unlocked { // Deploy with unlocked account let sender = self.eth.wallet.from.expect("required"); - self.deploy(abi, bin, params, provider, chain_id, sender).await + self.deploy(abi, bin, params, provider, chain_id, sender, config.transaction_timeout) + .await } else { // Deploy with signer let signer = self.eth.wallet.signer().await?; @@ -146,7 +161,8 @@ impl CreateArgs { let provider = ProviderBuilder::<_, _, AnyNetwork>::default() .wallet(EthereumWallet::new(signer)) .on_provider(provider); - self.deploy(abi, bin, params, provider, chain_id, deployer).await + self.deploy(abi, bin, params, provider, chain_id, deployer, config.transaction_timeout) + .await } } @@ -207,6 +223,7 @@ impl CreateArgs { } /// Deploys the contract + #[allow(clippy::too_many_arguments)] async fn deploy, T: Transport + Clone>( self, abi: JsonAbi, @@ -215,12 +232,13 @@ impl CreateArgs { provider: P, chain: u64, deployer_address: Address, + timeout: u64, ) -> Result<()> { let bin = bin.into_bytes().unwrap_or_else(|| { panic!("no bytecode found in bin object for {}", self.contract.name) }); let provider = Arc::new(provider); - let factory = ContractFactory::new(abi.clone(), bin.clone(), provider.clone()); + let factory = ContractFactory::new(abi.clone(), bin.clone(), provider.clone(), timeout); let is_args_empty = args.is_empty(); let mut deployer = @@ -367,6 +385,20 @@ impl CreateArgs { } } +impl figment::Provider for CreateArgs { + fn metadata(&self) -> Metadata { + Metadata::named("Create Args Provider") + } + + fn data(&self) -> Result, figment::Error> { + let mut dict = Dict::default(); + if let Some(timeout) = self.timeout { + dict.insert("transaction_timeout".to_string(), timeout.into()); + } + Ok(Map::from([(Config::selected_profile(), dict)])) + } +} + /// `ContractFactory` is a [`DeploymentTxFactory`] object with an /// [`Arc`] middleware. This type alias exists to preserve backwards /// compatibility with less-abstract Contracts. @@ -414,6 +446,7 @@ pub struct Deployer { abi: JsonAbi, client: B, confs: usize, + timeout: u64, _p: PhantomData

, _t: PhantomData, } @@ -428,6 +461,7 @@ where abi: self.abi.clone(), client: self.client.clone(), confs: self.confs, + timeout: self.timeout, _p: PhantomData, _t: PhantomData, } @@ -504,6 +538,7 @@ pub struct DeploymentTxFactory { client: B, abi: JsonAbi, bytecode: Bytes, + timeout: u64, _p: PhantomData

, _t: PhantomData, } @@ -517,6 +552,7 @@ where client: self.client.clone(), abi: self.abi.clone(), bytecode: self.bytecode.clone(), + timeout: self.timeout, _p: PhantomData, _t: PhantomData, } @@ -532,8 +568,8 @@ where /// Creates a factory for deployment of the Contract with bytecode, and the /// constructor defined in the abi. The client will be used to send any deployment /// transaction. - pub fn new(abi: JsonAbi, bytecode: Bytes, client: B) -> Self { - Self { client, abi, bytecode, _p: PhantomData, _t: PhantomData } + pub fn new(abi: JsonAbi, bytecode: Bytes, client: B, timeout: u64) -> Self { + Self { client, abi, bytecode, timeout, _p: PhantomData, _t: PhantomData } } /// Create a deployment tx using the provided tokens as constructor @@ -567,6 +603,7 @@ where abi: self.abi, tx, confs: 1, + timeout: self.timeout, _p: PhantomData, _t: PhantomData, }) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 78c76a22a8d4d..cfad5206f8d53 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -149,6 +149,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { extra_args: vec![], eof_version: None, alphanet: false, + transaction_timeout: 120, _non_exhaustive: (), }; prj.write_config(input.clone()); diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index a1113bb2dbd2f..302be1509af66 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -170,7 +170,14 @@ impl BundledState { .map(|(sequence_idx, sequence)| async move { let rpc_url = sequence.rpc_url(); let provider = Arc::new(get_http_provider(rpc_url)); - progress_ref.wait_for_pending(sequence_idx, sequence, &provider).await + progress_ref + .wait_for_pending( + sequence_idx, + sequence, + &provider, + self.script_config.config.transaction_timeout, + ) + .await }) .collect::>(); @@ -368,7 +375,14 @@ impl BundledState { self.sequence.save(true, false)?; sequence = self.sequence.sequences_mut().get_mut(i).unwrap(); - progress.wait_for_pending(i, sequence, &provider).await? + progress + .wait_for_pending( + i, + sequence, + &provider, + self.script_config.config.transaction_timeout, + ) + .await? } // Checkpoint save self.sequence.save(true, false)?; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 1b2618f91e875..6af605690e2b9 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -181,6 +181,10 @@ pub struct ScriptArgs { )] pub with_gas_price: Option, + /// Timeout to use for broadcasting transactions. + #[arg(long, env = "ETH_TIMEOUT")] + pub timeout: Option, + #[command(flatten)] pub opts: CoreBuildArgs, @@ -453,6 +457,9 @@ impl Provider for ScriptArgs { figment::value::Value::from(etherscan_api_key.to_string()), ); } + if let Some(timeout) = self.timeout { + dict.insert("transaction_timeout".to_string(), timeout.into()); + } Ok(Map::from([(Config::selected_profile(), dict)])) } } diff --git a/crates/script/src/progress.rs b/crates/script/src/progress.rs index 6f028688b8c10..e88885de3e444 100644 --- a/crates/script/src/progress.rs +++ b/crates/script/src/progress.rs @@ -168,6 +168,7 @@ impl ScriptProgress { sequence_idx: usize, deployment_sequence: &mut ScriptSequence, provider: &RetryProvider, + timeout: u64, ) -> Result<()> { if deployment_sequence.pending.is_empty() { return Ok(()); @@ -180,8 +181,11 @@ impl ScriptProgress { trace!("Checking status of {count} pending transactions"); - let futs = - deployment_sequence.pending.clone().into_iter().map(|tx| check_tx_status(provider, tx)); + let futs = deployment_sequence + .pending + .clone() + .into_iter() + .map(|tx| check_tx_status(provider, tx, timeout)); let mut tasks = futures::stream::iter(futs).buffer_unordered(10); let mut errors: Vec = vec![]; diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index c0fbd56119db0..c1dad562905f9 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -28,6 +28,7 @@ impl From for TxStatus { pub async fn check_tx_status( provider: &RetryProvider, hash: TxHash, + timeout: u64, ) -> (TxHash, Result) { // We use the inner future so that we can use ? operator in the future, but // still neatly return the tuple @@ -40,7 +41,7 @@ pub async fn check_tx_status( loop { if let Ok(receipt) = PendingTransactionBuilder::new(provider, hash) - .with_timeout(Some(Duration::from_secs(120))) + .with_timeout(Some(Duration::from_secs(timeout))) .get_receipt() .await { From 6f0fdffc7e1c61d621671a2b5539966cf069070d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:34:34 +0200 Subject: [PATCH 1375/1963] test: add builtin redactions to snapbox assertions (#8712) * test: add builtin redactions to snapbox assertions * chore: fmt * fix: don't redact number of runs --- Cargo.lock | 1 + crates/forge/tests/cli/build.rs | 21 +-- crates/forge/tests/cli/cmd.rs | 62 +++++---- crates/forge/tests/cli/config.rs | 8 +- crates/forge/tests/cli/create.rs | 24 ++-- crates/forge/tests/cli/script.rs | 42 +++--- crates/forge/tests/cli/test_cmd.rs | 198 ++++++++++++++++++++--------- crates/test-utils/Cargo.toml | 2 +- crates/test-utils/src/lib.rs | 2 +- crates/test-utils/src/util.rs | 54 ++++++-- 10 files changed, 268 insertions(+), 146 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 207ee83d34c3e..53d92b8cf4561 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7981,6 +7981,7 @@ dependencies = [ "anstream", "anstyle", "normalize-line-endings", + "regex", "serde", "serde_json", "similar", diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 779c7aa076286..f5848173c921e 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -1,5 +1,5 @@ use foundry_config::Config; -use foundry_test_utils::{forgetest, str}; +use foundry_test_utils::{forgetest, snapbox::IntoData, str}; use globset::Glob; // tests that json is printed when --json is passed @@ -19,7 +19,6 @@ contract Dummy { // set up command cmd.args(["compile", "--format-json"]).assert_success().stdout_eq(str![[r#" -... { "errors": [ { @@ -32,23 +31,25 @@ contract Dummy { "component": "general", "severity": "error", "errorCode": "7576", - "message": "Undeclared identifier. Did you mean /"newNumber/"?", - "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean /"newNumber/"?/n --> src/jsonError.sol:7:18:/n |/n7 | number = newnumber; // error here/n | ^^^^^^^^^/n/n" + "message": "Undeclared identifier. Did you mean \"newNumber\"?", + "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n [FILE]:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" } ], "sources": {}, "contracts": {}, - "build_infos": [ - { -... + "build_infos": "{...}" } -... -"#]]); +"#]].is_json()); }); // tests build output is as expected forgetest_init!(exact_build_output, |prj, cmd| { - cmd.args(["build", "--force"]).assert_success().stdout_eq(str!["Compiling[..]\n..."]); + cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +Compiling 27 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); }); // tests build output is as expected diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index cdfd90a732f8f..9160973e9b024 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -235,8 +235,7 @@ forgetest!(can_detect_dirty_git_status_on_init, |prj, cmd| { cmd.current_dir(&nested); cmd.arg("init").assert_failure().stderr_eq(str![[r#" -... -Error:[..] +Error: The target directory is a part of or on its own an already initialized git repository, and it requires clean working and staging areas, including no untracked files. @@ -246,7 +245,7 @@ ignore them in the `.gitignore` file, or run this command again with the `--no-c If none of the previous steps worked, please open an issue at: https://github.com/foundry-rs/foundry/issues/new/choose -... + "#]]); // ensure nothing was emitted, dir is empty @@ -398,7 +397,7 @@ forgetest!(can_init_vscode, |prj, cmd| { assert_eq!( settings, serde_json::json!({ - "solidity.packageDefaultDependenciesContractsDirectory": "src", + "solidity.packageDefaultDependenciesContractsDirectory": "src", "solidity.packageDefaultDependenciesDirectory": "lib" }) ); @@ -758,11 +757,16 @@ contract ATest is DSTest { .unwrap(); cmd.args(["snapshot"]).assert_success().stdout_eq(str![[r#" -... +Compiling 2 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + Ran 1 test for src/ATest.t.sol:ATest -[PASS] testExample() (gas: 168) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in [..] -... +[PASS] testExample() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); cmd.arg("--check"); @@ -1689,22 +1693,20 @@ function test_run() external {} cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**", "--force"]) .assert_success() .stdout_eq(str![[r#" -... -Compiling 1 files [..] -[..] +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -... + "#]]); cmd.forge_fuse() .args(["build", "--skip", "./test/**", "--skip", "./script/**", "--force"]) .assert_success() .stdout_eq(str![[r#" -... -Compiling 1 files [..] -[..] +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -... + "#]]); }); @@ -1738,44 +1740,40 @@ function test_bar() external {} // Build 2 files within test dir prj.clear(); cmd.args(["build", "test", "--force"]).assert_success().stdout_eq(str![[r#" -... -Compiling 2 files with Solc 0.8.23 -[..] +Compiling 2 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -... + "#]]); // Build one file within src dir prj.clear(); cmd.forge_fuse(); cmd.args(["build", "src", "--force"]).assert_success().stdout_eq(str![[r#" -... -Compiling 1 files with Solc 0.8.23 -[..] +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -... + "#]]); // Build 3 files from test and src dirs prj.clear(); cmd.forge_fuse(); cmd.args(["build", "src", "test", "--force"]).assert_success().stdout_eq(str![[r#" -... -Compiling 3 files with Solc 0.8.23 -[..] +Compiling 3 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -... + "#]]); // Build single test file prj.clear(); cmd.forge_fuse(); cmd.args(["build", "test/Bar.sol", "--force"]).assert_success().stdout_eq(str![[r#" -... -Compiling 1 files with Solc 0.8.23 -[..] +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -... + "#]]); }); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index cfad5206f8d53..e943001af9078 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -401,15 +401,15 @@ contract Foo { .unwrap(); cmd.arg("build").assert_failure().stderr_eq(str![[r#" -... -Error:[..] +Error: Compiler run failed: Error (6553): The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. - --> src/foo.sol:6:8: + [FILE]:6:8: | 6 | assembly { | ^ (Relevant source part starts here and spans across multiple lines). -... + + "#]]); // disable yul optimizer explicitly diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 6aaa4f536c44a..c7071dcf586fa 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -151,11 +151,12 @@ forgetest_async!(can_create_template_contract, |prj, cmd| { ]); cmd.assert().stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -Transaction hash: [..] +[TX_HASH] "#]]); @@ -163,7 +164,7 @@ Transaction hash: [..] No files changed, compilation skipped Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 -Transaction hash: [..] +[TX_HASH] "#]]); }); @@ -191,18 +192,19 @@ forgetest_async!(can_create_using_unlocked, |prj, cmd| { ]); cmd.assert().stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -Transaction hash: [..] +[TX_HASH] "#]]); cmd.assert().stdout_eq(str![[r#" No files changed, compilation skipped Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 -Transaction hash: [..] +[TX_HASH] "#]]); }); @@ -247,11 +249,12 @@ contract ConstructorContract { ]) .assert_success() .stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -Transaction hash: [..] +[TX_HASH] "#]]); @@ -283,11 +286,12 @@ contract TupleArrayConstructorContract { ]) .assert() .stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 -Transaction hash: [..] +[TX_HASH] "#]]); }); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index f64bce20556db..2b92559f2da91 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -54,13 +54,15 @@ contract Demo { .unwrap(); cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! Script ran successfully. -Gas used: 22815 +[GAS] == Logs == script ran -... + "#]]); }); @@ -84,7 +86,7 @@ contract Demo { r#" ... Script ran successfully. -Gas used: 22815 +[GAS] == Logs == script ran @@ -111,13 +113,15 @@ contract Demo { cmd.arg("script").arg(script).arg("--sig").arg("myFunction()").assert_success().stdout_eq( str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! Script ran successfully. -Gas used: 22815 +[GAS] == Logs == script ran -... + "#]], ); }); @@ -296,15 +300,17 @@ contract Demo { .arg("2") .assert_success() .stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! Script ran successfully. -Gas used: 25301 +[GAS] == Logs == script ran 1 2 -... + "#]]); }); @@ -325,9 +331,11 @@ contract Demo { .unwrap(); cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! Script ran successfully. -Gas used: 22900 +[GAS] == Return == result: uint256 255 @@ -335,7 +343,7 @@ result: uint256 255 == Logs == script ran -... + "#]]); }); @@ -973,9 +981,11 @@ contract Demo { .args(["--skip", "tests", "--skip", TEMPLATE_CONTRACT]) .assert_success() .stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! Script ran successfully. -Gas used: 22900 +[GAS] == Return == result: uint256 255 @@ -983,7 +993,7 @@ result: uint256 255 == Logs == script ran -... + "#]]); }); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 7c0499916e22d..40890c9dbb44c 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -52,7 +52,6 @@ contract Dummy {} // run command and assert cmd.assert_failure().stdout_eq(str![[r#" -... No tests found in project! Forge looks for functions that starts with `test`. "#]]); @@ -75,7 +74,6 @@ contract Dummy {} // run command and assert cmd.assert_failure().stdout_eq(str![[r#" -... No tests match the provided pattern: match-test: `testA.*` no-match-test: `testB.*` @@ -108,7 +106,6 @@ contract TestC { // run command and assert cmd.assert_failure().stdout_eq(str![[r#" -... No tests match the provided pattern: match-test: `testA.*` no-match-test: `testB.*` @@ -197,12 +194,16 @@ contract FailTest is DSTest { .unwrap(); cmd.args(["test", "--match-path", "*src/ATest.t.sol"]).assert_success().stdout_eq(str![[r#" -... +Compiling 3 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + Ran 1 test for src/ATest.t.sol:ATest -[PASS] testPass() (gas: 190) -... -Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) -... +[PASS] testPass() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); }); @@ -240,12 +241,16 @@ contract FailTest is DSTest { let test_path = test_path.to_string_lossy(); cmd.args(["test", "--match-path", test_path.as_ref()]).assert_success().stdout_eq(str![[r#" -... +Compiling 3 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + Ran 1 test for src/ATest.t.sol:ATest -[PASS] testPass() (gas: 190) -... -Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) -... +[PASS] testPass() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); }); @@ -273,10 +278,16 @@ contract MyTest is DSTest { .unwrap(); cmd.arg("test").assert_success().stdout_eq(str![[r#" -... +Compiling 2 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + Ran 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest -[PASS] testTrue() (gas: 168) -... +[PASS] testTrue() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); }); @@ -288,13 +299,14 @@ forgetest_init!(can_test_repeatedly, |_prj, cmd| { for _ in 0..5 { cmd.assert_success().stdout_eq(str![[r#" -... +No files changed, compilation skipped + Ran 2 tests for test/Counter.t.sol:CounterTest -[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: [..], ~: [..]) -[PASS] test_Increment() (gas: 31303) -Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in [..] ([..] CPU time) +[PASS] testFuzz_SetNumber(uint256) (runs: 256, [AVG_GAS]) +[PASS] test_Increment() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] -Ran 1 test suite in [..] ([..] CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests) +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) "#]]); } @@ -327,17 +339,16 @@ contract ContractTest is DSTest { prj.write_config(config); cmd.arg("test").assert_success().stdout_eq(str![[r#" -... -Compiling 2 files with Solc 0.8.23 -Solc 0.8.23 finished in [..] +Compiling 2 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! Ran 1 test for src/Contract.t.sol:ContractTest -[PASS] testExample() (gas: 190) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in [..] +[PASS] testExample() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) -Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) -... "#]]); // pin version @@ -345,17 +356,16 @@ Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) prj.write_config(config); cmd.forge_fuse().arg("test").assert_success().stdout_eq(str![[r#" -... -Compiling 2 files with Solc 0.8.22 -Solc 0.8.22 finished in [..] +Compiling 2 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! Ran 1 test for src/Contract.t.sol:ContractTest -[PASS] testExample() (gas: 190) -Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in [..] +[PASS] testExample() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) -Ran 1 test suite in [..] 1 tests passed, 0 failed, 0 skipped (1 total tests) -... "#]]); }); @@ -407,10 +417,16 @@ contract ContractTest is Test { .unwrap(); cmd.arg("test").assert_success().stdout_eq(str![[r#" -... +Compiling 2 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + Ran 1 test for test/Contract.t.sol:ContractTest -[PASS] test() (gas: 70360) -... +[PASS] test() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); }); @@ -473,19 +489,24 @@ contract USDTCallingTest is Test { .unwrap(); cmd.args(["test", "-vvvv"]).assert_success().stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! Ran 1 test for test/Contract.t.sol:USDTCallingTest -[PASS] test() (gas: 9537) +[PASS] test() ([GAS]) Traces: [9537] USDTCallingTest::test() ├─ [0] VM::createSelectFork("[..]") │ └─ ← [Return] 0 ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] │ └─ ← [Return] "Tether USD" - └─ ← [Stop][..] -... + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); }); @@ -514,19 +535,32 @@ contract CustomTypesTest is Test { .unwrap(); cmd.args(["test", "-vvvv"]).assert_failure().stdout_eq(str![[r#" -... +Compiling 1 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + Ran 2 tests for test/Contract.t.sol:CustomTypesTest -[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) +[FAIL. Reason: PoolNotInitialized()] testErr() ([GAS]) Traces: [254] CustomTypesTest::testErr() └─ ← [Revert] PoolNotInitialized() -[PASS] testEvent() (gas: 1268) +[PASS] testEvent() ([GAS]) Traces: [1268] CustomTypesTest::testEvent() ├─ emit MyEvent(a: 100) - └─ ← [Stop][..] -... + └─ ← [Stop] + +Suite result: FAILED. 1 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 1 failed, 0 skipped (2 total tests) + +Failing tests: +Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest +[FAIL. Reason: PoolNotInitialized()] testErr() ([GAS]) + +Encountered a total of 1 failing tests, 1 tests succeeded + "#]]); }); @@ -704,9 +738,22 @@ contract CounterTest is Test { // make sure there are only 61 runs (with proptest shrinking same test results in 298 runs) cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" -... -[..]testAddOne(uint256) (runs: 61, μ: [..], ~: [..]) -... +Compiling 23 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/CounterFuzz.t.sol:CounterTest +[FAIL. Reason: panic: arithmetic underflow or overflow (0x11); counterexample: calldata=0xa76d58f5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]] testAddOne(uint256) (runs: 61, [AVG_GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) + +Failing tests: +Encountered 1 failing test in test/CounterFuzz.t.sol:CounterTest +[FAIL. Reason: panic: arithmetic underflow or overflow (0x11); counterexample: calldata=0xa76d58f5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]] testAddOne(uint256) (runs: 61, [AVG_GAS]) + +Encountered a total of 1 failing tests, 0 tests succeeded + "#]]); }); @@ -742,9 +789,22 @@ contract CounterTest is Test { // make sure invariant test exit early with 0 runs cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" -... -[..]invariant_early_exit() (runs: 0, calls: 0, reverts: 0) -... +Compiling 23 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/CounterInvariant.t.sol:CounterTest +[FAIL. Reason: failed to set up invariant testing environment: wrong count] invariant_early_exit() (runs: 0, calls: 0, reverts: 0) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) + +Failing tests: +Encountered 1 failing test in test/CounterInvariant.t.sol:CounterTest +[FAIL. Reason: failed to set up invariant testing environment: wrong count] invariant_early_exit() (runs: 0, calls: 0, reverts: 0) + +Encountered a total of 1 failing tests, 0 tests succeeded + "#]]); }); @@ -783,11 +843,22 @@ contract ReplayFailuresTest is Test { // Perform only the 2 failing tests from last run. cmd.forge_fuse().args(["test", "--rerun"]).assert_failure().stdout_eq(str![[r#" -... +No files changed, compilation skipped + Ran 2 tests for test/ReplayFailures.t.sol:ReplayFailuresTest -[FAIL. Reason: revert: testB failed] testB() (gas: 303) -[FAIL. Reason: revert: testD failed] testD() (gas: 314) -... +[FAIL. Reason: revert: testB failed] testB() ([GAS]) +[FAIL. Reason: revert: testD failed] testD() ([GAS]) +Suite result: FAILED. 0 passed; 2 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 2 failed, 0 skipped (2 total tests) + +Failing tests: +Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest +[FAIL. Reason: revert: testB failed] testB() ([GAS]) +[FAIL. Reason: revert: testD failed] testD() ([GAS]) + +Encountered a total of 2 failing tests, 0 tests succeeded + "#]]); }); @@ -1013,7 +1084,12 @@ contract SimpleContractTest is Test { ) .unwrap(); cmd.args(["test", "-vvvv", "--decode-internal"]).assert_success().stdout_eq(str![[r#" -... +Compiling 24 files with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/Simple.sol:SimpleContractTest +[PASS] test() ([GAS]) Traces: [250463] SimpleContractTest::test() ├─ [171014] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f @@ -1029,7 +1105,11 @@ Traces: │ │ └─ ← 0x0000000000000000000000000000000000000000 │ └─ ← [Stop] └─ ← [Stop] -... + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); }); diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index e3cb1f5429d42..db47ce6024176 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -33,7 +33,7 @@ tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } walkdir.workspace = true rand.workspace = true -snapbox = { version = "0.6.9", features = ["json"] } +snapbox = { version = "0.6.9", features = ["json", "regex"] } [features] # feature for integration tests that test external projects diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 2a00932789ba5..0fcfb621610a6 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -28,7 +28,7 @@ pub use script::{ScriptOutcome, ScriptTester}; // re-exports for convenience pub use foundry_compilers; -pub use snapbox::{assert_data_eq, file, str}; +pub use snapbox::{self, assert_data_eq, file, str}; /// Initializes tracing for tests. pub fn init_tracing() { diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 9b6380e0771fe..7ed13cf14257d 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -920,18 +920,6 @@ impl TestCommand { output } - /// Runs the command and asserts that it resulted in success - #[track_caller] - pub fn assert_success(&mut self) -> OutputAssert { - self.assert().success() - } - - /// Runs the command and asserts that it failed. - #[track_caller] - pub fn assert_failure(&mut self) -> OutputAssert { - self.assert().failure() - } - /// Executes command, applies stdin function and returns output #[track_caller] pub fn execute(&mut self) -> Output { @@ -1063,11 +1051,51 @@ stderr: ) } + /// Runs the command, returning a [`snapbox`] object to assert the command output. + #[track_caller] pub fn assert(&mut self) -> OutputAssert { - OutputAssert::new(self.execute()) + OutputAssert::new(self.execute()).with_assert(test_assert()) + } + + /// Runs the command and asserts that it resulted in success. + #[track_caller] + pub fn assert_success(&mut self) -> OutputAssert { + self.assert().success() + } + + /// Runs the command and asserts that it failed. + #[track_caller] + pub fn assert_failure(&mut self) -> OutputAssert { + self.assert().failure() } } +fn test_assert() -> snapbox::Assert { + snapbox::Assert::new() + .action_env(snapbox::assert::DEFAULT_ACTION_ENV) + .redact_with(test_redactions()) +} + +fn test_redactions() -> snapbox::Redactions { + static REDACTIONS: Lazy = Lazy::new(|| { + let mut r = snapbox::Redactions::new(); + let redactions = [ + ("[SOLC_VERSION]", r"Solc( version)? \d+.\d+.\d+"), + ("[ELAPSED]", r"(finished )?in \d+(\.\d+)?\w?s( \(.*?s CPU time\))?"), + ("[GAS]", r"[Gg]as( used)?: \d+"), + ("[AVG_GAS]", r"μ: \d+, ~: \d+"), + ("[FILE]", r"-->.*\.sol"), + ("[FILE]", r"Location(.|\n)*\.rs(.|\n)*Backtrace"), + ("[TX_HASH]", r"Transaction hash: 0x[0-9A-Fa-f]{64}"), + ]; + for (placeholder, re) in redactions { + r.insert(placeholder, Regex::new(re).expect(re)).expect(re); + } + r + }); + REDACTIONS.clone() +} + /// Extension trait for [`Output`]. /// /// These function will read the path's content and assert that the process' output matches the From 91656a28b104654fd08e3daf2ab7ffc5a2008f2f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:26:32 +0200 Subject: [PATCH 1376/1963] chore: replace `once_cell` with `std::sync` (#8718) * chore: replace `once_cell` with `std::sync` * chore: fmt * docs --- Cargo.lock | 10 --------- Cargo.toml | 5 ++--- clippy.toml | 2 +- crates/chisel/Cargo.toml | 1 - crates/chisel/benches/session_source.rs | 8 +++---- crates/chisel/src/dispatcher.rs | 8 +++---- crates/cli/Cargo.toml | 1 - crates/cli/src/opts/dependency.rs | 7 +++---- crates/common/Cargo.toml | 1 - crates/common/src/shell.rs | 5 ++--- crates/common/src/term.rs | 8 ++++--- crates/config/Cargo.toml | 1 - crates/config/src/inline/mod.rs | 5 ++--- crates/config/src/resolve.rs | 7 +++---- crates/doc/Cargo.toml | 1 - .../doc/src/preprocessor/infer_hyperlinks.rs | 4 ++-- crates/doc/src/writer/buf_writer.rs | 14 +++++++------ crates/evm/abi/Cargo.toml | 1 - crates/evm/abi/src/console/hardhat.rs | 6 +++--- crates/evm/traces/Cargo.toml | 1 - crates/evm/traces/src/decoder/mod.rs | 8 ++++--- crates/forge/Cargo.toml | 1 - crates/forge/bin/cmd/inspect.rs | 7 +++---- crates/forge/bin/cmd/install.rs | 6 +++--- crates/forge/bin/cmd/snapshot.rs | 4 ++-- crates/forge/tests/it/test_helpers.rs | 17 +++++++-------- crates/test-utils/Cargo.toml | 1 - crates/test-utils/src/rpc.rs | 12 ++++++----- crates/test-utils/src/util.rs | 21 +++++++++---------- crates/verify/Cargo.toml | 1 - crates/verify/src/etherscan/mod.rs | 7 +++---- 31 files changed, 80 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 53d92b8cf4561..132c4840d1858 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1969,7 +1969,6 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm", - "once_cell", "regex", "reqwest", "revm", @@ -3324,7 +3323,6 @@ dependencies = [ "indicatif", "itertools 0.13.0", "mockall", - "once_cell", "opener", "parking_lot", "paste", @@ -3373,7 +3371,6 @@ dependencies = [ "foundry-config", "itertools 0.13.0", "mdbook", - "once_cell", "rayon", "regex", "serde", @@ -3482,7 +3479,6 @@ dependencies = [ "foundry-test-utils", "futures", "itertools 0.13.0", - "once_cell", "regex", "reqwest", "revm-primitives", @@ -3601,7 +3597,6 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "once_cell", "regex", "serde", "strsim", @@ -3645,7 +3640,6 @@ dependencies = [ "foundry-config", "foundry-macros", "num-format", - "once_cell", "reqwest", "rustc-hash", "semver 1.0.23", @@ -3807,7 +3801,6 @@ dependencies = [ "glob", "globset", "number_prefix", - "once_cell", "path-slash", "regex", "reqwest", @@ -3880,7 +3873,6 @@ dependencies = [ "foundry-macros", "foundry-test-utils", "itertools 0.13.0", - "once_cell", "rustc-hash", ] @@ -3977,7 +3969,6 @@ dependencies = [ "foundry-linking", "futures", "itertools 0.13.0", - "once_cell", "rayon", "revm", "revm-inspectors", @@ -4044,7 +4035,6 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", - "once_cell", "parking_lot", "rand", "regex", diff --git a/Cargo.toml b/Cargo.toml index 238bc38bd9683..8563d1add39a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ resolver = "2" version = "0.2.0" edition = "2021" # Remember to update clippy.toml as well -rust-version = "1.79" +rust-version = "1.80" authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" @@ -230,7 +230,6 @@ futures = "0.3" itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" -once_cell = "1" parking_lot = "0.12" rand = "0.8" rustc-hash = "2.0" @@ -287,4 +286,4 @@ alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "511ae alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } revm = { git = "https://github.com/bluealloy/revm", rev = "caadc71" } -revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "caadc71" } \ No newline at end of file +revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "caadc71" } diff --git a/clippy.toml b/clippy.toml index b5a99df72b1e5..92b35ffc0afc8 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,4 +1,4 @@ -msrv = "1.79" +msrv = "1.80" # bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, # so it is safe to ignore it as well ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 64e218f97f053..bbfeb6ee9dbb1 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -50,7 +50,6 @@ alloy-rpc-types.workspace = true clap = { version = "4", features = ["derive", "env", "wrap_help"] } dirs = "5" eyre.workspace = true -once_cell = "1.18.0" regex = "1" reqwest.workspace = true revm.workspace = true diff --git a/crates/chisel/benches/session_source.rs b/crates/chisel/benches/session_source.rs index f54944966d975..49d127c4728e5 100644 --- a/crates/chisel/benches/session_source.rs +++ b/crates/chisel/benches/session_source.rs @@ -1,12 +1,12 @@ use chisel::session_source::{SessionSource, SessionSourceConfig}; use criterion::{criterion_group, Criterion}; use foundry_compilers::solc::Solc; -use once_cell::sync::Lazy; use semver::Version; -use std::hint::black_box; +use std::{hint::black_box, sync::LazyLock}; use tokio::runtime::Runtime; -static SOLC: Lazy = Lazy::new(|| Solc::find_or_install(&Version::new(0, 8, 19)).unwrap()); +static SOLC: LazyLock = + LazyLock::new(|| Solc::find_or_install(&Version::new(0, 8, 19)).unwrap()); /// Benchmark for the `clone_with_new_line` function in [SessionSource] fn clone_with_new_line(c: &mut Criterion) { @@ -74,7 +74,7 @@ fn rt() -> Runtime { fn main() { // Install before benches if not present - let _ = Lazy::force(&SOLC); + let _ = LazyLock::force(&SOLC); session_source_benches(); diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 909b7525c9f53..6afa7ccb9f537 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -22,7 +22,6 @@ use foundry_evm::{ render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, }, }; -use once_cell::sync::Lazy; use regex::Regex; use reqwest::Url; use serde::{Deserialize, Serialize}; @@ -33,6 +32,7 @@ use std::{ io::Write, path::{Path, PathBuf}, process::Command, + sync::LazyLock, }; use strum::IntoEnumIterator; use tracing::debug; @@ -48,11 +48,11 @@ pub static COMMAND_LEADER: char = '!'; pub static CHISEL_CHAR: &str = "⚒️"; /// Matches Solidity comments -static COMMENT_RE: Lazy = - Lazy::new(|| Regex::new(r"^\s*(?://.*\s*$)|(/*[\s\S]*?\*/\s*$)").unwrap()); +static COMMENT_RE: LazyLock = + LazyLock::new(|| Regex::new(r"^\s*(?://.*\s*$)|(/*[\s\S]*?\*/\s*$)").unwrap()); /// Matches Ethereum addresses that are not strings -static ADDRESS_RE: Lazy = Lazy::new(|| { +static ADDRESS_RE: LazyLock = LazyLock::new(|| { Regex::new(r#"(?m)(([^"']\s*)|^)(?P

0x[a-fA-F0-9]{40})((\s*[^"'\w])|$)"#).unwrap() }); diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 9c8b3fab80b9a..e8690a0a7d91f 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -35,7 +35,6 @@ dotenvy = "0.15" eyre.workspace = true futures.workspace = true indicatif = "0.17" -once_cell.workspace = true regex = { version = "1", default-features = false } serde.workspace = true strsim = "0.11" diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index 945386d2b64a9..6fa33a53f8a1f 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -1,14 +1,13 @@ //! CLI dependency parsing use eyre::Result; -use once_cell::sync::Lazy; use regex::Regex; -use std::str::FromStr; +use std::{str::FromStr, sync::LazyLock}; -static GH_REPO_REGEX: Lazy = Lazy::new(|| Regex::new(r"[\w-]+/[\w.-]+").unwrap()); +static GH_REPO_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"[\w-]+/[\w.-]+").unwrap()); /// Git repo prefix regex -pub static GH_REPO_PREFIX_REGEX: Lazy = Lazy::new(|| { +pub static GH_REPO_PREFIX_REGEX: LazyLock = LazyLock::new(|| { Regex::new(r"((git@)|(git\+https://)|(https://)|(org-([A-Za-z0-9-])+@))?(?P[A-Za-z0-9-]+)\.(?P[A-Za-z0-9-]+)(/|:)") .unwrap() }); diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 5c843979a97e6..73bd90cc71266 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -51,7 +51,6 @@ comfy-table.workspace = true dunce.workspace = true eyre.workspace = true num-format.workspace = true -once_cell.workspace = true reqwest.workspace = true rustc-hash.workspace = true semver.workspace = true diff --git a/crates/common/src/shell.rs b/crates/common/src/shell.rs index 898b154fad9a4..5ce6d5b38187b 100644 --- a/crates/common/src/shell.rs +++ b/crates/common/src/shell.rs @@ -1,16 +1,15 @@ //! Helpers for printing to output -use once_cell::sync::OnceCell; use serde::Serialize; use std::{ error::Error, fmt, io, io::Write, - sync::{Arc, Mutex}, + sync::{Arc, Mutex, OnceLock}, }; /// Stores the configured shell for the duration of the program -static SHELL: OnceCell = OnceCell::new(); +static SHELL: OnceLock = OnceLock::new(); /// Error indicating that `set_hook` was unable to install the provided ErrorHook #[derive(Clone, Copy, Debug)] diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 925456e4c65f2..30aaf6c52f822 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -3,13 +3,15 @@ use foundry_compilers::{ artifacts::remappings::Remapping, report::{self, BasicStdoutReporter, Reporter}, }; -use once_cell::sync::Lazy; use semver::Version; use std::{ io, io::{prelude::*, IsTerminal}, path::{Path, PathBuf}, - sync::mpsc::{self, TryRecvError}, + sync::{ + mpsc::{self, TryRecvError}, + LazyLock, + }, thread, time::Duration, }; @@ -25,7 +27,7 @@ pub static SPINNERS: &[&[&str]] = &[ &[" ", "▘", "▀", "▜", "█", "▟", "▄", "▖"], ]; -static TERM_SETTINGS: Lazy = Lazy::new(TermSettings::from_env); +static TERM_SETTINGS: LazyLock = LazyLock::new(TermSettings::from_env); /// Helper type to determine the current tty pub struct TermSettings { diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index c29a5fd44c01b..f155981228c92 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -31,7 +31,6 @@ globset = "0.4" glob = "0.3" Inflector = "0.11" number_prefix = "0.4" -once_cell.workspace = true regex = "1" reqwest.workspace = true semver = { workspace = true, features = ["serde"] } diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 9bdf1d5d0ad40..36bad2514df39 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -1,6 +1,5 @@ use crate::Config; -use once_cell::sync::Lazy; -use std::collections::HashMap; +use std::{collections::HashMap, sync::LazyLock}; mod conf_parser; pub use conf_parser::*; @@ -15,7 +14,7 @@ pub const INLINE_CONFIG_FUZZ_KEY: &str = "fuzz"; pub const INLINE_CONFIG_INVARIANT_KEY: &str = "invariant"; const INLINE_CONFIG_PREFIX: &str = "forge-config"; -static INLINE_CONFIG_PREFIX_SELECTED_PROFILE: Lazy = Lazy::new(|| { +static INLINE_CONFIG_PREFIX_SELECTED_PROFILE: LazyLock = LazyLock::new(|| { let selected_profile = Config::selected_profile().to_string(); format!("{INLINE_CONFIG_PREFIX}:{selected_profile}.") }); diff --git a/crates/config/src/resolve.rs b/crates/config/src/resolve.rs index 746280f3d2b19..179ecffa2901a 100644 --- a/crates/config/src/resolve.rs +++ b/crates/config/src/resolve.rs @@ -1,12 +1,11 @@ //! Helper for resolving env vars -use once_cell::sync::Lazy; use regex::Regex; -use std::{env, env::VarError, fmt}; +use std::{env, env::VarError, fmt, sync::LazyLock}; /// A regex that matches `${val}` placeholders -pub static RE_PLACEHOLDER: Lazy = - Lazy::new(|| Regex::new(r"(?m)(?P\$\{\s*(?P.*?)\s*})").unwrap()); +pub static RE_PLACEHOLDER: LazyLock = + LazyLock::new(|| Regex::new(r"(?m)(?P\$\{\s*(?P.*?)\s*})").unwrap()); /// Error when we failed to resolve an env var #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index ab74ef697a440..22abae5bec2a5 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -25,7 +25,6 @@ derive_more = "0.99" eyre.workspace = true itertools.workspace = true mdbook = { version = "0.4", default-features = false, features = ["search"] } -once_cell.workspace = true rayon.workspace = true serde_json.workspace = true serde.workspace = true diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index a7f7c19c4cb74..613976ec8d079 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -1,18 +1,18 @@ use super::{Preprocessor, PreprocessorId}; use crate::{Comments, Document, ParseItem, ParseSource}; use forge_fmt::solang_ext::SafeUnwrap; -use once_cell::sync::Lazy; use regex::{Captures, Match, Regex}; use std::{ borrow::Cow, path::{Path, PathBuf}, + sync::LazyLock, }; /// A regex that matches `{identifier-part}` placeholders /// /// Overloaded functions are referenced by including the exact function arguments in the `part` /// section of the placeholder. -static RE_INLINE_LINK: Lazy = Lazy::new(|| { +static RE_INLINE_LINK: LazyLock = LazyLock::new(|| { Regex::new(r"(?m)(\{(?Pxref-)?(?P[a-zA-Z_][0-9a-zA-Z_]*)(-(?P[a-zA-Z_][0-9a-zA-Z_-]*))?}(\[(?P(.*?))\])?)").unwrap() }); diff --git a/crates/doc/src/writer/buf_writer.rs b/crates/doc/src/writer/buf_writer.rs index 7ab47c953c5fe..dfec68fe25cea 100644 --- a/crates/doc/src/writer/buf_writer.rs +++ b/crates/doc/src/writer/buf_writer.rs @@ -1,21 +1,23 @@ use crate::{writer::traits::ParamLike, AsDoc, CommentTag, Comments, Deployment, Markdown}; use itertools::Itertools; -use once_cell::sync::Lazy; use solang_parser::pt::{ErrorParameter, EventParameter, Parameter, VariableDeclaration}; -use std::fmt::{self, Display, Write}; +use std::{ + fmt::{self, Display, Write}, + sync::LazyLock, +}; /// Solidity language name. const SOLIDITY: &str = "solidity"; /// Headers and separator for rendering parameter table. const PARAM_TABLE_HEADERS: &[&str] = &["Name", "Type", "Description"]; -static PARAM_TABLE_SEPARATOR: Lazy = - Lazy::new(|| PARAM_TABLE_HEADERS.iter().map(|h| "-".repeat(h.len())).join("|")); +static PARAM_TABLE_SEPARATOR: LazyLock = + LazyLock::new(|| PARAM_TABLE_HEADERS.iter().map(|h| "-".repeat(h.len())).join("|")); /// Headers and separator for rendering the deployments table. const DEPLOYMENTS_TABLE_HEADERS: &[&str] = &["Network", "Address"]; -static DEPLOYMENTS_TABLE_SEPARATOR: Lazy = - Lazy::new(|| DEPLOYMENTS_TABLE_HEADERS.iter().map(|h| "-".repeat(h.len())).join("|")); +static DEPLOYMENTS_TABLE_SEPARATOR: LazyLock = + LazyLock::new(|| DEPLOYMENTS_TABLE_HEADERS.iter().map(|h| "-".repeat(h.len())).join("|")); /// The buffered writer. /// Writes various display items into the internal buffer. diff --git a/crates/evm/abi/Cargo.toml b/crates/evm/abi/Cargo.toml index 892963acdc0dd..330ea6626d6bc 100644 --- a/crates/evm/abi/Cargo.toml +++ b/crates/evm/abi/Cargo.toml @@ -22,7 +22,6 @@ alloy-sol-types = { workspace = true, features = ["json"] } derive_more.workspace = true itertools.workspace = true -once_cell.workspace = true rustc-hash.workspace = true [dev-dependencies] diff --git a/crates/evm/abi/src/console/hardhat.rs b/crates/evm/abi/src/console/hardhat.rs index bdacddba5619c..a99ad8fc6451c 100644 --- a/crates/evm/abi/src/console/hardhat.rs +++ b/crates/evm/abi/src/console/hardhat.rs @@ -2,8 +2,8 @@ use alloy_primitives::Selector; use alloy_sol_types::sol; use foundry_common_fmt::*; use foundry_macros::ConsoleFmt; -use once_cell::sync::Lazy; use rustc_hash::FxHashMap; +use std::sync::LazyLock; sol!( #[sol(abi)] @@ -39,8 +39,8 @@ pub fn hh_console_selector(input: &[u8]) -> Option<&'static Selector> { /// `hardhat/console.log` logs its events manually, and in functions that accept integers they're /// encoded as `abi.encodeWithSignature("log(int)", p0)`, which is not the canonical ABI encoding /// for `int` that Solidity and [`sol!`] use. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: Lazy> = - Lazy::new(|| FxHashMap::from_iter(include!("./patches.rs"))); +pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: LazyLock> = + LazyLock::new(|| FxHashMap::from_iter(include!("./patches.rs"))); #[cfg(test)] mod tests { diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 92426806537b3..96fb8d1c6dc0e 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -35,7 +35,6 @@ revm-inspectors.workspace = true eyre.workspace = true futures.workspace = true itertools.workspace = true -once_cell.workspace = true serde.workspace = true tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index c8d1e461abbe8..1bb20381b9eca 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -24,10 +24,12 @@ use foundry_evm_core::{ }, }; use itertools::Itertools; -use once_cell::sync::OnceCell; use revm_inspectors::tracing::types::{DecodedCallLog, DecodedCallTrace}; use rustc_hash::FxHashMap; -use std::collections::{hash_map::Entry, BTreeMap, HashMap}; +use std::{ + collections::{hash_map::Entry, BTreeMap, HashMap}, + sync::OnceLock, +}; mod precompiles; @@ -145,7 +147,7 @@ impl CallTraceDecoder { pub fn new() -> &'static Self { // If you want to take arguments in this function, assign them to the fields of the cloned // lazy instead of removing it - static INIT: OnceCell = OnceCell::new(); + static INIT: OnceLock = OnceLock::new(); INIT.get_or_init(Self::init) } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index eb3e94406a080..a4fce5cc39588 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -79,7 +79,6 @@ dunce.workspace = true futures.workspace = true indicatif = "0.17" itertools.workspace = true -once_cell.workspace = true parking_lot.workspace = true regex = { version = "1", default-features = false } reqwest = { workspace = true, features = ["json"] } diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index c1c9f7db83e14..d3097854c9dfb 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -16,9 +16,8 @@ use foundry_compilers::{ info::ContractInfo, utils::canonicalize, }; -use once_cell::sync::Lazy; use regex::Regex; -use std::fmt; +use std::{fmt, sync::LazyLock}; /// CLI arguments for `forge inspect`. #[derive(Clone, Debug, Parser)] @@ -398,8 +397,8 @@ fn print_yul(yul: Option<&str>, pretty: bool) -> Result<()> { eyre::bail!("Could not get IR output"); }; - static YUL_COMMENTS: Lazy = - Lazy::new(|| Regex::new(r"(///.*\n\s*)|(\s*/\*\*.*\*/)").unwrap()); + static YUL_COMMENTS: LazyLock = + LazyLock::new(|| Regex::new(r"(///.*\n\s*)|(\s*/\*\*.*\*/)").unwrap()); if pretty { println!("{}", YUL_COMMENTS.replace_all(yul, "")); diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 57096f8592e6f..448d5b1ad7b7b 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -7,18 +7,18 @@ use foundry_cli::{ }; use foundry_common::fs; use foundry_config::{impl_figment_convert_basic, Config}; -use once_cell::sync::Lazy; use regex::Regex; use semver::Version; use std::{ io::IsTerminal, path::{Path, PathBuf}, str, + sync::LazyLock, }; use yansi::Paint; -static DEPENDENCY_VERSION_TAG_REGEX: Lazy = - Lazy::new(|| Regex::new(r"^v?\d+(\.\d+)*$").unwrap()); +static DEPENDENCY_VERSION_TAG_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r"^v?\d+(\.\d+)*$").unwrap()); /// CLI arguments for `forge install`. #[derive(Clone, Debug, Parser)] diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 6c102c9d6fc5c..8c3d57fc3135c 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -4,7 +4,6 @@ use clap::{builder::RangedU64ValueParser, Parser, ValueHint}; use eyre::{Context, Result}; use forge::result::{SuiteTestResult, TestKindReport, TestOutcome}; use foundry_cli::utils::STATIC_FUZZ_SEED; -use once_cell::sync::Lazy; use regex::Regex; use std::{ cmp::Ordering, @@ -13,12 +12,13 @@ use std::{ io::{self, BufRead}, path::{Path, PathBuf}, str::FromStr, + sync::LazyLock, }; use yansi::Paint; /// A regex that matches a basic snapshot entry like /// `Test:testDeposit() (gas: 58804)` -pub static RE_BASIC_SNAPSHOT_ENTRY: Lazy = Lazy::new(|| { +pub static RE_BASIC_SNAPSHOT_ENTRY: LazyLock = LazyLock::new(|| { Regex::new(r"(?P(.*?)):(?P(\w+)\s*\((.*?)\))\s*\(((gas:)?\s*(?P\d+)|(runs:\s*(?P\d+),\s*μ:\s*(?P\d+),\s*~:\s*(?P\d+))|(runs:\s*(?P\d+),\s*calls:\s*(?P\d+),\s*reverts:\s*(?P\d+)))\)").unwrap() }); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 480a924a07fc8..fdef2f2ecdb4a 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -20,17 +20,16 @@ use foundry_evm::{ opts::{Env, EvmOpts}, }; use foundry_test_utils::{fd_lock, init_tracing, rpc::next_rpc_endpoint}; -use once_cell::sync::Lazy; use std::{ env, fmt, io::Write, path::{Path, PathBuf}, - sync::Arc, + sync::{Arc, LazyLock}, }; pub const RE_PATH_SEPARATOR: &str = "/"; const TESTDATA: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata"); -static VYPER: Lazy = Lazy::new(|| std::env::temp_dir().join("vyper")); +static VYPER: LazyLock = LazyLock::new(|| std::env::temp_dir().join("vyper")); /// Profile for the tests group. Used to configure separate configurations for test runs. pub enum ForgeTestProfile { @@ -334,16 +333,16 @@ pub fn get_compiled(project: &mut Project) -> ProjectCompileOutput { } /// Default data for the tests group. -pub static TEST_DATA_DEFAULT: Lazy = - Lazy::new(|| ForgeTestData::new(ForgeTestProfile::Default)); +pub static TEST_DATA_DEFAULT: LazyLock = + LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Default)); /// Data for tests requiring Cancun support on Solc and EVM level. -pub static TEST_DATA_CANCUN: Lazy = - Lazy::new(|| ForgeTestData::new(ForgeTestProfile::Cancun)); +pub static TEST_DATA_CANCUN: LazyLock = + LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Cancun)); /// Data for tests requiring Cancun support on Solc and EVM level. -pub static TEST_DATA_MULTI_VERSION: Lazy = - Lazy::new(|| ForgeTestData::new(ForgeTestProfile::MultiVersion)); +pub static TEST_DATA_MULTI_VERSION: LazyLock = + LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::MultiVersion)); pub fn manifest_root() -> &'static Path { let mut root = Path::new(env!("CARGO_MANIFEST_DIR")); diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index db47ce6024176..960e22124f4ac 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -24,7 +24,6 @@ alloy-provider.workspace = true eyre.workspace = true fd-lock = "4.0.0" -once_cell.workspace = true parking_lot.workspace = true similar-asserts.workspace = true regex = "1" diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 8d4229da79bb8..96415af3fb735 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -1,12 +1,14 @@ //! RPC API keys utilities. use foundry_config::NamedChain; -use once_cell::sync::Lazy; use rand::seq::SliceRandom; -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::{ + atomic::{AtomicUsize, Ordering}, + LazyLock, +}; // List of general purpose infura keys to rotate through -static INFURA_KEYS: Lazy> = Lazy::new(|| { +static INFURA_KEYS: LazyLock> = LazyLock::new(|| { let mut keys = vec![ // "16a8be88795540b9b3903d8de0f7baa5", // "f4a0bdad42674adab5fc0ac077ffab2b", @@ -19,7 +21,7 @@ static INFURA_KEYS: Lazy> = Lazy::new(|| { }); // List of alchemy keys for mainnet -static ALCHEMY_KEYS: Lazy> = Lazy::new(|| { +static ALCHEMY_KEYS: LazyLock> = LazyLock::new(|| { let mut keys = vec![ "ib1f4u1ojm-9lJJypwkeZeG-75TJRB7O", "7mTtk6IW4DwroGnKmG_bOWri2hyaGYhX", @@ -56,7 +58,7 @@ static ALCHEMY_KEYS: Lazy> = Lazy::new(|| { }); // List of etherscan keys for mainnet -static ETHERSCAN_MAINNET_KEYS: Lazy> = Lazy::new(|| { +static ETHERSCAN_MAINNET_KEYS: LazyLock> = LazyLock::new(|| { let mut keys = vec![ "MCAUM7WPE9XP5UQMZPCKIBUJHPM1C24FP6", "JW6RWCG2C5QF8TANH4KC7AYIF1CX7RB5D1", diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 7ed13cf14257d..5d06a8c69f29b 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -9,7 +9,6 @@ use foundry_compilers::{ ArtifactOutput, ConfigurableArtifacts, PathStyle, ProjectPathsConfig, }; use foundry_config::Config; -use once_cell::sync::Lazy; use parking_lot::Mutex; use regex::Regex; use snapbox::cmd::OutputAssert; @@ -22,27 +21,27 @@ use std::{ process::{ChildStdin, Command, Output, Stdio}, sync::{ atomic::{AtomicUsize, Ordering}, - Arc, + Arc, LazyLock, }, }; -static CURRENT_DIR_LOCK: Lazy> = Lazy::new(|| Mutex::new(())); +static CURRENT_DIR_LOCK: LazyLock> = LazyLock::new(|| Mutex::new(())); /// The commit of forge-std to use. const FORGE_STD_REVISION: &str = include_str!("../../../testdata/forge-std-rev"); /// Stores whether `stdout` is a tty / terminal. -pub static IS_TTY: Lazy = Lazy::new(|| std::io::stdout().is_terminal()); +pub static IS_TTY: LazyLock = LazyLock::new(|| std::io::stdout().is_terminal()); /// Global default template path. Contains the global template project from which all other /// temp projects are initialized. See [`initialize()`] for more info. -static TEMPLATE_PATH: Lazy = - Lazy::new(|| env::temp_dir().join("foundry-forge-test-template")); +static TEMPLATE_PATH: LazyLock = + LazyLock::new(|| env::temp_dir().join("foundry-forge-test-template")); /// Global default template lock. If its contents are not exactly `"1"`, the global template will /// be re-initialized. See [`initialize()`] for more info. -static TEMPLATE_LOCK: Lazy = - Lazy::new(|| env::temp_dir().join("foundry-forge-test-template.lock")); +static TEMPLATE_LOCK: LazyLock = + LazyLock::new(|| env::temp_dir().join("foundry-forge-test-template.lock")); /// Global test identifier. static NEXT_ID: AtomicUsize = AtomicUsize::new(0); @@ -219,7 +218,7 @@ impl ExtTester { /// This doesn't always run `forge init`, instead opting to copy an already-initialized template /// project from a global template path. This is done to speed up tests. /// -/// This used to use a `static` [`Lazy`], but this approach does not with `cargo-nextest` because it +/// This used to use a `static` `Lazy`, but this approach does not with `cargo-nextest` because it /// runs each test in a separate process. Instead, we use a global lock file to ensure that only one /// test can initialize the template at a time. pub fn initialize(target: &Path) { @@ -1077,7 +1076,7 @@ fn test_assert() -> snapbox::Assert { } fn test_redactions() -> snapbox::Redactions { - static REDACTIONS: Lazy = Lazy::new(|| { + static REDACTIONS: LazyLock = LazyLock::new(|| { let mut r = snapbox::Redactions::new(); let redactions = [ ("[SOLC_VERSION]", r"Solc( version)? \d+.\d+.\d+"), @@ -1121,7 +1120,7 @@ pub trait OutputExt { /// Patterns to remove from fixtures before comparing output /// /// This should strip everything that can vary from run to run, like elapsed time, file paths -static IGNORE_IN_FIXTURES: Lazy = Lazy::new(|| { +static IGNORE_IN_FIXTURES: LazyLock = LazyLock::new(|| { let re = &[ // solc version r" ?Solc(?: version)? \d+.\d+.\d+", diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 3ef9b4fb425d9..4512d7801b6d2 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -37,7 +37,6 @@ async-trait.workspace = true futures.workspace = true semver.workspace = true regex = { version = "1", default-features = false } -once_cell.workspace = true yansi.workspace = true itertools.workspace = true diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 3109a3d081869..9136c200d7a29 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -23,17 +23,16 @@ use foundry_compilers::{artifacts::BytecodeObject, Artifact}; use foundry_config::{Chain, Config}; use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; use futures::FutureExt; -use once_cell::sync::Lazy; use regex::Regex; use semver::{BuildMetadata, Version}; -use std::fmt::Debug; +use std::{fmt::Debug, sync::LazyLock}; mod flatten; mod standard_json; -pub static RE_BUILD_COMMIT: Lazy = - Lazy::new(|| Regex::new(r"(?Pcommit\.[0-9,a-f]{8})").unwrap()); +pub static RE_BUILD_COMMIT: LazyLock = + LazyLock::new(|| Regex::new(r"(?Pcommit\.[0-9,a-f]{8})").unwrap()); #[derive(Clone, Debug, Default)] #[non_exhaustive] From 93fd555283d4d6da9a4922b57fadad2e3060794c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:41:49 +0200 Subject: [PATCH 1377/1963] test: unflake cast storage layout test (#8720) --- crates/cast/tests/cli/main.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index fcbeaf4226775..6ef092cb1e717 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,10 +1,11 @@ //! Contains various tests for checking cast commands +use alloy_chains::NamedChain; use alloy_primitives::{address, b256, Address, B256}; use anvil::{Hardfork, NodeConfig}; use foundry_test_utils::{ casttest, - rpc::{next_http_rpc_endpoint, next_ws_rpc_endpoint}, + rpc::{next_http_rpc_endpoint, next_rpc_endpoint, next_ws_rpc_endpoint}, str, util::OutputExt, }; @@ -825,17 +826,20 @@ casttest!(storage, |_prj, cmd| { // casttest!(storage_layout, |_prj, cmd| { - cmd.cast_fuse().args([ - "storage", - "--rpc-url", - "https://mainnet.optimism.io", - "--block", - "110000000", - "--etherscan-api-key", - "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46", - "0xB67c152E69217b5aCB85A2e19dF13423351b0E27", - ]); - let output = r#"| Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | + cmd.cast_fuse() + .args([ + "storage", + "--rpc-url", + next_rpc_endpoint(NamedChain::Optimism).as_str(), + "--block", + "110000000", + "--etherscan-api-key", + "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46", + "0xB67c152E69217b5aCB85A2e19dF13423351b0E27", + ]) + .assert_success() + .stdout_eq(str![[r#" +| Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | |-------------------------------|-----------------------------------------------------------------|------|--------|-------|---------------------------------------------------|--------------------------------------------------------------------|----------------------------------------------------| | gov | address | 0 | 0 | 20 | 1352965747418285184211909460723571462248744342032 | 0x000000000000000000000000ecfd15165d994c2766fbe0d6bacdc2e8dedfd210 | contracts/perp/PositionManager.sol:PositionManager | | _status | uint256 | 1 | 0 | 32 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | @@ -863,8 +867,8 @@ casttest!(storage_layout, |_prj, cmd| { | closePositionRequests | mapping(bytes32 => struct PositionManager.ClosePositionRequest) | 20 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | | managers | mapping(address => bool) | 21 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | | approvedManagers | mapping(address => mapping(address => bool)) | 22 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -"#; - assert_eq!(cmd.stdout_lossy(), output); + +"#]]); }); casttest!(balance, |_prj, cmd| { From 8b4d447b5d55e61784326ef623a3e432da658c04 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:43:22 +0200 Subject: [PATCH 1378/1963] chore: update CODEOWNERS (#8721) --- .github/CODEOWNERS | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4eea49b388b79..9f19e678f5f72 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,10 +1 @@ -* @danipopes @evalir @mattsse - -crates/anvil/ @danipopes @mattsse @evalir -crates/cheatcodes/ @danipopes @mattsse @klkvr @evalir -crates/evm/coverage/ @onbjerg -crates/fmt/ @rkrasiuk -crates/linking/ @klkvr -crates/macros/ @danipopes -crates/script/ @danipopes @mattsse @klkvr -crates/wallets/ @klkvr +* @danipopes @klkvr @mattsse From 5c52be617e0d7578f2a68f56b54ac495def22cb9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:49:21 +0200 Subject: [PATCH 1379/1963] chore(deps): breaking bumps (#8719) --- Cargo.lock | 145 +++++++++++++-------------- Cargo.toml | 4 +- crates/chisel/Cargo.toml | 2 +- crates/chisel/src/solidity_helper.rs | 2 +- crates/debugger/Cargo.toml | 6 +- crates/debugger/src/tui/draw.rs | 60 +++++------ crates/doc/Cargo.toml | 2 +- crates/evm/abi/src/console/mod.rs | 44 ++++---- crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/clone.rs | 4 +- 10 files changed, 132 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 132c4840d1858..66b4357a48705 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2115,13 +2115,11 @@ dependencies = [ [[package]] name = "clipboard-win" -version = "4.5.0" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" dependencies = [ "error-code", - "str-buf", - "winapi", ] [[package]] @@ -2237,7 +2235,7 @@ version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ - "crossterm", + "crossterm 0.27.0", "strum", "strum_macros", "unicode-width", @@ -2245,13 +2243,14 @@ dependencies = [ [[package]] name = "compact_str" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644" dependencies = [ "castaway", "cfg-if", "itoa", + "rustversion", "ryu", "static_assertions", ] @@ -2319,6 +2318,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -2434,8 +2442,21 @@ dependencies = [ "bitflags 2.6.0", "crossterm_winapi", "libc", - "mio 0.8.11", "parking_lot", + "winapi", +] + +[[package]] +name = "crossterm" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" +dependencies = [ + "bitflags 2.6.0", + "crossterm_winapi", + "mio 1.0.2", + "parking_lot", + "rustix", "signal-hook", "signal-hook-mio", "winapi", @@ -2642,7 +2663,7 @@ version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version 0.4.0", @@ -2664,9 +2685,11 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ + "convert_case 0.6.0", "proc-macro2", "quote", "syn 2.0.75", + "unicode-xid", ] [[package]] @@ -2944,13 +2967,9 @@ dependencies = [ [[package]] name = "error-code" -version = "2.3.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" -dependencies = [ - "libc", - "str-buf", -] +checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b" [[package]] name = "eth-keystore" @@ -3148,17 +3167,6 @@ dependencies = [ "bytes", ] -[[package]] -name = "fd-lock" -version = "3.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" -dependencies = [ - "cfg-if", - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "fd-lock" version = "4.0.2" @@ -3364,7 +3372,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "auto_impl", - "derive_more 0.99.18", + "derive_more 1.0.0", "eyre", "forge-fmt", "foundry-compilers", @@ -3824,7 +3832,7 @@ name = "foundry-debugger" version = "0.2.0" dependencies = [ "alloy-primitives", - "crossterm", + "crossterm 0.28.1", "eyre", "foundry-common", "foundry-compilers", @@ -3868,7 +3876,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-sol-types", - "derive_more 0.99.18", + "derive_more 1.0.0", "foundry-common-fmt", "foundry-macros", "foundry-test-utils", @@ -4031,7 +4039,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "eyre", - "fd-lock 4.0.2", + "fd-lock", "foundry-common", "foundry-compilers", "foundry-config", @@ -5104,6 +5112,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "instability" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" +dependencies = [ + "quote", + "syn 2.0.75", +] + [[package]] name = "instant" version = "0.1.13" @@ -5169,15 +5187,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -5616,20 +5625,20 @@ checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi 0.3.9", "libc", + "log", "wasi", "windows-sys 0.52.0", ] [[package]] name = "mockall" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43766c2b5203b10de348ffe19f7e54564b64f3d6018ff7648d1e2d6d3a0f0a48" +checksum = "d4c28b3fb6d753d28c20e826cd46ee611fda1cf3cde03a443a974043247c065a" dependencies = [ "cfg-if", "downcast", "fragile", - "lazy_static", "mockall_derive", "predicates", "predicates-tree", @@ -5637,9 +5646,9 @@ dependencies = [ [[package]] name = "mockall_derive" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cbce79ec385a1d4f54baa90a76401eb15d9cab93685f62e7e9f942aa00ae2" +checksum = "341014e7f530314e9a1fdbc7400b244efea7122662c96bfa248c31da5bfb2020" dependencies = [ "cfg-if", "proc-macro2", @@ -6854,19 +6863,20 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.26.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f44c9e68fd46eda15c646fbb85e1040b657a58cdc8c98db1d97a55930d991eef" +checksum = "5ba6a365afbe5615999275bea2446b970b10a41102500e27ce7678d50d978303" dependencies = [ "bitflags 2.6.0", "cassowary", "compact_str", - "crossterm", - "itertools 0.12.1", + "crossterm 0.28.1", + "instability", + "itertools 0.13.0", "lru", "paste", - "stability", "strum", + "strum_macros", "unicode-segmentation", "unicode-truncate", "unicode-width", @@ -7385,25 +7395,24 @@ dependencies = [ [[package]] name = "rustyline" -version = "12.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" +checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63" dependencies = [ "bitflags 2.6.0", "cfg-if", "clipboard-win", - "fd-lock 3.0.13", + "fd-lock", "home", "libc", "log", "memchr", - "nix 0.26.4", + "nix 0.28.0", "radix_trie", - "scopeguard", "unicode-segmentation", "unicode-width", "utf8parse", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -7871,7 +7880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio 0.8.11", + "mio 1.0.2", "signal-hook", ] @@ -8057,28 +8066,12 @@ dependencies = [ "der", ] -[[package]] -name = "stability" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" -dependencies = [ - "quote", - "syn 2.0.75", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "str-buf" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" - [[package]] name = "string_cache" version = "0.8.7" @@ -8342,9 +8335,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" +version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d" dependencies = [ "cc", "libc", @@ -8352,9 +8345,9 @@ dependencies = [ [[package]] name = "tikv-jemallocator" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +checksum = "4cec5ff18518d81584f477e9bfdf957f5bb0979b0bac3af4ca30b5b3ae2d2865" dependencies = [ "libc", "tikv-jemalloc-sys", diff --git a/Cargo.toml b/Cargo.toml index 8563d1add39a1..5ac49d2df8db0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -221,7 +221,7 @@ chrono = { version = "0.4", default-features = false, features = [ "std", ] } color-eyre = "0.6" -derive_more = "0.99" +derive_more = { version = "1.0", features = ["full"] } dunce = "1" evm-disassembler = "0.5" eyre = "0.6" @@ -244,7 +244,7 @@ tracing = "0.1" tracing-subscriber = "0.3" vergen = { version = "8", default-features = false } indexmap = "2.2" -tikv-jemallocator = "0.5.4" +tikv-jemallocator = "0.6" url = "2" num-format = "0.4.4" yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index bbfeb6ee9dbb1..5d8ad4d2c4dd1 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -53,7 +53,7 @@ eyre.workspace = true regex = "1" reqwest.workspace = true revm.workspace = true -rustyline = "12" +rustyline = "14" semver.workspace = true serde_json.workspace = true serde.workspace = true diff --git a/crates/chisel/src/solidity_helper.rs b/crates/chisel/src/solidity_helper.rs index 84140c820a542..4707ab37b789f 100644 --- a/crates/chisel/src/solidity_helper.rs +++ b/crates/chisel/src/solidity_helper.rs @@ -211,7 +211,7 @@ impl Highlighter for SolidityHelper { Self::highlight(line) } - fn highlight_char(&self, line: &str, pos: usize) -> bool { + fn highlight_char(&self, line: &str, pos: usize, _forced: bool) -> bool { pos == line.len() } diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index 9f96eb7f06dae..6ccb630ca0c98 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -20,9 +20,11 @@ revm-inspectors.workspace = true alloy-primitives.workspace = true -crossterm = "0.27" +crossterm = "0.28" eyre.workspace = true -ratatui = { version = "0.26", default-features = false, features = ["crossterm"] } +ratatui = { version = "0.28", default-features = false, features = [ + "crossterm", +] } revm.workspace = true tracing.workspace = true serde.workspace = true diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 509b986fdb323..0f2399a20da9c 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -8,9 +8,9 @@ use foundry_evm_traces::debug::SourceData; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, - terminal::Frame, text::{Line, Span, Text}, widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap}, + Frame, }; use revm::interpreter::opcode; use revm_inspectors::tracing::types::CallKind; @@ -25,17 +25,17 @@ impl DebuggerContext<'_> { #[inline] fn draw_layout(&self, f: &mut Frame<'_>) { // We need 100 columns to display a 32 byte word in the memory and stack panes. - let size = f.size(); + let area = f.area(); let min_width = 100; let min_height = 16; - if size.width < min_width || size.height < min_height { + if area.width < min_width || area.height < min_height { self.size_too_small(f, min_width, min_height); return; } // The horizontal layout draws these panes at 50% width. let min_column_width_for_horizontal = 200; - if size.width >= min_column_width_for_horizontal { + if area.width >= min_column_width_for_horizontal { self.horizontal_layout(f); } else { self.vertical_layout(f); @@ -48,14 +48,14 @@ impl DebuggerContext<'_> { let l1 = "Terminal size too small:"; lines.push(Line::from(l1)); - let size = f.size(); - let width_color = if size.width >= min_width { Color::Green } else { Color::Red }; - let height_color = if size.height >= min_height { Color::Green } else { Color::Red }; + let area = f.area(); + let width_color = if area.width >= min_width { Color::Green } else { Color::Red }; + let height_color = if area.height >= min_height { Color::Green } else { Color::Red }; let l2 = vec![ Span::raw("Width = "), - Span::styled(size.width.to_string(), Style::new().fg(width_color)), + Span::styled(area.width.to_string(), Style::new().fg(width_color)), Span::raw(" Height = "), - Span::styled(size.height.to_string(), Style::new().fg(height_color)), + Span::styled(area.height.to_string(), Style::new().fg(height_color)), ]; lines.push(Line::from(l2)); @@ -66,7 +66,7 @@ impl DebuggerContext<'_> { let paragraph = Paragraph::new(lines).alignment(Alignment::Center).wrap(Wrap { trim: true }); - f.render_widget(paragraph, size) + f.render_widget(paragraph, area) } /// Draws the layout in vertical mode. @@ -85,7 +85,7 @@ impl DebuggerContext<'_> { /// |-----------------------------| /// ``` fn vertical_layout(&self, f: &mut Frame<'_>) { - let area = f.size(); + let area = f.area(); let h_height = if self.show_shortcuts { 4 } else { 0 }; // NOTE: `Layout::split` always returns a slice of the same length as the number of @@ -135,7 +135,7 @@ impl DebuggerContext<'_> { /// |-----------------|-----------| /// ``` fn horizontal_layout(&self, f: &mut Frame<'_>) { - let area = f.size(); + let area = f.area(); let h_height = if self.show_shortcuts { 4 } else { 0 }; // Split off footer. @@ -465,7 +465,7 @@ impl DebuggerContext<'_> { // Color memory region based on read/write. let mut offset = None; - let mut size = None; + let mut len = None; let mut write_offset = None; let mut write_size = None; let mut color = None; @@ -475,13 +475,13 @@ impl DebuggerContext<'_> { if let Some(accesses) = get_buffer_accesses(step.op.get(), stack) { if let Some(read_access) = accesses.read { offset = Some(read_access.1.offset); - size = Some(read_access.1.size); + len = Some(read_access.1.len); color = Some(Color::Cyan); } if let Some(write_access) = accesses.write { if self.active_buffer == BufferKind::Memory { write_offset = Some(write_access.offset); - write_size = Some(write_access.size); + write_size = Some(write_access.len); } } } @@ -501,7 +501,7 @@ impl DebuggerContext<'_> { { if self.active_buffer == BufferKind::Memory { offset = Some(write_access.offset); - size = Some(write_access.size); + len = Some(write_access.len); color = Some(Color::Green); } } @@ -530,10 +530,10 @@ impl DebuggerContext<'_> { let mut byte_color = Color::White; let mut end = None; let idx = i * 32 + j; - if let (Some(offset), Some(size), Some(color)) = (offset, size, color) { - end = Some(offset + size); - if (offset..offset + size).contains(&idx) { - // [offset, offset + size] is the memory region to be colored. + if let (Some(offset), Some(len), Some(color)) = (offset, len, color) { + end = Some(offset + len); + if (offset..offset + len).contains(&idx) { + // [offset, offset + len] is the memory region to be colored. // If a byte at row i and column j in the memory panel // falls in this region, set the color. byte_color = color; @@ -627,7 +627,7 @@ impl<'a> SourceLines<'a> { /// Container for buffer access information. struct BufferAccess { offset: usize, - size: usize, + len: usize, } /// Container for read and write buffer access information. @@ -639,15 +639,15 @@ struct BufferAccesses { } /// The memory_access variable stores the index on the stack that indicates the buffer -/// offset/size accessed by the given opcode: -/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) +/// offset/len accessed by the given opcode: +/// (read buffer, buffer read offset, buffer read len, write memory offset, write memory len) /// \>= 1: the stack index /// 0: no memory access -/// -1: a fixed size of 32 bytes -/// -2: a fixed size of 1 byte +/// -1: a fixed len of 32 bytes +/// -2: a fixed len of 1 byte /// /// The return value is a tuple about accessed buffer region by the given opcode: -/// (read buffer, buffer read offset, buffer read size, write memory offset, write memory size) +/// (read buffer, buffer read offset, buffer read len, write memory offset, write memory len) fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { let buffer_access = match op { opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => { @@ -696,12 +696,12 @@ fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { if buffer_access.0.is_some() || buffer_access.1.is_some() { let (read, write) = buffer_access; let read_access = read.and_then(|b| { - let (buffer, offset, size) = b; - Some((buffer, BufferAccess { offset: get_size(offset)?, size: get_size(size)? })) + let (buffer, offset, len) = b; + Some((buffer, BufferAccess { offset: get_size(offset)?, len: get_size(len)? })) }); let write_access = write.and_then(|b| { - let (offset, size) = b; - Some(BufferAccess { offset: get_size(offset)?, size: get_size(size)? }) + let (offset, len) = b; + Some(BufferAccess { offset: get_size(offset)?, len: get_size(len)? }) }); Some(BufferAccesses { read: read_access, write: write_access }) } else { diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 22abae5bec2a5..0dcd407476c0d 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -21,7 +21,7 @@ foundry-config.workspace = true alloy-primitives.workspace = true auto_impl.workspace = true -derive_more = "0.99" +derive_more.workspace = true eyre.workspace = true itertools.workspace = true mdbook = { version = "0.4", default-features = false, features = ["search"] } diff --git a/crates/evm/abi/src/console/mod.rs b/crates/evm/abi/src/console/mod.rs index 3f10c769e7927..9ce96e4cea110 100644 --- a/crates/evm/abi/src/console/mod.rs +++ b/crates/evm/abi/src/console/mod.rs @@ -12,70 +12,70 @@ sol! { #[sol(abi)] #[derive(Display)] interface Console { - #[display(fmt = "{val}")] + #[display("{val}")] event log(string val); - #[display(fmt = "{}", "hex::encode_prefixed(val)")] + #[display("{}", hex::encode_prefixed(val))] event logs(bytes val); - #[display(fmt = "{val}")] + #[display("{val}")] event log_address(address val); - #[display(fmt = "{val}")] + #[display("{val}")] event log_bytes32(bytes32 val); - #[display(fmt = "{val}")] + #[display("{val}")] event log_int(int val); - #[display(fmt = "{val}")] + #[display("{val}")] event log_uint(uint val); - #[display(fmt = "{}", "hex::encode_prefixed(val)")] + #[display("{}", hex::encode_prefixed(val))] event log_bytes(bytes val); - #[display(fmt = "{val}")] + #[display("{val}")] event log_string(string val); - #[display(fmt = "[{}]", "val.iter().format(\", \")")] + #[display("[{}]", val.iter().format(", "))] event log_array(uint256[] val); - #[display(fmt = "[{}]", "val.iter().format(\", \")")] + #[display("[{}]", val.iter().format(", "))] event log_array(int256[] val); - #[display(fmt = "[{}]", "val.iter().format(\", \")")] + #[display("[{}]", val.iter().format(", "))] event log_array(address[] val); - #[display(fmt = "{key}: {val}")] + #[display("{key}: {val}")] event log_named_address(string key, address val); - #[display(fmt = "{key}: {val}")] + #[display("{key}: {val}")] event log_named_bytes32(string key, bytes32 val); - #[display(fmt = "{key}: {}", "format_units_int(val, decimals)")] + #[display("{key}: {}", format_units_int(val, decimals))] event log_named_decimal_int(string key, int val, uint decimals); - #[display(fmt = "{key}: {}", "format_units_uint(val, decimals)")] + #[display("{key}: {}", format_units_uint(val, decimals))] event log_named_decimal_uint(string key, uint val, uint decimals); - #[display(fmt = "{key}: {val}")] + #[display("{key}: {val}")] event log_named_int(string key, int val); - #[display(fmt = "{key}: {val}")] + #[display("{key}: {val}")] event log_named_uint(string key, uint val); - #[display(fmt = "{key}: {}", "hex::encode_prefixed(val)")] + #[display("{key}: {}", hex::encode_prefixed(val))] event log_named_bytes(string key, bytes val); - #[display(fmt = "{key}: {val}")] + #[display("{key}: {val}")] event log_named_string(string key, string val); - #[display(fmt = "{key}: [{}]", "val.iter().format(\", \")")] + #[display("{key}: [{}]", val.iter().format(", "))] event log_named_array(string key, uint256[] val); - #[display(fmt = "{key}: [{}]", "val.iter().format(\", \")")] + #[display("{key}: [{}]", val.iter().format(", "))] event log_named_array(string key, int256[] val); - #[display(fmt = "{key}: [{}]", "val.iter().format(\", \")")] + #[display("{key}: [{}]", val.iter().format(", "))] event log_named_array(string key, address[] val); } } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index a4fce5cc39588..4f9110ff60e74 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -114,7 +114,7 @@ tikv-jemallocator = { workspace = true, optional = true } anvil.workspace = true foundry-test-utils.workspace = true -mockall = "0.12" +mockall = "0.13" criterion = "0.5" globset = "0.4" paste = "1.0" diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index f2c07294a835f..65b3cf01d6d04 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -575,11 +575,9 @@ pub fn find_main_contract<'a>( rv.ok_or_else(|| eyre::eyre!("contract not found")) } -#[cfg(test)] -use mockall::automock; /// EtherscanClient is a trait that defines the methods to interact with Etherscan. /// It is defined as a wrapper of the `foundry_block_explorers::Client` to allow mocking. -#[cfg_attr(test, automock)] +#[cfg_attr(test, mockall::automock)] pub(crate) trait EtherscanClient { async fn contract_source_code( &self, From 70ef94a90f4d2adb5dd932b417e7cf37410cebb3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:07:17 +0300 Subject: [PATCH 1380/1963] fix(forge): reset gas to original after pauseGasMetering (#8717) --- crates/cheatcodes/src/inspector.rs | 8 ++++- crates/forge/tests/cli/test_cmd.rs | 48 ++++++++++++++++++++++++++++++ crates/test-utils/src/util.rs | 16 +++++++++- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 02c97ac273798..65dabcf2d521b 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1354,7 +1354,13 @@ impl Cheatcodes { // inside it. self.gas_metering_create = Some(None) } - opcode::STOP | opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { + opcode::STOP => { + // Reset gas to value recorded when paused. + interpreter.gas = *gas; + self.gas_metering = None; + self.gas_metering_create = None; + } + opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { match &self.gas_metering_create { None | Some(None) => { // If we are ending current execution frame, we want to reset diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 40890c9dbb44c..3b0cbfb7f24e7 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1238,3 +1238,51 @@ contract DeterministicRandomnessTest is Test { assert_ne!(res4, res1); assert_ne!(res4, res3); }); + +// tests that `pauseGasMetering` used at the end of test does not produce meaningless values +// see https://github.com/foundry-rs/foundry/issues/5491 +forgetest_init!(repro_5491, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "ATest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract ATest is Test { + function testWeirdGas1() public { + vm.pauseGasMetering(); + } + + function testWeirdGas2() public { + uint256 a = 1; + uint256 b = a + 1; + require(b == 2, "b is not 2"); + vm.pauseGasMetering(); + } + + function testNormalGas() public { + vm.pauseGasMetering(); + vm.resumeGasMetering(); + } + + function testWithAssembly() public { + vm.pauseGasMetering(); + assembly { + return(0, 0) + } + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" +... +[PASS] testNormalGas() (gas: 3202) +[PASS] testWeirdGas1() (gas: 3040) +[PASS] testWeirdGas2() (gas: 3148) +[PASS] testWithAssembly() (gas: 3083) +... +"#]]); +}); diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 5d06a8c69f29b..593dbdbe1f3d9 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -624,6 +624,7 @@ impl TestProject { current_dir_lock: None, saved_cwd: pretty_err("", std::env::current_dir()), stdin_fun: None, + redact_output: true, } } @@ -638,6 +639,7 @@ impl TestProject { current_dir_lock: None, saved_cwd: pretty_err("", std::env::current_dir()), stdin_fun: None, + redact_output: true, } } @@ -735,6 +737,8 @@ pub struct TestCommand { // initial: Command, current_dir_lock: Option>, stdin_fun: Option>, + /// If true, command output is redacted. + redact_output: bool, } impl TestCommand { @@ -825,6 +829,12 @@ impl TestCommand { self } + /// Does not apply [`snapbox`] redactions to the command output. + pub fn with_no_redact(&mut self) -> &mut Self { + self.redact_output = false; + self + } + /// Returns the `Config` as spit out by `forge config` #[track_caller] pub fn config(&mut self) -> Config { @@ -1053,7 +1063,11 @@ stderr: /// Runs the command, returning a [`snapbox`] object to assert the command output. #[track_caller] pub fn assert(&mut self) -> OutputAssert { - OutputAssert::new(self.execute()).with_assert(test_assert()) + let assert = OutputAssert::new(self.execute()); + if self.redact_output { + return assert.with_assert(test_assert()); + }; + assert } /// Runs the command and asserts that it resulted in success. From 1dad817e099e4bb0a672e937b1c8d559702f5112 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 23 Aug 2024 13:53:42 +0800 Subject: [PATCH 1381/1963] feat(cast): get create2 address (#8724) * feat(cast): get create2 address * add additional documentation for `salt` --- crates/cast/bin/cmd/create2.rs | 59 ++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 0f751fc89f06e..ebf2b3ecab1b5 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -22,7 +22,7 @@ pub struct Create2Args { #[arg( long, short, - required_unless_present_any = &["ends_with", "matching"], + required_unless_present_any = &["ends_with", "matching", "salt"], value_name = "HEX" )] starts_with: Option, @@ -48,6 +48,23 @@ pub struct Create2Args { )] deployer: Address, + /// Salt to be used for the contract deployment. This option separate from the default salt + /// mining with filters. + #[arg( + long, + conflicts_with_all = [ + "starts_with", + "ends_with", + "matching", + "case_sensitive", + "caller", + "seed", + "no_random" + ], + value_name = "HEX" + )] + salt: Option, + /// Init code of the contract to be deployed. #[arg(short, long, value_name = "HEX")] init_code: Option, @@ -87,6 +104,7 @@ impl Create2Args { matching, case_sensitive, deployer, + salt, init_code, init_code_hash, jobs, @@ -95,6 +113,21 @@ impl Create2Args { no_random, } = self; + let init_code_hash = if let Some(init_code_hash) = init_code_hash { + hex::FromHex::from_hex(init_code_hash) + } else if let Some(init_code) = init_code { + hex::decode(init_code).map(keccak256) + } else { + unreachable!(); + }?; + + if let Some(salt) = salt { + let salt = hex::FromHex::from_hex(salt)?; + let address = deployer.create2(salt, init_code_hash); + println!("{address}"); + return Ok(Create2Output { address, salt }); + } + let mut regexs = vec![]; if let Some(matches) = matching { @@ -134,14 +167,6 @@ impl Create2Args { let regex = RegexSetBuilder::new(regexs).case_insensitive(!case_sensitive).build()?; - let init_code_hash = if let Some(init_code_hash) = init_code_hash { - hex::FromHex::from_hex(init_code_hash) - } else if let Some(init_code) = init_code { - hex::decode(init_code).map(keccak256) - } else { - unreachable!(); - }?; - let mut n_threads = std::thread::available_parallelism().map_or(1, |n| n.get()); if let Some(jobs) = jobs { n_threads = n_threads.min(jobs.get()); @@ -302,6 +327,22 @@ mod tests { assert!(format!("{address:x}").starts_with("bb")); } + #[test] + fn create2_salt() { + let args = Create2Args::parse_from([ + "foundry-cli", + "--deployer=0x8ba1f109551bD432803012645Ac136ddd64DBA72", + "--salt=0x7c5ea36004851c764c44143b1dcb59679b11c9a68e5f41497f6cf3d480715331", + "--init-code=0x6394198df16000526103ff60206004601c335afa6040516060f3", + ]); + let create2_out = args.run().unwrap(); + let address = create2_out.address; + assert_eq!( + address, + Address::from_str("0x533AE9D683B10C02EBDB05471642F85230071FC3").unwrap() + ); + } + #[test] fn create2_init_code() { let init_code = "00"; From 2b1f8d6dd90f9790faf0528e05e60e573a7569ce Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 25 Aug 2024 05:36:38 +0000 Subject: [PATCH 1382/1963] chore(deps): weekly `cargo update` (#8737) --- Cargo.lock | 301 +++++++++++++++++++++++++++++------------------------ 1 file changed, 166 insertions(+), 135 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66b4357a48705..daa1a091a6022 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aes" version = "0.8.4" @@ -316,7 +322,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -551,7 +557,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -568,7 +574,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "syn-solidity", "tiny-keccak", ] @@ -586,7 +592,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.75", + "syn 2.0.76", "syn-solidity", ] @@ -1094,7 +1100,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1116,7 +1122,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1127,7 +1133,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1180,7 +1186,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1575,7 +1581,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -1811,9 +1817,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3054fea8a20d8ff3968d5b22cc27501d2b08dc4decdb31b184323f00c5ef23bb" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" dependencies = [ "serde", ] @@ -1923,9 +1929,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.13" +version = "1.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" dependencies = [ "jobserver", "libc", @@ -2065,9 +2071,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.18" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee158892bd7ce77aa15c208abbdb73e155d191c287a659b57abd5adb92feb03" +checksum = "531d7959c5bbb6e266cecdd0f20213639c3a5c3e4d615f97db87661745f781ff" dependencies = [ "clap", ] @@ -2091,7 +2097,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2539,7 +2545,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2550,7 +2556,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2623,7 +2629,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2644,7 +2650,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2654,7 +2660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2667,7 +2673,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2688,7 +2694,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "unicode-xid", ] @@ -2796,7 +2802,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2923,7 +2929,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3069,7 +3075,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.75", + "syn 2.0.76", "toml 0.8.19", "walkdir", ] @@ -3097,7 +3103,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.75", + "syn 2.0.76", "tempfile", "thiserror", "tiny-keccak", @@ -3127,9 +3133,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628b1881ed2b7f83a32418f6de735c49292065dfc225067687ee1d4fc59a134e" +checksum = "0ffb1f458e6901be6a6aaa485ce3a5d81478644edde1ffbe95da114ad9c94467" dependencies = [ "ruint", ] @@ -3152,9 +3158,9 @@ checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fastrlp" @@ -3248,12 +3254,12 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -3462,7 +3468,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4029,7 +4035,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4093,9 +4099,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "fs4" -version = "0.8.4" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e180ac76c23b45e767bd7ae9579bc0bb458618c4bc71835926e098e61d15f8" +checksum = "e8c6b3bd49c37d2aa3f3f2220233b29a7cd23f79d1fe70e5337d25fb390793de" dependencies = [ "rustix", "windows-sys 0.52.0", @@ -4188,7 +4194,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4335,9 +4341,9 @@ dependencies = [ [[package]] name = "gix-config-value" -version = "0.14.7" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b328997d74dd15dc71b2773b162cb4af9a25c424105e4876e6d0686ab41c383e" +checksum = "03f76169faa0dec598eac60f83d7fcdd739ec16596eca8fb144c88973dbe6f8c" dependencies = [ "bitflags 2.6.0", "bstr", @@ -4385,9 +4391,9 @@ dependencies = [ [[package]] name = "gix-glob" -version = "0.16.4" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7df15afa265cc8abe92813cd354d522f1ac06b29ec6dfa163ad320575cb447" +checksum = "74908b4bbc0a0a40852737e5d7889f676f081e340d5451a16e5b4c50d592f111" dependencies = [ "bitflags 2.6.0", "bstr", @@ -4437,9 +4443,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.9" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d23d5bbda31344d8abc8de7c075b3cf26e5873feba7c4a15d916bce67382bd9" +checksum = "38d5b8722112fa2fa87135298780bc833b0e9f6c56cc82795d209804b3a03484" dependencies = [ "bstr", "gix-trace", @@ -4472,9 +4478,9 @@ dependencies = [ [[package]] name = "gix-sec" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1547d26fa5693a7f34f05b4a3b59a90890972922172653bcb891ab3f09f436df" +checksum = "0fe4d52f30a737bbece5276fab5d3a8b276dc2650df963e293d0673be34e7a5f" dependencies = [ "bitflags 2.6.0", "gix-path", @@ -4572,9 +4578,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -4704,7 +4710,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4830,7 +4836,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -4869,7 +4875,7 @@ dependencies = [ "hyper 1.4.1", "hyper-util", "rustls 0.23.12", - "rustls-native-certs 0.7.1", + "rustls-native-certs 0.7.2", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -5119,7 +5125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5355,9 +5361,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.156" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libdbus-sys" @@ -5571,7 +5577,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5605,6 +5611,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "0.8.11" @@ -5653,7 +5668,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -5903,7 +5918,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6015,7 +6030,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6201,7 +6216,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6260,7 +6275,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6344,7 +6359,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6402,7 +6417,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6516,12 +6531,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "a909e6e8053fa1a5ad670f5816c7d93029ee1fa8898718490544a6b0d5d38b3e" dependencies = [ "proc-macro2", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6597,7 +6612,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "version_check", "yansi", ] @@ -6684,7 +6699,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -6799,9 +6814,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -6919,9 +6934,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -6980,9 +6995,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "async-compression", "base64 0.22.1", @@ -7008,7 +7023,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.12", - "rustls-native-certs 0.7.1", + "rustls-native-certs 0.7.2", "rustls-pemfile 2.1.3", "rustls-pki-types", "serde", @@ -7018,6 +7033,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.26.0", + "tokio-socks", "tokio-util", "tower-service", "url", @@ -7026,7 +7042,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots", - "winreg", + "windows-registry", ] [[package]] @@ -7045,9 +7061,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43cbb1576a147317c6990cf69d6cd5ef402df99f638616ba911006e9ec45866b" +checksum = "ec16f9b9d3cdaaf2f4b7ceaf004eb2c89df04e7ea29622584c0a6ec676bd0a83" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7318,9 +7334,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" dependencies = [ "openssl-probe", "rustls-pemfile 2.1.3", @@ -7502,7 +7518,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -7649,22 +7665,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -7675,14 +7691,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "indexmap 2.4.0", "itoa", @@ -7719,7 +7735,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -7778,7 +7794,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -8046,7 +8062,7 @@ dependencies = [ "walkdir", "yansi", "yash-fnmatch", - "zip 2.1.6", + "zip 2.2.0", "zip-extract", ] @@ -8123,7 +8139,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -8147,14 +8163,13 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5910befd515534a92e9424f250d952fe6f6dba6a92bd001dfeba1fb4a2f87c" +checksum = "7b638fb4b6a74ef632a18935d240596b2618c8eb5c888e9cbf3c689af9a4aded" dependencies = [ "const-hex", "dirs 5.0.1", "fs4", - "once_cell", "reqwest", "semver 1.0.23", "serde", @@ -8162,14 +8177,14 @@ dependencies = [ "sha2", "thiserror", "url", - "zip 2.1.6", + "zip 2.2.0", ] [[package]] name = "svm-rs-builds" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d5ea000fdbeab0b2739315f9093c75ea63030e5c44f92daa72401d11b48adda" +checksum = "813b21b9858cc493134b899c96e73c60f2e6043f050a17020e98ad8c2d9c9912" dependencies = [ "build_const", "const-hex", @@ -8191,9 +8206,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.75" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -8209,7 +8224,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -8223,6 +8238,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "tap" @@ -8311,7 +8329,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -8446,7 +8464,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -8480,6 +8498,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-socks" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -8599,7 +8629,7 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "http-body-util", @@ -8609,7 +8639,7 @@ dependencies = [ "percent-encoding", "pin-project 1.1.5", "prost", - "rustls-native-certs 0.7.1", + "rustls-native-certs 0.7.2", "rustls-pemfile 2.1.3", "socket2", "tokio", @@ -8716,7 +8746,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -8770,9 +8800,9 @@ dependencies = [ [[package]] name = "tracing-tracy" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be7f8874d6438e4263f9874c84eded5095bda795d9c7da6ea0192e1750d3ffe" +checksum = "c6a90519f16f55e5c62ffd5976349f10744435a919ecff83d918300575dfb69b" dependencies = [ "tracing-core", "tracing-subscriber", @@ -8781,9 +8811,9 @@ dependencies = [ [[package]] name = "tracy-client" -version = "0.17.1" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63de1e1d4115534008d8fd5788b39324d6f58fc707849090533828619351d855" +checksum = "373db47331c3407b343538df77eea2516884a0b126cdfb4b135acfd400015dd7" dependencies = [ "loom", "once_cell", @@ -8792,9 +8822,9 @@ dependencies = [ [[package]] name = "tracy-client-sys" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b98232a2447ce0a58f9a0bfb5f5e39647b5c597c994b63945fcccd1306fafb" +checksum = "49cf0064dcb31c99aa1244c1b93439359e53f72ed217eef5db50abd442241e9a" dependencies = [ "cc", ] @@ -8959,9 +8989,9 @@ checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" [[package]] name = "unsafe-libyaml" @@ -9116,7 +9146,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -9150,7 +9180,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9367,7 +9397,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -9378,7 +9408,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -9389,7 +9419,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -9400,7 +9430,18 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result 0.2.0", + "windows-strings", + "windows-targets 0.52.6", ] [[package]] @@ -9597,16 +9638,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "winsafe" version = "0.0.19" @@ -9685,7 +9716,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -9705,7 +9736,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -9729,9 +9760,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.1.6" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40dd8c92efc296286ce1fbd16657c5dbefff44f1b4ca01cc5f517d8b7b3d3e2e" +checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" dependencies = [ "arbitrary", "crc32fast", From 47c040baec32378b8fc49573bf088ad3f6e276df Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:58:48 +0300 Subject: [PATCH 1383/1963] fix(cheatcodes): rework gas metering pause/resume (#8736) * fix(cheatcodes): rework gas metering pause/resume * Changes after review: simplify paused gas recording * Move check out of meter_gas * Fix clippy * Add unit test for 4523 --- crates/anvil/src/eth/backend/mem/mod.rs | 4 +- crates/anvil/src/eth/otterscan/api.rs | 5 +- crates/cheatcodes/src/evm.rs | 7 +- crates/cheatcodes/src/inspector.rs | 102 +++++------------- crates/common/src/contracts.rs | 2 + crates/common/src/evm.rs | 1 + .../common/src/provider/runtime_transport.rs | 2 + crates/doc/src/parser/mod.rs | 7 +- .../src/preprocessor/contract_inheritance.rs | 1 + crates/evm/core/src/backend/mod.rs | 1 + .../evm/evm/src/executors/invariant/shrink.rs | 1 + crates/evm/fuzz/src/lib.rs | 1 + crates/evm/fuzz/src/strategies/param.rs | 5 +- crates/fmt/src/visit.rs | 2 + crates/forge/tests/cli/test_cmd.rs | 80 ++++++++++++++ 15 files changed, 132 insertions(+), 89 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index a089a9d2b8b71..12ae96dabd73d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2676,8 +2676,8 @@ pub fn transaction_build( WithOtherFields::new(transaction) } -/// Prove a storage key's existence or nonexistence in the account's storage -/// trie. +/// Prove a storage key's existence or nonexistence in the account's storage trie. +/// /// `storage_key` is the hash of the desired storage key, meaning /// this will only work correctly under a secure trie. /// `storage_key` == keccak(key) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 9b6b54a80fa45..0195cee69ba80 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -39,8 +39,9 @@ pub fn mentions_address(trace: LocalizedTransactionTrace, address: Address) -> O } } -/// Converts the list of traces for a transaction into the expected Otterscan format, as -/// specified in the [`ots_traceTransaction`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_tracetransaction) spec +/// Converts the list of traces for a transaction into the expected Otterscan format. +/// +/// Follows format specified in the [`ots_traceTransaction`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_tracetransaction) spec. pub fn batch_build_ots_traces(traces: Vec) -> Vec { traces .into_iter() diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 5cb05ec2bfa7d..1e2359425838f 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -209,9 +209,7 @@ impl Cheatcode for getRecordedLogsCall { impl Cheatcode for pauseGasMeteringCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - if state.gas_metering.is_none() { - state.gas_metering = Some(None); - } + state.pause_gas_metering = true; Ok(Default::default()) } } @@ -219,7 +217,8 @@ impl Cheatcode for pauseGasMeteringCall { impl Cheatcode for resumeGasMeteringCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - state.gas_metering = None; + state.pause_gas_metering = false; + state.paused_frame_gas = vec![]; Ok(Default::default()) } } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 65dabcf2d521b..e7d3540596025 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -293,18 +293,11 @@ pub struct Cheatcodes { /// All recorded ETH `deal`s. pub eth_deals: Vec, - /// Holds the stored gas info for when we pause gas metering. It is an `Option>` - /// because the `call` callback in an `Inspector` doesn't get access to - /// the `revm::Interpreter` which holds the `revm::Gas` struct that - /// we need to copy. So we convert it to a `Some(None)` in `apply_cheatcode`, and once we have - /// the interpreter, we copy the gas struct. Then each time there is an execution of an - /// operation, we reset the gas. - pub gas_metering: Option>, - - /// Holds stored gas info for when we pause gas metering, and we're entering/inside - /// CREATE / CREATE2 frames. This is needed to make gas meter pausing work correctly when - /// paused and creating new contracts. - pub gas_metering_create: Option>, + /// If true then gas metering is paused. + pub pause_gas_metering: bool, + + /// Stores frames paused gas. + pub paused_frame_gas: Vec, /// Mapping slots. pub mapping_slots: Option>, @@ -353,8 +346,8 @@ impl Cheatcodes { context: Default::default(), serialized_jsons: Default::default(), eth_deals: Default::default(), - gas_metering: Default::default(), - gas_metering_create: Default::default(), + pause_gas_metering: false, + paused_frame_gas: Default::default(), mapping_slots: Default::default(), pc: Default::default(), breakpoints: Default::default(), @@ -940,7 +933,7 @@ impl Cheatcodes { impl Inspector for Cheatcodes { #[inline] - fn initialize_interp(&mut self, _interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. if let Some(block) = self.block.take() { @@ -949,6 +942,11 @@ impl Inspector for Cheatcodes { if let Some(gas_price) = self.gas_price.take() { ecx.env.tx.gas_price = gas_price; } + + // Record gas for current frame if gas metering is paused. + if self.pause_gas_metering { + self.paused_frame_gas.push(interpreter.gas); + } } #[inline] @@ -956,7 +954,7 @@ impl Inspector for Cheatcodes { self.pc = interpreter.program_counter(); // `pauseGasMetering`: reset interpreter gas. - if self.gas_metering.is_some() { + if self.pause_gas_metering { self.meter_gas(interpreter); } @@ -1343,68 +1341,20 @@ impl InspectorExt for Cheatcodes { impl Cheatcodes { #[cold] fn meter_gas(&mut self, interpreter: &mut Interpreter) { - match &self.gas_metering { - None => {} - // Need to store gas metering. - Some(None) => self.gas_metering = Some(Some(interpreter.gas)), - Some(Some(gas)) => { - match interpreter.current_opcode() { - opcode::CREATE | opcode::CREATE2 => { - // Set we're about to enter CREATE frame to meter its gas on first opcode - // inside it. - self.gas_metering_create = Some(None) - } - opcode::STOP => { - // Reset gas to value recorded when paused. - interpreter.gas = *gas; - self.gas_metering = None; - self.gas_metering_create = None; - } - opcode::RETURN | opcode::SELFDESTRUCT | opcode::REVERT => { - match &self.gas_metering_create { - None | Some(None) => { - // If we are ending current execution frame, we want to reset - // interpreter gas to the value of gas spent during frame, so only - // the consumed gas is erased. - // ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/evm_impl.rs#L190 - // - // It would be nice if we had access to the interpreter in - // `call_end`, as we could just do this there instead. - interpreter.gas = Gas::new(interpreter.gas.spent()); - - // Make sure CREATE gas metering is resetted. - self.gas_metering_create = None - } - Some(Some(gas)) => { - // If this was CREATE frame, set correct gas limit. This is needed - // because CREATE opcodes deduct additional gas for code storage, - // and deducted amount is compared to gas limit. If we set this to - // 0, the CREATE would fail with out of gas. - // - // If we however set gas limit to the limit of outer frame, it would - // cause a panic after erasing gas cost post-create. Reason for this - // is pre-create REVM records `gas_limit - (gas_limit / 64)` as gas - // used, and erases costs by `remaining` gas post-create. - // gas used ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L254-L258 - // post-create erase ref: https://github.com/bluealloy/revm/blob/2cb991091d32330cfe085320891737186947ce5a/crates/revm/src/instructions/host.rs#L279 - interpreter.gas = Gas::new(gas.limit()); - - // Reset CREATE gas metering because we're about to exit its frame. - self.gas_metering_create = None - } - } - } - _ => { - // If just starting with CREATE opcodes, record its inner frame gas. - if self.gas_metering_create == Some(None) { - self.gas_metering_create = Some(Some(interpreter.gas)) - } + if let Some(paused_gas) = self.paused_frame_gas.last() { + // Keep gas constant if paused. + interpreter.gas = *paused_gas; + } else { + // Record frame paused gas. + self.paused_frame_gas.push(interpreter.gas); + } - // Don't monitor gas changes, keep it constant. - interpreter.gas = *gas; - } - } + // Remove recorded gas if we exit frame. + match interpreter.current_opcode() { + opcode::STOP | opcode::RETURN | opcode::REVERT | opcode::SELFDESTRUCT => { + self.paused_frame_gas.pop(); } + _ => {} } } diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 38f73a7133f5c..bccac2f7867c4 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -341,6 +341,8 @@ unsafe fn count_different_bytes(a: &[u8], b: &[u8]) -> usize { sum } +/// Returns contract name for a given contract identifier. +/// /// Artifact/Contract identifier can take the following form: /// `:`, the `artifact file name` is the name of the json file of /// the contract's artifact and the contract name is the name of the solidity contract, like diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index d7f026552510e..d281d56529b9d 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -18,6 +18,7 @@ use serde::Serialize; pub type Breakpoints = FxHashMap; /// `EvmArgs` and `EnvArgs` take the highest precedence in the Config/Figment hierarchy. +/// /// All vars are opt-in, their default values are expected to be set by the /// [`foundry_config::Config`], and are always present ([`foundry_config::Config::default`]) /// diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 8ca90ca80a36c..8362b46d66055 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -62,6 +62,8 @@ pub enum RuntimeTransportError { InvalidJwt(String), } +/// Runtime transport that only connects on first request. +/// /// A runtime transport is a custom [alloy_transport::Transport] that only connects when the *first* /// request is made. When the first request is made, it will connect to the runtime using either an /// HTTP WebSocket, or IPC transport depending on the URL used. diff --git a/crates/doc/src/parser/mod.rs b/crates/doc/src/parser/mod.rs index aa493c5c6ddd0..9757fec1adc26 100644 --- a/crates/doc/src/parser/mod.rs +++ b/crates/doc/src/parser/mod.rs @@ -23,9 +23,10 @@ pub use item::{ParseItem, ParseSource}; mod comment; pub use comment::{Comment, CommentTag, Comments, CommentsRef}; -/// The documentation parser. This type implements a [Visitor] trait. While walking the parse tree, -/// [Parser] will collect relevant source items and corresponding doc comments. The resulting -/// [ParseItem]s can be accessed by calling [Parser::items]. +/// The documentation parser. This type implements a [Visitor] trait. +/// +/// While walking the parse tree, [Parser] will collect relevant source items and corresponding +/// doc comments. The resulting [ParseItem]s can be accessed by calling [Parser::items]. #[derive(Debug, Default)] pub struct Parser { /// Initial comments from solang parser. diff --git a/crates/doc/src/preprocessor/contract_inheritance.rs b/crates/doc/src/preprocessor/contract_inheritance.rs index 894f373e775ff..7d74589bddb4f 100644 --- a/crates/doc/src/preprocessor/contract_inheritance.rs +++ b/crates/doc/src/preprocessor/contract_inheritance.rs @@ -7,6 +7,7 @@ use std::{collections::HashMap, path::PathBuf}; pub const CONTRACT_INHERITANCE_ID: PreprocessorId = PreprocessorId("contract_inheritance"); /// The contract inheritance preprocessor. +/// /// It matches the documents with inner [`ParseSource::Contract`](crate::ParseSource) elements, /// iterates over their [Base](solang_parser::pt::Base)s and attempts /// to link them with the paths of the other contract documents. diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index f33b772af2c8b..be3b0135e0f07 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -50,6 +50,7 @@ pub use snapshot::{BackendSnapshot, RevertSnapshotAction, StateSnapshot}; type ForkDB = CacheDB; /// Represents a numeric `ForkId` valid only for the existence of the `Backend`. +/// /// The difference between `ForkId` and `LocalForkId` is that `ForkId` tracks pairs of `endpoint + /// block` which can be reused by multiple tests, whereas the `LocalForkId` is unique within a test pub type LocalForkId = U256; diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index 5559ec821724d..318163534f9b8 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -137,6 +137,7 @@ pub(crate) fn shrink_sequence( } /// Checks if the given call sequence breaks the invariant. +/// /// Used in shrinking phase for checking candidate sequences and in replay failures phase to test /// persisted failures. /// Returns the result of invariant check (and afterInvariant call if needed) and if sequence was diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 8f24cba3048ce..bb5bdde37bd52 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -299,6 +299,7 @@ impl FuzzedCases { } /// Fixtures to be used for fuzz tests. +/// /// The key represents name of the fuzzed parameter, value holds possible fuzzed values. /// For example, for a fixture function declared as /// `function fixture_sender() external returns (address[] memory senders)` diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 65229d6866a37..10b166956d0f7 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -14,9 +14,10 @@ pub fn fuzz_param(param: &DynSolType) -> BoxedStrategy { } /// Given a parameter type and configured fixtures for param name, returns a strategy for generating -/// values for that type. Fixtures can be currently generated for uint, int, address, bytes and -/// string types and are defined for parameter name. +/// values for that type. /// +/// Fixtures can be currently generated for uint, int, address, bytes and +/// string types and are defined for parameter name. /// For example, fixtures for parameter `owner` of type `address` can be defined in a function with /// a `function fixture_owner() public returns (address[] memory)` signature. /// diff --git a/crates/fmt/src/visit.rs b/crates/fmt/src/visit.rs index ef9273a30ce2d..b977ba5b33abb 100644 --- a/crates/fmt/src/visit.rs +++ b/crates/fmt/src/visit.rs @@ -383,6 +383,8 @@ pub trait Visitor { } } +/// Visitable trait for [`solang_parser::pt`] types. +/// /// All [`solang_parser::pt`] types, such as [Statement], should implement the [Visitable] trait /// that accepts a trait [Visitor] implementation, which has various callback handles for Solidity /// Parse Tree nodes. diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 3b0cbfb7f24e7..83869fa5b11d5 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1286,3 +1286,83 @@ contract ATest is Test { ... "#]]); }); + +// see https://github.com/foundry-rs/foundry/issues/5564 +forgetest_init!(repro_5564, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "ATest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; +contract ATest is Test { + error MyError(); + function testSelfMeteringRevert() public { + vm.pauseGasMetering(); + vm.expectRevert(MyError.selector); + this.selfReverts(); + } + function selfReverts() external { + vm.resumeGasMetering(); + revert MyError(); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" +... +[PASS] testSelfMeteringRevert() (gas: 3299) +... +"#]]); +}); + +// see https://github.com/foundry-rs/foundry/issues/4523 +forgetest_init!(repro_4523, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "ATest.t.sol", + r#" +import "forge-std/Test.sol"; +contract ATest is Test { + mapping(uint => bytes32) map; + + function test_GasMeter () public { + vm.pauseGasMetering(); + for (uint i = 0; i < 10000; i++) { + map[i] = keccak256(abi.encode(i)); + } + vm.resumeGasMetering(); + + for (uint i = 0; i < 10000; i++) { + map[i] = keccak256(abi.encode(i)); + } + } + + function test_GasLeft () public { + for (uint i = 0; i < 10000; i++) { + map[i] = keccak256(abi.encode(i)); + } + + uint start = gasleft(); + for (uint i = 0; i < 10000; i++) { + map[i] = keccak256(abi.encode(i)); + } + console2.log("Gas cost:", start - gasleft()); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "-vvvv"]).with_no_redact().assert_success().stdout_eq(str![[r#" +... +Logs: + Gas cost: 5754479 +... +[PASS] test_GasMeter() (gas: 5757137) +... +"#]]); +}); From 44cceb4a3d0a64faf818f16ce7c6ab7dc3a27400 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:17:31 +0200 Subject: [PATCH 1384/1963] chore: add security policy document (#8741) add security policy document --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000000..5260d529f5a4d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +Contact georgios at paradigm.xyz. From bdf48aa6f04f69f40c8eb3623cf32f7413a82ea4 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 26 Aug 2024 19:57:47 +0800 Subject: [PATCH 1385/1963] feat: `vm.pauseTracing` + `vm.resumeTracing` (#8696) * feat: vm.pauseTracing + vm.resumeTracing * clippy * fixes * fix --decode-internal edge case * fmt * clippy + change tracing_inspector return type * update fixture * fix fixture --- Cargo.lock | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 40 ++++++ crates/cheatcodes/spec/src/vm.rs | 9 ++ crates/cheatcodes/src/fs.rs | 18 +-- crates/cheatcodes/src/inspector.rs | 34 ++++- crates/cheatcodes/src/utils.rs | 63 ++++++++- crates/debugger/src/tui/builder.rs | 2 +- crates/evm/evm/src/executors/fuzz/mod.rs | 6 +- crates/evm/evm/src/executors/fuzz/types.rs | 4 +- crates/evm/evm/src/executors/invariant/mod.rs | 8 +- .../evm/evm/src/executors/invariant/replay.rs | 3 +- crates/evm/evm/src/executors/mod.rs | 12 +- crates/evm/evm/src/inspectors/stack.rs | 30 +++- crates/evm/fuzz/src/lib.rs | 10 +- crates/evm/traces/src/lib.rs | 133 +++++++++++++++++- crates/forge/bin/cmd/test/mod.rs | 4 +- crates/forge/src/runner.rs | 2 +- crates/forge/tests/cli/test_cmd.rs | 87 ++++++++++++ crates/forge/tests/it/repros.rs | 2 +- crates/test-utils/src/util.rs | 6 + testdata/cheats/Vm.sol | 2 + 22 files changed, 430 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index daa1a091a6022..f9a01ff964b26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3557,6 +3557,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-evm-core", + "foundry-evm-traces", "foundry-wallets", "itertools 0.13.0", "jsonpath_lib", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 8af927f349d3e..412c5b898768e 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -27,6 +27,7 @@ foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true foundry-evm-core.workspace = true +foundry-evm-traces.workspace = true foundry-wallets.workspace = true alloy-dyn-abi.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 80c8516f6dde2..4f41af83ea1c0 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6431,6 +6431,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "pauseTracing", + "description": "Pauses collection of call traces. Useful in cases when you want to skip tracing of\ncomplex calls which are not useful for debugging.", + "declaration": "function pauseTracing() external view;", + "visibility": "external", + "mutability": "view", + "signature": "pauseTracing()", + "selector": "0xc94d1f90", + "selectorBytes": [ + 201, + 77, + 31, + 144 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "prank_0", @@ -7031,6 +7051,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "resumeTracing", + "description": "Unpauses collection of call traces.", + "declaration": "function resumeTracing() external view;", + "visibility": "external", + "mutability": "view", + "signature": "resumeTracing()", + "selector": "0x72a09ccb", + "selectorBytes": [ + 114, + 160, + 156, + 203 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "revertTo", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 8e0b51ec35c2d..4149b56b46168 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2282,6 +2282,15 @@ interface Vm { /// Returns a random `address`. #[cheatcode(group = Utilities)] function randomAddress() external returns (address); + + /// Pauses collection of call traces. Useful in cases when you want to skip tracing of + /// complex calls which are not useful for debugging. + #[cheatcode(group = Utilities)] + function pauseTracing() external view; + + /// Unpauses collection of call traces. + #[cheatcode(group = Utilities)] + function resumeTracing() external view; } } diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 7f07674d07437..da69094017422 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -272,7 +272,7 @@ impl Cheatcode for deployCode_0Call { ) -> Result { let Self { artifactPath: path } = self; let bytecode = get_artifact_code(ccx.state, path, false)?; - let output = executor + let address = executor .exec_create( CreateInputs { caller: ccx.caller, @@ -282,10 +282,11 @@ impl Cheatcode for deployCode_0Call { gas_limit: ccx.gas_limit, }, ccx, - ) - .unwrap(); + )? + .address + .ok_or_else(|| fmt_err!("contract creation failed"))?; - Ok(output.address.unwrap().abi_encode()) + Ok(address.abi_encode()) } } @@ -298,7 +299,7 @@ impl Cheatcode for deployCode_1Call { let Self { artifactPath: path, constructorArgs } = self; let mut bytecode = get_artifact_code(ccx.state, path, false)?.to_vec(); bytecode.extend_from_slice(constructorArgs); - let output = executor + let address = executor .exec_create( CreateInputs { caller: ccx.caller, @@ -308,10 +309,11 @@ impl Cheatcode for deployCode_1Call { gas_limit: ccx.gas_limit, }, ccx, - ) - .unwrap(); + )? + .address + .ok_or_else(|| fmt_err!("contract creation failed"))?; - Ok(output.address.unwrap().abi_encode()) + Ok(address.abi_encode()) } } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index e7d3540596025..41b1aa562d715 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -13,6 +13,7 @@ use crate::{ self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, ExpectedRevert, ExpectedRevertKind, }, + utils::IgnoredTraces, CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, Vm, Vm::AccountAccess, }; @@ -28,14 +29,15 @@ use foundry_evm_core::{ utils::new_evm_with_existing_context, InspectorExt, }; +use foundry_evm_traces::TracingInspector; use itertools::Itertools; use rand::{rngs::StdRng, Rng, SeedableRng}; use revm::{ interpreter::{ opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, EOFCreateInputs, - Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, + EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, - primitives::{BlockEnv, CreateScheme, EVMError}, + primitives::{BlockEnv, CreateScheme, EVMError, SpecId, EOF_MAGIC_BYTES}, EvmContext, InnerEvmContext, Inspector, }; use rustc_hash::FxHashMap; @@ -115,8 +117,19 @@ pub trait CheatcodesExecutor { self.with_evm(ccx, |evm| { evm.context.evm.inner.journaled_state.depth += 1; - let first_frame_or_result = - evm.handler.execution().create(&mut evm.context, Box::new(inputs))?; + // Handle EOF bytecode + let first_frame_or_result = if evm.handler.cfg.spec_id.is_enabled_in(SpecId::PRAGUE_EOF) + && inputs.scheme == CreateScheme::Create && inputs.init_code.starts_with(&EOF_MAGIC_BYTES) + { + evm.handler.execution().eofcreate( + &mut evm.context, + Box::new(EOFCreateInputs::new(inputs.caller, inputs.value, inputs.gas_limit, EOFCreateKind::Tx { + initdata: inputs.init_code, + })), + )? + } else { + evm.handler.execution().create(&mut evm.context, Box::new(inputs))? + }; let mut result = match first_frame_or_result { revm::FrameOrResult::Frame(first_frame) => evm.run_the_loop(first_frame)?, @@ -126,8 +139,8 @@ pub trait CheatcodesExecutor { evm.handler.execution().last_frame_return(&mut evm.context, &mut result)?; let outcome = match result { - revm::FrameResult::Call(_) | revm::FrameResult::EOFCreate(_) => unreachable!(), - revm::FrameResult::Create(create) => create, + revm::FrameResult::Call(_) => unreachable!(), + revm::FrameResult::Create(create) | revm::FrameResult::EOFCreate(create) => create, }; evm.context.evm.inner.journaled_state.depth -= 1; @@ -139,6 +152,11 @@ pub trait CheatcodesExecutor { fn console_log(&mut self, ccx: &mut CheatsCtxt, message: String) { self.get_inspector::(ccx.state).console_log(message); } + + /// Returns a mutable reference to the tracing inspector if it is available. + fn tracing_inspector(&mut self) -> Option<&mut Option> { + None + } } /// Basic implementation of [CheatcodesExecutor] that simply returns the [Cheatcodes] instance as an @@ -310,6 +328,9 @@ pub struct Cheatcodes { /// Optional RNG algorithm. rng: Option, + + /// Ignored traces. + pub ignored_traces: IgnoredTraces, } // This is not derived because calling this in `fn new` with `..Default::default()` creates a second @@ -352,6 +373,7 @@ impl Cheatcodes { pc: Default::default(), breakpoints: Default::default(), rng: Default::default(), + ignored_traces: Default::default(), } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 5fa55ba8fdd0e..642cf83abb99b 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -4,8 +4,23 @@ use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_primitives::{Address, U256}; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; -use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; +use foundry_evm_core::{backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER}; use rand::Rng; +use std::collections::HashMap; + +/// Contains locations of traces ignored via cheatcodes. +/// +/// The way we identify location in traces is by (node_idx, item_idx) tuple where node_idx is an +/// index of a call trace node, and item_idx is a value between 0 and `node.ordering.len()` where i +/// represents point after ith item, and 0 represents the beginning of the node trace. +#[derive(Debug, Default, Clone)] +pub struct IgnoredTraces { + /// Mapping from (start_node_idx, start_item_idx) to (end_node_idx, end_item_idx) representing + /// ranges of trace nodes to ignore. + pub ignored: HashMap<(usize, usize), (usize, usize)>, + /// Keeps track of (start_node_idx, start_item_idx) of the last `vm.pauseTracing` call. + pub last_pause_call: Option<(usize, usize)>, +} impl Cheatcode for labelCall { fn apply(&self, state: &mut Cheatcodes) -> Result { @@ -88,3 +103,49 @@ impl Cheatcode for randomAddressCall { Ok(addr.abi_encode()) } } + +impl Cheatcode for pauseTracingCall { + fn apply_full( + &self, + ccx: &mut crate::CheatsCtxt, + executor: &mut E, + ) -> Result { + let Some(tracer) = executor.tracing_inspector().and_then(|t| t.as_ref()) else { + // No tracer -> nothing to pause + return Ok(Default::default()) + }; + + // If paused earlier, ignore the call + if ccx.state.ignored_traces.last_pause_call.is_some() { + return Ok(Default::default()) + } + + let cur_node = &tracer.traces().nodes().last().expect("no trace nodes"); + ccx.state.ignored_traces.last_pause_call = Some((cur_node.idx, cur_node.ordering.len())); + + Ok(Default::default()) + } +} + +impl Cheatcode for resumeTracingCall { + fn apply_full( + &self, + ccx: &mut crate::CheatsCtxt, + executor: &mut E, + ) -> Result { + let Some(tracer) = executor.tracing_inspector().and_then(|t| t.as_ref()) else { + // No tracer -> nothing to unpause + return Ok(Default::default()) + }; + + let Some(start) = ccx.state.ignored_traces.last_pause_call.take() else { + // Nothing to unpause + return Ok(Default::default()) + }; + + let node = &tracer.traces().nodes().last().expect("no trace nodes"); + ccx.state.ignored_traces.ignored.insert(start, (node.idx, node.ordering.len())); + + Ok(Default::default()) + } +} diff --git a/crates/debugger/src/tui/builder.rs b/crates/debugger/src/tui/builder.rs index 81632dcca6480..fd952def5bc4f 100644 --- a/crates/debugger/src/tui/builder.rs +++ b/crates/debugger/src/tui/builder.rs @@ -31,7 +31,7 @@ impl DebuggerBuilder { #[inline] pub fn traces(mut self, traces: Traces) -> Self { for (_, arena) in traces { - self = self.trace_arena(arena); + self = self.trace_arena(arena.arena); } self } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 76f01541d5e84..7fa5498bfcab6 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -11,7 +11,7 @@ use foundry_evm_fuzz::{ strategies::{fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, BaseCounterExample, CounterExample, FuzzCase, FuzzError, FuzzFixtures, FuzzTestResult, }; -use foundry_evm_traces::CallTraceArena; +use foundry_evm_traces::SparsedTraceArena; use indicatif::ProgressBar; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; use std::cell::RefCell; @@ -29,7 +29,7 @@ pub struct FuzzTestData { // Stores the result and calldata of the last failed call, if any. pub counterexample: (Bytes, RawCallResult), // Stores up to `max_traces_to_collect` traces. - pub traces: Vec, + pub traces: Vec, // Stores breakpoints for the last fuzz case. pub breakpoints: Option, // Stores coverage information for all fuzz cases. @@ -163,7 +163,7 @@ impl FuzzedExecutor { labeled_addresses: call.labels, traces: last_run_traces, breakpoints: last_run_breakpoints, - gas_report_traces: traces, + gas_report_traces: traces.into_iter().map(|a| a.arena).collect(), coverage: fuzz_result.coverage, }; diff --git a/crates/evm/evm/src/executors/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs index 7ec707eff66a9..ac7c143739bc6 100644 --- a/crates/evm/evm/src/executors/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -3,7 +3,7 @@ use alloy_primitives::{Bytes, Log}; use foundry_common::evm::Breakpoints; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::FuzzCase; -use foundry_evm_traces::CallTraceArena; +use foundry_evm_traces::SparsedTraceArena; use revm::interpreter::InstructionResult; /// Returned by a single fuzz in the case of a successful run @@ -12,7 +12,7 @@ pub struct CaseOutcome { /// Data of a single fuzz test case pub case: FuzzCase, /// The traces of the call - pub traces: Option, + pub traces: Option, /// The coverage info collected during the call pub coverage: Option, /// Breakpoints char pc map diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 91143f4b232e3..b5854d1d7a070 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -21,7 +21,7 @@ use foundry_evm_fuzz::{ strategies::{invariant_strat, override_call_strat, EvmFuzzState}, FuzzCase, FuzzFixtures, FuzzedCases, }; -use foundry_evm_traces::CallTraceArena; +use foundry_evm_traces::{CallTraceArena, SparsedTraceArena}; use indicatif::ProgressBar; use parking_lot::RwLock; use proptest::{ @@ -199,7 +199,9 @@ impl InvariantTest { let mut invariant_data = self.execution_data.borrow_mut(); if invariant_data.gas_report_traces.len() < gas_samples { - invariant_data.gas_report_traces.push(run.run_traces); + invariant_data + .gas_report_traces + .push(run.run_traces.into_iter().map(|arena| arena.arena).collect()); } invariant_data.fuzz_cases.push(FuzzedCases::new(run.fuzz_runs)); @@ -219,7 +221,7 @@ pub struct InvariantTestRun { // Contracts created during current invariant run. pub created_contracts: Vec
, // Traces of each call of the invariant run call sequence. - pub run_traces: Vec, + pub run_traces: Vec, // Current depth of invariant run. pub depth: u32, // Current assume rejects of the invariant run. diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 9de5bf5317141..c10d31560b562 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -59,7 +59,8 @@ pub fn replay_run( } // Identify newly generated contracts, if they exist. - ided_contracts.extend(load_contracts(call_result.traces.as_slice(), known_contracts)); + ided_contracts + .extend(load_contracts(call_result.traces.iter().map(|a| &a.arena), known_contracts)); // Create counter example to be used in failed case. counterexample_sequence.push(BaseCounterExample::from_invariant_call( diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 2f08b2f42efdd..44bc33e372c06 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -23,7 +23,7 @@ use foundry_evm_core::{ utils::StateChangeset, }; use foundry_evm_coverage::HitMaps; -use foundry_evm_traces::{CallTraceArena, TraceMode}; +use foundry_evm_traces::{SparsedTraceArena, TraceMode}; use revm::{ db::{DatabaseCommit, DatabaseRef}, interpreter::{return_ok, InstructionResult}, @@ -424,9 +424,13 @@ impl Executor { if let Some(cheats) = self.inspector_mut().cheatcodes.as_mut() { // Clear broadcastable transactions cheats.broadcastable_transactions.clear(); + cheats.ignored_traces.ignored.clear(); - // corrected_nonce value is needed outside of this context (setUp), so we don't - // reset it. + // if tracing was paused but never unpaused, we should begin next frame with tracing + // still paused + if let Some(last_pause_call) = cheats.ignored_traces.last_pause_call.as_mut() { + *last_pause_call = (0, 0); + } } // Persist the changed environment. @@ -721,7 +725,7 @@ pub struct RawCallResult { /// The labels assigned to addresses during the call pub labels: HashMap, /// The traces of the call - pub traces: Option, + pub traces: Option, /// The coverage info collected during the call pub coverage: Option, /// Scripted transactions generated from this call diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 7199983658744..f72c62ff327a9 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -9,7 +9,7 @@ use foundry_evm_core::{ InspectorExt, }; use foundry_evm_coverage::HitMaps; -use foundry_evm_traces::{CallTraceArena, TraceMode}; +use foundry_evm_traces::{SparsedTraceArena, TraceMode}; use revm::{ inspectors::CustomPrintTracer, interpreter::{ @@ -244,7 +244,7 @@ macro_rules! call_inspectors_adjust_depth { pub struct InspectorData { pub logs: Vec, pub labels: HashMap, - pub traces: Option, + pub traces: Option, pub coverage: Option, pub cheatcodes: Option, pub chisel_state: Option<(Vec, Vec, InstructionResult)>, @@ -318,6 +318,10 @@ impl CheatcodesExecutor for InspectorStackInner { ) -> impl InspectorExt + 'a { InspectorStackRefMut { cheatcodes: Some(cheats), inner: self } } + + fn tracing_inspector(&mut self) -> Option<&mut Option> { + Some(&mut self.tracer) + } } impl InspectorStack { @@ -437,17 +441,35 @@ impl InspectorStack { #[inline] pub fn collect(self) -> InspectorData { let Self { - cheatcodes, + mut cheatcodes, inner: InspectorStackInner { chisel_state, coverage, log_collector, tracer, .. }, } = self; + let traces = tracer.map(|tracer| tracer.into_traces()).map(|arena| { + let ignored = cheatcodes + .as_mut() + .map(|cheatcodes| { + let mut ignored = std::mem::take(&mut cheatcodes.ignored_traces.ignored); + + // If the last pause call was not resumed, ignore the rest of the trace + if let Some(last_pause_call) = cheatcodes.ignored_traces.last_pause_call { + ignored.insert(last_pause_call, (arena.nodes().len(), 0)); + } + + ignored + }) + .unwrap_or_default(); + + SparsedTraceArena { arena, ignored } + }); + InspectorData { logs: log_collector.map(|logs| logs.logs).unwrap_or_default(), labels: cheatcodes .as_ref() .map(|cheatcodes| cheatcodes.labels.clone()) .unwrap_or_default(), - traces: tracer.map(|tracer| tracer.into_traces()), + traces, coverage: coverage.map(|coverage| coverage.maps), cheatcodes, chisel_state: chisel_state.and_then(|state| state.state), diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index bb5bdde37bd52..99232443b9cda 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -12,7 +12,7 @@ use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; use alloy_primitives::{Address, Bytes, Log}; use foundry_common::{calc, contracts::ContractsByAddress, evm::Breakpoints}; use foundry_evm_coverage::HitMaps; -use foundry_evm_traces::CallTraceArena; +use foundry_evm_traces::{CallTraceArena, SparsedTraceArena}; use itertools::Itertools; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, fmt, sync::Arc}; @@ -52,7 +52,7 @@ pub struct BaseCounterExample { pub args: Option, /// Traces #[serde(skip)] - pub traces: Option, + pub traces: Option, } impl BaseCounterExample { @@ -62,7 +62,7 @@ impl BaseCounterExample { addr: Address, bytes: &Bytes, contracts: &ContractsByAddress, - traces: Option, + traces: Option, ) -> Self { if let Some((name, abi)) = &contracts.get(&addr) { if let Some(func) = abi.functions().find(|f| f.selector() == bytes[..4]) { @@ -98,7 +98,7 @@ impl BaseCounterExample { pub fn from_fuzz_call( bytes: Bytes, args: Vec, - traces: Option, + traces: Option, ) -> Self { Self { sender: None, @@ -170,7 +170,7 @@ pub struct FuzzTestResult { /// /// **Note** We only store a single trace of a successful fuzz call, otherwise we would get /// `num(fuzz_cases)` traces, one for each run, which is neither helpful nor performant. - pub traces: Option, + pub traces: Option, /// Additional traces used for gas report construction. /// Those traces should not be displayed. diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 4677a02bc9fd8..4a80b164ad33b 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -10,8 +10,16 @@ extern crate tracing; use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use revm::interpreter::OpCode; -use revm_inspectors::tracing::OpcodeFilter; +use revm_inspectors::tracing::{ + types::{DecodedTraceStep, TraceMemberOrder}, + OpcodeFilter, +}; use serde::{Deserialize, Serialize}; +use std::{ + borrow::Cow, + collections::{BTreeSet, HashMap}, + ops::{Deref, DerefMut}, +}; pub use revm_inspectors::tracing::{ types::{ @@ -34,7 +42,124 @@ pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; pub mod debug; pub use debug::DebugTraceIdentifier; -pub type Traces = Vec<(TraceKind, CallTraceArena)>; +pub type Traces = Vec<(TraceKind, SparsedTraceArena)>; + +/// Trace arena keeping track of ignored trace items. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SparsedTraceArena { + /// Full trace arena. + #[serde(flatten)] + pub arena: CallTraceArena, + /// Ranges of trace steps to ignore in format (start_node, start_step) -> (end_node, end_step). + /// See `foundry_cheatcodes::utils::IgnoredTraces` for more information. + #[serde(default, skip_serializing_if = "HashMap::is_empty")] + pub ignored: HashMap<(usize, usize), (usize, usize)>, +} + +impl SparsedTraceArena { + /// Goes over entire trace arena and removes ignored trace items. + fn resolve_arena(&self) -> Cow<'_, CallTraceArena> { + if self.ignored.is_empty() { + Cow::Borrowed(&self.arena) + } else { + let mut arena = self.arena.clone(); + + fn clear_node( + nodes: &mut [CallTraceNode], + node_idx: usize, + ignored: &HashMap<(usize, usize), (usize, usize)>, + cur_ignore_end: &mut Option<(usize, usize)>, + ) { + // Prepend an additional None item to the ordering to handle the beginning of the + // trace. + let items = std::iter::once(None) + .chain(nodes[node_idx].ordering.clone().into_iter().map(Some)) + .enumerate(); + + let mut iternal_calls = Vec::new(); + let mut items_to_remove = BTreeSet::new(); + for (item_idx, item) in items { + if let Some(end_node) = ignored.get(&(node_idx, item_idx)) { + *cur_ignore_end = Some(*end_node); + } + + let mut remove = cur_ignore_end.is_some() & item.is_some(); + + match item { + // we only remove calls if they did not start/pause tracing + Some(TraceMemberOrder::Call(child_idx)) => { + clear_node( + nodes, + nodes[node_idx].children[child_idx], + ignored, + cur_ignore_end, + ); + remove &= cur_ignore_end.is_some(); + } + // we only remove decoded internal calls if they did not start/pause tracing + Some(TraceMemberOrder::Step(step_idx)) => { + // If this is an internal call beginning, track it in `iternal_calls` + if let Some(DecodedTraceStep::InternalCall(_, end_step_idx)) = + &nodes[node_idx].trace.steps[step_idx].decoded + { + iternal_calls.push((item_idx, remove, *end_step_idx)); + // we decide if we should remove it later + remove = false; + } + // Handle ends of internal calls + iternal_calls.retain(|(start_item_idx, remove_start, end_step_idx)| { + if *end_step_idx != step_idx { + return true; + } + // only remove start if end should be removed as well + if *remove_start && remove { + items_to_remove.insert(*start_item_idx); + } else { + remove = false; + } + + false + }); + } + _ => {} + } + + if remove { + items_to_remove.insert(item_idx); + } + + if let Some((end_node, end_step_idx)) = cur_ignore_end { + if node_idx == *end_node && item_idx == *end_step_idx { + *cur_ignore_end = None; + } + } + } + + for (offset, item_idx) in items_to_remove.into_iter().enumerate() { + nodes[node_idx].ordering.remove(item_idx - offset - 1); + } + } + + clear_node(arena.nodes_mut(), 0, &self.ignored, &mut None); + + Cow::Owned(arena) + } + } +} + +impl Deref for SparsedTraceArena { + type Target = CallTraceArena; + + fn deref(&self) -> &Self::Target { + &self.arena + } +} + +impl DerefMut for SparsedTraceArena { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.arena + } +} /// Decode a collection of call traces. /// @@ -50,9 +175,9 @@ pub async fn decode_trace_arena( } /// Render a collection of call traces to a string. -pub fn render_trace_arena(arena: &CallTraceArena) -> String { +pub fn render_trace_arena(arena: &SparsedTraceArena) -> String { let mut w = TraceWriter::new(Vec::::new()); - w.write_arena(arena).expect("Failed to write traces"); + w.write_arena(&arena.resolve_arena()).expect("Failed to write traces"); String::from_utf8(w.into_writer()).expect("trace writer wrote invalid UTF-8") } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index ab868f5bc9d06..ec582f2981034 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -560,9 +560,7 @@ impl TestArgs { } if let Some(gas_report) = &mut gas_report { - gas_report - .analyze(result.traces.iter().map(|(_, arena)| arena), &decoder) - .await; + gas_report.analyze(result.traces.iter().map(|(_, a)| &a.arena), &decoder).await; for trace in result.gas_report_traces.iter() { decoder.clear_addresses(); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 6ed06e525e399..3cfbd76c9206f 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -350,7 +350,7 @@ impl<'a> ContractRunner<'a> { ); let identified_contracts = has_invariants - .then(|| load_contracts(setup.traces.iter().map(|(_, t)| t), &known_contracts)); + .then(|| load_contracts(setup.traces.iter().map(|(_, t)| &t.arena), &known_contracts)); let test_results = functions .par_iter() .map(|&func| { diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 83869fa5b11d5..eae1514cf408b 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1366,3 +1366,90 @@ Logs: ... "#]]); }); + +// tests `pauseTracing` and `resumeTracing` functions +#[cfg(not(feature = "isolate-by-default"))] +forgetest_init!(pause_tracing, |prj, cmd| { + prj.wipe_contracts(); + prj.insert_ds_test(); + prj.insert_vm(); + prj.clear(); + + prj.add_source( + "Pause.t.sol", + r#"pragma solidity 0.8.24; +import {Vm} from "./Vm.sol"; +import {DSTest} from "./test.sol"; +contract TraceGenerator is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + event DummyEvent(uint256 i); + function call(uint256 i) public { + emit DummyEvent(i); + } + function generate() public { + for (uint256 i = 0; i < 10; i++) { + if (i == 3) { + vm.pauseTracing(); + } + this.call(i); + if (i == 7) { + vm.resumeTracing(); + } + } + } +} +contract PauseTracingTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + event DummyEvent(uint256 i); + function setUp() public { + emit DummyEvent(1); + vm.pauseTracing(); + emit DummyEvent(2); + } + function test() public { + emit DummyEvent(3); + TraceGenerator t = new TraceGenerator(); + vm.resumeTracing(); + t.generate(); + } +} + "#, + ) + .unwrap(); + cmd.args(["test", "-vvvvv"]).assert_success().stdout_eq(str![[r#" +... +Traces: + [7285] PauseTracingTest::setUp() + ├─ emit DummyEvent(i: 1) + ├─ [0] VM::pauseTracing() [staticcall] + │ └─ ← [Return] + └─ ← [Stop] + + [294725] PauseTracingTest::test() + ├─ [0] VM::resumeTracing() [staticcall] + │ └─ ← [Return] + ├─ [18373] TraceGenerator::generate() + │ ├─ [1280] TraceGenerator::call(0) + │ │ ├─ emit DummyEvent(i: 0) + │ │ └─ ← [Stop] + │ ├─ [1280] TraceGenerator::call(1) + │ │ ├─ emit DummyEvent(i: 1) + │ │ └─ ← [Stop] + │ ├─ [1280] TraceGenerator::call(2) + │ │ ├─ emit DummyEvent(i: 2) + │ │ └─ ← [Stop] + │ ├─ [0] VM::pauseTracing() [staticcall] + │ │ └─ ← [Return] + │ ├─ [0] VM::resumeTracing() [staticcall] + │ │ └─ ← [Return] + │ ├─ [1280] TraceGenerator::call(8) + │ │ ├─ emit DummyEvent(i: 8) + │ │ └─ ← [Stop] + │ ├─ [1280] TraceGenerator::call(9) + │ │ ├─ emit DummyEvent(i: 9) + │ │ └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] +... +"#]]); +}); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index a74933f6f9a1d..6c0708e207067 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -261,7 +261,7 @@ test_repro!(6501, false, None, |res| { ); let (kind, traces) = test.traces.last().unwrap().clone(); - let nodes = traces.into_nodes(); + let nodes = traces.arena.into_nodes(); assert_eq!(kind, TraceKind::Execution); let test_call = nodes.first().unwrap(); diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 593dbdbe1f3d9..ac5674d9a3333 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -596,6 +596,12 @@ impl TestProject { self.add_source("console.sol", s).unwrap() } + /// Adds `Vm.sol` as a source under "Vm.sol" + pub fn insert_vm(&self) -> PathBuf { + let s = include_str!("../../../testdata/cheats/Vm.sol"); + self.add_source("Vm.sol", s).unwrap() + } + /// Asserts all project paths exist. These are: /// - sources /// - artifacts diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 8004efb1dad70..8ce2ce5fece5c 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -317,6 +317,7 @@ interface Vm { function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData); function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue); function pauseGasMetering() external; + function pauseTracing() external view; function prank(address msgSender) external; function prank(address msgSender, address txOrigin) external; function prevrandao(bytes32 newPrevrandao) external; @@ -347,6 +348,7 @@ interface Vm { function replace(string calldata input, string calldata from, string calldata to) external pure returns (string memory output); function resetNonce(address account) external; function resumeGasMetering() external; + function resumeTracing() external view; function revertTo(uint256 snapshotId) external returns (bool success); function revertToAndDelete(uint256 snapshotId) external returns (bool success); function revokePersistent(address account) external; From 88a4920420fe2e7f82efb997f614e9ed7ca40da5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:58:49 +0200 Subject: [PATCH 1386/1963] chore(cheatcodes): make pauseGasMetering more robust (#8743) * chore: make pauseGasMetering more robust * test * test * simpler * fix(cheatcodes): reconcile gas when exiting frame (#8744) * Fix for 4370 + tests * assert on test kind gas --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/cheatcodes/src/evm.rs | 5 +- crates/cheatcodes/src/inspector.rs | 126 +++++++++++++++------- crates/evm/evm/src/inspectors/stack.rs | 2 +- crates/forge/tests/cli/test_cmd.rs | 84 ++++++++++----- crates/forge/tests/it/repros.rs | 15 ++- testdata/default/cheats/GasMetering.t.sol | 12 +-- 6 files changed, 162 insertions(+), 82 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 1e2359425838f..6d8bdfb37bafe 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -209,7 +209,7 @@ impl Cheatcode for getRecordedLogsCall { impl Cheatcode for pauseGasMeteringCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - state.pause_gas_metering = true; + state.gas_metering.paused = true; Ok(Default::default()) } } @@ -217,8 +217,7 @@ impl Cheatcode for pauseGasMeteringCall { impl Cheatcode for resumeGasMeteringCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - state.pause_gas_metering = false; - state.paused_frame_gas = vec![]; + state.gas_metering.resume(); Ok(Default::default()) } } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 41b1aa562d715..09ced929462b5 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -34,8 +34,9 @@ use itertools::Itertools; use rand::{rngs::StdRng, Rng, SeedableRng}; use revm::{ interpreter::{ - opcode, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, EOFCreateInputs, - EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, + opcode as op, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, + EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction, + InterpreterResult, }, primitives::{BlockEnv, CreateScheme, EVMError, SpecId, EOF_MAGIC_BYTES}, EvmContext, InnerEvmContext, Inspector, @@ -213,6 +214,28 @@ pub struct BroadcastableTransaction { pub transaction: TransactionMaybeSigned, } +/// Holds gas metering state. +#[derive(Clone, Debug, Default)] +pub struct GasMetering { + /// True if gas metering is paused. + pub paused: bool, + /// True if gas metering was resumed during the test. + pub resumed: bool, + /// Stores frames paused gas. + pub paused_frames: Vec, +} + +impl GasMetering { + /// Resume paused gas metering. + pub fn resume(&mut self) { + if self.paused { + self.paused = false; + self.resumed = true; + } + self.paused_frames.clear(); + } +} + /// List of transactions that can be broadcasted. pub type BroadcastableTransactions = VecDeque; @@ -311,11 +334,8 @@ pub struct Cheatcodes { /// All recorded ETH `deal`s. pub eth_deals: Vec, - /// If true then gas metering is paused. - pub pause_gas_metering: bool, - - /// Stores frames paused gas. - pub paused_frame_gas: Vec, + /// Gas metering state. + pub gas_metering: GasMetering, /// Mapping slots. pub mapping_slots: Option>, @@ -367,8 +387,7 @@ impl Cheatcodes { context: Default::default(), serialized_jsons: Default::default(), eth_deals: Default::default(), - pause_gas_metering: false, - paused_frame_gas: Default::default(), + gas_metering: Default::default(), mapping_slots: Default::default(), pc: Default::default(), breakpoints: Default::default(), @@ -965,9 +984,9 @@ impl Inspector for Cheatcodes { ecx.env.tx.gas_price = gas_price; } - // Record gas for current frame if gas metering is paused. - if self.pause_gas_metering { - self.paused_frame_gas.push(interpreter.gas); + // Record gas for current frame. + if self.gas_metering.paused { + self.gas_metering.paused_frames.push(interpreter.gas); } } @@ -976,7 +995,7 @@ impl Inspector for Cheatcodes { self.pc = interpreter.program_counter(); // `pauseGasMetering`: reset interpreter gas. - if self.pause_gas_metering { + if self.gas_metering.paused { self.meter_gas(interpreter); } @@ -1001,7 +1020,18 @@ impl Inspector for Cheatcodes { } } - fn log(&mut self, _interpreter: &mut Interpreter, _context: &mut EvmContext, log: &Log) { + #[inline] + fn step_end(&mut self, interpreter: &mut Interpreter, _ecx: &mut EvmContext) { + if self.gas_metering.paused { + self.meter_gas_end(interpreter); + } + + if self.gas_metering.resumed { + self.meter_gas_check(interpreter); + } + } + + fn log(&mut self, _interpreter: &mut Interpreter, _ecx: &mut EvmContext, log: &Log) { if !self.expected_emits.is_empty() { expect::handle_expect_emit(self, log); } @@ -1016,12 +1046,8 @@ impl Inspector for Cheatcodes { } } - fn call( - &mut self, - context: &mut EvmContext, - inputs: &mut CallInputs, - ) -> Option { - Self::call_with_executor(self, context, inputs, &mut TransparentCheatcodesExecutor) + fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { + Self::call_with_executor(self, ecx, inputs, &mut TransparentCheatcodesExecutor) } fn call_end( @@ -1363,20 +1389,33 @@ impl InspectorExt for Cheatcodes { impl Cheatcodes { #[cold] fn meter_gas(&mut self, interpreter: &mut Interpreter) { - if let Some(paused_gas) = self.paused_frame_gas.last() { + if let Some(paused_gas) = self.gas_metering.paused_frames.last() { // Keep gas constant if paused. interpreter.gas = *paused_gas; } else { // Record frame paused gas. - self.paused_frame_gas.push(interpreter.gas); + self.gas_metering.paused_frames.push(interpreter.gas); } + } + #[cold] + fn meter_gas_end(&mut self, interpreter: &mut Interpreter) { // Remove recorded gas if we exit frame. - match interpreter.current_opcode() { - opcode::STOP | opcode::RETURN | opcode::REVERT | opcode::SELFDESTRUCT => { - self.paused_frame_gas.pop(); + if will_exit(interpreter.instruction_result) { + self.gas_metering.paused_frames.pop(); + } + } + + #[cold] + fn meter_gas_check(&mut self, interpreter: &mut Interpreter) { + if will_exit(interpreter.instruction_result) { + // Reconcile gas if spent is less than refunded. + // This can happen if gas was paused / resumed (https://github.com/foundry-rs/foundry/issues/4370). + if interpreter.gas.spent() < + u64::try_from(interpreter.gas.refunded()).unwrap_or_default() + { + interpreter.gas = Gas::new(interpreter.gas.remaining()); } - _ => {} } } @@ -1385,11 +1424,11 @@ impl Cheatcodes { fn record_accesses(&mut self, interpreter: &mut Interpreter) { let Some(access) = &mut self.accesses else { return }; match interpreter.current_opcode() { - opcode::SLOAD => { + op::SLOAD => { let key = try_or_return!(interpreter.stack().peek(0)); access.record_read(interpreter.contract().target_address, key); } - opcode::SSTORE => { + op::SSTORE => { let key = try_or_return!(interpreter.stack().peek(0)); access.record_write(interpreter.contract().target_address, key); } @@ -1405,7 +1444,7 @@ impl Cheatcodes { ) { let Some(account_accesses) = &mut self.recorded_account_diffs_stack else { return }; match interpreter.current_opcode() { - opcode::SELFDESTRUCT => { + op::SELFDESTRUCT => { // Ensure that we're not selfdestructing a context recording was initiated on let Some(last) = account_accesses.last_mut() else { return }; @@ -1444,7 +1483,7 @@ impl Cheatcodes { }); } - opcode::SLOAD => { + op::SLOAD => { let Some(last) = account_accesses.last_mut() else { return }; let key = try_or_return!(interpreter.stack().peek(0)); @@ -1469,7 +1508,7 @@ impl Cheatcodes { }; append_storage_access(last, access, ecx.journaled_state.depth()); } - opcode::SSTORE => { + op::SSTORE => { let Some(last) = account_accesses.last_mut() else { return }; let key = try_or_return!(interpreter.stack().peek(0)); @@ -1496,12 +1535,12 @@ impl Cheatcodes { } // Record account accesses via the EXT family of opcodes - opcode::EXTCODECOPY | opcode::EXTCODESIZE | opcode::EXTCODEHASH | opcode::BALANCE => { + op::EXTCODECOPY | op::EXTCODESIZE | op::EXTCODEHASH | op::BALANCE => { let kind = match interpreter.current_opcode() { - opcode::EXTCODECOPY => crate::Vm::AccountAccessKind::Extcodecopy, - opcode::EXTCODESIZE => crate::Vm::AccountAccessKind::Extcodesize, - opcode::EXTCODEHASH => crate::Vm::AccountAccessKind::Extcodehash, - opcode::BALANCE => crate::Vm::AccountAccessKind::Balance, + op::EXTCODECOPY => crate::Vm::AccountAccessKind::Extcodecopy, + op::EXTCODESIZE => crate::Vm::AccountAccessKind::Extcodesize, + op::EXTCODEHASH => crate::Vm::AccountAccessKind::Extcodehash, + op::BALANCE => crate::Vm::AccountAccessKind::Balance, _ => unreachable!(), }; let address = @@ -1570,7 +1609,7 @@ impl Cheatcodes { // OPERATIONS THAT CAN EXPAND/MUTATE MEMORY BY WRITING // //////////////////////////////////////////////////////////////// - opcode::MSTORE => { + op::MSTORE => { // The offset of the mstore operation is at the top of the stack. let offset = try_or_return!(interpreter.stack().peek(0)).saturating_to::(); @@ -1592,7 +1631,7 @@ impl Cheatcodes { return } } - opcode::MSTORE8 => { + op::MSTORE8 => { // The offset of the mstore8 operation is at the top of the stack. let offset = try_or_return!(interpreter.stack().peek(0)).saturating_to::(); @@ -1608,7 +1647,7 @@ impl Cheatcodes { // OPERATIONS THAT CAN EXPAND MEMORY BY READING // //////////////////////////////////////////////////////////////// - opcode::MLOAD => { + op::MLOAD => { // The offset of the mload operation is at the top of the stack let offset = try_or_return!(interpreter.stack().peek(0)).saturating_to::(); @@ -1627,7 +1666,7 @@ impl Cheatcodes { // OPERATIONS WITH OFFSET AND SIZE ON STACK // //////////////////////////////////////////////////////////////// - opcode::CALL => { + op::CALL => { // The destination offset of the operation is the fifth element on the stack. let dest_offset = try_or_return!(interpreter.stack().peek(5)).saturating_to::(); @@ -1663,7 +1702,7 @@ impl Cheatcodes { } } - $(opcode::$opcode => { + $(op::$opcode => { // The destination offset of the operation. let dest_offset = try_or_return!(interpreter.stack().peek($offset_depth)).saturating_to::(); @@ -1842,6 +1881,11 @@ fn apply_dispatch( result } +/// Helper function to check if frame execution will exit. +fn will_exit(ir: InstructionResult) -> bool { + !matches!(ir, InstructionResult::Continue | InstructionResult::CallOrCreate) +} + // Caches the result of `calls_as_dyn_cheatcode`. // TODO: Remove this once Cheatcode is object-safe, as caching would not be necessary anymore. struct DynCheatCache<'a> { diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index f72c62ff327a9..e44d499eafa24 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -686,7 +686,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { call_inspectors_adjust_depth!( - [&mut self.tracer, &mut self.chisel_state, &mut self.printer], + [&mut self.tracer, &mut self.cheatcodes, &mut self.chisel_state, &mut self.printer], |inspector| inspector.step_end(interpreter, ecx), self, ecx diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index eae1514cf408b..37e1895f65373 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -462,8 +462,8 @@ forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { cmd.assert_err(); }); -// -forgetest_init!(repro_6531, |prj, cmd| { +// https://github.com/foundry-rs/foundry/pull/6531 +forgetest_init!(fork_traces, |prj, cmd| { prj.wipe_contracts(); let endpoint = rpc::next_http_archive_rpc_endpoint(); @@ -510,7 +510,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); }); -// +// https://github.com/foundry-rs/foundry/issues/6579 forgetest_init!(include_custom_types_in_traces, |prj, cmd| { prj.wipe_contracts(); @@ -862,7 +862,7 @@ Encountered a total of 2 failing tests, 0 tests succeeded "#]]); }); -// +// https://github.com/foundry-rs/foundry/issues/7530 forgetest_init!(should_show_precompile_labels, |prj, cmd| { prj.wipe_contracts(); @@ -1239,9 +1239,9 @@ contract DeterministicRandomnessTest is Test { assert_ne!(res4, res3); }); -// tests that `pauseGasMetering` used at the end of test does not produce meaningless values -// see https://github.com/foundry-rs/foundry/issues/5491 -forgetest_init!(repro_5491, |prj, cmd| { +// Tests that `pauseGasMetering` used at the end of test does not produce meaningless values. +// https://github.com/foundry-rs/foundry/issues/5491 +forgetest_init!(gas_metering_pause_last_call, |prj, cmd| { prj.wipe_contracts(); prj.add_test( @@ -1287,8 +1287,8 @@ contract ATest is Test { "#]]); }); -// see https://github.com/foundry-rs/foundry/issues/5564 -forgetest_init!(repro_5564, |prj, cmd| { +// https://github.com/foundry-rs/foundry/issues/5564 +forgetest_init!(gas_metering_expect_revert, |prj, cmd| { prj.wipe_contracts(); prj.add_test( @@ -1318,51 +1318,79 @@ contract ATest is Test { "#]]); }); -// see https://github.com/foundry-rs/foundry/issues/4523 -forgetest_init!(repro_4523, |prj, cmd| { +// https://github.com/foundry-rs/foundry/issues/4523 +forgetest_init!(gas_metering_gasleft, |prj, cmd| { prj.wipe_contracts(); prj.add_test( "ATest.t.sol", r#" import "forge-std/Test.sol"; + contract ATest is Test { - mapping(uint => bytes32) map; + mapping(uint256 => bytes32) map; - function test_GasMeter () public { + function test_GasMeter() public { vm.pauseGasMetering(); - for (uint i = 0; i < 10000; i++) { - map[i] = keccak256(abi.encode(i)); - } + consumeGas(); vm.resumeGasMetering(); - for (uint i = 0; i < 10000; i++) { - map[i] = keccak256(abi.encode(i)); - } + consumeGas(); } - function test_GasLeft () public { - for (uint i = 0; i < 10000; i++) { - map[i] = keccak256(abi.encode(i)); - } + function test_GasLeft() public { + consumeGas(); + + uint256 start = gasleft(); + consumeGas(); + console.log("Gas cost:", start - gasleft()); + } - uint start = gasleft(); - for (uint i = 0; i < 10000; i++) { + function consumeGas() private { + for (uint256 i = 0; i < 100; i++) { map[i] = keccak256(abi.encode(i)); } - console2.log("Gas cost:", start - gasleft()); } } "#, ) .unwrap(); + // Log and test gas cost should be similar. cmd.args(["test", "-vvvv"]).with_no_redact().assert_success().stdout_eq(str![[r#" ... Logs: - Gas cost: 5754479 + Gas cost: 34468 +... +[PASS] test_GasMeter() (gas: 37512) +... +"#]]); +}); + +// https://github.com/foundry-rs/foundry/issues/4370 +forgetest_init!(repro_4370, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "ATest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; +contract ATest is Test { + uint a; + function test_negativeGas () public { + vm.pauseGasMetering(); + a = 100; + vm.resumeGasMetering(); + delete a; + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" ... -[PASS] test_GasMeter() (gas: 5757137) +[PASS] test_negativeGas() (gas: 3252) ... "#]]); }); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 6c0708e207067..3cce4bed203e5 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -9,7 +9,10 @@ use crate::{ use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; use alloy_json_abi::Event; use alloy_primitives::{address, b256, Address, U256}; -use forge::{decode::decode_console_logs, result::TestStatus}; +use forge::{ + decode::decode_console_logs, + result::{TestKind, TestStatus}, +}; use foundry_config::{fs_permissions::PathPermission, Config, FsPermissions}; use foundry_evm::{ constants::HARDHAT_CONSOLE_ADDRESS, @@ -363,7 +366,15 @@ test_repro!(8287); test_repro!(8168); // https://github.com/foundry-rs/foundry/issues/8383 -test_repro!(8383); +test_repro!(8383, false, None, |res| { + let mut res = res.remove("default/repros/Issue8383.t.sol:Issue8383Test").unwrap(); + let test = res.test_results.remove("testP256VerifyOutOfBounds()").unwrap(); + assert_eq!(test.status, TestStatus::Success); + match test.kind { + TestKind::Unit { gas } => assert_eq!(gas, 3103), + _ => panic!("not a unit test kind"), + } +}); // https://github.com/foundry-rs/foundry/issues/1543 test_repro!(1543); diff --git a/testdata/default/cheats/GasMetering.t.sol b/testdata/default/cheats/GasMetering.t.sol index 54d0a7422aece..e439e05be0f74 100644 --- a/testdata/default/cheats/GasMetering.t.sol +++ b/testdata/default/cheats/GasMetering.t.sol @@ -16,21 +16,21 @@ contract GasMeteringTest is DSTest { function testGasMetering() public { uint256 gas_start = gasleft(); - addInLoop(); + consumeGas(); uint256 gas_end_normal = gas_start - gasleft(); vm.pauseGasMetering(); uint256 gas_start_not_metered = gasleft(); - addInLoop(); + consumeGas(); uint256 gas_end_not_metered = gas_start_not_metered - gasleft(); vm.resumeGasMetering(); uint256 gas_start_metered = gasleft(); - addInLoop(); + consumeGas(); uint256 gas_end_resume_metered = gas_start_metered - gasleft(); @@ -76,11 +76,9 @@ contract GasMeteringTest is DSTest { assertEq(gas_end_not_metered, 0); } - function addInLoop() internal returns (uint256) { - uint256 b; + function consumeGas() internal returns (uint256 x) { for (uint256 i; i < 10000; i++) { - b + i; + x += i; } - return b; } } From d28a3377e52e6a4114a8cea2903c115b023279e8 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 27 Aug 2024 03:44:18 +0800 Subject: [PATCH 1387/1963] chore(deps): bump foundry-compilers (#8746) * chore(deps): bump compilers * add doc * fix --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- crates/config/src/lib.rs | 7 +++++-- crates/config/src/vyper.rs | 3 +++ crates/verify/src/provider.rs | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9a01ff964b26..fdb4214e2eb79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3691,9 +3691,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b8ffe1d5a00cd78a9461262377270d88b8d6a8a5f51b402996242bccef3994" +checksum = "7eaa24a47bb84e1db38c84f03e8c90ca81050bd20beac8bdc99aae8afd0b8784" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3729,9 +3729,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdb80803e20447fc8c3f4ec97d47ad5fa37286648bb8224edbbc553ebe1a0f4" +checksum = "3588ee6a986f89040d1158fb90459731580b404fb72b8c6c832c0ddbc95fed58" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3739,9 +3739,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3280cf657d802358856a397cb8465b18a0a6c09b1fa6422842e422a9aa21276d" +checksum = "a149c5e8c326c7bae8f73cacb28c637f4bc2e535f950eec10348494990e9636f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3763,9 +3763,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ecc61aa540bff773d4441a94e0f158769fcedd61f61d3e91608a76d6bcd7aa" +checksum = "8645c9e7c070c81bf8c90f456416953234334f097b67445c773af98df74e27b0" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3778,9 +3778,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a14603a33a217e64cc38977c215b01b37b48a0cae0a739a9f9b3555f16938704" +checksum = "66492aeb708f3d142c078457dba5f52b04ca5031012d48903a0bcb37d205d595" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 5ac49d2df8db0..7816eb95b51c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -158,7 +158,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.5.1", default-features = false } -foundry-compilers = { version = "0.10.2", default-features = false } +foundry-compilers = { version = "0.10.3", default-features = false } foundry-fork-db = "0.2" solang-parser = "=0.3.3" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index cedf96e6e45e9..715a83a19aed7 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -997,7 +997,7 @@ impl Config { /// Returns configuration for a compiler to use when setting up a [Project]. pub fn compiler(&self) -> Result { - Ok(MultiCompiler { solc: self.solc_compiler()?, vyper: self.vyper_compiler()? }) + Ok(MultiCompiler { solc: Some(self.solc_compiler()?), vyper: self.vyper_compiler()? }) } /// Returns configured [MultiCompilerSettings]. @@ -1347,6 +1347,7 @@ impl Config { "evm.deployedBytecode".to_string(), ]), search_paths: None, + experimental_codegen: self.vyper.experimental_codegen, }) } @@ -5023,6 +5024,7 @@ mod tests { [vyper] optimize = "codesize" path = "/path/to/vyper" + experimental_codegen = true "#, )?; @@ -5031,7 +5033,8 @@ mod tests { config.vyper, VyperConfig { optimize: Some(VyperOptimizationMode::Codesize), - path: Some("/path/to/vyper".into()) + path: Some("/path/to/vyper".into()), + experimental_codegen: Some(true), } ); diff --git a/crates/config/src/vyper.rs b/crates/config/src/vyper.rs index 7b2f0a54ddc5d..dbd47faec208d 100644 --- a/crates/config/src/vyper.rs +++ b/crates/config/src/vyper.rs @@ -12,4 +12,7 @@ pub struct VyperConfig { /// The Vyper instance to use if any. #[serde(default, skip_serializing_if = "Option::is_none")] pub path: Option, + /// Optionally enables experimental Venom pipeline + #[serde(default, skip_serializing_if = "Option::is_none")] + pub experimental_codegen: Option, } diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index 1506585abf257..6e5b29d5e34c7 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -38,7 +38,7 @@ impl VerificationContext { project.no_artifacts = true; let solc = Solc::find_or_install(&compiler_version)?; - project.compiler.solc = SolcCompiler::Specific(solc); + project.compiler.solc = Some(SolcCompiler::Specific(solc)); Ok(Self { config, project, target_name, target_path, compiler_version }) } From 26f0ab4af02804e0c09d97d75099059ce0b32e11 Mon Sep 17 00:00:00 2001 From: Priyank Makwana <117025290+PriyankMkwna@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:44:54 +0530 Subject: [PATCH 1388/1963] Provide a shields.io badge (#8738) * Provide a Foundry shields.io badge * Updated foundry badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bdb5ad8a04c90..684b33556069e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ ## Foundry ![Github Actions][gha-badge] [![Telegram Chat][tg-badge]][tg-url] [![Telegram Support][tg-support-badge]][tg-support-url] +![Foundry](https://img.shields.io/badge/Foundry-grey?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAElElEQVR4nH1VUUhUaRg9984YdzBpkqR0Z210rIESIXSabEbcHgydrpNRRj00kWaztj0U1MOW0MOIbD300IvLMqBpMTGYxdoqyoRNDUESBDWwUuPugCSSsTM7u0Oj1/+efdiMcmnP2/fDd77D4f/OB6xCa2urQZbllVICYGtqanK1tLS4AdgAyAAgyzJaW1sNq/ulT4twOGw4fPiwAGDp7Ow8VV1d7bVarRWxWCw/k8mgsbExm0wmZ+Lx+M/Xr1//CcAsSVmSJH01McLhsAEAnE5nx+Tk5B/xeJxOp5N9fX2sqqqixWLhnTt36HA4GIvFGI1GU3V1df5Pe/9D1t7eHkgkEuzo6GBPT49WWloq7Ha7fujQITocDu7atUs3m83i6tWr2okTJ/jixQuePn265zPScDhskGUZe/fubXv8+DFv3rypbdiwQaxbt46RSIT79u3j0NAQb926RVVVOT4+TqvVyvz8fD0YDC5NTk6ysbHxlCRJ/5KSlAAURyKRTFNT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A%2F%2Fbook.getfoundry.sh%2F) [gha-badge]: https://img.shields.io/github/actions/workflow/status/foundry-rs/foundry/test.yml?branch=master [tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Ffoundry_rs From fa11be9f16e4ff5d969f61ffa9f57aa08679e175 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 27 Aug 2024 13:15:49 +0400 Subject: [PATCH 1389/1963] fix: throw error if `vm.expectEmit` is used on anonymous event (#8748) * fix: throw error on vm.expectEmit on anonymous event * add test --- crates/cheatcodes/src/inspector.rs | 4 ++-- crates/cheatcodes/src/test/expect.rs | 24 +++++++++++++++++++----- testdata/default/repros/Issue7457.t.sol | 4 ++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 09ced929462b5..a11d24bb92b16 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1031,9 +1031,9 @@ impl Inspector for Cheatcodes { } } - fn log(&mut self, _interpreter: &mut Interpreter, _ecx: &mut EvmContext, log: &Log) { + fn log(&mut self, interpreter: &mut Interpreter, _ecx: &mut EvmContext, log: &Log) { if !self.expected_emits.is_empty() { - expect::handle_expect_emit(self, log); + expect::handle_expect_emit(self, log, interpreter); } // `recordLogs` diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index b68ae700a57b4..4592f6367c0ec 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,7 +1,9 @@ -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result, Vm::*}; use alloy_primitives::{address, hex, Address, Bytes, LogData as RawLog, U256}; use alloy_sol_types::{SolError, SolValue}; -use revm::interpreter::{return_ok, InstructionResult}; +use revm::interpreter::{ + return_ok, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, +}; use spec::Vm; use std::collections::{hash_map::Entry, HashMap}; @@ -444,7 +446,11 @@ fn expect_emit( Ok(Default::default()) } -pub(crate) fn handle_expect_emit(state: &mut Cheatcodes, log: &alloy_primitives::Log) { +pub(crate) fn handle_expect_emit( + state: &mut Cheatcodes, + log: &alloy_primitives::Log, + interpreter: &mut Interpreter, +) { // Fill or check the expected emits. // We expect for emit checks to be filled as they're declared (from oldest to newest), // so we fill them and push them to the back of the queue. @@ -473,11 +479,19 @@ pub(crate) fn handle_expect_emit(state: &mut Cheatcodes, log: &alloy_primitives: let Some(expected) = &event_to_fill_or_check.log else { // Unless the caller is trying to match an anonymous event, the first topic must be // filled. - // TODO: failing this check should probably cause a warning if event_to_fill_or_check.anonymous || log.topics().first().is_some() { event_to_fill_or_check.log = Some(log.data.clone()); + state.expected_emits.push_back(event_to_fill_or_check); + } else { + interpreter.instruction_result = InstructionResult::Revert; + interpreter.next_action = InterpreterAction::Return { + result: InterpreterResult { + output: Error::encode("use vm.expectEmitAnonymous to match anonymous events"), + gas: interpreter.gas, + result: InstructionResult::Revert, + }, + }; } - state.expected_emits.push_back(event_to_fill_or_check); return }; diff --git a/testdata/default/repros/Issue7457.t.sol b/testdata/default/repros/Issue7457.t.sol index 8d9d6f0753d5c..3c4080df2f8e7 100644 --- a/testdata/default/repros/Issue7457.t.sol +++ b/testdata/default/repros/Issue7457.t.sol @@ -61,10 +61,10 @@ contract Issue7457Test is DSTest, ITarget { target.emitAnonymousEventEmpty(); } - function testFailEmitEventNonIndexed() public { + function testEmitEventNonIndexedReverts() public { vm.expectEmit(false, false, false, true); + vm.expectRevert("use vm.expectEmitAnonymous to match anonymous events"); emit AnonymousEventNonIndexed(1); - target.emitAnonymousEventNonIndexed(1); } function testEmitEventNonIndexed() public { From b97c67339cb8153dd9fa9207000e2b8561fe729d Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Tue, 27 Aug 2024 13:35:12 +0300 Subject: [PATCH 1390/1963] Update to Soldeer 0.3.0 (#8648) * Update to Soldeer 0.3.0 * added config tests and descriptive comments, refactored the soldeer config to look more explicit as well * fmt * removed soldeer config value variable * fixed tests * modified cargo lock * clipy and fmt * fmt * fmt * bumped to 0.3.1 with the hotfix for os --- Cargo.lock | 60 +++------- Cargo.toml | 3 +- crates/config/src/lib.rs | 92 ++++++++++----- crates/config/src/soldeer.rs | 57 ++++++++- crates/forge/bin/cmd/soldeer.rs | 30 +++-- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/soldeer.rs | 185 ++++++++++++++++++++++-------- 7 files changed, 295 insertions(+), 133 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdb4214e2eb79..9278cf751c4a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7456,6 +7456,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sanitize-filename" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ed72fbaf78e6f2d41744923916966c4fbe3d7c74e3037a8ee482f1115572603" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "scale-info" version = "2.11.3" @@ -7826,19 +7836,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha256" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0" -dependencies = [ - "async-trait", - "bytes", - "hex", - "sha2", - "tokio", -] - [[package]] name = "sha3" version = "0.10.8" @@ -7946,15 +7943,6 @@ dependencies = [ "similar", ] -[[package]] -name = "simple-home-dir" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c221cbc8c1ff6bdf949b12cc011456c510ec6840654b444c7374c78e928ce344" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "simple_asn1" version = "0.6.2" @@ -8039,30 +8027,29 @@ dependencies = [ [[package]] name = "soldeer" -version = "0.2.19" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d584c27ebf7ad3e2557d029a07b19fa0d192d67bd73eea1e1695936eb5666e34" +checksum = "6191e16cbc3b4ed14cafc642bc2b7f966eddb7c1f3a9f60549f6a1e526016127" dependencies = [ "chrono", "clap", + "const-hex", "email-address-parser", "futures", - "once_cell", + "home", + "ignore", "regex", "reqwest", "rpassword", + "sanitize-filename", "serde", - "serde_derive", "serde_json", - "sha256", - "simple-home-dir", + "sha2", + "thiserror", "tokio", - "toml 0.8.19", "toml_edit 0.22.20", "uuid 1.10.0", - "walkdir", "yansi", - "yash-fnmatch", "zip 2.2.0", "zip-extract", ] @@ -9688,17 +9675,6 @@ dependencies = [ "is-terminal", ] -[[package]] -name = "yash-fnmatch" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697c20b479d2e6419e9a073bfdd20e90cbd8540d6c683ee46712e13de650e54f" -dependencies = [ - "regex", - "regex-syntax 0.8.4", - "thiserror", -] - [[package]] name = "zerocopy" version = "0.7.35" diff --git a/Cargo.toml b/Cargo.toml index 7816eb95b51c5..c6c8aee07db86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -258,8 +258,7 @@ reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" # soldeer -soldeer = "0.2.19" - +soldeer = "0.3.1" proptest = "1" comfy-table = "7" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 715a83a19aed7..13dfc0474200d 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -107,7 +107,7 @@ mod inline; pub use inline::{validate_profiles, InlineConfig, InlineConfigError, InlineConfigParser, NatSpec}; pub mod soldeer; -use soldeer::SoldeerConfig; +use soldeer::{SoldeerConfig, SoldeerDependencyConfig}; mod vyper; use vyper::VyperConfig; @@ -422,7 +422,10 @@ pub struct Config { pub vyper: VyperConfig, /// Soldeer dependencies - pub dependencies: Option, + pub dependencies: Option, + + /// Soldeer custom configs + pub soldeer: Option, /// The root path where the config detection started from, [`Config::with_root`]. // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] @@ -498,6 +501,7 @@ impl Config { "invariant", "labels", "dependencies", + "soldeer", "vyper", "bind_json", ]; @@ -892,7 +896,7 @@ impl Config { if self.offline { return Err(SolcError::msg(format!( "can't install missing solc {version} in offline mode" - ))) + ))); } Solc::blocking_install(version)? } @@ -902,12 +906,12 @@ impl Config { return Err(SolcError::msg(format!( "`solc` {} does not exist", solc.display() - ))) + ))); } Solc::new(solc)? } }; - return Ok(Some(solc)) + return Ok(Some(solc)); } Ok(None) @@ -925,7 +929,7 @@ impl Config { /// `auto_detect_solc` pub fn is_auto_detect(&self) -> bool { if self.solc.is_some() { - return false + return false; } self.auto_detect_solc } @@ -984,7 +988,7 @@ impl Config { pub fn vyper_compiler(&self) -> Result, SolcError> { // Only instantiate Vyper if there are any Vyper files in the project. if self.project_paths::().input_files_iter().next().is_none() { - return Ok(None) + return Ok(None); } let vyper = if let Some(path) = &self.vyper.path { Some(Vyper::new(path)?) @@ -1166,7 +1170,7 @@ impl Config { ) -> Result, EtherscanConfigError> { if let Some(maybe_alias) = self.etherscan_api_key.as_ref().or(self.eth_rpc_url.as_ref()) { if self.etherscan.contains_key(maybe_alias) { - return self.etherscan.clone().resolved().remove(maybe_alias).transpose() + return self.etherscan.clone().resolved().remove(maybe_alias).transpose(); } } @@ -1180,7 +1184,7 @@ impl Config { // we update the key, because if an etherscan_api_key is set, it should take // precedence over the entry, since this is usually set via env var or CLI args. config.key.clone_from(key); - return Ok(Some(config)) + return Ok(Some(config)); } (Ok(config), None) => return Ok(Some(config)), (Err(err), None) => return Err(err), @@ -1193,7 +1197,7 @@ impl Config { // etherscan fallback via API key if let Some(key) = self.etherscan_api_key.as_ref() { let chain = chain.or(self.chain).unwrap_or_default(); - return Ok(ResolvedEtherscanConfig::create(key, chain)) + return Ok(ResolvedEtherscanConfig::create(key, chain)); } Ok(None) @@ -1478,7 +1482,7 @@ impl Config { { let file_path = self.get_config_path(); if !file_path.exists() { - return Ok(()) + return Ok(()); } let contents = fs::read_to_string(&file_path)?; let mut doc = contents.parse::()?; @@ -1640,14 +1644,14 @@ impl Config { return match path.is_file() { true => Some(path.to_path_buf()), false => None, - } + }; } let cwd = std::env::current_dir().ok()?; let mut cwd = cwd.as_path(); loop { let file_path = cwd.join(path); if file_path.is_file() { - return Some(file_path) + return Some(file_path); } cwd = cwd.parent()?; } @@ -1721,7 +1725,7 @@ impl Config { if let Some(cache_dir) = Self::foundry_rpc_cache_dir() { let mut cache = Cache { chains: vec![] }; if !cache_dir.exists() { - return Ok(cache) + return Ok(cache); } if let Ok(entries) = cache_dir.as_path().read_dir() { for entry in entries.flatten().filter(|x| x.path().is_dir()) { @@ -1765,7 +1769,7 @@ impl Config { fn get_cached_blocks(chain_path: &Path) -> eyre::Result> { let mut blocks = vec![]; if !chain_path.exists() { - return Ok(blocks) + return Ok(blocks); } for block in chain_path.read_dir()?.flatten() { let file_type = block.file_type()?; @@ -1777,7 +1781,7 @@ impl Config { { block.path() } else { - continue + continue; }; blocks.push((file_name.to_string_lossy().into_owned(), fs::metadata(filepath)?.len())); } @@ -1787,7 +1791,7 @@ impl Config { /// The path provided to this function should point to the etherscan cache for a chain. fn get_cached_block_explorer_data(chain_path: &Path) -> eyre::Result { if !chain_path.exists() { - return Ok(0) + return Ok(0); } fn dir_size_recursive(mut dir: fs::ReadDir) -> eyre::Result { @@ -1963,7 +1967,7 @@ pub(crate) mod from_opt_glob { { let s: Option = Option::deserialize(deserializer)?; if let Some(s) = s { - return Ok(Some(globset::Glob::new(&s).map_err(serde::de::Error::custom)?)) + return Ok(Some(globset::Glob::new(&s).map_err(serde::de::Error::custom)?)); } Ok(None) } @@ -2141,6 +2145,7 @@ impl Default for Config { create2_library_salt: Self::DEFAULT_CREATE2_LIBRARY_SALT, skip: vec![], dependencies: Default::default(), + soldeer: Default::default(), assertions_revert: true, legacy_assertions: false, warnings: vec![], @@ -2247,7 +2252,7 @@ impl TomlFileProvider { if let Some(file) = self.env_val() { let path = Path::new(&file); if !path.exists() { - return true + return true; } } false @@ -2267,7 +2272,7 @@ impl TomlFileProvider { "Config file `{}` set in env var `{}` does not exist", file, self.env_var.unwrap() - ))) + ))); } Toml::file(file) } else { @@ -2311,7 +2316,7 @@ impl Provider for ForcedSnakeCaseData

{ if Config::STANDALONE_SECTIONS.contains(&profile.as_ref()) { // don't force snake case for keys in standalone sections map.insert(profile, dict); - continue + continue; } map.insert(profile, dict.into_iter().map(|(k, v)| (k.to_snake_case(), v)).collect()); } @@ -2451,7 +2456,7 @@ impl Provider for DappEnvCompatProvider { if val > 1 { return Err( format!("Invalid $DAPP_BUILD_OPTIMIZE value `{val}`, expected 0 or 1").into() - ) + ); } dict.insert("optimizer".to_string(), (val == 1).into()); } @@ -2517,7 +2522,7 @@ impl Provider for RenameProfileProvider

{ fn data(&self) -> Result, Error> { let mut data = self.provider.data()?; if let Some(data) = data.remove(&self.from) { - return Ok(Map::from([(self.to.clone(), data)])) + return Ok(Map::from([(self.to.clone(), data)])); } Ok(Default::default()) } @@ -2563,7 +2568,7 @@ impl Provider for UnwrapProfileProvider

{ for (profile_str, profile_val) in profiles { let profile = Profile::new(&profile_str); if profile != self.profile { - continue + continue; } match profile_val { Value::Dict(_, dict) => return Ok(profile.collect(dict)), @@ -2574,7 +2579,7 @@ impl Provider for UnwrapProfileProvider

{ )); err.metadata = Some(self.provider.metadata()); err.profile = Some(self.profile.clone()); - return Err(err) + return Err(err); } } } @@ -2686,7 +2691,7 @@ impl Provider for OptionalStrictProfileProvider

{ // provider and can't map the metadata to the error. Therefor we return the root error // if this error originated in the provider's data. if let Err(root_err) = self.provider.data() { - return root_err + return root_err; } err }) @@ -2814,6 +2819,7 @@ mod tests { vyper::VyperOptimizationMode, ModelCheckerEngine, YulDetails, }; use similar_asserts::assert_eq; + use soldeer::RemappingsLocation; use std::{collections::BTreeMap, fs::File, io::Write}; use tempfile::tempdir; use NamedChain::Moonbeam; @@ -5041,4 +5047,38 @@ mod tests { Ok(()) }); } + + #[test] + fn test_parse_soldeer() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [soldeer] + remappings_generate = true + remappings_regenerate = false + remappings_version = true + remappings_prefix = "@" + remappings_location = "txt" + recursive_deps = true + "#, + )?; + + let config = Config::load(); + + assert_eq!( + config.soldeer, + Some(SoldeerConfig { + remappings_generate: true, + remappings_regenerate: false, + remappings_version: true, + remappings_prefix: "@".to_string(), + remappings_location: RemappingsLocation::Txt, + recursive_deps: true, + }) + ); + + Ok(()) + }); + } } diff --git a/crates/config/src/soldeer.rs b/crates/config/src/soldeer.rs index 3bb8e9a3b74a8..75ee96c2c0fee 100644 --- a/crates/config/src/soldeer.rs +++ b/crates/config/src/soldeer.rs @@ -21,9 +21,9 @@ pub struct MapDependency { /// Type for Soldeer configs, under dependencies tag in the foundry.toml #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct SoldeerConfig(BTreeMap); +pub struct SoldeerDependencyConfig(BTreeMap); -impl AsRef for SoldeerConfig { +impl AsRef for SoldeerDependencyConfig { fn as_ref(&self) -> &Self { self } @@ -39,3 +39,56 @@ pub enum SoldeerDependencyValue { Map(MapDependency), Str(String), } + +/// Location where to store the remappings, either in `remappings.txt` or in the `foundry.toml` +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Default)] +#[serde(rename_all = "lowercase")] +pub enum RemappingsLocation { + #[default] + Txt, + Config, +} + +fn default_true() -> bool { + true +} + +/// Type for Soldeer configs, under soldeer tag in the foundry.toml +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +pub struct SoldeerConfig { + #[serde(default = "default_true")] + pub remappings_generate: bool, + + #[serde(default)] + pub remappings_regenerate: bool, + + #[serde(default = "default_true")] + pub remappings_version: bool, + + #[serde(default)] + pub remappings_prefix: String, + + #[serde(default)] + pub remappings_location: RemappingsLocation, + + #[serde(default)] + pub recursive_deps: bool, +} + +impl AsRef for SoldeerConfig { + fn as_ref(&self) -> &Self { + self + } +} +impl Default for SoldeerConfig { + fn default() -> Self { + Self { + remappings_generate: true, + remappings_regenerate: false, + remappings_version: true, + remappings_prefix: String::new(), + remappings_location: Default::default(), + recursive_deps: false, + } + } +} diff --git a/crates/forge/bin/cmd/soldeer.rs b/crates/forge/bin/cmd/soldeer.rs index 9c8579fe7a4e9..5482bdc6fe94c 100644 --- a/crates/forge/bin/cmd/soldeer.rs +++ b/crates/forge/bin/cmd/soldeer.rs @@ -4,15 +4,23 @@ use eyre::Result; use soldeer::commands::Subcommands; // CLI arguments for `forge soldeer`. +// The following list of commands and their actions: +// +// forge soldeer install: looks up the config file and install all the dependencies that are present +// there forge soldeer install package~version: looks up on https://soldeer.xyz and if the package>version is there then add to config+lockfile and install new dependency. Replaces existing entry if version is different. +// forge soldeer install package~version url: same behavior as install but instead of looking at https://soldeer.xyz it choses the URL, which can be git or custom zip url +// forge soldeer update: same behavior as install looks up the config file and install all the +// dependencies that are present there. This will change in the future forge soldeer login: logs in into https://soldeer.xyz account +// forge soldeer push package~version: pushes files to the central repository +// forge soldeer version: checks soldeer version +// forge soldeer init: initializes a new project with minimal dependency for foundry setup, install +// latest forge-std version forge soldeer uninstall dependency: uninstalls a dependency, removes +// artifacts and configs + #[derive(Clone, Debug, Parser)] -#[clap(override_usage = "forge soldeer install [DEPENDENCY]~[VERSION] - forge soldeer install [DEPENDENCY]~[VERSION] - forge soldeer install [DEPENDENCY]~[VERSION] --rev - forge soldeer install [DEPENDENCY]~[VERSION] --rev - forge soldeer push [DEPENDENCY]~[VERSION] - forge soldeer login - forge soldeer update - forge soldeer version")] +#[clap( + override_usage = "Native Solidity Package Manager, `run forge soldeer [COMMAND] --help` for more details" +)] pub struct SoldeerArgs { /// Command must be one of the following install/push/login/update/version. #[command(subcommand)] @@ -23,7 +31,7 @@ impl SoldeerArgs { pub fn run(self) -> Result<()> { match soldeer::run(self.command) { Ok(_) => Ok(()), - Err(err) => Err(eyre::eyre!("Failed to run soldeer {}", err.message)), + Err(err) => Err(eyre::eyre!("Failed to run soldeer {}", err)), } } } @@ -31,10 +39,10 @@ impl SoldeerArgs { #[cfg(test)] mod tests { use super::*; - use soldeer::commands::VersionDryRun; + use soldeer::commands::Version; #[test] fn test_soldeer_version() { - assert!(soldeer::run(Subcommands::VersionDryRun(VersionDryRun {})).is_ok()); + assert!(soldeer::run(Subcommands::Version(Version {})).is_ok()); } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index e943001af9078..88ac186b20cb7 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -143,6 +143,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { vyper: Default::default(), skip: vec![], dependencies: Default::default(), + soldeer: Default::default(), warnings: vec![], assertions_revert: true, legacy_assertions: false, diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index 1a62578d1b67a..bacf47230ba69 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -24,16 +24,12 @@ forgesoldeer!(install_dependency, |prj, cmd| { // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - let lock_contents = r#" -[[dependencies]] -name = "forge-std" -version = "1.8.1" -source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" -checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" -"#; let actual_lock_contents = read_file_to_string(&path_lock_file); - assert_eq!(lock_contents, actual_lock_contents); + assert!(actual_lock_contents.contains("forge-std")); + assert!(actual_lock_contents + .contains("0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0")); + assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -41,10 +37,10 @@ src = "src" out = "out" libs = ["lib"] -# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options - [dependencies] forge-std = "1.8.1" + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options "#; assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); @@ -53,7 +49,7 @@ forge-std = "1.8.1" forgesoldeer!(install_dependency_git, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; - let git = "git@gitlab.com:mario4582928/Mario.git"; + let git = "https://gitlab.com/mario4582928/Mario.git"; let foundry_file = prj.root().join("foundry.toml"); @@ -67,16 +63,11 @@ forgesoldeer!(install_dependency_git, |prj, cmd| { // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - let lock_contents = r#" -[[dependencies]] -name = "forge-std" -version = "1.8.1" -source = "git@gitlab.com:mario4582928/Mario.git" -checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c" -"#; let actual_lock_contents = read_file_to_string(&path_lock_file); - assert_eq!(lock_contents, actual_lock_contents); + assert!(actual_lock_contents.contains("forge-std")); + assert!(actual_lock_contents.contains("22868f426bd4dd0e682b5ec5f9bd55507664240c")); + assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -84,10 +75,10 @@ src = "src" out = "out" libs = ["lib"] -# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options - [dependencies] -forge-std = { version = "1.8.1", git = "git@gitlab.com:mario4582928/Mario.git", rev = "22868f426bd4dd0e682b5ec5f9bd55507664240c" } +forge-std = { version = "1.8.1", git = "https://gitlab.com/mario4582928/Mario.git", rev = "22868f426bd4dd0e682b5ec5f9bd55507664240c" } + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options "#; assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); @@ -96,7 +87,7 @@ forge-std = { version = "1.8.1", git = "git@gitlab.com:mario4582928/Mario.git", forgesoldeer!(install_dependency_git_commit, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; - let git = "git@gitlab.com:mario4582928/Mario.git"; + let git = "https://gitlab.com/mario4582928/Mario.git"; let rev_flag = "--rev"; let commit = "7a0663eaf7488732f39550be655bad6694974cb3"; @@ -113,16 +104,12 @@ forgesoldeer!(install_dependency_git_commit, |prj, cmd| { // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - let lock_contents = r#" -[[dependencies]] -name = "forge-std" -version = "1.8.1" -source = "git@gitlab.com:mario4582928/Mario.git" -checksum = "7a0663eaf7488732f39550be655bad6694974cb3" -"#; let actual_lock_contents = read_file_to_string(&path_lock_file); - assert_eq!(lock_contents, actual_lock_contents); + assert!(actual_lock_contents.contains("forge-std")); + assert!(actual_lock_contents.contains("7a0663eaf7488732f39550be655bad6694974cb3")); + assert!(actual_lock_contents.contains("https://gitlab.com/mario4582928/Mario.git")); + assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -130,10 +117,10 @@ src = "src" out = "out" libs = ["lib"] -# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options - [dependencies] -forge-std = { version = "1.8.1", git = "git@gitlab.com:mario4582928/Mario.git", rev = "7a0663eaf7488732f39550be655bad6694974cb3" } +forge-std = { version = "1.8.1", git = "https://gitlab.com/mario4582928/Mario.git", rev = "7a0663eaf7488732f39550be655bad6694974cb3" } + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options "#; assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); @@ -145,7 +132,12 @@ forgesoldeer!(update_dependencies, |prj, cmd| { // We need to write this into the foundry.toml to make the update install the dependency let foundry_updates = r#" [dependencies] +"@tt" = {version = "1.6.1", url = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/3_3_0-rc_2_22-01-2024_13:12:57_contracts.zip"} forge-std = { version = "1.8.1" } +solmate = "6.7.0" +mario = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", rev = "22868f426bd4dd0e682b5ec5f9bd55507664240c" } +mario-custom-tag = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", tag = "custom-tag" } +mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", tag = "custom-branch" } "#; let foundry_file = prj.root().join("foundry.toml"); @@ -166,16 +158,20 @@ forge-std = { version = "1.8.1" } // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - let lock_contents = r#" -[[dependencies]] -name = "forge-std" -version = "1.8.1" -source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" -checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" -"#; + let dep1 = prj.root().join("dependencies").join("@tt-1.6.1"); + let dep2 = prj.root().join("dependencies").join("forge-std-1.8.1"); + let dep3 = prj.root().join("dependencies").join("mario-1.0"); + let dep4 = prj.root().join("dependencies").join("solmate-6.7.0"); + let dep5 = prj.root().join("dependencies").join("mario-custom-tag-1.0"); + let dep6 = prj.root().join("dependencies").join("mario-custom-branch-1.0"); let actual_lock_contents = read_file_to_string(&path_lock_file); - assert_eq!(lock_contents, actual_lock_contents); + assert!(actual_lock_contents.contains("@tt")); + assert!(actual_lock_contents.contains("forge-std")); + assert!(actual_lock_contents.contains("mario")); + assert!(actual_lock_contents.contains("solmate")); + assert!(actual_lock_contents.contains("mario-custom-tag")); + assert!(actual_lock_contents.contains("mario-custom-branch")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -186,10 +182,21 @@ libs = ["lib"] # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options [dependencies] +"@tt" = {version = "1.6.1", url = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/3_3_0-rc_2_22-01-2024_13:12:57_contracts.zip"} forge-std = { version = "1.8.1" } +solmate = "6.7.0" +mario = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", rev = "22868f426bd4dd0e682b5ec5f9bd55507664240c" } +mario-custom-tag = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", tag = "custom-tag" } +mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", tag = "custom-branch" } "#; assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); + assert!(dep1.exists()); + assert!(dep2.exists()); + assert!(dep3.exists()); + assert!(dep4.exists()); + assert!(dep5.exists()); + assert!(dep6.exists()); }); forgesoldeer!(update_dependencies_simple_version, |prj, cmd| { @@ -220,16 +227,12 @@ forge-std = "1.8.1" // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - let lock_contents = r#" -[[dependencies]] -name = "forge-std" -version = "1.8.1" -source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" -checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" -"#; let actual_lock_contents = read_file_to_string(&path_lock_file); - assert_eq!(lock_contents, actual_lock_contents); + assert!(actual_lock_contents.contains("forge-std")); + assert!(actual_lock_contents + .contains("0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0")); + assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -257,6 +260,88 @@ forgesoldeer!(login, |prj, cmd| { assert!(stdout.contains("Please enter your email")); }); +forgesoldeer!(install_dependency_with_remappings_config, |prj, cmd| { + let command = "install"; + let dependency = "forge-std~1.8.1"; + let foundry_updates = r#" +[soldeer] +remappings_generate = true +remappings_prefix = "@custom-f@" +remappings_location = "config" +remappings_regenerate = true +"#; + let foundry_file = prj.root().join("foundry.toml"); + let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); + + if let Err(e) = write!(file, "{foundry_updates}") { + eprintln!("Couldn't write to file: {e}"); + } + + cmd.arg("soldeer").args([command, dependency]); + cmd.execute(); + + // Making sure the path was created to the dependency and that foundry.toml exists + // meaning that the dependencies were installed correctly + let path_dep_forge = + prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); + assert!(path_dep_forge.exists()); + + // Making sure the foundry contents are the right ones + let foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] +remappings = ["@custom-f@forge-std-1.8.1/=dependencies/forge-std-1.8.1/"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + +[soldeer] +remappings_generate = true +remappings_prefix = "@custom-f@" +remappings_location = "config" +remappings_regenerate = true + +[dependencies] +forge-std = "1.8.1" +"#; + + assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); +}); + +forgesoldeer!(install_dependency_with_remappings_txt, |prj, cmd| { + let command = "install"; + let dependency = "forge-std~1.8.1"; + let foundry_updates = r#" +[soldeer] +remappings_generate = true +remappings_prefix = "@custom-f@" +remappings_location = "txt" +remappings_regenerate = true +"#; + let foundry_file = prj.root().join("foundry.toml"); + let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); + + if let Err(e) = write!(file, "{foundry_updates}") { + eprintln!("Couldn't write to file: {e}"); + } + + cmd.arg("soldeer").args([command, dependency]); + cmd.execute(); + + // Making sure the path was created to the dependency and that foundry.toml exists + // meaning that the dependencies were installed correctly + let path_dep_forge = + prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); + assert!(path_dep_forge.exists()); + + // Making sure the foundry contents are the right ones + let remappings_content = "@custom-f@forge-std-1.8.1/=dependencies/forge-std-1.8.1/\n"; + let remappings_file = prj.root().join("remappings.txt"); + println!("ddd {:?}", read_file_to_string(&remappings_file)); + + assert_data_eq!(read_file_to_string(&remappings_file), remappings_content); +}); + fn read_file_to_string(path: &Path) -> String { let contents: String = fs::read_to_string(path).unwrap_or_default(); contents From 5d2ac1ad0682f8172fec7348802d62344cb562bd Mon Sep 17 00:00:00 2001 From: bernard-wagner Date: Tue, 27 Aug 2024 15:46:33 +0200 Subject: [PATCH 1391/1963] fix(anvil): backwards compatible dumps (#8752) * fix(anvil): backwards compatible state * regression tests * fmt --------- Co-authored-by: Matthias Seitz --- crates/anvil/src/eth/backend/db.rs | 33 +++++++++++++++++-- crates/anvil/test-data/state-dump-legacy.json | 1 + crates/anvil/test-data/state-dump.json | 1 + crates/anvil/tests/it/state.rs | 21 ++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 crates/anvil/test-data/state-dump-legacy.json create mode 100644 crates/anvil/test-data/state-dump.json diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index e6d9541f32c1e..cf8f1f5c9ae03 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -6,7 +6,7 @@ use alloy_primitives::{keccak256, Address, Bytes, B256, U256, U64}; use alloy_rpc_types::BlockId; use anvil_core::eth::{ block::Block, - transaction::{MaybeImpersonatedTransaction, TransactionInfo, TypedReceipt}, + transaction::{MaybeImpersonatedTransaction, TransactionInfo, TypedReceipt, TypedTransaction}, }; use foundry_common::errors::FsPathError; use foundry_evm::{ @@ -359,10 +359,24 @@ pub struct SerializableAccountRecord { pub storage: BTreeMap, } +/// Defines a backwards-compatible enum for transactions. +/// This is essential for maintaining compatibility with state dumps +/// created before the changes introduced in PR #8411. +/// +/// The enum can represent either a `TypedTransaction` or a `MaybeImpersonatedTransaction`, +/// depending on the data being deserialized. This flexibility ensures that older state +/// dumps can still be loaded correctly, even after the changes in #8411. +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SerializableTransactionType { + TypedTransaction(TypedTransaction), + MaybeImpersonatedTransaction(MaybeImpersonatedTransaction), +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SerializableBlock { pub header: Header, - pub transactions: Vec, + pub transactions: Vec, pub ommers: Vec

, } @@ -386,6 +400,21 @@ impl From for Block { } } +impl From for SerializableTransactionType { + fn from(transaction: MaybeImpersonatedTransaction) -> Self { + Self::MaybeImpersonatedTransaction(transaction) + } +} + +impl From for MaybeImpersonatedTransaction { + fn from(transaction: SerializableTransactionType) -> Self { + match transaction { + SerializableTransactionType::TypedTransaction(tx) => Self::new(tx), + SerializableTransactionType::MaybeImpersonatedTransaction(tx) => tx, + } + } +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SerializableTransaction { pub info: TransactionInfo, diff --git a/crates/anvil/test-data/state-dump-legacy.json b/crates/anvil/test-data/state-dump-legacy.json new file mode 100644 index 0000000000000..45906791db452 --- /dev/null +++ b/crates/anvil/test-data/state-dump-legacy.json @@ -0,0 +1 @@ +{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdc823","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xb92480171c0235f8c6710a4047d7ee14a3be58c630839fb4422826ff3a013e44","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc823","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}}],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdc80e","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xa00dc0c9ee9a888e67ea32d8772f8cc28eff62448c9ec985ee941fcbc921ba59","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc814","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}}],"ommers":[]}]} \ No newline at end of file diff --git a/crates/anvil/test-data/state-dump.json b/crates/anvil/test-data/state-dump.json new file mode 100644 index 0000000000000..159f30d21c407 --- /dev/null +++ b/crates/anvil/test-data/state-dump.json @@ -0,0 +1 @@ +{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdcc2b","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xdb639d7f8af4f0ff2aa9cc49861820e72f5f8bfeeed677d1e3569f6b1625df4a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdcc25","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x3a52101c98a4319c419681131d3585d70a6cf13a9af25136be20d451eed5480a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc29","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}},"impersonated_sender":null}],"ommers":[]},{"header":{"parentHash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc2b","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}},"impersonated_sender":null}],"ommers":[]}],"transactions":[{"info":{"transaction_hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3","transaction_index":0,"from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","block_number":1},{"info":{"transaction_hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515","transaction_index":0,"from":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","address":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x1f435a603c1bf6d544a90156b572b96d7a1730028422d800839bae78bb3506d0","block_number":2}]} \ No newline at end of file diff --git a/crates/anvil/tests/it/state.rs b/crates/anvil/tests/it/state.rs index 7e822ee23b5ac..4e96ab0f11633 100644 --- a/crates/anvil/tests/it/state.rs +++ b/crates/anvil/tests/it/state.rs @@ -1,5 +1,6 @@ //! general eth api tests +use alloy_primitives::Uint; use anvil::{spawn, NodeConfig}; #[tokio::test(flavor = "multi_thread")] @@ -21,3 +22,23 @@ async fn can_load_state() { let num2 = api.block_number().unwrap(); assert_eq!(num, num2); } + +#[tokio::test(flavor = "multi_thread")] +async fn can_load_existing_state_legacy() { + let state_file = "test-data/state-dump-legacy.json"; + + let (api, _handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; + + let block_number = api.block_number().unwrap(); + assert_eq!(block_number, Uint::from(2)); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_load_existing_state() { + let state_file = "test-data/state-dump.json"; + + let (api, _handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; + + let block_number = api.block_number().unwrap(); + assert_eq!(block_number, Uint::from(2)); +} From 187cbb5797cc57b8d5261d77e93e8f330f53a912 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:49:33 +0300 Subject: [PATCH 1392/1963] feat(cheatcodes): add resetGasMetering cheatcode (#8750) * feat(cheatcodes): add resetGasMetering cheatcode * Changes after review: nit, add test for negative gas * Consistent gas reset if touched --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++ crates/cheatcodes/spec/src/vm.rs | 4 + crates/cheatcodes/src/evm.rs | 10 +- crates/cheatcodes/src/inspector.rs | 52 +++++++--- crates/forge/tests/cli/test_cmd.rs | 122 ++++++++++++++++++++++- testdata/cheats/Vm.sol | 1 + 6 files changed, 192 insertions(+), 17 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 4f41af83ea1c0..03755f4e6a01a 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7011,6 +7011,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "resetGasMetering", + "description": "Reset gas metering (i.e. gas usage is set to gas limit).", + "declaration": "function resetGasMetering() external;", + "visibility": "external", + "mutability": "", + "signature": "resetGasMetering()", + "selector": "0xbe367dd3", + "selectorBytes": [ + 190, + 54, + 125, + 211 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "resetNonce", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 4149b56b46168..1a092176d44af 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -662,6 +662,10 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function resumeGasMetering() external; + /// Reset gas metering (i.e. gas usage is set to gas limit). + #[cheatcode(group = Evm, safety = Safe)] + function resetGasMetering() external; + // -------- Gas Measurement -------- /// Gets the gas used in the last call. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 6d8bdfb37bafe..a3d517387d3d3 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -222,10 +222,18 @@ impl Cheatcode for resumeGasMeteringCall { } } +impl Cheatcode for resetGasMeteringCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self {} = self; + state.gas_metering.reset(); + Ok(Default::default()) + } +} + impl Cheatcode for lastCallGasCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self {} = self; - let Some(last_call_gas) = &state.last_call_gas else { + let Some(last_call_gas) = &state.gas_metering.last_call_gas else { bail!("no external call was made yet"); }; Ok(last_call_gas.abi_encode()) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index a11d24bb92b16..8e2331cf17830 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -219,10 +219,17 @@ pub struct BroadcastableTransaction { pub struct GasMetering { /// True if gas metering is paused. pub paused: bool, - /// True if gas metering was resumed during the test. - pub resumed: bool, + /// True if gas metering was resumed or reseted during the test. + /// Used to reconcile gas when frame ends (if spent less than refunded). + pub touched: bool, + /// True if gas metering should be reset to frame limit. + pub reset: bool, /// Stores frames paused gas. pub paused_frames: Vec, + + /// Cache of the amount of gas used in previous call. + /// This is used by the `lastCallGas` cheatcode. + pub last_call_gas: Option, } impl GasMetering { @@ -230,10 +237,18 @@ impl GasMetering { pub fn resume(&mut self) { if self.paused { self.paused = false; - self.resumed = true; + self.touched = true; } self.paused_frames.clear(); } + + /// Reset gas to limit. + pub fn reset(&mut self) { + self.paused = false; + self.touched = true; + self.reset = true; + self.paused_frames.clear(); + } } /// List of transactions that can be broadcasted. @@ -264,7 +279,7 @@ pub struct Cheatcodes { /// execution block environment. pub block: Option, - /// The gas price + /// The gas price. /// /// Used in the cheatcode handler to overwrite the gas price separately from the gas price /// in the execution environment. @@ -295,10 +310,6 @@ pub struct Cheatcodes { /// Recorded logs pub recorded_logs: Option>, - /// Cache of the amount of gas used in previous call. - /// This is used by the `lastCallGas` cheatcode. - pub last_call_gas: Option, - /// Mocked calls // **Note**: inner must a BTreeMap because of special `Ord` impl for `MockCallDataContext` pub mocked_calls: HashMap>, @@ -377,7 +388,6 @@ impl Cheatcodes { accesses: Default::default(), recorded_account_diffs_stack: Default::default(), recorded_logs: Default::default(), - last_call_gas: Default::default(), mocked_calls: Default::default(), expected_calls: Default::default(), expected_emits: Default::default(), @@ -994,11 +1004,16 @@ impl Inspector for Cheatcodes { fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { self.pc = interpreter.program_counter(); - // `pauseGasMetering`: reset interpreter gas. + // `pauseGasMetering`: pause / resume interpreter gas. if self.gas_metering.paused { self.meter_gas(interpreter); } + // `resetGasMetering`: reset interpreter gas. + if self.gas_metering.reset { + self.meter_gas_reset(interpreter); + } + // `record`: record storage reads and writes. if self.accesses.is_some() { self.record_accesses(interpreter); @@ -1026,7 +1041,7 @@ impl Inspector for Cheatcodes { self.meter_gas_end(interpreter); } - if self.gas_metering.resumed { + if self.gas_metering.touched { self.meter_gas_check(interpreter); } } @@ -1143,7 +1158,7 @@ impl Inspector for Cheatcodes { // Record the gas usage of the call, this allows the `lastCallGas` cheatcode to // retrieve the gas usage of the last call. let gas = outcome.result.gas; - self.last_call_gas = Some(crate::Vm::Gas { + self.gas_metering.last_call_gas = Some(crate::Vm::Gas { gasLimit: gas.limit(), gasTotalUsed: gas.spent(), gasMemoryUsed: 0, @@ -1406,15 +1421,22 @@ impl Cheatcodes { } } + #[cold] + fn meter_gas_reset(&mut self, interpreter: &mut Interpreter) { + interpreter.gas = Gas::new(interpreter.gas().limit()); + self.gas_metering.reset = false; + } + #[cold] fn meter_gas_check(&mut self, interpreter: &mut Interpreter) { if will_exit(interpreter.instruction_result) { - // Reconcile gas if spent is less than refunded. - // This can happen if gas was paused / resumed (https://github.com/foundry-rs/foundry/issues/4370). + // 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() { - interpreter.gas = Gas::new(interpreter.gas.remaining()); + interpreter.gas = Gas::new(interpreter.gas.limit()); } } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 37e1895f65373..c2cf46f8fac62 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1390,7 +1390,7 @@ contract ATest is Test { cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" ... -[PASS] test_negativeGas() (gas: 3252) +[PASS] test_negativeGas() (gas: 0) ... "#]]); }); @@ -1481,3 +1481,123 @@ Traces: ... "#]]); }); + +forgetest_init!(gas_metering_reset, |prj, cmd| { + prj.wipe_contracts(); + prj.insert_ds_test(); + prj.insert_vm(); + prj.clear(); + + prj.add_source( + "ATest.t.sol", + r#"pragma solidity 0.8.24; +import {Vm} from "./Vm.sol"; +import {DSTest} from "./test.sol"; +contract B { + function a() public returns (uint256) { + return 100; + } +} +contract ATest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + B b; + uint256 a; + + function testResetGas() public { + vm.resetGasMetering(); + } + + function testResetGas1() public { + vm.resetGasMetering(); + b = new B(); + vm.resetGasMetering(); + } + + function testResetGas2() public { + b = new B(); + b = new B(); + vm.resetGasMetering(); + } + + function testResetGas3() public { + vm.resetGasMetering(); + b = new B(); + b = new B(); + } + + function testResetGas4() public { + vm.resetGasMetering(); + b = new B(); + vm.resetGasMetering(); + b = new B(); + } + + function testResetGas5() public { + vm.resetGasMetering(); + b = new B(); + vm.resetGasMetering(); + b = new B(); + vm.resetGasMetering(); + } + + function testResetGas6() public { + vm.resetGasMetering(); + b = new B(); + b = new B(); + _reset(); + vm.resetGasMetering(); + } + + function testResetGas7() public { + vm.resetGasMetering(); + b = new B(); + b = new B(); + _reset(); + } + + function testResetGas8() public { + this.resetExternal(); + } + + function testResetGas9() public { + this.resetExternal(); + vm.resetGasMetering(); + } + + function testResetNegativeGas() public { + a = 100; + vm.resetGasMetering(); + + delete a; + } + + function _reset() internal { + vm.resetGasMetering(); + } + + function resetExternal() external { + b = new B(); + b = new B(); + vm.resetGasMetering(); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" +... +[PASS] testResetGas() (gas: 40) +[PASS] testResetGas1() (gas: 40) +[PASS] testResetGas2() (gas: 40) +[PASS] testResetGas3() (gas: 134476) +[PASS] testResetGas4() (gas: 56302) +[PASS] testResetGas5() (gas: 40) +[PASS] testResetGas6() (gas: 40) +[PASS] testResetGas7() (gas: 49) +[PASS] testResetGas8() (gas: 622) +[PASS] testResetGas9() (gas: 40) +[PASS] testResetNegativeGas() (gas: 0) +... +"#]]); +}); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 8ce2ce5fece5c..44caa5933677a 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -346,6 +346,7 @@ interface Vm { 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 resetGasMetering() external; function resetNonce(address account) external; function resumeGasMetering() external; function resumeTracing() external view; From 995a4d089581c489f9e616b133b7a140f55fd6b4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:44:07 +0200 Subject: [PATCH 1393/1963] chore(deps): midweek bumps (#8757) --- Cargo.lock | 102 ++++++++++++++++++++++------------------------------- 1 file changed, 42 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9278cf751c4a2..4dce9a826571e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.27" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b515e82c8468ddb6ff8db21c78a5997442f113fd8471fd5b2261b2602dd0c67" +checksum = "bb07629a5d0645d29f68d2fb6f4d0cf15c89ec0965be915f303967180929743f" dependencies = [ "num_enum", "serde", @@ -134,7 +134,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -603,7 +603,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" dependencies = [ "serde", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -1751,9 +1751,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd4c6dcc3b0aea2f5c0b4b82c2b15fe39ddbc76041a310848f4706edf76bb31" +checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" [[package]] name = "byteorder" @@ -1803,15 +1803,16 @@ dependencies = [ [[package]] name = "c-kzg" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf100c4cea8f207e883ff91ca886d621d8a166cb04971dfaa9bb8fd99ed95df" +checksum = "f0307f72feab3300336fb803a57134159f6e20139af1357f36c54cb90d8e8928" dependencies = [ "blst", "cc", "glob", "hex", "libc", + "once_cell", "serde", ] @@ -1929,9 +1930,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.14" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ "jobserver", "libc", @@ -2071,9 +2072,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531d7959c5bbb6e266cecdd0f20213639c3a5c3e4d615f97db87661745f781ff" +checksum = "6d7db6eca8c205649e8d3ccd05aa5042b1800a784e56bc7c43524fde8abbfa9b" dependencies = [ "clap", ] @@ -3361,7 +3362,7 @@ dependencies = [ "tikv-jemallocator", "tokio", "toml 0.8.19", - "toml_edit 0.22.20", + "toml_edit", "tower-http", "tracing", "tracing-subscriber", @@ -3516,9 +3517,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3306c1dfb236a3f7c86f7f6c9a88843d621cea96add97fdefbdc53ef3ecf6dfe" +checksum = "c1580bdb99a6a531b44ac5cda229069cacc11ae7d54faa45676e1bee9ee7da1c" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3723,7 +3724,7 @@ dependencies = [ "thiserror", "tokio", "tracing", - "winnow 0.6.18", + "winnow", "yansi", ] @@ -3829,7 +3830,7 @@ dependencies = [ "tempfile", "thiserror", "toml 0.8.19", - "toml_edit 0.22.20", + "toml_edit", "tracing", "walkdir", ] @@ -4316,7 +4317,7 @@ dependencies = [ "gix-utils", "itoa", "thiserror", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -4337,7 +4338,7 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -4439,7 +4440,7 @@ dependencies = [ "itoa", "smallvec", "thiserror", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -4474,7 +4475,7 @@ dependencies = [ "gix-validate", "memmap2", "thiserror", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -6532,9 +6533,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a909e6e8053fa1a5ad670f5816c7d93029ee1fa8898718490544a6b0d5d38b3e" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", "syn 2.0.76", @@ -6565,11 +6566,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.21.1", + "toml_edit", ] [[package]] @@ -6879,9 +6880,9 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba6a365afbe5615999275bea2446b970b10a41102500e27ce7678d50d978303" +checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" dependencies = [ "bitflags 2.6.0", "cassowary", @@ -7316,7 +7317,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.7", "subtle", "zeroize", ] @@ -7383,9 +7384,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.102.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" dependencies = [ "ring", "rustls-pki-types", @@ -8047,7 +8048,7 @@ dependencies = [ "sha2", "thiserror", "tokio", - "toml_edit 0.22.20", + "toml_edit", "uuid 1.10.0", "yansi", "zip 2.2.0", @@ -8151,9 +8152,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b638fb4b6a74ef632a18935d240596b2618c8eb5c888e9cbf3c689af9a4aded" +checksum = "00d3230221bec82c4a79cd7af637ac29f04f369e95e476bc492f22882bb83c91" dependencies = [ "const-hex", "dirs 5.0.1", @@ -8163,6 +8164,7 @@ dependencies = [ "serde", "serde_json", "sha2", + "tempfile", "thiserror", "url", "zip 2.2.0", @@ -8170,9 +8172,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "813b21b9858cc493134b899c96e73c60f2e6043f050a17020e98ad8c2d9c9912" +checksum = "83fe4ebbe1038a5a517a07948c2487b3ccf79a4908953cc8f0047cf652233546" dependencies = [ "build_const", "const-hex", @@ -8570,7 +8572,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -8582,17 +8584,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.4.0", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.20" @@ -8603,14 +8594,14 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.18", + "winnow", ] [[package]] name = "tonic" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", @@ -9608,15 +9599,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "0.6.18" From 2442e7a5fc165d7d0b022aa8b9f09dcdf675157b Mon Sep 17 00:00:00 2001 From: Pranesh A S <42379522+PraneshASP@users.noreply.github.com> Date: Tue, 27 Aug 2024 23:18:20 +0530 Subject: [PATCH 1394/1963] feat(`forge selectors`): add `find` command (#8754) * feat: add find selectors cmd * chore: throw error --- crates/forge/bin/cmd/selectors.rs | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index c1626e99fc7af..04d19295c69cd 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -56,6 +56,17 @@ pub enum SelectorsSubcommands { #[command(flatten)] project_paths: ProjectPathsArgs, }, + + /// Find if a selector is present in the project + #[command(visible_alias = "f")] + Find { + /// The selector to search for + #[arg(help = "The selector to search for (with or without 0x prefix)")] + selector: String, + + #[command(flatten)] + project_paths: ProjectPathsArgs, + }, } impl SelectorsSubcommands { @@ -260,6 +271,83 @@ impl SelectorsSubcommands { } } } + + Self::Find { selector, project_paths } => { + println!("Searching for selector {selector:?} in the project..."); + + let build_args = CoreBuildArgs { + project_paths, + compiler: CompilerArgs { + extra_output: vec![ContractOutputSelection::Abi], + ..Default::default() + }, + ..Default::default() + }; + + let project = build_args.project()?; + let outcome = ProjectCompiler::new().quiet(true).compile(&project)?; + let artifacts = outcome + .into_artifacts_with_files() + .filter(|(file, _, _)| { + let is_sources_path = file.starts_with(&project.paths.sources); + let is_test = file.is_sol_test(); + is_sources_path && !is_test + }) + .collect::>(); + + let mut table = Table::new(); + + table.set_header(["Type", "Signature", "Selector", "Contract"]); + + for (_file, contract, artifact) in artifacts { + let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?; + + let selector_bytes = + hex::decode(selector.strip_prefix("0x").unwrap_or(&selector))?; + + for func in abi.functions() { + if func.selector().as_slice().starts_with(selector_bytes.as_slice()) { + table.add_row([ + "Function", + &func.signature(), + &hex::encode_prefixed(func.selector()), + contract.as_str(), + ]); + } + } + + for event in abi.events() { + if event.selector().as_slice().starts_with(selector_bytes.as_slice()) { + table.add_row([ + "Event", + &event.signature(), + &hex::encode_prefixed(event.selector()), + contract.as_str(), + ]); + } + } + + for error in abi.errors() { + if error.selector().as_slice().starts_with(selector_bytes.as_slice()) { + table.add_row([ + "Event", + &error.signature(), + &hex::encode_prefixed(error.selector()), + contract.as_str(), + ]); + } + } + } + + if table.row_count() > 0 { + println!(); + println!("Found {} instance(s)...", table.row_count()); + println!("{table}"); + } else { + println!(); + return Err(eyre::eyre!("Selector not found in the project.")); + } + } } Ok(()) } From e0aeef918e03fcfa3a06e5bd4739a371856d4ee1 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:54:45 +0300 Subject: [PATCH 1395/1963] fix(fmt): `params_first_multi` split if more than one param (#8762) feat(fmt): params_first_multi split if more than one param --- crates/config/src/fmt.rs | 8 +- crates/fmt/src/formatter.rs | 13 +- .../testdata/FunctionDefinition/all.fmt.sol | 4 +- .../FunctionDefinition/params-first.fmt.sol | 8 +- .../FunctionDefinition/params-multi.fmt.sol | 710 ++++++++++++++++++ 5 files changed, 732 insertions(+), 11 deletions(-) create mode 100644 crates/fmt/testdata/FunctionDefinition/params-multi.fmt.sol diff --git a/crates/config/src/fmt.rs b/crates/config/src/fmt.rs index e1ebf720765bc..44fefe7d469e8 100644 --- a/crates/config/src/fmt.rs +++ b/crates/config/src/fmt.rs @@ -153,11 +153,13 @@ pub enum SingleLineBlockStyle { #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum MultilineFuncHeaderStyle { - /// Write function parameters multiline first + /// Write function parameters multiline first. ParamsFirst, - /// Write function attributes multiline first + /// Write function parameters multiline first when there is more than one param. + ParamsFirstMulti, + /// Write function attributes multiline first. AttributesFirst, - /// If function params or attrs are multiline + /// If function params or attrs are multiline. /// split the rest All, } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 396348201042b..1c5000330f4b9 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1617,7 +1617,9 @@ impl<'a, W: Write> Formatter<'a, W> { let should_multiline = header_multiline && matches!( fmt.config.multiline_func_header, - MultilineFuncHeaderStyle::ParamsFirst | MultilineFuncHeaderStyle::All + MultilineFuncHeaderStyle::ParamsFirst | + MultilineFuncHeaderStyle::ParamsFirstMulti | + MultilineFuncHeaderStyle::All ); params_multiline = should_multiline || multiline || @@ -1626,8 +1628,13 @@ impl<'a, W: Write> Formatter<'a, W> { ¶ms, ",", )?; - // Write new line if we have only one parameter and params on multiline set. - if params.len() == 1 && params_multiline { + // Write new line if we have only one parameter and params first set. + if params.len() == 1 && + matches!( + fmt.config.multiline_func_header, + MultilineFuncHeaderStyle::ParamsFirst + ) + { writeln!(fmt.buf())?; } fmt.write_chunks_separated(¶ms, ",", params_multiline)?; diff --git a/crates/fmt/testdata/FunctionDefinition/all.fmt.sol b/crates/fmt/testdata/FunctionDefinition/all.fmt.sol index 86577d44b3b81..6d90880679199 100644 --- a/crates/fmt/testdata/FunctionDefinition/all.fmt.sol +++ b/crates/fmt/testdata/FunctionDefinition/all.fmt.sol @@ -717,9 +717,7 @@ contract FunctionOverrides is a = 1; } - function oneParam( - uint256 x - ) + function oneParam(uint256 x) override( FunctionInterfaces, FunctionDefinitions, diff --git a/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol b/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol index 8208c15d21fc3..3e7ebfff6b3aa 100644 --- a/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol +++ b/crates/fmt/testdata/FunctionDefinition/params-first.fmt.sol @@ -3,7 +3,9 @@ interface FunctionInterfaces { function noParamsNoModifiersNoReturns(); - function oneParam(uint256 x); + function oneParam( + uint256 x + ); function oneModifier() modifier1; @@ -335,7 +337,9 @@ contract FunctionDefinitions { a = 1; } - function oneParam(uint256 x) { + function oneParam( + uint256 x + ) { a = 1; } diff --git a/crates/fmt/testdata/FunctionDefinition/params-multi.fmt.sol b/crates/fmt/testdata/FunctionDefinition/params-multi.fmt.sol new file mode 100644 index 0000000000000..cd2015c9e050e --- /dev/null +++ b/crates/fmt/testdata/FunctionDefinition/params-multi.fmt.sol @@ -0,0 +1,710 @@ +// config: line_length = 60 +// config: multiline_func_header = "params_first_multi" +interface FunctionInterfaces { + function noParamsNoModifiersNoReturns(); + + function oneParam(uint256 x); + + function oneModifier() modifier1; + + function oneReturn() returns (uint256 y1); + + // function prefix + function withComments( // function name postfix + // x1 prefix + uint256 x1, // x1 postfix + // x2 prefix + uint256 x2, // x2 postfix + // x2 postfix2 + /* + multi-line x3 prefix + */ + uint256 x3 // x3 postfix + ) + // public prefix + public // public postfix + // pure prefix + pure // pure postfix + // modifier1 prefix + modifier1 // modifier1 postfix + // modifier2 prefix + modifier2 /* + mutliline modifier2 postfix + */ + // modifier3 prefix + modifier3 // modifier3 postfix + returns ( + // y1 prefix + uint256 y1, // y1 postfix + // y2 prefix + uint256 y2, // y2 postfix + // y3 prefix + uint256 y3 + ); // y3 postfix + // function postfix + + /*////////////////////////////////////////////////////////////////////////// + TEST + //////////////////////////////////////////////////////////////////////////*/ + function manyParams( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ); + + function manyModifiers() + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10; + + function manyReturns() + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function someParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) modifier1 modifier2 modifier3; + + function someParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) returns (uint256 y1, uint256 y2, uint256 y3); + + function someModifiersSomeReturns() + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3); + + function someParamSomeModifiersSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3); + + function someParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10; + + function someParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function manyParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) modifier1 modifier2 modifier3; + + function manyParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) returns (uint256 y1, uint256 y2, uint256 y3); + + function manyParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10; + + function manyParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function manyParamsManyModifiersManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function modifierOrderCorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderCorrect02() + private + pure + virtual + modifier1 + modifier2 + returns (string); + + function modifierOrderCorrect03() + external + payable + override + modifier1 + modifier2 + returns (address); + + function modifierOrderCorrect04() + internal + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect02() + external + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect03() + internal + pure + virtual + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect04() + external + payable + override + modifier1 + modifier2 + returns (uint256); +} + +contract FunctionDefinitions { + function() external {} + fallback() external {} + + function() external payable {} + fallback() external payable {} + receive() external payable {} + + function noParamsNoModifiersNoReturns() { + a = 1; + } + + function oneParam(uint256 x) { + a = 1; + } + + function oneModifier() modifier1 { + a = 1; + } + + function oneReturn() returns (uint256 y1) { + a = 1; + } + + function manyParams( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) { + a = 1; + } + + function manyModifiers() + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + { + a = 1; + } + + function manyReturns() + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function someParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) modifier1 modifier2 modifier3 { + a = 1; + } + + function someParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) returns (uint256 y1, uint256 y2, uint256 y3) { + a = 1; + } + + function someModifiersSomeReturns() + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3) + { + a = 1; + } + + function someParamSomeModifiersSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3) + { + a = 1; + } + + function someParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + { + a = 1; + } + + function someParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function manyParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) modifier1 modifier2 modifier3 { + a = 1; + } + + function manyParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) returns (uint256 y1, uint256 y2, uint256 y3) { + a = 1; + } + + function manyParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + public + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + { + a = 1; + } + + function manyParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function manyParamsManyModifiersManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function modifierOrderCorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderCorrect02() + private + pure + virtual + modifier1 + modifier2 + returns (string) + { + a = 1; + } + + function modifierOrderCorrect03() + external + payable + override + modifier1 + modifier2 + returns (address) + { + a = 1; + } + + function modifierOrderCorrect04() + internal + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect02() + external + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect03() + internal + pure + virtual + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect04() + external + payable + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + fallback() external payable virtual {} + receive() external payable virtual {} +} + +contract FunctionOverrides is + FunctionInterfaces, + FunctionDefinitions +{ + function noParamsNoModifiersNoReturns() override { + a = 1; + } + + function oneParam(uint256 x) + override( + FunctionInterfaces, + FunctionDefinitions, + SomeOtherFunctionContract, + SomeImport.AndAnotherFunctionContract + ) + { + a = 1; + } +} From aa3b189cf8c59c40ec6616e70fa2c1e0dfe968fb Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:58:20 +0300 Subject: [PATCH 1396/1963] fix(cheatcodes): decode custom error in expectRevert (#8753) --- crates/cheatcodes/src/inspector.rs | 2 ++ crates/cheatcodes/src/test/expect.rs | 34 ++++++++++++-------- crates/forge/tests/cli/test_cmd.rs | 46 ++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 8e2331cf17830..08aef103dd4ae 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -644,6 +644,7 @@ impl Cheatcodes { expected_revert.reason.as_deref(), outcome.result.result, outcome.result.output.clone(), + &self.config.available_artifacts, ) { Ok((address, retdata)) => { outcome.result.result = InstructionResult::Return; @@ -1124,6 +1125,7 @@ impl Inspector for Cheatcodes { expected_revert.reason.as_deref(), outcome.result.result, outcome.result.output.clone(), + &self.config.available_artifacts, ) { Err(error) => { trace!(expected=?expected_revert, ?error, status=?outcome.result.result, "Expected revert mismatch"); diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 4592f6367c0ec..be2aeca54c495 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,6 +1,8 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result, Vm::*}; use alloy_primitives::{address, hex, Address, Bytes, LogData as RawLog, U256}; use alloy_sol_types::{SolError, SolValue}; +use foundry_common::ContractsByArtifact; +use foundry_evm_core::decode::RevertDecoder; use revm::interpreter::{ return_ok, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }; @@ -561,6 +563,7 @@ pub(crate) fn handle_expect_revert( expected_revert: Option<&[u8]>, status: InstructionResult, retdata: Bytes, + known_contracts: &Option, ) -> Result<(Option
, Bytes)> { let success_return = || { if is_create { @@ -598,20 +601,25 @@ pub(crate) fn handle_expect_revert( { Ok(success_return()) } else { - let stringify = |data: &[u8]| { - if let Ok(s) = String::abi_decode(data, true) { - return s; - } - if data.is_ascii() { - return std::str::from_utf8(data).unwrap().to_owned(); - } - hex::encode_prefixed(data) + let (actual, expected) = if let Some(contracts) = known_contracts { + let decoder = RevertDecoder::new().with_abis(contracts.iter().map(|(_, c)| &c.abi)); + ( + &decoder.decode(actual_revert.as_slice(), Some(status)), + &decoder.decode(expected_revert, Some(status)), + ) + } else { + let stringify = |data: &[u8]| { + if let Ok(s) = String::abi_decode(data, true) { + return s; + } + if data.is_ascii() { + return std::str::from_utf8(data).unwrap().to_owned(); + } + hex::encode_prefixed(data) + }; + (&stringify(&actual_revert), &stringify(expected_revert)) }; - Err(fmt_err!( - "Error != expected error: {} != {}", - stringify(&actual_revert), - stringify(expected_revert), - )) + Err(fmt_err!("Error != expected error: {} != {}", actual, expected,)) } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index c2cf46f8fac62..94775d01a84ca 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1601,3 +1601,49 @@ contract ATest is DSTest { ... "#]]); }); + +// https://github.com/foundry-rs/foundry/issues/8705 +forgetest_init!(test_expect_revert_decode, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "Counter.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; +contract Counter { + uint256 public number; + error NumberNotEven(uint256 number); + error RandomError(); + function setNumber(uint256 newNumber) public { + if (newNumber % 2 != 0) { + revert NumberNotEven(newNumber); + } + number = newNumber; + } +} +contract CounterTest is Test { + Counter public counter; + function setUp() public { + counter = new Counter(); + counter.setNumber(0); + } + function test_decode() public { + vm.expectRevert(Counter.RandomError.selector); + counter.setNumber(1); + } + function test_decode_with_args() public { + vm.expectRevert(abi.encodePacked(Counter.NumberNotEven.selector, uint(2))); + counter.setNumber(1); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" +... +[FAIL. Reason: Error != expected error: NumberNotEven(1) != RandomError()] test_decode() ([GAS]) +[FAIL. Reason: Error != expected error: NumberNotEven(1) != NumberNotEven(2)] test_decode_with_args() ([GAS]) +... +"#]]); +}); From 327e29e3f3cb6492e33c43b1cdb1b923620ccb2f Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:29:58 +0300 Subject: [PATCH 1397/1963] feat(cheatcodes): add expectPartialRevert cheatcode (#8763) --- crates/cheatcodes/assets/cheatcodes.json | 22 +++++++++- crates/cheatcodes/spec/src/vm.rs | 6 ++- crates/cheatcodes/src/inspector.rs | 2 + crates/cheatcodes/src/test/expect.rs | 55 +++++++++++++++++++----- crates/forge/tests/cli/test_cmd.rs | 49 +++++++++++++++++++++ testdata/cheats/Vm.sol | 1 + 6 files changed, 123 insertions(+), 12 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 03755f4e6a01a..574d310ca19fc 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4711,6 +4711,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "expectPartialRevert", + "description": "Expects an error on next call that starts with the revert data.", + "declaration": "function expectPartialRevert(bytes4 revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "expectPartialRevert(bytes4)", + "selector": "0x11fb5b9c", + "selectorBytes": [ + 17, + 251, + 91, + 156 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "expectRevert_0", @@ -4734,7 +4754,7 @@ { "func": { "id": "expectRevert_1", - "description": "Expects an error on next call that starts with the revert data.", + "description": "Expects an error on next call that exactly matches the revert data.", "declaration": "function expectRevert(bytes4 revertData) external;", "visibility": "external", "mutability": "", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 1a092176d44af..575ccfa84a5a7 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -791,7 +791,7 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectRevert() external; - /// Expects an error on next call that starts with the revert data. + /// Expects an error on next call that exactly matches the revert data. #[cheatcode(group = Testing, safety = Unsafe)] function expectRevert(bytes4 revertData) external; @@ -799,6 +799,10 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectRevert(bytes calldata revertData) external; + /// Expects an error on next call that starts with the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectPartialRevert(bytes4 revertData) external; + /// Expects an error on next cheatcode call with any revert data. #[cheatcode(group = Testing, safety = Unsafe, status = Internal)] function _expectCheatcodeRevert() external; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 08aef103dd4ae..1ff2a6e999dcc 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -642,6 +642,7 @@ impl Cheatcodes { false, true, expected_revert.reason.as_deref(), + expected_revert.partial_match, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, @@ -1123,6 +1124,7 @@ impl Inspector for Cheatcodes { cheatcode_call, false, expected_revert.reason.as_deref(), + expected_revert.partial_match, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index be2aeca54c495..83899041515dd 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -72,12 +72,14 @@ pub enum ExpectedRevertKind { #[derive(Clone, Debug)] pub struct ExpectedRevert { - /// The expected data returned by the revert, None being any + /// The expected data returned by the revert, None being any. pub reason: Option>, - /// The depth at which the revert is expected + /// The depth at which the revert is expected. pub depth: u64, /// The type of expected revert. pub kind: ExpectedRevertKind, + /// If true then only the first 4 bytes of expected data returned by the revert are checked. + pub partial_match: bool, } #[derive(Clone, Debug)] @@ -286,41 +288,66 @@ impl Cheatcode for expectEmitAnonymous_3Call { impl Cheatcode for expectRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false, false) } } impl Cheatcode for expectRevert_1Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData.as_ref()), ccx.ecx.journaled_state.depth(), false) + expect_revert( + ccx.state, + Some(revertData.as_ref()), + ccx.ecx.journaled_state.depth(), + false, + false, + ) } } impl Cheatcode for expectRevert_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), false) + expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), false, false) + } +} + +impl Cheatcode for expectPartialRevertCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData } = self; + expect_revert( + ccx.state, + Some(revertData.as_ref()), + ccx.ecx.journaled_state.depth(), + false, + true, + ) } } impl Cheatcode for _expectCheatcodeRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true, false) } } impl Cheatcode for _expectCheatcodeRevert_1Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData.as_ref()), ccx.ecx.journaled_state.depth(), true) + expect_revert( + ccx.state, + Some(revertData.as_ref()), + ccx.ecx.journaled_state.depth(), + true, + false, + ) } } impl Cheatcode for _expectCheatcodeRevert_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), true) + expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), true, false) } } @@ -540,6 +567,7 @@ fn expect_revert( reason: Option<&[u8]>, depth: u64, cheatcode: bool, + partial_match: bool, ) -> Result { ensure!( state.expected_revert.is_none(), @@ -553,6 +581,7 @@ fn expect_revert( } else { ExpectedRevertKind::Default }, + partial_match, }); Ok(Default::default()) } @@ -561,6 +590,7 @@ pub(crate) fn handle_expect_revert( is_cheatcode: bool, is_create: bool, expected_revert: Option<&[u8]>, + partial_match: bool, status: InstructionResult, retdata: Bytes, known_contracts: &Option, @@ -575,7 +605,7 @@ pub(crate) fn handle_expect_revert( ensure!(!matches!(status, return_ok!()), "next call did not revert as expected"); - // If None, accept any revert + // If None, accept any revert. let Some(expected_revert) = expected_revert else { return Ok(success_return()); }; @@ -586,7 +616,12 @@ pub(crate) fn handle_expect_revert( let mut actual_revert: Vec = retdata.into(); - // Try decoding as known errors + // Compare only the first 4 bytes if partial match. + if partial_match && actual_revert.get(..4) == expected_revert.get(..4) { + return Ok(success_return()) + } + + // Try decoding as known errors. if matches!( actual_revert.get(..4).map(|s| s.try_into().unwrap()), Some(Vm::CheatcodeError::SELECTOR | alloy_sol_types::Revert::SELECTOR) diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 94775d01a84ca..391de7a28d6c3 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1647,3 +1647,52 @@ contract CounterTest is Test { ... "#]]); }); + +// Tests that `expectPartialRevert` cheatcode partially matches revert data. +forgetest_init!(test_expect_partial_revert, |prj, cmd| { + prj.wipe_contracts(); + prj.insert_ds_test(); + prj.insert_vm(); + prj.clear(); + + prj.add_source( + "Counter.t.sol", + r#"pragma solidity 0.8.24; +import {Vm} from "./Vm.sol"; +import {DSTest} from "./test.sol"; +contract Counter { + error WrongNumber(uint256 number); + function count() public pure { + revert WrongNumber(0); + } +} +contract CounterTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + function testExpectPartialRevertWithSelector() public { + Counter counter = new Counter(); + vm.expectPartialRevert(Counter.WrongNumber.selector); + counter.count(); + } + function testExpectPartialRevertWith4Bytes() public { + Counter counter = new Counter(); + vm.expectPartialRevert(bytes4(0x238ace70)); + counter.count(); + } + function testExpectRevert() public { + Counter counter = new Counter(); + vm.expectRevert(Counter.WrongNumber.selector); + counter.count(); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" +... +[PASS] testExpectPartialRevertWith4Bytes() ([GAS]) +[PASS] testExpectPartialRevertWithSelector() ([GAS]) +[FAIL. Reason: Error != expected error: WrongNumber(0) != custom error 238ace70:] testExpectRevert() ([GAS]) +... +"#]]); +}); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 44caa5933677a..b929053dac012 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -231,6 +231,7 @@ interface Vm { 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; function expectRevert() external; function expectRevert(bytes4 revertData) external; function expectRevert(bytes calldata revertData) external; From 0d8302880b79fa9c3c4aa52ab446583dece19a34 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:59:31 +0200 Subject: [PATCH 1398/1963] feat: snapbox migration (#8728) * test basic flow * establish required test list by build errors * experiment with abstractions * basic test with stderr * move over the stderr lossy tests * add `get_stdout_lossy` helper * TestCommand will require a cleanup to route as much through Snapbox as possible, including execute and assertions * fix placeholder redacts * move tests * update tests * fix tests * improve tests * continue * continue * clean up * clean up * match against "Updating dependencies in" * fix broken tests, make sure to clear consistently to force recompilation where expected * port more tests * additional tests * more tests * clean up * avoid unnecessary fuse * fix malformed test + full output comparison asserting specific layout, not negative assertion * access list ordering is not consistent * enforce block layout * use stdout_eq file with relative path as dynamic joined CARGO_MANIFEST_DIR does not work * continue migrating tests * more tests * more tests * improve tests * restore test * replace stdout_lossy, unify access * replace more lossy stdout tests * continue porting tests * more tests * clean up * use redactions for scripts, enforce stricter regex * start porting more tests using undesired helpers * remove assert_non_empty_stdout helper, enforce stdout layouts * use snapbox inside of helpers * replace cmd.execute * fix CI tests * soldeer has inconsistent spelling for some reason * attempt fix flaky test * no idea why soldeer is so spotty * make tests more robust, redact "Compiling N files" with [COMPILING_FILES] --- Cargo.lock | 2 - crates/cast/tests/cli/main.rs | 842 ++++++++++++++++++----------- crates/forge/benches/test.rs | 9 +- crates/forge/tests/cli/build.rs | 16 +- crates/forge/tests/cli/cmd.rs | 758 ++++++++++++++++++-------- crates/forge/tests/cli/config.rs | 151 ++++-- crates/forge/tests/cli/create.rs | 58 +- crates/forge/tests/cli/debug.rs | 13 +- crates/forge/tests/cli/script.rs | 727 ++++++++++++++++++++----- crates/forge/tests/cli/soldeer.rs | 56 +- crates/forge/tests/cli/svm.rs | 15 +- crates/forge/tests/cli/test_cmd.rs | 264 ++++++--- crates/forge/tests/cli/verify.rs | 62 ++- crates/test-utils/Cargo.toml | 2 - crates/test-utils/src/macros.rs | 2 +- crates/test-utils/src/script.rs | 6 +- crates/test-utils/src/util.rs | 368 ++----------- crates/verify/src/etherscan/mod.rs | 9 +- 18 files changed, 2205 insertions(+), 1155 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4dce9a826571e..4b71c523ea174 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4055,11 +4055,9 @@ dependencies = [ "rand", "regex", "serde_json", - "similar-asserts", "snapbox", "tracing", "tracing-subscriber", - "walkdir", ] [[package]] diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 6ef092cb1e717..8ece9ef65dedf 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,10 +1,10 @@ //! Contains various tests for checking cast commands use alloy_chains::NamedChain; -use alloy_primitives::{address, b256, Address, B256}; +use alloy_primitives::{b256, B256}; use anvil::{Hardfork, NodeConfig}; use foundry_test_utils::{ - casttest, + casttest, file, rpc::{next_http_rpc_endpoint, next_rpc_endpoint, next_ws_rpc_endpoint}, str, util::OutputExt, @@ -13,8 +13,21 @@ use std::{fs, io::Write, path::Path, str::FromStr}; // tests `--help` is printed to std out casttest!(print_help, |_prj, cmd| { - cmd.arg("--help"); - cmd.assert_non_empty_stdout(); + cmd.arg("--help").assert_success().stdout_eq(str![[r#" +Perform Ethereum RPC calls from the comfort of your command line + +Usage: cast[..] + +Commands: +... + +Options: + -h, --help Print help + -V, --version Print version + +Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html + +"#]]); }); // tests that the `cast block` command works correctly @@ -23,14 +36,41 @@ casttest!(latest_block, |_prj, cmd| { // Call `cast find-block` cmd.args(["block", "latest", "--rpc-url", eth_rpc_url.as_str()]); - let output = cmd.stdout_lossy(); - assert!(output.contains("transactions:")); - assert!(output.contains("gasUsed")); + cmd.assert_success().stdout_eq(str![[r#" + + +baseFeePerGas [..] +difficulty [..] +extraData [..] +gasLimit [..] +gasUsed [..] +hash [..] +logsBloom [..] +miner [..] +mixHash [..] +nonce [..] +number [..] +parentHash [..] +transactionsRoot [..] +receiptsRoot [..] +sha3Uncles [..] +size [..] +stateRoot [..] +timestamp [..] +withdrawalsRoot [..] +totalDifficulty [..] +transactions: [ +... +] + +"#]]); // cmd.cast_fuse().args(["block", "15007840", "-f", "hash", "--rpc-url", eth_rpc_url.as_str()]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0x950091817a57e22b6c1f3b951a15f52d41ac89b299cc8f9c89bb6d185f80c415") + cmd.assert_success().stdout_eq(str![[r#" +0x950091817a57e22b6c1f3b951a15f52d41ac89b299cc8f9c89bb6d185f80c415 + +"#]]); }); // tests that the `cast find-block` command works correctly @@ -40,23 +80,24 @@ casttest!(finds_block, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast find-block` - cmd.args(["find-block", "--rpc-url", eth_rpc_url.as_str(), ×tamp]); - let output = cmd.stdout_lossy(); - println!("{output}"); - - // Expect successful block query - // Query: 1647843609, Mar 21 2022 06:20:09 UTC - // Output block: https://etherscan.io/block/14428082 - // Output block time: Mar 21 2022 06:20:09 UTC - assert!(output.contains("14428082"), "{}", output); + // + cmd.args(["find-block", "--rpc-url", eth_rpc_url.as_str(), ×tamp]) + .assert_success() + .stdout_eq(str![[r#" +14428082 + +"#]]); }); // tests that we can create a new wallet with keystore casttest!(new_wallet_keystore_with_password, |_prj, cmd| { - cmd.args(["wallet", "new", ".", "--unsafe-password", "test"]); - let out = cmd.stdout_lossy(); - assert!(out.contains("Created new encrypted keystore file")); - assert!(out.contains("Address")); + cmd.args(["wallet", "new", ".", "--unsafe-password", "test"]).assert_success().stdout_eq(str![ + [r#" +Created new encrypted keystore file: [..] +[ADDRESS] + +"#] + ]); }); // tests that we can get the address of a keystore file @@ -73,9 +114,12 @@ casttest!(wallet_address_keystore_with_password_file, |_prj, cmd| { .unwrap(), "--password-file", keystore_dir.join("password-ec554").to_str().unwrap(), - ]); - let out = cmd.stdout_lossy(); - assert!(out.contains("0xeC554aeAFE75601AaAb43Bd4621A22284dB566C2")); + ]) + .assert_success() + .stdout_eq(str![[r#" +0xeC554aeAFE75601AaAb43Bd4621A22284dB566C2 + +"#]]); }); // tests that `cast wallet sign message` outputs the expected signature @@ -85,17 +129,29 @@ casttest!(wallet_sign_message_utf8_data, |_prj, cmd| { let msg = "test"; let expected = "0xfe28833983d6faa0715c7e8c3873c725ddab6fa5bf84d40e780676e463e6bea20fc6aea97dc273a98eb26b0914e224c8dd5c615ceaab69ddddcf9b0ae3de0e371c"; - cmd.args(["wallet", "sign", "--private-key", pk, msg]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), expected); + cmd.args(["wallet", "sign", "--private-key", pk, msg]).assert_success().stdout_eq(str![[r#" +0xfe28833983d6faa0715c7e8c3873c725ddab6fa5bf84d40e780676e463e6bea20fc6aea97dc273a98eb26b0914e224c8dd5c615ceaab69ddddcf9b0ae3de0e371c + +"#]]); // Success. cmd.cast_fuse() .args(["wallet", "verify", "-a", address, msg, expected]) - .assert_non_empty_stdout(); + .assert_success() + .stdout_eq(str![[r#" +Validation succeeded. Address 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf signed this message. + +"#]]); // Fail. - cmd.cast_fuse().args(["wallet", "verify", "-a", address, "other msg", expected]).assert_err(); + cmd.cast_fuse() + .args(["wallet", "verify", "-a", address, "other msg", expected]) + .assert_failure() + .stderr_eq(str![[r#" +Error: +Validation failed. Address 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf did not sign this message. + +"#]]); }); // tests that `cast wallet sign message` outputs the expected signature, given a 0x-prefixed data @@ -172,25 +228,74 @@ casttest!(wallet_list_local_accounts, |prj, cmd| { cmd.set_current_dir(prj.root()); // empty results - cmd.cast_fuse().args(["wallet", "list", "--dir", "keystore"]); - let list_output = cmd.stdout_lossy(); - assert!(list_output.is_empty()); + cmd.cast_fuse() + .args(["wallet", "list", "--dir", "keystore"]) + .assert_success() + .stdout_eq(str![""]); // create 10 wallets - cmd.cast_fuse().args(["wallet", "new", "keystore", "-n", "10", "--unsafe-password", "test"]); - cmd.stdout_lossy(); + cmd.cast_fuse() + .args(["wallet", "new", "keystore", "-n", "10", "--unsafe-password", "test"]) + .assert_success() + .stdout_eq(str![[r#" +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] +Created new encrypted keystore file: [..] +[ADDRESS] + +"#]]); // test list new wallet - cmd.cast_fuse().args(["wallet", "list", "--dir", "keystore"]); - let list_output = cmd.stdout_lossy(); - assert_eq!(list_output.matches('\n').count(), 10); + cmd.cast_fuse().args(["wallet", "list", "--dir", "keystore"]).assert_success().stdout_eq(str![ + [r#" +[..] (Local) +[..] (Local) +[..] (Local) +[..] (Local) +[..] (Local) +[..] (Local) +[..] (Local) +[..] (Local) +[..] (Local) +[..] (Local) + +"#] + ]); }); // tests that `cast wallet new-mnemonic --entropy` outputs the expected mnemonic casttest!(wallet_mnemonic_from_entropy, |_prj, cmd| { - cmd.args(["wallet", "new-mnemonic", "--entropy", "0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c"]); - let output = cmd.stdout_lossy(); - assert!(output.contains("test test test test test test test test test test test junk")); + cmd.args(["wallet", "new-mnemonic", "--entropy", "0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c"]) + .assert_success() + .stdout_eq(str![[r#" +Generating mnemonic from provided entropy... +Successfully generated a new mnemonic. +Phrase: +test test test test test test test test test test test junk + +Accounts: +- Account 0: +Address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Private key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 + + +"#]]); }); // tests that `cast wallet private-key` with arguments outputs the private key @@ -217,9 +322,12 @@ casttest!(wallet_private_key_from_mnemonic_option, |_prj, cmd| { "test test test test test test test test test test test junk", "--mnemonic-index", "1", - ]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"); + ]) + .assert_success() + .stdout_eq(str![[r#" +0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d + +"#]]); }); // tests that `cast wallet private-key` with derivation path outputs the private key @@ -231,9 +339,12 @@ casttest!(wallet_private_key_with_derivation_path, |_prj, cmd| { "test test test test test test test test test test test junk", "--mnemonic-derivation-path", "m/44'/60'/0'/0/1", - ]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"); + ]) + .assert_success() + .stdout_eq(str![[r#" +0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d + +"#]]); }); // tests that `cast wallet import` creates a keystore for a private key and that `cast wallet @@ -250,19 +361,23 @@ casttest!(wallet_import_and_decrypt, |prj, cmd| { b256!("ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"); // import private key - cmd.cast_fuse().args([ - "wallet", - "import", - account_name, - "--private-key", - &test_private_key.to_string(), - "-k", - "keystore", - "--unsafe-password", - "test", - ]); + cmd.cast_fuse() + .args([ + "wallet", + "import", + account_name, + "--private-key", + &test_private_key.to_string(), + "-k", + "keystore", + "--unsafe-password", + "test", + ]) + .assert_success() + .stdout_eq(str![[r#" +`testAccount` keystore was saved successfully. [ADDRESS] - cmd.assert_non_empty_stdout(); +"#]]); // check that the keystore file was created let keystore_file = keystore_path.join(account_name); @@ -281,7 +396,7 @@ casttest!(wallet_import_and_decrypt, |prj, cmd| { ]); // get the PK out of the output (last word in the output) - let decrypt_output = decrypt_output.stdout_lossy(); + let decrypt_output = decrypt_output.assert_success().get_output().stdout_lossy(); let private_key_string = decrypt_output.split_whitespace().last().unwrap(); // check that the decrypted private key matches the imported private key let decrypted_private_key = B256::from_str(private_key_string).unwrap(); @@ -292,18 +407,25 @@ casttest!(wallet_import_and_decrypt, |prj, cmd| { // tests that `cast estimate` is working correctly. casttest!(estimate_function_gas, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); - cmd.args([ - "estimate", - "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // vitalik.eth - "--value", - "100", - "deposit()", - "--rpc-url", - eth_rpc_url.as_str(), - ]); - let out: u32 = cmd.stdout_lossy().trim().parse().unwrap(); + // ensure we get a positive non-error value for gas estimate - assert!(out.ge(&0)); + let output: u32 = cmd + .args([ + "estimate", + "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // vitalik.eth + "--value", + "100", + "deposit()", + "--rpc-url", + eth_rpc_url.as_str(), + ]) + .assert_success() + .get_output() + .stdout_lossy() + .trim() + .parse() + .unwrap(); + assert!(output.ge(&0)); }); // tests that `cast estimate --create` is working correctly. @@ -311,41 +433,45 @@ casttest!(estimate_contract_deploy_gas, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // sample contract code bytecode. Wouldn't run but is valid bytecode that the estimate method // accepts and could be deployed. - cmd.args([ - "estimate", - "--rpc-url", - eth_rpc_url.as_str(), - "--create", - "0000", - "ERC20(uint256,string,string)", - "100", - "Test", - "TST", - ]); + let output = cmd + .args([ + "estimate", + "--rpc-url", + eth_rpc_url.as_str(), + "--create", + "0000", + "ERC20(uint256,string,string)", + "100", + "Test", + "TST", + ]) + .assert_success() + .get_output() + .stdout_lossy(); - let gas: u32 = cmd.stdout_lossy().trim().parse().unwrap(); // ensure we get a positive non-error value for gas estimate - assert!(gas > 0); + let output: u32 = output.trim().parse().unwrap(); + assert!(output > 0); }); // tests that the `cast upload-signatures` command works correctly casttest!(upload_signatures, |_prj, cmd| { // test no prefix is accepted as function - cmd.args(["upload-signature", "transfer(address,uint256)"]); - let output = cmd.stdout_lossy(); - + let output = cmd + .args(["upload-signature", "transfer(address,uint256)"]) + .assert_success() + .get_output() + .stdout_lossy(); assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); // test event prefix cmd.args(["upload-signature", "event Transfer(address,uint256)"]); - let output = cmd.stdout_lossy(); - + let output = cmd.assert_success().get_output().stdout_lossy(); assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); // test error prefix cmd.args(["upload-signature", "error ERC20InsufficientBalance(address,uint256,uint256)"]); - let output = cmd.stdout_lossy(); - + let output = cmd.assert_success().get_output().stdout_lossy(); assert!( output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), "{}", @@ -359,8 +485,7 @@ casttest!(upload_signatures, |_prj, cmd| { "transfer(address,uint256)", "approve(address,uint256)", ]); - let output = cmd.stdout_lossy(); - + let output = cmd.assert_success().get_output().stdout_lossy(); assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); @@ -378,8 +503,7 @@ casttest!(upload_signatures, |_prj, cmd| { .unwrap() .as_str(), ]); - let output = cmd.stdout_lossy(); - + let output = cmd.assert_success().get_output().stdout_lossy(); assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); @@ -394,14 +518,18 @@ casttest!(upload_signatures, |_prj, cmd| { // tests that the `cast to-rlp` and `cast from-rlp` commands work correctly casttest!(rlp, |_prj, cmd| { - cmd.args(["--to-rlp", "[\"0xaa\", [[\"bb\"]], \"0xcc\"]"]); - let out = cmd.stdout_lossy(); - assert!(out.contains("0xc881aac3c281bb81cc"), "{}", out); + cmd.args(["--to-rlp", "[\"0xaa\", [[\"bb\"]], \"0xcc\"]"]).assert_success().stdout_eq(str![[ + r#" +0xc881aac3c281bb81cc + +"# + ]]); cmd.cast_fuse(); - cmd.args(["--from-rlp", "0xcbc58455556666c0c0c2c1c0"]); - let out = cmd.stdout_lossy(); - assert!(out.contains("[[\"0x55556666\"],[],[],[[[]]]]"), "{}", out); + cmd.args(["--from-rlp", "0xcbc58455556666c0c0c2c1c0"]).assert_success().stdout_eq(str![[r#" +[["0x55556666"],[],[],[[[]]]] + +"#]]); }); // test for cast_rpc without arguments @@ -409,9 +537,12 @@ casttest!(rpc_no_args, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_chainId` - cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_chainId"]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim_end(), r#""0x1""#); + cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_chainId"]).assert_success().stdout_eq( + str![[r#" +"0x1" + +"#]], + ); }); // test for cast_rpc without arguments using websocket @@ -419,9 +550,12 @@ casttest!(ws_rpc_no_args, |_prj, cmd| { let eth_rpc_url = next_ws_rpc_endpoint(); // Call `cast rpc eth_chainId` - cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_chainId"]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim_end(), r#""0x1""#); + cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_chainId"]).assert_success().stdout_eq( + str![[r#" +"0x1" + +"#]], + ); }); // test for cast_rpc with arguments @@ -429,9 +563,12 @@ casttest!(rpc_with_args, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); // Call `cast rpc eth_getBlockByNumber 0x123 false` - cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_getBlockByNumber", "0x123", "false"]); - let output = cmd.stdout_lossy(); - assert!(output.contains(r#""number":"0x123""#), "{}", output); + cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_getBlockByNumber", "0x123", "false"]) + .assert_success() + .stdout_eq(str![[r#" +{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} + +"#]]); }); // test for cast_rpc with raw params @@ -446,9 +583,12 @@ casttest!(rpc_raw_params, |_prj, cmd| { "eth_getBlockByNumber", "--raw", r#"["0x123", false]"#, - ]); - let output = cmd.stdout_lossy(); - assert!(output.contains(r#""number":"0x123""#), "{}", output); + ]) + .assert_success() + .stdout_eq(str![[r#" +{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} + +"#]]); }); // test for cast_rpc with direct params @@ -460,17 +600,20 @@ casttest!(rpc_raw_params_stdin, |_prj, cmd| { |mut stdin| { stdin.write_all(b"\n[\n\"0x123\",\nfalse\n]\n").unwrap(); }, - ); - let output = cmd.stdout_lossy(); - assert!(output.contains(r#""number":"0x123""#), "{}", output); + ) + .assert_success() + .stdout_eq(str![[r#" +{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} + +"#]]); }); // checks `cast calldata` can handle arrays casttest!(calldata_array, |_prj, cmd| { - cmd.args(["calldata", "propose(string[])", "[\"\"]"]); - let out = cmd.stdout_lossy(); - assert_eq!(out.trim(),"0xcde2baba0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000" - ); + cmd.args(["calldata", "propose(string[])", "[\"\"]"]).assert_success().stdout_eq(str![[r#" +0xcde2baba0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000 + +"#]]); }); // @@ -483,10 +626,14 @@ casttest!(run_succeeds, |_prj, cmd| { "--quick", "--rpc-url", rpc.as_str(), - ]); - let output = cmd.stdout_lossy(); - assert!(output.contains("Transaction successfully executed")); - assert!(!output.contains("Revert")); + ]) + .assert_success() + .stdout_eq(str![[r#" +... +Transaction successfully executed. +[GAS] + +"#]]); }); // tests that `cast --to-base` commands are working correctly. @@ -507,11 +654,11 @@ casttest!(to_base, |_prj, cmd| { if subcmd == "--to-base" { for base in ["bin", "oct", "dec", "hex"] { cmd.cast_fuse().args([subcmd, value, base]); - assert!(!cmd.stdout_lossy().trim().is_empty()); + assert!(!cmd.assert_success().get_output().stdout_lossy().trim().is_empty()); } } else { cmd.cast_fuse().args([subcmd, value]); - assert!(!cmd.stdout_lossy().trim().is_empty()); + assert!(!cmd.assert_success().get_output().stdout_lossy().trim().is_empty()); } } } @@ -522,25 +669,68 @@ casttest!(receipt_revert_reason, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); // - cmd.cast_fuse().args([ + cmd.args([ "receipt", "0x44f2aaa351460c074f2cb1e5a9e28cbc7d83f33e425101d2de14331c7b7ec31e", "--rpc-url", rpc.as_str(), - ]); - let output = cmd.stdout_lossy(); - assert!(!output.contains("revertReason")); + ]) + .assert_success() + .stdout_eq(str![[r#" + +blockHash 0x2cfe65be49863676b6dbc04d58176a14f39b123f1e2f4fea0383a2d82c2c50d0 +blockNumber 16239315 +contractAddress +cumulativeGasUsed 10743428 +effectiveGasPrice 10539984136 +from 0x199D5ED7F45F4eE35960cF22EAde2076e95B253F +gasUsed 21000 +logs [] +logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +root +status 1 (success) +transactionHash 0x44f2aaa351460c074f2cb1e5a9e28cbc7d83f33e425101d2de14331c7b7ec31e +transactionIndex 116 +type 0 +blobGasPrice +blobGasUsed +authorizationList +to 0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59c + +"#]]); // - cmd.cast_fuse().args([ - "receipt", - "0x0e07d8b53ed3d91314c80e53cf25bcde02084939395845cbb625b029d568135c", - "--rpc-url", - rpc.as_str(), - ]); - let output = cmd.stdout_lossy(); - assert!(output.contains("revertReason")); - assert!(output.contains("Transaction too old")); + cmd.cast_fuse() + .args([ + "receipt", + "0x0e07d8b53ed3d91314c80e53cf25bcde02084939395845cbb625b029d568135c", + "--rpc-url", + rpc.as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#" + +blockHash 0x883f974b17ca7b28cb970798d1c80f4d4bb427473dc6d39b2a7fe24edc02902d +blockNumber 14839405 +contractAddress +cumulativeGasUsed 20273649 +effectiveGasPrice 21491736378 +from 0x3cF412d970474804623bb4e3a42dE13F9bCa5436 +gasUsed 24952 +logs [] +logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +root +status 0 (failed) +transactionHash 0x0e07d8b53ed3d91314c80e53cf25bcde02084939395845cbb625b029d568135c +transactionIndex 173 +type 2 +blobGasPrice +blobGasUsed +authorizationList +to 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45 +revertReason Transaction too old, data: "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000135472616e73616374696f6e20746f6f206f6c6400000000000000000000000000" + +"#]]); }); // tests that `cast --parse-bytes32-address` command is working correctly. @@ -548,9 +738,12 @@ casttest!(parse_bytes32_address, |_prj, cmd| { cmd.args([ "--parse-bytes32-address", "0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045", - ]); - let output = cmd.stdout_lossy(); - assert_eq!(output.trim(), "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045") + ]) + .assert_success() + .stdout_eq(str![[r#" +0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 + +"#]]); }); casttest!(access_list, |_prj, cmd| { @@ -564,12 +757,22 @@ casttest!(access_list, |_prj, cmd| { rpc.as_str(), "--gas-limit", // need to set this for alchemy.io to avoid "intrinsic gas too low" error "100000", - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +[GAS] +access list: +- address: [..] + keys: +... +- address: [..] + keys: +... +- address: [..] + keys: +... - let output = cmd.stdout_lossy(); - assert!(output.contains("address: 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599")); - assert!(output.contains("0x0d2a19d3ac39dc6cc6fd07423195495e18679bd8c7dd610aa1db7cd784a683a8")); - assert!(output.contains("0x7fba2702a7d6e85ac783a88eacdc48e51310443458071f6db9ac66f8ca7068b8")); +"#]]); }); casttest!(logs_topics, |_prj, cmd| { @@ -584,11 +787,9 @@ casttest!(logs_topics, |_prj, cmd| { "12421182", "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b", - ]); - - cmd.unchecked_output().stdout_matches_path( - Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/cast_logs.stdout"), - ); + ]) + .assert_success() + .stdout_eq(file!["../fixtures/cast_logs.stdout"]); }); casttest!(logs_topic_2, |_prj, cmd| { @@ -605,11 +806,9 @@ casttest!(logs_topic_2, |_prj, cmd| { "", "0x00000000000000000000000068a99f89e475a078645f4bac491360afe255dff1", /* Filter on the * `to` address */ - ]); - - cmd.unchecked_output().stdout_matches_path( - Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/cast_logs.stdout"), - ); + ]) + .assert_success() + .stdout_eq(file!["../fixtures/cast_logs.stdout"]); }); casttest!(logs_sig, |_prj, cmd| { @@ -624,11 +823,9 @@ casttest!(logs_sig, |_prj, cmd| { "12421182", "Transfer(address indexed from, address indexed to, uint256 value)", "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B", - ]); - - cmd.unchecked_output().stdout_matches_path( - Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/cast_logs.stdout"), - ); + ]) + .assert_success() + .stdout_eq(file!["../fixtures/cast_logs.stdout"]); }); casttest!(logs_sig_2, |_prj, cmd| { @@ -644,11 +841,9 @@ casttest!(logs_sig_2, |_prj, cmd| { "Transfer(address indexed from, address indexed to, uint256 value)", "", "0x68A99f89E475a078645f4BAC491360aFe255Dff1", - ]); - - cmd.unchecked_output().stdout_matches_path( - Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/cast_logs.stdout"), - ); + ]) + .assert_success() + .stdout_eq(file!["../fixtures/cast_logs.stdout"]); }); casttest!(mktx, |_prj, cmd| { @@ -669,12 +864,10 @@ casttest!(mktx, |_prj, cmd| { "--priority-gas-price", "1000000000", "0x0000000000000000000000000000000000000001", - ]); - let output = cmd.stdout_lossy(); - assert_eq!( - output.trim(), - "0x02f86b0180843b9aca008502540be4008252089400000000000000000000000000000000000000016480c001a070d55e79ed3ac9fc8f51e78eb91fd054720d943d66633f2eb1bc960f0126b0eca052eda05a792680de3181e49bab4093541f75b49d1ecbe443077b3660c836016a" - ); + ]).assert_success().stdout_eq(str![[r#" +0x02f86b0180843b9aca008502540be4008252089400000000000000000000000000000000000000016480c001a070d55e79ed3ac9fc8f51e78eb91fd054720d943d66633f2eb1bc960f0126b0eca052eda05a792680de3181e49bab4093541f75b49d1ecbe443077b3660c836016a + +"#]]); }); // ensure recipient or code is required @@ -684,11 +877,11 @@ casttest!(mktx_requires_to, |_prj, cmd| { "--private-key", "0x0000000000000000000000000000000000000000000000000000000000000001", ]); - let output = cmd.stderr_lossy(); - assert_eq!( - output.trim(), - "Error: \nMust specify a recipient address or contract code to deploy" - ); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +Must specify a recipient address or contract code to deploy + +"#]]); }); casttest!(mktx_signer_from_mismatch, |_prj, cmd| { @@ -702,10 +895,14 @@ casttest!(mktx_signer_from_mismatch, |_prj, cmd| { "1", "0x0000000000000000000000000000000000000001", ]); - let output = cmd.stderr_lossy(); - assert!( - output.contains("The specified sender via CLI/env vars does not match the sender configured via\nthe hardware wallet's HD Path.") - ); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +The specified sender via CLI/env vars does not match the sender configured via +the hardware wallet's HD Path. +Please use the `--hd-path ` parameter to specify the BIP32 Path which +corresponds to the sender, or let foundry automatically detect it by not specifying any sender address. + +"#]]); }); casttest!(mktx_signer_from_match, |_prj, cmd| { @@ -726,43 +923,39 @@ casttest!(mktx_signer_from_match, |_prj, cmd| { "--priority-gas-price", "1000000000", "0x0000000000000000000000000000000000000001", - ]); - let output = cmd.stdout_lossy(); - assert_eq!( - output.trim(), - "0x02f86b0180843b9aca008502540be4008252089400000000000000000000000000000000000000018080c001a0cce9a61187b5d18a89ecd27ec675e3b3f10d37f165627ef89a15a7fe76395ce8a07537f5bffb358ffbef22cda84b1c92f7211723f9e09ae037e81686805d3e5505" - ); + ]).assert_success().stdout_eq(str![[r#" +0x02f86b0180843b9aca008502540be4008252089400000000000000000000000000000000000000018080c001a0cce9a61187b5d18a89ecd27ec675e3b3f10d37f165627ef89a15a7fe76395ce8a07537f5bffb358ffbef22cda84b1c92f7211723f9e09ae037e81686805d3e5505 + +"#]]); }); // tests that the raw encoded transaction is returned casttest!(tx_raw, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); - // - cmd.cast_fuse().args([ + // + cmd.args([ "tx", "0x44f2aaa351460c074f2cb1e5a9e28cbc7d83f33e425101d2de14331c7b7ec31e", "raw", "--rpc-url", rpc.as_str(), - ]); - let output = cmd.stdout_lossy(); + ]).assert_success().stdout_eq(str![[r#" +0xf86d824c548502743b65088275309491da5bf3f8eb72724e6f50ec6c3d199c6355c59c87a0a73f33e9e4cc8025a0428518b1748a08bbeb2392ea055b418538944d30adfc2accbbfa8362a401d3a4a07d6093ab2580efd17c11b277de7664fce56e6953cae8e925bec3313399860470 - // - assert_eq!( - output.trim(), - "0xf86d824c548502743b65088275309491da5bf3f8eb72724e6f50ec6c3d199c6355c59c87a0a73f33e9e4cc8025a0428518b1748a08bbeb2392ea055b418538944d30adfc2accbbfa8362a401d3a4a07d6093ab2580efd17c11b277de7664fce56e6953cae8e925bec3313399860470" - ); +"#]]); + // cmd.cast_fuse().args([ "tx", "0x44f2aaa351460c074f2cb1e5a9e28cbc7d83f33e425101d2de14331c7b7ec31e", "--raw", "--rpc-url", rpc.as_str(), - ]); - let output2 = cmd.stdout_lossy(); - assert_eq!(output, output2); + ]).assert_success().stdout_eq(str![[r#" +0xf86d824c548502743b65088275309491da5bf3f8eb72724e6f50ec6c3d199c6355c59c87a0a73f33e9e4cc8025a0428518b1748a08bbeb2392ea055b418538944d30adfc2accbbfa8362a401d3a4a07d6093ab2580efd17c11b277de7664fce56e6953cae8e925bec3313399860470 + +"#]]); }); // ensure receipt or code is required @@ -772,62 +965,66 @@ casttest!(send_requires_to, |_prj, cmd| { "--private-key", "0x0000000000000000000000000000000000000000000000000000000000000001", ]); - let output = cmd.stderr_lossy(); - assert_eq!( - output.trim(), - "Error: \nMust specify a recipient address or contract code to deploy" - ); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +Must specify a recipient address or contract code to deploy + +"#]]); }); casttest!(storage, |_prj, cmd| { - let empty = "0x0000000000000000000000000000000000000000000000000000000000000000"; - let rpc = next_http_rpc_endpoint(); - cmd.cast_fuse().args(["storage", "vitalik.eth", "1", "--rpc-url", &rpc]); - assert_eq!(cmd.stdout_lossy().trim(), empty); + cmd.args(["storage", "vitalik.eth", "1", "--rpc-url", &rpc]).assert_success().stdout_eq(str![ + [r#" +0x0000000000000000000000000000000000000000000000000000000000000000 + +"#] + ]); let rpc = next_http_rpc_endpoint(); - cmd.cast_fuse().args(["storage", "vitalik.eth", "0x01", "--rpc-url", &rpc]); - assert_eq!(cmd.stdout_lossy().trim(), empty); + cmd.cast_fuse() + .args(["storage", "vitalik.eth", "0x01", "--rpc-url", &rpc]) + .assert_success() + .stdout_eq(str![[r#" +0x0000000000000000000000000000000000000000000000000000000000000000 + +"#]]); let rpc = next_http_rpc_endpoint(); let usdt = "0xdac17f958d2ee523a2206206994597c13d831ec7"; let decimals_slot = "0x09"; - let six = "0x0000000000000000000000000000000000000000000000000000000000000006"; - cmd.cast_fuse().args(["storage", usdt, decimals_slot, "--rpc-url", &rpc]); - assert_eq!(cmd.stdout_lossy().trim(), six); + cmd.cast_fuse() + .args(["storage", usdt, decimals_slot, "--rpc-url", &rpc]) + .assert_success() + .stdout_eq(str![[r#" +0x0000000000000000000000000000000000000000000000000000000000000006 + +"#]]); let rpc = next_http_rpc_endpoint(); let total_supply_slot = "0x01"; - let issued = "0x000000000000000000000000000000000000000000000000000000174876e800"; let block_before = "4634747"; let block_after = "4634748"; - cmd.cast_fuse().args([ - "storage", - usdt, - total_supply_slot, - "--rpc-url", - &rpc, - "--block", - block_before, - ]); - assert_eq!(cmd.stdout_lossy().trim(), empty); - cmd.cast_fuse().args([ - "storage", - usdt, - total_supply_slot, - "--rpc-url", - &rpc, - "--block", - block_after, - ]); - assert_eq!(cmd.stdout_lossy().trim(), issued); + cmd.cast_fuse() + .args(["storage", usdt, total_supply_slot, "--rpc-url", &rpc, "--block", block_before]) + .assert_success() + .stdout_eq(str![[r#" +0x0000000000000000000000000000000000000000000000000000000000000000 + +"#]]); + + cmd.cast_fuse() + .args(["storage", usdt, total_supply_slot, "--rpc-url", &rpc, "--block", block_after]) + .assert_success() + .stdout_eq(str![[r#" +0x000000000000000000000000000000000000000000000000000000174876e800 + +"#]]); }); // casttest!(storage_layout, |_prj, cmd| { - cmd.cast_fuse() - .args([ + cmd.args([ "storage", "--rpc-url", next_rpc_endpoint(NamedChain::Optimism).as_str(), @@ -874,27 +1071,39 @@ casttest!(storage_layout, |_prj, cmd| { casttest!(balance, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); let usdt = "0xdac17f958d2ee523a2206206994597c13d831ec7"; - cmd.cast_fuse().args([ - "balance", - "0x0000000000000000000000000000000000000000", - "--erc20", - usdt, - "--rpc-url", - &rpc, - ]); - cmd.cast_fuse().args([ - "balance", - "0x0000000000000000000000000000000000000000", - "--erc721", - usdt, - "--rpc-url", - &rpc, - ]); - let usdt_result = cmd.stdout_lossy(); - let alias_result = cmd.stdout_lossy(); + let usdt_result = cmd + .args([ + "balance", + "0x0000000000000000000000000000000000000000", + "--erc20", + usdt, + "--rpc-url", + &rpc, + ]) + .assert_success() + .get_output() + .stdout_lossy() + .trim() + .to_string(); - assert_ne!(usdt_result, "0x0000000000000000000000000000000000000000000000000000000000000000"); + let alias_result = cmd + .cast_fuse() + .args([ + "balance", + "0x0000000000000000000000000000000000000000", + "--erc721", + usdt, + "--rpc-url", + &rpc, + ]) + .assert_success() + .get_output() + .stdout_lossy() + .trim() + .to_string(); + + assert_ne!(usdt_result, "0"); assert_eq!(alias_result, usdt_result); }); @@ -906,10 +1115,8 @@ casttest!(interface_no_constructor, |prj, cmd| { let path = prj.root().join("interface.json"); fs::write(&path, interface).unwrap(); // Call `cast find-block` - cmd.args(["interface"]).arg(&path); - let output = cmd.stdout_lossy(); - - let s = r#"// SPDX-License-Identifier: UNLICENSED + cmd.args(["interface"]).arg(&path).assert_success().stdout_eq(str![[ + r#"// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; interface Interface { @@ -928,8 +1135,10 @@ interface Interface { uint256[] memory minIncomingAssetAmounts_ ); function redeem(address _vaultProxy, bytes memory, bytes memory _assetData) external; -}"#; - assert_eq!(output.trim(), s); +} + +"# + ]]); }); // tests that fetches WETH interface from etherscan @@ -937,10 +1146,9 @@ interface Interface { casttest!(fetch_weth_interface_from_etherscan, |_prj, cmd| { let weth_address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; let api_key = "ZUB97R31KSYX7NYVW6224Q6EYY6U56H591"; - cmd.args(["interface", "--etherscan-api-key", api_key, weth_address]); - let output = cmd.stdout_lossy(); - - let weth_interface = r#"// SPDX-License-Identifier: UNLICENSED + cmd.args(["interface", "--etherscan-api-key", api_key, weth_address]) + .assert_success() + .stdout_eq(str![[r#"// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; interface WETH9 { @@ -962,65 +1170,89 @@ interface WETH9 { function transfer(address dst, uint256 wad) external returns (bool); function transferFrom(address src, address dst, uint256 wad) external returns (bool); function withdraw(uint256 wad) external; -}"#; - assert_eq!(output.trim(), weth_interface); -}); +} -const ENS_NAME: &str = "emo.eth"; -const ENS_NAMEHASH: B256 = - b256!("0a21aaf2f6414aa664deb341d1114351fdb023cad07bf53b28e57c26db681910"); -const ENS_ADDRESS: Address = address!("28679A1a632125fbBf7A68d850E50623194A709E"); +"#]]); +}); casttest!(ens_namehash, |_prj, cmd| { - cmd.args(["namehash", ENS_NAME]); - let out = cmd.stdout_lossy().trim().parse::(); - assert_eq!(out, Ok(ENS_NAMEHASH)); + cmd.args(["namehash", "emo.eth"]).assert_success().stdout_eq(str![[r#" +0x0a21aaf2f6414aa664deb341d1114351fdb023cad07bf53b28e57c26db681910 + +"#]]); }); casttest!(ens_lookup, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); - cmd.args(["lookup-address", &ENS_ADDRESS.to_string(), "--rpc-url", ð_rpc_url, "--verify"]); - let out = cmd.stdout_lossy(); - assert_eq!(out.trim(), ENS_NAME); + cmd.args([ + "lookup-address", + "0x28679A1a632125fbBf7A68d850E50623194A709E", + "--rpc-url", + ð_rpc_url, + "--verify", + ]) + .assert_success() + .stdout_eq(str![[r#" +emo.eth + +"#]]); }); casttest!(ens_resolve, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); - cmd.args(["resolve-name", ENS_NAME, "--rpc-url", ð_rpc_url, "--verify"]); - let out = cmd.stdout_lossy().trim().parse::
(); - assert_eq!(out, Ok(ENS_ADDRESS)); + cmd.args(["resolve-name", "emo.eth", "--rpc-url", ð_rpc_url, "--verify"]) + .assert_success() + .stdout_eq(str![[r#" +0x28679A1a632125fbBf7A68d850E50623194A709E + +"#]]); }); casttest!(ens_resolve_no_dot_eth, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); - let name = ENS_NAME.strip_suffix(".eth").unwrap(); - cmd.args(["resolve-name", name, "--rpc-url", ð_rpc_url, "--verify"]); - let (_out, err) = cmd.unchecked_output_lossy(); - assert!(err.contains("not found"), "{err:?}"); + cmd.args(["resolve-name", "emo", "--rpc-url", ð_rpc_url, "--verify"]) + .assert_failure() + .stderr_eq(str![[r#" +Error: +ENS resolver not found for name "emo" + +"#]]); }); casttest!(index7201, |_prj, cmd| { - let tests = - [("example.main", "0x183a6125c38840424c4a85fa12bab2ab606c4b6d0e7cc73c0c06ba5300eab500")]; - for (id, expected) in tests { - cmd.cast_fuse(); - assert_eq!(cmd.args(["index-erc7201", id]).stdout_lossy().trim(), expected); - } + cmd.args(["index-erc7201", "example.main"]).assert_success().stdout_eq(str![[r#" +0x183a6125c38840424c4a85fa12bab2ab606c4b6d0e7cc73c0c06ba5300eab500 + +"#]]); }); casttest!(index7201_unknown_formula_id, |_prj, cmd| { - cmd.args(["index-7201", "test", "--formula-id", "unknown"]).assert_err(); + cmd.args(["index-erc7201", "test", "--formula-id", "unknown"]).assert_failure().stderr_eq( + str![[r#" +Error: +unsupported formula ID: unknown + +"#]], + ); }); casttest!(block_number, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); - let s = cmd.args(["block-number", "--rpc-url", eth_rpc_url.as_str()]).stdout_lossy(); + let s = cmd + .args(["block-number", "--rpc-url", eth_rpc_url.as_str()]) + .assert_success() + .get_output() + .stdout_lossy(); assert!(s.trim().parse::().unwrap() > 0, "{s}") }); casttest!(block_number_latest, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); - let s = cmd.args(["block-number", "--rpc-url", eth_rpc_url.as_str(), "latest"]).stdout_lossy(); + let s = cmd + .args(["block-number", "--rpc-url", eth_rpc_url.as_str(), "latest"]) + .assert_success() + .get_output() + .stdout_lossy(); assert!(s.trim().parse::().unwrap() > 0, "{s}") }); @@ -1033,6 +1265,8 @@ casttest!(block_number_hash, |_prj, cmd| { eth_rpc_url.as_str(), "0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6", ]) + .assert_success() + .get_output() .stdout_lossy(); assert_eq!(s.trim().parse::().unwrap(), 1, "{s}") }); @@ -1041,6 +1275,7 @@ casttest!(send_eip7702, async |_prj, cmd| { let (_api, handle) = anvil::spawn(NodeConfig::test().with_hardfork(Some(Hardfork::PragueEOF))).await; let endpoint = handle.http_endpoint(); + cmd.args([ "send", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", @@ -1063,12 +1298,13 @@ casttest!(send_eip7702, async |_prj, cmd| { }); casttest!(hash_message, |_prj, cmd| { - let tests = [ - ("hello", "0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750"), - ("0x68656c6c6f", "0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750"), - ]; - for (message, expected) in tests { - cmd.cast_fuse(); - assert_eq!(cmd.args(["hash-message", message]).stdout_lossy().trim(), expected); - } + cmd.args(["hash-message", "hello"]).assert_success().stdout_eq(str![[r#" +0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750 + +"#]]); + + cmd.cast_fuse().args(["hash-message", "0x68656c6c6f"]).assert_success().stdout_eq(str![[r#" +0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750 + +"#]]); }); diff --git a/crates/forge/benches/test.rs b/crates/forge/benches/test.rs index 7646a3c214a33..593bce3d320d5 100644 --- a/crates/forge/benches/test.rs +++ b/crates/forge/benches/test.rs @@ -1,5 +1,8 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use foundry_test_utils::{util::setup_forge_remote, TestCommand, TestProject}; +use foundry_test_utils::{ + util::{lossy_string, setup_forge_remote}, + TestCommand, TestProject, +}; /// Returns a cloned and `forge built` `solmate` project fn built_solmate() -> (TestProject, TestCommand) { @@ -15,7 +18,9 @@ fn forge_test_benchmark(c: &mut Criterion) { let mut cmd = prj.forge_command(); cmd.arg("test"); b.iter(|| { - cmd.print_output(); + let output = cmd.execute(); + println!("stdout:\n{}", lossy_string(&output.stdout)); + println!("\nstderr:\n{}", lossy_string(&output.stderr)); }); }); } diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index f5848173c921e..d9861f19e392d 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -45,7 +45,7 @@ contract Dummy { // tests build output is as expected forgetest_init!(exact_build_output, |prj, cmd| { cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" -Compiling 27 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -54,11 +54,15 @@ Compiler run successful! // tests build output is as expected forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { - cmd.args(["build", "--sizes"]); - let stdout = cmd.stdout_lossy(); - assert!(!stdout.contains("console"), "\n{stdout}"); - assert!(!stdout.contains("std"), "\n{stdout}"); - assert!(stdout.contains("Counter"), "\n{stdout}"); + cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![ + r#" +... +| Contract | Size (B) | Margin (B) | +|----------|----------|------------| +| Counter | 247 | 24,329 | +... +"# + ]); }); // tests that skip key in config can be used to skip non-compilable contract diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 9160973e9b024..1a8d2cb7e08c9 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1,7 +1,6 @@ //! Contains various tests for checking forge's commands use crate::constants::*; -use alloy_primitives::hex; use foundry_compilers::artifacts::{remappings::Remapping, ConfigurableContractArtifact, Metadata}; use foundry_config::{ parse_with_profile, BasicConfig, Chain, Config, FuzzConfig, InvariantConfig, SolidityErrorCode, @@ -21,8 +20,21 @@ use std::{ // tests `--help` is printed to std out forgetest!(print_help, |_prj, cmd| { - cmd.arg("--help"); - cmd.assert_non_empty_stdout(); + cmd.arg("--help").assert_success().stdout_eq(str![[r#" +Build, test, fuzz, debug and deploy Solidity contracts + +Usage: forge[..] + +Commands: +... + +Options: + -h, --help Print help + -V, --version Print version + +Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html + +"#]]); }); // checks that `clean` can be invoked even if out and cache don't exist @@ -52,10 +64,9 @@ forgetest!( fs::write(block2_file, "{}").unwrap(); fs::create_dir_all(etherscan_cache_dir).unwrap(); - cmd.args(["cache", "ls"]); - let output_string = String::from_utf8_lossy(&cmd.output().stdout).to_string(); - let output_lines = output_string.split('\n').collect::>(); - println!("{output_string}"); + let output = cmd.args(["cache", "ls"]).assert_success().get_output().stdout_lossy(); + let output_lines = output.split('\n').collect::>(); + println!("{output}"); assert_eq!(output_lines.len(), 6); assert!(output_lines[0].starts_with("-️ mainnet (")); @@ -213,8 +224,14 @@ forgetest!(can_init_repo_with_config, |prj, cmd| { let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(!foundry_toml.exists()); - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); + cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); let s = read_string(&foundry_toml); let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; @@ -256,8 +273,13 @@ https://github.com/foundry-rs/foundry/issues/new/choose forgetest!(can_init_no_git, |prj, cmd| { prj.wipe(); - cmd.arg("init").arg(prj.root()).arg("--no-git"); - cmd.assert_non_empty_stdout(); + cmd.arg("init").arg(prj.root()).arg("--no-git").assert_success().stdout_eq(str![[r#" +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std + Initialized forge project + +"#]]); prj.assert_config_exists(); assert!(!prj.root().join(".git").exists()); @@ -269,8 +291,7 @@ forgetest!(can_init_no_git, |prj, cmd| { forgetest!(can_init_quiet, |prj, cmd| { prj.wipe(); - cmd.arg("init").arg(prj.root()).arg("-q"); - let _ = cmd.output(); + cmd.arg("init").arg(prj.root()).arg("-q").assert_empty_stdout(); }); // `forge init foobar` works with dir argument @@ -284,10 +305,14 @@ forgetest!(can_init_with_dir, |prj, cmd| { // `forge init foobar --template [template]` works with dir argument forgetest!(can_init_with_dir_and_template, |prj, cmd| { - cmd.args(["init", "foobar", "--template", "foundry-rs/forge-template"]); + cmd.args(["init", "foobar", "--template", "foundry-rs/forge-template"]) + .assert_success() + .stdout_eq(str![[r#" +Initializing [..] from https://github.com/foundry-rs/forge-template... + Initialized forge project + +"#]]); - cmd.assert_success(); - cmd.assert_non_empty_stdout(); assert!(prj.root().join("foobar/.git").exists()); assert!(prj.root().join("foobar/foundry.toml").exists()); assert!(prj.root().join("foobar/lib/forge-std").exists()); @@ -306,10 +331,14 @@ forgetest!(can_init_with_dir_and_template_and_branch, |prj, cmd| { "foundry-rs/forge-template", "--branch", "test/deployments", - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +Initializing [..] from https://github.com/foundry-rs/forge-template... + Initialized forge project + +"#]]); - cmd.assert_success(); - cmd.assert_non_empty_stdout(); assert!(prj.root().join("foobar/.dapprc").exists()); assert!(prj.root().join("foobar/lib/ds-test").exists()); // assert that gitmodules were correctly initialized @@ -321,11 +350,22 @@ forgetest!(can_init_with_dir_and_template_and_branch, |prj, cmd| { // `forge init --force` works on non-empty dirs forgetest!(can_init_non_empty, |prj, cmd| { prj.create_file("README.md", "non-empty dir"); - cmd.arg("init").arg(prj.root()); - cmd.assert_err(); + cmd.arg("init").arg(prj.root()).assert_failure().stderr_eq(str![[r#" +Error: +Cannot run `init` on a non-empty directory. +Run with the `--force` flag to initialize regardless. + +"#]]); + + cmd.arg("--force").assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); - cmd.arg("--force"); - cmd.assert_non_empty_stdout(); assert!(prj.root().join(".git").exists()); assert!(prj.root().join("lib/forge-std").exists()); }); @@ -345,11 +385,21 @@ forgetest!(can_init_in_empty_repo, |prj, cmd| { assert!(status.success()); assert!(root.join(".git").exists()); - cmd.arg("init").arg(root); - cmd.assert_err(); + cmd.arg("init").arg(root).assert_failure().stderr_eq(str![[r#" +Error: +Cannot run `init` on a non-empty directory. +Run with the `--force` flag to initialize regardless. + +"#]]); + + cmd.arg("--force").assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project - cmd.arg("--force"); - cmd.assert_non_empty_stdout(); +"#]]); assert!(root.join("lib/forge-std").exists()); }); @@ -371,11 +421,21 @@ forgetest!(can_init_in_non_empty_repo, |prj, cmd| { prj.create_file("README.md", "non-empty dir"); prj.create_file(".gitignore", "not foundry .gitignore"); - cmd.arg("init").arg(root); - cmd.assert_err(); + cmd.arg("init").arg(root).assert_failure().stderr_eq(str![[r#" +Error: +Cannot run `init` on a non-empty directory. +Run with the `--force` flag to initialize regardless. - cmd.arg("--force"); - cmd.assert_non_empty_stdout(); +"#]]); + + cmd.arg("--force").assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); assert!(root.join("lib/forge-std").exists()); // not overwritten @@ -388,8 +448,13 @@ forgetest!(can_init_in_non_empty_repo, |prj, cmd| { forgetest!(can_init_vscode, |prj, cmd| { prj.wipe(); - cmd.arg("init").arg(prj.root()).arg("--vscode"); - cmd.assert_non_empty_stdout(); + cmd.arg("init").arg(prj.root()).arg("--vscode").assert_success().stdout_eq(str![[r#" +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); let settings = prj.root().join(".vscode/settings.json"); assert!(settings.is_file()); @@ -411,8 +476,16 @@ forgetest!(can_init_vscode, |prj, cmd| { // checks that forge can init with template forgetest!(can_init_template, |prj, cmd| { prj.wipe(); - cmd.args(["init", "--template", "foundry-rs/forge-template"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); + + cmd.args(["init", "--template", "foundry-rs/forge-template"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" +Initializing [..] from https://github.com/foundry-rs/forge-template... + Initialized forge project + +"#]]); + assert!(prj.root().join(".git").exists()); assert!(prj.root().join("foundry.toml").exists()); assert!(prj.root().join("lib/forge-std").exists()); @@ -426,8 +499,14 @@ forgetest!(can_init_template, |prj, cmd| { forgetest!(can_init_template_with_branch, |prj, cmd| { prj.wipe(); cmd.args(["init", "--template", "foundry-rs/forge-template", "--branch", "test/deployments"]) - .arg(prj.root()); - cmd.assert_non_empty_stdout(); + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" +Initializing [..] from https://github.com/foundry-rs/forge-template... + Initialized forge project + +"#]]); + assert!(prj.root().join(".git").exists()); assert!(prj.root().join(".dapprc").exists()); assert!(prj.root().join("lib/ds-test").exists()); @@ -440,8 +519,13 @@ forgetest!(can_init_template_with_branch, |prj, cmd| { // checks that init fails when the provided template doesn't exist forgetest!(fail_init_nonexistent_template, |prj, cmd| { prj.wipe(); - cmd.args(["init", "--template", "a"]).arg(prj.root()); - cmd.assert_non_empty_stderr(); + cmd.args(["init", "--template", "a"]).arg(prj.root()).assert_failure().stderr_eq(str![[r#" +remote: Not Found +fatal: repository 'https://github.com/a/' not found +Error: +git fetch exited with code 128 + +"#]]); }); // checks that clone works @@ -457,8 +541,20 @@ forgetest!(can_clone, |prj, cmd| { next_etherscan_api_key().as_str(), "0x044b75f554b886A065b9567891e45c79542d7357", ]) - .arg(prj.root()); - cmd.assert_non_empty_stdout(); + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" +Downloading the source code of 0x044b75f554b886A065b9567891e45c79542d7357 from Etherscan... +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project +Collecting the creation information of 0x044b75f554b886A065b9567891e45c79542d7357 from Etherscan... +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); let s = read_string(&foundry_toml); let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; @@ -475,8 +571,8 @@ forgetest!(can_clone_quiet, |prj, cmd| { "--quiet", "0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec", ]) - .arg(prj.root()); - cmd.assert_empty_stdout(); + .arg(prj.root()) + .assert_empty_stdout(); }); // checks that clone works with --no-remappings-txt @@ -493,8 +589,20 @@ forgetest!(can_clone_no_remappings_txt, |prj, cmd| { "--no-remappings-txt", "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", ]) - .arg(prj.root()); - cmd.assert_non_empty_stdout(); + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" +Downloading the source code of 0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf from Etherscan... +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project +Collecting the creation information of 0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf from Etherscan... +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); let s = read_string(&foundry_toml); let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; @@ -507,16 +615,21 @@ forgetest!(can_clone_keep_directory_structure, |prj, cmd| { let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(!foundry_toml.exists()); - cmd.args([ - "clone", - "--etherscan-api-key", - next_etherscan_api_key().as_str(), - "--keep-directory-structure", - "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", - ]) - .arg(prj.root()); - let out = cmd.unchecked_output(); - if out.stdout_lossy().contains("502 Bad Gateway") { + let output = cmd + .forge_fuse() + .args([ + "clone", + "--etherscan-api-key", + next_etherscan_api_key().as_str(), + "--keep-directory-structure", + "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", + ]) + .arg(prj.root()) + .assert_success() + .get_output() + .stdout_lossy(); + + if output.contains("502 Bad Gateway") { // etherscan nginx proxy issue, skip this test: // // stdout: @@ -526,10 +639,9 @@ forgetest!(can_clone_keep_directory_structure, |prj, cmd| { // Gateway\r\n\r\n

502 Bad // Gateway

\r\n
nginx
\r\n\r\n\r\n" - eprintln!("Skipping test due to 502 Bad Gateway: {}", cmd.make_error_message(&out, false)); - return + eprintln!("Skipping test due to 502 Bad Gateway"); + return; } - cmd.ensure_success(&out).unwrap(); let s = read_string(&foundry_toml); let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1; @@ -557,15 +669,18 @@ forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj, cmd| { forgetest_init!(can_clean_config, |prj, cmd| { let config = Config { out: "custom-out".into(), ..Default::default() }; prj.write_config(config); - cmd.arg("build"); - cmd.assert_non_empty_stdout(); + cmd.arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); // default test contract is written in custom out directory let artifact = prj.root().join(format!("custom-out/{TEMPLATE_TEST_CONTRACT_ARTIFACT_JSON}")); assert!(artifact.exists()); - cmd.forge_fuse().arg("clean"); - cmd.output(); + cmd.forge_fuse().arg("clean").assert_empty_stdout(); assert!(!artifact.exists()); }); @@ -586,24 +701,37 @@ forgetest_init!(can_clean_test_cache, |prj, cmd| { assert!(fuzz_cache_dir.exists()); assert!(invariant_cache_dir.exists()); - cmd.forge_fuse().arg("clean"); - cmd.output(); + cmd.forge_fuse().arg("clean").assert_empty_stdout(); assert!(!fuzz_cache_dir.exists()); assert!(!invariant_cache_dir.exists()); }); // checks that extra output works forgetest_init!(can_emit_extra_output, |prj, cmd| { - cmd.args(["build", "--extra-output", "metadata"]); - cmd.assert_non_empty_stdout(); + prj.clear(); + + cmd.args(["build", "--extra-output", "metadata"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON); let artifact: ConfigurableContractArtifact = foundry_compilers::utils::read_json_file(&artifact_path).unwrap(); assert!(artifact.metadata.is_some()); - cmd.forge_fuse().args(["build", "--extra-output-files", "metadata", "--force"]).root_arg(); - cmd.assert_non_empty_stdout(); + cmd.forge_fuse() + .args(["build", "--extra-output-files", "metadata", "--force"]) + .root_arg() + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); let metadata_path = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json")); @@ -612,8 +740,14 @@ forgetest_init!(can_emit_extra_output, |prj, cmd| { // checks that extra output works forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| { - cmd.args(["build", "--extra-output", "metadata", "ir-optimized", "--extra-output", "ir"]); - cmd.assert_non_empty_stdout(); + cmd.args(["build", "--extra-output", "metadata", "ir-optimized", "--extra-output", "ir"]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON); let artifact: ConfigurableContractArtifact = @@ -631,8 +765,14 @@ forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| { "evm.bytecode.sourceMap", "--force", ]) - .root_arg(); - cmd.assert_non_empty_stdout(); + .root_arg() + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); let metadata_path = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json")); @@ -659,10 +799,30 @@ contract Greeter { ) .unwrap(); - cmd.arg("build"); + cmd.arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (5667): Unused function parameter. Remove or comment out the variable name to silence this warning. + [FILE]:5:18: + | +5 | function foo(uint256 a) public { + | ^^^^^^^^^ + +Warning (2072): Unused local variable. + [FILE]:6:9: + | +6 | uint256 x = 1; + | ^^^^^^^^^ + +Warning (2018): Function state mutability can be restricted to pure + [FILE]:5:5: + | +5 | function foo(uint256 a) public { + | ^ (Relevant source part starts here and spans across multiple lines). + - let output = cmd.stdout_lossy(); - assert!(output.contains("Warning"), "{output}"); +"#]]); }); // Tests that direct import paths are handled correctly @@ -700,13 +860,12 @@ library FooLib { ) .unwrap(); - cmd.arg("build"); - - assert!(cmd.stdout_lossy().ends_with( - " + cmd.arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -" - )); + +"#]]); }); // tests that the `inspect` command works correctly @@ -726,17 +885,18 @@ contract Foo { ) .unwrap(); - let check_output = |output: String| { - let output = output.trim(); - assert!(output.starts_with("0x") && hex::decode(output).is_ok(), "{output}"); - }; + cmd.arg("inspect").arg(contract_name).arg("bytecode").assert_success().stdout_eq(str![[r#" +0x60806040[..] - cmd.arg("inspect").arg(contract_name).arg("bytecode"); - check_output(cmd.stdout_lossy()); +"#]]); let info = format!("src/{}:{}", path.file_name().unwrap().to_string_lossy(), contract_name); - cmd.forge_fuse().arg("inspect").arg(info).arg("bytecode"); - check_output(cmd.stdout_lossy()); + cmd.forge_fuse().arg("inspect").arg(info).arg("bytecode").assert_success().stdout_eq(str![[ + r#" +0x60806040[..] + +"# + ]]); }); // test that `forge snapshot` commands work @@ -757,7 +917,7 @@ contract ATest is DSTest { .unwrap(); cmd.args(["snapshot"]).assert_success().stdout_eq(str![[r#" -Compiling 2 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -769,8 +929,16 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); - cmd.arg("--check"); - let _ = cmd.output(); + cmd.arg("--check").assert_success().stdout_eq(str![[r#" +No files changed, compilation skipped + +Ran 1 test for src/ATest.t.sol:ATest +[PASS] testExample() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // test that `forge build` does not print `(with warnings)` if file path is ignored @@ -793,20 +961,27 @@ contract A { ) .unwrap(); - cmd.args(["build", "--force"]); - let out = cmd.stdout_lossy(); - // expect no warning as path is ignored - assert!(out.contains("Compiler run successful!")); - assert!(!out.contains("Compiler run successful with warnings:")); + cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); // Reconfigure without ignored paths or error codes and check for warnings // need to reset empty error codes as default would set some error codes prj.write_config(Config { ignored_error_codes: vec![], ..Default::default() }); - let out = cmd.stdout_lossy(); - // expect warnings as path is not ignored - assert!(out.contains("Compiler run successful with warnings:"), "{out}"); - assert!(out.contains("Warning") && out.contains("SPDX-License-Identifier"), "{out}"); + cmd.forge_fuse().args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +[FILE] + + +"#]]); }); // test that `forge build` does not print `(with warnings)` if there arent any @@ -827,19 +1002,27 @@ contract A { ) .unwrap(); - cmd.args(["build", "--force"]); - let out = cmd.stdout_lossy(); - // no warnings - assert!(out.contains("Compiler run successful!")); - assert!(!out.contains("Compiler run successful with warnings:")); + cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); // don't ignore errors let config = Config { ignored_error_codes: vec![], ..Default::default() }; prj.write_config(config); - let out = cmd.stdout_lossy(); - assert!(out.contains("Compiler run successful with warnings:"), "{out}"); - assert!(out.contains("Warning") && out.contains("SPDX-License-Identifier"), "{out}"); + cmd.forge_fuse().args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +[FILE] + + +"#]]); }); // test that `forge build` compiles when severity set to error, fails when set to warning, and @@ -859,14 +1042,30 @@ contract A { .unwrap(); // there are no errors - cmd.args(["build", "--force"]); - let out = cmd.stdout_lossy(); - assert!(out.contains("Compiler run successful with warnings:"), "{out}"); + cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +[FILE] + + +"#]]); // warning fails to compile let config = Config { ignored_error_codes: vec![], deny_warnings: true, ..Default::default() }; prj.write_config(config); - cmd.assert_err(); + + cmd.forge_fuse().args(["build", "--force"]).assert_failure().stderr_eq(str![[r#" +Error: +Compiler run failed: +Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +[FILE] + + +"#]]); // ignores error code and compiles let config = Config { @@ -875,10 +1074,13 @@ contract A { ..Default::default() }; prj.write_config(config); - let out = cmd.stdout_lossy(); - assert!(out.contains("Compiler run successful!")); - assert!(!out.contains("Compiler run successful with warnings:")); + cmd.forge_fuse().args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); }); // test that a failing `forge build` does not impact followup builds @@ -910,8 +1112,14 @@ contract BTest is DSTest { ) .unwrap(); - cmd.arg("build"); - cmd.assert_non_empty_stdout(); + cmd.arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +... +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); + prj.assert_cache_exists(); prj.assert_artifacts_dir_exists(); @@ -928,16 +1136,34 @@ contract CTest is DSTest { prj.add_source("CTest.t.sol", syntax_err).unwrap(); // `forge build --force` which should fail - cmd.arg("--force"); - cmd.assert_err(); + cmd.forge_fuse().args(["build", "--force"]).assert_failure().stderr_eq(str![[r#" +Error: +Compiler run failed: +Error (2314): Expected ';' but got identifier + [FILE]:7:19: + | +7 | THIS WILL CAUSE AN ERROR + | ^^^^^ + + +"#]]); // but ensure this cleaned cache and artifacts assert!(!prj.paths().artifacts.exists()); assert!(!prj.cache().exists()); // still errors - cmd.forge_fuse().arg("build"); - cmd.assert_err(); + cmd.forge_fuse().args(["build", "--force"]).assert_failure().stderr_eq(str![[r#" +Error: +Compiler run failed: +Error (2314): Expected ';' but got identifier + [FILE]:7:19: + | +7 | THIS WILL CAUSE AN ERROR + | ^^^^^ + + +"#]]); // resolve the error by replacing the file prj.add_source( @@ -953,7 +1179,13 @@ contract CTest is DSTest { ) .unwrap(); - cmd.assert_non_empty_stdout(); + cmd.forge_fuse().args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); + prj.assert_cache_exists(); prj.assert_artifacts_dir_exists(); @@ -962,7 +1194,17 @@ contract CTest is DSTest { // introduce the error again but building without force prj.add_source("CTest.t.sol", syntax_err).unwrap(); - cmd.assert_err(); + cmd.forge_fuse().arg("build").assert_failure().stderr_eq(str![[r#" +Error: +Compiler run failed: +Error (2314): Expected ';' but got identifier + [FILE]:7:19: + | +7 | THIS WILL CAUSE AN ERROR + | ^^^^^ + + +"#]]); // ensure unchanged cache file let cache_after = fs::read_to_string(prj.cache()).unwrap(); @@ -981,8 +1223,15 @@ forgetest!(can_install_and_remove, |prj, cmd| { let forge_std_mod = git_mod.join("forge-std"); let install = |cmd: &mut TestCommand| { - cmd.forge_fuse().args(["install", "foundry-rs/forge-std", "--no-commit"]); - cmd.assert_non_empty_stdout(); + cmd.forge_fuse() + .args(["install", "foundry-rs/forge-std", "--no-commit"]) + .assert_success() + .stdout_eq(str![[r#" +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + +"#]]); + assert!(forge_std.exists()); assert!(forge_std_mod.exists()); @@ -991,8 +1240,14 @@ forgetest!(can_install_and_remove, |prj, cmd| { }; let remove = |cmd: &mut TestCommand, target: &str| { - cmd.forge_fuse().args(["remove", "--force", target]); - cmd.assert_non_empty_stdout(); + // TODO: flaky behavior with URL, sometimes it is None, sometimes it is Some("https://github.com/lib/forge-std") + cmd.forge_fuse().args(["remove", "--force", target]).assert_success().stdout_eq(str![[ + r#" +Removing 'forge-std' in [..], (url: [..], tag: None) + +"# + ]]); + assert!(!forge_std.exists()); assert!(!forge_std_mod.exists()); let submods = read_string(&git_mod_file); @@ -1017,8 +1272,8 @@ forgetest!(can_install_empty, |prj, cmd| { // create initial commit fs::write(prj.root().join("README.md"), "Initial commit").unwrap(); - cmd.git_add().unwrap(); - cmd.git_commit("Initial commit").unwrap(); + cmd.git_add(); + cmd.git_commit("Initial commit"); cmd.forge_fuse().args(["install"]); cmd.assert_empty_stdout(); @@ -1036,8 +1291,15 @@ forgetest!(can_reinstall_after_manual_remove, |prj, cmd| { let forge_std_mod = git_mod.join("forge-std"); let install = |cmd: &mut TestCommand| { - cmd.forge_fuse().args(["install", "foundry-rs/forge-std", "--no-commit"]); - cmd.assert_non_empty_stdout(); + cmd.forge_fuse() + .args(["install", "foundry-rs/forge-std", "--no-commit"]) + .assert_success() + .stdout_eq(str![[r#" +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + +"#]]); + assert!(forge_std.exists()); assert!(forge_std_mod.exists()); @@ -1098,8 +1360,14 @@ forgetest!( let package_mod = git_mod.join("forge-5980-test"); // install main dependency - cmd.forge_fuse().args(["install", "evalir/forge-5980-test", "--no-commit"]); - cmd.assert_non_empty_stdout(); + cmd.forge_fuse() + .args(["install", "evalir/forge-5980-test", "--no-commit"]) + .assert_success() + .stdout_eq(str![[r#" +Installing forge-5980-test in [..] (url: Some("https://github.com/evalir/forge-5980-test"), tag: None) + Installed forge-5980-test + +"#]]); // assert paths exist assert!(package.exists()); @@ -1111,8 +1379,7 @@ forgetest!( // try to update the top-level dependency; there should be no update for this dependency, // but its sub-dependency has upstream (breaking) changes; forge should not attempt to // update the sub-dependency - cmd.forge_fuse().args(["update", "lib/forge-5980-test"]); - cmd.stdout_lossy(); + cmd.forge_fuse().args(["update", "lib/forge-5980-test"]).assert_empty_stdout(); // add explicit remappings for test file let config = Config { @@ -1142,9 +1409,12 @@ contract CounterCopy is Counter { .unwrap(); // build and check output - cmd.forge_fuse().arg("build"); - let output = cmd.stdout_lossy(); - assert!(output.contains("Compiler run successful",)); + cmd.forge_fuse().arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); } ); @@ -1245,23 +1515,36 @@ contract ContractThreeTest is DSTest { gas_reports_ignore: (vec![]), ..Default::default() }); - cmd.forge_fuse(); - let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + + let first_out = cmd + .forge_fuse() + .arg("test") + .arg("--gas-report") + .assert_success() + .get_output() + .stdout_lossy(); assert!(first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); - cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); - cmd.forge_fuse(); - let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let second_out = cmd + .forge_fuse() + .arg("test") + .arg("--gas-report") + .assert_success() + .get_output() + .stdout_lossy(); assert!(second_out.contains("foo") && second_out.contains("bar") && second_out.contains("baz")); - cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); - cmd.forge_fuse(); - let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let third_out = cmd + .forge_fuse() + .arg("test") + .arg("--gas-report") + .assert_success() + .get_output() + .stdout_lossy(); assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); - cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec![ "ContractOne".to_string(), @@ -1270,8 +1553,13 @@ contract ContractThreeTest is DSTest { ]), ..Default::default() }); - cmd.forge_fuse(); - let fourth_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let fourth_out = cmd + .forge_fuse() + .arg("test") + .arg("--gas-report") + .assert_success() + .get_output() + .stdout_lossy(); assert!(fourth_out.contains("foo") && fourth_out.contains("bar") && fourth_out.contains("baz")); }); @@ -1369,7 +1657,8 @@ contract ContractThreeTest is DSTest { // report for One prj.write_config(Config { gas_reports: vec!["ContractOne".to_string()], ..Default::default() }); cmd.forge_fuse(); - let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let first_out = + cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); assert!( first_out.contains("foo") && !first_out.contains("bar") && !first_out.contains("baz"), "foo:\n{first_out}" @@ -1378,7 +1667,8 @@ contract ContractThreeTest is DSTest { // report for Two prj.write_config(Config { gas_reports: vec!["ContractTwo".to_string()], ..Default::default() }); cmd.forge_fuse(); - let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let second_out = + cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); assert!( !second_out.contains("foo") && second_out.contains("bar") && !second_out.contains("baz"), "bar:\n{second_out}" @@ -1390,7 +1680,8 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let third_out = + cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); assert!( !third_out.contains("foo") && !third_out.contains("bar") && third_out.contains("baz"), "baz:\n{third_out}" @@ -1495,7 +1786,8 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let first_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let first_out = + cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); assert!(!first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); // ignore ContractTwo @@ -1506,7 +1798,8 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let second_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let second_out = + cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); assert!( second_out.contains("foo") && !second_out.contains("bar") && second_out.contains("baz") ); @@ -1523,7 +1816,8 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let third_out = cmd.arg("test").arg("--gas-report").stdout_lossy(); + let third_out = + cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); }); @@ -1566,9 +1860,12 @@ forgetest_init!(can_use_absolute_imports, |prj, cmd| { ) .unwrap(); - cmd.arg("build"); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiler run successful")); + cmd.arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); }); // @@ -1609,9 +1906,12 @@ contract MyTest is IMyTest {} ) .unwrap(); - cmd.arg("build"); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiler run successful"), "{stdout}"); + cmd.arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); }); // checks `forge inspect irOptimized works @@ -1621,61 +1921,90 @@ forgetest_init!(can_inspect_ir_optimized, |_prj, cmd| { }); // checks forge bind works correctly on the default project -forgetest_init!(can_bind, |_prj, cmd| { - cmd.arg("bind"); - cmd.assert_non_empty_stdout(); +forgetest_init!(can_bind, |prj, cmd| { + prj.clear(); + + cmd.arg("bind").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Generating bindings for [..] contracts +Bindings have been generated to [..] + +"#]]); }); // checks missing dependencies are auto installed forgetest_init!(can_install_missing_deps_test, |prj, cmd| { + prj.clear(); + // wipe forge-std let forge_std_dir = prj.root().join("lib/forge-std"); pretty_err(&forge_std_dir, fs::remove_dir_all(&forge_std_dir)); - cmd.arg("test"); + cmd.arg("test").assert_success().stdout_eq(str![[r#" +Missing dependencies found. Installing now... + +[UPDATING_DEPENDENCIES] +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 2 tests for test/Counter.t.sol:CounterTest +[PASS] testFuzz_SetNumber(uint256) (runs: 256, [AVG_GAS]) +[PASS] test_Increment() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] - let output = cmd.stdout_lossy(); - assert!(output.contains("Missing dependencies found. Installing now"), "{}", output); - assert!(output.contains("[PASS]"), "{}", output); +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) + +"#]]); }); // checks missing dependencies are auto installed forgetest_init!(can_install_missing_deps_build, |prj, cmd| { + prj.clear(); + // wipe forge-std let forge_std_dir = prj.root().join("lib/forge-std"); pretty_err(&forge_std_dir, fs::remove_dir_all(&forge_std_dir)); - cmd.arg("build"); + // Build the project + cmd.arg("build").assert_success().stdout_eq(str![[r#" +Missing dependencies found. Installing now... + +[UPDATING_DEPENDENCIES] +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); - let output = cmd.stdout_lossy(); - assert!(output.contains("Missing dependencies found. Installing now"), "{output}"); + // Expect compilation to be skipped as no files have changed + cmd.arg("build").assert_success().stdout_eq(str![[r#" +No files changed, compilation skipped - // re-run - let output = cmd.stdout_lossy(); - assert!(!output.contains("Missing dependencies found. Installing now"), "{output}"); - assert!(output.contains("No files changed, compilation skipped"), "{output}"); +"#]]); }); // checks that extra output works forgetest_init!(can_build_skip_contracts, |prj, cmd| { prj.clear(); - // only builds the single template contract `src/*` + // Only builds the single template contract `src/*` cmd.args(["build", "--skip", "tests", "--skip", "scripts"]).assert_success().stdout_eq(str![[ r#" -... -Compiling 1 files [..] -[..] +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] Compiler run successful! -... + "# ]]); - // re-run command - let out = cmd.stdout_lossy(); + // Expect compilation to be skipped as no files have changed + cmd.arg("build").assert_success().stdout_eq(str![[r#" +No files changed, compilation skipped - // unchanged - assert!(out.contains("No files changed, compilation skipped"), "{}", out); +"#]]); }); forgetest_init!(can_build_skip_glob, |prj, cmd| { @@ -1693,7 +2022,7 @@ function test_run() external {} cmd.args(["build", "--skip", "*/test/**", "--skip", "*/script/**", "--force"]) .assert_success() .stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -1703,7 +2032,7 @@ Compiler run successful! .args(["build", "--skip", "./test/**", "--skip", "./script/**", "--force"]) .assert_success() .stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -1740,7 +2069,7 @@ function test_bar() external {} // Build 2 files within test dir prj.clear(); cmd.args(["build", "test", "--force"]).assert_success().stdout_eq(str![[r#" -Compiling 2 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -1750,7 +2079,7 @@ Compiler run successful! prj.clear(); cmd.forge_fuse(); cmd.args(["build", "src", "--force"]).assert_success().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -1760,7 +2089,7 @@ Compiler run successful! prj.clear(); cmd.forge_fuse(); cmd.args(["build", "src", "test", "--force"]).assert_success().stdout_eq(str![[r#" -Compiling 3 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -1770,7 +2099,7 @@ Compiler run successful! prj.clear(); cmd.forge_fuse(); cmd.args(["build", "test/Bar.sol", "--force"]).assert_success().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -1781,45 +2110,44 @@ Compiler run successful! forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { prj.clear_cache(); - cmd.args(["build", "--sizes"]); - let out = cmd.stdout_lossy(); - - // contains: Counter ┆ 0.247 ┆ 24.329 - assert!(out.contains(TEMPLATE_CONTRACT)); + cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +| Contract | Size (B) | Margin (B) | +|----------|----------|------------| +| Counter | 247 | 24,329 | - // get the entire table - let table = out.split("Compiler run successful!").nth(1).unwrap().trim(); - let unchanged = cmd.stdout_lossy(); - assert!(unchanged.contains(table), "{}", table); +"#]]); }); // checks that build --names includes all contracts even if unchanged forgetest_init!(can_build_names_repeatedly, |prj, cmd| { prj.clear_cache(); - cmd.args(["build", "--names"]); - let out = cmd.stdout_lossy(); - - assert!(out.contains(TEMPLATE_CONTRACT)); - - // get the entire list - let list = out.split("Compiler run successful!").nth(1).unwrap().trim(); + cmd.args(["build", "--names"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + compiler version: [..] + - [..] +... - let unchanged = cmd.stdout_lossy(); - assert!(unchanged.contains(list), "{}", list); +"#]]); }); // forgetest_init!(can_inspect_counter_pretty, |prj, cmd| { - cmd.args(["inspect", "src/Counter.sol:Counter", "abi", "--pretty"]); - let output = cmd.stdout_lossy(); - assert_eq!( - output.trim(), - "interface Counter { + cmd.args(["inspect", "src/Counter.sol:Counter", "abi", "--pretty"]).assert_success().stdout_eq( + str![[r#" +interface Counter { function increment() external; function number() external view returns (uint256); function setNumber(uint256 newNumber) external; -}" +} + + +"#]], ); }); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 88ac186b20cb7..2cb11e72f1861 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -14,7 +14,7 @@ use foundry_config::{ use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ foundry_compilers::artifacts::{remappings::Remapping, EvmVersion}, - util::{pretty_err, TestCommand, OTHER_SOLC_VERSION}, + util::{pretty_err, OutputExt, TestCommand, OTHER_SOLC_VERSION}, }; use path_slash::PathBufExt; use similar_asserts::assert_eq; @@ -160,10 +160,10 @@ forgetest!(can_extract_config_values, |prj, cmd| { // tests config gets printed to std out forgetest!(can_show_config, |prj, cmd| { - cmd.arg("config"); let expected = Config::load_with_root(prj.root()).to_string_pretty().unwrap().trim().to_string(); - assert_eq!(expected, cmd.stdout_lossy().trim().to_string()); + let output = cmd.arg("config").assert_success().get_output().stdout_lossy().trim().to_string(); + assert_eq!(expected, output); }); // checks that config works @@ -188,9 +188,9 @@ forgetest_init!(can_override_config, |prj, cmd| { Remapping::from(profile.remappings[0].clone()).to_string() ); - cmd.arg("config"); - let expected = profile.to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + let expected = profile.to_string_pretty().unwrap().trim().to_string(); + let output = cmd.arg("config").assert_success().get_output().stdout_lossy().trim().to_string(); + assert_eq!(expected, output); // remappings work let remappings_txt = @@ -236,9 +236,16 @@ forgetest_init!(can_override_config, |prj, cmd| { std::env::remove_var("DAPP_REMAPPINGS"); pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); - cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); - let expected = profile.into_basic().to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + let expected = profile.into_basic().to_string_pretty().unwrap().trim().to_string(); + let output = cmd + .forge_fuse() + .args(["config", "--basic"]) + .assert_success() + .get_output() + .stdout_lossy() + .trim() + .to_string(); + assert_eq!(expected, output); }); forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { @@ -255,13 +262,18 @@ forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { // the loaded config has resolved, absolute paths assert_eq!("forge-std/=lib/forge-std/src/", Remapping::from(r.clone()).to_string()); - cmd.arg("config"); - let expected = profile.to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + let expected = profile.to_string_pretty().unwrap().trim().to_string(); + let output = cmd.arg("config").assert_success().get_output().stdout_lossy().trim().to_string(); + assert_eq!(expected, output); let install = |cmd: &mut TestCommand, dep: &str| { - cmd.forge_fuse().args(["install", dep, "--no-commit"]); - cmd.assert_non_empty_stdout(); + cmd.forge_fuse().args(["install", dep, "--no-commit"]).assert_success().stdout_eq(str![[ + r#" +Installing solmate in [..] (url: Some("https://github.com/transmissions11/solmate"), tag: None) + Installed solmate + +"# + ]]); }; install(&mut cmd, "transmissions11/solmate"); @@ -288,9 +300,16 @@ forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { ); pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); - cmd.set_cmd(prj.forge_bin()).args(["config", "--basic"]); - let expected = profile.into_basic().to_string_pretty().unwrap(); - assert_eq!(expected.trim().to_string(), cmd.stdout_lossy().trim().to_string()); + let expected = profile.into_basic().to_string_pretty().unwrap().trim().to_string(); + let output = cmd + .forge_fuse() + .args(["config", "--basic"]) + .assert_success() + .get_output() + .stdout_lossy() + .trim() + .to_string(); + assert_eq!(expected, output); }); forgetest_init!(can_detect_config_vals, |prj, _cmd| { @@ -348,9 +367,12 @@ contract Greeter {} let config = Config { solc: Some(OTHER_SOLC_VERSION.into()), ..Default::default() }; prj.write_config(config); - cmd.arg("build"); + cmd.arg("build").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! - assert!(cmd.stdout_lossy().contains("Compiler run successful!")); +"#]]); }); // tests that `--use ` works @@ -364,25 +386,45 @@ contract Foo {} ) .unwrap(); - cmd.args(["build", "--use", OTHER_SOLC_VERSION]); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiler run successful")); + cmd.args(["build", "--use", OTHER_SOLC_VERSION]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); cmd.forge_fuse() .args(["build", "--force", "--use", &format!("solc:{OTHER_SOLC_VERSION}")]) - .root_arg(); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiler run successful")); + .root_arg() + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); // fails to use solc that does not exist cmd.forge_fuse().args(["build", "--use", "this/solc/does/not/exist"]); - assert!(cmd.stderr_lossy().contains("`solc` this/solc/does/not/exist does not exist")); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +`solc` this/solc/does/not/exist does not exist + +"#]]); // `OTHER_SOLC_VERSION` was installed in previous step, so we can use the path to this directly let local_solc = Solc::find_or_install(&OTHER_SOLC_VERSION.parse().unwrap()).unwrap(); - cmd.forge_fuse().args(["build", "--force", "--use"]).arg(local_solc.solc).root_arg(); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("Compiler run successful")); + cmd.forge_fuse() + .args(["build", "--force", "--use"]) + .arg(local_solc.solc) + .root_arg() + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); }); // test to ensure yul optimizer can be set as intended @@ -571,8 +613,13 @@ forgetest!(can_update_libs_section, |prj, cmd| { let init = Config { libs: vec!["node_modules".into()], ..Default::default() }; prj.write_config(init); - cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]); - cmd.assert_non_empty_stdout(); + cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]).assert_success().stdout_eq(str![ + [r#" +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + +"#] + ]); let config = cmd.forge_fuse().config(); // `lib` was added automatically @@ -580,8 +627,14 @@ forgetest!(can_update_libs_section, |prj, cmd| { assert_eq!(config.libs, expected); // additional install don't edit `libs` - cmd.forge_fuse().args(["install", "dapphub/ds-test", "--no-commit"]); - cmd.assert_non_empty_stdout(); + cmd.forge_fuse() + .args(["install", "dapphub/ds-test", "--no-commit"]) + .assert_success() + .stdout_eq(str![[r#" +Installing ds-test in [..] (url: Some("https://github.com/dapphub/ds-test"), tag: None) + Installed ds-test + +"#]]); let config = cmd.forge_fuse().config(); assert_eq!(config.libs, expected); @@ -592,8 +645,13 @@ forgetest!(can_update_libs_section, |prj, cmd| { forgetest!(config_emit_warnings, |prj, cmd| { cmd.git_init(); - cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]); - cmd.assert_non_empty_stdout(); + cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]).assert_success().stdout_eq(str![ + [r#" +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + +"#] + ]); let faulty_toml = r"[default] src = 'src' @@ -603,16 +661,12 @@ forgetest!(config_emit_warnings, |prj, cmd| { fs::write(prj.root().join("foundry.toml"), faulty_toml).unwrap(); fs::write(prj.root().join("lib").join("forge-std").join("foundry.toml"), faulty_toml).unwrap(); - cmd.forge_fuse().args(["config"]); - let output = cmd.execute(); - assert!(output.status.success()); - assert_eq!( - String::from_utf8_lossy(&output.stderr) - .lines() - .filter(|line| line.contains("unknown config section") && line.contains("[default]")) - .count(), - 1, - ); + cmd.forge_fuse().args(["config"]).assert_success().stderr_eq(str![[r#" +warning: Found unknown config section in foundry.toml: [default] +This notation for profiles has been deprecated and may result in the profile not being registered in future versions. +Please use [profile.default] instead or run `forge config --fix`. + +"#]]); }); forgetest_init!(can_skip_remappings_auto_detection, |prj, cmd| { @@ -705,8 +759,11 @@ forgetest_init!(can_resolve_symlink_fs_permissions, |prj, cmd| { // tests if evm version is normalized for config output forgetest!(normalize_config_evm_version, |_prj, cmd| { - cmd.args(["config", "--use", "0.8.0", "--json"]); - let output = cmd.stdout_lossy(); + let output = cmd + .args(["config", "--use", "0.8.0", "--json"]) + .assert_success() + .get_output() + .stdout_lossy(); let config: Config = serde_json::from_str(&output).unwrap(); assert_eq!(config.evm_version, EvmVersion::Istanbul); }); diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index c7071dcf586fa..ebf8c81dbcc1e 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -10,7 +10,7 @@ use foundry_compilers::artifacts::{remappings::Remapping, BytecodeHash}; use foundry_config::Config; use foundry_test_utils::{ forgetest, forgetest_async, str, - util::{TestCommand, TestProject}, + util::{OutputExt, TestCommand, TestProject}, }; use std::str::FromStr; @@ -104,12 +104,16 @@ where { if let Some(info) = info { let contract_path = f(&prj); - cmd.arg("create"); - cmd.args(info.create_args()).arg(contract_path); - let out = cmd.stdout_lossy(); - let _address = utils::parse_deployed_address(out.as_str()) - .unwrap_or_else(|| panic!("Failed to parse deployer {out}")); + let output = cmd + .arg("create") + .args(info.create_args()) + .arg(contract_path) + .assert_success() + .get_output() + .stdout_lossy(); + let _address = utils::parse_deployed_address(output.as_str()) + .unwrap_or_else(|| panic!("Failed to parse deployer {output}")); } } @@ -151,7 +155,7 @@ forgetest_async!(can_create_template_contract, |prj, cmd| { ]); cmd.assert().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 @@ -192,7 +196,7 @@ forgetest_async!(can_create_using_unlocked, |prj, cmd| { ]); cmd.assert().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 @@ -249,7 +253,7 @@ contract ConstructorContract { ]) .assert_success() .stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 @@ -286,7 +290,7 @@ contract TupleArrayConstructorContract { ]) .assert() .stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 @@ -323,15 +327,29 @@ contract UniswapV2Swap { ) .unwrap(); - cmd.forge_fuse().args([ - "create", - "./src/UniswapV2Swap.sol:UniswapV2Swap", - "--rpc-url", - rpc.as_str(), - "--private-key", - pk.as_str(), - ]); + cmd.forge_fuse() + .args([ + "create", + "./src/UniswapV2Swap.sol:UniswapV2Swap", + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (2018): Function state mutability can be restricted to pure + [FILE]:6:5: + | +6 | function pairInfo() public view returns (uint reserveA, uint reserveB, uint totalSupply) { + | ^ (Relevant source part starts here and spans across multiple lines). - let (stdout, _) = cmd.output_lossy(); - assert!(stdout.contains("Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3")); +Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 +Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +[TX_HASH] + +"#]]); }); diff --git a/crates/forge/tests/cli/debug.rs b/crates/forge/tests/cli/debug.rs index 3e3d08c7e2ad7..8ee1eb3f27753 100644 --- a/crates/forge/tests/cli/debug.rs +++ b/crates/forge/tests/cli/debug.rs @@ -7,8 +7,14 @@ forgetest_async!( #[ignore = "ran manually"] manual_debug_setup, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()).assert_non_empty_stdout(); - cmd.forge_fuse(); + cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); prj.add_source("Counter2.sol", r#" contract A { @@ -74,8 +80,7 @@ contract Script0 is Script, Test { ) .unwrap(); - cmd.args(["build"]).assert_success(); - cmd.forge_fuse(); + cmd.forge_fuse().args(["build"]).assert_success(); cmd.args([ "script", diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 2b92559f2da91..6ef99d9d11bde 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -54,7 +54,7 @@ contract Demo { .unwrap(); cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Script ran successfully. @@ -113,7 +113,7 @@ contract Demo { cmd.arg("script").arg(script).arg("--sig").arg("myFunction()").assert_success().stdout_eq( str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Script ran successfully. @@ -145,10 +145,11 @@ forgetest_async!(assert_exit_code_error_on_failure_script, |prj, cmd| { cmd.arg("script").arg(script); // run command and assert error exit code - cmd.assert_err(); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +script failed: revert: failed - let output = cmd.stderr_lossy(); - assert!(output.contains("script failed: revert: failed")); +"#]]); }); // Tests that execution throws upon encountering a revert in the script with --json option. @@ -161,10 +162,11 @@ forgetest_async!(assert_exit_code_error_on_failure_script_with_json, |prj, cmd| cmd.arg("script").arg(script).arg("--json"); // run command and assert error exit code - cmd.assert_err(); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +script failed: revert: failed - let output = cmd.stderr_lossy(); - assert!(output.contains("script failed: revert: failed")); +"#]]); }); // Tests that the manually specified gas limit is used when using the --unlocked option @@ -182,7 +184,7 @@ contract GasWaster { } } contract DeployScript is Script { - function run() external returns (uint256 result, uint8) { + function run() external { vm.startBroadcast(); GasWaster gasWaster = new GasWaster(); gasWaster.wasteGas{gas: 500000}(200000); @@ -213,11 +215,66 @@ contract DeployScript is Script { "--slow", "--broadcast", "--unlocked", - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (2018): Function state mutability can be restricted to view + [FILE]:7:5: + | +7 | function wasteGas(uint256 minGas) public { + | ^ (Relevant source part starts here and spans across multiple lines). + +Traces: + [81040] DeployScript::run() + ├─ [0] VM::startBroadcast() + │ └─ ← [Return] + ├─ [45299] → new GasWaster@[..] + │ └─ ← [Return] 226 bytes of code + ├─ [226] GasWaster::wasteGas(200000 [2e5]) + │ └─ ← [Stop] + └─ ← [Stop] + + +Script ran successfully. + +## Setting up 1 EVM. +========================== +Simulated On-chain Traces: + +Gas limit was set in script to 500000 + [45299] → new GasWaster@[..] + └─ ← [Return] 226 bytes of code + + [226] GasWaster::wasteGas(200000 [2e5]) + └─ ← [Stop] + + +========================== + +Chain 1 + +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] - let output = cmd.stdout_lossy(); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); - assert!(output.contains("Gas limit was set in script to 500000")); +========================== + + +========================== + +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); }); // Tests that the manually specified gas limit is used. @@ -235,7 +292,7 @@ contract GasWaster { } } contract DeployScript is Script { - function run() external returns (uint256 result, uint8) { + function run() external { vm.startBroadcast(); GasWaster gasWaster = new GasWaster(); gasWaster.wasteGas{gas: 500000}(200000); @@ -266,11 +323,66 @@ contract DeployScript is Script { "--broadcast", "--private-key", &private_key, - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (2018): Function state mutability can be restricted to view + [FILE]:7:5: + | +7 | function wasteGas(uint256 minGas) public { + | ^ (Relevant source part starts here and spans across multiple lines). + +Traces: + [81040] DeployScript::run() + ├─ [0] VM::startBroadcast() + │ └─ ← [Return] + ├─ [45299] → new GasWaster@[..] + │ └─ ← [Return] 226 bytes of code + ├─ [226] GasWaster::wasteGas(200000 [2e5]) + │ └─ ← [Stop] + └─ ← [Stop] + + +Script ran successfully. + +## Setting up 1 EVM. +========================== +Simulated On-chain Traces: + +Gas limit was set in script to 500000 + [45299] → new GasWaster@[..] + └─ ← [Return] 226 bytes of code + + [226] GasWaster::wasteGas(200000 [2e5]) + └─ ← [Stop] - let output = cmd.stdout_lossy(); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); - assert!(output.contains("Gas limit was set in script to 500000")); + +========================== + +Chain 1 + +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + + +========================== + +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); }); // Tests that the run command can run functions with arguments @@ -300,7 +412,7 @@ contract Demo { .arg("2") .assert_success() .stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Script ran successfully. @@ -331,7 +443,7 @@ contract Demo { .unwrap(); cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Script ran successfully. @@ -358,20 +470,24 @@ import "forge-std/Script.sol"; contract HashChecker { bytes32 public lastHash; + function update() public { bytes32 newHash = blockhash(block.number - 1); require(newHash != lastHash, "Hash didn't change"); lastHash = newHash; } - function checkLastHash() public { + function checkLastHash() public view { require(lastHash != bytes32(0), "Hash shouldn't be zero"); } } + contract DeployScript is Script { - function run() external returns (uint256 result, uint8) { + HashChecker public hashChecker; + + function run() external { vm.startBroadcast(); - HashChecker hashChecker = new HashChecker(); + hashChecker = new HashChecker(); } }"#, ) @@ -399,12 +515,36 @@ contract DeployScript is Script { "--skip-simulation", "--private-key", &private_key, - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Traces: + [116040] DeployScript::run() + ├─ [0] VM::startBroadcast() + │ └─ ← [Return] + ├─ [75723] → new HashChecker@[..] + │ └─ ← [Return] 378 bytes of code + └─ ← [Stop] + + +Script ran successfully. + +SKIPPING ON CHAIN SIMULATION. + - let output = cmd.stdout_lossy(); +========================== - assert!(output.contains("SKIPPING ON CHAIN SIMULATION")); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); let run_log = std::fs::read_to_string("broadcast/DeployScript.sol/1/run-latest.json").unwrap(); let run_object: Value = serde_json::from_str(&run_log).unwrap(); @@ -420,9 +560,11 @@ import "forge-std/Script.sol"; import { HashChecker } from "./DeployScript.sol"; contract RunScript is Script { - function run() external returns (uint256 result, uint8) { + HashChecker public hashChecker; + + function run() external { vm.startBroadcast(); - HashChecker hashChecker = HashChecker(CONTRACT_ADDRESS); + hashChecker = HashChecker(CONTRACT_ADDRESS); uint numUpdates = 8; vm.roll(block.number - numUpdates); for(uint i = 0; i < numUpdates; i++) { @@ -437,28 +579,100 @@ contract RunScript is Script { let run_script = prj.add_source("RunScript", &run_code).unwrap(); let run_contract = run_script.display().to_string() + ":RunScript"; - cmd.forge_fuse(); - cmd.set_current_dir(prj.root()); - cmd.args([ - "script", - &run_contract, - "--root", - prj.root().to_str().unwrap(), - "--fork-url", - &handle.http_endpoint(), - "-vvvvv", - "--broadcast", - "--slow", - "--skip-simulation", - "--gas-estimate-multiplier", - "200", - "--private-key", - &private_key, - ]); + cmd.forge_fuse() + .args([ + "script", + &run_contract, + "--root", + prj.root().to_str().unwrap(), + "--fork-url", + &handle.http_endpoint(), + "-vvvvv", + "--broadcast", + "--slow", + "--skip-simulation", + "--gas-estimate-multiplier", + "200", + "--private-key", + &private_key, + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Traces: + [51327] RunScript::run() + ├─ [0] VM::startBroadcast() + │ └─ ← [Return] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [22394] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [494] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [494] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [494] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [494] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [494] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [494] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + ├─ [0] VM::roll([..]) + │ └─ ← [Return] + ├─ [494] [..]::update() + │ └─ ← [Stop] + ├─ [239] [..]::checkLastHash() [staticcall] + │ └─ ← [Stop] + └─ ← [Stop] - let output = cmd.stdout_lossy(); - assert!(output.contains("SKIPPING ON CHAIN SIMULATION")); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); + +Script ran successfully. + +SKIPPING ON CHAIN SIMULATION. + + +========================== + +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); }); forgetest_async!(can_deploy_script_without_lib, |prj, cmd| { @@ -801,12 +1015,17 @@ struct Transaction { // test we output arguments forgetest_async!(can_execute_script_with_arguments, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); + cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); let (_api, handle) = spawn(NodeConfig::test()).await; - let script = prj .add_script( + let script = prj.add_script( "Counter.s.sol", r#" import "forge-std/Script.sol"; @@ -822,6 +1041,9 @@ contract A { int c; bytes32 d; bool e; + bytes f; + Point g; + string h; constructor(address _a, uint _b, int _c, bytes32 _d, bool _e, bytes memory _f, Point memory _g, string memory _h) { a = _a; @@ -829,6 +1051,9 @@ contract A { c = _c; d = _d; e = _e; + f = _f; + g = _g; + h = _h; } } @@ -843,16 +1068,48 @@ contract Script0 is Script { ) .unwrap(); - cmd.arg("script").arg(script).args([ - "--tc", - "Script0", - "--sender", - "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", - "--rpc-url", - handle.http_endpoint().as_str(), - ]); + cmd + .forge_fuse() + .arg("script") + .arg(script) + .args([ + "--tc", + "Script0", + "--sender", + "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", + "--rpc-url", + handle.http_endpoint().as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +... +Script ran successfully. + +## Setting up 1 EVM. + +========================== - assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); +Chain 31337 + +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + +SIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); let run_latest = foundry_common::fs::json_files(&prj.root().join("broadcast")) .find(|path| path.ends_with("run-latest.json")) @@ -880,9 +1137,14 @@ contract Script0 is Script { // test we output arguments forgetest_async!(can_execute_script_with_arguments_nested_deploy, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); + cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); let (_api, handle) = spawn(NodeConfig::test()).await; let script = prj @@ -927,16 +1189,48 @@ contract Script0 is Script { ) .unwrap(); - cmd.arg("script").arg(script).args([ - "--tc", - "Script0", - "--sender", - "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", - "--rpc-url", - handle.http_endpoint().as_str(), - ]); + cmd + .forge_fuse() + .arg("script") + .arg(script) + .args([ + "--tc", + "Script0", + "--sender", + "0x00a329c0648769A73afAc7F9381E08FB43dBEA72", + "--rpc-url", + handle.http_endpoint().as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +... +Script ran successfully. + +## Setting up 1 EVM. + +========================== + +Chain 31337 + +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] - assert!(cmd.stdout_lossy().contains("SIMULATION COMPLETE")); +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + +SIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); let run_latest = foundry_common::fs::json_files(&prj.root().join("broadcast")) .find(|file| file.ends_with("run-latest.json")) @@ -981,7 +1275,7 @@ contract Demo { .args(["--skip", "tests", "--skip", TEMPLATE_CONTRACT]) .assert_success() .stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! Script ran successfully. @@ -1010,9 +1304,14 @@ forgetest_async!(does_script_override_correctly, |prj, cmd| { }); forgetest_async!(assert_tx_origin_is_not_overritten, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); + cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); let script = prj .add_script( @@ -1068,14 +1367,32 @@ contract ContractC { ) .unwrap(); - cmd.arg("script").arg(script).args(["--tc", "ScriptTxOrigin"]); - assert!(cmd.stdout_lossy().contains("Script ran successfully.")); + cmd.forge_fuse() + .arg("script") + .arg(script) + .args(["--tc", "ScriptTxOrigin"]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Script ran successfully. +[GAS] + +If you wish to simulate on-chain transactions pass a RPC URL. + +"#]]); }); forgetest_async!(assert_can_create_multiple_contracts_with_correct_nonce, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); + cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); let script = prj .add_script( @@ -1088,18 +1405,20 @@ contract Contract { console.log(tx.origin); } } + contract SubContract { constructor() { console.log(tx.origin); } } + contract BadContract { constructor() { - // new SubContract(); + new SubContract(); console.log(tx.origin); } } -contract NestedCreateFail is Script { +contract NestedCreate is Script { function run() public { address sender = address(uint160(uint(keccak256("woops")))); @@ -1114,8 +1433,26 @@ contract NestedCreateFail is Script { ) .unwrap(); - cmd.arg("script").arg(script).args(["--tc", "NestedCreateFail"]); - assert!(cmd.stdout_lossy().contains("Script ran successfully.")); + cmd.forge_fuse() + .arg("script") + .arg(script) + .args(["--tc", "NestedCreate"]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Script ran successfully. +[GAS] + +== Logs == + 0x159E2f2F1C094625A2c6c8bF59526d91454c2F3c + 0x159E2f2F1C094625A2c6c8bF59526d91454c2F3c + 0x159E2f2F1C094625A2c6c8bF59526d91454c2F3c + +If you wish to simulate on-chain transactions pass a RPC URL. + +"#]]); }); forgetest_async!(assert_can_detect_target_contract_with_interfaces, |prj, cmd| { @@ -1132,8 +1469,14 @@ interface Interface {} ) .unwrap(); - cmd.arg("script").arg(script); - assert!(cmd.stdout_lossy().contains("Script ran successfully.")); + cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Script ran successfully. +[GAS] + +"#]]); }); forgetest_async!(assert_can_detect_unlinked_target_with_libraries, |prj, cmd| { @@ -1154,8 +1497,16 @@ contract Script { ) .unwrap(); - cmd.arg("script").arg(script); - assert!(cmd.stdout_lossy().contains("Script ran successfully.")); + cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Script ran successfully. +[GAS] + +If you wish to simulate on-chain transactions pass a RPC URL. + +"#]]); }); forgetest_async!(assert_can_resume_with_additional_contracts, |prj, cmd| { @@ -1239,7 +1590,7 @@ forgetest_async!(can_sign_with_script_wallet_multiple, |prj, cmd| { forgetest_async!(fails_with_function_name_and_overloads, |prj, cmd| { let script = prj .add_script( - "Sctipt.s.sol", + "Script.s.sol", r#" contract Script { function run() external {} @@ -1251,13 +1602,22 @@ contract Script { .unwrap(); cmd.arg("script").args([&script.to_string_lossy(), "--sig", "run"]); - assert!(cmd.stderr_lossy().contains("Multiple functions with the same name")); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +Multiple functions with the same name `run` found in the ABI + +"#]]); }); forgetest_async!(can_decode_custom_errors, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()); - cmd.assert_non_empty_stdout(); - cmd.forge_fuse(); + cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" +Target directory is not empty, but `--force` was specified +Initializing [..]... +Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) + Installed forge-std [..] + Initialized forge project + +"#]]); let script = prj .add_script( @@ -1284,8 +1644,12 @@ contract CustomErrorScript is Script { ) .unwrap(); - cmd.arg("script").arg(script).args(["--tc", "CustomErrorScript"]); - assert!(cmd.stderr_lossy().contains("script failed: CustomError()")); + cmd.forge_fuse().arg("script").arg(script).args(["--tc", "CustomErrorScript"]); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +script failed: CustomError() + +"#]]); }); // https://github.com/foundry-rs/foundry/issues/7620 @@ -1297,9 +1661,9 @@ forgetest_async!(can_run_zero_base_fee, |prj, cmd| { import "forge-std/Script.sol"; contract SimpleScript is Script { - function run() external { + function run() external returns (bool success) { vm.startBroadcast(); - address(0).call(""); + (success, ) = address(0).call(""); } } "#, @@ -1325,25 +1689,90 @@ contract SimpleScript is Script { "2000000", "--priority-gas-price", "100000", - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +... +Script ran successfully. + +== Return == +success: bool true + +## Setting up 1 EVM. + +========================== + +Chain 31337 - let output = cmd.stdout_lossy(); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + + +========================== + +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); // Ensure that we can correctly estimate gas when base fee is zero but priority fee is not. - cmd.forge_fuse().args([ - "script", - "SimpleScript", - "--fork-url", - &handle.http_endpoint(), - "--sender", - format!("{dev:?}").as_str(), - "--broadcast", - "--unlocked", - ]); + cmd.forge_fuse() + .args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--sender", + format!("{dev:?}").as_str(), + "--broadcast", + "--unlocked", + ]) + .assert_success() + .stdout_eq(str![[r#" +No files changed, compilation skipped +... +Script ran successfully. + +== Return == +success: bool true + +## Setting up 1 EVM. + +========================== + +Chain 31337 + +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + + +========================== - let output = cmd.stdout_lossy(); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); }); // https://github.com/foundry-rs/foundry/pull/7742 @@ -1355,9 +1784,9 @@ forgetest_async!(unlocked_no_sender, |prj, cmd| { import "forge-std/Script.sol"; contract SimpleScript is Script { - function run() external { + function run() external returns (bool success) { vm.startBroadcast(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - address(0).call(""); + (success, ) = address(0).call(""); } } "#, @@ -1373,10 +1802,43 @@ contract SimpleScript is Script { &handle.http_endpoint(), "--broadcast", "--unlocked", - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +... +Script ran successfully. + +== Return == +success: bool true + +## Setting up 1 EVM. + +========================== + +Chain 31337 + +[ESTIMATED_GAS_PRICE] - let output = cmd.stdout_lossy(); - assert!(output.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL")); +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + + +========================== + +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); }); // https://github.com/foundry-rs/foundry/issues/7833 @@ -1411,8 +1873,11 @@ contract SimpleScript is Script { "--unlocked", ]); - let output = cmd.stderr_lossy(); - assert!(output.contains("missing CREATE2 deployer")); + cmd.assert_failure().stderr_eq(str![[r#" +Error: +script failed: missing CREATE2 deployer + +"#]]); }); forgetest_async!(can_switch_forks_in_setup, |prj, cmd| { @@ -1450,9 +1915,21 @@ contract SimpleScript is Script { &url, "--sender", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - ]); + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (2018): Function state mutability can be restricted to view + [FILE]:13:5: + | +13 | function run() external { + | ^ (Relevant source part starts here and spans across multiple lines). + +Script ran successfully. - cmd.stdout_lossy(); +"#]]); }); // Asserts that running the same script twice only deploys library once. diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index bacf47230ba69..21666edbb493b 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -7,14 +7,17 @@ use std::{ use foundry_test_utils::forgesoldeer; use std::io::Write; + forgesoldeer!(install_dependency, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; let foundry_file = prj.root().join("foundry.toml"); - cmd.arg("soldeer").args([command, dependency]); - cmd.execute(); + cmd.arg("soldeer").args([command, dependency]).assert_success().stdout_eq(str![[r#" +🦌 Running [..]oldeer install 🦌 +... +"#]]); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -53,8 +56,10 @@ forgesoldeer!(install_dependency_git, |prj, cmd| { let foundry_file = prj.root().join("foundry.toml"); - cmd.arg("soldeer").args([command, dependency, git]); - cmd.execute(); + cmd.arg("soldeer").args([command, dependency, git]).assert_success().stdout_eq(str![[r#" +🦌 Running [..]oldeer install 🦌 +... +"#]]); // Making sure the path was created to the dependency and that README.md exists // meaning that the dependencies were installed correctly @@ -93,8 +98,13 @@ forgesoldeer!(install_dependency_git_commit, |prj, cmd| { let foundry_file = prj.root().join("foundry.toml"); - cmd.arg("soldeer").args([command, dependency, git, rev_flag, commit]); - cmd.execute(); + cmd.arg("soldeer") + .args([command, dependency, git, rev_flag, commit]) + .assert_success() + .stdout_eq(str![[r#" +🦌 Running [..]oldeer install 🦌 +... +"#]]); // Making sure the path was created to the dependency and that README.md exists // meaning that the dependencies were installed correctly @@ -147,8 +157,11 @@ mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/ eprintln!("Couldn't write to file: {e}"); } - cmd.arg("soldeer").arg(command); - cmd.execute(); + cmd.arg("soldeer").arg(command).assert_success().stdout_eq(str![[r#" +🦌 Running [..]oldeer update 🦌 +... + +"#]]); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -216,8 +229,11 @@ forge-std = "1.8.1" eprintln!("Couldn't write to file: {e}"); } - cmd.arg("soldeer").arg(command); - cmd.execute(); + cmd.arg("soldeer").arg(command).assert_success().stdout_eq(str![[r#" +🦌 Running [..]oldeer update 🦌 +... + +"#]]); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -252,12 +268,20 @@ forge-std = "1.8.1" forgesoldeer!(login, |prj, cmd| { let command = "login"; - cmd.arg("soldeer").arg(command); - let output = cmd.unchecked_output(); - - // On login, we can only check if the prompt is displayed in the stdout - let stdout = String::from_utf8(output.stdout).expect("Could not parse the output"); - assert!(stdout.contains("Please enter your email")); + cmd.arg("soldeer") + .arg(command) + .assert_failure() + .stderr_eq(str![[r#" +Error: +Failed to run [..] + +"#]]) + .stdout_eq(str![[r#" +🦌 Running [..]oldeer login 🦌 +... +ℹ️ If you do not have an account, please go to soldeer.xyz to create one. +📧 Please enter your email: +"#]]); }); forgesoldeer!(install_dependency_with_remappings_config, |prj, cmd| { diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index 8403053d84d6a..ab8db41f8a8b0 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -57,5 +57,18 @@ contract CounterTest is Test {{ "# ); prj.add_test("Counter", &src).unwrap(); - cmd.arg("test").stdout_lossy().contains("[PASS]"); + cmd.arg("test").assert_success().stdout_eq(str![[r#" +... +Ran 1 test for test/Counter.sol:CounterTest +[PASS] testAssert() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +... +Ran 2 tests for test/Counter.t.sol:CounterTest +[PASS] testFuzz_SetNumber(uint256) (runs: 256, [AVG_GAS]) +[PASS] test_Increment() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 2 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) + +"#]]); }); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 391de7a28d6c3..23ffa890d6030 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -4,7 +4,7 @@ use alloy_primitives::U256; use foundry_config::{Config, FuzzConfig}; use foundry_test_utils::{ rpc, str, - util::{OTHER_SOLC_VERSION, SOLC_VERSION}, + util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, }; use similar_asserts::assert_eq; use std::{path::PathBuf, str::FromStr}; @@ -128,7 +128,7 @@ forgetest!(can_fuzz_array_params, |prj, cmd| { r#" import "./test.sol"; contract ATest is DSTest { - function testArray(uint64[2] calldata values) external { + function testArray(uint64[2] calldata) external { assertTrue(true); } } @@ -136,8 +136,18 @@ contract ATest is DSTest { ) .unwrap(); - cmd.arg("test"); - cmd.stdout_lossy().contains("[PASS]"); + cmd.arg("test").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for src/ATest.t.sol:ATest +[PASS] testArray(uint64[2]) (runs: 256, [AVG_GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // tests that `bytecode_hash` will be sanitized @@ -151,7 +161,7 @@ forgetest!(can_test_pre_bytecode_hash, |prj, cmd| { pragma solidity 0.5.17; import "./test.sol"; contract ATest is DSTest { - function testArray(uint64[2] calldata values) external { + function testArray(uint64[2] calldata) external { assertTrue(true); } } @@ -159,8 +169,18 @@ contract ATest is DSTest { ) .unwrap(); - cmd.arg("test"); - cmd.stdout_lossy().contains("[PASS]"); + cmd.arg("test").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for src/ATest.t.sol:ATest +[PASS] testArray(uint64[2]) (runs: 256, [AVG_GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // tests that using the --match-path option only runs files matching the path @@ -194,7 +214,7 @@ contract FailTest is DSTest { .unwrap(); cmd.args(["test", "--match-path", "*src/ATest.t.sol"]).assert_success().stdout_eq(str![[r#" -Compiling 3 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -241,7 +261,7 @@ contract FailTest is DSTest { let test_path = test_path.to_string_lossy(); cmd.args(["test", "--match-path", test_path.as_ref()]).assert_success().stdout_eq(str![[r#" -Compiling 3 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -278,7 +298,7 @@ contract MyTest is DSTest { .unwrap(); cmd.arg("test").assert_success().stdout_eq(str![[r#" -Compiling 2 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -293,9 +313,22 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // checks that forge test repeatedly produces the same output #[cfg(not(feature = "isolate-by-default"))] -forgetest_init!(can_test_repeatedly, |_prj, cmd| { - cmd.arg("test"); - cmd.assert_non_empty_stdout(); +forgetest_init!(can_test_repeatedly, |prj, cmd| { + prj.clear(); + + cmd.arg("test").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 2 tests for test/Counter.t.sol:CounterTest +[PASS] testFuzz_SetNumber(uint256) (runs: 256, [AVG_GAS]) +[PASS] test_Increment() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) + +"#]]); for _ in 0..5 { cmd.assert_success().stdout_eq(str![[r#" @@ -339,7 +372,7 @@ contract ContractTest is DSTest { prj.write_config(config); cmd.arg("test").assert_success().stdout_eq(str![[r#" -Compiling 2 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -356,7 +389,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) prj.write_config(config); cmd.forge_fuse().arg("test").assert_success().stdout_eq(str![[r#" -Compiling 2 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -417,7 +450,7 @@ contract ContractTest is Test { .unwrap(); cmd.arg("test").assert_success().stdout_eq(str![[r#" -Compiling 2 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -448,7 +481,7 @@ forgetest_init!(exit_code_error_on_fail_fast, |prj, cmd| { cmd.args(["test", "--fail-fast"]); // run command and assert error exit code - cmd.assert_err(); + cmd.assert_empty_stderr(); }); forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { @@ -459,7 +492,7 @@ forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { cmd.args(["test", "--fail-fast", "--json"]); // run command and assert error exit code - cmd.assert_err(); + cmd.assert_empty_stderr(); }); // https://github.com/foundry-rs/foundry/pull/6531 @@ -489,7 +522,7 @@ contract USDTCallingTest is Test { .unwrap(); cmd.args(["test", "-vvvv"]).assert_success().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -535,7 +568,7 @@ contract CustomTypesTest is Test { .unwrap(); cmd.args(["test", "-vvvv"]).assert_failure().stdout_eq(str![[r#" -Compiling 1 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -738,7 +771,7 @@ contract CounterTest is Test { // make sure there are only 61 runs (with proptest shrinking same test results in 298 runs) cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" -Compiling 23 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -789,7 +822,7 @@ contract CounterTest is Test { // make sure invariant test exit early with 0 runs cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" -Compiling 23 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -836,8 +869,29 @@ contract ReplayFailuresTest is Test { ) .unwrap(); - cmd.args(["test"]); - cmd.assert_err(); + cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 4 tests for test/ReplayFailures.t.sol:ReplayFailuresTest +[PASS] testA() ([GAS]) +[FAIL. Reason: revert: testB failed] testB() ([GAS]) +[PASS] testC() ([GAS]) +[FAIL. Reason: revert: testD failed] testD() ([GAS]) +Suite result: FAILED. 2 passed; 2 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 2 tests passed, 2 failed, 0 skipped (4 total tests) + +Failing tests: +Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest +[FAIL. Reason: revert: testB failed] testB() ([GAS]) +[FAIL. Reason: revert: testD failed] testD() ([GAS]) + +Encountered a total of 2 failing tests, 2 tests succeeded + +"#]]); + // Test failure filter should be persisted. assert!(prj.root().join("cache/test-failures").exists()); @@ -893,22 +947,52 @@ contract PrecompileLabelsTest is Test { ) .unwrap(); - let output = cmd.args(["test", "-vvvv"]).stdout_lossy(); - assert!(output.contains("VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D]")); - assert!(output.contains("console: [0x000000000000000000636F6e736F6c652e6c6f67]")); - assert!(output.contains("Create2Deployer: [0x4e59b44847b379578588920cA78FbF26c0B4956C]")); - assert!(output.contains("DefaultSender: [0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38]")); - assert!(output.contains("DefaultTestContract: [0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84]")); - assert!(output.contains("ECRecover: [0x0000000000000000000000000000000000000001]")); - assert!(output.contains("SHA-256: [0x0000000000000000000000000000000000000002]")); - assert!(output.contains("RIPEMD-160: [0x0000000000000000000000000000000000000003]")); - assert!(output.contains("Identity: [0x0000000000000000000000000000000000000004]")); - assert!(output.contains("ModExp: [0x0000000000000000000000000000000000000005]")); - assert!(output.contains("ECAdd: [0x0000000000000000000000000000000000000006]")); - assert!(output.contains("ECMul: [0x0000000000000000000000000000000000000007]")); - assert!(output.contains("ECPairing: [0x0000000000000000000000000000000000000008]")); - assert!(output.contains("Blake2F: [0x0000000000000000000000000000000000000009]")); - assert!(output.contains("PointEvaluation: [0x000000000000000000000000000000000000000A]")); + cmd.args(["test", "-vvvv"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/Contract.t.sol:PrecompileLabelsTest +[PASS] testPrecompileLabels() ([GAS]) +Traces: + [9474] PrecompileLabelsTest::testPrecompileLabels() + ├─ [0] VM::deal(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(console: [0x000000000000000000636F6e736F6c652e6c6f67], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(Create2Deployer: [0x4e59b44847b379578588920cA78FbF26c0B4956C], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(DefaultSender: [0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(DefaultTestContract: [0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(ECRecover: [0x0000000000000000000000000000000000000001], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(SHA-256: [0x0000000000000000000000000000000000000002], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(RIPEMD-160: [0x0000000000000000000000000000000000000003], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(Identity: [0x0000000000000000000000000000000000000004], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(ModExp: [0x0000000000000000000000000000000000000005], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(ECAdd: [0x0000000000000000000000000000000000000006], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(ECMul: [0x0000000000000000000000000000000000000007], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(ECPairing: [0x0000000000000000000000000000000000000008], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(Blake2F: [0x0000000000000000000000000000000000000009], 1000000000000000000 [1e18]) + │ └─ ← [Return] + ├─ [0] VM::deal(PointEvaluation: [0x000000000000000000000000000000000000000A], 1000000000000000000 [1e18]) + │ └─ ← [Return] + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // tests that `forge test` with config `show_logs: true` for fuzz tests will @@ -937,9 +1021,23 @@ forgetest_init!(should_show_logs_when_fuzz_test, |prj, cmd| { "#, ) .unwrap(); - cmd.args(["test", "-vv"]); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); + cmd.args(["test", "-vv"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/ContractFuzz.t.sol:ContractFuzz +[PASS] testFuzzConsoleLog(uint256) (runs: 3, [AVG_GAS]) +Logs: + inside fuzz test, x is: [..] + inside fuzz test, x is: [..] + inside fuzz test, x is: [..] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // tests that `forge test` with inline config `show_logs = true` for fuzz tests will @@ -968,9 +1066,23 @@ forgetest_init!(should_show_logs_when_fuzz_test_inline_config, |prj, cmd| { "#, ) .unwrap(); - cmd.args(["test", "-vv"]); - let stdout = cmd.stdout_lossy(); - assert!(stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); + cmd.args(["test", "-vv"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/ContractFuzz.t.sol:ContractFuzz +[PASS] testFuzzConsoleLog(uint256) (runs: 3, [AVG_GAS]) +Logs: + inside fuzz test, x is: [..] + inside fuzz test, x is: [..] + inside fuzz test, x is: [..] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // tests that `forge test` with config `show_logs: false` for fuzz tests will not display @@ -1000,9 +1112,18 @@ forgetest_init!(should_not_show_logs_when_fuzz_test, |prj, cmd| { "#, ) .unwrap(); - cmd.args(["test", "-vv"]); - let stdout = cmd.stdout_lossy(); - assert!(!stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); + cmd.args(["test", "-vv"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/ContractFuzz.t.sol:ContractFuzz +[PASS] testFuzzConsoleLog(uint256) (runs: 3, [AVG_GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // tests that `forge test` with inline config `show_logs = false` for fuzz tests will not @@ -1031,9 +1152,18 @@ forgetest_init!(should_not_show_logs_when_fuzz_test_inline_config, |prj, cmd| { "#, ) .unwrap(); - cmd.args(["test", "-vv"]); - let stdout = cmd.stdout_lossy(); - assert!(!stdout.contains("inside fuzz test, x is:"), "\n{stdout}"); + cmd.args(["test", "-vv"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/ContractFuzz.t.sol:ContractFuzz +[PASS] testFuzzConsoleLog(uint256) (runs: 3, [AVG_GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); }); // tests internal functions trace @@ -1084,7 +1214,7 @@ contract SimpleContractTest is Test { ) .unwrap(); cmd.args(["test", "-vvvv", "--decode-internal"]).assert_success().stdout_eq(str![[r#" -Compiling 24 files with [SOLC_VERSION] +[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -1211,29 +1341,37 @@ contract DeterministicRandomnessTest is Test { // Run the test twice with the same seed and verify the outputs are the same. let seed1 = "0xa1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2"; - cmd.args(["test", "--fuzz-seed", seed1, "-vv"]).assert_success(); - let out1 = cmd.stdout_lossy(); + let out1 = cmd + .args(["test", "--fuzz-seed", seed1, "-vv"]) + .assert_success() + .get_output() + .stdout_lossy(); let res1 = extract_test_result(&out1); - cmd.forge_fuse(); - cmd.args(["test", "--fuzz-seed", seed1, "-vv"]).assert_success(); - let out2 = cmd.stdout_lossy(); + let out2 = cmd + .forge_fuse() + .args(["test", "--fuzz-seed", seed1, "-vv"]) + .assert_success() + .get_output() + .stdout_lossy(); let res2 = extract_test_result(&out2); assert_eq!(res1, res2); // Run the test with another seed and verify the output differs. let seed2 = "0xb1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2"; - cmd.forge_fuse(); - cmd.args(["test", "--fuzz-seed", seed2, "-vv"]).assert_success(); - let out3 = cmd.stdout_lossy(); + let out3 = cmd + .forge_fuse() + .args(["test", "--fuzz-seed", seed2, "-vv"]) + .assert_success() + .get_output() + .stdout_lossy(); let res3 = extract_test_result(&out3); assert_ne!(res3, res1); // Run the test without a seed and verify the outputs differs once again. cmd.forge_fuse(); - cmd.args(["test", "-vv"]).assert_success(); - let out4 = cmd.stdout_lossy(); + let out4 = cmd.args(["test", "-vv"]).assert_success().get_output().stdout_lossy(); let res4 = extract_test_result(&out4); assert_ne!(res4, res1); assert_ne!(res4, res3); diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index 2f1f1368d1907..c8ce2c25f1bfc 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -5,7 +5,7 @@ use crate::utils::{self, EnvExternalities}; use foundry_common::retry::Retry; use foundry_test_utils::{ forgetest, - util::{TestCommand, TestProject}, + util::{OutputExt, TestCommand, TestProject}, }; use std::time::Duration; @@ -77,7 +77,7 @@ fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Resul // give etherscan some time to verify the contract let retry = Retry::new(retries, Some(Duration::from_secs(30))); retry.run(|| -> eyre::Result<()> { - let output = cmd.unchecked_output(); + let output = cmd.execute(); let out = String::from_utf8_lossy(&output.stdout); println!("{out}"); if out.contains("Contract successfully verified") { @@ -97,7 +97,7 @@ fn await_verification_response(info: EnvExternalities, mut cmd: TestCommand) { let retry = Retry::new(5, Some(Duration::from_secs(60))); retry .run(|| -> eyre::Result { - let output = cmd.unchecked_output(); + let output = cmd.execute(); let out = String::from_utf8_lossy(&output.stdout); utils::parse_verification_guid(&out).ok_or_else(|| { eyre::eyre!( @@ -132,11 +132,15 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te add_verify_target(&prj); let contract_path = "src/Verify.sol:Verify"; - cmd.arg("create").args(info.create_args()).arg(contract_path); - - let out = cmd.stdout_lossy(); - let address = utils::parse_deployed_address(out.as_str()) - .unwrap_or_else(|| panic!("Failed to parse deployer {out}")); + let output = cmd + .arg("create") + .args(info.create_args()) + .arg(contract_path) + .assert_success() + .get_output() + .stdout_lossy(); + let address = utils::parse_deployed_address(output.as_str()) + .unwrap_or_else(|| panic!("Failed to parse deployer {output}")); cmd.forge_fuse().arg("verify-contract").root_arg().args([ "--chain-id".to_string(), @@ -161,15 +165,21 @@ fn guess_constructor_args(info: Option, prj: TestProject, mut add_verify_target_with_constructor(&prj); let contract_path = "src/Verify.sol:Verify"; - cmd.arg("create").args(info.create_args()).arg(contract_path).args(vec![ - "--constructor-args", - "(239,SomeString)", - "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", - ]); - - let out = cmd.stdout_lossy(); - let address = utils::parse_deployed_address(out.as_str()) - .unwrap_or_else(|| panic!("Failed to parse deployer {out}")); + let output = cmd + .arg("create") + .args(info.create_args()) + .arg(contract_path) + .args(vec![ + "--constructor-args", + "(239,SomeString)", + "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", + ]) + .assert_success() + .get_output() + .stdout_lossy(); + + let address = utils::parse_deployed_address(output.as_str()) + .unwrap_or_else(|| panic!("Failed to parse deployer {output}")); cmd.forge_fuse().arg("verify-contract").root_arg().args([ "--rpc-url".to_string(), @@ -195,15 +205,15 @@ fn create_verify_on_chain(info: Option, prj: TestProject, mut add_single_verify_target_file(&prj); let contract_path = "src/Verify.sol:Verify"; - cmd.arg("create").args(info.create_args()).args([ - contract_path, - "--etherscan-api-key", - info.etherscan.as_str(), - "--verify", - ]); - - let out = cmd.stdout_lossy(); - assert!(out.contains("Contract successfully verified"), "{}", out); + let output = cmd + .arg("create") + .args(info.create_args()) + .args([contract_path, "--etherscan-api-key", info.etherscan.as_str(), "--verify"]) + .assert_success() + .get_output() + .stdout_lossy(); + + assert!(output.contains("Contract successfully verified"), "{}", output); } } diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 960e22124f4ac..ca0f60d0d64c2 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -25,12 +25,10 @@ alloy-provider.workspace = true eyre.workspace = true fd-lock = "4.0.0" parking_lot.workspace = true -similar-asserts.workspace = true regex = "1" serde_json.workspace = true tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } -walkdir.workspace = true rand.workspace = true snapbox = { version = "0.6.9", features = ["json", "regex"] } diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index 064a94ef2d6d0..cc92bb040607d 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -15,7 +15,7 @@ /// // adds `init` to forge's command arguments /// cmd.arg("init"); /// // executes forge and panics if the command failed or output is empty -/// cmd.assert_non_empty_stdout(); +/// cmd.assert_success().stdout_eq(str![[r#""#]]); /// }); /// ``` /// diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 0bc4d399db527..9b018573261f0 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -1,4 +1,4 @@ -use crate::{init_tracing, TestCommand}; +use crate::{init_tracing, util::lossy_string, TestCommand}; use alloy_primitives::Address; use alloy_provider::Provider; use eyre::Result; @@ -221,7 +221,9 @@ impl ScriptTester { } pub fn run(&mut self, expected: ScriptOutcome) -> &mut Self { - let (stdout, stderr) = self.cmd.unchecked_output_lossy(); + let out = self.cmd.execute(); + let (stdout, stderr) = (lossy_string(&out.stdout), lossy_string(&out.stderr)); + trace!(target: "tests", "STDOUT\n{stdout}\n\nSTDERR\n{stderr}"); let output = if expected.is_err() { &stderr } else { &stdout }; diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index ac5674d9a3333..4b9f8f53ee2c4 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -11,7 +11,7 @@ use foundry_compilers::{ use foundry_config::Config; use parking_lot::Mutex; use regex::Regex; -use snapbox::cmd::OutputAssert; +use snapbox::{cmd::OutputAssert, str}; use std::{ env, ffi::OsStr, @@ -204,7 +204,7 @@ impl ExtTester { } test_cmd.env("FOUNDRY_INVARIANT_DEPTH", "15"); - test_cmd.assert_non_empty_stdout(); + test_cmd.assert_success(); } } @@ -382,8 +382,7 @@ pub fn try_setup_forge_remote( let prj = TestProject::with_project(tmp); if config.run_build { let mut cmd = prj.forge_command(); - cmd.arg("build"); - cmd.ensure_execute_success().wrap_err("`forge build` unsuccessful")?; + cmd.arg("build").assert_success(); } for addon in config.run_commands { debug_assert!(!addon.is_empty()); @@ -835,104 +834,83 @@ impl TestCommand { self } - /// Does not apply [`snapbox`] redactions to the command output. - pub fn with_no_redact(&mut self) -> &mut Self { - self.redact_output = false; - self - } - /// Returns the `Config` as spit out by `forge config` #[track_caller] pub fn config(&mut self) -> Config { self.cmd.args(["config", "--json"]); - let output = self.output(); - let c = lossy_string(&output.stdout); - let config = serde_json::from_str(c.as_ref()).unwrap(); + let output = self.assert().success().get_output().stdout_lossy(); + let config = serde_json::from_str(output.as_ref()).unwrap(); self.forge_fuse(); config } /// Runs `git init` inside the project's dir #[track_caller] - pub fn git_init(&self) -> Output { + pub fn git_init(&self) { let mut cmd = Command::new("git"); cmd.arg("init").current_dir(self.project.root()); - let output = cmd.output().unwrap(); - self.ensure_success(&output).unwrap(); - output - } - - /// Returns a new [Command] that is inside the current project dir - pub fn cmd_in_current_dir(&self, program: &str) -> Command { - let mut cmd = Command::new(program); - cmd.current_dir(self.project.root()); - cmd + let output = OutputAssert::new(cmd.output().unwrap()); + output.success(); } /// Runs `git add .` inside the project's dir #[track_caller] - pub fn git_add(&self) -> Result<()> { - let mut cmd = self.cmd_in_current_dir("git"); + pub fn git_add(&self) { + let mut cmd = Command::new("git"); + cmd.current_dir(self.project.root()); cmd.arg("add").arg("."); - let output = cmd.output()?; - self.ensure_success(&output) + let output = OutputAssert::new(cmd.output().unwrap()); + output.success(); } /// Runs `git commit .` inside the project's dir #[track_caller] - pub fn git_commit(&self, msg: &str) -> Result<()> { - let mut cmd = self.cmd_in_current_dir("git"); + pub fn git_commit(&self, msg: &str) { + let mut cmd = Command::new("git"); + cmd.current_dir(self.project.root()); cmd.arg("commit").arg("-m").arg(msg); - let output = cmd.output()?; - self.ensure_success(&output) + let output = OutputAssert::new(cmd.output().unwrap()); + output.success(); } - /// Executes the command and returns the `(stdout, stderr)` of the output as lossy `String`s. - /// - /// Expects the command to be successful. + /// Runs the command, returning a [`snapbox`] object to assert the command output. #[track_caller] - pub fn output_lossy(&mut self) -> (String, String) { - let output = self.output(); - (lossy_string(&output.stdout), lossy_string(&output.stderr)) + pub fn assert(&mut self) -> OutputAssert { + let assert = OutputAssert::new(self.execute()); + if self.redact_output { + return assert.with_assert(test_assert()); + }; + assert } - /// Executes the command and returns the `(stdout, stderr)` of the output as lossy `String`s. - /// - /// Does not expect the command to be successful. + /// Runs the command and asserts that it resulted in success. #[track_caller] - pub fn unchecked_output_lossy(&mut self) -> (String, String) { - let output = self.unchecked_output(); - (lossy_string(&output.stdout), lossy_string(&output.stderr)) + pub fn assert_success(&mut self) -> OutputAssert { + self.assert().success() } - /// Executes the command and returns the stderr as lossy `String`. - /// - /// **Note**: This function checks whether the command was successful. + /// Runs the command and asserts that it **failed** nothing was printed to stdout. #[track_caller] - pub fn stdout_lossy(&mut self) -> String { - lossy_string(&self.output().stdout) + pub fn assert_empty_stdout(&mut self) { + self.assert_success().stdout_eq(str![[r#""#]]); } - /// Executes the command and returns the stderr as lossy `String`. - /// - /// **Note**: This function does **not** check whether the command was successful. + /// Runs the command and asserts that it failed. #[track_caller] - pub fn stderr_lossy(&mut self) -> String { - lossy_string(&self.unchecked_output().stderr) + pub fn assert_failure(&mut self) -> OutputAssert { + self.assert().failure() } - /// Returns the output but does not expect that the command was successful + /// Runs the command and asserts that it **failed** nothing was printed to stderr. #[track_caller] - pub fn unchecked_output(&mut self) -> Output { - self.execute() + pub fn assert_empty_stderr(&mut self) { + self.assert_failure().stderr_eq(str![[r#""#]]); } - /// Gets the output of a command. If the command failed, then this panics. - #[track_caller] - pub fn output(&mut self) -> Output { - let output = self.execute(); - self.ensure_success(&output).unwrap(); - output + /// Does not apply [`snapbox`] redactions to the command output. + pub fn with_no_redact(&mut self) -> &mut Self { + self.redact_output = false; + self } /// Executes command, applies stdin function and returns output @@ -951,142 +929,6 @@ impl TestCommand { } child.wait_with_output() } - - /// Executes command and expects an successful result - #[track_caller] - pub fn ensure_execute_success(&mut self) -> Result { - let out = self.try_execute()?; - self.ensure_success(&out)?; - Ok(out) - } - - /// Runs the command and prints its output - /// You have to pass --nocapture to cargo test or the print won't be displayed. - /// The full command would be: cargo test -- --nocapture - #[track_caller] - pub fn print_output(&mut self) { - let output = self.execute(); - println!("stdout:\n{}", lossy_string(&output.stdout)); - println!("\nstderr:\n{}", lossy_string(&output.stderr)); - } - - /// Writes the content of the output to new fixture files - #[track_caller] - pub fn write_fixtures(&mut self, name: impl AsRef) { - let name = name.as_ref(); - if let Some(parent) = name.parent() { - fs::create_dir_all(parent).unwrap(); - } - let output = self.execute(); - fs::write(format!("{}.stdout", name.display()), &output.stdout).unwrap(); - fs::write(format!("{}.stderr", name.display()), &output.stderr).unwrap(); - } - - /// Runs the command and asserts that it **failed** (resulted in an error exit code). - #[track_caller] - pub fn assert_err(&mut self) { - let out = self.execute(); - if out.status.success() { - self.make_panic(&out, true); - } - } - - /// Runs the command and asserts that it **failed** and something was printed to stderr. - #[track_caller] - pub fn assert_non_empty_stderr(&mut self) { - let out = self.execute(); - if out.status.success() || out.stderr.is_empty() { - self.make_panic(&out, true); - } - } - - /// Runs the command and asserts that it **succeeded** and something was printed to stdout. - #[track_caller] - pub fn assert_non_empty_stdout(&mut self) { - let out = self.execute(); - if !out.status.success() || out.stdout.is_empty() { - self.make_panic(&out, false); - } - } - - /// Runs the command and asserts that it **failed** nothing was printed to stdout. - #[track_caller] - pub fn assert_empty_stdout(&mut self) { - let out = self.execute(); - if !out.status.success() || !out.stderr.is_empty() { - self.make_panic(&out, true); - } - } - - #[track_caller] - pub fn ensure_success(&self, out: &Output) -> Result<()> { - if out.status.success() { - Ok(()) - } else { - Err(self.make_error(out, false)) - } - } - - #[track_caller] - fn make_panic(&self, out: &Output, expected_fail: bool) -> ! { - panic!("{}", self.make_error_message(out, expected_fail)) - } - - #[track_caller] - fn make_error(&self, out: &Output, expected_fail: bool) -> eyre::Report { - eyre::eyre!("{}", self.make_error_message(out, expected_fail)) - } - - pub fn make_error_message(&self, out: &Output, expected_fail: bool) -> String { - let msg = if expected_fail { - "expected failure but command succeeded!" - } else { - "command failed but expected success!" - }; - format!( - "\ ---- {:?} --- -{msg} - -status: {} - -paths: -{} - -stdout: -{} - -stderr: -{}", - self.cmd, - out.status, - self.project.inner.paths(), - lossy_string(&out.stdout), - lossy_string(&out.stderr), - ) - } - - /// Runs the command, returning a [`snapbox`] object to assert the command output. - #[track_caller] - pub fn assert(&mut self) -> OutputAssert { - let assert = OutputAssert::new(self.execute()); - if self.redact_output { - return assert.with_assert(test_assert()); - }; - assert - } - - /// Runs the command and asserts that it resulted in success. - #[track_caller] - pub fn assert_success(&mut self) -> OutputAssert { - self.assert().success() - } - - /// Runs the command and asserts that it failed. - #[track_caller] - pub fn assert_failure(&mut self) -> OutputAssert { - self.assert().failure() - } } fn test_assert() -> snapbox::Assert { @@ -1105,7 +947,15 @@ fn test_redactions() -> snapbox::Redactions { ("[AVG_GAS]", r"μ: \d+, ~: \d+"), ("[FILE]", r"-->.*\.sol"), ("[FILE]", r"Location(.|\n)*\.rs(.|\n)*Backtrace"), + ("[COMPILING_FILES]", r"Compiling \d+ files?"), ("[TX_HASH]", r"Transaction hash: 0x[0-9A-Fa-f]{64}"), + ("[ADDRESS]", r"Address: 0x[0-9A-Fa-f]{40}"), + ("[UPDATING_DEPENDENCIES]", r"Updating dependencies in .*"), + ("[SAVED_TRANSACTIONS]", r"Transactions saved to: .*\.json"), + ("[SAVED_SENSITIVE_VALUES]", r"Sensitive values saved to: .*\.json"), + ("[ESTIMATED_GAS_PRICE]", r"Estimated gas price:\s*(\d+(\.\d+)?)\s*gwei"), + ("[ESTIMATED_TOTAL_GAS_USED]", r"Estimated total gas used for script: \d+"), + ("[ESTIMATED_AMOUNT_REQUIRED]", r"Estimated amount required:\s*(\d+(\.\d+)?)\s*ETH"), ]; for (placeholder, re) in redactions { r.insert(placeholder, Regex::new(re).expect(re)).expect(re); @@ -1116,135 +966,17 @@ fn test_redactions() -> snapbox::Redactions { } /// Extension trait for [`Output`]. -/// -/// These function will read the path's content and assert that the process' output matches the -/// fixture. Since `forge` commands may emit colorized output depending on whether the current -/// terminal is tty, the path argument can be wrapped in [tty_fixture_path()] pub trait OutputExt { - /// Ensure the command wrote the expected data to `stdout`. - fn stdout_matches_content(&self, expected: &str); - - /// Ensure the command wrote the expected data to `stdout`. - fn stdout_matches_path(&self, expected_path: impl AsRef); - - /// Ensure the command wrote the expected data to `stderr`. - fn stderr_matches_path(&self, expected_path: impl AsRef); - - /// Returns the stderr as lossy string - fn stderr_lossy(&self) -> String; - /// Returns the stdout as lossy string fn stdout_lossy(&self) -> String; } -/// Patterns to remove from fixtures before comparing output -/// -/// This should strip everything that can vary from run to run, like elapsed time, file paths -static IGNORE_IN_FIXTURES: LazyLock = LazyLock::new(|| { - let re = &[ - // solc version - r" ?Solc(?: version)? \d+.\d+.\d+", - r" with(?: Solc)? \d+.\d+.\d+", - // solc runs - r"runs: \d+, μ: \d+, ~: \d+", - // elapsed time - r"(?:finished)? ?in .*?s(?: \(.*?s CPU time\))?", - // file paths - r"-->.*\.sol", - r"Location(.|\n)*\.rs(.|\n)*Backtrace", - // other - r"Transaction hash: 0x[0-9A-Fa-f]{64}", - ]; - Regex::new(&format!("({})", re.join("|"))).unwrap() -}); - -pub fn normalize_output(s: &str) -> String { - let s = s.replace("\r\n", "\n").replace('\\', "/"); - IGNORE_IN_FIXTURES.replace_all(&s, "").into_owned() -} - impl OutputExt for Output { - #[track_caller] - fn stdout_matches_content(&self, expected: &str) { - let out = lossy_string(&self.stdout); - similar_asserts::assert_eq!(normalize_output(&out), normalize_output(expected)); - } - - #[track_caller] - fn stdout_matches_path(&self, expected_path: impl AsRef) { - let expected = fs::read_to_string(expected_path).unwrap(); - self.stdout_matches_content(&expected); - } - - #[track_caller] - fn stderr_matches_path(&self, expected_path: impl AsRef) { - let expected = fs::read_to_string(expected_path).unwrap(); - let err = lossy_string(&self.stderr); - similar_asserts::assert_eq!(normalize_output(&err), normalize_output(&expected)); - } - - fn stderr_lossy(&self) -> String { - lossy_string(&self.stderr) - } - fn stdout_lossy(&self) -> String { lossy_string(&self.stdout) } } -/// Returns the fixture path depending on whether the current terminal is tty -/// -/// This is useful in combination with [OutputExt] -pub fn tty_fixture_path(path: impl AsRef) -> PathBuf { - let path = path.as_ref(); - if *IS_TTY { - return if let Some(ext) = path.extension().and_then(|s| s.to_str()) { - path.with_extension(format!("tty.{ext}")) - } else { - path.with_extension("tty") - } - } - path.to_path_buf() -} - -/// Return a recursive listing of all files and directories in the given -/// directory. This is useful for debugging transient and odd failures in -/// integration tests. -pub fn dir_list>(dir: P) -> Vec { - walkdir::WalkDir::new(dir) - .follow_links(true) - .into_iter() - .map(|result| result.unwrap().path().to_string_lossy().into_owned()) - .collect() -} - -fn lossy_string(bytes: &[u8]) -> String { +pub fn lossy_string(bytes: &[u8]) -> String { String::from_utf8_lossy(bytes).replace("\r\n", "\n") } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn tty_path_works() { - let path = "tests/fixture/test.stdout"; - if *IS_TTY { - assert_eq!(tty_fixture_path(path), PathBuf::from("tests/fixture/test.tty.stdout")); - } else { - assert_eq!(tty_fixture_path(path), PathBuf::from(path)); - } - } - - #[test] - fn fixture_regex_matches() { - assert!(IGNORE_IN_FIXTURES.is_match( - r" -Location: - cli/src/compile.rs:151 - -Backtrace omitted. - " - )); - } -} diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 9136c200d7a29..0a1d39c1956a1 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -455,7 +455,7 @@ mod tests { use super::*; use clap::Parser; use foundry_common::fs; - use foundry_test_utils::forgetest_async; + use foundry_test_utils::{forgetest_async, str}; use tempfile::tempdir; #[test] @@ -566,7 +566,12 @@ mod tests { prj.add_source("Counter1", "contract Counter {}").unwrap(); prj.add_source("Counter2", "contract Counter {}").unwrap(); - cmd.args(["build", "--force"]).ensure_execute_success().unwrap(); + cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +"#]]); let args = VerifyArgs::parse_from([ "foundry-cli", From 9e79f54d3bba74a860aadce072adf3e1875a9da5 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:09:59 +0530 Subject: [PATCH 1399/1963] fix(forge vb): bail when args expected but none provided (#8764) fix(forge vb): bail when args are expected but none are provided --- crates/verify/src/bytecode.rs | 4 ++++ crates/verify/src/utils.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index b1e4f7e520d80..8fffd84d6a65b 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -209,6 +209,10 @@ impl VerifyBytecodeArgs { check_explorer_args(source_code.clone())? }; + // This fails only when the contract expects constructor args but NONE were provided OR + // retrieved from explorer (in case of predeploys). + crate::utils::check_args_len(&artifact, &constructor_args)?; + if maybe_predeploy { if !self.json { println!( diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index d5545df6714b9..1b7c7fadacadc 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -307,6 +307,21 @@ pub fn check_explorer_args(source_code: ContractMetadata) -> Result Result<(), eyre::ErrReport> { + if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) { + if !constructor.inputs.is_empty() && args.len() == 0 { + eyre::bail!( + "Contract expects {} constructor argument(s), but none were provided", + constructor.inputs.len() + ); + } + } + Ok(()) +} + pub async fn get_tracing_executor( fork_config: &mut Config, fork_blk_num: u64, From 41198f33b911440c410395a8af6166b4d19e998f Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Thu, 29 Aug 2024 19:57:04 +0800 Subject: [PATCH 1400/1963] support positional `--mp` parameter for `forge test` (#8751) * support positional --mp parameter * use panic instead --- crates/forge/bin/cmd/test/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index ec582f2981034..b0792a8cfc562 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -1,6 +1,6 @@ use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; use alloy_primitives::U256; -use clap::Parser; +use clap::{Parser, ValueHint}; use eyre::Result; use forge::{ decode::decode_console_logs, @@ -32,6 +32,7 @@ use foundry_config::{ value::{Dict, Map}, Metadata, Profile, Provider, }, + filter::GlobMatcher, get_available_profiles, Config, }; use foundry_debugger::Debugger; @@ -58,6 +59,10 @@ foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); #[derive(Clone, Debug, Parser)] #[command(next_help_heading = "Test options")] pub struct TestArgs { + /// The contract file you want to test, it's a shortcut for --match-path. + #[arg(value_hint = ValueHint::FilePath)] + pub path: Option, + /// Run a test in the debugger. /// /// The argument passed to this flag is the name of the test function you want to run, and it @@ -634,6 +639,13 @@ impl TestArgs { if self.rerun { filter.test_pattern = last_run_failures(config); } + if filter.path_pattern.is_some() { + if self.path.is_some() { + panic!("Can not supply both --match-path and |path|"); + } + } else { + filter.path_pattern = self.path.clone(); + } filter.merge_with_config(config) } From 98ab45eeb5c3b8d07dede2f27df96f4778d89300 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 29 Aug 2024 14:27:14 +0200 Subject: [PATCH 1401/1963] feat: support mesc (#8760) --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 1 + crates/config/Cargo.toml | 1 + crates/config/src/lib.rs | 25 +++++++++++++++++++++---- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b71c523ea174..99ee3dae23678 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3816,6 +3816,7 @@ dependencies = [ "foundry-compilers", "glob", "globset", + "mesc", "number_prefix", "path-slash", "regex", @@ -5557,6 +5558,17 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mesc" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d340f1a6bfcd3ea5075231fb04b74c8bf7cb3be25ee6480976c8500fcd2949f" +dependencies = [ + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "miette" version = "7.2.0" diff --git a/Cargo.toml b/Cargo.toml index c6c8aee07db86..50c33c653dba1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -231,6 +231,7 @@ itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" parking_lot = "0.12" +mesc = "0.2.1" rand = "0.8" rustc-hash = "2.0" semver = "1" diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index f155981228c92..357830166d7d6 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -31,6 +31,7 @@ globset = "0.4" glob = "0.3" Inflector = "0.11" number_prefix = "0.4" +mesc.workspace = true regex = "1" reqwest.workspace = true semver = { workspace = true, features = ["serde"] } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 13dfc0474200d..d0fcc5a14ac5f 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1075,9 +1075,18 @@ impl Config { /// Resolves the given alias to a matching rpc url /// - /// Returns: - /// - the matching, resolved url of `rpc_endpoints` if `maybe_alias` is an alias - /// - None otherwise + /// # Returns + /// + /// In order of resolution: + /// + /// - the matching, resolved url of `rpc_endpoints` if `maybe_alias` is an alias + /// - a mesc resolved url if `maybe_alias` is a known alias in mesc + /// - `None` otherwise + /// + /// # Note on mesc + /// + /// The endpoint is queried for in mesc under the `foundry` profile, allowing users to customize + /// endpoints for Foundry specifically. /// /// # Example /// @@ -1093,7 +1102,15 @@ impl Config { maybe_alias: &str, ) -> Option, UnresolvedEnvVarError>> { let mut endpoints = self.rpc_endpoints.clone().resolved(); - Some(endpoints.remove(maybe_alias)?.map(Cow::Owned)) + if let Some(endpoint) = endpoints.remove(maybe_alias) { + return Some(endpoint.map(Cow::Owned)) + } + + if let Ok(Some(endpoint)) = mesc::get_endpoint_by_query(maybe_alias, Some("foundry")) { + return Some(Ok(Cow::Owned(endpoint.url))) + } + + None } /// Returns the configured rpc, or the fallback url From 818eeb9d5018d3858238d925fa9c9ef5fcdaee47 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 30 Aug 2024 14:40:19 +0300 Subject: [PATCH 1402/1963] fix(fmt): write files on disk only if they're not perfect match (#8775) * fix(fmt): write files on disk only if they're not perfect match * Cleanup --- crates/fmt/src/formatter.rs | 2 +- crates/fmt/testdata/Repros/fmt.sol | 3 +-- crates/forge/bin/cmd/fmt.rs | 11 ++++++++--- .../invariant/common/InvariantPreserveState.t.sol | 5 +++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 1c5000330f4b9..a44aa697ccb02 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1246,7 +1246,7 @@ impl<'a, W: Write> Formatter<'a, W> { })?; write_chunk!(self, "}}")?; - return Ok(true) + return Ok(false) } // Determine writable statements by excluding statements from disabled start / end lines. diff --git a/crates/fmt/testdata/Repros/fmt.sol b/crates/fmt/testdata/Repros/fmt.sol index 0842c7956bf6f..a61a626a0968f 100644 --- a/crates/fmt/testdata/Repros/fmt.sol +++ b/crates/fmt/testdata/Repros/fmt.sol @@ -139,8 +139,7 @@ contract IfElseTest { number = 1; } else if (newNumber = 2) { // number = 2; - } - else { + } else { newNumber = 3; } } diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index c467048368f01..9fd016ac70b0b 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -125,17 +125,22 @@ impl FmtArgs { ) })?; + let diff = TextDiff::from_lines(&source, &output); + let new_format = diff.ratio() < 1.0; if self.check || path.is_none() { if self.raw { print!("{output}"); } - let diff = TextDiff::from_lines(&source, &output); - if diff.ratio() < 1.0 { + // If new format then compute diff summary. + if new_format { return Ok(Some(format_diff_summary(&name, &diff))) } } else if let Some(path) = path { - fs::write(path, output)?; + // If new format then write it on disk. + if new_format { + fs::write(path, output)?; + } } Ok(None) }; diff --git a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol index b91cda739fc58..5469801362a98 100644 --- a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol @@ -15,8 +15,9 @@ contract Handler is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function thisFunctionReverts() external { - if (block.number < 10) {} - else revert(); + if (block.number < 10) {} else { + revert(); + } } function advanceTime(uint256 blocks) external { From d75318c9c7a1c6af5404fe96f63ca890dcdd588d Mon Sep 17 00:00:00 2001 From: Eric Woolsey Date: Sat, 31 Aug 2024 17:03:00 -0700 Subject: [PATCH 1403/1963] Optimism Hardfork Support (#8749) optimism hardfork Co-authored-by: Arsenii Kulikov --- crates/anvil/src/cmd.rs | 50 ++++++++-- crates/anvil/src/config.rs | 24 +++-- crates/anvil/src/hardfork.rs | 141 ++++++++++++++++++++------- crates/anvil/src/lib.rs | 2 +- crates/anvil/tests/it/anvil_api.rs | 8 +- crates/anvil/tests/it/eip4844.rs | 12 +-- crates/anvil/tests/it/eip7702.rs | 4 +- crates/anvil/tests/it/optimism.rs | 26 +++-- crates/anvil/tests/it/otterscan.rs | 12 +-- crates/anvil/tests/it/traces.rs | 5 +- crates/anvil/tests/it/transaction.rs | 5 +- crates/cast/tests/cli/main.rs | 5 +- 12 files changed, 208 insertions(+), 86 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index e21f12d365f5a..1238e59063c82 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -1,7 +1,8 @@ use crate::{ config::{ForkChoice, DEFAULT_MNEMONIC}, eth::{backend::db::SerializableState, pool::transactions::TransactionOrder, EthApi}, - AccountGenerator, Hardfork, NodeConfig, CHAIN_ID, + hardfork::OptimismHardfork, + AccountGenerator, EthereumHardfork, NodeConfig, CHAIN_ID, }; use alloy_genesis::Genesis; use alloy_primitives::{utils::Unit, B256, U256}; @@ -79,8 +80,8 @@ pub struct NodeArgs { /// /// Choose the hardfork by name, e.g. `shanghai`, `paris`, `london`, etc... /// [default: latest] - #[arg(long, value_parser = Hardfork::from_str)] - pub hardfork: Option, + #[arg(long)] + pub hardfork: Option, /// Block time in seconds for interval mining. #[arg(short, long, visible_alias = "blockTime", value_name = "SECONDS", value_parser = duration_from_secs_f64)] @@ -196,7 +197,7 @@ const IPC_HELP: &str = "Launch an ipc server at the given path or default path = const DEFAULT_DUMP_INTERVAL: Duration = Duration::from_secs(60); impl NodeArgs { - pub fn into_node_config(self) -> NodeConfig { + pub fn into_node_config(self) -> eyre::Result { let genesis_balance = Unit::ETHER.wei().saturating_mul(U256::from(self.balance)); let compute_units_per_second = if self.evm_opts.no_rate_limit { Some(u64::MAX) @@ -204,11 +205,22 @@ impl NodeArgs { self.evm_opts.compute_units_per_second }; - NodeConfig::default() + let hardfork = match &self.hardfork { + Some(hf) => { + if self.evm_opts.optimism { + Some(OptimismHardfork::from_str(hf)?.into()) + } else { + Some(EthereumHardfork::from_str(hf)?.into()) + } + } + None => None, + }; + + Ok(NodeConfig::default() .with_gas_limit(self.evm_opts.gas_limit) .disable_block_gas_limit(self.evm_opts.disable_block_gas_limit) .with_gas_price(self.evm_opts.gas_price) - .with_hardfork(self.hardfork) + .with_hardfork(hardfork) .with_blocktime(self.block_time) .with_no_mining(self.no_mining) .with_mixed_mining(self.mixed_mining, self.block_time) @@ -255,7 +267,7 @@ impl NodeArgs { .with_alphanet(self.evm_opts.alphanet) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) - .with_memory_limit(self.evm_opts.memory_limit) + .with_memory_limit(self.evm_opts.memory_limit)) } fn account_generator(&self) -> AccountGenerator { @@ -295,7 +307,7 @@ impl NodeArgs { let dump_interval = self.state_interval.map(Duration::from_secs).unwrap_or(DEFAULT_DUMP_INTERVAL); - let (api, mut handle) = crate::try_spawn(self.into_node_config()).await?; + let (api, mut handle) = crate::try_spawn(self.into_node_config()?).await?; // sets the signal handler to gracefully shutdown. let mut fork = api.get_fork(); @@ -739,6 +751,8 @@ fn duration_from_secs_f64(s: &str) -> Result { #[cfg(test)] mod tests { + use crate::EthereumHardfork; + use super::*; use std::{env, net::Ipv4Addr}; @@ -773,9 +787,25 @@ mod tests { } #[test] - fn can_parse_hardfork() { + fn can_parse_ethereum_hardfork() { let args: NodeArgs = NodeArgs::parse_from(["anvil", "--hardfork", "berlin"]); - assert_eq!(args.hardfork, Some(Hardfork::Berlin)); + let config = args.into_node_config().unwrap(); + assert_eq!(config.hardfork, Some(EthereumHardfork::Berlin.into())); + } + + #[test] + fn can_parse_optimism_hardfork() { + let args: NodeArgs = + NodeArgs::parse_from(["anvil", "--optimism", "--hardfork", "Regolith"]); + let config = args.into_node_config().unwrap(); + assert_eq!(config.hardfork, Some(OptimismHardfork::Regolith.into())); + } + + #[test] + fn cant_parse_invalid_hardfork() { + let args: NodeArgs = NodeArgs::parse_from(["anvil", "--hardfork", "Regolith"]); + let config = args.into_node_config(); + assert!(config.is_err()); } #[test] diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index a94d5b827d001..d5770f7036a5a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -11,8 +11,9 @@ use crate::{ fees::{INITIAL_BASE_FEE, INITIAL_GAS_PRICE}, pool::transactions::{PoolTransaction, TransactionOrder}, }, + hardfork::{ChainHardfork, OptimismHardfork}, mem::{self, in_memory_db::MemDb}, - FeeManager, Hardfork, PrecompileFactory, + EthereumHardfork, FeeManager, PrecompileFactory, }; use alloy_genesis::Genesis; use alloy_network::AnyNetwork; @@ -64,7 +65,6 @@ pub const DEFAULT_MNEMONIC: &str = "test test test test test test test test test /// The default IPC endpoint pub const DEFAULT_IPC_ENDPOINT: &str = if cfg!(unix) { "/tmp/anvil.ipc" } else { r"\\.\pipe\anvil.ipc" }; - /// `anvil 0.1.0 (f01b232bc 2022-04-13T23:28:39.493201+00:00)` pub const VERSION_MESSAGE: &str = concat!( env!("CARGO_PKG_VERSION"), @@ -100,7 +100,7 @@ pub struct NodeConfig { /// Default blob excess gas and price pub blob_excess_gas_and_price: Option, /// The hardfork to use - pub hardfork: Option, + pub hardfork: Option, /// Signer accounts that will be initialised with `genesis_balance` in the genesis block pub genesis_accounts: Vec, /// Native token balance of every genesis account in the genesis block @@ -475,11 +475,17 @@ impl NodeConfig { } /// Returns the hardfork to use - pub fn get_hardfork(&self) -> Hardfork { + pub fn get_hardfork(&self) -> ChainHardfork { if self.alphanet { - return Hardfork::PragueEOF; + return ChainHardfork::Ethereum(EthereumHardfork::PragueEOF); + } + if let Some(hardfork) = self.hardfork { + return hardfork; + } + if self.enable_optimism { + return OptimismHardfork::default().into(); } - self.hardfork.unwrap_or_default() + EthereumHardfork::default().into() } /// Sets a custom code size limit @@ -621,7 +627,7 @@ impl NodeConfig { /// Sets the hardfork #[must_use] - pub fn with_hardfork(mut self, hardfork: Option) -> Self { + pub fn with_hardfork(mut self, hardfork: Option) -> Self { self.hardfork = hardfork; self } @@ -1094,9 +1100,9 @@ impl NodeConfig { let chain_id = provider.get_chain_id().await.expect("Failed to fetch network chain ID"); if alloy_chains::NamedChain::Mainnet == chain_id { - let hardfork: Hardfork = fork_block_number.into(); + let hardfork: EthereumHardfork = fork_block_number.into(); env.handler_cfg.spec_id = hardfork.into(); - self.hardfork = Some(hardfork); + self.hardfork = Some(ChainHardfork::Ethereum(hardfork)); } Some(U256::from(chain_id)) } else { diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index de4c43c186575..c8d2fdebccd46 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -1,9 +1,37 @@ use alloy_rpc_types::BlockNumberOrTag; +use eyre::bail; use foundry_evm::revm::primitives::SpecId; use std::str::FromStr; +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum ChainHardfork { + Ethereum(EthereumHardfork), + Optimism(OptimismHardfork), +} + +impl From for ChainHardfork { + fn from(value: EthereumHardfork) -> Self { + Self::Ethereum(value) + } +} + +impl From for ChainHardfork { + fn from(value: OptimismHardfork) -> Self { + Self::Optimism(value) + } +} + +impl From for SpecId { + fn from(fork: ChainHardfork) -> Self { + match fork { + ChainHardfork::Ethereum(hardfork) => hardfork.into(), + ChainHardfork::Optimism(hardfork) => hardfork.into(), + } + } +} + #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum Hardfork { +pub enum EthereumHardfork { Frontier, Homestead, Dao, @@ -27,7 +55,7 @@ pub enum Hardfork { Latest, } -impl Hardfork { +impl EthereumHardfork { /// Get the first block number of the hardfork. pub fn fork_block(&self) -> u64 { match *self { @@ -53,8 +81,8 @@ impl Hardfork { } } -impl FromStr for Hardfork { - type Err = String; +impl FromStr for EthereumHardfork { + type Err = eyre::Report; fn from_str(s: &str) -> Result { let s = s.to_lowercase(); @@ -79,40 +107,40 @@ impl FromStr for Hardfork { "prague" | "18" => Self::Prague, "pragueeof" | "19" | "prague-eof" => Self::PragueEOF, "latest" => Self::Latest, - _ => return Err(format!("Unknown hardfork {s}")), + _ => bail!("Unknown hardfork {s}"), }; Ok(hardfork) } } -impl From for SpecId { - fn from(fork: Hardfork) -> Self { +impl From for SpecId { + fn from(fork: EthereumHardfork) -> Self { match fork { - Hardfork::Frontier => Self::FRONTIER, - Hardfork::Homestead => Self::HOMESTEAD, - Hardfork::Dao => Self::HOMESTEAD, - Hardfork::Tangerine => Self::TANGERINE, - Hardfork::SpuriousDragon => Self::SPURIOUS_DRAGON, - Hardfork::Byzantium => Self::BYZANTIUM, - Hardfork::Constantinople => Self::CONSTANTINOPLE, - Hardfork::Petersburg => Self::PETERSBURG, - Hardfork::Istanbul => Self::ISTANBUL, - Hardfork::Muirglacier => Self::MUIR_GLACIER, - Hardfork::Berlin => Self::BERLIN, - Hardfork::London => Self::LONDON, - Hardfork::ArrowGlacier => Self::LONDON, - Hardfork::GrayGlacier => Self::GRAY_GLACIER, - Hardfork::Paris => Self::MERGE, - Hardfork::Shanghai => Self::SHANGHAI, - Hardfork::Cancun | Hardfork::Latest => Self::CANCUN, - Hardfork::Prague => Self::PRAGUE, + EthereumHardfork::Frontier => Self::FRONTIER, + EthereumHardfork::Homestead => Self::HOMESTEAD, + EthereumHardfork::Dao => Self::HOMESTEAD, + EthereumHardfork::Tangerine => Self::TANGERINE, + EthereumHardfork::SpuriousDragon => Self::SPURIOUS_DRAGON, + EthereumHardfork::Byzantium => Self::BYZANTIUM, + EthereumHardfork::Constantinople => Self::CONSTANTINOPLE, + EthereumHardfork::Petersburg => Self::PETERSBURG, + EthereumHardfork::Istanbul => Self::ISTANBUL, + EthereumHardfork::Muirglacier => Self::MUIR_GLACIER, + EthereumHardfork::Berlin => Self::BERLIN, + EthereumHardfork::London => Self::LONDON, + EthereumHardfork::ArrowGlacier => Self::LONDON, + EthereumHardfork::GrayGlacier => Self::GRAY_GLACIER, + EthereumHardfork::Paris => Self::MERGE, + EthereumHardfork::Shanghai => Self::SHANGHAI, + EthereumHardfork::Cancun | EthereumHardfork::Latest => Self::CANCUN, + EthereumHardfork::Prague => Self::PRAGUE, // TODO: switch to latest after activation - Hardfork::PragueEOF => Self::PRAGUE_EOF, + EthereumHardfork::PragueEOF => Self::PRAGUE_EOF, } } } -impl> From for Hardfork { +impl> From for EthereumHardfork { fn from(block: T) -> Self { let num = match block.into() { BlockNumberOrTag::Earliest => 0, @@ -140,19 +168,64 @@ impl> From for Hardfork { } } +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum OptimismHardfork { + Bedrock, + Regolith, + Canyon, + Ecotone, + Fjord, + Granite, + #[default] + Latest, +} + +impl FromStr for OptimismHardfork { + type Err = eyre::Report; + + fn from_str(s: &str) -> Result { + let s = s.to_lowercase(); + let hardfork = match s.as_str() { + "bedrock" => Self::Bedrock, + "regolith" => Self::Regolith, + "canyon" => Self::Canyon, + "ecotone" => Self::Ecotone, + "fjord" => Self::Fjord, + "granite" => Self::Granite, + "latest" => Self::Latest, + _ => bail!("Unknown hardfork {s}"), + }; + Ok(hardfork) + } +} + +impl From for SpecId { + fn from(fork: OptimismHardfork) -> Self { + match fork { + OptimismHardfork::Bedrock => Self::BEDROCK, + OptimismHardfork::Regolith => Self::REGOLITH, + OptimismHardfork::Canyon => Self::CANYON, + OptimismHardfork::Ecotone => Self::ECOTONE, + OptimismHardfork::Fjord => Self::FJORD, + OptimismHardfork::Granite => Self::GRANITE, + OptimismHardfork::Latest => Self::LATEST, + } + } +} + #[cfg(test)] mod tests { - use crate::Hardfork; + use crate::EthereumHardfork; #[test] fn test_hardfork_blocks() { - let hf: Hardfork = 12_965_000u64.into(); - assert_eq!(hf, Hardfork::London); + let hf: EthereumHardfork = 12_965_000u64.into(); + assert_eq!(hf, EthereumHardfork::London); - let hf: Hardfork = 4370000u64.into(); - assert_eq!(hf, Hardfork::Byzantium); + let hf: EthereumHardfork = 4370000u64.into(); + assert_eq!(hf, EthereumHardfork::Byzantium); - let hf: Hardfork = 12244000u64.into(); - assert_eq!(hf, Hardfork::Berlin); + let hf: EthereumHardfork = 12244000u64.into(); + assert_eq!(hf, EthereumHardfork::Berlin); } } diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index dc7e0969f99cf..c800131d26bd1 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -48,7 +48,7 @@ mod config; pub use config::{AccountGenerator, ForkChoice, NodeConfig, CHAIN_ID, VERSION_MESSAGE}; mod hardfork; -pub use hardfork::Hardfork; +pub use hardfork::EthereumHardfork; /// ethereum related implementations pub mod eth; diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index e6289e0b0853c..1b94f5e439e7b 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -13,7 +13,7 @@ use alloy_rpc_types::{ BlockId, BlockNumberOrTag, TransactionRequest, }; use alloy_serde::WithOtherFields; -use anvil::{eth::api::CLIENT_VERSION, spawn, Hardfork, NodeConfig}; +use anvil::{eth::api::CLIENT_VERSION, spawn, EthereumHardfork, NodeConfig}; use anvil_core::eth::EthRequest; use foundry_evm::revm::primitives::SpecId; use std::{ @@ -23,7 +23,8 @@ use std::{ #[tokio::test(flavor = "multi_thread")] async fn can_set_gas_price() { - let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; + let (api, handle) = + spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::Berlin.into()))).await; let provider = handle.http_provider(); let gas_price = U256::from(1337); @@ -33,7 +34,8 @@ async fn can_set_gas_price() { #[tokio::test(flavor = "multi_thread")] async fn can_set_block_gas_limit() { - let (api, _) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; + let (api, _) = + spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::Berlin.into()))).await; let block_gas_limit = U256::from(1337); assert!(api.evm_set_block_gas_limit(block_gas_limit).unwrap()); diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 40d5a63a6c3dc..2da74da65ff67 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -6,11 +6,11 @@ use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, TransactionRequest}; use alloy_serde::WithOtherFields; -use anvil::{spawn, Hardfork, NodeConfig}; +use anvil::{spawn, EthereumHardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] async fn can_send_eip4844_transaction() { - let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); let (_api, handle) = spawn(node_config).await; let wallets = handle.dev_wallets().collect::>(); @@ -46,7 +46,7 @@ async fn can_send_eip4844_transaction() { #[tokio::test(flavor = "multi_thread")] async fn can_send_multiple_blobs_in_one_tx() { - let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); let (_api, handle) = spawn(node_config).await; let wallets = handle.dev_wallets().collect::>(); @@ -84,7 +84,7 @@ async fn can_send_multiple_blobs_in_one_tx() { #[tokio::test(flavor = "multi_thread")] async fn cannot_exceed_six_blobs() { - let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); let (_api, handle) = spawn(node_config).await; let wallets = handle.dev_wallets().collect::>(); @@ -121,7 +121,7 @@ async fn cannot_exceed_six_blobs() { #[tokio::test(flavor = "multi_thread")] async fn can_mine_blobs_when_exceeds_max_blobs() { - let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); let (api, handle) = spawn(node_config).await; api.anvil_set_auto_mine(false).await.unwrap(); @@ -194,7 +194,7 @@ async fn can_mine_blobs_when_exceeds_max_blobs() { #[tokio::test(flavor = "multi_thread")] async fn can_check_blob_fields_on_genesis() { - let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Cancun)); + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); let (_api, handle) = spawn(node_config).await; let provider = http_provider(&handle.http_endpoint()); diff --git a/crates/anvil/tests/it/eip7702.rs b/crates/anvil/tests/it/eip7702.rs index a23feceb2bc58..828e0d351b45f 100644 --- a/crates/anvil/tests/it/eip7702.rs +++ b/crates/anvil/tests/it/eip7702.rs @@ -6,11 +6,11 @@ use alloy_provider::Provider; use alloy_rpc_types::{Authorization, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_signer::SignerSync; -use anvil::{spawn, Hardfork, NodeConfig}; +use anvil::{spawn, EthereumHardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] async fn can_send_eip7702_tx() { - let node_config = NodeConfig::test().with_hardfork(Some(Hardfork::Prague)); + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Prague.into())); let (_api, handle) = spawn(node_config).await; let provider = http_provider(&handle.http_endpoint()); diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index f5f4a41ca7fa8..4ca74f9feb3fc 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -7,7 +7,7 @@ use alloy_primitives::{b256, Address, TxHash, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest}; use alloy_serde::WithOtherFields; -use anvil::{spawn, Hardfork, NodeConfig}; +use anvil::{spawn, EthereumHardfork, NodeConfig}; use anvil_core::eth::transaction::optimism::DepositTransaction; #[tokio::test(flavor = "multi_thread")] @@ -44,8 +44,10 @@ async fn test_deposits_not_supported_if_optimism_disabled() { #[tokio::test(flavor = "multi_thread")] async fn test_send_value_deposit_transaction() { // enable the Optimism flag - let (api, handle) = - spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; + let (api, handle) = spawn( + NodeConfig::test().with_optimism(true).with_hardfork(Some(EthereumHardfork::Paris.into())), + ) + .await; let accounts: Vec<_> = handle.dev_wallets().collect(); let signer: EthereumWallet = accounts[0].clone().into(); @@ -92,8 +94,10 @@ async fn test_send_value_deposit_transaction() { #[tokio::test(flavor = "multi_thread")] async fn test_send_value_raw_deposit_transaction() { // enable the Optimism flag - let (api, handle) = - spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; + let (api, handle) = spawn( + NodeConfig::test().with_optimism(true).with_hardfork(Some(EthereumHardfork::Paris.into())), + ) + .await; let accounts: Vec<_> = handle.dev_wallets().collect(); let signer: EthereumWallet = accounts[0].clone().into(); @@ -149,8 +153,10 @@ async fn test_send_value_raw_deposit_transaction() { #[tokio::test(flavor = "multi_thread")] async fn test_deposit_transaction_hash_matches_sepolia() { // enable the Optimism flag - let (_api, handle) = - spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; + let (_api, handle) = spawn( + NodeConfig::test().with_optimism(true).with_hardfork(Some(EthereumHardfork::Paris.into())), + ) + .await; let accounts: Vec<_> = handle.dev_wallets().collect(); let signer: EthereumWallet = accounts[0].clone().into(); @@ -181,8 +187,10 @@ async fn test_deposit_transaction_hash_matches_sepolia() { #[tokio::test(flavor = "multi_thread")] async fn test_deposit_tx_checks_sufficient_funds_after_applying_deposited_value() { // enable the Optimism flag - let (_api, handle) = - spawn(NodeConfig::test().with_optimism(true).with_hardfork(Some(Hardfork::Paris))).await; + let (_api, handle) = spawn( + NodeConfig::test().with_optimism(true).with_hardfork(Some(EthereumHardfork::Paris.into())), + ) + .await; let provider = http_provider(&handle.http_endpoint()); diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index fc153f9631cd3..2f2c0e3c1ce8a 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -9,7 +9,7 @@ use alloy_rpc_types::{ }; use alloy_serde::WithOtherFields; use alloy_sol_types::{sol, SolCall, SolError, SolValue}; -use anvil::{spawn, Hardfork, NodeConfig}; +use anvil::{spawn, EthereumHardfork, NodeConfig}; use std::collections::VecDeque; #[tokio::test(flavor = "multi_thread")] @@ -118,15 +118,15 @@ async fn ots_get_internal_operations_contract_create2() { #[tokio::test(flavor = "multi_thread")] async fn ots_get_internal_operations_contract_selfdestruct_london() { - ots_get_internal_operations_contract_selfdestruct(Hardfork::London).await; + ots_get_internal_operations_contract_selfdestruct(EthereumHardfork::London).await; } #[tokio::test(flavor = "multi_thread")] async fn ots_get_internal_operations_contract_selfdestruct_cancun() { - ots_get_internal_operations_contract_selfdestruct(Hardfork::Cancun).await; + ots_get_internal_operations_contract_selfdestruct(EthereumHardfork::Cancun).await; } -async fn ots_get_internal_operations_contract_selfdestruct(hardfork: Hardfork) { +async fn ots_get_internal_operations_contract_selfdestruct(hardfork: EthereumHardfork) { sol!( #[sol(rpc, bytecode = "608080604052607f908160108239f3fe6004361015600c57600080fd5b6000803560e01c6375fc8e3c14602157600080fd5b346046578060031936011260465773dcdd539da22bffaa499dbea4d37d086dde196e75ff5b80fdfea264697066735822122080a9ad005cc408b2d4e30ca11216d8e310700fbcdf58a629d6edbb91531f9c6164736f6c63430008190033")] contract Contract { @@ -137,7 +137,7 @@ async fn ots_get_internal_operations_contract_selfdestruct(hardfork: Hardfork) { } ); - let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(hardfork))).await; + let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(hardfork.into()))).await; let provider = handle.http_provider(); let sender = handle.dev_accounts().next().unwrap(); @@ -150,7 +150,7 @@ async fn ots_get_internal_operations_contract_selfdestruct(hardfork: Hardfork) { let receipt = contract.goodbye().send().await.unwrap().get_receipt().await.unwrap(); // TODO: This is currently not supported by revm-inspectors - let (expected_to, expected_value) = if hardfork < Hardfork::Cancun { + let (expected_to, expected_value) = if hardfork < EthereumHardfork::Cancun { (address!("DcDD539DA22bfFAa499dBEa4d37d086Dde196E75"), value) } else { (Address::ZERO, U256::ZERO) diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 9e09f8fcf639f..782e68d729d14 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -23,7 +23,7 @@ use alloy_rpc_types::{ }; use alloy_serde::WithOtherFields; use alloy_sol_types::sol; -use anvil::{spawn, Hardfork, NodeConfig}; +use anvil::{spawn, EthereumHardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] async fn test_get_transfer_parity_traces() { @@ -75,7 +75,8 @@ sol!( #[tokio::test(flavor = "multi_thread")] async fn test_parity_suicide_trace() { - let (_api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Shanghai))).await; + let (_api, handle) = + spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::Shanghai.into()))).await; let provider = handle.ws_provider(); let wallets = handle.dev_wallets().collect::>(); let owner = wallets[0].address(); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 0737209c1dc57..330eb7a3928f4 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -10,7 +10,7 @@ use alloy_rpc_types::{ AccessList, AccessListItem, BlockId, BlockNumberOrTag, BlockTransactions, TransactionRequest, }; use alloy_serde::WithOtherFields; -use anvil::{spawn, Hardfork, NodeConfig}; +use anvil::{spawn, EthereumHardfork, NodeConfig}; use eyre::Ok; use futures::{future::join_all, FutureExt, StreamExt}; use std::{collections::HashSet, str::FromStr, time::Duration}; @@ -1176,7 +1176,8 @@ async fn can_call_with_high_gas_limit() { #[tokio::test(flavor = "multi_thread")] async fn test_reject_eip1559_pre_london() { - let (api, handle) = spawn(NodeConfig::test().with_hardfork(Some(Hardfork::Berlin))).await; + let (api, handle) = + spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::Berlin.into()))).await; let provider = handle.http_provider(); let gas_limit = api.gas_limit().to::(); diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 8ece9ef65dedf..bb52936a9f730 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -2,7 +2,7 @@ use alloy_chains::NamedChain; use alloy_primitives::{b256, B256}; -use anvil::{Hardfork, NodeConfig}; +use anvil::{EthereumHardfork, NodeConfig}; use foundry_test_utils::{ casttest, file, rpc::{next_http_rpc_endpoint, next_rpc_endpoint, next_ws_rpc_endpoint}, @@ -1273,7 +1273,8 @@ casttest!(block_number_hash, |_prj, cmd| { casttest!(send_eip7702, async |_prj, cmd| { let (_api, handle) = - anvil::spawn(NodeConfig::test().with_hardfork(Some(Hardfork::PragueEOF))).await; + anvil::spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::PragueEOF.into()))) + .await; let endpoint = handle.http_endpoint(); cmd.args([ From 5881e0da10230e83c4458b52d49392c1c33c506c Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:25:55 +0300 Subject: [PATCH 1404/1963] Fix clippy - allow elided_named_lifetimes (#8787) --- crates/common/src/ens.rs | 2 +- crates/config/src/lib.rs | 1 + crates/doc/src/preprocessor/infer_hyperlinks.rs | 2 ++ crates/forge/src/multi_runner.rs | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index f84ea84cecab2..e120ad4c2a8a8 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -1,6 +1,6 @@ //! ENS Name resolving utilities. -#![allow(missing_docs)] +#![allow(missing_docs, elided_named_lifetimes)] use self::EnsResolver::EnsResolverInstance; use alloy_primitives::{address, Address, Keccak256, B256}; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d0fcc5a14ac5f..ef9c5f6b1cf9a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2,6 +2,7 @@ //! //! Foundry configuration. +#![allow(elided_named_lifetimes)] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index 613976ec8d079..5108ee374b4c5 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -1,3 +1,5 @@ +#![allow(elided_named_lifetimes)] + use super::{Preprocessor, PreprocessorId}; use crate::{Comments, Document, ParseItem, ParseSource}; use forge_fmt::solang_ext::SafeUnwrap; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 4df00f7944eee..cee986553cf62 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,5 +1,7 @@ //! Forge test runner for multiple contracts. +#![allow(elided_named_lifetimes)] + use crate::{ progress::TestsProgress, result::SuiteResult, runner::LIBRARY_DEPLOYER, ContractRunner, TestFilter, TestOptions, From c835d7ea9e34d3cb05bb2ba6e73a57fe51ab5ef8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:00:10 +0200 Subject: [PATCH 1405/1963] chore(deps): weekly `cargo update` (#8782) * chore(deps): weekly `cargo update` Updating git repository `https://github.com/alloy-rs/alloy` Updating git repository `https://github.com/bluealloy/revm` Locking 24 packages to latest compatible versions Updating aws-credential-types v1.2.0 -> v1.2.1 Updating aws-runtime v1.4.0 -> v1.4.2 Updating aws-sdk-kms v1.40.0 -> v1.41.0 Updating aws-sdk-sso v1.39.0 -> v1.40.0 Updating aws-sdk-ssooidc v1.40.0 -> v1.41.0 Updating aws-sdk-sts v1.39.0 -> v1.40.0 Updating aws-smithy-http v0.60.9 -> v0.60.10 Updating aws-smithy-runtime v1.6.3 -> v1.7.1 Updating aws-smithy-types v1.2.2 -> v1.2.4 Updating derive_builder v0.20.0 -> v0.20.1 Updating derive_builder_core v0.20.0 -> v0.20.1 Updating derive_builder_macro v0.20.0 -> v0.20.1 Updating filetime v0.2.24 -> v0.2.25 Updating indexmap v2.4.0 -> v2.5.0 Updating prost v0.13.1 -> v0.13.2 Updating prost-derive v0.13.1 -> v0.13.2 Updating prost-types v0.13.1 -> v0.13.2 Updating rustc_version v0.4.0 -> v0.4.1 Updating rustix v0.38.34 -> v0.38.35 Updating rustls-native-certs v0.7.2 -> v0.7.3 (latest: v0.8.0) Updating soldeer v0.3.1 -> v0.3.2 Updating syn v2.0.76 -> v2.0.77 Updating tokio v1.39.3 -> v1.40.0 Updating webpki-roots v0.26.3 -> v0.26.5 note: pass `--verbose` to see 146 unchanged dependencies behind latest * pin soldeer --------- Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> Co-authored-by: Matthias Seitz --- Cargo.lock | 241 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- 2 files changed, 122 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99ee3dae23678..c353292abfe05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -322,7 +322,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -557,7 +557,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -570,11 +570,11 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.4.0", + "indexmap 2.5.0", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "syn-solidity", "tiny-keccak", ] @@ -592,7 +592,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.76", + "syn 2.0.77", "syn-solidity", ] @@ -965,7 +965,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "zeroize", ] @@ -1100,7 +1100,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1122,7 +1122,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1133,7 +1133,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1144,7 +1144,7 @@ checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ "futures", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -1186,7 +1186,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1227,9 +1227,9 @@ dependencies = [ [[package]] name = "aws-credential-types" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16838e6c9e12125face1c1eff1343c75e3ff540de98ff7ebd61874a89bcfeb9" +checksum = "60e8f6b615cb5fc60a98132268508ad104310f0cfb25a1c22eee76efdf9154da" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -1239,14 +1239,15 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f42c2d4218de4dcd890a109461e2f799a1a2ba3bcd2cde9af88360f5df9266c6" +checksum = "2424565416eef55906f9f8cece2072b6b6a76075e3ff81483ebe938a89a4c05f" dependencies = [ "aws-credential-types", "aws-sigv4", "aws-smithy-async", "aws-smithy-http", + "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", "aws-types", @@ -1263,9 +1264,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ebbbc319551583b9233a74b359ede7349102e779fc12371d2478e80b50d218" +checksum = "178910fefe72743b62b9c4670c14a038ebfdb265ff7feccf43827af6a8899e14" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1285,9 +1286,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.39.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11822090cf501c316c6f75711d77b96fba30658e3867a7762e5e2f5d32d31e81" +checksum = "e5879bec6e74b648ce12f6085e7245417bc5f6d672781028384d2e494be3eb6d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1307,9 +1308,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a2a06ff89176123945d1bbe865603c4d7101bea216a550bb4d2e4e9ba74d74" +checksum = "4ef4cd9362f638c22a3b959fd8df292e7e47fdf170270f86246b97109b5f2f7d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1329,9 +1330,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.39.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20a91795850826a6f456f4a48eff1dfa59a0e69bdbf5b8c50518fd372106574" +checksum = "0b1e2735d2ab28b35ecbb5496c9d41857f52a0d6a0075bbf6a8af306045ea6f6" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1386,9 +1387,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.9" +version = "0.60.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9cd0ae3d97daa0a2bf377a4d8e8e1362cae590c4a1aad0d40058ebca18eb91e" +checksum = "01dbcb6e2588fd64cfb6d7529661b06466419e4c54ed1c62d6510d2d0350a728" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -1425,9 +1426,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.6.3" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0abbf454960d0db2ad12684a1640120e7557294b0ff8e2f11236290a1b293225" +checksum = "d1ce695746394772e7000b39fe073095db6d45a862d0767dd5ad0ac0d7f8eb87" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1469,9 +1470,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.2" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cee7cadb433c781d3299b916fbf620fea813bf38f49db282fb6858141a05cc8" +checksum = "273dcdfd762fae3e1650b8024624e7cd50e484e37abdab73a7a706188ad34543" dependencies = [ "base64-simd", "bytes", @@ -1509,7 +1510,7 @@ dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", "aws-smithy-types", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "tracing", ] @@ -2098,7 +2099,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2546,7 +2547,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2557,7 +2558,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2630,38 +2631,38 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "derive_builder" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" +checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d" +checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "derive_builder_macro" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" +checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" dependencies = [ "derive_builder_core", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2673,8 +2674,8 @@ dependencies = [ "convert_case 0.4.0", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn 2.0.76", + "rustc_version 0.4.1", + "syn 2.0.77", ] [[package]] @@ -2695,7 +2696,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "unicode-xid", ] @@ -2803,7 +2804,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2930,7 +2931,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3076,7 +3077,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.76", + "syn 2.0.77", "toml 0.8.19", "walkdir", ] @@ -3104,7 +3105,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.76", + "syn 2.0.77", "tempfile", "thiserror", "tiny-keccak", @@ -3224,9 +3225,9 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", @@ -3469,7 +3470,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3958,7 +3959,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap 2.4.0", + "indexmap 2.5.0", "itertools 0.13.0", "parking_lot", "proptest", @@ -4038,7 +4039,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4195,7 +4196,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4570,7 +4571,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -4589,7 +4590,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -4711,7 +4712,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4876,7 +4877,7 @@ dependencies = [ "hyper 1.4.1", "hyper-util", "rustls 0.23.12", - "rustls-native-certs 0.7.2", + "rustls-native-certs 0.7.3", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -5063,9 +5064,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -5126,7 +5127,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -5589,7 +5590,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -5680,7 +5681,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -5930,7 +5931,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6042,7 +6043,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6228,7 +6229,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6287,7 +6288,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6308,7 +6309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.4.0", + "indexmap 2.5.0", ] [[package]] @@ -6318,7 +6319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ "futures", - "rustc_version 0.4.0", + "rustc_version 0.4.1", ] [[package]] @@ -6371,7 +6372,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6429,7 +6430,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6548,7 +6549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6624,7 +6625,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "version_check", "yansi", ] @@ -6636,7 +6637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38ee68ae331824036479c84060534b18254c864fa73366c58d86db3b7b811619" dependencies = [ "futures", - "indexmap 2.4.0", + "indexmap 2.5.0", "nix 0.28.0", "tokio", "tracing", @@ -6693,9 +6694,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" dependencies = [ "bytes", "prost-derive", @@ -6703,22 +6704,22 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" dependencies = [ "anyhow", "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "prost-types" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +checksum = "60caa6738c7369b940c3d49246a8d1749323674c65cb13010134f5c9bad5b519" dependencies = [ "prost", ] @@ -7035,7 +7036,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.12", - "rustls-native-certs 0.7.2", + "rustls-native-certs 0.7.3", "rustls-pemfile 2.1.3", "rustls-pki-types", "serde", @@ -7285,18 +7286,18 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver 1.0.23", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" dependencies = [ "bitflags 2.6.0", "errno", @@ -7346,9 +7347,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" dependencies = [ "openssl-probe", "rustls-pemfile 2.1.3", @@ -7540,7 +7541,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -7702,7 +7703,7 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -7713,7 +7714,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -7722,7 +7723,7 @@ version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "itoa", "memchr", "ryu", @@ -7757,7 +7758,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -7787,7 +7788,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "itoa", "ryu", "serde", @@ -7816,7 +7817,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -8138,7 +8139,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -8206,9 +8207,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -8224,7 +8225,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -8329,7 +8330,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -8440,9 +8441,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -8464,7 +8465,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -8578,7 +8579,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", @@ -8600,7 +8601,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", @@ -8628,7 +8629,7 @@ dependencies = [ "percent-encoding", "pin-project 1.1.5", "prost", - "rustls-native-certs 0.7.2", + "rustls-native-certs 0.7.3", "rustls-pemfile 2.1.3", "socket2", "tokio", @@ -8735,7 +8736,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -9135,7 +9136,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-shared", ] @@ -9169,7 +9170,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9268,9 +9269,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.3" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" dependencies = [ "rustls-pki-types", ] @@ -9386,7 +9387,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -9397,7 +9398,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -9408,7 +9409,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -9419,7 +9420,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -9635,7 +9636,7 @@ dependencies = [ "js-sys", "log", "pharos", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "send_wrapper", "thiserror", "wasm-bindgen", @@ -9685,7 +9686,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -9705,7 +9706,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -9738,7 +9739,7 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap 2.4.0", + "indexmap 2.5.0", "memchr", "thiserror", "zopfli", diff --git a/Cargo.toml b/Cargo.toml index 50c33c653dba1..df99f6b4665f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -259,7 +259,7 @@ reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" # soldeer -soldeer = "0.3.1" +soldeer = "=0.3.1" proptest = "1" comfy-table = "7" From 386ca061b64f331a938f92a25b9557914b9ecdc8 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 3 Sep 2024 03:17:07 +0400 Subject: [PATCH 1406/1963] fix(eip7702): small fixes (#8791) * fix(eip7702): doc and small fixes * clippy --- crates/anvil/src/eth/error.rs | 15 +++++++++- crates/cast/bin/cmd/access_list.rs | 10 ++----- crates/cast/bin/cmd/call.rs | 10 ++----- crates/cast/bin/cmd/estimate.rs | 11 ++----- crates/cast/bin/cmd/mktx.rs | 8 ++---- crates/cast/bin/cmd/send.rs | 4 +-- crates/cast/bin/tx.rs | 46 ++++++++++++++---------------- 7 files changed, 48 insertions(+), 56 deletions(-) diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index b8b475deba006..7349cff7822e3 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -231,6 +231,12 @@ pub enum InvalidTransactionError { /// Thrown when there are no `blob_hashes` in the transaction. #[error("There should be at least one blob in a Blob transaction.")] EmptyBlobs, + /// Thrown when an access list is used before the berlin hard fork. + #[error("EIP-7702 authorization lists are not supported before the Prague hardfork")] + AuthorizationListNotSupported, + /// Forwards error from the revm + #[error(transparent)] + Revm(revm::primitives::InvalidTransaction), } impl From for InvalidTransactionError { @@ -263,7 +269,14 @@ impl From for InvalidTransactionError { InvalidTransaction::BlobVersionNotSupported => Self::BlobVersionNotSupported, InvalidTransaction::EmptyBlobs => Self::EmptyBlobs, InvalidTransaction::TooManyBlobs { max, have } => Self::TooManyBlobs(max, have), - _ => todo!(), + InvalidTransaction::AuthorizationListNotSupported => { + Self::AuthorizationListNotSupported + } + InvalidTransaction::AuthorizationListInvalidFields | + InvalidTransaction::InvalidAuthorizationList | + InvalidTransaction::OptimismError(_) | + InvalidTransaction::EofCrateShouldHaveToAddress | + InvalidTransaction::EmptyAuthorizationList => Self::Revm(err), } } } diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index fcaf848acbd4f..553d9c9ad4072 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -1,5 +1,4 @@ use crate::tx::{CastTxBuilder, SenderKind}; -use alloy_primitives::TxKind; use alloy_rpc_types::BlockId; use cast::Cast; use clap::Parser; @@ -55,15 +54,10 @@ impl AccessListArgs { let provider = utils::get_provider(&config)?; let sender = SenderKind::from_wallet_opts(eth.wallet).await?; - let tx_kind = if let Some(to) = to { - TxKind::Call(to.resolve(&provider).await?) - } else { - TxKind::Create - }; - let (tx, _) = CastTxBuilder::new(&provider, tx, &config) .await? - .with_tx_kind(tx_kind) + .with_to(to) + .await? .with_code_sig_and_args(None, sig, args) .await? .build_raw(sender) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 9a553e38507ca..5b1e1ff65fc11 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -143,12 +143,6 @@ impl CallArgs { let sender = SenderKind::from_wallet_opts(eth.wallet).await?; let from = sender.address(); - let tx_kind = if let Some(to) = to { - TxKind::Call(to.resolve(&provider).await?) - } else { - TxKind::Create - }; - let code = if let Some(CallSubcommands::Create { code, sig: create_sig, @@ -168,7 +162,8 @@ impl CallArgs { let (tx, func) = CastTxBuilder::new(&provider, tx, &config) .await? - .with_tx_kind(tx_kind) + .with_to(to) + .await? .with_code_sig_and_args(code, sig, args) .await? .build_raw(sender) @@ -192,6 +187,7 @@ impl CallArgs { let value = tx.value.unwrap_or_default(); let input = tx.inner.input.into_input().unwrap_or_default(); + let tx_kind = tx.inner.to.expect("set by builder"); let trace = match tx_kind { TxKind::Create => { diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 84812c8cc4447..315ba91dc564c 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -1,5 +1,5 @@ use crate::tx::{CastTxBuilder, SenderKind}; -use alloy_primitives::{TxKind, U256}; +use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::BlockId; use clap::Parser; @@ -73,12 +73,6 @@ impl EstimateArgs { let provider = utils::get_provider(&config)?; let sender = SenderKind::from_wallet_opts(eth.wallet).await?; - let tx_kind = if let Some(to) = to { - TxKind::Call(to.resolve(&provider).await?) - } else { - TxKind::Create - }; - let code = if let Some(EstimateSubcommands::Create { code, sig: create_sig, @@ -98,7 +92,8 @@ impl EstimateArgs { let (tx, _) = CastTxBuilder::new(&provider, tx, &config) .await? - .with_tx_kind(tx_kind) + .with_to(to) + .await? .with_code_sig_and_args(code, sig, args) .await? .build_raw(sender) diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index 4c7a55cb122e6..8a45b7363f5cf 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -6,7 +6,7 @@ use clap::Parser; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils::{self, get_provider}, + utils::get_provider, }; use foundry_common::ens::NameOrAddress; use foundry_config::Config; @@ -83,9 +83,6 @@ impl MakeTxArgs { }; let config = Config::from(ð); - let provider = utils::get_provider(&config)?; - - let tx_kind = tx::resolve_tx_kind(&provider, &code, &to).await?; // Retrieve the signer, and bail if it can't be constructed. let signer = eth.wallet.signer().await?; @@ -97,7 +94,8 @@ impl MakeTxArgs { let (tx, _) = CastTxBuilder::new(provider, tx, &config) .await? - .with_tx_kind(tx_kind) + .with_to(to) + .await? .with_code_sig_and_args(code, sig, args) .await? .with_blob_data(blob_data)? diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 573bb2bd1e206..cf3582fe03a6a 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -122,11 +122,11 @@ impl SendTxArgs { let config = Config::from(ð); let provider = utils::get_provider(&config)?; - let tx_kind = tx::resolve_tx_kind(&provider, &code, &to).await?; let builder = CastTxBuilder::new(&provider, tx, &config) .await? - .with_tx_kind(tx_kind) + .with_to(to) + .await? .with_code_sig_and_args(code, sig, args) .await? .with_blob_data(blob_data)?; diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index f6a9cbd53de99..419ad5bb6b8de 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -103,29 +103,14 @@ corresponds to the sender, or let foundry automatically detect it by not specify Ok(()) } -/// Ensures the transaction is either a contract deployment or a recipient address is specified -pub async fn resolve_tx_kind, T: Transport + Clone>( - provider: &P, - code: &Option, - to: &Option, -) -> Result { - if code.is_some() { - Ok(TxKind::Create) - } else if let Some(to) = to { - Ok(TxKind::Call(to.resolve(provider).await?)) - } else { - eyre::bail!("Must specify a recipient address or contract code to deploy"); - } -} - /// Initial state. #[derive(Debug)] pub struct InitState; /// State with known [TxKind]. #[derive(Debug)] -pub struct TxKindState { - kind: TxKind, +pub struct ToState { + to: Option
, } /// State with known input for the transaction. @@ -211,8 +196,9 @@ where } /// Sets [TxKind] for this builder and changes state to [TxKindState]. - pub fn with_tx_kind(self, kind: TxKind) -> CastTxBuilder { - CastTxBuilder { + pub async fn with_to(self, to: Option) -> Result> { + let to = if let Some(to) = to { Some(to.resolve(&self.provider).await?) } else { None }; + Ok(CastTxBuilder { provider: self.provider, tx: self.tx, legacy: self.legacy, @@ -220,13 +206,13 @@ where chain: self.chain, etherscan_api_key: self.etherscan_api_key, auth: self.auth, - state: TxKindState { kind }, + state: ToState { to }, _t: self._t, - } + }) } } -impl CastTxBuilder +impl CastTxBuilder where P: Provider, T: Transport + Clone, @@ -244,7 +230,7 @@ where parse_function_args( &sig, args, - self.state.kind.to().cloned(), + self.state.to, self.chain, &self.provider, self.etherscan_api_key.as_deref(), @@ -254,7 +240,7 @@ where (Vec::new(), None) }; - let input = if let Some(code) = code { + let input = if let Some(code) = &code { let mut code = hex::decode(code)?; code.append(&mut args); code @@ -262,6 +248,16 @@ where args }; + if self.state.to.is_none() && code.is_none() { + let has_value = self.tx.value.map_or(false, |v| !v.is_zero()); + let has_auth = self.auth.is_some(); + // We only allow user to omit the recipient address if transaction is an EIP-7702 tx + // without a value. + if !has_auth || has_value { + eyre::bail!("Must specify a recipient address or contract code to deploy"); + } + } + Ok(CastTxBuilder { provider: self.provider, tx: self.tx, @@ -270,7 +266,7 @@ where chain: self.chain, etherscan_api_key: self.etherscan_api_key, auth: self.auth, - state: InputState { kind: self.state.kind, input, func }, + state: InputState { kind: self.state.to.into(), input, func }, _t: self._t, }) } From d90e997d91532d902b0d6f786ff59777e69efa3a Mon Sep 17 00:00:00 2001 From: Felipe Buiras Date: Mon, 2 Sep 2024 20:31:19 -0300 Subject: [PATCH 1407/1963] fix(cheatcodes): fail when trying to parse malformatted strings as addresses (#8779) * fix(cheatcodes): fail when trying to parse malformatted strings as addresses * test: check non-address and badly checksummed addresses * fix: add check for address parsing when input is one-off * fix: do not error out on non-checksummed addresses * fix: remove custom address validation on typed json parsing * fix: change error message displayed on address parsing failure Co-authored-by: Arsenii Kulikov --------- Co-authored-by: Arsenii Kulikov --- crates/cheatcodes/src/json.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index 48c14e2a3ddc1..dad879e83b2d1 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -569,6 +569,9 @@ pub(super) fn json_value_to_token(value: &Value) -> Result { Value::String(string) => { if let Some(mut val) = string.strip_prefix("0x") { let s; + if val.len() == 39 { + return Err(format!("Cannot parse \"{val}\" as an address. If you want to specify address, prepend zero to the value.").into()) + } if val.len() % 2 != 0 { s = format!("0{val}"); val = &s[..]; From 91c0782acc39ee00ce0f841b242201b753aac192 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:54:06 +0300 Subject: [PATCH 1408/1963] fix(fuzz): apply inline max-test-rejects config (#8793) --- crates/forge/src/lib.rs | 6 ++++-- crates/forge/tests/it/fuzz.rs | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 6ad91ab6620c6..6c6552d05347b 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -115,6 +115,7 @@ impl TestOptions { .unwrap(); self.fuzzer_with_cases( fuzz_config.runs, + fuzz_config.max_test_rejects, Some(Box::new(FileFailurePersistence::Direct(failure_persist_path.leak()))), ) } @@ -128,7 +129,7 @@ impl TestOptions { /// - `test_fn` is the name of the test function declared inside the test contract. pub fn invariant_runner(&self, contract_id: &str, test_fn: &str) -> TestRunner { let invariant = self.invariant_config(contract_id, test_fn); - self.fuzzer_with_cases(invariant.runs, None) + self.fuzzer_with_cases(invariant.runs, invariant.max_assume_rejects, None) } /// Returns a "fuzz" configuration setup. Parameters are used to select tight scoped fuzz @@ -156,12 +157,13 @@ impl TestOptions { pub fn fuzzer_with_cases( &self, cases: u32, + max_global_rejects: u32, file_failure_persistence: Option>, ) -> TestRunner { let config = proptest::test_runner::Config { failure_persistence: file_failure_persistence, cases, - max_global_rejects: self.fuzz.max_test_rejects, + max_global_rejects, // Disable proptest shrink: for fuzz tests we provide single counterexample, // for invariant tests we shrink outside proptest. max_shrink_iters: 0, diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index f1c5edaaa58da..b0bd57a051c25 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -7,7 +7,7 @@ use forge::{ fuzz::CounterExample, result::{SuiteResult, TestStatus}, }; -use foundry_test_utils::Filter; +use foundry_test_utils::{forgetest_init, str, Filter}; use std::collections::BTreeMap; #[tokio::test(flavor = "multi_thread")] @@ -176,3 +176,29 @@ async fn test_scrape_bytecode() { } } } + +// tests that inline max-test-rejects config is properly applied +forgetest_init!(test_inline_max_test_rejects, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "Contract.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract InlineMaxRejectsTest is Test { + /// forge-config: default.fuzz.max-test-rejects = 1 + function test_fuzz_bound(uint256 a) public { + vm.assume(a == 0); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" +... +[FAIL. Reason: The `vm.assume` cheatcode rejected too many inputs (1 allowed)] test_fuzz_bound(uint256) (runs: 0, [AVG_GAS]) +... +"#]]); +}); From cb109b1699f82d009574d13aa59f1585a3fbfdb2 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:02:20 +0300 Subject: [PATCH 1409/1963] feat(cheatcodes): add vm.assumeNoRevert for fuzz tests (#8780) --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++ crates/cheatcodes/spec/src/vm.rs | 4 ++ crates/cheatcodes/src/inspector.rs | 28 +++++++-- crates/cheatcodes/src/test.rs | 16 +---- crates/cheatcodes/src/test/assume.rs | 29 +++++++++ crates/forge/tests/cli/test_cmd.rs | 79 ++++++++++++++++++++++++ testdata/cheats/Vm.sol | 1 + 7 files changed, 160 insertions(+), 17 deletions(-) create mode 100644 crates/cheatcodes/src/test/assume.rs diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 574d310ca19fc..4517f075e7fb0 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -2971,6 +2971,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "assumeNoRevert", + "description": "Discard this run's fuzz inputs and generate new ones if next call reverted.", + "declaration": "function assumeNoRevert() external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assumeNoRevert()", + "selector": "0x285b366a", + "selectorBytes": [ + 40, + 91, + 54, + 106 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "blobBaseFee", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 575ccfa84a5a7..980bab066a3a0 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -678,6 +678,10 @@ interface Vm { #[cheatcode(group = Testing, safety = Safe)] function assume(bool condition) external pure; + /// Discard this run's fuzz inputs and generate new ones if next call reverted. + #[cheatcode(group = Testing, safety = Safe)] + function assumeNoRevert() external pure; + /// Writes a breakpoint to jump to in the debugger. #[cheatcode(group = Testing, safety = Safe)] function breakpoint(string calldata char) external; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 1ff2a6e999dcc..f5238d810c8bd 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -9,9 +9,12 @@ use crate::{ }, inspector::utils::CommonCreateInput, script::{Broadcast, ScriptWallets}, - test::expect::{ - self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, - ExpectedRevert, ExpectedRevertKind, + test::{ + assume::AssumeNoRevert, + expect::{ + self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, + ExpectedRevert, ExpectedRevertKind, + }, }, utils::IgnoredTraces, CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, Vm, @@ -25,7 +28,7 @@ use foundry_config::Config; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseExt, RevertDiagnostic}, - constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, + constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME}, utils::new_evm_with_existing_context, InspectorExt, }; @@ -294,6 +297,9 @@ pub struct Cheatcodes { /// Expected revert information pub expected_revert: Option, + /// Assume next call can revert and discard fuzz run if it does. + pub assume_no_revert: Option, + /// Additional diagnostic for reverts pub fork_revert_diagnostic: Option, @@ -384,6 +390,7 @@ impl Cheatcodes { gas_price: Default::default(), prank: Default::default(), expected_revert: Default::default(), + assume_no_revert: Default::default(), fork_revert_diagnostic: Default::default(), accesses: Default::default(), recorded_account_diffs_stack: Default::default(), @@ -1106,6 +1113,19 @@ impl Inspector for Cheatcodes { } } + // Handle assume not revert cheatcode. + if let Some(assume_no_revert) = &self.assume_no_revert { + if ecx.journaled_state.depth() == assume_no_revert.depth && !cheatcode_call { + // Discard run if we're at the same depth as cheatcode and call reverted. + if outcome.result.is_revert() { + outcome.result.output = Error::from(MAGIC_ASSUME).abi_encode().into(); + return outcome; + } + // Call didn't revert, reset `assume_no_revert` state. + self.assume_no_revert = None; + } + } + // Handle expected reverts if let Some(expected_revert) = &self.expected_revert { if ecx.journaled_state.depth() <= expected_revert.depth { diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 279150dff89f4..0945f37a89c2a 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -3,25 +3,15 @@ use chrono::DateTime; use std::env; -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::Address; use alloy_sol_types::SolValue; -use foundry_evm_core::constants::{MAGIC_ASSUME, MAGIC_SKIP}; +use foundry_evm_core::constants::MAGIC_SKIP; pub(crate) mod assert; +pub(crate) mod assume; pub(crate) mod expect; -impl Cheatcode for assumeCall { - fn apply(&self, _state: &mut Cheatcodes) -> Result { - let Self { condition } = self; - if *condition { - Ok(Default::default()) - } else { - Err(Error::from(MAGIC_ASSUME)) - } - } -} - impl Cheatcode for breakpoint_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { char } = self; diff --git a/crates/cheatcodes/src/test/assume.rs b/crates/cheatcodes/src/test/assume.rs new file mode 100644 index 0000000000000..e100eeb9d1c43 --- /dev/null +++ b/crates/cheatcodes/src/test/assume.rs @@ -0,0 +1,29 @@ +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result}; +use foundry_evm_core::{backend::DatabaseExt, constants::MAGIC_ASSUME}; +use spec::Vm::{assumeCall, assumeNoRevertCall}; +use std::fmt::Debug; + +#[derive(Clone, Debug)] +pub struct AssumeNoRevert { + /// The call depth at which the cheatcode was added. + pub depth: u64, +} + +impl Cheatcode for assumeCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { condition } = self; + if *condition { + Ok(Default::default()) + } else { + Err(Error::from(MAGIC_ASSUME)) + } + } +} + +impl Cheatcode for assumeNoRevertCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + ccx.state.assume_no_revert = + Some(AssumeNoRevert { depth: ccx.ecx.journaled_state.depth() }); + Ok(Default::default()) + } +} diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 23ffa890d6030..19e5c4853d3ba 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1834,3 +1834,82 @@ contract CounterTest is DSTest { ... "#]]); }); + +forgetest_init!(test_assume_no_revert, |prj, cmd| { + prj.wipe_contracts(); + prj.insert_ds_test(); + prj.insert_vm(); + prj.clear(); + + prj.add_source( + "Counter.t.sol", + r#"pragma solidity 0.8.24; +import {Vm} from "./Vm.sol"; +import {DSTest} from "./test.sol"; +contract CounterWithRevert { + error CountError(); + error CheckError(); + + function count(uint256 a) public pure returns (uint256) { + if (a > 1000 || a < 10) { + revert CountError(); + } + return 99999999; + } + function check(uint256 a) public pure { + if (a == 99999999) { + revert CheckError(); + } + } + function dummy() public pure {} +} + +contract CounterRevertTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + function test_assume_no_revert_pass(uint256 a) public { + CounterWithRevert counter = new CounterWithRevert(); + vm.assumeNoRevert(); + a = counter.count(a); + assertEq(a, 99999999); + } + function test_assume_no_revert_fail_assert(uint256 a) public { + CounterWithRevert counter = new CounterWithRevert(); + vm.assumeNoRevert(); + a = counter.count(a); + // Test should fail on next assertion. + assertEq(a, 1); + } + function test_assume_no_revert_fail_in_2nd_call(uint256 a) public { + CounterWithRevert counter = new CounterWithRevert(); + vm.assumeNoRevert(); + a = counter.count(a); + // Test should revert here (not in scope of `assumeNoRevert` cheatcode). + counter.check(a); + assertEq(a, 99999999); + } + function test_assume_no_revert_fail_in_3rd_call(uint256 a) public { + CounterWithRevert counter = new CounterWithRevert(); + vm.assumeNoRevert(); + a = counter.count(a); + // Test `assumeNoRevert` applied to non reverting call should not be available for next reverting call. + vm.assumeNoRevert(); + counter.dummy(); + // Test will revert here (not in scope of `assumeNoRevert` cheatcode). + counter.check(a); + assertEq(a, 99999999); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).with_no_redact().assert_failure().stdout_eq(str![[r#" +... +[FAIL. Reason: assertion failed; counterexample: [..]] test_assume_no_revert_fail_assert(uint256) [..] +[FAIL. Reason: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_2nd_call(uint256) [..] +[FAIL. Reason: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_3rd_call(uint256) [..] +[PASS] test_assume_no_revert_pass(uint256) (runs: 256, [..]) +... +"#]]); +}); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index b929053dac012..5b6750237addb 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -144,6 +144,7 @@ interface Vm { function assertTrue(bool condition) external pure; function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; + function assumeNoRevert() external pure; function blobBaseFee(uint256 newBlobBaseFee) external; function blobhashes(bytes32[] calldata hashes) external; function breakpoint(string calldata char) external; From 143abd6a768eeb52a5785240b763d72a56987b4a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Sep 2024 23:09:26 +0200 Subject: [PATCH 1410/1963] chore: fix rustc lint elided_named_lifetimes (#8796) --- Cargo.lock | 4 ++-- crates/common/src/ens.rs | 2 +- crates/config/src/lib.rs | 3 +-- .../doc/src/preprocessor/infer_hyperlinks.rs | 4 +--- crates/forge/src/multi_runner.rs | 20 +++++++++---------- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c353292abfe05..5633a325106c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1127,9 +1127,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index e120ad4c2a8a8..f84ea84cecab2 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -1,6 +1,6 @@ //! ENS Name resolving utilities. -#![allow(missing_docs, elided_named_lifetimes)] +#![allow(missing_docs)] use self::EnsResolver::EnsResolverInstance; use alloy_primitives::{address, Address, Keccak256, B256}; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ef9c5f6b1cf9a..4dd6b8ce4bc1d 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2,7 +2,6 @@ //! //! Foundry configuration. -#![allow(elided_named_lifetimes)] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] @@ -1128,7 +1127,7 @@ impl Config { pub fn get_rpc_url_or<'a>( &'a self, fallback: impl Into>, - ) -> Result, UnresolvedEnvVarError> { + ) -> Result, UnresolvedEnvVarError> { if let Some(url) = self.get_rpc_url() { url } else { diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index 5108ee374b4c5..2d080278911b7 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -1,5 +1,3 @@ -#![allow(elided_named_lifetimes)] - use super::{Preprocessor, PreprocessorId}; use crate::{Comments, Document, ParseItem, ParseSource}; use forge_fmt::solang_ext::SafeUnwrap; @@ -228,7 +226,7 @@ impl<'a> InlineLink<'a> { }) } - fn captures(s: &'a str) -> impl Iterator + '_ { + fn captures(s: &'a str) -> impl Iterator + 'a { RE_INLINE_LINK.captures(s).map(Self::from_capture).into_iter().flatten() } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index cee986553cf62..43aade0ff65c1 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,7 +1,5 @@ //! Forge test runner for multiple contracts. -#![allow(elided_named_lifetimes)] - use crate::{ progress::TestsProgress, result::SuiteResult, runner::LIBRARY_DEPLOYER, ContractRunner, TestFilter, TestOptions, @@ -86,28 +84,28 @@ pub struct MultiContractRunner { impl MultiContractRunner { /// Returns an iterator over all contracts that match the filter. - pub fn matching_contracts<'a>( + pub fn matching_contracts<'a: 'b, 'b>( &'a self, - filter: &'a dyn TestFilter, - ) -> impl Iterator { + filter: &'b dyn TestFilter, + ) -> impl Iterator + 'b { self.contracts.iter().filter(|&(id, c)| matches_contract(id, &c.abi, filter)) } /// Returns an iterator over all test functions that match the filter. - pub fn matching_test_functions<'a>( + pub fn matching_test_functions<'a: 'b, 'b>( &'a self, - filter: &'a dyn TestFilter, - ) -> impl Iterator { + filter: &'b dyn TestFilter, + ) -> impl Iterator + 'b { self.matching_contracts(filter) .flat_map(|(_, c)| c.abi.functions()) .filter(|func| is_matching_test(func, filter)) } /// Returns an iterator over all test functions in contracts that match the filter. - pub fn all_test_functions<'a>( + pub fn all_test_functions<'a: 'b, 'b>( &'a self, - filter: &'a dyn TestFilter, - ) -> impl Iterator { + filter: &'b dyn TestFilter, + ) -> impl Iterator + 'b { self.contracts .iter() .filter(|(id, _)| filter.matches_path(&id.source) && filter.matches_contract(&id.name)) From 6d6d430f17ffdcab9dff75e1f00bcfbdae969fcf Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 4 Sep 2024 11:10:02 +0800 Subject: [PATCH 1411/1963] fix: small issues (#8800) --- crates/cast/src/lib.rs | 2 +- crates/forge/bin/cmd/selectors.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 95952bfbb7ce8..12d42c2c95389 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1043,7 +1043,7 @@ impl SimpleCast { if MAX { let mut max = U256::MAX; if n < 255 { - max &= U256::from(1).wrapping_shl(n); + max &= U256::from(1).wrapping_shl(n).wrapping_sub(U256::from(1)); } Ok(max.to_string()) } else { diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 04d19295c69cd..7b7bce2e5cd1d 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -330,7 +330,7 @@ impl SelectorsSubcommands { for error in abi.errors() { if error.selector().as_slice().starts_with(selector_bytes.as_slice()) { table.add_row([ - "Event", + "Error", &error.signature(), &hex::encode_prefixed(error.selector()), contract.as_str(), From d1271376d36e4cb24015bc6cde272468158e7c8d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:05:59 +0300 Subject: [PATCH 1412/1963] chore: fix `test_assume_no_revert` failing test (#8802) chore: fix nondeterministic failing test --- crates/forge/tests/cli/test_cmd.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 19e5c4853d3ba..3e3335f0c23ff 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1841,6 +1841,12 @@ forgetest_init!(test_assume_no_revert, |prj, cmd| { prj.insert_vm(); prj.clear(); + let config = Config { + fuzz: { FuzzConfig { runs: 100, seed: Some(U256::from(100)), ..Default::default() } }, + ..Default::default() + }; + prj.write_config(config); + prj.add_source( "Counter.t.sol", r#"pragma solidity 0.8.24; @@ -1909,7 +1915,7 @@ contract CounterRevertTest is DSTest { [FAIL. Reason: assertion failed; counterexample: [..]] test_assume_no_revert_fail_assert(uint256) [..] [FAIL. Reason: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_2nd_call(uint256) [..] [FAIL. Reason: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_3rd_call(uint256) [..] -[PASS] test_assume_no_revert_pass(uint256) (runs: 256, [..]) +[PASS] test_assume_no_revert_pass(uint256) [..] ... "#]]); }); From 63f9a0201903cff0df645a56fd44b5e7cc8dd8fd Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:17:10 +0530 Subject: [PATCH 1413/1963] fix(`forge bind`): default to alloy (#8806) * fix(forge-bind): default to alloy * nit --- crates/forge/bin/cmd/bind.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index f9e9a22a42e11..d5d23633243f4 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -104,10 +104,10 @@ impl BindArgs { let _ = ProjectCompiler::new().compile(&project)?; } - if !self.alloy { + if self.ethers { eprintln!( - "Warning: `--ethers` (default) bindings are deprecated and will be removed in the future. \ - Consider using `--alloy` instead." + "Warning: `--ethers` bindings are deprecated and will be removed in the future. \ + Consider using `--alloy` (default) instead." ); } @@ -191,7 +191,7 @@ impl BindArgs { fn get_json_files(&self, artifacts: &Path) -> Result> { let filter = self.get_filter()?; let alloy_filter = self.get_alloy_filter()?; - let is_alloy = self.alloy; + let is_alloy = !self.ethers; Ok(json_files(artifacts) .filter_map(|path| { // Ignore the build info JSON. @@ -264,7 +264,7 @@ impl BindArgs { /// Check that the existing bindings match the expected abigen output fn check_existing_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - if !self.alloy { + if self.ethers { return self.check_ethers(artifacts, bindings_root); } @@ -316,7 +316,7 @@ impl BindArgs { /// Generate the bindings fn generate_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - if !self.alloy { + if self.ethers { return self.generate_ethers(artifacts, bindings_root); } From eddb33a4119d8efadc2cd7857ef2c735e9d86e2b Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Wed, 4 Sep 2024 16:48:53 +0300 Subject: [PATCH 1414/1963] feat(cast/selectors): show function state mutability (#8804) --- Cargo.lock | 5 +++-- crates/cast/Cargo.toml | 2 +- crates/cast/bin/main.rs | 33 ++++++++++++++++----------------- crates/cast/src/lib.rs | 31 ++++++++++++++++++------------- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5633a325106c2..da993734f85ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3135,10 +3135,11 @@ dependencies = [ [[package]] name = "evmole" -version = "0.3.8" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffb1f458e6901be6a6aaa485ce3a5d81478644edde1ffbe95da114ad9c94467" +checksum = "d55794094e85dd9d2a4a44de6554015c7d0d7193a28756f2ee3432bb763003a7" dependencies = [ + "alloy-dyn-abi", "ruint", ] diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index edc3fbe8d6089..386c523b467f5 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -79,7 +79,7 @@ tempfile.workspace = true tokio = { workspace = true, features = ["macros", "signal"] } tracing.workspace = true yansi.workspace = true -evmole = "0.3.1" +evmole = "0.4.1" [target.'cfg(unix)'.dependencies] tikv-jemallocator = { workspace = true, optional = true } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 501955827fce7..8eaa201d6f5b2 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -305,25 +305,24 @@ async fn main() -> Result<()> { println!("{}", SimpleCast::disassemble(&bytecode)?); } CastSubcommand::Selectors { bytecode, resolve } => { - let selectors_and_args = SimpleCast::extract_selectors(&bytecode)?; - if resolve { - let selectors_it = selectors_and_args.iter().map(|r| &r.0); - let resolve_results = - decode_selectors(SelectorType::Function, selectors_it).await?; + let functions = SimpleCast::extract_functions(&bytecode)?; + let max_args_len = functions.iter().map(|r| r.1.len()).max().unwrap_or(0); + let max_mutability_len = functions.iter().map(|r| r.2.len()).max().unwrap_or(0); - let max_args_len = selectors_and_args.iter().map(|r| r.1.len()).max().unwrap_or(0); - for ((selector, arguments), func_names) in - selectors_and_args.into_iter().zip(resolve_results.into_iter()) - { - let resolved = match func_names { - Some(v) => v.join("|"), - None => String::new(), - }; - println!("{selector}\t{arguments:max_args_len$}\t{resolved}"); - } + let resolve_results = if resolve { + let selectors_it = functions.iter().map(|r| &r.0); + let ds = decode_selectors(SelectorType::Function, selectors_it).await?; + ds.into_iter().map(|v| v.unwrap_or_default().join("|")).collect() } else { - for (selector, arguments) in selectors_and_args { - println!("{selector}\t{arguments}"); + vec![] + }; + for (pos, (selector, arguments, state_mutability)) in functions.into_iter().enumerate() + { + if resolve { + let resolved = &resolve_results[pos]; + println!("{selector}\t{arguments:max_args_len$}\t{state_mutability:max_mutability_len$}\t{resolved}"); + } else { + println!("{selector}\t{arguments:max_args_len$}\t{state_mutability}"); } } } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 12d42c2c95389..c4d756ad72240 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1103,7 +1103,7 @@ impl SimpleCast { pub fn to_ascii(hex: &str) -> Result { let bytes = hex::decode(hex)?; if !bytes.iter().all(u8::is_ascii) { - return Err(eyre::eyre!("Invalid ASCII bytes")) + return Err(eyre::eyre!("Invalid ASCII bytes")); } Ok(String::from_utf8(bytes).unwrap()) } @@ -1405,7 +1405,7 @@ impl SimpleCast { let base_in = Base::unwrap_or_detect(base_in, value)?; let base_out: Base = base_out.parse()?; if base_in == base_out { - return Ok(value.to_string()) + return Ok(value.to_string()); } let mut n = NumberWithBase::parse_int(value, Some(&base_in.to_string()))?; @@ -1469,7 +1469,7 @@ impl SimpleCast { let s = if let Some(stripped) = s.strip_prefix("000000000000000000000000") { stripped } else { - return Err(eyre::eyre!("Not convertible to address, there are non-zero bytes")) + return Err(eyre::eyre!("Not convertible to address, there are non-zero bytes")); }; let lowercase_address_string = format!("0x{s}"); @@ -1925,7 +1925,7 @@ impl SimpleCast { } if optimize == 0 { let selector = get_func(signature)?.selector(); - return Ok((selector.to_string(), String::from(signature))) + return Ok((selector.to_string(), String::from(signature))); } let Some((name, params)) = signature.split_once('(') else { eyre::bail!("invalid function signature"); @@ -1947,7 +1947,7 @@ impl SimpleCast { if selector.iter().take_while(|&&byte| byte == 0).count() == optimize { found.store(true, Ordering::Relaxed); - return Some((nonce, hex::encode_prefixed(selector), input)) + return Some((nonce, hex::encode_prefixed(selector), input)); } nonce += nonce_step; @@ -1961,7 +1961,7 @@ impl SimpleCast { } } - /// Extracts function selectors and arguments from bytecode + /// Extracts function selectors, arguments and state mutability from bytecode /// /// # Example /// @@ -1969,16 +1969,21 @@ impl SimpleCast { /// use cast::SimpleCast as Cast; /// /// let bytecode = "6080604052348015600e575f80fd5b50600436106026575f3560e01c80632125b65b14602a575b5f80fd5b603a6035366004603c565b505050565b005b5f805f60608486031215604d575f80fd5b833563ffffffff81168114605f575f80fd5b925060208401356001600160a01b03811681146079575f80fd5b915060408401356001600160e01b03811681146093575f80fd5b80915050925092509256"; - /// let selectors = Cast::extract_selectors(bytecode)?; - /// assert_eq!(selectors, vec![("0x2125b65b".to_string(), "uint32,address,uint224".to_string())]); + /// let functions = Cast::extract_functions(bytecode)?; + /// assert_eq!(functions, vec![("0x2125b65b".to_string(), "uint32,address,uint224".to_string(), "pure")]); /// # Ok::<(), eyre::Report>(()) /// ``` - pub fn extract_selectors(bytecode: &str) -> Result> { + pub fn extract_functions(bytecode: &str) -> Result> { let code = hex::decode(strip_0x(bytecode))?; - let s = evmole::function_selectors(&code, 0); - - Ok(s.iter() - .map(|s| (hex::encode_prefixed(s), evmole::function_arguments(&code, s, 0))) + Ok(evmole::function_selectors(&code, 0) + .into_iter() + .map(|s| { + ( + hex::encode_prefixed(s), + evmole::function_arguments(&code, &s, 0), + evmole::function_state_mutability(&code, &s, 0), + ) + }) .collect()) } From ea3ba89e8179dc983abb7aa91a6f388c17ad3cec Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:45:43 +0300 Subject: [PATCH 1415/1963] feat: update soldeer 0 3 4 (#8777) * Update to 0.3.2 including a hotfix on the integrity check * fmt * replacing assert with data assert for files * Moved to Snapbox * reverse soldeer to 0.3.1 to test * reverted to old tests to check for timeout * updated to soldeer 0.3.3 * added stdout checks * fmt * updated output * updated to 0.3.4 which contains the windows fix * deleted non-deterministic output --- Cargo.lock | 96 ++--------- Cargo.toml | 2 +- crates/forge/tests/cli/soldeer.rs | 265 +++++++++++++++++++++++------- 3 files changed, 213 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da993734f85ed..846989c41aa05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1935,8 +1935,6 @@ version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ - "jobserver", - "libc", "shlex", ] @@ -2314,12 +2312,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "convert_case" version = "0.4.0" @@ -5211,15 +5203,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "jobserver" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.70" @@ -6165,17 +6148,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core", - "subtle", -] - [[package]] name = "paste" version = "1.0.15" @@ -6195,9 +6167,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest 0.10.7", - "hmac", - "password-hash", - "sha2", ] [[package]] @@ -8040,17 +8009,19 @@ dependencies = [ [[package]] name = "soldeer" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6191e16cbc3b4ed14cafc642bc2b7f966eddb7c1f3a9f60549f6a1e526016127" +checksum = "b9ed763c2bb43241ca0fb6c00feea54187895b7f4eb1090654fbf82807127369" dependencies = [ "chrono", "clap", "const-hex", + "dunce", "email-address-parser", "futures", "home", "ignore", + "path-slash", "regex", "reqwest", "rpassword", @@ -8063,7 +8034,7 @@ dependencies = [ "toml_edit", "uuid 1.10.0", "yansi", - "zip 2.2.0", + "zip", "zip-extract", ] @@ -8179,7 +8150,7 @@ dependencies = [ "tempfile", "thiserror", "url", - "zip 2.2.0", + "zip", ] [[package]] @@ -9710,25 +9681,6 @@ dependencies = [ "syn 2.0.77", ] -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "aes", - "byteorder", - "bzip2", - "constant_time_eq", - "crc32fast", - "crossbeam-utils", - "flate2", - "hmac", - "pbkdf2 0.11.0", - "sha1", - "zstd", -] - [[package]] name = "zip" version = "2.2.0" @@ -9736,6 +9688,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" dependencies = [ "arbitrary", + "bzip2", "crc32fast", "crossbeam-utils", "displaydoc", @@ -9748,13 +9701,13 @@ dependencies = [ [[package]] name = "zip-extract" -version = "0.1.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e109e5a291403b4c1e514d39f8a22d3f98d257e691a52bb1f16051bb1ffed63e" +checksum = "25a8c9e90f27d1435088a7b540b6cc8ae6ee525d992a695f16012d2f365b3d3c" dependencies = [ "log", "thiserror", - "zip 0.6.6", + "zip", ] [[package]] @@ -9770,32 +9723,3 @@ dependencies = [ "once_cell", "simd-adler32", ] - -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.13+zstd.1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/Cargo.toml b/Cargo.toml index df99f6b4665f5..9aa6ab471e6a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -259,7 +259,7 @@ reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" # soldeer -soldeer = "=0.3.1" +soldeer = "=0.3.4" proptest = "1" comfy-table = "7" diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index 21666edbb493b..6c57f69f30842 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -7,7 +7,6 @@ use std::{ use foundry_test_utils::forgesoldeer; use std::io::Write; - forgesoldeer!(install_dependency, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; @@ -15,8 +14,18 @@ forgesoldeer!(install_dependency, |prj, cmd| { let foundry_file = prj.root().join("foundry.toml"); cmd.arg("soldeer").args([command, dependency]).assert_success().stdout_eq(str![[r#" -🦌 Running [..]oldeer install 🦌 -... +🦌 Running Soldeer install 🦌 +No config file found. If you wish to proceed, please select how you want Soldeer to be configured: +1. Using foundry.toml +2. Using soldeer.toml +(Press 1 or 2), default is foundry.toml +Started HTTP download of forge-std~1.8.1 +Dependency forge-std~1.8.1 downloaded! +Adding dependency forge-std-1.8.1 to the config file +The dependency forge-std~1.8.1 was unzipped! +Writing forge-std~1.8.1 to the lock file. +Added forge-std~1.8.1 to remappings + "#]]); // Making sure the path was created to the dependency and that foundry.toml exists @@ -27,12 +36,17 @@ forgesoldeer!(install_dependency, |prj, cmd| { // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); + // let lock_contents = r#"[[dependencies]] + // name = "forge-std" + // version = "1.8.1" + // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" + // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" + // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" + // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); + // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); - assert!(actual_lock_contents - .contains("0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0")); - assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -56,9 +70,36 @@ forgesoldeer!(install_dependency_git, |prj, cmd| { let foundry_file = prj.root().join("foundry.toml"); - cmd.arg("soldeer").args([command, dependency, git]).assert_success().stdout_eq(str![[r#" -🦌 Running [..]oldeer install 🦌 -... + cmd.arg("soldeer") + .args([command, dependency, git]) + .assert_success() + .stdout_eq(str![[r#" +🦌 Running Soldeer install 🦌 +No config file found. If you wish to proceed, please select how you want Soldeer to be configured: +1. Using foundry.toml +2. Using soldeer.toml +(Press 1 or 2), default is foundry.toml +Started GIT download of forge-std~1.8.1 +Successfully downloaded forge-std~1.8.1 the dependency via git +Dependency forge-std~1.8.1 downloaded! +Adding dependency forge-std-1.8.1 to the config file +Writing forge-std~1.8.1 to the lock file. +Added forge-std~1.8.1 to remappings + +"#]]) + .stdout_eq(str![[r#" +🦌 Running Soldeer install 🦌 +No config file found. If you wish to proceed, please select how you want Soldeer to be configured: +1. Using foundry.toml +2. Using soldeer.toml +(Press 1 or 2), default is foundry.toml +Started GIT download of forge-std~1.8.1 +Successfully downloaded forge-std~1.8.1 the dependency via git +Dependency forge-std~1.8.1 downloaded! +Adding dependency forge-std-1.8.1 to the config file +Writing forge-std~1.8.1 to the lock file. +Added forge-std~1.8.1 to remappings + "#]]); // Making sure the path was created to the dependency and that README.md exists @@ -68,11 +109,16 @@ forgesoldeer!(install_dependency_git, |prj, cmd| { // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); + // let lock_contents = r#"[[dependencies]] + // name = "forge-std" + // version = "1.8.1" + // source = "https://gitlab.com/mario4582928/Mario.git" + // checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c" + // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); + // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); - assert!(actual_lock_contents.contains("22868f426bd4dd0e682b5ec5f9bd55507664240c")); - assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -102,8 +148,18 @@ forgesoldeer!(install_dependency_git_commit, |prj, cmd| { .args([command, dependency, git, rev_flag, commit]) .assert_success() .stdout_eq(str![[r#" -🦌 Running [..]oldeer install 🦌 -... +🦌 Running Soldeer install 🦌 +No config file found. If you wish to proceed, please select how you want Soldeer to be configured: +1. Using foundry.toml +2. Using soldeer.toml +(Press 1 or 2), default is foundry.toml +Started GIT download of forge-std~1.8.1 +Successfully downloaded forge-std~1.8.1 the dependency via git +Dependency forge-std~1.8.1 downloaded! +Adding dependency forge-std-1.8.1 to the config file +Writing forge-std~1.8.1 to the lock file. +Added forge-std~1.8.1 to remappings + "#]]); // Making sure the path was created to the dependency and that README.md exists @@ -114,12 +170,16 @@ forgesoldeer!(install_dependency_git_commit, |prj, cmd| { // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); + // let lock_contents = r#"[[dependencies]] + // name = "forge-std" + // version = "1.8.1" + // source = "https://gitlab.com/mario4582928/Mario.git" + // checksum = "7a0663eaf7488732f39550be655bad6694974cb3" + // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); + // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); - assert!(actual_lock_contents.contains("7a0663eaf7488732f39550be655bad6694974cb3")); - assert!(actual_lock_contents.contains("https://gitlab.com/mario4582928/Mario.git")); - assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -157,20 +217,10 @@ mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/ eprintln!("Couldn't write to file: {e}"); } - cmd.arg("soldeer").arg(command).assert_success().stdout_eq(str![[r#" -🦌 Running [..]oldeer update 🦌 -... - -"#]]); + cmd.arg("soldeer").arg(command).assert_success(); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly - let path_dep_forge = - prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); - assert!(path_dep_forge.exists()); - - // Making sure the lock contents are the right ones - let path_lock_file = prj.root().join("soldeer.lock"); let dep1 = prj.root().join("dependencies").join("@tt-1.6.1"); let dep2 = prj.root().join("dependencies").join("forge-std-1.8.1"); let dep3 = prj.root().join("dependencies").join("mario-1.0"); @@ -178,13 +228,58 @@ mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/ let dep5 = prj.root().join("dependencies").join("mario-custom-tag-1.0"); let dep6 = prj.root().join("dependencies").join("mario-custom-branch-1.0"); + assert!(dep1.exists()); + assert!(dep2.exists()); + assert!(dep3.exists()); + assert!(dep4.exists()); + assert!(dep5.exists()); + assert!(dep6.exists()); + + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + // let lock_contents = r#"[[dependencies]] + // name = "@tt" + // version = "1.6.1" + // source = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/3_3_0-rc_2_22-01-2024_13:12:57_contracts.zip" + // checksum = "3aa5b07e796ce2ae54bbab3a5280912444ae75807136a513fa19ff3a314c323f" + // integrity = "24e7847580674bd0a4abf222b82fac637055141704c75a3d679f637acdcfe817" + + // [[dependencies]] + // name = "forge-std" + // version = "1.8.1" + // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" + // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" + // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" + + // [[dependencies]] + // name = "mario" + // version = "1.0" + // source = "https://gitlab.com/mario4582928/Mario.git" + // checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c" + + // [[dependencies]] + // name = "mario-custom-branch" + // version = "1.0" + // source = "https://gitlab.com/mario4582928/Mario.git" + // checksum = "84c3b38dba44a4c29ec44f45a31e1e59d36aa77b" + + // [[dependencies]] + // name = "mario-custom-tag" + // version = "1.0" + // source = "https://gitlab.com/mario4582928/Mario.git" + // checksum = "a366c4b560022d12e668d6c1756c6382e2352d0f" + + // [[dependencies]] + // name = "solmate" + // version = "6.7.0" + // source = "https://soldeer-revisions.s3.amazonaws.com/solmate/6_7_0_22-01-2024_13:21:00_solmate.zip" + // checksum = "dd0f08cdaaaad1de0ac45993d4959351ba89c2d9325a0b5df5570357064f2c33" + // integrity = "ec330877af853f9d34b2b1bf692fb33c9f56450625f5c4abdcf0d3405839730e" + // "#; + + // assert_data_eq!(lock_contents, read_file_to_string(&path_lock_file)); let actual_lock_contents = read_file_to_string(&path_lock_file); - assert!(actual_lock_contents.contains("@tt")); assert!(actual_lock_contents.contains("forge-std")); - assert!(actual_lock_contents.contains("mario")); - assert!(actual_lock_contents.contains("solmate")); - assert!(actual_lock_contents.contains("mario-custom-tag")); - assert!(actual_lock_contents.contains("mario-custom-branch")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -204,12 +299,6 @@ mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/ "#; assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); - assert!(dep1.exists()); - assert!(dep2.exists()); - assert!(dep3.exists()); - assert!(dep4.exists()); - assert!(dep5.exists()); - assert!(dep6.exists()); }); forgesoldeer!(update_dependencies_simple_version, |prj, cmd| { @@ -230,8 +319,11 @@ forge-std = "1.8.1" } cmd.arg("soldeer").arg(command).assert_success().stdout_eq(str![[r#" -🦌 Running [..]oldeer update 🦌 -... +🦌 Running Soldeer update 🦌 +Started HTTP download of forge-std~1.8.1 +Dependency forge-std~1.8.1 downloaded! +The dependency forge-std~1.8.1 was unzipped! +Writing forge-std~1.8.1 to the lock file. "#]]); @@ -243,12 +335,17 @@ forge-std = "1.8.1" // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); + // let lock_contents = r#"[[dependencies]] + // name = "forge-std" + // version = "1.8.1" + // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" + // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" + // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" + // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); + // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); - assert!(actual_lock_contents - .contains("0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0")); - assert!(actual_lock_contents.contains("1.8.1")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] @@ -268,20 +365,11 @@ forge-std = "1.8.1" forgesoldeer!(login, |prj, cmd| { let command = "login"; - cmd.arg("soldeer") - .arg(command) - .assert_failure() - .stderr_eq(str![[r#" -Error: -Failed to run [..] + let output = cmd.arg("soldeer").arg(command).execute(); -"#]]) - .stdout_eq(str![[r#" -🦌 Running [..]oldeer login 🦌 -... -ℹ️ If you do not have an account, please go to soldeer.xyz to create one. -📧 Please enter your email: -"#]]); + // On login, we can only check if the prompt is displayed in the stdout + let stdout = String::from_utf8(output.stdout).expect("Could not parse the output"); + assert!(stdout.contains("Please enter your email")); }); forgesoldeer!(install_dependency_with_remappings_config, |prj, cmd| { @@ -301,8 +389,20 @@ remappings_regenerate = true eprintln!("Couldn't write to file: {e}"); } - cmd.arg("soldeer").args([command, dependency]); - cmd.execute(); + cmd.arg("soldeer").args([command, dependency]).assert_success().stdout_eq(str![[r#" +🦌 Running Soldeer install 🦌 +No config file found. If you wish to proceed, please select how you want Soldeer to be configured: +1. Using foundry.toml +2. Using soldeer.toml +(Press 1 or 2), default is foundry.toml +Started HTTP download of forge-std~1.8.1 +Dependency forge-std~1.8.1 downloaded! +Adding dependency forge-std-1.8.1 to the config file +The dependency forge-std~1.8.1 was unzipped! +Writing forge-std~1.8.1 to the lock file. +Added all dependencies to remapppings + +"#]]); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -310,6 +410,20 @@ remappings_regenerate = true prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); assert!(path_dep_forge.exists()); + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + // let lock_contents = r#"[[dependencies]] + // name = "forge-std" + // version = "1.8.1" + // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" + // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" + // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" + // "#; + + let actual_lock_contents = read_file_to_string(&path_lock_file); + // assert_data_eq!(lock_contents, actual_lock_contents); + assert!(actual_lock_contents.contains("forge-std")); + // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] src = "src" @@ -349,8 +463,20 @@ remappings_regenerate = true eprintln!("Couldn't write to file: {e}"); } - cmd.arg("soldeer").args([command, dependency]); - cmd.execute(); + cmd.arg("soldeer").args([command, dependency]).assert_success().stdout_eq(str![[r#" +🦌 Running Soldeer install 🦌 +No config file found. If you wish to proceed, please select how you want Soldeer to be configured: +1. Using foundry.toml +2. Using soldeer.toml +(Press 1 or 2), default is foundry.toml +Started HTTP download of forge-std~1.8.1 +Dependency forge-std~1.8.1 downloaded! +Adding dependency forge-std-1.8.1 to the config file +The dependency forge-std~1.8.1 was unzipped! +Writing forge-std~1.8.1 to the lock file. +Added all dependencies to remapppings + +"#]]); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -358,11 +484,24 @@ remappings_regenerate = true prj.root().join("dependencies").join("forge-std-1.8.1").join("foundry.toml"); assert!(path_dep_forge.exists()); + // Making sure the lock contents are the right ones + let path_lock_file = prj.root().join("soldeer.lock"); + // let lock_contents = r#"[[dependencies]] + // name = "forge-std" + // version = "1.8.1" + // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" + // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" + // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" + // "#; + + let actual_lock_contents = read_file_to_string(&path_lock_file); + // assert_data_eq!(lock_contents, actual_lock_contents); + assert!(actual_lock_contents.contains("forge-std")); + // Making sure the foundry contents are the right ones - let remappings_content = "@custom-f@forge-std-1.8.1/=dependencies/forge-std-1.8.1/\n"; + let remappings_content = r#"@custom-f@forge-std-1.8.1/=dependencies/forge-std-1.8.1/ +"#; let remappings_file = prj.root().join("remappings.txt"); - println!("ddd {:?}", read_file_to_string(&remappings_file)); - assert_data_eq!(read_file_to_string(&remappings_file), remappings_content); }); From 3f15f9a83377daac583ff87f900cb6d86ee4499f Mon Sep 17 00:00:00 2001 From: James <107906898+EdwardJES@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:15:03 +1000 Subject: [PATCH 1416/1963] feat(anvil): 7368 reorg (#8489) * solve merge conflicts * clean up imports * address last nits * small fix * small comment fix * make comment clearer --- crates/anvil/core/src/eth/mod.rs | 81 ++++++++++- crates/anvil/core/src/eth/transaction/mod.rs | 30 ++++ crates/anvil/core/src/types.rs | 20 ++- crates/anvil/src/eth/api.rs | 131 ++++++++++++++++- crates/anvil/src/eth/backend/mem/mod.rs | 70 +++++++++ crates/anvil/src/eth/backend/mem/storage.rs | 17 +++ crates/anvil/src/eth/pool/transactions.rs | 9 +- crates/anvil/tests/it/anvil_api.rs | 145 ++++++++++++++++++- 8 files changed, 493 insertions(+), 10 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 7c86baad32ae4..11342b8177572 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -1,4 +1,4 @@ -use crate::eth::subscription::SubscriptionId; +use crate::{eth::subscription::SubscriptionId, types::ReorgOptions}; use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256}; use alloy_rpc_types::{ anvil::{Forking, MineOptions}, @@ -768,6 +768,10 @@ pub enum EthRequest { serde(rename = "anvil_removePoolTransactions", with = "sequence") )] RemovePoolTransactions(Address), + + /// Reorg the chain + #[cfg_attr(feature = "serde", serde(rename = "anvil_reorg",))] + Reorg(ReorgOptions), } /// Represents ethereum JSON-RPC API @@ -1595,4 +1599,79 @@ true}]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); } + + #[test] + fn test_serde_anvil_reorg() { + // TransactionData::JSON + let s = r#" + { + "method": "anvil_reorg", + "params": [ + 5, + [ + [ + { + "from": "0x976EA74026E726554dB657fA54763abd0C3a0aa9", + "to": "0x1199bc69f16FDD6690DC40339EC445FaE1b6DD11", + "value": 100 + }, + 1 + ], + [ + { + "from": "0x976EA74026E726554dB657fA54763abd0C3a0aa9", + "to": "0x1199bc69f16FDD6690DC40339EC445FaE1b6DD11", + "value": 200 + }, + 2 + ] + ] + ] + } + "#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + // TransactionData::Raw + let s = r#" + { + "method": "anvil_reorg", + "params": [ + 5, + [ + [ + "0x19d55c67e1ba8f1bbdfed75f8ad524ebf087e4ecb848a2d19881d7a5e3d2c54e1732cb1b462da3b3fdb05bdf4c4d3c8e3c9fcebdc2ab5fa5d59a3f752888f27e1b", + 1 + ] + ] + ] + } + "#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + // TransactionData::Raw and TransactionData::JSON + let s = r#" + { + "method": "anvil_reorg", + "params": [ + 5, + [ + [ + "0x19d55c67e1ba8f1bbdfed75f8ad524ebf087e4ecb848a2d19881d7a5e3d2c54e1732cb1b462da3b3fdb05bdf4c4d3c8e3c9fcebdc2ab5fa5d59a3f752888f27e1b", + 1 + ], + [ + { + "from": "0x976EA74026E726554dB657fA54763abd0C3a0aa9", + "to": "0x1199bc69f16FDD6690DC40339EC445FaE1b6DD11", + "value": 200 + }, + 2 + ] + ] + ] + } + "#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let _req = serde_json::from_value::(value).unwrap(); + } } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 4320b423af009..d080f1e27cb74 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -674,6 +674,36 @@ pub enum TypedTransaction { Deposit(DepositTransaction), } +/// This is a function that demotes TypedTransaction to TransactionRequest for greater flexibility +/// over the type. +/// +/// This function is purely for convience and specific use cases, e.g. RLP encoded transactions +/// decode to TypedTransactions where the API over TypedTransctions is quite strict. +impl TryFrom for TransactionRequest { + type Error = ConversionError; + + fn try_from(value: TypedTransaction) -> Result { + let from = value.recover().map_err(|_| ConversionError::InvalidSignature)?; + let essentials = value.essentials(); + let tx_type = value.r#type(); + Ok(Self { + from: Some(from), + to: Some(value.kind()), + gas_price: essentials.gas_price, + max_fee_per_gas: essentials.max_fee_per_gas, + max_priority_fee_per_gas: essentials.max_priority_fee_per_gas, + max_fee_per_blob_gas: essentials.max_fee_per_blob_gas, + gas: Some(essentials.gas_limit), + value: Some(essentials.value), + input: essentials.input.into(), + nonce: Some(essentials.nonce), + chain_id: essentials.chain_id, + transaction_type: tx_type, + ..Default::default() + }) + } +} + impl TypedTransaction { /// Returns true if the transaction uses dynamic fees: EIP1559 or EIP4844 pub fn is_dynamic_fee(&self) -> bool { diff --git a/crates/anvil/core/src/types.rs b/crates/anvil/core/src/types.rs index 348686abc4ad7..ca756358840aa 100644 --- a/crates/anvil/core/src/types.rs +++ b/crates/anvil/core/src/types.rs @@ -1,5 +1,7 @@ -use alloy_primitives::{B256, U256}; +use alloy_primitives::{Bytes, B256, U256}; +use alloy_rpc_types::TransactionRequest; +use serde::Deserialize; #[cfg(feature = "serde")] use serde::Serializer; @@ -26,3 +28,19 @@ impl serde::Serialize for Work { } } } + +/// Represents the options used in `anvil_reorg` +#[derive(Debug, Clone, Deserialize)] +pub struct ReorgOptions { + // The depth of the reorg + pub depth: u64, + // List of transaction requests and blocks pairs to be mined into the new chain + pub tx_block_pairs: Vec<(TransactionData, u64)>, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(untagged)] +pub enum TransactionData { + JSON(TransactionRequest), + Raw(Bytes), +} diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index fbd37a3f2a4ee..937cd85048470 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -64,7 +64,7 @@ use anvil_core::{ }, EthRequest, }, - types::Work, + types::{ReorgOptions, TransactionData, Work}, }; use anvil_rpc::{error::RpcError, response::ResponseResult}; use foundry_common::provider::ProviderBuilder; @@ -79,7 +79,12 @@ use foundry_evm::{ }; use futures::channel::{mpsc::Receiver, oneshot}; use parking_lot::RwLock; -use std::{collections::HashSet, future::Future, sync::Arc, time::Duration}; +use std::{ + collections::{HashMap, HashSet}, + future::Future, + sync::Arc, + time::Duration, +}; /// The client version: `anvil/v{major}.{minor}.{patch}` pub const CLIENT_VERSION: &str = concat!("anvil/v", env!("CARGO_PKG_VERSION")); @@ -440,6 +445,9 @@ impl EthApi { EthRequest::RemovePoolTransactions(address) => { self.anvil_remove_pool_transactions(address).await.to_rpc_result() } + EthRequest::Reorg(reorg_options) => { + self.anvil_reorg(reorg_options).await.to_rpc_result() + } } } @@ -995,6 +1003,7 @@ impl EthApi { if data.is_empty() { return Err(BlockchainError::EmptyRawTransactionData); } + let transaction = TypedTransaction::decode_2718(&mut data) .map_err(|_| BlockchainError::FailedToDecodeSignedTransaction)?; @@ -1915,6 +1924,124 @@ impl EthApi { Ok(()) } + /// Reorg the chain to a specific depth and mine new blocks back to the cannonical height. + /// + /// e.g depth = 3 + /// A -> B -> C -> D -> E + /// A -> B -> C' -> D' -> E' + /// + /// Depth specifies the height to reorg the chain back to. Depth must not exceed the current + /// chain height, i.e. can't reorg past the genesis block. + /// + /// Optionally supply a list of transaction and block pairs that will populate the reorged + /// blocks. The maximum block number of the pairs must not exceed the specified depth. + /// + /// Handler for RPC call: `anvil_reorg` + pub async fn anvil_reorg(&self, options: ReorgOptions) -> Result<()> { + node_info!("anvil_reorg"); + let depth = options.depth; + let tx_block_pairs = options.tx_block_pairs; + + // Check reorg depth doesn't exceed current chain height + let current_height = self.backend.best_number(); + let common_height = current_height.checked_sub(depth).ok_or(BlockchainError::RpcError( + RpcError::invalid_params(format!( + "Reorg depth must not exceed current chain height: current height {current_height}, depth {depth}" + )), + ))?; + + // Get the common ancestor block + let common_block = + self.backend.get_block(common_height).ok_or(BlockchainError::BlockNotFound)?; + + // Convert the transaction requests to pool transactions if they exist, otherwise use empty + // hashmap + let block_pool_txs = if tx_block_pairs.is_empty() { + HashMap::new() + } else { + let mut pairs = tx_block_pairs; + + // Check the maximum block supplied number will not exceed the reorged chain height + if let Some((_, num)) = pairs.iter().find(|(_, num)| *num >= depth) { + return Err(BlockchainError::RpcError(RpcError::invalid_params(format!( + "Block number for reorg tx will exceed the reorged chain height. Block number {num} must not exceed (depth-1) {}", + depth-1 + )))); + } + + // Sort by block number to make it easier to manage new nonces + pairs.sort_by_key(|a| a.1); + + // Manage nonces for each signer + // address -> cumulative nonce + let mut nonces: HashMap = HashMap::new(); + + let mut txs: HashMap>> = HashMap::new(); + for pair in pairs { + let (tx_data, block_index) = pair; + + let mut tx_req = match tx_data { + TransactionData::JSON(req) => WithOtherFields::new(req), + TransactionData::Raw(bytes) => { + let mut data = bytes.as_ref(); + let decoded = TypedTransaction::decode_2718(&mut data) + .map_err(|_| BlockchainError::FailedToDecodeSignedTransaction)?; + let request = + TransactionRequest::try_from(decoded.clone()).map_err(|_| { + BlockchainError::RpcError(RpcError::invalid_params( + "Failed to convert raw transaction", + )) + })?; + WithOtherFields::new(request) + } + }; + + let from = tx_req.from.map(Ok).unwrap_or_else(|| { + self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) + })?; + + // Get the nonce at the common block + let curr_nonce = nonces.entry(from).or_insert( + self.get_transaction_count(from, Some(common_block.header.number.into())) + .await?, + ); + + // Estimate gas + if tx_req.gas.is_none() { + if let Ok(gas) = self.estimate_gas(tx_req.clone(), None, None).await { + tx_req.gas = Some(gas.to()); + } + } + + // Build typed transaction request + let typed = self.build_typed_tx_request(tx_req, *curr_nonce)?; + + // Increment nonce + *curr_nonce += 1; + + // Handle signer and convert to pending transaction + let pending = if self.is_impersonated(from) { + let bypass_signature = self.impersonated_signature(&typed); + let transaction = sign::build_typed_transaction(typed, bypass_signature)?; + self.ensure_typed_transaction_supported(&transaction)?; + PendingTransaction::with_impersonated(transaction, from) + } else { + let transaction = self.sign_request(&from, typed)?; + self.ensure_typed_transaction_supported(&transaction)?; + PendingTransaction::new(transaction)? + }; + + let pooled = PoolTransaction::new(pending); + txs.entry(block_index).or_default().push(Arc::new(pooled)); + } + + txs + }; + + self.backend.reorg(depth, block_pool_txs, common_block).await?; + Ok(()) + } + /// Snapshot the state of the blockchain at the current block. /// /// Handler for RPC call: `evm_snapshot` diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 12ae96dabd73d..054aa59256e1c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2440,6 +2440,76 @@ impl Backend { .lock() .retain(|tx| tx.unbounded_send(notification.clone()).is_ok()); } + + /// Reorg the chain to a common height and execute blocks to build new chain. + /// + /// The state of the chain is rewound using `rewind` to the common block, including the db, + /// storage, and env. + /// + /// Finally, `do_mine_block` is called to create the new chain. + pub async fn reorg( + &self, + depth: u64, + tx_pairs: HashMap>>, + common_block: Block, + ) -> Result<(), BlockchainError> { + // Get the database at the common block + let common_state = { + let mut state = self.states.write(); + let state_db = state + .get(&common_block.header.hash_slow()) + .ok_or(BlockchainError::DataUnavailable)?; + let db_full = state_db.maybe_as_full_db().ok_or(BlockchainError::DataUnavailable)?; + db_full.clone() + }; + + { + // Set state to common state + self.db.write().await.clear(); + for (address, acc) in common_state { + for (key, value) in acc.storage { + self.db.write().await.set_storage_at(address, key, value)?; + } + self.db.write().await.insert_account(address, acc.info); + } + } + + { + // Unwind the storage back to the common ancestor + self.blockchain + .storage + .write() + .unwind_to(common_block.header.number, common_block.header.hash_slow()); + + // Set environment back to common block + let mut env = self.env.write(); + env.block = BlockEnv { + number: U256::from(common_block.header.number), + timestamp: U256::from(common_block.header.timestamp), + gas_limit: U256::from(common_block.header.gas_limit), + difficulty: common_block.header.difficulty, + prevrandao: Some(common_block.header.mix_hash), + coinbase: env.block.coinbase, + basefee: env.block.basefee, + ..env.block.clone() + }; + self.time.reset(env.block.timestamp.to::()); + } + + // Create the new reorged chain, filling the blocks with transactions if supplied + for i in 0..depth { + let to_be_mined = tx_pairs.get(&i).cloned().unwrap_or_else(Vec::new); + let outcome = self.do_mine_block(to_be_mined).await; + node_info!( + " Mined reorg block number {}. With {} valid txs and with invalid {} txs", + outcome.block_number, + outcome.included.len(), + outcome.invalid.len() + ); + } + + Ok(()) + } } /// Get max nonce from transaction pool by address diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index aaa2f29e725a2..2b5886a6f1768 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -271,6 +271,23 @@ impl BlockchainStorage { } } + /// Unwind the chain state back to the given block in storage. + /// + /// The block identified by `block_number` and `block_hash` is __non-inclusive__, i.e. it will + /// remain in the state. + pub fn unwind_to(&mut self, block_number: u64, block_hash: B256) { + let best_num: u64 = self.best_number.try_into().unwrap_or(0); + for i in (block_number + 1)..=best_num { + if let Some(hash) = self.hashes.remove(&U64::from(i)) { + if let Some(block) = self.blocks.remove(&hash) { + self.remove_block_transactions_by_number(block.header.number); + } + } + } + self.best_hash = block_hash; + self.best_number = U64::from(block_number); + } + #[allow(unused)] pub fn empty() -> Self { Self { diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 502ee1e7886fa..f0987572ba0ff 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -85,6 +85,14 @@ pub struct PoolTransaction { // == impl PoolTransaction == impl PoolTransaction { + pub fn new(transaction: PendingTransaction) -> Self { + Self { + pending_transaction: transaction, + requires: vec![], + provides: vec![], + priority: TransactionPriority(0), + } + } /// Returns the hash of this transaction pub fn hash(&self) -> TxHash { *self.pending_transaction.hash() @@ -121,7 +129,6 @@ impl TryFrom for PoolTransaction { }) } } - /// A waiting pool of transaction that are pending, but not yet ready to be included in a new block. /// /// Keeps a set of transactions that are waiting for other transactions diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 1b94f5e439e7b..1f1c48e21ad22 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -1,20 +1,26 @@ //! tests for custom anvil endpoints use crate::{ - abi::{Greeter, MulticallContract, BUSD}, + abi::{self, Greeter, MulticallContract, BUSD}, fork::fork_config, utils::http_provider_with_signer, }; -use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{address, fixed_bytes, Address, U256}; +use alloy_consensus::{SignableTransaction, TxEip1559}; +use alloy_network::{EthereumWallet, TransactionBuilder, TxSignerSync}; +use alloy_primitives::{address, fixed_bytes, Address, Bytes, TxKind, U256}; use alloy_provider::{ext::TxPoolApi, Provider}; use alloy_rpc_types::{ - anvil::{ForkedNetwork, Forking, Metadata, NodeEnvironment, NodeForkConfig, NodeInfo}, + anvil::{ + ForkedNetwork, Forking, Metadata, MineOptions, NodeEnvironment, NodeForkConfig, NodeInfo, + }, BlockId, BlockNumberOrTag, TransactionRequest, }; use alloy_serde::WithOtherFields; use anvil::{eth::api::CLIENT_VERSION, spawn, EthereumHardfork, NodeConfig}; -use anvil_core::eth::EthRequest; +use anvil_core::{ + eth::EthRequest, + types::{ReorgOptions, TransactionData}, +}; use foundry_evm::revm::primitives::SpecId; use std::{ str::FromStr, @@ -658,3 +664,132 @@ async fn can_remove_pool_transactions() { let final_txs = provider.txpool_inspect().await.unwrap(); assert_eq!(final_txs.pending.len(), 0); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_reorg() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.ws_provider(); + + let accounts = handle.dev_wallets().collect::>(); + + // Test calls + // Populate chain + for i in 0..10 { + let tx = TransactionRequest::default() + .to(accounts[0].address()) + .value(U256::from(i)) + .from(accounts[1].address()); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + + let tx = TransactionRequest::default() + .to(accounts[1].address()) + .value(U256::from(i)) + .from(accounts[2].address()); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + } + + // Define transactions + let mut txs = vec![]; + for i in 0..3 { + let from = accounts[i].address(); + let to = accounts[i + 1].address(); + for j in 0..5 { + let tx = TransactionRequest::default().from(from).to(to).value(U256::from(j)); + txs.push((TransactionData::JSON(tx), i as u64)); + } + } + + let prev_height = provider.get_block_number().await.unwrap(); + api.anvil_reorg(ReorgOptions { depth: 7, tx_block_pairs: txs }).await.unwrap(); + + let reorged_height = provider.get_block_number().await.unwrap(); + assert_eq!(reorged_height, prev_height); + + // The first 3 reorged blocks should have 5 transactions each + for num in 14..17 { + let block = provider.get_block_by_number(num.into(), true).await.unwrap(); + let block = block.unwrap(); + assert_eq!(block.transactions.len(), 5); + } + + // Verify that historic blocks are still accessible + for num in (0..14).rev() { + let _ = provider.get_block_by_number(num.into(), true).await.unwrap(); + } + + // Send a few more transaction to verify the chain can still progress + for i in 0..3 { + let tx = TransactionRequest::default() + .to(accounts[0].address()) + .value(U256::from(i)) + .from(accounts[1].address()); + let tx = WithOtherFields::new(tx); + api.send_transaction(tx).await.unwrap(); + } + + // Test reverting code + let greeter = abi::Greeter::deploy(provider.clone(), "Reorg".to_string()).await.unwrap(); + api.anvil_reorg(ReorgOptions { depth: 5, tx_block_pairs: vec![] }).await.unwrap(); + let code = api.get_code(*greeter.address(), Some(BlockId::latest())).await.unwrap(); + assert_eq!(code, Bytes::default()); + + // Test reverting contract storage + let storage = + abi::SimpleStorage::deploy(provider.clone(), "initial value".to_string()).await.unwrap(); + api.evm_mine(Some(MineOptions::Options { timestamp: None, blocks: Some(5) })).await.unwrap(); + let _ = storage + .setValue("ReorgMe".to_string()) + .from(accounts[0].address()) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + api.anvil_reorg(ReorgOptions { depth: 3, tx_block_pairs: vec![] }).await.unwrap(); + let value = storage.getValue().call().await.unwrap()._0; + assert_eq!("initial value".to_string(), value); + + api.mine_one().await; + api.mine_one().await; + + // Test raw transaction data + let mut tx = TxEip1559 { + chain_id: api.chain_id(), + to: TxKind::Call(accounts[1].address()), + value: U256::from(100), + max_priority_fee_per_gas: 1000000000000, + max_fee_per_gas: 10000000000000, + gas_limit: 21000, + ..Default::default() + }; + let signature = accounts[5].sign_transaction_sync(&mut tx).unwrap(); + let tx = tx.into_signed(signature); + let mut encoded = vec![]; + tx.tx().encode_with_signature(tx.signature(), &mut encoded, false); + + let pre_bal = provider.get_balance(accounts[5].address()).await.unwrap(); + api.anvil_reorg(ReorgOptions { + depth: 1, + tx_block_pairs: vec![(TransactionData::Raw(encoded.into()), 0)], + }) + .await + .unwrap(); + let post_bal = provider.get_balance(accounts[5].address()).await.unwrap(); + assert_ne!(pre_bal, post_bal); + + // Test reorg depth exceeding current height + let res = api.anvil_reorg(ReorgOptions { depth: 100, tx_block_pairs: vec![] }).await; + assert!(res.is_err()); + + // Test reorg tx pairs exceeds chain length + let res = api + .anvil_reorg(ReorgOptions { + depth: 1, + tx_block_pairs: vec![(TransactionData::JSON(TransactionRequest::default()), 10)], + }) + .await; + assert!(res.is_err()); +} From de596a4db781933f0c95805bd1c8c05e65f03d4f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 5 Sep 2024 17:00:44 +0200 Subject: [PATCH 1417/1963] fix: ignore nonce in call evm env (#8815) --- crates/anvil/src/eth/backend/mem/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 054aa59256e1c..a9c54ba86e969 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1125,6 +1125,13 @@ impl Backend { }).await? } + /// ## EVM settings + /// + /// This modifies certain EVM settings to mirror geth's `SkipAccountChecks` when transacting requests, see also: : + /// + /// - `disable_eip3607` is set to `true` + /// - `disable_base_fee` is set to `true` + /// - `nonce` is set to `None` fn build_call_env( &self, request: WithOtherFields, @@ -1139,10 +1146,11 @@ impl Backend { gas, value, input, - nonce, access_list, blob_versioned_hashes, authorization_list, + // nonce is always ignored for calls + nonce: _, sidecar: _, chain_id: _, transaction_type: _, @@ -1190,7 +1198,8 @@ impl Backend { value: value.unwrap_or_default(), data: input.into_input().unwrap_or_default(), chain_id: None, - nonce, + // set nonce to None so that the correct nonce is chosen by the EVM + nonce: None, access_list: access_list.unwrap_or_default().into(), blob_hashes: blob_versioned_hashes.unwrap_or_default(), optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, From 4f202da4ea6d94f18cbab8cab43ff4d7e0f6aeb2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 6 Sep 2024 02:53:30 +0200 Subject: [PATCH 1418/1963] chore: ignore RUSTSEC-2024-0370 (#8821) --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index 18fcd55652da0..77cfc79a35f41 100644 --- a/deny.toml +++ b/deny.toml @@ -8,6 +8,8 @@ ignore = [ # https://github.com/watchexec/watchexec/issues/852 "RUSTSEC-2024-0350", "RUSTSEC-2024-0351", + # proc-macro-error is unmaintained + "RUSTSEC-2024-0370", ] # This section is considered when running `cargo deny check bans`. From da28b3125b08044004218cadefd9de450371414c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 6 Sep 2024 02:56:28 +0200 Subject: [PATCH 1419/1963] chore: improve git/project root pathfinding (#8820) * chore: improve git/project root pathfinding * chore: clippy * fix * clean * fix --- crates/cast/bin/cmd/interface.rs | 6 +- crates/cli/src/opts/build/core.rs | 2 +- crates/cli/src/opts/build/paths.rs | 10 ++- crates/cli/src/utils/mod.rs | 6 +- crates/config/src/lib.rs | 27 ++++---- crates/config/src/macros.rs | 7 +- crates/config/src/utils.rs | 103 +++++++++++++++-------------- crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/clone.rs | 2 +- crates/forge/bin/cmd/doc/mod.rs | 7 +- crates/forge/bin/main.rs | 2 +- crates/forge/tests/cli/config.rs | 6 +- 12 files changed, 93 insertions(+), 87 deletions(-) diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index caf9ac5ddfe42..b8de8d84deabc 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -6,7 +6,7 @@ use foundry_block_explorers::Client; use foundry_cli::opts::EtherscanOpts; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{info::ContractInfo, utils::canonicalize}; -use foundry_config::{find_project_root_path, load_config_with_root, Config}; +use foundry_config::{load_config_with_root, try_find_project_root, Config}; use itertools::Itertools; use serde_json::Value; use std::{ @@ -118,8 +118,8 @@ fn load_abi_from_file(path: &str, name: Option) -> Result Result> { - let root = find_project_root_path(None)?; - let config = load_config_with_root(Some(root)); + let root = try_find_project_root(None)?; + let config = load_config_with_root(Some(&root)); let project = config.project()?; let compiler = ProjectCompiler::new().quiet(true); diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index d575f9ae896a5..ebb4da9f1d45e 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -146,7 +146,7 @@ impl CoreBuildArgs { /// Returns the `Project` for the current workspace /// /// This loads the `foundry_config::Config` for the current workspace (see - /// `find_project_root_path` and merges the cli `BuildArgs` into it before returning + /// `find_project_root` and merges the cli `BuildArgs` into it before returning /// [`foundry_config::Config::project()`]). pub fn project(&self) -> Result> { let config = self.try_load_config_emit_warnings()?; diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index 9553eedb0d98e..aa070800a6003 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -8,7 +8,7 @@ use foundry_config::{ value::{Dict, Map, Value}, Metadata, Profile, Provider, }, - find_project_root_path, remappings_from_env_var, Config, + find_project_root, remappings_from_env_var, Config, }; use serde::Serialize; use std::path::PathBuf; @@ -66,15 +66,13 @@ pub struct ProjectPathsArgs { impl ProjectPathsArgs { /// Returns the root directory to use for configuring the project. /// - /// This will be the `--root` argument if provided, otherwise see [find_project_root_path()] + /// This will be the `--root` argument if provided, otherwise see [`find_project_root`]. /// /// # Panics /// - /// If the project root directory cannot be found: [find_project_root_path()] + /// Panics if the project root directory cannot be found. See [`find_project_root`]. pub fn project_root(&self) -> PathBuf { - self.root - .clone() - .unwrap_or_else(|| find_project_root_path(None).expect("Failed to find project root")) + self.root.clone().unwrap_or_else(|| find_project_root(None)) } /// Returns the remappings to add to the config diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 15864b016504d..f5bee0a77d1d1 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -191,9 +191,9 @@ pub fn load_dotenv() { }; // we only want the .env file of the cwd and project root - // `find_project_root_path` calls `current_dir` internally so both paths are either both `Ok` or + // `find_project_root` calls `current_dir` internally so both paths are either both `Ok` or // both `Err` - if let (Ok(cwd), Ok(prj_root)) = (std::env::current_dir(), find_project_root_path(None)) { + if let (Ok(cwd), Ok(prj_root)) = (std::env::current_dir(), try_find_project_root(None)) { load(&prj_root); if cwd != prj_root { // prj root and cwd can be identical @@ -602,7 +602,7 @@ mod tests { assert!(!p.is_sol_test()); } - // loads .env from cwd and project dir, See [`find_project_root_path()`] + // loads .env from cwd and project dir, See [`find_project_root()`] #[test] fn can_load_dotenv() { let temp = tempdir().unwrap(); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 4dd6b8ce4bc1d..34ebe62f59e80 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -522,7 +522,7 @@ impl Config { /// Returns the current `Config` /// - /// See `Config::figment` + /// See [`figment`](Self::figment) for more details. #[track_caller] pub fn load() -> Self { Self::from_provider(Self::figment()) @@ -530,7 +530,7 @@ impl Config { /// Returns the current `Config` with the given `providers` preset /// - /// See `Config::to_figment` + /// See [`figment`](Self::figment) for more details. #[track_caller] pub fn load_with_providers(providers: FigmentProviders) -> Self { Self::default().to_figment(providers).extract().unwrap() @@ -538,10 +538,10 @@ impl Config { /// Returns the current `Config` /// - /// See `Config::figment_with_root` + /// See [`figment_with_root`](Self::figment_with_root) for more details. #[track_caller] - pub fn load_with_root(root: impl Into) -> Self { - Self::from_provider(Self::figment_with_root(root)) + pub fn load_with_root(root: impl AsRef) -> Self { + Self::from_provider(Self::figment_with_root(root.as_ref())) } /// Extract a `Config` from `provider`, panicking if extraction fails. @@ -1407,8 +1407,8 @@ impl Config { /// /// let my_config = Config::figment_with_root(".").extract::(); /// ``` - pub fn figment_with_root(root: impl Into) -> Figment { - Self::with_root(root).into() + pub fn figment_with_root(root: impl AsRef) -> Figment { + Self::with_root(root.as_ref()).into() } /// Creates a new Config that adds additional context extracted from the provided root. @@ -1419,10 +1419,13 @@ impl Config { /// use foundry_config::Config; /// let my_config = Config::with_root("."); /// ``` - pub fn with_root(root: impl Into) -> Self { + pub fn with_root(root: impl AsRef) -> Self { + Self::_with_root(root.as_ref()) + } + + fn _with_root(root: &Path) -> Self { // autodetect paths - let root = root.into(); - let paths = ProjectPathsConfig::builder().build_with_root::<()>(&root); + let paths = ProjectPathsConfig::builder().build_with_root::<()>(root); let artifacts: PathBuf = paths.artifacts.file_name().unwrap().into(); Self { root: paths.root.into(), @@ -1432,7 +1435,7 @@ impl Config { remappings: paths .remappings .into_iter() - .map(|r| RelativeRemapping::new(r, &root)) + .map(|r| RelativeRemapping::new(r, root)) .collect(), fs_permissions: FsPermissions::new([PathPermission::read(artifacts)]), ..Self::default() @@ -1481,7 +1484,7 @@ impl Config { /// /// **Note:** the closure will only be invoked if the `foundry.toml` file exists, See /// [Self::get_config_path()] and if the closure returns `true`. - pub fn update_at(root: impl Into, f: F) -> eyre::Result<()> + pub fn update_at(root: &Path, f: F) -> eyre::Result<()> where F: FnOnce(&Self, &mut toml_edit::DocumentMut) -> bool, { diff --git a/crates/config/src/macros.rs b/crates/config/src/macros.rs index d4f3a59ba1f2c..b9261f03453ac 100644 --- a/crates/config/src/macros.rs +++ b/crates/config/src/macros.rs @@ -61,9 +61,8 @@ macro_rules! impl_figment_convert { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { let root = args.root.clone() - .unwrap_or_else(|| $crate::find_project_root_path(None) - .unwrap_or_else(|e| panic!("could not find project root: {e}"))); - $crate::Config::figment_with_root(root).merge(args) + .unwrap_or_else(|| $crate::find_project_root(None)); + $crate::Config::figment_with_root(&root).merge(args) } } @@ -194,7 +193,7 @@ macro_rules! impl_figment_convert_cast { ($name:ty) => { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { - $crate::Config::with_root($crate::find_project_root_path(None).unwrap()) + $crate::Config::with_root(&$crate::find_project_root(None)) .to_figment($crate::FigmentProviders::Cast) .merge(args) } diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index dff36e4fda40c..b1434bc7a62c5 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -2,7 +2,6 @@ use crate::Config; use alloy_primitives::U256; -use eyre::WrapErr; use figment::value::Value; use foundry_compilers::artifacts::{ remappings::{Remapping, RemappingError}, @@ -11,6 +10,7 @@ use foundry_compilers::artifacts::{ use revm_primitives::SpecId; use serde::{de::Error, Deserialize, Deserializer}; use std::{ + io, path::{Path, PathBuf}, str::FromStr, }; @@ -21,36 +21,31 @@ pub fn load_config() -> Config { load_config_with_root(None) } -/// Loads the config for the current project workspace or the provided root path -pub fn load_config_with_root(root: Option) -> Config { - if let Some(root) = root { - Config::load_with_root(root) - } else { - Config::load_with_root(find_project_root_path(None).unwrap()) - } - .sanitized() +/// Loads the config for the current project workspace or the provided root path. +/// +/// # Panics +/// +/// Panics if the project root cannot be found. See [`find_project_root`]. +#[track_caller] +pub fn load_config_with_root(root: Option<&Path>) -> Config { + let root = match root { + Some(root) => root, + None => &find_project_root(None), + }; + Config::load_with_root(root).sanitized() } -/// Returns the path of the top-level directory of the working git tree. If there is no working -/// tree, an error is returned. -pub fn find_git_root_path(relative_to: impl AsRef) -> eyre::Result { - let path = relative_to.as_ref(); - let path = std::process::Command::new("git") - .args(["rev-parse", "--show-toplevel"]) - .current_dir(path) - .output() - .wrap_err_with(|| { - format!("Failed detect git root path in current dir: {}", path.display()) - })? - .stdout; - let path = std::str::from_utf8(&path)?.trim_end_matches('\n'); - Ok(PathBuf::from(path)) +/// Returns the path of the top-level directory of the working git tree. +pub fn find_git_root(relative_to: &Path) -> io::Result> { + let root = + if relative_to.is_absolute() { relative_to } else { &dunce::canonicalize(relative_to)? }; + Ok(root.ancestors().find(|p| p.join(".git").is_dir()).map(Path::to_path_buf)) } -/// Returns the root path to set for the project root +/// Returns the root path to set for the project root. /// -/// traverse the dir tree up and look for a `foundry.toml` file starting at the given path or cwd, -/// but only until the root dir of the current repo so that +/// Traverse the dir tree up and look for a `foundry.toml` file starting at the given path or cwd, +/// but only until the root dir of the current repo so that: /// /// ```text /// -- foundry.toml @@ -60,29 +55,37 @@ pub fn find_git_root_path(relative_to: impl AsRef) -> eyre::Result) -> std::io::Result { - let cwd = &std::env::current_dir()?; - let cwd = path.unwrap_or(cwd); - let boundary = find_git_root_path(cwd) - .ok() - .filter(|p| !p.as_os_str().is_empty()) - .unwrap_or_else(|| cwd.clone()); - let mut cwd = cwd.as_path(); - // traverse as long as we're in the current git repo cwd - while cwd.starts_with(&boundary) { - let file_path = cwd.join(Config::FILE_NAME); - if file_path.is_file() { - return Ok(cwd.to_path_buf()) - } - if let Some(parent) = cwd.parent() { - cwd = parent; - } else { - break - } - } - // no foundry.toml found - Ok(boundary) +/// +/// will still detect `repo` as root. +/// +/// Returns `repo` or `cwd` if no `foundry.toml` is found in the tree. +/// +/// # Panics +/// +/// Panics if: +/// - `cwd` is `Some` and is not a valid directory; +/// - `cwd` is `None` and the [`std::env::current_dir`] call fails. +#[track_caller] +pub fn find_project_root(cwd: Option<&Path>) -> PathBuf { + try_find_project_root(cwd).expect("Could not find project root") +} + +/// Returns the root path to set for the project root. +/// +/// Same as [`find_project_root`], but returns an error instead of panicking. +pub fn try_find_project_root(cwd: Option<&Path>) -> io::Result { + let cwd = match cwd { + Some(path) => path, + None => &std::env::current_dir()?, + }; + let boundary = find_git_root(cwd)?; + let found = cwd + .ancestors() + // Don't look outside of the git repo if it exists. + .take_while(|p| if let Some(boundary) = &boundary { p.starts_with(boundary) } else { true }) + .find(|p| p.join(Config::FILE_NAME).is_file()) + .map(Path::to_path_buf); + Ok(found.or(boundary).unwrap_or_else(|| cwd.to_path_buf())) } /// Returns all [`Remapping`]s contained in the `remappings` str separated by newlines @@ -160,7 +163,7 @@ pub fn foundry_toml_dirs(root: impl AsRef) -> Vec { .into_iter() .filter_map(Result::ok) .filter(|e| e.file_type().is_dir()) - .filter_map(|e| foundry_compilers::utils::canonicalize(e.path()).ok()) + .filter_map(|e| dunce::canonicalize(e.path()).ok()) .filter(|p| p.join(Config::FILE_NAME).exists()) .collect() } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index f242d3d191d65..53bc5bc2001b9 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -117,7 +117,7 @@ impl BuildArgs { /// Returns the `Project` for the current workspace /// /// This loads the `foundry_config::Config` for the current workspace (see - /// [`utils::find_project_root_path`] and merges the cli `BuildArgs` into it before returning + /// [`utils::find_project_root`] and merges the cli `BuildArgs` into it before returning /// [`foundry_config::Config::project()`] pub fn project(&self) -> Result { self.args.project() diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 65b3cf01d6d04..4af5869646538 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -546,7 +546,7 @@ fn dump_sources(meta: &Metadata, root: &PathBuf, no_reorg: bool) -> Result Result { +pub fn compile_project(root: &Path, quiet: bool) -> Result { let mut config = Config::load_with_root(root).sanitized(); config.extra_output.push(ContractOutputSelection::StorageLayout); let project = config.project()?; diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index ad4375bfb7509..ad61facf5c950 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -6,7 +6,7 @@ use forge_doc::{ }; use foundry_cli::opts::GH_REPO_PREFIX_REGEX; use foundry_common::compile::ProjectCompiler; -use foundry_config::{find_project_root_path, load_config_with_root, Config}; +use foundry_config::{find_project_root, load_config_with_root, Config}; use std::{path::PathBuf, process::Command}; mod server; @@ -139,7 +139,10 @@ impl DocArgs { } pub fn config(&self) -> Result { - let root = self.root.clone().unwrap_or(find_project_root_path(None)?); + let root = match &self.root { + Some(root) => root, + None => &find_project_root(None), + }; Ok(load_config_with_root(Some(root))) } } diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 81ee0b86775c6..f92d3db8085b7 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -81,7 +81,7 @@ fn main() -> Result<()> { Ok(()) } ForgeSubcommand::Clean { root } => { - let config = utils::load_config_with_root(root); + let config = utils::load_config_with_root(root.as_deref()); let project = config.project()?; config.cleanup(&project)?; Ok(()) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 2cb11e72f1861..b597ce439c44b 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -195,7 +195,7 @@ forgetest_init!(can_override_config, |prj, cmd| { // remappings work let remappings_txt = prj.create_file("remappings.txt", "ds-test/=lib/forge-std/lib/ds-test/from-file/"); - let config = forge_utils::load_config_with_root(Some(prj.root().into())); + let config = forge_utils::load_config_with_root(Some(prj.root())); assert_eq!( format!( "ds-test/={}/", @@ -206,7 +206,7 @@ forgetest_init!(can_override_config, |prj, cmd| { // env vars work std::env::set_var("DAPP_REMAPPINGS", "ds-test/=lib/forge-std/lib/ds-test/from-env/"); - let config = forge_utils::load_config_with_root(Some(prj.root().into())); + let config = forge_utils::load_config_with_root(Some(prj.root())); assert_eq!( format!( "ds-test/={}/", @@ -283,7 +283,7 @@ Installing solmate in [..] (url: Some("https://github.com/transmissions11/solmat "remappings.txt", "solmate/=lib/solmate/src/\nsolmate-contracts/=lib/solmate/src/", ); - let config = forge_utils::load_config_with_root(Some(prj.root().into())); + let config = forge_utils::load_config_with_root(Some(prj.root())); // trailing slashes are removed on windows `to_slash_lossy` let path = prj.root().join("lib/solmate/src/").to_slash_lossy().into_owned(); #[cfg(windows)] From 3998de0bdda218b8ecd3f871ac0d67c7a46e3528 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 6 Sep 2024 02:57:27 +0200 Subject: [PATCH 1420/1963] chore: delay spawning tokio runtime until needed (#8819) --- Cargo.lock | 122 +++++++++++++-------------- crates/anvil/src/anvil.rs | 13 ++- crates/cast/Cargo.toml | 5 +- crates/cast/bin/{opts.rs => args.rs} | 0 crates/cast/bin/cmd/storage.rs | 2 +- crates/cast/bin/main.rs | 19 +++-- crates/chisel/bin/main.rs | 9 +- 7 files changed, 87 insertions(+), 83 deletions(-) rename crates/cast/bin/{opts.rs => args.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index 846989c41aa05..7130c61390c3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1855,65 +1855,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" -[[package]] -name = "cast" -version = "0.2.0" -dependencies = [ - "alloy-chains", - "alloy-consensus", - "alloy-contract", - "alloy-dyn-abi", - "alloy-json-abi", - "alloy-json-rpc", - "alloy-network", - "alloy-primitives", - "alloy-provider", - "alloy-rlp", - "alloy-rpc-types", - "alloy-serde", - "alloy-signer", - "alloy-signer-local", - "alloy-sol-types", - "alloy-transport", - "anvil", - "async-trait", - "aws-sdk-kms", - "chrono", - "clap", - "clap_complete", - "clap_complete_fig", - "comfy-table", - "criterion", - "dunce", - "evm-disassembler", - "evmole", - "eyre", - "foundry-block-explorers", - "foundry-cli", - "foundry-common", - "foundry-compilers", - "foundry-config", - "foundry-evm", - "foundry-test-utils", - "foundry-wallets", - "futures", - "indicatif", - "itertools 0.13.0", - "rand", - "rayon", - "regex", - "rpassword", - "semver 1.0.23", - "serde", - "serde_json", - "tempfile", - "tikv-jemallocator", - "tokio", - "tracing", - "vergen", - "yansi", -] - [[package]] name = "cast" version = "0.3.0" @@ -2368,7 +2309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ "anes", - "cast 0.3.0", + "cast", "ciborium", "clap", "criterion-plot", @@ -2395,7 +2336,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ - "cast 0.3.0", + "cast", "itertools 0.10.5", ] @@ -3527,6 +3468,65 @@ dependencies = [ "tracing", ] +[[package]] +name = "foundry-cast" +version = "0.2.0" +dependencies = [ + "alloy-chains", + "alloy-consensus", + "alloy-contract", + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-json-rpc", + "alloy-network", + "alloy-primitives", + "alloy-provider", + "alloy-rlp", + "alloy-rpc-types", + "alloy-serde", + "alloy-signer", + "alloy-signer-local", + "alloy-sol-types", + "alloy-transport", + "anvil", + "async-trait", + "aws-sdk-kms", + "chrono", + "clap", + "clap_complete", + "clap_complete_fig", + "comfy-table", + "criterion", + "dunce", + "evm-disassembler", + "evmole", + "eyre", + "foundry-block-explorers", + "foundry-cli", + "foundry-common", + "foundry-compilers", + "foundry-config", + "foundry-evm", + "foundry-test-utils", + "foundry-wallets", + "futures", + "indicatif", + "itertools 0.13.0", + "rand", + "rayon", + "regex", + "rpassword", + "semver 1.0.23", + "serde", + "serde_json", + "tempfile", + "tikv-jemallocator", + "tokio", + "tracing", + "vergen", + "yansi", +] + [[package]] name = "foundry-cheatcodes" version = "0.2.0" diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 1aa204587b200..38bbbbbd62e3a 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -33,14 +33,13 @@ pub enum AnvilSubcommand { GenerateFigSpec, } -#[tokio::main] -async fn main() -> eyre::Result<()> { +fn main() -> eyre::Result<()> { utils::load_dotenv(); - let mut app = Anvil::parse(); - app.node.evm_opts.resolve_rpc_alias(); + let mut args = Anvil::parse(); + args.node.evm_opts.resolve_rpc_alias(); - if let Some(ref cmd) = app.cmd { + if let Some(cmd) = &args.cmd { match cmd { AnvilSubcommand::Completions { shell } => { clap_complete::generate( @@ -61,9 +60,7 @@ async fn main() -> eyre::Result<()> { } let _ = fdlimit::raise_fd_limit(); - app.node.run().await?; - - Ok(()) + tokio::runtime::Builder::new_multi_thread().enable_all().build()?.block_on(args.node.run()) } #[cfg(test)] diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 386c523b467f5..2b2a0db9097b5 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cast" +name = "foundry-cast" description = "Command-line tool for performing Ethereum RPC calls" version.workspace = true @@ -13,6 +13,9 @@ repository.workspace = true [lints] workspace = true +[lib] +name = "cast" + [[bin]] name = "cast" path = "bin/main.rs" diff --git a/crates/cast/bin/opts.rs b/crates/cast/bin/args.rs similarity index 100% rename from crates/cast/bin/opts.rs rename to crates/cast/bin/args.rs diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 117130943dc52..a8ced363912a1 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -1,4 +1,4 @@ -use crate::opts::parse_slot; +use crate::args::parse_slot; use alloy_network::AnyNetwork; use alloy_primitives::{Address, B256, U256}; use alloy_provider::Provider; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 8eaa201d6f5b2..b0f29af438f2d 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -23,25 +23,28 @@ use foundry_common::{ use foundry_config::Config; use std::time::Instant; +pub mod args; pub mod cmd; -pub mod opts; pub mod tx; -use opts::{Cast as Opts, CastSubcommand, ToBaseArgs}; +use args::{Cast as CastArgs, CastSubcommand, ToBaseArgs}; #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; -#[tokio::main] -async fn main() -> Result<()> { +fn main() -> Result<()> { handler::install(); utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); + let args = CastArgs::parse(); + main_args(args) +} - let opts = Opts::parse(); - match opts.cmd { +#[tokio::main] +async fn main_args(args: CastArgs) -> Result<()> { + match args.cmd { // Constants CastSubcommand::MaxInt { r#type } => { println!("{}", SimpleCast::max_int(&r#type)?); @@ -555,11 +558,11 @@ async fn main() -> Result<()> { } CastSubcommand::Wallet { command } => command.run().await?, CastSubcommand::Completions { shell } => { - generate(shell, &mut Opts::command(), "cast", &mut std::io::stdout()) + generate(shell, &mut CastArgs::command(), "cast", &mut std::io::stdout()) } CastSubcommand::GenerateFigSpec => clap_complete::generate( clap_complete_fig::Fig, - &mut Opts::command(), + &mut CastArgs::command(), "cast", &mut std::io::stdout(), ), diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index d2b3a726f48e8..7a0703e85c2ee 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -94,15 +94,16 @@ pub enum ChiselSubcommand { ClearCache, } -#[tokio::main] -async fn main() -> eyre::Result<()> { +fn main() -> eyre::Result<()> { handler::install(); utils::subscriber(); utils::load_dotenv(); - - // Parse command args let args = Chisel::parse(); + main_args(args) +} +#[tokio::main] +async fn main_args(args: Chisel) -> eyre::Result<()> { // Keeps track of whether or not an interrupt was the last input let mut interrupt = false; From e53255b904a8533e65541b3b8d9d584a540ff4e3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 6 Sep 2024 16:46:52 +0200 Subject: [PATCH 1421/1963] feat: solc 0.8.27 support (#8825) --- Cargo.lock | 4 ++-- crates/forge/tests/cli/svm.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7130c61390c3b..aced1eab739e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8135,9 +8135,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d3230221bec82c4a79cd7af637ac29f04f369e95e476bc492f22882bb83c91" +checksum = "4aebac1b1ef2b46e2e2bdf3c09db304800f2a77c1fa902bd5231490203042be8" dependencies = [ "const-hex", "dirs 5.0.1", diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index ab8db41f8a8b0..e0c10a052e936 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -11,7 +11,7 @@ use svm::Platform; /// 3. svm bumped in foundry-compilers /// 4. foundry-compilers update with any breaking changes /// 5. upgrade the `LATEST_SOLC` -const LATEST_SOLC: Version = Version::new(0, 8, 26); +const LATEST_SOLC: Version = Version::new(0, 8, 27); macro_rules! ensure_svm_releases { ($($test:ident => $platform:ident),* $(,)?) => {$( From d8f6631f008c90cf880c9bf25cb8c31078f403f4 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 6 Sep 2024 20:29:13 +0530 Subject: [PATCH 1422/1963] chore(deps): bump alloy (#8771) * chore(deps): bump alloy * bump foundry-fork-db * bump foundry-compilers + revm * fix(fmt): rm other from `UIfmt` of `Transaction` * use patch foundry-compilers and alloy * make utils::apply_chain_and_block_specific_env_changes generic over Network * make EvmOpts generic over network * bump block explorers * use patched core version * nit * nit * squash * repatch * anvil: use WithOtherFields> * fix(anvil): otterscan * fix(anvil): TaskManager * breaking(anvil): change anvil-api Block return types to WithOtherFields> * impl UIfmt for WithOtherFields * fix cast * fix anvil tests * nit * nits * fix: UIfmt for WithOtherFields * fix(casttest): interface_no_constructor * fix UIfmt for WithOtherFields * nits + allow - evmole in deny * bump evmole * use AnyNetworkBlock * use WithOtherFields in otterscan return types * bump core to 0.8.1 * Update crates/anvil/src/eth/api.rs --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 541 +++++++++--------- Cargo.toml | 125 ++-- crates/anvil/Cargo.toml | 1 + crates/anvil/core/src/eth/transaction/mod.rs | 5 - .../core/src/eth/transaction/optimism.rs | 38 ++ crates/anvil/src/config.rs | 23 +- crates/anvil/src/eth/api.rs | 44 +- crates/anvil/src/eth/backend/fork.rs | 67 ++- crates/anvil/src/eth/backend/info.rs | 8 +- crates/anvil/src/eth/backend/mem/mod.rs | 63 +- crates/anvil/src/eth/error.rs | 2 +- crates/anvil/src/eth/otterscan/api.rs | 46 +- crates/anvil/src/tasks/mod.rs | 8 +- crates/anvil/tests/it/abi.rs | 2 +- crates/anvil/tests/it/anvil_api.rs | 24 +- crates/anvil/tests/it/api.rs | 86 ++- crates/anvil/tests/it/fork.rs | 21 +- crates/anvil/tests/it/ipc.rs | 2 +- crates/anvil/tests/it/logs.rs | 6 +- crates/anvil/tests/it/optimism.rs | 6 +- crates/anvil/tests/it/otterscan.rs | 26 +- crates/anvil/tests/it/pubsub.rs | 8 +- crates/anvil/tests/it/traces.rs | 6 +- crates/anvil/tests/it/transaction.rs | 11 +- crates/cast/Cargo.toml | 2 +- crates/cast/bin/cmd/run.rs | 8 +- crates/cast/bin/main.rs | 15 +- crates/cast/src/lib.rs | 6 +- crates/cast/tests/cli/main.rs | 27 +- crates/common/fmt/src/ui.rs | 47 +- crates/evm/core/src/backend/mod.rs | 73 ++- crates/evm/core/src/fork/init.rs | 27 +- crates/evm/core/src/fork/multi.rs | 3 +- crates/evm/core/src/opts.rs | 4 +- crates/evm/core/src/utils.rs | 27 +- crates/forge/bin/cmd/clone.rs | 4 +- crates/forge/tests/cli/cmd.rs | 10 +- crates/forge/tests/cli/verify_bytecode.rs | 6 +- crates/test-utils/Cargo.toml | 4 + crates/test-utils/src/rpc.rs | 68 ++- crates/verify/src/bytecode.rs | 2 +- crates/verify/src/utils.rs | 4 +- 42 files changed, 822 insertions(+), 684 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aced1eab739e1..6793346b546e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,8 +85,8 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-eips", "alloy-primitives", @@ -98,8 +98,8 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413902aa18a97569e60f679c23f46a18db1656d87ab4d4e49d0e1e52042f66df" +checksum = "6d1c7d5315d44b5e00ce9c6b72dc88aa8f3e49d82a742be85d6a755ef0aa28c5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -129,7 +129,7 @@ dependencies = [ "arbitrary", "const-hex", "derive_arbitrary", - "derive_more 0.99.18", + "derive_more 1.0.0", "itoa", "proptest", "serde", @@ -137,28 +137,55 @@ dependencies = [ "winnow", ] +[[package]] +name = "alloy-eip2930" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "arbitrary", + "rand", + "serde", +] + +[[package]] +name = "alloy-eip7702" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d319bb544ca6caeab58c39cea8921c55d924d4f68f2c60f24f914673f9a74a" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "arbitrary", + "k256", + "rand", + "serde", +] + [[package]] name = "alloy-eips" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ + "alloy-eip2930", + "alloy-eip7702", "alloy-primitives", "alloy-rlp", "alloy-serde", "arbitrary", "c-kzg", "derive_more 1.0.0", - "k256", "once_cell", - "rand", "serde", "sha2", ] [[package]] name = "alloy-genesis" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-primitives", "alloy-serde", @@ -167,9 +194,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc05b04ac331a9f07e3a4036ef7926e49a8bf84a99a1ccfc7e2ab55a5fcbb372" +checksum = "8129590e6f5aa3aeb33138f0faaa4cb763e4f1ca072ab98ce880a1998dca84d3" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -179,8 +206,8 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -192,8 +219,8 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-eips", @@ -212,8 +239,8 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-primitives", "alloy-serde", @@ -222,9 +249,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" +checksum = "19d1d1bdfba287209ee749a985230685c2ff8bdabe5fed6f699f72f22bb72c95" dependencies = [ "alloy-rlp", "arbitrary", @@ -232,8 +259,7 @@ dependencies = [ "cfg-if", "const-hex", "derive_arbitrary", - "derive_more 0.99.18", - "ethereum_ssz", + "derive_more 1.0.0", "getrandom", "hex-literal", "itoa", @@ -249,8 +275,8 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-chains", "alloy-consensus", @@ -287,8 +313,8 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -299,7 +325,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "tracing", ] @@ -327,8 +353,8 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -344,15 +370,15 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "tracing", "url", ] [[package]] name = "alloy-rpc-types" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -365,8 +391,8 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-primitives", "alloy-serde", @@ -375,8 +401,8 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-eips", @@ -392,8 +418,8 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-eips", @@ -410,8 +436,8 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -423,8 +449,8 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -434,8 +460,8 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-primitives", "arbitrary", @@ -445,8 +471,8 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -460,8 +486,8 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-network", @@ -477,8 +503,8 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-network", @@ -494,8 +520,8 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -513,8 +539,8 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-network", @@ -532,8 +558,8 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-consensus", "alloy-network", @@ -548,13 +574,13 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b40397ddcdcc266f59f959770f601ce1280e699a91fc1862f29cef91707cd09" +checksum = "03f6a68cb762b6feb50cff1a4f81831b8725aa10f5a1afc26c209b7df442fffe" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", "syn 2.0.77", @@ -562,16 +588,16 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" +checksum = "1e3d38952d1f54a541c00b1b28582cd112ac02e6302437bd3dead32367a87393" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", "const-hex", "heck", "indexmap 2.5.0", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", "syn 2.0.77", @@ -581,9 +607,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" +checksum = "2821c0ce9b217b17c9a52c8dc0dddadb391d0eb7593707da9f12df786510594b" dependencies = [ "alloy-json-abi", "const-hex", @@ -598,9 +624,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" +checksum = "f040419382164c509aa60f281e45c6fa295cf88ccffe686bd71d65780bc8d053" dependencies = [ "serde", "winnow", @@ -608,9 +634,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" +checksum = "53be2dde91d22bc1e398e26bd42bdac441705f205a4cbaf4f3abb9273867ed39" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -621,8 +647,8 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -632,29 +658,29 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower", + "tower 0.4.13", "tracing", "url", ] [[package]] name = "alloy-transport-http" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-json-rpc", "alloy-transport", "reqwest", "serde_json", - "tower", + "tower 0.4.13", "tracing", "url", ] [[package]] name = "alloy-transport-ipc" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -673,8 +699,8 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.2.1" -source = "git+https://github.com/alloy-rs/alloy?rev=511ae98#511ae9820210798d4a35f1e28a7993bb5d445cd4" +version = "0.3.1" +source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -690,13 +716,13 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03704f265cbbb943b117ecb5055fd46e8f41e7dc8a58b1aed20bcd40ace38c15" +checksum = "398a977d774db13446b8cead8cfa9517aebf9e03fc8a1512892dc1e03e70bb04" dependencies = [ "alloy-primitives", "alloy-rlp", - "derive_more 0.99.18", + "derive_more 1.0.0", "hashbrown 0.14.5", "nybbles", "serde", @@ -838,6 +864,7 @@ dependencies = [ "hyper 1.4.1", "itertools 0.13.0", "k256", + "op-alloy-rpc-types", "parking_lot", "rand", "revm", @@ -849,7 +876,7 @@ dependencies = [ "thiserror", "tikv-jemallocator", "tokio", - "tower", + "tower 0.4.13", "tracing", "tracing-subscriber", "vergen", @@ -1264,9 +1291,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.41.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "178910fefe72743b62b9c4670c14a038ebfdb265ff7feccf43827af6a8899e14" +checksum = "704ab31904cf70104a3bb023079e201b1353cf132ca674b26ba6f23acbbb53c9" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1286,9 +1313,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5879bec6e74b648ce12f6085e7245417bc5f6d672781028384d2e494be3eb6d" +checksum = "af0a3f676cba2c079c9563acc9233998c8951cdbe38629a0bef3c8c1b02f3658" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1308,9 +1335,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.41.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef4cd9362f638c22a3b959fd8df292e7e47fdf170270f86246b97109b5f2f7d" +checksum = "c91b6a04495547162cf52b075e3c15a17ab6608bf9c5785d3e5a5509b3f09f5c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1330,9 +1357,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1e2735d2ab28b35ecbb5496c9d41857f52a0d6a0075bbf6a8af306045ea6f6" +checksum = "99c56bcd6a56cab7933980a54148b476a5a69a7694e3874d9aa2a566f150447d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1545,7 +1572,7 @@ dependencies = [ "sync_wrapper 1.0.1", "tokio", "tokio-tungstenite 0.21.0", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -1686,19 +1713,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bls12_381" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" -dependencies = [ - "ff", - "group", - "pairing", - "rand_core", - "subtle", -] - [[package]] name = "blst" version = "0.3.13" @@ -1752,9 +1766,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -1872,9 +1886,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.15" +version = "1.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" dependencies = [ "shlex", ] @@ -1987,9 +2001,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -1997,9 +2011,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -2012,9 +2026,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.24" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7db6eca8c205649e8d3ccd05aa5042b1800a784e56bc7c43524fde8abbfa9b" +checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" dependencies = [ "clap", ] @@ -2253,12 +2267,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "convert_case" version = "0.6.0" @@ -2496,9 +2504,9 @@ dependencies = [ [[package]] name = "dashmap" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", "crossbeam-utils", @@ -2604,10 +2612,8 @@ version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ - "convert_case 0.4.0", "proc-macro2", "quote", - "rustc_version 0.4.1", "syn 2.0.77", ] @@ -2626,7 +2632,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ - "convert_case 0.6.0", + "convert_case", "proc-macro2", "quote", "syn 2.0.77", @@ -2982,17 +2988,6 @@ dependencies = [ "uint", ] -[[package]] -name = "ethereum_ssz" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3627f83d8b87b432a5fad9934b4565260722a141a2c40f371f8080adec9425" -dependencies = [ - "ethereum-types", - "itertools 0.10.5", - "smallvec", -] - [[package]] name = "ethers-contract-abigen" version = "2.0.14" @@ -3068,12 +3063,12 @@ dependencies = [ [[package]] name = "evmole" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d55794094e85dd9d2a4a44de6554015c7d0d7193a28756f2ee3432bb763003a7" +checksum = "2dc8472e812ff8f53a76946fa70b1cc4bf75c78755beb09df4d1376764769c7d" dependencies = [ "alloy-dyn-abi", - "ruint", + "alloy-primitives", ] [[package]] @@ -3136,7 +3131,6 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "bitvec", "rand_core", "subtle", ] @@ -3175,7 +3169,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ - "arbitrary", "byteorder", "rand", "rustc-hex", @@ -3452,9 +3445,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.5.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1580bdb99a6a531b44ac5cda229069cacc11ae7d54faa45676e1bee9ee7da1c" +checksum = "461772f04e5457d6b6501f6aff3a615a032d01368c1cc91c13a06eff172962b6" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3658,7 +3651,7 @@ dependencies = [ "similar-asserts", "thiserror", "tokio", - "tower", + "tower 0.4.13", "tracing", "url", "walkdir", @@ -3686,9 +3679,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.10.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eaa24a47bb84e1db38c84f03e8c90ca81050bd20beac8bdc99aae8afd0b8784" +checksum = "3372aaa89b1653b61fb297dbc24e74ad727ff76cc4415f1a0ec5f802d24e0797" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3724,9 +3717,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.10.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3588ee6a986f89040d1158fb90459731580b404fb72b8c6c832c0ddbc95fed58" +checksum = "76c4f9ac0ed5e695bbeb48ff0758ba31ce3d0d52b752aaa466f311f48ed772c0" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3734,9 +3727,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.10.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a149c5e8c326c7bae8f73cacb28c637f4bc2e535f950eec10348494990e9636f" +checksum = "5ad6beeb057a8a58993d13841cffcb99e8aefdeb52ed9b368c85518747b467f9" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3758,9 +3751,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.10.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8645c9e7c070c81bf8c90f456416953234334f097b67445c773af98df74e27b0" +checksum = "442e5eb231aad523f0f3e26f9475ad9eab1aa2173a5991df1b7fa51f589f309f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3773,9 +3766,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.10.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66492aeb708f3d142c078457dba5f52b04ca5031012d48903a0bcb37d205d595" +checksum = "92049644ce2745c36be16f6406592155d4be2314306af2543c7d30a32b00d6ed" dependencies = [ "alloy-primitives", "cfg-if", @@ -3993,9 +3986,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e1217b5063138a87feb51bd9ac71857d370f06f1aa3d8c22b73aae0e49f4c3" +checksum = "c88cb03fc4bd87856fc4d0ad38fd067f85c7c6306bf794202fc50a897449837b" dependencies = [ "alloy-primitives", "alloy-provider", @@ -4043,6 +4036,7 @@ dependencies = [ "alloy-provider", "eyre", "fd-lock", + "foundry-block-explorers", "foundry-common", "foundry-compilers", "foundry-config", @@ -4051,6 +4045,7 @@ dependencies = [ "regex", "serde_json", "snapbox", + "tokio", "tracing", "tracing-subscriber", ] @@ -4230,9 +4225,9 @@ checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" [[package]] name = "gcloud-sdk" -version = "0.25.5" +version = "0.25.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77045256cd0d2075e09d62c4c9f27c2b664e2cc806d7ddf3a4293bb0c20b4728" +checksum = "6d92f38cbe5b8796d2ab3f3c5f3bc286aa778015d5c5f67e2d0cbbe5d348473f" dependencies = [ "async-trait", "bytes", @@ -4249,7 +4244,7 @@ dependencies = [ "serde_json", "tokio", "tonic", - "tower", + "tower 0.5.0", "tower-layer", "tower-util", "tracing", @@ -4258,9 +4253,9 @@ dependencies = [ [[package]] name = "generator" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "979f00864edc7516466d6b3157706e06c032f22715700ddd878228a91d02bc56" +checksum = "dbb949699c3e4df3a183b1d2142cb24277057055ed23c68ed58894f76c517223" dependencies = [ "cfg-if", "libc", @@ -4438,9 +4433,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.10" +version = "0.10.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d5b8722112fa2fa87135298780bc833b0e9f6c56cc82795d209804b3a03484" +checksum = "ebfc4febd088abdcbc9f1246896e57e37b7a34f6909840045a1767c6dafac7af" dependencies = [ "bstr", "gix-trace", @@ -4498,9 +4493,9 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e" +checksum = "6cae0e8661c3ff92688ce1c8b8058b3efb312aba9492bbe93661a21705ab431b" [[package]] name = "gix-utils" @@ -4861,16 +4856,16 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", "hyper 1.4.1", "hyper-util", "rustls 0.23.12", - "rustls-native-certs 0.7.3", + "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -4922,7 +4917,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", + "tower 0.4.13", "tower-service", "tracing", ] @@ -5291,21 +5286,6 @@ dependencies = [ "libc", ] -[[package]] -name = "kzg-rs" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9920cd4460ce3cbca19c62f3bb9a9611562478a4dc9d2c556f4a7d049c5b6b" -dependencies = [ - "bls12_381", - "glob", - "hex", - "once_cell", - "serde", - "serde_derive", - "serde_yaml", -] - [[package]] name = "lalrpop" version = "0.20.2" @@ -5967,6 +5947,37 @@ version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" +[[package]] +name = "op-alloy-consensus" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b7fbb0f5c3754c22c6ea30e100dca6aea73b747e693e27763e23ca92fb02f2f" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "derive_more 1.0.0", + "serde", + "spin", +] + +[[package]] +name = "op-alloy-rpc-types" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1fbb93dcb71aba9cd555784375011efce1fdaaea67e01972a0a9bc9eb90c626" +dependencies = [ + "alloy-network", + "alloy-primitives", + "alloy-rpc-types-eth", + "alloy-serde", + "op-alloy-consensus", + "serde", + "serde_json", +] + [[package]] name = "open-fastrlp" version = "0.1.4" @@ -6084,15 +6095,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "pairing" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" -dependencies = [ - "group", -] - [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -6578,6 +6580,28 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74cdd32837fa2e86ec09c8266e5aad92400ac934c6dbca83d54673b298db3e45" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -6653,13 +6677,13 @@ dependencies = [ [[package]] name = "proptest-derive" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf16337405ca084e9c78985114633b6827711d22b9e6ef6c6c0d665eb3f0b6e" +checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.77", ] [[package]] @@ -6749,9 +6773,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "pin-project-lite", @@ -6767,9 +6791,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.6" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand", @@ -6784,15 +6808,15 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -6992,7 +7016,7 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "hyper 1.4.1", - "hyper-rustls 0.27.2", + "hyper-rustls 0.27.3", "hyper-tls", "hyper-util", "ipnet", @@ -7030,8 +7054,9 @@ dependencies = [ [[package]] name = "revm" -version = "13.0.0" -source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" +version = "14.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f719e28cc6fdd086f8bc481429e587740d20ad89729cec3f5f5dd7b655474df" dependencies = [ "auto_impl", "cfg-if", @@ -7044,9 +7069,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.5.7" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec16f9b9d3cdaaf2f4b7ceaf004eb2c89df04e7ea29622584c0a6ec676bd0a83" +checksum = "48184032103bb23788e42e42c7c85207f5b0b8a248b09ea8f5233077f35ab56e" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -7061,8 +7086,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "9.0.0" -source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "959ecbc36802de6126852479844737f20194cf8e6718e0c30697d306a2cca916" dependencies = [ "revm-primitives", "serde", @@ -7070,8 +7096,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "10.0.0" -source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" +version = "11.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e25f604cb9db593ca3013be8c00f310d6790ccb1b7d8fbbdd4660ec8888043a" dependencies = [ "aurora-engine-modexp", "blst", @@ -7089,8 +7116,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "8.0.0" -source = "git+https://github.com/bluealloy/revm?rev=caadc71#caadc71fd28929cd751cc997b4b454d8813c434b" +version = "9.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ccb981ede47ccf87c68cebf1ba30cdbb7ec935233ea305f3dfff4c1e10ae541" dependencies = [ "alloy-eips", "alloy-primitives", @@ -7099,13 +7127,10 @@ dependencies = [ "bitvec", "c-kzg", "cfg-if", - "derive_more 0.99.18", "dyn-clone", "enumn", "hashbrown 0.14.5", "hex", - "kzg-rs", - "once_cell", "serde", ] @@ -7265,9 +7290,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" dependencies = [ "bitflags 2.6.0", "errno", @@ -7328,6 +7353,19 @@ dependencies = [ "security-framework", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.3", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -7689,9 +7727,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "indexmap 2.5.0", "itoa", @@ -7752,19 +7790,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_yaml" -version = "0.9.34+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" -dependencies = [ - "indexmap 2.5.0", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - [[package]] name = "serial_test" version = "3.1.1" @@ -7917,9 +7942,9 @@ dependencies = [ [[package]] name = "similar-asserts" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" +checksum = "cfe85670573cd6f0fa97940f26e7e6601213c3b0555246c24234131f88c5709e" dependencies = [ "console", "similar", @@ -8043,6 +8068,9 @@ name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] [[package]] name = "spki" @@ -8155,9 +8183,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fe4ebbe1038a5a517a07948c2487b3ccf79a4908953cc8f0047cf652233546" +checksum = "f2fa0f145894cb4d1c14446f08098ee5f21fc37ccbd1a7dd9dd355bbc806de3b" dependencies = [ "build_const", "const-hex", @@ -8190,9 +8218,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c837dc8852cb7074e46b444afb81783140dab12c58867b49fb3898fbafedf7ea" +checksum = "03133179a4b51eabc6f1aea6951626a766b8aa3af68b12d150f88095914cb447" dependencies = [ "paste", "proc-macro2", @@ -8485,9 +8513,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -8525,9 +8553,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -8607,7 +8635,7 @@ dependencies = [ "tokio", "tokio-rustls 0.26.0", "tokio-stream", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -8639,6 +8667,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36b837f86b25d7c0d7988f00a54e74739be6477f2aac6201b8f429a7569991b7" +dependencies = [ + "tower-layer", + "tower-service", +] + [[package]] name = "tower-http" version = "0.5.2" @@ -8868,7 +8906,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ - "arbitrary", "byteorder", "crunchy", "hex", @@ -8955,12 +8992,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" -[[package]] -name = "unsafe-libyaml" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" - [[package]] name = "untrusted" version = "0.9.0" diff --git a/Cargo.toml b/Cargo.toml index 9aa6ab471e6a6..fe8730a6bae06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -157,54 +157,58 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.5.1", default-features = false } -foundry-compilers = { version = "0.10.3", default-features = false } -foundry-fork-db = "0.2" +foundry-block-explorers = { version = "0.7.1", default-features = false } +foundry-compilers = { version = "0.11.0", default-features = false } +foundry-fork-db = "0.3" solang-parser = "=0.3.3" ## revm # no default features to avoid c-kzg -revm = { version = "13.0.0", default-features = false } -revm-primitives = { version = "8.0.0", default-features = false } -revm-inspectors = { version = "0.5", features = ["serde"] } +revm = { version = "14.0.1", default-features = false } +revm-primitives = { version = "9.0.1", default-features = false } +revm-inspectors = { version = "0.6", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.2.1", default-features = false } -alloy-contract = { version = "0.2.1", default-features = false } -alloy-eips = { version = "0.2.1", default-features = false } -alloy-genesis = { version = "0.2.1", default-features = false } -alloy-json-rpc = { version = "0.2.1", default-features = false } -alloy-network = { version = "0.2.1", default-features = false } -alloy-provider = { version = "0.2.1", default-features = false } -alloy-pubsub = { version = "0.2.1", default-features = false } -alloy-rpc-client = { version = "0.2.1", default-features = false } -alloy-rpc-types = { version = "0.2.1", default-features = true } -alloy-serde = { version = "0.2.1", default-features = false } -alloy-signer = { version = "0.2.1", default-features = false } -alloy-signer-aws = { version = "0.2.1", default-features = false } -alloy-signer-gcp = { version = "0.2.1", default-features = false } -alloy-signer-ledger = { version = "0.2.1", default-features = false } -alloy-signer-local = { version = "0.2.1", default-features = false } -alloy-signer-trezor = { version = "0.2.1", default-features = false } -alloy-transport = { version = "0.2.1", default-features = false } -alloy-transport-http = { version = "0.2.1", default-features = false } -alloy-transport-ipc = { version = "0.2.1", default-features = false } -alloy-transport-ws = { version = "0.2.1", default-features = false } +alloy-consensus = { version = "0.3.1", default-features = false } +alloy-contract = { version = "0.3.1", default-features = false } +alloy-eips = { version = "0.3.1", default-features = false } +alloy-genesis = { version = "0.3.1", default-features = false } +alloy-json-rpc = { version = "0.3.1", default-features = false } +alloy-network = { version = "0.3.1", default-features = false } +alloy-provider = { version = "0.3.1", default-features = false } +alloy-pubsub = { version = "0.3.1", default-features = false } +alloy-rpc-client = { version = "0.3.1", default-features = false } +alloy-rpc-types = { version = "0.3.1", default-features = true } +alloy-serde = { version = "0.3.1", default-features = false } +alloy-signer = { version = "0.3.1", default-features = false } +alloy-signer-aws = { version = "0.3.1", default-features = false } +alloy-signer-gcp = { version = "0.3.1", default-features = false } +alloy-signer-ledger = { version = "0.3.1", default-features = false } +alloy-signer-local = { version = "0.3.1", default-features = false } +alloy-signer-trezor = { version = "0.3.1", default-features = false } +alloy-transport = { version = "0.3.1", default-features = false } +alloy-transport-http = { version = "0.3.1", default-features = false } +alloy-transport-ipc = { version = "0.3.1", default-features = false } +alloy-transport-ws = { version = "0.3.1", default-features = false } -alloy-dyn-abi = "0.7.7" -alloy-json-abi = "0.7.7" -alloy-primitives = { version = "0.7.7", features = ["getrandom", "rand"] } -alloy-sol-macro-expander = "0.7.7" -alloy-sol-macro-input = "0.7.7" -alloy-sol-types = "0.7.7" -syn-solidity = "0.7.7" +## alloy-core +alloy-dyn-abi = "0.8.1" +alloy-json-abi = "0.8.1" +alloy-primitives = { version = "0.8.1", features = ["getrandom", "rand"] } +alloy-sol-macro-expander = "0.8.1" +alloy-sol-macro-input = "0.8.1" +alloy-sol-types = "0.8.1" +syn-solidity = "0.8.1" alloy-chains = "0.1" -alloy-rlp = "0.3.3" -alloy-trie = "0.4.1" +alloy-rlp = "0.3" +alloy-trie = "0.5.0" + +## op-alloy for tests in anvil +op-alloy-rpc-types = "0.2.8" ## misc async-trait = "0.1" @@ -252,7 +256,7 @@ yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } tempfile = "3.10" tokio = "1" rayon = "1" - +evmole = "0.5" axum = "0.7" hyper = "1.0" reqwest = { version = "0.12", default-features = false } @@ -264,26 +268,27 @@ proptest = "1" comfy-table = "7" [patch.crates-io] -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" } -revm = { git = "https://github.com/bluealloy/revm", rev = "caadc71" } -revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "caadc71" } +# https://github.com/alloy-rs/alloy/pull/1229 + https://github.com/alloy-rs/alloy/pull/1243 +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index a987879852b1e..77faec1f1e52b 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -122,6 +122,7 @@ alloy-pubsub.workspace = true foundry-test-utils.workspace = true similar-asserts.workspace = true tokio = { workspace = true, features = ["full"] } +op-alloy-rpc-types.workspace = true [features] default = ["cli", "jemalloc"] diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index d080f1e27cb74..7d80450f379e3 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -300,7 +300,6 @@ pub fn to_alloy_transaction_with_hash_and_sender( transaction_type: None, max_fee_per_blob_gas: None, blob_versioned_hashes: None, - other: Default::default(), authorization_list: None, }, TypedTransaction::EIP2930(t) => RpcTransaction { @@ -328,7 +327,6 @@ pub fn to_alloy_transaction_with_hash_and_sender( transaction_type: Some(1), max_fee_per_blob_gas: None, blob_versioned_hashes: None, - other: Default::default(), authorization_list: None, }, TypedTransaction::EIP1559(t) => RpcTransaction { @@ -356,7 +354,6 @@ pub fn to_alloy_transaction_with_hash_and_sender( transaction_type: Some(2), max_fee_per_blob_gas: None, blob_versioned_hashes: None, - other: Default::default(), authorization_list: None, }, TypedTransaction::EIP4844(t) => RpcTransaction { @@ -384,7 +381,6 @@ pub fn to_alloy_transaction_with_hash_and_sender( transaction_type: Some(3), max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas), blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), - other: Default::default(), authorization_list: None, }, TypedTransaction::EIP7702(t) => RpcTransaction { @@ -433,7 +429,6 @@ pub fn to_alloy_transaction_with_hash_and_sender( transaction_type: None, max_fee_per_blob_gas: None, blob_versioned_hashes: None, - other: Default::default(), authorization_list: None, }, } diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 5c4f354810113..6cc7bfa5aa63c 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -186,6 +186,44 @@ impl Transaction for DepositTransactionRequest { fn gas_price(&self) -> Option { None } + + fn ty(&self) -> u8 { + 0x7E + } + + // Below fields are not found in a `DepositTransactionRequest` + + fn access_list(&self) -> Option<&alloy_rpc_types::AccessList> { + None + } + + fn authorization_list(&self) -> Option<&[revm::primitives::SignedAuthorization]> { + None + } + + fn blob_versioned_hashes(&self) -> Option<&[B256]> { + None + } + + fn effective_tip_per_gas(&self, _base_fee: u64) -> Option { + None + } + + fn max_fee_per_blob_gas(&self) -> Option { + None + } + + fn max_fee_per_gas(&self) -> u128 { + 0 + } + + fn max_priority_fee_per_gas(&self) -> Option { + None + } + + fn priority_fee_or_price(&self) -> u128 { + 0 + } } impl SignableTransaction for DepositTransactionRequest { diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index d5770f7036a5a..3145ee1b2af83 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1199,7 +1199,7 @@ latest block number: {latest_block}" } } - let block_hash = block.header.hash.unwrap_or_default(); + let block_hash = block.header.hash; let chain_id = if let Some(chain_id) = self.chain_id { chain_id @@ -1218,7 +1218,7 @@ latest block number: {latest_block}" }; let override_chain_id = self.chain_id; // apply changes such as difficulty -> prevrandao and chain specifics for current chain id - apply_chain_and_block_specific_env_changes(env, &block); + apply_chain_and_block_specific_env_changes::(env, &block); let meta = BlockchainDbMeta::new(*env.env.clone(), eth_rpc_url.clone()); let block_chain_db = if self.fork_chain_id.is_some() { @@ -1289,18 +1289,19 @@ async fn derive_block_and_transactions( .ok_or(eyre::eyre!("Failed to get fork block by number"))?; // Filter out transactions that are after the fork transaction - let filtered_transactions: Vec<&Transaction> = transaction_block - .transactions - .as_transactions() - .ok_or(eyre::eyre!("Failed to get transactions from full fork block"))? - .iter() - .take_while_inclusive(|&transaction| transaction.hash != transaction_hash.0) - .collect(); + let filtered_transactions: Vec<&alloy_serde::WithOtherFields> = + transaction_block + .transactions + .as_transactions() + .ok_or(eyre::eyre!("Failed to get transactions from full fork block"))? + .iter() + .take_while_inclusive(|&transaction| transaction.hash != transaction_hash.0) + .collect(); // Convert the transactions to PoolTransactions let force_transactions = filtered_transactions .iter() - .map(|&transaction| PoolTransaction::try_from(transaction.clone())) + .map(|&transaction| PoolTransaction::try_from(transaction.clone().inner)) .collect::, _>>()?; Ok((transaction_block_number.saturating_sub(1), Some(force_transactions))) } @@ -1461,7 +1462,7 @@ async fn find_latest_fork_block, T: Transport + Clone // leeway for _ in 0..2 { if let Some(block) = provider.get_block(num.into(), false.into()).await? { - if block.header.hash.is_some() { + if !block.header.hash.is_zero() { break; } } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 937cd85048470..90cdc100699e4 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -34,7 +34,7 @@ use crate::{ use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account, TxEnvelope}; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; -use alloy_network::eip2718::Decodable2718; +use alloy_network::{eip2718::Decodable2718, BlockResponse}; use alloy_primitives::{Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64}; use alloy_rpc_types::{ anvil::{ @@ -48,7 +48,7 @@ use alloy_rpc_types::{ parity::LocalizedTransactionTrace, }, txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, - AccessList, AccessListResult, Block, BlockId, BlockNumberOrTag as BlockNumber, + AccessList, AccessListResult, AnyNetworkBlock, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Index, Log, Transaction, }; @@ -721,7 +721,7 @@ impl EthApi { /// Returns block with given hash. /// /// Handler for ETH RPC call: `eth_getBlockByHash` - pub async fn block_by_hash(&self, hash: B256) -> Result> { + pub async fn block_by_hash(&self, hash: B256) -> Result> { node_info!("eth_getBlockByHash"); self.backend.block_by_hash(hash).await } @@ -729,7 +729,7 @@ impl EthApi { /// Returns a _full_ block with given hash. /// /// Handler for ETH RPC call: `eth_getBlockByHash` - pub async fn block_by_hash_full(&self, hash: B256) -> Result> { + pub async fn block_by_hash_full(&self, hash: B256) -> Result> { node_info!("eth_getBlockByHash"); self.backend.block_by_hash_full(hash).await } @@ -737,7 +737,7 @@ impl EthApi { /// Returns block with given number. /// /// Handler for ETH RPC call: `eth_getBlockByNumber` - pub async fn block_by_number(&self, number: BlockNumber) -> Result> { + pub async fn block_by_number(&self, number: BlockNumber) -> Result> { node_info!("eth_getBlockByNumber"); if number == BlockNumber::Pending { return Ok(Some(self.pending_block().await)); @@ -749,7 +749,10 @@ impl EthApi { /// Returns a _full_ block with given number /// /// Handler for ETH RPC call: `eth_getBlockByNumber` - pub async fn block_by_number_full(&self, number: BlockNumber) -> Result> { + pub async fn block_by_number_full( + &self, + number: BlockNumber, + ) -> Result> { node_info!("eth_getBlockByNumber"); if number == BlockNumber::Pending { return Ok(self.pending_block_full().await); @@ -778,7 +781,7 @@ impl EthApi { pub async fn block_transaction_count_by_hash(&self, hash: B256) -> Result> { node_info!("eth_getBlockTransactionCountByHash"); let block = self.backend.block_by_hash(hash).await?; - let txs = block.map(|b| match b.transactions { + let txs = block.map(|b| match b.transactions() { BlockTransactions::Full(txs) => U256::from(txs.len()), BlockTransactions::Hashes(txs) => U256::from(txs.len()), BlockTransactions::Uncle => U256::from(0), @@ -800,7 +803,7 @@ impl EthApi { return Ok(Some(U256::from(block.transactions.len()))); } let block = self.backend.block_by_number(block_number).await?; - let txs = block.map(|b| match b.transactions { + let txs = block.map(|b| match b.transactions() { BlockTransactions::Full(txs) => U256::from(txs.len()), BlockTransactions::Hashes(txs) => U256::from(txs.len()), BlockTransactions::Uncle => U256::from(0), @@ -1238,7 +1241,7 @@ impl EthApi { &self, block_hash: B256, idx: Index, - ) -> Result> { + ) -> Result> { node_info!("eth_getUncleByBlockHashAndIndex"); let number = self.backend.ensure_block_number(Some(BlockId::Hash(block_hash.into()))).await?; @@ -1258,7 +1261,7 @@ impl EthApi { &self, block_number: BlockNumber, idx: Index, - ) -> Result> { + ) -> Result> { node_info!("eth_getUncleByBlockNumberAndIndex"); let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?; if let Some(fork) = self.get_fork() { @@ -2138,7 +2141,10 @@ impl EthApi { /// **Note**: This behaves exactly as [Self::evm_mine] but returns different output, for /// compatibility reasons, this is a separate call since `evm_mine` is not an anvil original. /// and `ganache` may change the `0x0` placeholder. - pub async fn evm_mine_detailed(&self, opts: Option) -> Result> { + pub async fn evm_mine_detailed( + &self, + opts: Option, + ) -> Result> { node_info!("evm_mine_detailed"); let mined_blocks = self.do_evm_mine(opts).await?; @@ -2151,7 +2157,7 @@ impl EthApi { if let Some(mut block) = self.backend.block_by_number_full(BlockNumber::Number(block_num)).await? { - let mut block_txs = match block.transactions { + let block_txs = match block.transactions_mut() { BlockTransactions::Full(txs) => txs, BlockTransactions::Hashes(_) | BlockTransactions::Uncle => unreachable!(), }; @@ -2183,7 +2189,7 @@ impl EthApi { } } } - block.transactions = BlockTransactions::Full(block_txs); + block.transactions = BlockTransactions::Full(block_txs.to_vec()); blocks.push(block); } } @@ -2634,19 +2640,19 @@ impl EthApi { } /// Returns the pending block with tx hashes - async fn pending_block(&self) -> Block { + async fn pending_block(&self) -> AnyNetworkBlock { let transactions = self.pool.ready_transactions().collect::>(); let info = self.backend.pending_block(transactions).await; self.backend.convert_block(info.block) } /// Returns the full pending block with `Transaction` objects - async fn pending_block_full(&self) -> Option { + async fn pending_block_full(&self) -> Option { let transactions = self.pool.ready_transactions().collect::>(); let BlockInfo { block, transactions, receipts: _ } = self.backend.pending_block(transactions).await; - let partial_block = self.backend.convert_block(block.clone()); + let mut partial_block = self.backend.convert_block(block.clone()); let mut block_transactions = Vec::with_capacity(block.transactions.len()); let base_fee = self.backend.base_fee(); @@ -2661,10 +2667,12 @@ impl EthApi { Some(info), Some(base_fee), ); - block_transactions.push(tx.inner); + block_transactions.push(tx); } - Some(partial_block.into_full_block(block_transactions)) + partial_block.transactions = BlockTransactions::from(block_transactions); + + Some(partial_block) } fn build_typed_tx_request( diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 0a63ad453522f..c661eeaa89b86 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -3,6 +3,7 @@ use crate::eth::{backend::db::Db, error::BlockchainError, pool::transactions::PoolTransaction}; use alloy_consensus::Account; use alloy_eips::eip2930::AccessListResult; +use alloy_network::BlockResponse; use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; use alloy_provider::{ ext::{DebugApi, TraceApi}, @@ -14,7 +15,7 @@ use alloy_rpc_types::{ geth::{GethDebugTracingOptions, GethTrace}, parity::LocalizedTransactionTrace as Trace, }, - Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + AnyNetworkBlock, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, Log, Transaction, }; use alloy_serde::WithOtherFields; @@ -82,12 +83,12 @@ impl ClientFork { .get_block(block_number, false.into()) .await? .ok_or(BlockchainError::BlockNotFound)?; - let block_hash = block.header.hash.ok_or(BlockchainError::BlockNotFound)?; + let block_hash = block.header.hash; let timestamp = block.header.timestamp; let base_fee = block.header.base_fee_per_gas; let total_difficulty = block.header.total_difficulty.unwrap_or_default(); - let number = block.header.number.ok_or(BlockchainError::BlockNotFound)?; + let number = block.header.number; self.config.write().update_block(number, block_hash, timestamp, base_fee, total_difficulty); self.clear_cached_storage(); @@ -283,10 +284,10 @@ impl ClientFork { index: usize, ) -> Result>, TransportError> { if let Some(block) = self.block_by_number(number).await? { - match block.transactions { + match block.transactions() { BlockTransactions::Full(txs) => { if let Some(tx) = txs.get(index) { - return Ok(Some(WithOtherFields::new(tx.clone()))); + return Ok(Some(tx.clone())); } } BlockTransactions::Hashes(hashes) => { @@ -307,10 +308,10 @@ impl ClientFork { index: usize, ) -> Result>, TransportError> { if let Some(block) = self.block_by_hash(hash).await? { - match block.transactions { + match block.transactions() { BlockTransactions::Full(txs) => { if let Some(tx) = txs.get(index) { - return Ok(Some(WithOtherFields::new(tx.clone()))); + return Ok(Some(tx.clone())); } } BlockTransactions::Hashes(hashes) => { @@ -440,7 +441,10 @@ impl ClientFork { Ok(None) } - pub async fn block_by_hash(&self, hash: B256) -> Result, TransportError> { + pub async fn block_by_hash( + &self, + hash: B256, + ) -> Result, TransportError> { if let Some(mut block) = self.storage_read().blocks.get(&hash).cloned() { block.transactions.convert_to_hashes(); return Ok(Some(block)); @@ -452,7 +456,10 @@ impl ClientFork { })) } - pub async fn block_by_hash_full(&self, hash: B256) -> Result, TransportError> { + pub async fn block_by_hash_full( + &self, + hash: B256, + ) -> Result, TransportError> { if let Some(block) = self.storage_read().blocks.get(&hash).cloned() { return Ok(Some(self.convert_to_full_block(block))); } @@ -462,7 +469,7 @@ impl ClientFork { pub async fn block_by_number( &self, block_number: u64, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(mut block) = self .storage_read() .hashes @@ -483,7 +490,7 @@ impl ClientFork { pub async fn block_by_number_full( &self, block_number: u64, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self .storage_read() .hashes @@ -500,19 +507,17 @@ impl ClientFork { async fn fetch_full_block( &self, block_id: impl Into, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.provider().get_block(block_id.into(), true.into()).await? { - let hash = block.header.hash.unwrap(); - let block_number = block.header.number.unwrap(); + let hash = block.header.hash; + let block_number = block.header.number; let mut storage = self.storage_write(); // also insert all transactions - let block_txs = match block.clone().transactions { - BlockTransactions::Full(txs) => txs, + let block_txs = match block.transactions() { + BlockTransactions::Full(txs) => txs.to_owned(), _ => vec![], }; - storage - .transactions - .extend(block_txs.iter().map(|tx| (tx.hash, WithOtherFields::new(tx.clone())))); + storage.transactions.extend(block_txs.iter().map(|tx| (tx.hash, tx.clone()))); storage.hashes.insert(block_number, hash); storage.blocks.insert(hash, block.clone()); return Ok(Some(block)); @@ -525,7 +530,7 @@ impl ClientFork { &self, hash: B256, index: usize, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_hash(hash).await? { return self.uncles_by_block_and_index(block, index).await; } @@ -536,7 +541,7 @@ impl ClientFork { &self, number: u64, index: usize, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_number(number).await? { return self.uncles_by_block_and_index(block, index).await; } @@ -545,11 +550,11 @@ impl ClientFork { async fn uncles_by_block_and_index( &self, - block: Block, + block: AnyNetworkBlock, index: usize, - ) -> Result, TransportError> { - let block_hash = block.header.hash.expect("Missing block hash"); - let block_number = block.header.number.expect("Missing block number"); + ) -> Result, TransportError> { + let block_hash = block.header.hash; + let block_number = block.header.number; if let Some(uncles) = self.storage_read().uncles.get(&block_hash) { return Ok(uncles.get(index).cloned()); } @@ -568,7 +573,7 @@ impl ClientFork { } /// Converts a block of hashes into a full block - fn convert_to_full_block(&self, block: Block) -> Block { + fn convert_to_full_block(&self, mut block: AnyNetworkBlock) -> AnyNetworkBlock { let storage = self.storage.read(); let block_txs_len = match block.transactions { BlockTransactions::Full(ref txs) => txs.len(), @@ -579,11 +584,13 @@ impl ClientFork { let mut transactions = Vec::with_capacity(block_txs_len); for tx in block.transactions.hashes() { if let Some(tx) = storage.transactions.get(&tx).cloned() { - transactions.push(tx.inner); + transactions.push(tx); } } // TODO: fix once blocks have generic transactions - block.into_full_block(transactions) + block.inner.transactions = BlockTransactions::Full(transactions); + + block } } @@ -668,8 +675,8 @@ impl ClientForkConfig { /// This is used as a cache so repeated requests to the same data are not sent to the remote client #[derive(Clone, Debug, Default)] pub struct ForkedStorage { - pub uncles: HashMap>, - pub blocks: HashMap, + pub uncles: HashMap>, + pub blocks: HashMap, pub hashes: HashMap, pub transactions: HashMap>, pub transaction_receipts: HashMap, diff --git a/crates/anvil/src/eth/backend/info.rs b/crates/anvil/src/eth/backend/info.rs index 448dc660a1091..3ac359619d83e 100644 --- a/crates/anvil/src/eth/backend/info.rs +++ b/crates/anvil/src/eth/backend/info.rs @@ -2,7 +2,8 @@ use crate::mem::Backend; use alloy_primitives::B256; -use alloy_rpc_types::Block as AlloyBlock; +use alloy_rpc_types::{Block as AlloyBlock, Transaction}; +use alloy_serde::WithOtherFields; use anvil_core::eth::{block::Block, transaction::TypedReceipt}; use std::{fmt, sync::Arc}; @@ -42,7 +43,10 @@ impl StorageInfo { } /// Returns the block with the given hash in the format of the ethereum API - pub fn eth_block(&self, hash: B256) -> Option { + pub fn eth_block( + &self, + hash: B256, + ) -> Option>>> { let block = self.block(hash)?; Some(self.backend.convert_block(block)) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index a9c54ba86e969..86e8ad039c491 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -48,9 +48,10 @@ use alloy_rpc_types::{ }, parity::LocalizedTransactionTrace, }, - AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, - EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, - FilteredParams, Header as AlloyHeader, Index, Log, Transaction, TransactionReceipt, + AccessList, AnyNetworkBlock, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, + BlockTransactions, EIP1186AccountProofResponse as AccountProof, + EIP1186StorageProof as StorageProof, Filter, FilteredParams, Header as AlloyHeader, Index, Log, + Transaction, TransactionReceipt, }; use alloy_serde::WithOtherFields; use alloy_trie::{proof::ProofRetainer, HashBuilder, Nibbles}; @@ -1523,7 +1524,10 @@ impl Backend { } } - pub async fn block_by_hash(&self, hash: B256) -> Result, BlockchainError> { + pub async fn block_by_hash( + &self, + hash: B256, + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by hash {:?}", hash); if let tx @ Some(_) = self.mined_block_by_hash(hash) { return Ok(tx); @@ -1539,7 +1543,7 @@ impl Backend { pub async fn block_by_hash_full( &self, hash: B256, - ) -> Result, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by hash {:?}", hash); if let tx @ Some(_) = self.get_full_block(hash) { return Ok(tx); @@ -1552,7 +1556,7 @@ impl Backend { Ok(None) } - fn mined_block_by_hash(&self, hash: B256) -> Option { + fn mined_block_by_hash(&self, hash: B256) -> Option { let block = self.blockchain.get_block_by_hash(&hash)?; Some(self.convert_block(block)) } @@ -1588,7 +1592,7 @@ impl Backend { pub async fn block_by_number( &self, number: BlockNumber, - ) -> Result, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by number {:?}", number); if let tx @ Some(_) = self.mined_block_by_number(number) { return Ok(tx); @@ -1607,7 +1611,7 @@ impl Backend { pub async fn block_by_number_full( &self, number: BlockNumber, - ) -> Result, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by number {:?}", number); if let tx @ Some(_) = self.get_full_block(number) { return Ok(tx); @@ -1660,22 +1664,24 @@ impl Backend { self.blockchain.get_block_by_hash(&hash) } - pub fn mined_block_by_number(&self, number: BlockNumber) -> Option { + pub fn mined_block_by_number(&self, number: BlockNumber) -> Option { let block = self.get_block(number)?; let mut block = self.convert_block(block); block.transactions.convert_to_hashes(); Some(block) } - pub fn get_full_block(&self, id: impl Into) -> Option { + pub fn get_full_block(&self, id: impl Into) -> Option { let block = self.get_block(id)?; let transactions = self.mined_transactions_in_block(&block)?; - let block = self.convert_block(block); - Some(block.into_full_block(transactions.into_iter().map(|t| t.inner).collect())) + let mut block = self.convert_block(block); + block.inner.transactions = BlockTransactions::Full(transactions); + + Some(block) } /// Takes a block as it's stored internally and returns the eth api conform block format. - pub fn convert_block(&self, block: Block) -> AlloyBlock { + pub fn convert_block(&self, block: Block) -> AnyNetworkBlock { let size = U256::from(alloy_rlp::encode(&block).len() as u32); let Block { header, transactions, .. } = block; @@ -1705,16 +1711,16 @@ impl Backend { parent_beacon_block_root, } = header; - let mut block = AlloyBlock { + let block = AlloyBlock { header: AlloyHeader { - hash: Some(hash), + hash, parent_hash, uncles_hash: ommers_hash, miner: beneficiary, state_root, transactions_root, receipts_root, - number: Some(number), + number, gas_used, gas_limit, extra_data: extra_data.0.into(), @@ -1737,9 +1743,10 @@ impl Backend { ), uncles: vec![], withdrawals: None, - other: Default::default(), }; + let mut block = WithOtherFields::new(block); + // If Arbitrum, apply chain specifics to converted block. if let Ok( NamedChain::Arbitrum | @@ -1749,7 +1756,7 @@ impl Backend { ) = NamedChain::try_from(self.env.read().env.cfg.chain_id) { // Block number is the best number. - block.header.number = Some(self.best_number()); + block.header.number = self.best_number(); // Set `l1BlockNumber` field. block.other.insert("l1BlockNumber".to_string(), number.into()); } @@ -1769,13 +1776,13 @@ impl Backend { let current = self.best_number(); let requested = match block_id.map(Into::into).unwrap_or(BlockId::Number(BlockNumber::Latest)) { - BlockId::Hash(hash) => self - .block_by_hash(hash.block_hash) - .await? - .ok_or(BlockchainError::BlockNotFound)? - .header - .number - .ok_or(BlockchainError::BlockNotFound)?, + BlockId::Hash(hash) => { + self.block_by_hash(hash.block_hash) + .await? + .ok_or(BlockchainError::BlockNotFound)? + .header + .number + } BlockId::Number(num) => match num { BlockNumber::Latest | BlockNumber::Pending => self.best_number(), BlockNumber::Earliest => U64::ZERO.to::(), @@ -1841,7 +1848,7 @@ impl Backend { if let Some((block_hash, block)) = self .block_by_number(BlockNumber::Number(block_number.to::())) .await? - .and_then(|block| Some((block.header.hash?, block))) + .map(|block| (block.header.hash, block)) { if let Some(state) = self.states.write().get(&block_hash) { let block = BlockEnv { @@ -2290,8 +2297,8 @@ impl Backend { number: BlockNumber, index: Index, ) -> Result>, BlockchainError> { - if let Some(hash) = self.mined_block_by_number(number).and_then(|b| b.header.hash) { - return Ok(self.mined_transaction_by_block_hash_and_index(hash, index)); + if let Some(block) = self.mined_block_by_number(number) { + return Ok(self.mined_transaction_by_block_hash_and_index(block.header.hash, index)); } if let Some(fork) = self.get_fork() { diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 7349cff7822e3..ada9e6c532334 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -273,7 +273,7 @@ impl From for InvalidTransactionError { Self::AuthorizationListNotSupported } InvalidTransaction::AuthorizationListInvalidFields | - InvalidTransaction::InvalidAuthorizationList | + InvalidTransaction::InvalidAuthorizationList(_) | InvalidTransaction::OptimismError(_) | InvalidTransaction::EofCrateShouldHaveToAddress | InvalidTransaction::EmptyAuthorizationList => Self::Revm(err), diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 0195cee69ba80..798ff205bf1b8 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -3,20 +3,23 @@ use crate::eth::{ macros::node_info, EthApi, }; +use alloy_network::BlockResponse; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_rpc_types::{ trace::{ otterscan::{ BlockDetails, ContractCreator, InternalOperation, OtsBlock, OtsBlockTransactions, - OtsReceipt, OtsTransactionReceipt, TraceEntry, TransactionsWithReceipts, + OtsReceipt, OtsSlimBlock, OtsTransactionReceipt, TraceEntry, TransactionsWithReceipts, }, parity::{ Action, CallAction, CallType, CreateAction, CreateOutput, LocalizedTransactionTrace, RewardAction, TraceOutput, }, }, - Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + AnyNetworkBlock, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + Transaction, }; +use alloy_serde::WithOtherFields; use itertools::Itertools; use futures::future::join_all; @@ -84,7 +87,10 @@ impl EthApi { /// /// As a faster alternative to `eth_getBlockByNumber` (by excluding uncle block /// information), which is not relevant in the context of an anvil node - pub async fn erigon_get_header_by_number(&self, number: BlockNumber) -> Result> { + pub async fn erigon_get_header_by_number( + &self, + number: BlockNumber, + ) -> Result> { node_info!("ots_getApiLevel"); self.backend.block_by_number(number).await @@ -172,7 +178,7 @@ impl EthApi { number: u64, page: usize, page_size: usize, - ) -> Result { + ) -> Result>> { node_info!("ots_getBlockTransactions"); match self.backend.block_by_number_full(number.into()).await? { @@ -346,7 +352,7 @@ impl EthApi { /// based on the existing list. /// /// Therefore we keep it simple by keeping the data in the response - pub async fn build_ots_block_details(&self, block: Block) -> Result { + pub async fn build_ots_block_details(&self, block: AnyNetworkBlock) -> Result { if block.transactions.is_uncle() { return Err(BlockchainError::DataUnavailable); } @@ -369,8 +375,18 @@ impl EthApi { .iter() .fold(0, |acc, receipt| acc + receipt.gas_used * receipt.effective_gas_price); + let Block { header, uncles, transactions, size, withdrawals } = block.inner; + + let block = OtsSlimBlock { + header, + uncles, + transaction_count: transactions.len(), + size, + withdrawals, + }; + Ok(BlockDetails { - block: block.into(), + block, total_fees: U256::from(total_fees), // issuance has no meaningful value in anvil's backend. just default to 0 issuance: Default::default(), @@ -383,20 +399,20 @@ impl EthApi { /// [`ots_getBlockTransactions`]: https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails pub async fn build_ots_block_tx( &self, - mut block: Block, + mut block: AnyNetworkBlock, page: usize, page_size: usize, - ) -> Result { + ) -> Result>> { if block.transactions.is_uncle() { return Err(BlockchainError::DataUnavailable); } - block.transactions = match block.transactions { + block.transactions = match block.transactions() { BlockTransactions::Full(txs) => BlockTransactions::Full( - txs.into_iter().skip(page * page_size).take(page_size).collect(), + txs.iter().skip(page * page_size).take(page_size).cloned().collect(), ), BlockTransactions::Hashes(txs) => BlockTransactions::Hashes( - txs.into_iter().skip(page * page_size).take(page_size).collect(), + txs.iter().skip(page * page_size).take(page_size).cloned().collect(), ), BlockTransactions::Uncle => unreachable!(), }; @@ -418,9 +434,13 @@ impl EthApi { }) .collect::>>()?; - let fullblock: OtsBlock = block.into(); + let transaction_count = block.transactions().len(); + let fullblock = OtsBlock { block: block.inner, transaction_count }; + + let ots_block_txs = + OtsBlockTransactions::> { fullblock, receipts }; - Ok(OtsBlockTransactions { fullblock, receipts }) + Ok(ots_block_txs) } pub async fn build_ots_search_transactions( diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index 8cf13e844927c..f9ba36b60f6c6 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -6,7 +6,7 @@ use crate::{shutdown::Shutdown, tasks::block_listener::BlockListener, EthApi}; use alloy_network::AnyNetwork; use alloy_primitives::B256; use alloy_provider::Provider; -use alloy_rpc_types::{anvil::Forking, Block}; +use alloy_rpc_types::{anvil::Forking, AnyNetworkBlock}; use alloy_transport::Transport; use futures::StreamExt; use std::{fmt, future::Future}; @@ -77,7 +77,7 @@ impl TaskManager { let _ = api .anvil_reset(Some(Forking { json_rpc_url: None, - block_number: block.header.number, + block_number: Some(block.header.number), })) .await; } @@ -135,7 +135,7 @@ impl TaskManager { let _ = api .anvil_reset(Some(Forking { json_rpc_url: None, - block_number: block.header.number, + block_number: Some(block.header.number), })) .await; } @@ -149,7 +149,7 @@ impl TaskManager { where P: Provider + 'static, T: Transport + Clone, - F: Fn(Block) -> Fut + Unpin + Send + Sync + 'static, + F: Fn(AnyNetworkBlock) -> Fut + Unpin + Send + Sync + 'static, Fut: Future + Send, { let shutdown = self.on_shutdown.clone(); diff --git a/crates/anvil/tests/it/abi.rs b/crates/anvil/tests/it/abi.rs index 3356b02f10e40..9bd3b84e9d934 100644 --- a/crates/anvil/tests/it/abi.rs +++ b/crates/anvil/tests/it/abi.rs @@ -16,7 +16,7 @@ sol!( sol!( #[sol(rpc)] - MulticallContract, + Multicall, "test-data/multicall.json" ); diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 1f1c48e21ad22..0e8001853a95f 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -1,7 +1,7 @@ //! tests for custom anvil endpoints use crate::{ - abi::{self, Greeter, MulticallContract, BUSD}, + abi::{self, Greeter, Multicall, BUSD}, fork::fork_config, utils::http_provider_with_signer, }; @@ -298,13 +298,13 @@ async fn test_set_next_timestamp() { let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); - assert_eq!(block.header.number.unwrap(), 1); + assert_eq!(block.header.number, 1); assert_eq!(block.header.timestamp, next_timestamp.as_secs()); api.evm_mine(None).await.unwrap(); let next = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); - assert_eq!(next.header.number.unwrap(), 2); + assert_eq!(next.header.number, 2); assert!(next.header.timestamp > block.header.timestamp); } @@ -447,7 +447,7 @@ async fn can_get_node_info() { let expected_node_info = NodeInfo { current_block_number: 0_u64, current_block_timestamp: 1, - current_block_hash: block.header.hash.unwrap(), + current_block_hash: block.header.hash, hard_fork: hard_fork.to_string(), transaction_order: "fees".to_owned(), environment: NodeEnvironment { @@ -480,7 +480,7 @@ async fn can_get_metadata() { provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); let expected_metadata = Metadata { - latest_block_hash: block.header.hash.unwrap(), + latest_block_hash: block.header.hash, latest_block_number: block_number, chain_id, client_version: CLIENT_VERSION.to_string(), @@ -506,7 +506,7 @@ async fn can_get_metadata_on_fork() { provider.get_block(BlockId::from(block_number), false.into()).await.unwrap().unwrap(); let expected_metadata = Metadata { - latest_block_hash: block.header.hash.unwrap(), + latest_block_hash: block.header.hash, latest_block_number: block_number, chain_id, client_version: CLIENT_VERSION.to_string(), @@ -514,7 +514,7 @@ async fn can_get_metadata_on_fork() { forked_network: Some(ForkedNetwork { chain_id, fork_block_number: block_number, - fork_block_hash: block.header.hash.unwrap(), + fork_block_hash: block.header.hash, }), snapshots: Default::default(), }; @@ -618,21 +618,21 @@ async fn test_fork_revert_call_latest_block_timestamp() { api.evm_revert(snapshot_id).await.unwrap(); let multicall_contract = - MulticallContract::new(address!("eefba1e63905ef1d7acba5a8513c70307c1ce441"), &provider); + Multicall::new(address!("eefba1e63905ef1d7acba5a8513c70307c1ce441"), &provider); - let MulticallContract::getCurrentBlockTimestampReturn { timestamp } = + let Multicall::getCurrentBlockTimestampReturn { timestamp } = multicall_contract.getCurrentBlockTimestamp().call().await.unwrap(); assert_eq!(timestamp, U256::from(latest_block.header.timestamp)); - let MulticallContract::getCurrentBlockDifficultyReturn { difficulty } = + let Multicall::getCurrentBlockDifficultyReturn { difficulty } = multicall_contract.getCurrentBlockDifficulty().call().await.unwrap(); assert_eq!(difficulty, U256::from(latest_block.header.difficulty)); - let MulticallContract::getCurrentBlockGasLimitReturn { gaslimit } = + let Multicall::getCurrentBlockGasLimitReturn { gaslimit } = multicall_contract.getCurrentBlockGasLimit().call().await.unwrap(); assert_eq!(gaslimit, U256::from(latest_block.header.gas_limit)); - let MulticallContract::getCurrentBlockCoinbaseReturn { coinbase } = + let Multicall::getCurrentBlockCoinbaseReturn { coinbase } = multicall_contract.getCurrentBlockCoinbase().call().await.unwrap(); assert_eq!(coinbase, latest_block.header.miner); } diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index 8843efddc419c..f9aaf0dbab029 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -1,7 +1,7 @@ //! general eth api tests use crate::{ - abi::{MulticallContract, SimpleStorage}, + abi::{Multicall, SimpleStorage}, utils::{connect_pubsub_with_wallet, http_provider_with_signer}, }; use alloy_network::{EthereumWallet, TransactionBuilder}; @@ -118,11 +118,8 @@ async fn can_get_block_by_number() { let block = provider.get_block(BlockId::number(1), true.into()).await.unwrap().unwrap(); assert_eq!(block.transactions.len(), 1); - let block = provider - .get_block(BlockId::hash(block.header.hash.unwrap()), true.into()) - .await - .unwrap() - .unwrap(); + let block = + provider.get_block(BlockId::hash(block.header.hash), true.into()).await.unwrap().unwrap(); assert_eq!(block.transactions.len(), 1); } @@ -138,7 +135,7 @@ async fn can_get_pending_block() { let provider = connect_pubsub_with_wallet(&handle.http_endpoint(), signer).await; let block = provider.get_block(BlockId::pending(), false.into()).await.unwrap().unwrap(); - assert_eq!(block.header.number.unwrap(), 1); + assert_eq!(block.header.number, 1); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, 0); @@ -153,12 +150,12 @@ async fn can_get_pending_block() { assert_eq!(num, 0); let block = provider.get_block(BlockId::pending(), false.into()).await.unwrap().unwrap(); - assert_eq!(block.header.number.unwrap(), 1); + assert_eq!(block.header.number, 1); assert_eq!(block.transactions.len(), 1); assert_eq!(block.transactions, BlockTransactions::Hashes(vec![*pending.tx_hash()])); let block = provider.get_block(BlockId::pending(), true.into()).await.unwrap().unwrap(); - assert_eq!(block.header.number.unwrap(), 1); + assert_eq!(block.header.number, 1); assert_eq!(block.transactions.len(), 1); } @@ -210,7 +207,7 @@ async fn can_call_on_pending_block() { api.anvil_set_auto_mine(false).await.unwrap(); - let _contract_pending = MulticallContract::deploy_builder(&provider) + let _contract_pending = Multicall::deploy_builder(&provider) .from(wallet.address()) .send() .await @@ -219,13 +216,13 @@ async fn can_call_on_pending_block() { .await .unwrap(); let contract_address = sender.create(0); - let contract = MulticallContract::new(contract_address, &provider); + let contract = Multicall::new(contract_address, &provider); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, 0); // Ensure that we can get the block_number from the pending contract - let MulticallContract::aggregateReturn { blockNumber: ret_block_number, .. } = + let Multicall::aggregateReturn { blockNumber: ret_block_number, .. } = contract.aggregate(vec![]).block(BlockId::pending()).call().await.unwrap(); assert_eq!(ret_block_number, U256::from(1)); @@ -244,31 +241,28 @@ async fn can_call_on_pending_block() { let block_number = BlockNumberOrTag::Number(anvil_block_number as u64); let block = api.block_by_number(block_number).await.unwrap().unwrap(); - let MulticallContract::getCurrentBlockTimestampReturn { timestamp: ret_timestamp, .. } = - contract - .getCurrentBlockTimestamp() - .block(BlockId::number(anvil_block_number as u64)) - .call() - .await - .unwrap(); + let Multicall::getCurrentBlockTimestampReturn { timestamp: ret_timestamp, .. } = contract + .getCurrentBlockTimestamp() + .block(BlockId::number(anvil_block_number as u64)) + .call() + .await + .unwrap(); assert_eq!(block.header.timestamp, ret_timestamp.to::()); - let MulticallContract::getCurrentBlockGasLimitReturn { gaslimit: ret_gas_limit, .. } = - contract - .getCurrentBlockGasLimit() - .block(BlockId::number(anvil_block_number as u64)) - .call() - .await - .unwrap(); + let Multicall::getCurrentBlockGasLimitReturn { gaslimit: ret_gas_limit, .. } = contract + .getCurrentBlockGasLimit() + .block(BlockId::number(anvil_block_number as u64)) + .call() + .await + .unwrap(); assert_eq!(block.header.gas_limit, ret_gas_limit.to::()); - let MulticallContract::getCurrentBlockCoinbaseReturn { coinbase: ret_coinbase, .. } = - contract - .getCurrentBlockCoinbase() - .block(BlockId::number(anvil_block_number as u64)) - .call() - .await - .unwrap(); + let Multicall::getCurrentBlockCoinbaseReturn { coinbase: ret_coinbase, .. } = contract + .getCurrentBlockCoinbase() + .block(BlockId::number(anvil_block_number as u64)) + .call() + .await + .unwrap(); assert_eq!(block.header.miner, ret_coinbase); } } @@ -316,7 +310,7 @@ async fn can_call_with_state_override() { api.anvil_set_auto_mine(true).await.unwrap(); - let multicall_contract = MulticallContract::deploy(&provider).await.unwrap(); + let multicall_contract = Multicall::deploy(&provider).await.unwrap(); let init_value = "toto".to_string(); @@ -383,18 +377,12 @@ async fn can_mine_while_mining() { let total_blocks = 200; - let block_number = api - .block_by_number(BlockNumberOrTag::Latest) - .await - .unwrap() - .unwrap() - .header - .number - .unwrap(); + let block_number = + api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap().header.number; assert_eq!(block_number, 0); let block = api.block_by_number(BlockNumberOrTag::Number(block_number)).await.unwrap().unwrap(); - assert_eq!(block.header.number.unwrap(), 0); + assert_eq!(block.header.number, 0); let result = join!( api.anvil_mine(Some(U256::from(total_blocks / 2)), None), @@ -404,16 +392,10 @@ async fn can_mine_while_mining() { result.1.unwrap(); tokio::time::sleep(Duration::from_millis(100)).await; - let block_number = api - .block_by_number(BlockNumberOrTag::Latest) - .await - .unwrap() - .unwrap() - .header - .number - .unwrap(); + let block_number = + api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap().header.number; assert_eq!(block_number, total_blocks); let block = api.block_by_number(BlockNumberOrTag::Number(block_number)).await.unwrap().unwrap(); - assert_eq!(block.header.number.unwrap(), total_blocks); + assert_eq!(block.header.number, total_blocks); } diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 884bc06054669..672d3b72fdf36 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -734,7 +734,7 @@ async fn test_fork_init_base_fee() { let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); // - assert_eq!(block.header.number.unwrap(), 13184859u64); + assert_eq!(block.header.number, 13184859u64); let init_base_fee = block.header.base_fee_per_gas.unwrap(); assert_eq!(init_base_fee, 63739886069u128); @@ -850,7 +850,7 @@ async fn test_fork_uncles_fetch() { let count = provider.get_uncle_count(block_with_uncles.into()).await.unwrap(); assert_eq!(count as usize, block.uncles.len()); - let hash = BlockId::hash(block.header.hash.unwrap()); + let hash = BlockId::hash(block.header.hash); let count = provider.get_uncle_count(hash).await.unwrap(); assert_eq!(count as usize, block.uncles.len()); @@ -861,15 +861,15 @@ async fn test_fork_uncles_fetch() { .await .unwrap() .unwrap(); - assert_eq!(*uncle_hash, uncle.header.hash.unwrap()); + assert_eq!(*uncle_hash, uncle.header.hash); // Try with block hash let uncle = provider - .get_uncle(BlockId::hash(block.header.hash.unwrap()), uncle_idx as u64) + .get_uncle(BlockId::hash(block.header.hash), uncle_idx as u64) .await .unwrap() .unwrap(); - assert_eq!(*uncle_hash, uncle.header.hash.unwrap()); + assert_eq!(*uncle_hash, uncle.header.hash); } } @@ -905,11 +905,8 @@ async fn test_fork_block_transaction_count() { api.block_transaction_count_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); assert_eq!(latest_txs.to::(), 1); let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - let latest_txs = api - .block_transaction_count_by_hash(latest_block.header.hash.unwrap()) - .await - .unwrap() - .unwrap(); + let latest_txs = + api.block_transaction_count_by_hash(latest_block.header.hash).await.unwrap().unwrap(); assert_eq!(latest_txs.to::(), 1); // check txs count on an older block: 420000 has 3 txs on mainnet @@ -1173,7 +1170,7 @@ async fn test_arbitrum_fork_block_number() { // test block by number API call returns proper block number and `l1BlockNumber` is set let block_by_number = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert_eq!(block_by_number.header.number.unwrap(), initial_block_number + 1); + assert_eq!(block_by_number.header.number, initial_block_number + 1); assert!(block_by_number.other.get("l1BlockNumber").is_some()); // revert to recorded snapshot and check block number @@ -1283,7 +1280,7 @@ async fn test_immutable_fork_transaction_hash() { let tx = api .backend .mined_block_by_number(BlockNumberOrTag::Number(fork_block_number)) - .and_then(|b| b.header.hash) + .map(|b| b.header.hash) .and_then(|hash| { api.backend.mined_transaction_by_block_hash_and_index(hash, expected.1.into()) }) diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index 786217ecd6ab2..4f13f8aaf0a12 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -54,7 +54,7 @@ async fn test_sub_new_heads_ipc() { let blocks = provider.subscribe_blocks().await.unwrap().into_stream(); let blocks = blocks.take(3).collect::>().await; - let block_numbers = blocks.into_iter().map(|b| b.header.number.unwrap()).collect::>(); + let block_numbers = blocks.into_iter().map(|b| b.header.number).collect::>(); assert_eq!(block_numbers, vec![1, 2, 3]); } diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index 40d032d7ccdcf..1ce4ac64ffaea 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -60,8 +60,7 @@ async fn get_past_events() { .unwrap() .unwrap() .header - .hash - .unwrap(); + .hash; let filter = Filter::new() .address(simple_storage_address) @@ -197,8 +196,7 @@ async fn watch_events() { .unwrap() .unwrap() .header - .hash - .unwrap(); + .hash; assert_eq!(log.1.block_hash.unwrap(), hash); } } diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 4ca74f9feb3fc..6446caf9ce682 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -5,10 +5,11 @@ use alloy_eips::eip2718::Encodable2718; use alloy_network::{EthereumWallet, TransactionBuilder}; use alloy_primitives::{b256, Address, TxHash, TxKind, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{optimism::OptimismTransactionFields, TransactionRequest}; +use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; use anvil::{spawn, EthereumHardfork, NodeConfig}; use anvil_core::eth::transaction::optimism::DepositTransaction; +use op_alloy_rpc_types::OptimismTransactionFields; #[tokio::test(flavor = "multi_thread")] async fn test_deposits_not_supported_if_optimism_disabled() { @@ -32,6 +33,7 @@ async fn test_deposits_not_supported_if_optimism_disabled() { )), mint: Some(0), is_system_tx: Some(true), + deposit_receipt_version: None, } .into(), }; @@ -72,6 +74,7 @@ async fn test_send_value_deposit_transaction() { )), mint: Some(0), is_system_tx: Some(true), + deposit_receipt_version: None, } .into(), }; @@ -126,6 +129,7 @@ async fn test_send_value_raw_deposit_transaction() { )), mint: Some(0), is_system_tx: Some(true), + deposit_receipt_version: None, } .into(), }; diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 2f2c0e3c1ce8a..55474079fb0ea 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -1,6 +1,6 @@ //! Tests for otterscan endpoints. -use crate::abi::MulticallContract; +use crate::abi::Multicall; use alloy_primitives::{address, Address, Bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ @@ -18,10 +18,10 @@ async fn erigon_get_header_by_number() { api.mine_one().await; let res0 = api.erigon_get_header_by_number(0.into()).await.unwrap().unwrap(); - assert_eq!(res0.header.number, Some(0)); + assert_eq!(res0.header.number, 0); let res1 = api.erigon_get_header_by_number(1.into()).await.unwrap().unwrap(); - assert_eq!(res1.header.number, Some(1)); + assert_eq!(res1.header.number, 1); } #[tokio::test(flavor = "multi_thread")] @@ -37,13 +37,8 @@ async fn ots_get_internal_operations_contract_deploy() { let provider = handle.http_provider(); let sender = handle.dev_accounts().next().unwrap(); - let contract_receipt = MulticallContract::deploy_builder(&provider) - .send() - .await - .unwrap() - .get_receipt() - .await - .unwrap(); + let contract_receipt = + Multicall::deploy_builder(&provider).send().await.unwrap().get_receipt().await.unwrap(); let res = api.ots_get_internal_operations(contract_receipt.transaction_hash).await.unwrap(); assert_eq!( @@ -181,7 +176,7 @@ async fn ots_has_code() { // no code in the address before deploying assert!(!api.ots_has_code(contract_address, BlockNumberOrTag::Number(1)).await.unwrap()); - let contract_builder = MulticallContract::deploy_builder(&provider); + let contract_builder = Multicall::deploy_builder(&provider); let contract_receipt = contract_builder.send().await.unwrap().get_receipt().await.unwrap(); let num = provider.get_block_number().await.unwrap(); @@ -501,13 +496,8 @@ async fn ots_get_contract_creator() { let provider = handle.http_provider(); let sender = handle.dev_accounts().next().unwrap(); - let receipt = MulticallContract::deploy_builder(&provider) - .send() - .await - .unwrap() - .get_receipt() - .await - .unwrap(); + let receipt = + Multicall::deploy_builder(&provider).send().await.unwrap().get_receipt().await.unwrap(); let contract_address = receipt.contract_address.unwrap(); let creator = api.ots_get_contract_creator(contract_address).await.unwrap().unwrap(); diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index fec22ca41cd48..a343f7c7089d6 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -23,7 +23,7 @@ async fn test_sub_new_heads() { api.anvil_set_interval_mining(1).unwrap(); let blocks = blocks.into_stream().take(3).collect::>().await; - let block_numbers = blocks.into_iter().map(|b| b.header.number.unwrap()).collect::>(); + let block_numbers = blocks.into_iter().map(|b| b.header.number).collect::>(); assert_eq!(block_numbers, vec![1, 2, 3]); } @@ -233,7 +233,7 @@ async fn test_subscriptions() { let (_api, handle) = spawn(NodeConfig::test().with_blocktime(Some(std::time::Duration::from_secs(1)))).await; let provider = connect_pubsub(&handle.ws_endpoint()).await; - let sub_id: U256 = provider.raw_request("eth_subscribe".into(), ["newHeads"]).await.unwrap(); + let sub_id = provider.raw_request("eth_subscribe".into(), ["newHeads"]).await.unwrap(); let stream: Subscription = provider.get_subscription(sub_id).await.unwrap(); let blocks = stream .into_stream() @@ -241,7 +241,7 @@ async fn test_subscriptions() { .collect::>() .await .into_iter() - .map(|b| b.header.number.unwrap()) + .map(|b| b.header.number) .collect::>(); assert_eq!(blocks, vec![1, 2, 3]) @@ -261,7 +261,7 @@ async fn test_sub_new_heads_fast() { let mut block_numbers = Vec::new(); for _ in 0..num { api.mine_one().await; - let block_number = blocks.next().await.unwrap().header.number.unwrap(); + let block_number = blocks.next().await.unwrap().header.number; block_numbers.push(block_number); } diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 782e68d729d14..5c9d87ca1aa57 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -1,5 +1,5 @@ use crate::{ - abi::{MulticallContract, SimpleStorage}, + abi::{Multicall, SimpleStorage}, fork::fork_config, utils::http_provider_with_signer, }; @@ -155,7 +155,7 @@ async fn test_call_tracer_debug_trace_call() { let deployer: EthereumWallet = wallets[0].clone().into(); let provider = http_provider_with_signer(&handle.http_endpoint(), deployer); - let multicall_contract = MulticallContract::deploy(&provider).await.unwrap(); + let multicall_contract = Multicall::deploy(&provider).await.unwrap(); let simple_storage_contract = SimpleStorage::deploy(&provider, "init value".to_string()).await.unwrap(); @@ -163,7 +163,7 @@ async fn test_call_tracer_debug_trace_call() { let set_value = simple_storage_contract.setValue("bar".to_string()); let set_value_calldata = set_value.calldata(); - let internal_call_tx_builder = multicall_contract.aggregate(vec![MulticallContract::Call { + let internal_call_tx_builder = multicall_contract.aggregate(vec![Multicall::Call { target: *simple_storage_contract.address(), callData: set_value_calldata.to_owned(), }]); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 330eb7a3928f4..0827bbac1de8c 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -1,5 +1,5 @@ use crate::{ - abi::{Greeter, MulticallContract, SimpleStorage}, + abi::{Greeter, Multicall, SimpleStorage}, utils::{connect_pubsub, http_provider_with_signer}, }; use alloy_network::{EthereumWallet, TransactionBuilder}; @@ -477,7 +477,7 @@ async fn get_blocktimestamp_works() { let (api, handle) = spawn(NodeConfig::test()).await; let provider = handle.http_provider(); - let contract = MulticallContract::deploy(provider.clone()).await.unwrap(); + let contract = Multicall::deploy(provider.clone()).await.unwrap(); let timestamp = contract.getCurrentBlockTimestamp().call().await.unwrap().timestamp; @@ -557,8 +557,7 @@ async fn call_past_state() { .unwrap() .unwrap() .header - .hash - .unwrap(); + .hash; let value = contract.getValue().block(BlockId::Hash(hash.into())).call().await.unwrap(); assert_eq!(value._0, "initial value"); } @@ -996,7 +995,7 @@ async fn test_tx_access_list() { let sender = Address::random(); let other_acc = Address::random(); - let multicall = MulticallContract::deploy(provider.clone()).await.unwrap(); + let multicall = Multicall::deploy(provider.clone()).await.unwrap(); let simple_storage = SimpleStorage::deploy(provider.clone(), "foo".to_string()).await.unwrap(); // when calling `setValue` on SimpleStorage, both the `lastSender` and `_value` storages are @@ -1044,7 +1043,7 @@ async fn test_tx_access_list() { // With a subcall to another contract, the AccessList should be the same as when calling the // subcontract directly (given that the proxy contract doesn't read/write any state) - let subcall_tx = multicall.aggregate(vec![MulticallContract::Call { + let subcall_tx = multicall.aggregate(vec![Multicall::Call { target: *simple_storage.address(), callData: set_value_calldata.to_owned(), }]); diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 2b2a0db9097b5..46f8eac95cd82 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -82,7 +82,7 @@ tempfile.workspace = true tokio = { workspace = true, features = ["macros", "signal"] } tracing.workspace = true yansi.workspace = true -evmole = "0.4.1" +evmole.workspace = true [target.'cfg(unix)'.dependencies] tikv-jemallocator = { workspace = true, optional = true } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 7a5e7980ceeee..b67c0ed1188ae 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -176,11 +176,11 @@ impl RunArgs { let pb = init_progress(block.transactions.len() as u64, "tx"); pb.set_position(0); - let BlockTransactions::Full(txs) = block.transactions else { + let BlockTransactions::Full(ref txs) = block.transactions else { return Err(eyre::eyre!("Could not get block txs")) }; - for (index, tx) in txs.into_iter().enumerate() { + for (index, tx) in txs.iter().enumerate() { // System transactions such as on L2s don't contain any pricing info so // we skip them otherwise this would cause // reverts @@ -194,7 +194,7 @@ impl RunArgs { break; } - configure_tx_env(&mut env, &tx); + configure_tx_env(&mut env, &tx.inner); if let Some(to) = tx.to { trace!(tx=?tx.hash,?to, "executing previous call transaction"); @@ -231,7 +231,7 @@ impl RunArgs { let result = { executor.set_trace_printer(self.trace_printer); - configure_tx_env(&mut env, &tx); + configure_tx_env(&mut env, &tx.inner); if let Some(to) = tx.to { trace!(tx=?tx.hash, to=?to, "executing call transaction"); diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index b0f29af438f2d..28009dbdcfccf 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -258,13 +258,14 @@ async fn main_args(args: CastArgs) -> Result<()> { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let number = match block { - Some(id) => provider - .get_block(id, false.into()) - .await? - .ok_or_else(|| eyre::eyre!("block {id:?} not found"))? - .header - .number - .ok_or_else(|| eyre::eyre!("block {id:?} has no block number"))?, + Some(id) => { + provider + .get_block(id, false.into()) + .await? + .ok_or_else(|| eyre::eyre!("block {id:?} not found"))? + .header + .number + } None => Cast::new(provider).block_number().await?, }; println!("{number}"); diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index c4d756ad72240..03355213de572 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -872,7 +872,7 @@ where BlockId::Hash(hash) => { let block = self.provider.get_block_by_hash(hash.block_hash, false.into()).await?; - Ok(block.map(|block| block.header.number.unwrap()).map(BlockNumberOrTag::from)) + Ok(block.map(|block| block.header.number).map(BlockNumberOrTag::from)) } }, None => Ok(None), @@ -937,7 +937,7 @@ where Either::Right(futures::future::pending()) } => { if let (Some(block), Some(to_block)) = (block, to_block_number) { - if block.header.number.map_or(false, |bn| bn > to_block) { + if block.header.number > to_block { break; } } @@ -1981,7 +1981,7 @@ impl SimpleCast { ( hex::encode_prefixed(s), evmole::function_arguments(&code, &s, 0), - evmole::function_state_mutability(&code, &s, 0), + evmole::function_state_mutability(&code, &s, 0).as_json_str(), ) }) .collect()) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index bb52936a9f730..01fdaef867d42 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -5,7 +5,10 @@ use alloy_primitives::{b256, B256}; use anvil::{EthereumHardfork, NodeConfig}; use foundry_test_utils::{ casttest, file, - rpc::{next_http_rpc_endpoint, next_rpc_endpoint, next_ws_rpc_endpoint}, + rpc::{ + next_http_rpc_endpoint, next_mainnet_etherscan_api_key, next_rpc_endpoint, + next_ws_rpc_endpoint, + }, str, util::OutputExt, }; @@ -1115,20 +1118,22 @@ casttest!(interface_no_constructor, |prj, cmd| { let path = prj.root().join("interface.json"); fs::write(&path, interface).unwrap(); // Call `cast find-block` - cmd.args(["interface"]).arg(&path).assert_success().stdout_eq(str![[ + cmd.arg("interface").arg(&path).assert_success().stdout_eq(str![[ r#"// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; -interface Interface { +library IIntegrationManager { type SpendAssetsHandleType is uint8; +} +interface Interface { function getIntegrationManager() external view returns (address integrationManager_); function lend(address _vaultProxy, bytes memory, bytes memory _assetData) external; function parseAssetsForAction(address, bytes4 _selector, bytes memory _actionData) external view returns ( - SpendAssetsHandleType spendAssetsHandleType_, + IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_, address[] memory spendAssets_, uint256[] memory spendAssetAmounts_, address[] memory incomingAssets_, @@ -1144,11 +1149,15 @@ interface Interface { // tests that fetches WETH interface from etherscan // casttest!(fetch_weth_interface_from_etherscan, |_prj, cmd| { - let weth_address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; - let api_key = "ZUB97R31KSYX7NYVW6224Q6EYY6U56H591"; - cmd.args(["interface", "--etherscan-api-key", api_key, weth_address]) - .assert_success() - .stdout_eq(str![[r#"// SPDX-License-Identifier: UNLICENSED + cmd.args([ + "interface", + "--etherscan-api-key", + &next_mainnet_etherscan_api_key(), + "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + ]) + .assert_success() + .stdout_eq(str![[r#" +// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; interface WETH9 { diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index f13e0f0218d00..64c5207690d7a 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -3,10 +3,10 @@ use alloy_consensus::{AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom, TxType}; use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, B256, I256, U256, U64}; use alloy_rpc_types::{ - AccessListItem, AnyTransactionReceipt, Block, BlockTransactions, Log, Transaction, - TransactionReceipt, + AccessListItem, AnyNetworkBlock, AnyTransactionReceipt, Block, BlockTransactions, Log, + Transaction, TransactionReceipt, }; -use alloy_serde::OtherFields; +use alloy_serde::{OtherFields, WithOtherFields}; use serde::Deserialize; /// length of the name column for pretty formatting `{:>20}{value}` @@ -267,7 +267,7 @@ transactionIndex: {}", } } -impl UIfmt for Block { +impl UIfmt for Block { fn pretty(&self) -> String { format!( " @@ -338,7 +338,7 @@ to {} transactionIndex {} type {} value {} -yParity {}{}", +yParity {}", self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), self.block_hash.pretty(), self.block_number.pretty(), @@ -356,7 +356,6 @@ yParity {}{}", self.transaction_type.unwrap(), self.value.pretty(), self.signature.map(|s| s.v).pretty(), - self.other.pretty() ), Some(2) => format!( " @@ -377,7 +376,7 @@ to {} transactionIndex {} type {} value {} -yParity {}{}", +yParity {}", self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), self.block_hash.pretty(), self.block_number.pretty(), @@ -396,7 +395,6 @@ yParity {}{}", self.transaction_type.unwrap(), self.value.pretty(), self.signature.map(|s| s.v).pretty(), - self.other.pretty() ), Some(3) => format!( " @@ -419,7 +417,7 @@ to {} transactionIndex {} type {} value {} -yParity {}{}", +yParity {}", self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), self.blob_versioned_hashes.as_deref().unwrap_or(&[]).pretty(), self.block_hash.pretty(), @@ -440,7 +438,6 @@ yParity {}{}", self.transaction_type.unwrap(), self.value.pretty(), self.signature.map(|s| s.v).pretty(), - self.other.pretty() ), Some(4) => format!( " @@ -462,7 +459,7 @@ to {} transactionIndex {} type {} value {} -yParity {}{}", +yParity {}", self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), self.authorization_list .as_ref() @@ -485,7 +482,6 @@ yParity {}{}", self.transaction_type.unwrap(), self.value.pretty(), self.signature.map(|s| s.v).pretty(), - self.other.pretty() ), _ => format!( " @@ -502,7 +498,7 @@ s {} to {} transactionIndex {} v {} -value {}{}", +value {}", self.block_hash.pretty(), self.block_number.pretty(), self.from.pretty(), @@ -517,12 +513,17 @@ value {}{}", self.transaction_index.pretty(), self.signature.map(|s| s.v).pretty(), self.value.pretty(), - self.other.pretty() ), } } } +impl UIfmt for WithOtherFields { + fn pretty(&self) -> String { + format!("{}{}", self.inner.pretty(), self.other.pretty()) + } +} + /// Various numerical ethereum types used for pretty printing #[derive(Clone, Debug, Deserialize)] #[serde(untagged)] @@ -570,17 +571,12 @@ pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option Some(transaction.transaction_index.pretty()), "v" => transaction.signature.map(|s| s.v.pretty()), "value" => Some(transaction.value.pretty()), - other => { - if let Some(value) = transaction.other.get(other) { - return Some(value.to_string().trim_matches('"').to_string()) - } - None - } + _ => None, } } /// Returns the `UiFmt::pretty()` formatted attribute of the given block -pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option { +pub fn get_pretty_block_attr(block: &AnyNetworkBlock, attr: &str) -> Option { match attr { "baseFeePerGas" | "base_fee_per_gas" => Some(block.header.base_fee_per_gas.pretty()), "difficulty" => Some(block.header.difficulty.pretty()), @@ -611,7 +607,7 @@ pub fn get_pretty_block_attr(block: &Block, attr: &str) -> Option { } } -fn pretty_block_basics(block: &Block) -> String { +fn pretty_block_basics(block: &Block) -> String { format!( " baseFeePerGas {} @@ -633,7 +629,7 @@ size {} stateRoot {} timestamp {} ({}) withdrawalsRoot {} -totalDifficulty {}{}", +totalDifficulty {}", block.header.base_fee_per_gas.pretty(), block.header.difficulty.pretty(), block.header.extra_data.pretty(), @@ -657,7 +653,6 @@ totalDifficulty {}{}", .to_rfc2822(), block.header.withdrawals_root.pretty(), block.header.total_difficulty.pretty(), - block.other.pretty() ) } @@ -711,7 +706,7 @@ mod tests { } "#; - let tx: Transaction = serde_json::from_str(s).unwrap(); + let tx: WithOtherFields = serde_json::from_str(s).unwrap(); assert_eq!(tx.pretty().trim(), r" blockHash 0x02b853cf50bc1c335b70790f93d5a390a35a166bea9c895e685cc866e4961cae @@ -1058,7 +1053,7 @@ value 0".to_string(); } ); - let block: Block = serde_json::from_value(json).unwrap(); + let block: AnyNetworkBlock = serde_json::from_value(json).unwrap(); assert_eq!(None, get_pretty_block_attr(&block, "")); assert_eq!(Some("7".to_string()), get_pretty_block_attr(&block, "baseFeePerGas")); diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index be3b0135e0f07..e98ac00c5d6c1 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -9,9 +9,7 @@ use crate::{ }; use alloy_genesis::GenesisAccount; use alloy_primitives::{keccak256, uint, Address, TxKind, B256, U256}; -use alloy_rpc_types::{ - Block, BlockNumberOrTag, BlockTransactions, Transaction, TransactionRequest, -}; +use alloy_rpc_types::{Block, BlockNumberOrTag, Transaction, TransactionRequest}; use alloy_serde::WithOtherFields; use eyre::Context; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; @@ -828,7 +826,7 @@ impl Backend { &self, id: LocalForkId, transaction: B256, - ) -> eyre::Result<(u64, Block)> { + ) -> eyre::Result<(u64, Block>)> { let fork = self.inner.get_fork_by_id(id)?; let tx = fork.db.db.get_transaction(transaction)?; @@ -839,12 +837,13 @@ impl Backend { // we need to subtract 1 here because we want the state before the transaction // was mined let fork_block = tx_block - 1; - Ok((fork_block, block)) + Ok((fork_block, block.inner)) } else { let block = fork.db.db.get_full_block(BlockNumberOrTag::Latest)?; - let number = - block.header.number.ok_or_else(|| BackendError::msg("missing block number"))?; + let number = block.header.number; + + let block = block.inner; Ok((number, block)) } @@ -869,33 +868,31 @@ impl Backend { let fork = self.inner.get_fork_by_id_mut(id)?; let full_block = fork.db.db.get_full_block(env.block.number.to::())?; - if let BlockTransactions::Full(txs) = full_block.transactions { - for tx in txs.into_iter() { - // System transactions such as on L2s don't contain any pricing info so we skip them - // otherwise this would cause reverts - if is_known_system_sender(tx.from) || - tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) - { - trace!(tx=?tx.hash, "skipping system transaction"); - continue; - } + for tx in full_block.transactions.clone().into_transactions() { + // System transactions such as on L2s don't contain any pricing info so we skip them + // otherwise this would cause reverts + if is_known_system_sender(tx.from) || + tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) + { + trace!(tx=?tx.hash, "skipping system transaction"); + continue; + } - if tx.hash == tx_hash { - // found the target transaction - return Ok(Some(tx)) - } - trace!(tx=?tx.hash, "committing transaction"); - - commit_transaction( - WithOtherFields::new(tx), - env.clone(), - journaled_state, - fork, - &fork_id, - &persistent_accounts, - &mut NoOpInspector, - )?; + if tx.hash == tx_hash { + // found the target transaction + return Ok(Some(tx.inner)) } + trace!(tx=?tx.hash, "committing transaction"); + + commit_transaction( + tx, + env.clone(), + journaled_state, + fork, + &fork_id, + &persistent_accounts, + &mut NoOpInspector, + )?; } Ok(None) @@ -1210,7 +1207,7 @@ impl DatabaseExt for Backend { // roll the fork to the transaction's block or latest if it's pending self.roll_fork(Some(id), fork_block, env, journaled_state)?; - update_env_block(env, fork_block, &block); + update_env_block(env, &block); // replay all transactions that came before let env = env.clone(); @@ -1240,10 +1237,10 @@ impl DatabaseExt for Backend { // This is a bit ambiguous because the user wants to transact an arbitrary transaction in the current context, but we're assuming the user wants to transact the transaction as it was mined. Usually this is used in a combination of a fork at the transaction's parent transaction in the block and then the transaction is transacted: // So we modify the env to match the transaction's block - let (fork_block, block) = + let (_fork_block, block) = self.get_block_number_and_block_for_transaction(id, transaction)?; let mut env = env.clone(); - update_env_block(&mut env, fork_block, &block); + update_env_block(&mut env, &block); let env = self.env_with_handler_cfg(env); let fork = self.inner.get_fork_by_id_mut(id)?; @@ -1895,14 +1892,14 @@ fn is_contract_in_state(journaled_state: &JournaledState, acc: Address) -> bool } /// Updates the env's block with the block's data -fn update_env_block(env: &mut Env, fork_block: u64, block: &Block) { +fn update_env_block(env: &mut Env, block: &Block) { env.block.timestamp = U256::from(block.header.timestamp); env.block.coinbase = block.header.miner; env.block.difficulty = block.header.difficulty; env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); env.block.gas_limit = U256::from(block.header.gas_limit); - env.block.number = U256::from(block.header.number.unwrap_or(fork_block)); + env.block.number = U256::from(block.header.number); } /// Executes the given transaction and commits state changes to the database _and_ the journaled @@ -1916,7 +1913,7 @@ fn commit_transaction>( persistent_accounts: &HashSet
, inspector: I, ) -> eyre::Result<()> { - configure_tx_env(&mut env.env, &tx); + configure_tx_env(&mut env.env, &tx.inner); let now = Instant::now(); let res = { diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index f60b99cb97087..b32fece5a0373 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -1,7 +1,10 @@ use crate::utils::apply_chain_and_block_specific_env_changes; use alloy_primitives::{Address, U256}; -use alloy_provider::{Network, Provider}; -use alloy_rpc_types::{Block, BlockNumberOrTag}; +use alloy_provider::{ + network::{BlockResponse, HeaderResponse}, + Network, Provider, +}; +use alloy_rpc_types::BlockNumberOrTag; use alloy_transport::Transport; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; @@ -18,7 +21,7 @@ pub async fn environment>( pin_block: Option, origin: Address, disable_block_gas_limit: bool, -) -> eyre::Result<(Env, Block)> { +) -> eyre::Result<(Env, N::BlockResponse)> { let block_number = if let Some(pin_block) = pin_block { pin_block } else { @@ -61,25 +64,25 @@ pub async fn environment>( let mut env = Env { cfg, block: BlockEnv { - number: U256::from(block.header.number.expect("block number not found")), - timestamp: U256::from(block.header.timestamp), - coinbase: block.header.miner, - difficulty: block.header.difficulty, - prevrandao: Some(block.header.mix_hash.unwrap_or_default()), - basefee: U256::from(block.header.base_fee_per_gas.unwrap_or_default()), - gas_limit: U256::from(block.header.gas_limit), + number: U256::from(block.header().number()), + timestamp: U256::from(block.header().timestamp()), + coinbase: block.header().coinbase(), + difficulty: block.header().difficulty(), + prevrandao: block.header().mix_hash(), + basefee: U256::from(block.header().base_fee_per_gas().unwrap_or_default()), + gas_limit: U256::from(block.header().gas_limit()), ..Default::default() }, tx: TxEnv { caller: origin, gas_price: U256::from(gas_price.unwrap_or(fork_gas_price)), chain_id: Some(override_chain_id.unwrap_or(rpc_chain_id)), - gas_limit: block.header.gas_limit as u64, + gas_limit: block.header().gas_limit() as u64, ..Default::default() }, }; - apply_chain_and_block_specific_env_changes(&mut env, &block); + apply_chain_and_block_specific_env_changes::(&mut env, &block); Ok((env, block)) } diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 001c654699685..a39b543ea254e 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -5,6 +5,7 @@ use super::CreateFork; use alloy_primitives::U256; +use alloy_provider::network::{BlockResponse, HeaderResponse}; use alloy_transport::layers::RetryBackoffService; use foundry_common::provider::{ runtime_transport::RuntimeTransport, ProviderBuilder, RetryProvider, @@ -524,7 +525,7 @@ async fn create_fork(mut fork: CreateFork) -> eyre::Result<(ForkId, CreatedFork, // We need to use the block number from the block because the env's number can be different on // some L2s (e.g. Arbitrum). - let number = block.header.number.unwrap_or(meta.block_env.number.to()); + let number = block.header().number(); // Determine the cache path if caching is enabled. let cache_path = if fork.enable_caching { diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index f9e674e09a26b..7a41d075641b4 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -2,7 +2,7 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; use alloy_provider::Provider; -use alloy_rpc_types::Block; +use alloy_rpc_types::AnyNetworkBlock; use eyre::WrapErr; use foundry_common::{provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS}; use foundry_config::{Chain, Config}; @@ -86,7 +86,7 @@ impl EvmOpts { pub async fn fork_evm_env( &self, fork_url: impl AsRef, - ) -> eyre::Result<(revm::primitives::Env, Block)> { + ) -> eyre::Result<(revm::primitives::Env, AnyNetworkBlock)> { let fork_url = fork_url.as_ref(); let provider = ProviderBuilder::new(fork_url) .compute_units_per_second(self.get_compute_units_per_second()) diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 21284e78035b4..27db37eaf1e20 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -2,7 +2,11 @@ pub use crate::ic::*; use crate::{constants::DEFAULT_CREATE2_DEPLOYER, precompiles::ALPHANET_P256, InspectorExt}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Selector, TxKind, U256}; -use alloy_rpc_types::{Block, Transaction}; +use alloy_provider::{ + network::{BlockResponse, HeaderResponse}, + Network, +}; +use alloy_rpc_types::Transaction; use foundry_config::NamedChain; use revm::{ db::WrapDatabaseRef, @@ -24,9 +28,12 @@ pub use revm::primitives::EvmState as StateChangeset; /// - applies chain specifics: on Arbitrum `block.number` is the L1 block /// /// Should be called with proper chain id (retrieved from provider if not provided). -pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::Env, block: &Block) { +pub fn apply_chain_and_block_specific_env_changes( + env: &mut revm::primitives::Env, + block: &N::BlockResponse, +) { if let Ok(chain) = NamedChain::try_from(env.cfg.chain_id) { - let block_number = block.header.number.unwrap_or_default(); + let block_number = block.header().number(); match chain { NamedChain::Mainnet => { @@ -43,10 +50,14 @@ pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::En NamedChain::ArbitrumTestnet => { // on arbitrum `block.number` is the L1 block which is included in the // `l1BlockNumber` field - if let Some(l1_block_number) = block.other.get("l1BlockNumber").cloned() { - if let Ok(l1_block_number) = serde_json::from_value::(l1_block_number) { - env.block.number = l1_block_number; - } + if let Some(l1_block_number) = block + .other_fields() + .and_then(|other| other.get("l1BlockNumber").cloned()) + .and_then(|l1_block_number| { + serde_json::from_value::(l1_block_number).ok() + }) + { + env.block.number = l1_block_number; } } _ => {} @@ -54,7 +65,7 @@ pub fn apply_chain_and_block_specific_env_changes(env: &mut revm::primitives::En } // if difficulty is `0` we assume it's past merge - if block.header.difficulty.is_zero() { + if block.header().difficulty().is_zero() { env.block.difficulty = env.block.prevrandao.unwrap_or_default().into(); } } diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 4af5869646538..98ef95d40e2d1 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -612,7 +612,7 @@ mod tests { use super::*; use alloy_primitives::hex; use foundry_compilers::Artifact; - use foundry_test_utils::rpc::next_etherscan_api_key; + use foundry_test_utils::rpc::next_mainnet_etherscan_api_key; use std::collections::BTreeMap; fn assert_successful_compilation(root: &PathBuf) -> ProjectCompileOutput { @@ -690,7 +690,7 @@ mod tests { // create folder if not exists std::fs::create_dir_all(&data_folder).unwrap(); // create metadata.json and creation_data.json - let client = Client::new(Chain::mainnet(), next_etherscan_api_key()).unwrap(); + let client = Client::new(Chain::mainnet(), next_mainnet_etherscan_api_key()).unwrap(); let meta = client.contract_source_code(address).await.unwrap(); // dump json let json = serde_json::to_string_pretty(&meta).unwrap(); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 1a8d2cb7e08c9..4e860bc649003 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -7,7 +7,7 @@ use foundry_config::{ }; use foundry_test_utils::{ foundry_compilers::PathStyle, - rpc::next_etherscan_api_key, + rpc::next_mainnet_etherscan_api_key, util::{pretty_err, read_string, OutputExt, TestCommand}, }; use semver::Version; @@ -538,7 +538,7 @@ forgetest!(can_clone, |prj, cmd| { cmd.args([ "clone", "--etherscan-api-key", - next_etherscan_api_key().as_str(), + next_mainnet_etherscan_api_key().as_str(), "0x044b75f554b886A065b9567891e45c79542d7357", ]) .arg(prj.root()) @@ -567,7 +567,7 @@ forgetest!(can_clone_quiet, |prj, cmd| { cmd.args([ "clone", "--etherscan-api-key", - next_etherscan_api_key().as_str(), + next_mainnet_etherscan_api_key().as_str(), "--quiet", "0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec", ]) @@ -585,7 +585,7 @@ forgetest!(can_clone_no_remappings_txt, |prj, cmd| { cmd.args([ "clone", "--etherscan-api-key", - next_etherscan_api_key().as_str(), + next_mainnet_etherscan_api_key().as_str(), "--no-remappings-txt", "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", ]) @@ -620,7 +620,7 @@ forgetest!(can_clone_keep_directory_structure, |prj, cmd| { .args([ "clone", "--etherscan-api-key", - next_etherscan_api_key().as_str(), + next_mainnet_etherscan_api_key().as_str(), "--keep-directory-structure", "0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf", ]) diff --git a/crates/forge/tests/cli/verify_bytecode.rs b/crates/forge/tests/cli/verify_bytecode.rs index 2b28570e75b33..7e615b5659ddc 100644 --- a/crates/forge/tests/cli/verify_bytecode.rs +++ b/crates/forge/tests/cli/verify_bytecode.rs @@ -2,7 +2,7 @@ use foundry_compilers::artifacts::{BytecodeHash, EvmVersion}; use foundry_config::Config; use foundry_test_utils::{ forgetest_async, - rpc::{next_etherscan_api_key, next_http_archive_rpc_endpoint}, + rpc::{next_http_archive_rpc_endpoint, next_mainnet_etherscan_api_key}, util::OutputExt, TestCommand, TestProject, }; @@ -19,7 +19,7 @@ fn test_verify_bytecode( verifier_url: &str, expected_matches: (&str, &str), ) { - let etherscan_key = next_etherscan_api_key(); + let etherscan_key = next_mainnet_etherscan_api_key(); let rpc_url = next_http_archive_rpc_endpoint(); // fetch and flatten source code @@ -73,7 +73,7 @@ fn test_verify_bytecode_with_ignore( ignore: &str, chain: &str, ) { - let etherscan_key = next_etherscan_api_key(); + let etherscan_key = next_mainnet_etherscan_api_key(); let rpc_url = next_http_archive_rpc_endpoint(); // fetch and flatten source code diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index ca0f60d0d64c2..6e5e900ce33c3 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -32,6 +32,10 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } rand.workspace = true snapbox = { version = "0.6.9", features = ["json", "regex"] } +[dev-dependencies] +tokio.workspace = true +foundry-block-explorers.workspace = true + [features] # feature for integration tests that test external projects external-integration-tests = [] diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 96415af3fb735..305c8a1c87bd3 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -51,9 +51,7 @@ static ALCHEMY_KEYS: LazyLock> = LazyLock::new(|| { "UVatYU2Ax0rX6bDiqddeTRDdcCxzdpoE", "bVjX9v-FpmUhf5R_oHIgwJx2kXvYPRbx", ]; - keys.shuffle(&mut rand::thread_rng()); - keys }); @@ -69,19 +67,18 @@ static ETHERSCAN_MAINNET_KEYS: LazyLock> = LazyLock::new(|| { "C7I2G4JTA5EPYS42Z8IZFEIMQNI5GXIJEV", "A15KZUMZXXCK1P25Y1VP1WGIVBBHIZDS74", "3IA6ASNQXN8WKN7PNFX7T72S9YG56X9FPG", + "ZUB97R31KSYX7NYVW6224Q6EYY6U56H591", + // Optimism + // "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46", ]; - keys.shuffle(&mut rand::thread_rng()); - keys }); -/// counts how many times a rpc endpoint was requested for _mainnet_ -static NEXT_RPC_ENDPOINT: AtomicUsize = AtomicUsize::new(0); - -// returns the current value of the atomic counter and increments it +/// Returns the next index to use. fn next() -> usize { - NEXT_RPC_ENDPOINT.fetch_add(1, Ordering::SeqCst) + static NEXT_INDEX: AtomicUsize = AtomicUsize::new(0); + NEXT_INDEX.fetch_add(1, Ordering::SeqCst) } fn num_keys() -> usize { @@ -125,7 +122,7 @@ pub fn next_ws_archive_rpc_endpoint() -> String { } /// Returns the next etherscan api key -pub fn next_etherscan_api_key() -> String { +pub fn next_mainnet_etherscan_api_key() -> String { let idx = next() % ETHERSCAN_MAINNET_KEYS.len(); ETHERSCAN_MAINNET_KEYS[idx].to_string() } @@ -178,15 +175,48 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { #[cfg(test)] mod tests { use super::*; - use std::collections::HashSet; - - #[test] - #[ignore] - fn can_rotate_unique() { - let mut keys = HashSet::new(); - for _ in 0..100 { - keys.insert(next_http_rpc_endpoint()); + use alloy_primitives::address; + use foundry_config::Chain; + + #[tokio::test] + #[ignore = "run manually"] + async fn test_etherscan_keys() { + let address = address!("dAC17F958D2ee523a2206206994597C13D831ec7"); + let mut first_abi = None; + let mut failed = Vec::new(); + for (i, &key) in ETHERSCAN_MAINNET_KEYS.iter().enumerate() { + eprintln!("trying key {i} ({key})"); + + let client = foundry_block_explorers::Client::builder() + .chain(Chain::mainnet()) + .unwrap() + .with_api_key(key) + .build() + .unwrap(); + + let mut fail = |e: &str| { + eprintln!("key {i} ({key}) failed: {e}"); + failed.push(key); + }; + + let abi = match client.contract_abi(address).await { + Ok(abi) => abi, + Err(e) => { + fail(&e.to_string()); + continue; + } + }; + + if let Some(first_abi) = &first_abi { + if abi != *first_abi { + fail("abi mismatch"); + } + } else { + first_abi = Some(abi); + } + } + if !failed.is_empty() { + panic!("failed keys: {failed:#?}"); } - assert_eq!(keys.len(), num_keys()); } } diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 8fffd84d6a65b..e08cf3a5a0281 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -459,7 +459,7 @@ impl VerifyBytecodeArgs { transaction.input = Bytes::from(local_bytecode_vec); } - configure_tx_env(&mut env, &transaction); + configure_tx_env(&mut env, &transaction.inner); let fork_address = crate::utils::deploy_contract( &mut executor, diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 1b7c7fadacadc..aaf8a0e016b75 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -2,7 +2,7 @@ use crate::{bytecode::VerifyBytecodeArgs, types::VerificationType}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Address, Bytes, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{Block, BlockId, Transaction}; +use alloy_rpc_types::{AnyNetworkBlock, BlockId, Transaction}; use clap::ValueEnum; use eyre::{OptionExt, Result}; use foundry_block_explorers::{ @@ -346,7 +346,7 @@ pub async fn get_tracing_executor( Ok((env, executor)) } -pub fn configure_env_block(env: &mut Env, block: &Block) { +pub fn configure_env_block(env: &mut Env, block: &AnyNetworkBlock) { env.block.timestamp = U256::from(block.header.timestamp); env.block.coinbase = block.header.miner; env.block.difficulty = block.header.difficulty; From 872e2f3fa622480e863576db06fa6d67a6ba87ce Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 6 Sep 2024 20:36:28 +0530 Subject: [PATCH 1423/1963] fix(`anvil`): reset from fork to another fork (#8768) fix(anvil): reset from fork to another fork --- crates/anvil/src/config.rs | 1 - crates/anvil/src/eth/backend/mem/mod.rs | 64 +++++++++++++++---------- crates/anvil/tests/it/fork.rs | 34 ++++++++++++- 3 files changed, 72 insertions(+), 27 deletions(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 3145ee1b2af83..cafdf1695a3bc 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1075,7 +1075,6 @@ impl NodeConfig { let provider = Arc::new( ProviderBuilder::new(ð_rpc_url) .timeout(self.fork_request_timeout) - // .timeout_retry(self.fork_request_retries) .initial_backoff(self.fork_retry_backoff.as_millis() as u64) .compute_units_per_second(self.compute_units_per_second) .max_retry(self.fork_request_retries) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 86e8ad039c491..dd10c672fc377 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -30,7 +30,7 @@ use crate::{ storage::{BlockchainStorage, InMemoryBlockStates, MinedBlockOutcome}, }, revm::{db::DatabaseRef, primitives::AccountInfo}, - NodeConfig, PrecompileFactory, + ForkChoice, NodeConfig, PrecompileFactory, }; use alloy_consensus::{Account, Header, Receipt, ReceiptWithBloom}; use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK; @@ -427,37 +427,51 @@ impl Backend { .ok_or(BlockchainError::BlockNotFound)?; // update all settings related to the forked block { - let mut env = self.env.write(); - env.cfg.chain_id = fork.chain_id(); - - env.block = BlockEnv { - number: U256::from(fork_block_number), - timestamp: U256::from(fork_block.header.timestamp), - gas_limit: U256::from(fork_block.header.gas_limit), - difficulty: fork_block.header.difficulty, - prevrandao: Some(fork_block.header.mix_hash.unwrap_or_default()), - // Keep previous `coinbase` and `basefee` value - coinbase: env.block.coinbase, - basefee: env.block.basefee, - ..env.block.clone() - }; + if let Some(fork_url) = forking.json_rpc_url { + // Set the fork block number + let mut node_config = self.node_config.write().await; + node_config.fork_choice = Some(ForkChoice::Block(fork_block_number)); - self.time.reset(env.block.timestamp.to::()); + let mut env = self.env.read().clone(); + let (forked_db, client_fork_config) = + node_config.setup_fork_db_config(fork_url, &mut env, &self.fees).await; - // this is the base fee of the current block, but we need the base fee of - // the next block - let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( - fork_block.header.gas_used, - fork_block.header.gas_limit, - fork_block.header.base_fee_per_gas.unwrap_or_default(), - ); + *self.db.write().await = Box::new(forked_db); + let fork = ClientFork::new(client_fork_config, Arc::clone(&self.db)); + *self.fork.write() = Some(fork); + *self.env.write() = env; + } else { + let mut env = self.env.write(); + env.cfg.chain_id = fork.chain_id(); + env.block = BlockEnv { + number: U256::from(fork_block_number), + timestamp: U256::from(fork_block.header.timestamp), + gas_limit: U256::from(fork_block.header.gas_limit), + difficulty: fork_block.header.difficulty, + prevrandao: Some(fork_block.header.mix_hash.unwrap_or_default()), + // Keep previous `coinbase` and `basefee` value + coinbase: env.block.coinbase, + basefee: env.block.basefee, + ..env.block.clone() + }; - self.fees.set_base_fee(next_block_base_fee); + // this is the base fee of the current block, but we need the base fee of + // the next block + let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( + fork_block.header.gas_used, + fork_block.header.gas_limit, + fork_block.header.base_fee_per_gas.unwrap_or_default(), + ); + + self.fees.set_base_fee(next_block_base_fee); + } + + // reset the time to the timestamp of the forked block + self.time.reset(fork_block.header.timestamp); // also reset the total difficulty self.blockchain.storage.write().total_difficulty = fork.total_difficulty(); } - // reset storage *self.blockchain.storage.write() = BlockchainStorage::forked( fork.block_number(), diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 672d3b72fdf36..d8465ec5cacee 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -4,6 +4,7 @@ use crate::{ abi::{Greeter, ERC721}, utils::{http_provider, http_provider_with_signer}, }; +use alloy_chains::NamedChain; use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder}; use alloy_primitives::{address, b256, bytes, Address, Bytes, TxHash, TxKind, U256}; use alloy_provider::Provider; @@ -17,7 +18,7 @@ use alloy_signer_local::PrivateKeySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use foundry_common::provider::get_http_provider; use foundry_config::Config; -use foundry_test_utils::rpc::{self, next_http_rpc_endpoint}; +use foundry_test_utils::rpc::{self, next_http_rpc_endpoint, next_rpc_endpoint}; use futures::StreamExt; use std::{sync::Arc, thread::sleep, time::Duration}; @@ -476,6 +477,37 @@ async fn can_reset_properly() { assert!(fork_tx_provider.get_transaction_by_hash(tx.transaction_hash).await.unwrap().is_none()) } +// Ref: +#[tokio::test(flavor = "multi_thread")] +async fn can_reset_fork_to_new_fork() { + let eth_rpc_url = next_rpc_endpoint(NamedChain::Mainnet); + let (api, handle) = spawn(NodeConfig::test().with_eth_rpc_url(Some(eth_rpc_url))).await; + let provider = handle.http_provider(); + + let op = address!("C0d3c0d3c0D3c0D3C0d3C0D3C0D3c0d3c0d30007"); // L2CrossDomainMessenger - Dead on mainnet. + + let tx = TransactionRequest::default().with_to(op).with_input("0x54fd4d50"); + + let tx = WithOtherFields::new(tx); + + let mainnet_call_output = provider.call(&tx).await.unwrap(); + + assert_eq!(mainnet_call_output, Bytes::new()); // 0x + + let optimism = next_rpc_endpoint(NamedChain::Optimism); + + api.anvil_reset(Some(Forking { + json_rpc_url: Some(optimism.to_string()), + block_number: Some(124659890), + })) + .await + .unwrap(); + + let code = provider.get_code_at(op).await.unwrap(); + + assert_ne!(code, Bytes::new()); +} + #[tokio::test(flavor = "multi_thread")] async fn test_fork_timestamp() { let start = std::time::Instant::now(); From 8a51b89f838e0a17afb6443d8cd008130d0cd47a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 7 Sep 2024 07:02:57 +0300 Subject: [PATCH 1424/1963] fix(cheatcodes): do not account already matched emit events when fill or check (#8824) * fix(6643): do not account already matched events when fill or check * Move test as repro test --- crates/cheatcodes/src/test/expect.rs | 49 ++++++++++++------- crates/forge/tests/it/repros.rs | 3 ++ testdata/default/repros/Issue6643.t.sol | 65 +++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 18 deletions(-) create mode 100644 testdata/default/repros/Issue6643.t.sol diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 83899041515dd..df9c480e3aa4d 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -464,14 +464,16 @@ fn expect_emit( address: Option
, anonymous: bool, ) -> Result { - state.expected_emits.push_back(ExpectedEmit { - depth, - checks, - address, - found: false, - log: None, - anonymous, - }); + let expected_emit = ExpectedEmit { depth, checks, address, found: false, log: None, anonymous }; + if let Some(found_emit_pos) = state.expected_emits.iter().position(|emit| emit.found) { + // The order of emits already found (back of queue) should not be modified, hence push any + // new emit before first found emit. + state.expected_emits.insert(found_emit_pos, expected_emit); + } else { + // If no expected emits then push new one at the back of queue. + state.expected_emits.push_back(expected_emit); + } + Ok(Default::default()) } @@ -494,15 +496,25 @@ pub(crate) fn handle_expect_emit( return } - // If there's anything to fill, we need to pop back. - // Otherwise, if there are any events that are unmatched, we try to match to match them - // in the order declared, so we start popping from the front (like a queue). - let mut event_to_fill_or_check = - if state.expected_emits.iter().any(|expected| expected.log.is_none()) { - state.expected_emits.pop_back() - } else { - state.expected_emits.pop_front() - } + let should_fill_logs = state.expected_emits.iter().any(|expected| expected.log.is_none()); + let index_to_fill_or_check = if should_fill_logs { + // If there's anything to fill, we start with the last event to match in the queue + // (without taking into account events already matched). + state + .expected_emits + .iter() + .position(|emit| emit.found) + .unwrap_or(state.expected_emits.len()) + .saturating_sub(1) + } else { + // Otherwise, if all expected logs are filled, we start to check any unmatched event + // in the declared order, so we start from the front (like a queue). + 0 + }; + + let mut event_to_fill_or_check = state + .expected_emits + .remove(index_to_fill_or_check) .expect("we should have an emit to fill or check"); let Some(expected) = &event_to_fill_or_check.log else { @@ -510,7 +522,8 @@ pub(crate) fn handle_expect_emit( // filled. if event_to_fill_or_check.anonymous || log.topics().first().is_some() { event_to_fill_or_check.log = Some(log.data.clone()); - state.expected_emits.push_back(event_to_fill_or_check); + // If we only filled the expected log then we put it back at the same position. + state.expected_emits.insert(index_to_fill_or_check, event_to_fill_or_check); } else { interpreter.instruction_result = InstructionResult::Revert; interpreter.next_action = InterpreterAction::Return { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 3cce4bed203e5..73310f0117607 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -378,3 +378,6 @@ test_repro!(8383, false, None, |res| { // https://github.com/foundry-rs/foundry/issues/1543 test_repro!(1543); + +// https://github.com/foundry-rs/foundry/issues/6643 +test_repro!(6643); diff --git a/testdata/default/repros/Issue6643.t.sol b/testdata/default/repros/Issue6643.t.sol new file mode 100644 index 0000000000000..36b684c133dc1 --- /dev/null +++ b/testdata/default/repros/Issue6643.t.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Counter { + event TestEvent(uint256 n); + event AnotherTestEvent(uint256 n); + + constructor() { + emit TestEvent(1); + } + + function f() external { + emit TestEvent(2); + } + + function g() external { + emit AnotherTestEvent(1); + this.f(); + emit AnotherTestEvent(2); + } +} + +// https://github.com/foundry-rs/foundry/issues/6643 +contract Issue6643Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Counter public counter; + + event TestEvent(uint256 n); + event AnotherTestEvent(uint256 n); + + function setUp() public { + counter = new Counter(); + } + + function test_Bug1() public { + // part1 + vm.expectEmit(); + emit TestEvent(1); + new Counter(); + // part2 + vm.expectEmit(); + emit TestEvent(2); + counter.f(); + // part3 + vm.expectEmit(); + emit AnotherTestEvent(1); + vm.expectEmit(); + emit TestEvent(2); + vm.expectEmit(); + emit AnotherTestEvent(2); + counter.g(); + } + + function test_Bug2() public { + vm.expectEmit(); + emit TestEvent(1); + new Counter(); + vm.expectEmit(); + emit TestEvent(1); + new Counter(); + } +} From 27d008f2e5c4e383bfad37e7970aa5895ea22bdf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 7 Sep 2024 13:23:58 +0200 Subject: [PATCH 1425/1963] ci: update docker build (#8829) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index aba0b3986d32c..cbdf08b258464 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ COPY . . RUN git update-index --force-write-index RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/root/.cargo/git --mount=type=cache,target=/opt/foundry/target \ - source $HOME/.profile && cargo build --release --features cast/aws-kms,forge/aws-kms \ + source $HOME/.profile && cargo build --release --features foundry-cast/aws-kms,forge/aws-kms \ && mkdir out \ && mv target/release/forge out/forge \ && mv target/release/cast out/cast \ From 4d377409faf5e681f88b5b3a2de640c9f9631ae9 Mon Sep 17 00:00:00 2001 From: Sabnock <24715302+Sabnock01@users.noreply.github.com> Date: Sat, 7 Sep 2024 08:33:15 -0500 Subject: [PATCH 1426/1963] feat: add `codehash` and `storage-root` to `cast` (#8828) * feat: add codehash and storage-root to cast * fix: use eth_getProof * fix: nits --- crates/cast/bin/args.rs | 42 ++++++++++++++++++++++++++ crates/cast/bin/main.rs | 12 ++++++++ crates/cast/src/lib.rs | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 7274585059684..fdb6a113354a2 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -831,6 +831,48 @@ pub enum CastSubcommand { rpc: RpcOpts, }, + /// Get the codehash for an account. + #[command()] + Codehash { + /// The block height to query at. + /// + /// Can also be the tags earliest, finalized, safe, latest, or pending. + #[arg(long, short = 'B')] + block: Option, + + /// The address to get the codehash for. + #[arg(value_parser = NameOrAddress::from_str)] + who: NameOrAddress, + + /// The storage slot numbers (hex or decimal). + #[arg(value_parser = parse_slot)] + slots: Vec, + + #[command(flatten)] + rpc: RpcOpts, + }, + + /// Get the storage root for an account. + #[command(visible_alias = "sr")] + StorageRoot { + /// The block height to query at. + /// + /// Can also be the tags earliest, finalized, safe, latest, or pending. + #[arg(long, short = 'B')] + block: Option, + + /// The address to get the storage root for. + #[arg(value_parser = NameOrAddress::from_str)] + who: NameOrAddress, + + /// The storage slot numbers (hex or decimal). + #[arg(value_parser = parse_slot)] + slots: Vec, + + #[command(flatten)] + rpc: RpcOpts, + }, + /// Get the source code of a contract from Etherscan. #[command(visible_aliases = &["et", "src"])] EtherscanSource { diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 28009dbdcfccf..27a052fe6ccc1 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -362,6 +362,18 @@ async fn main_args(args: CastArgs) -> Result<()> { let who = who.resolve(&provider).await?; println!("{}", Cast::new(provider).nonce(who, block).await?); } + CastSubcommand::Codehash { block, who, slots, rpc } => { + let config = Config::from(&rpc); + let provider = utils::get_provider(&config)?; + let who = who.resolve(&provider).await?; + println!("{}", Cast::new(provider).codehash(who, slots, block).await?); + } + CastSubcommand::StorageRoot { block, who, slots, rpc } => { + let config = Config::from(&rpc); + let provider = utils::get_provider(&config)?; + let who = who.resolve(&provider).await?; + println!("{}", Cast::new(provider).storage_root(who, slots, block).await?); + } CastSubcommand::Proof { address, slots, rpc, block } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 03355213de572..73ab5b28bda19 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -494,6 +494,72 @@ where Ok(self.provider.get_transaction_count(who).block_id(block.unwrap_or_default()).await?) } + /// #Example + /// + /// ``` + /// use alloy_primitives::{Address, FixedBytes}; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; + /// use cast::Cast; + /// use std::str::FromStr; + /// + /// # async fn foo() -> eyre::Result<()> { + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; + /// let cast = Cast::new(provider); + /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; + /// let slots = vec![FixedBytes::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")?]; + /// let codehash = cast.codehash(addr, slots, None).await?; + /// println!("{}", codehash); + /// # Ok(()) + /// # } + pub async fn codehash( + &self, + who: Address, + slots: Vec, + block: Option, + ) -> Result { + Ok(self + .provider + .get_proof(who, slots) + .block_id(block.unwrap_or_default()) + .await? + .code_hash + .to_string()) + } + + /// #Example + /// + /// ``` + /// use alloy_primitives::{Address, FixedBytes}; + /// use alloy_provider::{network::AnyNetwork, ProviderBuilder, RootProvider}; + /// use cast::Cast; + /// use std::str::FromStr; + /// + /// # async fn foo() -> eyre::Result<()> { + /// let provider = + /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; + /// let cast = Cast::new(provider); + /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; + /// let slots = vec![FixedBytes::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")?]; + /// let storage_root = cast.storage_root(addr, slots, None).await?; + /// println!("{}", storage_root); + /// # Ok(()) + /// # } + pub async fn storage_root( + &self, + who: Address, + slots: Vec, + block: Option, + ) -> Result { + Ok(self + .provider + .get_proof(who, slots) + .block_id(block.unwrap_or_default()) + .await? + .storage_hash + .to_string()) + } + /// # Example /// /// ``` From 96105b4d240681c336e063eac0e250cc51a84414 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Sep 2024 03:11:09 +0200 Subject: [PATCH 1427/1963] chore(deps): weekly `cargo update` (#8832) --- Cargo.lock | 98 +++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6793346b546e3..6172e6ea112c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb07629a5d0645d29f68d2fb6f4d0cf15c89ec0965be915f303967180929743f" +checksum = "2b4f201b0ac8f81315fbdc55269965a8ddadbc04ab47fa65a1a468f9a40f7a5f" dependencies = [ "num_enum", "serde", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1c7d5315d44b5e00ce9c6b72dc88aa8f3e49d82a742be85d6a755ef0aa28c5" +checksum = "b03f58cfae4d41b624effe1f11624ee40499449174b20a6d6505fd72ef0d547d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -194,9 +194,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8129590e6f5aa3aeb33138f0faaa4cb763e4f1ca072ab98ce880a1998dca84d3" +checksum = "a28ecae8b5315daecd0075084eb47f4374b3037777346ca52fc8d9c327693f02" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -249,9 +249,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d1d1bdfba287209ee749a985230685c2ff8bdabe5fed6f699f72f22bb72c95" +checksum = "ccb865df835f851b367ae439d6c82b117ded971628c8888b24fed411a290e38a" dependencies = [ "alloy-rlp", "arbitrary", @@ -574,9 +574,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f6a68cb762b6feb50cff1a4f81831b8725aa10f5a1afc26c209b7df442fffe" +checksum = "e2dc5201ca0018afb7a3e0cd8bd15f7ca6aca924333b5f3bb87463b41d0c4ef2" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -588,9 +588,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e3d38952d1f54a541c00b1b28582cd112ac02e6302437bd3dead32367a87393" +checksum = "155f63dc6945885aa4532601800201fddfaa3b20901fda8e8c2570327242fe0e" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -607,9 +607,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2821c0ce9b217b17c9a52c8dc0dddadb391d0eb7593707da9f12df786510594b" +checksum = "847700aa9cb59d3c7b290b2d05976cd8d76b64d73bb63116a9533132d995586b" dependencies = [ "alloy-json-abi", "const-hex", @@ -624,9 +624,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f040419382164c509aa60f281e45c6fa295cf88ccffe686bd71d65780bc8d053" +checksum = "3a6b5d462d4520bd9ed70d8364c6280aeff13baa46ea26be1ddd33538dbbe6ac" dependencies = [ "serde", "winnow", @@ -634,9 +634,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53be2dde91d22bc1e398e26bd42bdac441705f205a4cbaf4f3abb9273867ed39" +checksum = "83665e5607725a7a1aab3cb0dea708f4a05e70776954ec7f0a9461439175c957" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -935,9 +935,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "arbitrary" @@ -1886,9 +1886,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.16" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "shlex", ] @@ -2294,9 +2294,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -5144,9 +5144,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is-terminal" @@ -6123,9 +6123,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" @@ -6231,9 +6231,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea" dependencies = [ "memchr", "thiserror", @@ -6242,9 +6242,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" +checksum = "664d22978e2815783adbdd2c588b455b1bd625299ce36b2a99881ac9627e6d8d" dependencies = [ "pest", "pest_generator", @@ -6252,9 +6252,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" +checksum = "a2d5487022d5d33f4c30d91c22afa240ce2a644e87fe08caad974d4eab6badbe" dependencies = [ "pest", "pest_meta", @@ -6265,9 +6265,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" +checksum = "0091754bbd0ea592c4deb3a122ce8ecbb0753b738aa82bc055fcc2eccc8d8174" dependencies = [ "once_cell", "pest", @@ -6592,9 +6592,9 @@ dependencies = [ [[package]] name = "proc-macro-error2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74cdd32837fa2e86ec09c8266e5aad92400ac934c6dbca83d54673b298db3e45" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" dependencies = [ "proc-macro-error-attr2", "proc-macro2", @@ -7521,11 +7521,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -7608,9 +7608,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" dependencies = [ "rand", "secp256k1-sys", @@ -7696,18 +7696,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -8218,9 +8218,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03133179a4b51eabc6f1aea6951626a766b8aa3af68b12d150f88095914cb447" +checksum = "f1e1355d44af21638c8e05d45097db6cb5ec2aa3e970c51cb2901605cf3344fa" dependencies = [ "paste", "proc-macro2", From 0079a1146b79a4aeda58b0258215bedb1f92700b Mon Sep 17 00:00:00 2001 From: soham Date: Mon, 9 Sep 2024 20:34:29 +0530 Subject: [PATCH 1428/1963] Support for Flamegraph (#8640) * first pass bump revm-inspectors * fix: bug while processing call node * handle contract creation in flamegraph * store in tmp file and open file * enable decode_internal * remove pub from internal method * use temp_dir * ref: combine fst code into single file * remove redundant option * fix: handle non-empty step_exits * some docs * revert revm-inspectors version change * switch to flamegraph and flamechart boolean flags * Update crates/evm/traces/src/folded_stack_trace.rs Co-authored-by: Arsenii Kulikov * Update crates/evm/traces/src/folded_stack_trace.rs Co-authored-by: Arsenii Kulikov * save to cache dir and gracefully handle opener outcome * disable default features in inferno * fixes * license --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: Arsenii Kulikov --- Cargo.lock | 44 ++- crates/evm/traces/src/folded_stack_trace.rs | 301 ++++++++++++++++++++ crates/evm/traces/src/lib.rs | 2 + crates/forge/Cargo.toml | 1 + crates/forge/bin/cmd/test/mod.rs | 101 +++++-- crates/forge/src/result.rs | 12 + deny.toml | 1 + 7 files changed, 443 insertions(+), 19 deletions(-) create mode 100644 crates/evm/traces/src/folded_stack_trace.rs diff --git a/Cargo.lock b/Cargo.lock index 6172e6ea112c2..011a7af0fb62a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2837,7 +2837,7 @@ dependencies = [ "console_error_panic_hook", "pest", "pest_derive", - "quick-xml", + "quick-xml 0.18.1", "wasm-bindgen", ] @@ -3264,6 +3264,7 @@ dependencies = [ "humantime-serde", "hyper 1.4.1", "indicatif", + "inferno", "itertools 0.13.0", "mockall", "opener", @@ -5073,6 +5074,23 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "inferno" +version = "0.11.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" +dependencies = [ + "ahash", + "is-terminal", + "itoa", + "log", + "num-format", + "once_cell", + "quick-xml 0.26.0", + "rgb", + "str_stack", +] + [[package]] name = "inlinable_string" version = "0.1.15" @@ -6771,6 +6789,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" +dependencies = [ + "memchr", +] + [[package]] name = "quinn" version = "0.11.5" @@ -7144,6 +7171,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "rgb" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f86ae463694029097b846d8f99fd5536740602ae00022c0c50c5600720b2f71" +dependencies = [ + "bytemuck", +] + [[package]] name = "ring" version = "0.17.8" @@ -8088,6 +8124,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "str_stack" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" + [[package]] name = "string_cache" version = "0.8.7" diff --git a/crates/evm/traces/src/folded_stack_trace.rs b/crates/evm/traces/src/folded_stack_trace.rs new file mode 100644 index 0000000000000..de76f8e804085 --- /dev/null +++ b/crates/evm/traces/src/folded_stack_trace.rs @@ -0,0 +1,301 @@ +use alloy_primitives::hex::ToHexExt; +use revm_inspectors::tracing::{ + types::{CallTraceNode, CallTraceStep, DecodedTraceStep, TraceMemberOrder}, + CallTraceArena, +}; + +/// Builds a folded stack trace from a call trace arena. +pub fn build(arena: &CallTraceArena) -> Vec { + let mut fst = EvmFoldedStackTraceBuilder::default(); + fst.process_call_node(arena.nodes(), 0); + fst.build() +} + +/// Wrapper for building a folded stack trace using EVM call trace node. +#[derive(Default)] +pub struct EvmFoldedStackTraceBuilder { + /// Raw folded stack trace builder. + fst: FoldedStackTraceBuilder, +} + +impl EvmFoldedStackTraceBuilder { + /// Returns the folded stack trace. + pub fn build(self) -> Vec { + self.fst.build() + } + + /// Creates an entry for a EVM CALL in the folded stack trace. This method recursively processes + /// all the children nodes of the call node and at the end it exits. + pub fn process_call_node(&mut self, nodes: &[CallTraceNode], idx: usize) { + let node = &nodes[idx]; + + let func_name = if node.trace.kind.is_any_create() { + let default_contract_name = "Contract".to_string(); + let contract_name = node.trace.decoded.label.as_ref().unwrap_or(&default_contract_name); + format!("new {contract_name}") + } else { + let selector = node + .selector() + .map(|selector| selector.encode_hex_with_prefix()) + .unwrap_or("fallback".to_string()); + let signature = + node.trace.decoded.call_data.as_ref().map(|dc| &dc.signature).unwrap_or(&selector); + + if let Some(label) = &node.trace.decoded.label { + format!("{label}.{signature}") + } else { + signature.clone() + } + }; + + self.fst.enter(func_name, node.trace.gas_used as i64); + + // Track internal function step exits to do in this call context. + let mut step_exits = vec![]; + + // Process children nodes. + for order in &node.ordering { + match order { + TraceMemberOrder::Call(child_idx) => { + let child_node_idx = node.children[*child_idx]; + self.process_call_node(nodes, child_node_idx); + } + TraceMemberOrder::Step(step_idx) => { + self.exit_previous_steps(&mut step_exits, *step_idx); + self.process_step(&node.trace.steps, *step_idx, &mut step_exits) + } + TraceMemberOrder::Log(_) => {} + } + } + + // Exit pending internal function calls if any. + for _ in 0..step_exits.len() { + self.fst.exit(); + } + + // Exit from this call context in the folded stack trace. + self.fst.exit(); + } + + /// Creates an entry for an internal function call in the folded stack trace. This method only + /// enters the function in the folded stack trace, we cannot exit since we need to exit at a + /// future step. Hence, we keep track of the step end index in the `step_exits`. + fn process_step( + &mut self, + steps: &[CallTraceStep], + step_idx: usize, + step_exits: &mut Vec, + ) { + let step = &steps[step_idx]; + if let Some(decoded_step) = &step.decoded { + match decoded_step { + DecodedTraceStep::InternalCall(decoded_internal_call, step_end_idx) => { + let gas_used = steps[*step_end_idx].gas_used.saturating_sub(step.gas_used); + self.fst.enter(decoded_internal_call.func_name.clone(), gas_used as i64); + step_exits.push(*step_end_idx); + } + DecodedTraceStep::Line(_) => {} + } + } + } + + /// Exits all the previous internal calls that should end before starting step_idx. + fn exit_previous_steps(&mut self, step_exits: &mut Vec, step_idx: usize) { + let initial_length = step_exits.len(); + step_exits.retain(|&number| number > step_idx); + + let num_exits = initial_length - step_exits.len(); + for _ in 0..num_exits { + self.fst.exit(); + } + } +} + +/// Helps to translate a function enter-exit flow into a folded stack trace. +/// +/// Example: +/// fn top() { child_a(); child_b() } // consumes 500 gas +/// fn child_a() {} // consumes 100 gas +/// fn child_b() {} // consumes 200 gas +/// +/// For execution of the `top` function looks like: +/// 1. enter `top` +/// 2. enter `child_a` +/// 3. exit `child_a` +/// 4. enter `child_b` +/// 5. exit `child_b` +/// 6. exit `top` +/// +/// The translated folded stack trace lines look like: +/// 1. top +/// 2. top;child_a +/// 3. top;child_b +/// +/// Including the gas consumed by the function by itself. +/// 1. top 200 // 500 - 100 - 200 +/// 2. top;child_a 100 +/// 3. top;child_b 200 +#[derive(Debug, Default)] +pub struct FoldedStackTraceBuilder { + /// Trace entries. + traces: Vec, + /// Number of exits to be done before entering a new function. + exits: usize, +} + +#[derive(Debug, Default)] +struct TraceEntry { + /// Names of all functions in the call stack of this trace. + names: Vec, + /// Gas consumed by this function, allowed to be negative due to refunds. + gas: i64, +} + +impl FoldedStackTraceBuilder { + /// Enter execution of a function call that consumes `gas`. + pub fn enter(&mut self, label: String, gas: i64) { + let mut names = self.traces.last().map(|entry| entry.names.clone()).unwrap_or_default(); + + while self.exits > 0 { + names.pop(); + self.exits -= 1; + } + + names.push(label); + self.traces.push(TraceEntry { names, gas }); + } + + /// Exit execution of a function call. + pub fn exit(&mut self) { + self.exits += 1; + } + + /// Returns folded stack trace. + pub fn build(mut self) -> Vec { + self.subtract_children(); + self.build_without_subtraction() + } + + /// Internal method to build the folded stack trace without subtracting gas consumed by + /// the children function calls. + fn build_without_subtraction(&mut self) -> Vec { + let mut lines = Vec::new(); + for TraceEntry { names, gas } in self.traces.iter() { + lines.push(format!("{} {}", names.join(";"), gas)); + } + lines + } + + /// Subtracts gas consumed by the children function calls from the parent function calls. + fn subtract_children(&mut self) { + // Iterate over each trace to find the children and subtract their values from the parents. + for i in 0..self.traces.len() { + let (left, right) = self.traces.split_at_mut(i); + let TraceEntry { names, gas } = &right[0]; + if names.len() > 1 { + let parent_trace_to_match = &names[..names.len() - 1]; + for parent in left.iter_mut().rev() { + if parent.names == parent_trace_to_match { + parent.gas -= gas; + break; + } + } + } + } + } +} + +mod tests { + #[test] + fn test_fst_1() { + let mut trace = super::FoldedStackTraceBuilder::default(); + trace.enter("top".to_string(), 500); + trace.enter("child_a".to_string(), 100); + trace.exit(); + trace.enter("child_b".to_string(), 200); + + assert_eq!( + trace.build_without_subtraction(), + vec![ + "top 500", // + "top;child_a 100", + "top;child_b 200", + ] + ); + assert_eq!( + trace.build(), + vec![ + "top 200", // 500 - 100 - 200 + "top;child_a 100", + "top;child_b 200", + ] + ); + } + + #[test] + fn test_fst_2() { + let mut trace = super::FoldedStackTraceBuilder::default(); + trace.enter("top".to_string(), 500); + trace.enter("child_a".to_string(), 300); + trace.enter("child_b".to_string(), 100); + trace.exit(); + trace.exit(); + trace.enter("child_c".to_string(), 100); + + assert_eq!( + trace.build_without_subtraction(), + vec![ + "top 500", // + "top;child_a 300", + "top;child_a;child_b 100", + "top;child_c 100", + ] + ); + + assert_eq!( + trace.build(), + vec![ + "top 100", // 500 - 300 - 100 + "top;child_a 200", // 300 - 100 + "top;child_a;child_b 100", + "top;child_c 100", + ] + ); + } + + #[test] + fn test_fst_3() { + let mut trace = super::FoldedStackTraceBuilder::default(); + trace.enter("top".to_string(), 1700); + trace.enter("child_a".to_string(), 500); + trace.exit(); + trace.enter("child_b".to_string(), 500); + trace.enter("child_c".to_string(), 500); + trace.exit(); + trace.exit(); + trace.exit(); + trace.enter("top2".to_string(), 1700); + + assert_eq!( + trace.build_without_subtraction(), + vec![ + "top 1700", // + "top;child_a 500", + "top;child_b 500", + "top;child_b;child_c 500", + "top2 1700", + ] + ); + + assert_eq!( + trace.build(), + vec![ + "top 700", // + "top;child_a 500", + "top;child_b 0", + "top;child_b;child_c 500", + "top2 1700", + ] + ); + } +} diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 4a80b164ad33b..fb1665a5a6cd1 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -42,6 +42,8 @@ pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder}; pub mod debug; pub use debug::DebugTraceIdentifier; +pub mod folded_stack_trace; + pub type Traces = Vec<(TraceKind, SparsedTraceArena)>; /// Trace arena keeping track of ignored trace items. diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 4f9110ff60e74..77034d6194de2 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -78,6 +78,7 @@ dialoguer = { version = "0.11", default-features = false } dunce.workspace = true futures.workspace = true indicatif = "0.17" +inferno = { version = "0.11.19", default-features = false } itertools.workspace = true parking_lot.workspace = true regex = { version = "1", default-features = false } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index b0792a8cfc562..1cc647b0cb8af 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -1,7 +1,7 @@ use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; use alloy_primitives::U256; use clap::{Parser, ValueHint}; -use eyre::Result; +use eyre::{Context, OptionExt, Result}; use forge::{ decode::decode_console_logs, gas_report::GasReport, @@ -9,7 +9,7 @@ use forge::{ result::{SuiteResult, TestOutcome, TestStatus}, traces::{ debug::{ContractSources, DebugTraceIdentifier}, - decode_trace_arena, + decode_trace_arena, folded_stack_trace, identifier::SignaturesIdentifier, render_trace_arena, CallTraceDecoderBuilder, InternalTraceMode, TraceKind, }, @@ -81,6 +81,14 @@ pub struct TestArgs { #[arg(long, value_name = "TEST_FUNCTION")] debug: Option, + /// Generate a flamegraph for a single test. Implies `--decode-internal`. + #[arg(long, conflicts_with = "flamechart")] + flamegraph: bool, + + /// Generate a flamechart for a single test. Implies `--decode-internal`. + #[arg(long, conflicts_with = "flamegraph")] + flamechart: bool, + /// Whether to identify internal functions in traces. /// /// If no argument is passed to this flag, it will trace internal functions scope and decode @@ -254,7 +262,7 @@ impl TestArgs { /// configured filter will be executed /// /// Returns the test results for all matching tests. - pub async fn execute_tests(self) -> Result { + pub async fn execute_tests(mut self) -> Result { // Merge all configs. let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; @@ -308,14 +316,22 @@ impl TestArgs { .profiles(profiles) .build(&output, project_root)?; + let should_debug = self.debug.is_some(); + let should_draw = self.flamegraph || self.flamechart; + // Determine print verbosity and executor verbosity. let verbosity = evm_opts.verbosity; - if self.gas_report && evm_opts.verbosity < 3 { + if (self.gas_report && evm_opts.verbosity < 3) || self.flamegraph || self.flamechart { evm_opts.verbosity = 3; } let env = evm_opts.evm_env().await?; + // Enable internal tracing for more informative flamegraph. + if should_draw { + self.decode_internal = Some(None); + } + // Choose the internal function tracing mode, if --decode-internal is provided. let decode_internal = if let Some(maybe_fn) = self.decode_internal.as_ref() { if maybe_fn.is_some() { @@ -330,7 +346,6 @@ impl TestArgs { }; // Prepare the test builder. - let should_debug = self.debug.is_some(); let config = Arc::new(config); let runner = MultiContractRunnerBuilder::new(config.clone()) .set_debug(should_debug) @@ -366,18 +381,60 @@ impl TestArgs { )?; let libraries = runner.libraries.clone(); - let outcome = self.run_tests(runner, config, verbosity, &filter, &output).await?; + let mut outcome = self.run_tests(runner, config, verbosity, &filter, &output).await?; + + if should_draw { + let (suite_name, test_name, mut test_result) = + outcome.remove_first().ok_or_eyre("no tests were executed")?; + + let arena = test_result + .traces + .iter_mut() + .find_map( + |(kind, arena)| { + if *kind == TraceKind::Execution { + Some(arena) + } else { + None + } + }, + ) + .unwrap(); + + // Decode traces. + let decoder = outcome.last_run_decoder.as_ref().unwrap(); + decode_trace_arena(arena, decoder).await?; + let mut fst = folded_stack_trace::build(arena); + + let label = if self.flamegraph { "flamegraph" } else { "flamechart" }; + let contract = suite_name.split(':').last().unwrap(); + let test_name = test_name.trim_end_matches("()"); + let file_name = format!("cache/{label}_{contract}_{test_name}.svg"); + let file = std::fs::File::create(&file_name).wrap_err("failed to create file")?; + + let mut options = inferno::flamegraph::Options::default(); + options.title = format!("{label} {contract}::{test_name}"); + options.count_name = "gas".to_string(); + if self.flamechart { + options.flame_chart = true; + fst.reverse(); + } + + // Generate SVG. + inferno::flamegraph::from_lines(&mut options, fst.iter().map(|s| s.as_str()), file) + .wrap_err("failed to write svg")?; + println!("\nSaved to {file_name}"); + + // Open SVG in default program. + if opener::open(&file_name).is_err() { + println!("\nFailed to open {file_name}. Please open it manually."); + } + } if should_debug { // Get first non-empty suite result. We will have only one such entry. - let Some((_, test_result)) = outcome - .results - .iter() - .find(|(_, r)| !r.test_results.is_empty()) - .map(|(_, r)| (r, r.test_results.values().next().unwrap())) - else { - return Err(eyre::eyre!("no tests were executed")); - }; + let (_, _, test_result) = + outcome.remove_first().ok_or_eyre("no tests were executed")?; let sources = ContractSources::from_project_output(&output, project.root(), Some(&libraries))?; @@ -417,13 +474,17 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); let num_filtered = runner.matching_test_functions(filter).count(); - if (self.debug.is_some() || self.decode_internal.as_ref().map_or(false, |v| v.is_some())) && + if (self.debug.is_some() || + self.decode_internal.as_ref().map_or(false, |v| v.is_some()) || + self.flamegraph || + self.flamechart) && num_filtered != 1 { eyre::bail!( - "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to run the debugger.\n\n\ + "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to {action}.\n\n\ Use --match-contract and --match-path to further limit the search.\n\ - Filter used:\n{filter}" + Filter used:\n{filter}", + action = if self.flamegraph {"generate a flamegraph"} else if self.flamechart {"generate a flamechart"} else {"run the debugger"}, ); } @@ -489,7 +550,11 @@ impl TestArgs { decoder.clear_addresses(); // We identify addresses if we're going to print *any* trace or gas report. - let identify_addresses = verbosity >= 3 || self.gas_report || self.debug.is_some(); + let identify_addresses = verbosity >= 3 || + self.gas_report || + self.debug.is_some() || + self.flamegraph || + self.flamechart; // Print suite header. println!(); diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index e7953575f3b50..aa88bc4016fcf 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -184,6 +184,18 @@ impl TestOutcome { // TODO: Avoid process::exit std::process::exit(1); } + + /// Removes first test result, if any. + pub fn remove_first(&mut self) -> Option<(String, String, TestResult)> { + self.results.iter_mut().find_map(|(suite_name, suite)| { + if let Some(test_name) = suite.test_results.keys().next().cloned() { + let result = suite.test_results.remove(&test_name).unwrap(); + Some((suite_name.clone(), test_name, result)) + } else { + None + } + }) + } } /// A set of test results for a single test suite, which is all the tests in a single contract. diff --git a/deny.toml b/deny.toml index 77cfc79a35f41..e908828cc2a03 100644 --- a/deny.toml +++ b/deny.toml @@ -52,6 +52,7 @@ allow = [ "BSL-1.0", "0BSD", "MPL-2.0", + "CDDL-1.0", ] # Allow 1 or more licenses on a per-crate basis, so that particular licenses From 209776527326e179448ca80e7591f533b1d135fe Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 10 Sep 2024 12:23:37 +0200 Subject: [PATCH 1429/1963] test: fix flaky test (#8839) --- crates/anvil/tests/it/traces.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 5c9d87ca1aa57..aaa2ca298d142 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -766,15 +766,15 @@ async fn test_trace_filter() { for i in 0..=5 { let tx = TransactionRequest::default().to(to).value(U256::from(i)).from(from); let tx = WithOtherFields::new(tx); - api.send_transaction(tx).await.unwrap(); + provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); let tx = TransactionRequest::default().to(to_two).value(U256::from(i)).from(from_two); let tx = WithOtherFields::new(tx); - api.send_transaction(tx).await.unwrap(); + provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); } let traces = api.trace_filter(tracer).await.unwrap(); - assert_eq!(traces.len(), 5); + assert_eq!(traces.len(), 6); // Test for the following actions: // Create (deploy the contract) @@ -804,11 +804,11 @@ async fn test_trace_filter() { for i in 0..=5 { let tx = TransactionRequest::default().to(to_two).value(U256::from(i)).from(from_two); let tx = WithOtherFields::new(tx); - api.send_transaction(tx).await.unwrap(); + provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); } let traces = api.trace_filter(tracer).await.unwrap(); - assert_eq!(traces.len(), 8); + assert_eq!(traces.len(), 9); // Test Range Error let latest = provider.get_block_number().await.unwrap(); @@ -854,7 +854,7 @@ async fn test_trace_filter() { for i in 0..=10 { let tx = TransactionRequest::default().to(to).value(U256::from(i)).from(from); let tx = WithOtherFields::new(tx); - api.send_transaction(tx).await.unwrap(); + provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); } let traces = api.trace_filter(tracer).await.unwrap(); From be451fb93a0d0ec52152fb67cc6c36cd8fbd7ae1 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:05:06 +0530 Subject: [PATCH 1430/1963] fix(anvil): prevent panic in ots (#8835) * fix(anvil): prevent panic in ots * fix(anvil): use block_by_number in ots_block_tx & ots_search_transactions * nit * nit --- crates/anvil/src/eth/otterscan/api.rs | 56 ++++++++++++--------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 798ff205bf1b8..e73fe4dd6647a 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -419,20 +419,19 @@ impl EthApi { let receipt_futs = block.transactions.hashes().map(|hash| self.transaction_receipt(hash)); - let receipts = join_all(receipt_futs) - .await - .into_iter() - .map(|r| match r { - Ok(Some(r)) => { - let timestamp = - self.backend.get_block(r.block_number.unwrap()).unwrap().header.timestamp; - let receipt = r.map_inner(OtsReceipt::from); - let res = OtsTransactionReceipt { receipt, timestamp: Some(timestamp) }; - Ok(res) - } - _ => Err(BlockchainError::DataUnavailable), - }) - .collect::>>()?; + let receipts = join_all(receipt_futs.map(|r| async { + if let Ok(Some(r)) = r.await { + let block = self.block_by_number(r.block_number.unwrap().into()).await?; + let timestamp = block.ok_or(BlockchainError::BlockNotFound)?.header.timestamp; + let receipt = r.map_inner(OtsReceipt::from); + Ok(OtsTransactionReceipt { receipt, timestamp: Some(timestamp) }) + } else { + Err(BlockchainError::BlockNotFound) + } + })) + .await + .into_iter() + .collect::>>()?; let transaction_count = block.transactions().len(); let fullblock = OtsBlock { block: block.inner, transaction_count }; @@ -458,23 +457,18 @@ impl EthApi { Ok(Some(t)) => Ok(t.inner), _ => Err(BlockchainError::DataUnavailable), }) - .collect::>()?; - - let receipts = join_all(hashes.iter().map(|hash| async { - match self.transaction_receipt(*hash).await { - Ok(Some(receipt)) => { - let timestamp = self - .backend - .get_block(receipt.block_number.unwrap()) - .unwrap() - .header - .timestamp; - let receipt = receipt.map_inner(OtsReceipt::from); - let res = OtsTransactionReceipt { receipt, timestamp: Some(timestamp) }; - Ok(res) - } - Ok(None) => Err(BlockchainError::DataUnavailable), - Err(e) => Err(e), + .collect::>>()?; + + let receipt_futs = hashes.iter().map(|hash| self.transaction_receipt(*hash)); + + let receipts = join_all(receipt_futs.map(|r| async { + if let Ok(Some(r)) = r.await { + let block = self.block_by_number(r.block_number.unwrap().into()).await?; + let timestamp = block.ok_or(BlockchainError::BlockNotFound)?.header.timestamp; + let receipt = r.map_inner(OtsReceipt::from); + Ok(OtsTransactionReceipt { receipt, timestamp: Some(timestamp) }) + } else { + Err(BlockchainError::BlockNotFound) } })) .await From 2c73013a01264e8577e728bee33961845d126963 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:32:50 +0530 Subject: [PATCH 1431/1963] chore: bump alloy to fix #8830 (#8838) * bump alloy to fix #8830 * rm alloy patch * nit --- Cargo.lock | 157 +++++++++++-------- Cargo.toml | 93 ++++++----- crates/anvil/core/src/eth/transaction/mod.rs | 12 +- crates/anvil/tests/it/eip7702.rs | 4 +- 4 files changed, 149 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 011a7af0fb62a..6345afda71b67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,8 +85,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1468e3128e07c7afe4ff13c17e8170c330d12c322f8924b8bf6986a27e0aad3d" dependencies = [ "alloy-eips", "alloy-primitives", @@ -98,8 +99,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335d62de1a887f1b780441f8a3037f39c9fb26839cc9acd891c9b80396145cd5" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -166,8 +168,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c35df7b972b06f1b2f4e8b7a53328522fa788054a9d3e556faf2411c5a51d5a" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -184,8 +187,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7210f9206c0fa2a83c824cf8cb6c962126bc9fdc4f41ade1932f14150ef5f6" dependencies = [ "alloy-primitives", "alloy-serde", @@ -206,8 +210,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8866562186d237f1dfeaf989ef941a24764f764bf5c33311e37ead3519c6a429" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -219,8 +224,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe714e233f9eaf410de95a9af6bcd05d3a7f8c8de7a0817221e95a6b642a080" dependencies = [ "alloy-consensus", "alloy-eips", @@ -239,9 +245,11 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c5a38117974c5776a45e140226745a0b664f79736aa900995d8e4121558e064" dependencies = [ + "alloy-eips", "alloy-primitives", "alloy-serde", "serde", @@ -275,8 +283,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c65633d6ef83c3626913c004eaf166a6dd50406f724772ea8567135efd6dc5d3" dependencies = [ "alloy-chains", "alloy-consensus", @@ -313,8 +322,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "949db89abae6193b44cc90ebf2eeb74eb8d2a474383c5e62b45bdcd362e84f8f" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -325,7 +335,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.4.13", + "tower 0.5.0", "tracing", ] @@ -353,8 +363,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fc328bb5d440599ba1b5aa44c0b9ab0625fbc3a403bb5ee94ed4a01ba23e07" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -370,15 +381,16 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.4.13", + "tower 0.5.0", "tracing", "url", ] [[package]] name = "alloy-rpc-types" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f8ff679f94c497a8383f2cd09e2a099266e5f3d5e574bc82b4b379865707dbb" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -391,8 +403,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d430bf98148565e67b2c08f033dd5fb27ce901c3481018941ce1524b9ad4fba" dependencies = [ "alloy-primitives", "alloy-serde", @@ -401,8 +414,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66bb45f4c5efe227bcb51d89c97221225169976e18097671a0bd4393d8248a4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -418,8 +432,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a59b1d7c86e0a653e7f3d29954f6de5a2878d8cfd1f010ff93be5c2c48cd3b1" dependencies = [ "alloy-consensus", "alloy-eips", @@ -436,8 +451,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54375e5a34ec5a2cf607f9ce98c0ece30dc76ad623afeb25d3953a8d7d30f20" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -449,8 +465,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65ae88491edfc8bbd55ba2b22b2ff24d4c522bacd8808461c4a232715fee3d22" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -460,8 +477,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51db8a6428a2159e01b7a43ec7aac801edd0c4db1d4de06f310c288940f16fd3" dependencies = [ "alloy-primitives", "arbitrary", @@ -471,8 +489,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebc1760c13592b7ba3fcd964abba546b8d6a9f10d15e8d92a8263731be33f36" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -486,8 +505,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa0d52968220ddfdb8d332cfddc6c7ae8147779aebb3c463d6023f1d458471b" dependencies = [ "alloy-consensus", "alloy-network", @@ -503,8 +523,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d369e98958cf6e2a41b1b1fcee21d73185f358db23751636e3d90b1f4aa184d" dependencies = [ "alloy-consensus", "alloy-network", @@ -520,8 +541,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f03b98771184d733139f0475e562f6f8cb8143d0a3765674078c0a3ed00c3b" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -539,8 +561,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bfb3508485aa798efb5725322e414313239274d3780079b7f8c6746b8ee6e1b" dependencies = [ "alloy-consensus", "alloy-network", @@ -558,8 +581,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "423c62e0596be68f55a7c03ec4b961d46c74e92ba2d0143fe147608a5c8fe4a4" dependencies = [ "alloy-consensus", "alloy-network", @@ -647,8 +671,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd5dc4e902f1860d54952446d246ac05386311ad61030a2b906ae865416d36e0" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -658,29 +683,31 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower 0.4.13", + "tower 0.5.0", "tracing", "url", ] [[package]] name = "alloy-transport-http" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1742b94bb814f1ca6b322a6f9dd38a0252ff45a3119e40e888fb7029afa500ce" dependencies = [ "alloy-json-rpc", "alloy-transport", "reqwest", "serde_json", - "tower 0.4.13", + "tower 0.5.0", "tracing", "url", ] [[package]] name = "alloy-transport-ipc" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be321aac6f06d86855d41d4ce9ff9feb877fe7e9fe1cafce7380b981c12398c7" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -699,8 +726,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/alloy?rev=7fab7ee#7fab7ee4b27220e755d21f4b50108d083ea341fd" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ed861e7030001364c8ffa2db63541f7bae275a6e636de7616c20f2fd3dc0c3" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -5967,9 +5995,9 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "op-alloy-consensus" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fbb0f5c3754c22c6ea30e100dca6aea73b747e693e27763e23ca92fb02f2f" +checksum = "ad134a77fdfebac469526756b207c7889593657eeaca374200332ec89175e27a" dependencies = [ "alloy-consensus", "alloy-eips", @@ -5983,10 +6011,11 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fbb93dcb71aba9cd555784375011efce1fdaaea67e01972a0a9bc9eb90c626" +checksum = "f9fbd440cd8a5ccfa7c4c085b29fd0f0a1574fb53e1572f8e070cc105039e42b" dependencies = [ + "alloy-eips", "alloy-network", "alloy-primitives", "alloy-rpc-types-eth", @@ -8715,6 +8744,10 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36b837f86b25d7c0d7988f00a54e74739be6477f2aac6201b8f429a7569991b7" dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] diff --git a/Cargo.toml b/Cargo.toml index fe8730a6bae06..b05398538f156 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,27 +172,27 @@ revm-inspectors = { version = "0.6", features = ["serde"] } ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.3.1", default-features = false } -alloy-contract = { version = "0.3.1", default-features = false } -alloy-eips = { version = "0.3.1", default-features = false } -alloy-genesis = { version = "0.3.1", default-features = false } -alloy-json-rpc = { version = "0.3.1", default-features = false } -alloy-network = { version = "0.3.1", default-features = false } -alloy-provider = { version = "0.3.1", default-features = false } -alloy-pubsub = { version = "0.3.1", default-features = false } -alloy-rpc-client = { version = "0.3.1", default-features = false } -alloy-rpc-types = { version = "0.3.1", default-features = true } -alloy-serde = { version = "0.3.1", default-features = false } -alloy-signer = { version = "0.3.1", default-features = false } -alloy-signer-aws = { version = "0.3.1", default-features = false } -alloy-signer-gcp = { version = "0.3.1", default-features = false } -alloy-signer-ledger = { version = "0.3.1", default-features = false } -alloy-signer-local = { version = "0.3.1", default-features = false } -alloy-signer-trezor = { version = "0.3.1", default-features = false } -alloy-transport = { version = "0.3.1", default-features = false } -alloy-transport-http = { version = "0.3.1", default-features = false } -alloy-transport-ipc = { version = "0.3.1", default-features = false } -alloy-transport-ws = { version = "0.3.1", default-features = false } +alloy-consensus = { version = "0.3.3", default-features = false } +alloy-contract = { version = "0.3.3", default-features = false } +alloy-eips = { version = "0.3.3", default-features = false } +alloy-genesis = { version = "0.3.3", default-features = false } +alloy-json-rpc = { version = "0.3.3", default-features = false } +alloy-network = { version = "0.3.3", default-features = false } +alloy-provider = { version = "0.3.3", default-features = false } +alloy-pubsub = { version = "0.3.3", default-features = false } +alloy-rpc-client = { version = "0.3.3", default-features = false } +alloy-rpc-types = { version = "0.3.3", default-features = true } +alloy-serde = { version = "0.3.3", default-features = false } +alloy-signer = { version = "0.3.3", default-features = false } +alloy-signer-aws = { version = "0.3.3", default-features = false } +alloy-signer-gcp = { version = "0.3.3", default-features = false } +alloy-signer-ledger = { version = "0.3.3", default-features = false } +alloy-signer-local = { version = "0.3.3", default-features = false } +alloy-signer-trezor = { version = "0.3.3", default-features = false } +alloy-transport = { version = "0.3.3", default-features = false } +alloy-transport-http = { version = "0.3.3", default-features = false } +alloy-transport-ipc = { version = "0.3.3", default-features = false } +alloy-transport-ws = { version = "0.3.3", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.1" @@ -208,7 +208,7 @@ alloy-rlp = "0.3" alloy-trie = "0.5.0" ## op-alloy for tests in anvil -op-alloy-rpc-types = "0.2.8" +op-alloy-rpc-types = "0.2.9" ## misc async-trait = "0.1" @@ -267,28 +267,27 @@ soldeer = "=0.3.4" proptest = "1" comfy-table = "7" -[patch.crates-io] -# https://github.com/alloy-rs/alloy/pull/1229 + https://github.com/alloy-rs/alloy/pull/1243 -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } -alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# [patch.crates-io] +# alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } +# alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 7d80450f379e3..128f6e9cd888f 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -390,7 +390,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( block_number: None, transaction_index: None, from, - to: t.tx().to.to().copied(), + to: Some(t.tx().to), value: t.tx().value, gas_price: Some(t.tx().max_fee_per_gas), max_fee_per_gas: Some(t.tx().max_fee_per_gas), @@ -602,7 +602,7 @@ impl PendingTransaction { } = tx.tx(); TxEnv { caller, - transact_to: *to, + transact_to: TxKind::Call(*to), data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), @@ -851,7 +851,7 @@ impl TypedTransaction { access_list: t.tx().tx().access_list.clone(), }, Self::EIP7702(t) => TransactionEssentials { - kind: t.tx().to, + kind: TxKind::Call(t.tx().to), input: t.tx().input.clone(), nonce: t.tx().nonce, gas_limit: t.tx().gas_limit, @@ -975,7 +975,7 @@ impl TypedTransaction { Self::EIP2930(tx) => tx.tx().to, Self::EIP1559(tx) => tx.tx().to, Self::EIP4844(tx) => TxKind::Call(tx.tx().tx().to), - Self::EIP7702(tx) => tx.tx().to, + Self::EIP7702(tx) => TxKind::Call(tx.tx().to), Self::Deposit(tx) => tx.kind, } } @@ -1105,7 +1105,7 @@ impl TryFrom for TypedTransaction { max_priority_fee_per_gas: tx .max_priority_fee_per_gas .ok_or(ConversionError::MissingMaxPriorityFeePerGas)?, - to: tx.to.map_or(TxKind::Create, TxKind::Call), + to: tx.to.ok_or(ConversionError::MissingTo)?, value: tx.value, access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, input: tx.input, @@ -1406,7 +1406,7 @@ impl From> for OtsReceipt { let receipt = ReceiptWithBloom::::from(value); let status = receipt.status(); let cumulative_gas_used = receipt.cumulative_gas_used() as u64; - let logs = receipt.receipt.logs.into_iter().map(|x| x.inner).collect(); + let logs = receipt.logs().to_vec(); let logs_bloom = receipt.logs_bloom; Self { status, cumulative_gas_used, logs: Some(logs), logs_bloom: Some(logs_bloom), r#type } diff --git a/crates/anvil/tests/it/eip7702.rs b/crates/anvil/tests/it/eip7702.rs index 828e0d351b45f..2a0cc0e43fb77 100644 --- a/crates/anvil/tests/it/eip7702.rs +++ b/crates/anvil/tests/it/eip7702.rs @@ -1,7 +1,7 @@ use crate::utils::http_provider; use alloy_consensus::{transaction::TxEip7702, SignableTransaction}; use alloy_network::{ReceiptResponse, TransactionBuilder, TxSignerSync}; -use alloy_primitives::{bytes, TxKind, U256}; +use alloy_primitives::{bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{Authorization, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -57,7 +57,7 @@ async fn can_send_eip7702_tx() { max_priority_fee_per_gas: eip1559_est.max_priority_fee_per_gas, gas_limit: 100000, chain_id: 31337, - to: TxKind::Call(from), + to: from, input: bytes!("11112222"), authorization_list: vec![authorization], ..Default::default() From d663f38be3114ccb94f08fe3b8ea26e27e2043c1 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:38:38 +0300 Subject: [PATCH 1432/1963] feat(cheatcodes): additional cheatcodes to aid in symbolic testing (#8807) * feat(cheatcodes): additional cheatcodes to aid in symbolic testing * Support copies from arbitrary storage, docs * Changes after review: - separate cheatcodes tests with specific seed - better way to match mocked function - arbitrary_storage_end instead multiple calls - generate arbitrary value only when needed * Update crates/cheatcodes/src/utils.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Fix tests with isolate-by-default --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 60 +++++++ crates/cheatcodes/spec/src/vm.rs | 17 ++ crates/cheatcodes/src/evm.rs | 21 ++- crates/cheatcodes/src/evm/mock.rs | 9 + crates/cheatcodes/src/inspector.rs | 140 +++++++++++++++- crates/cheatcodes/src/utils.rs | 30 +++- crates/evm/evm/src/inspectors/stack.rs | 12 ++ crates/forge/tests/it/cheats.rs | 26 ++- testdata/cheats/Vm.sol | 3 + .../default/cheats/ArbitraryStorage.t.sol | 125 ++++++++++++++ testdata/default/cheats/CopyStorage.t.sol | 158 ++++++++++++++++++ testdata/default/cheats/MockFunction.t.sol | 74 ++++++++ 12 files changed, 667 insertions(+), 8 deletions(-) create mode 100644 testdata/default/cheats/ArbitraryStorage.t.sol create mode 100644 testdata/default/cheats/CopyStorage.t.sol create mode 100644 testdata/default/cheats/MockFunction.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 4517f075e7fb0..da501a11ed685 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3331,6 +3331,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "copyStorage", + "description": "Utility cheatcode to copy storage of `from` contract to another `to` contract.", + "declaration": "function copyStorage(address from, address to) external;", + "visibility": "external", + "mutability": "", + "signature": "copyStorage(address,address)", + "selector": "0x203dac0d", + "selectorBytes": [ + 32, + 61, + 172, + 13 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "createDir", @@ -5591,6 +5611,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "mockFunction", + "description": "Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls\n`target` with the same calldata. This functionality is similar to a delegate call made to\n`target` contract from `callee`.\nCan be used to substitute a call to a function with another implementation that captures\nthe primary logic of the original function but is easier to reason about.\nIf calldata is not a strict match then partial match by selector is attempted.", + "declaration": "function mockFunction(address callee, address target, bytes calldata data) external;", + "visibility": "external", + "mutability": "", + "signature": "mockFunction(address,address,bytes)", + "selector": "0xadf84d21", + "selectorBytes": [ + 173, + 248, + 77, + 33 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "parseAddress", @@ -7791,6 +7831,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "setArbitraryStorage", + "description": "Utility cheatcode to set arbitrary storage for given target address.", + "declaration": "function setArbitraryStorage(address target) external;", + "visibility": "external", + "mutability": "", + "signature": "setArbitraryStorage(address)", + "selector": "0xe1631837", + "selectorBytes": [ + 225, + 99, + 24, + 55 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "setBlockhash", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 980bab066a3a0..d0a921485c7f9 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -473,6 +473,15 @@ interface Vm { function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; + /// Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls + /// `target` with the same calldata. This functionality is similar to a delegate call made to + /// `target` contract from `callee`. + /// Can be used to substitute a call to a function with another implementation that captures + /// the primary logic of the original function but is easier to reason about. + /// If calldata is not a strict match then partial match by selector is attempted. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockFunction(address callee, address target, bytes calldata data) external; + // --- Impersonation (pranks) --- /// Sets the *next* call's `msg.sender` to be the input address. @@ -2303,6 +2312,14 @@ interface Vm { /// Unpauses collection of call traces. #[cheatcode(group = Utilities)] function resumeTracing() external view; + + /// Utility cheatcode to copy storage of `from` contract to another `to` contract. + #[cheatcode(group = Utilities)] + function copyStorage(address from, address to) external; + + /// Utility cheatcode to set arbitrary storage for given target address. + #[cheatcode(group = Utilities)] + function setArbitraryStorage(address target) external; } } diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index a3d517387d3d3..703d7db126e9a 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -13,6 +13,7 @@ use foundry_evm_core::{ backend::{DatabaseExt, RevertSnapshotAction}, constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS}, }; +use rand::Rng; use revm::{ primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, InnerEvmContext, @@ -89,7 +90,25 @@ impl Cheatcode for loadCall { let Self { target, slot } = *self; ensure_not_precompile!(&target, ccx); ccx.ecx.load_account(target)?; - let val = ccx.ecx.sload(target, slot.into())?; + let mut val = ccx.ecx.sload(target, slot.into())?; + + if val.is_cold && val.data.is_zero() { + if ccx.state.arbitrary_storage.is_arbitrary(&target) { + // If storage slot is untouched and load from a target with arbitrary storage, + // then set random value for current slot. + let rand_value = ccx.state.rng().gen(); + ccx.state.arbitrary_storage.save(ccx.ecx, target, slot.into(), rand_value); + val.data = rand_value; + } else if ccx.state.arbitrary_storage.is_copy(&target) { + // If storage slot is untouched and load from a target that copies storage from + // a source address with arbitrary storage, then copy existing arbitrary value. + // If no arbitrary value generated yet, then the random one is saved and set. + let rand_value = ccx.state.rng().gen(); + val.data = + ccx.state.arbitrary_storage.copy(ccx.ecx, target, slot.into(), rand_value); + } + } + Ok(val.abi_encode()) } } diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 1a6ffb46a51fb..cd7c459b6b177 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -89,6 +89,15 @@ impl Cheatcode for mockCallRevert_1Call { } } +impl Cheatcode for mockFunctionCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { callee, target, data } = self; + state.mocked_functions.entry(*callee).or_default().insert(data.clone(), *target); + + Ok(Default::default()) + } +} + #[allow(clippy::ptr_arg)] // Not public API, doesn't matter fn mock_call( state: &mut Cheatcodes, diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index f5238d810c8bd..e09e1e8c88b9f 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -41,7 +41,7 @@ use revm::{ EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, - primitives::{BlockEnv, CreateScheme, EVMError, SpecId, EOF_MAGIC_BYTES}, + primitives::{BlockEnv, CreateScheme, EVMError, EvmStorageSlot, SpecId, EOF_MAGIC_BYTES}, EvmContext, InnerEvmContext, Inspector, }; use rustc_hash::FxHashMap; @@ -254,6 +254,89 @@ impl GasMetering { } } +/// Holds data about arbitrary storage. +#[derive(Clone, Debug, Default)] +pub struct ArbitraryStorage { + /// Mapping of arbitrary storage addresses to generated values (slot, arbitrary value). + /// (SLOADs return random value if storage slot wasn't accessed). + /// Changed values are recorded and used to copy storage to different addresses. + pub values: HashMap>, + /// Mapping of address with storage copied to arbitrary storage address source. + pub copies: HashMap, +} + +impl ArbitraryStorage { + /// Whether the given address has arbitrary storage. + pub fn is_arbitrary(&self, address: &Address) -> bool { + self.values.contains_key(address) + } + + /// Whether the given address is a copy of an address with arbitrary storage. + pub fn is_copy(&self, address: &Address) -> bool { + self.copies.contains_key(address) + } + + /// Marks an address with arbitrary storage. + pub fn mark_arbitrary(&mut self, address: &Address) { + self.values.insert(*address, HashMap::default()); + } + + /// Maps an address that copies storage with the arbitrary storage address. + pub fn mark_copy(&mut self, from: &Address, to: &Address) { + if self.is_arbitrary(from) { + self.copies.insert(*to, *from); + } + } + + /// Saves arbitrary storage value for a given address: + /// - store value in changed values cache. + /// - update account's storage with given value. + pub fn save( + &mut self, + ecx: &mut InnerEvmContext, + address: Address, + slot: U256, + data: U256, + ) { + self.values.get_mut(&address).expect("missing arbitrary address entry").insert(slot, data); + if let Ok(mut account) = ecx.load_account(address) { + account.storage.insert(slot, EvmStorageSlot::new(data)); + } + } + + /// Copies arbitrary storage value from source address to the given target address: + /// - if a value is present in arbitrary values cache, then update target storage and return + /// existing value. + /// - if no value was yet generated for given slot, then save new value in cache and update both + /// source and target storages. + pub fn copy( + &mut self, + ecx: &mut InnerEvmContext, + target: Address, + slot: U256, + new_value: U256, + ) -> U256 { + let source = self.copies.get(&target).expect("missing arbitrary copy target entry"); + let storage_cache = self.values.get_mut(source).expect("missing arbitrary source storage"); + let value = match storage_cache.get(&slot) { + Some(value) => *value, + None => { + storage_cache.insert(slot, new_value); + // Update source storage with new value. + if let Ok(mut source_account) = ecx.load_account(*source) { + source_account.storage.insert(slot, EvmStorageSlot::new(new_value)); + } + new_value + } + }; + // Update target storage with new value. + if let Ok(mut target_account) = ecx.load_account(target) { + target_account.storage.insert(slot, EvmStorageSlot::new(value)); + } + value + } +} + /// List of transactions that can be broadcasted. pub type BroadcastableTransactions = VecDeque; @@ -320,6 +403,9 @@ pub struct Cheatcodes { // **Note**: inner must a BTreeMap because of special `Ord` impl for `MockCallDataContext` pub mocked_calls: HashMap>, + /// Mocked functions. Maps target address to be mocked to pair of (calldata, mock address). + pub mocked_functions: HashMap>, + /// Expected calls pub expected_calls: ExpectedCallTracker, /// Expected emits @@ -368,6 +454,9 @@ pub struct Cheatcodes { /// Ignored traces. pub ignored_traces: IgnoredTraces, + + /// Addresses with arbitrary storage. + pub arbitrary_storage: ArbitraryStorage, } // This is not derived because calling this in `fn new` with `..Default::default()` creates a second @@ -396,6 +485,7 @@ impl Cheatcodes { recorded_account_diffs_stack: Default::default(), recorded_logs: Default::default(), mocked_calls: Default::default(), + mocked_functions: Default::default(), expected_calls: Default::default(), expected_emits: Default::default(), allowed_mem_writes: Default::default(), @@ -410,6 +500,7 @@ impl Cheatcodes { breakpoints: Default::default(), rng: Default::default(), ignored_traces: Default::default(), + arbitrary_storage: Default::default(), } } @@ -1045,7 +1136,7 @@ impl Inspector for Cheatcodes { } #[inline] - fn step_end(&mut self, interpreter: &mut Interpreter, _ecx: &mut EvmContext) { + fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { if self.gas_metering.paused { self.meter_gas_end(interpreter); } @@ -1053,6 +1144,14 @@ impl Inspector for Cheatcodes { if self.gas_metering.touched { self.meter_gas_check(interpreter); } + + // `setArbitraryStorage` and `copyStorage`: add arbitrary values to storage. + if (self.arbitrary_storage.is_arbitrary(&interpreter.contract().target_address) || + self.arbitrary_storage.is_copy(&interpreter.contract().target_address)) && + interpreter.current_opcode() == op::SLOAD + { + self.arbitrary_storage_end(interpreter, ecx); + } } fn log(&mut self, interpreter: &mut Interpreter, _ecx: &mut EvmContext, log: &Log) { @@ -1465,6 +1564,43 @@ impl Cheatcodes { } } + /// Generates or copies arbitrary values for storage slots. + /// Invoked in inspector `step_end` (when the current opcode is not executed), if current opcode + /// to execute is `SLOAD` and storage slot is cold. + /// Ensures that in next step (when `SLOAD` opcode is executed) an arbitrary value is returned: + /// - copies the existing arbitrary storage value (or the new generated one if no value in + /// cache) from mapped source address to the target address. + /// - generates arbitrary value and saves it in target address storage. + #[cold] + fn arbitrary_storage_end( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext, + ) { + let key = try_or_return!(interpreter.stack().peek(0)); + let target_address = interpreter.contract().target_address; + if let Ok(value) = ecx.sload(target_address, key) { + if value.is_cold && value.data.is_zero() { + let arbitrary_value = self.rng().gen(); + if self.arbitrary_storage.is_copy(&target_address) { + self.arbitrary_storage.copy( + &mut ecx.inner, + target_address, + key, + arbitrary_value, + ); + } else { + self.arbitrary_storage.save( + &mut ecx.inner, + target_address, + key, + arbitrary_value, + ); + } + } + } + } + /// Records storage slots reads and writes. #[cold] fn record_accesses(&mut self, interpreter: &mut Interpreter) { diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 642cf83abb99b..0896f2b316314 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -1,6 +1,6 @@ //! Implementations of [`Utilities`](spec::Group::Utilities) cheatcodes. -use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, U256}; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; @@ -149,3 +149,31 @@ impl Cheatcode for resumeTracingCall { Ok(Default::default()) } } + +impl Cheatcode for setArbitraryStorageCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { target } = self; + ccx.state.arbitrary_storage.mark_arbitrary(target); + + Ok(Default::default()) + } +} + +impl Cheatcode for copyStorageCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { from, to } = self; + ensure!( + !ccx.state.arbitrary_storage.is_arbitrary(to), + "target address cannot have arbitrary storage" + ); + if let Ok(from_account) = ccx.load_account(*from) { + let from_storage = from_account.storage.clone(); + if let Ok(mut to_account) = ccx.load_account(*to) { + to_account.storage = from_storage; + ccx.state.arbitrary_storage.mark_copy(from, to); + } + } + + Ok(Default::default()) + } +} diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index e44d499eafa24..3df8dc8f01dab 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -726,6 +726,18 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ecx.journaled_state.depth += self.in_inner_context as usize; if let Some(cheatcodes) = self.cheatcodes.as_deref_mut() { + // Handle mocked functions, replace bytecode address with mock if matched. + if let Some(mocks) = cheatcodes.mocked_functions.get(&call.target_address) { + // Check if any mock function set for call data or if catch-all mock function set + // for selector. + if let Some(target) = mocks + .get(&call.input) + .or_else(|| call.input.get(..4).and_then(|selector| mocks.get(selector))) + { + call.bytecode_address = *target; + } + } + if let Some(output) = cheatcodes.call_with_executor(ecx, call, self.inner) { if output.result.result != InstructionResult::Continue { ecx.journaled_state.depth -= self.in_inner_context as usize; diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 2bbbee90289cd..a60602cbc1cc6 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -7,14 +7,16 @@ use crate::{ TEST_DATA_MULTI_VERSION, }, }; +use alloy_primitives::U256; use foundry_config::{fs_permissions::PathPermission, FsPermissions}; use foundry_test_utils::Filter; -/// Executes all cheat code tests but not fork cheat codes or tests that require isolation mode +/// Executes all cheat code tests but not fork cheat codes or tests that require isolation mode or +/// specific seed. async fn test_cheats_local(test_data: &ForgeTestData) { let mut filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}*")) .exclude_paths("Fork") - .exclude_contracts("Isolated"); + .exclude_contracts("(Isolated|WithSeed)"); // Exclude FFI tests on Windows because no `echo`, and file tests that expect certain file paths if cfg!(windows) { @@ -22,7 +24,7 @@ async fn test_cheats_local(test_data: &ForgeTestData) { } if cfg!(feature = "isolate-by-default") { - filter = filter.exclude_contracts("LastCallGasDefaultTest"); + filter = filter.exclude_contracts("(LastCallGasDefaultTest|MockFunctionTest|WithSeed)"); } let mut config = test_data.config.clone(); @@ -32,7 +34,7 @@ async fn test_cheats_local(test_data: &ForgeTestData) { TestConfig::with_filter(runner, filter).run().await; } -/// Executes subset of all cheat code tests in isolation mode +/// Executes subset of all cheat code tests in isolation mode. async fn test_cheats_local_isolated(test_data: &ForgeTestData) { let filter = Filter::new(".*", ".*(Isolated)", &format!(".*cheats{RE_PATH_SEPARATOR}*")); @@ -43,6 +45,17 @@ async fn test_cheats_local_isolated(test_data: &ForgeTestData) { TestConfig::with_filter(runner, filter).run().await; } +/// Executes subset of all cheat code tests using a specific seed. +async fn test_cheats_local_with_seed(test_data: &ForgeTestData) { + let filter = Filter::new(".*", ".*(WithSeed)", &format!(".*cheats{RE_PATH_SEPARATOR}*")); + + let mut config = test_data.config.clone(); + config.fuzz.seed = Some(U256::from(100)); + let runner = test_data.runner_with_config(config); + + TestConfig::with_filter(runner, filter).run().await; +} + #[tokio::test(flavor = "multi_thread")] async fn test_cheats_local_default() { test_cheats_local(&TEST_DATA_DEFAULT).await @@ -53,6 +66,11 @@ async fn test_cheats_local_default_isolated() { test_cheats_local_isolated(&TEST_DATA_DEFAULT).await } +#[tokio::test(flavor = "multi_thread")] +async fn test_cheats_local_default_with_seed() { + test_cheats_local_with_seed(&TEST_DATA_DEFAULT).await +} + #[tokio::test(flavor = "multi_thread")] async fn test_cheats_local_multi_version() { test_cheats_local(&TEST_DATA_MULTI_VERSION).await diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 5b6750237addb..edc7dad3249ea 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -162,6 +162,7 @@ interface Vm { function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address); function cool(address target) external; function copyFile(string calldata from, string calldata to) external returns (uint64 copied); + function copyStorage(address from, address to) external; function createDir(string calldata path, bool recursive) external; function createFork(string calldata urlOrAlias) external returns (uint256 forkId); function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId); @@ -275,6 +276,7 @@ interface Vm { function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; function mockCall(address callee, bytes calldata data, bytes calldata returnData) external; function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; + function mockFunction(address callee, address target, bytes calldata data) external; function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue); function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue); @@ -385,6 +387,7 @@ interface Vm { 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; function setNonce(address account, uint64 newNonce) external; diff --git a/testdata/default/cheats/ArbitraryStorage.t.sol b/testdata/default/cheats/ArbitraryStorage.t.sol new file mode 100644 index 0000000000000..86910279e98e0 --- /dev/null +++ b/testdata/default/cheats/ArbitraryStorage.t.sol @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Counter { + uint256 public a; + address public b; + int8 public c; + address[] public owners; + + function setA(uint256 _a) public { + a = _a; + } + + function setB(address _b) public { + b = _b; + } + + function getOwner(uint256 pos) public view returns (address) { + return owners[pos]; + } + + function setOwner(uint256 pos, address owner) public { + owners[pos] = owner; + } +} + +contract CounterArbitraryStorageWithSeedTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + function test_fresh_storage() public { + uint256 index = 55; + Counter counter = new Counter(); + vm.setArbitraryStorage(address(counter)); + // Next call would fail with array out of bounds without arbitrary storage. + address owner = counter.getOwner(index); + // Subsequent calls should retrieve same value + assertEq(counter.getOwner(index), owner); + // Change slot and make sure new value retrieved + counter.setOwner(index, address(111)); + assertEq(counter.getOwner(index), address(111)); + } + + function test_arbitrary_storage_warm() public { + Counter counter = new Counter(); + vm.setArbitraryStorage(address(counter)); + assertGt(counter.a(), 0); + counter.setA(0); + // This should remain 0 if explicitly set. + assertEq(counter.a(), 0); + counter.setA(11); + assertEq(counter.a(), 11); + } + + function test_arbitrary_storage_multiple_read_writes() public { + Counter counter = new Counter(); + vm.setArbitraryStorage(address(counter)); + uint256 slot1 = vm.randomUint(0, 100); + uint256 slot2 = vm.randomUint(0, 100); + require(slot1 != slot2, "random positions should be different"); + address alice = counter.owners(slot1); + address bob = counter.owners(slot2); + require(alice != bob, "random storage values should be different"); + counter.setOwner(slot1, bob); + counter.setOwner(slot2, alice); + assertEq(alice, counter.owners(slot2)); + assertEq(bob, counter.owners(slot1)); + } +} + +contract AContract { + uint256[] public a; + address[] public b; + int8[] public c; + bytes32[] public d; +} + +contract AContractArbitraryStorageWithSeedTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + function test_arbitrary_storage_with_seed() public { + AContract target = new AContract(); + vm.setArbitraryStorage(address(target)); + assertEq(target.a(11), 85286582241781868037363115933978803127245343755841464083427462398552335014708); + assertEq(target.b(22), 0x939180Daa938F9e18Ff0E76c112D25107D358B02); + assertEq(target.c(33), -104); + assertEq(target.d(44), 0x6c178fa9c434f142df61a5355cc2b8d07be691b98dabf5b1a924f2bce97a19c7); + } +} + +contract SymbolicStore { + uint256 public testNumber = 1337; // slot 0 + + constructor() {} +} + +contract SymbolicStorageWithSeedTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + function test_SymbolicStorage() public { + uint256 slot = vm.randomUint(0, 100); + address addr = 0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8; + vm.setArbitraryStorage(addr); + bytes32 value = vm.load(addr, bytes32(slot)); + assertEq(uint256(value), 85286582241781868037363115933978803127245343755841464083427462398552335014708); + // Load slot again and make sure we get same value. + bytes32 value1 = vm.load(addr, bytes32(slot)); + assertEq(uint256(value), uint256(value1)); + } + + function test_SymbolicStorage1() public { + uint256 slot = vm.randomUint(0, 100); + SymbolicStore myStore = new SymbolicStore(); + vm.setArbitraryStorage(address(myStore)); + bytes32 value = vm.load(address(myStore), bytes32(uint256(slot))); + assertEq(uint256(value), 85286582241781868037363115933978803127245343755841464083427462398552335014708); + } + + function testEmptyInitialStorage(uint256 slot) public { + bytes32 storage_value = vm.load(address(vm), bytes32(slot)); + assertEq(uint256(storage_value), 0); + } +} diff --git a/testdata/default/cheats/CopyStorage.t.sol b/testdata/default/cheats/CopyStorage.t.sol new file mode 100644 index 0000000000000..89584749745ea --- /dev/null +++ b/testdata/default/cheats/CopyStorage.t.sol @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Counter { + uint256 public a; + address public b; + int256[] public c; + + function setA(uint256 _a) public { + a = _a; + } + + function setB(address _b) public { + b = _b; + } +} + +contract CounterWithSeedTest is DSTest { + Counter public counter; + Counter public counter1; + Vm vm = Vm(HEVM_ADDRESS); + + function test_copy_storage() public { + counter = new Counter(); + counter.setA(1000); + counter.setB(address(27)); + counter1 = new Counter(); + counter1.setA(11); + counter1.setB(address(50)); + + assertEq(counter.a(), 1000); + assertEq(counter.b(), address(27)); + assertEq(counter1.a(), 11); + assertEq(counter1.b(), address(50)); + vm.copyStorage(address(counter), address(counter1)); + assertEq(counter.a(), 1000); + assertEq(counter.b(), address(27)); + assertEq(counter1.a(), 1000); + assertEq(counter1.b(), address(27)); + } + + function test_copy_storage_from_arbitrary() public { + counter = new Counter(); + counter1 = new Counter(); + vm.setArbitraryStorage(address(counter)); + vm.copyStorage(address(counter), address(counter1)); + + // Make sure untouched storage has same values. + assertEq(counter.a(), counter1.a()); + assertEq(counter.b(), counter1.b()); + assertEq(counter.c(33), counter1.c(33)); + + // Change storage in source storage contract and make sure copy is not changed. + counter.setA(1000); + counter1.setB(address(50)); + assertEq(counter.a(), 1000); + assertEq(counter1.a(), 40426841063417815470953489044557166618267862781491517122018165313568904172524); + assertEq(counter.b(), 0x485E9Cc0ef187E54A3AB45b50c3DcE43f2C223B1); + assertEq(counter1.b(), address(50)); + } +} + +contract CopyStorageContract { + uint256 public x; +} + +contract CopyStorageTest is DSTest { + CopyStorageContract csc_1; + CopyStorageContract csc_2; + CopyStorageContract csc_3; + Vm vm = Vm(HEVM_ADDRESS); + + function _storeUInt256(address contractAddress, uint256 slot, uint256 value) internal { + vm.store(contractAddress, bytes32(slot), bytes32(value)); + } + + function setUp() public { + csc_1 = new CopyStorageContract(); + csc_2 = new CopyStorageContract(); + csc_3 = new CopyStorageContract(); + } + + function test_copy_storage() public { + // Make the storage of first contract symbolic + vm.setArbitraryStorage(address(csc_1)); + // and explicitly put a constrained symbolic value into the slot for `x` + uint256 x_1 = vm.randomUint(); + _storeUInt256(address(csc_1), 0, x_1); + // `x` of second contract is uninitialized + assert(csc_2.x() == 0); + // Copy storage from first to second contract + vm.copyStorage(address(csc_1), address(csc_2)); + // `x` of second contract is now the `x` of the first + assert(csc_2.x() == x_1); + } + + function test_copy_storage_same_values_on_load() public { + // Make the storage of first contract symbolic + vm.setArbitraryStorage(address(csc_1)); + vm.copyStorage(address(csc_1), address(csc_2)); + uint256 slot1 = vm.randomUint(0, 100); + uint256 slot2 = vm.randomUint(0, 100); + bytes32 value1 = vm.load(address(csc_1), bytes32(slot1)); + bytes32 value2 = vm.load(address(csc_1), bytes32(slot2)); + + bytes32 value3 = vm.load(address(csc_2), bytes32(slot1)); + bytes32 value4 = vm.load(address(csc_2), bytes32(slot2)); + + // Check storage values are the same for both source and target contracts. + assertEq(value1, value3); + assertEq(value2, value4); + } + + function test_copy_storage_consistent_values() public { + // Make the storage of first contract symbolic. + vm.setArbitraryStorage(address(csc_1)); + // Copy arbitrary storage to 2 contracts. + vm.copyStorage(address(csc_1), address(csc_2)); + vm.copyStorage(address(csc_1), address(csc_3)); + uint256 slot1 = vm.randomUint(0, 100); + uint256 slot2 = vm.randomUint(0, 100); + + // Load slot 1 from 1st copied contract and slot2 from symbolic contract. + bytes32 value3 = vm.load(address(csc_2), bytes32(slot1)); + bytes32 value2 = vm.load(address(csc_1), bytes32(slot2)); + + bytes32 value1 = vm.load(address(csc_1), bytes32(slot1)); + bytes32 value4 = vm.load(address(csc_2), bytes32(slot2)); + + // Make sure same values for both copied and symbolic contract. + assertEq(value3, value1); + assertEq(value2, value4); + + uint256 x_1 = vm.randomUint(); + // Change slot1 of 1st copied contract. + _storeUInt256(address(csc_2), slot1, x_1); + value3 = vm.load(address(csc_2), bytes32(slot1)); + bytes32 value5 = vm.load(address(csc_3), bytes32(slot1)); + // Make sure value for 1st contract copied is different than symbolic contract value. + assert(value3 != value1); + // Make sure same values for 2nd contract copied and symbolic contract. + assertEq(value5, value1); + + uint256 x_2 = vm.randomUint(); + // Change slot2 of symbolic contract. + _storeUInt256(address(csc_1), slot2, x_2); + value2 = vm.load(address(csc_1), bytes32(slot2)); + bytes32 value6 = vm.load(address(csc_3), bytes32(slot2)); + // Make sure value for symbolic contract value is different than 1st contract copied. + assert(value2 != value4); + // Make sure value for symbolic contract value is different than 2nd contract copied. + assert(value2 != value6); + assertEq(value4, value6); + } +} diff --git a/testdata/default/cheats/MockFunction.t.sol b/testdata/default/cheats/MockFunction.t.sol new file mode 100644 index 0000000000000..9cf1004ca2795 --- /dev/null +++ b/testdata/default/cheats/MockFunction.t.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract MockFunctionContract { + uint256 public a; + + function mocked_function() public { + a = 321; + } + + function mocked_args_function(uint256 x) public { + a = 321 + x; + } +} + +contract ModelMockFunctionContract { + uint256 public a; + + function mocked_function() public { + a = 123; + } + + function mocked_args_function(uint256 x) public { + a = 123 + x; + } +} + +contract MockFunctionTest is DSTest { + MockFunctionContract my_contract; + ModelMockFunctionContract model_contract; + Vm vm = Vm(HEVM_ADDRESS); + + function setUp() public { + my_contract = new MockFunctionContract(); + model_contract = new ModelMockFunctionContract(); + } + + function test_mock_function() public { + vm.mockFunction( + address(my_contract), + address(model_contract), + abi.encodeWithSelector(MockFunctionContract.mocked_function.selector) + ); + my_contract.mocked_function(); + assertEq(my_contract.a(), 123); + } + + function test_mock_function_concrete_args() public { + vm.mockFunction( + address(my_contract), + address(model_contract), + abi.encodeWithSelector(MockFunctionContract.mocked_args_function.selector, 456) + ); + my_contract.mocked_args_function(456); + assertEq(my_contract.a(), 123 + 456); + my_contract.mocked_args_function(567); + assertEq(my_contract.a(), 321 + 567); + } + + function test_mock_function_all_args() public { + vm.mockFunction( + address(my_contract), + address(model_contract), + abi.encodeWithSelector(MockFunctionContract.mocked_args_function.selector) + ); + my_contract.mocked_args_function(678); + assertEq(my_contract.a(), 123 + 678); + my_contract.mocked_args_function(789); + assertEq(my_contract.a(), 123 + 789); + } +} From 32022238364879c050e91f5ad6de587dafa331bd Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:34:28 +0200 Subject: [PATCH 1433/1963] chore: add more size optimizations (#8847) --- .gitignore | 1 - Cargo.toml | 14 ++++++++++---- crates/evm/traces/src/debug/sources.rs | 22 +++++++++------------- crates/fmt/src/buffer.rs | 8 ++++++-- crates/fmt/src/formatter.rs | 11 ++++++++++- crates/forge/bin/cmd/test/mod.rs | 2 +- 6 files changed, 36 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 14e811f2d511f..19f666e451bf9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ out/ out.json .idea .vscode -bloat* diff --git a/Cargo.toml b/Cargo.toml index b05398538f156..fbf9be9b8d773 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,11 +121,17 @@ axum.opt-level = 3 # keystores scrypt.opt-level = 3 -# Override packages which aren't perf-sensitive for faster compilation speed. +# Override packages which aren't perf-sensitive for faster compilation speed and smaller binary size. [profile.release.package] -mdbook.opt-level = 1 -protobuf.opt-level = 1 -trezor-client.opt-level = 1 +alloy-sol-macro-expander.opt-level = "z" +html5ever.opt-level = "z" +mdbook.opt-level = "z" +prettyplease.opt-level = "z" +protobuf.opt-level = "z" +pulldown-cmark.opt-level = "z" +syn-solidity.opt-level = "z" +syn.opt-level = "z" +trezor-client.opt-level = "z" [workspace.dependencies] anvil = { path = "crates/anvil" } diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index feb87038190bb..5087a06f39dbb 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -124,7 +124,7 @@ impl ContractSources { /// Collects the contract sources and artifacts from the project compile output. pub fn from_project_output( output: &ProjectCompileOutput, - root: impl AsRef, + root: &Path, libraries: Option<&Libraries>, ) -> Result { let mut sources = Self::default(); @@ -135,13 +135,12 @@ impl ContractSources { pub fn insert( &mut self, output: &ProjectCompileOutput, - root: impl AsRef, + root: &Path, libraries: Option<&Libraries>, ) -> Result<()> where C::Language: Into, { - let root = root.as_ref(); let link_data = libraries.map(|libraries| { let linker = Linker::new(root, output.artifact_ids().collect()); (linker, libraries) @@ -152,16 +151,16 @@ impl ContractSources { .collect::>() .par_iter() .map(|(id, artifact)| { - let mut artifacts = Vec::new(); + let mut new_artifact = None; if let Some(file_id) = artifact.id { let artifact = if let Some((linker, libraries)) = link_data.as_ref() { - linker.link(id, libraries)?.into_contract_bytecode() + linker.link(id, libraries)? } else { - (*artifact).clone().into_contract_bytecode() + artifact.get_contract_bytecode() }; let bytecode = compact_to_contract(artifact.into_contract_bytecode())?; - artifacts.push(( + new_artifact = Some(( id.name.clone(), ArtifactData::new(bytecode, id.build_id.clone(), file_id)?, )); @@ -169,14 +168,11 @@ impl ContractSources { warn!(id = id.identifier(), "source not found"); }; - Ok(artifacts) + Ok(new_artifact) }) - .collect::>>()? - .into_iter() - .flatten() - .collect(); + .collect::>>()?; - for (name, artifact) in artifacts { + for (name, artifact) in artifacts.into_iter().flatten() { self.artifacts_by_name.entry(name).or_default().push(artifact); } diff --git a/crates/fmt/src/buffer.rs b/crates/fmt/src/buffer.rs index 8d62a70f9881e..b09e9e620df3c 100644 --- a/crates/fmt/src/buffer.rs +++ b/crates/fmt/src/buffer.rs @@ -165,7 +165,11 @@ impl FormatBuffer { /// Write a raw string to the buffer. This will ignore indents and remove the indents of the /// written string to match the current base indent of this buffer if it is a temp buffer pub fn write_raw(&mut self, s: impl AsRef) -> std::fmt::Result { - let mut lines = s.as_ref().lines().peekable(); + self._write_raw(s.as_ref()) + } + + fn _write_raw(&mut self, s: &str) -> std::fmt::Result { + let mut lines = s.lines().peekable(); let mut comment_state = self.state.comment_state(); while let Some(line) = lines.next() { // remove the whitespace that covered by the base indent length (this is normally the @@ -187,7 +191,7 @@ impl FormatBuffer { self.last_char = trimmed_line.chars().next_back(); self.state = WriteState::WriteTokens(comment_state); } - if lines.peek().is_some() || s.as_ref().ends_with('\n') { + if lines.peek().is_some() || s.ends_with('\n') { if self.restrict_to_single_line { return Err(std::fmt::Error) } diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index a44aa697ccb02..2ae083e5db48c 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -370,7 +370,16 @@ impl<'a, W: Write> Formatter<'a, W> { &mut self, byte_offset: usize, next_byte_offset: Option, - fun: impl FnMut(&mut Self) -> Result<()>, + mut fun: impl FnMut(&mut Self) -> Result<()>, + ) -> Result { + self.chunked_mono(byte_offset, next_byte_offset, &mut fun) + } + + fn chunked_mono( + &mut self, + byte_offset: usize, + next_byte_offset: Option, + fun: &mut dyn FnMut(&mut Self) -> Result<()>, ) -> Result { let postfixes_before = self.comments.remove_postfixes_before(byte_offset); let prefixes = self.comments.remove_prefixes_before(byte_offset); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1cc647b0cb8af..669413d7849ad 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -531,7 +531,7 @@ impl TestArgs { if self.decode_internal.is_some() { let sources = - ContractSources::from_project_output(output, &config.root, Some(&libraries))?; + ContractSources::from_project_output(output, &config.root.0, Some(&libraries))?; builder = builder.with_debug_identifier(DebugTraceIdentifier::new(sources)); } let mut decoder = builder.build(); From 0c79ab590b6a9d3dcb7e0e407811c76339009eca Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:45:58 +0300 Subject: [PATCH 1434/1963] fix(test): increment nonce for calls too when isolate (#8854) --- crates/evm/evm/src/inspectors/stack.rs | 30 +------------------------- testdata/default/cheats/Nonce.t.sol | 30 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 29 deletions(-) create mode 100644 testdata/default/cheats/Nonce.t.sol diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 3df8dc8f01dab..30271910b95b5 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -257,15 +257,8 @@ pub struct InspectorData { /// non-isolated mode. For descriptions and workarounds for those changes see: #[derive(Debug, Clone)] pub struct InnerContextData { - /// The sender of the inner EVM context. - /// It is also an origin of the transaction that created the inner EVM context. - sender: Address, - /// Nonce of the sender before invocation of the inner EVM context. - original_sender_nonce: u64, /// Origin of the transaction in the outer EVM context. original_origin: Address, - /// Whether the inner context was created by a CREATE transaction. - is_create: bool, } /// An inspector that calls multiple inspectors in sequence. @@ -490,14 +483,6 @@ impl<'a> InspectorStackRefMut<'a> { fn adjust_evm_data_for_inner_context(&mut self, ecx: &mut EvmContext) { let inner_context_data = self.inner_context_data.as_ref().expect("should be called in inner context"); - let sender_acc = ecx - .journaled_state - .state - .get_mut(&inner_context_data.sender) - .expect("failed to load sender"); - if !inner_context_data.is_create { - sender_acc.info.nonce = inner_context_data.original_sender_nonce; - } ecx.env.tx.caller = inner_context_data.original_origin; } @@ -541,13 +526,6 @@ impl<'a> InspectorStackRefMut<'a> { ecx.db.commit(ecx.journaled_state.state.clone()); - let nonce = ecx - .journaled_state - .load_account(caller, &mut ecx.db) - .expect("failed to load caller") - .info - .nonce; - let cached_env = ecx.env.clone(); ecx.env.block.basefee = U256::ZERO; @@ -555,7 +533,6 @@ impl<'a> InspectorStackRefMut<'a> { ecx.env.tx.transact_to = transact_to; ecx.env.tx.data = input; ecx.env.tx.value = value; - ecx.env.tx.nonce = Some(nonce); // Add 21000 to the gas limit to account for the base cost of transaction. ecx.env.tx.gas_limit = gas_limit + 21000; // If we haven't disabled gas limit checks, ensure that transaction gas limit will not @@ -566,12 +543,7 @@ impl<'a> InspectorStackRefMut<'a> { } ecx.env.tx.gas_price = U256::ZERO; - self.inner_context_data = Some(InnerContextData { - sender: ecx.env.tx.caller, - original_origin: cached_env.tx.caller, - original_sender_nonce: nonce, - is_create: matches!(transact_to, TxKind::Create), - }); + self.inner_context_data = Some(InnerContextData { original_origin: cached_env.tx.caller }); self.in_inner_context = true; let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); diff --git a/testdata/default/cheats/Nonce.t.sol b/testdata/default/cheats/Nonce.t.sol new file mode 100644 index 0000000000000..5dd8b0c6a268a --- /dev/null +++ b/testdata/default/cheats/Nonce.t.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Counter { + uint256 public count; + + function increment() public { + count += 1; + } +} + +contract NonceIsolatedTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testIncrementNonce() public { + address bob = address(14); + vm.startPrank(bob); + Counter counter = new Counter(); + assertEq(vm.getNonce(bob), 1); + counter.increment(); + assertEq(vm.getNonce(bob), 2); + new Counter(); + assertEq(vm.getNonce(bob), 3); + counter.increment(); + assertEq(vm.getNonce(bob), 4); + } +} From fb9dbba4ed81321557a68053f845ca6ea46b6ba1 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 12 Sep 2024 20:21:17 +0400 Subject: [PATCH 1435/1963] Revert "fix(test): increment nonce for calls too when isolate" (#8855) Revert "fix(test): increment nonce for calls too when isolate (#8854)" This reverts commit 0c79ab590b6a9d3dcb7e0e407811c76339009eca. --- crates/evm/evm/src/inspectors/stack.rs | 30 +++++++++++++++++++++++++- testdata/default/cheats/Nonce.t.sol | 30 -------------------------- 2 files changed, 29 insertions(+), 31 deletions(-) delete mode 100644 testdata/default/cheats/Nonce.t.sol diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 30271910b95b5..3df8dc8f01dab 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -257,8 +257,15 @@ pub struct InspectorData { /// non-isolated mode. For descriptions and workarounds for those changes see: #[derive(Debug, Clone)] pub struct InnerContextData { + /// The sender of the inner EVM context. + /// It is also an origin of the transaction that created the inner EVM context. + sender: Address, + /// Nonce of the sender before invocation of the inner EVM context. + original_sender_nonce: u64, /// Origin of the transaction in the outer EVM context. original_origin: Address, + /// Whether the inner context was created by a CREATE transaction. + is_create: bool, } /// An inspector that calls multiple inspectors in sequence. @@ -483,6 +490,14 @@ impl<'a> InspectorStackRefMut<'a> { fn adjust_evm_data_for_inner_context(&mut self, ecx: &mut EvmContext) { let inner_context_data = self.inner_context_data.as_ref().expect("should be called in inner context"); + let sender_acc = ecx + .journaled_state + .state + .get_mut(&inner_context_data.sender) + .expect("failed to load sender"); + if !inner_context_data.is_create { + sender_acc.info.nonce = inner_context_data.original_sender_nonce; + } ecx.env.tx.caller = inner_context_data.original_origin; } @@ -526,6 +541,13 @@ impl<'a> InspectorStackRefMut<'a> { ecx.db.commit(ecx.journaled_state.state.clone()); + let nonce = ecx + .journaled_state + .load_account(caller, &mut ecx.db) + .expect("failed to load caller") + .info + .nonce; + let cached_env = ecx.env.clone(); ecx.env.block.basefee = U256::ZERO; @@ -533,6 +555,7 @@ impl<'a> InspectorStackRefMut<'a> { ecx.env.tx.transact_to = transact_to; ecx.env.tx.data = input; ecx.env.tx.value = value; + ecx.env.tx.nonce = Some(nonce); // Add 21000 to the gas limit to account for the base cost of transaction. ecx.env.tx.gas_limit = gas_limit + 21000; // If we haven't disabled gas limit checks, ensure that transaction gas limit will not @@ -543,7 +566,12 @@ impl<'a> InspectorStackRefMut<'a> { } ecx.env.tx.gas_price = U256::ZERO; - self.inner_context_data = Some(InnerContextData { original_origin: cached_env.tx.caller }); + self.inner_context_data = Some(InnerContextData { + sender: ecx.env.tx.caller, + original_origin: cached_env.tx.caller, + original_sender_nonce: nonce, + is_create: matches!(transact_to, TxKind::Create), + }); self.in_inner_context = true; let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); diff --git a/testdata/default/cheats/Nonce.t.sol b/testdata/default/cheats/Nonce.t.sol deleted file mode 100644 index 5dd8b0c6a268a..0000000000000 --- a/testdata/default/cheats/Nonce.t.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; - -import "ds-test/test.sol"; -import "cheats/Vm.sol"; - -contract Counter { - uint256 public count; - - function increment() public { - count += 1; - } -} - -contract NonceIsolatedTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - function testIncrementNonce() public { - address bob = address(14); - vm.startPrank(bob); - Counter counter = new Counter(); - assertEq(vm.getNonce(bob), 1); - counter.increment(); - assertEq(vm.getNonce(bob), 2); - new Counter(); - assertEq(vm.getNonce(bob), 3); - counter.increment(); - assertEq(vm.getNonce(bob), 4); - } -} From c6d342def10db104500e3295b1c2e5582491bd61 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:30:57 +0200 Subject: [PATCH 1436/1963] test: use alchemy for arbitrum URLs (#8859) --- crates/anvil/tests/it/fork.rs | 8 ++++---- crates/cast/src/lib.rs | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index d8465ec5cacee..ad2ed1e04bbb5 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1156,7 +1156,7 @@ async fn test_arbitrum_fork_dev_balance() { let (api, handle) = spawn( fork_config() .with_fork_block_number(None::) - .with_eth_rpc_url(Some("https://arb1.arbitrum.io/rpc".to_string())), + .with_eth_rpc_url(Some(next_rpc_endpoint(NamedChain::Arbitrum))), ) .await; @@ -1174,7 +1174,7 @@ async fn test_arbitrum_fork_block_number() { let (_, handle) = spawn( fork_config() .with_fork_block_number(None::) - .with_eth_rpc_url(Some("https://arb1.arbitrum.io/rpc".to_string())), + .with_eth_rpc_url(Some(next_rpc_endpoint(NamedChain::Arbitrum))), ) .await; let provider = handle.http_provider(); @@ -1186,7 +1186,7 @@ async fn test_arbitrum_fork_block_number() { let (api, _) = spawn( fork_config() .with_fork_block_number(Some(initial_block_number)) - .with_eth_rpc_url(Some("https://arb1.arbitrum.io/rpc".to_string())), + .with_eth_rpc_url(Some(next_rpc_endpoint(NamedChain::Arbitrum))), ) .await; let block_number = api.block_number().unwrap().to::(); @@ -1212,7 +1212,7 @@ async fn test_arbitrum_fork_block_number() { // reset fork to different block number and compare with block returned by `eth_blockNumber` api.anvil_reset(Some(Forking { - json_rpc_url: Some("https://arb1.arbitrum.io/rpc".to_string()), + json_rpc_url: Some(next_rpc_endpoint(NamedChain::Arbitrum)), block_number: Some(initial_block_number - 2), })) .await diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 73ab5b28bda19..8132f8e4f706c 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1648,12 +1648,10 @@ impl SimpleCast { /// ``` pub fn abi_encode(sig: &str, args: &[impl AsRef]) -> Result { let func = get_func(sig)?; - let calldata = match encode_function_args(&func, args) { - Ok(res) => hex::encode(res), + match encode_function_args(&func, args) { + Ok(res) => Ok(hex::encode_prefixed(&res[4..])), Err(e) => eyre::bail!("Could not ABI encode the function and arguments. Did you pass in the right types?\nError\n{}", e), - }; - let encoded = &calldata[8..]; - Ok(format!("0x{encoded}")) + } } /// Performs packed ABI encoding based off of the function signature or tuple. From 2cdbfaca634b284084d0f86357623aef7a0d2ce3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:57:00 +0200 Subject: [PATCH 1437/1963] feat: add support for test skip reasons (#8858) --- crates/cheatcodes/assets/cheatcodes.json | 24 ++- crates/cheatcodes/spec/src/vm.rs | 6 +- crates/cheatcodes/src/test.rs | 13 +- crates/evm/core/src/constants.rs | 2 +- crates/evm/core/src/decode.rs | 57 +++++- crates/evm/evm/src/executors/fuzz/mod.rs | 45 +++-- .../evm/evm/src/executors/invariant/error.rs | 6 +- crates/evm/evm/src/executors/mod.rs | 20 +- crates/evm/fuzz/src/error.rs | 9 +- crates/evm/fuzz/src/lib.rs | 2 + crates/forge/src/result.rs | 69 ++++--- crates/forge/src/runner.rs | 12 +- crates/forge/tests/cli/script.rs | 13 +- crates/forge/tests/cli/test_cmd.rs | 182 ++++++++++++------ crates/forge/tests/fixtures/ScriptVerify.sol | 2 +- crates/forge/tests/it/fuzz.rs | 2 +- crates/forge/tests/it/invariant.rs | 2 +- crates/test-utils/src/util.rs | 4 +- testdata/cheats/Vm.sol | 1 + 19 files changed, 308 insertions(+), 163 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index da501a11ed685..567167e215dbb 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -8113,8 +8113,8 @@ }, { "func": { - "id": "skip", - "description": "Marks a test as skipped. Must be called at the top of the test.", + "id": "skip_0", + "description": "Marks a test as skipped. Must be called at the top level of a test.", "declaration": "function skip(bool skipTest) external;", "visibility": "external", "mutability": "", @@ -8131,6 +8131,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "skip_1", + "description": "Marks a test as skipped with a reason. Must be called at the top level of a test.", + "declaration": "function skip(bool skipTest, string calldata reason) external;", + "visibility": "external", + "mutability": "", + "signature": "skip(bool,string)", + "selector": "0xc42a80a7", + "selectorBytes": [ + 196, + 42, + 128, + 167 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "sleep", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index d0a921485c7f9..49aeaa211cea6 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -843,10 +843,14 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectSafeMemoryCall(uint64 min, uint64 max) external; - /// Marks a test as skipped. Must be called at the top of the test. + /// Marks a test as skipped. Must be called at the top level of a test. #[cheatcode(group = Testing, safety = Unsafe)] function skip(bool skipTest) external; + /// Marks a test as skipped with a reason. Must be called at the top level of a test. + #[cheatcode(group = Testing, safety = Unsafe)] + function skip(bool skipTest, string calldata reason) external; + /// Asserts that the given condition is true. #[cheatcode(group = Testing, safety = Safe)] function assertTrue(bool condition) external pure; diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 0945f37a89c2a..cc91dba45b23d 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -70,14 +70,21 @@ impl Cheatcode for sleepCall { } } -impl Cheatcode for skipCall { +impl Cheatcode for skip_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { skipTest } = *self; - if skipTest { + skip_1Call { skipTest, reason: String::new() }.apply_stateful(ccx) + } +} + +impl Cheatcode for skip_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { skipTest, reason } = self; + if *skipTest { // Skip should not work if called deeper than at test level. // Since we're not returning the magic skip bytes, this will cause a test failure. ensure!(ccx.ecx.journaled_state.depth() <= 1, "`skip` can only be used at test level"); - Err(MAGIC_SKIP.into()) + Err([MAGIC_SKIP, reason.as_bytes()].concat().into()) } else { Ok(Default::default()) } diff --git a/crates/evm/core/src/constants.rs b/crates/evm/core/src/constants.rs index 5e49a01e7b143..70c7441d20a77 100644 --- a/crates/evm/core/src/constants.rs +++ b/crates/evm/core/src/constants.rs @@ -34,7 +34,7 @@ pub const TEST_CONTRACT_ADDRESS: Address = address!("b4c79daB8f259C7Aee6E5b2Aa72 /// Magic return value returned by the `assume` cheatcode. pub const MAGIC_ASSUME: &[u8] = b"FOUNDRY::ASSUME"; -/// Magic return value returned by the `skip` cheatcode. +/// Magic return value returned by the `skip` cheatcode. Optionally appended with a reason. pub const MAGIC_SKIP: &[u8] = b"FOUNDRY::SKIP"; /// The address that deploys the default CREATE2 deployer contract. diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 29f448bcebd58..b777ec4537bba 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -9,7 +9,39 @@ use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; use rustc_hash::FxHashMap; -use std::sync::OnceLock; +use std::{fmt, sync::OnceLock}; + +/// A skip reason. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct SkipReason(pub Option); + +impl SkipReason { + /// Decodes a skip reason, if any. + pub fn decode(raw_result: &[u8]) -> Option { + raw_result.strip_prefix(crate::constants::MAGIC_SKIP).map(|reason| { + let reason = String::from_utf8_lossy(reason).into_owned(); + Self((!reason.is_empty()).then_some(reason)) + }) + } + + /// Decodes a skip reason from a string that was obtained by formatting `Self`. + /// + /// This is a hack to support re-decoding a skip reason in proptest. + pub fn decode_self(s: &str) -> Option { + s.strip_prefix("skipped").map(|rest| Self(rest.strip_prefix(": ").map(ToString::to_string))) + } +} + +impl fmt::Display for SkipReason { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("skipped")?; + if let Some(reason) = &self.0 { + f.write_str(": ")?; + f.write_str(reason)?; + } + Ok(()) + } +} /// Decode a set of logs, only returning logs from DSTest logging events and Hardhat's `console.log` pub fn decode_console_logs(logs: &[Log]) -> Vec { @@ -120,9 +152,8 @@ impl RevertDecoder { }; } - if err == crate::constants::MAGIC_SKIP { - // Also used in forge fuzz runner - return Some("SKIPPED".to_string()); + if let Some(reason) = SkipReason::decode(err) { + return Some(reason.to_string()); } // Solidity's `Error(string)` or `Panic(uint256)` @@ -177,11 +208,17 @@ impl RevertDecoder { } // Generic custom error. - Some(format!( - "custom error {}:{}", - hex::encode(selector), - std::str::from_utf8(data).map_or_else(|_| trimmed_hex(data), String::from) - )) + Some({ + let mut s = format!("custom error {}", hex::encode_prefixed(selector)); + if !data.is_empty() { + s.push_str(": "); + match std::str::from_utf8(data) { + Ok(data) => s.push_str(data), + Err(_) => s.push_str(&trimmed_hex(data)), + } + } + s + }) } } @@ -194,7 +231,7 @@ fn trimmed_hex(s: &[u8]) -> String { "{}…{} ({} bytes)", &hex::encode(&s[..n / 2]), &hex::encode(&s[s.len() - n / 2..]), - s.len() + s.len(), ) } } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 7fa5498bfcab6..ee5a03dca541d 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -5,7 +5,10 @@ use alloy_primitives::{Address, Bytes, Log, U256}; use eyre::Result; use foundry_common::evm::Breakpoints; use foundry_config::FuzzConfig; -use foundry_evm_core::{constants::MAGIC_ASSUME, decode::RevertDecoder}; +use foundry_evm_core::{ + constants::MAGIC_ASSUME, + decode::{RevertDecoder, SkipReason}, +}; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::{ strategies::{fuzz_calldata, fuzz_calldata_from_state, EvmFuzzState}, @@ -131,9 +134,8 @@ impl FuzzedExecutor { }) => { // We cannot use the calldata returned by the test runner in `TestError::Fail`, // since that input represents the last run case, which may not correspond with - // our failure - when a fuzz case fails, proptest will try - // to run at least one more case to find a minimal failure - // case. + // our failure - when a fuzz case fails, proptest will try to run at least one + // more case to find a minimal failure case. let reason = rd.maybe_decode(&outcome.1.result, Some(status)); execution_data.borrow_mut().logs.extend(outcome.1.logs.clone()); execution_data.borrow_mut().counterexample = outcome; @@ -157,6 +159,7 @@ impl FuzzedExecutor { first_case: fuzz_result.first_case.unwrap_or_default(), gas_by_case: fuzz_result.gas_by_case, success: run_result.is_ok(), + skipped: false, reason: None, counterexample: None, logs: fuzz_result.logs, @@ -168,20 +171,22 @@ impl FuzzedExecutor { }; match run_result { - // Currently the only operation that can trigger proptest global rejects is the - // `vm.assume` cheatcode, thus we surface this info to the user when the fuzz test - // aborts due to too many global rejects, making the error message more actionable. - Err(TestError::Abort(reason)) if reason.message() == "Too many global rejects" => { - result.reason = Some( - FuzzError::TooManyRejects(self.runner.config().max_global_rejects).to_string(), - ); - } + Ok(()) => {} Err(TestError::Abort(reason)) => { - result.reason = Some(reason.to_string()); + let msg = reason.message(); + // Currently the only operation that can trigger proptest global rejects is the + // `vm.assume` cheatcode, thus we surface this info to the user when the fuzz test + // aborts due to too many global rejects, making the error message more actionable. + result.reason = if msg == "Too many global rejects" { + let error = FuzzError::TooManyRejects(self.runner.config().max_global_rejects); + Some(error.to_string()) + } else { + Some(msg.to_string()) + }; } Err(TestError::Fail(reason, _)) => { let reason = reason.to_string(); - result.reason = if reason.is_empty() { None } else { Some(reason) }; + result.reason = (!reason.is_empty()).then_some(reason); let args = if let Some(data) = calldata.get(4..) { func.abi_decode_input(data, false).unwrap_or_default() @@ -193,7 +198,13 @@ impl FuzzedExecutor { BaseCounterExample::from_fuzz_call(calldata, args, call.traces), )); } - _ => {} + } + + if let Some(reason) = &result.reason { + if let Some(reason) = SkipReason::decode_self(reason) { + result.skipped = true; + result.reason = reason.0; + } } state.log_stats(); @@ -212,9 +223,9 @@ impl FuzzedExecutor { let mut call = self .executor .call_raw(self.sender, address, calldata.clone(), U256::ZERO) - .map_err(|_| TestCaseError::fail(FuzzError::FailedContractCall))?; + .map_err(|e| TestCaseError::fail(e.to_string()))?; - // When the `assume` cheatcode is called it returns a special string + // Handle `vm.assume`. if call.result.as_ref() == MAGIC_ASSUME { return Err(TestCaseError::reject(FuzzError::AssumeReject)) } diff --git a/crates/evm/evm/src/executors/invariant/error.rs b/crates/evm/evm/src/executors/invariant/error.rs index b8cff9b1d3c4b..f5eef18ed7529 100644 --- a/crates/evm/evm/src/executors/invariant/error.rs +++ b/crates/evm/evm/src/executors/invariant/error.rs @@ -40,9 +40,9 @@ impl InvariantFuzzError { Self::BrokenInvariant(case_data) | Self::Revert(case_data) => { (!case_data.revert_reason.is_empty()).then(|| case_data.revert_reason.clone()) } - Self::MaxAssumeRejects(allowed) => Some(format!( - "The `vm.assume` cheatcode rejected too many inputs ({allowed} allowed)" - )), + Self::MaxAssumeRejects(allowed) => { + Some(format!("`vm.assume` rejected too many inputs ({allowed} allowed)")) + } } } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 44bc33e372c06..655418fadeb6d 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -19,7 +19,7 @@ use foundry_evm_core::{ CALLER, CHEATCODE_ADDRESS, CHEATCODE_CONTRACT_HASH, DEFAULT_CREATE2_DEPLOYER, DEFAULT_CREATE2_DEPLOYER_CODE, DEFAULT_CREATE2_DEPLOYER_DEPLOYER, }, - decode::RevertDecoder, + decode::{RevertDecoder, SkipReason}, utils::StateChangeset, }; use foundry_evm_coverage::HitMaps; @@ -649,15 +649,15 @@ impl std::ops::DerefMut for ExecutionErr { #[derive(Debug, thiserror::Error)] pub enum EvmError { - /// Error which occurred during execution of a transaction + /// Error which occurred during execution of a transaction. #[error(transparent)] Execution(#[from] Box), - /// Error which occurred during ABI encoding/decoding + /// Error which occurred during ABI encoding/decoding. #[error(transparent)] - AbiError(#[from] alloy_dyn_abi::Error), - /// Error caused which occurred due to calling the skip() cheatcode. - #[error("Skipped")] - SkipError, + Abi(#[from] alloy_dyn_abi::Error), + /// Error caused which occurred due to calling the `skip` cheatcode. + #[error("{_0}")] + Skip(SkipReason), /// Any other error. #[error(transparent)] Eyre(#[from] eyre::Error), @@ -671,7 +671,7 @@ impl From for EvmError { impl From for EvmError { fn from(err: alloy_sol_types::Error) -> Self { - Self::AbiError(err.into()) + Self::Abi(err.into()) } } @@ -769,8 +769,8 @@ impl Default for RawCallResult { impl RawCallResult { /// Converts the result of the call into an `EvmError`. pub fn into_evm_error(self, rd: Option<&RevertDecoder>) -> EvmError { - if self.result[..] == crate::constants::MAGIC_SKIP[..] { - return EvmError::SkipError; + if let Some(reason) = SkipReason::decode(&self.result) { + return EvmError::Skip(reason); } let reason = rd.unwrap_or_default().decode(&self.result, Some(self.exit_reason)); EvmError::Execution(Box::new(self.into_execution_error(reason))) diff --git a/crates/evm/fuzz/src/error.rs b/crates/evm/fuzz/src/error.rs index 1371f49692adf..8fc3c1897af65 100644 --- a/crates/evm/fuzz/src/error.rs +++ b/crates/evm/fuzz/src/error.rs @@ -1,16 +1,13 @@ -//! errors related to fuzz tests +//! Errors related to fuzz tests. + use proptest::test_runner::Reason; /// Possible errors when running fuzz tests #[derive(Debug, thiserror::Error)] pub enum FuzzError { - #[error("Couldn't call unknown contract")] - UnknownContract, - #[error("Failed contract call")] - FailedContractCall, #[error("`vm.assume` reject")] AssumeReject, - #[error("The `vm.assume` cheatcode rejected too many inputs ({0} allowed)")] + #[error("`vm.assume` rejected too many inputs ({0} allowed)")] TooManyRejects(u32), } diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 99232443b9cda..fe1cb38d08f4e 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -151,6 +151,8 @@ pub struct FuzzTestResult { /// properly, or that there was a revert and that the test was expected to fail /// (prefixed with `testFail`) pub success: bool, + /// Whether the test case was skipped. `reason` will contain the skip reason, if any. + pub skipped: bool, /// If there was a revert, this field will be populated. Note that the test can /// still be successful (i.e self.success == true) when it's expected to fail. diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index aa88bc4016fcf..be445d49165cf 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -9,6 +9,7 @@ use eyre::Report; use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ coverage::HitMaps, + decode::SkipReason, executors::{EvmError, RawCallResult}, fuzz::{CounterExample, FuzzCase, FuzzFixtures, FuzzTestResult}, traces::{CallTraceArena, CallTraceDecoder, TraceKind, Traces}, @@ -53,17 +54,17 @@ impl TestOutcome { /// Returns an iterator over all individual succeeding tests and their names. pub fn successes(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Success) + self.tests().filter(|(_, t)| t.status.is_success()) } /// Returns an iterator over all individual skipped tests and their names. pub fn skips(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Skipped) + self.tests().filter(|(_, t)| t.status.is_skipped()) } /// Returns an iterator over all individual failing tests and their names. pub fn failures(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Failure) + self.tests().filter(|(_, t)| t.status.is_failure()) } /// Returns an iterator over all individual tests and their names. @@ -221,17 +222,17 @@ impl SuiteResult { /// Returns an iterator over all individual succeeding tests and their names. pub fn successes(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Success) + self.tests().filter(|(_, t)| t.status.is_success()) } /// Returns an iterator over all individual skipped tests and their names. pub fn skips(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Skipped) + self.tests().filter(|(_, t)| t.status.is_skipped()) } /// Returns an iterator over all individual failing tests and their names. pub fn failures(&self) -> impl Iterator { - self.tests().filter(|(_, t)| t.status == TestStatus::Failure) + self.tests().filter(|(_, t)| t.status.is_failure()) } /// Returns the number of tests that passed. @@ -395,29 +396,39 @@ impl fmt::Display for TestResult { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.status { TestStatus::Success => "[PASS]".green().fmt(f), - TestStatus::Skipped => "[SKIP]".yellow().fmt(f), + TestStatus::Skipped => { + let mut s = String::from("[SKIP"); + if let Some(reason) = &self.reason { + write!(s, ": {reason}").unwrap(); + } + s.push(']'); + s.yellow().fmt(f) + } TestStatus::Failure => { - let mut s = String::from("[FAIL. Reason: "); - - let reason = self.reason.as_deref().unwrap_or("assertion failed"); - s.push_str(reason); + let mut s = String::from("[FAIL"); + if self.reason.is_some() || self.counterexample.is_some() { + if let Some(reason) = &self.reason { + write!(s, ": {reason}").unwrap(); + } - if let Some(counterexample) = &self.counterexample { - match counterexample { - CounterExample::Single(ex) => { - write!(s, "; counterexample: {ex}]").unwrap(); - } - CounterExample::Sequence(sequence) => { - s.push_str("]\n\t[Sequence]\n"); - for ex in sequence { - writeln!(s, "\t\t{ex}").unwrap(); + if let Some(counterexample) = &self.counterexample { + match counterexample { + CounterExample::Single(ex) => { + write!(s, "; counterexample: {ex}]").unwrap(); + } + CounterExample::Sequence(sequence) => { + s.push_str("]\n\t[Sequence]\n"); + for ex in sequence { + writeln!(s, "\t\t{ex}").unwrap(); + } } } + } else { + s.push(']'); } } else { s.push(']'); } - s.red().fmt(f) } } @@ -455,8 +466,9 @@ impl TestResult { } /// Returns the skipped result for single test (used in skipped fuzz test too). - pub fn single_skip(mut self) -> Self { + pub fn single_skip(mut self, reason: SkipReason) -> Self { self.status = TestStatus::Skipped; + self.reason = reason.0; self } @@ -511,22 +523,27 @@ impl TestResult { self.traces.extend(result.traces.map(|traces| (TraceKind::Execution, traces))); self.merge_coverages(result.coverage); - self.status = match result.success { - true => TestStatus::Success, - false => TestStatus::Failure, + self.status = if result.skipped { + TestStatus::Skipped + } else if result.success { + TestStatus::Success + } else { + TestStatus::Failure }; self.reason = result.reason; self.counterexample = result.counterexample; self.duration = Duration::default(); self.gas_report_traces = result.gas_report_traces.into_iter().map(|t| vec![t]).collect(); self.breakpoints = result.breakpoints.unwrap_or_default(); + self } /// Returns the skipped result for invariant test. - pub fn invariant_skip(mut self) -> Self { + pub fn invariant_skip(mut self, reason: SkipReason) -> Self { self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }; self.status = TestStatus::Skipped; + self.reason = reason.0; self } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 3cfbd76c9206f..02b8150df5ce2 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -443,7 +443,7 @@ impl<'a> ContractRunner<'a> { ) { Ok(res) => (res.raw, None), Err(EvmError::Execution(err)) => (err.raw, Some(err.reason)), - Err(EvmError::SkipError) => return test_result.single_skip(), + Err(EvmError::Skip(reason)) => return test_result.single_skip(reason), Err(err) => return test_result.single_fail(Some(err.to_string())), }; @@ -467,7 +467,7 @@ impl<'a> ContractRunner<'a> { let mut test_result = TestResult::new(setup); // First, run the test normally to see if it needs to be skipped. - if let Err(EvmError::SkipError) = self.executor.call( + if let Err(EvmError::Skip(reason)) = self.executor.call( self.sender, address, func, @@ -475,7 +475,7 @@ impl<'a> ContractRunner<'a> { U256::ZERO, Some(self.revert_decoder), ) { - return test_result.invariant_skip() + return test_result.invariant_skip(reason); }; let mut evm = InvariantExecutor::new( @@ -661,12 +661,6 @@ impl<'a> ContractRunner<'a> { self.revert_decoder, progress.as_ref(), ); - - // Check the last test result and skip the test - // if it's marked as so. - if let Some("SKIPPED") = result.reason.as_deref() { - return test_result.single_skip() - } test_result.fuzz_result(result) } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 6ef99d9d11bde..ee803147a8c1b 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -215,20 +215,15 @@ contract DeployScript is Script { "--slow", "--broadcast", "--unlocked", + "--ignored-error-codes=2018", // `wasteGas` can be restricted to view ]) .assert_success() .stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] -Compiler run successful with warnings: -Warning (2018): Function state mutability can be restricted to view - [FILE]:7:5: - | -7 | function wasteGas(uint256 minGas) public { - | ^ (Relevant source part starts here and spans across multiple lines). - +Compiler run successful! Traces: - [81040] DeployScript::run() + [81034] DeployScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [45299] → new GasWaster@[..] @@ -336,7 +331,7 @@ Warning (2018): Function state mutability can be restricted to view | ^ (Relevant source part starts here and spans across multiple lines). Traces: - [81040] DeployScript::run() + [81034] DeployScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [45299] → new GasWaster@[..] diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 3e3335f0c23ff..b6eec8903dff6 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -529,7 +529,7 @@ Compiler run successful! Ran 1 test for test/Contract.t.sol:USDTCallingTest [PASS] test() ([GAS]) Traces: - [9537] USDTCallingTest::test() + [9516] USDTCallingTest::test() ├─ [0] VM::createSelectFork("[..]") │ └─ ← [Return] 0 ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] @@ -573,7 +573,7 @@ contract CustomTypesTest is Test { Compiler run successful! Ran 2 tests for test/Contract.t.sol:CustomTypesTest -[FAIL. Reason: PoolNotInitialized()] testErr() ([GAS]) +[FAIL: PoolNotInitialized()] testErr() ([GAS]) Traces: [254] CustomTypesTest::testErr() └─ ← [Revert] PoolNotInitialized() @@ -590,7 +590,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 1 failed, 0 skipped (2 total tests) Failing tests: Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest -[FAIL. Reason: PoolNotInitialized()] testErr() ([GAS]) +[FAIL: PoolNotInitialized()] testErr() ([GAS]) Encountered a total of 1 failing tests, 1 tests succeeded @@ -632,7 +632,8 @@ forgetest_init!(can_test_transient_storage_with_isolation, |prj, cmd| { prj.add_test( "Contract.t.sol", - r#"pragma solidity 0.8.24; + r#" +pragma solidity ^0.8.24; import {Test} from "forge-std/Test.sol"; contract TransientTester { @@ -687,7 +688,7 @@ forgetest_init!(can_disable_block_gas_limit, |prj, cmd| { prj.add_test( "Contract.t.sol", - &r#"pragma solidity 0.8.24; + &r#" import {Test} from "forge-std/Test.sol"; contract C is Test {} @@ -743,7 +744,7 @@ forgetest_init!(should_not_shrink_fuzz_failure, |prj, cmd| { prj.add_test( "CounterFuzz.t.sol", - r#"pragma solidity 0.8.24; + r#" import {Test} from "forge-std/Test.sol"; contract Counter { @@ -776,14 +777,14 @@ contract CounterTest is Test { Compiler run successful! Ran 1 test for test/CounterFuzz.t.sol:CounterTest -[FAIL. Reason: panic: arithmetic underflow or overflow (0x11); counterexample: calldata=0xa76d58f5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]] testAddOne(uint256) (runs: 61, [AVG_GAS]) +[FAIL: panic: arithmetic underflow or overflow (0x11); counterexample: calldata=0xa76d58f5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]] testAddOne(uint256) (runs: 61, [AVG_GAS]) Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) Failing tests: Encountered 1 failing test in test/CounterFuzz.t.sol:CounterTest -[FAIL. Reason: panic: arithmetic underflow or overflow (0x11); counterexample: calldata=0xa76d58f5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]] testAddOne(uint256) (runs: 61, [AVG_GAS]) +[FAIL: panic: arithmetic underflow or overflow (0x11); counterexample: calldata=0xa76d58f5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]] testAddOne(uint256) (runs: 61, [AVG_GAS]) Encountered a total of 1 failing tests, 0 tests succeeded @@ -794,7 +795,7 @@ forgetest_init!(should_exit_early_on_invariant_failure, |prj, cmd| { prj.wipe_contracts(); prj.add_test( "CounterInvariant.t.sol", - r#"pragma solidity 0.8.24; + r#" import {Test} from "forge-std/Test.sol"; contract Counter { @@ -827,14 +828,14 @@ contract CounterTest is Test { Compiler run successful! Ran 1 test for test/CounterInvariant.t.sol:CounterTest -[FAIL. Reason: failed to set up invariant testing environment: wrong count] invariant_early_exit() (runs: 0, calls: 0, reverts: 0) +[FAIL: failed to set up invariant testing environment: wrong count] invariant_early_exit() (runs: 0, calls: 0, reverts: 0) Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) Failing tests: Encountered 1 failing test in test/CounterInvariant.t.sol:CounterTest -[FAIL. Reason: failed to set up invariant testing environment: wrong count] invariant_early_exit() (runs: 0, calls: 0, reverts: 0) +[FAIL: failed to set up invariant testing environment: wrong count] invariant_early_exit() (runs: 0, calls: 0, reverts: 0) Encountered a total of 1 failing tests, 0 tests succeeded @@ -845,7 +846,7 @@ forgetest_init!(should_replay_failures_only, |prj, cmd| { prj.wipe_contracts(); prj.add_test( "ReplayFailures.t.sol", - r#"pragma solidity 0.8.24; + r#" import {Test} from "forge-std/Test.sol"; contract ReplayFailuresTest is Test { @@ -876,17 +877,17 @@ Compiler run successful! Ran 4 tests for test/ReplayFailures.t.sol:ReplayFailuresTest [PASS] testA() ([GAS]) -[FAIL. Reason: revert: testB failed] testB() ([GAS]) +[FAIL: revert: testB failed] testB() ([GAS]) [PASS] testC() ([GAS]) -[FAIL. Reason: revert: testD failed] testD() ([GAS]) +[FAIL: revert: testD failed] testD() ([GAS]) Suite result: FAILED. 2 passed; 2 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 2 tests passed, 2 failed, 0 skipped (4 total tests) Failing tests: Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest -[FAIL. Reason: revert: testB failed] testB() ([GAS]) -[FAIL. Reason: revert: testD failed] testD() ([GAS]) +[FAIL: revert: testB failed] testB() ([GAS]) +[FAIL: revert: testD failed] testD() ([GAS]) Encountered a total of 2 failing tests, 2 tests succeeded @@ -900,16 +901,16 @@ Encountered a total of 2 failing tests, 2 tests succeeded No files changed, compilation skipped Ran 2 tests for test/ReplayFailures.t.sol:ReplayFailuresTest -[FAIL. Reason: revert: testB failed] testB() ([GAS]) -[FAIL. Reason: revert: testD failed] testD() ([GAS]) +[FAIL: revert: testB failed] testB() ([GAS]) +[FAIL: revert: testD failed] testD() ([GAS]) Suite result: FAILED. 0 passed; 2 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 0 tests passed, 2 failed, 0 skipped (2 total tests) Failing tests: Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest -[FAIL. Reason: revert: testB failed] testB() ([GAS]) -[FAIL. Reason: revert: testD failed] testD() ([GAS]) +[FAIL: revert: testB failed] testB() ([GAS]) +[FAIL: revert: testD failed] testD() ([GAS]) Encountered a total of 2 failing tests, 0 tests succeeded @@ -924,6 +925,7 @@ forgetest_init!(should_show_precompile_labels, |prj, cmd| { "Contract.t.sol", r#" import {Test} from "forge-std/Test.sol"; + contract PrecompileLabelsTest is Test { function testPrecompileLabels() public { vm.deal(address(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D), 1 ether); @@ -1011,14 +1013,15 @@ forgetest_init!(should_show_logs_when_fuzz_test, |prj, cmd| { prj.add_test( "ContractFuzz.t.sol", - r#"pragma solidity 0.8.24; - import {Test, console2} from "forge-std/Test.sol"; - contract ContractFuzz is Test { - function testFuzzConsoleLog(uint256 x) public pure { - console2.log("inside fuzz test, x is:", x); - } + r#" +import {Test, console} from "forge-std/Test.sol"; + +contract ContractFuzz is Test { + function testFuzzConsoleLog(uint256 x) public pure { + console.log("inside fuzz test, x is:", x); } - "#, +} + "#, ) .unwrap(); cmd.args(["test", "-vv"]).assert_success().stdout_eq(str![[r#" @@ -1054,16 +1057,16 @@ forgetest_init!(should_show_logs_when_fuzz_test_inline_config, |prj, cmd| { prj.add_test( "ContractFuzz.t.sol", - r#"pragma solidity 0.8.24; - import {Test, console2} from "forge-std/Test.sol"; - contract ContractFuzz is Test { + r#" +import {Test, console} from "forge-std/Test.sol"; - /// forge-config: default.fuzz.show-logs = true - function testFuzzConsoleLog(uint256 x) public pure { - console2.log("inside fuzz test, x is:", x); - } +contract ContractFuzz is Test { + /// forge-config: default.fuzz.show-logs = true + function testFuzzConsoleLog(uint256 x) public pure { + console.log("inside fuzz test, x is:", x); } - "#, +} + "#, ) .unwrap(); cmd.args(["test", "-vv"]).assert_success().stdout_eq(str![[r#" @@ -1101,12 +1104,12 @@ forgetest_init!(should_not_show_logs_when_fuzz_test, |prj, cmd| { prj.add_test( "ContractFuzz.t.sol", - r#"pragma solidity 0.8.24; - import {Test, console2} from "forge-std/Test.sol"; + r#" + import {Test, console} from "forge-std/Test.sol"; contract ContractFuzz is Test { function testFuzzConsoleLog(uint256 x) public pure { - console2.log("inside fuzz test, x is:", x); + console.log("inside fuzz test, x is:", x); } } "#, @@ -1140,15 +1143,15 @@ forgetest_init!(should_not_show_logs_when_fuzz_test_inline_config, |prj, cmd| { prj.add_test( "ContractFuzz.t.sol", - r#"pragma solidity 0.8.24; - import {Test, console2} from "forge-std/Test.sol"; - contract ContractFuzz is Test { + r#" +import {Test, console} from "forge-std/Test.sol"; - /// forge-config: default.fuzz.show-logs = false - function testFuzzConsoleLog(uint256 x) public pure { - console2.log("inside fuzz test, x is:", x); - } +contract ContractFuzz is Test { + /// forge-config: default.fuzz.show-logs = false + function testFuzzConsoleLog(uint256 x) public pure { + console.log("inside fuzz test, x is:", x); } +} "#, ) .unwrap(); @@ -1177,8 +1180,9 @@ forgetest_init!(internal_functions_trace, |prj, cmd| { prj.add_test( "Simple", - r#"pragma solidity 0.8.24; - import {Test, console2} from "forge-std/Test.sol"; + r#" +import {Test, console} from "forge-std/Test.sol"; + contract SimpleContract { uint256 public num; address public addr; @@ -1254,8 +1258,8 @@ forgetest_init!(internal_functions_trace_memory, |prj, cmd| { prj.add_test( "Simple", - r#"pragma solidity 0.8.24; -import {Test, console2} from "forge-std/Test.sol"; + r#" +import {Test, console} from "forge-std/Test.sol"; contract SimpleContract { string public str = "initial value"; @@ -1283,7 +1287,7 @@ contract SimpleContractTest is Test { r#" ... Traces: - [421960] SimpleContractTest::test() + [421947] SimpleContractTest::test() ├─ [385978] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 1814 bytes of code ├─ [2534] SimpleContract::setStr("new value") @@ -1506,7 +1510,7 @@ Logs: }); // https://github.com/foundry-rs/foundry/issues/4370 -forgetest_init!(repro_4370, |prj, cmd| { +forgetest_init!(pause_gas_metering_with_delete, |prj, cmd| { prj.wipe_contracts(); prj.add_test( @@ -1543,7 +1547,7 @@ forgetest_init!(pause_tracing, |prj, cmd| { prj.add_source( "Pause.t.sol", - r#"pragma solidity 0.8.24; + r#" import {Vm} from "./Vm.sol"; import {DSTest} from "./test.sol"; contract TraceGenerator is DSTest { @@ -1628,7 +1632,7 @@ forgetest_init!(gas_metering_reset, |prj, cmd| { prj.add_source( "ATest.t.sol", - r#"pragma solidity 0.8.24; + r#" import {Vm} from "./Vm.sol"; import {DSTest} from "./test.sol"; contract B { @@ -1780,8 +1784,8 @@ contract CounterTest is Test { cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" ... -[FAIL. Reason: Error != expected error: NumberNotEven(1) != RandomError()] test_decode() ([GAS]) -[FAIL. Reason: Error != expected error: NumberNotEven(1) != NumberNotEven(2)] test_decode_with_args() ([GAS]) +[FAIL: Error != expected error: NumberNotEven(1) != RandomError()] test_decode() ([GAS]) +[FAIL: Error != expected error: NumberNotEven(1) != NumberNotEven(2)] test_decode_with_args() ([GAS]) ... "#]]); }); @@ -1795,7 +1799,7 @@ forgetest_init!(test_expect_partial_revert, |prj, cmd| { prj.add_source( "Counter.t.sol", - r#"pragma solidity 0.8.24; + r#" import {Vm} from "./Vm.sol"; import {DSTest} from "./test.sol"; contract Counter { @@ -1830,7 +1834,7 @@ contract CounterTest is DSTest { ... [PASS] testExpectPartialRevertWith4Bytes() ([GAS]) [PASS] testExpectPartialRevertWithSelector() ([GAS]) -[FAIL. Reason: Error != expected error: WrongNumber(0) != custom error 238ace70:] testExpectRevert() ([GAS]) +[FAIL: Error != expected error: WrongNumber(0) != custom error 0x238ace70] testExpectRevert() ([GAS]) ... "#]]); }); @@ -1849,7 +1853,7 @@ forgetest_init!(test_assume_no_revert, |prj, cmd| { prj.add_source( "Counter.t.sol", - r#"pragma solidity 0.8.24; + r#" import {Vm} from "./Vm.sol"; import {DSTest} from "./test.sol"; contract CounterWithRevert { @@ -1912,10 +1916,66 @@ contract CounterRevertTest is DSTest { cmd.args(["test"]).with_no_redact().assert_failure().stdout_eq(str![[r#" ... -[FAIL. Reason: assertion failed; counterexample: [..]] test_assume_no_revert_fail_assert(uint256) [..] -[FAIL. Reason: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_2nd_call(uint256) [..] -[FAIL. Reason: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_3rd_call(uint256) [..] +[FAIL; counterexample: [..]] test_assume_no_revert_fail_assert(uint256) [..] +[FAIL: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_2nd_call(uint256) [..] +[FAIL: CheckError(); counterexample: [..]] test_assume_no_revert_fail_in_3rd_call(uint256) [..] [PASS] test_assume_no_revert_pass(uint256) [..] ... "#]]); }); + +forgetest_init!(skip_output, |prj, cmd| { + prj.wipe_contracts(); + prj.insert_ds_test(); + prj.insert_vm(); + prj.clear(); + + prj.add_source( + "Counter.t.sol", + r#" + import {Vm} from "./Vm.sol"; + import {DSTest} from "./test.sol"; + + contract Skips is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_skipUnit() public { + vm.skip(true); + } + function test_skipUnitReason() public { + vm.skip(true, "unit"); + } + + function test_skipFuzz(uint) public { + vm.skip(true); + } + function test_skipFuzzReason(uint) public { + vm.skip(true, "fuzz"); + } + + function invariant_skipInvariant() public { + vm.skip(true); + } + function invariant_skipInvariantReason() public { + vm.skip(true, "invariant"); + } + } + "#, + ) + .unwrap(); + + cmd.arg("test").assert_success().stdout_eq(str![[r#" +... +Ran 6 tests for src/Counter.t.sol:Skips +[SKIP] invariant_skipInvariant() (runs: 1, calls: 1, reverts: 1) +[SKIP: invariant] invariant_skipInvariantReason() (runs: 1, calls: 1, reverts: 1) +[SKIP] test_skipFuzz(uint256) (runs: 0, [AVG_GAS]) +[SKIP: fuzz] test_skipFuzzReason(uint256) (runs: 0, [AVG_GAS]) +[SKIP] test_skipUnit() ([GAS]) +[SKIP: unit] test_skipUnitReason() ([GAS]) +Suite result: ok. 0 passed; 0 failed; 6 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 0 failed, 6 skipped (6 total tests) + +"#]]); +}); diff --git a/crates/forge/tests/fixtures/ScriptVerify.sol b/crates/forge/tests/fixtures/ScriptVerify.sol index 4ff4c07505cb6..8dc611f5e531a 100644 --- a/crates/forge/tests/fixtures/ScriptVerify.sol +++ b/crates/forge/tests/fixtures/ScriptVerify.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity =0.8.16; +pragma solidity ^0.8.16; import {Unique} from "./unique.sol"; diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index b0bd57a051c25..e3fc31b8bef27 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -198,7 +198,7 @@ contract InlineMaxRejectsTest is Test { cmd.args(["test"]).assert_failure().stdout_eq(str![[r#" ... -[FAIL. Reason: The `vm.assume` cheatcode rejected too many inputs (1 allowed)] test_fuzz_bound(uint256) (runs: 0, [AVG_GAS]) +[FAIL: `vm.assume` rejected too many inputs (1 allowed)] test_fuzz_bound(uint256) (runs: 0, [AVG_GAS]) ... "#]]); }); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index bd9286713b1de..5a571f77298fb 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -479,7 +479,7 @@ async fn test_invariant_assume_respects_restrictions() { vec![( "invariant_dummy()", false, - Some("The `vm.assume` cheatcode rejected too many inputs (1 allowed)".into()), + Some("`vm.assume` rejected too many inputs (1 allowed)".into()), None, None, )], diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 4b9f8f53ee2c4..70db0a4070ad0 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -47,11 +47,11 @@ static TEMPLATE_LOCK: LazyLock = static NEXT_ID: AtomicUsize = AtomicUsize::new(0); /// The default Solc version used when compiling tests. -pub const SOLC_VERSION: &str = "0.8.23"; +pub const SOLC_VERSION: &str = "0.8.27"; /// Another Solc version used when compiling tests. Necessary to avoid downloading multiple /// versions. -pub const OTHER_SOLC_VERSION: &str = "0.8.22"; +pub const OTHER_SOLC_VERSION: &str = "0.8.26"; /// External test builder #[derive(Clone, Debug)] diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index edc7dad3249ea..eacf81bda286c 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -402,6 +402,7 @@ interface Vm { function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); function skip(bool skipTest) external; + function skip(bool skipTest, string calldata reason) external; function sleep(uint256 duration) external; function snapshot() external returns (uint256 snapshotId); function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs); From 19bd60a173cbc9870eb733e2650e9774c83f3cbd Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:56:53 +0300 Subject: [PATCH 1438/1963] chore(cheatcodes): ArbitraryStorage as option (#8848) * chore(cheatcodes): ArbitraryStorage as option * Update crates/cheatcodes/src/utils.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/cheatcodes/src/inspector.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Early arbitrary_storage_end return --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/src/evm.rs | 19 +++++-- crates/cheatcodes/src/inspector.rs | 86 ++++++++++++++++++------------ crates/cheatcodes/src/utils.rs | 10 ++-- 3 files changed, 72 insertions(+), 43 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 703d7db126e9a..45b6f8c752706 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -93,19 +93,28 @@ impl Cheatcode for loadCall { let mut val = ccx.ecx.sload(target, slot.into())?; if val.is_cold && val.data.is_zero() { - if ccx.state.arbitrary_storage.is_arbitrary(&target) { + if ccx.state.has_arbitrary_storage(&target) { // If storage slot is untouched and load from a target with arbitrary storage, // then set random value for current slot. let rand_value = ccx.state.rng().gen(); - ccx.state.arbitrary_storage.save(ccx.ecx, target, slot.into(), rand_value); + ccx.state.arbitrary_storage.as_mut().unwrap().save( + ccx.ecx, + target, + slot.into(), + rand_value, + ); val.data = rand_value; - } else if ccx.state.arbitrary_storage.is_copy(&target) { + } else if ccx.state.is_arbitrary_storage_copy(&target) { // If storage slot is untouched and load from a target that copies storage from // a source address with arbitrary storage, then copy existing arbitrary value. // If no arbitrary value generated yet, then the random one is saved and set. let rand_value = ccx.state.rng().gen(); - val.data = - ccx.state.arbitrary_storage.copy(ccx.ecx, target, slot.into(), rand_value); + val.data = ccx.state.arbitrary_storage.as_mut().unwrap().copy( + ccx.ecx, + target, + slot.into(), + rand_value, + ); } } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index e09e1e8c88b9f..779c4ac35c3ca 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -266,16 +266,6 @@ pub struct ArbitraryStorage { } impl ArbitraryStorage { - /// Whether the given address has arbitrary storage. - pub fn is_arbitrary(&self, address: &Address) -> bool { - self.values.contains_key(address) - } - - /// Whether the given address is a copy of an address with arbitrary storage. - pub fn is_copy(&self, address: &Address) -> bool { - self.copies.contains_key(address) - } - /// Marks an address with arbitrary storage. pub fn mark_arbitrary(&mut self, address: &Address) { self.values.insert(*address, HashMap::default()); @@ -283,7 +273,7 @@ impl ArbitraryStorage { /// Maps an address that copies storage with the arbitrary storage address. pub fn mark_copy(&mut self, from: &Address, to: &Address) { - if self.is_arbitrary(from) { + if self.values.contains_key(from) { self.copies.insert(*to, *from); } } @@ -456,7 +446,7 @@ pub struct Cheatcodes { pub ignored_traces: IgnoredTraces, /// Addresses with arbitrary storage. - pub arbitrary_storage: ArbitraryStorage, + pub arbitrary_storage: Option, } // This is not derived because calling this in `fn new` with `..Default::default()` creates a second @@ -1080,6 +1070,28 @@ impl Cheatcodes { None => StdRng::from_entropy(), }) } + + /// Returns existing or set a default `ArbitraryStorage` option. + /// Used by `setArbitraryStorage` cheatcode to track addresses with arbitrary storage. + pub fn arbitrary_storage(&mut self) -> &mut ArbitraryStorage { + self.arbitrary_storage.get_or_insert_with(ArbitraryStorage::default) + } + + /// Whether the given address has arbitrary storage. + pub fn has_arbitrary_storage(&self, address: &Address) -> bool { + match &self.arbitrary_storage { + Some(storage) => storage.values.contains_key(address), + None => false, + } + } + + /// Whether the given address is a copy of an address with arbitrary storage. + pub fn is_arbitrary_storage_copy(&self, address: &Address) -> bool { + match &self.arbitrary_storage { + Some(storage) => storage.copies.contains_key(address), + None => false, + } + } } impl Inspector for Cheatcodes { @@ -1146,10 +1158,7 @@ impl Inspector for Cheatcodes { } // `setArbitraryStorage` and `copyStorage`: add arbitrary values to storage. - if (self.arbitrary_storage.is_arbitrary(&interpreter.contract().target_address) || - self.arbitrary_storage.is_copy(&interpreter.contract().target_address)) && - interpreter.current_opcode() == op::SLOAD - { + if self.arbitrary_storage.is_some() { self.arbitrary_storage_end(interpreter, ecx); } } @@ -1577,26 +1586,33 @@ impl Cheatcodes { interpreter: &mut Interpreter, ecx: &mut EvmContext, ) { - let key = try_or_return!(interpreter.stack().peek(0)); - let target_address = interpreter.contract().target_address; - if let Ok(value) = ecx.sload(target_address, key) { - if value.is_cold && value.data.is_zero() { + let (key, target_address) = if interpreter.current_opcode() == op::SLOAD { + (try_or_return!(interpreter.stack().peek(0)), interpreter.contract().target_address) + } else { + return + }; + + let Ok(value) = ecx.sload(target_address, key) else { + return; + }; + + if value.is_cold && value.data.is_zero() { + if self.has_arbitrary_storage(&target_address) { let arbitrary_value = self.rng().gen(); - if self.arbitrary_storage.is_copy(&target_address) { - self.arbitrary_storage.copy( - &mut ecx.inner, - target_address, - key, - arbitrary_value, - ); - } else { - self.arbitrary_storage.save( - &mut ecx.inner, - target_address, - key, - arbitrary_value, - ); - } + self.arbitrary_storage.as_mut().unwrap().save( + &mut ecx.inner, + target_address, + key, + arbitrary_value, + ); + } else if self.is_arbitrary_storage_copy(&target_address) { + let arbitrary_value = self.rng().gen(); + self.arbitrary_storage.as_mut().unwrap().copy( + &mut ecx.inner, + target_address, + key, + arbitrary_value, + ); } } } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 0896f2b316314..a96a44832a5e9 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -153,7 +153,7 @@ impl Cheatcode for resumeTracingCall { impl Cheatcode for setArbitraryStorageCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target } = self; - ccx.state.arbitrary_storage.mark_arbitrary(target); + ccx.state.arbitrary_storage().mark_arbitrary(target); Ok(Default::default()) } @@ -162,15 +162,19 @@ impl Cheatcode for setArbitraryStorageCall { impl Cheatcode for copyStorageCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { from, to } = self; + ensure!( - !ccx.state.arbitrary_storage.is_arbitrary(to), + !ccx.state.has_arbitrary_storage(to), "target address cannot have arbitrary storage" ); + if let Ok(from_account) = ccx.load_account(*from) { let from_storage = from_account.storage.clone(); if let Ok(mut to_account) = ccx.load_account(*to) { to_account.storage = from_storage; - ccx.state.arbitrary_storage.mark_copy(from, to); + if let Some(ref mut arbitrary_storage) = &mut ccx.state.arbitrary_storage { + arbitrary_storage.mark_copy(from, to); + } } } From 898c9360175c2eff5a09cd87df016fe6f5c2181c Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:02:10 +0300 Subject: [PATCH 1439/1963] feat(forge): support junit xml test reports (#8852) * feat(forge): support junit xml test reports * Update crates/forge/bin/cmd/test/mod.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Changes after review * Fix clippy * Support skipped tests with message * Set reason msg only is Some --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 64 ++++++++++++++++ crates/common/src/shell.rs | 4 +- crates/forge/Cargo.toml | 2 + crates/forge/bin/cmd/test/mod.rs | 63 +++++++++++++++- crates/forge/tests/cli/test_cmd.rs | 113 +++++++++++++++++++++++++++++ 5 files changed, 241 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6345afda71b67..20e4a36b90edb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3261,6 +3261,7 @@ dependencies = [ "anvil", "async-trait", "axum", + "chrono", "clap", "clap_complete", "clap_complete_fig", @@ -3300,6 +3301,7 @@ dependencies = [ "paste", "path-slash", "proptest", + "quick-junit", "rayon", "regex", "reqwest", @@ -5717,6 +5719,15 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "newtype-uuid" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3526cb7c660872e401beaf3297f95f548ce3b4b4bdd8121b7c0713771d7c4a6e" +dependencies = [ + "uuid 1.10.0", +] + [[package]] name = "nibble_vec" version = "0.1.0" @@ -6809,6 +6820,21 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-junit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ffd2f9a162cfae131bed6d9d1ed60adced33be340a94f96952897d7cb0c240" +dependencies = [ + "chrono", + "indexmap 2.5.0", + "newtype-uuid", + "quick-xml 0.36.1", + "strip-ansi-escapes", + "thiserror", + "uuid 1.10.0", +] + [[package]] name = "quick-xml" version = "0.18.1" @@ -6827,6 +6853,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" +dependencies = [ + "memchr", +] + [[package]] name = "quinn" version = "0.11.5" @@ -8185,6 +8220,15 @@ dependencies = [ "quote", ] +[[package]] +name = "strip-ansi-escapes" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ff8ef943b384c414f54aefa961dd2bd853add74ec75e7ac74cf91dba62bcfa" +dependencies = [ + "vte", +] + [[package]] name = "strsim" version = "0.11.1" @@ -9158,6 +9202,26 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" +[[package]] +name = "vte" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" +dependencies = [ + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/crates/common/src/shell.rs b/crates/common/src/shell.rs index 5ce6d5b38187b..8ab98e64a9c72 100644 --- a/crates/common/src/shell.rs +++ b/crates/common/src/shell.rs @@ -75,8 +75,8 @@ impl Shell { Self { output, verbosity } } - /// Returns a new shell that conforms to the specified verbosity arguments, where `json` takes - /// higher precedence + /// Returns a new shell that conforms to the specified verbosity arguments, where `json` + /// or `junit` takes higher precedence. pub fn from_args(silent: bool, json: bool) -> Self { match (silent, json) { (_, true) => Self::json(), diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 77034d6194de2..f636e4c6279f9 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -46,6 +46,7 @@ serde.workspace = true tracing.workspace = true yansi.workspace = true humantime-serde = "1.1.1" +chrono.workspace = true # bin forge-doc.workspace = true @@ -107,6 +108,7 @@ opener = "0.7" # soldeer soldeer.workspace = true +quick-junit = "0.5.0" [target.'cfg(unix)'.dependencies] tikv-jemallocator = { workspace = true, optional = true } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 669413d7849ad..3bc659ea083d3 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -1,5 +1,6 @@ use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs}; use alloy_primitives::U256; +use chrono::Utc; use clap::{Parser, ValueHint}; use eyre::{Context, OptionExt, Result}; use forge::{ @@ -40,14 +41,17 @@ use foundry_evm::traces::identifier::TraceIdentifiers; use regex::Regex; use std::{ collections::{BTreeMap, BTreeSet}, + fmt::Write, path::PathBuf, sync::{mpsc::channel, Arc}, - time::Instant, + time::{Duration, Instant}, }; use yansi::Paint; mod filter; mod summary; + +use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; use summary::TestSummaryReporter; pub use filter::FilterArgs; @@ -115,6 +119,10 @@ pub struct TestArgs { #[arg(long, help_heading = "Display options")] json: bool, + /// Output test results as JUnit XML report. + #[arg(long, conflicts_with = "json", help_heading = "Display options")] + junit: bool, + /// Stop running tests after the first failure. #[arg(long)] pub fail_fast: bool, @@ -181,7 +189,7 @@ impl TestArgs { pub async fn run(self) -> Result { trace!(target: "forge::test", "executing test command"); - shell::set_shell(shell::Shell::from_args(self.opts.silent, self.json))?; + shell::set_shell(shell::Shell::from_args(self.opts.silent, self.json || self.junit))?; self.execute_tests().await } @@ -300,7 +308,7 @@ impl TestArgs { let sources_to_compile = self.get_sources_to_compile(&config, &filter)?; let compiler = ProjectCompiler::new() - .quiet_if(self.json || self.opts.silent) + .quiet_if(self.json || self.junit || self.opts.silent) .files(sources_to_compile); let output = compiler.compile(&project)?; @@ -494,6 +502,12 @@ impl TestArgs { return Ok(TestOutcome::new(results, self.allow_failure)); } + if self.junit { + let results = runner.test_collect(filter); + println!("{}", junit_xml_report(&results, verbosity).to_string()?); + return Ok(TestOutcome::new(results, self.allow_failure)); + } + let remote_chain_id = runner.evm_opts.get_remote_chain_id().await; let known_contracts = runner.known_contracts.clone(); @@ -814,6 +828,49 @@ fn persist_run_failures(config: &Config, outcome: &TestOutcome) { } } +/// Generate test report in JUnit XML report format. +fn junit_xml_report(results: &BTreeMap, verbosity: u8) -> Report { + let mut total_duration = Duration::default(); + let mut junit_report = Report::new("Test run"); + junit_report.set_timestamp(Utc::now()); + for (suite_name, suite_result) in results { + let mut test_suite = TestSuite::new(suite_name); + total_duration += suite_result.duration; + test_suite.set_time(suite_result.duration); + test_suite.set_system_out(suite_result.summary()); + for (test_name, test_result) in &suite_result.test_results { + let mut test_status = match test_result.status { + TestStatus::Success => TestCaseStatus::success(), + TestStatus::Failure => TestCaseStatus::non_success(NonSuccessKind::Failure), + TestStatus::Skipped => TestCaseStatus::skipped(), + }; + if let Some(reason) = &test_result.reason { + test_status.set_message(reason); + } + + let mut test_case = TestCase::new(test_name, test_status); + test_case.set_time(test_result.duration); + + let mut sys_out = String::new(); + let result_report = test_result.kind.report(); + write!(sys_out, "{test_result} {test_name} {result_report}").unwrap(); + if verbosity >= 2 && !test_result.logs.is_empty() { + write!(sys_out, "\\nLogs:\\n").unwrap(); + let console_logs = decode_console_logs(&test_result.logs); + for log in console_logs { + write!(sys_out, " {log}\\n").unwrap(); + } + } + + test_case.set_system_out(sys_out); + test_suite.add_test_case(test_case); + } + junit_report.add_test_suite(test_suite); + } + junit_report.set_time(total_duration); + junit_report +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index b6eec8903dff6..09c7e40f85e41 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1977,5 +1977,118 @@ Suite result: ok. 0 passed; 0 failed; 6 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 0 tests passed, 0 failed, 6 skipped (6 total tests) +"#]]); +}); + +forgetest_init!(should_generate_junit_xml_report, |prj, cmd| { + prj.wipe_contracts(); + prj.insert_ds_test(); + prj.insert_vm(); + prj.clear(); + + prj.add_source( + "JunitReportTest.t.sol", + r#" + import {Vm} from "./Vm.sol"; + import {DSTest} from "./test.sol"; + + contract AJunitReportTest is DSTest { + function test_junit_assert_fail() public { + assert(1 > 2); + } + + function test_junit_revert_fail() public { + require(1 > 2, "Revert"); + } + } + + contract BJunitReportTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + function test_junit_pass() public { + require(1 < 2, "Revert"); + } + + function test_junit_skip() public { + vm.skip(true); + } + + function test_junit_skip_with_message() public { + vm.skip(true, "skipped test"); + } + + function test_junit_pass_fuzz(uint256 a) public { + } + } + "#, + ) + .unwrap(); + + cmd.args(["test", "--junit"]).assert_failure().stdout_eq(str![[r#" + + + + + + [FAIL: panic: assertion failed (0x01)] test_junit_assert_fail() ([GAS]) + + + + [FAIL: revert: Revert] test_junit_revert_fail() ([GAS]) + + Suite result: FAILED. 0 passed; 2 failed; 0 skipped; [ELAPSED] + + + + [PASS] test_junit_pass() ([GAS]) + + + [PASS] test_junit_pass_fuzz(uint256) (runs: 256, [AVG_GAS]) + + + + [SKIP] test_junit_skip() ([GAS]) + + + + [SKIP: skipped test] test_junit_skip_with_message() ([GAS]) + + Suite result: ok. 2 passed; 0 failed; 2 skipped; [ELAPSED] + + + + +"#]]); +}); + +forgetest_init!(should_generate_junit_xml_report_with_logs, |prj, cmd| { + prj.wipe_contracts(); + prj.add_source( + "JunitReportTest.t.sol", + r#" +import "forge-std/Test.sol"; +contract JunitReportTest is Test { + function test_junit_with_logs() public { + console.log("Step1"); + console.log("Step2"); + console.log("Step3"); + assert(2 > 1); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--junit", "-vvvv"]).assert_success().stdout_eq(str![[r#" + + + + + [PASS] test_junit_with_logs() ([GAS])/nLogs:/n Step1/n Step2/n Step3/n + + Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + + + + "#]]); }); From 6c0a15b10aaa276050f8f4d53c79d9f0de53b16a Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:58:20 +0200 Subject: [PATCH 1440/1963] test: ignore 3703 (#8861) ignore 3703 --- crates/forge/tests/it/repros.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 73310f0117607..0d1e15052a793 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -22,32 +22,35 @@ use foundry_test_utils::Filter; /// Creates a test that runs `testdata/repros/Issue{issue}.t.sol`. macro_rules! test_repro { - ($issue_number:literal $(,)?) => { - test_repro!($issue_number, false, None); + ($(#[$attr:meta])* $issue_number:literal $(,)?) => { + test_repro!($(#[$attr])* $issue_number, false, None); }; - ($issue_number:literal, $should_fail:expr $(,)?) => { - test_repro!($issue_number, $should_fail, None); + ($(#[$attr:meta])* $issue_number:literal, $should_fail:expr $(,)?) => { + test_repro!($(#[$attr])* $issue_number, $should_fail, None); }; - ($issue_number:literal, $should_fail:expr, $sender:expr $(,)?) => { + ($(#[$attr:meta])* $issue_number:literal, $should_fail:expr, $sender:expr $(,)?) => { paste::paste! { #[tokio::test(flavor = "multi_thread")] + $(#[$attr])* async fn [< issue_ $issue_number >]() { repro_config($issue_number, $should_fail, $sender.into(), &*TEST_DATA_DEFAULT).await.run().await; } } }; - ($issue_number:literal, $should_fail:expr, $sender:expr, |$res:ident| $e:expr $(,)?) => { + ($(#[$attr:meta])* $issue_number:literal, $should_fail:expr, $sender:expr, |$res:ident| $e:expr $(,)?) => { paste::paste! { #[tokio::test(flavor = "multi_thread")] + $(#[$attr])* async fn [< issue_ $issue_number >]() { let mut $res = repro_config($issue_number, $should_fail, $sender.into(), &*TEST_DATA_DEFAULT).await.test(); $e } } }; - ($issue_number:literal; |$config:ident| $e:expr $(,)?) => { + ($(#[$attr:meta])* $issue_number:literal; |$config:ident| $e:expr $(,)?) => { paste::paste! { #[tokio::test(flavor = "multi_thread")] + $(#[$attr])* async fn [< issue_ $issue_number >]() { let mut $config = repro_config($issue_number, false, None, &*TEST_DATA_DEFAULT).await; $e @@ -167,7 +170,10 @@ test_repro!(3674, false, address!("F0959944122fb1ed4CfaBA645eA06EED30427BAA")); test_repro!(3685); // https://github.com/foundry-rs/foundry/issues/3703 -test_repro!(3703); +test_repro!( + #[ignore = "flaky polygon RPCs"] + 3703 +); // https://github.com/foundry-rs/foundry/issues/3708 test_repro!(3708); From 84e63fe5b1d907e9d914f422e006cab8dd44b713 Mon Sep 17 00:00:00 2001 From: Fulum <112524347+AxelAramburu@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:04:41 +0200 Subject: [PATCH 1441/1963] Fix truncated hex in anvil dump_state (#8216) * Fix truncated hex in anvil dump_state * Change type of key * fixs * rustfmt * fix --------- Co-authored-by: unknown Co-authored-by: Matthias Seitz Co-authored-by: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> --- crates/anvil/src/eth/backend/db.rs | 8 ++++---- crates/anvil/src/eth/backend/genesis.rs | 2 +- crates/anvil/src/eth/backend/mem/fork_db.rs | 4 ++-- crates/anvil/src/eth/backend/mem/in_memory_db.rs | 16 +++++++++------- crates/anvil/src/eth/backend/mem/mod.rs | 4 ++-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index cf8f1f5c9ae03..6c16f694dac5d 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -112,7 +112,7 @@ pub trait Db: } /// Sets the balance of the given address - fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()>; + fn set_storage_at(&mut self, address: Address, slot: B256, val: B256) -> DatabaseResult<()>; /// inserts a blockhash for the given number fn insert_block_hash(&mut self, number: U256, hash: B256); @@ -184,8 +184,8 @@ impl + Send + Sync + Clone + fmt::Debug> D self.insert_account_info(address, account) } - fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.insert_account_storage(address, slot, val) + fn set_storage_at(&mut self, address: Address, slot: B256, val: B256) -> DatabaseResult<()> { + self.insert_account_storage(address, slot.into(), val.into()) } fn insert_block_hash(&mut self, number: U256, hash: B256) { @@ -356,7 +356,7 @@ pub struct SerializableAccountRecord { pub nonce: u64, pub balance: U256, pub code: Bytes, - pub storage: BTreeMap, + pub storage: BTreeMap, } /// Defines a backwards-compatible enum for transactions. diff --git a/crates/anvil/src/eth/backend/genesis.rs b/crates/anvil/src/eth/backend/genesis.rs index ee459204d0cd5..e5e76ff491e82 100644 --- a/crates/anvil/src/eth/backend/genesis.rs +++ b/crates/anvil/src/eth/backend/genesis.rs @@ -49,7 +49,7 @@ impl GenesisConfig { db.insert_account(addr, self.genesis_to_account_info(&acc)); // insert all storage values for (k, v) in storage.unwrap_or_default().iter() { - db.set_storage_at(addr, U256::from_be_bytes(k.0), U256::from_be_bytes(v.0))?; + db.set_storage_at(addr, *k, *v)?; } } } diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index a179f50c3b494..bd879f8f42019 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -22,7 +22,7 @@ impl Db for ForkedDatabase { self.database_mut().insert_account(address, account) } - fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { + fn set_storage_at(&mut self, address: Address, slot: B256, val: B256) -> DatabaseResult<()> { // this ensures the account is loaded first let _ = Database::basic(self, address)?; self.database_mut().set_storage_at(address, slot, val) @@ -57,7 +57,7 @@ impl Db for ForkedDatabase { nonce: v.info.nonce, balance: v.info.balance, code: code.original_bytes(), - storage: v.storage.into_iter().collect(), + storage: v.storage.into_iter().map(|(k, v)| (k.into(), v.into())).collect(), }, )) }) diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 059c00f326bf5..2abee72ef33cf 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -24,8 +24,8 @@ impl Db for MemDb { self.inner.insert_account_info(address, account) } - fn set_storage_at(&mut self, address: Address, slot: U256, val: U256) -> DatabaseResult<()> { - self.inner.insert_account_storage(address, slot, val) + fn set_storage_at(&mut self, address: Address, slot: B256, val: B256) -> DatabaseResult<()> { + self.inner.insert_account_storage(address, slot.into(), val.into()) } fn insert_block_hash(&mut self, number: U256, hash: B256) { @@ -56,7 +56,7 @@ impl Db for MemDb { nonce: v.info.nonce, balance: v.info.balance, code: code.original_bytes(), - storage: v.storage.into_iter().collect(), + storage: v.storage.into_iter().map(|(k, v)| (k.into(), v.into())).collect(), }, )) }) @@ -159,7 +159,9 @@ mod tests { nonce: 1234, }, ); - dump_db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); + dump_db + .set_storage_at(test_addr, U256::from(1234567).into(), U256::from(1).into()) + .unwrap(); // blocks dumping/loading tested in storage.rs let state = dump_db @@ -202,8 +204,8 @@ mod tests { }, ); - db.set_storage_at(test_addr, U256::from(1234567), U256::from(1)).unwrap(); - db.set_storage_at(test_addr, U256::from(1234568), U256::from(2)).unwrap(); + db.set_storage_at(test_addr, U256::from(1234567).into(), U256::from(1).into()).unwrap(); + db.set_storage_at(test_addr, U256::from(1234568).into(), U256::from(2).into()).unwrap(); let mut new_state = SerializableState::default(); @@ -218,7 +220,7 @@ mod tests { ); let mut new_storage = BTreeMap::default(); - new_storage.insert(U256::from(1234568), U256::from(5)); + new_storage.insert(U256::from(1234568).into(), U256::from(5).into()); new_state.accounts.insert( test_addr, diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index dd10c672fc377..6a0aeadeea9e2 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -576,7 +576,7 @@ impl Backend { slot: U256, val: B256, ) -> DatabaseResult<()> { - self.db.write().await.set_storage_at(address, slot, U256::from_be_bytes(val.0)) + self.db.write().await.set_storage_at(address, slot.into(), val) } /// Returns the configured specid @@ -2498,7 +2498,7 @@ impl Backend { self.db.write().await.clear(); for (address, acc) in common_state { for (key, value) in acc.storage { - self.db.write().await.set_storage_at(address, key, value)?; + self.db.write().await.set_storage_at(address, key.into(), value.into())?; } self.db.write().await.insert_account(address, acc.info); } From e16a75b615f812db6127ea22e23c3ee65504c1f1 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 13 Sep 2024 21:03:39 +0400 Subject: [PATCH 1442/1963] fix(script): correctly fill metadata + prompt on noop transactions (#8833) * refactor metadata handling * warn on noop transactions * infer is_fixed_gas_limit * add comments back * rm gas limit println * fix fixtures * retain --- crates/common/src/transactions.rs | 7 ++ crates/forge/tests/cli/script.rs | 8 +- crates/script/src/lib.rs | 9 ++- crates/script/src/simulate.rs | 118 ++++++++++++++---------------- crates/script/src/transaction.rs | 67 +++++++++-------- 5 files changed, 112 insertions(+), 97 deletions(-) diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index c927d575dcc10..9df8f896f99d0 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -216,6 +216,13 @@ impl TransactionMaybeSigned { Self::Unsigned(tx) => tx.gas, } } + + pub fn nonce(&self) -> Option { + match self { + Self::Signed { tx, .. } => Some(tx.nonce()), + Self::Unsigned(tx) => tx.nonce, + } + } } impl From for TransactionMaybeSigned { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index ee803147a8c1b..2aefd985c045e 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -239,7 +239,6 @@ Script ran successfully. ========================== Simulated On-chain Traces: -Gas limit was set in script to 500000 [45299] → new GasWaster@[..] └─ ← [Return] 226 bytes of code @@ -347,7 +346,6 @@ Script ran successfully. ========================== Simulated On-chain Traces: -Gas limit was set in script to 500000 [45299] → new GasWaster@[..] └─ ← [Return] 226 bytes of code @@ -1684,6 +1682,7 @@ contract SimpleScript is Script { "2000000", "--priority-gas-price", "100000", + "--non-interactive", ]) .assert_success() .stdout_eq(str![[r#" @@ -1697,6 +1696,7 @@ Script ran successfully. success: bool true ## Setting up 1 EVM. +Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. ========================== @@ -1733,6 +1733,7 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. format!("{dev:?}").as_str(), "--broadcast", "--unlocked", + "--non-interactive", ]) .assert_success() .stdout_eq(str![[r#" @@ -1744,6 +1745,7 @@ Script ran successfully. success: bool true ## Setting up 1 EVM. +Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. ========================== @@ -1797,6 +1799,7 @@ contract SimpleScript is Script { &handle.http_endpoint(), "--broadcast", "--unlocked", + "--non-interactive", ]) .assert_success() .stdout_eq(str![[r#" @@ -1810,6 +1813,7 @@ Script ran successfully. success: bool true ## Setting up 1 EVM. +Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. ========================== diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 6af605690e2b9..a20a884f04b3d 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -276,7 +276,7 @@ impl ScriptArgs { }; // Exit early in case user didn't provide any broadcast/verify related flags. - if !bundled.args.broadcast && !bundled.args.resume && !bundled.args.verify { + if !bundled.args.should_broadcast() { shell::println("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; return Ok(()); } @@ -419,7 +419,7 @@ impl ScriptArgs { let deployment_size = deployed_code.len(); if deployment_size > max_size { - prompt_user = self.broadcast; + prompt_user = self.should_broadcast(); shell::println(format!( "{}", format!( @@ -440,6 +440,11 @@ impl ScriptArgs { Ok(()) } + + /// We only broadcast transactions if --broadcast or --resume was passed. + fn should_broadcast(&self) -> bool { + self.broadcast || self.resume + } } impl Provider for ScriptArgs { diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 077c507e24a3c..eea660bcdbee5 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -14,8 +14,9 @@ use crate::{ }; use alloy_network::TransactionBuilder; use alloy_primitives::{utils::format_units, Address, Bytes, TxKind, U256}; +use dialoguer::Confirm; use eyre::{Context, Result}; -use foundry_cheatcodes::{BroadcastableTransactions, ScriptWallets}; +use foundry_cheatcodes::ScriptWallets; use foundry_cli::utils::{has_different_gas_calc, now}; use foundry_common::{get_contract_name, shell, ContractData}; use foundry_evm::traces::{decode_trace_arena, render_trace_arena}; @@ -25,6 +26,7 @@ use std::{ collections::{BTreeMap, HashMap, VecDeque}, sync::Arc, }; +use yansi::Paint; /// Same as [ExecutedState](crate::execute::ExecutedState), but also contains [ExecutionArtifacts] /// which are obtained from [ScriptResult]. @@ -48,16 +50,30 @@ impl PreSimulationState { /// /// Both modes will panic if any of the transactions have None for the `rpc` field. pub async fn fill_metadata(self) -> Result { - let transactions = if let Some(txs) = self.execution_result.transactions.as_ref() { - if self.args.skip_simulation { - shell::println("\nSKIPPING ON CHAIN SIMULATION.")?; - self.no_simulation(txs.clone())? - } else { - self.onchain_simulation(txs.clone()).await? - } + let address_to_abi = self.build_address_to_abi_map(); + + let mut transactions = self + .execution_result + .transactions + .clone() + .unwrap_or_default() + .into_iter() + .map(|tx| { + let rpc = tx.rpc.expect("missing broadcastable tx rpc url"); + TransactionWithMetadata::new( + tx.transaction, + rpc, + &address_to_abi, + &self.execution_artifacts.decoder, + ) + }) + .collect::>>()?; + + if self.args.skip_simulation { + shell::println("\nSKIPPING ON CHAIN SIMULATION.")?; } else { - VecDeque::new() - }; + transactions = self.simulate_and_fill(transactions).await?; + } Ok(FilledTransactionsState { args: self.args, @@ -73,9 +89,9 @@ impl PreSimulationState { /// transactions in those environments. /// /// Collects gas usage and metadata for each transaction. - pub async fn onchain_simulation( + pub async fn simulate_and_fill( &self, - transactions: BroadcastableTransactions, + transactions: VecDeque, ) -> Result> { trace!(target: "script", "executing onchain simulation"); @@ -87,18 +103,15 @@ impl PreSimulationState { .collect::>(), ); - let address_to_abi = self.build_address_to_abi_map(); - let mut final_txs = VecDeque::new(); // Executes all transactions from the different forks concurrently. let futs = transactions .into_iter() - .map(|transaction| async { - let rpc = transaction.rpc.expect("missing broadcastable tx rpc url"); - let mut runner = runners.get(&rpc).expect("invalid rpc url").write(); + .map(|mut transaction| async { + let mut runner = runners.get(&transaction.rpc).expect("invalid rpc url").write(); - let mut tx = transaction.transaction; + let tx = &mut transaction.transaction; let to = if let Some(TxKind::Call(to)) = tx.to() { Some(to) } else { None }; let result = runner .simulate( @@ -111,46 +124,24 @@ impl PreSimulationState { .wrap_err("Internal EVM error during simulation")?; if !result.success { - return Ok((None, result.traces)); + return Ok((None, false, result.traces)); } - let created_contracts = result.get_created_contracts(); - // Simulate mining the transaction if the user passes `--slow`. if self.args.slow { runner.executor.env_mut().block.number += U256::from(1); } - let is_fixed_gas_limit = if let Some(tx) = tx.as_unsigned_mut() { - match tx.gas { - // If tx.gas is already set that means it was specified in script - Some(gas) => { - println!("Gas limit was set in script to {gas}"); - true - } - // We inflate the gas used by the user specified percentage - None => { - let gas = result.gas_used * self.args.gas_estimate_multiplier / 100; - tx.gas = Some(gas as u128); - false - } - } + let is_noop_tx = if let Some(to) = to { + runner.executor.is_empty_code(to)? && tx.value().unwrap_or_default().is_zero() } else { - // for pre-signed transactions we can't alter gas limit - true + false }; - let tx = TransactionWithMetadata::new( - tx, - rpc, - &result, - &address_to_abi, - &self.execution_artifacts.decoder, - created_contracts, - is_fixed_gas_limit, - )?; + let transaction = + transaction.with_execution_result(&result, self.args.gas_estimate_multiplier); - eyre::Ok((Some(tx), result.traces)) + eyre::Ok((Some(transaction), is_noop_tx, result.traces)) }) .collect::>(); @@ -161,7 +152,7 @@ impl PreSimulationState { let mut abort = false; for res in join_all(futs).await { - let (tx, mut traces) = res?; + let (tx, is_noop_tx, mut traces) = res?; // Transaction will be `None`, if execution didn't pass. if tx.is_none() || self.script_config.evm_opts.verbosity > 3 { @@ -172,6 +163,21 @@ impl PreSimulationState { } if let Some(tx) = tx { + if is_noop_tx { + let to = tx.contract_address.unwrap(); + shell::println(format!("Script contains a transaction to {to} which does not contain any code.").yellow())?; + + // Only prompt if we're broadcasting and we've not disabled interactivity. + if self.args.should_broadcast() && + !self.args.non_interactive && + !Confirm::new() + .with_prompt("Do you wish to continue?".to_string()) + .interact()? + { + eyre::bail!("User canceled the script."); + } + } + final_txs.push_back(tx); } else { abort = true; @@ -220,22 +226,6 @@ impl PreSimulationState { }); try_join_all(futs).await } - - /// If simulation is disabled, converts transactions into [TransactionWithMetadata] type - /// skipping metadata filling. - fn no_simulation( - &self, - transactions: BroadcastableTransactions, - ) -> Result> { - Ok(transactions - .into_iter() - .map(|btx| { - let mut tx = TransactionWithMetadata::from_tx_request(btx.transaction); - tx.rpc = btx.rpc.expect("missing broadcastable tx rpc url"); - tx - }) - .collect()) - } } /// At this point we have converted transactions collected during script execution to diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 0ef2559d94a9b..bbf84ff0ff8ae 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,7 +1,7 @@ use super::ScriptResult; use alloy_dyn_abi::JsonAbiExt; use alloy_primitives::{hex, Address, Bytes, TxKind, B256}; -use eyre::{ContextCompat, Result, WrapErr}; +use eyre::{Result, WrapErr}; use foundry_common::{fmt::format_token_raw, ContractData, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; use itertools::Itertools; @@ -70,53 +70,62 @@ impl TransactionWithMetadata { pub fn new( transaction: TransactionMaybeSigned, rpc: String, - result: &ScriptResult, local_contracts: &BTreeMap, decoder: &CallTraceDecoder, - additional_contracts: Vec, - is_fixed_gas_limit: bool, ) -> Result { let mut metadata = Self::from_tx_request(transaction); metadata.rpc = rpc; - metadata.is_fixed_gas_limit = is_fixed_gas_limit; + // If tx.gas is already set that means it was specified in script + metadata.is_fixed_gas_limit = metadata.tx().gas().is_some(); - // Specify if any contract was directly created with this transaction if let Some(TxKind::Call(to)) = metadata.transaction.to() { if to == DEFAULT_CREATE2_DEPLOYER { - metadata.set_create( - true, - Address::from_slice(&result.returned), - local_contracts, - )?; + if let Some(input) = metadata.transaction.input() { + let (salt, init_code) = input.split_at(32); + metadata.set_create( + true, + DEFAULT_CREATE2_DEPLOYER + .create2_from_code(B256::from_slice(salt), init_code), + local_contracts, + )?; + } } else { metadata .set_call(to, local_contracts, decoder) .wrap_err("Could not decode transaction type.")?; } } else { - metadata.set_create( - false, - result.address.wrap_err("There should be a contract address from CREATE.")?, - local_contracts, - )?; + let sender = + metadata.transaction.from().expect("all transactions should have a sender"); + let nonce = metadata.transaction.nonce().expect("all transactions should have a nonce"); + metadata.set_create(false, sender.create(nonce), local_contracts)?; } + Ok(metadata) + } + + /// Populates additional data from the transaction execution result. + pub fn with_execution_result( + mut self, + result: &ScriptResult, + gas_estimate_multiplier: u64, + ) -> Self { + let mut created_contracts = result.get_created_contracts(); + // Add the additional contracts created in this transaction, so we can verify them later. - if let Some(tx_address) = metadata.contract_address { - metadata.additional_contracts = additional_contracts - .into_iter() - .filter_map(|contract| { - // Filter out the transaction contract repeated init_code. - if contract.address != tx_address { - Some(contract) - } else { - None - } - }) - .collect(); + created_contracts.retain(|contract| { + // Filter out the contract that was created by the transaction itself. + self.contract_address.map_or(true, |addr| addr != contract.address) + }); + + if !self.is_fixed_gas_limit { + if let Some(unsigned) = self.transaction.as_unsigned_mut() { + // We inflate the gas used by the user specified percentage + unsigned.gas = Some((result.gas_used * gas_estimate_multiplier / 100) as u128); + } } - Ok(metadata) + self } /// Populate the transaction as CREATE tx From 280aa26c3a6d71c442d32b45920d30c62f9d6fbb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 11:11:59 +0000 Subject: [PATCH 1443/1963] chore(deps): weekly `cargo update` (#8868) Locking 72 packages to latest compatible versions Updating alloy-chains v0.1.30 -> v0.1.31 Updating alloy-consensus v0.3.3 -> v0.3.5 Updating alloy-contract v0.3.3 -> v0.3.5 Updating alloy-dyn-abi v0.8.2 -> v0.8.3 Updating alloy-eips v0.3.3 -> v0.3.5 Updating alloy-genesis v0.3.3 -> v0.3.5 Updating alloy-json-abi v0.8.2 -> v0.8.3 Updating alloy-json-rpc v0.3.3 -> v0.3.5 Updating alloy-network v0.3.3 -> v0.3.5 Updating alloy-network-primitives v0.3.3 -> v0.3.5 Updating alloy-primitives v0.8.2 -> v0.8.3 Updating alloy-provider v0.3.3 -> v0.3.5 Updating alloy-pubsub v0.3.3 -> v0.3.5 Updating alloy-rpc-client v0.3.3 -> v0.3.5 Updating alloy-rpc-types v0.3.3 -> v0.3.5 Updating alloy-rpc-types-anvil v0.3.3 -> v0.3.5 Updating alloy-rpc-types-engine v0.3.3 -> v0.3.5 Updating alloy-rpc-types-eth v0.3.3 -> v0.3.5 Updating alloy-rpc-types-trace v0.3.3 -> v0.3.5 Updating alloy-rpc-types-txpool v0.3.3 -> v0.3.5 Updating alloy-serde v0.3.3 -> v0.3.5 Updating alloy-signer v0.3.3 -> v0.3.5 Updating alloy-signer-aws v0.3.3 -> v0.3.5 Updating alloy-signer-gcp v0.3.3 -> v0.3.5 Updating alloy-signer-ledger v0.3.3 -> v0.3.5 Updating alloy-signer-local v0.3.3 -> v0.3.5 Updating alloy-signer-trezor v0.3.3 -> v0.3.5 Updating alloy-sol-macro v0.8.2 -> v0.8.3 Updating alloy-sol-macro-expander v0.8.2 -> v0.8.3 Updating alloy-sol-macro-input v0.8.2 -> v0.8.3 Updating alloy-sol-type-parser v0.8.2 -> v0.8.3 Updating alloy-sol-types v0.8.2 -> v0.8.3 Updating alloy-transport v0.3.3 -> v0.3.5 Updating alloy-transport-http v0.3.3 -> v0.3.5 Updating alloy-transport-ipc v0.3.3 -> v0.3.5 Updating alloy-transport-ws v0.3.3 -> v0.3.5 Updating anyhow v1.0.87 -> v1.0.88 Updating aws-config v1.5.5 -> v1.5.6 Updating aws-runtime v1.4.2 -> v1.4.3 Updating aws-sdk-kms v1.42.0 -> v1.43.0 Updating aws-sdk-sso v1.41.0 -> v1.42.0 Updating aws-sdk-ssooidc v1.42.0 -> v1.43.0 Updating aws-sdk-sts v1.41.0 -> v1.42.0 Updating aws-sigv4 v1.2.3 -> v1.2.4 Updating aws-smithy-http v0.60.10 -> v0.60.11 Updating aws-smithy-types v1.2.4 -> v1.2.6 Updating aws-smithy-xml v0.60.8 -> v0.60.9 Updating error-code v3.2.0 -> v3.3.1 Updating globset v0.4.14 -> v0.4.15 Updating hyper-util v0.1.7 -> v0.1.8 Updating ignore v0.4.22 -> v0.4.23 Updating keccak-asm v0.1.3 -> v0.1.4 Updating memmap2 v0.9.4 -> v0.9.5 Updating once_cell v1.19.0 -> v1.20.0 Updating op-alloy-consensus v0.2.9 -> v0.2.11 Updating op-alloy-rpc-types v0.2.9 -> v0.2.11 Updating plotters v0.3.6 -> v0.3.7 Updating plotters-backend v0.3.6 -> v0.3.7 Updating plotters-svg v0.3.6 -> v0.3.7 Updating redox_syscall v0.5.3 -> v0.5.4 Updating rgb v0.8.48 -> v0.8.50 Updating rustix v0.38.36 -> v0.38.37 Updating rustls v0.23.12 -> v0.23.13 Updating rustls-webpki v0.102.7 -> v0.102.8 Updating scc v2.1.16 -> v2.1.17 Updating sdd v3.0.2 -> v3.0.3 Updating secp256k1-sys v0.10.0 -> v0.10.1 Updating sha3-asm v0.1.3 -> v0.1.4 Updating syn-solidity v0.8.2 -> v0.8.3 Updating tower v0.5.0 -> v0.5.1 Updating unicode-ident v1.0.12 -> v1.0.13 Updating unicode-segmentation v1.11.0 -> v1.12.0 note: pass `--verbose` to see 137 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 323 +++++++++++++++++++++++++++-------------------------- 1 file changed, 162 insertions(+), 161 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20e4a36b90edb..c11f775fa21f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b4f201b0ac8f81315fbdc55269965a8ddadbc04ab47fa65a1a468f9a40f7a5f" +checksum = "b68b94c159bcc2ca5f758b8663d7b00fc7c5e40569984595ddf2221b0f7f7f6e" dependencies = [ "num_enum", "serde", @@ -85,9 +85,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1468e3128e07c7afe4ff13c17e8170c330d12c322f8924b8bf6986a27e0aad3d" +checksum = "c28ddd17ffb7e4d66ef3a84e7b179072a9320cdc4b26c7f6f44cbf1081631b36" dependencies = [ "alloy-eips", "alloy-primitives", @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335d62de1a887f1b780441f8a3037f39c9fb26839cc9acd891c9b80396145cd5" +checksum = "a69257e2ffe1a9f15f20a89cd54d1ca758468c5b3e87979191b8b5fc24d39b37" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03f58cfae4d41b624effe1f11624ee40499449174b20a6d6505fd72ef0d547d" +checksum = "4004925bff5ba0a11739ae84dbb6601a981ea692f3bd45b626935ee90a6b8471" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c35df7b972b06f1b2f4e8b7a53328522fa788054a9d3e556faf2411c5a51d5a" +checksum = "2f6c5c0a383f14519531cf58d8440e74f10b938e289f803af870be6f79223110" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7210f9206c0fa2a83c824cf8cb6c962126bc9fdc4f41ade1932f14150ef5f6" +checksum = "7db0ddc76399bb1a4010f630767f027cafe65ab406cfee8e6040128cd65e8325" dependencies = [ "alloy-primitives", "alloy-serde", @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28ecae8b5315daecd0075084eb47f4374b3037777346ca52fc8d9c327693f02" +checksum = "9996daf962fd0a90d3c93b388033228865953b92de7bb1959b891d78750a4091" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -210,9 +210,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8866562186d237f1dfeaf989ef941a24764f764bf5c33311e37ead3519c6a429" +checksum = "7111af869909275cffc5c84d16b6c892d6d512773e40cbe83187d0b9c5235e91" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -224,9 +224,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe714e233f9eaf410de95a9af6bcd05d3a7f8c8de7a0817221e95a6b642a080" +checksum = "342028392a2d5050b7b93dd32a0715d3b3b9ce30072ecb69a35dd4895c005495" dependencies = [ "alloy-consensus", "alloy-eips", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c5a38117974c5776a45e140226745a0b664f79736aa900995d8e4121558e064" +checksum = "a6e66d78c049dcadd065a926a9f2d9a9b2b10981a7889449e694fac7bccd2c6f" dependencies = [ "alloy-eips", "alloy-primitives", @@ -257,9 +257,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb865df835f851b367ae439d6c82b117ded971628c8888b24fed411a290e38a" +checksum = "411aff151f2a73124ee473708e82ed51b2535f68928b6a1caa8bc1246ae6f7cd" dependencies = [ "alloy-rlp", "arbitrary", @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65633d6ef83c3626913c004eaf166a6dd50406f724772ea8567135efd6dc5d3" +checksum = "79f14ccc2a3c575cb17b1b4af8c772cf9b5b93b7ce7047d6640e53954abb558d" dependencies = [ "alloy-chains", "alloy-consensus", @@ -322,9 +322,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949db89abae6193b44cc90ebf2eeb74eb8d2a474383c5e62b45bdcd362e84f8f" +checksum = "34b9f5e85120aab30b8da23354592f7bd2b208d33d3204ffa1d44ac2e3dd5691" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -335,7 +335,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.5.0", + "tower 0.5.1", "tracing", ] @@ -363,9 +363,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fc328bb5d440599ba1b5aa44c0b9ab0625fbc3a403bb5ee94ed4a01ba23e07" +checksum = "4dc79aeca84abb122a2fffbc1c91fdf958dca5c95be3875977bc99672bde0027" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -381,16 +381,16 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.5.0", + "tower 0.5.1", "tracing", "url", ] [[package]] name = "alloy-rpc-types" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f8ff679f94c497a8383f2cd09e2a099266e5f3d5e574bc82b4b379865707dbb" +checksum = "22045187a5ebf5b2af3f8b6831b66735b6556c5750ec5790aeeb45935260c1c2" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -403,9 +403,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d430bf98148565e67b2c08f033dd5fb27ce901c3481018941ce1524b9ad4fba" +checksum = "578d9ccad4e8510d32cc2810d05e01a232ccd79a4a6df60d257466897b43b013" dependencies = [ "alloy-primitives", "alloy-serde", @@ -414,27 +414,26 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66bb45f4c5efe227bcb51d89c97221225169976e18097671a0bd4393d8248a4" +checksum = "1c031a91e94a39f928244bc837c953817be5b8cc61759e1a9123b3abd17560dd" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types-eth", "alloy-serde", + "derive_more 1.0.0", "jsonwebtoken", "rand", "serde", - "thiserror", ] [[package]] name = "alloy-rpc-types-eth" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a59b1d7c86e0a653e7f3d29954f6de5a2878d8cfd1f010ff93be5c2c48cd3b1" +checksum = "238f494727ff861a803bd73b1274ef788a615bf8f8c4bfada4e6df42afa275d2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -443,17 +442,19 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", + "cfg-if", + "derive_more 1.0.0", + "hashbrown 0.14.5", "itertools 0.13.0", "serde", "serde_json", - "thiserror", ] [[package]] name = "alloy-rpc-types-trace" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54375e5a34ec5a2cf607f9ce98c0ece30dc76ad623afeb25d3953a8d7d30f20" +checksum = "64ca08b0ccc0861055ceb83a1db009c4c8a7f52a259e7cda7ca6ca36ec2b5ce8" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -465,9 +466,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ae88491edfc8bbd55ba2b22b2ff24d4c522bacd8808461c4a232715fee3d22" +checksum = "192ad94fe34c12be8ac4413ea00b1170202faa6fdebaa756b6a33555bf86d902" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -477,9 +478,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51db8a6428a2159e01b7a43ec7aac801edd0c4db1d4de06f310c288940f16fd3" +checksum = "6b95b6f024a558593dd3b8628af03f7df2ca50e4c56839293ad0a7546e471db0" dependencies = [ "alloy-primitives", "arbitrary", @@ -489,9 +490,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebc1760c13592b7ba3fcd964abba546b8d6a9f10d15e8d92a8263731be33f36" +checksum = "da64740ff0518606c514eb0e03dd0a1daa8ff94d6d491a626fd8e50efd6c4f18" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -505,9 +506,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa0d52968220ddfdb8d332cfddc6c7ae8147779aebb3c463d6023f1d458471b" +checksum = "f187534919dcccebaf92774ad6b17645087b49a8716d49e2db29a2e3229b03f2" dependencies = [ "alloy-consensus", "alloy-network", @@ -523,9 +524,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d369e98958cf6e2a41b1b1fcee21d73185f358db23751636e3d90b1f4aa184d" +checksum = "907e56e2153e785c36e4197f4e254b5087e073a12b686f486d3bd6245c811313" dependencies = [ "alloy-consensus", "alloy-network", @@ -541,9 +542,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f03b98771184d733139f0475e562f6f8cb8143d0a3765674078c0a3ed00c3b" +checksum = "221d828bdf1df1e7d490c304eb1425c7adacd6897a4baa2316e3f3054fc8863f" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -561,9 +562,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfb3508485aa798efb5725322e414313239274d3780079b7f8c6746b8ee6e1b" +checksum = "99e250010dce0e3caf6a6033e809718e5921391d937d1cbbcffe52653b37cc63" dependencies = [ "alloy-consensus", "alloy-network", @@ -581,9 +582,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "423c62e0596be68f55a7c03ec4b961d46c74e92ba2d0143fe147608a5c8fe4a4" +checksum = "586b4c42aa61b47591813fca23098e21530470986a00e3dc588baa2d5b8dd111" dependencies = [ "alloy-consensus", "alloy-network", @@ -598,9 +599,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2dc5201ca0018afb7a3e0cd8bd15f7ca6aca924333b5f3bb87463b41d0c4ef2" +checksum = "0458ccb02a564228fcd76efb8eb5a520521a8347becde37b402afec9a1b83859" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -612,9 +613,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "155f63dc6945885aa4532601800201fddfaa3b20901fda8e8c2570327242fe0e" +checksum = "2bc65475025fc1e84bf86fc840f04f63fcccdcf3cf12053c99918e4054dfbc69" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -631,9 +632,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847700aa9cb59d3c7b290b2d05976cd8d76b64d73bb63116a9533132d995586b" +checksum = "6ed10f0715a0b69fde3236ff3b9ae5f6f7c97db5a387747100070d3016b9266b" dependencies = [ "alloy-json-abi", "const-hex", @@ -648,9 +649,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6b5d462d4520bd9ed70d8364c6280aeff13baa46ea26be1ddd33538dbbe6ac" +checksum = "3edae8ea1de519ccba896b6834dec874230f72fe695ff3c9c118e90ec7cff783" dependencies = [ "serde", "winnow", @@ -658,9 +659,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83665e5607725a7a1aab3cb0dea708f4a05e70776954ec7f0a9461439175c957" +checksum = "1eb88e4da0a1b697ed6a9f811fdba223cf4d5c21410804fd1707836af73a462b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -671,9 +672,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5dc4e902f1860d54952446d246ac05386311ad61030a2b906ae865416d36e0" +checksum = "3c7a669caa427abe8802184c8776f5103302f9337bb30a5b36bdebc332946c14" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -683,31 +684,31 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower 0.5.0", + "tower 0.5.1", "tracing", "url", ] [[package]] name = "alloy-transport-http" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1742b94bb814f1ca6b322a6f9dd38a0252ff45a3119e40e888fb7029afa500ce" +checksum = "4433ffa97aab6ae643de81c7bde9a2f043496f27368a607405a5c78a610caf74" dependencies = [ "alloy-json-rpc", "alloy-transport", "reqwest", "serde_json", - "tower 0.5.0", + "tower 0.5.1", "tracing", "url", ] [[package]] name = "alloy-transport-ipc" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be321aac6f06d86855d41d4ce9ff9feb877fe7e9fe1cafce7380b981c12398c7" +checksum = "9aa02db8751f9c0c37caf8c38ad3eb7aa1cfb09cfea3451a13aacaf06846c7a5" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -726,15 +727,15 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ed861e7030001364c8ffa2db63541f7bae275a6e636de7616c20f2fd3dc0c3" +checksum = "b0a5c4a0929479bcb85a2df628c01173618a71c807b2f499939a236dbde5d008" dependencies = [ "alloy-pubsub", "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.12", + "rustls 0.23.13", "serde_json", "tokio", "tokio-tungstenite 0.23.1", @@ -963,9 +964,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "arbitrary" @@ -1252,9 +1253,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-config" -version = "1.5.5" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e95816a168520d72c0e7680c405a5a8c1fb6a035b4bc4b9d7b0de8e1a941697" +checksum = "848d7b9b605720989929279fa644ce8f244d0ce3146fcca5b70e4eb7b3c020fc" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1294,9 +1295,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2424565416eef55906f9f8cece2072b6b6a76075e3ff81483ebe938a89a4c05f" +checksum = "a10d5c055aa540164d9561a0e2e74ad30f0dcf7393c3a92f6733ddf9c5762468" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1319,9 +1320,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704ab31904cf70104a3bb023079e201b1353cf132ca674b26ba6f23acbbb53c9" +checksum = "d9f7cb482caa5444d445c94417b9c74e49a849beb09ede4f2f4c3c15f8157387" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1341,9 +1342,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.41.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af0a3f676cba2c079c9563acc9233998c8951cdbe38629a0bef3c8c1b02f3658" +checksum = "27bf24cd0d389daa923e974b0e7c38daf308fc21e963c049f57980235017175e" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1363,9 +1364,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91b6a04495547162cf52b075e3c15a17ab6608bf9c5785d3e5a5509b3f09f5c" +checksum = "3b43b3220f1c46ac0e9dcc0a97d94b93305dacb36d1dd393996300c6b9b74364" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1385,9 +1386,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.41.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c56bcd6a56cab7933980a54148b476a5a69a7694e3874d9aa2a566f150447d" +checksum = "d1c46924fb1add65bba55636e12812cae2febf68c0f37361766f627ddcca91ce" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1408,9 +1409,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.3" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5df1b0fa6be58efe9d4ccc257df0a53b89cd8909e86591a13ca54817c87517be" +checksum = "cc8db6904450bafe7473c6ca9123f88cc11089e41a025408f992db4e22d3be68" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1442,9 +1443,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.10" +version = "0.60.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01dbcb6e2588fd64cfb6d7529661b06466419e4c54ed1c62d6510d2d0350a728" +checksum = "5c8bc3e8fdc6b8d07d976e301c02fe553f72a39b7a9fea820e023268467d7ab6" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -1525,9 +1526,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.4" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273dcdfd762fae3e1650b8024624e7cd50e484e37abdab73a7a706188ad34543" +checksum = "03701449087215b5369c7ea17fef0dd5d24cb93439ec5af0c7615f58c3f22605" dependencies = [ "base64-simd", "bytes", @@ -1548,9 +1549,9 @@ dependencies = [ [[package]] name = "aws-smithy-xml" -version = "0.60.8" +version = "0.60.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d123fbc2a4adc3c301652ba8e149bf4bc1d1725affb9784eb20c953ace06bf55" +checksum = "ab0b0166827aa700d3dc519f72f8b3a91c35d0b8d042dc5d643a91e6f80648fc" dependencies = [ "xmlparser", ] @@ -2942,9 +2943,9 @@ dependencies = [ [[package]] name = "error-code" -version = "3.2.0" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b" +checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f" [[package]] name = "eth-keystore" @@ -4275,7 +4276,7 @@ dependencies = [ "serde_json", "tokio", "tonic", - "tower 0.5.0", + "tower 0.5.1", "tower-layer", "tower-util", "tracing", @@ -4556,9 +4557,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", "bstr", @@ -4895,7 +4896,7 @@ dependencies = [ "http 1.1.0", "hyper 1.4.1", "hyper-util", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", @@ -4935,9 +4936,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ "bytes", "futures-channel", @@ -4994,9 +4995,9 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" dependencies = [ "crossbeam-deque", "globset", @@ -5306,9 +5307,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422fbc7ff2f2f5bdffeb07718e5a5324dca72b0c9293d50df4026652385e3314" +checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -5555,9 +5556,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" dependencies = [ "libc", ] @@ -5994,9 +5995,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" [[package]] name = "oorandom" @@ -6006,9 +6007,9 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "op-alloy-consensus" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad134a77fdfebac469526756b207c7889593657eeaca374200332ec89175e27a" +checksum = "3ef361231f72bea90365e441bd97d9c8fd3875603f18bbcad0e04874c6158e53" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6022,9 +6023,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9fbd440cd8a5ccfa7c4c085b29fd0f0a1574fb53e1572f8e070cc105039e42b" +checksum = "e5a65da5f7591acba3d2304b25145ca9942ea90481213269aed9cb28add8e3ff" dependencies = [ "alloy-eips", "alloy-network", @@ -6493,9 +6494,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -6506,15 +6507,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -6873,7 +6874,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.12", + "rustls 0.23.13", "socket2", "thiserror", "tokio", @@ -6890,7 +6891,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.12", + "rustls 0.23.13", "slab", "thiserror", "tinyvec", @@ -7023,9 +7024,9 @@ checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" dependencies = [ "bitflags 2.6.0", ] @@ -7120,7 +7121,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-native-certs 0.7.3", "rustls-pemfile 2.1.3", "rustls-pki-types", @@ -7237,9 +7238,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.48" +version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f86ae463694029097b846d8f99fd5536740602ae00022c0c50c5600720b2f71" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" dependencies = [ "bytemuck", ] @@ -7390,9 +7391,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.36" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -7415,15 +7416,15 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "log", "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -7503,9 +7504,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", "rustls-pki-types", @@ -7612,9 +7613,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.16" +version = "2.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb7ac86243095b70a7920639507b71d51a63390d1ba26c4f60a552fbb914a37" +checksum = "0c947adb109a8afce5fc9c7bf951f87f146e9147b3a6a58413105628fb1d1e66" dependencies = [ "sdd", ] @@ -7688,9 +7689,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0495e4577c672de8254beb68d01a9b62d0e8a13c099edecdbedccce3223cd29f" +checksum = "60a7b59a5d9b0099720b417b6325d91a52cbf5b3dcb5041d864be53eefa58abc" [[package]] name = "sec1" @@ -7718,9 +7719,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" dependencies = [ "cc", ] @@ -7955,9 +7956,9 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d79b758b7cb2085612b11a235055e485605a5103faccdd633f35bd7aee69dd" +checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" dependencies = [ "cc", "cfg-if", @@ -8333,9 +8334,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e1355d44af21638c8e05d45097db6cb5ec2aa3e970c51cb2901605cf3344fa" +checksum = "4b95156f8b577cb59dc0b1df15c6f29a10afc5f8a7ac9786b0b5c68c19149278" dependencies = [ "paste", "proc-macro2", @@ -8609,7 +8610,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "tokio", ] @@ -8658,7 +8659,7 @@ checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" dependencies = [ "futures-util", "log", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -8784,9 +8785,9 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36b837f86b25d7c0d7988f00a54e74739be6477f2aac6201b8f429a7569991b7" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" dependencies = [ "futures-core", "futures-util", @@ -9000,7 +9001,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "sha1", "thiserror", @@ -9069,9 +9070,9 @@ checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -9084,9 +9085,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-truncate" From f141a4386aa24ddafa90ad50cd9ee5e93bf0d025 Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Mon, 16 Sep 2024 04:49:04 -0700 Subject: [PATCH 1444/1963] feat: transaction access list option (#8818) * add access list * fix lint * improve * set access list even if legacy is true * update grammar * update comment to doc string * call access list if no string provided * address comments * update docs * update docs again * address comments * refactor --- crates/cast/bin/tx.rs | 23 +++++++++++++++++++++-- crates/cli/src/opts/transaction.rs | 8 ++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 419ad5bb6b8de..08ee6d182a77d 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -4,12 +4,12 @@ use alloy_network::{AnyNetwork, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; use alloy_rlp::Decodable; -use alloy_rpc_types::{Authorization, TransactionInput, TransactionRequest}; +use alloy_rpc_types::{AccessList, Authorization, TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_signer::Signer; use alloy_transport::Transport; use cast::revm::primitives::SignedAuthorization; -use eyre::Result; +use eyre::{Result, WrapErr}; use foundry_cli::{ opts::TransactionOpts, utils::{self, parse_function_args}, @@ -17,6 +17,7 @@ use foundry_cli::{ use foundry_common::ens::NameOrAddress; use foundry_config::{Chain, Config}; use foundry_wallets::{WalletOpts, WalletSigner}; +use serde_json; /// Different sender kinds used by [`CastTxBuilder`]. pub enum SenderKind<'a> { @@ -134,6 +135,7 @@ pub struct CastTxBuilder { auth: Option, chain: Chain, etherscan_api_key: Option, + access_list: Option>, state: S, _t: std::marker::PhantomData, } @@ -190,6 +192,7 @@ where chain, etherscan_api_key, auth: tx_opts.auth, + access_list: tx_opts.access_list, state: InitState, _t: std::marker::PhantomData, }) @@ -206,6 +209,7 @@ where chain: self.chain, etherscan_api_key: self.etherscan_api_key, auth: self.auth, + access_list: self.access_list, state: ToState { to }, _t: self._t, }) @@ -266,6 +270,7 @@ where chain: self.chain, etherscan_api_key: self.etherscan_api_key, auth: self.auth, + access_list: self.access_list, state: InputState { kind: self.state.to.into(), input, func }, _t: self._t, }) @@ -316,6 +321,20 @@ where return Ok((self.tx, self.state.func)); } + if let Some(access_list) = match self.access_list { + None => None, + // --access-list provided with no value, call the provider to create it + Some(None) => Some(self.provider.create_access_list(&self.tx).await?.access_list), + // Access list provided as a string, attempt to parse it + Some(Some(ref s)) => Some( + serde_json::from_str::(s) + .map(AccessList::from) + .wrap_err("Failed to parse access list from string")?, + ), + } { + self.tx.set_access_list(access_list); + } + if self.legacy && self.tx.gas_price.is_none() { self.tx.gas_price = Some(self.provider.get_gas_price().await?); } diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index c443146b57db6..6730902f92a59 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -62,6 +62,14 @@ pub struct TransactionOpts { /// Can be either a hex-encoded signed authorization or an address. #[arg(long, conflicts_with_all = &["legacy", "blob"])] pub auth: Option, + + /// EIP-2930 access list. + /// + /// Accepts either a JSON-encoded access list or an empty value to create the access list + /// via an RPC call to `eth_createAccessList`. To retrieve only the access list portion, use + /// the `cast access-list` command. + #[arg(long)] + pub access_list: Option>, } #[cfg(test)] From 011dd09d3daf035f6771c7dbce705a484c98bf00 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:41:01 +0300 Subject: [PATCH 1445/1963] chore(tests): fix isolate CI + all targets / features tests (#8871) chore(tests): fix all targets / features tests --- crates/forge/tests/cli/config.rs | 6 ++- crates/forge/tests/cli/ext_integration.rs | 2 +- crates/forge/tests/cli/script.rs | 50 +++++++++++------------ crates/forge/tests/cli/test_cmd.rs | 21 ++++++---- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index b597ce439c44b..1ddd402722dd4 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -505,6 +505,7 @@ forgetest!(can_set_gas_price, |prj, cmd| { // test that we can detect remappings from foundry.toml forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { + std::env::remove_var("DAPP_REMAPPINGS"); let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); similar_asserts::assert_eq!( @@ -545,6 +546,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let toml_file = nested.join("foundry.toml"); pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); + std::env::remove_var("DAPP_REMAPPINGS"); let another_config = cmd.config(); let remappings = another_config.remappings.iter().cloned().map(Remapping::from).collect::>(); @@ -564,6 +566,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { config.src = "custom-source-dir".into(); pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); + std::env::remove_var("DAPP_REMAPPINGS"); let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); similar_asserts::assert_eq!( @@ -689,7 +692,8 @@ forgetest_init!(can_parse_default_fs_permissions, |_prj, cmd| { let config = cmd.config(); assert_eq!(config.fs_permissions.len(), 1); - let out_permission = config.fs_permissions.find_permission(Path::new("out")).unwrap(); + let permissions = config.fs_permissions.joined(Path::new("test")); + let out_permission = permissions.find_permission(Path::new("test/out")).unwrap(); assert_eq!(FsAccessPermission::Read, out_permission); }); diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 8aadad62f140c..1cf7b54ad6e9a 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -99,7 +99,7 @@ fn lil_web3() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn snekmate() { - ExtTester::new("pcaversaccio", "snekmate", "316088761ca7605216b5bfbbecca8d694c61ed98") + ExtTester::new("pcaversaccio", "snekmate", "df226f4a45e86c8f8c3ff1f9fa3443d260002050") .install_command(&["pnpm", "install", "--prefer-offline"]) // Try npm if pnpm fails / is not installed. .install_command(&["npm", "install", "--prefer-offline"]) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 2aefd985c045e..9fc398c902c9c 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -223,12 +223,12 @@ contract DeployScript is Script { [SOLC_VERSION] [ELAPSED] Compiler run successful! Traces: - [81034] DeployScript::run() + [..] DeployScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] - ├─ [45299] → new GasWaster@[..] + ├─ [..] → new GasWaster@[..] │ └─ ← [Return] 226 bytes of code - ├─ [226] GasWaster::wasteGas(200000 [2e5]) + ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -330,12 +330,12 @@ Warning (2018): Function state mutability can be restricted to view | ^ (Relevant source part starts here and spans across multiple lines). Traces: - [81034] DeployScript::run() + [..] DeployScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] - ├─ [45299] → new GasWaster@[..] + ├─ [..] → new GasWaster@[..] │ └─ ← [Return] 226 bytes of code - ├─ [226] GasWaster::wasteGas(200000 [2e5]) + ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -515,10 +515,10 @@ contract DeployScript is Script { [SOLC_VERSION] [ELAPSED] Compiler run successful! Traces: - [116040] DeployScript::run() + [..] DeployScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] - ├─ [75723] → new HashChecker@[..] + ├─ [..] → new HashChecker@[..] │ └─ ← [Return] 378 bytes of code └─ ← [Stop] @@ -595,58 +595,58 @@ contract RunScript is Script { [SOLC_VERSION] [ELAPSED] Compiler run successful! Traces: - [51327] RunScript::run() + [..] RunScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [0] VM::roll([..]) │ └─ ← [Return] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [22394] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [494] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [494] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [494] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [494] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [494] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [494] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] ├─ [0] VM::roll([..]) │ └─ ← [Return] - ├─ [494] [..]::update() + ├─ [..] [..]::update() │ └─ ← [Stop] - ├─ [239] [..]::checkLastHash() [staticcall] + ├─ [..] [..]::checkLastHash() [staticcall] │ └─ ← [Stop] └─ ← [Stop] diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 09c7e40f85e41..0254f251b0f25 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1453,10 +1453,17 @@ contract ATest is Test { ) .unwrap(); - cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" -... -[PASS] testSelfMeteringRevert() (gas: 3299) -... + cmd.args(["test"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/ATest.t.sol:ATest +[PASS] testSelfMeteringRevert() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); }); @@ -1732,12 +1739,12 @@ contract ATest is DSTest { [PASS] testResetGas() (gas: 40) [PASS] testResetGas1() (gas: 40) [PASS] testResetGas2() (gas: 40) -[PASS] testResetGas3() (gas: 134476) -[PASS] testResetGas4() (gas: 56302) +[PASS] testResetGas3() (gas: [..]) +[PASS] testResetGas4() (gas: [..]) [PASS] testResetGas5() (gas: 40) [PASS] testResetGas6() (gas: 40) [PASS] testResetGas7() (gas: 49) -[PASS] testResetGas8() (gas: 622) +[PASS] testResetGas8() (gas: [..]) [PASS] testResetGas9() (gas: 40) [PASS] testResetNegativeGas() (gas: 0) ... From 78a8d492ec95f98d9e35a81ca37511b6ffc4604c Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:11:58 +0530 Subject: [PATCH 1446/1963] feat(`anvil`): optionally preserve historical states on dump_state (#8864) --- crates/anvil/core/src/eth/mod.rs | 19 ++-- crates/anvil/src/cmd.rs | 32 +++++-- crates/anvil/src/eth/api.rs | 19 +++- crates/anvil/src/eth/backend/db.rs | 60 ++++++++++++ crates/anvil/src/eth/backend/mem/fork_db.rs | 16 +++- .../anvil/src/eth/backend/mem/in_memory_db.rs | 10 +- crates/anvil/src/eth/backend/mem/mod.rs | 30 +++++- crates/anvil/src/eth/backend/mem/storage.rs | 34 ++++++- crates/anvil/tests/it/state.rs | 94 ++++++++++++++++++- 9 files changed, 286 insertions(+), 28 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 11342b8177572..70c62ed563501 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -523,11 +523,8 @@ pub enum EthRequest { /// Serializes the current state (including contracts code, contract's storage, accounts /// properties, etc.) into a savable data blob - #[cfg_attr( - feature = "serde", - serde(rename = "anvil_dumpState", alias = "hardhat_dumpState", with = "empty_params") - )] - DumpState(()), + #[cfg_attr(feature = "serde", serde(rename = "anvil_dumpState", alias = "hardhat_dumpState"))] + DumpState(#[cfg_attr(feature = "serde", serde(default))] Option>>), /// Adds state previously dumped with `DumpState` to the current chain #[cfg_attr( @@ -1210,9 +1207,19 @@ mod tests { #[test] fn test_serde_custom_dump_state() { - let s = r#"{"method": "anvil_dumpState", "params": [] }"#; + let s = r#"{"method": "anvil_dumpState", "params": [true]}"#; let value: serde_json::Value = serde_json::from_str(s).unwrap(); let _req = serde_json::from_value::(value).unwrap(); + + let s = r#"{"method": "anvil_dumpState"}"#; + let value: serde_json::Value = serde_json::from_str(s).unwrap(); + let req = serde_json::from_value::(value).unwrap(); + match req { + EthRequest::DumpState(param) => { + assert!(param.is_none()); + } + _ => unreachable!(), + } } #[test] diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 1238e59063c82..3b7778a722468 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -149,6 +149,15 @@ pub struct NodeArgs { #[arg(long, value_name = "PATH", conflicts_with = "init")] pub dump_state: Option, + /// Preserve historical state snapshots when dumping the state. + /// + /// This will save the in-memory states of the chain at particular block hashes. + /// + /// These historical states will be loaded into the memory when `--load-state` / `--state`, and + /// aids in RPC calls beyond the block at which state was dumped. + #[arg(long, conflicts_with = "init", default_value = "false")] + pub preserve_historical_states: bool, + /// Initialize the chain from a previously saved state snapshot. #[arg( long, @@ -306,6 +315,7 @@ impl NodeArgs { let dump_state = self.dump_state_path(); let dump_interval = self.state_interval.map(Duration::from_secs).unwrap_or(DEFAULT_DUMP_INTERVAL); + let preserve_historical_states = self.preserve_historical_states; let (api, mut handle) = crate::try_spawn(self.into_node_config()?).await?; @@ -320,7 +330,8 @@ impl NodeArgs { let task_manager = handle.task_manager(); let mut on_shutdown = task_manager.on_shutdown(); - let mut state_dumper = PeriodicStateDumper::new(api, dump_state, dump_interval); + let mut state_dumper = + PeriodicStateDumper::new(api, dump_state, dump_interval, preserve_historical_states); task_manager.spawn(async move { // wait for the SIGTERM signal on unix systems @@ -588,11 +599,17 @@ struct PeriodicStateDumper { in_progress_dump: Option + Send + Sync + 'static>>>, api: EthApi, dump_state: Option, + preserve_historical_states: bool, interval: Interval, } impl PeriodicStateDumper { - fn new(api: EthApi, dump_state: Option, interval: Duration) -> Self { + fn new( + api: EthApi, + dump_state: Option, + interval: Duration, + preserve_historical_states: bool, + ) -> Self { let dump_state = dump_state.map(|mut dump_state| { if dump_state.is_dir() { dump_state = dump_state.join("state.json"); @@ -602,19 +619,19 @@ impl PeriodicStateDumper { // periodically flush the state let interval = tokio::time::interval_at(Instant::now() + interval, interval); - Self { in_progress_dump: None, api, dump_state, interval } + Self { in_progress_dump: None, api, dump_state, preserve_historical_states, interval } } async fn dump(&self) { if let Some(state) = self.dump_state.clone() { - Self::dump_state(self.api.clone(), state).await + Self::dump_state(self.api.clone(), state, self.preserve_historical_states).await } } /// Infallible state dump - async fn dump_state(api: EthApi, dump_state: PathBuf) { + async fn dump_state(api: EthApi, dump_state: PathBuf, preserve_historical_states: bool) { trace!(path=?dump_state, "Dumping state on shutdown"); - match api.serialized_state().await { + match api.serialized_state(preserve_historical_states).await { Ok(state) => { if let Err(err) = foundry_common::fs::write_json_file(&dump_state, &state) { error!(?err, "Failed to dump state"); @@ -655,7 +672,8 @@ impl Future for PeriodicStateDumper { if this.interval.poll_tick(cx).is_ready() { let api = this.api.clone(); let path = this.dump_state.clone().expect("exists; see above"); - this.in_progress_dump = Some(Box::pin(Self::dump_state(api, path))); + this.in_progress_dump = + Some(Box::pin(Self::dump_state(api, path, this.preserve_historical_states))); } else { break } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 90cdc100699e4..f856fef42c5ae 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -351,7 +351,10 @@ impl EthApi { EthRequest::SetNextBlockBaseFeePerGas(gas) => { self.anvil_set_next_block_base_fee_per_gas(gas).await.to_rpc_result() } - EthRequest::DumpState(_) => self.anvil_dump_state().await.to_rpc_result(), + EthRequest::DumpState(preserve_historical_states) => self + .anvil_dump_state(preserve_historical_states.and_then(|s| s.params)) + .await + .to_rpc_result(), EthRequest::LoadState(buf) => self.anvil_load_state(buf).await.to_rpc_result(), EthRequest::NodeInfo(_) => self.anvil_node_info().await.to_rpc_result(), EthRequest::AnvilMetadata(_) => self.anvil_metadata().await.to_rpc_result(), @@ -1839,14 +1842,20 @@ impl EthApi { /// process by calling `anvil_loadState` /// /// Handler for RPC call: `anvil_dumpState` - pub async fn anvil_dump_state(&self) -> Result { + pub async fn anvil_dump_state( + &self, + preserve_historical_states: Option, + ) -> Result { node_info!("anvil_dumpState"); - self.backend.dump_state().await + self.backend.dump_state(preserve_historical_states.unwrap_or(false)).await } /// Returns the current state - pub async fn serialized_state(&self) -> Result { - self.backend.serialized_state().await + pub async fn serialized_state( + &self, + preserve_historical_states: bool, + ) -> Result { + self.backend.serialized_state(preserve_historical_states).await } /// Append chain state buffer to current chain. Will overwrite any conflicting addresses or diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 6c16f694dac5d..39edbd8cd27dc 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -32,6 +32,11 @@ pub trait MaybeFullDatabase: DatabaseRef { /// Clear the state and move it into a new `StateSnapshot` fn clear_into_snapshot(&mut self) -> StateSnapshot; + /// Read the state snapshot + /// + /// This clones all the states and returns a new `StateSnapshot` + fn read_as_snapshot(&self) -> StateSnapshot; + /// Clears the entire database fn clear(&mut self); @@ -51,6 +56,10 @@ where unreachable!("never called for DatabaseRef") } + fn read_as_snapshot(&self) -> StateSnapshot { + unreachable!("never called for DatabaseRef") + } + fn clear(&mut self) {} fn init_from_snapshot(&mut self, _snapshot: StateSnapshot) {} @@ -124,6 +133,7 @@ pub trait Db: best_number: U64, blocks: Vec, transactions: Vec, + historical_states: Option, ) -> DatabaseResult>; /// Deserialize and add all chain data to the backend storage @@ -198,6 +208,7 @@ impl + Send + Sync + Clone + fmt::Debug> D _best_number: U64, _blocks: Vec, _transaction: Vec, + _historical_states: Option, ) -> DatabaseResult> { Ok(None) } @@ -235,6 +246,22 @@ impl> MaybeFullDatabase for CacheDB { StateSnapshot { accounts, storage: account_storage, block_hashes } } + fn read_as_snapshot(&self) -> StateSnapshot { + let db_accounts = self.accounts.clone(); + let mut accounts = HashMap::new(); + let mut account_storage = HashMap::new(); + + for (addr, acc) in db_accounts { + account_storage.insert(addr, acc.storage.clone()); + let mut info = acc.info; + info.code = self.contracts.get(&info.code_hash).cloned(); + accounts.insert(addr, info); + } + + let block_hashes = self.block_hashes.clone(); + StateSnapshot { accounts, storage: account_storage, block_hashes } + } + fn clear(&mut self) { self.clear_into_snapshot(); } @@ -280,6 +307,12 @@ impl StateDb { pub fn new(db: impl MaybeFullDatabase + Send + Sync + 'static) -> Self { Self(Box::new(db)) } + + pub fn serialize_state(&mut self) -> StateSnapshot { + // Using read_as_snapshot makes sures we don't clear the historical state from the current + // instance. + self.read_as_snapshot() + } } impl DatabaseRef for StateDb { @@ -310,6 +343,10 @@ impl MaybeFullDatabase for StateDb { self.0.clear_into_snapshot() } + fn read_as_snapshot(&self) -> StateSnapshot { + self.0.read_as_snapshot() + } + fn clear(&mut self) { self.0.clear() } @@ -332,6 +369,11 @@ pub struct SerializableState { pub blocks: Vec, #[serde(default)] pub transactions: Vec, + /// Historical states of accounts and storage at particular block hashes. + /// + /// Note: This is an Option for backwards compatibility. + #[serde(default)] + pub historical_states: Option, } impl SerializableState { @@ -444,3 +486,21 @@ impl From for MinedTransaction { } } } + +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct SerializableHistoricalStates(Vec<(B256, StateSnapshot)>); + +impl SerializableHistoricalStates { + pub const fn new(states: Vec<(B256, StateSnapshot)>) -> Self { + Self(states) + } +} + +impl IntoIterator for SerializableHistoricalStates { + type Item = (B256, StateSnapshot); + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() + } +} diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index bd879f8f42019..1329de724a1c4 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -1,7 +1,7 @@ use crate::{ eth::backend::db::{ Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableBlock, - SerializableState, SerializableTransaction, StateDb, + SerializableHistoricalStates, SerializableState, SerializableTransaction, StateDb, }, revm::primitives::AccountInfo, }; @@ -38,6 +38,7 @@ impl Db for ForkedDatabase { best_number: U64, blocks: Vec, transactions: Vec, + historical_states: Option, ) -> DatabaseResult> { let mut db = self.database().clone(); let accounts = self @@ -68,6 +69,7 @@ impl Db for ForkedDatabase { best_block_number: Some(best_number), blocks, transactions, + historical_states, })) } @@ -93,6 +95,14 @@ impl MaybeFullDatabase for ForkedDatabase { StateSnapshot { accounts, storage, block_hashes } } + fn read_as_snapshot(&self) -> StateSnapshot { + let db = self.inner().db(); + let accounts = db.accounts.read().clone(); + let storage = db.storage.read().clone(); + let block_hashes = db.block_hashes.read().clone(); + StateSnapshot { accounts, storage, block_hashes } + } + fn clear(&mut self) { self.flush_cache(); self.clear_into_snapshot(); @@ -112,6 +122,10 @@ impl MaybeFullDatabase for ForkDbSnapshot { std::mem::take(&mut self.snapshot) } + fn read_as_snapshot(&self) -> StateSnapshot { + self.snapshot.clone() + } + fn clear(&mut self) { std::mem::take(&mut self.snapshot); self.local.clear() diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 2abee72ef33cf..56cd3815cb08c 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -3,7 +3,7 @@ use crate::{ eth::backend::db::{ Db, MaybeForkedDatabase, MaybeFullDatabase, SerializableAccountRecord, SerializableBlock, - SerializableState, SerializableTransaction, StateDb, + SerializableHistoricalStates, SerializableState, SerializableTransaction, StateDb, }, mem::state::state_root, revm::{db::DbAccount, primitives::AccountInfo}, @@ -38,6 +38,7 @@ impl Db for MemDb { best_number: U64, blocks: Vec, transactions: Vec, + historical_states: Option, ) -> DatabaseResult> { let accounts = self .inner @@ -68,6 +69,7 @@ impl Db for MemDb { best_block_number: Some(best_number), blocks, transactions, + historical_states, })) } @@ -110,6 +112,10 @@ impl MaybeFullDatabase for MemDb { self.inner.clear_into_snapshot() } + fn read_as_snapshot(&self) -> StateSnapshot { + self.inner.read_as_snapshot() + } + fn clear(&mut self) { self.inner.clear(); } @@ -165,7 +171,7 @@ mod tests { // blocks dumping/loading tested in storage.rs let state = dump_db - .dump_state(Default::default(), U64::ZERO, Vec::new(), Vec::new()) + .dump_state(Default::default(), U64::ZERO, Vec::new(), Vec::new(), Default::default()) .unwrap() .unwrap(); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 6a0aeadeea9e2..5e71892a31e87 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -758,12 +758,27 @@ impl Backend { } /// Get the current state. - pub async fn serialized_state(&self) -> Result { + pub async fn serialized_state( + &self, + preserve_historical_states: bool, + ) -> Result { let at = self.env.read().block.clone(); let best_number = self.blockchain.storage.read().best_number; let blocks = self.blockchain.storage.read().serialized_blocks(); let transactions = self.blockchain.storage.read().serialized_transactions(); - let state = self.db.read().await.dump_state(at, best_number, blocks, transactions)?; + let historical_states = if preserve_historical_states { + Some(self.states.write().serialized_states()) + } else { + None + }; + + let state = self.db.read().await.dump_state( + at, + best_number, + blocks, + transactions, + historical_states, + )?; state.ok_or_else(|| { RpcError::invalid_params("Dumping state not supported with the current configuration") .into() @@ -771,8 +786,11 @@ impl Backend { } /// Write all chain data to serialized bytes buffer - pub async fn dump_state(&self) -> Result { - let state = self.serialized_state().await?; + pub async fn dump_state( + &self, + preserve_historical_states: bool, + ) -> Result { + let state = self.serialized_state(preserve_historical_states).await?; let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); encoder .write_all(&serde_json::to_vec(&state).unwrap_or_default()) @@ -802,6 +820,10 @@ impl Backend { self.blockchain.storage.write().load_blocks(state.blocks.clone()); self.blockchain.storage.write().load_transactions(state.transactions.clone()); + if let Some(historical_states) = state.historical_states { + self.states.write().load_states(historical_states); + } + Ok(true) } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 2b5886a6f1768..f999a512a5886 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -1,7 +1,10 @@ //! In-memory blockchain storage use crate::eth::{ backend::{ - db::{MaybeFullDatabase, SerializableBlock, SerializableTransaction, StateDb}, + db::{ + MaybeFullDatabase, SerializableBlock, SerializableHistoricalStates, + SerializableTransaction, StateDb, + }, mem::cache::DiskStateCache, }, error::BlockchainError, @@ -25,6 +28,7 @@ use anvil_core::eth::{ }; use anvil_rpc::error::RpcError; use foundry_evm::{ + backend::MemDb, revm::primitives::Env, traces::{ CallKind, FourByteInspector, GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig, @@ -188,6 +192,34 @@ impl InMemoryBlockStates { self.disk_cache.remove(on_disk) } } + + /// Serialize all states to a list of serializable historical states + pub fn serialized_states(&mut self) -> SerializableHistoricalStates { + // Get in-memory states + let mut states = self + .states + .iter_mut() + .map(|(hash, state)| (*hash, state.serialize_state())) + .collect::>(); + + // Get on-disk state snapshots + self.on_disk_states.iter().for_each(|(hash, _)| { + if let Some(snapshot) = self.disk_cache.read(*hash) { + states.push((*hash, snapshot)); + } + }); + + SerializableHistoricalStates::new(states) + } + + /// Load states from serialized data + pub fn load_states(&mut self, states: SerializableHistoricalStates) { + for (hash, snapshot) in states { + let mut state_db = StateDb::new(MemDb::default()); + state_db.init_from_snapshot(snapshot); + self.insert(hash, state_db); + } + } } impl fmt::Debug for InMemoryBlockStates { diff --git a/crates/anvil/tests/it/state.rs b/crates/anvil/tests/it/state.rs index 4e96ab0f11633..7ed11ca46fa55 100644 --- a/crates/anvil/tests/it/state.rs +++ b/crates/anvil/tests/it/state.rs @@ -1,6 +1,9 @@ //! general eth api tests -use alloy_primitives::Uint; +use crate::abi::Greeter; +use alloy_primitives::{Bytes, Uint}; +use alloy_provider::Provider; +use alloy_rpc_types::BlockId; use anvil::{spawn, NodeConfig}; #[tokio::test(flavor = "multi_thread")] @@ -14,7 +17,7 @@ async fn can_load_state() { let num = api.block_number().unwrap(); - let state = api.serialized_state().await.unwrap(); + let state = api.serialized_state(false).await.unwrap(); foundry_common::fs::write_json_file(&state_file, &state).unwrap(); let (api, _handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; @@ -42,3 +45,90 @@ async fn can_load_existing_state() { let block_number = api.block_number().unwrap(); assert_eq!(block_number, Uint::from(2)); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_make_sure_historical_state_is_not_cleared_on_dump() { + let tmp = tempfile::tempdir().unwrap(); + let state_file = tmp.path().join("state.json"); + + let (api, handle) = spawn(NodeConfig::test()).await; + + let provider = handle.http_provider(); + + let greeter = Greeter::deploy(&provider, "Hello".to_string()).await.unwrap(); + + let address = greeter.address(); + + let _tx = greeter + .setGreeting("World!".to_string()) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + + api.mine_one().await; + + let ser_state = api.serialized_state(true).await.unwrap(); + foundry_common::fs::write_json_file(&state_file, &ser_state).unwrap(); + + let block_number = api.block_number().unwrap(); + assert_eq!(block_number, Uint::from(3)); + + // Makes sure historical states of the new instance are not cleared. + let code = provider.get_code_at(*address).block_id(BlockId::number(2)).await.unwrap(); + + assert_ne!(code, Bytes::new()); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_preserve_historical_states_between_dump_and_load() { + let tmp = tempfile::tempdir().unwrap(); + let state_file = tmp.path().join("state.json"); + + let (api, handle) = spawn(NodeConfig::test()).await; + + let provider = handle.http_provider(); + + let greeter = Greeter::deploy(&provider, "Hello".to_string()).await.unwrap(); + + let address = greeter.address(); + + let deploy_blk_num = provider.get_block_number().await.unwrap(); + + let tx = greeter + .setGreeting("World!".to_string()) + .send() + .await + .unwrap() + .get_receipt() + .await + .unwrap(); + + let change_greeting_blk_num = tx.block_number.unwrap(); + + api.mine_one().await; + + let ser_state = api.serialized_state(true).await.unwrap(); + foundry_common::fs::write_json_file(&state_file, &ser_state).unwrap(); + + let (api, handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; + + let block_number = api.block_number().unwrap(); + assert_eq!(block_number, Uint::from(3)); + + let provider = handle.http_provider(); + + let greeter = Greeter::new(*address, provider); + + let greeting_at_init = + greeter.greet().block(BlockId::number(deploy_blk_num)).call().await.unwrap()._0; + + assert_eq!(greeting_at_init, "Hello"); + + let greeting_after_change = + greeter.greet().block(BlockId::number(change_greeting_blk_num)).call().await.unwrap()._0; + + assert_eq!(greeting_after_change, "World!"); +} From 81349edd7b1d35df77a7e12ab955b237c1a33171 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:50:00 +0200 Subject: [PATCH 1447/1963] docs(dev): update cheatcode docs (#8872) --- crates/cheatcodes/src/lib.rs | 3 ++- docs/dev/cheatcodes.md | 28 ++++++++-------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 4bd0b22a3436e..4a06ff454df36 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -80,8 +80,9 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { fn apply_full( &self, ccx: &mut CheatsCtxt, - _executor: &mut E, + executor: &mut E, ) -> Result { + let _ = executor; self.apply_stateful(ccx) } } diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index 9ca0368d33c07..1e95bf7f266cb 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -6,22 +6,14 @@ manipulate the environment in which the execution is run. Most of the time, simply testing your smart contracts outputs isn't enough. To manipulate the state of the EVM, as well as test for specific reverts and events, Foundry is shipped with a set of cheatcodes. -## [`revm::Inspector`](https://docs.rs/revm/3.3.0/revm/trait.Inspector.html) +## [`revm::Inspector`](https://docs.rs/revm/latest/revm/trait.Inspector.html) -To understand how cheatcodes are implemented, we first need to look at [`revm::Inspector`](https://docs.rs/revm/3.3.0/revm/trait.Inspector.html), +To understand how cheatcodes are implemented, we first need to look at [`revm::Inspector`](https://docs.rs/revm/latest/revm/trait.Inspector.html), a trait that provides a set of callbacks to be notified at certain stages of EVM execution. -For example, [`Inspector::call`](https://docs.rs/revm/3.3.0/revm/trait.Inspector.html#method.call) -is called when the EVM is about to execute a call: - -```rust -fn call( - &mut self, - data: &mut EVMData<'_, DB>, - inputs: &mut CallInputs, - is_static: bool, -) -> (InstructionResult, Gas, Bytes) { ... } -``` +For example, [`Inspector::call`](https://docs.rs/revm/latest/revm/trait.Inspector.html#method.call) +is called when the EVM is about to execute a call and is provided with the call's inputs and the +current state of the EVM. ## [Foundry inspectors](../../crates/evm/evm/src/inspectors/) @@ -45,12 +37,7 @@ Since cheatcodes are bound to a constant address, the cheatcode inspector listen ```rust impl Inspector for Cheatcodes { - fn call( - &mut self, - data: &mut EVMData<'_, DB>, - call: &mut CallInputs, - is_static: bool, - ) -> (Return, Gas, Bytes) { + fn call(&mut self, ...) -> ... { if call.contract == CHEATCODE_ADDRESS { // intercepted cheatcode call // --snip-- @@ -141,7 +128,8 @@ Multiple attributes can be specified by separating them with commas, e.g. `#[che This trait defines the interface that all cheatcode implementations must implement. There are two methods that can be implemented: - `apply`: implemented when the cheatcode is pure and does not need to access EVM data -- `apply_full`: implemented when the cheatcode needs to access EVM data +- `apply_stateful`: implemented when the cheatcode needs to access EVM data +- `apply_full`: implemented when the cheatcode needs to access EVM data and the EVM executor itself, for example to recursively call back into the EVM to execute an arbitrary transaction Only one of these methods can be implemented. From 41d4e5437107f6f42c7711123890147bc736a609 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:09:25 +0200 Subject: [PATCH 1448/1963] docs: improve `optimizer_runs` documentation to be more accurate (#8875) improve optimizer_runs documentation --- crates/cli/src/opts/build/mod.rs | 6 +++++- crates/config/src/lib.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index 4ffd1c3bff996..dfd5d83668299 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -30,7 +30,11 @@ pub struct CompilerArgs { #[serde(skip)] pub optimize: bool, - /// The number of optimizer runs. + /// The number of runs specifies roughly how often each opcode of the deployed code will be + /// executed across the life-time of the contract. This means it is a trade-off parameter + /// between code size (deploy cost) and code execution cost (cost after deployment). + /// An `optimizer_runs` parameter of `1` will produce short but expensive code. In contrast, a + /// larger `optimizer_runs` parameter will produce longer but more gas efficient code. #[arg(long, value_name = "RUNS")] #[serde(skip_serializing_if = "Option::is_none")] pub optimizer_runs: Option, diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 34ebe62f59e80..d77e30492fc5b 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -212,7 +212,16 @@ pub struct Config { pub offline: bool, /// Whether to activate optimizer pub optimizer: bool, - /// Sets the optimizer runs + /// The number of runs specifies roughly how often each opcode of the deployed code will be + /// executed across the life-time of the contract. This means it is a trade-off parameter + /// between code size (deploy cost) and code execution cost (cost after deployment). + /// An `optimizer_runs` parameter of `1` will produce short but expensive code. In contrast, a + /// larger `optimizer_runs` parameter will produce longer but more gas efficient code. The + /// maximum value of the parameter is `2**32-1`. + /// + /// A common misconception is that this parameter specifies the number of iterations of the + /// optimizer. This is not true: The optimizer will always run as many times as it can + /// still improve the code. pub optimizer_runs: usize, /// Switch optimizer components on or off in detail. /// The "enabled" switch above provides two defaults which can be From 7428b6f01d1b1db4a6f031e51eda6275035d0f7d Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:58:54 +0530 Subject: [PATCH 1449/1963] fix(`cheatcodes`): apply_stateful in mockCallRevert (#8880) * fix(`cheatcodes`): apply_stateful in mockCallRevert * nit --- crates/cheatcodes/src/evm/mock.rs | 38 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index cd7c459b6b177..01a02c5c21c9d 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -1,6 +1,6 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_primitives::{Address, Bytes, U256}; -use revm::{interpreter::InstructionResult, primitives::Bytecode}; +use revm::{interpreter::InstructionResult, primitives::Bytecode, InnerEvmContext}; use std::cmp::Ordering; /// Mocked call data. @@ -49,15 +49,7 @@ impl Cheatcode for clearMockedCallsCall { impl Cheatcode for mockCall_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; - let acc = ccx.ecx.load_account(*callee)?; - - // Etches a single byte onto the account if it is empty to circumvent the `extcodesize` - // check Solidity might perform. - let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty); - if empty_bytecode { - let code = Bytecode::new_raw(Bytes::from_static(&[0u8])); - ccx.ecx.journaled_state.set_code(*callee, code); - } + let _ = make_acc_non_empty(callee, ccx.ecx)?; mock_call(ccx.state, callee, data, None, returnData, InstructionResult::Return); Ok(Default::default()) @@ -74,17 +66,21 @@ impl Cheatcode for mockCall_1Call { } impl Cheatcode for mockCallRevert_0Call { - fn apply(&self, state: &mut Cheatcodes) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, revertData } = self; - mock_call(state, callee, data, None, revertData, InstructionResult::Revert); + let _ = make_acc_non_empty(callee, ccx.ecx)?; + + mock_call(ccx.state, callee, data, None, revertData, InstructionResult::Revert); Ok(Default::default()) } } impl Cheatcode for mockCallRevert_1Call { - fn apply(&self, state: &mut Cheatcodes) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, msgValue, data, revertData } = self; - mock_call(state, callee, data, Some(msgValue), revertData, InstructionResult::Revert); + let _ = make_acc_non_empty(callee, ccx.ecx)?; + + mock_call(ccx.state, callee, data, Some(msgValue), revertData, InstructionResult::Revert); Ok(Default::default()) } } @@ -112,3 +108,17 @@ fn mock_call( MockCallReturnData { ret_type, data: Bytes::copy_from_slice(rdata) }, ); } + +// Etches a single byte onto the account if it is empty to circumvent the `extcodesize` +// check Solidity might perform. +fn make_acc_non_empty(callee: &Address, ecx: &mut InnerEvmContext) -> Result { + let acc = ecx.load_account(*callee)?; + + let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty); + if empty_bytecode { + let code = Bytecode::new_raw(Bytes::from_static(&[0u8])); + ecx.journaled_state.set_code(*callee, code); + } + + Ok(Default::default()) +} From 604ce1d60bd81fe8a7e5e51d1424121f631caf40 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:42:59 +0300 Subject: [PATCH 1450/1963] fix(test): increment nonce for calls too when isolate (#8878) fix(test): increment nonce for calls too when isolate (#8854) --- crates/cheatcodes/src/inspector.rs | 12 +++++------ crates/evm/evm/src/inspectors/stack.rs | 30 +------------------------- testdata/default/cheats/Nonce.t.sol | 30 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 testdata/default/cheats/Nonce.t.sol diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 779c4ac35c3ca..b5e96eeb230c4 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -993,12 +993,12 @@ impl Cheatcodes { }); debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable call"); - let prev = account.info.nonce; - - // Touch account to ensure that incremented nonce is committed - account.mark_touch(); - account.info.nonce += 1; - debug!(target: "cheatcodes", address=%broadcast.new_origin, nonce=prev+1, prev, "incremented nonce"); + // Explicitly increment nonce if calls are not isolated. + if !self.config.evm_opts.isolate { + let prev = account.info.nonce; + account.info.nonce += 1; + debug!(target: "cheatcodes", address=%broadcast.new_origin, nonce=prev+1, prev, "incremented nonce"); + } } else if broadcast.single_call { let msg = "`staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead"; diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 3df8dc8f01dab..30271910b95b5 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -257,15 +257,8 @@ pub struct InspectorData { /// non-isolated mode. For descriptions and workarounds for those changes see: #[derive(Debug, Clone)] pub struct InnerContextData { - /// The sender of the inner EVM context. - /// It is also an origin of the transaction that created the inner EVM context. - sender: Address, - /// Nonce of the sender before invocation of the inner EVM context. - original_sender_nonce: u64, /// Origin of the transaction in the outer EVM context. original_origin: Address, - /// Whether the inner context was created by a CREATE transaction. - is_create: bool, } /// An inspector that calls multiple inspectors in sequence. @@ -490,14 +483,6 @@ impl<'a> InspectorStackRefMut<'a> { fn adjust_evm_data_for_inner_context(&mut self, ecx: &mut EvmContext) { let inner_context_data = self.inner_context_data.as_ref().expect("should be called in inner context"); - let sender_acc = ecx - .journaled_state - .state - .get_mut(&inner_context_data.sender) - .expect("failed to load sender"); - if !inner_context_data.is_create { - sender_acc.info.nonce = inner_context_data.original_sender_nonce; - } ecx.env.tx.caller = inner_context_data.original_origin; } @@ -541,13 +526,6 @@ impl<'a> InspectorStackRefMut<'a> { ecx.db.commit(ecx.journaled_state.state.clone()); - let nonce = ecx - .journaled_state - .load_account(caller, &mut ecx.db) - .expect("failed to load caller") - .info - .nonce; - let cached_env = ecx.env.clone(); ecx.env.block.basefee = U256::ZERO; @@ -555,7 +533,6 @@ impl<'a> InspectorStackRefMut<'a> { ecx.env.tx.transact_to = transact_to; ecx.env.tx.data = input; ecx.env.tx.value = value; - ecx.env.tx.nonce = Some(nonce); // Add 21000 to the gas limit to account for the base cost of transaction. ecx.env.tx.gas_limit = gas_limit + 21000; // If we haven't disabled gas limit checks, ensure that transaction gas limit will not @@ -566,12 +543,7 @@ impl<'a> InspectorStackRefMut<'a> { } ecx.env.tx.gas_price = U256::ZERO; - self.inner_context_data = Some(InnerContextData { - sender: ecx.env.tx.caller, - original_origin: cached_env.tx.caller, - original_sender_nonce: nonce, - is_create: matches!(transact_to, TxKind::Create), - }); + self.inner_context_data = Some(InnerContextData { original_origin: cached_env.tx.caller }); self.in_inner_context = true; let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); diff --git a/testdata/default/cheats/Nonce.t.sol b/testdata/default/cheats/Nonce.t.sol new file mode 100644 index 0000000000000..5dd8b0c6a268a --- /dev/null +++ b/testdata/default/cheats/Nonce.t.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Counter { + uint256 public count; + + function increment() public { + count += 1; + } +} + +contract NonceIsolatedTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testIncrementNonce() public { + address bob = address(14); + vm.startPrank(bob); + Counter counter = new Counter(); + assertEq(vm.getNonce(bob), 1); + counter.increment(); + assertEq(vm.getNonce(bob), 2); + new Counter(); + assertEq(vm.getNonce(bob), 3); + counter.increment(); + assertEq(vm.getNonce(bob), 4); + } +} From 2b390940bcfe01d066cf71b67d5ccc43f975e6d0 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:33:32 +0300 Subject: [PATCH 1451/1963] feat(cheatcodes): expectRevert with specific reverter address (#8770) * feat(cheatcodes): expectRevert with specific reverter address * Support assert revert of the given contract at any subcall of the next call --- crates/cheatcodes/assets/cheatcodes.json | 82 +++++++++++- crates/cheatcodes/spec/src/vm.rs | 16 +++ crates/cheatcodes/src/inspector.rs | 19 ++- crates/cheatcodes/src/test/expect.rs | 121 +++++++++++++++-- crates/evm/core/src/decode.rs | 20 +++ crates/forge/tests/it/fuzz.rs | 2 +- testdata/cheats/Vm.sol | 4 + testdata/default/cheats/ExpectRevert.t.sol | 148 +++++++++++++++++++++ 8 files changed, 390 insertions(+), 22 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 567167e215dbb..88c65137cda27 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4753,7 +4753,7 @@ }, { "func": { - "id": "expectPartialRevert", + "id": "expectPartialRevert_0", "description": "Expects an error on next call that starts with the revert data.", "declaration": "function expectPartialRevert(bytes4 revertData) external;", "visibility": "external", @@ -4771,6 +4771,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "expectPartialRevert_1", + "description": "Expects an error on next call to reverter address, that starts with the revert data.", + "declaration": "function expectPartialRevert(bytes4 revertData, address reverter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectPartialRevert(bytes4,address)", + "selector": "0x51aa008a", + "selectorBytes": [ + 81, + 170, + 0, + 138 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "expectRevert_0", @@ -4831,6 +4851,66 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "expectRevert_3", + "description": "Expects an error with any revert data on next call to reverter address.", + "declaration": "function expectRevert(address reverter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(address)", + "selector": "0xd814f38a", + "selectorBytes": [ + 216, + 20, + 243, + 138 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_4", + "description": "Expects an error from reverter address on next call, with any revert data.", + "declaration": "function expectRevert(bytes4 revertData, address reverter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes4,address)", + "selector": "0x260bc5de", + "selectorBytes": [ + 38, + 11, + 197, + 222 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_5", + "description": "Expects an error from reverter address on next call, that exactly matches the revert data.", + "declaration": "function expectRevert(bytes calldata revertData, address reverter) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes,address)", + "selector": "0x61ebcf12", + "selectorBytes": [ + 97, + 235, + 207, + 18 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "expectSafeMemory", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 49aeaa211cea6..9c19196c82095 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -812,10 +812,26 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectRevert(bytes calldata revertData) external; + /// Expects an error with any revert data on next call to reverter address. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(address reverter) external; + + /// Expects an error from reverter address on next call, with any revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes4 revertData, address reverter) external; + + /// Expects an error from reverter address on next call, that exactly matches the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes calldata revertData, address reverter) external; + /// Expects an error on next call that starts with the revert data. #[cheatcode(group = Testing, safety = Unsafe)] function expectPartialRevert(bytes4 revertData) external; + /// Expects an error on next call to reverter address, that starts with the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectPartialRevert(bytes4 revertData, address reverter) external; + /// Expects an error on next cheatcode call with any revert data. #[cheatcode(group = Testing, safety = Unsafe, status = Internal)] function _expectCheatcodeRevert() external; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index b5e96eeb230c4..d254a9b668dde 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -729,8 +729,7 @@ impl Cheatcodes { return match expect::handle_expect_revert( false, true, - expected_revert.reason.as_deref(), - expected_revert.partial_match, + &expected_revert, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, @@ -1234,8 +1233,17 @@ impl Inspector for Cheatcodes { } } - // Handle expected reverts - if let Some(expected_revert) = &self.expected_revert { + // Handle expected reverts. + if let Some(expected_revert) = &mut self.expected_revert { + // Record current reverter address before processing the expect revert if call reverted, + // expect revert is set with expected reverter address and no actual reverter set yet. + if outcome.result.is_revert() && + expected_revert.reverter.is_some() && + expected_revert.reverted_by.is_none() + { + expected_revert.reverted_by = Some(call.target_address); + } + if ecx.journaled_state.depth() <= expected_revert.depth { let needs_processing = match expected_revert.kind { ExpectedRevertKind::Default => !cheatcode_call, @@ -1251,8 +1259,7 @@ impl Inspector for Cheatcodes { return match expect::handle_expect_revert( cheatcode_call, false, - expected_revert.reason.as_deref(), - expected_revert.partial_match, + &expected_revert, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index df9c480e3aa4d..066c900b3ae36 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -80,6 +80,10 @@ pub struct ExpectedRevert { pub kind: ExpectedRevertKind, /// If true then only the first 4 bytes of expected data returned by the revert are checked. pub partial_match: bool, + /// Contract expected to revert next call. + pub reverter: Option
, + /// Actual reverter of the call. + pub reverted_by: Option
, } #[derive(Clone, Debug)] @@ -288,7 +292,7 @@ impl Cheatcode for expectEmitAnonymous_3Call { impl Cheatcode for expectRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false, false) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false, false, None) } } @@ -301,6 +305,7 @@ impl Cheatcode for expectRevert_1Call { ccx.ecx.journaled_state.depth(), false, false, + None, ) } } @@ -308,11 +313,60 @@ impl Cheatcode for expectRevert_1Call { impl Cheatcode for expectRevert_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), false, false) + expect_revert( + ccx.state, + Some(revertData), + ccx.ecx.journaled_state.depth(), + false, + false, + None, + ) } } -impl Cheatcode for expectPartialRevertCall { +impl Cheatcode for expectRevert_3Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { reverter } = self; + expect_revert( + ccx.state, + None, + ccx.ecx.journaled_state.depth(), + false, + false, + Some(*reverter), + ) + } +} + +impl Cheatcode for expectRevert_4Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData, reverter } = self; + expect_revert( + ccx.state, + Some(revertData.as_ref()), + ccx.ecx.journaled_state.depth(), + false, + false, + Some(*reverter), + ) + } +} + +impl Cheatcode for expectRevert_5Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData, reverter } = self; + expect_revert( + ccx.state, + Some(revertData), + ccx.ecx.journaled_state.depth(), + false, + false, + Some(*reverter), + ) + } +} + +impl Cheatcode for expectPartialRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert( @@ -321,13 +375,28 @@ impl Cheatcode for expectPartialRevertCall { ccx.ecx.journaled_state.depth(), false, true, + None, + ) + } +} + +impl Cheatcode for expectPartialRevert_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData, reverter } = self; + expect_revert( + ccx.state, + Some(revertData.as_ref()), + ccx.ecx.journaled_state.depth(), + false, + true, + Some(*reverter), ) } } impl Cheatcode for _expectCheatcodeRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true, false) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true, false, None) } } @@ -340,6 +409,7 @@ impl Cheatcode for _expectCheatcodeRevert_1Call { ccx.ecx.journaled_state.depth(), true, false, + None, ) } } @@ -347,7 +417,14 @@ impl Cheatcode for _expectCheatcodeRevert_1Call { impl Cheatcode for _expectCheatcodeRevert_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; - expect_revert(ccx.state, Some(revertData), ccx.ecx.journaled_state.depth(), true, false) + expect_revert( + ccx.state, + Some(revertData), + ccx.ecx.journaled_state.depth(), + true, + false, + None, + ) } } @@ -581,6 +658,7 @@ fn expect_revert( depth: u64, cheatcode: bool, partial_match: bool, + reverter: Option
, ) -> Result { ensure!( state.expected_revert.is_none(), @@ -595,6 +673,8 @@ fn expect_revert( ExpectedRevertKind::Default }, partial_match, + reverter, + reverted_by: None, }); Ok(Default::default()) } @@ -602,8 +682,7 @@ fn expect_revert( pub(crate) fn handle_expect_revert( is_cheatcode: bool, is_create: bool, - expected_revert: Option<&[u8]>, - partial_match: bool, + expected_revert: &ExpectedRevert, status: InstructionResult, retdata: Bytes, known_contracts: &Option, @@ -618,19 +697,33 @@ pub(crate) fn handle_expect_revert( ensure!(!matches!(status, return_ok!()), "next call did not revert as expected"); + // If expected reverter address is set then check it matches the actual reverter. + if let (Some(expected_reverter), Some(actual_reverter)) = + (expected_revert.reverter, expected_revert.reverted_by) + { + if expected_reverter != actual_reverter { + return Err(fmt_err!( + "Reverter != expected reverter: {} != {}", + actual_reverter, + expected_reverter + )); + } + } + + let expected_reason = expected_revert.reason.as_deref(); // If None, accept any revert. - let Some(expected_revert) = expected_revert else { + let Some(expected_reason) = expected_reason else { return Ok(success_return()); }; - if !expected_revert.is_empty() && retdata.is_empty() { + if !expected_reason.is_empty() && retdata.is_empty() { bail!("call reverted as expected, but without data"); } let mut actual_revert: Vec = retdata.into(); // Compare only the first 4 bytes if partial match. - if partial_match && actual_revert.get(..4) == expected_revert.get(..4) { + if expected_revert.partial_match && actual_revert.get(..4) == expected_reason.get(..4) { return Ok(success_return()) } @@ -644,8 +737,8 @@ pub(crate) fn handle_expect_revert( } } - if actual_revert == expected_revert || - (is_cheatcode && memchr::memmem::find(&actual_revert, expected_revert).is_some()) + if actual_revert == expected_reason || + (is_cheatcode && memchr::memmem::find(&actual_revert, expected_reason).is_some()) { Ok(success_return()) } else { @@ -653,7 +746,7 @@ pub(crate) fn handle_expect_revert( let decoder = RevertDecoder::new().with_abis(contracts.iter().map(|(_, c)| &c.abi)); ( &decoder.decode(actual_revert.as_slice(), Some(status)), - &decoder.decode(expected_revert, Some(status)), + &decoder.decode(expected_reason, Some(status)), ) } else { let stringify = |data: &[u8]| { @@ -665,7 +758,7 @@ pub(crate) fn handle_expect_revert( } hex::encode_prefixed(data) }; - (&stringify(&actual_revert), &stringify(expected_revert)) + (&stringify(&actual_revert), &stringify(expected_reason)) }; Err(fmt_err!("Error != expected error: {} != {}", actual, expected,)) } diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index b777ec4537bba..5f3e86281ef95 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -175,11 +175,31 @@ impl RevertDecoder { let e = Vm::expectRevert_2Call::abi_decode_raw(data, false).ok()?; return self.maybe_decode(&e.revertData[..], status); } + // `expectRevert(bytes,address)` + Vm::expectRevert_5Call::SELECTOR => { + let e = Vm::expectRevert_5Call::abi_decode_raw(data, false).ok()?; + return self.maybe_decode(&e.revertData[..], status); + } // `expectRevert(bytes4)` Vm::expectRevert_1Call::SELECTOR => { let e = Vm::expectRevert_1Call::abi_decode_raw(data, false).ok()?; return self.maybe_decode(&e.revertData[..], status); } + // `expectRevert(bytes4,address)` + Vm::expectRevert_4Call::SELECTOR => { + let e = Vm::expectRevert_4Call::abi_decode_raw(data, false).ok()?; + return self.maybe_decode(&e.revertData[..], status); + } + // `expectPartialRevert(bytes4)` + Vm::expectPartialRevert_0Call::SELECTOR => { + let e = Vm::expectPartialRevert_0Call::abi_decode_raw(data, false).ok()?; + return self.maybe_decode(&e.revertData[..], status); + } + // `expectPartialRevert(bytes4,address)` + Vm::expectPartialRevert_1Call::SELECTOR => { + let e = Vm::expectPartialRevert_1Call::abi_decode_raw(data, false).ok()?; + return self.maybe_decode(&e.revertData[..], status); + } _ => {} } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index e3fc31b8bef27..1d810c9c5d84a 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -160,7 +160,7 @@ async fn test_scrape_bytecode() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzScrapeBytecode.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner(); runner.test_options.fuzz.runs = 2000; - runner.test_options.fuzz.seed = Some(U256::from(6u32)); + runner.test_options.fuzz.seed = Some(U256::from(100u32)); let suite_result = runner.test_collect(&filter); assert!(!suite_result.is_empty()); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index eacf81bda286c..4b7f3fe42f503 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -234,9 +234,13 @@ interface Vm { function expectEmit() external; function expectEmit(address emitter) external; function expectPartialRevert(bytes4 revertData) external; + function expectPartialRevert(bytes4 revertData, address reverter) external; function expectRevert() external; function expectRevert(bytes4 revertData) external; function expectRevert(bytes calldata revertData) external; + function expectRevert(address reverter) external; + function expectRevert(bytes4 revertData, address reverter) external; + function expectRevert(bytes calldata revertData, address reverter) external; function expectSafeMemory(uint64 min, uint64 max) external; function expectSafeMemoryCall(uint64 min, uint64 max) external; function fee(uint256 newBasefee) external; diff --git a/testdata/default/cheats/ExpectRevert.t.sol b/testdata/default/cheats/ExpectRevert.t.sol index 0cc6cac59b5fe..60137adfaa6d5 100644 --- a/testdata/default/cheats/ExpectRevert.t.sol +++ b/testdata/default/cheats/ExpectRevert.t.sol @@ -203,3 +203,151 @@ contract ExpectRevertTest is DSTest { new ConstructorReverter("some message"); } } + +contract AContract { + BContract bContract; + CContract cContract; + + constructor(BContract _bContract, CContract _cContract) { + bContract = _bContract; + cContract = _cContract; + } + + function callAndRevert() public pure { + require(1 > 2, "Reverted by AContract"); + } + + function callAndRevertInBContract() public { + bContract.callAndRevert(); + } + + function callAndRevertInCContract() public { + cContract.callAndRevert(); + } + + function callAndRevertInCContractThroughBContract() public { + bContract.callAndRevertInCContract(); + } + + function createDContract() public { + new DContract(); + } + + function createDContractThroughBContract() public { + bContract.createDContract(); + } + + function createDContractThroughCContract() public { + cContract.createDContract(); + } + + function doNotRevert() public {} +} + +contract BContract { + CContract cContract; + + constructor(CContract _cContract) { + cContract = _cContract; + } + + function callAndRevert() public pure { + require(1 > 2, "Reverted by BContract"); + } + + function callAndRevertInCContract() public { + this.doNotRevert(); + cContract.doNotRevert(); + cContract.callAndRevert(); + } + + function createDContract() public { + this.doNotRevert(); + cContract.doNotRevert(); + new DContract(); + } + + function createDContractThroughCContract() public { + this.doNotRevert(); + cContract.doNotRevert(); + cContract.createDContract(); + } + + function doNotRevert() public {} +} + +contract CContract { + error CContractError(string reason); + + function callAndRevert() public pure { + revert CContractError("Reverted by CContract"); + } + + function createDContract() public { + new DContract(); + } + + function doNotRevert() public {} +} + +contract DContract { + constructor() { + require(1 > 2, "Reverted by DContract"); + } +} + +contract ExpectRevertWithReverterTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + error CContractError(string reason); + + AContract aContract; + BContract bContract; + CContract cContract; + + function setUp() public { + cContract = new CContract(); + bContract = new BContract(cContract); + aContract = new AContract(bContract, cContract); + } + + function testExpectRevertsWithReverter() public { + // Test expect revert with reverter at first call. + vm.expectRevert(address(aContract)); + aContract.callAndRevert(); + // Test expect revert with reverter at second subcall. + vm.expectRevert(address(bContract)); + aContract.callAndRevertInBContract(); + // Test expect revert with partial data match and reverter at third subcall. + vm.expectPartialRevert(CContractError.selector, address(cContract)); + aContract.callAndRevertInCContractThroughBContract(); + // Test expect revert with exact data match and reverter at second subcall. + vm.expectRevert(abi.encodeWithSelector(CContractError.selector, "Reverted by CContract"), address(cContract)); + aContract.callAndRevertInCContract(); + } + + function testExpectRevertsWithReverterInConstructor() public { + // Test expect revert with reverter when constructor reverts. + vm.expectRevert(abi.encodePacked("Reverted by DContract"), address(cContract)); + cContract.createDContract(); + + vm.expectRevert(address(bContract)); + bContract.createDContract(); + vm.expectRevert(address(cContract)); + bContract.createDContractThroughCContract(); + + vm.expectRevert(address(aContract)); + aContract.createDContract(); + vm.expectRevert(address(bContract)); + aContract.createDContractThroughBContract(); + vm.expectRevert(address(cContract)); + aContract.createDContractThroughCContract(); + } + + function testFailExpectRevertsNotOnImmediateNextCall() public { + // Test expect revert with reverter fails if next call doesn't revert. + vm.expectRevert(address(aContract)); + aContract.doNotRevert(); + aContract.callAndRevert(); + } +} From b3405e2582d13f4fa476eb4d7bbf4bbeaa37ca3b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:37:48 +0200 Subject: [PATCH 1452/1963] ci: build release artifacts with maxperf (#8884) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c846ed8c8338..cea54177fa43c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -133,7 +133,7 @@ jobs: run: | set -eo pipefail target="${{ matrix.target }}" - flags=(--release --bins --no-default-features --features rustls,aws-kms,cli,asm-keccak) + flags=(--profile maxperf --bins --no-default-features --features rustls,aws-kms,cli,asm-keccak) # `jemalloc` is not fully supported on MSVC or aarch64 Linux. if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then From 0b13f0d60257be379d5bf6d5db3db32c439124a1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 18 Sep 2024 09:59:08 +0200 Subject: [PATCH 1453/1963] ci(release): also print size (#8885) --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cea54177fa43c..4780a5f2d1677 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -147,7 +147,9 @@ jobs: bins=(anvil cast chisel forge) for name in "${bins[@]}"; do bin=./target/$target/release/$name$exe + echo "" file "$bin" || true + du -h "$bin" || true ldd "$bin" || true $bin --version || true done From 8a8116977b3937ff7e871743f1805157cf242db6 Mon Sep 17 00:00:00 2001 From: dbeal Date: Wed, 18 Sep 2024 18:56:15 +0900 Subject: [PATCH 1454/1963] Fix failure to load some legacy state dumps (#8879) * Fix failure to load some legacy state dumps There are some cases where state dump cannot be loaded with the recent truncated hex change. https://github.com/foundry-rs/foundry/commit/84e63fe5b1d907e9d914f422e006cab8dd44b713 The existing tests for legacy state dumps were not sufficient, so I added a new test which is based on actual state dumps that are used in production right now with Synthetix. Specifically, its a state dump of the `oracle-manager` build with Cannon. This is mostly designed to be a catchall in case the basic legacy test fails. * Update db.rs * switch to using deserializer * fix lint * more fmt * clippy fix --- crates/anvil/src/eth/backend/db.rs | 36 ++++++++++++++++++- .../test-data/state-dump-legacy-stress.json | 1 + crates/anvil/tests/it/state.rs | 10 ++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 crates/anvil/test-data/state-dump-legacy-stress.json diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 39edbd8cd27dc..60565c4d54679 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -19,7 +19,10 @@ use foundry_evm::{ Database, DatabaseCommit, }, }; -use serde::{Deserialize, Serialize}; +use serde::{ + de::{MapAccess, Visitor}, + Deserialize, Deserializer, Serialize, +}; use std::{collections::BTreeMap, fmt, path::Path}; /// Helper trait get access to the full state data of the database @@ -398,9 +401,40 @@ pub struct SerializableAccountRecord { pub nonce: u64, pub balance: U256, pub code: Bytes, + + #[serde(deserialize_with = "deserialize_btree")] pub storage: BTreeMap, } +fn deserialize_btree<'de, D>(deserializer: D) -> Result, D::Error> +where + D: Deserializer<'de>, +{ + struct BTreeVisitor; + + impl<'de> Visitor<'de> for BTreeVisitor { + type Value = BTreeMap; + + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter.write_str("a mapping of hex encoded storage slots to hex encoded state data") + } + + fn visit_map(self, mut mapping: M) -> Result, M::Error> + where + M: MapAccess<'de>, + { + let mut btree = BTreeMap::new(); + while let Some((key, value)) = mapping.next_entry::()? { + btree.insert(B256::from(key), B256::from(value)); + } + + Ok(btree) + } + } + + deserializer.deserialize_map(BTreeVisitor) +} + /// Defines a backwards-compatible enum for transactions. /// This is essential for maintaining compatibility with state dumps /// created before the changes introduced in PR #8411. diff --git a/crates/anvil/test-data/state-dump-legacy-stress.json b/crates/anvil/test-data/state-dump-legacy-stress.json new file mode 100644 index 0000000000000..dff50a670e35f --- /dev/null +++ b/crates/anvil/test-data/state-dump-legacy-stress.json @@ -0,0 +1 @@ +{"block":{"number":"0x5","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66b200cb","gas_limit":"0x1c9c380","basefee":"0x12e09c7a","difficulty":"0x0","prevrandao":"0xe7ef87fc7c2090741a6749a087e4ca8092cb4d07136008799e4ebeac3b69e34a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0x1088aa62285a00","code":"0x","storage":{}},"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd":{"nonce":1,"balance":"0x0","code":"0x6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x19ba1fac55eea44d12a01372a8eb0c2ebbf9ca21":{"nonce":1,"balance":"0x21e19df7c2963f0ac6b","code":"0x","storage":{}},"0x19c6ab860dbe2bc433574193a4409770a8748bf6":{"nonce":1,"balance":"0x21e19df8da6b7bdc410","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x40567ec443c1d1872af5155755ac3803cc3fe61e":{"nonce":1,"balance":"0x21e19da82562f921b40","code":"0x","storage":{}},"0x47d08dad17ccb558b3ea74b1a0e73a9cc804a9dc":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","storage":{"0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0x0"}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":2,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x8138ef7cf908021d117e542120b7a39065016107":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","storage":{}},"0x83a0444b93927c3afcbe46e522280390f748e171":{"nonce":1,"balance":"0x0","code":"0x6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c63430008110033","storage":{"0x5a648c35a2f5512218b4683cf10e03f5b7c9dc7346e1bf77d304ae97f60f592b":"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xc67e2bd3108604cf0168c0e5ef9cd6d78b9bb14b":{"nonce":1,"balance":"0x21e19c6edb7e2445f20","code":"0x","storage":{}},"0xeb045d78d273107348b0300c01d29b7552d622ab":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e08b86820a43ea","code":"0x","storage":{}}},"best_block_number":"0x5","blocks":[{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xcd346446ed010523161f40a5f2b512def549bfb79e165b4354488738416481f2","transactionsRoot":"0xb3a4689832e0b599260ae70362ffcf224b60571b35ff8836904a3d81e2675d66","receiptsRoot":"0x2d13fdc120ab90536fed583939de7fb68b64926a306c1f629593ca9c2c93b198","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x3ea90d","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x2e0b6260","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0x3ea90d","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b5061494f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xbc73db80bf4b8784ba10a8910a0b7ef85f6846d102b41dd990969ea205335354"}}],"ommers":[]},{"header":{"parentHash":"0x026ae0c6ae91f186a9befa1ac8be30eea35e30e77de51a731085221e5cd39209","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x6e4969a136061ca7a390d12830d47a151585325a8d396819fb2b958ff85e9f8f","receiptsRoot":"0xc3e81df67d3e2a6c8345a954ef250cfcc41abcc2292a5aa263071124533fc9ad","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x3c0f6","timestamp":"0x66b200ce","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x18993a68","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0x3c0f6","maxFeePerGas":"0x5d4285cd","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b50610380806100206000396000f3fe6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x2476e039803622aeb040f924f04c493f559aed3d6c9372ab405cb33c8c695328"}}],"ommers":[]},{"header":{"parentHash":"0x3d22100ac0ee8d5cde334f7f926191a861b0648971ebc179547df28a0224c6d0","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9511d4711e5c30a72b0bff38a261daa75dcc5ba8b772d970a5c742244b4c861b","transactionsRoot":"0xba5fff578d3d6c2cd63acbe9bca353eaa6fe22a5c408956eff49106e0a96c507","receiptsRoot":"0xbae111f01cb07677e3a8c5031546138407c01bc964d3493d732dc4edf47d36d3","logsBloom":"0x00000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000020000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000001000000000000000000000400000001000010000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x5","gasLimit":"0x1c9c380","gasUsed":"0xcae7","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x12e09c7a","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0xcc4d","maxFeePerGas":"0x557e5ec4","maxPriorityFeePerGas":"0x3b9aca00","to":"0x83a0444b93927c3afcbe46e522280390f748e171","value":"0x0","accessList":[],"input":"0x3659cfe6000000000000000000000000108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xf88e7b19ee347145c257e0cf7ac4ecc2bae83ca79d7edaa231e71d3213aeb151"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9c8eaf493f8b4edce2ba1647343eadcc0989cf461e712c0a6253ff2ca1842bb7","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xdd07c07470e1deff3749831f0f1ad8d4b6e35505e83b3c6ea14181716197cd8a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x24a1ab52","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200c9","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xf6930be4847cac5017bbcbec2756eed19f36b4196526a98a88e311c296e3a9be","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cc","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x200d75e8","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x4","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1592fbf9","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x149d41e3b89d8324cef3feff98ef308e97bafe8745cc8461c60172bc7d4c44ba","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x0b44110186e52ff0ceb6b0776ca2992c94144a4ed712eef65ea038260ef0fcc7","receiptsRoot":"0xc2823b8eb4730d9f2657137cc2ddc2c4f22ab68e0ab826236cf6a1551ca2b3a5","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0xe61f9","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342770c0","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0xe94d1","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060008061002661006d60201b61081b1760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610141565b60008060405160200161007f90610121565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b600061010b60238361009e565b9150610116826100af565b604082019050919050565b6000602082019050818103600083015261013a816100fe565b9050919050565b611000806101506000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x4feae6769d748b4f0f7c9bf21d782236c88f13906789a3ec602961296e4c3e43"}}],"ommers":[]},{"header":{"parentHash":"0xb3535af5103fd1c2bbd6dc7ff23f0799037a6542c231ebcb85abd776560fa512","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x23d74fb99ff6e42cbb5c33f92b078e37be6af2b6092459b103ff7059a6517ebc","transactionsRoot":"0x9eab45eca206fe11c107ea985c7d02fcfa442836aea3e04ba11dc4df587d5aa6","receiptsRoot":"0xe25abcfa973db8c55f73292137c626430de130a382ad4466337fefb0f7c8fde0","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x3ce3f","timestamp":"0x66b200cd","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1c0bc72b","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0x3d8a8","maxFeePerGas":"0x6211577c","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060405161068538038061068583398181016040528101906100329190610275565b818181600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361009b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100ae8161019d60201b61004f1760201c565b6100ef57806040517f8a8b41ec0000000000000000000000000000000000000000000000000000000081526004016100e691906102c4565b60405180910390fd5b806100fe6101b060201b60201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050806101536101e160201b6100621760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050610414565b600080823b905060008111915050919050565b6000806040516020016101c290610362565b6040516020818303038152906040528051906020012090508091505090565b6000806040516020016101f3906103f4565b6040516020818303038152906040528051906020012090508091505090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061024282610217565b9050919050565b61025281610237565b811461025d57600080fd5b50565b60008151905061026f81610249565b92915050565b6000806040838503121561028c5761028b610212565b5b600061029a85828601610260565b92505060206102ab85828601610260565b9150509250929050565b6102be81610237565b82525050565b60006020820190506102d960008301846102b5565b92915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b600061034c6021836102df565b9150610357826102f0565b604082019050919050565b6000602082019050818103600083015261037b8161033f565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006103de6023836102df565b91506103e982610382565b604082019050919050565b6000602082019050818103600083015261040d816103d1565b9050919050565b610262806104236000396000f3fe6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c6343000811003300000000000000000000000047d08dad17ccb558b3ea74b1a0e73a9cc804a9dc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xb6794d5c7abed6f91d447e8efb72ef2580595a6d7c8dee57ba1dbb330970146a"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x29dd5614","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]}]} \ No newline at end of file diff --git a/crates/anvil/tests/it/state.rs b/crates/anvil/tests/it/state.rs index 7ed11ca46fa55..8227a89f1c592 100644 --- a/crates/anvil/tests/it/state.rs +++ b/crates/anvil/tests/it/state.rs @@ -36,6 +36,16 @@ async fn can_load_existing_state_legacy() { assert_eq!(block_number, Uint::from(2)); } +#[tokio::test(flavor = "multi_thread")] +async fn can_load_existing_state_legacy_stress() { + let state_file = "test-data/state-dump-legacy-stress.json"; + + let (api, _handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; + + let block_number = api.block_number().unwrap(); + assert_eq!(block_number, Uint::from(5)); +} + #[tokio::test(flavor = "multi_thread")] async fn can_load_existing_state() { let state_file = "test-data/state-dump.json"; From 08f1a0768c657244100d57e37454dd957fec5c30 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:10:36 +0200 Subject: [PATCH 1455/1963] ci(release): fix hardcoded profile (#8888) --- .github/workflows/release.yml | 44 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4780a5f2d1677..b398aae8e00a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,6 +103,13 @@ jobs: svm_target_platform: windows-amd64 platform: win32 arch: amd64 + env: + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + PLATFORM_NAME: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} + PROFILE: maxperf + OUT_DIR: target/${{ env.TARGET }}/${{ env.PROFILE }} + VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -127,26 +134,24 @@ jobs: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - name: Build binaries - env: - SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} shell: bash run: | set -eo pipefail - target="${{ matrix.target }}" - flags=(--profile maxperf --bins --no-default-features --features rustls,aws-kms,cli,asm-keccak) + flags=(--target $TARGET --profile $PROFILE --bins + --no-default-features --features rustls,aws-kms,cli,asm-keccak) # `jemalloc` is not fully supported on MSVC or aarch64 Linux. - if [[ "$target" != *msvc* && "$target" != "aarch64-unknown-linux-gnu" ]]; then + if [[ "$TARGET" != *msvc* && "$TARGET" != "aarch64-unknown-linux-gnu" ]]; then flags+=(--features jemalloc) fi - [[ "$target" == *windows* ]] && exe=".exe" + [[ "$TARGET" == *windows* ]] && ext=".exe" - cargo build --target "$target" "${flags[@]}" + cargo build "${flags[@]}" bins=(anvil cast chisel forge) for name in "${bins[@]}"; do - bin=./target/$target/release/$name$exe + bin=$OUT_DIR/$name$ext echo "" file "$bin" || true du -h "$bin" || true @@ -156,23 +161,18 @@ jobs: - name: Archive binaries id: artifacts - env: - PLATFORM_NAME: ${{ matrix.platform }} - TARGET: ${{ matrix.target }} - ARCH: ${{ matrix.arch }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash run: | if [ "$PLATFORM_NAME" == "linux" ]; then - tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel + tar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast anvil chisel echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT elif [ "$PLATFORM_NAME" == "darwin" ]; then # We need to use gtar here otherwise the archive is corrupt. # See: https://github.com/actions/virtual-environments/issues/2619 - gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release forge cast anvil chisel + gtar -czvf "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C $OUT_DIR forge cast anvil chisel echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT else - cd ./target/${TARGET}/release + cd $OUT_DIR 7z a -tzip "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" forge.exe cast.exe anvil.exe chisel.exe mv "foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../ echo "file_name=foundry_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT @@ -181,17 +181,13 @@ jobs: - name: Build man page id: man if: matrix.target == 'x86_64-unknown-linux-gnu' - env: - PLATFORM_NAME: ${{ matrix.platform }} - TARGET: ${{ matrix.target }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash run: | sudo apt-get -y install help2man - help2man -N ./target/${TARGET}/release/forge > forge.1 - help2man -N ./target/${TARGET}/release/cast > cast.1 - help2man -N ./target/${TARGET}/release/anvil > anvil.1 - help2man -N ./target/${TARGET}/release/chisel > chisel.1 + help2man -N $OUT_DIR/forge > forge.1 + help2man -N $OUT_DIR/cast > cast.1 + help2man -N $OUT_DIR/anvil > anvil.1 + help2man -N $OUT_DIR/chisel > chisel.1 gzip forge.1 gzip cast.1 gzip anvil.1 From 03ea54c63e33e3175a6f44d8cfe3718bd6c962ba Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:28:52 +0200 Subject: [PATCH 1456/1963] ci(release): fix workflow (#8893) * ci(release): fix workflow post-8888 * move profile to global env def * add missing $ARCH env * to be sure, add back SVM_TARGET_PLATFORM * cannot use `env.TARGET` directly after setting it --- .github/workflows/release.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b398aae8e00a5..1377e5d6e48e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,7 @@ on: env: CARGO_TERM_COLOR: always IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} + PROFILE: maxperf jobs: prepare: @@ -103,13 +104,6 @@ jobs: svm_target_platform: windows-amd64 platform: win32 arch: amd64 - env: - SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} - PLATFORM_NAME: ${{ matrix.platform }} - TARGET: ${{ matrix.target }} - PROFILE: maxperf - OUT_DIR: target/${{ env.TARGET }}/${{ env.PROFILE }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -134,6 +128,11 @@ jobs: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - name: Build binaries + env: + SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + PLATFORM_NAME: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} + OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} shell: bash run: | set -eo pipefail @@ -161,6 +160,11 @@ jobs: - name: Archive binaries id: artifacts + env: + PLATFORM_NAME: ${{ matrix.platform }} + OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} + VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + ARCH: ${{ matrix.arch }} shell: bash run: | if [ "$PLATFORM_NAME" == "linux" ]; then @@ -181,6 +185,9 @@ jobs: - name: Build man page id: man if: matrix.target == 'x86_64-unknown-linux-gnu' + env: + OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} + VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash run: | sudo apt-get -y install help2man From 78ef20dfb5fe42d2f23eefbc4c773e331d307b75 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:30:54 +0300 Subject: [PATCH 1457/1963] chore(forge): fix isolate ext integration tests (#8901) --- crates/forge/tests/cli/ext_integration.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 1cf7b54ad6e9a..f0b1c5144ad30 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -71,6 +71,7 @@ fn solady() { #[test] #[cfg_attr(windows, ignore = "weird git fail")] +#[cfg(not(feature = "isolate-by-default"))] fn geb() { ExtTester::new("reflexer-labs", "geb", "1a59f16a377386c49f520006ed0f7fd9d128cb09") .env("FOUNDRY_LEGACY_ASSERTIONS", "true") From 0c7601a243d48b0b55ced0f286c3c41766f24a97 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:14:40 +0530 Subject: [PATCH 1458/1963] chore: bump alloy 0.3.6 (#8902) * bump 0.3.6 + block-explorers patch * fix * fix test * nit * bump block-explorers * bump --- Cargo.lock | 223 ++++++++++---------- Cargo.toml | 52 ++--- crates/anvil/src/eth/backend/mem/mod.rs | 3 +- crates/anvil/src/eth/backend/mem/storage.rs | 3 +- crates/anvil/tests/it/eip4844.rs | 2 +- crates/anvil/tests/it/otterscan.rs | 8 +- crates/anvil/tests/it/utils.rs | 11 +- crates/cast/bin/tx.rs | 4 +- crates/common/src/compile.rs | 2 +- crates/common/src/provider/mod.rs | 11 +- crates/forge/tests/it/test_helpers.rs | 3 +- 11 files changed, 172 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c11f775fa21f2..71467f3a4d5e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,9 +85,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28ddd17ffb7e4d66ef3a84e7b179072a9320cdc4b26c7f6f44cbf1081631b36" +checksum = "629b62e38d471cc15fea534eb7283d2f8a4e8bdb1811bcc5d66dda6cfce6fae1" dependencies = [ "alloy-eips", "alloy-primitives", @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69257e2ffe1a9f15f20a89cd54d1ca758468c5b3e87979191b8b5fc24d39b37" +checksum = "0eefe64fd344cffa9cf9e3435ec4e93e6e9c3481bc37269af988bf497faf4a6a" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f6c5c0a383f14519531cf58d8440e74f10b938e289f803af870be6f79223110" +checksum = "f923dd5fca5f67a43d81ed3ebad0880bd41f6dd0ada930030353ac356c54cd0f" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7db0ddc76399bb1a4010f630767f027cafe65ab406cfee8e6040128cd65e8325" +checksum = "3a7a18afb0b318616b6b2b0e2e7ac5529d32a966c673b48091c9919e284e6aca" dependencies = [ "alloy-primitives", "alloy-serde", @@ -210,9 +210,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7111af869909275cffc5c84d16b6c892d6d512773e40cbe83187d0b9c5235e91" +checksum = "d3c717b5298fad078cd3a418335b266eba91b511383ca9bd497f742d5975d5ab" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -224,9 +224,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "342028392a2d5050b7b93dd32a0715d3b3b9ce30072ecb69a35dd4895c005495" +checksum = "fb3705ce7d8602132bcf5ac7a1dd293a42adc2f183abf5907c30ac535ceca049" dependencies = [ "alloy-consensus", "alloy-eips", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6e66d78c049dcadd065a926a9f2d9a9b2b10981a7889449e694fac7bccd2c6f" +checksum = "94ad40869867ed2d9cd3842b1e800889e5b49e6b92da346e93862b4a741bedf3" dependencies = [ "alloy-eips", "alloy-primitives", @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79f14ccc2a3c575cb17b1b4af8c772cf9b5b93b7ce7047d6640e53954abb558d" +checksum = "927f708dd457ed63420400ee5f06945df9632d5d101851952056840426a10dc5" dependencies = [ "alloy-chains", "alloy-consensus", @@ -322,9 +322,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b9f5e85120aab30b8da23354592f7bd2b208d33d3204ffa1d44ac2e3dd5691" +checksum = "2d05f63677e210d758cd5d6d1ce10f20c980c3560ccfbe79ba1997791862a04f" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -363,9 +363,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc79aeca84abb122a2fffbc1c91fdf958dca5c95be3875977bc99672bde0027" +checksum = "7d82952dca71173813d4e5733e2c986d8b04aea9e0f3b0a576664c232ad050a5" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22045187a5ebf5b2af3f8b6831b66735b6556c5750ec5790aeeb45935260c1c2" +checksum = "64333d639f2a0cf73491813c629a405744e16343a4bc5640931be707c345ecc5" dependencies = [ "alloy-rpc-types-anvil", "alloy-rpc-types-engine", @@ -403,9 +403,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578d9ccad4e8510d32cc2810d05e01a232ccd79a4a6df60d257466897b43b013" +checksum = "d25cb45ad7c0930dd62eecf164d2afe4c3d2dd2c82af85680ad1f118e1e5cb83" dependencies = [ "alloy-primitives", "alloy-serde", @@ -414,9 +414,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c031a91e94a39f928244bc837c953817be5b8cc61759e1a9123b3abd17560dd" +checksum = "1464c4dd646e1bdfde86ae65ce5ba168dbb29180b478011fe87117ae46b1629b" dependencies = [ "alloy-consensus", "alloy-eips", @@ -431,9 +431,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238f494727ff861a803bd73b1274ef788a615bf8f8c4bfada4e6df42afa275d2" +checksum = "83aa984386deda02482660aa31cb8ca1e63d533f1c31a52d7d181ac5ec68e9b8" dependencies = [ "alloy-consensus", "alloy-eips", @@ -452,9 +452,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca08b0ccc0861055ceb83a1db009c4c8a7f52a259e7cda7ca6ca36ec2b5ce8" +checksum = "98db35cd42c90b484377e6bc44d95377a7a38a5ebee996e67754ac0446d542ab" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -466,9 +466,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "192ad94fe34c12be8ac4413ea00b1170202faa6fdebaa756b6a33555bf86d902" +checksum = "6bac37082c3b21283b3faf5cc0e08974272aee2f756ce1adeb26db56a5fce0d5" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -478,9 +478,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b95b6f024a558593dd3b8628af03f7df2ca50e4c56839293ad0a7546e471db0" +checksum = "731f75ec5d383107fd745d781619bd9cedf145836c51ecb991623d41278e71fa" dependencies = [ "alloy-primitives", "arbitrary", @@ -490,9 +490,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da64740ff0518606c514eb0e03dd0a1daa8ff94d6d491a626fd8e50efd6c4f18" +checksum = "307324cca94354cd654d6713629f0383ec037e1ff9e3e3d547212471209860c0" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -506,9 +506,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f187534919dcccebaf92774ad6b17645087b49a8716d49e2db29a2e3229b03f2" +checksum = "076be69aa26a4c500919f1ad3847662aa6d1e9bc2995e263ed826b1546d1b990" dependencies = [ "alloy-consensus", "alloy-network", @@ -524,9 +524,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907e56e2153e785c36e4197f4e254b5087e073a12b686f486d3bd6245c811313" +checksum = "cabd79d4eb954a8c2ae7889a18e2466af186ae68376251cf58525239c156ec54" dependencies = [ "alloy-consensus", "alloy-network", @@ -542,9 +542,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "221d828bdf1df1e7d490c304eb1425c7adacd6897a4baa2316e3f3054fc8863f" +checksum = "f3df66f5ddcc32d2070485dc702f5f5fb97cfbfa817f6e2e6bac16a4e32ed44c" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -562,9 +562,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e250010dce0e3caf6a6033e809718e5921391d937d1cbbcffe52653b37cc63" +checksum = "9fabe917ab1778e760b4701628d1cae8e028ee9d52ac6307de4e1e9286ab6b5f" dependencies = [ "alloy-consensus", "alloy-network", @@ -582,9 +582,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "586b4c42aa61b47591813fca23098e21530470986a00e3dc588baa2d5b8dd111" +checksum = "1068949eda889b2c052b29a6e8c7ea2ba16be6d1af83ad165fff2a4e4ad19fcd" dependencies = [ "alloy-consensus", "alloy-network", @@ -672,9 +672,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7a669caa427abe8802184c8776f5103302f9337bb30a5b36bdebc332946c14" +checksum = "33616b2edf7454302a1d48084db185e52c309f73f6c10be99b0fe39354b3f1e9" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -691,9 +691,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4433ffa97aab6ae643de81c7bde9a2f043496f27368a607405a5c78a610caf74" +checksum = "a944f5310c690b62bbb3e7e5ce34527cbd36b2d18532a797af123271ce595a49" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -706,9 +706,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aa02db8751f9c0c37caf8c38ad3eb7aa1cfb09cfea3451a13aacaf06846c7a5" +checksum = "09fd8491249f74d16ec979b1f5672377b12ebb818e6056478ffa386954dbd350" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -727,9 +727,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a5c4a0929479bcb85a2df628c01173618a71c807b2f499939a236dbde5d008" +checksum = "a9704761f6297fe482276bee7f77a93cb42bd541c2bd6c1c560b6f3a9ece672e" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -745,9 +745,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "398a977d774db13446b8cead8cfa9517aebf9e03fc8a1512892dc1e03e70bb04" +checksum = "0a46c9c4fdccda7982e7928904bd85fe235a0404ee3d7e197fff13d61eac8b4f" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -964,9 +964,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arbitrary" @@ -1320,9 +1320,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f7cb482caa5444d445c94417b9c74e49a849beb09ede4f2f4c3c15f8157387" +checksum = "c6550445e0913c9383375f4a5a2f550817567a19a178107fce1e1afd767f802a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1342,9 +1342,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27bf24cd0d389daa923e974b0e7c38daf308fc21e963c049f57980235017175e" +checksum = "70a9d27ed1c12b1140c47daf1bc541606c43fdafd918c4797d520db0043ceef2" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1364,9 +1364,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b43b3220f1c46ac0e9dcc0a97d94b93305dacb36d1dd393996300c6b9b74364" +checksum = "44514a6ca967686cde1e2a1b81df6ef1883d0e3e570da8d8bc5c491dcb6fc29b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1386,9 +1386,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c46924fb1add65bba55636e12812cae2febf68c0f37361766f627ddcca91ce" +checksum = "cd7a4d279762a35b9df97209f6808b95d4fe78547fe2316b4d200a0283960c5a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1807,9 +1807,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -1915,9 +1915,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.18" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" dependencies = [ "shlex", ] @@ -2055,9 +2055,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.26" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" +checksum = "9b378c786d3bde9442d2c6dd7e6080b2a818db2b96e30d6e7f1b6d224eb617d3" dependencies = [ "clap", ] @@ -3477,9 +3477,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "461772f04e5457d6b6501f6aff3a615a032d01368c1cc91c13a06eff172962b6" +checksum = "ff37530e7c5deead0f9d7dc2a27b070e683bef79735ab453849ebdee74fa848f" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3711,9 +3711,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3372aaa89b1653b61fb297dbc24e74ad727ff76cc4415f1a0ec5f802d24e0797" +checksum = "6d91e510bd537970f68f8462dea0e8df0a2302d4749fb57bc8e10bbd32a283e2" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3749,9 +3749,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4f9ac0ed5e695bbeb48ff0758ba31ce3d0d52b752aaa466f311f48ed772c0" +checksum = "f9971eefe4eae1cf2ac707beb4d40f63304b34c81c0961d299e461c14a23b1e7" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3759,9 +3759,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad6beeb057a8a58993d13841cffcb99e8aefdeb52ed9b368c85518747b467f9" +checksum = "0cde3d12776c295ad85bcdbbae18f4601e384f40a62b0e3371d880bbcd91c65c" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3783,9 +3783,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442e5eb231aad523f0f3e26f9475ad9eab1aa2173a5991df1b7fa51f589f309f" +checksum = "569a769f6105248816c253715ec39977d61d369e9c67e4774d6870da8f64dffc" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3798,9 +3798,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92049644ce2745c36be16f6406592155d4be2314306af2543c7d30a32b00d6ed" +checksum = "5f10ade77fa0eab75e142a76711c42a258781bad0c4516ad64aa413297ebb72e" dependencies = [ "alloy-primitives", "cfg-if", @@ -4956,9 +4956,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -5995,9 +5995,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -6007,9 +6007,9 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "op-alloy-consensus" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef361231f72bea90365e441bd97d9c8fd3875603f18bbcad0e04874c6158e53" +checksum = "21aad1fbf80d2bcd7406880efc7ba109365f44bbb72896758ddcbfa46bf1592c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6023,15 +6023,17 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a65da5f7591acba3d2304b25145ca9942ea90481213269aed9cb28add8e3ff" +checksum = "e281fbfc2198b7c0c16457d6524f83d192662bc9f3df70f24c3038d4521616df" dependencies = [ "alloy-eips", - "alloy-network", + "alloy-network-primitives", "alloy-primitives", "alloy-rpc-types-eth", "alloy-serde", + "cfg-if", + "hashbrown 0.14.5", "op-alloy-consensus", "serde", "serde_json", @@ -7146,9 +7148,9 @@ dependencies = [ [[package]] name = "revm" -version = "14.0.1" +version = "14.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f719e28cc6fdd086f8bc481429e587740d20ad89729cec3f5f5dd7b655474df" +checksum = "a9f3f55d0414c3d73902d876ba3d55a654f05fe937089fbf5f34b1ced26d78d5" dependencies = [ "auto_impl", "cfg-if", @@ -7161,12 +7163,13 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.6.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48184032103bb23788e42e42c7c85207f5b0b8a248b09ea8f5233077f35ab56e" +checksum = "48294aab02ed5d1940ad9b06f2a3230c3f0d98db6eacd618878cf143e204f6b0" dependencies = [ "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types-eth", + "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "colorchoice", @@ -7178,9 +7181,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "10.0.1" +version = "10.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "959ecbc36802de6126852479844737f20194cf8e6718e0c30697d306a2cca916" +checksum = "713dbb271acd13afb06dcd460c1dc43da211e7ac9bc73cdf13528f615f55f96b" dependencies = [ "revm-primitives", "serde", @@ -7188,9 +7191,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "11.0.1" +version = "11.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e25f604cb9db593ca3013be8c00f310d6790ccb1b7d8fbbdd4660ec8888043a" +checksum = "f73010c271d53fa7904e9845338e95f3955eb1200a0355e0abfdb89c41aaa9cd" dependencies = [ "aurora-engine-modexp", "blst", @@ -7208,9 +7211,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "9.0.1" +version = "9.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ccb981ede47ccf87c68cebf1ba30cdbb7ec935233ea305f3dfff4c1e10ae541" +checksum = "e7a6bff9dbde3370a5ac9555104117f7e6039b3cc76e8d5d9d01899088beca2a" dependencies = [ "alloy-eips", "alloy-primitives", @@ -8713,9 +8716,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" dependencies = [ "indexmap 2.5.0", "serde", @@ -9076,9 +9079,9 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -9412,9 +9415,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] diff --git a/Cargo.toml b/Cargo.toml index fbf9be9b8d773..ade7824a86ec2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -163,42 +163,42 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.7.1", default-features = false } -foundry-compilers = { version = "0.11.0", default-features = false } +foundry-block-explorers = { version = "0.7.3", default-features = false } +foundry-compilers = { version = "0.11.1", default-features = false } foundry-fork-db = "0.3" solang-parser = "=0.3.3" ## revm # no default features to avoid c-kzg -revm = { version = "14.0.1", default-features = false } -revm-primitives = { version = "9.0.1", default-features = false } -revm-inspectors = { version = "0.6", features = ["serde"] } +revm = { version = "14.0.2", default-features = false } +revm-primitives = { version = "9.0.2", default-features = false } +revm-inspectors = { version = "0.7", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.3.3", default-features = false } -alloy-contract = { version = "0.3.3", default-features = false } -alloy-eips = { version = "0.3.3", default-features = false } -alloy-genesis = { version = "0.3.3", default-features = false } -alloy-json-rpc = { version = "0.3.3", default-features = false } -alloy-network = { version = "0.3.3", default-features = false } -alloy-provider = { version = "0.3.3", default-features = false } -alloy-pubsub = { version = "0.3.3", default-features = false } -alloy-rpc-client = { version = "0.3.3", default-features = false } -alloy-rpc-types = { version = "0.3.3", default-features = true } -alloy-serde = { version = "0.3.3", default-features = false } -alloy-signer = { version = "0.3.3", default-features = false } -alloy-signer-aws = { version = "0.3.3", default-features = false } -alloy-signer-gcp = { version = "0.3.3", default-features = false } -alloy-signer-ledger = { version = "0.3.3", default-features = false } -alloy-signer-local = { version = "0.3.3", default-features = false } -alloy-signer-trezor = { version = "0.3.3", default-features = false } -alloy-transport = { version = "0.3.3", default-features = false } -alloy-transport-http = { version = "0.3.3", default-features = false } -alloy-transport-ipc = { version = "0.3.3", default-features = false } -alloy-transport-ws = { version = "0.3.3", default-features = false } +alloy-consensus = { version = "0.3.6", default-features = false } +alloy-contract = { version = "0.3.6", default-features = false } +alloy-eips = { version = "0.3.6", default-features = false } +alloy-genesis = { version = "0.3.6", default-features = false } +alloy-json-rpc = { version = "0.3.6", default-features = false } +alloy-network = { version = "0.3.6", default-features = false } +alloy-provider = { version = "0.3.6", default-features = false } +alloy-pubsub = { version = "0.3.6", default-features = false } +alloy-rpc-client = { version = "0.3.6", default-features = false } +alloy-rpc-types = { version = "0.3.6", default-features = true } +alloy-serde = { version = "0.3.6", default-features = false } +alloy-signer = { version = "0.3.6", default-features = false } +alloy-signer-aws = { version = "0.3.6", default-features = false } +alloy-signer-gcp = { version = "0.3.6", default-features = false } +alloy-signer-ledger = { version = "0.3.6", default-features = false } +alloy-signer-local = { version = "0.3.6", default-features = false } +alloy-signer-trezor = { version = "0.3.6", default-features = false } +alloy-transport = { version = "0.3.6", default-features = false } +alloy-transport-http = { version = "0.3.6", default-features = false } +alloy-transport-ipc = { version = "0.3.6", default-features = false } +alloy-transport-ws = { version = "0.3.6", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.1" diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 5e71892a31e87..0f28e28a56457 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1334,7 +1334,8 @@ impl Backend { GethDebugBuiltInTracerType::NoopTracer => Ok(NoopFrame::default().into()), GethDebugBuiltInTracerType::FourByteTracer | GethDebugBuiltInTracerType::PreStateTracer | - GethDebugBuiltInTracerType::MuxTracer => { + GethDebugBuiltInTracerType::MuxTracer | + GethDebugBuiltInTracerType::FlatCallTracer => { Err(RpcError::invalid_params("unsupported tracer type").into()) } }, diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index f999a512a5886..441bd1cbbfac8 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -541,7 +541,8 @@ impl MinedTransaction { } GethDebugBuiltInTracerType::PreStateTracer | GethDebugBuiltInTracerType::NoopTracer | - GethDebugBuiltInTracerType::MuxTracer => {} + GethDebugBuiltInTracerType::MuxTracer | + GethDebugBuiltInTracerType::FlatCallTracer => {} }, GethDebugTracerType::JsTracer(_code) => {} } diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 2da74da65ff67..3530834094584 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -1,7 +1,7 @@ use crate::utils::http_provider; use alloy_consensus::{SidecarBuilder, SimpleCoder}; use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK}; -use alloy_network::TransactionBuilder; +use alloy_network::{TransactionBuilder, TransactionBuilder4844}; use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, TransactionRequest}; diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index 55474079fb0ea..e839c9986a1fb 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -144,12 +144,8 @@ async fn ots_get_internal_operations_contract_selfdestruct(hardfork: EthereumHar let receipt = contract.goodbye().send().await.unwrap().get_receipt().await.unwrap(); - // TODO: This is currently not supported by revm-inspectors - let (expected_to, expected_value) = if hardfork < EthereumHardfork::Cancun { - (address!("DcDD539DA22bfFAa499dBEa4d37d086Dde196E75"), value) - } else { - (Address::ZERO, U256::ZERO) - }; + let expected_to = address!("DcDD539DA22bfFAa499dBEa4d37d086Dde196E75"); + let expected_value = value; let res = api.ots_get_internal_operations(receipt.transaction_hash).await.unwrap(); assert_eq!( diff --git a/crates/anvil/tests/it/utils.rs b/crates/anvil/tests/it/utils.rs index 3683775136d39..3d6ae700928c8 100644 --- a/crates/anvil/tests/it/utils.rs +++ b/crates/anvil/tests/it/utils.rs @@ -38,7 +38,16 @@ use alloy_transport::BoxTransport; type PubsubSigner = FillProvider< JoinFill< - JoinFill, NonceFiller>, ChainIdFiller>, + JoinFill< + Identity, + JoinFill< + GasFiller, + JoinFill< + alloy_provider::fillers::BlobGasFiller, + JoinFill, + >, + >, + >, WalletFiller, >, RootProvider, diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 08ee6d182a77d..1dc9b0cd149fd 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,6 +1,8 @@ use alloy_consensus::{SidecarBuilder, SimpleCoder}; use alloy_json_abi::Function; -use alloy_network::{AnyNetwork, TransactionBuilder}; +use alloy_network::{ + AnyNetwork, TransactionBuilder, TransactionBuilder4844, TransactionBuilder7702, +}; use alloy_primitives::{hex, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; use alloy_rlp::Decodable; diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 0c39dd8734982..a75ac0819ddef 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -407,7 +407,7 @@ pub fn etherscan_project( Ok(ProjectBuilder::::default() .settings(SolcSettings { - settings: SolcConfig::builder().settings(settings).build().settings, + settings: SolcConfig::builder().settings(settings).build(), ..Default::default() }) .paths(paths) diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index 49cadd95c16a3..fe7fd4ccc9d91 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -40,7 +40,16 @@ pub type RetryProvider = RootProvider = FillProvider< JoinFill< - JoinFill, NonceFiller>, ChainIdFiller>, + JoinFill< + Identity, + JoinFill< + GasFiller, + JoinFill< + alloy_provider::fillers::BlobGasFiller, + JoinFill, + >, + >, + >, WalletFiller, >, RootProvider, N>, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index fdef2f2ecdb4a..e5aee722ff07b 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -70,7 +70,8 @@ impl ForgeTestProfile { settings.evm_version = Some(EvmVersion::Cancun); } - SolcConfig::builder().settings(settings).build() + let settings = SolcConfig::builder().settings(settings).build(); + SolcConfig { settings } } pub fn project(&self) -> Project { From 92ccb23144e1cb27724b3ffff11135c1ae08b92c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:37:11 +0200 Subject: [PATCH 1459/1963] chore(deps): bump mesc to 0.3.0 (#8897) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71467f3a4d5e1..4726ad0420a08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5574,9 +5574,9 @@ dependencies = [ [[package]] name = "mesc" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d340f1a6bfcd3ea5075231fb04b74c8bf7cb3be25ee6480976c8500fcd2949f" +checksum = "d04b0347d2799ef17df4623dbcb03531031142105168e0c549e0bf1f980e9e7e" dependencies = [ "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index ade7824a86ec2..a143ef9384c95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -241,7 +241,7 @@ itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" parking_lot = "0.12" -mesc = "0.2.1" +mesc = "0.3" rand = "0.8" rustc-hash = "2.0" semver = "1" From fa3da2e075e766e82274f31602193f248fe3d890 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:04:18 +0200 Subject: [PATCH 1460/1963] chore: reduce size further (#8886) --- Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a143ef9384c95..c7e38cbc9031d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ split-debuginfo = "unpacked" opt-level = 3 lto = "thin" debug = "line-tables-only" -strip = "symbols" +strip = "debuginfo" panic = "abort" codegen-units = 16 @@ -124,6 +124,9 @@ scrypt.opt-level = 3 # Override packages which aren't perf-sensitive for faster compilation speed and smaller binary size. [profile.release.package] alloy-sol-macro-expander.opt-level = "z" +figment.opt-level = "z" +foundry-compilers-artifacts-solc.opt-level = "z" +foundry-config.opt-level = "z" html5ever.opt-level = "z" mdbook.opt-level = "z" prettyplease.opt-level = "z" From da77402c298066b084547c6027f1c9e3104fe871 Mon Sep 17 00:00:00 2001 From: aganisgash Date: Thu, 19 Sep 2024 23:34:48 +0800 Subject: [PATCH 1461/1963] readme: fix cheatcode path (#8907) fix cheatcode path --- crates/cheatcodes/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cheatcodes/README.md b/crates/cheatcodes/README.md index 790f2553a3919..7f776392eb744 100644 --- a/crates/cheatcodes/README.md +++ b/crates/cheatcodes/README.md @@ -12,7 +12,7 @@ Foundry cheatcodes definitions and implementations. All cheatcodes are defined in a single [`sol!`] macro call in [`spec/src/vm.rs`]. -This, combined with the use of an internal [`Cheatcode`](../macros/impl/src/cheatcodes.rs) derive macro, +This, combined with the use of an internal [`Cheatcode`](../../crates/cheatcodes/spec/src/cheatcode.rs) derive macro, allows us to generate both the Rust definitions and the JSON specification of the cheatcodes. Cheatcodes are manually implemented through the `Cheatcode` trait, which is called in the From 8a40f3466406a148b00073c7893a382aa8db34c9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 20 Sep 2024 11:58:13 +0200 Subject: [PATCH 1462/1963] chore(cheatcodes): reduce generated code (#8912) --- crates/cheatcodes/spec/src/vm.rs | 5 +++++ crates/macros/src/cheatcodes.rs | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 9c19196c82095..9be2e5f6f2b9a 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2365,3 +2365,8 @@ impl PartialEq for ForgeContext { } } } + +#[track_caller] +const fn panic_unknown_safety() -> ! { + panic!("cannot determine safety from the group, add a `#[cheatcode(safety = ...)]` attribute") +} diff --git a/crates/macros/src/cheatcodes.rs b/crates/macros/src/cheatcodes.rs index b38186e57732d..4fbe6cfa79cde 100644 --- a/crates/macros/src/cheatcodes.rs +++ b/crates/macros/src/cheatcodes.rs @@ -1,5 +1,5 @@ use proc_macro2::{Ident, Span, TokenStream}; -use quote::{quote, quote_spanned}; +use quote::quote; use syn::{Attribute, Data, DataStruct, DeriveInput, Error, Result}; pub fn derive_cheatcode(input: &DeriveInput) -> Result { @@ -42,13 +42,10 @@ fn derive_call(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result - panic!("cannot determine safety from the group, add a `#[cheatcode(safety = ...)]` attribute") - }; quote! { match Group::#group.safety() { Some(s) => s, - None => #panic, + None => panic_unknown_safety(), } } }; From 5725bcc66899646c640f7feea3fa2bb3dfca753b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:48:00 +0300 Subject: [PATCH 1463/1963] feat(cheatcodes): display warnings for deprecated cheatcodes (#8883) * feat(cheatcode): disaply message for cheatcodes marked as deprecated * Deprecated cheatcodes as hashset, displayed once per test suite * Add deprecated cheatcode replacement attr * Add support for fuzz and invariant tests * Changes after review: add Deprecated(replacement) * Update crates/cheatcodes/src/inspector.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * chore: touchups * Fix CI --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 4 +- .../cheatcodes/assets/cheatcodes.schema.json | 17 ++++- crates/cheatcodes/spec/src/cheatcode.rs | 10 ++- crates/cheatcodes/spec/src/vm.rs | 2 +- crates/cheatcodes/src/inspector.rs | 42 ++++------- crates/cheatcodes/src/lib.rs | 9 +++ crates/evm/evm/src/executors/fuzz/mod.rs | 15 ++-- crates/evm/evm/src/executors/fuzz/types.rs | 19 +++-- .../evm/evm/src/executors/invariant/replay.rs | 11 ++- crates/evm/fuzz/src/lib.rs | 3 + crates/forge/src/result.rs | 32 +++++++- crates/forge/src/runner.rs | 3 + crates/forge/tests/cli/test_cmd.rs | 75 +++++++++++++++++++ crates/macros/src/cheatcodes.rs | 4 +- 14 files changed, 192 insertions(+), 54 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 88c65137cda27..4d337ff5ecba5 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5408,7 +5408,9 @@ ] }, "group": "json", - "status": "deprecated", + "status": { + "deprecated": "replaced by `keyExistsJson`" + }, "safety": "safe" }, { diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index 9301196d9cffb..9ffc13d6121d8 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -384,11 +384,20 @@ ] }, { - "description": "The cheatcode has been deprecated, meaning it will be removed in a future release.\n\nUse of deprecated cheatcodes is discouraged and will result in a warning.", - "type": "string", - "enum": [ + "description": "The cheatcode has been deprecated, meaning it will be removed in a future release.\n\nContains the optional reason for deprecation.\n\nUse of deprecated cheatcodes is discouraged and will result in a warning.", + "type": "object", + "required": [ "deprecated" - ] + ], + "properties": { + "deprecated": { + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false }, { "description": "The cheatcode has been removed and is no longer available for use.\n\nUse of removed cheatcodes will result in a hard error.", diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index 207cac1590ce4..bce501d45d7bd 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -23,18 +23,18 @@ pub struct Cheatcode<'a> { /// The group that the cheatcode belongs to. pub group: Group, /// The current status of the cheatcode. E.g. whether it is stable or experimental, etc. - pub status: Status, + pub status: Status<'a>, /// Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an /// unexpected way. pub safety: Safety, } /// The status of a cheatcode. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase")] #[non_exhaustive] -pub enum Status { +pub enum Status<'a> { /// The cheatcode and its API is currently stable. Stable, /// The cheatcode is unstable, meaning it may contain bugs and may break its API on any @@ -44,8 +44,10 @@ pub enum Status { Experimental, /// The cheatcode has been deprecated, meaning it will be removed in a future release. /// + /// Contains the optional reason for deprecation. + /// /// Use of deprecated cheatcodes is discouraged and will result in a warning. - Deprecated, + Deprecated(Option<&'a str>), /// The cheatcode has been removed and is no longer available for use. /// /// Use of removed cheatcodes will result in a hard error. diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 9be2e5f6f2b9a..fef210bae2485 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1865,7 +1865,7 @@ interface Vm { /// Checks if `key` exists in a JSON object /// `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions. - #[cheatcode(group = Json, status = Deprecated)] + #[cheatcode(group = Json, status = Deprecated(Some("replaced by `keyExistsJson`")))] function keyExists(string calldata json, string calldata key) external view returns (bool); /// Checks if `key` exists in a JSON object. #[cheatcode(group = Json)] diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index d254a9b668dde..401966c4626b0 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -447,6 +447,9 @@ pub struct Cheatcodes { /// Addresses with arbitrary storage. pub arbitrary_storage: Option, + + /// Deprecated cheatcodes mapped to the reason. Used to report warnings on test results. + pub deprecated: HashMap<&'static str, Option<&'static str>>, } // This is not derived because calling this in `fn new` with `..Default::default()` creates a second @@ -491,6 +494,7 @@ impl Cheatcodes { rng: Default::default(), ignored_traces: Default::default(), arbitrary_storage: Default::default(), + deprecated: Default::default(), } } @@ -2071,6 +2075,7 @@ fn apply_dispatch( ccx: &mut CheatsCtxt, executor: &mut E, ) -> Result { + // TODO: Replace with `::apply_full` once it's object-safe. macro_rules! dispatch { ($($variant:ident),*) => { match calls { @@ -2079,10 +2084,13 @@ fn apply_dispatch( }; } - let mut dyn_cheat = DynCheatCache::new(calls); - let _guard = trace_span_and_call(&mut dyn_cheat); + let cheat = calls_as_dyn_cheatcode(calls); + if let spec::Status::Deprecated(replacement) = *cheat.status() { + ccx.state.deprecated.insert(cheat.signature(), replacement); + } + let _guard = trace_span_and_call(cheat); let mut result = vm_calls!(dispatch); - fill_and_trace_return(&mut dyn_cheat, &mut result); + fill_and_trace_return(cheat, &mut result); result } @@ -2091,34 +2099,17 @@ fn will_exit(ir: InstructionResult) -> bool { !matches!(ir, InstructionResult::Continue | InstructionResult::CallOrCreate) } -// Caches the result of `calls_as_dyn_cheatcode`. -// TODO: Remove this once Cheatcode is object-safe, as caching would not be necessary anymore. -struct DynCheatCache<'a> { - calls: &'a Vm::VmCalls, - slot: Option<&'a dyn DynCheatcode>, -} - -impl<'a> DynCheatCache<'a> { - fn new(calls: &'a Vm::VmCalls) -> Self { - Self { calls, slot: None } - } - - fn get(&mut self) -> &dyn DynCheatcode { - *self.slot.get_or_insert_with(|| calls_as_dyn_cheatcode(self.calls)) - } -} - -fn trace_span_and_call(dyn_cheat: &mut DynCheatCache) -> tracing::span::EnteredSpan { - let span = debug_span!(target: "cheatcodes", "apply", id = %dyn_cheat.get().id()); +fn trace_span_and_call(cheat: &dyn DynCheatcode) -> tracing::span::EnteredSpan { + let span = debug_span!(target: "cheatcodes", "apply", id = %cheat.id()); let entered = span.entered(); - trace!(target: "cheatcodes", cheat = ?dyn_cheat.get().as_debug(), "applying"); + trace!(target: "cheatcodes", cheat = ?cheat.as_debug(), "applying"); entered } -fn fill_and_trace_return(dyn_cheat: &mut DynCheatCache, result: &mut Result) { +fn fill_and_trace_return(cheat: &dyn DynCheatcode, result: &mut Result) { if let Err(e) = result { if e.is_str() { - let name = dyn_cheat.get().name(); + let name = cheat.name(); // Skip showing the cheatcode name for: // - assertions: too verbose, and can already be inferred from the error message // - `rpcUrl`: forge-std relies on it in `getChainWithUpdatedRpcUrl` @@ -2136,7 +2127,6 @@ fn fill_and_trace_return(dyn_cheat: &mut DynCheatCache, result: &mut Result) { ); } -#[cold] fn calls_as_dyn_cheatcode(calls: &Vm::VmCalls) -> &dyn DynCheatcode { macro_rules! as_dyn { ($($variant:ident),*) => { diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 4a06ff454df36..50bd54701919d 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -14,6 +14,7 @@ extern crate tracing; use alloy_primitives::Address; use foundry_evm_core::backend::DatabaseExt; use revm::{ContextPrecompiles, InnerEvmContext}; +use spec::Status; pub use config::CheatsConfig; pub use error::{Error, ErrorKind, Result}; @@ -90,6 +91,8 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { pub(crate) trait DynCheatcode { fn name(&self) -> &'static str; fn id(&self) -> &'static str; + fn signature(&self) -> &'static str; + fn status(&self) -> &Status<'static>; fn as_debug(&self) -> &dyn std::fmt::Debug; } @@ -100,6 +103,12 @@ impl DynCheatcode for T { fn id(&self) -> &'static str { T::CHEATCODE.func.id } + fn signature(&self) -> &'static str { + T::CHEATCODE.func.signature + } + fn status(&self) -> &Status<'static> { + &T::CHEATCODE.status + } fn as_debug(&self) -> &dyn std::fmt::Debug { self } diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index ee5a03dca541d..54480181ff1cd 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -17,7 +17,7 @@ use foundry_evm_fuzz::{ use foundry_evm_traces::SparsedTraceArena; use indicatif::ProgressBar; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; -use std::cell::RefCell; +use std::{cell::RefCell, collections::HashMap}; mod types; pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; @@ -39,6 +39,8 @@ pub struct FuzzTestData { pub coverage: Option, // Stores logs for all fuzz cases pub logs: Vec, + // Deprecated cheatcodes mapped to their replacements. + pub deprecated_cheatcodes: HashMap<&'static str, Option<&'static str>>, } /// Wrapper around an [`Executor`] which provides fuzzing support using [`proptest`]. @@ -124,6 +126,7 @@ impl FuzzedExecutor { Some(prev) => prev.merge(case.coverage.unwrap()), opt => *opt = case.coverage, } + data.deprecated_cheatcodes = case.deprecated_cheatcodes; Ok(()) } @@ -168,6 +171,7 @@ impl FuzzedExecutor { breakpoints: last_run_breakpoints, gas_report_traces: traces.into_iter().map(|a| a.arena).collect(), coverage: fuzz_result.coverage, + deprecated_cheatcodes: fuzz_result.deprecated_cheatcodes, }; match run_result { @@ -230,10 +234,10 @@ impl FuzzedExecutor { return Err(TestCaseError::reject(FuzzError::AssumeReject)) } - let breakpoints = call - .cheatcodes - .as_ref() - .map_or_else(Default::default, |cheats| cheats.breakpoints.clone()); + let (breakpoints, deprecated_cheatcodes) = + call.cheatcodes.as_ref().map_or_else(Default::default, |cheats| { + (cheats.breakpoints.clone(), cheats.deprecated.clone()) + }); let success = self.executor.is_raw_call_mut_success(address, &mut call, should_fail); if success { @@ -243,6 +247,7 @@ impl FuzzedExecutor { coverage: call.coverage, breakpoints, logs: call.logs, + deprecated_cheatcodes, })) } else { Ok(FuzzOutcome::CounterExample(CounterExampleOutcome { diff --git a/crates/evm/evm/src/executors/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs index ac7c143739bc6..081ff91129cf4 100644 --- a/crates/evm/evm/src/executors/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -5,30 +5,33 @@ use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::FuzzCase; use foundry_evm_traces::SparsedTraceArena; use revm::interpreter::InstructionResult; +use std::collections::HashMap; /// Returned by a single fuzz in the case of a successful run #[derive(Debug)] pub struct CaseOutcome { - /// Data of a single fuzz test case + /// Data of a single fuzz test case. pub case: FuzzCase, - /// The traces of the call + /// The traces of the call. pub traces: Option, - /// The coverage info collected during the call + /// The coverage info collected during the call. pub coverage: Option, - /// Breakpoints char pc map + /// Breakpoints char pc map. pub breakpoints: Breakpoints, - /// logs of a single fuzz test case + /// logs of a single fuzz test case. pub logs: Vec, + // Deprecated cheatcodes mapped to their replacements. + pub deprecated_cheatcodes: HashMap<&'static str, Option<&'static str>>, } /// Returned by a single fuzz when a counterexample has been discovered #[derive(Debug)] pub struct CounterExampleOutcome { - /// Minimal reproduction test case for failing test + /// Minimal reproduction test case for failing test. pub counterexample: (Bytes, RawCallResult), - /// The status of the call + /// The status of the call. pub exit_reason: InstructionResult, - /// Breakpoints char pc map + /// Breakpoints char pc map. pub breakpoints: Breakpoints, } diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index c10d31560b562..177e1b55b26c3 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -17,7 +17,7 @@ use indicatif::ProgressBar; use parking_lot::RwLock; use proptest::test_runner::TestError; use revm::primitives::U256; -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; /// Replays a call sequence for collecting logs and traces. /// Returns counterexample to be used when the call sequence is a failed scenario. @@ -30,6 +30,7 @@ pub fn replay_run( logs: &mut Vec, traces: &mut Traces, coverage: &mut Option, + deprecated_cheatcodes: &mut HashMap<&'static str, Option<&'static str>>, inputs: &[BasicTxDetails], ) -> Result> { // We want traces for a failed case. @@ -84,6 +85,12 @@ pub fn replay_run( )?; traces.push((TraceKind::Execution, invariant_result.traces.clone().unwrap())); logs.extend(invariant_result.logs); + deprecated_cheatcodes.extend( + invariant_result + .cheatcodes + .as_ref() + .map_or_else(Default::default, |cheats| cheats.deprecated.clone()), + ); // Collect after invariant logs and traces. if invariant_contract.call_after_invariant && invariant_success { @@ -107,6 +114,7 @@ pub fn replay_error( logs: &mut Vec, traces: &mut Traces, coverage: &mut Option, + deprecated_cheatcodes: &mut HashMap<&'static str, Option<&'static str>>, progress: Option<&ProgressBar>, ) -> Result> { match failed_case.test_error { @@ -133,6 +141,7 @@ pub fn replay_error( logs, traces, coverage, + deprecated_cheatcodes, &calls, ) } diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index fe1cb38d08f4e..2930a6aa020ca 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -183,6 +183,9 @@ pub struct FuzzTestResult { /// Breakpoints for debugger. Correspond to the same fuzz case as `traces`. pub breakpoints: Option, + + // Deprecated cheatcodes mapped to their replacements. + pub deprecated_cheatcodes: HashMap<&'static str, Option<&'static str>>, } impl FuzzTestResult { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index be445d49165cf..171a234a5ee02 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -215,8 +215,26 @@ impl SuiteResult { pub fn new( duration: Duration, test_results: BTreeMap, - warnings: Vec, + mut warnings: Vec, ) -> Self { + // Add deprecated cheatcodes warning, if any of them used in current test suite. + let mut deprecated_cheatcodes = HashMap::new(); + for test_result in test_results.values() { + deprecated_cheatcodes.extend(test_result.deprecated_cheatcodes.clone()); + } + if !deprecated_cheatcodes.is_empty() { + let mut warning = + "the following cheatcode(s) are deprecated and will be removed in future versions:" + .to_string(); + for (cheatcode, reason) in deprecated_cheatcodes { + write!(warning, "\n {cheatcode}").unwrap(); + if let Some(reason) = reason { + write!(warning, ": {reason}").unwrap(); + } + } + warnings.push(warning); + } + Self { duration, test_results, warnings } } @@ -390,6 +408,10 @@ pub struct TestResult { /// pc breakpoint char map pub breakpoints: Breakpoints, + + /// Deprecated cheatcodes (mapped to their replacements, if any) used in current test. + #[serde(skip)] + pub deprecated_cheatcodes: HashMap<&'static str, Option<&'static str>>, } impl fmt::Display for TestResult { @@ -501,9 +523,14 @@ impl TestResult { false => TestStatus::Failure, }; self.reason = reason; - self.breakpoints = raw_call_result.cheatcodes.map(|c| c.breakpoints).unwrap_or_default(); self.duration = Duration::default(); self.gas_report_traces = Vec::new(); + + if let Some(cheatcodes) = raw_call_result.cheatcodes { + self.breakpoints = cheatcodes.breakpoints; + self.deprecated_cheatcodes = cheatcodes.deprecated; + } + self } @@ -535,6 +562,7 @@ impl TestResult { self.duration = Duration::default(); self.gas_report_traces = result.gas_report_traces.into_iter().map(|t| vec![t]).collect(); self.breakpoints = result.breakpoints.unwrap_or_default(); + self.deprecated_cheatcodes = result.deprecated_cheatcodes; self } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 02b8150df5ce2..51f2e5cc1be40 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -530,6 +530,7 @@ impl<'a> ContractRunner<'a> { &mut test_result.logs, &mut test_result.traces, &mut test_result.coverage, + &mut test_result.deprecated_cheatcodes, &txes, ); return test_result.invariant_replay_fail( @@ -572,6 +573,7 @@ impl<'a> ContractRunner<'a> { &mut test_result.logs, &mut test_result.traces, &mut test_result.coverage, + &mut test_result.deprecated_cheatcodes, progress.as_ref(), ) { Ok(call_sequence) => { @@ -607,6 +609,7 @@ impl<'a> ContractRunner<'a> { &mut test_result.logs, &mut test_result.traces, &mut test_result.coverage, + &mut test_result.deprecated_cheatcodes, &invariant_result.last_run_inputs, ) { error!(%err, "Failed to replay last invariant run"); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 0254f251b0f25..acfec46c6bf54 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2099,3 +2099,78 @@ contract JunitReportTest is Test { "#]]); }); + +forgetest_init!( + // Enable this if no cheatcodes are deprecated. + // #[ignore = "no cheatcodes are deprecated"] + test_deprecated_cheatcode_warning, + |prj, cmd| { + prj.add_test( + "DeprecatedCheatcodeTest.t.sol", + r#" + import "forge-std/Test.sol"; + contract DeprecatedCheatcodeTest is Test { + function test_deprecated_cheatcode() public view { + vm.keyExists('{"a": 123}', ".a"); + vm.keyExists('{"a": 123}', ".a"); + } + } + + contract DeprecatedCheatcodeFuzzTest is Test { + function test_deprecated_cheatcode(uint256 a) public view { + vm.keyExists('{"a": 123}', ".a"); + } + } + + contract Counter { + uint256 a; + + function count() public { + a++; + } + } + + contract DeprecatedCheatcodeInvariantTest is Test { + function setUp() public { + Counter counter = new Counter(); + } + + /// forge-config: default.invariant.runs = 1 + function invariant_deprecated_cheatcode() public { + vm.keyExists('{"a": 123}', ".a"); + } + } + "#, + ) + .unwrap(); + + // Tests deprecated cheatcode warning for unit tests. + cmd.args(["test", "--mc", "DeprecatedCheatcodeTest"]).assert_success().stderr_eq(str![[ + r#" +Warning: the following cheatcode(s) are deprecated and will be removed in future versions: + keyExists(string,string): replaced by `keyExistsJson` + +"# + ]]); + + // Tests deprecated cheatcode warning for fuzz tests. + cmd.forge_fuse() + .args(["test", "--mc", "DeprecatedCheatcodeFuzzTest"]) + .assert_success() + .stderr_eq(str![[r#" +Warning: the following cheatcode(s) are deprecated and will be removed in future versions: + keyExists(string,string): replaced by `keyExistsJson` + +"#]]); + + // Tests deprecated cheatcode warning for invariant tests. + cmd.forge_fuse() + .args(["test", "--mc", "DeprecatedCheatcodeInvariantTest"]) + .assert_success() + .stderr_eq(str![[r#" +Warning: the following cheatcode(s) are deprecated and will be removed in future versions: + keyExists(string,string): replaced by `keyExistsJson` + +"#]]); + } +); diff --git a/crates/macros/src/cheatcodes.rs b/crates/macros/src/cheatcodes.rs index 4fbe6cfa79cde..d9c2d2c914352 100644 --- a/crates/macros/src/cheatcodes.rs +++ b/crates/macros/src/cheatcodes.rs @@ -20,7 +20,7 @@ pub fn derive_cheatcode(input: &DeriveInput) -> Result { /// Implements `CheatcodeDef` for a function call struct. fn derive_call(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result { let mut group = None::; - let mut status = None::; + let mut status = None::; let mut safety = None::; for attr in attrs.iter().filter(|a| a.path().is_ident("cheatcode")) { attr.meta.require_list()?.parse_nested_meta(|meta| { @@ -38,7 +38,7 @@ fn derive_call(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result Date: Fri, 20 Sep 2024 16:53:06 +0200 Subject: [PATCH 1464/1963] refactor: rewrite the console.log format string parser (#8913) * refactor: rewrite the console.log format string parser * chore: clippy --- crates/common/fmt/src/console.rs | 238 +++++++++++++++++++++---------- 1 file changed, 163 insertions(+), 75 deletions(-) diff --git a/crates/common/fmt/src/console.rs b/crates/common/fmt/src/console.rs index 7473ccdec76c7..5bc291e03e090 100644 --- a/crates/common/fmt/src/console.rs +++ b/crates/common/fmt/src/console.rs @@ -1,61 +1,175 @@ use super::UIfmt; use alloy_primitives::{Address, Bytes, FixedBytes, I256, U256}; -use std::iter::Peekable; +use std::fmt::{self, Write}; + +/// A piece is a portion of the format string which represents the next part to emit. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Piece<'a> { + /// A literal string which should directly be emitted. + String(&'a str), + /// A format specifier which should be replaced with the next argument. + NextArgument(FormatSpec), +} /// A format specifier. -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub enum FormatSpec { - /// %s format spec + /// `%s` #[default] String, - /// %d format spec + /// `%d` Number, - /// %i format spec + /// `%i` Integer, - /// %o format spec + /// `%o` Object, - /// %e format spec with an optional precision + /// `%e`, `%18e` Exponential(Option), - /// %x format spec + /// `%x` Hexadecimal, } -impl FormatSpec { - fn from_chars(iter: &mut Peekable) -> Result - where - I: Iterator, - { - match iter.next().ok_or_else(String::new)? { - 's' => Ok(Self::String), - 'd' => Ok(Self::Number), - 'i' => Ok(Self::Integer), - 'o' => Ok(Self::Object), - 'e' => Ok(Self::Exponential(None)), - 'x' => Ok(Self::Hexadecimal), - ch if ch.is_ascii_digit() => { - let mut num = ch.to_string(); - while let Some(&ch) = iter.peek() { - if ch.is_ascii_digit() { - num.push(ch); - iter.next(); - } else { - break; - } +impl fmt::Display for FormatSpec { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("%")?; + match *self { + Self::String => f.write_str("s"), + Self::Number => f.write_str("d"), + Self::Integer => f.write_str("i"), + Self::Object => f.write_str("o"), + Self::Exponential(Some(n)) => write!(f, "{n}e"), + Self::Exponential(None) => f.write_str("e"), + Self::Hexadecimal => f.write_str("x"), + } + } +} + +enum ParseArgError { + /// Failed to parse the argument. + Err, + /// Escape `%%`. + Skip, +} + +/// Parses a format string into a sequence of [pieces][Piece]. +#[derive(Debug)] +pub struct Parser<'a> { + input: &'a str, + chars: std::str::CharIndices<'a>, +} + +impl<'a> Parser<'a> { + /// Creates a new parser for the given input. + pub fn new(input: &'a str) -> Self { + Self { input, chars: input.char_indices() } + } + + /// Parses a string until the next format specifier. + /// + /// `skip` is the number of format specifier characters (`%`) to ignore before returning the + /// string. + fn string(&mut self, start: usize, mut skip: usize) -> &'a str { + while let Some((pos, c)) = self.peek() { + if c == '%' { + if skip == 0 { + return &self.input[start..pos]; } - if let Some(&ch) = iter.peek() { - if ch == 'e' { - let num = num.parse().map_err(|_| num)?; - iter.next(); - Ok(Self::Exponential(Some(num))) - } else { - Err(num) - } - } else { - Err(num) + skip -= 1; + } + self.chars.next(); + } + &self.input[start..] + } + + /// Parses a format specifier. + /// + /// If `Err` is returned, the internal iterator may have been advanced and it may be in an + /// invalid state. + fn argument(&mut self) -> Result { + let (start, ch) = self.peek().ok_or(ParseArgError::Err)?; + let simple_spec = match ch { + 's' => Some(FormatSpec::String), + 'd' => Some(FormatSpec::Number), + 'i' => Some(FormatSpec::Integer), + 'o' => Some(FormatSpec::Object), + 'e' => Some(FormatSpec::Exponential(None)), + 'x' => Some(FormatSpec::Hexadecimal), + // "%%" is a literal '%'. + '%' => return Err(ParseArgError::Skip), + _ => None, + }; + if let Some(spec) = simple_spec { + self.chars.next(); + return Ok(spec); + } + + // %e + if ch.is_ascii_digit() { + let n = self.integer(start); + if let Some((_, 'e')) = self.peek() { + self.chars.next(); + return Ok(FormatSpec::Exponential(n)); + } + } + + Err(ParseArgError::Err) + } + + fn integer(&mut self, start: usize) -> Option { + let mut end = start; + while let Some((pos, ch)) = self.peek() { + if !ch.is_ascii_digit() { + end = pos; + break; + } + self.chars.next(); + } + self.input[start..end].parse().ok() + } + + fn current_pos(&mut self) -> usize { + self.peek().map(|(n, _)| n).unwrap_or(self.input.len()) + } + + fn peek(&mut self) -> Option<(usize, char)> { + self.peek_n(0) + } + + fn peek_n(&mut self, n: usize) -> Option<(usize, char)> { + self.chars.clone().nth(n) + } +} + +impl<'a> Iterator for Parser<'a> { + type Item = Piece<'a>; + + fn next(&mut self) -> Option { + let (mut start, ch) = self.peek()?; + let mut skip = 0; + if ch == '%' { + let prev = self.chars.clone(); + self.chars.next(); + match self.argument() { + Ok(arg) => { + debug_assert_eq!(arg.to_string(), self.input[start..self.current_pos()]); + return Some(Piece::NextArgument(arg)); + } + + // Skip the argument if we encountered "%%". + Err(ParseArgError::Skip) => { + start = self.current_pos(); + skip += 1; + } + + // Reset the iterator if we failed to parse the argument, and include any + // parsed and unparsed specifier in `String`. + Err(ParseArgError::Err) => { + self.chars = prev; + skip += 1; } } - ch => Err(String::from(ch)), } + Some(Piece::String(self.string(start, skip))) } } @@ -249,7 +363,7 @@ impl ConsoleFmt for [u8] { /// assert_eq!(formatted, "foo has 3 characters"); /// ``` pub fn console_format(spec: &str, values: &[&dyn ConsoleFmt]) -> String { - let mut values = values.iter().copied().peekable(); + let mut values = values.iter().copied(); let mut result = String::with_capacity(spec.len()); // for the first space @@ -275,45 +389,19 @@ pub fn console_format(spec: &str, values: &[&dyn ConsoleFmt]) -> String { fn format_spec<'a>( s: &str, - values: &mut Peekable>, + mut values: impl Iterator, result: &mut String, ) { - let mut expect_fmt = false; - let mut chars = s.chars().peekable(); - - while chars.peek().is_some() { - if expect_fmt { - expect_fmt = false; - match FormatSpec::from_chars(&mut chars) { - Ok(spec) => { - let value = values.next().expect("value existence is checked"); - // format and write the value + for piece in Parser::new(s) { + match piece { + Piece::String(s) => result.push_str(s), + Piece::NextArgument(spec) => { + if let Some(value) = values.next() { result.push_str(&value.fmt(spec)); - } - Err(consumed) => { - // on parser failure, write '%' and consumed characters - result.push('%'); - result.push_str(&consumed); - } - } - } else { - let ch = chars.next().unwrap(); - if ch == '%' { - if let Some(&next_ch) = chars.peek() { - if next_ch == '%' { - result.push('%'); - chars.next(); - } else if values.peek().is_some() { - // only try formatting if there are values to format - expect_fmt = true; - } else { - result.push(ch); - } } else { - result.push(ch); + // Write the format specifier as-is if there are no more values. + write!(result, "{spec}").unwrap(); } - } else { - result.push(ch); } } } From f2c14c176b6f69ede1c067bcfcc0fdf2d6beba5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:59:41 +0200 Subject: [PATCH 1465/1963] feat: implement `parseTomlType` cheats (#8911) * feat: implement `parseTomlType` cheats * chore: `forge fmt` * revert: use json naming to indicate to users that they are operating on json data * chore: nit * chore: nit --- crates/cheatcodes/assets/cheatcodes.json | 60 ++++++++ crates/cheatcodes/spec/src/vm.rs | 13 ++ crates/cheatcodes/src/json.rs | 2 +- crates/cheatcodes/src/toml.rs | 25 +++- testdata/cheats/Vm.sol | 3 + testdata/default/cheats/Toml.t.sol | 130 ++++++++++++++++-- .../fixtures/Toml/nested_toml_struct.toml | 23 ++++ testdata/fixtures/Toml/test.toml | 4 +- 8 files changed, 244 insertions(+), 16 deletions(-) create mode 100644 testdata/fixtures/Toml/nested_toml_struct.toml diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 4d337ff5ecba5..4357d82a248f1 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6473,6 +6473,66 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "parseTomlTypeArray", + "description": "Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`.", + "declaration": "function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlTypeArray(string,string,string)", + "selector": "0x49be3743", + "selectorBytes": [ + 73, + 190, + 55, + 67 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlType_0", + "description": "Parses a string of TOML data and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlType(string,string)", + "selector": "0x47fa5e11", + "selectorBytes": [ + 71, + 250, + 94, + 17 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlType_1", + "description": "Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlType(string,string,string)", + "selector": "0xf9fa5cdb", + "selectorBytes": [ + 249, + 250, + 92, + 219 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "parseTomlUint", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index fef210bae2485..a29b0cf80a760 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2134,6 +2134,19 @@ interface Vm { pure returns (bytes32[] memory); + /// Parses a string of TOML data and coerces it to type corresponding to `typeDescription`. + #[cheatcode(group = Toml)] + function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory); + /// Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`. + #[cheatcode(group = Toml)] + function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory); + /// Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`. + #[cheatcode(group = Toml)] + function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription) + external + pure + returns (bytes memory); + /// Returns an array of all the keys in a TOML table. #[cheatcode(group = Toml)] function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys); diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index dad879e83b2d1..ba32b4ebe6441 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -654,7 +654,7 @@ fn serialize_json( } /// Resolves a [DynSolType] from user input. -fn resolve_type(type_description: &str) -> Result { +pub(super) fn resolve_type(type_description: &str) -> Result { if let Ok(ty) = DynSolType::parse(type_description) { return Ok(ty); }; diff --git a/crates/cheatcodes/src/toml.rs b/crates/cheatcodes/src/toml.rs index e83a183905472..b55ef2d16eedf 100644 --- a/crates/cheatcodes/src/toml.rs +++ b/crates/cheatcodes/src/toml.rs @@ -3,12 +3,13 @@ use crate::{ json::{ canonicalize_json_path, check_json_key_exists, parse_json, parse_json_coerce, - parse_json_keys, + parse_json_keys, resolve_type, }, Cheatcode, Cheatcodes, Result, Vm::*, }; use alloy_dyn_abi::DynSolType; +use alloy_sol_types::SolValue; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; use serde_json::Value as JsonValue; @@ -133,6 +134,28 @@ impl Cheatcode for parseTomlBytes32ArrayCall { } } +impl Cheatcode for parseTomlType_0Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, typeDescription } = self; + parse_toml_coerce(toml, "$", &resolve_type(typeDescription)?).map(|v| v.abi_encode()) + } +} + +impl Cheatcode for parseTomlType_1Call { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key, typeDescription } = self; + parse_toml_coerce(toml, key, &resolve_type(typeDescription)?).map(|v| v.abi_encode()) + } +} + +impl Cheatcode for parseTomlTypeArrayCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { toml, key, typeDescription } = self; + let ty = resolve_type(typeDescription)?; + parse_toml_coerce(toml, key, &DynSolType::Array(Box::new(ty))).map(|v| v.abi_encode()) + } +} + impl Cheatcode for parseTomlKeysCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { toml, key } = self; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 4b7f3fe42f503..7316521ecb32f 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -319,6 +319,9 @@ interface Vm { 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 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); diff --git a/testdata/default/cheats/Toml.t.sol b/testdata/default/cheats/Toml.t.sol index a01b29af62cb6..4b1666d4f28a8 100644 --- a/testdata/default/cheats/Toml.t.sol +++ b/testdata/default/cheats/Toml.t.sol @@ -5,7 +5,81 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; import "../logs/console.sol"; +library TomlStructs { + address constant HEVM_ADDRESS = address(bytes20(uint160(uint256(keccak256("hevm cheat code"))))); + Vm constant vm = Vm(HEVM_ADDRESS); + + // forge eip712 testdata/default/cheats/Toml.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^FlatToml + string constant schema_FlatToml = + "FlatToml(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + // forge eip712 testdata/default/cheats/Toml.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^NestedToml + string constant schema_NestedToml = + "NestedToml(FlatToml[] members,AnotherFlatToml inner,string name)AnotherFlatToml(bytes4 fixedBytes)FlatToml(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + function deserializeFlatToml(string memory toml) internal pure returns (ParseTomlTest.FlatToml memory) { + return abi.decode(vm.parseTomlType(toml, schema_FlatToml), (ParseTomlTest.FlatToml)); + } + + function deserializeFlatToml(string memory toml, string memory path) + internal + pure + returns (ParseTomlTest.FlatToml memory) + { + return abi.decode(vm.parseTomlType(toml, path, schema_FlatToml), (ParseTomlTest.FlatToml)); + } + + function deserializeFlatTomlArray(string memory toml, string memory path) + internal + pure + returns (ParseTomlTest.FlatToml[] memory) + { + return abi.decode(vm.parseTomlTypeArray(toml, path, schema_FlatToml), (ParseTomlTest.FlatToml[])); + } + + function deserializeNestedToml(string memory toml) internal pure returns (ParseTomlTest.NestedToml memory) { + return abi.decode(vm.parseTomlType(toml, schema_NestedToml), (ParseTomlTest.NestedToml)); + } + + function deserializeNestedToml(string memory toml, string memory path) + internal + pure + returns (ParseTomlTest.NestedToml memory) + { + return abi.decode(vm.parseTomlType(toml, path, schema_NestedToml), (ParseTomlTest.NestedToml)); + } + + function deserializeNestedTomlArray(string memory toml, string memory path) + internal + pure + returns (ParseTomlTest.NestedToml[] memory) + { + return abi.decode(vm.parseTomlType(toml, path, schema_NestedToml), (ParseTomlTest.NestedToml[])); + } +} + contract ParseTomlTest is DSTest { + using TomlStructs for *; + + struct FlatToml { + uint256 a; + int24[][] arr; + string str; + bytes b; + address addr; + bytes32 fixedBytes; + } + + struct AnotherFlatToml { + bytes4 fixedBytes; + } + + struct NestedToml { + FlatToml[] members; + AnotherFlatToml inner; + string name; + } + Vm constant vm = Vm(HEVM_ADDRESS); string toml; @@ -169,20 +243,20 @@ contract ParseTomlTest is DSTest { assertEq(bytesArray[1], hex"02"); } - struct Nested { + struct NestedStruct { uint256 number; string str; } function test_nestedObject() public { bytes memory data = vm.parseToml(toml, ".nestedObject"); - Nested memory nested = abi.decode(data, (Nested)); + NestedStruct memory nested = abi.decode(data, (NestedStruct)); assertEq(nested.number, 9223372036854775807); // TOML is limited to 64-bit integers assertEq(nested.str, "NEST"); } - function test_advancedJsonPath() public { - bytes memory data = vm.parseToml(toml, ".advancedJsonPath[*].id"); + function test_advancedTomlPath() public { + bytes memory data = vm.parseToml(toml, ".advancedTomlPath[*].id"); uint256[] memory numbers = abi.decode(data, (uint256[])); assertEq(numbers[0], 1); assertEq(numbers[1], 2); @@ -225,6 +299,36 @@ contract ParseTomlTest is DSTest { vm._expectCheatcodeRevert("key \".*\" must return exactly one JSON object"); vm.parseTomlKeys(tomlString, ".*"); } + + // forge eip712 testdata/default/cheats/Toml.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^FlatToml + string constant schema_FlatToml = + "FlatToml(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + // forge eip712 testdata/default/cheats/Toml.t.sol -R 'cheats=testdata/cheats' -R 'ds-test=testdata/lib/ds-test/src' | grep ^NestedToml + string constant schema_NestedToml = + "NestedToml(FlatToml[] members,AnotherFlatToml inner,string name)AnotherFlatToml(bytes4 fixedBytes)FlatToml(uint256 a,int24[][] arr,string str,bytes b,address addr,bytes32 fixedBytes)"; + + function test_parseTomlType() public { + string memory readToml = vm.readFile("fixtures/Toml/nested_toml_struct.toml"); + NestedToml memory data = readToml.deserializeNestedToml(); + assertEq(data.members.length, 2); + + FlatToml memory expected = FlatToml({ + a: 200, + arr: new int24[][](0), + str: "some other string", + b: hex"0000000000000000000000000000000000000000", + addr: 0x167D91deaEEE3021161502873d3bcc6291081648, + fixedBytes: 0xed1c7beb1f00feaaaec5636950d6edb25a8d4fedc8deb2711287b64c4d27719d + }); + + assertEq(keccak256(abi.encode(data.members[1])), keccak256(abi.encode(expected))); + assertEq(bytes32(data.inner.fixedBytes), bytes32(bytes4(0x12345678))); + + FlatToml[] memory members = TomlStructs.deserializeFlatTomlArray(readToml, ".members"); + + assertEq(keccak256(abi.encode(members)), keccak256(abi.encode(data.members))); + } } contract WriteTomlTest is DSTest { @@ -238,18 +342,18 @@ contract WriteTomlTest is DSTest { json2 = "example2"; } - struct simpleJson { + struct simpleStruct { uint256 a; string b; } - struct notSimpleJson { + struct nestedStruct { uint256 a; string b; - simpleJson c; + simpleStruct c; } - function test_serializeNotSimpleToml() public { + function test_serializeNestedStructToml() public { string memory json3 = "json3"; string memory path = "fixtures/Toml/write_complex_test.toml"; vm.serializeUint(json3, "a", uint256(123)); @@ -259,14 +363,16 @@ contract WriteTomlTest is DSTest { vm.writeToml(finalJson, path); string memory toml = vm.readFile(path); bytes memory data = vm.parseToml(toml); - notSimpleJson memory decodedData = abi.decode(data, (notSimpleJson)); + nestedStruct memory decodedData = abi.decode(data, (nestedStruct)); + console.log(decodedData.a); + assertEq(decodedData.a, 123); } function test_retrieveEntireToml() public { string memory path = "fixtures/Toml/write_complex_test.toml"; string memory toml = vm.readFile(path); bytes memory data = vm.parseToml(toml, "."); - notSimpleJson memory decodedData = abi.decode(data, (notSimpleJson)); + nestedStruct memory decodedData = abi.decode(data, (nestedStruct)); console.log(decodedData.a); assertEq(decodedData.a, 123); } @@ -294,7 +400,7 @@ contract WriteTomlTest is DSTest { string memory toml = vm.readFile(path); bytes memory data = vm.parseToml(toml); - simpleJson memory decodedData = abi.decode(data, (simpleJson)); + simpleStruct memory decodedData = abi.decode(data, (simpleStruct)); assertEq(decodedData.a, 123); assertEq(decodedData.b, "test"); @@ -303,7 +409,7 @@ contract WriteTomlTest is DSTest { // read again toml = vm.readFile(path); data = vm.parseToml(toml, ".b"); - decodedData = abi.decode(data, (simpleJson)); + decodedData = abi.decode(data, (simpleStruct)); assertEq(decodedData.a, 123); assertEq(decodedData.b, "test"); diff --git a/testdata/fixtures/Toml/nested_toml_struct.toml b/testdata/fixtures/Toml/nested_toml_struct.toml new file mode 100644 index 0000000000000..3cef0b7ba1045 --- /dev/null +++ b/testdata/fixtures/Toml/nested_toml_struct.toml @@ -0,0 +1,23 @@ +name = "test" + +[[members]] +a = 100 +arr = [ + [1, -2, -5], + [1000, 2000, 0] +] +str = "some string" +b = "0x" +addr = "0x0000000000000000000000000000000000000000" +fixedBytes = "0x8ae3fc6bd1b150a73ec4afe3ef136fa2f88e9c96131c883c5e4a4714811c1598" + +[[members]] +a = 200 +arr = [] +str = "some other string" +b = "0x0000000000000000000000000000000000000000" +addr = "0x167D91deaEEE3021161502873d3bcc6291081648" +fixedBytes = "0xed1c7beb1f00feaaaec5636950d6edb25a8d4fedc8deb2711287b64c4d27719d" + +[inner] +fixedBytes = "0x12345678" diff --git a/testdata/fixtures/Toml/test.toml b/testdata/fixtures/Toml/test.toml index ce735b8f18cf9..806dc2224de46 100644 --- a/testdata/fixtures/Toml/test.toml +++ b/testdata/fixtures/Toml/test.toml @@ -43,8 +43,8 @@ bytesStringArray = ["0x01", "0x02"] number = 9223372036854775807 # TOML is limited to 64-bit integers str = "NEST" -[[advancedJsonPath]] +[[advancedTomlPath]] id = 1 -[[advancedJsonPath]] +[[advancedTomlPath]] id = 2 From a33fc1d698182969df4fe77f57967db3b2ed2e75 Mon Sep 17 00:00:00 2001 From: Jennifer Date: Fri, 20 Sep 2024 21:32:28 +0200 Subject: [PATCH 1466/1963] Log address in checksum format (#8915) Co-authored-by: jenpaff --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0f28e28a56457..53dc9898f073b 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1068,7 +1068,7 @@ impl Backend { // log some tx info node_info!(" Transaction: {:?}", info.transaction_hash); if let Some(contract) = &info.contract_address { - node_info!(" Contract created: {contract:?}"); + node_info!(" Contract created: {contract}"); } node_info!(" Gas used: {}", receipt.cumulative_gas_used()); if !info.exit.is_ok() { From 09c8e753e1cc5ce6c68a4d04f33acfcdd42f673c Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Sat, 21 Sep 2024 15:46:13 +0800 Subject: [PATCH 1467/1963] improve description of `--flamechart` and `--flamegraph` (#8917) improve description of --flamechart and --flamegraph, explaining the difference --- crates/forge/bin/cmd/test/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 3bc659ea083d3..0b8a0995b9d44 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -86,10 +86,16 @@ pub struct TestArgs { debug: Option, /// Generate a flamegraph for a single test. Implies `--decode-internal`. + /// + /// A flame graph is used to visualize which functions or operations within the smart contract + /// are consuming the most gas overall in a sorted manner. #[arg(long, conflicts_with = "flamechart")] flamegraph: bool, /// Generate a flamechart for a single test. Implies `--decode-internal`. + /// + /// A flame chart shows the gas usage over time, illustrating when each function is + /// called (execution order) and how much gas it consumes at each point in the timeline. #[arg(long, conflicts_with = "flamegraph")] flamechart: bool, From 90541f054f1666547a4869eed74751a7463b8571 Mon Sep 17 00:00:00 2001 From: Qiwei Yang Date: Sat, 21 Sep 2024 19:17:17 +0800 Subject: [PATCH 1468/1963] fix(forge): improve `test --debug` doc (#8918) improve doc --- crates/forge/bin/cmd/test/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 0b8a0995b9d44..ac0d706910696 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -69,8 +69,8 @@ pub struct TestArgs { /// Run a test in the debugger. /// - /// The argument passed to this flag is the name of the test function you want to run, and it - /// works the same as --match-test. + /// The argument passed to this flag is the **regex** of the test function signature you want + /// to run, and it works the same as --match-test. /// /// If more than one test matches your specified criteria, you must add additional filters /// until only one test is found (see --match-contract and --match-path). From 1f9c77a366b913e762c12a2d6b6e21623f637b0f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:48:50 +0200 Subject: [PATCH 1469/1963] chore: use dyn InspectorExt in Backend (#8919) --- crates/evm/core/src/backend/mod.rs | 24 ++++++++++++++---------- crates/evm/core/src/lib.rs | 3 ++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index e98ac00c5d6c1..43e7bd73e6939 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -868,7 +868,7 @@ impl Backend { let fork = self.inner.get_fork_by_id_mut(id)?; let full_block = fork.db.db.get_full_block(env.block.number.to::())?; - for tx in full_block.transactions.clone().into_transactions() { + for tx in full_block.inner.transactions.into_transactions() { // System transactions such as on L2s don't contain any pricing info so we skip them // otherwise this would cause reverts if is_known_system_sender(tx.from) || @@ -885,7 +885,7 @@ impl Backend { trace!(tx=?tx.hash, "committing transaction"); commit_transaction( - tx, + &tx.inner, env.clone(), journaled_state, fork, @@ -1235,8 +1235,12 @@ impl DatabaseExt for Backend { fork.db.db.get_transaction(transaction)? }; - // This is a bit ambiguous because the user wants to transact an arbitrary transaction in the current context, but we're assuming the user wants to transact the transaction as it was mined. Usually this is used in a combination of a fork at the transaction's parent transaction in the block and then the transaction is transacted: - // So we modify the env to match the transaction's block + // This is a bit ambiguous because the user wants to transact an arbitrary transaction in + // the current context, but we're assuming the user wants to transact the transaction as it + // was mined. Usually this is used in a combination of a fork at the transaction's parent + // transaction in the block and then the transaction is transacted: + // + // So we modify the env to match the transaction's block. let (_fork_block, block) = self.get_block_number_and_block_for_transaction(id, transaction)?; let mut env = env.clone(); @@ -1245,7 +1249,7 @@ impl DatabaseExt for Backend { let env = self.env_with_handler_cfg(env); let fork = self.inner.get_fork_by_id_mut(id)?; commit_transaction( - tx, + &tx, env, journaled_state, fork, @@ -1903,17 +1907,17 @@ fn update_env_block(env: &mut Env, block: &Block) { } /// Executes the given transaction and commits state changes to the database _and_ the journaled -/// state, with an optional inspector -fn commit_transaction>( - tx: WithOtherFields, +/// state, with an inspector. +fn commit_transaction( + tx: &Transaction, mut env: EnvWithHandlerCfg, journaled_state: &mut JournaledState, fork: &mut Fork, fork_id: &ForkId, persistent_accounts: &HashSet
, - inspector: I, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { - configure_tx_env(&mut env.env, &tx.inner); + configure_tx_env(&mut env.env, tx); let now = Instant::now(); let res = { diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 26b392c433f39..48c6478651acb 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -45,9 +45,10 @@ pub trait InspectorExt: Inspector { false } - // Simulates `console.log` invocation. + /// Simulates `console.log` invocation. fn console_log(&mut self, _input: String) {} + /// Returns `true` if the current network is Alphanet. fn is_alphanet(&self) -> bool { false } From a301f261d9986bae659546d294468f5cacca265f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:16:51 +0200 Subject: [PATCH 1470/1963] chore(evm): use dyn DatabaseExt in inspect (#8921) chore(evm): use dyn DatabaseExt in inspect --- crates/evm/core/src/backend/cow.rs | 8 ++++++-- crates/evm/core/src/backend/mod.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 2dcd985ae9124..cba792b32d892 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -62,7 +62,7 @@ impl<'a> CowBackend<'a> { /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. #[instrument(name = "inspect", level = "debug", skip_all)] - pub fn inspect<'b, I: InspectorExt<&'b mut Self>>( + pub fn inspect<'b, I: InspectorExt<&'b mut dyn DatabaseExt>>( &'b mut self, env: &mut EnvWithHandlerCfg, inspector: I, @@ -71,7 +71,11 @@ impl<'a> CowBackend<'a> { // already, we reset the initialized state self.is_initialized = false; self.spec_id = env.handler_cfg.spec_id; - let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); + let mut evm = crate::utils::new_evm_with_inspector( + self as &mut dyn DatabaseExt, + env.clone(), + inspector, + ); let res = evm.transact().wrap_err("backend: failed while inspecting")?; diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 43e7bd73e6939..4d1d7d9efeb8f 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -749,13 +749,17 @@ impl Backend { /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. #[instrument(name = "inspect", level = "debug", skip_all)] - pub fn inspect<'a, I: InspectorExt<&'a mut Self>>( + pub fn inspect<'a, I: InspectorExt<&'a mut dyn DatabaseExt>>( &'a mut self, env: &mut EnvWithHandlerCfg, inspector: I, ) -> eyre::Result { self.initialize(env); - let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); + let mut evm = crate::utils::new_evm_with_inspector( + self as &mut dyn DatabaseExt, + env.clone(), + inspector, + ); let res = evm.transact().wrap_err("backend: failed while inspecting")?; From ed3ed155b06d05060b213e8a7fe86d4ffae42b46 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:17:08 +0200 Subject: [PATCH 1471/1963] chore(anvil): use dyn DatabaseRef instead of generics (#8920) --- Cargo.lock | 1 - crates/anvil/Cargo.toml | 1 - crates/anvil/src/eth/api.rs | 13 ++-- crates/anvil/src/eth/backend/db.rs | 26 ++++++- crates/anvil/src/eth/backend/executor.rs | 10 +-- crates/anvil/src/eth/backend/mem/fork_db.rs | 15 +++-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 4 ++ crates/anvil/src/eth/backend/mem/mod.rs | 67 +++++++++---------- crates/anvil/src/eth/backend/validate.rs | 1 - 9 files changed, 80 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4726ad0420a08..e8dc2fee52d52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -873,7 +873,6 @@ dependencies = [ "anvil-rpc", "anvil-server", "async-trait", - "auto_impl", "axum", "bytes", "chrono", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 77faec1f1e52b..0723fdb47f808 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -103,7 +103,6 @@ clap = { version = "4", features = [ ], optional = true } clap_complete = { version = "4", optional = true } chrono.workspace = true -auto_impl.workspace = true ctrlc = { version = "3", optional = true } fdlimit = { version = "0.3", optional = true } clap_complete_fig = "4" diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index f856fef42c5ae..ec2d0dd6a9e6e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2445,7 +2445,7 @@ impl EthApi { state, )?); } - self.do_estimate_gas_with_state(request, state, block) + self.do_estimate_gas_with_state(request, &state, block) }) .await? } @@ -2453,15 +2453,12 @@ impl EthApi { /// Estimates the gas usage of the `request` with the state. /// /// This will execute the transaction request and find the best gas limit via binary search. - fn do_estimate_gas_with_state( + fn do_estimate_gas_with_state( &self, mut request: WithOtherFields, - state: D, + state: &dyn DatabaseRef, block_env: BlockEnv, - ) -> Result - where - D: DatabaseRef, - { + ) -> Result { // If the request is a simple native token transfer we can optimize // We assume it's a transfer if we have no input data. let to = request.to.as_ref().and_then(TxKind::to); @@ -2497,7 +2494,7 @@ impl EthApi { // If we have non-zero gas price, cap gas limit by sender balance if gas_price > 0 { if let Some(from) = request.from { - let mut available_funds = self.backend.get_balance_with_state(&state, from)?; + let mut available_funds = self.backend.get_balance_with_state(state, from)?; if let Some(value) = request.value { if value > available_funds { return Err(InvalidTransactionError::InsufficientFunds.into()); diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 60565c4d54679..a02f9d0e31e17 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -26,8 +26,11 @@ use serde::{ use std::{collections::BTreeMap, fmt, path::Path}; /// Helper trait get access to the full state data of the database -#[auto_impl::auto_impl(Box)] pub trait MaybeFullDatabase: DatabaseRef { + /// Returns a reference to the database as a `dyn DatabaseRef`. + // TODO: Required until trait upcasting is stabilized: + fn as_dyn(&self) -> &dyn DatabaseRef; + fn maybe_as_full_db(&self) -> Option<&HashMap> { None } @@ -51,6 +54,10 @@ impl<'a, T: 'a + MaybeFullDatabase + ?Sized> MaybeFullDatabase for &'a T where &'a T: DatabaseRef, { + fn as_dyn(&self) -> &dyn DatabaseRef { + T::as_dyn(self) + } + fn maybe_as_full_db(&self) -> Option<&HashMap> { T::maybe_as_full_db(self) } @@ -69,7 +76,6 @@ where } /// Helper trait to reset the DB if it's forked -#[auto_impl::auto_impl(Box)] pub trait MaybeForkedDatabase { fn maybe_reset(&mut self, _url: Option, block_number: BlockId) -> Result<(), String>; @@ -79,7 +85,6 @@ pub trait MaybeForkedDatabase { } /// This bundles all required revm traits -#[auto_impl::auto_impl(Box)] pub trait Db: DatabaseRef + Database @@ -188,6 +193,13 @@ pub trait Db: fn current_state(&self) -> StateDb; } +impl dyn Db { + // TODO: Required until trait upcasting is stabilized: + pub fn as_dbref(&self) -> &dyn DatabaseRef { + self.as_dyn() + } +} + /// Convenience impl only used to use any `Db` on the fly as the db layer for revm's CacheDB /// This is useful to create blocks without actually writing to the `Db`, but rather in the cache of /// the `CacheDB` see also @@ -230,6 +242,10 @@ impl + Send + Sync + Clone + fmt::Debug> D } impl> MaybeFullDatabase for CacheDB { + fn as_dyn(&self) -> &dyn DatabaseRef { + self + } + fn maybe_as_full_db(&self) -> Option<&HashMap> { Some(&self.accounts) } @@ -338,6 +354,10 @@ impl DatabaseRef for StateDb { } impl MaybeFullDatabase for StateDb { + fn as_dyn(&self) -> &dyn DatabaseRef { + self.0.as_dyn() + } + fn maybe_as_full_db(&self) -> Option<&HashMap> { self.0.maybe_as_full_db() } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index c84ad52007c24..caa042bf48861 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -89,11 +89,11 @@ pub struct ExecutedTransactions { } /// An executor for a series of transactions -pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> { +pub struct TransactionExecutor<'a, Db: ?Sized, V: TransactionValidator> { /// where to insert the transactions pub db: &'a mut Db, /// type used to validate before inclusion - pub validator: Validator, + pub validator: &'a V, /// all pending transactions pub pending: std::vec::IntoIter>, pub block_env: BlockEnv, @@ -111,7 +111,7 @@ pub struct TransactionExecutor<'a, Db: ?Sized, Validator: TransactionValidator> pub precompile_factory: Option>, } -impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<'a, DB, Validator> { +impl<'a, DB: Db + ?Sized, V: TransactionValidator> TransactionExecutor<'a, DB, V> { /// Executes all transactions and puts them in a new block with the provided `timestamp` pub fn execute(mut self) -> ExecutedTransactions { let mut transactions = Vec::new(); @@ -262,8 +262,8 @@ pub enum TransactionExecutionOutcome { DatabaseError(Arc, DatabaseError), } -impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator - for &'b mut TransactionExecutor<'a, DB, Validator> +impl<'a, 'b, DB: Db + ?Sized, V: TransactionValidator> Iterator + for &'b mut TransactionExecutor<'a, DB, V> { type Item = TransactionExecutionOutcome; diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index 1329de724a1c4..a5f6cf455a221 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -8,15 +8,14 @@ use crate::{ use alloy_primitives::{Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ - backend::{BlockchainDb, DatabaseResult, RevertSnapshotAction, StateSnapshot}, + backend::{BlockchainDb, DatabaseError, DatabaseResult, RevertSnapshotAction, StateSnapshot}, fork::database::ForkDbSnapshot, - revm::Database, + revm::{primitives::BlockEnv, Database}, }; +use revm::DatabaseRef; pub use foundry_evm::fork::database::ForkedDatabase; -use foundry_evm::revm::primitives::BlockEnv; -/// Implement the helper for the fork database impl Db for ForkedDatabase { fn insert_account(&mut self, address: Address, account: AccountInfo) { self.database_mut().insert_account(address, account) @@ -87,6 +86,10 @@ impl Db for ForkedDatabase { } impl MaybeFullDatabase for ForkedDatabase { + fn as_dyn(&self) -> &dyn DatabaseRef { + self + } + fn clear_into_snapshot(&mut self) -> StateSnapshot { let db = self.inner().db(); let accounts = std::mem::take(&mut *db.accounts.write()); @@ -118,6 +121,10 @@ impl MaybeFullDatabase for ForkedDatabase { } impl MaybeFullDatabase for ForkDbSnapshot { + fn as_dyn(&self) -> &dyn DatabaseRef { + self + } + fn clear_into_snapshot(&mut self) -> StateSnapshot { std::mem::take(&mut self.snapshot) } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 56cd3815cb08c..f984b93bbbcfc 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -104,6 +104,10 @@ impl Db for MemDb { } impl MaybeFullDatabase for MemDb { + fn as_dyn(&self) -> &dyn DatabaseRef { + self + } + fn maybe_as_full_db(&self) -> Option<&HashMap> { Some(&self.inner.accounts) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 53dc9898f073b..d8846b3b86f74 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -857,16 +857,19 @@ impl Backend { } /// Creates an EVM instance with optionally injected precompiles. - fn new_evm_with_inspector_ref( + #[allow(clippy::type_complexity)] + fn new_evm_with_inspector_ref<'i, 'db>( &self, - db: DB, + db: &'db dyn DatabaseRef, env: EnvWithHandlerCfg, - inspector: I, - ) -> revm::Evm<'_, I, WrapDatabaseRef> - where - DB: revm::DatabaseRef, - I: InspectorExt>, - { + inspector: &'i mut dyn InspectorExt< + WrapDatabaseRef<&'db dyn DatabaseRef>, + >, + ) -> revm::Evm< + '_, + &'i mut dyn InspectorExt>>, + WrapDatabaseRef<&'db dyn DatabaseRef>, + > { let mut evm = new_evm_with_inspector_ref(db, env, inspector); if let Some(factory) = &self.precompile_factory { inject_precompiles(&mut evm, factory.precompiles()); @@ -892,7 +895,7 @@ impl Backend { let db = self.db.read().await; let mut inspector = self.build_inspector(); - let mut evm = self.new_evm_with_inspector_ref(&**db, env, &mut inspector); + let mut evm = self.new_evm_with_inspector_ref(db.as_dyn(), env, &mut inspector); let ResultAndState { result, state } = evm.transact()?; let (exit_reason, gas_used, out, logs) = match result { ExecutionResult::Success { reason, gas_used, logs, output, .. } => { @@ -1011,7 +1014,7 @@ impl Backend { env.block.timestamp = U256::from(self.time.next_timestamp()); let executor = TransactionExecutor { - db: &mut *db, + db: &mut **db, validator: self, pending: pool_transactions.into_iter(), block_env: env.block.clone(), @@ -1151,10 +1154,10 @@ impl Backend { self.with_database_at(block_request, |state, block| { let block_number = block.number.to::(); let (exit, out, gas, state) = match overrides { - None => self.call_with_state(state, request, fee_details, block), + None => self.call_with_state(state.as_dyn(), request, fee_details, block), Some(overrides) => { let state = state::apply_state_override(overrides.into_iter().collect(), state)?; - self.call_with_state(state, request, fee_details, block) + self.call_with_state(state.as_dyn(), request, fee_details, block) }, }?; trace!(target: "backend", "call return {:?} out: {:?} gas {} on block {}", exit, out, gas, block_number); @@ -1263,16 +1266,13 @@ impl Backend { inspector } - pub fn call_with_state( + pub fn call_with_state( &self, - state: D, + state: &dyn DatabaseRef, request: WithOtherFields, fee_details: FeeDetails, block_env: BlockEnv, - ) -> Result<(InstructionResult, Option, u128, State), BlockchainError> - where - D: DatabaseRef, - { + ) -> Result<(InstructionResult, Option, u128, State), BlockchainError> { let mut inspector = self.build_inspector(); let env = self.build_call_env(request, fee_details, block_env); @@ -1319,8 +1319,11 @@ impl Backend { ); let env = self.build_call_env(request, fee_details, block); - let mut evm = - self.new_evm_with_inspector_ref(state, env, &mut inspector); + let mut evm = self.new_evm_with_inspector_ref( + state.as_dyn(), + env, + &mut inspector, + ); let ResultAndState { result, state: _ } = evm.transact()?; drop(evm); @@ -1352,7 +1355,7 @@ impl Backend { .with_tracing_config(TracingInspectorConfig::from_geth_config(&config)); let env = self.build_call_env(request, fee_details, block); - let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); + let mut evm = self.new_evm_with_inspector_ref(state.as_dyn(), env, &mut inspector); let ResultAndState { result, state: _ } = evm.transact()?; let (exit_reason, gas_used, out) = match result { @@ -1381,16 +1384,13 @@ impl Backend { .await? } - pub fn build_access_list_with_state( + pub fn build_access_list_with_state( &self, - state: D, + state: &dyn DatabaseRef, request: WithOtherFields, fee_details: FeeDetails, block_env: BlockEnv, - ) -> Result<(InstructionResult, Option, u64, AccessList), BlockchainError> - where - D: DatabaseRef, - { + ) -> Result<(InstructionResult, Option, u64, AccessList), BlockchainError> { let from = request.from.unwrap_or_default(); let to = if let Some(TxKind::Call(to)) = request.to { to @@ -1911,7 +1911,7 @@ impl Backend { let db = self.db.read().await; let block = self.env.read().block.clone(); - Ok(f(Box::new(&*db), block)) + Ok(f(Box::new(&**db), block)) } pub async fn storage_at( @@ -1937,17 +1937,14 @@ impl Backend { address: Address, block_request: Option, ) -> Result { - self.with_database_at(block_request, |db, _| self.get_code_with_state(db, address)).await? + self.with_database_at(block_request, |db, _| self.get_code_with_state(&db, address)).await? } - pub fn get_code_with_state( + pub fn get_code_with_state( &self, - state: D, + state: &dyn DatabaseRef, address: Address, - ) -> Result - where - D: DatabaseRef, - { + ) -> Result { trace!(target: "backend", "get code for {:?}", address); let account = state.basic_ref(address)?.unwrap_or_default(); if account.code_hash == KECCAK_EMPTY { diff --git a/crates/anvil/src/eth/backend/validate.rs b/crates/anvil/src/eth/backend/validate.rs index 650ce24a55010..eca3fd9e3bfe9 100644 --- a/crates/anvil/src/eth/backend/validate.rs +++ b/crates/anvil/src/eth/backend/validate.rs @@ -6,7 +6,6 @@ use foundry_evm::revm::primitives::{AccountInfo, EnvWithHandlerCfg}; /// A trait for validating transactions #[async_trait::async_trait] -#[auto_impl::auto_impl(&, Box)] pub trait TransactionValidator { /// Validates the transaction's validity when it comes to nonce, payment /// From 0380ca77515c27e7b92bf265b9bbeffe032faef9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:29:37 +0200 Subject: [PATCH 1472/1963] chore(doc): remove auto_impl (#8922) --- Cargo.lock | 1 - crates/doc/Cargo.toml | 1 - crates/doc/src/writer/as_doc.rs | 5 ++--- crates/doc/src/writer/buf_writer.rs | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8dc2fee52d52..5b6b19ac5f1ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3337,7 +3337,6 @@ name = "forge-doc" version = "0.2.0" dependencies = [ "alloy-primitives", - "auto_impl", "derive_more 1.0.0", "eyre", "forge-fmt", diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 0dcd407476c0d..3ebc7f8dac62b 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -20,7 +20,6 @@ foundry-config.workspace = true alloy-primitives.workspace = true -auto_impl.workspace = true derive_more.workspace = true eyre.workspace = true itertools.workspace = true diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index a21a59c1111c4..a14f9d3444715 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -14,7 +14,6 @@ use std::path::{Path, PathBuf}; pub type AsDocResult = Result; /// A trait for formatting a parse unit as documentation. -#[auto_impl::auto_impl(&)] pub trait AsDoc { /// Formats a parse tree item into a doc string. fn as_doc(&self) -> AsDocResult; @@ -224,7 +223,7 @@ impl AsDoc for Document { // TODO: cleanup // Write function docs writer.writeln_doc( - item.comments.exclude_tags(&[CommentTag::Param, CommentTag::Return]), + &item.comments.exclude_tags(&[CommentTag::Param, CommentTag::Return]), )?; // Write function header @@ -295,7 +294,7 @@ impl Document { writer.writeln()?; // Write function docs - writer.writeln_doc(comments.exclude_tags(&[CommentTag::Param, CommentTag::Return]))?; + writer.writeln_doc(&comments.exclude_tags(&[CommentTag::Param, CommentTag::Return]))?; // Write function header writer.write_code(code)?; diff --git a/crates/doc/src/writer/buf_writer.rs b/crates/doc/src/writer/buf_writer.rs index dfec68fe25cea..e6109c338c03f 100644 --- a/crates/doc/src/writer/buf_writer.rs +++ b/crates/doc/src/writer/buf_writer.rs @@ -43,7 +43,7 @@ impl BufWriter { } /// Write [AsDoc] implementation to the buffer with newline. - pub fn writeln_doc(&mut self, doc: T) -> fmt::Result { + pub fn writeln_doc(&mut self, doc: &T) -> fmt::Result { writeln!(self.buf, "{}", doc.as_doc()?) } From 1d2379a22a78d48a6f1a159868ca5978f31c5462 Mon Sep 17 00:00:00 2001 From: aganisgash Date: Sat, 21 Sep 2024 23:56:21 +0800 Subject: [PATCH 1473/1963] chore(docs): Update testcode path (#8923) Update testcode path --- testdata/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/testdata/README.md b/testdata/README.md index 566da52d136f1..5af60d647e17a 100644 --- a/testdata/README.md +++ b/testdata/README.md @@ -4,9 +4,9 @@ A test suite that tests different aspects of Foundry. ### Structure -- [`core`](core): Tests for fundamental aspects of Foundry -- [`logs`](logs): Tests for Foundry logging capabilities -- [`cheats`](cheats): Tests for Foundry cheatcodes -- [`fuzz`](fuzz): Tests for the Foundry fuzzer -- [`trace`](trace): Tests for the Foundry tracer -- [`fork`](fork): Tests for Foundry forking capabilities +- [`core`](default/core): Tests for fundamental aspects of Foundry +- [`logs`](default/logs): Tests for Foundry logging capabilities +- [`cheats`](default/cheats): Tests for Foundry cheatcodes +- [`fuzz`](default/fuzz): Tests for the Foundry fuzzer +- [`trace`](default/trace): Tests for the Foundry tracer +- [`fork`](default/fork): Tests for Foundry forking capabilities From cd1c77aa5db15b643b9e994e4f71c71f9b9a862f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 22 Sep 2024 11:37:37 +0200 Subject: [PATCH 1474/1963] chore(deps): weekly `cargo update` (#8927) --- Cargo.lock | 130 +++++++++++++++++++++-------------------------------- 1 file changed, 50 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b6b19ac5f1ba..a4621e5568cbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.31" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b68b94c159bcc2ca5f758b8663d7b00fc7c5e40569984595ddf2221b0f7f7f6e" +checksum = "805f7a974de5804f5c053edc6ca43b20883bdd3a733b3691200ae3a4b454a2db" dependencies = [ "num_enum", "serde", @@ -738,7 +738,7 @@ dependencies = [ "rustls 0.23.13", "serde_json", "tokio", - "tokio-tungstenite 0.23.1", + "tokio-tungstenite", "tracing", "ws_stream_wasm", ] @@ -1571,9 +1571,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" dependencies = [ "async-trait", "axum-core", @@ -1599,8 +1599,8 @@ dependencies = [ "sha1", "sync_wrapper 1.0.1", "tokio", - "tokio-tungstenite 0.21.0", - "tower 0.4.13", + "tokio-tungstenite", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -1608,9 +1608,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", "bytes", @@ -1621,7 +1621,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", "tracing", @@ -2029,9 +2029,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -2039,9 +2039,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -2054,9 +2054,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.28" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b378c786d3bde9442d2c6dd7e6080b2a818db2b96e30d6e7f1b6d224eb617d3" +checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" dependencies = [ "clap", ] @@ -2073,9 +2073,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -4016,9 +4016,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88cb03fc4bd87856fc4d0ad38fd067f85c7c6306bf794202fc50a897449837b" +checksum = "c3ab0b0379d1838fa1f0da521ffbbac168aaf113498ea8d6c9650195cadfa736" dependencies = [ "alloy-primitives", "alloy-provider", @@ -5282,9 +5282,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -6290,9 +6290,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", "thiserror", @@ -6301,9 +6301,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664d22978e2815783adbdd2c588b455b1bd625299ce36b2a99881ac9627e6d8d" +checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" dependencies = [ "pest", "pest_generator", @@ -6311,9 +6311,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d5487022d5d33f4c30d91c22afa240ce2a644e87fe08caad974d4eab6badbe" +checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" dependencies = [ "pest", "pest_meta", @@ -6324,9 +6324,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.12" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0091754bbd0ea592c4deb3a122ce8ecbb0753b738aa82bc055fcc2eccc8d8174" +checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" dependencies = [ "once_cell", "pest", @@ -6522,9 +6522,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" [[package]] name = "powerfmt" @@ -6747,9 +6747,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", "prost-derive", @@ -6757,9 +6757,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", "itertools 0.13.0", @@ -6770,9 +6770,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60caa6738c7369b940c3d49246a8d1749323674c65cb13010134f5c9bad5b519" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ "prost", ] @@ -6830,7 +6830,7 @@ dependencies = [ "chrono", "indexmap 2.5.0", "newtype-uuid", - "quick-xml 0.36.1", + "quick-xml 0.36.2", "strip-ansi-escapes", "thiserror", "uuid 1.10.0", @@ -6856,9 +6856,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.36.1" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" +checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" dependencies = [ "memchr", ] @@ -7194,7 +7194,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f73010c271d53fa7904e9845338e95f3955eb1200a0355e0abfdb89c41aaa9cd" dependencies = [ "aurora-engine-modexp", - "blst", "c-kzg", "cfg-if", "k256", @@ -7755,9 +7754,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -8640,18 +8639,6 @@ dependencies = [ "tokio-util", ] -[[package]] -name = "tokio-tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.21.0", -] - [[package]] name = "tokio-tungstenite" version = "0.23.1" @@ -8664,7 +8651,7 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", - "tungstenite 0.23.0", + "tungstenite", "webpki-roots", ] @@ -8794,8 +8781,10 @@ dependencies = [ "futures-util", "pin-project-lite", "sync_wrapper 0.1.2", + "tokio", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -8970,25 +8959,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.23.0" @@ -9103,15 +9073,15 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "untrusted" From a592f7a9b93c7cc099341e6e9dfee3f2bb0b8748 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:52:20 +0200 Subject: [PATCH 1475/1963] chore: don't display filter used if empty (#8929) --- crates/forge/bin/cmd/test/mod.rs | 16 +++++++++++++--- crates/forge/tests/cli/test_cmd.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index ac0d706910696..47a4bd075c026 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -494,11 +494,21 @@ impl TestArgs { self.flamechart) && num_filtered != 1 { + let action = if self.flamegraph { + "generate a flamegraph" + } else if self.flamechart { + "generate a flamechart" + } else { + "run the debugger" + }; + let filter = if filter.is_empty() { + String::new() + } else { + format!("\n\nFilter used:\n{filter}") + }; eyre::bail!( "{num_filtered} tests matched your criteria, but exactly 1 test must match in order to {action}.\n\n\ - Use --match-contract and --match-path to further limit the search.\n\ - Filter used:\n{filter}", - action = if self.flamegraph {"generate a flamegraph"} else if self.flamechart {"generate a flamechart"} else {"run the debugger"}, + Use --match-contract and --match-path to further limit the search.{filter}", ); } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index acfec46c6bf54..c3a5a548ab37e 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2174,3 +2174,31 @@ Warning: the following cheatcode(s) are deprecated and will be removed in future "#]]); } ); + +forgetest_init!(requires_single_test, |prj, cmd| { + cmd.args(["test", "--debug", "test"]).assert_failure().stderr_eq(str![[r#" +Error: +2 tests matched your criteria, but exactly 1 test must match in order to run the debugger. + +Use --match-contract and --match-path to further limit the search. + +Filter used: + match-test: `test` + + +"#]]); + cmd.forge_fuse().args(["test", "--flamegraph"]).assert_failure().stderr_eq(str![[r#" +Error: +2 tests matched your criteria, but exactly 1 test must match in order to generate a flamegraph. + +Use --match-contract and --match-path to further limit the search. + +"#]]); + cmd.forge_fuse().args(["test", "--flamechart"]).assert_failure().stderr_eq(str![[r#" +Error: +2 tests matched your criteria, but exactly 1 test must match in order to generate a flamechart. + +Use --match-contract and --match-path to further limit the search. + +"#]]); +}); From dab903633e4f01db8c604655bfe3c03a893c0827 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 23 Sep 2024 02:40:38 +0200 Subject: [PATCH 1476/1963] chore: use serde_json::from_str when possible (#8925) chore: use serde_json::from_str when possible --- crates/chisel/src/dispatcher.rs | 3 +-- crates/common/src/fs.rs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 6afa7ccb9f537..0f2b7afe38b6a 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -514,8 +514,7 @@ impl ChiselDispatcher { let json = response.json::().await.unwrap(); if json.status == "1" && json.result.is_some() { let abi = json.result.unwrap(); - let abi: serde_json::Result = - serde_json::from_slice(abi.as_bytes()); + let abi: serde_json::Result = serde_json::from_str(&abi); if let Ok(abi) = abi { let mut interface = format!( "// Interface of {}\ninterface {} {{\n", diff --git a/crates/common/src/fs.rs b/crates/common/src/fs.rs index 8ee47d2fd2a06..45c21eba69e2e 100644 --- a/crates/common/src/fs.rs +++ b/crates/common/src/fs.rs @@ -43,9 +43,8 @@ pub fn read_to_string(path: impl AsRef) -> Result { pub fn read_json_file(path: &Path) -> Result { // read the file into a byte array first // https://github.com/serde-rs/json/issues/160 - let bytes = read(path)?; - serde_json::from_slice(&bytes) - .map_err(|source| FsPathError::ReadJson { source, path: path.into() }) + let s = read_to_string(path)?; + serde_json::from_str(&s).map_err(|source| FsPathError::ReadJson { source, path: path.into() }) } /// Writes the object as a JSON object. From cba6e97fcdaedc2aad5c3b25f32be20ec2068e87 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 23 Sep 2024 03:20:29 +0200 Subject: [PATCH 1477/1963] chore: deprecate --debug regex argument (#8930) * chore: deprecate --debug regex argument * fix: enable full internal decoding if exactly one test matched --- crates/evm/traces/src/folded_stack_trace.rs | 13 +-- crates/forge/bin/cmd/test/mod.rs | 98 ++++++++------------- crates/forge/tests/cli/test_cmd.rs | 13 +-- 3 files changed, 52 insertions(+), 72 deletions(-) diff --git a/crates/evm/traces/src/folded_stack_trace.rs b/crates/evm/traces/src/folded_stack_trace.rs index de76f8e804085..ee3a05afad29d 100644 --- a/crates/evm/traces/src/folded_stack_trace.rs +++ b/crates/evm/traces/src/folded_stack_trace.rs @@ -30,14 +30,13 @@ impl EvmFoldedStackTraceBuilder { let node = &nodes[idx]; let func_name = if node.trace.kind.is_any_create() { - let default_contract_name = "Contract".to_string(); - let contract_name = node.trace.decoded.label.as_ref().unwrap_or(&default_contract_name); + let contract_name = node.trace.decoded.label.as_deref().unwrap_or("Contract"); format!("new {contract_name}") } else { let selector = node .selector() .map(|selector| selector.encode_hex_with_prefix()) - .unwrap_or("fallback".to_string()); + .unwrap_or_else(|| "fallback".to_string()); let signature = node.trace.decoded.call_data.as_ref().map(|dc| &dc.signature).unwrap_or(&selector); @@ -114,9 +113,11 @@ impl EvmFoldedStackTraceBuilder { /// Helps to translate a function enter-exit flow into a folded stack trace. /// /// Example: -/// fn top() { child_a(); child_b() } // consumes 500 gas -/// fn child_a() {} // consumes 100 gas -/// fn child_b() {} // consumes 200 gas +/// ```solidity +/// function top() { child_a(); child_b() } // consumes 500 gas +/// function child_a() {} // consumes 100 gas +/// function child_b() {} // consumes 200 gas +/// ``` /// /// For execution of the `top` function looks like: /// 1. enter `top` diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 47a4bd075c026..0eebbb9a0ee7a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -20,7 +20,7 @@ use foundry_cli::{ opts::CoreBuildArgs, utils::{self, LoadConfig}, }; -use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell}; +use foundry_common::{cli_warn, compile::ProjectCompiler, evm::EvmArgs, fs, shell}; use foundry_compilers::{ artifacts::output_selection::OutputSelection, compilers::{multi::MultiCompilerLanguage, CompilerSettings, Language}, @@ -67,29 +67,20 @@ pub struct TestArgs { #[arg(value_hint = ValueHint::FilePath)] pub path: Option, - /// Run a test in the debugger. - /// - /// The argument passed to this flag is the **regex** of the test function signature you want - /// to run, and it works the same as --match-test. - /// - /// If more than one test matches your specified criteria, you must add additional filters - /// until only one test is found (see --match-contract and --match-path). + /// Run a single test in the debugger. /// /// The matching test will be opened in the debugger regardless of the outcome of the test. /// /// If the matching test is a fuzz test, then it will open the debugger on the first failure - /// case. - /// If the fuzz test does not fail, it will open the debugger on the last fuzz case. - /// - /// For more fine-grained control of which fuzz case is run, see forge run. - #[arg(long, value_name = "TEST_FUNCTION")] - debug: Option, + /// case. If the fuzz test does not fail, it will open the debugger on the last fuzz case. + #[arg(long, value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] + debug: Option>, /// Generate a flamegraph for a single test. Implies `--decode-internal`. /// /// A flame graph is used to visualize which functions or operations within the smart contract /// are consuming the most gas overall in a sorted manner. - #[arg(long, conflicts_with = "flamechart")] + #[arg(long)] flamegraph: bool, /// Generate a flamechart for a single test. Implies `--decode-internal`. @@ -99,18 +90,13 @@ pub struct TestArgs { #[arg(long, conflicts_with = "flamegraph")] flamechart: bool, - /// Whether to identify internal functions in traces. + /// Identify internal functions in traces. /// - /// If no argument is passed to this flag, it will trace internal functions scope and decode - /// stack parameters, but parameters stored in memory (such as bytes or arrays) will not be - /// decoded. + /// This will trace internal functions and decode stack parameters. /// - /// To decode memory parameters, you should pass an argument with a test function name, - /// similarly to --debug and --match-test. - /// - /// If more than one test matches your specified criteria, you must add additional filters - /// until only one test is found (see --match-contract and --match-path). - #[arg(long, value_name = "TEST_FUNCTION")] + /// Parameters stored in memory (such as bytes or arrays) are currently decoded only when a + /// single function is matched, similarly to `--debug`, for performance reasons. + #[arg(long, value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] decode_internal: Option>, /// Print a gas report. @@ -342,19 +328,15 @@ impl TestArgs { let env = evm_opts.evm_env().await?; // Enable internal tracing for more informative flamegraph. - if should_draw { + if should_draw && self.decode_internal.is_none() { self.decode_internal = Some(None); } // Choose the internal function tracing mode, if --decode-internal is provided. - let decode_internal = if let Some(maybe_fn) = self.decode_internal.as_ref() { - if maybe_fn.is_some() { - // If function filter is provided, we enable full tracing. - InternalTraceMode::Full - } else { - // If no function filter is provided, we enable simple tracing. - InternalTraceMode::Simple - } + let decode_internal = if self.decode_internal.is_some() { + // If more than one function matched, we enable simple tracing. + // If only one function matched, we enable full tracing. This is done in `run_tests`. + InternalTraceMode::Simple } else { InternalTraceMode::None }; @@ -373,13 +355,18 @@ impl TestArgs { .alphanet(evm_opts.alphanet) .build(project_root, &output, env, evm_opts)?; - let mut maybe_override_mt = |flag, maybe_regex: Option<&Regex>| { - if let Some(regex) = maybe_regex { + let mut maybe_override_mt = |flag, maybe_regex: Option<&Option>| { + if let Some(Some(regex)) = maybe_regex { + cli_warn!( + "specifying argument for --{flag} is deprecated and will be removed in the future, \ + use --match-test instead" + ); + let test_pattern = &mut filter.args_mut().test_pattern; if test_pattern.is_some() { eyre::bail!( "Cannot specify both --{flag} and --match-test. \ - Use --match-contract and --match-path to further limit the search instead." + Use --match-contract and --match-path to further limit the search instead." ); } *test_pattern = Some(regex.clone()); @@ -387,12 +374,8 @@ impl TestArgs { Ok(()) }; - maybe_override_mt("debug", self.debug.as_ref())?; - maybe_override_mt( - "decode-internal", - self.decode_internal.as_ref().and_then(|v| v.as_ref()), - )?; + maybe_override_mt("decode-internal", self.decode_internal.as_ref())?; let libraries = runner.libraries.clone(); let mut outcome = self.run_tests(runner, config, verbosity, &filter, &output).await?; @@ -401,18 +384,10 @@ impl TestArgs { let (suite_name, test_name, mut test_result) = outcome.remove_first().ok_or_eyre("no tests were executed")?; - let arena = test_result + let (_, arena) = test_result .traces .iter_mut() - .find_map( - |(kind, arena)| { - if *kind == TraceKind::Execution { - Some(arena) - } else { - None - } - }, - ) + .find(|(kind, _)| *kind == TraceKind::Execution) .unwrap(); // Decode traces. @@ -425,6 +400,7 @@ impl TestArgs { let test_name = test_name.trim_end_matches("()"); let file_name = format!("cache/{label}_{contract}_{test_name}.svg"); let file = std::fs::File::create(&file_name).wrap_err("failed to create file")?; + let file = std::io::BufWriter::new(file); let mut options = inferno::flamegraph::Options::default(); options.title = format!("{label} {contract}::{test_name}"); @@ -435,13 +411,13 @@ impl TestArgs { } // Generate SVG. - inferno::flamegraph::from_lines(&mut options, fst.iter().map(|s| s.as_str()), file) + inferno::flamegraph::from_lines(&mut options, fst.iter().map(String::as_str), file) .wrap_err("failed to write svg")?; println!("\nSaved to {file_name}"); // Open SVG in default program. - if opener::open(&file_name).is_err() { - println!("\nFailed to open {file_name}. Please open it manually."); + if let Err(e) = opener::open(&file_name) { + eprintln!("\nFailed to open {file_name}; please open it manually: {e}"); } } @@ -488,12 +464,7 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); let num_filtered = runner.matching_test_functions(filter).count(); - if (self.debug.is_some() || - self.decode_internal.as_ref().map_or(false, |v| v.is_some()) || - self.flamegraph || - self.flamechart) && - num_filtered != 1 - { + if num_filtered != 1 && (self.debug.is_some() || self.flamegraph || self.flamechart) { let action = if self.flamegraph { "generate a flamegraph" } else if self.flamechart { @@ -512,6 +483,11 @@ impl TestArgs { ); } + // If exactly one test matched, we enable full tracing. + if num_filtered == 1 && self.decode_internal.is_some() { + runner.decode_internal = InternalTraceMode::Full; + } + if self.json { let results = runner.test_collect(filter); println!("{}", serde_json::to_string(&results)?); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index c3a5a548ab37e..63a4a92106994 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2176,16 +2176,12 @@ Warning: the following cheatcode(s) are deprecated and will be removed in future ); forgetest_init!(requires_single_test, |prj, cmd| { - cmd.args(["test", "--debug", "test"]).assert_failure().stderr_eq(str![[r#" + cmd.args(["test", "--debug"]).assert_failure().stderr_eq(str![[r#" Error: 2 tests matched your criteria, but exactly 1 test must match in order to run the debugger. Use --match-contract and --match-path to further limit the search. -Filter used: - match-test: `test` - - "#]]); cmd.forge_fuse().args(["test", "--flamegraph"]).assert_failure().stderr_eq(str![[r#" Error: @@ -2202,3 +2198,10 @@ Use --match-contract and --match-path to further limit the search. "#]]); }); + +forgetest_init!(deprecated_regex_arg, |prj, cmd| { + cmd.args(["test", "--decode-internal", "test_Increment"]).assert_success().stderr_eq(str![[r#" +warning: specifying argument for --decode-internal is deprecated and will be removed in the future, use --match-test instead + +"#]]); +}); From 07a1f67114565968b188d1abf42fe2c5c57bfca5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 23 Sep 2024 20:29:26 +0300 Subject: [PATCH 1478/1963] chore: fixes for --all-features tests (#8937) --- crates/cast/tests/cli/main.rs | 6 ++++++ crates/forge/tests/it/inline.rs | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 01fdaef867d42..a93d30c9193b0 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -702,6 +702,8 @@ to 0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59c "#]]); + let rpc = next_http_rpc_endpoint(); + // cmd.cast_fuse() .args([ @@ -879,6 +881,8 @@ casttest!(mktx_requires_to, |_prj, cmd| { "mktx", "--private-key", "0x0000000000000000000000000000000000000000000000000000000000000001", + "--chain", + "1", ]); cmd.assert_failure().stderr_eq(str![[r#" Error: @@ -967,6 +971,8 @@ casttest!(send_requires_to, |_prj, cmd| { "send", "--private-key", "0x0000000000000000000000000000000000000000000000000000000000000001", + "--chain", + "1", ]); cmd.assert_failure().stderr_eq(str![[r#" Error: diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index ed7729f7f9d8d..4448f982dcd3c 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -1,6 +1,6 @@ //! Inline configuration tests. -use crate::test_helpers::TEST_DATA_DEFAULT; +use crate::test_helpers::{ForgeTestData, ForgeTestProfile, TEST_DATA_DEFAULT}; use forge::{result::TestKind, TestOptionsBuilder}; use foundry_config::{FuzzConfig, InvariantConfig}; use foundry_test_utils::Filter; @@ -8,7 +8,8 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); + // Fresh runner to make sure there's no persisted failure from previous tests. + let mut runner = ForgeTestData::new(ForgeTestProfile::Default).runner(); let result = runner.test_collect(&filter); let results = result .into_iter() From 232e6c795a0307e6ca4f3fbe95abab66874a429b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:59:23 +0300 Subject: [PATCH 1479/1963] chore: more fixes for --all-features tests (#8946) --- crates/anvil/tests/it/anvil_api.rs | 6 +++++- crates/anvil/tests/it/gas.rs | 6 +++++- crates/anvil/tests/it/proof.rs | 6 +++++- crates/anvil/tests/it/traces.rs | 6 +++++- crates/cast/tests/cli/main.rs | 1 + crates/forge/tests/cli/config.rs | 3 +++ crates/forge/tests/cli/verify_bytecode.rs | 1 + 7 files changed, 25 insertions(+), 4 deletions(-) diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 0e8001853a95f..8038023130db2 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -667,7 +667,7 @@ async fn can_remove_pool_transactions() { #[tokio::test(flavor = "multi_thread")] async fn test_reorg() { - let (api, handle) = spawn(NodeConfig::test()).await; + let (api, mut handle) = spawn(NodeConfig::test()).await; let provider = handle.ws_provider(); let accounts = handle.dev_wallets().collect::>(); @@ -792,4 +792,8 @@ async fn test_reorg() { }) .await; assert!(res.is_err()); + + if let Some(signal) = handle.shutdown_signal_mut().take() { + signal.fire().unwrap(); + } } diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index ae9c9c201eced..be9f206d730c4 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -175,7 +175,7 @@ async fn test_tip_above_fee_cap() { #[tokio::test(flavor = "multi_thread")] async fn test_can_use_fee_history() { let base_fee = 50u128; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; + let (_api, mut handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; let provider = handle.http_provider(); for _ in 0..10 { @@ -200,4 +200,8 @@ async fn test_can_use_fee_history() { assert_eq!(latest_block.header.base_fee_per_gas.unwrap(), *latest_fee_history_fee); assert_eq!(latest_fee_history_fee, next_base_fee); } + + if let Some(signal) = handle.shutdown_signal_mut().take() { + signal.fire().unwrap(); + } } diff --git a/crates/anvil/tests/it/proof.rs b/crates/anvil/tests/it/proof.rs index 757d36082696d..33c51b2e0b473 100644 --- a/crates/anvil/tests/it/proof.rs +++ b/crates/anvil/tests/it/proof.rs @@ -122,7 +122,7 @@ async fn test_storage_proof() { #[tokio::test(flavor = "multi_thread")] async fn can_get_random_account_proofs() { - let (api, _handle) = spawn(NodeConfig::test()).await; + let (api, mut handle) = spawn(NodeConfig::test()).await; for acc in std::iter::repeat_with(Address::random).take(10) { let _ = api @@ -130,4 +130,8 @@ async fn can_get_random_account_proofs() { .await .unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}")); } + + if let Some(signal) = handle.shutdown_signal_mut().take() { + signal.fire().unwrap(); + } } diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index aaa2ca298d142..9ab3045412c57 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -722,7 +722,7 @@ async fn test_trace_address_fork2() { #[tokio::test(flavor = "multi_thread")] async fn test_trace_filter() { - let (api, handle) = spawn(NodeConfig::test()).await; + let (api, mut handle) = spawn(NodeConfig::test()).await; let provider = handle.ws_provider(); let accounts = handle.dev_wallets().collect::>(); @@ -859,4 +859,8 @@ async fn test_trace_filter() { let traces = api.trace_filter(tracer).await.unwrap(); assert_eq!(traces.len(), 5); + + if let Some(signal) = handle.shutdown_signal_mut().take() { + signal.fire().unwrap(); + } } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index a93d30c9193b0..8c928b3a8a535 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1022,6 +1022,7 @@ casttest!(storage, |_prj, cmd| { "#]]); + let rpc = next_http_rpc_endpoint(); cmd.cast_fuse() .args(["storage", usdt, total_supply_slot, "--rpc-url", &rpc, "--block", block_after]) .assert_success() diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 1ddd402722dd4..3d3feba6766b8 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -205,6 +205,7 @@ forgetest_init!(can_override_config, |prj, cmd| { ); // env vars work + std::env::remove_var("DAPP_REMAPPINGS"); std::env::set_var("DAPP_REMAPPINGS", "ds-test/=lib/forge-std/lib/ds-test/from-env/"); let config = forge_utils::load_config_with_root(Some(prj.root())); assert_eq!( @@ -517,6 +518,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { ); // create a new lib directly in the `lib` folder with a remapping + std::env::remove_var("DAPP_REMAPPINGS"); let mut config = config; config.remappings = vec![Remapping::from_str("nested/=lib/nested").unwrap().into()]; let nested = prj.paths().libraries[0].join("nested-lib"); @@ -524,6 +526,7 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let toml_file = nested.join("foundry.toml"); pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); + std::env::remove_var("DAPP_REMAPPINGS"); let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); similar_asserts::assert_eq!( diff --git a/crates/forge/tests/cli/verify_bytecode.rs b/crates/forge/tests/cli/verify_bytecode.rs index 7e615b5659ddc..398ecb52d353f 100644 --- a/crates/forge/tests/cli/verify_bytecode.rs +++ b/crates/forge/tests/cli/verify_bytecode.rs @@ -33,6 +33,7 @@ fn test_verify_bytecode( prj.add_source(contract_name, &source_code).unwrap(); prj.write_config(config); + let etherscan_key = next_mainnet_etherscan_api_key(); let mut args = vec![ "verify-bytecode", addr, From c9d7b48fb0cdddc33c61db82fc3a94dd7e602c9e Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:32:01 +0530 Subject: [PATCH 1480/1963] fix(`anvil`): handle OP deposit txs in `TypedTransaction` and `PoolTransaction` conversion (#8942) * fix(`anvil`): handle OP deposit tx in TypeTransaction conversion. * nits * clippy * test Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> * nits --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/anvil/core/src/eth/transaction/mod.rs | 36 ++++++++++++++++++-- crates/anvil/src/config.rs | 5 +-- crates/anvil/src/eth/pool/transactions.rs | 5 +-- crates/anvil/tests/it/fork.rs | 20 +++++++++++ 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 128f6e9cd888f..463c3de13fe7c 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1003,11 +1003,41 @@ impl TypedTransaction { } } -impl TryFrom for TypedTransaction { +impl TryFrom> for TypedTransaction { type Error = ConversionError; - fn try_from(tx: RpcTransaction) -> Result { - // TODO(sergerad): Handle Arbitrum system transactions? + fn try_from(tx: WithOtherFields) -> Result { + if tx.transaction_type.is_some_and(|t| t == 0x7E) { + let mint = tx + .other + .get_deserialized::("mint") + .ok_or(ConversionError::Custom("MissingMint".to_string()))? + .map_err(|_| ConversionError::Custom("Cannot deserialize mint".to_string()))?; + + let source_hash = tx + .other + .get_deserialized::("sourceHash") + .ok_or(ConversionError::Custom("MissingSourceHash".to_string()))? + .map_err(|_| { + ConversionError::Custom("Cannot deserialize source hash".to_string()) + })?; + + let deposit = DepositTransaction { + nonce: tx.nonce, + is_system_tx: true, + from: tx.from, + kind: tx.to.map(TxKind::Call).unwrap_or(TxKind::Create), + value: tx.value, + gas_limit: tx.gas, + input: tx.input.clone(), + mint, + source_hash, + }; + + return Ok(Self::Deposit(deposit)); + } + + let tx = tx.inner; match tx.transaction_type.unwrap_or_default().try_into()? { TxType::Legacy => { let legacy = TxLegacy { diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index cafdf1695a3bc..fd26e1ffd8849 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1300,8 +1300,9 @@ async fn derive_block_and_transactions( // Convert the transactions to PoolTransactions let force_transactions = filtered_transactions .iter() - .map(|&transaction| PoolTransaction::try_from(transaction.clone().inner)) - .collect::, _>>()?; + .map(|&transaction| PoolTransaction::try_from(transaction.clone())) + .collect::, _>>() + .map_err(|e| eyre::eyre!("Err converting to pool transactions {e}"))?; Ok((transaction_block_number.saturating_sub(1), Some(force_transactions))) } } diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index f0987572ba0ff..a1b7beb680628 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -1,6 +1,7 @@ use crate::eth::{error::PoolError, util::hex_fmt_many}; use alloy_primitives::{Address, TxHash}; use alloy_rpc_types::Transaction as RpcTransaction; +use alloy_serde::WithOtherFields; use anvil_core::eth::transaction::{PendingTransaction, TypedTransaction}; use parking_lot::RwLock; use std::{ @@ -116,9 +117,9 @@ impl fmt::Debug for PoolTransaction { } } -impl TryFrom for PoolTransaction { +impl TryFrom> for PoolTransaction { type Error = eyre::Error; - fn try_from(transaction: RpcTransaction) -> Result { + fn try_from(transaction: WithOtherFields) -> Result { let typed_transaction = TypedTransaction::try_from(transaction)?; let pending_transaction = PendingTransaction::new(typed_transaction)?; Ok(Self { diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index ad2ed1e04bbb5..0d1c4f82479fa 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -166,6 +166,26 @@ async fn test_fork_eth_get_nonce() { assert_eq!(api_nonce, provider_nonce); } +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_optimism_with_transaction_hash() { + use std::str::FromStr; + + // Fork to a block with a specific transaction + let fork_tx_hash = + TxHash::from_str("fcb864b5a50f0f0b111dbbf9e9167b2cb6179dfd6270e1ad53aac6049c0ec038") + .unwrap(); + let (api, _handle) = spawn( + NodeConfig::test() + .with_eth_rpc_url(Some(rpc::next_rpc_endpoint(NamedChain::Optimism))) + .with_fork_transaction_hash(Some(fork_tx_hash)), + ) + .await; + + // Make sure the fork starts from previous block + let block_number = api.block_number().unwrap().to::(); + assert_eq!(block_number, 125777954 - 1); +} + #[tokio::test(flavor = "multi_thread")] async fn test_fork_eth_fee_history() { let (api, handle) = spawn(fork_config()).await; From df2203cbb7c7945025c80a46b167b5a4fd118e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20=C5=BBuk?= Date: Tue, 24 Sep 2024 15:09:18 +0200 Subject: [PATCH 1481/1963] feat(cast): add contract creation bytecodes to traces (#8941) --- Cargo.lock | 8 ++++---- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/run.rs | 11 ++++++++++- crates/cli/src/utils/cmd.rs | 14 ++++++++++---- crates/evm/traces/src/lib.rs | 10 +++++++++- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4621e5568cbd..f2c3d9e68ebc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6762,7 +6762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.77", @@ -7161,9 +7161,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48294aab02ed5d1940ad9b06f2a3230c3f0d98db6eacd618878cf143e204f6b0" +checksum = "b57b33a24b5b8b8efa1da3f60d44f02d6e649f06ef925d7780723ff14ff55321" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -9430,7 +9430,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]] diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 5b1e1ff65fc11..9afc7ff5ae35e 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -200,7 +200,7 @@ impl CallArgs { ), }; - handle_traces(trace, &config, chain, labels, debug, decode_internal).await?; + handle_traces(trace, &config, chain, labels, debug, decode_internal, false).await?; return Ok(()); } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index b67c0ed1188ae..7d7c922b4b6d5 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -242,7 +242,16 @@ impl RunArgs { } }; - handle_traces(result, &config, chain, self.label, self.debug, self.decode_internal).await?; + handle_traces( + result, + &config, + chain, + self.label, + self.debug, + self.decode_internal, + self.verbose, + ) + .await?; Ok(()) } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 1e4af95dfdf55..8a4bff7294101 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -17,7 +17,8 @@ use foundry_evm::{ debug::DebugTraceIdentifier, decode_trace_arena, identifier::{EtherscanIdentifier, SignaturesIdentifier}, - render_trace_arena, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, + render_trace_arena_with_bytecodes, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, + Traces, }, }; use std::{ @@ -361,6 +362,7 @@ pub async fn handle_traces( labels: Vec, debug: bool, decode_internal: bool, + verbose: bool, ) -> Result<()> { let labels = labels.iter().filter_map(|label_str| { let mut iter = label_str.split(':'); @@ -410,19 +412,23 @@ pub async fn handle_traces( .build(); debugger.try_run()?; } else { - print_traces(&mut result, &decoder).await?; + print_traces(&mut result, &decoder, verbose).await?; } Ok(()) } -pub async fn print_traces(result: &mut TraceResult, decoder: &CallTraceDecoder) -> Result<()> { +pub async fn print_traces( + result: &mut TraceResult, + decoder: &CallTraceDecoder, + verbose: bool, +) -> Result<()> { let traces = result.traces.as_mut().expect("No traces found"); println!("Traces:"); for (_, arena) in traces { decode_trace_arena(arena, decoder).await?; - println!("{}", render_trace_arena(arena)); + println!("{}", render_trace_arena_with_bytecodes(arena, verbose)); } println!(); diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index fb1665a5a6cd1..382e3d3ec0511 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -178,7 +178,15 @@ pub async fn decode_trace_arena( /// Render a collection of call traces to a string. pub fn render_trace_arena(arena: &SparsedTraceArena) -> String { - let mut w = TraceWriter::new(Vec::::new()); + render_trace_arena_with_bytecodes(arena, false) +} + +/// Render a collection of call traces to a string optionally including contract creation bytecodes. +pub fn render_trace_arena_with_bytecodes( + arena: &SparsedTraceArena, + with_bytecodes: bool, +) -> String { + let mut w = TraceWriter::new(Vec::::new()).write_bytecodes(with_bytecodes); w.write_arena(&arena.resolve_arena()).expect("Failed to write traces"); String::from_utf8(w.into_writer()).expect("trace writer wrote invalid UTF-8") } From 81fb0f60cc9f65c79eadbf50dd4b9e4907c522f7 Mon Sep 17 00:00:00 2001 From: N Date: Tue, 24 Sep 2024 09:38:37 -0400 Subject: [PATCH 1482/1963] fix: #8759, default (low) gas limit set even when disabled, use custom gas_limit on forks (#8933) * fix: #8759, do not set low gas price on block if disabled, use custom gas price in forks * test(fix): default block gas limit for large mine test * fix fmt * fix: optional gas_limit in as_json * fix: use option not serde_json::Value::Null * tests: base tests + config tests * fix: nits * fix: comment --- crates/anvil/src/config.rs | 80 ++++++++++++++++++------- crates/anvil/src/eth/backend/mem/mod.rs | 6 +- crates/anvil/src/lib.rs | 4 +- crates/anvil/tests/it/fork.rs | 56 ++++++++++++++++- crates/anvil/tests/it/gas.rs | 17 +++++- crates/anvil/tests/it/transaction.rs | 4 +- crates/test-utils/src/rpc.rs | 4 ++ 7 files changed, 143 insertions(+), 28 deletions(-) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index fd26e1ffd8849..61ab278d0cd60 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -19,7 +19,8 @@ use alloy_genesis::Genesis; use alloy_network::AnyNetwork; use alloy_primitives::{hex, utils::Unit, BlockNumber, TxHash, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{BlockNumberOrTag, Transaction}; +use alloy_rpc_types::{Block, BlockNumberOrTag, Transaction}; +use alloy_serde::WithOtherFields; use alloy_signer::Signer; use alloy_signer_local::{ coins_bip39::{English, Mnemonic}, @@ -59,6 +60,8 @@ use yansi::Paint; pub const NODE_PORT: u16 = 8545; /// Default chain id of the node pub const CHAIN_ID: u64 = 31337; +/// The default gas limit for all transactions +pub const DEFAULT_GAS_LIMIT: u128 = 30_000_000; /// Default mnemonic for dev accounts pub const DEFAULT_MNEMONIC: &str = "test test test test test test test test test test test junk"; @@ -90,7 +93,7 @@ pub struct NodeConfig { /// Chain ID of the EVM chain pub chain_id: Option, /// Default gas limit for all txs - pub gas_limit: u128, + pub gas_limit: Option, /// If set to `true`, disables the block gas limit pub disable_block_gas_limit: bool, /// Default gas price for all txs @@ -303,7 +306,20 @@ Gas Limit {} "#, - self.gas_limit.green() + { + if self.disable_block_gas_limit { + "Disabled".to_string() + } else { + self.gas_limit.map(|l| l.to_string()).unwrap_or_else(|| { + if self.fork_choice.is_some() { + "Forked".to_string() + } else { + DEFAULT_GAS_LIMIT.to_string() + } + }) + } + } + .green() ); let _ = write!( @@ -338,6 +354,13 @@ Genesis Timestamp wallet_description.insert("mnemonic".to_string(), phrase); }; + let gas_limit = match self.gas_limit { + // if we have a disabled flag we should max out the limit + Some(_) | None if self.disable_block_gas_limit => Some(u64::MAX.to_string()), + Some(limit) => Some(limit.to_string()), + _ => None, + }; + if let Some(fork) = fork { json!({ "available_accounts": available_accounts, @@ -349,7 +372,7 @@ Genesis Timestamp "wallet": wallet_description, "base_fee": format!("{}", self.get_base_fee()), "gas_price": format!("{}", self.get_gas_price()), - "gas_limit": format!("{}", self.gas_limit), + "gas_limit": gas_limit, }) } else { json!({ @@ -358,7 +381,7 @@ Genesis Timestamp "wallet": wallet_description, "base_fee": format!("{}", self.get_base_fee()), "gas_price": format!("{}", self.get_gas_price()), - "gas_limit": format!("{}", self.gas_limit), + "gas_limit": gas_limit, "genesis_timestamp": format!("{}", self.get_genesis_timestamp()), }) } @@ -390,7 +413,7 @@ impl Default for NodeConfig { let genesis_accounts = AccountGenerator::new(10).phrase(DEFAULT_MNEMONIC).gen(); Self { chain_id: None, - gas_limit: 30_000_000, + gas_limit: None, disable_block_gas_limit: false, gas_price: None, hardfork: None, @@ -546,9 +569,7 @@ impl NodeConfig { /// Sets the gas limit #[must_use] pub fn with_gas_limit(mut self, gas_limit: Option) -> Self { - if let Some(gas_limit) = gas_limit { - self.gas_limit = gas_limit; - } + self.gas_limit = gas_limit; self } @@ -962,7 +983,7 @@ impl NodeConfig { let env = revm::primitives::Env { cfg: cfg.cfg_env, block: BlockEnv { - gas_limit: U256::from(self.gas_limit), + gas_limit: U256::from(self.gas_limit()), basefee: U256::from(self.get_base_fee()), ..Default::default() }, @@ -1140,15 +1161,7 @@ latest block number: {latest_block}" panic!("Failed to get block for block number: {fork_block_number}") }; - // we only use the gas limit value of the block if it is non-zero and the block gas - // limit is enabled, since there are networks where this is not used and is always - // `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also - let gas_limit = if self.disable_block_gas_limit || block.header.gas_limit == 0 { - u64::MAX as u128 - } else { - block.header.gas_limit - }; - + let gas_limit = self.fork_gas_limit(&block); env.block = BlockEnv { number: U256::from(fork_block_number), timestamp: U256::from(block.header.timestamp), @@ -1171,9 +1184,10 @@ latest block number: {latest_block}" // the next block let next_block_base_fee = fees.get_next_block_base_fee_per_gas( block.header.gas_used, - block.header.gas_limit, + gas_limit, block.header.base_fee_per_gas.unwrap_or_default(), ); + // update next base fee fees.set_base_fee(next_block_base_fee); } @@ -1261,6 +1275,32 @@ latest block number: {latest_block}" (db, config) } + + /// we only use the gas limit value of the block if it is non-zero and the block gas + /// limit is enabled, since there are networks where this is not used and is always + /// `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also + pub(crate) fn fork_gas_limit(&self, block: &Block>) -> u128 { + if !self.disable_block_gas_limit { + if let Some(gas_limit) = self.gas_limit { + return gas_limit; + } else if block.header.gas_limit > 0 { + return block.header.gas_limit; + } + } + + u64::MAX as u128 + } + + /// Returns the gas limit for a non forked anvil instance + /// + /// Checks the config for the `disable_block_gas_limit` flag + pub(crate) fn gas_limit(&self) -> u128 { + if self.disable_block_gas_limit { + return u64::MAX as u128; + } + + self.gas_limit.unwrap_or(DEFAULT_GAS_LIMIT) + } } /// If the fork choice is a block number, simply return it with an empty list of transactions. diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index d8846b3b86f74..0a11fb38c9fc1 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -441,12 +441,14 @@ impl Backend { *self.fork.write() = Some(fork); *self.env.write() = env; } else { + let gas_limit = self.node_config.read().await.fork_gas_limit(&fork_block); let mut env = self.env.write(); + env.cfg.chain_id = fork.chain_id(); env.block = BlockEnv { number: U256::from(fork_block_number), timestamp: U256::from(fork_block.header.timestamp), - gas_limit: U256::from(fork_block.header.gas_limit), + gas_limit: U256::from(gas_limit), difficulty: fork_block.header.difficulty, prevrandao: Some(fork_block.header.mix_hash.unwrap_or_default()), // Keep previous `coinbase` and `basefee` value @@ -459,7 +461,7 @@ impl Backend { // the next block let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( fork_block.header.gas_used, - fork_block.header.gas_limit, + gas_limit, fork_block.header.base_fee_per_gas.unwrap_or_default(), ); diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index c800131d26bd1..370ba9f2342d7 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -45,7 +45,9 @@ use tokio::{ mod service; mod config; -pub use config::{AccountGenerator, ForkChoice, NodeConfig, CHAIN_ID, VERSION_MESSAGE}; +pub use config::{ + AccountGenerator, ForkChoice, NodeConfig, CHAIN_ID, DEFAULT_GAS_LIMIT, VERSION_MESSAGE, +}; mod hardfork; pub use hardfork::EthereumHardfork; diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 0d1c4f82479fa..8d5b0c588d184 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -6,12 +6,12 @@ use crate::{ }; use alloy_chains::NamedChain; use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder}; -use alloy_primitives::{address, b256, bytes, Address, Bytes, TxHash, TxKind, U256}; +use alloy_primitives::{address, b256, bytes, uint, Address, Bytes, TxHash, TxKind, U256, U64}; use alloy_provider::Provider; use alloy_rpc_types::{ anvil::Forking, request::{TransactionInput, TransactionRequest}, - BlockId, BlockNumberOrTag, + BlockId, BlockNumberOrTag, BlockTransactionsKind, }; use alloy_serde::WithOtherFields; use alloy_signer_local::PrivateKeySigner; @@ -60,6 +60,37 @@ pub fn fork_config() -> NodeConfig { .silent() } +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_gas_limit_applied_from_config() { + let (api, _handle) = spawn(fork_config().with_gas_limit(Some(10_000_000_u128))).await; + + assert_eq!(api.gas_limit(), uint!(10_000_000_U256)); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_gas_limit_disabled_from_config() { + let (api, handle) = spawn(fork_config().disable_block_gas_limit(true)).await; + + // see https://github.com/foundry-rs/foundry/pull/8933 + assert_eq!(api.gas_limit(), U256::from(U64::MAX)); + + // try to mine a couple blocks + let provider = handle.http_provider(); + let tx = TransactionRequest::default() + .to(Address::random()) + .value(U256::from(1337u64)) + .from(handle.dev_wallets().next().unwrap().address()); + let tx = WithOtherFields::new(tx); + let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + let tx = TransactionRequest::default() + .to(Address::random()) + .value(U256::from(1337u64)) + .from(handle.dev_wallets().next().unwrap().address()); + let tx = WithOtherFields::new(tx); + let _ = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); +} + #[tokio::test(flavor = "multi_thread")] async fn test_spawn_fork() { let (api, _handle) = spawn(fork_config()).await; @@ -1241,6 +1272,27 @@ async fn test_arbitrum_fork_block_number() { assert_eq!(block_number, initial_block_number - 2); } +#[tokio::test(flavor = "multi_thread")] +async fn test_base_fork_gas_limit() { + // fork to get initial block for test + let (api, handle) = spawn( + fork_config() + .with_fork_block_number(None::) + .with_eth_rpc_url(Some(next_rpc_endpoint(NamedChain::Base))), + ) + .await; + + let provider = handle.http_provider(); + let block = provider + .get_block(BlockId::Number(BlockNumberOrTag::Latest), BlockTransactionsKind::Hashes) + .await + .unwrap() + .unwrap(); + + assert_eq!(api.gas_limit(), uint!(120_000_000_U256)); + assert_eq!(block.header.gas_limit, 120_000_000_u128); +} + // #[tokio::test(flavor = "multi_thread")] async fn test_fork_execution_reverted() { diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index be9f206d730c4..6561e2ada1eaa 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -2,7 +2,7 @@ use crate::utils::http_provider_with_signer; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{Address, U256}; +use alloy_primitives::{uint, Address, U256, U64}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -10,6 +10,21 @@ use anvil::{eth::fees::INITIAL_BASE_FEE, spawn, NodeConfig}; const GAS_TRANSFER: u128 = 21_000; +#[tokio::test(flavor = "multi_thread")] +async fn test_gas_limit_applied_from_config() { + let (api, _handle) = spawn(NodeConfig::test().with_gas_limit(Some(10_000_000))).await; + + assert_eq!(api.gas_limit(), uint!(10_000_000_U256)); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_gas_limit_disabled_from_config() { + let (api, _handle) = spawn(NodeConfig::test().disable_block_gas_limit(true)).await; + + // see https://github.com/foundry-rs/foundry/pull/8933 + assert_eq!(api.gas_limit(), U256::from(U64::MAX)); +} + #[tokio::test(flavor = "multi_thread")] async fn test_basefee_full_block() { let (_api, handle) = spawn( diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 0827bbac1de8c..b3e82c380101c 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -230,14 +230,14 @@ async fn can_reject_too_high_gas_limits() { // #[tokio::test(flavor = "multi_thread")] async fn can_mine_large_gas_limit() { - let (api, handle) = spawn(NodeConfig::test().disable_block_gas_limit(true)).await; + let (_, handle) = spawn(NodeConfig::test().disable_block_gas_limit(true)).await; let provider = handle.http_provider(); let accounts = handle.dev_wallets().collect::>(); let from = accounts[0].address(); let to = accounts[1].address(); - let gas_limit = api.gas_limit().to::(); + let gas_limit = anvil::DEFAULT_GAS_LIMIT; let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); let tx = diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 305c8a1c87bd3..6f91be10ff70e 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -130,6 +130,10 @@ pub fn next_mainnet_etherscan_api_key() -> String { fn next_url(is_ws: bool, chain: NamedChain) -> String { use NamedChain::*; + if matches!(chain, NamedChain::Base) { + return "https://mainnet.base.org".to_string(); + } + let idx = next() % num_keys(); let is_infura = idx < INFURA_KEYS.len(); From 64e7237d98755b773224ec1ceef5045cf9ed55e9 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:50:27 +0200 Subject: [PATCH 1483/1963] chore: add @grandizzy @yash-atreya @zerosnacks as codeowners (#8951) add @grandizzy @yash-atreya @zerosnacks as codeowners too --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9f19e678f5f72..63b25bbbcb260 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @danipopes @klkvr @mattsse +* @danipopes @klkvr @mattsse @grandizzy @yash-atreya @zerosnacks From ccb3c3726d3d10b22f055515d7331f9351908224 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:55:49 +0200 Subject: [PATCH 1484/1963] chore(deps): update revm-inspector version in manifest (#8950) --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 3 +-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2c3d9e68ebc7..84194dfafb24e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6488,9 +6488,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plotters" @@ -6762,7 +6762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.77", @@ -7161,9 +7161,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57b33a24b5b8b8efa1da3f60d44f02d6e649f06ef925d7780723ff14ff55321" +checksum = "cd8e3bae0d5c824da0ac883e2521c5e83870d6521eeeccd4ee54266aa3cc1a51" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -8431,18 +8431,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -8910,9 +8910,9 @@ dependencies = [ [[package]] name = "tracing-tracy" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a90519f16f55e5c62ffd5976349f10744435a919ecff83d918300575dfb69b" +checksum = "dc775fdaf33c3dfd19dc354729e65e87914bc67dcdc390ca1210807b8bee5902" dependencies = [ "tracing-core", "tracing-subscriber", @@ -8921,9 +8921,9 @@ dependencies = [ [[package]] name = "tracy-client" -version = "0.17.3" +version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373db47331c3407b343538df77eea2516884a0b126cdfb4b135acfd400015dd7" +checksum = "746b078c6a09ebfd5594609049e07116735c304671eaab06ce749854d23435bc" dependencies = [ "loom", "once_cell", @@ -8932,9 +8932,9 @@ dependencies = [ [[package]] name = "tracy-client-sys" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49cf0064dcb31c99aa1244c1b93439359e53f72ed217eef5db50abd442241e9a" +checksum = "68613466112302fdbeabc5fa55f7d57462a0b247d5a6b7d7e09401fb471a144d" dependencies = [ "cc", ] @@ -9430,7 +9430,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 c7e38cbc9031d..90936bb1130bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,10 +172,9 @@ foundry-fork-db = "0.3" solang-parser = "=0.3.3" ## revm -# no default features to avoid c-kzg revm = { version = "14.0.2", default-features = false } revm-primitives = { version = "9.0.2", default-features = false } -revm-inspectors = { version = "0.7", features = ["serde"] } +revm-inspectors = { version = "0.7.7", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } From b09a88b0ca70acb15f1876ff6528df2ea8987e1f Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:39:25 +0200 Subject: [PATCH 1485/1963] chore: add Makefile and `codespell` (#8948) * add makefile + codespell * update makefile * fix typos found by codespell * add codespell CI task * fix outdated spec * ignore testdata * switch default profile to dev, add strat to ignored words list --- .codespellrc | 3 + .github/workflows/test.yml | 10 +++ Makefile | 72 +++++++++++++++++++ README.md | 2 +- crates/anvil/core/src/eth/mod.rs | 2 +- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/api.rs | 4 +- crates/anvil/src/eth/backend/cheats.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/eth/backend/mem/storage.rs | 2 +- crates/anvil/src/eth/pool/mod.rs | 2 +- crates/cheatcodes/assets/cheatcodes.json | 2 +- crates/cheatcodes/spec/src/vm.rs | 2 +- crates/cheatcodes/src/inspector.rs | 4 +- crates/cheatcodes/src/json.rs | 2 +- crates/chisel/src/executor.rs | 2 +- crates/cli/src/utils/mod.rs | 2 +- crates/config/README.md | 2 +- crates/config/src/lib.rs | 2 +- crates/evm/core/src/utils.rs | 2 +- crates/evm/coverage/src/anchors.rs | 2 +- crates/evm/evm/src/executors/fuzz/mod.rs | 4 +- crates/evm/evm/src/executors/invariant/mod.rs | 6 +- .../evm/evm/src/executors/invariant/shrink.rs | 10 +-- crates/evm/evm/src/executors/mod.rs | 2 +- crates/evm/fuzz/src/strategies/param.rs | 4 +- crates/evm/traces/src/debug/mod.rs | 4 +- crates/fmt/src/buffer.rs | 2 +- crates/fmt/src/formatter.rs | 2 +- crates/fmt/src/visit.rs | 2 +- crates/forge/README.md | 2 +- crates/forge/bin/cmd/bind_json.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/gas_report.rs | 2 +- crates/forge/tests/cli/cmd.rs | 2 +- crates/forge/tests/cli/script.rs | 4 +- crates/script/src/broadcast.rs | 2 +- crates/script/src/progress.rs | 2 +- crates/script/src/verify.rs | 2 +- crates/sol-macro-gen/src/lib.rs | 2 +- crates/verify/src/bytecode.rs | 2 +- crates/verify/src/retry.rs | 2 +- testdata/default/repros/Issue6634.t.sol | 4 +- 44 files changed, 139 insertions(+), 54 deletions(-) create mode 100644 .codespellrc create mode 100644 Makefile diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000000000..929bd589b7112 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,3 @@ +[codespell] +skip = .git,target,testdata,Cargo.toml,Cargo.lock +ignore-words-list = crate,ser,ratatui,Caf,froms,strat diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e6db23aea698..acb63a994fec8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,6 +51,15 @@ jobs: cache-on-failure: true - run: cargo test --workspace --doc + codespell: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: codespell-project/actions-codespell@v2 + with: + skip: "*.json" + clippy: runs-on: ubuntu-latest timeout-minutes: 30 @@ -107,6 +116,7 @@ jobs: - nextest - docs - doctest + - codespell - clippy - rustfmt - forge-fmt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000..920e4de2d5fc4 --- /dev/null +++ b/Makefile @@ -0,0 +1,72 @@ +# Heavily inspired by: +# - Lighthouse: https://github.com/sigp/lighthouse/blob/693886b94176faa4cb450f024696cb69cda2fe58/Makefile +# - Reth: https://github.com/paradigmxyz/reth/blob/1f642353ca083b374851ab355b5d80207b36445c/Makefile +.DEFAULT_GOAL := help + +# Cargo profile for builds. +PROFILE ?= dev + +# List of features to use when building. Can be overridden via the environment. +# No jemalloc on Windows +ifeq ($(OS),Windows_NT) + FEATURES ?= rustls aws-kms cli asm-keccak +else + FEATURES ?= jemalloc rustls aws-kms cli asm-keccak +endif + +##@ Help + +.PHONY: help +help: ## Display this help. + @awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +##@ Build + +.PHONY: build +build: ## Build the project. + cargo build --features "$(FEATURES)" --profile "$(PROFILE)" + +##@ Other + +.PHONY: clean +clean: ## Clean the project. + cargo clean + +## Linting + +fmt: ## Run all formatters. + cargo +nightly fmt + ./.github/scripts/format.sh --check + +lint-foundry: + RUSTFLAGS="-Dwarnings" cargo clippy --workspace --all-targets --all-features + +lint-codespell: ensure-codespell + codespell --skip "*.json" + +ensure-codespell: + @if ! command -v codespell &> /dev/null; then \ + echo "codespell not found. Please install it by running the command `pip install codespell` or refer to the following link for more information: https://github.com/codespell-project/codespell" \ + exit 1; \ + fi + +lint: ## Run all linters. + make fmt && \ + make lint-foundry && \ + make lint-codespell + +## Testing + +test-foundry: + cargo nextest run -E 'kind(test) & !test(/issue|forge_std|ext_integration/)' + +test-doc: + cargo test --doc --workspace + +test: ## Run all tests. + make test-foundry && \ + make test-doc + +pr: ## Run all tests and linters in preparation for a PR. + make lint && \ + make test \ No newline at end of file diff --git a/README.md b/README.md index 684b33556069e..ec0884aa2378f 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ By default `forge config` shows the currently selected foundry profile and its v ### DappTools Compatibility -You can re-use your `.dapprc` environment variables by running `source .dapprc` before using a Foundry tool. +You can reuse your `.dapprc` environment variables by running `source .dapprc` before using a Foundry tool. ### Additional Configuration diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 70c62ed563501..d53473666e1f6 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -522,7 +522,7 @@ pub enum EthRequest { EvmSetTime(U256), /// Serializes the current state (including contracts code, contract's storage, accounts - /// properties, etc.) into a savable data blob + /// properties, etc.) into a saveable data blob #[cfg_attr(feature = "serde", serde(rename = "anvil_dumpState", alias = "hardhat_dumpState"))] DumpState(#[cfg_attr(feature = "serde", serde(default))] Option>>), diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 463c3de13fe7c..25e42e001b21d 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -672,7 +672,7 @@ pub enum TypedTransaction { /// This is a function that demotes TypedTransaction to TransactionRequest for greater flexibility /// over the type. /// -/// This function is purely for convience and specific use cases, e.g. RLP encoded transactions +/// This function is purely for convenience and specific use cases, e.g. RLP encoded transactions /// decode to TypedTransactions where the API over TypedTransctions is quite strict. impl TryFrom for TransactionRequest { type Error = ConversionError; diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 61ab278d0cd60..96f4c53d5ee23 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1401,7 +1401,7 @@ impl PruneStateHistoryConfig { !self.enabled || self.max_memory_history.is_some() } - /// Returns tru if this setting was enabled. + /// Returns true if this setting was enabled. pub fn is_config_enabled(&self) -> bool { self.enabled } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index ec2d0dd6a9e6e..88698e13cc083 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1936,7 +1936,7 @@ impl EthApi { Ok(()) } - /// Reorg the chain to a specific depth and mine new blocks back to the cannonical height. + /// Reorg the chain to a specific depth and mine new blocks back to the canonical height. /// /// e.g depth = 3 /// A -> B -> C -> D -> E @@ -2566,7 +2566,7 @@ impl EthApi { // current midpoint, as spending any less gas would make no // sense (as the TX would still revert due to lack of gas). // - // We don't care about the reason here, as we known that trasaction is correct + // We don't care about the reason here, as we known that transaction is correct // as it succeeded earlier lowest_gas_limit = mid_gas_limit; } diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 5b498f963c845..5e941d0046438 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -24,7 +24,7 @@ impl CheatsManager { let mut state = self.state.write(); // When somebody **explicitly** impersonates an account we need to store it so we are able // to return it from `eth_accounts`. That's why we do not simply call `is_impersonated()` - // which does not check that list when auto impersonation is enabeld. + // which does not check that list when auto impersonation is enabled. if state.impersonated_accounts.contains(&addr) { // need to check if already impersonated, so we don't overwrite the code return true diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0a11fb38c9fc1..89cd0bd4b33c3 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -149,7 +149,7 @@ pub struct Backend { /// which the write-lock is active depends on whether the `ForkDb` can provide all requested /// data from memory or whether it has to retrieve it via RPC calls first. This means that it /// potentially blocks for some time, even taking into account the rate limits of RPC - /// endpoints. Therefor the `Db` is guarded by a `tokio::sync::RwLock` here so calls that + /// endpoints. Therefore the `Db` is guarded by a `tokio::sync::RwLock` here so calls that /// need to read from it, while it's currently written to, don't block. E.g. a new block is /// currently mined and a new [`Self::set_storage_at()`] request is being executed. db: Arc>>, diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 441bd1cbbfac8..9afc9f66919a2 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -569,7 +569,7 @@ impl MinedTransaction { pub struct MinedTransactionReceipt { /// The actual json rpc receipt object pub inner: ReceiptResponse, - /// Output data fo the transaction + /// Output data for the transaction pub out: Option, } diff --git a/crates/anvil/src/eth/pool/mod.rs b/crates/anvil/src/eth/pool/mod.rs index 9ef45ace2c2cc..544d7eac9df37 100644 --- a/crates/anvil/src/eth/pool/mod.rs +++ b/crates/anvil/src/eth/pool/mod.rs @@ -20,7 +20,7 @@ //! used to determine whether it can be included in a block (transaction is ready) or whether it //! still _requires_ other transactions to be mined first (transaction is pending). //! A transaction is associated with the nonce of the account it's sent from. A unique identifying -//! marker for a transaction is therefor the pair `(nonce + account)`. An incoming transaction with +//! marker for a transaction is therefore the pair `(nonce + account)`. An incoming transaction with //! a `nonce > nonce on chain` will _require_ `(nonce -1, account)` first, before it is ready to be //! included in a block. //! diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 4357d82a248f1..d40d7353e356f 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3634,7 +3634,7 @@ { "func": { "id": "deployCode_1", - "description": "Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.\nAdditionaly accepts abi-encoded constructor arguments.", + "description": "Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.\nAdditionally accepts abi-encoded constructor arguments.", "declaration": "function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress);", "visibility": "external", "mutability": "", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index a29b0cf80a760..5fbd94ce00ed0 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1544,7 +1544,7 @@ interface Vm { /// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of :: where and parts are optional. /// - /// Additionaly accepts abi-encoded constructor arguments. + /// Additionally accepts abi-encoded constructor arguments. #[cheatcode(group = Filesystem)] function deployCode(string calldata artifactPath, bytes calldata constructorArgs) external returns (address deployedAddress); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 401966c4626b0..5f4ee94080cf9 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -222,7 +222,7 @@ pub struct BroadcastableTransaction { pub struct GasMetering { /// True if gas metering is paused. pub paused: bool, - /// True if gas metering was resumed or reseted during the test. + /// True if gas metering was resumed or reset during the test. /// Used to reconcile gas when frame ends (if spent less than refunded). pub touched: bool, /// True if gas metering should be reset to frame limit. @@ -1196,7 +1196,7 @@ impl Inspector for Cheatcodes { 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 appplied for cheatcodes in the `call` hook. + // it for cheatcode calls because they are not applied for cheatcodes in the `call` hook. // This should be placed before the revert handling, because we might exit early there if !cheatcode_call { // Clean up pranks diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index ba32b4ebe6441..0908f247ca944 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -594,7 +594,7 @@ fn serialize_value_as_json(value: DynSolValue) -> Result { match value { DynSolValue::Bool(b) => Ok(Value::Bool(b)), DynSolValue::String(s) => { - // Strings are allowed to contain strigified JSON objects, so we try to parse it like + // Strings are allowed to contain stringified JSON objects, so we try to parse it like // one first. if let Ok(map) = serde_json::from_str(&s) { Ok(Value::Object(map)) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index a0b9fc391e9b9..3d5fce2954547 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1161,7 +1161,7 @@ impl Type { Self::ethabi(&return_parameter.ty, Some(intermediate)).map(|p| (contract_expr.unwrap(), p)) } - /// Inverts Int to Uint and viceversa. + /// Inverts Int to Uint and vice-versa. fn invert_int(self) -> Self { match self { Self::Builtin(DynSolType::Uint(n)) => Self::Builtin(DynSolType::Int(n)), diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index f5bee0a77d1d1..736793e67cd52 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -163,7 +163,7 @@ pub fn block_on(future: F) -> F::Output { /// Conditionally print a message /// -/// This macro accepts a predicate and the message to print if the predicate is tru +/// This macro accepts a predicate and the message to print if the predicate is true /// /// ```ignore /// let quiet = true; diff --git a/crates/config/README.md b/crates/config/README.md index 99f02e5e68f2e..139c2a9f5601a 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -100,7 +100,7 @@ model_checker = { contracts = { 'a.sol' = [ ], timeout = 10000 } verbosity = 0 eth_rpc_url = "https://example.com/" -# Setting this option enables decoding of error traces from mainnet deployed / verfied contracts via etherscan +# Setting this option enables decoding of error traces from mainnet deployed / verified contracts via etherscan etherscan_api_key = "YOURETHERSCANAPIKEY" # ignore solc warnings for missing license and exceeded contract size # known error codes are: ["unreachable", "unused-return", "unused-param", "unused-var", "code-size", "shadowing", "func-mutability", "license", "pragma-solidity", "virtual-interfaces", "same-varname", "too-many-warnings", "constructor-visibility", "init-code-size", "missing-receive-ether", "unnamed-return", "transient-storage"] diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d77e30492fc5b..452365ce95512 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2717,7 +2717,7 @@ impl Provider for OptionalStrictProfileProvider

{ figment.data().map_err(|err| { // figment does tag metadata and tries to map metadata to an error, since we use a new // figment in this provider this new figment does not know about the metadata of the - // provider and can't map the metadata to the error. Therefor we return the root error + // provider and can't map the metadata to the error. Therefore we return the root error // if this error originated in the provider's data. if let Err(root_err) = self.provider.data() { return root_err; diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 27db37eaf1e20..11f8bbb318827 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -119,7 +119,7 @@ fn get_create2_factory_call_inputs(salt: U256, inputs: CreateInputs) -> CallInpu /// Used for routing certain CREATE2 invocations through [DEFAULT_CREATE2_DEPLOYER]. /// /// Overrides create hook with CALL frame if [InspectorExt::should_use_create2_factory] returns -/// true. Keeps track of overriden frames and handles outcome in the overriden insert_call_outcome +/// true. Keeps track of overridden frames and handles outcome in the overridden insert_call_outcome /// hook by inserting decoded address directly into interpreter. /// /// Should be installed after [revm::inspector_handle_register] and before any other registers. diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index 9e82ec1cbc9fb..c5bb8196a9c55 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -71,7 +71,7 @@ pub fn find_anchor_simple( Ok(ItemAnchor { instruction: ic_pc_map.get(instruction).ok_or_else(|| { - eyre::eyre!("We found an anchor, but we cant translate it to a program counter") + eyre::eyre!("We found an anchor, but we can't translate it to a program counter") })?, item_id, }) diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 54480181ff1cd..775b7e73e060f 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -88,7 +88,7 @@ impl FuzzedExecutor { let execution_data = RefCell::new(FuzzTestData::default()); let state = self.build_fuzz_state(); let dictionary_weight = self.config.dictionary.dictionary_weight.min(100); - let strat = proptest::prop_oneof![ + let strategy = proptest::prop_oneof![ 100 - dictionary_weight => fuzz_calldata(func.clone(), fuzz_fixtures), dictionary_weight => fuzz_calldata_from_state(func.clone(), &state), ]; @@ -96,7 +96,7 @@ impl FuzzedExecutor { let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize; let show_logs = self.config.show_logs; - let run_result = self.runner.clone().run(&strat, |calldata| { + let run_result = self.runner.clone().run(&strategy, |calldata| { let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; // If running with progress then increment current run. diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index b5854d1d7a070..2e2e06e6d32a1 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -243,7 +243,7 @@ impl InvariantTestRun { } } -/// Wrapper around any [`Executor`] implementor which provides fuzzing support using [`proptest`]. +/// Wrapper around any [`Executor`] implementer which provides fuzzing support using [`proptest`]. /// /// After instantiation, calling `invariant_fuzz` will proceed to hammer the deployed smart /// contracts with inputs, until it finds a counterexample sequence. The provided [`TestRunner`] @@ -463,7 +463,7 @@ impl<'a> InvariantExecutor<'a> { EvmFuzzState::new(self.executor.backend().mem_db(), self.config.dictionary); // Creates the invariant strategy. - let strat = invariant_strat( + let strategy = invariant_strat( fuzz_state.clone(), targeted_senders, targeted_contracts.clone(), @@ -519,7 +519,7 @@ impl<'a> InvariantExecutor<'a> { last_call_results, self.runner.clone(), ), - strat, + strategy, )) } diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index 318163534f9b8..ca5196b4a2ce4 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -21,13 +21,13 @@ struct Shrink { /// If the failure is not reproducible then restore removed call and moves to next one. #[derive(Debug)] struct CallSequenceShrinker { - /// Length of call sequence to be shrinked. + /// Length of call sequence to be shrunk. call_sequence_len: usize, - /// Call ids contained in current shrinked sequence. + /// Call ids contained in current shrunk sequence. included_calls: VarBitSet, - /// Current shrinked call id. + /// Current shrunk call id. shrink: Shrink, - /// Previous shrinked call id. + /// Previous shrunk call id. prev_shrink: Option, } @@ -82,7 +82,7 @@ impl CallSequenceShrinker { /// Maximal shrinkage is guaranteed if the shrink_run_limit is not set to a value lower than the /// length of failed call sequence. /// -/// The shrinked call sequence always respect the order failure is reproduced as it is tested +/// The shrunk call sequence always respect the order failure is reproduced as it is tested /// top-down. pub(crate) fn shrink_sequence( failed_case: &FailedInvariantCaseData, diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 655418fadeb6d..dc923d6e00b3e 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -576,7 +576,7 @@ impl Executor { /// Creates the environment to use when executing a transaction in a test context /// /// If using a backend with cheatcodes, `tx.gas_price` and `block.number` will be overwritten by - /// the cheatcode state inbetween calls. + /// the cheatcode state in between calls. fn build_test_env( &self, caller: Address, diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 10b166956d0f7..7e5218fd872ba 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -218,12 +218,12 @@ mod tests { let func = get_func(f).unwrap(); let db = CacheDB::new(EmptyDB::default()); let state = EvmFuzzState::new(&db, FuzzDictionaryConfig::default()); - let strat = proptest::prop_oneof![ + let strategy = proptest::prop_oneof![ 60 => fuzz_calldata(func.clone(), &FuzzFixtures::default()), 40 => fuzz_calldata_from_state(func, &state), ]; let cfg = proptest::test_runner::Config { failure_persistence: None, ..Default::default() }; let mut runner = proptest::test_runner::TestRunner::new(cfg); - let _ = runner.run(&strat, |_| Ok(())); + let _ = runner.run(&strategy, |_| Ok(())); } } diff --git a/crates/evm/traces/src/debug/mod.rs b/crates/evm/traces/src/debug/mod.rs index a651a3acc5cb3..a56f4ab2bff1e 100644 --- a/crates/evm/traces/src/debug/mod.rs +++ b/crates/evm/traces/src/debug/mod.rs @@ -110,7 +110,7 @@ impl<'a> DebugStepsWalker<'a> { loc.index() == other_loc.index() } - /// Invoked when current step is a JUMPDEST preceeded by a JUMP marked as [Jump::In]. + /// Invoked when current step is a JUMPDEST preceded by a JUMP marked as [Jump::In]. fn jump_in(&mut self) { // This usually means that this is a jump into the external function which is an // entrypoint for the current frame. We don't want to include this to avoid @@ -128,7 +128,7 @@ impl<'a> DebugStepsWalker<'a> { } } - /// Invoked when current step is a JUMPDEST preceeded by a JUMP marked as [Jump::Out]. + /// Invoked when current step is a JUMPDEST preceded by a JUMP marked as [Jump::Out]. fn jump_out(&mut self) { let Some((i, _)) = self.stack.iter().enumerate().rfind(|(_, (_, step_idx))| { self.is_same_loc(*step_idx, self.current_step) || diff --git a/crates/fmt/src/buffer.rs b/crates/fmt/src/buffer.rs index b09e9e620df3c..9226d5f6b54f7 100644 --- a/crates/fmt/src/buffer.rs +++ b/crates/fmt/src/buffer.rs @@ -173,7 +173,7 @@ impl FormatBuffer { let mut comment_state = self.state.comment_state(); while let Some(line) = lines.next() { // remove the whitespace that covered by the base indent length (this is normally the - // case with temporary buffers as this will be readded by the underlying IndentWriter + // case with temporary buffers as this will be re-added by the underlying IndentWriter // later on let (new_comment_state, line_start) = line .comment_state_char_indices() diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 2ae083e5db48c..1dbf63eacff1d 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -3244,7 +3244,7 @@ impl<'a, W: Write> Visitor for Formatter<'a, W> { let is_constructor = self.context.is_constructor_function(); // we can't make any decisions here regarding trailing `()` because we'd need to // find out if the `base` is a solidity modifier or an - // interface/contract therefor we we its raw content. + // interface/contract therefore we we its raw content. // we can however check if the contract `is` the `base`, this however also does // not cover all cases diff --git a/crates/fmt/src/visit.rs b/crates/fmt/src/visit.rs index b977ba5b33abb..3fff8893d232c 100644 --- a/crates/fmt/src/visit.rs +++ b/crates/fmt/src/visit.rs @@ -5,7 +5,7 @@ use crate::solang_ext::pt::*; /// A trait that is invoked while traversing the Solidity Parse Tree. /// Each method of the [Visitor] trait is a hook that can be potentially overridden. /// -/// Currently the main implementor of this trait is the [`Formatter`](crate::Formatter<'_>) struct. +/// Currently the main implementer of this trait is the [`Formatter`](crate::Formatter<'_>) struct. pub trait Visitor { type Error: std::error::Error; diff --git a/crates/forge/README.md b/crates/forge/README.md index d4cfeede210f3..a40a852db54ec 100644 --- a/crates/forge/README.md +++ b/crates/forge/README.md @@ -206,7 +206,7 @@ contract MyTest { function testBarExpectedRevert() public { vm.expectRevert("My expected revert string"); - // This would fail *if* we didnt expect revert. Since we expect the revert, + // This would fail *if* we didn't expect revert. Since we expect the revert, // it doesn't, unless the revert string is wrong. foo.bar(101); } diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index bd2d0ea30d673..d01abd60b8509 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -187,7 +187,7 @@ struct StructToWrite { } impl StructToWrite { - /// Returns the name of the imported item. If struct is definied at the file level, returns the + /// Returns the name of the imported item. If struct is defined at the file level, returns the /// struct name, otherwise returns the parent contract name. fn struct_or_contract_name(&self) -> &str { self.contract_name.as_deref().unwrap_or(&self.name) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 0eebbb9a0ee7a..6bf1ffd8183a4 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -187,7 +187,7 @@ impl TestArgs { /// Returns sources which include any tests to be executed. /// If no filters are provided, sources are filtered by existence of test/invariant methods in - /// them, If filters are provided, sources are additionaly filtered by them. + /// them, If filters are provided, sources are additionally filtered by them. pub fn get_sources_to_compile( &self, config: &Config, diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 4fb4388448cb6..85f53b5f517b7 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -79,7 +79,7 @@ impl GasReport { return; } - // Only include top-level calls which accout for calldata and base (21.000) cost. + // Only include top-level calls which account for calldata and base (21.000) cost. // Only include Calls and Creates as only these calls are isolated in inspector. if trace.depth > 1 && (trace.kind == CallKind::Call || diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 4e860bc649003..1144830c52ba1 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -984,7 +984,7 @@ Warning: SPDX license identifier not provided in source file. Before publishing, "#]]); }); -// test that `forge build` does not print `(with warnings)` if there arent any +// test that `forge build` does not print `(with warnings)` if there aren't any forgetest!(can_compile_without_warnings, |prj, cmd| { let config = Config { ignored_error_codes: vec![SolidityErrorCode::SpdxLicenseNotProvided], diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 9fc398c902c9c..78e27d65384d9 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -930,7 +930,7 @@ forgetest_async!(check_broadcast_log, |prj, cmd| { // Check broadcast logs // Ignore timestamp, blockHash, blockNumber, cumulativeGasUsed, effectiveGasPrice, - // transactionIndex and logIndex values since they can change inbetween runs + // transactionIndex and logIndex values since they can change in between runs let re = Regex::new(r#"((timestamp":).[0-9]*)|((blockHash":).*)|((blockNumber":).*)|((cumulativeGasUsed":).*)|((effectiveGasPrice":).*)|((transactionIndex":).*)|((logIndex":).*)"#).unwrap(); let fixtures_log = std::fs::read_to_string( @@ -954,7 +954,7 @@ forgetest_async!(check_broadcast_log, |prj, cmd| { // ); // Check sensitive logs - // Ignore port number since it can change inbetween runs + // Ignore port number since it can change in between runs let re = Regex::new(r":[0-9]+").unwrap(); let fixtures_log = std::fs::read_to_string( diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 302be1509af66..ff4e4205ecfdc 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -295,7 +295,7 @@ impl BundledState { tx.set_chain_id(sequence.chain); - // Set TxKind::Create explicitly to satify `check_reqd_fields` in + // Set TxKind::Create explicitly to satisfy `check_reqd_fields` in // alloy if tx.to.is_none() { tx.set_create(); diff --git a/crates/script/src/progress.rs b/crates/script/src/progress.rs index e88885de3e444..819ebca994387 100644 --- a/crates/script/src/progress.rs +++ b/crates/script/src/progress.rs @@ -16,7 +16,7 @@ use yansi::Paint; /// State of [ProgressBar]s displayed for the given [ScriptSequence]. #[derive(Debug)] pub struct SequenceProgressState { - /// The top spinner with containt of the format "Sequence #{id} on {network} | {status}"" + /// The top spinner with content of the format "Sequence #{id} on {network} | {status}"" top_spinner: ProgressBar, /// Progress bar with the count of transactions. txs: ProgressBar, diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 10c877ce6a419..18ee6ccf2937c 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -89,7 +89,7 @@ impl VerifyBundle { /// Configures the chain and sets the etherscan key, if available pub fn set_chain(&mut self, config: &Config, chain: Chain) { - // If dealing with multiple chains, we need to be able to change inbetween the config + // If dealing with multiple chains, we need to be able to change in between the config // chain_id. self.etherscan.key = config.get_etherscan_api_key(Some(chain)); self.etherscan.chain = Some(chain); diff --git a/crates/sol-macro-gen/src/lib.rs b/crates/sol-macro-gen/src/lib.rs index 0202827f25574..9984c6cce2b21 100644 --- a/crates/sol-macro-gen/src/lib.rs +++ b/crates/sol-macro-gen/src/lib.rs @@ -1,4 +1,4 @@ -//! This crate constains the logic for Rust bindings generating from Solidity contracts +//! This crate contains the logic for Rust bindings generating from Solidity contracts pub mod sol_macro_gen; diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index e08cf3a5a0281..034bb49a68461 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -468,7 +468,7 @@ impl VerifyBytecodeArgs { &transaction, )?; - // State commited using deploy_with_env, now get the runtime bytecode from the db. + // State committed using deploy_with_env, now get the runtime bytecode from the db. let (fork_runtime_code, onchain_runtime_code) = crate::utils::get_runtime_codes( &mut executor, &provider, diff --git a/crates/verify/src/retry.rs b/crates/verify/src/retry.rs index 528fd74975d8a..a12dde140f013 100644 --- a/crates/verify/src/retry.rs +++ b/crates/verify/src/retry.rs @@ -20,7 +20,7 @@ pub struct RetryArgs { )] pub retries: u32, - /// Optional delay to apply inbetween verification attempts, in seconds. + /// Optional delay to apply in between verification attempts, in seconds. #[arg( long, value_parser = RangedU64ValueParser::::new().range(0..=30), diff --git a/testdata/default/repros/Issue6634.t.sol b/testdata/default/repros/Issue6634.t.sol index 22294f6df2338..64d92e9d1f0ef 100644 --- a/testdata/default/repros/Issue6634.t.sol +++ b/testdata/default/repros/Issue6634.t.sol @@ -58,7 +58,7 @@ contract Issue6634Test is DSTest { assertEq(called.length, 2, "incorrect length"); assertEq(uint256(called[0].kind), uint256(Vm.AccountAccessKind.Call), "first AccountAccess is incorrect kind"); - assertEq(called[0].account, CREATE2_DEPLOYER, "first AccountAccess accout is incorrect"); + assertEq(called[0].account, CREATE2_DEPLOYER, "first AccountAccess account is incorrect"); assertEq(called[0].accessor, accessor, "first AccountAccess accessor is incorrect"); assertEq( uint256(called[1].kind), uint256(Vm.AccountAccessKind.Create), "second AccountAccess is incorrect kind" @@ -84,7 +84,7 @@ contract Issue6634Test is DSTest { assertEq(called.length, 2, "incorrect length"); assertEq(uint256(called[0].kind), uint256(Vm.AccountAccessKind.Call), "first AccountAccess is incorrect kind"); - assertEq(called[0].account, CREATE2_DEPLOYER, "first AccountAccess accout is incorrect"); + assertEq(called[0].account, CREATE2_DEPLOYER, "first AccountAccess account is incorrect"); assertEq(called[0].accessor, accessor, "first AccountAccess accessor is incorrect"); assertEq( uint256(called[1].kind), uint256(Vm.AccountAccessKind.Create), "second AccountAccess is incorrect kind" From 883bb1c39f56a525657116874e59e80c2b881b10 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:48:44 +0200 Subject: [PATCH 1486/1963] chore: add comments for alloy-core patches (#8955) --- Cargo.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 90936bb1130bc..99f079a758349 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -276,6 +276,18 @@ proptest = "1" comfy-table = "7" # [patch.crates-io] +## alloy-core +# alloy-dyn-abi = { path = "../../alloy-rs/core/crates/dyn-abi" } +# alloy-json-abi = { path = "../../alloy-rs/core/crates/json-abi" } +# alloy-primitives = { path = "../../alloy-rs/core/crates/primitives" } +# alloy-sol-macro = { path = "../../alloy-rs/core/crates/sol-macro" } +# alloy-sol-macro-expander = { path = "../../alloy-rs/core/crates/sol-macro-expander" } +# alloy-sol-macro-input = { path = "../../alloy-rs/core/crates/sol-macro-input" } +# alloy-sol-type-parser = { path = "../../alloy-rs/core/crates/sol-type-parser" } +# alloy-sol-types = { path = "../../alloy-rs/core/crates/sol-types" } +# syn-solidity = { path = "../../alloy-rs/core/crates/syn-solidity" } + +## alloy # alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } # alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } # alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" } From 8d5a66d90cfbf3e68b0188112898735cdd7562e9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 25 Sep 2024 10:20:36 +0300 Subject: [PATCH 1487/1963] fix(coverage): better find of loc start byte position (#8958) --- crates/evm/coverage/src/analysis.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index daf676c2ca9c4..1b68c89d36663 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -470,12 +470,14 @@ impl<'a> ContractVisitor<'a> { } fn source_location_for(&self, loc: &ast::LowFidelitySourceLocation) -> SourceLocation { + let loc_start = + self.source.char_indices().map(|(i, _)| i).nth(loc.start).unwrap_or_default(); SourceLocation { source_id: self.source_id, contract_name: self.contract_name.clone(), start: loc.start as u32, length: loc.length.map(|x| x as u32), - line: self.source[..loc.start].lines().count(), + line: self.source[..loc_start].lines().count(), } } } From ccabf8b71831ed872988bba0137fb760b18dc519 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:31:23 +0300 Subject: [PATCH 1488/1963] chore: improve fuzz scrape bytecode test (#8953) * chore: improve fuzz scrape bytecode test * Remove duped comments, Trigger CI --- crates/forge/tests/it/fuzz.rs | 67 ++++++++++++++----- .../default/fuzz/FuzzScrapeBytecode.t.sol | 35 ---------- 2 files changed, 50 insertions(+), 52 deletions(-) delete mode 100644 testdata/default/fuzz/FuzzScrapeBytecode.t.sol diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 1d810c9c5d84a..d6b047a17a93a 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -155,27 +155,60 @@ async fn test_persist_fuzz_failure() { assert_ne!(initial_calldata, new_calldata); } -#[tokio::test(flavor = "multi_thread")] -async fn test_scrape_bytecode() { - let filter = Filter::new(".*", ".*", ".*fuzz/FuzzScrapeBytecode.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.runs = 2000; - runner.test_options.fuzz.seed = Some(U256::from(100u32)); - let suite_result = runner.test_collect(&filter); +forgetest_init!(test_can_scrape_bytecode, |prj, cmd| { + prj.add_source( + "FuzzerDict.sol", + r#" +// https://github.com/foundry-rs/foundry/issues/1168 +contract FuzzerDict { + // Immutables should get added to the dictionary. + address public immutable immutableOwner; + // Regular storage variables should also get added to the dictionary. + address public storageOwner; + + constructor(address _immutableOwner, address _storageOwner) { + immutableOwner = _immutableOwner; + storageOwner = _storageOwner; + } +} + "#, + ) + .unwrap(); - assert!(!suite_result.is_empty()); + prj.add_test( + "FuzzerDictTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; +import "src/FuzzerDict.sol"; - for (_, SuiteResult { test_results, .. }) in suite_result { - for (test_name, result) in test_results { - match test_name.as_str() { - "testImmutableOwner(address)" | "testStorageOwner(address)" => { - assert_eq!(result.status, TestStatus::Failure) - } - _ => {} - } - } +contract FuzzerDictTest is Test { + FuzzerDict fuzzerDict; + + function setUp() public { + fuzzerDict = new FuzzerDict(address(100), address(200)); + } + + /// forge-config: default.fuzz.runs = 2000 + function testImmutableOwner(address who) public { + assertTrue(who != fuzzerDict.immutableOwner()); + } + + /// forge-config: default.fuzz.runs = 2000 + function testStorageOwner(address who) public { + assertTrue(who != fuzzerDict.storageOwner()); } } + "#, + ) + .unwrap(); + + // Test that immutable address is used as fuzzed input, causing test to fail. + cmd.args(["test", "--fuzz-seed", "100", "--mt", "testImmutableOwner"]).assert_failure(); + // Test that storage address is used as fuzzed input, causing test to fail. + cmd.forge_fuse() + .args(["test", "--fuzz-seed", "100", "--mt", "testStorageOwner"]) + .assert_failure(); +}); // tests that inline max-test-rejects config is properly applied forgetest_init!(test_inline_max_test_rejects, |prj, cmd| { diff --git a/testdata/default/fuzz/FuzzScrapeBytecode.t.sol b/testdata/default/fuzz/FuzzScrapeBytecode.t.sol deleted file mode 100644 index ffded67f03311..0000000000000 --- a/testdata/default/fuzz/FuzzScrapeBytecode.t.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; - -import "ds-test/test.sol"; - -// https://github.com/foundry-rs/foundry/issues/1168 -contract FuzzerDict { - // Immutables should get added to the dictionary. - address public immutable immutableOwner; - // Regular storage variables should also get added to the dictionary. - address public storageOwner; - - constructor(address _immutableOwner, address _storageOwner) { - immutableOwner = _immutableOwner; - storageOwner = _storageOwner; - } -} - -contract FuzzerDictTest is DSTest { - FuzzerDict fuzzerDict; - - function setUp() public { - fuzzerDict = new FuzzerDict(address(100), address(200)); - } - - // Fuzzer should try `fuzzerDict.immutableOwner()` as input, causing this to fail - function testImmutableOwner(address who) public { - assertTrue(who != fuzzerDict.immutableOwner()); - } - - // Fuzzer should try `fuzzerDict.storageOwner()` as input, causing this to fail - function testStorageOwner(address who) public { - assertTrue(who != fuzzerDict.storageOwner()); - } -} From 9a0f66ec57d65a4546b8af915238b55d536c47b6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:53:56 +0300 Subject: [PATCH 1489/1963] chore: fire shutdown signal on anvil node handle drop (#8947) * chore: add anvil NodeHandle.fire_shutdown_signal * Remove DAPP remappings from env vars from cli tests. * Unwrap fire shutdown * Fix clippy * track_caller on fire shutdown * fire shutdown signal on drop --- crates/anvil/src/lib.rs | 51 ++++++++++++++++++------------ crates/anvil/tests/it/anvil_api.rs | 6 +--- crates/anvil/tests/it/gas.rs | 6 +--- crates/anvil/tests/it/proof.rs | 6 +--- crates/anvil/tests/it/traces.rs | 6 +--- crates/forge/tests/cli/config.rs | 18 ----------- 6 files changed, 34 insertions(+), 59 deletions(-) diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 370ba9f2342d7..ee66caa672baa 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -255,32 +255,41 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle type IpcTask = JoinHandle<()>; -/// A handle to the spawned node and server tasks +/// A handle to the spawned node and server tasks. /// /// This future will resolve if either the node or server task resolve/fail. pub struct NodeHandle { config: NodeConfig, - /// The address of the running rpc server + /// The address of the running rpc server. addresses: Vec, - /// Join handle for the Node Service + /// Join handle for the Node Service. pub node_service: JoinHandle>, /// Join handles (one per socket) for the Anvil server. pub servers: Vec>>, - // The future that joins the ipc server, if any + /// The future that joins the ipc server, if any. ipc_task: Option, /// A signal that fires the shutdown, fired on drop. _signal: Option, - /// A task manager that can be used to spawn additional tasks + /// A task manager that can be used to spawn additional tasks. task_manager: TaskManager, } +impl Drop for NodeHandle { + fn drop(&mut self) { + // Fire shutdown signal to make sure anvil instance is terminated. + if let Some(signal) = self._signal.take() { + signal.fire().unwrap() + } + } +} + impl NodeHandle { - /// The [NodeConfig] the node was launched with + /// The [NodeConfig] the node was launched with. pub fn config(&self) -> &NodeConfig { &self.config } - /// Prints the launch info + /// Prints the launch info. pub(crate) fn print(&self, fork: Option<&ClientFork>) { self.config.print(fork); if !self.config.silent { @@ -298,25 +307,25 @@ impl NodeHandle { } } - /// The address of the launched server + /// The address of the launched server. /// /// **N.B.** this may not necessarily be the same `host + port` as configured in the - /// `NodeConfig`, if port was set to 0, then the OS auto picks an available port + /// `NodeConfig`, if port was set to 0, then the OS auto picks an available port. pub fn socket_address(&self) -> &SocketAddr { &self.addresses[0] } - /// Returns the http endpoint + /// Returns the http endpoint. pub fn http_endpoint(&self) -> String { format!("http://{}", self.socket_address()) } - /// Returns the websocket endpoint + /// Returns the websocket endpoint. pub fn ws_endpoint(&self) -> String { format!("ws://{}", self.socket_address()) } - /// Returns the path of the launched ipc server, if any + /// Returns the path of the launched ipc server, if any. pub fn ipc_path(&self) -> Option { self.config.get_ipc_path() } @@ -336,44 +345,44 @@ impl NodeHandle { ProviderBuilder::new(&self.config.get_ipc_path()?).build().ok() } - /// Signer accounts that can sign messages/transactions from the EVM node + /// Signer accounts that can sign messages/transactions from the EVM node. pub fn dev_accounts(&self) -> impl Iterator + '_ { self.config.signer_accounts.iter().map(|wallet| wallet.address()) } - /// Signer accounts that can sign messages/transactions from the EVM node + /// Signer accounts that can sign messages/transactions from the EVM node. pub fn dev_wallets(&self) -> impl Iterator + '_ { self.config.signer_accounts.iter().cloned() } - /// Accounts that will be initialised with `genesis_balance` in the genesis block + /// Accounts that will be initialised with `genesis_balance` in the genesis block. pub fn genesis_accounts(&self) -> impl Iterator + '_ { self.config.genesis_accounts.iter().map(|w| w.address()) } - /// Native token balance of every genesis account in the genesis block + /// Native token balance of every genesis account in the genesis block. pub fn genesis_balance(&self) -> U256 { self.config.genesis_balance } - /// Default gas price for all txs + /// Default gas price for all txs. pub fn gas_price(&self) -> u128 { self.config.get_gas_price() } - /// Returns the shutdown signal + /// Returns the shutdown signal. pub fn shutdown_signal(&self) -> &Option { &self._signal } - /// Returns mutable access to the shutdown signal + /// Returns mutable access to the shutdown signal. /// - /// This can be used to extract the Signal + /// This can be used to extract the Signal. pub fn shutdown_signal_mut(&mut self) -> &mut Option { &mut self._signal } - /// Returns the task manager that can be used to spawn new tasks + /// Returns the task manager that can be used to spawn new tasks. /// /// ``` /// use anvil::NodeHandle; diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 8038023130db2..0e8001853a95f 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -667,7 +667,7 @@ async fn can_remove_pool_transactions() { #[tokio::test(flavor = "multi_thread")] async fn test_reorg() { - let (api, mut handle) = spawn(NodeConfig::test()).await; + let (api, handle) = spawn(NodeConfig::test()).await; let provider = handle.ws_provider(); let accounts = handle.dev_wallets().collect::>(); @@ -792,8 +792,4 @@ async fn test_reorg() { }) .await; assert!(res.is_err()); - - if let Some(signal) = handle.shutdown_signal_mut().take() { - signal.fire().unwrap(); - } } diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index 6561e2ada1eaa..e80a52462875b 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -190,7 +190,7 @@ async fn test_tip_above_fee_cap() { #[tokio::test(flavor = "multi_thread")] async fn test_can_use_fee_history() { let base_fee = 50u128; - let (_api, mut handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; let provider = handle.http_provider(); for _ in 0..10 { @@ -215,8 +215,4 @@ async fn test_can_use_fee_history() { assert_eq!(latest_block.header.base_fee_per_gas.unwrap(), *latest_fee_history_fee); assert_eq!(latest_fee_history_fee, next_base_fee); } - - if let Some(signal) = handle.shutdown_signal_mut().take() { - signal.fire().unwrap(); - } } diff --git a/crates/anvil/tests/it/proof.rs b/crates/anvil/tests/it/proof.rs index 33c51b2e0b473..757d36082696d 100644 --- a/crates/anvil/tests/it/proof.rs +++ b/crates/anvil/tests/it/proof.rs @@ -122,7 +122,7 @@ async fn test_storage_proof() { #[tokio::test(flavor = "multi_thread")] async fn can_get_random_account_proofs() { - let (api, mut handle) = spawn(NodeConfig::test()).await; + let (api, _handle) = spawn(NodeConfig::test()).await; for acc in std::iter::repeat_with(Address::random).take(10) { let _ = api @@ -130,8 +130,4 @@ async fn can_get_random_account_proofs() { .await .unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}")); } - - if let Some(signal) = handle.shutdown_signal_mut().take() { - signal.fire().unwrap(); - } } diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index 9ab3045412c57..aaa2ca298d142 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -722,7 +722,7 @@ async fn test_trace_address_fork2() { #[tokio::test(flavor = "multi_thread")] async fn test_trace_filter() { - let (api, mut handle) = spawn(NodeConfig::test()).await; + let (api, handle) = spawn(NodeConfig::test()).await; let provider = handle.ws_provider(); let accounts = handle.dev_wallets().collect::>(); @@ -859,8 +859,4 @@ async fn test_trace_filter() { let traces = api.trace_filter(tracer).await.unwrap(); assert_eq!(traces.len(), 5); - - if let Some(signal) = handle.shutdown_signal_mut().take() { - signal.fire().unwrap(); - } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 3d3feba6766b8..42a2b51428157 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -204,18 +204,6 @@ forgetest_init!(can_override_config, |prj, cmd| { Remapping::from(config.remappings[0].clone()).to_string() ); - // env vars work - std::env::remove_var("DAPP_REMAPPINGS"); - std::env::set_var("DAPP_REMAPPINGS", "ds-test/=lib/forge-std/lib/ds-test/from-env/"); - let config = forge_utils::load_config_with_root(Some(prj.root())); - assert_eq!( - format!( - "ds-test/={}/", - prj.root().join("lib/forge-std/lib/ds-test/from-env").to_slash_lossy() - ), - Remapping::from(config.remappings[0].clone()).to_string() - ); - let config = prj.config_from_output(["--remappings", "ds-test/=lib/forge-std/lib/ds-test/from-cli"]); assert_eq!( @@ -234,7 +222,6 @@ forgetest_init!(can_override_config, |prj, cmd| { Remapping::from(config.remappings[0].clone()).to_string() ); - std::env::remove_var("DAPP_REMAPPINGS"); pretty_err(&remappings_txt, fs::remove_file(&remappings_txt)); let expected = profile.into_basic().to_string_pretty().unwrap().trim().to_string(); @@ -506,7 +493,6 @@ forgetest!(can_set_gas_price, |prj, cmd| { // test that we can detect remappings from foundry.toml forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { - std::env::remove_var("DAPP_REMAPPINGS"); let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); similar_asserts::assert_eq!( @@ -518,7 +504,6 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { ); // create a new lib directly in the `lib` folder with a remapping - std::env::remove_var("DAPP_REMAPPINGS"); let mut config = config; config.remappings = vec![Remapping::from_str("nested/=lib/nested").unwrap().into()]; let nested = prj.paths().libraries[0].join("nested-lib"); @@ -526,7 +511,6 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let toml_file = nested.join("foundry.toml"); pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); - std::env::remove_var("DAPP_REMAPPINGS"); let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); similar_asserts::assert_eq!( @@ -549,7 +533,6 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { let toml_file = nested.join("foundry.toml"); pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); - std::env::remove_var("DAPP_REMAPPINGS"); let another_config = cmd.config(); let remappings = another_config.remappings.iter().cloned().map(Remapping::from).collect::>(); @@ -569,7 +552,6 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { config.src = "custom-source-dir".into(); pretty_err(&toml_file, fs::write(&toml_file, config.to_string_pretty().unwrap())); - std::env::remove_var("DAPP_REMAPPINGS"); let config = cmd.config(); let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); similar_asserts::assert_eq!( From c59d97e8c1994684062f69305ce7cfacd52fceff Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:16:13 +0530 Subject: [PATCH 1490/1963] feat(`cheatcodes`): `getArtifactPathByCode` and `getArtifactPathByDeployedCode` (#8938) * feat(`cheatcodes`): vm.getArtifactPath * cargo cheats * nit * nit * fix * test: vm.getArtifactPath * feat: vm.getArtifactPath(creationCode) * cheats * nit * change seed * rm vm.getArtifactPath(contractName) * fmt * nit * fix * nit * rename * nit * fix --------- Co-authored-by: grandizzy --- crates/cheatcodes/assets/cheatcodes.json | 40 +++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 8 ++++ crates/cheatcodes/src/fs.rs | 28 +++++++++++++ testdata/cheats/Vm.sol | 2 + testdata/default/cheats/GetArtifactPath.t.sol | 37 +++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 testdata/default/cheats/GetArtifactPath.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d40d7353e356f..d3a0d49ed8a8d 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5011,6 +5011,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getArtifactPathByCode", + "description": "Gets the artifact path from code (aka. creation code).", + "declaration": "function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);", + "visibility": "external", + "mutability": "view", + "signature": "getArtifactPathByCode(bytes)", + "selector": "0xeb74848c", + "selectorBytes": [ + 235, + 116, + 132, + 140 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getArtifactPathByDeployedCode", + "description": "Gets the artifact path from deployed code (aka. runtime code).", + "declaration": "function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);", + "visibility": "external", + "mutability": "view", + "signature": "getArtifactPathByDeployedCode(bytes)", + "selector": "0x6d853ba5", + "selectorBytes": [ + 109, + 133, + 59, + 165 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "getBlobBaseFee", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 5fbd94ce00ed0..f518d9471fb47 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1531,6 +1531,14 @@ interface Vm { #[cheatcode(group = Filesystem)] function writeLine(string calldata path, string calldata data) external; + /// Gets the artifact path from code (aka. creation code). + #[cheatcode(group = Filesystem)] + function getArtifactPathByCode(bytes calldata code) external view returns (string memory path); + + /// Gets the artifact path from deployed code (aka. runtime code). + #[cheatcode(group = Filesystem)] + function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path); + /// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the /// artifact in the form of :: where and parts are optional. #[cheatcode(group = Filesystem)] diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index da69094017422..4185b2d799976 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -250,6 +250,34 @@ impl Cheatcode for writeLineCall { } } +impl Cheatcode for getArtifactPathByCodeCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { code } = self; + let (artifact_id, _) = state + .config + .available_artifacts + .as_ref() + .and_then(|artifacts| artifacts.find_by_creation_code(code)) + .ok_or_else(|| fmt_err!("no matching artifact found"))?; + + Ok(artifact_id.path.to_string_lossy().abi_encode()) + } +} + +impl Cheatcode for getArtifactPathByDeployedCodeCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { deployedCode } = self; + let (artifact_id, _) = state + .config + .available_artifacts + .as_ref() + .and_then(|artifacts| artifacts.find_by_deployed_code(deployedCode)) + .ok_or_else(|| fmt_err!("no matching artifact found"))?; + + Ok(artifact_id.path.to_string_lossy().abi_encode()) + } +} + impl Cheatcode for getCodeCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { artifactPath: path } = self; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 7316521ecb32f..459b16c8cca30 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -246,6 +246,8 @@ interface Vm { function fee(uint256 newBasefee) external; function ffi(string[] calldata commandInput) external returns (bytes memory result); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); + function getArtifactPathByCode(bytes calldata code) external view returns (string memory path); + function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path); function getBlobBaseFee() external view returns (uint256 blobBaseFee); function getBlobhashes() external view returns (bytes32[] memory hashes); function getBlockNumber() external view returns (uint256 height); diff --git a/testdata/default/cheats/GetArtifactPath.t.sol b/testdata/default/cheats/GetArtifactPath.t.sol new file mode 100644 index 0000000000000..d92d41e01ae4e --- /dev/null +++ b/testdata/default/cheats/GetArtifactPath.t.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract DummyForGetArtifactPath {} + +contract GetArtifactPathTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testGetArtifactPathByCode() public { + DummyForGetArtifactPath dummy = new DummyForGetArtifactPath(); + bytes memory dummyCreationCode = type(DummyForGetArtifactPath).creationCode; + + string memory root = vm.projectRoot(); + string memory path = vm.getArtifactPathByCode(dummyCreationCode); + + string memory expectedPath = + string.concat(root, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json"); + + assertEq(path, expectedPath); + } + + function testGetArtifactPathByDeployedCode() public { + DummyForGetArtifactPath dummy = new DummyForGetArtifactPath(); + bytes memory dummyRuntimeCode = address(dummy).code; + + string memory root = vm.projectRoot(); + string memory path = vm.getArtifactPathByDeployedCode(dummyRuntimeCode); + + string memory expectedPath = + string.concat(root, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json"); + + assertEq(path, expectedPath); + } +} From a0ff7bd3334073819d41934451f67f3323016480 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:49:57 +0300 Subject: [PATCH 1491/1963] chore: fix base gas limit test and clippy (#8961) --- crates/anvil/src/eth/backend/mem/storage.rs | 2 ++ crates/anvil/tests/it/fork.rs | 4 ++-- crates/anvil/tests/it/main.rs | 2 ++ crates/cast/bin/main.rs | 1 + crates/cast/src/rlp_converter.rs | 2 +- crates/cheatcodes/src/test/expect.rs | 2 +- crates/chisel/bin/main.rs | 1 + crates/common/src/selectors.rs | 2 ++ crates/evm/core/src/backend/mod.rs | 2 ++ crates/evm/core/src/fork/database.rs | 2 ++ crates/evm/traces/src/identifier/signatures.rs | 2 ++ crates/forge/bin/cmd/clone.rs | 2 ++ crates/forge/bin/cmd/doc/server.rs | 1 + crates/forge/tests/it/main.rs | 2 ++ crates/script/src/sequence.rs | 3 +-- crates/test-utils/src/rpc.rs | 2 ++ crates/verify/src/etherscan/mod.rs | 2 ++ crates/wallets/src/wallet.rs | 2 ++ 18 files changed, 30 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 9afc9f66919a2..4cb588221ae84 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -575,6 +575,8 @@ pub struct MinedTransactionReceipt { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use super::*; use crate::eth::backend::db::Db; use alloy_primitives::{hex, Address}; diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 8d5b0c588d184..3f96513c5c8e9 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1289,8 +1289,8 @@ async fn test_base_fork_gas_limit() { .unwrap() .unwrap(); - assert_eq!(api.gas_limit(), uint!(120_000_000_U256)); - assert_eq!(block.header.gas_limit, 120_000_000_u128); + assert!(api.gas_limit() >= uint!(132_000_000_U256)); + assert!(block.header.gas_limit >= 132_000_000_u128); } // diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index f3f5eca157707..256edb813898b 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::needless_return)] + mod abi; mod anvil; mod anvil_api; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 27a052fe6ccc1..0b861f90d02a5 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -42,6 +42,7 @@ fn main() -> Result<()> { main_args(args) } +#[allow(clippy::needless_return)] #[tokio::main] async fn main_args(args: CastArgs) -> Result<()> { match args.cmd { diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index ad17874380468..05e3462cb8260 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -47,7 +47,7 @@ impl Decodable for Item { impl Item { pub(crate) fn value_to_item(value: &Value) -> eyre::Result { - return match value { + match value { Value::Null => Ok(Self::Data(vec![])), Value::Bool(_) => { eyre::bail!("RLP input can not contain booleans") diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 066c900b3ae36..f38776f94bfd5 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -597,7 +597,7 @@ pub(crate) fn handle_expect_emit( let Some(expected) = &event_to_fill_or_check.log else { // Unless the caller is trying to match an anonymous event, the first topic must be // filled. - if event_to_fill_or_check.anonymous || log.topics().first().is_some() { + if event_to_fill_or_check.anonymous || !log.topics().is_empty() { event_to_fill_or_check.log = Some(log.data.clone()); // If we only filled the expected log then we put it back at the same position. state.expected_emits.insert(index_to_fill_or_check, event_to_fill_or_check); diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 7a0703e85c2ee..ba4d7e9bc336b 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -102,6 +102,7 @@ fn main() -> eyre::Result<()> { main_args(args) } +#[allow(clippy::needless_return)] #[tokio::main] async fn main_args(args: Chisel) -> eyre::Result<()> { // Keeps track of whether or not an interrupt was the last input diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index c22ee3076578c..16565a07e8e62 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -581,6 +581,8 @@ pub fn parse_signatures(tokens: Vec) -> ParsedSignatures { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use super::*; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 4d1d7d9efeb8f..6fbd2086dde80 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1979,6 +1979,8 @@ fn apply_state_changeset( #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use crate::{backend::Backend, fork::CreateFork, opts::EvmOpts}; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index de6b2a6b9f22e..873e8a8962ab2 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -263,6 +263,8 @@ impl DatabaseRef for ForkDbSnapshot { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use super::*; use crate::backend::BlockchainDbMeta; use foundry_common::provider::get_http_provider; diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 2a2f6a2f24733..498385ef19a44 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -162,6 +162,8 @@ impl Drop for SignaturesIdentifier { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use super::*; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 98ef95d40e2d1..f3879b931b778 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -609,6 +609,8 @@ impl EtherscanClient for Client { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use super::*; use alloy_primitives::hex; use foundry_compilers::Artifact; diff --git a/crates/forge/bin/cmd/doc/server.rs b/crates/forge/bin/cmd/doc/server.rs index f5991ba438377..72585a2bf4ed7 100644 --- a/crates/forge/bin/cmd/doc/server.rs +++ b/crates/forge/bin/cmd/doc/server.rs @@ -90,6 +90,7 @@ impl Server { } } +#[allow(clippy::needless_return)] #[tokio::main] async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) -> io::Result<()> { let file_404 = build_dir.join(file_404); diff --git a/crates/forge/tests/it/main.rs b/crates/forge/tests/it/main.rs index aaa129796a39a..ba1cff382da69 100644 --- a/crates/forge/tests/it/main.rs +++ b/crates/forge/tests/it/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::needless_return)] + pub mod config; pub mod test_helpers; diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 53212f4ebf3bb..8e21011554916 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -374,8 +374,7 @@ impl ScriptSequence { /// Converts the `sig` argument into the corresponding file path. /// -/// This accepts either the signature of the function or the raw calldata - +/// This accepts either the signature of the function or the raw calldata. pub fn sig_to_file_name(sig: &str) -> String { if let Some((name, _)) = sig.split_once('(') { // strip until call argument parenthesis diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 6f91be10ff70e..51ec2c8e0ee11 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -178,6 +178,8 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use super::*; use alloy_primitives::address; use foundry_config::Chain; diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 0a1d39c1956a1..3839b845b39e5 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -452,6 +452,8 @@ async fn ensure_solc_build_metadata(version: Version) -> Result { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use super::*; use clap::Parser; use foundry_common::fs; diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 14a9f74221105..37b731ddb1429 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -149,6 +149,8 @@ impl From for WalletOpts { #[cfg(test)] mod tests { + #![allow(clippy::needless_return)] + use alloy_signer::Signer; use std::{path::Path, str::FromStr}; From d15d71ac0182e41091631225fcbb517926eda3fa Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:36:29 +0300 Subject: [PATCH 1492/1963] feat(cheatcodes): random* cheatcodes to aid in symbolic testing (#8882) * feat(cheatcodes): additional random cheatcodes to aid in symbolic testing * Use arbitraryUint/address in tests * Test changes after review * Fix test * Add deprecated replacements * Changes after review: - add fn rng back - make sure cheats for uint/int/bytes doesn't panic + added tests * Update crates/cheatcodes/spec/src/vm.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Cargo cheats * Fix test * Rename Arbitrary -> Random * Review changes: simplify randomBytes and bool --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/Cargo.toml | 2 - crates/cheatcodes/assets/cheatcodes.json | 102 ++++++++++++++- crates/cheatcodes/spec/src/vm.rs | 22 +++- crates/cheatcodes/src/inspector.rs | 23 ++-- crates/cheatcodes/src/utils.rs | 117 ++++++++++++++---- testdata/cheats/Vm.sol | 5 + .../default/cheats/ArbitraryStorage.t.sol | 12 +- testdata/default/cheats/CopyStorage.t.sol | 4 +- .../default/cheats/RandomCheatcodes.t.sol | 104 ++++++++++++++++ 9 files changed, 351 insertions(+), 40 deletions(-) create mode 100644 testdata/default/cheats/RandomCheatcodes.t.sol diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 412c5b898768e..cbf66d684ee18 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -65,6 +65,4 @@ thiserror.workspace = true toml = { workspace = true, features = ["preserve_order"] } tracing.workspace = true walkdir.workspace = true - -[dev-dependencies] proptest.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d3a0d49ed8a8d..451ce6cb44c30 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6953,6 +6953,86 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "randomBool", + "description": "Returns an random `bool`.", + "declaration": "function randomBool() external view returns (bool);", + "visibility": "external", + "mutability": "view", + "signature": "randomBool()", + "selector": "0xcdc126bd", + "selectorBytes": [ + 205, + 193, + 38, + 189 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "randomBytes", + "description": "Returns an random byte array value of the given length.", + "declaration": "function randomBytes(uint256 len) external view returns (bytes memory);", + "visibility": "external", + "mutability": "view", + "signature": "randomBytes(uint256)", + "selector": "0x6c5d32a9", + "selectorBytes": [ + 108, + 93, + 50, + 169 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "randomInt_0", + "description": "Returns an random `int256` value.", + "declaration": "function randomInt() external view returns (int256);", + "visibility": "external", + "mutability": "view", + "signature": "randomInt()", + "selector": "0x111f1202", + "selectorBytes": [ + 17, + 31, + 18, + 2 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "randomInt_1", + "description": "Returns an random `int256` value of given bits.", + "declaration": "function randomInt(uint256 bits) external view returns (int256);", + "visibility": "external", + "mutability": "view", + "signature": "randomInt(uint256)", + "selector": "0x12845966", + "selectorBytes": [ + 18, + 132, + 89, + 102 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "randomUint_0", @@ -6976,7 +7056,7 @@ { "func": { "id": "randomUint_1", - "description": "Returns random uin256 value between the provided range (=min..=max).", + "description": "Returns random uint256 value between the provided range (=min..=max).", "declaration": "function randomUint(uint256 min, uint256 max) external returns (uint256);", "visibility": "external", "mutability": "", @@ -6993,6 +7073,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "randomUint_2", + "description": "Returns an random `uint256` value of given bits.", + "declaration": "function randomUint(uint256 bits) external view returns (uint256);", + "visibility": "external", + "mutability": "view", + "signature": "randomUint(uint256)", + "selector": "0xcf81e69c", + "selectorBytes": [ + 207, + 129, + 230, + 156 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readCallers", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index f518d9471fb47..a53d4f908d793 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2337,14 +2337,34 @@ interface Vm { #[cheatcode(group = Utilities)] function randomUint() external returns (uint256); - /// Returns random uin256 value between the provided range (=min..=max). + /// Returns random uint256 value between the provided range (=min..=max). #[cheatcode(group = Utilities)] function randomUint(uint256 min, uint256 max) external returns (uint256); + /// Returns an random `uint256` value of given bits. + #[cheatcode(group = Utilities)] + function randomUint(uint256 bits) external view returns (uint256); + /// Returns a random `address`. #[cheatcode(group = Utilities)] function randomAddress() external returns (address); + /// Returns an random `int256` value. + #[cheatcode(group = Utilities)] + function randomInt() external view returns (int256); + + /// Returns an random `int256` value of given bits. + #[cheatcode(group = Utilities)] + function randomInt(uint256 bits) external view returns (int256); + + /// Returns an random `bool`. + #[cheatcode(group = Utilities)] + function randomBool() external view returns (bool); + + /// Returns an random byte array value of the given length. + #[cheatcode(group = Utilities)] + function randomBytes(uint256 len) external view returns (bytes memory); + /// Pauses collection of call traces. Useful in cases when you want to skip tracing of /// complex calls which are not useful for debugging. #[cheatcode(group = Utilities)] diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 5f4ee94080cf9..58d8ca5c9e704 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -34,7 +34,8 @@ use foundry_evm_core::{ }; use foundry_evm_traces::TracingInspector; use itertools::Itertools; -use rand::{rngs::StdRng, Rng, SeedableRng}; +use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; +use rand::Rng; use revm::{ interpreter::{ opcode as op, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, @@ -439,8 +440,9 @@ pub struct Cheatcodes { /// `char -> (address, pc)` pub breakpoints: Breakpoints, - /// Optional RNG algorithm. - rng: Option, + /// Optional cheatcodes `TestRunner`. Used for generating random values from uint and int + /// strategies. + test_runner: Option, /// Ignored traces. pub ignored_traces: IgnoredTraces, @@ -491,7 +493,7 @@ impl Cheatcodes { mapping_slots: Default::default(), pc: Default::default(), breakpoints: Default::default(), - rng: Default::default(), + test_runner: Default::default(), ignored_traces: Default::default(), arbitrary_storage: Default::default(), deprecated: Default::default(), @@ -1068,9 +1070,16 @@ impl Cheatcodes { } pub fn rng(&mut self) -> &mut impl Rng { - self.rng.get_or_insert_with(|| match self.config.seed { - Some(seed) => StdRng::from_seed(seed.to_be_bytes::<32>()), - None => StdRng::from_entropy(), + self.test_runner().rng() + } + + pub fn test_runner(&mut self) -> &mut TestRunner { + self.test_runner.get_or_insert_with(|| match self.config.seed { + Some(seed) => TestRunner::new_with_rng( + proptest::test_runner::Config::default(), + TestRng::from_seed(RngAlgorithm::ChaCha, &seed.to_be_bytes::<32>()), + ), + None => TestRunner::new(proptest::test_runner::Config::default()), }) } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index a96a44832a5e9..b4e32748354ac 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -1,11 +1,13 @@ //! Implementations of [`Utilities`](spec::Group::Utilities) cheatcodes. use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; -use alloy_primitives::{Address, U256}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; +use alloy_primitives::U256; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; use foundry_evm_core::{backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER}; -use rand::Rng; +use proptest::strategy::{Strategy, ValueTree}; +use rand::{Rng, RngCore}; use std::collections::HashMap; /// Contains locations of traces ignored via cheatcodes. @@ -71,36 +73,64 @@ impl Cheatcode for ensNamehashCall { impl Cheatcode for randomUint_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { - let Self {} = self; - let rng = state.rng(); - let random_number: U256 = rng.gen(); - Ok(random_number.abi_encode()) + random_uint(state, None, None) } } impl Cheatcode for randomUint_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { min, max } = *self; - ensure!(min <= max, "min must be less than or equal to max"); - // Generate random between range min..=max - let exclusive_modulo = max - min; - let rng = state.rng(); - let mut random_number = rng.gen::(); - if exclusive_modulo != U256::MAX { - let inclusive_modulo = exclusive_modulo + U256::from(1); - random_number %= inclusive_modulo; - } - random_number += min; - Ok(random_number.abi_encode()) + random_uint(state, None, Some((min, max))) + } +} + +impl Cheatcode for randomUint_2Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { bits } = *self; + random_uint(state, Some(bits), None) } } impl Cheatcode for randomAddressCall { fn apply(&self, state: &mut Cheatcodes) -> Result { - let Self {} = self; - let rng = state.rng(); - let addr = Address::random_with(rng); - Ok(addr.abi_encode()) + Ok(DynSolValue::type_strategy(&DynSolType::Address) + .new_tree(state.test_runner()) + .unwrap() + .current() + .abi_encode()) + } +} + +impl Cheatcode for randomInt_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + random_int(state, None) + } +} + +impl Cheatcode for randomInt_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { bits } = *self; + random_int(state, Some(bits)) + } +} + +impl Cheatcode for randomBoolCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let rand_bool: bool = state.rng().gen(); + Ok(rand_bool.abi_encode()) + } +} + +impl Cheatcode for randomBytesCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { len } = *self; + ensure!( + len <= U256::from(usize::MAX), + format!("bytes length cannot exceed {}", usize::MAX) + ); + let mut bytes = vec![0u8; len.to::()]; + state.rng().fill_bytes(&mut bytes); + Ok(bytes.abi_encode()) } } @@ -181,3 +211,48 @@ impl Cheatcode for copyStorageCall { Ok(Default::default()) } } + +/// Helper to generate a random `uint` value (with given bits or bounded if specified) +/// from type strategy. +fn random_uint(state: &mut Cheatcodes, bits: Option, bounds: Option<(U256, U256)>) -> Result { + if let Some(bits) = bits { + // Generate random with specified bits. + ensure!(bits <= U256::from(256), "number of bits cannot exceed 256"); + return Ok(DynSolValue::type_strategy(&DynSolType::Uint(bits.to::())) + .new_tree(state.test_runner()) + .unwrap() + .current() + .abi_encode()) + } + + if let Some((min, max)) = bounds { + ensure!(min <= max, "min must be less than or equal to max"); + // Generate random between range min..=max + let exclusive_modulo = max - min; + let mut random_number: U256 = state.rng().gen(); + if exclusive_modulo != U256::MAX { + let inclusive_modulo = exclusive_modulo + U256::from(1); + random_number %= inclusive_modulo; + } + random_number += min; + return Ok(random_number.abi_encode()) + } + + // Generate random `uint256` value. + Ok(DynSolValue::type_strategy(&DynSolType::Uint(256)) + .new_tree(state.test_runner()) + .unwrap() + .current() + .abi_encode()) +} + +/// Helper to generate a random `int` value (with given bits if specified) from type strategy. +fn random_int(state: &mut Cheatcodes, bits: Option) -> Result { + let no_bits = bits.unwrap_or(U256::from(256)); + ensure!(no_bits <= U256::from(256), "number of bits cannot exceed 256"); + Ok(DynSolValue::type_strategy(&DynSolType::Int(no_bits.to::())) + .new_tree(state.test_runner()) + .unwrap() + .current() + .abi_encode()) +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 459b16c8cca30..2b93473827ebf 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -343,8 +343,13 @@ interface Vm { function promptUint(string calldata promptText) external returns (uint256); function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY); function randomAddress() external returns (address); + function randomBool() external view returns (bool); + function randomBytes(uint256 len) external view returns (bytes memory); + function randomInt() external view returns (int256); + function randomInt(uint256 bits) external view returns (int256); function randomUint() external returns (uint256); function randomUint(uint256 min, uint256 max) external returns (uint256); + function randomUint(uint256 bits) external view returns (uint256); 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); diff --git a/testdata/default/cheats/ArbitraryStorage.t.sol b/testdata/default/cheats/ArbitraryStorage.t.sol index 86910279e98e0..f763ab7af5a5a 100644 --- a/testdata/default/cheats/ArbitraryStorage.t.sol +++ b/testdata/default/cheats/ArbitraryStorage.t.sol @@ -83,10 +83,10 @@ contract AContractArbitraryStorageWithSeedTest is DSTest { function test_arbitrary_storage_with_seed() public { AContract target = new AContract(); vm.setArbitraryStorage(address(target)); - assertEq(target.a(11), 85286582241781868037363115933978803127245343755841464083427462398552335014708); - assertEq(target.b(22), 0x939180Daa938F9e18Ff0E76c112D25107D358B02); - assertEq(target.c(33), -104); - assertEq(target.d(44), 0x6c178fa9c434f142df61a5355cc2b8d07be691b98dabf5b1a924f2bce97a19c7); + assertEq(target.a(11), 112807530564575719000382171275495171195982096112439764207649185248041477080234); + assertEq(target.b(22), 0x9dce87df97C81f2529877E8127b4b8c13E4b2b31); + assertEq(target.c(33), 85); + assertEq(target.d(44), 0x6ceda712fc9d694d72afeea6c44d370b789a18e1a3d640068c11069e421d25f6); } } @@ -104,7 +104,7 @@ contract SymbolicStorageWithSeedTest is DSTest { address addr = 0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8; vm.setArbitraryStorage(addr); bytes32 value = vm.load(addr, bytes32(slot)); - assertEq(uint256(value), 85286582241781868037363115933978803127245343755841464083427462398552335014708); + assertEq(uint256(value), 112807530564575719000382171275495171195982096112439764207649185248041477080234); // Load slot again and make sure we get same value. bytes32 value1 = vm.load(addr, bytes32(slot)); assertEq(uint256(value), uint256(value1)); @@ -115,7 +115,7 @@ contract SymbolicStorageWithSeedTest is DSTest { SymbolicStore myStore = new SymbolicStore(); vm.setArbitraryStorage(address(myStore)); bytes32 value = vm.load(address(myStore), bytes32(uint256(slot))); - assertEq(uint256(value), 85286582241781868037363115933978803127245343755841464083427462398552335014708); + assertEq(uint256(value), 112807530564575719000382171275495171195982096112439764207649185248041477080234); } function testEmptyInitialStorage(uint256 slot) public { diff --git a/testdata/default/cheats/CopyStorage.t.sol b/testdata/default/cheats/CopyStorage.t.sol index 89584749745ea..3ca5d8dab88b9 100644 --- a/testdata/default/cheats/CopyStorage.t.sol +++ b/testdata/default/cheats/CopyStorage.t.sol @@ -57,8 +57,8 @@ contract CounterWithSeedTest is DSTest { counter.setA(1000); counter1.setB(address(50)); assertEq(counter.a(), 1000); - assertEq(counter1.a(), 40426841063417815470953489044557166618267862781491517122018165313568904172524); - assertEq(counter.b(), 0x485E9Cc0ef187E54A3AB45b50c3DcE43f2C223B1); + assertEq(counter1.a(), 67350900536747027229585709178274816969402970928486983076982664581925078789474); + assertEq(counter.b(), 0x5A61ACa23C478d83A72425c386Eb5dB083FBd0e4); assertEq(counter1.b(), address(50)); } } diff --git a/testdata/default/cheats/RandomCheatcodes.t.sol b/testdata/default/cheats/RandomCheatcodes.t.sol new file mode 100644 index 0000000000000..4f7d559fa8812 --- /dev/null +++ b/testdata/default/cheats/RandomCheatcodes.t.sol @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract RandomCheatcodesTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + int128 constant min = -170141183460469231731687303715884105728; + int128 constant max = 170141183460469231731687303715884105727; + + function test_int128() public { + vm.expectRevert("vm.randomInt: number of bits cannot exceed 256"); + int256 val = vm.randomInt(type(uint256).max); + + val = vm.randomInt(128); + assertGe(val, min); + assertLe(val, max); + } + + function testFail_int128() public { + int256 val = vm.randomInt(128); + assertGt(val, max); + } + + function test_address() public { + address fresh_address = vm.randomAddress(); + assert(fresh_address != address(this)); + assert(fresh_address != address(vm)); + } + + function test_randomUintLimit() public { + vm.expectRevert("vm.randomUint: number of bits cannot exceed 256"); + uint256 val = vm.randomUint(type(uint256).max); + } + + function test_randomUints(uint256 x) public { + x = vm.randomUint(0, 256); + uint256 freshUint = vm.randomUint(x); + + assert(0 <= freshUint); + if (x == 256) { + assert(freshUint <= type(uint256).max); + } else { + assert(freshUint <= 2 ** x - 1); + } + } + + function test_randomSymbolicWord() public { + uint256 freshUint192 = vm.randomUint(192); + + assert(0 <= freshUint192); + assert(freshUint192 <= type(uint192).max); + } +} + +contract RandomBytesTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + bytes1 local_byte; + bytes local_bytes; + + function manip_symbolic_bytes(bytes memory b) public { + uint256 middle = b.length / 2; + b[middle] = hex"aa"; + } + + function test_symbolic_bytes_revert() public { + vm.expectRevert(); + bytes memory val = vm.randomBytes(type(uint256).max); + } + + function test_symbolic_bytes_1() public { + uint256 length = uint256(vm.randomUint(1, type(uint8).max)); + bytes memory fresh_bytes = vm.randomBytes(length); + uint256 index = uint256(vm.randomUint(1)); + + local_byte = fresh_bytes[index]; + assertEq(fresh_bytes[index], local_byte); + } + + function test_symbolic_bytes_2() public { + uint256 length = uint256(vm.randomUint(1, type(uint8).max)); + bytes memory fresh_bytes = vm.randomBytes(length); + + local_bytes = fresh_bytes; + assertEq(fresh_bytes, local_bytes); + } + + function test_symbolic_bytes_3() public { + uint256 length = uint256(vm.randomUint(1, type(uint8).max)); + bytes memory fresh_bytes = vm.randomBytes(length); + + manip_symbolic_bytes(fresh_bytes); + assertEq(hex"aa", fresh_bytes[length / 2]); + } + + function test_symbolic_bytes_length(uint8 l) public { + vm.assume(0 < l); + bytes memory fresh_bytes = vm.randomBytes(l); + assertEq(fresh_bytes.length, l); + } +} From f7e920488846629ba4977063d43b37a544d653a1 Mon Sep 17 00:00:00 2001 From: Drake Evans <31104161+DrakeEvans@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:55:02 -0400 Subject: [PATCH 1493/1963] =?UTF-8?q?feat:=20use=20multi-architecture=20im?= =?UTF-8?q?ages=20in=20Dockerfile=20to=20support=20apple=20si=E2=80=A6=20(?= =?UTF-8?q?#8964)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: use multi-architecture images in Dockerfile to support apple silicon --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index cbdf08b258464..87e52b70861c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,9 +30,9 @@ RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/r && strip out/chisel \ && strip out/anvil; -FROM docker.io/frolvlad/alpine-glibc:alpine-3.16_glibc-2.34 as foundry-client +FROM alpine:3.18 as foundry-client -RUN apk add --no-cache linux-headers git +RUN apk add --no-cache linux-headers git gcompat libstdc++ COPY --from=build-environment /opt/foundry/out/forge /usr/local/bin/forge COPY --from=build-environment /opt/foundry/out/cast /usr/local/bin/cast From e485eebec933d5e615fe968264e58ca4adfd951d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 26 Sep 2024 20:55:36 +0300 Subject: [PATCH 1494/1963] fix: enable `revm/blst` (#8965) * fix: enable revm/blst * fix * fix --- Cargo.lock | 1 + crates/evm/core/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 84194dfafb24e..5a9f4a3b2cb1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7194,6 +7194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f73010c271d53fa7904e9845338e95f3955eb1200a0355e0abfdb89c41aaa9cd" dependencies = [ "aurora-engine-modexp", + "blst", "c-kzg", "cfg-if", "k256", diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 6fbf674535f65..ce06dc9d0ea8a 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -45,6 +45,7 @@ revm = { workspace = true, features = [ "arbitrary", "optimism", "c-kzg", + "blst", ] } revm-inspectors.workspace = true From 9dbfb2f1115466b28f2697e158131f90df6b2590 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 26 Sep 2024 20:14:45 +0200 Subject: [PATCH 1495/1963] test: redact forge version (#8967) --- crates/forge/tests/cli/cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 1144830c52ba1..8179e9eaa5537 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -276,7 +276,7 @@ forgetest!(can_init_no_git, |prj, cmd| { cmd.arg("init").arg(prj.root()).arg("--no-git").assert_success().stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std + Installed forge-std [..] Initialized forge project "#]]); From 98bcd8e115bb542e28cbc1b9df7263c472ea2f04 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 09:49:44 +0000 Subject: [PATCH 1496/1963] chore(tests): bump forge-std version (#8970) chore: bump forge-std version used for tests Co-authored-by: DaniPopes --- testdata/forge-std-rev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/forge-std-rev b/testdata/forge-std-rev index 239d2091e283b..c6c6e2da6a63d 100644 --- a/testdata/forge-std-rev +++ b/testdata/forge-std-rev @@ -1 +1 @@ -1714bee72e286e73f76e320d110e0eaf5c4e649d \ No newline at end of file +8f24d6b04c92975e0795b5868aa0d783251cdeaa \ No newline at end of file From 658bb88a7228189f1724048c7078929dcb934938 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:18:20 +0200 Subject: [PATCH 1497/1963] chore(traces): remove unreachable decoding of expectRevert (#8969) * chore(traces): remove unreachable decoding of expectRevert * chore: clippy --- crates/cheatcodes/spec/src/vm.rs | 15 +++++++++ crates/evm/core/src/decode.rs | 52 +++----------------------------- 2 files changed, 20 insertions(+), 47 deletions(-) diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index a53d4f908d793..22500ec980a68 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -6,6 +6,7 @@ use super::*; use crate::Vm::ForgeContext; use alloy_sol_types::sol; use foundry_macros::Cheatcode; +use std::fmt; sol! { // Cheatcodes are marked as view/pure/none using the following rules: @@ -2407,6 +2408,20 @@ impl PartialEq for ForgeContext { } } +impl fmt::Display for Vm::CheatcodeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.message.fmt(f) + } +} + +impl fmt::Display for Vm::VmErrors { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::CheatcodeError(err) => err.fmt(f), + } + } +} + #[track_caller] const fn panic_unknown_safety() -> ! { panic!("cannot determine safety from the group, add a `#[cheatcode(safety = ...)]` attribute") diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 5f3e86281ef95..95fcaf02a38b8 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -4,7 +4,7 @@ use crate::abi::{Console, Vm}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::{Error, JsonAbi}; use alloy_primitives::{hex, Log, Selector}; -use alloy_sol_types::{SolCall, SolError, SolEventInterface, SolInterface, SolValue}; +use alloy_sol_types::{SolEventInterface, SolInterface, SolValue}; use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; @@ -139,7 +139,7 @@ impl RevertDecoder { /// /// See [`decode`](Self::decode) for more information. pub fn maybe_decode(&self, err: &[u8], status: Option) -> Option { - if err.len() < SELECTOR_LEN { + let Some((selector, data)) = err.split_first_chunk::() else { if let Some(status) = status { if !status.is_ok() { return Some(format!("EvmError: {status:?}")); @@ -150,59 +150,17 @@ impl RevertDecoder { } else { Some(format!("custom error bytes {}", hex::encode_prefixed(err))) }; - } + }; if let Some(reason) = SkipReason::decode(err) { return Some(reason.to_string()); } - // Solidity's `Error(string)` or `Panic(uint256)` - if let Ok(e) = alloy_sol_types::GenericContractError::abi_decode(err, false) { + // Solidity's `Error(string)` or `Panic(uint256)`, or `Vm`'s custom errors. + if let Ok(e) = alloy_sol_types::ContractError::::abi_decode(err, false) { return Some(e.to_string()); } - let (selector, data) = err.split_at(SELECTOR_LEN); - let selector: &[u8; 4] = selector.try_into().unwrap(); - - match *selector { - // `CheatcodeError(string)` - Vm::CheatcodeError::SELECTOR => { - let e = Vm::CheatcodeError::abi_decode_raw(data, false).ok()?; - return Some(e.message); - } - // `expectRevert(bytes)` - Vm::expectRevert_2Call::SELECTOR => { - let e = Vm::expectRevert_2Call::abi_decode_raw(data, false).ok()?; - return self.maybe_decode(&e.revertData[..], status); - } - // `expectRevert(bytes,address)` - Vm::expectRevert_5Call::SELECTOR => { - let e = Vm::expectRevert_5Call::abi_decode_raw(data, false).ok()?; - return self.maybe_decode(&e.revertData[..], status); - } - // `expectRevert(bytes4)` - Vm::expectRevert_1Call::SELECTOR => { - let e = Vm::expectRevert_1Call::abi_decode_raw(data, false).ok()?; - return self.maybe_decode(&e.revertData[..], status); - } - // `expectRevert(bytes4,address)` - Vm::expectRevert_4Call::SELECTOR => { - let e = Vm::expectRevert_4Call::abi_decode_raw(data, false).ok()?; - return self.maybe_decode(&e.revertData[..], status); - } - // `expectPartialRevert(bytes4)` - Vm::expectPartialRevert_0Call::SELECTOR => { - let e = Vm::expectPartialRevert_0Call::abi_decode_raw(data, false).ok()?; - return self.maybe_decode(&e.revertData[..], status); - } - // `expectPartialRevert(bytes4,address)` - Vm::expectPartialRevert_1Call::SELECTOR => { - let e = Vm::expectPartialRevert_1Call::abi_decode_raw(data, false).ok()?; - return self.maybe_decode(&e.revertData[..], status); - } - _ => {} - } - // Custom errors. if let Some(errors) = self.errors.get(selector) { for error in errors { From 20cb9038e203c2f11162e9e3b91db22f25a71c76 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:23:26 +0300 Subject: [PATCH 1498/1963] fix(`invariant`): replay should not fail for magic assume (#8966) * fix(invariant): shrink should not fail for magic assume * Test & Code Comment --- .../evm/evm/src/executors/invariant/shrink.rs | 6 +- crates/forge/tests/it/invariant.rs | 71 ++++++++++++++++++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/shrink.rs b/crates/evm/evm/src/executors/invariant/shrink.rs index ca5196b4a2ce4..c468c58eefa63 100644 --- a/crates/evm/evm/src/executors/invariant/shrink.rs +++ b/crates/evm/evm/src/executors/invariant/shrink.rs @@ -5,6 +5,7 @@ use crate::executors::{ Executor, }; use alloy_primitives::{Address, Bytes, U256}; +use foundry_evm_core::constants::MAGIC_ASSUME; use foundry_evm_fuzz::invariant::BasicTxDetails; use indicatif::ProgressBar; use proptest::bits::{BitSetLike, VarBitSet}; @@ -160,7 +161,10 @@ pub fn check_sequence( tx.call_details.calldata.clone(), U256::ZERO, )?; - if call_result.reverted && fail_on_revert { + // Ignore calls reverted with `MAGIC_ASSUME`. This is needed to handle failed scenarios that + // are replayed with a modified version of test driver (that use new `vm.assume` + // cheatcodes). + if call_result.reverted && fail_on_revert && call_result.result.as_ref() != MAGIC_ASSUME { // Candidate sequence fails test. // We don't have to apply remaining calls to check sequence. return Ok((false, false)); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 5a571f77298fb..a6fa615122a23 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -3,7 +3,8 @@ use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_primitives::U256; use forge::fuzz::CounterExample; -use foundry_test_utils::Filter; +use foundry_config::{Config, InvariantConfig}; +use foundry_test_utils::{forgetest_init, str, Filter}; use std::collections::BTreeMap; macro_rules! get_counterexample { @@ -700,3 +701,71 @@ async fn test_no_reverts_in_counterexample() { } }; } + +// Tests that a persisted failure doesn't fail due to assume revert if test driver is changed. +forgetest_init!(should_not_fail_replay_assume, |prj, cmd| { + let config = Config { + invariant: { + InvariantConfig { fail_on_revert: true, max_assume_rejects: 10, ..Default::default() } + }, + ..Default::default() + }; + prj.write_config(config); + + // Add initial test that breaks invariant. + prj.add_test( + "AssumeTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract AssumeHandler is Test { + function fuzzMe(uint256 a) public { + require(false, "Invariant failure"); + } +} + +contract AssumeTest is Test { + function setUp() public { + AssumeHandler handler = new AssumeHandler(); + } + function invariant_assume() public {} +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "invariant_assume"]).assert_failure().stdout_eq(str![[r#" +... +[FAIL: revert: Invariant failure] +... +"#]]); + + // Change test to use assume instead require. Same test should fail with too many inputs + // rejected message instead persisted failure revert. + prj.add_test( + "AssumeTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract AssumeHandler is Test { + function fuzzMe(uint256 a) public { + vm.assume(false); + } +} + +contract AssumeTest is Test { + function setUp() public { + AssumeHandler handler = new AssumeHandler(); + } + function invariant_assume() public {} +} + "#, + ) + .unwrap(); + + cmd.assert_failure().stdout_eq(str![[r#" +... +[FAIL: `vm.assume` rejected too many inputs (10 allowed)] invariant_assume() (runs: 0, calls: 0, reverts: 0) +... +"#]]); +}); From 92e7ad511246e57016f97468767c4fc7999e6589 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Sep 2024 15:13:37 +0200 Subject: [PATCH 1499/1963] chore: bump max allowed verification delay (#8974) --- crates/verify/src/retry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/verify/src/retry.rs b/crates/verify/src/retry.rs index a12dde140f013..6067d9d85621d 100644 --- a/crates/verify/src/retry.rs +++ b/crates/verify/src/retry.rs @@ -23,7 +23,7 @@ pub struct RetryArgs { /// Optional delay to apply in between verification attempts, in seconds. #[arg( long, - value_parser = RangedU64ValueParser::::new().range(0..=30), + value_parser = RangedU64ValueParser::::new().range(0..=180), default_value = "5", )] pub delay: u32, From dd86b30d1b880525b3b008785fab3c65f9e2797d Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:43:01 +0200 Subject: [PATCH 1500/1963] chore: rename `snapshot` to be more specific (#8945) * update internal naming * further internals * deprecate cheats * update Solidity tests and add dedicated test for testing deprecated cheatcodes * clarify gas snapshots * fix build * final fixes * fix build * fix repro 6355 rename --- crates/anvil/src/eth/api.rs | 7 +- crates/anvil/src/eth/backend/db.rs | 61 +++--- crates/anvil/src/eth/backend/mem/fork_db.rs | 42 ++-- .../anvil/src/eth/backend/mem/in_memory_db.rs | 32 +-- crates/anvil/src/eth/backend/mem/mod.rs | 48 ++--- crates/anvil/src/eth/backend/mem/storage.rs | 14 +- crates/anvil/tests/it/anvil_api.rs | 8 +- crates/anvil/tests/it/fork.rs | 32 ++- crates/cheatcodes/assets/cheatcodes.json | 124 ++++++++++- crates/cheatcodes/spec/src/vm.rs | 34 ++- crates/cheatcodes/src/evm.rs | 131 +++++++++--- crates/evm/core/src/backend/cow.rs | 28 +-- crates/evm/core/src/backend/in_memory_db.rs | 6 +- crates/evm/core/src/backend/mod.rs | 92 ++++---- crates/evm/core/src/backend/snapshot.rs | 26 +-- crates/evm/core/src/fork/database.rs | 64 +++--- crates/evm/core/src/lib.rs | 2 +- crates/evm/core/src/snapshot.rs | 74 ------- crates/evm/core/src/state_snapshot.rs | 74 +++++++ crates/evm/evm/src/executors/mod.rs | 16 +- crates/forge/bin/cmd/snapshot.rs | 87 ++++---- crates/forge/bin/cmd/watch.rs | 4 +- crates/forge/bin/main.rs | 2 +- crates/forge/bin/opts.rs | 4 +- crates/forge/tests/it/repros.rs | 2 +- testdata/cheats/Vm.sol | 5 + testdata/default/cheats/Prevrandao.t.sol | 4 +- testdata/default/cheats/Snapshots.t.sol | 105 --------- testdata/default/cheats/StateSnapshots.t.sol | 201 ++++++++++++++++++ testdata/default/cheats/loadAllocs.t.sol | 8 +- testdata/default/repros/Issue2984.t.sol | 4 +- testdata/default/repros/Issue3055.t.sol | 12 +- testdata/default/repros/Issue3792.t.sol | 4 +- testdata/default/repros/Issue6355.t.sol | 8 +- 34 files changed, 835 insertions(+), 530 deletions(-) delete mode 100644 crates/evm/core/src/snapshot.rs create mode 100644 crates/evm/core/src/state_snapshot.rs delete mode 100644 testdata/default/cheats/Snapshots.t.sol create mode 100644 testdata/default/cheats/StateSnapshots.t.sol diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 88698e13cc083..1f005d4436b1b 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1913,7 +1913,6 @@ impl EthApi { pub async fn anvil_metadata(&self) -> Result { node_info!("anvil_metadata"); let fork_config = self.backend.get_fork(); - let snapshots = self.backend.list_snapshots(); Ok(Metadata { client_version: CLIENT_VERSION.to_string(), @@ -1926,7 +1925,7 @@ impl EthApi { fork_block_number: cfg.block_number(), fork_block_hash: cfg.block_hash(), }), - snapshots, + snapshots: self.backend.list_state_snapshots(), }) } @@ -2059,7 +2058,7 @@ impl EthApi { /// Handler for RPC call: `evm_snapshot` pub async fn evm_snapshot(&self) -> Result { node_info!("evm_snapshot"); - Ok(self.backend.create_snapshot().await) + Ok(self.backend.create_state_snapshot().await) } /// Revert the state of the blockchain to a previous snapshot. @@ -2068,7 +2067,7 @@ impl EthApi { /// Handler for RPC call: `evm_revert` pub async fn evm_revert(&self, id: U256) -> Result { node_info!("evm_revert"); - self.backend.revert_snapshot(id).await + self.backend.revert_state_snapshot(id).await } /// Jump forward in time by the given amount of time, in seconds. diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index a02f9d0e31e17..0aa0f8d13cb73 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -11,7 +11,8 @@ use anvil_core::eth::{ use foundry_common::errors::FsPathError; use foundry_evm::{ backend::{ - BlockchainDb, DatabaseError, DatabaseResult, MemDb, RevertSnapshotAction, StateSnapshot, + BlockchainDb, DatabaseError, DatabaseResult, MemDb, RevertStateSnapshotAction, + StateSnapshot, }, revm::{ db::{CacheDB, DatabaseRef, DbAccount}, @@ -35,19 +36,19 @@ pub trait MaybeFullDatabase: DatabaseRef { None } - /// Clear the state and move it into a new `StateSnapshot` - fn clear_into_snapshot(&mut self) -> StateSnapshot; + /// Clear the state and move it into a new `StateSnapshot`. + fn clear_into_state_snapshot(&mut self) -> StateSnapshot; - /// Read the state snapshot + /// Read the state snapshot. /// - /// This clones all the states and returns a new `StateSnapshot` - fn read_as_snapshot(&self) -> StateSnapshot; + /// This clones all the states and returns a new `StateSnapshot`. + fn read_as_state_snapshot(&self) -> StateSnapshot; /// Clears the entire database fn clear(&mut self); - /// Reverses `clear_into_snapshot` by initializing the db's state with the snapshot - fn init_from_snapshot(&mut self, snapshot: StateSnapshot); + /// Reverses `clear_into_snapshot` by initializing the db's state with the state snapshot. + fn init_from_state_snapshot(&mut self, state_snapshot: StateSnapshot); } impl<'a, T: 'a + MaybeFullDatabase + ?Sized> MaybeFullDatabase for &'a T @@ -62,17 +63,17 @@ where T::maybe_as_full_db(self) } - fn clear_into_snapshot(&mut self) -> StateSnapshot { + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { unreachable!("never called for DatabaseRef") } - fn read_as_snapshot(&self) -> StateSnapshot { + fn read_as_state_snapshot(&self) -> StateSnapshot { unreachable!("never called for DatabaseRef") } fn clear(&mut self) {} - fn init_from_snapshot(&mut self, _snapshot: StateSnapshot) {} + fn init_from_state_snapshot(&mut self, _state_snapshot: StateSnapshot) {} } /// Helper trait to reset the DB if it's forked @@ -176,13 +177,13 @@ pub trait Db: Ok(true) } - /// Creates a new snapshot - fn snapshot(&mut self) -> U256; + /// Creates a new state snapshot. + fn snapshot_state(&mut self) -> U256; - /// Reverts a snapshot + /// Reverts a state snapshot. /// - /// Returns `true` if the snapshot was reverted - fn revert(&mut self, snapshot: U256, action: RevertSnapshotAction) -> bool; + /// Returns `true` if the state snapshot was reverted. + fn revert_state(&mut self, state_snapshot: U256, action: RevertStateSnapshotAction) -> bool; /// Returns the state root if possible to compute fn maybe_state_root(&self) -> Option { @@ -228,11 +229,11 @@ impl + Send + Sync + Clone + fmt::Debug> D Ok(None) } - fn snapshot(&mut self) -> U256 { + fn snapshot_state(&mut self) -> U256 { U256::ZERO } - fn revert(&mut self, _snapshot: U256, _action: RevertSnapshotAction) -> bool { + fn revert_state(&mut self, _state_snapshot: U256, _action: RevertStateSnapshotAction) -> bool { false } @@ -250,7 +251,7 @@ impl> MaybeFullDatabase for CacheDB { Some(&self.accounts) } - fn clear_into_snapshot(&mut self) -> StateSnapshot { + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { let db_accounts = std::mem::take(&mut self.accounts); let mut accounts = HashMap::new(); let mut account_storage = HashMap::new(); @@ -265,7 +266,7 @@ impl> MaybeFullDatabase for CacheDB { StateSnapshot { accounts, storage: account_storage, block_hashes } } - fn read_as_snapshot(&self) -> StateSnapshot { + fn read_as_state_snapshot(&self) -> StateSnapshot { let db_accounts = self.accounts.clone(); let mut accounts = HashMap::new(); let mut account_storage = HashMap::new(); @@ -282,11 +283,11 @@ impl> MaybeFullDatabase for CacheDB { } fn clear(&mut self) { - self.clear_into_snapshot(); + self.clear_into_state_snapshot(); } - fn init_from_snapshot(&mut self, snapshot: StateSnapshot) { - let StateSnapshot { accounts, mut storage, block_hashes } = snapshot; + fn init_from_state_snapshot(&mut self, state_snapshot: StateSnapshot) { + let StateSnapshot { accounts, mut storage, block_hashes } = state_snapshot; for (addr, mut acc) in accounts { if let Some(code) = acc.code.take() { @@ -330,7 +331,7 @@ impl StateDb { pub fn serialize_state(&mut self) -> StateSnapshot { // Using read_as_snapshot makes sures we don't clear the historical state from the current // instance. - self.read_as_snapshot() + self.read_as_state_snapshot() } } @@ -362,20 +363,20 @@ impl MaybeFullDatabase for StateDb { self.0.maybe_as_full_db() } - fn clear_into_snapshot(&mut self) -> StateSnapshot { - self.0.clear_into_snapshot() + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { + self.0.clear_into_state_snapshot() } - fn read_as_snapshot(&self) -> StateSnapshot { - self.0.read_as_snapshot() + fn read_as_state_snapshot(&self) -> StateSnapshot { + self.0.read_as_state_snapshot() } fn clear(&mut self) { self.0.clear() } - fn init_from_snapshot(&mut self, snapshot: StateSnapshot) { - self.0.init_from_snapshot(snapshot) + fn init_from_state_snapshot(&mut self, state_snapshot: StateSnapshot) { + self.0.init_from_state_snapshot(state_snapshot) } } diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index a5f6cf455a221..a4528a8f034a6 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -8,8 +8,10 @@ use crate::{ use alloy_primitives::{Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ - backend::{BlockchainDb, DatabaseError, DatabaseResult, RevertSnapshotAction, StateSnapshot}, - fork::database::ForkDbSnapshot, + backend::{ + BlockchainDb, DatabaseError, DatabaseResult, RevertStateSnapshotAction, StateSnapshot, + }, + fork::database::ForkDbStateSnapshot, revm::{primitives::BlockEnv, Database}, }; use revm::DatabaseRef; @@ -72,16 +74,16 @@ impl Db for ForkedDatabase { })) } - fn snapshot(&mut self) -> U256 { - self.insert_snapshot() + fn snapshot_state(&mut self) -> U256 { + self.insert_state_snapshot() } - fn revert(&mut self, id: U256, action: RevertSnapshotAction) -> bool { - self.revert_snapshot(id, action) + fn revert_state(&mut self, id: U256, action: RevertStateSnapshotAction) -> bool { + self.revert_state_snapshot(id, action) } fn current_state(&self) -> StateDb { - StateDb::new(self.create_snapshot()) + StateDb::new(self.create_state_snapshot()) } } @@ -90,7 +92,7 @@ impl MaybeFullDatabase for ForkedDatabase { self } - fn clear_into_snapshot(&mut self) -> StateSnapshot { + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { let db = self.inner().db(); let accounts = std::mem::take(&mut *db.accounts.write()); let storage = std::mem::take(&mut *db.storage.write()); @@ -98,7 +100,7 @@ impl MaybeFullDatabase for ForkedDatabase { StateSnapshot { accounts, storage, block_hashes } } - fn read_as_snapshot(&self) -> StateSnapshot { + fn read_as_state_snapshot(&self) -> StateSnapshot { let db = self.inner().db(); let accounts = db.accounts.read().clone(); let storage = db.storage.read().clone(); @@ -108,38 +110,38 @@ impl MaybeFullDatabase for ForkedDatabase { fn clear(&mut self) { self.flush_cache(); - self.clear_into_snapshot(); + self.clear_into_state_snapshot(); } - fn init_from_snapshot(&mut self, snapshot: StateSnapshot) { + fn init_from_state_snapshot(&mut self, state_snapshot: StateSnapshot) { let db = self.inner().db(); - let StateSnapshot { accounts, storage, block_hashes } = snapshot; + let StateSnapshot { accounts, storage, block_hashes } = state_snapshot; *db.accounts.write() = accounts; *db.storage.write() = storage; *db.block_hashes.write() = block_hashes; } } -impl MaybeFullDatabase for ForkDbSnapshot { +impl MaybeFullDatabase for ForkDbStateSnapshot { fn as_dyn(&self) -> &dyn DatabaseRef { self } - fn clear_into_snapshot(&mut self) -> StateSnapshot { - std::mem::take(&mut self.snapshot) + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { + std::mem::take(&mut self.state_snapshot) } - fn read_as_snapshot(&self) -> StateSnapshot { - self.snapshot.clone() + fn read_as_state_snapshot(&self) -> StateSnapshot { + self.state_snapshot.clone() } fn clear(&mut self) { - std::mem::take(&mut self.snapshot); + std::mem::take(&mut self.state_snapshot); self.local.clear() } - fn init_from_snapshot(&mut self, snapshot: StateSnapshot) { - self.snapshot = snapshot; + fn init_from_state_snapshot(&mut self, state_snapshot: StateSnapshot) { + self.state_snapshot = state_snapshot; } } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index f984b93bbbcfc..01243c90f47ba 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -17,7 +17,7 @@ use foundry_evm::{ // reexport for convenience pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; -use foundry_evm::{backend::RevertSnapshotAction, revm::primitives::BlockEnv}; +use foundry_evm::{backend::RevertStateSnapshotAction, revm::primitives::BlockEnv}; impl Db for MemDb { fn insert_account(&mut self, address: Address, account: AccountInfo) { @@ -74,22 +74,22 @@ impl Db for MemDb { } /// Creates a new snapshot - fn snapshot(&mut self) -> U256 { - let id = self.snapshots.insert(self.inner.clone()); - trace!(target: "backend::memdb", "Created new snapshot {}", id); + fn snapshot_state(&mut self) -> U256 { + let id = self.state_snapshots.insert(self.inner.clone()); + trace!(target: "backend::memdb", "Created new state snapshot {}", id); id } - fn revert(&mut self, id: U256, action: RevertSnapshotAction) -> bool { - if let Some(snapshot) = self.snapshots.remove(id) { + fn revert_state(&mut self, id: U256, action: RevertStateSnapshotAction) -> bool { + if let Some(state_snapshot) = self.state_snapshots.remove(id) { if action.is_keep() { - self.snapshots.insert_at(snapshot.clone(), id); + self.state_snapshots.insert_at(state_snapshot.clone(), id); } - self.inner = snapshot; - trace!(target: "backend::memdb", "Reverted snapshot {}", id); + self.inner = state_snapshot; + trace!(target: "backend::memdb", "Reverted state snapshot {}", id); true } else { - warn!(target: "backend::memdb", "No snapshot to revert for {}", id); + warn!(target: "backend::memdb", "No state snapshot to revert for {}", id); false } } @@ -112,20 +112,20 @@ impl MaybeFullDatabase for MemDb { Some(&self.inner.accounts) } - fn clear_into_snapshot(&mut self) -> StateSnapshot { - self.inner.clear_into_snapshot() + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { + self.inner.clear_into_state_snapshot() } - fn read_as_snapshot(&self) -> StateSnapshot { - self.inner.read_as_snapshot() + fn read_as_state_snapshot(&self) -> StateSnapshot { + self.inner.read_as_state_snapshot() } fn clear(&mut self) { self.inner.clear(); } - fn init_from_snapshot(&mut self, snapshot: StateSnapshot) { - self.inner.init_from_snapshot(snapshot) + fn init_from_state_snapshot(&mut self, snapshot: StateSnapshot) { + self.inner.init_from_state_snapshot(snapshot) } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 89cd0bd4b33c3..cd23fa6d3a94b 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -68,7 +68,7 @@ use anvil_rpc::error::RpcError; use alloy_chains::NamedChain; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ - backend::{DatabaseError, DatabaseResult, RevertSnapshotAction}, + backend::{DatabaseError, DatabaseResult, RevertStateSnapshotAction}, constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE, decode::RevertDecoder, inspectors::AccessListInspector, @@ -153,26 +153,26 @@ pub struct Backend { /// need to read from it, while it's currently written to, don't block. E.g. a new block is /// currently mined and a new [`Self::set_storage_at()`] request is being executed. db: Arc>>, - /// stores all block related data in memory + /// stores all block related data in memory. blockchain: Blockchain, - /// Historic states of previous blocks + /// Historic states of previous blocks. states: Arc>, - /// env data of the chain + /// Env data of the chain env: Arc>, - /// this is set if this is currently forked off another client + /// This is set if this is currently forked off another client. fork: Arc>>, - /// provides time related info, like timestamp + /// Provides time related info, like timestamp. time: TimeManager, - /// Contains state of custom overrides + /// Contains state of custom overrides. cheats: CheatsManager, - /// contains fee data + /// Contains fee data. fees: FeeManager, - /// initialised genesis + /// Initialised genesis. genesis: GenesisConfig, - /// listeners for new blocks that get notified when a new block was imported + /// Listeners for new blocks that get notified when a new block was imported. new_block_listeners: Arc>>>, - /// keeps track of active snapshots at a specific block - active_snapshots: Arc>>, + /// Keeps track of active state snapshots at a specific block. + active_state_snapshots: Arc>>, enable_steps_tracing: bool, print_logs: bool, alphanet: bool, @@ -256,7 +256,7 @@ impl Backend { new_block_listeners: Default::default(), fees, genesis, - active_snapshots: Arc::new(Mutex::new(Default::default())), + active_state_snapshots: Arc::new(Mutex::new(Default::default())), enable_steps_tracing, print_logs, alphanet, @@ -695,21 +695,21 @@ impl Backend { self.blockchain.storage.read().total_difficulty } - /// Creates a new `evm_snapshot` at the current height + /// Creates a new `evm_snapshot` at the current height. /// - /// Returns the id of the snapshot created - pub async fn create_snapshot(&self) -> U256 { + /// Returns the id of the snapshot created. + pub async fn create_state_snapshot(&self) -> U256 { let num = self.best_number(); let hash = self.best_hash(); - let id = self.db.write().await.snapshot(); + let id = self.db.write().await.snapshot_state(); trace!(target: "backend", "creating snapshot {} at {}", id, num); - self.active_snapshots.lock().insert(id, (num, hash)); + self.active_state_snapshots.lock().insert(id, (num, hash)); id } - /// Reverts the state to the snapshot identified by the given `id`. - pub async fn revert_snapshot(&self, id: U256) -> Result { - let block = { self.active_snapshots.lock().remove(&id) }; + /// Reverts the state to the state snapshot identified by the given `id`. + pub async fn revert_state_snapshot(&self, id: U256) -> Result { + let block = { self.active_state_snapshots.lock().remove(&id) }; if let Some((num, hash)) = block { let best_block_hash = { // revert the storage that's newer than the snapshot @@ -752,11 +752,11 @@ impl Backend { ..Default::default() }; } - Ok(self.db.write().await.revert(id, RevertSnapshotAction::RevertRemove)) + Ok(self.db.write().await.revert_state(id, RevertStateSnapshotAction::RevertRemove)) } - pub fn list_snapshots(&self) -> BTreeMap { - self.active_snapshots.lock().clone().into_iter().collect() + pub fn list_state_snapshots(&self) -> BTreeMap { + self.active_state_snapshots.lock().clone().into_iter().collect() } /// Get the current state. diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 4cb588221ae84..928fb66e4e035 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -147,8 +147,8 @@ impl InMemoryBlockStates { { // only write to disk if supported if !self.is_memory_only() { - let snapshot = state.0.clear_into_snapshot(); - self.disk_cache.write(hash, snapshot); + let state_snapshot = state.0.clear_into_state_snapshot(); + self.disk_cache.write(hash, state_snapshot); self.on_disk_states.insert(hash, state); self.oldest_on_disk.push_back(hash); } @@ -170,7 +170,7 @@ impl InMemoryBlockStates { self.states.get(hash).or_else(|| { if let Some(state) = self.on_disk_states.get_mut(hash) { if let Some(cached) = self.disk_cache.read(*hash) { - state.init_from_snapshot(cached); + state.init_from_state_snapshot(cached); return Some(state); } } @@ -204,8 +204,8 @@ impl InMemoryBlockStates { // Get on-disk state snapshots self.on_disk_states.iter().for_each(|(hash, _)| { - if let Some(snapshot) = self.disk_cache.read(*hash) { - states.push((*hash, snapshot)); + if let Some(state_snapshot) = self.disk_cache.read(*hash) { + states.push((*hash, state_snapshot)); } }); @@ -214,9 +214,9 @@ impl InMemoryBlockStates { /// Load states from serialized data pub fn load_states(&mut self, states: SerializableHistoricalStates) { - for (hash, snapshot) in states { + for (hash, state_snapshot) in states { let mut state_db = StateDb::new(MemDb::default()); - state_db.init_from_snapshot(snapshot); + state_db.init_from_state_snapshot(state_snapshot); self.insert(hash, state_db); } } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 0e8001853a95f..31e37c98b7810 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -591,9 +591,9 @@ async fn test_fork_revert_next_block_timestamp() { api.mine_one().await; let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - let snapshot_id = api.evm_snapshot().await.unwrap(); + let state_snapshot = api.evm_snapshot().await.unwrap(); api.mine_one().await; - api.evm_revert(snapshot_id).await.unwrap(); + api.evm_revert(state_snapshot).await.unwrap(); let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); assert_eq!(block, latest_block); @@ -613,9 +613,9 @@ async fn test_fork_revert_call_latest_block_timestamp() { api.mine_one().await; let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - let snapshot_id = api.evm_snapshot().await.unwrap(); + let state_snapshot = api.evm_snapshot().await.unwrap(); api.mine_one().await; - api.evm_revert(snapshot_id).await.unwrap(); + api.evm_revert(state_snapshot).await.unwrap(); let multicall_contract = Multicall::new(address!("eefba1e63905ef1d7acba5a8513c70307c1ce441"), &provider); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 3f96513c5c8e9..f93fa92a19f96 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -302,10 +302,10 @@ async fn test_fork_reset_setup() { } #[tokio::test(flavor = "multi_thread")] -async fn test_fork_snapshotting() { +async fn test_fork_state_snapshotting() { let (api, handle) = spawn(fork_config()).await; let provider = handle.http_provider(); - let snapshot = api.evm_snapshot().await.unwrap(); + let state_snapshot = api.evm_snapshot().await.unwrap(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -329,7 +329,7 @@ async fn test_fork_snapshotting() { let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); - assert!(api.evm_revert(snapshot).await.unwrap()); + assert!(api.evm_revert(state_snapshot).await.unwrap()); let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce); @@ -341,11 +341,11 @@ async fn test_fork_snapshotting() { } #[tokio::test(flavor = "multi_thread")] -async fn test_fork_snapshotting_repeated() { +async fn test_fork_state_snapshotting_repeated() { let (api, handle) = spawn(fork_config()).await; let provider = handle.http_provider(); - let snapshot = api.evm_snapshot().await.unwrap(); + let state_snapshot = api.evm_snapshot().await.unwrap(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -366,9 +366,9 @@ async fn test_fork_snapshotting_repeated() { let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); - let _second_snapshot = api.evm_snapshot().await.unwrap(); + let _second_state_snapshot = api.evm_snapshot().await.unwrap(); - assert!(api.evm_revert(snapshot).await.unwrap()); + assert!(api.evm_revert(state_snapshot).await.unwrap()); let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce); @@ -383,17 +383,16 @@ async fn test_fork_snapshotting_repeated() { // assert!(!api.evm_revert(second_snapshot).await.unwrap()); // nothing is reverted, snapshot gone - assert!(!api.evm_revert(snapshot).await.unwrap()); + assert!(!api.evm_revert(state_snapshot).await.unwrap()); } // #[tokio::test(flavor = "multi_thread")] -async fn test_fork_snapshotting_blocks() { +async fn test_fork_state_snapshotting_blocks() { let (api, handle) = spawn(fork_config()).await; let provider = handle.http_provider(); - // create a snapshot - let snapshot = api.evm_snapshot().await.unwrap(); + let state_snapshot = api.evm_snapshot().await.unwrap(); let accounts: Vec<_> = handle.dev_wallets().collect(); let from = accounts[0].address(); @@ -417,8 +416,7 @@ async fn test_fork_snapshotting_blocks() { let to_balance = provider.get_balance(to).await.unwrap(); assert_eq!(balance_before.saturating_add(amount), to_balance); - // revert snapshot - assert!(api.evm_revert(snapshot).await.unwrap()); + assert!(api.evm_revert(state_snapshot).await.unwrap()); assert_eq!(initial_nonce, provider.get_transaction_count(from).await.unwrap()); let block_number_after = provider.get_block_number().await.unwrap(); @@ -429,8 +427,8 @@ async fn test_fork_snapshotting_blocks() { let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); - // revert again: nothing to revert since snapshot gone - assert!(!api.evm_revert(snapshot).await.unwrap()); + // revert again: nothing to revert since state snapshot gone + assert!(!api.evm_revert(state_snapshot).await.unwrap()); let nonce = provider.get_transaction_count(from).await.unwrap(); assert_eq!(nonce, initial_nonce + 1); let block_number_after = provider.get_block_number().await.unwrap(); @@ -1244,7 +1242,7 @@ async fn test_arbitrum_fork_block_number() { assert_eq!(block_number, initial_block_number); // take snapshot at initial block number - let snapshot = api.evm_snapshot().await.unwrap(); + let snapshot_state = api.evm_snapshot().await.unwrap(); // mine new block and check block number returned by `eth_blockNumber` api.mine_one().await; @@ -1257,7 +1255,7 @@ async fn test_arbitrum_fork_block_number() { assert!(block_by_number.other.get("l1BlockNumber").is_some()); // revert to recorded snapshot and check block number - assert!(api.evm_revert(snapshot).await.unwrap()); + assert!(api.evm_revert(snapshot_state).await.unwrap()); let block_number = api.block_number().unwrap().to::(); assert_eq!(block_number, initial_block_number); diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 451ce6cb44c30..fbf33e500d53a 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3574,7 +3574,7 @@ { "func": { "id": "deleteSnapshot", - "description": "Removes the snapshot with the given ID created by `snapshot`.\nTakes the snapshot ID to delete.\nReturns `true` if the snapshot was successfully deleted.\nReturns `false` if the snapshot does not exist.", + "description": "`deleteSnapshot` is being deprecated in favor of `deleteStateSnapshot`. It will be removed in future versions.", "declaration": "function deleteSnapshot(uint256 snapshotId) external returns (bool success);", "visibility": "external", "mutability": "", @@ -3588,13 +3588,15 @@ ] }, "group": "evm", - "status": "stable", + "status": { + "deprecated": "replaced by `deleteStateSnapshot`" + }, "safety": "unsafe" }, { "func": { "id": "deleteSnapshots", - "description": "Removes _all_ snapshots previously created by `snapshot`.", + "description": "`deleteSnapshots` is being deprecated in favor of `deleteStateSnapshots`. It will be removed in future versions.", "declaration": "function deleteSnapshots() external;", "visibility": "external", "mutability": "", @@ -3608,6 +3610,48 @@ ] }, "group": "evm", + "status": { + "deprecated": "replaced by `deleteStateSnapshots`" + }, + "safety": "unsafe" + }, + { + "func": { + "id": "deleteStateSnapshot", + "description": "Removes the snapshot with the given ID created by `snapshot`.\nTakes the snapshot ID to delete.\nReturns `true` if the snapshot was successfully deleted.\nReturns `false` if the snapshot does not exist.", + "declaration": "function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);", + "visibility": "external", + "mutability": "", + "signature": "deleteStateSnapshot(uint256)", + "selector": "0x08d6b37a", + "selectorBytes": [ + 8, + 214, + 179, + 122 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "deleteStateSnapshots", + "description": "Removes _all_ snapshots previously created by `snapshot`.", + "declaration": "function deleteStateSnapshots() external;", + "visibility": "external", + "mutability": "", + "signature": "deleteStateSnapshots()", + "selector": "0xe0933c74", + "selectorBytes": [ + 224, + 147, + 60, + 116 + ] + }, + "group": "evm", "status": "stable", "safety": "unsafe" }, @@ -7456,7 +7500,7 @@ { "func": { "id": "revertTo", - "description": "Revert the state of the EVM to a previous snapshot\nTakes the snapshot ID to revert to.\nReturns `true` if the snapshot was successfully reverted.\nReturns `false` if the snapshot does not exist.\n**Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteSnapshot`.", + "description": "`revertTo` is being deprecated in favor of `revertToState`. It will be removed in future versions.", "declaration": "function revertTo(uint256 snapshotId) external returns (bool success);", "visibility": "external", "mutability": "", @@ -7470,13 +7514,15 @@ ] }, "group": "evm", - "status": "stable", + "status": { + "deprecated": "replaced by `revertToState`" + }, "safety": "unsafe" }, { "func": { "id": "revertToAndDelete", - "description": "Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots\nTakes the snapshot ID to revert to.\nReturns `true` if the snapshot was successfully reverted and deleted.\nReturns `false` if the snapshot does not exist.", + "description": "`revertToAndDelete` is being deprecated in favor of `revertToStateAndDelete`. It will be removed in future versions.", "declaration": "function revertToAndDelete(uint256 snapshotId) external returns (bool success);", "visibility": "external", "mutability": "", @@ -7490,6 +7536,48 @@ ] }, "group": "evm", + "status": { + "deprecated": "replaced by `revertToStateAndDelete`" + }, + "safety": "unsafe" + }, + { + "func": { + "id": "revertToState", + "description": "Revert the state of the EVM to a previous snapshot\nTakes the snapshot ID to revert to.\nReturns `true` if the snapshot was successfully reverted.\nReturns `false` if the snapshot does not exist.\n**Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteStateSnapshot`.", + "declaration": "function revertToState(uint256 snapshotId) external returns (bool success);", + "visibility": "external", + "mutability": "", + "signature": "revertToState(uint256)", + "selector": "0xc2527405", + "selectorBytes": [ + 194, + 82, + 116, + 5 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "revertToStateAndDelete", + "description": "Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots\nTakes the snapshot ID to revert to.\nReturns `true` if the snapshot was successfully reverted and deleted.\nReturns `false` if the snapshot does not exist.", + "declaration": "function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);", + "visibility": "external", + "mutability": "", + "signature": "revertToStateAndDelete(uint256)", + "selector": "0x3a1985dc", + "selectorBytes": [ + 58, + 25, + 133, + 220 + ] + }, + "group": "evm", "status": "stable", "safety": "unsafe" }, @@ -8456,7 +8544,7 @@ { "func": { "id": "snapshot", - "description": "Snapshot the current state of the evm.\nReturns the ID of the snapshot that was created.\nTo revert a snapshot use `revertTo`.", + "description": "`snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions.", "declaration": "function snapshot() external returns (uint256 snapshotId);", "visibility": "external", "mutability": "", @@ -8470,6 +8558,28 @@ ] }, "group": "evm", + "status": { + "deprecated": "replaced by `snapshotState`" + }, + "safety": "unsafe" + }, + { + "func": { + "id": "snapshotState", + "description": "Snapshot the current state of the evm.\nReturns the ID of the snapshot that was created.\nTo revert a snapshot use `revertToState`.", + "declaration": "function snapshotState() external returns (uint256 snapshotId);", + "visibility": "external", + "mutability": "", + "signature": "snapshotState()", + "selector": "0x9cd23835", + "selectorBytes": [ + 156, + 210, + 56, + 53 + ] + }, + "group": "evm", "status": "stable", "safety": "unsafe" }, diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 22500ec980a68..69293d1b6d6e7 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -511,11 +511,19 @@ interface Vm { // -------- State Snapshots -------- + /// `snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions. + #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `snapshotState`")))] + function snapshot() external returns (uint256 snapshotId); + /// Snapshot the current state of the evm. /// Returns the ID of the snapshot that was created. - /// To revert a snapshot use `revertTo`. + /// To revert a snapshot use `revertToState`. #[cheatcode(group = Evm, safety = Unsafe)] - function snapshot() external returns (uint256 snapshotId); + function snapshotState() external returns (uint256 snapshotId); + + /// `revertTo` is being deprecated in favor of `revertToState`. It will be removed in future versions. + #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToState`")))] + function revertTo(uint256 snapshotId) external returns (bool success); /// Revert the state of the EVM to a previous snapshot /// Takes the snapshot ID to revert to. @@ -523,9 +531,13 @@ interface Vm { /// Returns `true` if the snapshot was successfully reverted. /// Returns `false` if the snapshot does not exist. /// - /// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteSnapshot`. + /// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteStateSnapshot`. #[cheatcode(group = Evm, safety = Unsafe)] - function revertTo(uint256 snapshotId) external returns (bool success); + function revertToState(uint256 snapshotId) external returns (bool success); + + /// `revertToAndDelete` is being deprecated in favor of `revertToStateAndDelete`. It will be removed in future versions. + #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `revertToStateAndDelete`")))] + function revertToAndDelete(uint256 snapshotId) external returns (bool success); /// Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots /// Takes the snapshot ID to revert to. @@ -533,7 +545,11 @@ interface Vm { /// Returns `true` if the snapshot was successfully reverted and deleted. /// Returns `false` if the snapshot does not exist. #[cheatcode(group = Evm, safety = Unsafe)] - function revertToAndDelete(uint256 snapshotId) external returns (bool success); + function revertToStateAndDelete(uint256 snapshotId) external returns (bool success); + + /// `deleteSnapshot` is being deprecated in favor of `deleteStateSnapshot`. It will be removed in future versions. + #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshot`")))] + function deleteSnapshot(uint256 snapshotId) external returns (bool success); /// Removes the snapshot with the given ID created by `snapshot`. /// Takes the snapshot ID to delete. @@ -541,11 +557,15 @@ interface Vm { /// Returns `true` if the snapshot was successfully deleted. /// Returns `false` if the snapshot does not exist. #[cheatcode(group = Evm, safety = Unsafe)] - function deleteSnapshot(uint256 snapshotId) external returns (bool success); + function deleteStateSnapshot(uint256 snapshotId) external returns (bool success); + + /// `deleteSnapshots` is being deprecated in favor of `deleteStateSnapshots`. It will be removed in future versions. + #[cheatcode(group = Evm, safety = Unsafe, status = Deprecated(Some("replaced by `deleteStateSnapshots`")))] + function deleteSnapshots() external; /// Removes _all_ snapshots previously created by `snapshot`. #[cheatcode(group = Evm, safety = Unsafe)] - function deleteSnapshots() external; + function deleteStateSnapshots() external; // -------- Forking -------- // --- Creation and Selection --- diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 45b6f8c752706..7ed1ce1a4edf0 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -10,7 +10,7 @@ use alloy_rlp::Decodable; use alloy_sol_types::SolValue; use foundry_common::fs::{read_json_file, write_json_file}; use foundry_evm_core::{ - backend::{DatabaseExt, RevertSnapshotAction}, + backend::{DatabaseExt, RevertStateSnapshotAction}, constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS}, }; use rand::Rng; @@ -506,63 +506,78 @@ impl Cheatcode for readCallersCall { } } +// Deprecated in favor of `snapshotStateCall` impl Cheatcode for snapshotCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - Ok(ccx.ecx.db.snapshot(&ccx.ecx.journaled_state, &ccx.ecx.env).abi_encode()) + inner_snapshot_state(ccx) } } +impl Cheatcode for snapshotStateCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + inner_snapshot_state(ccx) + } +} + +// Deprecated in favor of `revertToStateCall` impl Cheatcode for revertToCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; - let result = if let Some(journaled_state) = ccx.ecx.db.revert( - *snapshotId, - &ccx.ecx.journaled_state, - &mut ccx.ecx.env, - RevertSnapshotAction::RevertKeep, - ) { - // we reset the evm's journaled_state to the state of the snapshot previous state - ccx.ecx.journaled_state = journaled_state; - true - } else { - false - }; - Ok(result.abi_encode()) + inner_revert_to_state(ccx, *snapshotId) } } +impl Cheatcode for revertToStateCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { snapshotId } = self; + inner_revert_to_state(ccx, *snapshotId) + } +} + +// Deprecated in favor of `revertToStateAndDeleteCall` impl Cheatcode for revertToAndDeleteCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; - let result = if let Some(journaled_state) = ccx.ecx.db.revert( - *snapshotId, - &ccx.ecx.journaled_state, - &mut ccx.ecx.env, - RevertSnapshotAction::RevertRemove, - ) { - // we reset the evm's journaled_state to the state of the snapshot previous state - ccx.ecx.journaled_state = journaled_state; - true - } else { - false - }; - Ok(result.abi_encode()) + inner_revert_to_state_and_delete(ccx, *snapshotId) } } +impl Cheatcode for revertToStateAndDeleteCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { snapshotId } = self; + inner_revert_to_state_and_delete(ccx, *snapshotId) + } +} + +// Deprecated in favor of `deleteStateSnapshotCall` impl Cheatcode for deleteSnapshotCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; - let result = ccx.ecx.db.delete_snapshot(*snapshotId); - Ok(result.abi_encode()) + inner_delete_state_snapshot(ccx, *snapshotId) + } +} + +impl Cheatcode for deleteStateSnapshotCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { snapshotId } = self; + inner_delete_state_snapshot(ccx, *snapshotId) } } + +// Deprecated in favor of `deleteStateSnapshotsCall` impl Cheatcode for deleteSnapshotsCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - ccx.ecx.db.delete_snapshots(); - Ok(Default::default()) + inner_delete_state_snapshots(ccx) + } +} + +impl Cheatcode for deleteStateSnapshotsCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + inner_delete_state_snapshots(ccx) } } @@ -628,6 +643,58 @@ pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Add Ok(account.info.nonce.abi_encode()) } +fn inner_snapshot_state(ccx: &mut CheatsCtxt) -> Result { + Ok(ccx.ecx.db.snapshot_state(&ccx.ecx.journaled_state, &ccx.ecx.env).abi_encode()) +} + +fn inner_revert_to_state(ccx: &mut CheatsCtxt, snapshot_id: U256) -> Result { + let result = if let Some(journaled_state) = ccx.ecx.db.revert_state( + snapshot_id, + &ccx.ecx.journaled_state, + &mut ccx.ecx.env, + RevertStateSnapshotAction::RevertKeep, + ) { + // we reset the evm's journaled_state to the state of the snapshot previous state + ccx.ecx.journaled_state = journaled_state; + true + } else { + false + }; + Ok(result.abi_encode()) +} + +fn inner_revert_to_state_and_delete( + ccx: &mut CheatsCtxt, + snapshot_id: U256, +) -> Result { + let result = if let Some(journaled_state) = ccx.ecx.db.revert_state( + snapshot_id, + &ccx.ecx.journaled_state, + &mut ccx.ecx.env, + RevertStateSnapshotAction::RevertRemove, + ) { + // we reset the evm's journaled_state to the state of the snapshot previous state + ccx.ecx.journaled_state = journaled_state; + true + } else { + false + }; + Ok(result.abi_encode()) +} + +fn inner_delete_state_snapshot( + ccx: &mut CheatsCtxt, + snapshot_id: U256, +) -> Result { + let result = ccx.ecx.db.delete_state_snapshot(snapshot_id); + Ok(result.abi_encode()) +} + +fn inner_delete_state_snapshots(ccx: &mut CheatsCtxt) -> Result { + ccx.ecx.db.delete_state_snapshots(); + Ok(Default::default()) +} + /// Reads the current caller information and returns the current [CallerMode], `msg.sender` and /// `tx.origin`. /// diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index cba792b32d892..8156d75fbddfd 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -3,7 +3,7 @@ use super::BackendError; use crate::{ backend::{ - diagnostic::RevertDiagnostic, Backend, DatabaseExt, LocalForkId, RevertSnapshotAction, + diagnostic::RevertDiagnostic, Backend, DatabaseExt, LocalForkId, RevertStateSnapshotAction, }, fork::{CreateFork, ForkId}, InspectorExt, @@ -84,11 +84,11 @@ impl<'a> CowBackend<'a> { Ok(res) } - /// Returns whether there was a snapshot failure in the backend. + /// Returns whether there was a state snapshot failure in the backend. /// /// This is bubbled up from the underlying Copy-On-Write backend when a revert occurs. - pub fn has_snapshot_failure(&self) -> bool { - self.backend.has_snapshot_failure() + pub fn has_state_snapshot_failure(&self) -> bool { + self.backend.has_state_snapshot_failure() } /// Returns a mutable instance of the Backend. @@ -115,31 +115,31 @@ impl<'a> CowBackend<'a> { } impl<'a> DatabaseExt for CowBackend<'a> { - fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256 { - self.backend_mut(env).snapshot(journaled_state, env) + fn snapshot_state(&mut self, journaled_state: &JournaledState, env: &Env) -> U256 { + self.backend_mut(env).snapshot_state(journaled_state, env) } - fn revert( + fn revert_state( &mut self, id: U256, journaled_state: &JournaledState, current: &mut Env, - action: RevertSnapshotAction, + action: RevertStateSnapshotAction, ) -> Option { - self.backend_mut(current).revert(id, journaled_state, current, action) + self.backend_mut(current).revert_state(id, journaled_state, current, action) } - fn delete_snapshot(&mut self, id: U256) -> bool { - // delete snapshot requires a previous snapshot to be initialized + fn delete_state_snapshot(&mut self, id: U256) -> bool { + // delete state snapshot requires a previous snapshot to be initialized if let Some(backend) = self.initialized_backend_mut() { - return backend.delete_snapshot(id) + return backend.delete_state_snapshot(id) } false } - fn delete_snapshots(&mut self) { + fn delete_state_snapshots(&mut self) { if let Some(backend) = self.initialized_backend_mut() { - backend.delete_snapshots() + backend.delete_state_snapshots() } } diff --git a/crates/evm/core/src/backend/in_memory_db.rs b/crates/evm/core/src/backend/in_memory_db.rs index e819c5313c2a3..4e90bfec0ae05 100644 --- a/crates/evm/core/src/backend/in_memory_db.rs +++ b/crates/evm/core/src/backend/in_memory_db.rs @@ -1,6 +1,6 @@ //! In-memory database. -use crate::snapshot::Snapshots; +use crate::state_snapshot::StateSnapshots; use alloy_primitives::{Address, B256, U256}; use foundry_fork_db::DatabaseError; use revm::{ @@ -20,12 +20,12 @@ pub type FoundryEvmInMemoryDB = CacheDB; #[derive(Debug)] pub struct MemDb { pub inner: FoundryEvmInMemoryDB, - pub snapshots: Snapshots, + pub state_snapshots: StateSnapshots, } impl Default for MemDb { fn default() -> Self { - Self { inner: CacheDB::new(Default::default()), snapshots: Default::default() } + Self { inner: CacheDB::new(Default::default()), state_snapshots: Default::default() } } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 6fbd2086dde80..49830bc892d03 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -3,7 +3,7 @@ use crate::{ constants::{CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, TEST_CONTRACT_ADDRESS}, fork::{CreateFork, ForkId, MultiFork}, - snapshot::Snapshots, + state_snapshot::StateSnapshots, utils::{configure_tx_env, new_evm_with_inspector}, InspectorExt, }; @@ -42,7 +42,7 @@ mod in_memory_db; pub use in_memory_db::{EmptyDBWrapper, FoundryEvmInMemoryDB, MemDb}; mod snapshot; -pub use snapshot::{BackendSnapshot, RevertSnapshotAction, StateSnapshot}; +pub use snapshot::{BackendStateSnapshot, RevertStateSnapshotAction, StateSnapshot}; // A `revm::Database` that is used in forking mode type ForkDB = CacheDB; @@ -71,12 +71,12 @@ pub const GLOBAL_FAIL_SLOT: U256 = /// An extension trait that allows us to easily extend the `revm::Inspector` capabilities #[auto_impl::auto_impl(&mut)] pub trait DatabaseExt: Database + DatabaseCommit { - /// Creates a new snapshot at the current point of execution. + /// Creates a new state snapshot at the current point of execution. /// - /// A snapshot is associated with a new unique id that's created for the snapshot. - /// Snapshots can be reverted: [DatabaseExt::revert], however, depending on the - /// [RevertSnapshotAction], it will keep the snapshot alive or delete it. - fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256; + /// A state snapshot is associated with a new unique id that's created for the snapshot. + /// State snapshots can be reverted: [DatabaseExt::revert_state], however, depending on the + /// [RevertStateSnapshotAction], it will keep the snapshot alive or delete it. + fn snapshot_state(&mut self, journaled_state: &JournaledState, env: &Env) -> U256; /// Reverts the snapshot if it exists /// @@ -87,25 +87,25 @@ pub trait DatabaseExt: Database + DatabaseCommit { /// since the snapshots was created. This way we can show logs that were emitted between /// snapshot and its revert. /// This will also revert any changes in the `Env` and replace it with the captured `Env` of - /// `Self::snapshot`. + /// `Self::snapshot_state`. /// - /// Depending on [RevertSnapshotAction] it will keep the snapshot alive or delete it. - fn revert( + /// Depending on [RevertStateSnapshotAction] it will keep the snapshot alive or delete it. + fn revert_state( &mut self, id: U256, journaled_state: &JournaledState, env: &mut Env, - action: RevertSnapshotAction, + action: RevertStateSnapshotAction, ) -> Option; - /// Deletes the snapshot with the given `id` + /// Deletes the state snapshot with the given `id` /// /// Returns `true` if the snapshot was successfully deleted, `false` if no snapshot for that id /// exists. - fn delete_snapshot(&mut self, id: U256) -> bool; + fn delete_state_snapshot(&mut self, id: U256) -> bool; - /// Deletes all snapshots. - fn delete_snapshots(&mut self); + /// Deletes all state snapshots. + fn delete_state_snapshots(&mut self); /// Creates and also selects a new fork /// @@ -410,7 +410,7 @@ struct _ObjectSafe(dyn DatabaseExt); /// afterwards, as well as any snapshots taken after the reverted snapshot, (e.g.: reverting to id /// 0x1 will delete snapshots with ids 0x1, 0x2, etc.) /// -/// **Note:** Snapshots work across fork-swaps, e.g. if fork `A` is currently active, then a +/// **Note:** State snapshots work across fork-swaps, e.g. if fork `A` is currently active, then a /// snapshot is created before fork `B` is selected, then fork `A` will be the active fork again /// after reverting the snapshot. #[derive(Clone, Debug)] @@ -554,8 +554,10 @@ impl Backend { } /// Returns all snapshots created in this backend - pub fn snapshots(&self) -> &Snapshots> { - &self.inner.snapshots + pub fn state_snapshots( + &self, + ) -> &StateSnapshots> { + &self.inner.state_snapshots } /// Sets the address of the `DSTest` contract that is being executed @@ -591,18 +593,18 @@ impl Backend { self.inner.caller } - /// Failures occurred in snapshots are tracked when the snapshot is reverted + /// Failures occurred in state snapshots are tracked when the state snapshot is reverted. /// - /// If an error occurs in a restored snapshot, the test is considered failed. + /// If an error occurs in a restored state snapshot, the test is considered failed. /// - /// This returns whether there was a reverted snapshot that recorded an error - pub fn has_snapshot_failure(&self) -> bool { - self.inner.has_snapshot_failure + /// This returns whether there was a reverted state snapshot that recorded an error. + pub fn has_state_snapshot_failure(&self) -> bool { + self.inner.has_state_snapshot_failure } - /// Sets the snapshot failure flag. - pub fn set_snapshot_failure(&mut self, has_snapshot_failure: bool) { - self.inner.has_snapshot_failure = has_snapshot_failure + /// Sets the state snapshot failure flag. + pub fn set_state_snapshot_failure(&mut self, has_state_snapshot_failure: bool) { + self.inner.has_state_snapshot_failure = has_state_snapshot_failure } /// When creating or switching forks, we update the AccountInfo of the contract @@ -904,9 +906,9 @@ impl Backend { } impl DatabaseExt for Backend { - fn snapshot(&mut self, journaled_state: &JournaledState, env: &Env) -> U256 { + fn snapshot_state(&mut self, journaled_state: &JournaledState, env: &Env) -> U256 { trace!("create snapshot"); - let id = self.inner.snapshots.insert(BackendSnapshot::new( + let id = self.inner.state_snapshots.insert(BackendStateSnapshot::new( self.create_db_snapshot(), journaled_state.clone(), env.clone(), @@ -915,18 +917,18 @@ impl DatabaseExt for Backend { id } - fn revert( + fn revert_state( &mut self, id: U256, current_state: &JournaledState, current: &mut Env, - action: RevertSnapshotAction, + action: RevertStateSnapshotAction, ) -> Option { trace!(?id, "revert snapshot"); - if let Some(mut snapshot) = self.inner.snapshots.remove_at(id) { + if let Some(mut snapshot) = self.inner.state_snapshots.remove_at(id) { // Re-insert snapshot to persist it if action.is_keep() { - self.inner.snapshots.insert_at(snapshot.clone(), id); + self.inner.state_snapshots.insert_at(snapshot.clone(), id); } // https://github.com/foundry-rs/foundry/issues/3055 @@ -936,14 +938,14 @@ impl DatabaseExt for Backend { if let Some(account) = current_state.state.get(&CHEATCODE_ADDRESS) { if let Some(slot) = account.storage.get(&GLOBAL_FAIL_SLOT) { if !slot.present_value.is_zero() { - self.set_snapshot_failure(true); + self.set_state_snapshot_failure(true); } } } // merge additional logs snapshot.merge(current_state); - let BackendSnapshot { db, mut journaled_state, env } = snapshot; + let BackendStateSnapshot { db, mut journaled_state, env } = snapshot; match db { BackendDatabaseSnapshot::InMemory(mem_db) => { self.mem_db = mem_db; @@ -966,7 +968,7 @@ impl DatabaseExt for Backend { } caller_account.into() }); - self.inner.revert_snapshot(id, fork_id, idx, *fork); + self.inner.revert_state_snapshot(id, fork_id, idx, *fork); self.active_fork_ids = Some((id, idx)) } } @@ -981,12 +983,12 @@ impl DatabaseExt for Backend { } } - fn delete_snapshot(&mut self, id: U256) -> bool { - self.inner.snapshots.remove_at(id).is_some() + fn delete_state_snapshot(&mut self, id: U256) -> bool { + self.inner.state_snapshots.remove_at(id).is_some() } - fn delete_snapshots(&mut self) { - self.inner.snapshots.clear() + fn delete_state_snapshots(&mut self) { + self.inner.state_snapshots.clear() } fn create_fork(&mut self, create_fork: CreateFork) -> eyre::Result { @@ -1599,8 +1601,8 @@ pub struct BackendInner { /// Holds all created fork databases // Note: data is stored in an `Option` so we can remove it without reshuffling pub forks: Vec>, - /// Contains snapshots made at a certain point - pub snapshots: Snapshots>, + /// Contains state snapshots made at a certain point + pub state_snapshots: StateSnapshots>, /// Tracks whether there was a failure in a snapshot that was reverted /// /// The Test contract contains a bool variable that is set to true when an `assert` function @@ -1610,7 +1612,7 @@ pub struct BackendInner { /// reverted we get the _current_ `revm::JournaledState` which contains the state that we can /// check if the `_failed` variable is set, /// additionally - pub has_snapshot_failure: bool, + pub has_state_snapshot_failure: bool, /// Tracks the caller of the test function pub caller: Option

, /// Tracks numeric identifiers for forks @@ -1694,7 +1696,7 @@ impl BackendInner { } /// Reverts the entire fork database - pub fn revert_snapshot( + pub fn revert_state_snapshot( &mut self, id: LocalForkId, fork_id: ForkId, @@ -1797,8 +1799,8 @@ impl Default for BackendInner { issued_local_fork_ids: Default::default(), created_forks: Default::default(), forks: vec![], - snapshots: Default::default(), - has_snapshot_failure: false, + state_snapshots: Default::default(), + has_state_snapshot_failure: false, caller: None, next_fork_id: Default::default(), persistent_accounts: Default::default(), diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index f8961c7a0e674..7bfed1283feaf 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -13,9 +13,9 @@ pub struct StateSnapshot { pub block_hashes: HashMap, } -/// Represents a snapshot taken during evm execution +/// Represents a state snapshot taken during evm execution #[derive(Clone, Debug)] -pub struct BackendSnapshot { +pub struct BackendStateSnapshot { pub db: T, /// The journaled_state state at a specific point pub journaled_state: JournaledState, @@ -23,38 +23,38 @@ pub struct BackendSnapshot { pub env: Env, } -impl BackendSnapshot { - /// Takes a new snapshot +impl BackendStateSnapshot { + /// Takes a new state snapshot. pub fn new(db: T, journaled_state: JournaledState, env: Env) -> Self { Self { db, journaled_state, env } } - /// Called when this snapshot is reverted. + /// Called when this state snapshot is reverted. /// /// Since we want to keep all additional logs that were emitted since the snapshot was taken /// we'll merge additional logs into the snapshot's `revm::JournaledState`. Additional logs are /// those logs that are missing in the snapshot's journaled_state, since the current /// journaled_state includes the same logs, we can simply replace use that See also - /// `DatabaseExt::revert` + /// `DatabaseExt::revert`. pub fn merge(&mut self, current: &JournaledState) { self.journaled_state.logs.clone_from(¤t.logs); } } -/// What to do when reverting a snapshot +/// What to do when reverting a state snapshot. /// -/// Whether to remove the snapshot or keep it +/// Whether to remove the state snapshot or keep it. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -pub enum RevertSnapshotAction { - /// Remove the snapshot after reverting +pub enum RevertStateSnapshotAction { + /// Remove the state snapshot after reverting. #[default] RevertRemove, - /// Keep the snapshot after reverting + /// Keep the state snapshot after reverting. RevertKeep, } -impl RevertSnapshotAction { - /// Returns `true` if the action is to keep the snapshot +impl RevertStateSnapshotAction { + /// Returns `true` if the action is to keep the state snapshot. pub fn is_keep(&self) -> bool { matches!(self, Self::RevertKeep) } diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 873e8a8962ab2..a8d2ccc1db9a5 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -1,8 +1,8 @@ //! A revm database that forks off a remote client use crate::{ - backend::{RevertSnapshotAction, StateSnapshot}, - snapshot::Snapshots, + backend::{RevertStateSnapshotAction, StateSnapshot}, + state_snapshot::StateSnapshots, }; use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types::BlockId; @@ -23,22 +23,22 @@ use std::sync::Arc; /// `backend` will also write (missing) data to the `db` in the background #[derive(Clone, Debug)] pub struct ForkedDatabase { - /// responsible for fetching missing data + /// Responsible for fetching missing data. /// - /// This is responsible for getting data + /// This is responsible for getting data. backend: SharedBackend, /// Cached Database layer, ensures that changes are not written to the database that /// exclusively stores the state of the remote client. /// /// This separates Read/Write operations - /// - reads from the `SharedBackend as DatabaseRef` writes to the internal cache storage + /// - reads from the `SharedBackend as DatabaseRef` writes to the internal cache storage. cache_db: CacheDB, - /// Contains all the data already fetched + /// Contains all the data already fetched. /// - /// This exclusively stores the _unchanged_ remote client state + /// This exclusively stores the _unchanged_ remote client state. db: BlockchainDb, - /// holds the snapshot state of a blockchain - snapshots: Arc>>, + /// Holds the state snapshots of a blockchain. + state_snapshots: Arc>>, } impl ForkedDatabase { @@ -48,7 +48,7 @@ impl ForkedDatabase { cache_db: CacheDB::new(backend.clone()), backend, db, - snapshots: Arc::new(Mutex::new(Default::default())), + state_snapshots: Arc::new(Mutex::new(Default::default())), } } @@ -60,8 +60,8 @@ impl ForkedDatabase { &mut self.cache_db } - pub fn snapshots(&self) -> &Arc>> { - &self.snapshots + pub fn state_snapshots(&self) -> &Arc>> { + &self.state_snapshots } /// Reset the fork to a fresh forked state, and optionally update the fork config @@ -92,35 +92,35 @@ impl ForkedDatabase { &self.db } - pub fn create_snapshot(&self) -> ForkDbSnapshot { + pub fn create_state_snapshot(&self) -> ForkDbStateSnapshot { let db = self.db.db(); - let snapshot = StateSnapshot { + let state_snapshot = StateSnapshot { accounts: db.accounts.read().clone(), storage: db.storage.read().clone(), block_hashes: db.block_hashes.read().clone(), }; - ForkDbSnapshot { local: self.cache_db.clone(), snapshot } + ForkDbStateSnapshot { local: self.cache_db.clone(), state_snapshot } } - pub fn insert_snapshot(&self) -> U256 { - let snapshot = self.create_snapshot(); - let mut snapshots = self.snapshots().lock(); - let id = snapshots.insert(snapshot); + pub fn insert_state_snapshot(&self) -> U256 { + let state_snapshot = self.create_state_snapshot(); + let mut state_snapshots = self.state_snapshots().lock(); + let id = state_snapshots.insert(state_snapshot); trace!(target: "backend::forkdb", "Created new snapshot {}", id); id } /// Removes the snapshot from the tracked snapshot and sets it as the current state - pub fn revert_snapshot(&mut self, id: U256, action: RevertSnapshotAction) -> bool { - let snapshot = { self.snapshots().lock().remove_at(id) }; - if let Some(snapshot) = snapshot { + pub fn revert_state_snapshot(&mut self, id: U256, action: RevertStateSnapshotAction) -> bool { + let state_snapshot = { self.state_snapshots().lock().remove_at(id) }; + if let Some(state_snapshot) = state_snapshot { if action.is_keep() { - self.snapshots().lock().insert_at(snapshot.clone(), id); + self.state_snapshots().lock().insert_at(state_snapshot.clone(), id); } - let ForkDbSnapshot { + let ForkDbStateSnapshot { local, - snapshot: StateSnapshot { accounts, storage, block_hashes }, - } = snapshot; + state_snapshot: StateSnapshot { accounts, storage, block_hashes }, + } = state_snapshot; let db = self.inner().db(); { let mut accounts_lock = db.accounts.write(); @@ -202,12 +202,12 @@ impl DatabaseCommit for ForkedDatabase { /// /// This mimics `revm::CacheDB` #[derive(Clone, Debug)] -pub struct ForkDbSnapshot { +pub struct ForkDbStateSnapshot { pub local: CacheDB, - pub snapshot: StateSnapshot, + pub state_snapshot: StateSnapshot, } -impl ForkDbSnapshot { +impl ForkDbStateSnapshot { fn get_storage(&self, address: Address, index: U256) -> Option { self.local.accounts.get(&address).and_then(|account| account.storage.get(&index)).copied() } @@ -216,14 +216,14 @@ impl ForkDbSnapshot { // This `DatabaseRef` implementation works similar to `CacheDB` which prioritizes modified elements, // and uses another db as fallback // We prioritize stored changed accounts/storage -impl DatabaseRef for ForkDbSnapshot { +impl DatabaseRef for ForkDbStateSnapshot { type Error = DatabaseError; fn basic_ref(&self, address: Address) -> Result, Self::Error> { match self.local.accounts.get(&address) { Some(account) => Ok(Some(account.info.clone())), None => { - let mut acc = self.snapshot.accounts.get(&address).cloned(); + let mut acc = self.state_snapshot.accounts.get(&address).cloned(); if acc.is_none() { acc = self.local.basic_ref(address)?; @@ -254,7 +254,7 @@ impl DatabaseRef for ForkDbSnapshot { } fn block_hash_ref(&self, number: u64) -> Result { - match self.snapshot.block_hashes.get(&U256::from(number)).copied() { + match self.state_snapshot.block_hashes.get(&U256::from(number)).copied() { None => self.local.block_hash_ref(number), Some(block_hash) => Ok(block_hash), } diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 48c6478651acb..b30a36544b488 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -26,7 +26,7 @@ pub mod fork; pub mod opcodes; pub mod opts; pub mod precompiles; -pub mod snapshot; +pub mod state_snapshot; pub mod utils; /// An extension trait that allows us to add additional hooks to Inspector for later use in diff --git a/crates/evm/core/src/snapshot.rs b/crates/evm/core/src/snapshot.rs deleted file mode 100644 index 423f853eed498..0000000000000 --- a/crates/evm/core/src/snapshot.rs +++ /dev/null @@ -1,74 +0,0 @@ -//! support for snapshotting different states - -use alloy_primitives::U256; -use std::{collections::HashMap, ops::Add}; - -/// Represents all snapshots -#[derive(Clone, Debug)] -pub struct Snapshots { - id: U256, - snapshots: HashMap, -} - -impl Snapshots { - fn next_id(&mut self) -> U256 { - let id = self.id; - self.id = id.saturating_add(U256::from(1)); - id - } - - /// Returns the snapshot with the given id `id` - pub fn get(&self, id: U256) -> Option<&T> { - self.snapshots.get(&id) - } - - /// Removes the snapshot with the given `id`. - /// - /// This will also remove any snapshots taken after the snapshot with the `id`. e.g.: reverting - /// to id 1 will delete snapshots with ids 1, 2, 3, etc.) - pub fn remove(&mut self, id: U256) -> Option { - let snapshot = self.snapshots.remove(&id); - - // revert all snapshots taken after the snapshot - let mut to_revert = id.add(U256::from(1)); - while to_revert < self.id { - self.snapshots.remove(&to_revert); - to_revert += U256::from(1); - } - - snapshot - } - - /// Removes all snapshots - pub fn clear(&mut self) { - self.snapshots.clear(); - } - - /// Removes the snapshot with the given `id`. - /// - /// Does not remove snapshots after it. - pub fn remove_at(&mut self, id: U256) -> Option { - self.snapshots.remove(&id) - } - - /// Inserts the new snapshot and returns the id - pub fn insert(&mut self, snapshot: T) -> U256 { - let id = self.next_id(); - self.snapshots.insert(id, snapshot); - id - } - - /// Inserts the new snapshot at the given `id`. - /// - /// Does not auto-increment the next `id`. - pub fn insert_at(&mut self, snapshot: T, id: U256) -> U256 { - self.snapshots.insert(id, snapshot); - id - } -} - -impl Default for Snapshots { - fn default() -> Self { - Self { id: U256::ZERO, snapshots: HashMap::new() } - } -} diff --git a/crates/evm/core/src/state_snapshot.rs b/crates/evm/core/src/state_snapshot.rs new file mode 100644 index 0000000000000..e273a573344de --- /dev/null +++ b/crates/evm/core/src/state_snapshot.rs @@ -0,0 +1,74 @@ +//! Support for snapshotting different states + +use alloy_primitives::U256; +use std::{collections::HashMap, ops::Add}; + +/// Represents all state snapshots +#[derive(Clone, Debug)] +pub struct StateSnapshots { + id: U256, + state_snapshots: HashMap, +} + +impl StateSnapshots { + fn next_id(&mut self) -> U256 { + let id = self.id; + self.id = id.saturating_add(U256::from(1)); + id + } + + /// Returns the state snapshot with the given id `id` + pub fn get(&self, id: U256) -> Option<&T> { + self.state_snapshots.get(&id) + } + + /// Removes the state snapshot with the given `id`. + /// + /// This will also remove any state snapshots taken after the state snapshot with the `id`. + /// e.g.: reverting to id 1 will delete snapshots with ids 1, 2, 3, etc.) + pub fn remove(&mut self, id: U256) -> Option { + let snapshot_state = self.state_snapshots.remove(&id); + + // Revert all state snapshots taken after the state snapshot with the `id` + let mut to_revert = id.add(U256::from(1)); + while to_revert < self.id { + self.state_snapshots.remove(&to_revert); + to_revert += U256::from(1); + } + + snapshot_state + } + + /// Removes all state snapshots. + pub fn clear(&mut self) { + self.state_snapshots.clear(); + } + + /// Removes the state snapshot with the given `id`. + /// + /// Does not remove state snapshots after it. + pub fn remove_at(&mut self, id: U256) -> Option { + self.state_snapshots.remove(&id) + } + + /// Inserts the new state snapshot and returns the id. + pub fn insert(&mut self, state_snapshot: T) -> U256 { + let id = self.next_id(); + self.state_snapshots.insert(id, state_snapshot); + id + } + + /// Inserts the new state snapshot at the given `id`. + /// + /// Does not auto-increment the next `id`. + pub fn insert_at(&mut self, state_snapshot: T, id: U256) -> U256 { + self.state_snapshots.insert(id, state_snapshot); + id + } +} + +impl Default for StateSnapshots { + fn default() -> Self { + Self { id: U256::ZERO, state_snapshots: HashMap::new() } + } +} diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index dc923d6e00b3e..7a1a794f607e4 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -395,7 +395,7 @@ impl Executor { let mut inspector = self.inspector().clone(); let mut backend = CowBackend::new_borrowed(self.backend()); let result = backend.inspect(&mut env, &mut inspector)?; - convert_executed_result(env, inspector, result, backend.has_snapshot_failure()) + convert_executed_result(env, inspector, result, backend.has_state_snapshot_failure()) } /// Execute the transaction configured in `env.tx`. @@ -405,7 +405,7 @@ impl Executor { let backend = self.backend_mut(); let result = backend.inspect(&mut env, &mut inspector)?; let mut result = - convert_executed_result(env, inspector, result, backend.has_snapshot_failure())?; + convert_executed_result(env, inspector, result, backend.has_state_snapshot_failure())?; self.commit(&mut result); Ok(result) } @@ -465,7 +465,7 @@ impl Executor { call_result: &RawCallResult, should_fail: bool, ) -> bool { - if call_result.has_snapshot_failure { + if call_result.has_state_snapshot_failure { // a failure occurred in a reverted snapshot, which is considered a failed test return should_fail; } @@ -517,7 +517,7 @@ impl Executor { } // A failure occurred in a reverted snapshot, which is considered a failed test. - if self.backend().has_snapshot_failure() { + if self.backend().has_state_snapshot_failure() { return false; } @@ -711,7 +711,7 @@ pub struct RawCallResult { /// /// This is tracked separately from revert because a snapshot failure can occur without a /// revert, since assert failures are stored in a global variable (ds-test legacy) - pub has_snapshot_failure: bool, + pub has_state_snapshot_failure: bool, /// The raw result of the call. pub result: Bytes, /// The gas used for the call @@ -747,7 +747,7 @@ impl Default for RawCallResult { Self { exit_reason: InstructionResult::Continue, reverted: false, - has_snapshot_failure: false, + has_state_snapshot_failure: false, result: Bytes::new(), gas_used: 0, gas_refunded: 0, @@ -842,7 +842,7 @@ fn convert_executed_result( env: EnvWithHandlerCfg, inspector: InspectorStack, ResultAndState { result, state: state_changeset }: ResultAndState, - has_snapshot_failure: bool, + has_state_snapshot_failure: bool, ) -> eyre::Result { let (exit_reason, gas_refunded, gas_used, out, exec_logs) = match result { ExecutionResult::Success { reason, gas_used, gas_refunded, output, logs, .. } => { @@ -884,7 +884,7 @@ fn convert_executed_result( Ok(RawCallResult { exit_reason, reverted: !matches!(exit_reason, return_ok!()), - has_snapshot_failure, + has_state_snapshot_failure, result, gas_used, gas_refunded, diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 8c3d57fc3135c..20c5013ec450f 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -24,8 +24,8 @@ pub static RE_BASIC_SNAPSHOT_ENTRY: LazyLock = LazyLock::new(|| { /// CLI arguments for `forge snapshot`. #[derive(Clone, Debug, Parser)] -pub struct SnapshotArgs { - /// Output a diff against a pre-existing snapshot. +pub struct GasSnapshotArgs { + /// Output a diff against a pre-existing gas snapshot. /// /// By default, the comparison is done with .gas-snapshot. #[arg( @@ -36,9 +36,9 @@ pub struct SnapshotArgs { )] diff: Option>, - /// Compare against a pre-existing snapshot, exiting with code 1 if they do not match. + /// Compare against a pre-existing gas snapshot, exiting with code 1 if they do not match. /// - /// Outputs a diff if the snapshots do not match. + /// Outputs a diff if the gas snapshots do not match. /// /// By default, the comparison is done with .gas-snapshot. #[arg( @@ -54,7 +54,7 @@ pub struct SnapshotArgs { #[arg(long, hide(true))] format: Option, - /// Output file for the snapshot. + /// Output file for the gas snapshot. #[arg( long, default_value = ".gas-snapshot", @@ -77,11 +77,11 @@ pub struct SnapshotArgs { /// Additional configs for test results #[command(flatten)] - config: SnapshotConfig, + config: GasSnapshotConfig, } -impl SnapshotArgs { - /// Returns whether `SnapshotArgs` was configured with `--watch` +impl GasSnapshotArgs { + /// Returns whether `GasSnapshotArgs` was configured with `--watch` pub fn is_watch(&self) -> bool { self.test.is_watch() } @@ -102,18 +102,18 @@ impl SnapshotArgs { if let Some(path) = self.diff { let snap = path.as_ref().unwrap_or(&self.snap); - let snaps = read_snapshot(snap)?; + let snaps = read_gas_snapshot(snap)?; diff(tests, snaps)?; } else if let Some(path) = self.check { let snap = path.as_ref().unwrap_or(&self.snap); - let snaps = read_snapshot(snap)?; + let snaps = read_gas_snapshot(snap)?; if check(tests, snaps, self.tolerance) { std::process::exit(0) } else { std::process::exit(1) } } else { - write_to_snapshot_file(&tests, self.snap, self.format)?; + write_to_gas_snapshot_file(&tests, self.snap, self.format)?; } Ok(()) } @@ -138,7 +138,7 @@ impl FromStr for Format { /// Additional filters that can be applied on the test results #[derive(Clone, Debug, Default, Parser)] -struct SnapshotConfig { +struct GasSnapshotConfig { /// Sort results by gas used (ascending). #[arg(long)] asc: bool, @@ -156,7 +156,7 @@ struct SnapshotConfig { max: Option, } -impl SnapshotConfig { +impl GasSnapshotConfig { fn is_in_gas_range(&self, gas_used: u64) -> bool { if let Some(min) = self.min { if gas_used < min { @@ -187,20 +187,20 @@ impl SnapshotConfig { } } -/// A general entry in a snapshot file +/// A general entry in a gas snapshot file /// /// Has the form: /// `(gas:? 40181)` for normal tests /// `(runs: 256, μ: 40181, ~: 40181)` for fuzz tests /// `(runs: 256, calls: 40181, reverts: 40181)` for invariant tests #[derive(Clone, Debug, PartialEq, Eq)] -pub struct SnapshotEntry { +pub struct GasSnapshotEntry { pub contract_name: String, pub signature: String, pub gas_used: TestKindReport, } -impl FromStr for SnapshotEntry { +impl FromStr for GasSnapshotEntry { type Err = String; fn from_str(s: &str) -> Result { @@ -253,8 +253,8 @@ impl FromStr for SnapshotEntry { } } -/// Reads a list of snapshot entries from a snapshot file -fn read_snapshot(path: impl AsRef) -> Result> { +/// Reads a list of gas snapshot entries from a gas snapshot file. +fn read_gas_snapshot(path: impl AsRef) -> Result> { let path = path.as_ref(); let mut entries = Vec::new(); for line in io::BufReader::new( @@ -263,13 +263,14 @@ fn read_snapshot(path: impl AsRef) -> Result> { ) .lines() { - entries.push(SnapshotEntry::from_str(line?.as_str()).map_err(|err| eyre::eyre!("{err}"))?); + entries + .push(GasSnapshotEntry::from_str(line?.as_str()).map_err(|err| eyre::eyre!("{err}"))?); } Ok(entries) } -/// Writes a series of tests to a snapshot file after sorting them -fn write_to_snapshot_file( +/// Writes a series of tests to a gas snapshot file after sorting them. +fn write_to_gas_snapshot_file( tests: &[SuiteTestResult], path: impl AsRef, _format: Option, @@ -288,15 +289,15 @@ fn write_to_snapshot_file( Ok(fs::write(path, content)?) } -/// A Snapshot entry diff +/// A Gas snapshot entry diff. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct SnapshotDiff { +pub struct GasSnapshotDiff { pub signature: String, pub source_gas_used: TestKindReport, pub target_gas_used: TestKindReport, } -impl SnapshotDiff { +impl GasSnapshotDiff { /// Returns the gas diff /// /// `> 0` if the source used more gas @@ -311,10 +312,14 @@ impl SnapshotDiff { } } -/// Compares the set of tests with an existing snapshot +/// Compares the set of tests with an existing gas snapshot. /// /// Returns true all tests match -fn check(tests: Vec, snaps: Vec, tolerance: Option) -> bool { +fn check( + tests: Vec, + snaps: Vec, + tolerance: Option, +) -> bool { let snaps = snaps .into_iter() .map(|s| ((s.contract_name, s.signature), s.gas_used)) @@ -347,8 +352,8 @@ fn check(tests: Vec, snaps: Vec, tolerance: Opti !has_diff } -/// Compare the set of tests with an existing snapshot -fn diff(tests: Vec, snaps: Vec) -> Result<()> { +/// Compare the set of tests with an existing gas snapshot. +fn diff(tests: Vec, snaps: Vec) -> Result<()> { let snaps = snaps .into_iter() .map(|s| ((s.contract_name, s.signature), s.gas_used)) @@ -358,7 +363,7 @@ fn diff(tests: Vec, snaps: Vec) -> Result<()> { if let Some(target_gas_used) = snaps.get(&(test.contract_name().to_string(), test.signature.clone())).cloned() { - diffs.push(SnapshotDiff { + diffs.push(GasSnapshotDiff { source_gas_used: test.result.kind.report(), signature: test.signature, target_gas_used, @@ -446,12 +451,12 @@ mod tests { } #[test] - fn can_parse_basic_snapshot_entry() { + fn can_parse_basic_gas_snapshot_entry() { let s = "Test:deposit() (gas: 7222)"; - let entry = SnapshotEntry::from_str(s).unwrap(); + let entry = GasSnapshotEntry::from_str(s).unwrap(); assert_eq!( entry, - SnapshotEntry { + GasSnapshotEntry { contract_name: "Test".to_string(), signature: "deposit()".to_string(), gas_used: TestKindReport::Unit { gas: 7222 } @@ -460,12 +465,12 @@ mod tests { } #[test] - fn can_parse_fuzz_snapshot_entry() { + fn can_parse_fuzz_gas_snapshot_entry() { let s = "Test:deposit() (runs: 256, μ: 100, ~:200)"; - let entry = SnapshotEntry::from_str(s).unwrap(); + let entry = GasSnapshotEntry::from_str(s).unwrap(); assert_eq!( entry, - SnapshotEntry { + GasSnapshotEntry { contract_name: "Test".to_string(), signature: "deposit()".to_string(), gas_used: TestKindReport::Fuzz { runs: 256, median_gas: 200, mean_gas: 100 } @@ -474,12 +479,12 @@ mod tests { } #[test] - fn can_parse_invariant_snapshot_entry() { + fn can_parse_invariant_gas_snapshot_entry() { let s = "Test:deposit() (runs: 256, calls: 100, reverts: 200)"; - let entry = SnapshotEntry::from_str(s).unwrap(); + let entry = GasSnapshotEntry::from_str(s).unwrap(); assert_eq!( entry, - SnapshotEntry { + GasSnapshotEntry { contract_name: "Test".to_string(), signature: "deposit()".to_string(), gas_used: TestKindReport::Invariant { runs: 256, calls: 100, reverts: 200 } @@ -488,12 +493,12 @@ mod tests { } #[test] - fn can_parse_invariant_snapshot_entry2() { + fn can_parse_invariant_gas_snapshot_entry2() { let s = "ERC20Invariants:invariantBalanceSum() (runs: 256, calls: 3840, reverts: 2388)"; - let entry = SnapshotEntry::from_str(s).unwrap(); + let entry = GasSnapshotEntry::from_str(s).unwrap(); assert_eq!( entry, - SnapshotEntry { + GasSnapshotEntry { contract_name: "ERC20Invariants".to_string(), signature: "invariantBalanceSum()".to_string(), gas_used: TestKindReport::Invariant { runs: 256, calls: 3840, reverts: 2388 } diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 10562ba1295c5..19b37009fd6f2 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -1,4 +1,4 @@ -use super::{build::BuildArgs, doc::DocArgs, snapshot::SnapshotArgs, test::TestArgs}; +use super::{build::BuildArgs, doc::DocArgs, snapshot::GasSnapshotArgs, test::TestArgs}; use clap::Parser; use eyre::Result; use foundry_cli::utils::{self, FoundryPathExt}; @@ -249,7 +249,7 @@ pub async fn watch_build(args: BuildArgs) -> Result<()> { /// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge /// snapshot` -pub async fn watch_snapshot(args: SnapshotArgs) -> Result<()> { +pub async fn watch_gas_snapshot(args: GasSnapshotArgs) -> Result<()> { let config = args.watchexec_config()?; run(config).await } diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index f92d3db8085b7..9a98d8aeffd02 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -88,7 +88,7 @@ fn main() -> Result<()> { } ForgeSubcommand::Snapshot(cmd) => { if cmd.is_watch() { - utils::block_on(watch::watch_snapshot(cmd)) + utils::block_on(watch::watch_gas_snapshot(cmd)) } else { utils::block_on(cmd.run()) } diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index fbe1f67df88ad..c929d0185ba7e 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -123,9 +123,9 @@ pub enum ForgeSubcommand { /// Manage the Foundry cache. Cache(CacheArgs), - /// Create a snapshot of each test's gas usage. + /// Create a gas snapshot of each test's gas usage. #[command(visible_alias = "s")] - Snapshot(snapshot::SnapshotArgs), + Snapshot(snapshot::GasSnapshotArgs), /// Display the current config. #[command(visible_alias = "co")] diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 0d1e15052a793..d463d12dd7c72 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -251,7 +251,7 @@ test_repro!(6355, false, None, |res| { let test = res.test_results.remove("test_shouldFail()").unwrap(); assert_eq!(test.status, TestStatus::Failure); - let test = res.test_results.remove("test_shouldFailWithRevertTo()").unwrap(); + let test = res.test_results.remove("test_shouldFailWithRevertToState()").unwrap(); assert_eq!(test.status, TestStatus::Failure); }); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 2b93473827ebf..09099f5402a2d 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -176,6 +176,8 @@ interface Vm { function deal(address account, uint256 newBalance) external; function deleteSnapshot(uint256 snapshotId) external returns (bool success); function deleteSnapshots() external; + 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 deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey); @@ -370,6 +372,8 @@ interface Vm { function resumeTracing() external view; function revertTo(uint256 snapshotId) external returns (bool success); function revertToAndDelete(uint256 snapshotId) external returns (bool success); + function revertToState(uint256 snapshotId) external returns (bool success); + function revertToStateAndDelete(uint256 snapshotId) external returns (bool success); function revokePersistent(address account) external; function revokePersistent(address[] calldata accounts) external; function roll(uint256 newHeight) external; @@ -419,6 +423,7 @@ interface Vm { function skip(bool skipTest, string calldata reason) external; function sleep(uint256 duration) external; function snapshot() external returns (uint256 snapshotId); + function snapshotState() external returns (uint256 snapshotId); function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs); function startBroadcast() external; function startBroadcast(address signer) external; diff --git a/testdata/default/cheats/Prevrandao.t.sol b/testdata/default/cheats/Prevrandao.t.sol index 7011ce3bee9cc..75f2b2cc13020 100644 --- a/testdata/default/cheats/Prevrandao.t.sol +++ b/testdata/default/cheats/Prevrandao.t.sol @@ -23,12 +23,12 @@ contract PrevrandaoTest is DSTest { function testPrevrandaoSnapshotFuzzed(uint256 newPrevrandao) public { vm.assume(newPrevrandao != block.prevrandao); uint256 oldPrevrandao = block.prevrandao; - uint256 snapshot = vm.snapshot(); + uint256 snapshotId = vm.snapshotState(); vm.prevrandao(newPrevrandao); assertEq(block.prevrandao, newPrevrandao); - assert(vm.revertTo(snapshot)); + assert(vm.revertToState(snapshotId)); assertEq(block.prevrandao, oldPrevrandao); } } diff --git a/testdata/default/cheats/Snapshots.t.sol b/testdata/default/cheats/Snapshots.t.sol deleted file mode 100644 index bb7b4e0e6008d..0000000000000 --- a/testdata/default/cheats/Snapshots.t.sol +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; - -import "ds-test/test.sol"; -import "cheats/Vm.sol"; - -struct Storage { - uint256 slot0; - uint256 slot1; -} - -contract SnapshotTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); - - Storage store; - - function setUp() public { - store.slot0 = 10; - store.slot1 = 20; - } - - function testSnapshot() public { - uint256 snapshot = vm.snapshot(); - store.slot0 = 300; - store.slot1 = 400; - - assertEq(store.slot0, 300); - assertEq(store.slot1, 400); - - vm.revertTo(snapshot); - assertEq(store.slot0, 10, "snapshot revert for slot 0 unsuccessful"); - assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); - } - - function testSnapshotRevertDelete() public { - uint256 snapshot = vm.snapshot(); - store.slot0 = 300; - store.slot1 = 400; - - assertEq(store.slot0, 300); - assertEq(store.slot1, 400); - - vm.revertToAndDelete(snapshot); - assertEq(store.slot0, 10, "snapshot revert for slot 0 unsuccessful"); - assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); - // nothing to revert to anymore - assert(!vm.revertTo(snapshot)); - } - - function testSnapshotDelete() public { - uint256 snapshot = vm.snapshot(); - store.slot0 = 300; - store.slot1 = 400; - - vm.deleteSnapshot(snapshot); - // nothing to revert to anymore - assert(!vm.revertTo(snapshot)); - } - - function testSnapshotDeleteAll() public { - uint256 snapshot = vm.snapshot(); - store.slot0 = 300; - store.slot1 = 400; - - vm.deleteSnapshots(); - // nothing to revert to anymore - assert(!vm.revertTo(snapshot)); - } - - // - function testSnapshotsMany() public { - uint256 preState; - for (uint256 c = 0; c < 10; c++) { - for (uint256 cc = 0; cc < 10; cc++) { - preState = vm.snapshot(); - vm.revertToAndDelete(preState); - assert(!vm.revertTo(preState)); - } - } - } - - // tests that snapshots can also revert changes to `block` - function testBlockValues() public { - uint256 num = block.number; - uint256 time = block.timestamp; - uint256 prevrandao = block.prevrandao; - - uint256 snapshot = vm.snapshot(); - - vm.warp(1337); - assertEq(block.timestamp, 1337); - - vm.roll(99); - assertEq(block.number, 99); - - vm.prevrandao(uint256(123)); - assertEq(block.prevrandao, 123); - - assert(vm.revertTo(snapshot)); - - assertEq(block.number, num, "snapshot revert for block.number unsuccessful"); - assertEq(block.timestamp, time, "snapshot revert for block.timestamp unsuccessful"); - assertEq(block.prevrandao, prevrandao, "snapshot revert for block.prevrandao unsuccessful"); - } -} diff --git a/testdata/default/cheats/StateSnapshots.t.sol b/testdata/default/cheats/StateSnapshots.t.sol new file mode 100644 index 0000000000000..92ee38d26e2e5 --- /dev/null +++ b/testdata/default/cheats/StateSnapshots.t.sol @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +struct Storage { + uint256 slot0; + uint256 slot1; +} + +contract StateSnapshotTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + Storage store; + + function setUp() public { + store.slot0 = 10; + store.slot1 = 20; + } + + function testStateSnapshot() public { + uint256 snapshotId = vm.snapshotState(); + store.slot0 = 300; + store.slot1 = 400; + + assertEq(store.slot0, 300); + assertEq(store.slot1, 400); + + vm.revertToState(snapshotId); + assertEq(store.slot0, 10, "snapshot revert for slot 0 unsuccessful"); + assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); + } + + function testStateSnapshotRevertDelete() public { + uint256 snapshotId = vm.snapshotState(); + store.slot0 = 300; + store.slot1 = 400; + + assertEq(store.slot0, 300); + assertEq(store.slot1, 400); + + vm.revertToStateAndDelete(snapshotId); + assertEq(store.slot0, 10, "snapshot revert for slot 0 unsuccessful"); + assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); + // nothing to revert to anymore + assert(!vm.revertToState(snapshotId)); + } + + function testStateSnapshotDelete() public { + uint256 snapshotId = vm.snapshotState(); + store.slot0 = 300; + store.slot1 = 400; + + vm.deleteStateSnapshot(snapshotId); + // nothing to revert to anymore + assert(!vm.revertToState(snapshotId)); + } + + function testStateSnapshotDeleteAll() public { + uint256 snapshotId = vm.snapshotState(); + store.slot0 = 300; + store.slot1 = 400; + + vm.deleteStateSnapshots(); + // nothing to revert to anymore + assert(!vm.revertToState(snapshotId)); + } + + // + function testStateSnapshotsMany() public { + uint256 snapshotId; + for (uint256 c = 0; c < 10; c++) { + for (uint256 cc = 0; cc < 10; cc++) { + snapshotId = vm.snapshotState(); + vm.revertToStateAndDelete(snapshotId); + assert(!vm.revertToState(snapshotId)); + } + } + } + + // tests that snapshots can also revert changes to `block` + function testBlockValues() public { + uint256 num = block.number; + uint256 time = block.timestamp; + uint256 prevrandao = block.prevrandao; + + uint256 snapshotId = vm.snapshotState(); + + vm.warp(1337); + assertEq(block.timestamp, 1337); + + vm.roll(99); + assertEq(block.number, 99); + + vm.prevrandao(uint256(123)); + assertEq(block.prevrandao, 123); + + assert(vm.revertToState(snapshotId)); + + assertEq(block.number, num, "snapshot revert for block.number unsuccessful"); + assertEq(block.timestamp, time, "snapshot revert for block.timestamp unsuccessful"); + assertEq(block.prevrandao, prevrandao, "snapshot revert for block.prevrandao unsuccessful"); + } +} + +// TODO: remove this test suite once `snapshot*` has been deprecated in favor of `snapshotState*`. +contract DeprecatedStateSnapshotTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + Storage store; + + function setUp() public { + store.slot0 = 10; + store.slot1 = 20; + } + + function testSnapshotState() public { + uint256 snapshotId = vm.snapshot(); + store.slot0 = 300; + store.slot1 = 400; + + assertEq(store.slot0, 300); + assertEq(store.slot1, 400); + + vm.revertTo(snapshotId); + assertEq(store.slot0, 10, "snapshot revert for slot 0 unsuccessful"); + assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); + } + + function testSnapshotStateRevertDelete() public { + uint256 snapshotId = vm.snapshot(); + store.slot0 = 300; + store.slot1 = 400; + + assertEq(store.slot0, 300); + assertEq(store.slot1, 400); + + vm.revertToAndDelete(snapshotId); + assertEq(store.slot0, 10, "snapshot revert for slot 0 unsuccessful"); + assertEq(store.slot1, 20, "snapshot revert for slot 1 unsuccessful"); + // nothing to revert to anymore + assert(!vm.revertTo(snapshotId)); + } + + function testSnapshotStateDelete() public { + uint256 snapshotId = vm.snapshot(); + store.slot0 = 300; + store.slot1 = 400; + + vm.deleteSnapshot(snapshotId); + // nothing to revert to anymore + assert(!vm.revertTo(snapshotId)); + } + + function testSnapshotStateDeleteAll() public { + uint256 snapshotId = vm.snapshot(); + store.slot0 = 300; + store.slot1 = 400; + + vm.deleteSnapshots(); + // nothing to revert to anymore + assert(!vm.revertTo(snapshotId)); + } + + // + function testSnapshotStatesMany() public { + uint256 snapshotId; + for (uint256 c = 0; c < 10; c++) { + for (uint256 cc = 0; cc < 10; cc++) { + snapshotId = vm.snapshot(); + vm.revertToAndDelete(snapshotId); + assert(!vm.revertTo(snapshotId)); + } + } + } + + // tests that snapshots can also revert changes to `block` + function testBlockValues() public { + uint256 num = block.number; + uint256 time = block.timestamp; + uint256 prevrandao = block.prevrandao; + + uint256 snapshotId = vm.snapshot(); + + vm.warp(1337); + assertEq(block.timestamp, 1337); + + vm.roll(99); + assertEq(block.number, 99); + + vm.prevrandao(uint256(123)); + assertEq(block.prevrandao, 123); + + assert(vm.revertTo(snapshotId)); + + assertEq(block.number, num, "snapshot revert for block.number unsuccessful"); + assertEq(block.timestamp, time, "snapshot revert for block.timestamp unsuccessful"); + assertEq(block.prevrandao, prevrandao, "snapshot revert for block.prevrandao unsuccessful"); + } +} diff --git a/testdata/default/cheats/loadAllocs.t.sol b/testdata/default/cheats/loadAllocs.t.sol index 358608860bd5d..a4b72af6b2fed 100644 --- a/testdata/default/cheats/loadAllocs.t.sol +++ b/testdata/default/cheats/loadAllocs.t.sol @@ -16,7 +16,7 @@ contract LoadAllocsTest is DSTest { allocsPath = string.concat(vm.projectRoot(), "/fixtures/Json/test_allocs.json"); // Snapshot the state; We'll restore it in each test that loads allocs inline. - snapshotId = vm.snapshot(); + snapshotId = vm.snapshotState(); // Load the allocs file. vm.loadAllocs(allocsPath); @@ -40,7 +40,7 @@ contract LoadAllocsTest is DSTest { /// @dev Checks that the `loadAllocs` cheatcode persists account info if called inline function testLoadAllocsStatic() public { // Restore the state snapshot prior to the allocs file being loaded. - vm.revertTo(snapshotId); + vm.revertToState(snapshotId); // Load the allocs file vm.loadAllocs(allocsPath); @@ -61,7 +61,7 @@ contract LoadAllocsTest is DSTest { /// @dev Checks that the `loadAllocs` cheatcode overrides existing account information (if present) function testLoadAllocsOverride() public { // Restore the state snapshot prior to the allocs file being loaded. - vm.revertTo(snapshotId); + vm.revertToState(snapshotId); // Populate the alloc'd account's code. vm.etch(ALLOCD, hex"FF"); @@ -88,7 +88,7 @@ contract LoadAllocsTest is DSTest { /// within the allocs/genesis file for the account field (i.e., partial overrides) function testLoadAllocsPartialOverride() public { // Restore the state snapshot prior to the allocs file being loaded. - vm.revertTo(snapshotId); + vm.revertToState(snapshotId); // Populate the alloc'd account's code. vm.etch(ALLOCD_B, hex"FF"); diff --git a/testdata/default/repros/Issue2984.t.sol b/testdata/default/repros/Issue2984.t.sol index 1a181ad533c2a..5f0203369e0d8 100644 --- a/testdata/default/repros/Issue2984.t.sol +++ b/testdata/default/repros/Issue2984.t.sol @@ -12,11 +12,11 @@ contract Issue2984Test is DSTest { function setUp() public { fork = vm.createSelectFork("avaxTestnet", 12880747); - snapshot = vm.snapshot(); + snapshot = vm.snapshotState(); } function testForkRevertSnapshot() public { - vm.revertTo(snapshot); + vm.revertToState(snapshot); } function testForkSelectSnapshot() public { diff --git a/testdata/default/repros/Issue3055.t.sol b/testdata/default/repros/Issue3055.t.sol index cacf5282f0581..72461a6c01651 100644 --- a/testdata/default/repros/Issue3055.t.sol +++ b/testdata/default/repros/Issue3055.t.sol @@ -9,15 +9,15 @@ contract Issue3055Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function test_snapshot() external { - uint256 snapId = vm.snapshot(); + uint256 snapshotId = vm.snapshotState(); assertEq(uint256(0), uint256(1)); - vm.revertTo(snapId); + vm.revertToState(snapshotId); } function test_snapshot2() public { - uint256 snapshot = vm.snapshot(); + uint256 snapshotId = vm.snapshotState(); assertTrue(false); - vm.revertTo(snapshot); + vm.revertToState(snapshotId); assertTrue(true); } @@ -29,8 +29,8 @@ contract Issue3055Test is DSTest { } function exposed_snapshot3() public { - uint256 snapshot = vm.snapshot(); + uint256 snapshotId = vm.snapshotState(); assertTrue(false); - vm.revertTo(snapshot); + vm.revertToState(snapshotId); } } diff --git a/testdata/default/repros/Issue3792.t.sol b/testdata/default/repros/Issue3792.t.sol index 723329f937a1e..1adeb88af8c9d 100644 --- a/testdata/default/repros/Issue3792.t.sol +++ b/testdata/default/repros/Issue3792.t.sol @@ -16,10 +16,10 @@ contract TestSetup is Config, DSTest { // We now check for keccak256("failed") on the hevm address. // This test should succeed. function testSnapshotStorageShift() public { - uint256 snapshotId = vm.snapshot(); + uint256 snapshotId = vm.snapshotState(); vm.prank(test); - vm.revertTo(snapshotId); + vm.revertToState(snapshotId); } } diff --git a/testdata/default/repros/Issue6355.t.sol b/testdata/default/repros/Issue6355.t.sol index d7830152a60a8..f002b2a87c03f 100644 --- a/testdata/default/repros/Issue6355.t.sol +++ b/testdata/default/repros/Issue6355.t.sol @@ -7,11 +7,11 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6355 contract Issue6355Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - uint256 snapshot; + uint256 snapshotId; Target targ; function setUp() public { - snapshot = vm.snapshot(); + snapshotId = vm.snapshotState(); targ = new Target(); } @@ -21,9 +21,9 @@ contract Issue6355Test is DSTest { } // always fails - function test_shouldFailWithRevertTo() public { + function test_shouldFailWithRevertToState() public { assertEq(3, targ.num()); - vm.revertTo(snapshot); + vm.revertToState(snapshotId); } // always fails From 25f24e677a6a32a62512ad4f561995589ac2c7dc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 27 Sep 2024 20:48:48 +0200 Subject: [PATCH 1501/1963] fix: 4844 fee fixes (#8963) * fix: use zero blob fee for estimate * add basic test * fix gas_price * support EIP-4844 with with_max_fee_per_blob_gas None * this should run succesfully once Alloy counterpart has been merged * undo max_fee_per_blob_gas != 0 check, not necessary anymore * clean up * fix setup bug from Matt * add test with signer, currently failing on Result::unwrap()` on an `Err` value: ErrorResp(ErrorPayload { code: -32003, message: "Block `blob_versioned_hashes` is not supported before the Cancun hardfork", data: None }) * able to reproduce * apply hotfix by Matt * remove debugs * use or_else, only need to do this if the blob_versioned hashes are non zero * move blob_hashes out --------- Co-authored-by: zerosnacks Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- crates/anvil/src/config.rs | 3 +- crates/anvil/src/eth/backend/mem/mod.rs | 50 ++++++----- crates/anvil/src/eth/fees.rs | 2 +- crates/anvil/tests/it/eip4844.rs | 93 +++++++++++++++++++- 5 files changed, 124 insertions(+), 26 deletions(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 25e42e001b21d..e03a862b86ab3 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -128,7 +128,7 @@ pub fn transaction_request_to_typed( })) } // EIP4844 - (Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), to) => { + (Some(3), None, _, _, _, _, Some(_), Some(sidecar), to) => { let tx = TxEip4844 { nonce: nonce.unwrap_or_default(), max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 96f4c53d5ee23..d907fc200f536 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -493,7 +493,8 @@ impl NodeConfig { { BlobExcessGasAndPrice::new(excess_blob_gas as u64) } else { - BlobExcessGasAndPrice { blob_gasprice: 0, excess_blob_gas: 0 } + // If no excess blob gas is configured, default to 0 + BlobExcessGasAndPrice::new(0) } } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index cd23fa6d3a94b..eed634bfacd5f 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1227,26 +1227,36 @@ impl Backend { }); let caller = from.unwrap_or_default(); let to = to.as_ref().and_then(TxKind::to); - env.tx = TxEnv { - caller, - gas_limit: gas_limit as u64, - gas_price: U256::from(gas_price), - gas_priority_fee: max_priority_fee_per_gas.map(U256::from), - max_fee_per_blob_gas: max_fee_per_blob_gas.map(U256::from), - transact_to: match to { - Some(addr) => TxKind::Call(*addr), - None => TxKind::Create, - }, - value: value.unwrap_or_default(), - data: input.into_input().unwrap_or_default(), - chain_id: None, - // set nonce to None so that the correct nonce is chosen by the EVM - nonce: None, - access_list: access_list.unwrap_or_default().into(), - blob_hashes: blob_versioned_hashes.unwrap_or_default(), - optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, - authorization_list: authorization_list.map(Into::into), - }; + let blob_hashes = blob_versioned_hashes.unwrap_or_default(); + env.tx = + TxEnv { + caller, + gas_limit: gas_limit as u64, + gas_price: U256::from(gas_price), + gas_priority_fee: max_priority_fee_per_gas.map(U256::from), + max_fee_per_blob_gas: max_fee_per_blob_gas + .or_else(|| { + if !blob_hashes.is_empty() { + env.block.get_blob_gasprice() + } else { + None + } + }) + .map(U256::from), + transact_to: match to { + Some(addr) => TxKind::Call(*addr), + None => TxKind::Create, + }, + value: value.unwrap_or_default(), + data: input.into_input().unwrap_or_default(), + chain_id: None, + // set nonce to None so that the correct nonce is chosen by the EVM + nonce: None, + access_list: access_list.unwrap_or_default().into(), + blob_hashes, + optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, + authorization_list: authorization_list.map(Into::into), + }; if env.block.basefee.is_zero() { // this is an edge case because the evm fails if `tx.effective_gas_price < base_fee` diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 45b33ad0fcdf6..cb1b8508fd24b 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -464,7 +464,7 @@ impl FeeDetails { impl fmt::Debug for FeeDetails { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "Fees {{ ")?; - write!(fmt, "gaPrice: {:?}, ", self.gas_price)?; + write!(fmt, "gas_price: {:?}, ", self.gas_price)?; write!(fmt, "max_fee_per_gas: {:?}, ", self.max_fee_per_gas)?; write!(fmt, "max_priority_fee_per_gas: {:?}, ", self.max_priority_fee_per_gas)?; write!(fmt, "}}")?; diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 3530834094584..71a8bfd84c06e 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -1,7 +1,7 @@ -use crate::utils::http_provider; +use crate::utils::{http_provider, http_provider_with_signer}; use alloy_consensus::{SidecarBuilder, SimpleCoder}; -use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK}; -use alloy_network::{TransactionBuilder, TransactionBuilder4844}; +use alloy_eips::eip4844::{BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK}; +use alloy_network::{EthereumWallet, TransactionBuilder, TransactionBuilder4844}; use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, TransactionRequest}; @@ -204,3 +204,90 @@ async fn can_check_blob_fields_on_genesis() { assert_eq!(block.header.blob_gas_used, Some(0)); assert_eq!(block.header.excess_blob_gas, Some(0)); } + +#[tokio::test(flavor = "multi_thread")] +async fn can_correctly_estimate_blob_gas_with_recommended_fillers() { + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); + let (_api, handle) = spawn(node_config).await; + + let provider = http_provider(&handle.http_endpoint()); + + let accounts = provider.get_accounts().await.unwrap(); + let alice = accounts[0]; + let bob = accounts[1]; + + let sidecar: SidecarBuilder = SidecarBuilder::from_slice(b"Blobs are fun!"); + let sidecar = sidecar.build().unwrap(); + + let tx = TransactionRequest::default().with_to(bob).with_blob_sidecar(sidecar); + let tx = WithOtherFields::new(tx); + + // Send the transaction and wait for the broadcast. + let pending_tx = provider.send_transaction(tx).await.unwrap(); + + println!("Pending transaction... {}", pending_tx.tx_hash()); + + // Wait for the transaction to be included and get the receipt. + let receipt = pending_tx.get_receipt().await.unwrap(); + + // Grab the processed transaction. + let tx = provider.get_transaction_by_hash(receipt.transaction_hash).await.unwrap().unwrap(); + + println!( + "Transaction included in block {}", + receipt.block_number.expect("Failed to get block number") + ); + + assert!(tx.max_fee_per_blob_gas.unwrap() >= BLOB_TX_MIN_BLOB_GASPRICE); + assert_eq!(receipt.from, alice); + assert_eq!(receipt.to, Some(bob)); + assert_eq!( + receipt.blob_gas_used.expect("Expected to be EIP-4844 transaction"), + DATA_GAS_PER_BLOB as u128 + ); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_correctly_estimate_blob_gas_with_recommended_fillers_with_signer() { + let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); + let (_api, handle) = spawn(node_config).await; + + let signer = handle.dev_wallets().next().unwrap(); + let wallet: EthereumWallet = signer.clone().into(); + + let provider = http_provider_with_signer(&handle.http_endpoint(), wallet); + + let accounts = provider.get_accounts().await.unwrap(); + let alice = accounts[0]; + let bob = accounts[1]; + + let sidecar: SidecarBuilder = SidecarBuilder::from_slice(b"Blobs are fun!"); + let sidecar = sidecar.build().unwrap(); + + let tx = TransactionRequest::default().with_to(bob).with_blob_sidecar(sidecar); + let tx = WithOtherFields::new(tx); + + // Send the transaction and wait for the broadcast. + let pending_tx = provider.send_transaction(tx).await.unwrap(); + + println!("Pending transaction... {}", pending_tx.tx_hash()); + + // Wait for the transaction to be included and get the receipt. + let receipt = pending_tx.get_receipt().await.unwrap(); + + // Grab the processed transaction. + let tx = provider.get_transaction_by_hash(receipt.transaction_hash).await.unwrap().unwrap(); + + println!( + "Transaction included in block {}", + receipt.block_number.expect("Failed to get block number") + ); + + assert!(tx.max_fee_per_blob_gas.unwrap() >= BLOB_TX_MIN_BLOB_GASPRICE); + assert_eq!(receipt.from, alice); + assert_eq!(receipt.to, Some(bob)); + assert_eq!( + receipt.blob_gas_used.expect("Expected to be EIP-4844 transaction"), + DATA_GAS_PER_BLOB as u128 + ); +} From 7559c09974e6166f945ff1b3136a811dfcc9d5da Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 03:33:06 +0200 Subject: [PATCH 1502/1963] chore(deps): weekly `cargo update` (#8981) * chore(deps): weekly `cargo update` Locking 41 packages to latest compatible versions Updating alloy-chains v0.1.33 -> v0.1.34 Updating alloy-dyn-abi v0.8.3 -> v0.8.5 Updating alloy-json-abi v0.8.3 -> v0.8.5 Updating alloy-primitives v0.8.3 -> v0.8.5 Updating alloy-sol-macro v0.8.3 -> v0.8.5 Updating alloy-sol-macro-expander v0.8.3 -> v0.8.5 Updating alloy-sol-macro-input v0.8.3 -> v0.8.5 Updating alloy-sol-type-parser v0.8.3 -> v0.8.5 Updating alloy-sol-types v0.8.3 -> v0.8.5 Updating async-trait v0.1.82 -> v0.1.83 Updating autocfg v1.3.0 -> v1.4.0 Updating aws-config v1.5.6 -> v1.5.7 Updating aws-sdk-kms v1.44.0 -> v1.45.0 Updating aws-sdk-sso v1.43.0 -> v1.44.0 Updating aws-sdk-ssooidc v1.44.0 -> v1.45.0 Updating aws-sdk-sts v1.43.0 -> v1.44.0 Updating aws-smithy-types v1.2.6 -> v1.2.7 Updating axum v0.7.6 -> v0.7.7 Updating axum-core v0.4.4 -> v0.4.5 Updating cc v1.1.21 -> v1.1.22 Updating evmole v0.5.0 -> v0.5.1 Updating flate2 v1.0.33 -> v1.0.34 Updating hyper-util v0.1.8 -> v0.1.9 Updating libc v0.2.158 -> v0.2.159 Updating portable-atomic v1.8.0 -> v1.9.0 Updating redox_syscall v0.5.4 -> v0.5.6 Updating revm v14.0.2 -> v14.0.3 Updating revm-interpreter v10.0.2 -> v10.0.3 Updating revm-precompile v11.0.2 -> v11.0.3 Adding revm-primitives v10.0.0 Updating rustls-pki-types v1.8.0 -> v1.9.0 Updating serde_spanned v0.6.7 -> v0.6.8 Updating syn v2.0.77 -> v2.0.79 Updating syn-solidity v0.8.3 -> v0.8.5 Updating tempfile v3.12.0 -> v3.13.0 Adding tokio-tungstenite v0.24.0 Updating toml_edit v0.22.21 -> v0.22.22 Updating tonic v0.12.2 -> v0.12.3 Adding tungstenite v0.24.0 Updating wasm-streams v0.4.0 -> v0.4.1 Updating winnow v0.6.18 -> v0.6.20 note: pass `--verbose` to see 143 unchanged dependencies behind latest * fixes * chore: clippy --------- Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 383 ++++++++++-------- Cargo.toml | 12 +- crates/anvil/src/eth/api.rs | 18 +- crates/anvil/src/eth/backend/db.rs | 8 +- crates/anvil/src/eth/backend/mem/mod.rs | 15 +- crates/chisel/src/session_source.rs | 2 +- crates/config/src/providers/remappings.rs | 4 +- crates/evm/core/src/backend/snapshot.rs | 6 +- crates/evm/core/src/fork/database.rs | 6 +- crates/evm/core/src/state_snapshot.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 2 +- crates/evm/fuzz/src/strategies/calldata.rs | 2 +- .../evm/traces/src/identifier/signatures.rs | 4 +- crates/forge/src/coverage.rs | 2 +- crates/forge/src/runner.rs | 12 +- crates/linking/src/lib.rs | 2 +- crates/script/src/execute.rs | 2 +- crates/script/src/lib.rs | 2 +- crates/script/src/simulate.rs | 2 +- 19 files changed, 267 insertions(+), 219 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a9f4a3b2cb1f..886cc3ff2644a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805f7a974de5804f5c053edc6ca43b20883bdd3a733b3691200ae3a4b454a2db" +checksum = "8158b4878c67837e5413721cc44298e6a2d88d39203175ea025e51892a16ba4c" dependencies = [ "num_enum", "serde", @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4004925bff5ba0a11739ae84dbb6601a981ea692f3bd45b626935ee90a6b8471" +checksum = "0b499852e1d0e9b8c6db0f24c48998e647c0d5762a01090f955106a7700e4611" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -177,7 +177,6 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-serde", - "arbitrary", "c-kzg", "derive_more 1.0.0", "once_cell", @@ -198,9 +197,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9996daf962fd0a90d3c93b388033228865953b92de7bb1959b891d78750a4091" +checksum = "a438d4486b5d525df3b3004188f9d5cd1d65cd30ecc41e5a3ccef6f6342e8af9" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -257,9 +256,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411aff151f2a73124ee473708e82ed51b2535f68928b6a1caa8bc1246ae6f7cd" +checksum = "260d3ff3bff0bb84599f032a2f2c6828180b0ea0cd41fdaf44f39cef3ba41861" dependencies = [ "alloy-rlp", "arbitrary", @@ -269,15 +268,20 @@ dependencies = [ "derive_arbitrary", "derive_more 1.0.0", "getrandom", + "hashbrown 0.14.5", "hex-literal", + "indexmap 2.5.0", "itoa", "k256", "keccak-asm", + "paste", "proptest", "proptest-derive", "rand", "ruint", + "rustc-hash", "serde", + "sha3", "tiny-keccak", ] @@ -358,7 +362,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -483,7 +487,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "731f75ec5d383107fd745d781619bd9cedf145836c51ecb991623d41278e71fa" dependencies = [ "alloy-primitives", - "arbitrary", "serde", "serde_json", ] @@ -599,23 +602,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0458ccb02a564228fcd76efb8eb5a520521a8347becde37b402afec9a1b83859" +checksum = "68e7f6e8fe5b443f82b3f1e15abfa191128f71569148428e49449d01f6f49e8b" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc65475025fc1e84bf86fc840f04f63fcccdcf3cf12053c99918e4054dfbc69" +checksum = "6b96ce28d2fde09abb6135f410c41fad670a3a770b6776869bd852f1df102e6f" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -625,16 +628,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed10f0715a0b69fde3236ff3b9ae5f6f7c97db5a387747100070d3016b9266b" +checksum = "906746396a8296537745711630d9185746c0b50c033d5e9d18b0a6eba3d53f90" dependencies = [ "alloy-json-abi", "const-hex", @@ -643,15 +646,15 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.77", + "syn 2.0.79", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3edae8ea1de519ccba896b6834dec874230f72fe695ff3c9c118e90ec7cff783" +checksum = "bc85178909a49c8827ffccfc9103a7ce1767ae66a801b69bdc326913870bf8e6" dependencies = [ "serde", "winnow", @@ -659,9 +662,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eb88e4da0a1b697ed6a9f811fdba223cf4d5c21410804fd1707836af73a462b" +checksum = "d86a533ce22525969661b25dfe296c112d35eb6861f188fd284f8bd4bb3842ae" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -738,21 +741,20 @@ dependencies = [ "rustls 0.23.13", "serde_json", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.23.1", "tracing", "ws_stream_wasm", ] [[package]] name = "alloy-trie" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a46c9c4fdccda7982e7928904bd85fe235a0404ee3d7e197fff13d61eac8b4f" +checksum = "e9703ce68b97f8faae6f7739d1e003fc97621b856953cbcdbb2b515743f23288" dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more 1.0.0", - "hashbrown 0.14.5", "nybbles", "serde", "smallvec", @@ -1155,7 +1157,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1177,18 +1179,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1241,20 +1243,20 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.6" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848d7b9b605720989929279fa644ce8f244d0ce3146fcca5b70e4eb7b3c020fc" +checksum = "8191fb3091fa0561d1379ef80333c3c7191c6f0435d986e85821bcf7acbd1126" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1319,9 +1321,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.44.0" +version = "1.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6550445e0913c9383375f4a5a2f550817567a19a178107fce1e1afd767f802a" +checksum = "0caf20b8855dbeb458552e6c8f8f9eb92b95e4a131725b93540ec73d60c38eb3" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1341,9 +1343,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a9d27ed1c12b1140c47daf1bc541606c43fdafd918c4797d520db0043ceef2" +checksum = "0b90cfe6504115e13c41d3ea90286ede5aa14da294f3fe077027a6e83850843c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1363,9 +1365,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.44.0" +version = "1.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44514a6ca967686cde1e2a1b81df6ef1883d0e3e570da8d8bc5c491dcb6fc29b" +checksum = "167c0fad1f212952084137308359e8e4c4724d1c643038ce163f06de9662c1d0" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1385,9 +1387,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7a4d279762a35b9df97209f6808b95d4fe78547fe2316b4d200a0283960c5a" +checksum = "2cb5f98188ec1435b68097daa2a37d74b9d17c9caa799466338a8d1544e71b9d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1525,9 +1527,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.6" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03701449087215b5369c7ea17fef0dd5d24cb93439ec5af0c7615f58c3f22605" +checksum = "147100a7bea70fa20ef224a6bad700358305f5dc0f84649c53769761395b355b" dependencies = [ "base64-simd", "bytes", @@ -1571,13 +1573,13 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" +checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" dependencies = [ "async-trait", "axum-core", - "base64 0.21.7", + "base64 0.22.1", "bytes", "futures-util", "http 1.1.0", @@ -1599,7 +1601,7 @@ dependencies = [ "sha1", "sync_wrapper 1.0.1", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.24.0", "tower 0.5.1", "tower-layer", "tower-service", @@ -1608,9 +1610,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", @@ -1770,7 +1772,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.8", "serde", ] @@ -1914,9 +1916,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.21" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ "shlex", ] @@ -2080,7 +2082,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2278,9 +2280,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" +checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" dependencies = [ "cfg-if", "cpufeatures", @@ -2516,7 +2518,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2527,7 +2529,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2600,7 +2602,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2621,7 +2623,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2631,7 +2633,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" dependencies = [ "derive_builder_core", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2642,7 +2644,7 @@ checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2663,7 +2665,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "unicode-xid", ] @@ -2771,7 +2773,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2898,7 +2900,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3033,7 +3035,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.77", + "syn 2.0.79", "toml 0.8.19", "walkdir", ] @@ -3061,7 +3063,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.77", + "syn 2.0.79", "tempfile", "thiserror", "tiny-keccak", @@ -3091,9 +3093,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc8472e812ff8f53a76946fa70b1cc4bf75c78755beb09df4d1376764769c7d" +checksum = "b6fcfb15a14bc209e2b3d2bd32291ec445b1e348d7d9d986aa61a09149350fd7" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -3211,9 +3213,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -3427,7 +3429,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4016,9 +4018,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ab0b0379d1838fa1f0da521ffbbac168aaf113498ea8d6c9650195cadfa736" +checksum = "2fb76083f203e341deeb4a03f9cc86df096f09c723c42e44c25052c233ed87b4" dependencies = [ "alloy-primitives", "alloy-provider", @@ -4029,7 +4031,6 @@ dependencies = [ "futures", "parking_lot", "revm", - "rustc-hash", "serde", "serde_json", "thiserror", @@ -4055,7 +4056,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4214,7 +4215,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4562,8 +4563,8 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -4730,7 +4731,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4934,9 +4935,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -4947,7 +4948,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower 0.4.13", "tower-service", "tracing", ] @@ -5001,7 +5001,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.8", "same-file", "walkdir", "winapi-util", @@ -5086,8 +5086,10 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ + "arbitrary", "equivalent", "hashbrown 0.14.5", + "serde", ] [[package]] @@ -5162,7 +5164,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5346,7 +5348,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "string_cache", "term", "tiny-keccak", @@ -5360,7 +5362,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.7", + "regex-automata 0.4.8", ] [[package]] @@ -5374,9 +5376,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libdbus-sys" @@ -5601,7 +5603,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5692,7 +5694,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5951,7 +5953,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5993,9 +5995,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "oorandom" @@ -6097,7 +6102,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6260,7 +6265,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6319,7 +6324,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6403,7 +6408,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6461,7 +6466,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6522,9 +6527,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -6580,7 +6585,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6658,7 +6663,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6678,7 +6683,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "version_check", "yansi", ] @@ -6728,7 +6733,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -6742,7 +6747,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6765,7 +6770,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6945,6 +6950,7 @@ dependencies = [ "libc", "rand_chacha", "rand_core", + "serde", ] [[package]] @@ -7024,9 +7030,9 @@ checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags 2.6.0", ] @@ -7044,14 +7050,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -7065,13 +7071,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -7088,9 +7094,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" @@ -7146,9 +7152,9 @@ dependencies = [ [[package]] name = "revm" -version = "14.0.2" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9f3f55d0414c3d73902d876ba3d55a654f05fe937089fbf5f34b1ced26d78d5" +checksum = "641702b12847f9ed418d552f4fcabe536d867a2c980e96b6e7e25d7b992f929f" dependencies = [ "auto_impl", "cfg-if", @@ -7179,9 +7185,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "10.0.2" +version = "10.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713dbb271acd13afb06dcd460c1dc43da211e7ac9bc73cdf13528f615f55f96b" +checksum = "2e5e14002afae20b5bf1566f22316122f42f57517000e559c55b25bf7a49cba2" dependencies = [ "revm-primitives", "serde", @@ -7189,9 +7195,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "11.0.2" +version = "11.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73010c271d53fa7904e9845338e95f3955eb1200a0355e0abfdb89c41aaa9cd" +checksum = "3198c06247e8d4ad0d1312591edf049b0de4ddffa9fecb625c318fd67db8639b" dependencies = [ "aurora-engine-modexp", "blst", @@ -7209,11 +7215,12 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "9.0.2" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a6bff9dbde3370a5ac9555104117f7e6039b3cc76e8d5d9d01899088beca2a" +checksum = "6f1525851a03aff9a9d6a1d018b414d76252d6802ab54695b27093ecd7e7a101" dependencies = [ - "alloy-eips", + "alloy-eip2930", + "alloy-eip7702", "alloy-primitives", "auto_impl", "bitflags 2.6.0", @@ -7222,7 +7229,6 @@ dependencies = [ "cfg-if", "dyn-clone", "enumn", - "hashbrown 0.14.5", "hex", "serde", ] @@ -7365,6 +7371,9 @@ name = "rustc-hash" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +dependencies = [ + "rand", +] [[package]] name = "rustc-hex" @@ -7489,9 +7498,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-webpki" @@ -7651,7 +7660,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -7813,7 +7822,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -7824,7 +7833,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -7868,14 +7877,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -7914,7 +7923,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8256,7 +8265,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8324,9 +8333,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -8335,14 +8344,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b95156f8b577cb59dc0b1df15c6f29a10afc5f8a7ac9786b0b5c68c19149278" +checksum = "0ab661c8148c2261222a4d641ad5477fd4bea79406a99056096a0b41b35617a5" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8368,9 +8377,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -8447,7 +8456,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8582,7 +8591,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8652,10 +8661,22 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", - "tungstenite", + "tungstenite 0.23.0", "webpki-roots", ] +[[package]] +name = "tokio-tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.24.0", +] + [[package]] name = "tokio-util" version = "0.7.12" @@ -8702,9 +8723,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap 2.5.0", "serde", @@ -8715,9 +8736,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", @@ -8734,7 +8755,7 @@ dependencies = [ "percent-encoding", "pin-project 1.1.5", "prost", - "rustls-native-certs 0.7.3", + "rustls-native-certs 0.8.0", "rustls-pemfile 2.1.3", "socket2", "tokio", @@ -8857,7 +8878,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8980,6 +9001,24 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "utf-8", +] + [[package]] name = "typenum" version = "1.17.0" @@ -8988,9 +9027,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "uint" @@ -9251,7 +9290,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -9285,7 +9324,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9298,9 +9337,9 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" dependencies = [ "futures-util", "js-sys", @@ -9502,7 +9541,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -9513,7 +9552,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -9524,7 +9563,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -9535,7 +9574,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -9727,9 +9766,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -9801,7 +9840,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -9821,7 +9860,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 99f079a758349..245c6da411008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,12 +168,12 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } foundry-compilers = { version = "0.11.1", default-features = false } -foundry-fork-db = "0.3" +foundry-fork-db = "0.3.2" solang-parser = "=0.3.3" ## revm revm = { version = "14.0.2", default-features = false } -revm-primitives = { version = "9.0.2", default-features = false } +revm-primitives = { version = "10.0.0", default-features = false } revm-inspectors = { version = "0.7.7", features = ["serde"] } ## ethers @@ -205,7 +205,11 @@ alloy-transport-ws = { version = "0.3.6", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.1" alloy-json-abi = "0.8.1" -alloy-primitives = { version = "0.8.1", features = ["getrandom", "rand"] } +alloy-primitives = { version = "0.8.1", features = [ + "getrandom", + "rand", + "map-fxhash", +] } alloy-sol-macro-expander = "0.8.1" alloy-sol-macro-input = "0.8.1" alloy-sol-types = "0.8.1" @@ -213,7 +217,7 @@ syn-solidity = "0.8.1" alloy-chains = "0.1" alloy-rlp = "0.3" -alloy-trie = "0.5.0" +alloy-trie = "0.6.0" ## op-alloy for tests in anvil op-alloy-rpc-types = "0.2.9" diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 1f005d4436b1b..85d1aceaf5318 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -35,7 +35,10 @@ use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account, TxEnvelop use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; use alloy_network::{eip2718::Decodable2718, BlockResponse}; -use alloy_primitives::{Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64}; +use alloy_primitives::{ + map::{HashMap, HashSet}, + Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64, +}; use alloy_rpc_types::{ anvil::{ ForkedNetwork, Forking, Metadata, MineOptions, NodeEnvironment, NodeForkConfig, NodeInfo, @@ -79,12 +82,7 @@ use foundry_evm::{ }; use futures::channel::{mpsc::Receiver, oneshot}; use parking_lot::RwLock; -use std::{ - collections::{HashMap, HashSet}, - future::Future, - sync::Arc, - time::Duration, -}; +use std::{future::Future, sync::Arc, time::Duration}; /// The client version: `anvil/v{major}.{minor}.{patch}` pub const CLIENT_VERSION: &str = concat!("anvil/v", env!("CARGO_PKG_VERSION")); @@ -1968,7 +1966,7 @@ impl EthApi { // Convert the transaction requests to pool transactions if they exist, otherwise use empty // hashmap let block_pool_txs = if tx_block_pairs.is_empty() { - HashMap::new() + HashMap::default() } else { let mut pairs = tx_block_pairs; @@ -1985,9 +1983,9 @@ impl EthApi { // Manage nonces for each signer // address -> cumulative nonce - let mut nonces: HashMap = HashMap::new(); + let mut nonces: HashMap = HashMap::default(); - let mut txs: HashMap>> = HashMap::new(); + let mut txs: HashMap>> = HashMap::default(); for pair in pairs { let (tx_data, block_index) = pair; diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 0aa0f8d13cb73..67ab27b9bbae6 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -253,8 +253,8 @@ impl> MaybeFullDatabase for CacheDB { fn clear_into_state_snapshot(&mut self) -> StateSnapshot { let db_accounts = std::mem::take(&mut self.accounts); - let mut accounts = HashMap::new(); - let mut account_storage = HashMap::new(); + let mut accounts = HashMap::default(); + let mut account_storage = HashMap::default(); for (addr, mut acc) in db_accounts { account_storage.insert(addr, std::mem::take(&mut acc.storage)); @@ -268,8 +268,8 @@ impl> MaybeFullDatabase for CacheDB { fn read_as_state_snapshot(&self) -> StateSnapshot { let db_accounts = self.accounts.clone(); - let mut accounts = HashMap::new(); - let mut account_storage = HashMap::new(); + let mut accounts = HashMap::default(); + let mut account_storage = HashMap::default(); for (addr, acc) in db_accounts { account_storage.insert(addr, acc.storage.clone()); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index eed634bfacd5f..83d8c1871fbf3 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2456,7 +2456,12 @@ impl Backend { let _ = builder.root(); - let proof = builder.take_proofs().values().cloned().collect::>(); + let proof = builder + .take_proof_nodes() + .into_nodes_sorted() + .into_iter() + .map(|(_, v)| v) + .collect(); let storage_proofs = prove_storage(&account.storage, &keys); let account_proof = AccountProof { @@ -2825,15 +2830,13 @@ pub fn prove_storage(storage: &HashMap, keys: &[B256]) -> Vec Result> { - let mut res_map = HashMap::new(); + let mut res_map = HashMap::default(); let parsed_map = self.compiler_input().sources; for source in parsed_map.values() { Self::get_intermediate_contract(&source.content, &mut res_map); diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 171967934f44a..2eaab0982d34b 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -39,9 +39,9 @@ impl Remappings { /// Consumes the wrapper and returns the inner remappings vector. pub fn into_inner(self) -> Vec { - let mut tmp = HashSet::new(); + let mut seen = HashSet::new(); let remappings = - self.remappings.iter().filter(|r| tmp.insert(Self::filter_key(r))).cloned().collect(); + self.remappings.iter().filter(|r| seen.insert(Self::filter_key(r))).cloned().collect(); remappings } diff --git a/crates/evm/core/src/backend/snapshot.rs b/crates/evm/core/src/backend/snapshot.rs index 7bfed1283feaf..36c4657c2618c 100644 --- a/crates/evm/core/src/backend/snapshot.rs +++ b/crates/evm/core/src/backend/snapshot.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::{map::AddressHashMap, B256, U256}; use revm::{ primitives::{AccountInfo, Env, HashMap}, JournaledState, @@ -8,8 +8,8 @@ use serde::{Deserialize, Serialize}; /// A minimal abstraction of a state at a certain point in time #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct StateSnapshot { - pub accounts: HashMap, - pub storage: HashMap>, + pub accounts: AddressHashMap, + pub storage: AddressHashMap>, pub block_hashes: HashMap, } diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index a8d2ccc1db9a5..1bab765150006 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -4,13 +4,13 @@ use crate::{ backend::{RevertStateSnapshotAction, StateSnapshot}, state_snapshot::StateSnapshots, }; -use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::{map::HashMap, Address, B256, U256}; use alloy_rpc_types::BlockId; use foundry_fork_db::{BlockchainDb, DatabaseError, SharedBackend}; use parking_lot::Mutex; use revm::{ db::{CacheDB, DatabaseRef}, - primitives::{Account, AccountInfo, Bytecode, HashMap as Map}, + primitives::{Account, AccountInfo, Bytecode}, Database, DatabaseCommit, }; use std::sync::Arc; @@ -193,7 +193,7 @@ impl DatabaseRef for ForkedDatabase { } impl DatabaseCommit for ForkedDatabase { - fn commit(&mut self, changes: Map) { + fn commit(&mut self, changes: HashMap) { self.database_mut().commit(changes) } } diff --git a/crates/evm/core/src/state_snapshot.rs b/crates/evm/core/src/state_snapshot.rs index e273a573344de..0f453b8c6710f 100644 --- a/crates/evm/core/src/state_snapshot.rs +++ b/crates/evm/core/src/state_snapshot.rs @@ -69,6 +69,6 @@ impl StateSnapshots { impl Default for StateSnapshots { fn default() -> Self { - Self { id: U256::ZERO, state_snapshots: HashMap::new() } + Self { id: U256::ZERO, state_snapshots: HashMap::default() } } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 7a1a794f607e4..421880c0da1b8 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -753,7 +753,7 @@ impl Default for RawCallResult { gas_refunded: 0, stipend: 0, logs: Vec::new(), - labels: HashMap::new(), + labels: HashMap::default(), traces: None, coverage: None, transactions: None, diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index c341cce9d934b..b919c477f4134 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -74,7 +74,7 @@ mod tests { let function = Function::parse("test_fuzzed_address(address addressFixture)").unwrap(); let address_fixture = DynSolValue::Address(Address::random()); - let mut fixtures = HashMap::new(); + let mut fixtures = HashMap::default(); fixtures.insert( "addressFixture".to_string(), DynSolValue::Array(vec![address_fixture.clone()]), diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 498385ef19a44..2d7cadad1b821 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -56,12 +56,12 @@ impl SignaturesIdentifier { } CachedSignatures::default() }; - Self { cached, cached_path: Some(path), unavailable: HashSet::new(), client } + Self { cached, cached_path: Some(path), unavailable: HashSet::default(), client } } else { Self { cached: Default::default(), cached_path: None, - unavailable: HashSet::new(), + unavailable: HashSet::default(), client, } }; diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 135636d3cac9d..b712c8fc27814 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -268,7 +268,7 @@ struct LineNumberCache { impl LineNumberCache { pub fn new(root: PathBuf) -> Self { - Self { root, line_offsets: HashMap::new() } + Self { root, line_offsets: HashMap::default() } } pub fn get_position(&mut self, path: &Path, offset: usize) -> eyre::Result<(usize, usize)> { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 51f2e5cc1be40..8f9f7ebdd8d27 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -164,9 +164,13 @@ impl<'a> ContractRunner<'a> { } = *err; (logs, traces, labels, Some(format!("setup failed: {reason}")), coverage) } - Err(err) => { - (Vec::new(), None, HashMap::new(), Some(format!("setup failed: {err}")), None) - } + Err(err) => ( + Vec::new(), + None, + HashMap::default(), + Some(format!("setup failed: {err}")), + None, + ), }; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(setup_logs); @@ -210,7 +214,7 @@ impl<'a> ContractRunner<'a> { /// returns an array of addresses to be used for fuzzing `owner` named parameter in scope of the /// current test. fn fuzz_fixtures(&mut self, address: Address) -> FuzzFixtures { - let mut fixtures = HashMap::new(); + let mut fixtures = HashMap::default(); let fixture_functions = self.contract.abi.functions().filter(|func| func.is_fixture()); for func in fixture_functions { if func.inputs.is_empty() { diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index 1ef9c9add01e9..c62c29e6c2993 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -317,7 +317,7 @@ mod tests { output = output.with_stripped_file_prefixes(project.root()); } - Self { project, output, dependency_assertions: HashMap::new() } + Self { project, output, dependency_assertions: HashMap::default() } } fn assert_dependencies( diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 410d896105cf2..97324e5cb39c7 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -350,7 +350,7 @@ impl ExecutedState { /// Collects the return values from the execution result. fn get_returns(&self) -> Result> { - let mut returns = HashMap::new(); + let mut returns = HashMap::default(); let returned = &self.execution_result.returned; let func = &self.execution_data.func; diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index a20a884f04b3d..b7d4088d435c9 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -536,7 +536,7 @@ impl ScriptConfig { // dapptools compatibility 1 }; - Ok(Self { config, evm_opts, sender_nonce, backends: HashMap::new() }) + Ok(Self { config, evm_opts, sender_nonce, backends: HashMap::default() }) } pub async fn update_sender(&mut self, sender: Address) -> Result<()> { diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index eea660bcdbee5..7c692ea232efd 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -253,7 +253,7 @@ impl FilledTransactionsState { eyre::bail!("Multi-chain deployment is not supported with libraries."); } - let mut total_gas_per_rpc: HashMap = HashMap::new(); + let mut total_gas_per_rpc: HashMap = HashMap::default(); // Batches sequence of transactions from different rpcs. let mut new_sequence = VecDeque::new(); From 4bcb309eb8eb49e0033d58cce86bd31d44d7937a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:19:57 +0300 Subject: [PATCH 1503/1963] fix(forge): generate `evm.legacyAssembly` extra output (#8987) fix(forge): include legacyAssembly output --- Cargo.lock | 21 ++++++++++----------- Cargo.toml | 2 +- crates/forge/bin/cmd/inspect.rs | 7 +++++++ crates/forge/tests/cli/cmd.rs | 22 +++++++++++++++++++--- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 886cc3ff2644a..fd4e2e0c62fb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3711,9 +3711,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d91e510bd537970f68f8462dea0e8df0a2302d4749fb57bc8e10bbd32a283e2" +checksum = "588bc1dd21020966a255a578433016d4637c810ed76127997a469bc4a3311e7f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3749,9 +3749,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9971eefe4eae1cf2ac707beb4d40f63304b34c81c0961d299e461c14a23b1e7" +checksum = "3b12c7a7ab554fde7521428b040205569c187995b817481720e99adf524bf7f8" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3759,9 +3759,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cde3d12776c295ad85bcdbbae18f4601e384f40a62b0e3371d880bbcd91c65c" +checksum = "4654933ab983928d8e33e7fdf425bb60553e8a4ac415a6014f1f2e56a5b3741d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3783,9 +3783,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "569a769f6105248816c253715ec39977d61d369e9c67e4774d6870da8f64dffc" +checksum = "2271a6689d27f42ffe1259f587196f56251508c6c9e362c585ccf234f5919f96" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3798,15 +3798,14 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f10ade77fa0eab75e142a76711c42a258781bad0c4516ad64aa413297ebb72e" +checksum = "eb71494112126e7ecb92748913403c35ef949f18734e3ff4566a782ce2c8b986" dependencies = [ "alloy-primitives", "cfg-if", "dunce", "fs_extra", - "memmap2", "once_cell", "path-slash", "regex", diff --git a/Cargo.toml b/Cargo.toml index 245c6da411008..228bac2909fcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,7 +167,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } -foundry-compilers = { version = "0.11.1", default-features = false } +foundry-compilers = { version = "0.11.3", default-features = false } foundry-fork-db = "0.3.2" solang-parser = "=0.3.3" diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index d3097854c9dfb..ddfe60e61d287 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -101,6 +101,9 @@ impl InspectArgs { ContractArtifactField::Assembly | ContractArtifactField::AssemblyOptimized => { print_json_str(&artifact.assembly, None)?; } + ContractArtifactField::LegacyAssembly => { + print_json_str(&artifact.legacy_assembly, None)?; + } ContractArtifactField::MethodIdentifiers => { print_json(&artifact.method_identifiers)?; } @@ -210,6 +213,7 @@ pub enum ContractArtifactField { DeployedBytecode, Assembly, AssemblyOptimized, + LegacyAssembly, MethodIdentifiers, GasEstimates, StorageLayout, @@ -292,6 +296,7 @@ impl_value_enum! { DeployedBytecode => "deployedBytecode" | "deployed_bytecode" | "deployed-bytecode" | "deployed" | "deployedbytecode", Assembly => "assembly" | "asm", + LegacyAssembly => "legacyAssembly" | "legacyassembly" | "legacy_assembly", AssemblyOptimized => "assemblyOptimized" | "asmOptimized" | "assemblyoptimized" | "assembly_optimized" | "asmopt" | "assembly-optimized" | "asmo" | "asm-optimized" | "asmoptimized" | "asm_optimized", @@ -324,6 +329,7 @@ impl From for ContractOutputSelection { DeployedBytecodeOutputSelection::All, )), Caf::Assembly | Caf::AssemblyOptimized => Self::Evm(EvmOutputSelection::Assembly), + Caf::LegacyAssembly => Self::Evm(EvmOutputSelection::LegacyAssembly), Caf::MethodIdentifiers => Self::Evm(EvmOutputSelection::MethodIdentifiers), Caf::GasEstimates => Self::Evm(EvmOutputSelection::GasEstimates), Caf::StorageLayout => Self::StorageLayout, @@ -354,6 +360,7 @@ impl PartialEq for ContractArtifactField { (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) | diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 8179e9eaa5537..5f0a78f9b4a65 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -740,9 +740,17 @@ Compiler run successful! // checks that extra output works forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| { - cmd.args(["build", "--extra-output", "metadata", "ir-optimized", "--extra-output", "ir"]) - .assert_success() - .stdout_eq(str![[r#" + cmd.args([ + "build", + "--extra-output", + "metadata", + "legacyAssembly", + "ir-optimized", + "--extra-output", + "ir", + ]) + .assert_success() + .stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! @@ -753,6 +761,7 @@ Compiler run successful! let artifact: ConfigurableContractArtifact = foundry_compilers::utils::read_json_file(&artifact_path).unwrap(); assert!(artifact.metadata.is_some()); + assert!(artifact.legacy_assembly.is_some()); assert!(artifact.ir.is_some()); assert!(artifact.ir_optimized.is_some()); @@ -763,6 +772,7 @@ Compiler run successful! "metadata", "ir-optimized", "evm.bytecode.sourceMap", + "evm.legacyAssembly", "--force", ]) .root_arg() @@ -784,6 +794,12 @@ Compiler run successful! let sourcemap = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.sourcemap")); std::fs::read_to_string(sourcemap).unwrap(); + + let legacy_assembly = prj + .paths() + .artifacts + .join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.legacyAssembly.json")); + std::fs::read_to_string(legacy_assembly).unwrap(); }); forgetest!(can_print_warnings, |prj, cmd| { From 3ff3d0562215bca620e07c5c4c154eec8da0f04b Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:05:58 +0530 Subject: [PATCH 1504/1963] chore: bump alloy-core deps + revm (#8988) * chore: bump alloy-core deps + revm * bump alloy to 0.4.0 * bump revm-inspectors + type casting to u128 * fix * Revert "fix" This reverts commit 5e0e0d1128b6819acf600b42372156738e666247. * Revert "bump revm-inspectors + type casting to u128" This reverts commit 25aa23cffaadef1d047ce7b359b4d7ad5018704a. * Revert "bump alloy to 0.4.0" This reverts commit f9721e00f5ba726c4fea6651839d65b45faae488. * replace std HashMap with alloy_primitives maps * bump compilers * replace remaining HashMaps * fmt * nit * replace HashSets * fmt --- Cargo.lock | 8 ++-- Cargo.toml | 16 ++++---- crates/anvil/src/config.rs | 3 +- crates/anvil/src/eth/backend/cheats.rs | 8 ++-- crates/anvil/src/eth/backend/fork.rs | 19 ++++++---- crates/anvil/src/eth/backend/mem/storage.rs | 37 +++++++++++-------- crates/anvil/src/eth/sign.rs | 5 +-- crates/anvil/src/filter.rs | 3 +- crates/anvil/tests/it/logs.rs | 4 +- crates/anvil/tests/it/transaction.rs | 6 +-- crates/cheatcodes/src/config.rs | 5 +-- crates/cheatcodes/src/evm/mapping.rs | 17 +++++---- crates/cheatcodes/src/inspector.rs | 12 ++++-- crates/cheatcodes/src/utils.rs | 3 +- crates/chisel/src/runner.rs | 5 +-- crates/chisel/src/session_source.rs | 3 +- crates/common/src/selectors.rs | 3 +- crates/config/src/error.rs | 4 +- crates/config/src/inline/mod.rs | 4 +- crates/config/src/lib.rs | 7 ++-- crates/debugger/src/tui/builder.rs | 6 +-- crates/debugger/src/tui/mod.rs | 7 ++-- crates/doc/src/builder.rs | 2 +- crates/doc/src/document.rs | 2 +- crates/doc/src/parser/comment.rs | 2 +- .../src/preprocessor/contract_inheritance.rs | 3 +- crates/doc/src/preprocessor/inheritdoc.rs | 2 +- crates/doc/src/preprocessor/mod.rs | 3 +- crates/evm/core/src/backend/diagnostic.rs | 5 +-- crates/evm/core/src/fork/multi.rs | 3 +- crates/evm/core/src/state_snapshot.rs | 4 +- crates/evm/evm/src/executors/fuzz/mod.rs | 4 +- crates/evm/evm/src/executors/fuzz/types.rs | 3 +- .../evm/evm/src/executors/invariant/replay.rs | 4 +- crates/evm/evm/src/executors/mod.rs | 9 +++-- crates/evm/evm/src/inspectors/stack.rs | 5 +-- crates/evm/fuzz/src/lib.rs | 9 +++-- crates/evm/fuzz/src/strategies/calldata.rs | 3 +- crates/evm/traces/src/lib.rs | 4 +- crates/forge/bin/cmd/bind.rs | 3 +- crates/forge/bin/cmd/snapshot.rs | 3 +- crates/forge/bin/cmd/watch.rs | 4 +- crates/forge/src/progress.rs | 4 +- crates/forge/src/result.rs | 17 +++++---- crates/linking/src/lib.rs | 3 +- crates/script/src/broadcast.rs | 17 +++++---- crates/script/src/execute.rs | 6 ++- crates/script/src/lib.rs | 9 +++-- crates/script/src/progress.rs | 9 +++-- crates/script/src/sequence.rs | 4 +- crates/verify/src/sourcify.rs | 7 +++- crates/wallets/src/multi_wallet.rs | 10 ++--- 52 files changed, 187 insertions(+), 161 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd4e2e0c62fb6..7308606c9e3cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7029,9 +7029,9 @@ checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -7622,9 +7622,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.17" +version = "2.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c947adb109a8afce5fc9c7bf951f87f146e9147b3a6a58413105628fb1d1e66" +checksum = "215b1103f73e23e9cb6883072c1fb26ae55c09d42054654955c739e5418a7c96" dependencies = [ "sdd", ] diff --git a/Cargo.toml b/Cargo.toml index 228bac2909fcd..ae6ee18250fa7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,7 +172,7 @@ foundry-fork-db = "0.3.2" solang-parser = "=0.3.3" ## revm -revm = { version = "14.0.2", default-features = false } +revm = { version = "14.0.3", default-features = false } revm-primitives = { version = "10.0.0", default-features = false } revm-inspectors = { version = "0.7.7", features = ["serde"] } @@ -203,17 +203,17 @@ alloy-transport-ipc = { version = "0.3.6", default-features = false } alloy-transport-ws = { version = "0.3.6", default-features = false } ## alloy-core -alloy-dyn-abi = "0.8.1" -alloy-json-abi = "0.8.1" -alloy-primitives = { version = "0.8.1", features = [ +alloy-dyn-abi = "0.8.5" +alloy-json-abi = "0.8.5" +alloy-primitives = { version = "0.8.5", features = [ "getrandom", "rand", "map-fxhash", ] } -alloy-sol-macro-expander = "0.8.1" -alloy-sol-macro-input = "0.8.1" -alloy-sol-types = "0.8.1" -syn-solidity = "0.8.1" +alloy-sol-macro-expander = "0.8.5" +alloy-sol-macro-input = "0.8.5" +alloy-sol-types = "0.8.5" +syn-solidity = "0.8.5" alloy-chains = "0.1" alloy-rlp = "0.3" diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index d907fc200f536..f3dbf21f6013c 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -17,7 +17,7 @@ use crate::{ }; use alloy_genesis::Genesis; use alloy_network::AnyNetwork; -use alloy_primitives::{hex, utils::Unit, BlockNumber, TxHash, U256}; +use alloy_primitives::{hex, map::HashMap, utils::Unit, BlockNumber, TxHash, U256}; use alloy_provider::Provider; use alloy_rpc_types::{Block, BlockNumberOrTag, Transaction}; use alloy_serde::WithOtherFields; @@ -46,7 +46,6 @@ use rand::thread_rng; use revm::primitives::BlobExcessGasAndPrice; use serde_json::{json, to_writer, Value}; use std::{ - collections::HashMap, fmt::Write as FmtWrite, fs::File, net::{IpAddr, Ipv4Addr}, diff --git a/crates/anvil/src/eth/backend/cheats.rs b/crates/anvil/src/eth/backend/cheats.rs index 5e941d0046438..32115cf41c13f 100644 --- a/crates/anvil/src/eth/backend/cheats.rs +++ b/crates/anvil/src/eth/backend/cheats.rs @@ -1,8 +1,8 @@ //! Support for "cheat codes" / bypass functions -use alloy_primitives::Address; +use alloy_primitives::{map::AddressHashSet, Address}; use parking_lot::RwLock; -use std::{collections::HashSet, sync::Arc}; +use std::sync::Arc; /// Manages user modifications that may affect the node's behavior /// @@ -55,7 +55,7 @@ impl CheatsManager { } /// Returns all accounts that are currently being impersonated. - pub fn impersonated_accounts(&self) -> HashSet
{ + pub fn impersonated_accounts(&self) -> AddressHashSet { self.state.read().impersonated_accounts.clone() } } @@ -64,7 +64,7 @@ impl CheatsManager { #[derive(Clone, Debug, Default)] pub struct CheatsState { /// All accounts that are currently impersonated - pub impersonated_accounts: HashSet
, + pub impersonated_accounts: AddressHashSet, /// If set to true will make the `is_impersonated` function always return true pub auto_impersonate_accounts: bool, } diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index c661eeaa89b86..ea41b85a954c4 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -4,7 +4,10 @@ use crate::eth::{backend::db::Db, error::BlockchainError, pool::transactions::Po use alloy_consensus::Account; use alloy_eips::eip2930::AccessListResult; use alloy_network::BlockResponse; -use alloy_primitives::{Address, Bytes, StorageValue, B256, U256}; +use alloy_primitives::{ + map::{FbHashMap, HashMap}, + Address, Bytes, StorageValue, B256, U256, +}; use alloy_provider::{ ext::{DebugApi, TraceApi}, Provider, @@ -27,7 +30,7 @@ use parking_lot::{ RawRwLock, RwLock, }; use revm::primitives::BlobExcessGasAndPrice; -use std::{collections::HashMap, sync::Arc, time::Duration}; +use std::{sync::Arc, time::Duration}; use tokio::sync::RwLock as AsyncRwLock; /// Represents a fork of a remote client @@ -675,14 +678,14 @@ impl ClientForkConfig { /// This is used as a cache so repeated requests to the same data are not sent to the remote client #[derive(Clone, Debug, Default)] pub struct ForkedStorage { - pub uncles: HashMap>, - pub blocks: HashMap, + pub uncles: FbHashMap<32, Vec>, + pub blocks: FbHashMap<32, AnyNetworkBlock>, pub hashes: HashMap, - pub transactions: HashMap>, - pub transaction_receipts: HashMap, - pub transaction_traces: HashMap>, + pub transactions: FbHashMap<32, WithOtherFields>, + pub transaction_receipts: FbHashMap<32, ReceiptResponse>, + pub transaction_traces: FbHashMap<32, Vec>, pub logs: HashMap>, - pub geth_transaction_traces: HashMap, + pub geth_transaction_traces: FbHashMap<32, GethTrace>, pub block_traces: HashMap>, pub block_receipts: HashMap>, pub code_at: HashMap<(Address, u64), Bytes>, diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 928fb66e4e035..abc520c3b0141 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -10,7 +10,10 @@ use crate::eth::{ error::BlockchainError, pool::transactions::PoolTransaction, }; -use alloy_primitives::{Bytes, TxHash, B256, U256, U64}; +use alloy_primitives::{ + map::{B256HashMap, HashMap}, + Bytes, B256, U256, U64, +}; use alloy_rpc_types::{ trace::{ geth::{ @@ -35,12 +38,8 @@ use foundry_evm::{ }, }; use parking_lot::RwLock; -use std::{ - collections::{HashMap, VecDeque}, - fmt, - sync::Arc, - time::Duration, -}; +use std::{collections::VecDeque, fmt, sync::Arc, time::Duration}; +// use yansi::Paint; // === various limits in number of blocks === @@ -52,9 +51,9 @@ const MAX_ON_DISK_HISTORY_LIMIT: usize = 3_600; /// Represents the complete state of single block pub struct InMemoryBlockStates { /// The states at a certain block - states: HashMap, + states: B256HashMap, /// states which data is moved to disk - on_disk_states: HashMap, + on_disk_states: B256HashMap, /// How many states to store at most in_memory_limit: usize, /// minimum amount of states we keep in memory @@ -245,7 +244,7 @@ impl Default for InMemoryBlockStates { #[derive(Clone)] pub struct BlockchainStorage { /// all stored blocks (block hash -> block) - pub blocks: HashMap, + pub blocks: B256HashMap, /// mapping from block number -> block hash pub hashes: HashMap, /// The current best hash @@ -256,7 +255,7 @@ pub struct BlockchainStorage { pub genesis_hash: B256, /// Mapping from the transaction hash to a tuple containing the transaction as well as the /// transaction receipt - pub transactions: HashMap, + pub transactions: B256HashMap, /// The total difficulty of the chain until this block pub total_difficulty: U256, } @@ -280,9 +279,14 @@ impl BlockchainStorage { let best_hash = genesis_hash; let best_number: U64 = U64::from(0u64); + let mut blocks = B256HashMap::default(); + blocks.insert(genesis_hash, block); + + let mut hashes = HashMap::default(); + hashes.insert(best_number, genesis_hash); Self { - blocks: HashMap::from([(genesis_hash, block)]), - hashes: HashMap::from([(best_number, genesis_hash)]), + blocks, + hashes, best_hash, best_number, genesis_hash, @@ -292,9 +296,12 @@ impl BlockchainStorage { } pub fn forked(block_number: u64, block_hash: B256, total_difficulty: U256) -> Self { + let mut hashes = HashMap::default(); + hashes.insert(U64::from(block_number), block_hash); + Self { - blocks: Default::default(), - hashes: HashMap::from([(U64::from(block_number), block_hash)]), + blocks: B256HashMap::default(), + hashes, best_hash: block_hash, best_number: U64::from(block_number), genesis_hash: Default::default(), diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index d921b18d35e46..d322e47d22654 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -2,14 +2,13 @@ use crate::eth::error::BlockchainError; use alloy_consensus::SignableTransaction; use alloy_dyn_abi::TypedData; use alloy_network::TxSignerSync; -use alloy_primitives::{Address, Signature, B256}; +use alloy_primitives::{map::AddressHashMap, Address, Signature, B256}; use alloy_signer::Signer as AlloySigner; use alloy_signer_local::PrivateKeySigner; use anvil_core::eth::transaction::{ optimism::{DepositTransaction, DepositTransactionRequest}, TypedTransaction, TypedTransactionRequest, }; -use std::collections::HashMap; /// A transaction signer #[async_trait::async_trait] @@ -47,7 +46,7 @@ pub trait Signer: Send + Sync { /// Maintains developer keys pub struct DevSigner { addresses: Vec
, - accounts: HashMap, + accounts: AddressHashMap, } impl DevSigner { diff --git a/crates/anvil/src/filter.rs b/crates/anvil/src/filter.rs index 2144ce27c9882..c0c8e7aef15e1 100644 --- a/crates/anvil/src/filter.rs +++ b/crates/anvil/src/filter.rs @@ -4,13 +4,12 @@ use crate::{ pubsub::filter_logs, StorageInfo, }; -use alloy_primitives::TxHash; +use alloy_primitives::{map::HashMap, TxHash}; use alloy_rpc_types::{Filter, FilteredParams, Log}; use anvil_core::eth::subscription::SubscriptionId; use anvil_rpc::response::ResponseResult; use futures::{channel::mpsc::Receiver, Stream, StreamExt}; use std::{ - collections::HashMap, pin::Pin, sync::Arc, task::{Context, Poll}, diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index 1ce4ac64ffaea..3bf09493d8aa9 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -5,7 +5,7 @@ use crate::{ utils::{http_provider_with_signer, ws_provider_with_signer}, }; use alloy_network::EthereumWallet; -use alloy_primitives::B256; +use alloy_primitives::{map::B256HashSet, B256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockNumberOrTag, Filter}; use anvil::{spawn, NodeConfig}; @@ -120,7 +120,7 @@ async fn get_all_events() { // test that logs returned from get_logs and get_transaction_receipt have // the same log_index, block_number, and transaction_hash let mut tasks = vec![]; - let mut seen_tx_hashes = std::collections::HashSet::new(); + let mut seen_tx_hashes = B256HashSet::default(); for log in &logs { if seen_tx_hashes.contains(&log.transaction_hash.unwrap()) { continue; diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index b3e82c380101c..63ebbbcf3404f 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -3,7 +3,7 @@ use crate::{ utils::{connect_pubsub, http_provider_with_signer}, }; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{Address, Bytes, FixedBytes, U256}; +use alloy_primitives::{map::B256HashSet, Address, Bytes, FixedBytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ state::{AccountOverride, StateOverride}, @@ -13,7 +13,7 @@ use alloy_serde::WithOtherFields; use anvil::{spawn, EthereumHardfork, NodeConfig}; use eyre::Ok; use futures::{future::join_all, FutureExt, StreamExt}; -use std::{collections::HashSet, str::FromStr, time::Duration}; +use std::{str::FromStr, time::Duration}; use tokio::time::timeout; #[tokio::test(flavor = "multi_thread")] @@ -950,7 +950,7 @@ async fn can_stream_pending_transactions() { if watch_received.len() == num_txs && sub_received.len() == num_txs { if let Some(sent) = &sent { assert_eq!(sent.len(), watch_received.len()); - let sent_txs = sent.iter().map(|tx| tx.transaction_hash).collect::>(); + let sent_txs = sent.iter().map(|tx| tx.transaction_hash).collect::(); assert_eq!(sent_txs, watch_received.iter().copied().collect()); assert_eq!(sent_txs, sub_received.iter().copied().collect()); break diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 715e26dc57bb9..531784e16339d 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -1,6 +1,6 @@ use super::Result; use crate::{script::ScriptWallets, Vm::Rpc}; -use alloy_primitives::{Address, U256}; +use alloy_primitives::{map::AddressHashMap, U256}; use foundry_common::{fs::normalize_path, ContractsByArtifact}; use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ @@ -10,7 +10,6 @@ use foundry_config::{ use foundry_evm_core::opts::EvmOpts; use semver::Version; use std::{ - collections::HashMap, path::{Path, PathBuf}, time::Duration, }; @@ -43,7 +42,7 @@ pub struct CheatsConfig { /// How the evm was configured by the user pub evm_opts: EvmOpts, /// Address labels from config - pub labels: HashMap, + pub labels: AddressHashMap, /// Script wallets pub script_wallets: Option, /// Artifacts which are guaranteed to be fresh (either recompiled or cached). diff --git a/crates/cheatcodes/src/evm/mapping.rs b/crates/cheatcodes/src/evm/mapping.rs index 679609274ed6d..e8525908e847a 100644 --- a/crates/cheatcodes/src/evm/mapping.rs +++ b/crates/cheatcodes/src/evm/mapping.rs @@ -1,26 +1,29 @@ use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; -use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_primitives::{ + keccak256, + map::{AddressHashMap, B256HashMap}, + Address, B256, U256, +}; use alloy_sol_types::SolValue; use revm::interpreter::{opcode, Interpreter}; -use std::collections::HashMap; /// Recorded mapping slots. #[derive(Clone, Debug, Default)] pub struct MappingSlots { /// Holds mapping parent (slots => slots) - pub parent_slots: HashMap, + pub parent_slots: B256HashMap, /// Holds mapping key (slots => key) - pub keys: HashMap, + pub keys: B256HashMap, /// Holds mapping child (slots => slots[]) - pub children: HashMap>, + pub children: B256HashMap>, /// Holds the last sha3 result `sha3_result => (data_low, data_high)`, this would only record /// when sha3 is called with `size == 0x40`, and the lower 256 bits would be stored in /// `data_low`, higher 256 bits in `data_high`. /// This is needed for mapping_key detect if the slot is for some mapping and record that. - pub seen_sha3: HashMap, + pub seen_sha3: B256HashMap<(B256, B256)>, } impl MappingSlots { @@ -113,7 +116,7 @@ fn slot_child<'a>( } #[cold] -pub(crate) fn step(mapping_slots: &mut HashMap, interpreter: &Interpreter) { +pub(crate) fn step(mapping_slots: &mut AddressHashMap, interpreter: &Interpreter) { match interpreter.current_opcode() { opcode::KECCAK256 => { if interpreter.stack.peek(1) == Ok(U256::from(0x40)) { diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 58d8ca5c9e704..f4d0ed82114ae 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -20,7 +20,11 @@ use crate::{ CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, Vm, Vm::AccountAccess, }; -use alloy_primitives::{hex, Address, Bytes, Log, TxKind, B256, U256}; +use alloy_primitives::{ + hex, + map::{AddressHashMap, HashMap}, + Address, Bytes, Log, TxKind, B256, U256, +}; use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolCall, SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, TransactionMaybeSigned, SELECTOR_LEN}; @@ -48,7 +52,7 @@ use revm::{ use rustc_hash::FxHashMap; use serde_json::Value; use std::{ - collections::{BTreeMap, HashMap, VecDeque}, + collections::{BTreeMap, VecDeque}, fs::File, io::BufReader, ops::Range, @@ -363,7 +367,7 @@ pub struct Cheatcodes { pub gas_price: Option, /// Address labels - pub labels: HashMap, + pub labels: AddressHashMap, /// Prank information pub prank: Option, @@ -432,7 +436,7 @@ pub struct Cheatcodes { pub gas_metering: GasMetering, /// Mapping slots. - pub mapping_slots: Option>, + pub mapping_slots: Option>, /// The current program counter. pub pc: usize, diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index b4e32748354ac..eb4d2f525a4fb 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -2,13 +2,12 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::U256; +use alloy_primitives::{map::HashMap, U256}; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; use foundry_evm_core::{backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER}; use proptest::strategy::{Strategy, ValueTree}; use rand::{Rng, RngCore}; -use std::collections::HashMap; /// Contains locations of traces ignored via cheatcodes. /// diff --git a/crates/chisel/src/runner.rs b/crates/chisel/src/runner.rs index e78454ee363b5..72b083e1fb882 100644 --- a/crates/chisel/src/runner.rs +++ b/crates/chisel/src/runner.rs @@ -3,14 +3,13 @@ //! This module contains the `ChiselRunner` struct, which assists with deploying //! and calling the REPL contract on a in-memory REVM instance. -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{map::AddressHashMap, Address, Bytes, Log, U256}; use eyre::Result; use foundry_evm::{ executors::{DeployResult, Executor, RawCallResult}, traces::{TraceKind, Traces}, }; use revm::interpreter::{return_ok, InstructionResult}; -use std::collections::HashMap; /// The function selector of the REPL contract's entrypoint, the `run()` function. static RUN_SELECTOR: [u8; 4] = [0xc0, 0x40, 0x62, 0x26]; @@ -43,7 +42,7 @@ pub struct ChiselResult { /// Amount of gas used in the transaction pub gas_used: u64, /// Map of addresses to their labels - pub labeled_addresses: HashMap, + pub labeled_addresses: AddressHashMap, /// Return data pub returned: Bytes, /// Called address diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index f7db438324c1d..e1b31a972a37f 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -4,6 +4,7 @@ //! the REPL contract's source code. It provides simple compilation, parsing, and //! execution helpers. +use alloy_primitives::map::HashMap; use eyre::Result; use forge_fmt::solang_ext::SafeUnwrap; use foundry_compilers::{ @@ -15,7 +16,7 @@ use foundry_evm::{backend::Backend, opts::EvmOpts}; use semver::Version; use serde::{Deserialize, Serialize}; use solang_parser::{diagnostics::Diagnostic, pt}; -use std::{collections::HashMap, fs, path::PathBuf}; +use std::{fs, path::PathBuf}; use yansi::Paint; /// The minimum Solidity version of the `Vm` interface. diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 16565a07e8e62..3b10739162cb2 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -4,11 +4,11 @@ use crate::abi::abi_decode_calldata; use alloy_json_abi::JsonAbi; +use alloy_primitives::map::HashMap; use eyre::Context; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{ - collections::HashMap, fmt, sync::{ atomic::{AtomicBool, AtomicUsize, Ordering}, @@ -16,7 +16,6 @@ use std::{ }, time::Duration, }; - const SELECTOR_LOOKUP_URL: &str = "https://api.openchain.xyz/signature-database/v1/lookup"; const SELECTOR_IMPORT_URL: &str = "https://api.openchain.xyz/signature-database/v1/import"; diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 3da1aee09e564..09f21605d1103 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -1,8 +1,8 @@ //! error handling and solc error codes +use alloy_primitives::map::HashSet; use figment::providers::{Format, Toml}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::{collections::HashSet, error::Error, fmt, str::FromStr}; - +use std::{error::Error, fmt, str::FromStr}; /// The message shown upon panic if the config could not be extracted from the figment pub const FAILED_TO_EXTRACT_CONFIG_PANIC_MSG: &str = "failed to extract foundry config:"; diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 36bad2514df39..8b5616a21afbb 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -1,6 +1,6 @@ use crate::Config; -use std::{collections::HashMap, sync::LazyLock}; - +use alloy_primitives::map::HashMap; +use std::sync::LazyLock; mod conf_parser; pub use conf_parser::*; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 452365ce95512..18352aab99729 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -38,12 +38,11 @@ use foundry_compilers::{ }; use inflector::Inflector; use regex::Regex; -use revm_primitives::{FixedBytes, SpecId}; +use revm_primitives::{map::AddressHashMap, FixedBytes, SpecId}; use semver::Version; use serde::{Deserialize, Serialize, Serializer}; use std::{ borrow::Cow, - collections::HashMap, fs, path::{Path, PathBuf}, str::FromStr, @@ -418,7 +417,7 @@ pub struct Config { pub disable_block_gas_limit: bool, /// Address labels - pub labels: HashMap, + pub labels: AddressHashMap, /// Whether to enable safety checks for `vm.getCode` and `vm.getDeployedCode` invocations. /// If disabled, it is possible to access artifacts which were not recompiled or cached. @@ -5034,7 +5033,7 @@ mod tests { let config = Config::load(); assert_eq!( config.labels, - HashMap::from_iter(vec![ + AddressHashMap::from_iter(vec![ ( Address::from_str("0x1F98431c8aD98523631AE4a59f267346ea31F984").unwrap(), "Uniswap V3: Factory".to_string() diff --git a/crates/debugger/src/tui/builder.rs b/crates/debugger/src/tui/builder.rs index fd952def5bc4f..484611c70e65c 100644 --- a/crates/debugger/src/tui/builder.rs +++ b/crates/debugger/src/tui/builder.rs @@ -1,11 +1,9 @@ //! TUI debugger builder. use crate::{node::flatten_call_trace, DebugNode, Debugger}; -use alloy_primitives::Address; +use alloy_primitives::{map::AddressHashMap, Address}; use foundry_common::{evm::Breakpoints, get_contract_name}; use foundry_evm_traces::{debug::ContractSources, CallTraceArena, CallTraceDecoder, Traces}; -use std::collections::HashMap; - /// Debugger builder. #[derive(Debug, Default)] #[must_use = "builders do nothing unless you call `build` on them"] @@ -13,7 +11,7 @@ pub struct DebuggerBuilder { /// Debug traces returned from the EVM execution. debug_arena: Vec, /// Identified contracts. - identified_contracts: HashMap, + identified_contracts: AddressHashMap, /// Map of source files. sources: ContractSources, /// Map of the debugger breakpoints. diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 155973e15830f..75b747a7ed02e 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -1,6 +1,6 @@ //! The TUI implementation. -use alloy_primitives::Address; +use alloy_primitives::map::AddressHashMap; use crossterm::{ event::{self, DisableMouseCapture, EnableMouseCapture, Event}, execute, @@ -14,7 +14,6 @@ use ratatui::{ Terminal, }; use std::{ - collections::HashMap, io, ops::ControlFlow, sync::{mpsc, Arc}, @@ -44,7 +43,7 @@ pub enum ExitReason { /// The TUI debugger. pub struct Debugger { debug_arena: Vec, - identified_contracts: HashMap, + identified_contracts: AddressHashMap, /// Source map of contract sources contracts_sources: ContractSources, breakpoints: Breakpoints, @@ -60,7 +59,7 @@ impl Debugger { /// Creates a new debugger. pub fn new( debug_arena: Vec, - identified_contracts: HashMap, + identified_contracts: AddressHashMap, contracts_sources: ContractSources, breakpoints: Breakpoints, ) -> Self { diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index e21e80c22bd5b..3ec433c395f47 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -2,6 +2,7 @@ use crate::{ document::DocumentContent, helpers::merge_toml_table, AsDoc, BufWriter, Document, ParseItem, ParseSource, Parser, Preprocessor, }; +use alloy_primitives::map::HashMap; use forge_fmt::{FormatterConfig, Visitable}; use foundry_compilers::{compilers::solc::SOLC_EXTENSIONS, utils::source_files_iter}; use foundry_config::{filter::expand_globs, DocConfig}; @@ -10,7 +11,6 @@ use mdbook::MDBook; use rayon::prelude::*; use std::{ cmp::Ordering, - collections::HashMap, fs, path::{Path, PathBuf}, }; diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index be4c1e647670d..10f72a672c256 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -1,6 +1,6 @@ use crate::{DocBuilder, ParseItem, PreprocessorId, PreprocessorOutput}; +use alloy_primitives::map::HashMap; use std::{ - collections::HashMap, path::{Path, PathBuf}, slice::IterMut, sync::Mutex, diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index 280dcfd0d712a..13184112e6e04 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -1,6 +1,6 @@ +use alloy_primitives::map::HashMap; use derive_more::{Deref, DerefMut}; use solang_parser::doccomment::DocCommentTag; -use std::collections::HashMap; /// The natspec comment tag explaining the purpose of the comment. /// See: . diff --git a/crates/doc/src/preprocessor/contract_inheritance.rs b/crates/doc/src/preprocessor/contract_inheritance.rs index 7d74589bddb4f..ac229a4342f5e 100644 --- a/crates/doc/src/preprocessor/contract_inheritance.rs +++ b/crates/doc/src/preprocessor/contract_inheritance.rs @@ -1,7 +1,8 @@ use super::{Preprocessor, PreprocessorId}; use crate::{document::DocumentContent, Document, ParseSource, PreprocessorOutput}; +use alloy_primitives::map::HashMap; use forge_fmt::solang_ext::SafeUnwrap; -use std::{collections::HashMap, path::PathBuf}; +use std::path::PathBuf; /// [ContractInheritance] preprocessor id. pub const CONTRACT_INHERITANCE_ID: PreprocessorId = PreprocessorId("contract_inheritance"); diff --git a/crates/doc/src/preprocessor/inheritdoc.rs b/crates/doc/src/preprocessor/inheritdoc.rs index 8d29a64fcf3a6..65cbb688c443d 100644 --- a/crates/doc/src/preprocessor/inheritdoc.rs +++ b/crates/doc/src/preprocessor/inheritdoc.rs @@ -2,8 +2,8 @@ use super::{Preprocessor, PreprocessorId}; use crate::{ document::DocumentContent, Comments, Document, ParseItem, ParseSource, PreprocessorOutput, }; +use alloy_primitives::map::HashMap; use forge_fmt::solang_ext::SafeUnwrap; -use std::collections::HashMap; /// [`Inheritdoc`] preprocessor ID. pub const INHERITDOC_ID: PreprocessorId = PreprocessorId("inheritdoc"); diff --git a/crates/doc/src/preprocessor/mod.rs b/crates/doc/src/preprocessor/mod.rs index 25ed4db231ae7..5011b59a1b5e8 100644 --- a/crates/doc/src/preprocessor/mod.rs +++ b/crates/doc/src/preprocessor/mod.rs @@ -1,7 +1,8 @@ //! Module containing documentation preprocessors. use crate::{Comments, Document}; -use std::{collections::HashMap, fmt::Debug, path::PathBuf}; +use alloy_primitives::map::HashMap; +use std::{fmt::Debug, path::PathBuf}; mod contract_inheritance; pub use contract_inheritance::{ContractInheritance, CONTRACT_INHERITANCE_ID}; diff --git a/crates/evm/core/src/backend/diagnostic.rs b/crates/evm/core/src/backend/diagnostic.rs index 109190a8fe594..df215508da1c0 100644 --- a/crates/evm/core/src/backend/diagnostic.rs +++ b/crates/evm/core/src/backend/diagnostic.rs @@ -1,7 +1,6 @@ use crate::backend::LocalForkId; -use alloy_primitives::Address; +use alloy_primitives::{map::AddressHashMap, Address}; use itertools::Itertools; -use std::collections::HashMap; /// Represents possible diagnostic cases on revert #[derive(Clone, Debug)] @@ -21,7 +20,7 @@ pub enum RevertDiagnostic { impl RevertDiagnostic { /// Converts the diagnostic to a readable error message - pub fn to_error_msg(&self, labels: &HashMap) -> String { + pub fn to_error_msg(&self, labels: &AddressHashMap) -> String { let get_label = |addr: &Address| labels.get(addr).cloned().unwrap_or_else(|| addr.to_string()); diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index a39b543ea254e..14fa59aafc1f4 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -4,7 +4,7 @@ //! concurrently active pairs at once. use super::CreateFork; -use alloy_primitives::U256; +use alloy_primitives::{map::HashMap, U256}; use alloy_provider::network::{BlockResponse, HeaderResponse}; use alloy_transport::layers::RetryBackoffService; use foundry_common::provider::{ @@ -20,7 +20,6 @@ use futures::{ }; use revm::primitives::Env; use std::{ - collections::HashMap, fmt::{self, Write}, pin::Pin, sync::{ diff --git a/crates/evm/core/src/state_snapshot.rs b/crates/evm/core/src/state_snapshot.rs index 0f453b8c6710f..3be1172aded5d 100644 --- a/crates/evm/core/src/state_snapshot.rs +++ b/crates/evm/core/src/state_snapshot.rs @@ -1,7 +1,7 @@ //! Support for snapshotting different states -use alloy_primitives::U256; -use std::{collections::HashMap, ops::Add}; +use alloy_primitives::{map::HashMap, U256}; +use std::ops::Add; /// Represents all state snapshots #[derive(Clone, Debug)] diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 775b7e73e060f..cb57f205326ab 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,7 +1,7 @@ use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{map::HashMap, Address, Bytes, Log, U256}; use eyre::Result; use foundry_common::evm::Breakpoints; use foundry_config::FuzzConfig; @@ -17,7 +17,7 @@ use foundry_evm_fuzz::{ use foundry_evm_traces::SparsedTraceArena; use indicatif::ProgressBar; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; -use std::{cell::RefCell, collections::HashMap}; +use std::cell::RefCell; mod types; pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; diff --git a/crates/evm/evm/src/executors/fuzz/types.rs b/crates/evm/evm/src/executors/fuzz/types.rs index 081ff91129cf4..f5399c5c3ac1a 100644 --- a/crates/evm/evm/src/executors/fuzz/types.rs +++ b/crates/evm/evm/src/executors/fuzz/types.rs @@ -1,11 +1,10 @@ use crate::executors::RawCallResult; -use alloy_primitives::{Bytes, Log}; +use alloy_primitives::{map::HashMap, Bytes, Log}; use foundry_common::evm::Breakpoints; use foundry_evm_coverage::HitMaps; use foundry_evm_fuzz::FuzzCase; use foundry_evm_traces::SparsedTraceArena; use revm::interpreter::InstructionResult; -use std::collections::HashMap; /// Returned by a single fuzz in the case of a successful run #[derive(Debug)] diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 177e1b55b26c3..969f1587f27e2 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -4,7 +4,7 @@ use super::{ }; use crate::executors::Executor; use alloy_dyn_abi::JsonAbiExt; -use alloy_primitives::Log; +use alloy_primitives::{map::HashMap, Log}; use eyre::Result; use foundry_common::{ContractsByAddress, ContractsByArtifact}; use foundry_evm_coverage::HitMaps; @@ -17,7 +17,7 @@ use indicatif::ProgressBar; use parking_lot::RwLock; use proptest::test_runner::TestError; use revm::primitives::U256; -use std::{collections::HashMap, sync::Arc}; +use std::sync::Arc; /// Replays a call sequence for collecting logs and traces. /// Returns counterexample to be used when the call sequence is a failed scenario. diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 421880c0da1b8..5e2acc98f5d0c 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -11,7 +11,10 @@ use crate::inspectors::{ }; use alloy_dyn_abi::{DynSolValue, FunctionExt, JsonAbiExt}; use alloy_json_abi::Function; -use alloy_primitives::{Address, Bytes, Log, U256}; +use alloy_primitives::{ + map::{AddressHashMap, HashMap}, + Address, Bytes, Log, U256, +}; use alloy_sol_types::{sol, SolCall}; use foundry_evm_core::{ backend::{Backend, BackendError, BackendResult, CowBackend, DatabaseExt, GLOBAL_FAIL_SLOT}, @@ -32,7 +35,7 @@ use revm::{ SpecId, TxEnv, TxKind, }, }; -use std::{borrow::Cow, collections::HashMap}; +use std::borrow::Cow; mod builder; pub use builder::ExecutorBuilder; @@ -723,7 +726,7 @@ pub struct RawCallResult { /// The logs emitted during the call pub logs: Vec, /// The labels assigned to addresses during the call - pub labels: HashMap, + pub labels: AddressHashMap, /// The traces of the call pub traces: Option, /// The coverage info collected during the call diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 30271910b95b5..fc270564133ad 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -2,7 +2,7 @@ use super::{ Cheatcodes, CheatsConfig, ChiselState, CoverageCollector, Fuzzer, LogCollector, TracingInspector, }; -use alloy_primitives::{Address, Bytes, Log, TxKind, U256}; +use alloy_primitives::{map::AddressHashMap, Address, Bytes, Log, TxKind, U256}; use foundry_cheatcodes::CheatcodesExecutor; use foundry_evm_core::{ backend::{update_state, DatabaseExt}, @@ -22,7 +22,6 @@ use revm::{ EvmContext, Inspector, }; use std::{ - collections::HashMap, ops::{Deref, DerefMut}, sync::Arc, }; @@ -243,7 +242,7 @@ macro_rules! call_inspectors_adjust_depth { /// The collected results of [`InspectorStack`]. pub struct InspectorData { pub logs: Vec, - pub labels: HashMap, + pub labels: AddressHashMap, pub traces: Option, pub coverage: Option, pub cheatcodes: Option, diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 2930a6aa020ca..276958ecf6fd5 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -9,13 +9,16 @@ extern crate tracing; use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; -use alloy_primitives::{Address, Bytes, Log}; +use alloy_primitives::{ + map::{AddressHashMap, HashMap}, + Address, Bytes, Log, +}; use foundry_common::{calc, contracts::ContractsByAddress, evm::Breakpoints}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::{CallTraceArena, SparsedTraceArena}; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, fmt, sync::Arc}; +use std::{fmt, sync::Arc}; pub use proptest::test_runner::{Config as FuzzConfig, Reason}; @@ -166,7 +169,7 @@ pub struct FuzzTestResult { pub logs: Vec, /// Labeled addresses - pub labeled_addresses: HashMap, + pub labeled_addresses: AddressHashMap, /// Exemplary traces for a fuzz run of the test function /// diff --git a/crates/evm/fuzz/src/strategies/calldata.rs b/crates/evm/fuzz/src/strategies/calldata.rs index b919c477f4134..6d9c0340bdca9 100644 --- a/crates/evm/fuzz/src/strategies/calldata.rs +++ b/crates/evm/fuzz/src/strategies/calldata.rs @@ -65,9 +65,8 @@ mod tests { use crate::{strategies::fuzz_calldata, FuzzFixtures}; use alloy_dyn_abi::{DynSolValue, JsonAbiExt}; use alloy_json_abi::Function; - use alloy_primitives::Address; + use alloy_primitives::{map::HashMap, Address}; use proptest::prelude::Strategy; - use std::collections::HashMap; #[test] fn can_fuzz_with_fixtures() { diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 382e3d3ec0511..dd4a8966481ab 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -17,10 +17,12 @@ use revm_inspectors::tracing::{ use serde::{Deserialize, Serialize}; use std::{ borrow::Cow, - collections::{BTreeSet, HashMap}, + collections::BTreeSet, ops::{Deref, DerefMut}, }; +use alloy_primitives::map::HashMap; + pub use revm_inspectors::tracing::{ types::{ CallKind, CallLog, CallTrace, CallTraceNode, DecodedCallData, DecodedCallLog, diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index d5d23633243f4..d8739b42d9f10 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -1,3 +1,4 @@ +use alloy_primitives::map::HashSet; use clap::{Parser, ValueHint}; use ethers_contract_abigen::{ Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts, @@ -244,7 +245,7 @@ impl BindArgs { } fn get_solmacrogen(&self, artifacts: &Path) -> Result { - let mut dup = std::collections::HashSet::::new(); + let mut dup = HashSet::::default(); let instances = self .get_json_files(artifacts)? .filter_map(|(name, path)| { diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 20c5013ec450f..0d7c2843a83f2 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -1,5 +1,5 @@ use super::test; -use alloy_primitives::U256; +use alloy_primitives::{map::HashMap, U256}; use clap::{builder::RangedU64ValueParser, Parser, ValueHint}; use eyre::{Context, Result}; use forge::result::{SuiteTestResult, TestKindReport, TestOutcome}; @@ -7,7 +7,6 @@ use foundry_cli::utils::STATIC_FUZZ_SEED; use regex::Regex; use std::{ cmp::Ordering, - collections::HashMap, fs, io::{self, BufRead}, path::{Path, PathBuf}, diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 19b37009fd6f2..4cf7dbabe5979 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -1,11 +1,11 @@ use super::{build::BuildArgs, doc::DocArgs, snapshot::GasSnapshotArgs, test::TestArgs}; +use alloy_primitives::map::HashSet; use clap::Parser; use eyre::Result; use foundry_cli::utils::{self, FoundryPathExt}; use foundry_config::Config; use parking_lot::Mutex; use std::{ - collections::HashSet, path::PathBuf, sync::{ atomic::{AtomicU8, Ordering}, @@ -265,7 +265,7 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { filter.args().contract_pattern.is_some() || args.watch.run_all; - let last_test_files = Mutex::new(HashSet::::new()); + let last_test_files = Mutex::new(HashSet::::default()); let project_root = config.root.0.to_string_lossy().into_owned(); let config = args.watch.watchexec_config_with_override( || [&config.test, &config.src], diff --git a/crates/forge/src/progress.rs b/crates/forge/src/progress.rs index 8d047c4133d36..2b45d5513a947 100644 --- a/crates/forge/src/progress.rs +++ b/crates/forge/src/progress.rs @@ -1,7 +1,7 @@ +use alloy_primitives::map::HashMap; use indicatif::{MultiProgress, ProgressBar}; use parking_lot::Mutex; -use std::{collections::HashMap, sync::Arc, time::Duration}; - +use std::{sync::Arc, time::Duration}; /// State of [ProgressBar]s displayed for the given test run. /// Shows progress of all test suites matching filter. /// For each test within the test suite an individual progress bar is displayed. diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 171a234a5ee02..1ec829f6bc942 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -4,7 +4,10 @@ use crate::{ fuzz::{BaseCounterExample, FuzzedCases}, gas_report::GasReport, }; -use alloy_primitives::{Address, Log}; +use alloy_primitives::{ + map::{AddressHashMap, HashMap}, + Address, Log, +}; use eyre::Report; use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ @@ -16,7 +19,7 @@ use foundry_evm::{ }; use serde::{Deserialize, Serialize}; use std::{ - collections::{BTreeMap, HashMap}, + collections::BTreeMap, fmt::{self, Write}, time::Duration, }; @@ -402,7 +405,7 @@ pub struct TestResult { pub coverage: Option, /// Labeled addresses - pub labeled_addresses: HashMap, + pub labeled_addresses: AddressHashMap, pub duration: Duration, @@ -738,7 +741,7 @@ pub struct TestSetup { /// Call traces of the setup pub traces: Traces, /// Addresses labeled during setup - pub labeled_addresses: HashMap, + pub labeled_addresses: AddressHashMap, /// The reason the setup failed, if it did pub reason: Option, /// Coverage info during setup @@ -752,7 +755,7 @@ impl TestSetup { error: EvmError, mut logs: Vec, mut traces: Traces, - mut labeled_addresses: HashMap, + mut labeled_addresses: AddressHashMap, ) -> Self { match error { EvmError::Execution(err) => { @@ -775,7 +778,7 @@ impl TestSetup { address: Address, logs: Vec, traces: Traces, - labeled_addresses: HashMap, + labeled_addresses: AddressHashMap, coverage: Option, fuzz_fixtures: FuzzFixtures, ) -> Self { @@ -785,7 +788,7 @@ impl TestSetup { pub fn failed_with( logs: Vec, traces: Traces, - labeled_addresses: HashMap, + labeled_addresses: AddressHashMap, reason: String, ) -> Self { Self { diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index c62c29e6c2993..d0959ddb7d507 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -283,9 +283,8 @@ impl<'a> Linker<'a> { #[cfg(test)] mod tests { use super::*; - use alloy_primitives::fixed_bytes; + use alloy_primitives::{fixed_bytes, map::HashMap}; use foundry_compilers::{Project, ProjectCompileOutput, ProjectPathsConfig}; - use std::collections::HashMap; struct LinkerTest { project: Project, diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index ff4e4205ecfdc..ac893b19f7aab 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -6,7 +6,11 @@ use alloy_chains::Chain; use alloy_consensus::TxEnvelope; use alloy_eips::eip2718::Encodable2718; use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; -use alloy_primitives::{utils::format_units, Address, TxHash}; +use alloy_primitives::{ + map::{AddressHashMap, AddressHashSet}, + utils::format_units, + Address, TxHash, +}; use alloy_provider::{utils::Eip1559Estimation, Provider}; use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; @@ -22,10 +26,7 @@ use foundry_common::{ use foundry_config::Config; use futures::{future::join_all, StreamExt}; use itertools::Itertools; -use std::{ - collections::{HashMap, HashSet}, - sync::Arc, -}; +use std::sync::Arc; pub async fn estimate_gas( tx: &mut WithOtherFields, @@ -115,9 +116,9 @@ pub enum SendTransactionKind<'a> { /// Represents how to send _all_ transactions pub enum SendTransactionsKind { /// Send via `eth_sendTransaction` and rely on the `from` address being unlocked. - Unlocked(HashSet
), + Unlocked(AddressHashSet), /// Send a signed transaction via `eth_sendRawTransaction` - Raw(HashMap), + Raw(AddressHashMap), } impl SendTransactionsKind { @@ -199,7 +200,7 @@ impl BundledState { .sequences() .iter() .flat_map(|sequence| sequence.transactions().map(|tx| tx.from().expect("missing from"))) - .collect::>(); + .collect::(); if required_addresses.contains(&Config::DEFAULT_SENDER) { eyre::bail!( diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 97324e5cb39c7..a1b3cf6133fb9 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -6,7 +6,10 @@ use crate::{ }; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; -use alloy_primitives::{Address, Bytes}; +use alloy_primitives::{ + map::{HashMap, HashSet}, + Address, Bytes, +}; use alloy_provider::Provider; use alloy_rpc_types::TransactionInput; use async_recursion::async_recursion; @@ -31,7 +34,6 @@ use foundry_evm::{ }; use futures::future::join_all; use itertools::Itertools; -use std::collections::{HashMap, HashSet}; use yansi::Paint; /// State after linking, contains the linked build data along with library addresses and optional diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index b7d4088d435c9..8231a5d54b561 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -11,7 +11,11 @@ extern crate tracing; use self::transaction::AdditionalContract; use crate::runner::ScriptRunner; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{hex, Address, Bytes, Log, TxKind, U256}; +use alloy_primitives::{ + hex, + map::{AddressHashMap, HashMap}, + Address, Bytes, Log, TxKind, U256, +}; use alloy_signer::Signer; use broadcast::next_nonce; use build::PreprocessedState; @@ -47,7 +51,6 @@ use foundry_evm::{ }; use foundry_wallets::MultiWalletOpts; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use yansi::Paint; mod broadcast; @@ -476,7 +479,7 @@ pub struct ScriptResult { pub logs: Vec, pub traces: Traces, pub gas_used: u64, - pub labeled_addresses: HashMap, + pub labeled_addresses: AddressHashMap, #[serde(skip)] pub transactions: Option, pub returned: Bytes, diff --git a/crates/script/src/progress.rs b/crates/script/src/progress.rs index 819ebca994387..b8bedb6cdbadb 100644 --- a/crates/script/src/progress.rs +++ b/crates/script/src/progress.rs @@ -3,14 +3,17 @@ use crate::{ sequence::ScriptSequence, }; use alloy_chains::Chain; -use alloy_primitives::B256; +use alloy_primitives::{ + map::{B256HashMap, HashMap}, + B256, +}; use eyre::Result; use foundry_cli::utils::init_progress; use foundry_common::provider::RetryProvider; use futures::StreamExt; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use parking_lot::RwLock; -use std::{collections::HashMap, fmt::Write, sync::Arc, time::Duration}; +use std::{fmt::Write, sync::Arc, time::Duration}; use yansi::Paint; /// State of [ProgressBar]s displayed for the given [ScriptSequence]. @@ -23,7 +26,7 @@ pub struct SequenceProgressState { /// Progress var with the count of confirmed transactions. receipts: ProgressBar, /// Standalone spinners for pending transactions. - tx_spinners: HashMap, + tx_spinners: B256HashMap, /// Copy of the main [MultiProgress] instance. multi: MultiProgress, } diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 8e21011554916..3c31773ba3abd 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -3,7 +3,7 @@ use crate::{ transaction::{AdditionalContract, TransactionWithMetadata}, verify::VerifyBundle, }; -use alloy_primitives::{hex, Address, TxHash}; +use alloy_primitives::{hex, map::HashMap, Address, TxHash}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::{eyre, ContextCompat, Result, WrapErr}; use forge_verify::provider::VerificationProviderType; @@ -13,7 +13,7 @@ use foundry_compilers::ArtifactId; use foundry_config::Config; use serde::{Deserialize, Serialize}; use std::{ - collections::{HashMap, VecDeque}, + collections::VecDeque, io::{BufWriter, Write}, path::{Path, PathBuf}, }; diff --git a/crates/verify/src/sourcify.rs b/crates/verify/src/sourcify.rs index 81fadd09e5b74..bbb5e9f9eddc3 100644 --- a/crates/verify/src/sourcify.rs +++ b/crates/verify/src/sourcify.rs @@ -2,13 +2,15 @@ use crate::{ provider::{VerificationContext, VerificationProvider}, verify::{VerifyArgs, VerifyCheckArgs}, }; +use alloy_primitives::map::HashMap; use async_trait::async_trait; use eyre::Result; use foundry_common::{fs, retry::Retry}; use futures::FutureExt; use reqwest::Url; +use revm_primitives::map::FxBuildHasher; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, str::FromStr}; +use std::str::FromStr; pub static SOURCIFY_URL: &str = "https://sourcify.dev/server/"; @@ -112,7 +114,8 @@ impl SourcifyVerificationProvider { let metadata = context.get_target_metadata()?; let imports = context.get_target_imports()?; - let mut files = HashMap::with_capacity(2 + imports.len()); + let mut files = + HashMap::with_capacity_and_hasher(2 + imports.len(), FxBuildHasher::default()); let metadata = serde_json::to_string_pretty(&metadata)?; files.insert("metadata.json".to_string(), metadata); diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index 459074aaa5848..28c3e31a168d5 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -2,14 +2,14 @@ use crate::{ utils, wallet_signer::{PendingSigner, WalletSigner}, }; -use alloy_primitives::Address; +use alloy_primitives::{map::AddressHashMap, Address}; use alloy_signer::Signer; use clap::Parser; use derive_builder::Builder; use eyre::Result; use foundry_config::Config; use serde::Serialize; -use std::{collections::HashMap, iter::repeat, path::PathBuf}; +use std::{iter::repeat, path::PathBuf}; /// Container for multiple wallets. #[derive(Debug, Default)] @@ -18,7 +18,7 @@ pub struct MultiWallet { /// Those are lazily unlocked on the first access of the signers. pending_signers: Vec, /// Contains unlocked signers. - signers: HashMap, + signers: AddressHashMap, } impl MultiWallet { @@ -35,12 +35,12 @@ impl MultiWallet { Ok(()) } - pub fn signers(&mut self) -> Result<&HashMap> { + pub fn signers(&mut self) -> Result<&AddressHashMap> { self.maybe_unlock_pending()?; Ok(&self.signers) } - pub fn into_signers(mut self) -> Result> { + pub fn into_signers(mut self) -> Result> { self.maybe_unlock_pending()?; Ok(self.signers) } From 452066e9747a28682a4de069a05b10fe9f381167 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:42:34 +0200 Subject: [PATCH 1505/1963] fix(ci): flexibly handle forge-std being installed with tag or untagged (#9003) flexible handle forge-std being installed with tag or untagged --- crates/forge/tests/cli/cmd.rs | 20 ++++++++++---------- crates/forge/tests/cli/config.rs | 4 ++-- crates/forge/tests/cli/debug.rs | 2 +- crates/forge/tests/cli/script.rs | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 5f0a78f9b4a65..6c8bab9289f6c 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -228,7 +228,7 @@ forgetest!(can_init_repo_with_config, |prj, cmd| { Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -276,7 +276,7 @@ forgetest!(can_init_no_git, |prj, cmd| { cmd.arg("init").arg(prj.root()).arg("--no-git").assert_success().stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -361,7 +361,7 @@ Run with the `--force` flag to initialize regardless. Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -396,7 +396,7 @@ Run with the `--force` flag to initialize regardless. Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -432,7 +432,7 @@ Run with the `--force` flag to initialize regardless. Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -451,7 +451,7 @@ forgetest!(can_init_vscode, |prj, cmd| { cmd.arg("init").arg(prj.root()).arg("--vscode").assert_success().stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -547,7 +547,7 @@ forgetest!(can_clone, |prj, cmd| { Downloading the source code of 0x044b75f554b886A065b9567891e45c79542d7357 from Etherscan... Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project Collecting the creation information of 0x044b75f554b886A065b9567891e45c79542d7357 from Etherscan... [COMPILING_FILES] with [SOLC_VERSION] @@ -595,7 +595,7 @@ forgetest!(can_clone_no_remappings_txt, |prj, cmd| { Downloading the source code of 0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf from Etherscan... Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project Collecting the creation information of 0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf from Etherscan... [COMPILING_FILES] with [SOLC_VERSION] @@ -1244,7 +1244,7 @@ forgetest!(can_install_and_remove, |prj, cmd| { .assert_success() .stdout_eq(str![[r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] "#]]); @@ -1312,7 +1312,7 @@ forgetest!(can_reinstall_after_manual_remove, |prj, cmd| { .assert_success() .stdout_eq(str![[r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] "#]]); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 42a2b51428157..f8b1da523c74c 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -604,7 +604,7 @@ forgetest!(can_update_libs_section, |prj, cmd| { cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]).assert_success().stdout_eq(str![ [r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] "#] ]); @@ -636,7 +636,7 @@ forgetest!(config_emit_warnings, |prj, cmd| { cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]).assert_success().stdout_eq(str![ [r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] "#] ]); diff --git a/crates/forge/tests/cli/debug.rs b/crates/forge/tests/cli/debug.rs index 8ee1eb3f27753..bbed7dc723248 100644 --- a/crates/forge/tests/cli/debug.rs +++ b/crates/forge/tests/cli/debug.rs @@ -11,7 +11,7 @@ forgetest_async!( Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 78e27d65384d9..fb2e8ae8dee77 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1012,7 +1012,7 @@ forgetest_async!(can_execute_script_with_arguments, |prj, cmd| { Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -1134,7 +1134,7 @@ forgetest_async!(can_execute_script_with_arguments_nested_deploy, |prj, cmd| { Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -1301,7 +1301,7 @@ forgetest_async!(assert_tx_origin_is_not_overritten, |prj, cmd| { Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -1382,7 +1382,7 @@ forgetest_async!(assert_can_create_multiple_contracts_with_correct_nonce, |prj, Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); @@ -1607,7 +1607,7 @@ forgetest_async!(can_decode_custom_errors, |prj, cmd| { Target directory is not empty, but `--force` was specified Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) - Installed forge-std [..] + Installed forge-std[..] Initialized forge project "#]]); From 4469a65cdf18eb03648b9f2bde4b597f4c91bd89 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:03:23 +0200 Subject: [PATCH 1506/1963] docs: clarify keystore path should point to a filename (#9004) clarify that you should point to a keystore by its file but it can be a custom directory --- crates/wallets/src/multi_wallet.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index 28c3e31a168d5..c593e67e3d510 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -162,7 +162,7 @@ pub struct MultiWalletOpts { )] pub mnemonic_indexes: Option>, - /// Use the keystore in the given folder or file. + /// Use the keystore by its filename in the given folder. #[arg( long = "keystore", visible_alias = "keystores", @@ -173,7 +173,7 @@ pub struct MultiWalletOpts { #[builder(default = "None")] pub keystore_paths: Option>, - /// Use a keystore from the default keystores folder (~/.foundry/keystores) by its filename + /// Use a keystore from the default keystores folder (~/.foundry/keystores) by its filename. #[arg( long = "account", visible_alias = "accounts", From 08a6409ab742f33b398de0fb5bc6c24800677e8c Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:29:15 +0200 Subject: [PATCH 1507/1963] feat: gas snapshots over arbitrary sections (#8952) * update internal naming * further internals * deprecate cheats * update Solidity tests and add dedicated test for testing deprecated cheatcodes * clarify gas snapshots * fix build * final fixes * fix build * fix repro 6355 rename * add gas snapshot setup from #8755 * fix build + clippy warnings * fix cheatcodes * account for fixed CREATE / CALL gas cost * remove import * add stipend * recalculate after a - b setup * clear call_stipend, update tests * avoid double counting external calls * update cheatcodes, remove debug prints * enable assertions * clean up tests * clean up test names * remove snapshot directory on `forge clean` * do not remove all snapshots by default due to multiple test suites being able to be ran concurrently or sequentially + optimize gas snapshots check - skip if none were captured * handle edge case where we ask to compare but file does not exist, remove snapshot directory at a top level before test suites are ran * fix path issue when attempting removal * Update crates/cheatcodes/src/evm.rs Co-authored-by: Arsenii Kulikov * Update crates/cheatcodes/src/inspector.rs Co-authored-by: Arsenii Kulikov * refactor, apply recommended changes for last_snapshot_group, last_snapshot_name * remove gas snapshots from fuzz tests for now: this is largely due to it conflicting with the FORGE_SNAPSHOT_CHECK where it is highly likely that with different fuzzed input the gas measurement differs as well. In the future it would be an idea to capture the average gas * fix clippy * avoid setting to 0 unnecessarily * use if let Some * improve comments, clarify use of last_gas_used != 0 * fix merge conflict issue * fix arg ordering to address group naming regression * fix import * move snapshot name derivation to helper * only skip initial call w/ overhead, no special handling for call frames * add flare test * style nits + use helper method --------- Co-authored-by: Arsenii Kulikov --- .gitignore | 1 + crates/cheatcodes/assets/cheatcodes.json | 182 +++++++++++- crates/cheatcodes/spec/src/vm.rs | 45 ++- crates/cheatcodes/src/config.rs | 6 + crates/cheatcodes/src/evm.rs | 203 +++++++++++++ crates/cheatcodes/src/inspector.rs | 59 +++- crates/chisel/src/executor.rs | 1 + crates/common/src/fs.rs | 9 + crates/config/src/lib.rs | 10 + crates/evm/evm/src/executors/fuzz/mod.rs | 9 +- crates/forge/bin/cmd/test/mod.rs | 90 ++++++ crates/forge/src/multi_runner.rs | 1 + crates/forge/src/result.rs | 4 + crates/forge/tests/cli/config.rs | 1 + crates/script/src/lib.rs | 1 + testdata/cheats/Vm.sol | 9 + testdata/default/cheats/GasSnapshots.t.sol | 321 +++++++++++++++++++++ 17 files changed, 947 insertions(+), 5 deletions(-) create mode 100644 testdata/default/cheats/GasSnapshots.t.sol diff --git a/.gitignore b/.gitignore index 19f666e451bf9..5b61e32022994 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_STORE /target out/ +snapshots/ out.json .idea .vscode diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index fbf33e500d53a..9b6c67ddd195f 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5560,7 +5560,7 @@ { "func": { "id": "lastCallGas", - "description": "Gets the gas used in the last call.", + "description": "Gets the gas used in the last call from the callee perspective.", "declaration": "function lastCallGas() external view returns (Gas memory gas);", "visibility": "external", "mutability": "view", @@ -8563,6 +8563,46 @@ }, "safety": "unsafe" }, + { + "func": { + "id": "snapshotGasLastCall_0", + "description": "Snapshot capture the gas usage of the last call by name from the callee perspective.", + "declaration": "function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);", + "visibility": "external", + "mutability": "", + "signature": "snapshotGasLastCall(string)", + "selector": "0xdd9fca12", + "selectorBytes": [ + 221, + 159, + 202, + 18 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "snapshotGasLastCall_1", + "description": "Snapshot capture the gas usage of the last call by name in a group from the callee perspective.", + "declaration": "function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);", + "visibility": "external", + "mutability": "", + "signature": "snapshotGasLastCall(string,string)", + "selector": "0x200c6772", + "selectorBytes": [ + 32, + 12, + 103, + 114 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "snapshotState", @@ -8583,6 +8623,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "snapshotValue_0", + "description": "Snapshot capture an arbitrary numerical value by name.\nThe group name is derived from the contract name.", + "declaration": "function snapshotValue(string calldata name, uint256 value) external;", + "visibility": "external", + "mutability": "", + "signature": "snapshotValue(string,uint256)", + "selector": "0x51db805a", + "selectorBytes": [ + 81, + 219, + 128, + 90 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "snapshotValue_1", + "description": "Snapshot capture an arbitrary numerical value by name in a group.", + "declaration": "function snapshotValue(string calldata group, string calldata name, uint256 value) external;", + "visibility": "external", + "mutability": "", + "signature": "snapshotValue(string,string,uint256)", + "selector": "0x6d2b27d8", + "selectorBytes": [ + 109, + 43, + 39, + 216 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "split", @@ -8723,6 +8803,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "startSnapshotGas_0", + "description": "Start a snapshot capture of the current gas usage by name.\nThe group name is derived from the contract name.", + "declaration": "function startSnapshotGas(string calldata name) external;", + "visibility": "external", + "mutability": "", + "signature": "startSnapshotGas(string)", + "selector": "0x3cad9d7b", + "selectorBytes": [ + 60, + 173, + 157, + 123 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "startSnapshotGas_1", + "description": "Start a snapshot capture of the current gas usage by name in a group.", + "declaration": "function startSnapshotGas(string calldata group, string calldata name) external;", + "visibility": "external", + "mutability": "", + "signature": "startSnapshotGas(string,string)", + "selector": "0x6cd0cc53", + "selectorBytes": [ + 108, + 208, + 204, + 83 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "startStateDiffRecording", @@ -8843,6 +8963,66 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "stopSnapshotGas_0", + "description": "Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.", + "declaration": "function stopSnapshotGas() external returns (uint256 gasUsed);", + "visibility": "external", + "mutability": "", + "signature": "stopSnapshotGas()", + "selector": "0xf6402eda", + "selectorBytes": [ + 246, + 64, + 46, + 218 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "stopSnapshotGas_1", + "description": "Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start.\nThe group name is derived from the contract name.", + "declaration": "function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);", + "visibility": "external", + "mutability": "", + "signature": "stopSnapshotGas(string)", + "selector": "0x773b2805", + "selectorBytes": [ + 119, + 59, + 40, + 5 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "stopSnapshotGas_2", + "description": "Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.", + "declaration": "function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);", + "visibility": "external", + "mutability": "", + "signature": "stopSnapshotGas(string,string)", + "selector": "0x0c9db707", + "selectorBytes": [ + 12, + 157, + 183, + 7 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "store", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 69293d1b6d6e7..7f27e1aa63b78 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -509,6 +509,49 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin); + // ----- Arbitrary Snapshots ----- + + /// Snapshot capture an arbitrary numerical value by name. + /// The group name is derived from the contract name. + #[cheatcode(group = Evm, safety = Unsafe)] + function snapshotValue(string calldata name, uint256 value) external; + + /// Snapshot capture an arbitrary numerical value by name in a group. + #[cheatcode(group = Evm, safety = Unsafe)] + function snapshotValue(string calldata group, string calldata name, uint256 value) external; + + // -------- Gas Snapshots -------- + + /// Snapshot capture the gas usage of the last call by name from the callee perspective. + #[cheatcode(group = Evm, safety = Unsafe)] + function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed); + + /// Snapshot capture the gas usage of the last call by name in a group from the callee perspective. + #[cheatcode(group = Evm, safety = Unsafe)] + function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed); + + /// Start a snapshot capture of the current gas usage by name. + /// The group name is derived from the contract name. + #[cheatcode(group = Evm, safety = Unsafe)] + function startSnapshotGas(string calldata name) external; + + /// Start a snapshot capture of the current gas usage by name in a group. + #[cheatcode(group = Evm, safety = Unsafe)] + function startSnapshotGas(string calldata group, string calldata name) external; + + /// Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start. + #[cheatcode(group = Evm, safety = Unsafe)] + function stopSnapshotGas() external returns (uint256 gasUsed); + + /// Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start. + /// The group name is derived from the contract name. + #[cheatcode(group = Evm, safety = Unsafe)] + function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed); + + /// Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start. + #[cheatcode(group = Evm, safety = Unsafe)] + function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed); + // -------- State Snapshots -------- /// `snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions. @@ -698,7 +741,7 @@ interface Vm { // -------- Gas Measurement -------- - /// Gets the gas used in the last call. + /// Gets the gas used in the last call from the callee perspective. #[cheatcode(group = Evm, safety = Safe)] function lastCallGas() external view returns (Gas memory gas); diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 531784e16339d..c6a15f45dfd31 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -49,6 +49,8 @@ pub struct CheatsConfig { /// If Some, `vm.getDeployedCode` invocations are validated to be in scope of this list. /// If None, no validation is performed. pub available_artifacts: Option, + /// Name of the script/test contract which is currently running. + pub running_contract: Option, /// Version of the script/test contract which is currently running. pub running_version: Option, /// Whether to enable legacy (non-reverting) assertions. @@ -64,6 +66,7 @@ impl CheatsConfig { evm_opts: EvmOpts, available_artifacts: Option, script_wallets: Option, + running_contract: Option, running_version: Option, ) -> Self { let mut allowed_paths = vec![config.root.0.clone()]; @@ -92,6 +95,7 @@ impl CheatsConfig { labels: config.labels.clone(), script_wallets, available_artifacts, + running_contract, running_version, assertions_revert: config.assertions_revert, seed: config.fuzz.seed, @@ -221,6 +225,7 @@ impl Default for CheatsConfig { labels: Default::default(), script_wallets: None, available_artifacts: Default::default(), + running_contract: Default::default(), running_version: Default::default(), assertions_revert: true, seed: None, @@ -240,6 +245,7 @@ mod tests { None, None, None, + None, ) } diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 7ed1ce1a4edf0..7d4a23d6126b7 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -52,6 +52,19 @@ impl RecordAccess { } } +/// Records the `snapshotGas*` cheatcodes. +#[derive(Clone, Debug)] +pub struct GasRecord { + /// The group name of the gas snapshot. + pub group: String, + /// The name of the gas snapshot. + pub name: String, + /// The total gas used in the gas snapshot. + pub gas_used: u64, + /// Depth at which the gas snapshot was taken. + pub depth: u64, +} + /// Records `deal` cheatcodes #[derive(Clone, Debug)] pub struct DealRecord { @@ -506,6 +519,80 @@ impl Cheatcode for readCallersCall { } } +impl Cheatcode for snapshotValue_0Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { name, value } = self; + inner_value_snapshot(ccx, None, Some(name.clone()), value.to_string()) + } +} + +impl Cheatcode for snapshotValue_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { group, name, value } = self; + inner_value_snapshot(ccx, Some(group.clone()), Some(name.clone()), value.to_string()) + } +} + +impl Cheatcode for snapshotGasLastCall_0Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { name } = self; + let Some(last_call_gas) = &ccx.state.gas_metering.last_call_gas else { + bail!("no external call was made yet"); + }; + inner_last_gas_snapshot(ccx, None, Some(name.clone()), last_call_gas.gasTotalUsed) + } +} + +impl Cheatcode for snapshotGasLastCall_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { name, group } = self; + let Some(last_call_gas) = &ccx.state.gas_metering.last_call_gas else { + bail!("no external call was made yet"); + }; + inner_last_gas_snapshot( + ccx, + Some(group.clone()), + Some(name.clone()), + last_call_gas.gasTotalUsed, + ) + } +} + +impl Cheatcode for startSnapshotGas_0Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { name } = self; + inner_start_gas_snapshot(ccx, None, Some(name.clone())) + } +} + +impl Cheatcode for startSnapshotGas_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { group, name } = self; + inner_start_gas_snapshot(ccx, Some(group.clone()), Some(name.clone())) + } +} + +impl Cheatcode for stopSnapshotGas_0Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self {} = self; + inner_stop_gas_snapshot(ccx, None, None) + } +} + +impl Cheatcode for stopSnapshotGas_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { name } = self; + inner_stop_gas_snapshot(ccx, None, Some(name.clone())) + } +} + +impl Cheatcode for stopSnapshotGas_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { group, name } = self; + inner_stop_gas_snapshot(ccx, Some(group.clone()), Some(name.clone())) + } +} + // Deprecated in favor of `snapshotStateCall` impl Cheatcode for snapshotCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { @@ -695,6 +782,122 @@ fn inner_delete_state_snapshots(ccx: &mut CheatsCtxt) -> Re Ok(Default::default()) } +fn inner_value_snapshot( + ccx: &mut CheatsCtxt, + group: Option, + name: Option, + value: String, +) -> Result { + let (group, name) = derive_snapshot_name(ccx, group, name); + + ccx.state.gas_snapshots.entry(group).or_default().insert(name, value); + + Ok(Default::default()) +} + +fn inner_last_gas_snapshot( + ccx: &mut CheatsCtxt, + group: Option, + name: Option, + value: u64, +) -> Result { + let (group, name) = derive_snapshot_name(ccx, group, name); + + ccx.state.gas_snapshots.entry(group).or_default().insert(name, value.to_string()); + + Ok(value.abi_encode()) +} + +fn inner_start_gas_snapshot( + ccx: &mut CheatsCtxt, + group: Option, + name: Option, +) -> Result { + // Revert if there is an active gas snapshot as we can only have one active snapshot at a time. + if ccx.state.gas_metering.active_gas_snapshot.is_some() { + let (group, name) = ccx.state.gas_metering.active_gas_snapshot.as_ref().unwrap().clone(); + bail!("gas snapshot was already started with group: {group} and name: {name}"); + } + + let (group, name) = derive_snapshot_name(ccx, group, name); + + ccx.state.gas_metering.gas_records.push(GasRecord { + group: group.clone(), + name: name.clone(), + gas_used: 0, + depth: ccx.ecx.journaled_state.depth(), + }); + + ccx.state.gas_metering.active_gas_snapshot = Some((group, name)); + + ccx.state.gas_metering.start(); + + Ok(Default::default()) +} + +fn inner_stop_gas_snapshot( + ccx: &mut CheatsCtxt, + group: Option, + name: Option, +) -> Result { + // If group and name are not provided, use the last snapshot group and name. + let (group, name) = group.zip(name).unwrap_or_else(|| { + let (group, name) = ccx.state.gas_metering.active_gas_snapshot.as_ref().unwrap().clone(); + (group, name) + }); + + if let Some(record) = ccx + .state + .gas_metering + .gas_records + .iter_mut() + .find(|record| record.group == group && record.name == name) + { + // Calculate the gas used since the snapshot was started. + // We subtract 171 from the gas used to account for gas used by the snapshot itself. + let value = record.gas_used.saturating_sub(171); + + ccx.state + .gas_snapshots + .entry(group.clone()) + .or_default() + .insert(name.clone(), value.to_string()); + + // Stop the gas metering. + ccx.state.gas_metering.stop(); + + // Remove the gas record. + ccx.state + .gas_metering + .gas_records + .retain(|record| record.group != group && record.name != name); + + // Clear last snapshot cache if we have an exact match. + if let Some((snapshot_group, snapshot_name)) = &ccx.state.gas_metering.active_gas_snapshot { + if snapshot_group == &group && snapshot_name == &name { + ccx.state.gas_metering.active_gas_snapshot = None; + } + } + + Ok(value.abi_encode()) + } else { + bail!("no gas snapshot was started with the name: {name} in group: {group}"); + } +} + +// Derives the snapshot group and name from the provided group and name or the running contract. +fn derive_snapshot_name( + ccx: &CheatsCtxt, + group: Option, + name: Option, +) -> (String, String) { + let group = group.unwrap_or_else(|| { + ccx.state.config.running_contract.clone().expect("expected running contract") + }); + let name = name.unwrap_or_else(|| "default".to_string()); + (group, name) +} + /// Reads the current caller information and returns the current [CallerMode], `msg.sender` and /// `tx.origin`. /// diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index f4d0ed82114ae..3e80f1eaa9d00 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -5,7 +5,7 @@ use crate::{ mapping::{self, MappingSlots}, mock::{MockCallDataContext, MockCallReturnData}, prank::Prank, - DealRecord, RecordAccess, + DealRecord, GasRecord, RecordAccess, }, inspector::utils::CommonCreateInput, script::{Broadcast, ScriptWallets}, @@ -232,15 +232,35 @@ pub struct GasMetering { pub touched: bool, /// True if gas metering should be reset to frame limit. pub reset: bool, - /// Stores frames paused gas. + /// Stores paused gas frames. pub paused_frames: Vec, + /// The group and name of the active snapshot. + pub active_gas_snapshot: Option<(String, String)>, + /// Cache of the amount of gas used in previous call. /// This is used by the `lastCallGas` cheatcode. pub last_call_gas: Option, + + /// True if gas recording is enabled. + pub recording: bool, + /// The gas used in the last frame. + pub last_gas_used: u64, + /// Gas records for the active snapshots. + pub gas_records: Vec, } impl GasMetering { + /// Start the gas recording. + pub fn start(&mut self) { + self.recording = true; + } + + /// Stop the gas recording. + pub fn stop(&mut self) { + self.recording = false; + } + /// Resume paused gas metering. pub fn resume(&mut self) { if self.paused { @@ -435,6 +455,10 @@ pub struct Cheatcodes { /// Gas metering state. pub gas_metering: GasMetering, + /// Contains gas snapshots made over the course of a test suite. + // **Note**: both must a BTreeMap to ensure the order of the keys is deterministic. + pub gas_snapshots: BTreeMap>, + /// Mapping slots. pub mapping_slots: Option>, @@ -494,6 +518,7 @@ impl Cheatcodes { serialized_jsons: Default::default(), eth_deals: Default::default(), gas_metering: Default::default(), + gas_snapshots: Default::default(), mapping_slots: Default::default(), pc: Default::default(), breakpoints: Default::default(), @@ -1161,6 +1186,11 @@ impl Inspector for Cheatcodes { if let Some(mapping_slots) = &mut self.mapping_slots { mapping::step(mapping_slots, interpreter); } + + // `snapshotGas*`: take a snapshot of the current gas. + if self.gas_metering.recording { + self.meter_gas_record(interpreter, ecx); + } } #[inline] @@ -1569,6 +1599,31 @@ impl Cheatcodes { } } + #[cold] + fn meter_gas_record( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext, + ) { + if matches!(interpreter.instruction_result, InstructionResult::Continue) { + self.gas_metering.gas_records.iter_mut().for_each(|record| { + if ecx.journaled_state.depth() == record.depth { + // Skip the first opcode of the first call frame as it includes the gas cost of + // creating the snapshot. + if self.gas_metering.last_gas_used != 0 { + let gas_diff = + interpreter.gas.spent().saturating_sub(self.gas_metering.last_gas_used); + record.gas_used = record.gas_used.saturating_add(gas_diff); + } + + // Update `last_gas_used` to the current spent gas for the next iteration to + // compare against. + self.gas_metering.last_gas_used = interpreter.gas.spent(); + } + }); + } + } + #[cold] fn meter_gas_end(&mut self, interpreter: &mut Interpreter) { // Remove recorded gas if we exit frame. diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 3d5fce2954547..5e40862f8277b 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -308,6 +308,7 @@ impl SessionSource { self.config.evm_opts.clone(), None, None, + None, Some(self.solc.version.clone()), ) .into(), diff --git a/crates/common/src/fs.rs b/crates/common/src/fs.rs index 45c21eba69e2e..71a62d13a7ae7 100644 --- a/crates/common/src/fs.rs +++ b/crates/common/src/fs.rs @@ -56,6 +56,15 @@ pub fn write_json_file(path: &Path, obj: &T) -> Result<()> { writer.flush().map_err(|e| FsPathError::write(e, path)) } +/// Writes the object as a pretty JSON object. +pub fn write_pretty_json_file(path: &Path, obj: &T) -> Result<()> { + let file = create_file(path)?; + let mut writer = BufWriter::new(file); + serde_json::to_writer_pretty(&mut writer, obj) + .map_err(|source| FsPathError::WriteJson { source, path: path.into() })?; + writer.flush().map_err(|e| FsPathError::write(e, path)) +} + /// Wrapper for `std::fs::write` pub fn write(path: impl AsRef, contents: impl AsRef<[u8]>) -> Result<()> { let path = path.as_ref(); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 18352aab99729..017341c3d828f 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -175,6 +175,8 @@ pub struct Config { pub cache: bool, /// where the cache is stored if enabled pub cache_path: PathBuf, + /// where the gas snapshots are stored + pub snapshots: PathBuf, /// where the broadcast logs are stored pub broadcast: PathBuf, /// additional solc allow paths for `--allow-paths` @@ -718,6 +720,7 @@ impl Config { self.out = p(&root, &self.out); self.broadcast = p(&root, &self.broadcast); self.cache_path = p(&root, &self.cache_path); + self.snapshots = p(&root, &self.snapshots); if let Some(build_info_path) = self.build_info_path { self.build_info_path = Some(p(&root, &build_info_path)); @@ -885,6 +888,12 @@ impl Config { remove_test_dir(&self.fuzz.failure_persist_dir); remove_test_dir(&self.invariant.failure_persist_dir); + // Remove snapshot directory. + let snapshot_dir = project.root().join(&self.snapshots); + if snapshot_dir.exists() { + let _ = fs::remove_dir_all(&snapshot_dir); + } + Ok(()) } @@ -2086,6 +2095,7 @@ impl Default for Config { cache: true, cache_path: "cache".into(), broadcast: "broadcast".into(), + snapshots: "snapshots".into(), allow_paths: vec![], include_paths: vec![], force: false, diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index cb57f205326ab..982e44ea9d6a2 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -17,7 +17,7 @@ use foundry_evm_fuzz::{ use foundry_evm_traces::SparsedTraceArena; use indicatif::ProgressBar; use proptest::test_runner::{TestCaseError, TestError, TestRunner}; -use std::cell::RefCell; +use std::{cell::RefCell, collections::BTreeMap}; mod types; pub use types::{CaseOutcome, CounterExampleOutcome, FuzzOutcome}; @@ -39,6 +39,8 @@ pub struct FuzzTestData { pub coverage: Option, // Stores logs for all fuzz cases pub logs: Vec, + // Stores gas snapshots for all fuzz cases + pub gas_snapshots: BTreeMap>, // Deprecated cheatcodes mapped to their replacements. pub deprecated_cheatcodes: HashMap<&'static str, Option<&'static str>>, } @@ -108,9 +110,11 @@ impl FuzzedExecutor { FuzzOutcome::Case(case) => { let mut data = execution_data.borrow_mut(); data.gas_by_case.push((case.case.gas, case.case.stipend)); + if data.first_case.is_none() { data.first_case.replace(case.case); } + if let Some(call_traces) = case.traces { if data.traces.len() == max_traces_to_collect { data.traces.pop(); @@ -118,14 +122,17 @@ impl FuzzedExecutor { data.traces.push(call_traces); data.breakpoints.replace(case.breakpoints); } + if show_logs { data.logs.extend(case.logs); } + // Collect and merge coverage if `forge snapshot` context. match &mut data.coverage { Some(prev) => prev.merge(case.coverage.unwrap()), opt => *opt = case.coverage, } + data.deprecated_cheatcodes = case.deprecated_cheatcodes; Ok(()) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 6bf1ffd8183a4..6d53a4756bd77 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -310,6 +310,17 @@ impl TestArgs { let toml = config.get_config_path(); let profiles = get_available_profiles(toml)?; + // Remove the snapshots directory if it exists. + // This is to ensure that we don't have any stale snapshots. + // If `FORGE_SNAPSHOT_CHECK` is set, we don't remove the snapshots directory as it is + // required for comparison. + if std::env::var("FORGE_SNAPSHOT_CHECK").is_err() { + let snapshot_dir = project_root.join(&config.snapshots); + if snapshot_dir.exists() { + let _ = fs::remove_dir_all(project_root.join(&config.snapshots)); + } + } + let test_options: TestOptions = TestOptionsBuilder::default() .fuzz(config.fuzz.clone()) .invariant(config.invariant.clone()) @@ -546,6 +557,8 @@ impl TestArgs { .gas_report .then(|| GasReport::new(config.gas_reports.clone(), config.gas_reports_ignore.clone())); + let mut gas_snapshots = BTreeMap::>::new(); + let mut outcome = TestOutcome::empty(self.allow_failure); let mut any_test_failed = false; @@ -655,6 +668,83 @@ impl TestArgs { } } } + + // Collect and merge gas snapshots. + for (group, new_snapshots) in result.gas_snapshots.iter() { + gas_snapshots.entry(group.clone()).or_default().extend(new_snapshots.clone()); + } + } + + // Write gas snapshots to disk if any were collected. + if !gas_snapshots.is_empty() { + // Check for differences in gas snapshots if `FORGE_SNAPSHOT_CHECK` is set. + // Exiting early with code 1 if differences are found. + if std::env::var("FORGE_SNAPSHOT_CHECK").is_ok() { + let differences_found = gas_snapshots.clone().into_iter().fold( + false, + |mut found, (group, snapshots)| { + // If the snapshot file doesn't exist, we can't compare so we skip. + if !&config.snapshots.join(format!("{group}.json")).exists() { + return false; + } + + let previous_snapshots: BTreeMap = + fs::read_json_file(&config.snapshots.join(format!("{group}.json"))) + .expect("Failed to read snapshots from disk"); + + let diff: BTreeMap<_, _> = snapshots + .iter() + .filter_map(|(k, v)| { + previous_snapshots.get(k).and_then(|previous_snapshot| { + if previous_snapshot != v { + Some(( + k.clone(), + (previous_snapshot.clone(), v.clone()), + )) + } else { + None + } + }) + }) + .collect(); + + if !diff.is_empty() { + println!( + "{}", + format!("\n[{group}] Failed to match snapshots:").red().bold() + ); + + for (key, (previous_snapshot, snapshot)) in &diff { + println!( + "{}", + format!("- [{key}] {previous_snapshot} → {snapshot}").red() + ); + } + + found = true; + } + + found + }, + ); + + if differences_found { + println!(); + eyre::bail!("Snapshots differ from previous run"); + } + } + + // Create `snapshots` directory if it doesn't exist. + fs::create_dir_all(&config.snapshots)?; + + // Write gas snapshots to disk per group. + gas_snapshots.clone().into_iter().for_each(|(group, snapshots)| { + fs::write_pretty_json_file( + &config.snapshots.join(format!("{group}.json")), + &snapshots, + ) + .expect("Failed to write gas snapshots to disk"); + }); } // Print suite summary. diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 43aade0ff65c1..802ad3884cc65 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -243,6 +243,7 @@ impl MultiContractRunner { self.evm_opts.clone(), Some(self.known_contracts.clone()), None, + Some(artifact_id.name.clone()), Some(artifact_id.version.clone()), ); diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 1ec829f6bc942..0e00bb5e2773e 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -412,6 +412,9 @@ pub struct TestResult { /// pc breakpoint char map pub breakpoints: Breakpoints, + /// Any captured gas snapshots along the test's execution which should be accumulated. + pub gas_snapshots: BTreeMap>, + /// Deprecated cheatcodes (mapped to their replacements, if any) used in current test. #[serde(skip)] pub deprecated_cheatcodes: HashMap<&'static str, Option<&'static str>>, @@ -531,6 +534,7 @@ impl TestResult { if let Some(cheatcodes) = raw_call_result.cheatcodes { self.breakpoints = cheatcodes.breakpoints; + self.gas_snapshots = cheatcodes.gas_snapshots; self.deprecated_cheatcodes = cheatcodes.deprecated; } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f8b1da523c74c..5c0d62a3299af 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -37,6 +37,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { libs: vec!["lib-test".into()], cache: true, cache_path: "test-cache".into(), + snapshots: "snapshots".into(), broadcast: "broadcast".into(), force: true, evm_version: EvmVersion::Byzantium, diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 8231a5d54b561..94c028bb9b471 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -612,6 +612,7 @@ impl ScriptConfig { self.evm_opts.clone(), Some(known_contracts), Some(script_wallets), + Some(target.name), Some(target.version), ) .into(), diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 09099f5402a2d..335ce83d08964 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -423,7 +423,11 @@ interface Vm { function skip(bool skipTest, string calldata reason) external; function sleep(uint256 duration) external; function snapshot() external returns (uint256 snapshotId); + function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed); + function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed); function snapshotState() external returns (uint256 snapshotId); + function snapshotValue(string calldata name, uint256 value) external; + function snapshotValue(string calldata group, string calldata name, uint256 value) external; function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs); function startBroadcast() external; function startBroadcast(address signer) external; @@ -431,12 +435,17 @@ interface Vm { function startMappingRecording() external; function startPrank(address msgSender) external; function startPrank(address msgSender, address txOrigin) external; + function startSnapshotGas(string calldata name) external; + function startSnapshotGas(string calldata group, string calldata name) external; function startStateDiffRecording() external; function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses); function stopBroadcast() external; function stopExpectSafeMemory() external; function stopMappingRecording() external; function stopPrank() external; + function stopSnapshotGas() external returns (uint256 gasUsed); + function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed); + function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed); function store(address target, bytes32 slot, bytes32 value) external; function toBase64URL(bytes calldata data) external pure returns (string memory); function toBase64URL(string calldata data) external pure returns (string memory); diff --git a/testdata/default/cheats/GasSnapshots.t.sol b/testdata/default/cheats/GasSnapshots.t.sol new file mode 100644 index 0000000000000..1e64a073d11fd --- /dev/null +++ b/testdata/default/cheats/GasSnapshots.t.sol @@ -0,0 +1,321 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract GasSnapshotTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + uint256 public slot0; + Flare public flare; + + function setUp() public { + flare = new Flare(); + } + + function testSnapshotGasSectionExternal() public { + vm.startSnapshotGas("testAssertGasExternal"); + flare.run(1); + uint256 gasUsed = vm.stopSnapshotGas(); + + assertGt(gasUsed, 0); + } + + function testSnapshotGasSectionInternal() public { + vm.startSnapshotGas("testAssertGasInternalA"); + slot0 = 1; + vm.stopSnapshotGas(); + + vm.startSnapshotGas("testAssertGasInternalB"); + slot0 = 2; + vm.stopSnapshotGas(); + + vm.startSnapshotGas("testAssertGasInternalC"); + slot0 = 0; + vm.stopSnapshotGas(); + + vm.startSnapshotGas("testAssertGasInternalD"); + slot0 = 1; + vm.stopSnapshotGas(); + + vm.startSnapshotGas("testAssertGasInternalE"); + slot0 = 2; + vm.stopSnapshotGas(); + } + + // Writes to `GasSnapshotTest` group with custom names. + function testSnapshotValueDefaultGroupA() public { + uint256 a = 123; + uint256 b = 456; + uint256 c = 789; + + vm.snapshotValue("a", a); + vm.snapshotValue("b", b); + vm.snapshotValue("c", c); + } + + // Writes to same `GasSnapshotTest` group with custom names. + function testSnapshotValueDefaultGroupB() public { + uint256 d = 123; + uint256 e = 456; + uint256 f = 789; + + vm.snapshotValue("d", d); + vm.snapshotValue("e", e); + vm.snapshotValue("f", f); + } + + // Writes to `CustomGroup` group with custom names. + // Asserts that the order of the values is alphabetical. + function testSnapshotValueCustomGroupA() public { + uint256 o = 123; + uint256 i = 456; + uint256 q = 789; + + vm.snapshotValue("CustomGroup", "q", q); + vm.snapshotValue("CustomGroup", "i", i); + vm.snapshotValue("CustomGroup", "o", o); + } + + // Writes to `CustomGroup` group with custom names. + // Asserts that the order of the values is alphabetical. + function testSnapshotValueCustomGroupB() public { + uint256 x = 123; + uint256 e = 456; + uint256 z = 789; + + vm.snapshotValue("CustomGroup", "z", z); + vm.snapshotValue("CustomGroup", "x", x); + vm.snapshotValue("CustomGroup", "e", e); + } + + // Writes to `GasSnapshotTest` group with `testSnapshotGasDefault` name. + function testSnapshotGasSectionDefaultGroupStop() public { + vm.startSnapshotGas("testSnapshotGasSection"); + + flare.run(256); + + // vm.stopSnapshotGas() will use the last snapshot name. + uint256 gasUsed = vm.stopSnapshotGas(); + assertGt(gasUsed, 0); + } + + // Writes to `GasSnapshotTest` group with `testSnapshotGasCustom` name. + function testSnapshotGasSectionCustomGroupStop() public { + vm.startSnapshotGas("CustomGroup", "testSnapshotGasSection"); + + flare.run(256); + + // vm.stopSnapshotGas() will use the last snapshot name, even with custom group. + uint256 gasUsed = vm.stopSnapshotGas(); + assertGt(gasUsed, 0); + } + + // Writes to `GasSnapshotTest` group with `testSnapshotGasSection` name. + function testSnapshotGasSectionName() public { + vm.startSnapshotGas("testSnapshotGasSectionName"); + + flare.run(256); + + uint256 gasUsed = vm.stopSnapshotGas("testSnapshotGasSectionName"); + assertGt(gasUsed, 0); + } + + // Writes to `CustomGroup` group with `testSnapshotGasSection` name. + function testSnapshotGasSectionGroupName() public { + vm.startSnapshotGas("CustomGroup", "testSnapshotGasSectionGroupName"); + + flare.run(256); + + uint256 gasUsed = vm.stopSnapshotGas("CustomGroup", "testSnapshotGasSectionGroupName"); + assertGt(gasUsed, 0); + } + + // Writes to `GasSnapshotTest` group with `testSnapshotGas` name. + function testSnapshotGasLastCallName() public { + flare.run(1); + + uint256 gasUsed = vm.snapshotGasLastCall("testSnapshotGasLastCallName"); + assertGt(gasUsed, 0); + } + + // Writes to `CustomGroup` group with `testSnapshotGas` name. + function testSnapshotGasLastCallGroupName() public { + flare.run(1); + + uint256 gasUsed = vm.snapshotGasLastCall("CustomGroup", "testSnapshotGasLastCallGroupName"); + assertGt(gasUsed, 0); + } +} + +contract GasComparisonTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + uint256 public slot0; + uint256 public slot1; + + uint256 public cachedGas; + + function testGasComparisonEmpty() public { + // Start a cheatcode snapshot. + vm.startSnapshotGas("ComparisonGroup", "testGasComparisonEmptyA"); + uint256 a = vm.stopSnapshotGas(); + + // Start a comparitive Solidity snapshot. + _snapStart(); + uint256 b = _snapEnd(); + vm.snapshotValue("ComparisonGroup", "testGasComparisonEmptyB", b); + + assertEq(a, b); + } + + function testGasComparisonInternalCold() public { + // Start a cheatcode snapshot. + vm.startSnapshotGas("ComparisonGroup", "testGasComparisonInternalColdA"); + slot0 = 1; + uint256 a = vm.stopSnapshotGas(); + + // Start a comparitive Solidity snapshot. + _snapStart(); + slot1 = 1; + uint256 b = _snapEnd(); + vm.snapshotValue("ComparisonGroup", "testGasComparisonInternalColdB", b); + + vm.assertApproxEqAbs(a, b, 6); + } + + function testGasComparisonInternalWarm() public { + // Warm up the cache. + slot0 = 1; + + // Start a cheatcode snapshot. + vm.startSnapshotGas("ComparisonGroup", "testGasComparisonInternalWarmA"); + slot0 = 2; + uint256 a = vm.stopSnapshotGas(); + + // Start a comparitive Solidity snapshot. + _snapStart(); + slot0 = 3; + uint256 b = _snapEnd(); + vm.snapshotValue("ComparisonGroup", "testGasComparisonInternalWarmB", b); + + vm.assertApproxEqAbs(a, b, 6); + } + + function testGasComparisonExternal() public { + // Warm up the cache. + TargetB target = new TargetB(); + target.update(1); + + // Start a cheatcode snapshot. + vm.startSnapshotGas("ComparisonGroup", "testGasComparisonExternalA"); + target.update(2); + uint256 a = vm.stopSnapshotGas(); + + // Start a comparitive Solidity snapshot. + _snapStart(); + target.update(3); + uint256 b = _snapEnd(); + vm.snapshotValue("ComparisonGroup", "testGasComparisonExternalB", b); + + assertEq(a, b); + } + + function testGasComparisonCreate() public { + // Start a cheatcode snapshot. + vm.startSnapshotGas("ComparisonGroup", "testGasComparisonCreateA"); + new TargetC(); + uint256 a = vm.stopSnapshotGas(); + + // Start a comparitive Solidity snapshot. + _snapStart(); + new TargetC(); + uint256 b = _snapEnd(); + vm.snapshotValue("ComparisonGroup", "testGasComparisonCreateB", b); + + assertEq(a, b); + } + + function testGasComparisonNestedCalls() public { + // Warm up the cache. + TargetA target = new TargetA(); + target.update(1); + + // Start a cheatcode snapshot. + vm.startSnapshotGas("ComparisonGroup", "testGasComparisonNestedCallsA"); + target.update(2); + uint256 a = vm.stopSnapshotGas(); + + // Start a comparitive Solidity snapshot. + _snapStart(); + target.update(3); + uint256 b = _snapEnd(); + vm.snapshotValue("ComparisonGroup", "testGasComparisonNestedCallsB", b); + + assertEq(a, b); + } + + function testGasComparisonFlare() public { + // Warm up the cache. + Flare flare = new Flare(); + flare.run(1); + + // Start a cheatcode snapshot. + vm.startSnapshotGas("ComparisonGroup", "testGasComparisonFlareA"); + flare.run(256); + uint256 a = vm.stopSnapshotGas(); + + // Start a comparitive Solidity snapshot. + _snapStart(); + flare.run(256); + uint256 b = _snapEnd(); + vm.snapshotValue("ComparisonGroup", "testGasComparisonFlareB", b); + + assertEq(a, b); + } + + // Internal function to start a Solidity snapshot. + function _snapStart() internal { + cachedGas = 1; + cachedGas = gasleft(); + } + + // Internal function to end a Solidity snapshot. + function _snapEnd() internal returns (uint256 gasUsed) { + gasUsed = cachedGas - gasleft() - 138; + cachedGas = 2; + } +} + +contract Flare { + bytes32[] public data; + + function run(uint256 n_) public { + for (uint256 i = 0; i < n_; i++) { + data.push(keccak256(abi.encodePacked(i))); + } + } +} + +contract TargetA { + TargetB public target; + + constructor() { + target = new TargetB(); + } + + function update(uint256 x_) public { + target.update(x_); + } +} + +contract TargetB { + uint256 public x; + + function update(uint256 x_) public { + x = x_; + } +} + +contract TargetC {} From 57bcac09ef36e14655fc62691a021f588defd6fb Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:59:57 +0530 Subject: [PATCH 1508/1963] chore(deps): bump alloy to 0.4.2 (#9000) * chore: bump alloy-core deps + revm * bump alloy to 0.4.0 * bump revm-inspectors + type casting to u128 * fix * fix * fix * bump foundry-fork-db * bump alloy * fix * gas related field to u64 * fmt * change gas fields types to u64 in DepositTx, TxEssentials --- Cargo.lock | 396 ++++++++++-------- Cargo.toml | 46 +- crates/anvil/core/src/eth/block.rs | 26 +- crates/anvil/core/src/eth/transaction/mod.rs | 35 +- .../core/src/eth/transaction/optimism.rs | 6 +- crates/anvil/src/cmd.rs | 2 +- crates/anvil/src/config.rs | 22 +- crates/anvil/src/eth/api.rs | 15 +- crates/anvil/src/eth/backend/executor.rs | 34 +- crates/anvil/src/eth/backend/fork.rs | 10 +- crates/anvil/src/eth/backend/mem/mod.rs | 34 +- crates/anvil/src/eth/backend/mem/storage.rs | 10 +- crates/anvil/src/eth/error.rs | 2 +- crates/anvil/src/eth/fees.rs | 24 +- crates/anvil/tests/it/anvil_api.rs | 4 +- crates/anvil/tests/it/api.rs | 41 +- crates/anvil/tests/it/eip4844.rs | 8 +- crates/anvil/tests/it/fork.rs | 12 +- crates/anvil/tests/it/gas.rs | 18 +- crates/anvil/tests/it/optimism.rs | 68 +-- crates/anvil/tests/it/transaction.rs | 22 +- crates/cheatcodes/src/inspector.rs | 12 +- crates/common/src/transactions.rs | 9 +- crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/utils.rs | 2 +- crates/script/src/broadcast.rs | 2 +- crates/script/src/transaction.rs | 2 +- crates/verify/src/bytecode.rs | 4 +- 28 files changed, 457 insertions(+), 411 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7308606c9e3cd..6c48e16b2bcbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,28 +89,44 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "629b62e38d471cc15fea534eb7283d2f8a4e8bdb1811bcc5d66dda6cfce6fae1" dependencies = [ - "alloy-eips", + "alloy-eips 0.3.6", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.3.6", "c-kzg", "serde", ] +[[package]] +name = "alloy-consensus" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "705687d5bfd019fee57cf9e206b27b30a9a9617535d5590a02b171e813208f8e" +dependencies = [ + "alloy-eips 0.4.2", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.4.2", + "auto_impl", + "c-kzg", + "derive_more 1.0.0", + "serde", +] + [[package]] name = "alloy-contract" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eefe64fd344cffa9cf9e3435ec4e93e6e9c3481bc37269af988bf497faf4a6a" +checksum = "917f7d12cf3971dc8c11c9972f732b35ccb9aaaf5f28f2f87e9e6523bee3a8ad" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-network", - "alloy-network-primitives", + "alloy-network-primitives 0.4.0", "alloy-primitives", "alloy-provider", "alloy-pubsub", - "alloy-rpc-types-eth", + "alloy-rpc-types-eth 0.4.0", "alloy-sol-types", "alloy-transport", "futures", @@ -154,9 +170,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d319bb544ca6caeab58c39cea8921c55d924d4f68f2c60f24f914673f9a74a" +checksum = "ea59dc42102bc9a1905dc57901edc6dd48b9f38115df86c7d252acba70d71d04" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -176,7 +192,25 @@ dependencies = [ "alloy-eip7702", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.3.6", + "c-kzg", + "derive_more 1.0.0", + "once_cell", + "serde", + "sha2", +] + +[[package]] +name = "alloy-eips" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ffb906284a1e1f63c4607da2068c8197458a352d0b3e9796e67353d72a9be85" +dependencies = [ + "alloy-eip2930", + "alloy-eip7702", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.4.2", "c-kzg", "derive_more 1.0.0", "once_cell", @@ -186,12 +220,12 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a7a18afb0b318616b6b2b0e2e7ac5529d32a966c673b48091c9919e284e6aca" +checksum = "8429cf4554eed9b40feec7f4451113e76596086447550275e3def933faf47ce3" dependencies = [ "alloy-primitives", - "alloy-serde", + "alloy-serde 0.4.2", "serde", ] @@ -209,9 +243,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3c717b5298fad078cd3a418335b266eba91b511383ca9bd497f742d5975d5ab" +checksum = "f8fa8a1a3c4cbd221f2b8e3693aeb328fca79a757fe556ed08e47bbbc2a70db7" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -223,17 +257,17 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3705ce7d8602132bcf5ac7a1dd293a42adc2f183abf5907c30ac535ceca049" +checksum = "85fa23a6a9d612b52e402c995f2d582c25165ec03ac6edf64c861a76bc5b87cd" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.4.2", + "alloy-eips 0.4.2", "alloy-json-rpc", - "alloy-network-primitives", + "alloy-network-primitives 0.4.0", "alloy-primitives", - "alloy-rpc-types-eth", - "alloy-serde", + "alloy-rpc-types-eth 0.4.0", + "alloy-serde 0.4.2", "alloy-signer", "alloy-sol-types", "async-trait", @@ -248,9 +282,22 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94ad40869867ed2d9cd3842b1e800889e5b49e6b92da346e93862b4a741bedf3" dependencies = [ - "alloy-eips", + "alloy-eips 0.3.6", + "alloy-primitives", + "alloy-serde 0.3.6", + "serde", +] + +[[package]] +name = "alloy-network-primitives" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8416e4e9ceee8014d2f89fc3dde331da392b26d14226a0d5cbc207ae7799fb2f" +dependencies = [ + "alloy-consensus 0.4.2", + "alloy-eips 0.4.2", "alloy-primitives", - "alloy-serde", + "alloy-serde 0.4.2", "serde", ] @@ -287,20 +334,20 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927f708dd457ed63420400ee5f06945df9632d5d101851952056840426a10dc5" +checksum = "fcfaa4ffec0af04e3555686b8aacbcdf7d13638133a0672749209069750f78a6" dependencies = [ "alloy-chains", - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.4.2", + "alloy-eips 0.4.2", "alloy-json-rpc", "alloy-network", - "alloy-network-primitives", + "alloy-network-primitives 0.4.0", "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types-eth", + "alloy-rpc-types-eth 0.4.0", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", "alloy-transport", @@ -326,9 +373,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d05f63677e210d758cd5d6d1ce10f20c980c3560ccfbe79ba1997791862a04f" +checksum = "f32cef487122ae75c91eb50154c70801d71fabdb976fec6c49e0af5e6486ab15" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -367,9 +414,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d82952dca71173813d4e5733e2c986d8b04aea9e0f3b0a576664c232ad050a5" +checksum = "370143ed581aace6e663342d21d209c6b2e34ee6142f7d6675adb518deeaf0dc" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -392,45 +439,47 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64333d639f2a0cf73491813c629a405744e16343a4bc5640931be707c345ecc5" +checksum = "9ffc534b7919e18f35e3aa1f507b6f3d9d92ec298463a9f6beaac112809d8d06" dependencies = [ + "alloy-primitives", "alloy-rpc-types-anvil", "alloy-rpc-types-engine", - "alloy-rpc-types-eth", + "alloy-rpc-types-eth 0.4.0", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", - "alloy-serde", + "alloy-serde 0.4.2", "serde", ] [[package]] name = "alloy-rpc-types-anvil" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25cb45ad7c0930dd62eecf164d2afe4c3d2dd2c82af85680ad1f118e1e5cb83" +checksum = "142f6fb21ef1857b3d175dc16b73d67f4b70914e6898610da3c0b65a1281fe7b" dependencies = [ "alloy-primitives", - "alloy-serde", + "alloy-serde 0.4.2", "serde", ] [[package]] name = "alloy-rpc-types-engine" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1464c4dd646e1bdfde86ae65ce5ba168dbb29180b478011fe87117ae46b1629b" +checksum = "c032e9b725a990be03cc0ddd9fa73c21f61d1449b328083aa22fbfafb03eda1b" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.4.2", + "alloy-eips 0.4.2", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.4.2", "derive_more 1.0.0", "jsonwebtoken", "rand", "serde", + "strum", ] [[package]] @@ -439,12 +488,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83aa984386deda02482660aa31cb8ca1e63d533f1c31a52d7d181ac5ec68e9b8" dependencies = [ - "alloy-consensus", - "alloy-eips", - "alloy-network-primitives", + "alloy-consensus 0.3.6", + "alloy-eips 0.3.6", + "alloy-network-primitives 0.3.6", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.3.6", "alloy-sol-types", "cfg-if", "derive_more 1.0.0", @@ -454,15 +503,34 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-rpc-types-eth" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e1f655dcd5e9ccf215cbffb69272698ef6b3ec76907e8937345f2a82ae04ed4" +dependencies = [ + "alloy-consensus 0.4.2", + "alloy-eips 0.4.2", + "alloy-network-primitives 0.4.0", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.4.2", + "alloy-sol-types", + "derive_more 1.0.0", + "itertools 0.13.0", + "serde", + "serde_json", +] + [[package]] name = "alloy-rpc-types-trace" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98db35cd42c90b484377e6bc44d95377a7a38a5ebee996e67754ac0446d542ab" +checksum = "6900c7d94528217465f6b619f03adb2eecc9682f9083d49ad7d40ec6eda0ed04" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth", - "alloy-serde", + "alloy-rpc-types-eth 0.4.0", + "alloy-serde 0.4.2", "serde", "serde_json", "thiserror", @@ -470,13 +538,13 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bac37082c3b21283b3faf5cc0e08974272aee2f756ce1adeb26db56a5fce0d5" +checksum = "954781be5ca2e15db08d753712f494504a04771ee4296de1e834e65c105b8ec3" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth", - "alloy-serde", + "alloy-rpc-types-eth 0.4.0", + "alloy-serde 0.4.2", "serde", ] @@ -491,11 +559,22 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-serde" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dff0ab1cdd43ca001e324dc27ee0e8606bd2161d6623c63e0e0b8c4dfc13600" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", +] + [[package]] name = "alloy-signer" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307324cca94354cd654d6713629f0383ec037e1ff9e3e3d547212471209860c0" +checksum = "2fd4e0ad79c81a27ca659be5d176ca12399141659fef2bcbfdc848da478f4504" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -509,11 +588,11 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076be69aa26a4c500919f1ad3847662aa6d1e9bc2995e263ed826b1546d1b990" +checksum = "417e19d9844350d11f7426d4920a5df777f8c2abbb7a70d9de6f1faf284db15b" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-network", "alloy-primitives", "alloy-signer", @@ -527,11 +606,11 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cabd79d4eb954a8c2ae7889a18e2466af186ae68376251cf58525239c156ec54" +checksum = "b6fd12ae28e8330766821058ed9a6a06ae4f9b12c776e8a7cfb16e3a954f508e" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-network", "alloy-primitives", "alloy-signer", @@ -545,11 +624,11 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3df66f5ddcc32d2070485dc702f5f5fb97cfbfa817f6e2e6bac16a4e32ed44c" +checksum = "d3a02400dea370022151f07581b73a836115c88ce4df350206653493bec024e2" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -565,18 +644,17 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fabe917ab1778e760b4701628d1cae8e028ee9d52ac6307de4e1e9286ab6b5f" +checksum = "494e0a256f3e99f2426f994bcd1be312c02cb8f88260088dacb33a8b8936475f" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-network", "alloy-primitives", "alloy-signer", "async-trait", "coins-bip32", "coins-bip39", - "elliptic-curve", "eth-keystore", "k256", "rand", @@ -585,11 +663,11 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1068949eda889b2c052b29a6e8c7ea2ba16be6d1af83ad165fff2a4e4ad19fcd" +checksum = "e0d91ddee2390b002148128e47902893deba353eb1b818a3afb6c960ebf4e42c" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-network", "alloy-primitives", "alloy-signer", @@ -675,9 +753,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33616b2edf7454302a1d48084db185e52c309f73f6c10be99b0fe39354b3f1e9" +checksum = "2ac3e97dad3d31770db0fc89bd6a63b789fbae78963086733f960cf32c483904" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -694,9 +772,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a944f5310c690b62bbb3e7e5ce34527cbd36b2d18532a797af123271ce595a49" +checksum = "b367dcccada5b28987c2296717ee04b9a5637aacd78eacb1726ef211678b5212" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -709,9 +787,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fd8491249f74d16ec979b1f5672377b12ebb818e6056478ffa386954dbd350" +checksum = "b90cf9cde7f2fce617da52768ee28f522264b282d148384a4ca0ea85af04fa3a" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -730,9 +808,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9704761f6297fe482276bee7f77a93cb42bd541c2bd6c1c560b6f3a9ece672e" +checksum = "7153b88690de6a50bba81c11e1d706bc41dbb90126d607404d60b763f6a3947f" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -741,7 +819,7 @@ dependencies = [ "rustls 0.23.13", "serde_json", "tokio", - "tokio-tungstenite 0.23.1", + "tokio-tungstenite", "tracing", "ws_stream_wasm", ] @@ -849,10 +927,10 @@ name = "anvil" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-contract", "alloy-dyn-abi", - "alloy-eips", + "alloy-eips 0.4.2", "alloy-genesis", "alloy-json-abi", "alloy-json-rpc", @@ -863,7 +941,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-client", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -917,13 +995,13 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-dyn-abi", - "alloy-eips", + "alloy-eips 0.4.2", "alloy-primitives", "alloy-rlp", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-trie", "bytes", "foundry-common", @@ -1601,7 +1679,7 @@ dependencies = [ "sha1", "sync_wrapper 1.0.1", "tokio", - "tokio-tungstenite 0.24.0", + "tokio-tungstenite", "tower 0.5.1", "tower-layer", "tower-service", @@ -1916,9 +1994,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.22" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ "shlex", ] @@ -3247,14 +3325,14 @@ name = "forge" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-dyn-abi", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-signer", "alloy-signer-local", "alloy-sol-macro-expander", @@ -3377,15 +3455,15 @@ name = "forge-script" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-dyn-abi", - "alloy-eips", + "alloy-eips 0.4.2", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-signer", "alloy-transport", "async-recursion", @@ -3498,7 +3576,7 @@ name = "foundry-cast" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -3508,7 +3586,7 @@ dependencies = [ "alloy-provider", "alloy-rlp", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -3556,7 +3634,7 @@ dependencies = [ name = "foundry-cheatcodes" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-dyn-abi", "alloy-genesis", "alloy-json-abi", @@ -3648,7 +3726,7 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -3658,7 +3736,7 @@ dependencies = [ "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3694,11 +3772,11 @@ dependencies = [ name = "foundry-common-fmt" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-dyn-abi", "alloy-primitives", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "chrono", "comfy-table", "foundry-macros", @@ -3921,7 +3999,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-sol-types", "alloy-transport", "auto_impl", @@ -4017,14 +4095,14 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fb76083f203e341deeb4a03f9cc86df096f09c723c42e44c25052c233ed87b4" +checksum = "2c8bdd63ecf8309c549d41a6167510da5053b13e9ab5456f06aff1070c0b642f" dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.4.2", "alloy-transport", "eyre", "futures", @@ -4084,7 +4162,7 @@ dependencies = [ name = "foundry-wallets" version = "0.2.0" dependencies = [ - "alloy-consensus", + "alloy-consensus 0.4.2", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -4797,9 +4875,9 @@ checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a" [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -6013,11 +6091,11 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21aad1fbf80d2bcd7406880efc7ba109365f44bbb72896758ddcbfa46bf1592c" dependencies = [ - "alloy-consensus", - "alloy-eips", + "alloy-consensus 0.3.6", + "alloy-eips 0.3.6", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.3.6", "derive_more 1.0.0", "serde", "spin", @@ -6029,11 +6107,11 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e281fbfc2198b7c0c16457d6524f83d192662bc9f3df70f24c3038d4521616df" dependencies = [ - "alloy-eips", - "alloy-network-primitives", + "alloy-eips 0.3.6", + "alloy-network-primitives 0.3.6", "alloy-primitives", - "alloy-rpc-types-eth", - "alloy-serde", + "alloy-rpc-types-eth 0.3.6", + "alloy-serde 0.3.6", "cfg-if", "hashbrown 0.14.5", "op-alloy-consensus", @@ -7099,9 +7177,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "async-compression", "base64 0.22.1", @@ -7127,8 +7205,8 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.13", - "rustls-native-certs 0.7.3", - "rustls-pemfile 2.1.3", + "rustls-native-certs 0.8.0", + "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", "serde_json", @@ -7166,12 +7244,12 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.7.7" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8e3bae0d5c824da0ac883e2521c5e83870d6521eeeccd4ee54266aa3cc1a51" +checksum = "43c44af0bf801f48d25f7baf25cf72aff4c02d610f83b428175228162fef0246" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth", + "alloy-rpc-types-eth 0.4.0", "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", @@ -7450,19 +7528,6 @@ dependencies = [ "security-framework", ] -[[package]] -name = "rustls-native-certs" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" -dependencies = [ - "openssl-probe", - "rustls-pemfile 2.1.3", - "rustls-pki-types", - "schannel", - "security-framework", -] - [[package]] name = "rustls-native-certs" version = "0.8.0" @@ -7470,7 +7535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.3", + "rustls-pemfile 2.2.0", "rustls-pki-types", "schannel", "security-framework", @@ -7487,11 +7552,10 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] @@ -7622,9 +7686,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.18" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "215b1103f73e23e9cb6883072c1fb26ae55c09d42054654955c739e5418a7c96" +checksum = "836f1e0f4963ef5288b539b643b35e043e76a32d0f4e47e67febf69576527f50" dependencies = [ "sdd", ] @@ -8650,9 +8714,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.23.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" +checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", @@ -8660,22 +8724,10 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", - "tungstenite 0.23.0", + "tungstenite", "webpki-roots", ] -[[package]] -name = "tokio-tungstenite" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.24.0", -] - [[package]] name = "tokio-util" version = "0.7.12" @@ -8755,7 +8807,7 @@ dependencies = [ "pin-project 1.1.5", "prost", "rustls-native-certs 0.8.0", - "rustls-pemfile 2.1.3", + "rustls-pemfile 2.2.0", "socket2", "tokio", "tokio-rustls 0.26.0", @@ -8980,26 +9032,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tungstenite" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand", - "rustls 0.23.13", - "rustls-pki-types", - "sha1", - "thiserror", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.24.0" @@ -9013,6 +9045,8 @@ dependencies = [ "httparse", "log", "rand", + "rustls 0.23.13", + "rustls-pki-types", "sha1", "thiserror", "utf-8", diff --git a/Cargo.toml b/Cargo.toml index ae6ee18250fa7..bdc2c87722340 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,39 +168,39 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } foundry-compilers = { version = "0.11.3", default-features = false } -foundry-fork-db = "0.3.2" +foundry-fork-db = "0.4.0" solang-parser = "=0.3.3" ## revm revm = { version = "14.0.3", default-features = false } revm-primitives = { version = "10.0.0", default-features = false } -revm-inspectors = { version = "0.7.7", features = ["serde"] } +revm-inspectors = { version = "0.8.0", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.3.6", default-features = false } -alloy-contract = { version = "0.3.6", default-features = false } -alloy-eips = { version = "0.3.6", default-features = false } -alloy-genesis = { version = "0.3.6", default-features = false } -alloy-json-rpc = { version = "0.3.6", default-features = false } -alloy-network = { version = "0.3.6", default-features = false } -alloy-provider = { version = "0.3.6", default-features = false } -alloy-pubsub = { version = "0.3.6", default-features = false } -alloy-rpc-client = { version = "0.3.6", default-features = false } -alloy-rpc-types = { version = "0.3.6", default-features = true } -alloy-serde = { version = "0.3.6", default-features = false } -alloy-signer = { version = "0.3.6", default-features = false } -alloy-signer-aws = { version = "0.3.6", default-features = false } -alloy-signer-gcp = { version = "0.3.6", default-features = false } -alloy-signer-ledger = { version = "0.3.6", default-features = false } -alloy-signer-local = { version = "0.3.6", default-features = false } -alloy-signer-trezor = { version = "0.3.6", default-features = false } -alloy-transport = { version = "0.3.6", default-features = false } -alloy-transport-http = { version = "0.3.6", default-features = false } -alloy-transport-ipc = { version = "0.3.6", default-features = false } -alloy-transport-ws = { version = "0.3.6", default-features = false } +alloy-consensus = { version = "0.4.2", default-features = false } +alloy-contract = { version = "0.4.2", default-features = false } +alloy-eips = { version = "0.4.2", default-features = false } +alloy-genesis = { version = "0.4.2", default-features = false } +alloy-json-rpc = { version = "0.4.2", default-features = false } +alloy-network = { version = "0.4.2", default-features = false } +alloy-provider = { version = "0.4.2", default-features = false } +alloy-pubsub = { version = "0.4.2", default-features = false } +alloy-rpc-client = { version = "0.4.2", default-features = false } +alloy-rpc-types = { version = "0.4.2", default-features = true } +alloy-serde = { version = "0.4.2", default-features = false } +alloy-signer = { version = "0.4.2", default-features = false } +alloy-signer-aws = { version = "0.4.2", default-features = false } +alloy-signer-gcp = { version = "0.4.2", default-features = false } +alloy-signer-ledger = { version = "0.4.2", default-features = false } +alloy-signer-local = { version = "0.4.2", default-features = false } +alloy-signer-trezor = { version = "0.4.2", default-features = false } +alloy-transport = { version = "0.4.2", default-features = false } +alloy-transport-http = { version = "0.4.2", default-features = false } +alloy-transport-ipc = { version = "0.4.2", default-features = false } +alloy-transport-ws = { version = "0.4.2", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.5" diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 1b0895dcd5f57..337c5cfd8a57f 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -90,16 +90,16 @@ pub struct PartialHeader { pub logs_bloom: Bloom, pub difficulty: U256, pub number: u64, - pub gas_limit: u128, - pub gas_used: u128, + pub gas_limit: u64, + pub gas_used: u64, pub timestamp: u64, pub extra_data: Bytes, pub mix_hash: B256, - pub blob_gas_used: Option, - pub excess_blob_gas: Option, + pub blob_gas_used: Option, + pub excess_blob_gas: Option, pub parent_beacon_block_root: Option, pub nonce: B64, - pub base_fee: Option, + pub base_fee: Option, } impl From
for PartialHeader { @@ -150,7 +150,7 @@ mod tests { difficulty: Default::default(), number: 124u64, gas_limit: Default::default(), - gas_used: 1337u128, + gas_used: 1337u64, timestamp: 0, extra_data: Default::default(), mix_hash: Default::default(), @@ -167,7 +167,7 @@ mod tests { let decoded: Header = Header::decode(&mut encoded.as_ref()).unwrap(); assert_eq!(header, decoded); - header.base_fee_per_gas = Some(12345u128); + header.base_fee_per_gas = Some(12345u64); let encoded = alloy_rlp::encode(&header); let decoded: Header = Header::decode(&mut encoded.as_ref()).unwrap(); @@ -190,8 +190,8 @@ mod tests { logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), difficulty: U256::from(2222), number: 0xd05u64, - gas_limit: 0x115cu128, - gas_used: 0x15b3u128, + gas_limit: 0x115cu64, + gas_used: 0x15b3u64, timestamp: 0x1a0au64, extra_data: hex::decode("7788").unwrap().into(), mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), @@ -223,8 +223,8 @@ mod tests { logs_bloom: <[u8; 256]>::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap().into(), difficulty: U256::from(2222), number: 0xd05u64, - gas_limit: 0x115cu128, - gas_used: 0x15b3u128, + gas_limit: 0x115cu64, + gas_used: 0x15b3u64, timestamp: 0x1a0au64, extra_data: hex::decode("7788").unwrap().into(), mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), @@ -255,8 +255,8 @@ mod tests { logs_bloom: Bloom::from_hex("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(), difficulty: U256::from(0x020000), number: 1u64, - gas_limit: U256::from(0x016345785d8a0000u128).to::(), - gas_used: U256::from(0x015534).to::(), + gas_limit: U256::from(0x016345785d8a0000u128).to::(), + gas_used: U256::from(0x015534).to::(), timestamp: 0x079e, extra_data: hex::decode("42").unwrap().into(), mix_hash: B256::from_str("0000000000000000000000000000000000000000000000000000000000000000").unwrap(), diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index e03a862b86ab3..2ed75db28f14d 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -498,7 +498,7 @@ impl PendingTransaction { value: (*value), gas_price: U256::from(*gas_price), gas_priority_fee: None, - gas_limit: *gas_limit as u64, + gas_limit: *gas_limit, access_list: vec![], ..Default::default() } @@ -524,7 +524,7 @@ impl PendingTransaction { value: *value, gas_price: U256::from(*gas_price), gas_priority_fee: None, - gas_limit: *gas_limit as u64, + gas_limit: *gas_limit, access_list: access_list.clone().into(), ..Default::default() } @@ -551,7 +551,7 @@ impl PendingTransaction { value: *value, gas_price: U256::from(*max_fee_per_gas), gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), - gas_limit: *gas_limit as u64, + gas_limit: *gas_limit, access_list: access_list.clone().into(), ..Default::default() } @@ -582,7 +582,7 @@ impl PendingTransaction { gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), max_fee_per_blob_gas: Some(U256::from(*max_fee_per_blob_gas)), blob_hashes: blob_versioned_hashes.clone(), - gas_limit: *gas_limit as u64, + gas_limit: *gas_limit, access_list: access_list.clone().into(), ..Default::default() } @@ -609,7 +609,7 @@ impl PendingTransaction { value: *value, gas_price: U256::from(*max_fee_per_gas), gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), - gas_limit: *gas_limit as u64, + gas_limit: *gas_limit, access_list: access_list.clone().into(), authorization_list: Some(authorization_list.clone().into()), ..Default::default() @@ -637,7 +637,7 @@ impl PendingTransaction { value: *value, gas_price: U256::ZERO, gas_priority_fee: None, - gas_limit: *gas_limit as u64, + gas_limit: { *gas_limit }, access_list: vec![], optimism: OptimismFields { source_hash: Some(*source_hash), @@ -716,7 +716,7 @@ impl TypedTransaction { } } - pub fn gas_limit(&self) -> u128 { + pub fn gas_limit(&self) -> u64 { match self { Self::Legacy(tx) => tx.tx().gas_limit, Self::EIP2930(tx) => tx.tx().gas_limit, @@ -766,20 +766,23 @@ impl TypedTransaction { /// and if the transaction is EIP-4844, the result of (total blob gas cost * max fee per blob /// gas) is also added pub fn max_cost(&self) -> u128 { - let mut max_cost = self.gas_limit().saturating_mul(self.gas_price()); + let mut max_cost = (self.gas_limit() as u128).saturating_mul(self.gas_price()); if self.is_eip4844() { max_cost = max_cost.saturating_add( - self.blob_gas().unwrap_or(0).mul(self.max_fee_per_blob_gas().unwrap_or(0)), + self.blob_gas() + .map(|g| g as u128) + .unwrap_or(0) + .mul(self.max_fee_per_blob_gas().unwrap_or(0)), ) } max_cost } - pub fn blob_gas(&self) -> Option { + pub fn blob_gas(&self) -> Option { match self { - Self::EIP4844(tx) => Some(tx.tx().tx().blob_gas() as u128), + Self::EIP4844(tx) => Some(tx.tx().tx().blob_gas()), _ => None, } } @@ -1256,7 +1259,7 @@ pub struct TransactionEssentials { pub kind: TxKind, pub input: Bytes, pub nonce: u64, - pub gas_limit: u128, + pub gas_limit: u64, pub gas_price: Option, pub max_fee_per_gas: Option, pub max_priority_fee_per_gas: Option, @@ -1279,7 +1282,7 @@ pub struct TransactionInfo { pub exit: InstructionResult, pub out: Option, pub nonce: u64, - pub gas_used: u128, + pub gas_used: u64, } #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] @@ -1287,9 +1290,9 @@ pub struct TransactionInfo { pub struct DepositReceipt { #[serde(flatten)] pub inner: ReceiptWithBloom, - #[serde(default, with = "alloy_serde::num::u64_opt_via_ruint")] + #[serde(default, with = "alloy_serde::quantity::opt")] pub deposit_nonce: Option, - #[serde(default, with = "alloy_serde::num::u64_opt_via_ruint")] + #[serde(default, with = "alloy_serde::quantity::opt")] pub deposit_receipt_version: Option, } @@ -1690,7 +1693,7 @@ mod tests { let tx = TxLegacy { nonce: 2u64, gas_price: 1000000000u128, - gas_limit: 100000u128, + gas_limit: 100000, to: TxKind::Call(Address::from_slice( &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap()[..], )), diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 6cc7bfa5aa63c..170d67f1d9ac1 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -16,7 +16,7 @@ pub struct DepositTransactionRequest { pub kind: TxKind, pub mint: U256, pub value: U256, - pub gas_limit: u128, + pub gas_limit: u64, pub is_system_tx: bool, pub input: Bytes, } @@ -178,7 +178,7 @@ impl Transaction for DepositTransactionRequest { } /// Get `gas_limit`. - fn gas_limit(&self) -> u128 { + fn gas_limit(&self) -> u64 { self.gas_limit } @@ -281,7 +281,7 @@ pub struct DepositTransaction { pub kind: TxKind, pub mint: U256, pub value: U256, - pub gas_limit: u128, + pub gas_limit: u64, pub is_system_tx: bool, pub input: Bytes, } diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 3b7778a722468..149b9c8630659 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -545,7 +545,7 @@ pub struct AnvilEvmArgs { value_name = "FEE", help_heading = "Environment config" )] - pub block_base_fee_per_gas: Option, + pub block_base_fee_per_gas: Option, /// The chain ID. #[arg(long, alias = "chain", help_heading = "Environment config")] diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index f3dbf21f6013c..189cf51752d1b 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -98,7 +98,7 @@ pub struct NodeConfig { /// Default gas price for all txs pub gas_price: Option, /// Default base fee - pub base_fee: Option, + pub base_fee: Option, /// Default blob excess gas and price pub blob_excess_gas_and_price: Option, /// The hardfork to use @@ -474,9 +474,9 @@ impl NodeConfig { self } /// Returns the base fee to use - pub fn get_base_fee(&self) -> u128 { + pub fn get_base_fee(&self) -> u64 { self.base_fee - .or_else(|| self.genesis.as_ref().and_then(|g| g.base_fee_per_gas)) + .or_else(|| self.genesis.as_ref().and_then(|g| g.base_fee_per_gas.map(|g| g as u64))) .unwrap_or(INITIAL_BASE_FEE) } @@ -618,7 +618,7 @@ impl NodeConfig { /// Sets the base fee #[must_use] - pub fn with_base_fee(mut self, base_fee: Option) -> Self { + pub fn with_base_fee(mut self, base_fee: Option) -> Self { self.base_fee = base_fee; self } @@ -1183,7 +1183,7 @@ latest block number: {latest_block}" // this is the base fee of the current block, but we need the base fee of // the next block let next_block_base_fee = fees.get_next_block_base_fee_per_gas( - block.header.gas_used, + block.header.gas_used as u128, gas_limit, block.header.base_fee_per_gas.unwrap_or_default(), ); @@ -1195,9 +1195,9 @@ latest block number: {latest_block}" (block.header.excess_blob_gas, block.header.blob_gas_used) { env.block.blob_excess_gas_and_price = - Some(BlobExcessGasAndPrice::new(blob_excess_gas as u64)); - let next_block_blob_excess_gas = - fees.get_next_block_blob_excess_gas(blob_excess_gas, blob_gas_used); + Some(BlobExcessGasAndPrice::new(blob_excess_gas)); + let next_block_blob_excess_gas = fees + .get_next_block_blob_excess_gas(blob_excess_gas as u128, blob_gas_used as u128); fees.set_blob_excess_gas_and_price(BlobExcessGasAndPrice::new( next_block_blob_excess_gas, )); @@ -1257,13 +1257,13 @@ latest block number: {latest_block}" chain_id, override_chain_id, timestamp: block.header.timestamp, - base_fee: block.header.base_fee_per_gas, + base_fee: block.header.base_fee_per_gas.map(|g| g as u128), timeout: self.fork_request_timeout, retries: self.fork_request_retries, backoff: self.fork_retry_backoff, compute_units_per_second: self.compute_units_per_second, total_difficulty: block.header.total_difficulty.unwrap_or_default(), - blob_gas_used: block.header.blob_gas_used, + blob_gas_used: block.header.blob_gas_used.map(|g| g as u128), blob_excess_gas_and_price: env.block.blob_excess_gas_and_price.clone(), force_transactions, }; @@ -1284,7 +1284,7 @@ latest block number: {latest_block}" if let Some(gas_limit) = self.gas_limit { return gas_limit; } else if block.header.gas_limit > 0 { - return block.header.gas_limit; + return block.header.gas_limit as u128; } } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 85d1aceaf5318..c8fd497a3e815 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -592,7 +592,7 @@ impl EthApi { /// Returns the current gas price pub fn gas_price(&self) -> u128 { if self.backend.is_eip1559() { - self.backend.base_fee().saturating_add(self.lowest_suggestion_tip()) + (self.backend.base_fee() as u128).saturating_add(self.lowest_suggestion_tip()) } else { self.backend.fees().raw_gas_price() } @@ -1405,7 +1405,7 @@ impl EthApi { // The spec states that `base_fee_per_gas` "[..] includes the next block after the // newest of the returned range, because this value can be derived from the // newest block" - response.base_fee_per_gas.push(self.backend.fees().base_fee()); + response.base_fee_per_gas.push(self.backend.fees().base_fee() as u128); // Same goes for the `base_fee_per_blob_gas`: // > [..] includes the next block after the newest of the returned range, because this @@ -2302,7 +2302,7 @@ impl EthApi { let to = tx.to(); let gas_price = tx.gas_price(); let value = tx.value(); - let gas = tx.gas_limit(); + let gas = tx.gas_limit() as u128; TxpoolInspectSummary { to, value, gas, gas_price } } @@ -2485,7 +2485,8 @@ impl EthApi { // get the highest possible gas limit, either the request's set value or the currently // configured gas limit - let mut highest_gas_limit = request.gas.unwrap_or(block_env.gas_limit.to()); + let mut highest_gas_limit = + request.gas.map_or(block_env.gas_limit.to::(), |g| g as u128); let gas_price = fees.gas_price.unwrap_or_default(); // If we have non-zero gas price, cap gas limit by sender balance @@ -2507,7 +2508,7 @@ impl EthApi { } let mut call_to_estimate = request.clone(); - call_to_estimate.gas = Some(highest_gas_limit); + call_to_estimate.gas = Some(highest_gas_limit as u64); // execute the call without writing to db let ethres = @@ -2541,7 +2542,7 @@ impl EthApi { // Binary search for the ideal gas limit while (highest_gas_limit - lowest_gas_limit) > 1 { - request.gas = Some(mid_gas_limit); + request.gas = Some(mid_gas_limit as u64); let ethres = self.backend.call_with_state( &state, request.clone(), @@ -2688,7 +2689,7 @@ impl EthApi { let max_fee_per_blob_gas = request.max_fee_per_blob_gas; let gas_price = request.gas_price; - let gas_limit = request.gas.unwrap_or(self.backend.gas_limit()); + let gas_limit = request.gas.unwrap_or(self.backend.gas_limit() as u64); let request = match transaction_request_to_typed(request) { Some(TypedTransactionRequest::Legacy(mut m)) => { diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index caa042bf48861..d92d60a874405 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -38,7 +38,7 @@ pub struct ExecutedTransaction { transaction: Arc, exit_reason: InstructionResult, out: Option, - gas_used: u128, + gas_used: u64, logs: Vec, traces: Vec, nonce: u64, @@ -48,7 +48,7 @@ pub struct ExecutedTransaction { impl ExecutedTransaction { /// Creates the receipt for the transaction - fn create_receipt(&self, cumulative_gas_used: &mut u128) -> TypedReceipt { + fn create_receipt(&self, cumulative_gas_used: &mut u64) -> TypedReceipt { let logs = self.logs.clone(); *cumulative_gas_used = cumulative_gas_used.saturating_add(self.gas_used); @@ -56,7 +56,7 @@ impl ExecutedTransaction { let status_code = u8::from(self.exit_reason as u8 <= InstructionResult::SelfDestruct as u8); let receipt_with_bloom: ReceiptWithBloom = Receipt { status: (status_code == 1).into(), - cumulative_gas_used: *cumulative_gas_used, + cumulative_gas_used: *cumulative_gas_used as u128, logs, } .into(); @@ -101,9 +101,9 @@ pub struct TransactionExecutor<'a, Db: ?Sized, V: TransactionValidator> { pub cfg_env: CfgEnvWithHandlerCfg, pub parent_hash: B256, /// Cumulative gas used by all executed transactions - pub gas_used: u128, + pub gas_used: u64, /// Cumulative blob gas used by all executed transactions - pub blob_gas_used: u128, + pub blob_gas_used: u64, pub enable_steps_tracing: bool, pub alphanet: bool, pub print_logs: bool, @@ -118,24 +118,24 @@ impl<'a, DB: Db + ?Sized, V: TransactionValidator> TransactionExecutor<'a, DB, V let mut transaction_infos = Vec::new(); let mut receipts = Vec::new(); let mut bloom = Bloom::default(); - let mut cumulative_gas_used: u128 = 0; + let mut cumulative_gas_used = 0u64; let mut invalid = Vec::new(); let mut included = Vec::new(); - let gas_limit = self.block_env.gas_limit.to::(); + let gas_limit = self.block_env.gas_limit.to::(); let parent_hash = self.parent_hash; let block_number = self.block_env.number.to::(); let difficulty = self.block_env.difficulty; let beneficiary = self.block_env.coinbase; let timestamp = self.block_env.timestamp.to::(); let base_fee = if self.cfg_env.handler_cfg.spec_id.is_enabled_in(SpecId::LONDON) { - Some(self.block_env.basefee.to::()) + Some(self.block_env.basefee.to::()) } else { None }; let is_cancun = self.cfg_env.handler_cfg.spec_id >= SpecId::CANCUN; let excess_blob_gas = if is_cancun { self.block_env.get_blob_excess_gas() } else { None }; - let mut cumulative_blob_gas_used = if is_cancun { Some(0u128) } else { None }; + let mut cumulative_blob_gas_used = if is_cancun { Some(0u64) } else { None }; for tx in self.into_iter() { let tx = match tx { @@ -172,7 +172,7 @@ impl<'a, DB: Db + ?Sized, V: TransactionValidator> TransactionExecutor<'a, DB, V .blob_gas() .unwrap_or(0); cumulative_blob_gas_used = - Some(cumulative_blob_gas_used.unwrap_or(0u128).saturating_add(tx_blob_gas)); + Some(cumulative_blob_gas_used.unwrap_or(0u64).saturating_add(tx_blob_gas)); } let receipt = tx.create_receipt(&mut cumulative_gas_used); @@ -228,7 +228,7 @@ impl<'a, DB: Db + ?Sized, V: TransactionValidator> TransactionExecutor<'a, DB, V base_fee, parent_beacon_block_root: Default::default(), blob_gas_used: cumulative_blob_gas_used, - excess_blob_gas: excess_blob_gas.map(|g| g as u128), + excess_blob_gas, }; let block = Block::new(partial_header, transactions.clone(), ommers); @@ -277,16 +277,16 @@ impl<'a, 'b, DB: Db + ?Sized, V: TransactionValidator> Iterator let env = self.env_for(&transaction.pending_transaction); // check that we comply with the block's gas limit, if not disabled - let max_gas = self.gas_used.saturating_add(env.tx.gas_limit as u128); - if !env.cfg.disable_block_gas_limit && max_gas > env.block.gas_limit.to::() { + let max_gas = self.gas_used.saturating_add(env.tx.gas_limit); + if !env.cfg.disable_block_gas_limit && max_gas > env.block.gas_limit.to::() { return Some(TransactionExecutionOutcome::Exhausted(transaction)) } // check that we comply with the block's blob gas limit let max_blob_gas = self.blob_gas_used.saturating_add( - transaction.pending_transaction.transaction.transaction.blob_gas().unwrap_or(0u128), + transaction.pending_transaction.transaction.transaction.blob_gas().unwrap_or(0), ); - if max_blob_gas > MAX_BLOB_GAS_PER_BLOCK as u128 { + if max_blob_gas > MAX_BLOB_GAS_PER_BLOCK { return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction)) } @@ -364,7 +364,7 @@ impl<'a, 'b, DB: Db + ?Sized, V: TransactionValidator> Iterator trace!(target: "backend", ?exit_reason, ?gas_used, "[{:?}] executed with out={:?}", transaction.hash(), out); // Track the total gas used for total gas per block checks - self.gas_used = self.gas_used.saturating_add(gas_used as u128); + self.gas_used = self.gas_used.saturating_add(gas_used); // Track the total blob gas used for total blob gas per blob checks if let Some(blob_gas) = transaction.pending_transaction.transaction.transaction.blob_gas() { @@ -377,7 +377,7 @@ impl<'a, 'b, DB: Db + ?Sized, V: TransactionValidator> Iterator transaction, exit_reason, out, - gas_used: gas_used as u128, + gas_used, logs: logs.unwrap_or_default(), traces: inspector.tracer.map(|t| t.into_traces().into_nodes()).unwrap_or_default(), nonce, diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index ea41b85a954c4..7d887f697572b 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -92,7 +92,13 @@ impl ClientFork { let total_difficulty = block.header.total_difficulty.unwrap_or_default(); let number = block.header.number; - self.config.write().update_block(number, block_hash, timestamp, base_fee, total_difficulty); + self.config.write().update_block( + number, + block_hash, + timestamp, + base_fee.map(|g| g as u128), + total_difficulty, + ); self.clear_cached_storage(); @@ -202,7 +208,7 @@ impl ClientFork { let block = block.unwrap_or_default(); let res = self.provider().estimate_gas(request).block(block.into()).await?; - Ok(res) + Ok(res as u128) } /// Sends `eth_createAccessList` diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 83d8c1871fbf3..ea36696f27487 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -460,7 +460,7 @@ impl Backend { // this is the base fee of the current block, but we need the base fee of // the next block let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( - fork_block.header.gas_used, + fork_block.header.gas_used as u128, gas_limit, fork_block.header.base_fee_per_gas.unwrap_or_default(), ); @@ -665,7 +665,7 @@ impl Backend { } /// Returns the current base fee - pub fn base_fee(&self) -> u128 { + pub fn base_fee(&self) -> u64 { self.fees.base_fee() } @@ -674,7 +674,7 @@ impl Backend { } /// Sets the current basefee - pub fn set_base_fee(&self, basefee: u128) { + pub fn set_base_fee(&self, basefee: u64) { self.fees.set_base_fee(basefee) } @@ -1121,13 +1121,13 @@ impl Backend { (outcome, header, block_hash) }; let next_block_base_fee = self.fees.get_next_block_base_fee_per_gas( - header.gas_used, - header.gas_limit, + header.gas_used as u128, + header.gas_limit as u128, header.base_fee_per_gas.unwrap_or_default(), ); let next_block_excess_blob_gas = self.fees.get_next_block_blob_excess_gas( - header.excess_blob_gas.unwrap_or_default(), - header.blob_gas_used.unwrap_or_default(), + header.excess_blob_gas.map(|g| g as u128).unwrap_or_default(), + header.blob_gas_used.map(|g| g as u128).unwrap_or_default(), ); // update next base fee @@ -1231,7 +1231,7 @@ impl Backend { env.tx = TxEnv { caller, - gas_limit: gas_limit as u64, + gas_limit, gas_price: U256::from(gas_price), gas_priority_fee: max_priority_fee_per_gas.map(U256::from), max_fee_per_blob_gas: max_fee_per_blob_gas @@ -2230,7 +2230,7 @@ impl Backend { // Cancun specific let excess_blob_gas = block.header.excess_blob_gas; - let blob_gas_price = calc_blob_gasprice(excess_blob_gas.map_or(0, |g| g as u64)); + let blob_gas_price = calc_blob_gasprice(excess_blob_gas.unwrap_or_default()); let blob_gas_used = transaction.blob_gas(); let effective_gas_price = match transaction.transaction { @@ -2239,17 +2239,17 @@ impl Backend { TypedTransaction::EIP1559(t) => block .header .base_fee_per_gas - .unwrap_or_else(|| self.base_fee()) + .map_or(self.base_fee() as u128, |g| g as u128) .saturating_add(t.tx().max_priority_fee_per_gas), TypedTransaction::EIP4844(t) => block .header .base_fee_per_gas - .unwrap_or_else(|| self.base_fee()) + .map_or(self.base_fee() as u128, |g| g as u128) .saturating_add(t.tx().tx().max_priority_fee_per_gas), TypedTransaction::EIP7702(t) => block .header .base_fee_per_gas - .unwrap_or_else(|| self.base_fee()) + .map_or(self.base_fee() as u128, |g| g as u128) .saturating_add(t.tx().max_priority_fee_per_gas), TypedTransaction::Deposit(_) => 0_u128, }; @@ -2298,7 +2298,7 @@ impl Backend { transaction_hash: info.transaction_hash, transaction_index: Some(info.transaction_index), block_number: Some(block.header.number), - gas_used: info.gas_used, + gas_used: info.gas_used as u128, contract_address: info.contract_address, effective_gas_price, block_hash: Some(block_hash), @@ -2306,7 +2306,7 @@ impl Backend { to: info.to, state_root: Some(block.header.state_root), blob_gas_price: Some(blob_gas_price), - blob_gas_used, + blob_gas_used: blob_gas_used.map(|g| g as u128), authorization_list: None, }; @@ -2634,7 +2634,7 @@ impl TransactionValidator for Backend { } } - if tx.gas_limit() < MIN_TRANSACTION_GAS { + if tx.gas_limit() < MIN_TRANSACTION_GAS as u64 { warn!(target: "backend", "[{:?}] gas too low", tx.hash()); return Err(InvalidTransactionError::GasTooLow); } @@ -2760,7 +2760,7 @@ pub fn transaction_build( eth_transaction: MaybeImpersonatedTransaction, block: Option<&Block>, info: Option, - base_fee: Option, + base_fee: Option, ) -> WithOtherFields { let mut transaction: Transaction = eth_transaction.clone().into(); if info.is_some() && transaction.transaction_type == Some(0x7E) { @@ -2774,7 +2774,7 @@ pub fn transaction_build( } else { // if transaction is already mined, gas price is considered base fee + priority fee: the // effective gas price. - let base_fee = base_fee.unwrap_or(0u128); + let base_fee = base_fee.map_or(0u128, |g| g as u128); let max_priority_fee_per_gas = transaction.max_priority_fee_per_gas.unwrap_or(0); transaction.gas_price = Some(base_fee.saturating_add(max_priority_fee_per_gas)); } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index abc520c3b0141..29ae472071e7a 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -262,16 +262,16 @@ pub struct BlockchainStorage { impl BlockchainStorage { /// Creates a new storage with a genesis block - pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { + pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { // create a dummy genesis block let partial_header = PartialHeader { timestamp, base_fee, - gas_limit: env.block.gas_limit.to::(), + gas_limit: env.block.gas_limit.to::(), beneficiary: env.block.coinbase, difficulty: env.block.difficulty, blob_gas_used: env.block.blob_excess_gas_and_price.as_ref().map(|_| 0), - excess_blob_gas: env.block.get_blob_excess_gas().map(|v| v as u128), + excess_blob_gas: env.block.get_blob_excess_gas(), ..Default::default() }; let block = Block::new::(partial_header, vec![], vec![]); @@ -423,7 +423,7 @@ pub struct Blockchain { impl Blockchain { /// Creates a new storage with a genesis block - pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { + pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { Self { storage: Arc::new(RwLock::new(BlockchainStorage::new(env, base_fee, timestamp))) } } @@ -711,7 +711,7 @@ mod tests { load_storage.load_transactions(serialized_transactions); let loaded_block = load_storage.blocks.get(&block_hash).unwrap(); - assert_eq!(loaded_block.header.gas_limit, partial_header.gas_limit); + assert_eq!(loaded_block.header.gas_limit, { partial_header.gas_limit }); let loaded_tx = loaded_block.transactions.first().unwrap(); assert_eq!(loaded_tx, &tx); } diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index ada9e6c532334..31d0521bb8543 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -388,7 +388,7 @@ impl ToRpcResponseResult for Result { match err { TransportError::ErrorResp(err) => RpcError { code: ErrorCode::from(err.code), - message: err.message.into(), + message: err.message, data: err.data.and_then(|data| serde_json::to_value(data).ok()), }, err => RpcError::internal_error_with(format!("Fork Error: {err:?}")), diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index cb1b8508fd24b..72d66b1130558 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -24,7 +24,7 @@ use std::{ pub const MAX_FEE_HISTORY_CACHE_SIZE: u64 = 2048u64; /// Initial base fee for EIP-1559 blocks. -pub const INITIAL_BASE_FEE: u128 = 1_000_000_000; +pub const INITIAL_BASE_FEE: u64 = 1_000_000_000; /// Initial default gas price for the first block pub const INITIAL_GAS_PRICE: u128 = 1_875_000_000; @@ -47,7 +47,7 @@ pub struct FeeManager { /// Tracks the base fee for the next block post London /// /// This value will be updated after a new block was mined - base_fee: Arc>, + base_fee: Arc>, /// Tracks the excess blob gas, and the base fee, for the next block post Cancun /// /// This value will be updated after a new block was mined @@ -62,7 +62,7 @@ pub struct FeeManager { impl FeeManager { pub fn new( spec_id: SpecId, - base_fee: u128, + base_fee: u64, gas_price: u128, blob_excess_gas_and_price: BlobExcessGasAndPrice, ) -> Self { @@ -97,7 +97,7 @@ impl FeeManager { } } - pub fn base_fee(&self) -> u128 { + pub fn base_fee(&self) -> u64 { if self.is_eip1559() { *self.base_fee.read() } else { @@ -133,7 +133,7 @@ impl FeeManager { } /// Returns the current base fee - pub fn set_base_fee(&self, fee: u128) { + pub fn set_base_fee(&self, fee: u64) { trace!(target: "backend::fees", "updated base fee {:?}", fee); let mut base = self.base_fee.write(); *base = fee; @@ -151,8 +151,8 @@ impl FeeManager { &self, gas_used: u128, gas_limit: u128, - last_fee_per_gas: u128, - ) -> u128 { + last_fee_per_gas: u64, + ) -> u64 { // It's naturally impossible for base fee to be 0; // It means it was set by the user deliberately and therefore we treat it as a constant. // Therefore, we skip the base fee calculation altogether and we return 0. @@ -179,8 +179,8 @@ impl FeeManager { } /// Calculate base fee for next block. [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) spec -pub fn calculate_next_block_base_fee(gas_used: u128, gas_limit: u128, base_fee: u128) -> u128 { - calc_next_block_base_fee(gas_used, gas_limit, base_fee, BaseFeeParams::ethereum()) +pub fn calculate_next_block_base_fee(gas_used: u128, gas_limit: u128, base_fee: u64) -> u64 { + calc_next_block_base_fee(gas_used as u64, gas_limit as u64, base_fee, BaseFeeParams::ethereum()) } /// An async service that takes care of the `FeeHistory` cache @@ -235,9 +235,9 @@ impl FeeHistoryService { }; let mut block_number: Option = None; - let base_fee = header.base_fee_per_gas.unwrap_or_default(); - let excess_blob_gas = header.excess_blob_gas; - let blob_gas_used = header.blob_gas_used; + let base_fee = header.base_fee_per_gas.map(|g| g as u128).unwrap_or_default(); + let excess_blob_gas = header.excess_blob_gas.map(|g| g as u128); + let blob_gas_used = header.blob_gas_used.map(|g| g as u128); let base_fee_per_blob_gas = header.blob_fee(); let mut item = FeeHistoryCacheItem { base_fee, diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 31e37c98b7810..74728f94b5931 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -48,7 +48,7 @@ async fn can_set_block_gas_limit() { // Mine a new block, and check the new block gas limit api.mine_one().await; let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert_eq!(block_gas_limit.to::(), latest_block.header.gas_limit); + assert_eq!(block_gas_limit.to::(), latest_block.header.gas_limit); } // Ref @@ -557,7 +557,7 @@ async fn test_get_transaction_receipt() { // the block should have the new base fee let block = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); - assert_eq!(block.header.base_fee_per_gas.unwrap(), new_base_fee.to::()); + assert_eq!(block.header.base_fee_per_gas.unwrap(), new_base_fee.to::()); // mine blocks api.evm_mine(None).await.unwrap(); diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index f9aaf0dbab029..c4172b265be19 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -5,7 +5,10 @@ use crate::{ utils::{connect_pubsub_with_wallet, http_provider_with_signer}, }; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{Address, ChainId, B256, U256}; +use alloy_primitives::{ + map::{AddressHashMap, B256HashMap, HashMap}, + Address, ChainId, B256, U256, +}; use alloy_provider::Provider; use alloy_rpc_types::{ request::TransactionRequest, state::AccountOverride, BlockId, BlockNumberOrTag, @@ -14,7 +17,7 @@ use alloy_rpc_types::{ use alloy_serde::WithOtherFields; use anvil::{eth::api::CLIENT_VERSION, spawn, NodeConfig, CHAIN_ID}; use futures::join; -use std::{collections::HashMap, time::Duration}; +use std::time::Duration; #[tokio::test(flavor = "multi_thread")] async fn can_get_block_number() { @@ -174,7 +177,7 @@ async fn can_estimate_gas_with_undersized_max_fee_per_gas() { let simple_storage_contract = SimpleStorage::deploy(&provider, init_value.clone()).await.unwrap(); - let undersized_max_fee_per_gas = 1_u128; + let undersized_max_fee_per_gas = 1; let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); let latest_block_base_fee_per_gas = latest_block.header.base_fee_per_gas.unwrap(); @@ -183,7 +186,7 @@ async fn can_estimate_gas_with_undersized_max_fee_per_gas() { let estimated_gas = simple_storage_contract .setValue("new_value".to_string()) - .max_fee_per_gas(undersized_max_fee_per_gas) + .max_fee_per_gas(undersized_max_fee_per_gas.into()) .from(wallet.address()) .estimate_gas() .await @@ -255,7 +258,7 @@ async fn can_call_on_pending_block() { .call() .await .unwrap(); - assert_eq!(block.header.gas_limit, ret_gas_limit.to::()); + assert_eq!(block.header.gas_limit, ret_gas_limit.to::()); let Multicall::getCurrentBlockCoinbaseReturn { coinbase: ret_coinbase, .. } = contract .getCurrentBlockCoinbase() @@ -284,13 +287,13 @@ async fn can_call_with_undersized_max_fee_per_gas() { let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); let latest_block_base_fee_per_gas = latest_block.header.base_fee_per_gas.unwrap(); - let undersized_max_fee_per_gas = 1_u128; + let undersized_max_fee_per_gas = 1; assert!(undersized_max_fee_per_gas < latest_block_base_fee_per_gas); let last_sender = simple_storage_contract .lastSender() - .max_fee_per_gas(undersized_max_fee_per_gas) + .max_fee_per_gas(undersized_max_fee_per_gas.into()) .from(wallet.address()) .call() .await @@ -319,23 +322,24 @@ async fn can_call_with_state_override() { // Test the `balance` account override let balance = U256::from(42u64); - let overrides = HashMap::from([( - account, - AccountOverride { balance: Some(balance), ..Default::default() }, - )]); + let mut overrides = AddressHashMap::default(); + overrides.insert(account, AccountOverride { balance: Some(balance), ..Default::default() }); let result = multicall_contract.getEthBalance(account).state(overrides).call().await.unwrap().balance; assert_eq!(result, balance); // Test the `state_diff` account override - let overrides = HashMap::from([( + let mut state_diff = B256HashMap::default(); + state_diff.insert(B256::ZERO, account.into_word()); + let mut overrides = AddressHashMap::default(); + overrides.insert( *simple_storage_contract.address(), AccountOverride { // The `lastSender` is in the first storage slot - state_diff: Some(HashMap::from([(B256::ZERO, account.into_word())])), + state_diff: Some(state_diff), ..Default::default() }, - )]); + ); let last_sender = simple_storage_contract.lastSender().state(HashMap::default()).call().await.unwrap()._0; @@ -352,14 +356,17 @@ async fn can_call_with_state_override() { assert_eq!(value, init_value); // Test the `state` account override - let overrides = HashMap::from([( + let mut state = B256HashMap::default(); + state.insert(B256::ZERO, account.into_word()); + let mut overrides = AddressHashMap::default(); + overrides.insert( *simple_storage_contract.address(), AccountOverride { // The `lastSender` is in the first storage slot - state: Some(HashMap::from([(B256::ZERO, account.into_word())])), + state: Some(state), ..Default::default() }, - )]); + ); let last_sender = simple_storage_contract.lastSender().state(overrides.clone()).call().await.unwrap()._0; diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 71a8bfd84c06e..a4243ce15f493 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -138,7 +138,7 @@ async fn can_mine_blobs_when_exceeds_max_blobs() { let first_batch = vec![1u8; DATA_GAS_PER_BLOB as usize * 3]; let sidecar: SidecarBuilder = SidecarBuilder::from_slice(&first_batch); - let num_blobs_first = sidecar.clone().take().len(); + let num_blobs_first = sidecar.clone().take().len() as u64; let sidecar = sidecar.build().unwrap(); @@ -160,7 +160,7 @@ async fn can_mine_blobs_when_exceeds_max_blobs() { let sidecar: SidecarBuilder = SidecarBuilder::from_slice(&second_batch); - let num_blobs_second = sidecar.clone().take().len(); + let num_blobs_second = sidecar.clone().take().len() as u64; let sidecar = sidecar.build().unwrap(); tx.set_blob_sidecar(sidecar); @@ -181,12 +181,12 @@ async fn can_mine_blobs_when_exceeds_max_blobs() { ); assert_eq!( first_block.unwrap().unwrap().header.blob_gas_used, - Some(DATA_GAS_PER_BLOB as u128 * num_blobs_first as u128) + Some(DATA_GAS_PER_BLOB * num_blobs_first) ); assert_eq!( second_block.unwrap().unwrap().header.blob_gas_used, - Some(DATA_GAS_PER_BLOB as u128 * num_blobs_second as u128) + Some(DATA_GAS_PER_BLOB * num_blobs_second) ); // Mined in two different blocks assert_eq!(first_receipt.block_number.unwrap() + 1, second_receipt.block_number.unwrap()); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index f93fa92a19f96..e6db8a0635bbc 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -781,7 +781,7 @@ async fn test_fork_can_send_opensea_tx() { .value(U256::from(20000000000000000u64)) .with_input(input) .with_gas_price(22180711707u128) - .with_gas_limit(150_000u128); + .with_gas_limit(150_000); let tx = WithOtherFields::new(tx); let tx = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); @@ -817,7 +817,7 @@ async fn test_fork_init_base_fee() { // assert_eq!(block.header.number, 13184859u64); let init_base_fee = block.header.base_fee_per_gas.unwrap(); - assert_eq!(init_base_fee, 63739886069u128); + assert_eq!(init_base_fee, 63739886069); api.mine_one().await; @@ -1185,7 +1185,7 @@ async fn test_fork_reset_basefee() { let latest = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); // basefee of +1 block: - assert_eq!(latest.header.base_fee_per_gas.unwrap(), 59455969592u128); + assert_eq!(latest.header.base_fee_per_gas.unwrap(), 59455969592u64); // now reset to block 18835000 -1 api.anvil_reset(Some(Forking { json_rpc_url: None, block_number: Some(18835000u64 - 1) })) @@ -1196,7 +1196,7 @@ async fn test_fork_reset_basefee() { let latest = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); // basefee of the forked block: - assert_eq!(latest.header.base_fee_per_gas.unwrap(), 59017001138u128); + assert_eq!(latest.header.base_fee_per_gas.unwrap(), 59017001138); } // @@ -1288,7 +1288,7 @@ async fn test_base_fork_gas_limit() { .unwrap(); assert!(api.gas_limit() >= uint!(132_000_000_U256)); - assert!(block.header.gas_limit >= 132_000_000_u128); + assert!(block.header.gas_limit >= 132_000_000_u64); } // @@ -1443,7 +1443,7 @@ async fn test_reset_dev_account_nonce() { .from(address) .to(address) .nonce(nonce_after) - .gas_limit(21000u128), + .gas_limit(21000), )) .await .unwrap() diff --git a/crates/anvil/tests/it/gas.rs b/crates/anvil/tests/it/gas.rs index e80a52462875b..55f8321997239 100644 --- a/crates/anvil/tests/it/gas.rs +++ b/crates/anvil/tests/it/gas.rs @@ -102,7 +102,7 @@ async fn test_basefee_half_block() { .unwrap(); // unchanged, half block - assert_eq!(next_base_fee, INITIAL_BASE_FEE); + assert_eq!(next_base_fee, { INITIAL_BASE_FEE }); } #[tokio::test(flavor = "multi_thread")] @@ -147,7 +147,7 @@ async fn test_basefee_empty_block() { #[tokio::test(flavor = "multi_thread")] async fn test_respect_base_fee() { let base_fee = 50u128; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee as u64))).await; let provider = handle.http_provider(); @@ -168,7 +168,7 @@ async fn test_respect_base_fee() { #[tokio::test(flavor = "multi_thread")] async fn test_tip_above_fee_cap() { let base_fee = 50u128; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee as u64))).await; let provider = handle.http_provider(); @@ -190,17 +190,17 @@ async fn test_tip_above_fee_cap() { #[tokio::test(flavor = "multi_thread")] async fn test_can_use_fee_history() { let base_fee = 50u128; - let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee))).await; + let (_api, handle) = spawn(NodeConfig::test().with_base_fee(Some(base_fee as u64))).await; let provider = handle.http_provider(); for _ in 0..10 { let fee_history = provider.get_fee_history(1, Default::default(), &[]).await.unwrap(); - let next_base_fee = fee_history.base_fee_per_gas.last().unwrap(); + let next_base_fee = *fee_history.base_fee_per_gas.last().unwrap(); let tx = TransactionRequest::default() .with_to(Address::random()) .with_value(U256::from(100)) - .with_gas_price(*next_base_fee); + .with_gas_price(next_base_fee); let tx = WithOtherFields::new(tx); let receipt = @@ -208,11 +208,11 @@ async fn test_can_use_fee_history() { assert!(receipt.inner.inner.is_success()); let fee_history_after = provider.get_fee_history(1, Default::default(), &[]).await.unwrap(); - let latest_fee_history_fee = fee_history_after.base_fee_per_gas.first().unwrap(); + let latest_fee_history_fee = *fee_history_after.base_fee_per_gas.first().unwrap() as u64; let latest_block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); - assert_eq!(latest_block.header.base_fee_per_gas.unwrap(), *latest_fee_history_fee); - assert_eq!(latest_fee_history_fee, next_base_fee); + assert_eq!(latest_block.header.base_fee_per_gas.unwrap(), latest_fee_history_fee); + assert_eq!(latest_fee_history_fee, next_base_fee as u64); } } diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 6446caf9ce682..8de4eab1d1f4f 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -25,19 +25,21 @@ async fn test_deposits_not_supported_if_optimism_disabled() { .with_to(to) .with_value(U256::from(1234)) .with_gas_limit(21000); - let tx = WithOtherFields { - inner: tx, - other: OptimismTransactionFields { - source_hash: Some(b256!( - "0000000000000000000000000000000000000000000000000000000000000000" - )), - mint: Some(0), - is_system_tx: Some(true), - deposit_receipt_version: None, - } - .into(), + + let op_fields = OptimismTransactionFields { + source_hash: Some(b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )), + mint: Some(0), + is_system_tx: Some(true), + deposit_receipt_version: None, }; + // TODO: Test this + let other = serde_json::to_value(op_fields).unwrap().try_into().unwrap(); + + let tx = WithOtherFields { inner: tx, other }; + let err = provider.send_transaction(tx).await.unwrap_err(); let s = err.to_string(); assert!(s.contains("op-stack deposit tx received but is not supported"), "{s:?}"); @@ -61,23 +63,22 @@ async fn test_send_value_deposit_transaction() { let send_value = U256::from(1234); let before_balance_to = provider.get_balance(to).await.unwrap(); + let op_fields = OptimismTransactionFields { + source_hash: Some(b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )), + mint: Some(0), + is_system_tx: Some(true), + deposit_receipt_version: None, + }; + + let other = serde_json::to_value(op_fields).unwrap().try_into().unwrap(); let tx = TransactionRequest::default() .with_from(from) .with_to(to) .with_value(send_value) .with_gas_limit(21000); - let tx: WithOtherFields = WithOtherFields { - inner: tx, - other: OptimismTransactionFields { - source_hash: Some(b256!( - "0000000000000000000000000000000000000000000000000000000000000000" - )), - mint: Some(0), - is_system_tx: Some(true), - deposit_receipt_version: None, - } - .into(), - }; + let tx: WithOtherFields = WithOtherFields { inner: tx, other }; let pending = provider.send_transaction(tx).await.unwrap().register().await.unwrap(); @@ -121,18 +122,17 @@ async fn test_send_value_raw_deposit_transaction() { .with_gas_limit(21_000) .with_max_fee_per_gas(20_000_000_000) .with_max_priority_fee_per_gas(1_000_000_000); - let tx = WithOtherFields { - inner: tx, - other: OptimismTransactionFields { - source_hash: Some(b256!( - "0000000000000000000000000000000000000000000000000000000000000000" - )), - mint: Some(0), - is_system_tx: Some(true), - deposit_receipt_version: None, - } - .into(), + + let op_fields = OptimismTransactionFields { + source_hash: Some(b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )), + mint: Some(0), + is_system_tx: Some(true), + deposit_receipt_version: None, }; + let other = serde_json::to_value(op_fields).unwrap().try_into().unwrap(); + let tx = WithOtherFields { inner: tx, other }; let tx_envelope = tx.build(&signer).await.unwrap(); let mut tx_buffer = Vec::with_capacity(tx_envelope.encode_2718_len()); tx_envelope.encode_2718(&mut tx_buffer); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 63ebbbcf3404f..07c120d1ce525 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -197,7 +197,7 @@ async fn can_reject_too_high_gas_limits() { let from = accounts[0].address(); let to = accounts[1].address(); - let gas_limit = api.gas_limit().to::(); + let gas_limit = api.gas_limit().to::(); let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); let tx = @@ -237,11 +237,11 @@ async fn can_mine_large_gas_limit() { let from = accounts[0].address(); let to = accounts[1].address(); - let gas_limit = anvil::DEFAULT_GAS_LIMIT; + let gas_limit = anvil::DEFAULT_GAS_LIMIT as u64; let amount = handle.genesis_balance().checked_div(U256::from(3u64)).unwrap(); let tx = - TransactionRequest::default().to(to).value(amount).from(from).with_gas_limit(gas_limit * 3); + TransactionRequest::default().to(to).value(amount).from(from).with_gas_limit(gas_limit); // send transaction with higher gas limit let pending = provider.send_transaction(WithOtherFields::new(tx)).await.unwrap(); @@ -580,7 +580,7 @@ async fn can_handle_multiple_concurrent_transfers_with_same_nonce() { .value(U256::from(100)) .from(from) .nonce(nonce) - .with_gas_limit(21000u128); + .with_gas_limit(21000); let tx = WithOtherFields::new(tx); @@ -621,7 +621,7 @@ async fn can_handle_multiple_concurrent_deploys_with_same_nonce() { .from(from) .with_input(greeter_calldata.to_owned()) .nonce(nonce) - .with_gas_limit(300_000u128); + .with_gas_limit(300_000); let tx = WithOtherFields::new(tx); @@ -662,7 +662,7 @@ async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { .from(from) .with_input(deploy_calldata.to_owned()) .nonce(nonce) - .with_gas_limit(300_000u128); + .with_gas_limit(300_000); let deploy_tx = WithOtherFields::new(deploy_tx); let set_greeting = greeter_contract.setGreeting("Hello".to_string()); @@ -672,7 +672,7 @@ async fn can_handle_multiple_concurrent_transactions_with_same_nonce() { .from(from) .with_input(set_greeting_calldata.to_owned()) .nonce(nonce) - .with_gas_limit(300_000u128); + .with_gas_limit(300_000); let set_greeting_tx = WithOtherFields::new(set_greeting_tx); for idx in 0..10 { @@ -1127,7 +1127,7 @@ async fn test_estimate_gas() { let addr = recipient; let account_override = AccountOverride { balance: Some(alloy_primitives::U256::from(1e18)), ..Default::default() }; - let mut state_override = StateOverride::new(); + let mut state_override = StateOverride::default(); state_override.insert(addr, account_override); // Estimate gas with state override implying sufficient funds. @@ -1152,7 +1152,7 @@ async fn test_reject_gas_too_low() { .to(Address::random()) .value(U256::from(1337u64)) .from(account) - .with_gas_limit(gas as u128); + .with_gas_limit(gas); let tx = WithOtherFields::new(tx); let resp = provider.send_transaction(tx).await; @@ -1169,7 +1169,7 @@ async fn can_call_with_high_gas_limit() { let greeter_contract = Greeter::deploy(provider, "Hello World!".to_string()).await.unwrap(); - let greeting = greeter_contract.greet().gas(60_000_000u128).call().await.unwrap(); + let greeting = greeter_contract.greet().gas(60_000_000).call().await.unwrap(); assert_eq!("Hello World!", greeting._0); } @@ -1179,7 +1179,7 @@ async fn test_reject_eip1559_pre_london() { spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::Berlin.into()))).await; let provider = handle.http_provider(); - let gas_limit = api.gas_limit().to::(); + let gas_limit = api.gas_limit().to::(); let gas_price = api.gas_price(); let unsupported_call_builder = diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 3e80f1eaa9d00..3ef5859ec36b0 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -677,11 +677,7 @@ impl Cheatcodes { value: Some(input.value()), input: TransactionInput::new(input.init_code()), nonce: Some(account.info.nonce), - gas: if is_fixed_gas_limit { - Some(input.gas_limit() as u128) - } else { - None - }, + gas: if is_fixed_gas_limit { Some(input.gas_limit()) } else { None }, ..Default::default() } .into(), @@ -1016,11 +1012,7 @@ impl Cheatcodes { value: call.transfer_value(), input: TransactionInput::new(call.input.clone()), nonce: Some(account.info.nonce), - gas: if is_fixed_gas_limit { - Some(call.gas_limit as u128) - } else { - None - }, + gas: if is_fixed_gas_limit { Some(call.gas_limit) } else { None }, ..Default::default() } .into(), diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 9df8f896f99d0..7335714e54806 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -2,7 +2,10 @@ use alloy_consensus::{Transaction, TxEnvelope}; use alloy_primitives::{Address, TxKind, U256}; -use alloy_provider::{network::AnyNetwork, Provider}; +use alloy_provider::{ + network::{AnyNetwork, TransactionBuilder}, + Provider, +}; use alloy_rpc_types::{AnyTransactionReceipt, BlockId, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_transport::Transport; @@ -212,8 +215,8 @@ impl TransactionMaybeSigned { pub fn gas(&self) -> Option { match self { - Self::Signed { tx, .. } => Some(tx.gas_limit()), - Self::Unsigned(tx) => tx.gas, + Self::Signed { tx, .. } => Some(tx.gas_limit() as u128), + Self::Unsigned(tx) => tx.gas_limit().map(|g| g as u128), } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 49830bc892d03..07ee7013012e5 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1279,7 +1279,7 @@ impl DatabaseExt for Backend { env.tx.caller = tx.from.ok_or_else(|| eyre::eyre!("transact_from_tx: No `from` field found"))?; env.tx.gas_limit = - tx.gas.ok_or_else(|| eyre::eyre!("transact_from_tx: No `gas` field found"))? as u64; + tx.gas.ok_or_else(|| eyre::eyre!("transact_from_tx: No `gas` field found"))?; env.tx.gas_price = U256::from(tx.gas_price.or(tx.max_fee_per_gas).unwrap_or_default()); env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); env.tx.nonce = tx.nonce; diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 11f8bbb318827..19782ee9da512 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -84,7 +84,7 @@ pub fn get_function<'a>( /// Configures the env for the transaction pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { env.tx.caller = tx.from; - env.tx.gas_limit = tx.gas as u64; + env.tx.gas_limit = tx.gas; env.tx.gas_price = U256::from(tx.gas_price.unwrap_or_default()); env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); env.tx.nonce = Some(tx.nonce); diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index ac893b19f7aab..3faaa441e24c2 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -43,7 +43,7 @@ where tx.set_gas_limit( provider.estimate_gas(tx).await.wrap_err("Failed to estimate gas for tx")? * - estimate_multiplier as u128 / + estimate_multiplier / 100, ); Ok(()) diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index bbf84ff0ff8ae..639c5f022ac18 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -121,7 +121,7 @@ impl TransactionWithMetadata { if !self.is_fixed_gas_limit { if let Some(unsigned) = self.transaction.as_unsigned_mut() { // We inflate the gas used by the user specified percentage - unsigned.gas = Some((result.gas_used * gas_estimate_multiplier / 100) as u128); + unsigned.gas = Some(result.gas_used * gas_estimate_multiplier / 100); } } diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 034bb49a68461..661eb5c8dcb33 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -253,9 +253,9 @@ impl VerifyBytecodeArgs { if let Some(ref block) = genesis_block { configure_env_block(&mut env, block); - gen_tx.max_fee_per_gas = Some(block.header.base_fee_per_gas.unwrap_or_default()); + gen_tx.max_fee_per_gas = block.header.base_fee_per_gas.map(|g| g as u128); gen_tx.gas = block.header.gas_limit; - gen_tx.gas_price = Some(block.header.base_fee_per_gas.unwrap_or_default()); + gen_tx.gas_price = block.header.base_fee_per_gas.map(|g| g as u128); } configure_tx_env(&mut env, &gen_tx); From 6a1e0b781c772209dcfecf13b2cceb875853d043 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 2 Oct 2024 20:23:18 +0200 Subject: [PATCH 1509/1963] chore: print parent beacon root (#9006) Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/tests/cli/main.rs | 1 + crates/common/fmt/src/ui.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 8c928b3a8a535..df566d1144c0b 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -54,6 +54,7 @@ mixHash [..] nonce [..] number [..] parentHash [..] +parentBeaconRoot [..] transactionsRoot [..] receiptsRoot [..] sha3Uncles [..] diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 64c5207690d7a..a82853145799b 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -622,6 +622,7 @@ mixHash {} nonce {} number {} parentHash {} +parentBeaconRoot {} transactionsRoot {} receiptsRoot {} sha3Uncles {} @@ -642,6 +643,7 @@ totalDifficulty {}", block.header.nonce.pretty(), block.header.number.pretty(), block.header.parent_hash.pretty(), + block.header.parent_beacon_block_root.pretty(), block.header.transactions_root.pretty(), block.header.receipts_root.pretty(), block.header.uncles_hash.pretty(), From 471e4ac317858b3419faaee58ade30c0671021e0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 3 Oct 2024 02:02:55 +0200 Subject: [PATCH 1510/1963] chore: use dyn DatabaseExt everywhere (#8924) * wip * feat: use `dyn DatabaseExt` (#9010) * wip * clean up * fix * clippy * doc * fix imports * chore: simplify InspectorExt by making it lifetime-generic * fmt * chore: remove unnecessary casts and lifetimes * chore: more unused lifetimes (clippy) --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: Arsenii Kulikov --- crates/anvil/src/eth/backend/executor.rs | 42 ++- crates/anvil/src/eth/backend/mem/inspector.rs | 15 - crates/anvil/src/eth/backend/mem/mod.rs | 14 +- crates/cheatcodes/src/evm.rs | 156 +++++---- crates/cheatcodes/src/evm/fork.rs | 86 ++--- crates/cheatcodes/src/evm/mock.rs | 14 +- crates/cheatcodes/src/evm/prank.rs | 14 +- crates/cheatcodes/src/fs.rs | 13 +- crates/cheatcodes/src/inspector.rs | 299 +++++++----------- crates/cheatcodes/src/inspector/utils.rs | 33 +- crates/cheatcodes/src/lib.rs | 59 ++-- crates/cheatcodes/src/script.rs | 28 +- crates/cheatcodes/src/test.rs | 15 +- crates/cheatcodes/src/test/assert.rs | 20 +- crates/cheatcodes/src/test/assume.rs | 4 +- crates/cheatcodes/src/test/expect.rs | 46 +-- crates/cheatcodes/src/utils.rs | 22 +- crates/evm/core/src/backend/cow.rs | 16 +- crates/evm/core/src/backend/mod.rs | 30 +- crates/evm/core/src/lib.rs | 12 +- crates/evm/core/src/utils.rs | 75 +---- crates/evm/evm/src/inspectors/logs.rs | 4 +- crates/evm/evm/src/inspectors/stack.rs | 111 ++++--- 23 files changed, 499 insertions(+), 629 deletions(-) diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index d92d60a874405..3221620ef0e88 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -28,8 +28,9 @@ use foundry_evm::{ }, }, traces::CallTraceNode, + utils::alphanet_handler_register, }; -use revm::primitives::MAX_BLOB_GAS_PER_BLOCK; +use revm::{db::WrapDatabaseRef, primitives::MAX_BLOB_GAS_PER_BLOCK}; use std::sync::Arc; /// Represents an executed transaction (transacted on the DB) @@ -303,7 +304,7 @@ impl<'a, 'b, DB: Db + ?Sized, V: TransactionValidator> Iterator let nonce = account.nonce; // records all call and step traces - let mut inspector = Inspector::default().with_tracing().with_alphanet(self.alphanet); + let mut inspector = Inspector::default().with_tracing(); if self.enable_steps_tracing { inspector = inspector.with_steps_tracing(); } @@ -312,8 +313,7 @@ impl<'a, 'b, DB: Db + ?Sized, V: TransactionValidator> Iterator } let exec_result = { - let mut evm = - foundry_evm::utils::new_evm_with_inspector(&mut *self.db, env, &mut inspector); + let mut evm = new_evm_with_inspector(&mut *self.db, env, &mut inspector, self.alphanet); if let Some(factory) = &self.precompile_factory { inject_precompiles(&mut evm, factory.precompiles()); } @@ -396,3 +396,37 @@ fn build_logs_bloom(logs: Vec, bloom: &mut Bloom) { } } } + +/// Creates a database with given database and inspector, optionally enabling alphanet features. +pub fn new_evm_with_inspector( + db: DB, + env: EnvWithHandlerCfg, + inspector: &mut dyn revm::Inspector, + alphanet: bool, +) -> revm::Evm<'_, &mut dyn revm::Inspector, DB> { + let EnvWithHandlerCfg { env, handler_cfg } = env; + + let mut handler = revm::Handler::new(handler_cfg); + + handler.append_handler_register_plain(revm::inspector_handle_register); + if alphanet { + handler.append_handler_register_plain(alphanet_handler_register); + } + + let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); + + revm::Evm::new(context, handler) +} + +/// Creates a new EVM with the given inspector and wraps the database in a `WrapDatabaseRef`. +pub fn new_evm_with_inspector_ref<'a, DB>( + db: DB, + env: EnvWithHandlerCfg, + inspector: &mut dyn revm::Inspector>, + alphanet: bool, +) -> revm::Evm<'a, &mut dyn revm::Inspector>, WrapDatabaseRef> +where + DB: revm::DatabaseRef, +{ + new_evm_with_inspector(WrapDatabaseRef(db), env, inspector, alphanet) +} diff --git a/crates/anvil/src/eth/backend/mem/inspector.rs b/crates/anvil/src/eth/backend/mem/inspector.rs index b354a9a5c1236..e590d57e35bbb 100644 --- a/crates/anvil/src/eth/backend/mem/inspector.rs +++ b/crates/anvil/src/eth/backend/mem/inspector.rs @@ -14,7 +14,6 @@ use foundry_evm::{ EvmContext, }, traces::TracingInspectorConfig, - InspectorExt, }; /// The [`revm::Inspector`] used when transacting in the evm @@ -23,8 +22,6 @@ pub struct Inspector { pub tracer: Option, /// collects all `console.sol` logs pub log_collector: Option, - /// Whether to enable Alphanet support - pub alphanet: bool, } impl Inspector { @@ -59,12 +56,6 @@ impl Inspector { self.log_collector = Some(Default::default()); self } - - /// Enables Alphanet features - pub fn with_alphanet(mut self, yes: bool) -> Self { - self.alphanet = yes; - self - } } impl revm::Inspector for Inspector { @@ -176,12 +167,6 @@ impl revm::Inspector for Inspector { } } -impl InspectorExt for Inspector { - fn is_alphanet(&self) -> bool { - self.alphanet - } -} - /// Prints all the logs pub fn print_logs(logs: &[Log]) { for log in decode_console_logs(logs) { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ea36696f27487..dbf22fbebe7fd 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1,6 +1,7 @@ //! In-memory blockchain backend. use self::state::trie_storage; +use super::executor::new_evm_with_inspector_ref; use crate::{ config::PruneStateHistoryConfig, eth::{ @@ -32,6 +33,7 @@ use crate::{ revm::{db::DatabaseRef, primitives::AccountInfo}, ForkChoice, NodeConfig, PrecompileFactory, }; +use alloy_chains::NamedChain; use alloy_consensus::{Account, Header, Receipt, ReceiptWithBloom}; use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK; use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256, U64}; @@ -64,8 +66,6 @@ use anvil_core::eth::{ utils::meets_eip155, }; use anvil_rpc::error::RpcError; - -use alloy_chains::NamedChain; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertStateSnapshotAction}, @@ -81,8 +81,6 @@ use foundry_evm::{ }, }, traces::TracingInspectorConfig, - utils::new_evm_with_inspector_ref, - InspectorExt, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; use parking_lot::{Mutex, RwLock}; @@ -864,15 +862,15 @@ impl Backend { &self, db: &'db dyn DatabaseRef, env: EnvWithHandlerCfg, - inspector: &'i mut dyn InspectorExt< + inspector: &'i mut dyn revm::Inspector< WrapDatabaseRef<&'db dyn DatabaseRef>, >, ) -> revm::Evm< '_, - &'i mut dyn InspectorExt>>, + &'i mut dyn revm::Inspector>>, WrapDatabaseRef<&'db dyn DatabaseRef>, > { - let mut evm = new_evm_with_inspector_ref(db, env, inspector); + let mut evm = new_evm_with_inspector_ref(db, env, inspector, self.alphanet); if let Some(factory) = &self.precompile_factory { inject_precompiles(&mut evm, factory.precompiles()); } @@ -1269,7 +1267,7 @@ impl Backend { /// Builds [`Inspector`] with the configured options fn build_inspector(&self) -> Inspector { - let mut inspector = Inspector::default().with_alphanet(self.alphanet); + let mut inspector = Inspector::default(); if self.print_logs { inspector = inspector.with_log_collector(); diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 7d4a23d6126b7..f9671430dc089 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1,7 +1,8 @@ //! Implementations of [`Evm`](spec::Group::Evm) cheatcodes. use crate::{ - BroadcastableTransaction, Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*, + inspector::InnerEcx, BroadcastableTransaction, Cheatcode, Cheatcodes, CheatcodesExecutor, + CheatsCtxt, Result, Vm::*, }; use alloy_consensus::TxEnvelope; use alloy_genesis::{Genesis, GenesisAccount}; @@ -14,10 +15,7 @@ use foundry_evm_core::{ constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS}, }; use rand::Rng; -use revm::{ - primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}, - InnerEvmContext, -}; +use revm::primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}; use std::{ collections::{BTreeMap, HashMap}, path::Path, @@ -85,21 +83,21 @@ impl Cheatcode for addrCall { } impl Cheatcode for getNonce_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; get_nonce(ccx, account) } } impl Cheatcode for getNonce_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { wallet } = self; get_nonce(ccx, &wallet.addr) } } impl Cheatcode for loadCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, slot } = *self; ensure_not_precompile!(&target, ccx); ccx.ecx.load_account(target)?; @@ -136,7 +134,7 @@ impl Cheatcode for loadCall { } impl Cheatcode for loadAllocsCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { pathToAllocsJson } = self; let path = Path::new(pathToAllocsJson); @@ -162,7 +160,7 @@ impl Cheatcode for loadAllocsCall { } impl Cheatcode for dumpStateCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { pathToStateJson } = self; let path = Path::new(pathToStateJson); @@ -282,7 +280,7 @@ impl Cheatcode for lastCallGasCall { } impl Cheatcode for chainIdCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newChainId } = self; ensure!(*newChainId <= U256::from(u64::MAX), "chain ID must be less than 2^64 - 1"); ccx.ecx.env.cfg.chain_id = newChainId.to(); @@ -291,7 +289,7 @@ impl Cheatcode for chainIdCall { } impl Cheatcode for coinbaseCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newCoinbase } = self; ccx.ecx.env.block.coinbase = *newCoinbase; Ok(Default::default()) @@ -299,7 +297,7 @@ impl Cheatcode for coinbaseCall { } impl Cheatcode for difficultyCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newDifficulty } = self; ensure!( ccx.ecx.spec_id() < SpecId::MERGE, @@ -312,7 +310,7 @@ impl Cheatcode for difficultyCall { } impl Cheatcode for feeCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newBasefee } = self; ccx.ecx.env.block.basefee = *newBasefee; Ok(Default::default()) @@ -320,7 +318,7 @@ impl Cheatcode for feeCall { } impl Cheatcode for prevrandao_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newPrevrandao } = self; ensure!( ccx.ecx.spec_id() >= SpecId::MERGE, @@ -333,7 +331,7 @@ impl Cheatcode for prevrandao_0Call { } impl Cheatcode for prevrandao_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newPrevrandao } = self; ensure!( ccx.ecx.spec_id() >= SpecId::MERGE, @@ -346,7 +344,7 @@ impl Cheatcode for prevrandao_1Call { } impl Cheatcode for blobhashesCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { hashes } = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, @@ -359,7 +357,7 @@ impl Cheatcode for blobhashesCall { } impl Cheatcode for getBlobhashesCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, @@ -371,7 +369,7 @@ impl Cheatcode for getBlobhashesCall { } impl Cheatcode for rollCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newHeight } = self; ccx.ecx.env.block.number = *newHeight; Ok(Default::default()) @@ -379,14 +377,14 @@ impl Cheatcode for rollCall { } impl Cheatcode for getBlockNumberCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; Ok(ccx.ecx.env.block.number.abi_encode()) } } impl Cheatcode for txGasPriceCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newGasPrice } = self; ccx.ecx.env.tx.gas_price = *newGasPrice; Ok(Default::default()) @@ -394,7 +392,7 @@ impl Cheatcode for txGasPriceCall { } impl Cheatcode for warpCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newTimestamp } = self; ccx.ecx.env.block.timestamp = *newTimestamp; Ok(Default::default()) @@ -402,14 +400,14 @@ impl Cheatcode for warpCall { } impl Cheatcode for getBlockTimestampCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; Ok(ccx.ecx.env.block.timestamp.abi_encode()) } } impl Cheatcode for blobBaseFeeCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { newBlobBaseFee } = self; ensure!( ccx.ecx.spec_id() >= SpecId::CANCUN, @@ -422,14 +420,14 @@ impl Cheatcode for blobBaseFeeCall { } impl Cheatcode for getBlobBaseFeeCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; Ok(ccx.ecx.env.block.get_blob_excess_gas().unwrap_or(0).abi_encode()) } } impl Cheatcode for dealCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account: address, newBalance: new_balance } = *self; let account = journaled_account(ccx.ecx, address)?; let old_balance = std::mem::replace(&mut account.info.balance, new_balance); @@ -440,7 +438,7 @@ impl Cheatcode for dealCall { } impl Cheatcode for etchCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, newRuntimeBytecode } = self; ensure_not_precompile!(target, ccx); ccx.ecx.load_account(*target)?; @@ -451,7 +449,7 @@ impl Cheatcode for etchCall { } impl Cheatcode for resetNonceCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; let account = journaled_account(ccx.ecx, *account)?; // Per EIP-161, EOA nonces start at 0, but contract nonces @@ -466,7 +464,7 @@ impl Cheatcode for resetNonceCall { } impl Cheatcode for setNonceCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account, newNonce } = *self; let account = journaled_account(ccx.ecx, account)?; // nonce must increment only @@ -482,7 +480,7 @@ impl Cheatcode for setNonceCall { } impl Cheatcode for setNonceUnsafeCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account, newNonce } = *self; let account = journaled_account(ccx.ecx, account)?; account.info.nonce = newNonce; @@ -491,7 +489,7 @@ impl Cheatcode for setNonceUnsafeCall { } impl Cheatcode for storeCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target, slot, value } = *self; ensure_not_precompile!(&target, ccx); // ensure the account is touched @@ -502,7 +500,7 @@ impl Cheatcode for storeCall { } impl Cheatcode for coolCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target } = self; if let Some(account) = ccx.ecx.journaled_state.state.get_mut(target) { account.unmark_touch(); @@ -513,28 +511,28 @@ impl Cheatcode for coolCall { } impl Cheatcode for readCallersCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; read_callers(ccx.state, &ccx.ecx.env.tx.caller) } } impl Cheatcode for snapshotValue_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { name, value } = self; inner_value_snapshot(ccx, None, Some(name.clone()), value.to_string()) } } impl Cheatcode for snapshotValue_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { group, name, value } = self; inner_value_snapshot(ccx, Some(group.clone()), Some(name.clone()), value.to_string()) } } impl Cheatcode for snapshotGasLastCall_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { name } = self; let Some(last_call_gas) = &ccx.state.gas_metering.last_call_gas else { bail!("no external call was made yet"); @@ -544,7 +542,7 @@ impl Cheatcode for snapshotGasLastCall_0Call { } impl Cheatcode for snapshotGasLastCall_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { name, group } = self; let Some(last_call_gas) = &ccx.state.gas_metering.last_call_gas else { bail!("no external call was made yet"); @@ -559,35 +557,35 @@ impl Cheatcode for snapshotGasLastCall_1Call { } impl Cheatcode for startSnapshotGas_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { name } = self; inner_start_gas_snapshot(ccx, None, Some(name.clone())) } } impl Cheatcode for startSnapshotGas_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { group, name } = self; inner_start_gas_snapshot(ccx, Some(group.clone()), Some(name.clone())) } } impl Cheatcode for stopSnapshotGas_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; inner_stop_gas_snapshot(ccx, None, None) } } impl Cheatcode for stopSnapshotGas_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { name } = self; inner_stop_gas_snapshot(ccx, None, Some(name.clone())) } } impl Cheatcode for stopSnapshotGas_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { group, name } = self; inner_stop_gas_snapshot(ccx, Some(group.clone()), Some(name.clone())) } @@ -595,14 +593,14 @@ impl Cheatcode for stopSnapshotGas_2Call { // Deprecated in favor of `snapshotStateCall` impl Cheatcode for snapshotCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; inner_snapshot_state(ccx) } } impl Cheatcode for snapshotStateCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; inner_snapshot_state(ccx) } @@ -610,14 +608,14 @@ impl Cheatcode for snapshotStateCall { // Deprecated in favor of `revertToStateCall` impl Cheatcode for revertToCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; inner_revert_to_state(ccx, *snapshotId) } } impl Cheatcode for revertToStateCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; inner_revert_to_state(ccx, *snapshotId) } @@ -625,14 +623,14 @@ impl Cheatcode for revertToStateCall { // Deprecated in favor of `revertToStateAndDeleteCall` impl Cheatcode for revertToAndDeleteCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; inner_revert_to_state_and_delete(ccx, *snapshotId) } } impl Cheatcode for revertToStateAndDeleteCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; inner_revert_to_state_and_delete(ccx, *snapshotId) } @@ -640,14 +638,14 @@ impl Cheatcode for revertToStateAndDeleteCall { // Deprecated in favor of `deleteStateSnapshotCall` impl Cheatcode for deleteSnapshotCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; inner_delete_state_snapshot(ccx, *snapshotId) } } impl Cheatcode for deleteStateSnapshotCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { snapshotId } = self; inner_delete_state_snapshot(ccx, *snapshotId) } @@ -655,14 +653,14 @@ impl Cheatcode for deleteStateSnapshotCall { // Deprecated in favor of `deleteStateSnapshotsCall` impl Cheatcode for deleteSnapshotsCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; inner_delete_state_snapshots(ccx) } } impl Cheatcode for deleteStateSnapshotsCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; inner_delete_state_snapshots(ccx) } @@ -684,11 +682,7 @@ impl Cheatcode for stopAndReturnStateDiffCall { } impl Cheatcode for broadcastRawTransactionCall { - fn apply_full( - &self, - ccx: &mut CheatsCtxt, - executor: &mut E, - ) -> Result { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let mut data = self.data.as_ref(); let tx = TxEnvelope::decode(&mut data) .map_err(|err| fmt_err!("failed to decode RLP-encoded transaction: {err}"))?; @@ -697,7 +691,7 @@ impl Cheatcode for broadcastRawTransactionCall { tx.clone().into(), &ccx.ecx.env, &mut ccx.ecx.journaled_state, - &mut executor.get_inspector(ccx.state), + &mut *executor.get_inspector(ccx.state), )?; if ccx.state.broadcast.is_some() { @@ -712,7 +706,7 @@ impl Cheatcode for broadcastRawTransactionCall { } impl Cheatcode for setBlockhashCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { blockNumber, blockHash } = *self; ensure!( blockNumber <= ccx.ecx.env.block.number, @@ -725,16 +719,16 @@ impl Cheatcode for setBlockhashCall { } } -pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { +pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { let account = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?; Ok(account.info.nonce.abi_encode()) } -fn inner_snapshot_state(ccx: &mut CheatsCtxt) -> Result { +fn inner_snapshot_state(ccx: &mut CheatsCtxt) -> Result { Ok(ccx.ecx.db.snapshot_state(&ccx.ecx.journaled_state, &ccx.ecx.env).abi_encode()) } -fn inner_revert_to_state(ccx: &mut CheatsCtxt, snapshot_id: U256) -> Result { +fn inner_revert_to_state(ccx: &mut CheatsCtxt, snapshot_id: U256) -> Result { let result = if let Some(journaled_state) = ccx.ecx.db.revert_state( snapshot_id, &ccx.ecx.journaled_state, @@ -750,10 +744,7 @@ fn inner_revert_to_state(ccx: &mut CheatsCtxt, snapshot_id: Ok(result.abi_encode()) } -fn inner_revert_to_state_and_delete( - ccx: &mut CheatsCtxt, - snapshot_id: U256, -) -> Result { +fn inner_revert_to_state_and_delete(ccx: &mut CheatsCtxt, snapshot_id: U256) -> Result { let result = if let Some(journaled_state) = ccx.ecx.db.revert_state( snapshot_id, &ccx.ecx.journaled_state, @@ -769,21 +760,18 @@ fn inner_revert_to_state_and_delete( Ok(result.abi_encode()) } -fn inner_delete_state_snapshot( - ccx: &mut CheatsCtxt, - snapshot_id: U256, -) -> Result { +fn inner_delete_state_snapshot(ccx: &mut CheatsCtxt, snapshot_id: U256) -> Result { let result = ccx.ecx.db.delete_state_snapshot(snapshot_id); Ok(result.abi_encode()) } -fn inner_delete_state_snapshots(ccx: &mut CheatsCtxt) -> Result { +fn inner_delete_state_snapshots(ccx: &mut CheatsCtxt) -> Result { ccx.ecx.db.delete_state_snapshots(); Ok(Default::default()) } -fn inner_value_snapshot( - ccx: &mut CheatsCtxt, +fn inner_value_snapshot( + ccx: &mut CheatsCtxt, group: Option, name: Option, value: String, @@ -795,8 +783,8 @@ fn inner_value_snapshot( Ok(Default::default()) } -fn inner_last_gas_snapshot( - ccx: &mut CheatsCtxt, +fn inner_last_gas_snapshot( + ccx: &mut CheatsCtxt, group: Option, name: Option, value: u64, @@ -808,8 +796,8 @@ fn inner_last_gas_snapshot( Ok(value.abi_encode()) } -fn inner_start_gas_snapshot( - ccx: &mut CheatsCtxt, +fn inner_start_gas_snapshot( + ccx: &mut CheatsCtxt, group: Option, name: Option, ) -> Result { @@ -835,8 +823,8 @@ fn inner_start_gas_snapshot( Ok(Default::default()) } -fn inner_stop_gas_snapshot( - ccx: &mut CheatsCtxt, +fn inner_stop_gas_snapshot( + ccx: &mut CheatsCtxt, group: Option, name: Option, ) -> Result { @@ -886,8 +874,8 @@ fn inner_stop_gas_snapshot( } // Derives the snapshot group and name from the provided group and name or the running contract. -fn derive_snapshot_name( - ccx: &CheatsCtxt, +fn derive_snapshot_name( + ccx: &CheatsCtxt, group: Option, name: Option, ) -> (String, String) { @@ -947,10 +935,10 @@ fn read_callers(state: &Cheatcodes, default_sender: &Address) -> Result { } /// Ensures the `Account` is loaded and touched. -pub(super) fn journaled_account( - ecx: &mut InnerEvmContext, +pub(super) fn journaled_account<'a>( + ecx: InnerEcx<'a, '_, '_>, addr: Address, -) -> Result<&mut Account> { +) -> Result<&'a mut Account> { ecx.load_account(addr)?; ecx.journaled_state.touch(&addr); Ok(ecx.journaled_state.state.get_mut(&addr).expect("account is loaded")) diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index a8cc830009fec..84fda7883c7d5 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,4 +1,4 @@ -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, DatabaseExt, Result, Vm::*}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{B256, U256}; use alloy_provider::Provider; @@ -8,7 +8,7 @@ use foundry_common::provider::ProviderBuilder; use foundry_evm_core::fork::CreateFork; impl Cheatcode for activeForkCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; ccx.ecx .db @@ -19,49 +19,49 @@ impl Cheatcode for activeForkCall { } impl Cheatcode for createFork_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias } = self; create_fork(ccx, urlOrAlias, None) } } impl Cheatcode for createFork_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, blockNumber } = self; create_fork(ccx, urlOrAlias, Some(blockNumber.saturating_to())) } } impl Cheatcode for createFork_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, txHash } = self; create_fork_at_transaction(ccx, urlOrAlias, txHash) } } impl Cheatcode for createSelectFork_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias } = self; create_select_fork(ccx, urlOrAlias, None) } } impl Cheatcode for createSelectFork_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, blockNumber } = self; create_select_fork(ccx, urlOrAlias, Some(blockNumber.saturating_to())) } } impl Cheatcode for createSelectFork_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { urlOrAlias, txHash } = self; create_select_fork_at_transaction(ccx, urlOrAlias, txHash) } } impl Cheatcode for rollFork_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { blockNumber } = self; persist_caller(ccx); ccx.ecx.db.roll_fork( @@ -75,7 +75,7 @@ impl Cheatcode for rollFork_0Call { } impl Cheatcode for rollFork_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { txHash } = self; persist_caller(ccx); ccx.ecx.db.roll_fork_to_transaction( @@ -89,7 +89,7 @@ impl Cheatcode for rollFork_1Call { } impl Cheatcode for rollFork_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, blockNumber } = self; persist_caller(ccx); ccx.ecx.db.roll_fork( @@ -103,7 +103,7 @@ impl Cheatcode for rollFork_2Call { } impl Cheatcode for rollFork_3Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId, txHash } = self; persist_caller(ccx); ccx.ecx.db.roll_fork_to_transaction( @@ -117,7 +117,7 @@ impl Cheatcode for rollFork_3Call { } impl Cheatcode for selectForkCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { forkId } = self; persist_caller(ccx); check_broadcast(ccx.state)?; @@ -128,11 +128,7 @@ impl Cheatcode for selectForkCall { } impl Cheatcode for transact_0Call { - fn apply_full( - &self, - ccx: &mut CheatsCtxt, - executor: &mut E, - ) -> Result { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let Self { txHash } = *self; ccx.ecx.db.transact( None, @@ -146,25 +142,21 @@ impl Cheatcode for transact_0Call { } impl Cheatcode for transact_1Call { - fn apply_full( - &self, - ccx: &mut CheatsCtxt, - executor: &mut E, - ) -> Result { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let Self { forkId, txHash } = *self; ccx.ecx.db.transact( Some(forkId), txHash, &mut ccx.ecx.env, &mut ccx.ecx.journaled_state, - &mut executor.get_inspector(ccx.state), + &mut *executor.get_inspector(ccx.state), )?; Ok(Default::default()) } } impl Cheatcode for allowCheatcodesCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; ccx.ecx.db.allow_cheatcode_access(*account); Ok(Default::default()) @@ -172,7 +164,7 @@ impl Cheatcode for allowCheatcodesCall { } impl Cheatcode for makePersistent_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; ccx.ecx.db.add_persistent_account(*account); Ok(Default::default()) @@ -180,7 +172,7 @@ impl Cheatcode for makePersistent_0Call { } impl Cheatcode for makePersistent_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account0, account1 } = self; ccx.ecx.db.add_persistent_account(*account0); ccx.ecx.db.add_persistent_account(*account1); @@ -189,7 +181,7 @@ impl Cheatcode for makePersistent_1Call { } impl Cheatcode for makePersistent_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account0, account1, account2 } = self; ccx.ecx.db.add_persistent_account(*account0); ccx.ecx.db.add_persistent_account(*account1); @@ -199,7 +191,7 @@ impl Cheatcode for makePersistent_2Call { } impl Cheatcode for makePersistent_3Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { accounts } = self; for account in accounts { ccx.ecx.db.add_persistent_account(*account); @@ -209,7 +201,7 @@ impl Cheatcode for makePersistent_3Call { } impl Cheatcode for revokePersistent_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; ccx.ecx.db.remove_persistent_account(account); Ok(Default::default()) @@ -217,7 +209,7 @@ impl Cheatcode for revokePersistent_0Call { } impl Cheatcode for revokePersistent_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { accounts } = self; for account in accounts { ccx.ecx.db.remove_persistent_account(account); @@ -227,14 +219,14 @@ impl Cheatcode for revokePersistent_1Call { } impl Cheatcode for isPersistentCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { account } = self; Ok(ccx.ecx.db.is_persistent(account).abi_encode()) } } impl Cheatcode for rpc_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { method, params } = self; let url = ccx.ecx.db.active_fork_url().ok_or_else(|| fmt_err!("no active fork URL found"))?; @@ -251,7 +243,7 @@ impl Cheatcode for rpc_1Call { } impl Cheatcode for eth_getLogsCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { fromBlock, toBlock, target, topics } = self; let (Ok(from_block), Ok(to_block)) = (u64::try_from(fromBlock), u64::try_from(toBlock)) else { @@ -293,11 +285,7 @@ impl Cheatcode for eth_getLogsCall { } /// Creates and then also selects the new fork -fn create_select_fork( - ccx: &mut CheatsCtxt, - url_or_alias: &str, - block: Option, -) -> Result { +fn create_select_fork(ccx: &mut CheatsCtxt, url_or_alias: &str, block: Option) -> Result { check_broadcast(ccx.state)?; let fork = create_fork_request(ccx, url_or_alias, block)?; @@ -306,19 +294,15 @@ fn create_select_fork( } /// Creates a new fork -fn create_fork( - ccx: &mut CheatsCtxt, - url_or_alias: &str, - block: Option, -) -> Result { +fn create_fork(ccx: &mut CheatsCtxt, url_or_alias: &str, block: Option) -> Result { let fork = create_fork_request(ccx, url_or_alias, block)?; let id = ccx.ecx.db.create_fork(fork)?; Ok(id.abi_encode()) } /// Creates and then also selects the new fork at the given transaction -fn create_select_fork_at_transaction( - ccx: &mut CheatsCtxt, +fn create_select_fork_at_transaction( + ccx: &mut CheatsCtxt, url_or_alias: &str, transaction: &B256, ) -> Result { @@ -335,8 +319,8 @@ fn create_select_fork_at_transaction( } /// Creates a new fork at the given transaction -fn create_fork_at_transaction( - ccx: &mut CheatsCtxt, +fn create_fork_at_transaction( + ccx: &mut CheatsCtxt, url_or_alias: &str, transaction: &B256, ) -> Result { @@ -346,8 +330,8 @@ fn create_fork_at_transaction( } /// Creates the request object for a new fork request -fn create_fork_request( - ccx: &mut CheatsCtxt, +fn create_fork_request( + ccx: &mut CheatsCtxt, url_or_alias: &str, block: Option, ) -> Result { @@ -380,7 +364,7 @@ fn check_broadcast(state: &Cheatcodes) -> Result<()> { // Applies to create, select and roll forks actions. // https://github.com/foundry-rs/foundry/issues/8004 #[inline] -fn persist_caller(ccx: &mut CheatsCtxt) { +fn persist_caller(ccx: &mut CheatsCtxt) { ccx.ecx.db.add_persistent_account(ccx.caller); } diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 01a02c5c21c9d..ab858c612da69 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -1,6 +1,6 @@ -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use crate::{inspector::InnerEcx, Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, Bytes, U256}; -use revm::{interpreter::InstructionResult, primitives::Bytecode, InnerEvmContext}; +use revm::{interpreter::InstructionResult, primitives::Bytecode}; use std::cmp::Ordering; /// Mocked call data. @@ -47,7 +47,7 @@ impl Cheatcode for clearMockedCallsCall { } impl Cheatcode for mockCall_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; let _ = make_acc_non_empty(callee, ccx.ecx)?; @@ -57,7 +57,7 @@ impl Cheatcode for mockCall_0Call { } impl Cheatcode for mockCall_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, msgValue, data, returnData } = self; ccx.ecx.load_account(*callee)?; mock_call(ccx.state, callee, data, Some(msgValue), returnData, InstructionResult::Return); @@ -66,7 +66,7 @@ impl Cheatcode for mockCall_1Call { } impl Cheatcode for mockCallRevert_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, revertData } = self; let _ = make_acc_non_empty(callee, ccx.ecx)?; @@ -76,7 +76,7 @@ impl Cheatcode for mockCallRevert_0Call { } impl Cheatcode for mockCallRevert_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, msgValue, data, revertData } = self; let _ = make_acc_non_empty(callee, ccx.ecx)?; @@ -111,7 +111,7 @@ fn mock_call( // Etches a single byte onto the account if it is empty to circumvent the `extcodesize` // check Solidity might perform. -fn make_acc_non_empty(callee: &Address, ecx: &mut InnerEvmContext) -> Result { +fn make_acc_non_empty(callee: &Address, ecx: InnerEcx) -> Result { let acc = ecx.load_account(*callee)?; let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty); diff --git a/crates/cheatcodes/src/evm/prank.rs b/crates/cheatcodes/src/evm/prank.rs index fe5418b3157f8..a310e28e515bc 100644 --- a/crates/cheatcodes/src/evm/prank.rs +++ b/crates/cheatcodes/src/evm/prank.rs @@ -1,4 +1,4 @@ -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::Address; /// Prank information. @@ -45,28 +45,28 @@ impl Prank { } impl Cheatcode for prank_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender } = self; prank(ccx, msgSender, None, true) } } impl Cheatcode for startPrank_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender } = self; prank(ccx, msgSender, None, false) } } impl Cheatcode for prank_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender, txOrigin } = self; prank(ccx, msgSender, Some(txOrigin), true) } } impl Cheatcode for startPrank_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender, txOrigin } = self; prank(ccx, msgSender, Some(txOrigin), false) } @@ -80,8 +80,8 @@ impl Cheatcode for stopPrankCall { } } -fn prank( - ccx: &mut CheatsCtxt, +fn prank( + ccx: &mut CheatsCtxt, new_caller: &Address, new_origin: Option<&Address>, single_call: bool, diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 4185b2d799976..f36c8d6fe8f8c 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -9,7 +9,6 @@ use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; -use foundry_evm_core::backend::DatabaseExt; use revm::interpreter::CreateInputs; use semver::Version; use std::{ @@ -293,11 +292,7 @@ impl Cheatcode for getDeployedCodeCall { } impl Cheatcode for deployCode_0Call { - fn apply_full( - &self, - ccx: &mut CheatsCtxt, - executor: &mut E, - ) -> Result { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let Self { artifactPath: path } = self; let bytecode = get_artifact_code(ccx.state, path, false)?; let address = executor @@ -319,11 +314,7 @@ impl Cheatcode for deployCode_0Call { } impl Cheatcode for deployCode_1Call { - fn apply_full( - &self, - ccx: &mut CheatsCtxt, - executor: &mut E, - ) -> Result { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let Self { artifactPath: path, constructorArgs } = self; let mut bytecode = get_artifact_code(ccx.state, path, false)?.to_vec(); bytecode.extend_from_slice(constructorArgs); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 3ef5859ec36b0..fe8834d5f5a82 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -17,8 +17,8 @@ use crate::{ }, }, utils::IgnoredTraces, - CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, Vm, - Vm::AccountAccess, + CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, + Vm::{self, AccountAccess}, }; use alloy_primitives::{ hex, @@ -31,7 +31,7 @@ use foundry_common::{evm::Breakpoints, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_config::Config; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, - backend::{DatabaseExt, RevertDiagnostic}, + backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME}, utils::new_evm_with_existing_context, InspectorExt, @@ -62,6 +62,9 @@ use std::{ mod utils; +pub type Ecx<'a, 'b, 'c> = &'a mut EvmContext<&'b mut (dyn DatabaseExt + 'c)>; +pub type InnerEcx<'a, 'b, 'c> = &'a mut InnerEvmContext<&'b mut (dyn DatabaseExt + 'c)>; + /// Helper trait for obtaining complete [revm::Inspector] instance from mutable reference to /// [Cheatcodes]. /// @@ -70,71 +73,30 @@ mod utils; pub trait CheatcodesExecutor { /// Core trait method accepting mutable reference to [Cheatcodes] and returning /// [revm::Inspector]. - fn get_inspector<'a, DB: DatabaseExt>( - &'a mut self, - cheats: &'a mut Cheatcodes, - ) -> impl InspectorExt + 'a; - - /// Constructs [revm::Evm] and runs a given closure with it. - fn with_evm( - &mut self, - ccx: &mut CheatsCtxt, - f: F, - ) -> Result> - where - F: for<'a, 'b> FnOnce( - &mut revm::Evm< - '_, - &'b mut dyn InspectorExt<&'a mut dyn DatabaseExt>, - &'a mut dyn DatabaseExt, - >, - ) -> Result>, - { - let mut inspector = self.get_inspector(ccx.state); - let error = std::mem::replace(&mut ccx.ecx.error, Ok(())); - let l1_block_info = std::mem::take(&mut ccx.ecx.l1_block_info); - - let inner = revm::InnerEvmContext { - env: ccx.ecx.env.clone(), - journaled_state: std::mem::replace( - &mut ccx.ecx.journaled_state, - revm::JournaledState::new(Default::default(), Default::default()), - ), - db: &mut ccx.ecx.db as &mut dyn DatabaseExt, - error, - l1_block_info, - }; - - let mut evm = new_evm_with_existing_context(inner, &mut inspector as _); - - let res = f(&mut evm)?; - - ccx.ecx.journaled_state = evm.context.evm.inner.journaled_state; - ccx.ecx.env = evm.context.evm.inner.env; - ccx.ecx.l1_block_info = evm.context.evm.inner.l1_block_info; - ccx.ecx.error = evm.context.evm.inner.error; - - Ok(res) - } + fn get_inspector<'a>(&'a mut self, cheats: &'a mut Cheatcodes) -> Box; /// Obtains [revm::Evm] instance and executes the given CREATE frame. - fn exec_create( + fn exec_create( &mut self, inputs: CreateInputs, - ccx: &mut CheatsCtxt, - ) -> Result> { - self.with_evm(ccx, |evm| { + ccx: &mut CheatsCtxt, + ) -> Result> { + with_evm(self, ccx, |evm| { 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::PRAGUE_EOF) - && 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::PRAGUE_EOF) && + inputs.scheme == CreateScheme::Create && + inputs.init_code.starts_with(&EOF_MAGIC_BYTES) { evm.handler.execution().eofcreate( &mut evm.context, - Box::new(EOFCreateInputs::new(inputs.caller, inputs.value, inputs.gas_limit, EOFCreateKind::Tx { - initdata: inputs.init_code, - })), + Box::new(EOFCreateInputs::new( + inputs.caller, + inputs.value, + inputs.gas_limit, + EOFCreateKind::Tx { initdata: inputs.init_code }, + )), )? } else { evm.handler.execution().create(&mut evm.context, Box::new(inputs))? @@ -158,8 +120,8 @@ pub trait CheatcodesExecutor { }) } - fn console_log(&mut self, ccx: &mut CheatsCtxt, message: String) { - self.get_inspector::(ccx.state).console_log(message); + fn console_log(&mut self, ccx: &mut CheatsCtxt, message: String) { + self.get_inspector(ccx.state).console_log(message); } /// Returns a mutable reference to the tracing inspector if it is available. @@ -168,17 +130,53 @@ pub trait CheatcodesExecutor { } } +/// Constructs [revm::Evm] and runs a given closure with it. +fn with_evm( + executor: &mut E, + ccx: &mut CheatsCtxt, + f: F, +) -> Result> +where + E: CheatcodesExecutor + ?Sized, + F: for<'a, 'b> FnOnce( + &mut revm::Evm<'_, &'b mut dyn InspectorExt, &'a mut dyn DatabaseExt>, + ) -> Result>, +{ + let mut inspector = executor.get_inspector(ccx.state); + let error = std::mem::replace(&mut ccx.ecx.error, Ok(())); + let l1_block_info = std::mem::take(&mut ccx.ecx.l1_block_info); + + let inner = revm::InnerEvmContext { + env: ccx.ecx.env.clone(), + journaled_state: std::mem::replace( + &mut ccx.ecx.journaled_state, + revm::JournaledState::new(Default::default(), Default::default()), + ), + db: &mut ccx.ecx.db as &mut dyn DatabaseExt, + error, + l1_block_info, + }; + + let mut evm = new_evm_with_existing_context(inner, &mut *inspector); + + let res = f(&mut evm)?; + + ccx.ecx.journaled_state = evm.context.evm.inner.journaled_state; + ccx.ecx.env = evm.context.evm.inner.env; + ccx.ecx.l1_block_info = evm.context.evm.inner.l1_block_info; + ccx.ecx.error = evm.context.evm.inner.error; + + Ok(res) +} + /// Basic implementation of [CheatcodesExecutor] that simply returns the [Cheatcodes] instance as an /// inspector. #[derive(Debug, Default, Clone, Copy)] struct TransparentCheatcodesExecutor; impl CheatcodesExecutor for TransparentCheatcodesExecutor { - fn get_inspector<'a, DB: DatabaseExt>( - &'a mut self, - cheats: &'a mut Cheatcodes, - ) -> impl InspectorExt + 'a { - cheats + fn get_inspector<'a>(&'a mut self, cheats: &'a mut Cheatcodes) -> Box { + Box::new(cheats) } } @@ -306,13 +304,7 @@ impl ArbitraryStorage { /// Saves arbitrary storage value for a given address: /// - store value in changed values cache. /// - update account's storage with given value. - pub fn save( - &mut self, - ecx: &mut InnerEvmContext, - address: Address, - slot: U256, - data: U256, - ) { + pub fn save(&mut self, ecx: InnerEcx, address: Address, slot: U256, data: U256) { self.values.get_mut(&address).expect("missing arbitrary address entry").insert(slot, data); if let Ok(mut account) = ecx.load_account(address) { account.storage.insert(slot, EvmStorageSlot::new(data)); @@ -324,13 +316,7 @@ impl ArbitraryStorage { /// existing value. /// - if no value was yet generated for given slot, then save new value in cache and update both /// source and target storages. - pub fn copy( - &mut self, - ecx: &mut InnerEvmContext, - target: Address, - slot: U256, - new_value: U256, - ) -> U256 { + pub fn copy(&mut self, ecx: InnerEcx, target: Address, slot: U256, new_value: U256) -> U256 { let source = self.copies.get(&target).expect("missing arbitrary copy target entry"); let storage_cache = self.values.get_mut(source).expect("missing arbitrary source storage"); let value = match storage_cache.get(&slot) { @@ -535,11 +521,11 @@ impl Cheatcodes { } /// Decodes the input data and applies the cheatcode. - fn apply_cheatcode( + fn apply_cheatcode( &mut self, - ecx: &mut EvmContext, + ecx: Ecx, call: &CallInputs, - executor: &mut E, + executor: &mut dyn CheatcodesExecutor, ) -> Result { // decode the cheatcode call let decoded = Vm::VmCalls::abi_decode(&call.input, false).map_err(|e| { @@ -578,12 +564,7 @@ impl Cheatcodes { /// /// There may be cheatcodes in the constructor of the new contract, in order to allow them /// automatically we need to determine the new address. - fn allow_cheatcodes_on_create( - &self, - ecx: &mut InnerEvmContext, - caller: Address, - created_address: Address, - ) { + fn allow_cheatcodes_on_create(&self, ecx: InnerEcx, caller: Address, created_address: Address) { if ecx.journaled_state.depth <= 1 || ecx.db.has_cheatcode_access(&caller) { ecx.db.allow_cheatcode_access(created_address); } @@ -593,7 +574,7 @@ impl Cheatcodes { /// /// Cleanup any previously applied cheatcodes that altered the state in such a way that revm's /// revert would run into issues. - pub fn on_revert(&mut self, ecx: &mut EvmContext) { + pub fn on_revert(&mut self, ecx: Ecx) { trace!(deals=?self.eth_deals.len(), "rolling back deals"); // Delay revert clean up until expected revert is handled, if set. @@ -617,14 +598,9 @@ impl Cheatcodes { } // common create functionality for both legacy and EOF. - fn create_common( - &mut self, - ecx: &mut EvmContext, - mut input: Input, - ) -> Option + fn create_common(&mut self, ecx: Ecx, mut input: Input) -> Option where - DB: DatabaseExt, - Input: CommonCreateInput, + Input: CommonCreateInput, { let ecx = &mut ecx.inner; let gas = Gas::new(input.gas_limit()); @@ -717,14 +693,8 @@ impl Cheatcodes { } // common create_end functionality for both legacy and EOF. - fn create_end_common( - &mut self, - ecx: &mut EvmContext, - mut outcome: CreateOutcome, - ) -> CreateOutcome - where - DB: DatabaseExt, - { + fn create_end_common(&mut self, ecx: Ecx, mut outcome: CreateOutcome) -> CreateOutcome +where { let ecx = &mut ecx.inner; // Clean up pranks @@ -831,9 +801,9 @@ impl Cheatcodes { outcome } - pub fn call_with_executor( + pub fn call_with_executor( &mut self, - ecx: &mut EvmContext, + ecx: Ecx, call: &mut CallInputs, executor: &mut impl CheatcodesExecutor, ) -> Option { @@ -1127,9 +1097,9 @@ impl Cheatcodes { } } -impl Inspector for Cheatcodes { +impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { #[inline] - fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: Ecx) { // When the first interpreter is initialized we've circumvented the balance and gas checks, // so we apply our actual block data with the correct fees and all. if let Some(block) = self.block.take() { @@ -1146,7 +1116,7 @@ impl Inspector for Cheatcodes { } #[inline] - fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn step(&mut self, interpreter: &mut Interpreter, ecx: Ecx) { self.pc = interpreter.program_counter(); // `pauseGasMetering`: pause / resume interpreter gas. @@ -1186,7 +1156,7 @@ impl Inspector for Cheatcodes { } #[inline] - fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn step_end(&mut self, interpreter: &mut Interpreter, ecx: Ecx) { if self.gas_metering.paused { self.meter_gas_end(interpreter); } @@ -1201,7 +1171,7 @@ impl Inspector for Cheatcodes { } } - fn log(&mut self, interpreter: &mut Interpreter, _ecx: &mut EvmContext, log: &Log) { + fn log(&mut self, interpreter: &mut Interpreter, _ecx: Ecx, log: &Log) { if !self.expected_emits.is_empty() { expect::handle_expect_emit(self, log, interpreter); } @@ -1216,16 +1186,11 @@ impl Inspector for Cheatcodes { } } - fn call(&mut self, ecx: &mut EvmContext, inputs: &mut CallInputs) -> Option { + fn call(&mut self, ecx: Ecx, inputs: &mut CallInputs) -> Option { Self::call_with_executor(self, ecx, inputs, &mut TransparentCheatcodesExecutor) } - fn call_end( - &mut self, - ecx: &mut EvmContext, - call: &CallInputs, - mut outcome: CallOutcome, - ) -> CallOutcome { + 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; @@ -1521,34 +1486,26 @@ impl Inspector for Cheatcodes { outcome } - fn create( - &mut self, - ecx: &mut EvmContext, - call: &mut CreateInputs, - ) -> Option { + fn create(&mut self, ecx: Ecx, call: &mut CreateInputs) -> Option { self.create_common(ecx, call) } fn create_end( &mut self, - ecx: &mut EvmContext, + ecx: Ecx, _call: &CreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { self.create_end_common(ecx, outcome) } - fn eofcreate( - &mut self, - ecx: &mut EvmContext, - call: &mut EOFCreateInputs, - ) -> Option { + fn eofcreate(&mut self, ecx: Ecx, call: &mut EOFCreateInputs) -> Option { self.create_common(ecx, call) } fn eofcreate_end( &mut self, - ecx: &mut EvmContext, + ecx: Ecx, _call: &EOFCreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { @@ -1556,12 +1513,8 @@ impl Inspector for Cheatcodes { } } -impl InspectorExt for Cheatcodes { - fn should_use_create2_factory( - &mut self, - ecx: &mut EvmContext, - inputs: &mut CreateInputs, - ) -> bool { +impl InspectorExt for Cheatcodes { + fn should_use_create2_factory(&mut self, ecx: Ecx, inputs: &mut CreateInputs) -> bool { if let CreateScheme::Create2 { .. } = inputs.scheme { let target_depth = if let Some(prank) = &self.prank { prank.depth @@ -1592,11 +1545,7 @@ impl Cheatcodes { } #[cold] - fn meter_gas_record( - &mut self, - interpreter: &mut Interpreter, - ecx: &mut EvmContext, - ) { + fn meter_gas_record(&mut self, interpreter: &mut Interpreter, ecx: Ecx) { if matches!(interpreter.instruction_result, InstructionResult::Continue) { self.gas_metering.gas_records.iter_mut().for_each(|record| { if ecx.journaled_state.depth() == record.depth { @@ -1652,11 +1601,7 @@ impl Cheatcodes { /// cache) from mapped source address to the target address. /// - generates arbitrary value and saves it in target address storage. #[cold] - fn arbitrary_storage_end( - &mut self, - interpreter: &mut Interpreter, - ecx: &mut EvmContext, - ) { + fn arbitrary_storage_end(&mut self, interpreter: &mut Interpreter, ecx: Ecx) { let (key, target_address) = if interpreter.current_opcode() == op::SLOAD { (try_or_return!(interpreter.stack().peek(0)), interpreter.contract().target_address) } else { @@ -1706,11 +1651,7 @@ impl Cheatcodes { } #[cold] - fn record_state_diffs( - &mut self, - interpreter: &mut Interpreter, - ecx: &mut EvmContext, - ) { + fn record_state_diffs(&mut self, interpreter: &mut Interpreter, ecx: Ecx) { let Some(account_accesses) = &mut self.recorded_account_diffs_stack else { return }; match interpreter.current_opcode() { op::SELFDESTRUCT => { @@ -2057,10 +1998,7 @@ fn disallowed_mem_write( // Determines if the gas limit on a given call was manually set in the script and should therefore // not be overwritten by later estimations -fn check_if_fixed_gas_limit( - ecx: &InnerEvmContext, - call_gas_limit: u64, -) -> bool { +fn check_if_fixed_gas_limit(ecx: InnerEcx, call_gas_limit: u64) -> bool { // If the gas limit was not set in the source code it is set to the estimated gas left at the // time of the call, which should be rather close to configured gas limit. // TODO: Find a way to reliably make this determination. @@ -2130,44 +2068,25 @@ fn append_storage_access( } /// Dispatches the cheatcode call to the appropriate function. -fn apply_dispatch( +fn apply_dispatch( calls: &Vm::VmCalls, - ccx: &mut CheatsCtxt, - executor: &mut E, + ccx: &mut CheatsCtxt, + executor: &mut dyn CheatcodesExecutor, ) -> Result { - // TODO: Replace with `::apply_full` once it's object-safe. - macro_rules! dispatch { - ($($variant:ident),*) => { - match calls { - $(Vm::VmCalls::$variant(cheat) => crate::Cheatcode::apply_full(cheat, ccx, executor),)* - } - }; - } - let cheat = calls_as_dyn_cheatcode(calls); + + let _guard = debug_span!(target: "cheatcodes", "apply", id = %cheat.id()).entered(); + trace!(target: "cheatcodes", cheat = ?cheat.as_debug(), "applying"); + if let spec::Status::Deprecated(replacement) = *cheat.status() { ccx.state.deprecated.insert(cheat.signature(), replacement); } - let _guard = trace_span_and_call(cheat); - let mut result = vm_calls!(dispatch); - fill_and_trace_return(cheat, &mut result); - result -} -/// Helper function to check if frame execution will exit. -fn will_exit(ir: InstructionResult) -> bool { - !matches!(ir, InstructionResult::Continue | InstructionResult::CallOrCreate) -} + // Apply the cheatcode. + let mut result = cheat.dyn_apply(ccx, executor); -fn trace_span_and_call(cheat: &dyn DynCheatcode) -> tracing::span::EnteredSpan { - let span = debug_span!(target: "cheatcodes", "apply", id = %cheat.id()); - let entered = span.entered(); - trace!(target: "cheatcodes", cheat = ?cheat.as_debug(), "applying"); - entered -} - -fn fill_and_trace_return(cheat: &dyn DynCheatcode, result: &mut Result) { - if let Err(e) = result { + // Format the error message to include the cheatcode name. + if let Err(e) = &mut result { if e.is_str() { let name = cheat.name(); // Skip showing the cheatcode name for: @@ -2178,13 +2097,16 @@ fn fill_and_trace_return(cheat: &dyn DynCheatcode, result: &mut Result) { } } } + trace!( target: "cheatcodes", - return = %match result { + return = %match &result { Ok(b) => hex::encode(b), Err(e) => e.to_string(), } ); + + result } fn calls_as_dyn_cheatcode(calls: &Vm::VmCalls) -> &dyn DynCheatcode { @@ -2197,3 +2119,8 @@ fn calls_as_dyn_cheatcode(calls: &Vm::VmCalls) -> &dyn DynCheatcode { } vm_calls!(as_dyn) } + +/// Helper function to check if frame execution will exit. +fn will_exit(ir: InstructionResult) -> bool { + !matches!(ir, InstructionResult::Continue | InstructionResult::CallOrCreate) +} diff --git a/crates/cheatcodes/src/inspector/utils.rs b/crates/cheatcodes/src/inspector/utils.rs index dfccd4b55552c..a0d7820aa3e27 100644 --- a/crates/cheatcodes/src/inspector/utils.rs +++ b/crates/cheatcodes/src/inspector/utils.rs @@ -1,13 +1,10 @@ +use super::InnerEcx; use crate::inspector::Cheatcodes; use alloy_primitives::{Address, Bytes, U256}; -use foundry_evm_core::backend::DatabaseExt; -use revm::{ - interpreter::{CreateInputs, CreateScheme, EOFCreateInputs, EOFCreateKind}, - InnerEvmContext, -}; +use revm::interpreter::{CreateInputs, CreateScheme, EOFCreateInputs, EOFCreateKind}; /// Common behaviour of legacy and EOF create inputs. -pub(crate) trait CommonCreateInput { +pub(crate) trait CommonCreateInput { fn caller(&self) -> Address; fn gas_limit(&self) -> u64; fn value(&self) -> U256; @@ -15,15 +12,11 @@ pub(crate) trait CommonCreateInput { fn scheme(&self) -> Option; fn set_caller(&mut self, caller: Address); fn log_debug(&self, cheatcode: &mut Cheatcodes, scheme: &CreateScheme); - fn allow_cheatcodes( - &self, - cheatcodes: &mut Cheatcodes, - ecx: &mut InnerEvmContext, - ) -> Address; + fn allow_cheatcodes(&self, cheatcodes: &mut Cheatcodes, ecx: InnerEcx) -> Address; fn computed_created_address(&self) -> Option
; } -impl CommonCreateInput for &mut CreateInputs { +impl CommonCreateInput for &mut CreateInputs { fn caller(&self) -> Address { self.caller } @@ -49,11 +42,7 @@ impl CommonCreateInput for &mut CreateInputs { }; debug!(target: "cheatcodes", tx=?cheatcode.broadcastable_transactions.back().unwrap(), "broadcastable {kind}"); } - fn allow_cheatcodes( - &self, - cheatcodes: &mut Cheatcodes, - ecx: &mut InnerEvmContext, - ) -> Address { + fn allow_cheatcodes(&self, cheatcodes: &mut Cheatcodes, ecx: InnerEcx) -> Address { let old_nonce = ecx .journaled_state .state @@ -69,7 +58,7 @@ impl CommonCreateInput for &mut CreateInputs { } } -impl CommonCreateInput for &mut EOFCreateInputs { +impl CommonCreateInput for &mut EOFCreateInputs { fn caller(&self) -> Address { self.caller } @@ -94,13 +83,9 @@ impl CommonCreateInput for &mut EOFCreateInputs { fn log_debug(&self, cheatcode: &mut Cheatcodes, _scheme: &CreateScheme) { debug!(target: "cheatcodes", tx=?cheatcode.broadcastable_transactions.back().unwrap(), "broadcastable eofcreate"); } - fn allow_cheatcodes( - &self, - cheatcodes: &mut Cheatcodes, - ecx: &mut InnerEvmContext, - ) -> Address { + fn allow_cheatcodes(&self, cheatcodes: &mut Cheatcodes, ecx: InnerEcx) -> Address { let created_address = - <&mut EOFCreateInputs as CommonCreateInput>::computed_created_address(self) + <&mut EOFCreateInputs as CommonCreateInput>::computed_created_address(self) .unwrap_or_default(); cheatcodes.allow_cheatcodes_on_create(ecx, self.caller, created_address); created_address diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 50bd54701919d..a257289916cd7 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -70,7 +70,7 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { /// /// Implement this function if you need access to the EVM data. #[inline(always)] - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { self.apply(ccx.state) } @@ -78,58 +78,69 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { /// /// Implement this function if you need access to the executor. #[inline(always)] - fn apply_full( - &self, - ccx: &mut CheatsCtxt, - executor: &mut E, - ) -> Result { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let _ = executor; self.apply_stateful(ccx) } } pub(crate) trait DynCheatcode { - fn name(&self) -> &'static str; - fn id(&self) -> &'static str; - fn signature(&self) -> &'static str; - fn status(&self) -> &Status<'static>; - fn as_debug(&self) -> &dyn std::fmt::Debug; -} + fn cheatcode(&self) -> &'static spec::Cheatcode<'static>; -impl DynCheatcode for T { fn name(&self) -> &'static str { - T::CHEATCODE.func.signature.split('(').next().unwrap() + self.cheatcode().func.signature.split('(').next().unwrap() } + fn id(&self) -> &'static str { - T::CHEATCODE.func.id + self.cheatcode().func.id } + fn signature(&self) -> &'static str { - T::CHEATCODE.func.signature + self.cheatcode().func.signature } + fn status(&self) -> &Status<'static> { - &T::CHEATCODE.status + &self.cheatcode().status } + + fn as_debug(&self) -> &dyn std::fmt::Debug; + + fn dyn_apply(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result; +} + +impl DynCheatcode for T { + #[inline] + fn cheatcode(&self) -> &'static spec::Cheatcode<'static> { + Self::CHEATCODE + } + + #[inline] fn as_debug(&self) -> &dyn std::fmt::Debug { self } + + #[inline] + fn dyn_apply(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { + self.apply_full(ccx, executor) + } } /// The cheatcode context, used in `Cheatcode`. -pub struct CheatsCtxt<'cheats, 'evm, DB: DatabaseExt> { +pub struct CheatsCtxt<'cheats, 'evm, 'db, 'db2> { /// The cheatcodes inspector state. pub(crate) state: &'cheats mut Cheatcodes, /// The EVM data. - pub(crate) ecx: &'evm mut InnerEvmContext, + pub(crate) ecx: &'evm mut InnerEvmContext<&'db mut (dyn DatabaseExt + 'db2)>, /// The precompiles context. - pub(crate) precompiles: &'evm mut ContextPrecompiles, + pub(crate) precompiles: &'evm mut ContextPrecompiles<&'db mut (dyn DatabaseExt + 'db2)>, /// The original `msg.sender`. pub(crate) caller: Address, /// Gas limit of the current cheatcode call. pub(crate) gas_limit: u64, } -impl<'cheats, 'evm, DB: DatabaseExt> std::ops::Deref for CheatsCtxt<'cheats, 'evm, DB> { - type Target = InnerEvmContext; +impl<'db, 'db2> std::ops::Deref for CheatsCtxt<'_, '_, 'db, 'db2> { + type Target = InnerEvmContext<&'db mut (dyn DatabaseExt + 'db2)>; #[inline(always)] fn deref(&self) -> &Self::Target { @@ -137,14 +148,14 @@ impl<'cheats, 'evm, DB: DatabaseExt> std::ops::Deref for CheatsCtxt<'cheats, 'ev } } -impl<'cheats, 'evm, DB: DatabaseExt> std::ops::DerefMut for CheatsCtxt<'cheats, 'evm, DB> { +impl std::ops::DerefMut for CheatsCtxt<'_, '_, '_, '_> { #[inline(always)] fn deref_mut(&mut self) -> &mut Self::Target { &mut *self.ecx } } -impl<'cheats, 'evm, DB: DatabaseExt> CheatsCtxt<'cheats, 'evm, DB> { +impl CheatsCtxt<'_, '_, '_, '_> { #[inline] pub(crate) fn is_precompile(&self, address: &Address) -> bool { self.precompiles.contains(address) diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 82eef2354994a..93d5aaaf8d349 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -1,6 +1,6 @@ //! Implementations of [`Scripting`](spec::Group::Scripting) cheatcodes. -use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use crate::{Cheatcode, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, B256, U256}; use alloy_signer_local::PrivateKeySigner; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; @@ -8,49 +8,49 @@ use parking_lot::Mutex; use std::sync::Arc; impl Cheatcode for broadcast_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; broadcast(ccx, None, true) } } impl Cheatcode for broadcast_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { signer } = self; broadcast(ccx, Some(signer), true) } } impl Cheatcode for broadcast_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; broadcast_key(ccx, privateKey, true) } } impl Cheatcode for startBroadcast_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; broadcast(ccx, None, false) } } impl Cheatcode for startBroadcast_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { signer } = self; broadcast(ccx, Some(signer), false) } } impl Cheatcode for startBroadcast_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { privateKey } = self; broadcast_key(ccx, privateKey, false) } } impl Cheatcode for stopBroadcastCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; let Some(broadcast) = ccx.state.broadcast.take() else { bail!("no broadcast in progress to stop"); @@ -123,11 +123,7 @@ impl ScriptWallets { } /// Sets up broadcasting from a script using `new_origin` as the sender. -fn broadcast( - ccx: &mut CheatsCtxt, - new_origin: Option<&Address>, - single_call: bool, -) -> Result { +fn broadcast(ccx: &mut CheatsCtxt, new_origin: Option<&Address>, single_call: bool) -> Result { ensure!( ccx.state.prank.is_none(), "you have an active prank; broadcasting and pranks are not compatible" @@ -166,11 +162,7 @@ fn broadcast( /// Sets up broadcasting from a script with the sender derived from `private_key`. /// Adds this private key to `state`'s `script_wallets` vector to later be used for signing /// if broadcast is successful. -fn broadcast_key( - ccx: &mut CheatsCtxt, - private_key: &U256, - single_call: bool, -) -> Result { +fn broadcast_key(ccx: &mut CheatsCtxt, private_key: &U256, single_call: bool) -> Result { let wallet = super::crypto::parse_wallet(private_key)?; let new_origin = wallet.address(); diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index cc91dba45b23d..bd723c9312ea2 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -1,26 +1,25 @@ //! Implementations of [`Testing`](spec::Group::Testing) cheatcodes. -use chrono::DateTime; -use std::env; - -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::Address; use alloy_sol_types::SolValue; +use chrono::DateTime; use foundry_evm_core::constants::MAGIC_SKIP; +use std::env; pub(crate) mod assert; pub(crate) mod assume; pub(crate) mod expect; impl Cheatcode for breakpoint_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { char } = self; breakpoint(ccx.state, &ccx.caller, char, true) } } impl Cheatcode for breakpoint_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { char, value } = self; breakpoint(ccx.state, &ccx.caller, char, *value) } @@ -71,14 +70,14 @@ impl Cheatcode for sleepCall { } impl Cheatcode for skip_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { skipTest } = *self; skip_1Call { skipTest, reason: String::new() }.apply_stateful(ccx) } } impl Cheatcode for skip_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { skipTest, reason } = self; if *skipTest { // Skip should not work if called deeper than at test level. diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index 4ab97c031e5a8..5161716fae56c 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -2,7 +2,7 @@ use crate::{CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{hex, I256, U256}; use foundry_evm_core::{ abi::{format_units_int, format_units_uint}, - backend::{DatabaseExt, GLOBAL_FAIL_SLOT}, + backend::GLOBAL_FAIL_SLOT, constants::CHEATCODE_ADDRESS, }; use itertools::Itertools; @@ -169,10 +169,10 @@ impl EqRelAssertionError { type ComparisonResult<'a, T> = Result, ComparisonAssertionError<'a, T>>; -fn handle_assertion_result( +fn handle_assertion_result( result: core::result::Result, ERR>, - ccx: &mut CheatsCtxt, - executor: &mut E, + ccx: &mut CheatsCtxt, + executor: &mut dyn CheatcodesExecutor, error_formatter: impl Fn(&ERR) -> String, error_msg: Option<&str>, format_error: bool, @@ -224,10 +224,10 @@ macro_rules! impl_assertions { }; (@impl $no_error:ident, $with_error:ident, ($($arg:ident),*), $body:expr, $error_formatter:expr, $format_error:literal) => { impl crate::Cheatcode for $no_error { - fn apply_full( + fn apply_full( &self, - ccx: &mut CheatsCtxt, - executor: &mut E, + ccx: &mut CheatsCtxt, + executor: &mut dyn CheatcodesExecutor, ) -> Result { let Self { $($arg),* } = self; handle_assertion_result($body, ccx, executor, $error_formatter, None, $format_error) @@ -235,10 +235,10 @@ macro_rules! impl_assertions { } impl crate::Cheatcode for $with_error { - fn apply_full( + fn apply_full( &self, - ccx: &mut CheatsCtxt, - executor: &mut E, + ccx: &mut CheatsCtxt, + executor: &mut dyn CheatcodesExecutor, ) -> Result { let Self { $($arg),*, error} = self; handle_assertion_result($body, ccx, executor, $error_formatter, Some(error), $format_error) diff --git a/crates/cheatcodes/src/test/assume.rs b/crates/cheatcodes/src/test/assume.rs index e100eeb9d1c43..a0321b5a1cd38 100644 --- a/crates/cheatcodes/src/test/assume.rs +++ b/crates/cheatcodes/src/test/assume.rs @@ -1,5 +1,5 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result}; -use foundry_evm_core::{backend::DatabaseExt, constants::MAGIC_ASSUME}; +use foundry_evm_core::constants::MAGIC_ASSUME; use spec::Vm::{assumeCall, assumeNoRevertCall}; use std::fmt::Debug; @@ -21,7 +21,7 @@ impl Cheatcode for assumeCall { } impl Cheatcode for assumeNoRevertCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { ccx.state.assume_no_revert = Some(AssumeNoRevert { depth: ccx.ecx.journaled_state.depth() }); Ok(Default::default()) diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index f38776f94bfd5..7a58c7ab8aa81 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,4 +1,4 @@ -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Error, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result, Vm::*}; use alloy_primitives::{address, hex, Address, Bytes, LogData as RawLog, U256}; use alloy_sol_types::{SolError, SolValue}; use foundry_common::ContractsByArtifact; @@ -210,7 +210,7 @@ impl Cheatcode for expectCallMinGas_1Call { } impl Cheatcode for expectEmit_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { checkTopic1, checkTopic2, checkTopic3, checkData } = *self; expect_emit( ccx.state, @@ -223,7 +223,7 @@ impl Cheatcode for expectEmit_0Call { } impl Cheatcode for expectEmit_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { checkTopic1, checkTopic2, checkTopic3, checkData, emitter } = *self; expect_emit( ccx.state, @@ -236,21 +236,21 @@ impl Cheatcode for expectEmit_1Call { } impl Cheatcode for expectEmit_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, false) } } impl Cheatcode for expectEmit_3Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { emitter } = *self; expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), false) } } impl Cheatcode for expectEmitAnonymous_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData } = *self; expect_emit( ccx.state, @@ -263,7 +263,7 @@ impl Cheatcode for expectEmitAnonymous_0Call { } impl Cheatcode for expectEmitAnonymous_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData, emitter } = *self; expect_emit( ccx.state, @@ -276,28 +276,28 @@ impl Cheatcode for expectEmitAnonymous_1Call { } impl Cheatcode for expectEmitAnonymous_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, true) } } impl Cheatcode for expectEmitAnonymous_3Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { emitter } = *self; expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), true) } } impl Cheatcode for expectRevert_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false, false, None) } } impl Cheatcode for expectRevert_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert( ccx.state, @@ -311,7 +311,7 @@ impl Cheatcode for expectRevert_1Call { } impl Cheatcode for expectRevert_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert( ccx.state, @@ -325,7 +325,7 @@ impl Cheatcode for expectRevert_2Call { } impl Cheatcode for expectRevert_3Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { reverter } = self; expect_revert( ccx.state, @@ -339,7 +339,7 @@ impl Cheatcode for expectRevert_3Call { } impl Cheatcode for expectRevert_4Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData, reverter } = self; expect_revert( ccx.state, @@ -353,7 +353,7 @@ impl Cheatcode for expectRevert_4Call { } impl Cheatcode for expectRevert_5Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData, reverter } = self; expect_revert( ccx.state, @@ -367,7 +367,7 @@ impl Cheatcode for expectRevert_5Call { } impl Cheatcode for expectPartialRevert_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert( ccx.state, @@ -381,7 +381,7 @@ impl Cheatcode for expectPartialRevert_0Call { } impl Cheatcode for expectPartialRevert_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData, reverter } = self; expect_revert( ccx.state, @@ -395,13 +395,13 @@ impl Cheatcode for expectPartialRevert_1Call { } impl Cheatcode for _expectCheatcodeRevert_0Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true, false, None) } } impl Cheatcode for _expectCheatcodeRevert_1Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert( ccx.state, @@ -415,7 +415,7 @@ impl Cheatcode for _expectCheatcodeRevert_1Call { } impl Cheatcode for _expectCheatcodeRevert_2Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { revertData } = self; expect_revert( ccx.state, @@ -429,14 +429,14 @@ impl Cheatcode for _expectCheatcodeRevert_2Call { } impl Cheatcode for expectSafeMemoryCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { min, max } = *self; expect_safe_memory(ccx.state, min, max, ccx.ecx.journaled_state.depth()) } } impl Cheatcode for stopExpectSafeMemoryCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; ccx.state.allowed_mem_writes.remove(&ccx.ecx.journaled_state.depth()); Ok(Default::default()) @@ -444,7 +444,7 @@ impl Cheatcode for stopExpectSafeMemoryCall { } impl Cheatcode for expectSafeMemoryCallCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { min, max } = *self; expect_safe_memory(ccx.state, min, max, ccx.ecx.journaled_state.depth() + 1) } diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index eb4d2f525a4fb..23cc02f7ad9de 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -1,12 +1,12 @@ //! Implementations of [`Utilities`](spec::Group::Utilities) cheatcodes. -use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{map::HashMap, U256}; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; -use foundry_evm_core::{backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER}; -use proptest::strategy::{Strategy, ValueTree}; +use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; +use proptest::prelude::Strategy; use rand::{Rng, RngCore}; /// Contains locations of traces ignored via cheatcodes. @@ -134,10 +134,10 @@ impl Cheatcode for randomBytesCall { } impl Cheatcode for pauseTracingCall { - fn apply_full( + fn apply_full( &self, - ccx: &mut crate::CheatsCtxt, - executor: &mut E, + ccx: &mut crate::CheatsCtxt, + executor: &mut dyn CheatcodesExecutor, ) -> Result { let Some(tracer) = executor.tracing_inspector().and_then(|t| t.as_ref()) else { // No tracer -> nothing to pause @@ -157,10 +157,10 @@ impl Cheatcode for pauseTracingCall { } impl Cheatcode for resumeTracingCall { - fn apply_full( + fn apply_full( &self, - ccx: &mut crate::CheatsCtxt, - executor: &mut E, + ccx: &mut crate::CheatsCtxt, + executor: &mut dyn CheatcodesExecutor, ) -> Result { let Some(tracer) = executor.tracing_inspector().and_then(|t| t.as_ref()) else { // No tracer -> nothing to unpause @@ -180,7 +180,7 @@ impl Cheatcode for resumeTracingCall { } impl Cheatcode for setArbitraryStorageCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { target } = self; ccx.state.arbitrary_storage().mark_arbitrary(target); @@ -189,7 +189,7 @@ impl Cheatcode for setArbitraryStorageCall { } impl Cheatcode for copyStorageCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { from, to } = self; ensure!( diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 8156d75fbddfd..1589c8ee8ec9f 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -62,20 +62,16 @@ impl<'a> CowBackend<'a> { /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. #[instrument(name = "inspect", level = "debug", skip_all)] - pub fn inspect<'b, I: InspectorExt<&'b mut dyn DatabaseExt>>( - &'b mut self, + pub fn inspect( + &mut self, env: &mut EnvWithHandlerCfg, - inspector: I, + inspector: &mut dyn InspectorExt, ) -> eyre::Result { // this is a new call to inspect with a new env, so even if we've cloned the backend // already, we reset the initialized state self.is_initialized = false; self.spec_id = env.handler_cfg.spec_id; - let mut evm = crate::utils::new_evm_with_inspector( - self as &mut dyn DatabaseExt, - env.clone(), - inspector, - ); + let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); let res = evm.transact().wrap_err("backend: failed while inspecting")?; @@ -190,7 +186,7 @@ impl<'a> DatabaseExt for CowBackend<'a> { transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: &mut dyn InspectorExt, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { self.backend_mut(env).transact(id, transaction, env, journaled_state, inspector) } @@ -200,7 +196,7 @@ impl<'a> DatabaseExt for CowBackend<'a> { transaction: TransactionRequest, env: &Env, journaled_state: &mut JournaledState, - inspector: &mut dyn InspectorExt, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { self.backend_mut(env).transact_from_tx(transaction, env, journaled_state, inspector) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 07ee7013012e5..9d26ce2873590 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -200,7 +200,7 @@ pub trait DatabaseExt: Database + DatabaseCommit { transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: &mut dyn InspectorExt, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()>; /// Executes a given TransactionRequest, commits the new state to the DB @@ -209,7 +209,7 @@ pub trait DatabaseExt: Database + DatabaseCommit { transaction: TransactionRequest, env: &Env, journaled_state: &mut JournaledState, - inspector: &mut dyn InspectorExt, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()>; /// Returns the `ForkId` that's currently used in the database, if fork mode is on @@ -751,17 +751,13 @@ impl Backend { /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. #[instrument(name = "inspect", level = "debug", skip_all)] - pub fn inspect<'a, I: InspectorExt<&'a mut dyn DatabaseExt>>( - &'a mut self, + pub fn inspect( + &mut self, env: &mut EnvWithHandlerCfg, - inspector: I, + inspector: &mut dyn InspectorExt, ) -> eyre::Result { self.initialize(env); - let mut evm = crate::utils::new_evm_with_inspector( - self as &mut dyn DatabaseExt, - env.clone(), - inspector, - ); + let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); let res = evm.transact().wrap_err("backend: failed while inspecting")?; @@ -1229,7 +1225,7 @@ impl DatabaseExt for Backend { transaction: B256, env: &mut Env, journaled_state: &mut JournaledState, - inspector: &mut dyn InspectorExt, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { trace!(?maybe_id, ?transaction, "execute transaction"); let persistent_accounts = self.inner.persistent_accounts.clone(); @@ -1270,7 +1266,7 @@ impl DatabaseExt for Backend { tx: TransactionRequest, env: &Env, journaled_state: &mut JournaledState, - inspector: &mut dyn InspectorExt, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { trace!(?tx, "execute signed transaction"); @@ -1294,9 +1290,9 @@ impl DatabaseExt for Backend { self.commit(journaled_state.state.clone()); let res = { - let db = self.clone(); + let mut db = self.clone(); let env = self.env_with_handler_cfg(env); - let mut evm = new_evm_with_inspector(db, env, inspector); + let mut evm = new_evm_with_inspector(&mut db, env, inspector); evm.context.evm.journaled_state.depth = journaled_state.depth + 1; evm.transact()? }; @@ -1921,7 +1917,7 @@ fn commit_transaction( fork: &mut Fork, fork_id: &ForkId, persistent_accounts: &HashSet
, - inspector: &mut dyn InspectorExt, + inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { configure_tx_env(&mut env.env, tx); @@ -1930,9 +1926,9 @@ fn commit_transaction( let fork = fork.clone(); let journaled_state = journaled_state.clone(); let depth = journaled_state.depth; - let db = Backend::new_with_fork(fork_id, fork, journaled_state); + let mut db = Backend::new_with_fork(fork_id, fork, journaled_state); - let mut evm = crate::utils::new_evm_with_inspector(db, env, inspector); + let mut evm = crate::utils::new_evm_with_inspector(&mut db as _, env, inspector); // Adjust inner EVM depth to ensure that inspectors receive accurate data. evm.context.evm.inner.journaled_state.depth = depth + 1; evm.transact().wrap_err("backend: failed committing transaction")? diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index b30a36544b488..b6da4b49a5d97 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -6,7 +6,8 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use auto_impl::auto_impl; -use revm::{inspectors::NoOpInspector, interpreter::CreateInputs, Database, EvmContext, Inspector}; +use backend::DatabaseExt; +use revm::{inspectors::NoOpInspector, interpreter::CreateInputs, EvmContext, Inspector}; use revm_inspectors::access_list::AccessListInspector; #[macro_use] @@ -32,14 +33,14 @@ pub mod utils; /// An extension trait that allows us to add additional hooks to Inspector for later use in /// handlers. #[auto_impl(&mut, Box)] -pub trait InspectorExt: Inspector { +pub trait InspectorExt: for<'a> Inspector<&'a mut dyn DatabaseExt> { /// Determines whether the `DEFAULT_CREATE2_DEPLOYER` should be used for a CREATE2 frame. /// /// If this function returns true, we'll replace CREATE2 frame with a CALL frame to CREATE2 /// factory. fn should_use_create2_factory( &mut self, - _context: &mut EvmContext, + _context: &mut EvmContext<&mut dyn DatabaseExt>, _inputs: &mut CreateInputs, ) -> bool { false @@ -54,5 +55,6 @@ pub trait InspectorExt: Inspector { } } -impl InspectorExt for NoOpInspector {} -impl InspectorExt for AccessListInspector {} +impl InspectorExt for NoOpInspector {} + +impl InspectorExt for AccessListInspector {} diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 19782ee9da512..d45c4b84908a8 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,5 +1,8 @@ pub use crate::ic::*; -use crate::{constants::DEFAULT_CREATE2_DEPLOYER, precompiles::ALPHANET_P256, InspectorExt}; +use crate::{ + backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER, precompiles::ALPHANET_P256, + InspectorExt, +}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Selector, TxKind, U256}; use alloy_provider::{ @@ -8,8 +11,8 @@ use alloy_provider::{ }; use alloy_rpc_types::Transaction; use foundry_config::NamedChain; +use foundry_fork_db::DatabaseError; use revm::{ - db::WrapDatabaseRef, handler::register::EvmHandler, interpreter::{ return_ok, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, @@ -123,15 +126,15 @@ fn get_create2_factory_call_inputs(salt: U256, inputs: CreateInputs) -> CallInpu /// hook by inserting decoded address directly into interpreter. /// /// Should be installed after [revm::inspector_handle_register] and before any other registers. -pub fn create2_handler_register>( - handler: &mut EvmHandler<'_, I, DB>, +pub fn create2_handler_register( + handler: &mut EvmHandler<'_, I, &mut dyn DatabaseExt>, ) { let create2_overrides = Rc::>>::new(RefCell::new(Vec::new())); let create2_overrides_inner = create2_overrides.clone(); let old_handle = handler.execution.create.clone(); handler.execution.create = - Arc::new(move |ctx, mut inputs| -> Result> { + Arc::new(move |ctx, mut inputs| -> Result> { let CreateScheme::Create2 { salt } = inputs.scheme else { return old_handle(ctx, inputs); }; @@ -219,9 +222,7 @@ pub fn create2_handler_register>( } /// Adds Alphanet P256 precompile to the list of loaded precompiles. -pub fn alphanet_handler_register>( - handler: &mut EvmHandler<'_, I, DB>, -) { +pub fn alphanet_handler_register(handler: &mut EvmHandler<'_, EXT, DB>) { let prev = handler.pre_execution.load_precompiles.clone(); handler.pre_execution.load_precompiles = Arc::new(move || { let mut loaded_precompiles = prev(); @@ -233,15 +234,11 @@ pub fn alphanet_handler_register>( } /// Creates a new EVM with the given inspector. -pub fn new_evm_with_inspector<'a, DB, I>( - db: DB, +pub fn new_evm_with_inspector<'evm, 'i, 'db>( + db: &'db mut dyn DatabaseExt, env: revm::primitives::EnvWithHandlerCfg, - inspector: I, -) -> revm::Evm<'a, I, DB> -where - DB: revm::Database, - I: InspectorExt, -{ + inspector: &'i mut dyn InspectorExt, +) -> revm::Evm<'evm, &'i mut dyn InspectorExt, &'db mut dyn DatabaseExt> { let revm::primitives::EnvWithHandlerCfg { env, handler_cfg } = env; // NOTE: We could use `revm::Evm::builder()` here, but on the current patch it has some @@ -269,27 +266,10 @@ where revm::Evm::new(context, handler) } -/// Creates a new EVM with the given inspector and wraps the database in a `WrapDatabaseRef`. -pub fn new_evm_with_inspector_ref<'a, DB, I>( - db: DB, - env: revm::primitives::EnvWithHandlerCfg, - inspector: I, -) -> revm::Evm<'a, I, WrapDatabaseRef> -where - DB: revm::DatabaseRef, - I: InspectorExt>, -{ - new_evm_with_inspector(WrapDatabaseRef(db), env, inspector) -} - -pub fn new_evm_with_existing_context<'a, DB, I>( - inner: revm::InnerEvmContext, - inspector: I, -) -> revm::Evm<'a, I, DB> -where - DB: revm::Database, - I: InspectorExt, -{ +pub fn new_evm_with_existing_context<'a>( + inner: revm::InnerEvmContext<&'a mut dyn DatabaseExt>, + inspector: &'a mut dyn InspectorExt, +) -> revm::Evm<'a, &'a mut dyn InspectorExt, &'a mut dyn DatabaseExt> { let handler_cfg = HandlerCfg::new(inner.spec_id()); let mut handler = revm::Handler::new(handler_cfg); @@ -303,24 +283,3 @@ where revm::Context::new(revm::EvmContext { inner, precompiles: Default::default() }, inspector); revm::Evm::new(context, handler) } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn build_evm() { - let mut db = revm::db::EmptyDB::default(); - - let env = Box::::default(); - let spec = SpecId::LATEST; - let handler_cfg = revm::primitives::HandlerCfg::new(spec); - let cfg = revm::primitives::EnvWithHandlerCfg::new(env, handler_cfg); - - let mut inspector = revm::inspectors::NoOpInspector; - - let mut evm = new_evm_with_inspector(&mut db, cfg, &mut inspector); - let result = evm.transact().unwrap(); - assert!(result.result.is_success()); - } -} diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index 03b677fcdf844..877101a8064f0 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -60,7 +60,7 @@ impl Inspector for LogCollector { gas: Gas::new(inputs.gas_limit), }, memory_offset: inputs.return_memory_offset.clone(), - }) + }); } } @@ -68,7 +68,7 @@ impl Inspector for LogCollector { } } -impl InspectorExt for LogCollector { +impl InspectorExt for LogCollector { fn console_log(&mut self, input: String) { self.logs.push(Log::new_unchecked( HARDHAT_CONSOLE_ADDRESS, diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index fc270564133ad..c8df2c693102c 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -304,11 +304,8 @@ pub struct InspectorStackRefMut<'a> { } impl CheatcodesExecutor for InspectorStackInner { - fn get_inspector<'a, DB: DatabaseExt>( - &'a mut self, - cheats: &'a mut Cheatcodes, - ) -> impl InspectorExt + 'a { - InspectorStackRefMut { cheatcodes: Some(cheats), inner: self } + fn get_inspector<'a>(&'a mut self, cheats: &'a mut Cheatcodes) -> Box { + Box::new(InspectorStackRefMut { cheatcodes: Some(cheats), inner: self }) } fn tracing_inspector(&mut self) -> Option<&mut Option> { @@ -479,15 +476,15 @@ impl<'a> InspectorStackRefMut<'a> { /// Should be called on the top-level call of inner context (depth == 0 && /// self.in_inner_context) Decreases sender nonce for CALLs to keep backwards compatibility /// Updates tx.origin to the value before entering inner context - fn adjust_evm_data_for_inner_context(&mut self, ecx: &mut EvmContext) { + fn adjust_evm_data_for_inner_context(&mut self, ecx: &mut EvmContext<&mut dyn DatabaseExt>) { let inner_context_data = self.inner_context_data.as_ref().expect("should be called in inner context"); ecx.env.tx.caller = inner_context_data.original_origin; } - fn do_call_end( + fn do_call_end( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, inputs: &CallInputs, outcome: CallOutcome, ) -> CallOutcome { @@ -512,9 +509,9 @@ impl<'a> InspectorStackRefMut<'a> { outcome } - fn transact_inner( + fn transact_inner( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, transact_to: TransactTo, caller: Address, input: Bytes, @@ -547,11 +544,7 @@ impl<'a> InspectorStackRefMut<'a> { let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); let res = { - let mut evm = crate::utils::new_evm_with_inspector( - &mut ecx.db as &mut dyn DatabaseExt, - env, - &mut *self, - ); + let mut evm = crate::utils::new_evm_with_inspector(&mut ecx.db, env, self); let res = evm.transact(); // need to reset the env in case it was modified via cheatcodes during execution @@ -630,8 +623,12 @@ impl<'a> InspectorStackRefMut<'a> { } } -impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { - fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { +impl<'a> Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'a> { + fn initialize_interp( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + ) { call_inspectors_adjust_depth!( [&mut self.coverage, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.initialize_interp(interpreter, ecx), @@ -640,7 +637,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ); } - fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut dyn DatabaseExt>) { call_inspectors_adjust_depth!( [ &mut self.fuzzer, @@ -655,7 +652,11 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ); } - fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn step_end( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + ) { call_inspectors_adjust_depth!( [&mut self.tracer, &mut self.cheatcodes, &mut self.chisel_state, &mut self.printer], |inspector| inspector.step_end(interpreter, ecx), @@ -664,7 +665,12 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ); } - fn log(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext, log: &Log) { + fn log( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + log: &Log, + ) { call_inspectors_adjust_depth!( [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.log(interpreter, ecx, log), @@ -673,7 +679,11 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { ); } - fn call(&mut self, ecx: &mut EvmContext, call: &mut CallInputs) -> Option { + fn call( + &mut self, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + call: &mut CallInputs, + ) -> Option { if self.in_inner_context && ecx.journaled_state.depth == 0 { self.adjust_evm_data_for_inner_context(ecx); return None; @@ -739,7 +749,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { fn call_end( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, inputs: &CallInputs, outcome: CallOutcome, ) -> CallOutcome { @@ -764,7 +774,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { fn create( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, create: &mut CreateInputs, ) -> Option { if self.in_inner_context && ecx.journaled_state.depth == 0 { @@ -801,7 +811,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { fn create_end( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, call: &CreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { @@ -835,7 +845,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { fn eofcreate( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, create: &mut EOFCreateInputs, ) -> Option { if self.in_inner_context && ecx.journaled_state.depth == 0 { @@ -877,7 +887,7 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { fn eofcreate_end( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, call: &EOFCreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { @@ -911,15 +921,15 @@ impl<'a, DB: DatabaseExt> Inspector for InspectorStackRefMut<'a> { fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { call_inspectors!([&mut self.tracer, &mut self.printer], |inspector| { - Inspector::::selfdestruct(inspector, contract, target, value) + Inspector::<&mut dyn DatabaseExt>::selfdestruct(inspector, contract, target, value) }); } } -impl<'a, DB: DatabaseExt> InspectorExt for InspectorStackRefMut<'a> { +impl InspectorExt for InspectorStackRefMut<'_> { fn should_use_create2_factory( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, inputs: &mut CreateInputs, ) -> bool { call_inspectors_adjust_depth!( @@ -934,7 +944,7 @@ impl<'a, DB: DatabaseExt> InspectorExt for InspectorStackRefMut<'a> { } fn console_log(&mut self, input: String) { - call_inspectors!([&mut self.log_collector], |inspector| InspectorExt::::console_log( + call_inspectors!([&mut self.log_collector], |inspector| InspectorExt::console_log( inspector, input )); } @@ -944,20 +954,24 @@ impl<'a, DB: DatabaseExt> InspectorExt for InspectorStackRefMut<'a> { } } -impl Inspector for InspectorStack { +impl Inspector<&mut dyn DatabaseExt> for InspectorStack { #[inline] - fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut dyn DatabaseExt>) { self.as_mut().step(interpreter, ecx) } #[inline] - fn step_end(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn step_end( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + ) { self.as_mut().step_end(interpreter, ecx) } fn call( &mut self, - context: &mut EvmContext, + context: &mut EvmContext<&mut dyn DatabaseExt>, inputs: &mut CallInputs, ) -> Option { self.as_mut().call(context, inputs) @@ -965,7 +979,7 @@ impl Inspector for InspectorStack { fn call_end( &mut self, - context: &mut EvmContext, + context: &mut EvmContext<&mut dyn DatabaseExt>, inputs: &CallInputs, outcome: CallOutcome, ) -> CallOutcome { @@ -974,7 +988,7 @@ impl Inspector for InspectorStack { fn create( &mut self, - context: &mut EvmContext, + context: &mut EvmContext<&mut dyn DatabaseExt>, create: &mut CreateInputs, ) -> Option { self.as_mut().create(context, create) @@ -982,7 +996,7 @@ impl Inspector for InspectorStack { fn create_end( &mut self, - context: &mut EvmContext, + context: &mut EvmContext<&mut dyn DatabaseExt>, call: &CreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { @@ -991,7 +1005,7 @@ impl Inspector for InspectorStack { fn eofcreate( &mut self, - context: &mut EvmContext, + context: &mut EvmContext<&mut dyn DatabaseExt>, create: &mut EOFCreateInputs, ) -> Option { self.as_mut().eofcreate(context, create) @@ -999,30 +1013,39 @@ impl Inspector for InspectorStack { fn eofcreate_end( &mut self, - context: &mut EvmContext, + context: &mut EvmContext<&mut dyn DatabaseExt>, call: &EOFCreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { self.as_mut().eofcreate_end(context, call, outcome) } - fn initialize_interp(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext) { + fn initialize_interp( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + ) { self.as_mut().initialize_interp(interpreter, ecx) } - fn log(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext, log: &Log) { + fn log( + &mut self, + interpreter: &mut Interpreter, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + log: &Log, + ) { self.as_mut().log(interpreter, ecx, log) } fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) { - Inspector::::selfdestruct(&mut self.as_mut(), contract, target, value) + Inspector::<&mut dyn DatabaseExt>::selfdestruct(&mut self.as_mut(), contract, target, value) } } -impl InspectorExt for InspectorStack { +impl InspectorExt for InspectorStack { fn should_use_create2_factory( &mut self, - ecx: &mut EvmContext, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, inputs: &mut CreateInputs, ) -> bool { self.as_mut().should_use_create2_factory(ecx, inputs) From ecf37f2f22d8e0700ead0ebae3bd3a27761c1236 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 3 Oct 2024 11:51:09 +0400 Subject: [PATCH 1511/1963] feat: `--eof` flag and config key (#9002) * feat: --eof flag and config key * not windows --------- Co-authored-by: grandizzy --- Cargo.lock | 21 +++++----- Cargo.toml | 2 +- crates/cli/src/opts/build/core.rs | 13 +++++++ crates/config/Cargo.toml | 1 + crates/config/src/lib.rs | 61 ++++++++++++++++++++++++++++++ crates/forge/tests/cli/alphanet.rs | 19 ++++++++++ crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/main.rs | 1 + 8 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 crates/forge/tests/cli/alphanet.rs diff --git a/Cargo.lock b/Cargo.lock index 6c48e16b2bcbb..70ea8bef4cab0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3789,9 +3789,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "588bc1dd21020966a255a578433016d4637c810ed76127997a469bc4a3311e7f" +checksum = "7c6cc925fc9fdd73f1038c528fef17ddbdd7512311809ace7d1860fe3666dbb5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3827,9 +3827,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b12c7a7ab554fde7521428b040205569c187995b817481720e99adf524bf7f8" +checksum = "0d5c999c80c6d702c51522f5b4a805bec5fcae978637f0c337fa5c7a4b43d863" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3837,9 +3837,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4654933ab983928d8e33e7fdf425bb60553e8a4ac415a6014f1f2e56a5b3741d" +checksum = "3747cfeab1fc8299d70ceae0a28b7e2e005324e8eba78ac7d06729d67be5a1ec" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3861,9 +3861,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2271a6689d27f42ffe1259f587196f56251508c6c9e362c585ccf234f5919f96" +checksum = "dbd5c142355bd4822b8a7ec37268cfafe37b2e36835fa8d067b2b9d5a22c7529" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3876,9 +3876,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71494112126e7ecb92748913403c35ef949f18734e3ff4566a782ce2c8b986" +checksum = "e1291c05a4c8c3b4558eb1b50f53ee1f1b599ff2490d62cdc519ad5ae4b088d6" dependencies = [ "alloy-primitives", "cfg-if", @@ -3930,6 +3930,7 @@ dependencies = [ "toml_edit", "tracing", "walkdir", + "yansi", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index bdc2c87722340..e6ccd75bd3aec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,7 +167,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } -foundry-compilers = { version = "0.11.3", default-features = false } +foundry-compilers = { version = "0.11.4", default-features = false } foundry-fork-db = "0.4.0" solang-parser = "=0.3.3" diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index ebb4da9f1d45e..b0d0ccbbd23ee 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -126,6 +126,15 @@ pub struct CoreBuildArgs { #[serde(skip_serializing_if = "Option::is_none")] pub build_info_path: Option, + /// Use EOF-enabled solc binary. Enables via-ir and sets EVM version to Prague. Requires Docker + /// to be installed. + /// + /// Note that this is a temporary solution until the EOF support is merged into the main solc + /// release. + #[arg(long)] + #[serde(skip)] + pub eof: bool, + /// Skip building files whose names contain the given filter. /// /// `test` and `script` are aliases for `.t.sol` and `.s.sol`. @@ -277,6 +286,10 @@ impl Provider for CoreBuildArgs { dict.insert("revert_strings".to_string(), revert.to_string().into()); } + if self.eof { + dict.insert("eof".to_string(), true.into()); + } + Ok(Map::from([(Config::selected_profile(), dict)])) } } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 357830166d7d6..ec1894fb2891d 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -43,6 +43,7 @@ toml = { version = "0.8", features = ["preserve_order"] } toml_edit = "0.22.4" tracing.workspace = true walkdir.workspace = true +yansi.workspace = true [target.'cfg(target_os = "windows")'.dependencies] path-slash = "0.2.1" diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 017341c3d828f..87564fd441e82 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -46,6 +46,8 @@ use std::{ fs, path::{Path, PathBuf}, str::FromStr, + sync::mpsc::{self, RecvTimeoutError}, + time::Duration, }; mod macros; @@ -466,6 +468,9 @@ pub struct Config { /// Timeout for transactions in seconds. pub transaction_timeout: u64, + /// Use EOF-enabled solc for compilation. + pub eof: bool, + /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information #[serde(rename = "__warnings", default, skip_serializing)] pub warnings: Vec, @@ -530,6 +535,9 @@ impl Config { /// Default salt for create2 library deployments pub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> = FixedBytes::<32>::ZERO; + /// Docker image with eof-enabled solc binary + pub const EOF_SOLC_IMAGE: &'static str = "ghcr.io/paradigmxyz/forge-eof@sha256:46f868ce5264e1190881a3a335d41d7f42d6f26ed20b0c823609c715e38d603f"; + /// Returns the current `Config` /// /// See [`figment`](Self::figment) for more details. @@ -786,6 +794,8 @@ impl Config { config.libs.sort_unstable(); config.libs.dedup(); + config.sanitize_eof_settings(); + config } @@ -803,6 +813,22 @@ impl Config { } } + /// Adjusts settings if EOF compilation is enabled. + /// + /// This includes enabling via_ir, eof_version and ensuring that evm_version is not lower than + /// Prague. + pub fn sanitize_eof_settings(&mut self) { + if self.eof { + self.via_ir = true; + if self.eof_version.is_none() { + self.eof_version = Some(EofVersion::V1); + } + if self.evm_version < EvmVersion::Prague { + self.evm_version = EvmVersion::Prague; + } + } + } + /// Returns the directory in which dependencies should be installed /// /// Returns the first dir from `libs` that is not `node_modules` or `lib` if `libs` is empty @@ -904,6 +930,40 @@ impl Config { /// /// If `solc` is [`SolcReq::Local`] then this will ensure that the path exists. fn ensure_solc(&self) -> Result, SolcError> { + if self.eof { + let (tx, rx) = mpsc::channel(); + let root = self.root.0.clone(); + std::thread::spawn(move || { + tx.send( + Solc::new_with_args( + "docker", + [ + "run", + "--rm", + "-i", + "-v", + &format!("{}:/app/root", root.display()), + Self::EOF_SOLC_IMAGE, + ], + ) + .map(Some), + ) + }); + // If it takes more than 1 second, this likely means we are pulling the image. + return match rx.recv_timeout(Duration::from_secs(1)) { + Ok(res) => res, + Err(RecvTimeoutError::Timeout) => { + eprintln!( + "{}", + yansi::Paint::yellow( + "Pulling Docker image for eof-solc, this might take some time..." + ) + ); + rx.recv().expect("sender dropped") + } + Err(RecvTimeoutError::Disconnected) => panic!("sender dropped"), + } + } if let Some(ref solc) = self.solc { let solc = match solc { SolcReq::Version(version) => { @@ -2191,6 +2251,7 @@ impl Default for Config { eof_version: None, alphanet: false, transaction_timeout: 120, + eof: false, _non_exhaustive: (), } } diff --git a/crates/forge/tests/cli/alphanet.rs b/crates/forge/tests/cli/alphanet.rs new file mode 100644 index 0000000000000..cec450aca6f7d --- /dev/null +++ b/crates/forge/tests/cli/alphanet.rs @@ -0,0 +1,19 @@ +// Ensure we can run basic counter tests with EOF support. +#[cfg(not(windows))] +forgetest_init!(test_eof_flag, |prj, cmd| { + cmd.forge_fuse().args(["test", "--eof"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful with warnings: +Warning (3805): This is a pre-release compiler version, please do not use it in production. + + +Ran 2 tests for test/Counter.t.sol:CounterTest +[PASS] testFuzz_SetNumber(uint256) (runs: 256, [AVG_GAS]) +[PASS] test_Increment() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) + +"#]]); +}); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 5c0d62a3299af..c061af78f0eff 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -152,6 +152,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { eof_version: None, alphanet: false, transaction_timeout: 120, + eof: false, _non_exhaustive: (), }; prj.write_config(input.clone()); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index e8c6f1cc085f7..53c5604577906 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -4,6 +4,7 @@ extern crate foundry_test_utils; pub mod constants; pub mod utils; +mod alphanet; mod bind_json; mod build; mod cache; From df2e91b5e22a9ebce2924f0f56c54508d36f1241 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 3 Oct 2024 15:23:53 +0400 Subject: [PATCH 1512/1963] perf: reduce dynamic dispatch for inspectors (#9011) --- crates/evm/core/src/backend/cow.rs | 4 ++-- crates/evm/core/src/backend/mod.rs | 4 ++-- crates/evm/core/src/utils.rs | 6 +++--- crates/evm/evm/src/inspectors/stack.rs | 25 ++++++++++++++++++++++--- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 1589c8ee8ec9f..d5e09efbcd05c 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -62,10 +62,10 @@ impl<'a> CowBackend<'a> { /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. #[instrument(name = "inspect", level = "debug", skip_all)] - pub fn inspect( + pub fn inspect( &mut self, env: &mut EnvWithHandlerCfg, - inspector: &mut dyn InspectorExt, + inspector: &mut I, ) -> eyre::Result { // this is a new call to inspect with a new env, so even if we've cloned the backend // already, we reset the initialized state diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 9d26ce2873590..b72ca682b8705 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -751,10 +751,10 @@ impl Backend { /// Note: in case there are any cheatcodes executed that modify the environment, this will /// update the given `env` with the new values. #[instrument(name = "inspect", level = "debug", skip_all)] - pub fn inspect( + pub fn inspect( &mut self, env: &mut EnvWithHandlerCfg, - inspector: &mut dyn InspectorExt, + inspector: &mut I, ) -> eyre::Result { self.initialize(env); let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index d45c4b84908a8..7e03bdf746cea 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -234,11 +234,11 @@ pub fn alphanet_handler_register(handler: &mut EvmHandl } /// Creates a new EVM with the given inspector. -pub fn new_evm_with_inspector<'evm, 'i, 'db>( +pub fn new_evm_with_inspector<'evm, 'i, 'db, I: InspectorExt + ?Sized>( db: &'db mut dyn DatabaseExt, env: revm::primitives::EnvWithHandlerCfg, - inspector: &'i mut dyn InspectorExt, -) -> revm::Evm<'evm, &'i mut dyn InspectorExt, &'db mut dyn DatabaseExt> { + inspector: &'i mut I, +) -> revm::Evm<'evm, &'i mut I, &'db mut dyn DatabaseExt> { let revm::primitives::EnvWithHandlerCfg { env, handler_cfg } = env; // NOTE: We could use `revm::Evm::builder()` here, but on the current patch it has some diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index c8df2c693102c..ac7c31ff96a3e 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -543,14 +543,14 @@ impl<'a> InspectorStackRefMut<'a> { self.in_inner_context = true; let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); - let res = { - let mut evm = crate::utils::new_evm_with_inspector(&mut ecx.db, env, self); + let res = self.with_stack(|inspector| { + let mut evm = crate::utils::new_evm_with_inspector(&mut ecx.db, env, inspector); let res = evm.transact(); // need to reset the env in case it was modified via cheatcodes during execution ecx.env = evm.context.evm.inner.env; res - }; + }); self.in_inner_context = false; self.inner_context_data = None; @@ -621,6 +621,25 @@ impl<'a> InspectorStackRefMut<'a> { }; (InterpreterResult { result, output, gas }, address) } + + /// Moves out of references, constructs an [`InspectorStack`] and runs the given closure with + /// it. + fn with_stack(&mut self, f: impl FnOnce(&mut InspectorStack) -> O) -> O { + let mut stack = InspectorStack { + cheatcodes: self.cheatcodes.as_deref_mut().map(std::mem::take), + inner: std::mem::take(self.inner), + }; + + let out = f(&mut stack); + + if let Some(cheats) = self.cheatcodes.as_deref_mut() { + *cheats = stack.cheatcodes.take().unwrap(); + } + + *self.inner = stack.inner; + + out + } } impl<'a> Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'a> { From d4649bf5094f5c863a1795f7fbb19cc7efa52b4c Mon Sep 17 00:00:00 2001 From: Abhishek kochar Date: Thu, 3 Oct 2024 20:29:14 +0800 Subject: [PATCH 1513/1963] feat(randomBytes): adding support to generate different bytes via RngCore (#8996) * feat(randomBytes): adding support to generate different bytes via RngCore Signed-off-by: Abhishekkochar * Added needed changes to util file Signed-off-by: Abhishekkochar * Added support to get random 4 and 8 bytes Signed-off-by: Abhishekkochar * Refractor code to suggested changes Signed-off-by: Abhishekkochar * Fixed import with B32 Signed-off-by: Abhishekkochar * updated cheatcodes.json file Signed-off-by: Abhishekkochar * docs --------- Signed-off-by: Abhishekkochar Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 50 ++++++++++++++++++++--- crates/cheatcodes/spec/src/vm.rs | 18 +++++--- crates/cheatcodes/src/utils.rs | 16 +++++++- testdata/cheats/Vm.sol | 2 + testdata/default/cheats/RandomBytes.t.sol | 22 ++++++++++ 5 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 testdata/default/cheats/RandomBytes.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 9b6c67ddd195f..9f08702266e91 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7000,7 +7000,7 @@ { "func": { "id": "randomBool", - "description": "Returns an random `bool`.", + "description": "Returns a random `bool`.", "declaration": "function randomBool() external view returns (bool);", "visibility": "external", "mutability": "view", @@ -7020,7 +7020,7 @@ { "func": { "id": "randomBytes", - "description": "Returns an random byte array value of the given length.", + "description": "Returns a random byte array value of the given length.", "declaration": "function randomBytes(uint256 len) external view returns (bytes memory);", "visibility": "external", "mutability": "view", @@ -7037,10 +7037,50 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "randomBytes4", + "description": "Returns a random fixed-size byte array of length 4.", + "declaration": "function randomBytes4() external view returns (bytes4);", + "visibility": "external", + "mutability": "view", + "signature": "randomBytes4()", + "selector": "0x9b7cd579", + "selectorBytes": [ + 155, + 124, + 213, + 121 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "randomBytes8", + "description": "Returns a random fixed-size byte array of length 8.", + "declaration": "function randomBytes8() external view returns (bytes8);", + "visibility": "external", + "mutability": "view", + "signature": "randomBytes8()", + "selector": "0x0497b0a5", + "selectorBytes": [ + 4, + 151, + 176, + 165 + ] + }, + "group": "utilities", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "randomInt_0", - "description": "Returns an random `int256` value.", + "description": "Returns a random `int256` value.", "declaration": "function randomInt() external view returns (int256);", "visibility": "external", "mutability": "view", @@ -7060,7 +7100,7 @@ { "func": { "id": "randomInt_1", - "description": "Returns an random `int256` value of given bits.", + "description": "Returns a random `int256` value of given bits.", "declaration": "function randomInt(uint256 bits) external view returns (int256);", "visibility": "external", "mutability": "view", @@ -7120,7 +7160,7 @@ { "func": { "id": "randomUint_2", - "description": "Returns an random `uint256` value of given bits.", + "description": "Returns a random `uint256` value of given bits.", "declaration": "function randomUint(uint256 bits) external view returns (uint256);", "visibility": "external", "mutability": "view", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 7f27e1aa63b78..4ec51130a22a4 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2405,7 +2405,7 @@ interface Vm { #[cheatcode(group = Utilities)] function randomUint(uint256 min, uint256 max) external returns (uint256); - /// Returns an random `uint256` value of given bits. + /// Returns a random `uint256` value of given bits. #[cheatcode(group = Utilities)] function randomUint(uint256 bits) external view returns (uint256); @@ -2413,22 +2413,30 @@ interface Vm { #[cheatcode(group = Utilities)] function randomAddress() external returns (address); - /// Returns an random `int256` value. + /// Returns a random `int256` value. #[cheatcode(group = Utilities)] function randomInt() external view returns (int256); - /// Returns an random `int256` value of given bits. + /// Returns a random `int256` value of given bits. #[cheatcode(group = Utilities)] function randomInt(uint256 bits) external view returns (int256); - /// Returns an random `bool`. + /// Returns a random `bool`. #[cheatcode(group = Utilities)] function randomBool() external view returns (bool); - /// Returns an random byte array value of the given length. + /// Returns a random byte array value of the given length. #[cheatcode(group = Utilities)] function randomBytes(uint256 len) external view returns (bytes memory); + /// Returns a random fixed-size byte array of length 4. + #[cheatcode(group = Utilities)] + function randomBytes4() external view returns (bytes4); + + /// Returns a random fixed-size byte array of length 8. + #[cheatcode(group = Utilities)] + function randomBytes8() external view returns (bytes8); + /// Pauses collection of call traces. Useful in cases when you want to skip tracing of /// complex calls which are not useful for debugging. #[cheatcode(group = Utilities)] diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index 23cc02f7ad9de..79299d9fd82b1 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -2,7 +2,7 @@ use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_dyn_abi::{DynSolType, DynSolValue}; -use alloy_primitives::{map::HashMap, U256}; +use alloy_primitives::{aliases::B32, map::HashMap, B64, U256}; use alloy_sol_types::SolValue; use foundry_common::ens::namehash; use foundry_evm_core::constants::DEFAULT_CREATE2_DEPLOYER; @@ -133,6 +133,20 @@ impl Cheatcode for randomBytesCall { } } +impl Cheatcode for randomBytes4Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let rand_u32 = state.rng().next_u32(); + Ok(B32::from(rand_u32).abi_encode()) + } +} + +impl Cheatcode for randomBytes8Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let rand_u64 = state.rng().next_u64(); + Ok(B64::from(rand_u64).abi_encode()) + } +} + impl Cheatcode for pauseTracingCall { fn apply_full( &self, diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 335ce83d08964..7dc38480a0d32 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -347,6 +347,8 @@ interface Vm { function randomAddress() external returns (address); function randomBool() external view returns (bool); function randomBytes(uint256 len) external view returns (bytes memory); + function randomBytes4() external view returns (bytes4); + function randomBytes8() external view returns (bytes8); function randomInt() external view returns (int256); function randomInt(uint256 bits) external view returns (int256); function randomUint() external returns (uint256); diff --git a/testdata/default/cheats/RandomBytes.t.sol b/testdata/default/cheats/RandomBytes.t.sol new file mode 100644 index 0000000000000..8d298f43f0c88 --- /dev/null +++ b/testdata/default/cheats/RandomBytes.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract RandomBytes is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testRandomBytes4() public { + vm.randomBytes4(); + } + + function testRandomBytes8() public { + vm.randomBytes8(); + } + + function testFillrandomBytes() public view { + uint256 len = 16; + vm.randomBytes(len); + } +} From 086fcca5e6672d2894ba80931888a05a89ea1ae9 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 3 Oct 2024 16:18:17 +0200 Subject: [PATCH 1514/1963] chore: add more context to sourcemap error (#9015) --- crates/evm/traces/src/debug/sources.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index 5087a06f39dbb..6ad335302fb2f 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -83,12 +83,14 @@ pub struct ArtifactData { impl ArtifactData { fn new(bytecode: ContractBytecodeSome, build_id: String, file_id: u32) -> Result { - let parse = |b: &Bytecode| { + let parse = |b: &Bytecode, name: &str| { // Only parse source map if it's not empty. let source_map = if b.source_map.as_ref().map_or(true, |s| s.is_empty()) { Ok(None) } else { - b.source_map().transpose() + b.source_map().transpose().wrap_err_with(|| { + format!("failed to parse {name} source map of file {file_id} in {build_id}") + }) }; // Only parse bytecode if it's not empty. @@ -100,11 +102,11 @@ impl ArtifactData { source_map.map(|source_map| (source_map, pc_ic_map)) }; - let (source_map, pc_ic_map) = parse(&bytecode.bytecode)?; + let (source_map, pc_ic_map) = parse(&bytecode.bytecode, "creation")?; let (source_map_runtime, pc_ic_map_runtime) = bytecode .deployed_bytecode .bytecode - .map(|b| parse(&b)) + .map(|b| parse(&b, "runtime")) .unwrap_or_else(|| Ok((None, None)))?; Ok(Self { source_map, source_map_runtime, pc_ic_map, pc_ic_map_runtime, build_id, file_id }) From c89a08c5b0bee69c8b6072853f0a34babbefc495 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 3 Oct 2024 19:06:15 +0400 Subject: [PATCH 1515/1963] fix: only test `--eof` on linux (#9016) fix: only test --eof on linux --- crates/forge/tests/cli/alphanet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/alphanet.rs b/crates/forge/tests/cli/alphanet.rs index cec450aca6f7d..6e41551ac890b 100644 --- a/crates/forge/tests/cli/alphanet.rs +++ b/crates/forge/tests/cli/alphanet.rs @@ -1,5 +1,5 @@ // Ensure we can run basic counter tests with EOF support. -#[cfg(not(windows))] +#[cfg(target_os = "linux")] forgetest_init!(test_eof_flag, |prj, cmd| { cmd.forge_fuse().args(["test", "--eof"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] From a355af4750c4e12103e9684f99401b5b14cd23f9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:37:56 +0300 Subject: [PATCH 1516/1963] fix(cheatcodes): handle create2 deployer with broadcastRawTransaction (#9020) fix(cheatcodes): fix deploy create with broadcastRawTransaction --- crates/evm/core/src/backend/mod.rs | 4 +- crates/forge/tests/cli/script.rs | 69 ++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index b72ca682b8705..f76f60ba13745 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1283,8 +1283,8 @@ impl DatabaseExt for Backend { env.tx.value = tx.value.ok_or_else(|| eyre::eyre!("transact_from_tx: No `value` field found"))?; env.tx.data = tx.input.into_input().unwrap_or_default(); - env.tx.transact_to = - tx.to.ok_or_else(|| eyre::eyre!("transact_from_tx: No `to` field found"))?; + // If no `to` field then set create kind: https://eips.ethereum.org/EIPS/eip-2470#deployment-transaction + env.tx.transact_to = tx.to.unwrap_or(TxKind::Create); env.tx.chain_id = tx.chain_id; self.commit(journaled_state.state.clone()); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index fb2e8ae8dee77..61c2456fef66f 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1986,3 +1986,72 @@ forgetest_async!(can_deploy_library_create2_different_sender, |prj, cmd| { .assert_nonce_increment(&[(2, 2)]) .await; }); + +// +forgetest_async!(test_broadcast_raw_create2_deployer, |prj, cmd| { + let (_api, handle) = + spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function run() external { + // send funds to create2 factory deployer + vm.broadcast(); + payable(0x3fAB184622Dc19b6109349B94811493BF2a45362).transfer(10000000 gwei); + // deploy create2 factory + vm.broadcastRawTransaction( + hex"f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222" + ); + } +} + "#, + ) + .unwrap(); + + cmd.args([ + "script", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + "--broadcast", + "SimpleScript", + ]); + + cmd.assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Script ran successfully. + +## Setting up 1 EVM. + +========================== + +Chain 31337 + +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + + +========================== + +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); +}); From 67018dcf3cc4ee80471a6d8a4d519c1d946b7fbb Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:51:49 +0530 Subject: [PATCH 1517/1963] fix(`anvil`): set `storage.best_hash` while loading state (#9021) * fix(anvil): set `storage.best_hash` while loading state * clippy nit * test: strengthen can_load_state --- crates/anvil/src/eth/backend/mem/mod.rs | 21 ++++++++++++++++----- crates/anvil/tests/it/state.rs | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index dbf22fbebe7fd..0b002d3db7ec8 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -800,14 +800,28 @@ impl Backend { /// Apply [SerializableState] data to the backend storage. pub async fn load_state(&self, state: SerializableState) -> Result { + // load the blocks and transactions into the storage + self.blockchain.storage.write().load_blocks(state.blocks.clone()); + self.blockchain.storage.write().load_transactions(state.transactions.clone()); // reset the block env if let Some(block) = state.block.clone() { self.env.write().block = block.clone(); // Set the current best block number. // Defaults to block number for compatibility with existing state files. - self.blockchain.storage.write().best_number = - state.best_block_number.unwrap_or(block.number.to::()); + + let best_number = state.best_block_number.unwrap_or(block.number.to::()); + self.blockchain.storage.write().best_number = best_number; + + // Set the current best block hash; + let best_hash = + self.blockchain.storage.read().hash(best_number.into()).ok_or_else(|| { + BlockchainError::RpcError(RpcError::internal_error_with(format!( + "Best hash not found for best number {best_number}", + ))) + })?; + + self.blockchain.storage.write().best_hash = best_hash; } if !self.db.write().await.load_state(state.clone())? { @@ -817,9 +831,6 @@ impl Backend { .into()); } - self.blockchain.storage.write().load_blocks(state.blocks.clone()); - self.blockchain.storage.write().load_transactions(state.transactions.clone()); - if let Some(historical_states) = state.historical_states { self.states.write().load_states(historical_states); } diff --git a/crates/anvil/tests/it/state.rs b/crates/anvil/tests/it/state.rs index 8227a89f1c592..cb8f3b9ebbca9 100644 --- a/crates/anvil/tests/it/state.rs +++ b/crates/anvil/tests/it/state.rs @@ -1,7 +1,7 @@ //! general eth api tests use crate::abi::Greeter; -use alloy_primitives::{Bytes, Uint}; +use alloy_primitives::{Bytes, Uint, U256}; use alloy_provider::Provider; use alloy_rpc_types::BlockId; use anvil::{spawn, NodeConfig}; @@ -13,6 +13,7 @@ async fn can_load_state() { let (api, _handle) = spawn(NodeConfig::test()).await; + api.mine_one().await; api.mine_one().await; let num = api.block_number().unwrap(); @@ -23,7 +24,19 @@ async fn can_load_state() { let (api, _handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; let num2 = api.block_number().unwrap(); + + // Ref: https://github.com/foundry-rs/foundry/issues/9017 + // Check responses of eth_blockNumber and eth_getBlockByNumber don't deviate after loading state + let num_from_tag = api + .block_by_number(alloy_eips::BlockNumberOrTag::Latest) + .await + .unwrap() + .unwrap() + .header + .number; assert_eq!(num, num2); + + assert_eq!(num, U256::from(num_from_tag)); } #[tokio::test(flavor = "multi_thread")] From e10ab3d7010b2cbe2b76030d6638c49a3cec696d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 3 Oct 2024 20:04:26 +0200 Subject: [PATCH 1518/1963] chore: reduce size of DynCheatcode vtable (#9023) --- crates/cheatcodes/src/lib.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index a257289916cd7..106b4c96121d4 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -84,25 +84,9 @@ pub(crate) trait Cheatcode: CheatcodeDef + DynCheatcode { } } -pub(crate) trait DynCheatcode { +pub(crate) trait DynCheatcode: 'static { fn cheatcode(&self) -> &'static spec::Cheatcode<'static>; - fn name(&self) -> &'static str { - self.cheatcode().func.signature.split('(').next().unwrap() - } - - fn id(&self) -> &'static str { - self.cheatcode().func.id - } - - fn signature(&self) -> &'static str { - self.cheatcode().func.signature - } - - fn status(&self) -> &Status<'static> { - &self.cheatcode().status - } - fn as_debug(&self) -> &dyn std::fmt::Debug; fn dyn_apply(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result; @@ -125,6 +109,24 @@ impl DynCheatcode for T { } } +impl dyn DynCheatcode { + pub(crate) fn name(&self) -> &'static str { + self.cheatcode().func.signature.split('(').next().unwrap() + } + + pub(crate) fn id(&self) -> &'static str { + self.cheatcode().func.id + } + + pub(crate) fn signature(&self) -> &'static str { + self.cheatcode().func.signature + } + + pub(crate) fn status(&self) -> &Status<'static> { + &self.cheatcode().status + } +} + /// The cheatcode context, used in `Cheatcode`. pub struct CheatsCtxt<'cheats, 'evm, 'db, 'db2> { /// The cheatcodes inspector state. From ac37bdb260acd21cc95a3a63ee78d6530a1eec87 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 4 Oct 2024 08:04:04 +0200 Subject: [PATCH 1519/1963] chore: unify tx env filling + add missing members (#9022) --- crates/cheatcodes/src/evm.rs | 7 ++-- crates/cheatcodes/src/evm/fork.rs | 36 ++++++++-------- crates/evm/core/src/backend/cow.rs | 10 ++--- crates/evm/core/src/backend/mod.rs | 36 +++++----------- crates/evm/core/src/utils.rs | 67 +++++++++++++++++++++++++----- 5 files changed, 92 insertions(+), 64 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index f9671430dc089..af2026a9e1a24 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -683,13 +683,12 @@ impl Cheatcode for stopAndReturnStateDiffCall { impl Cheatcode for broadcastRawTransactionCall { fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { - let mut data = self.data.as_ref(); - let tx = TxEnvelope::decode(&mut data) + let tx = TxEnvelope::decode(&mut self.data.as_ref()) .map_err(|err| fmt_err!("failed to decode RLP-encoded transaction: {err}"))?; ccx.ecx.db.transact_from_tx( - tx.clone().into(), - &ccx.ecx.env, + &tx.clone().into(), + (*ccx.ecx.env).clone(), &mut ccx.ecx.journaled_state, &mut *executor.get_inspector(ccx.state), )?; diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 84fda7883c7d5..e1d66538de721 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -130,28 +130,14 @@ impl Cheatcode for selectForkCall { impl Cheatcode for transact_0Call { fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let Self { txHash } = *self; - ccx.ecx.db.transact( - None, - txHash, - &mut ccx.ecx.env, - &mut ccx.ecx.journaled_state, - &mut executor.get_inspector(ccx.state), - )?; - Ok(Default::default()) + transact(ccx, executor, txHash, None) } } impl Cheatcode for transact_1Call { fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let Self { forkId, txHash } = *self; - ccx.ecx.db.transact( - Some(forkId), - txHash, - &mut ccx.ecx.env, - &mut ccx.ecx.journaled_state, - &mut *executor.get_inspector(ccx.state), - )?; - Ok(Default::default()) + transact(ccx, executor, txHash, Some(forkId)) } } @@ -350,7 +336,6 @@ fn create_fork_request( Ok(fork) } -#[inline] fn check_broadcast(state: &Cheatcodes) -> Result<()> { if state.broadcast.is_none() { Ok(()) @@ -359,11 +344,26 @@ fn check_broadcast(state: &Cheatcodes) -> Result<()> { } } +fn transact( + ccx: &mut CheatsCtxt, + executor: &mut dyn CheatcodesExecutor, + transaction: B256, + fork_id: Option, +) -> Result { + ccx.ecx.db.transact( + fork_id, + transaction, + (*ccx.ecx.env).clone(), + &mut ccx.ecx.journaled_state, + &mut *executor.get_inspector(ccx.state), + )?; + Ok(Default::default()) +} + // Helper to add the caller of fork cheat code as persistent account (in order to make sure that the // state of caller contract is not lost when fork changes). // Applies to create, select and roll forks actions. // https://github.com/foundry-rs/foundry/issues/8004 -#[inline] fn persist_caller(ccx: &mut CheatsCtxt) { ccx.ecx.db.add_persistent_account(ccx.caller); } diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index d5e09efbcd05c..d52ac6fd04616 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -184,21 +184,21 @@ impl<'a> DatabaseExt for CowBackend<'a> { &mut self, id: Option, transaction: B256, - env: &mut Env, + env: Env, journaled_state: &mut JournaledState, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { - self.backend_mut(env).transact(id, transaction, env, journaled_state, inspector) + self.backend_mut(&env).transact(id, transaction, env, journaled_state, inspector) } fn transact_from_tx( &mut self, - transaction: TransactionRequest, - env: &Env, + transaction: &TransactionRequest, + env: Env, journaled_state: &mut JournaledState, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { - self.backend_mut(env).transact_from_tx(transaction, env, journaled_state, inspector) + self.backend_mut(&env).transact_from_tx(transaction, env, journaled_state, inspector) } fn active_fork_id(&self) -> Option { diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index f76f60ba13745..8cf59d96e1b2d 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -4,7 +4,7 @@ use crate::{ constants::{CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, TEST_CONTRACT_ADDRESS}, fork::{CreateFork, ForkId, MultiFork}, state_snapshot::StateSnapshots, - utils::{configure_tx_env, new_evm_with_inspector}, + utils::{configure_tx_env, configure_tx_req_env, new_evm_with_inspector}, InspectorExt, }; use alloy_genesis::GenesisAccount; @@ -198,7 +198,7 @@ pub trait DatabaseExt: Database + DatabaseCommit { &mut self, id: Option, transaction: B256, - env: &mut Env, + env: Env, journaled_state: &mut JournaledState, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()>; @@ -206,8 +206,8 @@ pub trait DatabaseExt: Database + DatabaseCommit { /// Executes a given TransactionRequest, commits the new state to the DB fn transact_from_tx( &mut self, - transaction: TransactionRequest, - env: &Env, + transaction: &TransactionRequest, + env: Env, journaled_state: &mut JournaledState, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()>; @@ -1223,7 +1223,7 @@ impl DatabaseExt for Backend { &mut self, maybe_id: Option, transaction: B256, - env: &mut Env, + mut env: Env, journaled_state: &mut JournaledState, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { @@ -1245,7 +1245,6 @@ impl DatabaseExt for Backend { // So we modify the env to match the transaction's block. let (_fork_block, block) = self.get_block_number_and_block_for_transaction(id, transaction)?; - let mut env = env.clone(); update_env_block(&mut env, &block); let env = self.env_with_handler_cfg(env); @@ -1263,35 +1262,20 @@ impl DatabaseExt for Backend { fn transact_from_tx( &mut self, - tx: TransactionRequest, - env: &Env, + tx: &TransactionRequest, + mut env: Env, journaled_state: &mut JournaledState, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { trace!(?tx, "execute signed transaction"); - let mut env = env.clone(); - - env.tx.caller = - tx.from.ok_or_else(|| eyre::eyre!("transact_from_tx: No `from` field found"))?; - env.tx.gas_limit = - tx.gas.ok_or_else(|| eyre::eyre!("transact_from_tx: No `gas` field found"))?; - env.tx.gas_price = U256::from(tx.gas_price.or(tx.max_fee_per_gas).unwrap_or_default()); - env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); - env.tx.nonce = tx.nonce; - env.tx.access_list = tx.access_list.clone().unwrap_or_default().0.into_iter().collect(); - env.tx.value = - tx.value.ok_or_else(|| eyre::eyre!("transact_from_tx: No `value` field found"))?; - env.tx.data = tx.input.into_input().unwrap_or_default(); - // If no `to` field then set create kind: https://eips.ethereum.org/EIPS/eip-2470#deployment-transaction - env.tx.transact_to = tx.to.unwrap_or(TxKind::Create); - env.tx.chain_id = tx.chain_id; - self.commit(journaled_state.state.clone()); let res = { - let mut db = self.clone(); + configure_tx_req_env(&mut env, tx)?; let env = self.env_with_handler_cfg(env); + + let mut db = self.clone(); let mut evm = new_evm_with_inspector(&mut db, env, inspector); evm.context.evm.journaled_state.depth = journaled_state.depth + 1; evm.transact()? diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 7e03bdf746cea..bd17aae442922 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -9,7 +9,7 @@ use alloy_provider::{ network::{BlockResponse, HeaderResponse}, Network, }; -use alloy_rpc_types::Transaction; +use alloy_rpc_types::{Transaction, TransactionRequest}; use foundry_config::NamedChain; use foundry_fork_db::DatabaseError; use revm::{ @@ -84,17 +84,62 @@ pub fn get_function<'a>( .ok_or_else(|| eyre::eyre!("{contract_name} does not have the selector {selector}")) } -/// Configures the env for the transaction +/// Configures the env for the given RPC transaction. pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { - env.tx.caller = tx.from; - env.tx.gas_limit = tx.gas; - env.tx.gas_price = U256::from(tx.gas_price.unwrap_or_default()); - env.tx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); - env.tx.nonce = Some(tx.nonce); - env.tx.access_list = tx.access_list.clone().unwrap_or_default().0.into_iter().collect(); - env.tx.value = tx.value.to(); - env.tx.data = alloy_primitives::Bytes(tx.input.0.clone()); - env.tx.transact_to = tx.to.map(TxKind::Call).unwrap_or(TxKind::Create) + configure_tx_req_env(env, &tx.clone().into()).expect("cannot fail"); +} + +/// Configures the env for the given RPC transaction request. +pub fn configure_tx_req_env( + env: &mut revm::primitives::Env, + tx: &TransactionRequest, +) -> eyre::Result<()> { + let TransactionRequest { + nonce, + from, + to, + value, + gas_price, + gas, + max_fee_per_gas, + max_priority_fee_per_gas, + max_fee_per_blob_gas, + ref input, + chain_id, + ref blob_versioned_hashes, + ref access_list, + transaction_type: _, + ref authorization_list, + sidecar: _, + } = *tx; + + // If no `to` field then set create kind: https://eips.ethereum.org/EIPS/eip-2470#deployment-transaction + env.tx.transact_to = to.unwrap_or(TxKind::Create); + env.tx.caller = from.ok_or_else(|| eyre::eyre!("missing `from` field"))?; + env.tx.gas_limit = gas.ok_or_else(|| eyre::eyre!("missing `gas` field"))?; + env.tx.nonce = nonce; + env.tx.value = value.unwrap_or_default(); + env.tx.data = input.input().cloned().unwrap_or_default(); + env.tx.chain_id = chain_id; + + // Type 1, EIP-2930 + env.tx.access_list = access_list.clone().unwrap_or_default().0.into_iter().collect(); + + // Type 2, EIP-1559 + env.tx.gas_price = U256::from(gas_price.or(max_fee_per_gas).unwrap_or_default()); + env.tx.gas_priority_fee = max_priority_fee_per_gas.map(U256::from); + + // Type 3, EIP-4844 + env.tx.blob_hashes = blob_versioned_hashes.clone().unwrap_or_default(); + env.tx.max_fee_per_blob_gas = max_fee_per_blob_gas.map(U256::from); + + // Type 4, EIP-7702 + if let Some(authorization_list) = authorization_list { + env.tx.authorization_list = + Some(revm::primitives::AuthorizationList::Signed(authorization_list.clone())); + } + + Ok(()) } /// Get the gas used, accounting for refunds From a970b36d451fe84b8fba456ec99bf822376e56b8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:06:01 +0300 Subject: [PATCH 1520/1963] chore: fix clippy (#9028) --- crates/anvil/src/eth/backend/executor.rs | 6 ++---- crates/anvil/src/eth/util.rs | 4 ++-- crates/cheatcodes/src/test/assert.rs | 8 ++++---- crates/chisel/src/executor.rs | 2 +- crates/chisel/src/solidity_helper.rs | 2 +- crates/config/src/lib.rs | 2 +- crates/config/src/providers/remappings.rs | 4 ++-- crates/doc/src/preprocessor/infer_hyperlinks.rs | 2 +- crates/doc/src/writer/as_doc.rs | 2 +- crates/doc/src/writer/markdown.rs | 4 ++-- crates/doc/src/writer/traits.rs | 2 +- crates/evm/core/src/backend/cow.rs | 8 ++++---- crates/evm/evm/src/inspectors/stack.rs | 4 ++-- crates/fmt/src/comments.rs | 2 +- crates/fmt/src/formatter.rs | 6 +++--- crates/fmt/src/solang_ext/loc.rs | 6 +++--- crates/fmt/src/string.rs | 6 +++--- crates/forge/bin/cmd/geiger/find.rs | 2 +- crates/forge/src/coverage.rs | 2 +- crates/forge/src/runner.rs | 2 +- 20 files changed, 37 insertions(+), 39 deletions(-) diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 3221620ef0e88..3ceee8b04e948 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -112,7 +112,7 @@ pub struct TransactionExecutor<'a, Db: ?Sized, V: TransactionValidator> { pub precompile_factory: Option>, } -impl<'a, DB: Db + ?Sized, V: TransactionValidator> TransactionExecutor<'a, DB, V> { +impl TransactionExecutor<'_, DB, V> { /// Executes all transactions and puts them in a new block with the provided `timestamp` pub fn execute(mut self) -> ExecutedTransactions { let mut transactions = Vec::new(); @@ -263,9 +263,7 @@ pub enum TransactionExecutionOutcome { DatabaseError(Arc, DatabaseError), } -impl<'a, 'b, DB: Db + ?Sized, V: TransactionValidator> Iterator - for &'b mut TransactionExecutor<'a, DB, V> -{ +impl Iterator for &mut TransactionExecutor<'_, DB, V> { type Item = TransactionExecutionOutcome; fn next(&mut self) -> Option { diff --git a/crates/anvil/src/eth/util.rs b/crates/anvil/src/eth/util.rs index 6bcde67d5ac98..ca66f2ed3d3c5 100644 --- a/crates/anvil/src/eth/util.rs +++ b/crates/anvil/src/eth/util.rs @@ -29,7 +29,7 @@ impl<'a> HexDisplay<'a> { } } -impl<'a> fmt::Display for HexDisplay<'a> { +impl fmt::Display for HexDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.0.len() < 1027 { for byte in self.0 { @@ -48,7 +48,7 @@ impl<'a> fmt::Display for HexDisplay<'a> { } } -impl<'a> fmt::Debug for HexDisplay<'a> { +impl fmt::Debug for HexDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for byte in self.0 { f.write_fmt(format_args!("{byte:02x}"))?; diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index 5161716fae56c..b4b6652ac2970 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -37,27 +37,27 @@ macro_rules! format_values { }; } -impl<'a, T: Display> ComparisonAssertionError<'a, T> { +impl ComparisonAssertionError<'_, T> { fn format_for_values(&self) -> String { format_values!(self, T::to_string) } } -impl<'a, T: Display> ComparisonAssertionError<'a, Vec> { +impl ComparisonAssertionError<'_, Vec> { fn format_for_arrays(&self) -> String { let formatter = |v: &Vec| format!("[{}]", v.iter().format(", ")); format_values!(self, formatter) } } -impl<'a> ComparisonAssertionError<'a, U256> { +impl ComparisonAssertionError<'_, U256> { fn format_with_decimals(&self, decimals: &U256) -> String { let formatter = |v: &U256| format_units_uint(v, decimals); format_values!(self, formatter) } } -impl<'a> ComparisonAssertionError<'a, I256> { +impl ComparisonAssertionError<'_, I256> { fn format_with_decimals(&self, decimals: &U256) -> String { let formatter = |v: &I256| format_units_int(v, decimals); format_values!(self, formatter) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 5e40862f8277b..16387a69b5897 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -1371,7 +1371,7 @@ impl<'a> InstructionIter<'a> { } } -impl<'a> Iterator for InstructionIter<'a> { +impl Iterator for InstructionIter<'_> { type Item = Instruction; fn next(&mut self) -> Option { let pc = self.offset; diff --git a/crates/chisel/src/solidity_helper.rs b/crates/chisel/src/solidity_helper.rs index 4707ab37b789f..696cca1a16015 100644 --- a/crates/chisel/src/solidity_helper.rs +++ b/crates/chisel/src/solidity_helper.rs @@ -278,7 +278,7 @@ pub trait TokenStyle { } /// [TokenStyle] implementation for [Token] -impl<'a> TokenStyle for Token<'a> { +impl TokenStyle for Token<'_> { fn style(&self) -> Style { use Token::*; match self { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 87564fd441e82..648d40e66625e 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2456,7 +2456,7 @@ impl Provider for BackwardsCompatTomlProvider

{ /// A provider that sets the `src` and `output` path depending on their existence. struct DappHardhatDirProvider<'a>(&'a Path); -impl<'a> Provider for DappHardhatDirProvider<'a> { +impl Provider for DappHardhatDirProvider<'_> { fn metadata(&self) -> Metadata { Metadata::named("Dapp Hardhat dir compat") } diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 2eaab0982d34b..2e849bea4eccb 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -87,7 +87,7 @@ pub struct RemappingsProvider<'a> { pub remappings: Result, Error>, } -impl<'a> RemappingsProvider<'a> { +impl RemappingsProvider<'_> { /// Find and parse remappings for the projects /// /// **Order** @@ -240,7 +240,7 @@ impl<'a> RemappingsProvider<'a> { } } -impl<'a> Provider for RemappingsProvider<'a> { +impl Provider for RemappingsProvider<'_> { fn metadata(&self) -> Metadata { Metadata::named("Remapping Provider") } diff --git a/crates/doc/src/preprocessor/infer_hyperlinks.rs b/crates/doc/src/preprocessor/infer_hyperlinks.rs index 2d080278911b7..25fafc0325b6b 100644 --- a/crates/doc/src/preprocessor/infer_hyperlinks.rs +++ b/crates/doc/src/preprocessor/infer_hyperlinks.rs @@ -200,7 +200,7 @@ impl<'a> InlineLinkTarget<'a> { } } -impl<'a> std::fmt::Display for InlineLinkTarget<'a> { +impl std::fmt::Display for InlineLinkTarget<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { // NOTE: the url should be absolute for markdown and section names are lowercase write!(f, "/{}#{}", self.target_path.display(), self.section.to_lowercase()) diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index a14f9d3444715..50a847beb32c1 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -31,7 +31,7 @@ impl AsDoc for Comments { } } -impl<'a> AsDoc for CommentsRef<'a> { +impl AsDoc for CommentsRef<'_> { // TODO: support other tags fn as_doc(&self) -> AsDocResult { let mut writer = BufWriter::default(); diff --git a/crates/doc/src/writer/markdown.rs b/crates/doc/src/writer/markdown.rs index 2e577ad9601c9..7583c35e79ef8 100644 --- a/crates/doc/src/writer/markdown.rs +++ b/crates/doc/src/writer/markdown.rs @@ -21,7 +21,7 @@ pub enum Markdown<'a> { CodeBlock(&'a str, &'a str), } -impl<'a> AsDoc for Markdown<'a> { +impl AsDoc for Markdown<'_> { fn as_doc(&self) -> AsDocResult { let doc = match self { Self::H1(val) => format!("# {val}"), @@ -37,7 +37,7 @@ impl<'a> AsDoc for Markdown<'a> { } } -impl<'a> std::fmt::Display for Markdown<'a> { +impl std::fmt::Display for Markdown<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!("{}", self.as_doc()?)) } diff --git a/crates/doc/src/writer/traits.rs b/crates/doc/src/writer/traits.rs index b59708ed90661..0b79718d5102f 100644 --- a/crates/doc/src/writer/traits.rs +++ b/crates/doc/src/writer/traits.rs @@ -56,7 +56,7 @@ impl ParamLike for solang_parser::pt::ErrorParameter { } } -impl<'a, T> ParamLike for &'a T +impl ParamLike for &T where T: ParamLike, { diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index d52ac6fd04616..fcc2e1596c9fd 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -110,7 +110,7 @@ impl<'a> CowBackend<'a> { } } -impl<'a> DatabaseExt for CowBackend<'a> { +impl DatabaseExt for CowBackend<'_> { fn snapshot_state(&mut self, journaled_state: &JournaledState, env: &Env) -> U256 { self.backend_mut(env).snapshot_state(journaled_state, env) } @@ -262,7 +262,7 @@ impl<'a> DatabaseExt for CowBackend<'a> { } } -impl<'a> DatabaseRef for CowBackend<'a> { +impl DatabaseRef for CowBackend<'_> { type Error = DatabaseError; fn basic_ref(&self, address: Address) -> Result, Self::Error> { @@ -282,7 +282,7 @@ impl<'a> DatabaseRef for CowBackend<'a> { } } -impl<'a> Database for CowBackend<'a> { +impl Database for CowBackend<'_> { type Error = DatabaseError; fn basic(&mut self, address: Address) -> Result, Self::Error> { @@ -302,7 +302,7 @@ impl<'a> Database for CowBackend<'a> { } } -impl<'a> DatabaseCommit for CowBackend<'a> { +impl DatabaseCommit for CowBackend<'_> { fn commit(&mut self, changes: Map) { self.backend.to_mut().commit(changes) } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index ac7c31ff96a3e..589866359a539 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -471,7 +471,7 @@ impl InspectorStack { } } -impl<'a> InspectorStackRefMut<'a> { +impl InspectorStackRefMut<'_> { /// Adjusts the EVM data for the inner EVM context. /// Should be called on the top-level call of inner context (depth == 0 && /// self.in_inner_context) Decreases sender nonce for CALLs to keep backwards compatibility @@ -642,7 +642,7 @@ impl<'a> InspectorStackRefMut<'a> { } } -impl<'a> Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'a> { +impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { fn initialize_interp( &mut self, interpreter: &mut Interpreter, diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index 5b9d7fb276672..90054f1325eeb 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -409,7 +409,7 @@ impl std::iter::FusedIterator for CommentStateCharIndices<'_> {} /// An Iterator over characters in a string slice which are not a apart of comments pub struct NonCommentChars<'a>(CommentStateCharIndices<'a>); -impl<'a> Iterator for NonCommentChars<'a> { +impl Iterator for NonCommentChars<'_> { type Item = char; #[inline] diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 1dbf63eacff1d..02b7bd7fe9a5f 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1872,7 +1872,7 @@ impl<'a, W: Write> Formatter<'a, W> { } // Traverse the Solidity Parse Tree and write to the code formatter -impl<'a, W: Write> Visitor for Formatter<'a, W> { +impl Visitor for Formatter<'_, W> { type Error = FormatterError; #[instrument(name = "source", skip(self))] @@ -3843,14 +3843,14 @@ struct Transaction<'f, 'a, W> { comments: Comments, } -impl<'f, 'a, W> std::ops::Deref for Transaction<'f, 'a, W> { +impl<'a, W> std::ops::Deref for Transaction<'_, 'a, W> { type Target = Formatter<'a, W>; fn deref(&self) -> &Self::Target { self.fmt } } -impl<'f, 'a, W> std::ops::DerefMut for Transaction<'f, 'a, W> { +impl std::ops::DerefMut for Transaction<'_, '_, W> { fn deref_mut(&mut self) -> &mut Self::Target { self.fmt } diff --git a/crates/fmt/src/solang_ext/loc.rs b/crates/fmt/src/solang_ext/loc.rs index 2fcbaf995b4f3..54bf771c6df90 100644 --- a/crates/fmt/src/solang_ext/loc.rs +++ b/crates/fmt/src/solang_ext/loc.rs @@ -10,19 +10,19 @@ pub trait CodeLocationExt { fn loc(&self) -> pt::Loc; } -impl<'a, T: ?Sized + CodeLocationExt> CodeLocationExt for &'a T { +impl CodeLocationExt for &T { fn loc(&self) -> pt::Loc { (**self).loc() } } -impl<'a, T: ?Sized + CodeLocationExt> CodeLocationExt for &'a mut T { +impl CodeLocationExt for &mut T { fn loc(&self) -> pt::Loc { (**self).loc() } } -impl<'a, T: ?Sized + ToOwned + CodeLocationExt> CodeLocationExt for Cow<'a, T> { +impl CodeLocationExt for Cow<'_, T> { fn loc(&self) -> pt::Loc { (**self).loc() } diff --git a/crates/fmt/src/string.rs b/crates/fmt/src/string.rs index 1dbc2f2f61b59..ae570a39b827a 100644 --- a/crates/fmt/src/string.rs +++ b/crates/fmt/src/string.rs @@ -38,7 +38,7 @@ impl<'a> QuoteStateCharIndices<'a> { } } -impl<'a> Iterator for QuoteStateCharIndices<'a> { +impl Iterator for QuoteStateCharIndices<'_> { type Item = (QuoteState, usize, char); fn next(&mut self) -> Option { let (idx, ch) = self.iter.next()?; @@ -68,14 +68,14 @@ impl<'a> Iterator for QuoteStateCharIndices<'a> { /// An iterator over the indices of quoted string locations pub struct QuotedRanges<'a>(QuoteStateCharIndices<'a>); -impl<'a> QuotedRanges<'a> { +impl QuotedRanges<'_> { pub fn with_state(mut self, state: QuoteState) -> Self { self.0 = self.0.with_state(state); self } } -impl<'a> Iterator for QuotedRanges<'a> { +impl Iterator for QuotedRanges<'_> { type Item = (char, usize, usize); fn next(&mut self) -> Option { let (quote, start) = loop { diff --git a/crates/forge/bin/cmd/geiger/find.rs b/crates/forge/bin/cmd/geiger/find.rs index 6629390caeea8..e3cd6541334a5 100644 --- a/crates/forge/bin/cmd/geiger/find.rs +++ b/crates/forge/bin/cmd/geiger/find.rs @@ -47,7 +47,7 @@ pub struct SolFileMetricsPrinter<'a, 'b> { pub root: &'b Path, } -impl<'a, 'b> fmt::Display for SolFileMetricsPrinter<'a, 'b> { +impl fmt::Display for SolFileMetricsPrinter<'_, '_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let SolFileMetricsPrinter { metrics, root } = *self; diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index b712c8fc27814..ef9c7b0c6f0f3 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -86,7 +86,7 @@ impl<'a> LcovReporter<'a> { } } -impl<'a> CoverageReporter for LcovReporter<'a> { +impl CoverageReporter for LcovReporter<'_> { fn report(self, report: &CoverageReport) -> eyre::Result<()> { for (file, items) in report.items_by_source() { let summary = items.iter().fold(CoverageSummary::default(), |mut summary, item| { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 8f9f7ebdd8d27..2a964789b5b3d 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -76,7 +76,7 @@ pub struct ContractRunner<'a> { pub span: tracing::Span, } -impl<'a> ContractRunner<'a> { +impl ContractRunner<'_> { /// Deploys the test contract inside the runner from the sending account, and optionally runs /// the `setUp` function on the test contract. pub fn setup(&mut self, call_setup: bool) -> TestSetup { From d3ce9f08294bf3e78d0d3167f9b4a4669e262600 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 4 Oct 2024 12:48:22 +0400 Subject: [PATCH 1521/1963] fix(`--isolate`): track state in journal (#9018) * track in journal * wip * add test * forge fmt * rm selfdestruct test --- crates/evm/evm/src/inspectors/stack.rs | 315 +++++++++++++----------- crates/forge/tests/cli/test_cmd.rs | 30 --- crates/forge/tests/it/repros.rs | 7 + testdata/default/repros/Issue8971.t.sol | 50 ++++ 4 files changed, 232 insertions(+), 170 deletions(-) create mode 100644 testdata/default/repros/Issue8971.t.sol diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 589866359a539..1e3b36181e0d6 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -4,10 +4,7 @@ use super::{ }; use alloy_primitives::{map::AddressHashMap, Address, Bytes, Log, TxKind, U256}; use foundry_cheatcodes::CheatcodesExecutor; -use foundry_evm_core::{ - backend::{update_state, DatabaseExt}, - InspectorExt, -}; +use foundry_evm_core::{backend::DatabaseExt, InspectorExt}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::{SparsedTraceArena, TraceMode}; use revm::{ @@ -17,7 +14,8 @@ use revm::{ EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterResult, }, primitives::{ - BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, Output, TransactTo, + Account, AccountStatus, BlockEnv, CreateScheme, Env, EnvWithHandlerCfg, ExecutionResult, + HashMap, Output, TransactTo, }, EvmContext, Inspector, }; @@ -218,27 +216,6 @@ macro_rules! call_inspectors { }; } -/// Same as [`call_inspectors!`], but with depth adjustment for isolated execution. -macro_rules! call_inspectors_adjust_depth { - ([$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { - $data.journaled_state.depth += $self.in_inner_context as usize; - call_inspectors!([$($inspector),+], |$id| $call); - $data.journaled_state.depth -= $self.in_inner_context as usize; - }; - (#[ret] [$($inspector:expr),+ $(,)?], |$id:ident $(,)?| $call:expr, $self:ident, $data:ident $(,)?) => { - $data.journaled_state.depth += $self.in_inner_context as usize; - $( - if let Some($id) = $inspector { - if let Some(result) = ({ #[inline(always)] #[cold] || $call })() { - $data.journaled_state.depth -= $self.in_inner_context as usize; - return result; - } - } - )+ - $data.journaled_state.depth -= $self.in_inner_context as usize; - }; -} - /// The collected results of [`InspectorStack`]. pub struct InspectorData { pub logs: Vec, @@ -293,6 +270,7 @@ pub struct InspectorStackInner { /// Flag marking if we are in the inner EVM context. pub in_inner_context: bool, pub inner_context_data: Option, + pub top_frame_journal: HashMap, } /// Struct keeping mutable references to both parts of [InspectorStack] and implementing @@ -489,7 +467,7 @@ impl InspectorStackRefMut<'_> { outcome: CallOutcome, ) -> CallOutcome { let result = outcome.result.result; - call_inspectors_adjust_depth!( + call_inspectors!( #[ret] [&mut self.fuzzer, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| { @@ -502,8 +480,56 @@ impl InspectorStackRefMut<'_> { new_outcome.output() != outcome.output()); different.then_some(new_outcome) }, - self, - ecx + ); + + outcome + } + + fn do_create_end( + &mut self, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + call: &CreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { + let result = outcome.result.result; + call_inspectors!( + #[ret] + [&mut self.tracer, &mut self.cheatcodes, &mut self.printer], + |inspector| { + let new_outcome = inspector.create_end(ecx, call, outcome.clone()); + + // If the inspector returns a different status or a revert with a non-empty message, + // we assume it wants to tell us something + let different = new_outcome.result.result != result || + (new_outcome.result.result == InstructionResult::Revert && + new_outcome.output() != outcome.output()); + different.then_some(new_outcome) + }, + ); + + outcome + } + + fn do_eofcreate_end( + &mut self, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + call: &EOFCreateInputs, + outcome: CreateOutcome, + ) -> CreateOutcome { + let result = outcome.result.result; + call_inspectors!( + #[ret] + [&mut self.tracer, &mut self.cheatcodes, &mut self.printer], + |inspector| { + let new_outcome = inspector.eofcreate_end(ecx, call, outcome.clone()); + + // If the inspector returns a different status or a revert with a non-empty message, + // we assume it wants to tell us something + let different = new_outcome.result.result != result || + (new_outcome.result.result == InstructionResult::Revert && + new_outcome.output() != outcome.output()); + different.then_some(new_outcome) + }, ); outcome @@ -520,8 +546,6 @@ impl InspectorStackRefMut<'_> { ) -> (InterpreterResult, Option

) { let ecx = &mut ecx.inner; - ecx.db.commit(ecx.journaled_state.state.clone()); - let cached_env = ecx.env.clone(); ecx.env.block.basefee = U256::ZERO; @@ -545,6 +569,29 @@ impl InspectorStackRefMut<'_> { let env = EnvWithHandlerCfg::new_with_spec_id(ecx.env.clone(), ecx.spec_id()); let res = self.with_stack(|inspector| { let mut evm = crate::utils::new_evm_with_inspector(&mut ecx.db, env, inspector); + + evm.context.evm.inner.journaled_state.state = { + let mut state = ecx.journaled_state.state.clone(); + + for (addr, acc_mut) in &mut state { + // mark all accounts cold, besides preloaded addresses + if !ecx.journaled_state.warm_preloaded_addresses.contains(addr) { + acc_mut.mark_cold(); + } + + // mark all slots cold + for slot_mut in acc_mut.storage.values_mut() { + slot_mut.is_cold = true; + slot_mut.original_value = slot_mut.present_value; + } + } + + state + }; + + // set depth to 1 to make sure traces are collected correctly + evm.context.evm.inner.journaled_state.depth = 1; + let res = evm.transact(); // need to reset the env in case it was modified via cheatcodes during execution @@ -560,43 +607,35 @@ impl InspectorStackRefMut<'_> { let mut gas = Gas::new(gas_limit); - let Ok(mut res) = res else { + let Ok(res) = res else { // Should we match, encode and propagate error as a revert reason? let result = InterpreterResult { result: InstructionResult::Revert, output: Bytes::new(), gas }; return (result, None); }; - // Commit changes after transaction - ecx.db.commit(res.state.clone()); - - // Update both states with new DB data after commit. - if let Err(e) = update_state(&mut ecx.journaled_state.state, &mut ecx.db, None) { - let res = InterpreterResult { - result: InstructionResult::Revert, - output: Bytes::from(e.to_string()), - gas, - }; - return (res, None); - } - if let Err(e) = update_state(&mut res.state, &mut ecx.db, None) { - let res = InterpreterResult { - result: InstructionResult::Revert, - output: Bytes::from(e.to_string()), - gas, + for (addr, mut acc) in res.state { + let Some(acc_mut) = ecx.journaled_state.state.get_mut(&addr) else { + ecx.journaled_state.state.insert(addr, acc); + continue }; - return (res, None); - } - // Merge transaction journal into the active journal. - for (addr, acc) in res.state { - if let Some(acc_mut) = ecx.journaled_state.state.get_mut(&addr) { - acc_mut.status |= acc.status; - for (key, val) in acc.storage { - acc_mut.storage.entry(key).or_insert(val); - } - } else { - ecx.journaled_state.state.insert(addr, acc); + // make sure accounts that were warmed earlier do not become cold + if acc.status.contains(AccountStatus::Cold) && + !acc_mut.status.contains(AccountStatus::Cold) + { + acc.status -= AccountStatus::Cold; + } + acc_mut.info = acc.info; + acc_mut.status |= acc.status; + + for (key, val) in acc.storage { + let Some(slot_mut) = acc_mut.storage.get_mut(&key) else { + acc_mut.storage.insert(key, val); + continue + }; + slot_mut.present_value = val.present_value; + slot_mut.is_cold &= val.is_cold; } } @@ -640,6 +679,39 @@ impl InspectorStackRefMut<'_> { out } + + /// Invoked at the beginning of a new top-level (0 depth) frame. + fn top_level_frame_start(&mut self, ecx: &mut EvmContext<&mut dyn DatabaseExt>) { + if self.enable_isolation { + // If we're in isolation mode, we need to keep track of the state at the beginning of + // the frame to be able to roll back on revert + self.top_frame_journal = ecx.journaled_state.state.clone(); + } + } + + /// Invoked at the end of root frame. + fn top_level_frame_end( + &mut self, + ecx: &mut EvmContext<&mut dyn DatabaseExt>, + result: InstructionResult, + ) { + if !result.is_revert() { + return; + } + // Encountered a revert, since cheatcodes may have altered the evm state in such a way + // that violates some constraints, e.g. `deal`, we need to manually roll back on revert + // before revm reverts the state itself + if let Some(cheats) = self.cheatcodes.as_mut() { + cheats.on_revert(ecx); + } + + // If we're in isolation mode, we need to rollback to state before the root frame was + // created We can't rely on revm's journal because it doesn't account for changes + // made by isolated calls + if self.enable_isolation { + ecx.journaled_state.state = std::mem::take(&mut self.top_frame_journal); + } + } } impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { @@ -648,16 +720,14 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut dyn DatabaseExt>, ) { - call_inspectors_adjust_depth!( + call_inspectors!( [&mut self.coverage, &mut self.tracer, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.initialize_interp(interpreter, ecx), - self, - ecx ); } fn step(&mut self, interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut dyn DatabaseExt>) { - call_inspectors_adjust_depth!( + call_inspectors!( [ &mut self.fuzzer, &mut self.tracer, @@ -666,8 +736,6 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { &mut self.printer, ], |inspector| inspector.step(interpreter, ecx), - self, - ecx ); } @@ -676,11 +744,9 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { interpreter: &mut Interpreter, ecx: &mut EvmContext<&mut dyn DatabaseExt>, ) { - call_inspectors_adjust_depth!( + call_inspectors!( [&mut self.tracer, &mut self.cheatcodes, &mut self.chisel_state, &mut self.printer], |inspector| inspector.step_end(interpreter, ecx), - self, - ecx ); } @@ -690,11 +756,9 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { ecx: &mut EvmContext<&mut dyn DatabaseExt>, log: &Log, ) { - call_inspectors_adjust_depth!( + call_inspectors!( [&mut self.tracer, &mut self.log_collector, &mut self.cheatcodes, &mut self.printer], |inspector| inspector.log(interpreter, ecx, log), - self, - ecx ); } @@ -703,12 +767,16 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { ecx: &mut EvmContext<&mut dyn DatabaseExt>, call: &mut CallInputs, ) -> Option { - if self.in_inner_context && ecx.journaled_state.depth == 0 { + if self.in_inner_context && ecx.journaled_state.depth == 1 { self.adjust_evm_data_for_inner_context(ecx); return None; } - call_inspectors_adjust_depth!( + if ecx.journaled_state.depth == 0 { + self.top_level_frame_start(ecx); + } + + call_inspectors!( #[ret] [&mut self.fuzzer, &mut self.tracer, &mut self.log_collector, &mut self.printer], |inspector| { @@ -720,11 +788,8 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { } out }, - self, - ecx ); - ecx.journaled_state.depth += self.in_inner_context as usize; if let Some(cheatcodes) = self.cheatcodes.as_deref_mut() { // Handle mocked functions, replace bytecode address with mock if matched. if let Some(mocks) = cheatcodes.mocked_functions.get(&call.target_address) { @@ -740,12 +805,10 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { if let Some(output) = cheatcodes.call_with_executor(ecx, call, self.inner) { if output.result.result != InstructionResult::Continue { - ecx.journaled_state.depth -= self.in_inner_context as usize; return Some(output); } } } - ecx.journaled_state.depth -= self.in_inner_context as usize; if self.enable_isolation && call.scheme == CallScheme::Call && @@ -772,20 +835,16 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { inputs: &CallInputs, outcome: CallOutcome, ) -> CallOutcome { - // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. - // Avoid processing twice. - if self.in_inner_context && ecx.journaled_state.depth == 0 { + // We are processing inner context outputs in the outer context, so need to avoid processing + // twice. + if self.in_inner_context && ecx.journaled_state.depth == 1 { return outcome; } let outcome = self.do_call_end(ecx, inputs, outcome); - if outcome.result.is_revert() { - // Encountered a revert, since cheatcodes may have altered the evm state in such a way - // that violates some constraints, e.g. `deal`, we need to manually roll back on revert - // before revm reverts the state itself - if let Some(cheats) = self.cheatcodes.as_mut() { - cheats.on_revert(ecx); - } + + if ecx.journaled_state.depth == 0 { + self.top_level_frame_end(ecx, outcome.result.result); } outcome @@ -796,17 +855,19 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { ecx: &mut EvmContext<&mut dyn DatabaseExt>, create: &mut CreateInputs, ) -> Option { - if self.in_inner_context && ecx.journaled_state.depth == 0 { + if self.in_inner_context && ecx.journaled_state.depth == 1 { self.adjust_evm_data_for_inner_context(ecx); return None; } - call_inspectors_adjust_depth!( + if ecx.journaled_state.depth == 0 { + self.top_level_frame_start(ecx); + } + + call_inspectors!( #[ret] [&mut self.tracer, &mut self.coverage, &mut self.cheatcodes], |inspector| inspector.create(ecx, create).map(Some), - self, - ecx ); if !matches!(create.scheme, CreateScheme::Create2 { .. }) && @@ -834,30 +895,17 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { call: &CreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { - // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. - // Avoid processing twice. - if self.in_inner_context && ecx.journaled_state.depth == 0 { + // We are processing inner context outputs in the outer context, so need to avoid processing + // twice. + if self.in_inner_context && ecx.journaled_state.depth == 1 { return outcome; } - let result = outcome.result.result; - - call_inspectors_adjust_depth!( - #[ret] - [&mut self.tracer, &mut self.cheatcodes, &mut self.printer], - |inspector| { - let new_outcome = inspector.create_end(ecx, call, outcome.clone()); + let outcome = self.do_create_end(ecx, call, outcome); - // If the inspector returns a different status or a revert with a non-empty message, - // we assume it wants to tell us something - let different = new_outcome.result.result != result || - (new_outcome.result.result == InstructionResult::Revert && - new_outcome.output() != outcome.output()); - different.then_some(new_outcome) - }, - self, - ecx - ); + if ecx.journaled_state.depth == 0 { + self.top_level_frame_end(ecx, outcome.result.result); + } outcome } @@ -867,17 +915,19 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { ecx: &mut EvmContext<&mut dyn DatabaseExt>, create: &mut EOFCreateInputs, ) -> Option { - if self.in_inner_context && ecx.journaled_state.depth == 0 { + if self.in_inner_context && ecx.journaled_state.depth == 1 { self.adjust_evm_data_for_inner_context(ecx); return None; } - call_inspectors_adjust_depth!( + if ecx.journaled_state.depth == 0 { + self.top_level_frame_start(ecx); + } + + call_inspectors!( #[ret] [&mut self.tracer, &mut self.coverage, &mut self.cheatcodes], |inspector| inspector.eofcreate(ecx, create).map(Some), - self, - ecx ); if matches!(create.kind, EOFCreateKind::Tx { .. }) && @@ -910,30 +960,17 @@ impl Inspector<&mut dyn DatabaseExt> for InspectorStackRefMut<'_> { call: &EOFCreateInputs, outcome: CreateOutcome, ) -> CreateOutcome { - // Inner context calls with depth 0 are being dispatched as top-level calls with depth 1. - // Avoid processing twice. - if self.in_inner_context && ecx.journaled_state.depth == 0 { + // We are processing inner context outputs in the outer context, so need to avoid processing + // twice. + if self.in_inner_context && ecx.journaled_state.depth == 1 { return outcome; } - let result = outcome.result.result; - - call_inspectors_adjust_depth!( - #[ret] - [&mut self.tracer, &mut self.cheatcodes, &mut self.printer], - |inspector| { - let new_outcome = inspector.eofcreate_end(ecx, call, outcome.clone()); + let outcome = self.do_eofcreate_end(ecx, call, outcome); - // If the inspector returns a different status or a revert with a non-empty message, - // we assume it wants to tell us something - let different = new_outcome.result.result != result || - (new_outcome.result.result == InstructionResult::Revert && - new_outcome.output() != outcome.output()); - different.then_some(new_outcome) - }, - self, - ecx - ); + if ecx.journaled_state.depth == 0 { + self.top_level_frame_end(ecx, outcome.result.result); + } outcome } @@ -951,12 +988,10 @@ impl InspectorExt for InspectorStackRefMut<'_> { ecx: &mut EvmContext<&mut dyn DatabaseExt>, inputs: &mut CreateInputs, ) -> bool { - call_inspectors_adjust_depth!( + call_inspectors!( #[ret] [&mut self.cheatcodes], |inspector| { inspector.should_use_create2_factory(ecx, inputs).then_some(true) }, - self, - ecx ); false diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 63a4a92106994..28362671b756c 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -597,36 +597,6 @@ Encountered a total of 1 failing tests, 1 tests succeeded "#]]); }); -forgetest_init!(can_test_selfdestruct_with_isolation, |prj, cmd| { - prj.wipe_contracts(); - - prj.add_test( - "Contract.t.sol", - r#" -import {Test} from "forge-std/Test.sol"; - -contract Destructing { - function destruct() public { - selfdestruct(payable(address(0))); - } -} - -contract SelfDestructTest is Test { - function test() public { - Destructing d = new Destructing(); - vm.store(address(d), bytes32(0), bytes32(uint256(1))); - d.destruct(); - assertEq(address(d).code.length, 0); - assertEq(vm.load(address(d), bytes32(0)), bytes32(0)); - } -} - "#, - ) - .unwrap(); - - cmd.args(["test", "-vvvv", "--isolate"]).assert_success(); -}); - forgetest_init!(can_test_transient_storage_with_isolation, |prj, cmd| { prj.wipe_contracts(); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index d463d12dd7c72..9f46e3c2ec1fc 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -387,3 +387,10 @@ test_repro!(1543); // https://github.com/foundry-rs/foundry/issues/6643 test_repro!(6643); + +// https://github.com/foundry-rs/foundry/issues/8971 +test_repro!(8971; |config| { + let mut prj_config = Config::clone(&config.runner.config); + prj_config.isolate = true; + config.runner.config = Arc::new(prj_config); +}); diff --git a/testdata/default/repros/Issue8971.t.sol b/testdata/default/repros/Issue8971.t.sol new file mode 100644 index 0000000000000..d61e04ae60b93 --- /dev/null +++ b/testdata/default/repros/Issue8971.t.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Counter { + uint256 public number; + + function increment() public { + number++; + } +} + +/// @notice Test is mostly related to --isolate. Ensures that state is not affected by reverted +/// call to handler. +contract Handler { + bool public locked; + Counter public counter = new Counter(); + + function doNothing() public {} + + function doSomething() public { + locked = true; + counter.increment(); + this.doRevert(); + } + + function doRevert() public { + revert(); + } +} + +contract Invariant is DSTest { + Handler h; + + function setUp() public { + h = new Handler(); + } + + function targetContracts() public view returns (address[] memory contracts) { + contracts = new address[](1); + contracts[0] = address(h); + } + + function invariant_unchanged() public { + assertEq(h.locked(), false); + assertEq(h.counter().number(), 0); + } +} From eb046653de4047a27b181394338732e597965257 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 4 Oct 2024 16:47:37 +0200 Subject: [PATCH 1522/1963] fix: handle large years (#9032) --- crates/anvil/src/eth/backend/mem/mod.rs | 8 +++++++- crates/anvil/tests/it/anvil.rs | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0b002d3db7ec8..05a7a3ff7a7b4 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -66,6 +66,7 @@ use anvil_core::eth::{ utils::meets_eip155, }; use anvil_rpc::error::RpcError; +use chrono::Datelike; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertStateSnapshotAction}, @@ -1123,7 +1124,12 @@ impl Backend { node_info!(" Block Number: {}", block_number); node_info!(" Block Hash: {:?}", block_hash); - node_info!(" Block Time: {:?}\n", timestamp.to_rfc2822()); + if timestamp.year() > 9999 { + // rf2822 panics with more than 4 digits + node_info!(" Block Time: {:?}\n", timestamp.to_rfc3339()); + } else { + node_info!(" Block Time: {:?}\n", timestamp.to_rfc2822()); + } let outcome = MinedBlockOutcome { block_number, included, invalid }; diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index b8aed751d2e6e..50e27c57aa57c 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -1,5 +1,6 @@ //! tests for anvil specific logic +use alloy_eips::BlockNumberOrTag; use alloy_primitives::Address; use alloy_provider::Provider; use anvil::{spawn, NodeConfig}; @@ -76,3 +77,14 @@ async fn test_can_use_default_genesis_timestamp() { provider.get_block(0.into(), false.into()).await.unwrap().unwrap().header.timestamp ); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_can_handle_large_timestamp() { + let (api, _handle) = spawn(NodeConfig::test()).await; + let num = 317071597274; + api.evm_set_next_block_timestamp(num).unwrap(); + api.mine_one().await; + + let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert_eq!(block.header.timestamp, num); +} From f089dff1c6c24d1ddf43c7cbefee46ea0197c88f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sat, 5 Oct 2024 20:14:48 +0400 Subject: [PATCH 1523/1963] fix(`forge eip712`): fix handling of subtypes (#9035) * fix(forge eip712): fix handling of subtypes * fmt * clippy --- crates/forge/bin/cmd/bind_json.rs | 5 +-- crates/forge/bin/cmd/eip712.rs | 37 +++++++++++++++------- crates/forge/tests/cli/eip712.rs | 52 +++++++++++++++++++++++++++++++ crates/forge/tests/cli/main.rs | 1 + 4 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 crates/forge/tests/cli/eip712.rs diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index d01abd60b8509..2736325a7e20f 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -309,10 +309,7 @@ impl CompiledState { for ((path, id), (def, contract_name)) in structs { // For some structs there's no schema (e.g. if they contain a mapping), so we just skip // those. - let Some(schema) = resolver.resolve_struct_eip712(id, &mut Default::default(), true)? - else { - continue - }; + let Some(schema) = resolver.resolve_struct_eip712(id)? else { continue }; if !include.is_empty() { if !include.iter().any(|matcher| matcher.is_match(path)) { diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs index 636c305806dc8..f026d5848c55d 100644 --- a/crates/forge/bin/cmd/eip712.rs +++ b/crates/forge/bin/cmd/eip712.rs @@ -11,7 +11,7 @@ use foundry_compilers::{ }, CompilerSettings, }; -use std::{collections::BTreeMap, path::PathBuf}; +use std::{collections::BTreeMap, fmt::Write, path::PathBuf}; foundry_config::impl_figment_convert!(Eip712Args, opts); @@ -62,9 +62,7 @@ impl Eip712Args { }; for (id, _) in structs_in_target { - if let Some(resolved) = - resolver.resolve_struct_eip712(id, &mut Default::default(), true)? - { + if let Some(resolved) = resolver.resolve_struct_eip712(id)? { println!("{resolved}"); println!(); } @@ -128,14 +126,19 @@ impl Resolver { /// /// Returns `None` if struct contains any fields that are not supported by EIP-712 (e.g. /// mappings or function pointers). - pub fn resolve_struct_eip712( + pub fn resolve_struct_eip712(&self, id: usize) -> Result> { + self.resolve_eip712_inner(id, &mut Default::default(), true, None) + } + + fn resolve_eip712_inner( &self, id: usize, subtypes: &mut BTreeMap, append_subtypes: bool, + rename: Option<&str>, ) -> Result> { let def = &self.structs[&id]; - let mut result = format!("{}(", def.name); + let mut result = format!("{}(", rename.unwrap_or(&def.name)); for (idx, member) in def.members.iter().enumerate() { let Some(ty) = self.resolve_type( @@ -146,9 +149,7 @@ impl Resolver { return Ok(None) }; - result.push_str(&ty); - result.push(' '); - result.push_str(&member.name); + write!(result, "{ty} {name}", name = member.name)?; if idx < def.members.len() - 1 { result.push(','); @@ -161,11 +162,14 @@ impl Resolver { return Ok(Some(result)) } - for subtype_id in subtypes.values().copied().collect::>() { + for (subtype_name, subtype_id) in + subtypes.iter().map(|(name, id)| (name.clone(), *id)).collect::>() + { if subtype_id == id { continue } - let Some(encoded_subtype) = self.resolve_struct_eip712(subtype_id, subtypes, false)? + let Some(encoded_subtype) = + self.resolve_eip712_inner(subtype_id, subtypes, false, Some(&subtype_name))? else { return Ok(None) }; @@ -204,6 +208,17 @@ impl Resolver { name.clone() // Otherwise, try assigning a new name. } else { + // iterate over members to check if they are resolvable and to populate subtypes + for member in &def.members { + if self.resolve_type( + member.type_name.as_ref().ok_or_eyre("missing type name")?, + subtypes, + )? + .is_none() + { + return Ok(None) + } + } let mut i = 0; let mut name = def.name.clone(); while subtypes.contains_key(&name) { diff --git a/crates/forge/tests/cli/eip712.rs b/crates/forge/tests/cli/eip712.rs new file mode 100644 index 0000000000000..2f832ae315c62 --- /dev/null +++ b/crates/forge/tests/cli/eip712.rs @@ -0,0 +1,52 @@ +forgetest!(test_eip712, |prj, cmd| { + let path = prj + .add_source( + "Structs", + r#" +library Structs { + struct Foo { + Bar bar; + } + + struct Bar { + Art art; + } + + struct Art { + uint256 id; + } + + struct Complex { + Structs2.Foo foo2; + Foo[] foos; + } +} + +library Structs2 { + struct Foo { + uint256 id; + } +} +"#, + ) + .unwrap(); + + cmd.forge_fuse().args(["eip712", path.to_string_lossy().as_ref()]).assert_success().stdout_eq( + str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +No files changed, compilation skipped +Foo(Bar bar)Art(uint256 id)Bar(Art art) + +Bar(Art art)Art(uint256 id) + +Art(uint256 id) + +Complex(Foo foo2,Foo_1[] foos)Art(uint256 id)Bar(Art art)Foo(uint256 id)Foo_1(Bar bar) + +Foo(uint256 id) + + +"#]], + ); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 53c5604577906..6ad29ca48a935 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -15,6 +15,7 @@ mod coverage; mod create; mod debug; mod doc; +mod eip712; mod multi_script; mod script; mod soldeer; From a5f922d6fb0195b46a0c9c39b658175d7ad817ac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 6 Oct 2024 04:22:59 +0200 Subject: [PATCH 1524/1963] chore(deps): weekly `cargo update` (#9041) Locking 40 packages to latest compatible versions Updating alloy-chains v0.1.34 -> v0.1.36 Updating alloy-network-primitives v0.4.0 -> v0.4.2 Updating alloy-rpc-types-anvil v0.4.0 -> v0.4.2 Updating alloy-rpc-types-engine v0.4.0 -> v0.4.2 Updating alloy-rpc-types-eth v0.4.0 -> v0.4.2 Updating alloy-rpc-types-trace v0.4.0 -> v0.4.2 Updating alloy-rpc-types-txpool v0.4.0 -> v0.4.2 Updating async-compression v0.4.12 -> v0.4.13 Updating async-stream v0.3.5 -> v0.3.6 Updating async-stream-impl v0.3.5 -> v0.3.6 Updating aws-config v1.5.7 -> v1.5.8 Updating aws-sdk-kms v1.45.0 -> v1.46.0 Updating aws-sdk-sso v1.44.0 -> v1.45.0 Updating aws-sdk-ssooidc v1.45.0 -> v1.46.0 Updating aws-sdk-sts v1.44.0 -> v1.45.0 Updating cc v1.1.24 -> v1.1.25 Updating clap v4.5.18 -> v4.5.19 Updating clap_builder v4.5.18 -> v4.5.19 Updating clap_complete v4.5.29 -> v4.5.32 Updating futures v0.3.30 -> v0.3.31 Updating futures-channel v0.3.30 -> v0.3.31 Updating futures-core v0.3.30 -> v0.3.31 Updating futures-executor v0.3.30 -> v0.3.31 Updating futures-io v0.3.30 -> v0.3.31 Updating futures-macro v0.3.30 -> v0.3.31 Updating futures-sink v0.3.30 -> v0.3.31 Updating futures-task v0.3.30 -> v0.3.31 Updating futures-util v0.3.30 -> v0.3.31 Updating gcloud-sdk v0.25.6 -> v0.25.7 Adding hashbrown v0.15.0 Updating indexmap v2.5.0 -> v2.6.0 Updating ipnet v2.10.0 -> v2.10.1 Updating once_cell v1.20.1 -> v1.20.2 Updating pin-project v1.1.5 -> v1.1.6 Updating pin-project-internal v1.1.5 -> v1.1.6 Updating rustls v0.23.13 -> v0.23.14 Updating snapbox v0.6.17 -> v0.6.18 Updating terminal_size v0.3.0 -> v0.4.0 Updating unicode-bidi v0.3.15 -> v0.3.17 Adding unicode-width v0.2.0 note: pass `--verbose` to see 9 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 265 +++++++++++++++++++++++++++-------------------------- 1 file changed, 137 insertions(+), 128 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70ea8bef4cab0..80fbb62121549 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.34" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8158b4878c67837e5413721cc44298e6a2d88d39203175ea025e51892a16ba4c" +checksum = "94c225801d42099570d0674701dddd4142f0ef715282aeb5985042e2ec962df7" dependencies = [ "num_enum", "serde", @@ -122,11 +122,11 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-network", - "alloy-network-primitives 0.4.0", + "alloy-network-primitives 0.4.2", "alloy-primitives", "alloy-provider", "alloy-pubsub", - "alloy-rpc-types-eth 0.4.0", + "alloy-rpc-types-eth 0.4.2", "alloy-sol-types", "alloy-transport", "futures", @@ -264,9 +264,9 @@ dependencies = [ "alloy-consensus 0.4.2", "alloy-eips 0.4.2", "alloy-json-rpc", - "alloy-network-primitives 0.4.0", + "alloy-network-primitives 0.4.2", "alloy-primitives", - "alloy-rpc-types-eth 0.4.0", + "alloy-rpc-types-eth 0.4.2", "alloy-serde 0.4.2", "alloy-signer", "alloy-sol-types", @@ -290,9 +290,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8416e4e9ceee8014d2f89fc3dde331da392b26d14226a0d5cbc207ae7799fb2f" +checksum = "801492711d4392b2ccf5fc0bc69e299fa1aab15167d74dcaa9aab96a54f684bd" dependencies = [ "alloy-consensus 0.4.2", "alloy-eips 0.4.2", @@ -317,7 +317,7 @@ dependencies = [ "getrandom", "hashbrown 0.14.5", "hex-literal", - "indexmap 2.5.0", + "indexmap 2.6.0", "itoa", "k256", "keccak-asm", @@ -343,11 +343,11 @@ dependencies = [ "alloy-eips 0.4.2", "alloy-json-rpc", "alloy-network", - "alloy-network-primitives 0.4.0", + "alloy-network-primitives 0.4.2", "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types-eth 0.4.0", + "alloy-rpc-types-eth 0.4.2", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", "alloy-transport", @@ -361,7 +361,7 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", - "pin-project 1.1.5", + "pin-project 1.1.6", "reqwest", "serde", "serde_json", @@ -426,7 +426,7 @@ dependencies = [ "alloy-transport-ipc", "alloy-transport-ws", "futures", - "pin-project 1.1.5", + "pin-project 1.1.6", "reqwest", "serde", "serde_json", @@ -446,7 +446,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", "alloy-rpc-types-engine", - "alloy-rpc-types-eth 0.4.0", + "alloy-rpc-types-eth 0.4.2", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", "alloy-serde 0.4.2", @@ -455,9 +455,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142f6fb21ef1857b3d175dc16b73d67f4b70914e6898610da3c0b65a1281fe7b" +checksum = "d780adaa5d95b07ad92006b2feb68ecfa7e2015f7d5976ceaac4c906c73ebd07" dependencies = [ "alloy-primitives", "alloy-serde 0.4.2", @@ -466,9 +466,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c032e9b725a990be03cc0ddd9fa73c21f61d1449b328083aa22fbfafb03eda1b" +checksum = "e0285c4c09f838ab830048b780d7f4a4f460f309aa1194bb049843309524c64c" dependencies = [ "alloy-consensus 0.4.2", "alloy-eips 0.4.2", @@ -505,13 +505,13 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e1f655dcd5e9ccf215cbffb69272698ef6b3ec76907e8937345f2a82ae04ed4" +checksum = "413f4aa3ccf2c3e4234a047c5fa4727916d7daf25a89f9b765df0ba09784fd87" dependencies = [ "alloy-consensus 0.4.2", "alloy-eips 0.4.2", - "alloy-network-primitives 0.4.0", + "alloy-network-primitives 0.4.2", "alloy-primitives", "alloy-rlp", "alloy-serde 0.4.2", @@ -524,12 +524,12 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6900c7d94528217465f6b619f03adb2eecc9682f9083d49ad7d40ec6eda0ed04" +checksum = "017cad3e5793c5613588c1f9732bcbad77e820ba7d0feaba3527749f856fdbc5" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 0.4.0", + "alloy-rpc-types-eth 0.4.2", "alloy-serde 0.4.2", "serde", "serde_json", @@ -538,12 +538,12 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "954781be5ca2e15db08d753712f494504a04771ee4296de1e834e65c105b8ec3" +checksum = "2b230e321c416be7f50530159392b4c41a45596d40d97e185575bcd0b545e521" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 0.4.0", + "alloy-rpc-types-eth 0.4.2", "alloy-serde 0.4.2", "serde", ] @@ -702,7 +702,7 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.5.0", + "indexmap 2.6.0", "proc-macro-error2", "proc-macro2", "quote", @@ -797,7 +797,7 @@ dependencies = [ "bytes", "futures", "interprocess", - "pin-project 1.1.5", + "pin-project 1.1.6", "serde", "serde_json", "tempfile", @@ -816,7 +816,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.13", + "rustls 0.23.14", "serde_json", "tokio", "tokio-tungstenite", @@ -1032,7 +1032,7 @@ dependencies = [ "futures", "interprocess", "parking_lot", - "pin-project 1.1.5", + "pin-project 1.1.6", "serde", "serde_json", "thiserror", @@ -1062,7 +1062,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44055e597c674aef7cb903b2b9f6e4cba1277ed0d2d61dae7cd52d7ffa81f8e2" dependencies = [ - "unicode-width", + "unicode-width 0.1.14", "yansi", ] @@ -1207,9 +1207,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa" +checksum = "7e614738943d3f68c628ae3dbce7c3daffb196665f82f8c8ea6b65de73c79429" dependencies = [ "flate2", "futures-core", @@ -1240,9 +1240,9 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -1251,9 +1251,9 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", @@ -1332,9 +1332,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8191fb3091fa0561d1379ef80333c3c7191c6f0435d986e85821bcf7acbd1126" +checksum = "7198e6f03240fdceba36656d8be440297b6b82270325908c7381f37d826a74f6" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1399,9 +1399,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.45.0" +version = "1.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0caf20b8855dbeb458552e6c8f8f9eb92b95e4a131725b93540ec73d60c38eb3" +checksum = "e33590e8d45206fdc4273ded8a1f292bcceaadd513037aa790fc67b237bc30ee" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1421,9 +1421,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.44.0" +version = "1.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b90cfe6504115e13c41d3ea90286ede5aa14da294f3fe077027a6e83850843c" +checksum = "e33ae899566f3d395cbf42858e433930682cc9c1889fa89318896082fef45efb" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1443,9 +1443,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.45.0" +version = "1.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167c0fad1f212952084137308359e8e4c4724d1c643038ce163f06de9662c1d0" +checksum = "f39c09e199ebd96b9f860b0fce4b6625f211e064ad7c8693b72ecf7ef03881e0" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1465,9 +1465,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.44.0" +version = "1.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb5f98188ec1435b68097daa2a37d74b9d17c9caa799466338a8d1544e71b9d" +checksum = "3d95f93a98130389eb6233b9d615249e543f6c24a68ca1f109af9ca5164a8765" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1994,9 +1994,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.24" +version = "1.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" +checksum = "e8d9e0b4957f635b8d3da819d0db5603620467ecf1f692d22a8c2717ce27e6d8" dependencies = [ "shlex", ] @@ -2109,9 +2109,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.18" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" dependencies = [ "clap_builder", "clap_derive", @@ -2119,9 +2119,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.18" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" dependencies = [ "anstream", "anstyle", @@ -2129,14 +2129,14 @@ dependencies = [ "strsim", "terminal_size", "unicase", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] name = "clap_complete" -version = "4.5.29" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" +checksum = "74a01f4f9ee6c066d42a1c8dedf0dcddad16c72a8981a309d6398de3a75b0c39" dependencies = [ "clap", ] @@ -2307,7 +2307,7 @@ dependencies = [ "crossterm 0.27.0", "strum", "strum_macros", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -2342,7 +2342,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] @@ -4055,7 +4055,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap 2.5.0", + "indexmap 2.6.0", "itertools 0.13.0", "parking_lot", "proptest", @@ -4239,9 +4239,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -4254,9 +4254,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -4264,15 +4264,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -4281,15 +4281,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -4298,21 +4298,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -4334,9 +4334,9 @@ checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" [[package]] name = "gcloud-sdk" -version = "0.25.6" +version = "0.25.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d92f38cbe5b8796d2ab3f3c5f3bc286aa778015d5c5f67e2d0cbbe5d348473f" +checksum = "2a1130d4e37435a63bd9d968a33c11b64bf35a2013779a353e29cd3598989d39" dependencies = [ "async-trait", "bytes", @@ -4668,7 +4668,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.5.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -4687,7 +4687,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.5.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -4735,6 +4735,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.5.0" @@ -4973,7 +4979,7 @@ dependencies = [ "http 1.1.0", "hyper 1.4.1", "hyper-util", - "rustls 0.23.13", + "rustls 0.23.14", "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", @@ -5160,13 +5166,13 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "arbitrary", "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.0", "serde", ] @@ -5180,7 +5186,7 @@ dependencies = [ "instant", "number_prefix", "portable-atomic", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -5271,9 +5277,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" @@ -5670,7 +5676,7 @@ dependencies = [ "cfg-if", "miette-derive", "thiserror", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -6073,12 +6079,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.1" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" -dependencies = [ - "portable-atomic", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -6423,7 +6426,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.5.0", + "indexmap 2.6.0", ] [[package]] @@ -6518,11 +6521,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ - "pin-project-internal 1.1.5", + "pin-project-internal 1.1.6", ] [[package]] @@ -6538,9 +6541,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", @@ -6773,7 +6776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38ee68ae331824036479c84060534b18254c864fa73366c58d86db3b7b811619" dependencies = [ "futures", - "indexmap 2.5.0", + "indexmap 2.6.0", "nix 0.28.0", "tokio", "tracing", @@ -6911,7 +6914,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62ffd2f9a162cfae131bed6d9d1ed60adced33be340a94f96952897d7cb0c240" dependencies = [ "chrono", - "indexmap 2.5.0", + "indexmap 2.6.0", "newtype-uuid", "quick-xml 0.36.2", "strip-ansi-escapes", @@ -6957,7 +6960,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.13", + "rustls 0.23.14", "socket2", "thiserror", "tokio", @@ -6974,7 +6977,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.13", + "rustls 0.23.14", "slab", "thiserror", "tinyvec", @@ -7077,7 +7080,7 @@ dependencies = [ "strum_macros", "unicode-segmentation", "unicode-truncate", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -7205,7 +7208,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.13", + "rustls 0.23.14", "rustls-native-certs 0.8.0", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7250,7 +7253,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43c44af0bf801f48d25f7baf25cf72aff4c02d610f83b428175228162fef0246" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 0.4.0", + "alloy-rpc-types-eth 0.4.2", "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", @@ -7504,9 +7507,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" dependencies = [ "log", "once_cell", @@ -7622,7 +7625,7 @@ dependencies = [ "nix 0.28.0", "radix_trie", "unicode-segmentation", - "unicode-width", + "unicode-width 0.1.14", "utf8parse", "windows-sys 0.52.0", ] @@ -7906,7 +7909,7 @@ version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "itoa", "memchr", "ryu", @@ -8160,9 +8163,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snapbox" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "840b73eb3148bc3cbc10ebe00ec9bc6d96033e658d022c4adcbf3f35596fd64a" +checksum = "7ba434818a8a9b1b106404288d6bd75a94348aae8fc9a518b211b609a36a54bc" dependencies = [ "anstream", "anstyle", @@ -8476,12 +8479,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" dependencies = [ "rustix", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -8684,7 +8687,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.13", + "rustls 0.23.14", "rustls-pki-types", "tokio", ] @@ -8721,7 +8724,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.13", + "rustls 0.23.14", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -8757,7 +8760,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -8779,7 +8782,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -8805,7 +8808,7 @@ dependencies = [ "hyper-timeout", "hyper-util", "percent-encoding", - "pin-project 1.1.5", + "pin-project 1.1.6", "prost", "rustls-native-certs 0.8.0", "rustls-pemfile 2.2.0", @@ -8834,7 +8837,7 @@ dependencies = [ "futures-core", "futures-util", "indexmap 1.9.3", - "pin-project 1.1.5", + "pin-project 1.1.6", "pin-project-lite", "rand", "slab", @@ -9046,7 +9049,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.13", + "rustls 0.23.14", "rustls-pki-types", "sha1", "thiserror", @@ -9103,9 +9106,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-bom" @@ -9142,7 +9145,7 @@ checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" dependencies = [ "itertools 0.13.0", "unicode-segmentation", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -9151,6 +9154,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -9909,7 +9918,7 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap 2.5.0", + "indexmap 2.6.0", "memchr", "thiserror", "zopfli", From 8905af382e04b1bf3a492880abe5904a56e88491 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 6 Oct 2024 13:10:35 +0400 Subject: [PATCH 1525/1963] fix: normalize EVM version in chisel (#9040) * fix: normalize EVM version in chisel * rm test * clippy * fix --- crates/chisel/src/session_source.rs | 16 +++++----------- crates/chisel/tests/cache.rs | 27 +-------------------------- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index e1b31a972a37f..f80761e0de86b 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -106,16 +106,6 @@ impl SessionSourceConfig { match solc_req { SolcReq::Version(version) => { - // Validate that the requested evm version is supported by the solc version - let req_evm_version = self.foundry_config.evm_version; - if let Some(compat_evm_version) = req_evm_version.normalize_version_solc(&version) { - if req_evm_version > compat_evm_version { - eyre::bail!( - "The set evm version, {req_evm_version}, is not supported by solc {version}. Upgrade to a newer solc version." - ); - } - } - let solc = if let Some(solc) = Solc::find_svm_installed_version(&version)? { solc } else { @@ -322,7 +312,11 @@ impl SessionSource { let settings = Settings { remappings, - evm_version: Some(self.config.foundry_config.evm_version), + evm_version: self + .config + .foundry_config + .evm_version + .normalize_version_solc(&self.solc.version), ..Default::default() }; diff --git a/crates/chisel/tests/cache.rs b/crates/chisel/tests/cache.rs index 5f0864beeeb8a..7016bce09c76e 100644 --- a/crates/chisel/tests/cache.rs +++ b/crates/chisel/tests/cache.rs @@ -1,7 +1,6 @@ use chisel::session::ChiselSession; use foundry_compilers::artifacts::EvmVersion; -use foundry_config::{Config, SolcReq}; -use semver::Version; +use foundry_config::Config; use serial_test::serial; use std::path::Path; @@ -221,27 +220,3 @@ fn test_load_latest_cache() { assert_eq!(new_env.id.unwrap(), "1"); assert_eq!(new_env.session_source.to_repl_source(), env.session_source.to_repl_source()); } - -#[test] -#[serial] -fn test_solc_evm_configuration_mismatch() { - // Create and clear the cache directory - ChiselSession::create_cache_dir().unwrap(); - ChiselSession::clear_cache().unwrap(); - - // Force the solc version to be 0.8.13 which does not support Paris - let foundry_config = Config { - evm_version: EvmVersion::Paris, - solc: Some(SolcReq::Version(Version::new(0, 8, 13))), - ..Default::default() - }; - - // Create a new session that is expected to fail - let error = ChiselSession::new(chisel::session_source::SessionSourceConfig { - foundry_config, - ..Default::default() - }) - .unwrap_err(); - - assert_eq!(error.to_string(), "The set evm version, paris, is not supported by solc 0.8.13. Upgrade to a newer solc version."); -} From 47f1ecb9c6f7e251c5bf2452c1f327d5508481a9 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:12:16 +0200 Subject: [PATCH 1526/1963] fix(`cheatcodes`): mark `vm.breakpoint` as `pure` (#9051) breakpoint external -> external pure --- crates/cheatcodes/assets/cheatcodes.json | 8 ++++---- crates/cheatcodes/spec/src/vm.rs | 4 ++-- testdata/cheats/Vm.sol | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 9f08702266e91..ac42e63c1d961 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3035,9 +3035,9 @@ "func": { "id": "breakpoint_0", "description": "Writes a breakpoint to jump to in the debugger.", - "declaration": "function breakpoint(string calldata char) external;", + "declaration": "function breakpoint(string calldata char) external pure;", "visibility": "external", - "mutability": "", + "mutability": "pure", "signature": "breakpoint(string)", "selector": "0xf0259e92", "selectorBytes": [ @@ -3055,9 +3055,9 @@ "func": { "id": "breakpoint_1", "description": "Writes a conditional breakpoint to jump to in the debugger.", - "declaration": "function breakpoint(string calldata char, bool value) external;", + "declaration": "function breakpoint(string calldata char, bool value) external pure;", "visibility": "external", - "mutability": "", + "mutability": "pure", "signature": "breakpoint(string,bool)", "selector": "0xf7d39a8d", "selectorBytes": [ diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 4ec51130a22a4..129c553a96fc3 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -757,11 +757,11 @@ interface Vm { /// Writes a breakpoint to jump to in the debugger. #[cheatcode(group = Testing, safety = Safe)] - function breakpoint(string calldata char) external; + function breakpoint(string calldata char) external pure; /// Writes a conditional breakpoint to jump to in the debugger. #[cheatcode(group = Testing, safety = Safe)] - function breakpoint(string calldata char, bool value) external; + function breakpoint(string calldata char, bool value) external pure; /// Returns the Foundry version. /// Format: ++ diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 7dc38480a0d32..64c599a9e8564 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -147,8 +147,8 @@ interface Vm { function assumeNoRevert() external pure; function blobBaseFee(uint256 newBlobBaseFee) external; function blobhashes(bytes32[] calldata hashes) external; - function breakpoint(string calldata char) external; - function breakpoint(string calldata char, bool value) external; + function breakpoint(string calldata char) external pure; + function breakpoint(string calldata char, bool value) external pure; function broadcastRawTransaction(bytes calldata data) external; function broadcast() external; function broadcast(address signer) external; From 22a72d50aed05f5828655df2f29a1f8bab361653 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:07:01 +0200 Subject: [PATCH 1527/1963] fix: include `traces` field when running `forge test -vvvv --json` (#9034) * enable traces as part of verbose output when tests are ran with --json, includes tests * Update crates/forge/tests/cli/test_cmd.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Update crates/forge/tests/cli/test_cmd.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * use forgetest! directly --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/forge/bin/cmd/test/mod.rs | 3 +- crates/forge/src/result.rs | 1 - crates/forge/tests/cli/test_cmd.rs | 41 +++++ .../SimpleContractTestNonVerbose.json | 27 +++ .../fixtures/SimpleContractTestVerbose.json | 172 ++++++++++++++++++ 5 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json create mode 100644 crates/forge/tests/fixtures/SimpleContractTestVerbose.json diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 6d53a4756bd77..0e87a4c669152 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -499,6 +499,7 @@ impl TestArgs { runner.decode_internal = InternalTraceMode::Full; } + // Run tests in a non-streaming fashion and collect results for serialization. if self.json { let results = runner.test_collect(filter); println!("{}", serde_json::to_string(&results)?); @@ -516,7 +517,7 @@ impl TestArgs { let libraries = runner.libraries.clone(); - // Run tests. + // Run tests in a streaming fashion. let (tx, rx) = channel::<(String, SuiteResult)>(); let timer = Instant::now(); let show_progress = config.show_progress; diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 0e00bb5e2773e..a6d7fded9c489 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -393,7 +393,6 @@ pub struct TestResult { pub kind: TestKind, /// Traces - #[serde(skip)] pub traces: Traces, /// Additional traces to use for gas report. diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 28362671b756c..f8b54cc4126e1 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -274,6 +274,47 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); }); +const SIMPLE_CONTRACT: &str = r#" +import "./test.sol"; + +contract SimpleContract { + uint256 public num; + + function setValues(uint256 _num) public { + num = _num; + } +} + +contract SimpleContractTest is DSTest { + function test() public { + SimpleContract c = new SimpleContract(); + c.setValues(100); + } +} + "#; + +forgetest!(can_run_test_with_json_output_verbose, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source("Simple.t.sol", SIMPLE_CONTRACT).unwrap(); + + // Assert that with verbose output the json output includes the traces + cmd.args(["test", "-vvv", "--json"]) + .assert_success() + .stdout_eq(file!["../fixtures/SimpleContractTestVerbose.json": Json]); +}); + +forgetest!(can_run_test_with_json_output_non_verbose, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source("Simple.t.sol", SIMPLE_CONTRACT).unwrap(); + + // Assert that without verbose output the json output does not include the traces + cmd.args(["test", "--json"]) + .assert_success() + .stdout_eq(file!["../fixtures/SimpleContractTestNonVerbose.json": Json]); +}); + // tests that `forge test` will pick up tests that are stored in the `test = ` config value forgetest!(can_run_test_in_custom_test_folder, |prj, cmd| { prj.insert_ds_test(); diff --git a/crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json b/crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json new file mode 100644 index 0000000000000..8fd8a0faef538 --- /dev/null +++ b/crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json @@ -0,0 +1,27 @@ +{ + "src/Simple.t.sol:SimpleContractTest": { + "duration": "{...}", + "test_results": { + "test()": { + "status": "Success", + "reason": null, + "counterexample": null, + "logs": [], + "kind": { + "Unit": { + "gas": "{...}" + } + }, + "traces": [], + "labeled_addresses": {}, + "duration": { + "secs": "{...}", + "nanos": "{...}" + }, + "breakpoints": {}, + "gas_snapshots": {} + } + }, + "warnings": [] + } +} \ No newline at end of file diff --git a/crates/forge/tests/fixtures/SimpleContractTestVerbose.json b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json new file mode 100644 index 0000000000000..c7f47cf53477e --- /dev/null +++ b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json @@ -0,0 +1,172 @@ +{ + "src/Simple.t.sol:SimpleContractTest": { + "duration": "{...}", + "test_results": { + "test()": { + "status": "Success", + "reason": null, + "counterexample": null, + "logs": [], + "kind": { + "Unit": { + "gas": "{...}" + } + }, + "traces": [ + [ + "Deployment", + { + "arena": [ + { + "parent": null, + "children": [], + "idx": 0, + "trace": { + "depth": 0, + "success": true, + "caller": "0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38", + "address": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", + "maybe_precompile": false, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CREATE", + "value": "0x0", + "data": "{...}", + "output": "{...}", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Return", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [] + } + ] + } + ], + [ + "Execution", + { + "arena": [ + { + "parent": null, + "children": [ + 1, + 2 + ], + "idx": 0, + "trace": { + "depth": 0, + "success": true, + "caller": "0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38", + "address": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", + "maybe_precompile": null, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CALL", + "value": "0x0", + "data": "0xf8a8fd6d", + "output": "0x", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Stop", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [ + { + "Call": 0 + }, + { + "Call": 1 + } + ] + }, + { + "parent": 0, + "children": [], + "idx": 1, + "trace": { + "depth": 1, + "success": true, + "caller": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", + "address": "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f", + "maybe_precompile": false, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CREATE", + "value": "0x0", + "data": "{...}", + "output": "{...}", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Return", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [] + }, + { + "parent": 0, + "children": [], + "idx": 2, + "trace": { + "depth": 1, + "success": true, + "caller": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", + "address": "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f", + "maybe_precompile": null, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CALL", + "value": "0x0", + "data": "0xe26d14740000000000000000000000000000000000000000000000000000000000000064", + "output": "0x", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Stop", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [] + } + ] + } + ] + ], + "labeled_addresses": {}, + "duration": { + "secs": "{...}", + "nanos": "{...}" + }, + "breakpoints": {}, + "gas_snapshots": {} + } + }, + "warnings": [] + } +} \ No newline at end of file From d7d9b407b20a5d2df1d06b07dafc1371a7e715b3 Mon Sep 17 00:00:00 2001 From: Yotam Bar-On Date: Mon, 7 Oct 2024 17:12:02 +0300 Subject: [PATCH 1528/1963] feat(cheatcodes): Add `vm.mockCalls` to mock different return data for multiple calls (#9024) * Refactor vm.mockCall to be based on mutable VecDeque * Add vm.mockCalls cheatcode * Refactor mock_call to be wrapper for mock_calls * Add a test to vm.mockCalls * Add test for vm.mockCalls with msg.value * Fix fmt & clippy following vm.mockCalls implementation * Fix Solidity fmt in testdata/default/cheats/MockCalls.t.sol * Add test in MockCalls.t.sol to check last mocked data persists * Remove allow(clippy::ptr_arg) from mock_call & mock_calls * Apply suggestions from code review --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 40 ++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 8 ++++ crates/cheatcodes/src/evm/mock.rs | 38 +++++++++++++-- crates/cheatcodes/src/inspector.rs | 40 ++++++++++------ testdata/cheats/Vm.sol | 2 + testdata/default/cheats/MockCalls.t.sol | 59 ++++++++++++++++++++++++ 6 files changed, 169 insertions(+), 18 deletions(-) create mode 100644 testdata/default/cheats/MockCalls.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index ac42e63c1d961..9ef78f8b0da33 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5777,6 +5777,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "mockCalls_0", + "description": "Mocks multiple calls to an address, returning specified data for each call.", + "declaration": "function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCalls(address,bytes,bytes[])", + "selector": "0x5c5c3de9", + "selectorBytes": [ + 92, + 92, + 61, + 233 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "mockCalls_1", + "description": "Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call.", + "declaration": "function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCalls(address,uint256,bytes,bytes[])", + "selector": "0x08bcbae1", + "selectorBytes": [ + 8, + 188, + 186, + 225 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "mockFunction", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 129c553a96fc3..79249366cdb73 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -465,6 +465,14 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; + /// Mocks multiple calls to an address, returning specified data for each call. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external; + + /// Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external; + /// Reverts a call to an address with specified revert data. #[cheatcode(group = Evm, safety = Unsafe)] function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index ab858c612da69..50551d179c848 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -1,7 +1,7 @@ use crate::{inspector::InnerEcx, Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, Bytes, U256}; use revm::{interpreter::InstructionResult, primitives::Bytecode}; -use std::cmp::Ordering; +use std::{cmp::Ordering, collections::VecDeque}; /// Mocked call data. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] @@ -65,6 +65,25 @@ impl Cheatcode for mockCall_1Call { } } +impl Cheatcode for mockCalls_0Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, data, returnData } = self; + let _ = make_acc_non_empty(callee, ccx.ecx)?; + + mock_calls(ccx.state, callee, data, None, returnData, InstructionResult::Return); + Ok(Default::default()) + } +} + +impl Cheatcode for mockCalls_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, msgValue, data, returnData } = self; + ccx.ecx.load_account(*callee)?; + mock_calls(ccx.state, callee, data, Some(msgValue), returnData, InstructionResult::Return); + Ok(Default::default()) + } +} + impl Cheatcode for mockCallRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, revertData } = self; @@ -94,7 +113,6 @@ impl Cheatcode for mockFunctionCall { } } -#[allow(clippy::ptr_arg)] // Not public API, doesn't matter fn mock_call( state: &mut Cheatcodes, callee: &Address, @@ -102,10 +120,24 @@ fn mock_call( value: Option<&U256>, rdata: &Bytes, ret_type: InstructionResult, +) { + mock_calls(state, callee, cdata, value, std::slice::from_ref(rdata), ret_type) +} + +fn mock_calls( + state: &mut Cheatcodes, + callee: &Address, + cdata: &Bytes, + value: Option<&U256>, + rdata_vec: &[Bytes], + ret_type: InstructionResult, ) { state.mocked_calls.entry(*callee).or_default().insert( MockCallDataContext { calldata: Bytes::copy_from_slice(cdata), value: value.copied() }, - MockCallReturnData { ret_type, data: Bytes::copy_from_slice(rdata) }, + rdata_vec + .iter() + .map(|rdata| MockCallReturnData { ret_type, data: rdata.clone() }) + .collect::>(), ); } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index fe8834d5f5a82..bdcb1ad8d0e6f 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -402,7 +402,7 @@ pub struct Cheatcodes { /// Mocked calls // **Note**: inner must a BTreeMap because of special `Ord` impl for `MockCallDataContext` - pub mocked_calls: HashMap>, + pub mocked_calls: HashMap>>, /// Mocked functions. Maps target address to be mocked to pair of (calldata, mock address). pub mocked_functions: HashMap>, @@ -889,26 +889,36 @@ where { } // Handle mocked calls - if let Some(mocks) = self.mocked_calls.get(&call.bytecode_address) { + if let Some(mocks) = self.mocked_calls.get_mut(&call.bytecode_address) { let ctx = MockCallDataContext { calldata: call.input.clone(), value: call.transfer_value() }; - if let Some(return_data) = mocks.get(&ctx).or_else(|| { - mocks - .iter() + + if let Some(return_data_queue) = match mocks.get_mut(&ctx) { + Some(queue) => Some(queue), + None => mocks + .iter_mut() .find(|(mock, _)| { call.input.get(..mock.calldata.len()) == Some(&mock.calldata[..]) && mock.value.map_or(true, |value| Some(value) == call.transfer_value()) }) - .map(|(_, v)| v) - }) { - return Some(CallOutcome { - result: InterpreterResult { - result: return_data.ret_type, - output: return_data.data.clone(), - gas, - }, - memory_offset: call.return_memory_offset.clone(), - }); + .map(|(_, v)| v), + } { + if let Some(return_data) = if return_data_queue.len() == 1 { + // If the mocked calls stack has a single element in it, don't empty it + return_data_queue.front().map(|x| x.to_owned()) + } else { + // Else, we pop the front element + return_data_queue.pop_front() + } { + return Some(CallOutcome { + result: InterpreterResult { + result: return_data.ret_type, + output: return_data.data, + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }); + } } } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 64c599a9e8564..8bb13577e8b5b 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -284,6 +284,8 @@ interface Vm { function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; function mockCall(address callee, bytes calldata data, bytes calldata returnData) external; function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; + function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external; + function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external; function mockFunction(address callee, address target, bytes calldata data) external; function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue); function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); diff --git a/testdata/default/cheats/MockCalls.t.sol b/testdata/default/cheats/MockCalls.t.sol new file mode 100644 index 0000000000000..13e3cb78c992b --- /dev/null +++ b/testdata/default/cheats/MockCalls.t.sol @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract MockCallsTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testMockCallsLastShouldPersist() public { + address mockUser = vm.addr(vm.randomUint()); + address mockErc20 = vm.addr(vm.randomUint()); + bytes memory data = abi.encodeWithSignature("balanceOf(address)", mockUser); + bytes[] memory mocks = new bytes[](2); + mocks[0] = abi.encode(2 ether); + mocks[1] = abi.encode(7.219 ether); + vm.mockCalls(mockErc20, data, mocks); + (, bytes memory ret1) = mockErc20.call(data); + assertEq(abi.decode(ret1, (uint256)), 2 ether); + (, bytes memory ret2) = mockErc20.call(data); + assertEq(abi.decode(ret2, (uint256)), 7.219 ether); + (, bytes memory ret3) = mockErc20.call(data); + assertEq(abi.decode(ret3, (uint256)), 7.219 ether); + } + + function testMockCallsWithValue() public { + address mockUser = vm.addr(vm.randomUint()); + address mockErc20 = vm.addr(vm.randomUint()); + bytes memory data = abi.encodeWithSignature("balanceOf(address)", mockUser); + bytes[] memory mocks = new bytes[](3); + mocks[0] = abi.encode(2 ether); + mocks[1] = abi.encode(1 ether); + mocks[2] = abi.encode(6.423 ether); + vm.mockCalls(mockErc20, 1 ether, data, mocks); + (, bytes memory ret1) = mockErc20.call{value: 1 ether}(data); + assertEq(abi.decode(ret1, (uint256)), 2 ether); + (, bytes memory ret2) = mockErc20.call{value: 1 ether}(data); + assertEq(abi.decode(ret2, (uint256)), 1 ether); + (, bytes memory ret3) = mockErc20.call{value: 1 ether}(data); + assertEq(abi.decode(ret3, (uint256)), 6.423 ether); + } + + function testMockCalls() public { + address mockUser = vm.addr(vm.randomUint()); + address mockErc20 = vm.addr(vm.randomUint()); + bytes memory data = abi.encodeWithSignature("balanceOf(address)", mockUser); + bytes[] memory mocks = new bytes[](3); + mocks[0] = abi.encode(2 ether); + mocks[1] = abi.encode(1 ether); + mocks[2] = abi.encode(6.423 ether); + vm.mockCalls(mockErc20, data, mocks); + (, bytes memory ret1) = mockErc20.call(data); + assertEq(abi.decode(ret1, (uint256)), 2 ether); + (, bytes memory ret2) = mockErc20.call(data); + assertEq(abi.decode(ret2, (uint256)), 1 ether); + (, bytes memory ret3) = mockErc20.call(data); + assertEq(abi.decode(ret3, (uint256)), 6.423 ether); + } +} From 3b2e99973badc1d1597e37ae37dceb398fef4f8f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:34:28 +0200 Subject: [PATCH 1529/1963] chore(deps): bump alloy-core 0.8.6 (#9045) --- Cargo.lock | 60 ++++++++++--------- Cargo.toml | 3 +- .../anvil/src/eth/backend/mem/in_memory_db.rs | 7 +-- crates/anvil/src/eth/backend/mem/storage.rs | 3 +- crates/anvil/src/eth/pool/transactions.rs | 14 ++--- crates/cheatcodes/Cargo.toml | 1 - crates/cheatcodes/src/evm.rs | 7 +-- crates/cheatcodes/src/fs.rs | 3 +- crates/cheatcodes/src/inspector.rs | 3 +- crates/cheatcodes/src/test/expect.rs | 7 ++- crates/common/Cargo.toml | 1 - crates/common/src/evm.rs | 8 +-- crates/common/src/selectors.rs | 3 +- crates/evm/abi/Cargo.toml | 1 - crates/evm/abi/src/console/hardhat.rs | 7 +-- crates/evm/core/Cargo.toml | 1 - crates/evm/core/src/backend/mod.rs | 3 +- crates/evm/core/src/decode.rs | 5 +- crates/evm/core/src/fork/database.rs | 3 +- crates/evm/core/src/ic.rs | 10 ++-- crates/evm/coverage/Cargo.toml | 1 - crates/evm/coverage/src/analysis.rs | 4 +- crates/evm/coverage/src/anchors.rs | 6 +- crates/evm/coverage/src/lib.rs | 4 +- crates/evm/evm/src/lib.rs | 6 -- crates/evm/fuzz/src/strategies/state.rs | 8 +-- crates/evm/traces/Cargo.toml | 1 - crates/evm/traces/src/debug/sources.rs | 3 +- crates/evm/traces/src/decoder/mod.rs | 18 +++--- .../evm/traces/src/identifier/signatures.rs | 11 +--- crates/forge/Cargo.toml | 1 - crates/forge/bin/cmd/clone.rs | 3 +- crates/forge/bin/cmd/coverage.rs | 10 ++-- crates/forge/src/coverage.rs | 6 +- crates/forge/src/gas_report.rs | 6 +- crates/forge/src/runner.rs | 9 +-- crates/script/src/providers.rs | 7 +-- crates/script/src/simulate.rs | 4 +- crates/test-utils/src/rpc.rs | 3 +- crates/verify/src/etherscan/mod.rs | 3 +- crates/verify/src/sourcify.rs | 4 +- crates/wallets/src/wallet.rs | 3 +- deny.toml | 1 + 43 files changed, 110 insertions(+), 162 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80fbb62121549..d94ee063df489 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b499852e1d0e9b8c6db0f24c48998e647c0d5762a01090f955106a7700e4611" +checksum = "1109c57718022ac84c194f775977a534e1b3969b405e55693a61c42187cc0612" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a438d4486b5d525df3b3004188f9d5cd1d65cd30ecc41e5a3ccef6f6342e8af9" +checksum = "c4cc0e59c803dd44d14fc0cfa9fea1f74cfa8fd9fb60ca303ced390c58c28d4e" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -303,9 +303,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260d3ff3bff0bb84599f032a2f2c6828180b0ea0cd41fdaf44f39cef3ba41861" +checksum = "a289ffd7448036f2f436b377f981c79ce0b2090877bad938d43387dc09931877" dependencies = [ "alloy-rlp", "arbitrary", @@ -314,8 +314,9 @@ dependencies = [ "const-hex", "derive_arbitrary", "derive_more 1.0.0", + "foldhash", "getrandom", - "hashbrown 0.14.5", + "hashbrown 0.15.0", "hex-literal", "indexmap 2.6.0", "itoa", @@ -680,9 +681,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e7f6e8fe5b443f82b3f1e15abfa191128f71569148428e49449d01f6f49e8b" +checksum = "0409e3ba5d1de409997a7db8b8e9d679d52088c1dee042a85033affd3cadeab4" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -694,9 +695,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b96ce28d2fde09abb6135f410c41fad670a3a770b6776869bd852f1df102e6f" +checksum = "a18372ef450d59f74c7a64a738f546ba82c92f816597fed1802ef559304c81f1" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -713,9 +714,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "906746396a8296537745711630d9185746c0b50c033d5e9d18b0a6eba3d53f90" +checksum = "f7bad89dd0d5f109e8feeaf787a9ed7a05a91a9a0efc6687d147a70ebca8eff7" dependencies = [ "alloy-json-abi", "const-hex", @@ -730,9 +731,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc85178909a49c8827ffccfc9103a7ce1767ae66a801b69bdc326913870bf8e6" +checksum = "dbd3548d5262867c2c4be6223fe4f2583e21ade0ca1c307fd23bc7f28fca479e" dependencies = [ "serde", "winnow", @@ -740,9 +741,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a533ce22525969661b25dfe296c112d35eb6861f188fd284f8bd4bb3842ae" +checksum = "4aa666f1036341b46625e72bd36878bf45ad0185f1b88601223e1ec6ed4b72b1" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -1994,9 +1995,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.25" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d9e0b4957f635b8d3da819d0db5603620467ecf1f692d22a8c2717ce27e6d8" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" dependencies = [ "shlex", ] @@ -3305,6 +3306,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -3386,7 +3393,6 @@ dependencies = [ "regex", "reqwest", "revm-inspectors", - "rustc-hash", "semver 1.0.23", "serde", "serde_json", @@ -3666,7 +3672,6 @@ dependencies = [ "proptest", "rand", "revm", - "rustc-hash", "semver 1.0.23", "serde_json", "thiserror", @@ -3754,7 +3759,6 @@ dependencies = [ "foundry-macros", "num-format", "reqwest", - "rustc-hash", "semver 1.0.23", "serde", "serde_json", @@ -3987,7 +3991,6 @@ dependencies = [ "foundry-macros", "foundry-test-utils", "itertools 0.13.0", - "rustc-hash", ] [[package]] @@ -4016,7 +4019,6 @@ dependencies = [ "parking_lot", "revm", "revm-inspectors", - "rustc-hash", "serde", "serde_json", "thiserror", @@ -4035,7 +4037,6 @@ dependencies = [ "foundry-evm-core", "rayon", "revm", - "rustc-hash", "semver 1.0.23", "tracing", ] @@ -4086,7 +4087,6 @@ dependencies = [ "rayon", "revm", "revm-inspectors", - "rustc-hash", "serde", "solang-parser", "tempfile", @@ -4740,6 +4740,10 @@ name = "hashbrown" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "foldhash", + "serde", +] [[package]] name = "heck" @@ -8411,9 +8415,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab661c8148c2261222a4d641ad5477fd4bea79406a99056096a0b41b35617a5" +checksum = "f3a850d65181df41b83c6be01a7d91f5e9377c43d48faa5af7d95816f437f5a3" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index e6ccd75bd3aec..bbefa8c4bf528 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -208,7 +208,7 @@ alloy-json-abi = "0.8.5" alloy-primitives = { version = "0.8.5", features = [ "getrandom", "rand", - "map-fxhash", + "map-foldhash", ] } alloy-sol-macro-expander = "0.8.5" alloy-sol-macro-input = "0.8.5" @@ -249,7 +249,6 @@ k256 = "0.13" parking_lot = "0.12" mesc = "0.3" rand = "0.8" -rustc-hash = "2.0" semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index 01243c90f47ba..9e34448ad3110 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -8,12 +8,9 @@ use crate::{ mem::state::state_root, revm::{db::DbAccount, primitives::AccountInfo}, }; -use alloy_primitives::{Address, B256, U256, U64}; +use alloy_primitives::{map::HashMap, Address, B256, U256, U64}; use alloy_rpc_types::BlockId; -use foundry_evm::{ - backend::{BlockchainDb, DatabaseResult, StateSnapshot}, - hashbrown::HashMap, -}; +use foundry_evm::backend::{BlockchainDb, DatabaseResult, StateSnapshot}; // reexport for convenience pub use foundry_evm::{backend::MemDb, revm::db::DatabaseRef}; diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 29ae472071e7a..942ce5a9d23cf 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -581,9 +581,8 @@ pub struct MinedTransactionReceipt { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use super::*; use crate::eth::backend::db::Db; use alloy_primitives::{hex, Address}; diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index a1b7beb680628..631064549ce70 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -1,17 +1,13 @@ use crate::eth::{error::PoolError, util::hex_fmt_many}; -use alloy_primitives::{Address, TxHash}; +use alloy_primitives::{ + map::{HashMap, HashSet}, + Address, TxHash, +}; use alloy_rpc_types::Transaction as RpcTransaction; use alloy_serde::WithOtherFields; use anvil_core::eth::transaction::{PendingTransaction, TypedTransaction}; use parking_lot::RwLock; -use std::{ - cmp::Ordering, - collections::{BTreeSet, HashMap, HashSet}, - fmt, - str::FromStr, - sync::Arc, - time::Instant, -}; +use std::{cmp::Ordering, collections::BTreeSet, fmt, str::FromStr, sync::Arc, time::Instant}; /// A unique identifying marker for a transaction pub type TxMarker = Vec; diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index cbf66d684ee18..7f990a8e56beb 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -58,7 +58,6 @@ p256 = "0.13.2" ecdsa = "0.16" rand = "0.8" revm.workspace = true -rustc-hash.workspace = true semver.workspace = true serde_json.workspace = true thiserror.workspace = true diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index af2026a9e1a24..7691cd4c96f5b 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -6,7 +6,7 @@ use crate::{ }; use alloy_consensus::TxEnvelope; use alloy_genesis::{Genesis, GenesisAccount}; -use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_primitives::{map::HashMap, Address, Bytes, B256, U256}; use alloy_rlp::Decodable; use alloy_sol_types::SolValue; use foundry_common::fs::{read_json_file, write_json_file}; @@ -16,10 +16,7 @@ use foundry_evm_core::{ }; use rand::Rng; use revm::primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}; -use std::{ - collections::{BTreeMap, HashMap}, - path::Path, -}; +use std::{collections::BTreeMap, path::Path}; mod fork; pub(crate) mod mapping; diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index f36c8d6fe8f8c..c8c512b6f15ef 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -4,7 +4,7 @@ use super::string::parse; use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_dyn_abi::DynSolType; use alloy_json_abi::ContractObject; -use alloy_primitives::{hex, Bytes, U256}; +use alloy_primitives::{hex, map::Entry, Bytes, U256}; use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; use foundry_common::fs; @@ -12,7 +12,6 @@ use foundry_config::fs_permissions::FsAccessKind; use revm::interpreter::CreateInputs; use semver::Version; use std::{ - collections::hash_map::Entry, io::{BufRead, BufReader, Write}, path::{Path, PathBuf}, process::Command, diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index bdcb1ad8d0e6f..9a40c3cb1b313 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -49,7 +49,6 @@ use revm::{ primitives::{BlockEnv, CreateScheme, EVMError, EvmStorageSlot, SpecId, EOF_MAGIC_BYTES}, EvmContext, InnerEvmContext, Inspector, }; -use rustc_hash::FxHashMap; use serde_json::Value; use std::{ collections::{BTreeMap, VecDeque}, @@ -413,7 +412,7 @@ pub struct Cheatcodes { pub expected_emits: VecDeque, /// Map of context depths to memory offset ranges that may be written to within the call depth. - pub allowed_mem_writes: FxHashMap>>, + pub allowed_mem_writes: HashMap>>, /// Current broadcasting information pub broadcast: Option, diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 7a58c7ab8aa81..602ac512514ec 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,5 +1,9 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result, Vm::*}; -use alloy_primitives::{address, hex, Address, Bytes, LogData as RawLog, U256}; +use alloy_primitives::{ + address, hex, + map::{hash_map::Entry, HashMap}, + Address, Bytes, LogData as RawLog, U256, +}; use alloy_sol_types::{SolError, SolValue}; use foundry_common::ContractsByArtifact; use foundry_evm_core::decode::RevertDecoder; @@ -7,7 +11,6 @@ use revm::interpreter::{ return_ok, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }; use spec::Vm; -use std::collections::{hash_map::Entry, HashMap}; /// For some cheatcodes we may internally change the status of the call, i.e. in `expectRevert`. /// Solidity will see a successful call and attempt to decode the return data. Therefore, we need diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 73bd90cc71266..fbc5c82ca7718 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -52,7 +52,6 @@ dunce.workspace = true eyre.workspace = true num-format.workspace = true reqwest.workspace = true -rustc-hash.workspace = true semver.workspace = true serde_json.workspace = true serde.workspace = true diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index d281d56529b9d..30bcd4d0918a3 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -1,5 +1,6 @@ -//! cli arguments for configuring the evm settings -use alloy_primitives::{Address, B256, U256}; +//! CLI arguments for configuring the EVM settings. + +use alloy_primitives::{map::HashMap, Address, B256, U256}; use clap::{ArgAction, Parser}; use eyre::ContextCompat; use foundry_config::{ @@ -11,11 +12,10 @@ use foundry_config::{ }, Chain, Config, }; -use rustc_hash::FxHashMap; use serde::Serialize; /// Map keyed by breakpoints char to their location (contract address, pc) -pub type Breakpoints = FxHashMap; +pub type Breakpoints = HashMap; /// `EvmArgs` and `EnvArgs` take the highest precedence in the Config/Figment hierarchy. /// diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 3b10739162cb2..23a272a2a8e34 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -579,9 +579,8 @@ pub fn parse_signatures(tokens: Vec) -> ParsedSignatures { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use super::*; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/evm/abi/Cargo.toml b/crates/evm/abi/Cargo.toml index 330ea6626d6bc..b3202c96799f1 100644 --- a/crates/evm/abi/Cargo.toml +++ b/crates/evm/abi/Cargo.toml @@ -22,7 +22,6 @@ alloy-sol-types = { workspace = true, features = ["json"] } derive_more.workspace = true itertools.workspace = true -rustc-hash.workspace = true [dev-dependencies] foundry-test-utils.workspace = true diff --git a/crates/evm/abi/src/console/hardhat.rs b/crates/evm/abi/src/console/hardhat.rs index a99ad8fc6451c..8154c9ff79264 100644 --- a/crates/evm/abi/src/console/hardhat.rs +++ b/crates/evm/abi/src/console/hardhat.rs @@ -1,8 +1,7 @@ -use alloy_primitives::Selector; +use alloy_primitives::{map::HashMap, Selector}; use alloy_sol_types::sol; use foundry_common_fmt::*; use foundry_macros::ConsoleFmt; -use rustc_hash::FxHashMap; use std::sync::LazyLock; sol!( @@ -39,8 +38,8 @@ pub fn hh_console_selector(input: &[u8]) -> Option<&'static Selector> { /// `hardhat/console.log` logs its events manually, and in functions that accept integers they're /// encoded as `abi.encodeWithSignature("log(int)", p0)`, which is not the canonical ABI encoding /// for `int` that Solidity and [`sol!`] use. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: LazyLock> = - LazyLock::new(|| FxHashMap::from_iter(include!("./patches.rs"))); +pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: LazyLock> = + LazyLock::new(|| HashMap::from_iter(include!("./patches.rs"))); #[cfg(test)] mod tests { diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index ce06dc9d0ea8a..46441201664e5 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -54,7 +54,6 @@ eyre.workspace = true futures.workspace = true itertools.workspace = true parking_lot.workspace = true -rustc-hash.workspace = true serde.workspace = true serde_json.workspace = true thiserror.workspace = true diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 8cf59d96e1b2d..27c2d69443717 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1960,9 +1960,8 @@ fn apply_state_changeset( } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use crate::{backend::Backend, fork::CreateFork, opts::EvmOpts}; use alloy_primitives::{Address, U256}; use alloy_provider::Provider; diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 95fcaf02a38b8..d6e8b3dec88fd 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -3,12 +3,11 @@ use crate::abi::{Console, Vm}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::{Error, JsonAbi}; -use alloy_primitives::{hex, Log, Selector}; +use alloy_primitives::{hex, map::HashMap, Log, Selector}; use alloy_sol_types::{SolEventInterface, SolInterface, SolValue}; use foundry_common::SELECTOR_LEN; use itertools::Itertools; use revm::interpreter::InstructionResult; -use rustc_hash::FxHashMap; use std::{fmt, sync::OnceLock}; /// A skip reason. @@ -60,7 +59,7 @@ pub fn decode_console_log(log: &Log) -> Option { #[derive(Clone, Debug, Default)] pub struct RevertDecoder { /// The custom errors to use for decoding. - pub errors: FxHashMap>, + pub errors: HashMap>, } impl Default for &RevertDecoder { diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 1bab765150006..29dccb9c7dec0 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -262,9 +262,8 @@ impl DatabaseRef for ForkDbStateSnapshot { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use super::*; use crate::backend::BlockchainDbMeta; use foundry_common::provider::get_http_provider; diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index acb9cc50e6b34..f7ab3093c5207 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -1,12 +1,12 @@ +use alloy_primitives::map::HashMap; use revm::interpreter::opcode::{PUSH0, PUSH1, PUSH32}; -use rustc_hash::FxHashMap; /// Maps from program counter to instruction counter. /// /// Inverse of [`IcPcMap`]. #[derive(Debug, Clone)] pub struct PcIcMap { - pub inner: FxHashMap, + pub inner: HashMap, } impl PcIcMap { @@ -35,7 +35,7 @@ impl PcIcMap { /// /// Inverse of [`PcIcMap`]. pub struct IcPcMap { - pub inner: FxHashMap, + pub inner: HashMap, } impl IcPcMap { @@ -60,8 +60,8 @@ impl IcPcMap { } } -fn make_map(code: &[u8]) -> FxHashMap { - let mut map = FxHashMap::default(); +fn make_map(code: &[u8]) -> HashMap { + let mut map = HashMap::default(); let mut pc = 0; let mut cumulative_push_size = 0; diff --git a/crates/evm/coverage/Cargo.toml b/crates/evm/coverage/Cargo.toml index 777c37d99429a..e38d33e2a5907 100644 --- a/crates/evm/coverage/Cargo.toml +++ b/crates/evm/coverage/Cargo.toml @@ -23,5 +23,4 @@ eyre.workspace = true revm.workspace = true semver.workspace = true tracing.workspace = true -rustc-hash.workspace = true rayon.workspace = true diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 1b68c89d36663..e5eda5262d343 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -1,8 +1,8 @@ use super::{CoverageItem, CoverageItemKind, SourceLocation}; +use alloy_primitives::map::HashMap; use foundry_common::TestFunctionExt; use foundry_compilers::artifacts::ast::{self, Ast, Node, NodeType}; use rayon::prelude::*; -use rustc_hash::FxHashMap; use std::sync::Arc; /// A visitor that walks the AST of a single contract and finds coverage items. @@ -583,7 +583,7 @@ impl<'a> SourceAnalyzer<'a> { #[derive(Debug, Default)] pub struct SourceFiles<'a> { /// The versioned sources. - pub sources: FxHashMap>, + pub sources: HashMap>, } /// The source code and AST of a file. diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index c5bb8196a9c55..f42fd1a627260 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -1,9 +1,9 @@ use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; +use alloy_primitives::map::{DefaultHashBuilder, HashMap, HashSet}; use eyre::ensure; use foundry_compilers::artifacts::sourcemap::{SourceElement, SourceMap}; use foundry_evm_core::utils::IcPcMap; use revm::interpreter::opcode; -use rustc_hash::{FxHashMap, FxHashSet}; /// Attempts to find anchors for the given items using the given source map and bytecode. pub fn find_anchors( @@ -11,9 +11,9 @@ pub fn find_anchors( source_map: &SourceMap, ic_pc_map: &IcPcMap, items: &[CoverageItem], - items_by_source_id: &FxHashMap>, + items_by_source_id: &HashMap>, ) -> Vec { - let mut seen = FxHashSet::default(); + let mut seen = HashSet::with_hasher(DefaultHashBuilder::default()); source_map .iter() .filter_map(|element| items_by_source_id.get(&(element.index()? as usize))) diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 4481813aca8a6..220ab6b41407d 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -8,12 +8,12 @@ #[macro_use] extern crate tracing; -use alloy_primitives::{Bytes, B256}; +use alloy_primitives::{map::HashMap, Bytes, B256}; use eyre::{Context, Result}; use foundry_compilers::artifacts::sourcemap::SourceMap; use semver::Version; use std::{ - collections::{BTreeMap, HashMap}, + collections::BTreeMap, fmt::Display, ops::{AddAssign, Deref, DerefMut}, path::{Path, PathBuf}, diff --git a/crates/evm/evm/src/lib.rs b/crates/evm/evm/src/lib.rs index 8bbd7f1414d84..15858c0f393aa 100644 --- a/crates/evm/evm/src/lib.rs +++ b/crates/evm/evm/src/lib.rs @@ -19,9 +19,3 @@ pub use foundry_evm_traces as traces; // TODO: We should probably remove these, but it's a pretty big breaking change. #[doc(hidden)] pub use revm; - -#[doc(hidden)] -#[deprecated = "use `{hash_map, hash_set, HashMap, HashSet}` in `std::collections` or `revm::primitives` instead"] -pub mod hashbrown { - pub use revm::primitives::{hash_map, hash_set, HashMap, HashSet}; -} diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index f4f1dde924827..4df55772c4367 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,7 +1,7 @@ use crate::invariant::{BasicTxDetails, FuzzRunIdentifiedContracts}; use alloy_dyn_abi::{DynSolType, DynSolValue, EventExt, FunctionExt}; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{Address, Bytes, Log, B256, U256}; +use alloy_primitives::{map::HashMap, Address, Bytes, Log, B256, U256}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; use indexmap::IndexSet; @@ -11,11 +11,7 @@ use revm::{ interpreter::opcode, primitives::AccountInfo, }; -use std::{ - collections::{BTreeMap, HashMap}, - fmt, - sync::Arc, -}; +use std::{collections::BTreeMap, fmt, sync::Arc}; type AIndexSet = IndexSet>; diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 96fb8d1c6dc0e..3423213fbb9e9 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -38,7 +38,6 @@ itertools.workspace = true serde.workspace = true tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true -rustc-hash.workspace = true tempfile.workspace = true rayon.workspace = true solang-parser.workspace = true diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index 6ad335302fb2f..40e540a972d10 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -11,7 +11,6 @@ use foundry_compilers::{ use foundry_evm_core::utils::PcIcMap; use foundry_linking::Linker; use rayon::prelude::*; -use rustc_hash::FxHashMap; use solang_parser::pt::SourceUnitPart; use std::{ collections::{BTreeMap, HashMap}, @@ -117,7 +116,7 @@ impl ArtifactData { #[derive(Clone, Debug, Default)] pub struct ContractSources { /// Map over build_id -> file_id -> (source code, language) - pub sources_by_id: HashMap>>, + pub sources_by_id: HashMap>>, /// Map over contract name -> Vec<(bytecode, build_id, file_id)> pub artifacts_by_name: HashMap>, } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 1bb20381b9eca..25d9f4f2b8948 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -7,7 +7,10 @@ use crate::{ }; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt, FunctionExt, JsonAbiExt}; use alloy_json_abi::{Error, Event, Function, JsonAbi}; -use alloy_primitives::{Address, LogData, Selector, B256}; +use alloy_primitives::{ + map::{hash_map::Entry, HashMap}, + Address, LogData, Selector, B256, +}; use foundry_common::{ abi::get_indexed_event, fmt::format_token, get_contract_name, ContractsByArtifact, SELECTOR_LEN, }; @@ -25,11 +28,7 @@ use foundry_evm_core::{ }; use itertools::Itertools; use revm_inspectors::tracing::types::{DecodedCallLog, DecodedCallTrace}; -use rustc_hash::FxHashMap; -use std::{ - collections::{hash_map::Entry, BTreeMap, HashMap}, - sync::OnceLock, -}; +use std::{collections::BTreeMap, sync::OnceLock}; mod precompiles; @@ -124,7 +123,7 @@ pub struct CallTraceDecoder { pub receive_contracts: Vec
, /// All known functions. - pub functions: FxHashMap>, + pub functions: HashMap>, /// All known events. pub events: BTreeMap<(B256, usize), Vec>, /// Revert decoder. Contains all known custom errors. @@ -171,7 +170,7 @@ impl CallTraceDecoder { Self { contracts: Default::default(), - labels: [ + labels: HashMap::from_iter([ (CHEATCODE_ADDRESS, "VM".to_string()), (HARDHAT_CONSOLE_ADDRESS, "console".to_string()), (DEFAULT_CREATE2_DEPLOYER, "Create2Deployer".to_string()), @@ -187,8 +186,7 @@ impl CallTraceDecoder { (EC_PAIRING, "ECPairing".to_string()), (BLAKE_2F, "Blake2F".to_string()), (POINT_EVALUATION, "PointEvaluation".to_string()), - ] - .into(), + ]), receive_contracts: Default::default(), functions: hh_funcs() diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 2d7cadad1b821..1e3924aa3f494 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -1,16 +1,12 @@ use alloy_json_abi::{Event, Function}; -use alloy_primitives::hex; +use alloy_primitives::{hex, map::HashSet}; use foundry_common::{ abi::{get_event, get_func}, fs, selectors::{OpenChainClient, SelectorType}, }; use serde::{Deserialize, Serialize}; -use std::{ - collections::{BTreeMap, HashSet}, - path::PathBuf, - sync::Arc, -}; +use std::{collections::BTreeMap, path::PathBuf, sync::Arc}; use tokio::sync::RwLock; pub type SingleSignaturesIdentifier = Arc>; @@ -161,9 +157,8 @@ impl Drop for SignaturesIdentifier { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use super::*; #[tokio::test(flavor = "multi_thread")] diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index f636e4c6279f9..2cd6607859a1e 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -98,7 +98,6 @@ watchexec-events = "3.0" watchexec-signals = "3.0" clearscreen = "3.0" evm-disassembler.workspace = true -rustc-hash.workspace = true # doc server axum = { workspace = true, features = ["ws"] } diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index f3879b931b778..1c9ee47ec9fe4 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -608,9 +608,8 @@ impl EtherscanClient for Client { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use super::*; use alloy_primitives::hex; use foundry_compilers::Artifact; diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 487c0a7f15802..e21153d09c19b 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -1,5 +1,5 @@ use super::{install, test::TestArgs}; -use alloy_primitives::{Address, Bytes, U256}; +use alloy_primitives::{map::HashMap, Address, Bytes, U256}; use clap::{Parser, ValueEnum, ValueHint}; use eyre::{Context, Result}; use forge::{ @@ -24,10 +24,8 @@ use foundry_compilers::{ }; use foundry_config::{Config, SolcReq}; use rayon::prelude::*; -use rustc_hash::FxHashMap; use semver::Version; use std::{ - collections::HashMap, path::{Path, PathBuf}, sync::Arc, }; @@ -150,7 +148,7 @@ impl CoverageArgs { // Collect source files. let project_paths = &project.paths; - let mut versioned_sources = HashMap::>::new(); + let mut versioned_sources = HashMap::>::default(); for (path, source_file, version) in output.output().sources.sources_with_version() { report.add_source(version.clone(), source_file.id as usize, path.clone()); @@ -191,7 +189,7 @@ impl CoverageArgs { let source_analysis = SourceAnalyzer::new(sources).analyze()?; // Build helper mapping used by `find_anchors` - let mut items_by_source_id = FxHashMap::<_, Vec<_>>::with_capacity_and_hasher( + let mut items_by_source_id = HashMap::<_, Vec<_>>::with_capacity_and_hasher( source_analysis.items.len(), Default::default(), ); @@ -410,7 +408,7 @@ impl BytecodeData { pub fn find_anchors( &self, source_analysis: &SourceAnalysis, - items_by_source_id: &FxHashMap>, + items_by_source_id: &HashMap>, ) -> Vec { find_anchors( &self.bytecode, diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index ef9c7b0c6f0f3..4a00675dd754c 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -1,15 +1,17 @@ //! Coverage reports. +use alloy_primitives::map::HashMap; use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Row, Table}; use evm_disassembler::disassemble_bytes; use foundry_common::fs; -pub use foundry_evm::coverage::*; use std::{ - collections::{hash_map, HashMap}, + collections::hash_map, io::Write, path::{Path, PathBuf}, }; +pub use foundry_evm::coverage::*; + /// A coverage reporter. pub trait CoverageReporter { fn report(self, report: &CoverageReport) -> eyre::Result<()>; diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 85f53b5f517b7..ff7628bd5c4fc 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -4,14 +4,12 @@ use crate::{ constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS}, traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData}, }; +use alloy_primitives::map::HashSet; use comfy_table::{presets::ASCII_MARKDOWN, *}; use foundry_common::{calc, TestFunctionExt}; use foundry_evm::traces::CallKind; use serde::{Deserialize, Serialize}; -use std::{ - collections::{BTreeMap, HashSet}, - fmt::Display, -}; +use std::{collections::BTreeMap, fmt::Display}; use yansi::Paint; /// Represents the gas report for a set of contracts. diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 2a964789b5b3d..e580fb8b2fbaf 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -9,7 +9,7 @@ use crate::{ }; use alloy_dyn_abi::DynSolValue; use alloy_json_abi::Function; -use alloy_primitives::{address, Address, Bytes, U256}; +use alloy_primitives::{address, map::HashMap, Address, Bytes, U256}; use eyre::Result; use foundry_common::{ contracts::{ContractsByAddress, ContractsByArtifact}, @@ -35,12 +35,7 @@ use foundry_evm::{ }; use proptest::test_runner::TestRunner; use rayon::prelude::*; -use std::{ - borrow::Cow, - cmp::min, - collections::{BTreeMap, HashMap}, - time::Instant, -}; +use std::{borrow::Cow, cmp::min, collections::BTreeMap, time::Instant}; /// When running tests, we deploy all external libraries present in the project. To avoid additional /// libraries affecting nonces of senders used in tests, we are using separate address to diff --git a/crates/script/src/providers.rs b/crates/script/src/providers.rs index 7f1aa0eb38c97..eb6ea9319a77e 100644 --- a/crates/script/src/providers.rs +++ b/crates/script/src/providers.rs @@ -1,12 +1,9 @@ +use alloy_primitives::map::{hash_map::Entry, HashMap}; use alloy_provider::{utils::Eip1559Estimation, Provider}; use eyre::{Result, WrapErr}; use foundry_common::provider::{get_http_provider, RetryProvider}; use foundry_config::Chain; -use std::{ - collections::{hash_map::Entry, HashMap}, - ops::Deref, - sync::Arc, -}; +use std::{ops::Deref, sync::Arc}; /// Contains a map of RPC urls to single instances of [`ProviderInfo`]. #[derive(Default)] diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 7c692ea232efd..432a8ccd544e1 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -13,7 +13,7 @@ use crate::{ ScriptArgs, ScriptConfig, ScriptResult, }; use alloy_network::TransactionBuilder; -use alloy_primitives::{utils::format_units, Address, Bytes, TxKind, U256}; +use alloy_primitives::{map::HashMap, utils::format_units, Address, Bytes, TxKind, U256}; use dialoguer::Confirm; use eyre::{Context, Result}; use foundry_cheatcodes::ScriptWallets; @@ -23,7 +23,7 @@ use foundry_evm::traces::{decode_trace_arena, render_trace_arena}; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; use std::{ - collections::{BTreeMap, HashMap, VecDeque}, + collections::{BTreeMap, VecDeque}, sync::Arc, }; use yansi::Paint; diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 51ec2c8e0ee11..a9ff6a7e62a2d 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -177,9 +177,8 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use super::*; use alloy_primitives::address; use foundry_config::Chain; diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 3839b845b39e5..8b8c2bc3549fa 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -451,9 +451,8 @@ async fn ensure_solc_build_metadata(version: Version) -> Result { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use super::*; use clap::Parser; use foundry_common::fs; diff --git a/crates/verify/src/sourcify.rs b/crates/verify/src/sourcify.rs index bbb5e9f9eddc3..9dbe027efe1a2 100644 --- a/crates/verify/src/sourcify.rs +++ b/crates/verify/src/sourcify.rs @@ -8,7 +8,6 @@ use eyre::Result; use foundry_common::{fs, retry::Retry}; use futures::FutureExt; use reqwest::Url; -use revm_primitives::map::FxBuildHasher; use serde::{Deserialize, Serialize}; use std::str::FromStr; @@ -114,8 +113,7 @@ impl SourcifyVerificationProvider { let metadata = context.get_target_metadata()?; let imports = context.get_target_imports()?; - let mut files = - HashMap::with_capacity_and_hasher(2 + imports.len(), FxBuildHasher::default()); + let mut files = HashMap::with_capacity_and_hasher(2 + imports.len(), Default::default()); let metadata = serde_json::to_string_pretty(&metadata)?; files.insert("metadata.json".to_string(), metadata); diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 37b731ddb1429..01a2328951127 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -148,9 +148,8 @@ impl From for WalletOpts { } #[cfg(test)] +#[allow(clippy::needless_return)] mod tests { - #![allow(clippy::needless_return)] - use alloy_signer::Signer; use std::{path::Path, str::FromStr}; diff --git a/deny.toml b/deny.toml index e908828cc2a03..b932b03885a26 100644 --- a/deny.toml +++ b/deny.toml @@ -53,6 +53,7 @@ allow = [ "0BSD", "MPL-2.0", "CDDL-1.0", + "Zlib", ] # Allow 1 or more licenses on a per-crate basis, so that particular licenses From 1ba5d6fa58a80a5b24372f8a4894fc681bf0188a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 7 Oct 2024 18:33:22 +0300 Subject: [PATCH 1530/1963] feat(cheatcodes): add vm.cloneAccount() cheatcode (#9048) * feat(cheatcodes): add vm.cloneAccount() cheatcode * Fmt * Cargo cheats * Changes after review: - use autogenerated getter - consistent clone naming - nits --- crates/cheatcodes/assets/cheatcodes.json | 22 ++++- crates/cheatcodes/spec/src/vm.rs | 6 +- crates/cheatcodes/src/evm.rs | 51 ++++++++---- crates/evm/core/src/backend/cow.rs | 9 ++ crates/evm/core/src/backend/mod.rs | 96 ++++++++++++++-------- testdata/cheats/Vm.sol | 1 + testdata/default/cheats/CloneAccount.t.sol | 45 ++++++++++ 7 files changed, 176 insertions(+), 54 deletions(-) create mode 100644 testdata/default/cheats/CloneAccount.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 9ef78f8b0da33..e6fef48b0891d 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3191,6 +3191,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "cloneAccount", + "description": "Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.", + "declaration": "function cloneAccount(address source, address target) external;", + "visibility": "external", + "mutability": "", + "signature": "cloneAccount(address,address)", + "selector": "0x533d61c9", + "selectorBytes": [ + 83, + 61, + 97, + 201 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "closeFile", @@ -5600,7 +5620,7 @@ { "func": { "id": "loadAllocs", - "description": "Load a genesis JSON file's `allocs` into the in-memory revm state.", + "description": "Load a genesis JSON file's `allocs` into the in-memory EVM state.", "declaration": "function loadAllocs(string calldata pathToAllocsJson) external;", "visibility": "external", "mutability": "", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 79249366cdb73..0ee95e43fd02c 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -283,10 +283,14 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function load(address target, bytes32 slot) external view returns (bytes32 data); - /// Load a genesis JSON file's `allocs` into the in-memory revm state. + /// Load a genesis JSON file's `allocs` into the in-memory EVM state. #[cheatcode(group = Evm, safety = Unsafe)] function loadAllocs(string calldata pathToAllocsJson) external; + /// Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state. + #[cheatcode(group = Evm, safety = Unsafe)] + function cloneAccount(address source, address target) external; + // -------- Record Storage -------- /// Records all storage reads and writes. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 7691cd4c96f5b..b9a3d70474929 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -156,6 +156,22 @@ impl Cheatcode for loadAllocsCall { } } +impl Cheatcode for cloneAccountCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { source, target } = self; + + let account = ccx.ecx.journaled_state.load_account(*source, &mut ccx.ecx.db)?; + ccx.ecx.db.clone_account( + &genesis_account(account.data), + target, + &mut ccx.ecx.journaled_state, + )?; + // Cloned account should persist in forked envs. + ccx.ecx.db.add_persistent_account(*target); + Ok(Default::default()) + } +} + impl Cheatcode for dumpStateCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { pathToStateJson } = self; @@ -178,23 +194,7 @@ impl Cheatcode for dumpStateCall { .state() .iter_mut() .filter(|(key, val)| !skip(key, val)) - .map(|(key, val)| { - ( - key, - GenesisAccount { - nonce: Some(val.info.nonce), - balance: val.info.balance, - code: val.info.code.as_ref().map(|o| o.original_bytes()), - storage: Some( - val.storage - .iter() - .map(|(k, v)| (B256::from(*k), B256::from(v.present_value()))) - .collect(), - ), - private_key: None, - }, - ) - }) + .map(|(key, val)| (key, genesis_account(val))) .collect::>(); write_json_file(path, &alloc)?; @@ -957,3 +957,20 @@ fn get_state_diff(state: &mut Cheatcodes) -> Result { .collect::>(); Ok(res.abi_encode()) } + +/// Helper function that creates a `GenesisAccount` from a regular `Account`. +fn genesis_account(account: &Account) -> GenesisAccount { + GenesisAccount { + nonce: Some(account.info.nonce), + balance: account.info.balance, + code: account.info.code.as_ref().map(|o| o.original_bytes()), + storage: Some( + account + .storage + .iter() + .map(|(k, v)| (B256::from(*k), B256::from(v.present_value()))) + .collect(), + ), + private_key: None, + } +} diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index fcc2e1596c9fd..8623ca2f98ea0 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -233,6 +233,15 @@ impl DatabaseExt for CowBackend<'_> { self.backend_mut(&Env::default()).load_allocs(allocs, journaled_state) } + fn clone_account( + &mut self, + source: &GenesisAccount, + target: &Address, + journaled_state: &mut JournaledState, + ) -> Result<(), BackendError> { + self.backend_mut(&Env::default()).clone_account(source, target, journaled_state) + } + fn is_persistent(&self, acc: &Address) -> bool { self.backend.is_persistent(acc) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 27c2d69443717..d6774b89a105a 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -279,6 +279,17 @@ pub trait DatabaseExt: Database + DatabaseCommit { journaled_state: &mut JournaledState, ) -> Result<(), BackendError>; + /// Copies bytecode, storage, nonce and balance from the given genesis account to the target + /// address. + /// + /// Returns [Ok] if data was successfully inserted into the journal, [Err] otherwise. + fn clone_account( + &mut self, + source: &GenesisAccount, + target: &Address, + journaled_state: &mut JournaledState, + ) -> Result<(), BackendError>; + /// Returns true if the given account is currently marked as persistent. fn is_persistent(&self, acc: &Address) -> bool; @@ -1367,45 +1378,60 @@ impl DatabaseExt for Backend { ) -> Result<(), BackendError> { // Loop through all of the allocs defined in the map and commit them to the journal. for (addr, acc) in allocs.iter() { - // Fetch the account from the journaled state. Will create a new account if it does - // not already exist. - let mut state_acc = journaled_state.load_account(*addr, self)?; - - // Set the account's bytecode and code hash, if the `bytecode` field is present. - if let Some(bytecode) = acc.code.as_ref() { - state_acc.info.code_hash = keccak256(bytecode); - let bytecode = Bytecode::new_raw(bytecode.0.clone().into()); - state_acc.info.code = Some(bytecode); - } + self.clone_account(acc, addr, journaled_state)?; + } - // Set the account's storage, if the `storage` field is present. - if let Some(storage) = acc.storage.as_ref() { - state_acc.storage = storage - .iter() - .map(|(slot, value)| { - let slot = U256::from_be_bytes(slot.0); - ( - slot, - EvmStorageSlot::new_changed( - state_acc - .storage - .get(&slot) - .map(|s| s.present_value) - .unwrap_or_default(), - U256::from_be_bytes(value.0), - ), - ) - }) - .collect(); - } - // Set the account's nonce and balance. - state_acc.info.nonce = acc.nonce.unwrap_or_default(); - state_acc.info.balance = acc.balance; + Ok(()) + } - // Touch the account to ensure the loaded information persists if called in `setUp`. - journaled_state.touch(addr); + /// Copies bytecode, storage, nonce and balance from the given genesis account to the target + /// address. + /// + /// Returns [Ok] if data was successfully inserted into the journal, [Err] otherwise. + fn clone_account( + &mut self, + source: &GenesisAccount, + target: &Address, + journaled_state: &mut JournaledState, + ) -> Result<(), BackendError> { + // Fetch the account from the journaled state. Will create a new account if it does + // not already exist. + let mut state_acc = journaled_state.load_account(*target, self)?; + + // Set the account's bytecode and code hash, if the `bytecode` field is present. + if let Some(bytecode) = source.code.as_ref() { + state_acc.info.code_hash = keccak256(bytecode); + let bytecode = Bytecode::new_raw(bytecode.0.clone().into()); + state_acc.info.code = Some(bytecode); } + // Set the account's storage, if the `storage` field is present. + if let Some(storage) = source.storage.as_ref() { + state_acc.storage = storage + .iter() + .map(|(slot, value)| { + let slot = U256::from_be_bytes(slot.0); + ( + slot, + EvmStorageSlot::new_changed( + state_acc + .storage + .get(&slot) + .map(|s| s.present_value) + .unwrap_or_default(), + U256::from_be_bytes(value.0), + ), + ) + }) + .collect(); + } + // Set the account's nonce and balance. + state_acc.info.nonce = source.nonce.unwrap_or_default(); + state_acc.info.balance = source.balance; + + // Touch the account to ensure the loaded information persists if called in `setUp`. + journaled_state.touch(target); + Ok(()) } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 8bb13577e8b5b..be6522ac44ed9 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -155,6 +155,7 @@ interface Vm { function broadcast(uint256 privateKey) external; function chainId(uint256 newChainId) external; function clearMockedCalls() external; + 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); diff --git a/testdata/default/cheats/CloneAccount.t.sol b/testdata/default/cheats/CloneAccount.t.sol new file mode 100644 index 0000000000000..5342a92d39f28 --- /dev/null +++ b/testdata/default/cheats/CloneAccount.t.sol @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Source { + uint256 public a; + address public b; + uint256[3] public c; + bool public d; + + constructor() { + a = 100; + b = address(111); + c[0] = 222; + c[1] = 333; + c[2] = 444; + d = true; + } +} + +contract CloneAccountTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + address clone = address(777); + + function setUp() public { + Source src = new Source(); + vm.deal(address(src), 0.123 ether); + vm.cloneAccount(address(src), clone); + } + + function test_clone_account() public { + // Check clone balance. + assertEq(clone.balance, 0.123 ether); + // Check clone storage. + assertEq(Source(clone).a(), 100); + assertEq(Source(clone).b(), address(111)); + assertEq(Source(clone).c(0), 222); + assertEq(Source(clone).c(1), 333); + assertEq(Source(clone).c(2), 444); + assertEq(Source(clone).d(), true); + } +} From e215f3fdeada259a8886a7611151794d280ca298 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:39:49 +0200 Subject: [PATCH 1531/1963] fix(`anvil`): eth_gasPrice returned `1000000000` with `--block-base-fee-per-gas 0`, adds new `--disable-min-priority-fee` to return `0` (#9049) * add new flag to disable min suggested priority fee: `--disable-min-priority-fee` * documentation * remove unnecessary value_name --- crates/anvil/src/cmd.rs | 5 +++++ crates/anvil/src/config.rs | 11 +++++++++++ crates/anvil/src/eth/api.rs | 6 +++++- crates/anvil/src/eth/backend/mem/mod.rs | 5 +++++ crates/anvil/src/eth/fees.rs | 8 ++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 149b9c8630659..76eb0510a5916 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -254,6 +254,7 @@ impl NodeArgs { .fork_compute_units_per_second(compute_units_per_second) .with_eth_rpc_url(self.evm_opts.fork_url.map(|fork| fork.url)) .with_base_fee(self.evm_opts.block_base_fee_per_gas) + .disable_min_priority_fee(self.evm_opts.disable_min_priority_fee) .with_storage_caching(self.evm_opts.no_storage_caching) .with_server_config(self.server_config) .with_host(self.host) @@ -547,6 +548,10 @@ pub struct AnvilEvmArgs { )] pub block_base_fee_per_gas: Option, + /// Disable the enforcement of a minimum suggested priority fee. + #[arg(long, visible_alias = "no-priority-fee", help_heading = "Environment config")] + pub disable_min_priority_fee: bool, + /// The chain ID. #[arg(long, alias = "chain", help_heading = "Environment config")] pub chain_id: Option, diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 189cf51752d1b..273dbad89ffd6 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -99,6 +99,8 @@ pub struct NodeConfig { pub gas_price: Option, /// Default base fee pub base_fee: Option, + /// If set to `true`, disables the enforcement of a minimum suggested priority fee + pub disable_min_priority_fee: bool, /// Default blob excess gas and price pub blob_excess_gas_and_price: Option, /// The hardfork to use @@ -432,6 +434,7 @@ impl Default for NodeConfig { fork_choice: None, account_generator: None, base_fee: None, + disable_min_priority_fee: false, blob_excess_gas_and_price: None, enable_tracing: true, enable_steps_tracing: false, @@ -623,6 +626,13 @@ impl NodeConfig { self } + /// Disable the enforcement of a minimum suggested priority fee + #[must_use] + pub fn disable_min_priority_fee(mut self, disable_min_priority_fee: bool) -> Self { + self.disable_min_priority_fee = disable_min_priority_fee; + self + } + /// Sets the init genesis (genesis.json) #[must_use] pub fn with_genesis(mut self, genesis: Option) -> Self { @@ -994,6 +1004,7 @@ impl NodeConfig { let fees = FeeManager::new( cfg.handler_cfg.spec_id, self.get_base_fee(), + !self.disable_min_priority_fee, self.get_gas_price(), self.get_blob_excess_gas_and_price(), ); diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index c8fd497a3e815..78b52d49496ab 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -592,7 +592,11 @@ impl EthApi { /// Returns the current gas price pub fn gas_price(&self) -> u128 { if self.backend.is_eip1559() { - (self.backend.base_fee() as u128).saturating_add(self.lowest_suggestion_tip()) + if self.backend.is_min_priority_fee_enforced() { + (self.backend.base_fee() as u128).saturating_add(self.lowest_suggestion_tip()) + } else { + self.backend.base_fee() as u128 + } } else { self.backend.fees().raw_gas_price() } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 05a7a3ff7a7b4..0b7777f2db204 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -668,6 +668,11 @@ impl Backend { self.fees.base_fee() } + /// Returns whether the minimum suggested priority fee is enforced + pub fn is_min_priority_fee_enforced(&self) -> bool { + self.fees.is_min_priority_fee_enforced() + } + pub fn excess_blob_gas_and_price(&self) -> Option { self.fees.excess_blob_gas_and_price() } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index 72d66b1130558..f41c51505ff62 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -48,6 +48,8 @@ pub struct FeeManager { /// /// This value will be updated after a new block was mined base_fee: Arc>, + /// Whether the minimum suggested priority fee is enforced + is_min_priority_fee_enforced: bool, /// Tracks the excess blob gas, and the base fee, for the next block post Cancun /// /// This value will be updated after a new block was mined @@ -63,12 +65,14 @@ impl FeeManager { pub fn new( spec_id: SpecId, base_fee: u64, + is_min_priority_fee_enforced: bool, gas_price: u128, blob_excess_gas_and_price: BlobExcessGasAndPrice, ) -> Self { Self { spec_id, base_fee: Arc::new(RwLock::new(base_fee)), + is_min_priority_fee_enforced, gas_price: Arc::new(RwLock::new(gas_price)), blob_excess_gas_and_price: Arc::new(RwLock::new(blob_excess_gas_and_price)), elasticity: Arc::new(RwLock::new(default_elasticity())), @@ -105,6 +109,10 @@ impl FeeManager { } } + pub fn is_min_priority_fee_enforced(&self) -> bool { + self.is_min_priority_fee_enforced + } + /// Raw base gas price pub fn raw_gas_price(&self) -> u128 { *self.gas_price.read() From 0b9bdf35e14708cd88504bda55599eba196d21fc Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:15:36 +0300 Subject: [PATCH 1532/1963] feat: update to Soldeer v0.4.0 (#9014) * updated to version 0.4.0 * fmt and clippy * added cargo modifications * solving small nits * forcing special chars on windows * escaping special chars * removing stderr checks * fmt * remvoving err assert from login --- Cargo.lock | 92 ++++++++- Cargo.toml | 2 +- crates/forge/Cargo.toml | 2 +- crates/forge/bin/cmd/soldeer.rs | 21 +- crates/forge/bin/main.rs | 2 +- crates/forge/tests/cli/soldeer.rs | 308 ++++++++---------------------- 6 files changed, 175 insertions(+), 252 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d94ee063df489..d29783c243fc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1834,6 +1834,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bon" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97493a391b4b18ee918675fb8663e53646fd09321c58b46afa04e8ce2499c869" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2af3eac944c12cdf4423eab70d310da0a8e5851a18ffb192c0a5e3f7ae1663" +dependencies = [ + "darling", + "ident_case", + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "bs58" version = "0.5.1" @@ -2183,6 +2206,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "cliclack" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a80570d35684e725e9d2d4aaaf32bc0cbfcfb8539898f9afea3da0d2e5189e4" +dependencies = [ + "console", + "indicatif", + "once_cell", + "strsim", + "textwrap", + "zeroize", +] + [[package]] name = "clipboard-win" version = "5.4.0" @@ -3399,7 +3436,7 @@ dependencies = [ "similar", "similar-asserts", "solang-parser", - "soldeer", + "soldeer-commands", "strum", "svm-rs", "tempfile", @@ -8165,6 +8202,12 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "snapbox" version = "0.6.18" @@ -8215,24 +8258,39 @@ dependencies = [ ] [[package]] -name = "soldeer" -version = "0.3.4" +name = "soldeer-commands" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ed763c2bb43241ca0fb6c00feea54187895b7f4eb1090654fbf82807127369" +checksum = "236ae9bfdac074b0cf30caef23e59265b8f609334be3941727c1babcbb04c9cf" dependencies = [ - "chrono", "clap", + "cliclack", + "derive_more 1.0.0", + "email-address-parser", + "rayon", + "soldeer-core", +] + +[[package]] +name = "soldeer-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d84a27730c18b4ae2bce01a81bec17397009e3dd739e26f9c10ed8807a97d93e" +dependencies = [ + "bon", + "chrono", + "cliclack", "const-hex", + "derive_more 1.0.0", "dunce", - "email-address-parser", - "futures", "home", "ignore", "path-slash", + "rayon", "regex", "reqwest", - "rpassword", "sanitize-filename", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -8240,7 +8298,6 @@ dependencies = [ "tokio", "toml_edit", "uuid 1.10.0", - "yansi", "zip", "zip-extract", ] @@ -8510,6 +8567,17 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width 0.1.14", +] + [[package]] name = "thiserror" version = "1.0.64" @@ -9126,6 +9194,12 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.24" diff --git a/Cargo.toml b/Cargo.toml index bbefa8c4bf528..99637920d14a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -274,7 +274,7 @@ reqwest = { version = "0.12", default-features = false } tower = "0.4" tower-http = "0.5" # soldeer -soldeer = "=0.3.4" +soldeer-commands = "=0.4.0" proptest = "1" comfy-table = "7" diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 2cd6607859a1e..0e359191aabf3 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -106,7 +106,7 @@ tower-http = { workspace = true, features = ["fs"] } opener = "0.7" # soldeer -soldeer.workspace = true +soldeer-commands.workspace = true quick-junit = "0.5.0" [target.'cfg(unix)'.dependencies] diff --git a/crates/forge/bin/cmd/soldeer.rs b/crates/forge/bin/cmd/soldeer.rs index 5482bdc6fe94c..56b8c31f3a515 100644 --- a/crates/forge/bin/cmd/soldeer.rs +++ b/crates/forge/bin/cmd/soldeer.rs @@ -1,7 +1,7 @@ use clap::Parser; use eyre::Result; -use soldeer::commands::Subcommands; +use soldeer_commands::Command; // CLI arguments for `forge soldeer`. // The following list of commands and their actions: @@ -22,14 +22,14 @@ use soldeer::commands::Subcommands; override_usage = "Native Solidity Package Manager, `run forge soldeer [COMMAND] --help` for more details" )] pub struct SoldeerArgs { - /// Command must be one of the following install/push/login/update/version. + /// Command must be one of the following init/install/login/push/uninstall/update/version. #[command(subcommand)] - command: Subcommands, + command: Command, } impl SoldeerArgs { - pub fn run(self) -> Result<()> { - match soldeer::run(self.command) { + pub async fn run(self) -> Result<()> { + match soldeer_commands::run(self.command).await { Ok(_) => Ok(()), Err(err) => Err(eyre::eyre!("Failed to run soldeer {}", err)), } @@ -38,11 +38,12 @@ impl SoldeerArgs { #[cfg(test)] mod tests { - use super::*; - use soldeer::commands::Version; + use soldeer_commands::{commands::Version, Command}; - #[test] - fn test_soldeer_version() { - assert!(soldeer::run(Subcommands::Version(Version {})).is_ok()); + #[tokio::test] + #[allow(clippy::needless_return)] + async fn test_soldeer_version() { + let command = Command::Version(Version::default()); + assert!(soldeer_commands::run(command).await.is_ok()); } } diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 9a98d8aeffd02..ba89d6dcf6324 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -118,7 +118,7 @@ fn main() -> Result<()> { ForgeSubcommand::Generate(cmd) => match cmd.sub { GenerateSubcommands::Test(cmd) => cmd.run(), }, - ForgeSubcommand::Soldeer(cmd) => cmd.run(), + ForgeSubcommand::Soldeer(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Eip712(cmd) => cmd.run(), ForgeSubcommand::BindJson(cmd) => cmd.run(), } diff --git a/crates/forge/tests/cli/soldeer.rs b/crates/forge/tests/cli/soldeer.rs index 6c57f69f30842..30b0c49577a2b 100644 --- a/crates/forge/tests/cli/soldeer.rs +++ b/crates/forge/tests/cli/soldeer.rs @@ -1,32 +1,25 @@ //! Contains various tests related to `forge soldeer`. -use std::{ - fs::{self, OpenOptions}, - path::Path, -}; +use std::{fs, path::Path}; use foundry_test_utils::forgesoldeer; -use std::io::Write; forgesoldeer!(install_dependency, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; + let mut foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +[dependencies] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options +"#; let foundry_file = prj.root().join("foundry.toml"); + fs::write(&foundry_file, foundry_contents).unwrap(); - cmd.arg("soldeer").args([command, dependency]).assert_success().stdout_eq(str![[r#" -🦌 Running Soldeer install 🦌 -No config file found. If you wish to proceed, please select how you want Soldeer to be configured: -1. Using foundry.toml -2. Using soldeer.toml -(Press 1 or 2), default is foundry.toml -Started HTTP download of forge-std~1.8.1 -Dependency forge-std~1.8.1 downloaded! -Adding dependency forge-std-1.8.1 to the config file -The dependency forge-std~1.8.1 was unzipped! -Writing forge-std~1.8.1 to the lock file. -Added forge-std~1.8.1 to remappings - -"#]]); + cmd.arg("soldeer").args([command, dependency]).assert_success(); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -36,20 +29,12 @@ Added forge-std~1.8.1 to remappings // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - // let lock_contents = r#"[[dependencies]] - // name = "forge-std" - // version = "1.8.1" - // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" - // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" - // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" - // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); - // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); // Making sure the foundry contents are the right ones - let foundry_contents = r#"[profile.default] + foundry_contents = r#"[profile.default] src = "src" out = "out" libs = ["lib"] @@ -68,39 +53,19 @@ forgesoldeer!(install_dependency_git, |prj, cmd| { let dependency = "forge-std~1.8.1"; let git = "https://gitlab.com/mario4582928/Mario.git"; + let mut foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +[dependencies] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options +"#; let foundry_file = prj.root().join("foundry.toml"); + fs::write(&foundry_file, foundry_contents).unwrap(); - cmd.arg("soldeer") - .args([command, dependency, git]) - .assert_success() - .stdout_eq(str![[r#" -🦌 Running Soldeer install 🦌 -No config file found. If you wish to proceed, please select how you want Soldeer to be configured: -1. Using foundry.toml -2. Using soldeer.toml -(Press 1 or 2), default is foundry.toml -Started GIT download of forge-std~1.8.1 -Successfully downloaded forge-std~1.8.1 the dependency via git -Dependency forge-std~1.8.1 downloaded! -Adding dependency forge-std-1.8.1 to the config file -Writing forge-std~1.8.1 to the lock file. -Added forge-std~1.8.1 to remappings - -"#]]) - .stdout_eq(str![[r#" -🦌 Running Soldeer install 🦌 -No config file found. If you wish to proceed, please select how you want Soldeer to be configured: -1. Using foundry.toml -2. Using soldeer.toml -(Press 1 or 2), default is foundry.toml -Started GIT download of forge-std~1.8.1 -Successfully downloaded forge-std~1.8.1 the dependency via git -Dependency forge-std~1.8.1 downloaded! -Adding dependency forge-std-1.8.1 to the config file -Writing forge-std~1.8.1 to the lock file. -Added forge-std~1.8.1 to remappings - -"#]]); + cmd.arg("soldeer").args([command, dependency, git]).assert_success(); // Making sure the path was created to the dependency and that README.md exists // meaning that the dependencies were installed correctly @@ -109,19 +74,12 @@ Added forge-std~1.8.1 to remappings // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - // let lock_contents = r#"[[dependencies]] - // name = "forge-std" - // version = "1.8.1" - // source = "https://gitlab.com/mario4582928/Mario.git" - // checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c" - // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); - // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); // Making sure the foundry contents are the right ones - let foundry_contents = r#"[profile.default] + foundry_contents = r#"[profile.default] src = "src" out = "out" libs = ["lib"] @@ -142,25 +100,19 @@ forgesoldeer!(install_dependency_git_commit, |prj, cmd| { let rev_flag = "--rev"; let commit = "7a0663eaf7488732f39550be655bad6694974cb3"; + let mut foundry_contents = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +[dependencies] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options +"#; let foundry_file = prj.root().join("foundry.toml"); + fs::write(&foundry_file, foundry_contents).unwrap(); - cmd.arg("soldeer") - .args([command, dependency, git, rev_flag, commit]) - .assert_success() - .stdout_eq(str![[r#" -🦌 Running Soldeer install 🦌 -No config file found. If you wish to proceed, please select how you want Soldeer to be configured: -1. Using foundry.toml -2. Using soldeer.toml -(Press 1 or 2), default is foundry.toml -Started GIT download of forge-std~1.8.1 -Successfully downloaded forge-std~1.8.1 the dependency via git -Dependency forge-std~1.8.1 downloaded! -Adding dependency forge-std-1.8.1 to the config file -Writing forge-std~1.8.1 to the lock file. -Added forge-std~1.8.1 to remappings - -"#]]); + cmd.arg("soldeer").args([command, dependency, git, rev_flag, commit]).assert_success(); // Making sure the path was created to the dependency and that README.md exists // meaning that the dependencies were installed correctly @@ -170,19 +122,12 @@ Added forge-std~1.8.1 to remappings // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - // let lock_contents = r#"[[dependencies]] - // name = "forge-std" - // version = "1.8.1" - // source = "https://gitlab.com/mario4582928/Mario.git" - // checksum = "7a0663eaf7488732f39550be655bad6694974cb3" - // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); - // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); // Making sure the foundry contents are the right ones - let foundry_contents = r#"[profile.default] + foundry_contents = r#"[profile.default] src = "src" out = "out" libs = ["lib"] @@ -200,7 +145,13 @@ forgesoldeer!(update_dependencies, |prj, cmd| { let command = "update"; // We need to write this into the foundry.toml to make the update install the dependency - let foundry_updates = r#" + let foundry_updates = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + [dependencies] "@tt" = {version = "1.6.1", url = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/3_3_0-rc_2_22-01-2024_13:12:57_contracts.zip"} forge-std = { version = "1.8.1" } @@ -210,12 +161,7 @@ mario-custom-tag = { version = "1.0", git = "https://gitlab.com/mario4582928/Mar mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", tag = "custom-branch" } "#; let foundry_file = prj.root().join("foundry.toml"); - - let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); - - if let Err(e) = write!(file, "{foundry_updates}") { - eprintln!("Couldn't write to file: {e}"); - } + fs::write(&foundry_file, foundry_updates).unwrap(); cmd.arg("soldeer").arg(command).assert_success(); @@ -237,45 +183,6 @@ mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/ // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - // let lock_contents = r#"[[dependencies]] - // name = "@tt" - // version = "1.6.1" - // source = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/3_3_0-rc_2_22-01-2024_13:12:57_contracts.zip" - // checksum = "3aa5b07e796ce2ae54bbab3a5280912444ae75807136a513fa19ff3a314c323f" - // integrity = "24e7847580674bd0a4abf222b82fac637055141704c75a3d679f637acdcfe817" - - // [[dependencies]] - // name = "forge-std" - // version = "1.8.1" - // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" - // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" - // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" - - // [[dependencies]] - // name = "mario" - // version = "1.0" - // source = "https://gitlab.com/mario4582928/Mario.git" - // checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c" - - // [[dependencies]] - // name = "mario-custom-branch" - // version = "1.0" - // source = "https://gitlab.com/mario4582928/Mario.git" - // checksum = "84c3b38dba44a4c29ec44f45a31e1e59d36aa77b" - - // [[dependencies]] - // name = "mario-custom-tag" - // version = "1.0" - // source = "https://gitlab.com/mario4582928/Mario.git" - // checksum = "a366c4b560022d12e668d6c1756c6382e2352d0f" - - // [[dependencies]] - // name = "solmate" - // version = "6.7.0" - // source = "https://soldeer-revisions.s3.amazonaws.com/solmate/6_7_0_22-01-2024_13:21:00_solmate.zip" - // checksum = "dd0f08cdaaaad1de0ac45993d4959351ba89c2d9325a0b5df5570357064f2c33" - // integrity = "ec330877af853f9d34b2b1bf692fb33c9f56450625f5c4abdcf0d3405839730e" - // "#; // assert_data_eq!(lock_contents, read_file_to_string(&path_lock_file)); let actual_lock_contents = read_file_to_string(&path_lock_file); @@ -297,7 +204,6 @@ mario = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", re mario-custom-tag = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", tag = "custom-tag" } mario-custom-branch = { version = "1.0", git = "https://gitlab.com/mario4582928/Mario.git", tag = "custom-branch" } "#; - assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); }); @@ -306,27 +212,21 @@ forgesoldeer!(update_dependencies_simple_version, |prj, cmd| { // We need to write this into the foundry.toml to make the update install the dependency, this // is he simplified version of version specification - let foundry_updates = r#" + let foundry_updates = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + [dependencies] forge-std = "1.8.1" "#; let foundry_file = prj.root().join("foundry.toml"); - let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); - - if let Err(e) = write!(file, "{foundry_updates}") { - eprintln!("Couldn't write to file: {e}"); - } - - cmd.arg("soldeer").arg(command).assert_success().stdout_eq(str![[r#" -🦌 Running Soldeer update 🦌 -Started HTTP download of forge-std~1.8.1 -Dependency forge-std~1.8.1 downloaded! -The dependency forge-std~1.8.1 was unzipped! -Writing forge-std~1.8.1 to the lock file. - -"#]]); + fs::write(&foundry_file, foundry_updates).unwrap(); + cmd.arg("soldeer").arg(command).assert_success(); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly let path_dep_forge = @@ -335,16 +235,8 @@ Writing forge-std~1.8.1 to the lock file. // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - // let lock_contents = r#"[[dependencies]] - // name = "forge-std" - // version = "1.8.1" - // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" - // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" - // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" - // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); - // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); // Making sure the foundry contents are the right ones @@ -362,47 +254,28 @@ forge-std = "1.8.1" assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents); }); -forgesoldeer!(login, |prj, cmd| { - let command = "login"; - - let output = cmd.arg("soldeer").arg(command).execute(); - - // On login, we can only check if the prompt is displayed in the stdout - let stdout = String::from_utf8(output.stdout).expect("Could not parse the output"); - assert!(stdout.contains("Please enter your email")); -}); - forgesoldeer!(install_dependency_with_remappings_config, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; - let foundry_updates = r#" + let foundry_updates = r#"[profile.default] +src = "src" +out = "out" +libs = ["lib", "dependencies"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options + [soldeer] remappings_generate = true remappings_prefix = "@custom-f@" remappings_location = "config" remappings_regenerate = true + +[dependencies] "#; let foundry_file = prj.root().join("foundry.toml"); - let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); - - if let Err(e) = write!(file, "{foundry_updates}") { - eprintln!("Couldn't write to file: {e}"); - } - - cmd.arg("soldeer").args([command, dependency]).assert_success().stdout_eq(str![[r#" -🦌 Running Soldeer install 🦌 -No config file found. If you wish to proceed, please select how you want Soldeer to be configured: -1. Using foundry.toml -2. Using soldeer.toml -(Press 1 or 2), default is foundry.toml -Started HTTP download of forge-std~1.8.1 -Dependency forge-std~1.8.1 downloaded! -Adding dependency forge-std-1.8.1 to the config file -The dependency forge-std~1.8.1 was unzipped! -Writing forge-std~1.8.1 to the lock file. -Added all dependencies to remapppings - -"#]]); + fs::write(&foundry_file, foundry_updates).unwrap(); + + cmd.arg("soldeer").args([command, dependency]).assert_success(); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -412,23 +285,15 @@ Added all dependencies to remapppings // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - // let lock_contents = r#"[[dependencies]] - // name = "forge-std" - // version = "1.8.1" - // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" - // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" - // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" - // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); - // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); // Making sure the foundry contents are the right ones let foundry_contents = r#"[profile.default] src = "src" out = "out" -libs = ["lib"] +libs = ["lib", "dependencies"] remappings = ["@custom-f@forge-std-1.8.1/=dependencies/forge-std-1.8.1/"] # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options @@ -450,6 +315,8 @@ forgesoldeer!(install_dependency_with_remappings_txt, |prj, cmd| { let command = "install"; let dependency = "forge-std~1.8.1"; let foundry_updates = r#" +[dependencies] + [soldeer] remappings_generate = true remappings_prefix = "@custom-f@" @@ -457,26 +324,9 @@ remappings_location = "txt" remappings_regenerate = true "#; let foundry_file = prj.root().join("foundry.toml"); - let mut file = OpenOptions::new().append(true).open(&foundry_file).unwrap(); - - if let Err(e) = write!(file, "{foundry_updates}") { - eprintln!("Couldn't write to file: {e}"); - } - - cmd.arg("soldeer").args([command, dependency]).assert_success().stdout_eq(str![[r#" -🦌 Running Soldeer install 🦌 -No config file found. If you wish to proceed, please select how you want Soldeer to be configured: -1. Using foundry.toml -2. Using soldeer.toml -(Press 1 or 2), default is foundry.toml -Started HTTP download of forge-std~1.8.1 -Dependency forge-std~1.8.1 downloaded! -Adding dependency forge-std-1.8.1 to the config file -The dependency forge-std~1.8.1 was unzipped! -Writing forge-std~1.8.1 to the lock file. -Added all dependencies to remapppings - -"#]]); + fs::write(&foundry_file, foundry_updates).unwrap(); + + cmd.arg("soldeer").args([command, dependency]).assert_success(); // Making sure the path was created to the dependency and that foundry.toml exists // meaning that the dependencies were installed correctly @@ -486,16 +336,8 @@ Added all dependencies to remapppings // Making sure the lock contents are the right ones let path_lock_file = prj.root().join("soldeer.lock"); - // let lock_contents = r#"[[dependencies]] - // name = "forge-std" - // version = "1.8.1" - // source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_8_1_23-03-2024_00:05:44_forge-std-v1.8.1.zip" - // checksum = "0f7cd44f5670c31a9646d4031e70c66321cd3ed6ebac3c7278e4e57e4e5c5bd0" - // integrity = "6a52f0c34d935e508af46a6d12a3a741798252f20a66f6bbee86c23dd6ef7c8d" - // "#; let actual_lock_contents = read_file_to_string(&path_lock_file); - // assert_data_eq!(lock_contents, actual_lock_contents); assert!(actual_lock_contents.contains("forge-std")); // Making sure the foundry contents are the right ones @@ -505,6 +347,12 @@ Added all dependencies to remapppings assert_data_eq!(read_file_to_string(&remappings_file), remappings_content); }); +forgesoldeer!(login, |prj, cmd| { + let command = "login"; + + let _ = cmd.arg("soldeer").arg(command).assert_failure(); +}); + fn read_file_to_string(path: &Path) -> String { let contents: String = fs::read_to_string(path).unwrap_or_default(); contents From a17869a6dcce7ce3765c5ed521d40ddb572de9f0 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:42:37 +0300 Subject: [PATCH 1533/1963] fix(invariant): do not commit state if assume returns (#9062) --- crates/evm/evm/src/executors/invariant/mod.rs | 15 +++--- crates/forge/tests/it/invariant.rs | 54 +++++++++++++++++++ 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 2e2e06e6d32a1..f6edd586a8039 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -317,10 +317,11 @@ impl<'a> InvariantExecutor<'a> { TestCaseError::fail("No input generated to call fuzzed target.") })?; - // Execute call from the randomly generated sequence and commit state changes. - let call_result = current_run + // Execute call from the randomly generated sequence without committing state. + // State is committed only if call is not a magic assume. + let mut call_result = current_run .executor - .transact_raw( + .call_raw( tx.sender, tx.call_details.target, tx.call_details.calldata.clone(), @@ -343,9 +344,11 @@ impl<'a> InvariantExecutor<'a> { return Err(TestCaseError::fail("Max number of vm.assume rejects reached.")) } } else { + // Commit executed call result. + current_run.executor.commit(&mut call_result); + // Collect data for fuzzing from the state changeset. let mut state_changeset = call_result.state_changeset.clone(); - if !call_result.reverted { collect_data( &invariant_test, @@ -369,13 +372,13 @@ impl<'a> InvariantExecutor<'a> { { warn!(target: "forge::test", "{error}"); } - current_run.fuzz_runs.push(FuzzCase { calldata: tx.call_details.calldata.clone(), gas: call_result.gas_used, stipend: call_result.stipend, }); + // Determine if test can continue or should exit. let result = can_continue( &invariant_contract, &invariant_test, @@ -385,11 +388,9 @@ impl<'a> InvariantExecutor<'a> { &state_changeset, ) .map_err(|e| TestCaseError::fail(e.to_string()))?; - if !result.can_continue || current_run.depth == self.config.depth - 1 { invariant_test.set_last_run_inputs(¤t_run.inputs); } - // If test cannot continue then stop current run and exit test suite. if !result.can_continue { return Err(TestCaseError::fail("Test cannot continue.")) diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index a6fa615122a23..0a9e7910a0ad5 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -769,3 +769,57 @@ contract AssumeTest is Test { ... "#]]); }); + +// Test too many inputs rejected for `assumePrecompile`/`assumeForgeAddress`. +// +forgetest_init!(should_revert_with_assume_code, |prj, cmd| { + let config = Config { + invariant: { + InvariantConfig { fail_on_revert: true, max_assume_rejects: 10, ..Default::default() } + }, + ..Default::default() + }; + prj.write_config(config); + + // Add initial test that breaks invariant. + prj.add_test( + "AssumeTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract BalanceTestHandler is Test { + address public ref = address(1412323); + address alice; + + constructor(address _alice) { + alice = _alice; + } + + function increment(uint256 amount_, address addr) public { + assumeNotPrecompile(addr); + assumeNotForgeAddress(addr); + assertEq(alice.balance, 100_000 ether); + } +} + +contract BalanceAssumeTest is Test { + function setUp() public { + address alice = makeAddr("alice"); + vm.deal(alice, 100_000 ether); + targetSender(alice); + BalanceTestHandler handler = new BalanceTestHandler(alice); + targetContract(address(handler)); + } + + function invariant_balance() public {} +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "invariant_balance"]).assert_failure().stdout_eq(str![[r#" +... +[FAIL: `vm.assume` rejected too many inputs (10 allowed)] invariant_balance() (runs: 0, calls: 0, reverts: 0) +... +"#]]); +}); From 373ad46de9034f3b9e30b95084c9d1bd076d66a7 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:31:38 +0530 Subject: [PATCH 1534/1963] feat(`cheatcodes`): vm.getScriptWallets() (#9052) * feat(`cheatcodes`): vm.getScriptWallets() * feat: load default anvil accounts in script * Revert "feat: load default anvil accounts in script" This reverts commit 4d64356a51bf226482269a2af47f947c4e49e462. * clippy * test --------- Co-authored-by: grandizzy --------- Co-authored-by: grandizzy --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++ crates/cheatcodes/spec/src/vm.rs | 4 +++ crates/cheatcodes/src/script.rs | 15 +++++++++ crates/forge/tests/cli/script.rs | 40 ++++++++++++++++++++++++ testdata/cheats/Vm.sol | 1 + 5 files changed, 80 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index e6fef48b0891d..06ddba5bd5d1f 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5395,6 +5395,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getScriptWallets", + "description": "Returns addresses of available unlocked wallets in the script environment.", + "declaration": "function getScriptWallets() external returns (address[] memory wallets);", + "visibility": "external", + "mutability": "", + "signature": "getScriptWallets()", + "selector": "0x7c49aa1f", + "selectorBytes": [ + 124, + 73, + 170, + 31 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "indexOf", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 0ee95e43fd02c..e73755de1d3bc 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1877,6 +1877,10 @@ interface Vm { #[cheatcode(group = Scripting)] function broadcastRawTransaction(bytes calldata data) external; + /// Returns addresses of available unlocked wallets in the script environment. + #[cheatcode(group = Scripting)] + function getScriptWallets() external returns (address[] memory wallets); + // ======== Utilities ======== // -------- Strings -------- diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 93d5aaaf8d349..f9535844c7c44 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -3,6 +3,7 @@ use crate::{Cheatcode, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, B256, U256}; use alloy_signer_local::PrivateKeySigner; +use alloy_sol_types::SolValue; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; use parking_lot::Mutex; use std::sync::Arc; @@ -60,6 +61,20 @@ impl Cheatcode for stopBroadcastCall { } } +impl Cheatcode for getScriptWalletsCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let script_wallets = + ccx.state.script_wallets().cloned().map(|sw| sw.signers().unwrap_or_default()); + + if let Some(script_wallets) = script_wallets { + let script_wallets: Vec
= script_wallets.into_iter().collect(); + Ok(script_wallets.abi_encode()) + } else { + Ok(Default::default()) + } + } +} + #[derive(Clone, Debug, Default)] pub struct Broadcast { /// Address of the transaction origin diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 61c2456fef66f..826d66282dd77 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2055,3 +2055,43 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. "#]]); }); + +forgetest_init!(can_get_script_wallets, |prj, cmd| { + let script = prj + .add_source( + "Foo", + r#" +import "forge-std/Script.sol"; + +interface Vm { + function getScriptWallets() external returns (address[] memory wallets); +} + +contract WalletScript is Script { + function run() public { + address[] memory wallets = Vm(address(vm)).getScriptWallets(); + console.log(wallets[0]); + } +}"#, + ) + .unwrap(); + cmd.arg("script") + .arg(script) + .args([ + "--private-key", + "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6", + "-v", + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Script ran successfully. +[GAS] + +== Logs == + 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 + +"#]]); +}); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index be6522ac44ed9..1458e3e4621d2 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -265,6 +265,7 @@ interface Vm { function getNonce(address account) external view returns (uint64 nonce); function getNonce(Wallet calldata wallet) external returns (uint64 nonce); function getRecordedLogs() external returns (Log[] memory logs); + function getScriptWallets() external returns (address[] memory wallets); function indexOf(string calldata input, string calldata key) external pure returns (uint256); function isContext(ForgeContext context) external view returns (bool result); function isDir(string calldata path) external returns (bool result); From ad86979e06c0577fc097577358e460e7f5ec9bdf Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 9 Oct 2024 11:48:40 +0400 Subject: [PATCH 1535/1963] fix: support EOF opcodes in `cast da` (#9070) * fix: support EOF opcodes in cast da * fix * fix doc * fmt --- Cargo.lock | 1 - crates/cast/Cargo.toml | 1 - crates/cast/bin/main.rs | 2 +- crates/cast/src/lib.rs | 30 +++++++++++++++++++++++++----- crates/evm/core/src/ic.rs | 33 ++++++++++++++++++++++++++++++++- 5 files changed, 58 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d29783c243fc7..be6aebeea7de2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3644,7 +3644,6 @@ dependencies = [ "comfy-table", "criterion", "dunce", - "evm-disassembler", "evmole", "eyre", "foundry-block-explorers", diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 46f8eac95cd82..9f0b6758c11c9 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -54,7 +54,6 @@ alloy-sol-types.workspace = true alloy-transport.workspace = true chrono.workspace = true -evm-disassembler.workspace = true eyre.workspace = true futures.workspace = true rand.workspace = true diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 0b861f90d02a5..63894d980b0ab 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -307,7 +307,7 @@ async fn main_args(args: CastArgs) -> Result<()> { println!("Computed Address: {}", computed.to_checksum(None)); } CastSubcommand::Disassemble { bytecode } => { - println!("{}", SimpleCast::disassemble(&bytecode)?); + println!("{}", SimpleCast::disassemble(&hex::decode(bytecode)?)?); } CastSubcommand::Selectors { bytecode, resolve } => { let functions = SimpleCast::extract_functions(&bytecode)?; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 8132f8e4f706c..69f86268b3d0b 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -21,7 +21,6 @@ use alloy_sol_types::sol; use alloy_transport::Transport; use base::{Base, NumberWithBase, ToBase}; use chrono::DateTime; -use evm_disassembler::{disassemble_bytes, disassemble_str, format_operations}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::Client; use foundry_common::{ @@ -37,6 +36,7 @@ use rayon::prelude::*; use revm::primitives::Eof; use std::{ borrow::Cow, + fmt::Write, io, marker::PhantomData, path::PathBuf, @@ -45,6 +45,7 @@ use std::{ time::Duration, }; use tokio::signal::ctrl_c; +use utils::decode_instructions; use foundry_common::abi::encode_function_args_packed; pub use foundry_evm::*; @@ -670,7 +671,7 @@ where if disassemble { let code = self.provider.get_code_at(who).block_id(block.unwrap_or_default()).await?.to_vec(); - Ok(format_operations(disassemble_bytes(code)?)?) + SimpleCast::disassemble(&code) } else { Ok(format!( "{}", @@ -1959,17 +1960,36 @@ impl SimpleCast { /// # Example /// /// ``` + /// use alloy_primitives::hex; /// use cast::SimpleCast as Cast; /// /// # async fn foo() -> eyre::Result<()> { /// let bytecode = "0x608060405260043610603f57600035"; - /// let opcodes = Cast::disassemble(bytecode)?; + /// let opcodes = Cast::disassemble(&hex::decode(bytecode)?)?; /// println!("{}", opcodes); /// # Ok(()) /// # } /// ``` - pub fn disassemble(bytecode: &str) -> Result { - format_operations(disassemble_str(bytecode)?) + pub fn disassemble(code: &[u8]) -> Result { + let mut output = String::new(); + + for step in decode_instructions(code) { + write!(output, "{:08x}: ", step.pc)?; + + if let Some(op) = step.op { + write!(output, "{op}")?; + } else { + write!(output, "INVALID")?; + } + + if !step.immediate.is_empty() { + write!(output, " {}", hex::encode_prefixed(step.immediate))?; + } + + writeln!(output)?; + } + + Ok(output) } /// Gets the selector for a given function signature diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index f7ab3093c5207..2711f8933543a 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -1,5 +1,9 @@ use alloy_primitives::map::HashMap; -use revm::interpreter::opcode::{PUSH0, PUSH1, PUSH32}; +use revm::interpreter::{ + opcode::{PUSH0, PUSH1, PUSH32}, + OpCode, +}; +use revm_inspectors::opcode::immediate_size; /// Maps from program counter to instruction counter. /// @@ -84,3 +88,30 @@ fn make_map(code: &[u8]) -> HashMap { } map } + +/// Represents a single instruction consisting of the opcode and its immediate data. +pub struct Instruction<'a> { + /// OpCode, if it could be decoded. + pub op: Option, + /// Immediate data following the opcode. + pub immediate: &'a [u8], + /// Program counter of the opcode. + pub pc: usize, +} + +/// Decodes raw opcode bytes into [`Instruction`]s. +pub fn decode_instructions(code: &[u8]) -> Vec> { + let mut pc = 0; + let mut steps = Vec::new(); + + while pc < code.len() { + let op = OpCode::new(code[pc]); + let immediate_size = op.map(|op| immediate_size(op, &code[pc + 1..])).unwrap_or(0) as usize; + + steps.push(Instruction { op, pc, immediate: &code[pc + 1..pc + 1 + immediate_size] }); + + pc += 1 + immediate_size; + } + + steps +} From 641132f5418bd7c268366c2da09e5300f3a8e272 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 9 Oct 2024 14:57:05 +0400 Subject: [PATCH 1536/1963] feat(forge): allow passing value to `--optimize` (#9071) feat(forge): allow passing value to --optimize --- crates/cli/src/opts/build/core.rs | 4 ++-- crates/cli/src/opts/build/mod.rs | 4 ++-- crates/forge/bin/cmd/create.rs | 7 +++++-- crates/forge/bin/cmd/inspect.rs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index b0d0ccbbd23ee..59da53372c77c 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -266,8 +266,8 @@ impl Provider for CoreBuildArgs { dict.insert("ast".to_string(), true.into()); } - if self.compiler.optimize { - dict.insert("optimizer".to_string(), self.compiler.optimize.into()); + if let Some(optimize) = self.compiler.optimize { + dict.insert("optimizer".to_string(), optimize.into()); } if !self.compiler.extra_output.is_empty() { diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index dfd5d83668299..fe50a3a9a2093 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -26,9 +26,9 @@ pub struct CompilerArgs { pub evm_version: Option, /// Activate the Solidity optimizer. - #[arg(long)] + #[arg(long, default_missing_value="true", num_args = 0..=1)] #[serde(skip)] - pub optimize: bool, + pub optimize: Option, /// The number of runs specifies roughly how often each opcode of the deployed code will be /// executed across the life-time of the contract. This means it is a trade-off parameter diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 3bcf6b36cbde1..df42f458c0157 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -335,8 +335,11 @@ impl CreateArgs { println!("Starting contract verification..."); - let num_of_optimizations = - if self.opts.compiler.optimize { self.opts.compiler.optimizer_runs } else { None }; + let num_of_optimizations = if self.opts.compiler.optimize.unwrap_or_default() { + self.opts.compiler.optimizer_runs + } else { + None + }; let verify = forge_verify::VerifyArgs { address, contract: Some(self.contract), diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index ddfe60e61d287..14d43d6f5ec44 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -52,7 +52,7 @@ impl InspectArgs { // Run Optimized? let optimized = if field == ContractArtifactField::AssemblyOptimized { - true + Some(true) } else { build.compiler.optimize }; From a96b8266cf1f11e08ef0dfca9325ea6560d17c55 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:18:51 +0300 Subject: [PATCH 1537/1963] fix(forge): add logs/decoded logs in json test results (#9074) --- crates/forge/bin/cmd/test/mod.rs | 13 ++++- crates/forge/src/result.rs | 4 ++ crates/forge/tests/cli/test_cmd.rs | 6 +++ .../SimpleContractTestNonVerbose.json | 1 + .../fixtures/SimpleContractTestVerbose.json | 49 ++++++++++++++++++- 5 files changed, 70 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 0e87a4c669152..f83d336ed69b6 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -501,7 +501,18 @@ impl TestArgs { // Run tests in a non-streaming fashion and collect results for serialization. if self.json { - let results = runner.test_collect(filter); + let mut results = runner.test_collect(filter); + results.values_mut().for_each(|suite_result| { + for test_result in suite_result.test_results.values_mut() { + if verbosity >= 2 { + // Decode logs at level 2 and above. + test_result.decoded_logs = decode_console_logs(&test_result.logs); + } else { + // Empty logs for non verbose runs. + test_result.logs = vec![]; + } + } + }); println!("{}", serde_json::to_string(&results)?); return Ok(TestOutcome::new(results, self.allow_failure)); } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index a6d7fded9c489..4fb88dfd0b59d 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -389,6 +389,10 @@ pub struct TestResult { /// be printed to the user. pub logs: Vec, + /// The decoded DSTest logging events and Hardhat's `console.log` from [logs](Self::logs). + /// Used for json output. + pub decoded_logs: Vec, + /// What kind of test this was pub kind: TestKind, diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index f8b54cc4126e1..30c7f9deb4e67 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -275,7 +275,10 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) }); const SIMPLE_CONTRACT: &str = r#" +pragma solidity 0.8.18; + import "./test.sol"; +import "./console.sol"; contract SimpleContract { uint256 public num; @@ -289,12 +292,14 @@ contract SimpleContractTest is DSTest { function test() public { SimpleContract c = new SimpleContract(); c.setValues(100); + console.log("Value set: ", 100); } } "#; forgetest!(can_run_test_with_json_output_verbose, |prj, cmd| { prj.insert_ds_test(); + prj.insert_console(); prj.add_source("Simple.t.sol", SIMPLE_CONTRACT).unwrap(); @@ -306,6 +311,7 @@ forgetest!(can_run_test_with_json_output_verbose, |prj, cmd| { forgetest!(can_run_test_with_json_output_non_verbose, |prj, cmd| { prj.insert_ds_test(); + prj.insert_console(); prj.add_source("Simple.t.sol", SIMPLE_CONTRACT).unwrap(); diff --git a/crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json b/crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json index 8fd8a0faef538..b4e396863dc68 100644 --- a/crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json +++ b/crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json @@ -7,6 +7,7 @@ "reason": null, "counterexample": null, "logs": [], + "decoded_logs": [], "kind": { "Unit": { "gas": "{...}" diff --git a/crates/forge/tests/fixtures/SimpleContractTestVerbose.json b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json index c7f47cf53477e..adc700d4d59d6 100644 --- a/crates/forge/tests/fixtures/SimpleContractTestVerbose.json +++ b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json @@ -6,7 +6,18 @@ "status": "Success", "reason": null, "counterexample": null, - "logs": [], + "logs": [ + { + "address": "0x000000000000000000636F6e736F6c652e6c6f67", + "topics": [ + "0x41304facd9323d75b11bcdd609cb38effffdb05710f7caf0e9b16c6d9d709f50" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f56616c7565207365743a20203130300000000000000000000000000000000000" + } + ], + "decoded_logs": [ + "Value set: 100" + ], "kind": { "Unit": { "gas": "{...}" @@ -58,7 +69,8 @@ "parent": null, "children": [ 1, - 2 + 2, + 3 ], "idx": 0, "trace": { @@ -91,6 +103,9 @@ }, { "Call": 1 + }, + { + "Call": 2 } ] }, @@ -153,6 +168,36 @@ }, "logs": [], "ordering": [] + }, + { + "parent": 0, + "children": [], + "idx": 3, + "trace": { + "depth": 1, + "success": true, + "caller": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", + "address": "0x000000000000000000636F6e736F6c652e6c6f67", + "maybe_precompile": null, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "STATICCALL", + "value": "0x0", + "data": "{...}", + "output": "0x", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Stop", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [] } ] } From d847e0f09a95ef6ff8463521b98136e74dac37da Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:53:33 +0300 Subject: [PATCH 1538/1963] fix(`forge`): avoid panic when empty fuzz selectors in invariants (#9076) --- crates/evm/evm/src/executors/invariant/mod.rs | 8 +++-- crates/forge/tests/it/invariant.rs | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index f6edd586a8039..58c7efd8fe129 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -742,9 +742,6 @@ impl<'a> InvariantExecutor<'a> { ) -> Result<()> { for (address, (identifier, _)) in self.setup_contracts.iter() { if let Some(selectors) = self.artifact_filters.targeted.get(identifier) { - if selectors.is_empty() { - continue; - } self.add_address_with_functions(*address, selectors, false, targeted_contracts)?; } } @@ -774,6 +771,11 @@ impl<'a> InvariantExecutor<'a> { should_exclude: bool, targeted_contracts: &mut TargetedContracts, ) -> eyre::Result<()> { + // Do not add address in target contracts if no function selected. + if selectors.is_empty() { + return Ok(()) + } + let contract = match targeted_contracts.entry(address) { Entry::Occupied(entry) => entry.into_mut(), Entry::Vacant(entry) => { diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 0a9e7910a0ad5..37b3c9b239341 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -823,3 +823,35 @@ contract BalanceAssumeTest is Test { ... "#]]); }); + +// Test proper message displayed if `targetSelector`/`excludeSelector` called with empty selectors. +// +forgetest_init!(should_not_panic_if_no_selectors, |prj, cmd| { + prj.add_test( + "NoSelectorTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract TestHandler is Test {} + +contract NoSelectorTest is Test { + bytes4[] selectors; + + function setUp() public { + TestHandler handler = new TestHandler(); + targetSelector(FuzzSelector({addr: address(handler), selectors: selectors})); + excludeSelector(FuzzSelector({addr: address(handler), selectors: selectors})); + } + + function invariant_panic() public {} +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "invariant_panic"]).assert_failure().stdout_eq(str![[r#" +... +[FAIL: failed to set up invariant testing environment: No contracts to fuzz.] invariant_panic() (runs: 0, calls: 0, reverts: 0) +... +"#]]); +}); From 97ce8c33b518d3600a48bf0e614d98454bf11463 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:30:55 +0530 Subject: [PATCH 1539/1963] chore(`anvil`): use op-alloy types (#9047) --- Cargo.lock | 226 +++++--------- Cargo.toml | 7 +- crates/anvil/Cargo.toml | 3 + crates/anvil/core/Cargo.toml | 1 + crates/anvil/core/src/eth/transaction/mod.rs | 15 +- .../core/src/eth/transaction/optimism.rs | 284 +----------------- crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/sign.rs | 22 +- 8 files changed, 112 insertions(+), 448 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be6aebeea7de2..381ed5a7514ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,30 +83,16 @@ dependencies = [ "strum", ] -[[package]] -name = "alloy-consensus" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629b62e38d471cc15fea534eb7283d2f8a4e8bdb1811bcc5d66dda6cfce6fae1" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.3.6", - "c-kzg", - "serde", -] - [[package]] name = "alloy-consensus" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "705687d5bfd019fee57cf9e206b27b30a9a9617535d5590a02b171e813208f8e" dependencies = [ - "alloy-eips 0.4.2", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.4.2", + "alloy-serde", "auto_impl", "c-kzg", "derive_more 1.0.0", @@ -122,11 +108,11 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-network", - "alloy-network-primitives 0.4.2", + "alloy-network-primitives", "alloy-primitives", "alloy-provider", "alloy-pubsub", - "alloy-rpc-types-eth 0.4.2", + "alloy-rpc-types-eth", "alloy-sol-types", "alloy-transport", "futures", @@ -182,24 +168,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-eips" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f923dd5fca5f67a43d81ed3ebad0880bd41f6dd0ada930030353ac356c54cd0f" -dependencies = [ - "alloy-eip2930", - "alloy-eip7702", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.3.6", - "c-kzg", - "derive_more 1.0.0", - "once_cell", - "serde", - "sha2", -] - [[package]] name = "alloy-eips" version = "0.4.2" @@ -210,7 +178,7 @@ dependencies = [ "alloy-eip7702", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.4.2", + "alloy-serde", "c-kzg", "derive_more 1.0.0", "once_cell", @@ -225,7 +193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8429cf4554eed9b40feec7f4451113e76596086447550275e3def933faf47ce3" dependencies = [ "alloy-primitives", - "alloy-serde 0.4.2", + "alloy-serde", "serde", ] @@ -261,13 +229,13 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85fa23a6a9d612b52e402c995f2d582c25165ec03ac6edf64c861a76bc5b87cd" dependencies = [ - "alloy-consensus 0.4.2", - "alloy-eips 0.4.2", + "alloy-consensus", + "alloy-eips", "alloy-json-rpc", - "alloy-network-primitives 0.4.2", + "alloy-network-primitives", "alloy-primitives", - "alloy-rpc-types-eth 0.4.2", - "alloy-serde 0.4.2", + "alloy-rpc-types-eth", + "alloy-serde", "alloy-signer", "alloy-sol-types", "async-trait", @@ -276,28 +244,16 @@ dependencies = [ "thiserror", ] -[[package]] -name = "alloy-network-primitives" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94ad40869867ed2d9cd3842b1e800889e5b49e6b92da346e93862b4a741bedf3" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-serde 0.3.6", - "serde", -] - [[package]] name = "alloy-network-primitives" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "801492711d4392b2ccf5fc0bc69e299fa1aab15167d74dcaa9aab96a54f684bd" dependencies = [ - "alloy-consensus 0.4.2", - "alloy-eips 0.4.2", + "alloy-consensus", + "alloy-eips", "alloy-primitives", - "alloy-serde 0.4.2", + "alloy-serde", "serde", ] @@ -340,15 +296,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcfaa4ffec0af04e3555686b8aacbcdf7d13638133a0672749209069750f78a6" dependencies = [ "alloy-chains", - "alloy-consensus 0.4.2", - "alloy-eips 0.4.2", + "alloy-consensus", + "alloy-eips", "alloy-json-rpc", "alloy-network", - "alloy-network-primitives 0.4.2", + "alloy-network-primitives", "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", - "alloy-rpc-types-eth 0.4.2", + "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", "alloy-transport", @@ -447,10 +403,10 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", "alloy-rpc-types-engine", - "alloy-rpc-types-eth 0.4.2", + "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", - "alloy-serde 0.4.2", + "alloy-serde", "serde", ] @@ -461,7 +417,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d780adaa5d95b07ad92006b2feb68ecfa7e2015f7d5976ceaac4c906c73ebd07" dependencies = [ "alloy-primitives", - "alloy-serde 0.4.2", + "alloy-serde", "serde", ] @@ -471,11 +427,11 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0285c4c09f838ab830048b780d7f4a4f460f309aa1194bb049843309524c64c" dependencies = [ - "alloy-consensus 0.4.2", - "alloy-eips 0.4.2", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.4.2", + "alloy-serde", "derive_more 1.0.0", "jsonwebtoken", "rand", @@ -483,39 +439,18 @@ dependencies = [ "strum", ] -[[package]] -name = "alloy-rpc-types-eth" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83aa984386deda02482660aa31cb8ca1e63d533f1c31a52d7d181ac5ec68e9b8" -dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", - "alloy-network-primitives 0.3.6", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.3.6", - "alloy-sol-types", - "cfg-if", - "derive_more 1.0.0", - "hashbrown 0.14.5", - "itertools 0.13.0", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-eth" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413f4aa3ccf2c3e4234a047c5fa4727916d7daf25a89f9b765df0ba09784fd87" dependencies = [ - "alloy-consensus 0.4.2", - "alloy-eips 0.4.2", - "alloy-network-primitives 0.4.2", + "alloy-consensus", + "alloy-eips", + "alloy-network-primitives", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-sol-types", "derive_more 1.0.0", "itertools 0.13.0", @@ -530,8 +465,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "017cad3e5793c5613588c1f9732bcbad77e820ba7d0feaba3527749f856fdbc5" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 0.4.2", - "alloy-serde 0.4.2", + "alloy-rpc-types-eth", + "alloy-serde", "serde", "serde_json", "thiserror", @@ -544,20 +479,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b230e321c416be7f50530159392b4c41a45596d40d97e185575bcd0b545e521" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 0.4.2", - "alloy-serde 0.4.2", - "serde", -] - -[[package]] -name = "alloy-serde" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "731f75ec5d383107fd745d781619bd9cedf145836c51ecb991623d41278e71fa" -dependencies = [ - "alloy-primitives", + "alloy-rpc-types-eth", + "alloy-serde", "serde", - "serde_json", ] [[package]] @@ -593,7 +517,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "417e19d9844350d11f7426d4920a5df777f8c2abbb7a70d9de6f1faf284db15b" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", @@ -611,7 +535,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fd12ae28e8330766821058ed9a6a06ae4f9b12c776e8a7cfb16e3a954f508e" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", @@ -629,7 +553,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3a02400dea370022151f07581b73a836115c88ce4df350206653493bec024e2" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -649,7 +573,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "494e0a256f3e99f2426f994bcd1be312c02cb8f88260088dacb33a8b8936475f" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", @@ -668,7 +592,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0d91ddee2390b002148128e47902893deba353eb1b818a3afb6c960ebf4e42c" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-network", "alloy-primitives", "alloy-signer", @@ -928,10 +852,10 @@ name = "anvil" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-contract", "alloy-dyn-abi", - "alloy-eips 0.4.2", + "alloy-eips", "alloy-genesis", "alloy-json-abi", "alloy-json-rpc", @@ -942,7 +866,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-client", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -973,6 +897,7 @@ dependencies = [ "hyper 1.4.1", "itertools 0.13.0", "k256", + "op-alloy-consensus", "op-alloy-rpc-types", "parking_lot", "rand", @@ -996,17 +921,18 @@ dependencies = [ name = "anvil-core" version = "0.2.0" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-dyn-abi", - "alloy-eips 0.4.2", + "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-trie", "bytes", "foundry-common", "foundry-evm", + "op-alloy-consensus", "rand", "revm", "serde", @@ -3369,14 +3295,14 @@ name = "forge" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-dyn-abi", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-signer", "alloy-signer-local", "alloy-sol-macro-expander", @@ -3498,15 +3424,15 @@ name = "forge-script" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-dyn-abi", - "alloy-eips 0.4.2", + "alloy-eips", "alloy-json-abi", "alloy-network", "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-signer", "alloy-transport", "async-recursion", @@ -3619,7 +3545,7 @@ name = "foundry-cast" version = "0.2.0" dependencies = [ "alloy-chains", - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -3629,7 +3555,7 @@ dependencies = [ "alloy-provider", "alloy-rlp", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-signer", "alloy-signer-local", "alloy-sol-types", @@ -3676,7 +3602,7 @@ dependencies = [ name = "foundry-cheatcodes" version = "0.2.0" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-dyn-abi", "alloy-genesis", "alloy-json-abi", @@ -3767,7 +3693,7 @@ dependencies = [ name = "foundry-common" version = "0.2.0" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-contract", "alloy-dyn-abi", "alloy-json-abi", @@ -3777,7 +3703,7 @@ dependencies = [ "alloy-pubsub", "alloy-rpc-client", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-sol-types", "alloy-transport", "alloy-transport-http", @@ -3812,11 +3738,11 @@ dependencies = [ name = "foundry-common-fmt" version = "0.2.0" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-dyn-abi", "alloy-primitives", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "chrono", "comfy-table", "foundry-macros", @@ -4039,7 +3965,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-sol-types", "alloy-transport", "auto_impl", @@ -4139,7 +4065,7 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde 0.4.2", + "alloy-serde", "alloy-transport", "eyre", "futures", @@ -4199,7 +4125,7 @@ dependencies = [ name = "foundry-wallets" version = "0.2.0" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus", "alloy-dyn-abi", "alloy-network", "alloy-primitives", @@ -4768,7 +4694,6 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", - "serde", ] [[package]] @@ -6131,15 +6056,15 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "op-alloy-consensus" -version = "0.2.12" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21aad1fbf80d2bcd7406880efc7ba109365f44bbb72896758ddcbfa46bf1592c" +checksum = "c4f7f318f885db6e1455370ca91f74b7faed152c8142f6418f0936d606e582ff" dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.3.6", + "alloy-serde", "derive_more 1.0.0", "serde", "spin", @@ -6147,17 +6072,16 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.2.12" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e281fbfc2198b7c0c16457d6524f83d192662bc9f3df70f24c3038d4521616df" +checksum = "547d29c5ab957ff32e14edddb93652dad748d2ef6cbe4b0fe8615ce06b0a3ddb" dependencies = [ - "alloy-eips 0.3.6", - "alloy-network-primitives 0.3.6", + "alloy-consensus", + "alloy-eips", + "alloy-network-primitives", "alloy-primitives", - "alloy-rpc-types-eth 0.3.6", - "alloy-serde 0.3.6", - "cfg-if", - "hashbrown 0.14.5", + "alloy-rpc-types-eth", + "alloy-serde", "op-alloy-consensus", "serde", "serde_json", @@ -7293,7 +7217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43c44af0bf801f48d25f7baf25cf72aff4c02d610f83b428175228162fef0246" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 0.4.2", + "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", @@ -7739,9 +7663,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] diff --git a/Cargo.toml b/Cargo.toml index 99637920d14a4..9b660adbb1dc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -219,8 +219,9 @@ alloy-chains = "0.1" alloy-rlp = "0.3" alloy-trie = "0.6.0" -## op-alloy for tests in anvil -op-alloy-rpc-types = "0.2.9" +## op-alloy +op-alloy-rpc-types = "0.3.3" +op-alloy-consensus = "0.3.3" ## misc async-trait = "0.1" @@ -278,7 +279,7 @@ soldeer-commands = "=0.4.0" proptest = "1" comfy-table = "7" -# [patch.crates-io] +[patch.crates-io] ## alloy-core # alloy-dyn-abi = { path = "../../alloy-rs/core/crates/dyn-abi" } # alloy-json-abi = { path = "../../alloy-rs/core/crates/json-abi" } diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 0723fdb47f808..922cb6efc2078 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -67,6 +67,7 @@ alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true alloy-trie.workspace = true +op-alloy-consensus.workspace = true # axum related axum.workspace = true @@ -121,8 +122,10 @@ alloy-pubsub.workspace = true foundry-test-utils.workspace = true similar-asserts.workspace = true tokio = { workspace = true, features = ["full"] } + op-alloy-rpc-types.workspace = true + [features] default = ["cli", "jemalloc"] cmd = ["clap", "clap_complete", "ctrlc", "anvil-server/clap"] diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 8c2720c8f06a2..6ea5e53184daa 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -30,6 +30,7 @@ alloy-eips.workspace = true alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-trie.workspace = true +op-alloy-consensus.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 2ed75db28f14d..c3120792028ae 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1,6 +1,6 @@ //! Transaction related types -use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest}; +use crate::eth::transaction::optimism::DepositTransaction; use alloy_consensus::{ transaction::{ eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, @@ -21,6 +21,7 @@ use alloy_rpc_types::{ use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; use foundry_evm::traces::CallTraceNode; +use op_alloy_consensus::TxDeposit; use revm::{ interpreter::InstructionResult, primitives::{OptimismFields, TxEnv}, @@ -59,14 +60,16 @@ pub fn transaction_request_to_typed( // Special case: OP-stack deposit tx if transaction_type == Some(0x7E) || has_optimism_fields(&other) { - return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest { + let mint = other.get_deserialized::("mint")?.map(|m| m.to::()).ok()?; + + return Some(TypedTransactionRequest::Deposit(TxDeposit { from: from.unwrap_or_default(), source_hash: other.get_deserialized::("sourceHash")?.ok()?, - kind: to.unwrap_or_default(), - mint: other.get_deserialized::("mint")?.ok()?, + to: to.unwrap_or_default(), + mint: Some(mint), value: value.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), - is_system_tx: other.get_deserialized::("isSystemTx")?.ok()?, + is_system_transaction: other.get_deserialized::("isSystemTx")?.ok()?, input: input.into_input().unwrap_or_default(), })); } @@ -165,7 +168,7 @@ pub enum TypedTransactionRequest { EIP2930(TxEip2930), EIP1559(TxEip1559), EIP4844(TxEip4844Variant), - Deposit(DepositTransactionRequest), + Deposit(TxDeposit), } /// A wrapper for [TypedTransaction] that allows impersonating accounts. diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 170d67f1d9ac1..6bb4b2abb8a4f 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -1,276 +1,25 @@ -use alloy_consensus::{SignableTransaction, Signed, Transaction}; -use alloy_primitives::{keccak256, Address, Bytes, ChainId, Signature, TxKind, B256, U256}; -use alloy_rlp::{ - length_of_length, Decodable, Encodable, Error as DecodeError, Header as RlpHeader, -}; -use bytes::BufMut; +use alloy_primitives::{Address, Bytes, TxKind, B256, U256}; +use alloy_rlp::{Decodable, Encodable, Error as DecodeError, Header as RlpHeader}; +use op_alloy_consensus::TxDeposit; use serde::{Deserialize, Serialize}; -use std::mem; pub const DEPOSIT_TX_TYPE_ID: u8 = 0x7E; -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct DepositTransactionRequest { - pub source_hash: B256, - pub from: Address, - pub kind: TxKind, - pub mint: U256, - pub value: U256, - pub gas_limit: u64, - pub is_system_tx: bool, - pub input: Bytes, -} - -impl DepositTransactionRequest { - pub fn hash(&self) -> B256 { - let mut encoded = Vec::new(); - encoded.put_u8(DEPOSIT_TX_TYPE_ID); - self.encode(&mut encoded); - - B256::from_slice(alloy_primitives::keccak256(encoded).as_slice()) - } - - /// Encodes only the transaction's fields into the desired buffer, without a RLP header. - pub(crate) fn encode_fields(&self, out: &mut dyn alloy_rlp::BufMut) { - self.source_hash.encode(out); - self.from.encode(out); - self.kind.encode(out); - self.mint.encode(out); - self.value.encode(out); - self.gas_limit.encode(out); - self.is_system_tx.encode(out); - self.input.encode(out); - } - - /// Calculates the length of the RLP-encoded transaction's fields. - pub(crate) fn fields_len(&self) -> usize { - let mut len = 0; - len += self.source_hash.length(); - len += self.from.length(); - len += self.kind.length(); - len += self.mint.length(); - len += self.value.length(); - len += self.gas_limit.length(); - len += self.is_system_tx.length(); - len += self.input.length(); - len - } - - /// Decodes the inner [DepositTransactionRequest] fields from RLP bytes. - /// - /// NOTE: This assumes a RLP header has already been decoded, and _just_ decodes the following - /// RLP fields in the following order: - /// - /// - `source_hash` - /// - `from` - /// - `kind` - /// - `mint` - /// - `value` - /// - `gas_limit` - /// - `is_system_tx` - /// - `input` - pub fn decode_inner(buf: &mut &[u8]) -> Result { - Ok(Self { - source_hash: Decodable::decode(buf)?, - from: Decodable::decode(buf)?, - kind: Decodable::decode(buf)?, - mint: Decodable::decode(buf)?, - value: Decodable::decode(buf)?, - gas_limit: Decodable::decode(buf)?, - is_system_tx: Decodable::decode(buf)?, - input: Decodable::decode(buf)?, - }) - } - - /// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating - /// hash that for eip2718 does not require rlp header - pub(crate) fn encode_with_signature( - &self, - signature: &Signature, - out: &mut dyn alloy_rlp::BufMut, - ) { - let payload_length = self.fields_len() + signature.rlp_vrs_len(); - let header = alloy_rlp::Header { list: true, payload_length }; - header.encode(out); - self.encode_fields(out); - signature.write_rlp_vrs(out); - } - - /// Output the length of the RLP signed transaction encoding, _without_ a RLP string header. - pub fn payload_len_with_signature_without_header(&self, signature: &Signature) -> usize { - let payload_length = self.fields_len() + signature.rlp_vrs_len(); - // 'transaction type byte length' + 'header length' + 'payload length' - 1 + length_of_length(payload_length) + payload_length - } - - /// Output the length of the RLP signed transaction encoding. This encodes with a RLP header. - pub fn payload_len_with_signature(&self, signature: &Signature) -> usize { - let len = self.payload_len_with_signature_without_header(signature); - length_of_length(len) + len - } - - /// Get transaction type - pub(crate) const fn tx_type(&self) -> u8 { - DEPOSIT_TX_TYPE_ID - } - - /// Calculates a heuristic for the in-memory size of the [DepositTransaction] transaction. - pub fn size(&self) -> usize { - mem::size_of::() + // source_hash - mem::size_of::
() + // from - self.kind.size() + // to - mem::size_of::() + // mint - mem::size_of::() + // value - mem::size_of::() + // gas_limit - mem::size_of::() + // is_system_transaction - self.input.len() // input - } - - /// Encodes the legacy transaction in RLP for signing. - pub(crate) fn encode_for_signing(&self, out: &mut dyn alloy_rlp::BufMut) { - out.put_u8(self.tx_type()); - alloy_rlp::Header { list: true, payload_length: self.fields_len() }.encode(out); - self.encode_fields(out); - } - - /// Outputs the length of the signature RLP encoding for the transaction. - pub(crate) fn payload_len_for_signature(&self) -> usize { - let payload_length = self.fields_len(); - // 'transaction type byte length' + 'header length' + 'payload length' - 1 + length_of_length(payload_length) + payload_length - } - - fn encoded_len_with_signature(&self, signature: &Signature) -> usize { - // this counts the tx fields and signature fields - let payload_length = self.fields_len() + signature.rlp_vrs_len(); - - // this counts: - // * tx type byte - // * inner header length - // * inner payload length - 1 + alloy_rlp::Header { list: true, payload_length }.length() + payload_length - } -} - -impl Transaction for DepositTransactionRequest { - fn input(&self) -> &[u8] { - &self.input - } - - /// Get `to`. - fn to(&self) -> TxKind { - self.kind - } - - /// Get `value`. - fn value(&self) -> U256 { - self.value - } - - /// Get `chain_id`. - fn chain_id(&self) -> Option { - None - } - - /// Get `nonce`. - fn nonce(&self) -> u64 { - u64::MAX - } - - /// Get `gas_limit`. - fn gas_limit(&self) -> u64 { - self.gas_limit - } - - /// Get `gas_price`. - fn gas_price(&self) -> Option { - None - } - - fn ty(&self) -> u8 { - 0x7E - } - - // Below fields are not found in a `DepositTransactionRequest` - - fn access_list(&self) -> Option<&alloy_rpc_types::AccessList> { - None - } - - fn authorization_list(&self) -> Option<&[revm::primitives::SignedAuthorization]> { - None - } - - fn blob_versioned_hashes(&self) -> Option<&[B256]> { - None - } - - fn effective_tip_per_gas(&self, _base_fee: u64) -> Option { - None - } - - fn max_fee_per_blob_gas(&self) -> Option { - None - } - - fn max_fee_per_gas(&self) -> u128 { - 0 - } - - fn max_priority_fee_per_gas(&self) -> Option { - None - } - - fn priority_fee_or_price(&self) -> u128 { - 0 - } -} - -impl SignableTransaction for DepositTransactionRequest { - fn set_chain_id(&mut self, _chain_id: ChainId) {} - - fn payload_len_for_signature(&self) -> usize { - self.payload_len_for_signature() - } - - fn into_signed(self, signature: Signature) -> Signed { - let mut buf = Vec::with_capacity(self.encoded_len_with_signature(&signature)); - self.encode_with_signature(&signature, &mut buf); - let hash = keccak256(&buf); - - // Drop any v chain id value to ensure the signature format is correct at the time of - // combination for an EIP-4844 transaction. V should indicate the y-parity of the - // signature. - Signed::new_unchecked(self, signature.with_parity_bool(), hash) - } - - fn encode_for_signing(&self, out: &mut dyn alloy_rlp::BufMut) { - self.encode_for_signing(out); - } -} - -impl From for DepositTransactionRequest { +impl From for TxDeposit { fn from(tx: DepositTransaction) -> Self { Self { from: tx.from, source_hash: tx.source_hash, - kind: tx.kind, - mint: tx.mint, + to: tx.kind, + mint: Some(tx.mint.to::()), value: tx.value, gas_limit: tx.gas_limit, - is_system_tx: tx.is_system_tx, + is_system_transaction: tx.is_system_tx, input: tx.input, } } } -impl Encodable for DepositTransactionRequest { - fn encode(&self, out: &mut dyn bytes::BufMut) { - RlpHeader { list: true, payload_length: self.fields_len() }.encode(out); - self.encode_fields(out); - } -} - /// An op-stack deposit transaction. /// See #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -443,23 +192,4 @@ mod tests { assert_eq!(tx, decoded_tx); } - - #[test] - fn test_tx_request_hash_equals_tx_hash() { - let tx = DepositTransaction { - nonce: 0, - source_hash: B256::default(), - from: Address::default(), - kind: TxKind::Call(Address::default()), - mint: U256::from(100), - value: U256::from(100), - gas_limit: 50000, - is_system_tx: false, - input: Bytes::default(), - }; - - let tx_request = DepositTransactionRequest::from(tx.clone()); - - assert_eq!(tx.hash(), tx_request.hash()); - } } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 78b52d49496ab..a85862664684d 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2903,7 +2903,7 @@ fn determine_base_gas_by_kind(request: &WithOtherFields) -> TxKind::Create => MIN_CREATE_GAS, }, TypedTransactionRequest::EIP4844(_) => MIN_TRANSACTION_GAS, - TypedTransactionRequest::Deposit(req) => match req.kind { + TypedTransactionRequest::Deposit(req) => match req.to { TxKind::Call(_) => MIN_TRANSACTION_GAS, TxKind::Create => MIN_CREATE_GAS, }, diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index d322e47d22654..5f99ef9ca17d8 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -2,13 +2,13 @@ use crate::eth::error::BlockchainError; use alloy_consensus::SignableTransaction; use alloy_dyn_abi::TypedData; use alloy_network::TxSignerSync; -use alloy_primitives::{map::AddressHashMap, Address, Signature, B256}; +use alloy_primitives::{map::AddressHashMap, Address, Signature, B256, U256}; use alloy_signer::Signer as AlloySigner; use alloy_signer_local::PrivateKeySigner; use anvil_core::eth::transaction::{ - optimism::{DepositTransaction, DepositTransactionRequest}, - TypedTransaction, TypedTransactionRequest, + optimism::DepositTransaction, TypedTransaction, TypedTransactionRequest, }; +use op_alloy_consensus::TxDeposit; /// A transaction signer #[async_trait::async_trait] @@ -105,7 +105,9 @@ impl Signer for DevSigner { TypedTransactionRequest::EIP2930(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), TypedTransactionRequest::EIP1559(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), TypedTransactionRequest::EIP4844(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), - TypedTransactionRequest::Deposit(mut tx) => Ok(signer.sign_transaction_sync(&mut tx)?), + TypedTransactionRequest::Deposit(_) => { + unreachable!("op deposit txs should not be signed") + } } } } @@ -131,26 +133,26 @@ pub fn build_typed_transaction( TypedTransaction::EIP4844(tx.into_signed(signature)) } TypedTransactionRequest::Deposit(tx) => { - let DepositTransactionRequest { + let TxDeposit { from, gas_limit, - kind, + to, value, input, source_hash, mint, - is_system_tx, + is_system_transaction, .. } = tx; TypedTransaction::Deposit(DepositTransaction { from, gas_limit, - kind, + kind: to, value, input, source_hash, - mint, - is_system_tx, + mint: mint.map_or(U256::ZERO, U256::from), + is_system_tx: is_system_transaction, nonce: 0, }) } From 1465e39f853a7c7a151609cb3abe5dc19c52a94b Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:34:31 +0200 Subject: [PATCH 1540/1963] fix: redact RPC URLs in traces if URL is passed in directly (#9077) redact RPC urls if string is a URL, not an alias --- crates/evm/traces/src/decoder/mod.rs | 294 ++++++++++++++++++++++++++- 1 file changed, 293 insertions(+), 1 deletion(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 25d9f4f2b8948..de3a0c02f201a 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -516,6 +516,24 @@ impl CallTraceDecoder { Some(decoded.iter().map(format_token).collect()) } } + "createFork" | + "createSelectFork" | + "rpc" => { + let mut decoded = func.abi_decode_input(&data[SELECTOR_LEN..], false).ok()?; + + // Redact RPC URL except if referenced by an alias + if !decoded.is_empty() && func.inputs[0].ty == "string" { + let url_or_alias = decoded[0].as_str().unwrap_or_default(); + + if url_or_alias.starts_with("http") || url_or_alias.starts_with("ws") { + decoded[0] = DynSolValue::String("".to_string()); + } + } else { + return None; + } + + Some(decoded.iter().map(format_token).collect()) + } _ => None, } } @@ -558,6 +576,7 @@ impl CallTraceDecoder { "promptSecret" | "promptSecretUint" => Some(""), "parseJson" if self.verbosity < 5 => Some(""), "readFile" if self.verbosity < 5 => Some(""), + "rpcUrl" | "rpcUrls" | "rpcUrlStructs" => Some(""), _ => None, } .map(Into::into) @@ -670,7 +689,7 @@ mod tests { use alloy_primitives::hex; #[test] - fn test_should_redact_pk() { + fn test_should_redact() { let decoder = CallTraceDecoder::new(); // [function_signature, data, expected] @@ -726,6 +745,275 @@ mod tests { .to_string(), ]), ), + ( + // cast calldata "createFork(string)" "https://eth-mainnet.g.alchemy.com/v2/api_key" + "createFork(string)", + hex!( + " + 31ba3498 + 0000000000000000000000000000000000000000000000000000000000000020 + 000000000000000000000000000000000000000000000000000000000000002c + 68747470733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f + 6d2f76322f6170695f6b65790000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"\"".to_string()]), + ), + ( + // cast calldata "createFork(string)" "wss://eth-mainnet.g.alchemy.com/v2/api_key" + "createFork(string)", + hex!( + " + 31ba3498 + 0000000000000000000000000000000000000000000000000000000000000020 + 000000000000000000000000000000000000000000000000000000000000002a + 7773733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f6d2f + 76322f6170695f6b657900000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"\"".to_string()]), + ), + ( + // cast calldata "createFork(string)" "mainnet" + "createFork(string)", + hex!( + " + 31ba3498 + 0000000000000000000000000000000000000000000000000000000000000020 + 0000000000000000000000000000000000000000000000000000000000000007 + 6d61696e6e657400000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"mainnet\"".to_string()]), + ), + ( + // cast calldata "createFork(string,uint256)" "https://eth-mainnet.g.alchemy.com/v2/api_key" 1 + "createFork(string,uint256)", + hex!( + " + 6ba3ba2b + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000001 + 000000000000000000000000000000000000000000000000000000000000002c + 68747470733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f + 6d2f76322f6170695f6b65790000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"\"".to_string(), "1".to_string()]), + ), + ( + // cast calldata "createFork(string,uint256)" "mainnet" 1 + "createFork(string,uint256)", + hex!( + " + 6ba3ba2b + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000001 + 0000000000000000000000000000000000000000000000000000000000000007 + 6d61696e6e657400000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"mainnet\"".to_string(), "1".to_string()]), + ), + ( + // cast calldata "createFork(string,bytes32)" "https://eth-mainnet.g.alchemy.com/v2/api_key" 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + "createFork(string,bytes32)", + hex!( + " + 7ca29682 + 0000000000000000000000000000000000000000000000000000000000000040 + ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 000000000000000000000000000000000000000000000000000000000000002c + 68747470733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f + 6d2f76322f6170695f6b65790000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"\"".to_string(), + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + .to_string(), + ]), + ), + ( + // cast calldata "createFork(string,bytes32)" "mainnet" + // 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + "createFork(string,bytes32)", + hex!( + " + 7ca29682 + 0000000000000000000000000000000000000000000000000000000000000040 + ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 0000000000000000000000000000000000000000000000000000000000000007 + 6d61696e6e657400000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"mainnet\"".to_string(), + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + .to_string(), + ]), + ), + ( + // cast calldata "createSelectFork(string)" "https://eth-mainnet.g.alchemy.com/v2/api_key" + "createSelectFork(string)", + hex!( + " + 98680034 + 0000000000000000000000000000000000000000000000000000000000000020 + 000000000000000000000000000000000000000000000000000000000000002c + 68747470733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f + 6d2f76322f6170695f6b65790000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"\"".to_string()]), + ), + ( + // cast calldata "createSelectFork(string)" "mainnet" + "createSelectFork(string)", + hex!( + " + 98680034 + 0000000000000000000000000000000000000000000000000000000000000020 + 0000000000000000000000000000000000000000000000000000000000000007 + 6d61696e6e657400000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"mainnet\"".to_string()]), + ), + ( + // cast calldata "createSelectFork(string,uint256)" "https://eth-mainnet.g.alchemy.com/v2/api_key" 1 + "createSelectFork(string,uint256)", + hex!( + " + 71ee464d + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000001 + 000000000000000000000000000000000000000000000000000000000000002c + 68747470733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f + 6d2f76322f6170695f6b65790000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"\"".to_string(), "1".to_string()]), + ), + ( + // cast calldata "createSelectFork(string,uint256)" "mainnet" 1 + "createSelectFork(string,uint256)", + hex!( + " + 71ee464d + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000001 + 0000000000000000000000000000000000000000000000000000000000000007 + 6d61696e6e657400000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec!["\"mainnet\"".to_string(), "1".to_string()]), + ), + ( + // cast calldata "createSelectFork(string,bytes32)" "https://eth-mainnet.g.alchemy.com/v2/api_key" 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + "createSelectFork(string,bytes32)", + hex!( + " + 84d52b7a + 0000000000000000000000000000000000000000000000000000000000000040 + ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 000000000000000000000000000000000000000000000000000000000000002c + 68747470733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f + 6d2f76322f6170695f6b65790000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"\"".to_string(), + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + .to_string(), + ]), + ), + ( + // cast calldata "createSelectFork(string,bytes32)" "mainnet" + // 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + "createSelectFork(string,bytes32)", + hex!( + " + 84d52b7a + 0000000000000000000000000000000000000000000000000000000000000040 + ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + 0000000000000000000000000000000000000000000000000000000000000007 + 6d61696e6e657400000000000000000000000000000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"mainnet\"".to_string(), + "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + .to_string(), + ]), + ), + ( + // cast calldata "rpc(string,string,string)" "https://eth-mainnet.g.alchemy.com/v2/api_key" "eth_getBalance" "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x0\"]" + "rpc(string,string,string)", + hex!( + " + 0199a220 + 0000000000000000000000000000000000000000000000000000000000000060 + 00000000000000000000000000000000000000000000000000000000000000c0 + 0000000000000000000000000000000000000000000000000000000000000100 + 000000000000000000000000000000000000000000000000000000000000002c + 68747470733a2f2f6574682d6d61696e6e65742e672e616c6368656d792e636f + 6d2f76322f6170695f6b65790000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000000e + 6574685f67657442616c616e6365000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000034 + 5b22307835353165373738343737386566386530343865343935646634396632 + 363134663834613466316463222c22307830225d000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"\"".to_string(), + "\"eth_getBalance\"".to_string(), + "\"[\\\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\\\",\\\"0x0\\\"]\"" + .to_string(), + ]), + ), + ( + // cast calldata "rpc(string,string,string)" "mainnet" "eth_getBalance" + // "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x0\"]" + "rpc(string,string,string)", + hex!( + " + 0199a220 + 0000000000000000000000000000000000000000000000000000000000000060 + 00000000000000000000000000000000000000000000000000000000000000a0 + 00000000000000000000000000000000000000000000000000000000000000e0 + 0000000000000000000000000000000000000000000000000000000000000007 + 6d61696e6e657400000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000000e + 6574685f67657442616c616e6365000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000034 + 5b22307835353165373738343737386566386530343865343935646634396632 + 363134663834613466316463222c22307830225d000000000000000000000000 + " + ) + .to_vec(), + Some(vec![ + "\"mainnet\"".to_string(), + "\"eth_getBalance\"".to_string(), + "\"[\\\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\\\",\\\"0x0\\\"]\"" + .to_string(), + ]), + ), ]; // [function_signature, expected] @@ -733,6 +1021,10 @@ mod tests { // Should redact private key on output in all cases: ("createWallet(string)", Some("".to_string())), ("deriveKey(string,uint32)", Some("".to_string())), + // Should redact RPC URL if defined, except if referenced by an alias: + ("rpcUrl(string)", Some("".to_string())), + ("rpcUrls()", Some("".to_string())), + ("rpcUrlStructs()", Some("".to_string())), ]; for (function_signature, data, expected) in cheatcode_input_test_cases { From 5101a32b50a71741741730d351834cb190927b51 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:50:49 +0200 Subject: [PATCH 1541/1963] test: relax pragmas (#9078) * test: relax pragmas * test: update rust tests too --- crates/forge/tests/cli/script.rs | 39 ++++++++++++------- crates/forge/tests/cli/test_cmd.rs | 3 -- crates/linking/src/lib.rs | 21 ++++++---- crates/test-utils/src/util.rs | 5 ++- testdata/default/cheats/Addr.t.sol | 2 +- .../default/cheats/ArbitraryStorage.t.sol | 2 +- testdata/default/cheats/Assert.t.sol | 2 +- testdata/default/cheats/Assume.t.sol | 2 +- testdata/default/cheats/Bank.t.sol | 2 +- testdata/default/cheats/Base64.t.sol | 2 +- testdata/default/cheats/Broadcast.t.sol | 2 +- .../cheats/BroadcastRawTransaction.t.sol | 2 +- testdata/default/cheats/ChainId.t.sol | 2 +- testdata/default/cheats/CloneAccount.t.sol | 2 +- testdata/default/cheats/Cool.t.sol | 2 +- testdata/default/cheats/CopyStorage.t.sol | 2 +- testdata/default/cheats/Deal.t.sol | 2 +- testdata/default/cheats/DeployCode.t.sol | 2 +- testdata/default/cheats/Derive.t.sol | 2 +- testdata/default/cheats/EnsNamehash.t.sol | 2 +- testdata/default/cheats/Env.t.sol | 2 +- testdata/default/cheats/Etch.t.sol | 2 +- testdata/default/cheats/ExpectCall.t.sol | 2 +- testdata/default/cheats/ExpectEmit.t.sol | 2 +- testdata/default/cheats/ExpectRevert.t.sol | 2 +- testdata/default/cheats/Fee.t.sol | 2 +- testdata/default/cheats/Ffi.t.sol | 2 +- testdata/default/cheats/Fork.t.sol | 2 +- testdata/default/cheats/Fork2.t.sol | 2 +- testdata/default/cheats/Fs.t.sol | 2 +- testdata/default/cheats/GasMetering.t.sol | 2 +- testdata/default/cheats/GasSnapshots.t.sol | 2 +- testdata/default/cheats/GetArtifactPath.t.sol | 2 +- .../default/cheats/GetBlockTimestamp.t.sol | 2 +- testdata/default/cheats/GetCode.t.sol | 2 +- testdata/default/cheats/GetDeployedCode.t.sol | 2 +- .../default/cheats/GetFoundryVersion.t.sol | 2 +- testdata/default/cheats/GetLabel.t.sol | 2 +- testdata/default/cheats/GetNonce.t.sol | 2 +- testdata/default/cheats/Json.t.sol | 2 +- testdata/default/cheats/Label.t.sol | 2 +- testdata/default/cheats/LastCallGas.t.sol | 2 +- testdata/default/cheats/Load.t.sol | 2 +- testdata/default/cheats/Mapping.t.sol | 2 +- testdata/default/cheats/MemSafety.t.sol | 2 +- testdata/default/cheats/MockCall.t.sol | 2 +- testdata/default/cheats/MockCalls.t.sol | 2 +- testdata/default/cheats/MockFunction.t.sol | 2 +- testdata/default/cheats/Nonce.t.sol | 2 +- testdata/default/cheats/Parse.t.sol | 2 +- testdata/default/cheats/Prank.t.sol | 2 +- testdata/default/cheats/Prevrandao.t.sol | 2 +- testdata/default/cheats/ProjectRoot.t.sol | 2 +- testdata/default/cheats/Prompt.t.sol | 2 +- testdata/default/cheats/RandomAddress.t.sol | 2 +- testdata/default/cheats/RandomBytes.t.sol | 2 +- .../default/cheats/RandomCheatcodes.t.sol | 2 +- testdata/default/cheats/RandomUint.t.sol | 2 +- testdata/default/cheats/ReadCallers.t.sol | 2 +- testdata/default/cheats/Record.t.sol | 2 +- .../cheats/RecordAccountAccesses.t.sol | 2 +- testdata/default/cheats/RecordLogs.t.sol | 2 +- testdata/default/cheats/Remember.t.sol | 2 +- testdata/default/cheats/ResetNonce.t.sol | 2 +- testdata/default/cheats/Roll.t.sol | 2 +- testdata/default/cheats/RpcUrls.t.sol | 2 +- testdata/default/cheats/SetBlockhash.t.sol | 2 +- testdata/default/cheats/SetNonce.t.sol | 2 +- testdata/default/cheats/SetNonceUnsafe.t.sol | 2 +- testdata/default/cheats/Setup.t.sol | 2 +- testdata/default/cheats/Sign.t.sol | 2 +- testdata/default/cheats/SignP256.t.sol | 2 +- testdata/default/cheats/Skip.t.sol | 2 +- testdata/default/cheats/Sleep.t.sol | 2 +- testdata/default/cheats/StateSnapshots.t.sol | 2 +- testdata/default/cheats/Store.t.sol | 2 +- testdata/default/cheats/StringUtils.t.sol | 2 +- testdata/default/cheats/ToString.t.sol | 2 +- testdata/default/cheats/Toml.t.sol | 2 +- testdata/default/cheats/Travel.t.sol | 2 +- testdata/default/cheats/UnixTime.t.sol | 2 +- testdata/default/cheats/Wallet.t.sol | 2 +- testdata/default/cheats/Warp.t.sol | 2 +- testdata/default/cheats/dumpState.t.sol | 2 +- testdata/default/cheats/getBlockNumber.t.sol | 2 +- testdata/default/cheats/loadAllocs.t.sol | 2 +- testdata/default/core/Abstract.t.sol | 2 +- .../default/core/BadSigAfterInvariant.t.sol | 2 +- .../default/core/ContractEnvironment.t.sol | 2 +- testdata/default/core/DSStyle.t.sol | 2 +- testdata/default/core/FailingSetup.t.sol | 2 +- .../core/FailingTestAfterFailedSetup.t.sol | 2 +- testdata/default/core/LegacyAssertions.t.sol | 2 +- .../default/core/MultipleAfterInvariant.t.sol | 2 +- testdata/default/core/MultipleSetup.t.sol | 2 +- testdata/default/core/PaymentFailure.t.sol | 2 +- testdata/default/core/Reverting.t.sol | 2 +- testdata/default/core/SetupConsistency.t.sol | 2 +- testdata/default/fork/ForkSame_1.t.sol | 2 +- testdata/default/fork/ForkSame_2.t.sol | 2 +- testdata/default/fork/Transact.t.sol | 2 +- testdata/default/fs/Default.t.sol | 2 +- testdata/default/fs/Disabled.t.sol | 2 +- testdata/default/fuzz/Fuzz.t.sol | 2 +- testdata/default/fuzz/FuzzCollection.t.sol | 2 +- .../default/fuzz/FuzzFailurePersist.t.sol | 2 +- testdata/default/fuzz/FuzzInt.t.sol | 2 +- testdata/default/fuzz/FuzzPositive.t.sol | 2 +- testdata/default/fuzz/FuzzUint.t.sol | 2 +- .../common/InvariantCalldataDictionary.t.sol | 2 +- .../common/InvariantInnerContract.t.sol | 2 +- .../common/InvariantPreserveState.t.sol | 2 +- .../common/InvariantReentrancy.t.sol | 2 +- .../invariant/common/InvariantTest1.t.sol | 2 +- .../invariant/target/ExcludeContracts.t.sol | 2 +- .../invariant/target/ExcludeSelectors.t.sol | 2 +- .../invariant/target/ExcludeSenders.t.sol | 2 +- .../target/FuzzedTargetContracts.t.sol | 2 +- .../invariant/target/TargetContracts.t.sol | 2 +- .../invariant/target/TargetInterfaces.t.sol | 2 +- .../invariant/target/TargetSelectors.t.sol | 2 +- .../fuzz/invariant/target/TargetSenders.t.sol | 2 +- .../targetAbi/ExcludeArtifacts.t.sol | 2 +- .../targetAbi/TargetArtifactSelectors.t.sol | 2 +- .../targetAbi/TargetArtifactSelectors2.t.sol | 2 +- .../invariant/targetAbi/TargetArtifacts.t.sol | 2 +- testdata/default/inline/FuzzInlineConf.t.sol | 2 +- .../default/inline/InvariantInlineConf.t.sol | 2 +- testdata/default/linking/cycle/Cycle.t.sol | 2 +- .../default/linking/duplicate/Duplicate.t.sol | 2 +- testdata/default/linking/nested/Nested.t.sol | 2 +- testdata/default/linking/simple/Simple.t.sol | 2 +- testdata/default/logs/DebugLogs.t.sol | 2 +- testdata/default/logs/HardhatLogs.t.sol | 2 +- testdata/default/logs/console.sol | 2 +- testdata/default/repros/Issue1543.t.sol | 2 +- testdata/default/repros/Issue2623.t.sol | 2 +- testdata/default/repros/Issue2629.t.sol | 2 +- testdata/default/repros/Issue2723.t.sol | 2 +- testdata/default/repros/Issue2898.t.sol | 2 +- testdata/default/repros/Issue2956.t.sol | 2 +- testdata/default/repros/Issue2984.t.sol | 2 +- testdata/default/repros/Issue3055.t.sol | 2 +- testdata/default/repros/Issue3077.t.sol | 2 +- testdata/default/repros/Issue3110.t.sol | 2 +- testdata/default/repros/Issue3119.t.sol | 2 +- testdata/default/repros/Issue3189.t.sol | 2 +- testdata/default/repros/Issue3190.t.sol | 2 +- testdata/default/repros/Issue3192.t.sol | 2 +- testdata/default/repros/Issue3220.t.sol | 2 +- testdata/default/repros/Issue3221.t.sol | 2 +- testdata/default/repros/Issue3223.t.sol | 2 +- testdata/default/repros/Issue3347.t.sol | 2 +- testdata/default/repros/Issue3596.t.sol | 2 +- testdata/default/repros/Issue3653.t.sol | 2 +- testdata/default/repros/Issue3661.t.sol | 2 +- testdata/default/repros/Issue3674.t.sol | 2 +- testdata/default/repros/Issue3685.t.sol | 2 +- testdata/default/repros/Issue3703.t.sol | 2 +- testdata/default/repros/Issue3708.t.sol | 2 +- testdata/default/repros/Issue3753.t.sol | 2 +- testdata/default/repros/Issue3792.t.sol | 2 +- testdata/default/repros/Issue4402.t.sol | 2 +- testdata/default/repros/Issue4586.t.sol | 2 +- testdata/default/repros/Issue4630.t.sol | 2 +- testdata/default/repros/Issue4640.t.sol | 2 +- testdata/default/repros/Issue5038.t.sol | 2 +- testdata/default/repros/Issue5739.t.sol | 2 +- testdata/default/repros/Issue5808.t.sol | 2 +- testdata/default/repros/Issue5929.t.sol | 2 +- testdata/default/repros/Issue5935.t.sol | 2 +- testdata/default/repros/Issue5948.t.sol | 2 +- testdata/default/repros/Issue6006.t.sol | 2 +- testdata/default/repros/Issue6032.t.sol | 2 +- testdata/default/repros/Issue6070.t.sol | 2 +- testdata/default/repros/Issue6115.t.sol | 2 +- testdata/default/repros/Issue6170.t.sol | 2 +- testdata/default/repros/Issue6180.t.sol | 2 +- testdata/default/repros/Issue6293.t.sol | 2 +- testdata/default/repros/Issue6355.t.sol | 2 +- testdata/default/repros/Issue6437.t.sol | 2 +- testdata/default/repros/Issue6501.t.sol | 2 +- testdata/default/repros/Issue6538.t.sol | 2 +- testdata/default/repros/Issue6554.t.sol | 2 +- testdata/default/repros/Issue6616.t.sol | 2 +- testdata/default/repros/Issue6634.t.sol | 2 +- testdata/default/repros/Issue6643.t.sol | 2 +- testdata/default/repros/Issue6759.t.sol | 2 +- testdata/default/repros/Issue6966.t.sol | 2 +- testdata/default/repros/Issue7457.t.sol | 2 +- testdata/default/repros/Issue7481.t.sol | 2 +- testdata/default/repros/Issue8004.t.sol | 2 +- testdata/default/repros/Issue8006.t.sol | 2 +- testdata/default/repros/Issue8168.t.sol | 2 +- testdata/default/repros/Issue8277.t.sol | 2 +- testdata/default/repros/Issue8287.t.sol | 2 +- testdata/default/repros/Issue8383.t.sol | 2 +- testdata/default/repros/Issue8971.t.sol | 2 +- testdata/default/script/deploy.sol | 2 +- testdata/default/spec/ShanghaiCompat.t.sol | 2 +- .../default/trace/ConflictingSignatures.t.sol | 2 +- testdata/default/trace/Trace.t.sol | 2 +- .../fixtures/GetCode/UnlinkedContract.sol | 2 +- testdata/fixtures/GetCode/WorkingContract.sol | 2 +- testdata/multi-version/cheats/GetCode.t.sol | 2 +- testdata/multi-version/cheats/GetCode17.t.sol | 2 +- 206 files changed, 244 insertions(+), 228 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 826d66282dd77..e8f1466b911ef 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3,7 +3,11 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; -use foundry_test_utils::{rpc, ScriptOutcome, ScriptTester}; +use foundry_test_utils::{ + rpc, + util::{OTHER_SOLC_VERSION, SOLC_VERSION}, + ScriptOutcome, ScriptTester, +}; use regex::Regex; use serde_json::Value; use std::{env, path::PathBuf, str::FromStr}; @@ -1520,36 +1524,45 @@ forgetest_async!(can_detect_contract_when_multiple_versions, |prj, cmd| { prj.add_script( "A.sol", - r#"pragma solidity 0.8.20; + &format!( + r#" +pragma solidity {SOLC_VERSION}; import "./B.sol"; -contract ScriptA {} -"#, +contract ScriptA {{}} +"# + ), ) .unwrap(); prj.add_script( "B.sol", - r#"pragma solidity >=0.8.5 <=0.8.20; + &format!( + r#" +pragma solidity >={OTHER_SOLC_VERSION} <={SOLC_VERSION}; import 'forge-std/Script.sol'; -contract ScriptB is Script { - function run() external { +contract ScriptB is Script {{ + function run() external {{ vm.broadcast(); address(0).call(""); - } -} -"#, + }} +}} +"# + ), ) .unwrap(); prj.add_script( "C.sol", - r#"pragma solidity 0.8.5; + &format!( + r#" +pragma solidity {OTHER_SOLC_VERSION}; import "./B.sol"; -contract ScriptC {} -"#, +contract ScriptC {{}} +"# + ), ) .unwrap(); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 30c7f9deb4e67..ea3ce1911ba97 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -275,8 +275,6 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) }); const SIMPLE_CONTRACT: &str = r#" -pragma solidity 0.8.18; - import "./test.sol"; import "./console.sol"; @@ -650,7 +648,6 @@ forgetest_init!(can_test_transient_storage_with_isolation, |prj, cmd| { prj.add_test( "Contract.t.sol", r#" -pragma solidity ^0.8.24; import {Test} from "forge-std/Test.sol"; contract TransientTester { diff --git a/crates/linking/src/lib.rs b/crates/linking/src/lib.rs index d0959ddb7d507..e44ee77489f2f 100644 --- a/crates/linking/src/lib.rs +++ b/crates/linking/src/lib.rs @@ -284,7 +284,11 @@ impl<'a> Linker<'a> { mod tests { use super::*; use alloy_primitives::{fixed_bytes, map::HashMap}; - use foundry_compilers::{Project, ProjectCompileOutput, ProjectPathsConfig}; + use foundry_compilers::{ + multi::MultiCompiler, + solc::{Solc, SolcCompiler}, + Project, ProjectCompileOutput, ProjectPathsConfig, + }; struct LinkerTest { project: Project, @@ -303,11 +307,12 @@ mod tests { .build() .unwrap(); + let solc = Solc::find_or_install(&Version::new(0, 8, 18)).unwrap(); let project = Project::builder() .paths(paths) .ephemeral() .no_artifacts() - .build(Default::default()) + .build(MultiCompiler { solc: Some(SolcCompiler::Specific(solc)), vyper: None }) .unwrap(); let mut output = project.compile().unwrap(); @@ -393,7 +398,7 @@ mod tests { for (dep_identifier, address) in assertions { let (file, name) = dep_identifier.split_once(':').unwrap(); if let Some(lib_address) = - libraries.libs.get(&PathBuf::from(file)).and_then(|libs| libs.get(name)) + libraries.libs.get(Path::new(file)).and_then(|libs| libs.get(name)) { assert_eq!( *lib_address, @@ -637,7 +642,7 @@ mod tests { "default/linking/nested/Nested.t.sol:NestedLib".to_string(), vec![( "default/linking/nested/Nested.t.sol:Lib".to_string(), - Address::from_str("0xCD3864eB2D88521a5477691EE589D9994b796834").unwrap(), + Address::from_str("0xddb1Cd2497000DAeA687CEa3dc34Af44084BEa74").unwrap(), )], ) .assert_dependencies( @@ -647,12 +652,12 @@ mod tests { // have the same address and nonce. ( "default/linking/nested/Nested.t.sol:Lib".to_string(), - Address::from_str("0xCD3864eB2D88521a5477691EE589D9994b796834") + Address::from_str("0xddb1Cd2497000DAeA687CEa3dc34Af44084BEa74") .unwrap(), ), ( "default/linking/nested/Nested.t.sol:NestedLib".to_string(), - Address::from_str("0x023d9a6bfA39c45997572dC4F87b3E2713b6EBa4") + Address::from_str("0xfebE2F30641170642f317Ff6F644Cee60E7Ac369") .unwrap(), ), ], @@ -662,12 +667,12 @@ mod tests { vec![ ( "default/linking/nested/Nested.t.sol:Lib".to_string(), - Address::from_str("0xCD3864eB2D88521a5477691EE589D9994b796834") + Address::from_str("0xddb1Cd2497000DAeA687CEa3dc34Af44084BEa74") .unwrap(), ), ( "default/linking/nested/Nested.t.sol:NestedLib".to_string(), - Address::from_str("0x023d9a6bfA39c45997572dC4F87b3E2713b6EBa4") + Address::from_str("0xfebE2F30641170642f317Ff6F644Cee60E7Ac369") .unwrap(), ), ], diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 70db0a4070ad0..11757978a3c52 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -49,8 +49,9 @@ static NEXT_ID: AtomicUsize = AtomicUsize::new(0); /// The default Solc version used when compiling tests. pub const SOLC_VERSION: &str = "0.8.27"; -/// Another Solc version used when compiling tests. Necessary to avoid downloading multiple -/// versions. +/// Another Solc version used when compiling tests. +/// +/// Necessary to avoid downloading multiple versions. pub const OTHER_SOLC_VERSION: &str = "0.8.26"; /// External test builder diff --git a/testdata/default/cheats/Addr.t.sol b/testdata/default/cheats/Addr.t.sol index 432c52e698c9b..3f791583dbb9e 100644 --- a/testdata/default/cheats/Addr.t.sol +++ b/testdata/default/cheats/Addr.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ArbitraryStorage.t.sol b/testdata/default/cheats/ArbitraryStorage.t.sol index f763ab7af5a5a..afac010870159 100644 --- a/testdata/default/cheats/ArbitraryStorage.t.sol +++ b/testdata/default/cheats/ArbitraryStorage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Assert.t.sol b/testdata/default/cheats/Assert.t.sol index 971bb5e27cf7d..d6765967c5faa 100644 --- a/testdata/default/cheats/Assert.t.sol +++ b/testdata/default/cheats/Assert.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Assume.t.sol b/testdata/default/cheats/Assume.t.sol index de11d6644fe9d..14ed341c9970e 100644 --- a/testdata/default/cheats/Assume.t.sol +++ b/testdata/default/cheats/Assume.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Bank.t.sol b/testdata/default/cheats/Bank.t.sol index a02fe1667e653..166fbb16ac8ea 100644 --- a/testdata/default/cheats/Bank.t.sol +++ b/testdata/default/cheats/Bank.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Base64.t.sol b/testdata/default/cheats/Base64.t.sol index 0d2249395aadf..fad7bbf4f297c 100644 --- a/testdata/default/cheats/Base64.t.sol +++ b/testdata/default/cheats/Base64.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Broadcast.t.sol b/testdata/default/cheats/Broadcast.t.sol index 6a099dc6ed54b..bca8cc2eee8f8 100644 --- a/testdata/default/cheats/Broadcast.t.sol +++ b/testdata/default/cheats/Broadcast.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/BroadcastRawTransaction.t.sol b/testdata/default/cheats/BroadcastRawTransaction.t.sol index 43e4ff6323e89..5bd400a9f71e3 100644 --- a/testdata/default/cheats/BroadcastRawTransaction.t.sol +++ b/testdata/default/cheats/BroadcastRawTransaction.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ChainId.t.sol b/testdata/default/cheats/ChainId.t.sol index aa8fa0a131ada..31a6e5cdf37eb 100644 --- a/testdata/default/cheats/ChainId.t.sol +++ b/testdata/default/cheats/ChainId.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/CloneAccount.t.sol b/testdata/default/cheats/CloneAccount.t.sol index 5342a92d39f28..d584c747cb9b9 100644 --- a/testdata/default/cheats/CloneAccount.t.sol +++ b/testdata/default/cheats/CloneAccount.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Cool.t.sol b/testdata/default/cheats/Cool.t.sol index 82212f1b17fe5..d0750bebfa18e 100644 --- a/testdata/default/cheats/Cool.t.sol +++ b/testdata/default/cheats/Cool.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "lib/ds-test/src/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/CopyStorage.t.sol b/testdata/default/cheats/CopyStorage.t.sol index 3ca5d8dab88b9..e9195949e49c9 100644 --- a/testdata/default/cheats/CopyStorage.t.sol +++ b/testdata/default/cheats/CopyStorage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Deal.t.sol b/testdata/default/cheats/Deal.t.sol index ac47764356869..a46d9e7140e3e 100644 --- a/testdata/default/cheats/Deal.t.sol +++ b/testdata/default/cheats/Deal.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/DeployCode.t.sol b/testdata/default/cheats/DeployCode.t.sol index 330e826511da7..edf4c78e6dab4 100644 --- a/testdata/default/cheats/DeployCode.t.sol +++ b/testdata/default/cheats/DeployCode.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Derive.t.sol b/testdata/default/cheats/Derive.t.sol index fb14433334715..c27456c6ec487 100644 --- a/testdata/default/cheats/Derive.t.sol +++ b/testdata/default/cheats/Derive.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/EnsNamehash.t.sol b/testdata/default/cheats/EnsNamehash.t.sol index 2d66beea4167e..965d505006060 100644 --- a/testdata/default/cheats/EnsNamehash.t.sol +++ b/testdata/default/cheats/EnsNamehash.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Env.t.sol b/testdata/default/cheats/Env.t.sol index e325df2fa4429..7edb35dff13ff 100644 --- a/testdata/default/cheats/Env.t.sol +++ b/testdata/default/cheats/Env.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Etch.t.sol b/testdata/default/cheats/Etch.t.sol index fbd0e62b90bdb..33eaaf44ef87c 100644 --- a/testdata/default/cheats/Etch.t.sol +++ b/testdata/default/cheats/Etch.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ExpectCall.t.sol b/testdata/default/cheats/ExpectCall.t.sol index 7d757101ad3b6..f2624fd2e237f 100644 --- a/testdata/default/cheats/ExpectCall.t.sol +++ b/testdata/default/cheats/ExpectCall.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ExpectEmit.t.sol b/testdata/default/cheats/ExpectEmit.t.sol index cad184355443e..b8fe5e4587c76 100644 --- a/testdata/default/cheats/ExpectEmit.t.sol +++ b/testdata/default/cheats/ExpectEmit.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ExpectRevert.t.sol b/testdata/default/cheats/ExpectRevert.t.sol index 60137adfaa6d5..18a90bac6e29c 100644 --- a/testdata/default/cheats/ExpectRevert.t.sol +++ b/testdata/default/cheats/ExpectRevert.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Fee.t.sol b/testdata/default/cheats/Fee.t.sol index ad93fed6a4ef3..d258eaf13704e 100644 --- a/testdata/default/cheats/Fee.t.sol +++ b/testdata/default/cheats/Fee.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Ffi.t.sol b/testdata/default/cheats/Ffi.t.sol index 897783d7ec46f..23ac54e6ace12 100644 --- a/testdata/default/cheats/Ffi.t.sol +++ b/testdata/default/cheats/Ffi.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Fork.t.sol b/testdata/default/cheats/Fork.t.sol index 873fbec13921c..2f2e627de131a 100644 --- a/testdata/default/cheats/Fork.t.sol +++ b/testdata/default/cheats/Fork.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Fork2.t.sol b/testdata/default/cheats/Fork2.t.sol index 3e8f68a6cd6d1..7b6b4275990fc 100644 --- a/testdata/default/cheats/Fork2.t.sol +++ b/testdata/default/cheats/Fork2.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "../logs/console.sol"; diff --git a/testdata/default/cheats/Fs.t.sol b/testdata/default/cheats/Fs.t.sol index cb407641ec36b..b4882525944cf 100644 --- a/testdata/default/cheats/Fs.t.sol +++ b/testdata/default/cheats/Fs.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GasMetering.t.sol b/testdata/default/cheats/GasMetering.t.sol index e439e05be0f74..3cb105d236f02 100644 --- a/testdata/default/cheats/GasMetering.t.sol +++ b/testdata/default/cheats/GasMetering.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GasSnapshots.t.sol b/testdata/default/cheats/GasSnapshots.t.sol index 1e64a073d11fd..98abfa3e48efe 100644 --- a/testdata/default/cheats/GasSnapshots.t.sol +++ b/testdata/default/cheats/GasSnapshots.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GetArtifactPath.t.sol b/testdata/default/cheats/GetArtifactPath.t.sol index d92d41e01ae4e..538c2e6c96ecb 100644 --- a/testdata/default/cheats/GetArtifactPath.t.sol +++ b/testdata/default/cheats/GetArtifactPath.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity =0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GetBlockTimestamp.t.sol b/testdata/default/cheats/GetBlockTimestamp.t.sol index 383bfa8b0801d..edeaa0de79841 100644 --- a/testdata/default/cheats/GetBlockTimestamp.t.sol +++ b/testdata/default/cheats/GetBlockTimestamp.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GetCode.t.sol b/testdata/default/cheats/GetCode.t.sol index b155a1873ddfe..b258b6271efab 100644 --- a/testdata/default/cheats/GetCode.t.sol +++ b/testdata/default/cheats/GetCode.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity =0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GetDeployedCode.t.sol b/testdata/default/cheats/GetDeployedCode.t.sol index 220e3f3c87529..295d2ae8f3f38 100644 --- a/testdata/default/cheats/GetDeployedCode.t.sol +++ b/testdata/default/cheats/GetDeployedCode.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity =0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GetFoundryVersion.t.sol b/testdata/default/cheats/GetFoundryVersion.t.sol index 6f850561d71b5..34d9a74bb4537 100644 --- a/testdata/default/cheats/GetFoundryVersion.t.sol +++ b/testdata/default/cheats/GetFoundryVersion.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GetLabel.t.sol b/testdata/default/cheats/GetLabel.t.sol index dcbe0812c8907..c5a5638d36752 100644 --- a/testdata/default/cheats/GetLabel.t.sol +++ b/testdata/default/cheats/GetLabel.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.0; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/GetNonce.t.sol b/testdata/default/cheats/GetNonce.t.sol index 7eb53f205bd19..d4043a59992a8 100644 --- a/testdata/default/cheats/GetNonce.t.sol +++ b/testdata/default/cheats/GetNonce.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Json.t.sol b/testdata/default/cheats/Json.t.sol index 0604ef9078f1c..ff1b62c6ee8a2 100644 --- a/testdata/default/cheats/Json.t.sol +++ b/testdata/default/cheats/Json.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Label.t.sol b/testdata/default/cheats/Label.t.sol index d554f637dfbde..4ff5d3860bed0 100644 --- a/testdata/default/cheats/Label.t.sol +++ b/testdata/default/cheats/Label.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/LastCallGas.t.sol b/testdata/default/cheats/LastCallGas.t.sol index 0f5b65e350e13..bc7ac42639505 100644 --- a/testdata/default/cheats/LastCallGas.t.sol +++ b/testdata/default/cheats/LastCallGas.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Load.t.sol b/testdata/default/cheats/Load.t.sol index 0ed1cbbc20211..06f4b5bd52718 100644 --- a/testdata/default/cheats/Load.t.sol +++ b/testdata/default/cheats/Load.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Mapping.t.sol b/testdata/default/cheats/Mapping.t.sol index 6cd141fa85a7e..82477150ae9ca 100644 --- a/testdata/default/cheats/Mapping.t.sol +++ b/testdata/default/cheats/Mapping.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.0; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/MemSafety.t.sol b/testdata/default/cheats/MemSafety.t.sol index 096d8ac471823..a5c0a5a4ff614 100644 --- a/testdata/default/cheats/MemSafety.t.sol +++ b/testdata/default/cheats/MemSafety.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/MockCall.t.sol b/testdata/default/cheats/MockCall.t.sol index df7ee89c7379b..940e5e78c6034 100644 --- a/testdata/default/cheats/MockCall.t.sol +++ b/testdata/default/cheats/MockCall.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/MockCalls.t.sol b/testdata/default/cheats/MockCalls.t.sol index 13e3cb78c992b..2bd4d8bd9ea2e 100644 --- a/testdata/default/cheats/MockCalls.t.sol +++ b/testdata/default/cheats/MockCalls.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/MockFunction.t.sol b/testdata/default/cheats/MockFunction.t.sol index 9cf1004ca2795..6d670024b2053 100644 --- a/testdata/default/cheats/MockFunction.t.sol +++ b/testdata/default/cheats/MockFunction.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Nonce.t.sol b/testdata/default/cheats/Nonce.t.sol index 5dd8b0c6a268a..312c2b4d7edcc 100644 --- a/testdata/default/cheats/Nonce.t.sol +++ b/testdata/default/cheats/Nonce.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Parse.t.sol b/testdata/default/cheats/Parse.t.sol index 71d49af6f2d0b..65e7561d104de 100644 --- a/testdata/default/cheats/Parse.t.sol +++ b/testdata/default/cheats/Parse.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Prank.t.sol b/testdata/default/cheats/Prank.t.sol index f7dd9b714f80c..d833c0513d832 100644 --- a/testdata/default/cheats/Prank.t.sol +++ b/testdata/default/cheats/Prank.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Prevrandao.t.sol b/testdata/default/cheats/Prevrandao.t.sol index 75f2b2cc13020..aab8e326c43ce 100644 --- a/testdata/default/cheats/Prevrandao.t.sol +++ b/testdata/default/cheats/Prevrandao.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ProjectRoot.t.sol b/testdata/default/cheats/ProjectRoot.t.sol index 31e68e1058cba..cff3d83751d66 100644 --- a/testdata/default/cheats/ProjectRoot.t.sol +++ b/testdata/default/cheats/ProjectRoot.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Prompt.t.sol b/testdata/default/cheats/Prompt.t.sol index 33f83fea85ea4..2e623a28ef22c 100644 --- a/testdata/default/cheats/Prompt.t.sol +++ b/testdata/default/cheats/Prompt.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/RandomAddress.t.sol b/testdata/default/cheats/RandomAddress.t.sol index 74c5e20405704..61510ed4eaaac 100644 --- a/testdata/default/cheats/RandomAddress.t.sol +++ b/testdata/default/cheats/RandomAddress.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/RandomBytes.t.sol b/testdata/default/cheats/RandomBytes.t.sol index 8d298f43f0c88..dbc03a6ccfb8f 100644 --- a/testdata/default/cheats/RandomBytes.t.sol +++ b/testdata/default/cheats/RandomBytes.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/RandomCheatcodes.t.sol b/testdata/default/cheats/RandomCheatcodes.t.sol index 4f7d559fa8812..beeee9862bbb6 100644 --- a/testdata/default/cheats/RandomCheatcodes.t.sol +++ b/testdata/default/cheats/RandomCheatcodes.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/RandomUint.t.sol b/testdata/default/cheats/RandomUint.t.sol index 68a65dc0f86a1..c0021030d0d1e 100644 --- a/testdata/default/cheats/RandomUint.t.sol +++ b/testdata/default/cheats/RandomUint.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ReadCallers.t.sol b/testdata/default/cheats/ReadCallers.t.sol index e0da8ed0ddccc..dbd198a2d93e8 100644 --- a/testdata/default/cheats/ReadCallers.t.sol +++ b/testdata/default/cheats/ReadCallers.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.0; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Record.t.sol b/testdata/default/cheats/Record.t.sol index 152a5ccb5d0fc..c2907ebb84316 100644 --- a/testdata/default/cheats/Record.t.sol +++ b/testdata/default/cheats/Record.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/RecordAccountAccesses.t.sol b/testdata/default/cheats/RecordAccountAccesses.t.sol index a0aa2cb5332df..98b5843b2a7f8 100644 --- a/testdata/default/cheats/RecordAccountAccesses.t.sol +++ b/testdata/default/cheats/RecordAccountAccesses.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Unlicense -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/RecordLogs.t.sol b/testdata/default/cheats/RecordLogs.t.sol index 728acdb9b0e76..14ca8dde35e99 100644 --- a/testdata/default/cheats/RecordLogs.t.sol +++ b/testdata/default/cheats/RecordLogs.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Remember.t.sol b/testdata/default/cheats/Remember.t.sol index b5487c3698597..b8dbe7e38007c 100644 --- a/testdata/default/cheats/Remember.t.sol +++ b/testdata/default/cheats/Remember.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ResetNonce.t.sol b/testdata/default/cheats/ResetNonce.t.sol index 9014336091d21..d8c911587095c 100644 --- a/testdata/default/cheats/ResetNonce.t.sol +++ b/testdata/default/cheats/ResetNonce.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.0; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Roll.t.sol b/testdata/default/cheats/Roll.t.sol index 820cd9887b6b6..87f909cdd373f 100644 --- a/testdata/default/cheats/Roll.t.sol +++ b/testdata/default/cheats/Roll.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/RpcUrls.t.sol b/testdata/default/cheats/RpcUrls.t.sol index f7b9808604054..7976fa5722432 100644 --- a/testdata/default/cheats/RpcUrls.t.sol +++ b/testdata/default/cheats/RpcUrls.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/SetBlockhash.t.sol b/testdata/default/cheats/SetBlockhash.t.sol index f6c2af5f668ba..1274620df41a6 100644 --- a/testdata/default/cheats/SetBlockhash.t.sol +++ b/testdata/default/cheats/SetBlockhash.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/SetNonce.t.sol b/testdata/default/cheats/SetNonce.t.sol index 7f2e419b946f0..83e3830abc3f9 100644 --- a/testdata/default/cheats/SetNonce.t.sol +++ b/testdata/default/cheats/SetNonce.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/SetNonceUnsafe.t.sol b/testdata/default/cheats/SetNonceUnsafe.t.sol index 723f66ae2557b..0caf2b4ce7421 100644 --- a/testdata/default/cheats/SetNonceUnsafe.t.sol +++ b/testdata/default/cheats/SetNonceUnsafe.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Setup.t.sol b/testdata/default/cheats/Setup.t.sol index d694fb2c1c620..4d6e5954b5fe1 100644 --- a/testdata/default/cheats/Setup.t.sol +++ b/testdata/default/cheats/Setup.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Sign.t.sol b/testdata/default/cheats/Sign.t.sol index a257d62919efb..937ebc00a9222 100644 --- a/testdata/default/cheats/Sign.t.sol +++ b/testdata/default/cheats/Sign.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/SignP256.t.sol b/testdata/default/cheats/SignP256.t.sol index f1b62fe78d886..b92588ce9f823 100644 --- a/testdata/default/cheats/SignP256.t.sol +++ b/testdata/default/cheats/SignP256.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Skip.t.sol b/testdata/default/cheats/Skip.t.sol index fb2deadb4f52a..e2b0fc18113e3 100644 --- a/testdata/default/cheats/Skip.t.sol +++ b/testdata/default/cheats/Skip.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Sleep.t.sol b/testdata/default/cheats/Sleep.t.sol index 448d34668bed8..7af548e742573 100644 --- a/testdata/default/cheats/Sleep.t.sol +++ b/testdata/default/cheats/Sleep.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/StateSnapshots.t.sol b/testdata/default/cheats/StateSnapshots.t.sol index 92ee38d26e2e5..8751a04094129 100644 --- a/testdata/default/cheats/StateSnapshots.t.sol +++ b/testdata/default/cheats/StateSnapshots.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Store.t.sol b/testdata/default/cheats/Store.t.sol index 5159a4ab8635b..9a1ce6101c1b0 100644 --- a/testdata/default/cheats/Store.t.sol +++ b/testdata/default/cheats/Store.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/StringUtils.t.sol b/testdata/default/cheats/StringUtils.t.sol index 136164a413d7d..b65346a7a4e0a 100644 --- a/testdata/default/cheats/StringUtils.t.sol +++ b/testdata/default/cheats/StringUtils.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/ToString.t.sol b/testdata/default/cheats/ToString.t.sol index 835c85242883b..f19110e3e8655 100644 --- a/testdata/default/cheats/ToString.t.sol +++ b/testdata/default/cheats/ToString.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Toml.t.sol b/testdata/default/cheats/Toml.t.sol index 4b1666d4f28a8..5f0ef5b43c09e 100644 --- a/testdata/default/cheats/Toml.t.sol +++ b/testdata/default/cheats/Toml.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Travel.t.sol b/testdata/default/cheats/Travel.t.sol index 733559b2926a9..b46d2e7ad7041 100644 --- a/testdata/default/cheats/Travel.t.sol +++ b/testdata/default/cheats/Travel.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/UnixTime.t.sol b/testdata/default/cheats/UnixTime.t.sol index a6b683967fa79..29d86699f64d1 100644 --- a/testdata/default/cheats/UnixTime.t.sol +++ b/testdata/default/cheats/UnixTime.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Wallet.t.sol b/testdata/default/cheats/Wallet.t.sol index 5a7035876cd0c..d061b55ae45c5 100644 --- a/testdata/default/cheats/Wallet.t.sol +++ b/testdata/default/cheats/Wallet.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/Warp.t.sol b/testdata/default/cheats/Warp.t.sol index 01ebc8e89cbf0..42f373c6172f7 100644 --- a/testdata/default/cheats/Warp.t.sol +++ b/testdata/default/cheats/Warp.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/dumpState.t.sol b/testdata/default/cheats/dumpState.t.sol index 74ebd3071f2ce..8a8675ca5eace 100644 --- a/testdata/default/cheats/dumpState.t.sol +++ b/testdata/default/cheats/dumpState.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/getBlockNumber.t.sol b/testdata/default/cheats/getBlockNumber.t.sol index c874e5e2f3899..ebf240dd811a1 100644 --- a/testdata/default/cheats/getBlockNumber.t.sol +++ b/testdata/default/cheats/getBlockNumber.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/cheats/loadAllocs.t.sol b/testdata/default/cheats/loadAllocs.t.sol index a4b72af6b2fed..94ce6804c1260 100644 --- a/testdata/default/cheats/loadAllocs.t.sol +++ b/testdata/default/cheats/loadAllocs.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/core/Abstract.t.sol b/testdata/default/core/Abstract.t.sol index fee06bbe64e13..d04d0ff778b7c 100644 --- a/testdata/default/core/Abstract.t.sol +++ b/testdata/default/core/Abstract.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; contract TestFixture { function something() public pure returns (string memory) { diff --git a/testdata/default/core/BadSigAfterInvariant.t.sol b/testdata/default/core/BadSigAfterInvariant.t.sol index 6d303b04b380e..7b485e24f4a04 100644 --- a/testdata/default/core/BadSigAfterInvariant.t.sol +++ b/testdata/default/core/BadSigAfterInvariant.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/core/ContractEnvironment.t.sol b/testdata/default/core/ContractEnvironment.t.sol index cc5facd9284ba..452fa88022557 100644 --- a/testdata/default/core/ContractEnvironment.t.sol +++ b/testdata/default/core/ContractEnvironment.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/core/DSStyle.t.sol b/testdata/default/core/DSStyle.t.sol index 400b707b68765..1eaf83969f1ed 100644 --- a/testdata/default/core/DSStyle.t.sol +++ b/testdata/default/core/DSStyle.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/core/FailingSetup.t.sol b/testdata/default/core/FailingSetup.t.sol index 37a3b9ac26ca1..d5e24e131c3fa 100644 --- a/testdata/default/core/FailingSetup.t.sol +++ b/testdata/default/core/FailingSetup.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/core/FailingTestAfterFailedSetup.t.sol b/testdata/default/core/FailingTestAfterFailedSetup.t.sol index eeb5c207e4df5..c56f4ba5de605 100644 --- a/testdata/default/core/FailingTestAfterFailedSetup.t.sol +++ b/testdata/default/core/FailingTestAfterFailedSetup.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/core/LegacyAssertions.t.sol b/testdata/default/core/LegacyAssertions.t.sol index 9bbc56e8eae5b..c35a63417efc3 100644 --- a/testdata/default/core/LegacyAssertions.t.sol +++ b/testdata/default/core/LegacyAssertions.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/core/MultipleAfterInvariant.t.sol b/testdata/default/core/MultipleAfterInvariant.t.sol index 446e76cbb3320..b23b0996a9242 100644 --- a/testdata/default/core/MultipleAfterInvariant.t.sol +++ b/testdata/default/core/MultipleAfterInvariant.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/core/MultipleSetup.t.sol b/testdata/default/core/MultipleSetup.t.sol index 412b3fb4c28e0..73cbaf1a99bd0 100644 --- a/testdata/default/core/MultipleSetup.t.sol +++ b/testdata/default/core/MultipleSetup.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/core/PaymentFailure.t.sol b/testdata/default/core/PaymentFailure.t.sol index d4751b2d52358..52c42fd376052 100644 --- a/testdata/default/core/PaymentFailure.t.sol +++ b/testdata/default/core/PaymentFailure.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/core/Reverting.t.sol b/testdata/default/core/Reverting.t.sol index 36fdd99bcbde7..91022e6ad20c4 100644 --- a/testdata/default/core/Reverting.t.sol +++ b/testdata/default/core/Reverting.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; contract RevertingTest { function testFailRevert() public pure { diff --git a/testdata/default/core/SetupConsistency.t.sol b/testdata/default/core/SetupConsistency.t.sol index dfc6a9ab4e8b0..08d766f0f9242 100644 --- a/testdata/default/core/SetupConsistency.t.sol +++ b/testdata/default/core/SetupConsistency.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fork/ForkSame_1.t.sol b/testdata/default/fork/ForkSame_1.t.sol index bbb73fcaafa03..949c7ea9ec17d 100644 --- a/testdata/default/fork/ForkSame_1.t.sol +++ b/testdata/default/fork/ForkSame_1.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fork/ForkSame_2.t.sol b/testdata/default/fork/ForkSame_2.t.sol index bbb73fcaafa03..949c7ea9ec17d 100644 --- a/testdata/default/fork/ForkSame_2.t.sol +++ b/testdata/default/fork/ForkSame_2.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fork/Transact.t.sol b/testdata/default/fork/Transact.t.sol index 0e3d9c9cb763a..3756587725eb8 100644 --- a/testdata/default/fork/Transact.t.sol +++ b/testdata/default/fork/Transact.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fs/Default.t.sol b/testdata/default/fs/Default.t.sol index 5e776e696fb08..e1524963f6c3e 100644 --- a/testdata/default/fs/Default.t.sol +++ b/testdata/default/fs/Default.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fs/Disabled.t.sol b/testdata/default/fs/Disabled.t.sol index 4efe9affcc3b5..36f05c211fcad 100644 --- a/testdata/default/fs/Disabled.t.sol +++ b/testdata/default/fs/Disabled.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fuzz/Fuzz.t.sol b/testdata/default/fuzz/Fuzz.t.sol index ef44653800334..24c8d1750e366 100644 --- a/testdata/default/fuzz/Fuzz.t.sol +++ b/testdata/default/fuzz/Fuzz.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/FuzzCollection.t.sol b/testdata/default/fuzz/FuzzCollection.t.sol index 9be09bea88c75..0c98ddc66b6b2 100644 --- a/testdata/default/fuzz/FuzzCollection.t.sol +++ b/testdata/default/fuzz/FuzzCollection.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.15; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/FuzzFailurePersist.t.sol b/testdata/default/fuzz/FuzzFailurePersist.t.sol index 0823f29fb1655..3787060411e5d 100644 --- a/testdata/default/fuzz/FuzzFailurePersist.t.sol +++ b/testdata/default/fuzz/FuzzFailurePersist.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fuzz/FuzzInt.t.sol b/testdata/default/fuzz/FuzzInt.t.sol index 071727f6da929..a47ff2953331f 100644 --- a/testdata/default/fuzz/FuzzInt.t.sol +++ b/testdata/default/fuzz/FuzzInt.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/FuzzPositive.t.sol b/testdata/default/fuzz/FuzzPositive.t.sol index 952a3b6992278..7d3639dfe5ec2 100644 --- a/testdata/default/fuzz/FuzzPositive.t.sol +++ b/testdata/default/fuzz/FuzzPositive.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/FuzzUint.t.sol b/testdata/default/fuzz/FuzzUint.t.sol index 923c2980f2bc1..c0cbf6466c31b 100644 --- a/testdata/default/fuzz/FuzzUint.t.sol +++ b/testdata/default/fuzz/FuzzUint.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol b/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol index 5387b020d37d6..3d4c51eac41e5 100644 --- a/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantCalldataDictionary.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fuzz/invariant/common/InvariantInnerContract.t.sol b/testdata/default/fuzz/invariant/common/InvariantInnerContract.t.sol index b8d5dc4164cc2..f8330a33cd6ec 100644 --- a/testdata/default/fuzz/invariant/common/InvariantInnerContract.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantInnerContract.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol index 5469801362a98..bd70dd3aeafba 100644 --- a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol b/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol index f439b8ce1e485..74a01f1805de6 100644 --- a/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantReentrancy.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/common/InvariantTest1.t.sol b/testdata/default/fuzz/invariant/common/InvariantTest1.t.sol index 15deccf338d7b..bb62f34c6a965 100644 --- a/testdata/default/fuzz/invariant/common/InvariantTest1.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantTest1.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol b/testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol index 60aef60d935db..e2e850e316d1e 100644 --- a/testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol +++ b/testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol b/testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol index 526da0c67f971..e2251f42c8126 100644 --- a/testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol +++ b/testdata/default/fuzz/invariant/target/ExcludeSelectors.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/ExcludeSenders.t.sol b/testdata/default/fuzz/invariant/target/ExcludeSenders.t.sol index bd37bd9bb6a4a..dda07074d18c7 100644 --- a/testdata/default/fuzz/invariant/target/ExcludeSenders.t.sol +++ b/testdata/default/fuzz/invariant/target/ExcludeSenders.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol b/testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol index 7988d5c8a2c38..759810611e95b 100644 --- a/testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol +++ b/testdata/default/fuzz/invariant/target/FuzzedTargetContracts.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/TargetContracts.t.sol b/testdata/default/fuzz/invariant/target/TargetContracts.t.sol index cdce691538204..d24c7eb5282a4 100644 --- a/testdata/default/fuzz/invariant/target/TargetContracts.t.sol +++ b/testdata/default/fuzz/invariant/target/TargetContracts.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/TargetInterfaces.t.sol b/testdata/default/fuzz/invariant/target/TargetInterfaces.t.sol index 5cfa85ce1836b..30b4a05e3eaf9 100644 --- a/testdata/default/fuzz/invariant/target/TargetInterfaces.t.sol +++ b/testdata/default/fuzz/invariant/target/TargetInterfaces.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/TargetSelectors.t.sol b/testdata/default/fuzz/invariant/target/TargetSelectors.t.sol index ef3af21424748..c74ac7fa18114 100644 --- a/testdata/default/fuzz/invariant/target/TargetSelectors.t.sol +++ b/testdata/default/fuzz/invariant/target/TargetSelectors.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/target/TargetSenders.t.sol b/testdata/default/fuzz/invariant/target/TargetSenders.t.sol index 50f37c4e950b5..6fa4c9a6387d5 100644 --- a/testdata/default/fuzz/invariant/target/TargetSenders.t.sol +++ b/testdata/default/fuzz/invariant/target/TargetSenders.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol b/testdata/default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol index bf457ab1709a5..86ca6d5439b7a 100644 --- a/testdata/default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/ExcludeArtifacts.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol index 2957c57de2af6..440f6183f415c 100644 --- a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol index c12cae74f5942..162d9cc2e1106 100644 --- a/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol b/testdata/default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol index ea86ab135b624..28fa146059f92 100644 --- a/testdata/default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol +++ b/testdata/default/fuzz/invariant/targetAbi/TargetArtifacts.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/inline/FuzzInlineConf.t.sol b/testdata/default/inline/FuzzInlineConf.t.sol index 3789313128000..73d2de2fc4ed1 100644 --- a/testdata/default/inline/FuzzInlineConf.t.sol +++ b/testdata/default/inline/FuzzInlineConf.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.0; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/inline/InvariantInlineConf.t.sol b/testdata/default/inline/InvariantInlineConf.t.sol index c032911ec6e1e..5ac81755e998d 100644 --- a/testdata/default/inline/InvariantInlineConf.t.sol +++ b/testdata/default/inline/InvariantInlineConf.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity >=0.8.0; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/linking/cycle/Cycle.t.sol b/testdata/default/linking/cycle/Cycle.t.sol index 424bc001fbab6..010f55ac36b2c 100644 --- a/testdata/default/linking/cycle/Cycle.t.sol +++ b/testdata/default/linking/cycle/Cycle.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; library Foo { function foo() external { diff --git a/testdata/default/linking/duplicate/Duplicate.t.sol b/testdata/default/linking/duplicate/Duplicate.t.sol index a09c81e4f105f..d1d0f32789238 100644 --- a/testdata/default/linking/duplicate/Duplicate.t.sol +++ b/testdata/default/linking/duplicate/Duplicate.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/linking/nested/Nested.t.sol b/testdata/default/linking/nested/Nested.t.sol index 90100c88962e5..136cb36479cbf 100644 --- a/testdata/default/linking/nested/Nested.t.sol +++ b/testdata/default/linking/nested/Nested.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/linking/simple/Simple.t.sol b/testdata/default/linking/simple/Simple.t.sol index a6a636b6c5575..85be791fd2489 100644 --- a/testdata/default/linking/simple/Simple.t.sol +++ b/testdata/default/linking/simple/Simple.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/logs/DebugLogs.t.sol b/testdata/default/logs/DebugLogs.t.sol index 59bb2a188b67b..3e307d173dfa3 100644 --- a/testdata/default/logs/DebugLogs.t.sol +++ b/testdata/default/logs/DebugLogs.t.sol @@ -1,4 +1,4 @@ -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/logs/HardhatLogs.t.sol b/testdata/default/logs/HardhatLogs.t.sol index 842a390a413d3..cc2f2b7859a78 100644 --- a/testdata/default/logs/HardhatLogs.t.sol +++ b/testdata/default/logs/HardhatLogs.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "./console.sol"; diff --git a/testdata/default/logs/console.sol b/testdata/default/logs/console.sol index f67c10bfae4d0..feed58fb3b954 100644 --- a/testdata/default/logs/console.sol +++ b/testdata/default/logs/console.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity 0.8; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); diff --git a/testdata/default/repros/Issue1543.t.sol b/testdata/default/repros/Issue1543.t.sol index e8b4806ed1209..e58f331c4af94 100644 --- a/testdata/default/repros/Issue1543.t.sol +++ b/testdata/default/repros/Issue1543.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/repros/Issue2623.t.sol b/testdata/default/repros/Issue2623.t.sol index 1d1c2b35bbb64..31252cae36c3b 100644 --- a/testdata/default/repros/Issue2623.t.sol +++ b/testdata/default/repros/Issue2623.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue2629.t.sol b/testdata/default/repros/Issue2629.t.sol index ffff50722c4a2..d46868903a60e 100644 --- a/testdata/default/repros/Issue2629.t.sol +++ b/testdata/default/repros/Issue2629.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue2723.t.sol b/testdata/default/repros/Issue2723.t.sol index 70e522296dac3..b7678df450cb8 100644 --- a/testdata/default/repros/Issue2723.t.sol +++ b/testdata/default/repros/Issue2723.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue2898.t.sol b/testdata/default/repros/Issue2898.t.sol index 23de35bcdc059..a16adf5a350ff 100644 --- a/testdata/default/repros/Issue2898.t.sol +++ b/testdata/default/repros/Issue2898.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue2956.t.sol b/testdata/default/repros/Issue2956.t.sol index b69d17fb3cb8f..c57b46cc1f4bc 100644 --- a/testdata/default/repros/Issue2956.t.sol +++ b/testdata/default/repros/Issue2956.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue2984.t.sol b/testdata/default/repros/Issue2984.t.sol index 5f0203369e0d8..fbcd1ab8c3c4a 100644 --- a/testdata/default/repros/Issue2984.t.sol +++ b/testdata/default/repros/Issue2984.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3055.t.sol b/testdata/default/repros/Issue3055.t.sol index 72461a6c01651..90ac8c3b08afd 100644 --- a/testdata/default/repros/Issue3055.t.sol +++ b/testdata/default/repros/Issue3055.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3077.t.sol b/testdata/default/repros/Issue3077.t.sol index b67316294abdf..3b5e4257a3ad4 100644 --- a/testdata/default/repros/Issue3077.t.sol +++ b/testdata/default/repros/Issue3077.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3110.t.sol b/testdata/default/repros/Issue3110.t.sol index f9ca984bdbe8a..9f1da8d032ec3 100644 --- a/testdata/default/repros/Issue3110.t.sol +++ b/testdata/default/repros/Issue3110.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3119.t.sol b/testdata/default/repros/Issue3119.t.sol index 3e82985c295bf..6c0ceb429d6d6 100644 --- a/testdata/default/repros/Issue3119.t.sol +++ b/testdata/default/repros/Issue3119.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3189.t.sol b/testdata/default/repros/Issue3189.t.sol index 27ea0ac51cfd5..0bcf5ddce8d76 100644 --- a/testdata/default/repros/Issue3189.t.sol +++ b/testdata/default/repros/Issue3189.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3190.t.sol b/testdata/default/repros/Issue3190.t.sol index 4a9add5f5c616..ede3e50e2e3ec 100644 --- a/testdata/default/repros/Issue3190.t.sol +++ b/testdata/default/repros/Issue3190.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3192.t.sol b/testdata/default/repros/Issue3192.t.sol index 1f693b1aad1ed..9c5be8d89f3d6 100644 --- a/testdata/default/repros/Issue3192.t.sol +++ b/testdata/default/repros/Issue3192.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3220.t.sol b/testdata/default/repros/Issue3220.t.sol index 30e75027a9ac7..5235e44c79c60 100644 --- a/testdata/default/repros/Issue3220.t.sol +++ b/testdata/default/repros/Issue3220.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3221.t.sol b/testdata/default/repros/Issue3221.t.sol index 628f9d0e180c1..81398c41fc290 100644 --- a/testdata/default/repros/Issue3221.t.sol +++ b/testdata/default/repros/Issue3221.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3223.t.sol b/testdata/default/repros/Issue3223.t.sol index cd43cb8ef1b90..6c21b7b3d60b1 100644 --- a/testdata/default/repros/Issue3223.t.sol +++ b/testdata/default/repros/Issue3223.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3347.t.sol b/testdata/default/repros/Issue3347.t.sol index ed9be5f365b8e..e48c1305db426 100644 --- a/testdata/default/repros/Issue3347.t.sol +++ b/testdata/default/repros/Issue3347.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3596.t.sol b/testdata/default/repros/Issue3596.t.sol index 04ee470d70b37..b0c6785874375 100644 --- a/testdata/default/repros/Issue3596.t.sol +++ b/testdata/default/repros/Issue3596.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3653.t.sol b/testdata/default/repros/Issue3653.t.sol index 8cfcc2d0e8765..26eb38e4a29f1 100644 --- a/testdata/default/repros/Issue3653.t.sol +++ b/testdata/default/repros/Issue3653.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3661.t.sol b/testdata/default/repros/Issue3661.t.sol index f141a19abd84a..76b55a222ca00 100644 --- a/testdata/default/repros/Issue3661.t.sol +++ b/testdata/default/repros/Issue3661.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/repros/Issue3674.t.sol b/testdata/default/repros/Issue3674.t.sol index 0b680342adad9..de5a960059f52 100644 --- a/testdata/default/repros/Issue3674.t.sol +++ b/testdata/default/repros/Issue3674.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3685.t.sol b/testdata/default/repros/Issue3685.t.sol index 7e8f886d890cd..f1da5bf6997bd 100644 --- a/testdata/default/repros/Issue3685.t.sol +++ b/testdata/default/repros/Issue3685.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3703.t.sol b/testdata/default/repros/Issue3703.t.sol index b6dc39f265a07..48651be24c669 100644 --- a/testdata/default/repros/Issue3703.t.sol +++ b/testdata/default/repros/Issue3703.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3708.t.sol b/testdata/default/repros/Issue3708.t.sol index f5bdf48bf76a3..1e9a337f195cf 100644 --- a/testdata/default/repros/Issue3708.t.sol +++ b/testdata/default/repros/Issue3708.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3753.t.sol b/testdata/default/repros/Issue3753.t.sol index 7af774baf49d3..2c927c823dbb6 100644 --- a/testdata/default/repros/Issue3753.t.sol +++ b/testdata/default/repros/Issue3753.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue3792.t.sol b/testdata/default/repros/Issue3792.t.sol index 1adeb88af8c9d..37f62bc61fabe 100644 --- a/testdata/default/repros/Issue3792.t.sol +++ b/testdata/default/repros/Issue3792.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue4402.t.sol b/testdata/default/repros/Issue4402.t.sol index 3bf0f33fb96fc..830b2926ef269 100644 --- a/testdata/default/repros/Issue4402.t.sol +++ b/testdata/default/repros/Issue4402.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue4586.t.sol b/testdata/default/repros/Issue4586.t.sol index 29284ee1b423b..c904af1e46abb 100644 --- a/testdata/default/repros/Issue4586.t.sol +++ b/testdata/default/repros/Issue4586.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue4630.t.sol b/testdata/default/repros/Issue4630.t.sol index 4b9fe9c9b80ba..01eb626505cd1 100644 --- a/testdata/default/repros/Issue4630.t.sol +++ b/testdata/default/repros/Issue4630.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue4640.t.sol b/testdata/default/repros/Issue4640.t.sol index eaa87c12c1710..1e7d887a9b57d 100644 --- a/testdata/default/repros/Issue4640.t.sol +++ b/testdata/default/repros/Issue4640.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue5038.t.sol b/testdata/default/repros/Issue5038.t.sol index 834f8278375a4..51a90bca10d4c 100644 --- a/testdata/default/repros/Issue5038.t.sol +++ b/testdata/default/repros/Issue5038.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue5739.t.sol b/testdata/default/repros/Issue5739.t.sol index eafbabd9395cf..6f3494b7e6e7d 100644 --- a/testdata/default/repros/Issue5739.t.sol +++ b/testdata/default/repros/Issue5739.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue5808.t.sol b/testdata/default/repros/Issue5808.t.sol index 66ea82b30480e..40efe65a9ce69 100644 --- a/testdata/default/repros/Issue5808.t.sol +++ b/testdata/default/repros/Issue5808.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue5929.t.sol b/testdata/default/repros/Issue5929.t.sol index cce676d253935..70c5a4f4ffbd4 100644 --- a/testdata/default/repros/Issue5929.t.sol +++ b/testdata/default/repros/Issue5929.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue5935.t.sol b/testdata/default/repros/Issue5935.t.sol index f783d12da49a1..8ef724412ce31 100644 --- a/testdata/default/repros/Issue5935.t.sol +++ b/testdata/default/repros/Issue5935.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.8.0 <0.9.0; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue5948.t.sol b/testdata/default/repros/Issue5948.t.sol index 992099fb1061a..ae6ee9d50d8ba 100644 --- a/testdata/default/repros/Issue5948.t.sol +++ b/testdata/default/repros/Issue5948.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6006.t.sol b/testdata/default/repros/Issue6006.t.sol index dac37cd24b2c1..54f0d11376d79 100644 --- a/testdata/default/repros/Issue6006.t.sol +++ b/testdata/default/repros/Issue6006.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6032.t.sol b/testdata/default/repros/Issue6032.t.sol index 75002a136aeed..2fa05222d5a54 100644 --- a/testdata/default/repros/Issue6032.t.sol +++ b/testdata/default/repros/Issue6032.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6070.t.sol b/testdata/default/repros/Issue6070.t.sol index e699f5ca9f3b2..ebf3c7ab15c7b 100644 --- a/testdata/default/repros/Issue6070.t.sol +++ b/testdata/default/repros/Issue6070.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6115.t.sol b/testdata/default/repros/Issue6115.t.sol index 65c5cdaa75ce1..ae65a7dae8647 100644 --- a/testdata/default/repros/Issue6115.t.sol +++ b/testdata/default/repros/Issue6115.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/repros/Issue6170.t.sol b/testdata/default/repros/Issue6170.t.sol index 543ca3142c9a8..78511f4a2dc91 100644 --- a/testdata/default/repros/Issue6170.t.sol +++ b/testdata/default/repros/Issue6170.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6180.t.sol b/testdata/default/repros/Issue6180.t.sol index 591c60bdf8d0b..3d08ccbebac5d 100644 --- a/testdata/default/repros/Issue6180.t.sol +++ b/testdata/default/repros/Issue6180.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6293.t.sol b/testdata/default/repros/Issue6293.t.sol index 303e8fbbe297a..6d57d13850950 100644 --- a/testdata/default/repros/Issue6293.t.sol +++ b/testdata/default/repros/Issue6293.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Unlicense -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6355.t.sol b/testdata/default/repros/Issue6355.t.sol index f002b2a87c03f..bbc3a4a98d412 100644 --- a/testdata/default/repros/Issue6355.t.sol +++ b/testdata/default/repros/Issue6355.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6437.t.sol b/testdata/default/repros/Issue6437.t.sol index c18af2dfda841..4cf27be7b233e 100644 --- a/testdata/default/repros/Issue6437.t.sol +++ b/testdata/default/repros/Issue6437.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6501.t.sol b/testdata/default/repros/Issue6501.t.sol index 392f0f1abc8a9..5d631cbe3e0a8 100644 --- a/testdata/default/repros/Issue6501.t.sol +++ b/testdata/default/repros/Issue6501.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "../logs/console.sol"; diff --git a/testdata/default/repros/Issue6538.t.sol b/testdata/default/repros/Issue6538.t.sol index 2b8beb578cb04..5b318a04c8687 100644 --- a/testdata/default/repros/Issue6538.t.sol +++ b/testdata/default/repros/Issue6538.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6554.t.sol b/testdata/default/repros/Issue6554.t.sol index c13ebc4a7d712..7a5fe7879c655 100644 --- a/testdata/default/repros/Issue6554.t.sol +++ b/testdata/default/repros/Issue6554.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6616.t.sol b/testdata/default/repros/Issue6616.t.sol index f31a79ee6495f..262721d86d118 100644 --- a/testdata/default/repros/Issue6616.t.sol +++ b/testdata/default/repros/Issue6616.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6634.t.sol b/testdata/default/repros/Issue6634.t.sol index 64d92e9d1f0ef..aa94922dd1ccb 100644 --- a/testdata/default/repros/Issue6634.t.sol +++ b/testdata/default/repros/Issue6634.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6643.t.sol b/testdata/default/repros/Issue6643.t.sol index 36b684c133dc1..5c7e1c483a03a 100644 --- a/testdata/default/repros/Issue6643.t.sol +++ b/testdata/default/repros/Issue6643.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6759.t.sol b/testdata/default/repros/Issue6759.t.sol index e528c63e1d82c..ffdcb88935a92 100644 --- a/testdata/default/repros/Issue6759.t.sol +++ b/testdata/default/repros/Issue6759.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue6966.t.sol b/testdata/default/repros/Issue6966.t.sol index f7a8db7000acb..7e35a869ed0fb 100644 --- a/testdata/default/repros/Issue6966.t.sol +++ b/testdata/default/repros/Issue6966.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; diff --git a/testdata/default/repros/Issue7457.t.sol b/testdata/default/repros/Issue7457.t.sol index 3c4080df2f8e7..1836c48254d55 100644 --- a/testdata/default/repros/Issue7457.t.sol +++ b/testdata/default/repros/Issue7457.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue7481.t.sol b/testdata/default/repros/Issue7481.t.sol index 441758b4ff56e..46b24b1d5142a 100644 --- a/testdata/default/repros/Issue7481.t.sol +++ b/testdata/default/repros/Issue7481.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue8004.t.sol b/testdata/default/repros/Issue8004.t.sol index 229dde5ad3a22..278aa12125ff3 100644 --- a/testdata/default/repros/Issue8004.t.sol +++ b/testdata/default/repros/Issue8004.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue8006.t.sol b/testdata/default/repros/Issue8006.t.sol index 078117d40e291..95b16e6f64faa 100644 --- a/testdata/default/repros/Issue8006.t.sol +++ b/testdata/default/repros/Issue8006.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue8168.t.sol b/testdata/default/repros/Issue8168.t.sol index f11cef7bc15bd..9a072ce4bbf8f 100644 --- a/testdata/default/repros/Issue8168.t.sol +++ b/testdata/default/repros/Issue8168.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue8277.t.sol b/testdata/default/repros/Issue8277.t.sol index aebdbd8ffe6be..48a089575b402 100644 --- a/testdata/default/repros/Issue8277.t.sol +++ b/testdata/default/repros/Issue8277.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue8287.t.sol b/testdata/default/repros/Issue8287.t.sol index 86901c0fda926..d1e372bda91d8 100644 --- a/testdata/default/repros/Issue8287.t.sol +++ b/testdata/default/repros/Issue8287.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue8383.t.sol b/testdata/default/repros/Issue8383.t.sol index a002b4b3dc1d2..339f5b518a30c 100644 --- a/testdata/default/repros/Issue8383.t.sol +++ b/testdata/default/repros/Issue8383.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/repros/Issue8971.t.sol b/testdata/default/repros/Issue8971.t.sol index d61e04ae60b93..37861b483ec5d 100644 --- a/testdata/default/repros/Issue8971.t.sol +++ b/testdata/default/repros/Issue8971.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/script/deploy.sol b/testdata/default/script/deploy.sol index 013e009d3eaec..7570c706a5cec 100644 --- a/testdata/default/script/deploy.sol +++ b/testdata/default/script/deploy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import {DSTest} from "lib/ds-test/src/test.sol"; import {Vm} from "cheats/Vm.sol"; diff --git a/testdata/default/spec/ShanghaiCompat.t.sol b/testdata/default/spec/ShanghaiCompat.t.sol index 02856a88fbec9..fd7213b3d0702 100644 --- a/testdata/default/spec/ShanghaiCompat.t.sol +++ b/testdata/default/spec/ShanghaiCompat.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.20; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/trace/ConflictingSignatures.t.sol b/testdata/default/trace/ConflictingSignatures.t.sol index 67dfd5d3afcc8..c8b7066c7a2f1 100644 --- a/testdata/default/trace/ConflictingSignatures.t.sol +++ b/testdata/default/trace/ConflictingSignatures.t.sol @@ -1,4 +1,4 @@ -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/default/trace/Trace.t.sol b/testdata/default/trace/Trace.t.sol index d513e8637edd9..19af6dd7c9fe7 100644 --- a/testdata/default/trace/Trace.t.sol +++ b/testdata/default/trace/Trace.t.sol @@ -1,4 +1,4 @@ -pragma solidity 0.8.18; +pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/fixtures/GetCode/UnlinkedContract.sol b/testdata/fixtures/GetCode/UnlinkedContract.sol index 41f0b0d762b8f..93c6a8e261858 100644 --- a/testdata/fixtures/GetCode/UnlinkedContract.sol +++ b/testdata/fixtures/GetCode/UnlinkedContract.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; library SmolLibrary { function add(uint256 a, uint256 b) public pure returns (uint256 c) { diff --git a/testdata/fixtures/GetCode/WorkingContract.sol b/testdata/fixtures/GetCode/WorkingContract.sol index 3ea5020553749..7f4cb79afe73a 100644 --- a/testdata/fixtures/GetCode/WorkingContract.sol +++ b/testdata/fixtures/GetCode/WorkingContract.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity ^0.8.18; contract WorkingContract { uint256 public constant secret = 42; diff --git a/testdata/multi-version/cheats/GetCode.t.sol b/testdata/multi-version/cheats/GetCode.t.sol index e4a7bd14ae4e9..72dae24e676af 100644 --- a/testdata/multi-version/cheats/GetCode.t.sol +++ b/testdata/multi-version/cheats/GetCode.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.18; +pragma solidity =0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; diff --git a/testdata/multi-version/cheats/GetCode17.t.sol b/testdata/multi-version/cheats/GetCode17.t.sol index 068a910cf7b65..f8bf4bb2aee28 100644 --- a/testdata/multi-version/cheats/GetCode17.t.sol +++ b/testdata/multi-version/cheats/GetCode17.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8.17; +pragma solidity =0.8.17; import "ds-test/test.sol"; import "cheats/Vm.sol"; From 0c659f07e1a3c1710ca5bc7c587f86620c2b1f8b Mon Sep 17 00:00:00 2001 From: boolafish Date: Wed, 9 Oct 2024 23:57:38 +0900 Subject: [PATCH 1542/1963] feat(cheatcode): `startDebugTraceRecording` and `stopDebugTraceRecording` for ERC4337 testing (#8571) * feat: add record opcode cheat code feat: capture stack inputs as part of the opcode feat: record opcode -> record debug trace fix: memory OOG, need to only use needed stack, mem input fix: missing op code, instruction results fix: accessing out-of-bound idx memory When running on some project, we noticed that it sometimes try to access memory with out of bound index and panics. This commit fix it by: 1. Enfore reset to Nonce after stopDebugTraceRecording(), this ensures the `some(..) = ...` part will not be triggered 2. Change how opcode_utils.rs accesses memory. Return empty vector if trying access out-of-bound memory. * test: add DebugTrace.t.sol for the debug trace cheatcode * fix: rebase errors * feat: use tracer for debug trace instead of recording during inspector This commit also cleans up the previous implementaiton on inspector. And then change the cheatcode interface to be of three steps: 1. start recording debug trace 2. stop recording 3. get the debug trace by index The reason is to avoid out-of-memory issue by returning the whole traces at once. * fix: rebase duplication * feat: replace instruction result with isOutOfGas * fix: CI issues * fix: remove DebugTrace wrapper in inspector * fix: revert to original tracer config when stops * chore: reuse existing opcode functions * chore: refactor, fmt, clippy run * chore: use ref instead of clone, returning Error when not able to access * chore: move buffer to evm_core from debugger * fix: disable dummy tracer by default, return explicit error Since enabling dummy tracer still come with performance impact, remove the auto dummy tracer initiation. The cheatcode will return explicit error and require the test to be run in -vvv mode to have the tracer enabled by default. * fix: return all traces, turn on necessary tracer config There was OOM concern but using the get-by-index style, despite improved, does not solve the root cause. The main issue is that the tracer config did not turn off after the stop recording cheatcode being called. It seems too much burden for the tracer to record the returned traces inside forge tests as the tests will also pass around the debug traces, causing memory boost. This commit also only turns on necessary tracer config instead of using all(). * chore: cleanup comments, typo * fix: use bytes for memory, remove flattern function, fix get_slice_from_memory * fix: style fmt * fix: ensure steps in the order of node when flatten A node can have steps that calls to another node, so the child node's step might occur before some steps of its parent node. This introduce the flatten_call_trace function back using recursive call to ensure the steps are in correct order despite not in the same order of the node index. see PR comment: https://github.com/foundry-rs/foundry/pull/8571#discussion_r1785386322 * doc: remove legacy comment in test * style: reuse empty initialized var on return val --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- Cargo.lock | 2 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 76 ++++++++ crates/cheatcodes/spec/src/lib.rs | 1 + crates/cheatcodes/spec/src/vm.rs | 33 ++++ crates/cheatcodes/src/evm.rs | 67 ++++++- .../cheatcodes/src/evm/record_debug_step.rs | 144 +++++++++++++++ crates/cheatcodes/src/inspector.rs | 14 +- crates/debugger/Cargo.toml | 1 + crates/debugger/src/tui/context.rs | 29 +-- crates/debugger/src/tui/draw.rs | 90 +--------- crates/evm/core/src/buffer.rs | 117 ++++++++++++ crates/evm/core/src/lib.rs | 1 + testdata/cheats/Vm.sol | 3 + .../default/cheats/RecordDebugTrace.t.sol | 166 ++++++++++++++++++ 15 files changed, 626 insertions(+), 119 deletions(-) create mode 100644 crates/cheatcodes/src/evm/record_debug_step.rs create mode 100644 crates/evm/core/src/buffer.rs create mode 100644 testdata/default/cheats/RecordDebugTrace.t.sol diff --git a/Cargo.lock b/Cargo.lock index 381ed5a7514ff..7438ab7f1acb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3634,6 +3634,7 @@ dependencies = [ "proptest", "rand", "revm", + "revm-inspectors", "semver 1.0.23", "serde_json", "thiserror", @@ -3908,6 +3909,7 @@ dependencies = [ "eyre", "foundry-common", "foundry-compilers", + "foundry-evm-core", "foundry-evm-traces", "ratatui", "revm", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 7f990a8e56beb..adce79b211bd3 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -58,6 +58,7 @@ p256 = "0.13.2" ecdsa = "0.16" rand = "0.8" revm.workspace = true +revm-inspectors.workspace = true semver.workspace = true serde_json.workspace = true thiserror.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 06ddba5bd5d1f..d64df4860abe1 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -488,6 +488,42 @@ "description": "The amount of gas remaining." } ] + }, + { + "name": "DebugStep", + "description": "The result of the `stopDebugTraceRecording` call", + "fields": [ + { + "name": "stack", + "ty": "uint256[]", + "description": "The stack before executing the step of the run.\n stack\\[0\\] represents the top of the stack.\n and only stack data relevant to the opcode execution is contained." + }, + { + "name": "memoryInput", + "ty": "bytes", + "description": "The memory input data before executing the step of the run.\n only input data relevant to the opcode execution is contained.\n e.g. for MLOAD, it will have memory\\[offset:offset+32\\] copied here.\n the offset value can be get by the stack data." + }, + { + "name": "opcode", + "ty": "uint8", + "description": "The opcode that was accessed." + }, + { + "name": "depth", + "ty": "uint64", + "description": "The call depth of the step." + }, + { + "name": "isOutOfGas", + "ty": "bool", + "description": "Whether the call end up with out of gas error." + }, + { + "name": "contractAddr", + "ty": "address", + "description": "The contract address where the opcode is running" + } + ] } ], "cheatcodes": [ @@ -8863,6 +8899,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "startDebugTraceRecording", + "description": "Records the debug trace during the run.", + "declaration": "function startDebugTraceRecording() external;", + "visibility": "external", + "mutability": "", + "signature": "startDebugTraceRecording()", + "selector": "0x419c8832", + "selectorBytes": [ + 65, + 156, + 136, + 50 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "startMappingRecording", @@ -8983,6 +9039,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "stopAndReturnDebugTraceRecording", + "description": "Stop debug trace recording and returns the recorded debug trace.", + "declaration": "function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);", + "visibility": "external", + "mutability": "", + "signature": "stopAndReturnDebugTraceRecording()", + "selector": "0xced398a2", + "selectorBytes": [ + 206, + 211, + 152, + 162 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "stopAndReturnStateDiff", diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index fffc146a9d2c1..662853e9e8117 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -85,6 +85,7 @@ impl Cheatcodes<'static> { Vm::AccountAccess::STRUCT.clone(), Vm::StorageAccess::STRUCT.clone(), Vm::Gas::STRUCT.clone(), + Vm::DebugStep::STRUCT.clone(), ]), enums: Cow::Owned(vec![ Vm::CallerMode::ENUM.clone(), diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index e73755de1d3bc..761d64e9bedbc 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -261,6 +261,28 @@ interface Vm { uint64 depth; } + /// The result of the `stopDebugTraceRecording` call + struct DebugStep { + /// The stack before executing the step of the run. + /// stack\[0\] represents the top of the stack. + /// and only stack data relevant to the opcode execution is contained. + uint256[] stack; + /// The memory input data before executing the step of the run. + /// only input data relevant to the opcode execution is contained. + /// + /// e.g. for MLOAD, it will have memory\[offset:offset+32\] copied here. + /// the offset value can be get by the stack data. + bytes memoryInput; + /// The opcode that was accessed. + uint8 opcode; + /// The call depth of the step. + uint64 depth; + /// Whether the call end up with out of gas error. + bool isOutOfGas; + /// The contract address where the opcode is running + address contractAddr; + } + // ======== EVM ======== /// Gets the address for a given private key. @@ -287,6 +309,17 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function loadAllocs(string calldata pathToAllocsJson) external; + // -------- Record Debug Traces -------- + + /// Records the debug trace during the run. + #[cheatcode(group = Evm, safety = Safe)] + function startDebugTraceRecording() external; + + /// Stop debug trace recording and returns the recorded debug trace. + #[cheatcode(group = Evm, safety = Safe)] + function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step); + + /// Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state. #[cheatcode(group = Evm, safety = Unsafe)] function cloneAccount(address source, address target) external; diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index b9a3d70474929..acc349be15d31 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1,8 +1,9 @@ //! Implementations of [`Evm`](spec::Group::Evm) cheatcodes. use crate::{ - inspector::InnerEcx, BroadcastableTransaction, Cheatcode, Cheatcodes, CheatcodesExecutor, - CheatsCtxt, Result, Vm::*, + inspector::{InnerEcx, RecordDebugStepInfo}, + BroadcastableTransaction, Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Error, Result, + Vm::*, }; use alloy_consensus::TxEnvelope; use alloy_genesis::{Genesis, GenesisAccount}; @@ -14,10 +15,14 @@ use foundry_evm_core::{ backend::{DatabaseExt, RevertStateSnapshotAction}, constants::{CALLER, CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS}, }; +use foundry_evm_traces::StackSnapshotType; use rand::Rng; use revm::primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}; use std::{collections::BTreeMap, path::Path}; +mod record_debug_step; +use record_debug_step::{convert_call_trace_to_debug_step, flatten_call_trace}; + mod fork; pub(crate) mod mapping; pub(crate) mod mock; @@ -715,6 +720,64 @@ impl Cheatcode for setBlockhashCall { } } +impl Cheatcode for startDebugTraceRecordingCall { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { + let Some(tracer) = executor.tracing_inspector().and_then(|t| t.as_mut()) else { + return Err(Error::from("no tracer initiated, consider adding -vvv flag")) + }; + + let mut info = RecordDebugStepInfo { + // will be updated later + start_node_idx: 0, + // keep the original config to revert back later + original_tracer_config: *tracer.config(), + }; + + // turn on tracer configuration for recording + tracer.update_config(|config| { + config + .set_steps(true) + .set_memory_snapshots(true) + .set_stack_snapshots(StackSnapshotType::Full) + }); + + // track where the recording starts + if let Some(last_node) = tracer.traces().nodes().last() { + info.start_node_idx = last_node.idx; + } + + ccx.state.record_debug_steps_info = Some(info); + Ok(Default::default()) + } +} + +impl Cheatcode for stopAndReturnDebugTraceRecordingCall { + fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { + let Some(tracer) = executor.tracing_inspector().and_then(|t| t.as_mut()) else { + return Err(Error::from("no tracer initiated, consider adding -vvv flag")) + }; + + let Some(record_info) = ccx.state.record_debug_steps_info else { + return Err(Error::from("nothing recorded")) + }; + + // Revert the tracer config to the one before recording + tracer.update_config(|_config| record_info.original_tracer_config); + + // Use the trace nodes to flatten the call trace + let root = tracer.traces(); + let steps = flatten_call_trace(0, root, record_info.start_node_idx); + + let debug_steps: Vec = + steps.iter().map(|&step| convert_call_trace_to_debug_step(step)).collect(); + + // Clean up the recording info + ccx.state.record_debug_steps_info = None; + + Ok(debug_steps.abi_encode()) + } +} + pub(super) fn get_nonce(ccx: &mut CheatsCtxt, address: &Address) -> Result { let account = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?; Ok(account.info.nonce.abi_encode()) diff --git a/crates/cheatcodes/src/evm/record_debug_step.rs b/crates/cheatcodes/src/evm/record_debug_step.rs new file mode 100644 index 0000000000000..b9f0f89cb01ff --- /dev/null +++ b/crates/cheatcodes/src/evm/record_debug_step.rs @@ -0,0 +1,144 @@ +use alloy_primitives::{Bytes, U256}; + +use foundry_evm_traces::CallTraceArena; +use revm::interpreter::{InstructionResult, OpCode}; + +use foundry_evm_core::buffer::{get_buffer_accesses, BufferKind}; +use revm_inspectors::tracing::types::{CallTraceStep, RecordedMemory, TraceMemberOrder}; +use spec::Vm::DebugStep; + +// Do a depth first traverse of the nodes and steps and return steps +// that are after `node_start_idx` +pub(crate) fn flatten_call_trace( + root: usize, + arena: &CallTraceArena, + node_start_idx: usize, +) -> Vec<&CallTraceStep> { + let mut steps = Vec::new(); + let mut record_started = false; + + // Start the recursion from the root node + recursive_flatten_call_trace(root, arena, node_start_idx, &mut record_started, &mut steps); + steps +} + +// Inner recursive function to process nodes. +// This implementation directly mutates `record_started` and `flatten_steps`. +// So the recursive call can change the `record_started` flag even for the parent +// unfinished processing, and append steps to the `flatten_steps` as the final result. +fn recursive_flatten_call_trace<'a>( + node_idx: usize, + arena: &'a CallTraceArena, + node_start_idx: usize, + record_started: &mut bool, + flatten_steps: &mut Vec<&'a CallTraceStep>, +) { + // Once node_idx exceeds node_start_idx, start recording steps + // for all the recursive processing. + if !*record_started && node_idx >= node_start_idx { + *record_started = true; + } + + let node = &arena.nodes()[node_idx]; + + for order in node.ordering.iter() { + match order { + TraceMemberOrder::Step(step_idx) => { + if *record_started { + let step = &node.trace.steps[*step_idx]; + flatten_steps.push(step); + } + } + TraceMemberOrder::Call(call_idx) => { + let child_node_idx = node.children[*call_idx]; + recursive_flatten_call_trace( + child_node_idx, + arena, + node_start_idx, + record_started, + flatten_steps, + ); + } + _ => {} + } + } +} + +// Function to convert CallTraceStep to DebugStep +pub(crate) fn convert_call_trace_to_debug_step(step: &CallTraceStep) -> DebugStep { + let opcode = step.op.get(); + let stack = get_stack_inputs_for_opcode(opcode, step.stack.as_ref()); + + let memory = get_memory_input_for_opcode(opcode, step.stack.as_ref(), step.memory.as_ref()); + + let is_out_of_gas = step.status == InstructionResult::OutOfGas || + step.status == InstructionResult::MemoryOOG || + step.status == InstructionResult::MemoryLimitOOG || + step.status == InstructionResult::PrecompileOOG || + step.status == InstructionResult::InvalidOperandOOG; + + DebugStep { + stack, + memoryInput: memory, + opcode: step.op.get(), + depth: step.depth, + isOutOfGas: is_out_of_gas, + contractAddr: step.contract, + } +} + +// The expected `stack` here is from the trace stack, where the top of the stack +// is the last value of the vector +fn get_memory_input_for_opcode( + opcode: u8, + stack: Option<&Vec>, + memory: Option<&RecordedMemory>, +) -> Bytes { + let mut memory_input = Bytes::new(); + let Some(stack_data) = stack else { return memory_input }; + let Some(memory_data) = memory else { return memory_input }; + + if let Some(accesses) = get_buffer_accesses(opcode, stack_data) { + if let Some((BufferKind::Memory, access)) = accesses.read { + memory_input = get_slice_from_memory(memory_data.as_bytes(), access.offset, access.len); + } + }; + + memory_input +} + +// The expected `stack` here is from the trace stack, where the top of the stack +// is the last value of the vector +fn get_stack_inputs_for_opcode(opcode: u8, stack: Option<&Vec>) -> Vec { + let mut inputs = Vec::new(); + + let Some(op) = OpCode::new(opcode) else { return inputs }; + let Some(stack_data) = stack else { return inputs }; + + let stack_input_size = op.inputs() as usize; + for i in 0..stack_input_size { + inputs.push(stack_data[stack_data.len() - 1 - i]); + } + inputs +} + +fn get_slice_from_memory(memory: &Bytes, start_index: usize, size: usize) -> Bytes { + let memory_len = memory.len(); + + let end_bound = start_index + size; + + // Return the bytes if data is within the range. + if start_index < memory_len && end_bound <= memory_len { + return memory.slice(start_index..end_bound); + } + + // Pad zero bytes if attempting to load memory partially out of range. + if start_index < memory_len && end_bound > memory_len { + let mut result = memory.slice(start_index..memory_len).to_vec(); + result.resize(size, 0u8); + return Bytes::from(result); + } + + // Return empty bytes with the size if not in range at all. + Bytes::from(vec![0u8; size]) +} diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 9a40c3cb1b313..acb86681f8480 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -36,7 +36,7 @@ use foundry_evm_core::{ utils::new_evm_with_existing_context, InspectorExt, }; -use foundry_evm_traces::TracingInspector; +use foundry_evm_traces::{TracingInspector, TracingInspectorConfig}; use itertools::Itertools; use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; use rand::Rng; @@ -219,6 +219,14 @@ pub struct BroadcastableTransaction { pub transaction: TransactionMaybeSigned, } +#[derive(Clone, Debug, Copy)] +pub struct RecordDebugStepInfo { + /// The debug trace node index when the recording starts. + pub start_node_idx: usize, + /// The original tracer config when the recording starts. + pub original_tracer_config: TracingInspectorConfig, +} + /// Holds gas metering state. #[derive(Clone, Debug, Default)] pub struct GasMetering { @@ -396,6 +404,9 @@ pub struct Cheatcodes { /// merged into the previous vector. pub recorded_account_diffs_stack: Option>>, + /// The information of the debug step recording. + pub record_debug_steps_info: Option, + /// Recorded logs pub recorded_logs: Option>, @@ -492,6 +503,7 @@ impl Cheatcodes { accesses: Default::default(), recorded_account_diffs_stack: Default::default(), recorded_logs: Default::default(), + record_debug_steps_info: Default::default(), mocked_calls: Default::default(), mocked_functions: Default::default(), expected_calls: Default::default(), diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index 6ccb630ca0c98..4fb417db5c1e5 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -16,6 +16,7 @@ workspace = true foundry-common.workspace = true foundry-compilers.workspace = true foundry-evm-traces.workspace = true +foundry-evm-core.workspace = true revm-inspectors.workspace = true alloy-primitives.workspace = true diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index 6792145fe245d..c3645e31b1533 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -3,6 +3,7 @@ use crate::{DebugNode, Debugger, ExitReason}; use alloy_primitives::{hex, Address}; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; +use foundry_evm_core::buffer::BufferKind; use revm::interpreter::OpCode; use revm_inspectors::tracing::types::{CallKind, CallTraceStep}; use std::ops::ControlFlow; @@ -15,34 +16,6 @@ pub(crate) struct DrawMemory { pub(crate) current_stack_startline: usize, } -/// Used to keep track of which buffer is currently active to be drawn by the debugger. -#[derive(Debug, PartialEq)] -pub(crate) enum BufferKind { - Memory, - Calldata, - Returndata, -} - -impl BufferKind { - /// Helper to cycle through the active buffers. - pub(crate) fn next(&self) -> Self { - match self { - Self::Memory => Self::Calldata, - Self::Calldata => Self::Returndata, - Self::Returndata => Self::Memory, - } - } - - /// Helper to format the title of the active buffer pane - pub(crate) fn title(&self, size: usize) -> String { - match self { - Self::Memory => format!("Memory (max expansion: {size} bytes)"), - Self::Calldata => format!("Calldata (size: {size} bytes)"), - Self::Returndata => format!("Returndata (size: {size} bytes)"), - } - } -} - pub(crate) struct DebuggerContext<'a> { pub(crate) debugger: &'a mut Debugger, diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 0f2399a20da9c..55e4834f58d8b 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -1,9 +1,9 @@ //! TUI draw implementation. -use super::context::{BufferKind, DebuggerContext}; +use super::context::DebuggerContext; use crate::op::OpcodeParam; -use alloy_primitives::U256; use foundry_compilers::artifacts::sourcemap::SourceElement; +use foundry_evm_core::buffer::{get_buffer_accesses, BufferKind}; use foundry_evm_traces::debug::SourceData; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, @@ -12,7 +12,6 @@ use ratatui::{ widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap}, Frame, }; -use revm::interpreter::opcode; use revm_inspectors::tracing::types::CallKind; use std::{collections::VecDeque, fmt::Write, io}; @@ -624,91 +623,6 @@ impl<'a> SourceLines<'a> { } } -/// Container for buffer access information. -struct BufferAccess { - offset: usize, - len: usize, -} - -/// Container for read and write buffer access information. -struct BufferAccesses { - /// The read buffer kind and access information. - read: Option<(BufferKind, BufferAccess)>, - /// The only mutable buffer is the memory buffer, so don't store the buffer kind. - write: Option, -} - -/// The memory_access variable stores the index on the stack that indicates the buffer -/// offset/len accessed by the given opcode: -/// (read buffer, buffer read offset, buffer read len, write memory offset, write memory len) -/// \>= 1: the stack index -/// 0: no memory access -/// -1: a fixed len of 32 bytes -/// -2: a fixed len of 1 byte -/// -/// The return value is a tuple about accessed buffer region by the given opcode: -/// (read buffer, buffer read offset, buffer read len, write memory offset, write memory len) -fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { - let buffer_access = match op { - opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => { - (Some((BufferKind::Memory, 1, 2)), None) - } - opcode::CALLDATACOPY => (Some((BufferKind::Calldata, 2, 3)), Some((1, 3))), - opcode::RETURNDATACOPY => (Some((BufferKind::Returndata, 2, 3)), Some((1, 3))), - opcode::CALLDATALOAD => (Some((BufferKind::Calldata, 1, -1)), None), - opcode::CODECOPY => (None, Some((1, 3))), - opcode::EXTCODECOPY => (None, Some((2, 4))), - opcode::MLOAD => (Some((BufferKind::Memory, 1, -1)), None), - opcode::MSTORE => (None, Some((1, -1))), - opcode::MSTORE8 => (None, Some((1, -2))), - opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => { - (Some((BufferKind::Memory, 1, 2)), None) - } - opcode::CREATE | opcode::CREATE2 => (Some((BufferKind::Memory, 2, 3)), None), - opcode::CALL | opcode::CALLCODE => (Some((BufferKind::Memory, 4, 5)), None), - opcode::DELEGATECALL | opcode::STATICCALL => (Some((BufferKind::Memory, 3, 4)), None), - opcode::MCOPY => (Some((BufferKind::Memory, 2, 3)), Some((1, 3))), - opcode::RETURNDATALOAD => (Some((BufferKind::Returndata, 1, -1)), None), - opcode::EOFCREATE => (Some((BufferKind::Memory, 3, 4)), None), - opcode::RETURNCONTRACT => (Some((BufferKind::Memory, 1, 2)), None), - opcode::DATACOPY => (None, Some((1, 3))), - opcode::EXTCALL | opcode::EXTSTATICCALL | opcode::EXTDELEGATECALL => { - (Some((BufferKind::Memory, 2, 3)), None) - } - _ => Default::default(), - }; - - let stack_len = stack.len(); - let get_size = |stack_index| match stack_index { - -2 => Some(1), - -1 => Some(32), - 0 => None, - 1.. => { - if (stack_index as usize) <= stack_len { - Some(stack[stack_len - stack_index as usize].saturating_to()) - } else { - None - } - } - _ => panic!("invalid stack index"), - }; - - if buffer_access.0.is_some() || buffer_access.1.is_some() { - let (read, write) = buffer_access; - let read_access = read.and_then(|b| { - let (buffer, offset, len) = b; - Some((buffer, BufferAccess { offset: get_size(offset)?, len: get_size(len)? })) - }); - let write_access = write.and_then(|b| { - let (offset, len) = b; - Some(BufferAccess { offset: get_size(offset)?, len: get_size(len)? }) - }); - Some(BufferAccesses { read: read_access, write: write_access }) - } else { - None - } -} - fn hex_bytes_spans(bytes: &[u8], spans: &mut Vec>, f: impl Fn(usize, u8) -> Style) { for (i, &byte) in bytes.iter().enumerate() { if i > 0 { diff --git a/crates/evm/core/src/buffer.rs b/crates/evm/core/src/buffer.rs new file mode 100644 index 0000000000000..1db7420d78736 --- /dev/null +++ b/crates/evm/core/src/buffer.rs @@ -0,0 +1,117 @@ +use alloy_primitives::U256; +use revm::interpreter::opcode; + +/// Used to keep track of which buffer is currently active to be drawn by the debugger. +#[derive(Debug, PartialEq)] +pub enum BufferKind { + Memory, + Calldata, + Returndata, +} + +impl BufferKind { + /// Helper to cycle through the active buffers. + pub fn next(&self) -> Self { + match self { + Self::Memory => Self::Calldata, + Self::Calldata => Self::Returndata, + Self::Returndata => Self::Memory, + } + } + + /// Helper to format the title of the active buffer pane + pub fn title(&self, size: usize) -> String { + match self { + Self::Memory => format!("Memory (max expansion: {size} bytes)"), + Self::Calldata => format!("Calldata (size: {size} bytes)"), + Self::Returndata => format!("Returndata (size: {size} bytes)"), + } + } +} + +/// Container for buffer access information. +pub struct BufferAccess { + pub offset: usize, + pub len: usize, +} + +/// Container for read and write buffer access information. +pub struct BufferAccesses { + /// The read buffer kind and access information. + pub read: Option<(BufferKind, BufferAccess)>, + /// The only mutable buffer is the memory buffer, so don't store the buffer kind. + pub write: Option, +} + +/// A utility function to get the buffer access. +/// +/// The memory_access variable stores the index on the stack that indicates the buffer +/// offset/len accessed by the given opcode: +/// (read buffer, buffer read offset, buffer read len, write memory offset, write memory len) +/// \>= 1: the stack index +/// 0: no memory access +/// -1: a fixed len of 32 bytes +/// -2: a fixed len of 1 byte +/// +/// The return value is a tuple about accessed buffer region by the given opcode: +/// (read buffer, buffer read offset, buffer read len, write memory offset, write memory len) +pub fn get_buffer_accesses(op: u8, stack: &[U256]) -> Option { + let buffer_access = match op { + opcode::KECCAK256 | opcode::RETURN | opcode::REVERT => { + (Some((BufferKind::Memory, 1, 2)), None) + } + opcode::CALLDATACOPY => (Some((BufferKind::Calldata, 2, 3)), Some((1, 3))), + opcode::RETURNDATACOPY => (Some((BufferKind::Returndata, 2, 3)), Some((1, 3))), + opcode::CALLDATALOAD => (Some((BufferKind::Calldata, 1, -1)), None), + opcode::CODECOPY => (None, Some((1, 3))), + opcode::EXTCODECOPY => (None, Some((2, 4))), + opcode::MLOAD => (Some((BufferKind::Memory, 1, -1)), None), + opcode::MSTORE => (None, Some((1, -1))), + opcode::MSTORE8 => (None, Some((1, -2))), + opcode::LOG0 | opcode::LOG1 | opcode::LOG2 | opcode::LOG3 | opcode::LOG4 => { + (Some((BufferKind::Memory, 1, 2)), None) + } + opcode::CREATE | opcode::CREATE2 => (Some((BufferKind::Memory, 2, 3)), None), + opcode::CALL | opcode::CALLCODE => (Some((BufferKind::Memory, 4, 5)), None), + opcode::DELEGATECALL | opcode::STATICCALL => (Some((BufferKind::Memory, 3, 4)), None), + opcode::MCOPY => (Some((BufferKind::Memory, 2, 3)), Some((1, 3))), + opcode::RETURNDATALOAD => (Some((BufferKind::Returndata, 1, -1)), None), + opcode::EOFCREATE => (Some((BufferKind::Memory, 3, 4)), None), + opcode::RETURNCONTRACT => (Some((BufferKind::Memory, 1, 2)), None), + opcode::DATACOPY => (None, Some((1, 3))), + opcode::EXTCALL | opcode::EXTSTATICCALL | opcode::EXTDELEGATECALL => { + (Some((BufferKind::Memory, 2, 3)), None) + } + _ => Default::default(), + }; + + let stack_len = stack.len(); + let get_size = |stack_index| match stack_index { + -2 => Some(1), + -1 => Some(32), + 0 => None, + 1.. => { + if (stack_index as usize) <= stack_len { + Some(stack[stack_len - stack_index as usize].saturating_to()) + } else { + None + } + } + _ => panic!("invalid stack index"), + }; + + if buffer_access.0.is_some() || buffer_access.1.is_some() { + let (read, write) = buffer_access; + let read_access = read.and_then(|b| { + let (buffer, offset, len) = b; + Some((buffer, BufferAccess { offset: get_size(offset)?, len: get_size(len)? })) + }); + let write_access = write.and_then(|b| { + let (offset, len) = b; + Some(BufferAccess { offset: get_size(offset)?, len: get_size(len)? }) + }); + Some(BufferAccesses { read: read_access, write: write_access }) + } else { + None + } +} diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index b6da4b49a5d97..1a2ac4c4a0f49 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -21,6 +21,7 @@ pub mod abi { mod ic; pub mod backend; +pub mod buffer; pub mod constants; pub mod decode; pub mod fork; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 1458e3e4621d2..2572108972b17 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -20,6 +20,7 @@ interface Vm { 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; } function _expectCheatcodeRevert() external; function _expectCheatcodeRevert(bytes4 revertData) external; function _expectCheatcodeRevert(bytes calldata revertData) external; @@ -438,12 +439,14 @@ interface Vm { function startBroadcast() external; function startBroadcast(address signer) external; function startBroadcast(uint256 privateKey) external; + function startDebugTraceRecording() external; function startMappingRecording() external; function startPrank(address msgSender) external; function startPrank(address msgSender, address txOrigin) external; function startSnapshotGas(string calldata name) external; function startSnapshotGas(string calldata group, string calldata name) external; function startStateDiffRecording() external; + function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step); function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses); function stopBroadcast() external; function stopExpectSafeMemory() external; diff --git a/testdata/default/cheats/RecordDebugTrace.t.sol b/testdata/default/cheats/RecordDebugTrace.t.sol new file mode 100644 index 0000000000000..ade2e7aafb7e1 --- /dev/null +++ b/testdata/default/cheats/RecordDebugTrace.t.sol @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract MStoreAndMLoadCaller { + uint256 public constant expectedValueInMemory = 999; + + uint256 public memPtr; // the memory pointer being used + + function storeAndLoadValueFromMemory() public returns (uint256) { + uint256 mPtr; + assembly { + mPtr := mload(0x40) // load free pointer + mstore(mPtr, expectedValueInMemory) + mstore(0x40, add(mPtr, 0x20)) + } + + // record & expose the memory pointer location + memPtr = mPtr; + + uint256 result = 123; + assembly { + // override with `expectedValueInMemory` + result := mload(mPtr) + } + return result; + } +} + +contract FirstLayer { + SecondLayer secondLayer; + + constructor(SecondLayer _secondLayer) { + secondLayer = _secondLayer; + } + + function callSecondLayer() public view returns (uint256) { + return secondLayer.endHere(); + } +} + +contract SecondLayer { + uint256 public constant endNumber = 123; + + function endHere() public view returns (uint256) { + return endNumber; + } +} + +contract OutOfGas { + uint256 dummyVal = 0; + + function consumeGas() public { + dummyVal += 1; + } + + function triggerOOG() public { + bytes memory encodedFunctionCall = abi.encodeWithSignature("consumeGas()", ""); + uint256 notEnoughGas = 50; + (bool success,) = address(this).call{gas: notEnoughGas}(encodedFunctionCall); + require(!success, "it should error out of gas"); + } +} + +contract RecordDebugTraceTest is DSTest { + Vm constant cheats = Vm(HEVM_ADDRESS); + /** + * The goal of this test is to ensure the debug steps provide the correct OPCODE with its stack + * and memory input used. The test checke MSTORE and MLOAD and ensure it records the expected + * stack and memory inputs. + */ + + function testDebugTraceCanRecordOpcodeWithStackAndMemoryData() public { + MStoreAndMLoadCaller testContract = new MStoreAndMLoadCaller(); + + cheats.startDebugTraceRecording(); + + uint256 val = testContract.storeAndLoadValueFromMemory(); + assertTrue(val == testContract.expectedValueInMemory()); + + Vm.DebugStep[] memory steps = cheats.stopAndReturnDebugTraceRecording(); + + bool mstoreCalled = false; + bool mloadCalled = false; + + for (uint256 i = 0; i < steps.length; i++) { + Vm.DebugStep memory step = steps[i]; + if ( + step.opcode == 0x52 /*MSTORE*/ && step.stack[0] == testContract.memPtr() // MSTORE offset + && step.stack[1] == testContract.expectedValueInMemory() // MSTORE val + ) { + mstoreCalled = true; + } + + if ( + step.opcode == 0x51 /*MLOAD*/ && step.stack[0] == testContract.memPtr() // MLOAD offset + && step.memoryInput.length == 32 // MLOAD should always load 32 bytes + && uint256(bytes32(step.memoryInput)) == testContract.expectedValueInMemory() // MLOAD value + ) { + mloadCalled = true; + } + } + + assertTrue(mstoreCalled); + assertTrue(mloadCalled); + } + + /** + * This test tests that the cheatcode can correctly record the depth of the debug steps. + * This is test by test -> FirstLayer -> SecondLayer and check that the + * depth of the FirstLayer and SecondLayer are all as expected. + */ + function testDebugTraceCanRecordDepth() public { + SecondLayer second = new SecondLayer(); + FirstLayer first = new FirstLayer(second); + + cheats.startDebugTraceRecording(); + + first.callSecondLayer(); + + Vm.DebugStep[] memory steps = cheats.stopAndReturnDebugTraceRecording(); + + bool goToDepthTwo = false; + bool goToDepthThree = false; + for (uint256 i = 0; i < steps.length; i++) { + Vm.DebugStep memory step = steps[i]; + + if (step.depth == 2) { + assertTrue(step.contractAddr == address(first), "must be first layer on depth 2"); + goToDepthTwo = true; + } + + if (step.depth == 3) { + assertTrue(step.contractAddr == address(second), "must be second layer on depth 3"); + goToDepthThree = true; + } + } + assertTrue(goToDepthTwo && goToDepthThree, "must have been to both first and second layer"); + } + + /** + * The goal of this test is to ensure it can return expected `isOutOfGas` flag. + * It is tested with out of gas result here. + */ + function testDebugTraceCanRecordOutOfGas() public { + OutOfGas testContract = new OutOfGas(); + + cheats.startDebugTraceRecording(); + + testContract.triggerOOG(); + + Vm.DebugStep[] memory steps = cheats.stopAndReturnDebugTraceRecording(); + + bool isOOG = false; + for (uint256 i = 0; i < steps.length; i++) { + Vm.DebugStep memory step = steps[i]; + + if (step.isOutOfGas) { + isOOG = true; + } + } + assertTrue(isOOG, "should OOG"); + } +} From 92702e9c0db4e76ddd7917fae4f74427a7e728f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:05:56 +0200 Subject: [PATCH 1543/1963] feat(`forge doc`): include @custom natspec (#9075) * feat(`forge doc`): include @custom natspec * chore: make clippy happy * test: implement test for `is_custom` * chore: make rustfmt happy * doc: nit * chore: format custom tags --- crates/doc/src/parser/comment.rs | 44 +++++++++++++++++++++++++++++--- crates/doc/src/writer/as_doc.rs | 26 ++++++++++++++----- 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index 13184112e6e04..4954cd7cdee18 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -96,6 +96,11 @@ impl Comment { }, ) } + + /// Check if this comment is a custom tag. + pub fn is_custom(&self) -> bool { + matches!(self.tag, CommentTag::Custom(_)) + } } /// The collection of natspec [Comment] items. @@ -157,18 +162,18 @@ impl From> for Comments { pub struct CommentsRef<'a>(Vec<&'a Comment>); impl<'a> CommentsRef<'a> { - /// Filter a collection of comments and return only those that match a provided tag + /// Filter a collection of comments and return only those that match a provided tag. pub fn include_tag(&self, tag: CommentTag) -> Self { self.include_tags(&[tag]) } - /// Filter a collection of comments and return only those that match provided tags + /// Filter a collection of comments and return only those that match provided tags. pub fn include_tags(&self, tags: &[CommentTag]) -> Self { // Cloning only references here CommentsRef(self.iter().cloned().filter(|c| tags.contains(&c.tag)).collect()) } - /// Filter a collection of comments and return only those that do not match provided tags + /// Filter a collection of comments and return only those that do not match provided tags. pub fn exclude_tags(&self, tags: &[CommentTag]) -> Self { // Cloning only references here CommentsRef(self.iter().cloned().filter(|c| !tags.contains(&c.tag)).collect()) @@ -192,6 +197,11 @@ impl<'a> CommentsRef<'a> { .find(|c| matches!(c.tag, CommentTag::Inheritdoc)) .and_then(|c| c.value.split_whitespace().next()) } + + /// Filter a collection of comments and only return the custom tags. + pub fn get_custom_tags(&self) -> Self { + CommentsRef(self.iter().cloned().filter(|c| c.is_custom()).collect()) + } } impl<'a> From<&'a Comments> for CommentsRef<'a> { @@ -228,4 +238,32 @@ mod tests { assert_eq!(CommentTag::from_str("custom"), None); assert_eq!(CommentTag::from_str("sometag"), None); } + + #[test] + fn test_is_custom() { + // Test custom tag. + let custom_comment = Comment::new( + CommentTag::from_str("custom:test").unwrap(), + "dummy custom tag".to_owned(), + ); + assert!(custom_comment.is_custom(), "Custom tag should return true for is_custom"); + + // Test non-custom tags. + let non_custom_tags = [ + CommentTag::Title, + CommentTag::Author, + CommentTag::Notice, + CommentTag::Dev, + CommentTag::Param, + CommentTag::Return, + CommentTag::Inheritdoc, + ]; + for tag in non_custom_tags { + let comment = Comment::new(tag.clone(), "Non-custom comment".to_string()); + assert!( + !comment.is_custom(), + "Non-custom tag {tag:?} should return false for is_custom" + ); + } + } } diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index 50a847beb32c1..d68f7a8e502c6 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -46,18 +46,32 @@ impl AsDoc for CommentsRef<'_> { // Write notice tags let notices = self.include_tag(CommentTag::Notice); - for notice in notices.iter() { - writer.writeln_raw(¬ice.value)?; + for n in notices.iter() { + writer.writeln_raw(&n.value)?; writer.writeln()?; } // Write dev tags let devs = self.include_tag(CommentTag::Dev); - for dev in devs.iter() { - writer.write_italic(&dev.value)?; + for d in devs.iter() { + writer.write_italic(&d.value)?; writer.writeln()?; } + // Write custom tags + let customs = self.get_custom_tags(); + if !customs.is_empty() { + writer.write_bold(&format!("Note{}:", if customs.len() == 1 { "" } else { "s" }))?; + for c in customs.iter() { + writer.writeln_raw(format!( + "{}{}", + if customs.len() == 1 { "" } else { "- " }, + &c.value + ))?; + writer.writeln()?; + } + } + Ok(writer.finish()) } } @@ -234,7 +248,7 @@ impl AsDoc for Document { func.params.iter().filter_map(|p| p.1.as_ref()).collect::>(); writer.try_write_param_table(CommentTag::Param, ¶ms, &item.comments)?; - // Write function parameter comments in a table + // Write function return parameter comments in a table let returns = func.returns.iter().filter_map(|p| p.1.as_ref()).collect::>(); writer.try_write_param_table( @@ -303,7 +317,7 @@ impl Document { let params = func.params.iter().filter_map(|p| p.1.as_ref()).collect::>(); writer.try_write_param_table(CommentTag::Param, ¶ms, &comments)?; - // Write function parameter comments in a table + // Write function return parameter comments in a table let returns = func.returns.iter().filter_map(|p| p.1.as_ref()).collect::>(); writer.try_write_param_table(CommentTag::Return, &returns, &comments)?; From f79c53c4e41958809ee1f3473466f184bb34c195 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 9 Oct 2024 20:25:35 +0400 Subject: [PATCH 1544/1963] chore: add alias (#9082) add alias --- crates/anvil/src/cmd.rs | 2 +- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/run.rs | 2 +- crates/common/src/evm.rs | 2 +- crates/config/src/lib.rs | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 76eb0510a5916..13182686a3335 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -581,7 +581,7 @@ pub struct AnvilEvmArgs { pub memory_limit: Option, /// Enable Alphanet features - #[arg(long, visible_alias = "alphanet")] + #[arg(long, visible_alias = "odyssey")] pub alphanet: bool, } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 9afc7ff5ae35e..fe0a244df2133 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -74,7 +74,7 @@ pub struct CallArgs { json: bool, /// Enable Alphanet features. - #[arg(long)] + #[arg(long, alias = "odyssey")] pub alphanet: bool, #[command(subcommand)] diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 7d7c922b4b6d5..9d04ed1e2c1fd 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -84,7 +84,7 @@ pub struct RunArgs { pub no_rate_limit: bool, /// Enables Alphanet features. - #[arg(long)] + #[arg(long, alias = "odyssey")] pub alphanet: bool, } diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 30bcd4d0918a3..e738cc6ddce30 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -147,7 +147,7 @@ pub struct EvmArgs { pub isolate: bool, /// Whether to enable Alphanet features. - #[arg(long)] + #[arg(long, alias = "odyssey")] #[serde(skip)] pub alphanet: bool, } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 648d40e66625e..d70a8dab401fe 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2447,6 +2447,10 @@ impl Provider for BackwardsCompatTomlProvider

{ dict.insert("solc".to_string(), v); } } + + if let Some(v) = dict.remove("odyssey") { + dict.insert("alphanet".to_string(), v); + } map.insert(profile, dict); } Ok(map) From 4065d38cec998608a3e3042a7c577f72fb586ed4 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 10 Oct 2024 06:47:52 +0300 Subject: [PATCH 1545/1963] fix(chisel): final statement & fetch err with complex type fixes (#9081) * fix(chisel): consider assembly block return as final statement * Fix 4938 * Start from first assembly block when checking for return statement * Fix 6618 --- crates/chisel/src/dispatcher.rs | 19 +++++++++++++++++-- crates/chisel/src/executor.rs | 31 +++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 0f2b7afe38b6a..22ad242d091f1 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -10,7 +10,7 @@ use crate::{ }, session_source::SessionSource, }; -use alloy_json_abi::JsonAbi; +use alloy_json_abi::{InternalType, JsonAbi}; use alloy_primitives::{hex, Address}; use forge_fmt::FormatterConfig; use foundry_config::{Config, RpcEndpoint}; @@ -528,7 +528,22 @@ impl ChiselDispatcher { err.name, err.inputs .iter() - .map(|input| format_param!(input)) + .map(|input| { + let mut param_type = &input.ty; + // If complex type then add the name of custom type. + // see . + if input.is_complex_type() { + if let Some( + InternalType::Enum { contract: _, ty } | + InternalType::Struct { contract: _, ty } | + InternalType::Other { contract: _, ty }, + ) = &input.internal_type + { + param_type = ty; + } + } + format!("{} {}", param_type, input.name) + }) .collect::>() .join(",") )); diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 16387a69b5897..b63ebe3e41137 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -49,6 +49,22 @@ impl SessionSource { // Fetch the run function's body statement let run_func_statements = compiled.intermediate.run_func_body()?; + // Record loc of first yul block return statement (if any). + // This is used to decide which is the final statement within the `run()` method. + // see . + let last_yul_return = run_func_statements.iter().find_map(|statement| { + if let pt::Statement::Assembly { loc: _, dialect: _, flags: _, block } = statement { + if let Some(statement) = block.statements.last() { + if let pt::YulStatement::FunctionCall(yul_call) = statement { + if yul_call.id.name == "return" { + return Some(statement.loc()) + } + } + } + } + None + }); + // Find the last statement within the "run()" method and get the program // counter via the source map. if let Some(final_statement) = run_func_statements.last() { @@ -58,9 +74,13 @@ impl SessionSource { // // There is some code duplication within the arms due to the difference between // the [pt::Statement] type and the [pt::YulStatement] types. - let source_loc = match final_statement { + let mut source_loc = match final_statement { pt::Statement::Assembly { loc: _, dialect: _, flags: _, block } => { - if let Some(statement) = block.statements.last() { + // Select last non variable declaration statement, see . + let last_statement = block.statements.iter().rev().find(|statement| { + !matches!(statement, pt::YulStatement::VariableDeclaration(_, _, _)) + }); + if let Some(statement) = last_statement { statement.loc() } else { // In the case where the block is empty, attempt to grab the statement @@ -88,6 +108,13 @@ impl SessionSource { _ => final_statement.loc(), }; + // Consider yul return statement as final statement (if it's loc is lower) . + if let Some(yul_return) = last_yul_return { + if yul_return.end() < source_loc.start() { + source_loc = yul_return; + } + } + // Map the source location of the final statement of the `run()` function to its // corresponding runtime program counter let final_pc = { From 15fdb2a19ee2a038f7e72523c6a0b0c3cdc6c3e4 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:40:55 +0300 Subject: [PATCH 1546/1963] feat(chisel): add eval command (#9086) --- crates/chisel/bin/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index ba4d7e9bc336b..70425279484a7 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -92,6 +92,12 @@ pub enum ChiselSubcommand { /// Clear all cached chisel sessions from the cache directory ClearCache, + + /// Simple evaluation of a command without entering the REPL + Eval { + /// The command to be evaluated. + command: String, + }, } fn main() -> eyre::Result<()> { @@ -168,6 +174,10 @@ async fn main_args(args: Chisel) -> eyre::Result<()> { } return Ok(()) } + Some(ChiselSubcommand::Eval { command }) => { + dispatch_repl_line(&mut dispatcher, command).await; + return Ok(()) + } None => { /* No chisel subcommand present; Continue */ } } From 0ec018d34dc43600201d07386eaed41f97887028 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:06:07 +0200 Subject: [PATCH 1547/1963] feat: make `--gas-report` JSON output compatible (#9063) * add gas report generation in JSON * skip junit for now * add json formatted tests, trailing space and invalid formatting * avoid redundant modifications for calls count * replace existing tests with snapbox * clean up snapbox tests * merge in master * calls -> frames * use .is_jsonlines() --- crates/forge/bin/cmd/test/mod.rs | 71 +++-- crates/forge/src/gas_report.rs | 43 ++- crates/forge/tests/cli/cmd.rs | 523 +++++++++++++++++-------------- 3 files changed, 367 insertions(+), 270 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index f83d336ed69b6..7038fc0b5a8b0 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -5,7 +5,7 @@ use clap::{Parser, ValueHint}; use eyre::{Context, OptionExt, Result}; use forge::{ decode::decode_console_logs, - gas_report::GasReport, + gas_report::{GasReport, GasReportKind}, multi_runner::matches_contract, result::{SuiteResult, TestOutcome, TestStatus}, traces::{ @@ -112,7 +112,7 @@ pub struct TestArgs { json: bool, /// Output test results as JUnit XML report. - #[arg(long, conflicts_with = "json", help_heading = "Display options")] + #[arg(long, conflicts_with_all(["json", "gas_report"]), help_heading = "Display options")] junit: bool, /// Stop running tests after the first failure. @@ -474,6 +474,9 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); + // If we need to render to a serialized format, we should not print anything else to stdout. + let silent = self.gas_report && self.json; + let num_filtered = runner.matching_test_functions(filter).count(); if num_filtered != 1 && (self.debug.is_some() || self.flamegraph || self.flamechart) { let action = if self.flamegraph { @@ -500,7 +503,7 @@ impl TestArgs { } // Run tests in a non-streaming fashion and collect results for serialization. - if self.json { + if !self.gas_report && self.json { let mut results = runner.test_collect(filter); results.values_mut().for_each(|suite_result| { for test_result in suite_result.test_results.values_mut() { @@ -565,9 +568,13 @@ impl TestArgs { } let mut decoder = builder.build(); - let mut gas_report = self - .gas_report - .then(|| GasReport::new(config.gas_reports.clone(), config.gas_reports_ignore.clone())); + let mut gas_report = self.gas_report.then(|| { + GasReport::new( + config.gas_reports.clone(), + config.gas_reports_ignore.clone(), + if self.json { GasReportKind::JSON } else { GasReportKind::Markdown }, + ) + }); let mut gas_snapshots = BTreeMap::>::new(); @@ -588,30 +595,34 @@ impl TestArgs { self.flamechart; // Print suite header. - println!(); - for warning in suite_result.warnings.iter() { - eprintln!("{} {warning}", "Warning:".yellow().bold()); - } - if !tests.is_empty() { - let len = tests.len(); - let tests = if len > 1 { "tests" } else { "test" }; - println!("Ran {len} {tests} for {contract_name}"); + if !silent { + println!(); + for warning in suite_result.warnings.iter() { + eprintln!("{} {warning}", "Warning:".yellow().bold()); + } + if !tests.is_empty() { + let len = tests.len(); + let tests = if len > 1 { "tests" } else { "test" }; + println!("Ran {len} {tests} for {contract_name}"); + } } // Process individual test results, printing logs and traces when necessary. for (name, result) in tests { - shell::println(result.short_result(name))?; - - // We only display logs at level 2 and above - if verbosity >= 2 { - // We only decode logs from Hardhat and DS-style console events - let console_logs = decode_console_logs(&result.logs); - if !console_logs.is_empty() { - println!("Logs:"); - for log in console_logs { - println!(" {log}"); + if !silent { + shell::println(result.short_result(name))?; + + // We only display logs at level 2 and above + if verbosity >= 2 { + // We only decode logs from Hardhat and DS-style console events + let console_logs = decode_console_logs(&result.logs); + if !console_logs.is_empty() { + println!("Logs:"); + for log in console_logs { + println!(" {log}"); + } + println!(); } - println!(); } } @@ -653,7 +664,7 @@ impl TestArgs { } } - if !decoded_traces.is_empty() { + if !silent && !decoded_traces.is_empty() { shell::println("Traces:")?; for trace in &decoded_traces { shell::println(trace)?; @@ -760,7 +771,9 @@ impl TestArgs { } // Print suite summary. - shell::println(suite_result.summary())?; + if !silent { + shell::println(suite_result.summary())?; + } // Add the suite result to the outcome. outcome.results.insert(contract_name, suite_result); @@ -781,7 +794,7 @@ impl TestArgs { outcome.gas_report = Some(finalized); } - if !outcome.results.is_empty() { + if !silent && !outcome.results.is_empty() { shell::println(outcome.summary(duration))?; if self.summary { @@ -1063,7 +1076,7 @@ contract FooBarTest is DSTest { let call_cnts = gas_report .contracts .values() - .flat_map(|c| c.functions.values().flat_map(|f| f.values().map(|v| v.calls.len()))) + .flat_map(|c| c.functions.values().flat_map(|f| f.values().map(|v| v.frames.len()))) .collect::>(); // assert that all functions were called at least 100 times assert!(call_cnts.iter().all(|c| *c > 100)); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index ff7628bd5c4fc..59c417b970975 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -12,11 +12,25 @@ use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, fmt::Display}; use yansi::Paint; +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] +pub enum GasReportKind { + Markdown, + JSON, +} + +impl Default for GasReportKind { + fn default() -> Self { + Self::Markdown + } +} + /// Represents the gas report for a set of contracts. #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct GasReport { /// Whether to report any contracts. report_any: bool, + /// What kind of report to generate. + report_type: GasReportKind, /// Contracts to generate the report for. report_for: HashSet, /// Contracts to ignore when generating the report. @@ -30,11 +44,13 @@ impl GasReport { pub fn new( report_for: impl IntoIterator, ignore: impl IntoIterator, + report_kind: GasReportKind, ) -> Self { let report_for = report_for.into_iter().collect::>(); let ignore = ignore.into_iter().collect::>(); let report_any = report_for.is_empty() || report_for.contains("*"); - Self { report_any, report_for, ignore, ..Default::default() } + let report_type = report_kind; + Self { report_any, report_type, report_for, ignore, ..Default::default() } } /// Whether the given contract should be reported. @@ -113,7 +129,7 @@ impl GasReport { .or_default() .entry(signature.clone()) .or_default(); - gas_info.calls.push(trace.gas_used); + gas_info.frames.push(trace.gas_used); } } } @@ -125,11 +141,12 @@ impl GasReport { for contract in self.contracts.values_mut() { for sigs in contract.functions.values_mut() { for func in sigs.values_mut() { - func.calls.sort_unstable(); - func.min = func.calls.first().copied().unwrap_or_default(); - func.max = func.calls.last().copied().unwrap_or_default(); - func.mean = calc::mean(&func.calls); - func.median = calc::median_sorted(&func.calls); + func.frames.sort_unstable(); + func.min = func.frames.first().copied().unwrap_or_default(); + func.max = func.frames.last().copied().unwrap_or_default(); + func.mean = calc::mean(&func.frames); + func.median = calc::median_sorted(&func.frames); + func.calls = func.frames.len() as u64; } } } @@ -145,6 +162,11 @@ impl Display for GasReport { continue; } + if self.report_type == GasReportKind::JSON { + writeln!(f, "{}", serde_json::to_string(&contract).unwrap())?; + continue; + } + let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); table.set_header([Cell::new(format!("{name} contract")) @@ -176,7 +198,7 @@ impl Display for GasReport { Cell::new(gas_info.mean.to_string()).fg(Color::Yellow), Cell::new(gas_info.median.to_string()).fg(Color::Yellow), Cell::new(gas_info.max.to_string()).fg(Color::Red), - Cell::new(gas_info.calls.len().to_string()), + Cell::new(gas_info.calls.to_string()), ]); }) }); @@ -197,9 +219,12 @@ pub struct ContractInfo { #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct GasInfo { - pub calls: Vec, + pub calls: u64, pub min: u64, pub mean: u64, pub median: u64, pub max: u64, + + #[serde(skip)] + pub frames: Vec, } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 6c8bab9289f6c..61a5aeab89422 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -8,6 +8,7 @@ use foundry_config::{ use foundry_test_utils::{ foundry_compilers::PathStyle, rpc::next_mainnet_etherscan_api_key, + snapbox::IntoData, util::{pretty_err, read_string, OutputExt, TestCommand}, }; use semver::Version; @@ -1434,11 +1435,7 @@ Compiler run successful! } ); -forgetest!(gas_report_all_contracts, |prj, cmd| { - prj.insert_ds_test(); - prj.add_source( - "Contracts.sol", - r#" +const GAS_REPORT_CONTRACTS: &str = r#" //SPDX-license-identifier: MIT import "./test.sol"; @@ -1521,9 +1518,11 @@ contract ContractThreeTest is DSTest { c3.baz(); } } - "#, - ) - .unwrap(); +"#; + +forgetest!(gas_report_all_contracts, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // report for all prj.write_config(Config { @@ -1532,34 +1531,121 @@ contract ContractThreeTest is DSTest { ..Default::default() }); - let first_out = cmd - .forge_fuse() + cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractOne contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| foo | 45387 | 45387 | 45387 | 45387 | 1 | + + +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | + + +| src/Contracts.sol:ContractTwo contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| bar | 64984 | 64984 | 64984 | 64984 | 1 | +... + +"#]]); + cmd.forge_fuse() .arg("test") .arg("--gas-report") + .arg("--json") .assert_success() - .get_output() - .stdout_lossy(); - assert!(first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); + .stdout_eq(str![[r#" +{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} +"#]].is_jsonlines()); prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); - let second_out = cmd - .forge_fuse() + cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractOne contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| foo | 45387 | 45387 | 45387 | 45387 | 1 | + + +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | + + +| src/Contracts.sol:ContractTwo contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| bar | 64984 | 64984 | 64984 | 64984 | 1 | +... + +"#]]); + cmd.forge_fuse() .arg("test") .arg("--gas-report") + .arg("--json") .assert_success() - .get_output() - .stdout_lossy(); - assert!(second_out.contains("foo") && second_out.contains("bar") && second_out.contains("baz")); + .stdout_eq(str![[r#" +{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} +"#]].is_jsonlines()); prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); - let third_out = cmd - .forge_fuse() + cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractOne contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| foo | 45387 | 45387 | 45387 | 45387 | 1 | + + +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | + + +| src/Contracts.sol:ContractTwo contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| bar | 64984 | 64984 | 64984 | 64984 | 1 | +... + +"#]]); + cmd.forge_fuse() .arg("test") .arg("--gas-report") + .arg("--json") .assert_success() - .get_output() - .stdout_lossy(); - assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); + .stdout_eq(str![[r#" +{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} +"#]].is_jsonlines()); prj.write_config(Config { gas_reports: (vec![ @@ -1569,125 +1655,90 @@ contract ContractThreeTest is DSTest { ]), ..Default::default() }); - let fourth_out = cmd - .forge_fuse() + cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractOne contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| foo | 45387 | 45387 | 45387 | 45387 | 1 | + + +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | + + +| src/Contracts.sol:ContractTwo contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| bar | 64984 | 64984 | 64984 | 64984 | 1 | +... + +"#]]); + cmd.forge_fuse() .arg("test") .arg("--gas-report") + .arg("--json") .assert_success() - .get_output() - .stdout_lossy(); - assert!(fourth_out.contains("foo") && fourth_out.contains("bar") && fourth_out.contains("baz")); + .stdout_eq(str![[r#" +{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} +"#]].is_jsonlines()); }); forgetest!(gas_report_some_contracts, |prj, cmd| { prj.insert_ds_test(); - prj.add_source( - "Contracts.sol", - r#" -//SPDX-license-identifier: MIT - -import "./test.sol"; - -contract ContractOne { - int public i; - - constructor() { - i = 0; - } - - function foo() public{ - while(i<5){ - i++; - } - } -} - -contract ContractOneTest is DSTest { - ContractOne c1; - - function setUp() public { - c1 = new ContractOne(); - } - - function testFoo() public { - c1.foo(); - } -} - - -contract ContractTwo { - int public i; - - constructor() { - i = 0; - } - - function bar() public{ - while(i<50){ - i++; - } - } -} - -contract ContractTwoTest is DSTest { - ContractTwo c2; - - function setUp() public { - c2 = new ContractTwo(); - } - - function testBar() public { - c2.bar(); - } -} - -contract ContractThree { - int public i; - - constructor() { - i = 0; - } - - function baz() public{ - while(i<500){ - i++; - } - } -} - -contract ContractThreeTest is DSTest { - ContractThree c3; - - function setUp() public { - c3 = new ContractThree(); - } - - function testBaz() public { - c3.baz(); - } -} - "#, - ) - .unwrap(); + prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // report for One prj.write_config(Config { gas_reports: vec!["ContractOne".to_string()], ..Default::default() }); cmd.forge_fuse(); - let first_out = - cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); - assert!( - first_out.contains("foo") && !first_out.contains("bar") && !first_out.contains("baz"), - "foo:\n{first_out}" - ); + cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractOne contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| foo | 45387 | 45387 | 45387 | 45387 | 1 | +... + +"#]]); + cmd.forge_fuse() + .arg("test") + .arg("--gas-report") + .arg("--json") + .assert_success() + .stdout_eq(str![[r#" +{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} +"#]].is_jsonlines()); // report for Two prj.write_config(Config { gas_reports: vec!["ContractTwo".to_string()], ..Default::default() }); cmd.forge_fuse(); - let second_out = - cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); - assert!( - !second_out.contains("foo") && second_out.contains("bar") && !second_out.contains("baz"), - "bar:\n{second_out}" + cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractTwo contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| bar | 64984 | 64984 | 64984 | 64984 | 1 | +... + +"#]]); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} +"#]].is_jsonlines(), ); // report for Three @@ -1696,104 +1747,30 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let third_out = - cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); - assert!( - !third_out.contains("foo") && !third_out.contains("bar") && third_out.contains("baz"), - "baz:\n{third_out}" - ); + cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | +... + +"#]]); + cmd.forge_fuse() + .arg("test") + .arg("--gas-report") + .arg("--json") + .assert_success() + .stdout_eq(str![[r#" +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +"#]].is_jsonlines()); }); forgetest!(gas_ignore_some_contracts, |prj, cmd| { prj.insert_ds_test(); - prj.add_source( - "Contracts.sol", - r#" -//SPDX-license-identifier: MIT - -import "./test.sol"; - -contract ContractOne { - int public i; - - constructor() { - i = 0; - } - - function foo() public{ - while(i<5){ - i++; - } - } -} - -contract ContractOneTest is DSTest { - ContractOne c1; - - function setUp() public { - c1 = new ContractOne(); - } - - function testFoo() public { - c1.foo(); - } -} - - -contract ContractTwo { - int public i; - - constructor() { - i = 0; - } - - function bar() public{ - while(i<50){ - i++; - } - } -} - -contract ContractTwoTest is DSTest { - ContractTwo c2; - - function setUp() public { - c2 = new ContractTwo(); - } - - function testBar() public { - c2.bar(); - } -} - -contract ContractThree { - int public i; - - constructor() { - i = 0; - } - - function baz() public{ - while(i<500){ - i++; - } - } -} - -contract ContractThreeTest is DSTest { - ContractThree c3; - - function setUp() public { - c3 = new ContractThree(); - } - - function testBaz() public { - c3.baz(); - } -} - "#, - ) - .unwrap(); + prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // ignore ContractOne prj.write_config(Config { @@ -1802,9 +1779,34 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let first_out = - cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); - assert!(!first_out.contains("foo") && first_out.contains("bar") && first_out.contains("baz")); + cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | + + +| src/Contracts.sol:ContractTwo contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| bar | 64984 | 64984 | 64984 | 64984 | 1 | +... + +"#]]); + cmd.forge_fuse() + .arg("test") + .arg("--gas-report") + .arg("--json") + .assert_success() + .stdout_eq(str![[r#" +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} +"#]].is_jsonlines()); // ignore ContractTwo cmd.forge_fuse(); @@ -1814,11 +1816,34 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let second_out = - cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); - assert!( - second_out.contains("foo") && !second_out.contains("bar") && second_out.contains("baz") - ); + cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractOne contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| foo | 45387 | 45387 | 45387 | 45387 | 1 | + + +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | +... + +"#]]); + cmd.forge_fuse() + .arg("test") + .arg("--gas-report") + .arg("--json") + .assert_success() + .stdout_eq(str![[r#" +{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +"#]].is_jsonlines()); // ignore ContractThree cmd.forge_fuse(); @@ -1832,9 +1857,43 @@ contract ContractThreeTest is DSTest { ..Default::default() }); cmd.forge_fuse(); - let third_out = - cmd.arg("test").arg("--gas-report").assert_success().get_output().stdout_lossy(); - assert!(third_out.contains("foo") && third_out.contains("bar") && third_out.contains("baz")); + cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Contracts.sol:ContractOne contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| foo | 45387 | 45387 | 45387 | 45387 | 1 | + + +| src/Contracts.sol:ContractThree contract | | | | | | +|------------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103591 | 256 | | | | | +| Function Name | min | avg | median | max | # calls | +| baz | 260712 | 260712 | 260712 | 260712 | 1 | + + +| src/Contracts.sol:ContractTwo contract | | | | | | +|----------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 103375 | 255 | | | | | +| Function Name | min | avg | median | max | # calls | +| bar | 64984 | 64984 | 64984 | 64984 | 1 | +... + +"#]]); + cmd.forge_fuse() + .arg("test") + .arg("--gas-report") + .arg("--json") + .assert_success() + .stdout_eq(str![[r#" +{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} +{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} +{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} +"#]].is_jsonlines()); }); forgetest_init!(can_use_absolute_imports, |prj, cmd| { From da947073203cdf78fc9e27db12d850ac92dfabe5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:46:46 +0200 Subject: [PATCH 1548/1963] chore: replace criterion with divan (#9080) --- Cargo.lock | 237 +++++++++--------------- Cargo.toml | 52 +++--- Dockerfile | 2 +- crates/cast/Cargo.toml | 5 +- crates/cast/benches/vanity.rs | 53 ++---- crates/chisel/Cargo.toml | 5 - crates/chisel/benches/session_source.rs | 84 --------- crates/forge/Cargo.toml | 5 - crates/forge/benches/test.rs | 29 --- 9 files changed, 130 insertions(+), 342 deletions(-) delete mode 100644 crates/chisel/benches/session_source.rs delete mode 100644 crates/forge/benches/test.rs diff --git a/Cargo.lock b/Cargo.lock index 7438ab7f1acb7..ff25d3ac64608 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,12 +792,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "anstream" version = "0.6.15" @@ -1929,9 +1923,61 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" +version = "0.2.0" +dependencies = [ + "alloy-chains", + "alloy-consensus", + "alloy-contract", + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-json-rpc", + "alloy-network", + "alloy-primitives", + "alloy-provider", + "alloy-rlp", + "alloy-rpc-types", + "alloy-serde", + "alloy-signer", + "alloy-signer-local", + "alloy-sol-types", + "alloy-transport", + "anvil", + "async-trait", + "aws-sdk-kms", + "chrono", + "clap", + "clap_complete", + "clap_complete_fig", + "comfy-table", + "divan", + "dunce", + "evmole", + "eyre", + "foundry-block-explorers", + "foundry-cli", + "foundry-common", + "foundry-compilers", + "foundry-config", + "foundry-evm", + "foundry-test-utils", + "foundry-wallets", + "futures", + "indicatif", + "itertools 0.13.0", + "rand", + "rayon", + "regex", + "rpassword", + "semver 1.0.23", + "serde", + "serde_json", + "tempfile", + "tikv-jemallocator", + "tokio", + "tracing", + "vergen", + "yansi", +] [[package]] name = "castaway" @@ -1978,7 +2024,6 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types", "clap", - "criterion", "dirs 5.0.1", "eyre", "forge-fmt", @@ -2297,6 +2342,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "condtype" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af" + [[package]] name = "console" version = "0.15.8" @@ -2382,44 +2433,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "futures", - "is-terminal", - "itertools 0.10.5", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "tokio", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools 0.10.5", -] - [[package]] name = "crossbeam-channel" version = "0.5.13" @@ -2818,6 +2831,31 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "divan" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d567df2c9c2870a43f3f2bd65aaeb18dbce1c18f217c3e564b4fbaeb3ee56c" +dependencies = [ + "cfg-if", + "clap", + "condtype", + "divan-macros", + "libc", + "regex-lite", +] + +[[package]] +name = "divan-macros" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "doctest-file" version = "1.0.0" @@ -3317,7 +3355,6 @@ dependencies = [ "clap_complete_fig", "clearscreen", "comfy-table", - "criterion", "dialoguer", "dunce", "ethers-contract-abigen", @@ -3540,64 +3577,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "foundry-cast" -version = "0.2.0" -dependencies = [ - "alloy-chains", - "alloy-consensus", - "alloy-contract", - "alloy-dyn-abi", - "alloy-json-abi", - "alloy-json-rpc", - "alloy-network", - "alloy-primitives", - "alloy-provider", - "alloy-rlp", - "alloy-rpc-types", - "alloy-serde", - "alloy-signer", - "alloy-signer-local", - "alloy-sol-types", - "alloy-transport", - "anvil", - "async-trait", - "aws-sdk-kms", - "chrono", - "clap", - "clap_complete", - "clap_complete_fig", - "comfy-table", - "criterion", - "dunce", - "evmole", - "eyre", - "foundry-block-explorers", - "foundry-cli", - "foundry-common", - "foundry-compilers", - "foundry-config", - "foundry-evm", - "foundry-test-utils", - "foundry-wallets", - "futures", - "indicatif", - "itertools 0.13.0", - "rand", - "rayon", - "regex", - "rpassword", - "semver 1.0.23", - "serde", - "serde_json", - "tempfile", - "tikv-jemallocator", - "tokio", - "tracing", - "vergen", - "yansi", -] - [[package]] name = "foundry-cheatcodes" version = "0.2.0" @@ -6050,12 +6029,6 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" -[[package]] -name = "oorandom" -version = "11.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" - [[package]] name = "op-alloy-consensus" version = "0.3.3" @@ -6544,34 +6517,6 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" -[[package]] -name = "plotters" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" - -[[package]] -name = "plotters-svg" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" -dependencies = [ - "plotters-backend", -] - [[package]] name = "portable-atomic" version = "1.9.0" @@ -8604,16 +8549,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.8.0" diff --git a/Cargo.toml b/Cargo.toml index 9b660adbb1dc3..02b364e8332dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -223,13 +223,20 @@ alloy-trie = "0.6.0" op-alloy-rpc-types = "0.3.3" op-alloy-consensus = "0.3.3" -## misc -async-trait = "0.1" -auto_impl = "1" -walkdir = "2" +# macros proc-macro2 = "1.0.82" quote = "1.0" syn = "2.0" +async-trait = "0.1" +derive_more = { version = "1.0", features = ["full"] } +thiserror = "1" + +# bench +divan = "0.1" + +# misc +auto_impl = "1" +walkdir = "2" prettyplease = "0.2.20" ahash = "0.8" base64 = "0.22" @@ -237,47 +244,44 @@ chrono = { version = "0.4", default-features = false, features = [ "clock", "std", ] } +axum = "0.7" color-eyre = "0.6" -derive_more = { version = "1.0", features = ["full"] } +comfy-table = "7" dunce = "1" evm-disassembler = "0.5" +evmole = "0.5" eyre = "0.6" figment = "0.10" futures = "0.3" +hyper = "1.0" +indexmap = "2.2" itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" -parking_lot = "0.12" mesc = "0.3" +num-format = "0.4.4" +parking_lot = "0.12" +proptest = "1" rand = "0.8" +rayon = "1" +reqwest = { version = "0.12", default-features = false } semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } similar-asserts = "1.5" +soldeer-commands = "=0.4.0" strum = "0.26" -thiserror = "1" +tempfile = "3.10" +tikv-jemallocator = "0.6" +tokio = "1" toml = "0.8" +tower = "0.4" +tower-http = "0.5" tracing = "0.1" tracing-subscriber = "0.3" -vergen = { version = "8", default-features = false } -indexmap = "2.2" -tikv-jemallocator = "0.6" url = "2" -num-format = "0.4.4" +vergen = { version = "8", default-features = false } yansi = { version = "1.0", features = ["detect-tty", "detect-env"] } -tempfile = "3.10" -tokio = "1" -rayon = "1" -evmole = "0.5" -axum = "0.7" -hyper = "1.0" -reqwest = { version = "0.12", default-features = false } -tower = "0.4" -tower-http = "0.5" -# soldeer -soldeer-commands = "=0.4.0" -proptest = "1" -comfy-table = "7" [patch.crates-io] ## alloy-core diff --git a/Dockerfile b/Dockerfile index 87e52b70861c0..14415acbcf18d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ COPY . . RUN git update-index --force-write-index RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/root/.cargo/git --mount=type=cache,target=/opt/foundry/target \ - source $HOME/.profile && cargo build --release --features foundry-cast/aws-kms,forge/aws-kms \ + source $HOME/.profile && cargo build --release --features cast/aws-kms,forge/aws-kms \ && mkdir out \ && mv target/release/forge out/forge \ && mv target/release/cast out/cast \ diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 9f0b6758c11c9..5fadb49675cea 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "foundry-cast" +name = "cast" description = "Command-line tool for performing Ethereum RPC calls" version.workspace = true @@ -89,8 +89,9 @@ tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true + async-trait.workspace = true -criterion = "0.5" +divan.workspace = true [features] default = ["rustls", "jemalloc"] diff --git a/crates/cast/benches/vanity.rs b/crates/cast/benches/vanity.rs index 4311b5283a74e..a39e4d8bcabfd 100644 --- a/crates/cast/benches/vanity.rs +++ b/crates/cast/benches/vanity.rs @@ -1,51 +1,22 @@ -use criterion::{criterion_group, criterion_main, Criterion}; use rayon::prelude::*; -use std::{hint::black_box, time::Duration}; +use std::hint::black_box; #[path = "../bin/cmd/wallet/mod.rs"] #[allow(unused)] mod wallet; use wallet::vanity::*; -/// Benches `cast wallet vanity` -/// -/// Left or right matchers, with or without nonce do not change the outcome. -/// -/// Regex matchers get optimised away even with a black_box. -fn vanity(c: &mut Criterion) { - let mut g = c.benchmark_group("vanity"); - - g.sample_size(500); - g.noise_threshold(0.04); - g.measurement_time(Duration::from_secs(30)); - - g.bench_function("wallet generator", |b| b.iter(|| black_box(generate_wallet()))); - - // 1 - - g.sample_size(100); - g.noise_threshold(0.02); - - g.bench_function("match 1", |b| { - let m = LeftHexMatcher { left: vec![0] }; - let matcher = create_matcher(m); - b.iter(|| wallet_generator().find_any(|x| black_box(matcher(x)))) - }); - - // 2 - - g.sample_size(10); - g.noise_threshold(0.01); - g.measurement_time(Duration::from_secs(60)); - - g.bench_function("match 2", |b| { - let m = LeftHexMatcher { left: vec![0, 0] }; - let matcher = create_matcher(m); - b.iter(|| wallet_generator().find_any(|x| black_box(matcher(x)))) - }); +#[divan::bench] +fn vanity_wallet_generator() -> GeneratedWallet { + generate_wallet() +} - g.finish(); +#[divan::bench(args = [&[0][..]])] +fn vanity_match(bencher: divan::Bencher<'_, '_>, arg: &[u8]) { + let matcher = create_matcher(LeftHexMatcher { left: arg.to_vec() }); + bencher.bench_local(|| wallet_generator().find_any(|x| black_box(matcher(x)))); } -criterion_group!(vanity_benches, vanity); -criterion_main!(vanity_benches); +fn main() { + divan::main(); +} diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 5d8ad4d2c4dd1..7868137d85caf 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -68,7 +68,6 @@ tracing.workspace = true tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] -criterion = { version = "0.5", features = ["async_tokio"] } serial_test = "3" tracing-subscriber.workspace = true @@ -78,7 +77,3 @@ rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-compilers/openssl", "reqwest/default-tls"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] - -[[bench]] -name = "session_source" -harness = false diff --git a/crates/chisel/benches/session_source.rs b/crates/chisel/benches/session_source.rs deleted file mode 100644 index 49d127c4728e5..0000000000000 --- a/crates/chisel/benches/session_source.rs +++ /dev/null @@ -1,84 +0,0 @@ -use chisel::session_source::{SessionSource, SessionSourceConfig}; -use criterion::{criterion_group, Criterion}; -use foundry_compilers::solc::Solc; -use semver::Version; -use std::{hint::black_box, sync::LazyLock}; -use tokio::runtime::Runtime; - -static SOLC: LazyLock = - LazyLock::new(|| Solc::find_or_install(&Version::new(0, 8, 19)).unwrap()); - -/// Benchmark for the `clone_with_new_line` function in [SessionSource] -fn clone_with_new_line(c: &mut Criterion) { - let mut g = c.benchmark_group("session_source"); - - // Grab an empty session source - g.bench_function("clone_with_new_line", |b| { - b.iter(|| { - let session_source = get_empty_session_source(); - let new_line = String::from("uint a = 1"); - black_box(session_source.clone_with_new_line(new_line).unwrap()); - }) - }); -} - -/// Benchmark for the `build` function in [SessionSource] -fn build(c: &mut Criterion) { - let mut g = c.benchmark_group("session_source"); - - g.bench_function("build", |b| { - b.iter(|| { - // Grab an empty session source - let mut session_source = get_empty_session_source(); - black_box(session_source.build().unwrap()) - }) - }); -} - -/// Benchmark for the `execute` function in [SessionSource] -fn execute(c: &mut Criterion) { - let mut g = c.benchmark_group("session_source"); - - g.bench_function("execute", |b| { - b.to_async(rt()).iter(|| async { - // Grab an empty session source - let mut session_source = get_empty_session_source(); - black_box(session_source.execute().await.unwrap()) - }) - }); -} - -/// Benchmark for the `inspect` function in [SessionSource] -fn inspect(c: &mut Criterion) { - let mut g = c.benchmark_group("session_source"); - - g.bench_function("inspect", |b| { - b.to_async(rt()).iter(|| async { - // Grab an empty session source - let mut session_source = get_empty_session_source(); - // Add a uint named "a" with value 1 to the session source - session_source.with_run_code("uint a = 1"); - black_box(session_source.inspect("a").await.unwrap()) - }) - }); -} - -/// Helper function for getting an empty [SessionSource] with default configuration -fn get_empty_session_source() -> SessionSource { - SessionSource::new(SOLC.clone(), SessionSourceConfig::default()) -} - -fn rt() -> Runtime { - Runtime::new().unwrap() -} - -fn main() { - // Install before benches if not present - let _ = LazyLock::force(&SOLC); - - session_source_benches(); - - Criterion::default().configure_from_args().final_summary() -} - -criterion_group!(session_source_benches, clone_with_new_line, build, execute, inspect); diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 0e359191aabf3..1b716497a45e1 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -117,7 +117,6 @@ anvil.workspace = true foundry-test-utils.workspace = true mockall = "0.13" -criterion = "0.5" globset = "0.4" paste = "1.0" path-slash = "0.2" @@ -143,7 +142,3 @@ asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] aws-kms = ["foundry-wallets/aws-kms"] isolate-by-default = ["foundry-config/isolate-by-default"] - -[[bench]] -name = "test" -harness = false diff --git a/crates/forge/benches/test.rs b/crates/forge/benches/test.rs deleted file mode 100644 index 593bce3d320d5..0000000000000 --- a/crates/forge/benches/test.rs +++ /dev/null @@ -1,29 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; -use foundry_test_utils::{ - util::{lossy_string, setup_forge_remote}, - TestCommand, TestProject, -}; - -/// Returns a cloned and `forge built` `solmate` project -fn built_solmate() -> (TestProject, TestCommand) { - setup_forge_remote("transmissions11/solmate") -} - -fn forge_test_benchmark(c: &mut Criterion) { - let (prj, _) = built_solmate(); - - let mut group = c.benchmark_group("forge test"); - group.sample_size(10); - group.bench_function("solmate", |b| { - let mut cmd = prj.forge_command(); - cmd.arg("test"); - b.iter(|| { - let output = cmd.execute(); - println!("stdout:\n{}", lossy_string(&output.stdout)); - println!("\nstderr:\n{}", lossy_string(&output.stderr)); - }); - }); -} - -criterion_group!(benches, forge_test_benchmark); -criterion_main!(benches); From 0ed43cefa9c9cb93fa9f9b18ff73d04c1a07cf56 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:58:28 +0200 Subject: [PATCH 1549/1963] chore: reduce length of a common error message (#9089) --- crates/cli/src/utils/mod.rs | 5 +---- crates/forge/tests/cli/cmd.rs | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 736793e67cd52..af3c5e0a5dd9c 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -463,10 +463,7 @@ and it requires clean working and staging areas, including no untracked files. Check the current git repository's status with `git status`. Then, you can track files with `git add ...` and then commit them with `git commit`, -ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag. - -If none of the previous steps worked, please open an issue at: -https://github.com/foundry-rs/foundry/issues/new/choose" +ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag." )) } } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 61a5aeab89422..d82600b6251ab 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -261,9 +261,6 @@ Check the current git repository's status with `git status`. Then, you can track files with `git add ...` and then commit them with `git commit`, ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag. -If none of the previous steps worked, please open an issue at: -https://github.com/foundry-rs/foundry/issues/new/choose - "#]]); // ensure nothing was emitted, dir is empty From 44b2d754122c7ae98c03539e43b51efea6986c03 Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:12:07 +0300 Subject: [PATCH 1550/1963] feat: update to Soldeer v0.4.1 (#9092) Hotfix #212 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff25d3ac64608..b121e8b96dd15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8129,9 +8129,9 @@ dependencies = [ [[package]] name = "soldeer-commands" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236ae9bfdac074b0cf30caef23e59265b8f609334be3941727c1babcbb04c9cf" +checksum = "8daf7e07f2b6002f8410811915a2f6142f2d1084764dd88cba3f4ebf22232975" dependencies = [ "clap", "cliclack", @@ -8143,9 +8143,9 @@ dependencies = [ [[package]] name = "soldeer-core" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d84a27730c18b4ae2bce01a81bec17397009e3dd739e26f9c10ed8807a97d93e" +checksum = "ea249d0281f3755c3c2b095ad94a554a782cc29138f46c407b8080cfd3918996" dependencies = [ "bon", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 02b364e8332dc..322152f872216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -269,7 +269,7 @@ semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } similar-asserts = "1.5" -soldeer-commands = "=0.4.0" +soldeer-commands = "=0.4.1" strum = "0.26" tempfile = "3.10" tikv-jemallocator = "0.6" From 7a9ebf9ccbce2957762ef1b3f4623efb76ef0306 Mon Sep 17 00:00:00 2001 From: Giovanni Napoli Date: Fri, 11 Oct 2024 16:55:02 +0200 Subject: [PATCH 1551/1963] feat: bump alpine to `3.20.3` (#9094) * feat: bump alpine to `3.20.3` * feat: alpine v`3.20` --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 14415acbcf18d..b425f6ef4d1aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM alpine:3.18 as build-environment +FROM alpine:3.20 as build-environment ARG TARGETARCH WORKDIR /opt @@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/r && strip out/chisel \ && strip out/anvil; -FROM alpine:3.18 as foundry-client +FROM alpine:3.20 as foundry-client RUN apk add --no-cache linux-headers git gcompat libstdc++ From 88e18ef8bb096345ba19165da73c752215d4f19b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 11 Oct 2024 17:08:10 +0200 Subject: [PATCH 1552/1963] chore: update chains (#9097) --- Cargo.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b121e8b96dd15..0aec92430c11f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,10 +74,11 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.36" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c225801d42099570d0674701dddd4142f0ef715282aeb5985042e2ec962df7" +checksum = "156bfc5dcd52ef9a5f33381701fa03310317e14c65093a9430d3e3557b08dcd3" dependencies = [ + "alloy-primitives", "num_enum", "serde", "strum", From bcacf39e43812e50a124e3ba60d1becd9866534d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Fri, 11 Oct 2024 20:44:32 +0200 Subject: [PATCH 1553/1963] feat(cheatcodes): implement new cheatcode to check if a string contains another string (#9085) * feat: implement new cheatcode to check if a string contains another string * chore: make clippy and rustfmt happy * chore: vm.contains should return a boolean * Update testdata/cheats/Vm.sol Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cheatcodes/spec/src/vm.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * chore: update `cheatcodes.json` * chore: update var names * chore: rename to `vm.contains` * Update crates/cheatcodes/spec/src/vm.rs Co-authored-by: Matt Solomon * Update crates/cheatcodes/spec/src/vm.rs Co-authored-by: Matt Solomon * chore: address PR comments --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: Matt Solomon --- crates/cheatcodes/assets/cheatcodes.json | 20 ++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 3 +++ crates/cheatcodes/src/string.rs | 8 ++++++++ testdata/cheats/Vm.sol | 1 + testdata/default/cheats/StringUtils.t.sol | 6 ++++++ 5 files changed, 38 insertions(+) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d64df4860abe1..b41f736677bcb 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3347,6 +3347,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "contains", + "description": "Returns true if `search` is found in `subject`, false otherwise.", + "declaration": "function contains(string calldata subject, string calldata search) external returns (bool result);", + "visibility": "external", + "mutability": "", + "signature": "contains(string,string)", + "selector": "0x3fb18aec", + "selectorBytes": [ + 63, + 177, + 138, + 236 + ] + }, + "group": "string", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "cool", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 761d64e9bedbc..2a342a04438ec 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1976,6 +1976,9 @@ interface Vm { /// Returns 0 in case of an empty `key`. #[cheatcode(group = String)] function indexOf(string calldata input, string calldata key) external pure returns (uint256); + /// Returns true if `search` is found in `subject`, false otherwise. + #[cheatcode(group = String)] + function contains(string calldata subject, string calldata search) external returns (bool result); // ======== JSON Parsing and Manipulation ======== diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index e7435d541048c..a4c06eef650b1 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -144,6 +144,14 @@ impl Cheatcode for indexOfCall { } } +// contains +impl Cheatcode for containsCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { subject, search } = self; + Ok(subject.contains(search).abi_encode()) + } +} + pub(super) fn parse(s: &str, ty: &DynSolType) -> Result { parse_value(s, ty).map(|v| v.abi_encode()) } diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 2572108972b17..e47a79cc65ddb 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -162,6 +162,7 @@ interface Vm { 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); function cool(address target) external; function copyFile(string calldata from, string calldata to) external returns (uint64 copied); function copyStorage(address from, address to) external; diff --git a/testdata/default/cheats/StringUtils.t.sol b/testdata/default/cheats/StringUtils.t.sol index b65346a7a4e0a..256d65302a445 100644 --- a/testdata/default/cheats/StringUtils.t.sol +++ b/testdata/default/cheats/StringUtils.t.sol @@ -51,4 +51,10 @@ contract StringManipulationTest is DSTest { assertEq(vm.indexOf(input, key3), 0); assertEq(vm.indexOf(input, key4), type(uint256).max); } + + function testContains() public { + string memory subject = "this is a test"; + assert(vm.contains(subject, "test")); + assert(!vm.contains(subject, "foundry")); + } } From fd565286372b42a19b22d6a756e59a1b60a4135c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 03:12:03 +0000 Subject: [PATCH 1554/1963] chore(deps): weekly `cargo update` (#9100) Locking 35 packages to latest compatible versions Updating alloy-dyn-abi v0.8.6 -> v0.8.7 Updating alloy-json-abi v0.8.6 -> v0.8.7 Updating alloy-primitives v0.8.6 -> v0.8.7 Updating alloy-sol-macro v0.8.6 -> v0.8.7 Updating alloy-sol-macro-expander v0.8.6 -> v0.8.7 Updating alloy-sol-macro-input v0.8.6 -> v0.8.7 Updating alloy-sol-type-parser v0.8.6 -> v0.8.7 Updating alloy-sol-types v0.8.6 -> v0.8.7 Updating async-compression v0.4.13 -> v0.4.14 Updating aws-sdk-kms v1.46.0 -> v1.47.0 Updating aws-sdk-sso v1.45.0 -> v1.46.0 Updating aws-sdk-ssooidc v1.46.0 -> v1.47.0 Updating aws-sdk-sts v1.45.0 -> v1.46.0 Updating aws-smithy-runtime v1.7.1 -> v1.7.2 Updating cc v1.1.28 -> v1.1.30 Updating clap v4.5.19 -> v4.5.20 Updating clap_builder v4.5.19 -> v4.5.20 Updating clap_complete v4.5.32 -> v4.5.33 Updating derive_builder v0.20.1 -> v0.20.2 Updating derive_builder_core v0.20.1 -> v0.20.2 Updating derive_builder_macro v0.20.1 -> v0.20.2 Updating js-sys v0.3.70 -> v0.3.72 Updating lru v0.12.4 -> v0.12.5 Updating newtype-uuid v1.1.0 -> v1.1.2 Updating proc-macro2 v1.0.86 -> v1.0.87 Updating scc v2.2.0 -> v2.2.1 Updating sdd v3.0.3 -> v3.0.4 Updating syn-solidity v0.8.6 -> v0.8.7 Updating wasm-bindgen v0.2.93 -> v0.2.95 Updating wasm-bindgen-backend v0.2.93 -> v0.2.95 Updating wasm-bindgen-futures v0.4.43 -> v0.4.45 Updating wasm-bindgen-macro v0.2.93 -> v0.2.95 Updating wasm-bindgen-macro-support v0.2.93 -> v0.2.95 Updating wasm-bindgen-shared v0.2.93 -> v0.2.95 Updating web-sys v0.3.70 -> v0.3.72 note: pass `--verbose` to see 10 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 148 +++---- .../fixtures/SimpleContractTestVerbose.json | 416 +++++++++--------- 2 files changed, 281 insertions(+), 283 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0aec92430c11f..e597a7a91fd0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1109c57718022ac84c194f775977a534e1b3969b405e55693a61c42187cc0612" +checksum = "f95d76a38cae906fd394a5afb0736aaceee5432efe76addfd71048e623e208af" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -200,9 +200,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cc0e59c803dd44d14fc0cfa9fea1f74cfa8fd9fb60ca303ced390c58c28d4e" +checksum = "03c66eec1acdd96b39b995b8f5ee5239bc0c871d62c527ae1ac9fd1d7fecd455" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a289ffd7448036f2f436b377f981c79ce0b2090877bad938d43387dc09931877" +checksum = "8ecb848c43f6b06ae3de2e4a67496cbbabd78ae87db0f1248934f15d76192c6a" dependencies = [ "alloy-rlp", "arbitrary", @@ -606,9 +606,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0409e3ba5d1de409997a7db8b8e9d679d52088c1dee042a85033affd3cadeab4" +checksum = "661c516eb1fa3294cc7f2fb8955b3b609d639c282ac81a4eedb14d3046db503a" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -620,9 +620,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18372ef450d59f74c7a64a738f546ba82c92f816597fed1802ef559304c81f1" +checksum = "ecbabb8fc3d75a0c2cea5215be22e7a267e3efde835b0f2a8922f5e3f5d47683" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -639,9 +639,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7bad89dd0d5f109e8feeaf787a9ed7a05a91a9a0efc6687d147a70ebca8eff7" +checksum = "16517f2af03064485150d89746b8ffdcdbc9b6eeb3d536fb66efd7c2846fbc75" dependencies = [ "alloy-json-abi", "const-hex", @@ -656,9 +656,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd3548d5262867c2c4be6223fe4f2583e21ade0ca1c307fd23bc7f28fca479e" +checksum = "c07ebb0c1674ff8cbb08378d7c2e0e27919d2a2dae07ad3bca26174deda8d389" dependencies = [ "serde", "winnow", @@ -666,9 +666,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aa666f1036341b46625e72bd36878bf45ad0185f1b88601223e1ec6ed4b72b1" +checksum = "8e448d879903624863f608c552d10efb0e0905ddbee98b0049412799911eb062" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -1129,9 +1129,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e614738943d3f68c628ae3dbce7c3daffb196665f82f8c8ea6b65de73c79429" +checksum = "998282f8f49ccd6116b0ed8a4de0fbd3151697920e7c7533416d6e25e76434a7" dependencies = [ "flate2", "futures-core", @@ -1321,9 +1321,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.46.0" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33590e8d45206fdc4273ded8a1f292bcceaadd513037aa790fc67b237bc30ee" +checksum = "564a597a3c71a957d60a2e4c62c93d78ee5a0d636531e15b760acad983a5c18e" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1343,9 +1343,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.45.0" +version = "1.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33ae899566f3d395cbf42858e433930682cc9c1889fa89318896082fef45efb" +checksum = "0dc2faec3205d496c7e57eff685dd944203df7ce16a4116d0281c44021788a7b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1365,9 +1365,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.46.0" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f39c09e199ebd96b9f860b0fce4b6625f211e064ad7c8693b72ecf7ef03881e0" +checksum = "c93c241f52bc5e0476e259c953234dab7e2a35ee207ee202e86c0095ec4951dc" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1387,9 +1387,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.45.0" +version = "1.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d95f93a98130389eb6233b9d615249e543f6c24a68ca1f109af9ca5164a8765" +checksum = "b259429be94a3459fa1b00c5684faee118d74f9577cc50aebadc36e507c63b5f" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1483,9 +1483,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1ce695746394772e7000b39fe073095db6d45a862d0767dd5ad0ac0d7f8eb87" +checksum = "a065c0fe6fdbdf9f11817eb68582b2ab4aff9e9c39e986ae48f7ec576c6322db" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1991,9 +1991,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.28" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" dependencies = [ "shlex", ] @@ -2105,9 +2105,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.19" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -2115,9 +2115,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.19" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -2130,9 +2130,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.32" +version = "4.5.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74a01f4f9ee6c066d42a1c8dedf0dcddad16c72a8981a309d6398de3a75b0c39" +checksum = "9646e2e245bf62f45d39a0f3f36f1171ad1ea0d6967fd114bca72cb02a8fcdfb" dependencies = [ "clap", ] @@ -2663,18 +2663,18 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" dependencies = [ "darling", "proc-macro2", @@ -2684,9 +2684,9 @@ dependencies = [ [[package]] name = "derive_builder_macro" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", "syn 2.0.79", @@ -4673,10 +4673,6 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", - "allocator-api2", -] [[package]] name = "hashbrown" @@ -4684,6 +4680,8 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", "serde", ] @@ -5280,9 +5278,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -5493,11 +5491,11 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.0", ] [[package]] @@ -5753,9 +5751,9 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "newtype-uuid" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526cb7c660872e401beaf3297f95f548ce3b4b4bdd8121b7c0713771d7c4a6e" +checksum = "4f4933943834e236c864a48aefdc2da43885dbd5eb77bff3ab20f31e0c3146f5" dependencies = [ "uuid 1.10.0", ] @@ -6661,9 +6659,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -7602,9 +7600,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836f1e0f4963ef5288b539b643b35e043e76a32d0f4e47e67febf69576527f50" +checksum = "553f8299af7450cda9a52d3a370199904e7a46b5ffd1bef187c4a6af3bb6db69" dependencies = [ "sdd", ] @@ -7678,9 +7676,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a7b59a5d9b0099720b417b6325d91a52cbf5b3dcb5041d864be53eefa58abc" +checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" [[package]] name = "sec1" @@ -8343,9 +8341,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a850d65181df41b83c6be01a7d91f5e9377c43d48faa5af7d95816f437f5a3" +checksum = "20e7b52ad118b2153644eea95c6fc740b6c1555b2344fdab763fc9de4075f665" dependencies = [ "paste", "proc-macro2", @@ -9252,9 +9250,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -9263,9 +9261,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -9278,9 +9276,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -9290,9 +9288,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9300,9 +9298,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -9313,9 +9311,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-streams" @@ -9395,9 +9393,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/crates/forge/tests/fixtures/SimpleContractTestVerbose.json b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json index adc700d4d59d6..81803d949d36c 100644 --- a/crates/forge/tests/fixtures/SimpleContractTestVerbose.json +++ b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json @@ -1,217 +1,217 @@ { - "src/Simple.t.sol:SimpleContractTest": { - "duration": "{...}", - "test_results": { - "test()": { - "status": "Success", - "reason": null, - "counterexample": null, - "logs": [ + "src/Simple.t.sol:SimpleContractTest": { + "duration": "{...}", + "test_results": { + "test()": { + "status": "Success", + "reason": null, + "counterexample": null, + "logs": [ + { + "address": "0x000000000000000000636f6e736f6c652e6c6f67", + "topics": [ + "0x41304facd9323d75b11bcdd609cb38effffdb05710f7caf0e9b16c6d9d709f50" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f56616c7565207365743a20203130300000000000000000000000000000000000" + } + ], + "decoded_logs": [ + "Value set: 100" + ], + "kind": { + "Unit": { + "gas": "{...}" + } + }, + "traces": [ + [ + "Deployment", + { + "arena": [ + { + "parent": null, + "children": [], + "idx": 0, + "trace": { + "depth": 0, + "success": true, + "caller": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", + "address": "0x7fa9385be102ac3eac297483dd6233d62b3e1496", + "maybe_precompile": false, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CREATE", + "value": "0x0", + "data": "{...}", + "output": "{...}", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Return", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [] + } + ] + } + ], + [ + "Execution", + { + "arena": [ + { + "parent": null, + "children": [ + 1, + 2, + 3 + ], + "idx": 0, + "trace": { + "depth": 0, + "success": true, + "caller": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", + "address": "0x7fa9385be102ac3eac297483dd6233d62b3e1496", + "maybe_precompile": null, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CALL", + "value": "0x0", + "data": "0xf8a8fd6d", + "output": "0x", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Stop", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [ + { + "Call": 0 + }, { - "address": "0x000000000000000000636F6e736F6c652e6c6f67", - "topics": [ - "0x41304facd9323d75b11bcdd609cb38effffdb05710f7caf0e9b16c6d9d709f50" - ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f56616c7565207365743a20203130300000000000000000000000000000000000" + "Call": 1 + }, + { + "Call": 2 } - ], - "decoded_logs": [ - "Value set: 100" - ], - "kind": { - "Unit": { - "gas": "{...}" + ] + }, + { + "parent": 0, + "children": [], + "idx": 1, + "trace": { + "depth": 1, + "success": true, + "caller": "0x7fa9385be102ac3eac297483dd6233d62b3e1496", + "address": "0x5615deb798bb3e4dfa0139dfa1b3d433cc23b72f", + "maybe_precompile": false, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CREATE", + "value": "0x0", + "data": "{...}", + "output": "{...}", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Return", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null } + }, + "logs": [], + "ordering": [] }, - "traces": [ - [ - "Deployment", - { - "arena": [ - { - "parent": null, - "children": [], - "idx": 0, - "trace": { - "depth": 0, - "success": true, - "caller": "0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38", - "address": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", - "maybe_precompile": false, - "selfdestruct_address": null, - "selfdestruct_refund_target": null, - "selfdestruct_transferred_value": null, - "kind": "CREATE", - "value": "0x0", - "data": "{...}", - "output": "{...}", - "gas_used": "{...}", - "gas_limit": "{...}", - "status": "Return", - "steps": [], - "decoded": { - "label": null, - "return_data": null, - "call_data": null - } - }, - "logs": [], - "ordering": [] - } - ] - } - ], - [ - "Execution", - { - "arena": [ - { - "parent": null, - "children": [ - 1, - 2, - 3 - ], - "idx": 0, - "trace": { - "depth": 0, - "success": true, - "caller": "0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38", - "address": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", - "maybe_precompile": null, - "selfdestruct_address": null, - "selfdestruct_refund_target": null, - "selfdestruct_transferred_value": null, - "kind": "CALL", - "value": "0x0", - "data": "0xf8a8fd6d", - "output": "0x", - "gas_used": "{...}", - "gas_limit": "{...}", - "status": "Stop", - "steps": [], - "decoded": { - "label": null, - "return_data": null, - "call_data": null - } - }, - "logs": [], - "ordering": [ - { - "Call": 0 - }, - { - "Call": 1 - }, - { - "Call": 2 - } - ] - }, - { - "parent": 0, - "children": [], - "idx": 1, - "trace": { - "depth": 1, - "success": true, - "caller": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", - "address": "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f", - "maybe_precompile": false, - "selfdestruct_address": null, - "selfdestruct_refund_target": null, - "selfdestruct_transferred_value": null, - "kind": "CREATE", - "value": "0x0", - "data": "{...}", - "output": "{...}", - "gas_used": "{...}", - "gas_limit": "{...}", - "status": "Return", - "steps": [], - "decoded": { - "label": null, - "return_data": null, - "call_data": null - } - }, - "logs": [], - "ordering": [] - }, - { - "parent": 0, - "children": [], - "idx": 2, - "trace": { - "depth": 1, - "success": true, - "caller": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", - "address": "0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f", - "maybe_precompile": null, - "selfdestruct_address": null, - "selfdestruct_refund_target": null, - "selfdestruct_transferred_value": null, - "kind": "CALL", - "value": "0x0", - "data": "0xe26d14740000000000000000000000000000000000000000000000000000000000000064", - "output": "0x", - "gas_used": "{...}", - "gas_limit": "{...}", - "status": "Stop", - "steps": [], - "decoded": { - "label": null, - "return_data": null, - "call_data": null - } - }, - "logs": [], - "ordering": [] - }, - { - "parent": 0, - "children": [], - "idx": 3, - "trace": { - "depth": 1, - "success": true, - "caller": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496", - "address": "0x000000000000000000636F6e736F6c652e6c6f67", - "maybe_precompile": null, - "selfdestruct_address": null, - "selfdestruct_refund_target": null, - "selfdestruct_transferred_value": null, - "kind": "STATICCALL", - "value": "0x0", - "data": "{...}", - "output": "0x", - "gas_used": "{...}", - "gas_limit": "{...}", - "status": "Stop", - "steps": [], - "decoded": { - "label": null, - "return_data": null, - "call_data": null - } - }, - "logs": [], - "ordering": [] - } - ] - } - ] - ], - "labeled_addresses": {}, - "duration": { - "secs": "{...}", - "nanos": "{...}" + { + "parent": 0, + "children": [], + "idx": 2, + "trace": { + "depth": 1, + "success": true, + "caller": "0x7fa9385be102ac3eac297483dd6233d62b3e1496", + "address": "0x5615deb798bb3e4dfa0139dfa1b3d433cc23b72f", + "maybe_precompile": null, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "CALL", + "value": "0x0", + "data": "0xe26d14740000000000000000000000000000000000000000000000000000000000000064", + "output": "0x", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Stop", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [] }, - "breakpoints": {}, - "gas_snapshots": {} + { + "parent": 0, + "children": [], + "idx": 3, + "trace": { + "depth": 1, + "success": true, + "caller": "0x7fa9385be102ac3eac297483dd6233d62b3e1496", + "address": "0x000000000000000000636f6e736f6c652e6c6f67", + "maybe_precompile": null, + "selfdestruct_address": null, + "selfdestruct_refund_target": null, + "selfdestruct_transferred_value": null, + "kind": "STATICCALL", + "value": "0x0", + "data": "{...}", + "output": "0x", + "gas_used": "{...}", + "gas_limit": "{...}", + "status": "Stop", + "steps": [], + "decoded": { + "label": null, + "return_data": null, + "call_data": null + } + }, + "logs": [], + "ordering": [] + } + ] } + ] + ], + "labeled_addresses": {}, + "duration": { + "secs": "{...}", + "nanos": "{...}" }, - "warnings": [] - } + "breakpoints": {}, + "gas_snapshots": {} + } + }, + "warnings": [] + } } \ No newline at end of file From 9415dde6e6b4ce14bb773eab7a8ebe0ed8e0c52c Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:29:58 +0530 Subject: [PATCH 1555/1963] feat(`cheatcodes`): vm.rememberKeys (#9087) * feat(`cheatcodes`): vm.rememberKeys * docs + return addresses + test * remeberKeys with language * doc nits * cargo cheats * set script wallet in config if unset * nit * test --- crates/cheatcodes/assets/cheatcodes.json | 40 +++++++++ crates/cheatcodes/spec/src/vm.rs | 14 ++++ crates/cheatcodes/src/crypto.rs | 102 +++++++++++++++++++++-- crates/forge/tests/cli/script.rs | 38 +++++++++ crates/forge/tests/cli/test_cmd.rs | 55 ++++++++++++ testdata/cheats/Vm.sol | 2 + 6 files changed, 244 insertions(+), 7 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index b41f736677bcb..554cae92a890a 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7533,6 +7533,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "rememberKeys_0", + "description": "Derive a set number of wallets from a mnemonic at the derivation path `m/44'/60'/0'/0/{0..count}`.\nThe respective private keys are saved to the local forge wallet for later use and their addresses are returned.", + "declaration": "function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs);", + "visibility": "external", + "mutability": "", + "signature": "rememberKeys(string,string,uint32)", + "selector": "0x97cb9189", + "selectorBytes": [ + 151, + 203, + 145, + 137 + ] + }, + "group": "crypto", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "rememberKeys_1", + "description": "Derive a set number of wallets from a mnemonic in the specified language at the derivation path `m/44'/60'/0'/0/{0..count}`.\nThe respective private keys are saved to the local forge wallet for later use and their addresses are returned.", + "declaration": "function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count) external returns (address[] memory keyAddrs);", + "visibility": "external", + "mutability": "", + "signature": "rememberKeys(string,string,string,uint32)", + "selector": "0xf8d58eaf", + "selectorBytes": [ + 248, + 213, + 142, + 175 + ] + }, + "group": "crypto", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "removeDir", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 2a342a04438ec..0fd8a62a7edc6 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2407,6 +2407,20 @@ interface Vm { #[cheatcode(group = Crypto)] function rememberKey(uint256 privateKey) external returns (address keyAddr); + /// Derive a set number of wallets from a mnemonic at the derivation path `m/44'/60'/0'/0/{0..count}`. + /// + /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned. + #[cheatcode(group = Crypto)] + function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs); + + /// Derive a set number of wallets from a mnemonic in the specified language at the derivation path `m/44'/60'/0'/0/{0..count}`. + /// + /// The respective private keys are saved to the local forge wallet for later use and their addresses are returned. + #[cheatcode(group = Crypto)] + function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count) + external + returns (address[] memory keyAddrs); + // -------- Uncategorized Utilities -------- /// Labels an address in call traces. diff --git a/crates/cheatcodes/src/crypto.rs b/crates/cheatcodes/src/crypto.rs index f080938ac5a28..e5e6f56e36609 100644 --- a/crates/cheatcodes/src/crypto.rs +++ b/crates/cheatcodes/src/crypto.rs @@ -1,6 +1,6 @@ //! Implementations of [`Crypto`](spec::Group::Crypto) Cheatcodes. -use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use crate::{Cheatcode, Cheatcodes, Result, ScriptWallets, Vm::*}; use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_signer::{Signer, SignerSync}; use alloy_signer_local::{ @@ -8,14 +8,16 @@ use alloy_signer_local::{ ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, Portuguese, Spanish, Wordlist, }, - MnemonicBuilder, PrivateKeySigner, + LocalSigner, MnemonicBuilder, PrivateKeySigner, }; use alloy_sol_types::SolValue; +use foundry_wallets::multi_wallet::MultiWallet; use k256::{ ecdsa::SigningKey, elliptic_curve::{bigint::ArrayEncoding, sec1::ToEncodedPoint}, }; use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; +use std::sync::Arc; /// The BIP32 default derivation path prefix. const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; @@ -89,14 +91,56 @@ impl Cheatcode for rememberKeyCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { privateKey } = self; let wallet = parse_wallet(privateKey)?; - let address = wallet.address(); - if let Some(script_wallets) = state.script_wallets() { - script_wallets.add_local_signer(wallet); - } + let address = inject_wallet(state, wallet); Ok(address.abi_encode()) } } +impl Cheatcode for rememberKeys_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { mnemonic, derivationPath, count } = self; + tracing::info!("Remembering {} keys", count); + let wallets = derive_wallets::(mnemonic, derivationPath, *count)?; + + tracing::info!("Adding {} keys to script wallets", count); + + let mut addresses = Vec::

::with_capacity(wallets.len()); + for wallet in wallets { + let addr = inject_wallet(state, wallet); + addresses.push(addr); + } + + Ok(addresses.abi_encode()) + } +} + +impl Cheatcode for rememberKeys_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { mnemonic, derivationPath, language, count } = self; + let wallets = derive_wallets_str(mnemonic, derivationPath, language, *count)?; + let mut addresses = Vec::
::with_capacity(wallets.len()); + for wallet in wallets { + let addr = inject_wallet(state, wallet); + addresses.push(addr); + } + + Ok(addresses.abi_encode()) + } +} + +fn inject_wallet(state: &mut Cheatcodes, wallet: LocalSigner) -> Address { + let address = wallet.address(); + if let Some(script_wallets) = state.script_wallets() { + script_wallets.add_local_signer(wallet); + } else { + // This is needed in case of testing scripts, wherein script wallets are not set on setup. + let script_wallets = ScriptWallets::new(MultiWallet::default(), None); + script_wallets.add_local_signer(wallet); + Arc::make_mut(&mut state.config).script_wallets = Some(script_wallets); + } + address +} + impl Cheatcode for sign_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { privateKey, digest } = self; @@ -228,7 +272,7 @@ fn sign_with_wallet( } else if signers.len() == 1 { *signers.keys().next().unwrap() } else { - bail!("could not determine signer"); + bail!("could not determine signer, there are multiple signers available use vm.sign(signer, digest) to specify one"); }; let wallet = signers @@ -309,6 +353,50 @@ fn derive_key(mnemonic: &str, path: &str, index: u32) -> Result { Ok(private_key.abi_encode()) } +fn derive_wallets_str( + mnemonic: &str, + path: &str, + language: &str, + count: u32, +) -> Result>> { + match language { + "chinese_simplified" => derive_wallets::(mnemonic, path, count), + "chinese_traditional" => derive_wallets::(mnemonic, path, count), + "czech" => derive_wallets::(mnemonic, path, count), + "english" => derive_wallets::(mnemonic, path, count), + "french" => derive_wallets::(mnemonic, path, count), + "italian" => derive_wallets::(mnemonic, path, count), + "japanese" => derive_wallets::(mnemonic, path, count), + "korean" => derive_wallets::(mnemonic, path, count), + "portuguese" => derive_wallets::(mnemonic, path, count), + "spanish" => derive_wallets::(mnemonic, path, count), + _ => Err(fmt_err!("unsupported mnemonic language: {language:?}")), + } +} + +fn derive_wallets( + mnemonic: &str, + path: &str, + count: u32, +) -> Result>> { + let mut out = path.to_string(); + + if !out.ends_with('/') { + out.push('/'); + } + + let mut wallets = Vec::with_capacity(count as usize); + for idx in 0..count { + let wallet = MnemonicBuilder::::default() + .phrase(mnemonic) + .derivation_path(format!("{out}{idx}"))? + .build()?; + wallets.push(wallet); + } + + Ok(wallets) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index e8f1466b911ef..81b7461205fe3 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2108,3 +2108,41 @@ Script ran successfully. "#]]); }); + +forgetest_init!(can_remeber_keys, |prj, cmd| { + let script = prj + .add_source( + "Foo", + r#" +import "forge-std/Script.sol"; + +interface Vm { + function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs); +} + +contract WalletScript is Script { + function run() public { + string memory mnemonic = "test test test test test test test test test test test junk"; + string memory derivationPath = "m/44'/60'/0'/0/"; + address[] memory wallets = Vm(address(vm)).rememberKeys(mnemonic, derivationPath, 3); + for (uint256 i = 0; i < wallets.length; i++) { + console.log(wallets[i]); + } + } +}"#, + ) + .unwrap(); + cmd.arg("script").arg(script).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Script ran successfully. +[GAS] + +== Logs == + 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 + 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC + +"#]]); +}); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index ea3ce1911ba97..2cd258f661602 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2219,3 +2219,58 @@ warning: specifying argument for --decode-internal is deprecated and will be rem "#]]); }); + +// Test a script that calls vm.rememberKeys +forgetest_init!(script_testing, |prj, cmd| { + prj + .add_source( + "Foo", + r#" +import "forge-std/Script.sol"; + +interface Vm { +function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count) external returns (address[] memory keyAddrs); +} + +contract WalletScript is Script { +function run() public { + string memory mnemonic = "test test test test test test test test test test test junk"; + string memory derivationPath = "m/44'/60'/0'/0/"; + address[] memory wallets = Vm(address(vm)).rememberKeys(mnemonic, derivationPath, 3); + for (uint256 i = 0; i < wallets.length; i++) { + console.log(wallets[i]); + } +} +} + +contract FooTest { + WalletScript public script; + + + function setUp() public { + script = new WalletScript(); + } + + function testWalletScript() public { + script.run(); + } +} + +"#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "testWalletScript", "-vvv"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for src/Foo.sol:FooTest +[PASS] testWalletScript() ([GAS]) +Logs: + 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 + 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC +... +"#]]); +}); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index e47a79cc65ddb..bb9b07a6595c3 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -371,6 +371,8 @@ 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 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); From 9a813d50a500a7f70d3607a7bfca84d6614c9f0e Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:37:17 +0530 Subject: [PATCH 1556/1963] refactor(`cheatcodes`): mv `ScriptWallets` into `Cheatcode` (#9106) * refactor(`cheatcodes`): mv `ScriptWallets` into `Cheatcode` from `CheatsConfig` * nit * rename `ScriptWallets` to `Wallets` * rename cheatcode * doc nits --- crates/cheatcodes/assets/cheatcodes.json | 16 ++++++++-------- crates/cheatcodes/spec/src/vm.rs | 2 +- crates/cheatcodes/src/config.rs | 8 +------- crates/cheatcodes/src/crypto.rs | 7 +++---- crates/cheatcodes/src/inspector.rs | 14 +++++++++++--- crates/cheatcodes/src/lib.rs | 2 +- crates/cheatcodes/src/script.rs | 18 +++++++++--------- crates/chisel/src/executor.rs | 1 - crates/evm/evm/src/inspectors/stack.rs | 20 ++++++++++++++++++-- crates/forge/src/multi_runner.rs | 1 - crates/forge/tests/cli/script.rs | 4 ++-- crates/script/src/broadcast.rs | 4 ++-- crates/script/src/build.rs | 6 +++--- crates/script/src/execute.rs | 8 ++++---- crates/script/src/lib.rs | 10 +++++----- crates/script/src/simulate.rs | 6 +++--- testdata/cheats/Vm.sol | 2 +- 17 files changed, 72 insertions(+), 57 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 554cae92a890a..4dbdd29b5da7e 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5453,18 +5453,18 @@ }, { "func": { - "id": "getScriptWallets", + "id": "getWallets", "description": "Returns addresses of available unlocked wallets in the script environment.", - "declaration": "function getScriptWallets() external returns (address[] memory wallets);", + "declaration": "function getWallets() external returns (address[] memory wallets);", "visibility": "external", "mutability": "", - "signature": "getScriptWallets()", - "selector": "0x7c49aa1f", + "signature": "getWallets()", + "selector": "0xdb7a4605", "selectorBytes": [ - 124, - 73, - 170, - 31 + 219, + 122, + 70, + 5 ] }, "group": "scripting", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 0fd8a62a7edc6..21d41b373e011 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1912,7 +1912,7 @@ interface Vm { /// Returns addresses of available unlocked wallets in the script environment. #[cheatcode(group = Scripting)] - function getScriptWallets() external returns (address[] memory wallets); + function getWallets() external returns (address[] memory wallets); // ======== Utilities ======== diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index c6a15f45dfd31..cfd6e9452df67 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -1,5 +1,5 @@ use super::Result; -use crate::{script::ScriptWallets, Vm::Rpc}; +use crate::Vm::Rpc; use alloy_primitives::{map::AddressHashMap, U256}; use foundry_common::{fs::normalize_path, ContractsByArtifact}; use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; @@ -43,8 +43,6 @@ pub struct CheatsConfig { pub evm_opts: EvmOpts, /// Address labels from config pub labels: AddressHashMap, - /// Script wallets - pub script_wallets: Option, /// Artifacts which are guaranteed to be fresh (either recompiled or cached). /// If Some, `vm.getDeployedCode` invocations are validated to be in scope of this list. /// If None, no validation is performed. @@ -65,7 +63,6 @@ impl CheatsConfig { config: &Config, evm_opts: EvmOpts, available_artifacts: Option, - script_wallets: Option, running_contract: Option, running_version: Option, ) -> Self { @@ -93,7 +90,6 @@ impl CheatsConfig { allowed_paths, evm_opts, labels: config.labels.clone(), - script_wallets, available_artifacts, running_contract, running_version, @@ -223,7 +219,6 @@ impl Default for CheatsConfig { allowed_paths: vec![], evm_opts: Default::default(), labels: Default::default(), - script_wallets: None, available_artifacts: Default::default(), running_contract: Default::default(), running_version: Default::default(), @@ -245,7 +240,6 @@ mod tests { None, None, None, - None, ) } diff --git a/crates/cheatcodes/src/crypto.rs b/crates/cheatcodes/src/crypto.rs index e5e6f56e36609..f8f24e70b565d 100644 --- a/crates/cheatcodes/src/crypto.rs +++ b/crates/cheatcodes/src/crypto.rs @@ -1,6 +1,6 @@ //! Implementations of [`Crypto`](spec::Group::Crypto) Cheatcodes. -use crate::{Cheatcode, Cheatcodes, Result, ScriptWallets, Vm::*}; +use crate::{Cheatcode, Cheatcodes, Result, Vm::*, Wallets}; use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_signer::{Signer, SignerSync}; use alloy_signer_local::{ @@ -17,7 +17,6 @@ use k256::{ elliptic_curve::{bigint::ArrayEncoding, sec1::ToEncodedPoint}, }; use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; -use std::sync::Arc; /// The BIP32 default derivation path prefix. const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; @@ -134,9 +133,9 @@ fn inject_wallet(state: &mut Cheatcodes, wallet: LocalSigner) -> Add script_wallets.add_local_signer(wallet); } else { // This is needed in case of testing scripts, wherein script wallets are not set on setup. - let script_wallets = ScriptWallets::new(MultiWallet::default(), None); + let script_wallets = Wallets::new(MultiWallet::default(), None); script_wallets.add_local_signer(wallet); - Arc::make_mut(&mut state.config).script_wallets = Some(script_wallets); + state.set_wallets(script_wallets); } address } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index acb86681f8480..a5a2a474f7ff5 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -8,7 +8,7 @@ use crate::{ DealRecord, GasRecord, RecordAccess, }, inspector::utils::CommonCreateInput, - script::{Broadcast, ScriptWallets}, + script::{Broadcast, Wallets}, test::{ assume::AssumeNoRevert, expect::{ @@ -476,6 +476,8 @@ pub struct Cheatcodes { /// Deprecated cheatcodes mapped to the reason. Used to report warnings on test results. pub deprecated: HashMap<&'static str, Option<&'static str>>, + /// Unlocked wallets used in scripts and testing of scripts. + pub wallets: Option, } // This is not derived because calling this in `fn new` with `..Default::default()` creates a second @@ -523,12 +525,18 @@ impl Cheatcodes { ignored_traces: Default::default(), arbitrary_storage: Default::default(), deprecated: Default::default(), + wallets: Default::default(), } } /// Returns the configured script wallets. - pub fn script_wallets(&self) -> Option<&ScriptWallets> { - self.config.script_wallets.as_ref() + pub fn script_wallets(&self) -> Option<&Wallets> { + self.wallets.as_ref() + } + + /// Sets the unlocked wallets. + pub fn set_wallets(&mut self, wallets: Wallets) { + self.wallets = Some(wallets); } /// Decodes the input data and applies the cheatcode. diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 106b4c96121d4..ff93b83362364 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -45,7 +45,7 @@ mod inspector; mod json; mod script; -pub use script::{ScriptWallets, ScriptWalletsInner}; +pub use script::{Wallets, WalletsInner}; mod string; diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index f9535844c7c44..960d6a5508f48 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -61,7 +61,7 @@ impl Cheatcode for stopBroadcastCall { } } -impl Cheatcode for getScriptWalletsCall { +impl Cheatcode for getWalletsCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let script_wallets = ccx.state.script_wallets().cloned().map(|sw| sw.signers().unwrap_or_default()); @@ -91,29 +91,29 @@ pub struct Broadcast { /// Contains context for wallet management. #[derive(Debug)] -pub struct ScriptWalletsInner { +pub struct WalletsInner { /// All signers in scope of the script. pub multi_wallet: MultiWallet, /// Optional signer provided as `--sender` flag. pub provided_sender: Option
, } -/// Clonable wrapper around [`ScriptWalletsInner`]. +/// Clonable wrapper around [`WalletsInner`]. #[derive(Debug, Clone)] -pub struct ScriptWallets { +pub struct Wallets { /// Inner data. - pub inner: Arc>, + pub inner: Arc>, } -impl ScriptWallets { +impl Wallets { #[allow(missing_docs)] pub fn new(multi_wallet: MultiWallet, provided_sender: Option
) -> Self { - Self { inner: Arc::new(Mutex::new(ScriptWalletsInner { multi_wallet, provided_sender })) } + Self { inner: Arc::new(Mutex::new(WalletsInner { multi_wallet, provided_sender })) } } - /// Consumes [ScriptWallets] and returns [MultiWallet]. + /// Consumes [Wallets] and returns [MultiWallet]. /// - /// Panics if [ScriptWallets] is still in use. + /// Panics if [Wallets] is still in use. pub fn into_multi_wallet(self) -> MultiWallet { Arc::into_inner(self.inner) .map(|m| m.into_inner().multi_wallet) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index b63ebe3e41137..1a2267719c569 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -335,7 +335,6 @@ impl SessionSource { self.config.evm_opts.clone(), None, None, - None, Some(self.solc.version.clone()), ) .into(), diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 1e3b36181e0d6..403e906f6323c 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -3,7 +3,7 @@ use super::{ TracingInspector, }; use alloy_primitives::{map::AddressHashMap, Address, Bytes, Log, TxKind, U256}; -use foundry_cheatcodes::CheatcodesExecutor; +use foundry_cheatcodes::{CheatcodesExecutor, Wallets}; use foundry_evm_core::{backend::DatabaseExt, InspectorExt}; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::{SparsedTraceArena, TraceMode}; @@ -57,6 +57,8 @@ pub struct InspectorStackBuilder { pub enable_isolation: bool, /// Whether to enable Alphanet features. pub alphanet: bool, + /// The wallets to set in the cheatcodes context. + pub wallets: Option, } impl InspectorStackBuilder { @@ -87,6 +89,13 @@ impl InspectorStackBuilder { self } + /// Set the wallets. + #[inline] + pub fn wallets(mut self, wallets: Wallets) -> Self { + self.wallets = Some(wallets); + self + } + /// Set the fuzzer inspector. #[inline] pub fn fuzzer(mut self, fuzzer: Fuzzer) -> Self { @@ -161,13 +170,20 @@ impl InspectorStackBuilder { chisel_state, enable_isolation, alphanet, + wallets, } = self; let mut stack = InspectorStack::new(); // inspectors if let Some(config) = cheatcodes { - stack.set_cheatcodes(Cheatcodes::new(config)); + let mut cheatcodes = Cheatcodes::new(config); + // Set wallets if they are provided + if let Some(wallets) = wallets { + cheatcodes.set_wallets(wallets); + } + stack.set_cheatcodes(cheatcodes); } + if let Some(fuzzer) = fuzzer { stack.set_fuzzer(fuzzer); } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 802ad3884cc65..e7361db0004fc 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -242,7 +242,6 @@ impl MultiContractRunner { &self.config, self.evm_opts.clone(), Some(self.known_contracts.clone()), - None, Some(artifact_id.name.clone()), Some(artifact_id.version.clone()), ); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 81b7461205fe3..558580728b005 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2077,12 +2077,12 @@ forgetest_init!(can_get_script_wallets, |prj, cmd| { import "forge-std/Script.sol"; interface Vm { - function getScriptWallets() external returns (address[] memory wallets); + function getWallets() external returns (address[] memory wallets); } contract WalletScript is Script { function run() public { - address[] memory wallets = Vm(address(vm)).getScriptWallets(); + address[] memory wallets = Vm(address(vm)).getWallets(); console.log(wallets[0]); } }"#, diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 3faaa441e24c2..b0551de57dfa2 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -17,7 +17,7 @@ use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::{bail, Context, Result}; use forge_verify::provider::VerificationProviderType; -use foundry_cheatcodes::ScriptWallets; +use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_batch_support, has_different_gas_calc}; use foundry_common::{ provider::{get_http_provider, try_get_http_provider, RetryProvider}, @@ -154,7 +154,7 @@ impl SendTransactionsKind { pub struct BundledState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, pub build_data: LinkedBuildData, pub sequence: ScriptSequenceKind, } diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index b0c5a2947a4d1..3f5ffae81c8d7 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -8,7 +8,7 @@ use crate::{ use alloy_primitives::{Bytes, B256}; use alloy_provider::Provider; use eyre::{OptionExt, Result}; -use foundry_cheatcodes::ScriptWallets; +use foundry_cheatcodes::Wallets; use foundry_common::{ compile::ProjectCompiler, provider::try_get_http_provider, ContractData, ContractsByArtifact, }; @@ -156,7 +156,7 @@ impl LinkedBuildData { pub struct PreprocessedState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, } impl PreprocessedState { @@ -242,7 +242,7 @@ impl PreprocessedState { pub struct CompiledState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, pub build_data: BuildData, } diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index a1b3cf6133fb9..4c2e893686ce1 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -14,7 +14,7 @@ use alloy_provider::Provider; use alloy_rpc_types::TransactionInput; use async_recursion::async_recursion; use eyre::{OptionExt, Result}; -use foundry_cheatcodes::ScriptWallets; +use foundry_cheatcodes::Wallets; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ fmt::{format_token, format_token_raw}, @@ -41,7 +41,7 @@ use yansi::Paint; pub struct LinkedState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, pub build_data: LinkedBuildData, } @@ -92,7 +92,7 @@ impl LinkedState { pub struct PreExecutionState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, pub build_data: LinkedBuildData, pub execution_data: ExecutionData, } @@ -274,7 +274,7 @@ pub struct ExecutionArtifacts { pub struct ExecutedState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, pub build_data: LinkedBuildData, pub execution_data: ExecutionData, pub execution_result: ScriptResult, diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 94c028bb9b471..de06fa0c19de3 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -43,7 +43,7 @@ use foundry_evm::{ constants::DEFAULT_CREATE2_DEPLOYER, executors::ExecutorBuilder, inspectors::{ - cheatcodes::{BroadcastableTransactions, ScriptWallets}, + cheatcodes::{BroadcastableTransactions, Wallets}, CheatsConfig, }, opts::EvmOpts, @@ -207,7 +207,7 @@ pub struct ScriptArgs { impl ScriptArgs { pub async fn preprocess(self) -> Result { let script_wallets = - ScriptWallets::new(self.wallets.get_multi_wallet().await?, self.evm_opts.sender); + Wallets::new(self.wallets.get_multi_wallet().await?, self.evm_opts.sender); let (config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; @@ -560,7 +560,7 @@ impl ScriptConfig { async fn get_runner_with_cheatcodes( &mut self, known_contracts: ContractsByArtifact, - script_wallets: ScriptWallets, + script_wallets: Wallets, debug: bool, target: ArtifactId, ) -> Result { @@ -569,7 +569,7 @@ impl ScriptConfig { async fn _get_runner( &mut self, - cheats_data: Option<(ContractsByArtifact, ScriptWallets, ArtifactId)>, + cheats_data: Option<(ContractsByArtifact, Wallets, ArtifactId)>, debug: bool, ) -> Result { trace!("preparing script runner"); @@ -611,12 +611,12 @@ impl ScriptConfig { &self.config, self.evm_opts.clone(), Some(known_contracts), - Some(script_wallets), Some(target.name), Some(target.version), ) .into(), ) + .wallets(script_wallets) .enable_isolation(self.evm_opts.isolate) }); } diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 432a8ccd544e1..2fbfbcffafedb 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -16,7 +16,7 @@ use alloy_network::TransactionBuilder; use alloy_primitives::{map::HashMap, utils::format_units, Address, Bytes, TxKind, U256}; use dialoguer::Confirm; use eyre::{Context, Result}; -use foundry_cheatcodes::ScriptWallets; +use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_different_gas_calc, now}; use foundry_common::{get_contract_name, shell, ContractData}; use foundry_evm::traces::{decode_trace_arena, render_trace_arena}; @@ -36,7 +36,7 @@ use yansi::Paint; pub struct PreSimulationState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, pub build_data: LinkedBuildData, pub execution_data: ExecutionData, pub execution_result: ScriptResult, @@ -234,7 +234,7 @@ impl PreSimulationState { pub struct FilledTransactionsState { pub args: ScriptArgs, pub script_config: ScriptConfig, - pub script_wallets: ScriptWallets, + pub script_wallets: Wallets, pub build_data: LinkedBuildData, pub execution_artifacts: ExecutionArtifacts, pub transactions: VecDeque, diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index bb9b07a6595c3..2d4030d30e1a5 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -267,7 +267,7 @@ interface Vm { function getNonce(address account) external view returns (uint64 nonce); function getNonce(Wallet calldata wallet) external returns (uint64 nonce); function getRecordedLogs() external returns (Log[] memory logs); - function getScriptWallets() external returns (address[] memory wallets); + function getWallets() external returns (address[] memory wallets); function indexOf(string calldata input, string calldata key) external pure returns (uint256); function isContext(ForgeContext context) external view returns (bool result); function isDir(string calldata path) external returns (bool result); From 6f7c1f72f8c3361f1e738296a0ec634c099c8a7c Mon Sep 17 00:00:00 2001 From: pogobounce Date: Mon, 14 Oct 2024 15:32:53 +0300 Subject: [PATCH 1557/1963] fix: running script with `--broadcast` for a transaction sequence can error out due to nonce desync from rpc latency (#9096) * fix for issue #9095 * changed 'if' statement into 'match' * fmt fix * repeat ask for provider nonce on desync * loop break and tokio::time use instead of std::thread --- Cargo.lock | 1 + crates/script/Cargo.toml | 1 + crates/script/src/broadcast.rs | 24 +++++++++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e597a7a91fd0b..257f63e31f635 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3497,6 +3497,7 @@ dependencies = [ "serde", "serde_json", "tempfile", + "tokio", "tracing", "yansi", ] diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 9c042661775ce..37cc13741a7bc 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -33,6 +33,7 @@ tracing.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } semver.workspace = true futures.workspace = true +tokio.workspace = true async-recursion = "1.0.5" itertools.workspace = true diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index b0551de57dfa2..cb99b26a1d5f4 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -26,7 +26,7 @@ use foundry_common::{ use foundry_config::Config; use futures::{future::join_all, StreamExt}; use itertools::Itertools; -use std::sync::Arc; +use std::{cmp::Ordering, sync::Arc}; pub async fn estimate_gas( tx: &mut WithOtherFields, @@ -67,11 +67,25 @@ pub async fn send_transaction( if sequential_broadcast { let from = tx.from.expect("no sender"); - let nonce = provider.get_transaction_count(from).await?; - let tx_nonce = tx.nonce.expect("no nonce"); - if nonce != tx_nonce { - bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") + for attempt in 0..5 { + let nonce = provider.get_transaction_count(from).await?; + match nonce.cmp(&tx_nonce) { + Ordering::Greater => { + bail!("EOA nonce changed unexpectedly while sending transactions. Expected {tx_nonce} got {nonce} from provider.") + } + Ordering::Less => { + if attempt == 4 { + bail!("After 5 attempts, provider nonce ({nonce}) is still behind expected nonce ({tx_nonce}).") + } + warn!("Expected nonce ({tx_nonce}) is ahead of provider nonce ({nonce}). Retrying in 1 second..."); + tokio::time::sleep(std::time::Duration::from_millis(1000)).await; + } + Ordering::Equal => { + // Nonces are equal, we can proceed + break; + } + } } } From 440837d3e71c4cd4c551352bbc8486110a1db44d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:59:48 +0300 Subject: [PATCH 1558/1963] fix(fmt): do not panic when no named arg (#9114) --- crates/fmt/src/formatter.rs | 7 +++++-- crates/fmt/testdata/Repros/fmt.sol | 15 +++++++++++++++ crates/fmt/testdata/Repros/original.sol | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 02b7bd7fe9a5f..02d62f70567a8 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -2340,8 +2340,11 @@ impl Visitor for Formatter<'_, W> { "" }; let closing_bracket = format!("{prefix}{}", "}"); - let closing_bracket_loc = args.last().unwrap().loc.end(); - write_chunk!(self, closing_bracket_loc, "{closing_bracket}")?; + if let Some(arg) = args.last() { + write_chunk!(self, arg.loc.end(), "{closing_bracket}")?; + } else { + write_chunk!(self, "{closing_bracket}")?; + } Ok(()) } diff --git a/crates/fmt/testdata/Repros/fmt.sol b/crates/fmt/testdata/Repros/fmt.sol index a61a626a0968f..0a480c0b02bdf 100644 --- a/crates/fmt/testdata/Repros/fmt.sol +++ b/crates/fmt/testdata/Repros/fmt.sol @@ -144,3 +144,18 @@ contract IfElseTest { } } } + +contract DbgFmtTest is Test { + function test_argsList() public { + uint256 result1 = internalNoArgs({}); + result2 = add({a: 1, b: 2}); + } + + function add(uint256 a, uint256 b) internal pure returns (uint256) { + return a + b; + } + + function internalNoArgs() internal pure returns (uint256) { + return 0; + } +} diff --git a/crates/fmt/testdata/Repros/original.sol b/crates/fmt/testdata/Repros/original.sol index ef75931e233e6..6f18784d39dea 100644 --- a/crates/fmt/testdata/Repros/original.sol +++ b/crates/fmt/testdata/Repros/original.sol @@ -143,3 +143,18 @@ contract IfElseTest { } } } + +contract DbgFmtTest is Test { + function test_argsList() public { + uint256 result1 = internalNoArgs({}); + result2 = add({a: 1, b: 2}); + } + + function add(uint256 a, uint256 b) internal pure returns (uint256) { + return a + b; + } + + function internalNoArgs() internal pure returns (uint256) { + return 0; + } +} From fdd321bac95f0935529164a88faf99d4d5cfa321 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:20:28 +0300 Subject: [PATCH 1559/1963] fix(traces): identify artifacts using both deployed and creation code (#9050) * Identify by creation code * Compute score for both creation and runtime code * Fallback to deployed bytecode only if min creation bytecode score is under threshold * reuse check closure, add basic test --- crates/evm/traces/src/decoder/mod.rs | 5 +- crates/evm/traces/src/identifier/etherscan.rs | 4 +- crates/evm/traces/src/identifier/local.rs | 46 ++++++--- crates/evm/traces/src/identifier/mod.rs | 4 +- crates/forge/tests/cli/test_cmd.rs | 99 +++++++++++++++++++ 5 files changed, 139 insertions(+), 19 deletions(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index de3a0c02f201a..43a53286c17b4 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -262,7 +262,7 @@ impl CallTraceDecoder { pub fn trace_addresses<'a>( &'a self, arena: &'a CallTraceArena, - ) -> impl Iterator)> + Clone + 'a { + ) -> impl Iterator, Option<&'a [u8]>)> + Clone + 'a { arena .nodes() .iter() @@ -270,9 +270,10 @@ impl CallTraceDecoder { ( &node.trace.address, node.trace.kind.is_any_create().then_some(&node.trace.output[..]), + node.trace.kind.is_any_create().then_some(&node.trace.data[..]), ) }) - .filter(|&(address, _)| { + .filter(|&(address, _, _)| { !self.labels.contains_key(address) || !self.contracts.contains_key(address) }) } diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 4a34b31b36517..2af6fbb59f4a5 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -97,7 +97,7 @@ impl EtherscanIdentifier { impl TraceIdentifier for EtherscanIdentifier { fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where - A: Iterator)>, + A: Iterator, Option<&'a [u8]>)>, { trace!(target: "evm::traces", "identify {:?} addresses", addresses.size_hint().1); @@ -114,7 +114,7 @@ impl TraceIdentifier for EtherscanIdentifier { Arc::clone(&self.invalid_api_key), ); - for (addr, _) in addresses { + for (addr, _, _) in addresses { if let Some(metadata) = self.contracts.get(addr) { let label = metadata.contract_name.clone(); let abi = metadata.abi().ok().map(Cow::Owned); diff --git a/crates/evm/traces/src/identifier/local.rs b/crates/evm/traces/src/identifier/local.rs index 04680b01a91a4..90c28e016e1ff 100644 --- a/crates/evm/traces/src/identifier/local.rs +++ b/crates/evm/traces/src/identifier/local.rs @@ -32,23 +32,34 @@ impl<'a> LocalTraceIdentifier<'a> { self.known_contracts } - /// Tries to the bytecode most similar to the given one. - pub fn identify_code(&self, code: &[u8]) -> Option<(&'a ArtifactId, &'a JsonAbi)> { - let len = code.len(); + /// Identifies the artifact based on score computed for both creation and deployed bytecodes. + pub fn identify_code( + &self, + runtime_code: &[u8], + creation_code: &[u8], + ) -> Option<(&'a ArtifactId, &'a JsonAbi)> { + let len = runtime_code.len(); let mut min_score = f64::MAX; let mut min_score_id = None; - let mut check = |id| { + let mut check = |id, is_creation, min_score: &mut f64| { let contract = self.known_contracts.get(id)?; - if let Some(deployed_bytecode) = contract.deployed_bytecode() { - let score = bytecode_diff_score(deployed_bytecode, code); + // Select bytecodes to compare based on `is_creation` flag. + let (contract_bytecode, current_bytecode) = if is_creation { + (contract.bytecode(), creation_code) + } else { + (contract.deployed_bytecode(), runtime_code) + }; + + if let Some(bytecode) = contract_bytecode { + let score = bytecode_diff_score(bytecode, current_bytecode); if score == 0.0 { trace!(target: "evm::traces", "found exact match"); return Some((id, &contract.abi)); } - if score < min_score { - min_score = score; + if score < *min_score { + *min_score = score; min_score_id = Some((id, &contract.abi)); } } @@ -65,7 +76,7 @@ impl<'a> LocalTraceIdentifier<'a> { if len > max_len { break; } - if let found @ Some(_) = check(id) { + if let found @ Some(_) = check(id, true, &mut min_score) { return found; } } @@ -75,11 +86,20 @@ impl<'a> LocalTraceIdentifier<'a> { let idx = self.find_index(min_len); for i in idx..same_length_idx { let (id, _) = self.ordered_ids[i]; - if let found @ Some(_) = check(id) { + if let found @ Some(_) = check(id, true, &mut min_score) { return found; } } + // Fallback to comparing deployed code if min score greater than threshold. + if min_score >= 0.85 { + for (artifact, _) in &self.ordered_ids { + if let found @ Some(_) = check(artifact, false, &mut min_score) { + return found; + } + } + } + trace!(target: "evm::traces", %min_score, "no exact match found"); // Note: the diff score can be inaccurate for small contracts so we're using a relatively @@ -109,16 +129,16 @@ impl<'a> LocalTraceIdentifier<'a> { impl TraceIdentifier for LocalTraceIdentifier<'_> { fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where - A: Iterator)>, + A: Iterator, Option<&'a [u8]>)>, { trace!(target: "evm::traces", "identify {:?} addresses", addresses.size_hint().1); addresses - .filter_map(|(address, code)| { + .filter_map(|(address, runtime_code, creation_code)| { let _span = trace_span!(target: "evm::traces", "identify", %address).entered(); trace!(target: "evm::traces", "identifying"); - let (id, abi) = self.identify_code(code?)?; + let (id, abi) = self.identify_code(runtime_code?, creation_code?)?; trace!(target: "evm::traces", id=%id.identifier(), "identified"); Some(AddressIdentity { diff --git a/crates/evm/traces/src/identifier/mod.rs b/crates/evm/traces/src/identifier/mod.rs index a16b108d8537f..008e5f8418439 100644 --- a/crates/evm/traces/src/identifier/mod.rs +++ b/crates/evm/traces/src/identifier/mod.rs @@ -35,7 +35,7 @@ pub trait TraceIdentifier { /// Attempts to identify an address in one or more call traces. fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where - A: Iterator)> + Clone; + A: Iterator, Option<&'a [u8]>)> + Clone; } /// A collection of trace identifiers. @@ -55,7 +55,7 @@ impl Default for TraceIdentifiers<'_> { impl TraceIdentifier for TraceIdentifiers<'_> { fn identify_addresses<'a, A>(&mut self, addresses: A) -> Vec> where - A: Iterator)> + Clone, + A: Iterator, Option<&'a [u8]>)> + Clone, { let mut identities = Vec::new(); if let Some(local) = &mut self.local { diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 2cd258f661602..4f812e79cf6ef 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2274,3 +2274,102 @@ Logs: ... "#]]); }); + +// +forgetest_init!(metadata_bytecode_traces, |prj, cmd| { + prj.add_source( + "ParentProxy.sol", + r#" +import {Counter} from "./Counter.sol"; + +abstract contract ParentProxy { + Counter impl; + bytes data; + + constructor(Counter _implementation, bytes memory _data) { + impl = _implementation; + data = _data; + } +} + "#, + ) + .unwrap(); + prj.add_source( + "Proxy.sol", + r#" +import {ParentProxy} from "./ParentProxy.sol"; +import {Counter} from "./Counter.sol"; + +contract Proxy is ParentProxy { + constructor(Counter _implementation, bytes memory _data) + ParentProxy(_implementation, _data) + {} +} + "#, + ) + .unwrap(); + + prj.add_test( + "MetadataTraceTest.t.sol", + r#" +import {Counter} from "src/Counter.sol"; +import {Proxy} from "src/Proxy.sol"; + +import {Test} from "forge-std/Test.sol"; + +contract MetadataTraceTest is Test { + function test_proxy_trace() public { + Counter counter = new Counter(); + new Proxy(counter, ""); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "test_proxy_trace", "-vvvv"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest +[PASS] test_proxy_trace() ([GAS]) +Traces: + [152142] MetadataTraceTest::test_proxy_trace() + ├─ [49499] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 247 bytes of code + ├─ [37978] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b + │ └─ ← [Return] 63 bytes of code + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); + + // Check consistent traces for running with no metadata. + cmd.forge_fuse() + .args(["test", "--mt", "test_proxy_trace", "-vvvv", "--no-metadata"]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest +[PASS] test_proxy_trace() ([GAS]) +Traces: + [130521] MetadataTraceTest::test_proxy_trace() + ├─ [38693] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 193 bytes of code + ├─ [27175] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b + │ └─ ← [Return] 9 bytes of code + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); +}); From 11bd7715d5c16252f58c47b6e418930cf1501576 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:08:09 +0530 Subject: [PATCH 1560/1963] chore(`cheatcodes`): wallet nits (#9118) --- crates/cheatcodes/src/crypto.rs | 28 +++++----------- crates/cheatcodes/src/inspector.rs | 7 ++-- crates/cheatcodes/src/script.rs | 51 ++++++++++++++++-------------- 3 files changed, 40 insertions(+), 46 deletions(-) diff --git a/crates/cheatcodes/src/crypto.rs b/crates/cheatcodes/src/crypto.rs index f8f24e70b565d..cdb07720c3280 100644 --- a/crates/cheatcodes/src/crypto.rs +++ b/crates/cheatcodes/src/crypto.rs @@ -1,6 +1,6 @@ //! Implementations of [`Crypto`](spec::Group::Crypto) Cheatcodes. -use crate::{Cheatcode, Cheatcodes, Result, Vm::*, Wallets}; +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; use alloy_primitives::{keccak256, Address, B256, U256}; use alloy_signer::{Signer, SignerSync}; use alloy_signer_local::{ @@ -11,7 +11,6 @@ use alloy_signer_local::{ LocalSigner, MnemonicBuilder, PrivateKeySigner, }; use alloy_sol_types::SolValue; -use foundry_wallets::multi_wallet::MultiWallet; use k256::{ ecdsa::SigningKey, elliptic_curve::{bigint::ArrayEncoding, sec1::ToEncodedPoint}, @@ -98,11 +97,7 @@ impl Cheatcode for rememberKeyCall { impl Cheatcode for rememberKeys_0Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { mnemonic, derivationPath, count } = self; - tracing::info!("Remembering {} keys", count); let wallets = derive_wallets::(mnemonic, derivationPath, *count)?; - - tracing::info!("Adding {} keys to script wallets", count); - let mut addresses = Vec::
::with_capacity(wallets.len()); for wallet in wallets { let addr = inject_wallet(state, wallet); @@ -129,14 +124,7 @@ impl Cheatcode for rememberKeys_1Call { fn inject_wallet(state: &mut Cheatcodes, wallet: LocalSigner) -> Address { let address = wallet.address(); - if let Some(script_wallets) = state.script_wallets() { - script_wallets.add_local_signer(wallet); - } else { - // This is needed in case of testing scripts, wherein script wallets are not set on setup. - let script_wallets = Wallets::new(MultiWallet::default(), None); - script_wallets.add_local_signer(wallet); - state.set_wallets(script_wallets); - } + state.wallets().add_local_signer(wallet); address } @@ -256,13 +244,13 @@ fn sign_with_wallet( signer: Option
, digest: &B256, ) -> Result { - let Some(script_wallets) = state.script_wallets() else { - bail!("no wallets are available"); - }; + if state.wallets().is_empty() { + bail!("no wallets available"); + } - let mut script_wallets = script_wallets.inner.lock(); - let maybe_provided_sender = script_wallets.provided_sender; - let signers = script_wallets.multi_wallet.signers()?; + let mut wallets = state.wallets().inner.lock(); + let maybe_provided_sender = wallets.provided_sender; + let signers = wallets.multi_wallet.signers()?; let signer = if let Some(signer) = signer { signer diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index a5a2a474f7ff5..043f8af2fbe46 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -37,6 +37,7 @@ use foundry_evm_core::{ InspectorExt, }; use foundry_evm_traces::{TracingInspector, TracingInspectorConfig}; +use foundry_wallets::multi_wallet::MultiWallet; use itertools::Itertools; use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; use rand::Rng; @@ -529,9 +530,9 @@ impl Cheatcodes { } } - /// Returns the configured script wallets. - pub fn script_wallets(&self) -> Option<&Wallets> { - self.wallets.as_ref() + /// Returns the configured wallets if available, else creates a new instance. + pub fn wallets(&mut self) -> &Wallets { + self.wallets.get_or_insert(Wallets::new(MultiWallet::default(), None)) } /// Sets the unlocked wallets. diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 960d6a5508f48..29a804efd7ec5 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -63,15 +63,8 @@ impl Cheatcode for stopBroadcastCall { impl Cheatcode for getWalletsCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let script_wallets = - ccx.state.script_wallets().cloned().map(|sw| sw.signers().unwrap_or_default()); - - if let Some(script_wallets) = script_wallets { - let script_wallets: Vec
= script_wallets.into_iter().collect(); - Ok(script_wallets.abi_encode()) - } else { - Ok(Default::default()) - } + let wallets = ccx.state.wallets().signers().unwrap_or_default(); + Ok(wallets.abi_encode()) } } @@ -135,6 +128,21 @@ impl Wallets { pub fn signers(&self) -> Result> { Ok(self.inner.lock().multi_wallet.signers()?.keys().cloned().collect()) } + + /// Number of signers in the [MultiWallet]. + pub fn len(&self) -> usize { + let mut inner = self.inner.lock(); + let signers = inner.multi_wallet.signers(); + if signers.is_err() { + return 0; + } + signers.unwrap().len() + } + + /// Whether the [MultiWallet] is empty. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } } /// Sets up broadcasting from a script using `new_origin` as the sender. @@ -148,16 +156,14 @@ fn broadcast(ccx: &mut CheatsCtxt, new_origin: Option<&Address>, single_call: bo let mut new_origin = new_origin.cloned(); if new_origin.is_none() { - if let Some(script_wallets) = ccx.state.script_wallets() { - let mut script_wallets = script_wallets.inner.lock(); - if let Some(provided_sender) = script_wallets.provided_sender { - new_origin = Some(provided_sender); - } else { - let signers = script_wallets.multi_wallet.signers()?; - if signers.len() == 1 { - let address = signers.keys().next().unwrap(); - new_origin = Some(*address); - } + let mut wallets = ccx.state.wallets().inner.lock(); + if let Some(provided_sender) = wallets.provided_sender { + new_origin = Some(provided_sender); + } else { + let signers = wallets.multi_wallet.signers()?; + if signers.len() == 1 { + let address = signers.keys().next().unwrap(); + new_origin = Some(*address); } } } @@ -175,7 +181,7 @@ fn broadcast(ccx: &mut CheatsCtxt, new_origin: Option<&Address>, single_call: bo } /// Sets up broadcasting from a script with the sender derived from `private_key`. -/// Adds this private key to `state`'s `script_wallets` vector to later be used for signing +/// Adds this private key to `state`'s `wallets` vector to later be used for signing /// if broadcast is successful. fn broadcast_key(ccx: &mut CheatsCtxt, private_key: &U256, single_call: bool) -> Result { let wallet = super::crypto::parse_wallet(private_key)?; @@ -183,9 +189,8 @@ fn broadcast_key(ccx: &mut CheatsCtxt, private_key: &U256, single_call: bool) -> let result = broadcast(ccx, Some(&new_origin), single_call); if result.is_ok() { - if let Some(script_wallets) = ccx.state.script_wallets() { - script_wallets.add_local_signer(wallet); - } + let wallets = ccx.state.wallets(); + wallets.add_local_signer(wallet); } result } From f5aa05ee9ac4f088db64b93ae5df4d8656faf1ea Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:36:37 +0530 Subject: [PATCH 1561/1963] refactor(`script`): mv `ScriptSequence` to new crate (#9098) * refac(`script`): extract script sequence and related types to new crate * replace MultiChainSequence in script crate * replace TransactionWithMetadata and AdditionalContract * replace ScriptSequence * replace all underlying ScriptSequence and related types * doc nits * add `ScriptTransactionBuilder` * remove `TxWithMetadata` * mv verify fns and use `ScriptSequence` directly * clippy --- Cargo.lock | 17 ++ Cargo.toml | 2 + crates/script-sequence/Cargo.toml | 29 ++ crates/script-sequence/src/lib.rs | 7 + crates/script-sequence/src/sequence.rs | 248 +++++++++++++++ crates/script-sequence/src/transaction.rs | 75 +++++ crates/script/Cargo.toml | 1 + crates/script/src/broadcast.rs | 4 +- crates/script/src/build.rs | 8 +- crates/script/src/lib.rs | 10 +- crates/script/src/multi_sequence.rs | 5 +- crates/script/src/progress.rs | 6 +- crates/script/src/sequence.rs | 350 +--------------------- crates/script/src/simulate.rs | 43 +-- crates/script/src/transaction.rs | 251 ++++++---------- crates/script/src/verify.rs | 118 +++++++- 16 files changed, 629 insertions(+), 545 deletions(-) create mode 100644 crates/script-sequence/Cargo.toml create mode 100644 crates/script-sequence/src/lib.rs create mode 100644 crates/script-sequence/src/sequence.rs create mode 100644 crates/script-sequence/src/transaction.rs diff --git a/Cargo.lock b/Cargo.lock index 257f63e31f635..5736ded808814 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3478,6 +3478,7 @@ dependencies = [ "dialoguer", "dunce", "eyre", + "forge-script-sequence", "forge-verify", "foundry-cheatcodes", "foundry-cli", @@ -3502,6 +3503,22 @@ dependencies = [ "yansi", ] +[[package]] +name = "forge-script-sequence" +version = "0.2.0" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types", + "eyre", + "foundry-common", + "foundry-compilers", + "foundry-config", + "revm-inspectors", + "serde", + "serde_json", + "tracing", +] + [[package]] name = "forge-sol-macro-gen" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 322152f872216..2bb8f894570b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ members = [ "crates/evm/traces/", "crates/fmt/", "crates/forge/", + "crates/script-sequence/", "crates/macros/", "crates/test-utils/", ] @@ -147,6 +148,7 @@ forge-fmt = { path = "crates/fmt" } forge-verify = { path = "crates/verify" } forge-script = { path = "crates/script" } forge-sol-macro-gen = { path = "crates/sol-macro-gen" } +forge-script-sequence = { path = "crates/script-sequence" } foundry-cheatcodes = { path = "crates/cheatcodes" } foundry-cheatcodes-spec = { path = "crates/cheatcodes/spec" } foundry-cli = { path = "crates/cli" } diff --git a/crates/script-sequence/Cargo.toml b/crates/script-sequence/Cargo.toml new file mode 100644 index 0000000000000..e128fe37b5ef7 --- /dev/null +++ b/crates/script-sequence/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "forge-script-sequence" +description = "Script sequence types" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[lints] +workspace = true + +[dependencies] +foundry-config.workspace = true +foundry-common.workspace = true +foundry-compilers = { workspace = true, features = ["full"] } + +serde.workspace = true +eyre.workspace = true +serde_json.workspace = true +tracing.workspace = true + +revm-inspectors.workspace = true + +alloy-rpc-types.workspace = true +alloy-primitives.workspace = true diff --git a/crates/script-sequence/src/lib.rs b/crates/script-sequence/src/lib.rs new file mode 100644 index 0000000000000..3aa5fc65a7666 --- /dev/null +++ b/crates/script-sequence/src/lib.rs @@ -0,0 +1,7 @@ +//! Script Sequence and related types. + +pub mod sequence; +pub mod transaction; + +pub use sequence::*; +pub use transaction::*; diff --git a/crates/script-sequence/src/sequence.rs b/crates/script-sequence/src/sequence.rs new file mode 100644 index 0000000000000..080c725be69b8 --- /dev/null +++ b/crates/script-sequence/src/sequence.rs @@ -0,0 +1,248 @@ +use crate::transaction::TransactionWithMetadata; +use alloy_primitives::{hex, map::HashMap, TxHash}; +use alloy_rpc_types::AnyTransactionReceipt; +use eyre::{ContextCompat, Result, WrapErr}; +use foundry_common::{fs, shell, TransactionMaybeSigned, SELECTOR_LEN}; +use foundry_compilers::ArtifactId; +use foundry_config::Config; +use serde::{Deserialize, Serialize}; +use std::{ + collections::VecDeque, + io::{BufWriter, Write}, + path::PathBuf, + time::{Duration, SystemTime, UNIX_EPOCH}, +}; + +pub const DRY_RUN_DIR: &str = "dry-run"; + +#[derive(Clone, Serialize, Deserialize)] +pub struct NestedValue { + pub internal_type: String, + pub value: String, +} + +/// Helper that saves the transactions sequence and its state on which transactions have been +/// broadcasted +#[derive(Clone, Default, Serialize, Deserialize)] +pub struct ScriptSequence { + pub transactions: VecDeque, + pub receipts: Vec, + pub libraries: Vec, + pub pending: Vec, + #[serde(skip)] + /// Contains paths to the sequence files + /// None if sequence should not be saved to disk (e.g. part of a multi-chain sequence) + pub paths: Option<(PathBuf, PathBuf)>, + pub returns: HashMap, + pub timestamp: u64, + pub chain: u64, + pub commit: Option, +} + +/// Sensitive values from the transactions in a script sequence +#[derive(Clone, Default, Serialize, Deserialize)] +pub struct SensitiveTransactionMetadata { + pub rpc: String, +} + +/// Sensitive info from the script sequence which is saved into the cache folder +#[derive(Clone, Default, Serialize, Deserialize)] +pub struct SensitiveScriptSequence { + pub transactions: VecDeque, +} + +impl From for SensitiveScriptSequence { + fn from(sequence: ScriptSequence) -> Self { + Self { + transactions: sequence + .transactions + .iter() + .map(|tx| SensitiveTransactionMetadata { rpc: tx.rpc.clone() }) + .collect(), + } + } +} + +impl ScriptSequence { + /// Loads The sequence for the corresponding json file + pub fn load( + config: &Config, + sig: &str, + target: &ArtifactId, + chain_id: u64, + dry_run: bool, + ) -> Result { + let (path, sensitive_path) = Self::get_paths(config, sig, target, chain_id, dry_run)?; + + let mut script_sequence: Self = fs::read_json_file(&path) + .wrap_err(format!("Deployment not found for chain `{chain_id}`."))?; + + let sensitive_script_sequence: SensitiveScriptSequence = fs::read_json_file( + &sensitive_path, + ) + .wrap_err(format!("Deployment's sensitive details not found for chain `{chain_id}`."))?; + + script_sequence.fill_sensitive(&sensitive_script_sequence); + + script_sequence.paths = Some((path, sensitive_path)); + + Ok(script_sequence) + } + + /// Saves the transactions as file if it's a standalone deployment. + /// `save_ts` should be set to true for checkpoint updates, which might happen many times and + /// could result in us saving many identical files. + pub fn save(&mut self, silent: bool, save_ts: bool) -> Result<()> { + self.sort_receipts(); + + if self.transactions.is_empty() { + return Ok(()) + } + + let Some((path, sensitive_path)) = self.paths.clone() else { return Ok(()) }; + + self.timestamp = now().as_secs(); + let ts_name = format!("run-{}.json", self.timestamp); + + let sensitive_script_sequence: SensitiveScriptSequence = self.clone().into(); + + // broadcast folder writes + //../run-latest.json + let mut writer = BufWriter::new(fs::create_file(&path)?); + serde_json::to_writer_pretty(&mut writer, &self)?; + writer.flush()?; + if save_ts { + //../run-[timestamp].json + fs::copy(&path, path.with_file_name(&ts_name))?; + } + + // cache folder writes + //../run-latest.json + let mut writer = BufWriter::new(fs::create_file(&sensitive_path)?); + serde_json::to_writer_pretty(&mut writer, &sensitive_script_sequence)?; + writer.flush()?; + if save_ts { + //../run-[timestamp].json + fs::copy(&sensitive_path, sensitive_path.with_file_name(&ts_name))?; + } + + if !silent { + shell::println(format!("\nTransactions saved to: {}\n", path.display()))?; + shell::println(format!("Sensitive values saved to: {}\n", sensitive_path.display()))?; + } + + Ok(()) + } + + pub fn add_receipt(&mut self, receipt: AnyTransactionReceipt) { + self.receipts.push(receipt); + } + + /// Sorts all receipts with ascending transaction index + pub fn sort_receipts(&mut self) { + self.receipts.sort_by_key(|r| (r.block_number, r.transaction_index)); + } + + pub fn add_pending(&mut self, index: usize, tx_hash: TxHash) { + if !self.pending.contains(&tx_hash) { + self.transactions[index].hash = Some(tx_hash); + self.pending.push(tx_hash); + } + } + + pub fn remove_pending(&mut self, tx_hash: TxHash) { + self.pending.retain(|element| element != &tx_hash); + } + + /// Gets paths in the formats + /// `./broadcast/[contract_filename]/[chain_id]/[sig]-[timestamp].json` and + /// `./cache/[contract_filename]/[chain_id]/[sig]-[timestamp].json`. + pub fn get_paths( + config: &Config, + sig: &str, + target: &ArtifactId, + chain_id: u64, + dry_run: bool, + ) -> Result<(PathBuf, PathBuf)> { + let mut broadcast = config.broadcast.to_path_buf(); + let mut cache = config.cache_path.to_path_buf(); + let mut common = PathBuf::new(); + + let target_fname = target.source.file_name().wrap_err("No filename.")?; + common.push(target_fname); + common.push(chain_id.to_string()); + if dry_run { + common.push(DRY_RUN_DIR); + } + + broadcast.push(common.clone()); + cache.push(common); + + fs::create_dir_all(&broadcast)?; + fs::create_dir_all(&cache)?; + + // TODO: ideally we want the name of the function here if sig is calldata + let filename = sig_to_file_name(sig); + + broadcast.push(format!("{filename}-latest.json")); + cache.push(format!("{filename}-latest.json")); + + Ok((broadcast, cache)) + } + + /// Returns the first RPC URL of this sequence. + pub fn rpc_url(&self) -> &str { + self.transactions.front().expect("empty sequence").rpc.as_str() + } + + /// Returns the list of the transactions without the metadata. + pub fn transactions(&self) -> impl Iterator { + self.transactions.iter().map(|tx| tx.tx()) + } + + pub fn fill_sensitive(&mut self, sensitive: &SensitiveScriptSequence) { + self.transactions + .iter_mut() + .enumerate() + .for_each(|(i, tx)| tx.rpc.clone_from(&sensitive.transactions[i].rpc)); + } +} + +/// Converts the `sig` argument into the corresponding file path. +/// +/// This accepts either the signature of the function or the raw calldata. +pub fn sig_to_file_name(sig: &str) -> String { + if let Some((name, _)) = sig.split_once('(') { + // strip until call argument parenthesis + return name.to_string() + } + // assume calldata if `sig` is hex + if let Ok(calldata) = hex::decode(sig) { + // in which case we return the function signature + return hex::encode(&calldata[..SELECTOR_LEN]) + } + + // return sig as is + sig.to_string() +} + +pub fn now() -> Duration { + SystemTime::now().duration_since(UNIX_EPOCH).expect("time went backwards") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn can_convert_sig() { + assert_eq!(sig_to_file_name("run()").as_str(), "run"); + assert_eq!( + sig_to_file_name( + "522bb704000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfFFb92266" + ) + .as_str(), + "522bb704" + ); + } +} diff --git a/crates/script-sequence/src/transaction.rs b/crates/script-sequence/src/transaction.rs new file mode 100644 index 0000000000000..7f72a4d30980c --- /dev/null +++ b/crates/script-sequence/src/transaction.rs @@ -0,0 +1,75 @@ +use alloy_primitives::{Address, Bytes, B256}; +use foundry_common::TransactionMaybeSigned; +use revm_inspectors::tracing::types::CallKind; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct AdditionalContract { + #[serde(rename = "transactionType")] + pub opcode: CallKind, + pub address: Address, + pub init_code: Bytes, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct TransactionWithMetadata { + pub hash: Option, + #[serde(rename = "transactionType")] + pub opcode: CallKind, + #[serde(default = "default_string")] + pub contract_name: Option, + #[serde(default = "default_address")] + pub contract_address: Option
, + #[serde(default = "default_string")] + pub function: Option, + #[serde(default = "default_vec_of_strings")] + pub arguments: Option>, + #[serde(skip)] + pub rpc: String, + pub transaction: TransactionMaybeSigned, + pub additional_contracts: Vec, + pub is_fixed_gas_limit: bool, +} + +fn default_string() -> Option { + Some(String::new()) +} + +fn default_address() -> Option
{ + Some(Address::ZERO) +} + +fn default_vec_of_strings() -> Option> { + Some(vec![]) +} + +impl TransactionWithMetadata { + pub fn from_tx_request(transaction: TransactionMaybeSigned) -> Self { + Self { + transaction, + hash: Default::default(), + opcode: Default::default(), + contract_name: Default::default(), + contract_address: Default::default(), + function: Default::default(), + arguments: Default::default(), + is_fixed_gas_limit: Default::default(), + additional_contracts: Default::default(), + rpc: Default::default(), + } + } + + pub fn tx(&self) -> &TransactionMaybeSigned { + &self.transaction + } + + pub fn tx_mut(&mut self) -> &mut TransactionMaybeSigned { + &mut self.transaction + } + + pub fn is_create2(&self) -> bool { + self.opcode == CallKind::Create2 + } +} diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 37cc13741a7bc..0d4810da66c14 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -23,6 +23,7 @@ foundry-debugger.workspace = true foundry-cheatcodes.workspace = true foundry-wallets.workspace = true foundry-linking.workspace = true +forge-script-sequence.workspace = true serde.workspace = true eyre.workspace = true diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index cb99b26a1d5f4..82f28562d62d5 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -163,8 +163,8 @@ impl SendTransactionsKind { } /// State after we have bundled all -/// [`TransactionWithMetadata`](crate::transaction::TransactionWithMetadata) objects into a single -/// [`ScriptSequenceKind`] object containing one or more script sequences. +/// [`TransactionWithMetadata`](forge_script_sequence::TransactionWithMetadata) objects into a +/// single [`ScriptSequenceKind`] object containing one or more script sequences. pub struct BundledState { pub args: ScriptArgs, pub script_config: ScriptConfig, diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 3f5ffae81c8d7..4b357ae23bd75 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -1,13 +1,11 @@ use crate::{ - broadcast::BundledState, - execute::LinkedState, - multi_sequence::MultiChainSequence, - sequence::{ScriptSequence, ScriptSequenceKind}, - ScriptArgs, ScriptConfig, + broadcast::BundledState, execute::LinkedState, multi_sequence::MultiChainSequence, + sequence::ScriptSequenceKind, ScriptArgs, ScriptConfig, }; use alloy_primitives::{Bytes, B256}; use alloy_provider::Provider; use eyre::{OptionExt, Result}; +use forge_script_sequence::ScriptSequence; use foundry_cheatcodes::Wallets; use foundry_common::{ compile::ProjectCompiler, provider::try_get_http_provider, ContractData, ContractsByArtifact, diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index de06fa0c19de3..af44f2062802d 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -8,7 +8,6 @@ #[macro_use] extern crate tracing; -use self::transaction::AdditionalContract; use crate::runner::ScriptRunner; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{ @@ -22,6 +21,7 @@ use build::PreprocessedState; use clap::{Parser, ValueHint}; use dialoguer::Confirm; use eyre::{ContextCompat, Result}; +use forge_script_sequence::{AdditionalContract, NestedValue}; use forge_verify::RetryArgs; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ @@ -50,7 +50,7 @@ use foundry_evm::{ traces::{TraceMode, Traces}, }; use foundry_wallets::MultiWalletOpts; -use serde::{Deserialize, Serialize}; +use serde::Serialize; use yansi::Paint; mod broadcast; @@ -516,12 +516,6 @@ struct JsonResult<'a> { result: &'a ScriptResult, } -#[derive(Clone, Serialize, Deserialize)] -pub struct NestedValue { - pub internal_type: String, - pub value: String, -} - #[derive(Clone, Debug)] pub struct ScriptConfig { pub config: Config, diff --git a/crates/script/src/multi_sequence.rs b/crates/script/src/multi_sequence.rs index 24490bf017e9b..0aabcf79ac3f3 100644 --- a/crates/script/src/multi_sequence.rs +++ b/crates/script/src/multi_sequence.rs @@ -1,6 +1,7 @@ -use super::sequence::{sig_to_file_name, ScriptSequence, SensitiveScriptSequence, DRY_RUN_DIR}; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_cli::utils::now; +use forge_script_sequence::{ + now, sig_to_file_name, ScriptSequence, SensitiveScriptSequence, DRY_RUN_DIR, +}; use foundry_common::fs; use foundry_compilers::ArtifactId; use foundry_config::Config; diff --git a/crates/script/src/progress.rs b/crates/script/src/progress.rs index b8bedb6cdbadb..d9fa53bb33566 100644 --- a/crates/script/src/progress.rs +++ b/crates/script/src/progress.rs @@ -1,13 +1,11 @@ -use crate::{ - receipts::{check_tx_status, format_receipt, TxStatus}, - sequence::ScriptSequence, -}; +use crate::receipts::{check_tx_status, format_receipt, TxStatus}; use alloy_chains::Chain; use alloy_primitives::{ map::{B256HashMap, HashMap}, B256, }; use eyre::Result; +use forge_script_sequence::ScriptSequence; use foundry_cli::utils::init_progress; use foundry_common::provider::RetryProvider; use futures::StreamExt; diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 3c31773ba3abd..8bdb35bb33872 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -1,23 +1,10 @@ -use super::{multi_sequence::MultiChainSequence, NestedValue}; -use crate::{ - transaction::{AdditionalContract, TransactionWithMetadata}, - verify::VerifyBundle, -}; -use alloy_primitives::{hex, map::HashMap, Address, TxHash}; -use alloy_rpc_types::AnyTransactionReceipt; -use eyre::{eyre, ContextCompat, Result, WrapErr}; -use forge_verify::provider::VerificationProviderType; -use foundry_cli::utils::{now, Git}; -use foundry_common::{fs, shell, TransactionMaybeSigned, SELECTOR_LEN}; +use crate::multi_sequence::MultiChainSequence; +use eyre::Result; +use forge_script_sequence::ScriptSequence; +use foundry_cli::utils::Git; use foundry_compilers::ArtifactId; use foundry_config::Config; -use serde::{Deserialize, Serialize}; -use std::{ - collections::VecDeque, - io::{BufWriter, Write}, - path::{Path, PathBuf}, -}; -use yansi::Paint; +use std::path::Path; /// Returns the commit hash of the project if it exists pub fn get_commit_hash(root: &Path) -> Option { @@ -79,330 +66,3 @@ impl Drop for ScriptSequenceKind { } } } - -pub const DRY_RUN_DIR: &str = "dry-run"; - -/// Helper that saves the transactions sequence and its state on which transactions have been -/// broadcasted -#[derive(Clone, Default, Serialize, Deserialize)] -pub struct ScriptSequence { - pub transactions: VecDeque, - pub receipts: Vec, - pub libraries: Vec, - pub pending: Vec, - #[serde(skip)] - /// Contains paths to the sequence files - /// None if sequence should not be saved to disk (e.g. part of a multi-chain sequence) - pub paths: Option<(PathBuf, PathBuf)>, - pub returns: HashMap, - pub timestamp: u64, - pub chain: u64, - pub commit: Option, -} - -/// Sensitive values from the transactions in a script sequence -#[derive(Clone, Default, Serialize, Deserialize)] -pub struct SensitiveTransactionMetadata { - pub rpc: String, -} - -/// Sensitive info from the script sequence which is saved into the cache folder -#[derive(Clone, Default, Serialize, Deserialize)] -pub struct SensitiveScriptSequence { - pub transactions: VecDeque, -} - -impl From for SensitiveScriptSequence { - fn from(sequence: ScriptSequence) -> Self { - Self { - transactions: sequence - .transactions - .iter() - .map(|tx| SensitiveTransactionMetadata { rpc: tx.rpc.clone() }) - .collect(), - } - } -} - -impl ScriptSequence { - /// Loads The sequence for the corresponding json file - pub fn load( - config: &Config, - sig: &str, - target: &ArtifactId, - chain_id: u64, - dry_run: bool, - ) -> Result { - let (path, sensitive_path) = Self::get_paths(config, sig, target, chain_id, dry_run)?; - - let mut script_sequence: Self = foundry_compilers::utils::read_json_file(&path) - .wrap_err(format!("Deployment not found for chain `{chain_id}`."))?; - - let sensitive_script_sequence: SensitiveScriptSequence = - foundry_compilers::utils::read_json_file(&sensitive_path).wrap_err(format!( - "Deployment's sensitive details not found for chain `{chain_id}`." - ))?; - - script_sequence.fill_sensitive(&sensitive_script_sequence); - - script_sequence.paths = Some((path, sensitive_path)); - - Ok(script_sequence) - } - - /// Saves the transactions as file if it's a standalone deployment. - /// `save_ts` should be set to true for checkpoint updates, which might happen many times and - /// could result in us saving many identical files. - pub fn save(&mut self, silent: bool, save_ts: bool) -> Result<()> { - self.sort_receipts(); - - if self.transactions.is_empty() { - return Ok(()) - } - - let Some((path, sensitive_path)) = self.paths.clone() else { return Ok(()) }; - - self.timestamp = now().as_secs(); - let ts_name = format!("run-{}.json", self.timestamp); - - let sensitive_script_sequence: SensitiveScriptSequence = self.clone().into(); - - // broadcast folder writes - //../run-latest.json - let mut writer = BufWriter::new(fs::create_file(&path)?); - serde_json::to_writer_pretty(&mut writer, &self)?; - writer.flush()?; - if save_ts { - //../run-[timestamp].json - fs::copy(&path, path.with_file_name(&ts_name))?; - } - - // cache folder writes - //../run-latest.json - let mut writer = BufWriter::new(fs::create_file(&sensitive_path)?); - serde_json::to_writer_pretty(&mut writer, &sensitive_script_sequence)?; - writer.flush()?; - if save_ts { - //../run-[timestamp].json - fs::copy(&sensitive_path, sensitive_path.with_file_name(&ts_name))?; - } - - if !silent { - shell::println(format!("\nTransactions saved to: {}\n", path.display()))?; - shell::println(format!("Sensitive values saved to: {}\n", sensitive_path.display()))?; - } - - Ok(()) - } - - pub fn add_receipt(&mut self, receipt: AnyTransactionReceipt) { - self.receipts.push(receipt); - } - - /// Sorts all receipts with ascending transaction index - pub fn sort_receipts(&mut self) { - self.receipts.sort_by_key(|r| (r.block_number, r.transaction_index)); - } - - pub fn add_pending(&mut self, index: usize, tx_hash: TxHash) { - if !self.pending.contains(&tx_hash) { - self.transactions[index].hash = Some(tx_hash); - self.pending.push(tx_hash); - } - } - - pub fn remove_pending(&mut self, tx_hash: TxHash) { - self.pending.retain(|element| element != &tx_hash); - } - - /// Gets paths in the formats - /// `./broadcast/[contract_filename]/[chain_id]/[sig]-[timestamp].json` and - /// `./cache/[contract_filename]/[chain_id]/[sig]-[timestamp].json`. - pub fn get_paths( - config: &Config, - sig: &str, - target: &ArtifactId, - chain_id: u64, - dry_run: bool, - ) -> Result<(PathBuf, PathBuf)> { - let mut broadcast = config.broadcast.to_path_buf(); - let mut cache = config.cache_path.to_path_buf(); - let mut common = PathBuf::new(); - - let target_fname = target.source.file_name().wrap_err("No filename.")?; - common.push(target_fname); - common.push(chain_id.to_string()); - if dry_run { - common.push(DRY_RUN_DIR); - } - - broadcast.push(common.clone()); - cache.push(common); - - fs::create_dir_all(&broadcast)?; - fs::create_dir_all(&cache)?; - - // TODO: ideally we want the name of the function here if sig is calldata - let filename = sig_to_file_name(sig); - - broadcast.push(format!("{filename}-latest.json")); - cache.push(format!("{filename}-latest.json")); - - Ok((broadcast, cache)) - } - - /// Given the broadcast log, it matches transactions with receipts, and tries to verify any - /// created contract on etherscan. - pub async fn verify_contracts( - &mut self, - config: &Config, - mut verify: VerifyBundle, - ) -> Result<()> { - trace!(target: "script", "verifying {} contracts [{}]", verify.known_contracts.len(), self.chain); - - verify.set_chain(config, self.chain.into()); - - if verify.etherscan.has_key() || - verify.verifier.verifier != VerificationProviderType::Etherscan - { - trace!(target: "script", "prepare future verifications"); - - let mut future_verifications = Vec::with_capacity(self.receipts.len()); - let mut unverifiable_contracts = vec![]; - - // Make sure the receipts have the right order first. - self.sort_receipts(); - - for (receipt, tx) in self.receipts.iter_mut().zip(self.transactions.iter()) { - // create2 hash offset - let mut offset = 0; - - if tx.is_create2() { - receipt.contract_address = tx.contract_address; - offset = 32; - } - - // Verify contract created directly from the transaction - if let (Some(address), Some(data)) = (receipt.contract_address, tx.tx().input()) { - match verify.get_verify_args(address, offset, data, &self.libraries) { - Some(verify) => future_verifications.push(verify.run()), - None => unverifiable_contracts.push(address), - }; - } - - // Verify potential contracts created during the transaction execution - for AdditionalContract { address, init_code, .. } in &tx.additional_contracts { - match verify.get_verify_args(*address, 0, init_code.as_ref(), &self.libraries) { - Some(verify) => future_verifications.push(verify.run()), - None => unverifiable_contracts.push(*address), - }; - } - } - - trace!(target: "script", "collected {} verification jobs and {} unverifiable contracts", future_verifications.len(), unverifiable_contracts.len()); - - self.check_unverified(unverifiable_contracts, verify); - - let num_verifications = future_verifications.len(); - let mut num_of_successful_verifications = 0; - println!("##\nStart verification for ({num_verifications}) contracts"); - for verification in future_verifications { - match verification.await { - Ok(_) => { - num_of_successful_verifications += 1; - } - Err(err) => eprintln!("Error during verification: {err:#}"), - } - } - - if num_of_successful_verifications < num_verifications { - return Err(eyre!("Not all ({num_of_successful_verifications} / {num_verifications}) contracts were verified!")) - } - - println!("All ({num_verifications}) contracts were verified!"); - } - - Ok(()) - } - - /// Let the user know if there are any contracts which can not be verified. Also, present some - /// hints on potential causes. - fn check_unverified(&self, unverifiable_contracts: Vec
, verify: VerifyBundle) { - if !unverifiable_contracts.is_empty() { - println!( - "\n{}", - format!( - "We haven't found any matching bytecode for the following contracts: {:?}.\n\n{}", - unverifiable_contracts, - "This may occur when resuming a verification, but the underlying source code or compiler version has changed." - ) - .yellow() - .bold(), - ); - - if let Some(commit) = &self.commit { - let current_commit = verify - .project_paths - .root - .map(|root| get_commit_hash(&root).unwrap_or_default()) - .unwrap_or_default(); - - if ¤t_commit != commit { - println!("\tScript was broadcasted on commit `{commit}`, but we are at `{current_commit}`."); - } - } - } - } - - /// Returns the first RPC URL of this sequence. - pub fn rpc_url(&self) -> &str { - self.transactions.front().expect("empty sequence").rpc.as_str() - } - - /// Returns the list of the transactions without the metadata. - pub fn transactions(&self) -> impl Iterator { - self.transactions.iter().map(|tx| tx.tx()) - } - - pub fn fill_sensitive(&mut self, sensitive: &SensitiveScriptSequence) { - self.transactions - .iter_mut() - .enumerate() - .for_each(|(i, tx)| tx.rpc.clone_from(&sensitive.transactions[i].rpc)); - } -} - -/// Converts the `sig` argument into the corresponding file path. -/// -/// This accepts either the signature of the function or the raw calldata. -pub fn sig_to_file_name(sig: &str) -> String { - if let Some((name, _)) = sig.split_once('(') { - // strip until call argument parenthesis - return name.to_string() - } - // assume calldata if `sig` is hex - if let Ok(calldata) = hex::decode(sig) { - // in which case we return the function signature - return hex::encode(&calldata[..SELECTOR_LEN]) - } - - // return sig as is - sig.to_string() -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_convert_sig() { - assert_eq!(sig_to_file_name("run()").as_str(), "run"); - assert_eq!( - sig_to_file_name( - "522bb704000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfFFb92266" - ) - .as_str(), - "522bb704" - ); - } -} diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 2fbfbcffafedb..44788672a2da7 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -1,9 +1,6 @@ use super::{ - multi_sequence::MultiChainSequence, - providers::ProvidersManager, - runner::ScriptRunner, - sequence::{ScriptSequence, ScriptSequenceKind}, - transaction::TransactionWithMetadata, + multi_sequence::MultiChainSequence, providers::ProvidersManager, runner::ScriptRunner, + sequence::ScriptSequenceKind, transaction::ScriptTransactionBuilder, }; use crate::{ broadcast::{estimate_gas, BundledState}, @@ -16,6 +13,7 @@ use alloy_network::TransactionBuilder; use alloy_primitives::{map::HashMap, utils::format_units, Address, Bytes, TxKind, U256}; use dialoguer::Confirm; use eyre::{Context, Result}; +use forge_script_sequence::{ScriptSequence, TransactionWithMetadata}; use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_different_gas_calc, now}; use foundry_common::{get_contract_name, shell, ContractData}; @@ -60,12 +58,19 @@ impl PreSimulationState { .into_iter() .map(|tx| { let rpc = tx.rpc.expect("missing broadcastable tx rpc url"); - TransactionWithMetadata::new( - tx.transaction, - rpc, - &address_to_abi, - &self.execution_artifacts.decoder, - ) + let sender = tx.transaction.from().expect("all transactions should have a sender"); + let nonce = tx.transaction.nonce().expect("all transactions should have a sender"); + let to = tx.transaction.to(); + + let mut builder = ScriptTransactionBuilder::new(tx.transaction, rpc); + + if let Some(TxKind::Call(_)) = to { + builder.set_call(&address_to_abi, &self.execution_artifacts.decoder)?; + } else { + builder.set_create(false, sender.create(nonce), &address_to_abi)?; + } + + Ok(builder.build()) }) .collect::>>()?; @@ -111,7 +116,7 @@ impl PreSimulationState { .map(|mut transaction| async { let mut runner = runners.get(&transaction.rpc).expect("invalid rpc url").write(); - let tx = &mut transaction.transaction; + let tx = transaction.tx_mut(); let to = if let Some(TxKind::Call(to)) = tx.to() { Some(to) } else { None }; let result = runner .simulate( @@ -138,8 +143,9 @@ impl PreSimulationState { false }; - let transaction = - transaction.with_execution_result(&result, self.args.gas_estimate_multiplier); + let transaction = ScriptTransactionBuilder::from(transaction) + .with_execution_result(&result, self.args.gas_estimate_multiplier) + .build(); eyre::Ok((Some(transaction), is_noop_tx, result.traces)) }) @@ -265,10 +271,10 @@ impl FilledTransactionsState { let mut txes_iter = self.transactions.clone().into_iter().peekable(); while let Some(mut tx) = txes_iter.next() { - let tx_rpc = tx.rpc.clone(); + let tx_rpc = tx.rpc.to_owned(); let provider_info = manager.get_or_init_provider(&tx.rpc, self.args.legacy).await?; - if let Some(tx) = tx.transaction.as_unsigned_mut() { + if let Some(tx) = tx.tx_mut().as_unsigned_mut() { // Handles chain specific requirements for unsigned transactions. tx.set_chain_id(provider_info.chain); } @@ -418,7 +424,7 @@ impl FilledTransactionsState { }) .collect(); - Ok(ScriptSequence { + let sequence = ScriptSequence { transactions, returns: self.execution_artifacts.returns.clone(), receipts: vec![], @@ -428,6 +434,7 @@ impl FilledTransactionsState { libraries, chain, commit, - }) + }; + Ok(sequence) } } diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 639c5f022ac18..39bf0490ea426 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -1,88 +1,41 @@ use super::ScriptResult; use alloy_dyn_abi::JsonAbiExt; -use alloy_primitives::{hex, Address, Bytes, TxKind, B256}; -use eyre::{Result, WrapErr}; +use alloy_primitives::{hex, Address, TxKind, B256}; +use eyre::Result; +use forge_script_sequence::TransactionWithMetadata; use foundry_common::{fmt::format_token_raw, ContractData, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; use itertools::Itertools; use revm_inspectors::tracing::types::CallKind; -use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; -#[derive(Clone, Debug, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct AdditionalContract { - #[serde(rename = "transactionType")] - pub opcode: CallKind, - pub address: Address, - pub init_code: Bytes, +#[derive(Debug)] +pub struct ScriptTransactionBuilder { + transaction: TransactionWithMetadata, } -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct TransactionWithMetadata { - pub hash: Option, - #[serde(rename = "transactionType")] - pub opcode: CallKind, - #[serde(default = "default_string")] - pub contract_name: Option, - #[serde(default = "default_address")] - pub contract_address: Option
, - #[serde(default = "default_string")] - pub function: Option, - #[serde(default = "default_vec_of_strings")] - pub arguments: Option>, - #[serde(skip)] - pub rpc: String, - pub transaction: TransactionMaybeSigned, - pub additional_contracts: Vec, - pub is_fixed_gas_limit: bool, -} - -fn default_string() -> Option { - Some(String::new()) -} - -fn default_address() -> Option
{ - Some(Address::ZERO) -} - -fn default_vec_of_strings() -> Option> { - Some(vec![]) -} +impl ScriptTransactionBuilder { + pub fn new(transaction: TransactionMaybeSigned, rpc: String) -> Self { + let mut transaction = TransactionWithMetadata::from_tx_request(transaction); + transaction.rpc = rpc; + // If tx.gas is already set that means it was specified in script + transaction.is_fixed_gas_limit = transaction.tx().gas().is_some(); -impl TransactionWithMetadata { - pub fn from_tx_request(transaction: TransactionMaybeSigned) -> Self { - Self { - transaction, - hash: Default::default(), - opcode: Default::default(), - contract_name: Default::default(), - contract_address: Default::default(), - function: Default::default(), - arguments: Default::default(), - is_fixed_gas_limit: Default::default(), - additional_contracts: Default::default(), - rpc: Default::default(), - } + Self { transaction } } - pub fn new( - transaction: TransactionMaybeSigned, - rpc: String, + /// Populate the transaction as CALL tx + pub fn set_call( + &mut self, local_contracts: &BTreeMap, decoder: &CallTraceDecoder, - ) -> Result { - let mut metadata = Self::from_tx_request(transaction); - metadata.rpc = rpc; - // If tx.gas is already set that means it was specified in script - metadata.is_fixed_gas_limit = metadata.tx().gas().is_some(); - - if let Some(TxKind::Call(to)) = metadata.transaction.to() { + ) -> Result<()> { + if let Some(TxKind::Call(to)) = self.transaction.transaction.to() { if to == DEFAULT_CREATE2_DEPLOYER { - if let Some(input) = metadata.transaction.input() { + if let Some(input) = self.transaction.transaction.input() { let (salt, init_code) = input.split_at(32); - metadata.set_create( + + self.set_create( true, DEFAULT_CREATE2_DEPLOYER .create2_from_code(B256::from_slice(salt), init_code), @@ -90,65 +43,68 @@ impl TransactionWithMetadata { )?; } } else { - metadata - .set_call(to, local_contracts, decoder) - .wrap_err("Could not decode transaction type.")?; - } - } else { - let sender = - metadata.transaction.from().expect("all transactions should have a sender"); - let nonce = metadata.transaction.nonce().expect("all transactions should have a nonce"); - metadata.set_create(false, sender.create(nonce), local_contracts)?; - } + self.transaction.opcode = CallKind::Call; + self.transaction.contract_address = Some(to); - Ok(metadata) - } - - /// Populates additional data from the transaction execution result. - pub fn with_execution_result( - mut self, - result: &ScriptResult, - gas_estimate_multiplier: u64, - ) -> Self { - let mut created_contracts = result.get_created_contracts(); + let Some(data) = self.transaction.transaction.input() else { return Ok(()) }; - // Add the additional contracts created in this transaction, so we can verify them later. - created_contracts.retain(|contract| { - // Filter out the contract that was created by the transaction itself. - self.contract_address.map_or(true, |addr| addr != contract.address) - }); + if data.len() < SELECTOR_LEN { + return Ok(()); + } - if !self.is_fixed_gas_limit { - if let Some(unsigned) = self.transaction.as_unsigned_mut() { - // We inflate the gas used by the user specified percentage - unsigned.gas = Some(result.gas_used * gas_estimate_multiplier / 100); + let (selector, data) = data.split_at(SELECTOR_LEN); + + let function = if let Some(info) = local_contracts.get(&to) { + // This CALL is made to a local contract. + self.transaction.contract_name = Some(info.name.clone()); + info.abi.functions().find(|function| function.selector() == selector) + } else { + // This CALL is made to an external contract; try to decode it from the given + // decoder. + decoder.functions.get(selector).and_then(|v| v.first()) + }; + + if let Some(function) = function { + self.transaction.function = Some(function.signature()); + + let values = function.abi_decode_input(data, false).inspect_err(|_| { + error!( + contract=?self.transaction.contract_name, + signature=?function, + data=hex::encode(data), + "Failed to decode function arguments", + ); + })?; + self.transaction.arguments = + Some(values.iter().map(format_token_raw).collect()); + } } } - self + Ok(()) } /// Populate the transaction as CREATE tx /// /// If this is a CREATE2 transaction this attempt to decode the arguments from the CREATE2 /// deployer's function - fn set_create( + pub fn set_create( &mut self, is_create2: bool, address: Address, contracts: &BTreeMap, ) -> Result<()> { if is_create2 { - self.opcode = CallKind::Create2; + self.transaction.opcode = CallKind::Create2; } else { - self.opcode = CallKind::Create; + self.transaction.opcode = CallKind::Create; } let info = contracts.get(&address); - self.contract_name = info.map(|info| info.name.clone()); - self.contract_address = Some(address); + self.transaction.contract_name = info.map(|info| info.name.clone()); + self.transaction.contract_address = Some(address); - let Some(data) = self.transaction.input() else { return Ok(()) }; + let Some(data) = self.transaction.transaction.input() else { return Ok(()) }; let Some(info) = info else { return Ok(()) }; let Some(bytecode) = info.bytecode() else { return Ok(()) }; @@ -171,70 +127,51 @@ impl TransactionWithMetadata { let Some(constructor) = info.abi.constructor() else { return Ok(()) }; let values = constructor.abi_decode_input(constructor_args, false).inspect_err(|_| { - error!( - contract=?self.contract_name, - signature=%format!("constructor({})", constructor.inputs.iter().map(|p| &p.ty).format(",")), - is_create2, - constructor_args=%hex::encode(constructor_args), - "Failed to decode constructor arguments", - ); - debug!(full_data=%hex::encode(data), bytecode=%hex::encode(creation_code)); - })?; - self.arguments = Some(values.iter().map(format_token_raw).collect()); + error!( + contract=?self.transaction.contract_name, + signature=%format!("constructor({})", constructor.inputs.iter().map(|p| &p.ty).format(",")), + is_create2, + constructor_args=%hex::encode(constructor_args), + "Failed to decode constructor arguments", + ); + debug!(full_data=%hex::encode(data), bytecode=%hex::encode(creation_code)); + })?; + self.transaction.arguments = Some(values.iter().map(format_token_raw).collect()); Ok(()) } - /// Populate the transaction as CALL tx - fn set_call( - &mut self, - target: Address, - local_contracts: &BTreeMap, - decoder: &CallTraceDecoder, - ) -> Result<()> { - self.opcode = CallKind::Call; - self.contract_address = Some(target); - - let Some(data) = self.transaction.input() else { return Ok(()) }; - if data.len() < SELECTOR_LEN { - return Ok(()); - } - let (selector, data) = data.split_at(SELECTOR_LEN); + /// Populates additional data from the transaction execution result. + pub fn with_execution_result( + mut self, + result: &ScriptResult, + gas_estimate_multiplier: u64, + ) -> Self { + let mut created_contracts = result.get_created_contracts(); - let function = if let Some(info) = local_contracts.get(&target) { - // This CALL is made to a local contract. - self.contract_name = Some(info.name.clone()); - info.abi.functions().find(|function| function.selector() == selector) - } else { - // This CALL is made to an external contract; try to decode it from the given decoder. - decoder.functions.get(selector).and_then(|v| v.first()) - }; - if let Some(function) = function { - self.function = Some(function.signature()); + // Add the additional contracts created in this transaction, so we can verify them later. + created_contracts.retain(|contract| { + // Filter out the contract that was created by the transaction itself. + self.transaction.contract_address.map_or(true, |addr| addr != contract.address) + }); - let values = function.abi_decode_input(data, false).inspect_err(|_| { - error!( - contract=?self.contract_name, - signature=?function, - data=hex::encode(data), - "Failed to decode function arguments", - ); - })?; - self.arguments = Some(values.iter().map(format_token_raw).collect()); + if !self.transaction.is_fixed_gas_limit { + if let Some(unsigned) = self.transaction.transaction.as_unsigned_mut() { + // We inflate the gas used by the user specified percentage + unsigned.gas = Some(result.gas_used * gas_estimate_multiplier / 100); + } } - Ok(()) - } - - pub fn tx(&self) -> &TransactionMaybeSigned { - &self.transaction + self } - pub fn tx_mut(&mut self) -> &mut TransactionMaybeSigned { - &mut self.transaction + pub fn build(self) -> TransactionWithMetadata { + self.transaction } +} - pub fn is_create2(&self) -> bool { - self.opcode == CallKind::Create2 +impl From for ScriptTransactionBuilder { + fn from(transaction: TransactionWithMetadata) -> Self { + Self { transaction } } } diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 18ee6ccf2937c..74cc4a3f94925 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -1,12 +1,18 @@ -use crate::{build::LinkedBuildData, sequence::ScriptSequenceKind, ScriptArgs, ScriptConfig}; +use crate::{ + build::LinkedBuildData, + sequence::{get_commit_hash, ScriptSequenceKind}, + ScriptArgs, ScriptConfig, +}; use alloy_primitives::{hex, Address}; -use eyre::Result; -use forge_verify::{RetryArgs, VerifierArgs, VerifyArgs}; +use eyre::{eyre, Result}; +use forge_script_sequence::{AdditionalContract, ScriptSequence}; +use forge_verify::{provider::VerificationProviderType, RetryArgs, VerifierArgs, VerifyArgs}; use foundry_cli::opts::{EtherscanOpts, ProjectPathsArgs}; use foundry_common::ContractsByArtifact; use foundry_compilers::{info::ContractInfo, Project}; use foundry_config::{Chain, Config}; use semver::Version; +use yansi::Paint; /// State after we have broadcasted the script. /// It is assumed that at this point [BroadcastedState::sequence] contains receipts for all @@ -31,7 +37,7 @@ impl BroadcastedState { ); for sequence in sequence.sequences_mut() { - sequence.verify_contracts(&script_config.config, verify.clone()).await?; + verify_contracts(sequence, &script_config.config, verify.clone()).await?; } Ok(()) @@ -158,3 +164,107 @@ impl VerifyBundle { None } } + +/// Given the broadcast log, it matches transactions with receipts, and tries to verify any +/// created contract on etherscan. +async fn verify_contracts( + sequence: &mut ScriptSequence, + config: &Config, + mut verify: VerifyBundle, +) -> Result<()> { + trace!(target: "script", "verifying {} contracts [{}]", verify.known_contracts.len(), sequence.chain); + + verify.set_chain(config, sequence.chain.into()); + + if verify.etherscan.has_key() || verify.verifier.verifier != VerificationProviderType::Etherscan + { + trace!(target: "script", "prepare future verifications"); + + let mut future_verifications = Vec::with_capacity(sequence.receipts.len()); + let mut unverifiable_contracts = vec![]; + + // Make sure the receipts have the right order first. + sequence.sort_receipts(); + + for (receipt, tx) in sequence.receipts.iter_mut().zip(sequence.transactions.iter()) { + // create2 hash offset + let mut offset = 0; + + if tx.is_create2() { + receipt.contract_address = tx.contract_address; + offset = 32; + } + + // Verify contract created directly from the transaction + if let (Some(address), Some(data)) = (receipt.contract_address, tx.tx().input()) { + match verify.get_verify_args(address, offset, data, &sequence.libraries) { + Some(verify) => future_verifications.push(verify.run()), + None => unverifiable_contracts.push(address), + }; + } + + // Verify potential contracts created during the transaction execution + for AdditionalContract { address, init_code, .. } in &tx.additional_contracts { + match verify.get_verify_args(*address, 0, init_code.as_ref(), &sequence.libraries) { + Some(verify) => future_verifications.push(verify.run()), + None => unverifiable_contracts.push(*address), + }; + } + } + + trace!(target: "script", "collected {} verification jobs and {} unverifiable contracts", future_verifications.len(), unverifiable_contracts.len()); + + check_unverified(sequence, unverifiable_contracts, verify); + + let num_verifications = future_verifications.len(); + let mut num_of_successful_verifications = 0; + println!("##\nStart verification for ({num_verifications}) contracts"); + for verification in future_verifications { + match verification.await { + Ok(_) => { + num_of_successful_verifications += 1; + } + Err(err) => eprintln!("Error during verification: {err:#}"), + } + } + + if num_of_successful_verifications < num_verifications { + return Err(eyre!("Not all ({num_of_successful_verifications} / {num_verifications}) contracts were verified!")) + } + + println!("All ({num_verifications}) contracts were verified!"); + } + + Ok(()) +} + +fn check_unverified( + sequence: &ScriptSequence, + unverifiable_contracts: Vec
, + verify: VerifyBundle, +) { + if !unverifiable_contracts.is_empty() { + println!( + "\n{}", + format!( + "We haven't found any matching bytecode for the following contracts: {:?}.\n\n{}", + unverifiable_contracts, + "This may occur when resuming a verification, but the underlying source code or compiler version has changed." + ) + .yellow() + .bold(), + ); + + if let Some(commit) = &sequence.commit { + let current_commit = verify + .project_paths + .root + .map(|root| get_commit_hash(&root).unwrap_or_default()) + .unwrap_or_default(); + + if ¤t_commit != commit { + println!("\tScript was broadcasted on commit `{commit}`, but we are at `{current_commit}`."); + } + } + } +} From cc8e430cc9ad743265d8c897b855809128798d8f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 15 Oct 2024 23:57:58 +0400 Subject: [PATCH 1562/1963] fix: respect `--auth` in `cast call` and `cast estimate` (#9120) * fix: respect --auth in cast call and cast estimate * access list parser --- Cargo.lock | 3 ++ crates/cast/bin/tx.rs | 85 ++++++++++++++---------------- crates/cli/Cargo.toml | 3 ++ crates/cli/src/opts/transaction.rs | 41 +++++++++++--- crates/cli/src/utils/mod.rs | 6 +++ 5 files changed, 87 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5736ded808814..ab47c2ef8cb12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3659,9 +3659,11 @@ version = "0.2.0" dependencies = [ "alloy-chains", "alloy-dyn-abi", + "alloy-eips", "alloy-json-abi", "alloy-primitives", "alloy-provider", + "alloy-rlp", "alloy-transport", "clap", "color-eyre", @@ -3678,6 +3680,7 @@ dependencies = [ "indicatif", "regex", "serde", + "serde_json", "strsim", "strum", "tempfile", diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 1dc9b0cd149fd..88b24a6e33c9e 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -5,21 +5,18 @@ use alloy_network::{ }; use alloy_primitives::{hex, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; -use alloy_rlp::Decodable; use alloy_rpc_types::{AccessList, Authorization, TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_signer::Signer; use alloy_transport::Transport; -use cast::revm::primitives::SignedAuthorization; -use eyre::{Result, WrapErr}; +use eyre::Result; use foundry_cli::{ - opts::TransactionOpts, + opts::{CliAuthorizationList, TransactionOpts}, utils::{self, parse_function_args}, }; use foundry_common::ens::NameOrAddress; use foundry_config::{Chain, Config}; use foundry_wallets::{WalletOpts, WalletSigner}; -use serde_json; /// Different sender kinds used by [`CastTxBuilder`]. pub enum SenderKind<'a> { @@ -134,10 +131,10 @@ pub struct CastTxBuilder { tx: WithOtherFields, legacy: bool, blob: bool, - auth: Option, + auth: Option, chain: Chain, etherscan_api_key: Option, - access_list: Option>, + access_list: Option>, state: S, _t: std::marker::PhantomData, } @@ -319,24 +316,32 @@ where self.tx.set_from(from); self.tx.set_chain_id(self.chain.id()); - if !fill { - return Ok((self.tx, self.state.func)); - } + let tx_nonce = if let Some(nonce) = self.tx.nonce { + nonce + } else { + let nonce = self.provider.get_transaction_count(from).await?; + if fill { + self.tx.nonce = Some(nonce); + } + nonce + }; - if let Some(access_list) = match self.access_list { + self.resolve_auth(sender, tx_nonce).await?; + + if let Some(access_list) = match self.access_list.take() { None => None, // --access-list provided with no value, call the provider to create it Some(None) => Some(self.provider.create_access_list(&self.tx).await?.access_list), // Access list provided as a string, attempt to parse it - Some(Some(ref s)) => Some( - serde_json::from_str::(s) - .map(AccessList::from) - .wrap_err("Failed to parse access list from string")?, - ), + Some(Some(access_list)) => Some(access_list), } { self.tx.set_access_list(access_list); } + if !fill { + return Ok((self.tx, self.state.func)); + } + if self.legacy && self.tx.gas_price.is_none() { self.tx.gas_price = Some(self.provider.get_gas_price().await?); } @@ -361,16 +366,6 @@ where } } - let nonce = if let Some(nonce) = self.tx.nonce { - nonce - } else { - let nonce = self.provider.get_transaction_count(from).await?; - self.tx.nonce = Some(nonce); - nonce - }; - - self.resolve_auth(sender, nonce).await?; - if self.tx.gas.is_none() { self.tx.gas = Some(self.provider.estimate_gas(&self.tx).await?); } @@ -379,25 +374,27 @@ where } /// Parses the passed --auth value and sets the authorization list on the transaction. - async fn resolve_auth(&mut self, sender: SenderKind<'_>, nonce: u64) -> Result<()> { - let Some(auth) = &self.auth else { return Ok(()) }; - - let auth = hex::decode(auth)?; - let auth = if let Ok(address) = Address::try_from(auth.as_slice()) { - let auth = - Authorization { chain_id: U256::from(self.chain.id()), nonce: nonce + 1, address }; - - let Some(signer) = sender.as_signer() else { - eyre::bail!("No signer available to sign authorization"); - }; - let signature = signer.sign_hash(&auth.signature_hash()).await?; - - auth.into_signed(signature) - } else if let Ok(auth) = SignedAuthorization::decode(&mut auth.as_ref()) { - auth - } else { - eyre::bail!("Failed to decode authorization"); + async fn resolve_auth(&mut self, sender: SenderKind<'_>, tx_nonce: u64) -> Result<()> { + let Some(auth) = self.auth.take() else { return Ok(()) }; + + let auth = match auth { + CliAuthorizationList::Address(address) => { + let auth = Authorization { + chain_id: U256::from(self.chain.id()), + nonce: tx_nonce + 1, + address, + }; + + let Some(signer) = sender.as_signer() else { + eyre::bail!("No signer available to sign authorization"); + }; + let signature = signer.sign_hash(&auth.signature_hash()).await?; + + auth.into_signed(signature) + } + CliAuthorizationList::Signed(auth) => auth, }; + self.tx.set_authorization_list(vec![auth]); Ok(()) diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index e8690a0a7d91f..bab56495a5b33 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -22,10 +22,12 @@ foundry-wallets.workspace = true foundry-compilers = { workspace = true, features = ["full"] } +alloy-eips.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-provider.workspace = true +alloy-rlp.workspace = true alloy-transport.workspace = true alloy-chains.workspace = true @@ -43,6 +45,7 @@ tokio = { workspace = true, features = ["macros"] } tracing-subscriber = { workspace = true, features = ["registry", "env-filter"] } tracing.workspace = true yansi.workspace = true +serde_json.workspace = true tracing-tracy = { version = "0.11", optional = true } diff --git a/crates/cli/src/opts/transaction.rs b/crates/cli/src/opts/transaction.rs index 6730902f92a59..c0e229c35cda3 100644 --- a/crates/cli/src/opts/transaction.rs +++ b/crates/cli/src/opts/transaction.rs @@ -1,9 +1,36 @@ -use crate::utils::parse_ether_value; -use alloy_primitives::{U256, U64}; +use std::str::FromStr; + +use crate::utils::{parse_ether_value, parse_json}; +use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization}; +use alloy_primitives::{hex, Address, U256, U64}; +use alloy_rlp::Decodable; use clap::Parser; -use serde::Serialize; -#[derive(Clone, Debug, Serialize, Parser)] +/// CLI helper to parse a EIP-7702 authorization list. +/// Can be either a hex-encoded signed authorization or an address. +#[derive(Clone, Debug)] +pub enum CliAuthorizationList { + /// If an address is provided, we sign the authorization delegating to provided address. + Address(Address), + /// If RLP-encoded authorization is provided, we decode it and attach to transaction. + Signed(SignedAuthorization), +} + +impl FromStr for CliAuthorizationList { + type Err = eyre::Error; + + fn from_str(s: &str) -> Result { + if let Ok(addr) = Address::from_str(s) { + Ok(Self::Address(addr)) + } else if let Ok(auth) = SignedAuthorization::decode(&mut hex::decode(s)?.as_ref()) { + Ok(Self::Signed(auth)) + } else { + eyre::bail!("Failed to decode authorization") + } + } +} + +#[derive(Clone, Debug, Parser)] #[command(next_help_heading = "Transaction options")] pub struct TransactionOpts { /// Gas limit for the transaction. @@ -61,15 +88,15 @@ pub struct TransactionOpts { /// /// Can be either a hex-encoded signed authorization or an address. #[arg(long, conflicts_with_all = &["legacy", "blob"])] - pub auth: Option, + pub auth: Option, /// EIP-2930 access list. /// /// Accepts either a JSON-encoded access list or an empty value to create the access list /// via an RPC call to `eth_createAccessList`. To retrieve only the access list portion, use /// the `cast access-list` command. - #[arg(long)] - pub access_list: Option>, + #[arg(long, value_parser = parse_json::)] + pub access_list: Option>, } #[cfg(test)] diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index af3c5e0a5dd9c..5b7523447ec93 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -5,6 +5,7 @@ use alloy_transport::Transport; use eyre::{ContextCompat, Result}; use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_config::{Chain, Config}; +use serde::de::DeserializeOwned; use std::{ ffi::OsStr, future::Future, @@ -133,6 +134,11 @@ pub fn parse_ether_value(value: &str) -> Result { }) } +/// Parses a `T` from a string using [`serde_json::from_str`]. +pub fn parse_json(value: &str) -> serde_json::Result { + serde_json::from_str(value) +} + /// Parses a `Duration` from a &str pub fn parse_delay(delay: &str) -> Result { let delay = if delay.ends_with("ms") { From 3786b27150e9c444cbb060d6d991ebf867733e38 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:04:20 +0300 Subject: [PATCH 1563/1963] fix(cheatcodes): convert fixed bytes to bytes in vm.rpc tuple result (#9117) * fix(cheatcodes): convert fixed bytes to bytes in vm.rpc tuple result * Changes after review: recursive convert_to_bytes fn --- crates/cheatcodes/src/evm/fork.rs | 30 +++++++++++++++++++---------- testdata/default/cheats/Fork2.t.sol | 6 ++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index e1d66538de721..83942cdbefa5f 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -1,4 +1,7 @@ -use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, DatabaseExt, Result, Vm::*}; +use crate::{ + json::json_value_to_token, Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, DatabaseExt, + Result, Vm::*, +}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{B256, U256}; use alloy_provider::Provider; @@ -375,18 +378,25 @@ fn rpc_call(url: &str, method: &str, params: &str) -> Result { let result = foundry_common::block_on(provider.raw_request(method.to_string().into(), params_json)) .map_err(|err| fmt_err!("{method:?}: {err}"))?; + let result_as_tokens = convert_to_bytes( + &json_value_to_token(&result).map_err(|err| fmt_err!("failed to parse result: {err}"))?, + ); - let result_as_tokens = match crate::json::json_value_to_token(&result) - .map_err(|err| fmt_err!("failed to parse result: {err}"))? - { - // Convert fixed bytes to bytes to prevent encoding issues. + Ok(result_as_tokens.abi_encode()) +} + +/// Convert fixed bytes and address values to bytes in order to prevent encoding issues. +fn convert_to_bytes(token: &DynSolValue) -> DynSolValue { + match token { + // Convert fixed bytes to prevent encoding issues. // See: DynSolValue::FixedBytes(bytes, size) => { - DynSolValue::Bytes(bytes.as_slice()[..size].to_vec()) + DynSolValue::Bytes(bytes.as_slice()[..*size].to_vec()) } DynSolValue::Address(addr) => DynSolValue::Bytes(addr.to_vec()), - val => val, - }; - - Ok(result_as_tokens.abi_encode()) + // Convert tuple values to prevent encoding issues. + // See: + DynSolValue::Tuple(vals) => DynSolValue::Tuple(vals.iter().map(convert_to_bytes).collect()), + val => val.clone(), + } } diff --git a/testdata/default/cheats/Fork2.t.sol b/testdata/default/cheats/Fork2.t.sol index 7b6b4275990fc..d0703ce7fa6ce 100644 --- a/testdata/default/cheats/Fork2.t.sol +++ b/testdata/default/cheats/Fork2.t.sol @@ -234,6 +234,12 @@ contract ForkTest is DSTest { uint256 decodedResult = vm.parseUint(vm.toString(result)); assertGt(decodedResult, 20_000_000); } + + // + function testRpcTransactionByHash() public { + string memory param = string.concat('["0xe1a0fba63292976050b2fbf4379a1901691355ed138784b4e0d1854b4cf9193e"]'); + vm.rpc("sepolia", "eth_getTransactionByHash", param); + } } contract DummyContract { From adb6abae69c7a0d766db123f66686cc890c22dd0 Mon Sep 17 00:00:00 2001 From: jpgonzalezra Date: Wed, 16 Oct 2024 09:51:13 -0300 Subject: [PATCH 1564/1963] feat(forge): add `compiler` subcommand (#7909) * feat(forge): add solc subcommand and utilities * style: improve formatting in solc.rs file * fix: merge * add json compatible output * add basic tests * add basic tests * clean up * finish tests * add skip flag * add vyper for unit tests * move tests, pin compiler version, use forgetest! * update CI test location for target Python / Vyper * update foundry-compilers crate * Update crates/forge/bin/cmd/compiler.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * `compiler` command is sync, remove conditions on CI for Vyper / Python installs * is_jsonlines -> is_json --------- Co-authored-by: zerosnacks Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- .github/workflows/nextest.yml | 2 - Cargo.lock | 20 +-- Cargo.toml | 2 +- crates/forge/bin/cmd/compiler.rs | 145 +++++++++++++++++++ crates/forge/bin/cmd/mod.rs | 1 + crates/forge/bin/main.rs | 1 + crates/forge/bin/opts.rs | 14 +- crates/forge/tests/cli/compiler.rs | 218 +++++++++++++++++++++++++++++ crates/forge/tests/cli/main.rs | 1 + 9 files changed, 386 insertions(+), 18 deletions(-) create mode 100644 crates/forge/bin/cmd/compiler.rs create mode 100644 crates/forge/tests/cli/compiler.rs diff --git a/.github/workflows/nextest.yml b/.github/workflows/nextest.yml index 8803540806de3..da862c657abff 100644 --- a/.github/workflows/nextest.yml +++ b/.github/workflows/nextest.yml @@ -67,12 +67,10 @@ jobs: with: bun-version: latest - name: Setup Python - if: contains(matrix.name, 'external') uses: actions/setup-python@v4 with: python-version: 3.11 - name: Install Vyper - if: contains(matrix.name, 'external') run: pip install vyper~=0.4.0 - name: Forge RPC cache diff --git a/Cargo.lock b/Cargo.lock index ab47c2ef8cb12..9431ac1d325aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3757,9 +3757,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c6cc925fc9fdd73f1038c528fef17ddbdd7512311809ace7d1860fe3666dbb5" +checksum = "5cabcc146459af3ef3c7d05bfd1cca1450b065aaa0c168d567b3fe25d8530558" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3795,9 +3795,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d5c999c80c6d702c51522f5b4a805bec5fcae978637f0c337fa5c7a4b43d863" +checksum = "0217f21ad9c0aa8127fcca23e69bda25101b0849027e3cf949f04252b22810fd" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3805,9 +3805,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3747cfeab1fc8299d70ceae0a28b7e2e005324e8eba78ac7d06729d67be5a1ec" +checksum = "e35255af997575a4aac46d86259fb43c222edfbcf48230ed929fa7c92ece6277" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3829,9 +3829,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd5c142355bd4822b8a7ec37268cfafe37b2e36835fa8d067b2b9d5a22c7529" +checksum = "626fdc9a2ba83240d1b5ebbe3d8d50d794f231aa652abf27289119e71f6e774b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3844,9 +3844,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1291c05a4c8c3b4558eb1b50f53ee1f1b599ff2490d62cdc519ad5ae4b088d6" +checksum = "51486ab73194212079801418f6cc66ba05275467c80241a7f05bb7ef0475774a" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 2bb8f894570b2..877037e097163 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } -foundry-compilers = { version = "0.11.4", default-features = false } +foundry-compilers = { version = "0.11.5", default-features = false } foundry-fork-db = "0.4.0" solang-parser = "=0.3.3" diff --git a/crates/forge/bin/cmd/compiler.rs b/crates/forge/bin/cmd/compiler.rs new file mode 100644 index 0000000000000..badc053c6c4d7 --- /dev/null +++ b/crates/forge/bin/cmd/compiler.rs @@ -0,0 +1,145 @@ +use clap::{ArgAction, Parser, Subcommand, ValueHint}; +use eyre::Result; +use foundry_compilers::Graph; +use foundry_config::Config; +use semver::Version; +use std::{collections::BTreeMap, path::PathBuf}; + +/// CLI arguments for `forge compiler`. +#[derive(Debug, Parser)] +pub struct CompilerArgs { + #[command(subcommand)] + pub sub: CompilerSubcommands, +} + +impl CompilerArgs { + pub fn run(self) -> Result<()> { + match self.sub { + CompilerSubcommands::Resolve(args) => args.run(), + } + } +} + +#[derive(Debug, Subcommand)] +pub enum CompilerSubcommands { + /// Retrieves the resolved version(s) of the compiler within the project. + #[command(visible_alias = "r")] + Resolve(ResolveArgs), +} + +/// CLI arguments for `forge compiler resolve`. +#[derive(Debug, Parser)] +pub struct ResolveArgs { + /// The root directory + #[arg(long, short, value_hint = ValueHint::DirPath, value_name = "PATH")] + root: Option, + + /// Skip files that match the given regex pattern. + #[arg(long, short, value_name = "REGEX")] + skip: Option, + + /// Verbosity of the output. + /// + /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). + /// + /// Verbosity levels: + /// - 2: Print source paths. + #[arg(long, short, verbatim_doc_comment, action = ArgAction::Count, help_heading = "Display options")] + pub verbosity: u8, + + /// Print as JSON. + #[arg(long, short, help_heading = "Display options")] + json: bool, +} + +impl ResolveArgs { + pub fn run(self) -> Result<()> { + let Self { root, skip, verbosity, json } = self; + + let root = root.unwrap_or_else(|| PathBuf::from(".")); + let config = Config::load_with_root(&root); + let project = config.project()?; + + let graph = Graph::resolve(&project.paths)?; + let (sources, _) = graph.into_sources_by_version( + project.offline, + &project.locked_versions, + &project.compiler, + )?; + + let mut output: BTreeMap)>> = BTreeMap::new(); + + for (language, sources) in sources { + let mut versions_with_paths: Vec<(Version, Vec)> = sources + .iter() + .map(|(version, sources)| { + let paths: Vec = sources + .iter() + .filter_map(|(path_file, _)| { + let path_str = path_file + .strip_prefix(&project.paths.root) + .unwrap_or(path_file) + .to_path_buf() + .display() + .to_string(); + + // Skip files that match the given regex pattern. + if let Some(ref regex) = skip { + if regex.is_match(&path_str) { + return None; + } + } + + Some(path_str) + }) + .collect(); + + (version.clone(), paths) + }) + .filter(|(_, paths)| !paths.is_empty()) + .collect(); + + // Sort by SemVer version. + versions_with_paths.sort_by(|(v1, _), (v2, _)| Version::cmp(v1, v2)); + + // Skip language if no paths are found after filtering. + if !versions_with_paths.is_empty() { + output.insert(language.to_string(), versions_with_paths); + } + } + + if json { + println!("{}", serde_json::to_string(&output)?); + return Ok(()); + } + + for (language, versions) in &output { + if verbosity < 1 { + println!("{language}:"); + } else { + println!("{language}:\n"); + } + + for (version, paths) in versions { + if verbosity >= 1 { + println!("{version}:"); + for (idx, path) in paths.iter().enumerate() { + if idx == paths.len() - 1 { + println!("└── {path}\n"); + } else { + println!("├── {path}"); + } + } + } else { + println!("- {version}"); + } + } + + if verbosity < 1 { + println!(); + } + } + + Ok(()) + } +} diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index ff63fa7cbc0eb..f2de1d6321d51 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -44,6 +44,7 @@ pub mod bind_json; pub mod build; pub mod cache; pub mod clone; +pub mod compiler; pub mod config; pub mod coverage; pub mod create; diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index ba89d6dcf6324..925788ef8fdac 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -118,6 +118,7 @@ fn main() -> Result<()> { ForgeSubcommand::Generate(cmd) => match cmd.sub { GenerateSubcommands::Test(cmd) => cmd.run(), }, + ForgeSubcommand::Compiler(cmd) => cmd.run(), ForgeSubcommand::Soldeer(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Eip712(cmd) => cmd.run(), ForgeSubcommand::BindJson(cmd) => cmd.run(), diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index c929d0185ba7e..d0dfecd3a132b 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -1,8 +1,9 @@ use crate::cmd::{ - bind::BindArgs, bind_json, build::BuildArgs, cache::CacheArgs, clone::CloneArgs, config, - coverage, create::CreateArgs, debug::DebugArgs, doc::DocArgs, eip712, flatten, fmt::FmtArgs, - geiger, generate, init::InitArgs, inspect, install::InstallArgs, remappings::RemappingArgs, - remove::RemoveArgs, selectors::SelectorsSubcommands, snapshot, soldeer, test, tree, update, + bind::BindArgs, bind_json, build::BuildArgs, cache::CacheArgs, clone::CloneArgs, + compiler::CompilerArgs, config, coverage, create::CreateArgs, debug::DebugArgs, doc::DocArgs, + eip712, flatten, fmt::FmtArgs, geiger, generate, init::InitArgs, inspect, install::InstallArgs, + remappings::RemappingArgs, remove::RemoveArgs, selectors::SelectorsSubcommands, snapshot, + soldeer, test, tree, update, }; use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; @@ -152,7 +153,7 @@ pub enum ForgeSubcommand { /// Generate documentation for the project. Doc(DocArgs), - /// Function selector utilities + /// Function selector utilities. #[command(visible_alias = "se")] Selectors { #[command(subcommand)] @@ -162,6 +163,9 @@ pub enum ForgeSubcommand { /// Generate scaffold files. Generate(generate::GenerateArgs), + /// Compiler utilities. + Compiler(CompilerArgs), + /// Soldeer dependency manager. Soldeer(soldeer::SoldeerArgs), diff --git a/crates/forge/tests/cli/compiler.rs b/crates/forge/tests/cli/compiler.rs new file mode 100644 index 0000000000000..6653566323207 --- /dev/null +++ b/crates/forge/tests/cli/compiler.rs @@ -0,0 +1,218 @@ +//! Tests for the `forge compiler` command. + +use foundry_test_utils::snapbox::IntoData; + +const CONTRACT_A: &str = r#" +// SPDX-license-identifier: MIT +pragma solidity 0.8.4; + +contract ContractA {} +"#; + +const CONTRACT_B: &str = r#" +// SPDX-license-identifier: MIT +pragma solidity 0.8.11; + +contract ContractB {} +"#; + +const CONTRACT_C: &str = r#" +// SPDX-license-identifier: MIT +pragma solidity 0.8.27; + +contract ContractC {} +"#; + +const CONTRACT_D: &str = r#" +// SPDX-license-identifier: MIT +pragma solidity 0.8.27; + +contract ContractD {} +"#; + +const VYPER_INTERFACE: &str = r#" +# pragma version 0.4.0 + +@external +@view +def number() -> uint256: + return empty(uint256) + +@external +def set_number(new_number: uint256): + pass + +@external +def increment() -> uint256: + return empty(uint256) +"#; + +const VYPER_CONTRACT: &str = r#" +import ICounter +implements: ICounter + +number: public(uint256) + +@external +def set_number(new_number: uint256): + self.number = new_number + +@external +def increment() -> uint256: + self.number += 1 + return self.number +"#; + +forgetest!(can_resolve_path, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + + cmd.args(["compiler", "resolve", "--root", prj.root().to_str().unwrap()]) + .assert_success() + .stdout_eq(str![[r#" +Solidity: +- 0.8.4 + + +"#]]); +}); + +forgetest!(can_list_resolved_compiler_versions, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + + cmd.args(["compiler", "resolve"]).assert_success().stdout_eq(str![[r#" +Solidity: +- 0.8.4 + + +"#]]); +}); + +forgetest!(can_list_resolved_compiler_versions_verbose, |prj, cmd| { + prj.add_source("ContractC", CONTRACT_C).unwrap(); + prj.add_source("ContractD", CONTRACT_D).unwrap(); + + cmd.args(["compiler", "resolve", "-v"]).assert_success().stdout_eq(str![[r#" +Solidity: + +0.8.27: +├── src/ContractC.sol +└── src/ContractD.sol + + +"#]]); +}); + +forgetest!(can_list_resolved_compiler_versions_json, |prj, cmd| { + prj.add_source("ContractC", CONTRACT_C).unwrap(); + prj.add_source("ContractD", CONTRACT_D).unwrap(); + + cmd.args(["compiler", "resolve", "--json"]).assert_success().stdout_eq( + str![[r#" +{"Solidity":[["0.8.27",["src/ContractC.sol","src/ContractD.sol"]]]}"#]] + .is_json(), + ); +}); + +forgetest!(can_list_resolved_multiple_compiler_versions, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + prj.add_source("ContractB", CONTRACT_B).unwrap(); + prj.add_source("ContractC", CONTRACT_C).unwrap(); + prj.add_source("ContractD", CONTRACT_D).unwrap(); + prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); + prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); + + cmd.args(["compiler", "resolve"]).assert_success().stdout_eq(str![[r#" +Solidity: +- 0.8.4 +- 0.8.11 +- 0.8.27 + +Vyper: +- 0.4.0 + + +"#]]); +}); + +forgetest!(can_list_resolved_multiple_compiler_versions_skipped, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + prj.add_source("ContractB", CONTRACT_B).unwrap(); + prj.add_source("ContractC", CONTRACT_C).unwrap(); + prj.add_source("ContractD", CONTRACT_D).unwrap(); + prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); + prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); + + cmd.args(["compiler", "resolve", "--skip", ".sol", "-v"]).assert_success().stdout_eq(str![[ + r#" +Vyper: + +0.4.0: +├── src/Counter.vy +└── src/ICounter.vyi + + +"# + ]]); +}); + +forgetest!(can_list_resolved_multiple_compiler_versions_skipped_json, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + prj.add_source("ContractB", CONTRACT_B).unwrap(); + prj.add_source("ContractC", CONTRACT_C).unwrap(); + prj.add_source("ContractD", CONTRACT_D).unwrap(); + prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); + prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); + + cmd.args(["compiler", "resolve", "--skip", "Contract(A|B|C)", "--json"]) + .assert_success() + .stdout_eq(str![[r#" +{"Solidity":[["0.8.27",["src/ContractD.sol"]]],"Vyper":[["0.4.0",["src/Counter.vy","src/ICounter.vyi"]]]} +"#]].is_json()); +}); + +forgetest!(can_list_resolved_multiple_compiler_versions_verbose, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + prj.add_source("ContractB", CONTRACT_B).unwrap(); + prj.add_source("ContractC", CONTRACT_C).unwrap(); + prj.add_source("ContractD", CONTRACT_D).unwrap(); + prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); + prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); + + cmd.args(["compiler", "resolve", "-v"]).assert_success().stdout_eq(str![[r#" +Solidity: + +0.8.4: +└── src/ContractA.sol + +0.8.11: +└── src/ContractB.sol + +0.8.27: +├── src/ContractC.sol +└── src/ContractD.sol + +Vyper: + +0.4.0: +├── src/Counter.vy +└── src/ICounter.vyi + + +"#]]); +}); + +forgetest!(can_list_resolved_multiple_compiler_versions_json, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + prj.add_source("ContractB", CONTRACT_B).unwrap(); + prj.add_source("ContractC", CONTRACT_C).unwrap(); + prj.add_source("ContractD", CONTRACT_D).unwrap(); + prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); + prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); + + cmd.args(["compiler", "resolve", "--json"]).assert_success().stdout_eq( + str![[r#" +{"Solidity":[["0.8.4",["src/ContractA.sol"]],["0.8.11",["src/ContractB.sol"]],["0.8.27",["src/ContractC.sol","src/ContractD.sol"]]],"Vyper":[["0.4.0",["src/Counter.vy","src/ICounter.vyi"]]]} +"#]] + .is_json(), + ); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 6ad29ca48a935..a53a26d2ac5ac 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -9,6 +9,7 @@ mod bind_json; mod build; mod cache; mod cmd; +mod compiler; mod config; mod context; mod coverage; From d5f6e34c39df6da5ad662036c869f3488e43393b Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 17 Oct 2024 06:35:31 +0300 Subject: [PATCH 1565/1963] feat(forge): add max supported EVM version in compiler -vv (#9129) * feat(forge): add max supported EVM version in compiler -v * shorter message, displayed on -vv verbosity * match on verbosity * Respect verbosity in json, nicer json output * Redact default EVM version in tests * make --json output not output paths in verbosity mode 0, equivalent of non-verbose text mode --------- Co-authored-by: zerosnacks --- crates/forge/bin/cmd/compiler.rs | 77 ++++++++++++++----- crates/forge/tests/cli/compiler.rs | 118 ++++++++++++++++++++++++----- 2 files changed, 160 insertions(+), 35 deletions(-) diff --git a/crates/forge/bin/cmd/compiler.rs b/crates/forge/bin/cmd/compiler.rs index badc053c6c4d7..06823c0c60b07 100644 --- a/crates/forge/bin/cmd/compiler.rs +++ b/crates/forge/bin/cmd/compiler.rs @@ -1,8 +1,9 @@ use clap::{ArgAction, Parser, Subcommand, ValueHint}; use eyre::Result; -use foundry_compilers::Graph; +use foundry_compilers::{artifacts::EvmVersion, Graph}; use foundry_config::Config; use semver::Version; +use serde::Serialize; use std::{collections::BTreeMap, path::PathBuf}; /// CLI arguments for `forge compiler`. @@ -27,6 +28,19 @@ pub enum CompilerSubcommands { Resolve(ResolveArgs), } +/// Resolved compiler within the project. +#[derive(Serialize)] +struct ResolvedCompiler { + /// Compiler version. + version: Version, + /// Max supported EVM version of compiler. + #[serde(skip_serializing_if = "Option::is_none")] + evm_version: Option, + /// Source paths. + #[serde(skip_serializing_if = "Vec::is_empty")] + paths: Vec, +} + /// CLI arguments for `forge compiler resolve`. #[derive(Debug, Parser)] pub struct ResolveArgs { @@ -43,7 +57,9 @@ pub struct ResolveArgs { /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). /// /// Verbosity levels: - /// - 2: Print source paths. + /// - 0: Print compiler versions. + /// - 1: Print compiler version and source paths. + /// - 2: Print compiler version, source paths and max supported EVM version of the compiler. #[arg(long, short, verbatim_doc_comment, action = ArgAction::Count, help_heading = "Display options")] pub verbosity: u8, @@ -67,10 +83,10 @@ impl ResolveArgs { &project.compiler, )?; - let mut output: BTreeMap)>> = BTreeMap::new(); + let mut output: BTreeMap> = BTreeMap::new(); for (language, sources) in sources { - let mut versions_with_paths: Vec<(Version, Vec)> = sources + let mut versions_with_paths: Vec = sources .iter() .map(|(version, sources)| { let paths: Vec = sources @@ -94,16 +110,32 @@ impl ResolveArgs { }) .collect(); - (version.clone(), paths) + let evm_version = if verbosity > 1 { + Some( + EvmVersion::default() + .normalize_version_solc(version) + .unwrap_or_default(), + ) + } else { + None + }; + + ResolvedCompiler { version: version.clone(), evm_version, paths } }) - .filter(|(_, paths)| !paths.is_empty()) + .filter(|version| !version.paths.is_empty()) .collect(); // Sort by SemVer version. - versions_with_paths.sort_by(|(v1, _), (v2, _)| Version::cmp(v1, v2)); + versions_with_paths.sort_by(|v1, v2| Version::cmp(&v1.version, &v2.version)); // Skip language if no paths are found after filtering. if !versions_with_paths.is_empty() { + // Clear paths if verbosity is 0, performed only after filtering to avoid being + // skipped. + if verbosity == 0 { + versions_with_paths.iter_mut().for_each(|version| version.paths.clear()); + } + output.insert(language.to_string(), versions_with_paths); } } @@ -113,16 +145,27 @@ impl ResolveArgs { return Ok(()); } - for (language, versions) in &output { - if verbosity < 1 { - println!("{language}:"); - } else { - println!("{language}:\n"); + for (language, compilers) in &output { + match verbosity { + 0 => println!("{language}:"), + _ => println!("{language}:\n"), } - for (version, paths) in versions { - if verbosity >= 1 { - println!("{version}:"); + for resolved_compiler in compilers { + let version = &resolved_compiler.version; + match verbosity { + 0 => println!("- {version}"), + _ => { + if let Some(evm) = &resolved_compiler.evm_version { + println!("{version} (<= {evm}):") + } else { + println!("{version}:") + } + } + } + + if verbosity > 0 { + let paths = &resolved_compiler.paths; for (idx, path) in paths.iter().enumerate() { if idx == paths.len() - 1 { println!("└── {path}\n"); @@ -130,12 +173,10 @@ impl ResolveArgs { println!("├── {path}"); } } - } else { - println!("- {version}"); } } - if verbosity < 1 { + if verbosity == 0 { println!(); } } diff --git a/crates/forge/tests/cli/compiler.rs b/crates/forge/tests/cli/compiler.rs index 6653566323207..b8453b67b9442 100644 --- a/crates/forge/tests/cli/compiler.rs +++ b/crates/forge/tests/cli/compiler.rs @@ -31,7 +31,7 @@ contract ContractD {} "#; const VYPER_INTERFACE: &str = r#" -# pragma version 0.4.0 +# pragma version >=0.4.0 @external @view @@ -87,6 +87,23 @@ Solidity: "#]]); }); +forgetest!(can_list_resolved_compiler_versions_json, |prj, cmd| { + prj.add_source("ContractA", CONTRACT_A).unwrap(); + + cmd.args(["compiler", "resolve", "--json"]).assert_success().stdout_eq( + str![[r#" +{ + "Solidity":[ + { + "version":"0.8.4" + } + ] +} +"#]] + .is_json(), + ); +}); + forgetest!(can_list_resolved_compiler_versions_verbose, |prj, cmd| { prj.add_source("ContractC", CONTRACT_C).unwrap(); prj.add_source("ContractD", CONTRACT_D).unwrap(); @@ -102,13 +119,24 @@ Solidity: "#]]); }); -forgetest!(can_list_resolved_compiler_versions_json, |prj, cmd| { +forgetest!(can_list_resolved_compiler_versions_verbose_json, |prj, cmd| { prj.add_source("ContractC", CONTRACT_C).unwrap(); prj.add_source("ContractD", CONTRACT_D).unwrap(); - cmd.args(["compiler", "resolve", "--json"]).assert_success().stdout_eq( + cmd.args(["compiler", "resolve", "--json", "-v"]).assert_success().stdout_eq( str![[r#" -{"Solidity":[["0.8.27",["src/ContractC.sol","src/ContractD.sol"]]]}"#]] +{ + "Solidity": [ + { + "version": "0.8.27", + "paths": [ + "src/ContractC.sol", + "src/ContractD.sol" + ] + } + ] +} +"#]] .is_json(), ); }); @@ -163,11 +191,32 @@ forgetest!(can_list_resolved_multiple_compiler_versions_skipped_json, |prj, cmd| prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); - cmd.args(["compiler", "resolve", "--skip", "Contract(A|B|C)", "--json"]) - .assert_success() - .stdout_eq(str![[r#" -{"Solidity":[["0.8.27",["src/ContractD.sol"]]],"Vyper":[["0.4.0",["src/Counter.vy","src/ICounter.vyi"]]]} -"#]].is_json()); + cmd.args(["compiler", "resolve", "--skip", "Contract(A|B|C)", "--json", "-v"]) + .assert_success() + .stdout_eq( + str![[r#" +{ + "Solidity": [ + { + "version": "0.8.27", + "paths": [ + "src/ContractD.sol" + ] + } + ], + "Vyper": [ + { + "version": "0.4.0", + "paths": [ + "src/Counter.vy", + "src/ICounter.vyi" + ] + } + ] +} +"#]] + .is_json(), + ); }); forgetest!(can_list_resolved_multiple_compiler_versions_verbose, |prj, cmd| { @@ -178,22 +227,22 @@ forgetest!(can_list_resolved_multiple_compiler_versions_verbose, |prj, cmd| { prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); - cmd.args(["compiler", "resolve", "-v"]).assert_success().stdout_eq(str![[r#" + cmd.args(["compiler", "resolve", "-vv"]).assert_success().stdout_eq(str![[r#" Solidity: -0.8.4: +0.8.4 (<= istanbul): └── src/ContractA.sol -0.8.11: +0.8.11 (<= london): └── src/ContractB.sol -0.8.27: +0.8.27 (<= [..]): ├── src/ContractC.sol └── src/ContractD.sol Vyper: -0.4.0: +0.4.0 (<= [..]): ├── src/Counter.vy └── src/ICounter.vyi @@ -201,7 +250,7 @@ Vyper: "#]]); }); -forgetest!(can_list_resolved_multiple_compiler_versions_json, |prj, cmd| { +forgetest!(can_list_resolved_multiple_compiler_versions_verbose_json, |prj, cmd| { prj.add_source("ContractA", CONTRACT_A).unwrap(); prj.add_source("ContractB", CONTRACT_B).unwrap(); prj.add_source("ContractC", CONTRACT_C).unwrap(); @@ -209,9 +258,44 @@ forgetest!(can_list_resolved_multiple_compiler_versions_json, |prj, cmd| { prj.add_raw_source("ICounter.vyi", VYPER_INTERFACE).unwrap(); prj.add_raw_source("Counter.vy", VYPER_CONTRACT).unwrap(); - cmd.args(["compiler", "resolve", "--json"]).assert_success().stdout_eq( + cmd.args(["compiler", "resolve", "--json", "-vv"]).assert_success().stdout_eq( str![[r#" -{"Solidity":[["0.8.4",["src/ContractA.sol"]],["0.8.11",["src/ContractB.sol"]],["0.8.27",["src/ContractC.sol","src/ContractD.sol"]]],"Vyper":[["0.4.0",["src/Counter.vy","src/ICounter.vyi"]]]} +{ + "Solidity": [ + { + "version": "0.8.4", + "evm_version": "Istanbul", + "paths": [ + "src/ContractA.sol" + ] + }, + { + "version": "0.8.11", + "evm_version": "London", + "paths": [ + "src/ContractB.sol" + ] + }, + { + "version": "0.8.27", + "evm_version": "[..]", + "paths": [ + "src/ContractC.sol", + "src/ContractD.sol" + ] + } + ], + "Vyper": [ + { + "version": "0.4.0", + "evm_version": "[..]", + "paths": [ + "src/Counter.vy", + "src/ICounter.vyi" + ] + } + ] +} "#]] .is_json(), ); From 2b32882e0ff1b323348ea25931e64d27f4c4fd4d Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:03:02 +0200 Subject: [PATCH 1566/1963] chore: bump `foundry-compilers` to include Vyper fix (#9133) bump foundry-compilers to include Vyper fix: https://github.com/foundry-rs/compilers/pull/213 --- Cargo.lock | 253 +++++++++++++++++++++++++++++------------------------ Cargo.toml | 2 +- 2 files changed, 140 insertions(+), 115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9431ac1d325aa..5670390ca3194 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95d76a38cae906fd394a5afb0736aaceee5432efe76addfd71048e623e208af" +checksum = "e6228abfc751a29cde117b0879b805a3e0b3b641358f063272c83ca459a56886" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -200,9 +200,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c66eec1acdd96b39b995b8f5ee5239bc0c871d62c527ae1ac9fd1d7fecd455" +checksum = "d46eb5871592c216d39192499c95a99f7175cb94104f88c307e6dc960676d9f1" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb848c43f6b06ae3de2e4a67496cbbabd78ae87db0f1248934f15d76192c6a" +checksum = "38f35429a652765189c1c5092870d8360ee7b7769b09b06d89ebaefd34676446" dependencies = [ "alloy-rlp", "arbitrary", @@ -606,9 +606,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "661c516eb1fa3294cc7f2fb8955b3b609d639c282ac81a4eedb14d3046db503a" +checksum = "3b2395336745358cc47207442127c47c63801a7065ecc0aa928da844f8bb5576" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -620,9 +620,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecbabb8fc3d75a0c2cea5215be22e7a267e3efde835b0f2a8922f5e3f5d47683" +checksum = "9ed5047c9a241df94327879c2b0729155b58b941eae7805a7ada2e19436e6b39" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -639,9 +639,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16517f2af03064485150d89746b8ffdcdbc9b6eeb3d536fb66efd7c2846fbc75" +checksum = "5dee02a81f529c415082235129f0df8b8e60aa1601b9c9298ffe54d75f57210b" dependencies = [ "alloy-json-abi", "const-hex", @@ -656,9 +656,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c07ebb0c1674ff8cbb08378d7c2e0e27919d2a2dae07ad3bca26174deda8d389" +checksum = "f631f0bd9a9d79619b27c91b6b1ab2c4ef4e606a65192369a1ee05d40dcf81cc" dependencies = [ "serde", "winnow", @@ -666,9 +666,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e448d879903624863f608c552d10efb0e0905ddbee98b0049412799911eb062" +checksum = "c2841af22d99e2c0f82a78fe107b6481be3dd20b89bfb067290092794734343a" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -742,7 +742,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.14", + "rustls 0.23.15", "serde_json", "tokio", "tokio-tungstenite", @@ -889,7 +889,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 1.4.1", + "hyper 1.5.0", "itertools 0.13.0", "k256", "op-alloy-consensus", @@ -1129,9 +1129,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.14" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "998282f8f49ccd6116b0ed8a4de0fbd3151697920e7c7533416d6e25e76434a7" +checksum = "103db485efc3e41214fe4fda9f3dbeae2eb9082f48fd236e6095627a9422066e" dependencies = [ "flate2", "futures-core", @@ -1316,7 +1316,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.10.0", + "uuid 1.11.0", ] [[package]] @@ -1498,7 +1498,7 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", @@ -1585,7 +1585,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "itoa", "matchit", @@ -1819,9 +1819,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" @@ -3379,7 +3379,7 @@ dependencies = [ "futures", "globset", "humantime-serde", - "hyper 1.4.1", + "hyper 1.5.0", "indicatif", "inferno", "itertools 0.13.0", @@ -3757,9 +3757,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cabcc146459af3ef3c7d05bfd1cca1450b065aaa0c168d567b3fe25d8530558" +checksum = "4754b3f3bb924202b29bd7f0584ea1446018926342884c86029a7d56ef1a22c1" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3795,9 +3795,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0217f21ad9c0aa8127fcca23e69bda25101b0849027e3cf949f04252b22810fd" +checksum = "e6289da0f17fdb5a0454020dce595502b0abd2a56c15a36d4f6c05bd6c4ff864" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3805,9 +3805,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35255af997575a4aac46d86259fb43c222edfbcf48230ed929fa7c92ece6277" +checksum = "e1cf322ab7b726f2bafe9a7e6fb67db02801b35584a2b1d122b4feb52d8e9e7f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3829,9 +3829,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626fdc9a2ba83240d1b5ebbe3d8d50d794f231aa652abf27289119e71f6e774b" +checksum = "ec47f94c7833adfe8049c819d9e31a60c3f440a68cf5baf34c318413d3eb0700" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3844,9 +3844,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51486ab73194212079801418f6cc66ba05275467c80241a7f05bb7ef0475774a" +checksum = "61971b34545e8ea01502df9d076e811ad3926f27d31adf2641e0c931ca646933" dependencies = [ "alloy-primitives", "cfg-if", @@ -4163,9 +4163,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "fs4" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c6b3bd49c37d2aa3f3f2220233b29a7cd23f79d1fe70e5337d25fb390793de" +checksum = "ec6fcfb3c0c1d71612528825042261419d5dade9678c39a781e05b63677d9b32" dependencies = [ "rustix", "windows-sys 0.52.0", @@ -4307,7 +4307,7 @@ dependencies = [ "bytes", "chrono", "futures", - "hyper 1.4.1", + "hyper 1.5.0", "jsonwebtoken", "once_cell", "prost", @@ -4370,9 +4370,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gix-actor" -version = "0.31.5" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e454357e34b833cc3a00b6efbbd3dd4d18b24b9fb0c023876ec2645e8aa3f2" +checksum = "fc19e312cd45c4a66cd003f909163dc2f8e1623e30a0c0c6df3776e89b308665" dependencies = [ "bstr", "gix-date", @@ -4384,9 +4384,9 @@ dependencies = [ [[package]] name = "gix-config" -version = "0.36.1" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7580e05996e893347ad04e1eaceb92e1c0e6a3ffe517171af99bf6b6df0ca6e5" +checksum = "78e797487e6ca3552491de1131b4f72202f282fb33f198b1c34406d765b42bb0" dependencies = [ "bstr", "gix-config-value", @@ -4418,14 +4418,14 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.8.7" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eed6931f21491ee0aeb922751bd7ec97b4b2fe8fbfedcb678e2a2dce5f3b8c0" +checksum = "35c84b7af01e68daf7a6bb8bb909c1ff5edb3ce4326f1f43063a5a96d3c3c8a5" dependencies = [ "bstr", "itoa", + "jiff", "thiserror", - "time", ] [[package]] @@ -4445,10 +4445,11 @@ dependencies = [ [[package]] name = "gix-fs" -version = "0.10.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2184c40e7910529677831c8b481acf788ffd92427ed21fad65b6aa637e631b8" +checksum = "f2bfe6249cfea6d0c0e0990d5226a4cb36f030444ba9e35e0639275db8f98575" dependencies = [ + "fastrand", "gix-features", "gix-utils", ] @@ -4477,9 +4478,9 @@ dependencies = [ [[package]] name = "gix-lock" -version = "13.1.1" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c359f81f01b8352063319bcb39789b7ea0887b406406381106e38c4a34d049" +checksum = "e3bc7fe297f1f4614774989c00ec8b1add59571dc9b024b4c00acb7dedd4e19d" dependencies = [ "gix-tempfile", "gix-utils", @@ -4488,9 +4489,9 @@ dependencies = [ [[package]] name = "gix-object" -version = "0.42.3" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25da2f46b4e7c2fa7b413ce4dffb87f69eaf89c2057e386491f4c55cadbfe386" +checksum = "2f5b801834f1de7640731820c2df6ba88d95480dc4ab166a5882f8ff12b88efa" dependencies = [ "bstr", "gix-actor", @@ -4520,12 +4521,11 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.43.0" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4aba68b925101cb45d6df328979af0681364579db889098a0de75b36c77b65" +checksum = "ae0d8406ebf9aaa91f55a57f053c5a1ad1a39f60fdf0303142b7be7ea44311e5" dependencies = [ "gix-actor", - "gix-date", "gix-features", "gix-fs", "gix-hash", @@ -4554,9 +4554,9 @@ dependencies = [ [[package]] name = "gix-tempfile" -version = "13.1.1" +version = "14.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a761d76594f4443b675e85928e4902dec333273836bd386906f01e7e346a0d11" +checksum = "046b4927969fa816a150a0cda2e62c80016fe11fb3c3184e4dddf4e542f108aa" dependencies = [ "gix-fs", "libc", @@ -4583,9 +4583,9 @@ dependencies = [ [[package]] name = "gix-validate" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c27dd34a49b1addf193c92070bcbf3beaf6e10f16a78544de6372e146a0acf" +checksum = "81f2badbb64e57b404593ee26b752c26991910fd0d81fe6f9a71c1a8309b6c86" dependencies = [ "bstr", "thiserror", @@ -4876,9 +4876,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -4900,9 +4900,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -4927,7 +4927,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -4943,9 +4943,9 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", @@ -4960,7 +4960,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "pin-project-lite", "tokio", @@ -4975,7 +4975,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "native-tls", "tokio", @@ -4994,7 +4994,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.4.1", + "hyper 1.5.0", "pin-project-lite", "socket2", "tokio", @@ -5059,9 +5059,9 @@ dependencies = [ [[package]] name = "ignore-files" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99f84e7f847462c582abc4c2aef6ede285ad6e8f66aeec83b47f5481706ddeba" +checksum = "51ce3a1903263527cf3b6512a12f338ae63f425b66c1a3d7a24c3121e8557dbe" dependencies = [ "dunce", "futures", @@ -5297,6 +5297,31 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jiff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a45489186a6123c128fdf6016183fcfab7113e1820eb813127e036e287233fb" +dependencies = [ + "jiff-tzdb-platform", + "windows-sys 0.59.0", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91335e575850c5c4c673b9bd467b0e025f164ca59d0564f69d0c2ee0ffad4653" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9835f0060a626fe59f160437bc725491a6af23133ea906500027d1bd2f8f4329" +dependencies = [ + "jiff-tzdb", +] + [[package]] name = "js-sys" version = "0.3.72" @@ -5426,9 +5451,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.159" +version = "0.2.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f" [[package]] name = "libdbus-sys" @@ -5776,7 +5801,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f4933943834e236c864a48aefdc2da43885dbd5eb77bff3ab20f31e0c3146f5" dependencies = [ - "uuid 1.10.0", + "uuid 1.11.0", ] [[package]] @@ -6121,9 +6146,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -6153,9 +6178,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -6335,9 +6360,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.13" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", "thiserror", @@ -6346,9 +6371,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.13" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" +checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" dependencies = [ "pest", "pest_generator", @@ -6356,9 +6381,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.13" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" +checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" dependencies = [ "pest", "pest_meta", @@ -6369,9 +6394,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.13" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" +checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" dependencies = [ "once_cell", "pest", @@ -6680,9 +6705,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -6850,7 +6875,7 @@ dependencies = [ "quick-xml 0.36.2", "strip-ansi-escapes", "thiserror", - "uuid 1.10.0", + "uuid 1.11.0", ] [[package]] @@ -6891,7 +6916,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.14", + "rustls 0.23.15", "socket2", "thiserror", "tokio", @@ -6908,7 +6933,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.14", + "rustls 0.23.15", "slab", "thiserror", "tinyvec", @@ -7125,7 +7150,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-rustls 0.27.3", "hyper-tls", "hyper-util", @@ -7139,7 +7164,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-native-certs 0.8.0", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7438,9 +7463,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.14" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "log", "once_cell", @@ -7496,9 +7521,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -7523,9 +7548,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rusty-fork" @@ -7621,9 +7646,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553f8299af7450cda9a52d3a370199904e7a46b5ffd1bef187c4a6af3bb6db69" +checksum = "f2c1f7fc6deb21665a9060dfc7d271be784669295a31babdcd4dd2c79ae8cbfb" dependencies = [ "sdd", ] @@ -8187,7 +8212,7 @@ dependencies = [ "thiserror", "tokio", "toml_edit", - "uuid 1.10.0", + "uuid 1.11.0", "zip", "zip-extract", ] @@ -8307,9 +8332,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aebac1b1ef2b46e2e2bdf3c09db304800f2a77c1fa902bd5231490203042be8" +checksum = "040017ebc08d781c457a3bfe9c5c2a99f902f8133eb91ef82b7876b053962ece" dependencies = [ "const-hex", "dirs 5.0.1", @@ -8327,9 +8352,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fa0f145894cb4d1c14446f08098ee5f21fc37ccbd1a7dd9dd355bbc806de3b" +checksum = "2a76fff24884135e66485c726e46b90d7ced3118786b244d05df9ea8aeac8b1b" dependencies = [ "build_const", "const-hex", @@ -8362,9 +8387,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20e7b52ad118b2153644eea95c6fc740b6c1555b2344fdab763fc9de4075f665" +checksum = "ebfc1bfd06acc78f16d8fd3ef846bc222ee7002468d10a7dce8d703d6eab89a3" dependencies = [ "paste", "proc-macro2", @@ -8639,7 +8664,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pki-types", "tokio", ] @@ -8676,7 +8701,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -8756,7 +8781,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-timeout", "hyper-util", "percent-encoding", @@ -9001,7 +9026,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pki-types", "sha1", "thiserror", @@ -9171,9 +9196,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", "serde", diff --git a/Cargo.toml b/Cargo.toml index 877037e097163..27fd23f20cf7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } -foundry-compilers = { version = "0.11.5", default-features = false } +foundry-compilers = { version = "0.11.6", default-features = false } foundry-fork-db = "0.4.0" solang-parser = "=0.3.3" From ca4914772d3162ece49cfa3d2c6c6b28e4d48118 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:20:55 +0300 Subject: [PATCH 1567/1963] fix(cast): do not strip 0x / hex decode message before EIP-191 hashing (#9130) * fix(cast): do not strip 0x / hex decode message before encoding * Pass message directly to eip191_hash_message --- crates/cast/bin/main.rs | 6 +----- crates/cast/tests/cli/main.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 63894d980b0ab..607f4439188ac 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -533,11 +533,7 @@ async fn main_args(args: CastArgs) -> Result<()> { } CastSubcommand::HashMessage { message } => { let message = stdin::unwrap_line(message)?; - let input = match message.strip_prefix("0x") { - Some(hex_str) => hex::decode(hex_str)?, - None => message.as_bytes().to_vec(), - }; - println!("{}", eip191_hash_message(input)); + println!("{}", eip191_hash_message(message)); } CastSubcommand::SigEvent { event_string } => { let event_string = stdin::unwrap_line(event_string)?; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index df566d1144c0b..be9ccc168c118 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1322,7 +1322,7 @@ casttest!(hash_message, |_prj, cmd| { "#]]); cmd.cast_fuse().args(["hash-message", "0x68656c6c6f"]).assert_success().stdout_eq(str![[r#" -0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750 +0x83a0870b6c63a71efdd3b2749ef700653d97454152c4b53fa9b102dc430c7c32 "#]]); }); From 08021d911a88a257739a6c8e6c957dfd1e1d6ee2 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:34:24 +0530 Subject: [PATCH 1568/1963] feat(`anvil`): `wallet_` namespace + inject P256BatchDelegation + executor (#9110) * feat(anvil-rpc): wallet_ namespace * feat: init sponsor and delegation contract in backend * wallet_sendTransaction * wallet_sendTransaction * update p256 runtime code * nit P256_DELEGATION_CONTRACT addr * use correct runtime codes * fix * doc nits * fix * feat: anvil_addCapability * nit * feat: anvil_setExecutor * tests --- Cargo.lock | 1 + crates/anvil/core/Cargo.toml | 1 + crates/anvil/core/src/eth/mod.rs | 19 +++ crates/anvil/core/src/eth/wallet.rs | 79 ++++++++++++ crates/anvil/src/eth/api.rs | 154 +++++++++++++++++++++++- crates/anvil/src/eth/backend/mem/mod.rs | 94 ++++++++++++++- crates/anvil/src/eth/error.rs | 21 ++++ crates/anvil/tests/it/anvil_api.rs | 84 ++++++++++++- 8 files changed, 445 insertions(+), 8 deletions(-) create mode 100644 crates/anvil/core/src/eth/wallet.rs diff --git a/Cargo.lock b/Cargo.lock index 5670390ca3194..c158f31017138 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -932,6 +932,7 @@ dependencies = [ "revm", "serde", "serde_json", + "thiserror", ] [[package]] diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index 6ea5e53184daa..da337c62d8c89 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -38,6 +38,7 @@ bytes = "1.4" # misc rand = "0.8" +thiserror.workspace = true [features] default = ["serde"] diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index d53473666e1f6..e8a3f2ad4f78d 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -19,6 +19,7 @@ pub mod subscription; pub mod transaction; pub mod trie; pub mod utils; +pub mod wallet; #[cfg(feature = "serde")] pub mod serde_helpers; @@ -769,6 +770,24 @@ pub enum EthRequest { /// Reorg the chain #[cfg_attr(feature = "serde", serde(rename = "anvil_reorg",))] Reorg(ReorgOptions), + + /// Wallet + #[cfg_attr(feature = "serde", serde(rename = "wallet_getCapabilities", with = "empty_params"))] + WalletGetCapabilities(()), + + /// Wallet send_tx + #[cfg_attr(feature = "serde", serde(rename = "wallet_sendTransaction", with = "sequence"))] + WalletSendTransaction(Box>), + + /// Add an address to the [`DelegationCapability`] of the wallet + /// + /// [`DelegationCapability`]: wallet::DelegationCapability + #[cfg_attr(feature = "serde", serde(rename = "anvil_addCapability", with = "sequence"))] + AnvilAddCapability(Address), + + /// Set the executor (sponsor) wallet + #[cfg_attr(feature = "serde", serde(rename = "anvil_setExecutor", with = "sequence"))] + AnvilSetExecutor(String), } /// Represents ethereum JSON-RPC API diff --git a/crates/anvil/core/src/eth/wallet.rs b/crates/anvil/core/src/eth/wallet.rs new file mode 100644 index 0000000000000..8676ec2fbf053 --- /dev/null +++ b/crates/anvil/core/src/eth/wallet.rs @@ -0,0 +1,79 @@ +use alloy_primitives::{map::HashMap, Address, ChainId, U64}; +use serde::{Deserialize, Serialize}; + +/// The capability to perform [EIP-7702][eip-7702] delegations, sponsored by the sequencer. +/// +/// The sequencer will only perform delegations, and act on behalf of delegated accounts, if the +/// account delegates to one of the addresses specified within this capability. +/// +/// [eip-7702]: https://eips.ethereum.org/EIPS/eip-7702 +#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, Default)] +pub struct DelegationCapability { + /// A list of valid delegation contracts. + pub addresses: Vec
, +} + +/// Wallet capabilities for a specific chain. +#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, Default)] +pub struct Capabilities { + /// The capability to delegate. + pub delegation: DelegationCapability, +} + +/// A map of wallet capabilities per chain ID. +#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, Default)] +pub struct WalletCapabilities(HashMap); + +impl WalletCapabilities { + /// Get the capabilities of the wallet API for the specified chain ID. + pub fn get(&self, chain_id: ChainId) -> Option<&Capabilities> { + self.0.get(&U64::from(chain_id)) + } + + pub fn insert(&mut self, chain_id: ChainId, capabilities: Capabilities) { + self.0.insert(U64::from(chain_id), capabilities); + } +} + +#[derive(Debug, thiserror::Error)] +pub enum WalletError { + /// The transaction value is not 0. + /// + /// The value should be 0 to prevent draining the sequencer. + #[error("tx value not zero")] + ValueNotZero, + /// The from field is set on the transaction. + /// + /// Requests with the from field are rejected, since it is implied that it will always be the + /// sequencer. + #[error("tx from field is set")] + FromSet, + /// The nonce field is set on the transaction. + /// + /// Requests with the nonce field set are rejected, as this is managed by the sequencer. + #[error("tx nonce is set")] + NonceSet, + /// An authorization item was invalid. + /// + /// The item is invalid if it tries to delegate an account to a contract that is not + /// whitelisted. + #[error("invalid authorization address")] + InvalidAuthorization, + /// The to field of the transaction was invalid. + /// + /// The destination is invalid if: + /// + /// - There is no bytecode at the destination, or + /// - The bytecode is not an EIP-7702 delegation designator, or + /// - The delegation designator points to a contract that is not whitelisted + #[error("the destination of the transaction is not a delegated account")] + IllegalDestination, + /// The transaction request was invalid. + /// + /// This is likely an internal error, as most of the request is built by the sequencer. + #[error("invalid tx request")] + InvalidTransactionRequest, + /// An internal error occurred. + #[error("internal error")] + InternalError, +} diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index a85862664684d..20ac92234f275 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -4,8 +4,8 @@ use super::{ }; use crate::{ eth::{ - backend, backend::{ + self, db::SerializableState, mem::{MIN_CREATE_GAS, MIN_TRANSACTION_GAS}, notifications::NewBlockNotifications, @@ -23,8 +23,7 @@ use crate::{ }, Pool, }, - sign, - sign::Signer, + sign::{self, Signer}, }, filter::{EthFilter, Filters, LogsFilter}, mem::transaction_build, @@ -34,11 +33,17 @@ use crate::{ use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account, TxEnvelope}; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; -use alloy_network::{eip2718::Decodable2718, BlockResponse}; +use alloy_network::{ + eip2718::Decodable2718, BlockResponse, Ethereum, NetworkWallet, TransactionBuilder, +}; use alloy_primitives::{ map::{HashMap, HashSet}, Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64, }; +use alloy_provider::utils::{ + eip1559_default_estimator, EIP1559_FEE_ESTIMATION_PAST_BLOCKS, + EIP1559_FEE_ESTIMATION_REWARD_PERCENTILE, +}; use alloy_rpc_types::{ anvil::{ ForkedNetwork, Forking, Metadata, MineOptions, NodeEnvironment, NodeForkConfig, NodeInfo, @@ -65,6 +70,7 @@ use anvil_core::{ transaction_request_to_typed, PendingTransaction, ReceiptResponse, TypedTransaction, TypedTransactionRequest, }, + wallet::{WalletCapabilities, WalletError}, EthRequest, }, types::{ReorgOptions, TransactionData, Work}, @@ -82,6 +88,7 @@ use foundry_evm::{ }; use futures::channel::{mpsc::Receiver, oneshot}; use parking_lot::RwLock; +use revm::primitives::Bytecode; use std::{future::Future, sync::Arc, time::Duration}; /// The client version: `anvil/v{major}.{minor}.{patch}` @@ -449,6 +456,14 @@ impl EthApi { EthRequest::Reorg(reorg_options) => { self.anvil_reorg(reorg_options).await.to_rpc_result() } + EthRequest::WalletGetCapabilities(()) => self.get_capabilities().to_rpc_result(), + EthRequest::WalletSendTransaction(tx) => { + self.wallet_send_transaction(*tx).await.to_rpc_result() + } + EthRequest::AnvilAddCapability(addr) => self.anvil_add_capability(addr).to_rpc_result(), + EthRequest::AnvilSetExecutor(executor_pk) => { + self.anvil_set_executor(executor_pk).to_rpc_result() + } } } @@ -2369,6 +2384,137 @@ impl EthApi { } } +// ===== impl Wallet endppoints ===== +impl EthApi { + /// Get the capabilities of the wallet. + /// + /// See also [EIP-5792][eip-5792]. + /// + /// [eip-5792]: https://eips.ethereum.org/EIPS/eip-5792 + pub fn get_capabilities(&self) -> Result { + node_info!("wallet_getCapabilities"); + Ok(self.backend.get_capabilities()) + } + + pub async fn wallet_send_transaction( + &self, + mut request: WithOtherFields, + ) -> Result { + node_info!("wallet_sendTransaction"); + + // Validate the request + // reject transactions that have a non-zero value to prevent draining the executor. + if request.value.is_some_and(|val| val > U256::ZERO) { + return Err(WalletError::ValueNotZero.into()) + } + + // reject transactions that have from set, as this will be the executor. + if request.from.is_some() { + return Err(WalletError::FromSet.into()); + } + + // reject transaction requests that have nonce set, as this is managed by the executor. + if request.nonce.is_some() { + return Err(WalletError::NonceSet.into()); + } + + let capabilities = self.backend.get_capabilities(); + let valid_delegations: &[Address] = capabilities + .get(self.chain_id()) + .map(|caps| caps.delegation.addresses.as_ref()) + .unwrap_or_default(); + + if let Some(authorizations) = &request.authorization_list { + if authorizations.iter().any(|auth| !valid_delegations.contains(&auth.address)) { + return Err(WalletError::InvalidAuthorization.into()); + } + } + + // validate the destination address + match (request.authorization_list.is_some(), request.to) { + // if this is an eip-1559 tx, ensure that it is an account that delegates to a + // whitelisted address + (false, Some(TxKind::Call(addr))) => { + let acc = self.backend.get_account(addr).await?; + + let delegated_address = acc + .code + .map(|code| match code { + Bytecode::Eip7702(c) => c.address(), + _ => Address::ZERO, + }) + .unwrap_or_default(); + + // not a whitelisted address, or not an eip-7702 bytecode + if delegated_address == Address::ZERO || + !valid_delegations.contains(&delegated_address) + { + return Err(WalletError::IllegalDestination.into()); + } + } + // if it's an eip-7702 tx, let it through + (true, _) => (), + // create tx's disallowed + _ => return Err(WalletError::IllegalDestination.into()), + } + + let wallet = self.backend.executor_wallet().ok_or(WalletError::InternalError)?; + + let from = NetworkWallet::::default_signer_address(&wallet); + + let nonce = self.get_transaction_count(from, Some(BlockId::latest())).await?; + + request.nonce = Some(nonce); + + let chain_id = self.chain_id(); + + request.chain_id = Some(chain_id); + + request.from = Some(from); + + let gas_limit_fut = self.estimate_gas(request.clone(), Some(BlockId::latest()), None); + + let fees_fut = self.fee_history( + U256::from(EIP1559_FEE_ESTIMATION_PAST_BLOCKS), + BlockNumber::Latest, + vec![EIP1559_FEE_ESTIMATION_REWARD_PERCENTILE], + ); + + let (gas_limit, fees) = tokio::join!(gas_limit_fut, fees_fut); + + let gas_limit = gas_limit?; + let fees = fees?; + + request.gas = Some(gas_limit.to()); + + let base_fee = fees.latest_block_base_fee().unwrap_or_default(); + + let estimation = eip1559_default_estimator(base_fee, &fees.reward.unwrap_or_default()); + + request.max_fee_per_gas = Some(estimation.max_fee_per_gas); + request.max_priority_fee_per_gas = Some(estimation.max_priority_fee_per_gas); + request.gas_price = None; + + let envelope = request.build(&wallet).await.map_err(|_| WalletError::InternalError)?; + + self.send_raw_transaction(envelope.encoded_2718().into()).await + } + + /// Add an address to the delegation capability of wallet. + /// + /// This entails that the executor will now be able to sponsor transactions to this address. + pub fn anvil_add_capability(&self, address: Address) -> Result<()> { + node_info!("anvil_addCapability"); + self.backend.add_capability(address); + Ok(()) + } + + pub fn anvil_set_executor(&self, executor_pk: String) -> Result
{ + node_info!("anvil_setExecutor"); + self.backend.set_executor(executor_pk) + } +} + impl EthApi { /// Executes the future on a new blocking task. async fn on_blocking_task(&self, c: C) -> Result diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0b7777f2db204..c707e72cc17c7 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -36,7 +36,10 @@ use crate::{ use alloy_chains::NamedChain; use alloy_consensus::{Account, Header, Receipt, ReceiptWithBloom}; use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK; -use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256, U64}; +use alloy_network::EthereumWallet; +use alloy_primitives::{ + address, hex, keccak256, utils::Unit, Address, Bytes, TxHash, TxKind, B256, U256, U64, +}; use alloy_rpc_types::{ anvil::Forking, request::TransactionRequest, @@ -56,6 +59,7 @@ use alloy_rpc_types::{ Transaction, TransactionReceipt, }; use alloy_serde::WithOtherFields; +use alloy_signer_local::PrivateKeySigner; use alloy_trie::{proof::ProofRetainer, HashBuilder, Nibbles}; use anvil_core::eth::{ block::{Block, BlockInfo}, @@ -64,6 +68,7 @@ use anvil_core::eth::{ TransactionInfo, TypedReceipt, TypedTransaction, }, utils::meets_eip155, + wallet::{Capabilities, DelegationCapability, WalletCapabilities}, }; use anvil_rpc::error::RpcError; use chrono::Datelike; @@ -111,6 +116,17 @@ pub mod storage; pub const MIN_TRANSACTION_GAS: u128 = 21000; // Gas per transaction creating a contract. pub const MIN_CREATE_GAS: u128 = 53000; +// Executor +pub const EXECUTOR: Address = address!("6634F723546eCc92277e8a2F93d4f248bf1189ea"); +pub const EXECUTOR_PK: &str = "0x502d47e1421cb9abef497096728e69f07543232b93ef24de4998e18b5fd9ba0f"; +// P256 Batch Delegation Contract: https://odyssey-explorer.ithaca.xyz/address/0x35202a6E6317F3CC3a177EeEE562D3BcDA4a6FcC +pub const P256_DELEGATION_CONTRACT: Address = address!("35202a6e6317f3cc3a177eeee562d3bcda4a6fcc"); +// Runtime code of the P256 delegation contract +pub const P256_DELEGATION_RUNTIME_CODE: &[u8] = &hex!("60806040526004361015610018575b361561001657005b005b5f3560e01c806309c5eabe146100c75780630cb6aaf1146100c257806330f6a8e5146100bd5780635fce1927146100b8578063641cdfe2146100b357806376ba882d146100ae5780638d80ff0a146100a9578063972ce4bc146100a4578063a78fc2441461009f578063a82e44e01461009a5763b34893910361000e576108e1565b6108b5565b610786565b610646565b6105ba565b610529565b6103f8565b6103a2565b61034c565b6102c0565b61020b565b634e487b7160e01b5f52604160045260245ffd5b6040810190811067ffffffffffffffff8211176100fc57604052565b6100cc565b6080810190811067ffffffffffffffff8211176100fc57604052565b60a0810190811067ffffffffffffffff8211176100fc57604052565b90601f8019910116810190811067ffffffffffffffff8211176100fc57604052565b6040519061016a608083610139565b565b67ffffffffffffffff81116100fc57601f01601f191660200190565b9291926101948261016c565b916101a26040519384610139565b8294818452818301116101be578281602093845f960137010152565b5f80fd5b9080601f830112156101be578160206101dd93359101610188565b90565b60206003198201126101be576004359067ffffffffffffffff82116101be576101dd916004016101c2565b346101be57610219366101e0565b3033036102295761001690610ae6565b636f6a1b8760e11b5f5260045ffd5b634e487b7160e01b5f52603260045260245ffd5b5f54811015610284575f8080526005919091027f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630191565b610238565b8054821015610284575f52600560205f20910201905f90565b906040516102af816100e0565b602060018294805484520154910152565b346101be5760203660031901126101be576004355f548110156101be576102e69061024c565b5060ff815416600182015491610306600360ff60028401541692016102a2565b926040519215158352602083015260028110156103385760a09260209160408401528051606084015201516080820152f35b634e487b7160e01b5f52602160045260245ffd5b346101be575f3660031901126101be576020600254604051908152f35b6004359063ffffffff821682036101be57565b6064359063ffffffff821682036101be57565b6084359063ffffffff821682036101be57565b346101be5760203660031901126101be576103bb610369565b303303610229576103cb9061024c565b50805460ff19169055005b60609060231901126101be57602490565b60609060831901126101be57608490565b346101be5760803660031901126101be57610411610369565b60205f61041d366103d6565b60015461043161042c82610a0b565b600155565b60405184810191825260e086901b6001600160e01b031916602083015261046581602484015b03601f198101835282610139565b51902060ff61047660408401610a19565b161583146104fe576104b2601b925b85813591013590604051948594859094939260ff6060936080840197845216602083015260408201520152565b838052039060015afa156104f9575f51306001600160a01b03909116036104ea576104df6100169161024c565b50805460ff19169055565b638baa579f60e01b5f5260045ffd5b610a27565b6104b2601c92610485565b60409060031901126101be57600490565b6044359060028210156101be57565b346101be5760803660031901126101be5761054336610509565b61054b61051a565b606435903033036102295761059192610580610587926040519461056e86610101565b60018652602086015260408501610a32565b36906105f3565b6060820152610a3e565b5f545f1981019081116105b55760405163ffffffff919091168152602090f35b0390f35b6109f7565b6100166105c6366101e0565b610ae6565b60409060231901126101be57604051906105e4826100e0565b60243582526044356020830152565b91908260409103126101be5760405161060b816100e0565b6020808294803584520135910152565b6084359081151582036101be57565b60a4359081151582036101be57565b359081151582036101be57565b346101be5760a03660031901126101be5760043567ffffffffffffffff81116101be576106779036906004016101c2565b610680366105cb565b61068861037c565b61069061061b565b906002546106a56106a082610a0b565b600255565b6040516106bb8161045788602083019586610b6a565b51902091610747575b6106d06106d69161024c565b50610b7b565b906106e86106e48351151590565b1590565b610738576020820151801515908161072e575b5061071f576107129260606106e493015191610ce3565b6104ea5761001690610ae6565b632572e3a960e01b5f5260045ffd5b905042115f6106fb565b637dd286d760e11b5f5260045ffd5b905f61077361045761076760209460405192839187830160209181520190565b60405191828092610b58565b039060025afa156104f9575f51906106c4565b346101be5760e03660031901126101be576107a036610509565b6107a861051a565b6064359060205f6107b8366103e7565b6001546107c761042c82610a0b565b60408051808601928352883560208401528589013591830191909152606082018790526107f78160808401610457565b51902060ff61080860408401610a19565b161583146108aa5760408051918252601b602083015282359082015290830135606082015280608081015b838052039060015afa156104f9575f51306001600160a01b03909116036104ea5761087a926105806105879261086761015b565b6001815294602086015260408501610a32565b6105b161089361088a5f54610ad8565b63ffffffff1690565b60405163ffffffff90911681529081906020820190565b610833601c92610485565b346101be575f3660031901126101be576020600154604051908152f35b359061ffff821682036101be57565b346101be5760c03660031901126101be5760043567ffffffffffffffff81116101be576109129036906004016101c2565b61091b366105cb565b906064359167ffffffffffffffff83116101be5760a060031984360301126101be576040516109498161011d565b836004013567ffffffffffffffff81116101be5761096d90600436918701016101c2565b8152602484013567ffffffffffffffff81116101be57840193366023860112156101be5760846109db916109ae610016973690602460048201359101610188565b60208501526109bf604482016108d2565b60408501526109d0606482016108d2565b606085015201610639565b60808201526109e861038f565b916109f161062a565b93610bc3565b634e487b7160e01b5f52601160045260245ffd5b5f1981146105b55760010190565b3560ff811681036101be5790565b6040513d5f823e3d90fd5b60028210156103385752565b5f54680100000000000000008110156100fc57806001610a6192015f555f610289565b610ac557610a7e82511515829060ff801983541691151516179055565b6020820151600182015560028101604083015160028110156103385761016a9360039260609260ff8019835416911617905501519101906020600191805184550151910155565b634e487b7160e01b5f525f60045260245ffd5b5f198101919082116105b557565b80519060205b828110610af857505050565b808201805160f81c600182015160601c91601581015160358201519384915f9493845f14610b4257505050506001146101be575b15610b3a5701605501610aec565b3d5f803e3d5ffd5b5f95508594506055019130811502175af1610b2c565b805191908290602001825e015f815290565b6020906101dd939281520190610b58565b90604051610b8881610101565b6060610bbe6003839560ff8154161515855260018101546020860152610bb860ff60028301541660408701610a32565b016102a2565b910152565b93909192600254610bd66106a082610a0b565b604051610bec8161045789602083019586610b6a565b51902091610c50575b6106d0610c019161024c565b91610c0f6106e48451151590565b6107385760208301518015159081610c46575b5061071f57610c399360606106e494015192610e0d565b6104ea5761016a90610ae6565b905042115f610c22565b905f610c7061045761076760209460405192839187830160209181520190565b039060025afa156104f9575f5190610bf5565b3d15610cad573d90610c948261016c565b91610ca26040519384610139565b82523d5f602084013e565b606090565b8051601f101561028457603f0190565b8051602010156102845760400190565b908151811015610284570160200190565b5f9291839260208251920151906020815191015191604051936020850195865260408501526060840152608083015260a082015260a08152610d2660c082610139565b519060145afa610d34610c83565b81610d74575b81610d43575090565b600160f81b91506001600160f81b031990610d6f90610d6190610cb2565b516001600160f81b03191690565b161490565b80516020149150610d3a565b60405190610d8f604083610139565b6015825274113a3cb832911d113bb2b130baba34371733b2ba1160591b6020830152565b9061016a6001610de3936040519485916c1131b430b63632b733b2911d1160991b6020840152602d830190610b58565b601160f91b815203601e19810185520183610139565b610e069060209392610b58565b9081520190565b92919281516025815110908115610f0a575b50610ef957610e2c610d80565b90610e596106e460208501938451610e53610e4c606089015161ffff1690565b61ffff1690565b91610f9b565b610f01576106e4610e8d610e88610457610e83610ea1956040519283916020830160209181520190565b611012565b610db3565b8351610e53610e4c604088015161ffff1690565b610ef9575f610eb96020925160405191828092610b58565b039060025afa156104f9575f610ee360209261076783519151610457604051938492888401610df9565b039060025afa156104f9576101dd915f51610ce3565b505050505f90565b50505050505f90565b610f2b9150610f1e610d616106e492610cc2565b6080850151151590610f31565b5f610e1f565b906001600160f81b0319600160f81b831601610f955780610f85575b610f8057601f60fb1b600160fb1b821601610f69575b50600190565b600160fc1b90811614610f7c575f610f63565b5f90565b505f90565b50600160fa1b8181161415610f4d565b50505f90565b80519282515f5b858110610fb457505050505050600190565b8083018084116105b5578281101561100757610fe56001600160f81b0319610fdc8488610cd2565b51169187610cd2565b516001600160f81b03191603610ffd57600101610fa2565b5050505050505f90565b505050505050505f90565b80516060929181611021575050565b9092506003600284010460021b604051937f4142434445464748494a4b4c4d4e4f505152535455565758595a616263646566601f527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f603f52602085019282860191602083019460208284010190600460038351955f85525b0191603f8351818160121c16515f538181600c1c1651600153818160061c165160025316516003535f5181520190878210156110db5760049060039061109a565b5095505f93600393604092520160405206600204809303613d3d60f01b81525203825256fea26469706673582212200ba93b78f286a25ece47e9403c47be9862f9b8b70ba1a95098667b90c47308b064736f6c634300081a0033"); +// Experimental ERC20 +pub const EXP_ERC20_CONTRACT: Address = address!("238c8CD93ee9F8c7Edf395548eF60c0d2e46665E"); +// Runtime code of the experimental ERC20 contract +pub const EXP_ERC20_RUNTIME_CODE: &[u8] = &hex!("60806040526004361015610010575b005b5f3560e01c806306fdde03146106f7578063095ea7b31461068c57806318160ddd1461066757806323b872dd146105a15780632bb7c5951461050e578063313ce567146104f35780633644e5151461045557806340c10f191461043057806370a08231146103fe5780637ecebe00146103cc57806395d89b4114610366578063a9059cbb146102ea578063ad0c8fdd146102ad578063d505accf146100fb5763dd62ed3e0361000e57346100f75760403660031901126100f7576100d261075c565b6100da610772565b602052637f5e9f20600c525f5260206034600c2054604051908152f35b5f80fd5b346100f75760e03660031901126100f75761011461075c565b61011c610772565b6084359160643560443560ff851685036100f757610138610788565b60208101906e04578706572696d656e74455243323608c1b8252519020908242116102a0576040519360018060a01b03169460018060a01b03169565383775081901600e52855f5260c06020600c20958654957f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252602082019586528660408301967fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc688528b6060850198468a528c608087019330855260a08820602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9885252528688525260a082015220604e526042602c205f5260ff1660205260a43560405260c43560605260208060805f60015afa93853d5103610293577f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92594602094019055856303faf4f960a51b176040526034602c2055a3005b63ddafbaef5f526004601cfd5b631a15a3cc5f526004601cfd5b5f3660031901126100f7576103e834023481046103e814341517156102d65761000e90336107ac565b634e487b7160e01b5f52601160045260245ffd5b346100f75760403660031901126100f75761030361075c565b602435906387a211a2600c52335f526020600c2080548084116103595783900390555f526020600c20818154019055602052600c5160601c335f51602061080d5f395f51905f52602080a3602060405160018152f35b63f4d678b85f526004601cfd5b346100f7575f3660031901126100f757604051604081019080821067ffffffffffffffff8311176103b8576103b491604052600381526204558560ec1b602082015260405191829182610732565b0390f35b634e487b7160e01b5f52604160045260245ffd5b346100f75760203660031901126100f7576103e561075c565b6338377508600c525f52602080600c2054604051908152f35b346100f75760203660031901126100f75761041761075c565b6387a211a2600c525f52602080600c2054604051908152f35b346100f75760403660031901126100f75761000e61044c61075c565b602435906107ac565b346100f7575f3660031901126100f757602060a0610471610788565b828101906e04578706572696d656e74455243323608c1b8252519020604051907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015220604051908152f35b346100f7575f3660031901126100f757602060405160128152f35b346100f75760203660031901126100f7576004356387a211a2600c52335f526020600c2090815490818111610359575f80806103e88487839688039055806805345cdf77eb68f44c54036805345cdf77eb68f44c5580835282335f51602061080d5f395f51905f52602083a304818115610598575b3390f11561058d57005b6040513d5f823e3d90fd5b506108fc610583565b346100f75760603660031901126100f7576105ba61075c565b6105c2610772565b604435908260601b33602052637f5e9f208117600c526034600c20908154918219610643575b506387a211a2915017600c526020600c2080548084116103595783900390555f526020600c20818154019055602052600c5160601c9060018060a01b03165f51602061080d5f395f51905f52602080a3602060405160018152f35b82851161065a57846387a211a293039055856105e8565b6313be252b5f526004601cfd5b346100f7575f3660031901126100f75760206805345cdf77eb68f44c54604051908152f35b346100f75760403660031901126100f7576106a561075c565b60243590602052637f5e9f20600c52335f52806034600c20555f52602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560205fa3602060405160018152f35b346100f7575f3660031901126100f7576103b4610712610788565b6e04578706572696d656e74455243323608c1b6020820152604051918291825b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b03821682036100f757565b602435906001600160a01b03821682036100f757565b604051906040820182811067ffffffffffffffff8211176103b857604052600f8252565b6805345cdf77eb68f44c548281019081106107ff576805345cdf77eb68f44c556387a211a2600c525f526020600c20818154019055602052600c5160601c5f5f51602061080d5f395f51905f52602080a3565b63e5cfe9575f526004601cfdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220fbe302881d9891005ba1448ba48547cc1cb17dea1a5c4011dfcb035de325bb1d64736f6c634300081b0033"); pub type State = foundry_evm::utils::StateChangeset; @@ -186,6 +202,9 @@ pub struct Backend { precompile_factory: Option>, /// Prevent race conditions during mining mining: Arc>, + // === wallet === // + capabilities: Arc>, + executor_wallet: Arc>>, } impl Backend { @@ -244,6 +263,43 @@ impl Backend { (cfg.slots_in_an_epoch, cfg.precompile_factory.clone()) }; + let (capabilities, executor_wallet) = if alphanet { + // Insert account that sponsors the delegated txs. And deploy P256 delegation contract. + let mut db = db.write().await; + + let _ = db.set_code( + P256_DELEGATION_CONTRACT, + Bytes::from_static(P256_DELEGATION_RUNTIME_CODE), + ); + + // Insert EXP ERC20 contract + let _ = db.set_code(EXP_ERC20_CONTRACT, Bytes::from_static(EXP_ERC20_RUNTIME_CODE)); + + let init_balance = Unit::ETHER.wei().saturating_mul(U256::from(10_000)); // 10K ETH + + // Add ETH + let _ = db.set_balance(EXP_ERC20_CONTRACT, init_balance); + let _ = db.set_balance(EXECUTOR, init_balance); + + let mut capabilities = WalletCapabilities::default(); + + let chain_id = env.read().cfg.chain_id; + capabilities.insert( + chain_id, + Capabilities { + delegation: DelegationCapability { addresses: vec![P256_DELEGATION_CONTRACT] }, + }, + ); + + let signer: PrivateKeySigner = EXECUTOR_PK.parse().unwrap(); + + let executor_wallet = EthereumWallet::new(signer); + + (capabilities, Some(executor_wallet)) + } else { + (WalletCapabilities::default(), None) + }; + let backend = Self { db, blockchain, @@ -265,6 +321,8 @@ impl Backend { slots_in_an_epoch, precompile_factory, mining: Arc::new(tokio::sync::Mutex::new(())), + capabilities: Arc::new(RwLock::new(capabilities)), + executor_wallet: Arc::new(RwLock::new(executor_wallet)), }; if let Some(interval_block_time) = automine_block_time { @@ -283,11 +341,45 @@ impl Backend { Ok(()) } + /// Get the capabilities of the wallet. + /// + /// Currently the only capability is [`DelegationCapability`]. + /// + /// [`DelegationCapability`]: anvil_core::eth::wallet::DelegationCapability + pub(crate) fn get_capabilities(&self) -> WalletCapabilities { + self.capabilities.read().clone() + } + /// Updates memory limits that should be more strict when auto-mine is enabled pub(crate) fn update_interval_mine_block_time(&self, block_time: Duration) { self.states.write().update_interval_mine_block_time(block_time) } + pub(crate) fn executor_wallet(&self) -> Option { + self.executor_wallet.read().clone() + } + + /// Adds an address to the [`DelegationCapability`] of the wallet. + pub(crate) fn add_capability(&self, address: Address) { + let chain_id = self.env.read().cfg.chain_id; + let mut capabilities = self.capabilities.write(); + let mut capability = capabilities.get(chain_id).cloned().unwrap_or_default(); + capability.delegation.addresses.push(address); + capabilities.insert(chain_id, capability); + } + + pub(crate) fn set_executor(&self, executor_pk: String) -> Result { + let signer: PrivateKeySigner = + executor_pk.parse().map_err(|_| RpcError::invalid_params("Invalid private key"))?; + + let executor = signer.address(); + let wallet = EthereumWallet::new(signer); + + *self.executor_wallet.write() = Some(wallet); + + Ok(executor) + } + /// Applies the configured genesis settings /// /// This will fund, create the genesis accounts diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 31d0521bb8543..7af513ff12807 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -5,6 +5,7 @@ use alloy_primitives::{Bytes, SignatureError}; use alloy_rpc_types::BlockNumberOrTag; use alloy_signer::Error as SignerError; use alloy_transport::TransportError; +use anvil_core::eth::wallet::WalletError; use anvil_rpc::{ error::{ErrorCode, RpcError}, response::ResponseResult, @@ -119,6 +120,26 @@ where } } +impl From for BlockchainError { + fn from(value: WalletError) -> Self { + match value { + WalletError::ValueNotZero => Self::Message("tx value not zero".to_string()), + WalletError::FromSet => Self::Message("tx from field is set".to_string()), + WalletError::NonceSet => Self::Message("tx nonce is set".to_string()), + WalletError::InvalidAuthorization => { + Self::Message("invalid authorization address".to_string()) + } + WalletError::IllegalDestination => Self::Message( + "the destination of the transaction is not a delegated account".to_string(), + ), + WalletError::InternalError => Self::Message("internal error".to_string()), + WalletError::InvalidTransactionRequest => { + Self::Message("invalid tx request".to_string()) + } + } + } +} + /// Errors that can occur in the transaction pool #[derive(Debug, thiserror::Error)] pub enum PoolError { diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 74728f94b5931..088eb76feae88 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -7,7 +7,7 @@ use crate::{ }; use alloy_consensus::{SignableTransaction, TxEip1559}; use alloy_network::{EthereumWallet, TransactionBuilder, TxSignerSync}; -use alloy_primitives::{address, fixed_bytes, Address, Bytes, TxKind, U256}; +use alloy_primitives::{address, fixed_bytes, utils::Unit, Address, Bytes, TxKind, U256}; use alloy_provider::{ext::TxPoolApi, Provider}; use alloy_rpc_types::{ anvil::{ @@ -16,9 +16,18 @@ use alloy_rpc_types::{ BlockId, BlockNumberOrTag, TransactionRequest, }; use alloy_serde::WithOtherFields; -use anvil::{eth::api::CLIENT_VERSION, spawn, EthereumHardfork, NodeConfig}; +use anvil::{ + eth::{ + api::CLIENT_VERSION, + backend::mem::{EXECUTOR, P256_DELEGATION_CONTRACT, P256_DELEGATION_RUNTIME_CODE}, + }, + spawn, EthereumHardfork, NodeConfig, +}; use anvil_core::{ - eth::EthRequest, + eth::{ + wallet::{Capabilities, DelegationCapability, WalletCapabilities}, + EthRequest, + }, types::{ReorgOptions, TransactionData}, }; use foundry_evm::revm::primitives::SpecId; @@ -793,3 +802,72 @@ async fn test_reorg() { .await; assert!(res.is_err()); } + +// === wallet endpoints === // +#[tokio::test(flavor = "multi_thread")] +async fn can_get_wallet_capabilities() { + let (api, handle) = spawn(NodeConfig::test().with_alphanet(true)).await; + + let provider = handle.http_provider(); + + let init_sponsor_bal = provider.get_balance(EXECUTOR).await.unwrap(); + + let expected_bal = Unit::ETHER.wei().saturating_mul(U256::from(10_000)); + assert_eq!(init_sponsor_bal, expected_bal); + + let p256_code = provider.get_code_at(P256_DELEGATION_CONTRACT).await.unwrap(); + + assert_eq!(p256_code, Bytes::from_static(P256_DELEGATION_RUNTIME_CODE)); + + let capabilities = api.get_capabilities().unwrap(); + + let mut expect_caps = WalletCapabilities::default(); + let cap: Capabilities = Capabilities { + delegation: DelegationCapability { addresses: vec![P256_DELEGATION_CONTRACT] }, + }; + expect_caps.insert(api.chain_id(), cap); + + assert_eq!(capabilities, expect_caps); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_add_capability() { + let (api, _handle) = spawn(NodeConfig::test().with_alphanet(true)).await; + + let init_capabilities = api.get_capabilities().unwrap(); + + let mut expect_caps = WalletCapabilities::default(); + let cap: Capabilities = Capabilities { + delegation: DelegationCapability { addresses: vec![P256_DELEGATION_CONTRACT] }, + }; + expect_caps.insert(api.chain_id(), cap); + + assert_eq!(init_capabilities, expect_caps); + + let new_cap_addr = Address::with_last_byte(1); + + api.anvil_add_capability(new_cap_addr).unwrap(); + + let capabilities = api.get_capabilities().unwrap(); + + let cap: Capabilities = Capabilities { + delegation: DelegationCapability { + addresses: vec![P256_DELEGATION_CONTRACT, new_cap_addr], + }, + }; + expect_caps.insert(api.chain_id(), cap); + + assert_eq!(capabilities, expect_caps); +} + +#[tokio::test(flavor = "multi_thread")] +async fn can_set_executor() { + let (api, _handle) = spawn(NodeConfig::test().with_alphanet(true)).await; + + let expected_addr = address!("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"); + let pk = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); + + let executor = api.anvil_set_executor(pk).unwrap(); + + assert_eq!(executor, expected_addr); +} From 7cbd55e5b1b655f3855a816e16e954de83bb6b51 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 17 Oct 2024 17:01:52 +0200 Subject: [PATCH 1569/1963] fix: dont set state root (#9134) --- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index c707e72cc17c7..f24be966c6f9a 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2416,7 +2416,7 @@ impl Backend { block_hash: Some(block_hash), from: info.from, to: info.to, - state_root: Some(block.header.state_root), + state_root: None, blob_gas_price: Some(blob_gas_price), blob_gas_used: blob_gas_used.map(|g| g as u128), authorization_list: None, From a8c3e9c1376122e7030dbe5c695b2f1f2a6f389b Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:12:55 +0530 Subject: [PATCH 1570/1963] chore: alias wallet_sendTransaction as odyssey_sendTransaction (#9137) chore: alias wallet_sendTransaction --- crates/anvil/core/src/eth/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index e8a3f2ad4f78d..73c133b2c2857 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -776,7 +776,14 @@ pub enum EthRequest { WalletGetCapabilities(()), /// Wallet send_tx - #[cfg_attr(feature = "serde", serde(rename = "wallet_sendTransaction", with = "sequence"))] + #[cfg_attr( + feature = "serde", + serde( + rename = "wallet_sendTransaction", + alias = "odyssey_sendTransaction", + with = "sequence" + ) + )] WalletSendTransaction(Box>), /// Add an address to the [`DelegationCapability`] of the wallet From 8bdcbfa4d65408b75c4038bd5ee67ce7f6dbd3bb Mon Sep 17 00:00:00 2001 From: mgiagante <5287175+mgiagante@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:05:16 +0100 Subject: [PATCH 1571/1963] feat(`forge build`): add initcode size check (#9116) * Adds init code size limit check & column to table. * Adds option to ignore init code size check during --size output. * Updates tests with new column for --sizes table. * Adds test helpers for forge CLI. * Implements test for init code size limit as per EIP-3860 * Adds test for --ignore-eip-3860 * Fixes for Cargo +nightly fmt warnings. * Refactors both contract size functions into one with a boolean arg. * Adds alias for --ignore-eip-3860 to --ignore-initcode-size. * Brings back the original comments. * Update compile.rs * Changes --ignore-eip-3860 to be a boolean field. * Fixes ranges in table display code and comment punctuation. * Moves testing helper to existing utils module. * Improve ranges in table display code. * Adds output assertions to initcode size check tests. * Minor change to ranges in display logic for sizes table. --------- Co-authored-by: mgiagante <251503-mgiagante@users.noreply.gitlab.com> Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/common/src/compile.rs | 132 ++++++++++++++++++++++++-------- crates/forge/bin/cmd/build.rs | 10 +++ crates/forge/tests/cli/build.rs | 33 +++++++- crates/forge/tests/cli/cmd.rs | 6 +- crates/forge/tests/cli/utils.rs | 29 ++++++- 5 files changed, 168 insertions(+), 42 deletions(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index a75ac0819ddef..39998b3a61c10 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -44,6 +44,9 @@ pub struct ProjectCompiler { /// Whether to bail on compiler errors. bail: Option, + /// Whether to ignore the contract initcode size limit introduced by EIP-3860. + ignore_eip_3860: bool, + /// Extra files to include, that are not necessarily in the project's source dir. files: Vec, } @@ -65,6 +68,7 @@ impl ProjectCompiler { print_sizes: None, quiet: Some(crate::shell::verbosity().is_silent()), bail: None, + ignore_eip_3860: false, files: Vec::new(), } } @@ -114,6 +118,13 @@ impl ProjectCompiler { self } + /// Sets whether to ignore EIP-3860 initcode size limits. + #[inline] + pub fn ignore_eip_3860(mut self, yes: bool) -> Self { + self.ignore_eip_3860 = yes; + self + } + /// Sets extra files to include, that are not necessarily in the project's source dir. #[inline] pub fn files(mut self, files: impl IntoIterator) -> Self { @@ -232,7 +243,8 @@ impl ProjectCompiler { .collect(); for (name, artifact) in artifacts { - let size = deployed_contract_size(artifact).unwrap_or_default(); + let runtime_size = contract_size(artifact, false).unwrap_or_default(); + let init_size = contract_size(artifact, true).unwrap_or_default(); let is_dev_contract = artifact .abi @@ -244,14 +256,21 @@ impl ProjectCompiler { }) }) .unwrap_or(false); - size_report.contracts.insert(name, ContractInfo { size, is_dev_contract }); + size_report + .contracts + .insert(name, ContractInfo { runtime_size, init_size, is_dev_contract }); } println!("{size_report}"); // TODO: avoid process::exit // exit with error if any contract exceeds the size limit, excluding test contracts. - if size_report.exceeds_size_limit() { + if size_report.exceeds_runtime_size_limit() { + std::process::exit(1); + } + + // Check size limits only if not ignoring EIP-3860 + if !self.ignore_eip_3860 && size_report.exceeds_initcode_size_limit() { std::process::exit(1); } } @@ -259,7 +278,10 @@ impl ProjectCompiler { } // https://eips.ethereum.org/EIPS/eip-170 -const CONTRACT_SIZE_LIMIT: usize = 24576; +const CONTRACT_RUNTIME_SIZE_LIMIT: usize = 24576; + +// https://eips.ethereum.org/EIPS/eip-3860 +const CONTRACT_INITCODE_SIZE_LIMIT: usize = 49152; /// Contracts with info about their size pub struct SizeReport { @@ -268,20 +290,34 @@ pub struct SizeReport { } impl SizeReport { - /// Returns the size of the largest contract, excluding test contracts. - pub fn max_size(&self) -> usize { - let mut max_size = 0; - for contract in self.contracts.values() { - if !contract.is_dev_contract && contract.size > max_size { - max_size = contract.size; - } - } - max_size + /// Returns the maximum runtime code size, excluding dev contracts. + pub fn max_runtime_size(&self) -> usize { + self.contracts + .values() + .filter(|c| !c.is_dev_contract) + .map(|c| c.runtime_size) + .max() + .unwrap_or(0) + } + + /// Returns the maximum initcode size, excluding dev contracts. + pub fn max_init_size(&self) -> usize { + self.contracts + .values() + .filter(|c| !c.is_dev_contract) + .map(|c| c.init_size) + .max() + .unwrap_or(0) } - /// Returns true if any contract exceeds the size limit, excluding test contracts. - pub fn exceeds_size_limit(&self) -> bool { - self.max_size() > CONTRACT_SIZE_LIMIT + /// Returns true if any contract exceeds the runtime size limit, excluding dev contracts. + pub fn exceeds_runtime_size_limit(&self) -> bool { + self.max_runtime_size() > CONTRACT_RUNTIME_SIZE_LIMIT + } + + /// Returns true if any contract exceeds the initcode size limit, excluding dev contracts. + pub fn exceeds_initcode_size_limit(&self) -> bool { + self.max_init_size() > CONTRACT_INITCODE_SIZE_LIMIT } } @@ -291,29 +327,49 @@ impl Display for SizeReport { table.load_preset(ASCII_MARKDOWN); table.set_header([ Cell::new("Contract").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Size (B)").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Margin (B)").add_attribute(Attribute::Bold).fg(Color::Blue), + Cell::new("Runtime Size (B)").add_attribute(Attribute::Bold).fg(Color::Blue), + Cell::new("Initcode Size (B)").add_attribute(Attribute::Bold).fg(Color::Blue), + Cell::new("Runtime Margin (B)").add_attribute(Attribute::Bold).fg(Color::Blue), + Cell::new("Initcode Margin (B)").add_attribute(Attribute::Bold).fg(Color::Blue), ]); - // filters out non dev contracts (Test or Script) - let contracts = self.contracts.iter().filter(|(_, c)| !c.is_dev_contract && c.size > 0); + // Filters out dev contracts (Test or Script) + let contracts = self + .contracts + .iter() + .filter(|(_, c)| !c.is_dev_contract && (c.runtime_size > 0 || c.init_size > 0)); for (name, contract) in contracts { - let margin = CONTRACT_SIZE_LIMIT as isize - contract.size as isize; - let color = match contract.size { - 0..=17999 => Color::Reset, - 18000..=CONTRACT_SIZE_LIMIT => Color::Yellow, + let runtime_margin = + CONTRACT_RUNTIME_SIZE_LIMIT as isize - contract.runtime_size as isize; + let init_margin = CONTRACT_INITCODE_SIZE_LIMIT as isize - contract.init_size as isize; + + let runtime_color = match contract.runtime_size { + ..18_000 => Color::Reset, + 18_000..=CONTRACT_RUNTIME_SIZE_LIMIT => Color::Yellow, + _ => Color::Red, + }; + + let init_color = match contract.init_size { + ..36_000 => Color::Reset, + 36_000..=CONTRACT_INITCODE_SIZE_LIMIT => Color::Yellow, _ => Color::Red, }; let locale = &Locale::en; table.add_row([ - Cell::new(name).fg(color), - Cell::new(contract.size.to_formatted_string(locale)) + Cell::new(name).fg(Color::Blue), + Cell::new(contract.runtime_size.to_formatted_string(locale)) .set_alignment(CellAlignment::Right) - .fg(color), - Cell::new(margin.to_formatted_string(locale)) + .fg(runtime_color), + Cell::new(contract.init_size.to_formatted_string(locale)) .set_alignment(CellAlignment::Right) - .fg(color), + .fg(init_color), + Cell::new(runtime_margin.to_formatted_string(locale)) + .set_alignment(CellAlignment::Right) + .fg(runtime_color), + Cell::new(init_margin.to_formatted_string(locale)) + .set_alignment(CellAlignment::Right) + .fg(init_color), ]); } @@ -322,9 +378,14 @@ impl Display for SizeReport { } } -/// Returns the size of the deployed contract -pub fn deployed_contract_size(artifact: &T) -> Option { - let bytecode = artifact.get_deployed_bytecode_object()?; +/// Returns the deployed or init size of the contract. +fn contract_size(artifact: &T, initcode: bool) -> Option { + let bytecode = if initcode { + artifact.get_bytecode_object()? + } else { + artifact.get_deployed_bytecode_object()? + }; + let size = match bytecode.as_ref() { BytecodeObject::Bytecode(bytes) => bytes.len(), BytecodeObject::Unlinked(unlinked) => { @@ -338,14 +399,17 @@ pub fn deployed_contract_size(artifact: &T) -> Option { size / 2 } }; + Some(size) } /// How big the contract is and whether it is a dev contract where size limits can be neglected #[derive(Clone, Copy, Debug)] pub struct ContractInfo { - /// size of the contract in bytes - pub size: usize, + /// Size of the runtime code in bytes + pub runtime_size: usize, + /// Size of the initcode in bytes + pub init_size: usize, /// A development contract is either a Script or a Test contract. pub is_dev_contract: bool, } diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 53bc5bc2001b9..e539bfaeed693 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -60,6 +60,11 @@ pub struct BuildArgs { #[serde(skip)] pub sizes: bool, + /// Ignore initcode contract bytecode size limit introduced by EIP-3860. + #[arg(long, alias = "ignore-initcode-size")] + #[serde(skip)] + pub ignore_eip_3860: bool, + #[command(flatten)] #[serde(flatten)] pub args: CoreBuildArgs, @@ -102,6 +107,7 @@ impl BuildArgs { .files(files) .print_names(self.names) .print_sizes(self.sizes) + .ignore_eip_3860(self.ignore_eip_3860) .quiet(self.format_json) .bail(!self.format_json); @@ -158,6 +164,10 @@ impl Provider for BuildArgs { dict.insert("sizes".to_string(), true.into()); } + if self.ignore_eip_3860 { + dict.insert("ignore_eip_3860".to_string(), true.into()); + } + Ok(Map::from([(Config::selected_profile(), dict)])) } } diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index d9861f19e392d..81919241fa007 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -1,3 +1,4 @@ +use crate::utils::generate_large_contract; use foundry_config::Config; use foundry_test_utils::{forgetest, snapbox::IntoData, str}; use globset::Glob; @@ -42,6 +43,32 @@ contract Dummy { "#]].is_json()); }); +forgetest!(initcode_size_exceeds_limit, |prj, cmd| { + prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); + cmd.args(["build", "--sizes"]).assert_failure().stdout_eq(str![ + r#" +... +| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | +|--------------|------------------|-------------------|--------------------|---------------------| +| HugeContract | 202 | 49,359 | 24,374 | -207 | +... +"# + ]); +}); + +forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { + prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); + cmd.args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq(str![ + r#" +... +| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | +|--------------|------------------|-------------------|--------------------|---------------------| +| HugeContract | 202 | 49,359 | 24,374 | -207 | +... +"# + ]); +}); + // tests build output is as expected forgetest_init!(exact_build_output, |prj, cmd| { cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" @@ -57,9 +84,9 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![ r#" ... -| Contract | Size (B) | Margin (B) | -|----------|----------|------------| -| Counter | 247 | 24,329 | +| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | +|----------|------------------|-------------------|--------------------|---------------------| +| Counter | 247 | 277 | 24,329 | 48,875 | ... "# ]); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index d82600b6251ab..78c18bbaf65d3 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2186,9 +2186,9 @@ forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { [COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! -| Contract | Size (B) | Margin (B) | -|----------|----------|------------| -| Counter | 247 | 24,329 | +| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | +|----------|------------------|-------------------|--------------------|---------------------| +| Counter | 247 | 277 | 24,329 | 48,875 | "#]]); diff --git a/crates/forge/tests/cli/utils.rs b/crates/forge/tests/cli/utils.rs index 094255195c1e3..2b0bb627314ac 100644 --- a/crates/forge/tests/cli/utils.rs +++ b/crates/forge/tests/cli/utils.rs @@ -126,7 +126,7 @@ impl EnvExternalities { pub fn parse_deployed_address(out: &str) -> Option { for line in out.lines() { if line.starts_with("Deployed to") { - return Some(line.trim_start_matches("Deployed to: ").to_string()) + return Some(line.trim_start_matches("Deployed to: ").to_string()); } } None @@ -135,8 +135,33 @@ pub fn parse_deployed_address(out: &str) -> Option { pub fn parse_verification_guid(out: &str) -> Option { for line in out.lines() { if line.contains("GUID") { - return Some(line.replace("GUID:", "").replace('`', "").trim().to_string()) + return Some(line.replace("GUID:", "").replace('`', "").trim().to_string()); } } None } + +// Generates a string containing the code of a Solidity contract +// with a variable init code size. +pub fn generate_large_contract(num_elements: usize) -> String { + let mut contract_code = String::new(); + + contract_code.push_str( + "// Auto-generated Solidity contract to inflate initcode size\ncontract HugeContract {\n uint256 public number;\n" + ); + + contract_code.push_str(" uint256[] public largeArray;\n\n constructor() {\n"); + contract_code.push_str(" largeArray = ["); + + for i in 0..num_elements { + if i != 0 { + contract_code.push_str(", "); + } + contract_code.push_str(&i.to_string()); + } + + contract_code.push_str("];\n"); + contract_code.push_str(" }\n}"); + + contract_code +} From 9684c3d01412db5545cdc4407e8dce8729ba9ca9 Mon Sep 17 00:00:00 2001 From: mgiagante <5287175+mgiagante@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:23:12 +0100 Subject: [PATCH 1572/1963] docs: update CLI help for init code size check (#9145) --- crates/forge/bin/cmd/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index e539bfaeed693..fefa76e465eb2 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -56,6 +56,7 @@ pub struct BuildArgs { pub names: bool, /// Print compiled contract sizes. + /// Constructor argument length is not included in the calculation of initcode size. #[arg(long)] #[serde(skip)] pub sizes: bool, From ce66e14cc23213cd51f390f1a691dec522011378 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:49:16 +0000 Subject: [PATCH 1573/1963] chore(deps): weekly `cargo update` (#9149) Locking 8 packages to latest compatible versions Updating alloy-chains v0.1.38 -> v0.1.40 Updating anyhow v1.0.89 -> v1.0.90 Updating cc v1.1.30 -> v1.1.31 Updating libc v0.2.160 -> v0.2.161 Updating prettyplease v0.2.22 -> v0.2.23 Updating serde_json v1.0.128 -> v1.0.132 Updating syn v2.0.79 -> v2.0.80 Updating unicase v2.7.0 -> v2.8.0 note: pass `--verbose` to see 39 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 151 ++++++++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c158f31017138..f88eeb08629cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.38" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "156bfc5dcd52ef9a5f33381701fa03310317e14c65093a9430d3e3557b08dcd3" +checksum = "d4932d790c723181807738cf1ac68198ab581cd699545b155601332541ee47bd" dependencies = [ "alloy-primitives", "num_enum", @@ -367,7 +367,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -615,7 +615,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -632,7 +632,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", "syn-solidity", "tiny-keccak", ] @@ -650,7 +650,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.79", + "syn 2.0.80", "syn-solidity", ] @@ -966,9 +966,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" [[package]] name = "arbitrary" @@ -1158,7 +1158,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -1180,7 +1180,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -1191,7 +1191,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -1244,7 +1244,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -1776,7 +1776,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -1992,9 +1992,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "shlex", ] @@ -2157,7 +2157,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2575,7 +2575,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2586,7 +2586,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2659,7 +2659,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2680,7 +2680,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2690,7 +2690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2701,7 +2701,7 @@ checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2722,7 +2722,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", "unicode-xid", ] @@ -2830,7 +2830,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2855,7 +2855,7 @@ checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -2982,7 +2982,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -3117,7 +3117,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.79", + "syn 2.0.80", "toml 0.8.19", "walkdir", ] @@ -3145,7 +3145,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.79", + "syn 2.0.80", "tempfile", "thiserror", "tiny-keccak", @@ -3533,7 +3533,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -4100,7 +4100,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -4259,7 +4259,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -4782,7 +4782,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -5215,7 +5215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -5452,9 +5452,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.160" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libdbus-sys" @@ -5679,7 +5679,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -5770,7 +5770,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6029,7 +6029,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6168,7 +6168,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6331,7 +6331,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6390,7 +6390,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6474,7 +6474,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6532,7 +6532,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6618,12 +6618,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "904afd36257cdb6ce0bee88b7981847bd7b955e5e216bb32f466b302923ad446" dependencies = [ "proc-macro2", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6701,7 +6701,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6721,7 +6721,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", "version_check", "yansi", ] @@ -6785,7 +6785,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -6808,7 +6808,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -7684,7 +7684,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -7846,7 +7846,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -7857,14 +7857,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "indexmap 2.6.0", "itoa", @@ -7901,7 +7901,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -7947,7 +7947,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -8309,7 +8309,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -8377,9 +8377,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "e6e185e337f816bc8da115b8afcb3324006ccc82eeaddf35113888d3bd8e44ac" dependencies = [ "proc-macro2", "quote", @@ -8395,7 +8395,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -8511,7 +8511,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -8636,7 +8636,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -8911,7 +8911,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -9075,12 +9075,9 @@ dependencies = [ [[package]] name = "unicase" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] +checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-bidi" @@ -9317,7 +9314,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", "wasm-bindgen-shared", ] @@ -9351,7 +9348,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9568,7 +9565,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -9579,7 +9576,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -9590,7 +9587,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -9601,7 +9598,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -9867,7 +9864,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] @@ -9887,7 +9884,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.80", ] [[package]] From 52b3da2597e93bfda85fc650948945855e8e771e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:45:14 +0200 Subject: [PATCH 1574/1963] =?UTF-8?q?feat(`forge=20build`):=20`--watch`=20?= =?UTF-8?q?flag=20now=20watches=20`foundry.toml`=20config=E2=80=A6=20(#914?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(`forge build`): `--watch` flag now watches `foundry.toml` config changes --- crates/forge/bin/cmd/build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index fefa76e465eb2..f0fa7c9006e45 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -138,10 +138,12 @@ impl BuildArgs { /// Returns the [`watchexec::InitConfig`] and [`watchexec::RuntimeConfig`] necessary to /// bootstrap a new [`watchexe::Watchexec`] loop. pub(crate) fn watchexec_config(&self) -> Result { - // use the path arguments or if none where provided the `src` dir + // Use the path arguments or if none where provided the `src`, `test` and `script` + // directories as well as the `foundry.toml` configuration file. self.watch.watchexec_config(|| { let config = Config::from(self); - [config.src, config.test, config.script] + let foundry_toml: PathBuf = config.root.0.join(Config::FILE_NAME); + [config.src, config.test, config.script, foundry_toml] }) } } From 09824ad0cdb4d20e280e1698ca9097b869b2a4da Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Mon, 21 Oct 2024 12:49:15 +0400 Subject: [PATCH 1575/1963] fix: script simulation with default sender (#9042) * add test * fix: ensure correct sender nonce when dry-running script in fork * fix test * Fix test --------- Co-authored-by: grandizzy --- crates/cheatcodes/src/inspector.rs | 35 ++++++++-------- crates/forge/tests/cli/script.rs | 64 ++++++++++++++++++++++++++++++ crates/script/src/runner.rs | 15 +++++++ 3 files changed, 95 insertions(+), 19 deletions(-) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 043f8af2fbe46..7d91f5e203110 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -28,7 +28,6 @@ use alloy_primitives::{ use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use alloy_sol_types::{SolCall, SolInterface, SolValue}; use foundry_common::{evm::Breakpoints, TransactionMaybeSigned, SELECTOR_LEN}; -use foundry_config::Config; use foundry_evm_core::{ abi::Vm::stopExpectSafeMemoryCall, backend::{DatabaseError, DatabaseExt, RevertDiagnostic}, @@ -834,25 +833,23 @@ where { // broadcasting. if ecx.journaled_state.depth == 0 { let sender = ecx.env.tx.caller; - if sender != Config::DEFAULT_SENDER { - let account = match super::evm::journaled_account(ecx, sender) { - Ok(account) => account, - Err(err) => { - return Some(CallOutcome { - result: InterpreterResult { - result: InstructionResult::Revert, - output: err.abi_encode().into(), - gas, - }, - memory_offset: call.return_memory_offset.clone(), - }) - } - }; - let prev = account.info.nonce; - account.info.nonce = prev.saturating_sub(1); + let account = match super::evm::journaled_account(ecx, sender) { + Ok(account) => account, + Err(err) => { + return Some(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: err.abi_encode().into(), + gas, + }, + memory_offset: call.return_memory_offset.clone(), + }) + } + }; + let prev = account.info.nonce; + account.info.nonce = prev.saturating_sub(1); - trace!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); - } + trace!(target: "cheatcodes", %sender, nonce=account.info.nonce, prev, "corrected nonce"); } if call.target_address == CHEATCODE_ADDRESS { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 558580728b005..dda45cf514fdd 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2146,3 +2146,67 @@ Script ran successfully. "#]]); }); + +forgetest_async!(can_simulate_with_default_sender, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Script.s.sol", + r#" +import "forge-std/Script.sol"; +contract A { + function getValue() external pure returns (uint256) { + return 100; + } +} +contract B { + constructor(A a) { + require(a.getValue() == 100); + } +} +contract SimpleScript is Script { + function run() external { + vm.startBroadcast(); + A a = new A(); + new B(a); + } +} + "#, + ) + .unwrap(); + + cmd.arg("script").args(["SimpleScript", "--fork-url", &handle.http_endpoint(), "-vvvv"]); + cmd.assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Traces: + [104553] SimpleScript::run() + ├─ [0] VM::startBroadcast() + │ └─ ← [Return] + ├─ [23875] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 + │ └─ ← [Return] 119 bytes of code + ├─ [13367] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 + │ ├─ [146] A::getValue() [staticcall] + │ │ └─ ← [Return] 100 + │ └─ ← [Return] 63 bytes of code + └─ ← [Stop] + + +Script ran successfully. + +## Setting up 1 EVM. +========================== +Simulated On-chain Traces: + + [23875] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 + └─ ← [Return] 119 bytes of code + + [15867] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 + ├─ [146] A::getValue() [staticcall] + │ └─ ← [Return] 100 + └─ ← [Return] 63 bytes of code +... +"#]]); +}); diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 2b3fc5253b9cc..51b1018475dd0 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -133,6 +133,17 @@ impl ScriptRunner { // construction self.executor.set_balance(address, self.evm_opts.initial_balance)?; + // HACK: if the current sender is the default script sender (which is a default value), we + // set its nonce to a very large value before deploying the script contract. This + // ensures that the nonce increase during this CREATE does not affect deployment + // addresses of contracts that are deployed in the script, Otherwise, we'd have a + // nonce mismatch during script execution and onchain simulation, potentially + // resulting in weird errors like . + let prev_sender_nonce = self.executor.get_nonce(self.evm_opts.sender)?; + if self.evm_opts.sender == CALLER { + self.executor.set_nonce(self.evm_opts.sender, u64::MAX / 2)?; + } + // Deploy an instance of the contract let DeployResult { address, @@ -142,6 +153,10 @@ impl ScriptRunner { .deploy(CALLER, code, U256::ZERO, None) .map_err(|err| eyre::eyre!("Failed to deploy script:\n{}", err))?; + if self.evm_opts.sender == CALLER { + self.executor.set_nonce(self.evm_opts.sender, prev_sender_nonce)?; + } + traces.extend(constructor_traces.map(|traces| (TraceKind::Deployment, traces))); // Optionally call the `setUp` function From 7c1c019455686cdb277cfb3d47c15e22a59ae985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:12:18 +0200 Subject: [PATCH 1576/1963] feat(cast): add `json` flag in `cast wallet new-mnemonic` (#9139) * feat(cast): add `json` flag in `cast wallet new-mnemonic` * Update crates/cast/bin/cmd/wallet/mod.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cast/tests/cli/main.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * chore: adjust `wallet_mnemonic_from_entropy` to generate three accounts instead of one * Update crates/cast/bin/cmd/wallet/mod.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * fix: preserve check-summed format for addresses * chore: simplify code * fix: rustfmt --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/cast/bin/cmd/wallet/mod.rs | 43 +++++++++++++++++++----- crates/cast/tests/cli/main.rs | 55 +++++++++++++++++++++++++++++-- 2 files changed, 87 insertions(+), 11 deletions(-) diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 893a0f0ecdb4d..4664e66116878 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -69,6 +69,10 @@ pub enum WalletSubcommands { /// Entropy to use for the mnemonic #[arg(long, short, conflicts_with = "words")] entropy: Option, + + /// Output generated mnemonic phrase and accounts as JSON. + #[arg(long, short, default_value = "false")] + json: bool, }, /// Generate a vanity address. @@ -290,16 +294,19 @@ impl WalletSubcommands { } } } - Self::NewMnemonic { words, accounts, entropy } => { + Self::NewMnemonic { words, accounts, entropy, json } => { let phrase = if let Some(entropy) = entropy { let entropy = Entropy::from_slice(hex::decode(entropy)?)?; - println!("{}", "Generating mnemonic from provided entropy...".yellow()); Mnemonic::::new_from_entropy(entropy).to_phrase() } else { let mut rng = thread_rng(); Mnemonic::::new_with_count(&mut rng, words)?.to_phrase() }; + if !json { + println!("{}", "Generating mnemonic from provided entropy...".yellow()); + } + let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); let derivation_path = "m/44'/60'/0'/0/"; let wallets = (0..accounts) @@ -308,13 +315,33 @@ impl WalletSubcommands { let wallets = wallets.into_iter().map(|b| b.build()).collect::, _>>()?; - println!("{}", "Successfully generated a new mnemonic.".green()); - println!("Phrase:\n{phrase}"); - println!("\nAccounts:"); + if !json { + println!("{}", "Successfully generated a new mnemonic.".green()); + println!("Phrase:\n{phrase}"); + println!("\nAccounts:"); + } + + let mut accounts = json!([]); for (i, wallet) in wallets.iter().enumerate() { - println!("- Account {i}:"); - println!("Address: {}", wallet.address()); - println!("Private key: 0x{}\n", hex::encode(wallet.credential().to_bytes())); + let private_key = hex::encode(wallet.credential().to_bytes()); + if json { + accounts.as_array_mut().unwrap().push(json!({ + "address": format!("{}", wallet.address()), + "private_key": format!("0x{}", private_key), + })); + } else { + println!("- Account {i}:"); + println!("Address: {}", wallet.address()); + println!("Private key: 0x{private_key}\n"); + } + } + + if json { + let obj = json!({ + "mnemonic": phrase, + "accounts": accounts, + }); + println!("{}", serde_json::to_string_pretty(&obj)?); } } Self::Vanity(cmd) => { diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index be9ccc168c118..5487dc9f374bc 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -285,9 +285,16 @@ Created new encrypted keystore file: [..] // tests that `cast wallet new-mnemonic --entropy` outputs the expected mnemonic casttest!(wallet_mnemonic_from_entropy, |_prj, cmd| { - cmd.args(["wallet", "new-mnemonic", "--entropy", "0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c"]) - .assert_success() - .stdout_eq(str![[r#" + cmd.args([ + "wallet", + "new-mnemonic", + "--accounts", + "3", + "--entropy", + "0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c", + ]) + .assert_success() + .stdout_eq(str![[r#" Generating mnemonic from provided entropy... Successfully generated a new mnemonic. Phrase: @@ -298,6 +305,48 @@ Accounts: Address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Private key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +- Account 1: +Address: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 +Private key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d + +- Account 2: +Address: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC +Private key: 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a + + +"#]]); +}); + +// tests that `cast wallet new-mnemonic --json` outputs the expected mnemonic +casttest!(wallet_mnemonic_from_entropy_json, |_prj, cmd| { + cmd.args([ + "wallet", + "new-mnemonic", + "--accounts", + "3", + "--entropy", + "0xdf9bf37e6fcdf9bf37e6fcdf9bf37e3c", + "--json", + ]) + .assert_success() + .stdout_eq(str![[r#" +{ + "mnemonic": "test test test test test test test test test test test junk", + "accounts": [ + { + "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "private_key": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" + }, + { + "address": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", + "private_key": "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" + }, + { + "address": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", + "private_key": "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a" + } + ] +} "#]]); }); From 6d9951fce6ed482ec6717c104b9795d3cc3bb346 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:59:00 +0530 Subject: [PATCH 1577/1963] fix(`anvil`): use header.number not best_number (#9151) * fix(`anvil`): use header.number not best_number * test * ignore test_arbitrum_fork_block_number --- crates/anvil/src/eth/backend/mem/mod.rs | 2 -- crates/anvil/tests/it/anvil_api.rs | 17 +++++++++++++++++ crates/anvil/tests/it/fork.rs | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f24be966c6f9a..590e940e1dc0c 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1916,8 +1916,6 @@ impl Backend { NamedChain::ArbitrumTestnet, ) = NamedChain::try_from(self.env.read().env.cfg.chain_id) { - // Block number is the best number. - block.header.number = self.best_number(); // Set `l1BlockNumber` field. block.other.insert("l1BlockNumber".to_string(), number.into()); } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 088eb76feae88..a6e36929cf257 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -871,3 +871,20 @@ async fn can_set_executor() { assert_eq!(executor, expected_addr); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_arb_get_block() { + let (api, _handle) = spawn(NodeConfig::test().with_chain_id(Some(421611u64))).await; + + // Mine two blocks + api.mine_one().await; + api.mine_one().await; + + let best_number = api.block_number().unwrap().to::(); + + assert_eq!(best_number, 2); + + let block = api.block_by_number(1.into()).await.unwrap().unwrap(); + + assert_eq!(block.header.number, 1); +} diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index e6db8a0635bbc..7fd9293f31956 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1218,6 +1218,7 @@ async fn test_arbitrum_fork_dev_balance() { // #[tokio::test(flavor = "multi_thread")] +#[ignore] async fn test_arbitrum_fork_block_number() { // fork to get initial block for test let (_, handle) = spawn( From 1af44bf750e6c3917dcdcaf8f853a44aacb061ad Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:25:31 +0530 Subject: [PATCH 1578/1963] fix(`anvil`): arb fork mining (#9153) * fix(`anvil`): use header.number not best_number * test * ignore test_arbitrum_fork_block_number * fix(`anvil`): miner logic for arb-like chains * clippy * test --- crates/anvil/src/eth/backend/mem/mod.rs | 33 ++++++++++++++++--------- crates/anvil/tests/it/fork.rs | 22 ++++++++++++++++- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 590e940e1dc0c..0414b013cbdde 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1098,8 +1098,17 @@ impl Backend { env.cfg.disable_base_fee = true; } + let block_number = + self.blockchain.storage.read().best_number.saturating_add(U64::from(1)); + // increase block number for this block - env.block.number = env.block.number.saturating_add(U256::from(1)); + if is_arbitrum(env.cfg.chain_id) { + // Temporary set `env.block.number` to `block_number` for Arbitrum chains. + env.block.number = block_number.to(); + } else { + env.block.number = env.block.number.saturating_add(U256::from(1)); + } + env.block.basefee = U256::from(current_base_fee); env.block.blob_excess_gas_and_price = current_excess_blob_gas_and_price; @@ -1149,9 +1158,7 @@ impl Backend { let ExecutedTransactions { block, included, invalid } = executed_tx; let BlockInfo { block, transactions, receipts } = block; - let mut storage = self.blockchain.storage.write(); let header = block.header.clone(); - let block_number = storage.best_number.saturating_add(U64::from(1)); trace!( target: "backend", @@ -1160,7 +1167,7 @@ impl Backend { transactions.len(), transactions.iter().map(|tx| tx.transaction_hash).collect::>() ); - + let mut storage = self.blockchain.storage.write(); // update block metadata storage.best_number = block_number; storage.best_hash = block_hash; @@ -1909,13 +1916,7 @@ impl Backend { let mut block = WithOtherFields::new(block); // If Arbitrum, apply chain specifics to converted block. - if let Ok( - NamedChain::Arbitrum | - NamedChain::ArbitrumGoerli | - NamedChain::ArbitrumNova | - NamedChain::ArbitrumTestnet, - ) = NamedChain::try_from(self.env.read().env.cfg.chain_id) - { + if is_arbitrum(self.env.read().cfg.chain_id) { // Set `l1BlockNumber` field. block.other.insert("l1BlockNumber".to_string(), number.into()); } @@ -2952,3 +2953,13 @@ pub fn prove_storage(storage: &HashMap, keys: &[B256]) -> Vec bool { + matches!( + NamedChain::try_from(chain_id), + Ok(NamedChain::Arbitrum | + NamedChain::ArbitrumTestnet | + NamedChain::ArbitrumGoerli | + NamedChain::ArbitrumNova) + ) +} diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 7fd9293f31956..d8df936b1e0a0 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1216,9 +1216,29 @@ async fn test_arbitrum_fork_dev_balance() { } } +// +#[tokio::test(flavor = "multi_thread")] +async fn test_arb_fork_mining() { + let fork_block_number = 266137031u64; + let fork_rpc = next_rpc_endpoint(NamedChain::Arbitrum); + let (api, _handle) = spawn( + fork_config() + .with_fork_block_number(Some(fork_block_number)) + .with_eth_rpc_url(Some(fork_rpc)), + ) + .await; + + let init_blk_num = api.block_number().unwrap().to::(); + + // Mine one + api.mine_one().await; + let mined_blk_num = api.block_number().unwrap().to::(); + + assert_eq!(mined_blk_num, init_blk_num + 1); +} + // #[tokio::test(flavor = "multi_thread")] -#[ignore] async fn test_arbitrum_fork_block_number() { // fork to get initial block for test let (_, handle) = spawn( From 2044faec64f99a21f0e5f0094458a973612d0712 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:22:06 +0300 Subject: [PATCH 1579/1963] fix(cheatcodes): improve fork cheatcodes messages (#9141) fix(cheatcodes): chain report source errors --- crates/cheatcodes/src/error.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index 85be519bfd5e2..d459e9274bb22 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -293,7 +293,6 @@ impl_from!( alloy_primitives::SignatureError, FsPathError, hex::FromHexError, - eyre::Error, BackendError, DatabaseError, jsonpath_lib::JsonPathError, @@ -316,6 +315,17 @@ impl> From> for Error { } } +impl From for Error { + #[inline] + fn from(err: eyre::Report) -> Self { + let mut chained_cause = String::new(); + for cause in err.chain() { + chained_cause.push_str(format!(" {cause};").as_str()); + } + Self::display(chained_cause) + } +} + #[cfg(test)] mod tests { use super::*; From 4d7435e64ba1d351d128be3b1a30e6d6b246696a Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:59:41 +0530 Subject: [PATCH 1580/1963] feat(`anvil`): support mining with same block.timestamp (#9160) * feat(`anvil`): support mining with same block.timestamp * fix timestamp tests * fix --- crates/anvil/src/eth/backend/time.rs | 6 +- crates/anvil/tests/it/anvil_api.rs | 127 ++++++++++++++++++++++++++- crates/anvil/tests/it/fork.rs | 2 +- 3 files changed, 128 insertions(+), 7 deletions(-) diff --git a/crates/anvil/src/eth/backend/time.rs b/crates/anvil/src/eth/backend/time.rs index 0822baa047168..3ae9524f0e5eb 100644 --- a/crates/anvil/src/eth/backend/time.rs +++ b/crates/anvil/src/eth/backend/time.rs @@ -70,9 +70,9 @@ impl TimeManager { /// Fails if it's before (or at the same time) the last timestamp pub fn set_next_block_timestamp(&self, timestamp: u64) -> Result<(), BlockchainError> { trace!(target: "time", "override next timestamp {}", timestamp); - if timestamp <= *self.last_timestamp.read() { + if timestamp < *self.last_timestamp.read() { return Err(BlockchainError::TimestampError(format!( - "{timestamp} is lower than or equal to previous block's timestamp" + "{timestamp} is lower than previous block's timestamp" ))) } self.next_exact_timestamp.write().replace(timestamp); @@ -112,7 +112,7 @@ impl TimeManager { (current.saturating_add(self.offset()) as u64, false) }; // Ensures that the timestamp is always increasing - if next_timestamp <= last_timestamp { + if next_timestamp < last_timestamp { next_timestamp = last_timestamp + 1; } let next_offset = update_offset.then_some((next_timestamp as i128) - current); diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index a6e36929cf257..da5372c7edb37 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -315,7 +315,7 @@ async fn test_set_next_timestamp() { let next = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); assert_eq!(next.header.number, 2); - assert!(next.header.timestamp > block.header.timestamp); + assert!(next.header.timestamp >= block.header.timestamp); } #[tokio::test(flavor = "multi_thread")] @@ -339,7 +339,7 @@ async fn test_evm_set_time() { api.evm_mine(None).await.unwrap(); let next = provider.get_block(BlockId::default(), false.into()).await.unwrap().unwrap(); - assert!(next.header.timestamp > block.header.timestamp); + assert!(next.header.timestamp >= block.header.timestamp); } #[tokio::test(flavor = "multi_thread")] @@ -608,7 +608,7 @@ async fn test_fork_revert_next_block_timestamp() { api.mine_one().await; let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert!(block.header.timestamp > latest_block.header.timestamp); + assert!(block.header.timestamp >= latest_block.header.timestamp); } // test that after a snapshot revert, the env block is reset @@ -888,3 +888,124 @@ async fn test_arb_get_block() { assert_eq!(block.header.number, 1); } + +// Set next_block_timestamp same as previous block +// api.evm_set_next_block_timestamp(0).unwrap(); +#[tokio::test(flavor = "multi_thread")] +async fn test_mine_blk_with_prev_timestamp() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + let init_blk = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let init_number = init_blk.header.number; + let init_timestamp = init_blk.header.timestamp; + + // mock timestamp + api.evm_set_next_block_timestamp(init_timestamp).unwrap(); + + api.mine_one().await; + + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let next_blk_num = block.header.number; + let next_blk_timestamp = block.header.timestamp; + + assert_eq!(next_blk_num, init_number + 1); + assert_eq!(next_blk_timestamp, init_timestamp); + + // Sleep for 1 second + tokio::time::sleep(Duration::from_secs(1)).await; + + // Subsequent block should have a greater timestamp than previous block + api.mine_one().await; + + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let third_blk_num = block.header.number; + let third_blk_timestmap = block.header.timestamp; + + assert_eq!(third_blk_num, init_number + 2); + assert_ne!(third_blk_timestmap, next_blk_timestamp); + assert!(third_blk_timestmap > next_blk_timestamp); +} + +// increase time by 0 seconds i.e next_block_timestamp = prev_block_timestamp +// api.evm_increase_time(0).unwrap(); +#[tokio::test(flavor = "multi_thread")] +async fn test_increase_time_by_zero() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + let init_blk = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let init_number = init_blk.header.number; + let init_timestamp = init_blk.header.timestamp; + + let _ = api.evm_increase_time(U256::ZERO).await; + + api.mine_one().await; + + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let next_blk_num = block.header.number; + let next_blk_timestamp = block.header.timestamp; + + assert_eq!(next_blk_num, init_number + 1); + assert_eq!(next_blk_timestamp, init_timestamp); +} + +// evm_mine(MineOptions::Timestamp(prev_block_timestamp)) +#[tokio::test(flavor = "multi_thread")] +async fn evm_mine_blk_with_same_timestamp() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + let init_blk = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let init_number = init_blk.header.number; + let init_timestamp = init_blk.header.timestamp; + + api.evm_mine(Some(MineOptions::Timestamp(Some(init_timestamp)))).await.unwrap(); + + let block = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let next_blk_num = block.header.number; + let next_blk_timestamp = block.header.timestamp; + + assert_eq!(next_blk_num, init_number + 1); + assert_eq!(next_blk_timestamp, init_timestamp); +} + +// mine 4 blocks instantly. +#[tokio::test(flavor = "multi_thread")] +async fn test_mine_blks_with_same_timestamp() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + let init_blk = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + + let init_number = init_blk.header.number; + let init_timestamp = init_blk.header.timestamp; + + // Mine 4 blocks instantly + let _ = api.anvil_mine(Some(U256::from(4)), None).await; + + let latest_blk_num = api.block_number().unwrap().to::(); + + assert_eq!(latest_blk_num, init_number + 4); + + let mut blk_futs = vec![]; + for i in 1..=4 { + blk_futs.push(provider.get_block(i.into(), false.into())); + } + + let blks = futures::future::join_all(blk_futs) + .await + .into_iter() + .map(|blk| blk.unwrap().unwrap().header.timestamp) + .collect::>(); + + // timestamps should be equal + assert_eq!(blks, vec![init_timestamp; 4]); +} diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index d8df936b1e0a0..17e5f9bd4f923 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -897,7 +897,7 @@ async fn test_fork_block_timestamp() { api.anvil_mine(Some(U256::from(1)), None).await.unwrap(); let latest_block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); - assert!(initial_block.header.timestamp < latest_block.header.timestamp); + assert!(initial_block.header.timestamp <= latest_block.header.timestamp); } #[tokio::test(flavor = "multi_thread")] From 9252e98bd40aa709abf8a141ceee2bbd9ec2d2f2 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:55:24 +0300 Subject: [PATCH 1581/1963] chore: format chained error for EvmError (#9169) --- crates/evm/evm/src/executors/mod.rs | 12 +++++++++++- crates/forge/tests/cli/script.rs | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 5e2acc98f5d0c..723b520aa1b71 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -663,7 +663,7 @@ pub enum EvmError { Skip(SkipReason), /// Any other error. #[error(transparent)] - Eyre(#[from] eyre::Error), + Eyre(eyre::Error), } impl From for EvmError { @@ -678,6 +678,16 @@ impl From for EvmError { } } +impl From for EvmError { + fn from(err: eyre::Report) -> Self { + let mut chained_cause = String::new(); + for cause in err.chain() { + chained_cause.push_str(format!("{cause}; ").as_str()); + } + Self::Eyre(eyre::format_err!("{chained_cause}")) + } +} + /// The result of a deployment. #[derive(Debug)] pub struct DeployResult { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index dda45cf514fdd..62f606eebab3e 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2210,3 +2210,27 @@ Simulated On-chain Traces: ... "#]]); }); + +// Tests that chained errors are properly displayed. +// +forgetest_init!(should_display_evm_chained_error, |prj, cmd| { + let script = prj + .add_source( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract ContractScript is Script { + function run() public { + } +} + "#, + ) + .unwrap(); + cmd.arg("script").arg(script).args(["--fork-url", "https://public-node.testnet.rsk.co"]).assert_failure().stderr_eq(str![[r#" +Error: +Failed to deploy script: +backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set; + +"#]]); +}); From 3b2e57a2907657ba666034c2b6fd33dea8b6566c Mon Sep 17 00:00:00 2001 From: Piotr Heilman <1212808+piohei@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:38:38 +0200 Subject: [PATCH 1582/1963] Add debug file dump (#7375) * Refactored debugger to extract TUI abstraction. Added option to dump debugger context to file as json. * Update crates/forge/bin/cmd/test/mod.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/script/src/lib.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Cleanup code. * Added test. * Reformat code. * Reformat code. --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/cli/src/utils/cmd.rs | 2 +- crates/debugger/src/{tui => }/builder.rs | 2 +- crates/debugger/src/context.rs | 12 ++ crates/debugger/src/debugger.rs | 67 +++++++++ crates/debugger/src/file_dumper/mod.rs | 169 +++++++++++++++++++++++ crates/debugger/src/lib.rs | 12 +- crates/debugger/src/tui/context.rs | 23 +-- crates/debugger/src/tui/draw.rs | 8 +- crates/debugger/src/tui/mod.rs | 52 ++----- crates/forge/bin/cmd/debug.rs | 10 ++ crates/forge/bin/cmd/test/mod.rs | 15 +- crates/forge/tests/cli/test_cmd.rs | 20 +++ crates/script/src/execute.rs | 17 ++- crates/script/src/lib.rs | 15 +- 14 files changed, 355 insertions(+), 69 deletions(-) rename crates/debugger/src/{tui => }/builder.rs (99%) create mode 100644 crates/debugger/src/context.rs create mode 100644 crates/debugger/src/debugger.rs create mode 100644 crates/debugger/src/file_dumper/mod.rs diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 8a4bff7294101..4e289ba90e59b 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -410,7 +410,7 @@ pub async fn handle_traces( .decoder(&decoder) .sources(sources) .build(); - debugger.try_run()?; + debugger.try_run_tui()?; } else { print_traces(&mut result, &decoder, verbose).await?; } diff --git a/crates/debugger/src/tui/builder.rs b/crates/debugger/src/builder.rs similarity index 99% rename from crates/debugger/src/tui/builder.rs rename to crates/debugger/src/builder.rs index 484611c70e65c..fd2dce3dfe099 100644 --- a/crates/debugger/src/tui/builder.rs +++ b/crates/debugger/src/builder.rs @@ -1,4 +1,4 @@ -//! TUI debugger builder. +//! Debugger builder. use crate::{node::flatten_call_trace, DebugNode, Debugger}; use alloy_primitives::{map::AddressHashMap, Address}; diff --git a/crates/debugger/src/context.rs b/crates/debugger/src/context.rs new file mode 100644 index 0000000000000..1d89b549e82e3 --- /dev/null +++ b/crates/debugger/src/context.rs @@ -0,0 +1,12 @@ +use crate::DebugNode; +use alloy_primitives::map::AddressHashMap; +use foundry_common::evm::Breakpoints; +use foundry_evm_traces::debug::ContractSources; + +pub struct DebuggerContext { + pub debug_arena: Vec, + pub identified_contracts: AddressHashMap, + /// Source map of contract sources + pub contracts_sources: ContractSources, + pub breakpoints: Breakpoints, +} diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs new file mode 100644 index 0000000000000..723a4cb85f4f6 --- /dev/null +++ b/crates/debugger/src/debugger.rs @@ -0,0 +1,67 @@ +//! Debugger implementation. + +use crate::{ + context::DebuggerContext, tui::TUI, DebugNode, DebuggerBuilder, ExitReason, FileDumper, +}; +use alloy_primitives::map::AddressHashMap; +use eyre::Result; +use foundry_common::evm::Breakpoints; +use foundry_evm_traces::debug::ContractSources; +use std::path::PathBuf; + +pub struct Debugger { + context: DebuggerContext, +} + +impl Debugger { + /// Creates a new debugger builder. + #[inline] + pub fn builder() -> DebuggerBuilder { + DebuggerBuilder::new() + } + + /// Creates a new debugger. + pub fn new( + debug_arena: Vec, + identified_contracts: AddressHashMap, + contracts_sources: ContractSources, + breakpoints: Breakpoints, + ) -> Self { + Self { + context: DebuggerContext { + debug_arena, + identified_contracts, + contracts_sources, + breakpoints, + }, + } + } + + /// Starts the debugger TUI. Terminates the current process on failure or user exit. + pub fn run_tui_exit(mut self) -> ! { + let code = match self.try_run_tui() { + Ok(ExitReason::CharExit) => 0, + Err(e) => { + println!("{e}"); + 1 + } + }; + std::process::exit(code) + } + + /// Starts the debugger TUI. + pub fn try_run_tui(&mut self) -> Result { + eyre::ensure!(!self.context.debug_arena.is_empty(), "debug arena is empty"); + + let mut tui = TUI::new(&mut self.context); + tui.try_run() + } + + /// Dumps debugger data to file. + pub fn dump_to_file(&mut self, path: &PathBuf) -> Result<()> { + eyre::ensure!(!self.context.debug_arena.is_empty(), "debug arena is empty"); + + let mut file_dumper = FileDumper::new(path, &mut self.context); + file_dumper.run() + } +} diff --git a/crates/debugger/src/file_dumper/mod.rs b/crates/debugger/src/file_dumper/mod.rs new file mode 100644 index 0000000000000..969ad882f5931 --- /dev/null +++ b/crates/debugger/src/file_dumper/mod.rs @@ -0,0 +1,169 @@ +//! The file dumper implementation + +use crate::{context::DebuggerContext, DebugNode}; +use alloy_primitives::Address; +use eyre::Result; +use foundry_common::fs::write_json_file; +use foundry_compilers::{ + artifacts::sourcemap::{Jump, SourceElement}, + multi::MultiCompilerLanguage, +}; +use foundry_evm_traces::debug::{ArtifactData, ContractSources, SourceData}; +use serde::Serialize; +use std::{collections::HashMap, ops::Deref, path::PathBuf}; + +/// The file dumper +pub struct FileDumper<'a> { + path: &'a PathBuf, + debugger_context: &'a mut DebuggerContext, +} + +impl<'a> FileDumper<'a> { + pub fn new(path: &'a PathBuf, debugger_context: &'a mut DebuggerContext) -> Self { + Self { path, debugger_context } + } + + pub fn run(&mut self) -> Result<()> { + let data = DebuggerDump::from(self.debugger_context); + write_json_file(self.path, &data).unwrap(); + Ok(()) + } +} + +impl DebuggerDump { + fn from(debugger_context: &DebuggerContext) -> Self { + Self { + contracts: ContractsDump::new(debugger_context), + debug_arena: debugger_context.debug_arena.clone(), + } + } +} + +#[derive(Serialize)] +struct DebuggerDump { + contracts: ContractsDump, + debug_arena: Vec, +} + +#[derive(Serialize)] +pub struct SourceElementDump { + offset: u32, + length: u32, + index: i32, + jump: u32, + modifier_depth: u32, +} + +#[derive(Serialize)] +struct ContractsDump { + // Map of call address to contract name + identified_contracts: HashMap, + sources: ContractsSourcesDump, +} + +#[derive(Serialize)] +struct ContractsSourcesDump { + sources_by_id: HashMap>, + artifacts_by_name: HashMap>, +} + +#[derive(Serialize)] +struct SourceDataDump { + source: String, + language: MultiCompilerLanguage, + path: PathBuf, +} + +#[derive(Serialize)] +struct ArtifactDataDump { + pub source_map: Option>, + pub source_map_runtime: Option>, + pub pc_ic_map: Option>, + pub pc_ic_map_runtime: Option>, + pub build_id: String, + pub file_id: u32, +} + +impl ContractsDump { + pub fn new(debugger_context: &DebuggerContext) -> Self { + Self { + identified_contracts: debugger_context + .identified_contracts + .iter() + .map(|(k, v)| (*k, v.clone())) + .collect(), + sources: ContractsSourcesDump::new(&debugger_context.contracts_sources), + } + } +} + +impl ContractsSourcesDump { + pub fn new(contracts_sources: &ContractSources) -> Self { + Self { + sources_by_id: contracts_sources + .sources_by_id + .iter() + .map(|(name, inner_map)| { + ( + name.clone(), + inner_map + .iter() + .map(|(id, source_data)| (*id, SourceDataDump::new(source_data))) + .collect(), + ) + }) + .collect(), + artifacts_by_name: contracts_sources + .artifacts_by_name + .iter() + .map(|(name, data)| { + (name.clone(), data.iter().map(ArtifactDataDump::new).collect()) + }) + .collect(), + } + } +} + +impl SourceDataDump { + pub fn new(v: &SourceData) -> Self { + Self { source: v.source.deref().clone(), language: v.language, path: v.path.clone() } + } +} + +impl SourceElementDump { + pub fn new(v: &SourceElement) -> Self { + Self { + offset: v.offset(), + length: v.length(), + index: v.index_i32(), + jump: match v.jump() { + Jump::In => 0, + Jump::Out => 1, + Jump::Regular => 2, + }, + modifier_depth: v.modifier_depth(), + } + } +} + +impl ArtifactDataDump { + pub fn new(v: &ArtifactData) -> Self { + Self { + source_map: v + .source_map + .clone() + .map(|source_map| source_map.iter().map(SourceElementDump::new).collect()), + source_map_runtime: v + .source_map_runtime + .clone() + .map(|source_map| source_map.iter().map(SourceElementDump::new).collect()), + pc_ic_map: v.pc_ic_map.clone().map(|v| v.inner.iter().map(|(k, v)| (*k, *v)).collect()), + pc_ic_map_runtime: v + .pc_ic_map_runtime + .clone() + .map(|v| v.inner.iter().map(|(k, v)| (*k, *v)).collect()), + build_id: v.build_id.clone(), + file_id: v.file_id, + } + } +} diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 678ae8672d360..db8476e4056e7 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -1,6 +1,6 @@ //! # foundry-debugger //! -//! Interactive Solidity TUI debugger. +//! Interactive Solidity TUI debugger and debugger data file dumper #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] @@ -10,8 +10,16 @@ extern crate tracing; mod op; +mod builder; +mod context; +mod debugger; +mod file_dumper; mod tui; -pub use tui::{Debugger, DebuggerBuilder, ExitReason}; mod node; pub use node::DebugNode; + +pub use builder::DebuggerBuilder; +pub use debugger::Debugger; +pub use file_dumper::FileDumper; +pub use tui::{ExitReason, TUI}; diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index c3645e31b1533..80e16046c212e 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -1,6 +1,6 @@ //! Debugger context and event handler implementation. -use crate::{DebugNode, Debugger, ExitReason}; +use crate::{context::DebuggerContext, DebugNode, ExitReason}; use alloy_primitives::{hex, Address}; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; use foundry_evm_core::buffer::BufferKind; @@ -16,8 +16,8 @@ pub(crate) struct DrawMemory { pub(crate) current_stack_startline: usize, } -pub(crate) struct DebuggerContext<'a> { - pub(crate) debugger: &'a mut Debugger, +pub(crate) struct TUIContext<'a> { + pub(crate) debugger_context: &'a mut DebuggerContext, /// Buffer for keys prior to execution, i.e. '10' + 'k' => move up 10 operations. pub(crate) key_buffer: String, @@ -35,10 +35,10 @@ pub(crate) struct DebuggerContext<'a> { pub(crate) active_buffer: BufferKind, } -impl<'a> DebuggerContext<'a> { - pub(crate) fn new(debugger: &'a mut Debugger) -> Self { - DebuggerContext { - debugger, +impl<'a> TUIContext<'a> { + pub(crate) fn new(debugger_context: &'a mut DebuggerContext) -> Self { + TUIContext { + debugger_context, key_buffer: String::with_capacity(64), current_step: 0, @@ -58,7 +58,7 @@ impl<'a> DebuggerContext<'a> { } pub(crate) fn debug_arena(&self) -> &[DebugNode] { - &self.debugger.debug_arena + &self.debugger_context.debug_arena } pub(crate) fn debug_call(&self) -> &DebugNode { @@ -87,7 +87,8 @@ impl<'a> DebuggerContext<'a> { fn gen_opcode_list(&mut self) { self.opcode_list.clear(); - let debug_steps = &self.debugger.debug_arena[self.draw_memory.inner_call_index].steps; + let debug_steps = + &self.debugger_context.debug_arena[self.draw_memory.inner_call_index].steps; for step in debug_steps { self.opcode_list.push(pretty_opcode(step)); } @@ -109,7 +110,7 @@ impl<'a> DebuggerContext<'a> { } } -impl DebuggerContext<'_> { +impl TUIContext<'_> { pub(crate) fn handle_event(&mut self, event: Event) -> ControlFlow { let ret = match event { Event::Key(event) => self.handle_key_event(event), @@ -259,7 +260,7 @@ impl DebuggerContext<'_> { fn handle_breakpoint(&mut self, c: char) { // Find the location of the called breakpoint in the whole debug arena (at this address with // this pc) - if let Some((caller, pc)) = self.debugger.breakpoints.get(&c) { + if let Some((caller, pc)) = self.debugger_context.breakpoints.get(&c) { for (i, node) in self.debug_arena().iter().enumerate() { if node.address == *caller { if let Some(step) = node.steps.iter().position(|step| step.pc == *pc) { diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 55e4834f58d8b..18b58927966d0 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -1,6 +1,6 @@ //! TUI draw implementation. -use super::context::DebuggerContext; +use super::context::TUIContext; use crate::op::OpcodeParam; use foundry_compilers::artifacts::sourcemap::SourceElement; use foundry_evm_core::buffer::{get_buffer_accesses, BufferKind}; @@ -15,7 +15,7 @@ use ratatui::{ use revm_inspectors::tracing::types::CallKind; use std::{collections::VecDeque, fmt::Write, io}; -impl DebuggerContext<'_> { +impl TUIContext<'_> { /// Draws the TUI layout and subcomponents to the given terminal. pub(crate) fn draw(&self, terminal: &mut super::DebuggerTerminal) -> io::Result<()> { terminal.draw(|f| self.draw_layout(f)).map(drop) @@ -343,11 +343,11 @@ impl DebuggerContext<'_> { /// Returns source map, source code and source name of the current line. fn src_map(&self) -> Result<(SourceElement, &SourceData), String> { let address = self.address(); - let Some(contract_name) = self.debugger.identified_contracts.get(address) else { + let Some(contract_name) = self.debugger_context.identified_contracts.get(address) else { return Err(format!("Unknown contract at address {address}")); }; - self.debugger + self.debugger_context .contracts_sources .find_source_mapping( contract_name, diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 75b747a7ed02e..69ec0c201a06a 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -1,14 +1,11 @@ //! The TUI implementation. -use alloy_primitives::map::AddressHashMap; use crossterm::{ event::{self, DisableMouseCapture, EnableMouseCapture, Event}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; use eyre::Result; -use foundry_common::evm::Breakpoints; -use foundry_evm_traces::debug::ContractSources; use ratatui::{ backend::{Backend, CrosstermBackend}, Terminal, @@ -21,13 +18,9 @@ use std::{ time::{Duration, Instant}, }; -mod builder; -pub use builder::DebuggerBuilder; - mod context; -use context::DebuggerContext; - -use crate::DebugNode; +use crate::context::DebuggerContext; +use context::TUIContext; mod draw; @@ -41,47 +34,18 @@ pub enum ExitReason { } /// The TUI debugger. -pub struct Debugger { - debug_arena: Vec, - identified_contracts: AddressHashMap, - /// Source map of contract sources - contracts_sources: ContractSources, - breakpoints: Breakpoints, +pub struct TUI<'a> { + debugger_context: &'a mut DebuggerContext, } -impl Debugger { - /// Creates a new debugger builder. - #[inline] - pub fn builder() -> DebuggerBuilder { - DebuggerBuilder::new() - } - +impl<'a> TUI<'a> { /// Creates a new debugger. - pub fn new( - debug_arena: Vec, - identified_contracts: AddressHashMap, - contracts_sources: ContractSources, - breakpoints: Breakpoints, - ) -> Self { - Self { debug_arena, identified_contracts, contracts_sources, breakpoints } - } - - /// Starts the debugger TUI. Terminates the current process on failure or user exit. - pub fn run_exit(mut self) -> ! { - let code = match self.try_run() { - Ok(ExitReason::CharExit) => 0, - Err(e) => { - println!("{e}"); - 1 - } - }; - std::process::exit(code) + pub fn new(debugger_context: &'a mut DebuggerContext) -> Self { + Self { debugger_context } } /// Starts the debugger TUI. pub fn try_run(&mut self) -> Result { - eyre::ensure!(!self.debug_arena.is_empty(), "debug arena is empty"); - let backend = CrosstermBackend::new(io::stdout()); let terminal = Terminal::new(backend)?; TerminalGuard::with(terminal, |terminal| self.try_run_real(terminal)) @@ -90,7 +54,7 @@ impl Debugger { #[instrument(target = "debugger", name = "run", skip_all, ret)] fn try_run_real(&mut self, terminal: &mut DebuggerTerminal) -> Result { // Create the context. - let mut cx = DebuggerContext::new(self); + let mut cx = TUIContext::new(self.debugger_context); cx.init(); diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs index 8fe1d2e32a258..421478bd5762c 100644 --- a/crates/forge/bin/cmd/debug.rs +++ b/crates/forge/bin/cmd/debug.rs @@ -33,6 +33,15 @@ pub struct DebugArgs { #[arg(long)] pub debug: bool, + /// File path to dump execution details as JSON. + #[arg( + long, + requires = "debug", + value_hint = ValueHint::FilePath, + value_name = "PATH" + )] + pub dump: Option, + #[command(flatten)] pub opts: CoreBuildArgs, @@ -51,6 +60,7 @@ impl DebugArgs { opts: self.opts, evm_opts: self.evm_opts, debug: true, + dump: self.dump, retry: RETRY_VERIFY_ON_CREATE, ..Default::default() }; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 7038fc0b5a8b0..39f2b45557e3d 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -99,6 +99,15 @@ pub struct TestArgs { #[arg(long, value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] decode_internal: Option>, + /// Dumps all debugger steps to file. + #[arg( + long, + requires = "debug", + value_hint = ValueHint::FilePath, + value_name = "PATH" + )] + dump: Option, + /// Print a gas report. #[arg(long, env = "FORGE_GAS_REPORT")] gas_report: bool, @@ -453,7 +462,11 @@ impl TestArgs { } let mut debugger = builder.build(); - debugger.try_run()?; + if let Some(dump_path) = self.dump { + debugger.dump_to_file(&dump_path)?; + } else { + debugger.try_run_tui()?; + } } Ok(outcome) diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 4f812e79cf6ef..1c8ae36689db9 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2373,3 +2373,23 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); }); + +// Tests if dump of execution was created. +forgetest!(test_debug_with_dump, |prj, cmd| { + prj.add_source( + "dummy", + r" +contract Dummy { + function testDummy() public {} +} +", + ) + .unwrap(); + + let dump_path = prj.root().join("dump.json"); + + cmd.args(["test", "--debug", "testDummy", "--dump", dump_path.to_str().unwrap()]); + cmd.assert_success(); + + assert!(dump_path.exists()); +}); diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 4c2e893686ce1..d1191505a328d 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -34,6 +34,7 @@ use foundry_evm::{ }; use futures::future::join_all; use itertools::Itertools; +use std::path::PathBuf; use yansi::Paint; /// State after linking, contains the linked build data along with library addresses and optional @@ -495,7 +496,17 @@ impl PreSimulationState { } pub fn run_debugger(self) -> Result<()> { - let mut debugger = Debugger::builder() + self.create_debugger().try_run_tui()?; + Ok(()) + } + + pub fn run_debug_file_dumper(self, path: &PathBuf) -> Result<()> { + self.create_debugger().dump_to_file(path)?; + Ok(()) + } + + fn create_debugger(self) -> Debugger { + Debugger::builder() .traces( self.execution_result .traces @@ -506,8 +517,6 @@ impl PreSimulationState { .decoder(&self.execution_artifacts.decoder) .sources(self.build_data.sources) .breakpoints(self.execution_result.breakpoints) - .build(); - debugger.try_run()?; - Ok(()) + .build() } } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index af44f2062802d..49650584fd712 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -51,6 +51,7 @@ use foundry_evm::{ }; use foundry_wallets::MultiWalletOpts; use serde::Serialize; +use std::path::PathBuf; use yansi::Paint; mod broadcast; @@ -149,6 +150,15 @@ pub struct ScriptArgs { #[arg(long)] pub debug: bool, + /// Dumps all debugger steps to file. + #[arg( + long, + requires = "debug", + value_hint = ValueHint::FilePath, + value_name = "PATH" + )] + pub dump: Option, + /// Makes sure a transaction is sent, /// only after its previous one has been confirmed and succeeded. #[arg(long)] @@ -244,7 +254,10 @@ impl ScriptArgs { .await?; if pre_simulation.args.debug { - return pre_simulation.run_debugger() + return match pre_simulation.args.dump.clone() { + Some(ref path) => pre_simulation.run_debug_file_dumper(path), + None => pre_simulation.run_debugger(), + } } if pre_simulation.args.json { From 7b118faeff4848be480f9c30c11237b9e9e6eb31 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:18:16 +0530 Subject: [PATCH 1583/1963] chore(deps): bumps alloy, revm, fork-db (#9150) * chore(deps): bump alloy, revm, fork-db * fix: chain_id u64 * use SpecId::Osaka in place of PragueEOF * fix(`anvil`): test state files - tackle alloy breaking change https://github.com/alloy-rs/alloy/pull/1486 * fix test * minify state json --- Cargo.lock | 309 ++++++++++-------- Cargo.toml | 54 +-- crates/anvil/core/src/eth/block.rs | 10 +- crates/anvil/core/src/eth/transaction/mod.rs | 26 +- crates/anvil/src/eth/backend/db.rs | 54 +++ crates/anvil/src/eth/backend/mem/mod.rs | 5 +- crates/anvil/src/hardfork.rs | 3 +- .../test-data/state-dump-legacy-stress.json | 2 +- crates/anvil/test-data/state-dump-legacy.json | 2 +- crates/anvil/test-data/state-dump.json | 2 +- crates/anvil/tests/it/eip7702.rs | 4 +- crates/anvil/tests/it/optimism.rs | 8 +- crates/anvil/tests/it/traces.rs | 2 +- crates/cast/bin/cmd/wallet/mod.rs | 4 +- crates/cast/bin/tx.rs | 9 +- crates/cast/src/lib.rs | 6 +- crates/cheatcodes/src/inspector.rs | 2 +- crates/common/fmt/Cargo.toml | 1 + crates/common/fmt/src/ui.rs | 4 +- .../common/src/provider/runtime_transport.rs | 2 +- crates/common/src/transactions.rs | 6 +- crates/config/src/utils.rs | 4 +- crates/script/src/receipts.rs | 2 +- 23 files changed, 316 insertions(+), 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f88eeb08629cc..42c763b6229f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705687d5bfd019fee57cf9e206b27b30a9a9617535d5590a02b171e813208f8e" +checksum = "42642aed67f938363d9c7543e5ca4163cfb4205d9ec15fe933dc4e865d2932dd" dependencies = [ "alloy-eips", "alloy-primitives", @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917f7d12cf3971dc8c11c9972f732b35ccb9aaaf5f28f2f87e9e6523bee3a8ad" +checksum = "694f433e4105c2c5302e4c97f0fa408fa9058bd4bbf19398c0506a46ed3df255" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea59dc42102bc9a1905dc57901edc6dd48b9f38115df86c7d252acba70d71d04" +checksum = "eeffd2590ce780ddfaa9d0ae340eb2b4e08627650c4676eef537cef0b4bf535d" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -171,9 +171,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ffb906284a1e1f63c4607da2068c8197458a352d0b3e9796e67353d72a9be85" +checksum = "9fbc52a30df46f9831ed74557dfad0d94b12420393662a8b9ef90e2d6c8cb4b0" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -189,9 +189,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8429cf4554eed9b40feec7f4451113e76596086447550275e3def933faf47ce3" +checksum = "0787d1688b9806290313cc335d416cc7ee39b11e3245f3d218544c62572d92ba" dependencies = [ "alloy-primitives", "alloy-serde", @@ -212,9 +212,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fa8a1a3c4cbd221f2b8e3693aeb328fca79a757fe556ed08e47bbbc2a70db7" +checksum = "d55a16a5f9ca498a217c060414bcd1c43e934235dc8058b31b87dcd69ff4f105" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -226,9 +226,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85fa23a6a9d612b52e402c995f2d582c25165ec03ac6edf64c861a76bc5b87cd" +checksum = "3d236a8c3e1d5adc09b1b63c81815fc9b757d9a4ba9482cc899f9679b55dd437" dependencies = [ "alloy-consensus", "alloy-eips", @@ -247,9 +247,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "801492711d4392b2ccf5fc0bc69e299fa1aab15167d74dcaa9aab96a54f684bd" +checksum = "cd15a0990fa8a56d85a42d6a689719aa4eebf5e2f1a5c5354658c0bfc52cac9a" dependencies = [ "alloy-consensus", "alloy-eips", @@ -292,9 +292,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcfaa4ffec0af04e3555686b8aacbcdf7d13638133a0672749209069750f78a6" +checksum = "316f522bb6f9ac3805132112197957013b570e20cfdad058e8339dae6030c849" dependencies = [ "alloy-chains", "alloy-consensus", @@ -319,21 +319,24 @@ dependencies = [ "futures", "futures-utils-wasm", "lru", + "parking_lot", "pin-project 1.1.6", "reqwest", + "schnellru", "serde", "serde_json", "thiserror", "tokio", "tracing", "url", + "wasmtimer", ] [[package]] name = "alloy-pubsub" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f32cef487122ae75c91eb50154c70801d71fabdb976fec6c49e0af5e6486ab15" +checksum = "222cd9b17b1c5ad48de51a88ffbdb17f17145170288f22662f80ac88739125e6" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -367,14 +370,14 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] name = "alloy-rpc-client" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "370143ed581aace6e663342d21d209c6b2e34ee6142f7d6675adb518deeaf0dc" +checksum = "5b2ab59712c594c9624aaa69e38e4d38f180cb569f1fa46cdaf8c21fd50793e5" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -393,13 +396,14 @@ dependencies = [ "tower 0.5.1", "tracing", "url", + "wasmtimer", ] [[package]] name = "alloy-rpc-types" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ffc534b7919e18f35e3aa1f507b6f3d9d92ec298463a9f6beaac112809d8d06" +checksum = "ba21284319e12d053baa204d438db6c1577aedd94c1298e4becefdac1f9cec87" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -413,9 +417,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d780adaa5d95b07ad92006b2feb68ecfa7e2015f7d5976ceaac4c906c73ebd07" +checksum = "ba40bea86c3102b9ed9b3be579e32e0b3e54e766248d873de5fc0437238c8df2" dependencies = [ "alloy-primitives", "alloy-serde", @@ -424,9 +428,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0285c4c09f838ab830048b780d7f4a4f460f309aa1194bb049843309524c64c" +checksum = "44848fced3b42260b9cb61f22102246636dfe5a2d0132f8d10a617df3cb1a74b" dependencies = [ "alloy-consensus", "alloy-eips", @@ -442,9 +446,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413f4aa3ccf2c3e4234a047c5fa4727916d7daf25a89f9b765df0ba09784fd87" +checksum = "35894711990019fafff0012b82b9176cbb744516eb2a9bbe6b8e5cae522163ee" dependencies = [ "alloy-consensus", "alloy-eips", @@ -461,9 +465,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "017cad3e5793c5613588c1f9732bcbad77e820ba7d0feaba3527749f856fdbc5" +checksum = "f568c5624881896d8a25e19acbdcbabadd8df339427ea2f10b2ee447d57c4509" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -475,9 +479,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b230e321c416be7f50530159392b4c41a45596d40d97e185575bcd0b545e521" +checksum = "d4a37d2e1ed9b7daf20ad0b3e0092613cbae46737e0e988b23caa556c7067ce6" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -487,9 +491,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dff0ab1cdd43ca001e324dc27ee0e8606bd2161d6623c63e0e0b8c4dfc13600" +checksum = "2843c195675f06b29c09a4315cccdc233ab5bdc7c0a3775909f9f0cab5e9ae0f" dependencies = [ "alloy-primitives", "serde", @@ -498,9 +502,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd4e0ad79c81a27ca659be5d176ca12399141659fef2bcbfdc848da478f4504" +checksum = "88b2a00d9803dfef99963303ffe41a7bf2221f3342f0a503d6741a9f4a18e5e5" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -514,9 +518,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "417e19d9844350d11f7426d4920a5df777f8c2abbb7a70d9de6f1faf284db15b" +checksum = "d3de340e1b464a8f03ea6184a55d5eac34c5254ab575416d5e86f5a713dad7f7" dependencies = [ "alloy-consensus", "alloy-network", @@ -532,9 +536,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fd12ae28e8330766821058ed9a6a06ae4f9b12c776e8a7cfb16e3a954f508e" +checksum = "265d3ed0f67fcbb6e4ed4554e121a7d5e63fecf0e3827286179f6f0a264e85a1" dependencies = [ "alloy-consensus", "alloy-network", @@ -550,9 +554,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a02400dea370022151f07581b73a836115c88ce4df350206653493bec024e2" +checksum = "56224c04ef8eaf3aae77efa9079bfc202da6b8ecf5eb383748989ba122339e69" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -570,9 +574,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494e0a256f3e99f2426f994bcd1be312c02cb8f88260088dacb33a8b8936475f" +checksum = "5a2505d4f8c98dcae86152d58d549cb4bcf953f8352fca903410e0a0ef535571" dependencies = [ "alloy-consensus", "alloy-network", @@ -589,9 +593,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d91ddee2390b002148128e47902893deba353eb1b818a3afb6c960ebf4e42c" +checksum = "f11fac0c64b48c15187bc8dc3e633f8bc90bddd7e826dd745fcc1b2241c4b4be" dependencies = [ "alloy-consensus", "alloy-network", @@ -615,7 +619,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -632,7 +636,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", "syn-solidity", "tiny-keccak", ] @@ -650,7 +654,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.80", + "syn 2.0.82", "syn-solidity", ] @@ -679,9 +683,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac3e97dad3d31770db0fc89bd6a63b789fbae78963086733f960cf32c483904" +checksum = "9dc2c8f6b8c227ef0398f702d954c4ab572c2ead3c1ed4a5157aa1cbaf959747" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -694,13 +698,14 @@ dependencies = [ "tower 0.5.1", "tracing", "url", + "wasmtimer", ] [[package]] name = "alloy-transport-http" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b367dcccada5b28987c2296717ee04b9a5637aacd78eacb1726ef211678b5212" +checksum = "dd328e990d57f4c4e63899fb2c26877597d6503f8e0022a3d71b2d753ecbfc0c" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -713,9 +718,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b90cf9cde7f2fce617da52768ee28f522264b282d148384a4ca0ea85af04fa3a" +checksum = "89aea26aaf1d67904a7ff95ec4a24ddd5e7d419a6945f641b885962d7c2803e2" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -734,9 +739,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7153b88690de6a50bba81c11e1d706bc41dbb90126d607404d60b763f6a3947f" +checksum = "e222e950ecc4ea12fbfb524b9a2275cac2cd5f57c8ce25bcaf1bd3ff80dd8fc8" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1130,9 +1135,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "103db485efc3e41214fe4fda9f3dbeae2eb9082f48fd236e6095627a9422066e" +checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" dependencies = [ "flate2", "futures-core", @@ -1158,7 +1163,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -1180,7 +1185,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -1191,7 +1196,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -1244,7 +1249,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -1776,7 +1781,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2157,7 +2162,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2575,7 +2580,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2586,7 +2591,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2659,7 +2664,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2680,7 +2685,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2690,7 +2695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2701,7 +2706,7 @@ checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2722,7 +2727,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", "unicode-xid", ] @@ -2830,7 +2835,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2855,7 +2860,7 @@ checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -2982,7 +2987,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -3117,7 +3122,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.80", + "syn 2.0.82", "toml 0.8.19", "walkdir", ] @@ -3145,7 +3150,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.80", + "syn 2.0.82", "tempfile", "thiserror", "tiny-keccak", @@ -3533,7 +3538,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -3743,6 +3748,7 @@ version = "0.2.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", + "alloy-network", "alloy-primitives", "alloy-rpc-types", "alloy-serde", @@ -4062,9 +4068,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c8bdd63ecf8309c549d41a6167510da5053b13e9ab5456f06aff1070c0b642f" +checksum = "32c2d2bb411d4d88d6c84ff412a5182113d8e0b3d00363997a9b1f82a2e53d08" dependencies = [ "alloy-primitives", "alloy-provider", @@ -4100,7 +4106,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -4259,7 +4265,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -4690,6 +4696,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" + [[package]] name = "hashbrown" version = "0.14.5" @@ -4782,7 +4794,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -5215,7 +5227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -5679,7 +5691,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -5770,7 +5782,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6029,7 +6041,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6077,9 +6089,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.3.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f7f318f885db6e1455370ca91f74b7faed152c8142f6418f0936d606e582ff" +checksum = "99d49163f952491820088dd0e66f3a35d63337c3066eceff0a931bf83a8e2101" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6093,9 +6105,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.3.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "547d29c5ab957ff32e14edddb93652dad748d2ef6cbe4b0fe8615ce06b0a3ddb" +checksum = "9c9556293835232b019ec9c6fd84e4265a3151111af60ea09b5b513e3dbed41c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6168,7 +6180,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6331,7 +6343,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6390,7 +6402,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6474,7 +6486,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6532,7 +6544,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6618,12 +6630,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904afd36257cdb6ce0bee88b7981847bd7b955e5e216bb32f466b302923ad446" +checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" dependencies = [ "proc-macro2", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6701,7 +6713,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6721,7 +6733,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", "version_check", "yansi", ] @@ -6785,7 +6797,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -6808,7 +6820,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -7190,9 +7202,9 @@ dependencies = [ [[package]] name = "revm" -version = "14.0.3" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "641702b12847f9ed418d552f4fcabe536d867a2c980e96b6e7e25d7b992f929f" +checksum = "34e44692d5736cc44c697a372e507890f8797f06d1541c5f4b9bec594d90fd8a" dependencies = [ "auto_impl", "cfg-if", @@ -7205,9 +7217,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43c44af0bf801f48d25f7baf25cf72aff4c02d610f83b428175228162fef0246" +checksum = "a64e2246ad480167548724eb9c9c66945241b867c7d50894de3ca860c9823a45" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -7223,9 +7235,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "10.0.3" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5e14002afae20b5bf1566f22316122f42f57517000e559c55b25bf7a49cba2" +checksum = "6f89940d17d5d077570de1977f52f69049595322e237cb6c754c3d47f668f023" dependencies = [ "revm-primitives", "serde", @@ -7233,9 +7245,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "11.0.3" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3198c06247e8d4ad0d1312591edf049b0de4ddffa9fecb625c318fd67db8639b" +checksum = "d8f816aaea3245cbdbe7fdd84955df33597f9322c7912c3e3ba7bc855e03211f" dependencies = [ "aurora-engine-modexp", "blst", @@ -7253,9 +7265,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "10.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f1525851a03aff9a9d6a1d018b414d76252d6802ab54695b27093ecd7e7a101" +checksum = "532411bbde45a46707c1d434dcdc29866cf261c1b748fb01b303ce3b4310b361" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -7684,7 +7696,18 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.80", + "syn 2.0.82", +] + +[[package]] +name = "schnellru" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" +dependencies = [ + "ahash", + "cfg-if", + "hashbrown 0.13.2", ] [[package]] @@ -7846,7 +7869,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -7857,7 +7880,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -7901,7 +7924,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -7947,7 +7970,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -8309,7 +8332,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -8377,9 +8400,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.80" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e185e337f816bc8da115b8afcb3324006ccc82eeaddf35113888d3bd8e44ac" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -8395,7 +8418,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -8511,7 +8534,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -8636,7 +8659,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -8911,7 +8934,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -9314,7 +9337,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", "wasm-bindgen-shared", ] @@ -9348,7 +9371,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9372,6 +9395,20 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasmtimer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7ed9d8b15c7fb594d72bfb4b5a276f3d2029333cd93a932f376f5937f6f80ee" +dependencies = [ + "futures", + "js-sys", + "parking_lot", + "pin-utils", + "slab", + "wasm-bindgen", +] + [[package]] name = "watchexec" version = "4.1.0" @@ -9565,7 +9602,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -9576,7 +9613,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -9587,7 +9624,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -9598,7 +9635,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -9864,7 +9901,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] @@ -9884,7 +9921,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.80", + "syn 2.0.82", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 27fd23f20cf7a..a273b4a1bbecf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,39 +170,39 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } foundry-compilers = { version = "0.11.6", default-features = false } -foundry-fork-db = "0.4.0" +foundry-fork-db = "0.5.0" solang-parser = "=0.3.3" ## revm -revm = { version = "14.0.3", default-features = false } -revm-primitives = { version = "10.0.0", default-features = false } -revm-inspectors = { version = "0.8.0", features = ["serde"] } +revm = { version = "16.0.0", default-features = false } +revm-primitives = { version = "12.0.0", default-features = false } +revm-inspectors = { version = "0.9.0", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.4.2", default-features = false } -alloy-contract = { version = "0.4.2", default-features = false } -alloy-eips = { version = "0.4.2", default-features = false } -alloy-genesis = { version = "0.4.2", default-features = false } -alloy-json-rpc = { version = "0.4.2", default-features = false } -alloy-network = { version = "0.4.2", default-features = false } -alloy-provider = { version = "0.4.2", default-features = false } -alloy-pubsub = { version = "0.4.2", default-features = false } -alloy-rpc-client = { version = "0.4.2", default-features = false } -alloy-rpc-types = { version = "0.4.2", default-features = true } -alloy-serde = { version = "0.4.2", default-features = false } -alloy-signer = { version = "0.4.2", default-features = false } -alloy-signer-aws = { version = "0.4.2", default-features = false } -alloy-signer-gcp = { version = "0.4.2", default-features = false } -alloy-signer-ledger = { version = "0.4.2", default-features = false } -alloy-signer-local = { version = "0.4.2", default-features = false } -alloy-signer-trezor = { version = "0.4.2", default-features = false } -alloy-transport = { version = "0.4.2", default-features = false } -alloy-transport-http = { version = "0.4.2", default-features = false } -alloy-transport-ipc = { version = "0.4.2", default-features = false } -alloy-transport-ws = { version = "0.4.2", default-features = false } +alloy-consensus = { version = "0.5.2", default-features = false } +alloy-contract = { version = "0.5.2", default-features = false } +alloy-eips = { version = "0.5.2", default-features = false } +alloy-genesis = { version = "0.5.2", default-features = false } +alloy-json-rpc = { version = "0.5.2", default-features = false } +alloy-network = { version = "0.5.2", default-features = false } +alloy-provider = { version = "0.5.2", default-features = false } +alloy-pubsub = { version = "0.5.2", default-features = false } +alloy-rpc-client = { version = "0.5.2", default-features = false } +alloy-rpc-types = { version = "0.5.2", default-features = true } +alloy-serde = { version = "0.5.2", default-features = false } +alloy-signer = { version = "0.5.2", default-features = false } +alloy-signer-aws = { version = "0.5.2", default-features = false } +alloy-signer-gcp = { version = "0.5.2", default-features = false } +alloy-signer-ledger = { version = "0.5.2", default-features = false } +alloy-signer-local = { version = "0.5.2", default-features = false } +alloy-signer-trezor = { version = "0.5.2", default-features = false } +alloy-transport = { version = "0.5.2", default-features = false } +alloy-transport-http = { version = "0.5.2", default-features = false } +alloy-transport-ipc = { version = "0.5.2", default-features = false } +alloy-transport-ws = { version = "0.5.2", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.5" @@ -222,8 +222,8 @@ alloy-rlp = "0.3" alloy-trie = "0.6.0" ## op-alloy -op-alloy-rpc-types = "0.3.3" -op-alloy-consensus = "0.3.3" +op-alloy-rpc-types = "0.5.0" +op-alloy-consensus = "0.5.0" # macros proc-macro2 = "1.0.82" diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 337c5cfd8a57f..0dc386b01b1d6 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -72,7 +72,7 @@ impl Block { parent_beacon_block_root: partial_header.parent_beacon_block_root, nonce: partial_header.nonce, base_fee_per_gas: partial_header.base_fee, - requests_root: None, + requests_hash: None, }, transactions, ommers, @@ -160,7 +160,7 @@ mod tests { excess_blob_gas: Default::default(), parent_beacon_block_root: Default::default(), base_fee_per_gas: None, - requests_root: None, + requests_hash: None, }; let encoded = alloy_rlp::encode(&header); @@ -201,7 +201,7 @@ mod tests { parent_beacon_block_root: None, nonce: B64::ZERO, base_fee_per_gas: None, - requests_root: None, + requests_hash: None, }; header.encode(&mut data); @@ -234,7 +234,7 @@ mod tests { excess_blob_gas: None, parent_beacon_block_root: None, base_fee_per_gas: None, - requests_root: None, + requests_hash: None, }; let header = Header::decode(&mut data.as_slice()).unwrap(); assert_eq!(header, expected); @@ -266,7 +266,7 @@ mod tests { blob_gas_used: None, excess_blob_gas: None, parent_beacon_block_root: None, - requests_root: None, + requests_hash: None, }; assert_eq!(header.hash_slow(), expected_hash); } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index c3120792028ae..88e7f2765f329 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1637,7 +1637,6 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option Option TypedReceipt::Legacy(receipt_with_bloom), @@ -1896,4 +1894,28 @@ mod tests { assert_eq!(receipt, expected); } + + #[test] + fn deser_to_type_tx() { + let tx = r#" + { + "EIP1559": { + "chainId": "0x7a69", + "nonce": "0x0", + "gas": "0x5209", + "maxFeePerGas": "0x77359401", + "maxPriorityFeePerGas": "0x1", + "to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", + "value": "0x0", + "accessList": [], + "input": "0x", + "r": "0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0", + "s": "0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd", + "yParity": "0x0", + "hash": "0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515" + } + }"#; + + let _typed_tx: TypedTransaction = serde_json::from_str(tx).unwrap(); + } } diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 67ab27b9bbae6..174933c3490a2 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -559,3 +559,57 @@ impl IntoIterator for SerializableHistoricalStates { self.0.into_iter() } } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_deser_block() { + let block = r#"{ + "header": { + "parentHash": "0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929", + "ommersHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "beneficiary": "0x0000000000000000000000000000000000000000", + "stateRoot": "0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1", + "transactionsRoot": "0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988", + "receiptsRoot": "0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x0", + "number": "0x2", + "gasLimit": "0x1c9c380", + "gasUsed": "0x5208", + "timestamp": "0x66cdc823", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "baseFeePerGas": "0x342a1c58", + "blobGasUsed": "0x0", + "excessBlobGas": "0x0", + "extraData": "0x" + }, + "transactions": [ + { + "EIP1559": { + "chainId": "0x7a69", + "nonce": "0x0", + "gas": "0x5209", + "maxFeePerGas": "0x77359401", + "maxPriorityFeePerGas": "0x1", + "to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", + "value": "0x0", + "accessList": [], + "input": "0x", + "r": "0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0", + "s": "0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd", + "yParity": "0x0", + "hash": "0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515" + } + } + ], + "ommers": [] + } + "#; + + let _block: SerializableBlock = serde_json::from_str(block).unwrap(); + } +} diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0414b013cbdde..5300b717a3c1d 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1868,7 +1868,7 @@ impl Backend { gas_limit, gas_used, timestamp, - requests_root, + requests_hash, extra_data, mix_hash, nonce, @@ -1903,7 +1903,7 @@ impl Backend { blob_gas_used, excess_blob_gas, parent_beacon_block_root, - requests_root, + requests_hash, }, size: Some(size), transactions: alloy_rpc_types::BlockTransactions::Hashes( @@ -2415,7 +2415,6 @@ impl Backend { block_hash: Some(block_hash), from: info.from, to: info.to, - state_root: None, blob_gas_price: Some(blob_gas_price), blob_gas_used: blob_gas_used.map(|g| g as u128), authorization_list: None, diff --git a/crates/anvil/src/hardfork.rs b/crates/anvil/src/hardfork.rs index c8d2fdebccd46..2aedb7986e49b 100644 --- a/crates/anvil/src/hardfork.rs +++ b/crates/anvil/src/hardfork.rs @@ -135,7 +135,8 @@ impl From for SpecId { EthereumHardfork::Cancun | EthereumHardfork::Latest => Self::CANCUN, EthereumHardfork::Prague => Self::PRAGUE, // TODO: switch to latest after activation - EthereumHardfork::PragueEOF => Self::PRAGUE_EOF, + // EOF is included in OSAKA from Revm 16.0.0 + EthereumHardfork::PragueEOF => Self::OSAKA, } } } diff --git a/crates/anvil/test-data/state-dump-legacy-stress.json b/crates/anvil/test-data/state-dump-legacy-stress.json index dff50a670e35f..50df9e03906ef 100644 --- a/crates/anvil/test-data/state-dump-legacy-stress.json +++ b/crates/anvil/test-data/state-dump-legacy-stress.json @@ -1 +1 @@ -{"block":{"number":"0x5","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66b200cb","gas_limit":"0x1c9c380","basefee":"0x12e09c7a","difficulty":"0x0","prevrandao":"0xe7ef87fc7c2090741a6749a087e4ca8092cb4d07136008799e4ebeac3b69e34a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0x1088aa62285a00","code":"0x","storage":{}},"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd":{"nonce":1,"balance":"0x0","code":"0x6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x19ba1fac55eea44d12a01372a8eb0c2ebbf9ca21":{"nonce":1,"balance":"0x21e19df7c2963f0ac6b","code":"0x","storage":{}},"0x19c6ab860dbe2bc433574193a4409770a8748bf6":{"nonce":1,"balance":"0x21e19df8da6b7bdc410","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x40567ec443c1d1872af5155755ac3803cc3fe61e":{"nonce":1,"balance":"0x21e19da82562f921b40","code":"0x","storage":{}},"0x47d08dad17ccb558b3ea74b1a0e73a9cc804a9dc":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","storage":{"0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0x0"}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":2,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x8138ef7cf908021d117e542120b7a39065016107":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","storage":{}},"0x83a0444b93927c3afcbe46e522280390f748e171":{"nonce":1,"balance":"0x0","code":"0x6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c63430008110033","storage":{"0x5a648c35a2f5512218b4683cf10e03f5b7c9dc7346e1bf77d304ae97f60f592b":"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xc67e2bd3108604cf0168c0e5ef9cd6d78b9bb14b":{"nonce":1,"balance":"0x21e19c6edb7e2445f20","code":"0x","storage":{}},"0xeb045d78d273107348b0300c01d29b7552d622ab":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e08b86820a43ea","code":"0x","storage":{}}},"best_block_number":"0x5","blocks":[{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xcd346446ed010523161f40a5f2b512def549bfb79e165b4354488738416481f2","transactionsRoot":"0xb3a4689832e0b599260ae70362ffcf224b60571b35ff8836904a3d81e2675d66","receiptsRoot":"0x2d13fdc120ab90536fed583939de7fb68b64926a306c1f629593ca9c2c93b198","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x3ea90d","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x2e0b6260","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0x3ea90d","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b5061494f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xbc73db80bf4b8784ba10a8910a0b7ef85f6846d102b41dd990969ea205335354"}}],"ommers":[]},{"header":{"parentHash":"0x026ae0c6ae91f186a9befa1ac8be30eea35e30e77de51a731085221e5cd39209","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x6e4969a136061ca7a390d12830d47a151585325a8d396819fb2b958ff85e9f8f","receiptsRoot":"0xc3e81df67d3e2a6c8345a954ef250cfcc41abcc2292a5aa263071124533fc9ad","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x3c0f6","timestamp":"0x66b200ce","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x18993a68","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0x3c0f6","maxFeePerGas":"0x5d4285cd","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b50610380806100206000396000f3fe6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x2476e039803622aeb040f924f04c493f559aed3d6c9372ab405cb33c8c695328"}}],"ommers":[]},{"header":{"parentHash":"0x3d22100ac0ee8d5cde334f7f926191a861b0648971ebc179547df28a0224c6d0","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9511d4711e5c30a72b0bff38a261daa75dcc5ba8b772d970a5c742244b4c861b","transactionsRoot":"0xba5fff578d3d6c2cd63acbe9bca353eaa6fe22a5c408956eff49106e0a96c507","receiptsRoot":"0xbae111f01cb07677e3a8c5031546138407c01bc964d3493d732dc4edf47d36d3","logsBloom":"0x00000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000020000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000001000000000000000000000400000001000010000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x5","gasLimit":"0x1c9c380","gasUsed":"0xcae7","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x12e09c7a","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0xcc4d","maxFeePerGas":"0x557e5ec4","maxPriorityFeePerGas":"0x3b9aca00","to":"0x83a0444b93927c3afcbe46e522280390f748e171","value":"0x0","accessList":[],"input":"0x3659cfe6000000000000000000000000108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xf88e7b19ee347145c257e0cf7ac4ecc2bae83ca79d7edaa231e71d3213aeb151"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9c8eaf493f8b4edce2ba1647343eadcc0989cf461e712c0a6253ff2ca1842bb7","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xdd07c07470e1deff3749831f0f1ad8d4b6e35505e83b3c6ea14181716197cd8a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x24a1ab52","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200c9","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xf6930be4847cac5017bbcbec2756eed19f36b4196526a98a88e311c296e3a9be","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cc","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x200d75e8","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x4","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1592fbf9","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x149d41e3b89d8324cef3feff98ef308e97bafe8745cc8461c60172bc7d4c44ba","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x0b44110186e52ff0ceb6b0776ca2992c94144a4ed712eef65ea038260ef0fcc7","receiptsRoot":"0xc2823b8eb4730d9f2657137cc2ddc2c4f22ab68e0ab826236cf6a1551ca2b3a5","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0xe61f9","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342770c0","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0xe94d1","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060008061002661006d60201b61081b1760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610141565b60008060405160200161007f90610121565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b600061010b60238361009e565b9150610116826100af565b604082019050919050565b6000602082019050818103600083015261013a816100fe565b9050919050565b611000806101506000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x4feae6769d748b4f0f7c9bf21d782236c88f13906789a3ec602961296e4c3e43"}}],"ommers":[]},{"header":{"parentHash":"0xb3535af5103fd1c2bbd6dc7ff23f0799037a6542c231ebcb85abd776560fa512","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x23d74fb99ff6e42cbb5c33f92b078e37be6af2b6092459b103ff7059a6517ebc","transactionsRoot":"0x9eab45eca206fe11c107ea985c7d02fcfa442836aea3e04ba11dc4df587d5aa6","receiptsRoot":"0xe25abcfa973db8c55f73292137c626430de130a382ad4466337fefb0f7c8fde0","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x3ce3f","timestamp":"0x66b200cd","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1c0bc72b","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gasLimit":"0x3d8a8","maxFeePerGas":"0x6211577c","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060405161068538038061068583398181016040528101906100329190610275565b818181600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361009b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100ae8161019d60201b61004f1760201c565b6100ef57806040517f8a8b41ec0000000000000000000000000000000000000000000000000000000081526004016100e691906102c4565b60405180910390fd5b806100fe6101b060201b60201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050806101536101e160201b6100621760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050610414565b600080823b905060008111915050919050565b6000806040516020016101c290610362565b6040516020818303038152906040528051906020012090508091505090565b6000806040516020016101f3906103f4565b6040516020818303038152906040528051906020012090508091505090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061024282610217565b9050919050565b61025281610237565b811461025d57600080fd5b50565b60008151905061026f81610249565b92915050565b6000806040838503121561028c5761028b610212565b5b600061029a85828601610260565b92505060206102ab85828601610260565b9150509250929050565b6102be81610237565b82525050565b60006020820190506102d960008301846102b5565b92915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b600061034c6021836102df565b9150610357826102f0565b604082019050919050565b6000602082019050818103600083015261037b8161033f565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006103de6023836102df565b91506103e982610382565b604082019050919050565b6000602082019050818103600083015261040d816103d1565b9050919050565b610262806104236000396000f3fe6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c6343000811003300000000000000000000000047d08dad17ccb558b3ea74b1a0e73a9cc804a9dc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xb6794d5c7abed6f91d447e8efb72ef2580595a6d7c8dee57ba1dbb330970146a"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x29dd5614","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]}]} \ No newline at end of file +{"block":{"number":"0x5","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66b200cb","gas_limit":"0x1c9c380","basefee":"0x12e09c7a","difficulty":"0x0","prevrandao":"0xe7ef87fc7c2090741a6749a087e4ca8092cb4d07136008799e4ebeac3b69e34a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0x1088aa62285a00","code":"0x","storage":{}},"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd":{"nonce":1,"balance":"0x0","code":"0x6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x19ba1fac55eea44d12a01372a8eb0c2ebbf9ca21":{"nonce":1,"balance":"0x21e19df7c2963f0ac6b","code":"0x","storage":{}},"0x19c6ab860dbe2bc433574193a4409770a8748bf6":{"nonce":1,"balance":"0x21e19df8da6b7bdc410","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x40567ec443c1d1872af5155755ac3803cc3fe61e":{"nonce":1,"balance":"0x21e19da82562f921b40","code":"0x","storage":{}},"0x47d08dad17ccb558b3ea74b1a0e73a9cc804a9dc":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","storage":{"0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0x0"}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":2,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x8138ef7cf908021d117e542120b7a39065016107":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","storage":{}},"0x83a0444b93927c3afcbe46e522280390f748e171":{"nonce":1,"balance":"0x0","code":"0x6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c63430008110033","storage":{"0x5a648c35a2f5512218b4683cf10e03f5b7c9dc7346e1bf77d304ae97f60f592b":"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xc67e2bd3108604cf0168c0e5ef9cd6d78b9bb14b":{"nonce":1,"balance":"0x21e19c6edb7e2445f20","code":"0x","storage":{}},"0xeb045d78d273107348b0300c01d29b7552d622ab":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e08b86820a43ea","code":"0x","storage":{}}},"best_block_number":"0x5","blocks":[{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xcd346446ed010523161f40a5f2b512def549bfb79e165b4354488738416481f2","transactionsRoot":"0xb3a4689832e0b599260ae70362ffcf224b60571b35ff8836904a3d81e2675d66","receiptsRoot":"0x2d13fdc120ab90536fed583939de7fb68b64926a306c1f629593ca9c2c93b198","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x3ea90d","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x2e0b6260","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3ea90d","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b5061494f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xbc73db80bf4b8784ba10a8910a0b7ef85f6846d102b41dd990969ea205335354"}}],"ommers":[]},{"header":{"parentHash":"0x026ae0c6ae91f186a9befa1ac8be30eea35e30e77de51a731085221e5cd39209","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x6e4969a136061ca7a390d12830d47a151585325a8d396819fb2b958ff85e9f8f","receiptsRoot":"0xc3e81df67d3e2a6c8345a954ef250cfcc41abcc2292a5aa263071124533fc9ad","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x3c0f6","timestamp":"0x66b200ce","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x18993a68","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3c0f6","maxFeePerGas":"0x5d4285cd","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b50610380806100206000396000f3fe6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x2476e039803622aeb040f924f04c493f559aed3d6c9372ab405cb33c8c695328"}}],"ommers":[]},{"header":{"parentHash":"0x3d22100ac0ee8d5cde334f7f926191a861b0648971ebc179547df28a0224c6d0","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9511d4711e5c30a72b0bff38a261daa75dcc5ba8b772d970a5c742244b4c861b","transactionsRoot":"0xba5fff578d3d6c2cd63acbe9bca353eaa6fe22a5c408956eff49106e0a96c507","receiptsRoot":"0xbae111f01cb07677e3a8c5031546138407c01bc964d3493d732dc4edf47d36d3","logsBloom":"0x00000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000020000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000001000000000000000000000400000001000010000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x5","gasLimit":"0x1c9c380","gasUsed":"0xcae7","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x12e09c7a","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0xcc4d","maxFeePerGas":"0x557e5ec4","maxPriorityFeePerGas":"0x3b9aca00","to":"0x83a0444b93927c3afcbe46e522280390f748e171","value":"0x0","accessList":[],"input":"0x3659cfe6000000000000000000000000108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xf88e7b19ee347145c257e0cf7ac4ecc2bae83ca79d7edaa231e71d3213aeb151"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9c8eaf493f8b4edce2ba1647343eadcc0989cf461e712c0a6253ff2ca1842bb7","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xdd07c07470e1deff3749831f0f1ad8d4b6e35505e83b3c6ea14181716197cd8a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x24a1ab52","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200c9","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xf6930be4847cac5017bbcbec2756eed19f36b4196526a98a88e311c296e3a9be","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cc","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x200d75e8","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x4","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1592fbf9","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x149d41e3b89d8324cef3feff98ef308e97bafe8745cc8461c60172bc7d4c44ba","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x0b44110186e52ff0ceb6b0776ca2992c94144a4ed712eef65ea038260ef0fcc7","receiptsRoot":"0xc2823b8eb4730d9f2657137cc2ddc2c4f22ab68e0ab826236cf6a1551ca2b3a5","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0xe61f9","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342770c0","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0xe94d1","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060008061002661006d60201b61081b1760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610141565b60008060405160200161007f90610121565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b600061010b60238361009e565b9150610116826100af565b604082019050919050565b6000602082019050818103600083015261013a816100fe565b9050919050565b611000806101506000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x4feae6769d748b4f0f7c9bf21d782236c88f13906789a3ec602961296e4c3e43"}}],"ommers":[]},{"header":{"parentHash":"0xb3535af5103fd1c2bbd6dc7ff23f0799037a6542c231ebcb85abd776560fa512","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x23d74fb99ff6e42cbb5c33f92b078e37be6af2b6092459b103ff7059a6517ebc","transactionsRoot":"0x9eab45eca206fe11c107ea985c7d02fcfa442836aea3e04ba11dc4df587d5aa6","receiptsRoot":"0xe25abcfa973db8c55f73292137c626430de130a382ad4466337fefb0f7c8fde0","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x3ce3f","timestamp":"0x66b200cd","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1c0bc72b","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3d8a8","maxFeePerGas":"0x6211577c","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060405161068538038061068583398181016040528101906100329190610275565b818181600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361009b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100ae8161019d60201b61004f1760201c565b6100ef57806040517f8a8b41ec0000000000000000000000000000000000000000000000000000000081526004016100e691906102c4565b60405180910390fd5b806100fe6101b060201b60201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050806101536101e160201b6100621760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050610414565b600080823b905060008111915050919050565b6000806040516020016101c290610362565b6040516020818303038152906040528051906020012090508091505090565b6000806040516020016101f3906103f4565b6040516020818303038152906040528051906020012090508091505090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061024282610217565b9050919050565b61025281610237565b811461025d57600080fd5b50565b60008151905061026f81610249565b92915050565b6000806040838503121561028c5761028b610212565b5b600061029a85828601610260565b92505060206102ab85828601610260565b9150509250929050565b6102be81610237565b82525050565b60006020820190506102d960008301846102b5565b92915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b600061034c6021836102df565b9150610357826102f0565b604082019050919050565b6000602082019050818103600083015261037b8161033f565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006103de6023836102df565b91506103e982610382565b604082019050919050565b6000602082019050818103600083015261040d816103d1565b9050919050565b610262806104236000396000f3fe6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c6343000811003300000000000000000000000047d08dad17ccb558b3ea74b1a0e73a9cc804a9dc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xb6794d5c7abed6f91d447e8efb72ef2580595a6d7c8dee57ba1dbb330970146a"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x29dd5614","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]}]} \ No newline at end of file diff --git a/crates/anvil/test-data/state-dump-legacy.json b/crates/anvil/test-data/state-dump-legacy.json index 45906791db452..0641b2f7be911 100644 --- a/crates/anvil/test-data/state-dump-legacy.json +++ b/crates/anvil/test-data/state-dump-legacy.json @@ -1 +1 @@ -{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdc823","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xb92480171c0235f8c6710a4047d7ee14a3be58c630839fb4422826ff3a013e44","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc823","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}}],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdc80e","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xa00dc0c9ee9a888e67ea32d8772f8cc28eff62448c9ec985ee941fcbc921ba59","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc814","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}}],"ommers":[]}]} \ No newline at end of file +{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdc823","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xb92480171c0235f8c6710a4047d7ee14a3be58c630839fb4422826ff3a013e44","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc823","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}}],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdc80e","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xa00dc0c9ee9a888e67ea32d8772f8cc28eff62448c9ec985ee941fcbc921ba59","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc814","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}}],"ommers":[]}]} \ No newline at end of file diff --git a/crates/anvil/test-data/state-dump.json b/crates/anvil/test-data/state-dump.json index 159f30d21c407..3a3c478cfffef 100644 --- a/crates/anvil/test-data/state-dump.json +++ b/crates/anvil/test-data/state-dump.json @@ -1 +1 @@ -{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdcc2b","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xdb639d7f8af4f0ff2aa9cc49861820e72f5f8bfeeed677d1e3569f6b1625df4a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdcc25","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x3a52101c98a4319c419681131d3585d70a6cf13a9af25136be20d451eed5480a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc29","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}},"impersonated_sender":null}],"ommers":[]},{"header":{"parentHash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc2b","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gasLimit":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}},"impersonated_sender":null}],"ommers":[]}],"transactions":[{"info":{"transaction_hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3","transaction_index":0,"from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","block_number":1},{"info":{"transaction_hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515","transaction_index":0,"from":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","address":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x1f435a603c1bf6d544a90156b572b96d7a1730028422d800839bae78bb3506d0","block_number":2}]} \ No newline at end of file +{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdcc2b","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xdb639d7f8af4f0ff2aa9cc49861820e72f5f8bfeeed677d1e3569f6b1625df4a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdcc25","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x3a52101c98a4319c419681131d3585d70a6cf13a9af25136be20d451eed5480a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc29","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}},"impersonated_sender":null}],"ommers":[]},{"header":{"parentHash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc2b","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}},"impersonated_sender":null}],"ommers":[]}],"transactions":[{"info":{"transaction_hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3","transaction_index":0,"from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","block_number":1},{"info":{"transaction_hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515","transaction_index":0,"from":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","address":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x1f435a603c1bf6d544a90156b572b96d7a1730028422d800839bae78bb3506d0","block_number":2}]} \ No newline at end of file diff --git a/crates/anvil/tests/it/eip7702.rs b/crates/anvil/tests/it/eip7702.rs index 2a0cc0e43fb77..ab787e4ebc762 100644 --- a/crates/anvil/tests/it/eip7702.rs +++ b/crates/anvil/tests/it/eip7702.rs @@ -1,7 +1,7 @@ use crate::utils::http_provider; use alloy_consensus::{transaction::TxEip7702, SignableTransaction}; use alloy_network::{ReceiptResponse, TransactionBuilder, TxSignerSync}; -use alloy_primitives::{bytes, U256}; +use alloy_primitives::bytes; use alloy_provider::Provider; use alloy_rpc_types::{Authorization, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -44,7 +44,7 @@ async fn can_send_eip7702_tx() { let contract = receipt.contract_address.unwrap(); let authorization = Authorization { - chain_id: U256::from(31337u64), + chain_id: 31337u64, address: contract, nonce: provider.get_transaction_count(from).await.unwrap(), }; diff --git a/crates/anvil/tests/it/optimism.rs b/crates/anvil/tests/it/optimism.rs index 8de4eab1d1f4f..17246f0927d3b 100644 --- a/crates/anvil/tests/it/optimism.rs +++ b/crates/anvil/tests/it/optimism.rs @@ -9,7 +9,7 @@ use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; use anvil::{spawn, EthereumHardfork, NodeConfig}; use anvil_core::eth::transaction::optimism::DepositTransaction; -use op_alloy_rpc_types::OptimismTransactionFields; +use op_alloy_rpc_types::OpTransactionFields; #[tokio::test(flavor = "multi_thread")] async fn test_deposits_not_supported_if_optimism_disabled() { @@ -26,7 +26,7 @@ async fn test_deposits_not_supported_if_optimism_disabled() { .with_value(U256::from(1234)) .with_gas_limit(21000); - let op_fields = OptimismTransactionFields { + let op_fields = OpTransactionFields { source_hash: Some(b256!( "0000000000000000000000000000000000000000000000000000000000000000" )), @@ -63,7 +63,7 @@ async fn test_send_value_deposit_transaction() { let send_value = U256::from(1234); let before_balance_to = provider.get_balance(to).await.unwrap(); - let op_fields = OptimismTransactionFields { + let op_fields = OpTransactionFields { source_hash: Some(b256!( "0000000000000000000000000000000000000000000000000000000000000000" )), @@ -123,7 +123,7 @@ async fn test_send_value_raw_deposit_transaction() { .with_max_fee_per_gas(20_000_000_000) .with_max_priority_fee_per_gas(1_000_000_000); - let op_fields = OptimismTransactionFields { + let op_fields = OpTransactionFields { source_hash: Some(b256!( "0000000000000000000000000000000000000000000000000000000000000000" )), diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index aaa2ca298d142..e6fc2c39234d2 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -808,7 +808,7 @@ async fn test_trace_filter() { } let traces = api.trace_filter(tracer).await.unwrap(); - assert_eq!(traces.len(), 9); + assert_eq!(traces.len(), 3); // Test Range Error let latest = provider.get_block_number().await.unwrap(); diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 4664e66116878..51107c64958a8 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -7,7 +7,7 @@ use alloy_signer_local::{ coins_bip39::{English, Entropy, Mnemonic}, MnemonicBuilder, PrivateKeySigner, }; -use cast::revm::primitives::{Authorization, U256}; +use cast::revm::primitives::Authorization; use clap::Parser; use eyre::{Context, Result}; use foundry_cli::{opts::RpcOpts, utils}; @@ -390,7 +390,7 @@ impl WalletSubcommands { } else { provider.get_chain_id().await? }; - let auth = Authorization { chain_id: U256::from(chain_id), address, nonce }; + let auth = Authorization { chain_id, address, nonce }; let signature = wallet.sign_hash(&auth.signature_hash()).await?; let auth = auth.into_signed(signature); println!("{}", hex::encode_prefixed(alloy_rlp::encode(&auth))); diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 88b24a6e33c9e..a6f64b3db2d0b 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -3,7 +3,7 @@ use alloy_json_abi::Function; use alloy_network::{ AnyNetwork, TransactionBuilder, TransactionBuilder4844, TransactionBuilder7702, }; -use alloy_primitives::{hex, Address, Bytes, TxKind, U256}; +use alloy_primitives::{hex, Address, Bytes, TxKind}; use alloy_provider::Provider; use alloy_rpc_types::{AccessList, Authorization, TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -379,11 +379,8 @@ where let auth = match auth { CliAuthorizationList::Address(address) => { - let auth = Authorization { - chain_id: U256::from(self.chain.id()), - nonce: tx_nonce + 1, - address, - }; + let auth = + Authorization { chain_id: self.chain.id(), nonce: tx_nonce + 1, address }; let Some(signer) = sender.as_signer() else { eyre::bail!("No signer available to sign authorization"); diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 69f86268b3d0b..2dd56859eff60 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -279,7 +279,7 @@ where pub async fn send( &self, tx: WithOtherFields, - ) -> Result> { + ) -> Result> { let res = self.provider.send_transaction(tx).await?; Ok(res) @@ -305,7 +305,7 @@ where pub async fn publish( &self, mut raw_tx: String, - ) -> Result> { + ) -> Result> { raw_tx = match raw_tx.strip_prefix("0x") { Some(s) => s.to_string(), None => raw_tx, @@ -783,7 +783,7 @@ where if cast_async { eyre::bail!("tx not found: {:?}", tx_hash) } else { - PendingTransactionBuilder::new(self.provider.root(), tx_hash) + PendingTransactionBuilder::new(self.provider.root().clone(), tx_hash) .with_required_confirmations(confs) .with_timeout(timeout.map(Duration::from_secs)) .get_receipt() diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 7d91f5e203110..684f5eb110d2f 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -84,7 +84,7 @@ 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::PRAGUE_EOF) && + 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) { diff --git a/crates/common/fmt/Cargo.toml b/crates/common/fmt/Cargo.toml index fabe35a7a1a1d..9902de608f412 100644 --- a/crates/common/fmt/Cargo.toml +++ b/crates/common/fmt/Cargo.toml @@ -20,6 +20,7 @@ yansi.workspace = true # ui alloy-consensus.workspace = true +alloy-network.workspace = true alloy-rpc-types = { workspace = true, features = ["eth"] } alloy-serde.workspace = true serde.workspace = true diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index a82853145799b..4789c381da0aa 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -1,6 +1,7 @@ //! Helper trait and functions to format Ethereum types. use alloy_consensus::{AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom, TxType}; +use alloy_network::ReceiptResponse; use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, B256, I256, U256, U64}; use alloy_rpc_types::{ AccessListItem, AnyNetworkBlock, AnyTransactionReceipt, Block, BlockTransactions, Log, @@ -169,7 +170,6 @@ impl UIfmt for AnyTransactionReceipt { to, gas_used, contract_address, - state_root, effective_gas_price, inner: AnyReceiptEnvelope { @@ -215,7 +215,7 @@ authorizationList {}", gas_used.pretty(), serde_json::to_string(&logs).unwrap(), logs_bloom.pretty(), - state_root.pretty(), + self.state_root().pretty(), status.pretty(), transaction_hash.pretty(), transaction_index.pretty(), diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 8362b46d66055..a95969be5a406 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -187,7 +187,7 @@ impl RuntimeTransport { /// Connects to a WS transport. async fn connect_ws(&self) -> Result { let auth = self.jwt.as_ref().and_then(|jwt| build_auth(jwt.clone()).ok()); - let ws = WsConnect { url: self.url.to_string(), auth } + let ws = WsConnect { url: self.url.to_string(), auth, config: None } .into_service() .await .map_err(|e| RuntimeTransportError::TransportError(e, self.url.to_string()))?; diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 7335714e54806..4ddef26dd03f9 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -3,7 +3,7 @@ use alloy_consensus::{Transaction, TxEnvelope}; use alloy_primitives::{Address, TxKind, U256}; use alloy_provider::{ - network::{AnyNetwork, TransactionBuilder}, + network::{AnyNetwork, ReceiptResponse, TransactionBuilder}, Provider, }; use alloy_rpc_types::{AnyTransactionReceipt, BlockId, TransactionRequest}; @@ -122,7 +122,7 @@ pub fn get_pretty_tx_receipt_attr( "gasUsed" | "gas_used" => Some(receipt.receipt.gas_used.to_string()), "logs" => Some(receipt.receipt.inner.inner.inner.receipt.logs.as_slice().pretty()), "logsBloom" | "logs_bloom" => Some(receipt.receipt.inner.inner.inner.logs_bloom.pretty()), - "root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root.pretty()), + "root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root().pretty()), "status" | "statusCode" | "status_code" => { Some(receipt.receipt.inner.inner.inner.receipt.status.pretty()) } @@ -201,7 +201,7 @@ impl TransactionMaybeSigned { pub fn to(&self) -> Option { match self { - Self::Signed { tx, .. } => Some(tx.to()), + Self::Signed { tx, .. } => Some(tx.kind()), Self::Unsigned(tx) => tx.to, } } diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index b1434bc7a62c5..2117834f428a4 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -301,7 +301,7 @@ impl FromStr for Numeric { #[inline] pub fn evm_spec_id(evm_version: &EvmVersion, alphanet: bool) -> SpecId { if alphanet { - return SpecId::PRAGUE_EOF; + return SpecId::OSAKA; } match evm_version { EvmVersion::Homestead => SpecId::HOMESTEAD, @@ -316,7 +316,7 @@ pub fn evm_spec_id(evm_version: &EvmVersion, alphanet: bool) -> SpecId { EvmVersion::Paris => SpecId::MERGE, EvmVersion::Shanghai => SpecId::SHANGHAI, EvmVersion::Cancun => SpecId::CANCUN, - EvmVersion::Prague => SpecId::PRAGUE_EOF, + EvmVersion::Prague => SpecId::OSAKA, // Osaka enables EOF } } diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index c1dad562905f9..02ee75fa672ff 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -40,7 +40,7 @@ pub async fn check_tx_status( } loop { - if let Ok(receipt) = PendingTransactionBuilder::new(provider, hash) + if let Ok(receipt) = PendingTransactionBuilder::new(provider.clone(), hash) .with_timeout(Some(Duration::from_secs(timeout))) .get_receipt() .await From cd71da404df324f8a3851f9673e4686d2cd762ef Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:14:25 +0200 Subject: [PATCH 1584/1963] feat: add `foundry_common::shell` to unify log behavior (#9109) * replace existing shell::println, add macros * finish replacing shell::println * remove p_println * remove redundant quiet or silent variables * install global shells in binaries * CastArgs -> Cast, Cast -> CastInstance * fix tests, always initialize Mutex::new(Shell::new()) on initial access, for some reason cfg!(test) path is not handled when running with tokio tests * revert .quiet(true) * add back quiet * undo CastInstance -> Cast, Cast -> CastArgs * add global --json format * use global --json flag * revert sequence / multisequence save silent mode * fix failing tests * fix tests * fix tests * replace cli_warn with sh_warn * use shell json directly instead of passing in * clean up, document print modes in respect to --quiet flag * group shell options under display options * revert global --json flag * remove redundant import * fix: quiet * remove faulty argument conflict test as there is no way to currently assert a conflict between global and local args without custom reject at runtime * add back conflicts_with quiet flag, global args w/ conflicts_with works fine * remove yellow() * Apply suggestions from code review - update dependencies - use default Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * fix deprecated terminal_size method * revert quiet flag, fix os:fd import for windows * add replacing tests, add back quiet conflicting flag * make output windows compatible * to avoid visual regression, style warning message content in yellow, error message content in red - both not bold * fix docs links * fix junit throwing mixed content on warnings, avoid modifying global verbosity * remove set_verbosity shell helper, redundant * revert default .expect on printing, prefer passing. revert message style formatting - no longer style the message * fix doc test, fix formatting * fix merge issues --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 3 + Cargo.toml | 5 + clippy.toml | 8 + crates/anvil/src/anvil.rs | 16 +- crates/anvil/src/cmd.rs | 5 - crates/anvil/src/config.rs | 24 +- crates/anvil/src/lib.rs | 38 +- crates/anvil/tests/it/fork.rs | 8 +- crates/cast/bin/args.rs | 5 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/cmd/send.rs | 4 +- crates/cast/bin/main.rs | 16 +- crates/cast/tests/cli/main.rs | 40 +- crates/chisel/bin/main.rs | 15 +- crates/cli/src/lib.rs | 4 +- crates/cli/src/opts/build/core.rs | 5 - crates/cli/src/opts/mod.rs | 2 + crates/cli/src/opts/shell.rs | 39 ++ crates/cli/src/utils/cmd.rs | 18 +- crates/cli/src/utils/mod.rs | 24 +- crates/common/Cargo.toml | 4 + crates/common/fmt/Cargo.toml | 2 +- crates/common/src/compile.rs | 11 +- crates/common/src/io/macros.rs | 185 ++++++++ crates/common/src/io/mod.rs | 11 + crates/common/src/io/shell.rs | 518 +++++++++++++++++++++ crates/{cli/src => common/src/io}/stdin.rs | 32 +- crates/common/src/io/style.rs | 5 + crates/common/src/lib.rs | 5 +- crates/common/src/shell.rs | 307 ------------ crates/common/src/term.rs | 15 - crates/forge/bin/cmd/build.rs | 38 +- crates/forge/bin/cmd/clone.rs | 25 +- crates/forge/bin/cmd/config.rs | 6 +- crates/forge/bin/cmd/coverage.rs | 21 +- crates/forge/bin/cmd/create.rs | 3 +- crates/forge/bin/cmd/fmt.rs | 8 +- crates/forge/bin/cmd/init.rs | 17 +- crates/forge/bin/cmd/install.rs | 47 +- crates/forge/bin/cmd/snapshot.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 35 +- crates/forge/bin/main.rs | 37 +- crates/forge/bin/opts.rs | 4 + crates/forge/src/lib.rs | 3 + crates/forge/src/result.rs | 18 +- crates/forge/tests/cli/build.rs | 30 +- crates/forge/tests/cli/cmd.rs | 92 ++-- crates/forge/tests/cli/config.rs | 8 +- crates/forge/tests/cli/debug.rs | 11 +- crates/forge/tests/cli/script.rs | 91 ++-- crates/forge/tests/cli/test_cmd.rs | 11 +- crates/script-sequence/src/lib.rs | 3 + crates/script-sequence/src/sequence.rs | 6 +- crates/script/src/broadcast.rs | 6 +- crates/script/src/build.rs | 5 +- crates/script/src/execute.rs | 43 +- crates/script/src/lib.rs | 21 +- crates/script/src/multi_sequence.rs | 4 +- crates/script/src/simulate.rs | 34 +- crates/test-utils/src/script.rs | 8 +- crates/verify/src/bytecode.rs | 6 +- crates/verify/src/etherscan/mod.rs | 4 +- crates/verify/src/lib.rs | 9 +- 63 files changed, 1267 insertions(+), 765 deletions(-) create mode 100644 crates/cli/src/opts/shell.rs create mode 100644 crates/common/src/io/macros.rs create mode 100644 crates/common/src/io/mod.rs create mode 100644 crates/common/src/io/shell.rs rename crates/{cli/src => common/src/io}/stdin.rs (76%) create mode 100644 crates/common/src/io/style.rs delete mode 100644 crates/common/src/shell.rs diff --git a/Cargo.lock b/Cargo.lock index 42c763b6229f2..cae0781051577 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3717,6 +3717,8 @@ dependencies = [ "alloy-transport-http", "alloy-transport-ipc", "alloy-transport-ws", + "anstream", + "anstyle", "async-trait", "clap", "comfy-table", @@ -3733,6 +3735,7 @@ dependencies = [ "serde", "serde_json", "similar-asserts", + "terminal_size", "thiserror", "tokio", "tower 0.4.13", diff --git a/Cargo.toml b/Cargo.toml index a273b4a1bbecf..db0ad3de46928 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,6 +225,11 @@ alloy-trie = "0.6.0" op-alloy-rpc-types = "0.5.0" op-alloy-consensus = "0.5.0" +## cli +anstream = "0.6.15" +anstyle = "1.0.8" +terminal_size = "0.4" + # macros proc-macro2 = "1.0.82" quote = "1.0" diff --git a/clippy.toml b/clippy.toml index 92b35ffc0afc8..3e45486a86f4f 100644 --- a/clippy.toml +++ b/clippy.toml @@ -2,3 +2,11 @@ msrv = "1.80" # bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, # so it is safe to ignore it as well ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] + +# disallowed-macros = [ +# # See `foundry_common::shell` +# { path = "std::print", reason = "use `sh_print` or similar macros instead" }, +# { path = "std::eprint", reason = "use `sh_eprint` or similar macros instead" }, +# { path = "std::println", reason = "use `sh_println` or similar macros instead" }, +# { path = "std::eprintln", reason = "use `sh_eprintln` or similar macros instead" }, +# ] diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 38bbbbbd62e3a..9d4a0cf7ba200 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -2,7 +2,8 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; -use foundry_cli::utils; +use eyre::Result; +use foundry_cli::{opts::ShellOpts, utils}; #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] @@ -17,6 +18,9 @@ pub struct Anvil { #[command(subcommand)] pub cmd: Option, + + #[clap(flatten)] + pub shell: ShellOpts, } #[derive(Subcommand)] @@ -33,10 +37,18 @@ pub enum AnvilSubcommand { GenerateFigSpec, } -fn main() -> eyre::Result<()> { +fn main() { + if let Err(err) = run() { + let _ = foundry_common::Shell::get().error(&err); + std::process::exit(1); + } +} + +fn run() -> Result<()> { utils::load_dotenv(); let mut args = Anvil::parse(); + args.shell.shell().set(); args.node.evm_opts.resolve_rpc_alias(); if let Some(cmd) = &args.cmd { diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 13182686a3335..2121f5b64795f 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -72,10 +72,6 @@ pub struct NodeArgs { #[arg(long)] pub derivation_path: Option, - /// Don't print anything on startup and don't print logs - #[arg(long)] - pub silent: bool, - /// The EVM hardfork to use. /// /// Choose the hardfork by name, e.g. `shanghai`, `paris`, `london`, etc... @@ -258,7 +254,6 @@ impl NodeArgs { .with_storage_caching(self.evm_opts.no_storage_caching) .with_server_config(self.server_config) .with_host(self.host) - .set_silent(self.silent) .set_config_out(self.config_out) .with_chain_id(self.evm_opts.chain_id) .with_transaction_order(self.order) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 273dbad89ffd6..a54da25a3be9f 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -123,8 +123,6 @@ pub struct NodeConfig { pub port: u16, /// maximum number of transactions in a block pub max_transactions: usize, - /// don't print anything on startup - pub silent: bool, /// url of the rpc server that should be used for any rpc calls pub eth_rpc_url: Option, /// pins the block number or transaction hash for the state fork @@ -394,7 +392,7 @@ impl NodeConfig { /// random, free port by setting it to `0` #[doc(hidden)] pub fn test() -> Self { - Self { enable_tracing: true, silent: true, port: 0, ..Default::default() } + Self { enable_tracing: true, port: 0, ..Default::default() } } /// Returns a new config which does not initialize any accounts on node startup. @@ -429,7 +427,6 @@ impl Default for NodeConfig { port: NODE_PORT, // TODO make this something dependent on block capacity max_transactions: 1_000, - silent: false, eth_rpc_url: None, fork_choice: None, account_generator: None, @@ -732,18 +729,6 @@ impl NodeConfig { self } - /// Makes the node silent to not emit anything on stdout - #[must_use] - pub fn silent(self) -> Self { - self.set_silent(true) - } - - #[must_use] - pub fn set_silent(mut self, silent: bool) -> Self { - self.silent = silent; - self - } - /// Sets the ipc path to use /// /// Note: this is a double Option for @@ -763,7 +748,7 @@ impl NodeConfig { self } - /// Makes the node silent to not emit anything on stdout + /// Disables storage caching #[must_use] pub fn no_storage_caching(self) -> Self { self.with_storage_caching(true) @@ -921,11 +906,8 @@ impl NodeConfig { ) .expect("Failed writing json"); } - if self.silent { - return; - } - println!("{}", self.as_string(fork)) + let _ = sh_println!("{}", self.as_string(fork)); } /// Returns the path where the cache file should be stored diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index ee66caa672baa..11cb4473fad7b 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -1,9 +1,6 @@ #![doc = include_str!("../README.md")] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#[macro_use] -extern crate tracing; - use crate::{ eth::{ backend::{info::StorageInfo, mem}, @@ -23,7 +20,10 @@ use crate::{ use alloy_primitives::{Address, U256}; use alloy_signer_local::PrivateKeySigner; use eth::backend::fork::ClientFork; -use foundry_common::provider::{ProviderBuilder, RetryProvider}; +use foundry_common::{ + provider::{ProviderBuilder, RetryProvider}, + shell, +}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; use parking_lot::Mutex; @@ -74,6 +74,12 @@ mod tasks; #[cfg(feature = "cmd")] pub mod cmd; +#[macro_use] +extern crate foundry_common; + +#[macro_use] +extern crate tracing; + /// Creates the node and runs the server. /// /// Returns the [EthApi] that can be used to interact with the node and the [JoinHandle] of the @@ -125,7 +131,7 @@ pub async fn spawn(config: NodeConfig) -> (EthApi, NodeHandle) { /// ``` pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle)> { let logger = if config.enable_tracing { init_tracing() } else { Default::default() }; - logger.set_enabled(!config.silent); + logger.set_enabled(!shell::is_quiet()); let backend = Arc::new(config.setup().await); @@ -292,19 +298,17 @@ impl NodeHandle { /// Prints the launch info. pub(crate) fn print(&self, fork: Option<&ClientFork>) { self.config.print(fork); - if !self.config.silent { - if let Some(ipc_path) = self.ipc_path() { - println!("IPC path: {ipc_path}"); - } - println!( - "Listening on {}", - self.addresses - .iter() - .map(|addr| { addr.to_string() }) - .collect::>() - .join(", ") - ); + if let Some(ipc_path) = self.ipc_path() { + let _ = sh_println!("IPC path: {ipc_path}"); } + let _ = sh_println!( + "Listening on {}", + self.addresses + .iter() + .map(|addr| { addr.to_string() }) + .collect::>() + .join(", ") + ); } /// The address of the launched server. diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 17e5f9bd4f923..a35d7c267d625 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -57,7 +57,6 @@ pub fn fork_config() -> NodeConfig { NodeConfig::test() .with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())) .with_fork_block_number(Some(BLOCK_NUMBER)) - .silent() } #[tokio::test(flavor = "multi_thread")] @@ -829,10 +828,9 @@ async fn test_fork_init_base_fee() { #[tokio::test(flavor = "multi_thread")] async fn test_reset_fork_on_new_blocks() { - let (api, handle) = spawn( - NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())).silent(), - ) - .await; + let (api, handle) = + spawn(NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint()))) + .await; let anvil_provider = handle.http_provider(); let endpoint = next_http_rpc_endpoint(); diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index fdb6a113354a2..e4c8dcb4cda56 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -8,7 +8,7 @@ use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types::BlockId; use clap::{Parser, Subcommand, ValueHint}; use eyre::Result; -use foundry_cli::opts::{EtherscanOpts, RpcOpts}; +use foundry_cli::opts::{EtherscanOpts, RpcOpts, ShellOpts}; use foundry_common::ens::NameOrAddress; use std::{path::PathBuf, str::FromStr}; @@ -32,6 +32,9 @@ const VERSION_MESSAGE: &str = concat!( pub struct Cast { #[command(subcommand)] pub cmd: CastSubcommand, + + #[clap(flatten)] + pub shell: ShellOpts, } #[derive(Subcommand)] diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 9d04ed1e2c1fd..5eb6a490da796 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -45,7 +45,7 @@ pub struct RunArgs { /// Executes the transaction only with the state from the previous block. /// /// May result in different results than the live execution! - #[arg(long, short)] + #[arg(long)] quick: bool, /// Prints the full address of the contract. diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index cf3582fe03a6a..c8c0faf596230 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -12,7 +12,7 @@ use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils, }; -use foundry_common::{cli_warn, ens::NameOrAddress}; +use foundry_common::ens::NameOrAddress; use foundry_config::Config; use std::{path::PathBuf, str::FromStr}; @@ -145,7 +145,7 @@ impl SendTxArgs { // switch chain if current chain id is not the same as the one specified in the // config if config_chain_id != current_chain_id { - cli_warn!("Switching to chain {}", config_chain); + sh_warn!("Switching to chain {}", config_chain)?; provider .raw_request( "wallet_switchEthereumChain".into(), diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 607f4439188ac..1631ce4183fda 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -8,7 +8,7 @@ use cast::{Cast, SimpleCast}; use clap::{CommandFactory, Parser}; use clap_complete::generate; use eyre::Result; -use foundry_cli::{handler, prompt, stdin, utils}; +use foundry_cli::{handler, utils}; use foundry_common::{ abi::get_event, ens::{namehash, ProviderEnsExt}, @@ -19,6 +19,7 @@ use foundry_common::{ import_selectors, parse_signatures, pretty_calldata, ParsedSignatures, SelectorImportData, SelectorType, }, + stdin, }; use foundry_config::Config; use std::time::Instant; @@ -29,16 +30,27 @@ pub mod tx; use args::{Cast as CastArgs, CastSubcommand, ToBaseArgs}; +#[macro_use] +extern crate foundry_common; + #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; -fn main() -> Result<()> { +fn main() { + if let Err(err) = run() { + let _ = foundry_common::Shell::get().error(&err); + std::process::exit(1); + } +} + +fn run() -> Result<()> { handler::install(); utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); let args = CastArgs::parse(); + args.shell.shell().set(); main_args(args) } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 5487dc9f374bc..d43a78f1337f7 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -25,8 +25,26 @@ Commands: ... Options: - -h, --help Print help - -V, --version Print version + -h, --help + Print help (see a summary with '-h') + + -V, --version + Print version + +Display options: + --color + Log messages coloring + + Possible values: + - auto: Intelligently guess whether to use color output (default) + - always: Force color output + - never: Force disable color output + + -q, --quiet + Do not print log messages + + --verbose + Use verbose output Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html @@ -152,8 +170,7 @@ Validation succeeded. Address 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf signed .args(["wallet", "verify", "-a", address, "other msg", expected]) .assert_failure() .stderr_eq(str![[r#" -Error: -Validation failed. Address 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf did not sign this message. +Error: Validation failed. Address 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf did not sign this message. "#]]); }); @@ -935,8 +952,7 @@ casttest!(mktx_requires_to, |_prj, cmd| { "1", ]); cmd.assert_failure().stderr_eq(str![[r#" -Error: -Must specify a recipient address or contract code to deploy +Error: Must specify a recipient address or contract code to deploy "#]]); }); @@ -953,8 +969,7 @@ casttest!(mktx_signer_from_mismatch, |_prj, cmd| { "0x0000000000000000000000000000000000000001", ]); cmd.assert_failure().stderr_eq(str![[r#" -Error: -The specified sender via CLI/env vars does not match the sender configured via +Error: The specified sender via CLI/env vars does not match the sender configured via the hardware wallet's HD Path. Please use the `--hd-path ` parameter to specify the BIP32 Path which corresponds to the sender, or let foundry automatically detect it by not specifying any sender address. @@ -1025,8 +1040,7 @@ casttest!(send_requires_to, |_prj, cmd| { "1", ]); cmd.assert_failure().stderr_eq(str![[r#" -Error: -Must specify a recipient address or contract code to deploy +Error: Must specify a recipient address or contract code to deploy "#]]); }); @@ -1279,8 +1293,7 @@ casttest!(ens_resolve_no_dot_eth, |_prj, cmd| { cmd.args(["resolve-name", "emo", "--rpc-url", ð_rpc_url, "--verify"]) .assert_failure() .stderr_eq(str![[r#" -Error: -ENS resolver not found for name "emo" +Error: ENS resolver not found for name "emo" "#]]); }); @@ -1295,8 +1308,7 @@ casttest!(index7201, |_prj, cmd| { casttest!(index7201_unknown_formula_id, |_prj, cmd| { cmd.args(["index-erc7201", "test", "--formula-id", "unknown"]).assert_failure().stderr_eq( str![[r#" -Error: -unsupported formula ID: unknown +Error: unsupported formula ID: unknown "#]], ); diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 70425279484a7..c612a504706fc 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -11,7 +11,7 @@ use clap::{Parser, Subcommand}; use eyre::Context; use foundry_cli::{ handler, - opts::CoreBuildArgs, + opts::{CoreBuildArgs, ShellOpts}, utils::{self, LoadConfig}, }; use foundry_common::{evm::EvmArgs, fs}; @@ -50,6 +50,9 @@ pub struct Chisel { #[command(subcommand)] pub cmd: Option, + #[clap(flatten)] + pub shell: ShellOpts, + /// Path to a directory containing Solidity files to import, or path to a single Solidity file. /// /// These files will be evaluated before the top-level of the @@ -100,11 +103,19 @@ pub enum ChiselSubcommand { }, } -fn main() -> eyre::Result<()> { +fn main() { + if let Err(err) = run() { + let _ = foundry_common::Shell::get().error(&err); + std::process::exit(1); + } +} + +fn run() -> eyre::Result<()> { handler::install(); utils::subscriber(); utils::load_dotenv(); let args = Chisel::parse(); + args.shell.shell().set(); main_args(args) } diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 6f5e2f6076932..9c1fb848edaa9 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -5,10 +5,12 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; pub mod handler; pub mod opts; -pub mod stdin; pub mod utils; diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 59da53372c77c..58d0ace85ea2e 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -105,11 +105,6 @@ pub struct CoreBuildArgs { #[serde(skip)] pub revert_strings: Option, - /// Don't print anything on startup. - #[arg(long, help_heading = "Compiler options")] - #[serde(skip)] - pub silent: bool, - /// Generate build info files. #[arg(long, help_heading = "Project options")] #[serde(skip)] diff --git a/crates/cli/src/opts/mod.rs b/crates/cli/src/opts/mod.rs index 7825cba3c8b36..95bf9e126cc63 100644 --- a/crates/cli/src/opts/mod.rs +++ b/crates/cli/src/opts/mod.rs @@ -2,10 +2,12 @@ mod build; mod chain; mod dependency; mod ethereum; +mod shell; mod transaction; pub use build::*; pub use chain::*; pub use dependency::*; pub use ethereum::*; +pub use shell::*; pub use transaction::*; diff --git a/crates/cli/src/opts/shell.rs b/crates/cli/src/opts/shell.rs new file mode 100644 index 0000000000000..9213c670224c3 --- /dev/null +++ b/crates/cli/src/opts/shell.rs @@ -0,0 +1,39 @@ +use clap::Parser; +use foundry_common::shell::{ColorChoice, Shell, Verbosity}; + +// note: `verbose` and `quiet` cannot have `short` because of conflicts with multiple commands. + +/// Global shell options. +#[derive(Clone, Copy, Debug, Parser)] +pub struct ShellOpts { + /// Use verbose output. + #[clap(long, global = true, conflicts_with = "quiet", help_heading = "Display options")] + pub verbose: bool, + + /// Do not print log messages. + #[clap( + short, + long, + global = true, + alias = "silent", + conflicts_with = "verbose", + help_heading = "Display options" + )] + pub quiet: bool, + + /// Log messages coloring. + #[clap(long, global = true, value_enum, help_heading = "Display options")] + pub color: Option, +} + +impl ShellOpts { + pub fn shell(self) -> Shell { + let verbosity = match (self.verbose, self.quiet) { + (true, false) => Verbosity::Verbose, + (false, true) => Verbosity::Quiet, + (false, false) => Verbosity::Normal, + (true, true) => unreachable!(), + }; + Shell::new_with(self.color.unwrap_or_default(), verbosity) + } +} diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 4e289ba90e59b..eab1e0b318c09 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -1,7 +1,7 @@ use alloy_json_abi::JsonAbi; use alloy_primitives::Address; use eyre::{Result, WrapErr}; -use foundry_common::{cli_warn, fs, TestFunctionExt}; +use foundry_common::{fs, TestFunctionExt}; use foundry_compilers::{ artifacts::{CompactBytecode, CompactDeployedBytecode, Settings}, cache::{CacheEntry, CompilerCache}, @@ -275,35 +275,41 @@ where fn load_config_emit_warnings(self) -> Config { let config = self.load_config(); - config.warnings.iter().for_each(|w| cli_warn!("{w}")); + config.warnings.iter().for_each(|w| sh_warn!("{w}").unwrap()); config } fn try_load_config_emit_warnings(self) -> Result { let config = self.try_load_config()?; - config.warnings.iter().for_each(|w| cli_warn!("{w}")); + emit_warnings(&config); Ok(config) } fn load_config_and_evm_opts_emit_warnings(self) -> Result<(Config, EvmOpts)> { let (config, evm_opts) = self.load_config_and_evm_opts()?; - config.warnings.iter().for_each(|w| cli_warn!("{w}")); + emit_warnings(&config); Ok((config, evm_opts)) } fn load_config_unsanitized_emit_warnings(self) -> Config { let config = self.load_config_unsanitized(); - config.warnings.iter().for_each(|w| cli_warn!("{w}")); + emit_warnings(&config); config } fn try_load_config_unsanitized_emit_warnings(self) -> Result { let config = self.try_load_config_unsanitized()?; - config.warnings.iter().for_each(|w| cli_warn!("{w}")); + emit_warnings(&config); Ok(config) } } +fn emit_warnings(config: &Config) { + for warning in &config.warnings { + let _ = sh_warn!("{warning}"); + } +} + /// Read contract constructor arguments from the given file. pub fn read_constructor_args_file(constructor_args_path: PathBuf) -> Result> { if !constructor_args_path.exists() { diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 5b7523447ec93..8aa56aab8c411 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -3,7 +3,10 @@ use alloy_primitives::U256; use alloy_provider::{network::AnyNetwork, Provider}; use alloy_transport::Transport; use eyre::{ContextCompat, Result}; -use foundry_common::provider::{ProviderBuilder, RetryProvider}; +use foundry_common::{ + provider::{ProviderBuilder, RetryProvider}, + shell, +}; use foundry_config::{Chain, Config}; use serde::de::DeserializeOwned; use std::{ @@ -167,23 +170,6 @@ pub fn block_on(future: F) -> F::Output { rt.block_on(future) } -/// Conditionally print a message -/// -/// This macro accepts a predicate and the message to print if the predicate is true -/// -/// ```ignore -/// let quiet = true; -/// p_println!(!quiet => "message"); -/// ``` -#[macro_export] -macro_rules! p_println { - ($p:expr => $($arg:tt)*) => {{ - if $p { - println!($($arg)*) - } - }} -} - /// Loads a dotenv file, from the cwd and the project root, ignoring potential failure. /// /// We could use `warn!` here, but that would imply that the dotenv file can't configure @@ -288,7 +274,7 @@ pub struct Git<'a> { impl<'a> Git<'a> { #[inline] pub fn new(root: &'a Path) -> Self { - Self { root, quiet: false, shallow: false } + Self { root, quiet: shell::is_quiet(), shallow: false } } #[inline] diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index fbc5c82ca7718..af95e94bcc35a 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -62,6 +62,10 @@ url.workspace = true walkdir.workspace = true yansi.workspace = true +anstream.workspace = true +anstyle.workspace = true +terminal_size.workspace = true + [dev-dependencies] foundry-macros.workspace = true similar-asserts.workspace = true diff --git a/crates/common/fmt/Cargo.toml b/crates/common/fmt/Cargo.toml index 9902de608f412..2a56b3b10e010 100644 --- a/crates/common/fmt/Cargo.toml +++ b/crates/common/fmt/Cargo.toml @@ -16,7 +16,6 @@ workspace = true [dependencies] alloy-primitives.workspace = true alloy-dyn-abi = { workspace = true, features = ["eip712"] } -yansi.workspace = true # ui alloy-consensus.workspace = true @@ -28,6 +27,7 @@ serde_json.workspace = true chrono.workspace = true revm-primitives.workspace = true comfy-table.workspace = true +yansi.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 39998b3a61c10..d504e1688e64d 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -66,7 +66,7 @@ impl ProjectCompiler { verify: None, print_names: None, print_sizes: None, - quiet: Some(crate::shell::verbosity().is_silent()), + quiet: Some(crate::shell::is_quiet()), bail: None, ignore_eip_3860: false, files: Vec::new(), @@ -102,15 +102,6 @@ impl ProjectCompiler { self } - /// Do not print anything at all if true. Overrides other `print` options. - #[inline] - pub fn quiet_if(mut self, maybe: bool) -> Self { - if maybe { - self.quiet = Some(true); - } - self - } - /// Sets whether to bail on compiler errors. #[inline] pub fn bail(mut self, yes: bool) -> Self { diff --git a/crates/common/src/io/macros.rs b/crates/common/src/io/macros.rs new file mode 100644 index 0000000000000..fe1e72dfecc98 --- /dev/null +++ b/crates/common/src/io/macros.rs @@ -0,0 +1,185 @@ +/// Prints a message to [`stdout`][std::io::stdout] and reads a line from stdin into a String. +/// +/// Returns `Result`, so sometimes `T` must be explicitly specified, like in `str::parse`. +/// +/// # Examples +/// +/// ```no_run +/// use foundry_common::prompt; +/// +/// let response: String = prompt!("Would you like to continue? [y/N] ")?; +/// if !matches!(response.as_str(), "y" | "Y") { +/// return Ok(()) +/// } +/// # Ok::<(), Box>(()) +/// ``` +#[macro_export] +macro_rules! prompt { + () => { + $crate::stdin::parse_line() + }; + + ($($tt:tt)+) => {{ + let _ = $crate::sh_print!($($tt)+); + match ::std::io::Write::flush(&mut ::std::io::stdout()) { + ::core::result::Result::Ok(()) => $crate::prompt!(), + ::core::result::Result::Err(e) => ::core::result::Result::Err(::eyre::eyre!("Could not flush stdout: {e}")) + } + }}; +} + +/// Prints a formatted error to stderr. +/// +/// **Note**: will log regardless of the verbosity level. +#[macro_export] +macro_rules! sh_err { + ($($args:tt)*) => { + $crate::__sh_dispatch!(error $($args)*) + }; +} + +/// Prints a formatted warning to stderr. +/// +/// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. +#[macro_export] +macro_rules! sh_warn { + ($($args:tt)*) => { + $crate::__sh_dispatch!(warn $($args)*) + }; +} + +/// Prints a raw formatted message to stdout. +/// +/// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. +#[macro_export] +macro_rules! sh_print { + ($($args:tt)*) => { + $crate::__sh_dispatch!(print_out $($args)*) + }; + + ($shell:expr, $($args:tt)*) => { + $crate::__sh_dispatch!(print_out $shell, $($args)*) + }; +} + +/// Prints a raw formatted message to stderr. +/// +/// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. +#[macro_export] +macro_rules! sh_eprint { + ($($args:tt)*) => { + $crate::__sh_dispatch!(print_err $($args)*) + }; + + ($shell:expr, $($args:tt)*) => { + $crate::__sh_dispatch!(print_err $shell, $($args)*) + }; +} + +/// Prints a raw formatted message to stdout, with a trailing newline. +/// +/// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. +#[macro_export] +macro_rules! sh_println { + () => { + $crate::sh_print!("\n") + }; + + ($fmt:literal $($args:tt)*) => { + $crate::sh_print!("{}\n", ::core::format_args!($fmt $($args)*)) + }; + + ($shell:expr $(,)?) => { + $crate::sh_print!($shell, "\n").expect("failed to write newline") + }; + + ($shell:expr, $($args:tt)*) => { + $crate::sh_print!($shell, "{}\n", ::core::format_args!($($args)*)) + }; + + ($($args:tt)*) => { + $crate::sh_print!("{}\n", ::core::format_args!($($args)*)) + }; +} + +/// Prints a raw formatted message to stderr, with a trailing newline. +/// +/// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. +#[macro_export] +macro_rules! sh_eprintln { + () => { + $crate::sh_eprint!("\n") + }; + + ($fmt:literal $($args:tt)*) => { + $crate::sh_eprint!("{}\n", ::core::format_args!($fmt $($args)*)) + }; + + ($shell:expr $(,)?) => { + $crate::sh_eprint!($shell, "\n") + }; + + ($shell:expr, $($args:tt)*) => { + $crate::sh_eprint!($shell, "{}\n", ::core::format_args!($($args)*)) + }; + + ($($args:tt)*) => { + $crate::sh_eprint!("{}\n", ::core::format_args!($($args)*)) + }; +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __sh_dispatch { + ($f:ident $fmt:literal $($args:tt)*) => { + $crate::Shell::$f(&mut *$crate::Shell::get(), ::core::format_args!($fmt $($args)*)) + }; + + ($f:ident $shell:expr, $($args:tt)*) => { + $crate::Shell::$f($shell, ::core::format_args!($($args)*)) + }; + + ($f:ident $($args:tt)*) => { + $crate::Shell::$f(&mut *$crate::Shell::get(), ::core::format_args!($($args)*)) + }; +} + +#[cfg(test)] +mod tests { + #[test] + fn macros() -> eyre::Result<()> { + sh_err!("err")?; + sh_err!("err {}", "arg")?; + + sh_warn!("warn")?; + sh_warn!("warn {}", "arg")?; + + sh_print!("print -")?; + sh_print!("print {} -", "arg")?; + + sh_println!()?; + sh_println!("println")?; + sh_println!("println {}", "arg")?; + + sh_eprint!("eprint -")?; + sh_eprint!("eprint {} -", "arg")?; + + sh_eprintln!()?; + sh_eprintln!("eprintln")?; + sh_eprintln!("eprintln {}", "arg")?; + + Ok(()) + } + + #[test] + fn macros_with_shell() -> eyre::Result<()> { + let shell = &mut crate::Shell::new(); + sh_eprintln!(shell)?; + sh_eprintln!(shell,)?; + sh_eprintln!(shell, "shelled eprintln")?; + sh_eprintln!(shell, "shelled eprintln {}", "arg")?; + sh_eprintln!(&mut crate::Shell::new(), "shelled eprintln {}", "arg")?; + + Ok(()) + } +} diff --git a/crates/common/src/io/mod.rs b/crates/common/src/io/mod.rs new file mode 100644 index 0000000000000..f62fd034617bf --- /dev/null +++ b/crates/common/src/io/mod.rs @@ -0,0 +1,11 @@ +//! Utilities for working with standard input, output, and error. + +#[macro_use] +mod macros; + +pub mod shell; +pub mod stdin; +pub mod style; + +#[doc(no_inline)] +pub use shell::Shell; diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs new file mode 100644 index 0000000000000..b60061eea4acb --- /dev/null +++ b/crates/common/src/io/shell.rs @@ -0,0 +1,518 @@ +//! Utility functions for writing to [`stdout`](std::io::stdout) and [`stderr`](std::io::stderr). +//! +//! Originally from [cargo](https://github.com/rust-lang/cargo/blob/35814255a1dbaeca9219fae81d37a8190050092c/src/cargo/core/shell.rs). + +use super::style::*; +use anstream::AutoStream; +use anstyle::Style; +use clap::ValueEnum; +use eyre::Result; +use std::{ + fmt, + io::{prelude::*, IsTerminal}, + ops::DerefMut, + sync::{ + atomic::{AtomicBool, Ordering}, + Mutex, OnceLock, PoisonError, + }, +}; + +/// Returns the currently set verbosity. +pub fn verbosity() -> Verbosity { + Shell::get().verbosity() +} + +/// Returns whether the verbosity level is [`Verbosity::Quiet`]. +pub fn is_quiet() -> bool { + verbosity().is_quiet() +} + +/// The global shell instance. +static GLOBAL_SHELL: OnceLock> = OnceLock::new(); + +/// Terminal width. +pub enum TtyWidth { + /// Not a terminal, or could not determine size. + NoTty, + /// A known width. + Known(usize), + /// A guess at the width. + Guess(usize), +} + +impl TtyWidth { + /// Returns the width of the terminal from the environment, if known. + pub fn get() -> Self { + // use stderr + #[cfg(unix)] + #[allow(clippy::useless_conversion)] + let opt = terminal_size::terminal_size_of(unsafe { + std::os::fd::BorrowedFd::borrow_raw(2.into()) + }); + #[cfg(not(unix))] + let opt = terminal_size::terminal_size(); + match opt { + Some((w, _)) => Self::Known(w.0 as usize), + None => Self::NoTty, + } + } + + /// Returns the width used by progress bars for the tty. + pub fn progress_max_width(&self) -> Option { + match *self { + Self::NoTty => None, + Self::Known(width) | Self::Guess(width) => Some(width), + } + } +} + +/// The requested verbosity of output. +#[derive(Debug, Default, Clone, Copy, PartialEq)] +pub enum Verbosity { + /// All output + Verbose, + /// Default output + #[default] + Normal, + /// No output + Quiet, +} + +impl Verbosity { + /// Returns true if the verbosity level is `Verbose`. + #[inline] + pub fn is_verbose(self) -> bool { + self == Self::Verbose + } + + /// Returns true if the verbosity level is `Normal`. + #[inline] + pub fn is_normal(self) -> bool { + self == Self::Normal + } + + /// Returns true if the verbosity level is `Quiet`. + #[inline] + pub fn is_quiet(self) -> bool { + self == Self::Quiet + } +} + +/// An abstraction around console output that remembers preferences for output +/// verbosity and color. +pub struct Shell { + /// Wrapper around stdout/stderr. This helps with supporting sending + /// output to a memory buffer which is useful for tests. + output: ShellOut, + + /// How verbose messages should be. + verbosity: Verbosity, + + /// Flag that indicates the current line needs to be cleared before + /// printing. Used when a progress bar is currently displayed. + needs_clear: AtomicBool, +} + +impl fmt::Debug for Shell { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut s = f.debug_struct("Shell"); + s.field("verbosity", &self.verbosity); + if let ShellOut::Stream { color_choice, .. } = self.output { + s.field("color_choice", &color_choice); + } + s.finish() + } +} + +/// A `Write`able object, either with or without color support. +enum ShellOut { + /// Color-enabled stdio, with information on whether color should be used. + Stream { + stdout: AutoStream, + stderr: AutoStream, + stderr_tty: bool, + color_choice: ColorChoice, + }, + /// A write object that ignores all output. + Empty(std::io::Empty), +} + +/// Whether messages should use color output. +#[derive(Debug, Default, PartialEq, Clone, Copy, ValueEnum)] +pub enum ColorChoice { + /// Intelligently guess whether to use color output (default). + #[default] + Auto, + /// Force color output. + Always, + /// Force disable color output. + Never, +} + +impl Default for Shell { + #[inline] + fn default() -> Self { + Self::new() + } +} + +impl Shell { + /// Creates a new shell (color choice and verbosity), defaulting to 'auto' color and verbose + /// output. + #[inline] + pub fn new() -> Self { + Self::new_with(ColorChoice::Auto, Verbosity::Verbose) + } + + /// Creates a new shell with the given color choice and verbosity. + #[inline] + pub fn new_with(color: ColorChoice, verbosity: Verbosity) -> Self { + Self { + output: ShellOut::Stream { + stdout: AutoStream::new(std::io::stdout(), color.to_anstream_color_choice()), + stderr: AutoStream::new(std::io::stderr(), color.to_anstream_color_choice()), + color_choice: color, + stderr_tty: std::io::stderr().is_terminal(), + }, + verbosity, + needs_clear: AtomicBool::new(false), + } + } + + /// Creates a shell that ignores all output. + #[inline] + pub fn empty() -> Self { + Self { + output: ShellOut::Empty(std::io::empty()), + verbosity: Verbosity::Quiet, + needs_clear: AtomicBool::new(false), + } + } + + /// Get a static reference to the global shell. + #[inline] + #[cfg_attr(debug_assertions, track_caller)] + pub fn get() -> impl DerefMut + 'static { + #[inline(never)] + #[cold] + #[cfg_attr(debug_assertions, track_caller)] + fn shell_get_fail() -> Mutex { + Mutex::new(Shell::new()) + } + + GLOBAL_SHELL.get_or_init(shell_get_fail).lock().unwrap_or_else(PoisonError::into_inner) + } + + /// Set the global shell. + /// + /// # Panics + /// + /// Panics if the global shell has already been set. + #[inline] + #[track_caller] + pub fn set(self) { + if GLOBAL_SHELL.get().is_some() { + panic!("attempted to set global shell twice"); + } + GLOBAL_SHELL.get_or_init(|| Mutex::new(self)); + } + + /// Sets whether the next print should clear the current line and returns the previous value. + #[inline] + pub fn set_needs_clear(&self, needs_clear: bool) -> bool { + self.needs_clear.swap(needs_clear, Ordering::Relaxed) + } + + /// Returns `true` if the `needs_clear` flag is set. + #[inline] + pub fn needs_clear(&self) -> bool { + self.needs_clear.load(Ordering::Relaxed) + } + + /// Returns `true` if the `needs_clear` flag is unset. + #[inline] + pub fn is_cleared(&self) -> bool { + !self.needs_clear() + } + + /// Returns the width of the terminal in spaces, if any. + #[inline] + pub fn err_width(&self) -> TtyWidth { + match self.output { + ShellOut::Stream { stderr_tty: true, .. } => TtyWidth::get(), + _ => TtyWidth::NoTty, + } + } + + /// Gets the verbosity of the shell. + #[inline] + pub fn verbosity(&self) -> Verbosity { + self.verbosity + } + + /// Gets the current color choice. + /// + /// If we are not using a color stream, this will always return `Never`, even if the color + /// choice has been set to something else. + #[inline] + pub fn color_choice(&self) -> ColorChoice { + match self.output { + ShellOut::Stream { color_choice, .. } => color_choice, + ShellOut::Empty(_) => ColorChoice::Never, + } + } + + /// Returns `true` if stderr is a tty. + #[inline] + pub fn is_err_tty(&self) -> bool { + match self.output { + ShellOut::Stream { stderr_tty, .. } => stderr_tty, + ShellOut::Empty(_) => false, + } + } + + /// Whether `stderr` supports color. + #[inline] + pub fn err_supports_color(&self) -> bool { + match &self.output { + ShellOut::Stream { stderr, .. } => supports_color(stderr.current_choice()), + ShellOut::Empty(_) => false, + } + } + + /// Whether `stdout` supports color. + #[inline] + pub fn out_supports_color(&self) -> bool { + match &self.output { + ShellOut::Stream { stdout, .. } => supports_color(stdout.current_choice()), + ShellOut::Empty(_) => false, + } + } + + /// Gets a reference to the underlying stdout writer. + #[inline] + pub fn out(&mut self) -> &mut dyn Write { + self.maybe_err_erase_line(); + self.output.stdout() + } + + /// Gets a reference to the underlying stderr writer. + #[inline] + pub fn err(&mut self) -> &mut dyn Write { + self.maybe_err_erase_line(); + self.output.stderr() + } + + /// Erase from cursor to end of line if needed. + #[inline] + pub fn maybe_err_erase_line(&mut self) { + if self.err_supports_color() && self.set_needs_clear(false) { + // This is the "EL - Erase in Line" sequence. It clears from the cursor + // to the end of line. + // https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_sequences + let _ = self.output.stderr().write_all(b"\x1B[K"); + } + } + + /// Runs the callback only if we are in verbose mode. + #[inline] + pub fn verbose(&mut self, mut callback: impl FnMut(&mut Self) -> Result<()>) -> Result<()> { + match self.verbosity { + Verbosity::Verbose => callback(self), + _ => Ok(()), + } + } + + /// Runs the callback if we are not in verbose mode. + #[inline] + pub fn concise(&mut self, mut callback: impl FnMut(&mut Self) -> Result<()>) -> Result<()> { + match self.verbosity { + Verbosity::Verbose => Ok(()), + _ => callback(self), + } + } + + /// Prints a red 'error' message. Use the [`sh_err!`] macro instead. + /// This will render a message in [ERROR] style with a bold `Error: ` prefix. + /// + /// **Note**: will log regardless of the verbosity level. + #[inline] + pub fn error(&mut self, message: impl fmt::Display) -> Result<()> { + self.maybe_err_erase_line(); + self.output.message_stderr(&"Error", &ERROR, Some(&message), false) + } + + /// Prints an amber 'warning' message. Use the [`sh_warn!`] macro instead. + /// This will render a message in [WARN] style with a bold `Warning: `prefix. + /// + /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. + #[inline] + pub fn warn(&mut self, message: impl fmt::Display) -> Result<()> { + match self.verbosity { + Verbosity::Quiet => Ok(()), + _ => self.print(&"Warning", &WARN, Some(&message), false), + } + } + + /// Write a styled fragment. + /// + /// Caller is responsible for deciding whether [`Shell::verbosity`] is affects output. + #[inline] + pub fn write_stdout(&mut self, fragment: impl fmt::Display, color: &Style) -> Result<()> { + self.output.write_stdout(fragment, color) + } + + /// Write a styled fragment with the default color. Use the [`sh_print!`] macro instead. + /// + /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. + #[inline] + pub fn print_out(&mut self, fragment: impl fmt::Display) -> Result<()> { + if self.verbosity == Verbosity::Quiet { + Ok(()) + } else { + self.write_stdout(fragment, &Style::new()) + } + } + + /// Write a styled fragment + /// + /// Caller is responsible for deciding whether [`Shell::verbosity`] is affects output. + #[inline] + pub fn write_stderr(&mut self, fragment: impl fmt::Display, color: &Style) -> Result<()> { + self.output.write_stderr(fragment, color) + } + + /// Write a styled fragment with the default color. Use the [`sh_eprint!`] macro instead. + /// + /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. + #[inline] + pub fn print_err(&mut self, fragment: impl fmt::Display) -> Result<()> { + if self.verbosity == Verbosity::Quiet { + Ok(()) + } else { + self.write_stderr(fragment, &Style::new()) + } + } + + /// Prints a message, where the status will have `color` color, and can be justified. The + /// messages follows without color. + fn print( + &mut self, + status: &dyn fmt::Display, + style: &Style, + message: Option<&dyn fmt::Display>, + justified: bool, + ) -> Result<()> { + match self.verbosity { + Verbosity::Quiet => Ok(()), + _ => { + self.maybe_err_erase_line(); + self.output.message_stderr(status, style, message, justified) + } + } + } +} + +impl ShellOut { + /// Prints out a message with a status to stderr. The status comes first, and is bold plus the + /// given color. The status can be justified, in which case the max width that will right + /// align is 12 chars. + fn message_stderr( + &mut self, + status: &dyn fmt::Display, + style: &Style, + message: Option<&dyn fmt::Display>, + justified: bool, + ) -> Result<()> { + let buffer = Self::format_message(status, message, style, justified)?; + self.stderr().write_all(&buffer)?; + Ok(()) + } + + /// Write a styled fragment + fn write_stdout(&mut self, fragment: impl fmt::Display, style: &Style) -> Result<()> { + let style = style.render(); + let reset = anstyle::Reset.render(); + + let mut buffer = Vec::new(); + write!(buffer, "{style}{fragment}{reset}")?; + self.stdout().write_all(&buffer)?; + Ok(()) + } + + /// Write a styled fragment + fn write_stderr(&mut self, fragment: impl fmt::Display, style: &Style) -> Result<()> { + let style = style.render(); + let reset = anstyle::Reset.render(); + + let mut buffer = Vec::new(); + write!(buffer, "{style}{fragment}{reset}")?; + self.stderr().write_all(&buffer)?; + Ok(()) + } + + /// Gets stdout as a [`io::Write`](Write) trait object. + #[inline] + fn stdout(&mut self) -> &mut dyn Write { + match self { + Self::Stream { stdout, .. } => stdout, + Self::Empty(e) => e, + } + } + + /// Gets stderr as a [`io::Write`](Write) trait object. + #[inline] + fn stderr(&mut self) -> &mut dyn Write { + match self { + Self::Stream { stderr, .. } => stderr, + Self::Empty(e) => e, + } + } + + /// Formats a message with a status and optional message. + fn format_message( + status: &dyn fmt::Display, + message: Option<&dyn fmt::Display>, + style: &Style, + justified: bool, + ) -> Result> { + let style = style.render(); + let bold = (anstyle::Style::new() | anstyle::Effects::BOLD).render(); + let reset = anstyle::Reset.render(); + + let mut buffer = Vec::new(); + if justified { + write!(&mut buffer, "{style}{status:>12}{reset}")?; + } else { + write!(&mut buffer, "{style}{status}{reset}{bold}:{reset}")?; + } + match message { + Some(message) => { + writeln!(&mut buffer, " {message}")?; + } + None => write!(buffer, " ")?, + } + + Ok(buffer) + } +} + +impl ColorChoice { + /// Converts our color choice to [`anstream`]'s version. + fn to_anstream_color_choice(self) -> anstream::ColorChoice { + match self { + Self::Always => anstream::ColorChoice::Always, + Self::Never => anstream::ColorChoice::Never, + Self::Auto => anstream::ColorChoice::Auto, + } + } +} + +fn supports_color(choice: anstream::ColorChoice) -> bool { + match choice { + anstream::ColorChoice::Always | + anstream::ColorChoice::AlwaysAnsi | + anstream::ColorChoice::Auto => true, + anstream::ColorChoice::Never => false, + } +} diff --git a/crates/cli/src/stdin.rs b/crates/common/src/io/stdin.rs similarity index 76% rename from crates/cli/src/stdin.rs rename to crates/common/src/io/stdin.rs index 8242cc8057724..17b40a2cff1fe 100644 --- a/crates/cli/src/stdin.rs +++ b/crates/common/src/io/stdin.rs @@ -7,37 +7,6 @@ use std::{ str::FromStr, }; -/// Prints a message to [`stdout`][io::stdout] and [reads a line from stdin into a String](read). -/// -/// Returns `Result`, so sometimes `T` must be explicitly specified, like in `str::parse`. -/// -/// # Examples -/// -/// ```no_run -/// # use foundry_cli::prompt; -/// let response: String = prompt!("Would you like to continue? [y/N] ")?; -/// if !matches!(response.as_str(), "y" | "Y") { -/// return Ok(()) -/// } -/// # Ok::<(), Box>(()) -/// ``` -#[macro_export] -macro_rules! prompt { - () => { - $crate::stdin::parse_line() - }; - - ($($tt:tt)+) => { - { - ::std::print!($($tt)+); - match ::std::io::Write::flush(&mut ::std::io::stdout()) { - ::core::result::Result::Ok(_) => $crate::prompt!(), - ::core::result::Result::Err(e) => ::core::result::Result::Err(::eyre::eyre!("Could not flush stdout: {}", e)) - } - } - }; -} - /// Unwraps the given `Option` or [reads stdin into a String](read) and parses it as `T`. pub fn unwrap(value: Option, read_line: bool) -> Result where @@ -50,6 +19,7 @@ where } } +/// Shortcut for `(unwrap(a), unwrap(b))`. #[inline] pub fn unwrap2(a: Option, b: Option) -> Result<(A, B)> where diff --git a/crates/common/src/io/style.rs b/crates/common/src/io/style.rs new file mode 100644 index 0000000000000..6103b2d37d105 --- /dev/null +++ b/crates/common/src/io/style.rs @@ -0,0 +1,5 @@ +#![allow(missing_docs)] +use anstyle::*; + +pub const ERROR: Style = AnsiColor::Red.on_default().effects(Effects::BOLD); +pub const WARN: Style = AnsiColor::Yellow.on_default().effects(Effects::BOLD); diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index a33a7b2231565..68559d081b0ae 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -11,6 +11,9 @@ extern crate self as foundry_common; #[macro_use] extern crate tracing; +#[macro_use] +pub mod io; + pub use foundry_common_fmt as fmt; pub mod abi; @@ -26,7 +29,6 @@ pub mod provider; pub mod retry; pub mod selectors; pub mod serde_helpers; -pub mod shell; pub mod term; pub mod traits; pub mod transactions; @@ -34,6 +36,7 @@ mod utils; pub use constants::*; pub use contracts::*; +pub use io::{shell, stdin, Shell}; pub use traits::*; pub use transactions::*; pub use utils::*; diff --git a/crates/common/src/shell.rs b/crates/common/src/shell.rs deleted file mode 100644 index 8ab98e64a9c72..0000000000000 --- a/crates/common/src/shell.rs +++ /dev/null @@ -1,307 +0,0 @@ -//! Helpers for printing to output - -use serde::Serialize; -use std::{ - error::Error, - fmt, io, - io::Write, - sync::{Arc, Mutex, OnceLock}, -}; - -/// Stores the configured shell for the duration of the program -static SHELL: OnceLock = OnceLock::new(); - -/// Error indicating that `set_hook` was unable to install the provided ErrorHook -#[derive(Clone, Copy, Debug)] -pub struct InstallError; - -impl fmt::Display for InstallError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("cannot install provided Shell, a shell has already been installed") - } -} - -impl Error for InstallError {} - -/// Install the provided shell -pub fn set_shell(shell: Shell) -> Result<(), InstallError> { - SHELL.set(shell).map_err(|_| InstallError) -} - -/// Runs the given closure with the current shell, or default shell if none was set -pub fn with_shell(f: F) -> R -where - F: FnOnce(&Shell) -> R, -{ - if let Some(shell) = SHELL.get() { - f(shell) - } else { - let shell = Shell::default(); - f(&shell) - } -} - -/// Prints the given message to the shell -pub fn println(msg: impl fmt::Display) -> io::Result<()> { - with_shell(|shell| if !shell.verbosity.is_silent() { shell.write_stdout(msg) } else { Ok(()) }) -} -/// Prints the given message to the shell -pub fn print_json(obj: &T) -> serde_json::Result<()> { - with_shell(|shell| shell.print_json(obj)) -} - -/// Prints the given message to the shell -pub fn eprintln(msg: impl fmt::Display) -> io::Result<()> { - with_shell(|shell| if !shell.verbosity.is_silent() { shell.write_stderr(msg) } else { Ok(()) }) -} - -/// Returns the configured verbosity -pub fn verbosity() -> Verbosity { - with_shell(|shell| shell.verbosity) -} - -/// An abstraction around console output that also considers verbosity -#[derive(Default)] -pub struct Shell { - /// Wrapper around stdout/stderr. - output: ShellOut, - /// How to emit messages. - verbosity: Verbosity, -} - -impl Shell { - /// Creates a new shell instance - pub fn new(output: ShellOut, verbosity: Verbosity) -> Self { - Self { output, verbosity } - } - - /// Returns a new shell that conforms to the specified verbosity arguments, where `json` - /// or `junit` takes higher precedence. - pub fn from_args(silent: bool, json: bool) -> Self { - match (silent, json) { - (_, true) => Self::json(), - (true, _) => Self::silent(), - _ => Default::default(), - } - } - - /// Returns a new shell that won't emit anything - pub fn silent() -> Self { - Self::from_verbosity(Verbosity::Silent) - } - - /// Returns a new shell that'll only emit json - pub fn json() -> Self { - Self::from_verbosity(Verbosity::Json) - } - - /// Creates a new shell instance with default output and the given verbosity - pub fn from_verbosity(verbosity: Verbosity) -> Self { - Self::new(Default::default(), verbosity) - } - - /// Write a fragment to stdout - /// - /// Caller is responsible for deciding whether [`Shell`] verbosity affects output. - pub fn write_stdout(&self, fragment: impl fmt::Display) -> io::Result<()> { - self.output.write_stdout(fragment) - } - - /// Write a fragment to stderr - /// - /// Caller is responsible for deciding whether [`Shell`] verbosity affects output. - pub fn write_stderr(&self, fragment: impl fmt::Display) -> io::Result<()> { - self.output.write_stderr(fragment) - } - - /// Prints the object to stdout as json - pub fn print_json(&self, obj: &T) -> serde_json::Result<()> { - if self.verbosity.is_json() { - let json = serde_json::to_string(&obj)?; - let _ = self.output.with_stdout(|out| writeln!(out, "{json}")); - } - Ok(()) - } - /// Prints the object to stdout as pretty json - pub fn pretty_print_json(&self, obj: &T) -> serde_json::Result<()> { - if self.verbosity.is_json() { - let json = serde_json::to_string_pretty(&obj)?; - let _ = self.output.with_stdout(|out| writeln!(out, "{json}")); - } - Ok(()) - } -} - -impl fmt::Debug for Shell { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.output { - ShellOut::Write(_) => { - f.debug_struct("Shell").field("verbosity", &self.verbosity).finish() - } - ShellOut::Stream => { - f.debug_struct("Shell").field("verbosity", &self.verbosity).finish() - } - } - } -} - -/// Helper trait for custom shell output -/// -/// Can be used for debugging -pub trait ShellWrite { - /// Write the fragment - fn write(&self, fragment: impl fmt::Display) -> io::Result<()>; - - /// Executes a closure on the current stdout - fn with_stdout(&self, f: F) -> R - where - for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R; - - /// Executes a closure on the current stderr - fn with_err(&self, f: F) -> R - where - for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R; -} - -/// A guarded shell output type -pub struct WriteShellOut(Arc>>); - -unsafe impl Send for WriteShellOut {} -unsafe impl Sync for WriteShellOut {} - -impl ShellWrite for WriteShellOut { - fn write(&self, fragment: impl fmt::Display) -> io::Result<()> { - if let Ok(mut lock) = self.0.lock() { - writeln!(lock, "{fragment}")?; - } - Ok(()) - } - /// Executes a closure on the current stdout - fn with_stdout(&self, f: F) -> R - where - for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R, - { - let mut lock = self.0.lock().unwrap(); - f(&mut *lock) - } - - /// Executes a closure on the current stderr - fn with_err(&self, f: F) -> R - where - for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R, - { - let mut lock = self.0.lock().unwrap(); - f(&mut *lock) - } -} - -/// A `Write`able object, either with or without color support -#[derive(Default)] -pub enum ShellOut { - /// A plain write object - /// - /// Can be used for debug purposes - Write(WriteShellOut), - /// Streams to `stdio` - #[default] - Stream, -} - -impl ShellOut { - /// Creates a new shell that writes to memory - pub fn memory() -> Self { - #[allow(clippy::box_default)] - #[allow(clippy::arc_with_non_send_sync)] - Self::Write(WriteShellOut(Arc::new(Mutex::new(Box::new(Vec::new()))))) - } - - /// Write a fragment to stdout - fn write_stdout(&self, fragment: impl fmt::Display) -> io::Result<()> { - match *self { - Self::Stream => { - let stdout = io::stdout(); - let mut handle = stdout.lock(); - writeln!(handle, "{fragment}")?; - } - Self::Write(ref w) => { - w.write(fragment)?; - } - } - Ok(()) - } - - /// Write output to stderr - fn write_stderr(&self, fragment: impl fmt::Display) -> io::Result<()> { - match *self { - Self::Stream => { - let stderr = io::stderr(); - let mut handle = stderr.lock(); - writeln!(handle, "{fragment}")?; - } - Self::Write(ref w) => { - w.write(fragment)?; - } - } - Ok(()) - } - - /// Executes a closure on the current stdout - fn with_stdout(&self, f: F) -> R - where - for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R, - { - match *self { - Self::Stream => { - let stdout = io::stdout(); - let mut handler = stdout.lock(); - f(&mut handler) - } - Self::Write(ref w) => w.with_stdout(f), - } - } - - /// Executes a closure on the current stderr - #[allow(unused)] - fn with_err(&self, f: F) -> R - where - for<'r> F: FnOnce(&'r mut (dyn Write + 'r)) -> R, - { - match *self { - Self::Stream => { - let stderr = io::stderr(); - let mut handler = stderr.lock(); - f(&mut handler) - } - Self::Write(ref w) => w.with_err(f), - } - } -} - -/// The requested verbosity of output. -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -pub enum Verbosity { - /// only allow json output - Json, - /// print as is - #[default] - Normal, - /// print nothing - Silent, -} - -impl Verbosity { - /// Returns true if json mode - pub fn is_json(&self) -> bool { - matches!(self, Self::Json) - } - - /// Returns true if silent - pub fn is_silent(&self) -> bool { - matches!(self, Self::Silent) - } - - /// Returns true if normal verbosity - pub fn is_normal(&self) -> bool { - matches!(self, Self::Normal) - } -} diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 30aaf6c52f822..4753b1e416f8a 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -198,21 +198,6 @@ pub fn with_spinner_reporter(f: impl FnOnce() -> T) -> T { report::with_scoped(&reporter, f) } -#[macro_export] -/// Displays warnings on the cli -macro_rules! cli_warn { - ($($arg:tt)*) => { - eprintln!( - "{}{} {}", - yansi::Painted::new("warning").yellow().bold(), - yansi::Painted::new(":").bold(), - format_args!($($arg)*) - ) - } -} - -pub use cli_warn; - #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index f0fa7c9006e45..f6d3483342325 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -76,7 +76,7 @@ pub struct BuildArgs { /// Output the compilation errors in the json format. /// This is useful when you want to use the output in other tools. - #[arg(long, conflicts_with = "silent")] + #[arg(long, conflicts_with = "quiet")] #[serde(skip)] pub format_json: bool, } @@ -85,9 +85,7 @@ impl BuildArgs { pub fn run(self) -> Result { let mut config = self.try_load_config_emit_warnings()?; - if install::install_missing_dependencies(&mut config, self.args.silent) && - config.auto_detect_remappings - { + if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings config = self.load_config(); } @@ -115,7 +113,7 @@ impl BuildArgs { let output = compiler.compile(&project)?; if self.format_json { - println!("{}", serde_json::to_string_pretty(&output.output())?); + sh_println!("{}", serde_json::to_string_pretty(&output.output())?)?; } Ok(output) @@ -174,33 +172,3 @@ impl Provider for BuildArgs { Ok(Map::from([(Config::selected_profile(), dict)])) } } - -#[cfg(test)] -mod tests { - use super::*; - use foundry_config::filter::SkipBuildFilter; - - #[test] - fn can_parse_build_filters() { - let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "tests"]); - assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Tests])); - - let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "scripts"]); - assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Scripts])); - - let args: BuildArgs = - BuildArgs::parse_from(["foundry-cli", "--skip", "tests", "--skip", "scripts"]); - assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Tests, SkipBuildFilter::Scripts])); - - let args: BuildArgs = BuildArgs::parse_from(["foundry-cli", "--skip", "tests", "scripts"]); - assert_eq!(args.args.skip, Some(vec![SkipBuildFilter::Tests, SkipBuildFilter::Scripts])); - } - - #[test] - fn check_conflicts() { - let args: std::result::Result = - BuildArgs::try_parse_from(["foundry-cli", "--format-json", "--silent"]); - assert!(args.is_err()); - assert!(args.unwrap_err().kind() == clap::error::ErrorKind::ArgumentConflict); - } -} diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 1c9ee47ec9fe4..f1bb40cf6918a 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -7,7 +7,7 @@ use foundry_block_explorers::{ errors::EtherscanError, Client, }; -use foundry_cli::{opts::EtherscanOpts, p_println, utils::Git}; +use foundry_cli::{opts::EtherscanOpts, utils::Git}; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ artifacts::{ @@ -102,7 +102,8 @@ impl CloneArgs { let client = Client::new(chain, etherscan_api_key.clone())?; // step 1. get the metadata from client - p_println!(!opts.quiet => "Downloading the source code of {} from Etherscan...", address); + sh_println!("Downloading the source code of {address} from Etherscan...")?; + let meta = Self::collect_metadata_from_client(address, &client).await?; // step 2. initialize an empty project @@ -117,17 +118,17 @@ impl CloneArgs { // step 4. collect the compilation metadata // if the etherscan api key is not set, we need to wait for 3 seconds between calls - p_println!(!opts.quiet => "Collecting the creation information of {} from Etherscan...", address); + sh_println!("Collecting the creation information of {address} from Etherscan...")?; + if etherscan_api_key.is_empty() { - p_println!(!opts.quiet => "Waiting for 5 seconds to avoid rate limit..."); + sh_warn!("Waiting for 5 seconds to avoid rate limit...")?; tokio::time::sleep(Duration::from_secs(5)).await; } - Self::collect_compilation_metadata(&meta, chain, address, &root, &client, opts.quiet) - .await?; + Self::collect_compilation_metadata(&meta, chain, address, &root, &client).await?; // step 5. git add and commit the changes if needed if !opts.no_commit { - let git = Git::new(&root).quiet(opts.quiet); + let git = Git::new(&root); git.add(Some("--all"))?; let msg = format!("chore: forge clone {address}"); git.commit(&msg)?; @@ -185,10 +186,9 @@ impl CloneArgs { address: Address, root: &PathBuf, client: &C, - quiet: bool, ) -> Result<()> { // compile the cloned contract - let compile_output = compile_project(root, quiet)?; + let compile_output = compile_project(root)?; let (main_file, main_artifact) = find_main_contract(&compile_output, &meta.contract_name)?; let main_file = main_file.strip_prefix(root)?.to_path_buf(); let storage_layout = @@ -546,11 +546,11 @@ fn dump_sources(meta: &Metadata, root: &PathBuf, no_reorg: bool) -> Result Result { +pub fn compile_project(root: &Path) -> Result { let mut config = Config::load_with_root(root).sanitized(); config.extra_output.push(ContractOutputSelection::StorageLayout); let project = config.project()?; - let compiler = ProjectCompiler::new().quiet_if(quiet); + let compiler = ProjectCompiler::new(); compiler.compile(&project) } @@ -618,7 +618,7 @@ mod tests { fn assert_successful_compilation(root: &PathBuf) -> ProjectCompileOutput { println!("project_root: {root:#?}"); - compile_project(root, false).expect("compilation failure") + compile_project(root).expect("compilation failure") } fn assert_compilation_result( @@ -720,7 +720,6 @@ mod tests { address, &project_root, &client, - false, ) .await .unwrap(); diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index fc325e39d99c9..652c5a10fed3b 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -2,7 +2,7 @@ use super::build::BuildArgs; use clap::Parser; use eyre::Result; use foundry_cli::utils::LoadConfig; -use foundry_common::{evm::EvmArgs, term::cli_warn}; +use foundry_common::evm::EvmArgs; use foundry_config::fix::fix_tomls; foundry_config::impl_figment_convert!(ConfigArgs, opts, evm_opts); @@ -34,7 +34,7 @@ impl ConfigArgs { pub fn run(self) -> Result<()> { if self.fix { for warning in fix_tomls() { - cli_warn!("{warning}"); + sh_warn!("{warning}")?; } return Ok(()) } @@ -57,7 +57,7 @@ impl ConfigArgs { config.to_string_pretty()? }; - println!("{s}"); + sh_println!("{s}")?; Ok(()) } } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index e21153d09c19b..56b2024e391bf 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -13,10 +13,7 @@ use forge::{ utils::IcPcMap, MultiContractRunnerBuilder, TestOptions, }; -use foundry_cli::{ - p_println, - utils::{LoadConfig, STATIC_FUZZ_SEED}, -}; +use foundry_cli::utils::{LoadConfig, STATIC_FUZZ_SEED}; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ artifacts::{sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode}, @@ -29,7 +26,6 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use yansi::Paint; // Loads project's figment and merges the build cli arguments into it foundry_config::impl_figment_convert!(CoverageArgs, test); @@ -74,9 +70,7 @@ impl CoverageArgs { let (mut config, evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; // install missing dependencies - if install::install_missing_dependencies(&mut config, self.test.build_args().silent) && - config.auto_detect_remappings - { + if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings config = self.load_config(); } @@ -88,10 +82,10 @@ impl CoverageArgs { config.ast = true; let (project, output) = self.build(&config)?; - p_println!(!self.test.build_args().silent => "Analysing contracts..."); + sh_println!("Analysing contracts...")?; let report = self.prepare(&project, &output)?; - p_println!(!self.test.build_args().silent => "Running tests..."); + sh_println!("Running tests...")?; self.collect(project, &output, report, Arc::new(config), evm_opts).await } @@ -112,14 +106,13 @@ impl CoverageArgs { } // print warning message - let msg = concat!( + sh_warn!("{}", concat!( "Warning! \"--ir-minimum\" flag enables viaIR with minimum optimization, \ which can result in inaccurate source mappings.\n", "Only use this flag as a workaround if you are experiencing \"stack too deep\" errors.\n", "Note that \"viaIR\" is only available in Solidity 0.8.13 and above.\n", "See more: https://github.com/foundry-rs/foundry/issues/3357", - ).yellow(); - p_println!(!self.test.build_args().silent => "{msg}"); + ))?; // Enable viaIR with minimum optimization // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 @@ -254,7 +247,7 @@ impl CoverageArgs { let outcome = self.test.run_tests(runner, config.clone(), verbosity, &filter, output).await?; - outcome.ensure_ok()?; + outcome.ensure_ok(false)?; // Add hit data to the coverage report let data = outcome.results.iter().flat_map(|(_, suite)| { diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index df42f458c0157..1962f41f6d0c4 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -108,8 +108,7 @@ impl CreateArgs { project.find_contract_path(&self.contract.name)? }; - let mut output = - compile::compile_target(&target_path, &project, self.json || self.opts.silent)?; + let mut output = compile::compile_target(&target_path, &project, self.json)?; let (abi, bin, _) = remove_contract(&mut output, &target_path, &self.contract.name)?; diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 9fd016ac70b0b..ef1cf0461697f 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -2,7 +2,7 @@ use clap::{Parser, ValueHint}; use eyre::{Context, Result}; use forge_fmt::{format_to, parse}; use foundry_cli::utils::{FoundryPathExt, LoadConfig}; -use foundry_common::{fs, term::cli_warn}; +use foundry_common::fs; use foundry_compilers::{compilers::solc::SolcLanguage, solc::SOLC_EXTENSIONS}; use foundry_config::{filter::expand_globs, impl_figment_convert_basic}; use rayon::prelude::*; @@ -111,7 +111,7 @@ impl FmtArgs { let mut lines = source[..loc.start().min(source.len())].split('\n'); let col = lines.next_back().unwrap().len() + 1; let row = lines.count() + 1; - cli_warn!("[{}:{}:{}] {}", name, row, col, warning); + sh_warn!("[{}:{}:{}] {}", name, row, col, warning)?; } } @@ -149,11 +149,11 @@ impl FmtArgs { Input::Stdin(source) => format(source, None).map(|diff| vec![diff]), Input::Paths(paths) => { if paths.is_empty() { - cli_warn!( + sh_warn!( "Nothing to format.\n\ HINT: If you are working outside of the project, \ try providing paths to your source files: `forge fmt `" - ); + )?; return Ok(()) } paths diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 1882eca60c64a..82f296e417e9a 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -1,7 +1,7 @@ use super::install::DependencyInstallOpts; use clap::{Parser, ValueHint}; use eyre::Result; -use foundry_cli::{p_println, utils::Git}; +use foundry_cli::utils::Git; use foundry_common::fs; use foundry_compilers::artifacts::remappings::Remapping; use foundry_config::Config; @@ -44,14 +44,14 @@ pub struct InitArgs { impl InitArgs { pub fn run(self) -> Result<()> { let Self { root, template, branch, opts, offline, force, vscode } = self; - let DependencyInstallOpts { shallow, no_git, no_commit, quiet } = opts; + let DependencyInstallOpts { shallow, no_git, no_commit } = opts; // create the root dir if it does not exist if !root.exists() { fs::create_dir_all(&root)?; } let root = dunce::canonicalize(root)?; - let git = Git::new(&root).quiet(quiet).shallow(shallow); + let git = Git::new(&root).shallow(shallow); // if a template is provided, then this command initializes a git repo, // fetches the template repo, and resets the git history to the head of the fetched @@ -62,7 +62,7 @@ impl InitArgs { } else { "https://github.com/".to_string() + &template }; - p_println!(!quiet => "Initializing {} from {}...", root.display(), template); + sh_println!("Initializing {} from {}...", root.display(), template)?; // initialize the git repository git.init()?; @@ -95,8 +95,7 @@ impl InitArgs { Run with the `--force` flag to initialize regardless." ); } - - p_println!(!quiet => "Target directory is not empty, but `--force` was specified"); + sh_warn!("Target directory is not empty, but `--force` was specified")?; } // ensure git status is clean before generating anything @@ -104,7 +103,7 @@ impl InitArgs { git.ensure_clean()?; } - p_println!(!quiet => "Initializing {}...", root.display()); + sh_println!("Initializing {}...", root.display())?; // make the dirs let src = root.join("src"); @@ -145,7 +144,7 @@ impl InitArgs { // install forge-std if !offline { if root.join("lib/forge-std").exists() { - p_println!(!quiet => "\"lib/forge-std\" already exists, skipping install...."); + sh_warn!("\"lib/forge-std\" already exists, skipping install...")?; self.opts.install(&mut config, vec![])?; } else { let dep = "https://github.com/foundry-rs/forge-std".parse()?; @@ -159,7 +158,7 @@ impl InitArgs { } } - p_println!(!quiet => " {} forge project", "Initialized".green()); + sh_println!("{}", " Initialized forge project".green())?; Ok(()) } } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 448d5b1ad7b7b..2567825d45a15 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -2,7 +2,6 @@ use clap::{Parser, ValueHint}; use eyre::{Context, Result}; use foundry_cli::{ opts::Dependency, - p_println, prompt, utils::{CommandUtils, Git, LoadConfig}, }; use foundry_common::fs; @@ -77,15 +76,11 @@ pub struct DependencyInstallOpts { /// Do not create a commit. #[arg(long)] pub no_commit: bool, - - /// Do not print any messages. - #[arg(short, long)] - pub quiet: bool, } impl DependencyInstallOpts { pub fn git(self, config: &Config) -> Git<'_> { - Git::from_config(config).quiet(self.quiet).shallow(self.shallow) + Git::from_config(config).shallow(self.shallow) } /// Installs all missing dependencies. @@ -94,17 +89,16 @@ impl DependencyInstallOpts { /// /// Returns true if any dependency was installed. pub fn install_missing_dependencies(mut self, config: &mut Config) -> bool { - let Self { quiet, .. } = self; let lib = config.install_lib_dir(); if self.git(config).has_missing_dependencies(Some(lib)).unwrap_or(false) { // The extra newline is needed, otherwise the compiler output will overwrite the message - p_println!(!quiet => "Missing dependencies found. Installing now...\n"); + let _ = sh_println!("Missing dependencies found. Installing now...\n"); self.no_commit = true; - if self.install(config, Vec::new()).is_err() && !quiet { - eprintln!( + if self.install(config, Vec::new()).is_err() { + let _ = sh_warn!( "{}", - "Your project has missing dependencies that could not be installed.".yellow() - ) + "Your project has missing dependencies that could not be installed." + ); } true } else { @@ -114,7 +108,7 @@ impl DependencyInstallOpts { /// Installs all dependencies pub fn install(self, config: &mut Config, dependencies: Vec) -> Result<()> { - let Self { no_git, no_commit, quiet, .. } = self; + let Self { no_git, no_commit, .. } = self; let git = self.git(config); @@ -126,7 +120,8 @@ impl DependencyInstallOpts { let root = Git::root_of(git.root)?; match git.has_submodules(Some(&root)) { Ok(true) => { - p_println!(!quiet => "Updating dependencies in {}", libs.display()); + sh_println!("Updating dependencies in {}", libs.display())?; + // recursively fetch all submodules (without fetching latest) git.submodule_update(false, false, false, true, Some(&libs))?; } @@ -148,7 +143,13 @@ impl DependencyInstallOpts { let rel_path = path .strip_prefix(git.root) .wrap_err("Library directory is not relative to the repository root")?; - p_println!(!quiet => "Installing {} in {} (url: {:?}, tag: {:?})", dep.name, path.display(), dep.url, dep.tag); + sh_println!( + "Installing {} in {} (url: {:?}, tag: {:?})", + dep.name, + path.display(), + dep.url, + dep.tag + )?; // this tracks the actual installed tag let installed_tag; @@ -190,14 +191,12 @@ impl DependencyInstallOpts { } } - if !quiet { - let mut msg = format!(" {} {}", "Installed".green(), dep.name); - if let Some(tag) = dep.tag.or(installed_tag) { - msg.push(' '); - msg.push_str(tag.as_str()); - } - println!("{msg}"); + let mut msg = format!(" {} {}", "Installed".green(), dep.name); + if let Some(tag) = dep.tag.or(installed_tag) { + msg.push(' '); + msg.push_str(tag.as_str()); } + sh_println!("{msg}")?; } // update `libs` in config if not included yet @@ -209,8 +208,8 @@ impl DependencyInstallOpts { } } -pub fn install_missing_dependencies(config: &mut Config, quiet: bool) -> bool { - DependencyInstallOpts { quiet, ..Default::default() }.install_missing_dependencies(config) +pub fn install_missing_dependencies(config: &mut Config) -> bool { + DependencyInstallOpts::default().install_missing_dependencies(config) } #[derive(Clone, Copy, Debug)] diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 0d7c2843a83f2..234ff48a5807a 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -96,7 +96,7 @@ impl GasSnapshotArgs { self.test.fuzz_seed = Some(U256::from_be_bytes(STATIC_FUZZ_SEED)); let outcome = self.test.execute_tests().await?; - outcome.ensure_ok()?; + outcome.ensure_ok(false)?; let tests = self.config.apply(outcome); if let Some(path) = self.diff { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 39f2b45557e3d..962c0104280aa 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -20,7 +20,7 @@ use foundry_cli::{ opts::CoreBuildArgs, utils::{self, LoadConfig}, }; -use foundry_common::{cli_warn, compile::ProjectCompiler, evm::EvmArgs, fs, shell}; +use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; use foundry_compilers::{ artifacts::output_selection::OutputSelection, compilers::{multi::MultiCompilerLanguage, CompilerSettings, Language}, @@ -118,11 +118,11 @@ pub struct TestArgs { /// Output test results in JSON format. #[arg(long, help_heading = "Display options")] - json: bool, + pub json: bool, /// Output test results as JUnit XML report. #[arg(long, conflicts_with_all(["json", "gas_report"]), help_heading = "Display options")] - junit: bool, + pub junit: bool, /// Stop running tests after the first failure. #[arg(long)] @@ -190,7 +190,6 @@ impl TestArgs { pub async fn run(self) -> Result { trace!(target: "forge::test", "executing test command"); - shell::set_shell(shell::Shell::from_args(self.opts.silent, self.json || self.junit))?; self.execute_tests().await } @@ -295,9 +294,7 @@ impl TestArgs { let mut project = config.project()?; // Install missing dependencies. - if install::install_missing_dependencies(&mut config, self.build_args().silent) && - config.auto_detect_remappings - { + if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings config = self.load_config(); project = config.project()?; @@ -308,9 +305,8 @@ impl TestArgs { let sources_to_compile = self.get_sources_to_compile(&config, &filter)?; - let compiler = ProjectCompiler::new() - .quiet_if(self.json || self.junit || self.opts.silent) - .files(sources_to_compile); + let compiler = + ProjectCompiler::new().quiet(self.json || self.junit).files(sources_to_compile); let output = compiler.compile(&project)?; @@ -377,10 +373,10 @@ impl TestArgs { let mut maybe_override_mt = |flag, maybe_regex: Option<&Option>| { if let Some(Some(regex)) = maybe_regex { - cli_warn!( + sh_warn!( "specifying argument for --{flag} is deprecated and will be removed in the future, \ use --match-test instead" - ); + )?; let test_pattern = &mut filter.args_mut().test_pattern; if test_pattern.is_some() { @@ -623,7 +619,7 @@ impl TestArgs { // Process individual test results, printing logs and traces when necessary. for (name, result) in tests { if !silent { - shell::println(result.short_result(name))?; + sh_println!("{}", result.short_result(name))?; // We only display logs at level 2 and above if verbosity >= 2 { @@ -678,9 +674,9 @@ impl TestArgs { } if !silent && !decoded_traces.is_empty() { - shell::println("Traces:")?; + sh_println!("Traces:")?; for trace in &decoded_traces { - shell::println(trace)?; + sh_println!("{trace}")?; } } @@ -785,7 +781,7 @@ impl TestArgs { // Print suite summary. if !silent { - shell::println(suite_result.summary())?; + sh_println!("{}", suite_result.summary())?; } // Add the suite result to the outcome. @@ -803,16 +799,16 @@ impl TestArgs { if let Some(gas_report) = gas_report { let finalized = gas_report.finalize(); - shell::println(&finalized)?; + sh_println!("{}", &finalized)?; outcome.gas_report = Some(finalized); } if !silent && !outcome.results.is_empty() { - shell::println(outcome.summary(duration))?; + sh_println!("{}", outcome.summary(duration))?; if self.summary { let mut summary_table = TestSummaryReporter::new(self.detailed); - shell::println("\n\nTest Summary:")?; + sh_println!("\n\nTest Summary:")?; summary_table.print_summary(&outcome); } } @@ -1079,7 +1075,6 @@ contract FooBarTest is DSTest { "--gas-report", "--root", &prj.root().to_string_lossy(), - "--silent", ]); let outcome = args.run().await.unwrap(); diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 925788ef8fdac..a78218e94e0ab 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate tracing; - use clap::{CommandFactory, Parser}; use clap_complete::generate; use eyre::Result; @@ -13,36 +10,44 @@ use cmd::{cache::CacheSubcommands, generate::GenerateSubcommands, watch}; mod opts; use opts::{Forge, ForgeSubcommand}; +#[macro_use] +extern crate foundry_common; + +#[macro_use] +extern crate tracing; + #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; -fn main() -> Result<()> { +fn main() { + if let Err(err) = run() { + let _ = foundry_common::Shell::get().error(&err); + std::process::exit(1); + } +} + +fn run() -> Result<()> { handler::install(); utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); - let opts = Forge::parse(); - init_execution_context(&opts.cmd); + let args = Forge::parse(); + args.shell.shell().set(); + init_execution_context(&args.cmd); - match opts.cmd { + match args.cmd { ForgeSubcommand::Test(cmd) => { if cmd.is_watch() { utils::block_on(watch::watch_test(cmd)) } else { + let silent = cmd.junit || cmd.json; let outcome = utils::block_on(cmd.run())?; - outcome.ensure_ok() + outcome.ensure_ok(silent) } } - ForgeSubcommand::Script(cmd) => { - // install the shell before executing the command - foundry_common::shell::set_shell(foundry_common::shell::Shell::from_args( - cmd.opts.silent, - cmd.json, - ))?; - utils::block_on(cmd.run_script()) - } + ForgeSubcommand::Script(cmd) => utils::block_on(cmd.run_script()), ForgeSubcommand::Coverage(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::Bind(cmd) => cmd.run(), ForgeSubcommand::Build(cmd) => { diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index d0dfecd3a132b..39bc89e63b8f9 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -8,6 +8,7 @@ use crate::cmd::{ use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; use forge_verify::{VerifyArgs, VerifyBytecodeArgs, VerifyCheckArgs}; +use foundry_cli::opts::ShellOpts; use std::path::PathBuf; const VERSION_MESSAGE: &str = concat!( @@ -30,6 +31,9 @@ const VERSION_MESSAGE: &str = concat!( pub struct Forge { #[command(subcommand)] pub cmd: ForgeSubcommand, + + #[clap(flatten)] + pub shell: ShellOpts, } #[derive(Subcommand)] diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 6c6552d05347b..0bec55153099d 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -1,6 +1,9 @@ #![doc = include_str!("../README.md")] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 4fb88dfd0b59d..5f83168bb50a4 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -151,20 +151,20 @@ impl TestOutcome { } /// Checks if there are any failures and failures are disallowed. - pub fn ensure_ok(&self) -> eyre::Result<()> { + pub fn ensure_ok(&self, silent: bool) -> eyre::Result<()> { let outcome = self; let failures = outcome.failures().count(); if outcome.allow_failure || failures == 0 { return Ok(()); } - if !shell::verbosity().is_normal() { + if shell::is_quiet() || silent { // TODO: Avoid process::exit std::process::exit(1); } - shell::println("")?; - shell::println("Failing tests:")?; + sh_println!()?; + sh_println!("Failing tests:")?; for (suite_name, suite) in outcome.results.iter() { let failed = suite.failed(); if failed == 0 { @@ -172,18 +172,18 @@ impl TestOutcome { } let term = if failed > 1 { "tests" } else { "test" }; - shell::println(format!("Encountered {failed} failing {term} in {suite_name}"))?; + sh_println!("Encountered {failed} failing {term} in {suite_name}")?; for (name, result) in suite.failures() { - shell::println(result.short_result(name))?; + sh_println!("{}", result.short_result(name))?; } - shell::println("")?; + sh_println!()?; } let successes = outcome.passed(); - shell::println(format!( + sh_println!( "Encountered a total of {} failing tests, {} tests succeeded", failures.to_string().red(), successes.to_string().green() - ))?; + )?; // TODO: Avoid process::exit std::process::exit(1); diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 81919241fa007..812754c725520 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -3,7 +3,35 @@ use foundry_config::Config; use foundry_test_utils::{forgetest, snapbox::IntoData, str}; use globset::Glob; -// tests that json is printed when --json is passed +forgetest_init!(can_parse_build_filters, |prj, cmd| { + prj.clear(); + + cmd.args(["build", "--names", "--skip", "tests", "scripts"]).assert_success().stdout_eq(str![ + [r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + compiler version: [..] + - Counter + +"#] + ]); +}); + +forgetest!(throws_on_conflicting_args, |prj, cmd| { + prj.clear(); + + cmd.args(["compile", "--format-json", "--quiet"]).assert_failure().stderr_eq(str![[r#" +error: the argument '--format-json' cannot be used with '--quiet' + +Usage: forge[..] build --format-json [PATHS]... + +For more information, try '--help'. + +"#]]); +}); + +// tests that json is printed when --format-json is passed forgetest!(compile_json, |prj, cmd| { prj.add_source( "jsonError", diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 78c18bbaf65d3..6177e973dce66 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -30,8 +30,26 @@ Commands: ... Options: - -h, --help Print help - -V, --version Print version + -h, --help + Print help (see a summary with '-h') + + -V, --version + Print version + +Display options: + --color + Log messages coloring + + Possible values: + - auto: Intelligently guess whether to use color output (default) + - always: Force color output + - never: Force disable color output + + -q, --quiet + Do not print log messages + + --verbose + Use verbose output Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html @@ -225,13 +243,20 @@ forgetest!(can_init_repo_with_config, |prj, cmd| { let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(!foundry_toml.exists()); - cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.args(["init", "--force"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); let s = read_string(&foundry_toml); @@ -253,8 +278,7 @@ forgetest!(can_detect_dirty_git_status_on_init, |prj, cmd| { cmd.current_dir(&nested); cmd.arg("init").assert_failure().stderr_eq(str![[r#" -Error: -The target directory is a part of or on its own an already initialized git repository, +Error: The target directory is a part of or on its own an already initialized git repository, and it requires clean working and staging areas, including no untracked files. Check the current git repository's status with `git status`. @@ -349,19 +373,24 @@ Initializing [..] from https://github.com/foundry-rs/forge-template... forgetest!(can_init_non_empty, |prj, cmd| { prj.create_file("README.md", "non-empty dir"); cmd.arg("init").arg(prj.root()).assert_failure().stderr_eq(str![[r#" -Error: -Cannot run `init` on a non-empty directory. +Error: Cannot run `init` on a non-empty directory. Run with the `--force` flag to initialize regardless. "#]]); - cmd.arg("--force").assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.arg("--force") + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); assert!(prj.root().join(".git").exists()); @@ -384,20 +413,26 @@ forgetest!(can_init_in_empty_repo, |prj, cmd| { assert!(root.join(".git").exists()); cmd.arg("init").arg(root).assert_failure().stderr_eq(str![[r#" -Error: -Cannot run `init` on a non-empty directory. +Error: Cannot run `init` on a non-empty directory. Run with the `--force` flag to initialize regardless. "#]]); - cmd.arg("--force").assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.arg("--force") + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); + assert!(root.join("lib/forge-std").exists()); }); @@ -420,20 +455,26 @@ forgetest!(can_init_in_non_empty_repo, |prj, cmd| { prj.create_file(".gitignore", "not foundry .gitignore"); cmd.arg("init").arg(root).assert_failure().stderr_eq(str![[r#" -Error: -Cannot run `init` on a non-empty directory. +Error: Cannot run `init` on a non-empty directory. Run with the `--force` flag to initialize regardless. "#]]); - cmd.arg("--force").assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.arg("--force") + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); + assert!(root.join("lib/forge-std").exists()); // not overwritten @@ -520,8 +561,7 @@ forgetest!(fail_init_nonexistent_template, |prj, cmd| { cmd.args(["init", "--template", "a"]).arg(prj.root()).assert_failure().stderr_eq(str![[r#" remote: Not Found fatal: repository 'https://github.com/a/' not found -Error: -git fetch exited with code 128 +Error: git fetch exited with code 128 "#]]); }); @@ -1072,8 +1112,7 @@ Warning: SPDX license identifier not provided in source file. Before publishing, prj.write_config(config); cmd.forge_fuse().args(["build", "--force"]).assert_failure().stderr_eq(str![[r#" -Error: -Compiler run failed: +Error: Compiler run failed: Warning (1878): SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. [FILE] @@ -1151,8 +1190,7 @@ contract CTest is DSTest { // `forge build --force` which should fail cmd.forge_fuse().args(["build", "--force"]).assert_failure().stderr_eq(str![[r#" -Error: -Compiler run failed: +Error: Compiler run failed: Error (2314): Expected ';' but got identifier [FILE]:7:19: | @@ -1168,8 +1206,7 @@ Error (2314): Expected ';' but got identifier // still errors cmd.forge_fuse().args(["build", "--force"]).assert_failure().stderr_eq(str![[r#" -Error: -Compiler run failed: +Error: Compiler run failed: Error (2314): Expected ';' but got identifier [FILE]:7:19: | @@ -1209,8 +1246,7 @@ Compiler run successful! // introduce the error again but building without force prj.add_source("CTest.t.sol", syntax_err).unwrap(); cmd.forge_fuse().arg("build").assert_failure().stderr_eq(str![[r#" -Error: -Compiler run failed: +Error: Compiler run failed: Error (2314): Expected ';' but got identifier [FILE]:7:19: | diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index c061af78f0eff..491171cad165d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -397,8 +397,7 @@ Compiler run successful! // fails to use solc that does not exist cmd.forge_fuse().args(["build", "--use", "this/solc/does/not/exist"]); cmd.assert_failure().stderr_eq(str![[r#" -Error: -`solc` this/solc/does/not/exist does not exist +Error: `solc` this/solc/does/not/exist does not exist "#]]); @@ -434,8 +433,7 @@ contract Foo { .unwrap(); cmd.arg("build").assert_failure().stderr_eq(str![[r#" -Error: -Compiler run failed: +Error: Compiler run failed: Error (6553): The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. [FILE]:6:8: | @@ -652,7 +650,7 @@ Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std fs::write(prj.root().join("lib").join("forge-std").join("foundry.toml"), faulty_toml).unwrap(); cmd.forge_fuse().args(["config"]).assert_success().stderr_eq(str![[r#" -warning: Found unknown config section in foundry.toml: [default] +Warning: Found unknown config section in foundry.toml: [default] This notation for profiles has been deprecated and may result in the profile not being registered in future versions. Please use [profile.default] instead or run `forge config --fix`. diff --git a/crates/forge/tests/cli/debug.rs b/crates/forge/tests/cli/debug.rs index bbed7dc723248..e8cd084187bbc 100644 --- a/crates/forge/tests/cli/debug.rs +++ b/crates/forge/tests/cli/debug.rs @@ -7,13 +7,20 @@ forgetest_async!( #[ignore = "ran manually"] manual_debug_setup, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.args(["init", "--force"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); prj.add_source("Counter2.sol", r#" diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 62f606eebab3e..c4a69223d5217 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -150,8 +150,7 @@ forgetest_async!(assert_exit_code_error_on_failure_script, |prj, cmd| { // run command and assert error exit code cmd.assert_failure().stderr_eq(str![[r#" -Error: -script failed: revert: failed +Error: script failed: revert: failed "#]]); }); @@ -167,8 +166,7 @@ forgetest_async!(assert_exit_code_error_on_failure_script_with_json, |prj, cmd| // run command and assert error exit code cmd.assert_failure().stderr_eq(str![[r#" -Error: -script failed: revert: failed +Error: script failed: revert: failed "#]]); }); @@ -201,7 +199,7 @@ contract DeployScript is Script { let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; let node_config = - NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())).silent(); + NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())); let (_api, handle) = spawn(node_config).await; let dev = handle.dev_accounts().next().unwrap(); cmd.set_current_dir(prj.root()); @@ -303,7 +301,7 @@ contract DeployScript is Script { let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; let node_config = - NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())).silent(); + NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())); let (_api, handle) = spawn(node_config).await; let private_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); @@ -493,7 +491,7 @@ contract DeployScript is Script { let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; let node_config = - NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())).silent(); + NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())); let (_api, handle) = spawn(node_config).await; let private_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); @@ -1012,13 +1010,20 @@ struct Transaction { // test we output arguments forgetest_async!(can_execute_script_with_arguments, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.args(["init", "--force"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); let (_api, handle) = spawn(NodeConfig::test()).await; @@ -1134,13 +1139,20 @@ SIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet // test we output arguments forgetest_async!(can_execute_script_with_arguments_nested_deploy, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.args(["init", "--force"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); let (_api, handle) = spawn(NodeConfig::test()).await; @@ -1301,13 +1313,20 @@ forgetest_async!(does_script_override_correctly, |prj, cmd| { }); forgetest_async!(assert_tx_origin_is_not_overritten, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.args(["init", "--force"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); let script = prj @@ -1382,13 +1401,20 @@ If you wish to simulate on-chain transactions pass a RPC URL. }); forgetest_async!(assert_can_create_multiple_contracts_with_correct_nonce, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.args(["init", "--force"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); let script = prj @@ -1609,20 +1635,26 @@ contract Script { cmd.arg("script").args([&script.to_string_lossy(), "--sig", "run"]); cmd.assert_failure().stderr_eq(str![[r#" -Error: -Multiple functions with the same name `run` found in the ABI +Error: Multiple functions with the same name `run` found in the ABI "#]]); }); forgetest_async!(can_decode_custom_errors, |prj, cmd| { - cmd.args(["init", "--force"]).arg(prj.root()).assert_success().stdout_eq(str![[r#" -Target directory is not empty, but `--force` was specified + cmd.args(["init", "--force"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" Initializing [..]... Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] Initialized forge project +"#]]) + .stderr_eq(str![[r#" +Warning: Target directory is not empty, but `--force` was specified +... + "#]]); let script = prj @@ -1652,8 +1684,7 @@ contract CustomErrorScript is Script { cmd.forge_fuse().arg("script").arg(script).args(["--tc", "CustomErrorScript"]); cmd.assert_failure().stderr_eq(str![[r#" -Error: -script failed: CustomError() +Error: script failed: CustomError() "#]]); }); @@ -1709,7 +1740,6 @@ Script ran successfully. success: bool true ## Setting up 1 EVM. -Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. ========================== @@ -1733,6 +1763,9 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. [SAVED_SENSITIVE_VALUES] +"#]]).stderr_eq(str![[r#" +Warning: Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. + "#]]); // Ensure that we can correctly estimate gas when base fee is zero but priority fee is not. @@ -1758,7 +1791,6 @@ Script ran successfully. success: bool true ## Setting up 1 EVM. -Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. ========================== @@ -1782,6 +1814,9 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. [SAVED_SENSITIVE_VALUES] +"#]]).stderr_eq(str![[r#" +Warning: Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. + "#]]); }); @@ -1826,7 +1861,6 @@ Script ran successfully. success: bool true ## Setting up 1 EVM. -Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. ========================== @@ -1850,6 +1884,9 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. [SAVED_SENSITIVE_VALUES] +"#]]).stderr_eq(str![[r#" +Warning: Script contains a transaction to 0x0000000000000000000000000000000000000000 which does not contain any code. + "#]]); }); @@ -1886,8 +1923,7 @@ contract SimpleScript is Script { ]); cmd.assert_failure().stderr_eq(str![[r#" -Error: -script failed: missing CREATE2 deployer +Error: script failed: missing CREATE2 deployer "#]]); }); @@ -2228,8 +2264,7 @@ contract ContractScript is Script { ) .unwrap(); cmd.arg("script").arg(script).args(["--fork-url", "https://public-node.testnet.rsk.co"]).assert_failure().stderr_eq(str![[r#" -Error: -Failed to deploy script: +Error: Failed to deploy script: backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set; "#]]); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 1c8ae36689db9..d76a6124f7bdb 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2191,22 +2191,19 @@ Warning: the following cheatcode(s) are deprecated and will be removed in future forgetest_init!(requires_single_test, |prj, cmd| { cmd.args(["test", "--debug"]).assert_failure().stderr_eq(str![[r#" -Error: -2 tests matched your criteria, but exactly 1 test must match in order to run the debugger. +Error: 2 tests matched your criteria, but exactly 1 test must match in order to run the debugger. Use --match-contract and --match-path to further limit the search. "#]]); cmd.forge_fuse().args(["test", "--flamegraph"]).assert_failure().stderr_eq(str![[r#" -Error: -2 tests matched your criteria, but exactly 1 test must match in order to generate a flamegraph. +Error: 2 tests matched your criteria, but exactly 1 test must match in order to generate a flamegraph. Use --match-contract and --match-path to further limit the search. "#]]); cmd.forge_fuse().args(["test", "--flamechart"]).assert_failure().stderr_eq(str![[r#" -Error: -2 tests matched your criteria, but exactly 1 test must match in order to generate a flamechart. +Error: 2 tests matched your criteria, but exactly 1 test must match in order to generate a flamechart. Use --match-contract and --match-path to further limit the search. @@ -2215,7 +2212,7 @@ Use --match-contract and --match-path to further limit the search. forgetest_init!(deprecated_regex_arg, |prj, cmd| { cmd.args(["test", "--decode-internal", "test_Increment"]).assert_success().stderr_eq(str![[r#" -warning: specifying argument for --decode-internal is deprecated and will be removed in the future, use --match-test instead +Warning: specifying argument for --decode-internal is deprecated and will be removed in the future, use --match-test instead "#]]); }); diff --git a/crates/script-sequence/src/lib.rs b/crates/script-sequence/src/lib.rs index 3aa5fc65a7666..11970e9478be4 100644 --- a/crates/script-sequence/src/lib.rs +++ b/crates/script-sequence/src/lib.rs @@ -1,5 +1,8 @@ //! Script Sequence and related types. +#[macro_use] +extern crate foundry_common; + pub mod sequence; pub mod transaction; diff --git a/crates/script-sequence/src/sequence.rs b/crates/script-sequence/src/sequence.rs index 080c725be69b8..e34b6d06a8655 100644 --- a/crates/script-sequence/src/sequence.rs +++ b/crates/script-sequence/src/sequence.rs @@ -2,7 +2,7 @@ use crate::transaction::TransactionWithMetadata; use alloy_primitives::{hex, map::HashMap, TxHash}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{fs, shell, TransactionMaybeSigned, SELECTOR_LEN}; +use foundry_common::{fs, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_compilers::ArtifactId; use foundry_config::Config; use serde::{Deserialize, Serialize}; @@ -127,8 +127,8 @@ impl ScriptSequence { } if !silent { - shell::println(format!("\nTransactions saved to: {}\n", path.display()))?; - shell::println(format!("Sensitive values saved to: {}\n", sensitive_path.display()))?; + sh_println!("\nTransactions saved to: {}\n", path.display())?; + sh_println!("Sensitive values saved to: {}\n", sensitive_path.display())?; } Ok(()) diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 82f28562d62d5..4058aa6c59b3f 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -21,7 +21,7 @@ use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_batch_support, has_different_gas_calc}; use foundry_common::{ provider::{get_http_provider, try_get_http_provider, RetryProvider}, - shell, TransactionMaybeSigned, + TransactionMaybeSigned, }; use foundry_config::Config; use futures::{future::join_all, StreamExt}; @@ -424,8 +424,8 @@ impl BundledState { seq_progress.inner.write().finish(); } - shell::println("\n\n==========================")?; - shell::println("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; + sh_println!("\n\n==========================")?; + sh_println!("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; Ok(BroadcastedState { args: self.args, diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 4b357ae23bd75..ef42740841b2a 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -188,10 +188,7 @@ impl PreprocessedState { ) .chain([target_path.to_path_buf()]); - let output = ProjectCompiler::new() - .quiet_if(args.opts.silent) - .files(sources_to_compile) - .compile(&project)?; + let output = ProjectCompiler::new().files(sources_to_compile).compile(&project)?; let mut target_id: Option = None; diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index d1191505a328d..97555694a6910 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -19,7 +19,7 @@ use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; use foundry_common::{ fmt::{format_token, format_token_raw}, provider::get_http_provider, - shell, ContractsByArtifact, + ContractsByArtifact, }; use foundry_config::{Config, NamedChain}; use foundry_debugger::Debugger; @@ -196,7 +196,7 @@ impl PreExecutionState { let sender = tx.transaction.from().expect("no sender"); if let Some(ns) = new_sender { if sender != ns { - shell::println("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; + sh_warn!("You have more than one deployer who could predeploy libraries. Using `--sender` instead.")?; return Ok(None); } } else if sender != self.script_config.evm_opts.sender { @@ -255,7 +255,7 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855", .map(|(_, chain)| *chain as u64) .format(", ") ); - shell::println(msg.yellow())?; + sh_warn!("{}", msg)?; } Ok(()) } @@ -301,10 +301,7 @@ impl ExecutedState { let rpc_data = RpcData::from_transactions(&txs); if rpc_data.is_multi_chain() { - shell::eprintln(format!( - "{}", - "Multi chain deployment is still under development. Use with caution.".yellow() - ))?; + sh_warn!("Multi chain deployment is still under development. Use with caution.")?; if !self.build_data.libraries.is_empty() { eyre::bail!( "Multi chain deployment does not support library linking at the moment." @@ -382,7 +379,7 @@ impl ExecutedState { } } Err(_) => { - shell::println(format!("{returned:?}"))?; + sh_err!("Failed to decode return value: {:x?}", returned)?; } } @@ -400,7 +397,7 @@ impl PreSimulationState { result, }; let json = serde_json::to_string(&json_result)?; - shell::println(json)?; + sh_println!("{json}")?; if !self.execution_result.success { return Err(eyre::eyre!( @@ -423,7 +420,7 @@ impl PreSimulationState { warn!(verbosity, "no traces"); } - shell::println("Traces:")?; + sh_println!("Traces:")?; for (kind, trace) in &result.traces { let should_include = match kind { TraceKind::Setup => verbosity >= 5, @@ -434,22 +431,22 @@ impl PreSimulationState { if should_include { let mut trace = trace.clone(); decode_trace_arena(&mut trace, decoder).await?; - shell::println(render_trace_arena(&trace))?; + sh_println!("{}", render_trace_arena(&trace))?; } } - shell::println(String::new())?; + sh_println!()?; } if result.success { - shell::println(format!("{}", "Script ran successfully.".green()))?; + sh_println!("{}", "Script ran successfully.".green())?; } if self.script_config.evm_opts.fork_url.is_none() { - shell::println(format!("Gas used: {}", result.gas_used))?; + sh_println!("Gas used: {}", result.gas_used)?; } if result.success && !result.returned.is_empty() { - shell::println("\n== Return ==")?; + sh_println!("\n== Return ==")?; match func.abi_decode_output(&result.returned, false) { Ok(decoded) => { for (index, (token, output)) in decoded.iter().zip(&func.outputs).enumerate() { @@ -464,24 +461,24 @@ impl PreSimulationState { } else { index.to_string() }; - shell::println(format!( - "{}: {internal_type} {}", - label.trim_end(), - format_token(token) - ))?; + sh_println!( + "{label}: {internal_type} {value}", + label = label.trim_end(), + value = format_token(token) + )?; } } Err(_) => { - shell::println(format!("{:x?}", (&result.returned)))?; + sh_err!("{:x?}", (&result.returned))?; } } } let console_logs = decode_console_logs(&result.logs); if !console_logs.is_empty() { - shell::println("\n== Logs ==")?; + sh_println!("\n== Logs ==")?; for log in console_logs { - shell::println(format!(" {log}"))?; + sh_println!(" {log}")?; } } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 49650584fd712..ec19c0bf97162 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -5,6 +5,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; @@ -27,7 +30,7 @@ use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ abi::{encode_function_args, get_func}, evm::{Breakpoints, EvmArgs}, - shell, ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, + ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::ArtifactId; use foundry_config::{ @@ -52,7 +55,6 @@ use foundry_evm::{ use foundry_wallets::MultiWalletOpts; use serde::Serialize; use std::path::PathBuf; -use yansi::Paint; mod broadcast; mod build; @@ -257,7 +259,7 @@ impl ScriptArgs { return match pre_simulation.args.dump.clone() { Some(ref path) => pre_simulation.run_debug_file_dumper(path), None => pre_simulation.run_debugger(), - } + }; } if pre_simulation.args.json { @@ -279,7 +281,7 @@ impl ScriptArgs { // Check if there are any missing RPCs and exit early to avoid hard error. if pre_simulation.execution_artifacts.rpc_data.missing_rpc { - shell::println("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; + sh_println!("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; return Ok(()); } @@ -293,7 +295,7 @@ impl ScriptArgs { // Exit early in case user didn't provide any broadcast/verify related flags. if !bundled.args.should_broadcast() { - shell::println("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; + sh_println!("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; return Ok(()); } @@ -436,12 +438,9 @@ impl ScriptArgs { if deployment_size > max_size { prompt_user = self.should_broadcast(); - shell::println(format!( - "{}", - format!( - "`{name}` is above the contract size limit ({deployment_size} > {max_size})." - ).red() - ))?; + sh_err!( + "`{name}` is above the contract size limit ({deployment_size} > {max_size})." + )?; } } } diff --git a/crates/script/src/multi_sequence.rs b/crates/script/src/multi_sequence.rs index 0aabcf79ac3f3..ec2f03ae9855b 100644 --- a/crates/script/src/multi_sequence.rs +++ b/crates/script/src/multi_sequence.rs @@ -146,8 +146,8 @@ impl MultiChainSequence { } if !silent { - println!("\nTransactions saved to: {}\n", self.path.display()); - println!("Sensitive details saved to: {}\n", self.sensitive_path.display()); + sh_println!("\nTransactions saved to: {}\n", self.path.display())?; + sh_println!("Sensitive details saved to: {}\n", self.sensitive_path.display())?; } Ok(()) diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 44788672a2da7..6eb11d7f91176 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -16,7 +16,7 @@ use eyre::{Context, Result}; use forge_script_sequence::{ScriptSequence, TransactionWithMetadata}; use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_different_gas_calc, now}; -use foundry_common::{get_contract_name, shell, ContractData}; +use foundry_common::{get_contract_name, ContractData}; use foundry_evm::traces::{decode_trace_arena, render_trace_arena}; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; @@ -24,7 +24,6 @@ use std::{ collections::{BTreeMap, VecDeque}, sync::Arc, }; -use yansi::Paint; /// Same as [ExecutedState](crate::execute::ExecutedState), but also contains [ExecutionArtifacts] /// which are obtained from [ScriptResult]. @@ -75,7 +74,7 @@ impl PreSimulationState { .collect::>>()?; if self.args.skip_simulation { - shell::println("\nSKIPPING ON CHAIN SIMULATION.")?; + sh_println!("\nSKIPPING ON CHAIN SIMULATION.")?; } else { transactions = self.simulate_and_fill(transactions).await?; } @@ -171,7 +170,9 @@ impl PreSimulationState { if let Some(tx) = tx { if is_noop_tx { let to = tx.contract_address.unwrap(); - shell::println(format!("Script contains a transaction to {to} which does not contain any code.").yellow())?; + sh_warn!( + "Script contains a transaction to {to} which does not contain any code." + )?; // Only prompt if we're broadcasting and we've not disabled interactivity. if self.args.should_broadcast() && @@ -218,11 +219,10 @@ impl PreSimulationState { /// Build [ScriptRunner] forking given RPC for each RPC used in the script. async fn build_runners(&self) -> Result> { let rpcs = self.execution_artifacts.rpc_data.total_rpcs.clone(); - if !shell::verbosity().is_silent() { - let n = rpcs.len(); - let s = if n != 1 { "s" } else { "" }; - println!("\n## Setting up {n} EVM{s}."); - } + + let n = rpcs.len(); + let s = if n != 1 { "s" } else { "" }; + sh_println!("\n## Setting up {n} EVM{s}.")?; let futs = rpcs.into_iter().map(|rpc| async move { let mut script_config = self.script_config.clone(); @@ -348,24 +348,24 @@ impl FilledTransactionsState { provider_info.gas_price()? }; - shell::println("\n==========================")?; - shell::println(format!("\nChain {}", provider_info.chain))?; + sh_println!("\n==========================")?; + sh_println!("\nChain {}", provider_info.chain)?; - shell::println(format!( + sh_println!( "\nEstimated gas price: {} gwei", format_units(per_gas, 9) .unwrap_or_else(|_| "[Could not calculate]".to_string()) .trim_end_matches('0') .trim_end_matches('.') - ))?; - shell::println(format!("\nEstimated total gas used for script: {total_gas}"))?; - shell::println(format!( + )?; + sh_println!("\nEstimated total gas used for script: {total_gas}")?; + sh_println!( "\nEstimated amount required: {} ETH", format_units(total_gas.saturating_mul(per_gas), 18) .unwrap_or_else(|_| "[Could not calculate]".to_string()) .trim_end_matches('0') - ))?; - shell::println("\n==========================")?; + )?; + sh_println!("\n==========================")?; } } diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index 9b018573261f0..f15e91d5af781 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -226,11 +226,9 @@ impl ScriptTester { trace!(target: "tests", "STDOUT\n{stdout}\n\nSTDERR\n{stderr}"); - let output = if expected.is_err() { &stderr } else { &stdout }; - if !output.contains(expected.as_str()) { - let which = if expected.is_err() { "stderr" } else { "stdout" }; + if !stdout.contains(expected.as_str()) && !stderr.contains(expected.as_str()) { panic!( - "--STDOUT--\n{stdout}\n\n--STDERR--\n{stderr}\n\n--EXPECTED--\n{:?} in {which}", + "--STDOUT--\n{stdout}\n\n--STDERR--\n{stderr}\n\n--EXPECTED--\n{:?} not found in stdout or stderr", expected.as_str() ); } @@ -286,7 +284,7 @@ impl ScriptOutcome { Self::OkNoEndpoint => "If you wish to simulate on-chain transactions pass a RPC URL.", Self::OkSimulation => "SIMULATION COMPLETE. To broadcast these", Self::OkBroadcast => "ONCHAIN EXECUTION COMPLETE & SUCCESSFUL", - Self::WarnSpecifyDeployer => "You have more than one deployer who could predeploy libraries. Using `--sender` instead.", + Self::WarnSpecifyDeployer => "Warning: You have more than one deployer who could predeploy libraries. Using `--sender` instead.", Self::MissingSender => "You seem to be using Foundry's default sender. Be sure to set your own --sender", Self::MissingWallet => "No associated wallet", Self::StaticCallNotAllowed => "staticcall`s are not allowed after `broadcast`; use `startBroadcast` instead", diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 661eb5c8dcb33..02ca28c200665 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -299,7 +299,7 @@ impl VerifyBytecodeArgs { ); if self.json { - println!("{}", serde_json::to_string(&json_results)?); + sh_println!("{}", serde_json::to_string(&json_results)?)?; } return Ok(()); @@ -395,7 +395,7 @@ impl VerifyBytecodeArgs { &config, ); if self.json { - println!("{}", serde_json::to_string(&json_results)?); + sh_println!("{}", serde_json::to_string(&json_results)?)?; } return Ok(()); } @@ -498,7 +498,7 @@ impl VerifyBytecodeArgs { } if self.json { - println!("{}", serde_json::to_string(&json_results)?); + sh_println!("{}", serde_json::to_string(&json_results)?)?; } Ok(()) } diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 8b8c2bc3549fa..9b5b1fa345d31 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -17,7 +17,6 @@ use foundry_cli::utils::{get_provider, read_constructor_args_file, LoadConfig}; use foundry_common::{ abi::encode_function_args, retry::{Retry, RetryError}, - shell, }; use foundry_compilers::{artifacts::BytecodeObject, Artifact}; use foundry_config::{Chain, Config}; @@ -424,7 +423,7 @@ impl EtherscanVerificationProvider { if maybe_creation_code.starts_with(bytecode) { let constructor_args = &maybe_creation_code[bytecode.len()..]; let constructor_args = hex::encode(constructor_args); - shell::println(format!("Identified constructor arguments: {constructor_args}"))?; + sh_println!("Identified constructor arguments: {constructor_args}")?; Ok(constructor_args) } else { eyre::bail!("Local bytecode doesn't match on-chain bytecode") @@ -569,6 +568,7 @@ mod tests { cmd.args(["build", "--force"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] +... [SOLC_VERSION] [ELAPSED] Compiler run successful! diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rs index 9d2372964850e..a46fdba901550 100644 --- a/crates/verify/src/lib.rs +++ b/crates/verify/src/lib.rs @@ -3,6 +3,12 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + +#[macro_use] +extern crate tracing; + mod etherscan; pub mod provider; @@ -21,6 +27,3 @@ pub use verify::{VerifierArgs, VerifyArgs, VerifyCheckArgs}; mod types; mod utils; - -#[macro_use] -extern crate tracing; From 2cdf718ef9c114a8f551bbad119b5f04c7bf3c2a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:11:42 +0300 Subject: [PATCH 1585/1963] chore: refactor debugger dump code (#9170) chore: refactor debugger code --- crates/debugger/src/context.rs | 12 --- crates/debugger/src/debugger.rs | 12 ++- .../{file_dumper/mod.rs => file_dumper.rs} | 95 ++++++++++--------- crates/debugger/src/lib.rs | 2 +- crates/debugger/src/tui/context.rs | 2 +- crates/debugger/src/tui/mod.rs | 2 +- 6 files changed, 61 insertions(+), 64 deletions(-) delete mode 100644 crates/debugger/src/context.rs rename crates/debugger/src/{file_dumper/mod.rs => file_dumper.rs} (94%) diff --git a/crates/debugger/src/context.rs b/crates/debugger/src/context.rs deleted file mode 100644 index 1d89b549e82e3..0000000000000 --- a/crates/debugger/src/context.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::DebugNode; -use alloy_primitives::map::AddressHashMap; -use foundry_common::evm::Breakpoints; -use foundry_evm_traces::debug::ContractSources; - -pub struct DebuggerContext { - pub debug_arena: Vec, - pub identified_contracts: AddressHashMap, - /// Source map of contract sources - pub contracts_sources: ContractSources, - pub breakpoints: Breakpoints, -} diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index 723a4cb85f4f6..0e4de437c844a 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,14 +1,20 @@ //! Debugger implementation. -use crate::{ - context::DebuggerContext, tui::TUI, DebugNode, DebuggerBuilder, ExitReason, FileDumper, -}; +use crate::{tui::TUI, DebugNode, DebuggerBuilder, ExitReason, FileDumper}; use alloy_primitives::map::AddressHashMap; use eyre::Result; use foundry_common::evm::Breakpoints; use foundry_evm_traces::debug::ContractSources; use std::path::PathBuf; +pub struct DebuggerContext { + pub debug_arena: Vec, + pub identified_contracts: AddressHashMap, + /// Source map of contract sources + pub contracts_sources: ContractSources, + pub breakpoints: Breakpoints, +} + pub struct Debugger { context: DebuggerContext, } diff --git a/crates/debugger/src/file_dumper/mod.rs b/crates/debugger/src/file_dumper.rs similarity index 94% rename from crates/debugger/src/file_dumper/mod.rs rename to crates/debugger/src/file_dumper.rs index 969ad882f5931..909530c421595 100644 --- a/crates/debugger/src/file_dumper/mod.rs +++ b/crates/debugger/src/file_dumper.rs @@ -1,6 +1,6 @@ -//! The file dumper implementation +//! The debug file dumper implementation. -use crate::{context::DebuggerContext, DebugNode}; +use crate::{debugger::DebuggerContext, DebugNode}; use alloy_primitives::Address; use eyre::Result; use foundry_common::fs::write_json_file; @@ -12,9 +12,11 @@ use foundry_evm_traces::debug::{ArtifactData, ContractSources, SourceData}; use serde::Serialize; use std::{collections::HashMap, ops::Deref, path::PathBuf}; -/// The file dumper +/// Generates and writes debugger dump in a json file. pub struct FileDumper<'a> { + /// Path to json file to write dump into. path: &'a PathBuf, + /// Debugger context to generate dump for. debugger_context: &'a mut DebuggerContext, } @@ -30,6 +32,13 @@ impl<'a> FileDumper<'a> { } } +/// Holds info of debugger dump. +#[derive(Serialize)] +struct DebuggerDump { + contracts: ContractsDump, + debug_arena: Vec, +} + impl DebuggerDump { fn from(debugger_context: &DebuggerContext) -> Self { Self { @@ -39,12 +48,6 @@ impl DebuggerDump { } } -#[derive(Serialize)] -struct DebuggerDump { - contracts: ContractsDump, - debug_arena: Vec, -} - #[derive(Serialize)] pub struct SourceElementDump { offset: u32, @@ -54,6 +57,22 @@ pub struct SourceElementDump { modifier_depth: u32, } +impl SourceElementDump { + pub fn new(v: &SourceElement) -> Self { + Self { + offset: v.offset(), + length: v.length(), + index: v.index_i32(), + jump: match v.jump() { + Jump::In => 0, + Jump::Out => 1, + Jump::Regular => 2, + }, + modifier_depth: v.modifier_depth(), + } + } +} + #[derive(Serialize)] struct ContractsDump { // Map of call address to contract name @@ -61,29 +80,6 @@ struct ContractsDump { sources: ContractsSourcesDump, } -#[derive(Serialize)] -struct ContractsSourcesDump { - sources_by_id: HashMap>, - artifacts_by_name: HashMap>, -} - -#[derive(Serialize)] -struct SourceDataDump { - source: String, - language: MultiCompilerLanguage, - path: PathBuf, -} - -#[derive(Serialize)] -struct ArtifactDataDump { - pub source_map: Option>, - pub source_map_runtime: Option>, - pub pc_ic_map: Option>, - pub pc_ic_map_runtime: Option>, - pub build_id: String, - pub file_id: u32, -} - impl ContractsDump { pub fn new(debugger_context: &DebuggerContext) -> Self { Self { @@ -97,6 +93,12 @@ impl ContractsDump { } } +#[derive(Serialize)] +struct ContractsSourcesDump { + sources_by_id: HashMap>, + artifacts_by_name: HashMap>, +} + impl ContractsSourcesDump { pub fn new(contracts_sources: &ContractSources) -> Self { Self { @@ -124,26 +126,27 @@ impl ContractsSourcesDump { } } +#[derive(Serialize)] +struct SourceDataDump { + source: String, + language: MultiCompilerLanguage, + path: PathBuf, +} + impl SourceDataDump { pub fn new(v: &SourceData) -> Self { Self { source: v.source.deref().clone(), language: v.language, path: v.path.clone() } } } -impl SourceElementDump { - pub fn new(v: &SourceElement) -> Self { - Self { - offset: v.offset(), - length: v.length(), - index: v.index_i32(), - jump: match v.jump() { - Jump::In => 0, - Jump::Out => 1, - Jump::Regular => 2, - }, - modifier_depth: v.modifier_depth(), - } - } +#[derive(Serialize)] +struct ArtifactDataDump { + pub source_map: Option>, + pub source_map_runtime: Option>, + pub pc_ic_map: Option>, + pub pc_ic_map_runtime: Option>, + pub build_id: String, + pub file_id: u32, } impl ArtifactDataDump { diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index db8476e4056e7..aa561973cc635 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -11,12 +11,12 @@ extern crate tracing; mod op; mod builder; -mod context; mod debugger; mod file_dumper; mod tui; mod node; + pub use node::DebugNode; pub use builder::DebuggerBuilder; diff --git a/crates/debugger/src/tui/context.rs b/crates/debugger/src/tui/context.rs index 80e16046c212e..0c61a1fcd41c4 100644 --- a/crates/debugger/src/tui/context.rs +++ b/crates/debugger/src/tui/context.rs @@ -1,6 +1,6 @@ //! Debugger context and event handler implementation. -use crate::{context::DebuggerContext, DebugNode, ExitReason}; +use crate::{debugger::DebuggerContext, DebugNode, ExitReason}; use alloy_primitives::{hex, Address}; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; use foundry_evm_core::buffer::BufferKind; diff --git a/crates/debugger/src/tui/mod.rs b/crates/debugger/src/tui/mod.rs index 69ec0c201a06a..abc7c4a9706e6 100644 --- a/crates/debugger/src/tui/mod.rs +++ b/crates/debugger/src/tui/mod.rs @@ -19,7 +19,7 @@ use std::{ }; mod context; -use crate::context::DebuggerContext; +use crate::debugger::DebuggerContext; use context::TUIContext; mod draw; From 4c84dc7d9150d85794363402f959c3fe5ee28a55 Mon Sep 17 00:00:00 2001 From: Ilias Tsatiris Date: Wed, 23 Oct 2024 18:16:09 +0300 Subject: [PATCH 1586/1963] fix(anvil): Apply state overrides in debug_traceCall (#9172) * fix(anvil): Apply state overrides in debug_traceCall Co-authored-by: mixy1 * chore(anvil): fix formatting --------- Co-authored-by: mixy1 --- crates/anvil/src/eth/backend/mem/mod.rs | 9 ++++- crates/anvil/tests/it/traces.rs | 50 ++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 5300b717a3c1d..34d37d666d444 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1430,13 +1430,20 @@ impl Backend { block_request: Option, opts: GethDebugTracingCallOptions, ) -> Result { - let GethDebugTracingCallOptions { tracing_options, block_overrides: _, state_overrides: _ } = + let GethDebugTracingCallOptions { tracing_options, block_overrides: _, state_overrides } = opts; let GethDebugTracingOptions { config, tracer, tracer_config, .. } = tracing_options; self.with_database_at(block_request, |state, block| { let block_number = block.number; + let state = if let Some(overrides) = state_overrides { + Box::new(state::apply_state_override(overrides, state)?) + as Box + } else { + state + }; + if let Some(tracer) = tracer { return match tracer { GethDebugTracerType::BuiltInTracer(tracer) => match tracer { diff --git a/crates/anvil/tests/it/traces.rs b/crates/anvil/tests/it/traces.rs index e6fc2c39234d2..79448ad836921 100644 --- a/crates/anvil/tests/it/traces.rs +++ b/crates/anvil/tests/it/traces.rs @@ -5,12 +5,16 @@ use crate::{ }; use alloy_eips::BlockId; use alloy_network::{EthereumWallet, TransactionBuilder}; -use alloy_primitives::{hex, Address, Bytes, U256}; +use alloy_primitives::{ + hex::{self, FromHex}, + Address, Bytes, U256, +}; use alloy_provider::{ ext::{DebugApi, TraceApi}, Provider, }; use alloy_rpc_types::{ + state::StateOverride, trace::{ filter::{TraceFilter, TraceFilterMode}, geth::{ @@ -259,6 +263,50 @@ async fn test_call_tracer_debug_trace_call() { } } +#[tokio::test(flavor = "multi_thread")] +async fn test_debug_trace_call_state_override() { + let (_api, handle) = spawn(NodeConfig::test()).await; + let wallets = handle.dev_wallets().collect::>(); + + let tx = TransactionRequest::default() + .from(wallets[1].address()) + .to("0x1234567890123456789012345678901234567890".parse().unwrap()); + + let override_json = r#"{ + "0x1234567890123456789012345678901234567890": { + "balance": "0x01", + "code": "0x30315f5260205ff3" + } + }"#; + + let state_override: StateOverride = serde_json::from_str(override_json).unwrap(); + + let tx_traces = handle + .http_provider() + .debug_trace_call( + tx.clone(), + BlockId::latest(), + GethDebugTracingCallOptions::default() + .with_tracing_options(GethDebugTracingOptions::default()) + .with_state_overrides(state_override), + ) + .await + .unwrap(); + + match tx_traces { + GethTrace::Default(trace_res) => { + assert_eq!( + trace_res.return_value, + Bytes::from_hex("0000000000000000000000000000000000000000000000000000000000000001") + .unwrap() + ); + } + _ => { + unreachable!() + } + } +} + // #[tokio::test(flavor = "multi_thread")] async fn test_trace_address_fork() { From b1e93654348a0f31effa34790adae18865b14aa8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:37:54 +0300 Subject: [PATCH 1587/1963] feat(fmt): add `all_params` config - same as `all` but split single param too (#9176) fet(fmt): add all_params config - smae as all but split single param too --- crates/config/src/fmt.rs | 2 + crates/fmt/src/formatter.rs | 13 +- .../FunctionDefinition/all-params.fmt.sol | 736 ++++++++++++++++++ 3 files changed, 747 insertions(+), 4 deletions(-) create mode 100644 crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol diff --git a/crates/config/src/fmt.rs b/crates/config/src/fmt.rs index 44fefe7d469e8..69381171989be 100644 --- a/crates/config/src/fmt.rs +++ b/crates/config/src/fmt.rs @@ -162,6 +162,8 @@ pub enum MultilineFuncHeaderStyle { /// If function params or attrs are multiline. /// split the rest All, + /// Same as `All` but writes function params multiline even when there is a single param. + AllParams, } impl Default for FormatterConfig { diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 02d62f70567a8..9213235fe331b 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1628,7 +1628,8 @@ impl<'a, W: Write> Formatter<'a, W> { fmt.config.multiline_func_header, MultilineFuncHeaderStyle::ParamsFirst | MultilineFuncHeaderStyle::ParamsFirstMulti | - MultilineFuncHeaderStyle::All + MultilineFuncHeaderStyle::All | + MultilineFuncHeaderStyle::AllParams ); params_multiline = should_multiline || multiline || @@ -1637,11 +1638,12 @@ impl<'a, W: Write> Formatter<'a, W> { ¶ms, ",", )?; - // Write new line if we have only one parameter and params first set. + // Write new line if we have only one parameter and params first all multi set. if params.len() == 1 && matches!( fmt.config.multiline_func_header, - MultilineFuncHeaderStyle::ParamsFirst + MultilineFuncHeaderStyle::ParamsFirst | + MultilineFuncHeaderStyle::AllParams ) { writeln!(fmt.buf())?; @@ -1736,7 +1738,10 @@ impl<'a, W: Write> Formatter<'a, W> { let should_multiline = header_multiline && if params_multiline { - matches!(self.config.multiline_func_header, MultilineFuncHeaderStyle::All) + matches!( + self.config.multiline_func_header, + MultilineFuncHeaderStyle::All | MultilineFuncHeaderStyle::AllParams + ) } else { matches!( self.config.multiline_func_header, diff --git a/crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol b/crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol new file mode 100644 index 0000000000000..f723b00496b63 --- /dev/null +++ b/crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol @@ -0,0 +1,736 @@ +// config: line_length = 60 +// config: multiline_func_header = "all_params" +interface FunctionInterfaces { + function noParamsNoModifiersNoReturns(); + + function oneParam( + uint256 x + ); + + function oneModifier() modifier1; + + function oneReturn() returns (uint256 y1); + + // function prefix + function withComments( // function name postfix + // x1 prefix + uint256 x1, // x1 postfix + // x2 prefix + uint256 x2, // x2 postfix + // x2 postfix2 + /* + multi-line x3 prefix + */ + uint256 x3 // x3 postfix + ) + // public prefix + public // public postfix + // pure prefix + pure // pure postfix + // modifier1 prefix + modifier1 // modifier1 postfix + // modifier2 prefix + modifier2 /* + mutliline modifier2 postfix + */ + // modifier3 prefix + modifier3 // modifier3 postfix + returns ( + // y1 prefix + uint256 y1, // y1 postfix + // y2 prefix + uint256 y2, // y2 postfix + // y3 prefix + uint256 y3 + ); // y3 postfix + // function postfix + + /*////////////////////////////////////////////////////////////////////////// + TEST + //////////////////////////////////////////////////////////////////////////*/ + function manyParams( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ); + + function manyModifiers() + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10; + + function manyReturns() + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function someParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3; + + function someParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + returns (uint256 y1, uint256 y2, uint256 y3); + + function someModifiersSomeReturns() + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3); + + function someParamSomeModifiersSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3); + + function someParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10; + + function someParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function manyParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3; + + function manyParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + returns (uint256 y1, uint256 y2, uint256 y3); + + function manyParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10; + + function manyParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function manyParamsManyModifiersManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ); + + function modifierOrderCorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderCorrect02() + private + pure + virtual + modifier1 + modifier2 + returns (string); + + function modifierOrderCorrect03() + external + payable + override + modifier1 + modifier2 + returns (address); + + function modifierOrderCorrect04() + internal + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect02() + external + virtual + override + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect03() + internal + pure + virtual + modifier1 + modifier2 + returns (uint256); + + function modifierOrderIncorrect04() + external + payable + override + modifier1 + modifier2 + returns (uint256); +} + +contract FunctionDefinitions { + function() external {} + fallback() external {} + + function() external payable {} + fallback() external payable {} + receive() external payable {} + + function noParamsNoModifiersNoReturns() { + a = 1; + } + + function oneParam( + uint256 x + ) { + a = 1; + } + + function oneModifier() modifier1 { + a = 1; + } + + function oneReturn() returns (uint256 y1) { + a = 1; + } + + function manyParams( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) { + a = 1; + } + + function manyModifiers() + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + { + a = 1; + } + + function manyReturns() + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function someParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + { + a = 1; + } + + function someParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + returns (uint256 y1, uint256 y2, uint256 y3) + { + a = 1; + } + + function someModifiersSomeReturns() + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3) + { + a = 1; + } + + function someParamSomeModifiersSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + returns (uint256 y1, uint256 y2, uint256 y3) + { + a = 1; + } + + function someParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + { + a = 1; + } + + function someParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function manyParamsSomeModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3 + { + a = 1; + } + + function manyParamsSomeReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + returns (uint256 y1, uint256 y2, uint256 y3) + { + a = 1; + } + + function manyParamsManyModifiers( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + public + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + { + a = 1; + } + + function manyParamsManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function manyParamsManyModifiersManyReturns( + uint256 x1, + uint256 x2, + uint256 x3, + uint256 x4, + uint256 x5, + uint256 x6, + uint256 x7, + uint256 x8, + uint256 x9, + uint256 x10 + ) + modifier1 + modifier2 + modifier3 + modifier4 + modifier5 + modifier6 + modifier7 + modifier8 + modifier9 + modifier10 + returns ( + uint256 y1, + uint256 y2, + uint256 y3, + uint256 y4, + uint256 y5, + uint256 y6, + uint256 y7, + uint256 y8, + uint256 y9, + uint256 y10 + ) + { + a = 1; + } + + function modifierOrderCorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderCorrect02() + private + pure + virtual + modifier1 + modifier2 + returns (string) + { + a = 1; + } + + function modifierOrderCorrect03() + external + payable + override + modifier1 + modifier2 + returns (address) + { + a = 1; + } + + function modifierOrderCorrect04() + internal + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect01() + public + view + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect02() + external + virtual + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect03() + internal + pure + virtual + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + function modifierOrderIncorrect04() + external + payable + override + modifier1 + modifier2 + returns (uint256) + { + a = 1; + } + + fallback() external payable virtual {} + receive() external payable virtual {} +} + +contract FunctionOverrides is + FunctionInterfaces, + FunctionDefinitions +{ + function noParamsNoModifiersNoReturns() override { + a = 1; + } + + function oneParam( + uint256 x + ) + override( + FunctionInterfaces, + FunctionDefinitions, + SomeOtherFunctionContract, + SomeImport.AndAnotherFunctionContract + ) + { + a = 1; + } +} From 9fe891ab5babbdc2891c67d14d6c75ea1ca4b19c Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 24 Oct 2024 08:01:18 +0300 Subject: [PATCH 1588/1963] fix(chisel): on edit fail command only if execution failed (#9155) --- crates/chisel/src/dispatcher.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 22ad242d091f1..6805edd45e43b 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -719,18 +719,20 @@ impl ChiselDispatcher { } } - // If the contract execution failed, continue on without - // updating the source. - DispatchResult::CommandFailed(Self::make_error( - "Failed to execute edited contract!", - )) - } else { - // the code could be compiled, save it - *self.source_mut() = new_session_source; - DispatchResult::CommandSuccess(Some(String::from( - "Successfully edited `run()` function's body!", - ))) + if failed { + // If the contract execution failed, continue on without + // updating the source. + return DispatchResult::CommandFailed(Self::make_error( + "Failed to execute edited contract!", + )); + } } + + // the code could be compiled, save it + *self.source_mut() = new_session_source; + DispatchResult::CommandSuccess(Some(String::from( + "Successfully edited `run()` function's body!", + ))) } Err(_) => { DispatchResult::CommandFailed("The code could not be compiled".to_string()) From a41bd85b7ae16135219dd317f05ebad3ab0277a5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 24 Oct 2024 07:59:56 +0200 Subject: [PATCH 1589/1963] chore: cleanup shell module (#9178) --- crates/common/src/io/shell.rs | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs index b60061eea4acb..a132b343d11ec 100644 --- a/crates/common/src/io/shell.rs +++ b/crates/common/src/io/shell.rs @@ -45,10 +45,7 @@ impl TtyWidth { pub fn get() -> Self { // use stderr #[cfg(unix)] - #[allow(clippy::useless_conversion)] - let opt = terminal_size::terminal_size_of(unsafe { - std::os::fd::BorrowedFd::borrow_raw(2.into()) - }); + let opt = terminal_size::terminal_size_of(std::io::stderr()); #[cfg(not(unix))] let opt = terminal_size::terminal_size(); match opt { @@ -190,17 +187,10 @@ impl Shell { } /// Get a static reference to the global shell. - #[inline] - #[cfg_attr(debug_assertions, track_caller)] + /// + /// Initializes the global shell with the default values if it has not been set yet. pub fn get() -> impl DerefMut + 'static { - #[inline(never)] - #[cold] - #[cfg_attr(debug_assertions, track_caller)] - fn shell_get_fail() -> Mutex { - Mutex::new(Shell::new()) - } - - GLOBAL_SHELL.get_or_init(shell_get_fail).lock().unwrap_or_else(PoisonError::into_inner) + GLOBAL_SHELL.get_or_init(Default::default).lock().unwrap_or_else(PoisonError::into_inner) } /// Set the global shell. @@ -208,7 +198,6 @@ impl Shell { /// # Panics /// /// Panics if the global shell has already been set. - #[inline] #[track_caller] pub fn set(self) { if GLOBAL_SHELL.get().is_some() { @@ -290,21 +279,18 @@ impl Shell { } /// Gets a reference to the underlying stdout writer. - #[inline] pub fn out(&mut self) -> &mut dyn Write { self.maybe_err_erase_line(); self.output.stdout() } /// Gets a reference to the underlying stderr writer. - #[inline] pub fn err(&mut self) -> &mut dyn Write { self.maybe_err_erase_line(); self.output.stderr() } /// Erase from cursor to end of line if needed. - #[inline] pub fn maybe_err_erase_line(&mut self) { if self.err_supports_color() && self.set_needs_clear(false) { // This is the "EL - Erase in Line" sequence. It clears from the cursor @@ -336,7 +322,6 @@ impl Shell { /// This will render a message in [ERROR] style with a bold `Error: ` prefix. /// /// **Note**: will log regardless of the verbosity level. - #[inline] pub fn error(&mut self, message: impl fmt::Display) -> Result<()> { self.maybe_err_erase_line(); self.output.message_stderr(&"Error", &ERROR, Some(&message), false) @@ -346,7 +331,6 @@ impl Shell { /// This will render a message in [WARN] style with a bold `Warning: `prefix. /// /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. - #[inline] pub fn warn(&mut self, message: impl fmt::Display) -> Result<()> { match self.verbosity { Verbosity::Quiet => Ok(()), @@ -357,7 +341,6 @@ impl Shell { /// Write a styled fragment. /// /// Caller is responsible for deciding whether [`Shell::verbosity`] is affects output. - #[inline] pub fn write_stdout(&mut self, fragment: impl fmt::Display, color: &Style) -> Result<()> { self.output.write_stdout(fragment, color) } @@ -365,7 +348,6 @@ impl Shell { /// Write a styled fragment with the default color. Use the [`sh_print!`] macro instead. /// /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. - #[inline] pub fn print_out(&mut self, fragment: impl fmt::Display) -> Result<()> { if self.verbosity == Verbosity::Quiet { Ok(()) @@ -377,7 +359,6 @@ impl Shell { /// Write a styled fragment /// /// Caller is responsible for deciding whether [`Shell::verbosity`] is affects output. - #[inline] pub fn write_stderr(&mut self, fragment: impl fmt::Display, color: &Style) -> Result<()> { self.output.write_stderr(fragment, color) } @@ -385,7 +366,6 @@ impl Shell { /// Write a styled fragment with the default color. Use the [`sh_eprint!`] macro instead. /// /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. - #[inline] pub fn print_err(&mut self, fragment: impl fmt::Display) -> Result<()> { if self.verbosity == Verbosity::Quiet { Ok(()) @@ -499,6 +479,7 @@ impl ShellOut { impl ColorChoice { /// Converts our color choice to [`anstream`]'s version. + #[inline] fn to_anstream_color_choice(self) -> anstream::ColorChoice { match self { Self::Always => anstream::ColorChoice::Always, @@ -508,6 +489,7 @@ impl ColorChoice { } } +#[inline] fn supports_color(choice: anstream::ColorChoice) -> bool { match choice { anstream::ColorChoice::Always | From e5343c51f323e721b0c38caa9385d40623967e9d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:37:36 +0300 Subject: [PATCH 1590/1963] chore: add warning on persisted invariant scenario failure (#9171) --- crates/forge/src/runner.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index e580fb8b2fbaf..09b2fd99dc557 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -519,6 +519,11 @@ impl ContractRunner<'_> { invariant_contract.call_after_invariant, ) { if !success { + let _= sh_warn!("\ + Replayed invariant failure from {:?} file. \ + Run `forge clean` or remove file to ignore failure and to continue invariant test campaign.", + failure_file.as_path() + ); // If sequence still fails then replay error to collect traces and // exit without executing new runs. let _ = replay_run( From c2f1760e22390ac66fc9adb9fdc9425a151cd0e3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:47:51 +0300 Subject: [PATCH 1591/1963] feat(invariant): add basic metrics report (#9158) * feat(invariant): add basic metrics report * Put metrics behind show-metrics invariant config --- Cargo.lock | 1 + crates/config/src/invariant.rs | 5 ++ crates/evm/evm/Cargo.toml | 1 + crates/evm/evm/src/executors/invariant/mod.rs | 47 +++++++++++- .../evm/evm/src/executors/invariant/result.rs | 6 +- crates/evm/fuzz/src/invariant/mod.rs | 12 +++ crates/forge/bin/cmd/snapshot.rs | 15 +++- crates/forge/bin/cmd/test/mod.rs | 9 +++ crates/forge/bin/cmd/test/summary.rs | 40 +++++++++- crates/forge/src/result.rs | 39 ++++++---- crates/forge/src/runner.rs | 1 + crates/forge/tests/it/invariant.rs | 73 +++++++++++++++++++ crates/forge/tests/it/test_helpers.rs | 1 + 13 files changed, 228 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cae0781051577..361ce8de9b441 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3951,6 +3951,7 @@ dependencies = [ "proptest", "revm", "revm-inspectors", + "serde", "thiserror", "tracing", ] diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 698f63c269224..70e9a2b858470 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -34,6 +34,8 @@ pub struct InvariantConfig { pub gas_report_samples: u32, /// Path where invariant failures are recorded and replayed. pub failure_persist_dir: Option, + /// Whether to collect and display fuzzed selectors metrics. + pub show_metrics: bool, } impl Default for InvariantConfig { @@ -48,6 +50,7 @@ impl Default for InvariantConfig { max_assume_rejects: 65536, gas_report_samples: 256, failure_persist_dir: None, + show_metrics: false, } } } @@ -65,6 +68,7 @@ impl InvariantConfig { max_assume_rejects: 65536, gas_report_samples: 256, failure_persist_dir: Some(cache_dir), + show_metrics: false, } } @@ -103,6 +107,7 @@ impl InlineConfigParser for InvariantConfig { conf_clone.failure_persist_dir = Some(PathBuf::from(value)) } "shrink-run-limit" => conf_clone.shrink_run_limit = parse_config_u32(key, value)?, + "show-metrics" => conf_clone.show_metrics = parse_config_bool(key, value)?, _ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?, } } diff --git a/crates/evm/evm/Cargo.toml b/crates/evm/evm/Cargo.toml index 5250ea448ac40..214b241e31ab8 100644 --- a/crates/evm/evm/Cargo.toml +++ b/crates/evm/evm/Cargo.toml @@ -50,3 +50,4 @@ proptest.workspace = true thiserror.workspace = true tracing.workspace = true indicatif = "0.17" +serde.workspace = true diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 58c7efd8fe129..860acdbb26d0c 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -31,7 +31,11 @@ use proptest::{ use result::{assert_after_invariant, assert_invariants, can_continue}; use revm::primitives::HashMap; use shrink::shrink_sequence; -use std::{cell::RefCell, collections::btree_map::Entry, sync::Arc}; +use std::{ + cell::RefCell, + collections::{btree_map::Entry, HashMap as Map}, + sync::Arc, +}; mod error; pub use error::{InvariantFailures, InvariantFuzzError}; @@ -42,6 +46,7 @@ pub use replay::{replay_error, replay_run}; mod result; pub use result::InvariantFuzzTestResult; +use serde::{Deserialize, Serialize}; mod shrink; use crate::executors::EvmError; @@ -101,6 +106,17 @@ sol! { } } +/// Contains invariant metrics for a single fuzzed selector. +#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] +pub struct InvariantMetrics { + // Count of fuzzed selector calls. + pub calls: usize, + // Count of fuzzed selector reverts. + pub reverts: usize, + // Count of fuzzed selector discards (through assume cheatcodes). + pub discards: usize, +} + /// Contains data collected during invariant test runs. pub struct InvariantTestData { // Consumed gas and calldata of every successful fuzz call. @@ -115,6 +131,8 @@ pub struct InvariantTestData { pub last_call_results: Option, // Coverage information collected from all fuzzed calls. pub coverage: Option, + // Metrics for each fuzzed selector. + pub metrics: Map, // Proptest runner to query for random values. // The strategy only comes with the first `input`. We fill the rest of the `inputs` @@ -153,6 +171,7 @@ impl InvariantTest { gas_report_traces: vec![], last_call_results, coverage: None, + metrics: Map::default(), branch_runner, }); Self { fuzz_state, targeted_contracts, execution_data } @@ -191,6 +210,24 @@ impl InvariantTest { } } + /// Update metrics for a fuzzed selector, extracted from tx details. + /// Always increments number of calls; discarded runs (through assume cheatcodes) are tracked + /// separated from reverts. + pub fn record_metrics(&self, tx_details: &BasicTxDetails, reverted: bool, discarded: bool) { + if let Some(metric_key) = + self.targeted_contracts.targets.lock().fuzzed_metric_key(tx_details) + { + let test_metrics = &mut self.execution_data.borrow_mut().metrics; + let invariant_metrics = test_metrics.entry(metric_key).or_default(); + invariant_metrics.calls += 1; + if discarded { + invariant_metrics.discards += 1; + } else if reverted { + invariant_metrics.reverts += 1; + } + } + } + /// End invariant test run by collecting results, cleaning collected artifacts and reverting /// created fuzz state. pub fn end_run(&self, run: InvariantTestRun, gas_samples: usize) { @@ -331,10 +368,15 @@ impl<'a> InvariantExecutor<'a> { TestCaseError::fail(format!("Could not make raw evm call: {e}")) })?; + let discarded = call_result.result.as_ref() == MAGIC_ASSUME; + if self.config.show_metrics { + invariant_test.record_metrics(tx, call_result.reverted, discarded); + } + // Collect coverage from last fuzzed call. invariant_test.merge_coverage(call_result.coverage.clone()); - if call_result.result.as_ref() == MAGIC_ASSUME { + if discarded { current_run.inputs.pop(); current_run.assume_rejects_counter += 1; if current_run.assume_rejects_counter > self.config.max_assume_rejects { @@ -443,6 +485,7 @@ impl<'a> InvariantExecutor<'a> { last_run_inputs: result.last_run_inputs, gas_report_traces: result.gas_report_traces, coverage: result.coverage, + metrics: result.metrics, }) } diff --git a/crates/evm/evm/src/executors/invariant/result.rs b/crates/evm/evm/src/executors/invariant/result.rs index c6a15930cbaef..8920a1209342a 100644 --- a/crates/evm/evm/src/executors/invariant/result.rs +++ b/crates/evm/evm/src/executors/invariant/result.rs @@ -1,6 +1,6 @@ use super::{ call_after_invariant_function, call_invariant_function, error::FailedInvariantCaseData, - InvariantFailures, InvariantFuzzError, InvariantTest, InvariantTestRun, + InvariantFailures, InvariantFuzzError, InvariantMetrics, InvariantTest, InvariantTestRun, }; use crate::executors::{Executor, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; @@ -13,7 +13,7 @@ use foundry_evm_fuzz::{ FuzzedCases, }; use revm_inspectors::tracing::CallTraceArena; -use std::borrow::Cow; +use std::{borrow::Cow, collections::HashMap}; /// The outcome of an invariant fuzz test #[derive(Debug)] @@ -30,6 +30,8 @@ pub struct InvariantFuzzTestResult { pub gas_report_traces: Vec>, /// The coverage info collected during the invariant test runs. pub coverage: Option, + /// Fuzzed selectors metrics collected during the invariant test runs. + pub metrics: HashMap, } /// Enriched results of an invariant run check. diff --git a/crates/evm/fuzz/src/invariant/mod.rs b/crates/evm/fuzz/src/invariant/mod.rs index d6b3e574d8b1d..49f27e9f3950a 100644 --- a/crates/evm/fuzz/src/invariant/mod.rs +++ b/crates/evm/fuzz/src/invariant/mod.rs @@ -125,6 +125,18 @@ impl TargetedContracts { .filter(|(_, c)| !c.abi.functions.is_empty()) .flat_map(|(contract, c)| c.abi_fuzzed_functions().map(move |f| (contract, f))) } + + /// Identifies fuzzed contract and function based on given tx details and returns unique metric + /// key composed from contract identifier and function name. + pub fn fuzzed_metric_key(&self, tx: &BasicTxDetails) -> Option { + self.inner.get(&tx.call_details.target).and_then(|contract| { + contract + .abi + .functions() + .find(|f| f.selector() == tx.call_details.calldata[..4]) + .map(|function| format!("{}.{}", contract.identifier.clone(), function.name)) + }) + } } impl std::ops::Deref for TargetedContracts { diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 234ff48a5807a..391c45dd2d89b 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -242,6 +242,7 @@ impl FromStr for GasSnapshotEntry { runs: runs.as_str().parse().unwrap(), calls: calls.as_str().parse().unwrap(), reverts: reverts.as_str().parse().unwrap(), + metrics: HashMap::default(), }, }) } @@ -486,7 +487,12 @@ mod tests { GasSnapshotEntry { contract_name: "Test".to_string(), signature: "deposit()".to_string(), - gas_used: TestKindReport::Invariant { runs: 256, calls: 100, reverts: 200 } + gas_used: TestKindReport::Invariant { + runs: 256, + calls: 100, + reverts: 200, + metrics: HashMap::default() + } } ); } @@ -500,7 +506,12 @@ mod tests { GasSnapshotEntry { contract_name: "ERC20Invariants".to_string(), signature: "invariantBalanceSum()".to_string(), - gas_used: TestKindReport::Invariant { runs: 256, calls: 3840, reverts: 2388 } + gas_used: TestKindReport::Invariant { + runs: 256, + calls: 3840, + reverts: 2388, + metrics: HashMap::default() + } } ); } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 962c0104280aa..fa20e26d87889 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -54,7 +54,9 @@ mod summary; use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; use summary::TestSummaryReporter; +use crate::cmd::test::summary::print_invariant_metrics; pub use filter::FilterArgs; +use forge::result::TestKind; // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); @@ -621,6 +623,13 @@ impl TestArgs { if !silent { sh_println!("{}", result.short_result(name))?; + // Display invariant metrics if invariant kind. + if let TestKind::Invariant { runs: _, calls: _, reverts: _, metrics } = + &result.kind + { + print_invariant_metrics(metrics); + } + // We only display logs at level 2 and above if verbosity >= 2 { // We only decode logs from Hardhat and DS-style console events diff --git a/crates/forge/bin/cmd/test/summary.rs b/crates/forge/bin/cmd/test/summary.rs index 561ea6b6824c6..6d20edfd52f58 100644 --- a/crates/forge/bin/cmd/test/summary.rs +++ b/crates/forge/bin/cmd/test/summary.rs @@ -1,7 +1,11 @@ use crate::cmd::test::TestOutcome; use comfy_table::{ - modifiers::UTF8_ROUND_CORNERS, Attribute, Cell, CellAlignment, Color, Row, Table, + modifiers::UTF8_ROUND_CORNERS, presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, + Row, Table, }; +use foundry_evm::executors::invariant::InvariantMetrics; +use itertools::Itertools; +use std::collections::HashMap; /// A simple summary reporter that prints the test results in a table. pub struct TestSummaryReporter { @@ -91,3 +95,37 @@ impl TestSummaryReporter { println!("\n{}", self.table); } } + +/// Helper to create and render invariant metrics summary table: +/// | Contract | Selector | Calls | Reverts | Discards | +/// |-----------------------|----------------|-------|---------|----------| +/// | AnotherCounterHandler | doWork | 7451 | 123 | 4941 | +/// | AnotherCounterHandler | doWorkThing | 7279 | 137 | 4849 | +/// | CounterHandler | doAnotherThing | 7302 | 150 | 4794 | +/// | CounterHandler | doSomething | 7382 | 160 | 4830 | +pub(crate) fn print_invariant_metrics(test_metrics: &HashMap) { + if !test_metrics.is_empty() { + let mut table = Table::new(); + table.load_preset(ASCII_MARKDOWN); + table.set_header(["Contract", "Selector", "Calls", "Reverts", "Discards"]); + + for name in test_metrics.keys().sorted() { + if let Some((contract, selector)) = + name.split_once(':').and_then(|(_, contract)| contract.split_once('.')) + { + let mut row = Row::new(); + row.add_cell(Cell::new(contract).set_alignment(CellAlignment::Left)); + row.add_cell(Cell::new(selector).set_alignment(CellAlignment::Left)); + if let Some(metrics) = test_metrics.get(name) { + row.add_cell(Cell::new(metrics.calls).set_alignment(CellAlignment::Center)); + row.add_cell(Cell::new(metrics.reverts).set_alignment(CellAlignment::Center)); + row.add_cell(Cell::new(metrics.discards).set_alignment(CellAlignment::Center)); + } + + table.add_row(row); + } + } + + println!("{table}\n"); + } +} diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 5f83168bb50a4..ebe8a94864938 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -13,13 +13,13 @@ use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ coverage::HitMaps, decode::SkipReason, - executors::{EvmError, RawCallResult}, + executors::{invariant::InvariantMetrics, EvmError, RawCallResult}, fuzz::{CounterExample, FuzzCase, FuzzFixtures, FuzzTestResult}, traces::{CallTraceArena, CallTraceDecoder, TraceKind, Traces}, }; use serde::{Deserialize, Serialize}; use std::{ - collections::BTreeMap, + collections::{BTreeMap, HashMap as Map}, fmt::{self, Write}, time::Duration, }; @@ -579,7 +579,8 @@ impl TestResult { /// Returns the skipped result for invariant test. pub fn invariant_skip(mut self, reason: SkipReason) -> Self { - self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }; + self.kind = + TestKind::Invariant { runs: 1, calls: 1, reverts: 1, metrics: HashMap::default() }; self.status = TestStatus::Skipped; self.reason = reason.0; self @@ -592,7 +593,8 @@ impl TestResult { invariant_name: &String, call_sequence: Vec, ) -> Self { - self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1 }; + self.kind = + TestKind::Invariant { runs: 1, calls: 1, reverts: 1, metrics: HashMap::default() }; self.status = TestStatus::Failure; self.reason = if replayed_entirely { Some(format!("{invariant_name} replay failure")) @@ -605,13 +607,15 @@ impl TestResult { /// Returns the fail result for invariant test setup. pub fn invariant_setup_fail(mut self, e: Report) -> Self { - self.kind = TestKind::Invariant { runs: 0, calls: 0, reverts: 0 }; + self.kind = + TestKind::Invariant { runs: 0, calls: 0, reverts: 0, metrics: HashMap::default() }; self.status = TestStatus::Failure; self.reason = Some(format!("failed to set up invariant testing environment: {e}")); self } /// Returns the invariant test result. + #[allow(clippy::too_many_arguments)] pub fn invariant_result( mut self, gas_report_traces: Vec>, @@ -620,11 +624,13 @@ impl TestResult { counterexample: Option, cases: Vec, reverts: usize, + metrics: Map, ) -> Self { self.kind = TestKind::Invariant { runs: cases.len(), calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), reverts, + metrics, }; self.status = match success { true => TestStatus::Success, @@ -669,19 +675,19 @@ impl TestResult { pub enum TestKindReport { Unit { gas: u64 }, Fuzz { runs: usize, mean_gas: u64, median_gas: u64 }, - Invariant { runs: usize, calls: usize, reverts: usize }, + Invariant { runs: usize, calls: usize, reverts: usize, metrics: Map }, } impl fmt::Display for TestKindReport { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self { + match self { Self::Unit { gas } => { write!(f, "(gas: {gas})") } Self::Fuzz { runs, mean_gas, median_gas } => { write!(f, "(runs: {runs}, μ: {mean_gas}, ~: {median_gas})") } - Self::Invariant { runs, calls, reverts } => { + Self::Invariant { runs, calls, reverts, metrics: _ } => { write!(f, "(runs: {runs}, calls: {calls}, reverts: {reverts})") } } @@ -715,7 +721,7 @@ pub enum TestKind { median_gas: u64, }, /// An invariant test. - Invariant { runs: usize, calls: usize, reverts: usize }, + Invariant { runs: usize, calls: usize, reverts: usize, metrics: Map }, } impl Default for TestKind { @@ -727,14 +733,17 @@ impl Default for TestKind { impl TestKind { /// The gas consumed by this test pub fn report(&self) -> TestKindReport { - match *self { - Self::Unit { gas } => TestKindReport::Unit { gas }, + match self { + Self::Unit { gas } => TestKindReport::Unit { gas: *gas }, Self::Fuzz { first_case: _, runs, mean_gas, median_gas } => { - TestKindReport::Fuzz { runs, mean_gas, median_gas } - } - Self::Invariant { runs, calls, reverts } => { - TestKindReport::Invariant { runs, calls, reverts } + TestKindReport::Fuzz { runs: *runs, mean_gas: *mean_gas, median_gas: *median_gas } } + Self::Invariant { runs, calls, reverts, metrics: _ } => TestKindReport::Invariant { + runs: *runs, + calls: *calls, + reverts: *reverts, + metrics: HashMap::default(), + }, } } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 09b2fd99dc557..d0f4f579e537a 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -628,6 +628,7 @@ impl ContractRunner<'_> { counterexample, invariant_result.cases, invariant_result.reverts, + invariant_result.metrics, ) } diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 37b3c9b239341..3e09cd465a339 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -855,3 +855,76 @@ contract NoSelectorTest is Test { ... "#]]); }); + +// +forgetest_init!(should_show_invariant_metrics, |prj, cmd| { + prj.add_test( + "SelectorMetricsTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract CounterTest is Test { + function setUp() public { + CounterHandler handler = new CounterHandler(); + AnotherCounterHandler handler1 = new AnotherCounterHandler(); + // targetContract(address(handler1)); + } + + /// forge-config: default.invariant.runs = 10 + /// forge-config: default.invariant.show-metrics = true + function invariant_counter() public {} + + /// forge-config: default.invariant.runs = 10 + /// forge-config: default.invariant.show-metrics = true + function invariant_counter2() public {} +} + +contract CounterHandler is Test { + function doSomething(uint256 a) public { + vm.assume(a < 10_000_000); + require(a < 100_000); + } + + function doAnotherThing(uint256 a) public { + vm.assume(a < 10_000_000); + require(a < 100_000); + } +} + +contract AnotherCounterHandler is Test { + function doWork(uint256 a) public { + vm.assume(a < 10_000_000); + require(a < 100_000); + } + + function doWorkThing(uint256 a) public { + vm.assume(a < 10_000_000); + require(a < 100_000); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "invariant_"]).assert_success().stdout_eq(str![[r#" +... +Ran 2 tests for test/SelectorMetricsTest.t.sol:CounterTest +[PASS] invariant_counter() (runs: 10, calls: 5000, reverts: [..]) +| Contract | Selector | Calls | Reverts | Discards | +|-----------------------|----------------|-------|---------|----------| +| AnotherCounterHandler | doWork | [..] | [..] | [..] | +| AnotherCounterHandler | doWorkThing | [..] | [..] | [..] | +| CounterHandler | doAnotherThing | [..] | [..] | [..] | +| CounterHandler | doSomething | [..] | [..] | [..] | + +[PASS] invariant_counter2() (runs: 10, calls: 5000, reverts: [..]) +| Contract | Selector | Calls | Reverts | Discards | +|-----------------------|----------------|-------|---------|----------| +| AnotherCounterHandler | doWork | [..] | [..] | [..] | +| AnotherCounterHandler | doWorkThing | [..] | [..] | [..] | +| CounterHandler | doAnotherThing | [..] | [..] | [..] | +| CounterHandler | doSomething | [..] | [..] | [..] | + +... +"#]]); +}); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index e5aee722ff07b..eb5a0bf0a3c03 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -112,6 +112,7 @@ impl ForgeTestProfile { max_assume_rejects: 65536, gas_report_samples: 256, failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), + show_metrics: false, }) .build(output, Path::new(self.project().root())) .expect("Config loaded") From 3ff0cddea7e19ff00c94c92f6173092e7938086c Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:54:13 +0200 Subject: [PATCH 1592/1963] fix: add back `silent` option in Anvil's `NodeConfig` (#9181) * add quiet handling for Anvil tests using NodeConfig * add back `silent` flag, inheriting default from global shell --quiet setting, overrides as true in test * fix unrelated failing test * revert fix, moved to https://github.com/foundry-rs/foundry/pull/9182 --- crates/anvil/src/cmd.rs | 2 ++ crates/anvil/src/config.rs | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 2121f5b64795f..8592ed1a02b91 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -10,6 +10,7 @@ use alloy_signer_local::coins_bip39::{English, Mnemonic}; use anvil_server::ServerConfig; use clap::Parser; use core::fmt; +use foundry_common::shell; use foundry_config::{Chain, Config, FigmentProviders}; use futures::FutureExt; use rand::{rngs::StdRng, SeedableRng}; @@ -254,6 +255,7 @@ impl NodeArgs { .with_storage_caching(self.evm_opts.no_storage_caching) .with_server_config(self.server_config) .with_host(self.host) + .set_silent(shell::is_quiet()) .set_config_out(self.config_out) .with_chain_id(self.evm_opts.chain_id) .with_transaction_order(self.order) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index a54da25a3be9f..5561758182ebe 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -187,6 +187,8 @@ pub struct NodeConfig { pub precompile_factory: Option>, /// Enable Alphanet features. pub alphanet: bool, + /// Do not print log messages. + pub silent: bool, } impl NodeConfig { @@ -392,7 +394,7 @@ impl NodeConfig { /// random, free port by setting it to `0` #[doc(hidden)] pub fn test() -> Self { - Self { enable_tracing: true, port: 0, ..Default::default() } + Self { enable_tracing: true, port: 0, silent: true, ..Default::default() } } /// Returns a new config which does not initialize any accounts on node startup. @@ -462,6 +464,7 @@ impl Default for NodeConfig { memory_limit: None, precompile_factory: None, alphanet: false, + silent: false, } } } @@ -907,6 +910,10 @@ impl NodeConfig { .expect("Failed writing json"); } + if self.silent { + return; + } + let _ = sh_println!("{}", self.as_string(fork)); } @@ -950,6 +957,18 @@ impl NodeConfig { self } + /// Makes the node silent to not emit anything on stdout + #[must_use] + pub fn silent(self) -> Self { + self.set_silent(true) + } + + #[must_use] + pub fn set_silent(mut self, silent: bool) -> Self { + self.silent = silent; + self + } + /// Configures everything related to env, backend and database and returns the /// [Backend](mem::Backend) /// From 76d15ba8eb6c0a4c59987d7f89c2f1d3bde49001 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:23:47 +0200 Subject: [PATCH 1593/1963] chore(`cast`): fix `storage_layout` test due to request timeouts w/ Optimism explorer (#9182) * fix failing test * update test to use contract relevant to ticket https://github.com/foundry-rs/foundry/issues/6319 * get more advanced test w/ packed bool in slot 3 --- crates/cast/tests/cli/main.rs | 89 +++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index d43a78f1337f7..980d523d3d3b8 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1097,47 +1097,56 @@ casttest!(storage, |_prj, cmd| { }); // -casttest!(storage_layout, |_prj, cmd| { +casttest!(storage_layout_simple, |_prj, cmd| { cmd.args([ - "storage", - "--rpc-url", - next_rpc_endpoint(NamedChain::Optimism).as_str(), - "--block", - "110000000", - "--etherscan-api-key", - "JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46", - "0xB67c152E69217b5aCB85A2e19dF13423351b0E27", - ]) - .assert_success() - .stdout_eq(str![[r#" -| Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | -|-------------------------------|-----------------------------------------------------------------|------|--------|-------|---------------------------------------------------|--------------------------------------------------------------------|----------------------------------------------------| -| gov | address | 0 | 0 | 20 | 1352965747418285184211909460723571462248744342032 | 0x000000000000000000000000ecfd15165d994c2766fbe0d6bacdc2e8dedfd210 | contracts/perp/PositionManager.sol:PositionManager | -| _status | uint256 | 1 | 0 | 32 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | -| admin | address | 2 | 0 | 20 | 1352965747418285184211909460723571462248744342032 | 0x000000000000000000000000ecfd15165d994c2766fbe0d6bacdc2e8dedfd210 | contracts/perp/PositionManager.sol:PositionManager | -| feeCalculator | address | 3 | 0 | 20 | 1297482016264593221714872710065075000476194625473 | 0x000000000000000000000000e3451b170806aab3e24b5cd03a331c1ccdb4d7c1 | contracts/perp/PositionManager.sol:PositionManager | -| oracle | address | 4 | 0 | 20 | 241116142622541106669066767052022920958068430970 | 0x0000000000000000000000002a3c0592dcb58accd346ccee2bb46e3fb744987a | contracts/perp/PositionManager.sol:PositionManager | -| referralStorage | address | 5 | 0 | 20 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| minExecutionFee | uint256 | 6 | 0 | 32 | 20000 | 0x0000000000000000000000000000000000000000000000000000000000004e20 | contracts/perp/PositionManager.sol:PositionManager | -| minBlockDelayKeeper | uint256 | 7 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| minTimeExecuteDelayPublic | uint256 | 8 | 0 | 32 | 180 | 0x00000000000000000000000000000000000000000000000000000000000000b4 | contracts/perp/PositionManager.sol:PositionManager | -| minTimeCancelDelayPublic | uint256 | 9 | 0 | 32 | 180 | 0x00000000000000000000000000000000000000000000000000000000000000b4 | contracts/perp/PositionManager.sol:PositionManager | -| maxTimeDelay | uint256 | 10 | 0 | 32 | 1800 | 0x0000000000000000000000000000000000000000000000000000000000000708 | contracts/perp/PositionManager.sol:PositionManager | -| isUserExecuteEnabled | bool | 11 | 0 | 1 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | -| isUserCancelEnabled | bool | 11 | 1 | 1 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | -| allowPublicKeeper | bool | 11 | 2 | 1 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| allowUserCloseOnly | bool | 11 | 3 | 1 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager | -| openPositionRequestKeys | bytes32[] | 12 | 0 | 32 | 9287 | 0x0000000000000000000000000000000000000000000000000000000000002447 | contracts/perp/PositionManager.sol:PositionManager | -| closePositionRequestKeys | bytes32[] | 13 | 0 | 32 | 5782 | 0x0000000000000000000000000000000000000000000000000000000000001696 | contracts/perp/PositionManager.sol:PositionManager | -| openPositionRequestKeysStart | uint256 | 14 | 0 | 32 | 9287 | 0x0000000000000000000000000000000000000000000000000000000000002447 | contracts/perp/PositionManager.sol:PositionManager | -| closePositionRequestKeysStart | uint256 | 15 | 0 | 32 | 5782 | 0x0000000000000000000000000000000000000000000000000000000000001696 | contracts/perp/PositionManager.sol:PositionManager | -| isPositionKeeper | mapping(address => bool) | 16 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| openPositionsIndex | mapping(address => uint256) | 17 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| openPositionRequests | mapping(bytes32 => struct PositionManager.OpenPositionRequest) | 18 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| closePositionsIndex | mapping(address => uint256) | 19 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| closePositionRequests | mapping(bytes32 => struct PositionManager.ClosePositionRequest) | 20 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| managers | mapping(address => bool) | 21 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | -| approvedManagers | mapping(address => mapping(address => bool)) | 22 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager | + "storage", + "--rpc-url", + next_rpc_endpoint(NamedChain::Mainnet).as_str(), + "--block", + "21034138", + "--etherscan-api-key", + next_mainnet_etherscan_api_key().as_str(), + "0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2", + ]) + .assert_success() + .stdout_eq(str![[r#" +| Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | +|---------|---------|------|--------|-------|-------|--------------------------------------------------------------------|-----------------------------------------------| +| _owner | address | 0 | 0 | 20 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/Create2Deployer.sol:Create2Deployer | +| _paused | bool | 0 | 20 | 1 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/Create2Deployer.sol:Create2Deployer | + +"#]]); +}); + +// +casttest!(storage_layout_complex, |_prj, cmd| { + cmd.args([ + "storage", + "--rpc-url", + next_rpc_endpoint(NamedChain::Mainnet).as_str(), + "--block", + "21034138", + "--etherscan-api-key", + next_mainnet_etherscan_api_key().as_str(), + "0xBA12222222228d8Ba445958a75a0704d566BF2C8", + ]) + .assert_success() + .stdout_eq(str![[r#" +| Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | +|-------------------------------|--------------------------------------------------------------------|------|--------|-------|--------------------------------------------------|--------------------------------------------------------------------|---------------------------------| +| _status | uint256 | 0 | 0 | 32 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/vault/Vault.sol:Vault | +| _generalPoolsBalances | mapping(bytes32 => struct EnumerableMap.IERC20ToBytes32Map) | 1 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _nextNonce | mapping(address => uint256) | 2 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _paused | bool | 3 | 0 | 1 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _authorizer | contract IAuthorizer | 3 | 1 | 20 | 549683469959765988649777481110995959958745616871 | 0x0000000000000000000000006048a8c631fb7e77eca533cf9c29784e482391e7 | contracts/vault/Vault.sol:Vault | +| _approvedRelayers | mapping(address => mapping(address => bool)) | 4 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _isPoolRegistered | mapping(bytes32 => bool) | 5 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _nextPoolNonce | uint256 | 6 | 0 | 32 | 1760 | 0x00000000000000000000000000000000000000000000000000000000000006e0 | contracts/vault/Vault.sol:Vault | +| _minimalSwapInfoPoolsBalances | mapping(bytes32 => mapping(contract IERC20 => bytes32)) | 7 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _minimalSwapInfoPoolsTokens | mapping(bytes32 => struct EnumerableSet.AddressSet) | 8 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _twoTokenPoolTokens | mapping(bytes32 => struct TwoTokenPoolsBalance.TwoTokenPoolTokens) | 9 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _poolAssetManagers | mapping(bytes32 => mapping(contract IERC20 => address)) | 10 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +| _internalTokenBalance | mapping(address => mapping(contract IERC20 => uint256)) | 11 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | "#]]); }); From 72473a378294b55604018170ece2e4f17aef947b Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:12:39 +0530 Subject: [PATCH 1594/1963] chore(deps): bump alloy + revm + fork-db (#9183) * chore(deps): bump alloy + revm + fork-db * bump alloy-core --- Cargo.lock | 412 +++++++++++++++++----------------- Cargo.toml | 64 +++--- crates/anvil/src/eth/error.rs | 1 - 3 files changed, 233 insertions(+), 244 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 361ce8de9b441..f5d17a156de34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42642aed67f938363d9c7543e5ca4163cfb4205d9ec15fe933dc4e865d2932dd" +checksum = "41ed961a48297c732a5d97ee321aa8bb5009ecadbcb077d8bec90cb54e651629" dependencies = [ "alloy-eips", "alloy-primitives", @@ -96,15 +96,15 @@ dependencies = [ "alloy-serde", "auto_impl", "c-kzg", - "derive_more 1.0.0", + "derive_more", "serde", ] [[package]] name = "alloy-contract" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "694f433e4105c2c5302e4c97f0fa408fa9058bd4bbf19398c0506a46ed3df255" +checksum = "460ab80ce4bda1c80bcf96fe7460520476f2c7b734581c6567fac2708e2a60ef" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6228abfc751a29cde117b0879b805a3e0b3b641358f063272c83ca459a56886" +checksum = "5647fce5a168f9630f935bf7821c4207b1755184edaeba783cb4e11d35058484" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -134,7 +134,7 @@ dependencies = [ "arbitrary", "const-hex", "derive_arbitrary", - "derive_more 1.0.0", + "derive_more", "itoa", "proptest", "serde", @@ -157,13 +157,14 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeffd2590ce780ddfaa9d0ae340eb2b4e08627650c4676eef537cef0b4bf535d" +checksum = "64ffc577390ce50234e02d841214b3dc0bea6aaaae8e04bbf3cb82e9a45da9eb" dependencies = [ "alloy-primitives", "alloy-rlp", "arbitrary", + "derive_more", "k256", "rand", "serde", @@ -171,9 +172,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbc52a30df46f9831ed74557dfad0d94b12420393662a8b9ef90e2d6c8cb4b0" +checksum = "b69e06cf9c37be824b9d26d6d101114fdde6af0c87de2828b414c05c4b3daa71" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -181,7 +182,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "c-kzg", - "derive_more 1.0.0", + "derive_more", "once_cell", "serde", "sha2", @@ -189,9 +190,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0787d1688b9806290313cc335d416cc7ee39b11e3245f3d218544c62572d92ba" +checksum = "dde15e14944a88bd6a57d325e9a49b75558746fe16aaccc79713ae50a6a9574c" dependencies = [ "alloy-primitives", "alloy-serde", @@ -200,9 +201,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d46eb5871592c216d39192499c95a99f7175cb94104f88c307e6dc960676d9f1" +checksum = "4b5671117c38b1c2306891f97ad3828d85487087f54ebe2c7591a055ea5bcea7" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -212,9 +213,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d55a16a5f9ca498a217c060414bcd1c43e934235dc8058b31b87dcd69ff4f105" +checksum = "af5979e0d5a7bf9c7eb79749121e8256e59021af611322aee56e77e20776b4b3" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -226,9 +227,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d236a8c3e1d5adc09b1b63c81815fc9b757d9a4ba9482cc899f9679b55dd437" +checksum = "204237129086ce5dc17a58025e93739b01b45313841f98fa339eb1d780511e57" dependencies = [ "alloy-consensus", "alloy-eips", @@ -247,9 +248,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15a0990fa8a56d85a42d6a689719aa4eebf5e2f1a5c5354658c0bfc52cac9a" +checksum = "514f70ee2a953db21631cd817b13a1571474ec77ddc03d47616d5e8203489fde" dependencies = [ "alloy-consensus", "alloy-eips", @@ -260,9 +261,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f35429a652765189c1c5092870d8360ee7b7769b09b06d89ebaefd34676446" +checksum = "c71738eb20c42c5fb149571e76536a0f309d142f3957c28791662b96baf77a3d" dependencies = [ "alloy-rlp", "arbitrary", @@ -270,7 +271,7 @@ dependencies = [ "cfg-if", "const-hex", "derive_arbitrary", - "derive_more 1.0.0", + "derive_more", "foldhash", "getrandom", "hashbrown 0.15.0", @@ -292,9 +293,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "316f522bb6f9ac3805132112197957013b570e20cfdad058e8339dae6030c849" +checksum = "4814d141ede360bb6cd1b4b064f1aab9de391e7c4d0d4d50ac89ea4bc1e25fbd" dependencies = [ "alloy-chains", "alloy-consensus", @@ -334,9 +335,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222cd9b17b1c5ad48de51a88ffbdb17f17145170288f22662f80ac88739125e6" +checksum = "96ba46eb69ddf7a9925b81f15229cb74658e6eebe5dd30a5b74e2cd040380573" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -353,9 +354,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" +checksum = "da0822426598f95e45dd1ea32a738dac057529a709ee645fcc516ffa4cbde08f" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -364,20 +365,20 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" +checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] name = "alloy-rpc-client" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b2ab59712c594c9624aaa69e38e4d38f180cb569f1fa46cdaf8c21fd50793e5" +checksum = "7fc2bd1e7403463a5f2c61e955bcc9d3072b63aa177442b0f9aa6a6d22a941e3" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -401,9 +402,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba21284319e12d053baa204d438db6c1577aedd94c1298e4becefdac1f9cec87" +checksum = "eea9bf1abdd506f985a53533f5ac01296bcd6102c5e139bbc5d40bc468d2c916" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -417,9 +418,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba40bea86c3102b9ed9b3be579e32e0b3e54e766248d873de5fc0437238c8df2" +checksum = "2382fc63fb0cf3e02818d547b80cb66cc49a31f8803d0c328402b2008bc13650" dependencies = [ "alloy-primitives", "alloy-serde", @@ -428,16 +429,16 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44848fced3b42260b9cb61f22102246636dfe5a2d0132f8d10a617df3cb1a74b" +checksum = "886d22d41992287a235af2f3af4299b5ced2bcafb81eb835572ad35747476946" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", - "derive_more 1.0.0", + "derive_more", "jsonwebtoken", "rand", "serde", @@ -446,9 +447,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35894711990019fafff0012b82b9176cbb744516eb2a9bbe6b8e5cae522163ee" +checksum = "00b034779a4850b4b03f5be5ea674a1cf7d746b2da762b34d1860ab45e48ca27" dependencies = [ "alloy-consensus", "alloy-eips", @@ -457,7 +458,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", - "derive_more 1.0.0", + "derive_more", "itertools 0.13.0", "serde", "serde_json", @@ -465,9 +466,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f568c5624881896d8a25e19acbdcbabadd8df339427ea2f10b2ee447d57c4509" +checksum = "4e5fb6c5c401321f802f69dcdb95b932f30f8158f6798793f914baac5995628e" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -479,9 +480,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a37d2e1ed9b7daf20ad0b3e0092613cbae46737e0e988b23caa556c7067ce6" +checksum = "9ad066b49c3b1b5f64cdd2399177a19926a6a15db2dbf11e2098de621f9e7480" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -491,9 +492,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2843c195675f06b29c09a4315cccdc233ab5bdc7c0a3775909f9f0cab5e9ae0f" +checksum = "028e72eaa9703e4882344983cfe7636ce06d8cce104a78ea62fd19b46659efc4" dependencies = [ "alloy-primitives", "serde", @@ -502,9 +503,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b2a00d9803dfef99963303ffe41a7bf2221f3342f0a503d6741a9f4a18e5e5" +checksum = "592c185d7100258c041afac51877660c7bf6213447999787197db4842f0e938e" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -518,9 +519,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3de340e1b464a8f03ea6184a55d5eac34c5254ab575416d5e86f5a713dad7f7" +checksum = "a406102908a4e51834f32c4e5c1b29aa2c407b3fd23a5cad129c28b56d85e1b8" dependencies = [ "alloy-consensus", "alloy-network", @@ -536,9 +537,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "265d3ed0f67fcbb6e4ed4554e121a7d5e63fecf0e3827286179f6f0a264e85a1" +checksum = "d8d363e12280cb43747d3b62a1e6f00d595bc1a56464bb20200c6b6ca5d68185" dependencies = [ "alloy-consensus", "alloy-network", @@ -554,9 +555,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56224c04ef8eaf3aae77efa9079bfc202da6b8ecf5eb383748989ba122339e69" +checksum = "59a642c9f66ac73ae0d5398ce7ce3ce5bdfad5658d549abd48ea48962e585dca" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -574,9 +575,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a2505d4f8c98dcae86152d58d549cb4bcf953f8352fca903410e0a0ef535571" +checksum = "6614f02fc1d5b079b2a4a5320018317b506fd0a6d67c1fd5542a71201724986c" dependencies = [ "alloy-consensus", "alloy-network", @@ -593,9 +594,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11fac0c64b48c15187bc8dc3e633f8bc90bddd7e826dd745fcc1b2241c4b4be" +checksum = "b754988ef4e1f5f7d55c132949bb2a10491ed6bbf1d35108269014f50da1823f" dependencies = [ "alloy-consensus", "alloy-network", @@ -610,23 +611,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2395336745358cc47207442127c47c63801a7065ecc0aa928da844f8bb5576" +checksum = "b0900b83f4ee1f45c640ceee596afbc118051921b9438fdb5a3175c1a7e05f8b" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed5047c9a241df94327879c2b0729155b58b941eae7805a7ada2e19436e6b39" +checksum = "a41b1e78dde06b5e12e6702fa8c1d30621bf07728ba75b801fb801c9c6a0ba10" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -636,16 +637,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dee02a81f529c415082235129f0df8b8e60aa1601b9c9298ffe54d75f57210b" +checksum = "91dc311a561a306664393407b88d3e53ae58581624128afd8a15faa5de3627dc" dependencies = [ "alloy-json-abi", "const-hex", @@ -654,15 +655,15 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.82", + "syn 2.0.85", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f631f0bd9a9d79619b27c91b6b1ab2c4ef4e606a65192369a1ee05d40dcf81cc" +checksum = "45d1fbee9e698f3ba176b6e7a145f4aefe6d2b746b611e8bb246fe11a0e9f6c4" dependencies = [ "serde", "winnow", @@ -670,9 +671,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2841af22d99e2c0f82a78fe107b6481be3dd20b89bfb067290092794734343a" +checksum = "086f41bc6ebcd8cb15f38ba20e47be38dd03692149681ce8061c35d960dbf850" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -683,9 +684,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dc2c8f6b8c227ef0398f702d954c4ab572c2ead3c1ed4a5157aa1cbaf959747" +checksum = "be77579633ebbc1266ae6fd7694f75c408beb1aeb6865d0b18f22893c265a061" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -703,9 +704,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd328e990d57f4c4e63899fb2c26877597d6503f8e0022a3d71b2d753ecbfc0c" +checksum = "91fd1a5d0827939847983b46f2f79510361f901dc82f8e3c38ac7397af142c6e" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -718,9 +719,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89aea26aaf1d67904a7ff95ec4a24ddd5e7d419a6945f641b885962d7c2803e2" +checksum = "8073d1186bfeeb8fbdd1292b6f1a0731f3aed8e21e1463905abfae0b96a887a6" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -739,9 +740,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e222e950ecc4ea12fbfb524b9a2275cac2cd5f57c8ce25bcaf1bd3ff80dd8fc8" +checksum = "61f27837bb4a1d6c83a28231c94493e814882f0e9058648a97e908a5f3fc9fcf" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -763,7 +764,7 @@ checksum = "e9703ce68b97f8faae6f7739d1e003fc97621b856953cbcdbb2b515743f23288" dependencies = [ "alloy-primitives", "alloy-rlp", - "derive_more 1.0.0", + "derive_more", "nybbles", "serde", "smallvec", @@ -971,9 +972,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "arbitrary" @@ -1163,7 +1164,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1185,7 +1186,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1196,7 +1197,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1249,7 +1250,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1781,7 +1782,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -1837,9 +1838,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" dependencies = [ "serde", ] @@ -2136,9 +2137,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.33" +version = "4.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9646e2e245bf62f45d39a0f3f36f1171ad1ea0d6967fd114bca72cb02a8fcdfb" +checksum = "07a13ab5b8cb13dbe35e68b83f6c12f9293b2f601797b71bc9f23befdb329feb" dependencies = [ "clap", ] @@ -2162,7 +2163,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2580,7 +2581,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2591,7 +2592,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2664,7 +2665,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2685,7 +2686,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2695,18 +2696,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.82", -] - -[[package]] -name = "derive_more" -version = "0.99.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2727,7 +2717,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "unicode-xid", ] @@ -2835,7 +2825,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2860,7 +2850,7 @@ checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -2987,7 +2977,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -3122,7 +3112,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.82", + "syn 2.0.85", "toml 0.8.19", "walkdir", ] @@ -3150,7 +3140,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.82", + "syn 2.0.85", "tempfile", "thiserror", "tiny-keccak", @@ -3430,7 +3420,7 @@ name = "forge-doc" version = "0.2.0" dependencies = [ "alloy-primitives", - "derive_more 1.0.0", + "derive_more", "eyre", "forge-fmt", "foundry-compilers", @@ -3538,7 +3528,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -3962,7 +3952,7 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-sol-types", - "derive_more 1.0.0", + "derive_more", "foundry-common-fmt", "foundry-macros", "foundry-test-utils", @@ -4072,9 +4062,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32c2d2bb411d4d88d6c84ff412a5182113d8e0b3d00363997a9b1f82a2e53d08" +checksum = "73fe4a1e7e0f122b28afc156681687249bd5cf910d9bf873efb1181e4d41fbc3" dependencies = [ "alloy-primitives", "alloy-provider", @@ -4110,7 +4100,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -4269,7 +4259,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -4416,9 +4406,9 @@ dependencies = [ [[package]] name = "gix-config-value" -version = "0.14.8" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f76169faa0dec598eac60f83d7fcdd739ec16596eca8fb144c88973dbe6f8c" +checksum = "f3de3fdca9c75fa4b83a76583d265fa49b1de6b088ebcd210749c24ceeb74660" dependencies = [ "bitflags 2.6.0", "bstr", @@ -4429,9 +4419,9 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c84b7af01e68daf7a6bb8bb909c1ff5edb3ce4326f1f43063a5a96d3c3c8a5" +checksum = "d10d543ac13c97292a15e8e8b7889cd006faf739777437ed95362504b8fe81a0" dependencies = [ "bstr", "itoa", @@ -4519,9 +4509,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.11" +version = "0.10.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebfc4febd088abdcbc9f1246896e57e37b7a34f6909840045a1767c6dafac7af" +checksum = "c04e5a94fdb56b1e91eb7df2658ad16832428b8eeda24ff1a0f0288de2bce554" dependencies = [ "bstr", "gix-trace", @@ -4553,9 +4543,9 @@ dependencies = [ [[package]] name = "gix-sec" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe4d52f30a737bbece5276fab5d3a8b276dc2650df963e293d0673be34e7a5f" +checksum = "a2007538eda296445c07949cf04f4a767307d887184d6b3e83e2d636533ddc6e" dependencies = [ "bitflags 2.6.0", "gix-path", @@ -4578,15 +4568,15 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cae0e8661c3ff92688ce1c8b8058b3efb312aba9492bbe93661a21705ab431b" +checksum = "04bdde120c29f1fc23a24d3e115aeeea3d60d8e65bab92cc5f9d90d9302eb952" [[package]] name = "gix-utils" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35192df7fd0fa112263bad8021e2df7167df4cc2a6e6d15892e1e55621d3d4dc" +checksum = "ba427e3e9599508ed98a6ddf8ed05493db114564e338e41f6a996d2e4790335f" dependencies = [ "fastrand", "unicode-normalization", @@ -4594,9 +4584,9 @@ dependencies = [ [[package]] name = "gix-validate" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f2badbb64e57b404593ee26b752c26991910fd0d81fe6f9a71c1a8309b6c86" +checksum = "e187b263461bc36cea17650141567753bc6207d036cedd1de6e81a52f277ff68" dependencies = [ "bstr", "thiserror", @@ -4798,7 +4788,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -5231,7 +5221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -5695,7 +5685,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -5786,7 +5776,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6045,7 +6035,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6102,7 +6092,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-serde", - "derive_more 1.0.0", + "derive_more", "serde", "spin", ] @@ -6184,7 +6174,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6347,7 +6337,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6406,7 +6396,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6490,7 +6480,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6548,7 +6538,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6634,12 +6624,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6717,14 +6707,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -6737,7 +6727,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "version_check", "yansi", ] @@ -6801,7 +6791,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -6824,7 +6814,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -7206,9 +7196,9 @@ dependencies = [ [[package]] name = "revm" -version = "16.0.0" +version = "17.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34e44692d5736cc44c697a372e507890f8797f06d1541c5f4b9bec594d90fd8a" +checksum = "055bee6a81aaeee8c2389ae31f0d4de87f44df24f4444a1116f9755fd87a76ad" dependencies = [ "auto_impl", "cfg-if", @@ -7221,9 +7211,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64e2246ad480167548724eb9c9c66945241b867c7d50894de3ca860c9823a45" +checksum = "1e29c662f7887f3b659d4b0fd234673419a8fcbeaa1ecc29bf7034c0a75cc8ea" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -7239,9 +7229,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "12.0.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f89940d17d5d077570de1977f52f69049595322e237cb6c754c3d47f668f023" +checksum = "fac2034454f8bc69dc7d3c94cdb1b57559e27f5ef0518771f1787de543d7d6a1" dependencies = [ "revm-primitives", "serde", @@ -7249,9 +7239,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "13.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f816aaea3245cbdbe7fdd84955df33597f9322c7912c3e3ba7bc855e03211f" +checksum = "7a88c8c7c5f9b988a9e65fc0990c6ce859cdb74114db705bd118a96d22d08027" dependencies = [ "aurora-engine-modexp", "blst", @@ -7269,9 +7259,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "12.0.0" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532411bbde45a46707c1d434dcdc29866cf261c1b748fb01b303ce3b4310b361" +checksum = "0d11fa1e195b0bebaf3fb18596f314a13ba3a4cb1fdd16d3465934d812fd921e" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -7639,21 +7629,21 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.3" +version = "2.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" +checksum = "22760a375f81a31817aeaf6f5081e9ccb7ffd7f2da1809a6e3fc82b6656f10d5" dependencies = [ "cfg-if", - "derive_more 0.99.18", + "derive_more", "parity-scale-codec", "scale-info-derive", ] [[package]] name = "scale-info-derive" -version = "2.11.3" +version = "2.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" +checksum = "abc61ebe25a5c410c0e245028fc9934bf8fa4817199ef5a24a68092edfd34614" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7700,7 +7690,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -7858,22 +7848,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -7884,7 +7874,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -7928,7 +7918,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -7974,7 +7964,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -8208,7 +8198,7 @@ checksum = "8daf7e07f2b6002f8410811915a2f6142f2d1084764dd88cba3f4ebf22232975" dependencies = [ "clap", "cliclack", - "derive_more 1.0.0", + "derive_more", "email-address-parser", "rayon", "soldeer-core", @@ -8224,7 +8214,7 @@ dependencies = [ "chrono", "cliclack", "const-hex", - "derive_more 1.0.0", + "derive_more", "dunce", "home", "ignore", @@ -8336,7 +8326,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -8404,9 +8394,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.82" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -8415,14 +8405,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebfc1bfd06acc78f16d8fd3ef846bc222ee7002468d10a7dce8d703d6eab89a3" +checksum = "9d5e0c2ea8db64b2898b62ea2fbd60204ca95e0b2c6bdf53ff768bbe916fbe4d" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -8523,22 +8513,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -8639,9 +8629,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -8663,7 +8653,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -8938,7 +8928,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -9341,7 +9331,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "wasm-bindgen-shared", ] @@ -9375,7 +9365,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9606,7 +9596,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -9617,7 +9607,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -9628,7 +9618,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -9639,7 +9629,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -9905,7 +9895,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] @@ -9925,7 +9915,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.85", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index db0ad3de46928..80e7945d51460 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,52 +170,52 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.7.3", default-features = false } foundry-compilers = { version = "0.11.6", default-features = false } -foundry-fork-db = "0.5.0" +foundry-fork-db = "0.6.0" solang-parser = "=0.3.3" ## revm -revm = { version = "16.0.0", default-features = false } -revm-primitives = { version = "12.0.0", default-features = false } -revm-inspectors = { version = "0.9.0", features = ["serde"] } +revm = { version = "17.1.0", default-features = false } +revm-primitives = { version = "13.0.0", default-features = false } +revm-inspectors = { version = "0.10.0", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.5.2", default-features = false } -alloy-contract = { version = "0.5.2", default-features = false } -alloy-eips = { version = "0.5.2", default-features = false } -alloy-genesis = { version = "0.5.2", default-features = false } -alloy-json-rpc = { version = "0.5.2", default-features = false } -alloy-network = { version = "0.5.2", default-features = false } -alloy-provider = { version = "0.5.2", default-features = false } -alloy-pubsub = { version = "0.5.2", default-features = false } -alloy-rpc-client = { version = "0.5.2", default-features = false } -alloy-rpc-types = { version = "0.5.2", default-features = true } -alloy-serde = { version = "0.5.2", default-features = false } -alloy-signer = { version = "0.5.2", default-features = false } -alloy-signer-aws = { version = "0.5.2", default-features = false } -alloy-signer-gcp = { version = "0.5.2", default-features = false } -alloy-signer-ledger = { version = "0.5.2", default-features = false } -alloy-signer-local = { version = "0.5.2", default-features = false } -alloy-signer-trezor = { version = "0.5.2", default-features = false } -alloy-transport = { version = "0.5.2", default-features = false } -alloy-transport-http = { version = "0.5.2", default-features = false } -alloy-transport-ipc = { version = "0.5.2", default-features = false } -alloy-transport-ws = { version = "0.5.2", default-features = false } +alloy-consensus = { version = "0.5.4", default-features = false } +alloy-contract = { version = "0.5.4", default-features = false } +alloy-eips = { version = "0.5.4", default-features = false } +alloy-genesis = { version = "0.5.4", default-features = false } +alloy-json-rpc = { version = "0.5.4", default-features = false } +alloy-network = { version = "0.5.4", default-features = false } +alloy-provider = { version = "0.5.4", default-features = false } +alloy-pubsub = { version = "0.5.4", default-features = false } +alloy-rpc-client = { version = "0.5.4", default-features = false } +alloy-rpc-types = { version = "0.5.4", default-features = true } +alloy-serde = { version = "0.5.4", default-features = false } +alloy-signer = { version = "0.5.4", default-features = false } +alloy-signer-aws = { version = "0.5.4", default-features = false } +alloy-signer-gcp = { version = "0.5.4", default-features = false } +alloy-signer-ledger = { version = "0.5.4", default-features = false } +alloy-signer-local = { version = "0.5.4", default-features = false } +alloy-signer-trezor = { version = "0.5.4", default-features = false } +alloy-transport = { version = "0.5.4", default-features = false } +alloy-transport-http = { version = "0.5.4", default-features = false } +alloy-transport-ipc = { version = "0.5.4", default-features = false } +alloy-transport-ws = { version = "0.5.4", default-features = false } ## alloy-core -alloy-dyn-abi = "0.8.5" -alloy-json-abi = "0.8.5" -alloy-primitives = { version = "0.8.5", features = [ +alloy-dyn-abi = "0.8.9" +alloy-json-abi = "0.8.9" +alloy-primitives = { version = "0.8.9", features = [ "getrandom", "rand", "map-foldhash", ] } -alloy-sol-macro-expander = "0.8.5" -alloy-sol-macro-input = "0.8.5" -alloy-sol-types = "0.8.5" -syn-solidity = "0.8.5" +alloy-sol-macro-expander = "0.8.9" +alloy-sol-macro-input = "0.8.9" +alloy-sol-types = "0.8.9" +syn-solidity = "0.8.9" alloy-chains = "0.1" alloy-rlp = "0.3" diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 7af513ff12807..0c478ee061d9c 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -294,7 +294,6 @@ impl From for InvalidTransactionError { Self::AuthorizationListNotSupported } InvalidTransaction::AuthorizationListInvalidFields | - InvalidTransaction::InvalidAuthorizationList(_) | InvalidTransaction::OptimismError(_) | InvalidTransaction::EofCrateShouldHaveToAddress | InvalidTransaction::EmptyAuthorizationList => Self::Revm(err), From c6d59b32fad4b78453354b92acfef5a95013b17f Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:54:06 +0530 Subject: [PATCH 1595/1963] fix(`evm`): detect blob tx and set evm version (#9185) --- crates/evm/core/src/backend/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index d6774b89a105a..510cb9bbaeb1b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1929,6 +1929,12 @@ fn commit_transaction( persistent_accounts: &HashSet
, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { + // TODO: Remove after https://github.com/foundry-rs/foundry/pull/9131 + // if the tx has the blob_versioned_hashes field, we assume it's a Cancun block + if tx.blob_versioned_hashes.is_some() { + env.handler_cfg.spec_id = SpecId::CANCUN; + } + configure_tx_env(&mut env.env, tx); let now = Instant::now(); From b74e467e1047d0ac854bbc35f603a83e94fc13b8 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:11:53 +0530 Subject: [PATCH 1596/1963] fix(`evm`): set blob_excess_gas_and_price (#9186) --- crates/evm/core/src/backend/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 510cb9bbaeb1b..b08d5fd44b602 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -19,8 +19,8 @@ use revm::{ inspectors::NoOpInspector, precompile::{PrecompileSpecId, Precompiles}, primitives::{ - Account, AccountInfo, Bytecode, Env, EnvWithHandlerCfg, EvmState, EvmStorageSlot, - HashMap as Map, Log, ResultAndState, SpecId, KECCAK_EMPTY, + Account, AccountInfo, BlobExcessGasAndPrice, Bytecode, Env, EnvWithHandlerCfg, EvmState, + EvmStorageSlot, HashMap as Map, Log, ResultAndState, SpecId, KECCAK_EMPTY, }, Database, DatabaseCommit, JournaledState, }; @@ -1916,6 +1916,8 @@ fn update_env_block(env: &mut Env, block: &Block) { env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); env.block.gas_limit = U256::from(block.header.gas_limit); env.block.number = U256::from(block.header.number); + env.block.blob_excess_gas_and_price = + block.header.excess_blob_gas.map(BlobExcessGasAndPrice::new); } /// Executes the given transaction and commits state changes to the database _and_ the journaled From ce6f38839a8e06490ef55cb9ba6189da3af9c8d0 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:59:32 +0200 Subject: [PATCH 1597/1963] chore(`cast`): enforce `common::shell` for cast binary (#9174) * enforce common::shell for cast binary * revert unrelated Makefile change * revert formatting of commands * revert accidental fmt changes --- crates/cast/bin/cmd/access_list.rs | 2 +- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/create2.rs | 20 +-- crates/cast/bin/cmd/estimate.rs | 2 +- crates/cast/bin/cmd/find_block.rs | 2 +- crates/cast/bin/cmd/interface.rs | 4 +- crates/cast/bin/cmd/logs.rs | 4 +- crates/cast/bin/cmd/mktx.rs | 2 +- crates/cast/bin/cmd/rpc.rs | 2 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/cmd/send.rs | 4 +- crates/cast/bin/cmd/storage.rs | 12 +- crates/cast/bin/cmd/wallet/list.rs | 10 +- crates/cast/bin/cmd/wallet/mod.rs | 56 ++++---- crates/cast/bin/cmd/wallet/vanity.rs | 7 +- crates/cast/bin/main.rs | 186 ++++++++++++++------------- crates/cast/src/lib.rs | 7 +- crates/cast/src/rlp_converter.rs | 2 + 18 files changed, 169 insertions(+), 157 deletions(-) diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 553d9c9ad4072..3d60b52903a34 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -67,7 +67,7 @@ impl AccessListArgs { let access_list: String = cast.access_list(&tx, block, to_json).await?; - println!("{access_list}"); + sh_println!("{access_list}")?; Ok(()) } diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index fe0a244df2133..355d18ee6ad7d 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -205,7 +205,7 @@ impl CallArgs { return Ok(()); } - println!("{}", Cast::new(provider).call(&tx, func.as_ref(), block, json).await?); + sh_println!("{}", Cast::new(provider).call(&tx, func.as_ref(), block, json).await?)?; Ok(()) } diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index ebf2b3ecab1b5..271e5b43ef602 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -124,7 +124,7 @@ impl Create2Args { if let Some(salt) = salt { let salt = hex::FromHex::from_hex(salt)?; let address = deployer.create2(salt, init_code_hash); - println!("{address}"); + sh_println!("{address}")?; return Ok(Create2Output { address, salt }); } @@ -191,11 +191,13 @@ impl Create2Args { rng.fill_bytes(remaining); } - println!("Configuration:"); - println!("Init code hash: {init_code_hash}"); - println!("Regex patterns: {:?}", regex.patterns()); - println!(); - println!("Starting to generate deterministic contract address with {n_threads} threads..."); + sh_println!("Configuration:")?; + sh_println!("Init code hash: {init_code_hash}")?; + sh_println!("Regex patterns: {:?}", regex.patterns())?; + sh_println!()?; + sh_println!( + "Starting to generate deterministic contract address with {n_threads} threads..." + )?; let mut handles = Vec::with_capacity(n_threads); let found = Arc::new(AtomicBool::new(false)); let timer = Instant::now(); @@ -249,9 +251,9 @@ impl Create2Args { let results = handles.into_iter().filter_map(|h| h.join().unwrap()).collect::>(); let (address, salt) = results.into_iter().next().unwrap(); - println!("Successfully found contract address in {:?}", timer.elapsed()); - println!("Address: {address}"); - println!("Salt: {salt} ({})", U256::from_be_bytes(salt.0)); + sh_println!("Successfully found contract address in {:?}", timer.elapsed())?; + sh_println!("Address: {address}")?; + sh_println!("Salt: {salt} ({})", U256::from_be_bytes(salt.0))?; Ok(Create2Output { address, salt }) } diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 315ba91dc564c..3454db197247c 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -100,7 +100,7 @@ impl EstimateArgs { .await?; let gas = provider.estimate_gas(&tx).block(block.unwrap_or_default()).await?; - println!("{gas}"); + sh_println!("{gas}")?; Ok(()) } } diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index e598a21217787..dc7750490b915 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -77,7 +77,7 @@ impl FindBlockArgs { } matching_block.unwrap_or(low_block) }; - println!("{block_num}"); + sh_println!("{block_num}")?; Ok(()) } diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index b8de8d84deabc..1d9b392964b52 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -93,9 +93,9 @@ impl InterfaceArgs { fs::create_dir_all(parent)?; } fs::write(&loc, res)?; - println!("Saved interface at {}", loc.display()); + sh_println!("Saved interface at {}", loc.display())?; } else { - print!("{res}"); + sh_print!("{res}")?; } Ok(()) diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 51b95cffcace6..b38281d51e341 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -89,9 +89,7 @@ impl LogsArgs { if !subscribe { let logs = cast.filter_logs(filter, json).await?; - - println!("{logs}"); - + sh_println!("{logs}")?; return Ok(()) } diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index 8a45b7363f5cf..7837aaed0d657 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -105,7 +105,7 @@ impl MakeTxArgs { let tx = tx.build(&EthereumWallet::new(signer)).await?; let signed_tx = hex::encode(tx.encoded_2718()); - println!("0x{signed_tx}"); + sh_println!("0x{signed_tx}")?; Ok(()) } diff --git a/crates/cast/bin/cmd/rpc.rs b/crates/cast/bin/cmd/rpc.rs index cae5d3386a68f..d901c760bed00 100644 --- a/crates/cast/bin/cmd/rpc.rs +++ b/crates/cast/bin/cmd/rpc.rs @@ -53,7 +53,7 @@ impl RpcArgs { } else { serde_json::Value::Array(params.into_iter().map(value_or_string).collect()) }; - println!("{}", Cast::new(provider).rpc(&method, params).await?); + sh_println!("{}", Cast::new(provider).rpc(&method, params).await?)?; Ok(()) } } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 5eb6a490da796..bc06547044d4c 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -170,7 +170,7 @@ impl RunArgs { // Set the state to the moment right before the transaction if !self.quick { - println!("Executing previous transactions from the block."); + sh_println!("Executing previous transactions from the block.")?; if let Some(block) = block { let pb = init_progress(block.transactions.len() as u64, "tx"); diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index c8c0faf596230..9503bccbd5499 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -197,12 +197,12 @@ async fn cast_send, T: Transport + Clone>( let tx_hash = pending_tx.inner().tx_hash(); if cast_async { - println!("{tx_hash:#x}"); + sh_println!("{tx_hash:#x}")?; } else { let receipt = cast .receipt(format!("{tx_hash:#x}"), None, confs, Some(timeout), false, to_json) .await?; - println!("{receipt}"); + sh_println!("{receipt}")?; } Ok(()) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index a8ced363912a1..9fca4172e3452 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -92,7 +92,7 @@ impl StorageArgs { // Slot was provided, perform a simple RPC call if let Some(slot) = slot { let cast = Cast::new(provider); - println!("{}", cast.storage(address, slot, block).await?); + sh_println!("{}", cast.storage(address, slot, block).await?)?; return Ok(()); } @@ -120,7 +120,7 @@ impl StorageArgs { // Not a forge project or artifact not found // Get code from Etherscan - eprintln!("No matching artifacts found, fetching source code from Etherscan..."); + sh_warn!("No matching artifacts found, fetching source code from Etherscan...")?; if !self.etherscan.has_key() { eyre::bail!("You must provide an Etherscan API key if you're fetching a remote contract's storage."); @@ -161,7 +161,7 @@ impl StorageArgs { if is_storage_layout_empty(&artifact.storage_layout) && auto_detect { // try recompiling with the minimum version - eprintln!("The requested contract was compiled with {version} while the minimum version for storage layouts is {MIN_SOLC} and as a result the output may be empty."); + sh_warn!("The requested contract was compiled with {version} while the minimum version for storage layouts is {MIN_SOLC} and as a result the output may be empty.")?; let solc = Solc::find_or_install(&MIN_SOLC)?; project.compiler = SolcCompiler::Specific(solc); if let Ok(output) = ProjectCompiler::new().quiet(true).compile(&project) { @@ -223,7 +223,7 @@ async fn fetch_and_print_storage, T: Transport + Clon pretty: bool, ) -> Result<()> { if is_storage_layout_empty(&artifact.storage_layout) { - eprintln!("Storage layout is empty."); + sh_warn!("Storage layout is empty.")?; Ok(()) } else { let layout = artifact.storage_layout.as_ref().unwrap().clone(); @@ -255,7 +255,7 @@ async fn fetch_storage_slots, T: Transport + Clone>( fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Result<()> { if !pretty { - println!("{}", serde_json::to_string_pretty(&serde_json::to_value(layout)?)?); + sh_println!("{}", serde_json::to_string_pretty(&serde_json::to_value(layout)?)?)?; return Ok(()) } @@ -281,7 +281,7 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) ]); } - println!("{table}"); + sh_println!("{table}")?; Ok(()) } diff --git a/crates/cast/bin/cmd/wallet/list.rs b/crates/cast/bin/cmd/wallet/list.rs index 88b9486058294..be29cb22bde98 100644 --- a/crates/cast/bin/cmd/wallet/list.rs +++ b/crates/cast/bin/cmd/wallet/list.rs @@ -1,7 +1,7 @@ use clap::Parser; use eyre::Result; -use foundry_common::fs; +use foundry_common::{fs, sh_err, sh_println}; use foundry_config::Config; use foundry_wallets::multi_wallet::MultiWalletOptsBuilder; @@ -61,12 +61,14 @@ impl ListArgs { .available_senders(self.max_senders.unwrap()) .await? .iter() - .for_each(|sender| println!("{} ({})", sender, $label)); + .for_each(|sender| { + let _ = sh_println!("{} ({})", sender, $label); + }) } } Err(e) => { if !self.all { - println!("{}", e) + sh_err!("{}", e)?; } } } @@ -97,7 +99,7 @@ impl ListArgs { if path.is_file() { if let Some(file_name) = path.file_name() { if let Some(name) = file_name.to_str() { - println!("{name} (Local)"); + sh_println!("{name} (Local)")?; } } } diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 51107c64958a8..1dc2fb1c5824f 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -11,7 +11,7 @@ use cast::revm::primitives::Authorization; use clap::Parser; use eyre::{Context, Result}; use foundry_cli::{opts::RpcOpts, utils}; -use foundry_common::fs; +use foundry_common::{fs, sh_println}; use foundry_config::Config; use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner}; use rand::thread_rng; @@ -259,16 +259,16 @@ impl WalletSubcommands { } )); } else { - println!( + sh_println!( "Created new encrypted keystore file: {}", path.join(uuid).display() - ); - println!("Address: {}", wallet.address().to_checksum(None)); + )?; + sh_println!("Address: {}", wallet.address().to_checksum(None))?; } } if let Some(json) = json_values.as_ref() { - println!("{}", serde_json::to_string_pretty(json)?); + sh_println!("{}", serde_json::to_string_pretty(json)?)?; } } else { for _ in 0..number { @@ -280,17 +280,17 @@ impl WalletSubcommands { "private_key": format!("0x{}", hex::encode(wallet.credential().to_bytes())), })) } else { - println!("Successfully created new keypair."); - println!("Address: {}", wallet.address().to_checksum(None)); - println!( + sh_println!("Successfully created new keypair.")?; + sh_println!("Address: {}", wallet.address().to_checksum(None))?; + sh_println!( "Private key: 0x{}", hex::encode(wallet.credential().to_bytes()) - ); + )?; } } if let Some(json) = json_values.as_ref() { - println!("{}", serde_json::to_string_pretty(json)?); + sh_println!("{}", serde_json::to_string_pretty(json)?)?; } } } @@ -304,7 +304,7 @@ impl WalletSubcommands { }; if !json { - println!("{}", "Generating mnemonic from provided entropy...".yellow()); + sh_println!("{}", "Generating mnemonic from provided entropy...".yellow())?; } let builder = MnemonicBuilder::::default().phrase(phrase.as_str()); @@ -316,9 +316,9 @@ impl WalletSubcommands { wallets.into_iter().map(|b| b.build()).collect::, _>>()?; if !json { - println!("{}", "Successfully generated a new mnemonic.".green()); - println!("Phrase:\n{phrase}"); - println!("\nAccounts:"); + sh_println!("{}", "Successfully generated a new mnemonic.".green())?; + sh_println!("Phrase:\n{phrase}")?; + sh_println!("\nAccounts:")?; } let mut accounts = json!([]); @@ -330,9 +330,9 @@ impl WalletSubcommands { "private_key": format!("0x{}", private_key), })); } else { - println!("- Account {i}:"); - println!("Address: {}", wallet.address()); - println!("Private key: 0x{private_key}\n"); + sh_println!("- Account {i}:")?; + sh_println!("Address: {}", wallet.address())?; + sh_println!("Private key: 0x{private_key}\n")?; } } @@ -341,7 +341,7 @@ impl WalletSubcommands { "mnemonic": phrase, "accounts": accounts, }); - println!("{}", serde_json::to_string_pretty(&obj)?); + sh_println!("{}", serde_json::to_string_pretty(&obj)?)?; } } Self::Vanity(cmd) => { @@ -357,7 +357,7 @@ impl WalletSubcommands { .signer() .await?; let addr = wallet.address(); - println!("{}", addr.to_checksum(None)); + sh_println!("{}", addr.to_checksum(None))?; } Self::Sign { message, data, from_file, no_hash, wallet } => { let wallet = wallet.signer().await?; @@ -375,7 +375,7 @@ impl WalletSubcommands { } else { wallet.sign_message(&Self::hex_str_to_bytes(&message)?).await? }; - println!("0x{}", hex::encode(sig.as_bytes())); + sh_println!("0x{}", hex::encode(sig.as_bytes()))?; } Self::SignAuth { rpc, nonce, chain, wallet, address } => { let wallet = wallet.signer().await?; @@ -393,12 +393,12 @@ impl WalletSubcommands { let auth = Authorization { chain_id, address, nonce }; let signature = wallet.sign_hash(&auth.signature_hash()).await?; let auth = auth.into_signed(signature); - println!("{}", hex::encode_prefixed(alloy_rlp::encode(&auth))); + sh_println!("{}", hex::encode_prefixed(alloy_rlp::encode(&auth)))?; } Self::Verify { message, signature, address } => { let recovered_address = Self::recover_address_from_message(&message, &signature)?; if address == recovered_address { - println!("Validation succeeded. Address {address} signed this message."); + sh_println!("Validation succeeded. Address {address} signed this message.")?; } else { eyre::bail!("Validation failed. Address {address} did not sign this message."); } @@ -459,7 +459,7 @@ flag to set your key via: "`{}` keystore was saved successfully. Address: {:?}", &account_name, address, ); - println!("{}", success_message.green()); + sh_println!("{}", success_message.green())?; } Self::List(cmd) => { cmd.run().await?; @@ -492,13 +492,13 @@ flag to set your key via: match wallet { WalletSigner::Local(wallet) => { if verbose { - println!("Address: {}", wallet.address()); - println!( + sh_println!("Address: {}", wallet.address())?; + sh_println!( "Private key: 0x{}", hex::encode(wallet.credential().to_bytes()) - ); + )?; } else { - println!("0x{}", hex::encode(wallet.credential().to_bytes())); + sh_println!("0x{}", hex::encode(wallet.credential().to_bytes()))?; } } _ => { @@ -536,7 +536,7 @@ flag to set your key via: let success_message = format!("{}'s private key is: {}", &account_name, private_key); - println!("{}", success_message.green()); + sh_println!("{}", success_message.green())?; } }; diff --git a/crates/cast/bin/cmd/wallet/vanity.rs b/crates/cast/bin/cmd/wallet/vanity.rs index 5b597b3f0f52d..2137feb42b31d 100644 --- a/crates/cast/bin/cmd/wallet/vanity.rs +++ b/crates/cast/bin/cmd/wallet/vanity.rs @@ -3,6 +3,7 @@ use alloy_signer::{k256::ecdsa::SigningKey, utils::secret_key_to_address}; use alloy_signer_local::PrivateKeySigner; use clap::Parser; use eyre::Result; +use foundry_common::sh_println; use itertools::Either; use rayon::iter::{self, ParallelIterator}; use regex::Regex; @@ -99,7 +100,7 @@ impl VanityArgs { }; } - println!("Starting to generate vanity address..."); + sh_println!("Starting to generate vanity address...")?; let timer = Instant::now(); let wallet = match (left_exact_hex, left_regex, right_exact_hex, right_regex) { @@ -144,7 +145,7 @@ impl VanityArgs { save_wallet_to_file(&wallet, &save_path)?; } - println!( + sh_println!( "Successfully found vanity address in {:.3} seconds.{}{}\nAddress: {}\nPrivate Key: 0x{}", timer.elapsed().as_secs_f64(), if nonce.is_some() { "\nContract address: " } else { "" }, @@ -155,7 +156,7 @@ impl VanityArgs { }, wallet.address().to_checksum(None), hex::encode(wallet.credential().to_bytes()), - ); + )?; Ok(wallet) } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 1631ce4183fda..bdd316399a471 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -60,53 +60,53 @@ async fn main_args(args: CastArgs) -> Result<()> { match args.cmd { // Constants CastSubcommand::MaxInt { r#type } => { - println!("{}", SimpleCast::max_int(&r#type)?); + sh_println!("{}", SimpleCast::max_int(&r#type)?)?; } CastSubcommand::MinInt { r#type } => { - println!("{}", SimpleCast::min_int(&r#type)?); + sh_println!("{}", SimpleCast::min_int(&r#type)?)?; } CastSubcommand::MaxUint { r#type } => { - println!("{}", SimpleCast::max_int(&r#type)?); + sh_println!("{}", SimpleCast::max_int(&r#type)?)?; } CastSubcommand::AddressZero => { - println!("{:?}", Address::ZERO); + sh_println!("{:?}", Address::ZERO)?; } CastSubcommand::HashZero => { - println!("{:?}", B256::ZERO); + sh_println!("{:?}", B256::ZERO)?; } // Conversions & transformations CastSubcommand::FromUtf8 { text } => { let value = stdin::unwrap(text, false)?; - println!("{}", SimpleCast::from_utf8(&value)); + sh_println!("{}", SimpleCast::from_utf8(&value))? } CastSubcommand::ToAscii { hexdata } => { let value = stdin::unwrap(hexdata, false)?; - println!("{}", SimpleCast::to_ascii(value.trim())?); + sh_println!("{}", SimpleCast::to_ascii(value.trim())?)? } CastSubcommand::ToUtf8 { hexdata } => { let value = stdin::unwrap(hexdata, false)?; - println!("{}", SimpleCast::to_utf8(&value)?); + sh_println!("{}", SimpleCast::to_utf8(&value)?)? } CastSubcommand::FromFixedPoint { value, decimals } => { let (value, decimals) = stdin::unwrap2(value, decimals)?; - println!("{}", SimpleCast::from_fixed_point(&value, &decimals)?); + sh_println!("{}", SimpleCast::from_fixed_point(&value, &decimals)?)? } CastSubcommand::ToFixedPoint { value, decimals } => { let (value, decimals) = stdin::unwrap2(value, decimals)?; - println!("{}", SimpleCast::to_fixed_point(&value, &decimals)?); + sh_println!("{}", SimpleCast::to_fixed_point(&value, &decimals)?)? } CastSubcommand::ConcatHex { data } => { if data.is_empty() { let s = stdin::read(true)?; - println!("{}", SimpleCast::concat_hex(s.split_whitespace())) + sh_println!("{}", SimpleCast::concat_hex(s.split_whitespace()))? } else { - println!("{}", SimpleCast::concat_hex(data)) + sh_println!("{}", SimpleCast::concat_hex(data))? } } CastSubcommand::FromBin => { let hex = stdin::read_bytes(false)?; - println!("{}", hex::encode_prefixed(hex)); + sh_println!("{}", hex::encode_prefixed(hex))? } CastSubcommand::ToHexdata { input } => { let value = stdin::unwrap_line(input)?; @@ -115,67 +115,67 @@ async fn main_args(args: CastArgs) -> Result<()> { s if s.starts_with('/') => hex::encode(fs::read(s)?), s => s.split(':').map(|s| s.trim_start_matches("0x").to_lowercase()).collect(), }; - println!("0x{output}"); + sh_println!("0x{output}")? } CastSubcommand::ToCheckSumAddress { address } => { let value = stdin::unwrap_line(address)?; - println!("{}", value.to_checksum(None)); + sh_println!("{}", value.to_checksum(None))? } CastSubcommand::ToUint256 { value } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_uint256(&value)?); + sh_println!("{}", SimpleCast::to_uint256(&value)?)? } CastSubcommand::ToInt256 { value } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_int256(&value)?); + sh_println!("{}", SimpleCast::to_int256(&value)?)? } CastSubcommand::ToUnit { value, unit } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_unit(&value, &unit)?); + sh_println!("{}", SimpleCast::to_unit(&value, &unit)?)? } CastSubcommand::FromWei { value, unit } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::from_wei(&value, &unit)?); + sh_println!("{}", SimpleCast::from_wei(&value, &unit)?)? } CastSubcommand::ToWei { value, unit } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_wei(&value, &unit)?); + sh_println!("{}", SimpleCast::to_wei(&value, &unit)?)? } CastSubcommand::FromRlp { value } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::from_rlp(value)?); + sh_println!("{}", SimpleCast::from_rlp(value)?)? } CastSubcommand::ToRlp { value } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_rlp(&value)?); + sh_println!("{}", SimpleCast::to_rlp(&value)?)? } CastSubcommand::ToHex(ToBaseArgs { value, base_in }) => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "hex")?); + sh_println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "hex")?)? } CastSubcommand::ToDec(ToBaseArgs { value, base_in }) => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "dec")?); + sh_println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), "dec")?)? } CastSubcommand::ToBase { base: ToBaseArgs { value, base_in }, base_out } => { let (value, base_out) = stdin::unwrap2(value, base_out)?; - println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), &base_out)?); + sh_println!("{}", SimpleCast::to_base(&value, base_in.as_deref(), &base_out)?)? } CastSubcommand::ToBytes32 { bytes } => { let value = stdin::unwrap_line(bytes)?; - println!("{}", SimpleCast::to_bytes32(&value)?); + sh_println!("{}", SimpleCast::to_bytes32(&value)?)? } CastSubcommand::FormatBytes32String { string } => { let value = stdin::unwrap_line(string)?; - println!("{}", SimpleCast::format_bytes32_string(&value)?); + sh_println!("{}", SimpleCast::format_bytes32_string(&value)?)? } CastSubcommand::ParseBytes32String { bytes } => { let value = stdin::unwrap_line(bytes)?; - println!("{}", SimpleCast::parse_bytes32_string(&value)?); + sh_println!("{}", SimpleCast::parse_bytes32_string(&value)?)? } CastSubcommand::ParseBytes32Address { bytes } => { let value = stdin::unwrap_line(bytes)?; - println!("{}", SimpleCast::parse_bytes32_address(&value)?); + sh_println!("{}", SimpleCast::parse_bytes32_address(&value)?)? } // ABI encoding & decoding @@ -185,9 +185,9 @@ async fn main_args(args: CastArgs) -> Result<()> { } CastSubcommand::AbiEncode { sig, packed, args } => { if !packed { - println!("{}", SimpleCast::abi_encode(&sig, &args)?); + sh_println!("{}", SimpleCast::abi_encode(&sig, &args)?)? } else { - println!("{}", SimpleCast::abi_encode_packed(&sig, &args)?); + sh_println!("{}", SimpleCast::abi_encode_packed(&sig, &args)?)? } } CastSubcommand::CalldataDecode { sig, calldata, json } => { @@ -195,26 +195,26 @@ async fn main_args(args: CastArgs) -> Result<()> { print_tokens(&tokens, json) } CastSubcommand::CalldataEncode { sig, args } => { - println!("{}", SimpleCast::calldata_encode(sig, &args)?); + sh_println!("{}", SimpleCast::calldata_encode(sig, &args)?)?; } CastSubcommand::Interface(cmd) => cmd.run().await?, CastSubcommand::Bind(cmd) => cmd.run().await?, CastSubcommand::PrettyCalldata { calldata, offline } => { let calldata = stdin::unwrap_line(calldata)?; - println!("{}", pretty_calldata(&calldata, offline).await?); + sh_println!("{}", pretty_calldata(&calldata, offline).await?)?; } CastSubcommand::Sig { sig, optimize } => { let sig = stdin::unwrap_line(sig)?; match optimize { Some(opt) => { - println!("Starting to optimize signature..."); + sh_println!("Starting to optimize signature...")?; let start_time = Instant::now(); let (selector, signature) = SimpleCast::get_selector(&sig, opt)?; - println!("Successfully generated in {:?}", start_time.elapsed()); - println!("Selector: {selector}"); - println!("Optimized signature: {signature}"); + sh_println!("Successfully generated in {:?}", start_time.elapsed())?; + sh_println!("Selector: {selector}")?; + sh_println!("Optimized signature: {signature}")?; } - None => println!("{}", SimpleCast::get_selector(&sig, 0)?.0), + None => sh_println!("{}", SimpleCast::get_selector(&sig, 0)?.0)?, } } @@ -223,10 +223,10 @@ async fn main_args(args: CastArgs) -> Result<()> { CastSubcommand::Age { block, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!( + sh_println!( "{}", Cast::new(provider).age(block.unwrap_or(BlockId::Number(Latest))).await? - ); + )? } CastSubcommand::Balance { block, who, ether, rpc, erc20 } => { let config = Config::from(&rpc); @@ -237,14 +237,14 @@ async fn main_args(args: CastArgs) -> Result<()> { Some(token) => { let balance = Cast::new(&provider).erc20_balance(token, account_addr, block).await?; - println!("{}", format_uint_exp(balance)); + sh_println!("{}", format_uint_exp(balance))? } None => { let value = Cast::new(&provider).balance(account_addr, block).await?; if ether { - println!("{}", SimpleCast::from_wei(&value.to_string(), "eth")?); + sh_println!("{}", SimpleCast::from_wei(&value.to_string(), "eth")?)? } else { - println!("{value}"); + sh_println!("{value}")? } } } @@ -252,20 +252,20 @@ async fn main_args(args: CastArgs) -> Result<()> { CastSubcommand::BaseFee { block, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!( + sh_println!( "{}", Cast::new(provider).base_fee(block.unwrap_or(BlockId::Number(Latest))).await? - ); + )? } CastSubcommand::Block { block, full, field, json, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!( + sh_println!( "{}", Cast::new(provider) .block(block.unwrap_or(BlockId::Number(Latest)), full, field, json) .await? - ); + )? } CastSubcommand::BlockNumber { rpc, block } => { let config = Config::from(&rpc); @@ -281,34 +281,34 @@ async fn main_args(args: CastArgs) -> Result<()> { } None => Cast::new(provider).block_number().await?, }; - println!("{number}"); + sh_println!("{number}")? } CastSubcommand::Chain { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!("{}", Cast::new(provider).chain().await?); + sh_println!("{}", Cast::new(provider).chain().await?)? } CastSubcommand::ChainId { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!("{}", Cast::new(provider).chain_id().await?); + sh_println!("{}", Cast::new(provider).chain_id().await?)? } CastSubcommand::Client { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!("{}", provider.get_client_version().await?); + sh_println!("{}", provider.get_client_version().await?)? } CastSubcommand::Code { block, who, disassemble, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - println!("{}", Cast::new(provider).code(who, block, disassemble).await?); + sh_println!("{}", Cast::new(provider).code(who, block, disassemble).await?)? } CastSubcommand::Codesize { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - println!("{}", Cast::new(provider).codesize(who, block).await?); + sh_println!("{}", Cast::new(provider).codesize(who, block).await?)? } CastSubcommand::ComputeAddress { address, nonce, rpc } => { let config = Config::from(&rpc); @@ -316,10 +316,10 @@ async fn main_args(args: CastArgs) -> Result<()> { let address: Address = stdin::unwrap_line(address)?.parse()?; let computed = Cast::new(provider).compute_address(address, nonce).await?; - println!("Computed Address: {}", computed.to_checksum(None)); + sh_println!("Computed Address: {}", computed.to_checksum(None))? } CastSubcommand::Disassemble { bytecode } => { - println!("{}", SimpleCast::disassemble(&hex::decode(bytecode)?)?); + sh_println!("{}", SimpleCast::disassemble(&hex::decode(bytecode)?)?)? } CastSubcommand::Selectors { bytecode, resolve } => { let functions = SimpleCast::extract_functions(&bytecode)?; @@ -337,9 +337,9 @@ async fn main_args(args: CastArgs) -> Result<()> { { if resolve { let resolved = &resolve_results[pos]; - println!("{selector}\t{arguments:max_args_len$}\t{state_mutability:max_mutability_len$}\t{resolved}"); + sh_println!("{selector}\t{arguments:max_args_len$}\t{state_mutability:max_mutability_len$}\t{resolved}")? } else { - println!("{selector}\t{arguments:max_args_len$}\t{state_mutability}"); + sh_println!("{selector}\t{arguments:max_args_len$}\t{state_mutability}")? } } } @@ -347,45 +347,45 @@ async fn main_args(args: CastArgs) -> Result<()> { CastSubcommand::GasPrice { rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!("{}", Cast::new(provider).gas_price().await?); + sh_println!("{}", Cast::new(provider).gas_price().await?)?; } CastSubcommand::Index { key_type, key, slot_number } => { - println!("{}", SimpleCast::index(&key_type, &key, &slot_number)?); + sh_println!("{}", SimpleCast::index(&key_type, &key, &slot_number)?)?; } CastSubcommand::IndexErc7201 { id, formula_id } => { eyre::ensure!(formula_id == "erc7201", "unsupported formula ID: {formula_id}"); let id = stdin::unwrap_line(id)?; - println!("{}", foundry_common::erc7201(&id)); + sh_println!("{}", foundry_common::erc7201(&id))?; } CastSubcommand::Implementation { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - println!("{}", Cast::new(provider).implementation(who, block).await?); + sh_println!("{}", Cast::new(provider).implementation(who, block).await?)?; } CastSubcommand::Admin { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - println!("{}", Cast::new(provider).admin(who, block).await?); + sh_println!("{}", Cast::new(provider).admin(who, block).await?)?; } CastSubcommand::Nonce { block, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - println!("{}", Cast::new(provider).nonce(who, block).await?); + sh_println!("{}", Cast::new(provider).nonce(who, block).await?)?; } CastSubcommand::Codehash { block, who, slots, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - println!("{}", Cast::new(provider).codehash(who, slots, block).await?); + sh_println!("{}", Cast::new(provider).codehash(who, slots, block).await?)?; } CastSubcommand::StorageRoot { block, who, slots, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - println!("{}", Cast::new(provider).storage_root(who, slots, block).await?); + sh_println!("{}", Cast::new(provider).storage_root(who, slots, block).await?)?; } CastSubcommand::Proof { address, slots, rpc, block } => { let config = Config::from(&rpc); @@ -395,7 +395,7 @@ async fn main_args(args: CastArgs) -> Result<()> { .get_proof(address, slots.into_iter().collect()) .block_id(block.unwrap_or_default()) .await?; - println!("{}", serde_json::to_string(&value)?); + sh_println!("{}", serde_json::to_string(&value)?)?; } CastSubcommand::Rpc(cmd) => cmd.run().await?, CastSubcommand::Storage(cmd) => cmd.run().await?, @@ -412,21 +412,21 @@ async fn main_args(args: CastArgs) -> Result<()> { let tx_hash = pending_tx.inner().tx_hash(); if cast_async { - println!("{tx_hash:#x}"); + sh_println!("{tx_hash:#x}")?; } else { let receipt = pending_tx.get_receipt().await?; - println!("{}", serde_json::json!(receipt)); + sh_println!("{}", serde_json::json!(receipt))?; } } CastSubcommand::Receipt { tx_hash, field, json, cast_async, confirmations, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - println!( + sh_println!( "{}", Cast::new(provider) .receipt(tx_hash, field, confirmations, None, cast_async, json) .await? - ); + )? } CastSubcommand::Run(cmd) => cmd.run().await?, CastSubcommand::SendTx(cmd) => cmd.run().await?, @@ -437,7 +437,7 @@ async fn main_args(args: CastArgs) -> Result<()> { // Can use either --raw or specify raw as a field let raw = raw || field.as_ref().is_some_and(|f| f == "raw"); - println!("{}", Cast::new(&provider).transaction(tx_hash, field, raw, json).await?) + sh_println!("{}", Cast::new(&provider).transaction(tx_hash, field, raw, json).await?)? } // 4Byte @@ -448,13 +448,15 @@ async fn main_args(args: CastArgs) -> Result<()> { eyre::bail!("No matching function signatures found for selector `{selector}`"); } for sig in sigs { - println!("{sig}"); + sh_println!("{sig}")? } } CastSubcommand::FourByteDecode { calldata, json } => { let calldata = stdin::unwrap_line(calldata)?; let sigs = decode_calldata(&calldata).await?; - sigs.iter().enumerate().for_each(|(i, sig)| println!("{}) \"{sig}\"", i + 1)); + sigs.iter().enumerate().for_each(|(i, sig)| { + let _ = sh_println!("{}) \"{sig}\"", i + 1); + }); let sig = match sigs.len() { 0 => eyre::bail!("No signatures found"), @@ -475,7 +477,7 @@ async fn main_args(args: CastArgs) -> Result<()> { eyre::bail!("No matching event signatures found for topic `{topic}`"); } for sig in sigs { - println!("{sig}"); + sh_println!("{sig}")? } } CastSubcommand::UploadSignature { signatures } => { @@ -492,7 +494,7 @@ async fn main_args(args: CastArgs) -> Result<()> { // ENS CastSubcommand::Namehash { name } => { let name = stdin::unwrap_line(name)?; - println!("{}", namehash(&name)); + sh_println!("{}", namehash(&name))? } CastSubcommand::LookupAddress { who, rpc, verify } => { let config = Config::from(&rpc); @@ -507,7 +509,7 @@ async fn main_args(args: CastArgs) -> Result<()> { "Reverse lookup verification failed: got `{address}`, expected `{who}`" ); } - println!("{name}"); + sh_println!("{name}")? } CastSubcommand::ResolveName { who, rpc, verify } => { let config = Config::from(&rpc); @@ -522,7 +524,7 @@ async fn main_args(args: CastArgs) -> Result<()> { "Forward lookup verification failed: got `{name}`, expected `{who}`" ); } - println!("{address}"); + sh_println!("{address}")? } // Misc @@ -534,30 +536,32 @@ async fn main_args(args: CastArgs) -> Result<()> { match String::from_utf8(bytes) { Ok(s) => { let s = SimpleCast::keccak(&s)?; - println!("{s}"); + sh_println!("{s}")? } Err(e) => { let hash = keccak256(e.as_bytes()); let s = hex::encode(hash); - println!("0x{s}"); + sh_println!("0x{s}")? } }; } CastSubcommand::HashMessage { message } => { let message = stdin::unwrap_line(message)?; - println!("{}", eip191_hash_message(message)); + sh_println!("{}", eip191_hash_message(message))? } CastSubcommand::SigEvent { event_string } => { let event_string = stdin::unwrap_line(event_string)?; let parsed_event = get_event(&event_string)?; - println!("{:?}", parsed_event.selector()); - } - CastSubcommand::LeftShift { value, bits, base_in, base_out } => { - println!("{}", SimpleCast::left_shift(&value, &bits, base_in.as_deref(), &base_out)?); - } - CastSubcommand::RightShift { value, bits, base_in, base_out } => { - println!("{}", SimpleCast::right_shift(&value, &bits, base_in.as_deref(), &base_out)?); - } + sh_println!("{:?}", parsed_event.selector())? + } + CastSubcommand::LeftShift { value, bits, base_in, base_out } => sh_println!( + "{}", + SimpleCast::left_shift(&value, &bits, base_in.as_deref(), &base_out)? + )?, + CastSubcommand::RightShift { value, bits, base_in, base_out } => sh_println!( + "{}", + SimpleCast::right_shift(&value, &bits, base_in.as_deref(), &base_out)? + )?, CastSubcommand::EtherscanSource { address, directory, etherscan, flatten } => { let config = Config::from(ðerscan); let chain = config.chain.unwrap_or_default(); @@ -568,7 +572,7 @@ async fn main_args(args: CastArgs) -> Result<()> { .await? } (None, false) => { - println!("{}", SimpleCast::etherscan_source(chain, address, api_key).await?); + sh_println!("{}", SimpleCast::etherscan_source(chain, address, api_key).await?)? } (dir, true) => { SimpleCast::etherscan_source_flatten(chain, address, api_key, dir).await?; @@ -593,11 +597,11 @@ async fn main_args(args: CastArgs) -> Result<()> { let tx = stdin::unwrap_line(tx)?; let tx = SimpleCast::decode_raw_transaction(&tx)?; - println!("{}", serde_json::to_string_pretty(&tx)?); + sh_println!("{}", serde_json::to_string_pretty(&tx)?)? } CastSubcommand::DecodeEof { eof } => { let eof = stdin::unwrap_line(eof)?; - println!("{}", SimpleCast::decode_eof(&eof)?); + sh_println!("{}", SimpleCast::decode_eof(&eof)?)? } }; Ok(()) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 2dd56859eff60..ea717b6805d03 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -56,6 +56,9 @@ mod rlp_converter; use rlp_converter::Item; +#[macro_use] +extern crate foundry_common; + // TODO: CastContract with common contract initializers? Same for CastProviders? sol! { @@ -1947,9 +1950,9 @@ impl SimpleCast { if let Some(path) = output_path { fs::create_dir_all(path.parent().unwrap())?; fs::write(&path, flattened)?; - println!("Flattened file written at {}", path.display()); + sh_println!("Flattened file written at {}", path.display())? } else { - println!("{flattened}"); + sh_println!("{flattened}")? } Ok(()) diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index 05e3462cb8260..faa5cfd0569ee 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -108,6 +108,7 @@ mod test { } #[test] + #[allow(clippy::disallowed_macros)] fn encode_decode_test() -> alloy_rlp::Result<()> { let parameters = vec![ (1, b"\xc0".to_vec(), Item::Array(vec![])), @@ -149,6 +150,7 @@ mod test { } #[test] + #[allow(clippy::disallowed_macros)] fn deserialize_from_str_test_hex() -> JsonResult<()> { let parameters = vec![ (1, "[\"\"]", Item::Array(vec![Item::Data(vec![])])), From ab8ebf667d04eaeb0826adf17cc238c5a6719936 Mon Sep 17 00:00:00 2001 From: Pierrick Couderc Date: Thu, 24 Oct 2024 19:02:57 +0200 Subject: [PATCH 1598/1963] fix(cli): etherlink needs eth_estimateGas for gas calculation (#9188) --- crates/cli/src/utils/cmd.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index eab1e0b318c09..e4d0a51146272 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -171,6 +171,8 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { NamedChain::ArbitrumGoerli | NamedChain::ArbitrumSepolia | NamedChain::ArbitrumTestnet | + NamedChain::Etherlink | + NamedChain::EtherlinkTestnet | NamedChain::Karura | NamedChain::KaruraTestnet | NamedChain::Mantle | From 216b60a9467a29c89da578ba4495afd1dfb54f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:26:07 +0100 Subject: [PATCH 1599/1963] fix(fmt): multiline single param only if func definition is multiline for `all_params` (#9187) * test: adjust single param multiline expected behavior * fix: `AllParams` single param multiline condition * refactor: try simplifying the condition logic --- crates/fmt/src/formatter.rs | 15 +++++++++------ .../FunctionDefinition/all-params.fmt.sol | 8 ++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 9213235fe331b..6bb814e232691 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -1638,14 +1638,17 @@ impl<'a, W: Write> Formatter<'a, W> { ¶ms, ",", )?; - // Write new line if we have only one parameter and params first all multi set. - if params.len() == 1 && + // Write new line if we have only one parameter and params first set, + // or if the function definition is multiline and all params set. + let single_param_multiline = matches!( + fmt.config.multiline_func_header, + MultilineFuncHeaderStyle::ParamsFirst + ) || params_multiline && matches!( fmt.config.multiline_func_header, - MultilineFuncHeaderStyle::ParamsFirst | - MultilineFuncHeaderStyle::AllParams - ) - { + MultilineFuncHeaderStyle::AllParams + ); + if params.len() == 1 && single_param_multiline { writeln!(fmt.buf())?; } fmt.write_chunks_separated(¶ms, ",", params_multiline)?; diff --git a/crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol b/crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol index f723b00496b63..db7164d284a54 100644 --- a/crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol +++ b/crates/fmt/testdata/FunctionDefinition/all-params.fmt.sol @@ -3,9 +3,7 @@ interface FunctionInterfaces { function noParamsNoModifiersNoReturns(); - function oneParam( - uint256 x - ); + function oneParam(uint256 x); function oneModifier() modifier1; @@ -345,9 +343,7 @@ contract FunctionDefinitions { a = 1; } - function oneParam( - uint256 x - ) { + function oneParam(uint256 x) { a = 1; } From 6b4ad0ddcf52445acb434e52339bfa15845d798b Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:27:00 +0200 Subject: [PATCH 1600/1963] chore(`chisel`): enforce `common::shell` for chisel binary (#9177) * enforce common::shell for chisel binary * revert accidental fmt changes * change UnrecognizedCommand(e) to use sh_err! * avoid message painting, use default error formatting for consistency * revert color changes as this is in a REPL * avoid double rendering of error prefix --- crates/chisel/bin/main.rs | 53 +++++++++++++++-------------- crates/chisel/src/dispatcher.rs | 24 +++++++------ crates/chisel/src/executor.rs | 14 ++++---- crates/chisel/src/lib.rs | 3 ++ crates/chisel/src/session_source.rs | 4 +-- 5 files changed, 53 insertions(+), 45 deletions(-) diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index c612a504706fc..17697688bb3e5 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -27,6 +27,9 @@ use std::path::PathBuf; use tracing::debug; use yansi::Paint; +#[macro_use] +extern crate foundry_common; + #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; @@ -148,9 +151,9 @@ async fn main_args(args: Chisel) -> eyre::Result<()> { let sessions = dispatcher.dispatch_command(ChiselCommand::ListSessions, &[]).await; match sessions { DispatchResult::CommandSuccess(Some(session_list)) => { - println!("{session_list}"); + sh_println!("{session_list}")?; } - DispatchResult::CommandFailed(e) => eprintln!("{e}"), + DispatchResult::CommandFailed(e) => sh_err!("{e}")?, _ => panic!("Unexpected result: Please report this bug."), } return Ok(()) @@ -160,7 +163,7 @@ async fn main_args(args: Chisel) -> eyre::Result<()> { match dispatcher.dispatch_command(ChiselCommand::Load, &[id]).await { DispatchResult::CommandSuccess(_) => { /* Continue */ } DispatchResult::CommandFailed(e) => { - eprintln!("{e}"); + sh_err!("{e}")?; return Ok(()) } _ => panic!("Unexpected result! Please report this bug."), @@ -170,7 +173,7 @@ async fn main_args(args: Chisel) -> eyre::Result<()> { if matches!(args.cmd, Some(ChiselSubcommand::View { .. })) { match dispatcher.dispatch_command(ChiselCommand::Source, &[]).await { DispatchResult::CommandSuccess(Some(source)) => { - println!("{source}"); + sh_println!("{source}")?; } _ => panic!("Unexpected result! Please report this bug."), } @@ -179,14 +182,14 @@ async fn main_args(args: Chisel) -> eyre::Result<()> { } Some(ChiselSubcommand::ClearCache) => { match dispatcher.dispatch_command(ChiselCommand::ClearCache, &[]).await { - DispatchResult::CommandSuccess(Some(msg)) => println!("{}", msg.green()), - DispatchResult::CommandFailed(e) => eprintln!("{e}"), + DispatchResult::CommandSuccess(Some(msg)) => sh_println!("{}", msg.green())?, + DispatchResult::CommandFailed(e) => sh_err!("{e}")?, _ => panic!("Unexpected result! Please report this bug."), } return Ok(()) } Some(ChiselSubcommand::Eval { command }) => { - dispatch_repl_line(&mut dispatcher, command).await; + dispatch_repl_line(&mut dispatcher, command).await?; return Ok(()) } None => { /* No chisel subcommand present; Continue */ } @@ -205,7 +208,7 @@ async fn main_args(args: Chisel) -> eyre::Result<()> { } // Print welcome header - println!("Welcome to Chisel! Type `{}` to show available commands.", "!help".green()); + sh_println!("Welcome to Chisel! Type `{}` to show available commands.", "!help".green())?; // Begin Rustyline loop loop { @@ -224,20 +227,20 @@ async fn main_args(args: Chisel) -> eyre::Result<()> { interrupt = false; // Dispatch and match results - let errored = dispatch_repl_line(&mut dispatcher, &line).await; + let errored = dispatch_repl_line(&mut dispatcher, &line).await?; rl.helper_mut().unwrap().set_errored(errored); } Err(ReadlineError::Interrupted) => { if interrupt { break } else { - println!("(To exit, press Ctrl+C again)"); + sh_println!("(To exit, press Ctrl+C again)")?; interrupt = true; } } Err(ReadlineError::Eof) => break, Err(err) => { - println!("Error: {err:?}"); + sh_err!("{err:?}")?; break } } @@ -262,25 +265,25 @@ impl Provider for Chisel { } /// Evaluate a single Solidity line. -async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) -> bool { +async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) -> eyre::Result { let r = dispatcher.dispatch(line).await; match &r { DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => { debug!(%line, ?msg, "dispatch success"); if let Some(msg) = msg { - println!("{}", msg.green()); + sh_println!("{}", msg.green())?; } }, - DispatchResult::UnrecognizedCommand(e) => eprintln!("{e}"), + DispatchResult::UnrecognizedCommand(e) => sh_err!("{e}")?, DispatchResult::SolangParserFailed(e) => { - eprintln!("{}", "Compilation error".red()); - eprintln!("{}", format!("{e:?}").red()); + sh_err!("{}", "Compilation error".red())?; + sh_eprintln!("{}", format!("{e:?}").red())?; } - DispatchResult::FileIoError(e) => eprintln!("{}", format!("⚒️ Chisel File IO Error - {e}").red()), - DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => eprintln!("{}", msg.red()), - DispatchResult::Failure(None) => eprintln!("{}\nPlease Report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose", "⚒️ Unknown Chisel Error ⚒️".red()), + DispatchResult::FileIoError(e) => sh_err!("{}", format!("File IO - {e}").red())?, + DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => sh_err!("{}", msg.red())?, + DispatchResult::Failure(None) => sh_err!("Please report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose")?, } - r.is_error() + Ok(r.is_error()) } /// Evaluate multiple Solidity source files contained within a @@ -291,20 +294,20 @@ async fn evaluate_prelude( ) -> eyre::Result<()> { let Some(prelude_dir) = maybe_prelude else { return Ok(()) }; if prelude_dir.is_file() { - println!("{} {}", "Loading prelude source file:".yellow(), prelude_dir.display(),); + sh_println!("{} {}", "Loading prelude source file:".yellow(), prelude_dir.display())?; load_prelude_file(dispatcher, prelude_dir).await?; - println!("{}\n", "Prelude source file loaded successfully!".green()); + sh_println!("{}\n", "Prelude source file loaded successfully!".green())?; } else { let prelude_sources = fs::files_with_ext(&prelude_dir, "sol"); let mut print_success_msg = false; for source_file in prelude_sources { print_success_msg = true; - println!("{} {}", "Loading prelude source file:".yellow(), source_file.display()); + sh_println!("{} {}", "Loading prelude source file:".yellow(), source_file.display())?; load_prelude_file(dispatcher, source_file).await?; } if print_success_msg { - println!("{}\n", "All prelude source files loaded successfully!".green()); + sh_println!("{}\n", "All prelude source files loaded successfully!".green())?; } } Ok(()) @@ -314,7 +317,7 @@ async fn evaluate_prelude( async fn load_prelude_file(dispatcher: &mut ChiselDispatcher, file: PathBuf) -> eyre::Result<()> { let prelude = fs::read_to_string(file) .wrap_err("Could not load source file. Are you sure this path is correct?")?; - dispatch_repl_line(dispatcher, &prelude).await; + dispatch_repl_line(dispatcher, &prelude).await?; Ok(()) } diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 6805edd45e43b..d69de3bf540e5 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -275,7 +275,7 @@ impl ChiselDispatcher { if let Err(e) = self.session.write() { return DispatchResult::FileIoError(e.into()) } - println!("{}", "Saved current session!".green()); + let _ = sh_println!("{}", "Saved current session!".green()); } // Parse the arguments @@ -426,7 +426,7 @@ impl ChiselDispatcher { if matches!(cmd, ChiselCommand::MemDump) { // Print memory by word (0..mem.len()).step_by(32).for_each(|i| { - println!( + let _ = sh_println!( "{}: {}", format!("[0x{:02x}:0x{:02x}]", i, i + 32).yellow(), hex::encode_prefixed(&mem[i..i + 32]).cyan() @@ -435,7 +435,7 @@ impl ChiselDispatcher { } else { // Print all stack items (0..stack.len()).rev().for_each(|i| { - println!( + let _ = sh_println!( "{}: {}", format!("[{}]", stack.len() - i - 1).yellow(), format!("0x{:02x}", stack[i]).cyan() @@ -712,9 +712,9 @@ impl ChiselDispatcher { // Show console logs, if there are any let decoded_logs = decode_console_logs(&res.logs); if !decoded_logs.is_empty() { - println!("{}", "Logs:".green()); + let _ = sh_println!("{}", "Logs:".green()); for log in decoded_logs { - println!(" {log}"); + let _ = sh_println!(" {log}"); } } } @@ -830,7 +830,9 @@ impl ChiselDispatcher { // Should change up how this works. match source.inspect(input).await { // Continue and print - Ok((true, Some(res))) => println!("{res}"), + Ok((true, Some(res))) => { + let _ = sh_println!("{res}"); + } Ok((true, None)) => {} // Return successfully Ok((false, res)) => { @@ -859,9 +861,9 @@ impl ChiselDispatcher { // Show console logs, if there are any let decoded_logs = decode_console_logs(&res.logs); if !decoded_logs.is_empty() { - println!("{}", "Logs:".green()); + let _ = sh_println!("{}", "Logs:".green()); for log in decoded_logs { - println!(" {log}"); + let _ = sh_println!(" {log}"); } } @@ -948,12 +950,12 @@ impl ChiselDispatcher { eyre::bail!("Unexpected error: No traces gathered. Please report this as a bug: https://github.com/foundry-rs/foundry/issues/new?assignees=&labels=T-bug&template=BUG-FORM.yml"); } - println!("{}", "Traces:".green()); + sh_println!("{}", "Traces:".green())?; for (kind, trace) in &mut result.traces { // Display all Setup + Execution traces. if matches!(kind, TraceKind::Setup | TraceKind::Execution) { decode_trace_arena(trace, decoder).await?; - println!("{}", render_trace_arena(trace)); + sh_println!("{}", render_trace_arena(trace))?; } } @@ -970,7 +972,7 @@ impl ChiselDispatcher { /// /// A formatted error [String]. pub fn make_error(msg: T) -> String { - format!("{} {}", format!("{CHISEL_CHAR} Chisel Error:").red(), msg.red()) + format!("{}", msg.red()) } } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 1a2267719c569..b7f3973b09d51 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -179,7 +179,7 @@ impl SessionSource { Ok((_, res)) => (res, Some(err)), Err(_) => { if self.config.foundry_config.verbosity >= 3 { - eprintln!("Could not inspect: {err}"); + sh_err!("Could not inspect: {err}")?; } return Ok((true, None)) } @@ -207,7 +207,7 @@ impl SessionSource { // we were unable to check the event if self.config.foundry_config.verbosity >= 3 { - eprintln!("Failed eval: {err}"); + sh_err!("Failed eval: {err}")?; } debug!(%err, %input, "failed abi encode input"); @@ -221,9 +221,9 @@ impl SessionSource { } let decoded_logs = decode_console_logs(&res.logs); if !decoded_logs.is_empty() { - println!("{}", "Logs:".green()); + sh_println!("{}", "Logs:".green())?; for log in decoded_logs { - println!(" {log}"); + sh_println!(" {log}")?; } } @@ -1709,12 +1709,12 @@ mod tests { match solc { Ok((v, solc)) => { // successfully installed - eprintln!("found installed Solc v{v} @ {}", solc.solc.display()); + let _ = sh_println!("found installed Solc v{v} @ {}", solc.solc.display()); break } Err(e) => { // try reinstalling - eprintln!("error while trying to re-install Solc v{version}: {e}"); + let _ = sh_err!("error while trying to re-install Solc v{version}: {e}"); let solc = Solc::blocking_install(&version.parse().unwrap()); if solc.map_err(SolcError::from).is_ok() { *is_preinstalled = true; @@ -1753,7 +1753,7 @@ mod tests { if let Err(e) = s.parse() { for err in e { - eprintln!("{}:{}: {}", err.loc.start(), err.loc.end(), err.message); + let _ = sh_eprintln!("{}:{}: {}", err.loc.start(), err.loc.end(), err.message); } let source = s.to_repl_source(); panic!("could not parse input:\n{source}") diff --git a/crates/chisel/src/lib.rs b/crates/chisel/src/lib.rs index 9e7dcc9fb829f..ccae2db2ddbee 100644 --- a/crates/chisel/src/lib.rs +++ b/crates/chisel/src/lib.rs @@ -1,6 +1,9 @@ #![doc = include_str!("../README.md")] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + pub mod dispatcher; pub mod cmd; diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index f80761e0de86b..128873167a44c 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -98,7 +98,7 @@ impl SessionSourceConfig { SolcReq::Version(version) } else { if !self.foundry_config.offline { - print!("{}", "No solidity versions installed! ".green()); + sh_print!("{}", "No solidity versions installed! ".green())?; } // use default SolcReq::Version(Version::new(0, 8, 19)) @@ -112,7 +112,7 @@ impl SessionSourceConfig { if self.foundry_config.offline { eyre::bail!("can't install missing solc {version} in offline mode") } - println!("{}", format!("Installing solidity version {version}...").green()); + sh_println!("{}", format!("Installing solidity version {version}...").green())?; Solc::blocking_install(&version)? }; Ok(solc) From bcef90556bd6755cedce16d7cd37c0f7f444b067 Mon Sep 17 00:00:00 2001 From: Kien Trinh <51135161+kien6034@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:58:02 +0700 Subject: [PATCH 1601/1963] feat(`cast`): add flag equivalents of parseUnits, formatUnits (#9165) * feat: base func for parseunints and formatuints * test: update doc and tests * fix: function alias * test: cast test * refacctor: helper fucnction * Update crates/cast/tests/cli/main.rs * revert: format uints function cattest func name --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/cast/bin/args.rs | 32 ++++++++++++++++++++++ crates/cast/bin/main.rs | 8 ++++++ crates/cast/src/lib.rs | 51 ++++++++++++++++++++++++++++++++--- crates/cast/tests/cli/main.rs | 36 +++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index e4c8dcb4cda56..6cbfd73f79883 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -233,6 +233,38 @@ pub enum CastSubcommand { unit: String, }, + /// Convert a number from decimal to smallest unit with arbitrary decimals. + /// + /// Examples: + /// - 1.0 6 (for USDC, result: 1000000) + /// - 2.5 12 (for 12 decimals token, result: 2500000000000) + /// - 1.23 3 (for 3 decimals token, result: 1230) + #[command(visible_aliases = &["--parse-units", "pun"])] + ParseUnits { + /// The value to convert. + value: Option, + + /// The unit to convert to. + #[arg(default_value = "18")] + unit: u8, + }, + + /// Format a number from smallest unit to decimal with arbitrary decimals. + /// + /// Examples: + /// - 1000000 6 (for USDC, result: 1.0) + /// - 2500000000000 12 (for 12 decimals, result: 2.5) + /// - 1230 3 (for 3 decimals, result: 1.23) + #[command(visible_aliases = &["--format-units", "fun"])] + FormatUnits { + /// The value to format. + value: Option, + + /// The unit to format to. + #[arg(default_value = "18")] + unit: u8, + }, + /// Convert an ETH amount to wei. /// /// Consider using --to-unit. diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index bdd316399a471..90367d106e8a8 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -133,6 +133,14 @@ async fn main_args(args: CastArgs) -> Result<()> { let value = stdin::unwrap_line(value)?; sh_println!("{}", SimpleCast::to_unit(&value, &unit)?)? } + CastSubcommand::ParseUnits { value, unit } => { + let value = stdin::unwrap_line(value)?; + println!("{}", SimpleCast::parse_units(&value, unit)?); + } + CastSubcommand::FormatUnits { value, unit } => { + let value = stdin::unwrap_line(value)?; + println!("{}", SimpleCast::format_units(&value, unit)?); + } CastSubcommand::FromWei { value, unit } => { let value = stdin::unwrap_line(value)?; sh_println!("{}", SimpleCast::from_wei(&value, &unit)?)? diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index ea717b6805d03..d40a4a5954aa8 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1354,8 +1354,54 @@ impl SimpleCast { .wrap_err("Could not convert to uint")? .0; let unit = unit.parse().wrap_err("could not parse units")?; - let mut formatted = ParseUnits::U256(value).format_units(unit); + Ok(Self::format_unit_as_string(value, unit)) + } + + /// Convert a number into a uint with arbitrary decimals. + /// + /// # Example + /// + /// ``` + /// use cast::SimpleCast as Cast; + /// + /// # fn main() -> eyre::Result<()> { + /// assert_eq!(Cast::parse_units("1.0", 6)?, "1000000"); // USDC (6 decimals) + /// assert_eq!(Cast::parse_units("2.5", 6)?, "2500000"); + /// assert_eq!(Cast::parse_units("1.0", 12)?, "1000000000000"); // 12 decimals + /// assert_eq!(Cast::parse_units("1.23", 3)?, "1230"); // 3 decimals + /// # Ok(()) + /// # } + /// ``` + pub fn parse_units(value: &str, unit: u8) -> Result { + let unit = Unit::new(unit).ok_or_else(|| eyre::eyre!("invalid unit"))?; + + Ok(ParseUnits::parse_units(value, unit)?.to_string()) + } + /// Format a number from smallest unit to decimal with arbitrary decimals. + /// + /// # Example + /// + /// ``` + /// use cast::SimpleCast as Cast; + /// + /// # fn main() -> eyre::Result<()> { + /// assert_eq!(Cast::format_units("1000000", 6)?, "1"); // USDC (6 decimals) + /// assert_eq!(Cast::format_units("2500000", 6)?, "2.500000"); + /// assert_eq!(Cast::format_units("1000000000000", 12)?, "1"); // 12 decimals + /// assert_eq!(Cast::format_units("1230", 3)?, "1.230"); // 3 decimals + /// # Ok(()) + /// # } + /// ``` + pub fn format_units(value: &str, unit: u8) -> Result { + let value = NumberWithBase::parse_int(value, None)?.number(); + let unit = Unit::new(unit).ok_or_else(|| eyre::eyre!("invalid unit"))?; + Ok(Self::format_unit_as_string(value, unit)) + } + + // Helper function to format units as a string + fn format_unit_as_string(value: U256, unit: Unit) -> String { + let mut formatted = ParseUnits::U256(value).format_units(unit); // Trim empty fractional part. if let Some(dot) = formatted.find('.') { let fractional = &formatted[dot + 1..]; @@ -1363,8 +1409,7 @@ impl SimpleCast { formatted = formatted[..dot].to_string(); } } - - Ok(formatted) + formatted } /// Converts wei into an eth amount diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 980d523d3d3b8..f307a6cfef114 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1396,3 +1396,39 @@ casttest!(hash_message, |_prj, cmd| { "#]]); }); + +casttest!(parse_units, |_prj, cmd| { + cmd.args(["parse-units", "1.5", "6"]).assert_success().stdout_eq(str![[r#" +1500000 + +"#]]); + + cmd.cast_fuse().args(["pun", "1.23", "18"]).assert_success().stdout_eq(str![[r#" +1230000000000000000 + +"#]]); + + cmd.cast_fuse().args(["--parse-units", "1.23", "3"]).assert_success().stdout_eq(str![[r#" +1230 + +"#]]); +}); + +casttest!(format_units, |_prj, cmd| { + cmd.args(["format-units", "1000000", "6"]).assert_success().stdout_eq(str![[r#" +1 + +"#]]); + + cmd.cast_fuse().args(["--format-units", "2500000", "6"]).assert_success().stdout_eq(str![[ + r#" +2.500000 + +"# + ]]); + + cmd.cast_fuse().args(["fun", "1230", "3"]).assert_success().stdout_eq(str![[r#" +1.230 + +"#]]); +}); From 25598999a2b33ac6ccfa35c347f3c98aba8e0061 Mon Sep 17 00:00:00 2001 From: Panagiotis Ganelis <50522617+PanGan21@users.noreply.github.com> Date: Thu, 24 Oct 2024 20:20:30 +0200 Subject: [PATCH 1602/1963] feat(cast): add `--rpc-timeout` option (#9044) * feat: add timeout flag and override default rpc timeout value * fix clippy * fix: move timeout to rpc args * refactor: move rpc timeout to RpcOpts * clippy * refactor unecessary code * Apply suggestions from code review Minor documentation nits --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/cli/src/opts/ethereum.rs | 11 +++++++++++ crates/cli/src/utils/mod.rs | 4 ++++ crates/config/src/lib.rs | 3 +++ crates/forge/tests/cli/config.rs | 1 + 4 files changed, 19 insertions(+) diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index c4e8f08875df0..b858d998fafb6 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -40,6 +40,14 @@ pub struct RpcOpts { /// "0x6bb38c26db65749ab6e472080a3d20a2f35776494e72016d1e339593f21c59bc"]' #[arg(long, env = "ETH_RPC_JWT_SECRET")] pub jwt_secret: Option, + + /// Timeout for the RPC request in seconds. + /// + /// The specified timeout will be used to override the default timeout for RPC requests. + /// + /// Default value: 45 + #[arg(long, env = "ETH_RPC_TIMEOUT")] + pub rpc_timeout: Option, } impl_figment_convert_cast!(RpcOpts); @@ -84,6 +92,9 @@ impl RpcOpts { if let Ok(Some(jwt)) = self.jwt(None) { dict.insert("eth_rpc_jwt".into(), jwt.into_owned().into()); } + if let Some(rpc_timeout) = self.rpc_timeout { + dict.insert("eth_rpc_timeout".into(), rpc_timeout.into()); + } dict } } diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 8aa56aab8c411..2d8471e62685f 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -106,6 +106,10 @@ pub fn get_provider_builder(config: &Config) -> Result { builder = builder.jwt(jwt.as_ref()); } + if let Some(rpc_timeout) = config.eth_rpc_timeout { + builder = builder.timeout(Duration::from_secs(rpc_timeout)); + } + Ok(builder) } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d70a8dab401fe..2a75f3b23c72a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -238,6 +238,8 @@ pub struct Config { pub eth_rpc_url: Option, /// JWT secret that should be used for any rpc calls pub eth_rpc_jwt: Option, + /// Timeout that should be used for any rpc calls + pub eth_rpc_timeout: Option, /// etherscan API key, or alias for an `EtherscanConfig` in `etherscan` table pub etherscan_api_key: Option, /// Multiple etherscan api configs and their aliases @@ -2208,6 +2210,7 @@ impl Default for Config { memory_limit: 1 << 27, // 2**27 = 128MiB = 134_217_728 bytes eth_rpc_url: None, eth_rpc_jwt: None, + eth_rpc_timeout: None, etherscan_api_key: None, verbosity: 0, remappings: vec![], diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 491171cad165d..f492de01d1f37 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -105,6 +105,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { memory_limit: 1 << 27, eth_rpc_url: Some("localhost".to_string()), eth_rpc_jwt: None, + eth_rpc_timeout: None, etherscan_api_key: None, etherscan: Default::default(), verbosity: 4, From 913899eb3e1a67c7cfe20244e050236bef63cf8e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 05:09:38 +0400 Subject: [PATCH 1603/1963] chore(tests): bump forge-std version (#9193) chore: bump forge-std version used for tests Co-authored-by: DaniPopes --- testdata/forge-std-rev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/forge-std-rev b/testdata/forge-std-rev index c6c6e2da6a63d..ff90d09c2b004 100644 --- a/testdata/forge-std-rev +++ b/testdata/forge-std-rev @@ -1 +1 @@ -8f24d6b04c92975e0795b5868aa0d783251cdeaa \ No newline at end of file +1eea5bae12ae557d589f9f0f0edae2faa47cb262 \ No newline at end of file From 192a5a24919de3eed36c92cc48cd29d55dc991b7 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:01:35 +0200 Subject: [PATCH 1604/1963] fix(`anvil`): tag newly created legacy transactions on shadow fork as `Some(0)` (`0x0`) rather than `None` (#9195) * mark legacy transaction type as 0x0 or Some(0) rather than None * return as Some(0) for legacy tx * revert Some(0) change per EIP-2718 spec --- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 88e7f2765f329..827f14a554023 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -300,7 +300,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( y_parity: None, }), access_list: None, - transaction_type: None, + transaction_type: Some(0), max_fee_per_blob_gas: None, blob_versioned_hashes: None, authorization_list: None, From ce74f6be81f3164c4c874896ada8b155e1161243 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 26 Oct 2024 07:48:17 +0200 Subject: [PATCH 1605/1963] chore: silence logger if silent (#9199) --- crates/anvil/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 11cb4473fad7b..123faa1e9a5a6 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -20,10 +20,7 @@ use crate::{ use alloy_primitives::{Address, U256}; use alloy_signer_local::PrivateKeySigner; use eth::backend::fork::ClientFork; -use foundry_common::{ - provider::{ProviderBuilder, RetryProvider}, - shell, -}; +use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; use parking_lot::Mutex; @@ -131,7 +128,7 @@ pub async fn spawn(config: NodeConfig) -> (EthApi, NodeHandle) { /// ``` pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle)> { let logger = if config.enable_tracing { init_tracing() } else { Default::default() }; - logger.set_enabled(!shell::is_quiet()); + logger.set_enabled(!config.silent); let backend = Arc::new(config.setup().await); From 6913a3d2a27cd2c44d38e8492d6bb20f7eef1163 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 26 Oct 2024 08:34:40 +0200 Subject: [PATCH 1606/1963] test: add test for rlp data (#9200) --- crates/cast/src/rlp_converter.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/cast/src/rlp_converter.rs b/crates/cast/src/rlp_converter.rs index faa5cfd0569ee..3f24aa563c1e9 100644 --- a/crates/cast/src/rlp_converter.rs +++ b/crates/cast/src/rlp_converter.rs @@ -95,7 +95,8 @@ impl fmt::Display for Item { #[cfg(test)] mod test { use crate::rlp_converter::Item; - use alloy_rlp::Decodable; + use alloy_primitives::hex; + use alloy_rlp::{Bytes, Decodable}; use serde_json::Result as JsonResult; // https://en.wikipedia.org/wiki/Set-theoretic_definition_of_natural_numbers @@ -179,4 +180,24 @@ mod test { Ok(()) } + + #[test] + fn rlp_data() { + // + let hex_val_rlp = hex!("820002"); + let item = Item::decode(&mut &hex_val_rlp[..]).unwrap(); + + let data = hex!("0002"); + let encoded = alloy_rlp::encode(&data[..]); + let decoded: Bytes = alloy_rlp::decode_exact(&encoded[..]).unwrap(); + assert_eq!(Item::Data(decoded.to_vec()), item); + + let hex_val_rlp = hex!("00"); + let item = Item::decode(&mut &hex_val_rlp[..]).unwrap(); + + let data = hex!("00"); + let encoded = alloy_rlp::encode(&data[..]); + let decoded: Bytes = alloy_rlp::decode_exact(&encoded[..]).unwrap(); + assert_eq!(Item::Data(decoded.to_vec()), item); + } } From 12292787208c626ed6b2791eeed55ef7ab3578b0 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 27 Oct 2024 00:22:16 +0400 Subject: [PATCH 1607/1963] fix(anvil): correctly set hardfork-specific block fields (#9202) * fix(anvil): correctly set hardfork-specific block fields * fmt --- crates/anvil/core/src/eth/block.rs | 24 +++++++++------------ crates/anvil/src/eth/backend/executor.rs | 13 ++++++----- crates/anvil/src/eth/backend/mem/storage.rs | 9 +++----- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 0dc386b01b1d6..c9f9048b81998 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -2,7 +2,7 @@ use super::{ transaction::{TransactionInfo, TypedReceipt}, trie, }; -use alloy_consensus::Header; +use alloy_consensus::{Header, EMPTY_OMMER_ROOT_HASH}; use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{Address, Bloom, Bytes, B256, B64, U256}; use alloy_rlp::{RlpDecodable, RlpEncodable}; @@ -34,19 +34,11 @@ impl Block { /// /// Note: if the `impersonate-tx` feature is enabled this will also accept /// `MaybeImpersonatedTransaction`. - pub fn new( - partial_header: PartialHeader, - transactions: impl IntoIterator, - ommers: Vec
, - ) -> Self + pub fn new(partial_header: PartialHeader, transactions: impl IntoIterator) -> Self where T: Into, { let transactions: Vec<_> = transactions.into_iter().map(Into::into).collect(); - let mut encoded_ommers: Vec = Vec::new(); - alloy_rlp::encode_list(&ommers, &mut encoded_ommers); - let ommers_hash = - B256::from_slice(alloy_primitives::utils::keccak256(encoded_ommers).as_slice()); let transactions_root = trie::ordered_trie_root(transactions.iter().map(|r| r.encoded_2718())); @@ -54,7 +46,7 @@ impl Block { header: Header { parent_hash: partial_header.parent_hash, beneficiary: partial_header.beneficiary, - ommers_hash, + ommers_hash: EMPTY_OMMER_ROOT_HASH, state_root: partial_header.state_root, transactions_root, receipts_root: partial_header.receipts_root, @@ -66,16 +58,16 @@ impl Block { timestamp: partial_header.timestamp, extra_data: partial_header.extra_data, mix_hash: partial_header.mix_hash, - withdrawals_root: None, + withdrawals_root: partial_header.withdrawals_root, blob_gas_used: partial_header.blob_gas_used, excess_blob_gas: partial_header.excess_blob_gas, parent_beacon_block_root: partial_header.parent_beacon_block_root, nonce: partial_header.nonce, base_fee_per_gas: partial_header.base_fee, - requests_hash: None, + requests_hash: partial_header.requests_hash, }, transactions, - ommers, + ommers: vec![], } } } @@ -100,6 +92,8 @@ pub struct PartialHeader { pub parent_beacon_block_root: Option, pub nonce: B64, pub base_fee: Option, + pub withdrawals_root: Option, + pub requests_hash: Option, } impl From
for PartialHeader { @@ -122,6 +116,8 @@ impl From
for PartialHeader { blob_gas_used: value.blob_gas_used, excess_blob_gas: value.excess_blob_gas, parent_beacon_block_root: value.parent_beacon_block_root, + requests_hash: value.requests_hash, + withdrawals_root: value.withdrawals_root, } } } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index 3ceee8b04e948..a00afd962878c 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -8,8 +8,8 @@ use crate::{ mem::inspector::Inspector, PrecompileFactory, }; -use alloy_consensus::{Header, Receipt, ReceiptWithBloom}; -use alloy_eips::eip2718::Encodable2718; +use alloy_consensus::{constants::EMPTY_WITHDRAWALS, Receipt, ReceiptWithBloom}; +use alloy_eips::{eip2718::Encodable2718, eip7685::EMPTY_REQUESTS_HASH}; use alloy_primitives::{Bloom, BloomInput, Log, B256}; use anvil_core::eth::{ block::{Block, BlockInfo, PartialHeader}, @@ -134,7 +134,9 @@ impl TransactionExecutor<'_, DB, V> { None }; + let is_shanghai = self.cfg_env.handler_cfg.spec_id >= SpecId::SHANGHAI; let is_cancun = self.cfg_env.handler_cfg.spec_id >= SpecId::CANCUN; + let is_prague = self.cfg_env.handler_cfg.spec_id >= SpecId::PRAGUE; let excess_blob_gas = if is_cancun { self.block_env.get_blob_excess_gas() } else { None }; let mut cumulative_blob_gas_used = if is_cancun { Some(0u64) } else { None }; @@ -208,7 +210,6 @@ impl TransactionExecutor<'_, DB, V> { transactions.push(transaction.pending_transaction.transaction.clone()); } - let ommers: Vec
= Vec::new(); let receipts_root = trie::ordered_trie_root(receipts.iter().map(Encodable2718::encoded_2718)); @@ -227,12 +228,14 @@ impl TransactionExecutor<'_, DB, V> { mix_hash: Default::default(), nonce: Default::default(), base_fee, - parent_beacon_block_root: Default::default(), + parent_beacon_block_root: is_cancun.then_some(Default::default()), blob_gas_used: cumulative_blob_gas_used, excess_blob_gas, + withdrawals_root: is_shanghai.then_some(EMPTY_WITHDRAWALS), + requests_hash: is_prague.then_some(EMPTY_REQUESTS_HASH), }; - let block = Block::new(partial_header, transactions.clone(), ommers); + let block = Block::new(partial_header, transactions.clone()); let block = BlockInfo { block, transactions: transaction_infos, receipts }; ExecutedTransactions { block, included, invalid } } diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 942ce5a9d23cf..2105666a4e91d 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -274,7 +274,7 @@ impl BlockchainStorage { excess_blob_gas: env.block.get_blob_excess_gas(), ..Default::default() }; - let block = Block::new::(partial_header, vec![], vec![]); + let block = Block::new::(partial_header, vec![]); let genesis_hash = block.header.hash_slow(); let best_hash = genesis_hash; let best_number: U64 = U64::from(0u64); @@ -693,11 +693,8 @@ mod tests { let bytes_first = &mut &hex::decode("f86b02843b9aca00830186a094d3e8763675e4c425df46cc3b5c0f6cbdac39604687038d7ea4c68000802ba00eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5aea03a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca18").unwrap()[..]; let tx: MaybeImpersonatedTransaction = TypedTransaction::decode(&mut &bytes_first[..]).unwrap().into(); - let block = Block::new::( - partial_header.clone(), - vec![tx.clone()], - vec![], - ); + let block = + Block::new::(partial_header.clone(), vec![tx.clone()]); let block_hash = block.header.hash_slow(); dump_storage.blocks.insert(block_hash, block); From 484a5de4be707cd94d5f9bf128d997b0205e4880 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Oct 2024 02:53:32 +0100 Subject: [PATCH 1608/1963] chore(deps): weekly `cargo update` (#9206) Locking 26 packages to latest compatible versions Updating alloy-chains v0.1.40 -> v0.1.42 Updating anstream v0.6.15 -> v0.6.17 Updating anstyle v1.0.8 -> v1.0.9 Updating anstyle-parse v0.2.5 -> v0.2.6 Updating anstyle-query v1.1.1 -> v1.1.2 Updating anstyle-wincon v3.0.4 -> v3.0.6 Updating aws-config v1.5.8 -> v1.5.9 Updating aws-sdk-kms v1.47.0 -> v1.48.0 Updating aws-sdk-sso v1.46.0 -> v1.47.0 Updating aws-sdk-ssooidc v1.47.0 -> v1.48.0 Updating aws-sdk-sts v1.46.0 -> v1.47.0 Updating aws-sigv4 v1.2.4 -> v1.2.5 Updating aws-smithy-runtime v1.7.2 -> v1.7.3 Updating aws-smithy-types v1.2.7 -> v1.2.8 Updating colorchoice v1.0.2 -> v1.0.3 Updating libm v0.2.8 -> v0.2.9 Updating op-alloy-consensus v0.5.0 -> v0.5.1 Updating op-alloy-rpc-types v0.5.0 -> v0.5.1 Updating pin-project v1.1.6 -> v1.1.7 Updating pin-project-internal v1.1.6 -> v1.1.7 Updating pin-project-lite v0.2.14 -> v0.2.15 Updating regex v1.11.0 -> v1.11.1 Updating scale-info v2.11.4 -> v2.11.5 Updating scale-info-derive v2.11.4 -> v2.11.5 Updating scc v2.2.2 -> v2.2.4 Updating wasm-streams v0.4.1 -> v0.4.2 note: pass `--verbose` to see 13 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 124 ++++++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5d17a156de34..6d730b949b62d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.40" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4932d790c723181807738cf1ac68198ab581cd699545b155601332541ee47bd" +checksum = "dca4a1469a3e572e9ba362920ff145f5d0a00a3e71a64ddcb4a3659cf64c76a7" dependencies = [ "alloy-primitives", "num_enum", @@ -321,7 +321,7 @@ dependencies = [ "futures-utils-wasm", "lru", "parking_lot", - "pin-project 1.1.6", + "pin-project 1.1.7", "reqwest", "schnellru", "serde", @@ -388,7 +388,7 @@ dependencies = [ "alloy-transport-ipc", "alloy-transport-ws", "futures", - "pin-project 1.1.6", + "pin-project 1.1.7", "reqwest", "serde", "serde_json", @@ -729,7 +729,7 @@ dependencies = [ "bytes", "futures", "interprocess", - "pin-project 1.1.6", + "pin-project 1.1.7", "serde", "serde_json", "tempfile", @@ -801,9 +801,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" dependencies = [ "anstyle", "anstyle-parse", @@ -816,36 +816,36 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -961,7 +961,7 @@ dependencies = [ "futures", "interprocess", "parking_lot", - "pin-project 1.1.6", + "pin-project 1.1.7", "serde", "serde_json", "thiserror", @@ -1261,9 +1261,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.8" +version = "1.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7198e6f03240fdceba36656d8be440297b6b82270325908c7381f37d826a74f6" +checksum = "2d6448cfb224dd6a9b9ac734f58622dd0d4751f3589f3b777345745f46b2eb14" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1328,9 +1328,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.47.0" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "564a597a3c71a957d60a2e4c62c93d78ee5a0d636531e15b760acad983a5c18e" +checksum = "2afbd208dabc6785946d4ef2444eb1f54fe0aaf0f62f2a4f9a9e9c303aeff0be" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1350,9 +1350,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.46.0" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc2faec3205d496c7e57eff685dd944203df7ce16a4116d0281c44021788a7b" +checksum = "a8776850becacbd3a82a4737a9375ddb5c6832a51379f24443a98e61513f852c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1372,9 +1372,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.47.0" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c93c241f52bc5e0476e259c953234dab7e2a35ee207ee202e86c0095ec4951dc" +checksum = "0007b5b8004547133319b6c4e87193eee2a0bcb3e4c18c75d09febe9dab7b383" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1394,9 +1394,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.46.0" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b259429be94a3459fa1b00c5684faee118d74f9577cc50aebadc36e507c63b5f" +checksum = "9fffaa356e7f1c725908b75136d53207fa714e348f365671df14e95a60530ad3" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1417,9 +1417,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.4" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc8db6904450bafe7473c6ca9123f88cc11089e41a025408f992db4e22d3be68" +checksum = "5619742a0d8f253be760bfbb8e8e8368c69e3587e4637af5754e488a611499b1" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1490,9 +1490,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.2" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a065c0fe6fdbdf9f11817eb68582b2ab4aff9e9c39e986ae48f7ec576c6322db" +checksum = "be28bd063fa91fd871d131fc8b68d7cd4c5fa0869bea68daca50dcb1cbd76be2" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1534,9 +1534,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.7" +version = "1.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147100a7bea70fa20ef224a6bad700358305f5dc0f84649c53769761395b355b" +checksum = "07c9cdc179e6afbf5d391ab08c85eac817b51c87e1892a5edb5f7bbdc64314b4" dependencies = [ "base64-simd", "bytes", @@ -2311,9 +2311,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comfy-table" @@ -5474,9 +5474,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "3bda4c6077b0b08da2c48b172195795498381a7c8988c9e6212a6c55c5b9bd70" [[package]] name = "libredox" @@ -6083,9 +6083,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d49163f952491820088dd0e66f3a35d63337c3066eceff0a931bf83a8e2101" +checksum = "ba7c98055fd048073738df0cc6d6537e992a0d8828f39d99a469e870db126dbd" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6099,9 +6099,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9556293835232b019ec9c6fd84e4265a3151111af60ea09b5b513e3dbed41c" +checksum = "919e9b69212d61f3c8932bfb717c7ad458ea3fc52072b3433d99994f8223d555" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6512,11 +6512,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ - "pin-project-internal 1.1.6", + "pin-project-internal 1.1.7", ] [[package]] @@ -6532,9 +6532,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", @@ -6543,9 +6543,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -7094,9 +7094,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -7629,9 +7629,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.4" +version = "2.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22760a375f81a31817aeaf6f5081e9ccb7ffd7f2da1809a6e3fc82b6656f10d5" +checksum = "1aa7ffc1c0ef49b0452c6e2986abf2b07743320641ffd5fc63d552458e3b779b" dependencies = [ "cfg-if", "derive_more", @@ -7641,21 +7641,21 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.4" +version = "2.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc61ebe25a5c410c0e245028fc9934bf8fa4817199ef5a24a68092edfd34614" +checksum = "46385cc24172cf615450267463f937c10072516359b3ff1cb24228a4a08bf951" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.85", ] [[package]] name = "scc" -version = "2.2.2" +version = "2.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c1f7fc6deb21665a9060dfc7d271be784669295a31babdcd4dd2c79ae8cbfb" +checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" dependencies = [ "sdd", ] @@ -8803,7 +8803,7 @@ dependencies = [ "hyper-timeout", "hyper-util", "percent-encoding", - "pin-project 1.1.6", + "pin-project 1.1.7", "prost", "rustls-native-certs 0.8.0", "rustls-pemfile 2.2.0", @@ -8832,7 +8832,7 @@ dependencies = [ "futures-core", "futures-util", "indexmap 1.9.3", - "pin-project 1.1.6", + "pin-project 1.1.7", "pin-project-lite", "rand", "slab", @@ -9378,9 +9378,9 @@ checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-streams" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" dependencies = [ "futures-util", "js-sys", From 3b0c75d5edd01e7be921b48b2e16271a467c2ffd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 27 Oct 2024 15:12:07 +0100 Subject: [PATCH 1609/1963] fix: include withdrawals root in response (#9208) --- crates/anvil/src/eth/backend/mem/mod.rs | 6 ++--- crates/anvil/tests/it/anvil.rs | 29 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 34d37d666d444..73adaa97f3fd7 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -1880,7 +1880,7 @@ impl Backend { mix_hash, nonce, base_fee_per_gas, - withdrawals_root: _, + withdrawals_root, blob_gas_used, excess_blob_gas, parent_beacon_block_root, @@ -1906,7 +1906,7 @@ impl Backend { mix_hash: Some(mix_hash), nonce: Some(nonce), base_fee_per_gas, - withdrawals_root: None, + withdrawals_root, blob_gas_used, excess_blob_gas, parent_beacon_block_root, @@ -1917,7 +1917,7 @@ impl Backend { transactions.into_iter().map(|tx| tx.hash()).collect(), ), uncles: vec![], - withdrawals: None, + withdrawals: withdrawals_root.map(|_| Default::default()), }; let mut block = WithOtherFields::new(block); diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 50e27c57aa57c..5a952da6b2b49 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -1,9 +1,10 @@ //! tests for anvil specific logic +use alloy_consensus::EMPTY_ROOT_HASH; use alloy_eips::BlockNumberOrTag; use alloy_primitives::Address; use alloy_provider::Provider; -use anvil::{spawn, NodeConfig}; +use anvil::{spawn, EthereumHardfork, NodeConfig}; #[tokio::test(flavor = "multi_thread")] async fn test_can_change_mining_mode() { @@ -88,3 +89,29 @@ async fn test_can_handle_large_timestamp() { let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); assert_eq!(block.header.timestamp, num); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_shanghai_fields() { + let (api, _handle) = + spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::Shanghai.into()))).await; + api.mine_one().await; + + let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert_eq!(block.header.withdrawals_root, Some(EMPTY_ROOT_HASH)); + assert_eq!(block.withdrawals, Some(Default::default())); + assert!(block.header.blob_gas_used.is_none()); + assert!(block.header.excess_blob_gas.is_none()); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_cancun_fields() { + let (api, _handle) = + spawn(NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into()))).await; + api.mine_one().await; + + let block = api.block_by_number(BlockNumberOrTag::Latest).await.unwrap().unwrap(); + assert_eq!(block.header.withdrawals_root, Some(EMPTY_ROOT_HASH)); + assert_eq!(block.withdrawals, Some(Default::default())); + assert!(block.header.blob_gas_used.is_some()); + assert!(block.header.excess_blob_gas.is_some()); +} From 513ed69f79cbc24cfc08d5ef39e9f8bb5fe7eff7 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 27 Oct 2024 18:14:02 +0400 Subject: [PATCH 1610/1963] fix(script): correctly detect additional contracts (#9207) * add test * fix(script): correctly detect additional contracts * fix --- Cargo.lock | 1 + crates/forge/Cargo.toml | 1 + crates/forge/tests/cli/script.rs | 48 ++++++++++++++++++++++++++++++++ crates/script/src/transaction.rs | 2 ++ 4 files changed, 52 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6d730b949b62d..014b458f96428 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3360,6 +3360,7 @@ dependencies = [ "forge-doc", "forge-fmt", "forge-script", + "forge-script-sequence", "forge-sol-macro-gen", "forge-verify", "foundry-block-explorers", diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 1b716497a45e1..f85a08d69f279 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -33,6 +33,7 @@ foundry-config.workspace = true foundry-evm.workspace = true foundry-wallets.workspace = true foundry-linking.workspace = true +forge-script-sequence.workspace = true ethers-contract-abigen = { workspace = true, features = ["providers"] } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index c4a69223d5217..88b75ad50114a 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3,6 +3,7 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; +use forge_script_sequence::ScriptSequence; use foundry_test_utils::{ rpc, util::{OTHER_SOLC_VERSION, SOLC_VERSION}, @@ -2269,3 +2270,50 @@ backend: failed while inspecting; header validation error: `prevrandao` not set; "#]]); }); + +forgetest_async!(should_detect_additional_contracts, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_source( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract Simple {} + +contract Deployer { + function deploy() public { + new Simple(); + } +} + +contract ContractScript is Script { + function run() public { + vm.startBroadcast(); + Deployer deployer = new Deployer(); + deployer.deploy(); + } +} + "#, + ) + .unwrap(); + cmd.arg("script") + .args([ + "ContractScript", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + ]) + .assert_success(); + + let run_latest = foundry_common::fs::json_files(&prj.root().join("broadcast")) + .find(|file| file.ends_with("run-latest.json")) + .expect("No broadcast artifacts"); + + let sequence: ScriptSequence = foundry_common::fs::read_json_file(&run_latest).unwrap(); + + assert_eq!(sequence.transactions.len(), 2); + assert_eq!(sequence.transactions[1].additional_contracts.len(), 1); +}); diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index 39bf0490ea426..fcd4eefc36d4b 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -155,6 +155,8 @@ impl ScriptTransactionBuilder { self.transaction.contract_address.map_or(true, |addr| addr != contract.address) }); + self.transaction.additional_contracts = created_contracts; + if !self.transaction.is_fixed_gas_limit { if let Some(unsigned) = self.transaction.transaction.as_unsigned_mut() { // We inflate the gas used by the user specified percentage From 5c69a9d9fd4e2ec07fc398ab5ef9d706c33890c2 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 27 Oct 2024 18:37:01 +0400 Subject: [PATCH 1611/1963] fix(`cast block`): ensure to print all fields (#9209) fix(cast block): ensure to print all fields --- crates/cast/tests/cli/main.rs | 3 ++ crates/common/fmt/src/ui.rs | 89 +++++++++++++++++++++++++---------- 2 files changed, 68 insertions(+), 24 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index f307a6cfef114..6d5a6fd6a8214 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -81,6 +81,9 @@ stateRoot [..] timestamp [..] withdrawalsRoot [..] totalDifficulty [..] +blobGasUsed [..] +excessBlobGas [..] +requestsHash [..] transactions: [ ... ] diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 4789c381da0aa..5534e72d83556 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -4,7 +4,7 @@ use alloy_consensus::{AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom use alloy_network::ReceiptResponse; use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, B256, I256, U256, U64}; use alloy_rpc_types::{ - AccessListItem, AnyNetworkBlock, AnyTransactionReceipt, Block, BlockTransactions, Log, + AccessListItem, AnyNetworkBlock, AnyTransactionReceipt, Block, BlockTransactions, Header, Log, Transaction, TransactionReceipt, }; use alloy_serde::{OtherFields, WithOtherFields}; @@ -597,6 +597,9 @@ pub fn get_pretty_block_attr(block: &AnyNetworkBlock, attr: &str) -> Option Some(block.header.state_root.pretty()), "timestamp" => Some(block.header.timestamp.pretty()), "totalDifficulty" | "total_difficult" => Some(block.header.total_difficulty.pretty()), + "blobGasUsed" | "blob_gas_used" => Some(block.header.blob_gas_used.pretty()), + "excessBlobGas" | "excess_blob_gas" => Some(block.header.excess_blob_gas.pretty()), + "requestsHash" | "requests_hash" => Some(block.header.requests_hash.pretty()), other => { if let Some(value) = block.other.get(other) { let val = EthValue::from(value.clone()); @@ -608,6 +611,38 @@ pub fn get_pretty_block_attr(block: &AnyNetworkBlock, attr: &str) -> Option(block: &Block) -> String { + let Block { + header: + Header { + hash, + parent_hash, + uncles_hash, + miner, + state_root, + transactions_root, + receipts_root, + logs_bloom, + difficulty, + number, + gas_limit, + gas_used, + timestamp, + total_difficulty, + extra_data, + mix_hash, + nonce, + base_fee_per_gas, + withdrawals_root, + blob_gas_used, + excess_blob_gas, + parent_beacon_block_root, + requests_hash, + }, + uncles: _, + transactions: _, + size, + withdrawals: _, + } = block; format!( " baseFeePerGas {} @@ -630,31 +665,37 @@ size {} stateRoot {} timestamp {} ({}) withdrawalsRoot {} -totalDifficulty {}", - block.header.base_fee_per_gas.pretty(), - block.header.difficulty.pretty(), - block.header.extra_data.pretty(), - block.header.gas_limit.pretty(), - block.header.gas_used.pretty(), - block.header.hash.pretty(), - block.header.logs_bloom.pretty(), - block.header.miner.pretty(), - block.header.mix_hash.pretty(), - block.header.nonce.pretty(), - block.header.number.pretty(), - block.header.parent_hash.pretty(), - block.header.parent_beacon_block_root.pretty(), - block.header.transactions_root.pretty(), - block.header.receipts_root.pretty(), - block.header.uncles_hash.pretty(), - block.size.pretty(), - block.header.state_root.pretty(), - block.header.timestamp.pretty(), - chrono::DateTime::from_timestamp(block.header.timestamp as i64, 0) +totalDifficulty {} +blobGasUsed {} +excessBlobGas {} +requestsHash {}", + base_fee_per_gas.pretty(), + difficulty.pretty(), + extra_data.pretty(), + gas_limit.pretty(), + gas_used.pretty(), + hash.pretty(), + logs_bloom.pretty(), + miner.pretty(), + mix_hash.pretty(), + nonce.pretty(), + number.pretty(), + parent_hash.pretty(), + parent_beacon_block_root.pretty(), + transactions_root.pretty(), + receipts_root.pretty(), + uncles_hash.pretty(), + size.pretty(), + state_root.pretty(), + timestamp.pretty(), + chrono::DateTime::from_timestamp(*timestamp as i64, 0) .expect("block timestamp in range") .to_rfc2822(), - block.header.withdrawals_root.pretty(), - block.header.total_difficulty.pretty(), + withdrawals_root.pretty(), + total_difficulty.pretty(), + blob_gas_used.pretty(), + excess_blob_gas.pretty(), + requests_hash.pretty(), ) } From 00415bbb0653c429c1e21dcd0405be3005a36cc6 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Mon, 28 Oct 2024 18:24:37 +0700 Subject: [PATCH 1612/1963] feat(cast): add --int flag to from-rlp (#9210) * bet * fmt * bet * bet * remove unneccessary validation --- crates/cast/bin/args.rs | 4 ++++ crates/cast/bin/main.rs | 4 ++-- crates/cast/src/lib.rs | 28 ++++++++++++++++++---------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 6cbfd73f79883..386201e5b0ee6 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -317,6 +317,10 @@ pub enum CastSubcommand { FromRlp { /// The RLP hex-encoded data. value: Option, + + /// Decode the RLP data as int + #[arg(id = "int", long = "as_int", alias = "int")] + as_int: bool, }, /// Converts a number of one base to another diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 90367d106e8a8..0338d9ff26f0a 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -149,9 +149,9 @@ async fn main_args(args: CastArgs) -> Result<()> { let value = stdin::unwrap_line(value)?; sh_println!("{}", SimpleCast::to_wei(&value, &unit)?)? } - CastSubcommand::FromRlp { value } => { + CastSubcommand::FromRlp { value, as_int } => { let value = stdin::unwrap_line(value)?; - sh_println!("{}", SimpleCast::from_rlp(value)?)? + sh_println!("{}", SimpleCast::from_rlp(value, as_int)?)? } CastSubcommand::ToRlp { value } => { let value = stdin::unwrap_line(value)?; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index d40a4a5954aa8..97624c12ab646 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1448,23 +1448,31 @@ impl SimpleCast { Ok(ParseUnits::parse_units(value, unit)?.to_string()) } - /// Decodes rlp encoded list with hex data - /// - /// # Example + // Decodes RLP encoded data with validation for canonical integer representation /// + /// # Examples /// ``` /// use cast::SimpleCast as Cast; /// - /// assert_eq!(Cast::from_rlp("0xc0").unwrap(), "[]"); - /// assert_eq!(Cast::from_rlp("0x0f").unwrap(), "\"0x0f\""); - /// assert_eq!(Cast::from_rlp("0x33").unwrap(), "\"0x33\""); - /// assert_eq!(Cast::from_rlp("0xc161").unwrap(), "[\"0x61\"]"); - /// assert_eq!(Cast::from_rlp("0xc26162").unwrap(), "[\"0x61\",\"0x62\"]"); + /// assert_eq!(Cast::from_rlp("0xc0", false).unwrap(), "[]"); + /// assert_eq!(Cast::from_rlp("0x0f", false).unwrap(), "\"0x0f\""); + /// assert_eq!(Cast::from_rlp("0x33", false).unwrap(), "\"0x33\""); + /// assert_eq!(Cast::from_rlp("0xc161", false).unwrap(), "[\"0x61\"]"); + /// assert_eq!(Cast::from_rlp("820002", true).is_err(), true); + /// assert_eq!(Cast::from_rlp("820002", false).unwrap(), "\"0x0002\""); + /// assert_eq!(Cast::from_rlp("00", true).is_err(), true); + /// assert_eq!(Cast::from_rlp("00", false).unwrap(), "\"0x00\""); /// # Ok::<_, eyre::Report>(()) /// ``` - pub fn from_rlp(value: impl AsRef) -> Result { + pub fn from_rlp(value: impl AsRef, as_int: bool) -> Result { let bytes = hex::decode(value.as_ref()).wrap_err("Could not decode hex")?; + + if as_int { + return Ok(U256::decode(&mut &bytes[..])?.to_string()); + } + let item = Item::decode(&mut &bytes[..]).wrap_err("Could not decode rlp")?; + Ok(item.to_string()) } @@ -2288,7 +2296,7 @@ mod tests { #[test] fn from_rlp() { let rlp = "0xf8b1a02b5df5f0757397573e8ff34a8b987b21680357de1f6c8d10273aa528a851eaca8080a02838ac1d2d2721ba883169179b48480b2ba4f43d70fcf806956746bd9e83f90380a0e46fff283b0ab96a32a7cc375cecc3ed7b6303a43d64e0a12eceb0bc6bd8754980a01d818c1c414c665a9c9a0e0c0ef1ef87cacb380b8c1f6223cb2a68a4b2d023f5808080a0236e8f61ecde6abfebc6c529441f782f62469d8a2cc47b7aace2c136bd3b1ff08080808080"; - let item = Cast::from_rlp(rlp).unwrap(); + let item = Cast::from_rlp(rlp, false).unwrap(); assert_eq!( item, r#"["0x2b5df5f0757397573e8ff34a8b987b21680357de1f6c8d10273aa528a851eaca","0x","0x","0x2838ac1d2d2721ba883169179b48480b2ba4f43d70fcf806956746bd9e83f903","0x","0xe46fff283b0ab96a32a7cc375cecc3ed7b6303a43d64e0a12eceb0bc6bd87549","0x","0x1d818c1c414c665a9c9a0e0c0ef1ef87cacb380b8c1f6223cb2a68a4b2d023f5","0x","0x","0x","0x236e8f61ecde6abfebc6c529441f782f62469d8a2cc47b7aace2c136bd3b1ff0","0x","0x","0x","0x","0x"]"# From 0191e176acec1acffd94e671eb0a46b0894767e5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:21:30 +0200 Subject: [PATCH 1613/1963] chore: try from eyre:Result for TraceResult (display chained error) (#9212) --- crates/cast/bin/cmd/run.rs | 4 ++-- crates/cli/src/utils/cmd.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index bc06547044d4c..11c7b507e3554 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,7 +1,7 @@ use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::BlockTransactions; -use cast::{revm::primitives::EnvWithHandlerCfg, traces::TraceKind}; +use cast::revm::primitives::EnvWithHandlerCfg; use clap::Parser; use eyre::{Result, WrapErr}; use foundry_cli::{ @@ -235,7 +235,7 @@ impl RunArgs { if let Some(to) = tx.to { trace!(tx=?tx.hash, to=?to, "executing call transaction"); - TraceResult::from_raw(executor.transact_with_env(env)?, TraceKind::Execution) + TraceResult::try_from(executor.transact_with_env(env))? } else { trace!(tx=?tx.hash, "executing create transaction"); TraceResult::try_from(executor.deploy_with_env(env, None))? diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index e4d0a51146272..9852f53f1d44c 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -362,6 +362,23 @@ impl TryFrom> for TraceResult { } } +impl From for TraceResult { + fn from(result: RawCallResult) -> Self { + Self::from_raw(result, TraceKind::Execution) + } +} + +impl TryFrom> for TraceResult { + type Error = EvmError; + + fn try_from(value: Result) -> Result { + match value { + Ok(result) => Ok(Self::from(result)), + Err(err) => Err(EvmError::from(err)), + } + } +} + /// labels the traces, conditionally prints them or opens the debugger pub async fn handle_traces( mut result: TraceResult, From a428ba6ad8856611339a6319290aade3347d25d9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 28 Oct 2024 20:35:30 +0200 Subject: [PATCH 1614/1963] feat(`forge install`): add `@tag=` `@branch=` `@rev=` specific refs (#9214) * fix(`forge install`): add @tag= @branch= @commit= for refs * Consistent @rev= --- crates/cli/src/opts/dependency.rs | 46 ++++++++++++++++++++++++++----- crates/forge/bin/cmd/install.rs | 2 ++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index 6fa33a53f8a1f..6783e32d25cea 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -12,6 +12,9 @@ pub static GH_REPO_PREFIX_REGEX: LazyLock = LazyLock::new(|| { .unwrap() }); +static VERSION_PREFIX_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r#"@(tag|branch|rev)="#).unwrap()); + const GITHUB: &str = "github.com"; const VERSION_SEPARATOR: char = '@'; const ALIAS_SEPARATOR: char = '='; @@ -49,6 +52,12 @@ pub struct Dependency { impl FromStr for Dependency { type Err = eyre::Error; fn from_str(dependency: &str) -> Result { + // Handle dependency exact ref type (`@tag=`, `@branch=` or `@rev=`)`. + // Only extract version for first tag/branch/commit specified. + let url_and_version: Vec<&str> = VERSION_PREFIX_REGEX.split(dependency).collect(); + let dependency = url_and_version[0]; + let mut tag_or_branch = url_and_version.get(1).map(|version| version.to_string()); + // everything before "=" should be considered the alias let (mut alias, dependency) = if let Some(split) = dependency.split_once(ALIAS_SEPARATOR) { (Some(String::from(split.0)), split.1.to_string()) @@ -96,14 +105,15 @@ impl FromStr for Dependency { // `tag` does not contain a slash let mut split = url_with_version.rsplit(VERSION_SEPARATOR); - let mut tag = None; let mut url = url_with_version.as_str(); - let maybe_tag = split.next().unwrap(); - if let Some(actual_url) = split.next() { - if !maybe_tag.contains('/') { - tag = Some(maybe_tag.to_string()); - url = actual_url; + if tag_or_branch.is_none() { + let maybe_tag_or_branch = split.next().unwrap(); + if let Some(actual_url) = split.next() { + if !maybe_tag_or_branch.contains('/') { + tag_or_branch = Some(maybe_tag_or_branch.to_string()); + url = actual_url; + } } } @@ -114,7 +124,7 @@ impl FromStr for Dependency { .ok_or_else(|| eyre::eyre!("no dependency name found"))? .to_string(); - (Some(url), Some(name), tag) + (Some(url), Some(name), tag_or_branch) } else { (None, None, None) }; @@ -360,4 +370,26 @@ mod tests { let dep: Dependency = "org-git12345678@github.com:my-org/my-repo.git".parse().unwrap(); assert_eq!(dep.url.unwrap(), "https://github.com/my-org/my-repo"); } + + #[test] + fn can_parse_with_explicit_ref_type() { + let dep = Dependency::from_str("smartcontractkit/ccip@tag=contracts-ccip/v1.2.1").unwrap(); + assert_eq!(dep.name, "ccip"); + assert_eq!(dep.url, Some("https://github.com/smartcontractkit/ccip".to_string())); + assert_eq!(dep.tag, Some("contracts-ccip/v1.2.1".to_string())); + assert_eq!(dep.alias, None); + + let dep = + Dependency::from_str("smartcontractkit/ccip@branch=contracts-ccip/v1.2.1").unwrap(); + assert_eq!(dep.name, "ccip"); + assert_eq!(dep.url, Some("https://github.com/smartcontractkit/ccip".to_string())); + assert_eq!(dep.tag, Some("contracts-ccip/v1.2.1".to_string())); + assert_eq!(dep.alias, None); + + let dep = Dependency::from_str("smartcontractkit/ccip@rev=80eb41b").unwrap(); + assert_eq!(dep.name, "ccip"); + assert_eq!(dep.url, Some("https://github.com/smartcontractkit/ccip".to_string())); + assert_eq!(dep.tag, Some("80eb41b".to_string())); + assert_eq!(dep.alias, None); + } } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 2567825d45a15..1485bc4409424 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -37,6 +37,8 @@ pub struct InstallArgs { /// - A tag: v1.2.3 /// - A commit: 8e8128 /// + /// For exact match, a ref can be provided with `@tag=`, `@branch=` or `@rev=` prefix. + /// /// Target installation directory can be added via `=` suffix. /// The dependency will installed to `lib/`. dependencies: Vec, From 48930a68c583e8c56abd09e8b5af1cdb85367348 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:02:27 +0100 Subject: [PATCH 1615/1963] feat: make `--gas-report` w/ `--json` output one JSON blob and add `contract_path` to output (#9216) * show resolved contract name * split out helpers * add basic test for multiple selectors resolve to same name w/ different args * collect JSON gas reports and render it as one blob * update tests * avoid unnecessary nesting of non-overloaded function names --- crates/forge/src/gas_report.rs | 170 ++++++--- crates/forge/tests/cli/cmd.rs | 630 ++++++++++++++++++++++++++++----- 2 files changed, 669 insertions(+), 131 deletions(-) diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 59c417b970975..6c53bd9e6e75c 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -9,6 +9,7 @@ use comfy_table::{presets::ASCII_MARKDOWN, *}; use foundry_common::{calc, TestFunctionExt}; use foundry_evm::traces::CallKind; use serde::{Deserialize, Serialize}; +use serde_json::json; use std::{collections::BTreeMap, fmt::Display}; use yansi::Paint; @@ -156,59 +157,136 @@ impl GasReport { impl Display for GasReport { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - for (name, contract) in &self.contracts { - if contract.functions.is_empty() { - trace!(name, "gas report contract without functions"); - continue; - } + match self.report_type { + GasReportKind::Markdown => { + for (name, contract) in &self.contracts { + if contract.functions.is_empty() { + trace!(name, "gas report contract without functions"); + continue; + } - if self.report_type == GasReportKind::JSON { - writeln!(f, "{}", serde_json::to_string(&contract).unwrap())?; - continue; + let table = self.format_table_output(contract, name); + writeln!(f, "{table}")?; + writeln!(f, "\n")?; + } + } + GasReportKind::JSON => { + writeln!(f, "{}", &self.format_json_output())?; } - - let mut table = Table::new(); - table.load_preset(ASCII_MARKDOWN); - table.set_header([Cell::new(format!("{name} contract")) - .add_attribute(Attribute::Bold) - .fg(Color::Green)]); - table.add_row([ - Cell::new("Deployment Cost").add_attribute(Attribute::Bold).fg(Color::Cyan), - Cell::new("Deployment Size").add_attribute(Attribute::Bold).fg(Color::Cyan), - ]); - table.add_row([contract.gas.to_string(), contract.size.to_string()]); - - table.add_row([ - Cell::new("Function Name").add_attribute(Attribute::Bold).fg(Color::Magenta), - Cell::new("min").add_attribute(Attribute::Bold).fg(Color::Green), - Cell::new("avg").add_attribute(Attribute::Bold).fg(Color::Yellow), - Cell::new("median").add_attribute(Attribute::Bold).fg(Color::Yellow), - Cell::new("max").add_attribute(Attribute::Bold).fg(Color::Red), - Cell::new("# calls").add_attribute(Attribute::Bold), - ]); - contract.functions.iter().for_each(|(fname, sigs)| { - sigs.iter().for_each(|(sig, gas_info)| { - // show function signature if overloaded else name - let fn_display = - if sigs.len() == 1 { fname.clone() } else { sig.replace(':', "") }; - - table.add_row([ - Cell::new(fn_display).add_attribute(Attribute::Bold), - Cell::new(gas_info.min.to_string()).fg(Color::Green), - Cell::new(gas_info.mean.to_string()).fg(Color::Yellow), - Cell::new(gas_info.median.to_string()).fg(Color::Yellow), - Cell::new(gas_info.max.to_string()).fg(Color::Red), - Cell::new(gas_info.calls.to_string()), - ]); - }) - }); - writeln!(f, "{table}")?; - writeln!(f, "\n")?; } + Ok(()) } } +impl GasReport { + fn format_json_output(&self) -> String { + #[inline] + fn format_gas_info(gas_info: &GasInfo) -> serde_json::Value { + json!({ + "calls": gas_info.calls, + "min": gas_info.min, + "mean": gas_info.mean, + "median": gas_info.median, + "max": gas_info.max, + }) + } + + serde_json::to_string( + &self + .contracts + .iter() + .filter_map(|(name, contract)| { + if contract.functions.is_empty() { + trace!(name, "gas report contract without functions"); + return None; + } + + let functions = contract + .functions + .iter() + .map(|(fname, sigs)| { + // If there is only one signature, display the gas info directly. + let function_value = if sigs.len() == 1 { + format_gas_info(sigs.values().next().unwrap()) + } else { + // If there are multiple signatures, e.g. overloads like: + // - `foo(uint256)` + // - `foo(int256)` + // display the gas info as a map with the signature as the key. + let signatures = sigs + .iter() + .map(|(sig, gas_info)| { + let display_name = sig.replace(':', ""); + (display_name, format_gas_info(gas_info)) + }) + .collect::>(); + + json!(signatures) + }; + + (fname.to_string(), function_value) + }) + .collect::>(); + + Some(json!({ + "contract": name, + "deployment": { + "gas": contract.gas, + "size": contract.size, + }, + "functions": functions, + })) + }) + .collect::>(), + ) + .unwrap() + } + + // Helper function to format the table output + fn format_table_output(&self, contract: &ContractInfo, name: &str) -> Table { + let mut table = Table::new(); + table.load_preset(ASCII_MARKDOWN); + table.set_header([Cell::new(format!("{name} contract")) + .add_attribute(Attribute::Bold) + .fg(Color::Green)]); + + table.add_row([ + Cell::new("Deployment Cost").add_attribute(Attribute::Bold).fg(Color::Cyan), + Cell::new("Deployment Size").add_attribute(Attribute::Bold).fg(Color::Cyan), + ]); + table.add_row([contract.gas.to_string(), contract.size.to_string()]); + + table.add_row([ + Cell::new("Function Name").add_attribute(Attribute::Bold).fg(Color::Magenta), + Cell::new("min").add_attribute(Attribute::Bold).fg(Color::Green), + Cell::new("avg").add_attribute(Attribute::Bold).fg(Color::Yellow), + Cell::new("median").add_attribute(Attribute::Bold).fg(Color::Yellow), + Cell::new("max").add_attribute(Attribute::Bold).fg(Color::Red), + Cell::new("# calls").add_attribute(Attribute::Bold), + ]); + + contract.functions.iter().for_each(|(fname, sigs)| { + sigs.iter().for_each(|(sig, gas_info)| { + // Show function signature if overloaded else display function name. + let display_name = + if sigs.len() == 1 { fname.to_string() } else { sig.replace(':', "") }; + + table.add_row([ + Cell::new(display_name).add_attribute(Attribute::Bold), + Cell::new(gas_info.min.to_string()).fg(Color::Green), + Cell::new(gas_info.mean.to_string()).fg(Color::Yellow), + Cell::new(gas_info.median.to_string()).fg(Color::Yellow), + Cell::new(gas_info.max.to_string()).fg(Color::Red), + Cell::new(gas_info.calls.to_string()), + ]); + }) + }); + + table + } +} + #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct ContractInfo { pub gas: u64, diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 6177e973dce66..48b73ac626ec5 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1591,16 +1591,61 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractOne", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "foo": { + "calls": 1, + "min": 45387, + "mean": 45387, + "median": 45387, + "max": 45387 + } + } + }, + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + }, + { + "contract": "src/Contracts.sol:ContractTwo", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "bar": { + "calls": 1, + "min": 64984, + "mean": 64984, + "median": 64984, + "max": 64984 + } + } + } +] +"#]] + .is_json(), + ); prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" @@ -1630,16 +1675,61 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractOne", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "foo": { + "calls": 1, + "min": 45387, + "mean": 45387, + "median": 45387, + "max": 45387 + } + } + }, + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + }, + { + "contract": "src/Contracts.sol:ContractTwo", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "bar": { + "calls": 1, + "min": 64984, + "mean": 64984, + "median": 64984, + "max": 64984 + } + } + } +] +"#]] + .is_json(), + ); prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" @@ -1669,16 +1759,61 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractOne", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "foo": { + "calls": 1, + "min": 45387, + "mean": 45387, + "median": 45387, + "max": 45387 + } + } + }, + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + }, + { + "contract": "src/Contracts.sol:ContractTwo", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "bar": { + "calls": 1, + "min": 64984, + "mean": 64984, + "median": 64984, + "max": 64984 + } + } + } +] +"#]] + .is_json(), + ); prj.write_config(Config { gas_reports: (vec![ @@ -1715,16 +1850,61 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractOne", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "foo": { + "calls": 1, + "min": 45387, + "mean": 45387, + "median": 45387, + "max": 45387 + } + } + }, + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + }, + { + "contract": "src/Contracts.sol:ContractTwo", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "bar": { + "calls": 1, + "min": 64984, + "mean": 64984, + "median": 64984, + "max": 64984 + } + } + } +] +"#]] + .is_json(), + ); }); forgetest!(gas_report_some_contracts, |prj, cmd| { @@ -1745,14 +1925,29 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractOne", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "foo": { + "calls": 1, + "min": 45387, + "mean": 45387, + "median": 45387, + "max": 45387 + } + } + } +] +"#]] + .is_json(), + ); // report for Two prj.write_config(Config { gas_reports: vec!["ContractTwo".to_string()], ..Default::default() }); @@ -1770,8 +1965,26 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( str![[r#" -{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} -"#]].is_jsonlines(), +[ + { + "contract": "src/Contracts.sol:ContractTwo", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "bar": { + "calls": 1, + "min": 64984, + "mean": 64984, + "median": 64984, + "max": 64984 + } + } + } +] +"#]] + .is_json(), ); // report for Three @@ -1791,17 +2004,32 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + } +] +"#]] + .is_json(), + ); }); -forgetest!(gas_ignore_some_contracts, |prj, cmd| { +forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { prj.insert_ds_test(); prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); @@ -1831,15 +2059,45 @@ forgetest!(gas_ignore_some_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + }, + { + "contract": "src/Contracts.sol:ContractTwo", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "bar": { + "calls": 1, + "min": 64984, + "mean": 64984, + "median": 64984, + "max": 64984 + } + } + } +] +"#]] + .is_json(), + ); // ignore ContractTwo cmd.forge_fuse(); @@ -1868,17 +2126,51 @@ forgetest!(gas_ignore_some_contracts, |prj, cmd| { ... "#]]); - cmd.forge_fuse() - .arg("test") - .arg("--gas-report") - .arg("--json") - .assert_success() - .stdout_eq(str![[r#" -{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -"#]].is_jsonlines()); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractOne", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "foo": { + "calls": 1, + "min": 45387, + "mean": 45387, + "median": 45387, + "max": 45387 + } + } + }, + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + } +] +"#]] + .is_json(), + ); - // ignore ContractThree + // If the user listed the contract in 'gas_reports' (the foundry.toml field) a + // report for the contract is generated even if it's listed in the ignore + // list. This is addressed this way because getting a report you don't expect is + // preferable than not getting one you expect. A warning is printed to stderr + // indicating the "double listing". cmd.forge_fuse(); prj.write_config(Config { gas_reports: (vec![ @@ -1890,7 +2182,10 @@ forgetest!(gas_ignore_some_contracts, |prj, cmd| { ..Default::default() }); cmd.forge_fuse(); - cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" + cmd.arg("test") + .arg("--gas-report") + .assert_success() + .stdout_eq(str![[r#" ... | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| @@ -1915,18 +2210,183 @@ forgetest!(gas_ignore_some_contracts, |prj, cmd| { | Function Name | min | avg | median | max | # calls | | bar | 64984 | 64984 | 64984 | 64984 | 1 | ... - +"#]]) + .stderr_eq(str![[r#" +... +warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. +... "#]]); cmd.forge_fuse() .arg("test") .arg("--gas-report") .arg("--json") .assert_success() - .stdout_eq(str![[r#" -{"gas":103375,"size":255,"functions":{"foo":{"foo()":{"calls":1,"min":45387,"mean":45387,"median":45387,"max":45387}}}} -{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}} -{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}} -"#]].is_jsonlines()); + .stdout_eq( + str![[r#" +[ + { + "contract": "src/Contracts.sol:ContractOne", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "foo": { + "calls": 1, + "min": 45387, + "mean": 45387, + "median": 45387, + "max": 45387 + } + } + }, + { + "contract": "src/Contracts.sol:ContractThree", + "deployment": { + "gas": 103591, + "size": 256 + }, + "functions": { + "baz": { + "calls": 1, + "min": 260712, + "mean": 260712, + "median": 260712, + "max": 260712 + } + } + }, + { + "contract": "src/Contracts.sol:ContractTwo", + "deployment": { + "gas": 103375, + "size": 255 + }, + "functions": { + "bar": { + "calls": 1, + "min": 64984, + "mean": 64984, + "median": 64984, + "max": 64984 + } + } + } +] +"#]] + .is_json(), + ) + .stderr_eq(str![[r#" +... +warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. +... +"#]]); +}); + +forgetest!(gas_report_multiple_selectors, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "Counter.sol", + r#" +contract Counter { + uint256 public a; + int256 public b; + + function setNumber(uint256 x) public { + a = x; + } + + function setNumber(int256 x) public { + b = x; + } +} +"#, + ) + .unwrap(); + + prj.add_source( + "CounterTest.t.sol", + r#" +import "./test.sol"; +import {Counter} from "./Counter.sol"; + +contract CounterTest is DSTest { + Counter public counter; + + function setUp() public { + counter = new Counter(); + counter.setNumber(uint256(0)); + counter.setNumber(int256(0)); + } + + function test_Increment() public { + counter.setNumber(uint256(counter.a() + 1)); + counter.setNumber(int256(counter.b() + 1)); + } +} +"#, + ) + .unwrap(); + + cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" +... +| src/Counter.sol:Counter contract | | | | | | +|----------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 101137 | 250 | | | | | +| Function Name | min | avg | median | max | # calls | +| a | 2261 | 2261 | 2261 | 2261 | 1 | +| b | 2305 | 2305 | 2305 | 2305 | 1 | +| setNumber(int256) | 23648 | 33604 | 33604 | 43560 | 2 | +| setNumber(uint256) | 23604 | 33560 | 33560 | 43516 | 2 | +... +"#]]); + cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( + str![[r#" +[ + { + "contract": "src/Counter.sol:Counter", + "deployment": { + "gas": 101137, + "size": 250 + }, + "functions": { + "a": { + "calls": 1, + "min": 2261, + "mean": 2261, + "median": 2261, + "max": 2261 + }, + "b": { + "calls": 1, + "min": 2305, + "mean": 2305, + "median": 2305, + "max": 2305 + }, + "setNumber": { + "setNumber(int256)": { + "calls": 2, + "min": 23648, + "mean": 33604, + "median": 33604, + "max": 43560 + }, + "setNumber(uint256)": { + "calls": 2, + "min": 23604, + "mean": 33560, + "median": 33560, + "max": 43516 + } + } + } + } +] +"#]] + .is_json(), + ); }); forgetest_init!(can_use_absolute_imports, |prj, cmd| { From dd443c6c0b017718a97a2302328e61f5c01582c2 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:56:51 +0200 Subject: [PATCH 1616/1963] fix(forge create): set skip_is_verified_check: true (#9222) fix(verify): set skip_is_verified_check: true for deploy (similar to broadcast) --- crates/forge/bin/cmd/create.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 1962f41f6d0c4..0cbc389c2ffdc 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -350,7 +350,7 @@ impl CreateArgs { rpc: Default::default(), flatten: false, force: false, - skip_is_verified_check: false, + skip_is_verified_check: true, watch: true, retry: self.retry, libraries: self.opts.libraries.clone(), From 3e901afcdc5dd22755ebe8ebdb288a6af756c8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Urbanek?= Date: Tue, 29 Oct 2024 15:45:26 +0100 Subject: [PATCH 1617/1963] feat(cast) add creation-code method [#8973] (#9029) * feat(cast) add creation-code method [#8973] * Fix typo * Fix CI * Code review fixes * Add creation-code flags and creation-args * Update comments * eyre style fixes * typo * use r#".."# for snapbox * Apply suggestions from code review * fix test regression * tag arguments as mutually exclusive * use unreachable! * Rename and add abi_path param * Decode constructor args * Update crates/cast/bin/cmd/constructor_args.rs * fix test * Update crates/cast/bin/args.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cast/bin/cmd/creation_code.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Update crates/cast/bin/cmd/creation_code.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * Fix formatting * Code review fixes --------- Co-authored-by: zerosnacks Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/cast/Cargo.toml | 9 +- crates/cast/bin/args.rs | 11 +- crates/cast/bin/cmd/constructor_args.rs | 100 ++++++++++++++ crates/cast/bin/cmd/creation_code.rs | 167 ++++++++++++++++++++++++ crates/cast/bin/cmd/interface.rs | 4 +- crates/cast/bin/cmd/mod.rs | 2 + crates/cast/bin/main.rs | 2 + crates/cast/tests/cli/main.rs | 58 ++++++++ 8 files changed, 348 insertions(+), 5 deletions(-) create mode 100644 crates/cast/bin/cmd/constructor_args.rs create mode 100644 crates/cast/bin/cmd/creation_code.rs diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 5fadb49675cea..4e6b001ecfaf3 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -44,9 +44,14 @@ alloy-json-abi.workspace = true alloy-json-rpc.workspace = true alloy-network.workspace = true alloy-primitives.workspace = true -alloy-provider = { workspace = true, features = ["reqwest", "ws", "ipc"] } +alloy-provider = { workspace = true, features = [ + "reqwest", + "ws", + "ipc", + "trace-api", +] } alloy-rlp.workspace = true -alloy-rpc-types = { workspace = true, features = ["eth"] } +alloy-rpc-types = { workspace = true, features = ["eth", "trace"] } alloy-serde.workspace = true alloy-signer-local = { workspace = true, features = ["mnemonic", "keystore"] } alloy-signer.workspace = true diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 386201e5b0ee6..7552c3bd5f03e 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -1,5 +1,6 @@ use crate::cmd::{ - access_list::AccessListArgs, bind::BindArgs, call::CallArgs, create2::Create2Args, + access_list::AccessListArgs, bind::BindArgs, call::CallArgs, + constructor_args::ConstructorArgsArgs, create2::Create2Args, creation_code::CreationCodeArgs, estimate::EstimateArgs, find_block::FindBlockArgs, interface::InterfaceArgs, logs::LogsArgs, mktx::MakeTxArgs, rpc::RpcArgs, run::RunArgs, send::SendTxArgs, storage::StorageArgs, wallet::WalletSubcommands, @@ -937,6 +938,14 @@ pub enum CastSubcommand { command: WalletSubcommands, }, + /// Download a contract creation code from Etherscan and RPC. + #[command(visible_alias = "cc")] + CreationCode(CreationCodeArgs), + + /// Display constructor arguments used for the contract initialization. + #[command(visible_alias = "cra")] + ConstructorArgs(ConstructorArgsArgs), + /// Generate a Solidity interface from a given ABI. /// /// Currently does not support ABI encoder v2. diff --git a/crates/cast/bin/cmd/constructor_args.rs b/crates/cast/bin/cmd/constructor_args.rs new file mode 100644 index 0000000000000..b0a08704fb3ce --- /dev/null +++ b/crates/cast/bin/cmd/constructor_args.rs @@ -0,0 +1,100 @@ +use alloy_dyn_abi::DynSolType; +use alloy_primitives::{Address, Bytes}; +use clap::{command, Parser}; +use eyre::{eyre, OptionExt, Result}; +use foundry_block_explorers::Client; +use foundry_cli::{ + opts::{EtherscanOpts, RpcOpts}, + utils, +}; +use foundry_config::Config; + +use super::{ + creation_code::fetch_creation_code, + interface::{fetch_abi_from_etherscan, load_abi_from_file}, +}; + +/// CLI arguments for `cast creation-args`. +#[derive(Parser)] +pub struct ConstructorArgsArgs { + /// An Ethereum address, for which the bytecode will be fetched. + contract: Address, + + /// Path to file containing the contract's JSON ABI. It's necessary if the target contract is + /// not verified on Etherscan + #[arg(long)] + abi_path: Option, + + #[command(flatten)] + etherscan: EtherscanOpts, + + #[command(flatten)] + rpc: RpcOpts, +} + +impl ConstructorArgsArgs { + pub async fn run(self) -> Result<()> { + let Self { contract, etherscan, rpc, abi_path } = self; + + let config = Config::from(ðerscan); + let chain = config.chain.unwrap_or_default(); + let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); + let client = Client::new(chain, api_key)?; + + let config = Config::from(&rpc); + let provider = utils::get_provider(&config)?; + + let bytecode = fetch_creation_code(contract, client, provider).await?; + + let args_arr = parse_constructor_args(bytecode, contract, ðerscan, abi_path).await?; + for arg in args_arr { + let _ = sh_println!("{arg}"); + } + + Ok(()) + } +} + +/// Fetches the constructor arguments values and types from the creation bytecode and ABI. +async fn parse_constructor_args( + bytecode: Bytes, + contract: Address, + etherscan: &EtherscanOpts, + abi_path: Option, +) -> Result> { + let abi = if let Some(abi_path) = abi_path { + load_abi_from_file(&abi_path, None)? + } else { + fetch_abi_from_etherscan(contract, etherscan).await? + }; + + let abi = abi.into_iter().next().ok_or_eyre("No ABI found.")?; + let (abi, _) = abi; + + let constructor = abi.constructor.ok_or_else(|| eyre!("No constructor found."))?; + + if constructor.inputs.is_empty() { + return Err(eyre!("No constructor arguments found.")); + } + + let args_size = constructor.inputs.len() * 32; + let args_bytes = Bytes::from(bytecode[bytecode.len() - args_size..].to_vec()); + + let display_args: Vec = args_bytes + .chunks(32) + .enumerate() + .map(|(i, arg)| { + format_arg(&constructor.inputs[i].ty, arg).expect("Failed to format argument.") + }) + .collect(); + + Ok(display_args) +} + +fn format_arg(ty: &str, arg: &[u8]) -> Result { + let arg_type: DynSolType = ty.parse().expect("Invalid ABI type."); + let decoded = arg_type.abi_decode(arg)?; + let bytes = Bytes::from(arg.to_vec()); + + Ok(format!("{bytes} → {decoded:?}")) +} diff --git a/crates/cast/bin/cmd/creation_code.rs b/crates/cast/bin/cmd/creation_code.rs new file mode 100644 index 0000000000000..bcafeac9488a4 --- /dev/null +++ b/crates/cast/bin/cmd/creation_code.rs @@ -0,0 +1,167 @@ +use alloy_primitives::{Address, Bytes}; +use alloy_provider::{ext::TraceApi, Provider}; +use alloy_rpc_types::trace::parity::{Action, CreateAction, CreateOutput, TraceOutput}; +use cast::SimpleCast; +use clap::{command, Parser}; +use eyre::{eyre, OptionExt, Result}; +use foundry_block_explorers::Client; +use foundry_cli::{ + opts::{EtherscanOpts, RpcOpts}, + utils, +}; +use foundry_common::provider::RetryProvider; +use foundry_config::Config; + +use super::interface::{fetch_abi_from_etherscan, load_abi_from_file}; + +/// CLI arguments for `cast creation-code`. +#[derive(Parser)] +pub struct CreationCodeArgs { + /// An Ethereum address, for which the bytecode will be fetched. + contract: Address, + + /// Path to file containing the contract's JSON ABI. It's necessary if the target contract is + /// not verified on Etherscan. + #[arg(long)] + abi_path: Option, + + /// Disassemble bytecodes into individual opcodes. + #[arg(long)] + disassemble: bool, + + /// Return creation bytecode without constructor arguments appended. + #[arg(long, conflicts_with = "only_args")] + without_args: bool, + + /// Return only constructor arguments. + #[arg(long)] + only_args: bool, + + #[command(flatten)] + etherscan: EtherscanOpts, + + #[command(flatten)] + rpc: RpcOpts, +} + +impl CreationCodeArgs { + pub async fn run(self) -> Result<()> { + let Self { contract, etherscan, rpc, disassemble, without_args, only_args, abi_path } = + self; + + let config = Config::from(ðerscan); + let chain = config.chain.unwrap_or_default(); + let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); + let client = Client::new(chain, api_key)?; + + let config = Config::from(&rpc); + let provider = utils::get_provider(&config)?; + + let bytecode = fetch_creation_code(contract, client, provider).await?; + + let bytecode = + parse_code_output(bytecode, contract, ðerscan, abi_path, without_args, only_args) + .await?; + + if disassemble { + let _ = sh_println!("{}", SimpleCast::disassemble(&bytecode)?); + } else { + let _ = sh_println!("{bytecode}"); + } + + Ok(()) + } +} + +/// Parses the creation bytecode and returns one of the following: +/// - The complete bytecode +/// - The bytecode without constructor arguments +/// - Only the constructor arguments +async fn parse_code_output( + bytecode: Bytes, + contract: Address, + etherscan: &EtherscanOpts, + abi_path: Option, + without_args: bool, + only_args: bool, +) -> Result { + if !without_args && !only_args { + return Ok(bytecode); + } + + let abi = if let Some(abi_path) = abi_path { + load_abi_from_file(&abi_path, None)? + } else { + fetch_abi_from_etherscan(contract, etherscan).await? + }; + + let abi = abi.into_iter().next().ok_or_eyre("No ABI found.")?; + let (abi, _) = abi; + + if abi.constructor.is_none() { + if only_args { + return Err(eyre!("No constructor found.")); + } + return Ok(bytecode); + } + + let constructor = abi.constructor.unwrap(); + if constructor.inputs.is_empty() { + if only_args { + return Err(eyre!("No constructor arguments found.")); + } + return Ok(bytecode); + } + + let args_size = constructor.inputs.len() * 32; + + let bytecode = if without_args { + Bytes::from(bytecode[..bytecode.len() - args_size].to_vec()) + } else if only_args { + Bytes::from(bytecode[bytecode.len() - args_size..].to_vec()) + } else { + unreachable!(); + }; + + Ok(bytecode) +} + +/// Fetches the creation code of a contract from Etherscan and RPC. +pub async fn fetch_creation_code( + contract: Address, + client: Client, + provider: RetryProvider, +) -> Result { + let creation_data = client.contract_creation_data(contract).await?; + let creation_tx_hash = creation_data.transaction_hash; + let tx_data = provider.get_transaction_by_hash(creation_tx_hash).await?; + let tx_data = tx_data.ok_or_eyre("Could not find creation tx data.")?; + + let bytecode = if tx_data.inner.to.is_none() { + // Contract was created using a standard transaction + tx_data.inner.input + } else { + // Contract was created using a factory pattern or create2 + // Extract creation code from tx traces + let mut creation_bytecode = None; + + let traces = provider.trace_transaction(creation_tx_hash).await.map_err(|e| { + eyre!("Could not fetch traces for transaction {}: {}", creation_tx_hash, e) + })?; + + for trace in traces { + if let Some(TraceOutput::Create(CreateOutput { address, .. })) = trace.trace.result { + if address == contract { + creation_bytecode = match trace.trace.action { + Action::Create(CreateAction { init, .. }) => Some(init), + _ => None, + }; + } + } + } + + creation_bytecode.ok_or_else(|| eyre!("Could not find contract creation trace."))? + }; + + Ok(bytecode) +} diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 1d9b392964b52..45df4983e4f09 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -108,7 +108,7 @@ struct InterfaceSource { } /// Load the ABI from a file. -fn load_abi_from_file(path: &str, name: Option) -> Result> { +pub fn load_abi_from_file(path: &str, name: Option) -> Result> { let file = std::fs::read_to_string(path).wrap_err("unable to read abi file")?; let obj: ContractObject = serde_json::from_str(&file)?; let abi = obj.abi.ok_or_else(|| eyre::eyre!("could not find ABI in file {path}"))?; @@ -139,7 +139,7 @@ fn load_abi_from_artifact(path_or_contract: &str) -> Result Result> { diff --git a/crates/cast/bin/cmd/mod.rs b/crates/cast/bin/cmd/mod.rs index 6c904417407c2..49e3ed2efe96c 100644 --- a/crates/cast/bin/cmd/mod.rs +++ b/crates/cast/bin/cmd/mod.rs @@ -8,7 +8,9 @@ pub mod access_list; pub mod bind; pub mod call; +pub mod constructor_args; pub mod create2; +pub mod creation_code; pub mod estimate; pub mod find_block; pub mod interface; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 0338d9ff26f0a..a7cd013c8b2fc 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -206,6 +206,8 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{}", SimpleCast::calldata_encode(sig, &args)?)?; } CastSubcommand::Interface(cmd) => cmd.run().await?, + CastSubcommand::CreationCode(cmd) => cmd.run().await?, + CastSubcommand::ConstructorArgs(cmd) => cmd.run().await?, CastSubcommand::Bind(cmd) => cmd.run().await?, CastSubcommand::PrettyCalldata { calldata, offline } => { let calldata = stdin::unwrap_line(calldata)?; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 6d5a6fd6a8214..9ff8a6d49c6d3 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1435,3 +1435,61 @@ casttest!(format_units, |_prj, cmd| { "#]]); }); + +// tests that fetches a sample contract creation code +// +casttest!(fetch_creation_code_from_etherscan, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + cmd.args([ + "creation-code", + "--etherscan-api-key", + &next_mainnet_etherscan_api_key(), + "0x0923cad07f06b2d0e5e49e63b8b35738d4156b95", + "--rpc-url", + eth_rpc_url.as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#" +0x60566050600b82828239805160001a6073146043577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122074c61e8e4eefd410ca92eec26e8112ec6e831d0a4bf35718fdd78b45d68220d064736f6c63430008070033 + +"#]]); +}); + +// tests that fetches a sample contract creation args bytes +// +casttest!(fetch_creation_code_only_args_from_etherscan, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + cmd.args([ + "creation-code", + "--etherscan-api-key", + &next_mainnet_etherscan_api_key(), + "0x6982508145454ce325ddbe47a25d4ec3d2311933", + "--rpc-url", + eth_rpc_url.as_str(), + "--only-args", + ]) + .assert_success() + .stdout_eq(str![[r#" +0x00000000000000000000000000000000000014bddab3e51a57cff87a50000000 + +"#]]); +}); + +// tests that displays a sample contract creation args +// +casttest!(fetch_constructor_args_from_etherscan, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + cmd.args([ + "constructor-args", + "--etherscan-api-key", + &next_mainnet_etherscan_api_key(), + "0x6982508145454ce325ddbe47a25d4ec3d2311933", + "--rpc-url", + eth_rpc_url.as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#" +0x00000000000000000000000000000000000014bddab3e51a57cff87a50000000 → Uint(420690000000000000000000000000000, 256) + +"#]]); +}); From 4389cbc0146e2f1a5fc663d6ceaa80ec722871ca Mon Sep 17 00:00:00 2001 From: Karrq Date: Tue, 29 Oct 2024 15:49:35 +0100 Subject: [PATCH 1618/1963] refactor: simplify `merge_db_account_data` (#9223) * refactor: simplify `merge_db_account_data` * chore: fmt --- crates/evm/core/src/backend/mod.rs | 42 +++++++++++++++++------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index b08d5fd44b602..e0b35f0bd07b5 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1877,25 +1877,31 @@ fn merge_db_account_data( ) { trace!(?addr, "merging database data"); - let mut acc = if let Some(acc) = active.accounts.get(&addr).cloned() { - acc - } else { - // Account does not exist - return; - }; - - if let Some(code) = active.contracts.get(&acc.info.code_hash).cloned() { - fork_db.contracts.insert(acc.info.code_hash, code); - } - - if let Some(fork_account) = fork_db.accounts.get_mut(&addr) { - // This will merge the fork's tracked storage with active storage and update values - fork_account.storage.extend(std::mem::take(&mut acc.storage)); - // swap them so we can insert the account as whole in the next step - std::mem::swap(&mut fork_account.storage, &mut acc.storage); + let Some(acc) = active.accounts.get(&addr) else { return }; + + // port contract cache over + if let Some(code) = active.contracts.get(&acc.info.code_hash) { + trace!("merging contract cache"); + fork_db.contracts.insert(acc.info.code_hash, code.clone()); + } + + // port account storage over + use std::collections::hash_map::Entry; + match fork_db.accounts.entry(addr) { + Entry::Vacant(vacant) => { + trace!("target account not present - inserting from active"); + // if the fork_db doesn't have the target account + // insert the entire thing + vacant.insert(acc.clone()); + } + Entry::Occupied(mut occupied) => { + trace!("target account present - merging storage slots"); + // if the fork_db does have the system, + // extend the existing storage (overriding) + let fork_account = occupied.get_mut(); + fork_account.storage.extend(&acc.storage); + } } - - fork_db.accounts.insert(addr, acc); } /// Returns true of the address is a contract From 0c703053fd272b505f40b62962dbd682cacd0adb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 29 Oct 2024 20:15:42 +0100 Subject: [PATCH 1619/1963] test: update test (#9226) --- crates/forge/tests/cli/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f492de01d1f37..d7860381cb199 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -261,7 +261,7 @@ forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { cmd.forge_fuse().args(["install", dep, "--no-commit"]).assert_success().stdout_eq(str![[ r#" Installing solmate in [..] (url: Some("https://github.com/transmissions11/solmate"), tag: None) - Installed solmate + Installed solmate[..] "# ]]); From 95015894110734539c53ffad97cd64ca116fce5e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 29 Oct 2024 20:25:37 +0100 Subject: [PATCH 1620/1963] style: smol refactor (#9224) --- crates/forge/bin/cmd/create.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 0cbc389c2ffdc..23fb0922ec357 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -128,20 +128,19 @@ impl CreateArgs { }; // Add arguments to constructor - let provider = utils::get_provider(&config)?; - let params = match abi.constructor { - Some(ref v) => { - let constructor_args = - if let Some(ref constructor_args_path) = self.constructor_args_path { - read_constructor_args_file(constructor_args_path.to_path_buf())? - } else { - self.constructor_args.clone() - }; - self.parse_constructor_args(v, &constructor_args)? - } - None => vec![], + let params = if let Some(constructor) = &abi.constructor { + let constructor_args = + self.constructor_args_path.clone().map(read_constructor_args_file).transpose()?; + self.parse_constructor_args( + constructor, + constructor_args.as_deref().unwrap_or(&self.constructor_args), + )? + } else { + vec![] }; + let provider = utils::get_provider(&config)?; + // respect chain, if set explicitly via cmd args let chain_id = if let Some(chain_id) = self.chain_id() { chain_id From 4012adefd376bd618d1348398c1da07224d2dace Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 30 Oct 2024 10:16:02 +0100 Subject: [PATCH 1621/1963] fix: allow_hyphen_values for constructor args (#9225) * fix: unescape ints * use allow_hyp --- crates/forge/bin/cmd/create.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 23fb0922ec357..e9f6cac745e1e 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -45,6 +45,7 @@ pub struct CreateArgs { num_args(1..), conflicts_with = "constructor_args_path", value_name = "ARGS", + allow_hyphen_values = true, )] constructor_args: Vec, @@ -633,6 +634,7 @@ impl From for ContractDeploymentError { #[cfg(test)] mod tests { use super::*; + use alloy_primitives::I256; #[test] fn can_parse_create() { @@ -688,4 +690,17 @@ mod tests { let constructor: Constructor = serde_json::from_str(r#"{"type":"constructor","inputs":[{"name":"_points","type":"tuple[]","internalType":"struct Point[]","components":[{"name":"x","type":"uint256","internalType":"uint256"},{"name":"y","type":"uint256","internalType":"uint256"}]}],"stateMutability":"nonpayable"}"#).unwrap(); let _params = args.parse_constructor_args(&constructor, &args.constructor_args).unwrap(); } + + #[test] + fn test_parse_int_constructor_args() { + let args: CreateArgs = CreateArgs::parse_from([ + "foundry-cli", + "src/Domains.sol:Domains", + "--constructor-args", + "-5", + ]); + let constructor: Constructor = serde_json::from_str(r#"{"type":"constructor","inputs":[{"name":"_name","type":"int256","internalType":"int256"}],"stateMutability":"nonpayable"}"#).unwrap(); + let params = args.parse_constructor_args(&constructor, &args.constructor_args).unwrap(); + assert_eq!(params, vec![DynSolValue::Int(I256::unchecked_from(-5), 256)]); + } } From ec2fd7d1ab7412c54b742a24336de05505bf2ff2 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:10:51 +0100 Subject: [PATCH 1622/1963] chore(meta): update SECURITY.md (#9230) --- SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index 5260d529f5a4d..bea27ad1140c0 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,4 +2,4 @@ ## Reporting a Vulnerability -Contact georgios at paradigm.xyz. +Contact [security@ithaca.xyz](mailto:security@ithaca.xyz). From 748af798223bd24e95394795109a0e683b42690c Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:29:58 +0100 Subject: [PATCH 1623/1963] fix(`--gas-report`): add back signatures, even if empty, avoid nesting multiple selectors (#9229) * add back signatures, even if empty, flatten multiple selectors per feedback https://github.com/foundry-rs/foundry/pull/9216#issuecomment-2445386251 * avoid manually serializing `gas_info`, already implements serialize --- crates/forge/src/gas_report.rs | 37 +++------------- crates/forge/tests/cli/cmd.rs | 78 +++++++++++++++++----------------- 2 files changed, 43 insertions(+), 72 deletions(-) diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 6c53bd9e6e75c..ac2d0db002622 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -181,17 +181,6 @@ impl Display for GasReport { impl GasReport { fn format_json_output(&self) -> String { - #[inline] - fn format_gas_info(gas_info: &GasInfo) -> serde_json::Value { - json!({ - "calls": gas_info.calls, - "min": gas_info.min, - "mean": gas_info.mean, - "median": gas_info.median, - "max": gas_info.max, - }) - } - serde_json::to_string( &self .contracts @@ -205,27 +194,11 @@ impl GasReport { let functions = contract .functions .iter() - .map(|(fname, sigs)| { - // If there is only one signature, display the gas info directly. - let function_value = if sigs.len() == 1 { - format_gas_info(sigs.values().next().unwrap()) - } else { - // If there are multiple signatures, e.g. overloads like: - // - `foo(uint256)` - // - `foo(int256)` - // display the gas info as a map with the signature as the key. - let signatures = sigs - .iter() - .map(|(sig, gas_info)| { - let display_name = sig.replace(':', ""); - (display_name, format_gas_info(gas_info)) - }) - .collect::>(); - - json!(signatures) - }; - - (fname.to_string(), function_value) + .flat_map(|(_, sigs)| { + sigs.iter().map(|(sig, gas_info)| { + let display_name = sig.replace(':', ""); + (display_name, gas_info) + }) }) .collect::>(); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 48b73ac626ec5..f34d0e2dec5d1 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1601,7 +1601,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "foo": { + "foo()": { "calls": 1, "min": 45387, "mean": 45387, @@ -1617,7 +1617,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -1633,7 +1633,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "bar": { + "bar()": { "calls": 1, "min": 64984, "mean": 64984, @@ -1685,7 +1685,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "foo": { + "foo()": { "calls": 1, "min": 45387, "mean": 45387, @@ -1701,7 +1701,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -1717,7 +1717,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "bar": { + "bar()": { "calls": 1, "min": 64984, "mean": 64984, @@ -1769,7 +1769,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "foo": { + "foo()": { "calls": 1, "min": 45387, "mean": 45387, @@ -1785,7 +1785,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -1801,7 +1801,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "bar": { + "bar()": { "calls": 1, "min": 64984, "mean": 64984, @@ -1860,7 +1860,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "foo": { + "foo()": { "calls": 1, "min": 45387, "mean": 45387, @@ -1876,7 +1876,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -1892,7 +1892,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { "size": 255 }, "functions": { - "bar": { + "bar()": { "calls": 1, "min": 64984, "mean": 64984, @@ -1935,7 +1935,7 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { "size": 255 }, "functions": { - "foo": { + "foo()": { "calls": 1, "min": 45387, "mean": 45387, @@ -1973,7 +1973,7 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { "size": 255 }, "functions": { - "bar": { + "bar()": { "calls": 1, "min": 64984, "mean": 64984, @@ -2014,7 +2014,7 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -2069,7 +2069,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -2085,7 +2085,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { "size": 255 }, "functions": { - "bar": { + "bar()": { "calls": 1, "min": 64984, "mean": 64984, @@ -2136,7 +2136,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { "size": 255 }, "functions": { - "foo": { + "foo()": { "calls": 1, "min": 45387, "mean": 45387, @@ -2152,7 +2152,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -2231,7 +2231,7 @@ warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. "size": 255 }, "functions": { - "foo": { + "foo()": { "calls": 1, "min": 45387, "mean": 45387, @@ -2247,7 +2247,7 @@ warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. "size": 256 }, "functions": { - "baz": { + "baz()": { "calls": 1, "min": 260712, "mean": 260712, @@ -2263,7 +2263,7 @@ warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. "size": 255 }, "functions": { - "bar": { + "bar()": { "calls": 1, "min": 64984, "mean": 64984, @@ -2283,7 +2283,7 @@ warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. "#]]); }); -forgetest!(gas_report_multiple_selectors, |prj, cmd| { +forgetest!(gas_report_flatten_multiple_selectors, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "Counter.sol", @@ -2351,35 +2351,33 @@ contract CounterTest is DSTest { "size": 250 }, "functions": { - "a": { + "a()": { "calls": 1, "min": 2261, "mean": 2261, "median": 2261, "max": 2261 }, - "b": { + "b()": { "calls": 1, "min": 2305, "mean": 2305, "median": 2305, "max": 2305 }, - "setNumber": { - "setNumber(int256)": { - "calls": 2, - "min": 23648, - "mean": 33604, - "median": 33604, - "max": 43560 - }, - "setNumber(uint256)": { - "calls": 2, - "min": 23604, - "mean": 33560, - "median": 33560, - "max": 43516 - } + "setNumber(int256)": { + "calls": 2, + "min": 23648, + "mean": 33604, + "median": 33604, + "max": 43560 + }, + "setNumber(uint256)": { + "calls": 2, + "min": 23604, + "mean": 33560, + "median": 33560, + "max": 43516 } } } From 2bb446e9387b61d6fed1c157a7330b07c610b52e Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:02:56 +0530 Subject: [PATCH 1624/1963] feat(`cheatcodes`): access broadcast artifacts (#9107) * refac(`script`): extract script sequence and related types to new crate * replace MultiChainSequence in script crate * replace TransactionWithMetadata and AdditionalContract * replace ScriptSequence * replace all underlying ScriptSequence and related types * doc nits * add `ScriptTransactionBuilder` * remove `TxWithMetadata` * mv verify fns and use `ScriptSequence` directly * clippy * feat(`cheatcodes`): vm.getDeployment * cargo cheats * getBroadcast by txType * get all broadcast txs * nits * fix * feat: getBroadcasts by txType * nit * fix * mv `BroadcastReader` to script-sequence * fix: search all broadcast files and then apply filters * fix: ignore run-latest to avoid duplicating entries * nit * sort by descending block number * tests * feat(`CheatsConfig`): add `broadcast` dir path * feat: read multichain sequences * nit * minify json * use walkdir * fix * fix path * feat: getDeployment cheatcodes * feat: read broadcasts with multiple tx types * test: getDeployment * nit * fmt * fix * nit * cli test * nit * remove solidity test * nit --- Cargo.lock | 2 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 169 +++++++++++++++++++ crates/cheatcodes/spec/src/lib.rs | 2 + crates/cheatcodes/spec/src/vm.rs | 63 +++++++ crates/cheatcodes/src/config.rs | 4 + crates/cheatcodes/src/fs.rs | 169 +++++++++++++++++++ crates/forge/tests/cli/test_cmd.rs | 202 +++++++++++++++++++++++ crates/script-sequence/Cargo.toml | 1 + crates/script-sequence/src/lib.rs | 2 + crates/script-sequence/src/reader.rs | 179 ++++++++++++++++++++ testdata/cheats/Vm.sol | 8 + 12 files changed, 802 insertions(+) create mode 100644 crates/script-sequence/src/reader.rs diff --git a/Cargo.lock b/Cargo.lock index 014b458f96428..de6f11ea9b219 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3514,6 +3514,7 @@ dependencies = [ "serde", "serde_json", "tracing", + "walkdir", ] [[package]] @@ -3613,6 +3614,7 @@ dependencies = [ "dialoguer", "ecdsa", "eyre", + "forge-script-sequence", "foundry-cheatcodes-spec", "foundry-common", "foundry-compilers", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index adce79b211bd3..00d73ec4d41af 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -29,6 +29,7 @@ foundry-config.workspace = true foundry-evm-core.workspace = true foundry-evm-traces.workspace = true foundry-wallets.workspace = true +forge-script-sequence.workspace = true alloy-dyn-abi.workspace = true alloy-json-abi.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 4dbdd29b5da7e..79761ae5a0edb 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -125,6 +125,24 @@ "description": "Unknown `forge` execution context." } ] + }, + { + "name": "BroadcastTxType", + "description": "The transaction type (`txType`) of the broadcast.", + "variants": [ + { + "name": "Call", + "description": "Represents a CALL broadcast tx." + }, + { + "name": "Create", + "description": "Represents a CREATE broadcast tx." + }, + { + "name": "Create2", + "description": "Represents a CREATE2 broadcast tx." + } + ] } ], "structs": [ @@ -524,6 +542,37 @@ "description": "The contract address where the opcode is running" } ] + }, + { + "name": "BroadcastTxSummary", + "description": "Represents a transaction's broadcast details.", + "fields": [ + { + "name": "txHash", + "ty": "bytes32", + "description": "The hash of the transaction that was broadcasted" + }, + { + "name": "txType", + "ty": "BroadcastTxType", + "description": "Represent the type of transaction among CALL, CREATE, CREATE2" + }, + { + "name": "contractAddress", + "ty": "address", + "description": "The address of the contract that was called or created.\n This is address of the contract that is created if the txType is CREATE or CREATE2." + }, + { + "name": "blockNumber", + "ty": "uint64", + "description": "The block number the transaction landed in." + }, + { + "name": "success", + "ty": "bool", + "description": "Status of the transaction, retrieved from the transaction receipt." + } + ] } ], "cheatcodes": [ @@ -5251,6 +5300,66 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getBroadcast", + "description": "Returns the most recent broadcast for the given contract on `chainId` matching `txType`.\nFor example:\nThe most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.\nThe most recent call can be fetched by passing `txType` as `CALL`.", + "declaration": "function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary memory);", + "visibility": "external", + "mutability": "", + "signature": "getBroadcast(string,uint64,uint8)", + "selector": "0x3dc90cb3", + "selectorBytes": [ + 61, + 201, + 12, + 179 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getBroadcasts_0", + "description": "Returns all broadcasts for the given contract on `chainId` with the specified `txType`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", + "declaration": "function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary[] memory);", + "visibility": "external", + "mutability": "", + "signature": "getBroadcasts(string,uint64,uint8)", + "selector": "0xf7afe919", + "selectorBytes": [ + 247, + 175, + 233, + 25 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getBroadcasts_1", + "description": "Returns all broadcasts for the given contract on `chainId`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", + "declaration": "function getBroadcasts(string memory contractName, uint64 chainId) external returns (BroadcastTxSummary[] memory);", + "visibility": "external", + "mutability": "", + "signature": "getBroadcasts(string,uint64)", + "selector": "0xf2fa4a26", + "selectorBytes": [ + 242, + 250, + 74, + 38 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "getCode", @@ -5291,6 +5400,66 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getDeployment_0", + "description": "Returns the most recent deployment for the current `chainId`.", + "declaration": "function getDeployment(string memory contractName) external returns (address deployedAddress);", + "visibility": "external", + "mutability": "", + "signature": "getDeployment(string)", + "selector": "0xa8091d97", + "selectorBytes": [ + 168, + 9, + 29, + 151 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getDeployment_1", + "description": "Returns the most recent deployment for the given contract on `chainId`", + "declaration": "function getDeployment(string memory contractName, uint64 chainId) external returns (address deployedAddress);", + "visibility": "external", + "mutability": "", + "signature": "getDeployment(string,uint64)", + "selector": "0x0debd5d6", + "selectorBytes": [ + 13, + 235, + 213, + 214 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getDeployments", + "description": "Returns all deployments for the given contract on `chainId`\nSorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.\nThe most recent deployment is the first element, and the oldest is the last.", + "declaration": "function getDeployments(string memory contractName, uint64 chainId) external returns (address[] memory deployedAddresses);", + "visibility": "external", + "mutability": "", + "signature": "getDeployments(string,uint64)", + "selector": "0x74e133dd", + "selectorBytes": [ + 116, + 225, + 51, + 221 + ] + }, + "group": "filesystem", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "getFoundryVersion", diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index 662853e9e8117..eae2ae0ee9c21 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -86,11 +86,13 @@ impl Cheatcodes<'static> { Vm::StorageAccess::STRUCT.clone(), Vm::Gas::STRUCT.clone(), Vm::DebugStep::STRUCT.clone(), + Vm::BroadcastTxSummary::STRUCT.clone(), ]), enums: Cow::Owned(vec![ Vm::CallerMode::ENUM.clone(), Vm::AccountAccessKind::ENUM.clone(), Vm::ForgeContext::ENUM.clone(), + Vm::BroadcastTxType::ENUM.clone(), ]), errors: Vm::VM_ERRORS.iter().copied().cloned().collect(), events: Cow::Borrowed(&[]), diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 21d41b373e011..ce0bc08b05775 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -283,6 +283,31 @@ interface Vm { address contractAddr; } + /// The transaction type (`txType`) of the broadcast. + enum BroadcastTxType { + /// Represents a CALL broadcast tx. + Call, + /// Represents a CREATE broadcast tx. + Create, + /// Represents a CREATE2 broadcast tx. + Create2 + } + + /// Represents a transaction's broadcast details. + struct BroadcastTxSummary { + /// The hash of the transaction that was broadcasted + bytes32 txHash; + /// Represent the type of transaction among CALL, CREATE, CREATE2 + BroadcastTxType txType; + /// The address of the contract that was called or created. + /// This is address of the contract that is created if the txType is CREATE or CREATE2. + address contractAddress; + /// The block number the transaction landed in. + uint64 blockNumber; + /// Status of the transaction, retrieved from the transaction receipt. + bool success; + } + // ======== EVM ======== /// Gets the address for a given private key. @@ -1670,6 +1695,44 @@ interface Vm { #[cheatcode(group = Filesystem)] function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); + /// Returns the most recent broadcast for the given contract on `chainId` matching `txType`. + /// + /// For example: + /// + /// The most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`. + /// + /// The most recent call can be fetched by passing `txType` as `CALL`. + #[cheatcode(group = Filesystem)] + function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary memory); + + /// Returns all broadcasts for the given contract on `chainId` with the specified `txType`. + /// + /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. + #[cheatcode(group = Filesystem)] + function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary[] memory); + + /// Returns all broadcasts for the given contract on `chainId`. + /// + /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. + #[cheatcode(group = Filesystem)] + function getBroadcasts(string memory contractName, uint64 chainId) external returns (BroadcastTxSummary[] memory); + + /// Returns the most recent deployment for the current `chainId`. + #[cheatcode(group = Filesystem)] + function getDeployment(string memory contractName) external returns (address deployedAddress); + + /// Returns the most recent deployment for the given contract on `chainId` + #[cheatcode(group = Filesystem)] + function getDeployment(string memory contractName, uint64 chainId) external returns (address deployedAddress); + + /// Returns all deployments for the given contract on `chainId` + /// + /// Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber. + /// + /// The most recent deployment is the first element, and the oldest is the last. + #[cheatcode(group = Filesystem)] + function getDeployments(string memory contractName, uint64 chainId) external returns (address[] memory deployedAddresses); + // -------- Foreign Function Interface -------- /// Performs a foreign function call via the terminal. diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index cfd6e9452df67..fa1ec6039cdee 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -37,6 +37,8 @@ pub struct CheatsConfig { pub fs_permissions: FsPermissions, /// Project root pub root: PathBuf, + /// Absolute Path to broadcast dir i.e project_root/broadcast + pub broadcast: PathBuf, /// Paths (directories) where file reading/writing is allowed pub allowed_paths: Vec, /// How the evm was configured by the user @@ -87,6 +89,7 @@ impl CheatsConfig { paths: config.project_paths(), fs_permissions: config.fs_permissions.clone().joined(config.root.as_ref()), root: config.root.0.clone(), + broadcast: config.root.0.clone().join(&config.broadcast), allowed_paths, evm_opts, labels: config.labels.clone(), @@ -216,6 +219,7 @@ impl Default for CheatsConfig { paths: ProjectPathsConfig::builder().build_with_root("./"), fs_permissions: Default::default(), root: Default::default(), + broadcast: Default::default(), allowed_paths: vec![], evm_opts: Default::default(), labels: Default::default(), diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index c8c512b6f15ef..04af101eb7538 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -5,11 +5,15 @@ use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::* use alloy_dyn_abi::DynSolType; use alloy_json_abi::ContractObject; use alloy_primitives::{hex, map::Entry, Bytes, U256}; +use alloy_provider::network::ReceiptResponse; +use alloy_rpc_types::AnyTransactionReceipt; use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; +use forge_script_sequence::{BroadcastReader, TransactionWithMetadata}; use foundry_common::fs; use foundry_config::fs_permissions::FsAccessKind; use revm::interpreter::CreateInputs; +use revm_inspectors::tracing::types::CallKind; use semver::Version; use std::{ io::{BufRead, BufReader, Write}, @@ -626,6 +630,171 @@ fn prompt( } } +impl Cheatcode for getBroadcastCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { contractName, chainId, txType } = self; + + let latest_broadcast = latest_broadcast( + contractName, + *chainId, + &state.config.broadcast, + vec![map_broadcast_tx_type(*txType)], + )?; + + Ok(latest_broadcast.abi_encode()) + } +} + +impl Cheatcode for getBroadcasts_0Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { contractName, chainId, txType } = self; + + let reader = BroadcastReader::new(contractName.clone(), *chainId, &state.config.broadcast)? + .with_tx_type(map_broadcast_tx_type(*txType)); + + let broadcasts = reader.read()?; + + let summaries = broadcasts + .into_iter() + .flat_map(|broadcast| { + let results = reader.into_tx_receipts(broadcast); + parse_broadcast_results(results) + }) + .collect::>(); + + Ok(summaries.abi_encode()) + } +} + +impl Cheatcode for getBroadcasts_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { contractName, chainId } = self; + + let reader = BroadcastReader::new(contractName.clone(), *chainId, &state.config.broadcast)?; + + let broadcasts = reader.read()?; + + let summaries = broadcasts + .into_iter() + .flat_map(|broadcast| { + let results = reader.into_tx_receipts(broadcast); + parse_broadcast_results(results) + }) + .collect::>(); + + Ok(summaries.abi_encode()) + } +} + +impl Cheatcode for getDeployment_0Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { contractName } = self; + let chain_id = ccx.ecx.env.cfg.chain_id; + + let latest_broadcast = latest_broadcast( + contractName, + chain_id, + &ccx.state.config.broadcast, + vec![CallKind::Create, CallKind::Create2], + )?; + + Ok(latest_broadcast.contractAddress.abi_encode()) + } +} + +impl Cheatcode for getDeployment_1Call { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { contractName, chainId } = self; + + let latest_broadcast = latest_broadcast( + contractName, + *chainId, + &state.config.broadcast, + vec![CallKind::Create, CallKind::Create2], + )?; + + Ok(latest_broadcast.contractAddress.abi_encode()) + } +} + +impl Cheatcode for getDeploymentsCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let Self { contractName, chainId } = self; + + let reader = BroadcastReader::new(contractName.clone(), *chainId, &state.config.broadcast)? + .with_tx_type(CallKind::Create) + .with_tx_type(CallKind::Create2); + + let broadcasts = reader.read()?; + + let summaries = broadcasts + .into_iter() + .flat_map(|broadcast| { + let results = reader.into_tx_receipts(broadcast); + parse_broadcast_results(results) + }) + .collect::>(); + + let deployed_addresses = + summaries.into_iter().map(|summary| summary.contractAddress).collect::>(); + + Ok(deployed_addresses.abi_encode()) + } +} + +fn map_broadcast_tx_type(tx_type: BroadcastTxType) -> CallKind { + match tx_type { + BroadcastTxType::Call => CallKind::Call, + BroadcastTxType::Create => CallKind::Create, + BroadcastTxType::Create2 => CallKind::Create2, + _ => unreachable!("invalid tx type"), + } +} + +fn parse_broadcast_results( + results: Vec<(TransactionWithMetadata, AnyTransactionReceipt)>, +) -> Vec { + results + .into_iter() + .map(|(tx, receipt)| BroadcastTxSummary { + txHash: receipt.transaction_hash, + blockNumber: receipt.block_number.unwrap_or_default(), + txType: match tx.opcode { + CallKind::Call => BroadcastTxType::Call, + CallKind::Create => BroadcastTxType::Create, + CallKind::Create2 => BroadcastTxType::Create2, + _ => unreachable!("invalid tx type"), + }, + contractAddress: tx.contract_address.unwrap_or_default(), + success: receipt.status(), + }) + .collect() +} + +fn latest_broadcast( + contract_name: &String, + chain_id: u64, + broadcast_path: &Path, + filters: Vec, +) -> Result { + let mut reader = BroadcastReader::new(contract_name.clone(), chain_id, broadcast_path)?; + + for filter in filters { + reader = reader.with_tx_type(filter); + } + + let broadcast = reader.read_latest()?; + + let results = reader.into_tx_receipts(broadcast); + + let summaries = parse_broadcast_results(results); + + summaries + .first() + .ok_or_else(|| fmt_err!("no deployment found for {contract_name} on chain {chain_id}")) + .cloned() +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index d76a6124f7bdb..8ce502a652b9e 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1,6 +1,7 @@ //! Contains various tests for `forge test`. use alloy_primitives::U256; +use anvil::{spawn, NodeConfig}; use foundry_config::{Config, FuzzConfig}; use foundry_test_utils::{ rpc, str, @@ -2390,3 +2391,204 @@ contract Dummy { assert!(dump_path.exists()); }); + +forgetest_async!(can_get_broadcast_txs, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + + let (_api, handle) = spawn(NodeConfig::test().silent()).await; + + prj.insert_vm(); + prj.insert_ds_test(); + prj.insert_console(); + + prj.add_source( + "Counter.sol", + r#" + contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } +} + "#, + ) + .unwrap(); + + prj.add_script( + "DeployCounter", + r#" + import "forge-std/Script.sol"; + import "src/Counter.sol"; + + contract DeployCounter is Script { + function run() public { + vm.startBroadcast(); + + Counter counter = new Counter(); + + counter.increment(); + + counter.setNumber(10); + + vm.stopBroadcast(); + } + } + "#, + ) + .unwrap(); + + prj.add_script( + "DeployCounterWithCreate2", + r#" + import "forge-std/Script.sol"; + import "src/Counter.sol"; + + contract DeployCounterWithCreate2 is Script { + function run() public { + vm.startBroadcast(); + + bytes32 salt = bytes32(uint256(1337)); + Counter counter = new Counter{salt: salt}(); + + counter.increment(); + + counter.setNumber(20); + + vm.stopBroadcast(); + } + } + "#, + ) + .unwrap(); + + let test = r#" + import {Vm} from "../src/Vm.sol"; + import {DSTest} from "../src/test.sol"; + import {console} from "../src/console.sol"; + + contract GetBroadcastTest is DSTest { + + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_getLatestBroacast() external { + // Gets the latest create + Vm.BroadcastTxSummary memory broadcast = vm.getBroadcast( + "Counter", + 31337, + Vm.BroadcastTxType.Create + ); + + console.log("latest create"); + console.log(broadcast.blockNumber); + + assertEq(broadcast.blockNumber, 1); + + // Gets the latest create2 + Vm.BroadcastTxSummary memory broadcast2 = vm.getBroadcast( + "Counter", + 31337, + Vm.BroadcastTxType.Create2 + ); + + console.log("latest create2"); + console.log(broadcast2.blockNumber); + assertEq(broadcast2.blockNumber, 4); + + // Gets the latest call + Vm.BroadcastTxSummary memory broadcast3 = vm.getBroadcast( + "Counter", + 31337, + Vm.BroadcastTxType.Call + ); + + console.log("latest call"); + assertEq(broadcast3.blockNumber, 6); + } + + function test_getBroadcasts() public { + // Gets all calls + Vm.BroadcastTxSummary[] memory broadcasts = vm.getBroadcasts( + "Counter", + 31337, + Vm.BroadcastTxType.Call + ); + + assertEq(broadcasts.length, 4); + } + + function test_getAllBroadcasts() public { + // Gets all broadcasts + Vm.BroadcastTxSummary[] memory broadcasts2 = vm.getBroadcasts( + "Counter", + 31337 + ); + + assertEq(broadcasts2.length, 6); + } + + function test_getLatestDeployment() public { + address deployedAddress = vm.getDeployment( + "Counter", + 31337 + ); + + assertEq(deployedAddress, address(0x030D07c16e2c0a77f74ab16f3C8F10ACeF89FF81)); + } + + function test_getDeployments() public { + address[] memory deployments = vm.getDeployments( + "Counter", + 31337 + ); + + assertEq(deployments.length, 2); + assertEq(deployments[0], address(0x030D07c16e2c0a77f74ab16f3C8F10ACeF89FF81)); // Create2 address - latest deployment + assertEq(deployments[1], address(0x5FbDB2315678afecb367f032d93F642f64180aa3)); // Create address - oldest deployment + } + +} + "#; + + prj.add_test("GetBroadcast", test).unwrap(); + + let sender = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; + + cmd.args([ + "script", + "DeployCounter", + "--rpc-url", + &handle.http_endpoint(), + "--sender", + sender, + "--unlocked", + "--broadcast", + "--slow", + ]) + .assert_success(); + + cmd.forge_fuse() + .args([ + "script", + "DeployCounterWithCreate2", + "--rpc-url", + &handle.http_endpoint(), + "--sender", + sender, + "--unlocked", + "--broadcast", + "--slow", + ]) + .assert_success(); + + let broadcast_path = prj.root().join("broadcast"); + + // Check if the broadcast folder exists + assert!(broadcast_path.exists() && broadcast_path.is_dir()); + + cmd.forge_fuse().args(["test", "--mc", "GetBroadcastTest", "-vvv"]).assert_success(); +}); diff --git a/crates/script-sequence/Cargo.toml b/crates/script-sequence/Cargo.toml index e128fe37b5ef7..13326e684cac6 100644 --- a/crates/script-sequence/Cargo.toml +++ b/crates/script-sequence/Cargo.toml @@ -22,6 +22,7 @@ serde.workspace = true eyre.workspace = true serde_json.workspace = true tracing.workspace = true +walkdir.workspace = true revm-inspectors.workspace = true diff --git a/crates/script-sequence/src/lib.rs b/crates/script-sequence/src/lib.rs index 11970e9478be4..929f44a724b8c 100644 --- a/crates/script-sequence/src/lib.rs +++ b/crates/script-sequence/src/lib.rs @@ -3,8 +3,10 @@ #[macro_use] extern crate foundry_common; +pub mod reader; pub mod sequence; pub mod transaction; +pub use reader::*; pub use sequence::*; pub use transaction::*; diff --git a/crates/script-sequence/src/reader.rs b/crates/script-sequence/src/reader.rs new file mode 100644 index 0000000000000..c4627dec09ecc --- /dev/null +++ b/crates/script-sequence/src/reader.rs @@ -0,0 +1,179 @@ +use crate::{ScriptSequence, TransactionWithMetadata}; +use alloy_rpc_types::AnyTransactionReceipt; +use eyre::{bail, Result}; +use foundry_common::fs; +use revm_inspectors::tracing::types::CallKind; +use std::path::{Component, Path, PathBuf}; + +/// This type reads broadcast files in the +/// `project_root/broadcast/{contract_name}.s.sol/{chain_id}/` directory. +/// +/// It consists methods that filter and search for transactions in the broadcast files that match a +/// `transactionType` if provided. +/// +/// Note: +/// +/// It only returns transactions for which there exists a corresponding receipt in the broadcast. +#[derive(Debug, Clone)] +pub struct BroadcastReader { + contract_name: String, + chain_id: u64, + tx_type: Vec, + broadcast_path: PathBuf, +} + +impl BroadcastReader { + /// Create a new `BroadcastReader` instance. + pub fn new(contract_name: String, chain_id: u64, broadcast_path: &Path) -> Result { + if !broadcast_path.exists() && !broadcast_path.is_dir() { + bail!("broadcast dir does not exist"); + } + + Ok(Self { + contract_name, + chain_id, + tx_type: Default::default(), + broadcast_path: broadcast_path.to_path_buf(), + }) + } + + /// Set the transaction type to filter by. + pub fn with_tx_type(mut self, tx_type: CallKind) -> Self { + self.tx_type.push(tx_type); + self + } + + /// Read all broadcast files in the broadcast directory. + /// + /// Example structure: + /// + /// project-root/broadcast/{script_name}.s.sol/{chain_id}/*.json + /// project-root/broadcast/multi/{multichain_script_name}.s.sol-{timestamp}/deploy.json + pub fn read(&self) -> eyre::Result> { + // 1. Recursively read all .json files in the broadcast directory + let mut broadcasts = vec![]; + for entry in walkdir::WalkDir::new(&self.broadcast_path).into_iter() { + let entry = entry?; + let path = entry.path(); + + if path.is_file() && path.extension().is_some_and(|ext| ext == "json") { + // Ignore -latest to avoid duplicating broadcast entries + if path.components().any(|c| c.as_os_str().to_string_lossy().contains("-latest")) { + continue; + } + + // Detect Multichain broadcasts using "multi" in the path + if path.components().any(|c| c == Component::Normal("multi".as_ref())) { + // Parse as MultiScriptSequence + + let broadcast = fs::read_json_file::(path)?; + let multichain_deployments = broadcast + .get("deployments") + .and_then(|deployments| { + serde_json::from_value::>(deployments.clone()).ok() + }) + .unwrap_or_default(); + + broadcasts.extend(multichain_deployments); + continue; + } + + let broadcast = fs::read_json_file::(path)?; + broadcasts.push(broadcast); + } + } + + let broadcasts = self.filter_and_sort(broadcasts); + + Ok(broadcasts) + } + + /// Attempts read the latest broadcast file in the broadcast directory. + /// + /// This may be the `run-latest.json` file or the broadcast file with the latest timestamp. + pub fn read_latest(&self) -> eyre::Result { + let broadcasts = self.read()?; + + // Find the broadcast with the latest timestamp + let target = broadcasts + .into_iter() + .max_by_key(|broadcast| broadcast.timestamp) + .ok_or_else(|| eyre::eyre!("No broadcasts found"))?; + + Ok(target) + } + + /// Applies the filters and sorts the broadcasts by descending timestamp. + pub fn filter_and_sort(&self, broadcasts: Vec) -> Vec { + // Apply the filters + let mut seqs = broadcasts + .into_iter() + .filter(|broadcast| { + if broadcast.chain != self.chain_id { + return false; + } + + broadcast.transactions.iter().any(move |tx| { + let name_filter = + tx.contract_name.clone().is_some_and(|cn| cn == self.contract_name); + + let type_filter = self.tx_type.is_empty() || + self.tx_type.iter().any(|kind| *kind == tx.opcode); + + name_filter && type_filter + }) + }) + .collect::>(); + + // Sort by descending timestamp + seqs.sort_by(|a, b| b.timestamp.cmp(&a.timestamp)); + + seqs + } + + /// Search for transactions in the broadcast that match the specified `contractName` and + /// `txType`. + /// + /// It cross-checks the transactions with their corresponding receipts in the broadcast and + /// returns the result. + /// + /// Transactions that don't have a corresponding receipt are ignored. + /// + /// Sorts the transactions by descending block number. + pub fn into_tx_receipts( + &self, + broadcast: ScriptSequence, + ) -> Vec<(TransactionWithMetadata, AnyTransactionReceipt)> { + let transactions = broadcast.transactions.clone(); + + let txs = transactions + .into_iter() + .filter(|tx| { + let name_filter = + tx.contract_name.clone().is_some_and(|cn| cn == self.contract_name); + + let type_filter = + self.tx_type.is_empty() || self.tx_type.iter().any(|kind| *kind == tx.opcode); + + name_filter && type_filter + }) + .collect::>(); + + let mut targets = Vec::new(); + for tx in txs.into_iter() { + let maybe_receipt = broadcast + .receipts + .iter() + .find(|receipt| tx.hash.is_some_and(|hash| hash == receipt.transaction_hash)); + + if let Some(receipt) = maybe_receipt { + targets.push((tx, receipt.clone())); + } + } + + // Sort by descending block number + targets.sort_by(|a, b| b.1.block_number.cmp(&a.1.block_number)); + + targets + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 2d4030d30e1a5..b33df8f2dc18a 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -9,6 +9,7 @@ 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; } @@ -21,6 +22,7 @@ interface Vm { 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; @@ -257,8 +259,14 @@ 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 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 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); From 45d5997134e9de548a99a46367023c1ea4625073 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:10:18 +0530 Subject: [PATCH 1625/1963] fix(`anvil`): set `storage.best_number` correctly (#9215) * feat(`anvil`): persist accounts in `ForkedStorage` * load accounts * test * fix(`anvil`): override storage.best_number with fork_block_num if loading state on a fork url * Revert "load accounts" This reverts commit b650f56fe52f79be3eb7c8ab4d2ad1aaca08a32f. * Revert "feat(`anvil`): persist accounts in `ForkedStorage`" This reverts commit 456da156e07b1ede01c08c4f48ef36eed4094f17. * nit --------- Co-authored-by: grandizzy * nit --------- Co-authored-by: grandizzy --- crates/anvil/src/eth/backend/mem/mod.rs | 32 +++++---- crates/anvil/tests/it/state.rs | 94 ++++++++++++++++++++++++- 2 files changed, 112 insertions(+), 14 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 73adaa97f3fd7..65ab8c32952b8 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -907,19 +907,27 @@ impl Backend { // Set the current best block number. // Defaults to block number for compatibility with existing state files. + let fork_num_and_hash = self.get_fork().map(|f| (f.block_number(), f.block_hash())); - let best_number = state.best_block_number.unwrap_or(block.number.to::()); - self.blockchain.storage.write().best_number = best_number; - - // Set the current best block hash; - let best_hash = - self.blockchain.storage.read().hash(best_number.into()).ok_or_else(|| { - BlockchainError::RpcError(RpcError::internal_error_with(format!( - "Best hash not found for best number {best_number}", - ))) - })?; - - self.blockchain.storage.write().best_hash = best_hash; + if let Some((number, hash)) = fork_num_and_hash { + // If loading state file on a fork, set best number to the fork block number. + // Ref: https://github.com/foundry-rs/foundry/pull/9215#issue-2618681838 + self.blockchain.storage.write().best_number = U64::from(number); + self.blockchain.storage.write().best_hash = hash; + } else { + let best_number = state.best_block_number.unwrap_or(block.number.to::()); + self.blockchain.storage.write().best_number = best_number; + + // Set the current best block hash; + let best_hash = + self.blockchain.storage.read().hash(best_number.into()).ok_or_else(|| { + BlockchainError::RpcError(RpcError::internal_error_with(format!( + "Best hash not found for best number {best_number}", + ))) + })?; + + self.blockchain.storage.write().best_hash = best_hash; + } } if !self.db.write().await.load_state(state.clone())? { diff --git a/crates/anvil/tests/it/state.rs b/crates/anvil/tests/it/state.rs index cb8f3b9ebbca9..f7736de2f4030 100644 --- a/crates/anvil/tests/it/state.rs +++ b/crates/anvil/tests/it/state.rs @@ -1,10 +1,13 @@ //! general eth api tests use crate::abi::Greeter; -use alloy_primitives::{Bytes, Uint, U256}; +use alloy_network::{ReceiptResponse, TransactionBuilder}; +use alloy_primitives::{address, utils::Unit, Bytes, Uint, U256}; use alloy_provider::Provider; -use alloy_rpc_types::BlockId; +use alloy_rpc_types::{BlockId, TransactionRequest}; +use alloy_serde::WithOtherFields; use anvil::{spawn, NodeConfig}; +use foundry_test_utils::rpc::next_http_rpc_endpoint; #[tokio::test(flavor = "multi_thread")] async fn can_load_state() { @@ -155,3 +158,90 @@ async fn can_preserve_historical_states_between_dump_and_load() { assert_eq!(greeting_after_change, "World!"); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_load_state() { + let (api, handle) = spawn( + NodeConfig::test() + .with_eth_rpc_url(Some(next_http_rpc_endpoint())) + .with_fork_block_number(Some(21070682u64)), + ) + .await; + + let bob = address!("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"); + let alice = address!("9276449EaC5b4f7Bc17cFC6700f7BeeB86F9bCd0"); + + let provider = handle.http_provider(); + + let init_nonce_bob = provider.get_transaction_count(bob).await.unwrap(); + + let init_balance_alice = provider.get_balance(alice).await.unwrap(); + + let value = Unit::ETHER.wei().saturating_mul(U256::from(1)); // 1 ether + let tx = TransactionRequest::default().with_to(alice).with_value(value).with_from(bob); + let tx = WithOtherFields::new(tx); + + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + assert!(receipt.status()); + + let serialized_state = api.serialized_state(false).await.unwrap(); + + let state_dump_block = api.block_number().unwrap(); + + let (api, handle) = spawn( + NodeConfig::test() + .with_eth_rpc_url(Some(next_http_rpc_endpoint())) + .with_fork_block_number(Some(21070686u64)) // Forked chain has moved forward + .with_init_state(Some(serialized_state)), + ) + .await; + + // Ensure the initial block number is the fork_block_number and not the state_dump_block + let block_number = api.block_number().unwrap(); + assert_eq!(block_number, U256::from(21070686u64)); + assert_ne!(block_number, state_dump_block); + + let provider = handle.http_provider(); + + let restart_nonce_bob = provider.get_transaction_count(bob).await.unwrap(); + + let restart_balance_alice = provider.get_balance(alice).await.unwrap(); + + assert_eq!(init_nonce_bob + 1, restart_nonce_bob); + + assert_eq!(init_balance_alice + value, restart_balance_alice); + + // Send another tx to check if the state is preserved + + let tx = TransactionRequest::default().with_to(alice).with_value(value).with_from(bob); + let tx = WithOtherFields::new(tx); + + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + assert!(receipt.status()); + + let nonce_bob = provider.get_transaction_count(bob).await.unwrap(); + + let balance_alice = provider.get_balance(alice).await.unwrap(); + + let tx = TransactionRequest::default() + .with_to(alice) + .with_value(value) + .with_from(bob) + .with_nonce(nonce_bob); + let tx = WithOtherFields::new(tx); + + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + assert!(receipt.status()); + + let latest_nonce_bob = provider.get_transaction_count(bob).await.unwrap(); + + let latest_balance_alice = provider.get_balance(alice).await.unwrap(); + + assert_eq!(nonce_bob + 1, latest_nonce_bob); + + assert_eq!(balance_alice + value, latest_balance_alice); +} From c90ea4d67f6a2492caa5d218d6c077388e3ef932 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:15:11 +0200 Subject: [PATCH 1626/1963] feat(`--gas-report`): add option to include tests (#9232) feat(`--gas-report`): add option to show gas for tests --- crates/config/src/lib.rs | 3 + crates/forge/bin/cmd/test/mod.rs | 1 + crates/forge/src/gas_report.rs | 7 ++- crates/forge/tests/cli/cmd.rs | 98 ++++++++++++++++++++++++++++++++ crates/forge/tests/cli/config.rs | 1 + 5 files changed, 108 insertions(+), 2 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 2a75f3b23c72a..916c77f9bd71a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -196,6 +196,8 @@ pub struct Config { pub gas_reports: Vec, /// list of contracts to ignore for gas reports pub gas_reports_ignore: Vec, + /// Whether to include gas reports for tests. + pub gas_reports_include_tests: bool, /// The Solc instance to use if any. /// /// This takes precedence over `auto_detect_solc`, if a version is set then this overrides @@ -2164,6 +2166,7 @@ impl Default for Config { evm_version: EvmVersion::Paris, gas_reports: vec!["*".to_string()], gas_reports_ignore: vec![], + gas_reports_include_tests: false, solc: None, vyper: Default::default(), auto_detect_solc: true, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index fa20e26d87889..4c973217f4d7a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -583,6 +583,7 @@ impl TestArgs { GasReport::new( config.gas_reports.clone(), config.gas_reports_ignore.clone(), + config.gas_reports_include_tests, if self.json { GasReportKind::JSON } else { GasReportKind::Markdown }, ) }); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index ac2d0db002622..ea8a49d373c23 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -36,6 +36,8 @@ pub struct GasReport { report_for: HashSet, /// Contracts to ignore when generating the report. ignore: HashSet, + /// Whether to include gas reports for tests. + include_tests: bool, /// All contracts that were analyzed grouped by their identifier /// ``test/Counter.t.sol:CounterTest pub contracts: BTreeMap, @@ -45,13 +47,14 @@ impl GasReport { pub fn new( report_for: impl IntoIterator, ignore: impl IntoIterator, + include_tests: bool, report_kind: GasReportKind, ) -> Self { let report_for = report_for.into_iter().collect::>(); let ignore = ignore.into_iter().collect::>(); let report_any = report_for.is_empty() || report_for.contains("*"); let report_type = report_kind; - Self { report_any, report_type, report_for, ignore, ..Default::default() } + Self { report_any, report_type, report_for, ignore, include_tests, ..Default::default() } } /// Whether the given contract should be reported. @@ -122,7 +125,7 @@ impl GasReport { } else if let Some(DecodedCallData { signature, .. }) = decoded().await.call_data { let name = signature.split('(').next().unwrap(); // ignore any test/setup functions - if !name.test_function_kind().is_known() { + if self.include_tests || !name.test_function_kind().is_known() { trace!(contract_name, signature, "adding gas info"); let gas_info = contract_info .functions diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index f34d0e2dec5d1..f9e8997bd99ce 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2717,3 +2717,101 @@ interface Counter { "#]], ); }); + +// checks that `clean` also works with the "out" value set in Config +forgetest_init!(gas_report_include_tests, |prj, cmd| { + prj.write_config(Config { + gas_reports_include_tests: true, + fuzz: FuzzConfig { runs: 1, ..Default::default() }, + ..Default::default() + }); + + cmd.args(["test", "--mt", "test_Increment", "--gas-report"]).assert_success().stdout_eq(str![ + [r#" +... +| src/Counter.sol:Counter contract | | | | | | +|----------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 106715 | 277 | | | | | +| Function Name | min | avg | median | max | # calls | +| increment | 43404 | 43404 | 43404 | 43404 | 1 | +| number | 283 | 283 | 283 | 283 | 1 | +| setNumber | 23582 | 23582 | 23582 | 23582 | 1 | + + +| test/Counter.t.sol:CounterTest contract | | | | | | +|-----------------------------------------|-----------------|--------|--------|--------|---------| +| Deployment Cost | Deployment Size | | | | | +| 965418 | 4661 | | | | | +| Function Name | min | avg | median | max | # calls | +| setUp | 168064 | 168064 | 168064 | 168064 | 1 | +| test_Increment | 52367 | 52367 | 52367 | 52367 | 1 | +... + +"#] + ]); + + cmd.forge_fuse() + .args(["test", "--mt", "test_Increment", "--gas-report", "--json"]) + .assert_success() + .stdout_eq( + str![[r#" +[ + { + "contract": "src/Counter.sol:Counter", + "deployment": { + "gas": 106715, + "size": 277 + }, + "functions": { + "increment()": { + "calls": 1, + "min": 43404, + "mean": 43404, + "median": 43404, + "max": 43404 + }, + "number()": { + "calls": 1, + "min": 283, + "mean": 283, + "median": 283, + "max": 283 + }, + "setNumber(uint256)": { + "calls": 1, + "min": 23582, + "mean": 23582, + "median": 23582, + "max": 23582 + } + } + }, + { + "contract": "test/Counter.t.sol:CounterTest", + "deployment": { + "gas": 965418, + "size": 4661 + }, + "functions": { + "setUp()": { + "calls": 1, + "min": 168064, + "mean": 168064, + "median": 168064, + "max": 168064 + }, + "test_Increment()": { + "calls": 1, + "min": 52367, + "mean": 52367, + "median": 52367, + "max": 52367 + } + } + } +] +"#]] + .is_json(), + ); +}); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index d7860381cb199..f6ec7c88eddf9 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -43,6 +43,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { evm_version: EvmVersion::Byzantium, gas_reports: vec!["Contract".to_string()], gas_reports_ignore: vec![], + gas_reports_include_tests: false, solc: Some(SolcReq::Local(PathBuf::from("custom-solc"))), auto_detect_solc: false, auto_detect_remappings: true, From 213d8174727023cf2881825e4b4f9417d726e1c8 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 31 Oct 2024 03:07:49 +0400 Subject: [PATCH 1627/1963] fix: remove steps after steps tracing cheatcodes are done (#9234) --- crates/cheatcodes/src/evm.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index acc349be15d31..723beb1cfc8ab 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -761,9 +761,6 @@ impl Cheatcode for stopAndReturnDebugTraceRecordingCall { return Err(Error::from("nothing recorded")) }; - // Revert the tracer config to the one before recording - tracer.update_config(|_config| record_info.original_tracer_config); - // Use the trace nodes to flatten the call trace let root = tracer.traces(); let steps = flatten_call_trace(0, root, record_info.start_node_idx); @@ -771,6 +768,16 @@ impl Cheatcode for stopAndReturnDebugTraceRecordingCall { let debug_steps: Vec = steps.iter().map(|&step| convert_call_trace_to_debug_step(step)).collect(); + // Free up memory by clearing the steps if they are not recorded outside of cheatcode usage. + if !record_info.original_tracer_config.record_steps { + tracer.traces_mut().nodes_mut().iter_mut().for_each(|node| { + node.trace.steps = Vec::new(); + }); + } + + // Revert the tracer config to the one before recording + tracer.update_config(|_config| record_info.original_tracer_config); + // Clean up the recording info ccx.state.record_debug_steps_info = None; From 9d74675bae8bfbd83428ff1343cbe2ae206c3383 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 31 Oct 2024 03:42:59 +0400 Subject: [PATCH 1628/1963] fix: rename flag as_int -> as-int (#9235) * fix: rename flag as_int -> as-int * Update crates/cast/bin/args.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/bin/args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 7552c3bd5f03e..988516c14065d 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -320,7 +320,7 @@ pub enum CastSubcommand { value: Option, /// Decode the RLP data as int - #[arg(id = "int", long = "as_int", alias = "int")] + #[arg(long, alias = "int")] as_int: bool, }, From 736a3300234a0921b9d8adde6c0c4dd14053ec8a Mon Sep 17 00:00:00 2001 From: Delweng Date: Thu, 31 Oct 2024 17:22:10 +0800 Subject: [PATCH 1629/1963] feat(cast): add string-decode to decode string (#9237) * feat(cast): add error-decode to decode error string Signed-off-by: jsvisa * feat(cast): error-decode -> string-decode Signed-off-by: jsvisa * add test case for string-decode Signed-off-by: jsvisa * Apply suggestions from code review --------- Signed-off-by: jsvisa Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/cast/bin/args.rs | 15 ++++++++++++++- crates/cast/bin/main.rs | 4 ++++ crates/cast/tests/cli/main.rs | 7 +++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 988516c14065d..03ca46d238268 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -523,7 +523,7 @@ pub enum CastSubcommand { /// /// Similar to `abi-decode --input`, but function selector MUST be prefixed in `calldata` /// string - #[command(visible_aliases = &["--calldata-decode","cdd"])] + #[command(visible_aliases = &["--calldata-decode", "cdd"])] CalldataDecode { /// The function signature in the format `()()`. sig: String, @@ -536,6 +536,19 @@ pub enum CastSubcommand { json: bool, }, + /// Decode ABI-encoded string. + /// + /// Similar to `calldata-decode --input`, but the function argument is a `string` + #[command(visible_aliases = &["--string-decode", "sd"])] + StringDecode { + /// The ABI-encoded string. + data: String, + + /// Print the decoded string as JSON. + #[arg(long, short, help_heading = "Display options")] + json: bool, + }, + /// Decode ABI-encoded input or output data. /// /// Defaults to decoding output data. To decode input data pass --input. diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index a7cd013c8b2fc..974b7eb861570 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -205,6 +205,10 @@ async fn main_args(args: CastArgs) -> Result<()> { CastSubcommand::CalldataEncode { sig, args } => { sh_println!("{}", SimpleCast::calldata_encode(sig, &args)?)?; } + CastSubcommand::StringDecode { data, json } => { + let tokens = SimpleCast::calldata_decode("Any(string)", &data, true)?; + print_tokens(&tokens, json) + } CastSubcommand::Interface(cmd) => cmd.run().await?, CastSubcommand::CreationCode(cmd) => cmd.run().await?, CastSubcommand::ConstructorArgs(cmd) => cmd.run().await?, diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 9ff8a6d49c6d3..8a8d512f83c22 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1417,6 +1417,13 @@ casttest!(parse_units, |_prj, cmd| { "#]]); }); +casttest!(string_decode, |_prj, cmd| { + cmd.args(["string-decode", "0x88c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000054753303235000000000000000000000000000000000000000000000000000000"]).assert_success().stdout_eq(str![[r#" +"GS025" + +"#]]); +}); + casttest!(format_units, |_prj, cmd| { cmd.args(["format-units", "1000000", "6"]).assert_success().stdout_eq(str![[r#" 1 From 17e0981a071fbd3b5a0a59affb4d638a28dfec89 Mon Sep 17 00:00:00 2001 From: Karrq Date: Thu, 31 Oct 2024 18:16:20 +0100 Subject: [PATCH 1630/1963] chore: avoid unnecessary `mut` (#9238) --- crates/script/src/simulate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 6eb11d7f91176..720b970af4082 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -112,10 +112,10 @@ impl PreSimulationState { // Executes all transactions from the different forks concurrently. let futs = transactions .into_iter() - .map(|mut transaction| async { + .map(|transaction| async { let mut runner = runners.get(&transaction.rpc).expect("invalid rpc url").write(); - let tx = transaction.tx_mut(); + let tx = transaction.tx(); let to = if let Some(TxKind::Call(to)) = tx.to() { Some(to) } else { None }; let result = runner .simulate( From 6b0c27ed4ccfdb5a4805e9f53d487cca51c5e116 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:05:10 +0200 Subject: [PATCH 1631/1963] fix(anvil): on anvil_mine jump to next timestamp before mine new block (#9241) * fix(anvil): on anvil_mine jump to next timestamp before mine new block * Fix unrelated clippy, simplify test --- crates/anvil/src/eth/api.rs | 4 ++-- crates/anvil/tests/it/anvil_api.rs | 18 ++++++++++++++++++ crates/cast/src/lib.rs | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 20ac92234f275..81990d75558b6 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1697,12 +1697,12 @@ impl EthApi { // mine all the blocks for _ in 0..blocks.to::() { - self.mine_one().await; - // If we have an interval, jump forwards in time to the "next" timestamp if let Some(interval) = interval { self.backend.time().increase_time(interval); } + + self.mine_one().await; } Ok(()) diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index da5372c7edb37..ce78d72ca59a6 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -1009,3 +1009,21 @@ async fn test_mine_blks_with_same_timestamp() { // timestamps should be equal assert_eq!(blks, vec![init_timestamp; 4]); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_mine_first_block_with_interval() { + let (api, _) = spawn(NodeConfig::test()).await; + + let init_block = api.block_by_number(0.into()).await.unwrap().unwrap(); + let init_timestamp = init_block.header.timestamp; + + // Mine 2 blocks with interval of 60. + let _ = api.anvil_mine(Some(U256::from(2)), Some(U256::from(60))).await; + + let first_block = api.block_by_number(1.into()).await.unwrap().unwrap(); + assert_eq!(first_block.header.timestamp, init_timestamp + 60); + + let second_block = api.block_by_number(2.into()).await.unwrap().unwrap(); + assert_eq!(second_block.header.timestamp, init_timestamp + 120); +} diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 97624c12ab646..bfa33c6e93f8e 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -128,7 +128,7 @@ where /// # Ok(()) /// # } /// ``` - pub async fn call<'a>( + pub async fn call( &self, req: &WithOtherFields, func: Option<&Function>, From 95114622e832ca93a95004c5846c85e5ba81ba62 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:09:11 +0000 Subject: [PATCH 1632/1963] fix(`deps`): update `alloy-chains` to fix Celo explorer API URL (#9242) chore(deps): weekly `cargo update` Locking 32 packages to latest compatible versions Updating alloy-chains v0.1.42 -> v0.1.45 Updating alloy-dyn-abi v0.8.9 -> v0.8.10 Updating alloy-json-abi v0.8.9 -> v0.8.10 Updating alloy-primitives v0.8.9 -> v0.8.10 Updating alloy-sol-macro v0.8.9 -> v0.8.10 Updating alloy-sol-macro-expander v0.8.9 -> v0.8.10 Updating alloy-sol-macro-input v0.8.9 -> v0.8.10 Updating alloy-sol-type-parser v0.8.9 -> v0.8.10 Updating alloy-sol-types v0.8.9 -> v0.8.10 Updating anyhow v1.0.91 -> v1.0.92 Updating aws-sdk-kms v1.48.0 -> v1.49.0 Updating aws-sdk-sso v1.47.0 -> v1.48.0 Updating aws-sdk-ssooidc v1.48.0 -> v1.49.0 Updating aws-sdk-sts v1.47.0 -> v1.48.0 Updating clap_complete v4.5.35 -> v4.5.36 Updating divan v0.1.14 -> v0.1.15 Updating divan-macros v0.1.14 -> v0.1.15 Updating hyper-util v0.1.9 -> v0.1.10 Updating libm v0.2.9 -> v0.2.11 Updating op-alloy-consensus v0.5.1 -> v0.5.2 Updating op-alloy-rpc-types v0.5.1 -> v0.5.2 Updating quinn-udp v0.5.5 -> v0.5.6 Updating reqwest v0.12.8 -> v0.12.9 Updating rustix v0.38.37 -> v0.38.38 Updating rustls v0.23.15 -> v0.23.16 Updating serde v1.0.213 -> v1.0.214 Updating serde_derive v1.0.213 -> v1.0.214 Updating snapbox v0.6.18 -> v0.6.19 Updating syn v2.0.85 -> v2.0.86 Updating syn-solidity v0.8.9 -> v0.8.10 Updating thiserror v1.0.65 -> v1.0.66 Updating thiserror-impl v1.0.65 -> v1.0.66 note: pass `--verbose` to see 14 unchanged dependencies behind latest Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- Cargo.lock | 261 +++++++++++++++++++++++++++-------------------------- 1 file changed, 131 insertions(+), 130 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de6f11ea9b219..c4a78fba0fd75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.42" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca4a1469a3e572e9ba362920ff145f5d0a00a3e71a64ddcb4a3659cf64c76a7" +checksum = "4feb7c662fd0be3d0c926a456be4ac44e9cf8e05cbd91df6db7f7140b861016a" dependencies = [ "alloy-primitives", "num_enum", @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5647fce5a168f9630f935bf7821c4207b1755184edaeba783cb4e11d35058484" +checksum = "f5228b189b18b85761340dc9eaac0141148a8503657b36f9bc3a869413d987ca" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b5671117c38b1c2306891f97ad3828d85487087f54ebe2c7591a055ea5bcea7" +checksum = "31a0f0d51db8a1a30a4d98a9f90e090a94c8f44cb4d9eafc7e03aa6d00aae984" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -261,9 +261,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71738eb20c42c5fb149571e76536a0f309d142f3957c28791662b96baf77a3d" +checksum = "8edae627382349b56cd6a7a2106f4fd69b243a9233e560c55c2e03cabb7e1d3c" dependencies = [ "alloy-rlp", "arbitrary", @@ -371,7 +371,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -611,23 +611,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0900b83f4ee1f45c640ceee596afbc118051921b9438fdb5a3175c1a7e05f8b" +checksum = "841eabaa4710f719fddbc24c95d386eae313f07e6da4babc25830ee37945be0c" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41b1e78dde06b5e12e6702fa8c1d30621bf07728ba75b801fb801c9c6a0ba10" +checksum = "6672337f19d837b9f7073c45853aeb528ed9f7dd6a4154ce683e9e5cb7794014" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -637,16 +637,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91dc311a561a306664393407b88d3e53ae58581624128afd8a15faa5de3627dc" +checksum = "0dff37dd20bfb118b777c96eda83b2067f4226d2644c5cfa00187b3bc01770ba" dependencies = [ "alloy-json-abi", "const-hex", @@ -655,15 +655,15 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.85", + "syn 2.0.86", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d1fbee9e698f3ba176b6e7a145f4aefe6d2b746b611e8bb246fe11a0e9f6c4" +checksum = "5b853d42292dbb159671a3edae3b2750277ff130f32b726fe07dc2b17aa6f2b5" dependencies = [ "serde", "winnow", @@ -671,9 +671,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086f41bc6ebcd8cb15f38ba20e47be38dd03692149681ce8061c35d960dbf850" +checksum = "aa828bb1b9a6dc52208fbb18084fb9ce2c30facc2bfda6a5d922349b4990354f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -748,7 +748,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.15", + "rustls 0.23.16", "serde_json", "tokio", "tokio-tungstenite", @@ -972,9 +972,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" [[package]] name = "arbitrary" @@ -1164,7 +1164,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -1186,7 +1186,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -1197,7 +1197,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -1250,7 +1250,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -1328,9 +1328,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.48.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2afbd208dabc6785946d4ef2444eb1f54fe0aaf0f62f2a4f9a9e9c303aeff0be" +checksum = "1f4c89f1d2e0df99ccd21f98598c1e587ad78bd87ae22a74aba392b5566bb038" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1350,9 +1350,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.47.0" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8776850becacbd3a82a4737a9375ddb5c6832a51379f24443a98e61513f852c" +checksum = "ded855583fa1d22e88fe39fd6062b062376e50a8211989e07cf5e38d52eb3453" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1372,9 +1372,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.48.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0007b5b8004547133319b6c4e87193eee2a0bcb3e4c18c75d09febe9dab7b383" +checksum = "9177ea1192e6601ae16c7273385690d88a7ed386a00b74a6bc894d12103cd933" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1394,9 +1394,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.47.0" +version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fffaa356e7f1c725908b75136d53207fa714e348f365671df14e95a60530ad3" +checksum = "823ef553cf36713c97453e2ddff1eb8f62be7f4523544e2a5db64caf80100f0a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1782,7 +1782,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2137,9 +2137,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.35" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07a13ab5b8cb13dbe35e68b83f6c12f9293b2f601797b71bc9f23befdb329feb" +checksum = "86bc73de94bc81e52f3bebec71bc4463e9748f7a59166663e32044669577b0e2" dependencies = [ "clap", ] @@ -2163,7 +2163,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2581,7 +2581,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2592,7 +2592,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2665,7 +2665,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2686,7 +2686,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2696,7 +2696,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2717,7 +2717,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", "unicode-xid", ] @@ -2825,14 +2825,14 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] name = "divan" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d567df2c9c2870a43f3f2bd65aaeb18dbce1c18f217c3e564b4fbaeb3ee56c" +checksum = "6e05d17bd4ff1c1e7998ed4623d2efd91f72f1e24141ac33aac9377974270e1f" dependencies = [ "cfg-if", "clap", @@ -2844,13 +2844,13 @@ dependencies = [ [[package]] name = "divan-macros" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" +checksum = "1b4464d46ce68bfc7cb76389248c7c254def7baca8bece0693b02b83842c4c88" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -2977,7 +2977,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -3112,7 +3112,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.85", + "syn 2.0.86", "toml 0.8.19", "walkdir", ] @@ -3140,7 +3140,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.85", + "syn 2.0.86", "tempfile", "thiserror", "tiny-keccak", @@ -3530,7 +3530,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -4103,7 +4103,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -4262,7 +4262,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -4791,7 +4791,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -4955,7 +4955,7 @@ dependencies = [ "http 1.1.0", "hyper 1.5.0", "hyper-util", - "rustls 0.23.15", + "rustls 0.23.16", "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", @@ -4995,9 +4995,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-channel", @@ -5224,7 +5224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -5477,9 +5477,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bda4c6077b0b08da2c48b172195795498381a7c8988c9e6212a6c55c5b9bd70" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libredox" @@ -5688,7 +5688,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -5779,7 +5779,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6038,7 +6038,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6086,9 +6086,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7c98055fd048073738df0cc6d6537e992a0d8828f39d99a469e870db126dbd" +checksum = "f26c3b35b7b3e36d15e0563eebffe13c1d9ca16b7aaffcb6a64354633547e16b" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6102,9 +6102,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919e9b69212d61f3c8932bfb717c7ad458ea3fc52072b3433d99994f8223d555" +checksum = "94bae9bf91b620e1e2c2291562e5998bc1247bd8ada011773e1997b31a95de99" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6177,7 +6177,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6340,7 +6340,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6399,7 +6399,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6483,7 +6483,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6541,7 +6541,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6632,7 +6632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6710,7 +6710,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6730,7 +6730,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", "version_check", "yansi", ] @@ -6794,7 +6794,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6817,7 +6817,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -6926,7 +6926,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.15", + "rustls 0.23.16", "socket2", "thiserror", "tokio", @@ -6943,7 +6943,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.15", + "rustls 0.23.16", "slab", "thiserror", "tinyvec", @@ -6952,10 +6952,11 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" +checksum = "e346e016eacfff12233c243718197ca12f148c84e1e84268a896699b41c71780" dependencies = [ + "cfg_aliases 0.2.1", "libc", "once_cell", "socket2", @@ -7147,9 +7148,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "async-compression", "base64 0.22.1", @@ -7174,7 +7175,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.15", + "rustls 0.23.16", "rustls-native-certs 0.8.0", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7448,9 +7449,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ "bitflags 2.6.0", "errno", @@ -7473,9 +7474,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.15" +version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "log", "once_cell", @@ -7651,7 +7652,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -7693,7 +7694,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -7851,22 +7852,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -7877,7 +7878,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -7921,7 +7922,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -7967,7 +7968,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -8146,9 +8147,9 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "snapbox" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba434818a8a9b1b106404288d6bd75a94348aae8fc9a518b211b609a36a54bc" +checksum = "881f1849454828a68363dd288b7a0a071e55e2a4356d2c38b567db18a9be0d9f" dependencies = [ "anstream", "anstyle", @@ -8329,7 +8330,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -8397,9 +8398,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "e89275301d38033efb81a6e60e3497e734dfcc62571f2854bf4b16690398824c" dependencies = [ "proc-macro2", "quote", @@ -8408,14 +8409,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5e0c2ea8db64b2898b62ea2fbd60204ca95e0b2c6bdf53ff768bbe916fbe4d" +checksum = "16320d4a2021ba1a32470b3759676114a918885e9800e68ad60f2c67969fba62" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -8516,22 +8517,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -8656,7 +8657,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -8685,7 +8686,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.15", + "rustls 0.23.16", "rustls-pki-types", "tokio", ] @@ -8722,7 +8723,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.15", + "rustls 0.23.16", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -8931,7 +8932,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -9047,7 +9048,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.15", + "rustls 0.23.16", "rustls-pki-types", "sha1", "thiserror", @@ -9334,7 +9335,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", "wasm-bindgen-shared", ] @@ -9368,7 +9369,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9599,7 +9600,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -9610,7 +9611,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -9621,7 +9622,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -9632,7 +9633,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -9898,7 +9899,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] @@ -9918,7 +9919,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.86", ] [[package]] From 7587eb53a996ff289de2c8fdb4a49c93e90d5f9b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:11:14 +0100 Subject: [PATCH 1633/1963] fix: reset shell colors based on the input style (#9243) --- crates/common/src/io/shell.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs index a132b343d11ec..e13f1399969d0 100644 --- a/crates/common/src/io/shell.rs +++ b/crates/common/src/io/shell.rs @@ -411,22 +411,16 @@ impl ShellOut { /// Write a styled fragment fn write_stdout(&mut self, fragment: impl fmt::Display, style: &Style) -> Result<()> { - let style = style.render(); - let reset = anstyle::Reset.render(); - let mut buffer = Vec::new(); - write!(buffer, "{style}{fragment}{reset}")?; + write!(buffer, "{style}{fragment}{style:#}")?; self.stdout().write_all(&buffer)?; Ok(()) } /// Write a styled fragment fn write_stderr(&mut self, fragment: impl fmt::Display, style: &Style) -> Result<()> { - let style = style.render(); - let reset = anstyle::Reset.render(); - let mut buffer = Vec::new(); - write!(buffer, "{style}{fragment}{reset}")?; + write!(buffer, "{style}{fragment}{style:#}")?; self.stderr().write_all(&buffer)?; Ok(()) } @@ -456,19 +450,17 @@ impl ShellOut { style: &Style, justified: bool, ) -> Result> { - let style = style.render(); - let bold = (anstyle::Style::new() | anstyle::Effects::BOLD).render(); - let reset = anstyle::Reset.render(); + let bold = anstyle::Style::new().bold(); let mut buffer = Vec::new(); if justified { - write!(&mut buffer, "{style}{status:>12}{reset}")?; + write!(buffer, "{style}{status:>12}{style:#}")?; } else { - write!(&mut buffer, "{style}{status}{reset}{bold}:{reset}")?; + write!(buffer, "{style}{status}{style:#}{bold}:{bold:#}")?; } match message { Some(message) => { - writeln!(&mut buffer, " {message}")?; + writeln!(buffer, " {message}")?; } None => write!(buffer, " ")?, } From ea11082555e15f899a8bb9102890f3c2f7713cb8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:30:37 +0100 Subject: [PATCH 1634/1963] fix: avoid deadlock in nested shell calls (#9245) * fix: avoid deadlock in nested shell calls * cleanup --- crates/common/src/io/macros.rs | 19 ++++++++++++++++--- crates/common/src/io/shell.rs | 11 +++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/crates/common/src/io/macros.rs b/crates/common/src/io/macros.rs index fe1e72dfecc98..10e7cca4a2e3a 100644 --- a/crates/common/src/io/macros.rs +++ b/crates/common/src/io/macros.rs @@ -132,15 +132,23 @@ macro_rules! sh_eprintln { #[macro_export] macro_rules! __sh_dispatch { ($f:ident $fmt:literal $($args:tt)*) => { - $crate::Shell::$f(&mut *$crate::Shell::get(), ::core::format_args!($fmt $($args)*)) + $crate::__sh_dispatch!(@impl $f &mut *$crate::Shell::get(), $fmt $($args)*) }; ($f:ident $shell:expr, $($args:tt)*) => { - $crate::Shell::$f($shell, ::core::format_args!($($args)*)) + $crate::__sh_dispatch!(@impl $f $shell, $($args)*) }; ($f:ident $($args:tt)*) => { - $crate::Shell::$f(&mut *$crate::Shell::get(), ::core::format_args!($($args)*)) + $crate::__sh_dispatch!(@impl $f &mut *$crate::Shell::get(), $($args)*) + }; + + // Ensure that the global shell lock is held for as little time as possible. + // Also avoids deadlocks in case of nested calls. + (@impl $f:ident $shell:expr, $($args:tt)*) => { + match ::core::format_args!($($args)*) { + fmt => $crate::Shell::$f($shell, fmt), + } }; } @@ -168,6 +176,11 @@ mod tests { sh_eprintln!("eprintln")?; sh_eprintln!("eprintln {}", "arg")?; + sh_println!("{:?}", { + sh_println!("hi")?; + "nested" + })?; + Ok(()) } diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs index e13f1399969d0..ee217fa728e8e 100644 --- a/crates/common/src/io/shell.rs +++ b/crates/common/src/io/shell.rs @@ -186,9 +186,9 @@ impl Shell { } } - /// Get a static reference to the global shell. + /// Acquire a lock to the global shell. /// - /// Initializes the global shell with the default values if it has not been set yet. + /// Initializes it with the default values if it has not been set yet. pub fn get() -> impl DerefMut + 'static { GLOBAL_SHELL.get_or_init(Default::default).lock().unwrap_or_else(PoisonError::into_inner) } @@ -200,10 +200,9 @@ impl Shell { /// Panics if the global shell has already been set. #[track_caller] pub fn set(self) { - if GLOBAL_SHELL.get().is_some() { - panic!("attempted to set global shell twice"); - } - GLOBAL_SHELL.get_or_init(|| Mutex::new(self)); + GLOBAL_SHELL + .set(Mutex::new(self)) + .unwrap_or_else(|_| panic!("attempted to set global shell twice")) } /// Sets whether the next print should clear the current line and returns the previous value. From 56639cd1772dac628728d2441887e5ccc287ebe9 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Fri, 1 Nov 2024 18:29:36 +0100 Subject: [PATCH 1635/1963] anvil: Correctly set HF fields for Genesis block (#9248) Some fields were missing for some HF, leading to an invalid Genesis block hash. --- crates/anvil/src/eth/backend/mem/mod.rs | 4 +++- crates/anvil/src/eth/backend/mem/storage.rs | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 65ab8c32952b8..c7ff9422a6e4a 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -230,8 +230,10 @@ impl Backend { trace!(target: "backend", "using forked blockchain at {}", fork.block_number()); Blockchain::forked(fork.block_number(), fork.block_hash(), fork.total_difficulty()) } else { + let env = env.read(); Blockchain::new( - &env.read(), + &env, + env.handler_cfg.spec_id, fees.is_eip1559().then(|| fees.base_fee()), genesis.timestamp, ) diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 2105666a4e91d..d5a72fccbbb63 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -10,6 +10,8 @@ use crate::eth::{ error::BlockchainError, pool::transactions::PoolTransaction, }; +use alloy_consensus::constants::EMPTY_WITHDRAWALS; +use alloy_eips::eip7685::EMPTY_REQUESTS_HASH; use alloy_primitives::{ map::{B256HashMap, HashMap}, Bytes, B256, U256, U64, @@ -38,6 +40,7 @@ use foundry_evm::{ }, }; use parking_lot::RwLock; +use revm::primitives::SpecId; use std::{collections::VecDeque, fmt, sync::Arc, time::Duration}; // use yansi::Paint; @@ -262,7 +265,11 @@ pub struct BlockchainStorage { impl BlockchainStorage { /// Creates a new storage with a genesis block - pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { + pub fn new(env: &Env, spec_id: SpecId, base_fee: Option, timestamp: u64) -> Self { + let is_shanghai = spec_id >= SpecId::SHANGHAI; + let is_cancun = spec_id >= SpecId::CANCUN; + let is_prague = spec_id >= SpecId::PRAGUE; + // create a dummy genesis block let partial_header = PartialHeader { timestamp, @@ -272,6 +279,10 @@ impl BlockchainStorage { difficulty: env.block.difficulty, blob_gas_used: env.block.blob_excess_gas_and_price.as_ref().map(|_| 0), excess_blob_gas: env.block.get_blob_excess_gas(), + + parent_beacon_block_root: is_cancun.then_some(Default::default()), + withdrawals_root: is_shanghai.then_some(EMPTY_WITHDRAWALS), + requests_hash: is_prague.then_some(EMPTY_REQUESTS_HASH), ..Default::default() }; let block = Block::new::(partial_header, vec![]); @@ -423,8 +434,12 @@ pub struct Blockchain { impl Blockchain { /// Creates a new storage with a genesis block - pub fn new(env: &Env, base_fee: Option, timestamp: u64) -> Self { - Self { storage: Arc::new(RwLock::new(BlockchainStorage::new(env, base_fee, timestamp))) } + pub fn new(env: &Env, spec_id: SpecId, base_fee: Option, timestamp: u64) -> Self { + Self { + storage: Arc::new(RwLock::new(BlockchainStorage::new( + env, spec_id, base_fee, timestamp, + ))), + } } pub fn forked(block_number: u64, block_hash: B256, total_difficulty: U256) -> Self { From 97be9b9a2e128633b17589cd58bfde4b4d544e23 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 2 Nov 2024 10:33:19 +0100 Subject: [PATCH 1636/1963] perf: cap default poll interval (#9250) --- crates/common/src/provider/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index fe7fd4ccc9d91..4fb9e29aec0ce 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -270,6 +270,9 @@ impl ProviderBuilder { client.set_poll_interval( chain .average_blocktime_hint() + // we cap the poll interval because if not provided, chain would default to + // mainnet + .map(|hint| hint.min(DEFAULT_UNKNOWN_CHAIN_BLOCK_TIME)) .unwrap_or(DEFAULT_UNKNOWN_CHAIN_BLOCK_TIME) .mul_f32(POLL_INTERVAL_BLOCK_TIME_SCALE_FACTOR), ); From d402afd2db0e4546d33a7f94d3a226cce6ff2c76 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 3 Nov 2024 00:45:57 +0400 Subject: [PATCH 1637/1963] fix: better error handling when waiting for receipt (#9253) * fix: better error handling when waiting for receipt * fmt --- crates/script/src/receipts.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index 02ee75fa672ff..af80734c59fe3 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -1,6 +1,6 @@ use alloy_chains::Chain; use alloy_primitives::{utils::format_units, TxHash, U256}; -use alloy_provider::{PendingTransactionBuilder, Provider}; +use alloy_provider::{PendingTransactionBuilder, PendingTransactionError, Provider, WatchTxError}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::Result; use foundry_common::provider::RetryProvider; @@ -40,12 +40,16 @@ pub async fn check_tx_status( } loop { - if let Ok(receipt) = PendingTransactionBuilder::new(provider.clone(), hash) + match PendingTransactionBuilder::new(provider.clone(), hash) .with_timeout(Some(Duration::from_secs(timeout))) .get_receipt() .await { - return Ok(receipt.into()) + Ok(receipt) => return Ok(receipt.into()), + // do nothing on timeout, we will check whether tx is dropped below + Err(PendingTransactionError::TxWatcher(WatchTxError::Timeout)) => {} + // treat other errors as fatal + Err(e) => return Err(e.into()), } if provider.get_transaction_by_hash(hash).await?.is_some() { From 8660e5b941fe7f4d67e246cfd3dafea330fb53b1 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 3 Nov 2024 01:49:32 +0400 Subject: [PATCH 1638/1963] fix: use `Debug` when formatting errors (#9251) * fix: use Debug when formatting errors * sh_err * rm newline in handler --- crates/anvil/src/anvil.rs | 2 +- crates/cast/bin/main.rs | 2 +- crates/chisel/bin/main.rs | 2 +- crates/cli/src/handler.rs | 1 - crates/forge/bin/main.rs | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 9d4a0cf7ba200..5e2a42f59ef06 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -39,7 +39,7 @@ pub enum AnvilSubcommand { fn main() { if let Err(err) = run() { - let _ = foundry_common::Shell::get().error(&err); + let _ = foundry_common::sh_err!("{err:?}"); std::process::exit(1); } } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 974b7eb861570..f7d66ef9d0d07 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -39,7 +39,7 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; fn main() { if let Err(err) = run() { - let _ = foundry_common::Shell::get().error(&err); + let _ = foundry_common::sh_err!("{err:?}"); std::process::exit(1); } } diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 17697688bb3e5..dca99d4a594d4 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -108,7 +108,7 @@ pub enum ChiselSubcommand { fn main() { if let Err(err) = run() { - let _ = foundry_common::Shell::get().error(&err); + let _ = foundry_common::sh_err!("{err:?}"); std::process::exit(1); } } diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index 4f69c2ca445c9..b2fbb49d4ea86 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -15,7 +15,6 @@ impl EyreHandler for Handler { if f.alternate() { return core::fmt::Debug::fmt(error, f) } - writeln!(f)?; write!(f, "{}", error.red())?; if let Some(cause) = error.source() { diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index a78218e94e0ab..c713a703ee7bd 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -22,7 +22,7 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; fn main() { if let Err(err) = run() { - let _ = foundry_common::Shell::get().error(&err); + let _ = foundry_common::sh_err!("{err:?}"); std::process::exit(1); } } From d2ed15d517a3af56fced592aa4a21df0293710c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 3 Nov 2024 03:47:27 +0000 Subject: [PATCH 1639/1963] chore(deps): weekly `cargo update` (#9254) Locking 5 packages to latest compatible versions Updating alloy-chains v0.1.45 -> v0.1.46 Updating anstyle v1.0.9 -> v1.0.10 Updating cc v1.1.31 -> v1.1.34 Updating jiff v0.1.13 -> v0.1.14 Updating syn v2.0.86 -> v2.0.87 note: pass `--verbose` to see 14 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 136 ++++++++++++++++++++++++++--------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4a78fba0fd75..73a15ac8ce2c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4feb7c662fd0be3d0c926a456be4ac44e9cf8e05cbd91df6db7f7140b861016a" +checksum = "836cf02383d9ebb35502d379bcd1ae803155094077eaab9c29131d888cd5fa3e" dependencies = [ "alloy-primitives", "num_enum", @@ -371,7 +371,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -620,7 +620,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -637,7 +637,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", "syn-solidity", "tiny-keccak", ] @@ -655,7 +655,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.86", + "syn 2.0.87", "syn-solidity", ] @@ -816,9 +816,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -1164,7 +1164,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -1186,7 +1186,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -1197,7 +1197,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -1250,7 +1250,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -1782,7 +1782,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -1998,9 +1998,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" dependencies = [ "shlex", ] @@ -2163,7 +2163,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2581,7 +2581,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2592,7 +2592,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2665,7 +2665,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2686,7 +2686,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2696,7 +2696,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2717,7 +2717,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", "unicode-xid", ] @@ -2825,7 +2825,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2850,7 +2850,7 @@ checksum = "1b4464d46ce68bfc7cb76389248c7c254def7baca8bece0693b02b83842c4c88" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -2977,7 +2977,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -3112,7 +3112,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.86", + "syn 2.0.87", "toml 0.8.19", "walkdir", ] @@ -3140,7 +3140,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.86", + "syn 2.0.87", "tempfile", "thiserror", "tiny-keccak", @@ -3530,7 +3530,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -4103,7 +4103,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -4262,7 +4262,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -4791,7 +4791,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -5224,7 +5224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" dependencies = [ "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -5309,9 +5309,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jiff" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a45489186a6123c128fdf6016183fcfab7113e1820eb813127e036e287233fb" +checksum = "b9d9d414fc817d3e3d62b2598616733f76c4cc74fbac96069674739b881295c8" dependencies = [ "jiff-tzdb-platform", "windows-sys 0.59.0", @@ -5688,7 +5688,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -5779,7 +5779,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6038,7 +6038,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6177,7 +6177,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6340,7 +6340,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6399,7 +6399,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6483,7 +6483,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6541,7 +6541,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6632,7 +6632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6710,7 +6710,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6730,7 +6730,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", "version_check", "yansi", ] @@ -6794,7 +6794,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -6817,7 +6817,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -7652,7 +7652,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -7694,7 +7694,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -7867,7 +7867,7 @@ checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -7878,7 +7878,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -7922,7 +7922,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -7968,7 +7968,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -8330,7 +8330,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -8398,9 +8398,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.86" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89275301d38033efb81a6e60e3497e734dfcc62571f2854bf4b16690398824c" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -8416,7 +8416,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -8532,7 +8532,7 @@ checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -8657,7 +8657,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -8932,7 +8932,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -9335,7 +9335,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -9369,7 +9369,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9600,7 +9600,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -9611,7 +9611,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -9622,7 +9622,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -9633,7 +9633,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -9899,7 +9899,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] @@ -9919,7 +9919,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.86", + "syn 2.0.87", ] [[package]] From 32f8e798298443565c789883206bd024b46c4712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Mon, 4 Nov 2024 10:37:26 +0100 Subject: [PATCH 1640/1963] fix(`forge doc`): display custom natspec tag (#9257) fix(forge doc): display custom natspec tag --- crates/doc/src/parser/comment.rs | 4 ++-- crates/doc/src/writer/as_doc.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/doc/src/parser/comment.rs b/crates/doc/src/parser/comment.rs index 4954cd7cdee18..bf2b0ad7b4f0d 100644 --- a/crates/doc/src/parser/comment.rs +++ b/crates/doc/src/parser/comment.rs @@ -1,10 +1,10 @@ use alloy_primitives::map::HashMap; -use derive_more::{Deref, DerefMut}; +use derive_more::{derive::Display, Deref, DerefMut}; use solang_parser::doccomment::DocCommentTag; /// The natspec comment tag explaining the purpose of the comment. /// See: . -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Display, PartialEq, Eq)] pub enum CommentTag { /// A title that should describe the contract/interface Title, diff --git a/crates/doc/src/writer/as_doc.rs b/crates/doc/src/writer/as_doc.rs index d68f7a8e502c6..56a0a4026c504 100644 --- a/crates/doc/src/writer/as_doc.rs +++ b/crates/doc/src/writer/as_doc.rs @@ -64,8 +64,9 @@ impl AsDoc for CommentsRef<'_> { writer.write_bold(&format!("Note{}:", if customs.len() == 1 { "" } else { "s" }))?; for c in customs.iter() { writer.writeln_raw(format!( - "{}{}", + "{}{}: {}", if customs.len() == 1 { "" } else { "- " }, + &c.tag, &c.value ))?; writer.writeln()?; From 931374b30f9ba0ee63f153c3d154859426e207ac Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 4 Nov 2024 14:08:32 +0200 Subject: [PATCH 1641/1963] chore: do not print anvil launch info if silent (#9259) chore: do not print anvil port if silent --- crates/anvil/src/lib.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 123faa1e9a5a6..4fc0621c84fc6 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -295,17 +295,19 @@ impl NodeHandle { /// Prints the launch info. pub(crate) fn print(&self, fork: Option<&ClientFork>) { self.config.print(fork); - if let Some(ipc_path) = self.ipc_path() { - let _ = sh_println!("IPC path: {ipc_path}"); + if !self.config.silent { + if let Some(ipc_path) = self.ipc_path() { + let _ = sh_println!("IPC path: {ipc_path}"); + } + let _ = sh_println!( + "Listening on {}", + self.addresses + .iter() + .map(|addr| { addr.to_string() }) + .collect::>() + .join(", ") + ); } - let _ = sh_println!( - "Listening on {}", - self.addresses - .iter() - .map(|addr| { addr.to_string() }) - .collect::>() - .join(", ") - ); } /// The address of the launched server. From e2a6282a52ebe62775ae4dda76d97898da4a1228 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:11:05 +0100 Subject: [PATCH 1642/1963] feat: add global `--json` flag (#9244) * add global json --flag * finish port to shell::is_json * fix test * update message * very strange stalling bug, fixed by assignment? * remove jobs -j shorthand clashing with global json flag * fix test after -j change * fix doctests * temporarily disable junit conflict, revert -j as --json shorthand * tag --color, --quiet as conflicting with --json * update tests to be aware of global args to avoid `Argument or group quiet specified in conflicts_with* for junit does not exist` error * fix missed test * make sure tests throw on non-matching command * use --format-json in command to show alias works --- crates/cast/bin/args.rs | 28 ------------ crates/cast/bin/cmd/access_list.rs | 8 +--- crates/cast/bin/cmd/call.rs | 7 +-- crates/cast/bin/cmd/interface.rs | 10 ++--- crates/cast/bin/cmd/logs.rs | 20 ++------- crates/cast/bin/cmd/send.rs | 15 ++----- crates/cast/bin/cmd/wallet/mod.rs | 26 +++++------- crates/cast/bin/main.rs | 30 ++++++------- crates/cast/src/lib.rs | 54 +++++++++--------------- crates/cast/tests/cli/main.rs | 3 ++ crates/cli/src/opts/shell.rs | 20 ++++++++- crates/common/src/io/shell.rs | 43 ++++++++++++++++++- crates/forge/bin/cmd/build.rs | 15 +++---- crates/forge/bin/cmd/create.rs | 9 ++-- crates/forge/bin/cmd/test/mod.rs | 68 +++++++++++++++++++----------- crates/forge/bin/main.rs | 3 +- crates/forge/tests/cli/build.rs | 4 +- crates/forge/tests/cli/cmd.rs | 3 ++ crates/script/src/lib.rs | 8 +--- crates/verify/src/bytecode.rs | 19 +++------ crates/verify/src/utils.rs | 7 ++- 21 files changed, 192 insertions(+), 208 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 03ca46d238268..a16436dd2ea7f 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -369,10 +369,6 @@ pub enum CastSubcommand { #[arg(long, env = "CAST_FULL_BLOCK")] full: bool, - /// Print the block as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, - #[command(flatten)] rpc: RpcOpts, }, @@ -464,10 +460,6 @@ pub enum CastSubcommand { #[arg(long, conflicts_with = "field")] raw: bool, - /// Print as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, - #[command(flatten)] rpc: RpcOpts, }, @@ -489,10 +481,6 @@ pub enum CastSubcommand { #[arg(id = "async", long = "async", env = "CAST_ASYNC", alias = "cast-async")] cast_async: bool, - /// Print as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, - #[command(flatten)] rpc: RpcOpts, }, @@ -530,10 +518,6 @@ pub enum CastSubcommand { /// The ABI-encoded calldata. calldata: String, - - /// Print the decoded calldata as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, }, /// Decode ABI-encoded string. @@ -543,10 +527,6 @@ pub enum CastSubcommand { StringDecode { /// The ABI-encoded string. data: String, - - /// Print the decoded string as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, }, /// Decode ABI-encoded input or output data. @@ -565,10 +545,6 @@ pub enum CastSubcommand { /// Whether to decode the input or output data. #[arg(long, short, help_heading = "Decode input data instead of output data")] input: bool, - - /// Print the decoded calldata as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, }, /// ABI encode the given function argument, excluding the selector. @@ -655,10 +631,6 @@ pub enum CastSubcommand { FourByteDecode { /// The ABI-encoded calldata. calldata: Option, - - /// Print the decoded calldata as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, }, /// Get the event signature for a given topic 0 from https://openchain.xyz. diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index 3d60b52903a34..c283f60c40b0b 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -35,10 +35,6 @@ pub struct AccessListArgs { #[arg(long, short = 'B')] block: Option, - /// Print the access list as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, - #[command(flatten)] tx: TransactionOpts, @@ -48,7 +44,7 @@ pub struct AccessListArgs { impl AccessListArgs { pub async fn run(self) -> Result<()> { - let Self { to, sig, args, tx, eth, block, json: to_json } = self; + let Self { to, sig, args, tx, eth, block } = self; let config = Config::from(ð); let provider = utils::get_provider(&config)?; @@ -65,7 +61,7 @@ impl AccessListArgs { let cast = Cast::new(&provider); - let access_list: String = cast.access_list(&tx, block, to_json).await?; + let access_list: String = cast.access_list(&tx, block).await?; sh_println!("{access_list}")?; diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 355d18ee6ad7d..aefc5f1c02f58 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -69,10 +69,6 @@ pub struct CallArgs { #[arg(long, short)] block: Option, - /// Print the decoded output as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, - /// Enable Alphanet features. #[arg(long, alias = "odyssey")] pub alphanet: bool, @@ -131,7 +127,6 @@ impl CallArgs { decode_internal, labels, data, - json, .. } = self; @@ -205,7 +200,7 @@ impl CallArgs { return Ok(()); } - sh_println!("{}", Cast::new(provider).call(&tx, func.as_ref(), block, json).await?)?; + sh_println!("{}", Cast::new(provider).call(&tx, func.as_ref(), block).await?)?; Ok(()) } diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 45df4983e4f09..659ce6ccaa4fa 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -4,7 +4,7 @@ use clap::Parser; use eyre::{Context, Result}; use foundry_block_explorers::Client; use foundry_cli::opts::EtherscanOpts; -use foundry_common::{compile::ProjectCompiler, fs}; +use foundry_common::{compile::ProjectCompiler, fs, shell}; use foundry_compilers::{info::ContractInfo, utils::canonicalize}; use foundry_config::{load_config_with_root, try_find_project_root, Config}; use itertools::Itertools; @@ -44,17 +44,13 @@ pub struct InterfaceArgs { )] output: Option, - /// If specified, the interface will be output as JSON rather than Solidity. - #[arg(long, short)] - json: bool, - #[command(flatten)] etherscan: EtherscanOpts, } impl InterfaceArgs { pub async fn run(self) -> Result<()> { - let Self { contract, name, pragma, output: output_location, etherscan, json } = self; + let Self { contract, name, pragma, output: output_location, etherscan } = self; // Determine if the target contract is an ABI file, a local contract or an Ethereum address. let abis = if Path::new(&contract).is_file() && @@ -75,7 +71,7 @@ impl InterfaceArgs { let interfaces = get_interfaces(abis)?; // Print result or write to file. - let res = if json { + let res = if shell::is_json() { // Format as JSON. interfaces.iter().map(|iface| &iface.json_abi).format("\n").to_string() } else { diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index b38281d51e341..154b5c9d21354 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -49,26 +49,14 @@ pub struct LogsArgs { #[arg(long)] subscribe: bool, - /// Print the logs as JSON.s - #[arg(long, short, help_heading = "Display options")] - json: bool, - #[command(flatten)] eth: EthereumOpts, } impl LogsArgs { pub async fn run(self) -> Result<()> { - let Self { - from_block, - to_block, - address, - sig_or_topic, - topics_or_args, - subscribe, - json, - eth, - } = self; + let Self { from_block, to_block, address, sig_or_topic, topics_or_args, subscribe, eth } = + self; let config = Config::from(ð); let provider = utils::get_provider(&config)?; @@ -88,7 +76,7 @@ impl LogsArgs { let filter = build_filter(from_block, to_block, address, sig_or_topic, topics_or_args)?; if !subscribe { - let logs = cast.filter_logs(filter, json).await?; + let logs = cast.filter_logs(filter).await?; sh_println!("{logs}")?; return Ok(()) } @@ -102,7 +90,7 @@ impl LogsArgs { .await?; let cast = Cast::new(&provider); let mut stdout = io::stdout(); - cast.subscribe(filter, &mut stdout, json).await?; + cast.subscribe(filter, &mut stdout).await?; Ok(()) } diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 9503bccbd5499..77b6a2cddae56 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -39,10 +39,6 @@ pub struct SendTxArgs { #[arg(long, default_value = "1")] confirmations: u64, - /// Print the transaction receipt as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, - #[command(subcommand)] command: Option, @@ -98,7 +94,6 @@ impl SendTxArgs { mut args, tx, confirmations, - json: to_json, command, unlocked, path, @@ -159,7 +154,7 @@ impl SendTxArgs { let (tx, _) = builder.build(config.sender).await?; - cast_send(provider, tx, cast_async, confirmations, timeout, to_json).await + cast_send(provider, tx, cast_async, confirmations, timeout).await // Case 2: // An option to use a local signer was provided. // If we cannot successfully instantiate a local signer, then we will assume we don't have @@ -178,7 +173,7 @@ impl SendTxArgs { .wallet(wallet) .on_provider(&provider); - cast_send(provider, tx, cast_async, confirmations, timeout, to_json).await + cast_send(provider, tx, cast_async, confirmations, timeout).await } } } @@ -189,7 +184,6 @@ async fn cast_send, T: Transport + Clone>( cast_async: bool, confs: u64, timeout: u64, - to_json: bool, ) -> Result<()> { let cast = Cast::new(provider); let pending_tx = cast.send(tx).await?; @@ -199,9 +193,8 @@ async fn cast_send, T: Transport + Clone>( if cast_async { sh_println!("{tx_hash:#x}")?; } else { - let receipt = cast - .receipt(format!("{tx_hash:#x}"), None, confs, Some(timeout), false, to_json) - .await?; + let receipt = + cast.receipt(format!("{tx_hash:#x}"), None, confs, Some(timeout), false).await?; sh_println!("{receipt}")?; } diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 1dc2fb1c5824f..8023b8bdff334 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -11,7 +11,7 @@ use cast::revm::primitives::Authorization; use clap::Parser; use eyre::{Context, Result}; use foundry_cli::{opts::RpcOpts, utils}; -use foundry_common::{fs, sh_println}; +use foundry_common::{fs, sh_println, shell}; use foundry_config::Config; use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner}; use rand::thread_rng; @@ -49,10 +49,6 @@ pub enum WalletSubcommands { /// Number of wallets to generate. #[arg(long, short, default_value = "1")] number: u32, - - /// Output generated wallets as JSON. - #[arg(long, short, default_value = "false")] - json: bool, }, /// Generates a random BIP39 mnemonic phrase @@ -69,10 +65,6 @@ pub enum WalletSubcommands { /// Entropy to use for the mnemonic #[arg(long, short, conflicts_with = "words")] entropy: Option, - - /// Output generated mnemonic phrase and accounts as JSON. - #[arg(long, short, default_value = "false")] - json: bool, }, /// Generate a vanity address. @@ -219,10 +211,10 @@ pub enum WalletSubcommands { impl WalletSubcommands { pub async fn run(self) -> Result<()> { match self { - Self::New { path, unsafe_password, number, json, .. } => { + Self::New { path, unsafe_password, number, .. } => { let mut rng = thread_rng(); - let mut json_values = if json { Some(vec![]) } else { None }; + let mut json_values = if shell::is_json() { Some(vec![]) } else { None }; if let Some(path) = path { let path = match dunce::canonicalize(path.clone()) { Ok(path) => path, @@ -294,7 +286,7 @@ impl WalletSubcommands { } } } - Self::NewMnemonic { words, accounts, entropy, json } => { + Self::NewMnemonic { words, accounts, entropy } => { let phrase = if let Some(entropy) = entropy { let entropy = Entropy::from_slice(hex::decode(entropy)?)?; Mnemonic::::new_from_entropy(entropy).to_phrase() @@ -303,7 +295,9 @@ impl WalletSubcommands { Mnemonic::::new_with_count(&mut rng, words)?.to_phrase() }; - if !json { + let format_json = shell::is_json(); + + if !format_json { sh_println!("{}", "Generating mnemonic from provided entropy...".yellow())?; } @@ -315,7 +309,7 @@ impl WalletSubcommands { let wallets = wallets.into_iter().map(|b| b.build()).collect::, _>>()?; - if !json { + if !format_json { sh_println!("{}", "Successfully generated a new mnemonic.".green())?; sh_println!("Phrase:\n{phrase}")?; sh_println!("\nAccounts:")?; @@ -324,7 +318,7 @@ impl WalletSubcommands { let mut accounts = json!([]); for (i, wallet) in wallets.iter().enumerate() { let private_key = hex::encode(wallet.credential().to_bytes()); - if json { + if format_json { accounts.as_array_mut().unwrap().push(json!({ "address": format!("{}", wallet.address()), "private_key": format!("0x{}", private_key), @@ -336,7 +330,7 @@ impl WalletSubcommands { } } - if json { + if format_json { let obj = json!({ "mnemonic": phrase, "accounts": accounts, diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index f7d66ef9d0d07..851fcfd774908 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -19,7 +19,7 @@ use foundry_common::{ import_selectors, parse_signatures, pretty_calldata, ParsedSignatures, SelectorImportData, SelectorType, }, - stdin, + shell, stdin, }; use foundry_config::Config; use std::time::Instant; @@ -187,9 +187,9 @@ async fn main_args(args: CastArgs) -> Result<()> { } // ABI encoding & decoding - CastSubcommand::AbiDecode { sig, calldata, input, json } => { + CastSubcommand::AbiDecode { sig, calldata, input } => { let tokens = SimpleCast::abi_decode(&sig, &calldata, input)?; - print_tokens(&tokens, json) + print_tokens(&tokens, shell::is_json()) } CastSubcommand::AbiEncode { sig, packed, args } => { if !packed { @@ -198,16 +198,16 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{}", SimpleCast::abi_encode_packed(&sig, &args)?)? } } - CastSubcommand::CalldataDecode { sig, calldata, json } => { + CastSubcommand::CalldataDecode { sig, calldata } => { let tokens = SimpleCast::calldata_decode(&sig, &calldata, true)?; - print_tokens(&tokens, json) + print_tokens(&tokens, shell::is_json()) } CastSubcommand::CalldataEncode { sig, args } => { sh_println!("{}", SimpleCast::calldata_encode(sig, &args)?)?; } - CastSubcommand::StringDecode { data, json } => { + CastSubcommand::StringDecode { data } => { let tokens = SimpleCast::calldata_decode("Any(string)", &data, true)?; - print_tokens(&tokens, json) + print_tokens(&tokens, shell::is_json()) } CastSubcommand::Interface(cmd) => cmd.run().await?, CastSubcommand::CreationCode(cmd) => cmd.run().await?, @@ -271,13 +271,13 @@ async fn main_args(args: CastArgs) -> Result<()> { Cast::new(provider).base_fee(block.unwrap_or(BlockId::Number(Latest))).await? )? } - CastSubcommand::Block { block, full, field, json, rpc } => { + CastSubcommand::Block { block, full, field, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; sh_println!( "{}", Cast::new(provider) - .block(block.unwrap_or(BlockId::Number(Latest)), full, field, json) + .block(block.unwrap_or(BlockId::Number(Latest)), full, field) .await? )? } @@ -432,26 +432,26 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{}", serde_json::json!(receipt))?; } } - CastSubcommand::Receipt { tx_hash, field, json, cast_async, confirmations, rpc } => { + CastSubcommand::Receipt { tx_hash, field, cast_async, confirmations, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; sh_println!( "{}", Cast::new(provider) - .receipt(tx_hash, field, confirmations, None, cast_async, json) + .receipt(tx_hash, field, confirmations, None, cast_async) .await? )? } CastSubcommand::Run(cmd) => cmd.run().await?, CastSubcommand::SendTx(cmd) => cmd.run().await?, - CastSubcommand::Tx { tx_hash, field, raw, json, rpc } => { + CastSubcommand::Tx { tx_hash, field, raw, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; // Can use either --raw or specify raw as a field let raw = raw || field.as_ref().is_some_and(|f| f == "raw"); - sh_println!("{}", Cast::new(&provider).transaction(tx_hash, field, raw, json).await?)? + sh_println!("{}", Cast::new(&provider).transaction(tx_hash, field, raw).await?)? } // 4Byte @@ -465,7 +465,7 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{sig}")? } } - CastSubcommand::FourByteDecode { calldata, json } => { + CastSubcommand::FourByteDecode { calldata } => { let calldata = stdin::unwrap_line(calldata)?; let sigs = decode_calldata(&calldata).await?; sigs.iter().enumerate().for_each(|(i, sig)| { @@ -482,7 +482,7 @@ async fn main_args(args: CastArgs) -> Result<()> { }; let tokens = SimpleCast::calldata_decode(sig, &calldata, true)?; - print_tokens(&tokens, json) + print_tokens(&tokens, shell::is_json()) } CastSubcommand::FourByteEvent { topic } => { let topic = stdin::unwrap_line(topic)?; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index bfa33c6e93f8e..75272b3b1a997 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -27,7 +27,7 @@ use foundry_common::{ abi::{encode_function_args, get_func}, compile::etherscan_project, fmt::*, - fs, get_pretty_tx_receipt_attr, TransactionReceiptWithRevertReason, + fs, get_pretty_tx_receipt_attr, shell, TransactionReceiptWithRevertReason, }; use foundry_compilers::flatten::Flattener; use foundry_config::Chain; @@ -123,7 +123,7 @@ where /// let tx = TransactionRequest::default().to(to).input(bytes.into()); /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(alloy_provider); - /// let data = cast.call(&tx, None, None, false).await?; + /// let data = cast.call(&tx, None, None).await?; /// println!("{}", data); /// # Ok(()) /// # } @@ -133,7 +133,6 @@ where req: &WithOtherFields, func: Option<&Function>, block: Option, - json: bool, ) -> Result { let res = self.provider.call(req).block(block.unwrap_or_default()).await?; @@ -174,7 +173,7 @@ where // handle case when return type is not specified Ok(if decoded.is_empty() { res.to_string() - } else if json { + } else if shell::is_json() { let tokens = decoded.iter().map(format_token_raw).collect::>(); serde_json::to_string_pretty(&tokens).unwrap() } else { @@ -208,7 +207,7 @@ where /// let tx = TransactionRequest::default().to(to).input(bytes.into()); /// let tx = WithOtherFields::new(tx); /// let cast = Cast::new(&provider); - /// let access_list = cast.access_list(&tx, None, false).await?; + /// let access_list = cast.access_list(&tx, None).await?; /// println!("{}", access_list); /// # Ok(()) /// # } @@ -217,11 +216,10 @@ where &self, req: &WithOtherFields, block: Option, - to_json: bool, ) -> Result { let access_list = self.provider.create_access_list(req).block_id(block.unwrap_or_default()).await?; - let res = if to_json { + let res = if shell::is_json() { serde_json::to_string(&access_list)? } else { let mut s = @@ -329,7 +327,7 @@ where /// let provider = /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); - /// let block = cast.block(5, true, None, false).await?; + /// let block = cast.block(5, true, None).await?; /// println!("{}", block); /// # Ok(()) /// # } @@ -339,7 +337,6 @@ where block: B, full: bool, field: Option, - to_json: bool, ) -> Result { let block = block.into(); if let Some(ref field) = field { @@ -357,7 +354,7 @@ where let block = if let Some(ref field) = field { get_pretty_block_attr(&block, field) .unwrap_or_else(|| format!("{field} is not a valid block field")) - } else if to_json { + } else if shell::is_json() { serde_json::to_value(&block).unwrap().to_string() } else { block.pretty() @@ -374,7 +371,6 @@ where false, // Select only select field Some(field), - false, ) .await?; @@ -408,14 +404,12 @@ where false, // Select only block hash Some(String::from("hash")), - false, ) .await?; Ok(match &genesis_hash[..] { "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" => { - match &(Self::block(self, 1920000, false, Some("hash".to_string()), false).await?)[..] - { + match &(Self::block(self, 1920000, false, Some("hash".to_string())).await?)[..] { "0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f" => { "etclive" } @@ -453,7 +447,7 @@ where "0x6d3c66c5357ec91d5c43af47e234a939b22557cbb552dc45bebbceeed90fbe34" => "bsctest", "0x0d21840abff46b96c84b2ac9e10e4f5cdaeb5693cb665db62a2f3b02d2d57b5b" => "bsc", "0x31ced5b9beb7f8782b014660da0cb18cc409f121f408186886e1ca3e8eeca96b" => { - match &(Self::block(self, 1, false, Some(String::from("hash")), false).await?)[..] { + match &(Self::block(self, 1, false, Some(String::from("hash"))).await?)[..] { "0x738639479dc82d199365626f90caa82f7eafcfe9ed354b456fb3d294597ceb53" => { "avalanche-fuji" } @@ -718,7 +712,7 @@ where /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let tx_hash = "0xf8d1713ea15a81482958fb7ddf884baee8d3bcc478c5f2f604e008dc788ee4fc"; - /// let tx = cast.transaction(tx_hash.to_string(), None, false, false).await?; + /// let tx = cast.transaction(tx_hash.to_string(), None, false).await?; /// println!("{}", tx); /// # Ok(()) /// # } @@ -728,7 +722,6 @@ where tx_hash: String, field: Option, raw: bool, - to_json: bool, ) -> Result { let tx_hash = TxHash::from_str(&tx_hash).wrap_err("invalid tx hash")?; let tx = self @@ -742,7 +735,7 @@ where } else if let Some(field) = field { get_pretty_tx_attr(&tx, field.as_str()) .ok_or_else(|| eyre::eyre!("invalid tx field: {}", field.to_string()))? - } else if to_json { + } else if shell::is_json() { // to_value first to sort json object keys serde_json::to_value(&tx)?.to_string() } else { @@ -761,7 +754,7 @@ where /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let tx_hash = "0xf8d1713ea15a81482958fb7ddf884baee8d3bcc478c5f2f604e008dc788ee4fc"; - /// let receipt = cast.receipt(tx_hash.to_string(), None, 1, None, false, false).await?; + /// let receipt = cast.receipt(tx_hash.to_string(), None, 1, None, false).await?; /// println!("{}", receipt); /// # Ok(()) /// # } @@ -773,7 +766,6 @@ where confs: u64, timeout: Option, cast_async: bool, - to_json: bool, ) -> Result { let tx_hash = TxHash::from_str(&tx_hash).wrap_err("invalid tx hash")?; @@ -802,7 +794,7 @@ where Ok(if let Some(ref field) = field { get_pretty_tx_receipt_attr(&receipt, field) .ok_or_else(|| eyre::eyre!("invalid receipt field: {}", field))? - } else if to_json { + } else if shell::is_json() { // to_value first to sort json object keys serde_json::to_value(&receipt)?.to_string() } else { @@ -878,10 +870,10 @@ where )) } - pub async fn filter_logs(&self, filter: Filter, to_json: bool) -> Result { + pub async fn filter_logs(&self, filter: Filter) -> Result { let logs = self.provider.get_logs(&filter).await?; - let res = if to_json { + let res = if shell::is_json() { serde_json::to_string(&logs)? } else { let mut s = vec![]; @@ -969,16 +961,11 @@ where /// let filter = /// Filter::new().address(Address::from_str("0x00000000006c3852cbEf3e08E8dF289169EdE581")?); /// let mut output = io::stdout(); - /// cast.subscribe(filter, &mut output, false).await?; + /// cast.subscribe(filter, &mut output).await?; /// # Ok(()) /// # } /// ``` - pub async fn subscribe( - &self, - filter: Filter, - output: &mut dyn io::Write, - to_json: bool, - ) -> Result<()> { + pub async fn subscribe(&self, filter: Filter, output: &mut dyn io::Write) -> Result<()> { // Initialize the subscription stream for logs let mut subscription = self.provider.subscribe_logs(&filter).await?.into_stream(); @@ -989,10 +976,11 @@ where None }; + let format_json = shell::is_json(); let to_block_number = filter.get_to_block(); // If output should be JSON, start with an opening bracket - if to_json { + if format_json { write!(output, "[")?; } @@ -1014,7 +1002,7 @@ where }, // Process incoming log log = subscription.next() => { - if to_json { + if format_json { if !first { write!(output, ",")?; } @@ -1037,7 +1025,7 @@ where } // If output was JSON, end with a closing bracket - if to_json { + if format_json { write!(output, "]")?; } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 8a8d512f83c22..6fb3ddb73c58a 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -40,6 +40,9 @@ Display options: - always: Force color output - never: Force disable color output + --json + Format log messages as JSON + -q, --quiet Do not print log messages diff --git a/crates/cli/src/opts/shell.rs b/crates/cli/src/opts/shell.rs index 9213c670224c3..fd83b952bef0f 100644 --- a/crates/cli/src/opts/shell.rs +++ b/crates/cli/src/opts/shell.rs @@ -1,5 +1,5 @@ use clap::Parser; -use foundry_common::shell::{ColorChoice, Shell, Verbosity}; +use foundry_common::shell::{ColorChoice, OutputFormat, Shell, Verbosity}; // note: `verbose` and `quiet` cannot have `short` because of conflicts with multiple commands. @@ -21,6 +21,16 @@ pub struct ShellOpts { )] pub quiet: bool, + /// Format log messages as JSON. + #[clap( + long, + global = true, + alias = "format-json", + conflicts_with_all = &["quiet", "color"], + help_heading = "Display options" + )] + pub json: bool, + /// Log messages coloring. #[clap(long, global = true, value_enum, help_heading = "Display options")] pub color: Option, @@ -34,6 +44,12 @@ impl ShellOpts { (false, false) => Verbosity::Normal, (true, true) => unreachable!(), }; - Shell::new_with(self.color.unwrap_or_default(), verbosity) + let color = self.json.then_some(ColorChoice::Never).or(self.color).unwrap_or_default(); + let format = match self.json { + true => OutputFormat::Json, + false => OutputFormat::Text, + }; + + Shell::new_with(format, color, verbosity) } } diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs index ee217fa728e8e..45d9c2296037a 100644 --- a/crates/common/src/io/shell.rs +++ b/crates/common/src/io/shell.rs @@ -27,6 +27,11 @@ pub fn is_quiet() -> bool { verbosity().is_quiet() } +/// Returns whether the output format is [`OutputFormat::Json`]. +pub fn is_json() -> bool { + Shell::get().output_format().is_json() +} + /// The global shell instance. static GLOBAL_SHELL: OnceLock> = OnceLock::new(); @@ -95,6 +100,30 @@ impl Verbosity { } } +/// The requested output format. +#[derive(Debug, Default, Clone, Copy, PartialEq)] +pub enum OutputFormat { + /// Plain text output. + #[default] + Text, + /// JSON output. + Json, +} + +impl OutputFormat { + /// Returns true if the output format is `Text`. + #[inline] + pub fn is_text(self) -> bool { + self == Self::Text + } + + /// Returns true if the output format is `Json`. + #[inline] + pub fn is_json(self) -> bool { + self == Self::Json + } +} + /// An abstraction around console output that remembers preferences for output /// verbosity and color. pub struct Shell { @@ -102,6 +131,9 @@ pub struct Shell { /// output to a memory buffer which is useful for tests. output: ShellOut, + /// The format to use for message output. + output_format: OutputFormat, + /// How verbose messages should be. verbosity: Verbosity, @@ -158,12 +190,12 @@ impl Shell { /// output. #[inline] pub fn new() -> Self { - Self::new_with(ColorChoice::Auto, Verbosity::Verbose) + Self::new_with(OutputFormat::Text, ColorChoice::Auto, Verbosity::Verbose) } /// Creates a new shell with the given color choice and verbosity. #[inline] - pub fn new_with(color: ColorChoice, verbosity: Verbosity) -> Self { + pub fn new_with(format: OutputFormat, color: ColorChoice, verbosity: Verbosity) -> Self { Self { output: ShellOut::Stream { stdout: AutoStream::new(std::io::stdout(), color.to_anstream_color_choice()), @@ -171,6 +203,7 @@ impl Shell { color_choice: color, stderr_tty: std::io::stderr().is_terminal(), }, + output_format: format, verbosity, needs_clear: AtomicBool::new(false), } @@ -181,6 +214,7 @@ impl Shell { pub fn empty() -> Self { Self { output: ShellOut::Empty(std::io::empty()), + output_format: OutputFormat::Text, verbosity: Verbosity::Quiet, needs_clear: AtomicBool::new(false), } @@ -238,6 +272,11 @@ impl Shell { self.verbosity } + /// Gets the output format of the shell. + pub fn output_format(&self) -> OutputFormat { + self.output_format + } + /// Gets the current color choice. /// /// If we are not using a color stream, this will always return `Never`, even if the color diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index f6d3483342325..f2a1891e26343 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -2,7 +2,7 @@ use super::{install, watch::WatchArgs}; use clap::Parser; use eyre::Result; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; -use foundry_common::compile::ProjectCompiler; +use foundry_common::{compile::ProjectCompiler, shell}; use foundry_compilers::{ compilers::{multi::MultiCompilerLanguage, Language}, utils::source_files_iter, @@ -73,12 +73,6 @@ pub struct BuildArgs { #[command(flatten)] #[serde(skip)] pub watch: WatchArgs, - - /// Output the compilation errors in the json format. - /// This is useful when you want to use the output in other tools. - #[arg(long, conflicts_with = "quiet")] - #[serde(skip)] - pub format_json: bool, } impl BuildArgs { @@ -102,17 +96,18 @@ impl BuildArgs { } } + let format_json = shell::is_json(); let compiler = ProjectCompiler::new() .files(files) .print_names(self.names) .print_sizes(self.sizes) .ignore_eip_3860(self.ignore_eip_3860) - .quiet(self.format_json) - .bail(!self.format_json); + .quiet(format_json) + .bail(!format_json); let output = compiler.compile(&project)?; - if self.format_json { + if format_json { sh_println!("{}", serde_json::to_string_pretty(&output.output())?)?; } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index e9f6cac745e1e..93de30e98eab8 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -18,6 +18,7 @@ use foundry_cli::{ use foundry_common::{ compile::{self}, fmt::parse_tokens, + shell, }; use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalize}; use foundry_config::{ @@ -57,10 +58,6 @@ pub struct CreateArgs { )] constructor_args_path: Option, - /// Print the deployment information as JSON. - #[arg(long, help_heading = "Display options")] - json: bool, - /// Verify contract after creation. #[arg(long)] verify: bool, @@ -109,7 +106,7 @@ impl CreateArgs { project.find_contract_path(&self.contract.name)? }; - let mut output = compile::compile_target(&target_path, &project, self.json)?; + let mut output = compile::compile_target(&target_path, &project, shell::is_json())?; let (abi, bin, _) = remove_contract(&mut output, &target_path, &self.contract.name)?; @@ -315,7 +312,7 @@ impl CreateArgs { let (deployed_contract, receipt) = deployer.send_with_receipt().await?; let address = deployed_contract; - if self.json { + if shell::is_json() { let output = json!({ "deployer": deployer_address.to_string(), "deployedTo": address.to_string(), diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 4c973217f4d7a..e2707b82fc196 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -20,7 +20,7 @@ use foundry_cli::{ opts::CoreBuildArgs, utils::{self, LoadConfig}, }; -use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs}; +use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell}; use foundry_compilers::{ artifacts::output_selection::OutputSelection, compilers::{multi::MultiCompilerLanguage, CompilerSettings, Language}, @@ -118,12 +118,8 @@ pub struct TestArgs { #[arg(long, env = "FORGE_ALLOW_FAILURE")] allow_failure: bool, - /// Output test results in JSON format. - #[arg(long, help_heading = "Display options")] - pub json: bool, - /// Output test results as JUnit XML report. - #[arg(long, conflicts_with_all(["json", "gas_report"]), help_heading = "Display options")] + #[arg(long, conflicts_with_all = ["quiet", "json", "gas_report"], help_heading = "Display options")] pub junit: bool, /// Stop running tests after the first failure. @@ -308,7 +304,7 @@ impl TestArgs { let sources_to_compile = self.get_sources_to_compile(&config, &filter)?; let compiler = - ProjectCompiler::new().quiet(self.json || self.junit).files(sources_to_compile); + ProjectCompiler::new().quiet(shell::is_json() || self.junit).files(sources_to_compile); let output = compiler.compile(&project)?; @@ -480,13 +476,13 @@ impl TestArgs { output: &ProjectCompileOutput, ) -> eyre::Result { if self.list { - return list(runner, filter, self.json); + return list(runner, filter); } trace!(target: "forge::test", "running all tests"); // If we need to render to a serialized format, we should not print anything else to stdout. - let silent = self.gas_report && self.json; + let silent = self.gas_report && shell::is_json(); let num_filtered = runner.matching_test_functions(filter).count(); if num_filtered != 1 && (self.debug.is_some() || self.flamegraph || self.flamechart) { @@ -514,7 +510,7 @@ impl TestArgs { } // Run tests in a non-streaming fashion and collect results for serialization. - if !self.gas_report && self.json { + if !self.gas_report && shell::is_json() { let mut results = runner.test_collect(filter); results.values_mut().for_each(|suite_result| { for test_result in suite_result.test_results.values_mut() { @@ -584,7 +580,7 @@ impl TestArgs { config.gas_reports.clone(), config.gas_reports_ignore.clone(), config.gas_reports_include_tests, - if self.json { GasReportKind::JSON } else { GasReportKind::Markdown }, + if shell::is_json() { GasReportKind::JSON } else { GasReportKind::Markdown }, ) }); @@ -908,14 +904,10 @@ impl Provider for TestArgs { } /// Lists all matching tests -fn list( - runner: MultiContractRunner, - filter: &ProjectPathsAwareFilter, - json: bool, -) -> Result { +fn list(runner: MultiContractRunner, filter: &ProjectPathsAwareFilter) -> Result { let results = runner.list(filter); - if json { + if shell::is_json() { println!("{}", serde_json::to_string(&results)?); } else { for (file, contracts) in results.iter() { @@ -999,34 +991,56 @@ fn junit_xml_report(results: &BTreeMap, verbosity: u8) -> R #[cfg(test)] mod tests { + use crate::opts::{Forge, ForgeSubcommand}; + use super::*; use foundry_config::{Chain, InvariantConfig}; use foundry_test_utils::forgetest_async; #[test] fn watch_parse() { - let args: TestArgs = TestArgs::parse_from(["foundry-cli", "-vw"]); + let args = match Forge::parse_from(["foundry-cli", "test", "-vw"]).cmd { + ForgeSubcommand::Test(args) => args, + _ => unreachable!(), + }; assert!(args.watch.watch.is_some()); } #[test] fn fuzz_seed() { - let args: TestArgs = TestArgs::parse_from(["foundry-cli", "--fuzz-seed", "0x10"]); + let args = match Forge::parse_from(["foundry-cli", "test", "--fuzz-seed", "0x10"]).cmd { + ForgeSubcommand::Test(args) => args, + _ => unreachable!(), + }; assert!(args.fuzz_seed.is_some()); } // #[test] fn fuzz_seed_exists() { - let args: TestArgs = - TestArgs::parse_from(["foundry-cli", "-vvv", "--gas-report", "--fuzz-seed", "0x10"]); + let args = match Forge::parse_from([ + "foundry-cli", + "test", + "-vvv", + "--gas-report", + "--fuzz-seed", + "0x10", + ]) + .cmd + { + ForgeSubcommand::Test(args) => args, + _ => unreachable!(), + }; assert!(args.fuzz_seed.is_some()); } #[test] fn extract_chain() { let test = |arg: &str, expected: Chain| { - let args = TestArgs::parse_from(["foundry-cli", arg]); + let args = match Forge::parse_from(["foundry-cli", "test", arg]).cmd { + ForgeSubcommand::Test(args) => args, + _ => unreachable!(), + }; assert_eq!(args.evm_opts.env.chain, Some(expected)); let (config, evm_opts) = args.load_config_and_evm_opts().unwrap(); assert_eq!(config.chain, Some(expected)); @@ -1080,12 +1094,18 @@ contract FooBarTest is DSTest { ) .unwrap(); - let args = TestArgs::parse_from([ + let args = match Forge::parse_from([ "foundry-cli", + "test", "--gas-report", "--root", &prj.root().to_string_lossy(), - ]); + ]) + .cmd + { + ForgeSubcommand::Test(args) => args, + _ => unreachable!(), + }; let outcome = args.run().await.unwrap(); let gas_report = outcome.gas_report.unwrap(); diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index c713a703ee7bd..ee49f7f692b2c 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -2,6 +2,7 @@ use clap::{CommandFactory, Parser}; use clap_complete::generate; use eyre::Result; use foundry_cli::{handler, utils}; +use foundry_common::shell; use foundry_evm::inspectors::cheatcodes::{set_execution_context, ForgeContext}; mod cmd; @@ -42,7 +43,7 @@ fn run() -> Result<()> { if cmd.is_watch() { utils::block_on(watch::watch_test(cmd)) } else { - let silent = cmd.junit || cmd.json; + let silent = cmd.junit || shell::is_json(); let outcome = utils::block_on(cmd.run())?; outcome.ensure_ok(silent) } diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 812754c725520..4b257fe8d20a2 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -22,9 +22,9 @@ forgetest!(throws_on_conflicting_args, |prj, cmd| { prj.clear(); cmd.args(["compile", "--format-json", "--quiet"]).assert_failure().stderr_eq(str![[r#" -error: the argument '--format-json' cannot be used with '--quiet' +error: the argument '--json' cannot be used with '--quiet' -Usage: forge[..] build --format-json [PATHS]... +Usage: forge[..] build --json [PATHS]... For more information, try '--help'. diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index f9e8997bd99ce..1560850b26f51 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -45,6 +45,9 @@ Display options: - always: Force color output - never: Force disable color output + --json + Format log messages as JSON + -q, --quiet Do not print log messages diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index ec19c0bf97162..707399d6305dc 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -30,7 +30,7 @@ use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{ abi::{encode_function_args, get_func}, evm::{Breakpoints, EvmArgs}, - ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, + shell, ContractsByArtifact, CONTRACT_MAX_SIZE, SELECTOR_LEN, }; use foundry_compilers::ArtifactId; use foundry_config::{ @@ -180,10 +180,6 @@ pub struct ScriptArgs { #[arg(long)] pub verify: bool, - /// Output results in JSON format. - #[arg(long)] - pub json: bool, - /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions, either /// specified in wei, or as a string with a unit type. /// @@ -262,7 +258,7 @@ impl ScriptArgs { }; } - if pre_simulation.args.json { + if shell::is_json() { pre_simulation.show_json()?; } else { pre_simulation.show_traces().await?; diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 02ca28c200665..a4f368a961f7a 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -16,6 +16,7 @@ use foundry_cli::{ opts::EtherscanOpts, utils::{self, read_constructor_args_file, LoadConfig}, }; +use foundry_common::shell; use foundry_compilers::{artifacts::EvmVersion, info::ContractInfo}; use foundry_config::{figment, impl_figment_convert, Config}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, utils::configure_tx_env}; @@ -75,10 +76,6 @@ pub struct VerifyBytecodeArgs { #[clap(flatten)] pub verifier: VerifierArgs, - /// Suppress logs and emit json results to stdout - #[clap(long, default_value = "false")] - pub json: bool, - /// The project's root path. /// /// By default root of the Git repository, if in one, @@ -144,7 +141,7 @@ impl VerifyBytecodeArgs { eyre::bail!("No bytecode found at address {}", self.address); } - if !self.json { + if !shell::is_json() { println!( "Verifying bytecode for contract {} at address {}", self.contract.name.clone().green(), @@ -214,7 +211,7 @@ impl VerifyBytecodeArgs { crate::utils::check_args_len(&artifact, &constructor_args)?; if maybe_predeploy { - if !self.json { + if !shell::is_json() { println!( "{}", format!("Attempting to verify predeployed contract at {:?}. Ignoring creation code verification.", self.address) @@ -290,7 +287,6 @@ impl VerifyBytecodeArgs { ); crate::utils::print_result( - &self, match_type, BytecodeType::Runtime, &mut json_results, @@ -298,7 +294,7 @@ impl VerifyBytecodeArgs { &config, ); - if self.json { + if shell::is_json() { sh_println!("{}", serde_json::to_string(&json_results)?)?; } @@ -376,7 +372,6 @@ impl VerifyBytecodeArgs { ); crate::utils::print_result( - &self, match_type, BytecodeType::Creation, &mut json_results, @@ -387,14 +382,13 @@ impl VerifyBytecodeArgs { // If the creation code does not match, the runtime also won't match. Hence return. if match_type.is_none() { crate::utils::print_result( - &self, None, BytecodeType::Runtime, &mut json_results, etherscan_metadata, &config, ); - if self.json { + if shell::is_json() { sh_println!("{}", serde_json::to_string(&json_results)?)?; } return Ok(()); @@ -488,7 +482,6 @@ impl VerifyBytecodeArgs { ); crate::utils::print_result( - &self, match_type, BytecodeType::Runtime, &mut json_results, @@ -497,7 +490,7 @@ impl VerifyBytecodeArgs { ); } - if self.json { + if shell::is_json() { sh_println!("{}", serde_json::to_string(&json_results)?)?; } Ok(()) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index aaf8a0e016b75..e3065aca08539 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -9,7 +9,7 @@ use foundry_block_explorers::{ contract::{ContractCreationData, ContractMetadata, Metadata}, errors::EtherscanError, }; -use foundry_common::{abi::encode_args, compile::ProjectCompiler, provider::RetryProvider}; +use foundry_common::{abi::encode_args, compile::ProjectCompiler, provider::RetryProvider, shell}; use foundry_compilers::artifacts::{BytecodeHash, CompactContractBytecode, EvmVersion}; use foundry_config::Config; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, opts::EvmOpts}; @@ -137,7 +137,6 @@ pub fn build_using_cache( } pub fn print_result( - args: &VerifyBytecodeArgs, res: Option, bytecode_type: BytecodeType, json_results: &mut Vec, @@ -145,7 +144,7 @@ pub fn print_result( config: &Config, ) { if let Some(res) = res { - if !args.json { + if !shell::is_json() { println!( "{} with status {}", format!("{bytecode_type:?} code matched").green().bold(), @@ -155,7 +154,7 @@ pub fn print_result( let json_res = JsonResult { bytecode_type, match_type: Some(res), message: None }; json_results.push(json_res); } - } else if !args.json { + } else if !shell::is_json() { println!( "{}", format!( From c3069a50ba18cccfc4e7d5de9b9b388811d9cc7b Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:53:25 +0100 Subject: [PATCH 1643/1963] chore(`forge`): enforce `common::shell` for `forge` crate (#9231) * enforce common shell for forge crate * revert clippy.toml * fix tests * avoid empty printlns * fix missed eprint / print * avoid style regression --- crates/cast/bin/cmd/create2.rs | 3 +- crates/forge/bin/cmd/bind.rs | 23 +++++++-------- crates/forge/bin/cmd/bind_json.rs | 2 +- crates/forge/bin/cmd/cache.rs | 2 +- crates/forge/bin/cmd/clone.rs | 1 + crates/forge/bin/cmd/compiler.rs | 18 ++++++------ crates/forge/bin/cmd/create.rs | 12 ++++---- crates/forge/bin/cmd/doc/server.rs | 2 +- crates/forge/bin/cmd/eip712.rs | 3 +- crates/forge/bin/cmd/flatten.rs | 4 +-- crates/forge/bin/cmd/fmt.rs | 2 +- crates/forge/bin/cmd/geiger/mod.rs | 7 ++--- crates/forge/bin/cmd/generate/mod.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 14 ++++----- crates/forge/bin/cmd/install.rs | 14 ++++----- crates/forge/bin/cmd/remappings.rs | 10 +++---- crates/forge/bin/cmd/remove.rs | 2 +- crates/forge/bin/cmd/selectors.rs | 28 ++++++++---------- crates/forge/bin/cmd/snapshot.rs | 12 ++++---- crates/forge/bin/cmd/test/mod.rs | 44 ++++++++++++++-------------- crates/forge/bin/cmd/test/summary.rs | 4 +-- crates/forge/bin/cmd/watch.rs | 8 +++-- crates/forge/src/coverage.rs | 22 +++++++------- crates/forge/src/gas_report.rs | 7 ++--- crates/forge/src/progress.rs | 2 +- crates/forge/src/result.rs | 3 +- crates/forge/tests/cli/cmd.rs | 4 +-- crates/forge/tests/cli/verify.rs | 4 +++ crates/test-utils/src/macros.rs | 8 +++++ 29 files changed, 136 insertions(+), 131 deletions(-) diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 271e5b43ef602..17523e094577b 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -193,8 +193,7 @@ impl Create2Args { sh_println!("Configuration:")?; sh_println!("Init code hash: {init_code_hash}")?; - sh_println!("Regex patterns: {:?}", regex.patterns())?; - sh_println!()?; + sh_println!("Regex patterns: {:?}\n", regex.patterns())?; sh_println!( "Starting to generate deterministic contract address with {n_threads} threads..." )?; diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index d8739b42d9f10..ec6b13dfd49ae 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -106,10 +106,9 @@ impl BindArgs { } if self.ethers { - eprintln!( - "Warning: `--ethers` bindings are deprecated and will be removed in the future. \ - Consider using `--alloy` (default) instead." - ); + sh_warn!( + "`--ethers` bindings are deprecated and will be removed in the future. Consider using `--alloy` (default) instead." + )?; } let config = self.try_load_config_emit_warnings()?; @@ -118,7 +117,7 @@ impl BindArgs { if bindings_root.exists() { if !self.overwrite { - println!("Bindings found. Checking for consistency."); + sh_println!("Bindings found. Checking for consistency.")?; return self.check_existing_bindings(&artifacts, &bindings_root); } @@ -128,7 +127,7 @@ impl BindArgs { self.generate_bindings(&artifacts, &bindings_root)?; - println!("Bindings have been generated to {}", bindings_root.display()); + sh_println!("Bindings have been generated to {}", bindings_root.display())?; Ok(()) } @@ -274,7 +273,7 @@ impl BindArgs { fn check_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let bindings = self.get_multi(artifacts)?.build()?; - println!("Checking bindings for {} contracts.", bindings.len()); + sh_println!("Checking bindings for {} contracts.", bindings.len())?; if !self.module { bindings .ensure_consistent_crate( @@ -294,14 +293,14 @@ impl BindArgs { } else { bindings.ensure_consistent_module(bindings_root, self.single_file)?; } - println!("OK."); + sh_println!("OK.")?; Ok(()) } fn check_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut bindings = self.get_solmacrogen(artifacts)?; bindings.generate_bindings()?; - println!("Checking bindings for {} contracts", bindings.instances.len()); + sh_println!("Checking bindings for {} contracts", bindings.instances.len())?; bindings.check_consistency( &self.crate_name, &self.crate_version, @@ -311,7 +310,7 @@ impl BindArgs { self.module, self.alloy_version.clone(), )?; - println!("OK."); + sh_println!("OK.")?; Ok(()) } @@ -326,7 +325,7 @@ impl BindArgs { fn generate_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut bindings = self.get_multi(artifacts)?.build()?; - println!("Generating bindings for {} contracts", bindings.len()); + sh_println!("Generating bindings for {} contracts", bindings.len())?; if !self.module { trace!(single_file = self.single_file, "generating crate"); if !self.skip_extra_derives { @@ -346,7 +345,7 @@ impl BindArgs { fn generate_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut solmacrogen = self.get_solmacrogen(artifacts)?; - println!("Generating bindings for {} contracts", solmacrogen.instances.len()); + sh_println!("Generating bindings for {} contracts", solmacrogen.instances.len())?; if !self.module { trace!(single_file = self.single_file, "generating crate"); diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index 2736325a7e20f..c6a052836bafc 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -439,7 +439,7 @@ impl ResolvedState { } fs::write(&self.target_path, &result)?; - println!("Bindings written to {}", self.target_path.display()); + sh_println!("Bindings written to {}", self.target_path.display())?; Ok(result) } diff --git a/crates/forge/bin/cmd/cache.rs b/crates/forge/bin/cmd/cache.rs index 1adaf4d267794..efbdde5cb6981 100644 --- a/crates/forge/bin/cmd/cache.rs +++ b/crates/forge/bin/cmd/cache.rs @@ -101,7 +101,7 @@ impl LsArgs { ChainOrAll::All => cache = Config::list_foundry_cache()?, } } - print!("{cache}"); + sh_print!("{cache}")?; Ok(()) } } diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index f1bb40cf6918a..193e511836ba9 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -616,6 +616,7 @@ mod tests { use foundry_test_utils::rpc::next_mainnet_etherscan_api_key; use std::collections::BTreeMap; + #[allow(clippy::disallowed_macros)] fn assert_successful_compilation(root: &PathBuf) -> ProjectCompileOutput { println!("project_root: {root:#?}"); compile_project(root).expect("compilation failure") diff --git a/crates/forge/bin/cmd/compiler.rs b/crates/forge/bin/cmd/compiler.rs index 06823c0c60b07..0b0ec171b4c79 100644 --- a/crates/forge/bin/cmd/compiler.rs +++ b/crates/forge/bin/cmd/compiler.rs @@ -141,25 +141,25 @@ impl ResolveArgs { } if json { - println!("{}", serde_json::to_string(&output)?); + sh_println!("{}", serde_json::to_string(&output)?)?; return Ok(()); } for (language, compilers) in &output { match verbosity { - 0 => println!("{language}:"), - _ => println!("{language}:\n"), + 0 => sh_println!("{language}:")?, + _ => sh_println!("{language}:\n")?, } for resolved_compiler in compilers { let version = &resolved_compiler.version; match verbosity { - 0 => println!("- {version}"), + 0 => sh_println!("- {version}")?, _ => { if let Some(evm) = &resolved_compiler.evm_version { - println!("{version} (<= {evm}):") + sh_println!("{version} (<= {evm}):")? } else { - println!("{version}:") + sh_println!("{version}:")? } } } @@ -168,16 +168,16 @@ impl ResolveArgs { let paths = &resolved_compiler.paths; for (idx, path) in paths.iter().enumerate() { if idx == paths.len() - 1 { - println!("└── {path}\n"); + sh_println!("└── {path}\n")? } else { - println!("├── {path}"); + sh_println!("├── {path}")? } } } } if verbosity == 0 { - println!(); + sh_println!()? } } diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 93de30e98eab8..83494acb99de1 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -318,18 +318,18 @@ impl CreateArgs { "deployedTo": address.to_string(), "transactionHash": receipt.transaction_hash }); - println!("{output}"); + sh_println!("{output}")?; } else { - println!("Deployer: {deployer_address}"); - println!("Deployed to: {address}"); - println!("Transaction hash: {:?}", receipt.transaction_hash); + sh_println!("Deployer: {deployer_address}")?; + sh_println!("Deployed to: {address}")?; + sh_println!("Transaction hash: {:?}", receipt.transaction_hash)?; }; if !self.verify { return Ok(()); } - println!("Starting contract verification..."); + sh_println!("Starting contract verification...")?; let num_of_optimizations = if self.opts.compiler.optimize.unwrap_or_default() { self.opts.compiler.optimizer_runs @@ -358,7 +358,7 @@ impl CreateArgs { show_standard_json_input: self.show_standard_json_input, guess_constructor_args: false, }; - println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier); + sh_println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier)?; verify.run().await } diff --git a/crates/forge/bin/cmd/doc/server.rs b/crates/forge/bin/cmd/doc/server.rs index 72585a2bf4ed7..b42106d99ed68 100644 --- a/crates/forge/bin/cmd/doc/server.rs +++ b/crates/forge/bin/cmd/doc/server.rs @@ -75,7 +75,7 @@ impl Server { let file_404 = get_404_output_file(&input_404); let serving_url = format!("http://{address}"); - println!("Serving on: {serving_url}"); + sh_println!("Serving on: {serving_url}")?; let thread_handle = std::thread::spawn(move || serve(build_dir, sockaddr, &file_404)); diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs index f026d5848c55d..2ab15f05488ed 100644 --- a/crates/forge/bin/cmd/eip712.rs +++ b/crates/forge/bin/cmd/eip712.rs @@ -63,8 +63,7 @@ impl Eip712Args { for (id, _) in structs_in_target { if let Some(resolved) = resolver.resolve_struct_eip712(id)? { - println!("{resolved}"); - println!(); + sh_println!("{resolved}\n")?; } } diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index f538be5a8c8fa..7bbb0d1e2d766 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -64,9 +64,9 @@ impl FlattenArgs { Some(output) => { fs::create_dir_all(output.parent().unwrap())?; fs::write(&output, flattened)?; - println!("Flattened file written at {}", output.display()); + sh_println!("Flattened file written at {}", output.display())?; } - None => println!("{flattened}"), + None => sh_println!("{flattened}")?, }; Ok(()) diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index ef1cf0461697f..49548e1b6c06f 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -129,7 +129,7 @@ impl FmtArgs { let new_format = diff.ratio() < 1.0; if self.check || path.is_none() { if self.raw { - print!("{output}"); + sh_print!("{output}")?; } // If new format then compute diff summary. diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs index da0397cc5204b..4167b7882f910 100644 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ b/crates/forge/bin/cmd/geiger/mod.rs @@ -6,7 +6,6 @@ use foundry_config::{impl_figment_convert_basic, Config}; use itertools::Itertools; use rayon::prelude::*; use std::path::PathBuf; -use yansi::Paint; mod error; @@ -95,7 +94,7 @@ impl GeigerArgs { let sources = self.sources(&config).wrap_err("Failed to resolve files")?; if config.ffi { - eprintln!("{}\n", "ffi enabled".red()); + sh_warn!("FFI enabled\n")?; } let root = config.root.0; @@ -107,12 +106,12 @@ impl GeigerArgs { let len = metrics.cheatcodes.len(); let printer = SolFileMetricsPrinter { metrics: &metrics, root: &root }; if self.full || len == 0 { - eprint!("{printer}"); + let _ = sh_eprint!("{printer}"); } len } Err(err) => { - eprintln!("{err}"); + let _ = sh_err!("{err}"); 0 } }) diff --git a/crates/forge/bin/cmd/generate/mod.rs b/crates/forge/bin/cmd/generate/mod.rs index 2c3a512821ca9..f1f69d8385618 100644 --- a/crates/forge/bin/cmd/generate/mod.rs +++ b/crates/forge/bin/cmd/generate/mod.rs @@ -44,7 +44,7 @@ impl GenerateTestArgs { // Write the test content to the test file. fs::write(&test_file_path, test_content)?; - println!("{} test file: {}", "Generated".green(), test_file_path.to_str().unwrap()); + sh_println!("{} test file: {}", "Generated".green(), test_file_path.to_str().unwrap())?; Ok(()) } } diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 14d43d6f5ec44..5c7c224f7fd56 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -87,7 +87,7 @@ impl InspectArgs { .ok_or_else(|| eyre::eyre!("Failed to fetch lossless ABI"))?; if pretty { let source = foundry_cli::utils::abi_to_solidity(abi, &contract.name)?; - println!("{source}"); + sh_println!("{source}")?; } else { print_json(abi)?; } @@ -201,7 +201,7 @@ pub fn print_storage_layout(storage_layout: Option<&StorageLayout>, pretty: bool ]); } - println!("{table}"); + sh_println!("{table}")?; Ok(()) } @@ -390,12 +390,12 @@ impl ContractArtifactField { } fn print_json(obj: &impl serde::Serialize) -> Result<()> { - println!("{}", serde_json::to_string_pretty(obj)?); + sh_println!("{}", serde_json::to_string_pretty(obj)?)?; Ok(()) } fn print_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result<()> { - println!("{}", get_json_str(obj, key)?); + sh_println!("{}", get_json_str(obj, key)?)?; Ok(()) } @@ -408,9 +408,9 @@ fn print_yul(yul: Option<&str>, pretty: bool) -> Result<()> { LazyLock::new(|| Regex::new(r"(///.*\n\s*)|(\s*/\*\*.*\*/)").unwrap()); if pretty { - println!("{}", YUL_COMMENTS.replace_all(yul, "")); + sh_println!("{}", YUL_COMMENTS.replace_all(yul, ""))?; } else { - println!("{yul}"); + sh_println!("{yul}")?; } Ok(()) @@ -450,7 +450,7 @@ fn print_eof(bytecode: Option) -> Result<()> { let eof = Eof::decode(bytecode).wrap_err("Failed to decode EOF")?; - println!("{}", pretty_eof(&eof)?); + sh_println!("{}", pretty_eof(&eof)?)?; Ok(()) } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 1485bc4409424..31637b90ccd3f 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -412,9 +412,9 @@ impl Installer<'_> { // multiple candidates, ask the user to choose one or skip candidates.insert(0, String::from("SKIP AND USE ORIGINAL TAG")); - println!("There are multiple matching tags:"); + sh_println!("There are multiple matching tags:")?; for (i, candidate) in candidates.iter().enumerate() { - println!("[{i}] {candidate}"); + sh_println!("[{i}] {candidate}")?; } let n_candidates = candidates.len(); @@ -429,7 +429,7 @@ impl Installer<'_> { Ok(0) => return Ok(tag.into()), Ok(i) if (1..=n_candidates).contains(&i) => { let c = &candidates[i]; - println!("[{i}] {c} selected"); + sh_println!("[{i}] {c} selected")?; return Ok(c.clone()) } _ => continue, @@ -474,9 +474,9 @@ impl Installer<'_> { // multiple candidates, ask the user to choose one or skip candidates.insert(0, format!("{tag} (original branch)")); - println!("There are multiple matching branches:"); + sh_println!("There are multiple matching branches:")?; for (i, candidate) in candidates.iter().enumerate() { - println!("[{i}] {candidate}"); + sh_println!("[{i}] {candidate}")?; } let n_candidates = candidates.len(); @@ -488,7 +488,7 @@ impl Installer<'_> { // default selection, return None if input.is_empty() { - println!("Canceled branch matching"); + sh_println!("Canceled branch matching")?; return Ok(None) } @@ -497,7 +497,7 @@ impl Installer<'_> { Ok(0) => Ok(Some(tag.into())), Ok(i) if (1..=n_candidates).contains(&i) => { let c = &candidates[i]; - println!("[{i}] {c} selected"); + sh_println!("[{i}] {c} selected")?; Ok(Some(c.clone())) } _ => Ok(None), diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index b33f3442cf9be..dfa667ccc9edd 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -30,20 +30,20 @@ impl RemappingArgs { } for (group, remappings) in groups { if let Some(group) = group { - println!("Context: {group}"); + sh_println!("Context: {group}")?; } else { - println!("Global:"); + sh_println!("Global:")?; } for mut remapping in remappings { remapping.context = None; // avoid writing context twice - println!("- {remapping}"); + sh_println!("- {remapping}")?; } - println!(); + sh_println!()?; } } else { for remapping in config.remappings { - println!("{remapping}"); + sh_println!("{remapping}")?; } } diff --git a/crates/forge/bin/cmd/remove.rs b/crates/forge/bin/cmd/remove.rs index a4d62b9f77d88..da2f8b251119a 100644 --- a/crates/forge/bin/cmd/remove.rs +++ b/crates/forge/bin/cmd/remove.rs @@ -38,7 +38,7 @@ impl RemoveArgs { // remove all the dependencies from .git/modules for (Dependency { name, url, tag, .. }, path) in self.dependencies.iter().zip(&paths) { - println!("Removing '{name}' in {}, (url: {url:?}, tag: {tag:?})", path.display()); + sh_println!("Removing '{name}' in {}, (url: {url:?}, tag: {tag:?})", path.display())?; std::fs::remove_dir_all(git_modules.join(path))?; } diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 7b7bce2e5cd1d..ddd6a796870c4 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -120,13 +120,13 @@ impl SelectorsSubcommands { continue } - println!("Uploading selectors for {contract}..."); + sh_println!("Uploading selectors for {contract}...")?; // upload abi to selector database import_selectors(SelectorImportData::Abi(vec![abi])).await?.describe(); if artifacts.peek().is_some() { - println!() + sh_println!()? } } } @@ -171,7 +171,7 @@ impl SelectorsSubcommands { .collect(); if colliding_methods.is_empty() { - println!("No colliding method selectors between the two contracts."); + sh_println!("No colliding method selectors between the two contracts.")?; } else { let mut table = Table::new(); table.set_header([ @@ -182,12 +182,12 @@ impl SelectorsSubcommands { for method in colliding_methods.iter() { table.add_row([method.0, method.1, method.2]); } - println!("{} collisions found:", colliding_methods.len()); - println!("{table}"); + sh_println!("{} collisions found:", colliding_methods.len())?; + sh_println!("{table}")?; } } Self::List { contract, project_paths } => { - println!("Listing selectors for contracts in the project..."); + sh_println!("Listing selectors for contracts in the project...")?; let build_args = CoreBuildArgs { project_paths, compiler: CompilerArgs { @@ -240,7 +240,7 @@ impl SelectorsSubcommands { continue } - println!("{contract}"); + sh_println!("{contract}")?; let mut table = Table::new(); @@ -264,16 +264,16 @@ impl SelectorsSubcommands { table.add_row(["Error", &sig, &hex::encode_prefixed(selector)]); } - println!("{table}"); + sh_println!("{table}")?; if artifacts.peek().is_some() { - println!() + sh_println!()? } } } Self::Find { selector, project_paths } => { - println!("Searching for selector {selector:?} in the project..."); + sh_println!("Searching for selector {selector:?} in the project...")?; let build_args = CoreBuildArgs { project_paths, @@ -340,12 +340,10 @@ impl SelectorsSubcommands { } if table.row_count() > 0 { - println!(); - println!("Found {} instance(s)...", table.row_count()); - println!("{table}"); + sh_println!("\nFound {} instance(s)...", table.row_count())?; + sh_println!("{table}")?; } else { - println!(); - return Err(eyre::eyre!("Selector not found in the project.")); + return Err(eyre::eyre!("\nSelector not found in the project.")); } } } diff --git a/crates/forge/bin/cmd/snapshot.rs b/crates/forge/bin/cmd/snapshot.rs index 391c45dd2d89b..872a53138c8ee 100644 --- a/crates/forge/bin/cmd/snapshot.rs +++ b/crates/forge/bin/cmd/snapshot.rs @@ -331,7 +331,7 @@ fn check( { let source_gas = test.result.kind.report(); if !within_tolerance(source_gas.gas(), target_gas.gas(), tolerance) { - eprintln!( + let _ = sh_println!( "Diff in \"{}::{}\": consumed \"{}\" gas, expected \"{}\" gas ", test.contract_name(), test.signature, @@ -341,7 +341,7 @@ fn check( has_diff = true; } } else { - eprintln!( + let _ = sh_println!( "No matching snapshot entry found for \"{}::{}\" in snapshot file", test.contract_name(), test.signature @@ -382,20 +382,20 @@ fn diff(tests: Vec, snaps: Vec) -> Result<()> overall_gas_change += gas_change; overall_gas_used += diff.target_gas_used.gas() as i128; let gas_diff = diff.gas_diff(); - println!( + sh_println!( "{} (gas: {} ({})) ", diff.signature, fmt_change(gas_change), fmt_pct_change(gas_diff) - ); + )?; } let overall_gas_diff = overall_gas_change as f64 / overall_gas_used as f64; - println!( + sh_println!( "Overall gas change: {} ({})", fmt_change(overall_gas_change), fmt_pct_change(overall_gas_diff) - ); + )?; Ok(()) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index e2707b82fc196..c7d928a898a2f 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -207,7 +207,7 @@ impl TestArgs { let output = project.compile()?; if output.has_compiler_errors() { - println!("{output}"); + sh_println!("{output}")?; eyre::bail!("Compilation failed"); } @@ -226,13 +226,13 @@ impl TestArgs { if test_sources.is_empty() { if filter.is_empty() { - println!( + sh_println!( "No tests found in project! \ Forge looks for functions that starts with `test`." - ); + )?; } else { - println!("No tests match the provided pattern:"); - print!("{filter}"); + sh_println!("No tests match the provided pattern:")?; + sh_print!("{filter}")?; // Try to suggest a test when there's no match if let Some(test_pattern) = &filter.args().test_pattern { @@ -245,7 +245,7 @@ impl TestArgs { .flat_map(|(_, abi)| abi.functions.into_keys()) .collect::>(); if let Some(suggestion) = utils::did_you_mean(test_name, candidates).pop() { - println!("\nDid you mean `{suggestion}`?"); + sh_println!("\nDid you mean `{suggestion}`?")?; } } } @@ -427,11 +427,11 @@ impl TestArgs { // Generate SVG. inferno::flamegraph::from_lines(&mut options, fst.iter().map(String::as_str), file) .wrap_err("failed to write svg")?; - println!("\nSaved to {file_name}"); + sh_println!("Saved to {file_name}")?; // Open SVG in default program. if let Err(e) = opener::open(&file_name) { - eprintln!("\nFailed to open {file_name}; please open it manually: {e}"); + sh_err!("Failed to open {file_name}; please open it manually: {e}")?; } } @@ -523,13 +523,13 @@ impl TestArgs { } } }); - println!("{}", serde_json::to_string(&results)?); + sh_println!("{}", serde_json::to_string(&results)?)?; return Ok(TestOutcome::new(results, self.allow_failure)); } if self.junit { let results = runner.test_collect(filter); - println!("{}", junit_xml_report(&results, verbosity).to_string()?); + sh_println!("{}", junit_xml_report(&results, verbosity).to_string()?)?; return Ok(TestOutcome::new(results, self.allow_failure)); } @@ -604,14 +604,14 @@ impl TestArgs { // Print suite header. if !silent { - println!(); + sh_println!()?; for warning in suite_result.warnings.iter() { - eprintln!("{} {warning}", "Warning:".yellow().bold()); + sh_warn!("{warning}")?; } if !tests.is_empty() { let len = tests.len(); let tests = if len > 1 { "tests" } else { "test" }; - println!("Ran {len} {tests} for {contract_name}"); + sh_println!("Ran {len} {tests} for {contract_name}")?; } } @@ -632,11 +632,11 @@ impl TestArgs { // We only decode logs from Hardhat and DS-style console events let console_logs = decode_console_logs(&result.logs); if !console_logs.is_empty() { - println!("Logs:"); + sh_println!("Logs:")?; for log in console_logs { - println!(" {log}"); + sh_println!(" {log}")?; } - println!(); + sh_println!()?; } } } @@ -747,13 +747,13 @@ impl TestArgs { .collect(); if !diff.is_empty() { - println!( + let _ = sh_eprintln!( "{}", format!("\n[{group}] Failed to match snapshots:").red().bold() ); for (key, (previous_snapshot, snapshot)) in &diff { - println!( + let _ = sh_eprintln!( "{}", format!("- [{key}] {previous_snapshot} → {snapshot}").red() ); @@ -767,7 +767,7 @@ impl TestArgs { ); if differences_found { - println!(); + sh_eprintln!()?; eyre::bail!("Snapshots differ from previous run"); } } @@ -911,10 +911,10 @@ fn list(runner: MultiContractRunner, filter: &ProjectPathsAwareFilter) -> Result println!("{}", serde_json::to_string(&results)?); } else { for (file, contracts) in results.iter() { - println!("{file}"); + sh_println!("{file}")?; for (contract, tests) in contracts.iter() { - println!(" {contract}"); - println!(" {}\n", tests.join("\n ")); + sh_println!(" {contract}")?; + sh_println!(" {}\n", tests.join("\n "))?; } } } diff --git a/crates/forge/bin/cmd/test/summary.rs b/crates/forge/bin/cmd/test/summary.rs index 6d20edfd52f58..1922ce53bf18b 100644 --- a/crates/forge/bin/cmd/test/summary.rs +++ b/crates/forge/bin/cmd/test/summary.rs @@ -92,7 +92,7 @@ impl TestSummaryReporter { self.table.add_row(row); } - println!("\n{}", self.table); + let _ = sh_println!("\n{}", self.table); } } @@ -126,6 +126,6 @@ pub(crate) fn print_invariant_metrics(test_metrics: &HashMap Result { let config = watchexec::Config::default(); - config.on_error(|err| eprintln!("[[{err:?}]]")); + config.on_error(|err| { + let _ = sh_eprintln!("[[{err:?}]]"); + }); if let Some(delay) = &self.watch_delay { config.throttle(utils::parse_delay(delay)?); @@ -149,7 +151,7 @@ impl WatchArgs { let quit = |mut action: ActionHandler| { match quit_again.fetch_add(1, Ordering::Relaxed) { 0 => { - eprintln!( + let _ = sh_eprintln!( "[Waiting {stop_timeout:?} for processes to exit before stopping... \ Ctrl-C again to exit faster]" ); @@ -228,7 +230,7 @@ fn end_of_process(state: &CommandState) { let quiet = false; if !quiet { - eprintln!("{}", format!("[{msg}]").paint(fg.foreground())); + let _ = sh_eprintln!("{}", format!("[{msg}]").paint(fg.foreground())); } } diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 4a00675dd754c..de8d0a8aa8535 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -55,7 +55,7 @@ impl CoverageReporter for SummaryReporter { } self.add_row("Total", self.total.clone()); - println!("{}", self.table); + sh_println!("{}", self.table)?; Ok(()) } } @@ -139,7 +139,7 @@ impl CoverageReporter for LcovReporter<'_> { writeln!(self.destination, "end_of_record")?; } - println!("Wrote LCOV report."); + sh_println!("Wrote LCOV report.")?; Ok(()) } @@ -151,30 +151,30 @@ pub struct DebugReporter; impl CoverageReporter for DebugReporter { fn report(self, report: &CoverageReport) -> eyre::Result<()> { for (path, items) in report.items_by_source() { - println!("Uncovered for {}:", path.display()); + sh_println!("Uncovered for {}:", path.display())?; items.iter().for_each(|item| { if item.hits == 0 { - println!("- {item}"); + let _ = sh_println!("- {item}"); } }); - println!(); + sh_println!()?; } for (contract_id, anchors) in &report.anchors { - println!("Anchors for {contract_id}:"); + sh_println!("Anchors for {contract_id}:")?; anchors .0 .iter() .map(|anchor| (false, anchor)) .chain(anchors.1.iter().map(|anchor| (true, anchor))) .for_each(|(is_deployed, anchor)| { - println!("- {anchor}"); + let _ = sh_println!("- {anchor}"); if is_deployed { - println!("- Creation code"); + let _ = sh_println!("- Creation code"); } else { - println!("- Runtime code"); + let _ = sh_println!("- Runtime code"); } - println!( + let _ = sh_println!( " - Refers to item: {}", report .items @@ -183,7 +183,7 @@ impl CoverageReporter for DebugReporter { .map_or("None".to_owned(), |item| item.to_string()) ); }); - println!(); + sh_println!()?; } Ok(()) diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index ea8a49d373c23..1b6e4bd63bc09 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -11,7 +11,6 @@ use foundry_evm::traces::CallKind; use serde::{Deserialize, Serialize}; use serde_json::json; use std::{collections::BTreeMap, fmt::Display}; -use yansi::Paint; #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum GasReportKind { @@ -68,10 +67,8 @@ impl GasReport { // list. This is addressed this way because getting a report you don't expect is // preferable than not getting one you expect. A warning is printed to stderr // indicating the "double listing". - eprintln!( - "{}: {} is listed in both 'gas_reports' and 'gas_reports_ignore'.", - "warning".yellow().bold(), - contract_name + let _ = sh_warn!( + "{contract_name} is listed in both 'gas_reports' and 'gas_reports_ignore'." ); } return contains_anyway; diff --git a/crates/forge/src/progress.rs b/crates/forge/src/progress.rs index 2b45d5513a947..9ca182f769d50 100644 --- a/crates/forge/src/progress.rs +++ b/crates/forge/src/progress.rs @@ -48,7 +48,7 @@ impl TestsProgressState { pub fn end_suite_progress(&mut self, suite_name: &String, result_summary: String) { if let Some(suite_progress) = self.suites_progress.remove(suite_name) { self.multi.suspend(|| { - println!("{suite_name}\n ↪ {result_summary}"); + let _ = sh_println!("{suite_name}\n ↪ {result_summary}"); }); suite_progress.finish_and_clear(); // Increment test progress bar to reflect completed test suite. diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index ebe8a94864938..60c07472eac0b 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -163,8 +163,7 @@ impl TestOutcome { std::process::exit(1); } - sh_println!()?; - sh_println!("Failing tests:")?; + sh_println!("\nFailing tests:")?; for (suite_name, suite) in outcome.results.iter() { let failed = suite.failed(); if failed == 0 { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 1560850b26f51..feb608a1e12ac 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2216,7 +2216,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { "#]]) .stderr_eq(str![[r#" ... -warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. +Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. ... "#]]); cmd.forge_fuse() @@ -2281,7 +2281,7 @@ warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. ) .stderr_eq(str![[r#" ... -warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. +Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. ... "#]]); }); diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index c8ce2c25f1bfc..154c74e30d84d 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -73,6 +73,7 @@ contract Verify is Unique { .unwrap(); } +#[allow(clippy::disallowed_macros)] fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Result<()> { // give etherscan some time to verify the contract let retry = Retry::new(retries, Some(Duration::from_secs(30))); @@ -124,6 +125,7 @@ fn await_verification_response(info: EnvExternalities, mut cmd: TestCommand) { parse_verification_result(&mut cmd, 6).expect("Failed to verify check") } +#[allow(clippy::disallowed_macros)] fn verify_on_chain(info: Option, prj: TestProject, mut cmd: TestCommand) { // only execute if keys present if let Some(info) = info { @@ -157,6 +159,7 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te } } +#[allow(clippy::disallowed_macros)] fn guess_constructor_args(info: Option, prj: TestProject, mut cmd: TestCommand) { // only execute if keys present if let Some(info) = info { @@ -197,6 +200,7 @@ fn guess_constructor_args(info: Option, prj: TestProject, mut } } +#[allow(clippy::disallowed_macros)] /// Executes create --verify on the given chain fn create_verify_on_chain(info: Option, prj: TestProject, mut cmd: TestCommand) { // only execute if keys present diff --git a/crates/test-utils/src/macros.rs b/crates/test-utils/src/macros.rs index cc92bb040607d..08900ad149319 100644 --- a/crates/test-utils/src/macros.rs +++ b/crates/test-utils/src/macros.rs @@ -37,6 +37,7 @@ macro_rules! forgetest { $crate::forgetest!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { + #[allow(clippy::disallowed_macros)] #[test] $(#[$attr])* fn $test() { @@ -52,6 +53,7 @@ macro_rules! forgetest_async { $crate::forgetest_async!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { + #[allow(clippy::disallowed_macros)] #[tokio::test(flavor = "multi_thread")] $(#[$attr])* async fn $test() { @@ -67,6 +69,7 @@ macro_rules! casttest { $crate::casttest!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, $($async)? |$prj, $cmd| $e); }; ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { + #[allow(clippy::disallowed_macros)] #[test] $(#[$attr])* fn $test() { @@ -75,6 +78,7 @@ macro_rules! casttest { } }; ($(#[$attr:meta])* $test:ident, $style:expr, async |$prj:ident, $cmd:ident| $e:expr) => { + #[allow(clippy::disallowed_macros)] #[tokio::test(flavor = "multi_thread")] $(#[$attr])* async fn $test() { @@ -86,11 +90,13 @@ macro_rules! casttest { /// Same as `forgetest` but returns an already initialized project workspace (`forge init`) #[macro_export] +#[allow(clippy::disallowed_macros)] macro_rules! forgetest_init { ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { $crate::forgetest_init!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { + #[allow(clippy::disallowed_macros)] #[test] $(#[$attr])* fn $test() { @@ -103,11 +109,13 @@ macro_rules! forgetest_init { /// Setup forge soldeer #[macro_export] +#[allow(clippy::disallowed_macros)] macro_rules! forgesoldeer { ($(#[$attr:meta])* $test:ident, |$prj:ident, $cmd:ident| $e:expr) => { $crate::forgesoldeer!($(#[$attr])* $test, $crate::foundry_compilers::PathStyle::Dapptools, |$prj, $cmd| $e); }; ($(#[$attr:meta])* $test:ident, $style:expr, |$prj:ident, $cmd:ident| $e:expr) => { + #[allow(clippy::disallowed_macros)] #[test] $(#[$attr])* fn $test() { From 455ba9b1b736766232d84ba1790ac9ba6ca944de Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 5 Nov 2024 05:06:30 +0200 Subject: [PATCH 1644/1963] fix(remappings): check if remapping to add starts with existing remapping name (#9246) * fix(remappings): check if remapping to add starts with existing remapping name * Push remapping fn doesn't have to be pub, proper test remappings --- crates/config/src/providers/remappings.rs | 10 +++--- crates/forge/tests/cli/config.rs | 38 +++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 2e849bea4eccb..48e9c875f1ace 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -46,14 +46,16 @@ impl Remappings { } /// Push an element to the remappings vector, but only if it's not already present. - pub fn push(&mut self, remapping: Remapping) { + fn push(&mut self, remapping: Remapping) { if !self.remappings.iter().any(|existing| { // What we're doing here is filtering for ambiguous paths. For example, if we have - // @prb/math/=node_modules/@prb/math/src/ as existing, and - // @prb/=node_modules/@prb/ as the one being checked, + // @prb/=node_modules/@prb/ as existing, and + // @prb/math/=node_modules/@prb/math/src/ as the one being checked, // we want to keep the already existing one, which is the first one. This way we avoid // having to deal with ambiguous paths which is unwanted when autodetecting remappings. - existing.name.starts_with(&remapping.name) && existing.context == remapping.context + // Remappings are added from root of the project down to libraries, so + // we want to exclude any conflicting remappings added from libraries. + remapping.name.starts_with(&existing.name) && existing.context == remapping.context }) { self.remappings.push(remapping) } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f6ec7c88eddf9..f38dcf414a009 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -595,6 +595,44 @@ forgetest_init!(can_prioritise_closer_lib_remappings, |prj, cmd| { ); }); +// Test that remappings within root of the project have priority over remappings of sub-projects. +// E.g. `@utils/libraries` mapping from library shouldn't be added if project already has `@utils` +// remapping. +// See +forgetest_init!(test_root_remappings_priority, |prj, cmd| { + let mut config = cmd.config(); + // Add `@utils/` remapping in project config. + config.remappings = vec![ + Remapping::from_str("@utils/=src/").unwrap().into(), + Remapping::from_str("@another-utils/libraries/=src/").unwrap().into(), + ]; + let proj_toml_file = prj.paths().root.join("foundry.toml"); + pretty_err(&proj_toml_file, fs::write(&proj_toml_file, config.to_string_pretty().unwrap())); + + // Create a new lib in the `lib` folder with conflicting `@utils/libraries` remapping. + // This should be filtered out from final remappings as root project already has `@utils/`. + let nested = prj.paths().libraries[0].join("dep1"); + pretty_err(&nested, fs::create_dir_all(&nested)); + let mut lib_config = Config::load_with_root(&nested); + lib_config.remappings = vec![ + Remapping::from_str("@utils/libraries/=src/").unwrap().into(), + Remapping::from_str("@another-utils/=src/").unwrap().into(), + ]; + let lib_toml_file = nested.join("foundry.toml"); + pretty_err(&lib_toml_file, fs::write(&lib_toml_file, lib_config.to_string_pretty().unwrap())); + + cmd.args(["remappings", "--pretty"]).assert_success().stdout_eq(str![[r#" +Global: +- @utils/=src/ +- @another-utils/libraries/=src/ +- @another-utils/=lib/dep1/src/ +- dep1/=lib/dep1/src/ +- forge-std/=lib/forge-std/src/ + + +"#]]); +}); + // test to check that foundry.toml libs section updates on install forgetest!(can_update_libs_section, |prj, cmd| { cmd.git_init(); From 0c769c3b6f5bb4ade5e0f3855efe677eeea8203d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:23:06 +0200 Subject: [PATCH 1645/1963] chore: ignore flaky rostock chain test (#9261) --- crates/forge/tests/cli/script.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 88b75ad50114a..901ef592211dd 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2250,11 +2250,14 @@ Simulated On-chain Traces: // Tests that chained errors are properly displayed. // -forgetest_init!(should_display_evm_chained_error, |prj, cmd| { - let script = prj - .add_source( - "Foo", - r#" +forgetest_init!( + #[ignore] + should_display_evm_chained_error, + |prj, cmd| { + let script = prj + .add_source( + "Foo", + r#" import "forge-std/Script.sol"; contract ContractScript is Script { @@ -2262,14 +2265,15 @@ contract ContractScript is Script { } } "#, - ) - .unwrap(); - cmd.arg("script").arg(script).args(["--fork-url", "https://public-node.testnet.rsk.co"]).assert_failure().stderr_eq(str![[r#" + ) + .unwrap(); + cmd.arg("script").arg(script).args(["--fork-url", "https://public-node.testnet.rsk.co"]).assert_failure().stderr_eq(str![[r#" Error: Failed to deploy script: backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set; "#]]); -}); + } +); forgetest_async!(should_detect_additional_contracts, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; From 57bb12e022fb9ea46a4a7ca8647eb016e8d43ca3 Mon Sep 17 00:00:00 2001 From: Delweng Date: Tue, 5 Nov 2024 16:31:49 +0800 Subject: [PATCH 1646/1963] fix(anvil): set auto-unlock an alias of auto-impersonate (#9256) * fix(anvil): alias --auto-unlock of auto-impersonate Signed-off-by: jsvisa * feat(anvil): add more clear help messge for auto-impersonate Signed-off-by: jsvisa --------- Signed-off-by: jsvisa --- crates/anvil/src/cmd.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 8592ed1a02b91..839dae0160b2e 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -561,8 +561,9 @@ pub struct AnvilEvmArgs { #[arg(long, visible_alias = "no-console-log")] pub disable_console_log: bool, - /// Enable autoImpersonate on startup - #[arg(long, visible_alias = "auto-impersonate")] + /// Enables automatic impersonation on startup. This allows any transaction sender to be + /// simulated as different accounts, which is useful for testing contract behavior. + #[arg(long, visible_alias = "auto-unlock")] pub auto_impersonate: bool, /// Run an Optimism chain From 42f5eb9464650bc1e7a16b5931c2b4affdbb88f6 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:08:14 +0100 Subject: [PATCH 1647/1963] chore(deps): prefer soft pinning on minor version for dependencies (#9269) * soft-pin on minor version, prefer workspace * use workspace * prefer workspace --- Cargo.lock | 68 +++++++++++++++---------------- Cargo.toml | 34 ++++++++-------- crates/anvil/Cargo.toml | 4 +- crates/anvil/core/Cargo.toml | 4 +- crates/anvil/server/Cargo.toml | 2 +- crates/cast/Cargo.toml | 2 +- crates/cheatcodes/Cargo.toml | 6 +-- crates/cheatcodes/spec/Cargo.toml | 2 +- crates/chisel/Cargo.toml | 2 +- crates/cli/Cargo.toml | 2 +- crates/config/Cargo.toml | 8 ++-- crates/doc/Cargo.toml | 2 +- crates/forge/Cargo.toml | 8 ++-- crates/macros/Cargo.toml | 6 +-- crates/script/Cargo.toml | 2 +- crates/test-utils/Cargo.toml | 6 +-- crates/verify/Cargo.toml | 2 +- crates/wallets/Cargo.toml | 4 +- 18 files changed, 83 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73a15ac8ce2c3..2bfdbb92fcc86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5228b189b18b85761340dc9eaac0141148a8503657b36f9bc3a869413d987ca" +checksum = "85132f2698b520fab3f54beed55a44389f7006a7b557a0261e1e69439dcc1572" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31a0f0d51db8a1a30a4d98a9f90e090a94c8f44cb4d9eafc7e03aa6d00aae984" +checksum = "ded610181f3dad5810f6ff12d1a99994cf9b42d2fcb7709029352398a5da5ae6" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -261,9 +261,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8edae627382349b56cd6a7a2106f4fd69b243a9233e560c55c2e03cabb7e1d3c" +checksum = "fd58d377699e6cfeab52c4a9d28bdc4ef37e2bd235ff2db525071fe37a2e9af5" dependencies = [ "alloy-rlp", "arbitrary", @@ -274,7 +274,7 @@ dependencies = [ "derive_more", "foldhash", "getrandom", - "hashbrown 0.15.0", + "hashbrown 0.15.1", "hex-literal", "indexmap 2.6.0", "itoa", @@ -611,9 +611,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841eabaa4710f719fddbc24c95d386eae313f07e6da4babc25830ee37945be0c" +checksum = "8a1b42ac8f45e2f49f4bcdd72cbfde0bb148f5481d403774ffa546e48b83efc1" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -625,9 +625,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6672337f19d837b9f7073c45853aeb528ed9f7dd6a4154ce683e9e5cb7794014" +checksum = "06318f1778e57f36333e850aa71bd1bb5e560c10279e236622faae0470c50412" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -644,9 +644,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dff37dd20bfb118b777c96eda83b2067f4226d2644c5cfa00187b3bc01770ba" +checksum = "eaebb9b0ad61a41345a22c9279975c0cdd231b97947b10d7aad1cf0a7181e4a5" dependencies = [ "alloy-json-abi", "const-hex", @@ -661,9 +661,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b853d42292dbb159671a3edae3b2750277ff130f32b726fe07dc2b17aa6f2b5" +checksum = "12c71028bfbfec210e24106a542aad3def7caf1a70e2c05710e92a98481980d3" dependencies = [ "serde", "winnow", @@ -671,9 +671,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa828bb1b9a6dc52208fbb18084fb9ce2c30facc2bfda6a5d922349b4990354f" +checksum = "374d7fb042d68ddfe79ccb23359de3007f6d4d53c13f703b64fb0db422132111" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -801,9 +801,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -1998,9 +1998,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.34" +version = "1.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" +checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" dependencies = [ "shlex", ] @@ -4707,9 +4707,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" dependencies = [ "allocator-api2", "equivalent", @@ -5148,7 +5148,7 @@ checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "arbitrary", "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", "serde", ] @@ -5551,7 +5551,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -7449,9 +7449,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" dependencies = [ "bitflags 2.6.0", "errno", @@ -8409,9 +8409,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16320d4a2021ba1a32470b3759676114a918885e9800e68ad60f2c67969fba62" +checksum = "edf42e81491fb8871b74df3d222c64ae8cbc1269ea509fa768a3ed3e1b0ac8cb" dependencies = [ "paste", "proc-macro2", @@ -8517,18 +8517,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", @@ -9529,7 +9529,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]] diff --git a/Cargo.toml b/Cargo.toml index 80e7945d51460..937419325aa94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -205,17 +205,17 @@ alloy-transport-ipc = { version = "0.5.4", default-features = false } alloy-transport-ws = { version = "0.5.4", default-features = false } ## alloy-core -alloy-dyn-abi = "0.8.9" -alloy-json-abi = "0.8.9" -alloy-primitives = { version = "0.8.9", features = [ +alloy-dyn-abi = "0.8.11" +alloy-json-abi = "0.8.11" +alloy-primitives = { version = "0.8.11", features = [ "getrandom", "rand", "map-foldhash", ] } -alloy-sol-macro-expander = "0.8.9" -alloy-sol-macro-input = "0.8.9" -alloy-sol-types = "0.8.9" -syn-solidity = "0.8.9" +alloy-sol-macro-expander = "0.8.11" +alloy-sol-macro-input = "0.8.11" +alloy-sol-types = "0.8.11" +syn-solidity = "0.8.11" alloy-chains = "0.1" alloy-rlp = "0.3" @@ -226,12 +226,12 @@ op-alloy-rpc-types = "0.5.0" op-alloy-consensus = "0.5.0" ## cli -anstream = "0.6.15" -anstyle = "1.0.8" +anstream = "0.6" +anstyle = "1.0" terminal_size = "0.4" # macros -proc-macro2 = "1.0.82" +proc-macro2 = "1.0" quote = "1.0" syn = "2.0" async-trait = "0.1" @@ -243,8 +243,9 @@ divan = "0.1" # misc auto_impl = "1" +bytes = "1.8" walkdir = "2" -prettyplease = "0.2.20" +prettyplease = "0.2" ahash = "0.8" base64 = "0.22" chrono = { version = "0.4", default-features = false, features = [ @@ -260,25 +261,26 @@ evmole = "0.5" eyre = "0.6" figment = "0.10" futures = "0.3" -hyper = "1.0" -indexmap = "2.2" +hyper = "1.5" +indexmap = "2.6" itertools = "0.13" jsonpath_lib = "0.3" k256 = "0.13" mesc = "0.3" -num-format = "0.4.4" +num-format = "0.4" parking_lot = "0.12" proptest = "1" rand = "0.8" rayon = "1" +regex = { version = "1", default-features = false } reqwest = { version = "0.12", default-features = false } semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } -similar-asserts = "1.5" +similar-asserts = "1.6" soldeer-commands = "=0.4.1" strum = "0.26" -tempfile = "3.10" +tempfile = "3.13" tikv-jemallocator = "0.6" tokio = "1" toml = "0.8" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 922cb6efc2078..4c3cbc4f7e8e9 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -36,7 +36,7 @@ foundry-config.workspace = true foundry-evm.workspace = true # evm support -bytes = "1.4.0" +bytes.workspace = true k256.workspace = true revm = { workspace = true, features = [ "std", @@ -93,7 +93,7 @@ thiserror.workspace = true yansi.workspace = true tempfile.workspace = true itertools.workspace = true -rand = "0.8" +rand.workspace = true eyre.workspace = true # cli diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index da337c62d8c89..dcf8bf50857e1 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -34,10 +34,10 @@ op-alloy-consensus.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true -bytes = "1.4" +bytes.workspace = true # misc -rand = "0.8" +rand.workspace = true thiserror.workspace = true [features] diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index 282e090132dae..c8856939c21f3 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -29,7 +29,7 @@ futures.workspace = true # ipc interprocess = { version = "2", optional = true, features = ["tokio"] } -bytes = { version = "1.4", optional = true } +bytes = { workspace = true, optional = true } tokio-util = { version = "0.7", features = ["codec"], optional = true } # misc diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 4e6b001ecfaf3..0887649e58dd8 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -79,7 +79,7 @@ comfy-table.workspace = true dunce.workspace = true indicatif = "0.17" itertools.workspace = true -regex = { version = "1", default-features = false } +regex = { workspace = true, default-features = false } rpassword = "7" semver.workspace = true tempfile.workspace = true diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 00d73ec4d41af..97b22b16f6e3f 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -49,15 +49,15 @@ alloy-rlp.workspace = true base64.workspace = true chrono.workspace = true -dialoguer = "0.11.0" +dialoguer = "0.11" eyre.workspace = true itertools.workspace = true jsonpath_lib.workspace = true k256.workspace = true memchr = "2.7" -p256 = "0.13.2" +p256 = "0.13" ecdsa = "0.16" -rand = "0.8" +rand.workspace = true revm.workspace = true revm-inspectors.workspace = true semver.workspace = true diff --git a/crates/cheatcodes/spec/Cargo.toml b/crates/cheatcodes/spec/Cargo.toml index 738bb62b765f2..458f6b73067ad 100644 --- a/crates/cheatcodes/spec/Cargo.toml +++ b/crates/cheatcodes/spec/Cargo.toml @@ -20,7 +20,7 @@ alloy-sol-types = { workspace = true, features = ["json"] } serde.workspace = true # schema -schemars = { version = "0.8.15", optional = true } +schemars = { version = "0.8", optional = true } [dev-dependencies] serde_json.workspace = true diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 7868137d85caf..65b3c974836b3 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -50,7 +50,7 @@ alloy-rpc-types.workspace = true clap = { version = "4", features = ["derive", "env", "wrap_help"] } dirs = "5" eyre.workspace = true -regex = "1" +regex.workspace = true reqwest.workspace = true revm.workspace = true rustyline = "14" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index bab56495a5b33..9fa867db3c8f4 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -37,7 +37,7 @@ dotenvy = "0.15" eyre.workspace = true futures.workspace = true indicatif = "0.17" -regex = { version = "1", default-features = false } +regex = { workspace = true, default-features = false } serde.workspace = true strsim = "0.11" strum = { workspace = true, features = ["derive"] } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index ec1894fb2891d..3e6815d784e68 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -32,21 +32,21 @@ glob = "0.3" Inflector = "0.11" number_prefix = "0.4" mesc.workspace = true -regex = "1" +regex.workspace = true reqwest.workspace = true semver = { workspace = true, features = ["serde"] } serde_json.workspace = true serde_regex = "1" serde.workspace = true thiserror.workspace = true -toml = { version = "0.8", features = ["preserve_order"] } -toml_edit = "0.22.4" +toml = { workspace = true, features = ["preserve_order"] } +toml_edit = "0.22" tracing.workspace = true walkdir.workspace = true yansi.workspace = true [target.'cfg(target_os = "windows")'.dependencies] -path-slash = "0.2.1" +path-slash = "0.2" [dev-dependencies] similar-asserts.workspace = true diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 3ebc7f8dac62b..00223eb27a3b8 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -31,4 +31,4 @@ solang-parser.workspace = true thiserror.workspace = true toml.workspace = true tracing.workspace = true -regex = "1.10.2" +regex.workspace = true diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index f85a08d69f279..b32a9bd412237 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -80,10 +80,10 @@ dialoguer = { version = "0.11", default-features = false } dunce.workspace = true futures.workspace = true indicatif = "0.17" -inferno = { version = "0.11.19", default-features = false } +inferno = { version = "0.11", default-features = false } itertools.workspace = true parking_lot.workspace = true -regex = { version = "1", default-features = false } +regex = { workspace = true, default-features = false } reqwest = { workspace = true, features = ["json"] } semver.workspace = true serde_json.workspace = true @@ -92,8 +92,8 @@ solang-parser.workspace = true strum = { workspace = true, features = ["derive"] } thiserror.workspace = true tokio = { workspace = true, features = ["time"] } -toml = { version = "0.8", features = ["preserve_order"] } -toml_edit = "0.22.4" +toml = { workspace = true, features = ["preserve_order"] } +toml_edit = "0.22" watchexec = "4.1" watchexec-events = "3.0" watchexec-signals = "3.0" diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index 671d37be87a0d..98dc669f137e8 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -19,7 +19,7 @@ test = false doc = false [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = "2.0" +proc-macro2.workspace = true +quote.workspace = true +syn.workspace = true proc-macro-error = "1" diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 0d4810da66c14..e1a6428d9f199 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -35,7 +35,7 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } semver.workspace = true futures.workspace = true tokio.workspace = true -async-recursion = "1.0.5" +async-recursion = "1.1" itertools.workspace = true parking_lot.workspace = true diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 6e5e900ce33c3..11b7800e6bba9 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -23,14 +23,14 @@ alloy-primitives.workspace = true alloy-provider.workspace = true eyre.workspace = true -fd-lock = "4.0.0" +fd-lock = "4.0" parking_lot.workspace = true -regex = "1" +regex.workspace = true serde_json.workspace = true tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } rand.workspace = true -snapbox = { version = "0.6.9", features = ["json", "regex"] } +snapbox = { version = "0.6", features = ["json", "regex"] } [dev-dependencies] tokio.workspace = true diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 4512d7801b6d2..443d44cc110a4 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -36,7 +36,7 @@ reqwest = { workspace = true, features = ["json"] } async-trait.workspace = true futures.workspace = true semver.workspace = true -regex = { version = "1", default-features = false } +regex = { workspace = true, default-features = false } yansi.workspace = true itertools.workspace = true diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 8f6b606b4a117..0de57f0952141 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -27,7 +27,7 @@ alloy-dyn-abi.workspace = true # aws-kms alloy-signer-aws = { workspace = true, features = ["eip712"], optional = true } -aws-config = { version = "1", optional = true } # default-features are necessary +aws-config = { version = "1", optional = true } # default-features are necessary aws-sdk-kms = { version = "1", default-features = false, optional = true } # gcp-kms @@ -39,7 +39,7 @@ gcloud-sdk = { version = "0.25", features = [ async-trait.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } -derive_builder = "0.20.0" +derive_builder = "0.20" eyre.workspace = true rpassword = "7" serde.workspace = true From 58bf161bc9dd6e74de8cb61e3ae23f701feb5512 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:08:19 +0200 Subject: [PATCH 1648/1963] Revert "fix(remappings): check if remapping to add starts with existing remapping name (#9246)" (#9274) This reverts commit 455ba9b1b736766232d84ba1790ac9ba6ca944de. --- crates/config/src/providers/remappings.rs | 10 +++--- crates/forge/tests/cli/config.rs | 38 ----------------------- 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 48e9c875f1ace..2e849bea4eccb 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -46,16 +46,14 @@ impl Remappings { } /// Push an element to the remappings vector, but only if it's not already present. - fn push(&mut self, remapping: Remapping) { + pub fn push(&mut self, remapping: Remapping) { if !self.remappings.iter().any(|existing| { // What we're doing here is filtering for ambiguous paths. For example, if we have - // @prb/=node_modules/@prb/ as existing, and - // @prb/math/=node_modules/@prb/math/src/ as the one being checked, + // @prb/math/=node_modules/@prb/math/src/ as existing, and + // @prb/=node_modules/@prb/ as the one being checked, // we want to keep the already existing one, which is the first one. This way we avoid // having to deal with ambiguous paths which is unwanted when autodetecting remappings. - // Remappings are added from root of the project down to libraries, so - // we want to exclude any conflicting remappings added from libraries. - remapping.name.starts_with(&existing.name) && existing.context == remapping.context + existing.name.starts_with(&remapping.name) && existing.context == remapping.context }) { self.remappings.push(remapping) } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f38dcf414a009..f6ec7c88eddf9 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -595,44 +595,6 @@ forgetest_init!(can_prioritise_closer_lib_remappings, |prj, cmd| { ); }); -// Test that remappings within root of the project have priority over remappings of sub-projects. -// E.g. `@utils/libraries` mapping from library shouldn't be added if project already has `@utils` -// remapping. -// See -forgetest_init!(test_root_remappings_priority, |prj, cmd| { - let mut config = cmd.config(); - // Add `@utils/` remapping in project config. - config.remappings = vec![ - Remapping::from_str("@utils/=src/").unwrap().into(), - Remapping::from_str("@another-utils/libraries/=src/").unwrap().into(), - ]; - let proj_toml_file = prj.paths().root.join("foundry.toml"); - pretty_err(&proj_toml_file, fs::write(&proj_toml_file, config.to_string_pretty().unwrap())); - - // Create a new lib in the `lib` folder with conflicting `@utils/libraries` remapping. - // This should be filtered out from final remappings as root project already has `@utils/`. - let nested = prj.paths().libraries[0].join("dep1"); - pretty_err(&nested, fs::create_dir_all(&nested)); - let mut lib_config = Config::load_with_root(&nested); - lib_config.remappings = vec![ - Remapping::from_str("@utils/libraries/=src/").unwrap().into(), - Remapping::from_str("@another-utils/=src/").unwrap().into(), - ]; - let lib_toml_file = nested.join("foundry.toml"); - pretty_err(&lib_toml_file, fs::write(&lib_toml_file, lib_config.to_string_pretty().unwrap())); - - cmd.args(["remappings", "--pretty"]).assert_success().stdout_eq(str![[r#" -Global: -- @utils/=src/ -- @another-utils/libraries/=src/ -- @another-utils/=lib/dep1/src/ -- dep1/=lib/dep1/src/ -- forge-std/=lib/forge-std/src/ - - -"#]]); -}); - // test to check that foundry.toml libs section updates on install forgetest!(can_update_libs_section, |prj, cmd| { cmd.git_init(); From bcdd514a633e27c29d5c00355311f6432cf31e8a Mon Sep 17 00:00:00 2001 From: Yu Zeng Date: Thu, 7 Nov 2024 20:55:40 +0800 Subject: [PATCH 1649/1963] fix(forge): fix stack overflow when the lib path is absolute. (#9190) * fix(forge): fix stack overflow when the lib path is absolute. * format * add test for setting absolute lib path. * remove useless code: --- crates/config/src/providers/remappings.rs | 2 +- crates/forge/tests/cli/config.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 2e849bea4eccb..11a17a13d175e 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -196,7 +196,7 @@ impl RemappingsProvider<'_> { fn lib_foundry_toml_remappings(&self) -> impl Iterator + '_ { self.lib_paths .iter() - .map(|p| self.root.join(p)) + .map(|p| if p.is_absolute() { self.root.join("lib") } else { self.root.join(p) }) .flat_map(foundry_toml_dirs) .inspect(|lib| { trace!("find all remappings of nested foundry.toml lib: {:?}", lib); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index f6ec7c88eddf9..41fb17410914d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -569,6 +569,25 @@ forgetest_init!(can_detect_lib_foundry_toml, |prj, cmd| { "nested/=lib/nested-lib/lib/nested/".parse().unwrap(), ] ); + + // check if lib path is absolute, it should deteect nested lib + let mut config = cmd.config(); + config.libs = vec![nested]; + + let remappings = config.remappings.iter().cloned().map(Remapping::from).collect::>(); + similar_asserts::assert_eq!( + remappings, + vec![ + // local to the lib + "another-lib/=lib/nested-lib/lib/another-lib/custom-source-dir/".parse().unwrap(), + // global + "forge-std/=lib/forge-std/src/".parse().unwrap(), + "nested-lib/=lib/nested-lib/src/".parse().unwrap(), + // remappings local to the lib + "nested-twice/=lib/nested-lib/lib/another-lib/lib/nested-twice/".parse().unwrap(), + "nested/=lib/nested-lib/lib/nested/".parse().unwrap(), + ] + ); }); // test remappings with closer paths are prioritised From 10a8e8862ca5f9a28edebd9603f985349f536587 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:44:51 +0200 Subject: [PATCH 1650/1963] fix(remappings): ignore remappings of root proj dirs when merging (#9258) * fix(remappings): ignore remappings of root proj dir when merging * Remove unused code * Add test * Update * Load project paths from figment --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/cli/src/opts/build/core.rs | 3 +- crates/config/src/lib.rs | 17 -------- crates/config/src/providers/remappings.rs | 47 +++++++++++++++++++---- crates/forge/tests/cli/config.rs | 36 +++++++++++++++++ 4 files changed, 78 insertions(+), 25 deletions(-) diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 58d0ace85ea2e..d25018ae8df24 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -181,7 +181,8 @@ impl<'a> From<&'a CoreBuildArgs> for Figment { }; // remappings should stack - let mut remappings = Remappings::new_with_remappings(args.project_paths.get_remappings()); + let mut remappings = Remappings::new_with_remappings(args.project_paths.get_remappings()) + .with_figment(&figment); remappings .extend(figment.extract_inner::>("remappings").unwrap_or_default()); figment = figment.merge(("remappings", remappings.into_inner())).merge(args); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 916c77f9bd71a..ec3b4e5ebae74 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1091,23 +1091,6 @@ impl Config { } /// Returns all configured remappings. - /// - /// **Note:** this will add an additional `/=` remapping here, see - /// [Self::get_source_dir_remapping()] - /// - /// So that - /// - /// ```solidity - /// import "./math/math.sol"; - /// import "contracts/tokens/token.sol"; - /// ``` - /// - /// in `contracts/contract.sol` are resolved to - /// - /// ```text - /// contracts/tokens/token.sol - /// contracts/math/math.sol - /// ``` pub fn get_all_remappings(&self) -> impl Iterator + '_ { self.remappings.iter().map(|m| m.clone().into()) } diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 11a17a13d175e..623234f947982 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -1,7 +1,10 @@ -use crate::{foundry_toml_dirs, remappings_from_env_var, remappings_from_newline, Config}; +use crate::{ + foundry_toml_dirs, remappings_from_env_var, remappings_from_newline, utils::get_dir_remapping, + Config, +}; use figment::{ value::{Dict, Map}, - Error, Metadata, Profile, Provider, + Error, Figment, Metadata, Profile, Provider, }; use foundry_compilers::artifacts::remappings::{RelativeRemapping, Remapping}; use std::{ @@ -16,17 +19,35 @@ use std::{ pub struct Remappings { /// Remappings. remappings: Vec, + /// Source, test and script configured project dirs. + /// Remappings of these dirs from libs are ignored. + project_paths: Vec, } impl Remappings { /// Create a new `Remappings` wrapper with an empty vector. pub fn new() -> Self { - Self { remappings: Vec::new() } + Self { remappings: Vec::new(), project_paths: Vec::new() } } /// Create a new `Remappings` wrapper with a vector of remappings. pub fn new_with_remappings(remappings: Vec) -> Self { - Self { remappings } + Self { remappings, project_paths: Vec::new() } + } + + /// Extract project paths that cannot be remapped by dependencies. + pub fn with_figment(mut self, figment: &Figment) -> Self { + let mut add_project_remapping = |path: &str| { + if let Ok(path) = figment.find_value(path) { + if let Some(remapping) = path.into_string().and_then(get_dir_remapping) { + self.project_paths.push(remapping); + } + } + }; + add_project_remapping("src"); + add_project_remapping("test"); + add_project_remapping("script"); + self } /// Filters the remappings vector by name and context. @@ -47,7 +68,7 @@ impl Remappings { /// Push an element to the remappings vector, but only if it's not already present. pub fn push(&mut self, remapping: Remapping) { - if !self.remappings.iter().any(|existing| { + if self.remappings.iter().any(|existing| { // What we're doing here is filtering for ambiguous paths. For example, if we have // @prb/math/=node_modules/@prb/math/src/ as existing, and // @prb/=node_modules/@prb/ as the one being checked, @@ -55,8 +76,20 @@ impl Remappings { // having to deal with ambiguous paths which is unwanted when autodetecting remappings. existing.name.starts_with(&remapping.name) && existing.context == remapping.context }) { - self.remappings.push(remapping) - } + return; + }; + + // Ignore remappings of root project src, test or script dir. + // See . + if self + .project_paths + .iter() + .any(|project_path| remapping.name.eq_ignore_ascii_case(&project_path.name)) + { + return; + }; + + self.remappings.push(remapping); } /// Extend the remappings vector, leaving out the remappings that are already present. diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 41fb17410914d..91e0781afb1d7 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -777,3 +777,39 @@ forgetest!(normalize_config_evm_version, |_prj, cmd| { let config: Config = serde_json::from_str(&output).unwrap(); assert_eq!(config.evm_version, EvmVersion::Istanbul); }); + +// Tests that root paths are properly resolved even if submodule specifies remappings for them. +// See +forgetest_init!(test_submodule_root_path_remappings, |prj, cmd| { + prj.add_script( + "BaseScript.sol", + r#" +import "forge-std/Script.sol"; + +contract BaseScript is Script { +} + "#, + ) + .unwrap(); + prj.add_script( + "MyScript.sol", + r#" +import "script/BaseScript.sol"; + +contract MyScript is BaseScript { +} + "#, + ) + .unwrap(); + + let nested = prj.paths().libraries[0].join("another-dep"); + pretty_err(&nested, fs::create_dir_all(&nested)); + let mut lib_config = Config::load_with_root(&nested); + lib_config.remappings = vec![ + Remapping::from_str("test/=test/").unwrap().into(), + Remapping::from_str("script/=script/").unwrap().into(), + ]; + let lib_toml_file = nested.join("foundry.toml"); + pretty_err(&lib_toml_file, fs::write(&lib_toml_file, lib_config.to_string_pretty().unwrap())); + cmd.forge_fuse().args(["build"]).assert_success(); +}); From adaad3da964b18abaf425c7ce263ad0896a48cb5 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 7 Nov 2024 21:43:23 +0530 Subject: [PATCH 1651/1963] feat(`cheatcodes`): mockCall with bytes4 data (#9267) * feat(`cheatcodes`): mockCall with bytes4 * fix * fix --- crates/cheatcodes/assets/cheatcodes.json | 80 ++++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 29 +++++++++ crates/cheatcodes/src/evm/mock.rs | 67 ++++++++++++++++++++ testdata/cheats/Vm.sol | 4 ++ testdata/default/cheats/MockCall.t.sol | 4 +- 5 files changed, 182 insertions(+), 2 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 79761ae5a0edb..747648080395c 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -6002,6 +6002,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "mockCallRevert_2", + "description": "Reverts a call to an address with specified revert data.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCallRevert(address,bytes4,bytes)", + "selector": "0x2dfba5df", + "selectorBytes": [ + 45, + 251, + 165, + 223 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "mockCallRevert_3", + "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCallRevert(address,uint256,bytes4,bytes)", + "selector": "0x596c8f04", + "selectorBytes": [ + 89, + 108, + 143, + 4 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "mockCall_0", @@ -6042,6 +6082,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "mockCall_2", + "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCall(address callee, bytes4 data, bytes calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCall(address,bytes4,bytes)", + "selector": "0x08e0c537", + "selectorBytes": [ + 8, + 224, + 197, + 55 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "mockCall_3", + "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;", + "visibility": "external", + "mutability": "", + "signature": "mockCall(address,uint256,bytes4,bytes)", + "selector": "0xe7b36a3d", + "selectorBytes": [ + 231, + 179, + 106, + 61 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "mockCalls_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index ce0bc08b05775..b0c0400eb60f0 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -527,6 +527,22 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; + /// Mocks a call to an address, returning specified data. + /// Calldata can either be strict or a partial match, e.g. if you only + /// pass a Solidity selector to the expected calldata, then the entire Solidity + /// function will be mocked. + /// + /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCall(address callee, bytes4 data, bytes calldata returnData) external; + + /// Mocks a call to an address with a specific `msg.value`, returning specified data. + /// Calldata match takes precedence over `msg.value` in case of ambiguity. + /// + /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external; + /// Mocks multiple calls to an address, returning specified data for each call. #[cheatcode(group = Evm, safety = Unsafe)] function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external; @@ -544,6 +560,19 @@ interface Vm { function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; + /// Reverts a call to an address with specified revert data. + /// + /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external; + + /// Reverts a call to an address with a specific `msg.value`, with specified revert data. + /// + /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. + #[cheatcode(group = Evm, safety = Unsafe)] + function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) + external; + /// Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls /// `target` with the same calldata. This functionality is similar to a delegate call made to /// `target` contract from `callee`. diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 50551d179c848..26aae298fa64d 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -65,6 +65,39 @@ impl Cheatcode for mockCall_1Call { } } +impl Cheatcode for mockCall_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, data, returnData } = self; + let _ = make_acc_non_empty(callee, ccx.ecx)?; + + mock_call( + ccx.state, + callee, + &Bytes::from(*data), + None, + returnData, + InstructionResult::Return, + ); + Ok(Default::default()) + } +} + +impl Cheatcode for mockCall_3Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, msgValue, data, returnData } = self; + ccx.ecx.load_account(*callee)?; + mock_call( + ccx.state, + callee, + &Bytes::from(*data), + Some(msgValue), + returnData, + InstructionResult::Return, + ); + Ok(Default::default()) + } +} + impl Cheatcode for mockCalls_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { callee, data, returnData } = self; @@ -104,6 +137,40 @@ impl Cheatcode for mockCallRevert_1Call { } } +impl Cheatcode for mockCallRevert_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, data, revertData } = self; + let _ = make_acc_non_empty(callee, ccx.ecx)?; + + mock_call( + ccx.state, + callee, + &Bytes::from(*data), + None, + revertData, + InstructionResult::Revert, + ); + Ok(Default::default()) + } +} + +impl Cheatcode for mockCallRevert_3Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { callee, msgValue, data, revertData } = self; + let _ = make_acc_non_empty(callee, ccx.ecx)?; + + mock_call( + ccx.state, + callee, + &Bytes::from(*data), + Some(msgValue), + revertData, + InstructionResult::Revert, + ); + Ok(Default::default()) + } +} + impl Cheatcode for mockFunctionCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { callee, target, data } = self; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index b33df8f2dc18a..6b19f26a4ca89 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -294,8 +294,12 @@ interface Vm { function makePersistent(address[] calldata accounts) external; function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; + function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external; + function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external; function mockCall(address callee, bytes calldata data, bytes calldata returnData) external; function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; + function mockCall(address callee, bytes4 data, bytes calldata returnData) external; + function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external; function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external; function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external; function mockFunction(address callee, address target, bytes calldata data) external; diff --git a/testdata/default/cheats/MockCall.t.sol b/testdata/default/cheats/MockCall.t.sol index 940e5e78c6034..f85e9c8239bdc 100644 --- a/testdata/default/cheats/MockCall.t.sol +++ b/testdata/default/cheats/MockCall.t.sol @@ -176,7 +176,7 @@ contract MockCallTest is DSTest { Mock mock = Mock(address(100)); vm.mockCall(address(mock), abi.encodeWithSelector(mock.add.selector), abi.encode(10)); - vm.mockCall(address(mock), abi.encodeWithSelector(mock.noReturnValue.selector), abi.encode()); + vm.mockCall(address(mock), mock.noReturnValue.selector, abi.encode()); assertEq(mock.add(1, 2), 10); mock.noReturnValue(); @@ -197,7 +197,7 @@ contract MockCallRevertTest is DSTest { assertEq(target.numberA(), 1); assertEq(target.numberB(), 2); - vm.mockCallRevert(address(target), abi.encodeWithSelector(target.numberB.selector), ERROR_MESSAGE); + vm.mockCallRevert(address(target), target.numberB.selector, ERROR_MESSAGE); // post-mock assertEq(target.numberA(), 1); From c4a31a624874ab36284fca4e48d2197e43a62fbe Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:03:24 +0200 Subject: [PATCH 1652/1963] feat: update to Soldeer v0.5.0 (#9281) Release 0.5.0 --- Cargo.lock | 11 ++++++----- Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2bfdbb92fcc86..f06b855af1ca8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8196,10 +8196,11 @@ dependencies = [ [[package]] name = "soldeer-commands" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf7e07f2b6002f8410811915a2f6142f2d1084764dd88cba3f4ebf22232975" +checksum = "1925813f3dd013d212fa9ad184911846f99236dbfc8a6d79c8a54dfa0bb1a948" dependencies = [ + "bon", "clap", "cliclack", "derive_more", @@ -8210,9 +8211,9 @@ dependencies = [ [[package]] name = "soldeer-core" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea249d0281f3755c3c2b095ad94a554a782cc29138f46c407b8080cfd3918996" +checksum = "434b034d411ea9d1cd9bd77fa2978a42e4c4ae486f47738a545079f11a32c879" dependencies = [ "bon", "chrono", @@ -9529,7 +9530,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 937419325aa94..7754de503d832 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -278,7 +278,7 @@ semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } similar-asserts = "1.6" -soldeer-commands = "=0.4.1" +soldeer-commands = "=0.5.0" strum = "0.26" tempfile = "3.13" tikv-jemallocator = "0.6" From f3376a6e45ffacd45125e639e5f50bec0c0900be Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 8 Nov 2024 08:57:39 +0200 Subject: [PATCH 1653/1963] fix(`forge test`): record only test fns in test failures (#9286) --- crates/forge/bin/cmd/test/mod.rs | 12 +++++++----- crates/forge/tests/cli/test_cmd.rs | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index c7d928a898a2f..243ce9b226b5b 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -20,7 +20,7 @@ use foundry_cli::{ opts::CoreBuildArgs, utils::{self, LoadConfig}, }; -use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell}; +use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell, TestFunctionExt}; use foundry_compilers::{ artifacts::output_selection::OutputSelection, compilers::{multi::MultiCompilerLanguage, CompilerSettings, Language}, @@ -935,10 +935,12 @@ fn persist_run_failures(config: &Config, outcome: &TestOutcome) { let mut filter = String::new(); let mut failures = outcome.failures().peekable(); while let Some((test_name, _)) = failures.next() { - if let Some(test_match) = test_name.split("(").next() { - filter.push_str(test_match); - if failures.peek().is_some() { - filter.push('|'); + if test_name.is_any_test() { + if let Some(test_match) = test_name.split("(").next() { + filter.push_str(test_match); + if failures.peek().is_some() { + filter.push('|'); + } } } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 8ce502a652b9e..b952e19bd26d3 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -932,6 +932,30 @@ Encountered a total of 2 failing tests, 0 tests succeeded "#]]); }); +// +forgetest_init!(should_not_record_setup_failures, |prj, cmd| { + prj.add_test( + "ReplayFailures.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract SetupFailureTest is Test { + function setUp() public { + require(2 > 1); + } + + function testA() public pure { + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).assert_success(); + // Test failure filter should not be persisted if `setUp` failed. + assert!(!prj.root().join("cache/test-failures").exists()); +}); + // https://github.com/foundry-rs/foundry/issues/7530 forgetest_init!(should_show_precompile_labels, |prj, cmd| { prj.wipe_contracts(); From 91d33495a41530fc5ff78cb5ed26d6d17ade93e0 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 9 Nov 2024 07:40:34 +0200 Subject: [PATCH 1654/1963] fix(coverage): do not report empty constructors, enable reports for `receive` (#9288) fix(coverage): do not report empty constructors, enable reports for receive fn --- crates/evm/coverage/src/analysis.rs | 8 +-- crates/forge/tests/cli/coverage.rs | 92 +++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 4 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index e5eda5262d343..c18ba823b2d0e 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -50,15 +50,15 @@ impl<'a> ContractVisitor<'a> { let name: String = node.attribute("name").ok_or_else(|| eyre::eyre!("Function has no name"))?; - // TODO(onbjerg): Figure out why we cannot find anchors for the receive function let kind: String = node.attribute("kind").ok_or_else(|| eyre::eyre!("Function has no kind"))?; - if kind == "receive" { - return Ok(()) - } match &node.body { Some(body) => { + // Do not add coverage item for constructors without statements. + if kind == "constructor" && !has_statements(body) { + return Ok(()) + } self.push_item_kind(CoverageItemKind::Function { name }, &node.src); self.visit_block(body) } diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 381a31c12c210..0ed272ae2531d 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1321,3 +1321,95 @@ contract AContractTest is DSTest { "#]]); }); + +// +// Test that constructor with no statements is not counted in functions coverage. +forgetest!(test_ignore_empty_constructors_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + constructor() {} + + function increment() public {} +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import "./AContract.sol"; + +contract AContractTest is DSTest { + function test_constructors() public { + AContract a = new AContract(); + a.increment(); + } +} + "#, + ) + .unwrap(); + + // Assert there's only one function (`increment`) reported. + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | +| Total | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | + +"#]]); +}); + +// Test coverage for `receive` functions. +forgetest!(test_receive_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + uint256 public counter = 0; + + constructor() { + counter = 1; + } + + receive() external payable { + counter = msg.value; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import "./AContract.sol"; + +contract AContractTest is DSTest { + function test_constructors() public { + AContract a = new AContract(); + address(a).call{value: 5}(""); + require(a.counter() == 5); + } +} + "#, + ) + .unwrap(); + + // Assert both constructor and receive functions coverage reported. + cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|---------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | + +"#]]); +}); From bb545b1ccea9bd00eabb145008ab4fc78dfa8b47 Mon Sep 17 00:00:00 2001 From: Iain Nash Date: Sat, 9 Nov 2024 05:10:11 -0500 Subject: [PATCH 1655/1963] Make fs read cheatcodes views (#9289) --- crates/cheatcodes/assets/cheatcodes.json | 40 ++++++++++++------------ crates/cheatcodes/spec/src/vm.rs | 20 ++++++------ testdata/cheats/Vm.sol | 20 ++++++------ 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 747648080395c..41797106d6bb0 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4584,9 +4584,9 @@ "func": { "id": "exists", "description": "Returns true if the given path points to an existing entity, else returns false.", - "declaration": "function exists(string calldata path) external returns (bool result);", + "declaration": "function exists(string calldata path) external view returns (bool result);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "exists(string)", "selector": "0x261a323e", "selectorBytes": [ @@ -5304,9 +5304,9 @@ "func": { "id": "getBroadcast", "description": "Returns the most recent broadcast for the given contract on `chainId` matching `txType`.\nFor example:\nThe most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.\nThe most recent call can be fetched by passing `txType` as `CALL`.", - "declaration": "function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary memory);", + "declaration": "function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "getBroadcast(string,uint64,uint8)", "selector": "0x3dc90cb3", "selectorBytes": [ @@ -5324,9 +5324,9 @@ "func": { "id": "getBroadcasts_0", "description": "Returns all broadcasts for the given contract on `chainId` with the specified `txType`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", - "declaration": "function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary[] memory);", + "declaration": "function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "getBroadcasts(string,uint64,uint8)", "selector": "0xf7afe919", "selectorBytes": [ @@ -5344,9 +5344,9 @@ "func": { "id": "getBroadcasts_1", "description": "Returns all broadcasts for the given contract on `chainId`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", - "declaration": "function getBroadcasts(string memory contractName, uint64 chainId) external returns (BroadcastTxSummary[] memory);", + "declaration": "function getBroadcasts(string memory contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "getBroadcasts(string,uint64)", "selector": "0xf2fa4a26", "selectorBytes": [ @@ -5404,9 +5404,9 @@ "func": { "id": "getDeployment_0", "description": "Returns the most recent deployment for the current `chainId`.", - "declaration": "function getDeployment(string memory contractName) external returns (address deployedAddress);", + "declaration": "function getDeployment(string memory contractName) external view returns (address deployedAddress);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "getDeployment(string)", "selector": "0xa8091d97", "selectorBytes": [ @@ -5424,9 +5424,9 @@ "func": { "id": "getDeployment_1", "description": "Returns the most recent deployment for the given contract on `chainId`", - "declaration": "function getDeployment(string memory contractName, uint64 chainId) external returns (address deployedAddress);", + "declaration": "function getDeployment(string memory contractName, uint64 chainId) external view returns (address deployedAddress);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "getDeployment(string,uint64)", "selector": "0x0debd5d6", "selectorBytes": [ @@ -5444,9 +5444,9 @@ "func": { "id": "getDeployments", "description": "Returns all deployments for the given contract on `chainId`\nSorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.\nThe most recent deployment is the first element, and the oldest is the last.", - "declaration": "function getDeployments(string memory contractName, uint64 chainId) external returns (address[] memory deployedAddresses);", + "declaration": "function getDeployments(string memory contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "getDeployments(string,uint64)", "selector": "0x74e133dd", "selectorBytes": [ @@ -5684,9 +5684,9 @@ "func": { "id": "isDir", "description": "Returns true if the path exists on disk and is pointing at a directory, else returns false.", - "declaration": "function isDir(string calldata path) external returns (bool result);", + "declaration": "function isDir(string calldata path) external view returns (bool result);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "isDir(string)", "selector": "0x7d15d019", "selectorBytes": [ @@ -5704,9 +5704,9 @@ "func": { "id": "isFile", "description": "Returns true if the path exists on disk and is pointing at a regular file, else returns false.", - "declaration": "function isFile(string calldata path) external returns (bool result);", + "declaration": "function isFile(string calldata path) external view returns (bool result);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "isFile(string)", "selector": "0xe0eb04d4", "selectorBytes": [ @@ -9892,9 +9892,9 @@ "func": { "id": "unixTime", "description": "Returns the time since unix epoch in milliseconds.", - "declaration": "function unixTime() external returns (uint256 milliseconds);", + "declaration": "function unixTime() external view returns (uint256 milliseconds);", "visibility": "external", - "mutability": "", + "mutability": "view", "signature": "unixTime()", "selector": "0x625387dc", "selectorBytes": [ diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index b0c0400eb60f0..3c11cd53aca3e 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1582,7 +1582,7 @@ interface Vm { /// Returns true if the given path points to an existing entity, else returns false. #[cheatcode(group = Filesystem)] - function exists(string calldata path) external returns (bool result); + function exists(string calldata path) external view returns (bool result); /// Given a path, query the file system to get information about a file, directory, etc. #[cheatcode(group = Filesystem)] @@ -1590,11 +1590,11 @@ interface Vm { /// Returns true if the path exists on disk and is pointing at a directory, else returns false. #[cheatcode(group = Filesystem)] - function isDir(string calldata path) external returns (bool result); + function isDir(string calldata path) external view returns (bool result); /// Returns true if the path exists on disk and is pointing at a regular file, else returns false. #[cheatcode(group = Filesystem)] - function isFile(string calldata path) external returns (bool result); + function isFile(string calldata path) external view returns (bool result); /// Get the path of the current project root. #[cheatcode(group = Filesystem)] @@ -1602,7 +1602,7 @@ interface Vm { /// Returns the time since unix epoch in milliseconds. #[cheatcode(group = Filesystem)] - function unixTime() external returns (uint256 milliseconds); + function unixTime() external view returns (uint256 milliseconds); // -------- Reading and writing -------- @@ -1732,27 +1732,27 @@ interface Vm { /// /// The most recent call can be fetched by passing `txType` as `CALL`. #[cheatcode(group = Filesystem)] - function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary memory); + function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory); /// Returns all broadcasts for the given contract on `chainId` with the specified `txType`. /// /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. #[cheatcode(group = Filesystem)] - function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external returns (BroadcastTxSummary[] memory); + function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory); /// Returns all broadcasts for the given contract on `chainId`. /// /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. #[cheatcode(group = Filesystem)] - function getBroadcasts(string memory contractName, uint64 chainId) external returns (BroadcastTxSummary[] memory); + function getBroadcasts(string memory contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory); /// Returns the most recent deployment for the current `chainId`. #[cheatcode(group = Filesystem)] - function getDeployment(string memory contractName) external returns (address deployedAddress); + function getDeployment(string memory contractName) external view returns (address deployedAddress); /// Returns the most recent deployment for the given contract on `chainId` #[cheatcode(group = Filesystem)] - function getDeployment(string memory contractName, uint64 chainId) external returns (address deployedAddress); + function getDeployment(string memory contractName, uint64 chainId) external view returns (address deployedAddress); /// Returns all deployments for the given contract on `chainId` /// @@ -1760,7 +1760,7 @@ interface Vm { /// /// The most recent deployment is the first element, and the oldest is the last. #[cheatcode(group = Filesystem)] - function getDeployments(string memory contractName, uint64 chainId) external returns (address[] memory deployedAddresses); + function getDeployments(string memory contractName, uint64 chainId) external view returns (address[] memory deployedAddresses); // -------- Foreign Function Interface -------- diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 6b19f26a4ca89..d3a377f403ef0 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -223,7 +223,7 @@ interface Vm { function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value); function etch(address target, bytes calldata newRuntimeBytecode) external; function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) external returns (EthGetLogs[] memory logs); - function exists(string calldata path) external returns (bool result); + 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 expectCall(address callee, bytes calldata data) external; @@ -259,14 +259,14 @@ 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 getBroadcasts(string memory contractName, uint64 chainId) external returns (BroadcastTxSummary[] memory); + function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory); + function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory); + function getBroadcasts(string memory contractName, uint64 chainId) external view 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 getDeployment(string memory contractName) external view returns (address deployedAddress); + function getDeployment(string memory contractName, uint64 chainId) external view returns (address deployedAddress); + function getDeployments(string memory contractName, uint64 chainId) external view 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); @@ -278,8 +278,8 @@ interface Vm { function getWallets() external returns (address[] memory wallets); function indexOf(string calldata input, string calldata key) external pure returns (uint256); function isContext(ForgeContext context) external view returns (bool result); - function isDir(string calldata path) external returns (bool result); - function isFile(string calldata path) external returns (bool result); + function isDir(string calldata path) external view returns (bool result); + function isFile(string calldata path) external view returns (bool result); function isPersistent(address account) external view returns (bool persistent); function keyExists(string calldata json, string calldata key) external view returns (bool); function keyExistsJson(string calldata json, string calldata key) external view returns (bool); @@ -488,7 +488,7 @@ interface Vm { function trim(string calldata input) external pure returns (string memory output); function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result); function txGasPrice(uint256 newGasPrice) external; - function unixTime() external returns (uint256 milliseconds); + function unixTime() external view returns (uint256 milliseconds); function warp(uint256 newTimestamp) external; function writeFile(string calldata path, string calldata data) external; function writeFileBinary(string calldata path, bytes calldata data) external; From 48abbd95e4fd7ea55ee4f1e9b1a590d25d8aab37 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 9 Nov 2024 14:18:28 +0200 Subject: [PATCH 1656/1963] chore: fix clippy (#9291) --- crates/common/src/compile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index d504e1688e64d..1af4d5db6d4cc 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -382,7 +382,7 @@ fn contract_size(artifact: &T, initcode: bool) -> Option { BytecodeObject::Unlinked(unlinked) => { // we don't need to account for placeholders here, because library placeholders take up // 40 characters: `__$$__` which is the same as a 20byte address in hex. - let mut size = unlinked.as_bytes().len(); + let mut size = unlinked.len(); if unlinked.starts_with("0x") { size -= 2; } From 9df593939b995b08eee7dbab585ec368f65c8116 Mon Sep 17 00:00:00 2001 From: feynman <14007952+feynman-x@users.noreply.github.com> Date: Sun, 10 Nov 2024 00:23:14 +0800 Subject: [PATCH 1657/1963] feat(anvil): add `anvil_getIntervalMining` API (#9290) * feat: add anvil_get_interval_mine method * refactor: keep consistent naming --------- Co-authored-by: Your Name Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/anvil/core/src/eth/mod.rs | 4 ++++ crates/anvil/src/eth/api.rs | 9 +++++++++ crates/anvil/src/eth/miner.rs | 7 +++++-- crates/anvil/tests/it/anvil.rs | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 73c133b2c2857..38691ba0d5350 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -394,6 +394,10 @@ pub enum EthRequest { )] SetIntervalMining(u64), + /// Gets the current mining behavior + #[cfg_attr(feature = "serde", serde(rename = "anvil_getIntervalMing", with = "empty_params"))] + GetIntervalMining(()), + /// Removes transactions from the pool #[cfg_attr( feature = "serde", diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 81990d75558b6..e5210b0c23f69 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -326,6 +326,7 @@ impl EthApi { EthRequest::SetIntervalMining(interval) => { self.anvil_set_interval_mining(interval).to_rpc_result() } + EthRequest::GetIntervalMining(()) => self.anvil_get_interval_ming().to_rpc_result(), EthRequest::DropTransaction(tx) => { self.anvil_drop_transaction(tx).await.to_rpc_result() } @@ -1665,6 +1666,14 @@ impl EthApi { Ok(self.miner.is_auto_mine()) } + /// Returns the value of mining interval, if set. + /// + /// Handler for ETH RPC call: `anvil_getIntervalMing` + pub fn anvil_get_interval_ming(&self) -> Result> { + node_info!("anvil_getIntervalMining"); + Ok(self.miner.get_interval()) + } + /// Enables or disables, based on the single boolean argument, the automatic mining of new /// blocks with each new transaction submitted to the network. /// diff --git a/crates/anvil/src/eth/miner.rs b/crates/anvil/src/eth/miner.rs index defb6624a7877..90c4550907fef 100644 --- a/crates/anvil/src/eth/miner.rs +++ b/crates/anvil/src/eth/miner.rs @@ -64,9 +64,12 @@ impl Miner { matches!(*mode, MiningMode::Auto(_)) } - pub fn is_interval(&self) -> bool { + pub fn get_interval(&self) -> Option { let mode = self.mode.read(); - matches!(*mode, MiningMode::FixedBlockTime(_)) + if let MiningMode::FixedBlockTime(ref mm) = *mode { + return Some(mm.interval.period().as_secs()) + } + None } /// Sets the mining mode to operate in diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 5a952da6b2b49..17b94f041ab54 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -12,12 +12,14 @@ async fn test_can_change_mining_mode() { let provider = handle.http_provider(); assert!(api.anvil_get_auto_mine().unwrap()); + assert!(api.anvil_get_interval_ming().unwrap().is_none()); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, 0); api.anvil_set_interval_mining(1).unwrap(); assert!(!api.anvil_get_auto_mine().unwrap()); + assert!(matches!(api.anvil_get_interval_ming().unwrap(), Some(1))); // changing the mining mode will instantly mine a new block tokio::time::sleep(std::time::Duration::from_millis(500)).await; let num = provider.get_block_number().await.unwrap(); @@ -30,6 +32,7 @@ async fn test_can_change_mining_mode() { // assert that no block is mined when the interval is set to 0 api.anvil_set_interval_mining(0).unwrap(); assert!(!api.anvil_get_auto_mine().unwrap()); + assert!(api.anvil_get_interval_ming().unwrap().is_none()); tokio::time::sleep(std::time::Duration::from_millis(1000)).await; let num = provider.get_block_number().await.unwrap(); assert_eq!(num, 1); From d2f92bc35ec67e4db01ea00f5edf439eb92eee5e Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Sat, 9 Nov 2024 17:26:19 +0100 Subject: [PATCH 1658/1963] chore(`common::shell`): finish implementation + enforce in `clippy` (#9268) * enforce for script and verify crates * complete and enforce common shell * permit eprintln! due to circular dependency outside of common path * avoid code duplication --- Cargo.lock | 1 + clippy.toml | 14 ++++---- crates/anvil/tests/it/eip4844.rs | 2 ++ crates/anvil/tests/it/pubsub.rs | 1 + crates/cast/bin/main.rs | 32 +++++++++++++---- crates/cheatcodes/spec/src/lib.rs | 1 + crates/cheatcodes/src/fs.rs | 4 +-- crates/cheatcodes/src/lib.rs | 4 +++ crates/cli/src/utils/cmd.rs | 17 +++++---- crates/common/fmt/src/dynamic.rs | 12 ------- crates/common/fmt/src/lib.rs | 4 +-- crates/common/src/abi.rs | 4 +-- crates/common/src/compile.rs | 18 +++++----- crates/common/src/ens.rs | 4 ++- crates/common/src/selectors.rs | 33 ++++++++--------- crates/common/src/term.rs | 6 ++-- crates/config/src/lib.rs | 4 +++ crates/debugger/src/debugger.rs | 2 +- crates/debugger/src/lib.rs | 3 ++ crates/doc/Cargo.toml | 1 + crates/doc/src/builder.rs | 2 +- crates/doc/src/lib.rs | 3 ++ crates/evm/coverage/src/lib.rs | 5 ++- crates/evm/traces/src/identifier/etherscan.rs | 2 +- crates/evm/traces/src/lib.rs | 3 ++ crates/forge/bin/cmd/install.rs | 6 ++-- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/script/src/execute.rs | 2 +- crates/script/src/runner.rs | 3 +- crates/script/src/simulate.rs | 6 ++-- crates/script/src/verify.rs | 25 ++++++------- crates/test-utils/src/lib.rs | 3 ++ crates/test-utils/src/rpc.rs | 4 +-- crates/test-utils/src/util.rs | 26 +++++++------- crates/verify/src/bytecode.rs | 19 +++++----- crates/verify/src/etherscan/mod.rs | 36 ++++++++++--------- crates/verify/src/sourcify.rs | 12 +++---- crates/verify/src/utils.rs | 13 +++---- crates/verify/src/verify.rs | 9 +++-- 39 files changed, 188 insertions(+), 160 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f06b855af1ca8..a58b409773e90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3424,6 +3424,7 @@ dependencies = [ "derive_more", "eyre", "forge-fmt", + "foundry-common", "foundry-compilers", "foundry-config", "itertools 0.13.0", diff --git a/clippy.toml b/clippy.toml index 3e45486a86f4f..b1756dfd9beff 100644 --- a/clippy.toml +++ b/clippy.toml @@ -3,10 +3,10 @@ msrv = "1.80" # so it is safe to ignore it as well ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] -# disallowed-macros = [ -# # See `foundry_common::shell` -# { path = "std::print", reason = "use `sh_print` or similar macros instead" }, -# { path = "std::eprint", reason = "use `sh_eprint` or similar macros instead" }, -# { path = "std::println", reason = "use `sh_println` or similar macros instead" }, -# { path = "std::eprintln", reason = "use `sh_eprintln` or similar macros instead" }, -# ] +disallowed-macros = [ + # See `foundry_common::shell` + { path = "std::print", reason = "use `sh_print` or similar macros instead" }, + { path = "std::eprint", reason = "use `sh_eprint` or similar macros instead" }, + { path = "std::println", reason = "use `sh_println` or similar macros instead" }, + { path = "std::eprintln", reason = "use `sh_eprintln` or similar macros instead" }, +] diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index a4243ce15f493..2b965087b4c19 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -205,6 +205,7 @@ async fn can_check_blob_fields_on_genesis() { assert_eq!(block.header.excess_blob_gas, Some(0)); } +#[allow(clippy::disallowed_macros)] #[tokio::test(flavor = "multi_thread")] async fn can_correctly_estimate_blob_gas_with_recommended_fillers() { let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); @@ -247,6 +248,7 @@ async fn can_correctly_estimate_blob_gas_with_recommended_fillers() { ); } +#[allow(clippy::disallowed_macros)] #[tokio::test(flavor = "multi_thread")] async fn can_correctly_estimate_blob_gas_with_recommended_fillers_with_signer() { let node_config = NodeConfig::test().with_hardfork(Some(EthereumHardfork::Cancun.into())); diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index a343f7c7089d6..ecfb9b1005f0c 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -247,6 +247,7 @@ async fn test_subscriptions() { assert_eq!(blocks, vec![1, 2, 3]) } +#[allow(clippy::disallowed_macros)] #[tokio::test(flavor = "multi_thread")] async fn test_sub_new_heads_fast() { let (api, handle) = spawn(NodeConfig::test()).await; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 851fcfd774908..cdeaad2d21faf 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -1,6 +1,7 @@ #[macro_use] extern crate tracing; +use alloy_dyn_abi::DynSolValue; use alloy_primitives::{eip191_hash_message, hex, keccak256, Address, B256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, BlockNumberOrTag::Latest}; @@ -12,7 +13,7 @@ use foundry_cli::{handler, utils}; use foundry_common::{ abi::get_event, ens::{namehash, ProviderEnsExt}, - fmt::{format_uint_exp, print_tokens}, + fmt::{format_tokens, format_tokens_raw, format_uint_exp}, fs, selectors::{ decode_calldata, decode_event_topic, decode_function_selector, decode_selectors, @@ -135,11 +136,11 @@ async fn main_args(args: CastArgs) -> Result<()> { } CastSubcommand::ParseUnits { value, unit } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::parse_units(&value, unit)?); + sh_println!("{}", SimpleCast::parse_units(&value, unit)?)?; } CastSubcommand::FormatUnits { value, unit } => { let value = stdin::unwrap_line(value)?; - println!("{}", SimpleCast::format_units(&value, unit)?); + sh_println!("{}", SimpleCast::format_units(&value, unit)?)?; } CastSubcommand::FromWei { value, unit } => { let value = stdin::unwrap_line(value)?; @@ -189,7 +190,7 @@ async fn main_args(args: CastArgs) -> Result<()> { // ABI encoding & decoding CastSubcommand::AbiDecode { sig, calldata, input } => { let tokens = SimpleCast::abi_decode(&sig, &calldata, input)?; - print_tokens(&tokens, shell::is_json()) + print_tokens(&tokens); } CastSubcommand::AbiEncode { sig, packed, args } => { if !packed { @@ -200,14 +201,14 @@ async fn main_args(args: CastArgs) -> Result<()> { } CastSubcommand::CalldataDecode { sig, calldata } => { let tokens = SimpleCast::calldata_decode(&sig, &calldata, true)?; - print_tokens(&tokens, shell::is_json()) + print_tokens(&tokens); } CastSubcommand::CalldataEncode { sig, args } => { sh_println!("{}", SimpleCast::calldata_encode(sig, &args)?)?; } CastSubcommand::StringDecode { data } => { let tokens = SimpleCast::calldata_decode("Any(string)", &data, true)?; - print_tokens(&tokens, shell::is_json()) + print_tokens(&tokens); } CastSubcommand::Interface(cmd) => cmd.run().await?, CastSubcommand::CreationCode(cmd) => cmd.run().await?, @@ -482,7 +483,7 @@ async fn main_args(args: CastArgs) -> Result<()> { }; let tokens = SimpleCast::calldata_decode(sig, &calldata, true)?; - print_tokens(&tokens, shell::is_json()) + print_tokens(&tokens); } CastSubcommand::FourByteEvent { topic } => { let topic = stdin::unwrap_line(topic)?; @@ -618,5 +619,22 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{}", SimpleCast::decode_eof(&eof)?)? } }; + + /// Prints slice of tokens using [`format_tokens`] or [`format_tokens_raw`] depending whether + /// the shell is in JSON mode. + /// + /// This is included here to avoid a cyclic dependency between `fmt` and `common`. + fn print_tokens(tokens: &[DynSolValue]) { + if shell::is_json() { + let tokens: Vec = format_tokens_raw(tokens).collect(); + let _ = sh_println!("{}", serde_json::to_string_pretty(&tokens).unwrap()); + } else { + let tokens = format_tokens(tokens); + tokens.for_each(|t| { + let _ = sh_println!("{t}"); + }); + } + } + Ok(()) } diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index eae2ae0ee9c21..5692dfc48b9cd 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -103,6 +103,7 @@ impl Cheatcodes<'static> { } #[cfg(test)] +#[allow(clippy::disallowed_macros)] mod tests { use super::*; use std::{fs, path::Path}; diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 04af101eb7538..e52aaa688d7ab 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -620,11 +620,11 @@ fn prompt( match rx.recv_timeout(timeout) { Ok(res) => res.map_err(|err| { - println!(); + let _ = sh_println!(); err.to_string().into() }), Err(_) => { - println!(); + let _ = sh_eprintln!(); Err("Prompt timed out".into()) } } diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index ff93b83362364..95d04cab88e31 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -6,8 +6,12 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![allow(elided_lifetimes_in_paths)] // Cheats context uses 3 lifetimes +#[macro_use] +extern crate foundry_common; + #[macro_use] pub extern crate foundry_cheatcodes_spec as spec; + #[macro_use] extern crate tracing; diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 9852f53f1d44c..2ebdc2539dff5 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -128,9 +128,8 @@ pub fn needs_setup(abi: &JsonAbi) -> bool { for setup_fn in setup_fns.iter() { if setup_fn.name != "setUp" { - println!( - "{} Found invalid setup function \"{}\" did you mean \"setUp()\"?", - "Warning:".yellow().bold(), + let _ = sh_warn!( + "Found invalid setup function \"{}\" did you mean \"setUp()\"?", setup_fn.signature() ); } @@ -450,19 +449,19 @@ pub async fn print_traces( ) -> Result<()> { let traces = result.traces.as_mut().expect("No traces found"); - println!("Traces:"); + sh_println!("Traces:")?; for (_, arena) in traces { decode_trace_arena(arena, decoder).await?; - println!("{}", render_trace_arena_with_bytecodes(arena, verbose)); + sh_println!("{}", render_trace_arena_with_bytecodes(arena, verbose))?; } - println!(); + sh_println!()?; if result.success { - println!("{}", "Transaction successfully executed.".green()); + sh_println!("{}", "Transaction successfully executed.".green())?; } else { - println!("{}", "Transaction failed.".red()); + sh_err!("Transaction failed.")?; } - println!("Gas used: {}", result.gas_used); + sh_println!("Gas used: {}", result.gas_used)?; Ok(()) } diff --git a/crates/common/fmt/src/dynamic.rs b/crates/common/fmt/src/dynamic.rs index 498d209f7a328..2ba40286dd108 100644 --- a/crates/common/fmt/src/dynamic.rs +++ b/crates/common/fmt/src/dynamic.rs @@ -132,18 +132,6 @@ pub fn format_tokens_raw(tokens: &[DynSolValue]) -> impl Iterator tokens.iter().map(format_token_raw) } -/// Prints slice of tokens using [`format_tokens`] or [`format_tokens_raw`] depending on `json` -/// parameter. -pub fn print_tokens(tokens: &[DynSolValue], json: bool) { - if json { - let tokens: Vec = format_tokens_raw(tokens).collect(); - println!("{}", serde_json::to_string_pretty(&tokens).unwrap()); - } else { - let tokens = format_tokens(tokens); - tokens.for_each(|t| println!("{t}")); - } -} - /// Pretty-prints the given value into a string suitable for user output. pub fn format_token(value: &DynSolValue) -> String { DynValueDisplay::new(value, false).to_string() diff --git a/crates/common/fmt/src/lib.rs b/crates/common/fmt/src/lib.rs index f6f792e999742..b76016cd45d25 100644 --- a/crates/common/fmt/src/lib.rs +++ b/crates/common/fmt/src/lib.rs @@ -4,9 +4,7 @@ mod console; pub use console::{console_format, ConsoleFmt, FormatSpec}; mod dynamic; -pub use dynamic::{ - format_token, format_token_raw, format_tokens, format_tokens_raw, parse_tokens, print_tokens, -}; +pub use dynamic::{format_token, format_token_raw, format_tokens, format_tokens_raw, parse_tokens}; mod exp; pub use exp::{format_int_exp, format_uint_exp, to_exp_notation}; diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index bcf82b1cddd4c..de9b36219ecdd 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -146,9 +146,9 @@ pub fn find_source( Ok(source) } else { let implementation = metadata.implementation.unwrap(); - println!( + sh_println!( "Contract at {address} is a proxy, trying to fetch source at {implementation}..." - ); + )?; match find_source(client, implementation).await { impl_source @ Ok(_) => impl_source, Err(e) => { diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 1af4d5db6d4cc..4c7e7ba0fcef4 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -127,7 +127,7 @@ impl ProjectCompiler { pub fn compile(mut self, project: &Project) -> Result> { // TODO: Avoid process::exit if !project.paths.has_input_files() && self.files.is_empty() { - println!("Nothing to compile"); + sh_println!("Nothing to compile")?; // nothing to do here std::process::exit(0); } @@ -182,10 +182,10 @@ impl ProjectCompiler { if !quiet { if output.is_unchanged() { - println!("No files changed, compilation skipped"); + sh_println!("No files changed, compilation skipped")?; } else { // print the compiler output / warnings - println!("{output}"); + sh_println!("{output}")?; } self.handle_output(&output); @@ -206,12 +206,14 @@ impl ProjectCompiler { artifacts.entry(version).or_default().push(name); } for (version, names) in artifacts { - println!( + let _ = sh_println!( " compiler version: {}.{}.{}", - version.major, version.minor, version.patch + version.major, + version.minor, + version.patch ); for name in names { - println!(" - {name}"); + let _ = sh_println!(" - {name}"); } } } @@ -219,7 +221,7 @@ impl ProjectCompiler { if print_sizes { // add extra newline if names were already printed if print_names { - println!(); + let _ = sh_println!(); } let mut size_report = SizeReport { contracts: BTreeMap::new() }; @@ -252,7 +254,7 @@ impl ProjectCompiler { .insert(name, ContractInfo { runtime_size, init_size, is_dev_contract }); } - println!("{size_report}"); + let _ = sh_println!("{size_report}"); // TODO: avoid process::exit // exit with error if any contract exceeds the size limit, excluding test contracts. diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index f84ea84cecab2..1c4eadeac5ad1 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -123,7 +123,9 @@ pub trait ProviderEnsExt> { .call() .await .map_err(EnsError::Resolve) - .inspect_err(|e| eprintln!("{e:?}"))? + .inspect_err(|e| { + let _ = sh_eprintln!("{e:?}"); + })? ._0; Ok(addr) } diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 23a272a2a8e34..cd4e2ffd08825 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -492,24 +492,20 @@ pub struct SelectorImportResponse { impl SelectorImportResponse { /// Print info about the functions which were uploaded or already known pub fn describe(&self) { - self.result - .function - .imported - .iter() - .for_each(|(k, v)| println!("Imported: Function {k}: {v}")); - self.result.event.imported.iter().for_each(|(k, v)| println!("Imported: Event {k}: {v}")); - self.result - .function - .duplicated - .iter() - .for_each(|(k, v)| println!("Duplicated: Function {k}: {v}")); - self.result - .event - .duplicated - .iter() - .for_each(|(k, v)| println!("Duplicated: Event {k}: {v}")); - - println!("Selectors successfully uploaded to OpenChain"); + self.result.function.imported.iter().for_each(|(k, v)| { + let _ = sh_println!("Imported: Function {k}: {v}"); + }); + self.result.event.imported.iter().for_each(|(k, v)| { + let _ = sh_println!("Imported: Event {k}: {v}"); + }); + self.result.function.duplicated.iter().for_each(|(k, v)| { + let _ = sh_println!("Duplicated: Function {k}: {v}"); + }); + self.result.event.duplicated.iter().for_each(|(k, v)| { + let _ = sh_println!("Duplicated: Event {k}: {v}"); + }); + + let _ = sh_println!("Selectors successfully uploaded to OpenChain"); } } @@ -579,6 +575,7 @@ pub fn parse_signatures(tokens: Vec) -> ParsedSignatures { } #[cfg(test)] +#[allow(clippy::disallowed_macros)] #[allow(clippy::needless_return)] mod tests { use super::*; diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index 4753b1e416f8a..ead39b5face35 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -72,7 +72,7 @@ impl Spinner { let indicator = self.indicator[self.idx % self.indicator.len()].green(); let indicator = Paint::new(format!("[{indicator}]")).bold(); - print!("\r\x33[2K\r{indicator} {}", self.message); + let _ = sh_print!("\r\x33[2K\r{indicator} {}", self.message); io::stdout().flush().unwrap(); self.idx = self.idx.wrapping_add(1); @@ -112,11 +112,11 @@ impl SpinnerReporter { Ok(SpinnerMsg::Msg(msg)) => { spinner.message(msg); // new line so past messages are not overwritten - println!(); + let _ = sh_println!(); } Ok(SpinnerMsg::Shutdown(ack)) => { // end with a newline - println!(); + let _ = sh_println!(); let _ = ack.send(()); break } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ec3b4e5ebae74..986a0181dd73f 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -933,6 +933,7 @@ impl Config { /// it's missing, unless the `offline` flag is enabled, in which case an error is thrown. /// /// If `solc` is [`SolcReq::Local`] then this will ensure that the path exists. + #[allow(clippy::disallowed_macros)] fn ensure_solc(&self) -> Result, SolcError> { if self.eof { let (tx, rx) = mpsc::channel(); @@ -957,12 +958,14 @@ impl Config { return match rx.recv_timeout(Duration::from_secs(1)) { Ok(res) => res, Err(RecvTimeoutError::Timeout) => { + // `sh_warn!` is a circular dependency, preventing us from using it here. eprintln!( "{}", yansi::Paint::yellow( "Pulling Docker image for eof-solc, this might take some time..." ) ); + rx.recv().expect("sender dropped") } Err(RecvTimeoutError::Disconnected) => panic!("sender dropped"), @@ -4880,6 +4883,7 @@ mod tests { } // a test to print the config, mainly used to update the example config in the README + #[allow(clippy::disallowed_macros)] #[test] #[ignore] fn print_config() { diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index 0e4de437c844a..469225118e30f 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -48,7 +48,7 @@ impl Debugger { let code = match self.try_run_tui() { Ok(ExitReason::CharExit) => 0, Err(e) => { - println!("{e}"); + let _ = sh_eprintln!("{e}"); 1 } }; diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index aa561973cc635..67c9ee9845073 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -5,6 +5,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; diff --git a/crates/doc/Cargo.toml b/crates/doc/Cargo.toml index 00223eb27a3b8..95e26df179cc4 100644 --- a/crates/doc/Cargo.toml +++ b/crates/doc/Cargo.toml @@ -15,6 +15,7 @@ workspace = true [dependencies] forge-fmt.workspace = true +foundry-common.workspace = true foundry-compilers.workspace = true foundry-config.workspace = true diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index 3ec433c395f47..02a23ace5b4d5 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -105,7 +105,7 @@ impl DocBuilder { .collect::>(); if sources.is_empty() { - println!("No sources detected at {}", self.sources.display()); + sh_println!("No sources detected at {}", self.sources.display())?; return Ok(()) } diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index fd8e4d3ba7e64..174c76600d8a0 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -5,6 +5,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 220ab6b41407d..7ac6091232773 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -5,6 +5,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; @@ -237,7 +240,7 @@ impl HitMap { if let (Some(len1), Some(len2)) = (len1, len2) { let len = std::cmp::max(len1.0, len2.0); let ok = hm1.bytecode.0[..*len] == hm2.bytecode.0[..*len]; - println!("consistent_bytecode: {}, {}, {}, {}", ok, len1.0, len2.0, len); + let _ = sh_println!("consistent_bytecode: {}, {}, {}, {}", ok, len1.0, len2.0, len); return ok; } true diff --git a/crates/evm/traces/src/identifier/etherscan.rs b/crates/evm/traces/src/identifier/etherscan.rs index 2af6fbb59f4a5..96e4b69667b32 100644 --- a/crates/evm/traces/src/identifier/etherscan.rs +++ b/crates/evm/traces/src/identifier/etherscan.rs @@ -65,7 +65,7 @@ impl EtherscanIdentifier { // filter out vyper files .filter(|(_, metadata)| !metadata.is_vyper()) .map(|(address, metadata)| async move { - println!("Compiling: {} {address}", metadata.contract_name); + sh_println!("Compiling: {} {address}", metadata.contract_name)?; let root = tempfile::tempdir()?; let root_path = root.path(); let project = etherscan_project(metadata, root_path)?; diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index dd4a8966481ab..18136c481e7c9 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -5,6 +5,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 31637b90ccd3f..2024b3d23fefc 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -97,10 +97,8 @@ impl DependencyInstallOpts { let _ = sh_println!("Missing dependencies found. Installing now...\n"); self.no_commit = true; if self.install(config, Vec::new()).is_err() { - let _ = sh_warn!( - "{}", - "Your project has missing dependencies that could not be installed." - ); + let _ = + sh_warn!("Your project has missing dependencies that could not be installed."); } true } else { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 243ce9b226b5b..091599305dd86 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -908,7 +908,7 @@ fn list(runner: MultiContractRunner, filter: &ProjectPathsAwareFilter) -> Result let results = runner.list(filter); if shell::is_json() { - println!("{}", serde_json::to_string(&results)?); + sh_println!("{}", serde_json::to_string(&results)?)?; } else { for (file, contracts) in results.iter() { sh_println!("{file}")?; diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 97555694a6910..51ab0141456b8 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -255,7 +255,7 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855", .map(|(_, chain)| *chain as u64) .format(", ") ); - sh_warn!("{}", msg)?; + sh_warn!("{msg}")?; } Ok(()) } diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index 51b1018475dd0..a7d950690b92d 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -13,7 +13,6 @@ use foundry_evm::{ traces::{TraceKind, Traces}, }; use std::collections::VecDeque; -use yansi::Paint; /// Drives script execution #[derive(Debug)] @@ -248,7 +247,7 @@ impl ScriptRunner { Ok(DeployResult { address, raw }) => (address, raw), Err(EvmError::Execution(err)) => { let ExecutionErr { raw, reason } = *err; - println!("{}", format!("\nFailed with `{reason}`:\n").red()); + sh_err!("Failed with `{reason}`:\n")?; (Address::ZERO, raw) } Err(e) => eyre::bail!("Failed deploying contract: {e:?}"), diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 720b970af4082..f8f9c9a3662fb 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -151,8 +151,8 @@ impl PreSimulationState { .collect::>(); if self.script_config.evm_opts.verbosity > 3 { - println!("=========================="); - println!("Simulated On-chain Traces:\n"); + sh_println!("==========================")?; + sh_println!("Simulated On-chain Traces:\n")?; } let mut abort = false; @@ -163,7 +163,7 @@ impl PreSimulationState { if tx.is_none() || self.script_config.evm_opts.verbosity > 3 { for (_, trace) in &mut traces { decode_trace_arena(trace, &self.execution_artifacts.decoder).await?; - println!("{}", render_trace_arena(trace)); + sh_println!("{}", render_trace_arena(trace))?; } } diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 74cc4a3f94925..c013ee8628b97 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -12,7 +12,6 @@ use foundry_common::ContractsByArtifact; use foundry_compilers::{info::ContractInfo, Project}; use foundry_config::{Chain, Config}; use semver::Version; -use yansi::Paint; /// State after we have broadcasted the script. /// It is assumed that at this point [BroadcastedState::sequence] contains receipts for all @@ -218,13 +217,15 @@ async fn verify_contracts( let num_verifications = future_verifications.len(); let mut num_of_successful_verifications = 0; - println!("##\nStart verification for ({num_verifications}) contracts"); + sh_println!("##\nStart verification for ({num_verifications}) contracts")?; for verification in future_verifications { match verification.await { Ok(_) => { num_of_successful_verifications += 1; } - Err(err) => eprintln!("Error during verification: {err:#}"), + Err(err) => { + sh_err!("Failed to verify contract: {err:#}")?; + } } } @@ -232,7 +233,7 @@ async fn verify_contracts( return Err(eyre!("Not all ({num_of_successful_verifications} / {num_verifications}) contracts were verified!")) } - println!("All ({num_verifications}) contracts were verified!"); + sh_println!("All ({num_verifications}) contracts were verified!")?; } Ok(()) @@ -244,15 +245,9 @@ fn check_unverified( verify: VerifyBundle, ) { if !unverifiable_contracts.is_empty() { - println!( - "\n{}", - format!( - "We haven't found any matching bytecode for the following contracts: {:?}.\n\n{}", - unverifiable_contracts, - "This may occur when resuming a verification, but the underlying source code or compiler version has changed." - ) - .yellow() - .bold(), + let _ = sh_warn!( + "We haven't found any matching bytecode for the following contracts: {:?}.\n\nThis may occur when resuming a verification, but the underlying source code or compiler version has changed.", + unverifiable_contracts ); if let Some(commit) = &sequence.commit { @@ -263,7 +258,9 @@ fn check_unverified( .unwrap_or_default(); if ¤t_commit != commit { - println!("\tScript was broadcasted on commit `{commit}`, but we are at `{current_commit}`."); + let _ = sh_warn!( + "Script was broadcasted on commit `{commit}`, but we are at `{current_commit}`." + ); } } } diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 0fcfb621610a6..9d4316b419649 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -5,6 +5,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[macro_use] +extern crate foundry_common; + #[macro_use] extern crate tracing; diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index a9ff6a7e62a2d..7f0742143e4ce 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -177,7 +177,7 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { } #[cfg(test)] -#[allow(clippy::needless_return)] +#[allow(clippy::needless_return, clippy::disallowed_macros)] mod tests { use super::*; use alloy_primitives::address; @@ -190,7 +190,7 @@ mod tests { let mut first_abi = None; let mut failed = Vec::new(); for (i, &key) in ETHERSCAN_MAINNET_KEYS.iter().enumerate() { - eprintln!("trying key {i} ({key})"); + println!("trying key {i} ({key})"); let client = foundry_block_explorers::Client::builder() .chain(Chain::mainnet()) diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 11757978a3c52..9603ca3a20688 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -141,7 +141,7 @@ impl ExtTester { pub fn run(&self) { // Skip fork tests if the RPC url is not set. if self.fork_block.is_some() && std::env::var_os("ETH_RPC_URL").is_none() { - eprintln!("ETH_RPC_URL is not set; skipping"); + let _ = sh_eprintln!("ETH_RPC_URL is not set; skipping"); return; } @@ -159,7 +159,7 @@ impl ExtTester { if self.rev.is_empty() { let mut git = Command::new("git"); git.current_dir(root).args(["log", "-n", "1"]); - eprintln!("$ {git:?}"); + let _ = sh_println!("$ {git:?}"); let output = git.output().unwrap(); if !output.status.success() { panic!("git log failed: {output:?}"); @@ -170,7 +170,7 @@ impl ExtTester { } else { let mut git = Command::new("git"); git.current_dir(root).args(["checkout", self.rev]); - eprintln!("$ {git:?}"); + let _ = sh_println!("$ {git:?}"); let status = git.status().unwrap(); if !status.success() { panic!("git checkout failed: {status}"); @@ -181,15 +181,17 @@ impl ExtTester { for install_command in &self.install_commands { let mut install_cmd = Command::new(&install_command[0]); install_cmd.args(&install_command[1..]).current_dir(root); - eprintln!("cd {root}; {install_cmd:?}"); + let _ = sh_println!("cd {root}; {install_cmd:?}"); match install_cmd.status() { Ok(s) => { - eprintln!("\n\n{install_cmd:?}: {s}"); + let _ = sh_println!("\n\n{install_cmd:?}: {s}"); if s.success() { break; } } - Err(e) => eprintln!("\n\n{install_cmd:?}: {e}"), + Err(e) => { + let _ = sh_eprintln!("\n\n{install_cmd:?}: {e}"); + } } } @@ -223,7 +225,7 @@ impl ExtTester { /// runs each test in a separate process. Instead, we use a global lock file to ensure that only one /// test can initialize the template at a time. pub fn initialize(target: &Path) { - eprintln!("initializing {}", target.display()); + let _ = sh_println!("initializing {}", target.display()); let tpath = TEMPLATE_PATH.as_path(); pretty_err(tpath, fs::create_dir_all(tpath)); @@ -251,7 +253,7 @@ pub fn initialize(target: &Path) { if data != "1" { // Initialize and build. let (prj, mut cmd) = setup_forge("template", foundry_compilers::PathStyle::Dapptools); - eprintln!("- initializing template dir in {}", prj.root().display()); + let _ = sh_println!("- initializing template dir in {}", prj.root().display()); cmd.args(["init", "--force"]).assert_success(); // checkout forge-std @@ -281,7 +283,7 @@ pub fn initialize(target: &Path) { _read = Some(lock.read().unwrap()); } - eprintln!("- copying template dir from {}", tpath.display()); + let _ = sh_println!("- copying template dir from {}", tpath.display()); pretty_err(target, fs::create_dir_all(target)); pretty_err(target, copy_dir(tpath, target)); } @@ -291,12 +293,12 @@ pub fn clone_remote(repo_url: &str, target_dir: &str) { let mut cmd = Command::new("git"); cmd.args(["clone", "--no-tags", "--recursive", "--shallow-submodules"]); cmd.args([repo_url, target_dir]); - eprintln!("{cmd:?}"); + let _ = sh_println!("{cmd:?}"); let status = cmd.status().unwrap(); if !status.success() { panic!("git clone failed: {status}"); } - eprintln!(); + let _ = sh_println!(); } /// Setup an empty test project and return a command pointing to the forge @@ -922,7 +924,7 @@ impl TestCommand { #[track_caller] pub fn try_execute(&mut self) -> std::io::Result { - eprintln!("executing {:?}", self.cmd); + let _ = sh_println!("executing {:?}", self.cmd); let mut child = self.cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::piped()).spawn()?; if let Some(fun) = self.stdin_fun.take() { diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index a4f368a961f7a..a8fc1ace70668 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -22,7 +22,6 @@ use foundry_config::{figment, impl_figment_convert, Config}; use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, utils::configure_tx_env}; use revm_primitives::AccountInfo; use std::path::PathBuf; -use yansi::Paint; impl_figment_convert!(VerifyBytecodeArgs); @@ -142,11 +141,11 @@ impl VerifyBytecodeArgs { } if !shell::is_json() { - println!( + sh_println!( "Verifying bytecode for contract {} at address {}", - self.contract.name.clone().green(), - self.address.green() - ); + self.contract.name, + self.address + )?; } let mut json_results: Vec = vec![]; @@ -212,12 +211,10 @@ impl VerifyBytecodeArgs { if maybe_predeploy { if !shell::is_json() { - println!( - "{}", - format!("Attempting to verify predeployed contract at {:?}. Ignoring creation code verification.", self.address) - .yellow() - .bold() - ) + sh_warn!( + "Attempting to verify predeployed contract at {:?}. Ignoring creation code verification.", + self.address + )?; } // Append constructor args to the local_bytecode. diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 9b5b1fa345d31..ae1443962af66 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -65,11 +65,11 @@ impl VerificationProvider for EtherscanVerificationProvider { if !args.skip_is_verified_check && self.is_contract_verified(ðerscan, &verify_args).await? { - println!( + sh_println!( "\nContract [{}] {:?} is already verified. Skipping verification.", verify_args.contract_name, verify_args.address.to_checksum(None) - ); + )?; return Ok(()) } @@ -79,10 +79,11 @@ impl VerificationProvider for EtherscanVerificationProvider { let retry: Retry = args.retry.into(); let resp = retry .run_async(|| async { - println!( + sh_println!( "\nSubmitting verification for [{}] {}.", - verify_args.contract_name, verify_args.address - ); + verify_args.contract_name, + verify_args.address + )?; let resp = etherscan .submit_contract_verification(&verify_args) .await @@ -109,10 +110,12 @@ impl VerificationProvider for EtherscanVerificationProvider { } warn!("Failed verify submission: {:?}", resp); - eprintln!( - "Encountered an error verifying this contract:\nResponse: `{}`\nDetails: `{}`", - resp.message, resp.result - ); + sh_err!( + "Encountered an error verifying this contract:\nResponse: `{}`\nDetails: + `{}`", + resp.message, + resp.result + )?; std::process::exit(1); } @@ -121,12 +124,12 @@ impl VerificationProvider for EtherscanVerificationProvider { .await?; if let Some(resp) = resp { - println!( + sh_println!( "Submitted contract for verification:\n\tResponse: `{}`\n\tGUID: `{}`\n\tURL: {}", resp.message, resp.result, etherscan.address_url(args.address) - ); + )?; if args.watch { let check_args = VerifyCheckArgs { @@ -139,7 +142,7 @@ impl VerificationProvider for EtherscanVerificationProvider { return self.check(check_args).await } } else { - println!("Contract source code already verified"); + sh_println!("Contract source code already verified")?; } Ok(()) @@ -166,9 +169,10 @@ impl VerificationProvider for EtherscanVerificationProvider { trace!(?resp, "Received verification response"); - eprintln!( + let _ = sh_println!( "Contract verification status:\nResponse: `{}`\nDetails: `{}`", - resp.message, resp.result + resp.message, + resp.result ); if resp.result == "Pending in queue" { @@ -180,7 +184,7 @@ impl VerificationProvider for EtherscanVerificationProvider { } if resp.result == "Already Verified" { - println!("Contract source code already verified"); + let _ = sh_println!("Contract source code already verified"); return Ok(()) } @@ -189,7 +193,7 @@ impl VerificationProvider for EtherscanVerificationProvider { } if resp.result == "Pass - Verified" { - println!("Contract successfully verified"); + let _ = sh_println!("Contract successfully verified"); } Ok(()) diff --git a/crates/verify/src/sourcify.rs b/crates/verify/src/sourcify.rs index 9dbe027efe1a2..b215fd1afe69c 100644 --- a/crates/verify/src/sourcify.rs +++ b/crates/verify/src/sourcify.rs @@ -40,11 +40,11 @@ impl VerificationProvider for SourcifyVerificationProvider { let resp = retry .run_async(|| { async { - println!( + sh_println!( "\nSubmitting verification for [{}] {:?}.", context.target_name, args.address.to_string() - ); + )?; let response = client .post(args.verifier.verifier_url.as_deref().unwrap_or(SOURCIFY_URL)) .header("Content-Type", "application/json") @@ -145,15 +145,15 @@ impl SourcifyVerificationProvider { match response.status.as_str() { "perfect" => { if let Some(ts) = &response.storage_timestamp { - println!("Contract source code already verified. Storage Timestamp: {ts}"); + sh_println!("Contract source code already verified. Storage Timestamp: {ts}")?; } else { - println!("Contract successfully verified"); + sh_println!("Contract successfully verified")?; } } "partial" => { - println!("The recompiled contract partially matches the deployed version"); + sh_println!("The recompiled contract partially matches the deployed version")?; } - "false" => println!("Contract source code is not verified"), + "false" => sh_println!("Contract source code is not verified")?, s => eyre::bail!("Unknown status from sourcify. Status: {s:?}"), } Ok(()) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index e3065aca08539..19c63e7fb3eca 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -145,7 +145,7 @@ pub fn print_result( ) { if let Some(res) = res { if !shell::is_json() { - println!( + let _ = sh_println!( "{} with status {}", format!("{bytecode_type:?} code matched").green().bold(), res.green().bold() @@ -155,17 +155,12 @@ pub fn print_result( json_results.push(json_res); } } else if !shell::is_json() { - println!( - "{}", - format!( - "{bytecode_type:?} code did not match - this may be due to varying compiler settings" - ) - .red() - .bold() + let _ = sh_err!( + "{bytecode_type:?} code did not match - this may be due to varying compiler settings" ); let mismatches = find_mismatch_in_settings(etherscan_config, config); for mismatch in mismatches { - println!("{}", mismatch.red().bold()); + let _ = sh_eprintln!("{}", mismatch.red().bold()); } } else { let json_res = JsonResult { diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index 4a3abaa36cdc7..5f3e55329d888 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -197,12 +197,12 @@ impl VerifyArgs { let args = EtherscanVerificationProvider::default() .create_verify_request(&self, &context) .await?; - println!("{}", args.source); + sh_println!("{}", args.source)?; return Ok(()) } let verifier_url = self.verifier.verifier_url.clone(); - println!("Start verifying contract `{}` deployed on {chain}", self.address); + sh_println!("Start verifying contract `{}` deployed on {chain}", self.address)?; self.verifier.verifier.client(&self.etherscan.key())?.verify(self, context).await.map_err(|err| { if let Some(verifier_url) = verifier_url { match Url::parse(&verifier_url) { @@ -333,7 +333,10 @@ impl_figment_convert_cast!(VerifyCheckArgs); impl VerifyCheckArgs { /// Run the verify command to submit the contract's source code for verification on etherscan pub async fn run(self) -> Result<()> { - println!("Checking verification status on {}", self.etherscan.chain.unwrap_or_default()); + sh_println!( + "Checking verification status on {}", + self.etherscan.chain.unwrap_or_default() + )?; self.verifier.verifier.client(&self.etherscan.key())?.check(self).await } } From 896794a21aef9326b3350ae243fb6d91ea945d65 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 9 Nov 2024 19:04:49 +0200 Subject: [PATCH 1659/1963] chore: typo anvil_getIntervalMing -> anvil_getIntervalMining (#9292) chore: typo anvil_getIntervalMining --- crates/anvil/core/src/eth/mod.rs | 5 ++++- crates/anvil/src/eth/api.rs | 6 +++--- crates/anvil/tests/it/anvil.rs | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 38691ba0d5350..33ffda6a701fa 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -395,7 +395,10 @@ pub enum EthRequest { SetIntervalMining(u64), /// Gets the current mining behavior - #[cfg_attr(feature = "serde", serde(rename = "anvil_getIntervalMing", with = "empty_params"))] + #[cfg_attr( + feature = "serde", + serde(rename = "anvil_getIntervalMining", with = "empty_params") + )] GetIntervalMining(()), /// Removes transactions from the pool diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index e5210b0c23f69..6ee7c6d6014ab 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -326,7 +326,7 @@ impl EthApi { EthRequest::SetIntervalMining(interval) => { self.anvil_set_interval_mining(interval).to_rpc_result() } - EthRequest::GetIntervalMining(()) => self.anvil_get_interval_ming().to_rpc_result(), + EthRequest::GetIntervalMining(()) => self.anvil_get_interval_mining().to_rpc_result(), EthRequest::DropTransaction(tx) => { self.anvil_drop_transaction(tx).await.to_rpc_result() } @@ -1668,8 +1668,8 @@ impl EthApi { /// Returns the value of mining interval, if set. /// - /// Handler for ETH RPC call: `anvil_getIntervalMing` - pub fn anvil_get_interval_ming(&self) -> Result> { + /// Handler for ETH RPC call: `anvil_getIntervalMining`. + pub fn anvil_get_interval_mining(&self) -> Result> { node_info!("anvil_getIntervalMining"); Ok(self.miner.get_interval()) } diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 17b94f041ab54..65eeac70baf77 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -12,14 +12,14 @@ async fn test_can_change_mining_mode() { let provider = handle.http_provider(); assert!(api.anvil_get_auto_mine().unwrap()); - assert!(api.anvil_get_interval_ming().unwrap().is_none()); + assert!(api.anvil_get_interval_mining().unwrap().is_none()); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, 0); api.anvil_set_interval_mining(1).unwrap(); assert!(!api.anvil_get_auto_mine().unwrap()); - assert!(matches!(api.anvil_get_interval_ming().unwrap(), Some(1))); + assert!(matches!(api.anvil_get_interval_mining().unwrap(), Some(1))); // changing the mining mode will instantly mine a new block tokio::time::sleep(std::time::Duration::from_millis(500)).await; let num = provider.get_block_number().await.unwrap(); @@ -32,7 +32,7 @@ async fn test_can_change_mining_mode() { // assert that no block is mined when the interval is set to 0 api.anvil_set_interval_mining(0).unwrap(); assert!(!api.anvil_get_auto_mine().unwrap()); - assert!(api.anvil_get_interval_ming().unwrap().is_none()); + assert!(api.anvil_get_interval_mining().unwrap().is_none()); tokio::time::sleep(std::time::Duration::from_millis(1000)).await; let num = provider.get_block_number().await.unwrap(); assert_eq!(num, 1); From 765969d1612aa63283859f69d616983113b2c484 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2024 02:53:07 +0000 Subject: [PATCH 1660/1963] chore(deps): weekly `cargo update` (#9293) Locking 61 packages to latest compatible versions Updating allocator-api2 v0.2.18 -> v0.2.19 Updating alloy-chains v0.1.46 -> v0.1.47 Updating anyhow v1.0.92 -> v1.0.93 Updating arbitrary v1.3.2 -> v1.4.1 Updating aws-config v1.5.9 -> v1.5.10 Updating aws-sdk-kms v1.49.0 -> v1.50.0 Updating aws-sdk-sso v1.48.0 -> v1.49.0 Updating aws-sdk-ssooidc v1.49.0 -> v1.50.0 Updating aws-sdk-sts v1.48.0 -> v1.49.0 Updating aws-smithy-runtime-api v1.7.2 -> v1.7.3 Updating aws-smithy-types v1.2.8 -> v1.2.9 Updating cc v1.1.36 -> v1.1.37 Updating clap_complete v4.5.36 -> v4.5.37 Updating derive_arbitrary v1.3.2 -> v1.4.1 Updating fastrand v2.1.1 -> v2.2.0 Downgrading fs4 v0.10.0 -> v0.9.1 Updating gcloud-sdk v0.25.7 -> v0.25.8 Updating handlebars v5.1.2 -> v6.2.0 Updating hyper-timeout v0.5.1 -> v0.5.2 Adding icu_collections v1.5.0 Adding icu_locid v1.5.0 Adding icu_locid_transform v1.5.0 Adding icu_locid_transform_data v1.5.0 Adding icu_normalizer v1.5.0 Adding icu_normalizer_data v1.5.0 Adding icu_properties v1.5.1 Adding icu_properties_data v1.5.0 Adding icu_provider v1.5.0 Adding icu_provider_macros v1.5.0 Updating idna v0.5.0 -> v1.0.3 Adding idna_adapter v1.2.0 Updating libc v0.2.161 -> v0.2.162 Adding litemap v0.7.3 Updating mdbook v0.4.40 -> v0.4.42 Updating newtype-uuid v1.1.2 -> v1.1.3 Adding num-modular v0.6.1 Adding num-order v1.2.0 Updating quinn-udp v0.5.6 -> v0.5.7 Updating security-framework-sys v2.12.0 -> v2.12.1 Updating serial_test v3.1.1 -> v3.2.0 Updating serial_test_derive v3.1.1 -> v3.2.0 Updating snapbox v0.6.19 -> v0.6.20 Adding stable_deref_trait v1.2.0 Downgrading svm-rs v0.5.8 -> v0.5.7 (available: v0.5.8) Downgrading svm-rs-builds v0.5.8 -> v0.5.7 (available: v0.5.8) Adding synstructure v0.13.1 Updating tempfile v3.13.0 -> v3.14.0 Adding tinystr v0.7.6 Updating tokio v1.41.0 -> v1.41.1 Updating tracy-client-sys v0.24.1 -> v0.24.2 Removing unicode-bidi v0.3.17 Updating url v2.5.2 -> v2.5.3 Adding utf16_iter v1.0.5 Adding utf8_iter v1.0.4 Adding write16 v1.0.0 Adding writeable v0.5.5 Adding yoke v0.7.4 Adding yoke-derive v0.7.4 Adding zerofrom v0.1.4 Adding zerofrom-derive v0.1.4 Adding zerovec v0.10.4 Adding zerovec-derive v0.10.3 note: pass `--verbose` to see 42 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 416 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 340 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a58b409773e90..b18148fe967b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,15 +68,15 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" [[package]] name = "alloy-chains" -version = "0.1.46" +version = "0.1.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836cf02383d9ebb35502d379bcd1ae803155094077eaab9c29131d888cd5fa3e" +checksum = "18c5c520273946ecf715c0010b4e3503d7eba9893cd9ce6b7fff5654c4a3c470" dependencies = [ "alloy-primitives", "num_enum", @@ -972,15 +972,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" dependencies = [ "derive_arbitrary", ] @@ -1261,9 +1261,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.9" +version = "1.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6448cfb224dd6a9b9ac734f58622dd0d4751f3589f3b777345745f46b2eb14" +checksum = "9b49afaa341e8dd8577e1a2200468f98956d6eda50bcf4a53246cc00174ba924" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1328,9 +1328,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4c89f1d2e0df99ccd21f98598c1e587ad78bd87ae22a74aba392b5566bb038" +checksum = "bfd059dacda4dfd5b57f2bd453fc6555f9acb496cb77508d517da24cf5d73167" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1350,9 +1350,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.48.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded855583fa1d22e88fe39fd6062b062376e50a8211989e07cf5e38d52eb3453" +checksum = "09677244a9da92172c8dc60109b4a9658597d4d298b188dd0018b6a66b410ca4" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1372,9 +1372,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9177ea1192e6601ae16c7273385690d88a7ed386a00b74a6bc894d12103cd933" +checksum = "81fea2f3a8bb3bd10932ae7ad59cc59f65f270fc9183a7e91f501dc5efbef7ee" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1394,9 +1394,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.48.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "823ef553cf36713c97453e2ddff1eb8f62be7f4523544e2a5db64caf80100f0a" +checksum = "53dcf5e7d9bd1517b8b998e170e650047cea8a2b85fe1835abe3210713e541b7" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1517,9 +1517,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.7.2" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e086682a53d3aa241192aa110fa8dfce98f2f5ac2ead0de84d41582c7e8fdb96" +checksum = "92165296a47a812b267b4f41032ff8069ab7ff783696d217f0994a0d7ab585cd" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1534,9 +1534,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.8" +version = "1.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c9cdc179e6afbf5d391ab08c85eac817b51c87e1892a5edb5f7bbdc64314b4" +checksum = "4fbd94a32b3a7d55d3806fe27d98d3ad393050439dd05eb53ece36ec5e3d3510" dependencies = [ "base64-simd", "bytes", @@ -1998,9 +1998,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.36" +version = "1.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" +checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" dependencies = [ "shlex", ] @@ -2137,9 +2137,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.36" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86bc73de94bc81e52f3bebec71bc4463e9748f7a59166663e32044669577b0e2" +checksum = "11611dca53440593f38e6b25ec629de50b14cdfa63adc0fb856115a2c6d97595" dependencies = [ "clap", ] @@ -2659,9 +2659,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", @@ -3196,9 +3196,9 @@ checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fastrlp" @@ -4168,9 +4168,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "fs4" -version = "0.10.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec6fcfb3c0c1d71612528825042261419d5dade9678c39a781e05b63677d9b32" +checksum = "e8c6b3bd49c37d2aa3f3f2220233b29a7cd23f79d1fe70e5337d25fb390793de" dependencies = [ "rustix", "windows-sys 0.52.0", @@ -4304,9 +4304,9 @@ checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" [[package]] name = "gcloud-sdk" -version = "0.25.7" +version = "0.25.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1130d4e37435a63bd9d968a33c11b64bf35a2013779a353e29cd3598989d39" +checksum = "0775bfa745cdf7287ae9765a685a813b91049b6b6d5ca3de20a3d5d16a80d8b2" dependencies = [ "async-trait", "bytes", @@ -4676,11 +4676,12 @@ dependencies = [ [[package]] name = "handlebars" -version = "5.1.2" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" +checksum = "fd4ccde012831f9a071a637b0d4e31df31c0f6c525784b35ae76a9ac6bc1e315" dependencies = [ "log", + "num-order", "pest", "pest_derive", "serde", @@ -4967,9 +4968,9 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ "hyper 1.5.0", "hyper-util", @@ -5036,6 +5037,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -5044,12 +5163,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -5462,9 +5592,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libdbus-sys" @@ -5511,6 +5641,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -5608,9 +5744,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45a38e19bd200220ef07c892b0157ad3d2365e5b5a267ca01ad12182491eea5" +checksum = "7624879735513024d323e7267a0b3a7176aceb0db537939beb4ee31d9e8945e3" dependencies = [ "ammonia", "anyhow", @@ -5808,9 +5944,9 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "newtype-uuid" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4933943834e236c864a48aefdc2da43885dbd5eb77bff3ab20f31e0c3146f5" +checksum = "4c8781e2ef64806278a55ad223f0bc875772fd40e1fe6e73e8adbf027817229d" dependencies = [ "uuid 1.11.0", ] @@ -5990,6 +6126,21 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-modular" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f" + +[[package]] +name = "num-order" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" +dependencies = [ + "num-modular", +] + [[package]] name = "num-rational" version = "0.4.2" @@ -6953,9 +7104,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e346e016eacfff12233c243718197ca12f148c84e1e84268a896699b41c71780" +checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" dependencies = [ "cfg_aliases 0.2.1", "libc", @@ -7810,9 +7961,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -7949,9 +8100,9 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" dependencies = [ "futures", "log", @@ -7963,9 +8114,9 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", @@ -8148,9 +8299,9 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "snapbox" -version = "0.6.19" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881f1849454828a68363dd288b7a0a071e55e2a4356d2c38b567db18a9be0d9f" +checksum = "1373ce406dfad473059bbc31d807715642182bbc952a811952b58d1c9e41dcfa" dependencies = [ "anstream", "anstyle", @@ -8260,6 +8411,12 @@ dependencies = [ "der", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -8356,9 +8513,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.8" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "040017ebc08d781c457a3bfe9c5c2a99f902f8133eb91ef82b7876b053962ece" +checksum = "4aebac1b1ef2b46e2e2bdf3c09db304800f2a77c1fa902bd5231490203042be8" dependencies = [ "const-hex", "dirs 5.0.1", @@ -8376,9 +8533,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.8" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a76fff24884135e66485c726e46b90d7ced3118786b244d05df9ea8aeac8b1b" +checksum = "f2fa0f145894cb4d1c14446f08098ee5f21fc37ccbd1a7dd9dd355bbc806de3b" dependencies = [ "build_const", "const-hex", @@ -8436,6 +8593,17 @@ dependencies = [ "futures-core", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "tap" version = "1.0.1" @@ -8444,9 +8612,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -8618,6 +8786,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -8635,9 +8813,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -9010,11 +9188,12 @@ dependencies = [ [[package]] name = "tracy-client-sys" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68613466112302fdbeabc5fa55f7d57462a0b247d5a6b7d7e09401fb471a144d" +checksum = "3637e734239e12ab152cd269302500bd063f37624ee210cd04b4936ed671f3b1" dependencies = [ "cc", + "windows-targets 0.52.6", ] [[package]] @@ -9102,12 +9281,6 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" -[[package]] -name = "unicode-bidi" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" - [[package]] name = "unicode-bom" version = "2.0.3" @@ -9178,9 +9351,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", @@ -9199,6 +9372,18 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -9840,6 +10025,18 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -9883,6 +10080,30 @@ dependencies = [ "is-terminal", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -9904,6 +10125,27 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -9924,6 +10166,28 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "zip" version = "2.2.0" From e028b92698eae7e5019025e1784e7c06c3cae534 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sun, 10 Nov 2024 13:19:11 +0200 Subject: [PATCH 1661/1963] fix(trace): check fn sigs for contract with fallbacks (#9287) * fix(trace): check fn sigs for contract with fallbacks * Add Json test * Execute test with traces * Simplify, check only for decoded function --- crates/evm/traces/src/decoder/mod.rs | 23 ++++- crates/forge/tests/cli/cmd.rs | 144 +++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 1 deletion(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 43a53286c17b4..b63c7f1d7209b 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -121,6 +121,8 @@ pub struct CallTraceDecoder { pub labels: HashMap, /// Contract addresses that have a receive function. pub receive_contracts: Vec
, + /// Contract addresses that have fallback functions, mapped to function sigs. + pub fallback_contracts: HashMap>, /// All known functions. pub functions: HashMap>, @@ -188,6 +190,7 @@ impl CallTraceDecoder { (POINT_EVALUATION, "PointEvaluation".to_string()), ]), receive_contracts: Default::default(), + fallback_contracts: Default::default(), functions: hh_funcs() .chain( @@ -222,6 +225,7 @@ impl CallTraceDecoder { } self.receive_contracts.clear(); + self.fallback_contracts.clear(); } /// Identify unknown addresses in the specified call trace using the specified identifier. @@ -317,6 +321,14 @@ impl CallTraceDecoder { if abi.receive.is_some() { self.receive_contracts.push(*address); } + + if abi.fallback.is_some() { + let mut functions_sig = vec![]; + for function in abi.functions() { + functions_sig.push(function.signature()); + } + self.fallback_contracts.insert(*address, functions_sig); + } } } @@ -379,9 +391,18 @@ impl CallTraceDecoder { }; }; + // If traced contract is a fallback contract, check if it has the decoded function. + // If not, then replace call data signature with `fallback`. + let mut call_data = self.decode_function_input(trace, func); + if let Some(fallback_functions) = self.fallback_contracts.get(&trace.address) { + if !fallback_functions.contains(&func.signature()) { + call_data.signature = "fallback()".into(); + } + } + DecodedCallTrace { label, - call_data: Some(self.decode_function_input(trace, func)), + call_data: Some(call_data), return_data: self.decode_function_output(trace, functions), } } else { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index feb608a1e12ac..89335a492d01e 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2390,6 +2390,150 @@ contract CounterTest is DSTest { ); }); +// +forgetest_init!(gas_report_with_fallback, |prj, cmd| { + prj.add_test( + "DelegateProxyTest.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract ProxiedContract { + uint256 public amount; + + function deposit(uint256 aba) external { + amount = amount * 2; + } + + function deposit() external { + } +} + +contract DelegateProxy { + address internal implementation; + + constructor(address counter) { + implementation = counter; + } + + function deposit() external { + } + + fallback() external payable { + address addr = implementation; + + assembly { + calldatacopy(0, 0, calldatasize()) + let result := delegatecall(gas(), addr, 0, calldatasize(), 0, 0) + returndatacopy(0, 0, returndatasize()) + switch result + case 0 { revert(0, returndatasize()) } + default { return(0, returndatasize()) } + } + } +} + +contract GasReportFallbackTest is Test { + function test_fallback_gas_report() public { + ProxiedContract proxied = ProxiedContract(address(new DelegateProxy(address(new ProxiedContract())))); + proxied.deposit(100); + proxied.deposit(); + } +} +"#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "test_fallback_gas_report", "-vvvv", "--gas-report"]) + .assert_success() + .stdout_eq(str![[r#" +... +Ran 1 test for test/DelegateProxyTest.sol:GasReportFallbackTest +[PASS] test_fallback_gas_report() ([GAS]) +Traces: + [331067] GasReportFallbackTest::test_fallback_gas_report() + ├─ [106511] → new ProxiedContract@[..] + │ └─ ← [Return] 246 bytes of code + ├─ [108698] → new DelegateProxy@[..] + │ └─ ← [Return] 143 bytes of code + ├─ [29396] DelegateProxy::fallback(100) + │ ├─ [3320] ProxiedContract::deposit(100) [delegatecall] + │ │ └─ ← [Stop] + │ └─ ← [Return] + ├─ [21160] DelegateProxy::deposit() + │ └─ ← [Stop] + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +| test/DelegateProxyTest.sol:DelegateProxy contract | | | | | | +|---------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 108698 | 315 | | | | | +| Function Name | min | avg | median | max | # calls | +| deposit | 21160 | 21160 | 21160 | 21160 | 1 | +| fallback | 29396 | 29396 | 29396 | 29396 | 1 | + + +| test/DelegateProxyTest.sol:ProxiedContract contract | | | | | | +|-----------------------------------------------------|-----------------|------|--------|------|---------| +| Deployment Cost | Deployment Size | | | | | +| 106511 | 276 | | | | | +| Function Name | min | avg | median | max | # calls | +| deposit | 3320 | 3320 | 3320 | 3320 | 1 | +... + +"#]]); + + cmd.forge_fuse() + .args(["test", "--mt", "test_fallback_gas_report", "--gas-report", "--json"]) + .assert_success() + .stdout_eq( + str![[r#" +[ + { + "contract": "test/DelegateProxyTest.sol:DelegateProxy", + "deployment": { + "gas": 108698, + "size": 315 + }, + "functions": { + "deposit()": { + "calls": 1, + "min": 21160, + "mean": 21160, + "median": 21160, + "max": 21160 + }, + "fallback()": { + "calls": 1, + "min": 29396, + "mean": 29396, + "median": 29396, + "max": 29396 + } + } + }, + { + "contract": "test/DelegateProxyTest.sol:ProxiedContract", + "deployment": { + "gas": 106511, + "size": 276 + }, + "functions": { + "deposit(uint256)": { + "calls": 1, + "min": 3320, + "mean": 3320, + "median": 3320, + "max": 3320 + } + } + } +] +"#]] + .is_json(), + ); +}); + forgetest_init!(can_use_absolute_imports, |prj, cmd| { let remapping = prj.paths().libraries[0].join("myDependency"); let config = Config { From b7fe62ef1f58bfa2fe1980cc0f065dfc48b31d30 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:27:19 +0100 Subject: [PATCH 1662/1963] fix: use regular `println` in internal test utils to avoid interfering with `cargo test` runner (#9296) * use regular println to avoid interfering with cargo test runner * revert test change --- crates/script/src/receipts.rs | 2 +- crates/test-utils/src/util.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index af80734c59fe3..c11fdd71a92cd 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -72,7 +72,7 @@ pub fn format_receipt(chain: Chain, receipt: &AnyTransactionReceipt) -> String { let gas_used = receipt.gas_used; let gas_price = receipt.effective_gas_price; format!( - "\n##### {chain}\n{status}Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n\n", + "\n##### {chain}\n{status} Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n\n", status = if !receipt.inner.inner.inner.receipt.status.coerce_status() { "❌ [Failed]" } else { diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 9603ca3a20688..5d242800f6f99 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -224,8 +224,9 @@ impl ExtTester { /// This used to use a `static` `Lazy`, but this approach does not with `cargo-nextest` because it /// runs each test in a separate process. Instead, we use a global lock file to ensure that only one /// test can initialize the template at a time. +#[allow(clippy::disallowed_macros)] pub fn initialize(target: &Path) { - let _ = sh_println!("initializing {}", target.display()); + println!("initializing {}", target.display()); let tpath = TEMPLATE_PATH.as_path(); pretty_err(tpath, fs::create_dir_all(tpath)); @@ -253,7 +254,7 @@ pub fn initialize(target: &Path) { if data != "1" { // Initialize and build. let (prj, mut cmd) = setup_forge("template", foundry_compilers::PathStyle::Dapptools); - let _ = sh_println!("- initializing template dir in {}", prj.root().display()); + println!("- initializing template dir in {}", prj.root().display()); cmd.args(["init", "--force"]).assert_success(); // checkout forge-std @@ -283,7 +284,7 @@ pub fn initialize(target: &Path) { _read = Some(lock.read().unwrap()); } - let _ = sh_println!("- copying template dir from {}", tpath.display()); + println!("- copying template dir from {}", tpath.display()); pretty_err(target, fs::create_dir_all(target)); pretty_err(target, copy_dir(tpath, target)); } From 8c01706c96e457bac6a4d60be9c27ccbceca6396 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:25:42 +0200 Subject: [PATCH 1663/1963] feat(`cast run`): add `--etherscan-api-key` to resolve contract names (#9295) * fix(cast run): decode traces for non mainnet * Add test * Changes after review: use EtherscanOpts, remove short -e from evm_version Simplify test to avoid rate limiting. --- crates/cast/bin/cmd/run.rs | 11 +++++++++-- crates/cast/tests/cli/main.rs | 29 +++++++++++++++++++++++++++-- crates/evm/core/src/opts.rs | 12 ++++++++---- crates/test-utils/src/rpc.rs | 16 +++++++++++++++- 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 11c7b507e3554..7389d1f35e4d8 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -5,7 +5,7 @@ use cast::revm::primitives::EnvWithHandlerCfg; use clap::Parser; use eyre::{Result, WrapErr}; use foundry_cli::{ - opts::RpcOpts, + opts::{EtherscanOpts, RpcOpts}, utils::{handle_traces, init_progress, TraceResult}, }; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; @@ -58,13 +58,16 @@ pub struct RunArgs { #[arg(long, short)] label: Vec, + #[command(flatten)] + etherscan: EtherscanOpts, + #[command(flatten)] rpc: RpcOpts, /// The EVM version to use. /// /// Overrides the version specified in the config. - #[arg(long, short)] + #[arg(long)] evm_version: Option, /// Sets the number of assumed available compute units per second for this provider @@ -269,6 +272,10 @@ impl figment::Provider for RunArgs { map.insert("alphanet".into(), self.alphanet.into()); } + if let Some(api_key) = &self.etherscan.key { + map.insert("etherscan_api_key".into(), api_key.as_str().into()); + } + if let Some(evm_version) = self.evm_version { map.insert("evm_version".into(), figment::value::Value::serialize(evm_version)?); } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 6fb3ddb73c58a..29527f7dc3bbc 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -6,8 +6,8 @@ use anvil::{EthereumHardfork, NodeConfig}; use foundry_test_utils::{ casttest, file, rpc::{ - next_http_rpc_endpoint, next_mainnet_etherscan_api_key, next_rpc_endpoint, - next_ws_rpc_endpoint, + next_etherscan_api_key, next_http_rpc_endpoint, next_mainnet_etherscan_api_key, + next_rpc_endpoint, next_ws_rpc_endpoint, }, str, util::OutputExt, @@ -1503,3 +1503,28 @@ casttest!(fetch_constructor_args_from_etherscan, |_prj, cmd| { "#]]); }); + +// +casttest!(test_non_mainnet_traces, |prj, cmd| { + prj.clear(); + cmd.args([ + "run", + "0xa003e419e2d7502269eb5eda56947b580120e00abfd5b5460d08f8af44a0c24f", + "--rpc-url", + next_rpc_endpoint(NamedChain::Optimism).as_str(), + "--etherscan-api-key", + next_etherscan_api_key(NamedChain::Optimism).as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#" +Executing previous transactions from the block. +Traces: + [33841] FiatTokenProxy::fallback(0x111111125421cA6dc452d289314280a0f8842A65, 164054805 [1.64e8]) + ├─ [26673] FiatTokenV2_2::approve(0x111111125421cA6dc452d289314280a0f8842A65, 164054805 [1.64e8]) [delegatecall] + │ ├─ emit Approval(owner: 0x9a95Af47C51562acfb2107F44d7967DF253197df, spender: 0x111111125421cA6dc452d289314280a0f8842A65, value: 164054805 [1.64e8]) + │ └─ ← [Return] true + └─ ← [Return] true +... + +"#]]); +}); diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 7a41d075641b4..17ecbcca170eb 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -192,10 +192,6 @@ impl EvmOpts { /// Returns the chain ID from the RPC, if any. pub async fn get_remote_chain_id(&self) -> Option { if let Some(ref url) = self.fork_url { - if url.contains("mainnet") { - trace!(?url, "auto detected mainnet chain"); - return Some(Chain::mainnet()); - } trace!(?url, "retrieving chain via eth_chainId"); let provider = ProviderBuilder::new(url.as_str()) .compute_units_per_second(self.get_compute_units_per_second()) @@ -206,6 +202,14 @@ impl EvmOpts { if let Ok(id) = provider.get_chain_id().await { return Some(Chain::from(id)); } + + // Provider URLs could be of the format `{CHAIN_IDENTIFIER}-mainnet` + // (e.g. Alchemy `opt-mainnet`, `arb-mainnet`), fallback to this method only + // if we're not able to retrieve chain id from `RetryProvider`. + if url.contains("mainnet") { + trace!(?url, "auto detected mainnet chain"); + return Some(Chain::mainnet()); + } } None diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 7f0742143e4ce..a974e395406dd 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -1,6 +1,6 @@ //! RPC API keys utilities. -use foundry_config::NamedChain; +use foundry_config::{NamedChain, NamedChain::Optimism}; use rand::seq::SliceRandom; use std::sync::{ atomic::{AtomicUsize, Ordering}, @@ -75,6 +75,10 @@ static ETHERSCAN_MAINNET_KEYS: LazyLock> = LazyLock::new(|| { keys }); +// List of etherscan keys for Optimism. +static ETHERSCAN_OPTIMISM_KEYS: LazyLock> = + LazyLock::new(|| vec!["JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46"]); + /// Returns the next index to use. fn next() -> usize { static NEXT_INDEX: AtomicUsize = AtomicUsize::new(0); @@ -127,6 +131,16 @@ pub fn next_mainnet_etherscan_api_key() -> String { ETHERSCAN_MAINNET_KEYS[idx].to_string() } +/// Returns the next etherscan api key for given chain. +pub fn next_etherscan_api_key(chain: NamedChain) -> String { + let keys = match chain { + Optimism => ÐERSCAN_OPTIMISM_KEYS, + _ => ÐERSCAN_MAINNET_KEYS, + }; + let idx = next() % keys.len(); + keys[idx].to_string() +} + fn next_url(is_ws: bool, chain: NamedChain) -> String { use NamedChain::*; From f8d92341baa030675db135d08a574f4caeb96177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Urbanek?= Date: Mon, 11 Nov 2024 16:56:53 +0100 Subject: [PATCH 1664/1963] feat(cast): add artifact method (#9249) * feat(cast): add artifact method * Remove unneeded clone * Get chain info from provider * Rebase fix --- crates/cast/bin/args.rs | 6 +- crates/cast/bin/cmd/artifact.rs | 95 +++++++++++++++++++++++++ crates/cast/bin/cmd/constructor_args.rs | 11 +-- crates/cast/bin/cmd/creation_code.rs | 28 +++++--- crates/cast/bin/cmd/mod.rs | 1 + crates/cast/bin/main.rs | 1 + crates/cast/tests/cli/main.rs | 23 ++++++ 7 files changed, 148 insertions(+), 17 deletions(-) create mode 100644 crates/cast/bin/cmd/artifact.rs diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index a16436dd2ea7f..6f17707d4ea89 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -1,5 +1,5 @@ use crate::cmd::{ - access_list::AccessListArgs, bind::BindArgs, call::CallArgs, + access_list::AccessListArgs, artifact::ArtifactArgs, bind::BindArgs, call::CallArgs, constructor_args::ConstructorArgsArgs, create2::Create2Args, creation_code::CreationCodeArgs, estimate::EstimateArgs, find_block::FindBlockArgs, interface::InterfaceArgs, logs::LogsArgs, mktx::MakeTxArgs, rpc::RpcArgs, run::RunArgs, send::SendTxArgs, storage::StorageArgs, @@ -927,6 +927,10 @@ pub enum CastSubcommand { #[command(visible_alias = "cc")] CreationCode(CreationCodeArgs), + /// Generate an artifact file, that can be used to deploy a contract locally. + #[command(visible_alias = "ar")] + Artifact(ArtifactArgs), + /// Display constructor arguments used for the contract initialization. #[command(visible_alias = "cra")] ConstructorArgs(ConstructorArgsArgs), diff --git a/crates/cast/bin/cmd/artifact.rs b/crates/cast/bin/cmd/artifact.rs new file mode 100644 index 0000000000000..2e7a7cae015cb --- /dev/null +++ b/crates/cast/bin/cmd/artifact.rs @@ -0,0 +1,95 @@ +use alloy_primitives::Address; +use alloy_provider::Provider; +use clap::{command, Parser}; +use eyre::Result; +use foundry_block_explorers::Client; +use foundry_cli::{ + opts::{EtherscanOpts, RpcOpts}, + utils, +}; +use foundry_common::fs; +use foundry_config::Config; +use serde_json::json; +use std::path::PathBuf; + +use super::{ + creation_code::{fetch_creation_code, parse_code_output}, + interface::{fetch_abi_from_etherscan, load_abi_from_file}, +}; + +/// CLI arguments for `cast artifact`. +#[derive(Parser)] +pub struct ArtifactArgs { + /// An Ethereum address, for which the artifact will be produced. + contract: Address, + + /// Path to file containing the contract's JSON ABI. It's necessary if the target contract is + /// not verified on Etherscan. + #[arg(long)] + abi_path: Option, + + /// The path to the output file. + /// + /// If not specified, the artifact will be output to stdout. + #[arg( + short, + long, + value_hint = clap::ValueHint::FilePath, + value_name = "PATH", + )] + output: Option, + + #[command(flatten)] + etherscan: EtherscanOpts, + + #[command(flatten)] + rpc: RpcOpts, +} + +impl ArtifactArgs { + pub async fn run(self) -> Result<()> { + let Self { contract, etherscan, rpc, output: output_location, abi_path } = self; + + let mut etherscan = etherscan; + let config = Config::from(&rpc); + let provider = utils::get_provider(&config)?; + let api_key = etherscan.key().unwrap_or_default(); + let chain = provider.get_chain_id().await?; + etherscan.chain = Some(chain.into()); + let client = Client::new(chain.into(), api_key)?; + + let abi = if let Some(ref abi_path) = abi_path { + load_abi_from_file(abi_path, None)? + } else { + fetch_abi_from_etherscan(contract, ðerscan).await? + }; + + let (abi, _) = abi.first().ok_or_else(|| eyre::eyre!("No ABI found"))?; + + let bytecode = fetch_creation_code(contract, client, provider).await?; + let bytecode = + parse_code_output(bytecode, contract, ðerscan, abi_path.as_deref(), true, false) + .await?; + + let artifact = json!({ + "abi": abi, + "bytecode": { + "object": bytecode + } + }); + + let artifact = serde_json::to_string_pretty(&artifact)?; + + if let Some(loc) = output_location { + if let Some(parent) = loc.parent() { + fs::create_dir_all(parent)?; + } + fs::write(&loc, artifact)?; + sh_println!("Saved artifact at {}", loc.display())?; + } else { + sh_println!("{artifact}")?; + } + + Ok(()) + } +} diff --git a/crates/cast/bin/cmd/constructor_args.rs b/crates/cast/bin/cmd/constructor_args.rs index b0a08704fb3ce..8fe42c93cf711 100644 --- a/crates/cast/bin/cmd/constructor_args.rs +++ b/crates/cast/bin/cmd/constructor_args.rs @@ -1,5 +1,6 @@ use alloy_dyn_abi::DynSolType; use alloy_primitives::{Address, Bytes}; +use alloy_provider::Provider; use clap::{command, Parser}; use eyre::{eyre, OptionExt, Result}; use foundry_block_explorers::Client; @@ -36,13 +37,13 @@ impl ConstructorArgsArgs { pub async fn run(self) -> Result<()> { let Self { contract, etherscan, rpc, abi_path } = self; - let config = Config::from(ðerscan); - let chain = config.chain.unwrap_or_default(); - let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - let client = Client::new(chain, api_key)?; - + let mut etherscan = etherscan; let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let api_key = etherscan.key().unwrap_or_default(); + let chain = provider.get_chain_id().await?; + etherscan.chain = Some(chain.into()); + let client = Client::new(chain.into(), api_key)?; let bytecode = fetch_creation_code(contract, client, provider).await?; diff --git a/crates/cast/bin/cmd/creation_code.rs b/crates/cast/bin/cmd/creation_code.rs index bcafeac9488a4..04531b6167f3e 100644 --- a/crates/cast/bin/cmd/creation_code.rs +++ b/crates/cast/bin/cmd/creation_code.rs @@ -49,19 +49,25 @@ impl CreationCodeArgs { let Self { contract, etherscan, rpc, disassemble, without_args, only_args, abi_path } = self; - let config = Config::from(ðerscan); - let chain = config.chain.unwrap_or_default(); - let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); - let client = Client::new(chain, api_key)?; - + let mut etherscan = etherscan; let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; + let api_key = etherscan.key().unwrap_or_default(); + let chain = provider.get_chain_id().await?; + etherscan.chain = Some(chain.into()); + let client = Client::new(chain.into(), api_key)?; let bytecode = fetch_creation_code(contract, client, provider).await?; - let bytecode = - parse_code_output(bytecode, contract, ðerscan, abi_path, without_args, only_args) - .await?; + let bytecode = parse_code_output( + bytecode, + contract, + ðerscan, + abi_path.as_deref(), + without_args, + only_args, + ) + .await?; if disassemble { let _ = sh_println!("{}", SimpleCast::disassemble(&bytecode)?); @@ -77,11 +83,11 @@ impl CreationCodeArgs { /// - The complete bytecode /// - The bytecode without constructor arguments /// - Only the constructor arguments -async fn parse_code_output( +pub async fn parse_code_output( bytecode: Bytes, contract: Address, etherscan: &EtherscanOpts, - abi_path: Option, + abi_path: Option<&str>, without_args: bool, only_args: bool, ) -> Result { @@ -90,7 +96,7 @@ async fn parse_code_output( } let abi = if let Some(abi_path) = abi_path { - load_abi_from_file(&abi_path, None)? + load_abi_from_file(abi_path, None)? } else { fetch_abi_from_etherscan(contract, etherscan).await? }; diff --git a/crates/cast/bin/cmd/mod.rs b/crates/cast/bin/cmd/mod.rs index 49e3ed2efe96c..3f57b7668922d 100644 --- a/crates/cast/bin/cmd/mod.rs +++ b/crates/cast/bin/cmd/mod.rs @@ -6,6 +6,7 @@ //! [`foundry_config::Config`]. pub mod access_list; +pub mod artifact; pub mod bind; pub mod call; pub mod constructor_args; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index cdeaad2d21faf..2eac8682c21c1 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -213,6 +213,7 @@ async fn main_args(args: CastArgs) -> Result<()> { CastSubcommand::Interface(cmd) => cmd.run().await?, CastSubcommand::CreationCode(cmd) => cmd.run().await?, CastSubcommand::ConstructorArgs(cmd) => cmd.run().await?, + CastSubcommand::Artifact(cmd) => cmd.run().await?, CastSubcommand::Bind(cmd) => cmd.run().await?, CastSubcommand::PrettyCalldata { calldata, offline } => { let calldata = stdin::unwrap_line(calldata)?; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 29527f7dc3bbc..058c52aec1a25 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1528,3 +1528,26 @@ Traces: "#]]); }); + +// tests that displays a sample contract artifact +// +casttest!(fetch_artifact_from_etherscan, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + cmd.args([ + "artifact", + "--etherscan-api-key", + &next_mainnet_etherscan_api_key(), + "0x0923cad07f06b2d0e5e49e63b8b35738d4156b95", + "--rpc-url", + eth_rpc_url.as_str(), + ]) + .assert_success() + .stdout_eq(str![[r#"{ + "abi": [], + "bytecode": { + "object": "0x60566050600b82828239805160001a6073146043577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122074c61e8e4eefd410ca92eec26e8112ec6e831d0a4bf35718fdd78b45d68220d064736f6c63430008070033" + } +} + +"#]]); +}); From 4817280d96e0e33a2e96cf169770da60514d1764 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:39:37 +0200 Subject: [PATCH 1665/1963] fix(fork): set block blob_excess_gas_and_price only if `excess_blob_gas header` is Some (#9298) fix(fork): set block blob_excess_gas_and_price only if excess_blob_gas header is Some --- crates/evm/core/src/backend/mod.rs | 5 +++-- crates/forge/tests/cli/test_cmd.rs | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index e0b35f0bd07b5..c9bb890471811 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1922,8 +1922,9 @@ fn update_env_block(env: &mut Env, block: &Block) { env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); env.block.gas_limit = U256::from(block.header.gas_limit); env.block.number = U256::from(block.header.number); - env.block.blob_excess_gas_and_price = - block.header.excess_blob_gas.map(BlobExcessGasAndPrice::new); + if let Some(excess_blob_gas) = block.header.excess_blob_gas { + env.block.blob_excess_gas_and_price = Some(BlobExcessGasAndPrice::new(excess_blob_gas)); + } } /// Executes the given transaction and commits state changes to the database _and_ the journaled diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index b952e19bd26d3..8389c381ef9ff 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2616,3 +2616,26 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { cmd.forge_fuse().args(["test", "--mc", "GetBroadcastTest", "-vvv"]).assert_success(); }); + +// See +forgetest_init!(test_roll_scroll_fork_with_cancun, |prj, cmd| { + prj.add_test( + "ScrollForkTest.t.sol", + r#" + +import {Test} from "forge-std/Test.sol"; + +contract ScrollForkTest is Test { + function test_roll_scroll_fork_to_tx() public { + vm.createSelectFork("https://scroll-mainnet.chainstacklabs.com/"); + bytes32 targetTxHash = 0xf94774a1f69bba76892141190293ffe85dd8d9ac90a0a2e2b114b8c65764014c; + vm.rollFork(targetTxHash); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "test_roll_scroll_fork_to_tx", "--evm-version", "cancun"]) + .assert_success(); +}); From 22cf683acf04180a96f4a4435fa34da34a502874 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:59:27 +0100 Subject: [PATCH 1666/1963] feat(`common::shell`): add global verbosity level (`-vvv`) flag replacing `--verbose` (#9273) * remove --verbose, prefer output mode, introduce verbosity level (-vvv) * remove leftover * fix arg * add ability to set verbosity level * fix tests * remove evm args specific verbosity arg in favor of global arg due to Clap limitation * revert test modifications from https://github.com/foundry-rs/foundry/pull/9244 for TestArgs, simply pass + flatten ShellOpts in args * in lieu of a context specific help document the verbosity levels of the EVM as an example * format comment, update tests * fix clippy --- crates/cast/bin/args.rs | 4 +- crates/cast/bin/cmd/run.rs | 8 +- crates/cast/bin/cmd/wallet/mod.rs | 7 +- crates/cast/tests/cli/main.rs | 16 +++- crates/cli/src/opts/shell.rs | 43 +++++------ crates/common/src/evm.rs | 21 ++---- crates/common/src/io/shell.rs | 117 ++++++++++++++++-------------- crates/forge/bin/cmd/compiler.rs | 34 +++------ crates/forge/bin/cmd/config.rs | 10 +-- crates/forge/bin/cmd/test/mod.rs | 48 +++--------- crates/forge/tests/cli/cmd.rs | 16 +++- crates/script/src/lib.rs | 8 +- 12 files changed, 152 insertions(+), 180 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 6f17707d4ea89..8bb7f2d544334 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -793,7 +793,7 @@ pub enum CastSubcommand { who: Option, /// Perform a reverse lookup to verify that the name is correct. - #[arg(long, short)] + #[arg(long)] verify: bool, #[command(flatten)] @@ -807,7 +807,7 @@ pub enum CastSubcommand { who: Option
, /// Perform a normal lookup to verify that the address is correct. - #[arg(long, short)] + #[arg(long)] verify: bool, #[command(flatten)] diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 7389d1f35e4d8..880b2fe6f080a 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -8,7 +8,7 @@ use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, utils::{handle_traces, init_progress, TraceResult}, }; -use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{ figment::{ @@ -48,10 +48,6 @@ pub struct RunArgs { #[arg(long)] quick: bool, - /// Prints the full address of the contract. - #[arg(long, short)] - verbose: bool, - /// Label addresses in the trace. /// /// Example: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045:vitalik.eth @@ -252,7 +248,7 @@ impl RunArgs { self.label, self.debug, self.decode_internal, - self.verbose, + shell::verbosity() > 0, ) .await?; diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 8023b8bdff334..b6dea48e15c0b 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -183,10 +183,6 @@ pub enum WalletSubcommands { #[arg(value_name = "MNEMONIC_INDEX_OR_DERIVATION_PATH")] mnemonic_index_or_derivation_path_override: Option, - /// Verbose mode, print the address and private key. - #[arg(short = 'v', long)] - verbose: bool, - #[command(flatten)] wallet: WalletOpts, }, @@ -462,7 +458,6 @@ flag to set your key via: wallet, mnemonic_override, mnemonic_index_or_derivation_path_override, - verbose, } => { let (index_override, derivation_path_override) = match mnemonic_index_or_derivation_path_override { @@ -485,7 +480,7 @@ flag to set your key via: .await?; match wallet { WalletSigner::Local(wallet) => { - if verbose { + if shell::verbosity() > 0 { sh_println!("Address: {}", wallet.address())?; sh_println!( "Private key: 0x{}", diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 058c52aec1a25..bec345b1710c9 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -33,7 +33,7 @@ Options: Display options: --color - Log messages coloring + The color of the log messages Possible values: - auto: Intelligently guess whether to use color output (default) @@ -46,8 +46,18 @@ Display options: -q, --quiet Do not print log messages - --verbose - Use verbose output + -v, --verbosity... + Verbosity level of the log messages. + + Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). + + Depending on the context the verbosity levels have different meanings. + + For example, the verbosity levels of the EVM are: + - 2 (-vv): Print logs for all tests. + - 3 (-vvv): Print execution traces for failing tests. + - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. + - 5 (-vvvvv): Print execution and setup traces for all tests. Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html diff --git a/crates/cli/src/opts/shell.rs b/crates/cli/src/opts/shell.rs index fd83b952bef0f..e559cc0f275f5 100644 --- a/crates/cli/src/opts/shell.rs +++ b/crates/cli/src/opts/shell.rs @@ -1,24 +1,27 @@ -use clap::Parser; -use foundry_common::shell::{ColorChoice, OutputFormat, Shell, Verbosity}; +use clap::{ArgAction, Parser}; +use foundry_common::shell::{ColorChoice, OutputFormat, OutputMode, Shell, Verbosity}; // note: `verbose` and `quiet` cannot have `short` because of conflicts with multiple commands. /// Global shell options. -#[derive(Clone, Copy, Debug, Parser)] +#[derive(Clone, Copy, Debug, Default, Parser)] pub struct ShellOpts { - /// Use verbose output. - #[clap(long, global = true, conflicts_with = "quiet", help_heading = "Display options")] - pub verbose: bool, + /// Verbosity level of the log messages. + /// + /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). + /// + /// Depending on the context the verbosity levels have different meanings. + /// + /// For example, the verbosity levels of the EVM are: + /// - 2 (-vv): Print logs for all tests. + /// - 3 (-vvv): Print execution traces for failing tests. + /// - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. + /// - 5 (-vvvvv): Print execution and setup traces for all tests. + #[clap(short, long, global = true, verbatim_doc_comment, conflicts_with = "quiet", action = ArgAction::Count, help_heading = "Display options")] + pub verbosity: Verbosity, /// Do not print log messages. - #[clap( - short, - long, - global = true, - alias = "silent", - conflicts_with = "verbose", - help_heading = "Display options" - )] + #[clap(short, long, global = true, alias = "silent", help_heading = "Display options")] pub quiet: bool, /// Format log messages as JSON. @@ -31,18 +34,16 @@ pub struct ShellOpts { )] pub json: bool, - /// Log messages coloring. + /// The color of the log messages. #[clap(long, global = true, value_enum, help_heading = "Display options")] pub color: Option, } impl ShellOpts { pub fn shell(self) -> Shell { - let verbosity = match (self.verbose, self.quiet) { - (true, false) => Verbosity::Verbose, - (false, true) => Verbosity::Quiet, - (false, false) => Verbosity::Normal, - (true, true) => unreachable!(), + let mode = match self.quiet { + true => OutputMode::Quiet, + false => OutputMode::Normal, }; let color = self.json.then_some(ColorChoice::Never).or(self.color).unwrap_or_default(); let format = match self.json { @@ -50,6 +51,6 @@ impl ShellOpts { false => OutputFormat::Text, }; - Shell::new_with(format, color, verbosity) + Shell::new_with(format, mode, color, self.verbosity) } } diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index e738cc6ddce30..3eca0800e0cde 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -1,7 +1,7 @@ //! CLI arguments for configuring the EVM settings. use alloy_primitives::{map::HashMap, Address, B256, U256}; -use clap::{ArgAction, Parser}; +use clap::Parser; use eyre::ContextCompat; use foundry_config::{ figment::{ @@ -14,6 +14,8 @@ use foundry_config::{ }; use serde::Serialize; +use crate::shell; + /// Map keyed by breakpoints char to their location (contract address, pc) pub type Breakpoints = HashMap; @@ -101,19 +103,6 @@ pub struct EvmArgs { #[serde(skip)] pub always_use_create_2_factory: bool, - /// Verbosity of the EVM. - /// - /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). - /// - /// Verbosity levels: - /// - 2: Print logs for all tests - /// - 3: Print execution traces for failing tests - /// - 4: Print execution traces for all tests, and setup traces for failing tests - /// - 5: Print execution and setup traces for all tests - #[arg(long, short, verbatim_doc_comment, action = ArgAction::Count)] - #[serde(skip)] - pub verbosity: u8, - /// Sets the number of assumed available compute units per second for this provider /// /// default value: 330 @@ -163,9 +152,9 @@ impl Provider for EvmArgs { let error = InvalidType(value.to_actual(), "map".into()); let mut dict = value.into_dict().ok_or(error)?; - if self.verbosity > 0 { + if shell::verbosity() > 0 { // need to merge that manually otherwise `from_occurrences` does not work - dict.insert("verbosity".to_string(), self.verbosity.into()); + dict.insert("verbosity".to_string(), shell::verbosity().into()); } if self.ffi { diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs index 45d9c2296037a..09a167df94400 100644 --- a/crates/common/src/io/shell.rs +++ b/crates/common/src/io/shell.rs @@ -17,14 +17,19 @@ use std::{ }, }; -/// Returns the currently set verbosity. +/// Returns the currently set verbosity level. pub fn verbosity() -> Verbosity { Shell::get().verbosity() } -/// Returns whether the verbosity level is [`Verbosity::Quiet`]. +/// Set the verbosity level. +pub fn set_verbosity(verbosity: Verbosity) { + Shell::get().set_verbosity(verbosity); +} + +/// Returns whether the output mode is [`OutputMode::Quiet`]. pub fn is_quiet() -> bool { - verbosity().is_quiet() + Shell::get().output_mode().is_quiet() } /// Returns whether the output format is [`OutputFormat::Json`]. @@ -68,11 +73,9 @@ impl TtyWidth { } } -/// The requested verbosity of output. #[derive(Debug, Default, Clone, Copy, PartialEq)] -pub enum Verbosity { - /// All output - Verbose, +/// The requested output mode. +pub enum OutputMode { /// Default output #[default] Normal, @@ -80,20 +83,14 @@ pub enum Verbosity { Quiet, } -impl Verbosity { - /// Returns true if the verbosity level is `Verbose`. - #[inline] - pub fn is_verbose(self) -> bool { - self == Self::Verbose - } - - /// Returns true if the verbosity level is `Normal`. +impl OutputMode { + /// Returns true if the output mode is `Normal`. #[inline] pub fn is_normal(self) -> bool { self == Self::Normal } - /// Returns true if the verbosity level is `Quiet`. + /// Returns true if the output mode is `Quiet`. #[inline] pub fn is_quiet(self) -> bool { self == Self::Quiet @@ -124,6 +121,9 @@ impl OutputFormat { } } +/// The verbosity level. +pub type Verbosity = u8; + /// An abstraction around console output that remembers preferences for output /// verbosity and color. pub struct Shell { @@ -134,7 +134,10 @@ pub struct Shell { /// The format to use for message output. output_format: OutputFormat, - /// How verbose messages should be. + /// The verbosity mode to use for message output. + output_mode: OutputMode, + + /// The verbosity level to use for message output. verbosity: Verbosity, /// Flag that indicates the current line needs to be cleared before @@ -145,6 +148,8 @@ pub struct Shell { impl fmt::Debug for Shell { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut s = f.debug_struct("Shell"); + s.field("output_format", &self.output_format); + s.field("output_mode", &self.output_mode); s.field("verbosity", &self.verbosity); if let ShellOut::Stream { color_choice, .. } = self.output { s.field("color_choice", &color_choice); @@ -190,12 +195,22 @@ impl Shell { /// output. #[inline] pub fn new() -> Self { - Self::new_with(OutputFormat::Text, ColorChoice::Auto, Verbosity::Verbose) + Self::new_with( + OutputFormat::Text, + OutputMode::Normal, + ColorChoice::Auto, + Verbosity::default(), + ) } /// Creates a new shell with the given color choice and verbosity. #[inline] - pub fn new_with(format: OutputFormat, color: ColorChoice, verbosity: Verbosity) -> Self { + pub fn new_with( + format: OutputFormat, + mode: OutputMode, + color: ColorChoice, + verbosity: Verbosity, + ) -> Self { Self { output: ShellOut::Stream { stdout: AutoStream::new(std::io::stdout(), color.to_anstream_color_choice()), @@ -204,6 +219,7 @@ impl Shell { stderr_tty: std::io::stderr().is_terminal(), }, output_format: format, + output_mode: mode, verbosity, needs_clear: AtomicBool::new(false), } @@ -215,7 +231,8 @@ impl Shell { Self { output: ShellOut::Empty(std::io::empty()), output_format: OutputFormat::Text, - verbosity: Verbosity::Quiet, + output_mode: OutputMode::Quiet, + verbosity: 0, needs_clear: AtomicBool::new(false), } } @@ -266,15 +283,27 @@ impl Shell { } } - /// Gets the verbosity of the shell. + /// Gets the output format of the shell. + #[inline] + pub fn output_format(&self) -> OutputFormat { + self.output_format + } + + /// Gets the output mode of the shell. + #[inline] + pub fn output_mode(&self) -> OutputMode { + self.output_mode + } + + /// Gets the verbosity of the shell when [`OutputMode::Normal`] is set. #[inline] pub fn verbosity(&self) -> Verbosity { self.verbosity } - /// Gets the output format of the shell. - pub fn output_format(&self) -> OutputFormat { - self.output_format + /// Sets the verbosity level. + pub fn set_verbosity(&mut self, verbosity: Verbosity) { + self.verbosity = verbosity; } /// Gets the current color choice. @@ -338,24 +367,6 @@ impl Shell { } } - /// Runs the callback only if we are in verbose mode. - #[inline] - pub fn verbose(&mut self, mut callback: impl FnMut(&mut Self) -> Result<()>) -> Result<()> { - match self.verbosity { - Verbosity::Verbose => callback(self), - _ => Ok(()), - } - } - - /// Runs the callback if we are not in verbose mode. - #[inline] - pub fn concise(&mut self, mut callback: impl FnMut(&mut Self) -> Result<()>) -> Result<()> { - match self.verbosity { - Verbosity::Verbose => Ok(()), - _ => callback(self), - } - } - /// Prints a red 'error' message. Use the [`sh_err!`] macro instead. /// This will render a message in [ERROR] style with a bold `Error: ` prefix. /// @@ -370,8 +381,8 @@ impl Shell { /// /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. pub fn warn(&mut self, message: impl fmt::Display) -> Result<()> { - match self.verbosity { - Verbosity::Quiet => Ok(()), + match self.output_mode { + OutputMode::Quiet => Ok(()), _ => self.print(&"Warning", &WARN, Some(&message), false), } } @@ -387,10 +398,9 @@ impl Shell { /// /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. pub fn print_out(&mut self, fragment: impl fmt::Display) -> Result<()> { - if self.verbosity == Verbosity::Quiet { - Ok(()) - } else { - self.write_stdout(fragment, &Style::new()) + match self.output_mode { + OutputMode::Quiet => Ok(()), + _ => self.write_stdout(fragment, &Style::new()), } } @@ -405,10 +415,9 @@ impl Shell { /// /// **Note**: if `verbosity` is set to `Quiet`, this is a no-op. pub fn print_err(&mut self, fragment: impl fmt::Display) -> Result<()> { - if self.verbosity == Verbosity::Quiet { - Ok(()) - } else { - self.write_stderr(fragment, &Style::new()) + match self.output_mode { + OutputMode::Quiet => Ok(()), + _ => self.write_stderr(fragment, &Style::new()), } } @@ -421,8 +430,8 @@ impl Shell { message: Option<&dyn fmt::Display>, justified: bool, ) -> Result<()> { - match self.verbosity { - Verbosity::Quiet => Ok(()), + match self.output_mode { + OutputMode::Quiet => Ok(()), _ => { self.maybe_err_erase_line(); self.output.message_stderr(status, style, message, justified) diff --git a/crates/forge/bin/cmd/compiler.rs b/crates/forge/bin/cmd/compiler.rs index 0b0ec171b4c79..a7115c4876b8f 100644 --- a/crates/forge/bin/cmd/compiler.rs +++ b/crates/forge/bin/cmd/compiler.rs @@ -1,5 +1,6 @@ -use clap::{ArgAction, Parser, Subcommand, ValueHint}; +use clap::{Parser, Subcommand, ValueHint}; use eyre::Result; +use foundry_common::shell; use foundry_compilers::{artifacts::EvmVersion, Graph}; use foundry_config::Config; use semver::Version; @@ -51,26 +52,11 @@ pub struct ResolveArgs { /// Skip files that match the given regex pattern. #[arg(long, short, value_name = "REGEX")] skip: Option, - - /// Verbosity of the output. - /// - /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). - /// - /// Verbosity levels: - /// - 0: Print compiler versions. - /// - 1: Print compiler version and source paths. - /// - 2: Print compiler version, source paths and max supported EVM version of the compiler. - #[arg(long, short, verbatim_doc_comment, action = ArgAction::Count, help_heading = "Display options")] - pub verbosity: u8, - - /// Print as JSON. - #[arg(long, short, help_heading = "Display options")] - json: bool, } impl ResolveArgs { pub fn run(self) -> Result<()> { - let Self { root, skip, verbosity, json } = self; + let Self { root, skip } = self; let root = root.unwrap_or_else(|| PathBuf::from(".")); let config = Config::load_with_root(&root); @@ -110,7 +96,7 @@ impl ResolveArgs { }) .collect(); - let evm_version = if verbosity > 1 { + let evm_version = if shell::verbosity() > 1 { Some( EvmVersion::default() .normalize_version_solc(version) @@ -132,7 +118,7 @@ impl ResolveArgs { if !versions_with_paths.is_empty() { // Clear paths if verbosity is 0, performed only after filtering to avoid being // skipped. - if verbosity == 0 { + if shell::verbosity() == 0 { versions_with_paths.iter_mut().for_each(|version| version.paths.clear()); } @@ -140,20 +126,20 @@ impl ResolveArgs { } } - if json { + if shell::is_json() { sh_println!("{}", serde_json::to_string(&output)?)?; return Ok(()); } for (language, compilers) in &output { - match verbosity { + match shell::verbosity() { 0 => sh_println!("{language}:")?, _ => sh_println!("{language}:\n")?, } for resolved_compiler in compilers { let version = &resolved_compiler.version; - match verbosity { + match shell::verbosity() { 0 => sh_println!("- {version}")?, _ => { if let Some(evm) = &resolved_compiler.evm_version { @@ -164,7 +150,7 @@ impl ResolveArgs { } } - if verbosity > 0 { + if shell::verbosity() > 0 { let paths = &resolved_compiler.paths; for (idx, path) in paths.iter().enumerate() { if idx == paths.len() - 1 { @@ -176,7 +162,7 @@ impl ResolveArgs { } } - if verbosity == 0 { + if shell::verbosity() == 0 { sh_println!()? } } diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index 652c5a10fed3b..36f4d1731f4b1 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -2,7 +2,7 @@ use super::build::BuildArgs; use clap::Parser; use eyre::Result; use foundry_cli::utils::LoadConfig; -use foundry_common::evm::EvmArgs; +use foundry_common::{evm::EvmArgs, shell}; use foundry_config::fix::fix_tomls; foundry_config::impl_figment_convert!(ConfigArgs, opts, evm_opts); @@ -14,10 +14,6 @@ pub struct ConfigArgs { #[arg(long)] basic: bool, - /// Print currently set config values as JSON. - #[arg(long)] - json: bool, - /// Attempt to fix any configuration warnings. #[arg(long)] fix: bool, @@ -46,12 +42,12 @@ impl ConfigArgs { let s = if self.basic { let config = config.into_basic(); - if self.json { + if shell::is_json() { serde_json::to_string_pretty(&config)? } else { config.to_string_pretty()? } - } else if self.json { + } else if shell::is_json() { serde_json::to_string_pretty(&config)? } else { config.to_string_pretty()? diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 091599305dd86..77ae5d2631f66 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -17,7 +17,7 @@ use forge::{ MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, TestOptionsBuilder, }; use foundry_cli::{ - opts::CoreBuildArgs, + opts::{CoreBuildArgs, ShellOpts}, utils::{self, LoadConfig}, }; use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell, TestFunctionExt}; @@ -178,6 +178,9 @@ pub struct TestArgs { /// Print detailed test summary table. #[arg(long, help_heading = "Display options", requires = "summary")] pub detailed: bool, + + #[command(flatten)] + shell: ShellOpts, } impl TestArgs { @@ -993,56 +996,34 @@ fn junit_xml_report(results: &BTreeMap, verbosity: u8) -> R #[cfg(test)] mod tests { - use crate::opts::{Forge, ForgeSubcommand}; - use super::*; use foundry_config::{Chain, InvariantConfig}; use foundry_test_utils::forgetest_async; #[test] fn watch_parse() { - let args = match Forge::parse_from(["foundry-cli", "test", "-vw"]).cmd { - ForgeSubcommand::Test(args) => args, - _ => unreachable!(), - }; + let args: TestArgs = TestArgs::parse_from(["foundry-cli", "-vw"]); assert!(args.watch.watch.is_some()); } #[test] fn fuzz_seed() { - let args = match Forge::parse_from(["foundry-cli", "test", "--fuzz-seed", "0x10"]).cmd { - ForgeSubcommand::Test(args) => args, - _ => unreachable!(), - }; + let args: TestArgs = TestArgs::parse_from(["foundry-cli", "--fuzz-seed", "0x10"]); assert!(args.fuzz_seed.is_some()); } // #[test] fn fuzz_seed_exists() { - let args = match Forge::parse_from([ - "foundry-cli", - "test", - "-vvv", - "--gas-report", - "--fuzz-seed", - "0x10", - ]) - .cmd - { - ForgeSubcommand::Test(args) => args, - _ => unreachable!(), - }; + let args: TestArgs = + TestArgs::parse_from(["foundry-cli", "-vvv", "--gas-report", "--fuzz-seed", "0x10"]); assert!(args.fuzz_seed.is_some()); } #[test] fn extract_chain() { let test = |arg: &str, expected: Chain| { - let args = match Forge::parse_from(["foundry-cli", "test", arg]).cmd { - ForgeSubcommand::Test(args) => args, - _ => unreachable!(), - }; + let args = TestArgs::parse_from(["foundry-cli", arg]); assert_eq!(args.evm_opts.env.chain, Some(expected)); let (config, evm_opts) = args.load_config_and_evm_opts().unwrap(); assert_eq!(config.chain, Some(expected)); @@ -1096,19 +1077,12 @@ contract FooBarTest is DSTest { ) .unwrap(); - let args = match Forge::parse_from([ + let args = TestArgs::parse_from([ "foundry-cli", - "test", "--gas-report", "--root", &prj.root().to_string_lossy(), - ]) - .cmd - { - ForgeSubcommand::Test(args) => args, - _ => unreachable!(), - }; - + ]); let outcome = args.run().await.unwrap(); let gas_report = outcome.gas_report.unwrap(); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 89335a492d01e..9e9e1fda1c1fb 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -38,7 +38,7 @@ Options: Display options: --color - Log messages coloring + The color of the log messages Possible values: - auto: Intelligently guess whether to use color output (default) @@ -51,8 +51,18 @@ Display options: -q, --quiet Do not print log messages - --verbose - Use verbose output + -v, --verbosity... + Verbosity level of the log messages. + + Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). + + Depending on the context the verbosity levels have different meanings. + + For example, the verbosity levels of the EVM are: + - 2 (-vv): Print logs for all tests. + - 3 (-vvv): Print execution traces for failing tests. + - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. + - 5 (-vvvvv): Print execution and setup traces for all tests. Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 707399d6305dc..180a09647d4ff 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -26,7 +26,10 @@ use dialoguer::Confirm; use eyre::{ContextCompat, Result}; use forge_script_sequence::{AdditionalContract, NestedValue}; use forge_verify::RetryArgs; -use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; +use foundry_cli::{ + opts::{CoreBuildArgs, ShellOpts}, + utils::LoadConfig, +}; use foundry_common::{ abi::{encode_function_args, get_func}, evm::{Breakpoints, EvmArgs}, @@ -210,6 +213,9 @@ pub struct ScriptArgs { #[command(flatten)] pub retry: RetryArgs, + + #[clap(flatten)] + pub shell: ShellOpts, } impl ScriptArgs { From 40fc54eda8b905a00bf8c96250b0e0af9869de67 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:39:02 +0200 Subject: [PATCH 1667/1963] chore: do not trim decoded generic custom error (#9309) chore: do not trim generic custom error trace --- crates/evm/core/src/decode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index d6e8b3dec88fd..c0ff331646dcb 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -191,7 +191,7 @@ impl RevertDecoder { s.push_str(": "); match std::str::from_utf8(data) { Ok(data) => s.push_str(data), - Err(_) => s.push_str(&trimmed_hex(data)), + Err(_) => s.push_str(&hex::encode(data)), } } s From 54ea38d189bf192f689aed4c6f231a27f1def316 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:36:15 +0200 Subject: [PATCH 1668/1963] fix(forge): always report deployment size in gas reports (#9308) --- crates/forge/src/gas_report.rs | 29 ++++---- crates/forge/tests/cli/cmd.rs | 126 +++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 14 deletions(-) diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 1b6e4bd63bc09..e3e44994b91c3 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -94,31 +94,32 @@ impl GasReport { return; } - // Only include top-level calls which account for calldata and base (21.000) cost. - // Only include Calls and Creates as only these calls are isolated in inspector. - if trace.depth > 1 && - (trace.kind == CallKind::Call || - trace.kind == CallKind::Create || - trace.kind == CallKind::Create2 || - trace.kind == CallKind::EOFCreate) - { - return; - } - let Some(name) = decoder.contracts.get(&node.trace.address) else { return }; let contract_name = name.rsplit(':').next().unwrap_or(name); if !self.should_report(contract_name) { return; } + let contract_info = self.contracts.entry(name.to_string()).or_default(); + let is_create_call = trace.kind.is_any_create(); + + // Record contract deployment size. + if is_create_call { + trace!(contract_name, "adding create size info"); + contract_info.size = trace.data.len(); + } + + // Only include top-level calls which account for calldata and base (21.000) cost. + // Only include Calls and Creates as only these calls are isolated in inspector. + if trace.depth > 1 && (trace.kind == CallKind::Call || is_create_call) { + return; + } let decoded = || decoder.decode_function(&node.trace); - let contract_info = self.contracts.entry(name.to_string()).or_default(); - if trace.kind.is_any_create() { + if is_create_call { trace!(contract_name, "adding create gas info"); contract_info.gas = trace.gas_used; - contract_info.size = trace.data.len(); } else if let Some(DecodedCallData { signature, .. }) = decoded().await.call_data { let name = signature.split('(').next().unwrap(); // ignore any test/setup functions diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 9e9e1fda1c1fb..d4f3973a337a6 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2544,6 +2544,132 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] ); }); +// +forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| { + prj.add_test( + "NestedDeployTest.sol", + r#" +import {Test} from "forge-std/Test.sol"; +contract Child { + AnotherChild public child; + constructor() { + child = new AnotherChild(); + } + function w() external { + child.w(); + } +} +contract AnotherChild { + function w() external {} +} +contract Parent { + Child public immutable child; + constructor() { + child = new Child(); + } +} +contract NestedDeploy is Test { + function test_nested_create_gas_report() external { + Parent p = new Parent(); + p.child().child().w(); + } +} +"#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "test_nested_create_gas_report", "--gas-report"]) + .assert_success() + .stdout_eq(str![[r#" +... +Ran 1 test for test/NestedDeployTest.sol:NestedDeploy +[PASS] test_nested_create_gas_report() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +| test/NestedDeployTest.sol:AnotherChild contract | | | | | | +|-------------------------------------------------|-----------------|-------|--------|-------|---------| +| Deployment Cost | Deployment Size | | | | | +| 0 | 130 | | | | | +| Function Name | min | avg | median | max | # calls | +| w | 21162 | 21162 | 21162 | 21162 | 1 | + + +| test/NestedDeployTest.sol:Child contract | | | | | | +|------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 0 | 498 | | | | | +| Function Name | min | avg | median | max | # calls | +| child | 325 | 325 | 325 | 325 | 1 | + + +| test/NestedDeployTest.sol:Parent contract | | | | | | +|-------------------------------------------|-----------------|-----|--------|-----|---------| +| Deployment Cost | Deployment Size | | | | | +| 254857 | 770 | | | | | +| Function Name | min | avg | median | max | # calls | +| child | 182 | 182 | 182 | 182 | 1 | +... +"#]]); + + cmd.forge_fuse() + .args(["test", "--mt", "test_nested_create_gas_report", "--gas-report", "--json"]) + .assert_success() + .stdout_eq( + str![[r#" +[ + { + "contract": "test/NestedDeployTest.sol:AnotherChild", + "deployment": { + "gas": 0, + "size": 130 + }, + "functions": { + "w()": { + "calls": 1, + "min": 21162, + "mean": 21162, + "median": 21162, + "max": 21162 + } + } + }, + { + "contract": "test/NestedDeployTest.sol:Child", + "deployment": { + "gas": 0, + "size": 498 + }, + "functions": { + "child()": { + "calls": 1, + "min": 325, + "mean": 325, + "median": 325, + "max": 325 + } + } + }, + { + "contract": "test/NestedDeployTest.sol:Parent", + "deployment": { + "gas": 254857, + "size": 770 + }, + "functions": { + "child()": { + "calls": 1, + "min": 182, + "mean": 182, + "median": 182, + "max": 182 + } + } + } +] +"#]] + .is_json(), + ); +}); + forgetest_init!(can_use_absolute_imports, |prj, cmd| { let remapping = prj.paths().libraries[0].join("myDependency"); let config = Config { From 4304926fe0834af65a5cbc9b26c869e8c748d097 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:45:07 +0100 Subject: [PATCH 1669/1963] fix(`ci`): update cargo deny (#9314) fix cargo deny --- deny.toml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/deny.toml b/deny.toml index b932b03885a26..031bc56e2fbe5 100644 --- a/deny.toml +++ b/deny.toml @@ -5,11 +5,12 @@ version = 2 yanked = "warn" ignore = [ - # https://github.com/watchexec/watchexec/issues/852 - "RUSTSEC-2024-0350", - "RUSTSEC-2024-0351", # proc-macro-error is unmaintained "RUSTSEC-2024-0370", + # instant is unmaintained + "RUSTSEC-2024-0384", + # derivative is unmaintained + "RUSTSEC-2024-0388", ] # This section is considered when running `cargo deny check bans`. @@ -45,6 +46,7 @@ allow = [ "BSD-2-Clause", "BSD-3-Clause", "ISC", + "Unicode-3.0", "Unicode-DFS-2016", "OpenSSL", "Unlicense", @@ -67,9 +69,6 @@ exceptions = [ { allow = ["CC0-1.0"], name = "notify" }, { allow = ["CC0-1.0"], name = "dunce" }, { allow = ["CC0-1.0"], name = "aurora-engine-modexp" }, - { allow = ["CC0-1.0"], name = "constant_time_eq" }, - { allow = ["CC0-1.0"], name = "secp256k1" }, - { allow = ["CC0-1.0"], name = "secp256k1-sys" }, ] #copyleft = "deny" From 78d263af61f37737c2f69fd94ec7fb8d2fc73987 Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:00:06 +0200 Subject: [PATCH 1670/1963] feat: Update to soldeer 0.5.1 (#9315) Update to soldeer 0.5.1 Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b18148fe967b2..0c9a611b41b2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8348,9 +8348,9 @@ dependencies = [ [[package]] name = "soldeer-commands" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1925813f3dd013d212fa9ad184911846f99236dbfc8a6d79c8a54dfa0bb1a948" +checksum = "f5969c09f89ae6f0e18d5904e5bdbb8842ba948dad0f8202edb7ea510e35654d" dependencies = [ "bon", "clap", diff --git a/Cargo.toml b/Cargo.toml index 7754de503d832..0c0962a2d95eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -278,7 +278,7 @@ semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } similar-asserts = "1.6" -soldeer-commands = "=0.5.0" +soldeer-commands = "=0.5.1" strum = "0.26" tempfile = "3.13" tikv-jemallocator = "0.6" From 31c24b0b901d6fd393d52070221cccab54e45e80 Mon Sep 17 00:00:00 2001 From: "Valentin B." <703631+beeb@users.noreply.github.com> Date: Wed, 13 Nov 2024 21:32:22 +0100 Subject: [PATCH 1671/1963] chore: update soldeer-core dependency (#9316) --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c9a611b41b2c..af730814c9362 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8363,9 +8363,9 @@ dependencies = [ [[package]] name = "soldeer-core" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434b034d411ea9d1cd9bd77fa2978a42e4c4ae486f47738a545079f11a32c879" +checksum = "e63aeee0e78b5fba04f005d23a58d20f897720212bd21ad744201cacb9dd34f8" dependencies = [ "bon", "chrono", @@ -9193,7 +9193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3637e734239e12ab152cd269302500bd063f37624ee210cd04b4936ed671f3b1" dependencies = [ "cc", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -9716,7 +9716,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]] From a65a5b1445ba7ec9b10baf7ecb28f7a65bbb13ce Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Thu, 14 Nov 2024 13:12:27 +0400 Subject: [PATCH 1672/1963] fix(`forge eip712`): handle recursive types (#9319) fix(forge eip712): handle recursive types --- crates/forge/bin/cmd/eip712.rs | 23 +++++++++++++---------- crates/forge/tests/cli/eip712.rs | 32 +++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs index 2ab15f05488ed..5014d38d703b5 100644 --- a/crates/forge/bin/cmd/eip712.rs +++ b/crates/forge/bin/cmd/eip712.rs @@ -126,7 +126,9 @@ impl Resolver { /// Returns `None` if struct contains any fields that are not supported by EIP-712 (e.g. /// mappings or function pointers). pub fn resolve_struct_eip712(&self, id: usize) -> Result> { - self.resolve_eip712_inner(id, &mut Default::default(), true, None) + let mut subtypes = BTreeMap::new(); + subtypes.insert(self.structs[&id].name.clone(), id); + self.resolve_eip712_inner(id, &mut subtypes, true, None) } fn resolve_eip712_inner( @@ -205,8 +207,17 @@ impl Resolver { // If we've already seen struct with this ID, just use assigned name. if let Some((name, _)) = subtypes.iter().find(|(_, id)| **id == def.id) { name.clone() - // Otherwise, try assigning a new name. } else { + // Otherwise, assign new name. + let mut i = 0; + let mut name = def.name.clone(); + while subtypes.contains_key(&name) { + i += 1; + name = format!("{}_{i}", def.name); + } + + subtypes.insert(name.clone(), def.id); + // iterate over members to check if they are resolvable and to populate subtypes for member in &def.members { if self.resolve_type( @@ -218,14 +229,6 @@ impl Resolver { return Ok(None) } } - let mut i = 0; - let mut name = def.name.clone(); - while subtypes.contains_key(&name) { - i += 1; - name = format!("{}_{i}", def.name); - } - - subtypes.insert(name.clone(), def.id); name }; diff --git a/crates/forge/tests/cli/eip712.rs b/crates/forge/tests/cli/eip712.rs index 2f832ae315c62..9ec944631d9db 100644 --- a/crates/forge/tests/cli/eip712.rs +++ b/crates/forge/tests/cli/eip712.rs @@ -19,6 +19,11 @@ library Structs { struct Complex { Structs2.Foo foo2; Foo[] foos; + Rec[][] recs; + } + + struct Rec { + Rec[] rec; } } @@ -26,6 +31,23 @@ library Structs2 { struct Foo { uint256 id; } + + struct Rec { + Bar[] bar; + } + + struct Bar { + Rec rec; + } + + struct FooBar { + Foo[] foos; + Bar[] bars; + Structs.Foo foo; + Structs.Bar bar; + Rec[] recs; + Structs.Rec rec; + } } "#, ) @@ -42,10 +64,18 @@ Bar(Art art)Art(uint256 id) Art(uint256 id) -Complex(Foo foo2,Foo_1[] foos)Art(uint256 id)Bar(Art art)Foo(uint256 id)Foo_1(Bar bar) +Complex(Foo foo2,Foo_1[] foos,Rec[][] recs)Art(uint256 id)Bar(Art art)Foo(uint256 id)Foo_1(Bar bar)Rec(Rec[] rec) + +Rec(Rec[] rec) Foo(uint256 id) +Rec(Bar[] bar)Bar(Rec rec) + +Bar(Rec rec)Rec(Bar[] bar) + +FooBar(Foo[] foos,Bar[] bars,Foo_1 foo,Bar_1 bar,Rec[] recs,Rec_1 rec)Art(uint256 id)Bar(Rec rec)Bar_1(Art art)Foo(uint256 id)Foo_1(Bar_1 bar)Rec(Bar[] bar)Rec_1(Rec_1[] rec) + "#]], ); From 36cbce7c78b56dd68359084a5d8b03f84efed8fb Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 14 Nov 2024 20:34:12 +0200 Subject: [PATCH 1673/1963] feat(forge): allow `--verifier custom` option (#9311) * feat(forge): allow `--verifier custom` option * Changes after review: add description of custom verifier, reorg err message, add custom verifier api key * Fix descriptions * Update crates/verify/src/provider.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/common/src/retry.rs | 2 +- crates/verify/src/bytecode.rs | 5 +++++ crates/verify/src/provider.rs | 7 +++++++ crates/verify/src/verify.rs | 17 +++++++++++++++-- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs index 7f649c7ed35a4..59ba2055f8a35 100644 --- a/crates/common/src/retry.rs +++ b/crates/common/src/retry.rs @@ -83,6 +83,6 @@ impl Retry { fn handle_err(&mut self, err: Error) { self.retries -= 1; - warn!("erroneous attempt ({} tries remaining): {}", self.retries, err.root_cause()); + let _ = sh_warn!("{} ({} tries remaining)", err.root_cause(), self.retries); } } diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index a8fc1ace70668..0c3f9e5b0a91f 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -96,6 +96,11 @@ impl figment::Provider for VerifyBytecodeArgs { &self, ) -> Result, figment::Error> { let mut dict = self.etherscan.dict(); + + if let Some(api_key) = &self.verifier.verifier_api_key { + dict.insert("etherscan_api_key".into(), api_key.as_str().into()); + } + if let Some(block) = &self.block { dict.insert("block".into(), figment::value::Value::serialize(block)?); } diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index 6e5b29d5e34c7..bc01bd9e304d6 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -124,6 +124,7 @@ impl FromStr for VerificationProviderType { "s" | "sourcify" => Ok(Self::Sourcify), "b" | "blockscout" => Ok(Self::Blockscout), "o" | "oklink" => Ok(Self::Oklink), + "c" | "custom" => Ok(Self::Custom), _ => Err(format!("Unknown provider: {s}")), } } @@ -144,6 +145,9 @@ impl fmt::Display for VerificationProviderType { Self::Oklink => { write!(f, "oklink")?; } + Self::Custom => { + write!(f, "custom")?; + } }; Ok(()) } @@ -156,6 +160,8 @@ pub enum VerificationProviderType { Sourcify, Blockscout, Oklink, + /// Custom verification provider, requires compatibility with the Etherscan API. + Custom, } impl VerificationProviderType { @@ -171,6 +177,7 @@ impl VerificationProviderType { Self::Sourcify => Ok(Box::::default()), Self::Blockscout => Ok(Box::::default()), Self::Oklink => Ok(Box::::default()), + Self::Custom => Ok(Box::::default()), } } } diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index 5f3e55329d888..89cfd99aa676c 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -31,14 +31,22 @@ pub struct VerifierArgs { #[arg(long, help_heading = "Verifier options", default_value = "etherscan", value_enum)] pub verifier: VerificationProviderType, - /// The verifier URL, if using a custom provider + /// The verifier API KEY, if using a custom provider. + #[arg(long, help_heading = "Verifier options", env = "VERIFIER_API_KEY")] + pub verifier_api_key: Option, + + /// The verifier URL, if using a custom provider. #[arg(long, help_heading = "Verifier options", env = "VERIFIER_URL")] pub verifier_url: Option, } impl Default for VerifierArgs { fn default() -> Self { - Self { verifier: VerificationProviderType::Etherscan, verifier_url: None } + Self { + verifier: VerificationProviderType::Etherscan, + verifier_api_key: None, + verifier_url: None, + } } } @@ -162,6 +170,11 @@ impl figment::Provider for VerifyArgs { if self.via_ir { dict.insert("via_ir".to_string(), figment::value::Value::serialize(self.via_ir)?); } + + if let Some(api_key) = &self.verifier.verifier_api_key { + dict.insert("etherscan_api_key".into(), api_key.as_str().into()); + } + Ok(figment::value::Map::from([(Config::selected_profile(), dict)])) } } From c526cab8364fdf410fb8b04d256ca83d4dc632bf Mon Sep 17 00:00:00 2001 From: James <107906898+EdwardJES@users.noreply.github.com> Date: Fri, 15 Nov 2024 21:02:44 +0700 Subject: [PATCH 1674/1963] feat(`cheatcodes`): add `delegatecall` to `prank`ing (#8863) * begin api and rough comments * impl cheatcode * add check for eoa * fix eoa check on each prank call * add to assets * prank compiling * delegate call working, storage not upating * delegate call working, some tidy up * add prank2 calls * impl remaining tests * formatting * forge fmt * add pranks to cheatcodes.json * run cargo cheats * If verbosity level is 1 or higher, it shows dirty files. * Fix, add EOA prank test * Revert "If verbosity level is 1 or higher, it shows dirty files." This reverts commit d03ac1d59acb8096b12f46dfb5a397bcc4d28ce9. * Fix test * apply on extdelegatecall --------- Co-authored-by: mgiagante <251503-mgiagante@users.noreply.gitlab.com> Co-authored-by: grandizzy --- crates/cheatcodes/assets/cheatcodes.json | 80 ++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 16 ++++ crates/cheatcodes/src/evm/prank.rs | 58 +++++++++++- crates/cheatcodes/src/inspector.rs | 15 ++- testdata/cheats/Vm.sol | 4 + testdata/default/cheats/Prank.t.sol | 114 +++++++++++++++++++++++ 6 files changed, 281 insertions(+), 6 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 41797106d6bb0..347d738e01ec3 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -7182,6 +7182,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "prank_2", + "description": "Sets the *next* delegate call's `msg.sender` to be the input address.", + "declaration": "function prank(address msgSender, bool delegateCall) external;", + "visibility": "external", + "mutability": "", + "signature": "prank(address,bool)", + "selector": "0xa7f8bf5c", + "selectorBytes": [ + 167, + 248, + 191, + 92 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "prank_3", + "description": "Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", + "declaration": "function prank(address msgSender, address txOrigin, bool delegateCall) external;", + "visibility": "external", + "mutability": "", + "signature": "prank(address,address,bool)", + "selector": "0x7d73d042", + "selectorBytes": [ + 125, + 115, + 208, + 66 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "prevrandao_0", @@ -9288,6 +9328,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "startPrank_2", + "description": "Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called.", + "declaration": "function startPrank(address msgSender, bool delegateCall) external;", + "visibility": "external", + "mutability": "", + "signature": "startPrank(address,bool)", + "selector": "0x1cc0b435", + "selectorBytes": [ + 28, + 192, + 180, + 53 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "startPrank_3", + "description": "Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.", + "declaration": "function startPrank(address msgSender, address txOrigin, bool delegateCall) external;", + "visibility": "external", + "mutability": "", + "signature": "startPrank(address,address,bool)", + "selector": "0x4eb859b5", + "selectorBytes": [ + 78, + 184, + 89, + 181 + ] + }, + "group": "evm", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "startSnapshotGas_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 3c11cd53aca3e..d703f48e7ae54 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -600,6 +600,22 @@ interface Vm { #[cheatcode(group = Evm, safety = Unsafe)] function startPrank(address msgSender, address txOrigin) external; + /// Sets the *next* delegate call's `msg.sender` to be the input address. + #[cheatcode(group = Evm, safety = Unsafe)] + function prank(address msgSender, bool delegateCall) external; + + /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called. + #[cheatcode(group = Evm, safety = Unsafe)] + function startPrank(address msgSender, bool delegateCall) external; + + /// Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input. + #[cheatcode(group = Evm, safety = Unsafe)] + function prank(address msgSender, address txOrigin, bool delegateCall) external; + + /// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input. + #[cheatcode(group = Evm, safety = Unsafe)] + function startPrank(address msgSender, address txOrigin, bool delegateCall) external; + /// Resets subsequent calls' `msg.sender` to be `address(this)`. #[cheatcode(group = Evm, safety = Unsafe)] function stopPrank() external; diff --git a/crates/cheatcodes/src/evm/prank.rs b/crates/cheatcodes/src/evm/prank.rs index a310e28e515bc..1d7ca5a079471 100644 --- a/crates/cheatcodes/src/evm/prank.rs +++ b/crates/cheatcodes/src/evm/prank.rs @@ -16,6 +16,8 @@ pub struct Prank { pub depth: u64, /// Whether the prank stops by itself after the next call pub single_call: bool, + /// Whether the prank should be be applied to delegate call + pub delegate_call: bool, /// Whether the prank has been used yet (false if unused) pub used: bool, } @@ -29,8 +31,18 @@ impl Prank { new_origin: Option
, depth: u64, single_call: bool, + delegate_call: bool, ) -> Self { - Self { prank_caller, prank_origin, new_caller, new_origin, depth, single_call, used: false } + Self { + prank_caller, + prank_origin, + new_caller, + new_origin, + depth, + single_call, + delegate_call, + used: false, + } } /// Apply the prank by setting `used` to true iff it is false @@ -47,28 +59,56 @@ impl Prank { impl Cheatcode for prank_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender } = self; - prank(ccx, msgSender, None, true) + prank(ccx, msgSender, None, true, false) } } impl Cheatcode for startPrank_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender } = self; - prank(ccx, msgSender, None, false) + prank(ccx, msgSender, None, false, false) } } impl Cheatcode for prank_1Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender, txOrigin } = self; - prank(ccx, msgSender, Some(txOrigin), true) + prank(ccx, msgSender, Some(txOrigin), true, false) } } impl Cheatcode for startPrank_1Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { msgSender, txOrigin } = self; - prank(ccx, msgSender, Some(txOrigin), false) + prank(ccx, msgSender, Some(txOrigin), false, false) + } +} + +impl Cheatcode for prank_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender, delegateCall } = self; + prank(ccx, msgSender, None, true, *delegateCall) + } +} + +impl Cheatcode for startPrank_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender, delegateCall } = self; + prank(ccx, msgSender, None, false, *delegateCall) + } +} + +impl Cheatcode for prank_3Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender, txOrigin, delegateCall } = self; + prank(ccx, msgSender, Some(txOrigin), true, *delegateCall) + } +} + +impl Cheatcode for startPrank_3Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { msgSender, txOrigin, delegateCall } = self; + prank(ccx, msgSender, Some(txOrigin), false, *delegateCall) } } @@ -85,6 +125,7 @@ fn prank( new_caller: &Address, new_origin: Option<&Address>, single_call: bool, + delegate_call: bool, ) -> Result { let prank = Prank::new( ccx.caller, @@ -93,8 +134,15 @@ fn prank( new_origin.copied(), ccx.ecx.journaled_state.depth(), single_call, + delegate_call, ); + // Ensure that code exists at `msg.sender` if delegate calling. + if delegate_call { + let code = ccx.code(*new_caller)?; + ensure!(!code.is_empty(), "cannot `prank` delegate call from an EOA"); + } + if let Some(Prank { used, single_call: current_single_call, .. }) = ccx.state.prank { ensure!(used, "cannot overwrite a prank until it is applied at least once"); // This case can only fail if the user calls `vm.startPrank` and then `vm.prank` later on. diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 684f5eb110d2f..046a495a10e86 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -42,7 +42,7 @@ use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner}; use rand::Rng; use revm::{ interpreter::{ - opcode as op, CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, + opcode as op, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, @@ -941,6 +941,19 @@ where { // Apply our prank if let Some(prank) = &self.prank { + // Apply delegate call, `call.caller`` will not equal `prank.prank_caller` + if let CallScheme::DelegateCall | CallScheme::ExtDelegateCall = call.scheme { + if prank.delegate_call { + call.target_address = prank.new_caller; + call.caller = prank.new_caller; + let acc = ecx.journaled_state.account(prank.new_caller); + call.value = CallValue::Apparent(acc.info.balance); + if let Some(new_origin) = prank.new_origin { + ecx.env.tx.caller = new_origin; + } + } + } + if ecx.journaled_state.depth() >= prank.depth && call.caller == prank.prank_caller { let mut prank_applied = false; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index d3a377f403ef0..2004c44563d01 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -353,6 +353,8 @@ interface Vm { function pauseTracing() external view; function prank(address msgSender) external; function prank(address msgSender, address txOrigin) external; + function prank(address msgSender, bool delegateCall) external; + function prank(address msgSender, address txOrigin, bool delegateCall) external; function prevrandao(bytes32 newPrevrandao) external; function prevrandao(uint256 newPrevrandao) external; function projectRoot() external view returns (string memory path); @@ -458,6 +460,8 @@ interface Vm { function startMappingRecording() external; function startPrank(address msgSender) external; function startPrank(address msgSender, address txOrigin) external; + function startPrank(address msgSender, bool delegateCall) external; + function startPrank(address msgSender, address txOrigin, bool delegateCall) external; function startSnapshotGas(string calldata name) external; function startSnapshotGas(string calldata group, string calldata name) external; function startStateDiffRecording() external; diff --git a/testdata/default/cheats/Prank.t.sol b/testdata/default/cheats/Prank.t.sol index d833c0513d832..130e819606a28 100644 --- a/testdata/default/cheats/Prank.t.sol +++ b/testdata/default/cheats/Prank.t.sol @@ -85,9 +85,123 @@ contract NestedPranker { } } +contract ImplementationTest { + uint256 public num; + address public sender; + + function assertCorrectCaller(address expectedSender) public { + require(msg.sender == expectedSender); + } + + function assertCorrectOrigin(address expectedOrigin) public { + require(tx.origin == expectedOrigin); + } + + function setNum(uint256 _num) public { + num = _num; + } +} + +contract ProxyTest { + uint256 public num; + address public sender; +} + contract PrankTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); + function testPrankDelegateCallPrank2() public { + ProxyTest proxy = new ProxyTest(); + ImplementationTest impl = new ImplementationTest(); + vm.prank(address(proxy), true); + + // Assert correct `msg.sender` + (bool success,) = + address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", address(proxy))); + require(success, "prank2: delegate call failed assertCorrectCaller"); + + // Assert storage updates + uint256 num = 42; + vm.prank(address(proxy), true); + (bool successTwo,) = address(impl).delegatecall(abi.encodeWithSignature("setNum(uint256)", num)); + require(successTwo, "prank2: delegate call failed setNum"); + require(proxy.num() == num, "prank2: proxy's storage was not set correctly"); + vm.stopPrank(); + } + + function testPrankDelegateCallStartPrank2() public { + ProxyTest proxy = new ProxyTest(); + ImplementationTest impl = new ImplementationTest(); + vm.startPrank(address(proxy), true); + + // Assert correct `msg.sender` + (bool success,) = + address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", address(proxy))); + require(success, "startPrank2: delegate call failed assertCorrectCaller"); + + // Assert storage updates + uint256 num = 42; + (bool successTwo,) = address(impl).delegatecall(abi.encodeWithSignature("setNum(uint256)", num)); + require(successTwo, "startPrank2: delegate call failed setNum"); + require(proxy.num() == num, "startPrank2: proxy's storage was not set correctly"); + vm.stopPrank(); + } + + function testPrankDelegateCallPrank3(address origin) public { + ProxyTest proxy = new ProxyTest(); + ImplementationTest impl = new ImplementationTest(); + vm.prank(address(proxy), origin, true); + + // Assert correct `msg.sender` + (bool success,) = + address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", address(proxy))); + require(success, "prank3: delegate call failed assertCorrectCaller"); + + // Assert correct `tx.origin` + vm.prank(address(proxy), origin, true); + (bool successTwo,) = address(impl).delegatecall(abi.encodeWithSignature("assertCorrectOrigin(address)", origin)); + require(successTwo, "prank3: delegate call failed assertCorrectOrigin"); + + // Assert storage updates + uint256 num = 42; + vm.prank(address(proxy), address(origin), true); + (bool successThree,) = address(impl).delegatecall(abi.encodeWithSignature("setNum(uint256)", num)); + require(successThree, "prank3: delegate call failed setNum"); + require(proxy.num() == num, "prank3: proxy's storage was not set correctly"); + vm.stopPrank(); + } + + function testPrankDelegateCallStartPrank3(address origin) public { + ProxyTest proxy = new ProxyTest(); + ImplementationTest impl = new ImplementationTest(); + vm.startPrank(address(proxy), origin, true); + + // Assert correct `msg.sender` + (bool success,) = + address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", address(proxy))); + require(success, "startPrank3: delegate call failed assertCorrectCaller"); + + // Assert correct `tx.origin` + (bool successTwo,) = address(impl).delegatecall(abi.encodeWithSignature("assertCorrectOrigin(address)", origin)); + require(successTwo, "startPrank3: delegate call failed assertCorrectOrigin"); + + // Assert storage updates + uint256 num = 42; + (bool successThree,) = address(impl).delegatecall(abi.encodeWithSignature("setNum(uint256)", num)); + require(successThree, "startPrank3: delegate call failed setNum"); + require(proxy.num() == num, "startPrank3: proxy's storage was not set correctly"); + vm.stopPrank(); + } + + function testFailPrankDelegateCallToEOA() public { + uint256 privateKey = uint256(keccak256(abi.encodePacked("alice"))); + address alice = vm.addr(privateKey); + ImplementationTest impl = new ImplementationTest(); + vm.prank(alice, true); + // Should fail when EOA pranked with delegatecall. + address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", alice)); + } + function testPrankSender(address sender) public { // Perform the prank Victim victim = new Victim(); From 9d7557fcf0f758ea0e8ef5d2db853bd1e1d660dc Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:29:06 +0200 Subject: [PATCH 1675/1963] feat(forge build): err if no source file in specified paths (#9329) --- crates/forge/bin/cmd/build.rs | 3 +++ crates/forge/tests/cli/cmd.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index f2a1891e26343..f803f45f6cf05 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -94,6 +94,9 @@ impl BuildArgs { let path = if joined.exists() { &joined } else { path }; files.extend(source_files_iter(path, MultiCompilerLanguage::FILE_EXTENSIONS)); } + if files.is_empty() { + eyre::bail!("No source files found in specified build paths.") + } } let format_json = shell::is_json(); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index d4f3973a337a6..e2e38cc3c1f10 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2829,7 +2829,7 @@ Compiler run successful! "#]]); // Expect compilation to be skipped as no files have changed - cmd.arg("build").assert_success().stdout_eq(str![[r#" + cmd.forge_fuse().arg("build").assert_success().stdout_eq(str![[r#" No files changed, compilation skipped "#]]); @@ -2952,6 +2952,14 @@ Compiler run successful! [SOLC_VERSION] [ELAPSED] Compiler run successful! +"#]]); + + // Fail if no source file found. + prj.clear(); + cmd.forge_fuse(); + cmd.args(["build", "test/Dummy.sol", "--force"]).assert_failure().stderr_eq(str![[r#" +Error: No source files found in specified build paths. + "#]]); }); From a79dfaed6fc6f88cda5f314a25d1b484d9d8c051 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:01:01 +0100 Subject: [PATCH 1676/1963] feat(`forge build`): add `--sizes` and `--names` JSON compatibility (#9321) * add --sizes and --names JSON compatibility + generalize report kind * add additional json output tests * fix feedback nit --- crates/common/Cargo.toml | 2 +- crates/common/src/compile.rs | 91 +++++++++++++++++++++++++------- crates/common/src/lib.rs | 1 + crates/common/src/reports.rs | 19 +++++++ crates/forge/bin/cmd/build.rs | 3 +- crates/forge/bin/cmd/test/mod.rs | 3 +- crates/forge/src/gas_report.rs | 37 ++++++------- crates/forge/tests/cli/build.rs | 45 ++++++++++++++++ crates/forge/tests/cli/cmd.rs | 19 +++++++ 9 files changed, 175 insertions(+), 45 deletions(-) create mode 100644 crates/common/src/reports.rs diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index af95e94bcc35a..8fa745a139826 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -54,7 +54,7 @@ num-format.workspace = true reqwest.workspace = true semver.workspace = true serde_json.workspace = true -serde.workspace = true +serde = { workspace = true, features = ["derive"] } thiserror.workspace = true tokio.workspace = true tracing.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 4c7e7ba0fcef4..507f328307c50 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,6 +1,11 @@ //! Support for compiling [foundry_compilers::Project] -use crate::{term::SpinnerReporter, TestFunctionExt}; +use crate::{ + reports::{report_kind, ReportKind}, + shell, + term::SpinnerReporter, + TestFunctionExt, +}; use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, Table}; use eyre::Result; use foundry_block_explorers::contract::Metadata; @@ -181,11 +186,13 @@ impl ProjectCompiler { } if !quiet { - if output.is_unchanged() { - sh_println!("No files changed, compilation skipped")?; - } else { - // print the compiler output / warnings - sh_println!("{output}")?; + if !shell::is_json() { + if output.is_unchanged() { + sh_println!("No files changed, compilation skipped")?; + } else { + // print the compiler output / warnings + sh_println!("{output}")?; + } } self.handle_output(&output); @@ -205,26 +212,32 @@ impl ProjectCompiler { for (name, (_, version)) in output.versioned_artifacts() { artifacts.entry(version).or_default().push(name); } - for (version, names) in artifacts { - let _ = sh_println!( - " compiler version: {}.{}.{}", - version.major, - version.minor, - version.patch - ); - for name in names { - let _ = sh_println!(" - {name}"); + + if shell::is_json() { + let _ = sh_println!("{}", serde_json::to_string(&artifacts).unwrap()); + } else { + for (version, names) in artifacts { + let _ = sh_println!( + " compiler version: {}.{}.{}", + version.major, + version.minor, + version.patch + ); + for name in names { + let _ = sh_println!(" - {name}"); + } } } } if print_sizes { // add extra newline if names were already printed - if print_names { + if print_names && !shell::is_json() { let _ = sh_println!(); } - let mut size_report = SizeReport { contracts: BTreeMap::new() }; + let mut size_report = + SizeReport { report_kind: report_kind(), contracts: BTreeMap::new() }; let artifacts: BTreeMap<_, _> = output .artifact_ids() @@ -278,6 +291,8 @@ const CONTRACT_INITCODE_SIZE_LIMIT: usize = 49152; /// Contracts with info about their size pub struct SizeReport { + /// What kind of report to generate. + report_kind: ReportKind, /// `contract name -> info` pub contracts: BTreeMap, } @@ -316,6 +331,43 @@ impl SizeReport { impl Display for SizeReport { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + match self.report_kind { + ReportKind::Markdown => { + let table = self.format_table_output(); + writeln!(f, "{table}")?; + } + ReportKind::JSON => { + writeln!(f, "{}", self.format_json_output())?; + } + } + + Ok(()) + } +} + +impl SizeReport { + fn format_json_output(&self) -> String { + let contracts = self + .contracts + .iter() + .filter(|(_, c)| !c.is_dev_contract && (c.runtime_size > 0 || c.init_size > 0)) + .map(|(name, contract)| { + ( + name.clone(), + serde_json::json!({ + "runtime_size": contract.runtime_size, + "init_size": contract.init_size, + "runtime_margin": CONTRACT_RUNTIME_SIZE_LIMIT as isize - contract.runtime_size as isize, + "init_margin": CONTRACT_INITCODE_SIZE_LIMIT as isize - contract.init_size as isize, + }), + ) + }) + .collect::>(); + + serde_json::to_string(&contracts).unwrap() + } + + fn format_table_output(&self) -> Table { let mut table = Table::new(); table.load_preset(ASCII_MARKDOWN); table.set_header([ @@ -366,8 +418,7 @@ impl Display for SizeReport { ]); } - writeln!(f, "{table}")?; - Ok(()) + table } } @@ -476,7 +527,7 @@ pub fn etherscan_project( /// Configures the reporter and runs the given closure. pub fn with_compilation_reporter(quiet: bool, f: impl FnOnce() -> O) -> O { #[allow(clippy::collapsible_else_if)] - let reporter = if quiet { + let reporter = if quiet || shell::is_json() { Report::new(NoReporter::default()) } else { if std::io::stdout().is_terminal() { diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 68559d081b0ae..259e8fee2dac0 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -26,6 +26,7 @@ pub mod errors; pub mod evm; pub mod fs; pub mod provider; +pub mod reports; pub mod retry; pub mod selectors; pub mod serde_helpers; diff --git a/crates/common/src/reports.rs b/crates/common/src/reports.rs new file mode 100644 index 0000000000000..adbdc11bf66a9 --- /dev/null +++ b/crates/common/src/reports.rs @@ -0,0 +1,19 @@ +use serde::{Deserialize, Serialize}; + +use crate::shell; + +#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] +pub enum ReportKind { + #[default] + Markdown, + JSON, +} + +/// Determine the kind of report to generate based on the current shell. +pub fn report_kind() -> ReportKind { + if shell::is_json() { + ReportKind::JSON + } else { + ReportKind::Markdown + } +} diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index f803f45f6cf05..3efe68db77224 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -105,12 +105,11 @@ impl BuildArgs { .print_names(self.names) .print_sizes(self.sizes) .ignore_eip_3860(self.ignore_eip_3860) - .quiet(format_json) .bail(!format_json); let output = compiler.compile(&project)?; - if format_json { + if format_json && !self.names && !self.sizes { sh_println!("{}", serde_json::to_string_pretty(&output.output())?)?; } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 77ae5d2631f66..613d570785b99 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -5,7 +5,7 @@ use clap::{Parser, ValueHint}; use eyre::{Context, OptionExt, Result}; use forge::{ decode::decode_console_logs, - gas_report::{GasReport, GasReportKind}, + gas_report::GasReport, multi_runner::matches_contract, result::{SuiteResult, TestOutcome, TestStatus}, traces::{ @@ -583,7 +583,6 @@ impl TestArgs { config.gas_reports.clone(), config.gas_reports_ignore.clone(), config.gas_reports_include_tests, - if shell::is_json() { GasReportKind::JSON } else { GasReportKind::Markdown }, ) }); diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index e3e44994b91c3..7e87af0770299 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -6,31 +6,23 @@ use crate::{ }; use alloy_primitives::map::HashSet; use comfy_table::{presets::ASCII_MARKDOWN, *}; -use foundry_common::{calc, TestFunctionExt}; +use foundry_common::{ + calc, + reports::{report_kind, ReportKind}, + TestFunctionExt, +}; use foundry_evm::traces::CallKind; use serde::{Deserialize, Serialize}; use serde_json::json; use std::{collections::BTreeMap, fmt::Display}; -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub enum GasReportKind { - Markdown, - JSON, -} - -impl Default for GasReportKind { - fn default() -> Self { - Self::Markdown - } -} - /// Represents the gas report for a set of contracts. #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct GasReport { /// Whether to report any contracts. report_any: bool, /// What kind of report to generate. - report_type: GasReportKind, + report_kind: ReportKind, /// Contracts to generate the report for. report_for: HashSet, /// Contracts to ignore when generating the report. @@ -47,13 +39,18 @@ impl GasReport { report_for: impl IntoIterator, ignore: impl IntoIterator, include_tests: bool, - report_kind: GasReportKind, ) -> Self { let report_for = report_for.into_iter().collect::>(); let ignore = ignore.into_iter().collect::>(); let report_any = report_for.is_empty() || report_for.contains("*"); - let report_type = report_kind; - Self { report_any, report_type, report_for, ignore, include_tests, ..Default::default() } + Self { + report_any, + report_kind: report_kind(), + report_for, + ignore, + include_tests, + ..Default::default() + } } /// Whether the given contract should be reported. @@ -158,8 +155,8 @@ impl GasReport { impl Display for GasReport { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - match self.report_type { - GasReportKind::Markdown => { + match self.report_kind { + ReportKind::Markdown => { for (name, contract) in &self.contracts { if contract.functions.is_empty() { trace!(name, "gas report contract without functions"); @@ -171,7 +168,7 @@ impl Display for GasReport { writeln!(f, "\n")?; } } - GasReportKind::JSON => { + ReportKind::JSON => { writeln!(f, "{}", &self.format_json_output())?; } } diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 4b257fe8d20a2..dd25459957533 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -82,6 +82,20 @@ forgetest!(initcode_size_exceeds_limit, |prj, cmd| { ... "# ]); + + cmd.forge_fuse().args(["build", "--sizes", "--json"]).assert_failure().stdout_eq( + str![[r#" +{ + "HugeContract":{ + "runtime_size":202, + "init_size":49359, + "runtime_margin":24374, + "init_margin":-207 + } +} +"#]] + .is_json(), + ); }); forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { @@ -95,6 +109,23 @@ forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { ... "# ]); + + cmd.forge_fuse() + .args(["build", "--sizes", "--ignore-eip-3860", "--json"]) + .assert_success() + .stdout_eq( + str![[r#" +{ + "HugeContract": { + "runtime_size": 202, + "init_size": 49359, + "runtime_margin": 24374, + "init_margin": -207 + } +} +"#]] + .is_json(), + ); }); // tests build output is as expected @@ -118,6 +149,20 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { ... "# ]); + + cmd.forge_fuse().args(["build", "--sizes", "--json"]).assert_success().stdout_eq( + str![[r#" +{ + "Counter": { + "runtime_size": 247, + "init_size": 277, + "runtime_margin": 24329, + "init_margin": 48875 + } +} +"#]] + .is_json(), + ); }); // tests that skip key in config can be used to skip non-compilable contract diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index e2e38cc3c1f10..1e887791e5696 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2977,6 +2977,20 @@ Compiler run successful! "#]]); + + cmd.forge_fuse().args(["build", "--sizes", "--json"]).assert_success().stdout_eq( + str![[r#" +{ + "Counter": { + "runtime_size": 247, + "init_size": 277, + "runtime_margin": 24329, + "init_margin": 48875 + } +} +"#]] + .is_json(), + ); }); // checks that build --names includes all contracts even if unchanged @@ -2992,6 +3006,11 @@ Compiler run successful! ... "#]]); + + cmd.forge_fuse() + .args(["build", "--names", "--json"]) + .assert_success() + .stdout_eq(str![[r#""{...}""#]].is_json()); }); // From 3eb47ea41ba0b26f0c97ce20cad177a43f55d3b5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sat, 16 Nov 2024 12:12:14 +0200 Subject: [PATCH 1677/1963] chore: fix clippy (#9333) --- crates/cast/bin/tx.rs | 2 +- crates/cheatcodes/src/json.rs | 2 +- crates/cheatcodes/src/test/expect.rs | 2 +- crates/common/src/provider/mod.rs | 2 +- crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/utils.rs | 2 +- crates/evm/coverage/src/anchors.rs | 2 +- crates/fmt/src/comments.rs | 2 +- crates/fmt/src/formatter.rs | 12 ++++++------ crates/forge/bin/cmd/init.rs | 2 +- crates/forge/src/runner.rs | 2 +- crates/script/src/transaction.rs | 2 +- crates/script/src/verify.rs | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index a6f64b3db2d0b..29f8e2435186c 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -252,7 +252,7 @@ where }; if self.state.to.is_none() && code.is_none() { - let has_value = self.tx.value.map_or(false, |v| !v.is_zero()); + let has_value = self.tx.value.is_some_and(|v| !v.is_zero()); let has_auth = self.auth.is_some(); // We only allow user to omit the recipient address if transaction is an EIP-7702 tx // without a value. diff --git a/crates/cheatcodes/src/json.rs b/crates/cheatcodes/src/json.rs index 0908f247ca944..6ad36e4742901 100644 --- a/crates/cheatcodes/src/json.rs +++ b/crates/cheatcodes/src/json.rs @@ -682,7 +682,7 @@ mod tests { match value { DynSolValue::Tuple(_) | DynSolValue::CustomStruct { .. } => true, DynSolValue::Array(v) | DynSolValue::FixedArray(v) => { - v.first().map_or(false, contains_tuple) + v.first().is_some_and(contains_tuple) } _ => false, } diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 602ac512514ec..3ee58407a7e67 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -633,7 +633,7 @@ pub(crate) fn handle_expect_emit( return false } // Maybe match source address. - if event_to_fill_or_check.address.map_or(false, |addr| addr != log.address) { + if event_to_fill_or_check.address.is_some_and(|addr| addr != log.address) { return false; } // Maybe match data. diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index 4fb9e29aec0ce..75efdb869f9f2 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -137,7 +137,7 @@ impl ProviderBuilder { .wrap_err_with(|| format!("invalid provider URL: {url_str:?}")); // Use the final URL string to guess if it's a local URL. - let is_local = url.as_ref().map_or(false, |url| guess_local_url(url.as_str())); + let is_local = url.as_ref().is_ok_and(|url| guess_local_url(url.as_str())); Self { url, diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index c9bb890471811..e70468ef944c2 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1972,7 +1972,7 @@ pub fn update_state( persistent_accounts: Option<&HashSet
>, ) -> Result<(), DB::Error> { for (addr, acc) in state.iter_mut() { - if !persistent_accounts.map_or(false, |accounts| accounts.contains(addr)) { + if !persistent_accounts.is_some_and(|accounts| accounts.contains(addr)) { acc.info = db.basic(*addr)?.unwrap_or_default(); for (key, val) in acc.storage.iter_mut() { val.present_value = db.storage(*addr, *key)?; diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index bd17aae442922..d76cd087ce168 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -236,7 +236,7 @@ pub fn create2_handler_register( if create2_overrides_inner .borrow() .last() - .map_or(false, |(depth, _)| *depth == ctx.evm.journaled_state.depth()) + .is_some_and(|(depth, _)| *depth == ctx.evm.journaled_state.depth()) { let (_, call_inputs) = create2_overrides_inner.borrow_mut().pop().unwrap(); outcome = ctx.external.call_end(&mut ctx.evm, &call_inputs, outcome); diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index f42fd1a627260..6643524d61de6 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -171,7 +171,7 @@ pub fn find_anchor_branch( /// Calculates whether `element` is within the range of the target `location`. fn is_in_source_range(element: &SourceElement, location: &SourceLocation) -> bool { // Source IDs must match. - let source_ids_match = element.index().map_or(false, |a| a as usize == location.source_id); + let source_ids_match = element.index().is_some_and(|a| a as usize == location.source_id); if !source_ids_match { return false; } diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index 90054f1325eeb..e3fb79043ec68 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -112,7 +112,7 @@ impl CommentWithMetadata { // line has something // check if the last comment after code was a postfix comment if last_comment - .map_or(false, |last| last.loc.end() > code_end && !last.is_prefix()) + .is_some_and(|last| last.loc.end() > code_end && !last.is_prefix()) { // get the indent size of the next item of code let next_indent_len = src[comment.loc().end()..] diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 6bb814e232691..8f52d9e259b89 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -88,7 +88,7 @@ struct Context { impl Context { /// Returns true if the current function context is the constructor pub(crate) fn is_constructor_function(&self) -> bool { - self.function.as_ref().map_or(false, |f| matches!(f.ty, FunctionTy::Constructor)) + self.function.as_ref().is_some_and(|f| matches!(f.ty, FunctionTy::Constructor)) } } @@ -341,7 +341,7 @@ impl<'a, W: Write> Formatter<'a, W> { _ => stmt.loc().start(), }; - self.find_next_line(start_from).map_or(false, |loc| loc >= end_at) + self.find_next_line(start_from).is_some_and(|loc| loc >= end_at) } } } @@ -560,7 +560,7 @@ impl<'a, W: Write> Formatter<'a, W> { fn write_doc_block_line(&mut self, comment: &CommentWithMetadata, line: &str) -> Result<()> { if line.trim().starts_with('*') { let line = line.trim().trim_start_matches('*'); - let needs_space = line.chars().next().map_or(false, |ch| !ch.is_whitespace()); + let needs_space = line.chars().next().is_some_and(|ch| !ch.is_whitespace()); write!(self.buf(), " *{}", if needs_space { " " } else { "" })?; self.write_comment_line(comment, line)?; self.write_whitespace_separator(true)?; @@ -1945,7 +1945,7 @@ impl Visitor for Formatter<'_, W> { )?; // EOF newline - if self.last_char().map_or(true, |char| char != '\n') { + if self.last_char() != Some('\n') { writeln!(self.buf())?; } @@ -3259,7 +3259,7 @@ impl Visitor for Formatter<'_, W> { // we can however check if the contract `is` the `base`, this however also does // not cover all cases - let is_contract_base = self.context.contract.as_ref().map_or(false, |contract| { + let is_contract_base = self.context.contract.as_ref().is_some_and(|contract| { contract.base.iter().any(|contract_base| { contract_base .name @@ -3280,7 +3280,7 @@ impl Visitor for Formatter<'_, W> { let mut base_or_modifier = self.visit_to_chunk(loc.start(), Some(loc.end()), base)?; let is_lowercase = - base_or_modifier.content.chars().next().map_or(false, |c| c.is_lowercase()); + base_or_modifier.content.chars().next().is_some_and(|c| c.is_lowercase()); if is_lowercase && base_or_modifier.content.ends_with("()") { base_or_modifier.content.truncate(base_or_modifier.content.len() - 2); } diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 82f296e417e9a..472d575bd9a8e 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -88,7 +88,7 @@ impl InitArgs { } } else { // if target is not empty - if root.read_dir().map_or(false, |mut i| i.next().is_some()) { + if root.read_dir().is_ok_and(|mut i| i.next().is_some()) { if !force { eyre::bail!( "Cannot run `init` on a non-empty directory.\n\ diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index d0f4f579e537a..8ed3706defa8b 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -296,7 +296,7 @@ impl ContractRunner<'_> { warnings, ) } - let call_after_invariant = after_invariant_fns.first().map_or(false, |after_invariant_fn| { + let call_after_invariant = after_invariant_fns.first().is_some_and(|after_invariant_fn| { let match_sig = after_invariant_fn.name == "afterInvariant"; if !match_sig { warnings.push(format!( diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index fcd4eefc36d4b..ca6a6226949ce 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -152,7 +152,7 @@ impl ScriptTransactionBuilder { // Add the additional contracts created in this transaction, so we can verify them later. created_contracts.retain(|contract| { // Filter out the contract that was created by the transaction itself. - self.transaction.contract_address.map_or(true, |addr| addr != contract.address) + self.transaction.contract_address != Some(contract.address) }); self.transaction.additional_contracts = created_contracts; diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index c013ee8628b97..55435c5592426 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -116,7 +116,7 @@ impl VerifyBundle { if data.split_at(create2_offset).1.starts_with(bytecode) { let constructor_args = data.split_at(create2_offset + bytecode.len()).1.to_vec(); - if artifact.source.extension().map_or(false, |e| e.to_str() == Some("vy")) { + if artifact.source.extension().is_some_and(|e| e.to_str() == Some("vy")) { warn!("Skipping verification of Vyper contract: {}", artifact.name); } From d14c09f15a9849fe177d097451919810e5877617 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 16 Nov 2024 13:27:41 +0100 Subject: [PATCH 1678/1963] test: enhance tests (#9334) * test: enhance tests * update ws url * Assert json unordered * Update crates/test-utils/src/util.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Changes after review * Fix rpc url test --------- Co-authored-by: grandizzy Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cast/tests/cli/main.rs | 9 +++------ crates/test-utils/src/rpc.rs | 5 ++++- crates/test-utils/src/util.rs | 11 ++++++++++- testdata/default/cheats/RpcUrls.t.sol | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index bec345b1710c9..a88369e97ffe2 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -650,8 +650,7 @@ casttest!(rpc_with_args, |_prj, cmd| { // Call `cast rpc eth_getBlockByNumber 0x123 false` cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_getBlockByNumber", "0x123", "false"]) - .assert_success() - .stdout_eq(str![[r#" + .assert_json_stdout(str![[r#" {"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} "#]]); @@ -670,8 +669,7 @@ casttest!(rpc_raw_params, |_prj, cmd| { "--raw", r#"["0x123", false]"#, ]) - .assert_success() - .stdout_eq(str![[r#" + .assert_json_stdout(str![[r#" {"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} "#]]); @@ -687,8 +685,7 @@ casttest!(rpc_raw_params_stdin, |_prj, cmd| { stdin.write_all(b"\n[\n\"0x123\",\nfalse\n]\n").unwrap(); }, ) - .assert_success() - .stdout_eq(str![[r#" + .assert_json_stdout(str![[r#" {"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} "#]]); diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index a974e395406dd..44deda60cddf4 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -10,6 +10,9 @@ use std::sync::{ // List of general purpose infura keys to rotate through static INFURA_KEYS: LazyLock> = LazyLock::new(|| { let mut keys = vec![ + "6cb19d07ca2d44f59befd61563b1037b", + "6d46c0cca653407b861f3f93f7b0236a", + "69a36846dec146e3a2898429be60be85", // "16a8be88795540b9b3903d8de0f7baa5", // "f4a0bdad42674adab5fc0ac077ffab2b", // "5c812e02193c4ba793f8c214317582bd", @@ -184,7 +187,7 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { match (is_ws, is_infura) { (false, true) => format!("https://{full}.infura.io/v3/{key}"), - (true, true) => format!("wss://{full}.infura.io/v3/{key}"), + (true, true) => format!("wss://{full}.infura.io/ws/v3/{key}"), (false, false) => format!("https://{full}.g.alchemy.com/v2/{key}"), (true, false) => format!("wss://{full}.g.alchemy.com/v2/{key}"), } diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 5d242800f6f99..8d7f6cbb5fcc3 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -11,7 +11,7 @@ use foundry_compilers::{ use foundry_config::Config; use parking_lot::Mutex; use regex::Regex; -use snapbox::{cmd::OutputAssert, str}; +use snapbox::{assert_data_eq, cmd::OutputAssert, str, IntoData}; use std::{ env, ffi::OsStr, @@ -893,6 +893,15 @@ impl TestCommand { self.assert().success() } + /// Runs the command and asserts that it resulted in success, with expected JSON data. + #[track_caller] + pub fn assert_json_stdout(&mut self, expected: impl IntoData) { + let expected = expected.is(snapbox::data::DataFormat::Json).unordered(); + let stdout = self.assert_success().get_output().stdout.clone(); + let actual = stdout.into_data().is(snapbox::data::DataFormat::Json).unordered(); + assert_data_eq!(actual, expected); + } + /// Runs the command and asserts that it **failed** nothing was printed to stdout. #[track_caller] pub fn assert_empty_stdout(&mut self) { diff --git a/testdata/default/cheats/RpcUrls.t.sol b/testdata/default/cheats/RpcUrls.t.sol index 7976fa5722432..aaa5a00bdd976 100644 --- a/testdata/default/cheats/RpcUrls.t.sol +++ b/testdata/default/cheats/RpcUrls.t.sol @@ -10,7 +10,7 @@ contract RpcUrlTest is DSTest { // returns the correct url function testCanGetRpcUrl() public { string memory url = vm.rpcUrl("mainnet"); - assertEq(bytes(url).length, 69); + assertTrue(bytes(url).length == 61 || bytes(url).length == 69); } // returns an error if env alias does not exist From e649e62f125244a3ef116be25dfdc81a2afbaf2a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 09:06:44 +0000 Subject: [PATCH 1679/1963] chore(deps): weekly `cargo update` (#9336) Locking 40 packages to latest compatible versions Updating allocator-api2 v0.2.19 -> v0.2.20 Updating alloy-dyn-abi v0.8.11 -> v0.8.12 Updating alloy-json-abi v0.8.11 -> v0.8.12 Updating alloy-primitives v0.8.11 -> v0.8.12 Updating alloy-sol-macro v0.8.11 -> v0.8.12 Updating alloy-sol-macro-expander v0.8.11 -> v0.8.12 Updating alloy-sol-macro-input v0.8.11 -> v0.8.12 Updating alloy-sol-type-parser v0.8.11 -> v0.8.12 Updating alloy-sol-types v0.8.11 -> v0.8.12 Updating aws-sdk-sts v1.49.0 -> v1.50.0 Updating axum v0.7.7 -> v0.7.9 Updating bstr v1.10.0 -> v1.11.0 Updating cc v1.1.37 -> v1.2.1 Updating clap v4.5.20 -> v4.5.21 Updating clap_builder v4.5.20 -> v4.5.21 Updating clap_complete v4.5.37 -> v4.5.38 Updating clap_lex v0.7.2 -> v0.7.3 Updating comfy-table v7.1.1 -> v7.1.3 Updating cpufeatures v0.2.14 -> v0.2.15 Removing crossterm v0.27.0 Adding diff v0.1.13 Updating flate2 v1.0.34 -> v1.0.35 Updating indicatif v0.17.8 -> v0.17.9 Adding indoc v2.0.5 Updating instability v0.3.2 -> v0.3.3 Removing instant v0.1.13 Updating libc v0.2.162 -> v0.2.164 Adding pretty_assertions v1.4.1 Updating quinn v0.11.5 -> v0.11.6 Updating quinn-proto v0.11.8 -> v0.11.9 Updating regex-automata v0.4.8 -> v0.4.9 Updating rustix v0.38.39 -> v0.38.40 Updating rustls v0.23.16 -> v0.23.17 Updating scc v2.2.4 -> v2.2.5 Updating serde v1.0.214 -> v1.0.215 Updating serde_derive v1.0.214 -> v1.0.215 Updating syn-solidity v0.8.11 -> v0.8.12 Removing thiserror v1.0.68 Adding thiserror v1.0.69 (available: v2.0.3) Adding thiserror v2.0.3 Removing thiserror-impl v1.0.68 Adding thiserror-impl v1.0.69 Adding thiserror-impl v2.0.3 Adding web-time v1.1.0 note: pass `--verbose` to see 44 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 416 +++++++++++++++++++++++++++++------------------------ 1 file changed, 228 insertions(+), 188 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af730814c9362..1922c69b89af5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "alloy-chains" @@ -118,14 +118,14 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "alloy-dyn-abi" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85132f2698b520fab3f54beed55a44389f7006a7b557a0261e1e69439dcc1572" +checksum = "ef2364c782a245cf8725ea6dbfca5f530162702b5d685992ea03ce64529136cc" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded610181f3dad5810f6ff12d1a99994cf9b42d2fcb7709029352398a5da5ae6" +checksum = "b84c506bf264110fa7e90d9924f742f40ef53c6572ea56a0b0bd714a567ed389" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -221,7 +221,7 @@ dependencies = [ "alloy-sol-types", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -243,7 +243,7 @@ dependencies = [ "async-trait", "auto_impl", "futures-utils-wasm", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -261,9 +261,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd58d377699e6cfeab52c4a9d28bdc4ef37e2bd235ff2db525071fe37a2e9af5" +checksum = "9fce5dbd6a4f118eecc4719eaa9c7ffc31c315e6c5ccde3642db927802312425" dependencies = [ "alloy-rlp", "arbitrary", @@ -326,7 +326,7 @@ dependencies = [ "schnellru", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "url", @@ -475,7 +475,7 @@ dependencies = [ "alloy-serde", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -514,7 +514,7 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -531,7 +531,7 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -549,7 +549,7 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -569,7 +569,7 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.23", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -589,7 +589,7 @@ dependencies = [ "eth-keystore", "k256", "rand", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -604,16 +604,16 @@ dependencies = [ "alloy-signer", "async-trait", "semver 1.0.23", - "thiserror", + "thiserror 1.0.69", "tracing", "trezor-client", ] [[package]] name = "alloy-sol-macro" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a1b42ac8f45e2f49f4bcdd72cbfde0bb148f5481d403774ffa546e48b83efc1" +checksum = "9343289b4a7461ed8bab8618504c995c049c082b70c7332efd7b32125633dc05" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -625,9 +625,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06318f1778e57f36333e850aa71bd1bb5e560c10279e236622faae0470c50412" +checksum = "4222d70bec485ceccc5d8fd4f2909edd65b5d5e43d4aca0b5dcee65d519ae98f" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -644,9 +644,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaebb9b0ad61a41345a22c9279975c0cdd231b97947b10d7aad1cf0a7181e4a5" +checksum = "2e17f2677369571b976e51ea1430eb41c3690d344fef567b840bfc0b01b6f83a" dependencies = [ "alloy-json-abi", "const-hex", @@ -661,9 +661,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12c71028bfbfec210e24106a542aad3def7caf1a70e2c05710e92a98481980d3" +checksum = "aa64d80ae58ffaafdff9d5d84f58d03775f66c84433916dc9a64ed16af5755da" dependencies = [ "serde", "winnow", @@ -671,9 +671,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d7fb042d68ddfe79ccb23359de3007f6d4d53c13f703b64fb0db422132111" +checksum = "6520d427d4a8eb7aa803d852d7a52ceb0c519e784c292f64bb339e636918cf27" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -694,7 +694,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tower 0.5.1", "tracing", @@ -748,7 +748,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.16", + "rustls 0.23.17", "serde_json", "tokio", "tokio-tungstenite", @@ -908,7 +908,7 @@ dependencies = [ "serde_repr", "similar-asserts", "tempfile", - "thiserror", + "thiserror 1.0.69", "tikv-jemallocator", "tokio", "tower 0.4.13", @@ -938,7 +938,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -964,7 +964,7 @@ dependencies = [ "pin-project 1.1.7", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio-util", "tower-http", "tracing", @@ -1394,9 +1394,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53dcf5e7d9bd1517b8b998e170e650047cea8a2b85fe1835abe3210713e541b7" +checksum = "6ada54e5f26ac246dc79727def52f7f8ed38915cb47781e2a72213957dc3a7d5" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1580,9 +1580,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", @@ -1797,12 +1797,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "serde", ] @@ -1920,7 +1920,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1998,9 +1998,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.37" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "shlex", ] @@ -2112,9 +2112,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -2122,9 +2122,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -2137,9 +2137,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11611dca53440593f38e6b25ec629de50b14cdfa63adc0fb856115a2c6d97595" +checksum = "d9647a559c112175f17cf724dc72d3645680a883c58481332779192b0d8e7a01" dependencies = [ "clap", ] @@ -2168,9 +2168,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "clearscreen" @@ -2180,7 +2180,7 @@ checksum = "2f8c93eb5f77c9050c7750e14f13ef1033a40a0aac70c6371535b6763a01438c" dependencies = [ "nix 0.28.0", "terminfo", - "thiserror", + "thiserror 1.0.69", "which", "winapi", ] @@ -2221,7 +2221,7 @@ dependencies = [ "k256", "serde", "sha2", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2237,7 +2237,7 @@ dependencies = [ "pbkdf2 0.12.2", "rand", "sha2", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2256,7 +2256,7 @@ dependencies = [ "serde", "sha2", "sha3", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2275,7 +2275,7 @@ dependencies = [ "log", "nix 0.26.4", "once_cell", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "wasm-bindgen", @@ -2317,14 +2317,14 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comfy-table" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" +checksum = "24f165e7b643266ea80cb858aed492ad9280e3e05ce24d4a99d7d7b889b6a4d9" dependencies = [ - "crossterm 0.27.0", + "crossterm", "strum", "strum_macros", - "unicode-width 0.1.14", + "unicode-width 0.2.0", ] [[package]] @@ -2425,9 +2425,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -2475,19 +2475,6 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" -[[package]] -name = "crossterm" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" -dependencies = [ - "bitflags 2.6.0", - "crossterm_winapi", - "libc", - "parking_lot", - "winapi", -] - [[package]] name = "crossterm" version = "0.28.1" @@ -2730,10 +2717,16 @@ dependencies = [ "console", "shell-words", "tempfile", - "thiserror", + "thiserror 1.0.69", "zeroize", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "digest" version = "0.9.0" @@ -3043,7 +3036,7 @@ dependencies = [ "serde_json", "sha2", "sha3", - "thiserror", + "thiserror 1.0.69", "uuid 0.8.2", ] @@ -3060,7 +3053,7 @@ dependencies = [ "serde", "serde_json", "sha3", - "thiserror", + "thiserror 1.0.69", "uint", ] @@ -3142,7 +3135,7 @@ dependencies = [ "strum", "syn 2.0.87", "tempfile", - "thiserror", + "thiserror 1.0.69", "tiny-keccak", "unicode-xid", ] @@ -3229,7 +3222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" dependencies = [ "libc", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -3290,9 +3283,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -3401,7 +3394,7 @@ dependencies = [ "strum", "svm-rs", "tempfile", - "thiserror", + "thiserror 1.0.69", "tikv-jemallocator", "tokio", "toml 0.8.19", @@ -3434,7 +3427,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "thiserror", + "thiserror 1.0.69", "toml 0.8.19", "tracing", ] @@ -3449,7 +3442,7 @@ dependencies = [ "itertools 0.13.0", "similar-asserts", "solang-parser", - "thiserror", + "thiserror 1.0.69", "toml 0.8.19", "tracing", "tracing-subscriber", @@ -3591,7 +3584,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -3635,7 +3628,7 @@ dependencies = [ "revm-inspectors", "semver 1.0.23", "serde_json", - "thiserror", + "thiserror 1.0.69", "toml 0.8.19", "tracing", "vergen", @@ -3730,7 +3723,7 @@ dependencies = [ "serde_json", "similar-asserts", "terminal_size", - "thiserror", + "thiserror 1.0.69", "tokio", "tower 0.4.13", "tracing", @@ -3790,7 +3783,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "winnow", @@ -3824,7 +3817,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "walkdir", @@ -3864,7 +3857,7 @@ dependencies = [ "serde_json", "svm-rs", "tempfile", - "thiserror", + "thiserror 1.0.69", "tokio", "walkdir", ] @@ -3897,7 +3890,7 @@ dependencies = [ "similar-asserts", "solang-parser", "tempfile", - "thiserror", + "thiserror 1.0.69", "toml 0.8.19", "toml_edit", "tracing", @@ -3910,7 +3903,7 @@ name = "foundry-debugger" version = "0.2.0" dependencies = [ "alloy-primitives", - "crossterm 0.28.1", + "crossterm", "eyre", "foundry-common", "foundry-compilers", @@ -3946,7 +3939,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -3991,7 +3984,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -4033,7 +4026,7 @@ dependencies = [ "rand", "revm", "serde", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -4081,7 +4074,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "url", @@ -4094,7 +4087,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "semver 1.0.23", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4155,7 +4148,7 @@ dependencies = [ "gcloud-sdk", "rpassword", "serde", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -4383,7 +4376,7 @@ dependencies = [ "gix-date", "gix-utils", "itoa", - "thiserror", + "thiserror 1.0.69", "winnow", ] @@ -4403,7 +4396,7 @@ dependencies = [ "memchr", "once_cell", "smallvec", - "thiserror", + "thiserror 1.0.69", "unicode-bom", "winnow", ] @@ -4418,7 +4411,7 @@ dependencies = [ "bstr", "gix-path", "libc", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4430,7 +4423,7 @@ dependencies = [ "bstr", "itoa", "jiff", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4478,7 +4471,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" dependencies = [ "faster-hex", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4489,7 +4482,7 @@ checksum = "e3bc7fe297f1f4614774989c00ec8b1add59571dc9b024b4c00acb7dedd4e19d" dependencies = [ "gix-tempfile", "gix-utils", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4507,7 +4500,7 @@ dependencies = [ "gix-validate", "itoa", "smallvec", - "thiserror", + "thiserror 1.0.69", "winnow", ] @@ -4521,7 +4514,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4541,7 +4534,7 @@ dependencies = [ "gix-utils", "gix-validate", "memmap2", - "thiserror", + "thiserror 1.0.69", "winnow", ] @@ -4593,7 +4586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e187b263461bc36cea17650141567753bc6207d036cedd1de6e81a52f277ff68" dependencies = [ "bstr", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4611,7 +4604,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -4686,7 +4679,7 @@ dependencies = [ "pest_derive", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -4957,7 +4950,7 @@ dependencies = [ "http 1.1.0", "hyper 1.5.0", "hyper-util", - "rustls 0.23.16", + "rustls 0.23.17", "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", @@ -5192,7 +5185,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "same-file", "walkdir", "winapi-util", @@ -5212,7 +5205,7 @@ dependencies = [ "normalize-path", "project-origins", "radix_trie", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -5285,17 +5278,23 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", - "unicode-width 0.1.14", + "unicode-width 0.2.0", + "web-time", ] +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "inferno" version = "0.11.21" @@ -5350,23 +5349,18 @@ dependencies = [ [[package]] name = "instability" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" +checksum = "b829f37dead9dc39df40c2d3376c179fdfd2ac771f53f55d3c30dc096a3c0c6e" dependencies = [ + "darling", + "indoc", + "pretty_assertions", + "proc-macro2", "quote", "syn 2.0.87", ] -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - [[package]] name = "interprocess" version = "2.2.1" @@ -5578,7 +5572,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.8", + "regex-automata 0.4.9", ] [[package]] @@ -5592,9 +5586,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libdbus-sys" @@ -5802,7 +5796,7 @@ checksum = "d04b0347d2799ef17df4623dbcb03531031142105168e0c549e0bf1f980e9e7e" dependencies = [ "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -5813,7 +5807,7 @@ checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ "cfg-if", "miette-derive", - "thiserror", + "thiserror 1.0.69", "unicode-width 0.1.14", ] @@ -6527,7 +6521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.69", "ucd-trie", ] @@ -6777,6 +6771,16 @@ dependencies = [ "termtree", ] +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "prettyplease" version = "0.2.25" @@ -6989,7 +6993,7 @@ checksum = "b65f4a8ec18723a734e5dc09c173e0abf9690432da5340285d536edcb4dac190" dependencies = [ "once_cell", "protobuf-support", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -6998,7 +7002,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6872f4d4f4b98303239a2b5838f5bbbb77b01ffc892d627957f37a22d7cfe69c" dependencies = [ - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -7036,7 +7040,7 @@ dependencies = [ "newtype-uuid", "quick-xml 0.36.2", "strip-ansi-escapes", - "thiserror", + "thiserror 1.0.69", "uuid 1.11.0", ] @@ -7069,37 +7073,40 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.16", + "rustls 0.23.17", "socket2", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand", "ring", "rustc-hash", - "rustls 0.23.16", + "rustls 0.23.17", + "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.3", "tinyvec", "tracing", + "web-time", ] [[package]] @@ -7190,7 +7197,7 @@ dependencies = [ "bitflags 2.6.0", "cassowary", "compact_str", - "crossterm 0.28.1", + "crossterm", "instability", "itertools 0.13.0", "lru", @@ -7245,7 +7252,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -7256,7 +7263,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -7271,9 +7278,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -7327,7 +7334,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.16", + "rustls 0.23.17", "rustls-native-certs 0.8.0", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7380,7 +7387,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -7601,9 +7608,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.39" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -7626,9 +7633,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" dependencies = [ "log", "once_cell", @@ -7687,6 +7694,9 @@ name = "rustls-pki-types" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -7809,9 +7819,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.4" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" +checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" dependencies = [ "sdd", ] @@ -8004,18 +8014,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -8266,7 +8276,7 @@ checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ "num-bigint", "num-traits", - "thiserror", + "thiserror 1.0.69", "time", ] @@ -8342,7 +8352,7 @@ dependencies = [ "lalrpop", "lalrpop-util", "phf", - "thiserror", + "thiserror 1.0.69", "unicode-xid", ] @@ -8384,7 +8394,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror", + "thiserror 1.0.69", "tokio", "toml_edit", "uuid 1.11.0", @@ -8526,7 +8536,7 @@ dependencies = [ "serde_json", "sha2", "tempfile", - "thiserror", + "thiserror 1.0.69", "url", "zip", ] @@ -8568,9 +8578,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edf42e81491fb8871b74df3d222c64ae8cbc1269ea509fa768a3ed3e1b0ac8cb" +checksum = "f76fe0a3e1476bdaa0775b9aec5b869ed9520c2b2fedfe9c6df3618f8ea6290b" dependencies = [ "paste", "proc-macro2", @@ -8687,18 +8697,38 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.68" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.3", ] [[package]] name = "thiserror-impl" -version = "1.0.68" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ "proc-macro2", "quote", @@ -8866,7 +8896,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.16", + "rustls 0.23.17", "rustls-pki-types", "tokio", ] @@ -8879,7 +8909,7 @@ checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" dependencies = [ "either", "futures-util", - "thiserror", + "thiserror 1.0.69", "tokio", ] @@ -8903,7 +8933,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.16", + "rustls 0.23.17", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -9193,7 +9223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3637e734239e12ab152cd269302500bd063f37624ee210cd04b4936ed671f3b1" dependencies = [ "cc", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -9206,7 +9236,7 @@ dependencies = [ "hex", "protobuf", "rusb", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -9229,10 +9259,10 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.16", + "rustls 0.23.17", "rustls-pki-types", "sha1", - "thiserror", + "thiserror 1.0.69", "utf-8", ] @@ -9612,7 +9642,7 @@ dependencies = [ "once_cell", "process-wrap", "project-origins", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "watchexec-events", @@ -9639,7 +9669,7 @@ checksum = "8f7ccc54db7df8cbbe3251508321e46986ce179af4c4a03b4c70bda539d72755" dependencies = [ "miette", "nix 0.28.0", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -9667,6 +9697,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.26.6" @@ -9716,7 +9756,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]] @@ -10050,7 +10090,7 @@ dependencies = [ "pharos", "rustc_version 0.4.1", "send_wrapper", - "thiserror", + "thiserror 1.0.69", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -10202,7 +10242,7 @@ dependencies = [ "flate2", "indexmap 2.6.0", "memchr", - "thiserror", + "thiserror 1.0.69", "zopfli", ] @@ -10213,7 +10253,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a8c9e90f27d1435088a7b540b6cc8ae6ee525d992a695f16012d2f365b3d3c" dependencies = [ "log", - "thiserror", + "thiserror 1.0.69", "zip", ] From 44c86e76d5e37505cd7349a867e64a845b5b9b2d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 18 Nov 2024 08:55:59 +0200 Subject: [PATCH 1680/1963] chore: fix getArtifactPath flaky test (#9339) --- testdata/default/cheats/GetArtifactPath.t.sol | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/testdata/default/cheats/GetArtifactPath.t.sol b/testdata/default/cheats/GetArtifactPath.t.sol index 538c2e6c96ecb..4b0df4ba6e6ec 100644 --- a/testdata/default/cheats/GetArtifactPath.t.sol +++ b/testdata/default/cheats/GetArtifactPath.t.sol @@ -13,25 +13,15 @@ contract GetArtifactPathTest is DSTest { DummyForGetArtifactPath dummy = new DummyForGetArtifactPath(); bytes memory dummyCreationCode = type(DummyForGetArtifactPath).creationCode; - string memory root = vm.projectRoot(); string memory path = vm.getArtifactPathByCode(dummyCreationCode); - - string memory expectedPath = - string.concat(root, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json"); - - assertEq(path, expectedPath); + assertTrue(vm.contains(path, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json")); } function testGetArtifactPathByDeployedCode() public { DummyForGetArtifactPath dummy = new DummyForGetArtifactPath(); bytes memory dummyRuntimeCode = address(dummy).code; - string memory root = vm.projectRoot(); string memory path = vm.getArtifactPathByDeployedCode(dummyRuntimeCode); - - string memory expectedPath = - string.concat(root, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json"); - - assertEq(path, expectedPath); + assertTrue(vm.contains(path, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json")); } } From d275a4901f60a50c5a82fcf10fd5774ddb4598d8 Mon Sep 17 00:00:00 2001 From: Max <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:18:11 +0530 Subject: [PATCH 1681/1963] fix(cast storage): respect `--json` for layout (#9332) * feat(cast storage): allow ugly printing of layout Prior to this change, `cast storage $ADDRESS --rpc-url $RPC_URL --etherscan-api-key $ETHERSCAN_API_KEY` always provided a prettified output. This change adds a `--pretty` flag to `cast storage` which defaults to `true` thus retaining backwards compatibility. Passing `--pretty=false` to `cast storage` results in the json output of the storage layout being produced instead. * fix: remove default value from help text The default value is accessible via `cast storage --help` * fix(cast storage): provide output json path * test(cast): add storage_layout_simple_json test * fix(cast storage): use `--json` flag to ugly print * fix(cast storage): include values in json mode * fix(cast-storage): quiet compilation in all cases * chore: cargo clippy * use fixtures, assert JSON * only quiet if JSON mode, avoid unnecessary warning (if you pass an API key you already expect to fetch remote, very likely default) --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: zerosnacks --- crates/cast/bin/cmd/storage.rs | 46 +- crates/cast/tests/cli/main.rs | 33 ++ .../fixtures/storage_layout_complex.json | 397 ++++++++++++++++++ .../tests/fixtures/storage_layout_simple.json | 36 ++ 4 files changed, 503 insertions(+), 9 deletions(-) create mode 100644 crates/cast/tests/fixtures/storage_layout_complex.json create mode 100644 crates/cast/tests/fixtures/storage_layout_simple.json diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 9fca4172e3452..5e24591270013 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -17,6 +17,7 @@ use foundry_common::{ abi::find_source, compile::{etherscan_project, ProjectCompiler}, ens::NameOrAddress, + shell, }; use foundry_compilers::{ artifacts::{ConfigurableContractArtifact, StorageLayout}, @@ -31,6 +32,7 @@ use foundry_config::{ impl_figment_convert_cast, Config, }; use semver::Version; +use serde::{Deserialize, Serialize}; use std::str::FromStr; /// The minimum Solc version for outputting storage layouts. @@ -45,7 +47,7 @@ pub struct StorageArgs { #[arg(value_parser = NameOrAddress::from_str)] address: NameOrAddress, - /// The storage slot number. + /// The storage slot number. If not provided, it gets the full storage layout. #[arg(value_parser = parse_slot)] slot: Option, @@ -109,19 +111,22 @@ impl StorageArgs { if project.paths.has_input_files() { // Find in artifacts and pretty print add_storage_layout_output(&mut project); - let out = ProjectCompiler::new().compile(&project)?; + let out = ProjectCompiler::new().quiet(shell::is_json()).compile(&project)?; let artifact = out.artifacts().find(|(_, artifact)| { artifact.get_deployed_bytecode_bytes().is_some_and(|b| *b == address_code) }); if let Some((_, artifact)) = artifact { - return fetch_and_print_storage(provider, address, block, artifact, true).await; + return fetch_and_print_storage( + provider, + address, + block, + artifact, + !shell::is_json(), + ) + .await; } } - // Not a forge project or artifact not found - // Get code from Etherscan - sh_warn!("No matching artifacts found, fetching source code from Etherscan...")?; - if !self.etherscan.has_key() { eyre::bail!("You must provide an Etherscan API key if you're fetching a remote contract's storage."); } @@ -180,7 +185,7 @@ impl StorageArgs { // Clear temp directory root.close()?; - fetch_and_print_storage(provider, address, block, artifact, true).await + fetch_and_print_storage(provider, address, block, artifact, !shell::is_json()).await } } @@ -215,6 +220,14 @@ impl StorageValue { } } +/// Represents the storage layout of a contract and its values. +#[derive(Clone, Debug, Serialize, Deserialize)] +struct StorageReport { + #[serde(flatten)] + layout: StorageLayout, + values: Vec, +} + async fn fetch_and_print_storage, T: Transport + Clone>( provider: P, address: Address, @@ -255,7 +268,22 @@ async fn fetch_storage_slots, T: Transport + Clone>( fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) -> Result<()> { if !pretty { - sh_println!("{}", serde_json::to_string_pretty(&serde_json::to_value(layout)?)?)?; + let values: Vec<_> = layout + .storage + .iter() + .zip(&values) + .map(|(slot, storage_value)| { + let storage_type = layout.types.get(&slot.storage_type); + storage_value.value( + slot.offset, + storage_type.and_then(|t| t.number_of_bytes.parse::().ok()), + ) + }) + .collect(); + sh_println!( + "{}", + serde_json::to_string_pretty(&serde_json::to_value(StorageReport { layout, values })?)? + )?; return Ok(()) } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index a88369e97ffe2..2483fa479820f 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1131,6 +1131,23 @@ casttest!(storage_layout_simple, |_prj, cmd| { "#]]); }); +// +casttest!(storage_layout_simple_json, |_prj, cmd| { + cmd.args([ + "storage", + "--rpc-url", + next_rpc_endpoint(NamedChain::Mainnet).as_str(), + "--block", + "21034138", + "--etherscan-api-key", + next_mainnet_etherscan_api_key().as_str(), + "0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2", + "--json", + ]) + .assert_success() + .stdout_eq(file!["../fixtures/storage_layout_simple.json": Json]); +}); + // casttest!(storage_layout_complex, |_prj, cmd| { cmd.args([ @@ -1164,6 +1181,22 @@ casttest!(storage_layout_complex, |_prj, cmd| { "#]]); }); +casttest!(storage_layout_complex_json, |_prj, cmd| { + cmd.args([ + "storage", + "--rpc-url", + next_rpc_endpoint(NamedChain::Mainnet).as_str(), + "--block", + "21034138", + "--etherscan-api-key", + next_mainnet_etherscan_api_key().as_str(), + "0xBA12222222228d8Ba445958a75a0704d566BF2C8", + "--json", + ]) + .assert_success() + .stdout_eq(file!["../fixtures/storage_layout_complex.json": Json]); +}); + casttest!(balance, |_prj, cmd| { let rpc = next_http_rpc_endpoint(); let usdt = "0xdac17f958d2ee523a2206206994597c13d831ec7"; diff --git a/crates/cast/tests/fixtures/storage_layout_complex.json b/crates/cast/tests/fixtures/storage_layout_complex.json new file mode 100644 index 0000000000000..2cad9dc8c221f --- /dev/null +++ b/crates/cast/tests/fixtures/storage_layout_complex.json @@ -0,0 +1,397 @@ +{ + "storage": [ + { + "astId": 3805, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_status", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 9499, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_generalPoolsBalances", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_struct(IERC20ToBytes32Map)3177_storage)" + }, + { + "astId": 716, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_nextNonce", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 967, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_paused", + "offset": 0, + "slot": "3", + "type": "t_bool" + }, + { + "astId": 8639, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_authorizer", + "offset": 1, + "slot": "3", + "type": "t_contract(IAuthorizer)11086" + }, + { + "astId": 8645, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_approvedRelayers", + "offset": 0, + "slot": "4", + "type": "t_mapping(t_address,t_mapping(t_address,t_bool))" + }, + { + "astId": 5769, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_isPoolRegistered", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_bytes32,t_bool)" + }, + { + "astId": 5771, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_nextPoolNonce", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 9915, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_minimalSwapInfoPoolsBalances", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_bytes32,t_mapping(t_contract(IERC20)3793,t_bytes32))" + }, + { + "astId": 9919, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_minimalSwapInfoPoolsTokens", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_bytes32,t_struct(AddressSet)3520_storage)" + }, + { + "astId": 10373, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_twoTokenPoolTokens", + "offset": 0, + "slot": "9", + "type": "t_mapping(t_bytes32,t_struct(TwoTokenPoolTokens)10369_storage)" + }, + { + "astId": 4007, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_poolAssetManagers", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_bytes32,t_mapping(t_contract(IERC20)3793,t_address))" + }, + { + "astId": 8019, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_internalTokenBalance", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_address,t_mapping(t_contract(IERC20)3793,t_uint256))" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32", + "base": "t_address" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IAuthorizer)11086": { + "encoding": "inplace", + "label": "contract IAuthorizer", + "numberOfBytes": "20" + }, + "t_contract(IERC20)3793": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_bool)" + }, + "t_mapping(t_address,t_mapping(t_contract(IERC20)3793,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(contract IERC20 => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20)3793,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes32,t_bool)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_bytes32,t_mapping(t_contract(IERC20)3793,t_address))": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => mapping(contract IERC20 => address))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20)3793,t_address)" + }, + "t_mapping(t_bytes32,t_mapping(t_contract(IERC20)3793,t_bytes32))": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => mapping(contract IERC20 => bytes32))", + "numberOfBytes": "32", + "value": "t_mapping(t_contract(IERC20)3793,t_bytes32)" + }, + "t_mapping(t_bytes32,t_struct(AddressSet)3520_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)3520_storage" + }, + "t_mapping(t_bytes32,t_struct(IERC20ToBytes32Map)3177_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct EnumerableMap.IERC20ToBytes32Map)", + "numberOfBytes": "32", + "value": "t_struct(IERC20ToBytes32Map)3177_storage" + }, + "t_mapping(t_bytes32,t_struct(TwoTokenPoolBalances)10360_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct TwoTokenPoolsBalance.TwoTokenPoolBalances)", + "numberOfBytes": "32", + "value": "t_struct(TwoTokenPoolBalances)10360_storage" + }, + "t_mapping(t_bytes32,t_struct(TwoTokenPoolTokens)10369_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct TwoTokenPoolsBalance.TwoTokenPoolTokens)", + "numberOfBytes": "32", + "value": "t_struct(TwoTokenPoolTokens)10369_storage" + }, + "t_mapping(t_contract(IERC20)3793,t_address)": { + "encoding": "mapping", + "key": "t_contract(IERC20)3793", + "label": "mapping(contract IERC20 => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_contract(IERC20)3793,t_bytes32)": { + "encoding": "mapping", + "key": "t_contract(IERC20)3793", + "label": "mapping(contract IERC20 => bytes32)", + "numberOfBytes": "32", + "value": "t_bytes32" + }, + "t_mapping(t_contract(IERC20)3793,t_uint256)": { + "encoding": "mapping", + "key": "t_contract(IERC20)3793", + "label": "mapping(contract IERC20 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint256,t_struct(IERC20ToBytes32MapEntry)3166_storage)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => struct EnumerableMap.IERC20ToBytes32MapEntry)", + "numberOfBytes": "32", + "value": "t_struct(IERC20ToBytes32MapEntry)3166_storage" + }, + "t_struct(AddressSet)3520_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "numberOfBytes": "64", + "members": [ + { + "astId": 3515, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 3519, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_uint256)" + } + ] + }, + "t_struct(IERC20ToBytes32Map)3177_storage": { + "encoding": "inplace", + "label": "struct EnumerableMap.IERC20ToBytes32Map", + "numberOfBytes": "96", + "members": [ + { + "astId": 3168, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_length", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 3172, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_entries", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_uint256,t_struct(IERC20ToBytes32MapEntry)3166_storage)" + }, + { + "astId": 3176, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_indexes", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_contract(IERC20)3793,t_uint256)" + } + ] + }, + "t_struct(IERC20ToBytes32MapEntry)3166_storage": { + "encoding": "inplace", + "label": "struct EnumerableMap.IERC20ToBytes32MapEntry", + "numberOfBytes": "64", + "members": [ + { + "astId": 3163, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_key", + "offset": 0, + "slot": "0", + "type": "t_contract(IERC20)3793" + }, + { + "astId": 3165, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "_value", + "offset": 0, + "slot": "1", + "type": "t_bytes32" + } + ] + }, + "t_struct(TwoTokenPoolBalances)10360_storage": { + "encoding": "inplace", + "label": "struct TwoTokenPoolsBalance.TwoTokenPoolBalances", + "numberOfBytes": "64", + "members": [ + { + "astId": 10357, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "sharedCash", + "offset": 0, + "slot": "0", + "type": "t_bytes32" + }, + { + "astId": 10359, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "sharedManaged", + "offset": 0, + "slot": "1", + "type": "t_bytes32" + } + ] + }, + "t_struct(TwoTokenPoolTokens)10369_storage": { + "encoding": "inplace", + "label": "struct TwoTokenPoolsBalance.TwoTokenPoolTokens", + "numberOfBytes": "96", + "members": [ + { + "astId": 10362, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "tokenA", + "offset": 0, + "slot": "0", + "type": "t_contract(IERC20)3793" + }, + { + "astId": 10364, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "tokenB", + "offset": 0, + "slot": "1", + "type": "t_contract(IERC20)3793" + }, + { + "astId": 10368, + "contract": "contracts/vault/Vault.sol:Vault", + "label": "balances", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_bytes32,t_struct(TwoTokenPoolBalances)10360_storage)" + } + ] + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + }, + "values": [ + "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000006048a8c631fb7e77eca533cf9c29784e482391e7", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000000000000000000000000000000000000000006e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] +} \ No newline at end of file diff --git a/crates/cast/tests/fixtures/storage_layout_simple.json b/crates/cast/tests/fixtures/storage_layout_simple.json new file mode 100644 index 0000000000000..35f4777d02b31 --- /dev/null +++ b/crates/cast/tests/fixtures/storage_layout_simple.json @@ -0,0 +1,36 @@ +{ + "storage": [ + { + "astId": 7, + "contract": "contracts/Create2Deployer.sol:Create2Deployer", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 122, + "contract": "contracts/Create2Deployer.sol:Create2Deployer", + "label": "_paused", + "offset": 20, + "slot": "0", + "type": "t_bool" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + } + }, + "values": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] +} \ No newline at end of file From 60dd1d7fe9879008a52da40eb74d5b6706d00b78 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:24:53 +0200 Subject: [PATCH 1682/1963] feat(`config`): set default evm version to cancun (#9131) * chore: Update to Cancun * cancun to TEST_DATA_DEFAULT, add TEST_DATA_PARIS * Shanghai compat test * Redact gaswaster address --- crates/config/src/lib.rs | 2 +- crates/forge/src/multi_runner.rs | 2 +- crates/forge/tests/cli/build.rs | 6 +- crates/forge/tests/cli/cmd.rs | 462 +++++++++--------- crates/forge/tests/cli/compiler.rs | 2 +- crates/forge/tests/cli/config.rs | 37 ++ crates/forge/tests/cli/ext_integration.rs | 1 + crates/forge/tests/cli/script.rs | 40 +- crates/forge/tests/cli/test_cmd.rs | 86 ++-- crates/forge/tests/it/cheats.rs | 8 +- crates/forge/tests/it/core.rs | 27 +- crates/forge/tests/it/fork.rs | 8 +- crates/forge/tests/it/fuzz.rs | 4 +- crates/forge/tests/it/repros.rs | 5 +- crates/forge/tests/it/spec.rs | 4 +- crates/forge/tests/it/test_helpers.rs | 28 +- .../cheats/BlobBaseFee.t.sol | 0 .../cheats/Blobhashes.t.sol | 0 testdata/default/cheats/Etch.t.sol | 2 +- testdata/default/repros/Issue5929.t.sol | 4 +- testdata/default/repros/Issue6538.t.sol | 4 +- testdata/default/repros/Issue8006.t.sol | 6 +- testdata/paris/cheats/Fork.t.sol | 125 +++++ .../cheats/GasSnapshots.t.sol | 0 .../cheats/LastCallGas.t.sol | 0 .../core/BeforeTest.t.sol} | 2 +- .../{default => paris}/fork/Transact.t.sol | 2 +- testdata/paris/spec/ShanghaiCompat.t.sol | 29 ++ 28 files changed, 555 insertions(+), 341 deletions(-) rename testdata/{cancun => default}/cheats/BlobBaseFee.t.sol (100%) rename testdata/{cancun => default}/cheats/Blobhashes.t.sol (100%) create mode 100644 testdata/paris/cheats/Fork.t.sol rename testdata/{default => paris}/cheats/GasSnapshots.t.sol (100%) rename testdata/{default => paris}/cheats/LastCallGas.t.sol (100%) rename testdata/{default/repros/Issue1543.t.sol => paris/core/BeforeTest.t.sol} (98%) rename testdata/{default => paris}/fork/Transact.t.sol (99%) create mode 100644 testdata/paris/spec/ShanghaiCompat.t.sol diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 986a0181dd73f..b87eadcefa0b9 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2149,7 +2149,7 @@ impl Default for Config { allow_paths: vec![], include_paths: vec![], force: false, - evm_version: EvmVersion::Paris, + evm_version: EvmVersion::Cancun, gas_reports: vec!["*".to_string()], gas_reports_ignore: vec![], gas_reports_include_tests: false, diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index e7361db0004fc..a9f2a93eb37a6 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -449,7 +449,7 @@ impl MultiContractRunnerBuilder { contracts: deployable_contracts, evm_opts, env, - evm_spec: self.evm_spec.unwrap_or(SpecId::MERGE), + evm_spec: self.evm_spec.unwrap_or(SpecId::CANCUN), sender: self.sender, revert_decoder, fork: self.fork, diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index dd25459957533..51c358612e865 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -78,7 +78,7 @@ forgetest!(initcode_size_exceeds_limit, |prj, cmd| { ... | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | |--------------|------------------|-------------------|--------------------|---------------------| -| HugeContract | 202 | 49,359 | 24,374 | -207 | +| HugeContract | 194 | 49,344 | 24,382 | -192 | ... "# ]); @@ -105,7 +105,7 @@ forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { ... | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | |--------------|------------------|-------------------|--------------------|---------------------| -| HugeContract | 202 | 49,359 | 24,374 | -207 | +| HugeContract | 194 | 49,344 | 24,382 | -192 | ... "# ]); @@ -145,7 +145,7 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { ... | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | |----------|------------------|-------------------|--------------------|---------------------| -| Counter | 247 | 277 | 24,329 | 48,875 | +| Counter | 236 | 263 | 24,340 | 48,889 | ... "# ]); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 1e887791e5696..18f0327f6e907 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1582,25 +1582,25 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101532 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| foo | 45387 | 45387 | 45387 | 45387 | 1 | +| foo | 45370 | 45370 | 45370 | 45370 | 1 | | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | | src/Contracts.sol:ContractTwo contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101520 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| bar | 64984 | 64984 | 64984 | 64984 | 1 | +| bar | 64832 | 64832 | 64832 | 64832 | 1 | ... "#]]); @@ -1610,48 +1610,48 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101532, + "size": 241 }, "functions": { "foo()": { "calls": 1, - "min": 45387, - "mean": 45387, - "median": 45387, - "max": 45387 + "min": 45370, + "mean": 45370, + "median": 45370, + "max": 45370 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101520, + "size": 241 }, "functions": { "bar()": { "calls": 1, - "min": 64984, - "mean": 64984, - "median": 64984, - "max": 64984 + "min": 64832, + "mean": 64832, + "median": 64832, + "max": 64832 } } } @@ -1666,25 +1666,25 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101532 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| foo | 45387 | 45387 | 45387 | 45387 | 1 | +| foo | 45370 | 45370 | 45370 | 45370 | 1 | | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | | src/Contracts.sol:ContractTwo contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101520 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| bar | 64984 | 64984 | 64984 | 64984 | 1 | +| bar | 64832 | 64832 | 64832 | 64832 | 1 | ... "#]]); @@ -1694,48 +1694,48 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101532, + "size": 241 }, "functions": { "foo()": { "calls": 1, - "min": 45387, - "mean": 45387, - "median": 45387, - "max": 45387 + "min": 45370, + "mean": 45370, + "median": 45370, + "max": 45370 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101520, + "size": 241 }, "functions": { "bar()": { "calls": 1, - "min": 64984, - "mean": 64984, - "median": 64984, - "max": 64984 + "min": 64832, + "mean": 64832, + "median": 64832, + "max": 64832 } } } @@ -1750,25 +1750,25 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101532 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| foo | 45387 | 45387 | 45387 | 45387 | 1 | +| foo | 45370 | 45370 | 45370 | 45370 | 1 | | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | | src/Contracts.sol:ContractTwo contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101520 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| bar | 64984 | 64984 | 64984 | 64984 | 1 | +| bar | 64832 | 64832 | 64832 | 64832 | 1 | ... "#]]); @@ -1778,48 +1778,48 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101532, + "size": 241 }, "functions": { "foo()": { "calls": 1, - "min": 45387, - "mean": 45387, - "median": 45387, - "max": 45387 + "min": 45370, + "mean": 45370, + "median": 45370, + "max": 45370 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101520, + "size": 241 }, "functions": { "bar()": { "calls": 1, - "min": 64984, - "mean": 64984, - "median": 64984, - "max": 64984 + "min": 64832, + "mean": 64832, + "median": 64832, + "max": 64832 } } } @@ -1841,25 +1841,25 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101532 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| foo | 45387 | 45387 | 45387 | 45387 | 1 | +| foo | 45370 | 45370 | 45370 | 45370 | 1 | | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | | src/Contracts.sol:ContractTwo contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101520 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| bar | 64984 | 64984 | 64984 | 64984 | 1 | +| bar | 64832 | 64832 | 64832 | 64832 | 1 | ... "#]]); @@ -1869,48 +1869,48 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101532, + "size": 241 }, "functions": { "foo()": { "calls": 1, - "min": 45387, - "mean": 45387, - "median": 45387, - "max": 45387 + "min": 45370, + "mean": 45370, + "median": 45370, + "max": 45370 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101520, + "size": 241 }, "functions": { "bar()": { "calls": 1, - "min": 64984, - "mean": 64984, - "median": 64984, - "max": 64984 + "min": 64832, + "mean": 64832, + "median": 64832, + "max": 64832 } } } @@ -1932,9 +1932,9 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101532 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| foo | 45387 | 45387 | 45387 | 45387 | 1 | +| foo | 45370 | 45370 | 45370 | 45370 | 1 | ... "#]]); @@ -1944,16 +1944,16 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101532, + "size": 241 }, "functions": { "foo()": { "calls": 1, - "min": 45387, - "mean": 45387, - "median": 45387, - "max": 45387 + "min": 45370, + "mean": 45370, + "median": 45370, + "max": 45370 } } } @@ -1970,9 +1970,9 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { | src/Contracts.sol:ContractTwo contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101520 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| bar | 64984 | 64984 | 64984 | 64984 | 1 | +| bar | 64832 | 64832 | 64832 | 64832 | 1 | ... "#]]); @@ -1982,16 +1982,16 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101520, + "size": 241 }, "functions": { "bar()": { "calls": 1, - "min": 64984, - "mean": 64984, - "median": 64984, - "max": 64984 + "min": 64832, + "mean": 64832, + "median": 64832, + "max": 64832 } } } @@ -2011,9 +2011,9 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | ... "#]]); @@ -2023,16 +2023,16 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } } @@ -2058,17 +2058,17 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | | src/Contracts.sol:ContractTwo contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101520 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| bar | 64984 | 64984 | 64984 | 64984 | 1 | +| bar | 64832 | 64832 | 64832 | 64832 | 1 | ... "#]]); @@ -2078,32 +2078,32 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101520, + "size": 241 }, "functions": { "bar()": { "calls": 1, - "min": 64984, - "mean": 64984, - "median": 64984, - "max": 64984 + "min": 64832, + "mean": 64832, + "median": 64832, + "max": 64832 } } } @@ -2125,17 +2125,17 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101532 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| foo | 45387 | 45387 | 45387 | 45387 | 1 | +| foo | 45370 | 45370 | 45370 | 45370 | 1 | | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | ... "#]]); @@ -2145,32 +2145,32 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101532, + "size": 241 }, "functions": { "foo()": { "calls": 1, - "min": 45387, - "mean": 45387, - "median": 45387, - "max": 45387 + "min": 45370, + "mean": 45370, + "median": 45370, + "max": 45370 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } } @@ -2203,25 +2203,25 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { | src/Contracts.sol:ContractOne contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101532 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| foo | 45387 | 45387 | 45387 | 45387 | 1 | +| foo | 45370 | 45370 | 45370 | 45370 | 1 | | src/Contracts.sol:ContractThree contract | | | | | | |------------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 103591 | 256 | | | | | +| 101748 | 242 | | | | | | Function Name | min | avg | median | max | # calls | -| baz | 260712 | 260712 | 260712 | 260712 | 1 | +| baz | 259210 | 259210 | 259210 | 259210 | 1 | | src/Contracts.sol:ContractTwo contract | | | | | | |----------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 103375 | 255 | | | | | +| 101520 | 241 | | | | | | Function Name | min | avg | median | max | # calls | -| bar | 64984 | 64984 | 64984 | 64984 | 1 | +| bar | 64832 | 64832 | 64832 | 64832 | 1 | ... "#]]) .stderr_eq(str![[r#" @@ -2240,48 +2240,48 @@ Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101532, + "size": 241 }, "functions": { "foo()": { "calls": 1, - "min": 45387, - "mean": 45387, - "median": 45387, - "max": 45387 + "min": 45370, + "mean": 45370, + "median": 45370, + "max": 45370 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 103591, - "size": 256 + "gas": 101748, + "size": 242 }, "functions": { "baz()": { "calls": 1, - "min": 260712, - "mean": 260712, - "median": 260712, - "max": 260712 + "min": 259210, + "mean": 259210, + "median": 259210, + "max": 259210 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 103375, - "size": 255 + "gas": 101520, + "size": 241 }, "functions": { "bar()": { "calls": 1, - "min": 64984, - "mean": 64984, - "median": 64984, - "max": 64984 + "min": 64832, + "mean": 64832, + "median": 64832, + "max": 64832 } } } @@ -2346,12 +2346,12 @@ contract CounterTest is DSTest { | src/Counter.sol:Counter contract | | | | | | |----------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 101137 | 250 | | | | | +| 99711 | 240 | | | | | | Function Name | min | avg | median | max | # calls | -| a | 2261 | 2261 | 2261 | 2261 | 1 | -| b | 2305 | 2305 | 2305 | 2305 | 1 | -| setNumber(int256) | 23648 | 33604 | 33604 | 43560 | 2 | -| setNumber(uint256) | 23604 | 33560 | 33560 | 43516 | 2 | +| a | 2259 | 2259 | 2259 | 2259 | 1 | +| b | 2304 | 2304 | 2304 | 2304 | 1 | +| setNumber(int256) | 23646 | 33602 | 33602 | 43558 | 2 | +| setNumber(uint256) | 23601 | 33557 | 33557 | 43513 | 2 | ... "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -2360,37 +2360,37 @@ contract CounterTest is DSTest { { "contract": "src/Counter.sol:Counter", "deployment": { - "gas": 101137, - "size": 250 + "gas": 99711, + "size": 240 }, "functions": { "a()": { "calls": 1, - "min": 2261, - "mean": 2261, - "median": 2261, - "max": 2261 + "min": 2259, + "mean": 2259, + "median": 2259, + "max": 2259 }, "b()": { "calls": 1, - "min": 2305, - "mean": 2305, - "median": 2305, - "max": 2305 + "min": 2304, + "mean": 2304, + "median": 2304, + "max": 2304 }, "setNumber(int256)": { "calls": 2, - "min": 23648, - "mean": 33604, - "median": 33604, - "max": 43560 + "min": 23646, + "mean": 33602, + "median": 33602, + "max": 43558 }, "setNumber(uint256)": { "calls": 2, - "min": 23604, - "mean": 33560, - "median": 33560, - "max": 43516 + "min": 23601, + "mean": 33557, + "median": 33557, + "max": 43513 } } } @@ -2973,7 +2973,7 @@ forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { Compiler run successful! | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | |----------|------------------|-------------------|--------------------|---------------------| -| Counter | 247 | 277 | 24,329 | 48,875 | +| Counter | 236 | 263 | 24,340 | 48,889 | "#]]); @@ -3042,20 +3042,20 @@ forgetest_init!(gas_report_include_tests, |prj, cmd| { | src/Counter.sol:Counter contract | | | | | | |----------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 106715 | 277 | | | | | +| 104475 | 263 | | | | | | Function Name | min | avg | median | max | # calls | -| increment | 43404 | 43404 | 43404 | 43404 | 1 | -| number | 283 | 283 | 283 | 283 | 1 | -| setNumber | 23582 | 23582 | 23582 | 23582 | 1 | +| increment | 43401 | 43401 | 43401 | 43401 | 1 | +| number | 281 | 281 | 281 | 281 | 1 | +| setNumber | 23579 | 23579 | 23579 | 23579 | 1 | | test/Counter.t.sol:CounterTest contract | | | | | | |-----------------------------------------|-----------------|--------|--------|--------|---------| | Deployment Cost | Deployment Size | | | | | -| 965418 | 4661 | | | | | +| 938190 | 4522 | | | | | | Function Name | min | avg | median | max | # calls | -| setUp | 168064 | 168064 | 168064 | 168064 | 1 | -| test_Increment | 52367 | 52367 | 52367 | 52367 | 1 | +| setUp | 165834 | 165834 | 165834 | 165834 | 1 | +| test_Increment | 52357 | 52357 | 52357 | 52357 | 1 | ... "#] @@ -3070,53 +3070,53 @@ forgetest_init!(gas_report_include_tests, |prj, cmd| { { "contract": "src/Counter.sol:Counter", "deployment": { - "gas": 106715, - "size": 277 + "gas": 104475, + "size": 263 }, "functions": { "increment()": { "calls": 1, - "min": 43404, - "mean": 43404, - "median": 43404, - "max": 43404 + "min": 43401, + "mean": 43401, + "median": 43401, + "max": 43401 }, "number()": { "calls": 1, - "min": 283, - "mean": 283, - "median": 283, - "max": 283 + "min": 281, + "mean": 281, + "median": 281, + "max": 281 }, "setNumber(uint256)": { "calls": 1, - "min": 23582, - "mean": 23582, - "median": 23582, - "max": 23582 + "min": 23579, + "mean": 23579, + "median": 23579, + "max": 23579 } } }, { "contract": "test/Counter.t.sol:CounterTest", "deployment": { - "gas": 965418, - "size": 4661 + "gas": 938190, + "size": 4522 }, "functions": { "setUp()": { "calls": 1, - "min": 168064, - "mean": 168064, - "median": 168064, - "max": 168064 + "min": 165834, + "mean": 165834, + "median": 165834, + "max": 165834 }, "test_Increment()": { "calls": 1, - "min": 52367, - "mean": 52367, - "median": 52367, - "max": 52367 + "min": 52357, + "mean": 52357, + "median": 52357, + "max": 52357 } } } diff --git a/crates/forge/tests/cli/compiler.rs b/crates/forge/tests/cli/compiler.rs index b8453b67b9442..0b58221f2a1d0 100644 --- a/crates/forge/tests/cli/compiler.rs +++ b/crates/forge/tests/cli/compiler.rs @@ -242,7 +242,7 @@ Solidity: Vyper: -0.4.0 (<= [..]): +0.4.0 (<= cancun): ├── src/Counter.vy └── src/ICounter.vyi diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 91e0781afb1d7..11bcd49e2c40a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -776,6 +776,43 @@ forgetest!(normalize_config_evm_version, |_prj, cmd| { .stdout_lossy(); let config: Config = serde_json::from_str(&output).unwrap(); assert_eq!(config.evm_version, EvmVersion::Istanbul); + + // See + let output = cmd + .forge_fuse() + .args(["config", "--use", "0.8.17", "--json"]) + .assert_success() + .get_output() + .stdout_lossy(); + let config: Config = serde_json::from_str(&output).unwrap(); + assert_eq!(config.evm_version, EvmVersion::London); + + let output = cmd + .forge_fuse() + .args(["config", "--use", "0.8.18", "--json"]) + .assert_success() + .get_output() + .stdout_lossy(); + let config: Config = serde_json::from_str(&output).unwrap(); + assert_eq!(config.evm_version, EvmVersion::Paris); + + let output = cmd + .forge_fuse() + .args(["config", "--use", "0.8.23", "--json"]) + .assert_success() + .get_output() + .stdout_lossy(); + let config: Config = serde_json::from_str(&output).unwrap(); + assert_eq!(config.evm_version, EvmVersion::Shanghai); + + let output = cmd + .forge_fuse() + .args(["config", "--use", "0.8.26", "--json"]) + .assert_success() + .get_output() + .stdout_lossy(); + let config: Config = serde_json::from_str(&output).unwrap(); + assert_eq!(config.evm_version, EvmVersion::Cancun); }); // Tests that root paths are properly resolved even if submodule specifies remappings for them. diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index f0b1c5144ad30..b2747e3ccb80d 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -89,6 +89,7 @@ fn stringutils() { fn lootloose() { ExtTester::new("gakonst", "lootloose", "7b639efe97836155a6a6fc626bf1018d4f8b2495") .install_command(&["make", "install"]) + .args(["--evm-version", "paris"]) .run(); } diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 901ef592211dd..82c61ccbc3887 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -230,7 +230,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new GasWaster@[..] - │ └─ ← [Return] 226 bytes of code + │ └─ ← [Return] 221 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -242,10 +242,10 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [45299] → new GasWaster@[..] - └─ ← [Return] 226 bytes of code + [44291] → new GasWaster@[..] + └─ ← [Return] 221 bytes of code - [226] GasWaster::wasteGas(200000 [2e5]) + [224] GasWaster::wasteGas(200000 [2e5]) └─ ← [Stop] @@ -337,7 +337,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new GasWaster@[..] - │ └─ ← [Return] 226 bytes of code + │ └─ ← [Return] 221 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -349,10 +349,10 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [45299] → new GasWaster@[..] - └─ ← [Return] 226 bytes of code + [44291] → new GasWaster@[..] + └─ ← [Return] 221 bytes of code - [226] GasWaster::wasteGas(200000 [2e5]) + [224] GasWaster::wasteGas(200000 [2e5]) └─ ← [Stop] @@ -522,7 +522,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new HashChecker@[..] - │ └─ ← [Return] 378 bytes of code + │ └─ ← [Return] 368 bytes of code └─ ← [Stop] @@ -2219,15 +2219,15 @@ contract SimpleScript is Script { [SOLC_VERSION] [ELAPSED] Compiler run successful! Traces: - [104553] SimpleScript::run() + [103771] SimpleScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] - ├─ [23875] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 - │ └─ ← [Return] 119 bytes of code - ├─ [13367] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 - │ ├─ [146] A::getValue() [staticcall] + ├─ [23273] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 + │ └─ ← [Return] 116 bytes of code + ├─ [13162] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 + │ ├─ [145] A::getValue() [staticcall] │ │ └─ ← [Return] 100 - │ └─ ← [Return] 63 bytes of code + │ └─ ← [Return] 62 bytes of code └─ ← [Stop] @@ -2237,13 +2237,13 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [23875] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 - └─ ← [Return] 119 bytes of code + [23273] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 + └─ ← [Return] 116 bytes of code - [15867] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 - ├─ [146] A::getValue() [staticcall] + [15662] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 + ├─ [145] A::getValue() [staticcall] │ └─ ← [Return] 100 - └─ ← [Return] 63 bytes of code + └─ ← [Return] 62 bytes of code ... "#]]); }); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 8389c381ef9ff..f51cf6703a171 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -575,7 +575,7 @@ Compiler run successful! Ran 1 test for test/Contract.t.sol:USDTCallingTest [PASS] test() ([GAS]) Traces: - [9516] USDTCallingTest::test() + [9406] USDTCallingTest::test() ├─ [0] VM::createSelectFork("[..]") │ └─ ← [Return] 0 ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] @@ -621,12 +621,12 @@ Compiler run successful! Ran 2 tests for test/Contract.t.sol:CustomTypesTest [FAIL: PoolNotInitialized()] testErr() ([GAS]) Traces: - [254] CustomTypesTest::testErr() + [253] CustomTypesTest::testErr() └─ ← [Revert] PoolNotInitialized() [PASS] testEvent() ([GAS]) Traces: - [1268] CustomTypesTest::testEvent() + [1267] CustomTypesTest::testEvent() ├─ emit MyEvent(a: 100) └─ ← [Stop] @@ -996,7 +996,7 @@ Compiler run successful! Ran 1 test for test/Contract.t.sol:PrecompileLabelsTest [PASS] testPrecompileLabels() ([GAS]) Traces: - [9474] PrecompileLabelsTest::testPrecompileLabels() + [9383] PrecompileLabelsTest::testPrecompileLabels() ├─ [0] VM::deal(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 1000000000000000000 [1e18]) │ └─ ← [Return] ├─ [0] VM::deal(console: [0x000000000000000000636F6e736F6c652e6c6f67], 1000000000000000000 [1e18]) @@ -1264,17 +1264,17 @@ Compiler run successful! Ran 1 test for test/Simple.sol:SimpleContractTest [PASS] test() ([GAS]) Traces: - [250463] SimpleContractTest::test() - ├─ [171014] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 854 bytes of code - ├─ [22638] SimpleContract::increment() - │ ├─ [20150] SimpleContract::_setNum(1) + [244864] SimpleContractTest::test() + ├─ [165406] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 826 bytes of code + ├─ [22630] SimpleContract::increment() + │ ├─ [20147] SimpleContract::_setNum(1) │ │ └─ ← 0 │ └─ ← [Stop] - ├─ [23219] SimpleContract::setValues(100, 0x0000000000000000000000000000000000000123) - │ ├─ [250] SimpleContract::_setNum(100) + ├─ [23204] SimpleContract::setValues(100, 0x0000000000000000000000000000000000000123) + │ ├─ [247] SimpleContract::_setNum(100) │ │ └─ ← 1 - │ ├─ [22339] SimpleContract::_setAddr(0x0000000000000000000000000000000000000123) + │ ├─ [22336] SimpleContract::_setAddr(0x0000000000000000000000000000000000000123) │ │ └─ ← 0x0000000000000000000000000000000000000000 │ └─ ← [Stop] └─ ← [Stop] @@ -1326,11 +1326,11 @@ contract SimpleContractTest is Test { r#" ... Traces: - [421947] SimpleContractTest::test() - ├─ [385978] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 1814 bytes of code - ├─ [2534] SimpleContract::setStr("new value") - │ ├─ [1600] SimpleContract::_setStr("new value") + [406629] SimpleContractTest::test() + ├─ [370554] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 1737 bytes of code + ├─ [2511] SimpleContract::setStr("new value") + │ ├─ [1588] SimpleContract::_setStr("new value") │ │ └─ ← "initial value" │ └─ ← [Stop] └─ ← [Stop] @@ -1460,10 +1460,10 @@ contract ATest is Test { cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" ... -[PASS] testNormalGas() (gas: 3202) -[PASS] testWeirdGas1() (gas: 3040) -[PASS] testWeirdGas2() (gas: 3148) -[PASS] testWithAssembly() (gas: 3083) +[PASS] testNormalGas() (gas: 3194) +[PASS] testWeirdGas1() (gas: 3032) +[PASS] testWeirdGas2() (gas: 3139) +[PASS] testWithAssembly() (gas: 3075) ... "#]]); }); @@ -1548,9 +1548,9 @@ contract ATest is Test { cmd.args(["test", "-vvvv"]).with_no_redact().assert_success().stdout_eq(str![[r#" ... Logs: - Gas cost: 34468 + Gas cost: 34367 ... -[PASS] test_GasMeter() (gas: 37512) +[PASS] test_GasMeter() (gas: 37407) ... "#]]); }); @@ -1635,33 +1635,33 @@ contract PauseTracingTest is DSTest { cmd.args(["test", "-vvvvv"]).assert_success().stdout_eq(str![[r#" ... Traces: - [7285] PauseTracingTest::setUp() + [7282] PauseTracingTest::setUp() ├─ emit DummyEvent(i: 1) ├─ [0] VM::pauseTracing() [staticcall] │ └─ ← [Return] └─ ← [Stop] - [294725] PauseTracingTest::test() + [282512] PauseTracingTest::test() ├─ [0] VM::resumeTracing() [staticcall] │ └─ ← [Return] - ├─ [18373] TraceGenerator::generate() - │ ├─ [1280] TraceGenerator::call(0) + ├─ [18327] TraceGenerator::generate() + │ ├─ [1278] TraceGenerator::call(0) │ │ ├─ emit DummyEvent(i: 0) │ │ └─ ← [Stop] - │ ├─ [1280] TraceGenerator::call(1) + │ ├─ [1278] TraceGenerator::call(1) │ │ ├─ emit DummyEvent(i: 1) │ │ └─ ← [Stop] - │ ├─ [1280] TraceGenerator::call(2) + │ ├─ [1278] TraceGenerator::call(2) │ │ ├─ emit DummyEvent(i: 2) │ │ └─ ← [Stop] │ ├─ [0] VM::pauseTracing() [staticcall] │ │ └─ ← [Return] │ ├─ [0] VM::resumeTracing() [staticcall] │ │ └─ ← [Return] - │ ├─ [1280] TraceGenerator::call(8) + │ ├─ [1278] TraceGenerator::call(8) │ │ ├─ emit DummyEvent(i: 8) │ │ └─ ← [Stop] - │ ├─ [1280] TraceGenerator::call(9) + │ ├─ [1278] TraceGenerator::call(9) │ │ ├─ emit DummyEvent(i: 9) │ │ └─ ← [Stop] │ └─ ← [Stop] @@ -2357,11 +2357,11 @@ Compiler run successful! Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest [PASS] test_proxy_trace() ([GAS]) Traces: - [152142] MetadataTraceTest::test_proxy_trace() - ├─ [49499] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 247 bytes of code - ├─ [37978] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b - │ └─ ← [Return] 63 bytes of code + [149783] MetadataTraceTest::test_proxy_trace() + ├─ [47297] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 236 bytes of code + ├─ [37762] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b + │ └─ ← [Return] 62 bytes of code └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -2382,11 +2382,11 @@ Compiler run successful! Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest [PASS] test_proxy_trace() ([GAS]) Traces: - [130521] MetadataTraceTest::test_proxy_trace() - ├─ [38693] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 193 bytes of code - ├─ [27175] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b - │ └─ ← [Return] 9 bytes of code + [128142] MetadataTraceTest::test_proxy_trace() + ├─ [36485] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 182 bytes of code + ├─ [26959] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b + │ └─ ← [Return] 8 bytes of code └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -2561,7 +2561,7 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { 31337 ); - assertEq(deployedAddress, address(0x030D07c16e2c0a77f74ab16f3C8F10ACeF89FF81)); + assertEq(deployedAddress, address(0x78280279172ED4C0E65BCE5Ee9DFdcd828f837DB)); } function test_getDeployments() public { @@ -2571,7 +2571,7 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { ); assertEq(deployments.length, 2); - assertEq(deployments[0], address(0x030D07c16e2c0a77f74ab16f3C8F10ACeF89FF81)); // Create2 address - latest deployment + assertEq(deployments[0], address(0x78280279172ED4C0E65BCE5Ee9DFdcd828f837DB)); // Create2 address - latest deployment assertEq(deployments[1], address(0x5FbDB2315678afecb367f032d93F642f64180aa3)); // Create address - oldest deployment } diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index a60602cbc1cc6..871cda045fa7f 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -3,8 +3,8 @@ use crate::{ config::*, test_helpers::{ - ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_CANCUN, TEST_DATA_DEFAULT, - TEST_DATA_MULTI_VERSION, + ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_DEFAULT, TEST_DATA_MULTI_VERSION, + TEST_DATA_PARIS, }, }; use alloy_primitives::U256; @@ -77,6 +77,6 @@ async fn test_cheats_local_multi_version() { } #[tokio::test(flavor = "multi_thread")] -async fn test_cheats_local_cancun() { - test_cheats_local(&TEST_DATA_CANCUN).await +async fn test_cheats_local_paris() { + test_cheats_local(&TEST_DATA_PARIS).await } diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 17d9f59d88fad..abab87d2866e9 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -1,6 +1,9 @@ //! Forge tests for core functionality. -use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; +use crate::{ + config::*, + test_helpers::{TEST_DATA_DEFAULT, TEST_DATA_PARIS}, +}; use forge::result::SuiteResult; use foundry_evm::traces::TraceKind; use foundry_test_utils::Filter; @@ -803,3 +806,25 @@ async fn test_legacy_assertions() { )]), ); } + +/// Test `beforeTest` functionality and `selfdestruct`. +/// See +#[tokio::test(flavor = "multi_thread")] +async fn test_before_setup_with_selfdestruct() { + let filter = Filter::new(".*", ".*BeforeTestSelfDestructTest", ".*"); + let results = TEST_DATA_PARIS.runner().test_collect(&filter); + + assert_multiple( + &results, + BTreeMap::from([( + "paris/core/BeforeTest.t.sol:BeforeTestSelfDestructTest", + vec![ + ("testKill()", true, None, None, None), + ("testA()", true, None, None, None), + ("testSimpleA()", true, None, None, None), + ("testB()", true, None, None, None), + ("testC(uint256)", true, None, None, None), + ], + )]), + ); +} diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 26c45aa184e52..8dc637528ddd3 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -2,7 +2,7 @@ use crate::{ config::*, - test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT}, + test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT, TEST_DATA_PARIS}, }; use alloy_chains::Chain; use forge::result::SuiteResult; @@ -35,9 +35,9 @@ async fn test_cheats_fork_revert() { /// Executes all non-reverting fork cheatcodes #[tokio::test(flavor = "multi_thread")] async fn test_cheats_fork() { - let mut config = TEST_DATA_DEFAULT.config.clone(); + let mut config = TEST_DATA_PARIS.config.clone(); config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let runner = TEST_DATA_PARIS.runner_with_config(config); let filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; @@ -86,7 +86,7 @@ async fn test_launch_fork_ws() { /// Tests that we can transact transactions in forking mode #[tokio::test(flavor = "multi_thread")] async fn test_transact_fork() { - let runner = TEST_DATA_DEFAULT.runner(); + let runner = TEST_DATA_PARIS.runner(); let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Transact")); TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index d6b047a17a93a..8972c9bd98f19 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -203,10 +203,10 @@ contract FuzzerDictTest is Test { .unwrap(); // Test that immutable address is used as fuzzed input, causing test to fail. - cmd.args(["test", "--fuzz-seed", "100", "--mt", "testImmutableOwner"]).assert_failure(); + cmd.args(["test", "--fuzz-seed", "119", "--mt", "testImmutableOwner"]).assert_failure(); // Test that storage address is used as fuzzed input, causing test to fail. cmd.forge_fuse() - .args(["test", "--fuzz-seed", "100", "--mt", "testStorageOwner"]) + .args(["test", "--fuzz-seed", "119", "--mt", "testStorageOwner"]) .assert_failure(); }); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 9f46e3c2ec1fc..53185cf978560 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -377,14 +377,11 @@ test_repro!(8383, false, None, |res| { let test = res.test_results.remove("testP256VerifyOutOfBounds()").unwrap(); assert_eq!(test.status, TestStatus::Success); match test.kind { - TestKind::Unit { gas } => assert_eq!(gas, 3103), + TestKind::Unit { gas } => assert_eq!(gas, 3101), _ => panic!("not a unit test kind"), } }); -// https://github.com/foundry-rs/foundry/issues/1543 -test_repro!(1543); - // https://github.com/foundry-rs/foundry/issues/6643 test_repro!(6643); diff --git a/crates/forge/tests/it/spec.rs b/crates/forge/tests/it/spec.rs index db98a15d1af24..aed2063a0fba4 100644 --- a/crates/forge/tests/it/spec.rs +++ b/crates/forge/tests/it/spec.rs @@ -1,13 +1,13 @@ //! Integration tests for EVM specifications. -use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; +use crate::{config::*, test_helpers::TEST_DATA_PARIS}; use foundry_evm::revm::primitives::SpecId; use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_shanghai_compat() { let filter = Filter::new("", "ShanghaiCompat", ".*spec"); - TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter) + TestConfig::with_filter(TEST_DATA_PARIS.runner(), filter) .evm_spec(SpecId::SHANGHAI) .run() .await; diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index eb5a0bf0a3c03..5e540d8c67aa0 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -34,7 +34,7 @@ static VYPER: LazyLock = LazyLock::new(|| std::env::temp_dir().join("vy /// Profile for the tests group. Used to configure separate configurations for test runs. pub enum ForgeTestProfile { Default, - Cancun, + Paris, MultiVersion, } @@ -42,16 +42,16 @@ impl fmt::Display for ForgeTestProfile { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Default => write!(f, "default"), - Self::Cancun => write!(f, "cancun"), + Self::Paris => write!(f, "paris"), Self::MultiVersion => write!(f, "multi-version"), } } } impl ForgeTestProfile { - /// Returns true if the profile is Cancun. - pub fn is_cancun(&self) -> bool { - matches!(self, Self::Cancun) + /// Returns true if the profile is Paris. + pub fn is_paris(&self) -> bool { + matches!(self, Self::Paris) } pub fn root(&self) -> PathBuf { @@ -66,8 +66,8 @@ impl ForgeTestProfile { let mut settings = Settings { libraries: Libraries::parse(&libs).unwrap(), ..Default::default() }; - if matches!(self, Self::Cancun) { - settings.evm_version = Some(EvmVersion::Cancun); + if matches!(self, Self::Paris) { + settings.evm_version = Some(EvmVersion::Paris); } let settings = SolcConfig::builder().settings(settings).build(); @@ -155,8 +155,8 @@ impl ForgeTestProfile { "fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string(), ]; - if self.is_cancun() { - config.evm_version = EvmVersion::Cancun; + if self.is_paris() { + config.evm_version = EvmVersion::Paris; } config @@ -195,8 +195,8 @@ impl ForgeTestData { let mut runner = MultiContractRunnerBuilder::new(Arc::new(self.config.clone())) .sender(self.evm_opts.sender) .with_test_options(self.test_opts.clone()); - if self.profile.is_cancun() { - runner = runner.evm_spec(SpecId::CANCUN); + if self.profile.is_paris() { + runner = runner.evm_spec(SpecId::MERGE); } runner @@ -338,9 +338,9 @@ pub fn get_compiled(project: &mut Project) -> ProjectCompileOutput { pub static TEST_DATA_DEFAULT: LazyLock = LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Default)); -/// Data for tests requiring Cancun support on Solc and EVM level. -pub static TEST_DATA_CANCUN: LazyLock = - LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Cancun)); +/// Data for tests requiring Paris support on Solc and EVM level. +pub static TEST_DATA_PARIS: LazyLock = + LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Paris)); /// Data for tests requiring Cancun support on Solc and EVM level. pub static TEST_DATA_MULTI_VERSION: LazyLock = diff --git a/testdata/cancun/cheats/BlobBaseFee.t.sol b/testdata/default/cheats/BlobBaseFee.t.sol similarity index 100% rename from testdata/cancun/cheats/BlobBaseFee.t.sol rename to testdata/default/cheats/BlobBaseFee.t.sol diff --git a/testdata/cancun/cheats/Blobhashes.t.sol b/testdata/default/cheats/Blobhashes.t.sol similarity index 100% rename from testdata/cancun/cheats/Blobhashes.t.sol rename to testdata/default/cheats/Blobhashes.t.sol diff --git a/testdata/default/cheats/Etch.t.sol b/testdata/default/cheats/Etch.t.sol index 33eaaf44ef87c..f60ea4cad650e 100644 --- a/testdata/default/cheats/Etch.t.sol +++ b/testdata/default/cheats/Etch.t.sol @@ -8,7 +8,7 @@ contract EtchTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testEtch() public { - address target = address(10); + address target = address(11); bytes memory code = hex"1010"; vm.etch(target, code); assertEq(string(code), string(target.code)); diff --git a/testdata/default/repros/Issue5929.t.sol b/testdata/default/repros/Issue5929.t.sol index 70c5a4f4ffbd4..ced9d6d9b4a39 100644 --- a/testdata/default/repros/Issue5929.t.sol +++ b/testdata/default/repros/Issue5929.t.sol @@ -9,8 +9,8 @@ contract Issue5929Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function test_transact_not_working() public { - vm.createSelectFork("mainnet", 15625301); + vm.createSelectFork("mainnet", 21134547); // https://etherscan.io/tx/0x96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143 - vm.transact(hex"96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143"); + vm.transact(hex"7dcff74771babf9c23363c4228e55a27f50224d4596b1ba6608b0b45712f94ba"); } } diff --git a/testdata/default/repros/Issue6538.t.sol b/testdata/default/repros/Issue6538.t.sol index 5b318a04c8687..34c4e2253a68b 100644 --- a/testdata/default/repros/Issue6538.t.sol +++ b/testdata/default/repros/Issue6538.t.sol @@ -9,9 +9,9 @@ contract Issue6538Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function test_transact() public { - bytes32 lastHash = 0xdbdce1d5c14a6ca17f0e527ab762589d6a73f68697606ae0bb90df7ac9ec5087; + bytes32 lastHash = 0x4b70ca8c5a0990b43df3064372d424d46efa41dfaab961754b86c5afb2df4f61; vm.createSelectFork("mainnet", lastHash); - bytes32 txhash = 0xadbe5cf9269a001d50990d0c29075b402bcc3a0b0f3258821881621b787b35c6; + bytes32 txhash = 0x7dcff74771babf9c23363c4228e55a27f50224d4596b1ba6608b0b45712f94ba; vm.transact(txhash); } } diff --git a/testdata/default/repros/Issue8006.t.sol b/testdata/default/repros/Issue8006.t.sol index 95b16e6f64faa..efe339d9fef2b 100644 --- a/testdata/default/repros/Issue8006.t.sol +++ b/testdata/default/repros/Issue8006.t.sol @@ -18,10 +18,10 @@ contract Mock { contract Issue8006Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); IERC20 dai; - bytes32 transaction = 0x67cbad73764049e228495a3f90144aab4a37cb4b5fd697dffc234aa5ed811ace; + bytes32 transaction = 0xb23f389b26eb6f95c08e275ec2c360ab3990169492ff0d3e7b7233a3f81d299f; function setUp() public { - vm.createSelectFork("mainnet", 16261704); + vm.createSelectFork("mainnet", 21134541); dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); } @@ -30,7 +30,7 @@ contract Issue8006Test is DSTest { vm.etch(address(dai), address(new Mock()).code); assertEq(dai.totalSupply(), 1); vm.rollFork(transaction); - assertEq(dai.totalSupply(), 5155217627191887307044676292); + assertEq(dai.totalSupply(), 3324657947511778619416491233); } function testRollForkEtchCalled() public { diff --git a/testdata/paris/cheats/Fork.t.sol b/testdata/paris/cheats/Fork.t.sol new file mode 100644 index 0000000000000..2f2e627de131a --- /dev/null +++ b/testdata/paris/cheats/Fork.t.sol @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +interface IWETH { + function deposit() external payable; + function balanceOf(address) external view returns (uint256); +} + +contract ForkTest is DSTest { + address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; + uint256 constant mainblock = 14_608_400; + + Vm constant vm = Vm(HEVM_ADDRESS); + IWETH WETH = IWETH(WETH_TOKEN_ADDR); + + uint256 forkA; + uint256 forkB; + + uint256 testValue; + + // this will create two _different_ forks during setup + function setUp() public { + forkA = vm.createFork("mainnet", mainblock); + forkB = vm.createFork("mainnet2", mainblock - 1); + testValue = 999; + } + + // ensures forks use different ids + function testForkIdDiffer() public { + assert(forkA != forkB); + } + + // ensures we can create and select in one step + function testCreateSelect() public { + uint256 fork = vm.createSelectFork("mainnet"); + assertEq(fork, vm.activeFork()); + } + + // ensures forks use different ids + function testCanSwitchForks() public { + vm.selectFork(forkA); + vm.selectFork(forkB); + vm.selectFork(forkB); + vm.selectFork(forkA); + } + + function testForksHaveSeparatedStorage() public { + vm.selectFork(forkA); + // read state from forkA + assert(WETH.balanceOf(0x0000000000000000000000000000000000000000) != 1); + + vm.selectFork(forkB); + // read state from forkB + uint256 forkBbalance = WETH.balanceOf(0x0000000000000000000000000000000000000000); + assert(forkBbalance != 1); + + vm.selectFork(forkA); + + // modify state + bytes32 value = bytes32(uint256(1)); + // "0x3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff" is the slot storing the balance of zero address for the weth contract + // `cast index address uint 0x0000000000000000000000000000000000000000 3` + bytes32 zero_address_balance_slot = 0x3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff; + vm.store(WETH_TOKEN_ADDR, zero_address_balance_slot, value); + assertEq( + WETH.balanceOf(0x0000000000000000000000000000000000000000), + 1, + "Cheatcode did not change value at the storage slot." + ); + + // switch forks and ensure the balance on forkB remains untouched + vm.selectFork(forkB); + assert(forkBbalance != 1); + // balance of forkB is untouched + assertEq( + WETH.balanceOf(0x0000000000000000000000000000000000000000), + forkBbalance, + "Cheatcode did not change value at the storage slot." + ); + } + + function testCanShareDataAcrossSwaps() public { + assertEq(testValue, 999); + + uint256 val = 300; + vm.selectFork(forkA); + assertEq(val, 300); + + testValue = 100; + + vm.selectFork(forkB); + assertEq(val, 300); + assertEq(testValue, 100); + + val = 99; + testValue = 300; + + vm.selectFork(forkA); + assertEq(val, 99); + assertEq(testValue, 300); + } + + // ensures forks use different ids + function testCanChangeChainId() public { + vm.selectFork(forkA); + uint256 newChainId = 1337; + vm.chainId(newChainId); + uint256 expected = block.chainid; + assertEq(newChainId, expected); + } + + // ensures forks change chain ids automatically + function testCanAutoUpdateChainId() public { + vm.createSelectFork("sepolia"); + assertEq(block.chainid, 11155111); + } + + // ensures forks storage is cached at block + function testStorageCaching() public { + vm.createSelectFork("mainnet", 19800000); + } +} diff --git a/testdata/default/cheats/GasSnapshots.t.sol b/testdata/paris/cheats/GasSnapshots.t.sol similarity index 100% rename from testdata/default/cheats/GasSnapshots.t.sol rename to testdata/paris/cheats/GasSnapshots.t.sol diff --git a/testdata/default/cheats/LastCallGas.t.sol b/testdata/paris/cheats/LastCallGas.t.sol similarity index 100% rename from testdata/default/cheats/LastCallGas.t.sol rename to testdata/paris/cheats/LastCallGas.t.sol diff --git a/testdata/default/repros/Issue1543.t.sol b/testdata/paris/core/BeforeTest.t.sol similarity index 98% rename from testdata/default/repros/Issue1543.t.sol rename to testdata/paris/core/BeforeTest.t.sol index e58f331c4af94..2b14bcad1d2ef 100644 --- a/testdata/default/repros/Issue1543.t.sol +++ b/testdata/paris/core/BeforeTest.t.sol @@ -10,7 +10,7 @@ contract SelfDestructor { } // https://github.com/foundry-rs/foundry/issues/1543 -contract Issue1543Test is DSTest { +contract BeforeTestSelfDestructTest is DSTest { SelfDestructor killer; uint256 a; uint256 b; diff --git a/testdata/default/fork/Transact.t.sol b/testdata/paris/fork/Transact.t.sol similarity index 99% rename from testdata/default/fork/Transact.t.sol rename to testdata/paris/fork/Transact.t.sol index 3756587725eb8..92d595f98c516 100644 --- a/testdata/default/fork/Transact.t.sol +++ b/testdata/paris/fork/Transact.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; -import "../logs/console.sol"; +import "../../default/logs/console.sol"; interface IERC20 { function transfer(address to, uint256 amount) external returns (bool); diff --git a/testdata/paris/spec/ShanghaiCompat.t.sol b/testdata/paris/spec/ShanghaiCompat.t.sol new file mode 100644 index 0000000000000..fd7213b3d0702 --- /dev/null +++ b/testdata/paris/spec/ShanghaiCompat.t.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract ShanghaiCompat is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testPush0() public { + address target = address(uint160(uint256(0xc4f3))); + + bytes memory bytecode = hex"365f5f37365ff3"; + // 36 CALLDATASIZE + // 5F PUSH0 + // 5F PUSH0 + // 37 CALLDATACOPY -> copies calldata at mem[0..calldatasize] + + // 36 CALLDATASIZE + // 5F PUSH0 + // F3 RETURN -> returns mem[0..calldatasize] + + vm.etch(target, bytecode); + + (bool success, bytes memory result) = target.call(bytes("hello PUSH0")); + assertTrue(success); + assertEq(string(result), "hello PUSH0"); + } +} From 550ebd8f473c0f02434ddef9ad9cdca36be4bd54 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:15:25 +0200 Subject: [PATCH 1683/1963] chore: update test values to cancun (#9344) --- crates/forge/tests/cli/build.rs | 16 ++--- crates/forge/tests/cli/cmd.rs | 110 ++++++++++++++++---------------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 51c358612e865..9585b216b1592 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -87,10 +87,10 @@ forgetest!(initcode_size_exceeds_limit, |prj, cmd| { str![[r#" { "HugeContract":{ - "runtime_size":202, - "init_size":49359, - "runtime_margin":24374, - "init_margin":-207 + "runtime_size":194, + "init_size":49344, + "runtime_margin":24382, + "init_margin":-192 } } "#]] @@ -117,10 +117,10 @@ forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { str![[r#" { "HugeContract": { - "runtime_size": 202, - "init_size": 49359, - "runtime_margin": 24374, - "init_margin": -207 + "runtime_size": 194, + "init_size": 49344, + "runtime_margin": 24382, + "init_margin": -192 } } "#]] diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 18f0327f6e907..3cd4ae5edb041 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2460,16 +2460,16 @@ contract GasReportFallbackTest is Test { Ran 1 test for test/DelegateProxyTest.sol:GasReportFallbackTest [PASS] test_fallback_gas_report() ([GAS]) Traces: - [331067] GasReportFallbackTest::test_fallback_gas_report() - ├─ [106511] → new ProxiedContract@[..] - │ └─ ← [Return] 246 bytes of code - ├─ [108698] → new DelegateProxy@[..] - │ └─ ← [Return] 143 bytes of code - ├─ [29396] DelegateProxy::fallback(100) - │ ├─ [3320] ProxiedContract::deposit(100) [delegatecall] + [327404] GasReportFallbackTest::test_fallback_gas_report() + ├─ [104475] → new ProxiedContract@[..] + │ └─ ← [Return] 236 bytes of code + ├─ [107054] → new DelegateProxy@[..] + │ └─ ← [Return] 135 bytes of code + ├─ [29384] DelegateProxy::fallback(100) + │ ├─ [3316] ProxiedContract::deposit(100) [delegatecall] │ │ └─ ← [Stop] │ └─ ← [Return] - ├─ [21160] DelegateProxy::deposit() + ├─ [21159] DelegateProxy::deposit() │ └─ ← [Stop] └─ ← [Stop] @@ -2477,18 +2477,18 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] | test/DelegateProxyTest.sol:DelegateProxy contract | | | | | | |---------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 108698 | 315 | | | | | +| 107054 | 300 | | | | | | Function Name | min | avg | median | max | # calls | -| deposit | 21160 | 21160 | 21160 | 21160 | 1 | -| fallback | 29396 | 29396 | 29396 | 29396 | 1 | +| deposit | 21159 | 21159 | 21159 | 21159 | 1 | +| fallback | 29384 | 29384 | 29384 | 29384 | 1 | | test/DelegateProxyTest.sol:ProxiedContract contract | | | | | | |-----------------------------------------------------|-----------------|------|--------|------|---------| | Deployment Cost | Deployment Size | | | | | -| 106511 | 276 | | | | | +| 104475 | 263 | | | | | | Function Name | min | avg | median | max | # calls | -| deposit | 3320 | 3320 | 3320 | 3320 | 1 | +| deposit | 3316 | 3316 | 3316 | 3316 | 1 | ... "#]]); @@ -2502,39 +2502,39 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] { "contract": "test/DelegateProxyTest.sol:DelegateProxy", "deployment": { - "gas": 108698, - "size": 315 + "gas": 107054, + "size": 300 }, "functions": { "deposit()": { "calls": 1, - "min": 21160, - "mean": 21160, - "median": 21160, - "max": 21160 + "min": 21159, + "mean": 21159, + "median": 21159, + "max": 21159 }, "fallback()": { "calls": 1, - "min": 29396, - "mean": 29396, - "median": 29396, - "max": 29396 + "min": 29384, + "mean": 29384, + "median": 29384, + "max": 29384 } } }, { "contract": "test/DelegateProxyTest.sol:ProxiedContract", "deployment": { - "gas": 106511, - "size": 276 + "gas": 104475, + "size": 263 }, "functions": { "deposit(uint256)": { "calls": 1, - "min": 3320, - "mean": 3320, - "median": 3320, - "max": 3320 + "min": 3316, + "mean": 3316, + "median": 3316, + "max": 3316 } } } @@ -2588,25 +2588,25 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] | test/NestedDeployTest.sol:AnotherChild contract | | | | | | |-------------------------------------------------|-----------------|-------|--------|-------|---------| | Deployment Cost | Deployment Size | | | | | -| 0 | 130 | | | | | +| 0 | 124 | | | | | | Function Name | min | avg | median | max | # calls | -| w | 21162 | 21162 | 21162 | 21162 | 1 | +| w | 21161 | 21161 | 21161 | 21161 | 1 | | test/NestedDeployTest.sol:Child contract | | | | | | |------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | -| 0 | 498 | | | | | +| 0 | 477 | | | | | | Function Name | min | avg | median | max | # calls | -| child | 325 | 325 | 325 | 325 | 1 | +| child | 323 | 323 | 323 | 323 | 1 | | test/NestedDeployTest.sol:Parent contract | | | | | | |-------------------------------------------|-----------------|-----|--------|-----|---------| | Deployment Cost | Deployment Size | | | | | -| 254857 | 770 | | | | | +| 251997 | 739 | | | | | | Function Name | min | avg | median | max | # calls | -| child | 182 | 182 | 182 | 182 | 1 | +| child | 181 | 181 | 181 | 181 | 1 | ... "#]]); @@ -2620,15 +2620,15 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] "contract": "test/NestedDeployTest.sol:AnotherChild", "deployment": { "gas": 0, - "size": 130 + "size": 124 }, "functions": { "w()": { "calls": 1, - "min": 21162, - "mean": 21162, - "median": 21162, - "max": 21162 + "min": 21161, + "mean": 21161, + "median": 21161, + "max": 21161 } } }, @@ -2636,31 +2636,31 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] "contract": "test/NestedDeployTest.sol:Child", "deployment": { "gas": 0, - "size": 498 + "size": 477 }, "functions": { "child()": { "calls": 1, - "min": 325, - "mean": 325, - "median": 325, - "max": 325 + "min": 323, + "mean": 323, + "median": 323, + "max": 323 } } }, { "contract": "test/NestedDeployTest.sol:Parent", "deployment": { - "gas": 254857, - "size": 770 + "gas": 251997, + "size": 739 }, "functions": { "child()": { "calls": 1, - "min": 182, - "mean": 182, - "median": 182, - "max": 182 + "min": 181, + "mean": 181, + "median": 181, + "max": 181 } } } @@ -2982,10 +2982,10 @@ Compiler run successful! str![[r#" { "Counter": { - "runtime_size": 247, - "init_size": 277, - "runtime_margin": 24329, - "init_margin": 48875 + "runtime_size": 236, + "init_size": 263, + "runtime_margin": 24340, + "init_margin": 48889 } } "#]] From 7e323c23463193f70c025f0df57b559a79db9676 Mon Sep 17 00:00:00 2001 From: mgiagante <5287175+mgiagante@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:42:38 +0000 Subject: [PATCH 1684/1963] feat(`forge build -vvvvv`): If verbosity level is 5 or higher show files to compile (#9325) * If verbosity level is 1 or higher, it shows dirty files. * Adds verbose message variant for compilation. * Removing `if..else` statement to always display `self.send_msg`. * Changes order of messages. * Removes semicolons and adds comment on message order. * Removes verbose variant in favor of the already existing variant. * nits, sort the dirty files list and prefix with - * Raises verbosity level to 5+ * Update crates/common/src/term.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: mgiagante <251503-mgiagante@users.noreply.gitlab.com> Co-authored-by: zerosnacks Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 1 + crates/common/Cargo.toml | 1 + crates/common/src/term.rs | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 1922c69b89af5..7dc745cbf0de2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3716,6 +3716,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-macros", + "itertools 0.13.0", "num-format", "reqwest", "semver 1.0.23", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 8fa745a139826..033c53e49dba9 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -50,6 +50,7 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } comfy-table.workspace = true dunce.workspace = true eyre.workspace = true +itertools.workspace = true num-format.workspace = true reqwest.workspace = true semver.workspace = true diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index ead39b5face35..e673987454cb2 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -3,6 +3,8 @@ use foundry_compilers::{ artifacts::remappings::Remapping, report::{self, BasicStdoutReporter, Reporter}, }; +use foundry_config::find_project_root; +use itertools::Itertools; use semver::Version; use std::{ io, @@ -17,6 +19,8 @@ use std::{ }; use yansi::Paint; +use crate::shell; + /// Some spinners // https://github.com/gernest/wow/blob/master/spin/spinners.go pub static SPINNERS: &[&[&str]] = &[ @@ -151,6 +155,24 @@ impl Drop for SpinnerReporter { impl Reporter for SpinnerReporter { fn on_compiler_spawn(&self, compiler_name: &str, version: &Version, dirty_files: &[PathBuf]) { + // Verbose message with dirty files displays first to avoid being overlapped + // by the spinner in .tick() which prints repeatedly over the same line. + if shell::verbosity() >= 5 { + let project_root = find_project_root(None); + + self.send_msg(format!( + "Files to compile:\n{}", + dirty_files + .iter() + .map(|path| { + let trimmed_path = path.strip_prefix(&project_root).unwrap_or(path); + format!("- {}", trimmed_path.display()) + }) + .sorted() + .format("\n") + )); + } + self.send_msg(format!( "Compiling {} files with {} {}.{}.{}", dirty_files.len(), From 6625e16e57bd66e4f7d43b1d2d6dfb74c4a88469 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:46:06 +0100 Subject: [PATCH 1685/1963] chore: add some more debugging to forge bind (#9345) --- crates/sol-macro-gen/src/sol_macro_gen.rs | 70 +++++++++++++---------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/crates/sol-macro-gen/src/sol_macro_gen.rs b/crates/sol-macro-gen/src/sol_macro_gen.rs index 7309104fec615..8c146aa05ddac 100644 --- a/crates/sol-macro-gen/src/sol_macro_gen.rs +++ b/crates/sol-macro-gen/src/sol_macro_gen.rs @@ -11,7 +11,7 @@ use alloy_sol_macro_expander::expand::expand; use alloy_sol_macro_input::{SolInput, SolInputKind}; -use eyre::{Context, Ok, OptionExt, Result}; +use eyre::{Context, OptionExt, Result}; use foundry_common::fs; use proc_macro2::{Span, TokenStream}; use std::{ @@ -39,7 +39,7 @@ impl SolMacroGen { #path }; - let sol_input: SolInput = syn::parse2(tokens).wrap_err("Failed to parse SolInput {e}")?; + let sol_input: SolInput = syn::parse2(tokens).wrap_err("failed to parse input")?; Ok(sol_input) } @@ -69,24 +69,35 @@ impl MultiSolMacroGen { pub fn generate_bindings(&mut self) -> Result<()> { for instance in &mut self.instances { - let input = instance.get_sol_input()?.normalize_json()?; + Self::generate_binding(instance).wrap_err_with(|| { + format!( + "failed to generate bindings for {}:{}", + instance.path.display(), + instance.name + ) + })?; + } - let SolInput { attrs: _attrs, path: _path, kind } = input; + Ok(()) + } - let tokens = match kind { - SolInputKind::Sol(mut file) => { - let sol_attr: syn::Attribute = syn::parse_quote! { - #[sol(rpc, alloy_sol_types = alloy::sol_types, alloy_contract = alloy::contract)] - }; - file.attrs.push(sol_attr); - expand(file).wrap_err("Failed to expand SolInput")? - } - _ => unreachable!(), - }; + fn generate_binding(instance: &mut SolMacroGen) -> Result<()> { + let input = instance.get_sol_input()?.normalize_json()?; - instance.expansion = Some(tokens); - } + let SolInput { attrs: _, path: _, kind } = input; + let tokens = match kind { + SolInputKind::Sol(mut file) => { + let sol_attr: syn::Attribute = syn::parse_quote! { + #[sol(rpc, alloy_sol_types = alloy::sol_types, alloy_contract = alloy::contract)] + }; + file.attrs.push(sol_attr); + expand(file).wrap_err("failed to expand")? + } + _ => unreachable!(), + }; + + instance.expansion = Some(tokens); Ok(()) } @@ -139,27 +150,28 @@ edition = "2021" )?; // Write src + let parse_error = |name: &str| { + format!("failed to parse generated tokens as an AST for {name};\nthis is likely a bug") + }; for instance in &self.instances { - let name = instance.name.to_lowercase(); - let contents = instance.expansion.as_ref().unwrap().to_string(); + let contents = instance.expansion.as_ref().unwrap(); - if !single_file { - let path = src.join(format!("{name}.rs")); - let file = syn::parse_file(&contents)?; - let contents = prettyplease::unparse(&file); - - fs::write(path.clone(), contents).wrap_err("Failed to write file")?; - writeln!(&mut lib_contents, "pub mod {name};")?; - } else { + let name = instance.name.to_lowercase(); + let path = src.join(format!("{name}.rs")); + let file = syn::parse2(contents.clone()) + .wrap_err_with(|| parse_error(&format!("{}:{}", path.display(), name)))?; + let contents = prettyplease::unparse(&file); + if single_file { write!(&mut lib_contents, "{contents}")?; + } else { + fs::write(path, contents).wrap_err("failed to write to file")?; + writeln!(&mut lib_contents, "pub mod {name};")?; } } let lib_path = src.join("lib.rs"); - let lib_file = syn::parse_file(&lib_contents)?; - + let lib_file = syn::parse_file(&lib_contents).wrap_err_with(|| parse_error("lib.rs"))?; let lib_contents = prettyplease::unparse(&lib_file); - fs::write(lib_path, lib_contents).wrap_err("Failed to write lib.rs")?; Ok(()) From 547d8a52ec7d286214511eb9c8ef5d5be601e81b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 19 Nov 2024 01:11:59 +0400 Subject: [PATCH 1686/1963] feat: compilation restrictions (#8668) * [wip] feat: compilation restrictions * Cargo.lock * update patch * fixes * update patch * update patch * wip * deps * bytecode hash * fixes * rm patches * pub --- Cargo.lock | 194 ++++++++++++++++--- Cargo.toml | 4 +- crates/cast/bin/cmd/storage.rs | 4 +- crates/cli/src/utils/cmd.rs | 31 ++- crates/config/src/compilation.rs | 115 +++++++++++ crates/config/src/lib.rs | 76 +++++++- crates/forge/bin/cmd/bind_json.rs | 8 +- crates/forge/bin/cmd/compiler.rs | 8 +- crates/forge/bin/cmd/create.rs | 44 ++++- crates/forge/bin/cmd/eip712.rs | 14 +- crates/forge/bin/cmd/test/mod.rs | 4 +- crates/forge/tests/cli/config.rs | 2 + crates/script/src/verify.rs | 1 + crates/verify/src/etherscan/flatten.rs | 2 +- crates/verify/src/etherscan/standard_json.rs | 9 +- crates/verify/src/provider.rs | 11 +- crates/verify/src/verify.rs | 63 +++++- 17 files changed, 500 insertions(+), 90 deletions(-) create mode 100644 crates/config/src/compilation.rs diff --git a/Cargo.lock b/Cargo.lock index 7dc745cbf0de2..81adf0f4b1e1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -799,6 +799,16 @@ dependencies = [ "libc", ] +[[package]] +name = "annotate-snippets" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e35ed54e5ea7997c14ed4c70ba043478db1112e98263b3b035907aa197d991" +dependencies = [ + "anstyle", + "unicode-width 0.1.14", +] + [[package]] name = "anstream" version = "0.6.18" @@ -3572,9 +3582,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.7.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff37530e7c5deead0f9d7dc2a27b070e683bef79735ab453849ebdee74fa848f" +checksum = "0faa449506113b4969029da2ac1df3a1b3201bf10c99a4a8e6d684977b80c938" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3755,9 +3765,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.11.6" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4754b3f3bb924202b29bd7f0584ea1446018926342884c86029a7d56ef1a22c1" +checksum = "9edf09554357ebfcd2ea28503badbaca311aac3c947d269a6bae5256543aa172" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3780,7 +3790,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "solang-parser", + "solar-parse", "svm-rs", "svm-rs-builds", "tempfile", @@ -3793,9 +3803,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.11.6" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6289da0f17fdb5a0454020dce595502b0abd2a56c15a36d4f6c05bd6c4ff864" +checksum = "134b2499a20136716422f1ae5afd3a5d6c2ef833bf97b7c956285ca96c1d9743" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3803,9 +3813,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.11.6" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf322ab7b726f2bafe9a7e6fb67db02801b35584a2b1d122b4feb52d8e9e7f" +checksum = "78a9be34b3a43e77871e5bbd75f4a81d23eebf8f098519ae1ae9e163a0f3d0da" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3827,9 +3837,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.11.6" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec47f94c7833adfe8049c819d9e31a60c3f440a68cf5baf34c318413d3eb0700" +checksum = "1738950051ebcee2135adac07b3ef1708c6377ffed0c5e9a2bb485f31498befb" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3842,9 +3852,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.11.6" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61971b34545e8ea01502df9d076e811ad3926f27d31adf2641e0c931ca646933" +checksum = "2ac2d9982eedb0eb3819f82c7efa1e28c1f78e031cdfb6adfa34690364fe5e0d" dependencies = [ "alloy-primitives", "cfg-if", @@ -4700,6 +4710,10 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "hashbrown" @@ -5255,6 +5269,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "index_vec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44faf5bb8861a9c72e20d3fb0fdbd59233e43056e2b80475ab0aacdc2e781355" + [[package]] name = "indexmap" version = "1.9.3" @@ -5576,6 +5596,16 @@ dependencies = [ "regex-automata 0.4.9", ] +[[package]] +name = "lasso" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e14eda50a3494b3bf7b9ce51c52434a761e383d7238ce1dd5dcec2fbc13e9fb" +dependencies = [ + "dashmap", + "hashbrown 0.14.5", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -5712,6 +5742,12 @@ dependencies = [ "tendril", ] +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matchers" version = "0.1.0" @@ -5890,9 +5926,9 @@ dependencies = [ [[package]] name = "mockall" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c28b3fb6d753d28c20e826cd46ee611fda1cf3cde03a443a974043247c065a" +checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2" dependencies = [ "cfg-if", "downcast", @@ -5904,9 +5940,9 @@ dependencies = [ [[package]] name = "mockall_derive" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "341014e7f530314e9a1fdbc7400b244efea7122662c96bfa248c31da5bfb2020" +checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898" dependencies = [ "cfg-if", "proc-macro2", @@ -6383,28 +6419,29 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +checksum = "8be4817d39f3272f69c59fe05d0535ae6456c2dc2fa1ba02910296c7e0a5c590" dependencies = [ "arrayvec", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", + "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +checksum = "8781a75c6205af67215f382092b6e0a4ff3734798523e69073d4bcd294ec767b" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] @@ -8046,9 +8083,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "indexmap 2.6.0", "itoa", @@ -8357,6 +8394,109 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "solar-ast" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5aeaf7a4bd326242c909bd287291226a540b62b36fa5824880248f4b1d4d6af" +dependencies = [ + "alloy-primitives", + "bumpalo", + "either", + "num-bigint", + "num-rational", + "semver 1.0.23", + "solar-data-structures", + "solar-interface", + "solar-macros", + "strum", + "typed-arena", +] + +[[package]] +name = "solar-config" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31d00d672a40a1a3620d7696f01a2d3301abf883d8168e1a9da3bf83f0c8e343" +dependencies = [ + "strum", +] + +[[package]] +name = "solar-data-structures" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6e4eb0b72ed7adbb808897c85de08ea99609774a58c72e3dce55c758043ca2" +dependencies = [ + "bumpalo", + "index_vec", + "indexmap 2.6.0", + "parking_lot", + "rayon", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "solar-interface" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21fb8925638f3da1bba7a9a6ebeac3511e5c6354f921f2bb2e1ddce4ac70c107" +dependencies = [ + "annotate-snippets", + "anstream", + "anstyle", + "const-hex", + "derive_builder", + "dunce", + "itertools 0.13.0", + "itoa", + "lasso", + "match_cfg", + "normalize-path", + "rayon", + "scc", + "scoped-tls", + "solar-config", + "solar-data-structures", + "solar-macros", + "thiserror 1.0.69", + "tracing", + "unicode-width 0.2.0", +] + +[[package]] +name = "solar-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0cc54b74e214647c1bbfc098d080cc5deac77f8dcb99aca91747276b01a15ad" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "solar-parse" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82c3659c15975cd80e5e1c44591278c230c59ad89082d797837499a4784e1b" +dependencies = [ + "alloy-primitives", + "bitflags 2.6.0", + "bumpalo", + "itertools 0.13.0", + "memchr", + "num-bigint", + "num-rational", + "num-traits", + "smallvec", + "solar-ast", + "solar-data-structures", + "solar-interface", + "tracing", +] + [[package]] name = "soldeer-commands" version = "0.5.1" @@ -9267,6 +9407,12 @@ dependencies = [ "utf-8", ] +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" version = "1.17.0" diff --git a/Cargo.toml b/Cargo.toml index 0c0962a2d95eb..624264cf218e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,8 +168,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.7.3", default-features = false } -foundry-compilers = { version = "0.11.6", default-features = false } +foundry-block-explorers = { version = "0.9.0", default-features = false } +foundry-compilers = { version = "0.12.1", default-features = false } foundry-fork-db = "0.6.0" solang-parser = "=0.3.3" diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 5e24591270013..13fa908bc94ac 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -23,7 +23,7 @@ use foundry_compilers::{ artifacts::{ConfigurableContractArtifact, StorageLayout}, compilers::{ solc::{Solc, SolcCompiler}, - Compiler, CompilerSettings, + Compiler, }, Artifact, Project, }; @@ -316,7 +316,7 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) fn add_storage_layout_output(project: &mut Project) { project.artifacts.additional_values.storage_layout = true; - project.settings.update_output_selection(|selection| { + project.update_output_selection(|selection| { selection.0.values_mut().for_each(|contract_selection| { contract_selection .values_mut() diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 2ebdc2539dff5..19e4425b54c7a 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -3,10 +3,10 @@ use alloy_primitives::Address; use eyre::{Result, WrapErr}; use foundry_common::{fs, TestFunctionExt}; use foundry_compilers::{ - artifacts::{CompactBytecode, CompactDeployedBytecode, Settings}, + artifacts::{CompactBytecode, Settings}, cache::{CacheEntry, CompilerCache}, utils::read_json_file, - Artifact, ProjectCompileOutput, + Artifact, ArtifactId, ProjectCompileOutput, }; use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, NamedChain}; use foundry_debugger::Debugger; @@ -32,17 +32,21 @@ use yansi::Paint; /// Runtime Bytecode of the given contract. #[track_caller] pub fn remove_contract( - output: &mut ProjectCompileOutput, + output: ProjectCompileOutput, path: &Path, name: &str, -) -> Result<(JsonAbi, CompactBytecode, CompactDeployedBytecode)> { - let contract = if let Some(contract) = output.remove(path, name) { - contract - } else { +) -> Result<(JsonAbi, CompactBytecode, ArtifactId)> { + let mut other = Vec::new(); + let Some((id, contract)) = output.into_artifacts().find_map(|(id, artifact)| { + if id.name == name && id.source == path { + Some((id, artifact)) + } else { + other.push(id.name); + None + } + }) else { let mut err = format!("could not find artifact: `{name}`"); - if let Some(suggestion) = - super::did_you_mean(name, output.artifacts().map(|(name, _)| name)).pop() - { + if let Some(suggestion) = super::did_you_mean(name, other).pop() { if suggestion != name { err = format!( r#"{err} @@ -64,12 +68,7 @@ pub fn remove_contract( .ok_or_else(|| eyre::eyre!("contract {} does not contain bytecode", name))? .into_owned(); - let runtime = contract - .get_deployed_bytecode() - .ok_or_else(|| eyre::eyre!("contract {} does not contain deployed bytecode", name))? - .into_owned(); - - Ok((abi, bin, runtime)) + Ok((abi, bin, id)) } /// Helper function for finding a contract by ContractName diff --git a/crates/config/src/compilation.rs b/crates/config/src/compilation.rs new file mode 100644 index 0000000000000..b4f00b91b0d92 --- /dev/null +++ b/crates/config/src/compilation.rs @@ -0,0 +1,115 @@ +use crate::{filter::GlobMatcher, serde_helpers}; +use foundry_compilers::{ + artifacts::{BytecodeHash, EvmVersion}, + multi::{MultiCompilerRestrictions, MultiCompilerSettings}, + settings::VyperRestrictions, + solc::{Restriction, SolcRestrictions}, + RestrictionsWithVersion, +}; +use semver::VersionReq; +use serde::{Deserialize, Serialize}; + +/// Keeps possible overrides for default settings which users may configure to construct additional +/// settings profile. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct SettingsOverrides { + pub name: String, + pub via_ir: Option, + #[serde(default, with = "serde_helpers::display_from_str_opt")] + pub evm_version: Option, + pub optimizer: Option, + pub optimizer_runs: Option, + pub bytecode_hash: Option, +} + +impl SettingsOverrides { + /// Applies the overrides to the given settings. + pub fn apply(&self, settings: &mut MultiCompilerSettings) { + if let Some(via_ir) = self.via_ir { + settings.solc.via_ir = Some(via_ir); + } + + if let Some(evm_version) = self.evm_version { + settings.solc.evm_version = Some(evm_version); + settings.vyper.evm_version = Some(evm_version); + } + + if let Some(enabled) = self.optimizer { + settings.solc.optimizer.enabled = Some(enabled); + } + + if let Some(optimizer_runs) = self.optimizer_runs { + settings.solc.optimizer.runs = Some(optimizer_runs); + } + + if let Some(bytecode_hash) = self.bytecode_hash { + if let Some(metadata) = settings.solc.metadata.as_mut() { + metadata.bytecode_hash = Some(bytecode_hash); + } else { + settings.solc.metadata = Some(bytecode_hash.into()); + } + } + } +} + +#[derive(Debug, thiserror::Error)] +pub enum RestrictionsError { + #[error("specified both exact and relative restrictions for {0}")] + BothExactAndRelative(&'static str), +} + +/// Restrictions for compilation of given paths. +/// +/// Only purpose of this type is to accept user input to later construct +/// `RestrictionsWithVersion`. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct CompilationRestrictions { + pub paths: GlobMatcher, + pub version: Option, + pub via_ir: Option, + pub bytecode_hash: Option, + + pub min_optimizer_runs: Option, + pub optimizer_runs: Option, + pub max_optimizer_runs: Option, + + #[serde(default, with = "serde_helpers::display_from_str_opt")] + pub min_evm_version: Option, + #[serde(default, with = "serde_helpers::display_from_str_opt")] + pub evm_version: Option, + #[serde(default, with = "serde_helpers::display_from_str_opt")] + pub max_evm_version: Option, +} + +impl TryFrom for RestrictionsWithVersion { + type Error = RestrictionsError; + + fn try_from(value: CompilationRestrictions) -> Result { + let (min_evm, max_evm) = + match (value.min_evm_version, value.max_evm_version, value.evm_version) { + (None, None, Some(exact)) => (Some(exact), Some(exact)), + (min, max, None) => (min, max), + _ => return Err(RestrictionsError::BothExactAndRelative("evm_version")), + }; + let (min_opt, max_opt) = + match (value.min_optimizer_runs, value.max_optimizer_runs, value.optimizer_runs) { + (None, None, Some(exact)) => (Some(exact), Some(exact)), + (min, max, None) => (min, max), + _ => return Err(RestrictionsError::BothExactAndRelative("optimizer_runs")), + }; + Ok(Self { + restrictions: MultiCompilerRestrictions { + solc: SolcRestrictions { + evm_version: Restriction { min: min_evm, max: max_evm }, + via_ir: value.via_ir, + optimizer_runs: Restriction { min: min_opt, max: max_opt }, + bytecode_hash: value.bytecode_hash, + }, + vyper: VyperRestrictions { + evm_version: Restriction { min: min_evm, max: max_evm }, + }, + }, + version: value.version, + }) + } +} diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index b87eadcefa0b9..6444802e3bc9b 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -33,8 +33,10 @@ use foundry_compilers::{ Compiler, }, error::SolcError, + multi::{MultiCompilerParsedSource, MultiCompilerRestrictions}, solc::{CliSettings, SolcSettings}, - ConfigurableArtifacts, Project, ProjectPathsConfig, VyperLanguage, + ConfigurableArtifacts, Graph, Project, ProjectPathsConfig, RestrictionsWithVersion, + VyperLanguage, }; use inflector::Inflector; use regex::Regex; @@ -43,6 +45,7 @@ use semver::Version; use serde::{Deserialize, Serialize, Serializer}; use std::{ borrow::Cow, + collections::BTreeMap, fs, path::{Path, PathBuf}, str::FromStr, @@ -116,6 +119,9 @@ use vyper::VyperConfig; mod bind_json; use bind_json::BindJsonConfig; +mod compilation; +use compilation::{CompilationRestrictions, SettingsOverrides}; + /// Foundry configuration /// /// # Defaults @@ -479,6 +485,14 @@ pub struct Config { #[serde(rename = "__warnings", default, skip_serializing)] pub warnings: Vec, + /// Additional settings profiles to use when compiling. + #[serde(default)] + pub additional_compiler_profiles: Vec, + + /// Restrictions on compilation of certain files. + #[serde(default)] + pub compilation_restrictions: Vec, + /// PRIVATE: This structure may grow, As such, constructing this structure should /// _always_ be done using a public constructor or update syntax: /// @@ -867,12 +881,66 @@ impl Config { self.create_project(false, true) } + /// Builds mapping with additional settings profiles. + fn additional_settings( + &self, + base: &MultiCompilerSettings, + ) -> BTreeMap { + let mut map = BTreeMap::new(); + + for profile in &self.additional_compiler_profiles { + let mut settings = base.clone(); + profile.apply(&mut settings); + map.insert(profile.name.clone(), settings); + } + + map + } + + /// Resolves globs and builds a mapping from individual source files to their restrictions + fn restrictions( + &self, + paths: &ProjectPathsConfig, + ) -> Result>, SolcError> + { + let mut map = BTreeMap::new(); + + let graph = Graph::::resolve(paths)?; + let (sources, _) = graph.into_sources(); + + for res in &self.compilation_restrictions { + for source in sources.keys().filter(|path| { + if res.paths.is_match(path) { + true + } else if let Ok(path) = path.strip_prefix(&paths.root) { + res.paths.is_match(path) + } else { + false + } + }) { + let res: RestrictionsWithVersion<_> = + res.clone().try_into().map_err(SolcError::msg)?; + if !map.contains_key(source) { + map.insert(source.clone(), res); + } else { + map.get_mut(source.as_path()).unwrap().merge(res); + } + } + } + + Ok(map) + } + /// Creates a [Project] with the given `cached` and `no_artifacts` flags pub fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { + let settings = self.compiler_settings()?; + let paths = self.project_paths(); let mut builder = Project::builder() .artifacts(self.configured_artifacts_handler()) - .paths(self.project_paths()) - .settings(self.compiler_settings()?) + .additional_settings(self.additional_settings(&settings)) + .restrictions(self.restrictions(&paths)?) + .settings(settings) + .paths(paths) .ignore_error_codes(self.ignored_error_codes.iter().copied().map(Into::into)) .ignore_paths(self.ignored_file_paths.clone()) .set_compiler_severity_filter(if self.deny_warnings { @@ -2243,6 +2311,8 @@ impl Default for Config { eof_version: None, alphanet: false, transaction_timeout: 120, + additional_compiler_profiles: Default::default(), + compilation_restrictions: Default::default(), eof: false, _non_exhaustive: (), } diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index c6a052836bafc..de7a5a7a71aa3 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -11,7 +11,7 @@ use foundry_compilers::{ multi::{MultiCompilerLanguage, MultiCompilerParsedSource}, project::ProjectCompiler, solc::SolcLanguage, - CompilerSettings, Graph, Project, + Graph, Project, }; use foundry_config::Config; use itertools::Itertools; @@ -72,7 +72,7 @@ impl BindJsonArgs { // We only generate bindings for a single Solidity version to avoid conflicts. let mut sources = graph // resolve graph into mapping language -> version -> sources - .into_sources_by_version(project.offline, &project.locked_versions, &project.compiler)? + .into_sources_by_version(&project)? .0 .into_iter() // we are only interested in Solidity sources @@ -81,7 +81,7 @@ impl BindJsonArgs { .1 .into_iter() // For now, we are always picking the latest version. - .max_by(|(v1, _), (v2, _)| v1.cmp(v2)) + .max_by(|(v1, _, _), (v2, _, _)| v1.cmp(v2)) .unwrap() .1; @@ -229,7 +229,7 @@ impl PreprocessedState { fn compile(self) -> Result { let Self { sources, target_path, mut project, config } = self; - project.settings.update_output_selection(|selection| { + project.update_output_selection(|selection| { *selection = OutputSelection::ast_output_selection(); }); diff --git a/crates/forge/bin/cmd/compiler.rs b/crates/forge/bin/cmd/compiler.rs index a7115c4876b8f..f5d62b6714195 100644 --- a/crates/forge/bin/cmd/compiler.rs +++ b/crates/forge/bin/cmd/compiler.rs @@ -63,18 +63,14 @@ impl ResolveArgs { let project = config.project()?; let graph = Graph::resolve(&project.paths)?; - let (sources, _) = graph.into_sources_by_version( - project.offline, - &project.locked_versions, - &project.compiler, - )?; + let (sources, _) = graph.into_sources_by_version(&project)?; let mut output: BTreeMap> = BTreeMap::new(); for (language, sources) in sources { let mut versions_with_paths: Vec = sources .iter() - .map(|(version, sources)| { + .map(|(version, sources, _)| { let paths: Vec = sources .iter() .filter_map(|(path_file, _)| { diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 83494acb99de1..e19feafcc6285 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -20,7 +20,9 @@ use foundry_common::{ fmt::parse_tokens, shell, }; -use foundry_compilers::{artifacts::BytecodeObject, info::ContractInfo, utils::canonicalize}; +use foundry_compilers::{ + artifacts::BytecodeObject, info::ContractInfo, utils::canonicalize, ArtifactId, +}; use foundry_config::{ figment::{ self, @@ -106,9 +108,9 @@ impl CreateArgs { project.find_contract_path(&self.contract.name)? }; - let mut output = compile::compile_target(&target_path, &project, shell::is_json())?; + let output = compile::compile_target(&target_path, &project, shell::is_json())?; - let (abi, bin, _) = remove_contract(&mut output, &target_path, &self.contract.name)?; + let (abi, bin, id) = remove_contract(output, &target_path, &self.contract.name)?; let bin = match bin.object { BytecodeObject::Bytecode(_) => bin.object, @@ -148,8 +150,17 @@ impl CreateArgs { if self.unlocked { // Deploy with unlocked account let sender = self.eth.wallet.from.expect("required"); - self.deploy(abi, bin, params, provider, chain_id, sender, config.transaction_timeout) - .await + self.deploy( + abi, + bin, + params, + provider, + chain_id, + sender, + config.transaction_timeout, + id, + ) + .await } else { // Deploy with signer let signer = self.eth.wallet.signer().await?; @@ -157,8 +168,17 @@ impl CreateArgs { let provider = ProviderBuilder::<_, _, AnyNetwork>::default() .wallet(EthereumWallet::new(signer)) .on_provider(provider); - self.deploy(abi, bin, params, provider, chain_id, deployer, config.transaction_timeout) - .await + self.deploy( + abi, + bin, + params, + provider, + chain_id, + deployer, + config.transaction_timeout, + id, + ) + .await } } @@ -177,13 +197,14 @@ impl CreateArgs { &self, constructor_args: Option, chain: u64, + id: &ArtifactId, ) -> Result<()> { // NOTE: this does not represent the same `VerifyArgs` that would be sent after deployment, // since we don't know the address yet. let mut verify = forge_verify::VerifyArgs { address: Default::default(), contract: Some(self.contract.clone()), - compiler_version: None, + compiler_version: Some(id.version.to_string()), constructor_args, constructor_args_path: None, num_of_optimizations: None, @@ -204,6 +225,7 @@ impl CreateArgs { evm_version: self.opts.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, guess_constructor_args: false, + compilation_profile: Some(id.profile.to_string()), }; // Check config for Etherscan API Keys to avoid preflight check failing if no @@ -229,6 +251,7 @@ impl CreateArgs { chain: u64, deployer_address: Address, timeout: u64, + id: ArtifactId, ) -> Result<()> { let bin = bin.into_bytes().unwrap_or_else(|| { panic!("no bytecode found in bin object for {}", self.contract.name) @@ -305,7 +328,7 @@ impl CreateArgs { constructor_args = Some(hex::encode(encoded_args)); } - self.verify_preflight_check(constructor_args.clone(), chain).await?; + self.verify_preflight_check(constructor_args.clone(), chain, &id).await?; } // Deploy the actual contract @@ -339,7 +362,7 @@ impl CreateArgs { let verify = forge_verify::VerifyArgs { address, contract: Some(self.contract), - compiler_version: None, + compiler_version: Some(id.version.to_string()), constructor_args, constructor_args_path: None, num_of_optimizations, @@ -357,6 +380,7 @@ impl CreateArgs { evm_version: self.opts.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, guess_constructor_args: false, + compilation_profile: Some(id.profile.to_string()), }; sh_println!("Waiting for {} to detect contract deployment...", verify.verifier.verifier)?; verify.run().await diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs index 5014d38d703b5..eb1d8dc1d3158 100644 --- a/crates/forge/bin/cmd/eip712.rs +++ b/crates/forge/bin/cmd/eip712.rs @@ -2,14 +2,10 @@ use clap::{Parser, ValueHint}; use eyre::{Ok, OptionExt, Result}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::compile::ProjectCompiler; -use foundry_compilers::{ - artifacts::{ - output_selection::OutputSelection, - visitor::{Visitor, Walk}, - ContractDefinition, EnumDefinition, SourceUnit, StructDefinition, TypeDescriptions, - TypeName, - }, - CompilerSettings, +use foundry_compilers::artifacts::{ + output_selection::OutputSelection, + visitor::{Visitor, Walk}, + ContractDefinition, EnumDefinition, SourceUnit, StructDefinition, TypeDescriptions, TypeName, }; use std::{collections::BTreeMap, fmt::Write, path::PathBuf}; @@ -31,7 +27,7 @@ impl Eip712Args { let config = self.try_load_config_emit_warnings()?; let mut project = config.create_project(false, true)?; let target_path = dunce::canonicalize(self.target_path)?; - project.settings.update_output_selection(|selection| { + project.update_output_selection(|selection| { *selection = OutputSelection::ast_output_selection(); }); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 613d570785b99..4e811bcbfbf96 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -23,7 +23,7 @@ use foundry_cli::{ use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell, TestFunctionExt}; use foundry_compilers::{ artifacts::output_selection::OutputSelection, - compilers::{multi::MultiCompilerLanguage, CompilerSettings, Language}, + compilers::{multi::MultiCompilerLanguage, Language}, utils::source_files_iter, ProjectCompileOutput, }; @@ -203,7 +203,7 @@ impl TestArgs { filter: &ProjectPathsAwareFilter, ) -> Result> { let mut project = config.create_project(true, true)?; - project.settings.update_output_selection(|selection| { + project.update_output_selection(|selection| { *selection = OutputSelection::common_output_selection(["abi".to_string()]); }); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 11bcd49e2c40a..db87a85ba0d10 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -154,6 +154,8 @@ forgetest!(can_extract_config_values, |prj, cmd| { eof_version: None, alphanet: false, transaction_timeout: 120, + additional_compiler_profiles: Default::default(), + compilation_restrictions: Default::default(), eof: false, _non_exhaustive: (), }; diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 55435c5592426..220991703df7d 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -155,6 +155,7 @@ impl VerifyBundle { evm_version: None, show_standard_json_input: false, guess_constructor_args: false, + compilation_profile: Some(artifact.profile.to_string()), }; return Some(verify) diff --git a/crates/verify/src/etherscan/flatten.rs b/crates/verify/src/etherscan/flatten.rs index ffe1496cad5d7..a0b3defd7f90e 100644 --- a/crates/verify/src/etherscan/flatten.rs +++ b/crates/verify/src/etherscan/flatten.rs @@ -90,7 +90,7 @@ impl EtherscanFlattenedSource { let out = SolcCompiler::Specific(solc).compile(&input)?; if out.errors.iter().any(|e| e.is_error()) { let mut o = AggregatedCompilerOutput::::default(); - o.extend(version, RawBuildInfo::new(&input, &out, false)?, out); + o.extend(version, RawBuildInfo::new(&input, &out, false)?, "default", out); let diags = o.diagnostics(&[], &[], Default::default()); eyre::bail!( diff --git a/crates/verify/src/etherscan/standard_json.rs b/crates/verify/src/etherscan/standard_json.rs index cab3010fa638c..e2fb5d2a47c03 100644 --- a/crates/verify/src/etherscan/standard_json.rs +++ b/crates/verify/src/etherscan/standard_json.rs @@ -18,7 +18,8 @@ impl EtherscanSourceProvider for EtherscanStandardJsonSource { .wrap_err("Failed to get standard json input")? .normalize_evm_version(&context.compiler_version); - input.settings.libraries.libs = input + let mut settings = context.compiler_settings.solc.settings.clone(); + settings.libraries.libs = input .settings .libraries .libs @@ -28,8 +29,12 @@ impl EtherscanSourceProvider for EtherscanStandardJsonSource { }) .collect(); + settings.remappings = input.settings.remappings; + // remove all incompatible settings - input.settings.sanitize(&context.compiler_version, SolcLanguage::Solidity); + settings.sanitize(&context.compiler_version, SolcLanguage::Solidity); + + input.settings = settings; let source = serde_json::to_string(&input).wrap_err("Failed to parse standard json input")?; diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index bc01bd9e304d6..ab6c5e9f642ff 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -9,7 +9,8 @@ use eyre::{OptionExt, Result}; use foundry_common::compile::ProjectCompiler; use foundry_compilers::{ artifacts::{output_selection::OutputSelection, Metadata, Source}, - compilers::{multi::MultiCompilerParsedSource, solc::SolcCompiler, CompilerSettings}, + compilers::{multi::MultiCompilerParsedSource, solc::SolcCompiler}, + multi::MultiCompilerSettings, solc::Solc, Graph, Project, }; @@ -25,6 +26,7 @@ pub struct VerificationContext { pub target_path: PathBuf, pub target_name: String, pub compiler_version: Version, + pub compiler_settings: MultiCompilerSettings, } impl VerificationContext { @@ -33,6 +35,7 @@ impl VerificationContext { target_name: String, compiler_version: Version, config: Config, + compiler_settings: MultiCompilerSettings, ) -> Result { let mut project = config.project()?; project.no_artifacts = true; @@ -40,13 +43,13 @@ impl VerificationContext { let solc = Solc::find_or_install(&compiler_version)?; project.compiler.solc = Some(SolcCompiler::Specific(solc)); - Ok(Self { config, project, target_name, target_path, compiler_version }) + Ok(Self { config, project, target_name, target_path, compiler_version, compiler_settings }) } /// Compiles target contract requesting only ABI and returns it. pub fn get_target_abi(&self) -> Result { let mut project = self.project.clone(); - project.settings.update_output_selection(|selection| { + project.update_output_selection(|selection| { *selection = OutputSelection::common_output_selection(["abi".to_string()]) }); @@ -65,7 +68,7 @@ impl VerificationContext { /// Compiles target file requesting only metadata and returns it. pub fn get_target_metadata(&self) -> Result { let mut project = self.project.clone(); - project.settings.update_output_selection(|selection| { + project.update_output_selection(|selection| { *selection = OutputSelection::common_output_selection(["metadata".to_string()]); }); diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index 89cfd99aa676c..9c32ee95f5bfa 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -80,6 +80,10 @@ pub struct VerifyArgs { #[arg(long, value_name = "VERSION")] pub compiler_version: Option, + /// The compilation profile to use to build the smart contract. + #[arg(long, value_name = "PROFILE_NAME")] + pub compilation_profile: Option, + /// The number of optimization runs used to build the smart contract. #[arg(long, visible_alias = "optimizer-runs", value_name = "NUM")] pub num_of_optimizations: Option, @@ -258,6 +262,8 @@ impl VerifyArgs { project.find_contract_path(&contract.name)? }; + let cache = project.read_cache_file().ok(); + let version = if let Some(ref version) = self.compiler_version { version.trim_start_matches('v').parse()? } else if let Some(ref solc) = config.solc { @@ -265,10 +271,8 @@ impl VerifyArgs { SolcReq::Version(version) => version.to_owned(), SolcReq::Local(solc) => Solc::new(solc)?.version, } - } else if let Some(entry) = project - .read_cache_file() - .ok() - .and_then(|mut cache| cache.files.remove(&contract_path)) + } else if let Some(entry) = + cache.as_ref().and_then(|cache| cache.files.get(&contract_path).cloned()) { let unique_versions = entry .artifacts @@ -291,7 +295,48 @@ impl VerifyArgs { eyre::bail!("If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml") }; - VerificationContext::new(contract_path, contract.name.clone(), version, config) + let settings = if let Some(profile) = &self.compilation_profile { + if profile == "default" { + &project.settings + } else if let Some(settings) = project.additional_settings.get(profile.as_str()) { + settings + } else { + eyre::bail!("Unknown compilation profile: {}", profile) + } + } else if let Some((cache, entry)) = cache + .as_ref() + .and_then(|cache| Some((cache, cache.files.get(&contract_path)?.clone()))) + { + let profiles = entry + .artifacts + .get(&contract.name) + .and_then(|artifacts| artifacts.get(&version)) + .map(|artifacts| artifacts.keys().collect::>()) + .unwrap_or_default(); + + if profiles.is_empty() { + eyre::bail!("No matching artifact found for {}", contract.name); + } else if profiles.len() > 1 { + eyre::bail!("Ambiguous compilation profiles found in cache: {}, please specify the profile through `--compilation-profile` flag", profiles.iter().join(", ")) + } + + let profile = profiles.into_iter().next().unwrap().to_owned(); + let settings = cache.profiles.get(&profile).expect("must be present"); + + settings + } else if project.additional_settings.is_empty() { + &project.settings + } else { + eyre::bail!("If cache is disabled, compilation profile must be provided with `--compiler-version` option or set in foundry.toml") + }; + + VerificationContext::new( + contract_path, + contract.name.clone(), + version, + config, + settings.clone(), + ) } else { if config.get_rpc_url().is_none() { eyre::bail!("You have to provide a contract name or a valid RPC URL") @@ -311,11 +356,19 @@ impl VerifyArgs { )) }; + let settings = project + .settings_profiles() + .find_map(|(name, settings)| { + (name == artifact_id.profile.as_str()).then_some(settings) + }) + .expect("must be present"); + VerificationContext::new( artifact_id.source.clone(), artifact_id.name.split('.').next().unwrap().to_owned(), artifact_id.version.clone(), config, + settings.clone(), ) } } From c13d42e850da353c0856a8b0d4123e13cc40045d Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 19 Nov 2024 01:27:51 +0400 Subject: [PATCH 1687/1963] fix: identification of contracts in scripts (#9346) * fix: identification of contracts in scripts * clippy --- crates/script/src/simulate.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index f8f9c9a3662fb..a9798c43e4714 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -16,7 +16,7 @@ use eyre::{Context, Result}; use forge_script_sequence::{ScriptSequence, TransactionWithMetadata}; use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_different_gas_calc, now}; -use foundry_common::{get_contract_name, ContractData}; +use foundry_common::ContractData; use foundry_evm::traces::{decode_trace_arena, render_trace_arena}; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; @@ -205,9 +205,8 @@ impl PreSimulationState { .contracts .iter() .filter_map(move |(addr, contract_id)| { - let contract_name = get_contract_name(contract_id); if let Ok(Some((_, data))) = - self.build_data.known_contracts.find_by_name_or_identifier(contract_name) + self.build_data.known_contracts.find_by_name_or_identifier(contract_id) { return Some((*addr, data)); } From dacf3410e84bab1d8bab34a3c53364ab4fca4063 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:44:53 +0200 Subject: [PATCH 1688/1963] fix(`coverage`): allow `ir-minimum` for versions < 0.8.5 (#9341) * fix(coverage): allow ir-minimum for versions < 0.8.5 * Fix * Remove 0.8.13 restriction, update message and sanitize for 0.8.4 if version cannot be detected * Update crates/forge/bin/cmd/coverage.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/forge/bin/cmd/coverage.rs | 27 +++++++++++------------- crates/forge/tests/cli/coverage.rs | 34 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 56b2024e391bf..7e60a5451efcd 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -16,7 +16,7 @@ use forge::{ use foundry_cli::utils::{LoadConfig, STATIC_FUZZ_SEED}; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ - artifacts::{sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode}, + artifacts::{sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode, SolcLanguage}, Artifact, ArtifactId, Project, ProjectCompileOutput, }; use foundry_config::{Config, SolcReq}; @@ -94,23 +94,12 @@ impl CoverageArgs { // Set up the project let mut project = config.create_project(false, false)?; if self.ir_minimum { - // TODO: How to detect solc version if the user does not specify a solc version in - // config case1: specify local installed solc ? - // case2: multiple solc versions used and auto_detect_solc == true - if let Some(SolcReq::Version(version)) = &config.solc { - if *version < Version::new(0, 8, 13) { - return Err(eyre::eyre!( - "viaIR with minimum optimization is only available in Solidity 0.8.13 and above." - )); - } - } - // print warning message sh_warn!("{}", concat!( - "Warning! \"--ir-minimum\" flag enables viaIR with minimum optimization, \ + "`--ir-minimum` enables viaIR with minimum optimization, \ which can result in inaccurate source mappings.\n", "Only use this flag as a workaround if you are experiencing \"stack too deep\" errors.\n", - "Note that \"viaIR\" is only available in Solidity 0.8.13 and above.\n", + "Note that \"viaIR\" is production ready since Solidity 0.8.13 and above.\n", "See more: https://github.com/foundry-rs/foundry/issues/3357", ))?; @@ -119,7 +108,15 @@ impl CoverageArgs { // And also in new releases of solidity: // https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 project.settings.solc.settings = - project.settings.solc.settings.with_via_ir_minimum_optimization() + project.settings.solc.settings.with_via_ir_minimum_optimization(); + let version = if let Some(SolcReq::Version(version)) = &config.solc { + version + } else { + // Sanitize settings for solc 0.8.4 if version cannot be detected. + // See . + &Version::new(0, 8, 4) + }; + project.settings.solc.settings.sanitize(version, SolcLanguage::Solidity); } else { project.settings.solc.optimizer.disable(); project.settings.solc.optimizer.runs = None; diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 0ed272ae2531d..65900c592ba50 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1413,3 +1413,37 @@ contract AContractTest is DSTest { "#]]); }); + +// +// Test coverage with `--ir-minimum` for solidity < 0.8.5. +forgetest!(test_ir_minimum_coverage, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +pragma solidity 0.8.4; + +contract AContract { + function isContract(address account) internal view returns (bool) { + bytes32 codehash; + bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; + assembly { + codehash := extcodehash(account) + } + return (codehash != accountHash && codehash != 0x0); + } +} + "#, + ) + .unwrap(); + + // Assert coverage doesn't fail with `Error: Unknown key "inliner"`. + cmd.arg("coverage").arg("--ir-minimum").assert_success().stdout_eq(str![[r#" +... +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|-------------|--------------|---------------|-------------| +| src/AContract.sol | 0.00% (0/4) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | +| Total | 0.00% (0/4) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | + +"#]]); +}); From 25b317afd1387da82deca96e2b98d9a9c7b34784 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:23:05 +0100 Subject: [PATCH 1689/1963] chore: don't color error message in red (#9352) * chore: don't color error message in red * Update crates/cli/src/handler.rs Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/cli/src/handler.rs | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index b2fbb49d4ea86..ed32fa16b8083 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -1,21 +1,16 @@ use eyre::EyreHandler; -use std::error::Error; -use yansi::Paint; +use std::{error::Error, fmt}; /// A custom context type for Foundry specific error reporting via `eyre` #[derive(Debug)] pub struct Handler; impl EyreHandler for Handler { - fn debug( - &self, - error: &(dyn Error + 'static), - f: &mut core::fmt::Formatter<'_>, - ) -> core::fmt::Result { + fn debug(&self, error: &(dyn Error + 'static), f: &mut fmt::Formatter<'_>) -> fmt::Result { if f.alternate() { - return core::fmt::Debug::fmt(error, f) + return fmt::Debug::fmt(error, f) } - write!(f, "{}", error.red())?; + write!(f, "{error}")?; if let Some(cause) = error.source() { write!(f, "\n\nContext:")?; @@ -37,7 +32,7 @@ impl EyreHandler for Handler { } } -/// Installs the Foundry eyre hook as the global error report hook. +/// Installs the Foundry [eyre] and [panic](mod@std::panic) hooks as the global ones. /// /// # Details /// @@ -51,19 +46,17 @@ pub fn install() { std::env::set_var("RUST_BACKTRACE", "1"); } - if std::env::var_os("FOUNDRY_DEBUG").is_some() { - if let Err(e) = color_eyre::install() { - debug!("failed to install color eyre error hook: {e}"); - } + let panic_section = + "This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry"; + let (panic_hook, debug_eyre_hook) = + color_eyre::config::HookBuilder::default().panic_section(panic_section).into_hooks(); + panic_hook.install(); + let eyre_install_result = if std::env::var_os("FOUNDRY_DEBUG").is_some() { + debug_eyre_hook.install() } else { - let (panic_hook, _) = color_eyre::config::HookBuilder::default() - .panic_section( - "This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry", - ) - .into_hooks(); - panic_hook.install(); - if let Err(e) = eyre::set_hook(Box::new(move |_| Box::new(Handler))) { - debug!("failed to install eyre error hook: {e}"); - } + eyre::set_hook(Box::new(|_| Box::new(Handler))) + }; + if let Err(e) = eyre_install_result { + debug!("failed to install eyre error hook: {e}"); } } From 19249c3874146ec1a60c35fbe7800f9f21319207 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:23:21 +0100 Subject: [PATCH 1690/1963] chore: remove redundant 'setup failed' in setup errors (#9354) --- crates/forge/src/runner.rs | 10 ++-------- crates/forge/tests/it/core.rs | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 8ed3706defa8b..1302c39ad1f57 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -157,15 +157,9 @@ impl ContractRunner<'_> { raw: RawCallResult { traces, labels, logs, coverage, .. }, reason, } = *err; - (logs, traces, labels, Some(format!("setup failed: {reason}")), coverage) + (logs, traces, labels, Some(reason), coverage) } - Err(err) => ( - Vec::new(), - None, - HashMap::default(), - Some(format!("setup failed: {err}")), - None, - ), + Err(err) => (Vec::new(), None, HashMap::default(), Some(err.to_string()), None), }; traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); logs.extend(setup_logs); diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index abab87d2866e9..c8a599195441a 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -23,7 +23,7 @@ async fn test_core() { vec![( "setUp()", false, - Some("setup failed: revert: setup failed predictably".to_string()), + Some("revert: setup failed predictably".to_string()), None, None, )], @@ -70,13 +70,7 @@ async fn test_core() { ), ( "default/core/FailingTestAfterFailedSetup.t.sol:FailingTestAfterFailedSetupTest", - vec![( - "setUp()", - false, - Some("setup failed: execution error".to_string()), - None, - None, - )], + vec![("setUp()", false, Some("execution error".to_string()), None, None)], ), ( "default/core/MultipleAfterInvariant.t.sol:MultipleAfterInvariant", From 9b490823166927b218e62d86ac183c87aaf923ce Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:50:13 +0100 Subject: [PATCH 1691/1963] chore: make environment variable error nicer (#9353) --- crates/config/src/resolve.rs | 18 +++++++++++++----- testdata/default/cheats/RpcUrls.t.sol | 4 +--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/config/src/resolve.rs b/crates/config/src/resolve.rs index 179ecffa2901a..20606cb11aa57 100644 --- a/crates/config/src/resolve.rs +++ b/crates/config/src/resolve.rs @@ -23,15 +23,23 @@ impl UnresolvedEnvVarError { pub fn try_resolve(&self) -> Result { interpolate(&self.unresolved) } + + fn is_simple(&self) -> bool { + RE_PLACEHOLDER.captures_iter(&self.unresolved).count() <= 1 + } } impl fmt::Display for UnresolvedEnvVarError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "Failed to resolve env var `{}` in `{}`: {}", - self.var, self.unresolved, self.source - ) + write!(f, "environment variable `{}` ", self.var)?; + f.write_str(match self.source { + VarError::NotPresent => "not found", + VarError::NotUnicode(_) => "is not valid unicode", + })?; + if !self.is_simple() { + write!(f, " in `{}`", self.unresolved)?; + } + Ok(()) } } diff --git a/testdata/default/cheats/RpcUrls.t.sol b/testdata/default/cheats/RpcUrls.t.sol index aaa5a00bdd976..9425d59631b59 100644 --- a/testdata/default/cheats/RpcUrls.t.sol +++ b/testdata/default/cheats/RpcUrls.t.sol @@ -22,9 +22,7 @@ contract RpcUrlTest is DSTest { // can set env and return correct url function testCanSetAndGetURLAndAllUrls() public { // this will fail because alias is not set - vm._expectCheatcodeRevert( - "Failed to resolve env var `RPC_ENV_ALIAS` in `${RPC_ENV_ALIAS}`: environment variable not found" - ); + vm._expectCheatcodeRevert("environment variable `RPC_ENV_ALIAS` not found"); string[2][] memory _urls = vm.rpcUrls(); string memory url = vm.rpcUrl("mainnet"); From 9f0c26d9b61e6b1c0536945391a7158d68eda32c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:33:23 +0100 Subject: [PATCH 1692/1963] test: update external forge-std (#9356) --- crates/forge/tests/cli/ext_integration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index b2747e3ccb80d..e9437f04c9e9c 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -2,7 +2,7 @@ use foundry_test_utils::util::ExtTester; #[test] fn forge_std() { - ExtTester::new("foundry-rs", "forge-std", "1d0766bc5d814f117c7b1e643828f7d85024fb51") + ExtTester::new("foundry-rs", "forge-std", "2b59872eee0b8088ddcade39fe8c041e17bb79c0") // Skip fork tests. .args(["--nmc", "Fork"]) .run(); From 7538c4ed5a8575f403321d06c52882d3804eab3d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:48:29 +0200 Subject: [PATCH 1693/1963] chore(ci): archive endpoints config (#9348) * chore: move archive endpoints to different provider * Make archive endpoints configurable in env vars * Truncate fork url in err * Include only provider in failed fork message * Add env vars from secrets * Fix tests --------- Co-authored-by: Matthias Seitz --- .github/workflows/nextest.yml | 2 ++ Cargo.lock | 1 + crates/anvil/tests/it/fork.rs | 1 + crates/evm/core/Cargo.toml | 1 + crates/evm/core/src/opts.rs | 9 ++++++- crates/forge/tests/cli/test_cmd.rs | 28 +++++++++++++++++++++- crates/test-utils/src/rpc.rs | 38 ++++++++++++++++++++++++------ 7 files changed, 71 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nextest.yml b/.github/workflows/nextest.yml index da862c657abff..6fc1a6703901f 100644 --- a/.github/workflows/nextest.yml +++ b/.github/workflows/nextest.yml @@ -91,4 +91,6 @@ jobs: - name: Test env: SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} + HTTP_ARCHIVE_URLS: ${{ secrets.HTTP_ARCHIVE_URLS }} + WS_ARCHIVE_URLS: ${{ secrets.WS_ARCHIVE_URLS }} run: cargo nextest run ${{ matrix.flags }} diff --git a/Cargo.lock b/Cargo.lock index 81adf0f4b1e1f..144c6e07800cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3998,6 +3998,7 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tracing", + "url", ] [[package]] diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index a35d7c267d625..821395417fa38 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1040,6 +1040,7 @@ async fn can_impersonate_in_fork() { // #[tokio::test(flavor = "multi_thread")] +#[ignore] async fn test_total_difficulty_fork() { let (api, handle) = spawn(fork_config()).await; diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 46441201664e5..c9f5131d7f34e 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -59,6 +59,7 @@ serde_json.workspace = true thiserror.workspace = true tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true +url.workspace = true [dev-dependencies] foundry-test-utils.workspace = true diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 17ecbcca170eb..99cc8dabaf076 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -8,6 +8,7 @@ use foundry_common::{provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS}; use foundry_config::{Chain, Config}; use revm::primitives::{BlockEnv, CfgEnv, TxEnv}; use serde::{Deserialize, Deserializer, Serialize}; +use url::Url; #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct EvmOpts { @@ -102,7 +103,13 @@ impl EvmOpts { ) .await .wrap_err_with(|| { - format!("Could not instantiate forked environment with fork url: {fork_url}") + let mut err_msg = "Could not instantiate forked environment".to_string(); + if let Ok(url) = Url::parse(fork_url) { + if let Some(provider) = url.host() { + err_msg.push_str(&format!(" with provider {provider}")); + } + } + err_msg }) } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index f51cf6703a171..8e064c63c9fdd 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -575,7 +575,7 @@ Compiler run successful! Ran 1 test for test/Contract.t.sol:USDTCallingTest [PASS] test() ([GAS]) Traces: - [9406] USDTCallingTest::test() + [..] USDTCallingTest::test() ├─ [0] VM::createSelectFork("[..]") │ └─ ← [Return] 0 ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] @@ -2639,3 +2639,29 @@ contract ScrollForkTest is Test { cmd.args(["test", "--mt", "test_roll_scroll_fork_to_tx", "--evm-version", "cancun"]) .assert_success(); }); + +// Test that only provider is included in failed fork error. +forgetest_init!(test_display_provider_on_error, |prj, cmd| { + prj.add_test( + "ForkTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract ForkTest is Test { + function test_fork_err_message() public { + vm.createSelectFork("https://eth-mainnet.g.alchemy.com/v2/DUMMY_KEY"); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "test_fork_err_message"]).assert_failure().stdout_eq(str![[r#" +... +Ran 1 test for test/ForkTest.t.sol:ForkTest +[FAIL: vm.createSelectFork: Could not instantiate forked environment with provider eth-mainnet.g.alchemy.com;] test_fork_err_message() ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +... + +"#]]); +}); diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 44deda60cddf4..ba27f381cb102 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -2,11 +2,19 @@ use foundry_config::{NamedChain, NamedChain::Optimism}; use rand::seq::SliceRandom; -use std::sync::{ - atomic::{AtomicUsize, Ordering}, - LazyLock, +use std::{ + env, + sync::{ + atomic::{AtomicUsize, Ordering}, + LazyLock, + }, }; +/// Env var key for ws archive endpoints. +const ENV_WS_ARCHIVE_ENDPOINTS: &str = "WS_ARCHIVE_URLS"; +/// Env var key for http archive endpoints. +const ENV_HTTP_ARCHIVE_ENDPOINTS: &str = "HTTP_ARCHIVE_URLS"; + // List of general purpose infura keys to rotate through static INFURA_KEYS: LazyLock> = LazyLock::new(|| { let mut keys = vec![ @@ -118,14 +126,30 @@ pub fn next_ws_endpoint(chain: NamedChain) -> String { /// Returns endpoint that has access to archive state pub fn next_http_archive_rpc_endpoint() -> String { - let idx = next() % ALCHEMY_KEYS.len(); - format!("https://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) + next_archive_endpoint(false) } /// Returns endpoint that has access to archive state pub fn next_ws_archive_rpc_endpoint() -> String { - let idx = next() % ALCHEMY_KEYS.len(); - format!("wss://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) + next_archive_endpoint(true) +} + +/// Returns endpoint that has access to archive state, http or ws. +/// Use env vars (comma separated urls) or default inline keys (Alchemy for ws, Infura for http). +fn next_archive_endpoint(is_ws: bool) -> String { + let env_urls = if is_ws { ENV_WS_ARCHIVE_ENDPOINTS } else { ENV_HTTP_ARCHIVE_ENDPOINTS }; + + let rpc_env_vars = env::var(env_urls).unwrap_or_default(); + if !rpc_env_vars.is_empty() { + let urls = rpc_env_vars.split(',').collect::>(); + urls.choose(&mut rand::thread_rng()).unwrap().to_string() + } else if is_ws { + let idx = next() % ALCHEMY_KEYS.len(); + format!("wss://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) + } else { + let idx = next() % INFURA_KEYS.len(); + format!("https://mainnet.infura.io/v3/{}", INFURA_KEYS[idx]) + } } /// Returns the next etherscan api key From 4648d5c77f2ca8ee646464836f08be48b5072df6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:46:45 +0200 Subject: [PATCH 1694/1963] chore: pick provider urls by next index (#9359) --- crates/test-utils/src/rpc.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index ba27f381cb102..0934ea1797018 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -142,7 +142,8 @@ fn next_archive_endpoint(is_ws: bool) -> String { let rpc_env_vars = env::var(env_urls).unwrap_or_default(); if !rpc_env_vars.is_empty() { let urls = rpc_env_vars.split(',').collect::>(); - urls.choose(&mut rand::thread_rng()).unwrap().to_string() + let idx = next() % urls.len(); + urls[idx].to_string() } else if is_ws { let idx = next() % ALCHEMY_KEYS.len(); format!("wss://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) From d20c142d0655490122e79fb66aa119df3638bad6 Mon Sep 17 00:00:00 2001 From: Dmitry <98899785+mdqst@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:57:17 +0300 Subject: [PATCH 1695/1963] fix: correct shell substitution in installer (#9351) Fix typographical error in default value assignment for FOUNDRY_DIR --- foundryup/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundryup/install b/foundryup/install index da8156a09fe3f..1a8bc8c6ed5ad 100755 --- a/foundryup/install +++ b/foundryup/install @@ -4,7 +4,7 @@ set -eo pipefail echo "Installing foundryup..." BASE_DIR="${XDG_CONFIG_HOME:-$HOME}" -FOUNDRY_DIR="${FOUNDRY_DIR-"$BASE_DIR/.foundry"}" +FOUNDRY_DIR="${FOUNDRY_DIR:-"$BASE_DIR/.foundry"}" FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin" FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1" From e5776932e865c28acf002371e6fce8d95017b0a1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:39:20 +0100 Subject: [PATCH 1696/1963] chore: TestSetup cleanup (#9355) Co-authored-by: Matthias Seitz --- crates/evm/coverage/src/lib.rs | 8 ++ crates/evm/evm/src/executors/fuzz/mod.rs | 6 +- crates/evm/evm/src/executors/invariant/mod.rs | 5 +- .../evm/evm/src/executors/invariant/replay.rs | 10 +- crates/evm/evm/src/executors/mod.rs | 23 ++++ crates/forge/src/result.rs | 110 ++++++------------ crates/forge/src/runner.rs | 98 ++++++---------- 7 files changed, 103 insertions(+), 157 deletions(-) diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 7ac6091232773..ad4ab53e3cf13 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -174,6 +174,14 @@ impl CoverageReport { pub struct HitMaps(pub HashMap); impl HitMaps { + pub fn merge_opt(a: &mut Option, b: Option) { + match (a, b) { + (_, None) => {} + (a @ None, Some(b)) => *a = Some(b), + (Some(a), Some(b)) => a.merge(b), + } + } + pub fn merge(&mut self, other: Self) { for (code_hash, hit_map) in other.0 { if let Some(HitMap { hits: extra_hits, .. }) = self.insert(code_hash, hit_map) { diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 982e44ea9d6a2..2bbe80a63eadb 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -127,11 +127,7 @@ impl FuzzedExecutor { data.logs.extend(case.logs); } - // Collect and merge coverage if `forge snapshot` context. - match &mut data.coverage { - Some(prev) => prev.merge(case.coverage.unwrap()), - opt => *opt = case.coverage, - } + HitMaps::merge_opt(&mut data.coverage, case.coverage); data.deprecated_cheatcodes = case.deprecated_cheatcodes; diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 860acdbb26d0c..f98dd21114cbb 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -204,10 +204,7 @@ impl InvariantTest { /// Merge current collected coverage with the new coverage from last fuzzed call. pub fn merge_coverage(&self, new_coverage: Option) { - match &mut self.execution_data.borrow_mut().coverage { - Some(prev) => prev.merge(new_coverage.unwrap()), - opt => *opt = new_coverage, - } + HitMaps::merge_opt(&mut self.execution_data.borrow_mut().coverage, new_coverage); } /// Update metrics for a fuzzed selector, extracted from tx details. diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 969f1587f27e2..36192a6d69142 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -48,16 +48,10 @@ pub fn replay_run( tx.call_details.calldata.clone(), U256::ZERO, )?; + logs.extend(call_result.logs); traces.push((TraceKind::Execution, call_result.traces.clone().unwrap())); - - if let Some(new_coverage) = call_result.coverage { - if let Some(old_coverage) = coverage { - *coverage = Some(std::mem::take(old_coverage).merged(new_coverage)); - } else { - *coverage = Some(new_coverage); - } - } + HitMaps::merge_opt(coverage, call_result.coverage); // Identify newly generated contracts, if they exist. ided_contracts diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 723b520aa1b71..6f458258a5eac 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -713,6 +713,12 @@ impl std::ops::DerefMut for DeployResult { } } +impl From for RawCallResult { + fn from(d: DeployResult) -> Self { + d.raw + } +} + /// The result of a raw call. #[derive(Debug)] pub struct RawCallResult { @@ -780,6 +786,23 @@ impl Default for RawCallResult { } impl RawCallResult { + /// Unpacks an EVM result. + pub fn from_evm_result(r: Result) -> eyre::Result<(Self, Option)> { + match r { + Ok(r) => Ok((r, None)), + Err(EvmError::Execution(e)) => Ok((e.raw, Some(e.reason))), + Err(e) => Err(e.into()), + } + } + + /// Unpacks an execution result. + pub fn from_execution_result(r: Result) -> (Self, Option) { + match r { + Ok(r) => (r, None), + Err(e) => (e.raw, Some(e.reason)), + } + } + /// Converts the result of the call into an `EvmError`. pub fn into_evm_error(self, rd: Option<&RevertDecoder>) -> EvmError { if let Some(reason) = SkipReason::decode(&self.result) { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 60c07472eac0b..7f02db577c0de 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -13,7 +13,7 @@ use foundry_common::{evm::Breakpoints, get_contract_name, get_file_name, shell}; use foundry_evm::{ coverage::HitMaps, decode::SkipReason, - executors::{invariant::InvariantMetrics, EvmError, RawCallResult}, + executors::{invariant::InvariantMetrics, RawCallResult}, fuzz::{CounterExample, FuzzCase, FuzzFixtures, FuzzTestResult}, traces::{CallTraceArena, CallTraceDecoder, TraceKind, Traces}, }; @@ -469,7 +469,7 @@ impl TestResult { /// Creates a new test result starting from test setup results. pub fn new(setup: TestSetup) -> Self { Self { - labeled_addresses: setup.labeled_addresses, + labeled_addresses: setup.labels, logs: setup.logs, traces: setup.traces, coverage: setup.coverage, @@ -490,7 +490,7 @@ impl TestResult { logs: setup.logs, traces: setup.traces, coverage: setup.coverage, - labeled_addresses: setup.labeled_addresses, + labeled_addresses: setup.labels, ..Default::default() } } @@ -651,21 +651,17 @@ impl TestResult { format!("{self} {name} {}", self.kind.report()) } - /// Function to merge logs, addresses, traces and coverage from a call result into test result. - pub fn merge_call_result(&mut self, call_result: &RawCallResult) { - self.logs.extend(call_result.logs.clone()); - self.labeled_addresses.extend(call_result.labels.clone()); - self.traces.extend(call_result.traces.clone().map(|traces| (TraceKind::Execution, traces))); - self.merge_coverages(call_result.coverage.clone()); + /// Merges the given raw call result into `self`. + pub fn extend(&mut self, call_result: RawCallResult) { + self.logs.extend(call_result.logs); + self.labeled_addresses.extend(call_result.labels); + self.traces.extend(call_result.traces.map(|traces| (TraceKind::Execution, traces))); + self.merge_coverages(call_result.coverage); } - /// Function to merge given coverage in current test result coverage. + /// Merges the given coverage result into `self`. pub fn merge_coverages(&mut self, other_coverage: Option) { - let old_coverage = std::mem::take(&mut self.coverage); - self.coverage = match (old_coverage, other_coverage) { - (Some(old_coverage), Some(other)) => Some(old_coverage.merged(other)), - (a, b) => a.or(b), - }; + HitMaps::merge_opt(&mut self.coverage, other_coverage); } } @@ -747,77 +743,39 @@ impl TestKind { } } +/// The result of a test setup. +/// +/// Includes the deployment of the required libraries and the test contract itself, and the call to +/// the `setUp()` function. #[derive(Clone, Debug, Default)] pub struct TestSetup { - /// The address at which the test contract was deployed + /// The address at which the test contract was deployed. pub address: Address, - /// The logs emitted during setup + /// Defined fuzz test fixtures. + pub fuzz_fixtures: FuzzFixtures, + + /// The logs emitted during setup. pub logs: Vec, - /// Call traces of the setup + /// Addresses labeled during setup. + pub labels: AddressHashMap, + /// Call traces of the setup. pub traces: Traces, - /// Addresses labeled during setup - pub labeled_addresses: AddressHashMap, - /// The reason the setup failed, if it did - pub reason: Option, - /// Coverage info during setup + /// Coverage info during setup. pub coverage: Option, - /// Defined fuzz test fixtures - pub fuzz_fixtures: FuzzFixtures, + + /// The reason the setup failed, if it did. + pub reason: Option, } impl TestSetup { - pub fn from_evm_error_with( - error: EvmError, - mut logs: Vec, - mut traces: Traces, - mut labeled_addresses: AddressHashMap, - ) -> Self { - match error { - EvmError::Execution(err) => { - // force the tracekind to be setup so a trace is shown. - traces.extend(err.raw.traces.map(|traces| (TraceKind::Setup, traces))); - logs.extend(err.raw.logs); - labeled_addresses.extend(err.raw.labels); - Self::failed_with(logs, traces, labeled_addresses, err.reason) - } - e => Self::failed_with( - logs, - traces, - labeled_addresses, - format!("failed to deploy contract: {e}"), - ), - } - } - - pub fn success( - address: Address, - logs: Vec, - traces: Traces, - labeled_addresses: AddressHashMap, - coverage: Option, - fuzz_fixtures: FuzzFixtures, - ) -> Self { - Self { address, logs, traces, labeled_addresses, reason: None, coverage, fuzz_fixtures } - } - - pub fn failed_with( - logs: Vec, - traces: Traces, - labeled_addresses: AddressHashMap, - reason: String, - ) -> Self { - Self { - address: Address::ZERO, - logs, - traces, - labeled_addresses, - reason: Some(reason), - coverage: None, - fuzz_fixtures: FuzzFixtures::default(), - } - } - pub fn failed(reason: String) -> Self { Self { reason: Some(reason), ..Default::default() } } + + pub fn extend(&mut self, raw: RawCallResult, trace_kind: TraceKind) { + self.logs.extend(raw.logs); + self.labels.extend(raw.labels); + self.traces.extend(raw.traces.map(|traces| (trace_kind, traces))); + HitMaps::merge_opt(&mut self.coverage, raw.coverage); + } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 1302c39ad1f57..4b66a482c27cd 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -24,7 +24,7 @@ use foundry_evm::{ invariant::{ check_sequence, replay_error, replay_run, InvariantExecutor, InvariantFuzzError, }, - CallResult, EvmError, ExecutionErr, Executor, ITest, RawCallResult, + CallResult, EvmError, Executor, ITest, RawCallResult, }, fuzz::{ fixture_name, @@ -88,53 +88,51 @@ impl ContractRunner<'_> { self.executor.set_balance(self.sender, U256::MAX)?; self.executor.set_balance(CALLER, U256::MAX)?; - // We set the nonce of the deployer accounts to 1 to get the same addresses as DappTools + // We set the nonce of the deployer accounts to 1 to get the same addresses as DappTools. self.executor.set_nonce(self.sender, 1)?; - // Deploy libraries + // Deploy libraries. self.executor.set_balance(LIBRARY_DEPLOYER, U256::MAX)?; - let mut logs = Vec::new(); - let mut traces = Vec::with_capacity(self.libs_to_deploy.len()); + let mut result = TestSetup::default(); for code in self.libs_to_deploy.iter() { - match self.executor.deploy( + let deploy_result = self.executor.deploy( LIBRARY_DEPLOYER, code.clone(), U256::ZERO, Some(self.revert_decoder), - ) { - Ok(d) => { - logs.extend(d.raw.logs); - traces.extend(d.raw.traces.map(|traces| (TraceKind::Deployment, traces))); - } - Err(e) => { - return Ok(TestSetup::from_evm_error_with(e, logs, traces, Default::default())) - } + ); + let (raw, reason) = RawCallResult::from_evm_result(deploy_result.map(Into::into))?; + result.extend(raw, TraceKind::Deployment); + if reason.is_some() { + result.reason = reason; + return Ok(result); } } let address = self.sender.create(self.executor.get_nonce(self.sender)?); + result.address = address; // Set the contracts initial balance before deployment, so it is available during // construction self.executor.set_balance(address, self.initial_balance)?; // Deploy the test contract - match self.executor.deploy( + let deploy_result = self.executor.deploy( self.sender, self.contract.bytecode.clone(), U256::ZERO, Some(self.revert_decoder), - ) { - Ok(d) => { - logs.extend(d.raw.logs); - traces.extend(d.raw.traces.map(|traces| (TraceKind::Deployment, traces))); - d.address - } - Err(e) => { - return Ok(TestSetup::from_evm_error_with(e, logs, traces, Default::default())) - } - }; + ); + if let Ok(dr) = &deploy_result { + debug_assert_eq!(dr.address, address); + } + let (raw, reason) = RawCallResult::from_evm_result(deploy_result.map(Into::into))?; + result.extend(raw, TraceKind::Deployment); + if reason.is_some() { + result.reason = reason; + return Ok(result); + } // Reset `self.sender`s, `CALLER`s and `LIBRARY_DEPLOYER`'s balance to the initial balance. self.executor.set_balance(self.sender, self.initial_balance)?; @@ -144,45 +142,15 @@ impl ContractRunner<'_> { self.executor.deploy_create2_deployer()?; // Optionally call the `setUp` function - let result = if call_setup { + if call_setup { trace!("calling setUp"); let res = self.executor.setup(None, address, Some(self.revert_decoder)); - let (setup_logs, setup_traces, labeled_addresses, reason, coverage) = match res { - Ok(RawCallResult { traces, labels, logs, coverage, .. }) => { - trace!(%address, "successfully called setUp"); - (logs, traces, labels, None, coverage) - } - Err(EvmError::Execution(err)) => { - let ExecutionErr { - raw: RawCallResult { traces, labels, logs, coverage, .. }, - reason, - } = *err; - (logs, traces, labels, Some(reason), coverage) - } - Err(err) => (Vec::new(), None, HashMap::default(), Some(err.to_string()), None), - }; - traces.extend(setup_traces.map(|traces| (TraceKind::Setup, traces))); - logs.extend(setup_logs); - - TestSetup { - address, - logs, - traces, - labeled_addresses, - reason, - coverage, - fuzz_fixtures: self.fuzz_fixtures(address), - } - } else { - TestSetup::success( - address, - logs, - traces, - Default::default(), - None, - self.fuzz_fixtures(address), - ) - }; + let (raw, reason) = RawCallResult::from_evm_result(res)?; + result.extend(raw, TraceKind::Setup); + result.reason = reason; + } + + result.fuzz_fixtures = self.fuzz_fixtures(address); Ok(result) } @@ -698,11 +666,13 @@ impl ContractRunner<'_> { // Apply before test configured calldata. match executor.to_mut().transact_raw(self.sender, address, calldata, U256::ZERO) { Ok(call_result) => { + let reverted = call_result.reverted; + // Merge tx result traces in unit test result. - test_result.merge_call_result(&call_result); + test_result.extend(call_result); // To continue unit test execution the call should not revert. - if call_result.reverted { + if reverted { return Err(test_result.single_fail(None)) } } From 3a954409e350164d6267ed72b8c3fb5a2f0a01c4 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:07:24 +0200 Subject: [PATCH 1697/1963] chore(ci): proper read of archive nodes (#9362) inherit secrets, use alchemy as default for external PRs, comment out infura --- .github/workflows/test.yml | 1 + crates/test-utils/src/rpc.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index acb63a994fec8..d5a2eabb07c0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,7 @@ jobs: uses: ./.github/workflows/nextest.yml with: profile: default + secrets: inherit docs: runs-on: ubuntu-latest diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 0934ea1797018..7bf820a208aa3 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -18,9 +18,9 @@ const ENV_HTTP_ARCHIVE_ENDPOINTS: &str = "HTTP_ARCHIVE_URLS"; // List of general purpose infura keys to rotate through static INFURA_KEYS: LazyLock> = LazyLock::new(|| { let mut keys = vec![ - "6cb19d07ca2d44f59befd61563b1037b", - "6d46c0cca653407b861f3f93f7b0236a", - "69a36846dec146e3a2898429be60be85", + // "6cb19d07ca2d44f59befd61563b1037b", + // "6d46c0cca653407b861f3f93f7b0236a", + // "69a36846dec146e3a2898429be60be85", // "16a8be88795540b9b3903d8de0f7baa5", // "f4a0bdad42674adab5fc0ac077ffab2b", // "5c812e02193c4ba793f8c214317582bd", @@ -39,11 +39,11 @@ static ALCHEMY_KEYS: LazyLock> = LazyLock::new(|| { "GL4M0hfzSYGU5e1_t804HoUDOObWP-FA", "WV407BEiBmjNJfKo9Uo_55u0z0ITyCOX", "Ge56dH9siMF4T0whP99sQXOcr2mFs8wZ", - "QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", - "pwc5rmJhrdoaSEfimoKEmsvOjKSmPDrP", - "A5sZ85MIr4SzCMkT0zXh2eeamGIq3vGL", - "9VWGraLx0tMiSWx05WH-ywgSVmMxs66W", - "U4hsGWgl9lBM1j3jhSgJ4gbjHg2jRwKy", + // "QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", + // "pwc5rmJhrdoaSEfimoKEmsvOjKSmPDrP", + // "A5sZ85MIr4SzCMkT0zXh2eeamGIq3vGL", + // "9VWGraLx0tMiSWx05WH-ywgSVmMxs66W", + // "U4hsGWgl9lBM1j3jhSgJ4gbjHg2jRwKy", "K-uNlqYoYCO9cdBHcifwCDAcEjDy1UHL", "GWdgwabOE2XfBdLp_gIq-q6QHa7DSoag", "Uz0cF5HCXFtpZlvd9NR7kHxfB_Wdpsx7", @@ -148,8 +148,8 @@ fn next_archive_endpoint(is_ws: bool) -> String { let idx = next() % ALCHEMY_KEYS.len(); format!("wss://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) } else { - let idx = next() % INFURA_KEYS.len(); - format!("https://mainnet.infura.io/v3/{}", INFURA_KEYS[idx]) + let idx = next() % ALCHEMY_KEYS.len(); + format!("https://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) } } From 999cc1bf270bc9fd63af05b6dccbbf0743bf5e55 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:30:59 +0100 Subject: [PATCH 1698/1963] chore(test-utils): simplify next calls (#9361) Co-authored-by: grandizzy --- crates/test-utils/src/rpc.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 7bf820a208aa3..361bf56c2706e 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -91,13 +91,14 @@ static ETHERSCAN_OPTIMISM_KEYS: LazyLock> = LazyLock::new(|| vec!["JQNGFHINKS1W7Y5FRXU4SPBYF43J3NYK46"]); /// Returns the next index to use. -fn next() -> usize { +fn next_idx() -> usize { static NEXT_INDEX: AtomicUsize = AtomicUsize::new(0); NEXT_INDEX.fetch_add(1, Ordering::SeqCst) } -fn num_keys() -> usize { - INFURA_KEYS.len() + ALCHEMY_KEYS.len() +/// Returns the next item in the list to use. +fn next(list: &[T]) -> &T { + &list[next_idx() % list.len()] } /// Returns the next _mainnet_ rpc endpoint in inline @@ -142,21 +143,17 @@ fn next_archive_endpoint(is_ws: bool) -> String { let rpc_env_vars = env::var(env_urls).unwrap_or_default(); if !rpc_env_vars.is_empty() { let urls = rpc_env_vars.split(',').collect::>(); - let idx = next() % urls.len(); - urls[idx].to_string() + next(&urls).to_string() } else if is_ws { - let idx = next() % ALCHEMY_KEYS.len(); - format!("wss://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) + format!("wss://eth-mainnet.g.alchemy.com/v2/{}", next(&ALCHEMY_KEYS)) } else { - let idx = next() % ALCHEMY_KEYS.len(); - format!("https://eth-mainnet.g.alchemy.com/v2/{}", ALCHEMY_KEYS[idx]) + format!("https://eth-mainnet.g.alchemy.com/v2/{}", next(&ALCHEMY_KEYS)) } } /// Returns the next etherscan api key pub fn next_mainnet_etherscan_api_key() -> String { - let idx = next() % ETHERSCAN_MAINNET_KEYS.len(); - ETHERSCAN_MAINNET_KEYS[idx].to_string() + next_etherscan_api_key(NamedChain::Mainnet) } /// Returns the next etherscan api key for given chain. @@ -165,8 +162,7 @@ pub fn next_etherscan_api_key(chain: NamedChain) -> String { Optimism => ÐERSCAN_OPTIMISM_KEYS, _ => ÐERSCAN_MAINNET_KEYS, }; - let idx = next() % keys.len(); - keys[idx].to_string() + next(keys).to_string() } fn next_url(is_ws: bool, chain: NamedChain) -> String { @@ -176,7 +172,7 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { return "https://mainnet.base.org".to_string(); } - let idx = next() % num_keys(); + let idx = next_idx() % (INFURA_KEYS.len() + ALCHEMY_KEYS.len()); let is_infura = idx < INFURA_KEYS.len(); let key = if is_infura { INFURA_KEYS[idx] } else { ALCHEMY_KEYS[idx - INFURA_KEYS.len()] }; From 2a194bd75a5d2477c3e8236dcdea64f4508e32ed Mon Sep 17 00:00:00 2001 From: Evan Chipman <42247026+evchip@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:49:10 +0700 Subject: [PATCH 1699/1963] Support EIP-7702 Delegations in Forge (#9236) * add EIP-7702 cheatcodes: createDelegation, signDelegation, attachDelegation * add cheatcode implementations for EIP-7702: createDelegationCall, signDelegationCall, attachDelegationCall; modify broadcast to check if sender has a delegation * add delegations hashmap to Cheatcodes struct * add revm crate * create AttachDelegationTest for EIP-7702 transactions * regen cheatcodes.json * cargo fmt * move broadcast under attachDelegation * combine createDelegationCall logic with signDelegationCall in order to create and sign delegation in a single call; remove delegation logic from broadcast() - no need to track delegations here * remove revm import from workspace * combine createDelegation logic inton signDelegation for simplicity * remove revm from forge script deps * combine createDelegation with signDelegation * WIP - refactor test to use SimpleDelegateContract and ERC20 - test currently failing bc 7702 implementation.execute not executed as Alice EOA * add logic to include authorization_list for EIP 7702 in TransactionRequest by searching delegations hash map by active_delegation * add address authority param to attachDelegation; remove nonce param from signDelegation, as it can be constructed in cheatcode. * remove 7702 tx request construction logic - now handled in attachDelegation cheatcode implementation * refactor attachDelegation cheatcode implementation to handle verifying signature and setting bytecode on EOA; refactor signDelegation cheatcode implementation to get nonce from signer * remove nonce param from attachDelegation cheatcode in favor of loading from authority account * refactor test to check for code on alice account and call execute on alice account through SimpleDelegateContract * revert refactor on TransactionRequest * format * cargo fmt * fix clippy errors * remove faulty logic comparing nonce to itself - nonce still checked by recovered signature * add more tests to cover revert cases on attachDelegation and multiple calls via delegation contract * cargo fmt * restore logic to check if there's an active delegation when building TransactionRequest; add fixed values for gas and max_priority_fee_per_gas to ensure tx success, with TODO comment to explain what's left * remove obsolete comment * add comments explaining delegations and active_delegation * cargo fmt * add logic to increase gas limit by PER_EMPTY_ACCOUNT_COST(25k) if tx includes authorization list for EIP 7702 tx, which is seemingly not accounted for in gas estimation; remove hardcoded gas values from call_with_executor * revert logic to add PER_EMPTY_ACCOUNT_COST for EIP 7702 txs - handled inside of revm now * remove manually setting transaction type to 4 if auth list is present - handled in revm * add method set_delegation to Executor for setting EIP-7702 authorization list in the transaction environment; call set_delegation from simulate_and_fill if auth list is not empty * remove redundancy with TransactionMaybeSigned var tx * cargo fmt * refactor: use authorization_list() helper to return authorization_list and set delegation * refactor: change Cheatcodes::active_delegation to Option and remove delegations hashmap - tx will only use one active delegation at a time, so no need for mapping * replace verbose logic to set bytecode on EOA with journaled_state.set_code helper * cargo fmt * increment nonce of authority account * add logic to set authorization_list to None if active_delegation is None * add test testSwitchDelegation to assert that attaching an additional delegation switches the implementation on the EOA * remove set_delegation logic in favor of adding call_raw_with_authorization - previous approach kept the delegation in the TxEnv, resulting in higher gas cost for all subsequent calls after the delegation was applied * refactor signDelegation to return struct SignedDelegation and for attachDelegation to accept SignedDelegation * update delegation tests to reflect change in cheatcode interface for signDelegation and attachDelegation * add cheatcode signAndAttachDelegation * add signAndAttachDelegationCall cheatcode logic; refactor helper methods for shared logic used in 7702 delegation cheatcodes * add test testCallSingleSignAndAttachDelegation for new cheatcode signAndAttachDelegation * add comments to SignedDelegation struct and cargo fmt * cargo fmt * fix ci * fix spec --------- Co-authored-by: Arsenii Kulikov Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- Cargo.lock | 1 + crates/cheatcodes/assets/cheatcodes.json | 91 +++++++++ crates/cheatcodes/spec/src/lib.rs | 1 + crates/cheatcodes/spec/src/vm.rs | 28 +++ crates/cheatcodes/src/inspector.rs | 39 ++-- crates/cheatcodes/src/script.rs | 89 +++++++++ crates/common/Cargo.toml | 1 + crates/common/src/transactions.rs | 9 + crates/evm/evm/src/executors/mod.rs | 19 +- crates/script/src/runner.rs | 26 ++- crates/script/src/simulate.rs | 5 +- testdata/cheats/Vm.sol | 4 + .../default/cheats/AttachDelegation.t.sol | 182 ++++++++++++++++++ 13 files changed, 477 insertions(+), 18 deletions(-) create mode 100644 testdata/default/cheats/AttachDelegation.t.sol diff --git a/Cargo.lock b/Cargo.lock index 144c6e07800cc..6759a6d2fcfd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3701,6 +3701,7 @@ dependencies = [ "alloy-consensus", "alloy-contract", "alloy-dyn-abi", + "alloy-eips", "alloy-json-abi", "alloy-json-rpc", "alloy-primitives", diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 347d738e01ec3..d19c776b99166 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -573,6 +573,37 @@ "description": "Status of the transaction, retrieved from the transaction receipt." } ] + }, + { + "name": "SignedDelegation", + "description": "Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.", + "fields": [ + { + "name": "v", + "ty": "uint8", + "description": "The y-parity of the recovered secp256k1 signature (0 or 1)." + }, + { + "name": "r", + "ty": "bytes32", + "description": "First 32 bytes of the signature." + }, + { + "name": "s", + "ty": "bytes32", + "description": "Second 32 bytes of the signature." + }, + { + "name": "nonce", + "ty": "uint64", + "description": "The current nonce of the authority account at signing time.\n Used to ensure signature can't be replayed after account nonce changes." + }, + { + "name": "implementation", + "ty": "address", + "description": "Address of the contract implementation that will be delegated to.\n Gets encoded into delegation code: 0xef0100 || implementation." + } + ] } ], "cheatcodes": [ @@ -3076,6 +3107,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "attachDelegation", + "description": "Designate the next call as an EIP-7702 transaction", + "declaration": "function attachDelegation(SignedDelegation memory signedDelegation) external;", + "visibility": "external", + "mutability": "", + "signature": "attachDelegation((uint8,bytes32,bytes32,uint64,address))", + "selector": "0x14ae3519", + "selectorBytes": [ + 20, + 174, + 53, + 25 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "blobBaseFee", @@ -8806,6 +8857,26 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "signAndAttachDelegation", + "description": "Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction", + "declaration": "function signAndAttachDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);", + "visibility": "external", + "mutability": "", + "signature": "signAndAttachDelegation(address,uint256)", + "selector": "0xc7fa7288", + "selectorBytes": [ + 199, + 250, + 114, + 136 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "signCompact_0", @@ -8886,6 +8957,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "signDelegation", + "description": "Sign an EIP-7702 authorization for delegation", + "declaration": "function signDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation);", + "visibility": "external", + "mutability": "", + "signature": "signDelegation(address,uint256)", + "selector": "0x5b593c7b", + "selectorBytes": [ + 91, + 89, + 60, + 123 + ] + }, + "group": "scripting", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "signP256", diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index 5692dfc48b9cd..c4d7e9868fe13 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -87,6 +87,7 @@ impl Cheatcodes<'static> { Vm::Gas::STRUCT.clone(), Vm::DebugStep::STRUCT.clone(), Vm::BroadcastTxSummary::STRUCT.clone(), + Vm::SignedDelegation::STRUCT.clone(), ]), enums: Cow::Owned(vec![ Vm::CallerMode::ENUM.clone(), diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index d703f48e7ae54..bf0fe9781f8ae 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -308,6 +308,22 @@ interface Vm { bool success; } + /// Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation. + struct SignedDelegation { + /// The y-parity of the recovered secp256k1 signature (0 or 1). + uint8 v; + /// First 32 bytes of the signature. + bytes32 r; + /// Second 32 bytes of the signature. + bytes32 s; + /// The current nonce of the authority account at signing time. + /// Used to ensure signature can't be replayed after account nonce changes. + uint64 nonce; + /// Address of the contract implementation that will be delegated to. + /// Gets encoded into delegation code: 0xef0100 || implementation. + address implementation; + } + // ======== EVM ======== /// Gets the address for a given private key. @@ -2018,6 +2034,18 @@ interface Vm { #[cheatcode(group = Scripting)] function broadcastRawTransaction(bytes calldata data) external; + /// Sign an EIP-7702 authorization for delegation + #[cheatcode(group = Scripting)] + function signDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation); + + /// Designate the next call as an EIP-7702 transaction + #[cheatcode(group = Scripting)] + function attachDelegation(SignedDelegation memory signedDelegation) external; + + /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction + #[cheatcode(group = Scripting)] + function signAndAttachDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation); + /// Returns addresses of available unlocked wallets in the script environment. #[cheatcode(group = Scripting)] function getWallets() external returns (address[] memory wallets); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 046a495a10e86..6f3acb58c2735 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -46,7 +46,10 @@ use revm::{ EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, }, - primitives::{BlockEnv, CreateScheme, EVMError, EvmStorageSlot, SpecId, EOF_MAGIC_BYTES}, + primitives::{ + BlockEnv, CreateScheme, EVMError, EvmStorageSlot, SignedAuthorization, SpecId, + EOF_MAGIC_BYTES, + }, EvmContext, InnerEvmContext, Inspector, }; use serde_json::Value; @@ -373,6 +376,11 @@ pub struct Cheatcodes { /// execution block environment. pub block: Option, + /// Currently active EIP-7702 delegation that will be consumed when building the next + /// transaction. Set by `vm.attachDelegation()` and consumed via `.take()` during + /// transaction construction. + pub active_delegation: Option, + /// The gas price. /// /// Used in the cheatcode handler to overwrite the gas price separately from the gas price @@ -497,6 +505,7 @@ impl Cheatcodes { labels: config.labels.clone(), config, block: Default::default(), + active_delegation: Default::default(), gas_price: Default::default(), prank: Default::default(), expected_revert: Default::default(), @@ -1014,18 +1023,26 @@ where { let account = ecx.journaled_state.state().get_mut(&broadcast.new_origin).unwrap(); + let mut tx_req = TransactionRequest { + from: Some(broadcast.new_origin), + to: Some(TxKind::from(Some(call.target_address))), + value: call.transfer_value(), + input: TransactionInput::new(call.input.clone()), + nonce: Some(account.info.nonce), + chain_id: Some(ecx.env.cfg.chain_id), + gas: if is_fixed_gas_limit { Some(call.gas_limit) } else { None }, + ..Default::default() + }; + + if let Some(auth_list) = self.active_delegation.take() { + tx_req.authorization_list = Some(vec![auth_list]); + } else { + tx_req.authorization_list = None; + } + self.broadcastable_transactions.push_back(BroadcastableTransaction { rpc: ecx.db.active_fork_url(), - transaction: TransactionRequest { - from: Some(broadcast.new_origin), - to: Some(TxKind::from(Some(call.target_address))), - value: call.transfer_value(), - input: TransactionInput::new(call.input.clone()), - nonce: Some(account.info.nonce), - gas: if is_fixed_gas_limit { Some(call.gas_limit) } else { None }, - ..Default::default() - } - .into(), + transaction: tx_req.into(), }); debug!(target: "cheatcodes", tx=?self.broadcastable_transactions.back().unwrap(), "broadcastable call"); diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 29a804efd7ec5..3e1239237e83f 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -2,10 +2,13 @@ use crate::{Cheatcode, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{Address, B256, U256}; +use alloy_rpc_types::Authorization; +use alloy_signer::{Signature, SignerSync}; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::SolValue; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; use parking_lot::Mutex; +use revm::primitives::{Bytecode, SignedAuthorization}; use std::sync::Arc; impl Cheatcode for broadcast_0Call { @@ -29,6 +32,92 @@ impl Cheatcode for broadcast_2Call { } } +impl Cheatcode for attachDelegationCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { signedDelegation } = self; + let SignedDelegation { v, r, s, nonce, implementation } = signedDelegation; + + let auth = Authorization { + address: *implementation, + nonce: *nonce, + chain_id: ccx.ecx.env.cfg.chain_id, + }; + let signed_auth = SignedAuthorization::new_unchecked( + auth, + *v, + U256::from_be_bytes(r.0), + U256::from_be_bytes(s.0), + ); + write_delegation(ccx, signed_auth.clone())?; + ccx.state.active_delegation = Some(signed_auth); + Ok(Default::default()) + } +} + +impl Cheatcode for signDelegationCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { implementation, privateKey } = self; + let signer = PrivateKeySigner::from_bytes(&B256::from(*privateKey))?; + let authority = signer.address(); + let (auth, nonce) = create_auth(ccx, *implementation, authority)?; + let sig = signer.sign_hash_sync(&auth.signature_hash())?; + Ok(sig_to_delegation(sig, nonce, *implementation).abi_encode()) + } +} + +impl Cheatcode for signAndAttachDelegationCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { implementation, privateKey } = self; + let signer = PrivateKeySigner::from_bytes(&B256::from(*privateKey))?; + let authority = signer.address(); + let (auth, nonce) = create_auth(ccx, *implementation, authority)?; + let sig = signer.sign_hash_sync(&auth.signature_hash())?; + let signed_auth = sig_to_auth(sig, auth); + write_delegation(ccx, signed_auth.clone())?; + ccx.state.active_delegation = Some(signed_auth); + Ok(sig_to_delegation(sig, nonce, *implementation).abi_encode()) + } +} + +fn create_auth( + ccx: &mut CheatsCtxt, + implementation: Address, + authority: Address, +) -> Result<(Authorization, u64)> { + let authority_acc = ccx.ecx.journaled_state.load_account(authority, &mut ccx.ecx.db)?; + let nonce = authority_acc.data.info.nonce; + Ok(( + Authorization { address: implementation, nonce, chain_id: ccx.ecx.env.cfg.chain_id }, + nonce, + )) +} + +fn write_delegation(ccx: &mut CheatsCtxt, auth: SignedAuthorization) -> Result<()> { + let authority = auth.recover_authority().map_err(|e| format!("{e}"))?; + let authority_acc = ccx.ecx.journaled_state.load_account(authority, &mut ccx.ecx.db)?; + if authority_acc.data.info.nonce != auth.nonce { + return Err("invalid nonce".into()); + } + authority_acc.data.info.nonce += 1; + let bytecode = Bytecode::new_eip7702(*auth.address()); + ccx.ecx.journaled_state.set_code(authority, bytecode); + Ok(()) +} + +fn sig_to_delegation(sig: Signature, nonce: u64, implementation: Address) -> SignedDelegation { + SignedDelegation { + v: sig.v().y_parity() as u8, + r: sig.r().into(), + s: sig.s().into(), + nonce, + implementation, + } +} + +fn sig_to_auth(sig: Signature, auth: Authorization) -> SignedAuthorization { + SignedAuthorization::new_unchecked(auth, sig.v().y_parity() as u8, sig.r(), sig.s()) +} + impl Cheatcode for startBroadcast_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 033c53e49dba9..585e0080cc878 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -20,6 +20,7 @@ foundry-config.workspace = true alloy-contract.workspace = true alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] } +alloy-eips.workspace = true alloy-json-abi.workspace = true alloy-json-rpc.workspace = true alloy-primitives = { workspace = true, features = [ diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 4ddef26dd03f9..f0ed0b54f8bda 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -1,6 +1,7 @@ //! Wrappers for transactions. use alloy_consensus::{Transaction, TxEnvelope}; +use alloy_eips::eip7702::SignedAuthorization; use alloy_primitives::{Address, TxKind, U256}; use alloy_provider::{ network::{AnyNetwork, ReceiptResponse, TransactionBuilder}, @@ -226,6 +227,14 @@ impl TransactionMaybeSigned { Self::Unsigned(tx) => tx.nonce, } } + + pub fn authorization_list(&self) -> Option> { + match self { + Self::Signed { tx, .. } => tx.authorization_list().map(|auths| auths.to_vec()), + Self::Unsigned(tx) => tx.authorization_list.as_deref().map(|auths| auths.to_vec()), + } + .filter(|auths| !auths.is_empty()) + } } impl From for TransactionMaybeSigned { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 6f458258a5eac..b5b31b812298b 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -31,8 +31,8 @@ use revm::{ db::{DatabaseCommit, DatabaseRef}, interpreter::{return_ok, InstructionResult}, primitives::{ - BlockEnv, Bytecode, Env, EnvWithHandlerCfg, ExecutionResult, Output, ResultAndState, - SpecId, TxEnv, TxKind, + AuthorizationList, BlockEnv, Bytecode, Env, EnvWithHandlerCfg, ExecutionResult, Output, + ResultAndState, SignedAuthorization, SpecId, TxEnv, TxKind, }, }; use std::borrow::Cow; @@ -378,6 +378,21 @@ impl Executor { self.call_with_env(env) } + /// Performs a raw call to an account on the current state of the VM with an EIP-7702 + /// authorization list. + pub fn call_raw_with_authorization( + &mut self, + from: Address, + to: Address, + calldata: Bytes, + value: U256, + authorization_list: Vec, + ) -> eyre::Result { + let mut env = self.build_test_env(from, to.into(), calldata, value); + env.tx.authorization_list = Some(AuthorizationList::Signed(authorization_list)); + self.call_with_env(env) + } + /// Performs a raw call to an account on the current state of the VM. pub fn transact_raw( &mut self, diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index a7d950690b92d..fa8ff19d9a9dc 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -1,5 +1,6 @@ use super::ScriptResult; use crate::build::ScriptPredeployLibraries; +use alloy_eips::eip7702::SignedAuthorization; use alloy_primitives::{Address, Bytes, TxKind, U256}; use alloy_rpc_types::TransactionRequest; use eyre::Result; @@ -223,7 +224,7 @@ impl ScriptRunner { /// Executes the method that will collect all broadcastable transactions. pub fn script(&mut self, address: Address, calldata: Bytes) -> Result { - self.call(self.evm_opts.sender, address, calldata, U256::ZERO, false) + self.call(self.evm_opts.sender, address, calldata, U256::ZERO, None, false) } /// Runs a broadcastable transaction locally and persists its state. @@ -233,9 +234,17 @@ impl ScriptRunner { to: Option
, calldata: Option, value: Option, + authorization_list: Option>, ) -> Result { if let Some(to) = to { - self.call(from, to, calldata.unwrap_or_default(), value.unwrap_or(U256::ZERO), true) + self.call( + from, + to, + calldata.unwrap_or_default(), + value.unwrap_or(U256::ZERO), + authorization_list, + true, + ) } else if to.is_none() { let res = self.executor.deploy( from, @@ -282,9 +291,20 @@ impl ScriptRunner { to: Address, calldata: Bytes, value: U256, + authorization_list: Option>, commit: bool, ) -> Result { - let mut res = self.executor.call_raw(from, to, calldata.clone(), value)?; + let mut res = if let Some(authorization_list) = authorization_list { + self.executor.call_raw_with_authorization( + from, + to, + calldata.clone(), + value, + authorization_list, + )? + } else { + self.executor.call_raw(from, to, calldata.clone(), value)? + }; let mut gas_used = res.gas_used; // We should only need to calculate realistic gas costs when preparing to broadcast diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index a9798c43e4714..95427225f2026 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -112,10 +112,10 @@ impl PreSimulationState { // Executes all transactions from the different forks concurrently. let futs = transactions .into_iter() - .map(|transaction| async { + .map(|mut transaction| async { let mut runner = runners.get(&transaction.rpc).expect("invalid rpc url").write(); + let tx = transaction.tx_mut(); - let tx = transaction.tx(); let to = if let Some(TxKind::Call(to)) = tx.to() { Some(to) } else { None }; let result = runner .simulate( @@ -124,6 +124,7 @@ impl PreSimulationState { to, tx.input().map(Bytes::copy_from_slice), tx.value(), + tx.authorization_list(), ) .wrap_err("Internal EVM error during simulation")?; diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 2004c44563d01..9d1d3efd14208 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -23,6 +23,7 @@ interface Vm { 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; } + struct SignedDelegation { uint8 v; bytes32 r; bytes32 s; uint64 nonce; address implementation; } function _expectCheatcodeRevert() external; function _expectCheatcodeRevert(bytes4 revertData) external; function _expectCheatcodeRevert(bytes calldata revertData) external; @@ -148,6 +149,7 @@ interface Vm { function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; function assumeNoRevert() external pure; + function attachDelegation(SignedDelegation memory signedDelegation) external; function blobBaseFee(uint256 newBlobBaseFee) external; function blobhashes(bytes32[] calldata hashes) external; function breakpoint(string calldata char) external pure; @@ -434,10 +436,12 @@ interface Vm { function setEnv(string calldata name, string calldata value) external; function setNonce(address account, uint64 newNonce) external; function setNonceUnsafe(address account, uint64 newNonce) external; + function signAndAttachDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation); function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs); function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs); function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs); + function signDelegation(address implementation, uint256 privateKey) external returns (SignedDelegation memory signedDelegation); function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s); function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); diff --git a/testdata/default/cheats/AttachDelegation.t.sol b/testdata/default/cheats/AttachDelegation.t.sol new file mode 100644 index 0000000000000..7befc9a32047c --- /dev/null +++ b/testdata/default/cheats/AttachDelegation.t.sol @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity 0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract AttachDelegationTest is DSTest { + event ExecutedBy(uint256 id); + + Vm constant vm = Vm(HEVM_ADDRESS); + uint256 alice_pk = 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d; + address payable alice = payable(0x70997970C51812dc3A010C7d01b50e0d17dc79C8); + uint256 bob_pk = 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a; + address bob = 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC; + + SimpleDelegateContract implementation; + SimpleDelegateContract implementation2; + ERC20 token; + + function setUp() public { + implementation = new SimpleDelegateContract(1); + implementation2 = new SimpleDelegateContract(2); + token = new ERC20(alice); + } + + function testCallSingleAttachDelegation() public { + Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); + bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); + calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); + // executing as bob to make clear that we don't need to execute the tx as alice + vm.broadcast(bob_pk); + vm.attachDelegation(signedDelegation); + + bytes memory code = address(alice).code; + require(code.length > 0, "no code written to alice"); + SimpleDelegateContract(alice).execute(calls); + + assertEq(token.balanceOf(bob), 100); + } + + function testMultiCallAttachDelegation() public { + Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + vm.broadcast(bob_pk); + vm.attachDelegation(signedDelegation); + + SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](2); + calls[0] = + SimpleDelegateContract.Call({to: address(token), data: abi.encodeCall(ERC20.mint, (50, bob)), value: 0}); + calls[1] = SimpleDelegateContract.Call({ + to: address(token), + data: abi.encodeCall(ERC20.mint, (50, address(this))), + value: 0 + }); + + SimpleDelegateContract(alice).execute(calls); + + assertEq(token.balanceOf(bob), 50); + assertEq(token.balanceOf(address(this)), 50); + } + + function testSwitchAttachDelegation() public { + Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + + SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); + bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); + calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); + + vm.broadcast(bob_pk); + vm.attachDelegation(signedDelegation); + + vm.expectEmit(true, true, true, true); + emit ExecutedBy(1); + SimpleDelegateContract(alice).execute(calls); + + // switch to implementation2 + Vm.SignedDelegation memory signedDelegation2 = vm.signDelegation(address(implementation2), alice_pk); + vm.broadcast(bob_pk); + vm.attachDelegation(signedDelegation2); + + vm.expectEmit(true, true, true, true); + emit ExecutedBy(2); + SimpleDelegateContract(alice).execute(calls); + + // verify final state + assertEq(token.balanceOf(bob), 200); + } + + function testAttachDelegationRevertInvalidSignature() public { + Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + // change v from 1 to 0 + signedDelegation.v = (signedDelegation.v + 1) % 2; + vm.attachDelegation(signedDelegation); + + SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); + bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); + calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); + + vm.broadcast(alice_pk); + // empty revert because no bytecode was set to Alice's account + vm.expectRevert(); + SimpleDelegateContract(alice).execute(calls); + } + + function testAttachDelegationRevertsAfterNonceChange() public { + Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + + vm.broadcast(alice_pk); + // send tx to increment alice's nonce + token.mint(1, bob); + + vm.expectRevert("vm.attachDelegation: invalid nonce"); + vm.attachDelegation(signedDelegation); + } + + function testCallSingleSignAndAttachDelegation() public { + SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); + bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); + calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); + vm.signAndAttachDelegation(address(implementation), alice_pk); + bytes memory code = address(alice).code; + require(code.length > 0, "no code written to alice"); + vm.broadcast(bob_pk); + SimpleDelegateContract(alice).execute(calls); + + assertEq(token.balanceOf(bob), 100); + } +} + +contract SimpleDelegateContract { + event Executed(address indexed to, uint256 value, bytes data); + event ExecutedBy(uint256 id); + + struct Call { + bytes data; + address to; + uint256 value; + } + + uint256 public immutable id; + + constructor(uint256 _id) { + id = _id; + } + + function execute(Call[] memory calls) external payable { + for (uint256 i = 0; i < calls.length; i++) { + Call memory call = calls[i]; + (bool success, bytes memory result) = call.to.call{value: call.value}(call.data); + require(success, string(result)); + emit Executed(call.to, call.value, call.data); + emit ExecutedBy(id); + } + } + + receive() external payable {} +} + +contract ERC20 { + address public minter; + mapping(address => uint256) private _balances; + + constructor(address _minter) { + minter = _minter; + } + + function mint(uint256 amount, address to) public { + _mint(to, amount); + } + + function balanceOf(address account) public view returns (uint256) { + return _balances[account]; + } + + function _mint(address account, uint256 amount) internal { + require(msg.sender == minter, "ERC20: msg.sender is not minter"); + require(account != address(0), "ERC20: mint to the zero address"); + unchecked { + _balances[account] += amount; + } + } +} From b9ee7de28ff7468a58eec811cb283e98c24fbecb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:21:38 +0100 Subject: [PATCH 1700/1963] chore(deps): bump foundry-compilers 0.12.2 (#9364) --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6759a6d2fcfd1..189f2b222b523 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3766,9 +3766,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9edf09554357ebfcd2ea28503badbaca311aac3c947d269a6bae5256543aa172" +checksum = "bb4df7894aa6a5371df998d3945a801e21daafaf5aa20541be8c25671768c984" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3804,9 +3804,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134b2499a20136716422f1ae5afd3a5d6c2ef833bf97b7c956285ca96c1d9743" +checksum = "732c9950ef23e96584e8b9f022562dbceb5b8d33dbb7a6ec033ee3b3e63d26e2" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3814,9 +3814,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a9be34b3a43e77871e5bbd75f4a81d23eebf8f098519ae1ae9e163a0f3d0da" +checksum = "b43d648a62b85344d1d7cc445541a2db6aa85b5acd971799f0cc3c18bbdf801b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3838,9 +3838,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1738950051ebcee2135adac07b3ef1708c6377ffed0c5e9a2bb485f31498befb" +checksum = "167b634d89209acd6c28d9f4abd19e0d77e93a40595fb1c42dab7b4ca7a2bfe5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3853,9 +3853,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac2d9982eedb0eb3819f82c7efa1e28c1f78e031cdfb6adfa34690364fe5e0d" +checksum = "dfe866840fe05f80cd105cd7f535f5c567a500a3dda80e70f6ebe8f149001544" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 624264cf218e6..2e52d1e59327b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } -foundry-compilers = { version = "0.12.1", default-features = false } +foundry-compilers = { version = "0.12.2", default-features = false } foundry-fork-db = "0.6.0" solang-parser = "=0.3.3" From 622f922739923ed243b1b5d701bb9e0898b3ffee Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:16:51 +0100 Subject: [PATCH 1701/1963] feat: rename `ShellOtps` to `GlobalOpts` (#9313) * rename ShellOpts to GlobalOpts * prefer arg / command over clap * add global opts * remove redundant GlobalOpts injection, only use where access to the global variables is required * add global thread pool * add try_jobs method for global rayon pool * limit unnecessary globalopts injection where shell::* is preferred * fix tests * port custom threads iterator to use global rayon thread pool * remove redundant ignores * remove leftover from merge conflict, fix clashing args with inlined global in nodeargs / anvil top level args * leftovers * add back global args in script args * fix unused global opts * ignore attempted multiple initializations of the global thread pool * add init, default spawn with default rayon settings on forge test * make test thread number configurable * add back max threads back test to reduce pressure * remove global --jobs rayon pool, revert to current implementation * fix import --- crates/anvil/src/anvil.rs | 11 +++++---- crates/cast/bin/args.rs | 9 +++---- crates/cast/bin/main.rs | 3 ++- crates/chisel/bin/main.rs | 12 ++++++---- crates/cli/src/opts/{shell.rs => global.rs} | 26 ++++++++++++++------- crates/cli/src/opts/mod.rs | 4 ++-- crates/common/src/io/shell.rs | 15 ++++++++++-- crates/forge/bin/cmd/create.rs | 8 +++---- crates/forge/bin/cmd/soldeer.rs | 1 - crates/forge/bin/cmd/test/mod.rs | 9 +++---- crates/forge/bin/main.rs | 2 +- crates/forge/bin/opts.rs | 9 +++---- crates/script/src/lib.rs | 9 +++---- crates/verify/src/bytecode.rs | 13 ++++++----- 14 files changed, 79 insertions(+), 52 deletions(-) rename crates/cli/src/opts/{shell.rs => global.rs} (80%) diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 5e2a42f59ef06..48e17ed44d291 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -3,7 +3,7 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; use eyre::Result; -use foundry_cli::{opts::ShellOpts, utils}; +use foundry_cli::{opts::GlobalOpts, utils}; #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] @@ -13,14 +13,15 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[derive(Parser)] #[command(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] pub struct Anvil { + /// Include the global options. + #[command(flatten)] + pub global: GlobalOpts, + #[command(flatten)] pub node: NodeArgs, #[command(subcommand)] pub cmd: Option, - - #[clap(flatten)] - pub shell: ShellOpts, } #[derive(Subcommand)] @@ -48,7 +49,7 @@ fn run() -> Result<()> { utils::load_dotenv(); let mut args = Anvil::parse(); - args.shell.shell().set(); + args.global.init()?; args.node.evm_opts.resolve_rpc_alias(); if let Some(cmd) = &args.cmd { diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 8bb7f2d544334..f010c279e0d05 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -9,7 +9,7 @@ use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types::BlockId; use clap::{Parser, Subcommand, ValueHint}; use eyre::Result; -use foundry_cli::opts::{EtherscanOpts, RpcOpts, ShellOpts}; +use foundry_cli::opts::{EtherscanOpts, GlobalOpts, RpcOpts}; use foundry_common::ens::NameOrAddress; use std::{path::PathBuf, str::FromStr}; @@ -31,11 +31,12 @@ const VERSION_MESSAGE: &str = concat!( next_display_order = None, )] pub struct Cast { + /// Include the global options. + #[command(flatten)] + pub global: GlobalOpts, + #[command(subcommand)] pub cmd: CastSubcommand, - - #[clap(flatten)] - pub shell: ShellOpts, } #[derive(Subcommand)] diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 2eac8682c21c1..ffce79099c9cb 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -50,8 +50,9 @@ fn run() -> Result<()> { utils::load_dotenv(); utils::subscriber(); utils::enable_paint(); + let args = CastArgs::parse(); - args.shell.shell().set(); + args.global.init()?; main_args(args) } diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index dca99d4a594d4..acc2c6f172634 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -11,7 +11,7 @@ use clap::{Parser, Subcommand}; use eyre::Context; use foundry_cli::{ handler, - opts::{CoreBuildArgs, ShellOpts}, + opts::{CoreBuildArgs, GlobalOpts}, utils::{self, LoadConfig}, }; use foundry_common::{evm::EvmArgs, fs}; @@ -50,12 +50,13 @@ const VERSION_MESSAGE: &str = concat!( #[derive(Debug, Parser)] #[command(name = "chisel", version = VERSION_MESSAGE)] pub struct Chisel { + /// Include the global options. + #[command(flatten)] + pub global: GlobalOpts, + #[command(subcommand)] pub cmd: Option, - #[clap(flatten)] - pub shell: ShellOpts, - /// Path to a directory containing Solidity files to import, or path to a single Solidity file. /// /// These files will be evaluated before the top-level of the @@ -117,8 +118,9 @@ fn run() -> eyre::Result<()> { handler::install(); utils::subscriber(); utils::load_dotenv(); + let args = Chisel::parse(); - args.shell.shell().set(); + args.global.init()?; main_args(args) } diff --git a/crates/cli/src/opts/shell.rs b/crates/cli/src/opts/global.rs similarity index 80% rename from crates/cli/src/opts/shell.rs rename to crates/cli/src/opts/global.rs index e559cc0f275f5..99690a530d3f5 100644 --- a/crates/cli/src/opts/shell.rs +++ b/crates/cli/src/opts/global.rs @@ -1,11 +1,10 @@ use clap::{ArgAction, Parser}; use foundry_common::shell::{ColorChoice, OutputFormat, OutputMode, Shell, Verbosity}; +use serde::{Deserialize, Serialize}; -// note: `verbose` and `quiet` cannot have `short` because of conflicts with multiple commands. - -/// Global shell options. -#[derive(Clone, Copy, Debug, Default, Parser)] -pub struct ShellOpts { +/// Global options. +#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Parser)] +pub struct GlobalOpts { /// Verbosity level of the log messages. /// /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). @@ -22,7 +21,7 @@ pub struct ShellOpts { /// Do not print log messages. #[clap(short, long, global = true, alias = "silent", help_heading = "Display options")] - pub quiet: bool, + quiet: bool, /// Format log messages as JSON. #[clap( @@ -32,14 +31,23 @@ pub struct ShellOpts { conflicts_with_all = &["quiet", "color"], help_heading = "Display options" )] - pub json: bool, + json: bool, /// The color of the log messages. #[clap(long, global = true, value_enum, help_heading = "Display options")] - pub color: Option, + color: Option, } -impl ShellOpts { +impl GlobalOpts { + /// Initialize the global options. + pub fn init(self) -> eyre::Result<()> { + // Set the global shell. + self.shell().set(); + + Ok(()) + } + + /// Create a new shell instance. pub fn shell(self) -> Shell { let mode = match self.quiet { true => OutputMode::Quiet, diff --git a/crates/cli/src/opts/mod.rs b/crates/cli/src/opts/mod.rs index 95bf9e126cc63..4e5d355724389 100644 --- a/crates/cli/src/opts/mod.rs +++ b/crates/cli/src/opts/mod.rs @@ -2,12 +2,12 @@ mod build; mod chain; mod dependency; mod ethereum; -mod shell; +mod global; mod transaction; pub use build::*; pub use chain::*; pub use dependency::*; pub use ethereum::*; -pub use shell::*; +pub use global::*; pub use transaction::*; diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs index 09a167df94400..fd667ea682eb9 100644 --- a/crates/common/src/io/shell.rs +++ b/crates/common/src/io/shell.rs @@ -7,6 +7,7 @@ use anstream::AutoStream; use anstyle::Style; use clap::ValueEnum; use eyre::Result; +use serde::{Deserialize, Serialize}; use std::{ fmt, io::{prelude::*, IsTerminal}, @@ -34,7 +35,7 @@ pub fn is_quiet() -> bool { /// Returns whether the output format is [`OutputFormat::Json`]. pub fn is_json() -> bool { - Shell::get().output_format().is_json() + Shell::get().is_json() } /// The global shell instance. @@ -172,7 +173,7 @@ enum ShellOut { } /// Whether messages should use color output. -#[derive(Debug, Default, PartialEq, Clone, Copy, ValueEnum)] +#[derive(Debug, Default, PartialEq, Clone, Copy, Serialize, Deserialize, ValueEnum)] pub enum ColorChoice { /// Intelligently guess whether to use color output (default). #[default] @@ -262,6 +263,16 @@ impl Shell { self.needs_clear.swap(needs_clear, Ordering::Relaxed) } + /// Returns `true` if the output format is JSON. + pub fn is_json(&self) -> bool { + self.output_format.is_json() + } + + /// Returns `true` if the verbosity level is `Quiet`. + pub fn is_quiet(&self) -> bool { + self.output_mode.is_quiet() + } + /// Returns `true` if the `needs_clear` flag is set. #[inline] pub fn needs_clear(&self) -> bool { diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index e19feafcc6285..9fc2629e5988f 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -10,7 +10,7 @@ use alloy_signer::Signer; use alloy_transport::{Transport, TransportError}; use clap::{Parser, ValueHint}; use eyre::{Context, Result}; -use forge_verify::RetryArgs; +use forge_verify::{RetryArgs, VerifierArgs, VerifyArgs}; use foundry_cli::{ opts::{CoreBuildArgs, EthereumOpts, EtherscanOpts, TransactionOpts}, utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, @@ -89,7 +89,7 @@ pub struct CreateArgs { eth: EthereumOpts, #[command(flatten)] - pub verifier: forge_verify::VerifierArgs, + pub verifier: VerifierArgs, #[command(flatten)] retry: RetryArgs, @@ -201,7 +201,7 @@ impl CreateArgs { ) -> Result<()> { // NOTE: this does not represent the same `VerifyArgs` that would be sent after deployment, // since we don't know the address yet. - let mut verify = forge_verify::VerifyArgs { + let mut verify = VerifyArgs { address: Default::default(), contract: Some(self.contract.clone()), compiler_version: Some(id.version.to_string()), @@ -359,7 +359,7 @@ impl CreateArgs { } else { None }; - let verify = forge_verify::VerifyArgs { + let verify = VerifyArgs { address, contract: Some(self.contract), compiler_version: Some(id.version.to_string()), diff --git a/crates/forge/bin/cmd/soldeer.rs b/crates/forge/bin/cmd/soldeer.rs index 56b8c31f3a515..b2c9a77f10747 100644 --- a/crates/forge/bin/cmd/soldeer.rs +++ b/crates/forge/bin/cmd/soldeer.rs @@ -1,6 +1,5 @@ use clap::Parser; use eyre::Result; - use soldeer_commands::Command; // CLI arguments for `forge soldeer`. diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 4e811bcbfbf96..435c34275850f 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -17,7 +17,7 @@ use forge::{ MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, TestOptionsBuilder, }; use foundry_cli::{ - opts::{CoreBuildArgs, ShellOpts}, + opts::{CoreBuildArgs, GlobalOpts}, utils::{self, LoadConfig}, }; use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell, TestFunctionExt}; @@ -65,6 +65,10 @@ foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); #[derive(Clone, Debug, Parser)] #[command(next_help_heading = "Test options")] pub struct TestArgs { + /// Include the global options. + #[command(flatten)] + pub global: GlobalOpts, + /// The contract file you want to test, it's a shortcut for --match-path. #[arg(value_hint = ValueHint::FilePath)] pub path: Option, @@ -178,9 +182,6 @@ pub struct TestArgs { /// Print detailed test summary table. #[arg(long, help_heading = "Display options", requires = "summary")] pub detailed: bool, - - #[command(flatten)] - shell: ShellOpts, } impl TestArgs { diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index ee49f7f692b2c..ac0992cf9f656 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -35,7 +35,7 @@ fn run() -> Result<()> { utils::enable_paint(); let args = Forge::parse(); - args.shell.shell().set(); + args.global.init()?; init_execution_context(&args.cmd); match args.cmd { diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 39bc89e63b8f9..380cb61d403a5 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -8,7 +8,7 @@ use crate::cmd::{ use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; use forge_verify::{VerifyArgs, VerifyBytecodeArgs, VerifyCheckArgs}; -use foundry_cli::opts::ShellOpts; +use foundry_cli::opts::GlobalOpts; use std::path::PathBuf; const VERSION_MESSAGE: &str = concat!( @@ -29,11 +29,12 @@ const VERSION_MESSAGE: &str = concat!( next_display_order = None, )] pub struct Forge { + /// Include the global options. + #[command(flatten)] + pub global: GlobalOpts, + #[command(subcommand)] pub cmd: ForgeSubcommand, - - #[clap(flatten)] - pub shell: ShellOpts, } #[derive(Subcommand)] diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 180a09647d4ff..0f0283b9f01ae 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -27,7 +27,7 @@ use eyre::{ContextCompat, Result}; use forge_script_sequence::{AdditionalContract, NestedValue}; use forge_verify::RetryArgs; use foundry_cli::{ - opts::{CoreBuildArgs, ShellOpts}, + opts::{CoreBuildArgs, GlobalOpts}, utils::LoadConfig, }; use foundry_common::{ @@ -78,6 +78,10 @@ foundry_config::merge_impl_figment_convert!(ScriptArgs, opts, evm_opts); /// CLI arguments for `forge script`. #[derive(Clone, Debug, Default, Parser)] pub struct ScriptArgs { + /// Include the global options. + #[command(flatten)] + pub global: GlobalOpts, + /// The contract you want to run. Either the file path or contract name. /// /// If multiple contracts exist in the same file you must specify the target contract with @@ -213,9 +217,6 @@ pub struct ScriptArgs { #[command(flatten)] pub retry: RetryArgs, - - #[clap(flatten)] - pub shell: ShellOpts, } impl ScriptArgs { diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 0c3f9e5b0a91f..cd86c42006258 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -35,11 +35,11 @@ pub struct VerifyBytecodeArgs { pub contract: ContractInfo, /// The block at which the bytecode should be verified. - #[clap(long, value_name = "BLOCK")] + #[arg(long, value_name = "BLOCK")] pub block: Option, /// The constructor args to generate the creation code. - #[clap( + #[arg( long, num_args(1..), conflicts_with_all = &["constructor_args_path", "encoded_constructor_args"], @@ -65,14 +65,15 @@ pub struct VerifyBytecodeArgs { pub constructor_args_path: Option, /// The rpc url to use for verification. - #[clap(short = 'r', long, value_name = "RPC_URL", env = "ETH_RPC_URL")] + #[arg(short = 'r', long, value_name = "RPC_URL", env = "ETH_RPC_URL")] pub rpc_url: Option, - #[clap(flatten)] + /// Etherscan options. + #[command(flatten)] pub etherscan: EtherscanOpts, /// Verifier options. - #[clap(flatten)] + #[command(flatten)] pub verifier: VerifierArgs, /// The project's root path. @@ -83,7 +84,7 @@ pub struct VerifyBytecodeArgs { pub root: Option, /// Ignore verification for creation or runtime bytecode. - #[clap(long, value_name = "BYTECODE_TYPE")] + #[arg(long, value_name = "BYTECODE_TYPE")] pub ignore: Option, } From fb5f0e1c4d9b9b0861be3e3bd07963524c5ac08e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:06:42 +0200 Subject: [PATCH 1702/1963] chore(deps): bump foundry-compilers 0.12.3 (#9368) --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 189f2b222b523..7451f42b7ba91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3766,9 +3766,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4df7894aa6a5371df998d3945a801e21daafaf5aa20541be8c25671768c984" +checksum = "3a6131af72175c55aa531c4851290d9cf67af7a82b03f20a8a9d28dba81b9fd3" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3804,9 +3804,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732c9950ef23e96584e8b9f022562dbceb5b8d33dbb7a6ec033ee3b3e63d26e2" +checksum = "c522c473e7a111b81f0d47f8a65ca1ef0642c8c8d1ca2d1e230338210d16bb02" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3814,9 +3814,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b43d648a62b85344d1d7cc445541a2db6aa85b5acd971799f0cc3c18bbdf801b" +checksum = "c7cd569a0c38d232244932e71933b54e418cddcc8f0c16fd8af96dd844b27788" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3838,9 +3838,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167b634d89209acd6c28d9f4abd19e0d77e93a40595fb1c42dab7b4ca7a2bfe5" +checksum = "3b80563ba10981ec4a9667fda9318d02721a81f248ae73303603388580150a35" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3853,9 +3853,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe866840fe05f80cd105cd7f535f5c567a500a3dda80e70f6ebe8f149001544" +checksum = "4a840a87cb4845d208df3390a12d3724e6d1cc1268a51ac334a01f80f9b6419b" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 2e52d1e59327b..0cefa4cdb571c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } -foundry-compilers = { version = "0.12.2", default-features = false } +foundry-compilers = { version = "0.12.3", default-features = false } foundry-fork-db = "0.6.0" solang-parser = "=0.3.3" From 25cc1ac68b5f6977f23d713c01ec455ad7f03d21 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:17:59 +0530 Subject: [PATCH 1703/1963] chore(deps): bump alloy 0.6.4 (#9280) * bump alloy to 0.6.1 * fix: ui - use AnyRpcBlock * fix: wallets - use PrimitveSig * bump 0.6.2 * replace: AnyNetworkBlock with AnyRpcBlock + HeaderResponse with BlockHeader * fix: configure_tx_env * fix: crypto cheatcodes * fix: anvil_core tx * fix * fix: verify-bytecode * fix cast + get_pretty_tx_attr * fix(`anvil`): core TypedTx + BlockListener task * fix * fix: anvil tests * fix: test_deser_block * fix: transaction_build * fix: test load state files * fix: deny.toml * fix: try_from AnyRpcTx to DepositTx + bump op-alloy types * bump * fix: configure_tx_env * fix: UiFmt * fix: vb * fix: common-fmt tests * nit * fix: sig encoding * fix: process deposit tx in transaction_build * fix: common-fmt tests * fix * Update deny.toml Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> * fixes * fix: use alloy impls for conversions * nit * fix: transaction_build * nit * fix: eip155 check and rm anvil core utils * clippy * nits * fix * nit * fix: impl UIfmt for TxEnvelope and AnyTxEnvelope * make header in pretty_block_basics exhaustive * clippy * fix * fix: txpool_content * fix * fix * fix overriding hashes * fix --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- Cargo.lock | 158 +++--- Cargo.toml | 54 +- crates/anvil/Cargo.toml | 2 +- crates/anvil/core/Cargo.toml | 6 +- crates/anvil/core/src/eth/mod.rs | 1 - crates/anvil/core/src/eth/transaction/mod.rs | 473 +++++----------- crates/anvil/core/src/eth/utils.rs | 13 - crates/anvil/src/config.rs | 35 +- crates/anvil/src/eth/api.rs | 87 ++- crates/anvil/src/eth/backend/db.rs | 4 +- crates/anvil/src/eth/backend/fork.rs | 43 +- crates/anvil/src/eth/backend/info.rs | 8 +- crates/anvil/src/eth/backend/mem/mod.rs | 273 ++++++---- crates/anvil/src/eth/error.rs | 5 + crates/anvil/src/eth/otterscan/api.rs | 57 +- crates/anvil/src/eth/pool/transactions.rs | 9 +- crates/anvil/src/eth/sign.rs | 2 +- crates/anvil/src/tasks/mod.rs | 10 +- .../test-data/state-dump-legacy-stress.json | 2 +- crates/anvil/test-data/state-dump-legacy.json | 2 +- crates/anvil/test-data/state-dump.json | 2 +- crates/anvil/tests/it/anvil_api.rs | 12 +- crates/anvil/tests/it/api.rs | 2 +- crates/anvil/tests/it/eip4844.rs | 18 +- crates/anvil/tests/it/eip7702.rs | 2 +- crates/anvil/tests/it/fork.rs | 4 +- crates/anvil/tests/it/ipc.rs | 2 +- crates/anvil/tests/it/logs.rs | 9 +- crates/anvil/tests/it/otterscan.rs | 5 +- crates/anvil/tests/it/pubsub.rs | 4 +- crates/anvil/tests/it/transaction.rs | 4 +- crates/cast/bin/cmd/creation_code.rs | 5 +- crates/cast/bin/cmd/run.rs | 31 +- crates/cast/src/lib.rs | 6 +- crates/cheatcodes/src/crypto.rs | 20 +- crates/cheatcodes/src/script.rs | 16 +- crates/common/fmt/src/ui.rs | 513 +++++++++++++----- crates/common/src/transactions.rs | 2 +- crates/evm/core/Cargo.toml | 3 +- crates/evm/core/src/backend/mod.rs | 29 +- crates/evm/core/src/fork/init.rs | 15 +- crates/evm/core/src/fork/multi.rs | 3 +- crates/evm/core/src/opts.rs | 5 +- crates/evm/core/src/utils.rs | 13 +- crates/verify/src/bytecode.rs | 81 ++- crates/verify/src/etherscan/mod.rs | 7 +- crates/verify/src/utils.rs | 15 +- crates/wallets/src/wallet_signer.rs | 18 +- 48 files changed, 1124 insertions(+), 966 deletions(-) delete mode 100644 crates/anvil/core/src/eth/utils.rs diff --git a/Cargo.lock b/Cargo.lock index 7451f42b7ba91..ebc0c4e0bbe18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed961a48297c732a5d97ee321aa8bb5009ecadbcb077d8bec90cb54e651629" +checksum = "ae09ffd7c29062431dd86061deefe4e3c6f07fa0d674930095f8dcedb0baf02c" dependencies = [ "alloy-eips", "alloy-primitives", @@ -97,14 +97,15 @@ dependencies = [ "auto_impl", "c-kzg", "derive_more", + "k256", "serde", ] [[package]] name = "alloy-contract" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460ab80ce4bda1c80bcf96fe7460520476f2c7b734581c6567fac2708e2a60ef" +checksum = "66430a72d5bf5edead101c8c2f0a24bada5ec9f3cf9909b3e08b6d6899b4803e" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -157,9 +158,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ffc577390ce50234e02d841214b3dc0bea6aaaae8e04bbf3cb82e9a45da9eb" +checksum = "5f6cee6a35793f3db8a5ffe60e86c695f321d081a567211245f503e8c498fce8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -172,9 +173,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69e06cf9c37be824b9d26d6d101114fdde6af0c87de2828b414c05c4b3daa71" +checksum = "5b6aa3961694b30ba53d41006131a2fca3bdab22e4c344e46db2c639e7c2dfdd" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -190,9 +191,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde15e14944a88bd6a57d325e9a49b75558746fe16aaccc79713ae50a6a9574c" +checksum = "e53f7877ded3921d18a0a9556d55bedf84535567198c9edab2aa23106da91855" dependencies = [ "alloy-primitives", "alloy-serde", @@ -213,9 +214,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5979e0d5a7bf9c7eb79749121e8256e59021af611322aee56e77e20776b4b3" +checksum = "3694b7e480728c0b3e228384f223937f14c10caef5a4c766021190fc8f283d35" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -227,9 +228,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "204237129086ce5dc17a58025e93739b01b45313841f98fa339eb1d780511e57" +checksum = "ea94b8ceb5c75d7df0a93ba0acc53b55a22b47b532b600a800a87ef04eb5b0b4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -243,14 +244,16 @@ dependencies = [ "async-trait", "auto_impl", "futures-utils-wasm", + "serde", + "serde_json", "thiserror 1.0.69", ] [[package]] name = "alloy-network-primitives" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514f70ee2a953db21631cd817b13a1571474ec77ddc03d47616d5e8203489fde" +checksum = "df9f3e281005943944d15ee8491534a1c7b3cbf7a7de26f8c433b842b93eb5f9" dependencies = [ "alloy-consensus", "alloy-eips", @@ -293,9 +296,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4814d141ede360bb6cd1b4b064f1aab9de391e7c4d0d4d50ac89ea4bc1e25fbd" +checksum = "40c1f9eede27bf4c13c099e8e64d54efd7ce80ef6ea47478aa75d5d74e2dba3b" dependencies = [ "alloy-chains", "alloy-consensus", @@ -335,9 +338,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba46eb69ddf7a9925b81f15229cb74658e6eebe5dd30a5b74e2cd040380573" +checksum = "90f1f34232f77341076541c405482e4ae12f0ee7153d8f9969fc1691201b2247" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -376,9 +379,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc2bd1e7403463a5f2c61e955bcc9d3072b63aa177442b0f9aa6a6d22a941e3" +checksum = "374dbe0dc3abdc2c964f36b3d3edf9cdb3db29d16bda34aa123f03d810bec1dd" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -402,9 +405,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea9bf1abdd506f985a53533f5ac01296bcd6102c5e139bbc5d40bc468d2c916" +checksum = "c74832aa474b670309c20fffc2a869fa141edab7c79ff7963fad0a08de60bae1" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -418,20 +421,21 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2382fc63fb0cf3e02818d547b80cb66cc49a31f8803d0c328402b2008bc13650" +checksum = "5ca97963132f78ddfc60e43a017348e6d52eea983925c23652f5b330e8e02291" dependencies = [ "alloy-primitives", + "alloy-rpc-types-eth", "alloy-serde", "serde", ] [[package]] name = "alloy-rpc-types-engine" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "886d22d41992287a235af2f3af4299b5ced2bcafb81eb835572ad35747476946" +checksum = "3f56294dce86af23ad6ee8df46cf8b0d292eb5d1ff67dc88a0886051e32b1faf" dependencies = [ "alloy-consensus", "alloy-eips", @@ -447,9 +451,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b034779a4850b4b03f5be5ea674a1cf7d746b2da762b34d1860ab45e48ca27" +checksum = "a8a477281940d82d29315846c7216db45b15e90bcd52309da9f54bcf7ad94a11" dependencies = [ "alloy-consensus", "alloy-eips", @@ -466,9 +470,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5fb6c5c401321f802f69dcdb95b932f30f8158f6798793f914baac5995628e" +checksum = "ecd8b4877ef520c138af702097477cdd19504a8e1e4675ba37e92ba40f2d3c6f" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -480,9 +484,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad066b49c3b1b5f64cdd2399177a19926a6a15db2dbf11e2098de621f9e7480" +checksum = "1d4ab49acf90a71f7fb894dc5fd485f1f07a1e348966c714c4d1e0b7478850a8" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -492,9 +496,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028e72eaa9703e4882344983cfe7636ce06d8cce104a78ea62fd19b46659efc4" +checksum = "4dfa4a7ccf15b2492bb68088692481fd6b2604ccbee1d0d6c44c21427ae4df83" dependencies = [ "alloy-primitives", "serde", @@ -503,9 +507,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "592c185d7100258c041afac51877660c7bf6213447999787197db4842f0e938e" +checksum = "2e10aec39d60dc27edcac447302c7803d2371946fb737245320a05b78eb2fafd" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -519,9 +523,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a406102908a4e51834f32c4e5c1b29aa2c407b3fd23a5cad129c28b56d85e1b8" +checksum = "0109e5b18079aec2a022e4bc9db1d74bcc046f8b66274ffa8b0e4322b44b2b44" dependencies = [ "alloy-consensus", "alloy-network", @@ -537,9 +541,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d363e12280cb43747d3b62a1e6f00d595bc1a56464bb20200c6b6ca5d68185" +checksum = "558651eb0d76bcf2224de694481e421112fa2cbc6fe6a413cc76fd67e14cf0d7" dependencies = [ "alloy-consensus", "alloy-network", @@ -555,9 +559,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a642c9f66ac73ae0d5398ce7ce3ce5bdfad5658d549abd48ea48962e585dca" +checksum = "29781b6a064b6235de4ec3cc0810f59fe227b8d31258f23a077570fc9525d7a6" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -575,9 +579,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6614f02fc1d5b079b2a4a5320018317b506fd0a6d67c1fd5542a71201724986c" +checksum = "d8396f6dff60700bc1d215ee03d86ff56de268af96e2bf833a14d0bafcab9882" dependencies = [ "alloy-consensus", "alloy-network", @@ -594,9 +598,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b754988ef4e1f5f7d55c132949bb2a10491ed6bbf1d35108269014f50da1823f" +checksum = "21267541177607141a5db6fd1abed5a46553b7a6d9363cf3d047721634705905" dependencies = [ "alloy-consensus", "alloy-network", @@ -684,9 +688,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be77579633ebbc1266ae6fd7694f75c408beb1aeb6865d0b18f22893c265a061" +checksum = "f99acddb34000d104961897dbb0240298e8b775a7efffb9fda2a1a3efedd65b3" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -704,9 +708,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fd1a5d0827939847983b46f2f79510361f901dc82f8e3c38ac7397af142c6e" +checksum = "5dc013132e34eeadaa0add7e74164c1503988bfba8bae885b32e0918ba85a8a6" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -719,9 +723,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8073d1186bfeeb8fbdd1292b6f1a0731f3aed8e21e1463905abfae0b96a887a6" +checksum = "063edc0660e81260653cc6a95777c29d54c2543a668aa5da2359fb450d25a1ba" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -740,9 +744,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61f27837bb4a1d6c83a28231c94493e814882f0e9058648a97e908a5f3fc9fcf" +checksum = "abd170e600801116d5efe64f74a4fc073dbbb35c807013a7d0a388742aeebba0" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -935,6 +939,7 @@ dependencies = [ "alloy-consensus", "alloy-dyn-abi", "alloy-eips", + "alloy-network", "alloy-primitives", "alloy-rlp", "alloy-rpc-types", @@ -3972,13 +3977,14 @@ dependencies = [ name = "foundry-evm-core" version = "0.2.0" dependencies = [ + "alloy-consensus", "alloy-dyn-abi", "alloy-genesis", "alloy-json-abi", + "alloy-network", "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-serde", "alloy-sol-types", "alloy-transport", "auto_impl", @@ -4072,10 +4078,11 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fe4a1e7e0f122b28afc156681687249bd5cf910d9bf873efb1181e4d41fbc3" +checksum = "5fea8068a6b7929229f72059296da09bf3c1d15569fdb4a351d2983450587c12" dependencies = [ + "alloy-consensus", "alloy-primitives", "alloy-provider", "alloy-rpc-types", @@ -6271,9 +6278,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.5.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26c3b35b7b3e36d15e0563eebffe13c1d9ca16b7aaffcb6a64354633547e16b" +checksum = "bff54d1d790eca1f3aedbd666162e9c42eceff90b9f9d24b352ed9c2df1e901a" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6287,9 +6294,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.5.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bae9bf91b620e1e2c2291562e5998bc1247bd8ada011773e1997b31a95de99" +checksum = "981b7f8ab11fe85ba3c1723702f000429b8d0c16b5883c93d577895f262cbac6" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6297,6 +6304,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", "alloy-serde", + "derive_more", "op-alloy-consensus", "serde", "serde_json", @@ -7399,9 +7407,9 @@ dependencies = [ [[package]] name = "revm" -version = "17.1.0" +version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "055bee6a81aaeee8c2389ae31f0d4de87f44df24f4444a1116f9755fd87a76ad" +checksum = "15689a3c6a8d14b647b4666f2e236ef47b5a5133cdfd423f545947986fff7013" dependencies = [ "auto_impl", "cfg-if", @@ -7414,9 +7422,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e29c662f7887f3b659d4b0fd234673419a8fcbeaa1ecc29bf7034c0a75cc8ea" +checksum = "747291a18ad6726a08dd73f8b6a6b3a844db582ecae2063ccf0a04880c44f482" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -7432,9 +7440,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "13.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fac2034454f8bc69dc7d3c94cdb1b57559e27f5ef0518771f1787de543d7d6a1" +checksum = "74e3f11d0fed049a4a10f79820c59113a79b38aed4ebec786a79d5c667bfeb51" dependencies = [ "revm-primitives", "serde", @@ -7442,9 +7450,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "14.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a88c8c7c5f9b988a9e65fc0990c6ce859cdb74114db705bd118a96d22d08027" +checksum = "e381060af24b750069a2b2d2c54bba273d84e8f5f9e8026fc9262298e26cc336" dependencies = [ "aurora-engine-modexp", "blst", @@ -7462,9 +7470,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "13.0.0" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d11fa1e195b0bebaf3fb18596f314a13ba3a4cb1fdd16d3465934d812fd921e" +checksum = "3702f132bb484f4f0d0ca4f6fbde3c82cfd745041abbedd6eda67730e1868ef0" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -9761,9 +9769,9 @@ dependencies = [ [[package]] name = "wasmtimer" -version = "0.2.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7ed9d8b15c7fb594d72bfb4b5a276f3d2029333cd93a932f376f5937f6f80ee" +checksum = "bb4f099acbc1043cc752b91615b24b02d7f6fcd975bd781fed9f50b3c3e15bf7" dependencies = [ "futures", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 0cefa4cdb571c..f5ec94b906bc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,39 +170,39 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } foundry-compilers = { version = "0.12.3", default-features = false } -foundry-fork-db = "0.6.0" +foundry-fork-db = "0.7.0" solang-parser = "=0.3.3" ## revm -revm = { version = "17.1.0", default-features = false } -revm-primitives = { version = "13.0.0", default-features = false } -revm-inspectors = { version = "0.10.0", features = ["serde"] } +revm = { version = "18.0.0", default-features = false } +revm-primitives = { version = "14.0.0", default-features = false } +revm-inspectors = { version = "0.11.0", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.5.4", default-features = false } -alloy-contract = { version = "0.5.4", default-features = false } -alloy-eips = { version = "0.5.4", default-features = false } -alloy-genesis = { version = "0.5.4", default-features = false } -alloy-json-rpc = { version = "0.5.4", default-features = false } -alloy-network = { version = "0.5.4", default-features = false } -alloy-provider = { version = "0.5.4", default-features = false } -alloy-pubsub = { version = "0.5.4", default-features = false } -alloy-rpc-client = { version = "0.5.4", default-features = false } -alloy-rpc-types = { version = "0.5.4", default-features = true } -alloy-serde = { version = "0.5.4", default-features = false } -alloy-signer = { version = "0.5.4", default-features = false } -alloy-signer-aws = { version = "0.5.4", default-features = false } -alloy-signer-gcp = { version = "0.5.4", default-features = false } -alloy-signer-ledger = { version = "0.5.4", default-features = false } -alloy-signer-local = { version = "0.5.4", default-features = false } -alloy-signer-trezor = { version = "0.5.4", default-features = false } -alloy-transport = { version = "0.5.4", default-features = false } -alloy-transport-http = { version = "0.5.4", default-features = false } -alloy-transport-ipc = { version = "0.5.4", default-features = false } -alloy-transport-ws = { version = "0.5.4", default-features = false } +alloy-consensus = { version = "0.6.4", default-features = false } +alloy-contract = { version = "0.6.4", default-features = false } +alloy-eips = { version = "0.6.4", default-features = false } +alloy-genesis = { version = "0.6.4", default-features = false } +alloy-json-rpc = { version = "0.6.4", default-features = false } +alloy-network = { version = "0.6.4", default-features = false } +alloy-provider = { version = "0.6.4", default-features = false } +alloy-pubsub = { version = "0.6.4", default-features = false } +alloy-rpc-client = { version = "0.6.4", default-features = false } +alloy-rpc-types = { version = "0.6.4", default-features = true } +alloy-serde = { version = "0.6.4", default-features = false } +alloy-signer = { version = "0.6.4", default-features = false } +alloy-signer-aws = { version = "0.6.4", default-features = false } +alloy-signer-gcp = { version = "0.6.4", default-features = false } +alloy-signer-ledger = { version = "0.6.4", default-features = false } +alloy-signer-local = { version = "0.6.4", default-features = false } +alloy-signer-trezor = { version = "0.6.4", default-features = false } +alloy-transport = { version = "0.6.4", default-features = false } +alloy-transport-http = { version = "0.6.4", default-features = false } +alloy-transport-ipc = { version = "0.6.4", default-features = false } +alloy-transport-ws = { version = "0.6.4", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.11" @@ -222,8 +222,8 @@ alloy-rlp = "0.3" alloy-trie = "0.6.0" ## op-alloy -op-alloy-rpc-types = "0.5.0" -op-alloy-consensus = "0.5.0" +op-alloy-rpc-types = "0.6.5" +op-alloy-consensus = "0.6.5" ## cli anstream = "0.6" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 4c3cbc4f7e8e9..b3389d2eccae4 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -67,7 +67,7 @@ alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true alloy-trie.workspace = true -op-alloy-consensus.workspace = true +op-alloy-consensus = { workspace = true, features = ["serde"] } # axum related axum.workspace = true diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index dcf8bf50857e1..dacc7f20e0ea3 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -22,7 +22,7 @@ revm = { workspace = true, default-features = false, features = [ "c-kzg", ] } -alloy-primitives = { workspace = true, features = ["serde"] } +alloy-primitives = { workspace = true, features = ["serde", "rlp"] } alloy-rpc-types = { workspace = true, features = ["anvil", "trace"] } alloy-serde.workspace = true alloy-rlp.workspace = true @@ -30,8 +30,8 @@ alloy-eips.workspace = true alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-trie.workspace = true -op-alloy-consensus.workspace = true - +op-alloy-consensus = { workspace = true, features = ["serde"] } +alloy-network.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true bytes.workspace = true diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 33ffda6a701fa..b1d3b85221bee 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -18,7 +18,6 @@ pub mod proof; pub mod subscription; pub mod transaction; pub mod trie; -pub mod utils; pub mod wallet; #[cfg(feature = "serde")] diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 827f14a554023..8de659799a36c 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -6,22 +6,23 @@ use alloy_consensus::{ eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, TxEip7702, }, - AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, - TxEnvelope, TxLegacy, TxReceipt, TxType, + AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, + TxEip2930, TxEnvelope, TxLegacy, TxReceipt, }; use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; +use alloy_network::{AnyRpcTransaction, AnyTxEnvelope}; use alloy_primitives::{ - Address, Bloom, Bytes, Log, Parity, Signature, TxHash, TxKind, B256, U256, U64, + Address, Bloom, Bytes, Log, PrimitiveSignature, TxHash, TxKind, B256, U256, U64, }; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, AnyTransactionReceipt, - ConversionError, Signature as RpcSignature, Transaction as RpcTransaction, TransactionReceipt, + ConversionError, Transaction as RpcTransaction, TransactionReceipt, }; use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; use foundry_evm::traces::CallTraceNode; -use op_alloy_consensus::TxDeposit; +use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; use revm::{ interpreter::InstructionResult, primitives::{OptimismFields, TxEnv}, @@ -278,162 +279,64 @@ pub fn to_alloy_transaction_with_hash_and_sender( from: Address, ) -> RpcTransaction { match transaction { - TypedTransaction::Legacy(t) => RpcTransaction { - hash, - nonce: t.tx().nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: t.tx().to.to().copied(), - value: t.tx().value, - gas_price: Some(t.tx().gas_price), - max_fee_per_gas: Some(t.tx().gas_price), - max_priority_fee_per_gas: Some(t.tx().gas_price), - gas: t.tx().gas_limit, - input: t.tx().input.clone(), - chain_id: t.tx().chain_id, - signature: Some(RpcSignature { - r: t.signature().r(), - s: t.signature().s(), - v: U256::from(t.signature().v().to_u64()), - y_parity: None, - }), - access_list: None, - transaction_type: Some(0), - max_fee_per_blob_gas: None, - blob_versioned_hashes: None, - authorization_list: None, - }, - TypedTransaction::EIP2930(t) => RpcTransaction { - hash, - nonce: t.tx().nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: t.tx().to.to().copied(), - value: t.tx().value, - gas_price: Some(t.tx().gas_price), - max_fee_per_gas: Some(t.tx().gas_price), - max_priority_fee_per_gas: Some(t.tx().gas_price), - gas: t.tx().gas_limit, - input: t.tx().input.clone(), - chain_id: Some(t.tx().chain_id), - signature: Some(RpcSignature { - r: t.signature().r(), - s: t.signature().s(), - v: U256::from(t.signature().v().to_u64()), - y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), - }), - access_list: Some(t.tx().access_list.clone()), - transaction_type: Some(1), - max_fee_per_blob_gas: None, - blob_versioned_hashes: None, - authorization_list: None, - }, - TypedTransaction::EIP1559(t) => RpcTransaction { - hash, - nonce: t.tx().nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: t.tx().to.to().copied(), - value: t.tx().value, - gas_price: None, - max_fee_per_gas: Some(t.tx().max_fee_per_gas), - max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas), - gas: t.tx().gas_limit, - input: t.tx().input.clone(), - chain_id: Some(t.tx().chain_id), - signature: Some(RpcSignature { - r: t.signature().r(), - s: t.signature().s(), - v: U256::from(t.signature().v().to_u64()), - y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), - }), - access_list: Some(t.tx().access_list.clone()), - transaction_type: Some(2), - max_fee_per_blob_gas: None, - blob_versioned_hashes: None, - authorization_list: None, - }, - TypedTransaction::EIP4844(t) => RpcTransaction { - hash, - nonce: t.tx().tx().nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: Some(t.tx().tx().to), - value: t.tx().tx().value, - gas_price: Some(t.tx().tx().max_fee_per_gas), - max_fee_per_gas: Some(t.tx().tx().max_fee_per_gas), - max_priority_fee_per_gas: Some(t.tx().tx().max_priority_fee_per_gas), - gas: t.tx().tx().gas_limit, - input: t.tx().tx().input.clone(), - chain_id: Some(t.tx().tx().chain_id), - signature: Some(RpcSignature { - r: t.signature().r(), - s: t.signature().s(), - v: U256::from(t.signature().v().to_u64()), - y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), - }), - access_list: Some(t.tx().tx().access_list.clone()), - transaction_type: Some(3), - max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas), - blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), - authorization_list: None, - }, - TypedTransaction::EIP7702(t) => RpcTransaction { - hash, - nonce: t.tx().nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: Some(t.tx().to), - value: t.tx().value, - gas_price: Some(t.tx().max_fee_per_gas), - max_fee_per_gas: Some(t.tx().max_fee_per_gas), - max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas), - gas: t.tx().gas_limit, - input: t.tx().input.clone(), - chain_id: Some(t.tx().chain_id), - signature: Some(RpcSignature { - r: t.signature().r(), - s: t.signature().s(), - v: U256::from(t.signature().v().to_u64()), - y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), - }), - access_list: Some(t.tx().access_list.clone()), - transaction_type: Some(4), - authorization_list: Some(t.tx().authorization_list.clone()), - ..Default::default() - }, - TypedTransaction::Deposit(t) => RpcTransaction { - hash, - nonce: t.nonce, - block_hash: None, - block_number: None, - transaction_index: None, - from, - to: t.kind.to().copied(), - value: t.value, - gas_price: None, - max_fee_per_gas: None, - max_priority_fee_per_gas: None, - gas: t.gas_limit, - input: t.input.clone().0.into(), - chain_id: t.chain_id().map(u64::from), - signature: None, - access_list: None, - transaction_type: None, - max_fee_per_blob_gas: None, - blob_versioned_hashes: None, - authorization_list: None, - }, + TypedTransaction::Legacy(t) => { + let (tx, sig, _) = t.into_parts(); + RpcTransaction { + block_hash: None, + block_number: None, + transaction_index: None, + from, + effective_gas_price: None, + inner: TxEnvelope::Legacy(Signed::new_unchecked(tx, sig, hash)), + } + } + TypedTransaction::EIP2930(t) => { + let (tx, sig, _) = t.into_parts(); + RpcTransaction { + block_hash: None, + block_number: None, + transaction_index: None, + from, + effective_gas_price: None, + inner: TxEnvelope::Eip2930(Signed::new_unchecked(tx, sig, hash)), + } + } + TypedTransaction::EIP1559(t) => { + let (tx, sig, _) = t.into_parts(); + RpcTransaction { + block_hash: None, + block_number: None, + transaction_index: None, + from, + effective_gas_price: None, + inner: TxEnvelope::Eip1559(Signed::new_unchecked(tx, sig, hash)), + } + } + TypedTransaction::EIP4844(t) => { + let (tx, sig, _) = t.into_parts(); + RpcTransaction { + block_hash: None, + block_number: None, + transaction_index: None, + from, + effective_gas_price: None, + inner: TxEnvelope::Eip4844(Signed::new_unchecked(tx, sig, hash)), + } + } + TypedTransaction::EIP7702(t) => { + let (tx, sig, _) = t.into_parts(); + RpcTransaction { + block_hash: None, + block_number: None, + transaction_index: None, + from, + effective_gas_price: None, + inner: TxEnvelope::Eip7702(Signed::new_unchecked(tx, sig, hash)), + } + } + TypedTransaction::Deposit(_t) => { + unreachable!("cannot reach here, handled in `transaction_build` ") + } } } @@ -681,7 +584,8 @@ impl TryFrom for TransactionRequest { type Error = ConversionError; fn try_from(value: TypedTransaction) -> Result { - let from = value.recover().map_err(|_| ConversionError::InvalidSignature)?; + let from = + value.recover().map_err(|_| ConversionError::Custom("InvalidSignature".to_string()))?; let essentials = value.essentials(); let tx_type = value.r#type(); Ok(Self { @@ -702,8 +606,77 @@ impl TryFrom for TransactionRequest { } } +impl TryFrom for TypedTransaction { + type Error = ConversionError; + + fn try_from(value: AnyRpcTransaction) -> Result { + let AnyRpcTransaction { inner, .. } = value; + let from = inner.from; + match inner.inner { + AnyTxEnvelope::Ethereum(tx) => match tx { + TxEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)), + TxEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)), + TxEnvelope::Eip1559(tx) => Ok(Self::EIP1559(tx)), + TxEnvelope::Eip4844(tx) => Ok(Self::EIP4844(tx)), + TxEnvelope::Eip7702(tx) => Ok(Self::EIP7702(tx)), + _ => Err(ConversionError::Custom("UnsupportedTxType".to_string())), + }, + AnyTxEnvelope::Unknown(mut tx) => { + // Try to convert to deposit transaction + if tx.ty() == DEPOSIT_TX_TYPE_ID { + let nonce = get_field::(&tx.inner.fields, "nonce")?; + tx.inner.fields.insert("from".to_string(), serde_json::to_value(from).unwrap()); + let deposit_tx = + tx.inner.fields.deserialize_into::().map_err(|e| { + ConversionError::Custom(format!( + "Failed to deserialize deposit tx: {e}" + )) + })?; + + let TxDeposit { + source_hash, + is_system_transaction, + value, + gas_limit, + input, + mint, + from, + to, + } = deposit_tx; + + let deposit_tx = DepositTransaction { + nonce: nonce.to(), + source_hash, + from, + kind: to, + mint: mint.map(|m| U256::from(m)).unwrap_or_default(), + value, + gas_limit, + is_system_tx: is_system_transaction, + input, + }; + + return Ok(Self::Deposit(deposit_tx)); + }; + + Err(ConversionError::Custom("UnknownTxType".to_string())) + } + } + } +} + +fn get_field( + fields: &OtherFields, + key: &str, +) -> Result { + fields + .get_deserialized::(key) + .ok_or_else(|| ConversionError::Custom(format!("Missing{key}")))? + .map_err(|e| ConversionError::Custom(format!("Failed to deserialize {key}: {e}"))) +} + impl TypedTransaction { - /// Returns true if the transaction uses dynamic fees: EIP1559 or EIP4844 + /// Returns true if the transaction uses dynamic fees: EIP1559, EIP4844 or EIP7702 pub fn is_dynamic_fee(&self) -> bool { matches!(self, Self::EIP1559(_) | Self::EIP4844(_) | Self::EIP7702(_)) } @@ -992,168 +965,18 @@ impl TypedTransaction { } /// Returns the Signature of the transaction - pub fn signature(&self) -> Signature { + pub fn signature(&self) -> PrimitiveSignature { match self { Self::Legacy(tx) => *tx.signature(), Self::EIP2930(tx) => *tx.signature(), Self::EIP1559(tx) => *tx.signature(), Self::EIP4844(tx) => *tx.signature(), Self::EIP7702(tx) => *tx.signature(), - Self::Deposit(_) => Signature::from_scalars_and_parity( + Self::Deposit(_) => PrimitiveSignature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), - Parity::Parity(false), - ) - .unwrap(), - } - } -} - -impl TryFrom> for TypedTransaction { - type Error = ConversionError; - - fn try_from(tx: WithOtherFields) -> Result { - if tx.transaction_type.is_some_and(|t| t == 0x7E) { - let mint = tx - .other - .get_deserialized::("mint") - .ok_or(ConversionError::Custom("MissingMint".to_string()))? - .map_err(|_| ConversionError::Custom("Cannot deserialize mint".to_string()))?; - - let source_hash = tx - .other - .get_deserialized::("sourceHash") - .ok_or(ConversionError::Custom("MissingSourceHash".to_string()))? - .map_err(|_| { - ConversionError::Custom("Cannot deserialize source hash".to_string()) - })?; - - let deposit = DepositTransaction { - nonce: tx.nonce, - is_system_tx: true, - from: tx.from, - kind: tx.to.map(TxKind::Call).unwrap_or(TxKind::Create), - value: tx.value, - gas_limit: tx.gas, - input: tx.input.clone(), - mint, - source_hash, - }; - - return Ok(Self::Deposit(deposit)); - } - - let tx = tx.inner; - match tx.transaction_type.unwrap_or_default().try_into()? { - TxType::Legacy => { - let legacy = TxLegacy { - chain_id: tx.chain_id, - nonce: tx.nonce, - gas_price: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, - gas_limit: tx.gas, - value: tx.value, - input: tx.input, - to: tx.to.map_or(TxKind::Create, TxKind::Call), - }; - let signature = tx - .signature - .ok_or(ConversionError::MissingSignature)? - .try_into() - .map_err(ConversionError::SignatureError)?; - Ok(Self::Legacy(Signed::new_unchecked(legacy, signature, tx.hash))) - } - TxType::Eip1559 => { - let eip1559 = TxEip1559 { - chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, - nonce: tx.nonce, - max_fee_per_gas: tx - .max_fee_per_gas - .ok_or(ConversionError::MissingMaxFeePerGas)?, - max_priority_fee_per_gas: tx - .max_priority_fee_per_gas - .ok_or(ConversionError::MissingMaxPriorityFeePerGas)?, - gas_limit: tx.gas, - value: tx.value, - input: tx.input, - to: tx.to.map_or(TxKind::Create, TxKind::Call), - access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, - }; - let signature = tx - .signature - .ok_or(ConversionError::MissingSignature)? - .try_into() - .map_err(ConversionError::SignatureError)?; - Ok(Self::EIP1559(Signed::new_unchecked(eip1559, signature, tx.hash))) - } - TxType::Eip2930 => { - let eip2930 = TxEip2930 { - chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, - nonce: tx.nonce, - gas_price: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, - gas_limit: tx.gas, - value: tx.value, - input: tx.input, - to: tx.to.map_or(TxKind::Create, TxKind::Call), - access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, - }; - let signature = tx - .signature - .ok_or(ConversionError::MissingSignature)? - .try_into() - .map_err(ConversionError::SignatureError)?; - Ok(Self::EIP2930(Signed::new_unchecked(eip2930, signature, tx.hash))) - } - TxType::Eip4844 => { - let eip4844 = TxEip4844 { - chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, - nonce: tx.nonce, - gas_limit: tx.gas, - max_fee_per_gas: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, - max_priority_fee_per_gas: tx - .max_priority_fee_per_gas - .ok_or(ConversionError::MissingMaxPriorityFeePerGas)?, - max_fee_per_blob_gas: tx - .max_fee_per_blob_gas - .ok_or(ConversionError::MissingMaxFeePerBlobGas)?, - to: tx.to.ok_or(ConversionError::MissingTo)?, - value: tx.value, - access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, - blob_versioned_hashes: tx - .blob_versioned_hashes - .ok_or(ConversionError::MissingBlobVersionedHashes)?, - input: tx.input, - }; - Ok(Self::EIP4844(Signed::new_unchecked( - TxEip4844Variant::TxEip4844(eip4844), - tx.signature - .ok_or(ConversionError::MissingSignature)? - .try_into() - .map_err(ConversionError::SignatureError)?, - tx.hash, - ))) - } - TxType::Eip7702 => { - let eip7702 = TxEip7702 { - chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?, - nonce: tx.nonce, - gas_limit: tx.gas, - max_fee_per_gas: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?, - max_priority_fee_per_gas: tx - .max_priority_fee_per_gas - .ok_or(ConversionError::MissingMaxPriorityFeePerGas)?, - to: tx.to.ok_or(ConversionError::MissingTo)?, - value: tx.value, - access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?, - input: tx.input, - authorization_list: tx.authorization_list.unwrap_or_default(), - }; - let signature = tx - .signature - .ok_or(ConversionError::MissingSignature)? - .try_into() - .map_err(ConversionError::SignatureError)?; - Ok(Self::EIP7702(Signed::new_unchecked(eip7702, signature, tx.hash))) - } + false, + ), } } } @@ -1200,10 +1023,7 @@ impl Encodable2718 for TypedTransaction { Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), - Self::EIP7702(tx) => { - let payload_length = tx.tx().fields_len() + tx.signature().rlp_vrs_len(); - Header { list: true, payload_length }.length() + payload_length + 1 - } + Self::EIP7702(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), Self::Deposit(tx) => 1 + tx.length(), } } @@ -1214,7 +1034,7 @@ impl Encodable2718 for TypedTransaction { Self::EIP2930(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), Self::EIP1559(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), Self::EIP4844(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), - Self::EIP7702(tx) => tx.tx().encode_with_signature(tx.signature(), out, false), + Self::EIP7702(tx) => TxEnvelope::from(tx.clone()).encode_2718(out), Self::Deposit(tx) => { tx.encode_2718(out); } @@ -1224,15 +1044,14 @@ impl Encodable2718 for TypedTransaction { impl Decodable2718 for TypedTransaction { fn typed_decode(ty: u8, buf: &mut &[u8]) -> Result { - match ty { - 0x04 => return Ok(Self::EIP7702(TxEip7702::decode_signed_fields(buf)?)), - 0x7E => return Ok(Self::Deposit(DepositTransaction::decode(buf)?)), - _ => {} + if ty == 0x7E { + return Ok(Self::Deposit(DepositTransaction::decode(buf)?)) } match TxEnvelope::typed_decode(ty, buf)? { TxEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)), TxEnvelope::Eip1559(tx) => Ok(Self::EIP1559(tx)), TxEnvelope::Eip4844(tx) => Ok(Self::EIP4844(tx)), + TxEnvelope::Eip7702(tx) => Ok(Self::EIP7702(tx)), _ => unreachable!(), } } @@ -1703,7 +1522,7 @@ mod tests { chain_id: Some(4), }; - let signature = Signature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap(); + let signature = PrimitiveSignature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap(); let tx = TypedTransaction::Legacy(Signed::new_unchecked( tx, diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs deleted file mode 100644 index a604392801238..0000000000000 --- a/crates/anvil/core/src/eth/utils.rs +++ /dev/null @@ -1,13 +0,0 @@ -use alloy_primitives::Parity; - -/// See -/// > If you do, then the v of the signature MUST be set to {0,1} + CHAIN_ID * 2 + 35 where -/// > {0,1} is the parity of the y value of the curve point for which r is the x-value in the -/// > secp256k1 signing process. -pub fn meets_eip155(chain_id: u64, v: Parity) -> bool { - let double_chain_id = chain_id.saturating_mul(2); - match v { - Parity::Eip155(v) => v == double_chain_id + 35 || v == double_chain_id + 36, - _ => false, - } -} diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 5561758182ebe..714f91e6d7a80 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -15,12 +15,12 @@ use crate::{ mem::{self, in_memory_db::MemDb}, EthereumHardfork, FeeManager, PrecompileFactory, }; +use alloy_consensus::BlockHeader; use alloy_genesis::Genesis; -use alloy_network::AnyNetwork; +use alloy_network::{AnyNetwork, TransactionResponse}; use alloy_primitives::{hex, map::HashMap, utils::Unit, BlockNumber, TxHash, U256}; use alloy_provider::Provider; -use alloy_rpc_types::{Block, BlockNumberOrTag, Transaction}; -use alloy_serde::WithOtherFields; +use alloy_rpc_types::{Block, BlockNumberOrTag}; use alloy_signer::Signer; use alloy_signer_local::{ coins_bip39::{English, Mnemonic}, @@ -1291,12 +1291,15 @@ latest block number: {latest_block}" /// we only use the gas limit value of the block if it is non-zero and the block gas /// limit is enabled, since there are networks where this is not used and is always /// `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also - pub(crate) fn fork_gas_limit(&self, block: &Block>) -> u128 { + pub(crate) fn fork_gas_limit( + &self, + block: &Block, + ) -> u128 { if !self.disable_block_gas_limit { if let Some(gas_limit) = self.gas_limit { return gas_limit; - } else if block.header.gas_limit > 0 { - return block.header.gas_limit as u128; + } else if block.header.gas_limit() > 0 { + return block.header.gas_limit() as u128; } } @@ -1335,19 +1338,21 @@ async fn derive_block_and_transactions( // Get the block pertaining to the fork transaction let transaction_block = provider - .get_block_by_number(transaction_block_number.into(), true) + .get_block_by_number( + transaction_block_number.into(), + alloy_rpc_types::BlockTransactionsKind::Full, + ) .await? .ok_or(eyre::eyre!("Failed to get fork block by number"))?; // Filter out transactions that are after the fork transaction - let filtered_transactions: Vec<&alloy_serde::WithOtherFields> = - transaction_block - .transactions - .as_transactions() - .ok_or(eyre::eyre!("Failed to get transactions from full fork block"))? - .iter() - .take_while_inclusive(|&transaction| transaction.hash != transaction_hash.0) - .collect(); + let filtered_transactions = transaction_block + .transactions + .as_transactions() + .ok_or(eyre::eyre!("Failed to get transactions from full fork block"))? + .iter() + .take_while_inclusive(|&transaction| transaction.tx_hash() != transaction_hash.0) + .collect::>(); // Convert the transactions to PoolTransactions let force_transactions = filtered_transactions diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 6ee7c6d6014ab..daf9dc4a00f46 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -30,15 +30,16 @@ use crate::{ revm::primitives::{BlobExcessGasAndPrice, Output}, ClientFork, LoggingManager, Miner, MiningMode, StorageInfo, }; -use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account, TxEnvelope}; +use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account}; use alloy_dyn_abi::TypedData; use alloy_eips::eip2718::Encodable2718; use alloy_network::{ - eip2718::Decodable2718, BlockResponse, Ethereum, NetworkWallet, TransactionBuilder, + eip2718::Decodable2718, AnyRpcBlock, AnyRpcTransaction, BlockResponse, Ethereum, NetworkWallet, + TransactionBuilder, TransactionResponse, }; use alloy_primitives::{ map::{HashMap, HashSet}, - Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64, + Address, Bytes, PrimitiveSignature as Signature, TxHash, TxKind, B256, B64, U256, U64, }; use alloy_provider::utils::{ eip1559_default_estimator, EIP1559_FEE_ESTIMATION_PAST_BLOCKS, @@ -56,12 +57,10 @@ use alloy_rpc_types::{ parity::LocalizedTransactionTrace, }, txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, - AccessList, AccessListResult, AnyNetworkBlock, BlockId, BlockNumberOrTag as BlockNumber, - BlockTransactions, EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Index, Log, - Transaction, + AccessList, AccessListResult, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Index, Log, }; use alloy_serde::WithOtherFields; -use alloy_signer::Signature; use alloy_transport::TransportErrorKind; use anvil_core::{ eth::{ @@ -475,13 +474,11 @@ impl EthApi { ) -> Result { match request { TypedTransactionRequest::Deposit(_) => { - let nil_signature: alloy_primitives::Signature = - alloy_primitives::Signature::from_scalars_and_parity( - B256::with_last_byte(1), - B256::with_last_byte(1), - Parity::Parity(false), - ) - .unwrap(); + let nil_signature = Signature::from_scalars_and_parity( + B256::with_last_byte(1), + B256::with_last_byte(1), + false, + ); return build_typed_transaction(request, nil_signature) } _ => { @@ -514,10 +511,7 @@ impl EthApi { match self.pool.get_transaction(hash) { Some(tx) => Ok(Some(tx.transaction.encoded_2718().into())), None => match self.backend.transaction_by_hash(hash).await? { - Some(tx) => TxEnvelope::try_from(tx.inner) - .map_or(Err(BlockchainError::FailedToDecodeTransaction), |tx| { - Ok(Some(tx.encoded_2718().into())) - }), + Some(tx) => Ok(Some(tx.inner.inner.encoded_2718().into())), None => Ok(None), }, } @@ -742,7 +736,7 @@ impl EthApi { /// Returns block with given hash. /// /// Handler for ETH RPC call: `eth_getBlockByHash` - pub async fn block_by_hash(&self, hash: B256) -> Result> { + pub async fn block_by_hash(&self, hash: B256) -> Result> { node_info!("eth_getBlockByHash"); self.backend.block_by_hash(hash).await } @@ -750,7 +744,7 @@ impl EthApi { /// Returns a _full_ block with given hash. /// /// Handler for ETH RPC call: `eth_getBlockByHash` - pub async fn block_by_hash_full(&self, hash: B256) -> Result> { + pub async fn block_by_hash_full(&self, hash: B256) -> Result> { node_info!("eth_getBlockByHash"); self.backend.block_by_hash_full(hash).await } @@ -758,7 +752,7 @@ impl EthApi { /// Returns block with given number. /// /// Handler for ETH RPC call: `eth_getBlockByNumber` - pub async fn block_by_number(&self, number: BlockNumber) -> Result> { + pub async fn block_by_number(&self, number: BlockNumber) -> Result> { node_info!("eth_getBlockByNumber"); if number == BlockNumber::Pending { return Ok(Some(self.pending_block().await)); @@ -770,10 +764,7 @@ impl EthApi { /// Returns a _full_ block with given number /// /// Handler for ETH RPC call: `eth_getBlockByNumber` - pub async fn block_by_number_full( - &self, - number: BlockNumber, - ) -> Result> { + pub async fn block_by_number_full(&self, number: BlockNumber) -> Result> { node_info!("eth_getBlockByNumber"); if number == BlockNumber::Pending { return Ok(self.pending_block_full().await); @@ -1185,10 +1176,7 @@ impl EthApi { /// this will also scan the mempool for a matching pending transaction /// /// Handler for ETH RPC call: `eth_getTransactionByHash` - pub async fn transaction_by_hash( - &self, - hash: B256, - ) -> Result>> { + pub async fn transaction_by_hash(&self, hash: B256) -> Result> { node_info!("eth_getTransactionByHash"); let mut tx = self.pool.get_transaction(hash).map(|pending| { let from = *pending.sender(); @@ -1218,7 +1206,7 @@ impl EthApi { &self, hash: B256, index: Index, - ) -> Result>> { + ) -> Result> { node_info!("eth_getTransactionByBlockHashAndIndex"); self.backend.transaction_by_block_hash_and_index(hash, index).await } @@ -1230,7 +1218,7 @@ impl EthApi { &self, block: BlockNumber, idx: Index, - ) -> Result>> { + ) -> Result> { node_info!("eth_getTransactionByBlockNumberAndIndex"); self.backend.transaction_by_block_number_and_index(block, idx).await } @@ -1262,7 +1250,7 @@ impl EthApi { &self, block_hash: B256, idx: Index, - ) -> Result> { + ) -> Result> { node_info!("eth_getUncleByBlockHashAndIndex"); let number = self.backend.ensure_block_number(Some(BlockId::Hash(block_hash.into()))).await?; @@ -1282,7 +1270,7 @@ impl EthApi { &self, block_number: BlockNumber, idx: Index, - ) -> Result> { + ) -> Result> { node_info!("eth_getUncleByBlockNumberAndIndex"); let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?; if let Some(fork) = self.get_fork() { @@ -1544,7 +1532,7 @@ impl EthApi { ) -> Result> { node_info!("eth_getRawTransactionByBlockHashAndIndex"); match self.backend.transaction_by_block_hash_and_index(block_hash, index).await? { - Some(tx) => self.inner_raw_transaction(tx.hash).await, + Some(tx) => self.inner_raw_transaction(tx.tx_hash()).await, None => Ok(None), } } @@ -1559,7 +1547,7 @@ impl EthApi { ) -> Result> { node_info!("eth_getRawTransactionByBlockNumberAndIndex"); match self.backend.transaction_by_block_number_and_index(block_number, index).await? { - Some(tx) => self.inner_raw_transaction(tx.hash).await, + Some(tx) => self.inner_raw_transaction(tx.tx_hash()).await, None => Ok(None), } } @@ -2175,10 +2163,7 @@ impl EthApi { /// **Note**: This behaves exactly as [Self::evm_mine] but returns different output, for /// compatibility reasons, this is a separate call since `evm_mine` is not an anvil original. /// and `ganache` may change the `0x0` placeholder. - pub async fn evm_mine_detailed( - &self, - opts: Option, - ) -> Result> { + pub async fn evm_mine_detailed(&self, opts: Option) -> Result> { node_info!("evm_mine_detailed"); let mined_blocks = self.do_evm_mine(opts).await?; @@ -2196,7 +2181,7 @@ impl EthApi { BlockTransactions::Hashes(_) | BlockTransactions::Uncle => unreachable!(), }; for tx in block_txs.iter_mut() { - if let Some(receipt) = self.backend.mined_transaction_receipt(tx.hash) { + if let Some(receipt) = self.backend.mined_transaction_receipt(tx.tx_hash()) { if let Some(output) = receipt.out { // insert revert reason if failure if !receipt @@ -2359,10 +2344,10 @@ impl EthApi { /// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content) for more details /// /// Handler for ETH RPC call: `txpool_inspect` - pub async fn txpool_content(&self) -> Result { + pub async fn txpool_content(&self) -> Result> { node_info!("txpool_content"); - let mut content = TxpoolContent::default(); - fn convert(tx: Arc) -> Transaction { + let mut content = TxpoolContent::::default(); + fn convert(tx: Arc) -> Result { let from = *tx.pending_transaction.sender(); let mut tx = transaction_build( Some(tx.hash()), @@ -2375,18 +2360,19 @@ impl EthApi { // we set the from field here explicitly to the set sender of the pending transaction, // in case the transaction is impersonated. tx.from = from; - tx.inner + + Ok(tx) } for pending in self.pool.ready_transactions() { let entry = content.pending.entry(*pending.pending_transaction.sender()).or_default(); let key = pending.pending_transaction.nonce().to_string(); - entry.insert(key, convert(pending)); + entry.insert(key, convert(pending)?); } for queued in self.pool.pending_transactions() { let entry = content.pending.entry(*queued.pending_transaction.sender()).or_default(); let key = queued.pending_transaction.nonce().to_string(); - entry.insert(key, convert(queued)); + entry.insert(key, convert(queued)?); } Ok(content) @@ -2803,14 +2789,14 @@ impl EthApi { } /// Returns the pending block with tx hashes - async fn pending_block(&self) -> AnyNetworkBlock { + async fn pending_block(&self) -> AnyRpcBlock { let transactions = self.pool.ready_transactions().collect::>(); let info = self.backend.pending_block(transactions).await; self.backend.convert_block(info.block) } /// Returns the full pending block with `Transaction` objects - async fn pending_block_full(&self) -> Option { + async fn pending_block_full(&self) -> Option { let transactions = self.pool.ready_transactions().collect::>(); let BlockInfo { block, transactions, receipts: _ } = self.backend.pending_block(transactions).await; @@ -2925,7 +2911,7 @@ impl EthApi { TypedTransactionRequest::Legacy(_) => Signature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), - Parity::NonEip155(false), + false, ), TypedTransactionRequest::EIP2930(_) | TypedTransactionRequest::EIP1559(_) | @@ -2933,10 +2919,9 @@ impl EthApi { TypedTransactionRequest::Deposit(_) => Signature::from_scalars_and_parity( B256::with_last_byte(1), B256::with_last_byte(1), - Parity::Parity(false), + false, ), } - .unwrap() } /// Returns the nonce of the `address` depending on the `block_number` diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index 174933c3490a2..db34d9c1995e9 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -569,8 +569,8 @@ mod test { let block = r#"{ "header": { "parentHash": "0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929", - "ommersHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "beneficiary": "0x0000000000000000000000000000000000000000", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0000000000000000000000000000000000000000", "stateRoot": "0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1", "transactionsRoot": "0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988", "receiptsRoot": "0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa", diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 7d887f697572b..64852c802ae1e 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -3,7 +3,7 @@ use crate::eth::{backend::db::Db, error::BlockchainError, pool::transactions::PoolTransaction}; use alloy_consensus::Account; use alloy_eips::eip2930::AccessListResult; -use alloy_network::BlockResponse; +use alloy_network::{AnyRpcBlock, AnyRpcTransaction, BlockResponse, TransactionResponse}; use alloy_primitives::{ map::{FbHashMap, HashMap}, Address, Bytes, StorageValue, B256, U256, @@ -18,8 +18,8 @@ use alloy_rpc_types::{ geth::{GethDebugTracingOptions, GethTrace}, parity::LocalizedTransactionTrace as Trace, }, - AnyNetworkBlock, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, - EIP1186AccountProofResponse, FeeHistory, Filter, Log, Transaction, + BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, EIP1186AccountProofResponse, + FeeHistory, Filter, Log, }; use alloy_serde::WithOtherFields; use alloy_transport::TransportError; @@ -291,7 +291,7 @@ impl ClientFork { &self, number: u64, index: usize, - ) -> Result>, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_number(number).await? { match block.transactions() { BlockTransactions::Full(txs) => { @@ -315,7 +315,7 @@ impl ClientFork { &self, hash: B256, index: usize, - ) -> Result>, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_hash(hash).await? { match block.transactions() { BlockTransactions::Full(txs) => { @@ -338,7 +338,7 @@ impl ClientFork { pub async fn transaction_by_hash( &self, hash: B256, - ) -> Result>, TransportError> { + ) -> Result, TransportError> { trace!(target: "backend::fork", "transaction_by_hash={:?}", hash); if let tx @ Some(_) = self.storage_read().transactions.get(&hash).cloned() { return Ok(tx); @@ -450,10 +450,7 @@ impl ClientFork { Ok(None) } - pub async fn block_by_hash( - &self, - hash: B256, - ) -> Result, TransportError> { + pub async fn block_by_hash(&self, hash: B256) -> Result, TransportError> { if let Some(mut block) = self.storage_read().blocks.get(&hash).cloned() { block.transactions.convert_to_hashes(); return Ok(Some(block)); @@ -468,7 +465,7 @@ impl ClientFork { pub async fn block_by_hash_full( &self, hash: B256, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.storage_read().blocks.get(&hash).cloned() { return Ok(Some(self.convert_to_full_block(block))); } @@ -478,7 +475,7 @@ impl ClientFork { pub async fn block_by_number( &self, block_number: u64, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(mut block) = self .storage_read() .hashes @@ -499,7 +496,7 @@ impl ClientFork { pub async fn block_by_number_full( &self, block_number: u64, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self .storage_read() .hashes @@ -516,7 +513,7 @@ impl ClientFork { async fn fetch_full_block( &self, block_id: impl Into, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.provider().get_block(block_id.into(), true.into()).await? { let hash = block.header.hash; let block_number = block.header.number; @@ -526,7 +523,7 @@ impl ClientFork { BlockTransactions::Full(txs) => txs.to_owned(), _ => vec![], }; - storage.transactions.extend(block_txs.iter().map(|tx| (tx.hash, tx.clone()))); + storage.transactions.extend(block_txs.iter().map(|tx| (tx.tx_hash(), tx.clone()))); storage.hashes.insert(block_number, hash); storage.blocks.insert(hash, block.clone()); return Ok(Some(block)); @@ -539,7 +536,7 @@ impl ClientFork { &self, hash: B256, index: usize, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_hash(hash).await? { return self.uncles_by_block_and_index(block, index).await; } @@ -550,7 +547,7 @@ impl ClientFork { &self, number: u64, index: usize, - ) -> Result, TransportError> { + ) -> Result, TransportError> { if let Some(block) = self.block_by_number(number).await? { return self.uncles_by_block_and_index(block, index).await; } @@ -559,9 +556,9 @@ impl ClientFork { async fn uncles_by_block_and_index( &self, - block: AnyNetworkBlock, + block: AnyRpcBlock, index: usize, - ) -> Result, TransportError> { + ) -> Result, TransportError> { let block_hash = block.header.hash; let block_number = block.header.number; if let Some(uncles) = self.storage_read().uncles.get(&block_hash) { @@ -582,7 +579,7 @@ impl ClientFork { } /// Converts a block of hashes into a full block - fn convert_to_full_block(&self, mut block: AnyNetworkBlock) -> AnyNetworkBlock { + fn convert_to_full_block(&self, mut block: AnyRpcBlock) -> AnyRpcBlock { let storage = self.storage.read(); let block_txs_len = match block.transactions { BlockTransactions::Full(ref txs) => txs.len(), @@ -684,10 +681,10 @@ impl ClientForkConfig { /// This is used as a cache so repeated requests to the same data are not sent to the remote client #[derive(Clone, Debug, Default)] pub struct ForkedStorage { - pub uncles: FbHashMap<32, Vec>, - pub blocks: FbHashMap<32, AnyNetworkBlock>, + pub uncles: FbHashMap<32, Vec>, + pub blocks: FbHashMap<32, AnyRpcBlock>, pub hashes: HashMap, - pub transactions: FbHashMap<32, WithOtherFields>, + pub transactions: FbHashMap<32, AnyRpcTransaction>, pub transaction_receipts: FbHashMap<32, ReceiptResponse>, pub transaction_traces: FbHashMap<32, Vec>, pub logs: HashMap>, diff --git a/crates/anvil/src/eth/backend/info.rs b/crates/anvil/src/eth/backend/info.rs index 3ac359619d83e..0f539f9373dcb 100644 --- a/crates/anvil/src/eth/backend/info.rs +++ b/crates/anvil/src/eth/backend/info.rs @@ -1,9 +1,8 @@ //! Handler that can get current storage related data use crate::mem::Backend; +use alloy_network::AnyRpcBlock; use alloy_primitives::B256; -use alloy_rpc_types::{Block as AlloyBlock, Transaction}; -use alloy_serde::WithOtherFields; use anvil_core::eth::{block::Block, transaction::TypedReceipt}; use std::{fmt, sync::Arc}; @@ -43,10 +42,7 @@ impl StorageInfo { } /// Returns the block with the given hash in the format of the ethereum API - pub fn eth_block( - &self, - hash: B256, - ) -> Option>>> { + pub fn eth_block(&self, hash: B256) -> Option { let block = self.block(hash)?; Some(self.backend.convert_block(block)) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index c7ff9422a6e4a..0db343358fecc 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -34,9 +34,14 @@ use crate::{ ForkChoice, NodeConfig, PrecompileFactory, }; use alloy_chains::NamedChain; -use alloy_consensus::{Account, Header, Receipt, ReceiptWithBloom}; +use alloy_consensus::{ + Account, Header, Receipt, ReceiptWithBloom, Signed, Transaction as TransactionTrait, TxEnvelope, +}; use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK; -use alloy_network::EthereumWallet; +use alloy_network::{ + AnyHeader, AnyRpcBlock, AnyRpcTransaction, AnyTxEnvelope, AnyTxType, EthereumWallet, + UnknownTxEnvelope, UnknownTypedTransaction, +}; use alloy_primitives::{ address, hex, keccak256, utils::Unit, Address, Bytes, TxHash, TxKind, B256, U256, U64, }; @@ -53,21 +58,19 @@ use alloy_rpc_types::{ }, parity::LocalizedTransactionTrace, }, - AccessList, AnyNetworkBlock, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, - BlockTransactions, EIP1186AccountProofResponse as AccountProof, - EIP1186StorageProof as StorageProof, Filter, FilteredParams, Header as AlloyHeader, Index, Log, - Transaction, TransactionReceipt, + AccessList, Block as AlloyBlock, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, + EIP1186AccountProofResponse as AccountProof, EIP1186StorageProof as StorageProof, Filter, + FilteredParams, Header as AlloyHeader, Index, Log, Transaction, TransactionReceipt, }; -use alloy_serde::WithOtherFields; +use alloy_serde::{OtherFields, WithOtherFields}; use alloy_signer_local::PrivateKeySigner; use alloy_trie::{proof::ProofRetainer, HashBuilder, Nibbles}; use anvil_core::eth::{ block::{Block, BlockInfo}, transaction::{ - DepositReceipt, MaybeImpersonatedTransaction, PendingTransaction, ReceiptResponse, - TransactionInfo, TypedReceipt, TypedTransaction, + optimism::DepositTransaction, DepositReceipt, MaybeImpersonatedTransaction, + PendingTransaction, ReceiptResponse, TransactionInfo, TypedReceipt, TypedTransaction, }, - utils::meets_eip155, wallet::{Capabilities, DelegationCapability, WalletCapabilities}, }; use anvil_rpc::error::RpcError; @@ -89,6 +92,7 @@ use foundry_evm::{ traces::TracingInspectorConfig, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; +use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; use parking_lot::{Mutex, RwLock}; use revm::{ db::WrapDatabaseRef, @@ -1709,10 +1713,7 @@ impl Backend { } } - pub async fn block_by_hash( - &self, - hash: B256, - ) -> Result, BlockchainError> { + pub async fn block_by_hash(&self, hash: B256) -> Result, BlockchainError> { trace!(target: "backend", "get block by hash {:?}", hash); if let tx @ Some(_) = self.mined_block_by_hash(hash) { return Ok(tx); @@ -1728,7 +1729,7 @@ impl Backend { pub async fn block_by_hash_full( &self, hash: B256, - ) -> Result, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by hash {:?}", hash); if let tx @ Some(_) = self.get_full_block(hash) { return Ok(tx); @@ -1741,7 +1742,7 @@ impl Backend { Ok(None) } - fn mined_block_by_hash(&self, hash: B256) -> Option { + fn mined_block_by_hash(&self, hash: B256) -> Option { let block = self.blockchain.get_block_by_hash(&hash)?; Some(self.convert_block(block)) } @@ -1749,7 +1750,7 @@ impl Backend { pub(crate) async fn mined_transactions_by_block_number( &self, number: BlockNumber, - ) -> Option>> { + ) -> Option> { if let Some(block) = self.get_block(number) { return self.mined_transactions_in_block(&block); } @@ -1760,7 +1761,7 @@ impl Backend { pub(crate) fn mined_transactions_in_block( &self, block: &Block, - ) -> Option>> { + ) -> Option> { let mut transactions = Vec::with_capacity(block.transactions.len()); let base_fee = block.header.base_fee_per_gas; let storage = self.blockchain.storage.read(); @@ -1777,7 +1778,7 @@ impl Backend { pub async fn block_by_number( &self, number: BlockNumber, - ) -> Result, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by number {:?}", number); if let tx @ Some(_) = self.mined_block_by_number(number) { return Ok(tx); @@ -1796,7 +1797,7 @@ impl Backend { pub async fn block_by_number_full( &self, number: BlockNumber, - ) -> Result, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "get block by number {:?}", number); if let tx @ Some(_) = self.get_full_block(number) { return Ok(tx); @@ -1849,14 +1850,14 @@ impl Backend { self.blockchain.get_block_by_hash(&hash) } - pub fn mined_block_by_number(&self, number: BlockNumber) -> Option { + pub fn mined_block_by_number(&self, number: BlockNumber) -> Option { let block = self.get_block(number)?; let mut block = self.convert_block(block); block.transactions.convert_to_hashes(); Some(block) } - pub fn get_full_block(&self, id: impl Into) -> Option { + pub fn get_full_block(&self, id: impl Into) -> Option { let block = self.get_block(id)?; let transactions = self.mined_transactions_in_block(&block)?; let mut block = self.convert_block(block); @@ -1866,63 +1867,21 @@ impl Backend { } /// Takes a block as it's stored internally and returns the eth api conform block format. - pub fn convert_block(&self, block: Block) -> AnyNetworkBlock { + pub fn convert_block(&self, block: Block) -> AnyRpcBlock { let size = U256::from(alloy_rlp::encode(&block).len() as u32); let Block { header, transactions, .. } = block; let hash = header.hash_slow(); - let Header { - parent_hash, - ommers_hash, - beneficiary, - state_root, - transactions_root, - receipts_root, - logs_bloom, - difficulty, - number, - gas_limit, - gas_used, - timestamp, - requests_hash, - extra_data, - mix_hash, - nonce, - base_fee_per_gas, - withdrawals_root, - blob_gas_used, - excess_blob_gas, - parent_beacon_block_root, - } = header; + let Header { number, withdrawals_root, .. } = header; let block = AlloyBlock { header: AlloyHeader { + inner: AnyHeader::from(header), hash, - parent_hash, - uncles_hash: ommers_hash, - miner: beneficiary, - state_root, - transactions_root, - receipts_root, - number, - gas_used, - gas_limit, - extra_data: extra_data.0.into(), - logs_bloom, - timestamp, total_difficulty: Some(self.total_difficulty()), - difficulty, - mix_hash: Some(mix_hash), - nonce: Some(nonce), - base_fee_per_gas, - withdrawals_root, - blob_gas_used, - excess_blob_gas, - parent_beacon_block_root, - requests_hash, + size: Some(size), }, - size: Some(size), transactions: alloy_rpc_types::BlockTransactions::Hashes( transactions.into_iter().map(|tx| tx.hash()).collect(), ), @@ -2030,7 +1989,7 @@ impl Backend { if let Some(state) = self.states.write().get(&block_hash) { let block = BlockEnv { number: block_number, - coinbase: block.header.miner, + coinbase: block.header.beneficiary, timestamp: U256::from(block.header.timestamp), difficulty: block.header.difficulty, prevrandao: block.header.mix_hash, @@ -2469,7 +2428,7 @@ impl Backend { &self, number: BlockNumber, index: Index, - ) -> Result>, BlockchainError> { + ) -> Result, BlockchainError> { if let Some(block) = self.mined_block_by_number(number) { return Ok(self.mined_transaction_by_block_hash_and_index(block.header.hash, index)); } @@ -2488,7 +2447,7 @@ impl Backend { &self, hash: B256, index: Index, - ) -> Result>, BlockchainError> { + ) -> Result, BlockchainError> { if let tx @ Some(_) = self.mined_transaction_by_block_hash_and_index(hash, index) { return Ok(tx); } @@ -2504,7 +2463,7 @@ impl Backend { &self, block_hash: B256, index: Index, - ) -> Option> { + ) -> Option { let (info, block, tx) = { let storage = self.blockchain.storage.read(); let block = storage.blocks.get(&block_hash).cloned()?; @@ -2526,7 +2485,7 @@ impl Backend { pub async fn transaction_by_hash( &self, hash: B256, - ) -> Result>, BlockchainError> { + ) -> Result, BlockchainError> { trace!(target: "backend", "transaction_by_hash={:?}", hash); if let tx @ Some(_) = self.mined_transaction_by_hash(hash) { return Ok(tx); @@ -2539,7 +2498,7 @@ impl Backend { Ok(None) } - pub fn mined_transaction_by_hash(&self, hash: B256) -> Option> { + pub fn mined_transaction_by_hash(&self, hash: B256) -> Option { let (info, block) = { let storage = self.blockchain.storage.read(); let MinedTransaction { info, block_hash, .. } = @@ -2604,7 +2563,7 @@ impl Backend { .map(|(key, proof)| { let storage_key: U256 = key.into(); let value = account.storage.get(&storage_key).cloned().unwrap_or_default(); - StorageProof { key: JsonStorageKey(key), value, proof } + StorageProof { key: JsonStorageKey::Hash(key), value, proof } }) .collect(), }; @@ -2749,7 +2708,7 @@ impl TransactionValidator for Backend { if let Some(legacy) = tx.as_legacy() { // if env.handler_cfg.spec_id >= SpecId::SPURIOUS_DRAGON && - !meets_eip155(chain_id.to::(), legacy.signature().v()) + legacy.tx().chain_id.is_none() { warn!(target: "backend", ?chain_id, ?tx_chain_id, "incompatible EIP155-based V"); return Err(InvalidTransactionError::IncompatibleEIP155); @@ -2880,7 +2839,7 @@ impl TransactionValidator for Backend { } } -/// Creates a `Transaction` as it's expected for the `eth` RPC api from storage data +/// Creates a `AnyRpcTransaction` as it's expected for the `eth` RPC api from storage data #[allow(clippy::too_many_arguments)] pub fn transaction_build( tx_hash: Option, @@ -2888,56 +2847,134 @@ pub fn transaction_build( block: Option<&Block>, info: Option, base_fee: Option, -) -> WithOtherFields { - let mut transaction: Transaction = eth_transaction.clone().into(); - if info.is_some() && transaction.transaction_type == Some(0x7E) { - transaction.nonce = info.as_ref().unwrap().nonce; - } +) -> AnyRpcTransaction { + if let TypedTransaction::Deposit(ref deposit_tx) = eth_transaction.transaction { + let DepositTransaction { + nonce: _, + source_hash, + from, + kind, + mint, + gas_limit, + is_system_tx, + input, + value, + } = deposit_tx.clone(); + + let dep_tx = TxDeposit { + source_hash, + input, + from, + mint: Some(mint.to()), + to: kind, + is_system_transaction: is_system_tx, + value, + gas_limit, + }; - if eth_transaction.is_dynamic_fee() { - if block.is_none() && info.is_none() { - // transaction is not mined yet, gas price is considered just `max_fee_per_gas` - transaction.gas_price = transaction.max_fee_per_gas; - } else { - // if transaction is already mined, gas price is considered base fee + priority fee: the - // effective gas price. - let base_fee = base_fee.map_or(0u128, |g| g as u128); - let max_priority_fee_per_gas = transaction.max_priority_fee_per_gas.unwrap_or(0); - transaction.gas_price = Some(base_fee.saturating_add(max_priority_fee_per_gas)); + let ser = serde_json::to_value(&dep_tx).unwrap(); + let maybe_deposit_fields = OtherFields::try_from(ser); + + match maybe_deposit_fields { + Ok(fields) => { + let inner = UnknownTypedTransaction { + ty: AnyTxType(DEPOSIT_TX_TYPE_ID), + fields, + memo: Default::default(), + }; + + let envelope = AnyTxEnvelope::Unknown(UnknownTxEnvelope { + hash: eth_transaction.hash(), + inner, + }); + + let tx = Transaction { + inner: envelope, + block_hash: block + .as_ref() + .map(|block| B256::from(keccak256(alloy_rlp::encode(&block.header)))), + block_number: block.as_ref().map(|block| block.header.number), + transaction_index: info.as_ref().map(|info| info.transaction_index), + effective_gas_price: None, + from, + }; + + return WithOtherFields::new(tx); + } + Err(_) => { + error!(target: "backend", "failed to serialize deposit transaction"); + } } - } else { - transaction.max_fee_per_gas = None; - transaction.max_priority_fee_per_gas = None; } - transaction.block_hash = - block.as_ref().map(|block| B256::from(keccak256(alloy_rlp::encode(&block.header)))); + let mut transaction: Transaction = eth_transaction.clone().into(); - transaction.block_number = block.as_ref().map(|block| block.header.number); + let effective_gas_price = if !eth_transaction.is_dynamic_fee() { + transaction.effective_gas_price(base_fee) + } else if block.is_none() && info.is_none() { + // transaction is not mined yet, gas price is considered just `max_fee_per_gas` + transaction.max_fee_per_gas() + } else { + // if transaction is already mined, gas price is considered base fee + priority + // fee: the effective gas price. + let base_fee = base_fee.map_or(0u128, |g| g as u128); + let max_priority_fee_per_gas = transaction.max_priority_fee_per_gas().unwrap_or(0); - transaction.transaction_index = info.as_ref().map(|info| info.transaction_index); + base_fee.saturating_add(max_priority_fee_per_gas) + }; - // need to check if the signature of the transaction is impersonated, if so then we - // can't recover the sender, instead we use the sender from the executed transaction and set the - // impersonated hash. - if eth_transaction.is_impersonated() { - transaction.from = info.as_ref().map(|info| info.from).unwrap_or_default(); - transaction.hash = eth_transaction.impersonated_hash(transaction.from); - } else { - transaction.from = eth_transaction.recover().expect("can recover signed tx"); - } + transaction.effective_gas_price = Some(effective_gas_price); - // if a specific hash was provided we update the transaction's hash - // This is important for impersonated transactions since they all use the `BYPASS_SIGNATURE` - // which would result in different hashes - // Note: for impersonated transactions this only concerns pending transactions because there's - // no `info` yet. - if let Some(tx_hash) = tx_hash { - transaction.hash = tx_hash; - } + let envelope = transaction.inner; - transaction.to = info.as_ref().map_or(eth_transaction.to(), |status| status.to); - WithOtherFields::new(transaction) + // if a specific hash was provided we update the transaction's hash + // This is important for impersonated transactions since they all use the + // `BYPASS_SIGNATURE` which would result in different hashes + // Note: for impersonated transactions this only concerns pending transactions because + // there's // no `info` yet. + let hash = tx_hash.unwrap_or(*envelope.tx_hash()); + + let envelope = match envelope { + TxEnvelope::Legacy(signed_tx) => { + let (t, sig, _) = signed_tx.into_parts(); + let new_signed = Signed::new_unchecked(t, sig, hash); + AnyTxEnvelope::Ethereum(TxEnvelope::Legacy(new_signed)) + } + TxEnvelope::Eip1559(signed_tx) => { + let (t, sig, _) = signed_tx.into_parts(); + let new_signed = Signed::new_unchecked(t, sig, hash); + AnyTxEnvelope::Ethereum(TxEnvelope::Eip1559(new_signed)) + } + TxEnvelope::Eip2930(signed_tx) => { + let (t, sig, _) = signed_tx.into_parts(); + let new_signed = Signed::new_unchecked(t, sig, hash); + AnyTxEnvelope::Ethereum(TxEnvelope::Eip2930(new_signed)) + } + TxEnvelope::Eip4844(signed_tx) => { + let (t, sig, _) = signed_tx.into_parts(); + let new_signed = Signed::new_unchecked(t, sig, hash); + AnyTxEnvelope::Ethereum(TxEnvelope::Eip4844(new_signed)) + } + TxEnvelope::Eip7702(signed_tx) => { + let (t, sig, _) = signed_tx.into_parts(); + let new_signed = Signed::new_unchecked(t, sig, hash); + AnyTxEnvelope::Ethereum(TxEnvelope::Eip7702(new_signed)) + } + _ => unreachable!("unknown tx type"), + }; + + let tx = Transaction { + inner: envelope, + block_hash: block + .as_ref() + .map(|block| B256::from(keccak256(alloy_rlp::encode(&block.header)))), + block_number: block.as_ref().map(|block| block.header.number), + transaction_index: info.as_ref().map(|info| info.transaction_index), + from: eth_transaction.recover().expect("can recover signed tx"), + // deprecated + effective_gas_price: Some(effective_gas_price), + }; + WithOtherFields::new(tx) } /// Prove a storage key's existence or nonexistence in the account's storage trie. diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 0c478ee061d9c..394f33492e8d6 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -90,6 +90,8 @@ pub enum BlockchainError { EIP7702TransactionUnsupportedAtHardfork, #[error("op-stack deposit tx received but is not supported.\n\nYou can use it by running anvil with '--optimism'.")] DepositTransactionUnsupported, + #[error("UnknownTransactionType not supported ")] + UnknownTransactionType, #[error("Excess blob gas not set.")] ExcessBlobGasNotSet, #[error("{0}")] @@ -463,6 +465,9 @@ impl ToRpcResponseResult for Result { RpcError::invalid_params(err.to_string()) } err @ BlockchainError::Message(_) => RpcError::internal_error_with(err.to_string()), + err @ BlockchainError::UnknownTransactionType => { + RpcError::invalid_params(err.to_string()) + } } .into(), } diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index e73fe4dd6647a..617655444bef6 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -3,7 +3,11 @@ use crate::eth::{ macros::node_info, EthApi, }; -use alloy_network::BlockResponse; +use alloy_consensus::Transaction as TransactionTrait; +use alloy_network::{ + AnyHeader, AnyRpcBlock, AnyRpcHeader, AnyRpcTransaction, AnyTxEnvelope, BlockResponse, + TransactionResponse, +}; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_rpc_types::{ trace::{ @@ -16,10 +20,8 @@ use alloy_rpc_types::{ RewardAction, TraceOutput, }, }, - AnyNetworkBlock, Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, - Transaction, + Block, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions, }; -use alloy_serde::WithOtherFields; use itertools::Itertools; use futures::future::join_all; @@ -90,7 +92,7 @@ impl EthApi { pub async fn erigon_get_header_by_number( &self, number: BlockNumber, - ) -> Result> { + ) -> Result> { node_info!("ots_getApiLevel"); self.backend.block_by_number(number).await @@ -146,7 +148,10 @@ impl EthApi { /// For simplicity purposes, we return the entire block instead of emptying the values that /// Otterscan doesn't want. This is the original purpose of the endpoint (to save bandwidth), /// but it doesn't seem necessary in the context of an anvil node - pub async fn ots_get_block_details(&self, number: BlockNumber) -> Result { + pub async fn ots_get_block_details( + &self, + number: BlockNumber, + ) -> Result> { node_info!("ots_getBlockDetails"); if let Some(block) = self.backend.block_by_number(number).await? { @@ -160,7 +165,10 @@ impl EthApi { /// For simplicity purposes, we return the entire block instead of emptying the values that /// Otterscan doesn't want. This is the original purpose of the endpoint (to save bandwidth), /// but it doesn't seem necessary in the context of an anvil node - pub async fn ots_get_block_details_by_hash(&self, hash: B256) -> Result { + pub async fn ots_get_block_details_by_hash( + &self, + hash: B256, + ) -> Result> { node_info!("ots_getBlockDetailsByHash"); if let Some(block) = self.backend.block_by_hash(hash).await? { @@ -178,7 +186,7 @@ impl EthApi { number: u64, page: usize, page_size: usize, - ) -> Result>> { + ) -> Result> { node_info!("ots_getBlockTransactions"); match self.backend.block_by_number_full(number.into()).await? { @@ -193,7 +201,7 @@ impl EthApi { address: Address, block_number: u64, page_size: usize, - ) -> Result { + ) -> Result>> { node_info!("ots_searchTransactionsBefore"); let best = self.backend.best_number(); @@ -236,7 +244,7 @@ impl EthApi { address: Address, block_number: u64, page_size: usize, - ) -> Result { + ) -> Result>> { node_info!("ots_searchTransactionsAfter"); let best = self.backend.best_number(); @@ -295,8 +303,8 @@ impl EthApi { for n in (from..=to).rev() { if let Some(txs) = self.backend.mined_transactions_by_block_number(n.into()).await { for tx in txs { - if U256::from(tx.nonce) == nonce && tx.from == address { - return Ok(Some(tx.hash)); + if U256::from(tx.nonce()) == nonce && tx.from == address { + return Ok(Some(tx.tx_hash())); } } } @@ -352,7 +360,10 @@ impl EthApi { /// based on the existing list. /// /// Therefore we keep it simple by keeping the data in the response - pub async fn build_ots_block_details(&self, block: AnyNetworkBlock) -> Result { + pub async fn build_ots_block_details( + &self, + block: AnyRpcBlock, + ) -> Result>> { if block.transactions.is_uncle() { return Err(BlockchainError::DataUnavailable); } @@ -375,15 +386,10 @@ impl EthApi { .iter() .fold(0, |acc, receipt| acc + receipt.gas_used * receipt.effective_gas_price); - let Block { header, uncles, transactions, size, withdrawals } = block.inner; + let Block { header, uncles, transactions, withdrawals } = block.inner; - let block = OtsSlimBlock { - header, - uncles, - transaction_count: transactions.len(), - size, - withdrawals, - }; + let block = + OtsSlimBlock { header, uncles, transaction_count: transactions.len(), withdrawals }; Ok(BlockDetails { block, @@ -399,10 +405,10 @@ impl EthApi { /// [`ots_getBlockTransactions`]: https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails pub async fn build_ots_block_tx( &self, - mut block: AnyNetworkBlock, + mut block: AnyRpcBlock, page: usize, page_size: usize, - ) -> Result>> { + ) -> Result> { if block.transactions.is_uncle() { return Err(BlockchainError::DataUnavailable); } @@ -436,8 +442,7 @@ impl EthApi { let transaction_count = block.transactions().len(); let fullblock = OtsBlock { block: block.inner, transaction_count }; - let ots_block_txs = - OtsBlockTransactions::> { fullblock, receipts }; + let ots_block_txs = OtsBlockTransactions { fullblock, receipts }; Ok(ots_block_txs) } @@ -447,7 +452,7 @@ impl EthApi { hashes: Vec, first_page: bool, last_page: bool, - ) -> Result { + ) -> Result>> { let txs_futs = hashes.iter().map(|hash| async { self.transaction_by_hash(*hash).await }); let txs = join_all(txs_futs) diff --git a/crates/anvil/src/eth/pool/transactions.rs b/crates/anvil/src/eth/pool/transactions.rs index 631064549ce70..36e421d7a50e1 100644 --- a/crates/anvil/src/eth/pool/transactions.rs +++ b/crates/anvil/src/eth/pool/transactions.rs @@ -1,10 +1,9 @@ use crate::eth::{error::PoolError, util::hex_fmt_many}; +use alloy_network::AnyRpcTransaction; use alloy_primitives::{ map::{HashMap, HashSet}, Address, TxHash, }; -use alloy_rpc_types::Transaction as RpcTransaction; -use alloy_serde::WithOtherFields; use anvil_core::eth::transaction::{PendingTransaction, TypedTransaction}; use parking_lot::RwLock; use std::{cmp::Ordering, collections::BTreeSet, fmt, str::FromStr, sync::Arc, time::Instant}; @@ -113,10 +112,10 @@ impl fmt::Debug for PoolTransaction { } } -impl TryFrom> for PoolTransaction { +impl TryFrom for PoolTransaction { type Error = eyre::Error; - fn try_from(transaction: WithOtherFields) -> Result { - let typed_transaction = TypedTransaction::try_from(transaction)?; + fn try_from(value: AnyRpcTransaction) -> Result { + let typed_transaction = TypedTransaction::try_from(value)?; let pending_transaction = PendingTransaction::new(typed_transaction)?; Ok(Self { pending_transaction, diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index 5f99ef9ca17d8..e2ea036a0cafb 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -2,7 +2,7 @@ use crate::eth::error::BlockchainError; use alloy_consensus::SignableTransaction; use alloy_dyn_abi::TypedData; use alloy_network::TxSignerSync; -use alloy_primitives::{map::AddressHashMap, Address, Signature, B256, U256}; +use alloy_primitives::{map::AddressHashMap, Address, PrimitiveSignature as Signature, B256, U256}; use alloy_signer::Signer as AlloySigner; use alloy_signer_local::PrivateKeySigner; use anvil_core::eth::transaction::{ diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index f9ba36b60f6c6..022e7dd978427 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -3,10 +3,10 @@ #![allow(rustdoc::private_doc_tests)] use crate::{shutdown::Shutdown, tasks::block_listener::BlockListener, EthApi}; -use alloy_network::AnyNetwork; +use alloy_network::{AnyHeader, AnyNetwork}; use alloy_primitives::B256; use alloy_provider::Provider; -use alloy_rpc_types::{anvil::Forking, AnyNetworkBlock}; +use alloy_rpc_types::anvil::Forking; use alloy_transport::Transport; use futures::StreamExt; use std::{fmt, future::Future}; @@ -129,13 +129,13 @@ impl TaskManager { P: Provider + 'static, T: Transport + Clone, { - self.spawn_block_subscription(provider, move |block| { + self.spawn_block_subscription(provider, move |header| { let api = api.clone(); async move { let _ = api .anvil_reset(Some(Forking { json_rpc_url: None, - block_number: Some(block.header.number), + block_number: Some(header.number), })) .await; } @@ -149,7 +149,7 @@ impl TaskManager { where P: Provider + 'static, T: Transport + Clone, - F: Fn(AnyNetworkBlock) -> Fut + Unpin + Send + Sync + 'static, + F: Fn(alloy_rpc_types::Header) -> Fut + Unpin + Send + Sync + 'static, Fut: Future + Send, { let shutdown = self.on_shutdown.clone(); diff --git a/crates/anvil/test-data/state-dump-legacy-stress.json b/crates/anvil/test-data/state-dump-legacy-stress.json index 50df9e03906ef..f6605d5add4e3 100644 --- a/crates/anvil/test-data/state-dump-legacy-stress.json +++ b/crates/anvil/test-data/state-dump-legacy-stress.json @@ -1 +1 @@ -{"block":{"number":"0x5","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66b200cb","gas_limit":"0x1c9c380","basefee":"0x12e09c7a","difficulty":"0x0","prevrandao":"0xe7ef87fc7c2090741a6749a087e4ca8092cb4d07136008799e4ebeac3b69e34a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0x1088aa62285a00","code":"0x","storage":{}},"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd":{"nonce":1,"balance":"0x0","code":"0x6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x19ba1fac55eea44d12a01372a8eb0c2ebbf9ca21":{"nonce":1,"balance":"0x21e19df7c2963f0ac6b","code":"0x","storage":{}},"0x19c6ab860dbe2bc433574193a4409770a8748bf6":{"nonce":1,"balance":"0x21e19df8da6b7bdc410","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x40567ec443c1d1872af5155755ac3803cc3fe61e":{"nonce":1,"balance":"0x21e19da82562f921b40","code":"0x","storage":{}},"0x47d08dad17ccb558b3ea74b1a0e73a9cc804a9dc":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","storage":{"0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0x0"}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":2,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x8138ef7cf908021d117e542120b7a39065016107":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","storage":{}},"0x83a0444b93927c3afcbe46e522280390f748e171":{"nonce":1,"balance":"0x0","code":"0x6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c63430008110033","storage":{"0x5a648c35a2f5512218b4683cf10e03f5b7c9dc7346e1bf77d304ae97f60f592b":"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xc67e2bd3108604cf0168c0e5ef9cd6d78b9bb14b":{"nonce":1,"balance":"0x21e19c6edb7e2445f20","code":"0x","storage":{}},"0xeb045d78d273107348b0300c01d29b7552d622ab":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e08b86820a43ea","code":"0x","storage":{}}},"best_block_number":"0x5","blocks":[{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xcd346446ed010523161f40a5f2b512def549bfb79e165b4354488738416481f2","transactionsRoot":"0xb3a4689832e0b599260ae70362ffcf224b60571b35ff8836904a3d81e2675d66","receiptsRoot":"0x2d13fdc120ab90536fed583939de7fb68b64926a306c1f629593ca9c2c93b198","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x3ea90d","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x2e0b6260","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3ea90d","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b5061494f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xbc73db80bf4b8784ba10a8910a0b7ef85f6846d102b41dd990969ea205335354"}}],"ommers":[]},{"header":{"parentHash":"0x026ae0c6ae91f186a9befa1ac8be30eea35e30e77de51a731085221e5cd39209","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x6e4969a136061ca7a390d12830d47a151585325a8d396819fb2b958ff85e9f8f","receiptsRoot":"0xc3e81df67d3e2a6c8345a954ef250cfcc41abcc2292a5aa263071124533fc9ad","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x3c0f6","timestamp":"0x66b200ce","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x18993a68","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3c0f6","maxFeePerGas":"0x5d4285cd","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b50610380806100206000396000f3fe6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x2476e039803622aeb040f924f04c493f559aed3d6c9372ab405cb33c8c695328"}}],"ommers":[]},{"header":{"parentHash":"0x3d22100ac0ee8d5cde334f7f926191a861b0648971ebc179547df28a0224c6d0","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9511d4711e5c30a72b0bff38a261daa75dcc5ba8b772d970a5c742244b4c861b","transactionsRoot":"0xba5fff578d3d6c2cd63acbe9bca353eaa6fe22a5c408956eff49106e0a96c507","receiptsRoot":"0xbae111f01cb07677e3a8c5031546138407c01bc964d3493d732dc4edf47d36d3","logsBloom":"0x00000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000020000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000001000000000000000000000400000001000010000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x5","gasLimit":"0x1c9c380","gasUsed":"0xcae7","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x12e09c7a","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0xcc4d","maxFeePerGas":"0x557e5ec4","maxPriorityFeePerGas":"0x3b9aca00","to":"0x83a0444b93927c3afcbe46e522280390f748e171","value":"0x0","accessList":[],"input":"0x3659cfe6000000000000000000000000108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xf88e7b19ee347145c257e0cf7ac4ecc2bae83ca79d7edaa231e71d3213aeb151"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x9c8eaf493f8b4edce2ba1647343eadcc0989cf461e712c0a6253ff2ca1842bb7","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xdd07c07470e1deff3749831f0f1ad8d4b6e35505e83b3c6ea14181716197cd8a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x24a1ab52","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200c9","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xf6930be4847cac5017bbcbec2756eed19f36b4196526a98a88e311c296e3a9be","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cc","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x200d75e8","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x4","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1592fbf9","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x149d41e3b89d8324cef3feff98ef308e97bafe8745cc8461c60172bc7d4c44ba","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x0b44110186e52ff0ceb6b0776ca2992c94144a4ed712eef65ea038260ef0fcc7","receiptsRoot":"0xc2823b8eb4730d9f2657137cc2ddc2c4f22ab68e0ab826236cf6a1551ca2b3a5","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0xe61f9","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342770c0","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0xe94d1","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060008061002661006d60201b61081b1760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610141565b60008060405160200161007f90610121565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b600061010b60238361009e565b9150610116826100af565b604082019050919050565b6000602082019050818103600083015261013a816100fe565b9050919050565b611000806101506000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x4feae6769d748b4f0f7c9bf21d782236c88f13906789a3ec602961296e4c3e43"}}],"ommers":[]},{"header":{"parentHash":"0xb3535af5103fd1c2bbd6dc7ff23f0799037a6542c231ebcb85abd776560fa512","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x23d74fb99ff6e42cbb5c33f92b078e37be6af2b6092459b103ff7059a6517ebc","transactionsRoot":"0x9eab45eca206fe11c107ea985c7d02fcfa442836aea3e04ba11dc4df587d5aa6","receiptsRoot":"0xe25abcfa973db8c55f73292137c626430de130a382ad4466337fefb0f7c8fde0","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x3ce3f","timestamp":"0x66b200cd","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1c0bc72b","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3d8a8","maxFeePerGas":"0x6211577c","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060405161068538038061068583398181016040528101906100329190610275565b818181600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361009b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100ae8161019d60201b61004f1760201c565b6100ef57806040517f8a8b41ec0000000000000000000000000000000000000000000000000000000081526004016100e691906102c4565b60405180910390fd5b806100fe6101b060201b60201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050806101536101e160201b6100621760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050610414565b600080823b905060008111915050919050565b6000806040516020016101c290610362565b6040516020818303038152906040528051906020012090508091505090565b6000806040516020016101f3906103f4565b6040516020818303038152906040528051906020012090508091505090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061024282610217565b9050919050565b61025281610237565b811461025d57600080fd5b50565b60008151905061026f81610249565b92915050565b6000806040838503121561028c5761028b610212565b5b600061029a85828601610260565b92505060206102ab85828601610260565b9150509250929050565b6102be81610237565b82525050565b60006020820190506102d960008301846102b5565b92915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b600061034c6021836102df565b9150610357826102f0565b604082019050919050565b6000602082019050818103600083015261037b8161033f565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006103de6023836102df565b91506103e982610382565b604082019050919050565b6000602082019050818103600083015261040d816103d1565b9050919050565b610262806104236000396000f3fe6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c6343000811003300000000000000000000000047d08dad17ccb558b3ea74b1a0e73a9cc804a9dc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xb6794d5c7abed6f91d447e8efb72ef2580595a6d7c8dee57ba1dbb330970146a"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x29dd5614","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]}]} \ No newline at end of file +{"block":{"number":"0x5","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66b200cb","gas_limit":"0x1c9c380","basefee":"0x12e09c7a","difficulty":"0x0","prevrandao":"0xe7ef87fc7c2090741a6749a087e4ca8092cb4d07136008799e4ebeac3b69e34a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0x1088aa62285a00","code":"0x","storage":{}},"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd":{"nonce":1,"balance":"0x0","code":"0x6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x19ba1fac55eea44d12a01372a8eb0c2ebbf9ca21":{"nonce":1,"balance":"0x21e19df7c2963f0ac6b","code":"0x","storage":{}},"0x19c6ab860dbe2bc433574193a4409770a8748bf6":{"nonce":1,"balance":"0x21e19df8da6b7bdc410","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x40567ec443c1d1872af5155755ac3803cc3fe61e":{"nonce":1,"balance":"0x21e19da82562f921b40","code":"0x","storage":{}},"0x47d08dad17ccb558b3ea74b1a0e73a9cc804a9dc":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","storage":{"0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0x0"}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":2,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x8138ef7cf908021d117e542120b7a39065016107":{"nonce":1,"balance":"0x0","code":"0x608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","storage":{}},"0x83a0444b93927c3afcbe46e522280390f748e171":{"nonce":1,"balance":"0x0","code":"0x6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c63430008110033","storage":{"0x5a648c35a2f5512218b4683cf10e03f5b7c9dc7346e1bf77d304ae97f60f592b":"0x108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","0x5c7865864a2a990d80b5bb5c40e7b73a029960dc711fbb56120dfab976e92ea3":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xc67e2bd3108604cf0168c0e5ef9cd6d78b9bb14b":{"nonce":1,"balance":"0x21e19c6edb7e2445f20","code":"0x","storage":{}},"0xeb045d78d273107348b0300c01d29b7552d622ab":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e08b86820a43ea","code":"0x","storage":{}}},"best_block_number":"0x5","blocks":[{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0xcd346446ed010523161f40a5f2b512def549bfb79e165b4354488738416481f2","transactionsRoot":"0xb3a4689832e0b599260ae70362ffcf224b60571b35ff8836904a3d81e2675d66","receiptsRoot":"0x2d13fdc120ab90536fed583939de7fb68b64926a306c1f629593ca9c2c93b198","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x3ea90d","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x2e0b6260","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3ea90d","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b5061494f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632a952b2d1461005c57806350c946fe14610085578063625ca21c146100a5578063daa250be146100c6578063deba1b98146100d9575b600080fd5b61006f61006a366004613a63565b6100ec565b60405161007c9190613a7c565b60405180910390f35b610098610093366004613a63565b61011c565b60405161007c9190613b21565b6100b86100b3366004613c92565b610276565b60405190815260200161007c565b61006f6100d4366004613d5f565b6102bb565b6100b86100e7366004613c92565b6102d6565b6100f46139e4565b6040805160008082526020820190815281830190925261011691849190610310565b92915050565b6101416040805160608101909152806000815260200160608152602001606081525090565b61014a82610ab6565b60408051606081019091528154909190829060ff16600981111561017057610170613aa7565b600981111561018157610181613aa7565b815260200160018201805461019590613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546101c190613dc2565b801561020e5780601f106101e35761010080835404028352916020019161020e565b820191906000526020600020905b8154815290600101906020018083116101f157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561026657602002820191906000526020600020905b815481526020019060010190808311610252575b5050505050815250509050919050565b600080604051806060016040528086600981111561029657610296613aa7565b81526020018581526020018481525090506102b081610ac1565b9150505b9392505050565b6102c36139e4565b6102ce848484610310565b949350505050565b60008060405180606001604052808660098111156102f6576102f6613aa7565b81526020018581526020018481525090506102b081610acc565b6103186139e4565b81518351146103a05760408051634bab873760e11b81526004810191909152600d60448201526c72756e74696d6556616c75657360981b606482015260806024820152602260848201527f6d7573742062652073616d65206c656e6774682061732072756e74696d654b6560a482015261797360f01b60c482015260e4015b60405180910390fd5b60006103ab85610c26565b805490915060ff1660018160098111156103c7576103c7613aa7565b036104755761046c6103da838787610c84565b8360010180546103e990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461041590613dc2565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050610d46565b925050506102b4565b600281600981111561048957610489613aa7565b036105305761046c61049c838787610c84565b8360010180546104ab90613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546104d790613dc2565b80156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050508787610ebb565b600381600981111561054457610544613aa7565b036105de5761046c82600101805461055b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461058790613dc2565b80156105d45780601f106105a9576101008083540402835291602001916105d4565b820191906000526020600020905b8154815290600101906020018083116105b757829003601f168201915b5050505050610f59565b60048160098111156105f2576105f2613aa7565b0361068c5761046c82600101805461060990613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461063590613dc2565b80156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050611087565b60058160098111156106a0576106a0613aa7565b0361073a5761046c8260010180546106b790613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390613dc2565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b505050505061131e565b600981600981111561074e5761074e613aa7565b036107ea5761046c82600101805461076590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461079190613dc2565b80156107de5780601f106107b3576101008083540402835291602001916107de565b820191906000526020600020905b8154815290600101906020018083116107c157829003601f168201915b505050505086866114b5565b60068160098111156107fe576107fe613aa7565b036108a35761046c610811838787610c84565b83600101805461082090613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90613dc2565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b50505050506115c7565b60078160098111156108b7576108b7613aa7565b036109ec576040805160608101909152825461046c91908490829060ff1660098111156108e6576108e6613aa7565b60098111156108f7576108f7613aa7565b815260200160018201805461090b90613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461093790613dc2565b80156109845780601f1061095957610100808354040283529160200191610984565b820191906000526020600020905b81548152906001019060200180831161096757829003601f168201915b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156109dc57602002820191906000526020600020905b8154815260200190600101908083116109c8575b5050505050815250508686611728565b6008816009811115610a0057610a00613aa7565b03610a9a5761046c826001018054610a1790613dc2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a4390613dc2565b8015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b50505050506118a5565b6040516323a9bbc960e01b815260048101879052602401610397565b600061011682610c26565b6000610116826118ea565b6000610ad782610ac1565b9050610ae28161192a565b15610b35577fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e81836000015184602001518560400151604051610b289493929190613e32565b60405180910390a1919050565b610b3e82611a8c565b610b5d578160405163382bbbc960e11b81526004016103979190613b21565b60005b826040015151811015610bd957610b9383604001518281518110610b8657610b86613e6a565b602002602001015161192a565b610bd15782604001518181518110610bad57610bad613e6a565b6020026020010151604051632f19f96160e11b815260040161039791815260200190565b600101610b60565b50610be382611c31565b8351602085015160408087015190519395507fcb64985827770858ec421ad26da7e558c757541643036ce44d6b4eb9e8e5dc5e9450610b28938693929190613e32565b604080516020808201839052606082018190527f696f2e73796e7468657469782e6f7261636c652d6d616e616765722e4e6f6465608080840191909152828401949094528251808303909401845260a0909101909152815191012090565b600283015460609067ffffffffffffffff811115610ca457610ca4613b9a565b604051908082528060200260200182016040528015610cdd57816020015b610cca6139e4565b815260200190600190039081610cc25790505b50905060005b6002850154811015610d3e57610d19856002018281548110610d0757610d07613e6a565b90600052602060002001548585610310565b828281518110610d2b57610d2b613e6a565b6020908102919091010152600101610ce3565b509392505050565b610d4e6139e4565b600082806020019051810190610d649190613e80565b90506000816008811115610d7a57610d7a613aa7565b03610d9057610d8884611ca5565b915050610116565b6001816008811115610da457610da4613aa7565b03610db257610d8884611d0d565b6002816008811115610dc657610dc6613aa7565b03610dd457610d8884611d90565b6003816008811115610de857610de8613aa7565b03610df657610d8884611e13565b6004816008811115610e0a57610e0a613aa7565b03610e1857610d8884611ec9565b6005816008811115610e2c57610e2c613aa7565b03610e3a57610d8884612009565b6006816008811115610e4e57610e4e613aa7565b03610e5c57610d88846120e4565b6007816008811115610e7057610e70613aa7565b03610e7e57610d888461220c565b6008816008811115610e9257610e92613aa7565b03610ea057610d88846122ce565b80604051631be413d360e11b81526004016103979190613ea1565b610ec36139e4565b600084806020019051810190610ed99190613ed3565b604051631ecba7c360e31b81529091506001600160a01b0382169063f65d3e1890610f0e908990899089908990600401613ef0565b608060405180830381865afa158015610f2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4f9190613f91565b9695505050505050565b610f616139e4565b600080600084806020019051810190610f7a9190613fe8565b92509250925060008390506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610fc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fec9190614041565b509350509250925060008660001461100f5761100a8585858a6123c7565b611011565b825b905060128660ff161161103b5761103661102f60ff881660126140a7565b82906124c2565b611053565b61105361104c601260ff89166140a7565b82906124dc565b9050604051806080016040528082815260200183815260200160008152602001600081525098505050505050505050919050565b61108f6139e4565b600080600080600080878060200190518101906110ac91906140ba565b604080516002808252606082018352979d50959b50939950919750955093506000929060208301908036833701905050905081816000815181106110f2576110f2613e6a565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061112157611121613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0385169063883bdbfd90611165908590600401614143565b600060405180830381865afa158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111aa91908101906141f5565b5090506000816000815181106111c2576111c2613e6a565b6020026020010151826001815181106111dd576111dd613e6a565b60200260200101516111ef91906142c1565b9050600061121761120563ffffffff87166124f6565b61120f9084614304565b60060b61252d565b905060008260060b12801561124c575061123b63ffffffff8616612569565b612569565b8260060b6112499190614342565b15155b1561125f578061125b81614356565b9150505b600061126d6012600a61445d565b9050600061128061123684848f8f612593565b905060006112908a60ff16612569565b61129c8c60ff16612569565b6112a6919061446c565b905060008082136112d1576112cc6112c56112c084614493565b612686565b84906124dc565b6112e4565b6112e46112dd83612686565b84906124c2565b905060405180608001604052808281526020014281526020016000815260200160008152509e505050505050505050505050505050919050565b6113266139e4565b60008060008480602001905181019061133f91906144bf565b91945092509050826000826113bc576040516396834ad360e01b8152600481018590526001600160a01b038316906396834ad390602401608060405180830381865afa158015611393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b791906144f5565b611425565b604051639474f45b60e01b8152600481018590526001600160a01b03831690639474f45b90602401608060405180830381865afa158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906144f5565b90506000816040015160030b601261143d919061456f565b90506000808213611467576114626114576112c084614493565b845160070b906124dc565b61147e565b61147e61147383612686565b845160070b906124c2565b9050604051806080016040528082815260200184606001518152602001600081526020016000815250975050505050505050919050565b6114bd6139e4565b6000806000868060200190518101906114d69190614597565b92509250925060005b8651811015611545578681815181106114fa576114fa613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b0361153d5785818151811061152f5761152f613e6a565b602002602001015160001c91505b6001016114df565b5060408051600180825281830190925260009160208083019080368337019050509050828160008151811061157c5761157c613e6a565b602002602001018181525050836001838360405160200161159f939291906145ce565b60408051601f198184030181529082905263cf2cabdf60e01b82526103979291600401614603565b6115cf6139e4565b6000828060200190518101906115e59190614627565b90506000846000815181106115fc576115fc613e6a565b602002602001015160000151905060008560018151811061161f5761161f613e6a565b6020026020010151600001519050808214611702576000611653601261164d611648858761446c565b6126a9565b906124c2565b905082158061167b5750611666836126a9565b6116709082614640565b61167985612569565b125b15611700576002875111156116b0578660028151811061169d5761169d613e6a565b6020026020010151945050505050610116565b826000036116d15760405163014cc07160e01b815260040160405180910390fd5b6116da836126a9565b6116e49082614640565b60405163dcac091960e01b815260040161039791815260200190565b505b8560008151811061171557611715613e6a565b6020026020010151935050505092915050565b6117306139e4565b6000846020015180602001905181019061174a9190614627565b905060005b84518110156117bc5784818151811061176a5761176a613e6a565b6020026020010151717374616c656e657373546f6c6572616e636560701b036117b4576117ad8482815181106117a2576117a2613e6a565b602002602001015190565b91506117bc565b60010161174f565b50600085604001516000815181106117d6576117d6613e6a565b6020026020010151905060006117ed828787610310565b60208101519091506117ff84426140a7565b1161180e5792506102b4915050565b86604001515160010361187157866040015160008151811061183257611832613e6a565b602002602001015181600001518260200151604051631808066560e21b8152600401610397939291909283526020830191909152604082015260600190565b61189a876040015160018151811061188b5761188b613e6a565b60200260200101518787610310565b979650505050505050565b6118ad6139e4565b6040518060800160405280838060200190518101906118cc9190614627565b81526020014281526020016000815260200160008152509050919050565b600081600001518260200151836040015160405160200161190d9392919061466e565b604051602081830303815290604052805190602001209050919050565b60008061193683610c26565b60408051606081019091528154909190829060ff16600981111561195c5761195c613aa7565b600981111561196d5761196d613aa7565b815260200160018201805461198190613dc2565b80601f01602080910402602001604051908101604052809291908181526020018280546119ad90613dc2565b80156119fa5780601f106119cf576101008083540402835291602001916119fa565b820191906000526020600020905b8154815290600101906020018083116119dd57829003601f168201915b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a5257602002820191906000526020600020905b815481526020019060010190808311611a3e575b505050505081525050905060006009811115611a7057611a70613aa7565b81516009811115611a8357611a83613aa7565b14159392505050565b6000600182516009811115611aa357611aa3613aa7565b1480611ac15750600682516009811115611abf57611abf613aa7565b145b80611ade5750600782516009811115611adc57611adc613aa7565b145b15611aee57611aec826126c1565b505b600182516009811115611b0357611b03613aa7565b03611b11576101168261284a565b600282516009811115611b2657611b26613aa7565b03611b3457610116826128a5565b600382516009811115611b4957611b49613aa7565b03611b575761011682612973565b600482516009811115611b6c57611b6c613aa7565b03611b7a5761011682612aae565b600582516009811115611b8f57611b8f613aa7565b03611b9d5761011682612e92565b600982516009811115611bb257611bb2613aa7565b03611bc05761011682612fcb565b600682516009811115611bd557611bd5613aa7565b03611be3576101168261300e565b600782516009811115611bf857611bf8613aa7565b03611c065761011682613052565b600882516009811115611c1b57611c1b613aa7565b03611c295761011682613078565b506000919050565b600080611c3d836118ea565b9050611c4881610c26565b8351815491935090839060ff19166001836009811115611c6a57611c6a613aa7565b021790555060208301516001830190611c8390826146ed565b5060408301518051611c9f916002850191602090910190613a0c565b50915091565b611cad6139e4565b60005b8251811015611d07578160200151838281518110611cd057611cd0613e6a565b6020026020010151602001511115611cff57828181518110611cf457611cf4613e6a565b602002602001015191505b600101611cb0565b50919050565b611d156139e4565b81600081518110611d2857611d28613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611d5957611d59613e6a565b6020026020010151600001511215611d8857828181518110611d7d57611d7d613e6a565b602002602001015191505b600101611d39565b611d986139e4565b81600081518110611dab57611dab613e6a565b602002602001015190506000600190505b8251811015611d07578160000151838281518110611ddc57611ddc613e6a565b6020026020010151600001511315611e0b57828181518110611e0057611e00613e6a565b602002602001015191505b600101611dbc565b611e1b6139e4565b60005b8251811015611e9557828181518110611e3957611e39613e6a565b60200260200101516000015182600001818151611e56919061456f565b9052508251839082908110611e6d57611e6d613e6a565b60200260200101516020015182602001818151611e8a91906147ad565b905250600101611e1e565b50611ea08251612569565b8151611eac9190614640565b815281516020820151611ebf91906147c0565b6020820152919050565b611ed16139e4565b611eed826000611ee86001865161123691906140a7565b6130a4565b60028251611efb91906147d4565b600003611fd65760408051600280825260608201909252600091816020015b611f226139e4565b815260200190600190039081611f1a57905050905082600160028551611f4891906147c0565b611f5291906140a7565b81518110611f6257611f62613e6a565b602002602001015181600081518110611f7d57611f7d613e6a565b60200260200101819052508260028451611f9791906147c0565b81518110611fa757611fa7613e6a565b602002602001015181600181518110611fc257611fc2613e6a565b60200260200101819052506102b481611e13565b8160028351611fe591906147c0565b81518110611ff557611ff5613e6a565b60200260200101519050919050565b919050565b6120116139e4565b8160008151811061202457612024613e6a565b60209081029190910101515181528151829060009061204557612045613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061207657612076613e6a565b6020026020010151600001518260000181815161209391906147e8565b90525082518390829081106120aa576120aa613e6a565b602002602001015160200151826020018181516120c791906147ad565b90525060010161205b565b5081518160200151611ebf91906147c0565b6120ec6139e4565b816000815181106120ff576120ff613e6a565b60209081029190910101515181528151829060009061212057612120613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061215157612151613e6a565b60200260200101516000015160000361219e5782818151811061217657612176613e6a565b6020026020010151600001516040516338ee04a760e01b815260040161039791815260200190565b8281815181106121b0576121b0613e6a565b602002602001015160000151826000018181516121cd9190614640565b90525082518390829081106121e4576121e4613e6a565b6020026020010151602001518260200181815161220191906147ad565b905250600101612136565b6122146139e4565b8160008151811061222757612227613e6a565b60209081029190910101515181528151829060009061224857612248613e6a565b6020908102919091018101518101519082015260015b82518110156120d25761229083828151811061227c5761227c613e6a565b602090810291909101015151835190613264565b825282518390829081106122a6576122a6613e6a565b602002602001015160200151826020018181516122c391906147ad565b90525060010161225e565b6122d66139e4565b816000815181106122e9576122e9613e6a565b60209081029190910101515181528151829060009061230a5761230a613e6a565b6020908102919091018101518101519082015260015b82518110156120d25782818151811061233b5761233b613e6a565b6020026020010151600001516000036123605782818151811061217657612176613e6a565b61238983828151811061237557612375613e6a565b602090810291909101015151835190613283565b8252825183908290811061239f5761239f613e6a565b602002602001015160200151826020018181516123bc91906147ad565b905250600101612320565b6000826001826123d785426140a7565b90505b69ffffffffffffffffffff8716156124a3576001600160a01b038816639a6fc8f561240489614818565b6040516001600160e01b031960e084901b16815269ffffffffffffffffffff8216600482015290995060240160a060405180830381865afa925050508015612469575060408051601f3d908101601f1916820190925261246691810190614041565b60015b156124a357858210156124805750505050506124a3565b61248a848961456f565b97508661249681614834565b97505050505050506123da565b6124ac82612569565b6124b69084614640565b98975050505050505050565b60006124d261123683600a61484d565b6102b490846147e8565b60006124ec61123683600a61484d565b6102b49084614640565b6000667fffffffffffff66ffffffffffffff83161115612529576040516329d2678160e21b815260040160405180910390fd5b5090565b6000627fffff19600683900b128061254b5750627fffff600683900b135b1561252957604051630d962f7960e21b815260040160405180910390fd5b60006001600160ff1b038211156125295760405163677c430560e11b815260040160405180910390fd5b60008061259f86613298565b90506fffffffffffffffffffffffffffffffff6001600160a01b0382161161261c5760006125d66001600160a01b03831680614859565b9050836001600160a01b0316856001600160a01b03161061260557612600600160c01b87836136cd565b612614565b6126148187600160c01b6136cd565b92505061267d565b600061263b6001600160a01b03831680680100000000000000006136cd565b9050836001600160a01b0316856001600160a01b03161061266a57612665600160801b87836136cd565b612679565b6126798187600160801b6136cd565b9250505b50949350505050565b6000808212156125295760405163029f024d60e31b815260040160405180910390fd5b600080821215612529576126bc82614493565b610116565b6000805b8260400151518110156128415760006126fa846040015183815181106126ed576126ed613e6a565b6020026020010151610ab6565b60408051606081019091528154909190829060ff16600981111561272057612720613aa7565b600981111561273157612731613aa7565b815260200160018201805461274590613dc2565b80601f016020809104026020016040519081016040528092919081815260200182805461277190613dc2565b80156127be5780601f10612793576101008083540402835291602001916127be565b820191906000526020600020905b8154815290600101906020018083116127a157829003601f168201915b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561281657602002820191906000526020600020905b815481526020019060010190808311612802575b505050505081525050905061282a81611a8c565b612838575060009392505050565b506001016126c5565b50600192915050565b60006002826040015151101561286257506000919050565b81602001515160201461287757506000919050565b600082602001518060200190518101906128919190614627565b905060088111156128415750600092915050565b6000602082602001515110156128bd57506000919050565b600082602001518060200190518101906128d79190613ed3565b90506128ea816306e7ea3960e21b6138e2565b6128f75750600092915050565b604051633b70a5bf60e21b81526001600160a01b0382169063edc296fc90612923908690600401613b21565b6020604051808303816000875af1158015612942573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129669190614870565b6128415750600092915050565b6040810151516000901561298957506000919050565b81602001515160601461299e57506000919050565b60008083602001518060200190518101906129b99190613fe8565b92505091506000829050806001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015612a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a259190614041565b5050505050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8c919061488b565b60ff168260ff1614612aa357506000949350505050565b506001949350505050565b60408101515160009015612ac457506000919050565b81602001515160c014612ad957506000919050565b6000806000806000808760200151806020019051810190612afa91906140ba565b9550955095509550955095508360ff16866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6c919061488b565b60ff1614612b8257506000979650505050505050565b8260ff16856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be8919061488b565b60ff1614612bfe57506000979650505050505050565b6000826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c629190613ed3565b90506000836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190613ed3565b9050876001600160a01b0316826001600160a01b0316148015612cfc5750866001600160a01b0316816001600160a01b0316145b158015612d385750866001600160a01b0316826001600160a01b0316148015612d365750876001600160a01b0316816001600160a01b0316145b155b15612d4d575060009998505050505050505050565b60128660ff161180612d62575060128560ff16115b15612d77575060009998505050505050505050565b8263ffffffff16600003612d95575060009998505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110612dca57612dca613e6a565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110612df957612df9613e6a565b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526001600160a01b0386169063883bdbfd90612e3a908490600401614143565b600060405180830381865afa158015612e57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7f91908101906141f5565b5060019c9b505050505050505050505050565b60408101515160009015612ea857506000919050565b816020015151606014612ebd57506000919050565b60008060008460200151806020019051810190612eda91906144bf565b919450925090508281612f55576040516396834ad360e01b8152600481018490526001600160a01b038216906396834ad390602401608060405180830381865afa158015612f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5091906144f5565b612fbe565b604051639474f45b60e01b8152600481018490526001600160a01b03821690639474f45b90602401608060405180830381865afa158015612f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fbe91906144f5565b5060019695505050505050565b60408101515160009015612fe157506000919050565b816020015151606014612ff657506000919050565b8160200151806020019051810190612aa39190614597565b60008160400151516002148061302957508160400151516003145b61303557506000919050565b81602001515160201461304a57506000919050565b506001919050565b600081604001515160011480613029575081604001515160021461303557506000919050565b6040810151516000901561308e57506000919050565b6020826020015151101561304a57506000919050565b81818082036130b4575050505050565b6000856130da60026130c6888861446c565b6130d09190614640565b6112c0908861456f565b815181106130ea576130ea613e6a565b60200260200101516000015190505b818313613236575b808661310c85612686565b8151811061311c5761311c613e6a565b60200260200101516000015112156131405782613138816148a6565b935050613101565b8561314a83612686565b8151811061315a5761315a613e6a565b60200260200101516000015181121561317f5781613177816148be565b925050613140565b818313613231578561319083612686565b815181106131a0576131a0613e6a565b6020026020010151866131b285612686565b815181106131c2576131c2613e6a565b6020026020010151876131d486612686565b815181106131e4576131e4613e6a565b60200260200101886131f586612686565b8151811061320557613205613e6a565b602002602001018290528290525050828061321f906148a6565b935050818061322d906148be565b9250505b6130f9565b81851215613249576132498686846130a4565b8383121561325c5761325c8684866130a4565b505050505050565b6000670de0b6b3a764000061327983856147e8565b6102b49190614640565b600081613279670de0b6b3a7640000856147e8565b60008060008360020b126132b8576132b3600284900b612686565b6132c8565b6132c86112c0600285900b614493565b90506132e36112c06132dd620d89e7196148db565b60020b90565b8111156133165760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610397565b60008160011660000361332d57600160801b61333f565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561337e576080613379826ffff97272373d413259a46990580e213a614859565b901c90505b60048216156133a85760806133a3826ffff2e50f5f656932ef12357cf3c7fdcc614859565b901c90505b60088216156133d25760806133cd826fffe5caca7e10e4e61c3624eaa0941cd0614859565b901c90505b60108216156133fc5760806133f7826fffcb9843d60f6159c9db58835c926644614859565b901c90505b6020821615613426576080613421826fff973b41fa98c081472e6896dfb254c0614859565b901c90505b604082161561345057608061344b826fff2ea16466c96a3843ec78b326b52861614859565b901c90505b608082161561347a576080613475826ffe5dee046a99a2a811c461f1969c3053614859565b901c90505b6101008216156134a55760806134a0826ffcbe86c7900a88aedcffc83b479aa3a4614859565b901c90505b6102008216156134d05760806134cb826ff987a7253ac413176f2b074cf7815e54614859565b901c90505b6104008216156134fb5760806134f6826ff3392b0822b70005940c7a398e4b70f3614859565b901c90505b610800821615613526576080613521826fe7159475a2c29b7443b29c7fa6e889d9614859565b901c90505b61100082161561355157608061354c826fd097f3bdfd2022b8845ad8f792aa5825614859565b901c90505b61200082161561357c576080613577826fa9f746462d870fdf8a65dc1f90e061e5614859565b901c90505b6140008216156135a75760806135a2826f70d869a156d2a1b890bb3df62baf32f7614859565b901c90505b6180008216156135d25760806135cd826f31be135f97d08fd981231505542fcfa6614859565b901c90505b620100008216156135fe5760806135f9826f09aa508b5b7a84e1c677de54f3e99bc9614859565b901c90505b62020000821615613629576080613624826e5d6af8dedb81196699c329225ee604614859565b901c90505b6204000082161561365357608061364e826d2216e584f5fa1ea926041bedfe98614859565b901c90505b6208000082161561367b576080613676826b048a170391f7dc42444e8fa2614859565b901c90505b60008460020b131561369657613693816000196147c0565b90505b6102ce6136a8640100000000836147d4565b156136b45760016136b7565b60005b6136c89060ff16602084901c6147ad565b6139ba565b6000808060001985870985870292508281108382030391505080600003613749576000841161373e5760405162461bcd60e51b815260206004820152601960248201527f48616e646c65206e6f6e2d6f766572666c6f77206361736573000000000000006044820152606401610397565b5082900490506102b4565b8084116137985760405162461bcd60e51b815260206004820152601960248201527f70726576656e74732064656e6f6d696e61746f72203d3d2030000000000000006044820152606401610397565b60008486880980840393811190920391905060006137d06137b887612569565b6137c188612569565b6137ca90614493565b16612686565b9586900495938490049360008190030460010190506137ef8184614859565b909317926000613800876003614859565b600218905061380f8188614859565b61381a9060026140a7565b6138249082614859565b90506138308188614859565b61383b9060026140a7565b6138459082614859565b90506138518188614859565b61385c9060026140a7565b6138669082614859565b90506138728188614859565b61387d9060026140a7565b6138879082614859565b90506138938188614859565b61389e9060026140a7565b6138a89082614859565b90506138b48188614859565b6138bf9060026140a7565b6138c99082614859565b90506138d58186614859565b9998505050505050505050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1790529051600091829182916001600160a01b0387169161394391906148fd565b6000604051808303816000865af19150503d8060008114613980576040519150601f19603f3d011682016040523d82523d6000602084013e613985565b606091505b50915091508161399a57600092505050610116565b80516000036139ae57600092505050610116565b60200151949350505050565b60006001600160a01b038211156125295760405163dccde8ed60e01b815260040160405180910390fd5b6040518060800160405280600081526020016000815260200160008152602001600081525090565b828054828255906000526020600020908101928215613a47579160200282015b82811115613a47578251825591602001919060010190613a2c565b506125299291505b808211156125295760008155600101613a4f565b600060208284031215613a7557600080fd5b5035919050565b8151815260208083015190820152604080830151908201526060808301519082015260808101610116565b634e487b7160e01b600052602160045260246000fd5b600a8110613acd57613acd613aa7565b9052565b60005b83811015613aec578181015183820152602001613ad4565b50506000910152565b60008151808452613b0d816020860160208601613ad1565b601f01601f19169290920160200192915050565b60006020808352613b358184018551613abd565b8084015160606040850152613b4d6080850182613af5565b6040860151858203601f19016060870152805180835290840192506000918401905b80831015613b8f5783518252928401926001929092019190840190613b6f565b509695505050505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715613bd357613bd3613b9a565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c0257613c02613b9a565b604052919050565b600067ffffffffffffffff821115613c2457613c24613b9a565b5060051b60200190565b600082601f830112613c3f57600080fd5b81356020613c54613c4f83613c0a565b613bd9565b8083825260208201915060208460051b870101935086841115613c7657600080fd5b602086015b84811015613b8f5780358352918301918301613c7b565b600080600060608486031215613ca757600080fd5b8335600a8110613cb657600080fd5b925060208481013567ffffffffffffffff80821115613cd457600080fd5b818701915087601f830112613ce857600080fd5b813581811115613cfa57613cfa613b9a565b613d0c601f8201601f19168501613bd9565b8181528985838601011115613d2057600080fd5b818585018683013760009181019094015291935060408601359180831115613d4757600080fd5b5050613d5586828701613c2e565b9150509250925092565b600080600060608486031215613d7457600080fd5b83359250602084013567ffffffffffffffff80821115613d9357600080fd5b613d9f87838801613c2e565b93506040860135915080821115613db557600080fd5b50613d5586828701613c2e565b600181811c90821680613dd657607f821691505b602082108103611d0757634e487b7160e01b600052602260045260246000fd5b60008151808452602080850194506020840160005b83811015613e2757815187529582019590820190600101613e0b565b509495945050505050565b848152613e426020820185613abd565b608060408201526000613e586080830185613af5565b828103606084015261189a8185613df6565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613e9257600080fd5b8151600981106102b457600080fd5b6020810160098310613eb557613eb5613aa7565b91905290565b6001600160a01b0381168114613ed057600080fd5b50565b600060208284031215613ee557600080fd5b81516102b481613ebb565b608080825285518282018190526000919060209060a0850190828a01855b82811015613f5257613f42848351805182526020810151602083015260408101516040830152606081015160608301525050565b9285019290840190600101613f0e565b5050508481036020860152613f678189613af5565b925050508281036040840152613f7d8186613df6565b9050828103606084015261189a8185613df6565b600060808284031215613fa357600080fd5b613fab613bb0565b825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b805160ff8116811461200457600080fd5b600080600060608486031215613ffd57600080fd5b835161400881613ebb565b6020850151909350915061401e60408501613fd7565b90509250925092565b805169ffffffffffffffffffff8116811461200457600080fd5b600080600080600060a0868803121561405957600080fd5b61406286614027565b945060208601519350604086015192506060860151915061408560808701614027565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b8181038181111561011657610116614091565b60008060008060008060c087890312156140d357600080fd5b86516140de81613ebb565b60208801519096506140ef81613ebb565b94506140fd60408801613fd7565b935061410b60608801613fd7565b9250608087015161411b81613ebb565b60a088015190925063ffffffff8116811461413557600080fd5b809150509295509295509295565b6020808252825182820181905260009190848201906040850190845b8181101561418157835163ffffffff168352928401929184019160010161415f565b50909695505050505050565b600082601f83011261419e57600080fd5b815160206141ae613c4f83613c0a565b8083825260208201915060208460051b8701019350868411156141d057600080fd5b602086015b84811015613b8f5780516141e881613ebb565b83529183019183016141d5565b6000806040838503121561420857600080fd5b825167ffffffffffffffff8082111561422057600080fd5b818501915085601f83011261423457600080fd5b81516020614244613c4f83613c0a565b82815260059290921b8401810191818101908984111561426357600080fd5b948201945b838610156142915785518060060b81146142825760008081fd5b82529482019490820190614268565b918801519196509093505050808211156142aa57600080fd5b506142b78582860161418d565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff8213171561011657610116614091565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b8061431b5761431b6142ee565b667fffffffffffff1982146000198214161561433957614339614091565b90059392505050565b600082614351576143516142ee565b500790565b60008160020b627fffff19810361436f5761436f614091565b6000190192915050565b600181815b808511156143b457816000190482111561439a5761439a614091565b808516156143a757918102915b93841c939080029061437e565b509250929050565b6000826143cb57506001610116565b816143d857506000610116565b81600181146143ee57600281146143f857614414565b6001915050610116565b60ff84111561440957614409614091565b50506001821b610116565b5060208310610133831016604e8410600b8410161715614437575081810a610116565b6144418383614379565b806000190482111561445557614455614091565b029392505050565b60006102b460ff8416836143bc565b818103600083128015838313168383128216171561448c5761448c614091565b5092915050565b6000600160ff1b82016144a8576144a8614091565b5060000390565b8051801515811461200457600080fd5b6000806000606084860312156144d457600080fd5b83516144df81613ebb565b6020850151909350915061401e604085016144af565b60006080828403121561450757600080fd5b61450f613bb0565b82518060070b811461452057600080fd5b8152602083015167ffffffffffffffff8116811461453d57600080fd5b60208201526040830151600381900b811461455757600080fd5b60408201526060928301519281019290925250919050565b808201828112600083128015821682158216171561458f5761458f614091565b505092915050565b6000806000606084860312156145ac57600080fd5b83516145b781613ebb565b602085015160409095015190969495509392505050565b60ff8416815267ffffffffffffffff831660208201526060604082015260006145fa6060830184613df6565b95945050505050565b6001600160a01b03831681526040602082018190526000906102ce90830184613af5565b60006020828403121561463957600080fd5b5051919050565b60008261464f5761464f6142ee565b600160ff1b82146000198414161561466957614669614091565b500590565b6146788185613abd565b60606020820152600061468e6060830185613af5565b8281036040840152610f4f8185613df6565b601f8211156146e8576000816000526020600020601f850160051c810160208610156146c95750805b601f850160051c820191505b8181101561325c578281556001016146d5565b505050565b815167ffffffffffffffff81111561470757614707613b9a565b61471b816147158454613dc2565b846146a0565b602080601f83116001811461475057600084156147385750858301515b600019600386901b1c1916600185901b17855561325c565b600085815260208120601f198616915b8281101561477f57888601518255948401946001909101908401614760565b508582101561479d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082018082111561011657610116614091565b6000826147cf576147cf6142ee565b500490565b6000826147e3576147e36142ee565b500690565b80820260008212600160ff1b8414161561480457614804614091565b818105831482151761011657610116614091565b600069ffffffffffffffffffff82168061436f5761436f614091565b60006001820161484657614846614091565b5060010190565b60006102b483836143bc565b808202811582820484141761011657610116614091565b60006020828403121561488257600080fd5b6102b4826144af565b60006020828403121561489d57600080fd5b6102b482613fd7565b60006001600160ff1b01820161484657614846614091565b6000600160ff1b82016148d3576148d3614091565b506000190190565b60008160020b627fffff1981036148f4576148f4614091565b60000392915050565b6000825161490f818460208701613ad1565b919091019291505056fea264697066735822122074f32fef384fdc296b0859f1c1f941c8e736c6cb972aa9e2b894956ebd6a80b364736f6c63430008160033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xbc73db80bf4b8784ba10a8910a0b7ef85f6846d102b41dd990969ea205335354"}}],"ommers":[]},{"header":{"parentHash":"0x026ae0c6ae91f186a9befa1ac8be30eea35e30e77de51a731085221e5cd39209","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x6e4969a136061ca7a390d12830d47a151585325a8d396819fb2b958ff85e9f8f","receiptsRoot":"0xc3e81df67d3e2a6c8345a954ef250cfcc41abcc2292a5aa263071124533fc9ad","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x3c0f6","timestamp":"0x66b200ce","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x18993a68","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3c0f6","maxFeePerGas":"0x5d4285cd","maxPriorityFeePerGas":"0x3b9aca00","value":"0x0","accessList":[],"input":"0x608060405234801561001057600080fd5b50610380806100206000396000f3fe6080604052600080357fffffffff0000000000000000000000000000000000000000000000000000000016905060008160e01c610251565b60006379ba509782101561015e5781631627540c811461009857632a952b2d81146100b457633659cfe681146100d0576350c946fe81146100ec576353a47bb781146101085763625ca21c81146101245763718fe928811461014057610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc9150610158565b738138ef7cf908021d117e542120b7a390650161079150610158565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc91505b5061024c565b816379ba509781146101a657638da5cb5b81146101c25763aaf10f4281146101de5763c7f62cda81146101fa5763daa250be81146102165763deba1b9881146102325761024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b7347d08dad17ccb558b3ea74b1a0e73a9cc804a9dc915061024a565b738138ef7cf908021d117e542120b7a39065016107915061024a565b738138ef7cf908021d117e542120b7a3906501610791505b505b919050565b61025a81610037565b915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036102ce57816040517fc2a825f50000000000000000000000000000000000000000000000000000000081526004016102c5919061032f565b60405180910390fd5b3660008037600080366000845af43d6000803e80600081146102ef573d6000f35b3d6000fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610329816102f4565b82525050565b60006020820190506103446000830184610320565b9291505056fea264697066735822122017a4b7fdaaab3897a7b47abaed8d2ee92d558883d3bb2a8454f9601b2ab2c3db64736f6c63430008150033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x2476e039803622aeb040f924f04c493f559aed3d6c9372ab405cb33c8c695328"}}],"ommers":[]},{"header":{"parentHash":"0x3d22100ac0ee8d5cde334f7f926191a861b0648971ebc179547df28a0224c6d0","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x9511d4711e5c30a72b0bff38a261daa75dcc5ba8b772d970a5c742244b4c861b","transactionsRoot":"0xba5fff578d3d6c2cd63acbe9bca353eaa6fe22a5c408956eff49106e0a96c507","receiptsRoot":"0xbae111f01cb07677e3a8c5031546138407c01bc964d3493d732dc4edf47d36d3","logsBloom":"0x00000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000020000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000001000000000000000000000400000001000010000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x5","gasLimit":"0x1c9c380","gasUsed":"0xcae7","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x12e09c7a","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0xcc4d","maxFeePerGas":"0x557e5ec4","maxPriorityFeePerGas":"0x3b9aca00","to":"0x83a0444b93927c3afcbe46e522280390f748e171","value":"0x0","accessList":[],"input":"0x3659cfe6000000000000000000000000108f53faf774d7c4c56f5bce9ca6e605ce8aeadd","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xf88e7b19ee347145c257e0cf7ac4ecc2bae83ca79d7edaa231e71d3213aeb151"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x9c8eaf493f8b4edce2ba1647343eadcc0989cf461e712c0a6253ff2ca1842bb7","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xdd07c07470e1deff3749831f0f1ad8d4b6e35505e83b3c6ea14181716197cd8a","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x24a1ab52","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200c9","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xf6930be4847cac5017bbcbec2756eed19f36b4196526a98a88e311c296e3a9be","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x29aa352e71b139e83b397bdd3dcf9b65d74770edaf3a9624d0dbc4f96f868680","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200cc","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x200d75e8","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0xb6003e7ba07a15a9e35f63daa484728ec4ceeded0c4d10ac1b04e9552d412b3c","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x4","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1592fbf9","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x149d41e3b89d8324cef3feff98ef308e97bafe8745cc8461c60172bc7d4c44ba","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x0b44110186e52ff0ceb6b0776ca2992c94144a4ed712eef65ea038260ef0fcc7","receiptsRoot":"0xc2823b8eb4730d9f2657137cc2ddc2c4f22ab68e0ab826236cf6a1551ca2b3a5","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0xe61f9","timestamp":"0x66b200cb","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342770c0","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0xe94d1","maxFeePerGas":"0x83215600","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060008061002661006d60201b61081b1760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610141565b60008060405160200161007f90610121565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b600061010b60238361009e565b9150610116826100af565b604082019050919050565b6000602082019050818103600083015261013a816100fe565b9050919050565b611000806101506000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806379ba50971161005b57806379ba5097146100ed5780638da5cb5b146100f7578063aaf10f4214610115578063c7f62cda1461013357610088565b80631627540c1461008d5780633659cfe6146100a957806353a47bb7146100c5578063718fe928146100e3575b600080fd5b6100a760048036038101906100a29190610d25565b61014f565b005b6100c360048036038101906100be9190610d25565b6102d0565b005b6100cd6102e4565b6040516100da9190610d61565b60405180910390f35b6100eb610317565b005b6100f56103fe565b005b6100ff61058b565b60405161010c9190610d61565b60405180910390f35b61011d6105be565b60405161012a9190610d61565b60405180910390f35b61014d60048036038101906101489190610d25565b6105f1565b005b61015761084c565b600061016161081b565b9050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101c9576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610252576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22826040516102c49190610d61565b60405180910390a15050565b6102d861084c565b6102e1816108c5565b50565b60006102ee61081b565b60010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061032161081b565b90503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103b757336040517fa0e5a0d70000000000000000000000000000000000000000000000000000000081526004016103ae9190610d61565b60405180910390fd5b60008160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061040861081b565b905060008160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104a357336040517fa0e5a0d700000000000000000000000000000000000000000000000000000000815260040161049a9190610d61565b60405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c8260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104f8929190610d7c565b60405180910390a1808260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008260010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600061059561081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105c8610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006105fb610b05565b905060018160000160146101000a81548160ff02191690831515021790555060008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050828260000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16633659cfe6846040516024016106cc9190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161071b9190610e16565b600060405180830381855af49150503d8060008114610756576040519150601f19603f3d011682016040523d82523d6000602084013e61075b565b606091505b505090508015806107c357508173ffffffffffffffffffffffffffffffffffffffff16610786610b05565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156107fa576040517fa1cfa5a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008360000160146101000a81548160ff0219169083151502179055600080fd5b60008060405160200161082d90610eb0565b6040516020818303038152906040528051906020012090508091505090565b610854610b36565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c357336040517f8e4a23d60000000000000000000000000000000000000000000000000000000081526004016108ba9190610d61565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361092b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61093481610b69565b61097557806040517f8a8b41ec00000000000000000000000000000000000000000000000000000000815260040161096c9190610d61565b60405180910390fd5b600061097f610b05565b90508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a0a576040517fa88ee57700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000160149054906101000a900460ff16158015610a2e5750610a2d82610b7c565b5b15610a7057816040517f15504301000000000000000000000000000000000000000000000000000000008152600401610a679190610d61565b60405180910390fd5b818160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503073ffffffffffffffffffffffffffffffffffffffff167f5d611f318680d00598bb735d61bacf0c514c6b50e1e5ad30040a4df2b12791c783604051610af99190610d61565b60405180910390a25050565b600080604051602001610b1790610f42565b6040516020818303038152906040528051906020012090508091505090565b6000610b4061081b565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080823b905060008111915050919050565b60008060003073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663c7f62cda86604051602401610bc59190610d61565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c149190610e16565b600060405180830381855af49150503d8060008114610c4f576040519150601f19603f3d011682016040523d82523d6000602084013e610c54565b606091505b509150915081158015610cb9575063a1cfa5a860e01b604051602001610c7a9190610faf565b6040516020818303038152906040528051906020012081604051602001610ca19190610e16565b60405160208183030381529060405280519060200120145b92505050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cf282610cc7565b9050919050565b610d0281610ce7565b8114610d0d57600080fd5b50565b600081359050610d1f81610cf9565b92915050565b600060208284031215610d3b57610d3a610cc2565b5b6000610d4984828501610d10565b91505092915050565b610d5b81610ce7565b82525050565b6000602082019050610d766000830184610d52565b92915050565b6000604082019050610d916000830185610d52565b610d9e6020830184610d52565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015610dd9578082015181840152602081019050610dbe565b60008484015250505050565b6000610df082610da5565b610dfa8185610db0565b9350610e0a818560208601610dbb565b80840191505092915050565b6000610e228284610de5565b915081905092915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b6000610e9a602383610e2d565b9150610ea582610e3e565b604082019050919050565b60006020820190508181036000830152610ec981610e8d565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b6000610f2c602183610e2d565b9150610f3782610ed0565b604082019050919050565b60006020820190508181036000830152610f5b81610f1f565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b610fa9610fa482610f62565b610f8e565b82525050565b6000610fbb8284610f98565b6004820191508190509291505056fea264697066735822122023a7c33d7b91dce35ffbcf8837693364ab22a3905d0fc00016833e5fac45ca2f64736f6c63430008110033","r":"0x1","s":"0x1","yParity":"0x0","hash":"0x4feae6769d748b4f0f7c9bf21d782236c88f13906789a3ec602961296e4c3e43"}}],"ommers":[]},{"header":{"parentHash":"0xb3535af5103fd1c2bbd6dc7ff23f0799037a6542c231ebcb85abd776560fa512","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x23d74fb99ff6e42cbb5c33f92b078e37be6af2b6092459b103ff7059a6517ebc","transactionsRoot":"0x9eab45eca206fe11c107ea985c7d02fcfa442836aea3e04ba11dc4df587d5aa6","receiptsRoot":"0xe25abcfa973db8c55f73292137c626430de130a382ad4466337fefb0f7c8fde0","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x3ce3f","timestamp":"0x66b200cd","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x1c0bc72b","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x343a","nonce":"0x0","gas":"0x3d8a8","maxFeePerGas":"0x6211577c","maxPriorityFeePerGas":"0x3b9aca00","to":"0x4e59b44847b379578588920ca78fbf26c0b4956c","value":"0x0","accessList":[],"input":"0x4786e4342646b3ba97c1790b6cf5a55087a36240b22570f5d3a5d6bcc929d93b608060405234801561001057600080fd5b5060405161068538038061068583398181016040528101906100329190610275565b818181600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361009b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6100ae8161019d60201b61004f1760201c565b6100ef57806040517f8a8b41ec0000000000000000000000000000000000000000000000000000000081526004016100e691906102c4565b60405180910390fd5b806100fe6101b060201b60201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050806101536101e160201b6100621760201c565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050610414565b600080823b905060008111915050919050565b6000806040516020016101c290610362565b6040516020818303038152906040528051906020012090508091505090565b6000806040516020016101f3906103f4565b6040516020818303038152906040528051906020012090508091505090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061024282610217565b9050919050565b61025281610237565b811461025d57600080fd5b50565b60008151905061026f81610249565b92915050565b6000806040838503121561028c5761028b610212565b5b600061029a85828601610260565b92505060206102ab85828601610260565b9150509250929050565b6102be81610237565b82525050565b60006020820190506102d960008301846102b5565b92915050565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b600061034c6021836102df565b9150610357826102f0565b604082019050919050565b6000602082019050818103600083015261037b8161033f565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006103de6023836102df565b91506103e982610382565b604082019050919050565b6000602082019050818103600083015261040d816103d1565b9050919050565b610262806104236000396000f3fe6080604052366100135761001161001d565b005b61001b61001d565b005b6000610027610093565b90503660008037600080366000845af43d6000803e806000811461004a573d6000f35b3d6000fd5b600080823b905060008111915050919050565b6000806040516020016100749061017a565b6040516020818303038152906040528051906020012090508091505090565b600061009d6100c6565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000806040516020016100d89061020c565b6040516020818303038152906040528051906020012090508091505090565b600082825260208201905092915050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e4f776e6160008201527f626c650000000000000000000000000000000000000000000000000000000000602082015250565b60006101646023836100f7565b915061016f82610108565b604082019050919050565b6000602082019050818103600083015261019381610157565b9050919050565b7f696f2e73796e7468657469782e636f72652d636f6e7472616374732e50726f7860008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b60006101f66021836100f7565b91506102018261019a565b604082019050919050565b60006020820190508181036000830152610225816101e9565b905091905056fea2646970667358221220800da1f73cebd5e4afa07496d9bca6b6c4f526bdd3f4014ec15c70fe3a1c441364736f6c6343000811003300000000000000000000000047d08dad17ccb558b3ea74b1a0e73a9cc804a9dc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266","r":"0x1","s":"0x1","yParity":"0x0","hash":"0xb6794d5c7abed6f91d447e8efb72ef2580595a6d7c8dee57ba1dbb330970146a"}}],"ommers":[]},{"header":{"parentHash":"0x08abe6e453727534d8dd708843a7522b7d500338bdfe2402ca105dcdb05eebe9","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x510f2275449c013534a25ad0b13c867caf720947b68bcbcd4863f7b172a5d023","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x3","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66b200ca","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x29dd5614","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]}]} \ No newline at end of file diff --git a/crates/anvil/test-data/state-dump-legacy.json b/crates/anvil/test-data/state-dump-legacy.json index 0641b2f7be911..273442701292e 100644 --- a/crates/anvil/test-data/state-dump-legacy.json +++ b/crates/anvil/test-data/state-dump-legacy.json @@ -1 +1 @@ -{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdc823","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xb92480171c0235f8c6710a4047d7ee14a3be58c630839fb4422826ff3a013e44","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc823","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}}],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdc80e","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xa00dc0c9ee9a888e67ea32d8772f8cc28eff62448c9ec985ee941fcbc921ba59","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc814","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}}],"ommers":[]}]} \ No newline at end of file +{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdc823","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xb92480171c0235f8c6710a4047d7ee14a3be58c630839fb4422826ff3a013e44","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc823","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}}],"ommers":[]},{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdc80e","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0xa00dc0c9ee9a888e67ea32d8772f8cc28eff62448c9ec985ee941fcbc921ba59","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdc814","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}}],"ommers":[]}]} \ No newline at end of file diff --git a/crates/anvil/test-data/state-dump.json b/crates/anvil/test-data/state-dump.json index 3a3c478cfffef..e868bf2efea51 100644 --- a/crates/anvil/test-data/state-dump.json +++ b/crates/anvil/test-data/state-dump.json @@ -1 +1 @@ -{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdcc2b","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xdb639d7f8af4f0ff2aa9cc49861820e72f5f8bfeeed677d1e3569f6b1625df4a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdcc25","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x3a52101c98a4319c419681131d3585d70a6cf13a9af25136be20d451eed5480a","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc29","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}},"impersonated_sender":null}],"ommers":[]},{"header":{"parentHash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","ommersHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","beneficiary":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc2b","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}},"impersonated_sender":null}],"ommers":[]}],"transactions":[{"info":{"transaction_hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3","transaction_index":0,"from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","block_number":1},{"info":{"transaction_hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515","transaction_index":0,"from":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","address":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x1f435a603c1bf6d544a90156b572b96d7a1730028422d800839bae78bb3506d0","block_number":2}]} \ No newline at end of file +{"block":{"number":"0x2","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x66cdcc2b","gas_limit":"0x1c9c380","basefee":"0x342a1c58","difficulty":"0x0","prevrandao":"0xdb639d7f8af4f0ff2aa9cc49861820e72f5f8bfeeed677d1e3569f6b1625df4a","blob_excess_gas_and_price":{"excess_blob_gas":0,"blob_gasprice":1}},"accounts":{"0x0000000000000000000000000000000000000000":{"nonce":0,"balance":"0xa410","code":"0x","storage":{}},"0x14dc79964da2c08b23698b3d3cc7ca32193d9955":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x4e59b44847b379578588920ca78fbf26c0b4956c":{"nonce":0,"balance":"0x0","code":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3","storage":{}},"0x70997970c51812dc3a010c7d01b50e0d17dc79c8":{"nonce":1,"balance":"0x21e19e0b90393da9b38","code":"0x","storage":{}},"0x90f79bf6eb2c4f870365e785982e1f101e93b906":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x976ea74026e726554db657fa54763abd0c3a0aa9":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xa0ee7a142d267c1f36714e4a8f75612f20a79720":{"nonce":0,"balance":"0x21e19e0c9bab2400000","code":"0x","storage":{}},"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266":{"nonce":1,"balance":"0x21e19e0b6a140b55df8","code":"0x","storage":{}}},"best_block_number":"0x2","blocks":[{"header":{"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x0","gasLimit":"0x1c9c380","gasUsed":"0x0","timestamp":"0x66cdcc25","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[],"ommers":[]},{"header":{"parentHash":"0x3a52101c98a4319c419681131d3585d70a6cf13a9af25136be20d451eed5480a","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x6e5f60b37eeaece7dedfc42cc394731a0ae3ed3d3be93c402780b2e23e141175","transactionsRoot":"0x9ceaeb1b16b924afbf4bf4df4c2c49dc9cfbe23ac7a40bf26a704158ea2d352f","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x1","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc29","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x3b9aca00","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","value":"0x0","accessList":[],"input":"0x","r":"0x703a4b4d6dbff2fa2345df73263df2098faa7214863b5ec82c4c07162d87b853","s":"0x17dea762c4ce600ad1d9d2c9ae6dd35b9e526d03c875f868ad0792fd4fad72e0","yParity":"0x0","hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3"}},"impersonated_sender":null}],"ommers":[]},{"header":{"parentHash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1","transactionsRoot":"0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988","receiptsRoot":"0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","difficulty":"0x0","number":"0x2","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x66cdcc2b","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","baseFeePerGas":"0x342a1c58","blobGasUsed":"0x0","excessBlobGas":"0x0","extraData":"0x"},"transactions":[{"transaction":{"EIP1559":{"chainId":"0x7a69","nonce":"0x0","gas":"0x5209","maxFeePerGas":"0x77359401","maxPriorityFeePerGas":"0x1","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","value":"0x0","accessList":[],"input":"0x","r":"0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0","s":"0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd","yParity":"0x0","hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"}},"impersonated_sender":null}],"ommers":[]}],"transactions":[{"info":{"transaction_hash":"0xf8d5fb22350f52ae8c30cd7f6969eb73de849c8dc010f4215d4c5c24824fe2b3","transaction_index":0,"from":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","to":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x0d575f9ca968cd483549172245483a12343afc3cabef80f0fa39855b10b98c70","block_number":1},{"info":{"transaction_hash":"0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515","transaction_index":0,"from":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","to":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","contract_address":null,"traces":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x70997970c51812dc3a010c7d01b50e0d17dc79c8","address":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","maybe_precompile":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}],"exit":"Stop","out":"0x","nonce":0,"gas_used":21000},"receipt":{"type":"0x2","status":"0x1","cumulativeGasUsed":"0x5208","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"block_hash":"0x1f435a603c1bf6d544a90156b572b96d7a1730028422d800839bae78bb3506d0","block_number":2}]} \ No newline at end of file diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index ce78d72ca59a6..b75b088b0e1f4 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -13,7 +13,7 @@ use alloy_rpc_types::{ anvil::{ ForkedNetwork, Forking, Metadata, MineOptions, NodeEnvironment, NodeForkConfig, NodeInfo, }, - BlockId, BlockNumberOrTag, TransactionRequest, + BlockId, BlockNumberOrTag, BlockTransactionsKind, TransactionRequest, }; use alloy_serde::WithOtherFields; use anvil::{ @@ -643,7 +643,7 @@ async fn test_fork_revert_call_latest_block_timestamp() { let Multicall::getCurrentBlockCoinbaseReturn { coinbase } = multicall_contract.getCurrentBlockCoinbase().call().await.unwrap(); - assert_eq!(coinbase, latest_block.header.miner); + assert_eq!(coinbase, latest_block.header.beneficiary); } #[tokio::test(flavor = "multi_thread")] @@ -718,14 +718,16 @@ async fn test_reorg() { // The first 3 reorged blocks should have 5 transactions each for num in 14..17 { - let block = provider.get_block_by_number(num.into(), true).await.unwrap(); + let block = + provider.get_block_by_number(num.into(), BlockTransactionsKind::Full).await.unwrap(); let block = block.unwrap(); assert_eq!(block.transactions.len(), 5); } // Verify that historic blocks are still accessible for num in (0..14).rev() { - let _ = provider.get_block_by_number(num.into(), true).await.unwrap(); + let _ = + provider.get_block_by_number(num.into(), BlockTransactionsKind::Full).await.unwrap(); } // Send a few more transaction to verify the chain can still progress @@ -777,7 +779,7 @@ async fn test_reorg() { let signature = accounts[5].sign_transaction_sync(&mut tx).unwrap(); let tx = tx.into_signed(signature); let mut encoded = vec![]; - tx.tx().encode_with_signature(tx.signature(), &mut encoded, false); + tx.eip2718_encode(&mut encoded); let pre_bal = provider.get_balance(accounts[5].address()).await.unwrap(); api.anvil_reorg(ReorgOptions { diff --git a/crates/anvil/tests/it/api.rs b/crates/anvil/tests/it/api.rs index c4172b265be19..946118af8c07b 100644 --- a/crates/anvil/tests/it/api.rs +++ b/crates/anvil/tests/it/api.rs @@ -266,7 +266,7 @@ async fn can_call_on_pending_block() { .call() .await .unwrap(); - assert_eq!(block.header.miner, ret_coinbase); + assert_eq!(block.header.beneficiary, ret_coinbase); } } diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index 2b965087b4c19..ea195f000b6d0 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -1,10 +1,10 @@ use crate::utils::{http_provider, http_provider_with_signer}; -use alloy_consensus::{SidecarBuilder, SimpleCoder}; +use alloy_consensus::{SidecarBuilder, SimpleCoder, Transaction}; use alloy_eips::eip4844::{BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK}; use alloy_network::{EthereumWallet, TransactionBuilder, TransactionBuilder4844}; use alloy_primitives::U256; use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, TransactionRequest}; +use alloy_rpc_types::{BlockId, BlockTransactionsKind, TransactionRequest}; use alloy_serde::WithOtherFields; use anvil::{spawn, EthereumHardfork, NodeConfig}; @@ -176,8 +176,14 @@ async fn can_mine_blobs_when_exceeds_max_blobs() { let second_receipt = second_tx.get_receipt().await.unwrap(); let (first_block, second_block) = tokio::join!( - provider.get_block_by_number(first_receipt.block_number.unwrap().into(), false), - provider.get_block_by_number(second_receipt.block_number.unwrap().into(), false) + provider.get_block_by_number( + first_receipt.block_number.unwrap().into(), + BlockTransactionsKind::Hashes + ), + provider.get_block_by_number( + second_receipt.block_number.unwrap().into(), + BlockTransactionsKind::Hashes + ) ); assert_eq!( first_block.unwrap().unwrap().header.blob_gas_used, @@ -239,7 +245,7 @@ async fn can_correctly_estimate_blob_gas_with_recommended_fillers() { receipt.block_number.expect("Failed to get block number") ); - assert!(tx.max_fee_per_blob_gas.unwrap() >= BLOB_TX_MIN_BLOB_GASPRICE); + assert!(tx.max_fee_per_blob_gas().unwrap() >= BLOB_TX_MIN_BLOB_GASPRICE); assert_eq!(receipt.from, alice); assert_eq!(receipt.to, Some(bob)); assert_eq!( @@ -285,7 +291,7 @@ async fn can_correctly_estimate_blob_gas_with_recommended_fillers_with_signer() receipt.block_number.expect("Failed to get block number") ); - assert!(tx.max_fee_per_blob_gas.unwrap() >= BLOB_TX_MIN_BLOB_GASPRICE); + assert!(tx.max_fee_per_blob_gas().unwrap() >= BLOB_TX_MIN_BLOB_GASPRICE); assert_eq!(receipt.from, alice); assert_eq!(receipt.to, Some(bob)); assert_eq!( diff --git a/crates/anvil/tests/it/eip7702.rs b/crates/anvil/tests/it/eip7702.rs index ab787e4ebc762..e10633d6c14d8 100644 --- a/crates/anvil/tests/it/eip7702.rs +++ b/crates/anvil/tests/it/eip7702.rs @@ -66,7 +66,7 @@ async fn can_send_eip7702_tx() { let tx = tx.into_signed(signature); let mut encoded = Vec::new(); - tx.tx().encode_with_signature(tx.signature(), &mut encoded, false); + tx.eip2718_encode(&mut encoded); let receipt = provider.send_raw_transaction(&encoded).await.unwrap().get_receipt().await.unwrap(); diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 821395417fa38..3d470894b2b3f 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -5,7 +5,7 @@ use crate::{ utils::{http_provider, http_provider_with_signer}, }; use alloy_chains::NamedChain; -use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder}; +use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder, TransactionResponse}; use alloy_primitives::{address, b256, bytes, uint, Address, Bytes, TxHash, TxKind, U256, U64}; use alloy_provider::Provider; use alloy_rpc_types::{ @@ -1407,7 +1407,7 @@ async fn test_immutable_fork_transaction_hash() { api.backend.mined_transaction_by_block_hash_and_index(hash, expected.1.into()) }) .unwrap(); - assert_eq!(tx.inner.hash.to_string(), expected.0.to_string()); + assert_eq!(tx.tx_hash().to_string(), expected.0.to_string()); } } diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index 4f13f8aaf0a12..e5d99e01b333d 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -54,7 +54,7 @@ async fn test_sub_new_heads_ipc() { let blocks = provider.subscribe_blocks().await.unwrap().into_stream(); let blocks = blocks.take(3).collect::>().await; - let block_numbers = blocks.into_iter().map(|b| b.header.number).collect::>(); + let block_numbers = blocks.into_iter().map(|b| b.number).collect::>(); assert_eq!(block_numbers, vec![1, 2, 3]); } diff --git a/crates/anvil/tests/it/logs.rs b/crates/anvil/tests/it/logs.rs index 3bf09493d8aa9..ac644e6e24769 100644 --- a/crates/anvil/tests/it/logs.rs +++ b/crates/anvil/tests/it/logs.rs @@ -7,7 +7,7 @@ use crate::{ use alloy_network::EthereumWallet; use alloy_primitives::{map::B256HashSet, B256}; use alloy_provider::Provider; -use alloy_rpc_types::{BlockNumberOrTag, Filter}; +use alloy_rpc_types::{BlockNumberOrTag, BlockTransactionsKind, Filter}; use anvil::{spawn, NodeConfig}; use futures::StreamExt; @@ -55,7 +55,7 @@ async fn get_past_events() { // and we can fetch the events at a block hash // let hash = provider.get_block(1).await.unwrap().unwrap().hash.unwrap(); let hash = provider - .get_block_by_number(BlockNumberOrTag::from(1), false) + .get_block_by_number(BlockNumberOrTag::from(1), BlockTransactionsKind::Hashes) .await .unwrap() .unwrap() @@ -191,7 +191,10 @@ async fn watch_events() { assert_eq!(log.1.block_number.unwrap(), starting_block_number + i + 1); let hash = provider - .get_block_by_number(BlockNumberOrTag::from(starting_block_number + i + 1), false) + .get_block_by_number( + BlockNumberOrTag::from(starting_block_number + i + 1), + false.into(), + ) .await .unwrap() .unwrap() diff --git a/crates/anvil/tests/it/otterscan.rs b/crates/anvil/tests/it/otterscan.rs index e839c9986a1fb..37d21a29e0b7d 100644 --- a/crates/anvil/tests/it/otterscan.rs +++ b/crates/anvil/tests/it/otterscan.rs @@ -1,6 +1,7 @@ //! Tests for otterscan endpoints. use crate::abi::Multicall; +use alloy_network::TransactionResponse; use alloy_primitives::{address, Address, Bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ @@ -409,7 +410,7 @@ async fn ots_search_transactions_before() { // check each individual hash result.txs.iter().for_each(|tx| { - assert_eq!(hashes.pop(), Some(tx.hash)); + assert_eq!(hashes.pop(), Some(tx.tx_hash())); }); block = result.txs.last().unwrap().block_number.unwrap(); @@ -444,7 +445,7 @@ async fn ots_search_transactions_after() { // check each individual hash result.txs.iter().rev().for_each(|tx| { - assert_eq!(hashes.pop_back(), Some(tx.hash)); + assert_eq!(hashes.pop_back(), Some(tx.tx_hash())); }); block = result.txs.first().unwrap().block_number.unwrap(); diff --git a/crates/anvil/tests/it/pubsub.rs b/crates/anvil/tests/it/pubsub.rs index ecfb9b1005f0c..948456055f240 100644 --- a/crates/anvil/tests/it/pubsub.rs +++ b/crates/anvil/tests/it/pubsub.rs @@ -23,7 +23,7 @@ async fn test_sub_new_heads() { api.anvil_set_interval_mining(1).unwrap(); let blocks = blocks.into_stream().take(3).collect::>().await; - let block_numbers = blocks.into_iter().map(|b| b.header.number).collect::>(); + let block_numbers = blocks.into_iter().map(|b| b.number).collect::>(); assert_eq!(block_numbers, vec![1, 2, 3]); } @@ -262,7 +262,7 @@ async fn test_sub_new_heads_fast() { let mut block_numbers = Vec::new(); for _ in 0..num { api.mine_one().await; - let block_number = blocks.next().await.unwrap().header.number; + let block_number = blocks.next().await.unwrap().number; block_numbers.push(block_number); } diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 07c120d1ce525..0afce986b5e88 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -2,7 +2,7 @@ use crate::{ abi::{Greeter, Multicall, SimpleStorage}, utils::{connect_pubsub, http_provider_with_signer}, }; -use alloy_network::{EthereumWallet, TransactionBuilder}; +use alloy_network::{EthereumWallet, TransactionBuilder, TransactionResponse}; use alloy_primitives::{map::B256HashSet, Address, Bytes, FixedBytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{ @@ -718,7 +718,7 @@ async fn can_get_pending_transaction() { api.mine_one().await; let mined = provider.get_transaction_by_hash(*tx.tx_hash()).await.unwrap().unwrap(); - assert_eq!(mined.hash, pending.unwrap().unwrap().hash); + assert_eq!(mined.tx_hash(), pending.unwrap().unwrap().tx_hash()); } #[tokio::test(flavor = "multi_thread")] diff --git a/crates/cast/bin/cmd/creation_code.rs b/crates/cast/bin/cmd/creation_code.rs index 04531b6167f3e..b444bff3209a1 100644 --- a/crates/cast/bin/cmd/creation_code.rs +++ b/crates/cast/bin/cmd/creation_code.rs @@ -1,3 +1,4 @@ +use alloy_consensus::Transaction; use alloy_primitives::{Address, Bytes}; use alloy_provider::{ext::TraceApi, Provider}; use alloy_rpc_types::trace::parity::{Action, CreateAction, CreateOutput, TraceOutput}; @@ -143,9 +144,9 @@ pub async fn fetch_creation_code( let tx_data = provider.get_transaction_by_hash(creation_tx_hash).await?; let tx_data = tx_data.ok_or_eyre("Could not find creation tx data.")?; - let bytecode = if tx_data.inner.to.is_none() { + let bytecode = if tx_data.to().is_none() { // Contract was created using a standard transaction - tx_data.inner.input + tx_data.input().clone() } else { // Contract was created using a factory pattern or create2 // Extract creation code from tx traces diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 880b2fe6f080a..79083fa8db9ea 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -1,3 +1,5 @@ +use alloy_consensus::Transaction; +use alloy_network::TransactionResponse; use alloy_primitives::U256; use alloy_provider::Provider; use alloy_rpc_types::BlockTransactions; @@ -115,10 +117,11 @@ impl RunArgs { .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; // check if the tx is a system transaction - if is_known_system_sender(tx.from) || tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) { + if is_known_system_sender(tx.from) || tx.transaction_type() == Some(SYSTEM_TRANSACTION_TYPE) + { return Err(eyre::eyre!( "{:?} is a system transaction.\nReplaying system transactions is currently not supported.", - tx.hash + tx.tx_hash() )); } @@ -140,7 +143,7 @@ impl RunArgs { if let Some(block) = &block { env.block.timestamp = U256::from(block.header.timestamp); - env.block.coinbase = block.header.miner; + env.block.coinbase = block.header.beneficiary; env.block.difficulty = block.header.difficulty; env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); @@ -184,27 +187,28 @@ impl RunArgs { // we skip them otherwise this would cause // reverts if is_known_system_sender(tx.from) || - tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) + tx.transaction_type() == Some(SYSTEM_TRANSACTION_TYPE) { pb.set_position((index + 1) as u64); continue; } - if tx.hash == tx_hash { + if tx.tx_hash() == tx_hash { break; } configure_tx_env(&mut env, &tx.inner); - if let Some(to) = tx.to { - trace!(tx=?tx.hash,?to, "executing previous call transaction"); + if let Some(to) = Transaction::to(tx) { + trace!(tx=?tx.tx_hash(),?to, "executing previous call transaction"); executor.transact_with_env(env.clone()).wrap_err_with(|| { format!( "Failed to execute transaction: {:?} in block {}", - tx.hash, env.block.number + tx.tx_hash(), + env.block.number ) })?; } else { - trace!(tx=?tx.hash, "executing previous create transaction"); + trace!(tx=?tx.tx_hash(), "executing previous create transaction"); if let Err(error) = executor.deploy_with_env(env.clone(), None) { match error { // Reverted transactions should be skipped @@ -213,7 +217,8 @@ impl RunArgs { return Err(error).wrap_err_with(|| { format!( "Failed to deploy transaction: {:?} in block {}", - tx.hash, env.block.number + tx.tx_hash(), + env.block.number ) }) } @@ -232,11 +237,11 @@ impl RunArgs { configure_tx_env(&mut env, &tx.inner); - if let Some(to) = tx.to { - trace!(tx=?tx.hash, to=?to, "executing call transaction"); + if let Some(to) = Transaction::to(&tx) { + trace!(tx=?tx.tx_hash(), to=?to, "executing call transaction"); TraceResult::try_from(executor.transact_with_env(env))? } else { - trace!(tx=?tx.hash, "executing create transaction"); + trace!(tx=?tx.tx_hash(), "executing create transaction"); TraceResult::try_from(executor.deploy_with_env(env, None))? } }; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 75272b3b1a997..39e821dc91f13 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -731,9 +731,9 @@ where .ok_or_else(|| eyre::eyre!("tx not found: {:?}", tx_hash))?; Ok(if raw { - format!("0x{}", hex::encode(TxEnvelope::try_from(tx.inner)?.encoded_2718())) + format!("0x{}", hex::encode(tx.inner.inner.encoded_2718())) } else if let Some(field) = field { - get_pretty_tx_attr(&tx, field.as_str()) + get_pretty_tx_attr(&tx.inner, field.as_str()) .ok_or_else(|| eyre::eyre!("invalid tx field: {}", field.to_string()))? } else if shell::is_json() { // to_value first to sort json object keys @@ -995,7 +995,7 @@ where Either::Right(futures::future::pending()) } => { if let (Some(block), Some(to_block)) = (block, to_block_number) { - if block.header.number > to_block { + if block.number > to_block { break; } } diff --git a/crates/cheatcodes/src/crypto.rs b/crates/cheatcodes/src/crypto.rs index cdb07720c3280..3fd13d9b06e9a 100644 --- a/crates/cheatcodes/src/crypto.rs +++ b/crates/cheatcodes/src/crypto.rs @@ -15,7 +15,9 @@ use k256::{ ecdsa::SigningKey, elliptic_curve::{bigint::ArrayEncoding, sec1::ToEncodedPoint}, }; -use p256::ecdsa::{signature::hazmat::PrehashSigner, Signature, SigningKey as P256SigningKey}; +use p256::ecdsa::{ + signature::hazmat::PrehashSigner, Signature as P256Signature, SigningKey as P256SigningKey, +}; /// The BIP32 default derivation path prefix. const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/60'/0'/0/"; @@ -215,23 +217,23 @@ fn create_wallet(private_key: &U256, label: Option<&str>, state: &mut Cheatcodes .abi_encode()) } -fn encode_full_sig(sig: alloy_primitives::Signature) -> Vec { +fn encode_full_sig(sig: alloy_primitives::PrimitiveSignature) -> Vec { // Retrieve v, r and s from signature. - let v = U256::from(sig.v().y_parity_byte_non_eip155().unwrap_or(sig.v().y_parity_byte())); + let v = U256::from(sig.v() as u64 + 27); let r = B256::from(sig.r()); let s = B256::from(sig.s()); (v, r, s).abi_encode() } -fn encode_compact_sig(sig: alloy_primitives::Signature) -> Vec { +fn encode_compact_sig(sig: alloy_primitives::PrimitiveSignature) -> Vec { // Implement EIP-2098 compact signature. let r = B256::from(sig.r()); let mut vs = sig.s(); - vs.set_bit(255, sig.v().y_parity()); + vs.set_bit(255, sig.v()); (r, vs).abi_encode() } -fn sign(private_key: &U256, digest: &B256) -> Result { +fn sign(private_key: &U256, digest: &B256) -> Result { // The `ecrecover` precompile does not use EIP-155. No chain ID is needed. let wallet = parse_wallet(private_key)?; let sig = wallet.sign_hash_sync(digest)?; @@ -243,7 +245,7 @@ fn sign_with_wallet( state: &mut Cheatcodes, signer: Option
, digest: &B256, -) -> Result { +) -> Result { if state.wallets().is_empty() { bail!("no wallets available"); } @@ -273,7 +275,7 @@ fn sign_with_wallet( fn sign_p256(private_key: &U256, digest: &B256) -> Result { let signing_key = parse_private_key_p256(private_key)?; - let signature: Signature = signing_key.sign_prehash(digest.as_slice())?; + let signature: P256Signature = signing_key.sign_prehash(digest.as_slice())?; let r_bytes: [u8; 32] = signature.r().to_bytes().into(); let s_bytes: [u8; 32] = signature.s().to_bytes().into(); @@ -403,7 +405,7 @@ mod tests { let result = sign_p256(&pk_u256, &digest).unwrap(); let result_bytes: [u8; 64] = result.try_into().unwrap(); - let signature = Signature::from_bytes(&result_bytes.into()).unwrap(); + let signature = P256Signature::from_bytes(&result_bytes.into()).unwrap(); let verifying_key = VerifyingKey::from(&signing_key); assert!(verifying_key.verify_prehash(digest.as_slice(), &signature).is_ok()); } diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index 3e1239237e83f..b28141ae002ec 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -1,9 +1,9 @@ //! Implementations of [`Scripting`](spec::Group::Scripting) cheatcodes. use crate::{Cheatcode, CheatsCtxt, Result, Vm::*}; -use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::{Address, PrimitiveSignature, B256, U256}; use alloy_rpc_types::Authorization; -use alloy_signer::{Signature, SignerSync}; +use alloy_signer::SignerSync; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::SolValue; use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner}; @@ -104,9 +104,13 @@ fn write_delegation(ccx: &mut CheatsCtxt, auth: SignedAuthorization) -> Result<( Ok(()) } -fn sig_to_delegation(sig: Signature, nonce: u64, implementation: Address) -> SignedDelegation { +fn sig_to_delegation( + sig: PrimitiveSignature, + nonce: u64, + implementation: Address, +) -> SignedDelegation { SignedDelegation { - v: sig.v().y_parity() as u8, + v: sig.v() as u8, r: sig.r().into(), s: sig.s().into(), nonce, @@ -114,8 +118,8 @@ fn sig_to_delegation(sig: Signature, nonce: u64, implementation: Address) -> Sig } } -fn sig_to_auth(sig: Signature, auth: Authorization) -> SignedAuthorization { - SignedAuthorization::new_unchecked(auth, sig.v().y_parity() as u8, sig.r(), sig.s()) +fn sig_to_auth(sig: PrimitiveSignature, auth: Authorization) -> SignedAuthorization { + SignedAuthorization::new_unchecked(auth, sig.v() as u8, sig.r(), sig.s()) } impl Cheatcode for startBroadcast_0Call { diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 5534e72d83556..a82d2cdc3d3cd 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -1,11 +1,14 @@ //! Helper trait and functions to format Ethereum types. -use alloy_consensus::{AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom, TxType}; -use alloy_network::ReceiptResponse; -use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, B256, I256, U256, U64}; +use alloy_consensus::{ + AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom, Transaction as TxTrait, TxEnvelope, + TxType, +}; +use alloy_network::{AnyHeader, AnyRpcBlock, AnyTxEnvelope, ReceiptResponse}; +use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, I256, U256, U64, U8}; use alloy_rpc_types::{ - AccessListItem, AnyNetworkBlock, AnyTransactionReceipt, Block, BlockTransactions, Header, Log, - Transaction, TransactionReceipt, + AccessListItem, AnyTransactionReceipt, Block, BlockTransactions, Header, Log, Transaction, + TransactionReceipt, }; use alloy_serde::{OtherFields, WithOtherFields}; use serde::Deserialize; @@ -267,7 +270,7 @@ transactionIndex: {}", } } -impl UIfmt for Block { +impl UIfmt for Block> { fn pretty(&self) -> String { format!( " @@ -317,10 +320,210 @@ impl UIfmt for AccessListItem { } } +impl UIfmt for TxEnvelope { + fn pretty(&self) -> String { + match &self { + Self::Eip2930(tx) => format!( + " +accessList {} +chainId {} +gasLimit {} +gasPrice {} +hash {} +input {} +nonce {} +r {} +s {} +to {} +type {} +value {} +yParity {}", + self.access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), + self.chain_id().pretty(), + self.gas_limit().pretty(), + self.gas_price().pretty(), + self.tx_hash().pretty(), + self.input().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), + self.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), + ), + Self::Eip1559(tx) => format!( + " +accessList {} +chainId {} +gasLimit {} +hash {} +input {} +maxFeePerGas {} +maxPriorityFeePerGas {} +nonce {} +r {} +s {} +to {} +type {} +value {} +yParity {}", + self.access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), + self.chain_id().pretty(), + self.gas_limit().pretty(), + self.tx_hash().pretty(), + self.input().pretty(), + self.max_fee_per_gas().pretty(), + self.max_priority_fee_per_gas().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), + self.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), + ), + Self::Eip4844(tx) => format!( + " +accessList {} +blobVersionedHashes {} +chainId {} +gasLimit {} +hash {} +input {} +maxFeePerBlobGas {} +maxFeePerGas {} +maxPriorityFeePerGas {} +nonce {} +r {} +s {} +to {} +type {} +value {} +yParity {}", + self.access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), + self.blob_versioned_hashes().unwrap_or(&[]).pretty(), + self.chain_id().pretty(), + self.gas_limit().pretty(), + self.tx_hash().pretty(), + self.input().pretty(), + self.max_fee_per_blob_gas().pretty(), + self.max_fee_per_gas().pretty(), + self.max_priority_fee_per_gas().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), + self.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), + ), + Self::Eip7702(tx) => format!( + " +accessList {} +authorizationList {} +chainId {} +gasLimit {} +hash {} +input {} +maxFeePerGas {} +maxPriorityFeePerGas {} +nonce {} +r {} +s {} +to {} +type {} +value {} +yParity {}", + self.access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), + self.authorization_list() + .as_ref() + .map(|l| serde_json::to_string(&l).unwrap()) + .unwrap_or_default(), + self.chain_id().pretty(), + self.gas_limit().pretty(), + self.tx_hash().pretty(), + self.input().pretty(), + self.max_fee_per_gas().pretty(), + self.max_priority_fee_per_gas().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), + self.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), + ), + _ => format!( + " +gas {} +gasPrice {} +hash {} +input {} +nonce {} +r {} +s {} +to {} +type {} +v {} +value {}", + self.gas_limit().pretty(), + self.gas_price().pretty(), + self.tx_hash().pretty(), + self.input().pretty(), + self.nonce().pretty(), + self.as_legacy() + .map(|tx| FixedBytes::from(tx.signature().r()).pretty()) + .unwrap_or_default(), + self.as_legacy() + .map(|tx| FixedBytes::from(tx.signature().s()).pretty()) + .unwrap_or_default(), + self.to().pretty(), + self.ty(), + self.as_legacy() + .map(|tx| (if tx.signature().v() { 1u64 } else { 0 }).pretty()) + .unwrap_or_default(), + self.value().pretty(), + ), + } + } +} + +impl UIfmt for AnyTxEnvelope { + fn pretty(&self) -> String { + match self { + Self::Ethereum(envelop) => envelop.pretty(), + Self::Unknown(tx) => { + format!( + " +hash {} +type {} +{} + ", + tx.hash.pretty(), + tx.ty(), + tx.inner.fields.pretty(), + ) + } + } + } +} impl UIfmt for Transaction { fn pretty(&self) -> String { - match self.transaction_type { - Some(1) => format!( + match &self.inner { + TxEnvelope::Eip2930(tx) => format!( " accessList {} blockHash {} @@ -339,25 +542,29 @@ transactionIndex {} type {} value {} yParity {}", - self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), + self.inner + .access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), self.block_hash.pretty(), self.block_number.pretty(), - self.chain_id.pretty(), + self.chain_id().pretty(), self.from.pretty(), - self.gas.pretty(), - self.gas_price.pretty(), - self.hash.pretty(), - self.input.pretty(), - self.nonce.pretty(), - self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), - self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), - self.to.pretty(), + self.gas_limit().pretty(), + self.gas_price().pretty(), + self.inner.tx_hash().pretty(), + self.input().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), self.transaction_index.pretty(), - self.transaction_type.unwrap(), - self.value.pretty(), - self.signature.map(|s| s.v).pretty(), + self.inner.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), ), - Some(2) => format!( + TxEnvelope::Eip1559(tx) => format!( " accessList {} blockHash {} @@ -377,26 +584,30 @@ transactionIndex {} type {} value {} yParity {}", - self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), + self.inner + .access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), self.block_hash.pretty(), self.block_number.pretty(), - self.chain_id.pretty(), + self.chain_id().pretty(), self.from.pretty(), - self.gas.pretty(), - self.hash.pretty(), - self.input.pretty(), - self.max_fee_per_gas.pretty(), - self.max_priority_fee_per_gas.pretty(), - self.nonce.pretty(), - self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), - self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), - self.to.pretty(), + self.gas_limit().pretty(), + tx.hash().pretty(), + self.input().pretty(), + self.max_fee_per_gas().pretty(), + self.max_priority_fee_per_gas().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), self.transaction_index.pretty(), - self.transaction_type.unwrap(), - self.value.pretty(), - self.signature.map(|s| s.v).pretty(), + self.inner.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), ), - Some(3) => format!( + TxEnvelope::Eip4844(tx) => format!( " accessList {} blobVersionedHashes {} @@ -418,28 +629,32 @@ transactionIndex {} type {} value {} yParity {}", - self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), - self.blob_versioned_hashes.as_deref().unwrap_or(&[]).pretty(), + self.inner + .access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), + self.blob_versioned_hashes().unwrap_or(&[]).pretty(), self.block_hash.pretty(), self.block_number.pretty(), - self.chain_id.pretty(), + self.chain_id().pretty(), self.from.pretty(), - self.gas.pretty(), - self.hash.pretty(), - self.input.pretty(), - self.max_fee_per_blob_gas.pretty(), - self.max_fee_per_gas.pretty(), - self.max_priority_fee_per_gas.pretty(), - self.nonce.pretty(), - self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), - self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), - self.to.pretty(), + self.gas_limit().pretty(), + tx.hash().pretty(), + self.input().pretty(), + self.max_fee_per_blob_gas().pretty(), + self.max_fee_per_gas().pretty(), + self.max_priority_fee_per_gas().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), self.transaction_index.pretty(), - self.transaction_type.unwrap(), - self.value.pretty(), - self.signature.map(|s| s.v).pretty(), + self.inner.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), ), - Some(4) => format!( + TxEnvelope::Eip7702(tx) => format!( " accessList {} authorizationList {} @@ -460,28 +675,32 @@ transactionIndex {} type {} value {} yParity {}", - self.access_list.as_deref().map(Vec::as_slice).unwrap_or(&[]).pretty(), - self.authorization_list + self.inner + .access_list() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), + self.authorization_list() .as_ref() .map(|l| serde_json::to_string(&l).unwrap()) .unwrap_or_default(), self.block_hash.pretty(), self.block_number.pretty(), - self.chain_id.pretty(), + self.chain_id().pretty(), self.from.pretty(), - self.gas.pretty(), - self.hash.pretty(), - self.input.pretty(), - self.max_fee_per_gas.pretty(), - self.max_priority_fee_per_gas.pretty(), - self.nonce.pretty(), - self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), - self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), - self.to.pretty(), + self.gas_limit().pretty(), + tx.hash().pretty(), + self.input().pretty(), + self.max_fee_per_gas().pretty(), + self.max_priority_fee_per_gas().pretty(), + self.nonce().pretty(), + FixedBytes::from(tx.signature().r()).pretty(), + FixedBytes::from(tx.signature().s()).pretty(), + self.to().pretty(), self.transaction_index.pretty(), - self.transaction_type.unwrap(), - self.value.pretty(), - self.signature.map(|s| s.v).pretty(), + self.inner.ty(), + self.value().pretty(), + (if tx.signature().v() { 1u64 } else { 0 }).pretty(), ), _ => format!( " @@ -502,22 +721,52 @@ value {}", self.block_hash.pretty(), self.block_number.pretty(), self.from.pretty(), - self.gas.pretty(), - self.gas_price.pretty(), - self.hash.pretty(), - self.input.pretty(), - self.nonce, - self.signature.map(|s| s.r.to_be_bytes_vec()).pretty(), - self.signature.map(|s| s.s.to_be_bytes_vec()).pretty(), - self.to.pretty(), + self.gas_limit().pretty(), + self.gas_price().pretty(), + self.inner.tx_hash().pretty(), + self.input().pretty(), + self.nonce().pretty(), + self.inner + .as_legacy() + .map(|tx| FixedBytes::from(tx.signature().r()).pretty()) + .unwrap_or_default(), + self.inner + .as_legacy() + .map(|tx| FixedBytes::from(tx.signature().s()).pretty()) + .unwrap_or_default(), + self.to().pretty(), self.transaction_index.pretty(), - self.signature.map(|s| s.v).pretty(), - self.value.pretty(), + self.inner + .as_legacy() + .map(|tx| (if tx.signature().v() { 1u64 } else { 0 }).pretty()) + .unwrap_or_default(), + self.value().pretty(), ), } } } +impl UIfmt for Transaction { + fn pretty(&self) -> String { + format!( + " +blockHash {} +blockNumber {} +from {} +transactionIndex {} +effectiveGasPrice {} +{} + ", + self.block_hash.pretty(), + self.block_number.pretty(), + self.from.pretty(), + self.transaction_index.pretty(), + self.effective_gas_price.pretty(), + self.inner.pretty(), + ) + } +} + impl UIfmt for WithOtherFields { fn pretty(&self) -> String { format!("{}{}", self.inner.pretty(), self.other.pretty()) @@ -555,28 +804,39 @@ impl UIfmt for EthValue { } /// Returns the `UiFmt::pretty()` formatted attribute of the transactions -pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option { +pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) -> Option { + let sig = match &transaction.inner { + AnyTxEnvelope::Ethereum(envelope) => match &envelope { + TxEnvelope::Eip2930(tx) => Some(tx.signature()), + TxEnvelope::Eip1559(tx) => Some(tx.signature()), + TxEnvelope::Eip4844(tx) => Some(tx.signature()), + TxEnvelope::Eip7702(tx) => Some(tx.signature()), + TxEnvelope::Legacy(tx) => Some(tx.signature()), + _ => None, + }, + _ => None, + }; match attr { "blockHash" | "block_hash" => Some(transaction.block_hash.pretty()), "blockNumber" | "block_number" => Some(transaction.block_number.pretty()), "from" => Some(transaction.from.pretty()), - "gas" => Some(transaction.gas.pretty()), - "gasPrice" | "gas_price" => Some(transaction.gas_price.pretty()), - "hash" => Some(transaction.hash.pretty()), - "input" => Some(transaction.input.pretty()), - "nonce" => Some(transaction.nonce.to_string()), - "s" => transaction.signature.map(|s| B256::from(s.s).pretty()), - "r" => transaction.signature.map(|s| B256::from(s.r).pretty()), - "to" => Some(transaction.to.pretty()), + "gas" => Some(transaction.gas_limit().pretty()), + "gasPrice" | "gas_price" => Some(Transaction::gas_price(transaction).pretty()), + "hash" => Some(alloy_network::TransactionResponse::tx_hash(transaction).pretty()), + "input" => Some(transaction.input().pretty()), + "nonce" => Some(transaction.nonce().to_string()), + "s" => sig.map(|s| FixedBytes::from(s.s()).pretty()), + "r" => sig.map(|s| FixedBytes::from(s.r()).pretty()), + "to" => Some(transaction.to().pretty()), "transactionIndex" | "transaction_index" => Some(transaction.transaction_index.pretty()), - "v" => transaction.signature.map(|s| s.v.pretty()), - "value" => Some(transaction.value.pretty()), + "v" => sig.map(|s| U8::from_be_slice(&s.as_bytes()[64..]).pretty()), + "value" => Some(transaction.value().pretty()), _ => None, } } /// Returns the `UiFmt::pretty()` formatted attribute of the given block -pub fn get_pretty_block_attr(block: &AnyNetworkBlock, attr: &str) -> Option { +pub fn get_pretty_block_attr(block: &AnyRpcBlock, attr: &str) -> Option { match attr { "baseFeePerGas" | "base_fee_per_gas" => Some(block.header.base_fee_per_gas.pretty()), "difficulty" => Some(block.header.difficulty.pretty()), @@ -585,15 +845,15 @@ pub fn get_pretty_block_attr(block: &AnyNetworkBlock, attr: &str) -> Option Some(block.header.gas_used.pretty()), "hash" => Some(block.header.hash.pretty()), "logsBloom" | "logs_bloom" => Some(block.header.logs_bloom.pretty()), - "miner" | "author" => Some(block.header.miner.pretty()), + "miner" | "author" => Some(block.header.inner.beneficiary.pretty()), "mixHash" | "mix_hash" => Some(block.header.mix_hash.pretty()), "nonce" => Some(block.header.nonce.pretty()), "number" => Some(block.header.number.pretty()), "parentHash" | "parent_hash" => Some(block.header.parent_hash.pretty()), "transactionsRoot" | "transactions_root" => Some(block.header.transactions_root.pretty()), "receiptsRoot" | "receipts_root" => Some(block.header.receipts_root.pretty()), - "sha3Uncles" | "sha_3_uncles" => Some(block.header.uncles_hash.pretty()), - "size" => Some(block.size.pretty()), + "sha3Uncles" | "sha_3_uncles" => Some(block.header.ommers_hash.pretty()), + "size" => Some(block.header.size.pretty()), "stateRoot" | "state_root" => Some(block.header.state_root.pretty()), "timestamp" => Some(block.header.timestamp.pretty()), "totalDifficulty" | "total_difficult" => Some(block.header.total_difficulty.pretty()), @@ -610,37 +870,40 @@ pub fn get_pretty_block_attr(block: &AnyNetworkBlock, attr: &str) -> Option(block: &Block) -> String { +fn pretty_block_basics(block: &Block>) -> String { let Block { header: Header { hash, - parent_hash, - uncles_hash, - miner, - state_root, - transactions_root, - receipts_root, - logs_bloom, - difficulty, - number, - gas_limit, - gas_used, - timestamp, + size, total_difficulty, - extra_data, - mix_hash, - nonce, - base_fee_per_gas, - withdrawals_root, - blob_gas_used, - excess_blob_gas, - parent_beacon_block_root, - requests_hash, + inner: + AnyHeader { + parent_hash, + ommers_hash, + beneficiary, + state_root, + transactions_root, + receipts_root, + logs_bloom, + difficulty, + number, + gas_limit, + gas_used, + timestamp, + extra_data, + mix_hash, + nonce, + base_fee_per_gas, + withdrawals_root, + blob_gas_used, + excess_blob_gas, + parent_beacon_block_root, + requests_hash, + }, }, uncles: _, transactions: _, - size, withdrawals: _, } = block; format!( @@ -676,7 +939,7 @@ requestsHash {}", gas_used.pretty(), hash.pretty(), logs_bloom.pretty(), - miner.pretty(), + beneficiary.pretty(), mix_hash.pretty(), nonce.pretty(), number.pretty(), @@ -684,7 +947,7 @@ requestsHash {}", parent_beacon_block_root.pretty(), transactions_root.pretty(), receipts_root.pretty(), - uncles_hash.pretty(), + ommers_hash.pretty(), size.pretty(), state_root.pretty(), timestamp.pretty(), @@ -702,6 +965,7 @@ requestsHash {}", #[cfg(test)] mod tests { use super::*; + use alloy_primitives::B256; use similar_asserts::assert_eq; use std::str::FromStr; @@ -764,7 +1028,7 @@ r 0x6fca94073a0cf3381978662d46cf890602d3e9ccf6a31e4b69e8ecbd9 s 0x0e804161a2b56a37ca1f6f4c4b8bce926587afa0d9b1acc5165e6556c959d583 to 0x4a16A42407AA491564643E1dfc1fd50af29794eF transactionIndex 0 -v 56 +v 1 value 0 index 435 l1BlockNumber 12691036 @@ -973,7 +1237,7 @@ r 0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99 s 0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e to 0xdca8ce283150AB773BCbeB8d38289bdB5661dE1e transactionIndex 0 -v 37 +v 0 value 0".to_string(); let txs = match block.transactions { BlockTransactions::Full(txs) => txs, @@ -1027,11 +1291,12 @@ value 0".to_string(); #[test] fn test_pretty_tx_attr() { let block = r#"{"number":"0x3","hash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","parentHash":"0x689c70c080ca22bc0e681694fa803c1aba16a69c8b6368fed5311d279eb9de90","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x7270c1c4440180f2bd5215809ee3d545df042b67329499e1ab97eb759d31610d","stateRoot":"0x29f32984517a7d25607da485b23cefabfd443751422ca7e603395e1de9bc8a4b","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","miner":"0x0000000000000000000000000000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0x3e8","gasLimit":"0x6691b7","gasUsed":"0x5208","timestamp":"0x5ecedbb9","transactions":[{"hash":"0xc3c5f700243de37ae986082fd2af88d2a7c2752a0c0f7b9d6ac47c729d45e067","nonce":"0x2","blockHash":"0xda53da08ef6a3cbde84c33e51c04f68c3853b6a3731f10baa2324968eee63972","blockNumber":"0x3","transactionIndex":"0x0","from":"0xfdcedc3bfca10ecb0890337fbdd1977aba84807a","to":"0xdca8ce283150ab773bcbeb8d38289bdb5661de1e","value":"0x0","gas":"0x15f90","gasPrice":"0x4a817c800","input":"0x","v":"0x25","r":"0x19f2694eb9113656dbea0b925e2e7ceb43df83e601c4116aee9c0dd99130be88","s":"0x73e5764b324a4f7679d890a198ba658ba1c8cd36983ff9797e10b1b89dbb448e"}],"uncles":[]}"#; - let block: Block = serde_json::from_str(block).unwrap(); + let block: Block> = serde_json::from_str(block).unwrap(); let txs = match block.transactions { BlockTransactions::Full(txes) => txes, _ => panic!("not full transactions"), }; + assert_eq!(None, get_pretty_tx_attr(&txs[0], "")); assert_eq!(Some("3".to_string()), get_pretty_tx_attr(&txs[0], "blockNumber")); assert_eq!( @@ -1059,7 +1324,7 @@ value 0".to_string(); get_pretty_tx_attr(&txs[0], "to") ); assert_eq!(Some("0".to_string()), get_pretty_tx_attr(&txs[0], "transactionIndex")); - assert_eq!(Some("37".to_string()), get_pretty_tx_attr(&txs[0], "v")); + assert_eq!(Some("27".to_string()), get_pretty_tx_attr(&txs[0], "v")); assert_eq!(Some("0".to_string()), get_pretty_tx_attr(&txs[0], "value")); } @@ -1096,7 +1361,7 @@ value 0".to_string(); } ); - let block: AnyNetworkBlock = serde_json::from_value(json).unwrap(); + let block: AnyRpcBlock = serde_json::from_value(json).unwrap(); assert_eq!(None, get_pretty_block_attr(&block, "")); assert_eq!(Some("7".to_string()), get_pretty_block_attr(&block, "baseFeePerGas")); diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index f0ed0b54f8bda..b319da0d877b4 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -58,7 +58,7 @@ impl TransactionReceiptWithRevertReason { if let Some(block_hash) = self.receipt.block_hash { match provider - .call(&WithOtherFields::new(transaction.inner.into())) + .call(&transaction.inner.inner.into()) .block(BlockId::Hash(block_hash.into())) .await { diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index c9f5131d7f34e..2abf9b22fed50 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -29,8 +29,9 @@ alloy-primitives = { workspace = true, features = [ "rlp", ] } alloy-provider.workspace = true +alloy-network.workspace = true +alloy-consensus.workspace = true alloy-rpc-types.workspace = true -alloy-serde.workspace = true alloy-sol-types.workspace = true alloy-transport.workspace = true foundry-fork-db.workspace = true diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index e70468ef944c2..2db34ad290b0b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -7,10 +7,11 @@ use crate::{ utils::{configure_tx_env, configure_tx_req_env, new_evm_with_inspector}, InspectorExt, }; +use alloy_consensus::Transaction as TransactionTrait; use alloy_genesis::GenesisAccount; +use alloy_network::{AnyRpcBlock, AnyTxEnvelope, TransactionResponse}; use alloy_primitives::{keccak256, uint, Address, TxKind, B256, U256}; -use alloy_rpc_types::{Block, BlockNumberOrTag, Transaction, TransactionRequest}; -use alloy_serde::WithOtherFields; +use alloy_rpc_types::{BlockNumberOrTag, Transaction, TransactionRequest}; use eyre::Context; use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; pub use foundry_fork_db::{cache::BlockchainDbMeta, BlockchainDb, SharedBackend}; @@ -839,7 +840,7 @@ impl Backend { &self, id: LocalForkId, transaction: B256, - ) -> eyre::Result<(u64, Block>)> { + ) -> eyre::Result<(u64, AnyRpcBlock)> { let fork = self.inner.get_fork_by_id(id)?; let tx = fork.db.db.get_transaction(transaction)?; @@ -850,14 +851,12 @@ impl Backend { // we need to subtract 1 here because we want the state before the transaction // was mined let fork_block = tx_block - 1; - Ok((fork_block, block.inner)) + Ok((fork_block, block)) } else { let block = fork.db.db.get_full_block(BlockNumberOrTag::Latest)?; let number = block.header.number; - let block = block.inner; - Ok((number, block)) } } @@ -871,7 +870,7 @@ impl Backend { env: Env, tx_hash: B256, journaled_state: &mut JournaledState, - ) -> eyre::Result> { + ) -> eyre::Result>> { trace!(?id, ?tx_hash, "replay until transaction"); let persistent_accounts = self.inner.persistent_accounts.clone(); @@ -885,17 +884,17 @@ impl Backend { // System transactions such as on L2s don't contain any pricing info so we skip them // otherwise this would cause reverts if is_known_system_sender(tx.from) || - tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE) + tx.transaction_type() == Some(SYSTEM_TRANSACTION_TYPE) { - trace!(tx=?tx.hash, "skipping system transaction"); + trace!(tx=?tx.tx_hash(), "skipping system transaction"); continue; } - if tx.hash == tx_hash { + if tx.tx_hash() == tx_hash { // found the target transaction return Ok(Some(tx.inner)) } - trace!(tx=?tx.hash, "committing transaction"); + trace!(tx=?tx.tx_hash(), "committing transaction"); commit_transaction( &tx.inner, @@ -1914,9 +1913,9 @@ fn is_contract_in_state(journaled_state: &JournaledState, acc: Address) -> bool } /// Updates the env's block with the block's data -fn update_env_block(env: &mut Env, block: &Block) { +fn update_env_block(env: &mut Env, block: &AnyRpcBlock) { env.block.timestamp = U256::from(block.header.timestamp); - env.block.coinbase = block.header.miner; + env.block.coinbase = block.header.beneficiary; env.block.difficulty = block.header.difficulty; env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); @@ -1930,7 +1929,7 @@ fn update_env_block(env: &mut Env, block: &Block) { /// Executes the given transaction and commits state changes to the database _and_ the journaled /// state, with an inspector. fn commit_transaction( - tx: &Transaction, + tx: &Transaction, mut env: EnvWithHandlerCfg, journaled_state: &mut JournaledState, fork: &mut Fork, @@ -1940,7 +1939,7 @@ fn commit_transaction( ) -> eyre::Result<()> { // TODO: Remove after https://github.com/foundry-rs/foundry/pull/9131 // if the tx has the blob_versioned_hashes field, we assume it's a Cancun block - if tx.blob_versioned_hashes.is_some() { + if tx.blob_versioned_hashes().is_some() { env.handler_cfg.spec_id = SpecId::CANCUN; } diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index b32fece5a0373..ae3f9b7a04b14 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -1,10 +1,8 @@ use crate::utils::apply_chain_and_block_specific_env_changes; +use alloy_consensus::BlockHeader; use alloy_primitives::{Address, U256}; -use alloy_provider::{ - network::{BlockResponse, HeaderResponse}, - Network, Provider, -}; -use alloy_rpc_types::BlockNumberOrTag; +use alloy_provider::{network::BlockResponse, Network, Provider}; +use alloy_rpc_types::{BlockNumberOrTag, BlockTransactionsKind}; use alloy_transport::Transport; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; @@ -30,7 +28,10 @@ pub async fn environment>( let (fork_gas_price, rpc_chain_id, block) = tokio::try_join!( provider.get_gas_price(), provider.get_chain_id(), - provider.get_block_by_number(BlockNumberOrTag::Number(block_number), false) + provider.get_block_by_number( + BlockNumberOrTag::Number(block_number), + BlockTransactionsKind::Hashes + ) )?; let block = if let Some(block) = block { block @@ -66,7 +67,7 @@ pub async fn environment>( block: BlockEnv { number: U256::from(block.header().number()), timestamp: U256::from(block.header().timestamp()), - coinbase: block.header().coinbase(), + coinbase: block.header().beneficiary(), difficulty: block.header().difficulty(), prevrandao: block.header().mix_hash(), basefee: U256::from(block.header().base_fee_per_gas().unwrap_or_default()), diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 14fa59aafc1f4..112e1eeda7d4b 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -4,8 +4,9 @@ //! concurrently active pairs at once. use super::CreateFork; +use alloy_consensus::BlockHeader; use alloy_primitives::{map::HashMap, U256}; -use alloy_provider::network::{BlockResponse, HeaderResponse}; +use alloy_provider::network::BlockResponse; use alloy_transport::layers::RetryBackoffService; use foundry_common::provider::{ runtime_transport::RuntimeTransport, ProviderBuilder, RetryProvider, diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 99cc8dabaf076..9849fd1cef9c0 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,8 +1,7 @@ use super::fork::environment; use crate::fork::CreateFork; use alloy_primitives::{Address, B256, U256}; -use alloy_provider::Provider; -use alloy_rpc_types::AnyNetworkBlock; +use alloy_provider::{network::AnyRpcBlock, Provider}; use eyre::WrapErr; use foundry_common::{provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS}; use foundry_config::{Chain, Config}; @@ -87,7 +86,7 @@ impl EvmOpts { pub async fn fork_evm_env( &self, fork_url: impl AsRef, - ) -> eyre::Result<(revm::primitives::Env, AnyNetworkBlock)> { + ) -> eyre::Result<(revm::primitives::Env, AnyRpcBlock)> { let fork_url = fork_url.as_ref(); let provider = ProviderBuilder::new(fork_url) .compute_units_per_second(self.get_compute_units_per_second()) diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index d76cd087ce168..be9660c72ac4a 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -3,12 +3,11 @@ use crate::{ backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER, precompiles::ALPHANET_P256, InspectorExt, }; +use alloy_consensus::BlockHeader; use alloy_json_abi::{Function, JsonAbi}; +use alloy_network::AnyTxEnvelope; use alloy_primitives::{Address, Selector, TxKind, U256}; -use alloy_provider::{ - network::{BlockResponse, HeaderResponse}, - Network, -}; +use alloy_provider::{network::BlockResponse, Network}; use alloy_rpc_types::{Transaction, TransactionRequest}; use foundry_config::NamedChain; use foundry_fork_db::DatabaseError; @@ -85,8 +84,10 @@ pub fn get_function<'a>( } /// Configures the env for the given RPC transaction. -pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { - configure_tx_req_env(env, &tx.clone().into()).expect("cannot fail"); +pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { + if let AnyTxEnvelope::Ethereum(tx) = &tx.inner { + configure_tx_req_env(env, &tx.clone().into()).expect("cannot fail"); + } } /// Configures the env for the given RPC transaction request. diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index cd86c42006258..d3079fae72cfd 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -8,10 +8,13 @@ use crate::{ verify::VerifierArgs, }; use alloy_primitives::{hex, Address, Bytes, U256}; -use alloy_provider::Provider; -use alloy_rpc_types::{BlockId, BlockNumberOrTag, Transaction}; +use alloy_provider::{ + network::{AnyTxEnvelope, TransactionBuilder}, + Provider, +}; +use alloy_rpc_types::{BlockId, BlockNumberOrTag, TransactionInput, TransactionRequest}; use clap::{Parser, ValueHint}; -use eyre::{OptionExt, Result}; +use eyre::{Context, OptionExt, Result}; use foundry_cli::{ opts::EtherscanOpts, utils::{self, read_constructor_args_file, LoadConfig}, @@ -19,8 +22,8 @@ use foundry_cli::{ use foundry_common::shell; use foundry_compilers::{artifacts::EvmVersion, info::ContractInfo}; use foundry_config::{figment, impl_figment_convert, Config}; -use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, utils::configure_tx_env}; -use revm_primitives::AccountInfo; +use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, utils::configure_tx_req_env}; +use revm_primitives::{AccountInfo, TxKind}; use std::path::PathBuf; impl_figment_convert!(VerifyBytecodeArgs); @@ -244,21 +247,22 @@ impl VerifyBytecodeArgs { // Setup genesis tx and env. let deployer = Address::with_last_byte(0x1); - let mut gen_tx = Transaction { - from: deployer, - to: None, - input: Bytes::from(local_bytecode_vec), - ..Default::default() - }; + let mut gen_tx_req = TransactionRequest::default() + .with_from(deployer) + .with_input(Bytes::from(local_bytecode_vec)) + .into_create(); if let Some(ref block) = genesis_block { configure_env_block(&mut env, block); - gen_tx.max_fee_per_gas = block.header.base_fee_per_gas.map(|g| g as u128); - gen_tx.gas = block.header.gas_limit; - gen_tx.gas_price = block.header.base_fee_per_gas.map(|g| g as u128); + gen_tx_req.max_fee_per_gas = block.header.base_fee_per_gas.map(|g| g as u128); + gen_tx_req.gas = Some(block.header.gas_limit); + gen_tx_req.gas_price = block.header.base_fee_per_gas.map(|g| g as u128); } - configure_tx_env(&mut env, &gen_tx); + // configure_tx_rq_env(&mut env, &gen_tx); + + configure_tx_req_env(&mut env, &gen_tx_req) + .wrap_err("Failed to configure tx request env")?; // Seed deployer account with funds let account_info = AccountInfo { @@ -268,8 +272,12 @@ impl VerifyBytecodeArgs { }; executor.backend_mut().insert_account_info(deployer, account_info); - let fork_address = - crate::utils::deploy_contract(&mut executor, &env, config.evm_spec_id(), &gen_tx)?; + let fork_address = crate::utils::deploy_contract( + &mut executor, + &env, + config.evm_spec_id(), + gen_tx_req.to, + )?; // Compare runtime bytecode let (deployed_bytecode, onchain_runtime_code) = crate::utils::get_runtime_codes( @@ -308,7 +316,7 @@ impl VerifyBytecodeArgs { let creation_data = creation_data.unwrap(); // Get transaction and receipt. trace!(creation_tx_hash = ?creation_data.transaction_hash); - let mut transaction = provider + let transaction = provider .get_transaction_by_hash(creation_data.transaction_hash) .await .or_else(|e| eyre::bail!("Couldn't fetch transaction from RPC: {:?}", e))? @@ -328,12 +336,23 @@ impl VerifyBytecodeArgs { ); }; + let mut transaction: TransactionRequest = match transaction.inner.inner { + AnyTxEnvelope::Ethereum(tx) => tx.into(), + AnyTxEnvelope::Unknown(_) => unreachable!("Unknown transaction type"), + }; + // Extract creation code from creation tx input. let maybe_creation_code = if receipt.to.is_none() && receipt.contract_address == Some(self.address) { - &transaction.input + match &transaction.input.input { + Some(input) => &input[..], + None => unreachable!("creation tx input is None"), + } } else if receipt.to == Some(DEFAULT_CREATE2_DEPLOYER) { - &transaction.input[32..] + match &transaction.input.input { + Some(input) => &input[32..], + None => unreachable!("creation tx input is None"), + } } else { eyre::bail!( "Could not extract the creation code for contract at address {}", @@ -434,35 +453,39 @@ impl VerifyBytecodeArgs { // Use `transaction.from` instead of `creation_data.contract_creator` to resolve // blockscout creation data discrepancy in case of CREATE2. - let prev_block_nonce = - provider.get_transaction_count(transaction.from).block_id(prev_block_id).await?; - transaction.nonce = prev_block_nonce; + let prev_block_nonce = provider + .get_transaction_count(transaction.from.unwrap()) + .block_id(prev_block_id) + .await?; + transaction.set_nonce(prev_block_nonce); if let Some(ref block) = block { configure_env_block(&mut env, block) } // Replace the `input` with local creation code in the creation tx. - if let Some(to) = transaction.to { + if let Some(TxKind::Call(to)) = transaction.kind() { if to == DEFAULT_CREATE2_DEPLOYER { - let mut input = transaction.input[..32].to_vec(); // Salt + let mut input = transaction.input.input.unwrap()[..32].to_vec(); // Salt input.extend_from_slice(&local_bytecode_vec); - transaction.input = Bytes::from(input); + transaction.input = TransactionInput::both(Bytes::from(input)); // Deploy default CREATE2 deployer executor.deploy_create2_deployer()?; } } else { - transaction.input = Bytes::from(local_bytecode_vec); + transaction.input = TransactionInput::both(Bytes::from(local_bytecode_vec)); } - configure_tx_env(&mut env, &transaction.inner); + // configure_req__env(&mut env, &transaction.inner); + configure_tx_req_env(&mut env, &transaction) + .wrap_err("Failed to configure tx request env")?; let fork_address = crate::utils::deploy_contract( &mut executor, &env, config.evm_spec_id(), - &transaction, + transaction.to, )?; // State committed using deploy_with_env, now get the runtime bytecode from the db. diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index ae1443962af66..ca90129d543bb 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -6,6 +6,7 @@ use crate::{ use alloy_json_abi::Function; use alloy_primitives::hex; use alloy_provider::Provider; +use alloy_rpc_types::TransactionTrait; use eyre::{eyre, Context, OptionExt, Result}; use foundry_block_explorers::{ errors::EtherscanError, @@ -402,9 +403,9 @@ impl EtherscanVerificationProvider { .ok_or_eyre("Couldn't fetch transaction receipt from RPC")?; let maybe_creation_code = if receipt.contract_address == Some(args.address) { - &transaction.input - } else if transaction.to == Some(DEFAULT_CREATE2_DEPLOYER) { - &transaction.input[32..] + transaction.inner.inner.input() + } else if transaction.to() == Some(DEFAULT_CREATE2_DEPLOYER) { + &transaction.inner.inner.input()[32..] } else { eyre::bail!("Fetching of constructor arguments is not supported for contracts created by contracts") }; diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 19c63e7fb3eca..a14d6af6df964 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -1,8 +1,8 @@ use crate::{bytecode::VerifyBytecodeArgs, types::VerificationType}; use alloy_dyn_abi::DynSolValue; use alloy_primitives::{Address, Bytes, U256}; -use alloy_provider::Provider; -use alloy_rpc_types::{AnyNetworkBlock, BlockId, Transaction}; +use alloy_provider::{network::AnyRpcBlock, Provider}; +use alloy_rpc_types::BlockId; use clap::ValueEnum; use eyre::{OptionExt, Result}; use foundry_block_explorers::{ @@ -17,7 +17,7 @@ use reqwest::Url; use revm_primitives::{ db::Database, env::{EnvWithHandlerCfg, HandlerCfg}, - Bytecode, Env, SpecId, + Bytecode, Env, SpecId, TxKind, }; use semver::Version; use serde::{Deserialize, Serialize}; @@ -340,9 +340,9 @@ pub async fn get_tracing_executor( Ok((env, executor)) } -pub fn configure_env_block(env: &mut Env, block: &AnyNetworkBlock) { +pub fn configure_env_block(env: &mut Env, block: &AnyRpcBlock) { env.block.timestamp = U256::from(block.header.timestamp); - env.block.coinbase = block.header.miner; + env.block.coinbase = block.header.beneficiary; env.block.difficulty = block.header.difficulty; env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default()); env.block.basefee = U256::from(block.header.base_fee_per_gas.unwrap_or_default()); @@ -353,11 +353,12 @@ pub fn deploy_contract( executor: &mut TracingExecutor, env: &Env, spec_id: SpecId, - transaction: &Transaction, + to: Option, ) -> Result { let env_with_handler = EnvWithHandlerCfg::new(Box::new(env.clone()), HandlerCfg::new(spec_id)); - if let Some(to) = transaction.to { + if to.is_some_and(|to| to.is_call()) { + let TxKind::Call(to) = to.unwrap() else { unreachable!() }; if to != DEFAULT_CREATE2_DEPLOYER { eyre::bail!("Transaction `to` address is not the default create2 deployer i.e the tx is not a contract creation tx."); } diff --git a/crates/wallets/src/wallet_signer.rs b/crates/wallets/src/wallet_signer.rs index a7bc1a312a364..812df986300be 100644 --- a/crates/wallets/src/wallet_signer.rs +++ b/crates/wallets/src/wallet_signer.rs @@ -2,8 +2,8 @@ use crate::error::WalletSignerError; use alloy_consensus::SignableTransaction; use alloy_dyn_abi::TypedData; use alloy_network::TxSigner; -use alloy_primitives::{hex, Address, ChainId, B256}; -use alloy_signer::{Signature, Signer}; +use alloy_primitives::{hex, Address, ChainId, PrimitiveSignature, B256}; +use alloy_signer::Signer; use alloy_signer_ledger::{HDPath as LedgerHDPath, LedgerSigner}; use alloy_signer_local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner}; use alloy_signer_trezor::{HDPath as TrezorHDPath, TrezorSigner}; @@ -198,11 +198,11 @@ macro_rules! delegate { #[async_trait] impl Signer for WalletSigner { /// Signs the given hash. - async fn sign_hash(&self, hash: &B256) -> alloy_signer::Result { + async fn sign_hash(&self, hash: &B256) -> alloy_signer::Result { delegate!(self, inner => inner.sign_hash(hash)).await } - async fn sign_message(&self, message: &[u8]) -> alloy_signer::Result { + async fn sign_message(&self, message: &[u8]) -> alloy_signer::Result { delegate!(self, inner => inner.sign_message(message)).await } @@ -222,7 +222,7 @@ impl Signer for WalletSigner { &self, payload: &T, domain: &Eip712Domain, - ) -> alloy_signer::Result + ) -> alloy_signer::Result where Self: Sized, { @@ -232,21 +232,21 @@ impl Signer for WalletSigner { async fn sign_dynamic_typed_data( &self, payload: &TypedData, - ) -> alloy_signer::Result { + ) -> alloy_signer::Result { delegate!(self, inner => inner.sign_dynamic_typed_data(payload)).await } } #[async_trait] -impl TxSigner for WalletSigner { +impl TxSigner for WalletSigner { fn address(&self) -> Address { delegate!(self, inner => alloy_signer::Signer::address(inner)) } async fn sign_transaction( &self, - tx: &mut dyn SignableTransaction, - ) -> alloy_signer::Result { + tx: &mut dyn SignableTransaction, + ) -> alloy_signer::Result { delegate!(self, inner => inner.sign_transaction(tx)).await } } From 057c8ac20d2c2580237ed24557df846b48ab35b2 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:32:32 +0530 Subject: [PATCH 1704/1963] feat(`anvil`): `--cache-path` (#9343) * feat(`anvil`): --cache-path * nits * test * nit * run with tempdir * nit --- Cargo.lock | 18 +++++++++++ Cargo.toml | 1 + crates/anvil/Cargo.toml | 1 + crates/anvil/src/cmd.rs | 7 ++++- crates/anvil/src/config.rs | 11 +++++++ crates/anvil/src/eth/backend/mem/cache.rs | 4 +++ crates/anvil/src/eth/backend/mem/mod.rs | 9 ++++-- crates/anvil/src/eth/backend/mem/storage.rs | 8 ++++- crates/anvil/tests/it/anvil.rs | 34 ++++++++++++++++++++- 9 files changed, 88 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebc0c4e0bbe18..bb06adac6ca3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,6 +262,23 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-node-bindings" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27444ea67d360508753022807cdd0b49a95c878924c9c5f8f32668b7d7768245" +dependencies = [ + "alloy-genesis", + "alloy-primitives", + "k256", + "rand", + "serde_json", + "tempfile", + "thiserror 1.0.69", + "tracing", + "url", +] + [[package]] name = "alloy-primitives" version = "0.8.12" @@ -875,6 +892,7 @@ dependencies = [ "alloy-json-abi", "alloy-json-rpc", "alloy-network", + "alloy-node-bindings", "alloy-primitives", "alloy-provider", "alloy-pubsub", diff --git a/Cargo.toml b/Cargo.toml index f5ec94b906bc7..b2008ad5b64db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -203,6 +203,7 @@ alloy-transport = { version = "0.6.4", default-features = false } alloy-transport-http = { version = "0.6.4", default-features = false } alloy-transport-ipc = { version = "0.6.4", default-features = false } alloy-transport-ws = { version = "0.6.4", default-features = false } +alloy-node-bindings = { version = "0.6.4", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.11" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index b3389d2eccae4..39a8bc649dcb1 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -117,6 +117,7 @@ alloy-rpc-client = { workspace = true, features = ["pubsub"] } alloy-transport-ipc = { workspace = true, features = ["mock"] } alloy-provider = { workspace = true, features = ["txpool-api"] } alloy-transport-ws.workspace = true +alloy-node-bindings.workspace = true alloy-json-rpc.workspace = true alloy-pubsub.workspace = true foundry-test-utils.workspace = true diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 839dae0160b2e..eda009418c148 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -189,6 +189,10 @@ pub struct NodeArgs { #[command(flatten)] pub server_config: ServerConfig, + + /// Path to the cache directory where states are stored. + #[arg(long, value_name = "PATH")] + pub cache_path: Option, } #[cfg(windows)] @@ -274,7 +278,8 @@ impl NodeArgs { .with_alphanet(self.evm_opts.alphanet) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) - .with_memory_limit(self.evm_opts.memory_limit)) + .with_memory_limit(self.evm_opts.memory_limit) + .with_cache_path(self.cache_path)) } fn account_generator(&self) -> AccountGenerator { diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 714f91e6d7a80..ada48232904ba 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -189,6 +189,8 @@ pub struct NodeConfig { pub alphanet: bool, /// Do not print log messages. pub silent: bool, + /// The path where states are cached. + pub cache_path: Option, } impl NodeConfig { @@ -465,6 +467,7 @@ impl Default for NodeConfig { precompile_factory: None, alphanet: false, silent: false, + cache_path: None, } } } @@ -969,6 +972,13 @@ impl NodeConfig { self } + /// Sets the path where states are cached + #[must_use] + pub fn with_cache_path(mut self, cache_path: Option) -> Self { + self.cache_path = cache_path; + self + } + /// Configures everything related to env, backend and database and returns the /// [Backend](mem::Backend) /// @@ -1051,6 +1061,7 @@ impl NodeConfig { self.max_persisted_states, self.transaction_block_keeper, self.block_time, + self.cache_path.clone(), Arc::new(tokio::sync::RwLock::new(self.clone())), ) .await; diff --git a/crates/anvil/src/eth/backend/mem/cache.rs b/crates/anvil/src/eth/backend/mem/cache.rs index e51aaae7e1ae9..51b92c3d65d76 100644 --- a/crates/anvil/src/eth/backend/mem/cache.rs +++ b/crates/anvil/src/eth/backend/mem/cache.rs @@ -18,6 +18,10 @@ pub struct DiskStateCache { } impl DiskStateCache { + /// Specify the path where to create the tempdir in + pub fn with_path(self, temp_path: PathBuf) -> Self { + Self { temp_path: Some(temp_path), temp_dir: None } + } /// Returns the cache file for the given hash fn with_cache_file(&mut self, hash: B256, f: F) -> Option where diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 0db343358fecc..83718ad821aad 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -103,12 +103,12 @@ use revm::{ use std::{ collections::BTreeMap, io::{Read, Write}, + path::PathBuf, sync::Arc, time::Duration, }; use storage::{Blockchain, MinedTransaction, DEFAULT_HISTORY_LIMIT}; use tokio::sync::RwLock as AsyncRwLock; - pub mod cache; pub mod fork_db; pub mod in_memory_db; @@ -227,6 +227,7 @@ impl Backend { max_persisted_states: Option, transaction_block_keeper: Option, automine_block_time: Option, + cache_path: Option, node_config: Arc>, ) -> Self { // if this is a fork then adjust the blockchain storage @@ -249,7 +250,7 @@ impl Backend { genesis.timestamp }; - let states = if prune_state_history_config.is_config_enabled() { + let mut states = if prune_state_history_config.is_config_enabled() { // if prune state history is enabled, configure the state cache only for memory prune_state_history_config .max_memory_history @@ -264,6 +265,10 @@ impl Backend { Default::default() }; + if let Some(cache_path) = cache_path { + states = states.disk_path(cache_path); + } + let (slots_in_an_epoch, precompile_factory) = { let cfg = node_config.read().await; (cfg.slots_in_an_epoch, cfg.precompile_factory.clone()) diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index d5a72fccbbb63..056b886277c9f 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -41,7 +41,7 @@ use foundry_evm::{ }; use parking_lot::RwLock; use revm::primitives::SpecId; -use std::{collections::VecDeque, fmt, sync::Arc, time::Duration}; +use std::{collections::VecDeque, fmt, path::PathBuf, sync::Arc, time::Duration}; // use yansi::Paint; // === various limits in number of blocks === @@ -94,6 +94,12 @@ impl InMemoryBlockStates { self } + /// Configures the path on disk where the states will cached. + pub fn disk_path(mut self, path: PathBuf) -> Self { + self.disk_cache = self.disk_cache.with_path(path); + self + } + /// This modifies the `limit` what to keep stored in memory. /// /// This will ensure the new limit adjusts based on the block time. diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index 65eeac70baf77..b5ed0c85312fa 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -2,9 +2,11 @@ use alloy_consensus::EMPTY_ROOT_HASH; use alloy_eips::BlockNumberOrTag; -use alloy_primitives::Address; +use alloy_node_bindings::utils::run_with_tempdir; +use alloy_primitives::{Address, U256}; use alloy_provider::Provider; use anvil::{spawn, EthereumHardfork, NodeConfig}; +use std::time::Duration; #[tokio::test(flavor = "multi_thread")] async fn test_can_change_mining_mode() { @@ -118,3 +120,33 @@ async fn test_cancun_fields() { assert!(block.header.blob_gas_used.is_some()); assert!(block.header.excess_blob_gas.is_some()); } + +#[tokio::test(flavor = "multi_thread")] +#[cfg(not(windows))] +async fn test_cache_path() { + run_with_tempdir("custom-anvil-cache", |tmp_dir| async move { + let cache_path = tmp_dir.join("cache"); + let (api, _handle) = spawn( + NodeConfig::test() + .with_cache_path(Some(cache_path.clone())) + .with_max_persisted_states(Some(5_usize)) + .with_blocktime(Some(Duration::from_millis(1))), + ) + .await; + + api.anvil_mine(Some(U256::from(1000)), None).await.unwrap(); + + // sleep to ensure the cache is written + tokio::time::sleep(Duration::from_secs(2)).await; + + assert!(cache_path.exists()); + assert!(cache_path.read_dir().unwrap().count() > 0); + + // Clean the directory, this is to prevent an error when temp_dir is dropped. + let _ = std::fs::remove_dir_all(cache_path); + + //sleep to ensure OS file handles are released + tokio::time::sleep(Duration::from_secs(1)).await; + }) + .await; +} From 9504f78cb7bf9c4fc77de9a18f6d8383896f8238 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:43:21 +0530 Subject: [PATCH 1705/1963] chore: rm flaky cache-path test (#9372) --- Cargo.lock | 18 ------------------ Cargo.toml | 1 - crates/anvil/Cargo.toml | 1 - crates/anvil/tests/it/anvil.rs | 34 +--------------------------------- 4 files changed, 1 insertion(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb06adac6ca3b..ebc0c4e0bbe18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,23 +262,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-node-bindings" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27444ea67d360508753022807cdd0b49a95c878924c9c5f8f32668b7d7768245" -dependencies = [ - "alloy-genesis", - "alloy-primitives", - "k256", - "rand", - "serde_json", - "tempfile", - "thiserror 1.0.69", - "tracing", - "url", -] - [[package]] name = "alloy-primitives" version = "0.8.12" @@ -892,7 +875,6 @@ dependencies = [ "alloy-json-abi", "alloy-json-rpc", "alloy-network", - "alloy-node-bindings", "alloy-primitives", "alloy-provider", "alloy-pubsub", diff --git a/Cargo.toml b/Cargo.toml index b2008ad5b64db..f5ec94b906bc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -203,7 +203,6 @@ alloy-transport = { version = "0.6.4", default-features = false } alloy-transport-http = { version = "0.6.4", default-features = false } alloy-transport-ipc = { version = "0.6.4", default-features = false } alloy-transport-ws = { version = "0.6.4", default-features = false } -alloy-node-bindings = { version = "0.6.4", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.11" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 39a8bc649dcb1..b3389d2eccae4 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -117,7 +117,6 @@ alloy-rpc-client = { workspace = true, features = ["pubsub"] } alloy-transport-ipc = { workspace = true, features = ["mock"] } alloy-provider = { workspace = true, features = ["txpool-api"] } alloy-transport-ws.workspace = true -alloy-node-bindings.workspace = true alloy-json-rpc.workspace = true alloy-pubsub.workspace = true foundry-test-utils.workspace = true diff --git a/crates/anvil/tests/it/anvil.rs b/crates/anvil/tests/it/anvil.rs index b5ed0c85312fa..65eeac70baf77 100644 --- a/crates/anvil/tests/it/anvil.rs +++ b/crates/anvil/tests/it/anvil.rs @@ -2,11 +2,9 @@ use alloy_consensus::EMPTY_ROOT_HASH; use alloy_eips::BlockNumberOrTag; -use alloy_node_bindings::utils::run_with_tempdir; -use alloy_primitives::{Address, U256}; +use alloy_primitives::Address; use alloy_provider::Provider; use anvil::{spawn, EthereumHardfork, NodeConfig}; -use std::time::Duration; #[tokio::test(flavor = "multi_thread")] async fn test_can_change_mining_mode() { @@ -120,33 +118,3 @@ async fn test_cancun_fields() { assert!(block.header.blob_gas_used.is_some()); assert!(block.header.excess_blob_gas.is_some()); } - -#[tokio::test(flavor = "multi_thread")] -#[cfg(not(windows))] -async fn test_cache_path() { - run_with_tempdir("custom-anvil-cache", |tmp_dir| async move { - let cache_path = tmp_dir.join("cache"); - let (api, _handle) = spawn( - NodeConfig::test() - .with_cache_path(Some(cache_path.clone())) - .with_max_persisted_states(Some(5_usize)) - .with_blocktime(Some(Duration::from_millis(1))), - ) - .await; - - api.anvil_mine(Some(U256::from(1000)), None).await.unwrap(); - - // sleep to ensure the cache is written - tokio::time::sleep(Duration::from_secs(2)).await; - - assert!(cache_path.exists()); - assert!(cache_path.read_dir().unwrap().count() > 0); - - // Clean the directory, this is to prevent an error when temp_dir is dropped. - let _ = std::fs::remove_dir_all(cache_path); - - //sleep to ensure OS file handles are released - tokio::time::sleep(Duration::from_secs(1)).await; - }) - .await; -} From fef20981cbaa9c08e1ef1e3cd8bc57ccbcd1ac4e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:12:45 +0100 Subject: [PATCH 1706/1963] feat: add global -j, --threads (#9367) * feat: add global -j, --threads * Update crates/cli/src/opts/global.rs * fix tests after comment update --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: zerosnacks --- Cargo.lock | 1 + crates/cast/bin/cmd/create2.rs | 25 +++++++++++------- crates/cast/tests/cli/main.rs | 5 ++++ crates/cli/Cargo.toml | 3 ++- crates/cli/src/opts/global.rs | 45 ++++++++++++++++++++++---------- crates/config/README.md | 2 +- crates/forge/bin/cmd/test/mod.rs | 18 +------------ crates/forge/tests/cli/cmd.rs | 5 ++++ crates/script/src/lib.rs | 2 +- 9 files changed, 62 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebc0c4e0bbe18..4a7cb9a73c5d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3686,6 +3686,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", + "rayon", "regex", "serde", "serde_json", diff --git a/crates/cast/bin/cmd/create2.rs b/crates/cast/bin/cmd/create2.rs index 17523e094577b..f46066137dbb8 100644 --- a/crates/cast/bin/cmd/create2.rs +++ b/crates/cast/bin/cmd/create2.rs @@ -4,7 +4,6 @@ use eyre::{Result, WrapErr}; use rand::{rngs::StdRng, RngCore, SeedableRng}; use regex::RegexSetBuilder; use std::{ - num::NonZeroUsize, sync::{ atomic::{AtomicBool, Ordering}, Arc, @@ -73,9 +72,9 @@ pub struct Create2Args { #[arg(alias = "ch", long, value_name = "HASH", required_unless_present = "init_code")] init_code_hash: Option, - /// Number of threads to use. Defaults to and caps at the number of logical cores. - #[arg(short, long)] - jobs: Option, + /// Number of threads to use. Specifying 0 defaults to the number of logical cores. + #[arg(global = true, long, short = 'j', visible_alias = "jobs")] + threads: Option, /// Address of the caller. Used for the first 20 bytes of the salt. #[arg(long, value_name = "ADDRESS")] @@ -107,7 +106,7 @@ impl Create2Args { salt, init_code, init_code_hash, - jobs, + threads, caller, seed, no_random, @@ -168,8 +167,8 @@ impl Create2Args { let regex = RegexSetBuilder::new(regexs).case_insensitive(!case_sensitive).build()?; let mut n_threads = std::thread::available_parallelism().map_or(1, |n| n.get()); - if let Some(jobs) = jobs { - n_threads = n_threads.min(jobs.get()); + if let Some(threads) = threads { + n_threads = n_threads.min(threads); } if cfg!(test) { n_threads = n_threads.min(2); @@ -433,8 +432,14 @@ mod tests { #[test] fn j0() { - let e = - Create2Args::try_parse_from(["foundry-cli", "--starts-with=00", "-j0"]).unwrap_err(); - let _ = e.print(); + let args = Create2Args::try_parse_from([ + "foundry-cli", + "--starts-with=00", + "--init-code-hash", + &B256::ZERO.to_string(), + "-j0", + ]) + .unwrap(); + assert_eq!(args.threads, Some(0)); } } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 2483fa479820f..bdc4a6044d0c7 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -28,6 +28,11 @@ Options: -h, --help Print help (see a summary with '-h') + -j, --threads + Number of threads to use. Specifying 0 defaults to the number of logical cores + + [aliases: jobs] + -V, --version Print version diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 9fa867db3c8f4..8b741937d7c65 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -37,7 +37,9 @@ dotenvy = "0.15" eyre.workspace = true futures.workspace = true indicatif = "0.17" +rayon.workspace = true regex = { workspace = true, default-features = false } +serde_json.workspace = true serde.workspace = true strsim = "0.11" strum = { workspace = true, features = ["derive"] } @@ -45,7 +47,6 @@ tokio = { workspace = true, features = ["macros"] } tracing-subscriber = { workspace = true, features = ["registry", "env-filter"] } tracing.workspace = true yansi.workspace = true -serde_json.workspace = true tracing-tracy = { version = "0.11", optional = true } diff --git a/crates/cli/src/opts/global.rs b/crates/cli/src/opts/global.rs index 99690a530d3f5..ad715f24180a1 100644 --- a/crates/cli/src/opts/global.rs +++ b/crates/cli/src/opts/global.rs @@ -3,7 +3,7 @@ use foundry_common::shell::{ColorChoice, OutputFormat, OutputMode, Shell, Verbos use serde::{Deserialize, Serialize}; /// Global options. -#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Parser)] +#[derive(Clone, Debug, Default, Serialize, Deserialize, Parser)] pub struct GlobalOpts { /// Verbosity level of the log messages. /// @@ -16,39 +16,47 @@ pub struct GlobalOpts { /// - 3 (-vvv): Print execution traces for failing tests. /// - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. /// - 5 (-vvvvv): Print execution and setup traces for all tests. - #[clap(short, long, global = true, verbatim_doc_comment, conflicts_with = "quiet", action = ArgAction::Count, help_heading = "Display options")] - pub verbosity: Verbosity, + #[arg(help_heading = "Display options", global = true, short, long, verbatim_doc_comment, conflicts_with = "quiet", action = ArgAction::Count)] + verbosity: Verbosity, /// Do not print log messages. - #[clap(short, long, global = true, alias = "silent", help_heading = "Display options")] + #[arg(help_heading = "Display options", global = true, short, long, alias = "silent")] quiet: bool, /// Format log messages as JSON. - #[clap( - long, - global = true, - alias = "format-json", - conflicts_with_all = &["quiet", "color"], - help_heading = "Display options" - )] + #[arg(help_heading = "Display options", global = true, long, alias = "format-json", conflicts_with_all = &["quiet", "color"])] json: bool, /// The color of the log messages. - #[clap(long, global = true, value_enum, help_heading = "Display options")] + #[arg(help_heading = "Display options", global = true, long, value_enum)] color: Option, + + /// Number of threads to use. Specifying 0 defaults to the number of logical cores. + #[arg(global = true, long, short = 'j', visible_alias = "jobs")] + threads: Option, } impl GlobalOpts { /// Initialize the global options. - pub fn init(self) -> eyre::Result<()> { + pub fn init(&self) -> eyre::Result<()> { // Set the global shell. self.shell().set(); + // Initialize the thread pool only if `threads` was requested to avoid unnecessary overhead. + if self.threads.is_some() { + self.force_init_thread_pool()?; + } + Ok(()) } + /// Initialize the global thread pool. + pub fn force_init_thread_pool(&self) -> eyre::Result<()> { + init_thread_pool(self.threads.unwrap_or(0)) + } + /// Create a new shell instance. - pub fn shell(self) -> Shell { + pub fn shell(&self) -> Shell { let mode = match self.quiet { true => OutputMode::Quiet, false => OutputMode::Normal, @@ -62,3 +70,12 @@ impl GlobalOpts { Shell::new_with(format, mode, color, self.verbosity) } } + +/// Initialize the global thread pool. +pub fn init_thread_pool(threads: usize) -> eyre::Result<()> { + rayon::ThreadPoolBuilder::new() + .thread_name(|i| format!("foundry-{i}")) + .num_threads(threads) + .build_global()?; + Ok(()) +} diff --git a/crates/config/README.md b/crates/config/README.md index 139c2a9f5601a..9fcd30ac99dc8 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -115,7 +115,7 @@ no_match_contract = "Bar" match_path = "*/Foo*" no_match_path = "*/Bar*" no_match_coverage = "Baz" -# Number of threads to use. Not set or zero specifies the number of logical cores. +# Number of threads to use. Specifying 0 defaults to the number of logical cores. threads = 0 # whether to show test execution progress show_progress = true diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 435c34275850f..59434d5eb42bf 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -65,7 +65,7 @@ foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); #[derive(Clone, Debug, Parser)] #[command(next_help_heading = "Test options")] pub struct TestArgs { - /// Include the global options. + // Include global options for users of this struct. #[command(flatten)] pub global: GlobalOpts, @@ -149,11 +149,6 @@ pub struct TestArgs { #[arg(long)] pub fuzz_input_file: Option, - /// Max concurrent threads to use. - /// Default value is the number of available CPUs. - #[arg(long, short = 'j', visible_alias = "jobs")] - pub threads: Option, - /// Show test execution progress. #[arg(long)] pub show_progress: bool, @@ -276,13 +271,6 @@ impl TestArgs { // Merge all configs. let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; - // Set number of max threads to execute tests. - // If not specified then the number of threads determined by rayon will be used. - if let Some(test_threads) = config.threads { - trace!(target: "forge::test", "execute tests with {} max threads", test_threads); - rayon::ThreadPoolBuilder::new().num_threads(test_threads).build_global()?; - } - // Explicitly enable isolation for gas reports for more correct gas accounting. if self.gas_report { evm_opts.isolate = true; @@ -898,10 +886,6 @@ impl Provider for TestArgs { dict.insert("show_progress".to_string(), true.into()); } - if let Some(threads) = self.threads { - dict.insert("threads".to_string(), threads.into()); - } - Ok(Map::from([(Config::selected_profile(), dict)])) } } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 3cd4ae5edb041..e0000e01bee02 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -33,6 +33,11 @@ Options: -h, --help Print help (see a summary with '-h') + -j, --threads + Number of threads to use. Specifying 0 defaults to the number of logical cores + + [aliases: jobs] + -V, --version Print version diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 0f0283b9f01ae..aeea4940a0bed 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -78,7 +78,7 @@ foundry_config::merge_impl_figment_convert!(ScriptArgs, opts, evm_opts); /// CLI arguments for `forge script`. #[derive(Clone, Debug, Default, Parser)] pub struct ScriptArgs { - /// Include the global options. + // Include global options for users of this struct. #[command(flatten)] pub global: GlobalOpts, From 41b4359973235c37227a1d485cdb71dc56959b8b Mon Sep 17 00:00:00 2001 From: m4rio <92288535+mario-eth@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:55:37 +0200 Subject: [PATCH 1707/1963] feat: Update to soldeer 0.5.2 (#9373) --- Cargo.lock | 20 +++++++++++--------- Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a7cb9a73c5d8..e6f33e224c89e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1779,9 +1779,9 @@ dependencies = [ [[package]] name = "bon" -version = "2.3.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97493a391b4b18ee918675fb8663e53646fd09321c58b46afa04e8ce2499c869" +checksum = "a636f83af97c6946f3f5cf5c268ec02375bf5efd371110292dfd57961f57a509" dependencies = [ "bon-macros", "rustversion", @@ -1789,14 +1789,16 @@ dependencies = [ [[package]] name = "bon-macros" -version = "2.3.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2af3eac944c12cdf4423eab70d310da0a8e5851a18ffb192c0a5e3f7ae1663" +checksum = "a7eaf1bfaa5b8d512abfd36d0c432591fef139d3de9ee54f1f839ea109d70d33" dependencies = [ "darling", "ident_case", + "prettyplease", "proc-macro2", "quote", + "rustversion", "syn 2.0.87", ] @@ -8510,9 +8512,9 @@ dependencies = [ [[package]] name = "soldeer-commands" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5969c09f89ae6f0e18d5904e5bdbb8842ba948dad0f8202edb7ea510e35654d" +checksum = "a4bd924da31914871820d1404b63a89b100097957f6dc7f3bbb9c094f16d8f4e" dependencies = [ "bon", "clap", @@ -8525,9 +8527,9 @@ dependencies = [ [[package]] name = "soldeer-core" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63aeee0e78b5fba04f005d23a58d20f897720212bd21ad744201cacb9dd34f8" +checksum = "c7a3129568ab6b38132efa9c956b5ae14c09c0a1a1167353e337081d1d7f0c32" dependencies = [ "bon", "chrono", @@ -8546,7 +8548,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", "toml_edit", "uuid 1.11.0", diff --git a/Cargo.toml b/Cargo.toml index f5ec94b906bc7..03ff020fa732d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -278,7 +278,7 @@ semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } similar-asserts = "1.6" -soldeer-commands = "=0.5.1" +soldeer-commands = "=0.5.2" strum = "0.26" tempfile = "3.13" tikv-jemallocator = "0.6" From 2bc7125e913b211b2d6c59ecdc5f1f427440652b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 22 Nov 2024 05:39:03 +0400 Subject: [PATCH 1708/1963] fix: `vm.broadcastRawTransaction` (#9378) fix: vm.broadcastRawTransaction --- crates/common/src/transactions.rs | 4 ++++ crates/forge/tests/cli/script.rs | 13 +++++++++---- crates/script/src/broadcast.rs | 7 ++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index b319da0d877b4..a05a46eaed236 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -179,6 +179,10 @@ impl TransactionMaybeSigned { Ok(Self::Signed { tx, from }) } + pub fn is_unsigned(&self) -> bool { + matches!(self, Self::Unsigned(_)) + } + pub fn as_unsigned_mut(&mut self) -> Option<&mut WithOtherFields> { match self { Self::Unsigned(tx) => Some(tx), diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 82c61ccbc3887..38e702a1b22fb 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1,7 +1,7 @@ //! Contains various tests related to `forge script`. use crate::constants::TEMPLATE_CONTRACT; -use alloy_primitives::{hex, Address, Bytes}; +use alloy_primitives::{address, hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; use forge_script_sequence::ScriptSequence; use foundry_test_utils::{ @@ -2039,8 +2039,7 @@ forgetest_async!(can_deploy_library_create2_different_sender, |prj, cmd| { // forgetest_async!(test_broadcast_raw_create2_deployer, |prj, cmd| { - let (_api, handle) = - spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await; + let (api, handle) = spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await; foundry_test_utils::util::initialize(prj.root()); prj.add_script( @@ -2051,7 +2050,7 @@ import "forge-std/Script.sol"; contract SimpleScript is Script { function run() external { // send funds to create2 factory deployer - vm.broadcast(); + vm.startBroadcast(); payable(0x3fAB184622Dc19b6109349B94811493BF2a45362).transfer(10000000 gwei); // deploy create2 factory vm.broadcastRawTransaction( @@ -2104,6 +2103,12 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. "#]]); + + assert!(!api + .get_code(address!("4e59b44847b379578588920cA78FbF26c0B4956C"), Default::default()) + .await + .unwrap() + .is_empty()); }); forgetest_init!(can_get_script_wallets, |prj, cmd| { diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 4058aa6c59b3f..51e8baf5b3be8 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -213,7 +213,12 @@ impl BundledState { .sequence .sequences() .iter() - .flat_map(|sequence| sequence.transactions().map(|tx| tx.from().expect("missing from"))) + .flat_map(|sequence| { + sequence + .transactions() + .filter(|tx| tx.is_unsigned()) + .map(|tx| tx.from().expect("missing from")) + }) .collect::(); if required_addresses.contains(&Config::DEFAULT_SENDER) { From 76a2cb0dd6d60684fd64a8180500f9d619ec94d2 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 22 Nov 2024 10:53:21 +0400 Subject: [PATCH 1709/1963] fix(forge test): install missing dependencies before creating `Project` (#9379) * fix(forge test): install missing dependencies before instantiating the project * optimization --- crates/config/src/lib.rs | 3 +++ crates/forge/bin/cmd/test/mod.rs | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 6444802e3bc9b..5a159c3925b8a 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -904,6 +904,9 @@ impl Config { ) -> Result>, SolcError> { let mut map = BTreeMap::new(); + if self.compilation_restrictions.is_empty() { + return Ok(BTreeMap::new()); + } let graph = Graph::::resolve(paths)?; let (sources, _) = graph.into_sources(); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 59434d5eb42bf..1a409b33a822f 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -280,16 +280,15 @@ impl TestArgs { config.invariant.gas_report_samples = 0; } - // Set up the project. - let mut project = config.project()?; - // Install missing dependencies. if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings config = self.load_config(); - project = config.project()?; } + // Set up the project. + let project = config.project()?; + let mut filter = self.filter(&config); trace!(target: "forge::test", ?filter, "using filter"); From 1332b6d6c09264fe4cc3653f9d117ac9fb6c48c7 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:37:30 +0100 Subject: [PATCH 1710/1963] chore(chisel): replace solang with solar in SolidityHelper (#9376) --- Cargo.lock | 1 + Cargo.toml | 1 + crates/chisel/Cargo.toml | 1 + crates/chisel/src/dispatcher.rs | 14 +- crates/chisel/src/executor.rs | 2 +- crates/chisel/src/solidity_helper.rs | 252 +++++++++++---------------- 6 files changed, 117 insertions(+), 154 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6f33e224c89e..9179edf77172c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2067,6 +2067,7 @@ dependencies = [ "serde_json", "serial_test", "solang-parser", + "solar-parse", "strum", "tikv-jemallocator", "time", diff --git a/Cargo.toml b/Cargo.toml index 03ff020fa732d..8dc0ecd5f6a07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,6 +172,7 @@ foundry-block-explorers = { version = "0.9.0", default-features = false } foundry-compilers = { version = "0.12.3", default-features = false } foundry-fork-db = "0.7.0" solang-parser = "=0.3.3" +solar-parse = { version = "=0.1.0", default-features = false } ## revm revm = { version = "18.0.0", default-features = false } diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 65b3c974836b3..5f098817c39d9 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -58,6 +58,7 @@ semver.workspace = true serde_json.workspace = true serde.workspace = true solang-parser.workspace = true +solar-parse.workspace = true strum = { workspace = true, features = ["derive"] } time = { version = "0.3", features = ["formatting"] } tokio = { workspace = true, features = ["full"] } diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index d69de3bf540e5..2a6a2fc3f567a 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -38,14 +38,16 @@ use strum::IntoEnumIterator; use tracing::debug; use yansi::Paint; -/// Prompt arrow character -pub static PROMPT_ARROW: char = '➜'; -static DEFAULT_PROMPT: &str = "➜ "; +/// Prompt arrow character. +pub const PROMPT_ARROW: char = '➜'; +/// Prompt arrow string. +pub const PROMPT_ARROW_STR: &str = "➜"; +const DEFAULT_PROMPT: &str = "➜ "; /// Command leader character -pub static COMMAND_LEADER: char = '!'; +pub const COMMAND_LEADER: char = '!'; /// Chisel character -pub static CHISEL_CHAR: &str = "⚒️"; +pub const CHISEL_CHAR: &str = "⚒️"; /// Matches Solidity comments static COMMENT_RE: LazyLock = @@ -320,7 +322,7 @@ impl ChiselDispatcher { }, ChiselCommand::Source => match self.format_source() { Ok(formatted_source) => DispatchResult::CommandSuccess(Some( - SolidityHelper::highlight(&formatted_source).into_owned(), + SolidityHelper::new().highlight(&formatted_source).into_owned(), )), Err(_) => { DispatchResult::CommandFailed(String::from("Failed to format session source")) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index b7f3973b09d51..fc24e0b891b44 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -504,7 +504,7 @@ fn format_event_definition(event_definition: &pt::EventDefinition) -> Result Self { + Self::new() + } } impl SolidityHelper { /// Create a new SolidityHelper. pub fn new() -> Self { - Self::default() + Self { + errored: false, + do_paint: yansi::is_enabled(), + sess: Session::builder().with_silent_emitter(None).build(), + globals: SessionGlobals::new(), + } + } + + /// Returns whether the helper is in an errored state. + pub fn errored(&self) -> bool { + self.errored } /// Set the errored field. @@ -55,54 +68,9 @@ impl SolidityHelper { self } - /// Get styles for a solidity source string - pub fn get_styles(input: &str) -> Vec { - let mut comments = Vec::with_capacity(DEFAULT_COMMENTS); - let mut errors = Vec::with_capacity(5); - let mut out = Lexer::new(input, 0, &mut comments, &mut errors) - .map(|(start, token, end)| (start, token.style(), end)) - .collect::>(); - - // highlight comments too - let comments_iter = comments.into_iter().map(|comment| { - let loc = match comment { - pt::Comment::Line(loc, _) | - pt::Comment::Block(loc, _) | - pt::Comment::DocLine(loc, _) | - pt::Comment::DocBlock(loc, _) => loc, - }; - (loc.start(), Style::new().dim(), loc.end()) - }); - out.extend(comments_iter); - - out - } - - /// Get contiguous styles for a solidity source string - pub fn get_contiguous_styles(input: &str) -> Vec { - let mut styles = Self::get_styles(input); - styles.sort_unstable_by_key(|(start, _, _)| *start); - - let len = input.len(); - // len / 4 is just a random average of whitespaces in the input - let mut out = Vec::with_capacity(styles.len() + len / 4 + 1); - let mut index = 0; - for (start, style, end) in styles { - if index < start { - out.push((index, Style::default(), start)); - } - out.push((start, style, end)); - index = end; - } - if index < len { - out.push((index, Style::default(), len)); - } - out - } - - /// Highlights a solidity source string - pub fn highlight(input: &str) -> Cow<'_, str> { - if !yansi::is_enabled() { + /// Highlights a Solidity source string. + pub fn highlight<'a>(&self, input: &'a str) -> Cow<'a, str> { + if !self.do_paint() { return Cow::Borrowed(input) } @@ -133,52 +101,53 @@ impl SolidityHelper { Cow::Owned(out) } else { - let styles = Self::get_contiguous_styles(input); - let len = styles.len(); - if len == 0 { - Cow::Borrowed(input) - } else { - let mut out = String::with_capacity(input.len() + MAX_ANSI_LEN * len); - for (start, style, end) in styles { - Self::paint_unchecked(&input[start..end], style, &mut out); + let mut out = String::with_capacity(input.len() * 2); + self.with_contiguous_styles(input, |style, range| { + Self::paint_unchecked(&input[range], style, &mut out); + }); + Cow::Owned(out) + } + } + + /// Returns a list of styles and the ranges they should be applied to. + /// + /// Covers the entire source string, including any whitespace. + fn with_contiguous_styles(&self, input: &str, mut f: impl FnMut(Style, Range)) { + self.enter(|sess| { + let len = input.len(); + let mut index = 0; + for token in Lexer::new(sess, input) { + let range = token.span.lo().to_usize()..token.span.hi().to_usize(); + let style = token_style(&token); + if index < range.start { + f(Style::default(), index..range.start); } - Cow::Owned(out) + index = range.end; + f(style, range); } - } + if index < len { + f(Style::default(), index..len); + } + }); } /// Validate that a source snippet is closed (i.e., all braces and parenthesis are matched). - fn validate_closed(input: &str) -> ValidationResult { - let mut bracket_depth = 0usize; - let mut paren_depth = 0usize; - let mut brace_depth = 0usize; - let mut comments = Vec::with_capacity(DEFAULT_COMMENTS); - // returns on any encountered error, so allocate for just one - let mut errors = Vec::with_capacity(1); - for (_, token, _) in Lexer::new(input, 0, &mut comments, &mut errors) { - match token { - Token::OpenBracket => { - bracket_depth += 1; - } - Token::OpenCurlyBrace => { - brace_depth += 1; + fn validate_closed(&self, input: &str) -> ValidationResult { + let mut depth = [0usize; 3]; + self.enter(|sess| { + for token in Lexer::new(sess, input) { + match token.kind { + TokenKind::OpenDelim(delim) => { + depth[delim as usize] += 1; + } + TokenKind::CloseDelim(delim) => { + depth[delim as usize] = depth[delim as usize].saturating_sub(1); + } + _ => {} } - Token::OpenParenthesis => { - paren_depth += 1; - } - Token::CloseBracket => { - bracket_depth = bracket_depth.saturating_sub(1); - } - Token::CloseCurlyBrace => { - brace_depth = brace_depth.saturating_sub(1); - } - Token::CloseParenthesis => { - paren_depth = paren_depth.saturating_sub(1); - } - _ => {} } - } - if (bracket_depth | brace_depth | paren_depth) == 0 { + }); + if depth == [0; 3] { ValidationResult::Valid(None) } else { ValidationResult::Incomplete @@ -186,8 +155,7 @@ impl SolidityHelper { } /// Formats `input` with `style` into `out`, without checking `style.wrapping` or - /// `yansi::is_enabled` - #[inline] + /// `self.do_paint`. fn paint_unchecked(string: &str, style: Style, out: &mut String) { if style == Style::default() { out.push_str(string); @@ -198,17 +166,26 @@ impl SolidityHelper { } } - #[inline] fn paint_unchecked_owned(string: &str, style: Style) -> String { let mut out = String::with_capacity(MAX_ANSI_LEN + string.len()); Self::paint_unchecked(string, style, &mut out); out } + + /// Returns whether to color the output. + fn do_paint(&self) -> bool { + self.do_paint + } + + /// Enters the session. + fn enter(&self, f: impl FnOnce(&Session)) { + self.globals.set(|| self.sess.enter(|| f(&self.sess))); + } } impl Highlighter for SolidityHelper { fn highlight<'l>(&self, line: &'l str, _pos: usize) -> Cow<'l, str> { - Self::highlight(line) + self.highlight(line) } fn highlight_char(&self, line: &str, pos: usize, _forced: bool) -> bool { @@ -220,7 +197,7 @@ impl Highlighter for SolidityHelper { prompt: &'p str, _default: bool, ) -> Cow<'b, str> { - if !yansi::is_enabled() { + if !self.do_paint() { return Cow::Borrowed(prompt) } @@ -241,14 +218,7 @@ impl Highlighter for SolidityHelper { if let Some(i) = out.find(PROMPT_ARROW) { let style = if self.errored { Color::Red.foreground() } else { Color::Green.foreground() }; - - let mut arrow = String::with_capacity(MAX_ANSI_LEN + 4); - - let _ = style.fmt_prefix(&mut arrow); - arrow.push(PROMPT_ARROW); - let _ = style.fmt_suffix(&mut arrow); - - out.replace_range(i..=i + 2, &arrow); + out.replace_range(i..=i + 2, &Self::paint_unchecked_owned(PROMPT_ARROW_STR, style)); } Cow::Owned(out) @@ -257,7 +227,7 @@ impl Highlighter for SolidityHelper { impl Validator for SolidityHelper { fn validate(&self, ctx: &mut ValidationContext<'_>) -> rustyline::Result { - Ok(Self::validate_closed(ctx.input())) + Ok(self.validate_closed(ctx.input())) } } @@ -271,44 +241,32 @@ impl Hinter for SolidityHelper { impl Helper for SolidityHelper {} -/// Trait that assigns a color to a Token kind -pub trait TokenStyle { - /// Returns the style with which the token should be decorated with. - fn style(&self) -> Style; -} +#[allow(non_upper_case_globals)] +#[deny(unreachable_patterns)] +fn token_style(token: &Token) -> Style { + use solar_parse::{ + interface::kw::*, + token::{TokenKind::*, TokenLitKind::*}, + }; -/// [TokenStyle] implementation for [Token] -impl TokenStyle for Token<'_> { - fn style(&self) -> Style { - use Token::*; - match self { - StringLiteral(_, _) => Color::Green.foreground(), - - AddressLiteral(_) | - HexLiteral(_) | - Number(_, _) | - RationalNumber(_, _, _) | - HexNumber(_) | - True | - False => Color::Yellow.foreground(), + match token.kind { + Literal(Str | HexStr | UnicodeStr, _) => Color::Green.foreground(), + Literal(..) => Color::Yellow.foreground(), + Ident( Memory | Storage | Calldata | Public | Private | Internal | External | Constant | Pure | View | Payable | Anonymous | Indexed | Abstract | Virtual | Override | - Modifier | Immutable | Unchecked => Color::Cyan.foreground(), + Modifier | Immutable | Unchecked, + ) => Color::Cyan.foreground(), - Contract | Library | Interface | Function | Pragma | Import | Struct | Event | - Enum | Type | Constructor | As | Is | Using | New | Delete | Do | Continue | - Break | Throw | Emit | Return | Returns | Revert | For | While | If | Else | Try | - Catch | Assembly | Let | Leave | Switch | Case | Default | YulArrow | Arrow => { - Color::Magenta.foreground() - } + Ident(s) if s.is_elementary_type() => Color::Blue.foreground(), + Ident(Mapping) => Color::Blue.foreground(), - Uint(_) | Int(_) | Bytes(_) | Byte | DynamicBytes | Bool | Address | String | - Mapping => Color::Blue.foreground(), + Ident(s) if s.is_used_keyword() || s.is_yul_keyword() => Color::Magenta.foreground(), + Arrow | FatArrow => Color::Magenta.foreground(), - Identifier(_) => Style::default(), + Comment(..) => Color::Primary.dim(), - _ => Style::default(), - } + _ => Color::Primary.foreground(), } } From cf66dea727a6c7f41fa48fbe6dcabe474bfbfd79 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:37:40 +0200 Subject: [PATCH 1711/1963] fix(chisel): uint/int full word print (#9381) --- crates/chisel/src/executor.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index fc24e0b891b44..09c00f6ad5b3d 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -7,7 +7,7 @@ use crate::prelude::{ }; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_json_abi::EventParam; -use alloy_primitives::{hex, Address, U256}; +use alloy_primitives::{hex, Address, B256, U256}; use core::fmt::Debug; use eyre::{Result, WrapErr}; use foundry_compilers::Artifact; @@ -379,7 +379,7 @@ fn format_token(token: DynSolValue) -> String { .collect::() ) .cyan(), - format!("{i:#x}").cyan(), + hex::encode_prefixed(B256::from(i)).cyan(), i.cyan() ) } @@ -397,7 +397,7 @@ fn format_token(token: DynSolValue) -> String { .collect::() ) .cyan(), - format!("{i:#x}").cyan(), + hex::encode_prefixed(B256::from(i)).cyan(), i.cyan() ) } From 37cc284f939a55bc1886e4bb7ba6ca99930fb4ee Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:14:50 +0530 Subject: [PATCH 1712/1963] fix: flaky test_broadcast_raw_create2_deployer (#9383) --- crates/forge/tests/cli/script.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 38e702a1b22fb..df2a59bdc4dfb 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2069,6 +2069,7 @@ contract SimpleScript is Script { "--rpc-url", &handle.http_endpoint(), "--broadcast", + "--slow", "SimpleScript", ]); From 8b7d5dfc401aab29a69ff844cfd59c1255d5d106 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 22 Nov 2024 13:37:31 +0100 Subject: [PATCH 1713/1963] refactor(forge): rewrite `geiger` with Solar (#9382) --- Cargo.lock | 2 + Cargo.toml | 1 + crates/forge/Cargo.toml | 2 + crates/forge/bin/cmd/geiger.rs | 159 ++++++++++++ crates/forge/bin/cmd/geiger/error.rs | 11 - crates/forge/bin/cmd/geiger/find.rs | 165 ------------ crates/forge/bin/cmd/geiger/mod.rs | 122 --------- crates/forge/bin/cmd/geiger/visitor.rs | 333 ------------------------- crates/forge/bin/main.rs | 3 +- crates/forge/tests/cli/debug.rs | 2 +- crates/forge/tests/cli/geiger.rs | 92 +++++++ crates/forge/tests/cli/main.rs | 1 + crates/test-utils/src/util.rs | 8 +- 13 files changed, 266 insertions(+), 635 deletions(-) create mode 100644 crates/forge/bin/cmd/geiger.rs delete mode 100644 crates/forge/bin/cmd/geiger/error.rs delete mode 100644 crates/forge/bin/cmd/geiger/find.rs delete mode 100644 crates/forge/bin/cmd/geiger/mod.rs delete mode 100644 crates/forge/bin/cmd/geiger/visitor.rs create mode 100644 crates/forge/tests/cli/geiger.rs diff --git a/Cargo.lock b/Cargo.lock index 9179edf77172c..15a2386be8b92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3408,6 +3408,8 @@ dependencies = [ "similar", "similar-asserts", "solang-parser", + "solar-ast", + "solar-parse", "soldeer-commands", "strum", "svm-rs", diff --git a/Cargo.toml b/Cargo.toml index 8dc0ecd5f6a07..814c43aa556ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,6 +172,7 @@ foundry-block-explorers = { version = "0.9.0", default-features = false } foundry-compilers = { version = "0.12.3", default-features = false } foundry-fork-db = "0.7.0" solang-parser = "=0.3.3" +solar-ast = { version = "=0.1.0", default-features = false } solar-parse = { version = "=0.1.0", default-features = false } ## revm diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index b32a9bd412237..208ea8430ab96 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -89,6 +89,8 @@ semver.workspace = true serde_json.workspace = true similar = { version = "2", features = ["inline"] } solang-parser.workspace = true +solar-ast.workspace = true +solar-parse.workspace = true strum = { workspace = true, features = ["derive"] } thiserror.workspace = true tokio = { workspace = true, features = ["time"] } diff --git a/crates/forge/bin/cmd/geiger.rs b/crates/forge/bin/cmd/geiger.rs new file mode 100644 index 0000000000000..9ffddd3c98816 --- /dev/null +++ b/crates/forge/bin/cmd/geiger.rs @@ -0,0 +1,159 @@ +use clap::{Parser, ValueHint}; +use eyre::{Result, WrapErr}; +use foundry_cli::utils::LoadConfig; +use foundry_compilers::{resolver::parse::SolData, Graph}; +use foundry_config::{impl_figment_convert_basic, Config}; +use itertools::Itertools; +use solar_ast::visit::Visit; +use solar_parse::{ast, interface::Session}; +use std::path::{Path, PathBuf}; + +/// CLI arguments for `forge geiger`. +#[derive(Clone, Debug, Parser)] +pub struct GeigerArgs { + /// Paths to files or directories to detect. + #[arg( + conflicts_with = "root", + value_hint = ValueHint::FilePath, + value_name = "PATH", + num_args(1..), + )] + paths: Vec, + + /// The project's root path. + /// + /// By default root of the Git repository, if in one, + /// or the current working directory. + #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] + root: Option, + + /// Globs to ignore. + #[arg( + long, + value_hint = ValueHint::FilePath, + value_name = "PATH", + num_args(1..), + )] + ignore: Vec, + + #[arg(long, hide = true)] + check: bool, + #[arg(long, hide = true)] + full: bool, +} + +impl_figment_convert_basic!(GeigerArgs); + +impl GeigerArgs { + pub fn sources(&self, config: &Config) -> Result> { + let cwd = std::env::current_dir()?; + + let mut sources: Vec = { + if self.paths.is_empty() { + let paths = config.project_paths(); + Graph::::resolve(&paths)? + .files() + .keys() + .filter(|f| !paths.libraries.iter().any(|lib| f.starts_with(lib))) + .cloned() + .collect() + } else { + self.paths + .iter() + .flat_map(|path| foundry_common::fs::files_with_ext(path, "sol")) + .unique() + .collect() + } + }; + + sources.retain_mut(|path| { + let abs_path = if path.is_absolute() { path.clone() } else { cwd.join(&path) }; + *path = abs_path.strip_prefix(&cwd).unwrap_or(&abs_path).to_path_buf(); + !self.ignore.iter().any(|ignore| { + if ignore.is_absolute() { + abs_path.starts_with(ignore) + } else { + abs_path.starts_with(cwd.join(ignore)) + } + }) + }); + + Ok(sources) + } + + pub fn run(self) -> Result { + if self.check { + sh_warn!("`--check` is deprecated as it's now the default behavior\n")?; + } + if self.full { + sh_warn!("`--full` is deprecated as reports are not generated anymore\n")?; + } + + let config = self.try_load_config_emit_warnings()?; + let sources = self.sources(&config).wrap_err("Failed to resolve files")?; + + if config.ffi { + sh_warn!("FFI enabled\n")?; + } + + let mut sess = Session::builder().with_stderr_emitter().build(); + sess.dcx = sess.dcx.set_flags(|flags| flags.track_diagnostics = false); + let unsafe_cheatcodes = &[ + "ffi".to_string(), + "readFile".to_string(), + "readLine".to_string(), + "writeFile".to_string(), + "writeLine".to_string(), + "removeFile".to_string(), + "closeFile".to_string(), + "setEnv".to_string(), + "deriveKey".to_string(), + ]; + Ok(sess + .enter(|| sources.iter().map(|file| lint_file(&sess, unsafe_cheatcodes, file)).sum())) + } +} + +fn lint_file(sess: &Session, unsafe_cheatcodes: &[String], path: &Path) -> usize { + try_lint_file(sess, unsafe_cheatcodes, path).unwrap_or(0) +} + +fn try_lint_file( + sess: &Session, + unsafe_cheatcodes: &[String], + path: &Path, +) -> solar_parse::interface::Result { + let arena = solar_parse::ast::Arena::new(); + let mut parser = solar_parse::Parser::from_file(sess, &arena, path)?; + let ast = parser.parse_file().map_err(|e| e.emit())?; + let mut visitor = Visitor::new(sess, unsafe_cheatcodes); + visitor.visit_source_unit(&ast); + Ok(visitor.count) +} + +struct Visitor<'a> { + sess: &'a Session, + count: usize, + unsafe_cheatcodes: &'a [String], +} + +impl<'a> Visitor<'a> { + fn new(sess: &'a Session, unsafe_cheatcodes: &'a [String]) -> Self { + Self { sess, count: 0, unsafe_cheatcodes } + } +} + +impl<'ast> Visit<'ast> for Visitor<'_> { + fn visit_expr(&mut self, expr: &'ast ast::Expr<'ast>) { + if let ast::ExprKind::Call(lhs, _args) = &expr.kind { + if let ast::ExprKind::Member(_lhs, member) = &lhs.kind { + if self.unsafe_cheatcodes.iter().any(|c| c.as_str() == member.as_str()) { + let msg = format!("usage of unsafe cheatcode `vm.{member}`"); + self.sess.dcx.err(msg).span(member.span).emit(); + self.count += 1; + } + } + } + self.walk_expr(expr); + } +} diff --git a/crates/forge/bin/cmd/geiger/error.rs b/crates/forge/bin/cmd/geiger/error.rs deleted file mode 100644 index 010fb237ca070..0000000000000 --- a/crates/forge/bin/cmd/geiger/error.rs +++ /dev/null @@ -1,11 +0,0 @@ -use forge_fmt::FormatterError; -use foundry_common::errors::FsPathError; - -/// Possible errors when scanning a solidity file -#[derive(Debug, thiserror::Error)] -pub enum ScanFileError { - #[error(transparent)] - Io(#[from] FsPathError), - #[error(transparent)] - ParseSol(#[from] FormatterError), -} diff --git a/crates/forge/bin/cmd/geiger/find.rs b/crates/forge/bin/cmd/geiger/find.rs deleted file mode 100644 index e3cd6541334a5..0000000000000 --- a/crates/forge/bin/cmd/geiger/find.rs +++ /dev/null @@ -1,165 +0,0 @@ -use super::{error::ScanFileError, visitor::CheatcodeVisitor}; -use eyre::Result; -use forge_fmt::{offset_to_line_column, parse2, FormatterError, Visitable}; -use foundry_common::fs; -use solang_parser::pt::Loc; -use std::{ - fmt, - path::{Path, PathBuf}, -}; -use yansi::Paint; - -/// Scan a single file for `unsafe` cheatcode usage. -pub fn find_cheatcodes_in_file(path: &Path) -> Result { - let contents = fs::read_to_string(path)?; - let cheatcodes = find_cheatcodes_in_string(&contents, Some(path))?; - Ok(SolFileMetrics { contents, cheatcodes, file: path.to_path_buf() }) -} - -/// Scan a string for unsafe cheatcodes. -pub fn find_cheatcodes_in_string( - src: &str, - path: Option<&Path>, -) -> Result { - let mut parsed = parse2(src, path)?; - let mut visitor = CheatcodeVisitor::default(); - parsed.pt.visit(&mut visitor).unwrap(); - Ok(visitor.cheatcodes) -} - -/// Scan result for a single Solidity file. -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct SolFileMetrics { - /// The Solidity file - pub file: PathBuf, - - /// The file's contents. - pub contents: String, - - /// The unsafe cheatcodes found. - pub cheatcodes: UnsafeCheatcodes, -} - -/// Formats the metrics for a single file using [`fmt::Display`]. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct SolFileMetricsPrinter<'a, 'b> { - pub metrics: &'a SolFileMetrics, - pub root: &'b Path, -} - -impl fmt::Display for SolFileMetricsPrinter<'_, '_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let SolFileMetricsPrinter { metrics, root } = *self; - - let file = metrics.file.strip_prefix(root).unwrap_or(&metrics.file); - - macro_rules! print_unsafe_fn { - ($($name:literal => $field:ident),*) => {$( - let $field = &metrics.cheatcodes.$field[..]; - if !$field.is_empty() { - writeln!(f, " {} {}", metrics.cheatcodes.$field.len().red(), $name.red())?; - - for &loc in $field { - let content = &metrics.contents[loc.range()]; - let (line, col) = offset_to_line_column(&metrics.contents, loc.start()); - let pos = format!(" --> {}:{}:{}", file.display(), line, col); - writeln!(f,"{}", pos.red())?; - for line in content.lines() { - writeln!(f, " {}", line.red())?; - } - } - } - )*}; - } - - if !metrics.cheatcodes.is_empty() { - writeln!(f, "{} {}", metrics.cheatcodes.len().red(), file.display().red())?; - print_unsafe_fn!( - "ffi" => ffi, - "readFile" => read_file, - "readLine" => read_line, - "writeFile" => write_file, - "writeLine" => write_line, - "removeFile" => remove_file, - "closeFile" => close_file, - "setEnv" => set_env, - "deriveKey" => derive_key - ); - } else { - writeln!(f, "0 {}", file.display())? - } - - Ok(()) - } -} - -/// Unsafe usage metrics collection. -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct UnsafeCheatcodes { - pub ffi: Vec, - pub read_file: Vec, - pub read_line: Vec, - pub write_file: Vec, - pub write_line: Vec, - pub remove_file: Vec, - pub close_file: Vec, - pub set_env: Vec, - pub derive_key: Vec, -} - -impl UnsafeCheatcodes { - /// Whether there are any unsafe calls. - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - - /// The total number of unsafe calls. - pub fn len(&self) -> usize { - self.ffi.len() + - self.read_file.len() + - self.read_line.len() + - self.write_file.len() + - self.write_line.len() + - self.close_file.len() + - self.set_env.len() + - self.derive_key.len() + - self.remove_file.len() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_find_calls() { - let s = r" - contract A is Test { - function do_ffi() public { - string[] memory inputs = new string[](1); - vm.ffi(inputs); - } - } - "; - - let count = find_cheatcodes_in_string(s, None).unwrap(); - assert_eq!(count.ffi.len(), 1); - assert!(!count.is_empty()); - } - - #[test] - fn can_find_call_in_assignment() { - let s = r" - contract A is Test { - function do_ffi() public { - string[] memory inputs = new string[](1); - bytes stuff = vm.ffi(inputs); - } - } - "; - - let count = find_cheatcodes_in_string(s, None).unwrap(); - assert_eq!(count.ffi.len(), 1); - assert!(!count.is_empty()); - } -} diff --git a/crates/forge/bin/cmd/geiger/mod.rs b/crates/forge/bin/cmd/geiger/mod.rs deleted file mode 100644 index 4167b7882f910..0000000000000 --- a/crates/forge/bin/cmd/geiger/mod.rs +++ /dev/null @@ -1,122 +0,0 @@ -use clap::{Parser, ValueHint}; -use eyre::{Result, WrapErr}; -use foundry_cli::utils::LoadConfig; -use foundry_compilers::{resolver::parse::SolData, Graph}; -use foundry_config::{impl_figment_convert_basic, Config}; -use itertools::Itertools; -use rayon::prelude::*; -use std::path::PathBuf; - -mod error; - -mod find; -use find::{find_cheatcodes_in_file, SolFileMetricsPrinter}; - -mod visitor; - -/// CLI arguments for `forge geiger`. -#[derive(Clone, Debug, Parser)] -pub struct GeigerArgs { - /// Paths to files or directories to detect. - #[arg( - conflicts_with = "root", - value_hint = ValueHint::FilePath, - value_name = "PATH", - num_args(1..), - )] - paths: Vec, - - /// The project's root path. - /// - /// By default root of the Git repository, if in one, - /// or the current working directory. - #[arg(long, value_hint = ValueHint::DirPath, value_name = "PATH")] - root: Option, - - /// Run in "check" mode. - /// - /// The exit code of the program will be the number of unsafe cheatcodes found. - #[arg(long)] - pub check: bool, - - /// Globs to ignore. - #[arg( - long, - value_hint = ValueHint::FilePath, - value_name = "PATH", - num_args(1..), - )] - ignore: Vec, - - /// Print a report of all files, even if no unsafe functions are found. - #[arg(long)] - full: bool, -} - -impl_figment_convert_basic!(GeigerArgs); - -impl GeigerArgs { - pub fn sources(&self, config: &Config) -> Result> { - let cwd = std::env::current_dir()?; - - let mut sources: Vec = { - if self.paths.is_empty() { - Graph::::resolve(&config.project_paths())? - .files() - .keys() - .cloned() - .collect() - } else { - self.paths - .iter() - .flat_map(|path| foundry_common::fs::files_with_ext(path, "sol")) - .unique() - .collect() - } - }; - - sources.retain(|path| { - let abs_path = if path.is_absolute() { path.clone() } else { cwd.join(path) }; - !self.ignore.iter().any(|ignore| { - if ignore.is_absolute() { - abs_path.starts_with(ignore) - } else { - abs_path.starts_with(cwd.join(ignore)) - } - }) - }); - - Ok(sources) - } - - pub fn run(self) -> Result { - let config = self.try_load_config_emit_warnings()?; - let sources = self.sources(&config).wrap_err("Failed to resolve files")?; - - if config.ffi { - sh_warn!("FFI enabled\n")?; - } - - let root = config.root.0; - - let sum = sources - .par_iter() - .map(|file| match find_cheatcodes_in_file(file) { - Ok(metrics) => { - let len = metrics.cheatcodes.len(); - let printer = SolFileMetricsPrinter { metrics: &metrics, root: &root }; - if self.full || len == 0 { - let _ = sh_eprint!("{printer}"); - } - len - } - Err(err) => { - let _ = sh_err!("{err}"); - 0 - } - }) - .sum(); - - Ok(sum) - } -} diff --git a/crates/forge/bin/cmd/geiger/visitor.rs b/crates/forge/bin/cmd/geiger/visitor.rs deleted file mode 100644 index 70313089019ca..0000000000000 --- a/crates/forge/bin/cmd/geiger/visitor.rs +++ /dev/null @@ -1,333 +0,0 @@ -use super::find::UnsafeCheatcodes; -use eyre::Result; -use forge_fmt::{Visitable, Visitor}; -use solang_parser::pt::{ - ContractDefinition, Expression, FunctionDefinition, IdentifierPath, Loc, Parameter, SourceUnit, - Statement, TypeDefinition, VariableDeclaration, VariableDefinition, -}; -use std::convert::Infallible; - -/// a [`forge_fmt::Visitor` that scans for invocations of cheatcodes -#[derive(Default)] -pub struct CheatcodeVisitor { - pub cheatcodes: UnsafeCheatcodes, -} - -impl Visitor for CheatcodeVisitor { - type Error = Infallible; - - fn visit_source_unit(&mut self, source_unit: &mut SourceUnit) -> Result<(), Self::Error> { - source_unit.0.visit(self) - } - - fn visit_contract(&mut self, contract: &mut ContractDefinition) -> Result<(), Self::Error> { - contract.base.visit(self)?; - contract.parts.visit(self) - } - - fn visit_block( - &mut self, - _loc: Loc, - _unchecked: bool, - statements: &mut Vec, - ) -> Result<(), Self::Error> { - statements.visit(self) - } - - fn visit_expr(&mut self, _loc: Loc, expr: &mut Expression) -> Result<(), Self::Error> { - match expr { - Expression::PostIncrement(_, expr) => { - expr.visit(self)?; - } - Expression::PostDecrement(_, expr) => { - expr.visit(self)?; - } - Expression::New(_, expr) => { - expr.visit(self)?; - } - Expression::ArraySubscript(_, expr1, expr2) => { - expr1.visit(self)?; - expr2.visit(self)?; - } - Expression::ArraySlice(_, expr1, expr2, expr3) => { - expr1.visit(self)?; - expr2.visit(self)?; - expr3.visit(self)?; - } - Expression::Parenthesis(_, expr) => { - expr.visit(self)?; - } - Expression::MemberAccess(_, expr, _) => { - expr.visit(self)?; - } - Expression::FunctionCall(loc, lhs, rhs) => { - // all cheatcodes are accessd via .cheatcode - if let Expression::MemberAccess(_, expr, identifier) = &**lhs { - if let Expression::Variable(_) = &**expr { - match identifier.name.as_str() { - "ffi" => self.cheatcodes.ffi.push(*loc), - "readFile" => self.cheatcodes.read_file.push(*loc), - "writeFile" => self.cheatcodes.write_file.push(*loc), - "readLine" => self.cheatcodes.read_line.push(*loc), - "writeLine" => self.cheatcodes.write_line.push(*loc), - "closeFile" => self.cheatcodes.close_file.push(*loc), - "removeFile" => self.cheatcodes.remove_file.push(*loc), - "setEnv" => self.cheatcodes.set_env.push(*loc), - "deriveKey" => self.cheatcodes.derive_key.push(*loc), - _ => {} - } - } - } - rhs.visit(self)?; - } - Expression::FunctionCallBlock(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::NamedFunctionCall(_, lhs, rhs) => { - lhs.visit(self)?; - for arg in rhs.iter_mut() { - arg.expr.visit(self)?; - } - } - Expression::Not(_, expr) => { - expr.visit(self)?; - } - Expression::BitwiseNot(_, expr) => { - expr.visit(self)?; - } - Expression::Delete(_, expr) => { - expr.visit(self)?; - } - Expression::PreIncrement(_, expr) => { - expr.visit(self)?; - } - Expression::PreDecrement(_, expr) => { - expr.visit(self)?; - } - Expression::UnaryPlus(_, expr) => { - expr.visit(self)?; - } - Expression::Negate(_, expr) => { - expr.visit(self)?; - } - Expression::Power(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Multiply(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Divide(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Modulo(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Add(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Subtract(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::ShiftLeft(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::ShiftRight(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::BitwiseAnd(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::BitwiseXor(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::BitwiseOr(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Less(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::More(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::LessEqual(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::MoreEqual(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Equal(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::NotEqual(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::And(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Or(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::ConditionalOperator(_, llhs, lhs, rhs) => { - llhs.visit(self)?; - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::Assign(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignOr(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignAnd(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignXor(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignShiftLeft(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignShiftRight(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignAdd(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignSubtract(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignMultiply(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignDivide(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::AssignModulo(_, lhs, rhs) => { - lhs.visit(self)?; - rhs.visit(self)?; - } - Expression::List(_, param) => { - for (_, param) in param.iter_mut() { - param.visit(self)?; - } - } - _ => {} - } - - Ok(()) - } - - fn visit_emit(&mut self, _: Loc, expr: &mut Expression) -> Result<(), Self::Error> { - expr.visit(self) - } - - fn visit_var_definition(&mut self, var: &mut VariableDefinition) -> Result<(), Self::Error> { - var.ty.visit(self)?; - var.initializer.visit(self) - } - - fn visit_var_definition_stmt( - &mut self, - _: Loc, - declaration: &mut VariableDeclaration, - expr: &mut Option, - ) -> Result<(), Self::Error> { - declaration.visit(self)?; - expr.visit(self) - } - - fn visit_var_declaration(&mut self, var: &mut VariableDeclaration) -> Result<(), Self::Error> { - var.ty.visit(self) - } - - fn visit_revert( - &mut self, - _: Loc, - _error: &mut Option, - args: &mut Vec, - ) -> Result<(), Self::Error> { - args.visit(self) - } - - fn visit_if( - &mut self, - _loc: Loc, - cond: &mut Expression, - if_branch: &mut Box, - else_branch: &mut Option>, - _is_frst_stmt: bool, - ) -> Result<(), Self::Error> { - cond.visit(self)?; - if_branch.visit(self)?; - else_branch.visit(self) - } - - fn visit_while( - &mut self, - _loc: Loc, - cond: &mut Expression, - body: &mut Statement, - ) -> Result<(), Self::Error> { - cond.visit(self)?; - body.visit(self) - } - - fn visit_for( - &mut self, - _loc: Loc, - init: &mut Option>, - cond: &mut Option>, - update: &mut Option>, - body: &mut Option>, - ) -> Result<(), Self::Error> { - init.visit(self)?; - cond.visit(self)?; - update.visit(self)?; - body.visit(self) - } - - fn visit_function(&mut self, func: &mut FunctionDefinition) -> Result<(), Self::Error> { - if let Some(ref mut body) = func.body { - body.visit(self)?; - } - Ok(()) - } - - fn visit_parameter(&mut self, parameter: &mut Parameter) -> Result<(), Self::Error> { - parameter.ty.visit(self) - } - - fn visit_type_definition(&mut self, def: &mut TypeDefinition) -> Result<(), Self::Error> { - def.ty.visit(self) - } -} diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index ac0992cf9f656..d60c1639a05a5 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -105,9 +105,8 @@ fn run() -> Result<()> { ForgeSubcommand::Inspect(cmd) => cmd.run(), ForgeSubcommand::Tree(cmd) => cmd.run(), ForgeSubcommand::Geiger(cmd) => { - let check = cmd.check; let n = cmd.run()?; - if check && n > 0 { + if n > 0 { std::process::exit(n as i32); } Ok(()) diff --git a/crates/forge/tests/cli/debug.rs b/crates/forge/tests/cli/debug.rs index e8cd084187bbc..c217beeb501ff 100644 --- a/crates/forge/tests/cli/debug.rs +++ b/crates/forge/tests/cli/debug.rs @@ -3,7 +3,7 @@ use std::path::Path; // Sets up a debuggable test case. // Run with `cargo test-debugger`. -forgetest_async!( +forgetest!( #[ignore = "ran manually"] manual_debug_setup, |prj, cmd| { diff --git a/crates/forge/tests/cli/geiger.rs b/crates/forge/tests/cli/geiger.rs new file mode 100644 index 0000000000000..fd21656284744 --- /dev/null +++ b/crates/forge/tests/cli/geiger.rs @@ -0,0 +1,92 @@ +forgetest!(call, |prj, cmd| { + prj.add_source( + "call.sol", + r#" + contract A is Test { + function do_ffi() public { + string[] memory inputs = new string[](1); + vm.ffi(inputs); + } + } + "#, + ) + .unwrap(); + + cmd.arg("geiger").assert_code(1).stderr_eq(str![[r#" +error: usage of unsafe cheatcode `vm.ffi` + [FILE]:7:20 + | +7 | vm.ffi(inputs); + | ^^^ + | + + +"#]]); +}); + +forgetest!(assignment, |prj, cmd| { + prj.add_source( + "assignment.sol", + r#" + contract A is Test { + function do_ffi() public { + string[] memory inputs = new string[](1); + bytes stuff = vm.ffi(inputs); + } + } + "#, + ) + .unwrap(); + + cmd.arg("geiger").assert_code(1).stderr_eq(str![[r#" +error: usage of unsafe cheatcode `vm.ffi` + [FILE]:7:34 + | +7 | bytes stuff = vm.ffi(inputs); + | ^^^ + | + + +"#]]); +}); + +forgetest!(exit_code, |prj, cmd| { + prj.add_source( + "multiple.sol", + r#" + contract A is Test { + function do_ffi() public { + vm.ffi(inputs); + vm.ffi(inputs); + vm.ffi(inputs); + } + } + "#, + ) + .unwrap(); + + cmd.arg("geiger").assert_code(3).stderr_eq(str![[r#" +error: usage of unsafe cheatcode `vm.ffi` + [FILE]:6:20 + | +6 | vm.ffi(inputs); + | ^^^ + | + +error: usage of unsafe cheatcode `vm.ffi` + [FILE]:7:20 + | +7 | vm.ffi(inputs); + | ^^^ + | + +error: usage of unsafe cheatcode `vm.ffi` + [FILE]:8:20 + | +8 | vm.ffi(inputs); + | ^^^ + | + + +"#]]); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index a53a26d2ac5ac..5838fa8537772 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -17,6 +17,7 @@ mod create; mod debug; mod doc; mod eip712; +mod geiger; mod multi_script; mod script; mod soldeer; diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 8d7f6cbb5fcc3..f887a40ce7a1c 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -883,7 +883,7 @@ impl TestCommand { let assert = OutputAssert::new(self.execute()); if self.redact_output { return assert.with_assert(test_assert()); - }; + } assert } @@ -914,6 +914,12 @@ impl TestCommand { self.assert().failure() } + /// Runs the command and asserts that the exit code is `expected`. + #[track_caller] + pub fn assert_code(&mut self, expected: i32) -> OutputAssert { + self.assert().code(expected) + } + /// Runs the command and asserts that it **failed** nothing was printed to stderr. #[track_caller] pub fn assert_empty_stderr(&mut self) { From 398ef4a3d55d8dd769ce86cada5ec845e805188b Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 22 Nov 2024 23:58:04 +0800 Subject: [PATCH 1714/1963] feat(forge, cast): add `cast --with_local_artifacts`/`forge selectors cache` to trace with local artifacts (#7359) * add RunArgs generate_local_signatures to enable trace with local contracts functions and events * make generate_local_signatures as a helper function * rename generate_local_signatures to cache_local_signatures merge project signatures with exists cached local signatures instead of just override them * extract duplicate method for CachedSignatures * fix cache load path * fix for lint * fix fot lint * remove unnecessary `let` binding * fix for format check * fix for clippy check * fix for clippy check * Move cache in forge selectors, use local artifacts for cast run and send traces * Add test * Review changes: - compile without quiet, fix test - merge local sources with etherscan * Update crates/evm/traces/src/debug/sources.rs Co-authored-by: Arsenii Kulikov --------- Co-authored-by: grandizzy Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> Co-authored-by: Arsenii Kulikov --- crates/cast/bin/cmd/call.rs | 16 ++- crates/cast/bin/cmd/run.rs | 8 +- crates/cast/tests/cli/main.rs | 111 +++++++++++++++++- crates/cli/src/utils/cmd.rs | 102 ++++++++++------ crates/evm/traces/src/debug/sources.rs | 8 ++ crates/evm/traces/src/identifier/mod.rs | 2 +- .../evm/traces/src/identifier/signatures.rs | 35 ++++-- crates/forge/bin/cmd/selectors.rs | 26 +++- 8 files changed, 256 insertions(+), 52 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index aefc5f1c02f58..cdc3bd4bc6e2f 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -81,6 +81,10 @@ pub struct CallArgs { #[command(flatten)] eth: EthereumOpts, + + /// Use current project artifacts for trace decoding. + #[arg(long, visible_alias = "la")] + pub with_local_artifacts: bool, } #[derive(Debug, Parser)] @@ -127,6 +131,7 @@ impl CallArgs { decode_internal, labels, data, + with_local_artifacts, .. } = self; @@ -195,7 +200,16 @@ impl CallArgs { ), }; - handle_traces(trace, &config, chain, labels, debug, decode_internal, false).await?; + handle_traces( + trace, + &config, + chain, + labels, + with_local_artifacts, + debug, + decode_internal, + ) + .await?; return Ok(()); } diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 79083fa8db9ea..0b85d14feb987 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -10,7 +10,7 @@ use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, utils::{handle_traces, init_progress, TraceResult}, }; -use foundry_common::{is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{ figment::{ @@ -87,6 +87,10 @@ pub struct RunArgs { /// Enables Alphanet features. #[arg(long, alias = "odyssey")] pub alphanet: bool, + + /// Use current project artifacts for trace decoding. + #[arg(long, visible_alias = "la")] + pub with_local_artifacts: bool, } impl RunArgs { @@ -251,9 +255,9 @@ impl RunArgs { &config, chain, self.label, + self.with_local_artifacts, self.debug, self.decode_internal, - shell::verbosity() > 0, ) .await?; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index bdc4a6044d0c7..332f0f99f57bd 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,10 +1,12 @@ //! Contains various tests for checking cast commands use alloy_chains::NamedChain; +use alloy_network::TransactionResponse; use alloy_primitives::{b256, B256}; +use alloy_rpc_types::{BlockNumberOrTag, Index}; use anvil::{EthereumHardfork, NodeConfig}; use foundry_test_utils::{ - casttest, file, + casttest, file, forgetest_async, rpc::{ next_etherscan_api_key, next_http_rpc_endpoint, next_mainnet_etherscan_api_key, next_rpc_endpoint, next_ws_rpc_endpoint, @@ -1596,3 +1598,110 @@ casttest!(fetch_artifact_from_etherscan, |_prj, cmd| { "#]]); }); + +// tests cast can decode traces when using project artifacts +forgetest_async!(decode_traces_with_project_artifacts, |prj, cmd| { + let (api, handle) = + anvil::spawn(NodeConfig::test().with_disable_default_create2_deployer(true)).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_source( + "LocalProjectContract", + r#" +contract LocalProjectContract { + event LocalProjectContractCreated(address owner); + + constructor() { + emit LocalProjectContractCreated(msg.sender); + } +} + "#, + ) + .unwrap(); + prj.add_script( + "LocalProjectScript", + r#" +import "forge-std/Script.sol"; +import {LocalProjectContract} from "../src/LocalProjectContract.sol"; + +contract LocalProjectScript is Script { + function run() public { + vm.startBroadcast(); + new LocalProjectContract(); + vm.stopBroadcast(); + } +} + "#, + ) + .unwrap(); + + cmd.args([ + "script", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + "--broadcast", + "LocalProjectScript", + ]); + + cmd.assert_success(); + + let tx_hash = api + .transaction_by_block_number_and_index(BlockNumberOrTag::Latest, Index::from(0)) + .await + .unwrap() + .unwrap() + .tx_hash(); + + // Assert cast with local artifacts from outside the project. + cmd.cast_fuse() + .args(["run", "--la", format!("{tx_hash}").as_str(), "--rpc-url", &handle.http_endpoint()]) + .assert_success() + .stdout_eq(str![[r#" +Executing previous transactions from the block. +Compiling project to generate artifacts +Nothing to compile + +"#]]); + + // Run cast from project dir. + cmd.cast_fuse().set_current_dir(prj.root()); + + // Assert cast without local artifacts cannot decode traces. + cmd.cast_fuse() + .args(["run", format!("{tx_hash}").as_str(), "--rpc-url", &handle.http_endpoint()]) + .assert_success() + .stdout_eq(str![[r#" +Executing previous transactions from the block. +Traces: + [13520] → new @0x5FbDB2315678afecb367f032d93F642f64180aa3 + ├─ emit topic 0: 0xa7263295d3a687d750d1fd377b5df47de69d7db8decc745aaa4bbee44dc1688d + │ data: 0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266 + └─ ← [Return] 62 bytes of code + + +Transaction successfully executed. +[GAS] + +"#]]); + + // Assert cast with local artifacts can decode traces. + cmd.cast_fuse() + .args(["run", "--la", format!("{tx_hash}").as_str(), "--rpc-url", &handle.http_endpoint()]) + .assert_success() + .stdout_eq(str![[r#" +Executing previous transactions from the block. +Compiling project to generate artifacts +No files changed, compilation skipped +Traces: + [13520] → new LocalProjectContract@0x5FbDB2315678afecb367f032d93F642f64180aa3 + ├─ emit LocalProjectContractCreated(owner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266) + └─ ← [Return] 62 bytes of code + + +Transaction successfully executed. +[GAS] + +"#]]); +}); diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 19e4425b54c7a..523c10478fb64 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -1,7 +1,7 @@ use alloy_json_abi::JsonAbi; use alloy_primitives::Address; use eyre::{Result, WrapErr}; -use foundry_common::{fs, TestFunctionExt}; +use foundry_common::{compile::ProjectCompiler, fs, shell, ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{ artifacts::{CompactBytecode, Settings}, cache::{CacheEntry, CompilerCache}, @@ -14,9 +14,9 @@ use foundry_evm::{ executors::{DeployResult, EvmError, RawCallResult}, opts::EvmOpts, traces::{ - debug::DebugTraceIdentifier, + debug::{ContractSources, DebugTraceIdentifier}, decode_trace_arena, - identifier::{EtherscanIdentifier, SignaturesIdentifier}, + identifier::{CachedSignatures, SignaturesIdentifier, TraceIdentifiers}, render_trace_arena_with_bytecodes, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, @@ -383,10 +383,25 @@ pub async fn handle_traces( config: &Config, chain: Option, labels: Vec, + with_local_artifacts: bool, debug: bool, decode_internal: bool, - verbose: bool, ) -> Result<()> { + let (known_contracts, mut sources) = if with_local_artifacts { + let _ = sh_println!("Compiling project to generate artifacts"); + let project = config.project()?; + let compiler = ProjectCompiler::new(); + let output = compiler.compile(&project)?; + ( + Some(ContractsByArtifact::new( + output.artifact_ids().map(|(id, artifact)| (id, artifact.clone().into())), + )), + ContractSources::from_project_output(&output, project.root(), None)?, + ) + } else { + (None, ContractSources::default()) + }; + let labels = labels.iter().filter_map(|label_str| { let mut iter = label_str.split(':'); @@ -398,45 +413,44 @@ pub async fn handle_traces( None }); let config_labels = config.labels.clone().into_iter(); - let mut decoder = CallTraceDecoderBuilder::new() + + let mut builder = CallTraceDecoderBuilder::new() .with_labels(labels.chain(config_labels)) .with_signature_identifier(SignaturesIdentifier::new( Config::foundry_cache_dir(), config.offline, - )?) - .build(); + )?); + let mut identifier = TraceIdentifiers::new().with_etherscan(config, chain)?; + if let Some(contracts) = &known_contracts { + builder = builder.with_known_contracts(contracts); + identifier = identifier.with_local(contracts); + } - let mut etherscan_identifier = EtherscanIdentifier::new(config, chain)?; - if let Some(etherscan_identifier) = &mut etherscan_identifier { - for (_, trace) in result.traces.as_deref_mut().unwrap_or_default() { - decoder.identify(trace, etherscan_identifier); - } + let mut decoder = builder.build(); + + for (_, trace) in result.traces.as_deref_mut().unwrap_or_default() { + decoder.identify(trace, &mut identifier); } - if decode_internal { - let sources = if let Some(etherscan_identifier) = ðerscan_identifier { - etherscan_identifier.get_compiled_contracts().await? - } else { - Default::default() - }; + if decode_internal || debug { + if let Some(ref etherscan_identifier) = identifier.etherscan { + sources.merge(etherscan_identifier.get_compiled_contracts().await?); + } + + if debug { + let mut debugger = Debugger::builder() + .traces(result.traces.expect("missing traces")) + .decoder(&decoder) + .sources(sources) + .build(); + debugger.try_run_tui()?; + return Ok(()) + } + decoder.debug_identifier = Some(DebugTraceIdentifier::new(sources)); } - if debug { - let sources = if let Some(etherscan_identifier) = etherscan_identifier { - etherscan_identifier.get_compiled_contracts().await? - } else { - Default::default() - }; - let mut debugger = Debugger::builder() - .traces(result.traces.expect("missing traces")) - .decoder(&decoder) - .sources(sources) - .build(); - debugger.try_run_tui()?; - } else { - print_traces(&mut result, &decoder, verbose).await?; - } + print_traces(&mut result, &decoder, shell::verbosity() > 0).await?; Ok(()) } @@ -464,3 +478,25 @@ pub async fn print_traces( sh_println!("Gas used: {}", result.gas_used)?; Ok(()) } + +/// Traverse the artifacts in the project to generate local signatures and merge them into the cache +/// file. +pub fn cache_local_signatures(output: &ProjectCompileOutput, cache_path: PathBuf) -> Result<()> { + let path = cache_path.join("signatures"); + let mut cached_signatures = CachedSignatures::load(cache_path); + output.artifacts().for_each(|(_, artifact)| { + if let Some(abi) = &artifact.abi { + for func in abi.functions() { + cached_signatures.functions.insert(func.selector().to_string(), func.signature()); + } + for event in abi.events() { + cached_signatures + .events + .insert(event.selector().to_string(), event.full_signature()); + } + } + }); + + fs::write_json_file(&path, &cached_signatures)?; + Ok(()) +} diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index 40e540a972d10..dfbfe91af30d9 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -212,6 +212,14 @@ impl ContractSources { Ok(()) } + /// Merges given contract sources. + pub fn merge(&mut self, sources: Self) { + self.sources_by_id.extend(sources.sources_by_id); + for (name, artifacts) in sources.artifacts_by_name { + self.artifacts_by_name.entry(name).or_default().extend(artifacts); + } + } + /// Returns all sources for a contract by name. pub fn get_sources( &self, diff --git a/crates/evm/traces/src/identifier/mod.rs b/crates/evm/traces/src/identifier/mod.rs index 008e5f8418439..51f949832659f 100644 --- a/crates/evm/traces/src/identifier/mod.rs +++ b/crates/evm/traces/src/identifier/mod.rs @@ -12,7 +12,7 @@ mod etherscan; pub use etherscan::EtherscanIdentifier; mod signatures; -pub use signatures::{SignaturesIdentifier, SingleSignaturesIdentifier}; +pub use signatures::{CachedSignatures, SignaturesIdentifier, SingleSignaturesIdentifier}; /// An address identity pub struct AddressIdentity<'a> { diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 1e3924aa3f494..2a5ef354a7530 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -12,11 +12,29 @@ use tokio::sync::RwLock; pub type SingleSignaturesIdentifier = Arc>; #[derive(Debug, Default, Serialize, Deserialize)] -struct CachedSignatures { - events: BTreeMap, - functions: BTreeMap, +pub struct CachedSignatures { + pub events: BTreeMap, + pub functions: BTreeMap, } +impl CachedSignatures { + #[instrument(target = "evm::traces")] + pub fn load(cache_path: PathBuf) -> Self { + let path = cache_path.join("signatures"); + if path.is_file() { + fs::read_json_file(&path) + .map_err( + |err| warn!(target: "evm::traces", ?path, ?err, "failed to read cache file"), + ) + .unwrap_or_default() + } else { + if let Err(err) = std::fs::create_dir_all(cache_path) { + warn!(target: "evm::traces", "could not create signatures cache dir: {:?}", err); + } + Self::default() + } + } +} /// An identifier that tries to identify functions and events using signatures found at /// `https://openchain.xyz` or a local cache. #[derive(Debug)] @@ -42,16 +60,7 @@ impl SignaturesIdentifier { let identifier = if let Some(cache_path) = cache_path { let path = cache_path.join("signatures"); trace!(target: "evm::traces", ?path, "reading signature cache"); - let cached = if path.is_file() { - fs::read_json_file(&path) - .map_err(|err| warn!(target: "evm::traces", ?path, ?err, "failed to read cache file")) - .unwrap_or_default() - } else { - if let Err(err) = std::fs::create_dir_all(cache_path) { - warn!(target: "evm::traces", "could not create signatures cache dir: {:?}", err); - } - CachedSignatures::default() - }; + let cached = CachedSignatures::load(cache_path); Self { cached, cached_path: Some(path), unavailable: HashSet::default(), client } } else { Self { diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index ddd6a796870c4..f75dabaff449b 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -4,13 +4,14 @@ use comfy_table::Table; use eyre::Result; use foundry_cli::{ opts::{CompilerArgs, CoreBuildArgs, ProjectPathsArgs}, - utils::FoundryPathExt, + utils::{cache_local_signatures, FoundryPathExt}, }; use foundry_common::{ compile::{compile_target, ProjectCompiler}, selectors::{import_selectors, SelectorImportData}, }; use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, info::ContractInfo}; +use foundry_config::Config; use std::fs::canonicalize; /// CLI arguments for `forge selectors`. @@ -67,11 +68,34 @@ pub enum SelectorsSubcommands { #[command(flatten)] project_paths: ProjectPathsArgs, }, + + /// Cache project selectors (enables trace with local contracts functions and events). + #[command(visible_alias = "c")] + Cache { + #[command(flatten)] + project_paths: ProjectPathsArgs, + }, } impl SelectorsSubcommands { pub async fn run(self) -> Result<()> { match self { + Self::Cache { project_paths } => { + sh_println!("Caching selectors for contracts in the project...")?; + let build_args = CoreBuildArgs { + project_paths, + compiler: CompilerArgs { + extra_output: vec![ContractOutputSelection::Abi], + ..Default::default() + }, + ..Default::default() + }; + + // compile the project to get the artifacts/abis + let project = build_args.project()?; + let outcome = ProjectCompiler::new().quiet(true).compile(&project)?; + cache_local_signatures(&outcome, Config::foundry_cache_dir().unwrap())? + } Self::Upload { contract, all, project_paths } => { let build_args = CoreBuildArgs { project_paths: project_paths.clone(), From e5412ad6dc2d7ecdc7541b6c0c8b41df80b511ee Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 23 Nov 2024 15:15:27 +0100 Subject: [PATCH 1715/1963] chore: use has_library_ancestor (#9387) --- crates/forge/bin/cmd/geiger.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/geiger.rs b/crates/forge/bin/cmd/geiger.rs index 9ffddd3c98816..6d4c735a9909c 100644 --- a/crates/forge/bin/cmd/geiger.rs +++ b/crates/forge/bin/cmd/geiger.rs @@ -54,7 +54,7 @@ impl GeigerArgs { Graph::::resolve(&paths)? .files() .keys() - .filter(|f| !paths.libraries.iter().any(|lib| f.starts_with(lib))) + .filter(|f| !paths.has_library_ancestor(f)) .cloned() .collect() } else { From d14a7b44fc439407d761fccc4c1637216554bbb6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 23 Nov 2024 16:10:44 +0100 Subject: [PATCH 1716/1963] chore(evm/traces): replace solang with Solar (#9386) --- Cargo.lock | 2 +- crates/evm/traces/Cargo.toml | 2 +- crates/evm/traces/src/debug/sources.rs | 78 +++++++++++++------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15a2386be8b92..0fb6301f5e66f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4076,7 +4076,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "solang-parser", + "solar-parse", "tempfile", "tokio", "tracing", diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 3423213fbb9e9..53bf8b3bb2cb7 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -40,7 +40,7 @@ tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true tempfile.workspace = true rayon.workspace = true -solang-parser.workspace = true +solar-parse.workspace = true revm.workspace = true [dev-dependencies] diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index dfbfe91af30d9..ff1911493baa1 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -11,9 +11,13 @@ use foundry_compilers::{ use foundry_evm_core::utils::PcIcMap; use foundry_linking::Linker; use rayon::prelude::*; -use solang_parser::pt::SourceUnitPart; +use solar_parse::{ + interface::{Pos, Session}, + Parser, +}; use std::{ collections::{BTreeMap, HashMap}, + ops::Range, path::{Path, PathBuf}, sync::Arc, }; @@ -25,7 +29,7 @@ pub struct SourceData { pub path: PathBuf, /// Maps contract name to (start, end) of the contract definition in the source code. /// This is useful for determining which contract contains given function definition. - contract_definitions: Vec<(String, usize, usize)>, + contract_definitions: Vec<(String, Range)>, } impl SourceData { @@ -35,26 +39,26 @@ impl SourceData { match language { MultiCompilerLanguage::Vyper(_) => { // Vyper contracts have the same name as the file name. - if let Some(name) = path.file_name().map(|s| s.to_string_lossy().to_string()) { - contract_definitions.push((name, 0, source.len())); + if let Some(name) = path.file_stem().map(|s| s.to_string_lossy().to_string()) { + contract_definitions.push((name, 0..source.len())); } } MultiCompilerLanguage::Solc(_) => { - if let Ok((parsed, _)) = solang_parser::parse(&source, 0) { - for item in parsed.0 { - let SourceUnitPart::ContractDefinition(contract) = item else { - continue; - }; - let Some(name) = contract.name else { - continue; - }; - contract_definitions.push(( - name.name, - name.loc.start(), - contract.loc.end(), - )); + let sess = Session::builder().with_silent_emitter(None).build(); + let _ = sess.enter(|| -> solar_parse::interface::Result<()> { + let arena = solar_parse::ast::Arena::new(); + let filename = path.clone().into(); + let mut parser = + Parser::from_source_code(&sess, &arena, filename, source.to_string())?; + let ast = parser.parse_file().map_err(|e| e.emit())?; + for item in ast.items { + if let solar_parse::ast::ItemKind::Contract(contract) = &item.kind { + let range = item.span.lo().to_usize()..item.span.hi().to_usize(); + contract_definitions.push((contract.name.to_string(), range)); + } } - } + Ok(()) + }); } } @@ -65,8 +69,8 @@ impl SourceData { pub fn find_contract_name(&self, start: usize, end: usize) -> Option<&str> { self.contract_definitions .iter() - .find(|(_, s, e)| start >= *s && end <= *e) - .map(|(name, _, _)| name.as_str()) + .find(|(_, r)| start >= r.start && end <= r.end) + .map(|(name, _)| name.as_str()) } } @@ -182,26 +186,22 @@ impl ContractSources { let mut files: BTreeMap> = BTreeMap::new(); for (build_id, build) in output.builds() { for (source_id, path) in &build.source_id_to_path { - let source_data = if let Some(source_data) = files.get(path) { - source_data.clone() - } else { - let source = Source::read(path).wrap_err_with(|| { - format!("failed to read artifact source file for `{}`", path.display()) - })?; - - let stripped = path.strip_prefix(root).unwrap_or(path).to_path_buf(); - - let source_data = Arc::new(SourceData::new( - source.content.clone(), - build.language.into(), - stripped, - )); - - files.insert(path.clone(), source_data.clone()); - - source_data + let source_data = match files.entry(path.clone()) { + std::collections::btree_map::Entry::Vacant(entry) => { + let source = Source::read(path).wrap_err_with(|| { + format!("failed to read artifact source file for `{}`", path.display()) + })?; + let stripped = path.strip_prefix(root).unwrap_or(path).to_path_buf(); + let source_data = Arc::new(SourceData::new( + source.content.clone(), + build.language.into(), + stripped, + )); + entry.insert(source_data.clone()); + source_data + } + std::collections::btree_map::Entry::Occupied(entry) => entry.get().clone(), }; - self.sources_by_id .entry(build_id.clone()) .or_default() From 4923529c743f25a0f37503a7bcf7c68caa6901f1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 24 Nov 2024 00:51:26 +0000 Subject: [PATCH 1717/1963] chore(deps): weekly `cargo update` (#9392) Locking 36 packages to latest compatible versions Updating async-compression v0.4.17 -> v0.4.18 Updating bytemuck v1.19.0 -> v1.20.0 Updating const-hex v1.13.1 -> v1.13.2 Adding core-foundation v0.10.0 Updating cpufeatures v0.2.15 -> v0.2.16 Updating h2 v0.4.6 -> v0.4.7 Updating hyper v1.5.0 -> v1.5.1 Updating impl-trait-for-tuples v0.2.2 -> v0.2.3 Updating interprocess v2.2.1 -> v2.2.2 Updating itoa v1.0.11 -> v1.0.13 Updating litemap v0.7.3 -> v0.7.4 Updating op-alloy-consensus v0.6.5 -> v0.6.8 Updating op-alloy-rpc-types v0.6.5 -> v0.6.8 Updating portable-atomic v1.9.0 -> v1.10.0 Updating proc-macro2 v1.0.89 -> v1.0.92 Updating quick-junit v0.5.0 -> v0.5.1 Updating quick-xml v0.36.2 -> v0.37.1 Updating rustix v0.38.40 -> v0.38.41 Updating rustls v0.23.17 -> v0.23.18 Updating rustls-native-certs v0.8.0 -> v0.8.1 Updating scale-info v2.11.5 -> v2.11.6 Updating scale-info-derive v2.11.5 -> v2.11.6 Updating schannel v0.1.26 -> v0.1.27 Adding security-framework v3.0.1 Updating semver-parser v0.10.2 -> v0.10.3 Updating syn v2.0.87 -> v2.0.89 Updating sync_wrapper v1.0.1 -> v1.0.2 Updating unicode-ident v1.0.13 -> v1.0.14 Updating url v2.5.3 -> v2.5.4 Updating wasmtimer v0.4.0 -> v0.4.1 Updating webpki-roots v0.26.6 -> v0.26.7 Updating yoke v0.7.4 -> v0.7.5 Updating yoke-derive v0.7.4 -> v0.7.5 Updating zerofrom v0.1.4 -> v0.1.5 Updating zerofrom-derive v0.1.4 -> v0.1.5 Updating zip v2.2.0 -> v2.2.1 note: pass `--verbose` to see 18 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 365 ++++++++++++++++++++++++++++------------------------- 1 file changed, 192 insertions(+), 173 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fb6301f5e66f..0e6cdd0f96c62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -374,7 +374,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -624,7 +624,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -641,7 +641,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "syn-solidity", "tiny-keccak", ] @@ -659,7 +659,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.87", + "syn 2.0.89", "syn-solidity", ] @@ -752,7 +752,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.17", + "rustls 0.23.18", "serde_json", "tokio", "tokio-tungstenite", @@ -909,7 +909,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 1.5.0", + "hyper 1.5.1", "itertools 0.13.0", "k256", "op-alloy-consensus", @@ -1151,9 +1151,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" +checksum = "df895a515f70646414f4b45c0b79082783b80552b373a68283012928df56f522" dependencies = [ "flate2", "futures-core", @@ -1179,7 +1179,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1201,7 +1201,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1212,7 +1212,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1265,7 +1265,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1607,7 +1607,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "itoa", "matchit", @@ -1621,7 +1621,7 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tokio", "tokio-tungstenite", "tower 0.5.1", @@ -1645,7 +1645,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower-layer", "tower-service", "tracing", @@ -1799,7 +1799,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1843,9 +1843,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" [[package]] name = "byteorder" @@ -2181,7 +2181,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2399,9 +2399,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" +checksum = "487981fa1af147182687064d0a2c336586d337a606595ced9ffb0c685c250c73" dependencies = [ "cfg-if", "cpufeatures", @@ -2435,6 +2435,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -2443,9 +2453,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -2586,7 +2596,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2597,7 +2607,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2670,7 +2680,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2691,7 +2701,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2701,7 +2711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2722,7 +2732,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "unicode-xid", ] @@ -2836,7 +2846,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2861,7 +2871,7 @@ checksum = "1b4464d46ce68bfc7cb76389248c7c254def7baca8bece0693b02b83842c4c88" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2988,7 +2998,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3123,7 +3133,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.87", + "syn 2.0.89", "toml 0.8.19", "walkdir", ] @@ -3151,7 +3161,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.87", + "syn 2.0.89", "tempfile", "thiserror 1.0.69", "tiny-keccak", @@ -3387,7 +3397,7 @@ dependencies = [ "futures", "globset", "humantime-serde", - "hyper 1.5.0", + "hyper 1.5.1", "indicatif", "inferno", "itertools 0.13.0", @@ -3544,7 +3554,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4123,7 +4133,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4282,7 +4292,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4331,7 +4341,7 @@ dependencies = [ "bytes", "chrono", "futures", - "hyper 1.5.0", + "hyper 1.5.1", "jsonwebtoken", "once_cell", "prost", @@ -4666,9 +4676,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes", @@ -4816,7 +4826,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4935,14 +4945,14 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -4978,10 +4988,10 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", - "rustls 0.23.17", - "rustls-native-certs 0.8.0", + "rustls 0.23.18", + "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -4995,7 +5005,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "pin-project-lite", "tokio", @@ -5010,7 +5020,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "native-tls", "tokio", @@ -5029,7 +5039,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.5.1", "pin-project-lite", "socket2", "tokio", @@ -5175,7 +5185,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -5269,13 +5279,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.89", ] [[package]] @@ -5394,14 +5404,14 @@ dependencies = [ "pretty_assertions", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "interprocess" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f4e4a06d42fab3e85ab1b419ad32b09eab58b901d40c57935ff92db3287a13" +checksum = "894148491d817cb36b6f778017b8ac46b17408d522dd90f539d677ea938362eb" dependencies = [ "doctest-file", "futures-core", @@ -5464,9 +5474,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "jiff" @@ -5683,9 +5693,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" @@ -5871,7 +5881,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -5962,7 +5972,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -5977,7 +5987,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "tempfile", ] @@ -6236,7 +6246,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6284,9 +6294,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff54d1d790eca1f3aedbd666162e9c42eceff90b9f9d24b352ed9c2df1e901a" +checksum = "fce158d886815d419222daa67fcdf949a34f7950653a4498ebeb4963331f70ed" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6295,14 +6305,14 @@ dependencies = [ "alloy-serde", "derive_more", "serde", - "spin", + "thiserror 2.0.3", ] [[package]] name = "op-alloy-rpc-types" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "981b7f8ab11fe85ba3c1723702f000429b8d0c16b5883c93d577895f262cbac6" +checksum = "060ebeaea8c772e396215f69bb86d231ec8b7f36aca0dd6ce367ceaa9a8c33e6" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6376,7 +6386,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6457,7 +6467,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6540,7 +6550,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6599,7 +6609,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6683,7 +6693,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6741,7 +6751,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6774,9 +6784,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "powerfmt" @@ -6842,7 +6852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -6920,14 +6930,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -6940,7 +6950,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "version_check", "yansi", ] @@ -7004,7 +7014,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -7027,7 +7037,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -7085,16 +7095,16 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick-junit" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ffd2f9a162cfae131bed6d9d1ed60adced33be340a94f96952897d7cb0c240" +checksum = "3ed1a693391a16317257103ad06a88c6529ac640846021da7c435a06fffdacd7" dependencies = [ "chrono", "indexmap 2.6.0", "newtype-uuid", - "quick-xml 0.36.2", + "quick-xml 0.37.1", "strip-ansi-escapes", - "thiserror 1.0.69", + "thiserror 2.0.3", "uuid 1.11.0", ] @@ -7118,9 +7128,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.36.2" +version = "0.37.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" +checksum = "f22f29bdff3987b4d8632ef95fd6424ec7e4e0a57e2f4fc63e489e75357f6a03" dependencies = [ "memchr", ] @@ -7136,7 +7146,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.17", + "rustls 0.23.18", "socket2", "thiserror 2.0.3", "tokio", @@ -7154,7 +7164,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.17", + "rustls 0.23.18", "rustls-pki-types", "slab", "thiserror 2.0.3", @@ -7374,7 +7384,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-tls", "hyper-util", @@ -7388,14 +7398,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.17", - "rustls-native-certs 0.8.0", + "rustls 0.23.18", + "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tokio", "tokio-native-tls", "tokio-rustls 0.26.0", @@ -7662,9 +7672,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags 2.6.0", "errno", @@ -7687,9 +7697,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.17" +version = "0.23.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" +checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" dependencies = [ "log", "once_cell", @@ -7709,20 +7719,19 @@ dependencies = [ "openssl-probe", "rustls-pemfile 1.0.4", "schannel", - "security-framework", + "security-framework 2.11.1", ] [[package]] name = "rustls-native-certs" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" dependencies = [ "openssl-probe", - "rustls-pemfile 2.2.0", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.0.1", ] [[package]] @@ -7849,9 +7858,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.5" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aa7ffc1c0ef49b0452c6e2986abf2b07743320641ffd5fc63d552458e3b779b" +checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" dependencies = [ "cfg-if", "derive_more", @@ -7861,14 +7870,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.5" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46385cc24172cf615450267463f937c10072516359b3ff1cb24228a4a08bf951" +checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -7882,9 +7891,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -7910,7 +7919,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8017,7 +8026,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", - "core-foundation", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" +dependencies = [ + "bitflags 2.6.0", + "core-foundation 0.10.0", "core-foundation-sys", "libc", "security-framework-sys", @@ -8053,9 +8075,9 @@ dependencies = [ [[package]] name = "semver-parser" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +checksum = "9900206b54a3527fdc7b8a938bffd94a568bac4f4aa8113b209df75a09c0dec2" dependencies = [ "pest", ] @@ -8083,7 +8105,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8094,7 +8116,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8138,7 +8160,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8184,7 +8206,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8489,7 +8511,7 @@ checksum = "f0cc54b74e214647c1bbfc098d080cc5deac77f8dcb99aca91747276b01a15ad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8564,9 +8586,6 @@ name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] [[package]] name = "spki" @@ -8656,7 +8675,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8724,9 +8743,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -8742,7 +8761,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8753,9 +8772,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -8768,7 +8787,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8878,7 +8897,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -8889,7 +8908,7 @@ checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -9024,7 +9043,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -9053,7 +9072,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.17", + "rustls 0.23.18", "rustls-pki-types", "tokio", ] @@ -9090,7 +9109,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.17", + "rustls 0.23.18", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -9166,17 +9185,17 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-timeout", "hyper-util", "percent-encoding", "pin-project 1.1.7", "prost", - "rustls-native-certs 0.8.0", + "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "socket2", "tokio", @@ -9299,7 +9318,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -9416,7 +9435,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.17", + "rustls 0.23.18", "rustls-pki-types", "sha1", "thiserror 1.0.69", @@ -9482,9 +9501,9 @@ checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-linebreak" @@ -9544,9 +9563,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -9715,7 +9734,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-shared", ] @@ -9749,7 +9768,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9775,9 +9794,9 @@ dependencies = [ [[package]] name = "wasmtimer" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4f099acbc1043cc752b91615b24b02d7f6fcd975bd781fed9f50b3c3e15bf7" +checksum = "0048ad49a55b9deb3953841fa1fc5858f0efbcb7a18868c899a360269fac1b23" dependencies = [ "futures", "js-sys", @@ -9872,9 +9891,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" dependencies = [ "rustls-pki-types", ] @@ -9990,7 +10009,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -10001,7 +10020,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -10012,7 +10031,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -10023,7 +10042,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -10285,9 +10304,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -10297,13 +10316,13 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -10325,27 +10344,27 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -10366,7 +10385,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -10388,14 +10407,14 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "zip" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" +checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" dependencies = [ "arbitrary", "bzip2", @@ -10405,7 +10424,7 @@ dependencies = [ "flate2", "indexmap 2.6.0", "memchr", - "thiserror 1.0.69", + "thiserror 2.0.3", "zopfli", ] From cca72aba47a675380a3c87199c7ed0406e3281c2 Mon Sep 17 00:00:00 2001 From: publicqi <56060664+publicqi@users.noreply.github.com> Date: Mon, 25 Nov 2024 03:07:34 -0800 Subject: [PATCH 1718/1963] fix: bail incomplete bytecode sequence disassemble (#9390) --- crates/cast/src/lib.rs | 21 ++++++++++++++++++++- crates/evm/core/src/ic.rs | 9 +++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 39e821dc91f13..b5b719e39ae84 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -2017,7 +2017,7 @@ impl SimpleCast { pub fn disassemble(code: &[u8]) -> Result { let mut output = String::new(); - for step in decode_instructions(code) { + for step in decode_instructions(code)? { write!(output, "{:08x}: ", step.pc)?; if let Some(op) = step.op { @@ -2290,4 +2290,23 @@ mod tests { r#"["0x2b5df5f0757397573e8ff34a8b987b21680357de1f6c8d10273aa528a851eaca","0x","0x","0x2838ac1d2d2721ba883169179b48480b2ba4f43d70fcf806956746bd9e83f903","0x","0xe46fff283b0ab96a32a7cc375cecc3ed7b6303a43d64e0a12eceb0bc6bd87549","0x","0x1d818c1c414c665a9c9a0e0c0ef1ef87cacb380b8c1f6223cb2a68a4b2d023f5","0x","0x","0x","0x236e8f61ecde6abfebc6c529441f782f62469d8a2cc47b7aace2c136bd3b1ff0","0x","0x","0x","0x","0x"]"# ) } + + #[test] + fn disassemble_incomplete_sequence() { + let incomplete = &hex!("60"); // PUSH1 + let disassembled = Cast::disassemble(incomplete); + assert!(disassembled.is_err()); + + let complete = &hex!("6000"); // PUSH1 0x00 + let disassembled = Cast::disassemble(complete); + assert!(disassembled.is_ok()); + + let incomplete = &hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // PUSH32 with 31 bytes + let disassembled = Cast::disassemble(incomplete); + assert!(disassembled.is_err()); + + let complete = &hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // PUSH32 with 32 bytes + let disassembled = Cast::disassemble(complete); + assert!(disassembled.is_ok()); + } } diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index 2711f8933543a..fcabf2a18b41c 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -1,4 +1,5 @@ use alloy_primitives::map::HashMap; +use eyre::Result; use revm::interpreter::{ opcode::{PUSH0, PUSH1, PUSH32}, OpCode, @@ -100,7 +101,7 @@ pub struct Instruction<'a> { } /// Decodes raw opcode bytes into [`Instruction`]s. -pub fn decode_instructions(code: &[u8]) -> Vec> { +pub fn decode_instructions(code: &[u8]) -> Result>> { let mut pc = 0; let mut steps = Vec::new(); @@ -108,10 +109,14 @@ pub fn decode_instructions(code: &[u8]) -> Vec> { let op = OpCode::new(code[pc]); let immediate_size = op.map(|op| immediate_size(op, &code[pc + 1..])).unwrap_or(0) as usize; + if pc + 1 + immediate_size > code.len() { + eyre::bail!("incomplete sequence of bytecode"); + } + steps.push(Instruction { op, pc, immediate: &code[pc + 1..pc + 1 + immediate_size] }); pc += 1 + immediate_size; } - steps + Ok(steps) } From 66228e443846127499374d997aa5df9c898d4f5d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 25 Nov 2024 13:22:15 +0200 Subject: [PATCH 1719/1963] fix(forge create): install missing deps if any (#9401) --- crates/forge/bin/cmd/create.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 9fc2629e5988f..71823416d7131 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -1,3 +1,4 @@ +use crate::cmd::install; use alloy_chains::Chain; use alloy_dyn_abi::{DynSolValue, JsonAbiExt, Specifier}; use alloy_json_abi::{Constructor, JsonAbi}; @@ -98,7 +99,14 @@ pub struct CreateArgs { impl CreateArgs { /// Executes the command to create a contract pub async fn run(mut self) -> Result<()> { - let config = self.try_load_config_emit_warnings()?; + let mut config = self.try_load_config_emit_warnings()?; + + // Install missing dependencies. + if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { + // need to re-configure here to also catch additional remappings + config = self.load_config(); + } + // Find Project & Compile let project = config.project()?; From eae5fb489d39b4de0a611778b9ce82233399e73e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 25 Nov 2024 13:35:49 +0200 Subject: [PATCH 1720/1963] feat(forge): show additional details of contract to verify (#9403) --- crates/verify/src/verify.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index 9c32ee95f5bfa..5a8efe4c65984 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -220,6 +220,17 @@ impl VerifyArgs { let verifier_url = self.verifier.verifier_url.clone(); sh_println!("Start verifying contract `{}` deployed on {chain}", self.address)?; + if let Some(version) = &self.compiler_version { + sh_println!("Compiler version: {version}")?; + } + if let Some(optimizations) = &self.num_of_optimizations { + sh_println!("Optimizations: {optimizations}")? + } + if let Some(args) = &self.constructor_args { + if !args.is_empty() { + sh_println!("Constructor args: {args}")? + } + } self.verifier.verifier.client(&self.etherscan.key())?.verify(self, context).await.map_err(|err| { if let Some(verifier_url) = verifier_url { match Url::parse(&verifier_url) { From de5e89cd117bb30f147c28862c51be6ef239f23f Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:16:57 +0100 Subject: [PATCH 1721/1963] fix: remove duplicate `gas_limit` / `block_gas_limit` field, declare as alias (#9406) remove duplicate gas_limit field, declare as alias --- crates/common/src/evm.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 3eca0800e0cde..c4dfccae16412 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -196,11 +196,6 @@ impl Provider for EvmArgs { #[derive(Clone, Debug, Default, Serialize, Parser)] #[command(next_help_heading = "Executor environment config")] pub struct EnvArgs { - /// The block gas limit. - #[arg(long, value_name = "GAS_LIMIT")] - #[serde(skip_serializing_if = "Option::is_none")] - pub gas_limit: Option, - /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. By /// default, it is 0x6000 (~25kb). #[arg(long, value_name = "CODE_SIZE")] @@ -253,7 +248,7 @@ pub struct EnvArgs { pub block_prevrandao: Option, /// The block gas limit. - #[arg(long, value_name = "GAS_LIMIT")] + #[arg(long, visible_alias = "gas-limit", value_name = "GAS_LIMIT")] #[serde(skip_serializing_if = "Option::is_none")] pub block_gas_limit: Option, From 672bdf60f01630d849f0bf7ffdb447965a53e4e2 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:33:36 +0200 Subject: [PATCH 1722/1963] fix(cheatcodes): use calldata in attachDelegation (#9407) --- crates/cheatcodes/assets/cheatcodes.json | 2 +- crates/cheatcodes/spec/src/vm.rs | 2 +- testdata/cheats/Vm.sol | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d19c776b99166..ed842ddd8aeff 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -3111,7 +3111,7 @@ "func": { "id": "attachDelegation", "description": "Designate the next call as an EIP-7702 transaction", - "declaration": "function attachDelegation(SignedDelegation memory signedDelegation) external;", + "declaration": "function attachDelegation(SignedDelegation calldata signedDelegation) external;", "visibility": "external", "mutability": "", "signature": "attachDelegation((uint8,bytes32,bytes32,uint64,address))", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index bf0fe9781f8ae..e075438258d03 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2040,7 +2040,7 @@ interface Vm { /// Designate the next call as an EIP-7702 transaction #[cheatcode(group = Scripting)] - function attachDelegation(SignedDelegation memory signedDelegation) external; + function attachDelegation(SignedDelegation calldata signedDelegation) external; /// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction #[cheatcode(group = Scripting)] diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 9d1d3efd14208..682b5867197b9 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -149,7 +149,7 @@ interface Vm { function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; function assumeNoRevert() external pure; - function attachDelegation(SignedDelegation memory signedDelegation) external; + function attachDelegation(SignedDelegation calldata signedDelegation) external; function blobBaseFee(uint256 newBlobBaseFee) external; function blobhashes(bytes32[] calldata hashes) external; function breakpoint(string calldata char) external pure; From 995fd9ea031d902b6dd550c7d8a1cf15379feb82 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:30:14 +0100 Subject: [PATCH 1723/1963] chore(cheatcodes): enforce `calldata` in declaration (#9408) --- crates/cheatcodes/assets/cheatcodes.json | 18 +++++++++--------- crates/cheatcodes/spec/src/vm.rs | 18 +++++++++--------- crates/macros/src/cheatcodes.rs | 11 +++++++++++ testdata/cheats/Vm.sol | 18 +++++++++--------- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index ed842ddd8aeff..d8f8d21df67b6 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4615,7 +4615,7 @@ "func": { "id": "eth_getLogs", "description": "Gets all the logs according to specified filter.", - "declaration": "function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) external returns (EthGetLogs[] memory logs);", + "declaration": "function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics) external returns (EthGetLogs[] memory logs);", "visibility": "external", "mutability": "", "signature": "eth_getLogs(uint256,uint256,address,bytes32[])", @@ -5355,7 +5355,7 @@ "func": { "id": "getBroadcast", "description": "Returns the most recent broadcast for the given contract on `chainId` matching `txType`.\nFor example:\nThe most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.\nThe most recent call can be fetched by passing `txType` as `CALL`.", - "declaration": "function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);", + "declaration": "function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);", "visibility": "external", "mutability": "view", "signature": "getBroadcast(string,uint64,uint8)", @@ -5375,7 +5375,7 @@ "func": { "id": "getBroadcasts_0", "description": "Returns all broadcasts for the given contract on `chainId` with the specified `txType`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", - "declaration": "function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);", + "declaration": "function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);", "visibility": "external", "mutability": "view", "signature": "getBroadcasts(string,uint64,uint8)", @@ -5395,7 +5395,7 @@ "func": { "id": "getBroadcasts_1", "description": "Returns all broadcasts for the given contract on `chainId`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", - "declaration": "function getBroadcasts(string memory contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);", + "declaration": "function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);", "visibility": "external", "mutability": "view", "signature": "getBroadcasts(string,uint64)", @@ -5455,7 +5455,7 @@ "func": { "id": "getDeployment_0", "description": "Returns the most recent deployment for the current `chainId`.", - "declaration": "function getDeployment(string memory contractName) external view returns (address deployedAddress);", + "declaration": "function getDeployment(string calldata contractName) external view returns (address deployedAddress);", "visibility": "external", "mutability": "view", "signature": "getDeployment(string)", @@ -5475,7 +5475,7 @@ "func": { "id": "getDeployment_1", "description": "Returns the most recent deployment for the given contract on `chainId`", - "declaration": "function getDeployment(string memory contractName, uint64 chainId) external view returns (address deployedAddress);", + "declaration": "function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);", "visibility": "external", "mutability": "view", "signature": "getDeployment(string,uint64)", @@ -5495,7 +5495,7 @@ "func": { "id": "getDeployments", "description": "Returns all deployments for the given contract on `chainId`\nSorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.\nThe most recent deployment is the first element, and the oldest is the last.", - "declaration": "function getDeployments(string memory contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);", + "declaration": "function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);", "visibility": "external", "mutability": "view", "signature": "getDeployments(string,uint64)", @@ -8621,7 +8621,7 @@ "func": { "id": "serializeJsonType_0", "description": "See `serializeJson`.", - "declaration": "function serializeJsonType(string calldata typeDescription, bytes memory value) external pure returns (string memory json);", + "declaration": "function serializeJsonType(string calldata typeDescription, bytes calldata value) external pure returns (string memory json);", "visibility": "external", "mutability": "pure", "signature": "serializeJsonType(string,bytes)", @@ -8641,7 +8641,7 @@ "func": { "id": "serializeJsonType_1", "description": "See `serializeJson`.", - "declaration": "function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes memory value) external returns (string memory json);", + "declaration": "function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes calldata value) external returns (string memory json);", "visibility": "external", "mutability": "", "signature": "serializeJsonType(string,string,string,bytes)", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index e075438258d03..6b66d31ddb502 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -808,7 +808,7 @@ interface Vm { /// Gets all the logs according to specified filter. #[cheatcode(group = Evm, safety = Safe)] - function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] memory topics) + function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics) external returns (EthGetLogs[] memory logs); @@ -1764,27 +1764,27 @@ interface Vm { /// /// The most recent call can be fetched by passing `txType` as `CALL`. #[cheatcode(group = Filesystem)] - function getBroadcast(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory); + function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory); /// Returns all broadcasts for the given contract on `chainId` with the specified `txType`. /// /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. #[cheatcode(group = Filesystem)] - function getBroadcasts(string memory contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory); + function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory); /// Returns all broadcasts for the given contract on `chainId`. /// /// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber. #[cheatcode(group = Filesystem)] - function getBroadcasts(string memory contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory); + function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory); /// Returns the most recent deployment for the current `chainId`. #[cheatcode(group = Filesystem)] - function getDeployment(string memory contractName) external view returns (address deployedAddress); + function getDeployment(string calldata contractName) external view returns (address deployedAddress); /// Returns the most recent deployment for the given contract on `chainId` #[cheatcode(group = Filesystem)] - function getDeployment(string memory contractName, uint64 chainId) external view returns (address deployedAddress); + function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress); /// Returns all deployments for the given contract on `chainId` /// @@ -1792,7 +1792,7 @@ interface Vm { /// /// The most recent deployment is the first element, and the oldest is the last. #[cheatcode(group = Filesystem)] - function getDeployments(string memory contractName, uint64 chainId) external view returns (address[] memory deployedAddresses); + function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses); // -------- Foreign Function Interface -------- @@ -2298,13 +2298,13 @@ interface Vm { returns (string memory json); /// See `serializeJson`. #[cheatcode(group = Json)] - function serializeJsonType(string calldata typeDescription, bytes memory value) + function serializeJsonType(string calldata typeDescription, bytes calldata value) external pure returns (string memory json); /// See `serializeJson`. #[cheatcode(group = Json)] - function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes memory value) + function serializeJsonType(string calldata objectKey, string calldata valueKey, string calldata typeDescription, bytes calldata value) external returns (string memory json); diff --git a/crates/macros/src/cheatcodes.rs b/crates/macros/src/cheatcodes.rs index d9c2d2c914352..4d0f260c294b8 100644 --- a/crates/macros/src/cheatcodes.rs +++ b/crates/macros/src/cheatcodes.rs @@ -58,6 +58,17 @@ fn derive_call(name: &Ident, data: &DataStruct, attrs: &[Attribute]) -> Result Date: Tue, 26 Nov 2024 14:04:37 +0100 Subject: [PATCH 1724/1963] feat: remove ethers (#8826) Co-authored-by: grandizzy --- Cargo.lock | 216 ----------------------------------- Cargo.toml | 3 - README.md | 5 +- crates/forge/Cargo.toml | 2 - crates/forge/bin/cmd/bind.rs | 152 ++---------------------- 5 files changed, 14 insertions(+), 364 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e6cdd0f96c62..2aa261d17725f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1908,38 +1908,6 @@ 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.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.23", - "serde", - "serde_json", - "thiserror 1.0.69", -] - [[package]] name = "cassowary" version = "0.3.0" @@ -3068,106 +3036,6 @@ dependencies = [ "uuid 0.8.2", ] -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror 1.0.69", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-contract-abigen" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" -dependencies = [ - "Inflector", - "const-hex", - "dunce", - "ethers-core", - "eyre", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "serde", - "serde_json", - "syn 2.0.89", - "toml 0.8.19", - "walkdir", -] - -[[package]] -name = "ethers-core" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" -dependencies = [ - "arrayvec", - "bytes", - "cargo_metadata", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "once_cell", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum", - "syn 2.0.89", - "tempfile", - "thiserror 1.0.69", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "event-listener" version = "4.0.3" @@ -3375,7 +3243,6 @@ dependencies = [ "comfy-table", "dialoguer", "dunce", - "ethers-contract-abigen", "evm-disassembler", "eyre", "forge-doc", @@ -5259,24 +5126,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.3" @@ -6243,7 +6092,6 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.89", @@ -6326,31 +6174,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "opener" version = "0.7.2" @@ -6872,9 +6695,6 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", "uint", ] @@ -7554,21 +7374,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "rpassword" version = "7.3.1" @@ -7856,30 +7664,6 @@ dependencies = [ "regex", ] -[[package]] -name = "scale-info" -version = "2.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.89", -] - [[package]] name = "scc" version = "2.2.5" diff --git a/Cargo.toml b/Cargo.toml index 814c43aa556ae..42b033f260fa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -180,9 +180,6 @@ revm = { version = "18.0.0", default-features = false } revm-primitives = { version = "14.0.0", default-features = false } revm-inspectors = { version = "0.11.0", features = ["serde"] } -## ethers -ethers-contract-abigen = { version = "2.0.14", default-features = false } - ## alloy alloy-consensus = { version = "0.6.4", default-features = false } alloy-contract = { version = "0.6.4", default-features = false } diff --git a/README.md b/README.md index ec0884aa2378f..bd93251911219 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ If you're experiencing any issues while installing, check out [Getting Help](#ge ### How Fast? -Forge is quite fast at both compiling (leveraging [ethers-solc]) and testing. +Forge is quite fast at both compiling (leveraging [foundry-compilers]) and testing. See the benchmarks below. More benchmarks can be found in the [v0.2.0 announcement post][benchmark-post] and in the [Convex Shutdown Simulation][convex] repository. @@ -127,7 +127,7 @@ If you want to contribute, or follow along with contributor discussion, you can ## Acknowledgements - Foundry is a clean-room rewrite of the testing framework [DappTools](https://github.com/dapphub/dapptools). None of this would have been possible without the DappHub team's work over the years. -- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. +- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] (now [foundry-compilers]) which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. - [Rohit Narurkar](https://twitter.com/rohitnarurkar): Created the Rust Solidity version manager [svm-rs](https://github.com/roynalnaruto/svm-rs) which we use to auto-detect and manage multiple Solidity versions. - [Brock Elmore](https://twitter.com/brockjelmore): For extending the VM's cheatcodes and implementing [structured call tracing](https://github.com/foundry-rs/foundry/pull/192), a critical feature for debugging smart contract calls. - All the other [contributors](https://github.com/foundry-rs/foundry/graphs/contributors) to the [ethers-rs](https://github.com/gakonst/ethers-rs) & [foundry](https://github.com/foundry-rs/foundry) repositories and chatrooms. @@ -135,6 +135,7 @@ If you want to contribute, or follow along with contributor discussion, you can [foundry-book]: https://book.getfoundry.sh [foundry-gha]: https://github.com/foundry-rs/foundry-toolchain [ethers-solc]: https://github.com/gakonst/ethers-rs/tree/master/ethers-solc/ +[foundry-compilers]: https://github.com/foundry-rs/foundry-compilers [solmate]: https://github.com/transmissions11/solmate/ [geb]: https://github.com/reflexer-labs/geb [vaults]: https://github.com/rari-capital/vaults diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 208ea8430ab96..b01f2d3e1c276 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -35,8 +35,6 @@ foundry-wallets.workspace = true foundry-linking.workspace = true forge-script-sequence.workspace = true -ethers-contract-abigen = { workspace = true, features = ["providers"] } - revm-inspectors.workspace = true comfy-table.workspace = true diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index ec6b13dfd49ae..d541a530d9ce9 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -1,9 +1,6 @@ use alloy_primitives::map::HashSet; use clap::{Parser, ValueHint}; -use ethers_contract_abigen::{ - Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts, -}; -use eyre::{Result, WrapErr}; +use eyre::Result; use forge_sol_macro_gen::{MultiSolMacroGen, SolMacroGen}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs::json_files}; @@ -83,15 +80,15 @@ pub struct BindArgs { skip_extra_derives: bool, /// Generate bindings for the `alloy` library, instead of `ethers`. - #[arg(long, conflicts_with = "ethers")] + #[arg(long, hide = true)] alloy: bool, /// Specify the alloy version. - #[arg(long, value_name = "ALLOY_VERSION")] + #[arg(long)] alloy_version: Option, - /// Generate bindings for the `ethers` library, instead of `alloy` (default, deprecated). - #[arg(long)] + /// Generate bindings for the `ethers` library, instead of `alloy` (removed). + #[arg(long, hide = true)] ethers: bool, #[command(flatten)] @@ -100,17 +97,15 @@ pub struct BindArgs { impl BindArgs { pub fn run(self) -> Result<()> { + if self.ethers { + eyre::bail!("`--ethers` bindings have been removed. Use `--alloy` (default) instead."); + } + if !self.skip_build { let project = self.build_args.project()?; let _ = ProjectCompiler::new().compile(&project)?; } - if self.ethers { - sh_warn!( - "`--ethers` bindings are deprecated and will be removed in the future. Consider using `--alloy` (default) instead." - )?; - } - let config = self.try_load_config_emit_warnings()?; let artifacts = config.out; let bindings_root = self.bindings.clone().unwrap_or_else(|| artifacts.join("bindings")); @@ -131,40 +126,7 @@ impl BindArgs { Ok(()) } - /// Returns the filter to use for `MultiAbigen` - fn get_filter(&self) -> Result { - if self.select_all { - return Ok(ContractFilter::All) - } - if !self.select.is_empty() { - return Ok(SelectContracts::default().extend_regex(self.select.clone()).into()) - } - if let Some(skip) = self.build_args.skip.as_ref().filter(|s| !s.is_empty()) { - return Ok(ExcludeContracts::default() - .extend_regex( - skip.clone() - .into_iter() - .map(|s| Regex::new(s.file_pattern())) - .collect::, _>>()?, - ) - .into()) - } - // This excludes all Test/Script and forge-std contracts - Ok(ExcludeContracts::default() - .extend_pattern([ - ".*Test.*", - ".*Script", - "console[2]?", - "CommonBase", - "Components", - "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Toml|Storage(Safe)?)", - "[Vv]m.*", - ]) - .extend_names(["IMulticall3"]) - .into()) - } - - fn get_alloy_filter(&self) -> Result { + fn get_filter(&self) -> Result { if self.select_all { // Select all json files return Ok(Filter::All); @@ -190,8 +152,6 @@ impl BindArgs { /// Returns an iterator over the JSON files and the contract name in the `artifacts` directory. fn get_json_files(&self, artifacts: &Path) -> Result> { let filter = self.get_filter()?; - let alloy_filter = self.get_alloy_filter()?; - let is_alloy = !self.ethers; Ok(json_files(artifacts) .filter_map(|path| { // Ignore the build info JSON. @@ -212,35 +172,7 @@ impl BindArgs { Some((name, path)) }) - .filter( - move |(name, _path)| { - if is_alloy { - alloy_filter.is_match(name) - } else { - filter.is_match(name) - } - }, - )) - } - - /// Instantiate the multi-abigen - fn get_multi(&self, artifacts: &Path) -> Result { - let abigens = self - .get_json_files(artifacts)? - .map(|(name, path)| { - trace!(?path, "parsing Abigen from file"); - let abi = Abigen::new(name, path.to_str().unwrap()) - .wrap_err_with(|| format!("failed to parse Abigen from file: {path:?}")); - if !self.skip_extra_derives { - abi?.add_derive("serde::Serialize")?.add_derive("serde::Deserialize") - } else { - abi - } - }) - .collect::, _>>()?; - let multi = MultiAbigen::from_abigens(abigens); - eyre::ensure!(!multi.is_empty(), "No contract artifacts found"); - Ok(multi) + .filter(move |(name, _path)| filter.is_match(name))) } fn get_solmacrogen(&self, artifacts: &Path) -> Result { @@ -264,40 +196,6 @@ impl BindArgs { /// Check that the existing bindings match the expected abigen output fn check_existing_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - if self.ethers { - return self.check_ethers(artifacts, bindings_root); - } - - self.check_alloy(artifacts, bindings_root) - } - - fn check_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - let bindings = self.get_multi(artifacts)?.build()?; - sh_println!("Checking bindings for {} contracts.", bindings.len())?; - if !self.module { - bindings - .ensure_consistent_crate( - &self.crate_name, - &self.crate_version, - bindings_root, - self.single_file, - !self.skip_cargo_toml, - ) - .map_err(|err| { - if !self.skip_cargo_toml && err.to_string().contains("Cargo.toml") { - err.wrap_err("To skip Cargo.toml consistency check, pass --skip-cargo-toml") - } else { - err - } - })?; - } else { - bindings.ensure_consistent_module(bindings_root, self.single_file)?; - } - sh_println!("OK.")?; - Ok(()) - } - - fn check_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut bindings = self.get_solmacrogen(artifacts)?; bindings.generate_bindings()?; sh_println!("Checking bindings for {} contracts", bindings.instances.len())?; @@ -316,34 +214,6 @@ impl BindArgs { /// Generate the bindings fn generate_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - if self.ethers { - return self.generate_ethers(artifacts, bindings_root); - } - - self.generate_alloy(artifacts, bindings_root) - } - - fn generate_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - let mut bindings = self.get_multi(artifacts)?.build()?; - sh_println!("Generating bindings for {} contracts", bindings.len())?; - if !self.module { - trace!(single_file = self.single_file, "generating crate"); - if !self.skip_extra_derives { - bindings = bindings.dependencies([r#"serde = "1""#]) - } - bindings.write_to_crate( - &self.crate_name, - &self.crate_version, - bindings_root, - self.single_file, - ) - } else { - trace!(single_file = self.single_file, "generating module"); - bindings.write_to_module(bindings_root, self.single_file) - } - } - - fn generate_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut solmacrogen = self.get_solmacrogen(artifacts)?; sh_println!("Generating bindings for {} contracts", solmacrogen.instances.len())?; From 958c713e2fd343c0e84d3f7adda6b8ef9aa42eeb Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:37:29 +0200 Subject: [PATCH 1725/1963] Revert "feat: remove ethers" (#9411) Revert "feat: remove ethers (#8826)" This reverts commit d7397043e17e8d88a0c21cffa9d300377aed27c5. --- Cargo.lock | 216 +++++++++++++++++++++++++++++++++++ Cargo.toml | 3 + README.md | 5 +- crates/forge/Cargo.toml | 2 + crates/forge/bin/cmd/bind.rs | 152 ++++++++++++++++++++++-- 5 files changed, 364 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2aa261d17725f..0e6cdd0f96c62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1908,6 +1908,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.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.23", + "serde", + "serde_json", + "thiserror 1.0.69", +] + [[package]] name = "cassowary" version = "0.3.0" @@ -3036,6 +3068,106 @@ dependencies = [ "uuid 0.8.2", ] +[[package]] +name = "ethabi" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" +dependencies = [ + "ethereum-types", + "hex", + "once_cell", + "regex", + "serde", + "serde_json", + "sha3", + "thiserror 1.0.69", + "uint", +] + +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "scale-info", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "primitive-types", + "scale-info", + "uint", +] + +[[package]] +name = "ethers-contract-abigen" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" +dependencies = [ + "Inflector", + "const-hex", + "dunce", + "ethers-core", + "eyre", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "syn 2.0.89", + "toml 0.8.19", + "walkdir", +] + +[[package]] +name = "ethers-core" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" +dependencies = [ + "arrayvec", + "bytes", + "cargo_metadata", + "chrono", + "const-hex", + "elliptic-curve", + "ethabi", + "generic-array", + "k256", + "num_enum", + "once_cell", + "open-fastrlp", + "rand", + "rlp", + "serde", + "serde_json", + "strum", + "syn 2.0.89", + "tempfile", + "thiserror 1.0.69", + "tiny-keccak", + "unicode-xid", +] + [[package]] name = "event-listener" version = "4.0.3" @@ -3243,6 +3375,7 @@ dependencies = [ "comfy-table", "dialoguer", "dunce", + "ethers-contract-abigen", "evm-disassembler", "eyre", "forge-doc", @@ -5126,6 +5259,24 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + [[package]] name = "impl-trait-for-tuples" version = "0.2.3" @@ -6092,6 +6243,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ + "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.89", @@ -6174,6 +6326,31 @@ dependencies = [ "serde_json", ] +[[package]] +name = "open-fastrlp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", + "ethereum-types", + "open-fastrlp-derive", +] + +[[package]] +name = "open-fastrlp-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" +dependencies = [ + "bytes", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "opener" version = "0.7.2" @@ -6695,6 +6872,9 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", + "impl-rlp", + "impl-serde", + "scale-info", "uint", ] @@ -7374,9 +7554,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", + "rlp-derive", "rustc-hex", ] +[[package]] +name = "rlp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "rpassword" version = "7.3.1" @@ -7664,6 +7856,30 @@ dependencies = [ "regex", ] +[[package]] +name = "scale-info" +version = "2.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" +dependencies = [ + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "scc" version = "2.2.5" diff --git a/Cargo.toml b/Cargo.toml index 42b033f260fa4..814c43aa556ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -180,6 +180,9 @@ revm = { version = "18.0.0", default-features = false } revm-primitives = { version = "14.0.0", default-features = false } revm-inspectors = { version = "0.11.0", features = ["serde"] } +## ethers +ethers-contract-abigen = { version = "2.0.14", default-features = false } + ## alloy alloy-consensus = { version = "0.6.4", default-features = false } alloy-contract = { version = "0.6.4", default-features = false } diff --git a/README.md b/README.md index bd93251911219..ec0884aa2378f 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ If you're experiencing any issues while installing, check out [Getting Help](#ge ### How Fast? -Forge is quite fast at both compiling (leveraging [foundry-compilers]) and testing. +Forge is quite fast at both compiling (leveraging [ethers-solc]) and testing. See the benchmarks below. More benchmarks can be found in the [v0.2.0 announcement post][benchmark-post] and in the [Convex Shutdown Simulation][convex] repository. @@ -127,7 +127,7 @@ If you want to contribute, or follow along with contributor discussion, you can ## Acknowledgements - Foundry is a clean-room rewrite of the testing framework [DappTools](https://github.com/dapphub/dapptools). None of this would have been possible without the DappHub team's work over the years. -- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] (now [foundry-compilers]) which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. +- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. - [Rohit Narurkar](https://twitter.com/rohitnarurkar): Created the Rust Solidity version manager [svm-rs](https://github.com/roynalnaruto/svm-rs) which we use to auto-detect and manage multiple Solidity versions. - [Brock Elmore](https://twitter.com/brockjelmore): For extending the VM's cheatcodes and implementing [structured call tracing](https://github.com/foundry-rs/foundry/pull/192), a critical feature for debugging smart contract calls. - All the other [contributors](https://github.com/foundry-rs/foundry/graphs/contributors) to the [ethers-rs](https://github.com/gakonst/ethers-rs) & [foundry](https://github.com/foundry-rs/foundry) repositories and chatrooms. @@ -135,7 +135,6 @@ If you want to contribute, or follow along with contributor discussion, you can [foundry-book]: https://book.getfoundry.sh [foundry-gha]: https://github.com/foundry-rs/foundry-toolchain [ethers-solc]: https://github.com/gakonst/ethers-rs/tree/master/ethers-solc/ -[foundry-compilers]: https://github.com/foundry-rs/foundry-compilers [solmate]: https://github.com/transmissions11/solmate/ [geb]: https://github.com/reflexer-labs/geb [vaults]: https://github.com/rari-capital/vaults diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index b01f2d3e1c276..208ea8430ab96 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -35,6 +35,8 @@ foundry-wallets.workspace = true foundry-linking.workspace = true forge-script-sequence.workspace = true +ethers-contract-abigen = { workspace = true, features = ["providers"] } + revm-inspectors.workspace = true comfy-table.workspace = true diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index d541a530d9ce9..ec6b13dfd49ae 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -1,6 +1,9 @@ use alloy_primitives::map::HashSet; use clap::{Parser, ValueHint}; -use eyre::Result; +use ethers_contract_abigen::{ + Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts, +}; +use eyre::{Result, WrapErr}; use forge_sol_macro_gen::{MultiSolMacroGen, SolMacroGen}; use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs::json_files}; @@ -80,15 +83,15 @@ pub struct BindArgs { skip_extra_derives: bool, /// Generate bindings for the `alloy` library, instead of `ethers`. - #[arg(long, hide = true)] + #[arg(long, conflicts_with = "ethers")] alloy: bool, /// Specify the alloy version. - #[arg(long)] + #[arg(long, value_name = "ALLOY_VERSION")] alloy_version: Option, - /// Generate bindings for the `ethers` library, instead of `alloy` (removed). - #[arg(long, hide = true)] + /// Generate bindings for the `ethers` library, instead of `alloy` (default, deprecated). + #[arg(long)] ethers: bool, #[command(flatten)] @@ -97,15 +100,17 @@ pub struct BindArgs { impl BindArgs { pub fn run(self) -> Result<()> { - if self.ethers { - eyre::bail!("`--ethers` bindings have been removed. Use `--alloy` (default) instead."); - } - if !self.skip_build { let project = self.build_args.project()?; let _ = ProjectCompiler::new().compile(&project)?; } + if self.ethers { + sh_warn!( + "`--ethers` bindings are deprecated and will be removed in the future. Consider using `--alloy` (default) instead." + )?; + } + let config = self.try_load_config_emit_warnings()?; let artifacts = config.out; let bindings_root = self.bindings.clone().unwrap_or_else(|| artifacts.join("bindings")); @@ -126,7 +131,40 @@ impl BindArgs { Ok(()) } - fn get_filter(&self) -> Result { + /// Returns the filter to use for `MultiAbigen` + fn get_filter(&self) -> Result { + if self.select_all { + return Ok(ContractFilter::All) + } + if !self.select.is_empty() { + return Ok(SelectContracts::default().extend_regex(self.select.clone()).into()) + } + if let Some(skip) = self.build_args.skip.as_ref().filter(|s| !s.is_empty()) { + return Ok(ExcludeContracts::default() + .extend_regex( + skip.clone() + .into_iter() + .map(|s| Regex::new(s.file_pattern())) + .collect::, _>>()?, + ) + .into()) + } + // This excludes all Test/Script and forge-std contracts + Ok(ExcludeContracts::default() + .extend_pattern([ + ".*Test.*", + ".*Script", + "console[2]?", + "CommonBase", + "Components", + "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Toml|Storage(Safe)?)", + "[Vv]m.*", + ]) + .extend_names(["IMulticall3"]) + .into()) + } + + fn get_alloy_filter(&self) -> Result { if self.select_all { // Select all json files return Ok(Filter::All); @@ -152,6 +190,8 @@ impl BindArgs { /// Returns an iterator over the JSON files and the contract name in the `artifacts` directory. fn get_json_files(&self, artifacts: &Path) -> Result> { let filter = self.get_filter()?; + let alloy_filter = self.get_alloy_filter()?; + let is_alloy = !self.ethers; Ok(json_files(artifacts) .filter_map(|path| { // Ignore the build info JSON. @@ -172,7 +212,35 @@ impl BindArgs { Some((name, path)) }) - .filter(move |(name, _path)| filter.is_match(name))) + .filter( + move |(name, _path)| { + if is_alloy { + alloy_filter.is_match(name) + } else { + filter.is_match(name) + } + }, + )) + } + + /// Instantiate the multi-abigen + fn get_multi(&self, artifacts: &Path) -> Result { + let abigens = self + .get_json_files(artifacts)? + .map(|(name, path)| { + trace!(?path, "parsing Abigen from file"); + let abi = Abigen::new(name, path.to_str().unwrap()) + .wrap_err_with(|| format!("failed to parse Abigen from file: {path:?}")); + if !self.skip_extra_derives { + abi?.add_derive("serde::Serialize")?.add_derive("serde::Deserialize") + } else { + abi + } + }) + .collect::, _>>()?; + let multi = MultiAbigen::from_abigens(abigens); + eyre::ensure!(!multi.is_empty(), "No contract artifacts found"); + Ok(multi) } fn get_solmacrogen(&self, artifacts: &Path) -> Result { @@ -196,6 +264,40 @@ impl BindArgs { /// Check that the existing bindings match the expected abigen output fn check_existing_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + if self.ethers { + return self.check_ethers(artifacts, bindings_root); + } + + self.check_alloy(artifacts, bindings_root) + } + + fn check_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + let bindings = self.get_multi(artifacts)?.build()?; + sh_println!("Checking bindings for {} contracts.", bindings.len())?; + if !self.module { + bindings + .ensure_consistent_crate( + &self.crate_name, + &self.crate_version, + bindings_root, + self.single_file, + !self.skip_cargo_toml, + ) + .map_err(|err| { + if !self.skip_cargo_toml && err.to_string().contains("Cargo.toml") { + err.wrap_err("To skip Cargo.toml consistency check, pass --skip-cargo-toml") + } else { + err + } + })?; + } else { + bindings.ensure_consistent_module(bindings_root, self.single_file)?; + } + sh_println!("OK.")?; + Ok(()) + } + + fn check_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut bindings = self.get_solmacrogen(artifacts)?; bindings.generate_bindings()?; sh_println!("Checking bindings for {} contracts", bindings.instances.len())?; @@ -214,6 +316,34 @@ impl BindArgs { /// Generate the bindings fn generate_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + if self.ethers { + return self.generate_ethers(artifacts, bindings_root); + } + + self.generate_alloy(artifacts, bindings_root) + } + + fn generate_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { + let mut bindings = self.get_multi(artifacts)?.build()?; + sh_println!("Generating bindings for {} contracts", bindings.len())?; + if !self.module { + trace!(single_file = self.single_file, "generating crate"); + if !self.skip_extra_derives { + bindings = bindings.dependencies([r#"serde = "1""#]) + } + bindings.write_to_crate( + &self.crate_name, + &self.crate_version, + bindings_root, + self.single_file, + ) + } else { + trace!(single_file = self.single_file, "generating module"); + bindings.write_to_module(bindings_root, self.single_file) + } + } + + fn generate_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut solmacrogen = self.get_solmacrogen(artifacts)?; sh_println!("Generating bindings for {} contracts", solmacrogen.instances.len())?; From 0045384f1087897b2665506e95808f022776a5a7 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:32:35 +0100 Subject: [PATCH 1726/1963] fix: forge script should adhere to `--json` flag (#9404) * adhere to --quiet flag * revert case-specific handling of writing to progress, redundant * handle writing to multiprogress, previously panic * make verification process compatible with --json flag * revert verifaction --json flow, too messy * clean up * revert * handle json correctly for script deployment logs, incl. receipts * avoid incompatible lines with json output * revert unnecessary change * add json and quiet test * address feedback * fix incorrect ordering --- crates/forge/tests/cli/script.rs | 78 +++++++++++++++++++++ crates/script-sequence/src/sequence.rs | 17 ++++- crates/script/src/broadcast.rs | 8 ++- crates/script/src/lib.rs | 9 ++- crates/script/src/multi_sequence.rs | 17 ++++- crates/script/src/progress.rs | 95 +++++++++++++++----------- crates/script/src/receipts.rs | 76 +++++++++++++-------- crates/script/src/simulate.rs | 58 +++++++++------- crates/verify/src/etherscan/mod.rs | 1 - 9 files changed, 257 insertions(+), 102 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index df2a59bdc4dfb..d7776eee2e87f 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -6,6 +6,7 @@ use anvil::{spawn, NodeConfig}; use forge_script_sequence::ScriptSequence; use foundry_test_utils::{ rpc, + snapbox::IntoData, util::{OTHER_SOLC_VERSION, SOLC_VERSION}, ScriptOutcome, ScriptTester, }; @@ -1821,6 +1822,83 @@ Warning: Script contains a transaction to 0x000000000000000000000000000000000000 "#]]); }); +// Asserts that the script runs with expected non-output using `--quiet` flag +forgetest_async!(adheres_to_quiet_flag, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function run() external returns (bool success) { + vm.startBroadcast(); + (success, ) = address(0).call(""); + } +} + "#, + ) + .unwrap(); + + let (_api, handle) = spawn(NodeConfig::test()).await; + + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--sender", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "--broadcast", + "--unlocked", + "--non-interactive", + "--quiet", + ]) + .assert_empty_stdout(); +}); + +// Asserts that the script runs with expected non-output using `--quiet` flag +forgetest_async!(adheres_to_json_flag, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract SimpleScript is Script { + function run() external returns (bool success) { + vm.startBroadcast(); + (success, ) = address(0).call(""); + } +} + "#, + ) + .unwrap(); + + let (_api, handle) = spawn(NodeConfig::test()).await; + + cmd.args([ + "script", + "SimpleScript", + "--fork-url", + &handle.http_endpoint(), + "--sender", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "--broadcast", + "--unlocked", + "--non-interactive", + "--json", + ]) + .assert_success() + .stdout_eq(str![[r#" +{"logs":[],"returns":{"success":{"internal_type":"bool","value":"true"}},"success":true,"raw_logs":[],"traces":[["Deployment",{"arena":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":false,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CREATE","value":"0x0","data":"0x6080604052600c805462ff00ff191662010001179055348015601f575f5ffd5b506101568061002d5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122060ba6332e526de9b6bc731fb4682b44e42845196324ec33068982984d700cdd964736f6c634300081b0033","output":"0x608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122060ba6332e526de9b6bc731fb4682b44e42845196324ec33068982984d700cdd964736f6c634300081b0033","gas_used":90639,"gas_limit":1073682810,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}],["Execution",{"arena":[{"parent":null,"children":[1,2],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0xc0406226","output":"0x0000000000000000000000000000000000000000000000000000000000000001","gas_used":3214,"gas_limit":1073720760,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[{"Call":0},{"Call":1}]},{"parent":0,"children":[],"idx":1,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x7109709ecfa91a80626ff3989d68f67f5b1dd12d","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x7fb5297f","output":"0x","gas_used":0,"gas_limit":1056940983,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]},{"parent":0,"children":[],"idx":2,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x0000000000000000000000000000000000000000","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1056940820,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}]],"gas_used":24278,"labeled_addresses":{},"returned":"0x0000000000000000000000000000000000000000000000000000000000000001","address":null} +{"chain":31337,"estimated_gas_price":"2.000000001","estimated_total_gas_used":29005,"estimated_amount_required":"0.000058010000029005"} +{"chain":"anvil-hardhat","status":"success","tx_hash":"0x4f78afe915fceb282c7625a68eb350bc0bf78acb59ad893e5c62b710a37f3156","contract_address":null,"block_number":1,"gas_used":21000,"gas_price":1000000001} +{"status":"success","transactions":"[..]/broadcast/Foo.sol/31337/run-latest.json","sensitive":"[..]/cache/Foo.sol/31337/run-latest.json"} + +"#]].is_jsonlines()); +}); + // https://github.com/foundry-rs/foundry/pull/7742 forgetest_async!(unlocked_no_sender, |prj, cmd| { foundry_test_utils::util::initialize(prj.root()); diff --git a/crates/script-sequence/src/sequence.rs b/crates/script-sequence/src/sequence.rs index e34b6d06a8655..235f28f2c4ff4 100644 --- a/crates/script-sequence/src/sequence.rs +++ b/crates/script-sequence/src/sequence.rs @@ -2,7 +2,7 @@ use crate::transaction::TransactionWithMetadata; use alloy_primitives::{hex, map::HashMap, TxHash}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::{ContextCompat, Result, WrapErr}; -use foundry_common::{fs, TransactionMaybeSigned, SELECTOR_LEN}; +use foundry_common::{fs, shell, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_compilers::ArtifactId; use foundry_config::Config; use serde::{Deserialize, Serialize}; @@ -127,8 +127,19 @@ impl ScriptSequence { } if !silent { - sh_println!("\nTransactions saved to: {}\n", path.display())?; - sh_println!("Sensitive values saved to: {}\n", sensitive_path.display())?; + if shell::is_json() { + sh_println!( + "{}", + serde_json::json!({ + "status": "success", + "transactions": path.display().to_string(), + "sensitive": sensitive_path.display().to_string(), + }) + )?; + } else { + sh_println!("\nTransactions saved to: {}\n", path.display())?; + sh_println!("Sensitive values saved to: {}\n", sensitive_path.display())?; + } } Ok(()) diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 51e8baf5b3be8..207754e5c9526 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -21,7 +21,7 @@ use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_batch_support, has_different_gas_calc}; use foundry_common::{ provider::{get_http_provider, try_get_http_provider, RetryProvider}, - TransactionMaybeSigned, + shell, TransactionMaybeSigned, }; use foundry_config::Config; use futures::{future::join_all, StreamExt}; @@ -429,8 +429,10 @@ impl BundledState { seq_progress.inner.write().finish(); } - sh_println!("\n\n==========================")?; - sh_println!("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; + if !shell::is_json() { + sh_println!("\n\n==========================")?; + sh_println!("\nONCHAIN EXECUTION COMPLETE & SUCCESSFUL.")?; + } Ok(BroadcastedState { args: self.args, diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index aeea4940a0bed..517eff552fd0a 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -284,7 +284,10 @@ impl ScriptArgs { // Check if there are any missing RPCs and exit early to avoid hard error. if pre_simulation.execution_artifacts.rpc_data.missing_rpc { - sh_println!("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; + if !shell::is_json() { + sh_println!("\nIf you wish to simulate on-chain transactions pass a RPC URL.")?; + } + return Ok(()); } @@ -298,7 +301,9 @@ impl ScriptArgs { // Exit early in case user didn't provide any broadcast/verify related flags. if !bundled.args.should_broadcast() { - sh_println!("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; + if !shell::is_json() { + sh_println!("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; + } return Ok(()); } diff --git a/crates/script/src/multi_sequence.rs b/crates/script/src/multi_sequence.rs index ec2f03ae9855b..e0fd4d1bc7e68 100644 --- a/crates/script/src/multi_sequence.rs +++ b/crates/script/src/multi_sequence.rs @@ -2,7 +2,7 @@ use eyre::{ContextCompat, Result, WrapErr}; use forge_script_sequence::{ now, sig_to_file_name, ScriptSequence, SensitiveScriptSequence, DRY_RUN_DIR, }; -use foundry_common::fs; +use foundry_common::{fs, shell}; use foundry_compilers::ArtifactId; use foundry_config::Config; use serde::{Deserialize, Serialize}; @@ -146,8 +146,19 @@ impl MultiChainSequence { } if !silent { - sh_println!("\nTransactions saved to: {}\n", self.path.display())?; - sh_println!("Sensitive details saved to: {}\n", self.sensitive_path.display())?; + if shell::is_json() { + sh_println!( + "{}", + serde_json::json!({ + "status": "success", + "transactions": self.path.display().to_string(), + "sensitive": self.sensitive_path.display().to_string(), + }) + )?; + } else { + sh_println!("\nTransactions saved to: {}\n", self.path.display())?; + sh_println!("Sensitive details saved to: {}\n", self.sensitive_path.display())?; + } } Ok(()) diff --git a/crates/script/src/progress.rs b/crates/script/src/progress.rs index d9fa53bb33566..bc23fcf677052 100644 --- a/crates/script/src/progress.rs +++ b/crates/script/src/progress.rs @@ -7,7 +7,7 @@ use alloy_primitives::{ use eyre::Result; use forge_script_sequence::ScriptSequence; use foundry_cli::utils::init_progress; -use foundry_common::provider::RetryProvider; +use foundry_common::{provider::RetryProvider, shell}; use futures::StreamExt; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use parking_lot::RwLock; @@ -31,33 +31,42 @@ pub struct SequenceProgressState { impl SequenceProgressState { pub fn new(sequence_idx: usize, sequence: &ScriptSequence, multi: MultiProgress) -> Self { - let mut template = "{spinner:.green}".to_string(); - write!(template, " Sequence #{} on {}", sequence_idx + 1, Chain::from(sequence.chain)) - .unwrap(); - template.push_str("{msg}"); - - let top_spinner = ProgressBar::new_spinner() - .with_style(ProgressStyle::with_template(&template).unwrap().tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈✅")); - let top_spinner = multi.add(top_spinner); - - let txs = multi.insert_after( - &top_spinner, - init_progress(sequence.transactions.len() as u64, "txes").with_prefix(" "), - ); - - let receipts = multi.insert_after( - &txs, - init_progress(sequence.transactions.len() as u64, "receipts").with_prefix(" "), - ); - - top_spinner.enable_steady_tick(Duration::from_millis(100)); - txs.enable_steady_tick(Duration::from_millis(1000)); - receipts.enable_steady_tick(Duration::from_millis(1000)); - - txs.set_position(sequence.receipts.len() as u64); - receipts.set_position(sequence.receipts.len() as u64); - - let mut state = Self { top_spinner, txs, receipts, tx_spinners: Default::default(), multi }; + let mut state = if shell::is_quiet() || shell::is_json() { + let top_spinner = ProgressBar::hidden(); + let txs = ProgressBar::hidden(); + let receipts = ProgressBar::hidden(); + + Self { top_spinner, txs, receipts, tx_spinners: Default::default(), multi } + } else { + let mut template = "{spinner:.green}".to_string(); + write!(template, " Sequence #{} on {}", sequence_idx + 1, Chain::from(sequence.chain)) + .unwrap(); + template.push_str("{msg}"); + + let top_spinner = ProgressBar::new_spinner().with_style( + ProgressStyle::with_template(&template).unwrap().tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈✅"), + ); + let top_spinner = multi.add(top_spinner); + + let txs = multi.insert_after( + &top_spinner, + init_progress(sequence.transactions.len() as u64, "txes").with_prefix(" "), + ); + + let receipts = multi.insert_after( + &txs, + init_progress(sequence.transactions.len() as u64, "receipts").with_prefix(" "), + ); + + top_spinner.enable_steady_tick(Duration::from_millis(100)); + txs.enable_steady_tick(Duration::from_millis(1000)); + receipts.enable_steady_tick(Duration::from_millis(1000)); + + txs.set_position(sequence.receipts.len() as u64); + receipts.set_position(sequence.receipts.len() as u64); + + Self { top_spinner, txs, receipts, tx_spinners: Default::default(), multi } + }; for tx_hash in sequence.pending.iter() { state.tx_sent(*tx_hash); @@ -71,16 +80,21 @@ impl SequenceProgressState { pub fn tx_sent(&mut self, tx_hash: B256) { // Avoid showing more than 10 spinners. if self.tx_spinners.len() < 10 { - let spinner = ProgressBar::new_spinner() - .with_style( - ProgressStyle::with_template(" {spinner:.green} {msg}") - .unwrap() - .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈"), - ) - .with_message(format!("{} {}", "[Pending]".yellow(), tx_hash)); - - let spinner = self.multi.insert_before(&self.txs, spinner); - spinner.enable_steady_tick(Duration::from_millis(100)); + let spinner = if shell::is_quiet() || shell::is_json() { + ProgressBar::hidden() + } else { + let spinner = ProgressBar::new_spinner() + .with_style( + ProgressStyle::with_template(" {spinner:.green} {msg}") + .unwrap() + .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈"), + ) + .with_message(format!("{} {}", "[Pending]".yellow(), tx_hash)); + + let spinner = self.multi.insert_before(&self.txs, spinner); + spinner.enable_steady_tick(Duration::from_millis(100)); + spinner + }; self.tx_spinners.insert(tx_hash, spinner); } @@ -98,7 +112,10 @@ impl SequenceProgressState { /// Same as finish_tx_spinner but also prints a message to stdout above all other progress bars. pub fn finish_tx_spinner_with_msg(&mut self, tx_hash: B256, msg: &str) -> std::io::Result<()> { self.finish_tx_spinner(tx_hash); - self.multi.println(msg)?; + + if !(shell::is_quiet() || shell::is_json()) { + self.multi.println(msg)?; + } Ok(()) } diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index c11fdd71a92cd..f073e38e607bc 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -3,7 +3,7 @@ use alloy_primitives::{utils::format_units, TxHash, U256}; use alloy_provider::{PendingTransactionBuilder, PendingTransactionError, Provider, WatchTxError}; use alloy_rpc_types::AnyTransactionReceipt; use eyre::Result; -use foundry_common::provider::RetryProvider; +use foundry_common::{provider::RetryProvider, shell}; use std::time::Duration; /// Convenience enum for internal signalling of transaction status @@ -71,31 +71,51 @@ pub async fn check_tx_status( pub fn format_receipt(chain: Chain, receipt: &AnyTransactionReceipt) -> String { let gas_used = receipt.gas_used; let gas_price = receipt.effective_gas_price; - format!( - "\n##### {chain}\n{status} Hash: {tx_hash:?}{caddr}\nBlock: {bn}\n{gas}\n\n", - status = if !receipt.inner.inner.inner.receipt.status.coerce_status() { - "❌ [Failed]" - } else { - "✅ [Success]" - }, - tx_hash = receipt.transaction_hash, - caddr = if let Some(addr) = &receipt.contract_address { - format!("\nContract Address: {}", addr.to_checksum(None)) - } else { - String::new() - }, - bn = receipt.block_number.unwrap_or_default(), - gas = if gas_price == 0 { - format!("Gas Used: {gas_used}") - } else { - let paid = format_units(gas_used.saturating_mul(gas_price), 18) - .unwrap_or_else(|_| "N/A".into()); - let gas_price = format_units(U256::from(gas_price), 9).unwrap_or_else(|_| "N/A".into()); - format!( - "Paid: {} ETH ({gas_used} gas * {} gwei)", - paid.trim_end_matches('0'), - gas_price.trim_end_matches('0').trim_end_matches('.') - ) - }, - ) + let block_number = receipt.block_number.unwrap_or_default(); + let success = receipt.inner.inner.inner.receipt.status.coerce_status(); + + if shell::is_json() { + let _ = sh_println!( + "{}", + serde_json::json!({ + "chain": chain, + "status": if success { + "success" + } else { + "failed" + }, + "tx_hash": receipt.transaction_hash, + "contract_address": receipt.contract_address.map(|addr| addr.to_string()), + "block_number": block_number, + "gas_used": gas_used, + "gas_price": gas_price, + }) + ); + + String::new() + } else { + format!( + "\n##### {chain}\n{status} Hash: {tx_hash:?}{contract_address}\nBlock: {block_number}\n{gas}\n\n", + status = if success { "✅ [Success]" } else { "❌ [Failed]" }, + tx_hash = receipt.transaction_hash, + contract_address = if let Some(addr) = &receipt.contract_address { + format!("\nContract Address: {}", addr.to_checksum(None)) + } else { + String::new() + }, + gas = if gas_price == 0 { + format!("Gas Used: {gas_used}") + } else { + let paid = format_units(gas_used.saturating_mul(gas_price), 18) + .unwrap_or_else(|_| "N/A".into()); + let gas_price = + format_units(U256::from(gas_price), 9).unwrap_or_else(|_| "N/A".into()); + format!( + "Paid: {} ETH ({gas_used} gas * {} gwei)", + paid.trim_end_matches('0'), + gas_price.trim_end_matches('0').trim_end_matches('.') + ) + }, + ) + } } diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 95427225f2026..e833073ac00ff 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -16,7 +16,7 @@ use eyre::{Context, Result}; use forge_script_sequence::{ScriptSequence, TransactionWithMetadata}; use foundry_cheatcodes::Wallets; use foundry_cli::utils::{has_different_gas_calc, now}; -use foundry_common::ContractData; +use foundry_common::{shell, ContractData}; use foundry_evm::traces::{decode_trace_arena, render_trace_arena}; use futures::future::{join_all, try_join_all}; use parking_lot::RwLock; @@ -151,7 +151,7 @@ impl PreSimulationState { }) .collect::>(); - if self.script_config.evm_opts.verbosity > 3 { + if !shell::is_json() && self.script_config.evm_opts.verbosity > 3 { sh_println!("==========================")?; sh_println!("Simulated On-chain Traces:\n")?; } @@ -220,9 +220,11 @@ impl PreSimulationState { async fn build_runners(&self) -> Result> { let rpcs = self.execution_artifacts.rpc_data.total_rpcs.clone(); - let n = rpcs.len(); - let s = if n != 1 { "s" } else { "" }; - sh_println!("\n## Setting up {n} EVM{s}.")?; + if !shell::is_json() { + let n = rpcs.len(); + let s = if n != 1 { "s" } else { "" }; + sh_println!("\n## Setting up {n} EVM{s}.")?; + } let futs = rpcs.into_iter().map(|rpc| async move { let mut script_config = self.script_config.clone(); @@ -348,24 +350,34 @@ impl FilledTransactionsState { provider_info.gas_price()? }; - sh_println!("\n==========================")?; - sh_println!("\nChain {}", provider_info.chain)?; - - sh_println!( - "\nEstimated gas price: {} gwei", - format_units(per_gas, 9) - .unwrap_or_else(|_| "[Could not calculate]".to_string()) - .trim_end_matches('0') - .trim_end_matches('.') - )?; - sh_println!("\nEstimated total gas used for script: {total_gas}")?; - sh_println!( - "\nEstimated amount required: {} ETH", - format_units(total_gas.saturating_mul(per_gas), 18) - .unwrap_or_else(|_| "[Could not calculate]".to_string()) - .trim_end_matches('0') - )?; - sh_println!("\n==========================")?; + let estimated_gas_price_raw = format_units(per_gas, 9) + .unwrap_or_else(|_| "[Could not calculate]".to_string()); + let estimated_gas_price = + estimated_gas_price_raw.trim_end_matches('0').trim_end_matches('.'); + + let estimated_amount_raw = format_units(total_gas.saturating_mul(per_gas), 18) + .unwrap_or_else(|_| "[Could not calculate]".to_string()); + let estimated_amount = estimated_amount_raw.trim_end_matches('0'); + + if !shell::is_json() { + sh_println!("\n==========================")?; + sh_println!("\nChain {}", provider_info.chain)?; + + sh_println!("\nEstimated gas price: {} gwei", estimated_gas_price)?; + sh_println!("\nEstimated total gas used for script: {total_gas}")?; + sh_println!("\nEstimated amount required: {estimated_amount} ETH",)?; + sh_println!("\n==========================")?; + } else { + sh_println!( + "{}", + serde_json::json!({ + "chain": provider_info.chain, + "estimated_gas_price": estimated_gas_price, + "estimated_total_gas_used": total_gas, + "estimated_amount_required": estimated_amount, + }) + )?; + } } } diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index ca90129d543bb..78f39fe96dccc 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -139,7 +139,6 @@ impl VerificationProvider for EtherscanVerificationProvider { retry: RETRY_CHECK_ON_VERIFY, verifier: args.verifier, }; - // return check_args.run().await return self.check(check_args).await } } else { From 31dd1f77fd9156d09836486d97963cec7f555343 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:33:30 +0200 Subject: [PATCH 1727/1963] feat(cast): add decode-event sig data (#9413) --- crates/cast/bin/args.rs | 21 +++++++++++++++------ crates/cast/bin/main.rs | 13 +++++++++---- crates/cast/tests/cli/main.rs | 8 ++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index f010c279e0d05..7078810e4ce91 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -512,8 +512,8 @@ pub enum CastSubcommand { /// /// Similar to `abi-decode --input`, but function selector MUST be prefixed in `calldata` /// string - #[command(visible_aliases = &["--calldata-decode", "cdd"])] - CalldataDecode { + #[command(visible_aliases = &["calldata-decode", "--calldata-decode", "cdd"])] + DecodeCalldata { /// The function signature in the format `()()`. sig: String, @@ -524,19 +524,28 @@ pub enum CastSubcommand { /// Decode ABI-encoded string. /// /// Similar to `calldata-decode --input`, but the function argument is a `string` - #[command(visible_aliases = &["--string-decode", "sd"])] - StringDecode { + #[command(visible_aliases = &["string-decode", "--string-decode", "sd"])] + DecodeString { /// The ABI-encoded string. data: String, }, + /// Decode event data. + #[command(visible_aliases = &["event-decode", "--event-decode", "ed"])] + DecodeEvent { + /// The event signature. + sig: String, + /// The event data to decode. + data: String, + }, + /// Decode ABI-encoded input or output data. /// /// Defaults to decoding output data. To decode input data pass --input. /// /// When passing `--input`, function selector must NOT be prefixed in `calldata` string - #[command(name = "abi-decode", visible_aliases = &["ad", "--abi-decode"])] - AbiDecode { + #[command(name = "decode-abi", visible_aliases = &["abi-decode", "--abi-decode", "ad"])] + DecodeAbi { /// The function signature in the format `()()`. sig: String, diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index ffce79099c9cb..21b1df36d6cdc 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate tracing; -use alloy_dyn_abi::DynSolValue; +use alloy_dyn_abi::{DynSolValue, EventExt}; use alloy_primitives::{eip191_hash_message, hex, keccak256, Address, B256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, BlockNumberOrTag::Latest}; @@ -189,7 +189,7 @@ async fn main_args(args: CastArgs) -> Result<()> { } // ABI encoding & decoding - CastSubcommand::AbiDecode { sig, calldata, input } => { + CastSubcommand::DecodeAbi { sig, calldata, input } => { let tokens = SimpleCast::abi_decode(&sig, &calldata, input)?; print_tokens(&tokens); } @@ -200,17 +200,22 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{}", SimpleCast::abi_encode_packed(&sig, &args)?)? } } - CastSubcommand::CalldataDecode { sig, calldata } => { + CastSubcommand::DecodeCalldata { sig, calldata } => { let tokens = SimpleCast::calldata_decode(&sig, &calldata, true)?; print_tokens(&tokens); } CastSubcommand::CalldataEncode { sig, args } => { sh_println!("{}", SimpleCast::calldata_encode(sig, &args)?)?; } - CastSubcommand::StringDecode { data } => { + CastSubcommand::DecodeString { data } => { let tokens = SimpleCast::calldata_decode("Any(string)", &data, true)?; print_tokens(&tokens); } + CastSubcommand::DecodeEvent { sig, data } => { + let event = get_event(sig.as_str())?; + let decoded_event = event.decode_log_parts(None, &hex::decode(data)?, false)?; + print_tokens(&decoded_event.body); + } CastSubcommand::Interface(cmd) => cmd.run().await?, CastSubcommand::CreationCode(cmd) => cmd.run().await?, CastSubcommand::ConstructorArgs(cmd) => cmd.run().await?, diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 332f0f99f57bd..92f23a4574359 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1474,6 +1474,14 @@ casttest!(string_decode, |_prj, cmd| { "#]]); }); +casttest!(event_decode, |_prj, cmd| { + cmd.args(["decode-event", "MyEvent(uint256,address)", "0x000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000d0004f"]).assert_success().stdout_eq(str![[r#" +78 +0x0000000000000000000000000000000000D0004F + +"#]]); +}); + casttest!(format_units, |_prj, cmd| { cmd.args(["format-units", "1000000", "6"]).assert_success().stdout_eq(str![[r#" 1 From 735b5ebdbbe8fe05c93af930c53e0fba6d3aa4f9 Mon Sep 17 00:00:00 2001 From: wangjingcun Date: Wed, 27 Nov 2024 17:06:47 +0800 Subject: [PATCH 1728/1963] chore: fix 404 status URL (#9417) Signed-off-by: wangjingcun --- crates/anvil/src/eth/otterscan/api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 617655444bef6..f9a7334e03765 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -46,7 +46,7 @@ pub fn mentions_address(trace: LocalizedTransactionTrace, address: Address) -> O /// Converts the list of traces for a transaction into the expected Otterscan format. /// -/// Follows format specified in the [`ots_traceTransaction`](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_tracetransaction) spec. +/// Follows format specified in the [`ots_traceTransaction`](https://github.com/otterscan/otterscan/blob/main/docs/custom-jsonrpc.md#ots_tracetransaction) spec. pub fn batch_build_ots_traces(traces: Vec) -> Vec { traces .into_iter() @@ -350,7 +350,7 @@ impl EthApi { /// their `gas_used`. This would be extremely inefficient in a real blockchain RPC, but we can /// get away with that in this context. /// - /// The [original spec](https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails) + /// The [original spec](https://github.com/otterscan/otterscan/blob/main/docs/custom-jsonrpc.md#ots_getblockdetails) /// also mentions we can hardcode `transactions` and `logsBloom` to an empty array to save /// bandwidth, because fields weren't intended to be used in the Otterscan UI at this point. /// @@ -402,7 +402,7 @@ impl EthApi { /// Fetches all receipts for the blocks's transactions, as required by the /// [`ots_getBlockTransactions`] endpoint spec, and returns the final response object. /// - /// [`ots_getBlockTransactions`]: https://github.com/otterscan/otterscan/blob/develop/docs/custom-jsonrpc.md#ots_getblockdetails + /// [`ots_getBlockTransactions`]: https://github.com/otterscan/otterscan/blob/main/docs/custom-jsonrpc.md#ots_getblockdetails pub async fn build_ots_block_tx( &self, mut block: AnyRpcBlock, From 2c3114c4d9cbe66a897e634b11b8771a56f91bec Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:06:26 +0100 Subject: [PATCH 1729/1963] feat: add `--broadcast` flag to forge create, default to dry run mode (#9420) * add --broadcast flag to forge create, default to dry run * nits * fix tests * add dry run tests incl --json * minor fixes, failing test due to minor bytecode difference --- crates/forge/bin/cmd/create.rs | 37 ++++++++- crates/forge/tests/cli/create.rs | 129 +++++++++++++++++++++++++++++-- 2 files changed, 160 insertions(+), 6 deletions(-) diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 71823416d7131..6c2fbb0cfeccb 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -61,6 +61,10 @@ pub struct CreateArgs { )] constructor_args_path: Option, + /// Broadcast the transaction. + #[arg(long)] + pub broadcast: bool, + /// Verify contract after creation. #[arg(long)] verify: bool, @@ -155,6 +159,10 @@ impl CreateArgs { } else { provider.get_chain_id().await? }; + + // Whether to broadcast the transaction or not + let dry_run = !self.broadcast; + if self.unlocked { // Deploy with unlocked account let sender = self.eth.wallet.from.expect("required"); @@ -167,6 +175,7 @@ impl CreateArgs { sender, config.transaction_timeout, id, + dry_run, ) .await } else { @@ -185,6 +194,7 @@ impl CreateArgs { deployer, config.transaction_timeout, id, + dry_run, ) .await } @@ -260,6 +270,7 @@ impl CreateArgs { deployer_address: Address, timeout: u64, id: ArtifactId, + dry_run: bool, ) -> Result<()> { let bin = bin.into_bytes().unwrap_or_else(|| { panic!("no bytecode found in bin object for {}", self.contract.name) @@ -339,6 +350,30 @@ impl CreateArgs { self.verify_preflight_check(constructor_args.clone(), chain, &id).await?; } + if dry_run { + if !shell::is_json() { + sh_warn!("Dry run enabled, not broadcasting transaction\n")?; + + sh_println!("Contract: {}", self.contract.name)?; + sh_println!( + "Transaction: {}", + serde_json::to_string_pretty(&deployer.tx.clone())? + )?; + sh_println!("ABI: {}\n", serde_json::to_string_pretty(&abi)?)?; + + sh_warn!("To broadcast this transaction, add --broadcast to the previous command. See forge create --help for more.")?; + } else { + let output = json!({ + "contract": self.contract.name, + "transaction": &deployer.tx, + "abi":&abi + }); + sh_println!("{}", serde_json::to_string_pretty(&output)?)?; + } + + return Ok(()); + } + // Deploy the actual contract let (deployed_contract, receipt) = deployer.send_with_receipt().await?; @@ -349,7 +384,7 @@ impl CreateArgs { "deployedTo": address.to_string(), "transactionHash": receipt.transaction_hash }); - sh_println!("{output}")?; + sh_println!("{}", serde_json::to_string_pretty(&output)?)?; } else { sh_println!("Deployer: {deployer_address}")?; sh_println!("Deployed to: {address}")?; diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index ebf8c81dbcc1e..6a78f83231ef9 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -9,7 +9,9 @@ use anvil::{spawn, NodeConfig}; use foundry_compilers::artifacts::{remappings::Remapping, BytecodeHash}; use foundry_config::Config; use foundry_test_utils::{ - forgetest, forgetest_async, str, + forgetest, forgetest_async, + snapbox::IntoData, + str, util::{OutputExt, TestCommand, TestProject}, }; use std::str::FromStr; @@ -145,6 +147,7 @@ forgetest_async!(can_create_template_contract, |prj, cmd| { let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; prj.write_config(config); + // Dry-run without the `--broadcast` flag cmd.forge_fuse().args([ "create", format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), @@ -154,20 +157,131 @@ forgetest_async!(can_create_template_contract, |prj, cmd| { pk.as_str(), ]); + // Dry-run cmd.assert().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! -Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 -[TX_HASH] +Contract: Counter +Transaction: { + "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", + "to": null, + "maxFeePerGas": "0x77359401", + "maxPriorityFeePerGas": "0x1", + "gas": "0x17575", + "input": "[..]", + "nonce": "0x0", + "chainId": "0x7a69" +} +ABI: [ + { + "type": "function", + "name": "increment", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "number", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setNumber", + "inputs": [ + { + "name": "newNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } +] + "#]]); + // Dry-run with `--json` flag + cmd.arg("--json").assert().stdout_eq( + str![[r#" +{ + "contract": "Counter", + "transaction": { + "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", + "to": null, + "maxFeePerGas": "0x77359401", + "maxPriorityFeePerGas": "0x1", + "gas": "0x17575", + "input": "[..]", + "nonce": "0x0", + "chainId": "0x7a69" + }, + "abi": [ + { + "type": "function", + "name": "increment", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "number", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setNumber", + "inputs": [ + { + "name": "newNumber", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } + ] +} + +"#]] + .is_json(), + ); + + cmd.forge_fuse().args([ + "create", + format!("./src/{TEMPLATE_CONTRACT}.sol:{TEMPLATE_CONTRACT}").as_str(), + "--rpc-url", + rpc.as_str(), + "--private-key", + pk.as_str(), + "--broadcast", + ]); + cmd.assert().stdout_eq(str![[r#" No files changed, compilation skipped Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -Deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 +Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 [TX_HASH] "#]]); @@ -193,6 +307,7 @@ forgetest_async!(can_create_using_unlocked, |prj, cmd| { "--from", format!("{dev:?}").as_str(), "--unlocked", + "--broadcast", ]); cmd.assert().stdout_eq(str![[r#" @@ -204,6 +319,7 @@ Deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 [TX_HASH] "#]]); + cmd.assert().stdout_eq(str![[r#" No files changed, compilation skipped Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 @@ -248,6 +364,7 @@ contract ConstructorContract { rpc.as_str(), "--private-key", pk.as_str(), + "--broadcast", "--constructor-args", "My Constructor", ]) @@ -285,6 +402,7 @@ contract TupleArrayConstructorContract { rpc.as_str(), "--private-key", pk.as_str(), + "--broadcast", "--constructor-args", "[(1,2), (2,3), (3,4)]", ]) @@ -335,6 +453,7 @@ contract UniswapV2Swap { rpc.as_str(), "--private-key", pk.as_str(), + "--broadcast", ]) .assert_success() .stdout_eq(str![[r#" From c63aba816b76f9bad103b1275cc662a063919403 Mon Sep 17 00:00:00 2001 From: cl Date: Thu, 28 Nov 2024 03:36:30 +0800 Subject: [PATCH 1730/1963] feat(`traces`): show state changes in `cast run` and `forge test` on `-vvvvv` (#9013) * Add options for state changes output and json output in cast run command * fix test * add back serde_json in Cargo.lock * format using nightly * rename parameter * update revm-inspectors * supress clippy warning and merge master * add serde_json * disable some stdout print when --json option is used * remove unnecessary check * replace with sh_println * replace with shell::is_json * Show storage for verbosity > 1, add test * Change verbosity to > 4 for both cast and forge test, add test, fix ci --------- Co-authored-by: grandizzy --- Cargo.lock | 1 + crates/cast/bin/cmd/call.rs | 13 ++++-- crates/cast/bin/cmd/run.rs | 7 ++- crates/cast/tests/cli/main.rs | 65 ++++++++++++++++++++++++++- crates/cli/src/opts/global.rs | 2 +- crates/cli/src/utils/cmd.rs | 21 ++++++--- crates/evm/evm/src/executors/trace.rs | 9 ++-- crates/evm/traces/Cargo.toml | 1 + crates/evm/traces/src/lib.rs | 37 ++++++++++++--- crates/forge/bin/cmd/test/mod.rs | 8 ++-- crates/forge/src/multi_runner.rs | 5 ++- crates/forge/tests/cli/cmd.rs | 2 +- crates/forge/tests/cli/test_cmd.rs | 34 ++++++++++++++ crates/verify/src/utils.rs | 1 + 14 files changed, 176 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e6cdd0f96c62..d94d710ac07f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4086,6 +4086,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", + "serde_json", "solar-parse", "tempfile", "tokio", diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index cdc3bd4bc6e2f..2d5692efe4c1a 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -8,7 +8,7 @@ use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils::{self, handle_traces, parse_ether_value, TraceResult}, }; -use foundry_common::ens::NameOrAddress; +use foundry_common::{ens::NameOrAddress, shell}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{ figment::{ @@ -182,8 +182,15 @@ impl CallArgs { env.cfg.disable_block_gas_limit = true; env.block.gas_limit = U256::MAX; - let mut executor = - TracingExecutor::new(env, fork, evm_version, debug, decode_internal, alphanet); + let mut executor = TracingExecutor::new( + env, + fork, + evm_version, + debug, + decode_internal, + shell::verbosity() > 4, + alphanet, + ); let value = tx.value.unwrap_or_default(); let input = tx.inner.input.into_input().unwrap_or_default(); diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 0b85d14feb987..cfad7263a1e4e 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -10,7 +10,7 @@ use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, utils::{handle_traces, init_progress, TraceResult}, }; -use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{ figment::{ @@ -169,6 +169,7 @@ impl RunArgs { evm_version, self.debug, self.decode_internal, + shell::verbosity() > 4, alphanet, ); let mut env = @@ -176,7 +177,9 @@ impl RunArgs { // Set the state to the moment right before the transaction if !self.quick { - sh_println!("Executing previous transactions from the block.")?; + if !shell::is_json() { + sh_println!("Executing previous transactions from the block.")?; + } if let Some(block) = block { let pb = init_progress(block.transactions.len() as u64, "tx"); diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 92f23a4574359..aa70fef92db68 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -64,7 +64,7 @@ Display options: - 2 (-vv): Print logs for all tests. - 3 (-vvv): Print execution traces for failing tests. - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. - - 5 (-vvvvv): Print execution and setup traces for all tests. + - 5 (-vvvvv): Print execution and setup traces for all tests, including storage changes. Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html @@ -1713,3 +1713,66 @@ Transaction successfully executed. "#]]); }); + +// tests cast can decode traces when running with verbosity level > 4 +forgetest_async!(show_state_changes_in_traces, |prj, cmd| { + let (api, handle) = anvil::spawn(NodeConfig::test()).await; + + foundry_test_utils::util::initialize(prj.root()); + // Deploy counter contract. + cmd.args([ + "script", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + "--broadcast", + "CounterScript", + ]) + .assert_success(); + + // Send tx to change counter storage value. + cmd.cast_fuse() + .args([ + "send", + "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "setNumber(uint256)", + "111", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + ]) + .assert_success(); + + let tx_hash = api + .transaction_by_block_number_and_index(BlockNumberOrTag::Latest, Index::from(0)) + .await + .unwrap() + .unwrap() + .tx_hash(); + + // Assert cast with verbosity displays storage changes. + cmd.cast_fuse() + .args([ + "run", + format!("{tx_hash}").as_str(), + "-vvvvv", + "--rpc-url", + &handle.http_endpoint(), + ]) + .assert_success() + .stdout_eq(str![[r#" +Executing previous transactions from the block. +Traces: + [22287] 0x5FbDB2315678afecb367f032d93F642f64180aa3::setNumber(111) + ├─ storage changes: + │ @ 0: 0 → 111 + └─ ← [Stop] + + +Transaction successfully executed. +[GAS] + +"#]]); +}); diff --git a/crates/cli/src/opts/global.rs b/crates/cli/src/opts/global.rs index ad715f24180a1..c820ca2cff7e7 100644 --- a/crates/cli/src/opts/global.rs +++ b/crates/cli/src/opts/global.rs @@ -15,7 +15,7 @@ pub struct GlobalOpts { /// - 2 (-vv): Print logs for all tests. /// - 3 (-vvv): Print execution traces for failing tests. /// - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. - /// - 5 (-vvvvv): Print execution and setup traces for all tests. + /// - 5 (-vvvvv): Print execution and setup traces for all tests, including storage changes. #[arg(help_heading = "Display options", global = true, short, long, verbatim_doc_comment, conflicts_with = "quiet", action = ArgAction::Count)] verbosity: Verbosity, diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 523c10478fb64..505634996de8f 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -17,8 +17,7 @@ use foundry_evm::{ debug::{ContractSources, DebugTraceIdentifier}, decode_trace_arena, identifier::{CachedSignatures, SignaturesIdentifier, TraceIdentifiers}, - render_trace_arena_with_bytecodes, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, - Traces, + render_trace_arena_inner, CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, }, }; use std::{ @@ -450,7 +449,7 @@ pub async fn handle_traces( decoder.debug_identifier = Some(DebugTraceIdentifier::new(sources)); } - print_traces(&mut result, &decoder, shell::verbosity() > 0).await?; + print_traces(&mut result, &decoder, shell::verbosity() > 0, shell::verbosity() > 4).await?; Ok(()) } @@ -459,23 +458,31 @@ pub async fn print_traces( result: &mut TraceResult, decoder: &CallTraceDecoder, verbose: bool, + state_changes: bool, ) -> Result<()> { let traces = result.traces.as_mut().expect("No traces found"); - sh_println!("Traces:")?; + if !shell::is_json() { + sh_println!("Traces:")?; + } + for (_, arena) in traces { decode_trace_arena(arena, decoder).await?; - sh_println!("{}", render_trace_arena_with_bytecodes(arena, verbose))?; + sh_println!("{}", render_trace_arena_inner(arena, verbose, state_changes))?; + } + + if shell::is_json() { + return Ok(()); } - sh_println!()?; + sh_println!()?; if result.success { sh_println!("{}", "Transaction successfully executed.".green())?; } else { sh_err!("Transaction failed.")?; } - sh_println!("Gas used: {}", result.gas_used)?; + Ok(()) } diff --git a/crates/evm/evm/src/executors/trace.rs b/crates/evm/evm/src/executors/trace.rs index 69c68442b65cd..ceea6e67248a4 100644 --- a/crates/evm/evm/src/executors/trace.rs +++ b/crates/evm/evm/src/executors/trace.rs @@ -18,15 +18,18 @@ impl TracingExecutor { version: Option, debug: bool, decode_internal: bool, + with_state_changes: bool, alphanet: bool, ) -> Self { let db = Backend::spawn(fork); - let trace_mode = - TraceMode::Call.with_debug(debug).with_decode_internal(if decode_internal { + let trace_mode = TraceMode::Call + .with_debug(debug) + .with_decode_internal(if decode_internal { InternalTraceMode::Full } else { InternalTraceMode::None - }); + }) + .with_state_changes(with_state_changes); Self { // configures a bare version of the evm executor: no cheatcode inspector is enabled, // tracing will be enabled only for the targeted transaction diff --git a/crates/evm/traces/Cargo.toml b/crates/evm/traces/Cargo.toml index 53bf8b3bb2cb7..f555d619fa228 100644 --- a/crates/evm/traces/Cargo.toml +++ b/crates/evm/traces/Cargo.toml @@ -36,6 +36,7 @@ eyre.workspace = true futures.workspace = true itertools.workspace = true serde.workspace = true +serde_json.workspace = true tokio = { workspace = true, features = ["time", "macros"] } tracing.workspace = true tempfile.workspace = true diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index 18136c481e7c9..a0fa7e1fca498 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -11,7 +11,10 @@ extern crate foundry_common; #[macro_use] extern crate tracing; -use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; +use foundry_common::{ + contracts::{ContractsByAddress, ContractsByArtifact}, + shell, +}; use revm::interpreter::OpCode; use revm_inspectors::tracing::{ types::{DecodedTraceStep, TraceMemberOrder}, @@ -183,15 +186,23 @@ pub async fn decode_trace_arena( /// Render a collection of call traces to a string. pub fn render_trace_arena(arena: &SparsedTraceArena) -> String { - render_trace_arena_with_bytecodes(arena, false) + render_trace_arena_inner(arena, false, false) } -/// Render a collection of call traces to a string optionally including contract creation bytecodes. -pub fn render_trace_arena_with_bytecodes( +/// Render a collection of call traces to a string optionally including contract creation bytecodes +/// and in JSON format. +pub fn render_trace_arena_inner( arena: &SparsedTraceArena, with_bytecodes: bool, + with_storage_changes: bool, ) -> String { - let mut w = TraceWriter::new(Vec::::new()).write_bytecodes(with_bytecodes); + if shell::is_json() { + return serde_json::to_string(&arena.resolve_arena()).expect("Failed to write traces"); + } + + let mut w = TraceWriter::new(Vec::::new()) + .write_bytecodes(with_bytecodes) + .with_storage_changes(with_storage_changes); w.write_arena(&arena.resolve_arena()).expect("Failed to write traces"); String::from_utf8(w.into_writer()).expect("trace writer wrote invalid UTF-8") } @@ -289,6 +300,8 @@ pub enum TraceMode { /// /// Used by debugger. Debug, + /// Debug trace with storage changes. + RecordStateDiff, } impl TraceMode { @@ -308,6 +321,10 @@ impl TraceMode { matches!(self, Self::Jump) } + pub const fn record_state_diff(self) -> bool { + matches!(self, Self::RecordStateDiff) + } + pub const fn is_debug(self) -> bool { matches!(self, Self::Debug) } @@ -324,6 +341,14 @@ impl TraceMode { std::cmp::max(self, mode.into()) } + pub fn with_state_changes(self, yes: bool) -> Self { + if yes { + std::cmp::max(self, Self::RecordStateDiff) + } else { + self + } + } + pub fn with_verbosity(self, verbosiy: u8) -> Self { if verbosiy >= 3 { std::cmp::max(self, Self::Call) @@ -345,7 +370,7 @@ impl TraceMode { StackSnapshotType::None }, record_logs: true, - record_state_diff: false, + record_state_diff: self.record_state_diff(), record_returndata_snapshots: self.is_debug(), record_opcodes_filter: (self.is_jump() || self.is_jump_simple()) .then(|| OpcodeFilter::new().enabled(OpCode::JUMP).enabled(OpCode::JUMPDEST)), diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 1a409b33a822f..ad2e52df6725d 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -12,7 +12,7 @@ use forge::{ debug::{ContractSources, DebugTraceIdentifier}, decode_trace_arena, folded_stack_trace, identifier::SignaturesIdentifier, - render_trace_arena, CallTraceDecoderBuilder, InternalTraceMode, TraceKind, + CallTraceDecoderBuilder, InternalTraceMode, TraceKind, }, MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, TestOptionsBuilder, }; @@ -56,7 +56,7 @@ use summary::TestSummaryReporter; use crate::cmd::test::summary::print_invariant_metrics; pub use filter::FilterArgs; -use forge::result::TestKind; +use forge::{result::TestKind, traces::render_trace_arena_inner}; // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); @@ -652,7 +652,7 @@ impl TestArgs { // - 0..3: nothing // - 3: only display traces for failed tests // - 4: also display the setup trace for failed tests - // - 5..: display all traces for all tests + // - 5..: display all traces for all tests, including storage changes let should_include = match kind { TraceKind::Execution => { (verbosity == 3 && result.status.is_failure()) || verbosity >= 4 @@ -665,7 +665,7 @@ impl TestArgs { if should_include { decode_trace_arena(arena, &decoder).await?; - decoded_traces.push(render_trace_arena(arena)); + decoded_traces.push(render_trace_arena_inner(arena, false, verbosity > 4)); } } diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index a9f2a93eb37a6..dfb498c060e66 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -7,7 +7,7 @@ use crate::{ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; -use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; +use foundry_common::{get_contract_name, shell::verbosity, ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{ artifacts::Libraries, compilers::Compiler, Artifact, ArtifactId, ProjectCompileOutput, }; @@ -249,7 +249,8 @@ impl MultiContractRunner { let trace_mode = TraceMode::default() .with_debug(self.debug) .with_decode_internal(self.decode_internal) - .with_verbosity(self.evm_opts.verbosity); + .with_verbosity(self.evm_opts.verbosity) + .with_state_changes(verbosity() > 4); let executor = ExecutorBuilder::new() .inspectors(|stack| { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index e0000e01bee02..35f5c2314c16e 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -67,7 +67,7 @@ Display options: - 2 (-vv): Print logs for all tests. - 3 (-vvv): Print execution traces for failing tests. - 4 (-vvvv): Print execution traces for all tests, and setup traces for failing tests. - - 5 (-vvvvv): Print execution and setup traces for all tests. + - 5 (-vvvvv): Print execution and setup traces for all tests, including storage changes. Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 8e064c63c9fdd..819c3e9407e0b 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2665,3 +2665,37 @@ Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] "#]]); }); + +// Tests that test traces display state changes when running with verbosity. +forgetest_init!(should_show_state_changes, |prj, cmd| { + cmd.args(["test", "--mt", "test_Increment", "-vvvvv"]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for test/Counter.t.sol:CounterTest +[PASS] test_Increment() ([GAS]) +Traces: + [87464] CounterTest::setUp() + ├─ [47297] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 236 bytes of code + ├─ [2387] Counter::setNumber(0) + │ └─ ← [Stop] + └─ ← [Stop] + + [31293] CounterTest::test_Increment() + ├─ [22337] Counter::increment() + │ ├─ storage changes: + │ │ @ 0: 0 → 1 + │ └─ ← [Stop] + ├─ [281] Counter::number() [staticcall] + │ └─ ← [Return] 1 + ├─ [0] VM::assertEq(1, 1) [staticcall] + │ └─ ← [Return] + ├─ storage changes: + │ @ 0: 0 → 1 + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); +}); diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index a14d6af6df964..56ec035abcead 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -334,6 +334,7 @@ pub async fn get_tracing_executor( Some(fork_config.evm_version), false, false, + false, is_alphanet, ); From 16a013fafb519395dc1aca810dabc3fffb7d02a0 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 28 Nov 2024 08:35:24 +0200 Subject: [PATCH 1731/1963] feat(cast): decode external lib sigs from cached selectors (#9399) --- crates/cast/tests/cli/main.rs | 91 ++++++++++++++++++++++++++++ crates/cli/src/utils/cmd.rs | 9 +++ crates/evm/traces/src/decoder/mod.rs | 7 ++- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index aa70fef92db68..d2c70a779e65a 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1776,3 +1776,94 @@ Transaction successfully executed. "#]]); }); + +// tests cast can decode external libraries traces with project cached selectors +forgetest_async!(decode_external_libraries_with_cached_selectors, |prj, cmd| { + let (api, handle) = anvil::spawn(NodeConfig::test()).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_source( + "ExternalLib", + r#" +import "./CounterInExternalLib.sol"; +library ExternalLib { + function updateCounterInExternalLib(CounterInExternalLib.Info storage counterInfo, uint256 counter) public { + counterInfo.counter = counter + 1; + } +} + "#, + ) + .unwrap(); + prj.add_source( + "CounterInExternalLib", + r#" +import "./ExternalLib.sol"; +contract CounterInExternalLib { + struct Info { + uint256 counter; + } + Info info; + constructor() { + ExternalLib.updateCounterInExternalLib(info, 100); + } +} + "#, + ) + .unwrap(); + prj.add_script( + "CounterInExternalLibScript", + r#" +import "forge-std/Script.sol"; +import {CounterInExternalLib} from "../src/CounterInExternalLib.sol"; +contract CounterInExternalLibScript is Script { + function run() public { + vm.startBroadcast(); + new CounterInExternalLib(); + vm.stopBroadcast(); + } +} + "#, + ) + .unwrap(); + + cmd.args([ + "script", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + "--broadcast", + "CounterInExternalLibScript", + ]) + .assert_success(); + + let tx_hash = api + .transaction_by_block_number_and_index(BlockNumberOrTag::Latest, Index::from(0)) + .await + .unwrap() + .unwrap() + .tx_hash(); + + // Cache project selectors. + cmd.forge_fuse().set_current_dir(prj.root()); + cmd.forge_fuse().args(["selectors", "cache"]).assert_success(); + + // Assert cast with local artifacts can decode external lib signature. + cmd.cast_fuse().set_current_dir(prj.root()); + cmd.cast_fuse() + .args(["run", format!("{tx_hash}").as_str(), "--rpc-url", &handle.http_endpoint()]) + .assert_success() + .stdout_eq(str![[r#" +... +Traces: + [37739] → new @0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 + ├─ [22411] 0xfAb06527117d29EA121998AC4fAB9Fc88bF5f979::updateCounterInExternalLib(0, 100) [delegatecall] + │ └─ ← [Stop] + └─ ← [Return] 62 bytes of code + + +Transaction successfully executed. +[GAS] + +"#]]); +}); diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 505634996de8f..67aa65073ff88 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -501,6 +501,15 @@ pub fn cache_local_signatures(output: &ProjectCompileOutput, cache_path: PathBuf .events .insert(event.selector().to_string(), event.full_signature()); } + // External libraries doesn't have functions included in abi, but `methodIdentifiers`. + if let Some(method_identifiers) = &artifact.method_identifiers { + method_identifiers.iter().for_each(|(signature, selector)| { + cached_signatures + .functions + .entry(format!("0x{selector}")) + .or_insert(signature.to_string()); + }); + } } }); diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index b63c7f1d7209b..68ecbac29c7eb 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -689,10 +689,13 @@ fn reconstruct_params(event: &Event, decoded: &DecodedEvent) -> Vec let mut unindexed = 0; let mut inputs = vec![]; for input in event.inputs.iter() { - if input.indexed { + // Prevent panic of event `Transfer(from, to)` decoded with a signature + // `Transfer(address indexed from, address indexed to, uint256 indexed tokenId)` by making + // sure the event inputs is not higher than decoded indexed / un-indexed values. + if input.indexed && indexed < decoded.indexed.len() { inputs.push(decoded.indexed[indexed].clone()); indexed += 1; - } else { + } else if unindexed < decoded.body.len() { inputs.push(decoded.body[unindexed].clone()); unindexed += 1; } From 56d0dd8745248e9cd029472eb0a8697d12677246 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:59:27 +0100 Subject: [PATCH 1732/1963] feat: rewrite inline config using figment (#9414) * feat: rewrite inline config using figment * wip * wip * fix: use same GasLimit type * wip * fixes * tests * test fixes * fmt * test update --- Cargo.lock | 1 + crates/config/Cargo.toml | 5 +- crates/config/src/fuzz.rs | 108 +--------- crates/config/src/inline/conf_parser.rs | 169 --------------- crates/config/src/inline/error.rs | 44 ---- crates/config/src/inline/mod.rs | 185 +++++++++++++---- crates/config/src/inline/natspec.rs | 146 +++++++------ crates/config/src/invariant.rs | 93 +-------- crates/config/src/lib.rs | 194 ++++++++++++++---- crates/config/src/providers/mod.rs | 17 +- crates/config/src/providers/remappings.rs | 2 +- crates/config/src/utils.rs | 78 ------- crates/evm/core/src/opts.rs | 50 +---- crates/forge/bin/cmd/coverage.rs | 6 +- crates/forge/bin/cmd/test/mod.rs | 20 +- crates/forge/src/lib.rs | 239 +++++++--------------- crates/forge/src/runner.rs | 34 +-- crates/forge/tests/cli/alphanet.rs | 15 +- crates/forge/tests/cli/build.rs | 15 +- crates/forge/tests/cli/config.rs | 2 + crates/forge/tests/cli/inline_config.rs | 194 ++++++++++++++++++ crates/forge/tests/cli/main.rs | 1 + crates/forge/tests/it/cheats.rs | 18 +- crates/forge/tests/it/core.rs | 12 +- crates/forge/tests/it/fork.rs | 42 ++-- crates/forge/tests/it/fs.rs | 12 +- crates/forge/tests/it/fuzz.rs | 33 +-- crates/forge/tests/it/inline.rs | 36 +--- crates/forge/tests/it/invariant.rs | 131 +++++++----- crates/forge/tests/it/repros.rs | 38 ++-- crates/forge/tests/it/test_helpers.rs | 190 ++++++++--------- crates/test-utils/src/filter.rs | 1 + 32 files changed, 969 insertions(+), 1162 deletions(-) delete mode 100644 crates/config/src/inline/conf_parser.rs delete mode 100644 crates/config/src/inline/error.rs create mode 100644 crates/forge/tests/cli/inline_config.rs diff --git a/Cargo.lock b/Cargo.lock index d94d710ac07f4..09fab74b7f0db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3910,6 +3910,7 @@ dependencies = [ "foundry-compilers", "glob", "globset", + "itertools 0.13.0", "mesc", "number_prefix", "path-slash", diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 3e6815d784e68..ba01a1afbf4ca 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -27,11 +27,12 @@ dirs-next = "2" dunce.workspace = true eyre.workspace = true figment = { workspace = true, features = ["toml", "env"] } -globset = "0.4" glob = "0.3" +globset = "0.4" Inflector = "0.11" -number_prefix = "0.4" +itertools.workspace = true mesc.workspace = true +number_prefix = "0.4" regex.workspace = true reqwest.workspace = true semver = { workspace = true, features = ["serde"] } diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index fb04383228a9f..ae3d3c7967013 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -1,9 +1,5 @@ //! Configuration for fuzz testing. -use crate::inline::{ - parse_config_bool, parse_config_u32, InlineConfigParser, InlineConfigParserError, - INLINE_CONFIG_FUZZ_KEY, -}; use alloy_primitives::U256; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -53,50 +49,13 @@ impl FuzzConfig { /// Creates fuzz configuration to write failures in `{PROJECT_ROOT}/cache/fuzz` dir. pub fn new(cache_dir: PathBuf) -> Self { Self { - runs: 256, - max_test_rejects: 65536, - seed: None, - dictionary: FuzzDictionaryConfig::default(), - gas_report_samples: 256, failure_persist_dir: Some(cache_dir), failure_persist_file: Some("failures".to_string()), - show_logs: false, + ..Default::default() } } } -impl InlineConfigParser for FuzzConfig { - fn config_key() -> String { - INLINE_CONFIG_FUZZ_KEY.into() - } - - fn try_merge(&self, configs: &[String]) -> Result, InlineConfigParserError> { - let overrides: Vec<(String, String)> = Self::get_config_overrides(configs); - - if overrides.is_empty() { - return Ok(None) - } - - let mut conf_clone = self.clone(); - - for pair in overrides { - let key = pair.0; - let value = pair.1; - match key.as_str() { - "runs" => conf_clone.runs = parse_config_u32(key, value)?, - "max-test-rejects" => conf_clone.max_test_rejects = parse_config_u32(key, value)?, - "dictionary-weight" => { - conf_clone.dictionary.dictionary_weight = parse_config_u32(key, value)? - } - "failure-persist-file" => conf_clone.failure_persist_file = Some(value), - "show-logs" => conf_clone.show_logs = parse_config_bool(key, value)?, - _ => Err(InlineConfigParserError::InvalidConfigProperty(key))?, - } - } - Ok(Some(conf_clone)) - } -} - /// Contains for fuzz testing #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct FuzzDictionaryConfig { @@ -132,68 +91,3 @@ impl Default for FuzzDictionaryConfig { } } } - -#[cfg(test)] -mod tests { - use crate::{inline::InlineConfigParser, FuzzConfig}; - - #[test] - fn unrecognized_property() { - let configs = &["forge-config: default.fuzz.unknownprop = 200".to_string()]; - let base_config = FuzzConfig::default(); - if let Err(e) = base_config.try_merge(configs) { - assert_eq!(e.to_string(), "'unknownprop' is an invalid config property"); - } else { - unreachable!() - } - } - - #[test] - fn successful_merge() { - let configs = &[ - "forge-config: default.fuzz.runs = 42424242".to_string(), - "forge-config: default.fuzz.dictionary-weight = 42".to_string(), - "forge-config: default.fuzz.failure-persist-file = fuzz-failure".to_string(), - ]; - let base_config = FuzzConfig::default(); - let merged: FuzzConfig = base_config.try_merge(configs).expect("No errors").unwrap(); - assert_eq!(merged.runs, 42424242); - assert_eq!(merged.dictionary.dictionary_weight, 42); - assert_eq!(merged.failure_persist_file, Some("fuzz-failure".to_string())); - } - - #[test] - fn merge_is_none() { - let empty_config = &[]; - let base_config = FuzzConfig::default(); - let merged = base_config.try_merge(empty_config).expect("No errors"); - assert!(merged.is_none()); - } - - #[test] - fn merge_is_none_unrelated_property() { - let unrelated_configs = &["forge-config: default.invariant.runs = 2".to_string()]; - let base_config = FuzzConfig::default(); - let merged = base_config.try_merge(unrelated_configs).expect("No errors"); - assert!(merged.is_none()); - } - - #[test] - fn override_detection() { - let configs = &[ - "forge-config: default.fuzz.runs = 42424242".to_string(), - "forge-config: ci.fuzz.runs = 666666".to_string(), - "forge-config: default.invariant.runs = 2".to_string(), - "forge-config: default.fuzz.dictionary-weight = 42".to_string(), - ]; - let variables = FuzzConfig::get_config_overrides(configs); - assert_eq!( - variables, - vec![ - ("runs".into(), "42424242".into()), - ("runs".into(), "666666".into()), - ("dictionary-weight".into(), "42".into()) - ] - ); - } -} diff --git a/crates/config/src/inline/conf_parser.rs b/crates/config/src/inline/conf_parser.rs deleted file mode 100644 index e6944965499d8..0000000000000 --- a/crates/config/src/inline/conf_parser.rs +++ /dev/null @@ -1,169 +0,0 @@ -use super::{remove_whitespaces, InlineConfigParserError}; -use crate::{inline::INLINE_CONFIG_PREFIX, InlineConfigError, NatSpec}; -use regex::Regex; - -/// This trait is intended to parse configurations from -/// structured text. Foundry users can annotate Solidity test functions, -/// providing special configs just for the execution of a specific test. -/// -/// An example: -/// -/// ```solidity -/// contract MyTest is Test { -/// /// forge-config: default.fuzz.runs = 100 -/// /// forge-config: ci.fuzz.runs = 500 -/// function test_SimpleFuzzTest(uint256 x) public {...} -/// -/// /// forge-config: default.fuzz.runs = 500 -/// /// forge-config: ci.fuzz.runs = 10000 -/// function test_ImportantFuzzTest(uint256 x) public {...} -/// } -/// ``` -pub trait InlineConfigParser -where - Self: Clone + Default + Sized + 'static, -{ - /// Returns a config key that is common to all valid configuration lines - /// for the current impl. This helps to extract correct values out of a text. - /// - /// An example key would be `fuzz` of `invariant`. - fn config_key() -> String; - - /// Tries to override `self` properties with values specified in the `configs` parameter. - /// - /// Returns - /// - `Some(Self)` in case some configurations are merged into self. - /// - `None` in case there are no configurations that can be applied to self. - /// - `Err(InlineConfigParserError)` in case of wrong configuration. - fn try_merge(&self, configs: &[String]) -> Result, InlineConfigParserError>; - - /// Validates and merges the natspec configs for current profile into the current config. - fn merge(&self, natspec: &NatSpec) -> Result, InlineConfigError> { - let config_key = Self::config_key(); - - let configs = natspec - .current_profile_configs() - .filter(|l| l.contains(&config_key)) - .collect::>(); - - self.try_merge(&configs).map_err(|e| { - let line = natspec.debug_context(); - InlineConfigError { line, source: e } - }) - } - - /// Given a list of config lines, returns all available pairs (key, value) matching the current - /// config key. - /// - /// # Examples - /// - /// ```ignore - /// assert_eq!( - /// get_config_overrides(&[ - /// "forge-config: default.invariant.runs = 500", - /// "forge-config: default.invariant.depth = 500", - /// "forge-config: ci.invariant.depth = 500", - /// "forge-config: ci.fuzz.runs = 10", - /// ]), - /// [("runs", "500"), ("depth", "500"), ("depth", "500")] - /// ); - /// ``` - fn get_config_overrides(config_lines: &[String]) -> Vec<(String, String)> { - let mut result: Vec<(String, String)> = vec![]; - let config_key = Self::config_key(); - let profile = ".*"; - let prefix = format!("^{INLINE_CONFIG_PREFIX}:{profile}{config_key}\\."); - let re = Regex::new(&prefix).unwrap(); - - config_lines - .iter() - .map(|l| remove_whitespaces(l)) - .filter(|l| re.is_match(l)) - .map(|l| re.replace(&l, "").to_string()) - .for_each(|line| { - let key_value = line.split('=').collect::>(); // i.e. "['runs', '500']" - if let Some(key) = key_value.first() { - if let Some(value) = key_value.last() { - result.push((key.to_string(), value.to_string())); - } - } - }); - - result - } -} - -/// Checks if all configuration lines specified in `natspec` use a valid profile. -/// -/// i.e. Given available profiles -/// ```rust -/// let _profiles = vec!["ci", "default"]; -/// ``` -/// A configuration like `forge-config: ciii.invariant.depth = 1` would result -/// in an error. -pub fn validate_profiles(natspec: &NatSpec, profiles: &[String]) -> Result<(), InlineConfigError> { - for config in natspec.config_lines() { - if !profiles.iter().any(|p| config.starts_with(&format!("{INLINE_CONFIG_PREFIX}:{p}."))) { - let err_line: String = natspec.debug_context(); - let profiles = format!("{profiles:?}"); - Err(InlineConfigError { - source: InlineConfigParserError::InvalidProfile(config, profiles), - line: err_line, - })? - } - } - Ok(()) -} - -/// Tries to parse a `u32` from `value`. The `key` argument is used to give details -/// in the case of an error. -pub fn parse_config_u32(key: String, value: String) -> Result { - value.parse().map_err(|_| InlineConfigParserError::ParseInt(key, value)) -} - -/// Tries to parse a `bool` from `value`. The `key` argument is used to give details -/// in the case of an error. -pub fn parse_config_bool(key: String, value: String) -> Result { - value.parse().map_err(|_| InlineConfigParserError::ParseBool(key, value)) -} - -#[cfg(test)] -mod tests { - use crate::{inline::conf_parser::validate_profiles, NatSpec}; - - #[test] - fn can_reject_invalid_profiles() { - let profiles = ["ci".to_string(), "default".to_string()]; - let natspec = NatSpec { - contract: Default::default(), - function: Default::default(), - line: Default::default(), - docs: r" - forge-config: ciii.invariant.depth = 1 - forge-config: default.invariant.depth = 1 - " - .into(), - }; - - let result = validate_profiles(&natspec, &profiles); - assert!(result.is_err()); - } - - #[test] - fn can_accept_valid_profiles() { - let profiles = ["ci".to_string(), "default".to_string()]; - let natspec = NatSpec { - contract: Default::default(), - function: Default::default(), - line: Default::default(), - docs: r" - forge-config: ci.invariant.depth = 1 - forge-config: default.invariant.depth = 1 - " - .into(), - }; - - let result = validate_profiles(&natspec, &profiles); - assert!(result.is_ok()); - } -} diff --git a/crates/config/src/inline/error.rs b/crates/config/src/inline/error.rs deleted file mode 100644 index ddcb6a61bdb89..0000000000000 --- a/crates/config/src/inline/error.rs +++ /dev/null @@ -1,44 +0,0 @@ -/// Errors returned by the [`InlineConfigParser`](crate::InlineConfigParser) trait. -#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)] -pub enum InlineConfigParserError { - /// An invalid configuration property has been provided. - /// The property cannot be mapped to the configuration object - #[error("'{0}' is an invalid config property")] - InvalidConfigProperty(String), - /// An invalid profile has been provided - #[error("'{0}' specifies an invalid profile. Available profiles are: {1}")] - InvalidProfile(String, String), - /// An error occurred while trying to parse an integer configuration value - #[error("Invalid config value for key '{0}'. Unable to parse '{1}' into an integer value")] - ParseInt(String, String), - /// An error occurred while trying to parse a boolean configuration value - #[error("Invalid config value for key '{0}'. Unable to parse '{1}' into a boolean value")] - ParseBool(String, String), -} - -/// Wrapper error struct that catches config parsing errors, enriching them with context information -/// reporting the misconfigured line. -#[derive(Debug, thiserror::Error)] -#[error("Inline config error detected at {line}")] -pub struct InlineConfigError { - /// Specifies the misconfigured line. This is something of the form - /// `dir/TestContract.t.sol:FuzzContract:10:12:111` - pub line: String, - /// The inner error - pub source: InlineConfigParserError, -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn can_format_inline_config_errors() { - let source = InlineConfigParserError::ParseBool("key".into(), "invalid-bool-value".into()); - let line = "dir/TestContract.t.sol:FuzzContract".to_string(); - let error = InlineConfigError { line: line.clone(), source }; - - let expected = format!("Inline config error detected at {line}"); - assert_eq!(error.to_string(), expected); - } -} diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 8b5616a21afbb..30b1c820ec9b9 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -1,61 +1,168 @@ use crate::Config; use alloy_primitives::map::HashMap; -use std::sync::LazyLock; -mod conf_parser; -pub use conf_parser::*; - -mod error; -pub use error::*; +use figment::{ + value::{Dict, Map, Value}, + Figment, Profile, Provider, +}; +use itertools::Itertools; mod natspec; pub use natspec::*; -pub const INLINE_CONFIG_FUZZ_KEY: &str = "fuzz"; -pub const INLINE_CONFIG_INVARIANT_KEY: &str = "invariant"; -const INLINE_CONFIG_PREFIX: &str = "forge-config"; +const INLINE_CONFIG_PREFIX: &str = "forge-config:"; + +type DataMap = Map; -static INLINE_CONFIG_PREFIX_SELECTED_PROFILE: LazyLock = LazyLock::new(|| { - let selected_profile = Config::selected_profile().to_string(); - format!("{INLINE_CONFIG_PREFIX}:{selected_profile}.") -}); +/// Errors returned when parsing inline config. +#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)] +pub enum InlineConfigErrorKind { + /// Failed to parse inline config as TOML. + #[error(transparent)] + Parse(#[from] toml::de::Error), + /// An invalid profile has been provided. + #[error("invalid profile `{0}`; valid profiles: {1}")] + InvalidProfile(String, String), +} + +/// Wrapper error struct that catches config parsing errors, enriching them with context information +/// reporting the misconfigured line. +#[derive(Debug, thiserror::Error)] +#[error("Inline config error at {location}: {kind}")] +pub struct InlineConfigError { + /// The span of the error in the format: + /// `dir/TestContract.t.sol:FuzzContract:10:12:111` + pub location: String, + /// The inner error + pub kind: InlineConfigErrorKind, +} /// Represents per-test configurations, declared inline /// as structured comments in Solidity test files. This allows /// to create configs directly bound to a solidity test. #[derive(Clone, Debug, Default)] -pub struct InlineConfig { - /// Contract-level configurations, used for functions that do not have a specific - /// configuration. - contract_level: HashMap, - /// Maps a (test-contract, test-function) pair - /// to a specific configuration provided by the user. - fn_level: HashMap<(String, String), T>, +pub struct InlineConfig { + /// Contract-level configuration. + contract_level: HashMap, + /// Function-level configuration. + fn_level: HashMap<(String, String), DataMap>, } -impl InlineConfig { - /// Returns an inline configuration, if any, for a test function. - /// Configuration is identified by the pair "contract", "function". - pub fn get(&self, contract_id: &str, fn_name: &str) -> Option<&T> { - let key = (contract_id.to_string(), fn_name.to_string()); - self.fn_level.get(&key).or_else(|| self.contract_level.get(contract_id)) +impl InlineConfig { + /// Creates a new, empty [`InlineConfig`]. + pub fn new() -> Self { + Self::default() + } + + /// Inserts a new [`NatSpec`] into the [`InlineConfig`]. + pub fn insert(&mut self, natspec: &NatSpec) -> Result<(), InlineConfigError> { + let map = if let Some(function) = &natspec.function { + self.fn_level.entry((natspec.contract.clone(), function.clone())).or_default() + } else { + self.contract_level.entry(natspec.contract.clone()).or_default() + }; + let joined = natspec + .config_values() + .map(|s| { + // Replace `-` with `_` for backwards compatibility with the old parser. + if let Some(idx) = s.find('=') { + s[..idx].replace('-', "_") + &s[idx..] + } else { + s.to_string() + } + }) + .format("\n") + .to_string(); + let data = toml::from_str::(&joined).map_err(|e| InlineConfigError { + location: natspec.location_string(), + kind: InlineConfigErrorKind::Parse(e), + })?; + extend_data_map(map, &data); + Ok(()) } - pub fn insert_contract(&mut self, contract_id: impl Into, config: T) { - self.contract_level.insert(contract_id.into(), config); + /// Returns a [`figment::Provider`] for this [`InlineConfig`] at the given contract and function + /// level. + pub fn provide<'a>(&'a self, contract: &'a str, function: &'a str) -> InlineConfigProvider<'a> { + InlineConfigProvider { inline: self, contract, function } } - /// Inserts an inline configuration, for a test function. - /// Configuration is identified by the pair "contract", "function". - pub fn insert_fn(&mut self, contract_id: C, fn_name: F, config: T) - where - C: Into, - F: Into, - { - let key = (contract_id.into(), fn_name.into()); - self.fn_level.insert(key, config); + /// Merges the inline configuration at the given contract and function level with the provided + /// base configuration. + pub fn merge(&self, contract: &str, function: &str, base: &Config) -> Figment { + Figment::from(base).merge(self.provide(contract, function)) + } + + /// Returns `true` if a configuration is present at the given contract and function level. + pub fn contains(&self, contract: &str, function: &str) -> bool { + // Order swapped to avoid allocation in `get_function` since order doesn't matter here. + self.get_contract(contract) + .filter(|map| !map.is_empty()) + .or_else(|| self.get_function(contract, function)) + .is_some_and(|map| !map.is_empty()) + } + + fn get_contract(&self, contract: &str) -> Option<&DataMap> { + self.contract_level.get(contract) + } + + fn get_function(&self, contract: &str, function: &str) -> Option<&DataMap> { + let key = (contract.to_string(), function.to_string()); + self.fn_level.get(&key) } } -pub(crate) fn remove_whitespaces(s: &str) -> String { - s.chars().filter(|c| !c.is_whitespace()).collect() +/// [`figment::Provider`] for [`InlineConfig`] at a given contract and function level. +/// +/// Created by [`InlineConfig::provide`]. +#[derive(Clone, Debug)] +pub struct InlineConfigProvider<'a> { + inline: &'a InlineConfig, + contract: &'a str, + function: &'a str, +} + +impl Provider for InlineConfigProvider<'_> { + fn metadata(&self) -> figment::Metadata { + figment::Metadata::named("inline config") + } + + fn data(&self) -> figment::Result { + let mut map = DataMap::new(); + if let Some(new) = self.inline.get_contract(self.contract) { + extend_data_map(&mut map, new); + } + if let Some(new) = self.inline.get_function(self.contract, self.function) { + extend_data_map(&mut map, new); + } + Ok(map) + } +} + +fn extend_data_map(map: &mut DataMap, new: &DataMap) { + for (profile, data) in new { + extend_dict(map.entry(profile.clone()).or_default(), data); + } +} + +fn extend_dict(dict: &mut Dict, new: &Dict) { + for (k, v) in new { + match dict.entry(k.clone()) { + std::collections::btree_map::Entry::Vacant(entry) => { + entry.insert(v.clone()); + } + std::collections::btree_map::Entry::Occupied(entry) => { + extend_value(entry.into_mut(), v); + } + } + } +} + +fn extend_value(value: &mut Value, new: &Value) { + match (value, new) { + (Value::Dict(tag, dict), Value::Dict(new_tag, new_dict)) => { + *tag = *new_tag; + extend_dict(dict, new_dict); + } + (value, new) => *value = new.clone(), + } } diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 6dd6b696c0150..5774d9e193f1b 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -1,8 +1,10 @@ -use super::{remove_whitespaces, INLINE_CONFIG_PREFIX, INLINE_CONFIG_PREFIX_SELECTED_PROFILE}; +use super::{InlineConfigError, InlineConfigErrorKind, INLINE_CONFIG_PREFIX}; +use figment::Profile; use foundry_compilers::{ artifacts::{ast::NodeType, Node}, ProjectCompileOutput, }; +use itertools::Itertools; use serde_json::Value; use solang_parser::{helpers::CodeLocation, pt}; use std::{collections::BTreeMap, path::Path}; @@ -10,15 +12,13 @@ use std::{collections::BTreeMap, path::Path}; /// Convenient struct to hold in-line per-test configurations #[derive(Clone, Debug, PartialEq, Eq)] pub struct NatSpec { - /// The parent contract of the natspec + /// The parent contract of the natspec. pub contract: String, - /// The function annotated with the natspec. None if the natspec is contract-level + /// The function annotated with the natspec. None if the natspec is contract-level. pub function: Option, - /// The line the natspec appears, in the form - /// `row:col:length` i.e. `10:21:122` + /// The line the natspec appears, in the form `row:col:length`, i.e. `10:21:122`. pub line: String, - /// The actual natspec comment, without slashes or block - /// punctuation + /// The actual natspec comment, without slashes or block punctuation. pub docs: String, } @@ -56,29 +56,52 @@ impl NatSpec { natspecs } - /// Returns a string describing the natspec - /// context, for debugging purposes 🐞 - /// i.e. `test/Counter.t.sol:CounterTest:testFuzz_SetNumber` - pub fn debug_context(&self) -> String { - format!("{}:{}", self.contract, self.function.as_deref().unwrap_or_default()) + /// Checks if all configuration lines use a valid profile. + /// + /// i.e. Given available profiles + /// ```rust + /// let _profiles = vec!["ci", "default"]; + /// ``` + /// A configuration like `forge-config: ciii.invariant.depth = 1` would result + /// in an error. + pub fn validate_profiles(&self, profiles: &[Profile]) -> eyre::Result<()> { + for config in self.config_values() { + if !profiles.iter().any(|p| { + config + .strip_prefix(p.as_str().as_str()) + .is_some_and(|rest| rest.trim_start().starts_with('.')) + }) { + Err(InlineConfigError { + location: self.location_string(), + kind: InlineConfigErrorKind::InvalidProfile( + config.to_string(), + profiles.iter().format(", ").to_string(), + ), + })? + } + } + Ok(()) } - /// Returns a list of configuration lines that match the current profile - pub fn current_profile_configs(&self) -> impl Iterator + '_ { - self.config_lines_with_prefix(INLINE_CONFIG_PREFIX_SELECTED_PROFILE.as_str()) + /// Returns the path of the contract. + pub fn path(&self) -> &str { + match self.contract.split_once(':') { + Some((path, _)) => path, + None => self.contract.as_str(), + } } - /// Returns a list of configuration lines that match a specific string prefix - pub fn config_lines_with_prefix<'a>( - &'a self, - prefix: &'a str, - ) -> impl Iterator + 'a { - self.config_lines().filter(move |l| l.starts_with(prefix)) + /// Returns the location of the natspec as a string. + pub fn location_string(&self) -> String { + format!("{}:{}", self.path(), self.line) } - /// Returns a list of all the configuration lines available in the natspec - pub fn config_lines(&self) -> impl Iterator + '_ { - self.docs.lines().filter(|line| line.contains(INLINE_CONFIG_PREFIX)).map(remove_whitespaces) + /// Returns a list of all the configuration values available in the natspec. + pub fn config_values(&self) -> impl Iterator { + self.docs.lines().filter_map(|line| { + line.find(INLINE_CONFIG_PREFIX) + .map(|idx| line[idx + INLINE_CONFIG_PREFIX.len()..].trim()) + }) } } @@ -258,6 +281,42 @@ mod tests { use super::*; use serde_json::json; + #[test] + fn can_reject_invalid_profiles() { + let profiles = ["ci".into(), "default".into()]; + let natspec = NatSpec { + contract: Default::default(), + function: Default::default(), + line: Default::default(), + docs: r" + forge-config: ciii.invariant.depth = 1 + forge-config: default.invariant.depth = 1 + " + .into(), + }; + + let result = natspec.validate_profiles(&profiles); + assert!(result.is_err()); + } + + #[test] + fn can_accept_valid_profiles() { + let profiles = ["ci".into(), "default".into()]; + let natspec = NatSpec { + contract: Default::default(), + function: Default::default(), + line: Default::default(), + docs: r" + forge-config: ci.invariant.depth = 1 + forge-config: default.invariant.depth = 1 + " + .into(), + }; + + let result = natspec.validate_profiles(&profiles); + assert!(result.is_ok()); + } + #[test] fn parse_solang() { let src = " @@ -355,42 +414,13 @@ contract FuzzInlineConf is DSTest { #[test] fn config_lines() { let natspec = natspec(); - let config_lines = natspec.config_lines(); - assert_eq!( - config_lines.collect::>(), - vec![ - "forge-config:default.fuzz.runs=600".to_string(), - "forge-config:ci.fuzz.runs=500".to_string(), - "forge-config:default.invariant.runs=1".to_string() - ] - ) - } - - #[test] - fn current_profile_configs() { - let natspec = natspec(); - let config_lines = natspec.current_profile_configs(); - - assert_eq!( - config_lines.collect::>(), - vec![ - "forge-config:default.fuzz.runs=600".to_string(), - "forge-config:default.invariant.runs=1".to_string() - ] - ); - } - - #[test] - fn config_lines_with_prefix() { - use super::INLINE_CONFIG_PREFIX; - let natspec = natspec(); - let prefix = format!("{INLINE_CONFIG_PREFIX}:default"); - let config_lines = natspec.config_lines_with_prefix(&prefix); + let config_lines = natspec.config_values(); assert_eq!( config_lines.collect::>(), - vec![ - "forge-config:default.fuzz.runs=600".to_string(), - "forge-config:default.invariant.runs=1".to_string() + [ + "default.fuzz.runs = 600".to_string(), + "ci.fuzz.runs = 500".to_string(), + "default.invariant.runs = 1".to_string() ] ) } diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 70e9a2b858470..97f189b363d18 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -1,12 +1,6 @@ //! Configuration for invariant testing -use crate::{ - fuzz::FuzzDictionaryConfig, - inline::{ - parse_config_bool, parse_config_u32, InlineConfigParser, InlineConfigParserError, - INLINE_CONFIG_INVARIANT_KEY, - }, -}; +use crate::fuzz::FuzzDictionaryConfig; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -80,88 +74,3 @@ impl InvariantConfig { .join(contract_name.split(':').last().unwrap()) } } - -impl InlineConfigParser for InvariantConfig { - fn config_key() -> String { - INLINE_CONFIG_INVARIANT_KEY.into() - } - - fn try_merge(&self, configs: &[String]) -> Result, InlineConfigParserError> { - let overrides: Vec<(String, String)> = Self::get_config_overrides(configs); - - if overrides.is_empty() { - return Ok(None) - } - - let mut conf_clone = self.clone(); - - for pair in overrides { - let key = pair.0; - let value = pair.1; - match key.as_str() { - "runs" => conf_clone.runs = parse_config_u32(key, value)?, - "depth" => conf_clone.depth = parse_config_u32(key, value)?, - "fail-on-revert" => conf_clone.fail_on_revert = parse_config_bool(key, value)?, - "call-override" => conf_clone.call_override = parse_config_bool(key, value)?, - "failure-persist-dir" => { - conf_clone.failure_persist_dir = Some(PathBuf::from(value)) - } - "shrink-run-limit" => conf_clone.shrink_run_limit = parse_config_u32(key, value)?, - "show-metrics" => conf_clone.show_metrics = parse_config_bool(key, value)?, - _ => Err(InlineConfigParserError::InvalidConfigProperty(key.to_string()))?, - } - } - Ok(Some(conf_clone)) - } -} - -#[cfg(test)] -mod tests { - use crate::{inline::InlineConfigParser, InvariantConfig}; - - #[test] - fn unrecognized_property() { - let configs = &["forge-config: default.invariant.unknownprop = 200".to_string()]; - let base_config = InvariantConfig::default(); - if let Err(e) = base_config.try_merge(configs) { - assert_eq!(e.to_string(), "'unknownprop' is an invalid config property"); - } else { - unreachable!() - } - } - - #[test] - fn successful_merge() { - let configs = &["forge-config: default.invariant.runs = 42424242".to_string()]; - let base_config = InvariantConfig::default(); - let merged: InvariantConfig = base_config.try_merge(configs).expect("No errors").unwrap(); - assert_eq!(merged.runs, 42424242); - } - - #[test] - fn merge_is_none() { - let empty_config = &[]; - let base_config = InvariantConfig::default(); - let merged = base_config.try_merge(empty_config).expect("No errors"); - assert!(merged.is_none()); - } - - #[test] - fn can_merge_unrelated_properties_into_config() { - let unrelated_configs = &["forge-config: default.fuzz.runs = 2".to_string()]; - let base_config = InvariantConfig::default(); - let merged = base_config.try_merge(unrelated_configs).expect("No errors"); - assert!(merged.is_none()); - } - - #[test] - fn override_detection() { - let configs = &[ - "forge-config: default.fuzz.runs = 42424242".to_string(), - "forge-config: ci.fuzz.runs = 666666".to_string(), - "forge-config: default.invariant.runs = 2".to_string(), - ]; - let variables = InvariantConfig::get_config_overrides(configs); - assert_eq!(variables, vec![("runs".into(), "2".into())]); - } -} diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 5a159c3925b8a..72be43ab18a9b 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -108,7 +108,7 @@ mod invariant; pub use invariant::InvariantConfig; mod inline; -pub use inline::{validate_profiles, InlineConfig, InlineConfigError, InlineConfigParser, NatSpec}; +pub use inline::{InlineConfig, InlineConfigError, NatSpec}; pub mod soldeer; use soldeer::{SoldeerConfig, SoldeerDependencyConfig}; @@ -163,6 +163,11 @@ pub struct Config { /// set to the extracting Figment's selected `Profile`. #[serde(skip)] pub profile: Profile, + /// The list of all profiles defined in the config. + /// + /// See `profile`. + #[serde(skip)] + pub profiles: Vec, /// path of the source contracts dir, like `src` or `contracts` pub src: PathBuf, /// path of the test dir @@ -481,7 +486,7 @@ pub struct Config { /// Use EOF-enabled solc for compilation. pub eof: bool, - /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information + /// Warnings gathered when loading the Config. See [`WarningsProvider`] for more information. #[serde(rename = "__warnings", default, skip_serializing)] pub warnings: Vec, @@ -516,7 +521,7 @@ pub const DEPRECATIONS: &[(&str, &str)] = &[("cancun", "evm_version = Cancun")]; impl Config { /// The default profile: "default" - pub const DEFAULT_PROFILE: Profile = Profile::const_new("default"); + pub const DEFAULT_PROFILE: Profile = Profile::Default; /// The hardhat profile: "hardhat" pub const HARDHAT_PROFILE: Profile = Profile::const_new("hardhat"); @@ -569,7 +574,7 @@ impl Config { /// See [`figment`](Self::figment) for more details. #[track_caller] pub fn load_with_providers(providers: FigmentProviders) -> Self { - Self::default().to_figment(providers).extract().unwrap() + Self::from_provider(Self::default().to_figment(providers)) } /// Returns the current `Config` @@ -620,19 +625,47 @@ impl Config { /// let config = Config::try_from(figment); /// ``` pub fn try_from(provider: T) -> Result { - let figment = Figment::from(provider); + Self::try_from_figment(Figment::from(provider)) + } + + fn try_from_figment(figment: Figment) -> Result { let mut config = figment.extract::().map_err(ExtractConfigError::new)?; config.profile = figment.profile().clone(); + + // The `"profile"` profile contains all the profiles as keys. + let mut add_profile = |profile: &Profile| { + if !config.profiles.contains(profile) { + config.profiles.push(profile.clone()); + } + }; + let figment = figment.select(Self::PROFILE_SECTION); + if let Ok(data) = figment.data() { + if let Some(profiles) = data.get(&Profile::new(Self::PROFILE_SECTION)) { + for profile in profiles.keys() { + add_profile(&Profile::new(profile)); + } + } + } + add_profile(&Self::DEFAULT_PROFILE); + add_profile(&config.profile); + Ok(config) } /// Returns the populated [Figment] using the requested [FigmentProviders] preset. /// - /// This will merge various providers, such as env,toml,remappings into the figment. - pub fn to_figment(self, providers: FigmentProviders) -> Figment { - let mut c = self; + /// This will merge various providers, such as env,toml,remappings into the figment if + /// requested. + pub fn to_figment(&self, providers: FigmentProviders) -> Figment { + // Note that `Figment::from` here is a method on `Figment` rather than the `From` impl below + + if providers.is_none() { + return Figment::from(self); + } + + let root = self.root.0.as_path(); let profile = Self::selected_profile(); - let mut figment = Figment::default().merge(DappHardhatDirProvider(&c.root.0)); + let mut figment = Figment::default().merge(DappHardhatDirProvider(root)); // merge global foundry.toml file if let Some(global_toml) = Self::foundry_dir_toml().filter(|p| p.exists()) { @@ -645,7 +678,7 @@ impl Config { // merge local foundry.toml file figment = Self::merge_toml_provider( figment, - TomlFileProvider::new(Some("FOUNDRY_CONFIG"), c.root.0.join(Self::FILE_NAME)).cached(), + TomlFileProvider::new(Some("FOUNDRY_CONFIG"), root.join(Self::FILE_NAME)).cached(), profile.clone(), ); @@ -692,17 +725,17 @@ impl Config { lib_paths: figment .extract_inner::>("libs") .map(Cow::Owned) - .unwrap_or_else(|_| Cow::Borrowed(&c.libs)), - root: &c.root.0, + .unwrap_or_else(|_| Cow::Borrowed(&self.libs)), + root, remappings: figment.extract_inner::>("remappings"), }; figment = figment.merge(remappings); } // normalize defaults - figment = c.normalize_defaults(figment); + figment = self.normalize_defaults(figment); - Figment::from(c).merge(figment).select(profile) + Figment::from(self).merge(figment).select(profile) } /// The config supports relative paths and tracks the root path separately see @@ -1722,6 +1755,19 @@ impl Config { /// /// If the `FOUNDRY_PROFILE` env variable is not set, this returns the `DEFAULT_PROFILE`. pub fn selected_profile() -> Profile { + // Can't cache in tests because the env var can change. + #[cfg(test)] + { + Self::force_selected_profile() + } + #[cfg(not(test))] + { + static CACHE: std::sync::OnceLock = std::sync::OnceLock::new(); + CACHE.get_or_init(Self::force_selected_profile).clone() + } + } + + fn force_selected_profile() -> Profile { Profile::from_env_or("FOUNDRY_PROFILE", Self::DEFAULT_PROFILE) } @@ -2017,19 +2063,20 @@ impl Config { /// This normalizes the default `evm_version` if a `solc` was provided in the config. /// /// See also - fn normalize_defaults(&mut self, figment: Figment) -> Figment { + fn normalize_defaults(&self, mut figment: Figment) -> Figment { + // TODO: add a warning if evm_version is provided but incompatible + if figment.contains("evm_version") { + return figment; + } + + // Normalize `evm_version` based on the provided solc version. if let Ok(solc) = figment.extract_inner::("solc") { - // check if evm_version is set - // TODO: add a warning if evm_version is provided but incompatible - if figment.find_value("evm_version").is_err() { - if let Some(version) = solc - .try_version() - .ok() - .and_then(|version| self.evm_version.normalize_version_solc(&version)) - { - // normalize evm_version based on the provided solc version - self.evm_version = version; - } + if let Some(version) = solc + .try_version() + .ok() + .and_then(|version| self.evm_version.normalize_version_solc(&version)) + { + figment = figment.merge(("evm_version", version)); } } @@ -2039,36 +2086,53 @@ impl Config { impl From for Figment { fn from(c: Config) -> Self { + (&c).into() + } +} +impl From<&Config> for Figment { + fn from(c: &Config) -> Self { c.to_figment(FigmentProviders::All) } } -/// Determines what providers should be used when loading the [Figment] for a [Config] +/// Determines what providers should be used when loading the [`Figment`] for a [`Config`]. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum FigmentProviders { - /// Include all providers + /// Include all providers. #[default] All, - /// Only include necessary providers that are useful for cast commands + /// Only include necessary providers that are useful for cast commands. /// - /// This will exclude more expensive providers such as remappings + /// This will exclude more expensive providers such as remappings. Cast, - /// Only include necessary providers that are useful for anvil + /// Only include necessary providers that are useful for anvil. /// - /// This will exclude more expensive providers such as remappings + /// This will exclude more expensive providers such as remappings. Anvil, + /// Don't include any providers. + None, } impl FigmentProviders { - /// Returns true if all providers should be included + /// Returns true if all providers should be included. pub const fn is_all(&self) -> bool { matches!(self, Self::All) } - /// Returns true if this is the cast preset + /// Returns true if this is the cast preset. pub const fn is_cast(&self) -> bool { matches!(self, Self::Cast) } + + /// Returns true if this is the anvil preset. + pub const fn is_anvil(&self) -> bool { + matches!(self, Self::Anvil) + } + + /// Returns true if no providers should be included. + pub const fn is_none(&self) -> bool { + matches!(self, Self::None) + } } /// Wrapper type for `regex::Regex` that implements `PartialEq` @@ -2154,6 +2218,20 @@ impl AsRef for RootPath { } } +impl std::ops::Deref for RootPath { + type Target = PathBuf; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl std::ops::DerefMut for RootPath { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + /// Parses a config profile /// /// All `Profile` date is ignored by serde, however the `Config::to_string_pretty` includes it and @@ -2202,11 +2280,9 @@ impl Default for Config { fn default() -> Self { Self { profile: Self::DEFAULT_PROFILE, + profiles: vec![Self::DEFAULT_PROFILE], fs_permissions: FsPermissions::new([PathPermission::read("out")]), - #[cfg(not(feature = "isolate-by-default"))] - isolate: false, - #[cfg(feature = "isolate-by-default")] - isolate: true, + isolate: cfg!(feature = "isolate-by-default"), root: Default::default(), src: "src".into(), test: "test".into(), @@ -2322,11 +2398,12 @@ impl Default for Config { } } -/// Wrapper for the config's `gas_limit` value necessary because toml-rs can't handle larger number because integers are stored signed: +/// Wrapper for the config's `gas_limit` value necessary because toml-rs can't handle larger number +/// because integers are stored signed: /// /// Due to this limitation this type will be serialized/deserialized as String if it's larger than /// `i64` -#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize)] pub struct GasLimit(#[serde(deserialize_with = "crate::deserialize_u64_or_max")] pub u64); impl From for GasLimit { @@ -3052,9 +3129,39 @@ mod tests { #[test] fn test_figment_is_default() { figment::Jail::expect_with(|_| { - let mut default: Config = Config::figment().extract().unwrap(); - default.profile = Config::default().profile; - assert_eq!(default, Config::default()); + let mut default: Config = Config::figment().extract()?; + let default2 = Config::default(); + default.profile = default2.profile.clone(); + default.profiles = default2.profiles.clone(); + assert_eq!(default, default2); + Ok(()) + }); + } + + #[test] + fn figment_profiles() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r" + [foo.baz] + libs = ['node_modules', 'lib'] + + [profile.default] + libs = ['node_modules', 'lib'] + + [profile.ci] + libs = ['node_modules', 'lib'] + + [profile.local] + libs = ['node_modules', 'lib'] + ", + )?; + + let config = crate::Config::load(); + let expected: &[figment::Profile] = &["ci".into(), "default".into(), "local".into()]; + assert_eq!(config.profiles, expected); + Ok(()) }); } @@ -3163,7 +3270,6 @@ mod tests { jail.set_env("FOUNDRY_PROFILE", "custom"); let config = Config::load(); - assert_eq!(config.src, PathBuf::from("customsrc")); assert_eq!(config.test, PathBuf::from("defaulttest")); assert_eq!(config.libs, vec![PathBuf::from("lib"), PathBuf::from("node_modules")]); diff --git a/crates/config/src/providers/mod.rs b/crates/config/src/providers/mod.rs index 1f9f5c88ea895..9bd8a014f9699 100644 --- a/crates/config/src/providers/mod.rs +++ b/crates/config/src/providers/mod.rs @@ -17,7 +17,7 @@ pub struct WarningsProvider

{ old_warnings: Result, Error>, } -impl

WarningsProvider

{ +impl WarningsProvider

{ const WARNINGS_KEY: &'static str = "__warnings"; /// Creates a new warnings provider. @@ -41,9 +41,7 @@ impl

WarningsProvider

{ }; Self::new(provider, figment.profile().clone(), old_warnings) } -} -impl WarningsProvider

{ /// Collects all warnings. pub fn collect_warnings(&self) -> Result, Error> { let data = self.provider.data().unwrap_or_default(); @@ -103,12 +101,10 @@ impl Provider for WarningsProvider

{ } fn data(&self) -> Result, Error> { + let warnings = self.collect_warnings()?; Ok(Map::from([( self.profile.clone(), - Dict::from([( - Self::WARNINGS_KEY.to_string(), - Value::serialize(self.collect_warnings()?)?, - )]), + Dict::from([(Self::WARNINGS_KEY.to_string(), Value::serialize(warnings)?)]), )])) } @@ -138,8 +134,9 @@ impl Provider for FallbackProfileProvider

{ } fn data(&self) -> Result, Error> { - if let Some(fallback) = self.provider.data()?.get(&self.fallback) { - let mut inner = self.provider.data()?.remove(&self.profile).unwrap_or_default(); + let data = self.provider.data()?; + if let Some(fallback) = data.get(&self.fallback) { + let mut inner = data.get(&self.profile).cloned().unwrap_or_default(); for (k, v) in fallback.iter() { if !inner.contains_key(k) { inner.insert(k.to_owned(), v.clone()); @@ -147,7 +144,7 @@ impl Provider for FallbackProfileProvider

{ } Ok(self.profile.collect(inner)) } else { - self.provider.data() + Ok(data) } } diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 623234f947982..343fde697859a 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -112,7 +112,7 @@ pub struct RemappingsProvider<'a> { pub lib_paths: Cow<'a, Vec>, /// the root path used to turn an absolute `Remapping`, as we're getting it from /// `Remapping::find_many` into a relative one. - pub root: &'a PathBuf, + pub root: &'a Path, /// This contains either: /// - previously set remappings /// - a `MissingField` error, which means previous provider didn't set the "remappings" field diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 2117834f428a4..e07d7dfbcb09a 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -14,7 +14,6 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -use toml_edit::{DocumentMut, Item}; /// Loads the config for the current project workspace pub fn load_config() -> Config { @@ -186,45 +185,6 @@ pub(crate) fn get_dir_remapping(dir: impl AsRef) -> Option { } } -/// Returns all available `profile` keys in a given `.toml` file -/// -/// i.e. The toml below would return would return `["default", "ci", "local"]` -/// ```toml -/// [profile.default] -/// ... -/// [profile.ci] -/// ... -/// [profile.local] -/// ``` -pub fn get_available_profiles(toml_path: impl AsRef) -> eyre::Result> { - let mut result = vec![Config::DEFAULT_PROFILE.to_string()]; - - if !toml_path.as_ref().exists() { - return Ok(result) - } - - let doc = read_toml(toml_path)?; - - if let Some(Item::Table(profiles)) = doc.as_table().get(Config::PROFILE_SECTION) { - for (profile, _) in profiles { - let p = profile.to_string(); - if !result.contains(&p) { - result.push(p); - } - } - } - - Ok(result) -} - -/// Returns a [`toml_edit::Document`] loaded from the provided `path`. -/// Can raise an error in case of I/O or parsing errors. -fn read_toml(path: impl AsRef) -> eyre::Result { - let path = path.as_ref().to_owned(); - let doc: DocumentMut = std::fs::read_to_string(path)?.parse()?; - Ok(doc) -} - /// Deserialize stringified percent. The value must be between 0 and 100 inclusive. pub(crate) fn deserialize_stringified_percent<'de, D>(deserializer: D) -> Result where @@ -319,41 +279,3 @@ pub fn evm_spec_id(evm_version: &EvmVersion, alphanet: bool) -> SpecId { EvmVersion::Prague => SpecId::OSAKA, // Osaka enables EOF } } - -#[cfg(test)] -mod tests { - use crate::get_available_profiles; - use std::path::Path; - - #[test] - fn get_profiles_from_toml() { - figment::Jail::expect_with(|jail| { - jail.create_file( - "foundry.toml", - r" - [foo.baz] - libs = ['node_modules', 'lib'] - - [profile.default] - libs = ['node_modules', 'lib'] - - [profile.ci] - libs = ['node_modules', 'lib'] - - [profile.local] - libs = ['node_modules', 'lib'] - ", - )?; - - let path = Path::new("./foundry.toml"); - let profiles = get_available_profiles(path).unwrap(); - - assert_eq!( - profiles, - vec!["default".to_string(), "ci".to_string(), "local".to_string()] - ); - - Ok(()) - }); - } -} diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 9849fd1cef9c0..6f4448ae482c2 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -4,9 +4,9 @@ use alloy_primitives::{Address, B256, U256}; use alloy_provider::{network::AnyRpcBlock, Provider}; use eyre::WrapErr; use foundry_common::{provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS}; -use foundry_config::{Chain, Config}; +use foundry_config::{Chain, Config, GasLimit}; use revm::primitives::{BlockEnv, CfgEnv, TxEnv}; -use serde::{Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Serialize}; use url::Url; #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -166,7 +166,7 @@ impl EvmOpts { /// Returns the gas limit to use pub fn gas_limit(&self) -> u64 { - self.env.block_gas_limit.unwrap_or(self.env.gas_limit) + self.env.block_gas_limit.unwrap_or(self.env.gas_limit).0 } /// Returns the configured chain id, which will be @@ -225,8 +225,7 @@ impl EvmOpts { #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct Env { /// The block gas limit. - #[serde(deserialize_with = "string_or_number")] - pub gas_limit: u64, + pub gas_limit: GasLimit, /// The `CHAINID` opcode value. pub chain_id: Option, @@ -260,47 +259,10 @@ pub struct Env { pub block_prevrandao: B256, /// the block.gaslimit value during EVM execution - #[serde( - default, - skip_serializing_if = "Option::is_none", - deserialize_with = "string_or_number_opt" - )] - pub block_gas_limit: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub block_gas_limit: Option, /// EIP-170: Contract code size limit in bytes. Useful to increase this because of tests. #[serde(default, skip_serializing_if = "Option::is_none")] pub code_size_limit: Option, } - -#[derive(Deserialize)] -#[serde(untagged)] -enum Gas { - Number(u64), - Text(String), -} - -fn string_or_number<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - use serde::de::Error; - match Gas::deserialize(deserializer)? { - Gas::Number(num) => Ok(num), - Gas::Text(s) => s.parse().map_err(D::Error::custom), - } -} - -fn string_or_number_opt<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - use serde::de::Error; - - match Option::::deserialize(deserializer)? { - Some(gas) => match gas { - Gas::Number(num) => Ok(Some(num)), - Gas::Text(s) => s.parse().map(Some).map_err(D::Error::custom), - }, - _ => Ok(None), - } -} diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 7e60a5451efcd..4ca111a567404 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -230,11 +230,7 @@ impl CoverageArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_test_options(TestOptions { - fuzz: config.fuzz.clone(), - invariant: config.invariant.clone(), - ..Default::default() - }) + .with_test_options(TestOptions::new(output, config.clone())?) .set_coverage(true) .build(&root, output, env, evm_opts)?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index ad2e52df6725d..6e19c96d08d76 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -14,7 +14,7 @@ use forge::{ identifier::SignaturesIdentifier, CallTraceDecoderBuilder, InternalTraceMode, TraceKind, }, - MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, TestOptionsBuilder, + MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, }; use foundry_cli::{ opts::{CoreBuildArgs, GlobalOpts}, @@ -34,7 +34,7 @@ use foundry_config::{ Metadata, Profile, Provider, }, filter::GlobMatcher, - get_available_profiles, Config, + Config, }; use foundry_debugger::Debugger; use foundry_evm::traces::identifier::TraceIdentifiers; @@ -301,25 +301,20 @@ impl TestArgs { // Create test options from general project settings and compiler output. let project_root = &project.paths.root; - let toml = config.get_config_path(); - let profiles = get_available_profiles(toml)?; // Remove the snapshots directory if it exists. // This is to ensure that we don't have any stale snapshots. // If `FORGE_SNAPSHOT_CHECK` is set, we don't remove the snapshots directory as it is // required for comparison. - if std::env::var("FORGE_SNAPSHOT_CHECK").is_err() { + if std::env::var_os("FORGE_SNAPSHOT_CHECK").is_none() { let snapshot_dir = project_root.join(&config.snapshots); if snapshot_dir.exists() { let _ = fs::remove_dir_all(project_root.join(&config.snapshots)); } } - let test_options: TestOptions = TestOptionsBuilder::default() - .fuzz(config.fuzz.clone()) - .invariant(config.invariant.clone()) - .profiles(profiles) - .build(&output, project_root)?; + let config = Arc::new(config); + let test_options = TestOptions::new(&output, config.clone())?; let should_debug = self.debug.is_some(); let should_draw = self.flamegraph || self.flamechart; @@ -347,7 +342,6 @@ impl TestArgs { }; // Prepare the test builder. - let config = Arc::new(config); let runner = MultiContractRunnerBuilder::new(config.clone()) .set_debug(should_debug) .set_decode_internal(decode_internal) @@ -1067,9 +1061,9 @@ contract FooBarTest is DSTest { &prj.root().to_string_lossy(), ]); let outcome = args.run().await.unwrap(); - let gas_report = outcome.gas_report.unwrap(); + let gas_report = outcome.gas_report.as_ref().unwrap(); - assert_eq!(gas_report.contracts.len(), 3); + assert_eq!(gas_report.contracts.len(), 3, "{}", outcome.summary(Default::default())); let call_cnts = gas_report .contracts .values() diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 0bec55153099d..257760c4e94be 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -7,15 +7,16 @@ extern crate foundry_common; #[macro_use] extern crate tracing; +use alloy_primitives::U256; +use eyre::Result; use foundry_compilers::ProjectCompileOutput; use foundry_config::{ - validate_profiles, Config, FuzzConfig, InlineConfig, InlineConfigError, InlineConfigParser, - InvariantConfig, NatSpec, + figment::Figment, Config, FuzzConfig, InlineConfig, InvariantConfig, NatSpec, }; use proptest::test_runner::{ FailurePersistence, FileFailurePersistence, RngAlgorithm, TestRng, TestRunner, }; -use std::path::Path; +use std::sync::Arc; pub mod coverage; @@ -34,200 +35,108 @@ pub mod result; pub use foundry_common::traits::TestFilter; pub use foundry_evm::*; -/// Metadata on how to run fuzz/invariant tests +/// Test configuration. #[derive(Clone, Debug, Default)] pub struct TestOptions { - /// The base "fuzz" test configuration. To be used as a fallback in case - /// no more specific configs are found for a given run. - pub fuzz: FuzzConfig, - /// The base "invariant" test configuration. To be used as a fallback in case - /// no more specific configs are found for a given run. - pub invariant: InvariantConfig, - /// Contains per-test specific "fuzz" configurations. - pub inline_fuzz: InlineConfig, - /// Contains per-test specific "invariant" configurations. - pub inline_invariant: InlineConfig, + /// The base configuration. + pub config: Arc, + /// Per-test configuration. Merged onto `base_config`. + pub inline: InlineConfig, } impl TestOptions { /// Tries to create a new instance by detecting inline configurations from the project compile /// output. - pub fn new( - output: &ProjectCompileOutput, - root: &Path, - profiles: Vec, - base_fuzz: FuzzConfig, - base_invariant: InvariantConfig, - ) -> Result { - let natspecs: Vec = NatSpec::parse(output, root); - let mut inline_invariant = InlineConfig::::default(); - let mut inline_fuzz = InlineConfig::::default(); - - // Validate all natspecs + pub fn new(output: &ProjectCompileOutput, base_config: Arc) -> eyre::Result { + let natspecs: Vec = NatSpec::parse(output, &base_config.root); + let profiles = &base_config.profiles; + let mut inline = InlineConfig::new(); for natspec in &natspecs { - validate_profiles(natspec, &profiles)?; + inline.insert(natspec)?; + // Validate after parsing as TOML. + natspec.validate_profiles(profiles)?; } + Ok(Self { config: base_config, inline }) + } - // Firstly, apply contract-level configurations - for natspec in natspecs.iter().filter(|n| n.function.is_none()) { - if let Some(fuzz) = base_fuzz.merge(natspec)? { - inline_fuzz.insert_contract(&natspec.contract, fuzz); - } - - if let Some(invariant) = base_invariant.merge(natspec)? { - inline_invariant.insert_contract(&natspec.contract, invariant); - } - } - - for (natspec, f) in natspecs.iter().filter_map(|n| n.function.as_ref().map(|f| (n, f))) { - // Apply in-line configurations for the current profile - let c = &natspec.contract; - - // We might already have inserted contract-level configs above, so respect data already - // present in inline configs. - let base_fuzz = inline_fuzz.get(c, f).unwrap_or(&base_fuzz); - let base_invariant = inline_invariant.get(c, f).unwrap_or(&base_invariant); - - if let Some(fuzz) = base_fuzz.merge(natspec)? { - inline_fuzz.insert_fn(c, f, fuzz); - } - - if let Some(invariant) = base_invariant.merge(natspec)? { - inline_invariant.insert_fn(c, f, invariant); - } - } + /// Creates a new instance without parsing inline configuration. + pub fn new_unparsed(base_config: Arc) -> Self { + Self { config: base_config, inline: InlineConfig::new() } + } - Ok(Self { fuzz: base_fuzz, invariant: base_invariant, inline_fuzz, inline_invariant }) + /// Returns the [`Figment`] for the configuration. + pub fn figment(&self, contract: &str, function: &str) -> Result { + Ok(self.inline.merge(contract, function, &self.config)) } /// Returns a "fuzz" test runner instance. Parameters are used to select tight scoped fuzz /// configs that apply for a contract-function pair. A fallback configuration is applied /// if no specific setup is found for a given input. /// - /// - `contract_id` is the id of the test contract, expressed as a relative path from the - /// project root. - /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn fuzz_runner(&self, contract_id: &str, test_fn: &str) -> TestRunner { - let fuzz_config = self.fuzz_config(contract_id, test_fn).clone(); - let failure_persist_path = fuzz_config + /// - `contract` is the id of the test contract, expressed as a relative path from the project + /// root. + /// - `function` is the name of the test function declared inside the test contract. + pub fn fuzz_runner(&self, contract: &str, function: &str) -> Result<(FuzzConfig, TestRunner)> { + let config: FuzzConfig = self.figment(contract, function)?.extract_inner("fuzz")?; + let failure_persist_path = config .failure_persist_dir + .as_ref() .unwrap() - .join(fuzz_config.failure_persist_file.unwrap()) + .join(config.failure_persist_file.as_ref().unwrap()) .into_os_string() .into_string() .unwrap(); - self.fuzzer_with_cases( - fuzz_config.runs, - fuzz_config.max_test_rejects, + let runner = fuzzer_with_cases( + config.seed, + config.runs, + config.max_test_rejects, Some(Box::new(FileFailurePersistence::Direct(failure_persist_path.leak()))), - ) + ); + Ok((config, runner)) } /// Returns an "invariant" test runner instance. Parameters are used to select tight scoped fuzz /// configs that apply for a contract-function pair. A fallback configuration is applied /// if no specific setup is found for a given input. /// - /// - `contract_id` is the id of the test contract, expressed as a relative path from the - /// project root. - /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn invariant_runner(&self, contract_id: &str, test_fn: &str) -> TestRunner { - let invariant = self.invariant_config(contract_id, test_fn); - self.fuzzer_with_cases(invariant.runs, invariant.max_assume_rejects, None) - } - - /// Returns a "fuzz" configuration setup. Parameters are used to select tight scoped fuzz - /// configs that apply for a contract-function pair. A fallback configuration is applied - /// if no specific setup is found for a given input. - /// - /// - `contract_id` is the id of the test contract, expressed as a relative path from the - /// project root. - /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn fuzz_config(&self, contract_id: &str, test_fn: &str) -> &FuzzConfig { - self.inline_fuzz.get(contract_id, test_fn).unwrap_or(&self.fuzz) - } - - /// Returns an "invariant" configuration setup. Parameters are used to select tight scoped - /// invariant configs that apply for a contract-function pair. A fallback configuration is - /// applied if no specific setup is found for a given input. - /// - /// - `contract_id` is the id of the test contract, expressed as a relative path from the - /// project root. - /// - `test_fn` is the name of the test function declared inside the test contract. - pub fn invariant_config(&self, contract_id: &str, test_fn: &str) -> &InvariantConfig { - self.inline_invariant.get(contract_id, test_fn).unwrap_or(&self.invariant) - } - - pub fn fuzzer_with_cases( + /// - `contract` is the id of the test contract, expressed as a relative path from the project + /// root. + /// - `function` is the name of the test function declared inside the test contract. + pub fn invariant_runner( &self, - cases: u32, - max_global_rejects: u32, - file_failure_persistence: Option>, - ) -> TestRunner { - let config = proptest::test_runner::Config { - failure_persistence: file_failure_persistence, - cases, - max_global_rejects, - // Disable proptest shrink: for fuzz tests we provide single counterexample, - // for invariant tests we shrink outside proptest. - max_shrink_iters: 0, - ..Default::default() - }; - - if let Some(seed) = &self.fuzz.seed { - trace!(target: "forge::test", %seed, "building deterministic fuzzer"); - let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &seed.to_be_bytes::<32>()); - TestRunner::new_with_rng(config, rng) - } else { - trace!(target: "forge::test", "building stochastic fuzzer"); - TestRunner::new(config) - } + contract: &str, + function: &str, + ) -> Result<(InvariantConfig, TestRunner)> { + let figment = self.figment(contract, function)?; + let config: InvariantConfig = figment.extract_inner("invariant")?; + let seed: Option = figment.extract_inner("fuzz.seed").ok(); + let runner = fuzzer_with_cases(seed, config.runs, config.max_assume_rejects, None); + Ok((config, runner)) } } -/// Builder utility to create a [`TestOptions`] instance. -#[derive(Default)] -#[must_use = "builders do nothing unless you call `build` on them"] -pub struct TestOptionsBuilder { - fuzz: Option, - invariant: Option, - profiles: Option>, -} - -impl TestOptionsBuilder { - /// Sets a [`FuzzConfig`] to be used as base "fuzz" configuration. - pub fn fuzz(mut self, conf: FuzzConfig) -> Self { - self.fuzz = Some(conf); - self - } - - /// Sets a [`InvariantConfig`] to be used as base "invariant" configuration. - pub fn invariant(mut self, conf: InvariantConfig) -> Self { - self.invariant = Some(conf); - self - } - - /// Sets available configuration profiles. Profiles are useful to validate existing in-line - /// configurations. This argument is necessary in case a `compile_output`is provided. - pub fn profiles(mut self, p: Vec) -> Self { - self.profiles = Some(p); - self - } - - /// Creates an instance of [`TestOptions`]. This takes care of creating "fuzz" and - /// "invariant" fallbacks, and extracting all inline test configs, if available. - /// - /// `root` is a reference to the user's project root dir. This is essential - /// to determine the base path of generated contract identifiers. This is to provide correct - /// matchers for inline test configs. - pub fn build( - self, - output: &ProjectCompileOutput, - root: &Path, - ) -> Result { - let profiles: Vec = - self.profiles.unwrap_or_else(|| vec![Config::selected_profile().into()]); - let base_fuzz = self.fuzz.unwrap_or_default(); - let base_invariant = self.invariant.unwrap_or_default(); - TestOptions::new(output, root, profiles, base_fuzz, base_invariant) +fn fuzzer_with_cases( + seed: Option, + cases: u32, + max_global_rejects: u32, + file_failure_persistence: Option>, +) -> TestRunner { + let config = proptest::test_runner::Config { + failure_persistence: file_failure_persistence, + cases, + max_global_rejects, + // Disable proptest shrink: for fuzz tests we provide single counterexample, + // for invariant tests we shrink outside proptest. + max_shrink_iters: 0, + ..Default::default() + }; + + if let Some(seed) = seed { + trace!(target: "forge::test", %seed, "building deterministic fuzzer"); + let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &seed.to_be_bytes::<32>()); + TestRunner::new_with_rng(config, rng) + } else { + trace!(target: "forge::test", "building stochastic fuzzer"); + TestRunner::new(config) } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 4b66a482c27cd..fc2b89cb08150 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -341,24 +341,26 @@ impl ContractRunner<'_> { self.run_unit_test(func, should_fail, setup) } TestFunctionKind::FuzzTest { should_fail } => { - let runner = test_options.fuzz_runner(self.name, &func.name); - let fuzz_config = test_options.fuzz_config(self.name, &func.name); - - self.run_fuzz_test(func, should_fail, runner, setup, fuzz_config.clone()) + match test_options.fuzz_runner(self.name, &func.name) { + Ok((fuzz_config, runner)) => { + self.run_fuzz_test(func, should_fail, runner, setup, fuzz_config) + } + Err(err) => TestResult::fail(err.to_string()), + } } TestFunctionKind::InvariantTest => { - let runner = test_options.invariant_runner(self.name, &func.name); - let invariant_config = test_options.invariant_config(self.name, &func.name); - - self.run_invariant_test( - runner, - setup, - invariant_config.clone(), - func, - call_after_invariant, - &known_contracts, - identified_contracts.as_ref().unwrap(), - ) + match test_options.invariant_runner(self.name, &func.name) { + Ok((invariant_config, runner)) => self.run_invariant_test( + runner, + setup, + invariant_config, + func, + call_after_invariant, + &known_contracts, + identified_contracts.as_ref().unwrap(), + ), + Err(err) => TestResult::fail(err.to_string()), + } } _ => unreachable!(), }; diff --git a/crates/forge/tests/cli/alphanet.rs b/crates/forge/tests/cli/alphanet.rs index 6e41551ac890b..49b8c01fc7d29 100644 --- a/crates/forge/tests/cli/alphanet.rs +++ b/crates/forge/tests/cli/alphanet.rs @@ -1,6 +1,10 @@ // Ensure we can run basic counter tests with EOF support. -#[cfg(target_os = "linux")] forgetest_init!(test_eof_flag, |prj, cmd| { + if !has_docker() { + println!("skipping because no docker is available"); + return; + } + cmd.forge_fuse().args(["test", "--eof"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] @@ -17,3 +21,12 @@ Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) "#]]); }); + +fn has_docker() -> bool { + if !cfg!(target_os = "linux") { + return false; + } + + // `images` will also check for the daemon. + std::process::Command::new("docker").arg("images").output().is_ok_and(|o| o.status.success()) +} diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 9585b216b1592..ca54ae0d03529 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -140,6 +140,11 @@ Compiler run successful! // tests build output is as expected forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { + prj.write_config(Config { + solc: Some(foundry_config::SolcReq::Version(semver::Version::new(0, 8, 27))), + ..Default::default() + }); + cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![ r#" ... @@ -154,12 +159,12 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { str![[r#" { "Counter": { - "runtime_size": 247, - "init_size": 277, - "runtime_margin": 24329, - "init_margin": 48875 + "runtime_size": 236, + "init_size": 263, + "runtime_margin": 24340, + "init_margin": 48889 } -} +} "#]] .is_json(), ); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index db87a85ba0d10..72aacff49eb67 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -29,6 +29,8 @@ forgetest!(can_extract_config_values, |prj, cmd| { // explicitly set all values let input = Config { profile: Config::DEFAULT_PROFILE, + // `profiles` is not serialized. + profiles: vec![], root: Default::default(), src: "test-src".into(), test: "test-test".into(), diff --git a/crates/forge/tests/cli/inline_config.rs b/crates/forge/tests/cli/inline_config.rs new file mode 100644 index 0000000000000..de585a48ce17b --- /dev/null +++ b/crates/forge/tests/cli/inline_config.rs @@ -0,0 +1,194 @@ +forgetest!(runs, |prj, cmd| { + prj.add_test( + "inline.sol", + " + contract Inline { + /** forge-config: default.fuzz.runs = 2 */ + function test1(bool) public {} + + \t///\t forge-config:\tdefault.fuzz.runs=\t3 \t + + function test2(bool) public {} + } + ", + ) + .unwrap(); + + cmd.arg("test").assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 2 tests for test/inline.sol:Inline +[PASS] test1(bool) (runs: 2, [AVG_GAS]) +[PASS] test2(bool) (runs: 3, [AVG_GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) + +"#]]); + + // Make sure inline config is parsed in coverage too. + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" +... +Ran 2 tests for test/inline.sol:Inline +[PASS] test1(bool) (runs: 2, [AVG_GAS]) +[PASS] test2(bool) (runs: 3, [AVG_GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) +| File | % Lines | % Statements | % Branches | % Funcs | +|-------|---------------|---------------|---------------|---------------| +| Total | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | + +"#]]); +}); + +forgetest!(invalid_profile, |prj, cmd| { + prj.add_test( + "inline.sol", + " + /** forge-config: unknown.fuzz.runs = 2 */ + contract Inline { + function test(bool) public {} + } + ", + ) + .unwrap(); + + cmd.arg("test").assert_failure().stderr_eq(str![[r#" +Error: Inline config error at test/inline.sol:0:0:0: invalid profile `unknown.fuzz.runs = 2`; valid profiles: default + +"#]]); +}); + +// TODO: Uncomment once this done for normal config too. +/* +forgetest!(invalid_key, |prj, cmd| { + prj.add_test( + "inline.sol", + " + /** forge-config: default.fuzzz.runs = 2 */ + contract Inline { + function test(bool) public {} + } + ", + ) + .unwrap(); + + cmd.arg("test").assert_failure().stderr_eq(str![[]]).stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/inline.sol:Inline +[FAIL: failed to get inline configuration: unknown config section `default`] test(bool) ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) + +Failing tests: +Encountered 1 failing test in test/inline.sol:Inline +[FAIL: failed to get inline configuration: unknown config section `default`] test(bool) ([GAS]) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]]); +}); + +forgetest!(invalid_key_2, |prj, cmd| { + prj.add_test( + "inline.sol", + " +/** forge-config: default.fuzz.runss = 2 */ + contract Inline { + function test(bool) public {} + } + ", + ) + .unwrap(); + + cmd.arg("test").assert_failure().stderr_eq(str![[]]).stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/inline.sol:Inline +[FAIL: failed to get inline configuration: unknown config section `default`] test(bool) ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) + +Failing tests: +Encountered 1 failing test in test/inline.sol:Inline +[FAIL: failed to get inline configuration: unknown config section `default`] test(bool) ([GAS]) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]]); +}); +*/ + +forgetest!(invalid_value, |prj, cmd| { + prj.add_test( + "inline.sol", + " + /** forge-config: default.fuzz.runs = [2] */ + contract Inline { + function test(bool) public {} + } + ", + ) + .unwrap(); + + cmd.arg("test").assert_failure().stderr_eq(str![[]]).stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/inline.sol:Inline +[FAIL: invalid type: found sequence, expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) + +Failing tests: +Encountered 1 failing test in test/inline.sol:Inline +[FAIL: invalid type: found sequence, expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]]); +}); + +forgetest!(invalid_value_2, |prj, cmd| { + prj.add_test( + "inline.sol", + " + /** forge-config: default.fuzz.runs = '2' */ + contract Inline { + function test(bool) public {} + } + ", + ) + .unwrap(); + + cmd.arg("test").assert_failure().stderr_eq(str![[]]).stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/inline.sol:Inline +[FAIL: invalid type: found string "2", expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) + +Failing tests: +Encountered 1 failing test in test/inline.sol:Inline +[FAIL: invalid type: found string "2", expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]]); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 5838fa8537772..d59dbc6bedd64 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -18,6 +18,7 @@ mod debug; mod doc; mod eip712; mod geiger; +mod inline_config; mod multi_script; mod script; mod soldeer; diff --git a/crates/forge/tests/it/cheats.rs b/crates/forge/tests/it/cheats.rs index 871cda045fa7f..11fcdbcfd5c1b 100644 --- a/crates/forge/tests/it/cheats.rs +++ b/crates/forge/tests/it/cheats.rs @@ -27,9 +27,9 @@ async fn test_cheats_local(test_data: &ForgeTestData) { filter = filter.exclude_contracts("(LastCallGasDefaultTest|MockFunctionTest|WithSeed)"); } - let mut config = test_data.config.clone(); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); - let runner = test_data.runner_with_config(config); + let runner = test_data.runner_with(|config| { + config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); + }); TestConfig::with_filter(runner, filter).run().await; } @@ -38,9 +38,9 @@ async fn test_cheats_local(test_data: &ForgeTestData) { async fn test_cheats_local_isolated(test_data: &ForgeTestData) { let filter = Filter::new(".*", ".*(Isolated)", &format!(".*cheats{RE_PATH_SEPARATOR}*")); - let mut config = test_data.config.clone(); - config.isolate = true; - let runner = test_data.runner_with_config(config); + let runner = test_data.runner_with(|config| { + config.isolate = true; + }); TestConfig::with_filter(runner, filter).run().await; } @@ -49,9 +49,9 @@ async fn test_cheats_local_isolated(test_data: &ForgeTestData) { async fn test_cheats_local_with_seed(test_data: &ForgeTestData) { let filter = Filter::new(".*", ".*(WithSeed)", &format!(".*cheats{RE_PATH_SEPARATOR}*")); - let mut config = test_data.config.clone(); - config.fuzz.seed = Some(U256::from(100)); - let runner = test_data.runner_with_config(config); + let runner = test_data.runner_with(|config| { + config.fuzz.seed = Some(U256::from(100)); + }); TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index c8a599195441a..a2b4916d3e7cf 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -758,9 +758,9 @@ async fn test_trace() { #[tokio::test(flavor = "multi_thread")] async fn test_assertions_revert_false() { let filter = Filter::new(".*", ".*NoAssertionsRevertTest", ".*"); - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.assertions_revert = false; - let mut runner = TEST_DATA_DEFAULT.runner_with_config(config); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.assertions_revert = false; + }); let results = runner.test_collect(&filter); assert_multiple( @@ -784,9 +784,9 @@ async fn test_assertions_revert_false() { #[tokio::test(flavor = "multi_thread")] async fn test_legacy_assertions() { let filter = Filter::new(".*", ".*LegacyAssertions", ".*"); - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.legacy_assertions = true; - let mut runner = TEST_DATA_DEFAULT.runner_with_config(config); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.legacy_assertions = true; + }); let results = runner.test_collect(&filter); assert_multiple( diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 8dc637528ddd3..5974a12ed644c 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -35,9 +35,9 @@ async fn test_cheats_fork_revert() { /// Executes all non-reverting fork cheatcodes #[tokio::test(flavor = "multi_thread")] async fn test_cheats_fork() { - let mut config = TEST_DATA_PARIS.config.clone(); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = TEST_DATA_PARIS.runner_with_config(config); + let runner = TEST_DATA_PARIS.runner_with(|config| { + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + }); let filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; @@ -46,9 +46,9 @@ async fn test_cheats_fork() { /// Executes eth_getLogs cheatcode #[tokio::test(flavor = "multi_thread")] async fn test_get_logs_fork() { - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + }); let filter = Filter::new("testEthGetLogs", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; @@ -57,9 +57,9 @@ async fn test_get_logs_fork() { /// Executes rpc cheatcode #[tokio::test(flavor = "multi_thread")] async fn test_rpc_fork() { - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + }); let filter = Filter::new("testRpc", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); TestConfig::with_filter(runner, filter).run().await; @@ -102,25 +102,25 @@ async fn test_create_same_fork() { /// Test that `no_storage_caching` config is properly applied #[tokio::test(flavor = "multi_thread")] async fn test_storage_caching_config() { - // no_storage_caching set to true: storage should not be cached - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.no_storage_caching = true; - let runner = TEST_DATA_DEFAULT.runner_with_config(config); let filter = Filter::new("testStorageCaching", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) .exclude_tests(".*Revert"); - TestConfig::with_filter(runner, filter).run().await; + + let runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.no_storage_caching = true; + }); + + // no_storage_caching set to true: storage should not be cached + TestConfig::with_filter(runner, filter.clone()).run().await; let cache_dir = Config::foundry_block_cache_dir(Chain::mainnet(), 19800000).unwrap(); let _ = fs::remove_file(cache_dir); - // no_storage_caching set to false: storage should be cached - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.no_storage_caching = false; - let runner = TEST_DATA_DEFAULT.runner_with_config(config); - let filter = - Filter::new("testStorageCaching", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork")) - .exclude_tests(".*Revert"); + let runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.no_storage_caching = false; + }); TestConfig::with_filter(runner, filter).run().await; + + // no_storage_caching set to false: storage should be cached let cache_dir = Config::foundry_block_cache_dir(Chain::mainnet(), 19800000).unwrap(); assert!(cache_dir.exists()); diff --git a/crates/forge/tests/it/fs.rs b/crates/forge/tests/it/fs.rs index 5bb0b59fb24b3..5733ec5849b99 100644 --- a/crates/forge/tests/it/fs.rs +++ b/crates/forge/tests/it/fs.rs @@ -6,18 +6,18 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_fs_disabled() { - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.fs_permissions = FsPermissions::new(vec![PathPermission::none("./")]); - let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fs_permissions = FsPermissions::new(vec![PathPermission::none("./")]); + }); let filter = Filter::new(".*", ".*", ".*fs/Disabled"); TestConfig::with_filter(runner, filter).run().await; } #[tokio::test(flavor = "multi_thread")] async fn test_fs_default() { - let mut config = TEST_DATA_DEFAULT.config.clone(); - config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); - let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]); + }); let filter = Filter::new(".*", ".*", ".*fs/Default"); TestConfig::with_filter(runner, filter).run().await; } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 8972c9bd98f19..eaa627b9652fb 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -82,11 +82,12 @@ async fn test_successful_fuzz_cases() { #[ignore] async fn test_fuzz_collection() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzCollection.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.depth = 100; - runner.test_options.invariant.runs = 1000; - runner.test_options.fuzz.runs = 1000; - runner.test_options.fuzz.seed = Some(U256::from(6u32)); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.depth = 100; + config.invariant.runs = 1000; + config.fuzz.runs = 1000; + config.fuzz.seed = Some(U256::from(6u32)); + }); let results = runner.test_collect(&filter); assert_multiple( @@ -111,11 +112,14 @@ async fn test_fuzz_collection() { #[tokio::test(flavor = "multi_thread")] async fn test_persist_fuzz_failure() { let filter = Filter::new(".*", ".*", ".*fuzz/FuzzFailurePersist.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.runs = 1000; - macro_rules! get_failure_result { - () => { + macro_rules! run_fail { + () => { run_fail!(|config| {}) }; + (|$config:ident| $e:expr) => {{ + let mut runner = TEST_DATA_DEFAULT.runner_with(|$config| { + $config.fuzz.runs = 1000; + $e + }); runner .test_collect(&filter) .get("default/fuzz/FuzzFailurePersist.t.sol:FuzzFailurePersistTest") @@ -125,11 +129,11 @@ async fn test_persist_fuzz_failure() { .unwrap() .counterexample .clone() - }; + }}; } // record initial counterexample calldata - let initial_counterexample = get_failure_result!(); + let initial_counterexample = run_fail!(); let initial_calldata = match initial_counterexample { Some(CounterExample::Single(counterexample)) => counterexample.calldata, _ => Bytes::new(), @@ -137,7 +141,7 @@ async fn test_persist_fuzz_failure() { // run several times and compare counterexamples calldata for i in 0..10 { - let new_calldata = match get_failure_result!() { + let new_calldata = match run_fail!() { Some(CounterExample::Single(counterexample)) => counterexample.calldata, _ => Bytes::new(), }; @@ -146,8 +150,9 @@ async fn test_persist_fuzz_failure() { } // write new failure in different file - runner.test_options.fuzz.failure_persist_file = Some("failure1".to_string()); - let new_calldata = match get_failure_result!() { + let new_calldata = match run_fail!(|config| { + config.fuzz.failure_persist_file = Some("failure1".to_string()); + }) { Some(CounterExample::Single(counterexample)) => counterexample.calldata, _ => Bytes::new(), }; diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 4448f982dcd3c..eab7f9ec1bb16 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -1,15 +1,13 @@ //! Inline configuration tests. -use crate::test_helpers::{ForgeTestData, ForgeTestProfile, TEST_DATA_DEFAULT}; -use forge::{result::TestKind, TestOptionsBuilder}; -use foundry_config::{FuzzConfig, InvariantConfig}; +use crate::test_helpers::TEST_DATA_DEFAULT; +use forge::result::TestKind; use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - // Fresh runner to make sure there's no persisted failure from previous tests. - let mut runner = ForgeTestData::new(ForgeTestProfile::Default).runner(); + let mut runner = TEST_DATA_DEFAULT.runner(); let result = runner.test_collect(&filter); let results = result .into_iter() @@ -70,31 +68,3 @@ async fn inline_config_run_invariant() { _ => unreachable!(), } } - -#[test] -fn build_test_options() { - let root = &TEST_DATA_DEFAULT.project.paths.root; - let profiles = vec!["default".to_string(), "ci".to_string()]; - let build_result = TestOptionsBuilder::default() - .fuzz(FuzzConfig::default()) - .invariant(InvariantConfig::default()) - .profiles(profiles) - .build(&TEST_DATA_DEFAULT.output, root); - - assert!(build_result.is_ok()); -} - -#[test] -fn build_test_options_just_one_valid_profile() { - let root = &TEST_DATA_DEFAULT.project.root(); - let valid_profiles = vec!["profile-sheldon-cooper".to_string()]; - let build_result = TestOptionsBuilder::default() - .fuzz(FuzzConfig::default()) - .invariant(InvariantConfig::default()) - .profiles(valid_profiles) - .build(&TEST_DATA_DEFAULT.output, root); - - // We expect an error, since COMPILED contains in-line - // per-test configs for "default" and "ci" profiles - assert!(build_result.is_err()); -} diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 3e09cd465a339..2f4da40542451 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -48,8 +48,9 @@ async fn test_invariant_with_alias() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_filters() { - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.runs = 10; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.runs = 10; + }); // Contracts filter tests. assert_multiple( @@ -173,9 +174,10 @@ async fn test_invariant_filters() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_override() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantReentrancy.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.fail_on_revert = false; - runner.test_options.invariant.call_override = true; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.fail_on_revert = false; + config.invariant.call_override = true; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -189,10 +191,11 @@ async fn test_invariant_override() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_fail_on_revert() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantHandlerFailure.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.fail_on_revert = true; - runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 10; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.fail_on_revert = true; + config.invariant.runs = 1; + config.invariant.depth = 10; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -213,9 +216,13 @@ async fn test_invariant_fail_on_revert() { #[ignore] async fn test_invariant_storage() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/storage/InvariantStorageTest.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.depth = 100 + (50 * cfg!(windows) as u32); - runner.test_options.fuzz.seed = Some(U256::from(6u32)); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.depth = 100; + if cfg!(windows) { + config.invariant.depth += 50; + } + config.fuzz.seed = Some(U256::from(6u32)); + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -254,8 +261,9 @@ async fn test_invariant_inner_contract() { #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.seed = Some(U256::from(119u32)); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fuzz.seed = Some(U256::from(119u32)); + }); match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), @@ -300,10 +308,11 @@ async fn test_invariant_require_shrink() { async fn check_shrink_sequence(test_pattern: &str, expected_len: usize) { let filter = Filter::new(test_pattern, ".*", ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.seed = Some(U256::from(100u32)); - runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 15; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fuzz.seed = Some(U256::from(100u32)); + config.invariant.runs = 1; + config.invariant.depth = 15; + }); match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), @@ -318,10 +327,11 @@ async fn check_shrink_sequence(test_pattern: &str, expected_len: usize) { async fn test_shrink_big_sequence() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantShrinkBigSequence.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.seed = Some(U256::from(119u32)); - runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 1000; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fuzz.seed = Some(U256::from(119u32)); + config.invariant.runs = 1; + config.invariant.depth = 1000; + }); let initial_counterexample = runner .test_collect(&filter) @@ -390,11 +400,12 @@ async fn test_shrink_big_sequence() { async fn test_shrink_fail_on_revert() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.seed = Some(U256::from(119u32)); - runner.test_options.invariant.fail_on_revert = true; - runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 200; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fuzz.seed = Some(U256::from(119u32)); + config.invariant.fail_on_revert = true; + config.invariant.runs = 1; + config.invariant.depth = 200; + }); match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), @@ -408,8 +419,9 @@ async fn test_shrink_fail_on_revert() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_preserve_state() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantPreserveState.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.fail_on_revert = true; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.fail_on_revert = true; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -452,9 +464,10 @@ async fn test_invariant_with_address_fixture() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_assume_does_not_revert() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAssume.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - // Should not treat vm.assume as revert. - runner.test_options.invariant.fail_on_revert = true; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + // Should not treat vm.assume as revert. + config.invariant.fail_on_revert = true; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -468,10 +481,11 @@ async fn test_invariant_assume_does_not_revert() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_assume_respects_restrictions() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantAssume.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 10; - runner.test_options.invariant.max_assume_rejects = 1; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.runs = 1; + config.invariant.depth = 10; + config.invariant.max_assume_rejects = 1; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -491,8 +505,9 @@ async fn test_invariant_assume_respects_restrictions() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_decode_custom_error() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantCustomError.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.fail_on_revert = true; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.fail_on_revert = true; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -512,8 +527,9 @@ async fn test_invariant_decode_custom_error() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_fuzzed_selected_targets() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/target/FuzzedTargetContracts.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.fail_on_revert = true; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.fail_on_revert = true; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -539,9 +555,10 @@ async fn test_invariant_fuzzed_selected_targets() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_fixtures() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantFixtures.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 100; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.runs = 1; + config.invariant.depth = 100; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -592,8 +609,9 @@ async fn test_invariant_scrape_values() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_roll_fork_handler() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantRollFork.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.seed = Some(U256::from(119u32)); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fuzz.seed = Some(U256::from(119u32)); + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -625,8 +643,9 @@ async fn test_invariant_roll_fork_handler() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_excluded_senders() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantExcludedSenders.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.fail_on_revert = true; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.fail_on_revert = true; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -670,10 +689,11 @@ async fn test_invariant_after_invariant() { #[tokio::test(flavor = "multi_thread")] async fn test_invariant_selectors_weight() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantSelectorsWeight.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.fuzz.seed = Some(U256::from(119u32)); - runner.test_options.invariant.runs = 1; - runner.test_options.invariant.depth = 10; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fuzz.seed = Some(U256::from(119u32)); + config.invariant.runs = 1; + config.invariant.depth = 10; + }); let results = runner.test_collect(&filter); assert_multiple( &results, @@ -688,10 +708,11 @@ async fn test_invariant_selectors_weight() { async fn test_no_reverts_in_counterexample() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantSequenceNoReverts.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); - runner.test_options.invariant.fail_on_revert = false; - // Use original counterexample to test sequence len. - runner.test_options.invariant.shrink_run_limit = 0; + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.invariant.fail_on_revert = false; + // Use original counterexample to test sequence len. + config.invariant.shrink_run_limit = 0; + }); match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 53185cf978560..69c3a0fb35f70 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -1,11 +1,6 @@ //! Regression tests for previous issues. -use std::sync::Arc; - -use crate::{ - config::*, - test_helpers::{ForgeTestData, TEST_DATA_DEFAULT}, -}; +use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_dyn_abi::{DecodedEvent, DynSolValue, EventExt}; use alloy_json_abi::Event; use alloy_primitives::{address, b256, Address, U256}; @@ -19,6 +14,7 @@ use foundry_evm::{ traces::{CallKind, CallTraceDecoder, DecodedCallData, TraceKind}, }; use foundry_test_utils::Filter; +use std::sync::Arc; /// Creates a test that runs `testdata/repros/Issue{issue}.t.sol`. macro_rules! test_repro { @@ -33,7 +29,7 @@ macro_rules! test_repro { #[tokio::test(flavor = "multi_thread")] $(#[$attr])* async fn [< issue_ $issue_number >]() { - repro_config($issue_number, $should_fail, $sender.into(), &*TEST_DATA_DEFAULT).await.run().await; + repro_config($issue_number, $should_fail, $sender.into()).await.run().await; } } }; @@ -42,7 +38,7 @@ macro_rules! test_repro { #[tokio::test(flavor = "multi_thread")] $(#[$attr])* async fn [< issue_ $issue_number >]() { - let mut $res = repro_config($issue_number, $should_fail, $sender.into(), &*TEST_DATA_DEFAULT).await.test(); + let mut $res = repro_config($issue_number, $should_fail, $sender.into()).await.test(); $e } } @@ -52,7 +48,7 @@ macro_rules! test_repro { #[tokio::test(flavor = "multi_thread")] $(#[$attr])* async fn [< issue_ $issue_number >]() { - let mut $config = repro_config($issue_number, false, None, &*TEST_DATA_DEFAULT).await; + let mut $config = repro_config($issue_number, false, None).await; $e $config.run().await; } @@ -60,23 +56,19 @@ macro_rules! test_repro { }; } -async fn repro_config( - issue: usize, - should_fail: bool, - sender: Option

, - test_data: &ForgeTestData, -) -> TestConfig { +async fn repro_config(issue: usize, should_fail: bool, sender: Option
) -> TestConfig { foundry_test_utils::init_tracing(); let filter = Filter::path(&format!(".*repros/Issue{issue}.t.sol")); - let mut config = test_data.config.clone(); - config.fs_permissions = - FsPermissions::new(vec![PathPermission::read("./fixtures"), PathPermission::read("out")]); - if let Some(sender) = sender { - config.sender = sender; - } - - let runner = TEST_DATA_DEFAULT.runner_with_config(config); + let runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.fs_permissions = FsPermissions::new(vec![ + PathPermission::read("./fixtures"), + PathPermission::read("out"), + ]); + if let Some(sender) = sender { + config.sender = sender; + } + }); TestConfig::with_filter(runner, filter).set_should_fail(should_fail) } diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 5e540d8c67aa0..298bbae2971d8 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -4,7 +4,6 @@ use alloy_chains::NamedChain; use alloy_primitives::U256; use forge::{ revm::primitives::SpecId, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, - TestOptionsBuilder, }; use foundry_compilers::{ artifacts::{EvmVersion, Libraries, Settings}, @@ -15,10 +14,7 @@ use foundry_config::{ fs_permissions::PathPermission, Config, FsPermissions, FuzzConfig, FuzzDictionaryConfig, InvariantConfig, RpcEndpoint, RpcEndpoints, }; -use foundry_evm::{ - constants::CALLER, - opts::{Env, EvmOpts}, -}; +use foundry_evm::{constants::CALLER, opts::EvmOpts}; use foundry_test_utils::{fd_lock, init_tracing, rpc::next_rpc_endpoint}; use std::{ env, fmt, @@ -74,69 +70,6 @@ impl ForgeTestProfile { SolcConfig { settings } } - pub fn project(&self) -> Project { - self.config().project().expect("Failed to build project") - } - - pub fn test_opts(&self, output: &ProjectCompileOutput) -> TestOptions { - TestOptionsBuilder::default() - .fuzz(FuzzConfig { - runs: 256, - max_test_rejects: 65536, - seed: None, - dictionary: FuzzDictionaryConfig { - include_storage: true, - include_push_bytes: true, - dictionary_weight: 40, - max_fuzz_dictionary_addresses: 10_000, - max_fuzz_dictionary_values: 10_000, - }, - gas_report_samples: 256, - failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), - failure_persist_file: Some("testfailure".to_string()), - show_logs: false, - }) - .invariant(InvariantConfig { - runs: 256, - depth: 15, - fail_on_revert: false, - call_override: false, - dictionary: FuzzDictionaryConfig { - dictionary_weight: 80, - include_storage: true, - include_push_bytes: true, - max_fuzz_dictionary_addresses: 10_000, - max_fuzz_dictionary_values: 10_000, - }, - shrink_run_limit: 5000, - max_assume_rejects: 65536, - gas_report_samples: 256, - failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), - show_metrics: false, - }) - .build(output, Path::new(self.project().root())) - .expect("Config loaded") - } - - pub fn evm_opts(&self) -> EvmOpts { - EvmOpts { - env: Env { - gas_limit: u64::MAX, - chain_id: None, - tx_origin: CALLER, - block_number: 1, - block_timestamp: 1, - ..Default::default() - }, - sender: CALLER, - initial_balance: U256::MAX, - ffi: true, - verbosity: 3, - memory_limit: 1 << 26, - ..Default::default() - } - } - /// Build [Config] for test profile. /// /// Project source files are read from testdata/{profile_name} @@ -155,11 +88,66 @@ impl ForgeTestProfile { "fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string(), ]; + config.prompt_timeout = 0; + + config.gas_limit = u64::MAX.into(); + config.chain = None; + config.tx_origin = CALLER; + config.block_number = 1; + config.block_timestamp = 1; + + config.sender = CALLER; + config.initial_balance = U256::MAX; + config.ffi = true; + config.verbosity = 3; + config.memory_limit = 1 << 26; + if self.is_paris() { config.evm_version = EvmVersion::Paris; } - config + config.fuzz = FuzzConfig { + runs: 256, + max_test_rejects: 65536, + seed: None, + dictionary: FuzzDictionaryConfig { + include_storage: true, + include_push_bytes: true, + dictionary_weight: 40, + max_fuzz_dictionary_addresses: 10_000, + max_fuzz_dictionary_values: 10_000, + }, + gas_report_samples: 256, + failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), + failure_persist_file: Some("testfailure".to_string()), + show_logs: false, + }; + config.invariant = InvariantConfig { + runs: 256, + depth: 15, + fail_on_revert: false, + call_override: false, + dictionary: FuzzDictionaryConfig { + dictionary_weight: 80, + include_storage: true, + include_push_bytes: true, + max_fuzz_dictionary_addresses: 10_000, + max_fuzz_dictionary_values: 10_000, + }, + shrink_run_limit: 5000, + max_assume_rejects: 65536, + gas_report_samples: 256, + failure_persist_dir: Some( + tempfile::Builder::new() + .prefix(&format!("foundry-{self}")) + .tempdir() + .unwrap() + .into_path(), + ), + show_metrics: false, + }; + + config.sanitized() } } @@ -167,9 +155,7 @@ impl ForgeTestProfile { pub struct ForgeTestData { pub project: Project, pub output: ProjectCompileOutput, - pub test_opts: TestOptions, - pub evm_opts: EvmOpts, - pub config: Config, + pub config: Arc, pub profile: ForgeTestProfile, } @@ -179,67 +165,63 @@ impl ForgeTestData { /// Uses [get_compiled] to lazily compile the project. pub fn new(profile: ForgeTestProfile) -> Self { init_tracing(); - - let mut project = profile.project(); + let config = Arc::new(profile.config()); + let mut project = config.project().unwrap(); let output = get_compiled(&mut project); - let test_opts = profile.test_opts(&output); - let config = profile.config(); - let evm_opts = profile.evm_opts(); - - Self { project, output, test_opts, evm_opts, config, profile } + Self { project, output, config, profile } } /// Builds a base runner pub fn base_runner(&self) -> MultiContractRunnerBuilder { init_tracing(); - let mut runner = MultiContractRunnerBuilder::new(Arc::new(self.config.clone())) - .sender(self.evm_opts.sender) - .with_test_options(self.test_opts.clone()); + let config = self.config.clone(); + let mut runner = MultiContractRunnerBuilder::new(config.clone()) + .sender(self.config.sender) + .with_test_options(TestOptions::new_unparsed(config)); if self.profile.is_paris() { runner = runner.evm_spec(SpecId::MERGE); } - runner } /// Builds a non-tracing runner pub fn runner(&self) -> MultiContractRunner { - let mut config = self.config.clone(); - config.fs_permissions = - FsPermissions::new(vec![PathPermission::read_write(manifest_root())]); - self.runner_with_config(config) + self.runner_with(|_| {}) } /// Builds a non-tracing runner - pub fn runner_with_config(&self, mut config: Config) -> MultiContractRunner { + pub fn runner_with(&self, modify: impl FnOnce(&mut Config)) -> MultiContractRunner { + let mut config = (*self.config).clone(); + modify(&mut config); + self.runner_with_config(config) + } + + fn runner_with_config(&self, mut config: Config) -> MultiContractRunner { config.rpc_endpoints = rpc_endpoints(); config.allow_paths.push(manifest_root().to_path_buf()); - // no prompt testing - config.prompt_timeout = 0; - - let root = self.project.root(); - let mut opts = self.evm_opts.clone(); - - if config.isolate { - opts.isolate = true; + if config.fs_permissions.is_empty() { + config.fs_permissions = + FsPermissions::new(vec![PathPermission::read_write(manifest_root())]); } - let sender = config.sender; + let opts = config_evm_opts(&config); let mut builder = self.base_runner(); - builder.config = Arc::new(config); + let config = Arc::new(config); + let root = self.project.root(); + builder.config = config.clone(); builder .enable_isolation(opts.isolate) - .sender(sender) - .with_test_options(self.test_opts.clone()) + .sender(config.sender) + .with_test_options(TestOptions::new(&self.output, config.clone()).unwrap()) .build(root, &self.output, opts.local_evm_env(), opts) .unwrap() } /// Builds a tracing runner pub fn tracing_runner(&self) -> MultiContractRunner { - let mut opts = self.evm_opts.clone(); + let mut opts = config_evm_opts(&self.config); opts.verbosity = 5; self.base_runner() .build(self.project.root(), &self.output, opts.local_evm_env(), opts) @@ -248,7 +230,7 @@ impl ForgeTestData { /// Builds a runner that runs against forked state pub async fn forked_runner(&self, rpc: &str) -> MultiContractRunner { - let mut opts = self.evm_opts.clone(); + let mut opts = config_evm_opts(&self.config); opts.env.chain_id = None; // clear chain id so the correct one gets fetched from the RPC opts.fork_url = Some(rpc.to_string()); @@ -369,3 +351,7 @@ pub fn rpc_endpoints() -> RpcEndpoints { ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".into())), ]) } + +fn config_evm_opts(config: &Config) -> EvmOpts { + config.to_figment(foundry_config::FigmentProviders::None).extract().unwrap() +} diff --git a/crates/test-utils/src/filter.rs b/crates/test-utils/src/filter.rs index 003b0170fca84..1ba905d27d8c9 100644 --- a/crates/test-utils/src/filter.rs +++ b/crates/test-utils/src/filter.rs @@ -2,6 +2,7 @@ use foundry_common::TestFilter; use regex::Regex; use std::path::Path; +#[derive(Clone, Debug)] pub struct Filter { test_regex: Regex, contract_regex: Regex, From 20905ef9491f86c45415bf8ec764fbda31b83f54 Mon Sep 17 00:00:00 2001 From: Delweng Date: Fri, 29 Nov 2024 03:56:28 +0800 Subject: [PATCH 1733/1963] chore: rename the arg name of EvmOpts from evm_opts to evm_args (#9424) * script: evm_opts -> evm_args Signed-off-by: jsvisa * forge: evm_opts -> evm_args Signed-off-by: jsvisa * chisel: evm_opts -> evm_args Signed-off-by: jsvisa * forge: evm_opts -> evm_args Signed-off-by: jsvisa --------- Signed-off-by: jsvisa --- crates/chisel/bin/main.rs | 4 ++-- crates/forge/bin/cmd/config.rs | 4 ++-- crates/forge/bin/cmd/debug.rs | 6 +++--- crates/forge/bin/cmd/mod.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 6 +++--- crates/script/src/execute.rs | 2 +- crates/script/src/lib.rs | 10 +++++----- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index acc2c6f172634..ca3fc1ff593ec 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -35,7 +35,7 @@ extern crate foundry_common; static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; // Loads project's figment and merges the build cli arguments into it -foundry_config::merge_impl_figment_convert!(Chisel, opts, evm_opts); +foundry_config::merge_impl_figment_convert!(Chisel, opts, evm_args); const VERSION_MESSAGE: &str = concat!( env!("CARGO_PKG_VERSION"), @@ -76,7 +76,7 @@ pub struct Chisel { pub opts: CoreBuildArgs, #[command(flatten)] - pub evm_opts: EvmArgs, + pub evm_args: EvmArgs, } /// Chisel binary subcommands diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index 36f4d1731f4b1..0aa1fdb6322ac 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -5,7 +5,7 @@ use foundry_cli::utils::LoadConfig; use foundry_common::{evm::EvmArgs, shell}; use foundry_config::fix::fix_tomls; -foundry_config::impl_figment_convert!(ConfigArgs, opts, evm_opts); +foundry_config::impl_figment_convert!(ConfigArgs, opts, evm_args); /// CLI arguments for `forge config`. #[derive(Clone, Debug, Parser)] @@ -23,7 +23,7 @@ pub struct ConfigArgs { opts: BuildArgs, #[command(flatten)] - evm_opts: EvmArgs, + evm_args: EvmArgs, } impl ConfigArgs { diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs index 421478bd5762c..5ccfc13d57d09 100644 --- a/crates/forge/bin/cmd/debug.rs +++ b/crates/forge/bin/cmd/debug.rs @@ -6,7 +6,7 @@ use foundry_common::evm::EvmArgs; use std::path::PathBuf; // Loads project's figment and merges the build cli arguments into it -foundry_config::impl_figment_convert!(DebugArgs, opts, evm_opts); +foundry_config::impl_figment_convert!(DebugArgs, opts, evm_args); /// CLI arguments for `forge debug`. #[derive(Clone, Debug, Parser)] @@ -46,7 +46,7 @@ pub struct DebugArgs { pub opts: CoreBuildArgs, #[command(flatten)] - pub evm_opts: EvmArgs, + pub evm_args: EvmArgs, } impl DebugArgs { @@ -58,7 +58,7 @@ impl DebugArgs { sig: self.sig, gas_estimate_multiplier: 130, opts: self.opts, - evm_opts: self.evm_opts, + evm_args: self.evm_args, debug: true, dump: self.dump, retry: RETRY_VERIFY_ON_CREATE, diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index f2de1d6321d51..427b25fb0c50d 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -24,7 +24,7 @@ //! #[derive(Clone, Debug, Parser)] //! pub struct MyArgs { //! #[command(flatten)] -//! evm_opts: EvmArgs, +//! evm_args: EvmArgs, //! #[command(flatten)] //! opts: BuildArgs, //! } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 6e19c96d08d76..982a8f0a3d262 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -59,7 +59,7 @@ pub use filter::FilterArgs; use forge::{result::TestKind, traces::render_trace_arena_inner}; // Loads project's figment and merges the build cli arguments into it -foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts); +foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_args); /// CLI arguments for `forge test`. #[derive(Clone, Debug, Parser)] @@ -162,7 +162,7 @@ pub struct TestArgs { pub rerun: bool, #[command(flatten)] - evm_opts: EvmArgs, + evm_args: EvmArgs, #[command(flatten)] opts: CoreBuildArgs, @@ -1001,7 +1001,7 @@ mod tests { fn extract_chain() { let test = |arg: &str, expected: Chain| { let args = TestArgs::parse_from(["foundry-cli", arg]); - assert_eq!(args.evm_opts.env.chain, Some(expected)); + assert_eq!(args.evm_args.env.chain, Some(expected)); let (config, evm_opts) = args.load_config_and_evm_opts().unwrap(); assert_eq!(config.chain, Some(expected)); assert_eq!(evm_opts.env.chain_id, Some(expected.id())); diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 51ab0141456b8..3e6cc30a12423 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -189,7 +189,7 @@ impl PreExecutionState { if let Some(txs) = transactions { // If the user passed a `--sender` don't check anything. if self.build_data.predeploy_libraries.libraries_count() > 0 && - self.args.evm_opts.sender.is_none() + self.args.evm_args.sender.is_none() { for tx in txs.iter() { if tx.transaction.to().is_none() { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 517eff552fd0a..6ccc818410a41 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -73,7 +73,7 @@ mod transaction; mod verify; // Loads project's figment and merges the build cli arguments into it -foundry_config::merge_impl_figment_convert!(ScriptArgs, opts, evm_opts); +foundry_config::merge_impl_figment_convert!(ScriptArgs, opts, evm_args); /// CLI arguments for `forge script`. #[derive(Clone, Debug, Default, Parser)] @@ -210,7 +210,7 @@ pub struct ScriptArgs { pub wallets: MultiWalletOpts, #[command(flatten)] - pub evm_opts: EvmArgs, + pub evm_args: EvmArgs, #[command(flatten)] pub verifier: forge_verify::VerifierArgs, @@ -222,7 +222,7 @@ pub struct ScriptArgs { impl ScriptArgs { pub async fn preprocess(self) -> Result { let script_wallets = - Wallets::new(self.wallets.get_multi_wallet().await?, self.evm_opts.sender); + Wallets::new(self.wallets.get_multi_wallet().await?, self.evm_args.sender); let (config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; @@ -411,7 +411,7 @@ impl ScriptArgs { } let mut prompt_user = false; - let max_size = match self.evm_opts.env.code_size_limit { + let max_size = match self.evm_args.env.code_size_limit { Some(size) => size, None => CONTRACT_MAX_SIZE, }; @@ -723,7 +723,7 @@ mod tests { "--code-size-limit", "50000", ]); - assert_eq!(args.evm_opts.env.code_size_limit, Some(50000)); + assert_eq!(args.evm_args.env.code_size_limit, Some(50000)); } #[test] From 27cabbd6c905b1273a5ed3ba7c10acce90833d76 Mon Sep 17 00:00:00 2001 From: Voronor <129545215+voronor@users.noreply.github.com> Date: Thu, 28 Nov 2024 20:57:46 +0100 Subject: [PATCH 1734/1963] Fix conditional syntax issue in macOS libusb check (#9384) This pull request addresses a minor but important syntax issue in the conditional statement used to check for the presence of libusb on macOS. --- foundryup/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundryup/install b/foundryup/install index 1a8bc8c6ed5ad..22870f939a930 100755 --- a/foundryup/install +++ b/foundryup/install @@ -54,7 +54,7 @@ if [[ ":$PATH:" != *":${FOUNDRY_BIN_DIR}:"* ]]; then fi # Warn MacOS users that they may need to manually install libusb via Homebrew: -if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/libusb/lib/libusb-1.0.0.dylib && ! -f /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib ]]; then +if [[ "$OSTYPE" =~ ^darwin ]] && [[ ! -f /usr/local/opt/libusb/lib/libusb-1.0.0.dylib ]] && [[ ! -f /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib ]]; then echo && echo "warning: libusb not found. You may need to install it manually on MacOS via Homebrew (brew install libusb)." fi From 2e9f53632a787323318e4575d7a0325ef3e7cc84 Mon Sep 17 00:00:00 2001 From: smartcontracts Date: Fri, 29 Nov 2024 01:21:24 -0500 Subject: [PATCH 1735/1963] feat: add timeouts to fuzz testing (#9394) * feat: add timeouts to fuzz testing Adds --fuzz-timeout-secs to fuzz tests which will cause a property test to timeout after a certain number of seconds. Also adds --fuzz-allow-timeouts so that timeouts are optionally not considered to be failures. * simplify timeout implementation * use u32 for timeout * switch back to failing for timeouts * clippy * Nits: - move logic to interrupt invariant test in depth loop - add and reuse start_timer fn and TEST_TIMEOUT constant - add fuzz and invariant tests - fix failing test * Fix fmt * Changes after review: introduce FuzzTestTimer --------- Co-authored-by: grandizzy --- crates/config/src/fuzz.rs | 3 ++ crates/config/src/invariant.rs | 4 ++ crates/evm/core/src/constants.rs | 3 ++ crates/evm/evm/src/executors/fuzz/mod.rs | 34 +++++++++---- crates/evm/evm/src/executors/invariant/mod.rs | 15 +++++- crates/evm/evm/src/executors/mod.rs | 22 +++++++- crates/forge/bin/cmd/test/mod.rs | 7 +++ crates/forge/tests/it/fuzz.rs | 35 +++++++++++++ crates/forge/tests/it/invariant.rs | 50 +++++++++++++++++++ crates/forge/tests/it/test_helpers.rs | 2 + 10 files changed, 162 insertions(+), 13 deletions(-) diff --git a/crates/config/src/fuzz.rs b/crates/config/src/fuzz.rs index ae3d3c7967013..26e1c080cbc8d 100644 --- a/crates/config/src/fuzz.rs +++ b/crates/config/src/fuzz.rs @@ -28,6 +28,8 @@ pub struct FuzzConfig { pub failure_persist_file: Option, /// show `console.log` in fuzz test, defaults to `false` pub show_logs: bool, + /// Optional timeout (in seconds) for each property test + pub timeout: Option, } impl Default for FuzzConfig { @@ -41,6 +43,7 @@ impl Default for FuzzConfig { failure_persist_dir: None, failure_persist_file: None, show_logs: false, + timeout: None, } } } diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 97f189b363d18..334cf3b87b995 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -30,6 +30,8 @@ pub struct InvariantConfig { pub failure_persist_dir: Option, /// Whether to collect and display fuzzed selectors metrics. pub show_metrics: bool, + /// Optional timeout (in seconds) for each invariant test. + pub timeout: Option, } impl Default for InvariantConfig { @@ -45,6 +47,7 @@ impl Default for InvariantConfig { gas_report_samples: 256, failure_persist_dir: None, show_metrics: false, + timeout: None, } } } @@ -63,6 +66,7 @@ impl InvariantConfig { gas_report_samples: 256, failure_persist_dir: Some(cache_dir), show_metrics: false, + timeout: None, } } diff --git a/crates/evm/core/src/constants.rs b/crates/evm/core/src/constants.rs index 70c7441d20a77..cebbdcb87c796 100644 --- a/crates/evm/core/src/constants.rs +++ b/crates/evm/core/src/constants.rs @@ -37,6 +37,9 @@ pub const MAGIC_ASSUME: &[u8] = b"FOUNDRY::ASSUME"; /// Magic return value returned by the `skip` cheatcode. Optionally appended with a reason. pub const MAGIC_SKIP: &[u8] = b"FOUNDRY::SKIP"; +/// Test timeout return value. +pub const TEST_TIMEOUT: &str = "FOUNDRY::TEST_TIMEOUT"; + /// The address that deploys the default CREATE2 deployer contract. pub const DEFAULT_CREATE2_DEPLOYER_DEPLOYER: Address = address!("3fAB184622Dc19b6109349B94811493BF2a45362"); diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 2bbe80a63eadb..0d79f8fa49610 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -1,4 +1,4 @@ -use crate::executors::{Executor, RawCallResult}; +use crate::executors::{Executor, FuzzTestTimer, RawCallResult}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::Function; use alloy_primitives::{map::HashMap, Address, Bytes, Log, U256}; @@ -6,7 +6,7 @@ use eyre::Result; use foundry_common::evm::Breakpoints; use foundry_config::FuzzConfig; use foundry_evm_core::{ - constants::MAGIC_ASSUME, + constants::{MAGIC_ASSUME, TEST_TIMEOUT}, decode::{RevertDecoder, SkipReason}, }; use foundry_evm_coverage::HitMaps; @@ -98,7 +98,15 @@ impl FuzzedExecutor { let max_traces_to_collect = std::cmp::max(1, self.config.gas_report_samples) as usize; let show_logs = self.config.show_logs; + // Start timer for this fuzz test. + let timer = FuzzTestTimer::new(self.config.timeout); + let run_result = self.runner.clone().run(&strategy, |calldata| { + // Check if the timeout has been reached. + if timer.is_timed_out() { + return Err(TestCaseError::fail(TEST_TIMEOUT)); + } + let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; // If running with progress then increment current run. @@ -193,17 +201,21 @@ impl FuzzedExecutor { } Err(TestError::Fail(reason, _)) => { let reason = reason.to_string(); - result.reason = (!reason.is_empty()).then_some(reason); - - let args = if let Some(data) = calldata.get(4..) { - func.abi_decode_input(data, false).unwrap_or_default() + if reason == TEST_TIMEOUT { + // If the reason is a timeout, we consider the fuzz test successful. + result.success = true; } else { - vec![] - }; + result.reason = (!reason.is_empty()).then_some(reason); + let args = if let Some(data) = calldata.get(4..) { + func.abi_decode_input(data, false).unwrap_or_default() + } else { + vec![] + }; - result.counterexample = Some(CounterExample::Single( - BaseCounterExample::from_fuzz_call(calldata, args, call.traces), - )); + result.counterexample = Some(CounterExample::Single( + BaseCounterExample::from_fuzz_call(calldata, args, call.traces), + )); + } } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index f98dd21114cbb..d5fdb5668f5ee 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -10,6 +10,7 @@ use foundry_config::InvariantConfig; use foundry_evm_core::{ constants::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME, + TEST_TIMEOUT, }, precompiles::PRECOMPILES, }; @@ -49,7 +50,7 @@ pub use result::InvariantFuzzTestResult; use serde::{Deserialize, Serialize}; mod shrink; -use crate::executors::EvmError; +use crate::executors::{EvmError, FuzzTestTimer}; pub use shrink::check_sequence; sol! { @@ -332,6 +333,9 @@ impl<'a> InvariantExecutor<'a> { let (invariant_test, invariant_strategy) = self.prepare_test(&invariant_contract, fuzz_fixtures)?; + // Start timer for this invariant test. + let timer = FuzzTestTimer::new(self.config.timeout); + let _ = self.runner.run(&invariant_strategy, |first_input| { // Create current invariant run data. let mut current_run = InvariantTestRun::new( @@ -347,6 +351,15 @@ impl<'a> InvariantExecutor<'a> { } while current_run.depth < self.config.depth { + // Check if the timeout has been reached. + if timer.is_timed_out() { + // Since we never record a revert here the test is still considered + // successful even though it timed out. We *want* + // this behavior for now, so that's ok, but + // future developers should be aware of this. + return Err(TestCaseError::fail(TEST_TIMEOUT)); + } + let tx = current_run.inputs.last().ok_or_else(|| { TestCaseError::fail("No input generated to call fuzzed target.") })?; diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index b5b31b812298b..2ccfad9e2a583 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -35,7 +35,10 @@ use revm::{ ResultAndState, SignedAuthorization, SpecId, TxEnv, TxKind, }, }; -use std::borrow::Cow; +use std::{ + borrow::Cow, + time::{Duration, Instant}, +}; mod builder; pub use builder::ExecutorBuilder; @@ -952,3 +955,20 @@ fn convert_executed_result( chisel_state, }) } + +/// Timer for a fuzz test. +pub struct FuzzTestTimer { + /// Inner fuzz test timer - (test start time, test duration). + inner: Option<(Instant, Duration)>, +} + +impl FuzzTestTimer { + pub fn new(timeout: Option) -> Self { + Self { inner: timeout.map(|timeout| (Instant::now(), Duration::from_secs(timeout.into()))) } + } + + /// Whether the current fuzz test timed out and should be stopped. + pub fn is_timed_out(&self) -> bool { + self.inner.is_some_and(|(start, duration)| start.elapsed() > duration) + } +} diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 982a8f0a3d262..18ab08d6d152a 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -145,6 +145,10 @@ pub struct TestArgs { #[arg(long, env = "FOUNDRY_FUZZ_RUNS", value_name = "RUNS")] pub fuzz_runs: Option, + /// Timeout for each fuzz run in seconds. + #[arg(long, env = "FOUNDRY_FUZZ_TIMEOUT", value_name = "TIMEOUT")] + pub fuzz_timeout: Option, + /// File to rerun fuzz failures from. #[arg(long)] pub fuzz_input_file: Option, @@ -864,6 +868,9 @@ impl Provider for TestArgs { if let Some(fuzz_runs) = self.fuzz_runs { fuzz_dict.insert("runs".to_string(), fuzz_runs.into()); } + if let Some(fuzz_timeout) = self.fuzz_timeout { + fuzz_dict.insert("timeout".to_string(), fuzz_timeout.into()); + } if let Some(fuzz_input_file) = self.fuzz_input_file.clone() { fuzz_dict.insert("failure_persist_file".to_string(), fuzz_input_file.into()); } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index eaa627b9652fb..8b49d4accad31 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -240,3 +240,38 @@ contract InlineMaxRejectsTest is Test { ... "#]]); }); + +// Tests that test timeout config is properly applied. +// If test doesn't timeout after one second, then test will fail with `rejected too many inputs`. +forgetest_init!(test_fuzz_timeout, |prj, cmd| { + prj.wipe_contracts(); + + prj.add_test( + "Contract.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract FuzzTimeoutTest is Test { + /// forge-config: default.fuzz.max-test-rejects = 10000 + /// forge-config: default.fuzz.timeout = 1 + function test_fuzz_bound(uint256 a) public pure { + vm.assume(a == 0); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/Contract.t.sol:FuzzTimeoutTest +[PASS] test_fuzz_bound(uint256) (runs: [..], [AVG_GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); +}); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 2f4da40542451..76afd5b36a772 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -949,3 +949,53 @@ Ran 2 tests for test/SelectorMetricsTest.t.sol:CounterTest ... "#]]); }); + +// Tests that invariant exists with success after configured timeout. +forgetest_init!(should_apply_configured_timeout, |prj, cmd| { + // Add initial test that breaks invariant. + prj.add_test( + "TimeoutTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract TimeoutHandler is Test { + uint256 public count; + + function increment() public { + count++; + } +} + +contract TimeoutTest is Test { + TimeoutHandler handler; + + function setUp() public { + handler = new TimeoutHandler(); + } + + /// forge-config: default.invariant.runs = 10000 + /// forge-config: default.invariant.depth = 20000 + /// forge-config: default.invariant.timeout = 1 + function invariant_counter_timeout() public view { + // Invariant will fail if more than 10000 increments. + // Make sure test timeouts after one second and remaining runs are canceled. + require(handler.count() < 10000); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "invariant_counter_timeout"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/TimeoutTest.t.sol:TimeoutTest +[PASS] invariant_counter_timeout() (runs: 0, calls: 0, reverts: 0) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); +}); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 298bbae2971d8..54985b9b6154e 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -121,6 +121,7 @@ impl ForgeTestProfile { failure_persist_dir: Some(tempfile::tempdir().unwrap().into_path()), failure_persist_file: Some("testfailure".to_string()), show_logs: false, + timeout: None, }; config.invariant = InvariantConfig { runs: 256, @@ -145,6 +146,7 @@ impl ForgeTestProfile { .into_path(), ), show_metrics: false, + timeout: None, }; config.sanitized() From 0d76df57a28236908084f21c965b20e30ed9dfdd Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 29 Nov 2024 09:52:07 +0200 Subject: [PATCH 1736/1963] feat(`cast`): `decode-error` with sig, local cache and openchain api (#9428) * feat(cast): Add custom error decoding support * Review changes * Changes after review: decode with Openchain too, add test * Review changes: nit, handle incomplete selectors --- crates/cast/bin/args.rs | 10 ++++ crates/cast/bin/main.rs | 27 ++++++++- crates/cast/tests/cli/main.rs | 56 ++++++++++++++++++- crates/cli/src/utils/cmd.rs | 3 + crates/common/src/abi.rs | 7 ++- crates/common/src/selectors.rs | 12 ++-- .../evm/traces/src/identifier/signatures.rs | 21 ++++++- 7 files changed, 124 insertions(+), 12 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 7078810e4ce91..e4cf32639d4b6 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -539,6 +539,16 @@ pub enum CastSubcommand { data: String, }, + /// Decode custom error data. + #[command(visible_aliases = &["error-decode", "--error-decode", "erd"])] + DecodeError { + /// The error signature. If none provided then tries to decode from local cache or `https://api.openchain.xyz`. + #[arg(long, visible_alias = "error-sig")] + sig: Option, + /// The error data to decode. + data: String, + }, + /// Decode ABI-encoded input or output data. /// /// Defaults to decoding output data. To decode input data pass --input. diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 21b1df36d6cdc..cacddb8344f54 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate tracing; -use alloy_dyn_abi::{DynSolValue, EventExt}; +use alloy_dyn_abi::{DynSolValue, ErrorExt, EventExt}; use alloy_primitives::{eip191_hash_message, hex, keccak256, Address, B256}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, BlockNumberOrTag::Latest}; @@ -11,7 +11,7 @@ use clap_complete::generate; use eyre::Result; use foundry_cli::{handler, utils}; use foundry_common::{ - abi::get_event, + abi::{get_error, get_event}, ens::{namehash, ProviderEnsExt}, fmt::{format_tokens, format_tokens_raw, format_uint_exp}, fs, @@ -30,6 +30,7 @@ pub mod cmd; pub mod tx; use args::{Cast as CastArgs, CastSubcommand, ToBaseArgs}; +use cast::traces::identifier::SignaturesIdentifier; #[macro_use] extern crate foundry_common; @@ -216,6 +217,28 @@ async fn main_args(args: CastArgs) -> Result<()> { let decoded_event = event.decode_log_parts(None, &hex::decode(data)?, false)?; print_tokens(&decoded_event.body); } + CastSubcommand::DecodeError { sig, data } => { + let error = if let Some(err_sig) = sig { + get_error(err_sig.as_str())? + } else { + let data = data.strip_prefix("0x").unwrap_or(data.as_str()); + let selector = data.get(..8).unwrap_or_default(); + let identified_error = + SignaturesIdentifier::new(Config::foundry_cache_dir(), false)? + .write() + .await + .identify_error(&hex::decode(selector)?) + .await; + if let Some(error) = identified_error { + let _ = sh_println!("{}", error.signature()); + error + } else { + eyre::bail!("No matching error signature found for selector `{selector}`") + } + }; + let decoded_error = error.decode_error(&hex::decode(data)?)?; + print_tokens(&decoded_error.body); + } CastSubcommand::Interface(cmd) => cmd.run().await?, CastSubcommand::CreationCode(cmd) => cmd.run().await?, CastSubcommand::ConstructorArgs(cmd) => cmd.run().await?, diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index d2c70a779e65a..0cd43766e3e13 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -6,7 +6,7 @@ use alloy_primitives::{b256, B256}; use alloy_rpc_types::{BlockNumberOrTag, Index}; use anvil::{EthereumHardfork, NodeConfig}; use foundry_test_utils::{ - casttest, file, forgetest_async, + casttest, file, forgetest, forgetest_async, rpc::{ next_etherscan_api_key, next_http_rpc_endpoint, next_mainnet_etherscan_api_key, next_rpc_endpoint, next_ws_rpc_endpoint, @@ -1482,6 +1482,60 @@ casttest!(event_decode, |_prj, cmd| { "#]]); }); +// tests cast can decode traces with provided signature +casttest!(error_decode_with_sig, |_prj, cmd| { + cmd.args(["decode-error", "--sig", "AnotherValueTooHigh(uint256,address)", "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F"]).assert_success().stdout_eq(str![[r#" +101 +0x0000000000000000000000000000000000D0004F + +"#]]); + + cmd.args(["--json"]).assert_success().stdout_eq(str![[r#" +[ + "101", + "0x0000000000000000000000000000000000D0004F" +] + +"#]]); +}); + +// tests cast can decode traces with Openchain API +casttest!(error_decode_with_openchain, |_prj, cmd| { + cmd.args(["decode-error", "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"]).assert_success().stdout_eq(str![[r#" +ValueTooHigh(uint256,uint256) +101 +100 + +"#]]); +}); + +// tests cast can decode traces when using local sig identifiers cache +forgetest!(error_decode_with_cache, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_source( + "LocalProjectContract", + r#" +contract ContractWithCustomError { + error AnotherValueTooHigh(uint256, address); +} + "#, + ) + .unwrap(); + // Store selectors in local cache. + cmd.forge_fuse().args(["selectors", "cache"]).assert_success(); + + // Assert cast can decode custom error with local cache. + cmd.cast_fuse() + .args(["decode-error", "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F"]) + .assert_success() + .stdout_eq(str![[r#" +AnotherValueTooHigh(uint256,address) +101 +0x0000000000000000000000000000000000D0004F + +"#]]); +}); + casttest!(format_units, |_prj, cmd| { cmd.args(["format-units", "1000000", "6"]).assert_success().stdout_eq(str![[r#" 1 diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 67aa65073ff88..4cf24221bbee1 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -501,6 +501,9 @@ pub fn cache_local_signatures(output: &ProjectCompileOutput, cache_path: PathBuf .events .insert(event.selector().to_string(), event.full_signature()); } + for error in abi.errors() { + cached_signatures.errors.insert(error.selector().to_string(), error.signature()); + } // External libraries doesn't have functions included in abi, but `methodIdentifiers`. if let Some(method_identifiers) = &artifact.method_identifiers { method_identifiers.iter().for_each(|(signature, selector)| { diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index de9b36219ecdd..fa9f241719fdb 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -1,7 +1,7 @@ //! ABI related helper functions. use alloy_dyn_abi::{DynSolType, DynSolValue, FunctionExt, JsonAbiExt}; -use alloy_json_abi::{Event, Function, Param}; +use alloy_json_abi::{Error, Event, Function, Param}; use alloy_primitives::{hex, Address, LogData}; use eyre::{Context, ContextCompat, Result}; use foundry_block_explorers::{contract::ContractMetadata, errors::EtherscanError, Client}; @@ -85,6 +85,11 @@ pub fn get_event(sig: &str) -> Result { Event::parse(sig).wrap_err("could not parse event signature") } +/// Given an error signature string, it tries to parse it as a `Error` +pub fn get_error(sig: &str) -> Result { + Error::parse(sig).wrap_err("could not parse event signature") +} + /// Given an event without indexed parameters and a rawlog, it tries to return the event with the /// proper indexed parameters. Otherwise, it returns the original event. pub fn get_indexed_event(mut event: Event, raw_log: &LogData) -> Event { diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index cd4e2ffd08825..cb59e1f32e373 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -140,7 +140,7 @@ impl OpenChainClient { .ok_or_else(|| eyre::eyre!("No signature found")) } - /// Decodes the given function or event selectors using OpenChain + /// Decodes the given function, error or event selectors using OpenChain. pub async fn decode_selectors( &self, selector_type: SelectorType, @@ -164,8 +164,8 @@ impl OpenChainClient { self.ensure_not_spurious()?; let expected_len = match selector_type { - SelectorType::Function => 10, // 0x + hex(4bytes) - SelectorType::Event => 66, // 0x + hex(32bytes) + SelectorType::Function | SelectorType::Error => 10, // 0x + hex(4bytes) + SelectorType::Event => 66, // 0x + hex(32bytes) }; if let Some(s) = selectors.iter().find(|s| s.len() != expected_len) { eyre::bail!( @@ -193,7 +193,7 @@ impl OpenChainClient { let url = format!( "{SELECTOR_LOOKUP_URL}?{ltype}={selectors_str}", ltype = match selector_type { - SelectorType::Function => "function", + SelectorType::Function | SelectorType::Error => "function", SelectorType::Event => "event", }, selectors_str = selectors.join(",") @@ -212,7 +212,7 @@ impl OpenChainClient { } let decoded = match selector_type { - SelectorType::Function => api_response.result.function, + SelectorType::Function | SelectorType::Error => api_response.result.function, SelectorType::Event => api_response.result.event, }; @@ -391,6 +391,8 @@ pub enum SelectorType { Function, /// An event selector. Event, + /// An custom error selector. + Error, } /// Decodes the given function or event selector using OpenChain. diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 2a5ef354a7530..801f9da373d5c 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -1,7 +1,7 @@ -use alloy_json_abi::{Event, Function}; +use alloy_json_abi::{Error, Event, Function}; use alloy_primitives::{hex, map::HashSet}; use foundry_common::{ - abi::{get_event, get_func}, + abi::{get_error, get_event, get_func}, fs, selectors::{OpenChainClient, SelectorType}, }; @@ -13,6 +13,7 @@ pub type SingleSignaturesIdentifier = Arc>; #[derive(Debug, Default, Serialize, Deserialize)] pub struct CachedSignatures { + pub errors: BTreeMap, pub events: BTreeMap, pub functions: BTreeMap, } @@ -39,7 +40,7 @@ impl CachedSignatures { /// `https://openchain.xyz` or a local cache. #[derive(Debug)] pub struct SignaturesIdentifier { - /// Cached selectors for functions and events. + /// Cached selectors for functions, events and custom errors. cached: CachedSignatures, /// Location where to save `CachedSignatures`. cached_path: Option, @@ -101,6 +102,7 @@ impl SignaturesIdentifier { let cache = match selector_type { SelectorType::Function => &mut self.cached.functions, SelectorType::Event => &mut self.cached.events, + SelectorType::Error => &mut self.cached.errors, }; let hex_identifiers: Vec = @@ -157,6 +159,19 @@ impl SignaturesIdentifier { pub async fn identify_event(&mut self, identifier: &[u8]) -> Option { self.identify_events(&[identifier]).await.pop().unwrap() } + + /// Identifies `Error`s from its cache or `https://api.openchain.xyz`. + pub async fn identify_errors( + &mut self, + identifiers: impl IntoIterator>, + ) -> Vec> { + self.identify(SelectorType::Error, identifiers, get_error).await + } + + /// Identifies `Error` from its cache or `https://api.openchain.xyz`. + pub async fn identify_error(&mut self, identifier: &[u8]) -> Option { + self.identify_errors(&[identifier]).await.pop().unwrap() + } } impl Drop for SignaturesIdentifier { From 0f7268f46d2db7502cd0a75c8cfba34f06f8fd6e Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:38:40 +0200 Subject: [PATCH 1737/1963] feat(`cast`): `decode-event` with local and openchain API (#9431) --- crates/cast/bin/args.rs | 5 ++-- crates/cast/bin/main.rs | 25 +++++++++++++++++-- crates/cast/tests/cli/main.rs | 47 +++++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index e4cf32639d4b6..fb7fb07578903 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -533,8 +533,9 @@ pub enum CastSubcommand { /// Decode event data. #[command(visible_aliases = &["event-decode", "--event-decode", "ed"])] DecodeEvent { - /// The event signature. - sig: String, + /// The event signature. If none provided then tries to decode from local cache or `https://api.openchain.xyz`. + #[arg(long, visible_alias = "event-sig")] + sig: Option, /// The event data to decode. data: String, }, diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index cacddb8344f54..fcb5a20eb1ada 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -213,8 +213,29 @@ async fn main_args(args: CastArgs) -> Result<()> { print_tokens(&tokens); } CastSubcommand::DecodeEvent { sig, data } => { - let event = get_event(sig.as_str())?; - let decoded_event = event.decode_log_parts(None, &hex::decode(data)?, false)?; + let decoded_event = if let Some(event_sig) = sig { + get_event(event_sig.as_str())?.decode_log_parts(None, &hex::decode(data)?, false)? + } else { + let data = data.strip_prefix("0x").unwrap_or(data.as_str()); + let selector = data.get(..64).unwrap_or_default(); + let identified_event = + SignaturesIdentifier::new(Config::foundry_cache_dir(), false)? + .write() + .await + .identify_event(&hex::decode(selector)?) + .await; + if let Some(event) = identified_event { + let _ = sh_println!("{}", event.signature()); + let data = data.get(64..).unwrap_or_default(); + get_event(event.signature().as_str())?.decode_log_parts( + None, + &hex::decode(data)?, + false, + )? + } else { + eyre::bail!("No matching event signature found for selector `{selector}`") + } + }; print_tokens(&decoded_event.body); } CastSubcommand::DecodeError { sig, data } => { diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 0cd43766e3e13..f3d04b09456bf 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1474,15 +1474,35 @@ casttest!(string_decode, |_prj, cmd| { "#]]); }); -casttest!(event_decode, |_prj, cmd| { - cmd.args(["decode-event", "MyEvent(uint256,address)", "0x000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000d0004f"]).assert_success().stdout_eq(str![[r#" +// tests cast can decode event with provided signature +casttest!(event_decode_with_sig, |_prj, cmd| { + cmd.args(["decode-event", "--sig", "MyEvent(uint256,address)", "0x000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000d0004f"]).assert_success().stdout_eq(str![[r#" 78 0x0000000000000000000000000000000000D0004F +"#]]); + + cmd.args(["--json"]).assert_success().stdout_eq(str![[r#" +[ + "78", + "0x0000000000000000000000000000000000D0004F" +] + "#]]); }); -// tests cast can decode traces with provided signature +// tests cast can decode event with Openchain API +casttest!(event_decode_with_openchain, |prj, cmd| { + prj.clear_cache(); + cmd.args(["decode-event", "0xe27c4c1372396a3d15a9922f74f9dfc7c72b1ad6d63868470787249c356454c1000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]).assert_success().stdout_eq(str![[r#" +BaseCurrencySet(address,uint256) +0x000000000000000000000000000000000000004e +15187004358734 [1.518e13] + +"#]]); +}); + +// tests cast can decode error with provided signature casttest!(error_decode_with_sig, |_prj, cmd| { cmd.args(["decode-error", "--sig", "AnotherValueTooHigh(uint256,address)", "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F"]).assert_success().stdout_eq(str![[r#" 101 @@ -1499,8 +1519,9 @@ casttest!(error_decode_with_sig, |_prj, cmd| { "#]]); }); -// tests cast can decode traces with Openchain API -casttest!(error_decode_with_openchain, |_prj, cmd| { +// tests cast can decode error with Openchain API +casttest!(error_decode_with_openchain, |prj, cmd| { + prj.clear_cache(); cmd.args(["decode-error", "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"]).assert_success().stdout_eq(str![[r#" ValueTooHigh(uint256,uint256) 101 @@ -1509,14 +1530,16 @@ ValueTooHigh(uint256,uint256) "#]]); }); -// tests cast can decode traces when using local sig identifiers cache -forgetest!(error_decode_with_cache, |prj, cmd| { +// tests cast can decode error and event when using local sig identifiers cache +forgetest!(error_event_decode_with_cache, |prj, cmd| { + prj.clear_cache(); foundry_test_utils::util::initialize(prj.root()); prj.add_source( "LocalProjectContract", r#" contract ContractWithCustomError { error AnotherValueTooHigh(uint256, address); + event MyUniqueEventWithinLocalProject(uint256 a, address b); } "#, ) @@ -1533,6 +1556,16 @@ AnotherValueTooHigh(uint256,address) 101 0x0000000000000000000000000000000000D0004F +"#]]); + // Assert cast can decode event with local cache. + cmd.cast_fuse() + .args(["decode-event", "0xbd3699995dcc867b64dbb607be2c33be38df9134bef1178df13bfb9446e73104000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]) + .assert_success() + .stdout_eq(str![[r#" +MyUniqueEventWithinLocalProject(uint256,address) +78 +0x00000000000000000000000000000DD00000004e + "#]]); }); From fbbcc8c4521bae19dfeac451d51db97c0912e512 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:15:21 +0100 Subject: [PATCH 1738/1963] chore: use alloy-chains' `is_arbitrum` (#9432) * use alloy-chains' is_arbitrum * clean up --- crates/anvil/src/eth/backend/mem/mod.rs | 11 +++--- crates/cli/src/utils/cmd.rs | 47 ++++++++++--------------- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 83718ad821aad..fa79332e74061 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -3013,11 +3013,8 @@ pub fn prove_storage(storage: &HashMap, keys: &[B256]) -> Vec bool { - matches!( - NamedChain::try_from(chain_id), - Ok(NamedChain::Arbitrum | - NamedChain::ArbitrumTestnet | - NamedChain::ArbitrumGoerli | - NamedChain::ArbitrumNova) - ) + if let Ok(chain) = NamedChain::try_from(chain_id) { + return chain.is_arbitrum() + } + false } diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 4cf24221bbee1..0d2febf93d07e 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -159,27 +159,24 @@ pub fn init_progress(len: u64, label: &str) -> indicatif::ProgressBar { /// True if the network calculates gas costs differently. pub fn has_different_gas_calc(chain_id: u64) -> bool { if let Some(chain) = Chain::from(chain_id).named() { - return matches!( - chain, - NamedChain::Acala | - NamedChain::AcalaMandalaTestnet | - NamedChain::AcalaTestnet | - NamedChain::Arbitrum | - NamedChain::ArbitrumGoerli | - NamedChain::ArbitrumSepolia | - NamedChain::ArbitrumTestnet | - NamedChain::Etherlink | - NamedChain::EtherlinkTestnet | - NamedChain::Karura | - NamedChain::KaruraTestnet | - NamedChain::Mantle | - NamedChain::MantleSepolia | - NamedChain::MantleTestnet | - NamedChain::Moonbase | - NamedChain::Moonbeam | - NamedChain::MoonbeamDev | - NamedChain::Moonriver - ); + return chain.is_arbitrum() || + matches!( + chain, + NamedChain::Acala | + NamedChain::AcalaMandalaTestnet | + NamedChain::AcalaTestnet | + NamedChain::Etherlink | + NamedChain::EtherlinkTestnet | + NamedChain::Karura | + NamedChain::KaruraTestnet | + NamedChain::Mantle | + NamedChain::MantleSepolia | + NamedChain::MantleTestnet | + NamedChain::Moonbase | + NamedChain::Moonbeam | + NamedChain::MoonbeamDev | + NamedChain::Moonriver + ); } false } @@ -187,13 +184,7 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { /// True if it supports broadcasting in batches. pub fn has_batch_support(chain_id: u64) -> bool { if let Some(chain) = Chain::from(chain_id).named() { - return !matches!( - chain, - NamedChain::Arbitrum | - NamedChain::ArbitrumTestnet | - NamedChain::ArbitrumGoerli | - NamedChain::ArbitrumSepolia - ); + return !chain.is_arbitrum(); } true } From af0fee2031ed4273c1b697775650de1efb2a2d4e Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:39:51 +0530 Subject: [PATCH 1739/1963] feat: rpc_headers in cast and config (#9429) * feat: specify `rpc_headers` in cast and config * test --- Cargo.lock | 18 ++++++++++++++++++ Cargo.toml | 1 + crates/cast/Cargo.toml | 1 + crates/cast/bin/cmd/run.rs | 8 +++----- crates/cli/src/opts/ethereum.rs | 7 +++++++ crates/cli/src/utils/mod.rs | 10 ++++++++++ crates/config/src/lib.rs | 10 ++++++++++ crates/forge/tests/cli/config.rs | 1 + 8 files changed, 51 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09fab74b7f0db..b83fd212c9443 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,6 +262,23 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-node-bindings" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9805d126f24be459b958973c0569c73e1aadd27d4535eee82b2b6764aa03616" +dependencies = [ + "alloy-genesis", + "alloy-primitives", + "k256", + "rand", + "serde_json", + "tempfile", + "thiserror 1.0.69", + "tracing", + "url", +] + [[package]] name = "alloy-primitives" version = "0.8.12" @@ -1957,6 +1974,7 @@ dependencies = [ "alloy-json-abi", "alloy-json-rpc", "alloy-network", + "alloy-node-bindings", "alloy-primitives", "alloy-provider", "alloy-rlp", diff --git a/Cargo.toml b/Cargo.toml index 814c43aa556ae..b07d99cc9f92c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -205,6 +205,7 @@ alloy-transport = { version = "0.6.4", default-features = false } alloy-transport-http = { version = "0.6.4", default-features = false } alloy-transport-ipc = { version = "0.6.4", default-features = false } alloy-transport-ws = { version = "0.6.4", default-features = false } +alloy-node-bindings = { version = "0.6.4", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.11" diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index 0887649e58dd8..f6011831accbb 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -94,6 +94,7 @@ tikv-jemallocator = { workspace = true, optional = true } [dev-dependencies] anvil.workspace = true foundry-test-utils.workspace = true +alloy-node-bindings.workspace = true async-trait.workspace = true divan.workspace = true diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index cfad7263a1e4e..bb5c505b11c3e 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -107,11 +107,9 @@ impl RunArgs { let compute_units_per_second = if self.no_rate_limit { Some(u64::MAX) } else { self.compute_units_per_second }; - let provider = foundry_common::provider::ProviderBuilder::new( - &config.get_rpc_url_or_localhost_http()?, - ) - .compute_units_per_second_opt(compute_units_per_second) - .build()?; + let provider = foundry_cli::utils::get_provider_builder(&config)? + .compute_units_per_second_opt(compute_units_per_second) + .build()?; let tx_hash = self.tx_hash.parse().wrap_err("invalid tx hash")?; let tx = provider diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index b858d998fafb6..4b15b8551940f 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -48,6 +48,10 @@ pub struct RpcOpts { /// Default value: 45 #[arg(long, env = "ETH_RPC_TIMEOUT")] pub rpc_timeout: Option, + + /// Specify custom headers for RPC requests. + #[arg(long, alias = "headers", env = "ETH_RPC_HEADERS", value_delimiter(','))] + pub rpc_headers: Option>, } impl_figment_convert_cast!(RpcOpts); @@ -95,6 +99,9 @@ impl RpcOpts { if let Some(rpc_timeout) = self.rpc_timeout { dict.insert("eth_rpc_timeout".into(), rpc_timeout.into()); } + if let Some(headers) = &self.rpc_headers { + dict.insert("eth_rpc_headers".into(), headers.clone().into()); + } dict } } diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 2d8471e62685f..f833924f57fe7 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -39,6 +39,8 @@ pub const STATIC_FUZZ_SEED: [u8; 32] = [ 0x5d, 0x64, 0x0b, 0x19, 0xad, 0xf0, 0xe3, 0x57, 0xb8, 0xd4, 0xbe, 0x7d, 0x49, 0xee, 0x70, 0xe6, ]; +const DEFAULT_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); + /// Useful extensions to [`std::path::Path`]. pub trait FoundryPathExt { /// Returns true if the [`Path`] ends with `.t.sol` @@ -110,6 +112,14 @@ pub fn get_provider_builder(config: &Config) -> Result { builder = builder.timeout(Duration::from_secs(rpc_timeout)); } + if let Some(mut rpc_headers) = config.eth_rpc_headers.clone() { + if !rpc_headers.iter().any(|h| h.starts_with("User-Agent:")) { + rpc_headers.push(format!("User-Agent:{DEFAULT_USER_AGENT}")); + } + + builder = builder.headers(rpc_headers); + } + Ok(builder) } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 72be43ab18a9b..bcdeb04a9952b 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -253,6 +253,15 @@ pub struct Config { pub eth_rpc_jwt: Option, /// Timeout that should be used for any rpc calls pub eth_rpc_timeout: Option, + /// Headers that should be used for any rpc calls + /// + /// # Example + /// + /// rpc_headers = ["x-custom-header:value", "x-another-header:another-value"] + /// + /// You can also the ETH_RPC_HEADERS env variable like so: + /// `ETH_RPC_HEADERS="x-custom-header:value x-another-header:another-value"` + pub eth_rpc_headers: Option>, /// etherscan API key, or alias for an `EtherscanConfig` in `etherscan` table pub etherscan_api_key: Option, /// Multiple etherscan api configs and their aliases @@ -2347,6 +2356,7 @@ impl Default for Config { eth_rpc_url: None, eth_rpc_jwt: None, eth_rpc_timeout: None, + eth_rpc_headers: None, etherscan_api_key: None, verbosity: 0, remappings: vec![], diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 72aacff49eb67..aa38a0b77c650 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -109,6 +109,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { eth_rpc_url: Some("localhost".to_string()), eth_rpc_jwt: None, eth_rpc_timeout: None, + eth_rpc_headers: None, etherscan_api_key: None, etherscan: Default::default(), verbosity: 4, From 4527475bc8be4044a8daa1dddecb4086403c5b76 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:10:40 +0530 Subject: [PATCH 1740/1963] fix: set user-agent header in runtime transport (#9434) --- crates/cli/src/utils/mod.rs | 8 +------- crates/common/src/constants.rs | 3 +++ crates/common/src/provider/runtime_transport.rs | 10 +++++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index f833924f57fe7..9f8475f63dabc 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -39,8 +39,6 @@ pub const STATIC_FUZZ_SEED: [u8; 32] = [ 0x5d, 0x64, 0x0b, 0x19, 0xad, 0xf0, 0xe3, 0x57, 0xb8, 0xd4, 0xbe, 0x7d, 0x49, 0xee, 0x70, 0xe6, ]; -const DEFAULT_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); - /// Useful extensions to [`std::path::Path`]. pub trait FoundryPathExt { /// Returns true if the [`Path`] ends with `.t.sol` @@ -112,11 +110,7 @@ pub fn get_provider_builder(config: &Config) -> Result { builder = builder.timeout(Duration::from_secs(rpc_timeout)); } - if let Some(mut rpc_headers) = config.eth_rpc_headers.clone() { - if !rpc_headers.iter().any(|h| h.starts_with("User-Agent:")) { - rpc_headers.push(format!("User-Agent:{DEFAULT_USER_AGENT}")); - } - + if let Some(rpc_headers) = config.eth_rpc_headers.clone() { builder = builder.headers(rpc_headers); } diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 0ba0514c2b87b..4ff3eb8d70fbb 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -40,6 +40,9 @@ pub const OPTIMISM_SYSTEM_ADDRESS: Address = address!("deaddeaddeaddeaddeaddeadd /// Transaction identifier of System transaction types pub const SYSTEM_TRANSACTION_TYPE: u8 = 126; +/// Default user agent set as the header for requests that don't specify one. +pub const DEFAULT_USER_AGENT: &str = concat!("foundry/", env!("CARGO_PKG_VERSION")); + /// Returns whether the sender is a known L2 system sender that is the first tx in every block. /// /// Transactions from these senders usually don't have a any fee information. diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index a95969be5a406..563cec3138505 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -1,7 +1,7 @@ //! Runtime transport that connects on first request, which can take either of an HTTP, //! WebSocket, or IPC transport and supports retries based on CUPS logic. -use crate::REQUEST_TIMEOUT; +use crate::{DEFAULT_USER_AGENT, REQUEST_TIMEOUT}; use alloy_json_rpc::{RequestPacket, ResponsePacket}; use alloy_pubsub::{PubSubConnect, PubSubFrontend}; use alloy_rpc_types::engine::{Claims, JwtSecret}; @@ -176,6 +176,14 @@ impl RuntimeTransport { ); } + if !headers.iter().any(|(k, _v)| k.as_str().starts_with("User-Agent:")) { + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_str(DEFAULT_USER_AGENT) + .expect("User-Agent should be valid string"), + ); + } + client_builder = client_builder.default_headers(headers); let client = From 7f41280ee071193557f73f16bae9aee9a5548ee8 Mon Sep 17 00:00:00 2001 From: Delweng Date: Sat, 30 Nov 2024 08:10:35 +0800 Subject: [PATCH 1741/1963] feat(script): support custom create2 deployer (#9278) * script: add --create2-deployer Signed-off-by: jsvisa * script: add create2 deployer Signed-off-by: jsvisa * evm/constants: add get_create2_deployer from env or default Signed-off-by: jsvisa * evm/core: use env's create2 Signed-off-by: jsvisa * script: fetch create2_deployer from env or default Signed-off-by: jsvisa * fmt Signed-off-by: jsvisa * docs Signed-off-by: jsvisa * evm/constants: use sync::LazyLock Signed-off-by: jsvisa * evm/inspector: add fn create2_deployer Signed-off-by: jsvisa * config: add create2_deployer Signed-off-by: jsvisa * evm/inpector: set create2 deployer Signed-off-by: jsvisa * evm-opts: add create2_deployer Signed-off-by: jsvisa * script: pass deployer2-creater from cli or config Signed-off-by: jsvisa * script: use create2 address to fill tx meta Signed-off-by: jsvisa * config: create2 address ,no Option Signed-off-by: jsvisa * script/runner: set inspector.create2_deployer with evm_opts Signed-off-by: jsvisa * clippy Signed-off-by: jsvisa * doc typo Signed-off-by: jsvisa * fix/evm-opts: default value of create2_deployer Signed-off-by: jsvisa * evm/core: no need to extract create2 deployer from env Signed-off-by: jsvisa * evm/core: implement Default for EvmOpts.create2_deployer Signed-off-by: jsvisa * evm/core: use constants::DEFAULT create2 deployer Signed-off-by: jsvisa * evm/core: output create2 deployer Signed-off-by: jsvisa unit test Signed-off-by: jsvisa * evm/evm: set create2 deployer for trace and stack Signed-off-by: jsvisa * cast/{run,call}: set create2 deployer Signed-off-by: jsvisa * forge/runner: set create2 deployer Signed-off-by: jsvisa * script: set create2 deployer for stack Signed-off-by: jsvisa * verify: set create2 deployer Signed-off-by: jsvisa * clipy Signed-off-by: jsvisa * fmt Signed-off-by: jsvisa * script: use executor's create2 deployer Signed-off-by: jsvisa * script: wrap create2_deployer inside executor Signed-off-by: jsvisa * script: add custom create2 test Signed-off-by: jsvisa * script: add nonexist create2 Signed-off-by: jsvisa * all: set EvmOpts.create2_deployer Signed-off-by: jsvisa * script: no need to pass create2_deployer in fill_metadata Signed-off-by: jsvisa * evm/executor: duplicate set create2's deployer address Signed-off-by: jsvisa * evm: check create2 codehash Signed-off-by: jsvisa * tests/script: test with notmatched create2 deployer Signed-off-by: jsvisa * clipy Signed-off-by: jsvisa * evm: skip serialize create2_deployer if none Signed-off-by: jsvisa * test: add test of deployer2 address Signed-off-by: jsvisa * Update crates/script/src/lib.rs --------- Signed-off-by: jsvisa Co-authored-by: Arsenii Kulikov --- crates/cast/bin/cmd/call.rs | 20 ++++++-- crates/cast/bin/cmd/run.rs | 15 ++++-- crates/cheatcodes/src/inspector.rs | 4 ++ crates/common/src/evm.rs | 5 ++ crates/config/src/lib.rs | 8 +++ crates/evm/core/src/constants.rs | 5 ++ crates/evm/core/src/lib.rs | 7 +++ crates/evm/core/src/opts.rs | 32 +++++++++++- crates/evm/core/src/utils.rs | 31 +++++++++--- crates/evm/evm/src/executors/mod.rs | 6 +++ crates/evm/evm/src/executors/trace.rs | 23 ++++----- crates/evm/evm/src/inspectors/stack.rs | 25 ++++++++++ crates/forge/src/multi_runner.rs | 1 + crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/script.rs | 66 ++++++++++++++++++++++++- crates/script/src/build.rs | 7 +-- crates/script/src/lib.rs | 11 +++-- crates/script/src/runner.rs | 10 ++-- crates/script/src/simulate.rs | 6 ++- crates/script/src/transaction.rs | 8 +-- crates/test-utils/src/script.rs | 4 ++ crates/verify/src/utils.rs | 11 +++-- testdata/default/cheats/Broadcast.t.sol | 26 ++++++++++ 23 files changed, 281 insertions(+), 51 deletions(-) diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 2d5692efe4c1a..1704247dc7068 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -18,7 +18,11 @@ use foundry_config::{ }, Config, }; -use foundry_evm::{executors::TracingExecutor, opts::EvmOpts}; +use foundry_evm::{ + executors::TracingExecutor, + opts::EvmOpts, + traces::{InternalTraceMode, TraceMode}, +}; use std::str::FromStr; /// CLI arguments for `cast call`. @@ -175,6 +179,7 @@ impl CallArgs { config.fork_block_number = Some(block_number); } + let create2_deployer = evm_opts.create2_deployer; let (mut env, fork, chain, alphanet) = TracingExecutor::get_fork_material(&config, evm_opts).await?; @@ -182,14 +187,21 @@ impl CallArgs { env.cfg.disable_block_gas_limit = true; env.block.gas_limit = U256::MAX; + let trace_mode = TraceMode::Call + .with_debug(debug) + .with_decode_internal(if decode_internal { + InternalTraceMode::Full + } else { + InternalTraceMode::None + }) + .with_state_changes(shell::verbosity() > 4); let mut executor = TracingExecutor::new( env, fork, evm_version, - debug, - decode_internal, - shell::verbosity() > 4, + trace_mode, alphanet, + create2_deployer, ); let value = tx.value.unwrap_or_default(); diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index bb5c505b11c3e..62a41ca6c9982 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -23,6 +23,7 @@ use foundry_config::{ use foundry_evm::{ executors::{EvmError, TracingExecutor}, opts::EvmOpts, + traces::{InternalTraceMode, TraceMode}, utils::configure_tx_env, }; @@ -136,6 +137,7 @@ impl RunArgs { // we need to fork off the parent block config.fork_block_number = Some(tx_block_number - 1); + let create2_deployer = evm_opts.create2_deployer; let (mut env, fork, chain, alphanet) = TracingExecutor::get_fork_material(&config, evm_opts).await?; @@ -161,14 +163,21 @@ impl RunArgs { } } + let trace_mode = TraceMode::Call + .with_debug(self.debug) + .with_decode_internal(if self.decode_internal { + InternalTraceMode::Full + } else { + InternalTraceMode::None + }) + .with_state_changes(shell::verbosity() > 4); let mut executor = TracingExecutor::new( env.clone(), fork, evm_version, - self.debug, - self.decode_internal, - shell::verbosity() > 4, + trace_mode, alphanet, + create2_deployer, ); let mut env = EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), executor.spec_id()); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 6f3acb58c2735..447a9e7473ec9 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -1587,6 +1587,10 @@ impl InspectorExt for Cheatcodes { false } } + + fn create2_deployer(&self) -> Address { + self.config.evm_opts.create2_deployer + } } impl Cheatcodes { diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index c4dfccae16412..dbcaf02aff0ad 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -103,6 +103,11 @@ pub struct EvmArgs { #[serde(skip)] pub always_use_create_2_factory: bool, + /// The CREATE2 deployer address to use, this will override the one in the config. + #[arg(long, value_name = "ADDRESS")] + #[serde(skip_serializing_if = "Option::is_none")] + pub create2_deployer: Option
, + /// Sets the number of assumed available compute units per second for this provider /// /// default value: 330 diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index bcdeb04a9952b..b88f134d2cc26 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -454,6 +454,9 @@ pub struct Config { /// CREATE2 salt to use for the library deployment in scripts. pub create2_library_salt: B256, + /// The CREATE2 deployer address to use. + pub create2_deployer: Address, + /// Configuration for Vyper compiler pub vyper: VyperConfig, @@ -567,6 +570,10 @@ impl Config { /// Default salt for create2 library deployments pub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> = FixedBytes::<32>::ZERO; + /// Default create2 deployer + pub const DEFAULT_CREATE2_DEPLOYER: Address = + address!("4e59b44847b379578588920ca78fbf26c0b4956c"); + /// Docker image with eof-enabled solc binary pub const EOF_SOLC_IMAGE: &'static str = "ghcr.io/paradigmxyz/forge-eof@sha256:46f868ce5264e1190881a3a335d41d7f42d6f26ed20b0c823609c715e38d603f"; @@ -2390,6 +2397,7 @@ impl Default for Config { labels: Default::default(), unchecked_cheatcode_artifacts: false, create2_library_salt: Self::DEFAULT_CREATE2_LIBRARY_SALT, + create2_deployer: Self::DEFAULT_CREATE2_DEPLOYER, skip: vec![], dependencies: Default::default(), soldeer: Default::default(), diff --git a/crates/evm/core/src/constants.rs b/crates/evm/core/src/constants.rs index cebbdcb87c796..2e4fdb52617b8 100644 --- a/crates/evm/core/src/constants.rs +++ b/crates/evm/core/src/constants.rs @@ -49,6 +49,11 @@ pub const DEFAULT_CREATE2_DEPLOYER: Address = address!("4e59b44847b379578588920c pub const DEFAULT_CREATE2_DEPLOYER_CODE: &[u8] = &hex!("604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); /// The runtime code of the default CREATE2 deployer. pub const DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE: &[u8] = &hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"); +/// The hash of the default CREATE2 deployer code. +/// +/// This is calculated as `keccak256([`DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE`])`. +pub const DEFAULT_CREATE2_DEPLOYER_CODEHASH: B256 = + b256!("2fa86add0aed31f33a762c9d88e807c475bd51d0f52bd0955754b2608f7e4989"); #[cfg(test)] mod tests { diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 1a2ac4c4a0f49..0bdc34cc92ce3 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -5,6 +5,8 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +use crate::constants::DEFAULT_CREATE2_DEPLOYER; +use alloy_primitives::Address; use auto_impl::auto_impl; use backend::DatabaseExt; use revm::{inspectors::NoOpInspector, interpreter::CreateInputs, EvmContext, Inspector}; @@ -54,6 +56,11 @@ pub trait InspectorExt: for<'a> Inspector<&'a mut dyn DatabaseExt> { fn is_alphanet(&self) -> bool { false } + + /// Returns the CREATE2 deployer address. + fn create2_deployer(&self) -> Address { + DEFAULT_CREATE2_DEPLOYER + } } impl InspectorExt for NoOpInspector {} diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 6f4448ae482c2..c5817e483c25b 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -1,5 +1,5 @@ use super::fork::environment; -use crate::fork::CreateFork; +use crate::{constants::DEFAULT_CREATE2_DEPLOYER, fork::CreateFork}; use alloy_primitives::{Address, B256, U256}; use alloy_provider::{network::AnyRpcBlock, Provider}; use eyre::WrapErr; @@ -9,7 +9,7 @@ use revm::primitives::{BlockEnv, CfgEnv, TxEnv}; use serde::{Deserialize, Serialize}; use url::Url; -#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct EvmOpts { /// The EVM environment configuration. #[serde(flatten)] @@ -66,6 +66,34 @@ pub struct EvmOpts { /// whether to enable Alphanet features. pub alphanet: bool, + + /// The CREATE2 deployer's address. + pub create2_deployer: Address, +} + +impl Default for EvmOpts { + fn default() -> Self { + Self { + env: Env::default(), + fork_url: None, + fork_block_number: None, + fork_retries: None, + fork_retry_backoff: None, + compute_units_per_second: None, + no_rpc_rate_limit: false, + no_storage_caching: false, + initial_balance: U256::default(), + sender: Address::default(), + ffi: false, + always_use_create_2_factory: false, + verbosity: 0, + memory_limit: 0, + isolate: false, + disable_block_gas_limit: false, + alphanet: false, + create2_deployer: DEFAULT_CREATE2_DEPLOYER, + } + } } impl EvmOpts { diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index be9660c72ac4a..2257709e5e917 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,6 +1,6 @@ pub use crate::ic::*; use crate::{ - backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER, precompiles::ALPHANET_P256, + backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER_CODEHASH, precompiles::ALPHANET_P256, InspectorExt, }; use alloy_consensus::BlockHeader; @@ -149,12 +149,16 @@ pub fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 { spent - (refunded).min(spent / refund_quotient) } -fn get_create2_factory_call_inputs(salt: U256, inputs: CreateInputs) -> CallInputs { +fn get_create2_factory_call_inputs( + salt: U256, + inputs: CreateInputs, + deployer: Address, +) -> CallInputs { let calldata = [&salt.to_be_bytes::<32>()[..], &inputs.init_code[..]].concat(); CallInputs { caller: inputs.caller, - bytecode_address: DEFAULT_CREATE2_DEPLOYER, - target_address: DEFAULT_CREATE2_DEPLOYER, + bytecode_address: deployer, + target_address: deployer, scheme: CallScheme::Call, value: CallValue::Transfer(inputs.value), input: calldata.into(), @@ -165,7 +169,7 @@ fn get_create2_factory_call_inputs(salt: U256, inputs: CreateInputs) -> CallInpu } } -/// Used for routing certain CREATE2 invocations through [DEFAULT_CREATE2_DEPLOYER]. +/// Used for routing certain CREATE2 invocations through CREATE2_DEPLOYER. /// /// Overrides create hook with CALL frame if [InspectorExt::should_use_create2_factory] returns /// true. Keeps track of overridden frames and handles outcome in the overridden insert_call_outcome @@ -190,8 +194,10 @@ pub fn create2_handler_register( let gas_limit = inputs.gas_limit; + // Get CREATE2 deployer. + let create2_deployer = ctx.external.create2_deployer(); // Generate call inputs for CREATE2 factory. - let mut call_inputs = get_create2_factory_call_inputs(salt, *inputs); + let mut call_inputs = get_create2_factory_call_inputs(salt, *inputs, create2_deployer); // Call inspector to change input or return outcome. let outcome = ctx.external.call(&mut ctx.evm, &mut call_inputs); @@ -202,12 +208,21 @@ pub fn create2_handler_register( .push((ctx.evm.journaled_state.depth(), call_inputs.clone())); // Sanity check that CREATE2 deployer exists. - let code_hash = ctx.evm.load_account(DEFAULT_CREATE2_DEPLOYER)?.info.code_hash; + let code_hash = ctx.evm.load_account(create2_deployer)?.info.code_hash; if code_hash == KECCAK_EMPTY { return Ok(FrameOrResult::Result(FrameResult::Call(CallOutcome { result: InterpreterResult { result: InstructionResult::Revert, - output: "missing CREATE2 deployer".into(), + output: format!("missing CREATE2 deployer: {create2_deployer}").into(), + gas: Gas::new(gas_limit), + }, + memory_offset: 0..0, + }))) + } else if code_hash != DEFAULT_CREATE2_DEPLOYER_CODEHASH { + return Ok(FrameOrResult::Result(FrameResult::Call(CallOutcome { + result: InterpreterResult { + result: InstructionResult::Revert, + output: "invalid CREATE2 deployer bytecode".into(), gas: Gas::new(gas_limit), }, memory_offset: 0..0, diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 2ccfad9e2a583..8146cec82d44a 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -24,6 +24,7 @@ use foundry_evm_core::{ }, decode::{RevertDecoder, SkipReason}, utils::StateChangeset, + InspectorExt, }; use foundry_evm_coverage::HitMaps; use foundry_evm_traces::{SparsedTraceArena, TraceMode}; @@ -240,6 +241,11 @@ impl Executor { self } + #[inline] + pub fn create2_deployer(&self) -> Address { + self.inspector().create2_deployer() + } + /// Deploys a contract and commits the new state to the underlying database. /// /// Executes a CREATE transaction with the contract `code` and persistent database state diff --git a/crates/evm/evm/src/executors/trace.rs b/crates/evm/evm/src/executors/trace.rs index ceea6e67248a4..214e7c28ae16e 100644 --- a/crates/evm/evm/src/executors/trace.rs +++ b/crates/evm/evm/src/executors/trace.rs @@ -1,8 +1,9 @@ use crate::executors::{Executor, ExecutorBuilder}; +use alloy_primitives::Address; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{utils::evm_spec_id, Chain, Config}; use foundry_evm_core::{backend::Backend, fork::CreateFork, opts::EvmOpts}; -use foundry_evm_traces::{InternalTraceMode, TraceMode}; +use foundry_evm_traces::TraceMode; use revm::primitives::{Env, SpecId}; use std::ops::{Deref, DerefMut}; @@ -16,25 +17,21 @@ impl TracingExecutor { env: revm::primitives::Env, fork: Option, version: Option, - debug: bool, - decode_internal: bool, - with_state_changes: bool, + trace_mode: TraceMode, alphanet: bool, + create2_deployer: Address, ) -> Self { let db = Backend::spawn(fork); - let trace_mode = TraceMode::Call - .with_debug(debug) - .with_decode_internal(if decode_internal { - InternalTraceMode::Full - } else { - InternalTraceMode::None - }) - .with_state_changes(with_state_changes); Self { // configures a bare version of the evm executor: no cheatcode inspector is enabled, // tracing will be enabled only for the targeted transaction executor: ExecutorBuilder::new() - .inspectors(|stack| stack.trace_mode(trace_mode).alphanet(alphanet)) + .inspectors(|stack| { + stack + .trace_mode(trace_mode) + .alphanet(alphanet) + .create2_deployer(create2_deployer) + }) .spec(evm_spec_id(&version.unwrap_or_default(), alphanet)) .build(env, db), } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 403e906f6323c..accbca4fd59c9 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -59,6 +59,8 @@ pub struct InspectorStackBuilder { pub alphanet: bool, /// The wallets to set in the cheatcodes context. pub wallets: Option, + /// The CREATE2 deployer address. + pub create2_deployer: Address, } impl InspectorStackBuilder { @@ -156,6 +158,12 @@ impl InspectorStackBuilder { self } + #[inline] + pub fn create2_deployer(mut self, create2_deployer: Address) -> Self { + self.create2_deployer = create2_deployer; + self + } + /// Builds the stack of inspectors to use when transacting/committing on the EVM. pub fn build(self) -> InspectorStack { let Self { @@ -171,6 +179,7 @@ impl InspectorStackBuilder { enable_isolation, alphanet, wallets, + create2_deployer, } = self; let mut stack = InspectorStack::new(); @@ -197,6 +206,7 @@ impl InspectorStackBuilder { stack.enable_isolation(enable_isolation); stack.alphanet(alphanet); + stack.set_create2_deployer(create2_deployer); // environment, must come after all of the inspectors if let Some(block) = block { @@ -282,6 +292,7 @@ pub struct InspectorStackInner { pub tracer: Option, pub enable_isolation: bool, pub alphanet: bool, + pub create2_deployer: Address, /// Flag marking if we are in the inner EVM context. pub in_inner_context: bool, @@ -398,6 +409,12 @@ impl InspectorStack { self.alphanet = yes; } + /// Set the CREATE2 deployer address. + #[inline] + pub fn set_create2_deployer(&mut self, deployer: Address) { + self.create2_deployer = deployer; + } + /// Set whether to enable the log collector. #[inline] pub fn collect_logs(&mut self, yes: bool) { @@ -1022,6 +1039,10 @@ impl InspectorExt for InspectorStackRefMut<'_> { fn is_alphanet(&self) -> bool { self.inner.alphanet } + + fn create2_deployer(&self) -> Address { + self.inner.create2_deployer + } } impl Inspector<&mut dyn DatabaseExt> for InspectorStack { @@ -1124,6 +1145,10 @@ impl InspectorExt for InspectorStack { fn is_alphanet(&self) -> bool { self.alphanet } + + fn create2_deployer(&self) -> Address { + self.create2_deployer + } } impl<'a> Deref for InspectorStackRefMut<'a> { diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index dfb498c060e66..572c3d4fe9845 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -260,6 +260,7 @@ impl MultiContractRunner { .coverage(self.coverage) .enable_isolation(self.isolation) .alphanet(self.alphanet) + .create2_deployer(self.evm_opts.create2_deployer) }) .spec(self.evm_spec) .gas_limit(self.evm_opts.gas_limit()) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index aa38a0b77c650..9a7e61c6a4e3d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -146,6 +146,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { isolate: true, unchecked_cheatcode_artifacts: false, create2_library_salt: Config::DEFAULT_CREATE2_LIBRARY_SALT, + create2_deployer: Config::DEFAULT_CREATE2_DEPLOYER, vyper: Default::default(), skip: vec![], dependencies: Default::default(), diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index d7776eee2e87f..e52bd2fef4a70 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -855,6 +855,70 @@ forgetest_async!(can_deploy_with_create2, |prj, cmd| { .run(ScriptOutcome::ScriptFailed); }); +forgetest_async!(can_deploy_with_custom_create2, |prj, cmd| { + let (api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + let create2 = Address::from_str("0x0000000000000000000000000000000000b4956c").unwrap(); + + // Prepare CREATE2 Deployer + api.anvil_set_code( + create2, + Bytes::from_static(foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE), + ) + .await + .unwrap(); + + tester + .add_deployer(0) + .load_private_keys(&[0]) + .await + .add_create2_deployer(create2) + .add_sig("BroadcastTestNoLinking", "deployCreate2(address)") + .arg(&create2.to_string()) + .simulate(ScriptOutcome::OkSimulation) + .broadcast(ScriptOutcome::OkBroadcast) + .assert_nonce_increment(&[(0, 2)]) + .await; +}); + +forgetest_async!(can_deploy_with_custom_create2_notmatched_bytecode, |prj, cmd| { + let (api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + let create2 = Address::from_str("0x0000000000000000000000000000000000b4956c").unwrap(); + + // Prepare CREATE2 Deployer + api.anvil_set_code( + create2, + Bytes::from_static(&hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cef")), + ) + .await + .unwrap(); + + tester + .add_deployer(0) + .load_private_keys(&[0]) + .await + .add_create2_deployer(create2) + .add_sig("BroadcastTestNoLinking", "deployCreate2()") + .simulate(ScriptOutcome::ScriptFailed) + .broadcast(ScriptOutcome::ScriptFailed); +}); + +forgetest_async!(canot_deploy_with_nonexist_create2, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); + let create2 = Address::from_str("0x0000000000000000000000000000000000b4956c").unwrap(); + + tester + .add_deployer(0) + .load_private_keys(&[0]) + .await + .add_create2_deployer(create2) + .add_sig("BroadcastTestNoLinking", "deployCreate2()") + .simulate(ScriptOutcome::ScriptFailed) + .broadcast(ScriptOutcome::ScriptFailed); +}); + forgetest_async!(can_deploy_and_simulate_25_txes_concurrently, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root()); @@ -2002,7 +2066,7 @@ contract SimpleScript is Script { ]); cmd.assert_failure().stderr_eq(str![[r#" -Error: script failed: missing CREATE2 deployer +Error: script failed: missing CREATE2 deployer: 0x4e59b44847b379578588920cA78FbF26c0B4956C "#]]); }); diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index ef42740841b2a..052e78e10781a 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -17,7 +17,7 @@ use foundry_compilers::{ utils::source_files_iter, ArtifactId, ProjectCompileOutput, }; -use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::debug::ContractSources}; +use foundry_evm::traces::debug::ContractSources; use foundry_linking::Linker; use std::{path::PathBuf, str::FromStr, sync::Arc}; @@ -40,9 +40,10 @@ impl BuildData { /// Links contracts. Uses CREATE2 linking when possible, otherwise falls back to /// default linking with sender nonce and address. pub async fn link(self, script_config: &ScriptConfig) -> Result { + let create2_deployer = script_config.evm_opts.create2_deployer; let can_use_create2 = if let Some(fork_url) = &script_config.evm_opts.fork_url { let provider = try_get_http_provider(fork_url)?; - let deployer_code = provider.get_code_at(DEFAULT_CREATE2_DEPLOYER).await?; + let deployer_code = provider.get_code_at(create2_deployer).await?; !deployer_code.is_empty() } else { @@ -57,7 +58,7 @@ impl BuildData { self.get_linker() .link_with_create2( known_libraries.clone(), - DEFAULT_CREATE2_DEPLOYER, + create2_deployer, script_config.config.create2_library_salt, &self.target, ) diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 6ccc818410a41..ccf5eab2ad0dd 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -46,7 +46,6 @@ use foundry_config::{ }; use foundry_evm::{ backend::Backend, - constants::DEFAULT_CREATE2_DEPLOYER, executors::ExecutorBuilder, inspectors::{ cheatcodes::{BroadcastableTransactions, Wallets}, @@ -239,7 +238,9 @@ impl ScriptArgs { pub async fn run_script(self) -> Result<()> { trace!(target: "script", "executing script command"); - let compiled = self.preprocess().await?.compile()?; + let state = self.preprocess().await?; + let create2_deployer = state.script_config.evm_opts.create2_deployer; + let compiled = state.compile()?; // Move from `CompiledState` to `BundledState` either by resuming or executing and // simulating script. @@ -294,6 +295,7 @@ impl ScriptArgs { pre_simulation.args.check_contract_sizes( &pre_simulation.execution_result, &pre_simulation.build_data.known_contracts, + create2_deployer, )?; pre_simulation.fill_metadata().await?.bundle().await? @@ -384,6 +386,7 @@ impl ScriptArgs { &self, result: &ScriptResult, known_contracts: &ContractsByArtifact, + create2_deployer: Address, ) -> Result<()> { // (name, &init, &deployed)[] let mut bytecodes: Vec<(String, &[u8], &[u8])> = vec![]; @@ -428,7 +431,7 @@ impl ScriptArgs { // Find if it's a CREATE or CREATE2. Otherwise, skip transaction. if let Some(TxKind::Call(to)) = to { - if to == DEFAULT_CREATE2_DEPLOYER { + if to == create2_deployer { // Size of the salt prefix. offset = 32; } else { @@ -553,6 +556,7 @@ impl ScriptConfig { // dapptools compatibility 1 }; + Ok(Self { config, evm_opts, sender_nonce, backends: HashMap::default() }) } @@ -612,6 +616,7 @@ impl ScriptConfig { stack .trace_mode(if debug { TraceMode::Debug } else { TraceMode::Call }) .alphanet(self.evm_opts.alphanet) + .create2_deployer(self.evm_opts.create2_deployer) }) .spec(self.config.evm_spec_id()) .gas_limit(self.evm_opts.gas_limit()) diff --git a/crates/script/src/runner.rs b/crates/script/src/runner.rs index fa8ff19d9a9dc..2d58e381f6356 100644 --- a/crates/script/src/runner.rs +++ b/crates/script/src/runner.rs @@ -7,7 +7,7 @@ use eyre::Result; use foundry_cheatcodes::BroadcastableTransaction; use foundry_config::Config; use foundry_evm::{ - constants::{CALLER, DEFAULT_CREATE2_DEPLOYER}, + constants::CALLER, executors::{DeployResult, EvmError, ExecutionErr, Executor, RawCallResult}, opts::EvmOpts, revm::interpreter::{return_ok, InstructionResult}, @@ -83,9 +83,9 @@ impl ScriptRunner { }) }), ScriptPredeployLibraries::Create2(libraries, salt) => { + let create2_deployer = self.executor.create2_deployer(); for library in libraries { - let address = - DEFAULT_CREATE2_DEPLOYER.create2_from_code(salt, library.as_ref()); + let address = create2_deployer.create2_from_code(salt, library.as_ref()); // Skip if already deployed if !self.executor.is_empty_code(address)? { continue; @@ -95,7 +95,7 @@ impl ScriptRunner { .executor .transact_raw( self.evm_opts.sender, - DEFAULT_CREATE2_DEPLOYER, + create2_deployer, calldata.clone().into(), U256::from(0), ) @@ -111,7 +111,7 @@ impl ScriptRunner { from: Some(self.evm_opts.sender), input: calldata.into(), nonce: Some(sender_nonce + library_transactions.len() as u64), - to: Some(TxKind::Call(DEFAULT_CREATE2_DEPLOYER)), + to: Some(TxKind::Call(create2_deployer)), ..Default::default() } .into(), diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index e833073ac00ff..0d7990591cd18 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -64,7 +64,11 @@ impl PreSimulationState { let mut builder = ScriptTransactionBuilder::new(tx.transaction, rpc); if let Some(TxKind::Call(_)) = to { - builder.set_call(&address_to_abi, &self.execution_artifacts.decoder)?; + builder.set_call( + &address_to_abi, + &self.execution_artifacts.decoder, + self.script_config.evm_opts.create2_deployer, + )?; } else { builder.set_create(false, sender.create(nonce), &address_to_abi)?; } diff --git a/crates/script/src/transaction.rs b/crates/script/src/transaction.rs index ca6a6226949ce..2cf480b9bd0ad 100644 --- a/crates/script/src/transaction.rs +++ b/crates/script/src/transaction.rs @@ -4,7 +4,7 @@ use alloy_primitives::{hex, Address, TxKind, B256}; use eyre::Result; use forge_script_sequence::TransactionWithMetadata; use foundry_common::{fmt::format_token_raw, ContractData, TransactionMaybeSigned, SELECTOR_LEN}; -use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, traces::CallTraceDecoder}; +use foundry_evm::traces::CallTraceDecoder; use itertools::Itertools; use revm_inspectors::tracing::types::CallKind; use std::collections::BTreeMap; @@ -29,16 +29,16 @@ impl ScriptTransactionBuilder { &mut self, local_contracts: &BTreeMap, decoder: &CallTraceDecoder, + create2_deployer: Address, ) -> Result<()> { if let Some(TxKind::Call(to)) = self.transaction.transaction.to() { - if to == DEFAULT_CREATE2_DEPLOYER { + if to == create2_deployer { if let Some(input) = self.transaction.transaction.input() { let (salt, init_code) = input.split_at(32); self.set_create( true, - DEFAULT_CREATE2_DEPLOYER - .create2_from_code(B256::from_slice(salt), init_code), + create2_deployer.create2_from_code(B256::from_slice(salt), init_code), local_contracts, )?; } diff --git a/crates/test-utils/src/script.rs b/crates/test-utils/src/script.rs index f15e91d5af781..b82126d2db288 100644 --- a/crates/test-utils/src/script.rs +++ b/crates/test-utils/src/script.rs @@ -171,6 +171,10 @@ impl ScriptTester { self.args(&["--tc", contract_name, "--sig", sig]) } + pub fn add_create2_deployer(&mut self, create2_deployer: Address) -> &mut Self { + self.args(&["--create2-deployer", create2_deployer.to_string().as_str()]) + } + /// Adds the `--unlocked` flag pub fn unlocked(&mut self) -> &mut Self { self.arg("--unlocked") diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 56ec035abcead..824e784435994 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -12,7 +12,10 @@ use foundry_block_explorers::{ use foundry_common::{abi::encode_args, compile::ProjectCompiler, provider::RetryProvider, shell}; use foundry_compilers::artifacts::{BytecodeHash, CompactContractBytecode, EvmVersion}; use foundry_config::Config; -use foundry_evm::{constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, opts::EvmOpts}; +use foundry_evm::{ + constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, opts::EvmOpts, + traces::TraceMode, +}; use reqwest::Url; use revm_primitives::{ db::Database, @@ -325,6 +328,7 @@ pub async fn get_tracing_executor( fork_config.fork_block_number = Some(fork_blk_num); fork_config.evm_version = evm_version; + let create2_deployer = evm_opts.create2_deployer; let (env, fork, _chain, is_alphanet) = TracingExecutor::get_fork_material(fork_config, evm_opts).await?; @@ -332,10 +336,9 @@ pub async fn get_tracing_executor( env.clone(), fork, Some(fork_config.evm_version), - false, - false, - false, + TraceMode::Call, is_alphanet, + create2_deployer, ); Ok((env, executor)) diff --git a/testdata/default/cheats/Broadcast.t.sol b/testdata/default/cheats/Broadcast.t.sol index bca8cc2eee8f8..97b9d52752d79 100644 --- a/testdata/default/cheats/Broadcast.t.sol +++ b/testdata/default/cheats/Broadcast.t.sol @@ -219,6 +219,32 @@ contract BroadcastTestNoLinking is DSTest { vm.stopBroadcast(); } + function deployCreate2(address deployer) public { + vm.startBroadcast(); + bytes32 salt = bytes32(uint256(1338)); + NoLink test_c2 = new NoLink{salt: salt}(); + assert(test_c2.view_me() == 1337); + + address expectedAddress = address( + uint160( + uint256( + keccak256( + abi.encodePacked( + bytes1(0xff), + deployer, + salt, + keccak256(abi.encodePacked(type(NoLink).creationCode, abi.encode())) + ) + ) + ) + ) + ); + require(address(test_c2) == expectedAddress, "Create2 address mismatch"); + + NoLink test2 = new NoLink(); + vm.stopBroadcast(); + } + function errorStaticCall() public { vm.broadcast(); NoLink test11 = new NoLink(); From 7a23a5cf851b991bfd2fde32d4f088319bbc1183 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 30 Nov 2024 15:47:18 +0100 Subject: [PATCH 1742/1963] fix(coverage): clean ups, use normalized source code for locations (#9438) * feat(coverage): add function line end to LCOV, clean ups * fix(coverage): store normalized source code * fix(coverage): add a Line item for functions too * test: update snapshots * clean --- crates/evm/coverage/src/analysis.rs | 56 ++++++------ crates/evm/coverage/src/anchors.rs | 8 +- crates/evm/coverage/src/lib.rs | 134 ++++++++++++++++------------ crates/forge/bin/cmd/coverage.rs | 21 +++-- crates/forge/src/coverage.rs | 56 ++++++------ crates/forge/tests/cli/coverage.rs | 133 +++++++++++++-------------- 6 files changed, 219 insertions(+), 189 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index c18ba823b2d0e..69bd73075a3f6 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -1,7 +1,10 @@ use super::{CoverageItem, CoverageItemKind, SourceLocation}; use alloy_primitives::map::HashMap; use foundry_common::TestFunctionExt; -use foundry_compilers::artifacts::ast::{self, Ast, Node, NodeType}; +use foundry_compilers::artifacts::{ + ast::{self, Ast, Node, NodeType}, + Source, +}; use rayon::prelude::*; use std::sync::Arc; @@ -19,7 +22,7 @@ pub struct ContractVisitor<'a> { /// The current branch ID branch_id: usize, /// Stores the last line we put in the items collection to ensure we don't push duplicate lines - last_line: usize, + last_line: u32, /// Coverage items pub items: Vec, @@ -47,23 +50,20 @@ impl<'a> ContractVisitor<'a> { } fn visit_function_definition(&mut self, node: &Node) -> eyre::Result<()> { - let name: String = - node.attribute("name").ok_or_else(|| eyre::eyre!("Function has no name"))?; + let Some(body) = &node.body else { return Ok(()) }; let kind: String = node.attribute("kind").ok_or_else(|| eyre::eyre!("Function has no kind"))?; - match &node.body { - Some(body) => { - // Do not add coverage item for constructors without statements. - if kind == "constructor" && !has_statements(body) { - return Ok(()) - } - self.push_item_kind(CoverageItemKind::Function { name }, &node.src); - self.visit_block(body) - } - _ => Ok(()), + let name: String = + node.attribute("name").ok_or_else(|| eyre::eyre!("Function has no name"))?; + + // Do not add coverage item for constructors without statements. + if kind == "constructor" && !has_statements(body) { + return Ok(()) } + self.push_item_kind(CoverageItemKind::Function { name }, &node.src); + self.visit_block(body) } fn visit_modifier_or_yul_fn_definition(&mut self, node: &Node) -> eyre::Result<()> { @@ -454,30 +454,34 @@ impl<'a> ContractVisitor<'a> { /// collection (plus additional coverage line if item is a statement). fn push_item_kind(&mut self, kind: CoverageItemKind, src: &ast::LowFidelitySourceLocation) { let item = CoverageItem { kind, loc: self.source_location_for(src), hits: 0 }; - // Push a line item if we haven't already - if matches!(item.kind, CoverageItemKind::Statement | CoverageItemKind::Branch { .. }) && - self.last_line < item.loc.line - { + + // Push a line item if we haven't already. + debug_assert!(!matches!(item.kind, CoverageItemKind::Line)); + if self.last_line < item.loc.lines.start { self.items.push(CoverageItem { kind: CoverageItemKind::Line, loc: item.loc.clone(), hits: 0, }); - self.last_line = item.loc.line; + self.last_line = item.loc.lines.start; } self.items.push(item); } fn source_location_for(&self, loc: &ast::LowFidelitySourceLocation) -> SourceLocation { - let loc_start = - self.source.char_indices().map(|(i, _)| i).nth(loc.start).unwrap_or_default(); + let bytes_start = loc.start as u32; + let bytes_end = (loc.start + loc.length.unwrap_or(0)) as u32; + let bytes = bytes_start..bytes_end; + + let start_line = self.source[..bytes.start as usize].lines().count() as u32; + let n_lines = self.source[bytes.start as usize..bytes.end as usize].lines().count() as u32; + let lines = start_line..start_line + n_lines; SourceLocation { source_id: self.source_id, contract_name: self.contract_name.clone(), - start: loc.start as u32, - length: loc.length.map(|x| x as u32), - line: self.source[..loc_start].lines().count(), + bytes, + lines, } } } @@ -556,7 +560,7 @@ impl<'a> SourceAnalyzer<'a> { .attribute("name") .ok_or_else(|| eyre::eyre!("Contract has no name"))?; - let mut visitor = ContractVisitor::new(source_id, source, &name); + let mut visitor = ContractVisitor::new(source_id, &source.content, &name); visitor.visit_contract(node)?; let mut items = visitor.items; @@ -590,7 +594,7 @@ pub struct SourceFiles<'a> { #[derive(Debug)] pub struct SourceFile<'a> { /// The source code. - pub source: String, + pub source: Source, /// The AST of the source code. pub ast: &'a Ast, } diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index 6643524d61de6..ee723d95cc5c8 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -177,14 +177,14 @@ fn is_in_source_range(element: &SourceElement, location: &SourceLocation) -> boo } // Needed because some source ranges in the source map mark the entire contract... - let is_within_start = element.offset() >= location.start; + let is_within_start = element.offset() >= location.bytes.start; if !is_within_start { return false; } - let start_of_ranges = location.start.max(element.offset()); - let end_of_ranges = (location.start + location.length.unwrap_or_default()) - .min(element.offset() + element.length()); + let start_of_ranges = location.bytes.start.max(element.offset()); + let end_of_ranges = + (location.bytes.start + location.len()).min(element.offset() + element.length()); let within_ranges = start_of_ranges <= end_of_ranges; if !within_ranges { return false; diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index ad4ab53e3cf13..8d5575631f842 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -18,7 +18,7 @@ use semver::Version; use std::{ collections::BTreeMap, fmt::Display, - ops::{AddAssign, Deref, DerefMut}, + ops::{Deref, DerefMut, Range}, path::{Path, PathBuf}, sync::Arc, }; @@ -82,40 +82,29 @@ impl CoverageReport { self.anchors.extend(anchors); } - /// Get coverage summaries by source file path. - pub fn summary_by_file(&self) -> impl Iterator { - let mut summaries = BTreeMap::new(); - - for (version, items) in self.items.iter() { - for item in items { - let Some(path) = - self.source_paths.get(&(version.clone(), item.loc.source_id)).cloned() - else { - continue; - }; - *summaries.entry(path).or_default() += item; - } - } - - summaries.into_iter() + /// Returns an iterator over coverage summaries by source file path. + pub fn summary_by_file(&self) -> impl Iterator { + self.by_file(|summary: &mut CoverageSummary, item| summary.add_item(item)) } - /// Get coverage items by source file path. - pub fn items_by_source(&self) -> impl Iterator)> { - let mut items_by_source: BTreeMap<_, Vec<_>> = BTreeMap::new(); + /// Returns an iterator over coverage items by source file path. + pub fn items_by_file(&self) -> impl Iterator)> { + self.by_file(|list: &mut Vec<_>, item| list.push(item)) + } - for (version, items) in self.items.iter() { + fn by_file<'a, T: Default>( + &'a self, + mut f: impl FnMut(&mut T, &'a CoverageItem), + ) -> impl Iterator { + let mut by_file: BTreeMap<&Path, T> = BTreeMap::new(); + for (version, items) in &self.items { for item in items { - let Some(path) = - self.source_paths.get(&(version.clone(), item.loc.source_id)).cloned() - else { - continue; - }; - items_by_source.entry(path).or_default().push(item.clone()); + let key = (version.clone(), item.loc.source_id); + let Some(path) = self.source_paths.get(&key) else { continue }; + f(by_file.entry(path).or_default(), item); } } - - items_by_source.into_iter() + by_file.into_iter() } /// Processes data from a [`HitMap`] and sets hit counts for coverage items in this coverage @@ -345,30 +334,34 @@ impl Display for CoverageItem { } } +/// A source location. #[derive(Clone, Debug)] pub struct SourceLocation { /// The source ID. pub source_id: usize, /// The contract this source range is in. pub contract_name: Arc, - /// Start byte in the source code. - pub start: u32, - /// Number of bytes in the source code. - pub length: Option, - /// The line in the source code. - pub line: usize, + /// Byte range. + pub bytes: Range, + /// Line range. Indices are 1-based. + pub lines: Range, } impl Display for SourceLocation { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "source ID {}, line {}, chars {}-{}", - self.source_id, - self.line, - self.start, - self.length.map_or(self.start, |length| self.start + length) - ) + write!(f, "source ID {}, lines {:?}, bytes {:?}", self.source_id, self.lines, self.bytes) + } +} + +impl SourceLocation { + /// Returns the length of the byte range. + pub fn len(&self) -> u32 { + self.bytes.len() as u32 + } + + /// Returns true if the byte range is empty. + pub fn is_empty(&self) -> bool { + self.len() == 0 } } @@ -393,21 +386,43 @@ pub struct CoverageSummary { pub function_hits: usize, } -impl AddAssign<&Self> for CoverageSummary { - fn add_assign(&mut self, other: &Self) { - self.line_count += other.line_count; - self.line_hits += other.line_hits; - self.statement_count += other.statement_count; - self.statement_hits += other.statement_hits; - self.branch_count += other.branch_count; - self.branch_hits += other.branch_hits; - self.function_count += other.function_count; - self.function_hits += other.function_hits; +impl CoverageSummary { + /// Creates a new, empty coverage summary. + pub fn new() -> Self { + Self::default() + } + + /// Creates a coverage summary from a collection of coverage items. + pub fn from_items<'a>(items: impl IntoIterator) -> Self { + let mut summary = Self::default(); + summary.add_items(items); + summary } -} -impl AddAssign<&CoverageItem> for CoverageSummary { - fn add_assign(&mut self, item: &CoverageItem) { + /// Adds another coverage summary to this one. + pub fn merge(&mut self, other: &Self) { + let Self { + line_count, + line_hits, + statement_count, + statement_hits, + branch_count, + branch_hits, + function_count, + function_hits, + } = self; + *line_count += other.line_count; + *line_hits += other.line_hits; + *statement_count += other.statement_count; + *statement_hits += other.statement_hits; + *branch_count += other.branch_count; + *branch_hits += other.branch_hits; + *function_count += other.function_count; + *function_hits += other.function_hits; + } + + /// Adds a coverage item to this summary. + pub fn add_item(&mut self, item: &CoverageItem) { match item.kind { CoverageItemKind::Line => { self.line_count += 1; @@ -435,4 +450,11 @@ impl AddAssign<&CoverageItem> for CoverageSummary { } } } + + /// Adds multiple coverage items to this summary. + pub fn add_items<'a>(&mut self, items: impl IntoIterator) { + for item in items { + self.add_item(item); + } + } } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 4ca111a567404..10d67d825b306 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -16,13 +16,16 @@ use forge::{ use foundry_cli::utils::{LoadConfig, STATIC_FUZZ_SEED}; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ - artifacts::{sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode, SolcLanguage}, + artifacts::{ + sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode, SolcLanguage, Source, + }, Artifact, ArtifactId, Project, ProjectCompileOutput, }; use foundry_config::{Config, SolcReq}; use rayon::prelude::*; use semver::Version; use std::{ + io, path::{Path, PathBuf}, sync::Arc, }; @@ -153,7 +156,7 @@ impl CoverageArgs { let source = SourceFile { ast, - source: fs::read_to_string(&file) + source: Source::read(&file) .wrap_err("Could not read source code for analysis")?, }; versioned_sources @@ -290,19 +293,15 @@ impl CoverageArgs { match report_kind { CoverageReportKind::Summary => SummaryReporter::default().report(&report), CoverageReportKind::Lcov => { - if let Some(report_file) = self.report_file { - return LcovReporter::new(&mut fs::create_file(root.join(report_file))?) - .report(&report) - } else { - return LcovReporter::new(&mut fs::create_file(root.join("lcov.info"))?) - .report(&report) - } + let path = + root.join(self.report_file.as_deref().unwrap_or("lcov.info".as_ref())); + let mut file = io::BufWriter::new(fs::create_file(path)?); + LcovReporter::new(&mut file).report(&report) } CoverageReportKind::Bytecode => { let destdir = root.join("bytecode-coverage"); fs::create_dir_all(&destdir)?; - BytecodeReporter::new(root.clone(), destdir).report(&report)?; - Ok(()) + BytecodeReporter::new(root.clone(), destdir).report(&report) } CoverageReportKind::Debug => DebugReporter.report(&report), }?; diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index de8d0a8aa8535..e1236fa2a40d0 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -50,7 +50,7 @@ impl SummaryReporter { impl CoverageReporter for SummaryReporter { fn report(mut self, report: &CoverageReport) -> eyre::Result<()> { for (path, summary) in report.summary_by_file() { - self.total += &summary; + self.total.merge(&summary); self.add_row(path.display(), summary); } @@ -77,66 +77,68 @@ fn format_cell(hits: usize, total: usize) -> Cell { cell } +/// Writes the coverage report in [LCOV]'s [tracefile format]. +/// +/// [LCOV]: https://github.com/linux-test-project/lcov +/// [tracefile format]: https://man.archlinux.org/man/geninfo.1.en#TRACEFILE_FORMAT pub struct LcovReporter<'a> { - /// Destination buffer - destination: &'a mut (dyn Write + 'a), + out: &'a mut (dyn Write + 'a), } impl<'a> LcovReporter<'a> { - pub fn new(destination: &'a mut (dyn Write + 'a)) -> Self { - Self { destination } + /// Create a new LCOV reporter. + pub fn new(out: &'a mut (dyn Write + 'a)) -> Self { + Self { out } } } impl CoverageReporter for LcovReporter<'_> { fn report(self, report: &CoverageReport) -> eyre::Result<()> { - for (file, items) in report.items_by_source() { - let summary = items.iter().fold(CoverageSummary::default(), |mut summary, item| { - summary += item; - summary - }); + for (path, items) in report.items_by_file() { + let summary = CoverageSummary::from_items(items.iter().copied()); - writeln!(self.destination, "TN:")?; - writeln!(self.destination, "SF:{}", file.display())?; + writeln!(self.out, "TN:")?; + writeln!(self.out, "SF:{}", path.display())?; for item in items { - let line = item.loc.line; + let line = item.loc.lines.start; + let line_end = item.loc.lines.end - 1; let hits = item.hits; match item.kind { - CoverageItemKind::Function { name } => { + CoverageItemKind::Function { ref name } => { let name = format!("{}.{name}", item.loc.contract_name); - writeln!(self.destination, "FN:{line},{name}")?; - writeln!(self.destination, "FNDA:{hits},{name}")?; + writeln!(self.out, "FN:{line},{line_end},{name}")?; + writeln!(self.out, "FNDA:{hits},{name}")?; } CoverageItemKind::Line => { - writeln!(self.destination, "DA:{line},{hits}")?; + writeln!(self.out, "DA:{line},{hits}")?; } CoverageItemKind::Branch { branch_id, path_id, .. } => { writeln!( - self.destination, + self.out, "BRDA:{line},{branch_id},{path_id},{}", if hits == 0 { "-".to_string() } else { hits.to_string() } )?; } // Statements are not in the LCOV format. // We don't add them in order to avoid doubling line hits. - _ => {} + CoverageItemKind::Statement { .. } => {} } } // Function summary - writeln!(self.destination, "FNF:{}", summary.function_count)?; - writeln!(self.destination, "FNH:{}", summary.function_hits)?; + writeln!(self.out, "FNF:{}", summary.function_count)?; + writeln!(self.out, "FNH:{}", summary.function_hits)?; // Line summary - writeln!(self.destination, "LF:{}", summary.line_count)?; - writeln!(self.destination, "LH:{}", summary.line_hits)?; + writeln!(self.out, "LF:{}", summary.line_count)?; + writeln!(self.out, "LH:{}", summary.line_hits)?; // Branch summary - writeln!(self.destination, "BRF:{}", summary.branch_count)?; - writeln!(self.destination, "BRH:{}", summary.branch_hits)?; + writeln!(self.out, "BRF:{}", summary.branch_count)?; + writeln!(self.out, "BRH:{}", summary.branch_hits)?; - writeln!(self.destination, "end_of_record")?; + writeln!(self.out, "end_of_record")?; } sh_println!("Wrote LCOV report.")?; @@ -150,7 +152,7 @@ pub struct DebugReporter; impl CoverageReporter for DebugReporter { fn report(self, report: &CoverageReport) -> eyre::Result<()> { - for (path, items) in report.items_by_source() { + for (path, items) in report.items_by_file() { sh_println!("Uncovered for {}:", path.display())?; items.iter().for_each(|item| { if item.hits == 0 { diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 65900c592ba50..060a603715f04 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -62,8 +62,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | -| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| src/AContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | "#]]); }); @@ -161,8 +161,8 @@ contract BContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/BContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | -| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| src/BContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | "#]]); }); @@ -218,8 +218,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| -| src/AContract.sol | 50.00% (1/2) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 50.00% (1/2) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | +| src/AContract.sol | 66.67% (2/3) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 66.67% (2/3) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | "#]]); @@ -232,8 +232,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|--------------|---------------| -| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 100.00% (2/2) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 100.00% (3/3) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | "#]]); @@ -243,8 +243,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | -| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | +| Total | 100.00% (3/3) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | "#]], ); @@ -299,8 +299,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|--------------|---------------| -| src/AContract.sol | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | "#]]); @@ -313,8 +313,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|--------------|---------------| -| src/AContract.sol | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 100.00% (1/1) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | "#]]); @@ -324,8 +324,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (1/1) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | -| Total | 100.00% (1/1) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (2/2) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | +| Total | 100.00% (2/2) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | "#]], ); @@ -376,18 +376,21 @@ contract AContractTest is DSTest { // We want to make sure DA:8,1 is added only once so line hit is not doubled. assert_data_eq!( std::fs::read_to_string(lcov_info).unwrap(), - str![[r#"TN: + str![[r#" +TN: SF:src/AContract.sol -FN:7,AContract.foo +DA:7,1 +FN:7,9,AContract.foo FNDA:1,AContract.foo DA:8,1 FNF:1 FNH:1 -LF:1 -LH:1 +LF:2 +LH:2 BRF:0 BRH:0 -end[..] +end_of_record + "#]] ); }); @@ -617,8 +620,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|----------------|----------------|----------------|---------------| -| src/Foo.sol | 88.89% (24/27) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | -| Total | 88.89% (24/27) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | +| src/Foo.sol | 91.67% (33/36) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | +| Total | 91.67% (33/36) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | "#]]); @@ -631,8 +634,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|----------------|----------------|----------------|---------------| -| src/Foo.sol | 96.30% (26/27) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | -| Total | 96.30% (26/27) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | +| src/Foo.sol | 97.22% (35/36) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | +| Total | 97.22% (35/36) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | "#]]); @@ -642,8 +645,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|-----------------|---------------| -| src/Foo.sol | 100.00% (27/27) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | -| Total | 100.00% (27/27) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | +| src/Foo.sol | 100.00% (36/36) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | +| Total | 100.00% (36/36) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | "#]], ); @@ -713,10 +716,10 @@ contract AContractTest is DSTest { // constructor calls are not included). cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | -| Total | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|-----------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (14/14) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | +| Total | 100.00% (14/14) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | "#]]); }); @@ -815,8 +818,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|----------------|----------------|--------------|---------------| -| src/Foo.sol | 66.67% (10/15) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | -| Total | 66.67% (10/15) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | +| src/Foo.sol | 75.00% (15/20) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | +| Total | 75.00% (15/20) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | "#]], ); @@ -827,8 +830,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|---------------|---------------| -| src/Foo.sol | 100.00% (15/15) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | -| Total | 100.00% (15/15) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | +| src/Foo.sol | 100.00% (20/20) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | +| Total | 100.00% (20/20) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | "#]], ); @@ -932,8 +935,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|---------------|---------------| -| src/Foo.sol | 100.00% (23/23) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | -| Total | 100.00% (23/23) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | +| src/Foo.sol | 100.00% (30/30) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | +| Total | 100.00% (30/30) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | "#]], ); @@ -1022,10 +1025,10 @@ contract FooTest is DSTest { cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------|---------------|---------------|---------------|---------------| -| src/Foo.sol | 100.00% (8/8) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | -| Total | 100.00% (8/8) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|-----------------|---------------|---------------|---------------| +| src/Foo.sol | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | +| Total | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | "#]], ); @@ -1082,8 +1085,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| -| src/AContract.sol | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | -| Total | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| src/AContract.sol | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| Total | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | "#]]); @@ -1096,8 +1099,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| -| src/AContract.sol | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | -| Total | 50.00% (2/4) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| src/AContract.sol | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +| Total | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | "#]]); @@ -1107,8 +1110,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (4/4) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | -| Total | 100.00% (4/4) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (5/5) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | +| Total | 100.00% (5/5) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | "#]], ); @@ -1171,8 +1174,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| -| src/AContract.sol | 75.00% (3/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 75.00% (3/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +| src/AContract.sol | 80.00% (4/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 80.00% (4/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | "#]]); @@ -1185,8 +1188,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| -| src/AContract.sol | 50.00% (2/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 50.00% (2/4) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +| src/AContract.sol | 60.00% (3/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +| Total | 60.00% (3/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | "#]]); @@ -1196,8 +1199,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (4/4) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | -| Total | 100.00% (4/4) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (5/5) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | +| Total | 100.00% (5/5) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | "#]], ); @@ -1264,10 +1267,10 @@ contract AContractTest is DSTest { cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | -| Total | 100.00% (9/9) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|-----------------|---------------|---------------|---------------| +| src/AContract.sol | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | +| Total | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | "#]]); }); @@ -1316,8 +1319,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | -| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| src/AContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | "#]]); }); @@ -1359,8 +1362,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | -| Total | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (1/1) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | +| Total | 100.00% (1/1) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | "#]]); }); @@ -1408,8 +1411,8 @@ contract AContractTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | -| Total | 100.00% (2/2) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| src/AContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | "#]]); }); @@ -1442,8 +1445,8 @@ contract AContract { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|-------------|--------------|---------------|-------------| -| src/AContract.sol | 0.00% (0/4) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | -| Total | 0.00% (0/4) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | +| src/AContract.sol | 0.00% (0/5) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | +| Total | 0.00% (0/5) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | "#]]); }); From ac81a53d1d5823919ffbadd3c65f081927aa11f2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 01:16:06 +0000 Subject: [PATCH 1743/1963] chore(deps): weekly `cargo update` (#9440) Locking 52 packages to latest compatible versions Updating alloy-dyn-abi v0.8.12 -> v0.8.14 Updating alloy-eip7702 v0.4.1 -> v0.4.2 Updating alloy-json-abi v0.8.12 -> v0.8.14 Updating alloy-primitives v0.8.12 -> v0.8.14 Updating alloy-sol-macro v0.8.12 -> v0.8.14 Updating alloy-sol-macro-expander v0.8.12 -> v0.8.14 Updating alloy-sol-macro-input v0.8.12 -> v0.8.14 Updating alloy-sol-type-parser v0.8.12 -> v0.8.14 Updating alloy-sol-types v0.8.12 -> v0.8.14 Updating bon v3.0.2 -> v3.1.1 Updating bon-macros v3.0.2 -> v3.1.1 Updating bytes v1.8.0 -> v1.9.0 Updating cargo-platform v0.1.8 -> v0.1.9 Updating cc v1.2.1 -> v1.2.2 Updating const-hex v1.13.2 -> v1.14.0 Updating divan v0.1.15 -> v0.1.16 Updating divan-macros v0.1.15 -> v0.1.16 Updating errno v0.3.9 -> v0.3.10 Updating foundry-fork-db v0.7.1 -> v0.7.2 (available: v0.8.0) Updating gix-config-value v0.14.9 -> v0.14.10 Updating gix-date v0.9.1 -> v0.9.2 Updating gix-path v0.10.12 -> v0.10.13 Updating gix-sec v0.10.9 -> v0.10.10 Updating gix-validate v0.9.1 -> v0.9.2 Updating hashbrown v0.15.1 -> v0.15.2 Updating http-range-header v0.4.1 -> v0.4.2 Updating itoa v1.0.13 -> v1.0.14 Updating jiff v0.1.14 -> v0.1.15 Updating js-sys v0.3.72 -> v0.3.74 Updating libc v0.2.164 -> v0.2.167 Updating mdbook v0.4.42 -> v0.4.43 Updating miette v7.2.0 -> v7.4.0 Updating miette-derive v7.2.0 -> v7.4.0 Updating mio v1.0.2 -> v1.0.3 Updating rustc-hash v2.0.0 -> v2.1.0 Updating rustls v0.23.18 -> v0.23.19 Updating socket2 v0.5.7 -> v0.5.8 Updating syn v2.0.89 -> v2.0.90 Updating syn-solidity v0.8.12 -> v0.8.14 Updating terminal_size v0.4.0 -> v0.4.1 Updating tracing v0.1.40 -> v0.1.41 Updating tracing-attributes v0.1.27 -> v0.1.28 Updating tracing-core v0.1.32 -> v0.1.33 Updating tracing-error v0.2.0 -> v0.2.1 Updating tracing-subscriber v0.3.18 -> v0.3.19 Updating wasm-bindgen v0.2.95 -> v0.2.97 Updating wasm-bindgen-backend v0.2.95 -> v0.2.97 Updating wasm-bindgen-futures v0.4.45 -> v0.4.47 Updating wasm-bindgen-macro v0.2.95 -> v0.2.97 Updating wasm-bindgen-macro-support v0.2.95 -> v0.2.97 Updating wasm-bindgen-shared v0.2.95 -> v0.2.97 Updating web-sys v0.3.72 -> v0.3.74 note: pass `--verbose` to see 43 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 383 +++++++++++++++++++++++++++-------------------------- 1 file changed, 192 insertions(+), 191 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b83fd212c9443..a0dafa83f97c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2364c782a245cf8725ea6dbfca5f530162702b5d685992ea03ce64529136cc" +checksum = "80759b3f57b3b20fa7cd8fef6479930fc95461b58ff8adea6e87e618449c8a1d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6cee6a35793f3db8a5ffe60e86c695f321d081a567211245f503e8c498fce8" +checksum = "4c986539255fb839d1533c128e190e557e52ff652c9ef62939e233a81dd93f7e" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -202,9 +202,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84c506bf264110fa7e90d9924f742f40ef53c6572ea56a0b0bd714a567ed389" +checksum = "ac4b22b3e51cac09fd2adfcc73b55f447b4df669f983c13f7894ec82b607c63f" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -281,9 +281,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fce5dbd6a4f118eecc4719eaa9c7ffc31c315e6c5ccde3642db927802312425" +checksum = "9db948902dfbae96a73c2fbf1f7abec62af034ab883e4c777c3fd29702bd6e2c" dependencies = [ "alloy-rlp", "arbitrary", @@ -294,7 +294,7 @@ dependencies = [ "derive_more", "foldhash", "getrandom", - "hashbrown 0.15.1", + "hashbrown 0.15.2", "hex-literal", "indexmap 2.6.0", "itoa", @@ -391,7 +391,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -632,23 +632,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9343289b4a7461ed8bab8618504c995c049c082b70c7332efd7b32125633dc05" +checksum = "3bfd7853b65a2b4f49629ec975fee274faf6dff15ab8894c620943398ef283c0" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4222d70bec485ceccc5d8fd4f2909edd65b5d5e43d4aca0b5dcee65d519ae98f" +checksum = "82ec42f342d9a9261699f8078e57a7a4fda8aaa73c1a212ed3987080e6a9cd13" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -658,16 +658,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e17f2677369571b976e51ea1430eb41c3690d344fef567b840bfc0b01b6f83a" +checksum = "ed2c50e6a62ee2b4f7ab3c6d0366e5770a21cad426e109c2f40335a1b3aff3df" dependencies = [ "alloy-json-abi", "const-hex", @@ -676,15 +676,15 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.89", + "syn 2.0.90", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa64d80ae58ffaafdff9d5d84f58d03775f66c84433916dc9a64ed16af5755da" +checksum = "ac17c6e89a50fb4a758012e4b409d9a0ba575228e69b539fe37d7a1bd507ca4a" dependencies = [ "serde", "winnow", @@ -692,9 +692,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6520d427d4a8eb7aa803d852d7a52ceb0c519e784c292f64bb339e636918cf27" +checksum = "c9dc0fffe397aa17628160e16b89f704098bf3c9d74d5d369ebc239575936de5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -769,7 +769,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.1.0", - "rustls 0.23.18", + "rustls 0.23.19", "serde_json", "tokio", "tokio-tungstenite", @@ -1196,7 +1196,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1218,7 +1218,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1229,7 +1229,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1282,7 +1282,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1796,9 +1796,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.0.2" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a636f83af97c6946f3f5cf5c268ec02375bf5efd371110292dfd57961f57a509" +checksum = "1e47d5c63335658326076cf7c81795af665c534ea552da69526d6cef51b12ed9" dependencies = [ "bon-macros", "rustversion", @@ -1806,9 +1806,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.0.2" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7eaf1bfaa5b8d512abfd36d0c432591fef139d3de9ee54f1f839ea109d70d33" +checksum = "b162272b6d55562ea30cc937d74ef4d07399e507bfd6eb3860f6a845c7264eef" dependencies = [ "darling", "ident_case", @@ -1816,7 +1816,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -1872,9 +1872,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" dependencies = [ "serde", ] @@ -1936,9 +1936,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" dependencies = [ "serde", ] @@ -2033,9 +2033,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "shlex", ] @@ -2199,7 +2199,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2417,9 +2417,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487981fa1af147182687064d0a2c336586d337a606595ced9ffb0c685c250c73" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" dependencies = [ "cfg-if", "cpufeatures", @@ -2529,7 +2529,7 @@ checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ "bitflags 2.6.0", "crossterm_winapi", - "mio 1.0.2", + "mio 1.0.3", "parking_lot", "rustix", "signal-hook", @@ -2614,7 +2614,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2625,7 +2625,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2698,7 +2698,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2719,7 +2719,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2729,7 +2729,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -2750,7 +2750,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "unicode-xid", ] @@ -2864,14 +2864,14 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] name = "divan" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e05d17bd4ff1c1e7998ed4623d2efd91f72f1e24141ac33aac9377974270e1f" +checksum = "ccc40f214f0d9e897cfc72e2edfa5c225d3252f758c537f11ac0a80371c073a6" dependencies = [ "cfg-if", "clap", @@ -2883,13 +2883,13 @@ dependencies = [ [[package]] name = "divan-macros" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b4464d46ce68bfc7cb76389248c7c254def7baca8bece0693b02b83842c4c88" +checksum = "7bdb5411188f7f878a17964798c1264b6b0a9f915bd39b20bf99193c923e1b4e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3016,7 +3016,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -3050,12 +3050,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3151,7 +3151,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.89", + "syn 2.0.90", "toml 0.8.19", "walkdir", ] @@ -3179,7 +3179,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.89", + "syn 2.0.90", "tempfile", "thiserror 1.0.69", "tiny-keccak", @@ -3572,7 +3572,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4114,9 +4114,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fea8068a6b7929229f72059296da09bf3c1d15569fdb4a351d2983450587c12" +checksum = "0f040169c6573e9989d1a26c3dcbe645ef8e4edabbf64af98958552da1073e4e" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -4153,7 +4153,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4312,7 +4312,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4459,27 +4459,27 @@ dependencies = [ [[package]] name = "gix-config-value" -version = "0.14.9" +version = "0.14.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3de3fdca9c75fa4b83a76583d265fa49b1de6b088ebcd210749c24ceeb74660" +checksum = "49aaeef5d98390a3bcf9dbc6440b520b793d1bf3ed99317dc407b02be995b28e" dependencies = [ "bitflags 2.6.0", "bstr", "gix-path", "libc", - "thiserror 1.0.69", + "thiserror 2.0.3", ] [[package]] name = "gix-date" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d10d543ac13c97292a15e8e8b7889cd006faf739777437ed95362504b8fe81a0" +checksum = "691142b1a34d18e8ed6e6114bc1a2736516c5ad60ef3aa9bd1b694886e3ca92d" dependencies = [ "bstr", "itoa", "jiff", - "thiserror 1.0.69", + "thiserror 2.0.3", ] [[package]] @@ -4562,15 +4562,15 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.12" +version = "0.10.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c04e5a94fdb56b1e91eb7df2658ad16832428b8eeda24ff1a0f0288de2bce554" +checksum = "afc292ef1a51e340aeb0e720800338c805975724c1dfbd243185452efd8645b7" dependencies = [ "bstr", "gix-trace", "home", "once_cell", - "thiserror 1.0.69", + "thiserror 2.0.3", ] [[package]] @@ -4596,9 +4596,9 @@ dependencies = [ [[package]] name = "gix-sec" -version = "0.10.9" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2007538eda296445c07949cf04f4a767307d887184d6b3e83e2d636533ddc6e" +checksum = "a8b876ef997a955397809a2ec398d6a45b7a55b4918f2446344330f778d14fd6" dependencies = [ "bitflags 2.6.0", "gix-path", @@ -4637,12 +4637,12 @@ dependencies = [ [[package]] name = "gix-validate" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e187b263461bc36cea17650141567753bc6207d036cedd1de6e81a52f277ff68" +checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr", - "thiserror 1.0.69", + "thiserror 2.0.3", ] [[package]] @@ -4762,9 +4762,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -4846,7 +4846,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -4907,9 +4907,9 @@ dependencies = [ [[package]] name = "http-range-header" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a" +checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" [[package]] name = "httparse" @@ -5010,7 +5010,7 @@ dependencies = [ "http 1.1.0", "hyper 1.5.1", "hyper-util", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", @@ -5205,7 +5205,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5305,7 +5305,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5338,7 +5338,7 @@ checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "arbitrary", "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", "serde", ] @@ -5424,7 +5424,7 @@ dependencies = [ "pretty_assertions", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5494,15 +5494,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d9d414fc817d3e3d62b2598616733f76c4cc74fbac96069674739b881295c8" +checksum = "db69f08d4fb10524cacdb074c10b296299d71274ddbc830a8ee65666867002e9" dependencies = [ "jiff-tzdb-platform", "windows-sys 0.59.0", @@ -5525,10 +5525,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -5662,9 +5663,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.164" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libdbus-sys" @@ -5758,7 +5759,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] @@ -5820,9 +5821,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7624879735513024d323e7267a0b3a7176aceb0db537939beb4ee31d9e8945e3" +checksum = "fe1f98b8d66e537d2f0ba06e7dec4f44001deec539a2d18bfc102d6a86189148" dependencies = [ "ammonia", "anyhow", @@ -5883,9 +5884,9 @@ dependencies = [ [[package]] name = "miette" -version = "7.2.0" +version = "7.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +checksum = "317f146e2eb7021892722af37cf1b971f0a70c8406f487e24952667616192c64" dependencies = [ "cfg-if", "miette-derive", @@ -5895,13 +5896,13 @@ dependencies = [ [[package]] name = "miette-derive" -version = "7.2.0" +version = "7.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -5958,11 +5959,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "log", "wasi", @@ -5992,7 +5992,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6266,7 +6266,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6406,7 +6406,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6487,7 +6487,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6570,7 +6570,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6629,7 +6629,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6713,7 +6713,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6771,7 +6771,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6872,7 +6872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6950,7 +6950,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -6970,7 +6970,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "version_check", "yansi", ] @@ -7034,7 +7034,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -7057,7 +7057,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -7166,7 +7166,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.18", + "rustls 0.23.19", "socket2", "thiserror 2.0.3", "tokio", @@ -7184,7 +7184,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "slab", "thiserror 2.0.3", @@ -7418,7 +7418,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7659,9 +7659,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" dependencies = [ "rand", ] @@ -7717,9 +7717,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.18" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -7897,7 +7897,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -7939,7 +7939,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8125,7 +8125,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8136,7 +8136,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8180,7 +8180,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8226,7 +8226,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8315,7 +8315,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio 1.0.2", + "mio 1.0.3", "signal-hook", ] @@ -8430,9 +8430,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -8531,7 +8531,7 @@ checksum = "f0cc54b74e214647c1bbfc098d080cc5deac77f8dcb99aca91747276b01a15ad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8695,7 +8695,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8763,9 +8763,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.89" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -8774,14 +8774,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76fe0a3e1476bdaa0775b9aec5b869ed9520c2b2fedfe9c6df3618f8ea6290b" +checksum = "da0523f59468a2696391f2a772edc089342aacd53c3caa2ac3264e598edf119b" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8807,7 +8807,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8853,9 +8853,9 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" +checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" dependencies = [ "rustix", "windows-sys 0.59.0", @@ -8917,7 +8917,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -8928,7 +8928,7 @@ checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9046,7 +9046,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.2", + "mio 1.0.3", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -9063,7 +9063,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -9092,7 +9092,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "tokio", ] @@ -9129,7 +9129,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -9320,9 +9320,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -9332,20 +9332,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -9353,9 +9353,9 @@ dependencies = [ [[package]] name = "tracing-error" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db" dependencies = [ "tracing", "tracing-subscriber", @@ -9374,9 +9374,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", "nu-ansi-term", @@ -9455,7 +9455,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.18", + "rustls 0.23.19", "rustls-pki-types", "sha1", "thiserror 1.0.69", @@ -9734,9 +9734,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -9745,36 +9745,37 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9782,22 +9783,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "wasm-streams" @@ -9891,9 +9892,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", @@ -10029,7 +10030,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10040,7 +10041,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10051,7 +10052,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10062,7 +10063,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10342,7 +10343,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "synstructure", ] @@ -10364,7 +10365,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10384,7 +10385,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", "synstructure", ] @@ -10405,7 +10406,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] @@ -10427,7 +10428,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.90", ] [[package]] From 168b239486c834d9d1fafdd98950e377c044b4db Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 07:56:51 +0200 Subject: [PATCH 1744/1963] fix(coverage): special functions have no name (#9441) * fix(coverage): special functions have no name * test: don't to_string * test: rm --summary which is not --report=summary * test: add regression test for #9437 * fmt * docs --- Cargo.lock | 1 + crates/evm/coverage/src/analysis.rs | 15 +- crates/forge/bin/cmd/coverage.rs | 5 +- crates/forge/src/coverage.rs | 5 +- crates/forge/tests/cli/coverage.rs | 275 +++++++++++++++++----------- crates/test-utils/Cargo.toml | 1 + crates/test-utils/src/util.rs | 24 ++- 7 files changed, 202 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0dafa83f97c0..3f8fa5bb58ef3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4173,6 +4173,7 @@ dependencies = [ "regex", "serde_json", "snapbox", + "tempfile", "tokio", "tracing", "tracing-subscriber", diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 69bd73075a3f6..07b9160350c40 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -52,16 +52,20 @@ impl<'a> ContractVisitor<'a> { fn visit_function_definition(&mut self, node: &Node) -> eyre::Result<()> { let Some(body) = &node.body else { return Ok(()) }; - let kind: String = - node.attribute("kind").ok_or_else(|| eyre::eyre!("Function has no kind"))?; - let name: String = node.attribute("name").ok_or_else(|| eyre::eyre!("Function has no name"))?; + let kind: String = + node.attribute("kind").ok_or_else(|| eyre::eyre!("Function has no kind"))?; // Do not add coverage item for constructors without statements. if kind == "constructor" && !has_statements(body) { return Ok(()) } + + // `fallback`, `receive`, and `constructor` functions have an empty `name`. + // Use the `kind` itself as the name. + let name = if name.is_empty() { kind } else { name }; + self.push_item_kind(CoverageItemKind::Function { name }, &node.src); self.visit_block(body) } @@ -498,10 +502,7 @@ fn has_statements(node: &Node) -> bool { NodeType::TryStatement | NodeType::VariableDeclarationStatement | NodeType::WhileStatement => true, - _ => { - let statements: Vec = node.attribute("statements").unwrap_or_default(); - !statements.is_empty() - } + _ => node.attribute::>("statements").is_some_and(|s| !s.is_empty()), } } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 10d67d825b306..3a7d434369993 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -310,9 +310,10 @@ impl CoverageArgs { } } -// TODO: HTML -#[derive(Clone, Debug, ValueEnum)] +/// Coverage reports to generate. +#[derive(Clone, Debug, Default, ValueEnum)] pub enum CoverageReportKind { + #[default] Summary, Lcov, Debug, diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index e1236fa2a40d0..14fc5e7be8023 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -102,12 +102,13 @@ impl CoverageReporter for LcovReporter<'_> { for item in items { let line = item.loc.lines.start; - let line_end = item.loc.lines.end - 1; + // `lines` is half-open, so we need to subtract 1 to get the last included line. + let end_line = item.loc.lines.end - 1; let hits = item.hits; match item.kind { CoverageItemKind::Function { ref name } => { let name = format!("{}.{name}", item.loc.contract_name); - writeln!(self.out, "FN:{line},{line_end},{name}")?; + writeln!(self.out, "FN:{line},{end_line},{name}")?; writeln!(self.out, "FNDA:{hits},{name}")?; } CoverageItemKind::Line => { diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 060a603715f04..9b0569da6ff6b 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1,18 +1,94 @@ -use foundry_test_utils::{assert_data_eq, str}; +use foundry_common::fs; +use foundry_test_utils::{ + snapbox::{Data, IntoData}, + TestCommand, TestProject, +}; +use std::path::Path; + +fn basic_coverage_base(prj: TestProject, mut cmd: TestCommand) { + cmd.args(["coverage", "--report=lcov", "--report=summary"]).assert_success().stdout_eq(str![[ + r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Analysing contracts... +Running tests... + +Ran 2 tests for test/Counter.t.sol:CounterTest +[PASS] testFuzz_SetNumber(uint256) (runs: 256, [AVG_GAS]) +[PASS] test_Increment() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) +Wrote LCOV report. +| File | % Lines | % Statements | % Branches | % Funcs | +|----------------------|---------------|---------------|---------------|---------------| +| script/Counter.s.sol | 0.00% (0/5) | 0.00% (0/3) | 100.00% (0/0) | 0.00% (0/2) | +| src/Counter.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +| Total | 44.44% (4/9) | 40.00% (2/5) | 100.00% (0/0) | 50.00% (2/4) | + +"# + ]]); + + let lcov = prj.root().join("lcov.info"); + assert!(lcov.exists(), "lcov.info was not created"); + assert_data_eq!( + Data::read_from(&lcov, None), + str![[r#" +TN: +SF:script/Counter.s.sol +DA:10,0 +FN:10,10,CounterScript.setUp +FNDA:0,CounterScript.setUp +DA:12,0 +FN:12,18,CounterScript.run +FNDA:0,CounterScript.run +DA:13,0 +DA:15,0 +DA:17,0 +FNF:2 +FNH:0 +LF:5 +LH:0 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/Counter.sol +DA:7,258 +FN:7,9,Counter.setNumber +FNDA:258,Counter.setNumber +DA:8,258 +DA:11,1 +FN:11,13,Counter.increment +FNDA:1,Counter.increment +DA:12,1 +FNF:2 +FNH:2 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record -forgetest!(basic_coverage, |_prj, cmd| { - cmd.args(["coverage"]); - cmd.assert_success(); +"#]] + ); +} + +forgetest_init!(basic_coverage, |prj, cmd| { + basic_coverage_base(prj, cmd); }); -forgetest!(report_file_coverage, |prj, cmd| { - cmd.arg("coverage").args([ - "--report".to_string(), - "lcov".to_string(), - "--report-file".to_string(), - prj.root().join("lcov.info").to_str().unwrap().to_string(), - ]); - cmd.assert_success(); +forgetest_init!(basic_coverage_crlf, |prj, cmd| { + // Manually replace `\n` with `\r\n` in the source file. + let make_crlf = |path: &Path| { + fs::write(path, fs::read_to_string(path).unwrap().replace('\n', "\r\n")).unwrap() + }; + make_crlf(&prj.paths().sources.join("Counter.sol")); + make_crlf(&prj.paths().scripts.join("Counter.s.sol")); + + // Should have identical stdout and lcov output. + basic_coverage_base(prj, cmd); }); forgetest!(test_setup_coverage, |prj, cmd| { @@ -58,7 +134,7 @@ contract AContractTest is DSTest { .unwrap(); // Assert 100% coverage (init function coverage called in setUp is accounted). - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| @@ -151,20 +227,16 @@ contract BContractTest is DSTest { .unwrap(); // Assert AContract is not included in report. - cmd.arg("coverage") - .args([ - "--no-match-coverage".to_string(), - "AContract".to_string(), // Filter out `AContract` - ]) - .assert_success() - .stdout_eq(str![[r#" + cmd.arg("coverage").arg("--no-match-coverage=AContract").assert_success().stdout_eq(str![[ + r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| | src/BContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | | Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | -"#]]); +"# + ]]); }); forgetest!(test_assert_coverage, |prj, cmd| { @@ -211,43 +283,38 @@ contract AContractTest is DSTest { .unwrap(); // Assert 50% branch coverage for assert failure. - cmd.arg("coverage") - .args(["--mt".to_string(), "testAssertRevertBranch".to_string()]) - .assert_success() - .stdout_eq(str![[r#" + cmd.arg("coverage").args(["--mt", "testAssertRevertBranch"]).assert_success().stdout_eq(str![ + [r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| | src/AContract.sol | 66.67% (2/3) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | | Total | 66.67% (2/3) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | -"#]]); +"#] + ]); // Assert 50% branch coverage for proper assert. - cmd.forge_fuse() - .arg("coverage") - .args(["--mt".to_string(), "testAssertBranch".to_string()]) - .assert_success() - .stdout_eq(str![[r#" + cmd.forge_fuse().arg("coverage").args(["--mt", "testAssertBranch"]).assert_success().stdout_eq( + str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|--------------|---------------| | src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | | Total | 100.00% (3/3) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | -"#]]); +"#]], + ); // Assert 100% coverage (assert properly covered). - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| | src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | | Total | 100.00% (3/3) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | -"#]], - ); +"#]]); }); forgetest!(test_require_coverage, |prj, cmd| { @@ -292,10 +359,7 @@ contract AContractTest is DSTest { .unwrap(); // Assert 50% branch coverage if only revert tested. - cmd.arg("coverage") - .args(["--mt".to_string(), "testRequireRevert".to_string()]) - .assert_success() - .stdout_eq(str![[r#" + cmd.arg("coverage").args(["--mt", "testRequireRevert"]).assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|--------------|---------------| @@ -307,7 +371,7 @@ contract AContractTest is DSTest { // Assert 50% branch coverage if only happy path tested. cmd.forge_fuse() .arg("coverage") - .args(["--mt".to_string(), "testRequireNoRevert".to_string()]) + .args(["--mt", "testRequireNoRevert"]) .assert_success() .stdout_eq(str![[r#" ... @@ -319,16 +383,14 @@ contract AContractTest is DSTest { "#]]); // Assert 100% branch coverage. - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| | src/AContract.sol | 100.00% (2/2) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | | Total | 100.00% (2/2) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | -"#]], - ); +"#]]); }); forgetest!(test_line_hit_not_doubled, |prj, cmd| { @@ -363,19 +425,9 @@ contract AContractTest is DSTest { ) .unwrap(); - let lcov_info = prj.root().join("lcov.info"); - cmd.arg("coverage").args([ - "--report".to_string(), - "lcov".to_string(), - "--report-file".to_string(), - lcov_info.to_str().unwrap().to_string(), - ]); - cmd.assert_success(); - assert!(lcov_info.exists()); - // We want to make sure DA:8,1 is added only once so line hit is not doubled. - assert_data_eq!( - std::fs::read_to_string(lcov_info).unwrap(), + assert_lcov( + cmd.arg("coverage"), str![[r#" TN: SF:src/AContract.sol @@ -391,7 +443,7 @@ BRF:0 BRH:0 end_of_record -"#]] +"#]], ); }); @@ -611,10 +663,7 @@ contract FooTest is DSTest { // Assert no coverage for single path branch. 2 branches (parent and child) not covered. cmd.arg("coverage") - .args([ - "--nmt".to_string(), - "test_single_path_child_branch|test_single_path_parent_branch".to_string(), - ]) + .args(["--nmt", "test_single_path_child_branch|test_single_path_parent_branch"]) .assert_success() .stdout_eq(str![[r#" ... @@ -628,7 +677,7 @@ contract FooTest is DSTest { // Assert no coverage for single path child branch. 1 branch (child) not covered. cmd.forge_fuse() .arg("coverage") - .args(["--nmt".to_string(), "test_single_path_child_branch".to_string()]) + .args(["--nmt", "test_single_path_child_branch"]) .assert_success() .stdout_eq(str![[r#" ... @@ -640,16 +689,14 @@ contract FooTest is DSTest { "#]]); // Assert 100% coverage. - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|-----------------|---------------| | src/Foo.sol | 100.00% (36/36) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | | Total | 100.00% (36/36) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | -"#]], - ); +"#]]); }); forgetest!(test_function_call_coverage, |prj, cmd| { @@ -712,9 +759,8 @@ contract AContractTest is DSTest { ) .unwrap(); - // Assert 100% coverage and only 9 lines reported (comments, type conversions and struct - // constructor calls are not included). - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + // Assert 100% coverage. + cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|-----------------|---------------|---------------|---------------| @@ -813,28 +859,24 @@ contract FooTest is DSTest { .unwrap(); // Assert coverage not 100% for happy paths only. - cmd.arg("coverage").args(["--mt".to_string(), "happy".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.arg("coverage").args(["--mt", "happy"]).assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|----------------|----------------|--------------|---------------| | src/Foo.sol | 75.00% (15/20) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | | Total | 75.00% (15/20) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | -"#]], - ); +"#]]); // Assert 100% branch coverage (including clauses without body). - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|---------------|---------------| | src/Foo.sol | 100.00% (20/20) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | | Total | 100.00% (20/20) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | -"#]], - ); +"#]]); }); forgetest!(test_yul_coverage, |prj, cmd| { @@ -930,16 +972,14 @@ contract FooTest is DSTest { ) .unwrap(); - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|---------------|---------------| | src/Foo.sol | 100.00% (30/30) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | | Total | 100.00% (30/30) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | -"#]], - ); +"#]]); }); forgetest!(test_misc_coverage, |prj, cmd| { @@ -1022,16 +1062,14 @@ contract FooTest is DSTest { ) .unwrap(); - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|---------------|---------------|---------------| | src/Foo.sol | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | | Total | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | -"#]], - ); +"#]]); }); // https://github.com/foundry-rs/foundry/issues/8605 @@ -1078,10 +1116,7 @@ contract AContractTest is DSTest { .unwrap(); // Assert 50% coverage for true branches. - cmd.arg("coverage") - .args(["--mt".to_string(), "testTrueCoverage".to_string()]) - .assert_success() - .stdout_eq(str![[r#" + cmd.arg("coverage").args(["--mt", "testTrueCoverage"]).assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| @@ -1093,7 +1128,7 @@ contract AContractTest is DSTest { // Assert 50% coverage for false branches. cmd.forge_fuse() .arg("coverage") - .args(["--mt".to_string(), "testFalseCoverage".to_string()]) + .args(["--mt", "testFalseCoverage"]) .assert_success() .stdout_eq(str![[r#" ... @@ -1105,16 +1140,14 @@ contract AContractTest is DSTest { "#]]); // Assert 100% coverage (true/false branches properly covered). - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| | src/AContract.sol | 100.00% (5/5) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | | Total | 100.00% (5/5) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | -"#]], - ); +"#]]); }); // https://github.com/foundry-rs/foundry/issues/8604 @@ -1167,10 +1200,7 @@ contract AContractTest is DSTest { .unwrap(); // Assert 50% coverage for true branches. - cmd.arg("coverage") - .args(["--mt".to_string(), "testTrueCoverage".to_string()]) - .assert_success() - .stdout_eq(str![[r#" + cmd.arg("coverage").args(["--mt", "testTrueCoverage"]).assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|--------------|--------------|--------------|---------------| @@ -1182,7 +1212,7 @@ contract AContractTest is DSTest { // Assert 50% coverage for false branches. cmd.forge_fuse() .arg("coverage") - .args(["--mt".to_string(), "testFalseCoverage".to_string()]) + .args(["--mt", "testFalseCoverage"]) .assert_success() .stdout_eq(str![[r#" ... @@ -1194,16 +1224,14 @@ contract AContractTest is DSTest { "#]]); // Assert 100% coverage (true/false branches properly covered). - cmd.forge_fuse().arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq( - str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| | src/AContract.sol | 100.00% (5/5) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | | Total | 100.00% (5/5) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | -"#]], - ); +"#]]); }); forgetest!(test_identical_bytecodes, |prj, cmd| { @@ -1265,7 +1293,7 @@ contract AContractTest is DSTest { ) .unwrap(); - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|-----------------|---------------|---------------|---------------| @@ -1315,7 +1343,7 @@ contract AContractTest is DSTest { ) .unwrap(); - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| @@ -1358,7 +1386,7 @@ contract AContractTest is DSTest { .unwrap(); // Assert there's only one function (`increment`) reported. - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| @@ -1406,8 +1434,32 @@ contract AContractTest is DSTest { ) .unwrap(); - // Assert both constructor and receive functions coverage reported. - cmd.arg("coverage").args(["--summary".to_string()]).assert_success().stdout_eq(str![[r#" + // Assert both constructor and receive functions coverage reported and appear in LCOV. + assert_lcov( + cmd.arg("coverage"), + str![[r#" +TN: +SF:src/AContract.sol +DA:7,1 +FN:7,9,AContract.constructor +FNDA:1,AContract.constructor +DA:8,1 +DA:11,1 +FN:11,13,AContract.receive +FNDA:1,AContract.receive +DA:12,1 +FNF:2 +FNH:2 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record + +"#]], + ); + + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| @@ -1450,3 +1502,8 @@ contract AContract { "#]]); }); + +#[track_caller] +fn assert_lcov(cmd: &mut TestCommand, data: impl IntoData) { + cmd.args(["--report=lcov", "--report-file"]).assert_file(data); +} diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 11b7800e6bba9..efe6d288ff9e0 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -31,6 +31,7 @@ tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } rand.workspace = true snapbox = { version = "0.6", features = ["json", "regex"] } +tempfile.workspace = true [dev-dependencies] tokio.workspace = true diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index f887a40ce7a1c..a86304923ffef 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -11,7 +11,7 @@ use foundry_compilers::{ use foundry_config::Config; use parking_lot::Mutex; use regex::Regex; -use snapbox::{assert_data_eq, cmd::OutputAssert, str, IntoData}; +use snapbox::{assert_data_eq, cmd::OutputAssert, Data, IntoData}; use std::{ env, ffi::OsStr, @@ -902,10 +902,10 @@ impl TestCommand { assert_data_eq!(actual, expected); } - /// Runs the command and asserts that it **failed** nothing was printed to stdout. + /// Runs the command and asserts that it **succeeded** nothing was printed to stdout. #[track_caller] pub fn assert_empty_stdout(&mut self) { - self.assert_success().stdout_eq(str![[r#""#]]); + self.assert_success().stdout_eq(Data::new()); } /// Runs the command and asserts that it failed. @@ -923,7 +923,23 @@ impl TestCommand { /// Runs the command and asserts that it **failed** nothing was printed to stderr. #[track_caller] pub fn assert_empty_stderr(&mut self) { - self.assert_failure().stderr_eq(str![[r#""#]]); + self.assert_failure().stderr_eq(Data::new()); + } + + /// Runs the command with a temporary file argument and asserts that the contents of the file + /// match the given data. + #[track_caller] + pub fn assert_file(&mut self, data: impl IntoData) { + self.assert_file_with(|this, path| _ = this.arg(path).assert_success(), data); + } + + /// Creates a temporary file, passes it to `f`, then asserts that the contents of the file match + /// the given data. + #[track_caller] + pub fn assert_file_with(&mut self, f: impl FnOnce(&mut Self, &Path), data: impl IntoData) { + let file = tempfile::NamedTempFile::new().expect("couldn't create temporary file"); + f(self, file.path()); + assert_data_eq!(Data::read_from(file.path(), None), data); } /// Does not apply [`snapbox`] redactions to the command output. From d4e91c80266defb486c7b3626f44600f0cc1e0fc Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 07:57:05 +0200 Subject: [PATCH 1745/1963] feat(cast): allow some more stdin inputs (#9442) --- crates/cast/bin/args.rs | 14 +++++++------- crates/cast/bin/main.rs | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index fb7fb07578903..47bf9a8849f60 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -422,7 +422,7 @@ pub enum CastSubcommand { #[command(visible_alias = "ca")] ComputeAddress { /// The deployer address. - address: Option, + address: Option
, /// The nonce of the deployer address. #[arg(long)] @@ -432,11 +432,11 @@ pub enum CastSubcommand { rpc: RpcOpts, }, - /// Disassembles hex encoded bytecode into individual / human readable opcodes + /// Disassembles a hex-encoded bytecode into a human-readable representation. #[command(visible_alias = "da")] Disassemble { - /// The hex encoded bytecode. - bytecode: String, + /// The hex-encoded bytecode. + bytecode: Option, }, /// Build and sign a transaction. @@ -754,7 +754,7 @@ pub enum CastSubcommand { #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, - /// Disassemble bytecodes into individual opcodes. + /// Disassemble bytecodes. #[arg(long, short)] disassemble: bool, @@ -1030,8 +1030,8 @@ pub enum CastSubcommand { /// Extracts function selectors and arguments from bytecode #[command(visible_alias = "sel")] Selectors { - /// The hex encoded bytecode. - bytecode: String, + /// The hex-encoded bytecode. + bytecode: Option, /// Resolve the function signatures for the extracted selectors using https://openchain.xyz #[arg(long, short)] diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index fcb5a20eb1ada..01bab16ac16ce 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -380,14 +380,16 @@ async fn main_args(args: CastArgs) -> Result<()> { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; - let address: Address = stdin::unwrap_line(address)?.parse()?; + let address = stdin::unwrap_line(address)?; let computed = Cast::new(provider).compute_address(address, nonce).await?; sh_println!("Computed Address: {}", computed.to_checksum(None))? } CastSubcommand::Disassemble { bytecode } => { + let bytecode = stdin::unwrap_line(bytecode)?; sh_println!("{}", SimpleCast::disassemble(&hex::decode(bytecode)?)?)? } CastSubcommand::Selectors { bytecode, resolve } => { + let bytecode = stdin::unwrap_line(bytecode)?; let functions = SimpleCast::extract_functions(&bytecode)?; let max_args_len = functions.iter().map(|r| r.1.len()).max().unwrap_or(0); let max_mutability_len = functions.iter().map(|r| r.2.len()).max().unwrap_or(0); From 8b8d1cd9da30b7d5baeb0971809ebc518752c2b1 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:17:51 +0200 Subject: [PATCH 1746/1963] chore(config): remove RootPath (#9448) --- crates/cheatcodes/src/config.rs | 8 ++-- crates/cli/src/opts/build/core.rs | 2 +- crates/cli/src/utils/mod.rs | 2 +- crates/config/src/lib.rs | 80 ++++++++++--------------------- crates/forge/bin/cmd/bind_json.rs | 2 +- crates/forge/bin/cmd/build.rs | 2 +- crates/forge/bin/cmd/doc/mod.rs | 2 +- crates/forge/bin/cmd/fmt.rs | 6 +-- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/bin/cmd/update.rs | 2 +- crates/forge/bin/cmd/watch.rs | 2 +- crates/forge/tests/cli/config.rs | 2 +- crates/forge/tests/it/repros.rs | 2 +- crates/script/src/simulate.rs | 2 +- 14 files changed, 41 insertions(+), 75 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index fa1ec6039cdee..2279e24359a5d 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -68,7 +68,7 @@ impl CheatsConfig { running_contract: Option, running_version: Option, ) -> Self { - let mut allowed_paths = vec![config.root.0.clone()]; + let mut allowed_paths = vec![config.root.clone()]; allowed_paths.extend(config.libs.clone()); allowed_paths.extend(config.allow_paths.clone()); @@ -88,8 +88,8 @@ impl CheatsConfig { rpc_endpoints, paths: config.project_paths(), fs_permissions: config.fs_permissions.clone().joined(config.root.as_ref()), - root: config.root.0.clone(), - broadcast: config.root.0.clone().join(&config.broadcast), + root: config.root.clone(), + broadcast: config.root.clone().join(&config.broadcast), allowed_paths, evm_opts, labels: config.labels.clone(), @@ -239,7 +239,7 @@ mod tests { fn config(root: &str, fs_permissions: FsPermissions) -> CheatsConfig { CheatsConfig::new( - &Config { root: PathBuf::from(root).into(), fs_permissions, ..Default::default() }, + &Config { root: root.into(), fs_permissions, ..Default::default() }, Default::default(), None, None, diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index d25018ae8df24..ff52cf0d627b2 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -204,7 +204,7 @@ impl<'a> From<&'a CoreBuildArgs> for Config { // if `--config-path` is set we need to adjust the config's root path to the actual root // path for the project, otherwise it will the parent dir of the `--config-path` if args.project_paths.config_path.is_some() { - config.root = args.project_paths.project_root().into(); + config.root = args.project_paths.project_root(); } config } diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 9f8475f63dabc..6a2afe657d87e 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -287,7 +287,7 @@ impl<'a> Git<'a> { #[inline] pub fn from_config(config: &'a Config) -> Self { - Self::new(config.root.0.as_path()) + Self::new(config.root.as_path()) } pub fn root_of(relative_to: &Path) -> Result { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index b88f134d2cc26..f37c383456250 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -168,6 +168,14 @@ pub struct Config { /// See `profile`. #[serde(skip)] pub profiles: Vec, + + /// The root path where the config detection started from, [`Config::with_root`]. + // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] + // representation, but will be deserialized from the `Figment` so that forge commands can + // override it. + #[serde(default = "root_default", skip_serializing)] + pub root: PathBuf, + /// path of the source contracts dir, like `src` or `contracts` pub src: PathBuf, /// path of the test dir @@ -466,13 +474,6 @@ pub struct Config { /// Soldeer custom configs pub soldeer: Option, - /// The root path where the config detection started from, [`Config::with_root`]. - // We're skipping serialization here, so it won't be included in the [`Config::to_string()`] - // representation, but will be deserialized from the `Figment` so that forge commands can - // override it. - #[serde(default, skip_serializing)] - pub root: RootPath, - /// Whether failed assertions should revert. /// /// Note that this only applies to native (cheatcode) assertions, invoked on Vm contract. @@ -679,7 +680,7 @@ impl Config { return Figment::from(self); } - let root = self.root.0.as_path(); + let root = self.root.as_path(); let profile = Self::selected_profile(); let mut figment = Figment::default().merge(DappHardhatDirProvider(root)); @@ -760,7 +761,7 @@ impl Config { /// This joins all relative paths with the current root and attempts to make them canonic #[must_use] pub fn canonic(self) -> Self { - let root = self.root.0.clone(); + let root = self.root.clone(); self.canonic_at(root) } @@ -1006,7 +1007,7 @@ impl Config { .set_no_artifacts(no_artifacts); if !self.skip.is_empty() { - let filter = SkipBuildFilters::new(self.skip.clone(), self.root.0.clone()); + let filter = SkipBuildFilters::new(self.skip.clone(), self.root.clone()); builder = builder.sparse_output(filter); } @@ -1057,7 +1058,7 @@ impl Config { fn ensure_solc(&self) -> Result, SolcError> { if self.eof { let (tx, rx) = mpsc::channel(); - let root = self.root.0.clone(); + let root = self.root.clone(); std::thread::spawn(move || { tx.send( Solc::new_with_args( @@ -1167,7 +1168,7 @@ impl Config { .artifacts(&self.out) .libs(self.libs.iter()) .remappings(self.get_all_remappings()) - .allowed_path(&self.root.0) + .allowed_path(&self.root) .allowed_paths(&self.libs) .allowed_paths(&self.allow_paths) .include_paths(&self.include_paths); @@ -1176,7 +1177,7 @@ impl Config { builder = builder.build_infos(build_info_path); } - builder.build_with_root(&self.root.0) + builder.build_with_root(&self.root) } /// Returns configuration for a compiler to use when setting up a [Project]. @@ -1428,7 +1429,7 @@ impl Config { /// Returns the remapping for the project's _test_ directory, but only if it exists pub fn get_test_dir_remapping(&self) -> Option { - if self.root.0.join(&self.test).exists() { + if self.root.join(&self.test).exists() { get_dir_remapping(&self.test) } else { None @@ -1437,7 +1438,7 @@ impl Config { /// Returns the remapping for the project's _script_ directory, but only if it exists pub fn get_script_dir_remapping(&self) -> Option { - if self.root.0.join(&self.script).exists() { + if self.root.join(&self.script).exists() { get_dir_remapping(&self.script) } else { None @@ -1615,7 +1616,7 @@ impl Config { let paths = ProjectPathsConfig::builder().build_with_root::<()>(root); let artifacts: PathBuf = paths.artifacts.file_name().unwrap().into(); Self { - root: paths.root.into(), + root: paths.root, src: paths.sources.file_name().unwrap().into(), out: artifacts.clone(), libs: paths.libraries.into_iter().map(|lib| lib.file_name().unwrap().into()).collect(), @@ -1707,7 +1708,7 @@ impl Config { pub fn update_libs(&self) -> eyre::Result<()> { self.update(|doc| { let profile = self.profile.as_str().as_str(); - let root = &self.root.0; + let root = &self.root; let libs: toml_edit::Value = self .libs .iter() @@ -1764,7 +1765,7 @@ impl Config { /// Returns the path to the `foundry.toml` of this `Config`. pub fn get_config_path(&self) -> PathBuf { - self.root.0.join(Self::FILE_NAME) + self.root.join(Self::FILE_NAME) } /// Returns the selected profile. @@ -2211,43 +2212,6 @@ pub(crate) mod from_opt_glob { } } -/// A helper wrapper around the root path used during Config detection -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] -#[serde(transparent)] -pub struct RootPath(pub PathBuf); - -impl Default for RootPath { - fn default() -> Self { - ".".into() - } -} - -impl> From

for RootPath { - fn from(p: P) -> Self { - Self(p.into()) - } -} - -impl AsRef for RootPath { - fn as_ref(&self) -> &Path { - &self.0 - } -} - -impl std::ops::Deref for RootPath { - type Target = PathBuf; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl std::ops::DerefMut for RootPath { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - /// Parses a config profile /// /// All `Profile` date is ignored by serde, however the `Config::to_string_pretty` includes it and @@ -2299,7 +2263,7 @@ impl Default for Config { profiles: vec![Self::DEFAULT_PROFILE], fs_permissions: FsPermissions::new([PathPermission::read("out")]), isolate: cfg!(feature = "isolate-by-default"), - root: Default::default(), + root: root_default(), src: "src".into(), test: "test".into(), script: "script".into(), @@ -3068,6 +3032,10 @@ fn canonic(path: impl Into) -> PathBuf { foundry_compilers::utils::canonicalize(&path).unwrap_or(path) } +fn root_default() -> PathBuf { + ".".into() +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index de7a5a7a71aa3..d8a361134f50b 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -64,7 +64,7 @@ impl BindJsonArgs { let config = self.try_load_config_emit_warnings()?; let project = config.create_project(false, true)?; - let target_path = config.root.0.join(self.out.as_ref().unwrap_or(&config.bind_json.out)); + let target_path = config.root.join(self.out.as_ref().unwrap_or(&config.bind_json.out)); let sources = project.paths.read_input_files()?; let graph = Graph::::resolve_sources(&project.paths, sources)?; diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 3efe68db77224..7dea6b0068d03 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -137,7 +137,7 @@ impl BuildArgs { // directories as well as the `foundry.toml` configuration file. self.watch.watchexec_config(|| { let config = Config::from(self); - let foundry_toml: PathBuf = config.root.0.join(Config::FILE_NAME); + let foundry_toml: PathBuf = config.root.join(Config::FILE_NAME); [config.src, config.test, config.script, foundry_toml] }) } diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index ad61facf5c950..2fa996a04fe2f 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -68,7 +68,7 @@ pub struct DocArgs { impl DocArgs { pub async fn run(self) -> Result<()> { let config = self.config()?; - let root = &config.root.0; + let root = &config.root; let project = config.project()?; let compiler = ProjectCompiler::new().quiet(true); let _output = compiler.compile(&project)?; diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 49548e1b6c06f..137e139e6b32f 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -48,7 +48,7 @@ impl FmtArgs { let config = self.try_load_config_emit_warnings()?; // Expand ignore globs and canonicalize from the get go - let ignored = expand_globs(&config.root.0, config.fmt.ignore.iter())? + let ignored = expand_globs(&config.root, config.fmt.ignore.iter())? .iter() .flat_map(foundry_common::fs::canonicalize_path) .collect::>(); @@ -96,9 +96,7 @@ impl FmtArgs { let format = |source: String, path: Option<&Path>| -> Result<_> { let name = match path { - Some(path) => { - path.strip_prefix(&config.root.0).unwrap_or(path).display().to_string() - } + Some(path) => path.strip_prefix(&config.root).unwrap_or(path).display().to_string(), None => "stdin".to_string(), }; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 18ab08d6d152a..e5a058c0d72d7 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -559,7 +559,7 @@ impl TestArgs { if self.decode_internal.is_some() { let sources = - ContractSources::from_project_output(output, &config.root.0, Some(&libraries))?; + ContractSources::from_project_output(output, &config.root, Some(&libraries))?; builder = builder.with_debug_identifier(DebugTraceIdentifier::new(sources)); } let mut decoder = builder.build(); diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index 5ddc5460a78c7..c61b03d7a089c 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -52,7 +52,7 @@ impl UpdateArgs { /// Returns `(root, paths)` where `root` is the root of the Git repository and `paths` are the /// relative paths of the dependencies. pub fn dependencies_paths(deps: &[Dependency], config: &Config) -> Result<(PathBuf, Vec)> { - let git_root = Git::root_of(&config.root.0)?; + let git_root = Git::root_of(&config.root)?; let libs = config.install_lib_dir(); let mut paths = Vec::with_capacity(deps.len()); diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 1f679d2c72c45..926aecdbadc2c 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -268,7 +268,7 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { args.watch.run_all; let last_test_files = Mutex::new(HashSet::::default()); - let project_root = config.root.0.to_string_lossy().into_owned(); + let project_root = config.root.to_string_lossy().into_owned(); let config = args.watch.watchexec_config_with_override( || [&config.test, &config.src], move |events, command| { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 9a7e61c6a4e3d..02ff2fce85365 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -31,7 +31,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { profile: Config::DEFAULT_PROFILE, // `profiles` is not serialized. profiles: vec![], - root: Default::default(), + root: ".".into(), src: "test-src".into(), test: "test-test".into(), script: "test-script".into(), diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 69c3a0fb35f70..0e4adbbc281ef 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -299,7 +299,7 @@ test_repro!(6538); // https://github.com/foundry-rs/foundry/issues/6554 test_repro!(6554; |config| { - let path = config.runner.config.root.0.join("out/default/Issue6554.t.sol"); + let path = config.runner.config.root.join("out/default/Issue6554.t.sol"); let mut prj_config = Config::clone(&config.runner.config); prj_config.fs_permissions.add(PathPermission::read_write(path)); diff --git a/crates/script/src/simulate.rs b/crates/script/src/simulate.rs index 0d7990591cd18..cf6aeb349436b 100644 --- a/crates/script/src/simulate.rs +++ b/crates/script/src/simulate.rs @@ -427,7 +427,7 @@ impl FilledTransactionsState { )?) }; - let commit = get_commit_hash(&self.script_config.config.root.0); + let commit = get_commit_hash(&self.script_config.config.root); let libraries = self .build_data From ddb19d08a7f5eea76c8a05f232aef726228b0af8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:27:08 +0200 Subject: [PATCH 1747/1963] chore(config): move providers into module (#9449) --- crates/cli/src/opts/build/core.rs | 3 +- crates/config/src/lib.rs | 520 +--------------------- crates/config/src/providers/ext.rs | 562 ++++++++++++++++++++++++ crates/config/src/providers/mod.rs | 156 +------ crates/config/src/providers/warnings.rs | 109 +++++ 5 files changed, 682 insertions(+), 668 deletions(-) create mode 100644 crates/config/src/providers/ext.rs create mode 100644 crates/config/src/providers/warnings.rs diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index ff52cf0d627b2..52a925ebb16af 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -16,8 +16,7 @@ use foundry_config::{ Figment, Metadata, Profile, Provider, }, filter::SkipBuildFilter, - providers::remappings::Remappings, - Config, + Config, Remappings, }; use serde::Serialize; use std::path::PathBuf; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f37c383456250..e1c3fa5ee2d00 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -38,7 +38,6 @@ use foundry_compilers::{ ConfigurableArtifacts, Graph, Project, ProjectPathsConfig, RestrictionsWithVersion, VyperLanguage, }; -use inflector::Inflector; use regex::Regex; use revm_primitives::{map::AddressHashMap, FixedBytes, SpecId}; use semver::Version; @@ -99,7 +98,8 @@ pub use alloy_chains::{Chain, NamedChain}; pub use figment; pub mod providers; -use providers::{remappings::RemappingsProvider, FallbackProfileProvider, WarningsProvider}; +pub use providers::Remappings; +use providers::*; mod fuzz; pub use fuzz::{FuzzConfig, FuzzDictionaryConfig}; @@ -524,7 +524,7 @@ pub struct Config { pub _non_exhaustive: (), } -/// Mapping of fallback standalone sections. See [`FallbackProfileProvider`] +/// Mapping of fallback standalone sections. See [`FallbackProfileProvider`]. pub const STANDALONE_FALLBACK_SECTIONS: &[(&str, &str)] = &[("invariant", "fuzz")]; /// Deprecated keys and their replacements. @@ -2050,7 +2050,7 @@ impl Config { let provider = toml_provider.strict_select(profiles); // apply any key fixes - let provider = BackwardsCompatTomlProvider(ForcedSnakeCaseData(provider)); + let provider = &BackwardsCompatTomlProvider(ForcedSnakeCaseData(provider)); // merge the default profile as a base if profile != Self::DEFAULT_PROFILE { @@ -2450,518 +2450,6 @@ impl> From for SolcReq { } } -/// A convenience provider to retrieve a toml file. -/// This will return an error if the env var is set but the file does not exist -struct TomlFileProvider { - pub env_var: Option<&'static str>, - pub default: PathBuf, - pub cache: Option, Error>>, -} - -impl TomlFileProvider { - fn new(env_var: Option<&'static str>, default: impl Into) -> Self { - Self { env_var, default: default.into(), cache: None } - } - - fn env_val(&self) -> Option { - self.env_var.and_then(Env::var) - } - - fn file(&self) -> PathBuf { - self.env_val().map(PathBuf::from).unwrap_or_else(|| self.default.clone()) - } - - fn is_missing(&self) -> bool { - if let Some(file) = self.env_val() { - let path = Path::new(&file); - if !path.exists() { - return true; - } - } - false - } - - pub fn cached(mut self) -> Self { - self.cache = Some(self.read()); - self - } - - fn read(&self) -> Result, Error> { - use serde::de::Error as _; - if let Some(file) = self.env_val() { - let path = Path::new(&file); - if !path.exists() { - return Err(Error::custom(format!( - "Config file `{}` set in env var `{}` does not exist", - file, - self.env_var.unwrap() - ))); - } - Toml::file(file) - } else { - Toml::file(&self.default) - } - .nested() - .data() - } -} - -impl Provider for TomlFileProvider { - fn metadata(&self) -> Metadata { - if self.is_missing() { - Metadata::named("TOML file provider") - } else { - Toml::file(self.file()).nested().metadata() - } - } - - fn data(&self) -> Result, Error> { - if let Some(cache) = self.cache.as_ref() { - cache.clone() - } else { - self.read() - } - } -} - -/// A Provider that ensures all keys are snake case if they're not standalone sections, See -/// `Config::STANDALONE_SECTIONS` -struct ForcedSnakeCaseData

(P); - -impl Provider for ForcedSnakeCaseData

{ - fn metadata(&self) -> Metadata { - self.0.metadata() - } - - fn data(&self) -> Result, Error> { - let mut map = Map::new(); - for (profile, dict) in self.0.data()? { - if Config::STANDALONE_SECTIONS.contains(&profile.as_ref()) { - // don't force snake case for keys in standalone sections - map.insert(profile, dict); - continue; - } - map.insert(profile, dict.into_iter().map(|(k, v)| (k.to_snake_case(), v)).collect()); - } - Ok(map) - } -} - -/// A Provider that handles breaking changes in toml files -struct BackwardsCompatTomlProvider

(P); - -impl Provider for BackwardsCompatTomlProvider

{ - fn metadata(&self) -> Metadata { - self.0.metadata() - } - - fn data(&self) -> Result, Error> { - let mut map = Map::new(); - let solc_env = std::env::var("FOUNDRY_SOLC_VERSION") - .or_else(|_| std::env::var("DAPP_SOLC_VERSION")) - .map(Value::from) - .ok(); - for (profile, mut dict) in self.0.data()? { - if let Some(v) = solc_env.clone() { - // ENV var takes precedence over config file - dict.insert("solc".to_string(), v); - } else if let Some(v) = dict.remove("solc_version") { - // only insert older variant if not already included - if !dict.contains_key("solc") { - dict.insert("solc".to_string(), v); - } - } - - if let Some(v) = dict.remove("odyssey") { - dict.insert("alphanet".to_string(), v); - } - map.insert(profile, dict); - } - Ok(map) - } -} - -/// A provider that sets the `src` and `output` path depending on their existence. -struct DappHardhatDirProvider<'a>(&'a Path); - -impl Provider for DappHardhatDirProvider<'_> { - fn metadata(&self) -> Metadata { - Metadata::named("Dapp Hardhat dir compat") - } - - fn data(&self) -> Result, Error> { - let mut dict = Dict::new(); - dict.insert( - "src".to_string(), - ProjectPathsConfig::find_source_dir(self.0) - .file_name() - .unwrap() - .to_string_lossy() - .to_string() - .into(), - ); - dict.insert( - "out".to_string(), - ProjectPathsConfig::find_artifacts_dir(self.0) - .file_name() - .unwrap() - .to_string_lossy() - .to_string() - .into(), - ); - - // detect libs folders: - // if `lib` _and_ `node_modules` exists: include both - // if only `node_modules` exists: include `node_modules` - // include `lib` otherwise - let mut libs = vec![]; - let node_modules = self.0.join("node_modules"); - let lib = self.0.join("lib"); - if node_modules.exists() { - if lib.exists() { - libs.push(lib.file_name().unwrap().to_string_lossy().to_string()); - } - libs.push(node_modules.file_name().unwrap().to_string_lossy().to_string()); - } else { - libs.push(lib.file_name().unwrap().to_string_lossy().to_string()); - } - - dict.insert("libs".to_string(), libs.into()); - - Ok(Map::from([(Config::selected_profile(), dict)])) - } -} - -/// A provider that checks for DAPP_ env vars that are named differently than FOUNDRY_ -struct DappEnvCompatProvider; - -impl Provider for DappEnvCompatProvider { - fn metadata(&self) -> Metadata { - Metadata::named("Dapp env compat") - } - - fn data(&self) -> Result, Error> { - use serde::de::Error as _; - use std::env; - - let mut dict = Dict::new(); - if let Ok(val) = env::var("DAPP_TEST_NUMBER") { - dict.insert( - "block_number".to_string(), - val.parse::().map_err(figment::Error::custom)?.into(), - ); - } - if let Ok(val) = env::var("DAPP_TEST_ADDRESS") { - dict.insert("sender".to_string(), val.into()); - } - if let Ok(val) = env::var("DAPP_FORK_BLOCK") { - dict.insert( - "fork_block_number".to_string(), - val.parse::().map_err(figment::Error::custom)?.into(), - ); - } else if let Ok(val) = env::var("DAPP_TEST_NUMBER") { - dict.insert( - "fork_block_number".to_string(), - val.parse::().map_err(figment::Error::custom)?.into(), - ); - } - if let Ok(val) = env::var("DAPP_TEST_TIMESTAMP") { - dict.insert( - "block_timestamp".to_string(), - val.parse::().map_err(figment::Error::custom)?.into(), - ); - } - if let Ok(val) = env::var("DAPP_BUILD_OPTIMIZE_RUNS") { - dict.insert( - "optimizer_runs".to_string(), - val.parse::().map_err(figment::Error::custom)?.into(), - ); - } - if let Ok(val) = env::var("DAPP_BUILD_OPTIMIZE") { - // Activate Solidity optimizer (0 or 1) - let val = val.parse::().map_err(figment::Error::custom)?; - if val > 1 { - return Err( - format!("Invalid $DAPP_BUILD_OPTIMIZE value `{val}`, expected 0 or 1").into() - ); - } - dict.insert("optimizer".to_string(), (val == 1).into()); - } - - // libraries in env vars either as `[..]` or single string separated by comma - if let Ok(val) = env::var("DAPP_LIBRARIES").or_else(|_| env::var("FOUNDRY_LIBRARIES")) { - dict.insert("libraries".to_string(), utils::to_array_value(&val)?); - } - - let mut fuzz_dict = Dict::new(); - if let Ok(val) = env::var("DAPP_TEST_FUZZ_RUNS") { - fuzz_dict.insert( - "runs".to_string(), - val.parse::().map_err(figment::Error::custom)?.into(), - ); - } - dict.insert("fuzz".to_string(), fuzz_dict.into()); - - let mut invariant_dict = Dict::new(); - if let Ok(val) = env::var("DAPP_TEST_DEPTH") { - invariant_dict.insert( - "depth".to_string(), - val.parse::().map_err(figment::Error::custom)?.into(), - ); - } - dict.insert("invariant".to_string(), invariant_dict.into()); - - Ok(Map::from([(Config::selected_profile(), dict)])) - } -} - -/// Renames a profile from `from` to `to`. -/// -/// For example given: -/// -/// ```toml -/// [from] -/// key = "value" -/// ``` -/// -/// RenameProfileProvider will output -/// -/// ```toml -/// [to] -/// key = "value" -/// ``` -struct RenameProfileProvider

{ - provider: P, - from: Profile, - to: Profile, -} - -impl

RenameProfileProvider

{ - pub fn new(provider: P, from: impl Into, to: impl Into) -> Self { - Self { provider, from: from.into(), to: to.into() } - } -} - -impl Provider for RenameProfileProvider

{ - fn metadata(&self) -> Metadata { - self.provider.metadata() - } - fn data(&self) -> Result, Error> { - let mut data = self.provider.data()?; - if let Some(data) = data.remove(&self.from) { - return Ok(Map::from([(self.to.clone(), data)])); - } - Ok(Default::default()) - } - fn profile(&self) -> Option { - Some(self.to.clone()) - } -} - -/// Unwraps a profile reducing the key depth -/// -/// For example given: -/// -/// ```toml -/// [wrapping_key.profile] -/// key = "value" -/// ``` -/// -/// UnwrapProfileProvider will output: -/// -/// ```toml -/// [profile] -/// key = "value" -/// ``` -struct UnwrapProfileProvider

{ - provider: P, - wrapping_key: Profile, - profile: Profile, -} - -impl

UnwrapProfileProvider

{ - pub fn new(provider: P, wrapping_key: impl Into, profile: impl Into) -> Self { - Self { provider, wrapping_key: wrapping_key.into(), profile: profile.into() } - } -} - -impl Provider for UnwrapProfileProvider

{ - fn metadata(&self) -> Metadata { - self.provider.metadata() - } - fn data(&self) -> Result, Error> { - self.provider.data().and_then(|mut data| { - if let Some(profiles) = data.remove(&self.wrapping_key) { - for (profile_str, profile_val) in profiles { - let profile = Profile::new(&profile_str); - if profile != self.profile { - continue; - } - match profile_val { - Value::Dict(_, dict) => return Ok(profile.collect(dict)), - bad_val => { - let mut err = Error::from(figment::error::Kind::InvalidType( - bad_val.to_actual(), - "dict".into(), - )); - err.metadata = Some(self.provider.metadata()); - err.profile = Some(self.profile.clone()); - return Err(err); - } - } - } - } - Ok(Default::default()) - }) - } - fn profile(&self) -> Option { - Some(self.profile.clone()) - } -} - -/// Wraps a profile in another profile -/// -/// For example given: -/// -/// ```toml -/// [profile] -/// key = "value" -/// ``` -/// -/// WrapProfileProvider will output: -/// -/// ```toml -/// [wrapping_key.profile] -/// key = "value" -/// ``` -struct WrapProfileProvider

{ - provider: P, - wrapping_key: Profile, - profile: Profile, -} - -impl

WrapProfileProvider

{ - pub fn new(provider: P, wrapping_key: impl Into, profile: impl Into) -> Self { - Self { provider, wrapping_key: wrapping_key.into(), profile: profile.into() } - } -} - -impl Provider for WrapProfileProvider

{ - fn metadata(&self) -> Metadata { - self.provider.metadata() - } - fn data(&self) -> Result, Error> { - if let Some(inner) = self.provider.data()?.remove(&self.profile) { - let value = Value::from(inner); - let dict = [(self.profile.to_string().to_snake_case(), value)].into_iter().collect(); - Ok(self.wrapping_key.collect(dict)) - } else { - Ok(Default::default()) - } - } - fn profile(&self) -> Option { - Some(self.profile.clone()) - } -} - -/// Extracts the profile from the `profile` key and using the original key as backup, merging -/// values where necessary -/// -/// For example given: -/// -/// ```toml -/// [profile.cool] -/// key = "value" -/// -/// [cool] -/// key2 = "value2" -/// ``` -/// -/// OptionalStrictProfileProvider will output: -/// -/// ```toml -/// [cool] -/// key = "value" -/// key2 = "value2" -/// ``` -/// -/// And emit a deprecation warning -struct OptionalStrictProfileProvider

{ - provider: P, - profiles: Vec, -} - -impl

OptionalStrictProfileProvider

{ - pub const PROFILE_PROFILE: Profile = Profile::const_new("profile"); - - pub fn new(provider: P, profiles: impl IntoIterator>) -> Self { - Self { provider, profiles: profiles.into_iter().map(|profile| profile.into()).collect() } - } -} - -impl Provider for OptionalStrictProfileProvider

{ - fn metadata(&self) -> Metadata { - self.provider.metadata() - } - fn data(&self) -> Result, Error> { - let mut figment = Figment::from(&self.provider); - for profile in &self.profiles { - figment = figment.merge(UnwrapProfileProvider::new( - &self.provider, - Self::PROFILE_PROFILE, - profile.clone(), - )); - } - figment.data().map_err(|err| { - // figment does tag metadata and tries to map metadata to an error, since we use a new - // figment in this provider this new figment does not know about the metadata of the - // provider and can't map the metadata to the error. Therefore we return the root error - // if this error originated in the provider's data. - if let Err(root_err) = self.provider.data() { - return root_err; - } - err - }) - } - fn profile(&self) -> Option { - self.profiles.last().cloned() - } -} - -trait ProviderExt: Provider { - fn rename( - &self, - from: impl Into, - to: impl Into, - ) -> RenameProfileProvider<&Self> { - RenameProfileProvider::new(self, from, to) - } - - fn wrap( - &self, - wrapping_key: impl Into, - profile: impl Into, - ) -> WrapProfileProvider<&Self> { - WrapProfileProvider::new(self, wrapping_key, profile) - } - - fn strict_select( - &self, - profiles: impl IntoIterator>, - ) -> OptionalStrictProfileProvider<&Self> { - OptionalStrictProfileProvider::new(self, profiles) - } - - fn fallback( - &self, - profile: impl Into, - fallback: impl Into, - ) -> FallbackProfileProvider<&Self> { - FallbackProfileProvider::new(self, profile, fallback) - } -} -impl ProviderExt for P {} - /// A subset of the foundry `Config` /// used to initialize a `foundry.toml` file /// diff --git a/crates/config/src/providers/ext.rs b/crates/config/src/providers/ext.rs new file mode 100644 index 0000000000000..040f2127cbee0 --- /dev/null +++ b/crates/config/src/providers/ext.rs @@ -0,0 +1,562 @@ +use crate::{utils, Config}; +use figment::{ + providers::{Env, Format, Toml}, + value::{Dict, Map, Value}, + Error, Figment, Metadata, Profile, Provider, +}; +use foundry_compilers::ProjectPathsConfig; +use inflector::Inflector; +use std::path::{Path, PathBuf}; + +pub(crate) trait ProviderExt: Provider + Sized { + fn rename( + self, + from: impl Into, + to: impl Into, + ) -> RenameProfileProvider { + RenameProfileProvider::new(self, from, to) + } + + fn wrap( + self, + wrapping_key: impl Into, + profile: impl Into, + ) -> WrapProfileProvider { + WrapProfileProvider::new(self, wrapping_key, profile) + } + + fn strict_select( + self, + profiles: impl IntoIterator>, + ) -> OptionalStrictProfileProvider { + OptionalStrictProfileProvider::new(self, profiles) + } + + fn fallback( + self, + profile: impl Into, + fallback: impl Into, + ) -> FallbackProfileProvider { + FallbackProfileProvider::new(self, profile, fallback) + } +} + +impl ProviderExt for P {} + +/// A convenience provider to retrieve a toml file. +/// This will return an error if the env var is set but the file does not exist +pub(crate) struct TomlFileProvider { + pub env_var: Option<&'static str>, + pub default: PathBuf, + pub cache: Option, Error>>, +} + +impl TomlFileProvider { + pub(crate) fn new(env_var: Option<&'static str>, default: impl Into) -> Self { + Self { env_var, default: default.into(), cache: None } + } + + fn env_val(&self) -> Option { + self.env_var.and_then(Env::var) + } + + fn file(&self) -> PathBuf { + self.env_val().map(PathBuf::from).unwrap_or_else(|| self.default.clone()) + } + + fn is_missing(&self) -> bool { + if let Some(file) = self.env_val() { + let path = Path::new(&file); + if !path.exists() { + return true; + } + } + false + } + + pub(crate) fn cached(mut self) -> Self { + self.cache = Some(self.read()); + self + } + + fn read(&self) -> Result, Error> { + use serde::de::Error as _; + if let Some(file) = self.env_val() { + let path = Path::new(&file); + if !path.exists() { + return Err(Error::custom(format!( + "Config file `{}` set in env var `{}` does not exist", + file, + self.env_var.unwrap() + ))); + } + Toml::file(file) + } else { + Toml::file(&self.default) + } + .nested() + .data() + } +} + +impl Provider for TomlFileProvider { + fn metadata(&self) -> Metadata { + if self.is_missing() { + Metadata::named("TOML file provider") + } else { + Toml::file(self.file()).nested().metadata() + } + } + + fn data(&self) -> Result, Error> { + if let Some(cache) = self.cache.as_ref() { + cache.clone() + } else { + self.read() + } + } +} + +/// A Provider that ensures all keys are snake case if they're not standalone sections, See +/// `Config::STANDALONE_SECTIONS` +pub(crate) struct ForcedSnakeCaseData

(pub(crate) P); + +impl Provider for ForcedSnakeCaseData

{ + fn metadata(&self) -> Metadata { + self.0.metadata() + } + + fn data(&self) -> Result, Error> { + let mut map = Map::new(); + for (profile, dict) in self.0.data()? { + if Config::STANDALONE_SECTIONS.contains(&profile.as_ref()) { + // don't force snake case for keys in standalone sections + map.insert(profile, dict); + continue; + } + map.insert(profile, dict.into_iter().map(|(k, v)| (k.to_snake_case(), v)).collect()); + } + Ok(map) + } +} + +/// A Provider that handles breaking changes in toml files +pub(crate) struct BackwardsCompatTomlProvider

(pub(crate) P); + +impl Provider for BackwardsCompatTomlProvider

{ + fn metadata(&self) -> Metadata { + self.0.metadata() + } + + fn data(&self) -> Result, Error> { + let mut map = Map::new(); + let solc_env = std::env::var("FOUNDRY_SOLC_VERSION") + .or_else(|_| std::env::var("DAPP_SOLC_VERSION")) + .map(Value::from) + .ok(); + for (profile, mut dict) in self.0.data()? { + if let Some(v) = solc_env.clone() { + // ENV var takes precedence over config file + dict.insert("solc".to_string(), v); + } else if let Some(v) = dict.remove("solc_version") { + // only insert older variant if not already included + if !dict.contains_key("solc") { + dict.insert("solc".to_string(), v); + } + } + + if let Some(v) = dict.remove("odyssey") { + dict.insert("alphanet".to_string(), v); + } + map.insert(profile, dict); + } + Ok(map) + } +} + +/// A provider that sets the `src` and `output` path depending on their existence. +pub(crate) struct DappHardhatDirProvider<'a>(pub(crate) &'a Path); + +impl Provider for DappHardhatDirProvider<'_> { + fn metadata(&self) -> Metadata { + Metadata::named("Dapp Hardhat dir compat") + } + + fn data(&self) -> Result, Error> { + let mut dict = Dict::new(); + dict.insert( + "src".to_string(), + ProjectPathsConfig::find_source_dir(self.0) + .file_name() + .unwrap() + .to_string_lossy() + .to_string() + .into(), + ); + dict.insert( + "out".to_string(), + ProjectPathsConfig::find_artifacts_dir(self.0) + .file_name() + .unwrap() + .to_string_lossy() + .to_string() + .into(), + ); + + // detect libs folders: + // if `lib` _and_ `node_modules` exists: include both + // if only `node_modules` exists: include `node_modules` + // include `lib` otherwise + let mut libs = vec![]; + let node_modules = self.0.join("node_modules"); + let lib = self.0.join("lib"); + if node_modules.exists() { + if lib.exists() { + libs.push(lib.file_name().unwrap().to_string_lossy().to_string()); + } + libs.push(node_modules.file_name().unwrap().to_string_lossy().to_string()); + } else { + libs.push(lib.file_name().unwrap().to_string_lossy().to_string()); + } + + dict.insert("libs".to_string(), libs.into()); + + Ok(Map::from([(Config::selected_profile(), dict)])) + } +} + +/// A provider that checks for DAPP_ env vars that are named differently than FOUNDRY_ +pub(crate) struct DappEnvCompatProvider; + +impl Provider for DappEnvCompatProvider { + fn metadata(&self) -> Metadata { + Metadata::named("Dapp env compat") + } + + fn data(&self) -> Result, Error> { + use serde::de::Error as _; + use std::env; + + let mut dict = Dict::new(); + if let Ok(val) = env::var("DAPP_TEST_NUMBER") { + dict.insert( + "block_number".to_string(), + val.parse::().map_err(figment::Error::custom)?.into(), + ); + } + if let Ok(val) = env::var("DAPP_TEST_ADDRESS") { + dict.insert("sender".to_string(), val.into()); + } + if let Ok(val) = env::var("DAPP_FORK_BLOCK") { + dict.insert( + "fork_block_number".to_string(), + val.parse::().map_err(figment::Error::custom)?.into(), + ); + } else if let Ok(val) = env::var("DAPP_TEST_NUMBER") { + dict.insert( + "fork_block_number".to_string(), + val.parse::().map_err(figment::Error::custom)?.into(), + ); + } + if let Ok(val) = env::var("DAPP_TEST_TIMESTAMP") { + dict.insert( + "block_timestamp".to_string(), + val.parse::().map_err(figment::Error::custom)?.into(), + ); + } + if let Ok(val) = env::var("DAPP_BUILD_OPTIMIZE_RUNS") { + dict.insert( + "optimizer_runs".to_string(), + val.parse::().map_err(figment::Error::custom)?.into(), + ); + } + if let Ok(val) = env::var("DAPP_BUILD_OPTIMIZE") { + // Activate Solidity optimizer (0 or 1) + let val = val.parse::().map_err(figment::Error::custom)?; + if val > 1 { + return Err( + format!("Invalid $DAPP_BUILD_OPTIMIZE value `{val}`, expected 0 or 1").into() + ); + } + dict.insert("optimizer".to_string(), (val == 1).into()); + } + + // libraries in env vars either as `[..]` or single string separated by comma + if let Ok(val) = env::var("DAPP_LIBRARIES").or_else(|_| env::var("FOUNDRY_LIBRARIES")) { + dict.insert("libraries".to_string(), utils::to_array_value(&val)?); + } + + let mut fuzz_dict = Dict::new(); + if let Ok(val) = env::var("DAPP_TEST_FUZZ_RUNS") { + fuzz_dict.insert( + "runs".to_string(), + val.parse::().map_err(figment::Error::custom)?.into(), + ); + } + dict.insert("fuzz".to_string(), fuzz_dict.into()); + + let mut invariant_dict = Dict::new(); + if let Ok(val) = env::var("DAPP_TEST_DEPTH") { + invariant_dict.insert( + "depth".to_string(), + val.parse::().map_err(figment::Error::custom)?.into(), + ); + } + dict.insert("invariant".to_string(), invariant_dict.into()); + + Ok(Map::from([(Config::selected_profile(), dict)])) + } +} + +/// Renames a profile from `from` to `to`. +/// +/// For example given: +/// +/// ```toml +/// [from] +/// key = "value" +/// ``` +/// +/// RenameProfileProvider will output +/// +/// ```toml +/// [to] +/// key = "value" +/// ``` +pub(crate) struct RenameProfileProvider

{ + provider: P, + from: Profile, + to: Profile, +} + +impl

RenameProfileProvider

{ + pub(crate) fn new(provider: P, from: impl Into, to: impl Into) -> Self { + Self { provider, from: from.into(), to: to.into() } + } +} + +impl Provider for RenameProfileProvider

{ + fn metadata(&self) -> Metadata { + self.provider.metadata() + } + fn data(&self) -> Result, Error> { + let mut data = self.provider.data()?; + if let Some(data) = data.remove(&self.from) { + return Ok(Map::from([(self.to.clone(), data)])); + } + Ok(Default::default()) + } + fn profile(&self) -> Option { + Some(self.to.clone()) + } +} + +/// Unwraps a profile reducing the key depth +/// +/// For example given: +/// +/// ```toml +/// [wrapping_key.profile] +/// key = "value" +/// ``` +/// +/// UnwrapProfileProvider will output: +/// +/// ```toml +/// [profile] +/// key = "value" +/// ``` +struct UnwrapProfileProvider

{ + provider: P, + wrapping_key: Profile, + profile: Profile, +} + +impl

UnwrapProfileProvider

{ + pub fn new(provider: P, wrapping_key: impl Into, profile: impl Into) -> Self { + Self { provider, wrapping_key: wrapping_key.into(), profile: profile.into() } + } +} + +impl Provider for UnwrapProfileProvider

{ + fn metadata(&self) -> Metadata { + self.provider.metadata() + } + fn data(&self) -> Result, Error> { + self.provider.data().and_then(|mut data| { + if let Some(profiles) = data.remove(&self.wrapping_key) { + for (profile_str, profile_val) in profiles { + let profile = Profile::new(&profile_str); + if profile != self.profile { + continue; + } + match profile_val { + Value::Dict(_, dict) => return Ok(profile.collect(dict)), + bad_val => { + let mut err = Error::from(figment::error::Kind::InvalidType( + bad_val.to_actual(), + "dict".into(), + )); + err.metadata = Some(self.provider.metadata()); + err.profile = Some(self.profile.clone()); + return Err(err); + } + } + } + } + Ok(Default::default()) + }) + } + fn profile(&self) -> Option { + Some(self.profile.clone()) + } +} + +/// Wraps a profile in another profile +/// +/// For example given: +/// +/// ```toml +/// [profile] +/// key = "value" +/// ``` +/// +/// WrapProfileProvider will output: +/// +/// ```toml +/// [wrapping_key.profile] +/// key = "value" +/// ``` +pub(crate) struct WrapProfileProvider

{ + provider: P, + wrapping_key: Profile, + profile: Profile, +} + +impl

WrapProfileProvider

{ + pub fn new(provider: P, wrapping_key: impl Into, profile: impl Into) -> Self { + Self { provider, wrapping_key: wrapping_key.into(), profile: profile.into() } + } +} + +impl Provider for WrapProfileProvider

{ + fn metadata(&self) -> Metadata { + self.provider.metadata() + } + fn data(&self) -> Result, Error> { + if let Some(inner) = self.provider.data()?.remove(&self.profile) { + let value = Value::from(inner); + let dict = [(self.profile.to_string().to_snake_case(), value)].into_iter().collect(); + Ok(self.wrapping_key.collect(dict)) + } else { + Ok(Default::default()) + } + } + fn profile(&self) -> Option { + Some(self.profile.clone()) + } +} + +/// Extracts the profile from the `profile` key and using the original key as backup, merging +/// values where necessary +/// +/// For example given: +/// +/// ```toml +/// [profile.cool] +/// key = "value" +/// +/// [cool] +/// key2 = "value2" +/// ``` +/// +/// OptionalStrictProfileProvider will output: +/// +/// ```toml +/// [cool] +/// key = "value" +/// key2 = "value2" +/// ``` +/// +/// And emit a deprecation warning +pub(crate) struct OptionalStrictProfileProvider

{ + provider: P, + profiles: Vec, +} + +impl

OptionalStrictProfileProvider

{ + pub const PROFILE_PROFILE: Profile = Profile::const_new("profile"); + + pub fn new(provider: P, profiles: impl IntoIterator>) -> Self { + Self { provider, profiles: profiles.into_iter().map(|profile| profile.into()).collect() } + } +} + +impl Provider for OptionalStrictProfileProvider

{ + fn metadata(&self) -> Metadata { + self.provider.metadata() + } + fn data(&self) -> Result, Error> { + let mut figment = Figment::from(&self.provider); + for profile in &self.profiles { + figment = figment.merge(UnwrapProfileProvider::new( + &self.provider, + Self::PROFILE_PROFILE, + profile.clone(), + )); + } + figment.data().map_err(|err| { + // figment does tag metadata and tries to map metadata to an error, since we use a new + // figment in this provider this new figment does not know about the metadata of the + // provider and can't map the metadata to the error. Therefore we return the root error + // if this error originated in the provider's data. + if let Err(root_err) = self.provider.data() { + return root_err; + } + err + }) + } + fn profile(&self) -> Option { + self.profiles.last().cloned() + } +} + +/// Extracts the profile from the `profile` key and sets unset values according to the fallback +/// provider +pub struct FallbackProfileProvider

{ + provider: P, + profile: Profile, + fallback: Profile, +} + +impl

FallbackProfileProvider

{ + /// Creates a new fallback profile provider. + pub fn new(provider: P, profile: impl Into, fallback: impl Into) -> Self { + Self { provider, profile: profile.into(), fallback: fallback.into() } + } +} + +impl Provider for FallbackProfileProvider

{ + fn metadata(&self) -> Metadata { + self.provider.metadata() + } + + fn data(&self) -> Result, Error> { + let data = self.provider.data()?; + if let Some(fallback) = data.get(&self.fallback) { + let mut inner = data.get(&self.profile).cloned().unwrap_or_default(); + for (k, v) in fallback.iter() { + if !inner.contains_key(k) { + inner.insert(k.to_owned(), v.clone()); + } + } + Ok(self.profile.collect(inner)) + } else { + Ok(data) + } + } + + fn profile(&self) -> Option { + Some(self.profile.clone()) + } +} diff --git a/crates/config/src/providers/mod.rs b/crates/config/src/providers/mod.rs index 9bd8a014f9699..9fec7d290ca34 100644 --- a/crates/config/src/providers/mod.rs +++ b/crates/config/src/providers/mod.rs @@ -1,154 +1,10 @@ //! Config providers. -use crate::{Config, Warning, DEPRECATIONS}; -use figment::{ - value::{Dict, Map, Value}, - Error, Figment, Metadata, Profile, Provider, -}; -use std::collections::BTreeMap; +mod ext; +pub use ext::*; -/// Remappings provider -pub mod remappings; +mod remappings; +pub use remappings::*; -/// Generate warnings for unknown sections and deprecated keys -pub struct WarningsProvider

{ - provider: P, - profile: Profile, - old_warnings: Result, Error>, -} - -impl WarningsProvider

{ - const WARNINGS_KEY: &'static str = "__warnings"; - - /// Creates a new warnings provider. - pub fn new( - provider: P, - profile: impl Into, - old_warnings: Result, Error>, - ) -> Self { - Self { provider, profile: profile.into(), old_warnings } - } - - /// Creates a new figment warnings provider. - pub fn for_figment(provider: P, figment: &Figment) -> Self { - let old_warnings = { - let warnings_res = figment.extract_inner(Self::WARNINGS_KEY); - if warnings_res.as_ref().err().map(|err| err.missing()).unwrap_or(false) { - Ok(vec![]) - } else { - warnings_res - } - }; - Self::new(provider, figment.profile().clone(), old_warnings) - } - - /// Collects all warnings. - pub fn collect_warnings(&self) -> Result, Error> { - let data = self.provider.data().unwrap_or_default(); - - let mut out = self.old_warnings.clone()?; - - // Add warning for unknown sections. - out.extend( - data.keys() - .filter(|k| { - **k != Config::PROFILE_SECTION && - !Config::STANDALONE_SECTIONS.iter().any(|s| s == k) - }) - .map(|unknown_section| { - let source = self.provider.metadata().source.map(|s| s.to_string()); - Warning::UnknownSection { unknown_section: unknown_section.clone(), source } - }), - ); - - // Add warning for deprecated keys. - let deprecated_key_warning = |key| { - DEPRECATIONS.iter().find_map(|(deprecated_key, new_value)| { - if key == *deprecated_key { - Some(Warning::DeprecatedKey { - old: deprecated_key.to_string(), - new: new_value.to_string(), - }) - } else { - None - } - }) - }; - let profiles = data - .iter() - .filter(|(profile, _)| **profile == Config::PROFILE_SECTION) - .map(|(_, dict)| dict); - out.extend(profiles.clone().flat_map(BTreeMap::keys).filter_map(deprecated_key_warning)); - out.extend( - profiles - .filter_map(|dict| dict.get(self.profile.as_str().as_str())) - .filter_map(Value::as_dict) - .flat_map(BTreeMap::keys) - .filter_map(deprecated_key_warning), - ); - - Ok(out) - } -} - -impl Provider for WarningsProvider

{ - fn metadata(&self) -> Metadata { - if let Some(source) = self.provider.metadata().source { - Metadata::from("Warnings", source) - } else { - Metadata::named("Warnings") - } - } - - fn data(&self) -> Result, Error> { - let warnings = self.collect_warnings()?; - Ok(Map::from([( - self.profile.clone(), - Dict::from([(Self::WARNINGS_KEY.to_string(), Value::serialize(warnings)?)]), - )])) - } - - fn profile(&self) -> Option { - Some(self.profile.clone()) - } -} - -/// Extracts the profile from the `profile` key and sets unset values according to the fallback -/// provider -pub struct FallbackProfileProvider

{ - provider: P, - profile: Profile, - fallback: Profile, -} - -impl

FallbackProfileProvider

{ - /// Creates a new fallback profile provider. - pub fn new(provider: P, profile: impl Into, fallback: impl Into) -> Self { - Self { provider, profile: profile.into(), fallback: fallback.into() } - } -} - -impl Provider for FallbackProfileProvider

{ - fn metadata(&self) -> Metadata { - self.provider.metadata() - } - - fn data(&self) -> Result, Error> { - let data = self.provider.data()?; - if let Some(fallback) = data.get(&self.fallback) { - let mut inner = data.get(&self.profile).cloned().unwrap_or_default(); - for (k, v) in fallback.iter() { - if !inner.contains_key(k) { - inner.insert(k.to_owned(), v.clone()); - } - } - Ok(self.profile.collect(inner)) - } else { - Ok(data) - } - } - - fn profile(&self) -> Option { - Some(self.profile.clone()) - } -} +mod warnings; +pub use warnings::*; diff --git a/crates/config/src/providers/warnings.rs b/crates/config/src/providers/warnings.rs new file mode 100644 index 0000000000000..944225be18c2c --- /dev/null +++ b/crates/config/src/providers/warnings.rs @@ -0,0 +1,109 @@ +use crate::{Config, Warning, DEPRECATIONS}; +use figment::{ + value::{Dict, Map, Value}, + Error, Figment, Metadata, Profile, Provider, +}; +use std::collections::BTreeMap; + +/// Generate warnings for unknown sections and deprecated keys +pub struct WarningsProvider

{ + provider: P, + profile: Profile, + old_warnings: Result, Error>, +} + +impl WarningsProvider

{ + const WARNINGS_KEY: &'static str = "__warnings"; + + /// Creates a new warnings provider. + pub fn new( + provider: P, + profile: impl Into, + old_warnings: Result, Error>, + ) -> Self { + Self { provider, profile: profile.into(), old_warnings } + } + + /// Creates a new figment warnings provider. + pub fn for_figment(provider: P, figment: &Figment) -> Self { + let old_warnings = { + let warnings_res = figment.extract_inner(Self::WARNINGS_KEY); + if warnings_res.as_ref().err().map(|err| err.missing()).unwrap_or(false) { + Ok(vec![]) + } else { + warnings_res + } + }; + Self::new(provider, figment.profile().clone(), old_warnings) + } + + /// Collects all warnings. + pub fn collect_warnings(&self) -> Result, Error> { + let data = self.provider.data().unwrap_or_default(); + + let mut out = self.old_warnings.clone()?; + + // Add warning for unknown sections. + out.extend( + data.keys() + .filter(|k| { + **k != Config::PROFILE_SECTION && + !Config::STANDALONE_SECTIONS.iter().any(|s| s == k) + }) + .map(|unknown_section| { + let source = self.provider.metadata().source.map(|s| s.to_string()); + Warning::UnknownSection { unknown_section: unknown_section.clone(), source } + }), + ); + + // Add warning for deprecated keys. + let deprecated_key_warning = |key| { + DEPRECATIONS.iter().find_map(|(deprecated_key, new_value)| { + if key == *deprecated_key { + Some(Warning::DeprecatedKey { + old: deprecated_key.to_string(), + new: new_value.to_string(), + }) + } else { + None + } + }) + }; + let profiles = data + .iter() + .filter(|(profile, _)| **profile == Config::PROFILE_SECTION) + .map(|(_, dict)| dict); + out.extend(profiles.clone().flat_map(BTreeMap::keys).filter_map(deprecated_key_warning)); + out.extend( + profiles + .filter_map(|dict| dict.get(self.profile.as_str().as_str())) + .filter_map(Value::as_dict) + .flat_map(BTreeMap::keys) + .filter_map(deprecated_key_warning), + ); + + Ok(out) + } +} + +impl Provider for WarningsProvider

{ + fn metadata(&self) -> Metadata { + if let Some(source) = self.provider.metadata().source { + Metadata::from("Warnings", source) + } else { + Metadata::named("Warnings") + } + } + + fn data(&self) -> Result, Error> { + let warnings = self.collect_warnings()?; + Ok(Map::from([( + self.profile.clone(), + Dict::from([(Self::WARNINGS_KEY.to_string(), Value::serialize(warnings)?)]), + )])) + } + + fn profile(&self) -> Option { + Some(self.profile.clone()) + } +} From c4d81b9f022ee2e5344f88276b662543e62460cd Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:31:02 +0530 Subject: [PATCH 1748/1963] chore(deps): alloy 0.7 (#9447) * bump deps * fix: receipts * bump core * fix --- Cargo.lock | 191 ++++++++++++------- Cargo.toml | 66 +++---- crates/anvil/core/src/eth/block.rs | 5 + crates/anvil/core/src/eth/transaction/mod.rs | 28 +-- crates/anvil/src/eth/backend/mem/storage.rs | 32 ++-- crates/cast/tests/cli/main.rs | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/src/fs.rs | 2 +- crates/common/Cargo.toml | 1 + crates/common/fmt/src/ui.rs | 16 +- crates/common/src/transactions.rs | 3 +- crates/forge/bin/cmd/create.rs | 4 +- crates/script-sequence/Cargo.toml | 1 + crates/script-sequence/src/reader.rs | 2 +- crates/script-sequence/src/sequence.rs | 2 +- crates/script/src/receipts.rs | 2 +- 16 files changed, 212 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f8fa5bb58ef3..ea8b8da749b3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,14 +86,15 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae09ffd7c29062431dd86061deefe4e3c6f07fa0d674930095f8dcedb0baf02c" +checksum = "3a1ff8439834ab71a4b0ecd1a8ff80b3921c87615f158940c3364f399c732786" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", + "alloy-trie 0.7.4", "auto_impl", "c-kzg", "derive_more", @@ -101,11 +102,25 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-consensus-any" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519a86faaa6729464365a90c04eba68539b6d3a30f426edb4b3dafd78920d42f" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "serde", +] + [[package]] name = "alloy-contract" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66430a72d5bf5edead101c8c2f0a24bada5ec9f3cf9909b3e08b6d6899b4803e" +checksum = "cca2b353d8b7f160dc930dfa174557acefece6deab5ecd7e6230d38858579eea" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -173,9 +188,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6aa3961694b30ba53d41006131a2fca3bdab22e4c344e46db2c639e7c2dfdd" +checksum = "8dedb328c2114284f767e075589ca9de8d5e9c8a91333402f4804a584ed71a38" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -191,9 +206,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53f7877ded3921d18a0a9556d55bedf84535567198c9edab2aa23106da91855" +checksum = "4841e8dd4e0f53d76b501fd4c6bc21d95d688bc8ebf0ea359fc6c7ab65b48742" dependencies = [ "alloy-primitives", "alloy-serde", @@ -214,9 +229,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3694b7e480728c0b3e228384f223937f14c10caef5a4c766021190fc8f283d35" +checksum = "254f770918f96dc4ec88a15e6e2e243358e1719d66b40ef814428e7697079d25" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -228,15 +243,17 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea94b8ceb5c75d7df0a93ba0acc53b55a22b47b532b600a800a87ef04eb5b0b4" +checksum = "931dd176c6e33355f3dc0170ec69cf5b951f4d73870b276e2c837ab35f9c5136" dependencies = [ "alloy-consensus", + "alloy-consensus-any", "alloy-eips", "alloy-json-rpc", "alloy-network-primitives", "alloy-primitives", + "alloy-rpc-types-any", "alloy-rpc-types-eth", "alloy-serde", "alloy-signer", @@ -251,9 +268,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df9f3e281005943944d15ee8491534a1c7b3cbf7a7de26f8c433b842b93eb5f9" +checksum = "fa6ec0f23be233e851e31c5e4badfedfa9c7bc177bc37f4e03616072cd40a806" dependencies = [ "alloy-consensus", "alloy-eips", @@ -264,9 +281,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9805d126f24be459b958973c0569c73e1aadd27d4535eee82b2b6764aa03616" +checksum = "e3bce85f0f67b2248c2eb42941bb75079ac53648569a668e8bfd7de5a831ec64" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -313,9 +330,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c1f9eede27bf4c13c099e8e64d54efd7ce80ef6ea47478aa75d5d74e2dba3b" +checksum = "5545e2cbf2f8f24c68bb887ba0294fa12a2f816b9e72c4f226cd137b77d0e294" dependencies = [ "alloy-chains", "alloy-consensus", @@ -326,6 +343,7 @@ dependencies = [ "alloy-primitives", "alloy-pubsub", "alloy-rpc-client", + "alloy-rpc-types-debug", "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", @@ -355,9 +373,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f1f34232f77341076541c405482e4ae12f0ee7153d8f9969fc1691201b2247" +checksum = "b633f7731a3df2f4f334001bf80436565113816c5aa5c136c1ded563051e049b" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -396,9 +414,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374dbe0dc3abdc2c964f36b3d3edf9cdb3db29d16bda34aa123f03d810bec1dd" +checksum = "aed9e40c2a73265ebf70f1e48303ee55920282e1ea5971e832873fb2d32cea74" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -422,9 +440,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c74832aa474b670309c20fffc2a869fa141edab7c79ff7963fad0a08de60bae1" +checksum = "42dea20fa715a6f39ec7adc735cfd9567342870737270ac67795d55896527772" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -438,9 +456,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca97963132f78ddfc60e43a017348e6d52eea983925c23652f5b330e8e02291" +checksum = "2750f4f694b27461915b9794df60177198bf733da38dde71aadfbe2946a3c0be" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -448,11 +466,33 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-rpc-types-any" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79d7620e22d6ed7c58451dd303d0501ade5a8bec9dc8daef0fbc48ceffabbae1" +dependencies = [ + "alloy-consensus", + "alloy-consensus-any", + "alloy-rpc-types-eth", + "alloy-serde", +] + +[[package]] +name = "alloy-rpc-types-debug" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d2d4a265fb1198272cc43d8d418c0423cdfc1aebcd283be9105464874a1dda" +dependencies = [ + "alloy-primitives", + "serde", +] + [[package]] name = "alloy-rpc-types-engine" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56294dce86af23ad6ee8df46cf8b0d292eb5d1ff67dc88a0886051e32b1faf" +checksum = "9fb843daa6feb011475f0db8c499fff5ac62e1e6012fc01d97477ddb3217a83f" dependencies = [ "alloy-consensus", "alloy-eips", @@ -468,11 +508,12 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a477281940d82d29315846c7216db45b15e90bcd52309da9f54bcf7ad94a11" +checksum = "df34b88df4deeac9ecfc80ad7cbb26a33e57437b9db8be5b952792feef6134bc" dependencies = [ "alloy-consensus", + "alloy-consensus-any", "alloy-eips", "alloy-network-primitives", "alloy-primitives", @@ -487,9 +528,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd8b4877ef520c138af702097477cdd19504a8e1e4675ba37e92ba40f2d3c6f" +checksum = "db32f30a55ea4fa9d893127a84eef52fc54d23acb34c1a5a39bfe9bd95fbc149" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -501,9 +542,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d4ab49acf90a71f7fb894dc5fd485f1f07a1e348966c714c4d1e0b7478850a8" +checksum = "af1588d8d799095a9bd55d9045b76add042ab725c37316a77da933683754aa4b" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -513,9 +554,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dfa4a7ccf15b2492bb68088692481fd6b2604ccbee1d0d6c44c21427ae4df83" +checksum = "43a89fd4cc3f96b3c5c0dd1cebeb63323e4659bbdc837117fa3fd5ac168df7d9" dependencies = [ "alloy-primitives", "serde", @@ -524,9 +565,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e10aec39d60dc27edcac447302c7803d2371946fb737245320a05b78eb2fafd" +checksum = "532010243a96d1f8593c2246ec3971bc52303884fa1e43ca0a776798ba178910" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -540,9 +581,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0109e5b18079aec2a022e4bc9db1d74bcc046f8b66274ffa8b0e4322b44b2b44" +checksum = "fd0bdb5079a35d7559714d9f9690b2ebb462921b9ceea63488bd2bef5744c15a" dependencies = [ "alloy-consensus", "alloy-network", @@ -558,9 +599,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558651eb0d76bcf2224de694481e421112fa2cbc6fe6a413cc76fd67e14cf0d7" +checksum = "794e996552efa65a76b20c088f8a968da514f90f7e44cecc32fc544c8a66fd29" dependencies = [ "alloy-consensus", "alloy-network", @@ -576,9 +617,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29781b6a064b6235de4ec3cc0810f59fe227b8d31258f23a077570fc9525d7a6" +checksum = "416fbc9f19bed61f722181b8f10bd4d89648c254d49f594e1617215f0a30ba46" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -596,9 +637,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8396f6dff60700bc1d215ee03d86ff56de268af96e2bf833a14d0bafcab9882" +checksum = "e8080c0ab2dc729b0cbb183843d08e78d2a1629140c9fc16234d2272abb483bd" dependencies = [ "alloy-consensus", "alloy-network", @@ -615,9 +656,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21267541177607141a5db6fd1abed5a46553b7a6d9363cf3d047721634705905" +checksum = "1862a5a0e883998e65b735c71560a7b9eaca57cab2165eeb80f0b9a01fff3348" dependencies = [ "alloy-consensus", "alloy-network", @@ -705,9 +746,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f99acddb34000d104961897dbb0240298e8b775a7efffb9fda2a1a3efedd65b3" +checksum = "b6f295f4b745fb9e4e663d70bc57aed991288912c7aaaf25767def921050ee43" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -725,9 +766,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc013132e34eeadaa0add7e74164c1503988bfba8bae885b32e0918ba85a8a6" +checksum = "39139015a5ec127d9c895b49b484608e27fe4538544f84cdf5eae0bd36339bc6" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -740,9 +781,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063edc0660e81260653cc6a95777c29d54c2543a668aa5da2359fb450d25a1ba" +checksum = "d9b4f865b13bb8648e93f812b19b74838b9165212a2beb95fc386188c443a5e3" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -761,9 +802,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abd170e600801116d5efe64f74a4fc073dbbb35c807013a7d0a388742aeebba0" +checksum = "6af91e3521b8b3eac26809b1c6f9b86e3ed455dfab812f036836aabdf709b921" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -792,6 +833,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "alloy-trie" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b2e366c0debf0af77766c23694a3f863b02633050e71e096e257ffbd395e50" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "arrayvec", + "derive_more", + "nybbles", + "smallvec", + "tracing", +] + [[package]] name = "ammonia" version = "4.0.0" @@ -905,7 +961,7 @@ dependencies = [ "alloy-transport", "alloy-transport-ipc", "alloy-transport-ws", - "alloy-trie", + "alloy-trie 0.6.0", "anvil-core", "anvil-rpc", "anvil-server", @@ -961,7 +1017,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-types", "alloy-serde", - "alloy-trie", + "alloy-trie 0.6.0", "bytes", "foundry-common", "foundry-evm", @@ -3546,6 +3602,7 @@ dependencies = [ name = "forge-script-sequence" version = "0.2.0" dependencies = [ + "alloy-network", "alloy-primitives", "alloy-rpc-types", "eyre", @@ -3644,6 +3701,7 @@ dependencies = [ "alloy-dyn-abi", "alloy-genesis", "alloy-json-abi", + "alloy-network", "alloy-primitives", "alloy-provider", "alloy-rlp", @@ -3743,6 +3801,7 @@ dependencies = [ "alloy-eips", "alloy-json-abi", "alloy-json-rpc", + "alloy-network", "alloy-primitives", "alloy-provider", "alloy-pubsub", @@ -4114,9 +4173,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f040169c6573e9989d1a26c3dcbe645ef8e4edabbf64af98958552da1073e4e" +checksum = "0c3d9ee7669c2a184b83c05393abfa5c9f24ef99b9abefa627fe45660adee0ba" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -6315,9 +6374,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.6.8" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce158d886815d419222daa67fcdf949a34f7950653a4498ebeb4963331f70ed" +checksum = "75353c94e7515fac7d3c280bae56bff3375784a05cb44b317260606292ff6ba9" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6331,9 +6390,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.6.8" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060ebeaea8c772e396215f69bb86d231ec8b7f36aca0dd6ce367ceaa9a8c33e6" +checksum = "680a86b63fe4c45fbd5dbf1ac6779409565211c4b234d20af94cf1f79d11f23a" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7459,9 +7518,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747291a18ad6726a08dd73f8b6a6b3a844db582ecae2063ccf0a04880c44f482" +checksum = "41bbeb6004cc4ed48d27756f0479011df91a6f5642a3abab9309eda5ce67c4ad" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", diff --git a/Cargo.toml b/Cargo.toml index b07d99cc9f92c..a4d8f2724b103 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,7 +170,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } foundry-compilers = { version = "0.12.3", default-features = false } -foundry-fork-db = "0.7.0" +foundry-fork-db = "0.8.0" solang-parser = "=0.3.3" solar-ast = { version = "=0.1.0", default-features = false } solar-parse = { version = "=0.1.0", default-features = false } @@ -178,55 +178,55 @@ solar-parse = { version = "=0.1.0", default-features = false } ## revm revm = { version = "18.0.0", default-features = false } revm-primitives = { version = "14.0.0", default-features = false } -revm-inspectors = { version = "0.11.0", features = ["serde"] } +revm-inspectors = { version = "0.12.0", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.6.4", default-features = false } -alloy-contract = { version = "0.6.4", default-features = false } -alloy-eips = { version = "0.6.4", default-features = false } -alloy-genesis = { version = "0.6.4", default-features = false } -alloy-json-rpc = { version = "0.6.4", default-features = false } -alloy-network = { version = "0.6.4", default-features = false } -alloy-provider = { version = "0.6.4", default-features = false } -alloy-pubsub = { version = "0.6.4", default-features = false } -alloy-rpc-client = { version = "0.6.4", default-features = false } -alloy-rpc-types = { version = "0.6.4", default-features = true } -alloy-serde = { version = "0.6.4", default-features = false } -alloy-signer = { version = "0.6.4", default-features = false } -alloy-signer-aws = { version = "0.6.4", default-features = false } -alloy-signer-gcp = { version = "0.6.4", default-features = false } -alloy-signer-ledger = { version = "0.6.4", default-features = false } -alloy-signer-local = { version = "0.6.4", default-features = false } -alloy-signer-trezor = { version = "0.6.4", default-features = false } -alloy-transport = { version = "0.6.4", default-features = false } -alloy-transport-http = { version = "0.6.4", default-features = false } -alloy-transport-ipc = { version = "0.6.4", default-features = false } -alloy-transport-ws = { version = "0.6.4", default-features = false } -alloy-node-bindings = { version = "0.6.4", default-features = false } +alloy-consensus = { version = "0.7.0", default-features = false } +alloy-contract = { version = "0.7.0", default-features = false } +alloy-eips = { version = "0.7.0", default-features = false } +alloy-genesis = { version = "0.7.0", default-features = false } +alloy-json-rpc = { version = "0.7.0", default-features = false } +alloy-network = { version = "0.7.0", default-features = false } +alloy-provider = { version = "0.7.0", default-features = false } +alloy-pubsub = { version = "0.7.0", default-features = false } +alloy-rpc-client = { version = "0.7.0", default-features = false } +alloy-rpc-types = { version = "0.7.0", default-features = true } +alloy-serde = { version = "0.7.0", default-features = false } +alloy-signer = { version = "0.7.0", default-features = false } +alloy-signer-aws = { version = "0.7.0", default-features = false } +alloy-signer-gcp = { version = "0.7.0", default-features = false } +alloy-signer-ledger = { version = "0.7.0", default-features = false } +alloy-signer-local = { version = "0.7.0", default-features = false } +alloy-signer-trezor = { version = "0.7.0", default-features = false } +alloy-transport = { version = "0.7.0", default-features = false } +alloy-transport-http = { version = "0.7.0", default-features = false } +alloy-transport-ipc = { version = "0.7.0", default-features = false } +alloy-transport-ws = { version = "0.7.0", default-features = false } +alloy-node-bindings = { version = "0.7.0", default-features = false } ## alloy-core -alloy-dyn-abi = "0.8.11" -alloy-json-abi = "0.8.11" -alloy-primitives = { version = "0.8.11", features = [ +alloy-dyn-abi = "0.8.14" +alloy-json-abi = "0.8.14" +alloy-primitives = { version = "0.8.14", features = [ "getrandom", "rand", "map-foldhash", ] } -alloy-sol-macro-expander = "0.8.11" -alloy-sol-macro-input = "0.8.11" -alloy-sol-types = "0.8.11" -syn-solidity = "0.8.11" +alloy-sol-macro-expander = "0.8.14" +alloy-sol-macro-input = "0.8.14" +alloy-sol-types = "0.8.14" +syn-solidity = "0.8.14" alloy-chains = "0.1" alloy-rlp = "0.3" alloy-trie = "0.6.0" ## op-alloy -op-alloy-rpc-types = "0.6.5" -op-alloy-consensus = "0.6.5" +op-alloy-rpc-types = "0.7.1" +op-alloy-consensus = "0.7.1" ## cli anstream = "0.6" diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index c9f9048b81998..50a9a66b331fc 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -65,6 +65,7 @@ impl Block { nonce: partial_header.nonce, base_fee_per_gas: partial_header.base_fee, requests_hash: partial_header.requests_hash, + target_blobs_per_block: None, }, transactions, ommers: vec![], @@ -157,6 +158,7 @@ mod tests { parent_beacon_block_root: Default::default(), base_fee_per_gas: None, requests_hash: None, + target_blobs_per_block: None, }; let encoded = alloy_rlp::encode(&header); @@ -198,6 +200,7 @@ mod tests { nonce: B64::ZERO, base_fee_per_gas: None, requests_hash: None, + target_blobs_per_block: None, }; header.encode(&mut data); @@ -231,6 +234,7 @@ mod tests { parent_beacon_block_root: None, base_fee_per_gas: None, requests_hash: None, + target_blobs_per_block: None, }; let header = Header::decode(&mut data.as_slice()).unwrap(); assert_eq!(header, expected); @@ -263,6 +267,7 @@ mod tests { excess_blob_gas: None, parent_beacon_block_root: None, requests_hash: None, + target_blobs_per_block: None, }; assert_eq!(header.hash_slow(), expected_hash); } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 8de659799a36c..4067aa6680fe6 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -6,18 +6,18 @@ use alloy_consensus::{ eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, TxEip7702, }, - AnyReceiptEnvelope, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, - TxEip2930, TxEnvelope, TxLegacy, TxReceipt, + Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, TxEip2930, + TxEnvelope, TxLegacy, TxReceipt, }; use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; -use alloy_network::{AnyRpcTransaction, AnyTxEnvelope}; +use alloy_network::{AnyReceiptEnvelope, AnyRpcTransaction, AnyTransactionReceipt, AnyTxEnvelope}; use alloy_primitives::{ Address, Bloom, Bytes, Log, PrimitiveSignature, TxHash, TxKind, B256, U256, U64, }; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use alloy_rpc_types::{ - request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, AnyTransactionReceipt, - ConversionError, Transaction as RpcTransaction, TransactionReceipt, + request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, ConversionError, + Transaction as RpcTransaction, TransactionReceipt, }; use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; @@ -1109,7 +1109,7 @@ pub struct TransactionInfo { #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] #[serde(rename_all = "camelCase")] -pub struct DepositReceipt { +pub struct DepositReceipt> { #[serde(flatten)] pub inner: ReceiptWithBloom, #[serde(default, with = "alloy_serde::quantity::opt")] @@ -1136,7 +1136,7 @@ impl DepositReceipt { /// Encodes the receipt data. fn encode_fields(&self, out: &mut dyn BufMut) { self.receipt_rlp_header().encode(out); - self.inner.receipt.status.encode(out); + self.inner.status().encode(out); self.inner.receipt.cumulative_gas_used.encode(out); self.inner.logs_bloom.encode(out); self.inner.receipt.logs.encode(out); @@ -1161,7 +1161,7 @@ impl DepositReceipt { let status = Decodable::decode(b)?; let cumulative_gas_used = Decodable::decode(b)?; let logs_bloom = Decodable::decode(b)?; - let logs = Decodable::decode(b)?; + let logs: Vec = Decodable::decode(b)?; let deposit_nonce = remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?; let deposit_nonce_version = remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?; @@ -1207,7 +1207,7 @@ impl alloy_rlp::Decodable for DepositReceipt { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(tag = "type")] -pub enum TypedReceipt { +pub enum TypedReceipt> { #[serde(rename = "0x0", alias = "0x00")] Legacy(ReceiptWithBloom), #[serde(rename = "0x1", alias = "0x01")] @@ -1248,8 +1248,8 @@ impl From> for ReceiptWithBloom { } } -impl From> for OtsReceipt { - fn from(value: TypedReceipt) -> Self { +impl From>> for OtsReceipt { + fn from(value: TypedReceipt>) -> Self { let r#type = match value { TypedReceipt::Legacy(_) => 0x00, TypedReceipt::EIP2930(_) => 0x01, @@ -1258,7 +1258,7 @@ impl From> for OtsReceipt { TypedReceipt::EIP7702(_) => 0x04, TypedReceipt::Deposit(_) => 0x7E, } as u8; - let receipt = ReceiptWithBloom::::from(value); + let receipt = ReceiptWithBloom::>::from(value); let status = receipt.status(); let cumulative_gas_used = receipt.cumulative_gas_used() as u64; let logs = receipt.logs().to_vec(); @@ -1282,7 +1282,7 @@ impl TypedReceipt { } } -impl From> for TypedReceipt { +impl From> for TypedReceipt> { fn from(value: ReceiptEnvelope) -> Self { match value { ReceiptEnvelope::Legacy(r) => Self::Legacy(r), @@ -1439,7 +1439,7 @@ impl Decodable2718 for TypedReceipt { } } -pub type ReceiptResponse = TransactionReceipt>; +pub type ReceiptResponse = TransactionReceipt>>; pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option { let WithOtherFields { diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 056b886277c9f..5635a7accbd44 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -555,15 +555,12 @@ impl MinedTransaction { } GethDebugBuiltInTracerType::CallTracer => { return match tracer_config.into_call_config() { - Ok(call_config) => Ok(GethTraceBuilder::new( - self.info.traces.clone(), - TracingInspectorConfig::from_geth_config(&config), - ) - .geth_call_traces( - call_config, - self.receipt.cumulative_gas_used() as u64, - ) - .into()), + Ok(call_config) => Ok(GethTraceBuilder::new(self.info.traces.clone()) + .geth_call_traces( + call_config, + self.receipt.cumulative_gas_used() as u64, + ) + .into()), Err(e) => Err(RpcError::invalid_params(e.to_string()).into()), }; } @@ -579,16 +576,13 @@ impl MinedTransaction { } // default structlog tracer - Ok(GethTraceBuilder::new( - self.info.traces.clone(), - TracingInspectorConfig::from_geth_config(&config), - ) - .geth_traces( - self.receipt.cumulative_gas_used() as u64, - self.info.out.clone().unwrap_or_default(), - opts.config, - ) - .into()) + Ok(GethTraceBuilder::new(self.info.traces.clone()) + .geth_traces( + self.receipt.cumulative_gas_used() as u64, + self.info.out.clone().unwrap_or_default(), + config, + ) + .into()) } } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index f3d04b09456bf..cd833f7c3ed94 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -104,6 +104,7 @@ totalDifficulty [..] blobGasUsed [..] excessBlobGas [..] requestsHash [..] +targetBlobsPerBlock [..] transactions: [ ... ] diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index 97b22b16f6e3f..a06416160111b 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -45,6 +45,7 @@ alloy-signer-local = { workspace = true, features = [ ] } parking_lot.workspace = true alloy-consensus = { workspace = true, features = ["k256"] } +alloy-network.workspace = true alloy-rlp.workspace = true base64.workspace = true diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index e52aaa688d7ab..b96a6d4d78bdb 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -4,9 +4,9 @@ use super::string::parse; use crate::{Cheatcode, Cheatcodes, CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_dyn_abi::DynSolType; use alloy_json_abi::ContractObject; +use alloy_network::AnyTransactionReceipt; use alloy_primitives::{hex, map::Entry, Bytes, U256}; use alloy_provider::network::ReceiptResponse; -use alloy_rpc_types::AnyTransactionReceipt; use alloy_sol_types::SolValue; use dialoguer::{Input, Password}; use forge_script_sequence::{BroadcastReader, TransactionWithMetadata}; diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 585e0080cc878..c09e23849ed50 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -43,6 +43,7 @@ alloy-transport-ipc.workspace = true alloy-transport-ws.workspace = true alloy-transport.workspace = true alloy-consensus = { workspace = true, features = ["k256"] } +alloy-network.workspace = true tower.workspace = true diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index a82d2cdc3d3cd..7ae6adea861ac 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -1,14 +1,15 @@ //! Helper trait and functions to format Ethereum types. use alloy_consensus::{ - AnyReceiptEnvelope, Eip658Value, Receipt, ReceiptWithBloom, Transaction as TxTrait, TxEnvelope, - TxType, + Eip658Value, Receipt, ReceiptWithBloom, Transaction as TxTrait, TxEnvelope, TxType, +}; +use alloy_network::{ + AnyHeader, AnyReceiptEnvelope, AnyRpcBlock, AnyTransactionReceipt, AnyTxEnvelope, + ReceiptResponse, }; -use alloy_network::{AnyHeader, AnyRpcBlock, AnyTxEnvelope, ReceiptResponse}; use alloy_primitives::{hex, Address, Bloom, Bytes, FixedBytes, Uint, I256, U256, U64, U8}; use alloy_rpc_types::{ - AccessListItem, AnyTransactionReceipt, Block, BlockTransactions, Header, Log, Transaction, - TransactionReceipt, + AccessListItem, Block, BlockTransactions, Header, Log, Transaction, TransactionReceipt, }; use alloy_serde::{OtherFields, WithOtherFields}; use serde::Deserialize; @@ -900,6 +901,7 @@ fn pretty_block_basics(block: &Block>) excess_blob_gas, parent_beacon_block_root, requests_hash, + target_blobs_per_block, }, }, uncles: _, @@ -931,7 +933,8 @@ withdrawalsRoot {} totalDifficulty {} blobGasUsed {} excessBlobGas {} -requestsHash {}", +requestsHash {} +targetBlobsPerBlock {}", base_fee_per_gas.pretty(), difficulty.pretty(), extra_data.pretty(), @@ -959,6 +962,7 @@ requestsHash {}", blob_gas_used.pretty(), excess_blob_gas.pretty(), requests_hash.pretty(), + target_blobs_per_block.pretty(), ) } diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index a05a46eaed236..b725fc068b17f 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -2,12 +2,13 @@ use alloy_consensus::{Transaction, TxEnvelope}; use alloy_eips::eip7702::SignedAuthorization; +use alloy_network::AnyTransactionReceipt; use alloy_primitives::{Address, TxKind, U256}; use alloy_provider::{ network::{AnyNetwork, ReceiptResponse, TransactionBuilder}, Provider, }; -use alloy_rpc_types::{AnyTransactionReceipt, BlockId, TransactionRequest}; +use alloy_rpc_types::{BlockId, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_transport::Transport; use eyre::Result; diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 6c2fbb0cfeccb..2294d511e9e8e 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -2,10 +2,10 @@ use crate::cmd::install; use alloy_chains::Chain; use alloy_dyn_abi::{DynSolValue, JsonAbiExt, Specifier}; use alloy_json_abi::{Constructor, JsonAbi}; -use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; +use alloy_network::{AnyNetwork, AnyTransactionReceipt, EthereumWallet, TransactionBuilder}; use alloy_primitives::{hex, Address, Bytes}; use alloy_provider::{PendingTransactionError, Provider, ProviderBuilder}; -use alloy_rpc_types::{AnyTransactionReceipt, TransactionRequest}; +use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; use alloy_signer::Signer; use alloy_transport::{Transport, TransportError}; diff --git a/crates/script-sequence/Cargo.toml b/crates/script-sequence/Cargo.toml index 13326e684cac6..08fd9a695fde9 100644 --- a/crates/script-sequence/Cargo.toml +++ b/crates/script-sequence/Cargo.toml @@ -28,3 +28,4 @@ revm-inspectors.workspace = true alloy-rpc-types.workspace = true alloy-primitives.workspace = true +alloy-network.workspace = true diff --git a/crates/script-sequence/src/reader.rs b/crates/script-sequence/src/reader.rs index c4627dec09ecc..de2e9faf16389 100644 --- a/crates/script-sequence/src/reader.rs +++ b/crates/script-sequence/src/reader.rs @@ -1,5 +1,5 @@ use crate::{ScriptSequence, TransactionWithMetadata}; -use alloy_rpc_types::AnyTransactionReceipt; +use alloy_network::AnyTransactionReceipt; use eyre::{bail, Result}; use foundry_common::fs; use revm_inspectors::tracing::types::CallKind; diff --git a/crates/script-sequence/src/sequence.rs b/crates/script-sequence/src/sequence.rs index 235f28f2c4ff4..4b2b434e11793 100644 --- a/crates/script-sequence/src/sequence.rs +++ b/crates/script-sequence/src/sequence.rs @@ -1,6 +1,6 @@ use crate::transaction::TransactionWithMetadata; +use alloy_network::AnyTransactionReceipt; use alloy_primitives::{hex, map::HashMap, TxHash}; -use alloy_rpc_types::AnyTransactionReceipt; use eyre::{ContextCompat, Result, WrapErr}; use foundry_common::{fs, shell, TransactionMaybeSigned, SELECTOR_LEN}; use foundry_compilers::ArtifactId; diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index f073e38e607bc..cff893b55688b 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -1,7 +1,7 @@ use alloy_chains::Chain; +use alloy_network::AnyTransactionReceipt; use alloy_primitives::{utils::format_units, TxHash, U256}; use alloy_provider::{PendingTransactionBuilder, PendingTransactionError, Provider, WatchTxError}; -use alloy_rpc_types::AnyTransactionReceipt; use eyre::Result; use foundry_common::{provider::RetryProvider, shell}; use std::time::Duration; From 3e6d3b8b6b96a02df1264294320a840ddc88345b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:55:46 +0200 Subject: [PATCH 1749/1963] feat: allow any config to be defined inline (#9430) * feat: allow any config to be defined inline * com * rm duplicate * don't update everything * bump * bump --- crates/cheatcodes/src/config.rs | 15 +- crates/cheatcodes/src/inspector.rs | 4 +- crates/chisel/src/executor.rs | 2 +- crates/config/src/inline/mod.rs | 32 +- crates/config/src/lib.rs | 2 +- crates/config/src/utils.rs | 2 +- crates/evm/core/src/opts.rs | 3 +- crates/evm/core/src/utils.rs | 5 +- crates/evm/evm/src/executors/builder.rs | 2 +- crates/evm/evm/src/executors/mod.rs | 40 +- crates/evm/evm/src/executors/trace.rs | 2 +- crates/evm/traces/src/lib.rs | 4 +- crates/forge/bin/cmd/coverage.rs | 3 +- crates/forge/bin/cmd/test/mod.rs | 7 +- crates/forge/src/lib.rs | 117 ------ crates/forge/src/multi_runner.rs | 262 +++++++----- crates/forge/src/result.rs | 42 +- crates/forge/src/runner.rs | 515 +++++++++++++++--------- crates/forge/tests/cli/inline_config.rs | 78 +++- crates/forge/tests/it/config.rs | 4 +- crates/forge/tests/it/spec.rs | 5 +- crates/forge/tests/it/test_helpers.rs | 9 +- crates/script/src/lib.rs | 2 +- 23 files changed, 679 insertions(+), 478 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 2279e24359a5d..e0463dfc45354 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -69,8 +69,8 @@ impl CheatsConfig { running_version: Option, ) -> Self { let mut allowed_paths = vec![config.root.clone()]; - allowed_paths.extend(config.libs.clone()); - allowed_paths.extend(config.allow_paths.clone()); + allowed_paths.extend(config.libs.iter().cloned()); + allowed_paths.extend(config.allow_paths.iter().cloned()); let rpc_endpoints = config.rpc_endpoints.clone().resolved(); trace!(?rpc_endpoints, "using resolved rpc endpoints"); @@ -101,6 +101,17 @@ impl CheatsConfig { } } + /// Returns a new `CheatsConfig` configured with the given `Config` and `EvmOpts`. + pub fn clone_with(&self, config: &Config, evm_opts: EvmOpts) -> Self { + Self::new( + config, + evm_opts, + self.available_artifacts.clone(), + self.running_contract.clone(), + self.running_version.clone(), + ) + } + /// Attempts to canonicalize (see [std::fs::canonicalize]) the path. /// /// Canonicalization fails for non-existing paths, in which case we just normalize the path. diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 447a9e7473ec9..ac8058dd9f996 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -439,7 +439,7 @@ pub struct Cheatcodes { /// Scripting based transactions pub broadcastable_transactions: BroadcastableTransactions, - /// Additional, user configurable context this Inspector has access to when inspecting a call + /// Additional, user configurable context this Inspector has access to when inspecting a call. pub config: Arc, /// Test-scoped context holding data that needs to be reset every test run @@ -540,7 +540,7 @@ impl Cheatcodes { /// Returns the configured wallets if available, else creates a new instance. pub fn wallets(&mut self) -> &Wallets { - self.wallets.get_or_insert(Wallets::new(MultiWallet::default(), None)) + self.wallets.get_or_insert_with(|| Wallets::new(MultiWallet::default(), None)) } /// Sets the unlocked wallets. diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 09c00f6ad5b3d..71bf18e1ad6a7 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -341,7 +341,7 @@ impl SessionSource { ) }) .gas_limit(self.config.evm_opts.gas_limit()) - .spec(self.config.foundry_config.evm_spec_id()) + .spec_id(self.config.foundry_config.evm_spec_id()) .legacy_assertions(self.config.foundry_config.legacy_assertions) .build(env, backend); diff --git a/crates/config/src/inline/mod.rs b/crates/config/src/inline/mod.rs index 30b1c820ec9b9..fa67b2426cf00 100644 --- a/crates/config/src/inline/mod.rs +++ b/crates/config/src/inline/mod.rs @@ -4,6 +4,7 @@ use figment::{ value::{Dict, Map, Value}, Figment, Profile, Provider, }; +use foundry_compilers::ProjectCompileOutput; use itertools::Itertools; mod natspec; @@ -53,6 +54,20 @@ impl InlineConfig { Self::default() } + /// Tries to create a new instance by detecting inline configurations from the project compile + /// output. + pub fn new_parsed(output: &ProjectCompileOutput, config: &Config) -> eyre::Result { + let natspecs: Vec = NatSpec::parse(output, &config.root); + let profiles = &config.profiles; + let mut inline = Self::new(); + for natspec in &natspecs { + inline.insert(natspec)?; + // Validate after parsing as TOML. + natspec.validate_profiles(profiles)?; + } + Ok(inline) + } + /// Inserts a new [`NatSpec`] into the [`InlineConfig`]. pub fn insert(&mut self, natspec: &NatSpec) -> Result<(), InlineConfigError> { let map = if let Some(function) = &natspec.function { @@ -92,13 +107,16 @@ impl InlineConfig { Figment::from(base).merge(self.provide(contract, function)) } - /// Returns `true` if a configuration is present at the given contract and function level. - pub fn contains(&self, contract: &str, function: &str) -> bool { - // Order swapped to avoid allocation in `get_function` since order doesn't matter here. - self.get_contract(contract) - .filter(|map| !map.is_empty()) - .or_else(|| self.get_function(contract, function)) - .is_some_and(|map| !map.is_empty()) + /// Returns `true` if a configuration is present at the given contract level. + pub fn contains_contract(&self, contract: &str) -> bool { + self.get_contract(contract).is_some_and(|map| !map.is_empty()) + } + + /// Returns `true` if a configuration is present at the function level. + /// + /// Does not include contract-level configurations. + pub fn contains_function(&self, contract: &str, function: &str) -> bool { + self.get_function(contract, function).is_some_and(|map| !map.is_empty()) } fn get_contract(&self, contract: &str) -> Option<&DataMap> { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index e1c3fa5ee2d00..f2d25461dfaf4 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1125,7 +1125,7 @@ impl Config { /// Returns the [SpecId] derived from the configured [EvmVersion] #[inline] pub fn evm_spec_id(&self) -> SpecId { - evm_spec_id(&self.evm_version, self.alphanet) + evm_spec_id(self.evm_version, self.alphanet) } /// Returns whether the compiler version should be auto-detected diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index e07d7dfbcb09a..19f70a939e020 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -259,7 +259,7 @@ impl FromStr for Numeric { /// Returns the [SpecId] derived from [EvmVersion] #[inline] -pub fn evm_spec_id(evm_version: &EvmVersion, alphanet: bool) -> SpecId { +pub fn evm_spec_id(evm_version: EvmVersion, alphanet: bool) -> SpecId { if alphanet { return SpecId::OSAKA; } diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index c5817e483c25b..aec0d78a05cf5 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -113,9 +113,8 @@ impl EvmOpts { /// And the block that was used to configure the environment. pub async fn fork_evm_env( &self, - fork_url: impl AsRef, + fork_url: &str, ) -> eyre::Result<(revm::primitives::Env, AnyRpcBlock)> { - let fork_url = fork_url.as_ref(); let provider = ProviderBuilder::new(fork_url) .compute_units_per_second(self.get_compute_units_per_second()) .build()?; diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 2257709e5e917..0841d93401471 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -46,10 +46,7 @@ pub fn apply_chain_and_block_specific_env_changes( return; } - NamedChain::Arbitrum | - NamedChain::ArbitrumGoerli | - NamedChain::ArbitrumNova | - NamedChain::ArbitrumTestnet => { + c if c.is_arbitrum() => { // on arbitrum `block.number` is the L1 block which is included in the // `l1BlockNumber` field if let Some(l1_block_number) = block diff --git a/crates/evm/evm/src/executors/builder.rs b/crates/evm/evm/src/executors/builder.rs index fee3c249ad90a..c371a6550b879 100644 --- a/crates/evm/evm/src/executors/builder.rs +++ b/crates/evm/evm/src/executors/builder.rs @@ -52,7 +52,7 @@ impl ExecutorBuilder { /// Sets the EVM spec to use. #[inline] - pub fn spec(mut self, spec: SpecId) -> Self { + pub fn spec_id(mut self, spec: SpecId) -> Self { self.spec_id = spec; self } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 8146cec82d44a..8560c3e10f957 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -86,9 +86,7 @@ pub struct Executor { env: EnvWithHandlerCfg, /// The Revm inspector stack. inspector: InspectorStack, - /// The gas limit for calls and deployments. This is different from the gas limit imposed by - /// the passed in environment, as those limits are used by the EVM for certain opcodes like - /// `gaslimit`. + /// The gas limit for calls and deployments. gas_limit: u64, /// Whether `failed()` should be called on the test contract to determine if the test failed. legacy_assertions: bool, @@ -166,6 +164,36 @@ impl Executor { self.env.spec_id() } + /// Sets the EVM spec ID. + pub fn set_spec_id(&mut self, spec_id: SpecId) { + self.env.handler_cfg.spec_id = spec_id; + } + + /// Returns the gas limit for calls and deployments. + /// + /// This is different from the gas limit imposed by the passed in environment, as those limits + /// are used by the EVM for certain opcodes like `gaslimit`. + pub fn gas_limit(&self) -> u64 { + self.gas_limit + } + + /// Sets the gas limit for calls and deployments. + pub fn set_gas_limit(&mut self, gas_limit: u64) { + self.gas_limit = gas_limit; + } + + /// Returns whether `failed()` should be called on the test contract to determine if the test + /// failed. + pub fn legacy_assertions(&self) -> bool { + self.legacy_assertions + } + + /// Sets whether `failed()` should be called on the test contract to determine if the test + /// failed. + pub fn set_legacy_assertions(&mut self, legacy_assertions: bool) { + self.legacy_assertions = legacy_assertions; + } + /// Creates the default CREATE2 Contract Deployer for local tests and scripts. pub fn deploy_create2_deployer(&mut self) -> eyre::Result<()> { trace!("deploying local create2 deployer"); @@ -235,12 +263,6 @@ impl Executor { self } - #[inline] - pub fn set_gas_limit(&mut self, gas_limit: u64) -> &mut Self { - self.gas_limit = gas_limit; - self - } - #[inline] pub fn create2_deployer(&self) -> Address { self.inspector().create2_deployer() diff --git a/crates/evm/evm/src/executors/trace.rs b/crates/evm/evm/src/executors/trace.rs index 214e7c28ae16e..d9c0d74f6e97f 100644 --- a/crates/evm/evm/src/executors/trace.rs +++ b/crates/evm/evm/src/executors/trace.rs @@ -32,7 +32,7 @@ impl TracingExecutor { .alphanet(alphanet) .create2_deployer(create2_deployer) }) - .spec(evm_spec_id(&version.unwrap_or_default(), alphanet)) + .spec_id(evm_spec_id(version.unwrap_or_default(), alphanet)) .build(env, db), } } diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index a0fa7e1fca498..f88efbb1b1953 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -349,8 +349,8 @@ impl TraceMode { } } - pub fn with_verbosity(self, verbosiy: u8) -> Self { - if verbosiy >= 3 { + pub fn with_verbosity(self, verbosity: u8) -> Self { + if verbosity >= 3 { std::cmp::max(self, Self::Call) } else { self diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 3a7d434369993..f1c862d81a52a 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -11,7 +11,7 @@ use forge::{ }, opts::EvmOpts, utils::IcPcMap, - MultiContractRunnerBuilder, TestOptions, + MultiContractRunnerBuilder, }; use foundry_cli::utils::{LoadConfig, STATIC_FUZZ_SEED}; use foundry_common::{compile::ProjectCompiler, fs}; @@ -233,7 +233,6 @@ impl CoverageArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_test_options(TestOptions::new(output, config.clone())?) .set_coverage(true) .build(&root, output, env, evm_opts)?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index e5a058c0d72d7..dd6d04a98cde3 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -14,7 +14,7 @@ use forge::{ identifier::SignaturesIdentifier, CallTraceDecoderBuilder, InternalTraceMode, TraceKind, }, - MultiContractRunner, MultiContractRunnerBuilder, TestFilter, TestOptions, + MultiContractRunner, MultiContractRunnerBuilder, TestFilter, }; use foundry_cli::{ opts::{CoreBuildArgs, GlobalOpts}, @@ -317,9 +317,6 @@ impl TestArgs { } } - let config = Arc::new(config); - let test_options = TestOptions::new(&output, config.clone())?; - let should_debug = self.debug.is_some(); let should_draw = self.flamegraph || self.flamechart; @@ -346,6 +343,7 @@ impl TestArgs { }; // Prepare the test builder. + let config = Arc::new(config); let runner = MultiContractRunnerBuilder::new(config.clone()) .set_debug(should_debug) .set_decode_internal(decode_internal) @@ -353,7 +351,6 @@ impl TestArgs { .evm_spec(config.evm_spec_id()) .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) - .with_test_options(test_options) .enable_isolation(evm_opts.isolate) .alphanet(evm_opts.alphanet) .build(project_root, &output, env, evm_opts)?; diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 257760c4e94be..ddeada0a69c23 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -7,17 +7,6 @@ extern crate foundry_common; #[macro_use] extern crate tracing; -use alloy_primitives::U256; -use eyre::Result; -use foundry_compilers::ProjectCompileOutput; -use foundry_config::{ - figment::Figment, Config, FuzzConfig, InlineConfig, InvariantConfig, NatSpec, -}; -use proptest::test_runner::{ - FailurePersistence, FileFailurePersistence, RngAlgorithm, TestRng, TestRunner, -}; -use std::sync::Arc; - pub mod coverage; pub mod gas_report; @@ -34,109 +23,3 @@ pub mod result; // TODO: remove pub use foundry_common::traits::TestFilter; pub use foundry_evm::*; - -/// Test configuration. -#[derive(Clone, Debug, Default)] -pub struct TestOptions { - /// The base configuration. - pub config: Arc, - /// Per-test configuration. Merged onto `base_config`. - pub inline: InlineConfig, -} - -impl TestOptions { - /// Tries to create a new instance by detecting inline configurations from the project compile - /// output. - pub fn new(output: &ProjectCompileOutput, base_config: Arc) -> eyre::Result { - let natspecs: Vec = NatSpec::parse(output, &base_config.root); - let profiles = &base_config.profiles; - let mut inline = InlineConfig::new(); - for natspec in &natspecs { - inline.insert(natspec)?; - // Validate after parsing as TOML. - natspec.validate_profiles(profiles)?; - } - Ok(Self { config: base_config, inline }) - } - - /// Creates a new instance without parsing inline configuration. - pub fn new_unparsed(base_config: Arc) -> Self { - Self { config: base_config, inline: InlineConfig::new() } - } - - /// Returns the [`Figment`] for the configuration. - pub fn figment(&self, contract: &str, function: &str) -> Result { - Ok(self.inline.merge(contract, function, &self.config)) - } - - /// Returns a "fuzz" test runner instance. Parameters are used to select tight scoped fuzz - /// configs that apply for a contract-function pair. A fallback configuration is applied - /// if no specific setup is found for a given input. - /// - /// - `contract` is the id of the test contract, expressed as a relative path from the project - /// root. - /// - `function` is the name of the test function declared inside the test contract. - pub fn fuzz_runner(&self, contract: &str, function: &str) -> Result<(FuzzConfig, TestRunner)> { - let config: FuzzConfig = self.figment(contract, function)?.extract_inner("fuzz")?; - let failure_persist_path = config - .failure_persist_dir - .as_ref() - .unwrap() - .join(config.failure_persist_file.as_ref().unwrap()) - .into_os_string() - .into_string() - .unwrap(); - let runner = fuzzer_with_cases( - config.seed, - config.runs, - config.max_test_rejects, - Some(Box::new(FileFailurePersistence::Direct(failure_persist_path.leak()))), - ); - Ok((config, runner)) - } - - /// Returns an "invariant" test runner instance. Parameters are used to select tight scoped fuzz - /// configs that apply for a contract-function pair. A fallback configuration is applied - /// if no specific setup is found for a given input. - /// - /// - `contract` is the id of the test contract, expressed as a relative path from the project - /// root. - /// - `function` is the name of the test function declared inside the test contract. - pub fn invariant_runner( - &self, - contract: &str, - function: &str, - ) -> Result<(InvariantConfig, TestRunner)> { - let figment = self.figment(contract, function)?; - let config: InvariantConfig = figment.extract_inner("invariant")?; - let seed: Option = figment.extract_inner("fuzz.seed").ok(); - let runner = fuzzer_with_cases(seed, config.runs, config.max_assume_rejects, None); - Ok((config, runner)) - } -} - -fn fuzzer_with_cases( - seed: Option, - cases: u32, - max_global_rejects: u32, - file_failure_persistence: Option>, -) -> TestRunner { - let config = proptest::test_runner::Config { - failure_persistence: file_failure_persistence, - cases, - max_global_rejects, - // Disable proptest shrink: for fuzz tests we provide single counterexample, - // for invariant tests we shrink outside proptest. - max_shrink_iters: 0, - ..Default::default() - }; - - if let Some(seed) = seed { - trace!(target: "forge::test", %seed, "building deterministic fuzzer"); - let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &seed.to_be_bytes::<32>()); - TestRunner::new_with_rng(config, rng) - } else { - trace!(target: "forge::test", "building stochastic fuzzer"); - TestRunner::new(config) - } -} diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 572c3d4fe9845..0372becb208af 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -2,20 +2,18 @@ use crate::{ progress::TestsProgress, result::SuiteResult, runner::LIBRARY_DEPLOYER, ContractRunner, - TestFilter, TestOptions, + TestFilter, }; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{get_contract_name, shell::verbosity, ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{ - artifacts::Libraries, compilers::Compiler, Artifact, ArtifactId, ProjectCompileOutput, -}; -use foundry_config::Config; +use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput}; +use foundry_config::{Config, InlineConfig}; use foundry_evm::{ backend::Backend, decode::RevertDecoder, - executors::ExecutorBuilder, + executors::{Executor, ExecutorBuilder}, fork::CreateFork, inspectors::CheatsConfig, opts::EvmOpts, @@ -48,38 +46,34 @@ pub struct MultiContractRunner { /// Mapping of contract name to JsonAbi, creation bytecode and library bytecode which /// needs to be deployed & linked against pub contracts: DeployableContracts, - /// The EVM instance used in the test runner - pub evm_opts: EvmOpts, - /// The configured evm - pub env: revm::primitives::Env, - /// The EVM spec - pub evm_spec: SpecId, - /// Revert decoder. Contains all known errors and their selectors. - pub revert_decoder: RevertDecoder, - /// The address which will be used as the `from` field in all EVM calls - pub sender: Option

, - /// The fork to use at launch - pub fork: Option, - /// Project config. - pub config: Arc, - /// Whether to collect coverage info - pub coverage: bool, - /// Whether to collect debug info - pub debug: bool, - /// Whether to enable steps tracking in the tracer. - pub decode_internal: InternalTraceMode, - /// Settings related to fuzz and/or invariant tests - pub test_options: TestOptions, - /// Whether to enable call isolation - pub isolation: bool, - /// Whether to enable Alphanet features. - pub alphanet: bool, /// Known contracts linked with computed library addresses. pub known_contracts: ContractsByArtifact, + /// Revert decoder. Contains all known errors and their selectors. + pub revert_decoder: RevertDecoder, /// Libraries to deploy. pub libs_to_deploy: Vec, /// Library addresses used to link contracts. pub libraries: Libraries, + + /// The fork to use at launch + pub fork: Option, + + /// The base configuration for the test runner. + pub tcfg: TestRunnerConfig, +} + +impl std::ops::Deref for MultiContractRunner { + type Target = TestRunnerConfig; + + fn deref(&self) -> &Self::Target { + &self.tcfg + } +} + +impl std::ops::DerefMut for MultiContractRunner { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.tcfg + } } impl MultiContractRunner { @@ -196,7 +190,7 @@ impl MultiContractRunner { let result = self.run_test_suite( id, contract, - db.clone(), + &db, filter, &tokio_handle, Some(&tests_progress), @@ -219,8 +213,7 @@ impl MultiContractRunner { } else { contracts.par_iter().for_each(|&(id, contract)| { let _guard = tokio_handle.enter(); - let result = - self.run_test_suite(id, contract, db.clone(), filter, &tokio_handle, None); + let result = self.run_test_suite(id, contract, &db, filter, &tokio_handle, None); let _ = tx.send((id.identifier(), result)); }) } @@ -230,7 +223,7 @@ impl MultiContractRunner { &self, artifact_id: &ArtifactId, contract: &TestContract, - db: Backend, + db: &Backend, filter: &dyn TestFilter, tokio_handle: &tokio::runtime::Handle, progress: Option<&TestsProgress>, @@ -238,35 +231,6 @@ impl MultiContractRunner { let identifier = artifact_id.identifier(); let mut span_name = identifier.as_str(); - let cheats_config = CheatsConfig::new( - &self.config, - self.evm_opts.clone(), - Some(self.known_contracts.clone()), - Some(artifact_id.name.clone()), - Some(artifact_id.version.clone()), - ); - - let trace_mode = TraceMode::default() - .with_debug(self.debug) - .with_decode_internal(self.decode_internal) - .with_verbosity(self.evm_opts.verbosity) - .with_state_changes(verbosity() > 4); - - let executor = ExecutorBuilder::new() - .inspectors(|stack| { - stack - .cheatcodes(Arc::new(cheats_config)) - .trace_mode(trace_mode) - .coverage(self.coverage) - .enable_isolation(self.isolation) - .alphanet(self.alphanet) - .create2_deployer(self.evm_opts.create2_deployer) - }) - .spec(self.evm_spec) - .gas_limit(self.evm_opts.gas_limit()) - .legacy_assertions(self.config.legacy_assertions) - .build(self.env.clone(), db); - if !enabled!(tracing::Level::TRACE) { span_name = get_contract_name(&identifier); } @@ -276,20 +240,16 @@ impl MultiContractRunner { debug!("start executing all tests in contract"); - let runner = ContractRunner { - name: &identifier, + let runner = ContractRunner::new( + &identifier, contract, - libs_to_deploy: &self.libs_to_deploy, - executor, - revert_decoder: &self.revert_decoder, - initial_balance: self.evm_opts.initial_balance, - sender: self.sender.unwrap_or_default(), - debug: self.debug, + self.tcfg.executor(self.known_contracts.clone(), artifact_id, db.clone()), progress, tokio_handle, span, - }; - let r = runner.run_tests(filter, &self.test_options, self.known_contracts.clone()); + self, + ); + let r = runner.run_tests(filter); debug!(duration=?r.duration, "executed all tests in contract"); @@ -297,6 +257,116 @@ impl MultiContractRunner { } } +/// Configuration for the test runner. +/// +/// This is modified after instantiation through inline config. +#[derive(Clone)] +pub struct TestRunnerConfig { + /// Project config. + pub config: Arc, + /// Inline configuration. + pub inline_config: Arc, + + /// EVM configuration. + pub evm_opts: EvmOpts, + /// EVM environment. + pub env: revm::primitives::Env, + /// EVM version. + pub spec_id: SpecId, + /// The address which will be used to deploy the initial contracts and send all transactions. + pub sender: Address, + + /// Whether to collect coverage info + pub coverage: bool, + /// Whether to collect debug info + pub debug: bool, + /// Whether to enable steps tracking in the tracer. + pub decode_internal: InternalTraceMode, + /// Whether to enable call isolation. + pub isolation: bool, + /// Whether to enable Alphanet features. + pub alphanet: bool, +} + +impl TestRunnerConfig { + /// Reconfigures all fields using the given `config`. + pub fn reconfigure_with(&mut self, config: Arc) { + debug_assert!(!Arc::ptr_eq(&self.config, &config)); + + // TODO: self.evm_opts + // TODO: self.env + self.spec_id = config.evm_spec_id(); + self.sender = config.sender; + // self.coverage = N/A; + // self.debug = N/A; + // self.decode_internal = N/A; + // self.isolation = N/A; + self.alphanet = config.alphanet; + + self.config = config; + } + + /// Configures the given executor with this configuration. + pub fn configure_executor(&self, executor: &mut Executor) { + // TODO: See above + + let inspector = executor.inspector_mut(); + // inspector.set_env(&self.env); + if let Some(cheatcodes) = inspector.cheatcodes.as_mut() { + cheatcodes.config = + Arc::new(cheatcodes.config.clone_with(&self.config, self.evm_opts.clone())); + } + inspector.tracing(self.trace_mode()); + inspector.collect_coverage(self.coverage); + inspector.enable_isolation(self.isolation); + inspector.alphanet(self.alphanet); + // inspector.set_create2_deployer(self.evm_opts.create2_deployer); + + // executor.env_mut().clone_from(&self.env); + executor.set_spec_id(self.spec_id); + // executor.set_gas_limit(self.evm_opts.gas_limit()); + executor.set_legacy_assertions(self.config.legacy_assertions); + } + + /// Creates a new executor with this configuration. + pub fn executor( + &self, + known_contracts: ContractsByArtifact, + artifact_id: &ArtifactId, + db: Backend, + ) -> Executor { + let cheats_config = Arc::new(CheatsConfig::new( + &self.config, + self.evm_opts.clone(), + Some(known_contracts), + Some(artifact_id.name.clone()), + Some(artifact_id.version.clone()), + )); + ExecutorBuilder::new() + .inspectors(|stack| { + stack + .cheatcodes(cheats_config) + .trace_mode(self.trace_mode()) + .coverage(self.coverage) + .enable_isolation(self.isolation) + .alphanet(self.alphanet) + .create2_deployer(self.evm_opts.create2_deployer) + }) + .spec_id(self.spec_id) + .gas_limit(self.evm_opts.gas_limit()) + .legacy_assertions(self.config.legacy_assertions) + .build(self.env.clone(), db) + } + + fn trace_mode(&self) -> TraceMode { + TraceMode::default() + .with_debug(self.debug) + .with_decode_internal(self.decode_internal) + .with_verbosity(self.evm_opts.verbosity) + .with_state_changes(verbosity() > 4) + } +} + /// Builder used for instantiating the multi-contract runner #[derive(Clone, Debug)] #[must_use = "builders do nothing unless you call `build` on them"] @@ -322,8 +392,6 @@ pub struct MultiContractRunnerBuilder { pub isolation: bool, /// Whether to enable Alphanet features. pub alphanet: bool, - /// Settings related to fuzz and/or invariant tests - pub test_options: Option, } impl MultiContractRunnerBuilder { @@ -337,7 +405,6 @@ impl MultiContractRunnerBuilder { coverage: Default::default(), debug: Default::default(), isolation: Default::default(), - test_options: Default::default(), decode_internal: Default::default(), alphanet: Default::default(), } @@ -363,11 +430,6 @@ impl MultiContractRunnerBuilder { self } - pub fn with_test_options(mut self, test_options: TestOptions) -> Self { - self.test_options = Some(test_options); - self - } - pub fn set_coverage(mut self, enable: bool) -> Self { self.coverage = enable; self @@ -395,10 +457,10 @@ impl MultiContractRunnerBuilder { /// Given an EVM, proceeds to return a runner which is able to execute all tests /// against that evm - pub fn build( + pub fn build( self, root: &Path, - output: &ProjectCompileOutput, + output: &ProjectCompileOutput, env: revm::primitives::Env, evm_opts: EvmOpts, ) -> Result { @@ -449,22 +511,28 @@ impl MultiContractRunnerBuilder { Ok(MultiContractRunner { contracts: deployable_contracts, - evm_opts, - env, - evm_spec: self.evm_spec.unwrap_or(SpecId::CANCUN), - sender: self.sender, revert_decoder, - fork: self.fork, - config: self.config, - coverage: self.coverage, - debug: self.debug, - decode_internal: self.decode_internal, - test_options: self.test_options.unwrap_or_default(), - isolation: self.isolation, - alphanet: self.alphanet, known_contracts, libs_to_deploy, libraries, + + fork: self.fork, + + tcfg: TestRunnerConfig { + evm_opts, + env, + spec_id: self.evm_spec.unwrap_or_else(|| self.config.evm_spec_id()), + sender: self.sender.unwrap_or(self.config.sender), + + coverage: self.coverage, + debug: self.debug, + decode_internal: self.decode_internal, + inline_config: Arc::new(InlineConfig::new_parsed(output, &self.config)?), + isolation: self.isolation, + alphanet: self.alphanet, + + config: self.config, + }, }) } } diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 7f02db577c0de..28b52d74c1f03 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -467,12 +467,12 @@ impl fmt::Display for TestResult { impl TestResult { /// Creates a new test result starting from test setup results. - pub fn new(setup: TestSetup) -> Self { + pub fn new(setup: &TestSetup) -> Self { Self { - labeled_addresses: setup.labels, - logs: setup.logs, - traces: setup.traces, - coverage: setup.coverage, + labeled_addresses: setup.labels.clone(), + logs: setup.logs.clone(), + traces: setup.traces.clone(), + coverage: setup.coverage.clone(), ..Default::default() } } @@ -496,27 +496,25 @@ impl TestResult { } /// Returns the skipped result for single test (used in skipped fuzz test too). - pub fn single_skip(mut self, reason: SkipReason) -> Self { + pub fn single_skip(&mut self, reason: SkipReason) { self.status = TestStatus::Skipped; self.reason = reason.0; - self } /// Returns the failed result with reason for single test. - pub fn single_fail(mut self, reason: Option) -> Self { + pub fn single_fail(&mut self, reason: Option) { self.status = TestStatus::Failure; self.reason = reason; - self } /// Returns the result for single test. Merges execution results (logs, labeled addresses, /// traces and coverages) in initial setup results. pub fn single_result( - mut self, + &mut self, success: bool, reason: Option, raw_call_result: RawCallResult, - ) -> Self { + ) { self.kind = TestKind::Unit { gas: raw_call_result.gas_used.wrapping_sub(raw_call_result.stipend) }; @@ -539,13 +537,11 @@ impl TestResult { self.gas_snapshots = cheatcodes.gas_snapshots; self.deprecated_cheatcodes = cheatcodes.deprecated; } - - self } /// Returns the result for a fuzzed test. Merges fuzz execution results (logs, labeled /// addresses, traces and coverages) in initial setup results. - pub fn fuzz_result(mut self, result: FuzzTestResult) -> Self { + pub fn fuzz_result(&mut self, result: FuzzTestResult) { self.kind = TestKind::Fuzz { median_gas: result.median_gas(false), mean_gas: result.mean_gas(false), @@ -572,26 +568,23 @@ impl TestResult { self.gas_report_traces = result.gas_report_traces.into_iter().map(|t| vec![t]).collect(); self.breakpoints = result.breakpoints.unwrap_or_default(); self.deprecated_cheatcodes = result.deprecated_cheatcodes; - - self } /// Returns the skipped result for invariant test. - pub fn invariant_skip(mut self, reason: SkipReason) -> Self { + pub fn invariant_skip(&mut self, reason: SkipReason) { self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1, metrics: HashMap::default() }; self.status = TestStatus::Skipped; self.reason = reason.0; - self } /// Returns the fail result for replayed invariant test. pub fn invariant_replay_fail( - mut self, + &mut self, replayed_entirely: bool, invariant_name: &String, call_sequence: Vec, - ) -> Self { + ) { self.kind = TestKind::Invariant { runs: 1, calls: 1, reverts: 1, metrics: HashMap::default() }; self.status = TestStatus::Failure; @@ -601,22 +594,20 @@ impl TestResult { Some(format!("{invariant_name} persisted failure revert")) }; self.counterexample = Some(CounterExample::Sequence(call_sequence)); - self } /// Returns the fail result for invariant test setup. - pub fn invariant_setup_fail(mut self, e: Report) -> Self { + pub fn invariant_setup_fail(&mut self, e: Report) { self.kind = TestKind::Invariant { runs: 0, calls: 0, reverts: 0, metrics: HashMap::default() }; self.status = TestStatus::Failure; self.reason = Some(format!("failed to set up invariant testing environment: {e}")); - self } /// Returns the invariant test result. #[allow(clippy::too_many_arguments)] pub fn invariant_result( - mut self, + &mut self, gas_report_traces: Vec>, success: bool, reason: Option, @@ -624,7 +615,7 @@ impl TestResult { cases: Vec, reverts: usize, metrics: Map, - ) -> Self { + ) { self.kind = TestKind::Invariant { runs: cases.len(), calls: cases.iter().map(|sequence| sequence.cases().len()).sum(), @@ -638,7 +629,6 @@ impl TestResult { self.reason = reason; self.counterexample = counterexample; self.gas_report_traces = gas_report_traces; - self } /// Returns `true` if this is the result of a fuzz test diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index fc2b89cb08150..0948df6d1b0df 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -2,20 +2,17 @@ use crate::{ fuzz::{invariant::BasicTxDetails, BaseCounterExample}, - multi_runner::{is_matching_test, TestContract}, + multi_runner::{is_matching_test, TestContract, TestRunnerConfig}, progress::{start_fuzz_progress, TestsProgress}, result::{SuiteResult, TestResult, TestSetup}, - TestFilter, TestOptions, + MultiContractRunner, TestFilter, }; use alloy_dyn_abi::DynSolValue; use alloy_json_abi::Function; -use alloy_primitives::{address, map::HashMap, Address, Bytes, U256}; +use alloy_primitives::{address, map::HashMap, Address, U256}; use eyre::Result; -use foundry_common::{ - contracts::{ContractsByAddress, ContractsByArtifact}, - TestFunctionExt, TestFunctionKind, -}; -use foundry_config::{FuzzConfig, InvariantConfig}; +use foundry_common::{contracts::ContractsByAddress, TestFunctionExt, TestFunctionKind}; +use foundry_config::Config; use foundry_evm::{ constants::CALLER, decode::RevertDecoder, @@ -33,9 +30,12 @@ use foundry_evm::{ }, traces::{load_contracts, TraceKind, TraceMode}, }; -use proptest::test_runner::TestRunner; +use proptest::test_runner::{ + FailurePersistence, FileFailurePersistence, RngAlgorithm, TestRng, TestRunner, +}; use rayon::prelude::*; -use std::{borrow::Cow, cmp::min, collections::BTreeMap, time::Instant}; +use std::{borrow::Cow, cmp::min, collections::BTreeMap, sync::Arc, time::Instant}; +use tracing::Span; /// When running tests, we deploy all external libraries present in the project. To avoid additional /// libraries affecting nonces of senders used in tests, we are using separate address to @@ -45,33 +45,56 @@ use std::{borrow::Cow, cmp::min, collections::BTreeMap, time::Instant}; pub const LIBRARY_DEPLOYER: Address = address!("1F95D37F27EA0dEA9C252FC09D5A6eaA97647353"); /// A type that executes all tests of a contract -#[derive(Clone, Debug)] pub struct ContractRunner<'a> { /// The name of the contract. - pub name: &'a str, + name: &'a str, /// The data of the contract. - pub contract: &'a TestContract, - /// The libraries that need to be deployed before the contract. - pub libs_to_deploy: &'a Vec, - /// The executor used by the runner. - pub executor: Executor, - /// Revert decoder. Contains all known errors. - pub revert_decoder: &'a RevertDecoder, - /// The initial balance of the test contract. - pub initial_balance: U256, - /// The address which will be used as the `from` field in all EVM calls. - pub sender: Address, - /// Whether debug traces should be generated. - pub debug: bool, + contract: &'a TestContract, + /// The EVM executor. + executor: Executor, /// Overall test run progress. - pub progress: Option<&'a TestsProgress>, + progress: Option<&'a TestsProgress>, /// The handle to the tokio runtime. - pub tokio_handle: &'a tokio::runtime::Handle, + tokio_handle: &'a tokio::runtime::Handle, /// The span of the contract. - pub span: tracing::Span, + span: tracing::Span, + /// The contract-level configuration. + tcfg: Cow<'a, TestRunnerConfig>, + /// The parent runner. + mcr: &'a MultiContractRunner, +} + +impl<'a> std::ops::Deref for ContractRunner<'a> { + type Target = Cow<'a, TestRunnerConfig>; + + #[inline(always)] + fn deref(&self) -> &Self::Target { + &self.tcfg + } } -impl ContractRunner<'_> { +impl<'a> ContractRunner<'a> { + pub fn new( + name: &'a str, + contract: &'a TestContract, + executor: Executor, + progress: Option<&'a TestsProgress>, + tokio_handle: &'a tokio::runtime::Handle, + span: Span, + mcr: &'a MultiContractRunner, + ) -> Self { + Self { + name, + contract, + executor, + progress, + tokio_handle, + span, + tcfg: Cow::Borrowed(&mcr.tcfg), + mcr, + } + } + /// Deploys the test contract inside the runner from the sending account, and optionally runs /// the `setUp` function on the test contract. pub fn setup(&mut self, call_setup: bool) -> TestSetup { @@ -84,6 +107,8 @@ impl ContractRunner<'_> { fn _setup(&mut self, call_setup: bool) -> Result { trace!(call_setup, "setting up"); + self.apply_contract_inline_config()?; + // We max out their balance so that they can deploy and make calls. self.executor.set_balance(self.sender, U256::MAX)?; self.executor.set_balance(CALLER, U256::MAX)?; @@ -95,12 +120,12 @@ impl ContractRunner<'_> { self.executor.set_balance(LIBRARY_DEPLOYER, U256::MAX)?; let mut result = TestSetup::default(); - for code in self.libs_to_deploy.iter() { + for code in self.mcr.libs_to_deploy.iter() { let deploy_result = self.executor.deploy( LIBRARY_DEPLOYER, code.clone(), U256::ZERO, - Some(self.revert_decoder), + Some(&self.mcr.revert_decoder), ); let (raw, reason) = RawCallResult::from_evm_result(deploy_result.map(Into::into))?; result.extend(raw, TraceKind::Deployment); @@ -115,14 +140,14 @@ impl ContractRunner<'_> { // Set the contracts initial balance before deployment, so it is available during // construction - self.executor.set_balance(address, self.initial_balance)?; + self.executor.set_balance(address, self.initial_balance())?; // Deploy the test contract let deploy_result = self.executor.deploy( self.sender, self.contract.bytecode.clone(), U256::ZERO, - Some(self.revert_decoder), + Some(&self.mcr.revert_decoder), ); if let Ok(dr) = &deploy_result { debug_assert_eq!(dr.address, address); @@ -135,16 +160,16 @@ impl ContractRunner<'_> { } // Reset `self.sender`s, `CALLER`s and `LIBRARY_DEPLOYER`'s balance to the initial balance. - self.executor.set_balance(self.sender, self.initial_balance)?; - self.executor.set_balance(CALLER, self.initial_balance)?; - self.executor.set_balance(LIBRARY_DEPLOYER, self.initial_balance)?; + self.executor.set_balance(self.sender, self.initial_balance())?; + self.executor.set_balance(CALLER, self.initial_balance())?; + self.executor.set_balance(LIBRARY_DEPLOYER, self.initial_balance())?; self.executor.deploy_create2_deployer()?; // Optionally call the `setUp` function if call_setup { trace!("calling setUp"); - let res = self.executor.setup(None, address, Some(self.revert_decoder)); + let res = self.executor.setup(None, address, Some(&self.mcr.revert_decoder)); let (raw, reason) = RawCallResult::from_evm_result(res)?; result.extend(raw, TraceKind::Setup); result.reason = reason; @@ -155,6 +180,31 @@ impl ContractRunner<'_> { Ok(result) } + fn initial_balance(&self) -> U256 { + self.evm_opts.initial_balance + } + + /// Configures this runner with the inline configuration for the contract. + fn apply_contract_inline_config(&mut self) -> Result<()> { + if self.inline_config.contains_contract(self.name) { + let new_config = Arc::new(self.inline_config(None)?); + self.tcfg.to_mut().reconfigure_with(new_config); + let prev_tracer = self.executor.inspector_mut().tracer.take(); + self.tcfg.configure_executor(&mut self.executor); + // Don't set tracer here. + self.executor.inspector_mut().tracer = prev_tracer; + } + Ok(()) + } + + /// Returns the configuration for a contract or function. + fn inline_config(&self, func: Option<&Function>) -> Result { + let function = func.map(|f| f.name.as_str()).unwrap_or(""); + let config = + self.mcr.inline_config.merge(self.name, function, &self.config).extract::()?; + Ok(config) + } + /// Collect fixtures from test contract. /// /// Fixtures can be defined: @@ -210,12 +260,7 @@ impl ContractRunner<'_> { } /// Runs all tests for a contract whose names match the provided regular expression - pub fn run_tests( - mut self, - filter: &dyn TestFilter, - test_options: &TestOptions, - known_contracts: ContractsByArtifact, - ) -> SuiteResult { + pub fn run_tests(mut self, filter: &dyn TestFilter) -> SuiteResult { let start = Instant::now(); let mut warnings = Vec::new(); @@ -302,16 +347,16 @@ impl ContractRunner<'_> { .functions() .filter(|func| is_matching_test(func, filter)) .collect::>(); - let find_time = find_timer.elapsed(); debug!( "Found {} test functions out of {} in {:?}", functions.len(), self.contract.abi.functions().count(), - find_time, + find_timer.elapsed(), ); - let identified_contracts = has_invariants - .then(|| load_contracts(setup.traces.iter().map(|(_, t)| &t.arena), &known_contracts)); + let identified_contracts = has_invariants.then(|| { + load_contracts(setup.traces.iter().map(|(_, t)| &t.arena), &self.mcr.known_contracts) + }); let test_results = functions .par_iter() .map(|&func| { @@ -335,36 +380,12 @@ impl ContractRunner<'_> { ) .entered(); - let setup = setup.clone(); - let mut res = match kind { - TestFunctionKind::UnitTest { should_fail } => { - self.run_unit_test(func, should_fail, setup) - } - TestFunctionKind::FuzzTest { should_fail } => { - match test_options.fuzz_runner(self.name, &func.name) { - Ok((fuzz_config, runner)) => { - self.run_fuzz_test(func, should_fail, runner, setup, fuzz_config) - } - Err(err) => TestResult::fail(err.to_string()), - } - } - TestFunctionKind::InvariantTest => { - match test_options.invariant_runner(self.name, &func.name) { - Ok((invariant_config, runner)) => self.run_invariant_test( - runner, - setup, - invariant_config, - func, - call_after_invariant, - &known_contracts, - identified_contracts.as_ref().unwrap(), - ), - Err(err) => TestResult::fail(err.to_string()), - } - } - _ => unreachable!(), - }; - + let mut res = FunctionRunner::new(&self, &setup).run( + func, + kind, + call_after_invariant, + identified_contracts.as_ref(), + ); res.duration = start.elapsed(); (sig, res) @@ -374,6 +395,83 @@ impl ContractRunner<'_> { let duration = start.elapsed(); SuiteResult::new(duration, test_results, warnings) } +} + +/// Executes a single test function, returning a [`TestResult`]. +struct FunctionRunner<'a> { + /// The function-level configuration. + tcfg: Cow<'a, TestRunnerConfig>, + /// The EVM executor. + executor: Cow<'a, Executor>, + /// The parent runner. + cr: &'a ContractRunner<'a>, + /// The address of the test contract. + address: Address, + /// The test setup result. + setup: &'a TestSetup, + /// The test result. Returned after running the test. + result: TestResult, +} + +impl<'a> std::ops::Deref for FunctionRunner<'a> { + type Target = Cow<'a, TestRunnerConfig>; + + #[inline(always)] + fn deref(&self) -> &Self::Target { + &self.tcfg + } +} + +impl<'a> FunctionRunner<'a> { + fn new(cr: &'a ContractRunner<'a>, setup: &'a TestSetup) -> Self { + Self { + tcfg: match &cr.tcfg { + Cow::Borrowed(tcfg) => Cow::Borrowed(tcfg), + Cow::Owned(tcfg) => Cow::Owned(tcfg.clone()), + }, + executor: Cow::Borrowed(&cr.executor), + cr, + address: setup.address, + setup, + result: TestResult::new(setup), + } + } + + fn revert_decoder(&self) -> &'a RevertDecoder { + &self.cr.mcr.revert_decoder + } + + /// Configures this runner with the inline configuration for the contract. + fn apply_function_inline_config(&mut self, func: &Function) -> Result<()> { + if self.inline_config.contains_function(self.cr.name, &func.name) { + let new_config = Arc::new(self.cr.inline_config(Some(func))?); + self.tcfg.to_mut().reconfigure_with(new_config); + self.tcfg.configure_executor(self.executor.to_mut()); + } + Ok(()) + } + + fn run( + mut self, + func: &Function, + kind: TestFunctionKind, + call_after_invariant: bool, + identified_contracts: Option<&ContractsByAddress>, + ) -> TestResult { + if let Err(e) = self.apply_function_inline_config(func) { + self.result.single_fail(Some(e.to_string())); + return self.result; + } + + match kind { + TestFunctionKind::UnitTest { should_fail } => self.run_unit_test(func, should_fail), + TestFunctionKind::FuzzTest { should_fail } => self.run_fuzz_test(func, should_fail), + TestFunctionKind::InvariantTest => { + self.run_invariant_test(func, call_after_invariant, identified_contracts.unwrap()) + } + _ => unreachable!(), + } + } /// Runs a single unit test. /// @@ -383,80 +481,77 @@ impl ContractRunner<'_> { /// (therefore the unit test call will be made on modified state). /// State modifications of before test txes and unit test function call are discarded after /// test ends, similar to `eth_call`. - pub fn run_unit_test( - &self, - func: &Function, - should_fail: bool, - setup: TestSetup, - ) -> TestResult { + fn run_unit_test(mut self, func: &Function, should_fail: bool) -> TestResult { // Prepare unit test execution. - let (executor, test_result, address) = match self.prepare_test(func, setup) { - Ok(res) => res, - Err(res) => return res, - }; + if self.prepare_test(func).is_err() { + return self.result; + } // Run current unit test. - let (mut raw_call_result, reason) = match executor.call( + let (mut raw_call_result, reason) = match self.executor.call( self.sender, - address, + self.address, func, &[], U256::ZERO, - Some(self.revert_decoder), + Some(self.revert_decoder()), ) { Ok(res) => (res.raw, None), Err(EvmError::Execution(err)) => (err.raw, Some(err.reason)), - Err(EvmError::Skip(reason)) => return test_result.single_skip(reason), - Err(err) => return test_result.single_fail(Some(err.to_string())), + Err(EvmError::Skip(reason)) => { + self.result.single_skip(reason); + return self.result; + } + Err(err) => { + self.result.single_fail(Some(err.to_string())); + return self.result; + } }; - let success = executor.is_raw_call_mut_success(address, &mut raw_call_result, should_fail); - test_result.single_result(success, reason, raw_call_result) + let success = + self.executor.is_raw_call_mut_success(self.address, &mut raw_call_result, should_fail); + self.result.single_result(success, reason, raw_call_result); + self.result } - #[allow(clippy::too_many_arguments)] - pub fn run_invariant_test( - &self, - runner: TestRunner, - setup: TestSetup, - invariant_config: InvariantConfig, + fn run_invariant_test( + mut self, func: &Function, call_after_invariant: bool, - known_contracts: &ContractsByArtifact, identified_contracts: &ContractsByAddress, ) -> TestResult { - let address = setup.address; - let fuzz_fixtures = setup.fuzz_fixtures.clone(); - let mut test_result = TestResult::new(setup); - // First, run the test normally to see if it needs to be skipped. if let Err(EvmError::Skip(reason)) = self.executor.call( self.sender, - address, + self.address, func, &[], U256::ZERO, - Some(self.revert_decoder), + Some(self.revert_decoder()), ) { - return test_result.invariant_skip(reason); + self.result.invariant_skip(reason); + return self.result; }; + let runner = self.invariant_runner(); + let invariant_config = &self.config.invariant; + let mut evm = InvariantExecutor::new( - self.executor.clone(), + self.clone_executor(), runner, invariant_config.clone(), identified_contracts, - known_contracts, + &self.cr.mcr.known_contracts, ); let invariant_contract = InvariantContract { - address, + address: self.address, invariant_function: func, call_after_invariant, - abi: &self.contract.abi, + abi: &self.cr.contract.abi, }; - let failure_dir = invariant_config.clone().failure_dir(self.name); - let failure_file = failure_dir.join(invariant_contract.invariant_function.clone().name); + let failure_dir = invariant_config.clone().failure_dir(self.cr.name); + let failure_file = failure_dir.join(&invariant_contract.invariant_function.name); // Try to replay recorded failure if any. if let Ok(call_sequence) = @@ -474,7 +569,7 @@ impl ContractRunner<'_> { }) .collect::>(); if let Ok((success, replayed_entirely)) = check_sequence( - self.executor.clone(), + self.clone_executor(), &txes, (0..min(txes.len(), invariant_config.depth as usize)).collect(), invariant_contract.address, @@ -492,34 +587,40 @@ impl ContractRunner<'_> { // exit without executing new runs. let _ = replay_run( &invariant_contract, - self.executor.clone(), - known_contracts, + self.clone_executor(), + &self.cr.mcr.known_contracts, identified_contracts.clone(), - &mut test_result.logs, - &mut test_result.traces, - &mut test_result.coverage, - &mut test_result.deprecated_cheatcodes, + &mut self.result.logs, + &mut self.result.traces, + &mut self.result.coverage, + &mut self.result.deprecated_cheatcodes, &txes, ); - return test_result.invariant_replay_fail( + self.result.invariant_replay_fail( replayed_entirely, &invariant_contract.invariant_function.name, call_sequence, - ) + ); + return self.result; } } } let progress = - start_fuzz_progress(self.progress, self.name, &func.name, invariant_config.runs); - let invariant_result = - match evm.invariant_fuzz(invariant_contract.clone(), &fuzz_fixtures, progress.as_ref()) - { - Ok(x) => x, - Err(e) => return test_result.invariant_setup_fail(e), - }; + start_fuzz_progress(self.cr.progress, self.cr.name, &func.name, invariant_config.runs); + let invariant_result = match evm.invariant_fuzz( + invariant_contract.clone(), + &self.setup.fuzz_fixtures, + progress.as_ref(), + ) { + Ok(x) => x, + Err(e) => { + self.result.invariant_setup_fail(e); + return self.result; + } + }; // Merge coverage collected during invariant run with test setup coverage. - test_result.merge_coverages(invariant_result.coverage); + self.result.merge_coverages(invariant_result.coverage); let mut counterexample = None; let success = invariant_result.error.is_none(); @@ -535,13 +636,13 @@ impl ContractRunner<'_> { match replay_error( &case_data, &invariant_contract, - self.executor.clone(), - known_contracts, + self.clone_executor(), + &self.cr.mcr.known_contracts, identified_contracts.clone(), - &mut test_result.logs, - &mut test_result.traces, - &mut test_result.coverage, - &mut test_result.deprecated_cheatcodes, + &mut self.result.logs, + &mut self.result.traces, + &mut self.result.coverage, + &mut self.result.deprecated_cheatcodes, progress.as_ref(), ) { Ok(call_sequence) => { @@ -571,13 +672,13 @@ impl ContractRunner<'_> { _ => { if let Err(err) = replay_run( &invariant_contract, - self.executor.clone(), - known_contracts, + self.clone_executor(), + &self.cr.mcr.known_contracts, identified_contracts.clone(), - &mut test_result.logs, - &mut test_result.traces, - &mut test_result.coverage, - &mut test_result.deprecated_cheatcodes, + &mut self.result.logs, + &mut self.result.traces, + &mut self.result.coverage, + &mut self.result.deprecated_cheatcodes, &invariant_result.last_run_inputs, ) { error!(%err, "Failed to replay last invariant run"); @@ -585,7 +686,7 @@ impl ContractRunner<'_> { } } - test_result.invariant_result( + self.result.invariant_result( invariant_result.gas_report_traces, success, reason, @@ -593,7 +694,8 @@ impl ContractRunner<'_> { invariant_result.cases, invariant_result.reverts, invariant_result.metrics, - ) + ); + self.result } /// Runs a fuzzed test. @@ -605,35 +707,31 @@ impl ContractRunner<'_> { /// (therefore the fuzz test will use the modified state). /// State modifications of before test txes and fuzz test are discarded after test ends, /// similar to `eth_call`. - pub fn run_fuzz_test( - &self, - func: &Function, - should_fail: bool, - runner: TestRunner, - setup: TestSetup, - fuzz_config: FuzzConfig, - ) -> TestResult { - let progress = start_fuzz_progress(self.progress, self.name, &func.name, fuzz_config.runs); - + fn run_fuzz_test(mut self, func: &Function, should_fail: bool) -> TestResult { // Prepare fuzz test execution. - let fuzz_fixtures = setup.fuzz_fixtures.clone(); - let (executor, test_result, address) = match self.prepare_test(func, setup) { - Ok(res) => res, - Err(res) => return res, - }; + if self.prepare_test(func).is_err() { + return self.result; + } + + let runner = self.fuzz_runner(); + let fuzz_config = self.config.fuzz.clone(); + + let progress = + start_fuzz_progress(self.cr.progress, self.cr.name, &func.name, fuzz_config.runs); // Run fuzz test. let fuzzed_executor = - FuzzedExecutor::new(executor.into_owned(), runner, self.sender, fuzz_config); + FuzzedExecutor::new(self.executor.into_owned(), runner, self.tcfg.sender, fuzz_config); let result = fuzzed_executor.fuzz( func, - &fuzz_fixtures, - address, + &self.setup.fuzz_fixtures, + self.address, should_fail, - self.revert_decoder, + &self.cr.mcr.revert_decoder, progress.as_ref(), ); - test_result.fuzz_result(result) + self.result.fuzz_result(result); + self.result } /// Prepares single unit test and fuzz test execution: @@ -645,20 +743,15 @@ impl ContractRunner<'_> { /// /// Unit tests within same contract (or even current test) are valid options for before test tx /// configuration. Test execution stops if any of before test txes fails. - fn prepare_test( - &self, - func: &Function, - setup: TestSetup, - ) -> Result<(Cow<'_, Executor>, TestResult, Address), TestResult> { - let address = setup.address; - let mut executor = Cow::Borrowed(&self.executor); - let mut test_result = TestResult::new(setup); + fn prepare_test(&mut self, func: &Function) -> Result<(), ()> { + let address = self.setup.address; // Apply before test configured functions (if any). - if self.contract.abi.functions().filter(|func| func.name.is_before_test_setup()).count() == + if self.cr.contract.abi.functions().filter(|func| func.name.is_before_test_setup()).count() == 1 { - for calldata in executor + for calldata in self + .executor .call_sol_default( address, &ITest::beforeTestSetupCall { testSelector: func.selector() }, @@ -666,22 +759,84 @@ impl ContractRunner<'_> { .beforeTestCalldata { // Apply before test configured calldata. - match executor.to_mut().transact_raw(self.sender, address, calldata, U256::ZERO) { + match self.executor.to_mut().transact_raw( + self.tcfg.sender, + address, + calldata, + U256::ZERO, + ) { Ok(call_result) => { let reverted = call_result.reverted; // Merge tx result traces in unit test result. - test_result.extend(call_result); + self.result.extend(call_result); // To continue unit test execution the call should not revert. if reverted { - return Err(test_result.single_fail(None)) + self.result.single_fail(None); + return Err(()); } } - Err(_) => return Err(test_result.single_fail(None)), + Err(_) => { + self.result.single_fail(None); + return Err(()); + } } } } - Ok((executor, test_result, address)) + Ok(()) + } + + fn fuzz_runner(&self) -> TestRunner { + let config = &self.config.fuzz; + let failure_persist_path = config + .failure_persist_dir + .as_ref() + .unwrap() + .join(config.failure_persist_file.as_ref().unwrap()) + .into_os_string() + .into_string() + .unwrap(); + fuzzer_with_cases( + config.seed, + config.runs, + config.max_test_rejects, + Some(Box::new(FileFailurePersistence::Direct(failure_persist_path.leak()))), + ) + } + + fn invariant_runner(&self) -> TestRunner { + let config = &self.config.invariant; + fuzzer_with_cases(self.config.fuzz.seed, config.runs, config.max_assume_rejects, None) + } + + fn clone_executor(&self) -> Executor { + self.executor.clone().into_owned() + } +} + +fn fuzzer_with_cases( + seed: Option, + cases: u32, + max_global_rejects: u32, + file_failure_persistence: Option>, +) -> TestRunner { + let config = proptest::test_runner::Config { + failure_persistence: file_failure_persistence, + cases, + max_global_rejects, + // Disable proptest shrink: for fuzz tests we provide single counterexample, + // for invariant tests we shrink outside proptest. + max_shrink_iters: 0, + ..Default::default() + }; + + if let Some(seed) = seed { + trace!(target: "forge::test", %seed, "building deterministic fuzzer"); + let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &seed.to_be_bytes::<32>()); + TestRunner::new_with_rng(config, rng) + } else { + trace!(target: "forge::test", "building stochastic fuzzer"); + TestRunner::new(config) } } diff --git a/crates/forge/tests/cli/inline_config.rs b/crates/forge/tests/cli/inline_config.rs index de585a48ce17b..31da29d21ea86 100644 --- a/crates/forge/tests/cli/inline_config.rs +++ b/crates/forge/tests/cli/inline_config.rs @@ -147,14 +147,14 @@ forgetest!(invalid_value, |prj, cmd| { Compiler run successful! Ran 1 test for test/inline.sol:Inline -[FAIL: invalid type: found sequence, expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) +[FAIL: invalid type: found sequence, expected u32 for key "default.fuzz.runs" in inline config] setUp() ([GAS]) Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) Failing tests: Encountered 1 failing test in test/inline.sol:Inline -[FAIL: invalid type: found sequence, expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) +[FAIL: invalid type: found sequence, expected u32 for key "default.fuzz.runs" in inline config] setUp() ([GAS]) Encountered a total of 1 failing tests, 0 tests succeeded @@ -179,16 +179,86 @@ forgetest!(invalid_value_2, |prj, cmd| { Compiler run successful! Ran 1 test for test/inline.sol:Inline -[FAIL: invalid type: found string "2", expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) +[FAIL: invalid type: found string "2", expected u32 for key "default.fuzz.runs" in inline config] setUp() ([GAS]) Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 0 tests passed, 1 failed, 0 skipped (1 total tests) Failing tests: Encountered 1 failing test in test/inline.sol:Inline -[FAIL: invalid type: found string "2", expected u32 for key "default.runs.fuzz" in inline config] test(bool) ([GAS]) +[FAIL: invalid type: found string "2", expected u32 for key "default.fuzz.runs" in inline config] setUp() ([GAS]) Encountered a total of 1 failing tests, 0 tests succeeded "#]]); }); + +forgetest_init!(evm_version, |prj, cmd| { + prj.wipe_contracts(); + prj.add_test( + "inline.sol", + r#" + import {Test} from "forge-std/Test.sol"; + + contract Dummy { + function getBlobBaseFee() public returns (uint256) { + return block.blobbasefee; + } + } + + contract FunctionConfig is Test { + Dummy dummy; + + function setUp() public { + dummy = new Dummy(); + } + + /// forge-config: default.evm_version = "shanghai" + function test_old() public { + vm.expectRevert(); + dummy.getBlobBaseFee(); + } + + function test_new() public { + dummy.getBlobBaseFee(); + } + } + + /// forge-config: default.evm_version = "shanghai" + contract ContractConfig is Test { + Dummy dummy; + + function setUp() public { + dummy = new Dummy(); + } + + function test_old() public { + vm.expectRevert(); + dummy.getBlobBaseFee(); + } + + /// forge-config: default.evm_version = "cancun" + function test_new() public { + dummy.getBlobBaseFee(); + } + } + "#, + ) + .unwrap(); + + cmd.arg("test").arg("--evm-version=cancun").assert_success().stdout_eq(str![[r#" +... +Ran 2 tests for test/inline.sol:FunctionConfig +[PASS] test_new() ([GAS]) +[PASS] test_old() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 2 tests for test/inline.sol:ContractConfig +[PASS] test_new() ([GAS]) +[PASS] test_old() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 2 test suites [ELAPSED]: 4 tests passed, 0 failed, 0 skipped (4 total tests) + +"#]]); +}); diff --git a/crates/forge/tests/it/config.rs b/crates/forge/tests/it/config.rs index 9cabd998a01a8..655fae4db254b 100644 --- a/crates/forge/tests/it/config.rs +++ b/crates/forge/tests/it/config.rs @@ -31,8 +31,8 @@ impl TestConfig { Self { runner, should_fail: false, filter } } - pub fn evm_spec(mut self, spec: SpecId) -> Self { - self.runner.evm_spec = spec; + pub fn spec_id(mut self, spec: SpecId) -> Self { + self.runner.spec_id = spec; self } diff --git a/crates/forge/tests/it/spec.rs b/crates/forge/tests/it/spec.rs index aed2063a0fba4..52e581c33c921 100644 --- a/crates/forge/tests/it/spec.rs +++ b/crates/forge/tests/it/spec.rs @@ -7,8 +7,5 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn test_shanghai_compat() { let filter = Filter::new("", "ShanghaiCompat", ".*spec"); - TestConfig::with_filter(TEST_DATA_PARIS.runner(), filter) - .evm_spec(SpecId::SHANGHAI) - .run() - .await; + TestConfig::with_filter(TEST_DATA_PARIS.runner(), filter).spec_id(SpecId::SHANGHAI).run().await; } diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 54985b9b6154e..937f582f4e4ff 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -2,9 +2,7 @@ use alloy_chains::NamedChain; use alloy_primitives::U256; -use forge::{ - revm::primitives::SpecId, MultiContractRunner, MultiContractRunnerBuilder, TestOptions, -}; +use forge::{revm::primitives::SpecId, MultiContractRunner, MultiContractRunnerBuilder}; use foundry_compilers::{ artifacts::{EvmVersion, Libraries, Settings}, utils::RuntimeOrHandle, @@ -177,9 +175,7 @@ impl ForgeTestData { pub fn base_runner(&self) -> MultiContractRunnerBuilder { init_tracing(); let config = self.config.clone(); - let mut runner = MultiContractRunnerBuilder::new(config.clone()) - .sender(self.config.sender) - .with_test_options(TestOptions::new_unparsed(config)); + let mut runner = MultiContractRunnerBuilder::new(config).sender(self.config.sender); if self.profile.is_paris() { runner = runner.evm_spec(SpecId::MERGE); } @@ -216,7 +212,6 @@ impl ForgeTestData { builder .enable_isolation(opts.isolate) .sender(config.sender) - .with_test_options(TestOptions::new(&self.output, config.clone()).unwrap()) .build(root, &self.output, opts.local_evm_env(), opts) .unwrap() } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index ccf5eab2ad0dd..5f5543912fe2a 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -618,7 +618,7 @@ impl ScriptConfig { .alphanet(self.evm_opts.alphanet) .create2_deployer(self.evm_opts.create2_deployer) }) - .spec(self.config.evm_spec_id()) + .spec_id(self.config.evm_spec_id()) .gas_limit(self.evm_opts.gas_limit()) .legacy_assertions(self.config.legacy_assertions); From 7d0b0a0371765afa0734197dc01f9f7f4d5d4c1b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:21:22 +0200 Subject: [PATCH 1750/1963] chore(deps): bump foundry-compilers 0.12.4 (#9455) --- Cargo.lock | 34 ++++++++++++++++----------------- crates/cheatcodes/src/string.rs | 11 ++--------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea8b8da749b3d..87ac75dee06ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3864,9 +3864,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6131af72175c55aa531c4851290d9cf67af7a82b03f20a8a9d28dba81b9fd3" +checksum = "daece74fc0b127e587ac343405283577b4fe9d0195317998c3031778b5f799cd" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3881,7 +3881,6 @@ dependencies = [ "home", "itertools 0.13.0", "md-5", - "once_cell", "path-slash", "rand", "rayon", @@ -3893,7 +3892,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", "tracing", "winnow", @@ -3902,9 +3901,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c522c473e7a111b81f0d47f8a65ca1ef0642c8c8d1ca2d1e230338210d16bb02" +checksum = "c0c6b0571a37cc9860103df548330eaceb36e9438cb0264ec63e5db74031fa4f" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3912,9 +3911,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cd569a0c38d232244932e71933b54e418cddcc8f0c16fd8af96dd844b27788" +checksum = "278cc3f1f4f628793ae6c0db38b0d3fe4124ab0bc10da081b1eb365766512e6d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3927,7 +3926,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", "tracing", "walkdir", @@ -3936,9 +3935,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b80563ba10981ec4a9667fda9318d02721a81f248ae73303603388580150a35" +checksum = "196b16fcfbbe69a315d64f74dd817ba6843f7749c64124b937118551414b9b90" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3951,15 +3950,14 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a840a87cb4845d208df3390a12d3724e6d1cc1268a51ac334a01f80f9b6419b" +checksum = "1eb08a74eb12b281038bbf74cbbd76cc3c85546896628d4c7c769c816ab4104b" dependencies = [ "alloy-primitives", "cfg-if", "dunce", "fs_extra", - "once_cell", "path-slash", "regex", "semver 1.0.23", @@ -3967,7 +3965,7 @@ dependencies = [ "serde_json", "svm-rs", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", "walkdir", ] @@ -7114,7 +7112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.90", @@ -8567,7 +8565,7 @@ dependencies = [ "const-hex", "derive_builder", "dunce", - "itertools 0.13.0", + "itertools 0.11.0", "itoa", "lasso", "match_cfg", @@ -8603,7 +8601,7 @@ dependencies = [ "alloy-primitives", "bitflags 2.6.0", "bumpalo", - "itertools 0.13.0", + "itertools 0.11.0", "memchr", "num-bigint", "num-rational", diff --git a/crates/cheatcodes/src/string.rs b/crates/cheatcodes/src/string.rs index a4c06eef650b1..080d9bc0820ff 100644 --- a/crates/cheatcodes/src/string.rs +++ b/crates/cheatcodes/src/string.rs @@ -17,7 +17,7 @@ impl Cheatcode for toString_0Call { impl Cheatcode for toString_1Call { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { value } = self; - Ok(hex::encode_prefixed(value).abi_encode()) + Ok(value.to_string().abi_encode()) } } @@ -95,7 +95,6 @@ impl Cheatcode for parseBoolCall { } } -// toLowercase impl Cheatcode for toLowercaseCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { input } = self; @@ -103,7 +102,6 @@ impl Cheatcode for toLowercaseCall { } } -// toUppercase impl Cheatcode for toUppercaseCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { input } = self; @@ -111,7 +109,6 @@ impl Cheatcode for toUppercaseCall { } } -// trim impl Cheatcode for trimCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { input } = self; @@ -119,7 +116,6 @@ impl Cheatcode for trimCall { } } -// Replace impl Cheatcode for replaceCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { input, from, to } = self; @@ -127,7 +123,6 @@ impl Cheatcode for replaceCall { } } -// Split impl Cheatcode for splitCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { input, delimiter } = self; @@ -136,7 +131,6 @@ impl Cheatcode for splitCall { } } -// indexOf impl Cheatcode for indexOfCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { input, key } = self; @@ -144,7 +138,6 @@ impl Cheatcode for indexOfCall { } } -// contains impl Cheatcode for containsCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { subject, search } = self; @@ -202,7 +195,7 @@ fn parse_value_fallback(s: &str, ty: &DynSolType) -> Option { - if !s.starts_with("0x") && s.chars().all(|c| c.is_ascii_hexdigit()) { + if !s.starts_with("0x") && hex::check_raw(s) { return Some(Err("missing hex prefix (\"0x\") for hex string")); } } From b7a065f79fa63c80ece43e05b5e521ae269b4635 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:56:00 +0200 Subject: [PATCH 1751/1963] perf(coverage): improve HitMap merging and internal repr (#9456) --- crates/evm/coverage/src/lib.rs | 88 +++++++++++++++++--------------- crates/forge/bin/cmd/coverage.rs | 4 +- crates/forge/src/coverage.rs | 5 +- 3 files changed, 50 insertions(+), 47 deletions(-) diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 8d5575631f842..345261ad5b2c4 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -5,19 +5,20 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#[macro_use] -extern crate foundry_common; - #[macro_use] extern crate tracing; -use alloy_primitives::{map::HashMap, Bytes, B256}; -use eyre::{Context, Result}; +use alloy_primitives::{ + map::{B256HashMap, HashMap}, + Bytes, +}; +use eyre::Result; use foundry_compilers::artifacts::sourcemap::SourceMap; use semver::Version; use std::{ collections::BTreeMap, fmt::Display, + num::NonZeroU32, ops::{Deref, DerefMut, Range}, path::{Path, PathBuf}, sync::Arc, @@ -119,22 +120,21 @@ impl CoverageReport { is_deployed_code: bool, ) -> Result<()> { // Add bytecode level hits - let e = self - .bytecode_hits + self.bytecode_hits .entry(contract_id.clone()) - .or_insert_with(|| HitMap::new(hit_map.bytecode.clone())); - e.merge(hit_map).wrap_err_with(|| format!("{contract_id:?}"))?; + .and_modify(|m| m.merge(hit_map)) + .or_insert_with(|| hit_map.clone()); // Add source level hits if let Some(anchors) = self.anchors.get(contract_id) { let anchors = if is_deployed_code { &anchors.1 } else { &anchors.0 }; for anchor in anchors { - if let Some(&hits) = hit_map.hits.get(&anchor.instruction) { + if let Some(hits) = hit_map.get(anchor.instruction) { self.items .get_mut(&contract_id.version) .and_then(|items| items.get_mut(anchor.item_id)) .expect("Anchor refers to non-existent coverage item") - .hits += hits; + .hits += hits.get(); } } } @@ -160,9 +160,10 @@ impl CoverageReport { /// A collection of [`HitMap`]s. #[derive(Clone, Debug, Default)] -pub struct HitMaps(pub HashMap); +pub struct HitMaps(pub B256HashMap); impl HitMaps { + /// Merges two `Option`. pub fn merge_opt(a: &mut Option, b: Option) { match (a, b) { (_, None) => {} @@ -171,17 +172,14 @@ impl HitMaps { } } + /// Merges two `HitMaps`. pub fn merge(&mut self, other: Self) { - for (code_hash, hit_map) in other.0 { - if let Some(HitMap { hits: extra_hits, .. }) = self.insert(code_hash, hit_map) { - for (pc, hits) in extra_hits { - self.entry(code_hash) - .and_modify(|map| *map.hits.entry(pc).or_default() += hits); - } - } + for (code_hash, other) in other.0 { + self.entry(code_hash).and_modify(|e| e.merge(&other)).or_insert(other); } } + /// Merges two `HitMaps`. pub fn merged(mut self, other: Self) -> Self { self.merge(other); self @@ -189,7 +187,7 @@ impl HitMaps { } impl Deref for HitMaps { - type Target = HashMap; + type Target = B256HashMap; fn deref(&self) -> &Self::Target { &self.0 @@ -207,40 +205,46 @@ impl DerefMut for HitMaps { /// Contains low-level data about hit counters for the instructions in the bytecode of a contract. #[derive(Clone, Debug)] pub struct HitMap { - pub bytecode: Bytes, - pub hits: BTreeMap, + bytecode: Bytes, + hits: HashMap, } impl HitMap { + /// Create a new hitmap with the given bytecode. pub fn new(bytecode: Bytes) -> Self { - Self { bytecode, hits: BTreeMap::new() } + Self { bytecode, hits: Default::default() } + } + + /// Returns the bytecode. + pub fn bytecode(&self) -> &Bytes { + &self.bytecode } - /// Increase the hit counter for the given program counter. + /// Returns the number of hits for the given program counter. + pub fn get(&self, pc: usize) -> Option { + NonZeroU32::new(self.hits.get(&Self::cvt_pc(pc)).copied().unwrap_or(0)) + } + + /// Increase the hit counter by 1 for the given program counter. pub fn hit(&mut self, pc: usize) { - *self.hits.entry(pc).or_default() += 1; + self.hits(pc, 1) + } + + /// Increase the hit counter by `hits` for the given program counter. + pub fn hits(&mut self, pc: usize, hits: u32) { + *self.hits.entry(Self::cvt_pc(pc)).or_default() += hits; } /// Merge another hitmap into this, assuming the bytecode is consistent - pub fn merge(&mut self, other: &Self) -> Result<(), eyre::Report> { - for (pc, hits) in &other.hits { - *self.hits.entry(*pc).or_default() += hits; + pub fn merge(&mut self, other: &Self) { + for (&pc, &hits) in &other.hits { + self.hits(pc as usize, hits); } - Ok(()) } - pub fn consistent_bytecode(&self, hm1: &Self, hm2: &Self) -> bool { - // Consider the bytecodes consistent if they are the same out as far as the - // recorded hits - let len1 = hm1.hits.last_key_value(); - let len2 = hm2.hits.last_key_value(); - if let (Some(len1), Some(len2)) = (len1, len2) { - let len = std::cmp::max(len1.0, len2.0); - let ok = hm1.bytecode.0[..*len] == hm2.bytecode.0[..*len]; - let _ = sh_println!("consistent_bytecode: {}, {}, {}, {}", ok, len1.0, len2.0, len); - return ok; - } - true + #[inline] + fn cvt_pc(pc: usize) -> u32 { + pc.try_into().expect("4GiB bytecode") } } @@ -311,7 +315,7 @@ pub struct CoverageItem { /// The location of the item in the source code. pub loc: SourceLocation, /// The number of times this item was hit. - pub hits: u64, + pub hits: u32, } impl Display for CoverageItem { diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index f1c862d81a52a..d995e764df5bc 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -250,10 +250,10 @@ impl CoverageArgs { for result in suite.test_results.values() { let Some(hit_maps) = result.coverage.as_ref() else { continue }; for map in hit_maps.0.values() { - if let Some((id, _)) = known_contracts.find_by_deployed_code(&map.bytecode) { + if let Some((id, _)) = known_contracts.find_by_deployed_code(map.bytecode()) { hits.push((id, map, true)); } else if let Some((id, _)) = - known_contracts.find_by_creation_code(&map.bytecode) + known_contracts.find_by_creation_code(map.bytecode()) { hits.push((id, map, false)); } diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 14fc5e7be8023..f73b17da532d7 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -212,7 +212,7 @@ impl CoverageReporter for BytecodeReporter { let mut line_number_cache = LineNumberCache::new(self.root.clone()); for (contract_id, hits) in &report.bytecode_hits { - let ops = disassemble_bytes(hits.bytecode.to_vec())?; + let ops = disassemble_bytes(hits.bytecode().to_vec())?; let mut formatted = String::new(); let source_elements = @@ -220,8 +220,7 @@ impl CoverageReporter for BytecodeReporter { for (code, source_element) in std::iter::zip(ops.iter(), source_elements) { let hits = hits - .hits - .get(&(code.offset as usize)) + .get(code.offset as usize) .map(|h| format!("[{h:03}]")) .unwrap_or(" ".to_owned()); let source_id = source_element.index(); From d35fee62382b9bf66c946f3f9b6646e00a64db43 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:45:35 +0200 Subject: [PATCH 1752/1963] perf(coverage): cache computed bytecode hash in CoverageCollector (#9457) * perf(coverage): cache computed bytecode hash in CoverageCollector * perf: use get_mut instead of entry --- crates/evm/coverage/src/inspector.rs | 32 +++++++++++++++----------- crates/evm/evm/src/inspectors/stack.rs | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index 73d2ff148fa9c..07c24ae9e5ef4 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -2,35 +2,41 @@ use crate::{HitMap, HitMaps}; use alloy_primitives::B256; use revm::{interpreter::Interpreter, Database, EvmContext, Inspector}; +/// Inspector implementation for collecting coverage information. #[derive(Clone, Debug, Default)] pub struct CoverageCollector { - /// Maps that track instruction hit data. - pub maps: HitMaps, + maps: HitMaps, } impl Inspector for CoverageCollector { - #[inline] - fn initialize_interp(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { + fn initialize_interp(&mut self, interpreter: &mut Interpreter, _context: &mut EvmContext) { self.maps - .entry(get_contract_hash(interp)) - .or_insert_with(|| HitMap::new(interp.contract.bytecode.original_bytes())); + .entry(*get_contract_hash(interpreter)) + .or_insert_with(|| HitMap::new(interpreter.contract.bytecode.original_bytes())); } #[inline] - fn step(&mut self, interp: &mut Interpreter, _context: &mut EvmContext) { + fn step(&mut self, interpreter: &mut Interpreter, _context: &mut EvmContext) { + if let Some(map) = self.maps.get_mut(get_contract_hash(interpreter)) { + map.hit(interpreter.program_counter()); + } + } +} + +impl CoverageCollector { + /// Finish collecting coverage information and return the [`HitMaps`]. + pub fn finish(self) -> HitMaps { self.maps - .entry(get_contract_hash(interp)) - .and_modify(|map| map.hit(interp.program_counter())); } } /// Helper function for extracting contract hash used to record coverage hit map. /// If contract hash available in interpreter contract is zero (contract not yet created but going /// to be created in current tx) then it hash is calculated from contract bytecode. -fn get_contract_hash(interp: &mut Interpreter) -> B256 { - let mut hash = interp.contract.hash.expect("Contract hash is None"); - if hash == B256::ZERO { - hash = interp.contract.bytecode.hash_slow(); +fn get_contract_hash(interpreter: &mut Interpreter) -> &B256 { + let hash = interpreter.contract.hash.as_mut().expect("coverage does not support EOF"); + if *hash == B256::ZERO { + *hash = interpreter.contract.bytecode.hash_slow(); } hash } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index accbca4fd59c9..94ec349b1f53e 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -470,7 +470,7 @@ impl InspectorStack { .map(|cheatcodes| cheatcodes.labels.clone()) .unwrap_or_default(), traces, - coverage: coverage.map(|coverage| coverage.maps), + coverage: coverage.map(|coverage| coverage.finish()), cheatcodes, chisel_state: chisel_state.and_then(|state| state.state), } From ee9d23723efe7893c10547371d830b24bd2aab13 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:50:13 +0200 Subject: [PATCH 1753/1963] fix(coverage): also ignore empty fallbacks and receives (#9459) --- crates/evm/coverage/src/analysis.rs | 7 +-- crates/forge/tests/cli/coverage.rs | 77 +++++++++++++++++++---------- 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 07b9160350c40..06673293a9b39 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -57,9 +57,10 @@ impl<'a> ContractVisitor<'a> { let kind: String = node.attribute("kind").ok_or_else(|| eyre::eyre!("Function has no kind"))?; - // Do not add coverage item for constructors without statements. - if kind == "constructor" && !has_statements(body) { - return Ok(()) + // TODO: We currently can only detect empty bodies in normal functions, not any of the other + // kinds: https://github.com/foundry-rs/foundry/issues/9458 + if kind != "function" && !has_statements(body) { + return Ok(()); } // `fallback`, `receive`, and `constructor` functions have an empty `name`. diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 9b0569da6ff6b..6ffc6c2b323ad 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -5,7 +5,7 @@ use foundry_test_utils::{ }; use std::path::Path; -fn basic_coverage_base(prj: TestProject, mut cmd: TestCommand) { +fn basic_base(prj: TestProject, mut cmd: TestCommand) { cmd.args(["coverage", "--report=lcov", "--report=summary"]).assert_success().stdout_eq(str![[ r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -75,11 +75,11 @@ end_of_record ); } -forgetest_init!(basic_coverage, |prj, cmd| { - basic_coverage_base(prj, cmd); +forgetest_init!(basic, |prj, cmd| { + basic_base(prj, cmd); }); -forgetest_init!(basic_coverage_crlf, |prj, cmd| { +forgetest_init!(basic_crlf, |prj, cmd| { // Manually replace `\n` with `\r\n` in the source file. let make_crlf = |path: &Path| { fs::write(path, fs::read_to_string(path).unwrap().replace('\n', "\r\n")).unwrap() @@ -88,10 +88,10 @@ forgetest_init!(basic_coverage_crlf, |prj, cmd| { make_crlf(&prj.paths().scripts.join("Counter.s.sol")); // Should have identical stdout and lcov output. - basic_coverage_base(prj, cmd); + basic_base(prj, cmd); }); -forgetest!(test_setup_coverage, |prj, cmd| { +forgetest!(setup, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -144,7 +144,7 @@ contract AContractTest is DSTest { "#]]); }); -forgetest!(test_no_match_coverage, |prj, cmd| { +forgetest!(no_match, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -239,7 +239,7 @@ contract BContractTest is DSTest { ]]); }); -forgetest!(test_assert_coverage, |prj, cmd| { +forgetest!(assert, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -317,7 +317,7 @@ contract AContractTest is DSTest { "#]]); }); -forgetest!(test_require_coverage, |prj, cmd| { +forgetest!(require, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -393,7 +393,7 @@ contract AContractTest is DSTest { "#]]); }); -forgetest!(test_line_hit_not_doubled, |prj, cmd| { +forgetest!(line_hit_not_doubled, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -447,7 +447,7 @@ end_of_record ); }); -forgetest!(test_branch_coverage, |prj, cmd| { +forgetest!(branch, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "Foo.sol", @@ -699,7 +699,7 @@ contract FooTest is DSTest { "#]]); }); -forgetest!(test_function_call_coverage, |prj, cmd| { +forgetest!(function_call, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -770,7 +770,7 @@ contract AContractTest is DSTest { "#]]); }); -forgetest!(test_try_catch_coverage, |prj, cmd| { +forgetest!(try_catch, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "Foo.sol", @@ -879,7 +879,7 @@ contract FooTest is DSTest { "#]]); }); -forgetest!(test_yul_coverage, |prj, cmd| { +forgetest!(yul, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "Foo.sol", @@ -982,7 +982,7 @@ contract FooTest is DSTest { "#]]); }); -forgetest!(test_misc_coverage, |prj, cmd| { +forgetest!(misc, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "Foo.sol", @@ -1073,7 +1073,7 @@ contract FooTest is DSTest { }); // https://github.com/foundry-rs/foundry/issues/8605 -forgetest!(test_single_statement_coverage, |prj, cmd| { +forgetest!(single_statement, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -1151,7 +1151,7 @@ contract AContractTest is DSTest { }); // https://github.com/foundry-rs/foundry/issues/8604 -forgetest!(test_branch_with_calldata_reads, |prj, cmd| { +forgetest!(branch_with_calldata_reads, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -1234,7 +1234,7 @@ contract AContractTest is DSTest { "#]]); }); -forgetest!(test_identical_bytecodes, |prj, cmd| { +forgetest!(identical_bytecodes, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -1303,7 +1303,7 @@ contract AContractTest is DSTest { "#]]); }); -forgetest!(test_constructors_coverage, |prj, cmd| { +forgetest!(constructors, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -1353,9 +1353,11 @@ contract AContractTest is DSTest { "#]]); }); -// -// Test that constructor with no statements is not counted in functions coverage. -forgetest!(test_ignore_empty_constructors_coverage, |prj, cmd| { +// https://github.com/foundry-rs/foundry/issues/9270, https://github.com/foundry-rs/foundry/issues/9444 +// Test that special functions with no statements are not counted. +// TODO: We should support this, but for now just ignore them. +// See TODO in `visit_function_definition`: https://github.com/foundry-rs/foundry/issues/9458 +forgetest!(empty_functions, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -1363,6 +1365,8 @@ forgetest!(test_ignore_empty_constructors_coverage, |prj, cmd| { contract AContract { constructor() {} + receive() external payable {} + function increment() public {} } "#, @@ -1379,14 +1383,35 @@ contract AContractTest is DSTest { function test_constructors() public { AContract a = new AContract(); a.increment(); + (bool success,) = address(a).call{value: 1}(""); + require(success); } } "#, ) .unwrap(); + assert_lcov( + cmd.arg("coverage"), + str![[r#" +TN: +SF:src/AContract.sol +DA:9,1 +FN:9,9,AContract.increment +FNDA:1,AContract.increment +FNF:1 +FNH:1 +LF:1 +LH:1 +BRF:0 +BRH:0 +end_of_record + +"#]], + ); + // Assert there's only one function (`increment`) reported. - cmd.arg("coverage").assert_success().stdout_eq(str![[r#" + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| @@ -1397,7 +1422,7 @@ contract AContractTest is DSTest { }); // Test coverage for `receive` functions. -forgetest!(test_receive_coverage, |prj, cmd| { +forgetest!(receive, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", @@ -1469,9 +1494,9 @@ end_of_record "#]]); }); -// +// https://github.com/foundry-rs/foundry/issues/9322 // Test coverage with `--ir-minimum` for solidity < 0.8.5. -forgetest!(test_ir_minimum_coverage, |prj, cmd| { +forgetest!(ir_minimum_early, |prj, cmd| { prj.insert_ds_test(); prj.add_source( "AContract.sol", From e5dbb7a320c2b871c4a4a1006ad3c15a08fcf17b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Dec 2024 00:16:59 +0200 Subject: [PATCH 1754/1963] fix/feat(coverage): add --lcov-version (#9462) feat(coverage): add --lcov-version --- crates/forge/bin/cmd/coverage.rs | 44 ++++++++++++- crates/forge/src/coverage.rs | 22 +++++-- crates/forge/tests/cli/coverage.rs | 102 ++++++++++++++++++++++++++--- 3 files changed, 154 insertions(+), 14 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index d995e764df5bc..9178c27bea5fa 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -23,7 +23,7 @@ use foundry_compilers::{ }; use foundry_config::{Config, SolcReq}; use rayon::prelude::*; -use semver::Version; +use semver::{Version, VersionReq}; use std::{ io, path::{Path, PathBuf}, @@ -42,6 +42,18 @@ pub struct CoverageArgs { #[arg(long, value_enum, default_value = "summary")] report: Vec, + /// The version of the LCOV "tracefile" format to use. + /// + /// Format: `MAJOR[.MINOR]`. + /// + /// Main differences: + /// - `1.x`: The original v1 format. + /// - `2.0`: Adds support for "line end" numbers for functions. LCOV 2.1 and onwards may emit + /// an error if this option is not provided. + /// - `2.2`: Changes the format of functions. + #[arg(long, default_value = "1.16", value_parser = parse_lcov_version)] + lcov_version: Version, + /// Enable viaIR with minimum optimization /// /// This can fix most of the "stack too deep" errors while resulting a @@ -295,7 +307,7 @@ impl CoverageArgs { let path = root.join(self.report_file.as_deref().unwrap_or("lcov.info".as_ref())); let mut file = io::BufWriter::new(fs::create_file(path)?); - LcovReporter::new(&mut file).report(&report) + LcovReporter::new(&mut file, self.lcov_version.clone()).report(&report) } CoverageReportKind::Bytecode => { let destdir = root.join("bytecode-coverage"); @@ -404,3 +416,31 @@ impl BytecodeData { ) } } + +fn parse_lcov_version(s: &str) -> Result { + let vr = VersionReq::parse(&format!("={s}")).map_err(|e| e.to_string())?; + let [c] = &vr.comparators[..] else { + return Err("invalid version".to_string()); + }; + if c.op != semver::Op::Exact { + return Err("invalid version".to_string()); + } + if !c.pre.is_empty() { + return Err("pre-releases are not supported".to_string()); + } + Ok(Version::new(c.major, c.minor.unwrap_or(0), c.patch.unwrap_or(0))) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn lcov_version() { + assert_eq!(parse_lcov_version("0").unwrap(), Version::new(0, 0, 0)); + assert_eq!(parse_lcov_version("1").unwrap(), Version::new(1, 0, 0)); + assert_eq!(parse_lcov_version("1.0").unwrap(), Version::new(1, 0, 0)); + assert_eq!(parse_lcov_version("1.1").unwrap(), Version::new(1, 1, 0)); + assert_eq!(parse_lcov_version("1.11").unwrap(), Version::new(1, 11, 0)); + } +} diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index f73b17da532d7..813480b405230 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -4,6 +4,7 @@ use alloy_primitives::map::HashMap; use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Row, Table}; use evm_disassembler::disassemble_bytes; use foundry_common::fs; +use semver::Version; use std::{ collections::hash_map, io::Write, @@ -83,17 +84,19 @@ fn format_cell(hits: usize, total: usize) -> Cell { /// [tracefile format]: https://man.archlinux.org/man/geninfo.1.en#TRACEFILE_FORMAT pub struct LcovReporter<'a> { out: &'a mut (dyn Write + 'a), + version: Version, } impl<'a> LcovReporter<'a> { /// Create a new LCOV reporter. - pub fn new(out: &'a mut (dyn Write + 'a)) -> Self { - Self { out } + pub fn new(out: &'a mut (dyn Write + 'a), version: Version) -> Self { + Self { out, version } } } impl CoverageReporter for LcovReporter<'_> { fn report(self, report: &CoverageReport) -> eyre::Result<()> { + let mut fn_index = 0usize; for (path, items) in report.items_by_file() { let summary = CoverageSummary::from_items(items.iter().copied()); @@ -108,8 +111,19 @@ impl CoverageReporter for LcovReporter<'_> { match item.kind { CoverageItemKind::Function { ref name } => { let name = format!("{}.{name}", item.loc.contract_name); - writeln!(self.out, "FN:{line},{end_line},{name}")?; - writeln!(self.out, "FNDA:{hits},{name}")?; + if self.version >= Version::new(2, 2, 0) { + // v2.2 changed the FN format. + writeln!(self.out, "FNL:{fn_index},{line},{end_line}")?; + writeln!(self.out, "FNA:{fn_index},{hits},{name}")?; + fn_index += 1; + } else if self.version >= Version::new(2, 0, 0) { + // v2.0 added end_line to FN. + writeln!(self.out, "FN:{line},{end_line},{name}")?; + writeln!(self.out, "FNDA:{hits},{name}")?; + } else { + writeln!(self.out, "FN:{line},{name}")?; + writeln!(self.out, "FNDA:{hits},{name}")?; + } } CoverageItemKind::Line => { writeln!(self.out, "DA:{line},{hits}")?; diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 6ffc6c2b323ad..8c6cbc19c54c6 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -32,8 +32,52 @@ Wrote LCOV report. let lcov = prj.root().join("lcov.info"); assert!(lcov.exists(), "lcov.info was not created"); - assert_data_eq!( - Data::read_from(&lcov, None), + let default_lcov = str![[r#" +TN: +SF:script/Counter.s.sol +DA:10,0 +FN:10,CounterScript.setUp +FNDA:0,CounterScript.setUp +DA:12,0 +FN:12,CounterScript.run +FNDA:0,CounterScript.run +DA:13,0 +DA:15,0 +DA:17,0 +FNF:2 +FNH:0 +LF:5 +LH:0 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/Counter.sol +DA:7,258 +FN:7,Counter.setNumber +FNDA:258,Counter.setNumber +DA:8,258 +DA:11,1 +FN:11,Counter.increment +FNDA:1,Counter.increment +DA:12,1 +FNF:2 +FNH:2 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record + +"#]]; + assert_data_eq!(Data::read_from(&lcov, None), default_lcov.clone()); + assert_lcov( + cmd.forge_fuse().args(["coverage", "--report=lcov", "--lcov-version=1"]), + default_lcov, + ); + + assert_lcov( + cmd.forge_fuse().args(["coverage", "--report=lcov", "--lcov-version=2"]), str![[r#" TN: SF:script/Counter.s.sol @@ -71,7 +115,49 @@ BRF:0 BRH:0 end_of_record -"#]] +"#]], + ); + + assert_lcov( + cmd.forge_fuse().args(["coverage", "--report=lcov", "--lcov-version=2.2"]), + str![[r#" +TN: +SF:script/Counter.s.sol +DA:10,0 +FNL:0,10,10 +FNA:0,0,CounterScript.setUp +DA:12,0 +FNL:1,12,18 +FNA:1,0,CounterScript.run +DA:13,0 +DA:15,0 +DA:17,0 +FNF:2 +FNH:0 +LF:5 +LH:0 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/Counter.sol +DA:7,258 +FNL:2,7,9 +FNA:2,258,Counter.setNumber +DA:8,258 +DA:11,1 +FNL:3,11,13 +FNA:3,1,Counter.increment +DA:12,1 +FNF:2 +FNH:2 +LF:4 +LH:4 +BRF:0 +BRH:0 +end_of_record + +"#]], ); } @@ -432,7 +518,7 @@ contract AContractTest is DSTest { TN: SF:src/AContract.sol DA:7,1 -FN:7,9,AContract.foo +FN:7,AContract.foo FNDA:1,AContract.foo DA:8,1 FNF:1 @@ -1397,7 +1483,7 @@ contract AContractTest is DSTest { TN: SF:src/AContract.sol DA:9,1 -FN:9,9,AContract.increment +FN:9,AContract.increment FNDA:1,AContract.increment FNF:1 FNH:1 @@ -1466,11 +1552,11 @@ contract AContractTest is DSTest { TN: SF:src/AContract.sol DA:7,1 -FN:7,9,AContract.constructor +FN:7,AContract.constructor FNDA:1,AContract.constructor DA:8,1 DA:11,1 -FN:11,13,AContract.receive +FN:11,AContract.receive FNDA:1,AContract.receive DA:12,1 FNF:2 @@ -1530,5 +1616,5 @@ contract AContract { #[track_caller] fn assert_lcov(cmd: &mut TestCommand, data: impl IntoData) { - cmd.args(["--report=lcov", "--report-file"]).assert_file(data); + cmd.args(["--report=lcov", "--report-file"]).assert_file(data.into_data()); } From 7f8154c2ededd7521be50bb6498f14794c91f6ae Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Dec 2024 05:07:47 +0200 Subject: [PATCH 1755/1963] chore: set --lcov-version default to 1 (#9463) --- crates/forge/bin/cmd/coverage.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 9178c27bea5fa..753d4ec767711 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -48,10 +48,9 @@ pub struct CoverageArgs { /// /// Main differences: /// - `1.x`: The original v1 format. - /// - `2.0`: Adds support for "line end" numbers for functions. LCOV 2.1 and onwards may emit - /// an error if this option is not provided. + /// - `2.0`: Adds support for "line end" numbers for functions. /// - `2.2`: Changes the format of functions. - #[arg(long, default_value = "1.16", value_parser = parse_lcov_version)] + #[arg(long, default_value = "1", value_parser = parse_lcov_version)] lcov_version: Version, /// Enable viaIR with minimum optimization From 9af381f91e7ad10d1bd34255a3af5fad34b9573b Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:17:57 +0530 Subject: [PATCH 1756/1963] fix(`anvil`): impl `maybe_as_full_db` for `ForkedDatabase` (#9465) --- crates/anvil/src/eth/backend/mem/fork_db.rs | 12 +++++-- crates/anvil/tests/it/fork.rs | 39 +++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/fork_db.rs b/crates/anvil/src/eth/backend/mem/fork_db.rs index a4528a8f034a6..be5c3bcd7b32e 100644 --- a/crates/anvil/src/eth/backend/mem/fork_db.rs +++ b/crates/anvil/src/eth/backend/mem/fork_db.rs @@ -5,7 +5,7 @@ use crate::{ }, revm::primitives::AccountInfo, }; -use alloy_primitives::{Address, B256, U256, U64}; +use alloy_primitives::{map::HashMap, Address, B256, U256, U64}; use alloy_rpc_types::BlockId; use foundry_evm::{ backend::{ @@ -14,7 +14,7 @@ use foundry_evm::{ fork::database::ForkDbStateSnapshot, revm::{primitives::BlockEnv, Database}, }; -use revm::DatabaseRef; +use revm::{db::DbAccount, DatabaseRef}; pub use foundry_evm::fork::database::ForkedDatabase; @@ -92,6 +92,10 @@ impl MaybeFullDatabase for ForkedDatabase { self } + fn maybe_as_full_db(&self) -> Option<&HashMap> { + Some(&self.database().accounts) + } + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { let db = self.inner().db(); let accounts = std::mem::take(&mut *db.accounts.write()); @@ -127,6 +131,10 @@ impl MaybeFullDatabase for ForkDbStateSnapshot { self } + fn maybe_as_full_db(&self) -> Option<&HashMap> { + Some(&self.local.accounts) + } + fn clear_into_state_snapshot(&mut self) -> StateSnapshot { std::mem::take(&mut self.state_snapshot) } diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 3d470894b2b3f..1b664d99e6aa3 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1473,3 +1473,42 @@ async fn test_reset_dev_account_nonce() { assert!(receipt.status()); } + +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_get_account() { + let (_api, handle) = spawn(fork_config()).await; + let provider = handle.http_provider(); + + let accounts = handle.dev_accounts().collect::>(); + + let alice = accounts[0]; + let bob = accounts[1]; + + let init_block = provider.get_block_number().await.unwrap(); + let alice_bal = provider.get_balance(alice).await.unwrap(); + let alice_nonce = provider.get_transaction_count(alice).await.unwrap(); + let alice_acc_init = provider.get_account(alice).await.unwrap(); + + assert_eq!(alice_acc_init.balance, alice_bal); + assert_eq!(alice_acc_init.nonce, alice_nonce); + + let tx = TransactionRequest::default().from(alice).to(bob).value(U256::from(142)); + + let tx = WithOtherFields::new(tx); + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + assert!(receipt.status()); + assert_eq!(init_block + 1, receipt.block_number.unwrap()); + + let alice_acc = provider.get_account(alice).await.unwrap(); + + assert_eq!( + alice_acc.balance, + alice_bal - (U256::from(142) + U256::from(receipt.gas_used * receipt.effective_gas_price)), + ); + assert_eq!(alice_acc.nonce, alice_nonce + 1); + + let alice_acc_prev_block = provider.get_account(alice).number(init_block).await.unwrap(); + + assert_eq!(alice_acc_init, alice_acc_prev_block); +} From 9ee60053de47ce18ca76ff7f2da41ab026df17f9 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 3 Dec 2024 10:57:08 +0200 Subject: [PATCH 1757/1963] fix(coverage): assert should not be branch (#9467) --- crates/evm/coverage/src/analysis.rs | 3 +- crates/forge/tests/cli/coverage.rs | 58 ++++++++++++----------------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index 06673293a9b39..f8cc746c5a10e 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -372,8 +372,9 @@ impl<'a> ContractVisitor<'a> { let expr: Option = node.attribute("expression"); if let Some(NodeType::Identifier) = expr.as_ref().map(|expr| &expr.node_type) { // Might be a require call, add branch coverage. + // Asserts should not be considered branches: . let name: Option = expr.and_then(|expr| expr.attribute("name")); - if let Some("require" | "assert") = name.as_deref() { + if let Some("require") = name.as_deref() { let branch_id = self.branch_id; self.branch_id += 1; self.push_item_kind( diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 8c6cbc19c54c6..141a9677dd503 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -368,39 +368,29 @@ contract AContractTest is DSTest { ) .unwrap(); - // Assert 50% branch coverage for assert failure. + // Assert 50% statement coverage for assert failure (assert not considered a branch). cmd.arg("coverage").args(["--mt", "testAssertRevertBranch"]).assert_success().stdout_eq(str![ [r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|--------------|--------------|--------------|---------------| -| src/AContract.sol | 66.67% (2/3) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 66.67% (2/3) | 50.00% (1/2) | 50.00% (1/2) | 100.00% (1/1) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------------|--------------|--------------|---------------|---------------| +| src/AContract.sol | 66.67% (2/3) | 50.00% (1/2) | 100.00% (0/0) | 100.00% (1/1) | +| Total | 66.67% (2/3) | 50.00% (1/2) | 100.00% (0/0) | 100.00% (1/1) | "#] ]); - // Assert 50% branch coverage for proper assert. + // Assert 100% statement coverage for proper assert (assert not considered a branch). cmd.forge_fuse().arg("coverage").args(["--mt", "testAssertBranch"]).assert_success().stdout_eq( str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|--------------|---------------| -| src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | -| Total | 100.00% (3/3) | 100.00% (2/2) | 50.00% (1/2) | 100.00% (1/1) | - -"#]], - ); - - // Assert 100% coverage (assert properly covered). - cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" -... | File | % Lines | % Statements | % Branches | % Funcs | |-------------------|---------------|---------------|---------------|---------------| -| src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | -| Total | 100.00% (3/3) | 100.00% (2/2) | 100.00% (2/2) | 100.00% (1/1) | +| src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | +| Total | 100.00% (3/3) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | -"#]]); +"#]], + ); }); forgetest!(require, |prj, cmd| { @@ -753,10 +743,10 @@ contract FooTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------|----------------|----------------|----------------|---------------| -| src/Foo.sol | 91.67% (33/36) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | -| Total | 91.67% (33/36) | 90.00% (27/30) | 87.50% (14/16) | 100.00% (9/9) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|----------------|----------------|---------------|---------------| +| src/Foo.sol | 91.67% (33/36) | 90.00% (27/30) | 80.00% (8/10) | 100.00% (9/9) | +| Total | 91.67% (33/36) | 90.00% (27/30) | 80.00% (8/10) | 100.00% (9/9) | "#]]); @@ -767,10 +757,10 @@ contract FooTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... -| File | % Lines | % Statements | % Branches | % Funcs | -|-------------|----------------|----------------|----------------|---------------| -| src/Foo.sol | 97.22% (35/36) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | -| Total | 97.22% (35/36) | 96.67% (29/30) | 93.75% (15/16) | 100.00% (9/9) | +| File | % Lines | % Statements | % Branches | % Funcs | +|-------------|----------------|----------------|---------------|---------------| +| src/Foo.sol | 97.22% (35/36) | 96.67% (29/30) | 90.00% (9/10) | 100.00% (9/9) | +| Total | 97.22% (35/36) | 96.67% (29/30) | 90.00% (9/10) | 100.00% (9/9) | "#]]); @@ -779,8 +769,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|-----------------|---------------| -| src/Foo.sol | 100.00% (36/36) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | -| Total | 100.00% (36/36) | 100.00% (30/30) | 100.00% (16/16) | 100.00% (9/9) | +| src/Foo.sol | 100.00% (36/36) | 100.00% (30/30) | 100.00% (10/10) | 100.00% (9/9) | +| Total | 100.00% (36/36) | 100.00% (30/30) | 100.00% (10/10) | 100.00% (9/9) | "#]]); }); @@ -949,8 +939,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|----------------|----------------|--------------|---------------| -| src/Foo.sol | 75.00% (15/20) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | -| Total | 75.00% (15/20) | 66.67% (14/21) | 83.33% (5/6) | 100.00% (5/5) | +| src/Foo.sol | 75.00% (15/20) | 66.67% (14/21) | 75.00% (3/4) | 100.00% (5/5) | +| Total | 75.00% (15/20) | 66.67% (14/21) | 75.00% (3/4) | 100.00% (5/5) | "#]]); @@ -959,8 +949,8 @@ contract FooTest is DSTest { ... | File | % Lines | % Statements | % Branches | % Funcs | |-------------|-----------------|-----------------|---------------|---------------| -| src/Foo.sol | 100.00% (20/20) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | -| Total | 100.00% (20/20) | 100.00% (21/21) | 100.00% (6/6) | 100.00% (5/5) | +| src/Foo.sol | 100.00% (20/20) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | +| Total | 100.00% (20/20) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | "#]]); }); From ade4b35eedbab9ebe9511c7a70cd371a4b7ed2bb Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:34:19 +0530 Subject: [PATCH 1758/1963] fix(`forge`): run `dep.has_branch` in correct dir (#9453) fix(`forge`): run git cmd in correct dir --- crates/cli/src/utils/mod.rs | 10 ++++++++-- crates/forge/bin/cmd/install.rs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 6a2afe657d87e..6bf8c5b5d1628 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -444,8 +444,8 @@ impl<'a> Git<'a> { self.cmd().args(["status", "--porcelain"]).exec().map(|out| out.stdout.is_empty()) } - pub fn has_branch(self, branch: impl AsRef) -> Result { - self.cmd() + pub fn has_branch(self, branch: impl AsRef, at: &Path) -> Result { + self.cmd_at(at) .args(["branch", "--list", "--no-color"]) .arg(branch) .get_stdout_lossy() @@ -567,6 +567,12 @@ ignore them in the `.gitignore` file, or run this command again with the `--no-c cmd } + pub fn cmd_at(self, path: &Path) -> Command { + let mut cmd = Self::cmd_no_root(); + cmd.current_dir(path); + cmd + } + pub fn cmd_no_root() -> Command { let mut cmd = Command::new("git"); cmd.stdout(Stdio::piped()).stderr(Stdio::piped()); diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 2024b3d23fefc..3543caeea51b8 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -164,7 +164,7 @@ impl DependencyInstallOpts { // Pin branch to submodule if branch is used if let Some(branch) = &installed_tag { // First, check if this tag has a branch - if git.has_branch(branch)? { + if git.has_branch(branch, &path)? { // always work with relative paths when directly modifying submodules git.cmd() .args(["submodule", "set-branch", "-b", branch]) From 8ef1302dab263780dee15529c0d6c478a5aa85c8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:25:57 +0200 Subject: [PATCH 1759/1963] chore: fix test isolate (#9468) --- crates/forge/tests/cli/ext_integration.rs | 1 + crates/forge/tests/cli/script.rs | 10 +++++++--- crates/forge/tests/cli/test_cmd.rs | 13 +++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index e9437f04c9e9c..2e5e383e5bbbf 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -100,6 +100,7 @@ fn lil_web3() { #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] +#[cfg(not(feature = "isolate-by-default"))] fn snekmate() { ExtTester::new("pcaversaccio", "snekmate", "df226f4a45e86c8f8c3ff1f9fa3443d260002050") .install_command(&["pnpm", "install", "--prefer-offline"]) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index e52bd2fef4a70..6f5193c532e8f 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1923,6 +1923,10 @@ contract SimpleScript is Script { // Asserts that the script runs with expected non-output using `--quiet` flag forgetest_async!(adheres_to_json_flag, |prj, cmd| { + if cfg!(feature = "isolate-by-default") { + return; + } + foundry_test_utils::util::initialize(prj.root()); prj.add_script( "Foo", @@ -2367,12 +2371,12 @@ contract SimpleScript is Script { [SOLC_VERSION] [ELAPSED] Compiler run successful! Traces: - [103771] SimpleScript::run() + [..] SimpleScript::run() ├─ [0] VM::startBroadcast() │ └─ ← [Return] - ├─ [23273] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 + ├─ [..] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 │ └─ ← [Return] 116 bytes of code - ├─ [13162] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 + ├─ [..] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 │ ├─ [145] A::getValue() [staticcall] │ │ └─ ← [Return] 100 │ └─ ← [Return] 62 bytes of code diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 819c3e9407e0b..b24ebea666738 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2357,10 +2357,10 @@ Compiler run successful! Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest [PASS] test_proxy_trace() ([GAS]) Traces: - [149783] MetadataTraceTest::test_proxy_trace() - ├─ [47297] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + [..] MetadataTraceTest::test_proxy_trace() + ├─ [..] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 236 bytes of code - ├─ [37762] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b + ├─ [..] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b │ └─ ← [Return] 62 bytes of code └─ ← [Stop] @@ -2382,10 +2382,10 @@ Compiler run successful! Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest [PASS] test_proxy_trace() ([GAS]) Traces: - [128142] MetadataTraceTest::test_proxy_trace() - ├─ [36485] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + [..] MetadataTraceTest::test_proxy_trace() + ├─ [..] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 182 bytes of code - ├─ [26959] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b + ├─ [..] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b │ └─ ← [Return] 8 bytes of code └─ ← [Stop] @@ -2667,6 +2667,7 @@ Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] }); // Tests that test traces display state changes when running with verbosity. +#[cfg(not(feature = "isolate-by-default"))] forgetest_init!(should_show_state_changes, |prj, cmd| { cmd.args(["test", "--mt", "test_Increment", "-vvvvv"]).assert_success().stdout_eq(str![[r#" ... From 2f56133ce2e7d0d0d8b1488c2784dbd799d01e16 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Dec 2024 19:54:26 +0100 Subject: [PATCH 1760/1963] feat: bump MSRV to 1.83 (#9473) --- Cargo.toml | 2 +- clippy.toml | 2 +- crates/cheatcodes/src/evm/mock.rs | 2 +- crates/cheatcodes/src/inspector.rs | 9 ++++----- crates/evm/evm/src/executors/mod.rs | 2 +- crates/evm/traces/src/debug/sources.rs | 2 +- crates/fmt/src/comments.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 2 +- crates/script/src/build.rs | 4 ++-- crates/script/src/lib.rs | 2 +- crates/verify/src/provider.rs | 2 +- 11 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a4d8f2724b103..af1d118b9fe84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ resolver = "2" version = "0.2.0" edition = "2021" # Remember to update clippy.toml as well -rust-version = "1.80" +rust-version = "1.83" authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" diff --git a/clippy.toml b/clippy.toml index b1756dfd9beff..8581063b6ce99 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,4 +1,4 @@ -msrv = "1.80" +msrv = "1.83" # bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, # so it is safe to ignore it as well ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] diff --git a/crates/cheatcodes/src/evm/mock.rs b/crates/cheatcodes/src/evm/mock.rs index 26aae298fa64d..fcfea7a9ce87c 100644 --- a/crates/cheatcodes/src/evm/mock.rs +++ b/crates/cheatcodes/src/evm/mock.rs @@ -213,7 +213,7 @@ fn mock_calls( fn make_acc_non_empty(callee: &Address, ecx: InnerEcx) -> Result { let acc = ecx.load_account(*callee)?; - let empty_bytecode = acc.info.code.as_ref().map_or(true, Bytecode::is_empty); + let empty_bytecode = acc.info.code.as_ref().is_none_or(Bytecode::is_empty); if empty_bytecode { let code = Bytecode::new_raw(Bytes::from_static(&[0u8])); ecx.journaled_state.set_code(*callee, code); diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index ac8058dd9f996..4e2b91b9dd2d6 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -902,12 +902,11 @@ where { *calldata == call.input[..calldata.len()] && // The value matches, if provided expected - .value - .map_or(true, |value| Some(value) == call.transfer_value()) && + .value.is_none_or(|value| Some(value) == call.transfer_value()) && // The gas matches, if provided - expected.gas.map_or(true, |gas| gas == call.gas_limit) && + expected.gas.is_none_or(|gas| gas == call.gas_limit) && // The minimum gas matches, if provided - expected.min_gas.map_or(true, |min_gas| min_gas <= call.gas_limit) + expected.min_gas.is_none_or(|min_gas| min_gas <= call.gas_limit) { *actual_count += 1; } @@ -925,7 +924,7 @@ where { .iter_mut() .find(|(mock, _)| { call.input.get(..mock.calldata.len()) == Some(&mock.calldata[..]) && - mock.value.map_or(true, |value| Some(value) == call.transfer_value()) + mock.value.is_none_or(|value| Some(value) == call.transfer_value()) }) .map(|(_, v)| v), } { diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 8560c3e10f957..e70df0e164a28 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -203,7 +203,7 @@ impl Executor { .ok_or_else(|| BackendError::MissingAccount(DEFAULT_CREATE2_DEPLOYER))?; // If the deployer is not currently deployed, deploy the default one. - if create2_deployer_account.code.map_or(true, |code| code.is_empty()) { + if create2_deployer_account.code.is_none_or(|code| code.is_empty()) { let creator = DEFAULT_CREATE2_DEPLOYER_DEPLOYER; // Probably 0, but just in case. diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index ff1911493baa1..f934be61f00b9 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -88,7 +88,7 @@ impl ArtifactData { fn new(bytecode: ContractBytecodeSome, build_id: String, file_id: u32) -> Result { let parse = |b: &Bytecode, name: &str| { // Only parse source map if it's not empty. - let source_map = if b.source_map.as_ref().map_or(true, |s| s.is_empty()) { + let source_map = if b.source_map.as_ref().is_none_or(|s| s.is_empty()) { Ok(None) } else { b.source_map().transpose().wrap_err_with(|| { diff --git a/crates/fmt/src/comments.rs b/crates/fmt/src/comments.rs index e3fb79043ec68..eafdb998910d9 100644 --- a/crates/fmt/src/comments.rs +++ b/crates/fmt/src/comments.rs @@ -88,7 +88,7 @@ impl CommentWithMetadata { return Self::new( comment, CommentPosition::Prefix, - last_line.map_or(true, str::is_empty), + last_line.is_none_or(str::is_empty), indent_len, ) } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 753d4ec767711..c3d0545c28d99 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -293,7 +293,7 @@ impl CoverageArgs { let file_pattern = filter.args().coverage_pattern_inverse.as_ref(); let file_root = &filter.paths().root; report.filter_out_ignored_sources(|path: &Path| { - file_pattern.map_or(true, |re| { + file_pattern.is_none_or(|re| { !re.is_match(&path.strip_prefix(file_root).unwrap_or(path).to_string_lossy()) }) }); diff --git a/crates/script/src/build.rs b/crates/script/src/build.rs index 052e78e10781a..4824cee6b8140 100644 --- a/crates/script/src/build.rs +++ b/crates/script/src/build.rs @@ -199,8 +199,8 @@ impl PreprocessedState { if id.name != *name { continue; } - } else if contract.abi.as_ref().map_or(true, |abi| abi.is_empty()) || - contract.bytecode.as_ref().map_or(true, |b| match &b.object { + } else if contract.abi.as_ref().is_none_or(|abi| abi.is_empty()) || + contract.bytecode.as_ref().is_none_or(|b| match &b.object { BytecodeObject::Bytecode(b) => b.is_empty(), BytecodeObject::Unlinked(_) => false, }) diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 5f5543912fe2a..7aa18dcbe5c78 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -278,7 +278,7 @@ impl ScriptArgs { .execution_result .transactions .as_ref() - .map_or(true, |txs| txs.is_empty()) + .is_none_or(|txs| txs.is_empty()) { return Ok(()); } diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index ab6c5e9f642ff..9c619239b6d67 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -172,7 +172,7 @@ impl VerificationProviderType { pub fn client(&self, key: &Option) -> Result> { match self { Self::Etherscan => { - if key.as_ref().map_or(true, |key| key.is_empty()) { + if key.as_ref().is_none_or(|key| key.is_empty()) { eyre::bail!("ETHERSCAN_API_KEY must be set") } Ok(Box::::default()) From 22202a7a2b3abed5ff74a226dfed790197ac7723 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:10:44 +0100 Subject: [PATCH 1761/1963] perf(coverage): cache current HitMap, reserve when merging (#9469) * perf(coverage): cache current HitMap, reserve when merging * test: shuffle RPC env --- crates/evm/coverage/src/inspector.rs | 76 +++++++++++++++++++++++----- crates/evm/coverage/src/lib.rs | 31 ++++++++++-- 2 files changed, 91 insertions(+), 16 deletions(-) diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index 07c24ae9e5ef4..eeea3900c0d91 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -1,25 +1,40 @@ use crate::{HitMap, HitMaps}; use alloy_primitives::B256; use revm::{interpreter::Interpreter, Database, EvmContext, Inspector}; +use std::ptr::NonNull; /// Inspector implementation for collecting coverage information. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct CoverageCollector { + current_map: NonNull, + current_hash: B256, maps: HitMaps, } +// SAFETY: `current_map` is always valid and points into an allocation managed by self. +unsafe impl Send for CoverageCollector {} +unsafe impl Sync for CoverageCollector {} + +impl Default for CoverageCollector { + fn default() -> Self { + Self { + current_map: NonNull::dangling(), + current_hash: B256::ZERO, + maps: Default::default(), + } + } +} + impl Inspector for CoverageCollector { fn initialize_interp(&mut self, interpreter: &mut Interpreter, _context: &mut EvmContext) { - self.maps - .entry(*get_contract_hash(interpreter)) - .or_insert_with(|| HitMap::new(interpreter.contract.bytecode.original_bytes())); + get_or_insert_contract_hash(interpreter); + self.insert_map(interpreter); } #[inline] fn step(&mut self, interpreter: &mut Interpreter, _context: &mut EvmContext) { - if let Some(map) = self.maps.get_mut(get_contract_hash(interpreter)) { - map.hit(interpreter.program_counter()); - } + let map = self.get_or_insert_map(interpreter); + map.hit(interpreter.program_counter()); } } @@ -28,15 +43,50 @@ impl CoverageCollector { pub fn finish(self) -> HitMaps { self.maps } + + #[inline] + fn get_or_insert_map(&mut self, interpreter: &mut Interpreter) -> &mut HitMap { + let hash = get_or_insert_contract_hash(interpreter); + if self.current_hash != *hash { + self.insert_map(interpreter); + } + unsafe { self.current_map.as_mut() } + } + + #[cold] + #[inline(never)] + fn insert_map(&mut self, interpreter: &Interpreter) { + let Some(hash) = interpreter.contract.hash else { eof_panic() }; + self.current_hash = hash; + self.current_map = self + .maps + .entry(hash) + .or_insert_with(|| HitMap::new(interpreter.contract.bytecode.original_bytes())) + .into(); + } } /// Helper function for extracting contract hash used to record coverage hit map. -/// If contract hash available in interpreter contract is zero (contract not yet created but going -/// to be created in current tx) then it hash is calculated from contract bytecode. -fn get_contract_hash(interpreter: &mut Interpreter) -> &B256 { - let hash = interpreter.contract.hash.as_mut().expect("coverage does not support EOF"); - if *hash == B256::ZERO { - *hash = interpreter.contract.bytecode.hash_slow(); +/// +/// If the contract hash is zero (contract not yet created but it's going to be created in current +/// tx) then the hash is calculated from the bytecode. +#[inline] +fn get_or_insert_contract_hash(interpreter: &mut Interpreter) -> &B256 { + let Some(hash) = interpreter.contract.hash.as_mut() else { eof_panic() }; + if hash.is_zero() { + set_contract_hash(hash, &interpreter.contract.bytecode); } hash } + +#[cold] +#[inline(never)] +fn set_contract_hash(hash: &mut B256, bytecode: &revm::primitives::Bytecode) { + *hash = bytecode.hash_slow(); +} + +#[cold] +#[inline(never)] +fn eof_panic() -> ! { + panic!("coverage does not support EOF"); +} diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 345261ad5b2c4..52ec329add140 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -174,6 +174,7 @@ impl HitMaps { /// Merges two `HitMaps`. pub fn merge(&mut self, other: Self) { + self.reserve(other.len()); for (code_hash, other) in other.0 { self.entry(code_hash).and_modify(|e| e.merge(&other)).or_insert(other); } @@ -211,37 +212,61 @@ pub struct HitMap { impl HitMap { /// Create a new hitmap with the given bytecode. + #[inline] pub fn new(bytecode: Bytes) -> Self { - Self { bytecode, hits: Default::default() } + Self { bytecode, hits: HashMap::with_capacity_and_hasher(1024, Default::default()) } } /// Returns the bytecode. + #[inline] pub fn bytecode(&self) -> &Bytes { &self.bytecode } /// Returns the number of hits for the given program counter. + #[inline] pub fn get(&self, pc: usize) -> Option { NonZeroU32::new(self.hits.get(&Self::cvt_pc(pc)).copied().unwrap_or(0)) } /// Increase the hit counter by 1 for the given program counter. + #[inline] pub fn hit(&mut self, pc: usize) { self.hits(pc, 1) } /// Increase the hit counter by `hits` for the given program counter. + #[inline] pub fn hits(&mut self, pc: usize, hits: u32) { *self.hits.entry(Self::cvt_pc(pc)).or_default() += hits; } /// Merge another hitmap into this, assuming the bytecode is consistent pub fn merge(&mut self, other: &Self) { - for (&pc, &hits) in &other.hits { - self.hits(pc as usize, hits); + self.hits.reserve(other.len()); + for (pc, hits) in other.iter() { + self.hits(pc, hits); } } + /// Returns an iterator over all the program counters and their hit counts. + #[inline] + pub fn iter(&self) -> impl Iterator + '_ { + self.hits.iter().map(|(&pc, &hits)| (pc as usize, hits)) + } + + /// Returns the number of program counters hit in the hitmap. + #[inline] + pub fn len(&self) -> usize { + self.hits.len() + } + + /// Returns `true` if the hitmap is empty. + #[inline] + pub fn is_empty(&self) -> bool { + self.hits.is_empty() + } + #[inline] fn cvt_pc(pc: usize) -> u32 { pc.try_into().expect("4GiB bytecode") From f9d86632972c5ce8144014a864119fe937881971 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:16:17 +0100 Subject: [PATCH 1762/1963] test: shuffle archive URLs (#9472) * test: shuffle archive URLs * fmt * chore: clippy * print --- crates/anvil/tests/it/fork.rs | 9 +- crates/forge/tests/cli/script.rs | 9 +- crates/forge/tests/cli/test_cmd.rs | 6 +- crates/forge/tests/cli/verify_bytecode.rs | 6 +- crates/forge/tests/it/fork.rs | 4 +- crates/test-utils/src/lib.rs | 1 + crates/test-utils/src/rpc.rs | 110 +++++++++++++++++----- crates/test-utils/src/util.rs | 2 +- 8 files changed, 102 insertions(+), 45 deletions(-) diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 1b664d99e6aa3..8e7736b0df364 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -55,7 +55,7 @@ impl LocalFork { pub fn fork_config() -> NodeConfig { NodeConfig::test() - .with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())) + .with_eth_rpc_url(Some(rpc::next_http_archive_rpc_url())) .with_fork_block_number(Some(BLOCK_NUMBER)) } @@ -287,7 +287,7 @@ async fn test_fork_reset_setup() { assert_eq!(local_balance, U256::ZERO); api.anvil_reset(Some(Forking { - json_rpc_url: Some(rpc::next_http_archive_rpc_endpoint()), + json_rpc_url: Some(rpc::next_http_archive_rpc_url()), block_number: Some(BLOCK_NUMBER), })) .await @@ -829,8 +829,7 @@ async fn test_fork_init_base_fee() { #[tokio::test(flavor = "multi_thread")] async fn test_reset_fork_on_new_blocks() { let (api, handle) = - spawn(NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint()))) - .await; + spawn(NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_url()))).await; let anvil_provider = handle.http_provider(); let endpoint = next_http_rpc_endpoint(); @@ -864,7 +863,7 @@ async fn test_fork_call() { let to: Address = "0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc".parse().unwrap(); let block_number = 14746300u64; - let provider = http_provider(rpc::next_http_archive_rpc_endpoint().as_str()); + let provider = http_provider(rpc::next_http_archive_rpc_url().as_str()); let tx = TransactionRequest::default().to(to).with_input(input.clone()); let tx = WithOtherFields::new(tx); let res0 = provider.call(&tx).block(BlockId::Number(block_number.into())).await.unwrap(); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 6f5193c532e8f..e40db2b81f396 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -200,8 +200,7 @@ contract DeployScript is Script { let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; - let node_config = - NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())); + let node_config = NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_url())); let (_api, handle) = spawn(node_config).await; let dev = handle.dev_accounts().next().unwrap(); cmd.set_current_dir(prj.root()); @@ -302,8 +301,7 @@ contract DeployScript is Script { let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; - let node_config = - NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())); + let node_config = NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_url())); let (_api, handle) = spawn(node_config).await; let private_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); @@ -492,8 +490,7 @@ contract DeployScript is Script { let deploy_contract = deploy_script.display().to_string() + ":DeployScript"; - let node_config = - NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_endpoint())); + let node_config = NodeConfig::test().with_eth_rpc_url(Some(rpc::next_http_archive_rpc_url())); let (_api, handle) = spawn(node_config).await; let private_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index b24ebea666738..7e568af0c5d88 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -473,7 +473,7 @@ contract Contract { ) .unwrap(); - let endpoint = rpc::next_http_archive_rpc_endpoint(); + let endpoint = rpc::next_http_archive_rpc_url(); prj.add_test( "Contract.t.sol", @@ -545,7 +545,7 @@ forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| { forgetest_init!(fork_traces, |prj, cmd| { prj.wipe_contracts(); - let endpoint = rpc::next_http_archive_rpc_endpoint(); + let endpoint = rpc::next_http_archive_rpc_url(); prj.add_test( "Contract.t.sol", @@ -699,7 +699,7 @@ contract TransientTest is Test { forgetest_init!(can_disable_block_gas_limit, |prj, cmd| { prj.wipe_contracts(); - let endpoint = rpc::next_http_archive_rpc_endpoint(); + let endpoint = rpc::next_http_archive_rpc_url(); prj.add_test( "Contract.t.sol", diff --git a/crates/forge/tests/cli/verify_bytecode.rs b/crates/forge/tests/cli/verify_bytecode.rs index 398ecb52d353f..6e89f1e940f7c 100644 --- a/crates/forge/tests/cli/verify_bytecode.rs +++ b/crates/forge/tests/cli/verify_bytecode.rs @@ -2,7 +2,7 @@ use foundry_compilers::artifacts::{BytecodeHash, EvmVersion}; use foundry_config::Config; use foundry_test_utils::{ forgetest_async, - rpc::{next_http_archive_rpc_endpoint, next_mainnet_etherscan_api_key}, + rpc::{next_http_archive_rpc_url, next_mainnet_etherscan_api_key}, util::OutputExt, TestCommand, TestProject, }; @@ -20,7 +20,7 @@ fn test_verify_bytecode( expected_matches: (&str, &str), ) { let etherscan_key = next_mainnet_etherscan_api_key(); - let rpc_url = next_http_archive_rpc_endpoint(); + let rpc_url = next_http_archive_rpc_url(); // fetch and flatten source code let source_code = cmd @@ -75,7 +75,7 @@ fn test_verify_bytecode_with_ignore( chain: &str, ) { let etherscan_key = next_mainnet_etherscan_api_key(); - let rpc_url = next_http_archive_rpc_endpoint(); + let rpc_url = next_http_archive_rpc_url(); // fetch and flatten source code let source_code = cmd diff --git a/crates/forge/tests/it/fork.rs b/crates/forge/tests/it/fork.rs index 5974a12ed644c..d84309275e393 100644 --- a/crates/forge/tests/it/fork.rs +++ b/crates/forge/tests/it/fork.rs @@ -68,7 +68,7 @@ async fn test_rpc_fork() { /// Tests that we can launch in forking mode #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork() { - let rpc_url = foundry_test_utils::rpc::next_http_archive_rpc_endpoint(); + let rpc_url = foundry_test_utils::rpc::next_http_archive_rpc_url(); let runner = TEST_DATA_DEFAULT.forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; @@ -77,7 +77,7 @@ async fn test_launch_fork() { /// Smoke test that forking workings with websockets #[tokio::test(flavor = "multi_thread")] async fn test_launch_fork_ws() { - let rpc_url = foundry_test_utils::rpc::next_ws_archive_rpc_endpoint(); + let rpc_url = foundry_test_utils::rpc::next_ws_archive_rpc_url(); let runner = TEST_DATA_DEFAULT.forked_runner(&rpc_url).await; let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Launch")); TestConfig::with_filter(runner, filter).run().await; diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 9d4316b419649..e51e911f32b2d 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -4,6 +4,7 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![allow(clippy::disallowed_macros)] #[macro_use] extern crate foundry_common; diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index 361bf56c2706e..ed0dfaa3c4a42 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -101,53 +101,109 @@ fn next(list: &[T]) -> &T { &list[next_idx() % list.len()] } -/// Returns the next _mainnet_ rpc endpoint in inline +/// Returns the next _mainnet_ rpc URL in inline /// /// This will rotate all available rpc endpoints pub fn next_http_rpc_endpoint() -> String { next_rpc_endpoint(NamedChain::Mainnet) } -/// Returns the next _mainnet_ rpc endpoint in inline +/// Returns the next _mainnet_ rpc URL in inline /// /// This will rotate all available rpc endpoints pub fn next_ws_rpc_endpoint() -> String { next_ws_endpoint(NamedChain::Mainnet) } -/// Returns the next HTTP RPC endpoint. +/// Returns the next HTTP RPC URL. pub fn next_rpc_endpoint(chain: NamedChain) -> String { next_url(false, chain) } -/// Returns the next WS RPC endpoint. +/// Returns the next WS RPC URL. pub fn next_ws_endpoint(chain: NamedChain) -> String { next_url(true, chain) } -/// Returns endpoint that has access to archive state -pub fn next_http_archive_rpc_endpoint() -> String { - next_archive_endpoint(false) +/// Returns a websocket URL that has access to archive state +pub fn next_http_archive_rpc_url() -> String { + next_archive_url(false) } -/// Returns endpoint that has access to archive state -pub fn next_ws_archive_rpc_endpoint() -> String { - next_archive_endpoint(true) +/// Returns an HTTP URL that has access to archive state +pub fn next_ws_archive_rpc_url() -> String { + next_archive_url(true) } -/// Returns endpoint that has access to archive state, http or ws. -/// Use env vars (comma separated urls) or default inline keys (Alchemy for ws, Infura for http). -fn next_archive_endpoint(is_ws: bool) -> String { - let env_urls = if is_ws { ENV_WS_ARCHIVE_ENDPOINTS } else { ENV_HTTP_ARCHIVE_ENDPOINTS }; - - let rpc_env_vars = env::var(env_urls).unwrap_or_default(); - if !rpc_env_vars.is_empty() { - let urls = rpc_env_vars.split(',').collect::>(); - next(&urls).to_string() - } else if is_ws { - format!("wss://eth-mainnet.g.alchemy.com/v2/{}", next(&ALCHEMY_KEYS)) +/// Returns a URL that has access to archive state. +/// +/// Uses either environment variables (comma separated urls) or default keys. +fn next_archive_url(is_ws: bool) -> String { + let urls = archive_urls(is_ws); + let url = if env_archive_urls(is_ws).is_empty() { + next(urls) } else { - format!("https://eth-mainnet.g.alchemy.com/v2/{}", next(&ALCHEMY_KEYS)) + urls.choose_weighted(&mut rand::thread_rng(), |url| { + if url.contains("reth") { + 2usize + } else { + 1usize + } + }) + .unwrap() + }; + eprintln!("--- next_archive_url(is_ws={is_ws}) = {url} ---"); + url.clone() +} + +fn archive_urls(is_ws: bool) -> &'static [String] { + static WS: LazyLock> = LazyLock::new(|| get(true)); + static HTTP: LazyLock> = LazyLock::new(|| get(false)); + + fn get(is_ws: bool) -> Vec { + let env_urls = env_archive_urls(is_ws); + if !env_urls.is_empty() { + let mut urls = env_urls.to_vec(); + urls.shuffle(&mut rand::thread_rng()); + return urls; + } + + let mut urls = Vec::new(); + for &key in ALCHEMY_KEYS.iter() { + if is_ws { + urls.push(format!("wss://eth-mainnet.g.alchemy.com/v2/{key}")); + } else { + urls.push(format!("https://eth-mainnet.g.alchemy.com/v2/{key}")); + } + } + urls + } + + if is_ws { + &WS + } else { + &HTTP + } +} + +fn env_archive_urls(is_ws: bool) -> &'static [String] { + static WS: LazyLock> = LazyLock::new(|| get(true)); + static HTTP: LazyLock> = LazyLock::new(|| get(false)); + + fn get(is_ws: bool) -> Vec { + let env = if is_ws { ENV_WS_ARCHIVE_ENDPOINTS } else { ENV_HTTP_ARCHIVE_ENDPOINTS }; + let env = env::var(env).unwrap_or_default(); + let env = env.trim(); + if env.is_empty() { + return vec![]; + } + env.split(',').map(str::trim).filter(|s| !s.is_empty()).map(ToString::to_string).collect() + } + + if is_ws { + &WS + } else { + &HTTP } } @@ -162,7 +218,9 @@ pub fn next_etherscan_api_key(chain: NamedChain) -> String { Optimism => ÐERSCAN_OPTIMISM_KEYS, _ => ÐERSCAN_MAINNET_KEYS, }; - next(keys).to_string() + let key = next(keys).to_string(); + eprintln!("--- next_etherscan_api_key(chain={chain:?}) = {key} ---"); + key } fn next_url(is_ws: bool, chain: NamedChain) -> String { @@ -206,12 +264,14 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { }; let full = if prefix.is_empty() { network.to_string() } else { format!("{prefix}-{network}") }; - match (is_ws, is_infura) { + let url = match (is_ws, is_infura) { (false, true) => format!("https://{full}.infura.io/v3/{key}"), (true, true) => format!("wss://{full}.infura.io/ws/v3/{key}"), (false, false) => format!("https://{full}.g.alchemy.com/v2/{key}"), (true, false) => format!("wss://{full}.g.alchemy.com/v2/{key}"), - } + }; + eprintln!("--- next_url(is_ws={is_ws}, chain={chain:?}) = {url} ---"); + url } #[cfg(test)] diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index a86304923ffef..fb9eca587f4bc 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -202,7 +202,7 @@ impl ExtTester { test_cmd.envs(self.envs.iter().map(|(k, v)| (k, v))); if let Some(fork_block) = self.fork_block { - test_cmd.env("FOUNDRY_ETH_RPC_URL", crate::rpc::next_http_archive_rpc_endpoint()); + test_cmd.env("FOUNDRY_ETH_RPC_URL", crate::rpc::next_http_archive_rpc_url()); test_cmd.env("FOUNDRY_FORK_BLOCK_NUMBER", fork_block.to_string()); } test_cmd.env("FOUNDRY_INVARIANT_DEPTH", "15"); From 805d7cee81e78e9163b8ce3d86a0c3beb39772d4 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:35:56 +0100 Subject: [PATCH 1763/1963] docs: CoverageCollector comments (#9474) --- crates/evm/coverage/src/inspector.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index eeea3900c0d91..bc3a40e5638b4 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -6,12 +6,16 @@ use std::ptr::NonNull; /// Inspector implementation for collecting coverage information. #[derive(Clone, Debug)] pub struct CoverageCollector { + // NOTE: `current_map` is always a valid reference into `maps`. + // It is accessed only through `get_or_insert_map` which guarantees that it's valid. + // Both of these fields are unsafe to access directly outside of `*insert_map`. current_map: NonNull, current_hash: B256, + maps: HitMaps, } -// SAFETY: `current_map` is always valid and points into an allocation managed by self. +// SAFETY: See comments on `current_map`. unsafe impl Send for CoverageCollector {} unsafe impl Sync for CoverageCollector {} @@ -44,12 +48,17 @@ impl CoverageCollector { self.maps } + /// Gets the hit map for the current contract, or inserts a new one if it doesn't exist. + /// + /// The map is stored in `current_map` and returned as a mutable reference. + /// See comments on `current_map` for more details. #[inline] fn get_or_insert_map(&mut self, interpreter: &mut Interpreter) -> &mut HitMap { let hash = get_or_insert_contract_hash(interpreter); if self.current_hash != *hash { self.insert_map(interpreter); } + // SAFETY: See comments on `current_map`. unsafe { self.current_map.as_mut() } } @@ -58,6 +67,7 @@ impl CoverageCollector { fn insert_map(&mut self, interpreter: &Interpreter) { let Some(hash) = interpreter.contract.hash else { eof_panic() }; self.current_hash = hash; + // Converts the mutable reference to a `NonNull` pointer. self.current_map = self .maps .entry(hash) From 3a1e76b504348e3fd90196e445fc04934f05680c Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:34:43 +0530 Subject: [PATCH 1764/1963] fix(`cli`): handle id and named chain_id's correctly (#9480) * fix(`cli`): handle id and named chain_id's correctly * test --- crates/cast/tests/cli/main.rs | 19 +++++++++++++++++++ crates/cli/src/opts/ethereum.rs | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index cd833f7c3ed94..fe9309877b6aa 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1955,3 +1955,22 @@ Transaction successfully executed. "#]]); }); + +// https://github.com/foundry-rs/foundry/issues/9476 +forgetest_async!(cast_call_custom_chain_id, |_prj, cmd| { + let chain_id = 55555u64; + let (_api, handle) = anvil::spawn(NodeConfig::test().with_chain_id(Some(chain_id))).await; + + let http_endpoint = handle.http_endpoint(); + + cmd.cast_fuse() + .args([ + "call", + "5FbDB2315678afecb367f032d93F642f64180aa3", + "--rpc-url", + &http_endpoint, + "--chain", + &chain_id.to_string(), + ]) + .assert_success(); +}); diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 4b15b8551940f..8d2601be16381 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -1,4 +1,5 @@ use crate::opts::ChainValueParser; +use alloy_chains::ChainKind; use clap::Parser; use eyre::Result; use foundry_config::{ @@ -154,7 +155,11 @@ impl EtherscanOpts { dict.insert("etherscan_api_key".into(), key.into()); } if let Some(chain) = self.chain { - dict.insert("chain_id".into(), chain.to_string().into()); + if let ChainKind::Id(id) = chain.kind() { + dict.insert("chain_id".into(), (*id).into()); + } else { + dict.insert("chain_id".into(), chain.to_string().into()); + } } dict } From 8ac30d9c7ebeab1b50d98b56f6b5e623e7cdbf83 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:08:20 +0100 Subject: [PATCH 1765/1963] feat: dedup error messages (#9481) --- crates/cast/bin/cmd/send.rs | 2 +- crates/cheatcodes/src/error.rs | 16 +------------ crates/common/src/errors/mod.rs | 35 +++++++++++++++++++++++++++++ crates/evm/core/src/backend/cow.rs | 2 +- crates/evm/core/src/backend/mod.rs | 9 +------- crates/evm/core/src/opts.rs | 7 +++--- crates/evm/evm/src/executors/mod.rs | 18 +++++---------- crates/forge/tests/cli/script.rs | 27 ---------------------- crates/forge/tests/cli/test_cmd.rs | 26 ++++++++++++++++++++- 9 files changed, 74 insertions(+), 68 deletions(-) diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 77b6a2cddae56..0af83da1ae58d 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -85,7 +85,7 @@ pub enum SendTxSubcommands { impl SendTxArgs { #[allow(unknown_lints, dependency_on_unit_never_type_fallback)] - pub async fn run(self) -> Result<(), eyre::Report> { + pub async fn run(self) -> eyre::Result<()> { let Self { eth, to, diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index d459e9274bb22..c2c220edfed32 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -206,7 +206,6 @@ impl Error { } impl Drop for Error { - #[inline] fn drop(&mut self) { if self.drop { drop(unsafe { Box::<[u8]>::from_raw(self.data.cast_mut()) }); @@ -224,21 +223,18 @@ impl From> for Error { } impl From for Error { - #[inline] fn from(value: String) -> Self { Self::new_string(value) } } impl From<&'static str> for Error { - #[inline] fn from(value: &'static str) -> Self { Self::new_str(value) } } impl From> for Error { - #[inline] fn from(value: Cow<'static, [u8]>) -> Self { match value { Cow::Borrowed(bytes) => Self::new_bytes(bytes), @@ -248,21 +244,18 @@ impl From> for Error { } impl From<&'static [u8]> for Error { - #[inline] fn from(value: &'static [u8]) -> Self { Self::new_bytes(value) } } impl From<&'static [u8; N]> for Error { - #[inline] fn from(value: &'static [u8; N]) -> Self { Self::new_bytes(value) } } impl From> for Error { - #[inline] fn from(value: Vec) -> Self { Self::new_vec(value) } @@ -279,7 +272,6 @@ impl From for Error { macro_rules! impl_from { ($($t:ty),* $(,)?) => {$( impl From<$t> for Error { - #[inline] fn from(value: $t) -> Self { Self::display(value) } @@ -309,20 +301,14 @@ impl_from!( ); impl> From> for Error { - #[inline] fn from(err: EVMError) -> Self { Self::display(BackendError::from(err)) } } impl From for Error { - #[inline] fn from(err: eyre::Report) -> Self { - let mut chained_cause = String::new(); - for cause in err.chain() { - chained_cause.push_str(format!(" {cause};").as_str()); - } - Self::display(chained_cause) + Self::from(foundry_common::errors::display_chain(&err)) } } diff --git a/crates/common/src/errors/mod.rs b/crates/common/src/errors/mod.rs index cfd9a307ea461..c8b2c6bcc0239 100644 --- a/crates/common/src/errors/mod.rs +++ b/crates/common/src/errors/mod.rs @@ -5,3 +5,38 @@ pub use fs::FsPathError; mod artifacts; pub use artifacts::*; + +/// Displays a chain of errors in a single line. +pub fn display_chain(error: &eyre::Report) -> String { + let mut causes = all_sources(error); + // Deduplicate the common pattern `msg1: msg2; msg2` -> `msg1: msg2`. + causes.dedup_by(|b, a| a.contains(b.as_str())); + causes.join("; ") +} + +fn all_sources(err: &eyre::Report) -> Vec { + err.chain().map(|cause| cause.to_string().trim().to_string()).collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn dedups_contained() { + #[derive(thiserror::Error, Debug)] + #[error("my error: {0}")] + struct A(#[from] B); + + #[derive(thiserror::Error, Debug)] + #[error("{0}")] + struct B(String); + + let ee = eyre::Report::from(A(B("hello".into()))); + assert_eq!(ee.chain().count(), 2, "{ee:?}"); + let full = all_sources(&ee).join("; "); + assert_eq!(full, "my error: hello; hello"); + let chained = display_chain(&ee); + assert_eq!(chained, "my error: hello"); + } +} diff --git a/crates/evm/core/src/backend/cow.rs b/crates/evm/core/src/backend/cow.rs index 8623ca2f98ea0..3ffb9fc84f3cd 100644 --- a/crates/evm/core/src/backend/cow.rs +++ b/crates/evm/core/src/backend/cow.rs @@ -73,7 +73,7 @@ impl<'a> CowBackend<'a> { self.spec_id = env.handler_cfg.spec_id; let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); - let res = evm.transact().wrap_err("backend: failed while inspecting")?; + let res = evm.transact().wrap_err("EVM error")?; env.env = evm.context.evm.inner.env; diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 2db34ad290b0b..cf6e7e8beb0bc 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -7,7 +7,6 @@ use crate::{ utils::{configure_tx_env, configure_tx_req_env, new_evm_with_inspector}, InspectorExt, }; -use alloy_consensus::Transaction as TransactionTrait; use alloy_genesis::GenesisAccount; use alloy_network::{AnyRpcBlock, AnyTxEnvelope, TransactionResponse}; use alloy_primitives::{keccak256, uint, Address, TxKind, B256, U256}; @@ -771,7 +770,7 @@ impl Backend { self.initialize(env); let mut evm = crate::utils::new_evm_with_inspector(self, env.clone(), inspector); - let res = evm.transact().wrap_err("backend: failed while inspecting")?; + let res = evm.transact().wrap_err("EVM error")?; env.env = evm.context.evm.inner.env; @@ -1937,12 +1936,6 @@ fn commit_transaction( persistent_accounts: &HashSet
, inspector: &mut dyn InspectorExt, ) -> eyre::Result<()> { - // TODO: Remove after https://github.com/foundry-rs/foundry/pull/9131 - // if the tx has the blob_versioned_hashes field, we assume it's a Cancun block - if tx.blob_versioned_hashes().is_some() { - env.handler_cfg.spec_id = SpecId::CANCUN; - } - configure_tx_env(&mut env.env, tx); let now = Instant::now(); diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index aec0d78a05cf5..fec780b0fe6f5 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -7,6 +7,7 @@ use foundry_common::{provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS}; use foundry_config::{Chain, Config, GasLimit}; use revm::primitives::{BlockEnv, CfgEnv, TxEnv}; use serde::{Deserialize, Serialize}; +use std::fmt::Write; use url::Url; #[derive(Clone, Debug, Serialize, Deserialize)] @@ -129,13 +130,13 @@ impl EvmOpts { ) .await .wrap_err_with(|| { - let mut err_msg = "Could not instantiate forked environment".to_string(); + let mut msg = "Could not instantiate forked environment".to_string(); if let Ok(url) = Url::parse(fork_url) { if let Some(provider) = url.host() { - err_msg.push_str(&format!(" with provider {provider}")); + write!(msg, " with provider {provider}").unwrap(); } } - err_msg + msg }) } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index e70df0e164a28..ada7cc7b0666f 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -708,8 +708,12 @@ pub enum EvmError { #[error("{_0}")] Skip(SkipReason), /// Any other error. - #[error(transparent)] - Eyre(eyre::Error), + #[error("{}", foundry_common::errors::display_chain(.0))] + Eyre( + #[from] + #[source] + eyre::Report, + ), } impl From for EvmError { @@ -724,16 +728,6 @@ impl From for EvmError { } } -impl From for EvmError { - fn from(err: eyre::Report) -> Self { - let mut chained_cause = String::new(); - for cause in err.chain() { - chained_cause.push_str(format!("{cause}; ").as_str()); - } - Self::Eyre(eyre::format_err!("{chained_cause}")) - } -} - /// The result of a deployment. #[derive(Debug)] pub struct DeployResult { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index e40db2b81f396..9cf3e746c9227 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2397,33 +2397,6 @@ Simulated On-chain Traces: "#]]); }); -// Tests that chained errors are properly displayed. -// -forgetest_init!( - #[ignore] - should_display_evm_chained_error, - |prj, cmd| { - let script = prj - .add_source( - "Foo", - r#" -import "forge-std/Script.sol"; - -contract ContractScript is Script { - function run() public { - } -} - "#, - ) - .unwrap(); - cmd.arg("script").arg(script).args(["--fork-url", "https://public-node.testnet.rsk.co"]).assert_failure().stderr_eq(str![[r#" -Error: Failed to deploy script: -backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set; - -"#]]); - } -); - forgetest_async!(should_detect_additional_contracts, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test()).await; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 7e568af0c5d88..fa3d72e0dd5e4 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2659,7 +2659,7 @@ contract ForkTest is Test { cmd.args(["test", "--mt", "test_fork_err_message"]).assert_failure().stdout_eq(str![[r#" ... Ran 1 test for test/ForkTest.t.sol:ForkTest -[FAIL: vm.createSelectFork: Could not instantiate forked environment with provider eth-mainnet.g.alchemy.com;] test_fork_err_message() ([GAS]) +[FAIL: vm.createSelectFork: Could not instantiate forked environment with provider eth-mainnet.g.alchemy.com] test_fork_err_message() ([GAS]) Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] ... @@ -2700,3 +2700,27 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); }); + +// Tests that chained errors are properly displayed. +// +forgetest!(displays_chained_error, |prj, cmd| { + prj.add_test( + "Foo.t.sol", + r#" +contract ContractTest { + function test_anything(uint) public {} +} + "#, + ) + .unwrap(); + + cmd.arg("test").arg("--gas-limit=100").assert_failure().stdout_eq(str![[r#" +... +Failing tests: +Encountered 1 failing test in test/Foo.t.sol:ContractTest +[FAIL: EVM error; transaction validation error: call gas cost exceeds the gas limit] setUp() ([GAS]) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]]); +}); From 2c9719ed2fdc99c3fd75ed6f62bb298e2f080b88 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:41:59 +0100 Subject: [PATCH 1766/1963] chore(anvil): convert panics into errors (#9471) --- crates/anvil/src/cmd.rs | 4 +- crates/anvil/src/config.rs | 137 ++++++++++++------------ crates/anvil/src/eth/backend/mem/mod.rs | 15 +-- crates/anvil/src/eth/error.rs | 6 ++ crates/anvil/src/lib.rs | 21 ++-- 5 files changed, 93 insertions(+), 90 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index eda009418c148..eda36bb90c682 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -89,8 +89,8 @@ pub struct NodeArgs { pub slots_in_an_epoch: u64, /// Writes output of `anvil` as json to user-specified file. - #[arg(long, value_name = "OUT_FILE")] - pub config_out: Option, + #[arg(long, value_name = "FILE", value_hint = clap::ValueHint::FilePath)] + pub config_out: Option, /// Disable auto and interval mining, and mine on demand instead. #[arg(long, visible_alias = "no-mine", conflicts_with = "block_time")] diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index ada48232904ba..b867aca266e4d 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -28,7 +28,7 @@ use alloy_signer_local::{ }; use alloy_transport::{Transport, TransportError}; use anvil_server::ServerConfig; -use eyre::Result; +use eyre::{Context, Result}; use foundry_common::{ provider::{ProviderBuilder, RetryProvider}, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT, @@ -44,15 +44,17 @@ use itertools::Itertools; use parking_lot::RwLock; use rand::thread_rng; use revm::primitives::BlobExcessGasAndPrice; -use serde_json::{json, to_writer, Value}; +use serde_json::{json, Value}; use std::{ fmt::Write as FmtWrite, fs::File, + io, net::{IpAddr, Ipv4Addr}, path::{Path, PathBuf}, sync::Arc, time::Duration, }; +use tokio::sync::RwLock as TokioRwLock; use yansi::Paint; /// Default port the rpc will open @@ -144,7 +146,7 @@ pub struct NodeConfig { /// How transactions are sorted in the mempool pub transaction_order: TransactionOrder, /// Filename to write anvil output as json - pub config_out: Option, + pub config_out: Option, /// The genesis to use to initialize the node pub genesis: Option, /// Timeout in for requests sent to remote JSON-RPC server in forking mode @@ -195,13 +197,13 @@ pub struct NodeConfig { impl NodeConfig { fn as_string(&self, fork: Option<&ClientFork>) -> String { - let mut config_string: String = String::new(); - let _ = write!(config_string, "\n{}", BANNER.green()); - let _ = write!(config_string, "\n {VERSION_MESSAGE}"); - let _ = write!(config_string, "\n {}", "https://github.com/foundry-rs/foundry".green()); + let mut s: String = String::new(); + let _ = write!(s, "\n{}", BANNER.green()); + let _ = write!(s, "\n {VERSION_MESSAGE}"); + let _ = write!(s, "\n {}", "https://github.com/foundry-rs/foundry".green()); let _ = write!( - config_string, + s, r#" Available Accounts @@ -210,11 +212,11 @@ Available Accounts ); let balance = alloy_primitives::utils::format_ether(self.genesis_balance); for (idx, wallet) in self.genesis_accounts.iter().enumerate() { - write!(config_string, "\n({idx}) {} ({balance} ETH)", wallet.address()).unwrap(); + write!(s, "\n({idx}) {} ({balance} ETH)", wallet.address()).unwrap(); } let _ = write!( - config_string, + s, r#" Private Keys @@ -224,12 +226,12 @@ Private Keys for (idx, wallet) in self.genesis_accounts.iter().enumerate() { let hex = hex::encode(wallet.credential().to_bytes()); - let _ = write!(config_string, "\n({idx}) 0x{hex}"); + let _ = write!(s, "\n({idx}) 0x{hex}"); } if let Some(ref gen) = self.account_generator { let _ = write!( - config_string, + s, r#" Wallet @@ -244,7 +246,7 @@ Derivation path: {} if let Some(fork) = fork { let _ = write!( - config_string, + s, r#" Fork @@ -261,11 +263,11 @@ Chain ID: {} ); if let Some(tx_hash) = fork.transaction_hash() { - let _ = writeln!(config_string, "Transaction hash: {tx_hash}"); + let _ = writeln!(s, "Transaction hash: {tx_hash}"); } } else { let _ = write!( - config_string, + s, r#" Chain ID @@ -279,7 +281,7 @@ Chain ID if (SpecId::from(self.get_hardfork()) as u8) < (SpecId::LONDON as u8) { let _ = write!( - config_string, + s, r#" Gas Price ================== @@ -290,7 +292,7 @@ Gas Price ); } else { let _ = write!( - config_string, + s, r#" Base Fee ================== @@ -302,7 +304,7 @@ Base Fee } let _ = write!( - config_string, + s, r#" Gas Limit ================== @@ -326,7 +328,7 @@ Gas Limit ); let _ = write!( - config_string, + s, r#" Genesis Timestamp ================== @@ -336,7 +338,7 @@ Genesis Timestamp self.get_genesis_timestamp().green() ); - config_string + s } fn as_json(&self, fork: Option<&ClientFork>) -> Value { @@ -749,7 +751,7 @@ impl NodeConfig { /// Sets the file path to write the Anvil node's config info to. #[must_use] - pub fn set_config_out(mut self, config_out: Option) -> Self { + pub fn set_config_out(mut self, config_out: Option) -> Self { self.config_out = config_out; self } @@ -903,21 +905,18 @@ impl NodeConfig { } /// Prints the config info - pub fn print(&self, fork: Option<&ClientFork>) { - if self.config_out.is_some() { - let config_out = self.config_out.as_deref().unwrap(); - to_writer( - &File::create(config_out).expect("Unable to create anvil config description file"), - &self.as_json(fork), - ) - .expect("Failed writing json"); + pub fn print(&self, fork: Option<&ClientFork>) -> Result<()> { + if let Some(path) = &self.config_out { + let file = io::BufWriter::new( + File::create(path).wrap_err("unable to create anvil config description file")?, + ); + let value = self.as_json(fork); + serde_json::to_writer(file, &value).wrap_err("failed writing JSON")?; } - - if self.silent { - return; + if !self.silent { + sh_println!("{}", self.as_string(fork))?; } - - let _ = sh_println!("{}", self.as_string(fork)); + Ok(()) } /// Returns the path where the cache file should be stored @@ -983,7 +982,7 @@ impl NodeConfig { /// [Backend](mem::Backend) /// /// *Note*: only memory based backend for now - pub(crate) async fn setup(&mut self) -> mem::Backend { + pub(crate) async fn setup(&mut self) -> Result { // configure the revm environment let mut cfg = @@ -1020,11 +1019,11 @@ impl NodeConfig { self.get_blob_excess_gas_and_price(), ); - let (db, fork): (Arc>>, Option) = + let (db, fork): (Arc>>, Option) = if let Some(eth_rpc_url) = self.eth_rpc_url.clone() { - self.setup_fork_db(eth_rpc_url, &mut env, &fees).await + self.setup_fork_db(eth_rpc_url, &mut env, &fees).await? } else { - (Arc::new(tokio::sync::RwLock::new(Box::::default())), None) + (Arc::new(TokioRwLock::new(Box::::default())), None) }; // if provided use all settings of `genesis.json` @@ -1062,9 +1061,9 @@ impl NodeConfig { self.transaction_block_keeper, self.block_time, self.cache_path.clone(), - Arc::new(tokio::sync::RwLock::new(self.clone())), + Arc::new(TokioRwLock::new(self.clone())), ) - .await; + .await?; // Writes the default create2 deployer to the backend, // if the option is not disabled and we are not forking. @@ -1072,19 +1071,19 @@ impl NodeConfig { backend .set_create2_deployer(DEFAULT_CREATE2_DEPLOYER) .await - .expect("Failed to create default create2 deployer"); + .wrap_err("failed to create default create2 deployer")?; } if let Some(state) = self.init_state.clone() { - backend.load_state(state).await.expect("Failed to load init state"); + backend.load_state(state).await.wrap_err("failed to load init state")?; } - backend + Ok(backend) } /// Configures everything related to forking based on the passed `eth_rpc_url`: - /// - returning a tuple of a [ForkedDatabase] wrapped in an [Arc] [RwLock](tokio::sync::RwLock) - /// and [ClientFork] wrapped in an [Option] which can be used in a [Backend](mem::Backend) to + /// - returning a tuple of a [ForkedDatabase] wrapped in an [Arc] [RwLock](TokioRwLock) and + /// [ClientFork] wrapped in an [Option] which can be used in a [Backend](mem::Backend) to /// fork from. /// - modifying some parameters of the passed `env` /// - mutating some members of `self` @@ -1093,15 +1092,11 @@ impl NodeConfig { eth_rpc_url: String, env: &mut EnvWithHandlerCfg, fees: &FeeManager, - ) -> (Arc>>, Option) { - let (db, config) = self.setup_fork_db_config(eth_rpc_url, env, fees).await; - - let db: Arc>> = - Arc::new(tokio::sync::RwLock::new(Box::new(db))); - + ) -> Result<(Arc>>, Option)> { + let (db, config) = self.setup_fork_db_config(eth_rpc_url, env, fees).await?; + let db: Arc>> = Arc::new(TokioRwLock::new(Box::new(db))); let fork = ClientFork::new(config, Arc::clone(&db)); - - (db, Some(fork)) + Ok((db, Some(fork))) } /// Configures everything related to forking based on the passed `eth_rpc_url`: @@ -1114,7 +1109,7 @@ impl NodeConfig { eth_rpc_url: String, env: &mut EnvWithHandlerCfg, fees: &FeeManager, - ) -> (ForkedDatabase, ClientForkConfig) { + ) -> Result<(ForkedDatabase, ClientForkConfig)> { // TODO make provider agnostic let provider = Arc::new( ProviderBuilder::new(ð_rpc_url) @@ -1125,23 +1120,22 @@ impl NodeConfig { .initial_backoff(1000) .headers(self.fork_headers.clone()) .build() - .expect("Failed to establish provider to fork url"), + .wrap_err("failed to establish provider to fork url")?, ); let (fork_block_number, fork_chain_id, force_transactions) = if let Some(fork_choice) = &self.fork_choice { let (fork_block_number, force_transactions) = - derive_block_and_transactions(fork_choice, &provider).await.expect( - "Failed to derive fork block number and force transactions from fork choice", - ); + derive_block_and_transactions(fork_choice, &provider).await.wrap_err( + "failed to derive fork block number and force transactions from fork choice", + )?; let chain_id = if let Some(chain_id) = self.fork_chain_id { Some(chain_id) } else if self.hardfork.is_none() { - // auto adjust hardfork if not specified - // but only if we're forking mainnet + // Auto-adjust hardfork if not specified, but only if we're forking mainnet. let chain_id = - provider.get_chain_id().await.expect("Failed to fetch network chain ID"); + provider.get_chain_id().await.wrap_err("failed to fetch network chain ID")?; if alloy_chains::NamedChain::Mainnet == chain_id { let hardfork: EthereumHardfork = fork_block_number.into(); env.handler_cfg.spec_id = hardfork.into(); @@ -1155,15 +1149,16 @@ impl NodeConfig { (fork_block_number, chain_id, force_transactions) } else { // pick the last block number but also ensure it's not pending anymore - let bn = - find_latest_fork_block(&provider).await.expect("Failed to get fork block number"); + let bn = find_latest_fork_block(&provider) + .await + .wrap_err("failed to get fork block number")?; (bn, None, None) }; let block = provider .get_block(BlockNumberOrTag::Number(fork_block_number).into(), false.into()) .await - .expect("Failed to get fork block"); + .wrap_err("failed to get fork block")?; let block = if let Some(block) = block { block @@ -1179,9 +1174,9 @@ latest block number: {latest_block}" if fork_block_number <= latest_block { message.push_str(&format!("\n{NON_ARCHIVE_NODE_WARNING}")); } - panic!("{}", message); + eyre::bail!("{message}"); } - panic!("Failed to get block for block number: {fork_block_number}") + eyre::bail!("failed to get block for block number: {fork_block_number}") }; let gas_limit = self.fork_gas_limit(&block); @@ -1243,7 +1238,7 @@ latest block number: {latest_block}" let chain_id = if let Some(fork_chain_id) = fork_chain_id { fork_chain_id.to() } else { - provider.get_chain_id().await.unwrap() + provider.get_chain_id().await.wrap_err("failed to fetch network chain ID")? }; // need to update the dev signers and env with the chain id @@ -1296,7 +1291,7 @@ latest block number: {latest_block}" // need to insert the forked block's hash db.insert_block_hash(U256::from(config.block_number), config.block_hash); - (db, config) + Ok((db, config)) } /// we only use the gas limit value of the block if it is non-zero and the block gas @@ -1344,7 +1339,7 @@ async fn derive_block_and_transactions( let transaction = provider .get_transaction_by_hash(transaction_hash.0.into()) .await? - .ok_or(eyre::eyre!("Failed to get fork transaction by hash"))?; + .ok_or_else(|| eyre::eyre!("failed to get fork transaction by hash"))?; let transaction_block_number = transaction.block_number.unwrap(); // Get the block pertaining to the fork transaction @@ -1354,13 +1349,13 @@ async fn derive_block_and_transactions( alloy_rpc_types::BlockTransactionsKind::Full, ) .await? - .ok_or(eyre::eyre!("Failed to get fork block by number"))?; + .ok_or_else(|| eyre::eyre!("failed to get fork block by number"))?; // Filter out transactions that are after the fork transaction let filtered_transactions = transaction_block .transactions .as_transactions() - .ok_or(eyre::eyre!("Failed to get transactions from full fork block"))? + .ok_or_else(|| eyre::eyre!("failed to get transactions from full fork block"))? .iter() .take_while_inclusive(|&transaction| transaction.tx_hash() != transaction_hash.0) .collect::>(); diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index fa79332e74061..75888c130e4ae 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -75,6 +75,7 @@ use anvil_core::eth::{ }; use anvil_rpc::error::RpcError; use chrono::Datelike; +use eyre::{Context, Result}; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use foundry_evm::{ backend::{DatabaseError, DatabaseResult, RevertStateSnapshotAction}, @@ -229,7 +230,7 @@ impl Backend { automine_block_time: Option, cache_path: Option, node_config: Arc>, - ) -> Self { + ) -> Result { // if this is a fork then adjust the blockchain storage let blockchain = if let Some(fork) = fork.read().as_ref() { trace!(target: "backend", "using forked blockchain at {}", fork.block_number()); @@ -341,8 +342,8 @@ impl Backend { } // Note: this can only fail in forking mode, in which case we can't recover - backend.apply_genesis().await.expect("Failed to create genesis"); - backend + backend.apply_genesis().await.wrap_err("failed to create genesis")?; + Ok(backend) } /// Writes the CREATE2 deployer code directly to the database at the address provided. @@ -500,7 +501,7 @@ impl Backend { // `setup_fork_db_config` node_config.base_fee.take(); - node_config.setup_fork_db_config(eth_rpc_url, &mut env, &self.fees).await + node_config.setup_fork_db_config(eth_rpc_url, &mut env, &self.fees).await? }; *self.db.write().await = Box::new(db); @@ -536,7 +537,7 @@ impl Backend { let mut env = self.env.read().clone(); let (forked_db, client_fork_config) = - node_config.setup_fork_db_config(fork_url, &mut env, &self.fees).await; + node_config.setup_fork_db_config(fork_url, &mut env, &self.fees).await?; *self.db.write().await = Box::new(forked_db); let fork = ClientFork::new(client_fork_config, Arc::clone(&self.db)); @@ -1232,7 +1233,7 @@ impl Backend { if storage.blocks.len() > transaction_block_keeper { let to_clear = block_number .to::() - .saturating_sub(transaction_block_keeper.try_into().unwrap()); + .saturating_sub(transaction_block_keeper.try_into().unwrap_or(u64::MAX)); storage.remove_block_transactions_by_number(to_clear) } } @@ -2877,7 +2878,7 @@ pub fn transaction_build( gas_limit, }; - let ser = serde_json::to_value(&dep_tx).unwrap(); + let ser = serde_json::to_value(&dep_tx).expect("could not serialize TxDeposit"); let maybe_deposit_fields = OtherFields::try_from(ser); match maybe_deposit_fields { diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index 394f33492e8d6..dda9b8bb26a9f 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -98,6 +98,12 @@ pub enum BlockchainError { Message(String), } +impl From for BlockchainError { + fn from(err: eyre::Report) -> Self { + Self::Message(err.to_string()) + } +} + impl From for BlockchainError { fn from(err: RpcError) -> Self { Self::RpcError(err) diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 4fc0621c84fc6..6d2e6d5e465e0 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -20,6 +20,7 @@ use crate::{ use alloy_primitives::{Address, U256}; use alloy_signer_local::PrivateKeySigner; use eth::backend::fork::ClientFork; +use eyre::Result; use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_evm::revm; use futures::{FutureExt, TryFutureExt}; @@ -27,7 +28,6 @@ use parking_lot::Mutex; use server::try_spawn_ipc; use std::{ future::Future, - io, net::SocketAddr, pin::Pin, sync::Arc, @@ -126,11 +126,11 @@ pub async fn spawn(config: NodeConfig) -> (EthApi, NodeHandle) { /// # Ok(()) /// # } /// ``` -pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle)> { +pub async fn try_spawn(mut config: NodeConfig) -> Result<(EthApi, NodeHandle)> { let logger = if config.enable_tracing { init_tracing() } else { Default::default() }; logger.set_enabled(!config.silent); - let backend = Arc::new(config.setup().await); + let backend = Arc::new(config.setup().await?); if config.enable_auto_impersonate { backend.auto_impersonate_account(true); @@ -251,7 +251,7 @@ pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle task_manager, }; - handle.print(fork.as_ref()); + handle.print(fork.as_ref())?; Ok((api, handle)) } @@ -281,7 +281,7 @@ impl Drop for NodeHandle { fn drop(&mut self) { // Fire shutdown signal to make sure anvil instance is terminated. if let Some(signal) = self._signal.take() { - signal.fire().unwrap() + let _ = signal.fire(); } } } @@ -293,21 +293,22 @@ impl NodeHandle { } /// Prints the launch info. - pub(crate) fn print(&self, fork: Option<&ClientFork>) { - self.config.print(fork); + pub(crate) fn print(&self, fork: Option<&ClientFork>) -> Result<()> { + self.config.print(fork)?; if !self.config.silent { if let Some(ipc_path) = self.ipc_path() { - let _ = sh_println!("IPC path: {ipc_path}"); + sh_println!("IPC path: {ipc_path}")?; } - let _ = sh_println!( + sh_println!( "Listening on {}", self.addresses .iter() .map(|addr| { addr.to_string() }) .collect::>() .join(", ") - ); + )?; } + Ok(()) } /// The address of the launched server. From 25c978ae29454454cec857de3400a885efc4bd7c Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:25:29 +0200 Subject: [PATCH 1767/1963] fix(remappings): project autoremappings should respect config (#9466) --- crates/config/src/providers/remappings.rs | 12 +++++---- crates/forge/tests/cli/config.rs | 33 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 343fde697859a..1d8a7b16368cb 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -1,7 +1,4 @@ -use crate::{ - foundry_toml_dirs, remappings_from_env_var, remappings_from_newline, utils::get_dir_remapping, - Config, -}; +use crate::{foundry_toml_dirs, remappings_from_env_var, remappings_from_newline, Config}; use figment::{ value::{Dict, Map}, Error, Figment, Metadata, Profile, Provider, @@ -39,7 +36,12 @@ impl Remappings { pub fn with_figment(mut self, figment: &Figment) -> Self { let mut add_project_remapping = |path: &str| { if let Ok(path) = figment.find_value(path) { - if let Some(remapping) = path.into_string().and_then(get_dir_remapping) { + if let Some(path) = path.into_string() { + let remapping = Remapping { + context: None, + name: format!("{path}/"), + path: format!("{path}/"), + }; self.project_paths.push(remapping); } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 02ff2fce85365..6f70f845c0454 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -856,3 +856,36 @@ contract MyScript is BaseScript { pretty_err(&lib_toml_file, fs::write(&lib_toml_file, lib_config.to_string_pretty().unwrap())); cmd.forge_fuse().args(["build"]).assert_success(); }); + +// Tests that project remappings use config paths. +// For `src=src/contracts` config, remapping should be `src/contracts/ = src/contracts/`. +// For `src=src` config, remapping should be `src/ = src/`. +// +forgetest!(test_project_remappings, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + let config = Config { + src: "src/contracts".into(), + remappings: vec![Remapping::from_str("contracts/=src/contracts/").unwrap().into()], + ..Default::default() + }; + prj.write_config(config); + + // Add Counter.sol in `src/contracts` project dir. + let src_dir = &prj.root().join("src/contracts"); + pretty_err(src_dir, fs::create_dir_all(src_dir)); + pretty_err( + src_dir.join("Counter.sol"), + fs::write(src_dir.join("Counter.sol"), "contract Counter{}"), + ); + prj.add_test( + "CounterTest.sol", + r#" +import "contracts/Counter.sol"; + +contract CounterTest { +} + "#, + ) + .unwrap(); + cmd.forge_fuse().args(["build"]).assert_success(); +}); From 3784cd8514bf2c2248a21df6c19455e8a674ef63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Rodr=C3=ADguez?= Date: Wed, 4 Dec 2024 15:16:59 -0300 Subject: [PATCH 1768/1963] refactor: adapt to CompilerContract trait type (#9423) * refactor: adapt to CompilerContract trait type * chore: cargo fmt * fix: specify MultiCompiler in MultiContractRunner::build * bump * fix --------- Co-authored-by: Arsenii Kulikov --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 2 +- crates/cast/bin/cmd/storage.rs | 6 +++--- crates/common/src/compile.rs | 19 ++++++++++++++----- crates/config/src/lib.rs | 15 +++++++++------ crates/evm/traces/src/debug/sources.rs | 4 ++-- crates/forge/bin/cmd/clone.rs | 6 +++--- crates/forge/bin/cmd/coverage.rs | 3 ++- crates/forge/bin/cmd/test/mod.rs | 7 +++++-- crates/forge/src/multi_runner.rs | 8 ++++++-- crates/forge/tests/it/test_helpers.rs | 7 ++++--- crates/test-utils/src/util.rs | 5 ++++- 12 files changed, 66 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87ac75dee06ef..e60060bfcb66f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3864,9 +3864,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daece74fc0b127e587ac343405283577b4fe9d0195317998c3031778b5f799cd" +checksum = "611e6de7379c57fc353a53e718cd95844e9bd08b2e3ca79a34b76d4a84d38e48" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3901,9 +3901,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c6b0571a37cc9860103df548330eaceb36e9438cb0264ec63e5db74031fa4f" +checksum = "868df34b353da95395e61fd83e4a56cb075f462f58d9fa1150c9cf96ccb46637" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3911,9 +3911,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278cc3f1f4f628793ae6c0db38b0d3fe4124ab0bc10da081b1eb365766512e6d" +checksum = "ac37bffdf6d62cbc4ce03393cc45814d32274807b87486a808a370efbd08b67d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3935,9 +3935,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196b16fcfbbe69a315d64f74dd817ba6843f7749c64124b937118551414b9b90" +checksum = "8c873d45485dc4b4f351f2f6c6acbb7f5ef8ec27f12e1bd0e6dc016cb9bdda2b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3950,9 +3950,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eb08a74eb12b281038bbf74cbbd76cc3c85546896628d4c7c769c816ab4104b" +checksum = "2a605a29e2c0b9c54f14540ec3d03a2434fbaabdda8e6565451cdd38ae8fbd00" dependencies = [ "alloy-primitives", "cfg-if", @@ -7112,7 +7112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.90", @@ -8565,7 +8565,7 @@ dependencies = [ "const-hex", "derive_builder", "dunce", - "itertools 0.11.0", + "itertools 0.13.0", "itoa", "lasso", "match_cfg", @@ -8601,7 +8601,7 @@ dependencies = [ "alloy-primitives", "bitflags 2.6.0", "bumpalo", - "itertools 0.11.0", + "itertools 0.13.0", "memchr", "num-bigint", "num-rational", diff --git a/Cargo.toml b/Cargo.toml index af1d118b9fe84..0fa4b4bdb33f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } -foundry-compilers = { version = "0.12.3", default-features = false } +foundry-compilers = { version = "0.12.5", default-features = false } foundry-fork-db = "0.8.0" solang-parser = "=0.3.3" solar-ast = { version = "=0.1.0", default-features = false } diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 13fa908bc94ac..468f20b27ae1b 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -20,7 +20,7 @@ use foundry_common::{ shell, }; use foundry_compilers::{ - artifacts::{ConfigurableContractArtifact, StorageLayout}, + artifacts::{ConfigurableContractArtifact, Contract, StorageLayout}, compilers::{ solc::{Solc, SolcCompiler}, Compiler, @@ -284,7 +284,7 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) "{}", serde_json::to_string_pretty(&serde_json::to_value(StorageReport { layout, values })?)? )?; - return Ok(()) + return Ok(()); } let mut table = Table::new(); @@ -314,7 +314,7 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) Ok(()) } -fn add_storage_layout_output(project: &mut Project) { +fn add_storage_layout_output>(project: &mut Project) { project.artifacts.additional_values.storage_layout = true; project.update_output_selection(|selection| { selection.0.values_mut().for_each(|contract_selection| { diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 507f328307c50..47fe226d98db5 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -10,7 +10,7 @@ use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color use eyre::Result; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ - artifacts::{remappings::Remapping, BytecodeObject, Source}, + artifacts::{remappings::Remapping, BytecodeObject, Contract, Source}, compilers::{ solc::{Solc, SolcCompiler}, Compiler, @@ -129,7 +129,10 @@ impl ProjectCompiler { } /// Compiles the project. - pub fn compile(mut self, project: &Project) -> Result> { + pub fn compile>( + mut self, + project: &Project, + ) -> Result> { // TODO: Avoid process::exit if !project.paths.has_input_files() && self.files.is_empty() { sh_println!("Nothing to compile")?; @@ -163,7 +166,10 @@ impl ProjectCompiler { /// ProjectCompiler::new().compile_with(|| Ok(prj.compile()?)).unwrap(); /// ``` #[instrument(target = "forge::compile", skip_all)] - fn compile_with(self, f: F) -> Result> + fn compile_with, F>( + self, + f: F, + ) -> Result> where F: FnOnce() -> Result>, { @@ -202,7 +208,10 @@ impl ProjectCompiler { } /// If configured, this will print sizes or names - fn handle_output(&self, output: &ProjectCompileOutput) { + fn handle_output>( + &self, + output: &ProjectCompileOutput, + ) { let print_names = self.print_names.unwrap_or(false); let print_sizes = self.print_sizes.unwrap_or(false); @@ -465,7 +474,7 @@ pub struct ContractInfo { /// If `verify` and it's a standalone script, throw error. Only allowed for projects. /// /// **Note:** this expects the `target_path` to be absolute -pub fn compile_target( +pub fn compile_target>( target_path: &Path, project: &Project, quiet: bool, diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f2d25461dfaf4..08c1ed0ee4093 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -35,8 +35,8 @@ use foundry_compilers::{ error::SolcError, multi::{MultiCompilerParsedSource, MultiCompilerRestrictions}, solc::{CliSettings, SolcSettings}, - ConfigurableArtifacts, Graph, Project, ProjectPathsConfig, RestrictionsWithVersion, - VyperLanguage, + ArtifactOutput, ConfigurableArtifacts, Graph, Project, ProjectPathsConfig, + RestrictionsWithVersion, VyperLanguage, }; use regex::Regex; use revm_primitives::{map::AddressHashMap, FixedBytes, SpecId}; @@ -1021,7 +1021,10 @@ impl Config { } /// Cleans the project. - pub fn cleanup(&self, project: &Project) -> Result<(), SolcError> { + pub fn cleanup>( + &self, + project: &Project, + ) -> Result<(), SolcError> { project.cleanup()?; // Remove last test run failures file. @@ -1090,7 +1093,7 @@ impl Config { rx.recv().expect("sender dropped") } Err(RecvTimeoutError::Disconnected) => panic!("sender dropped"), - } + }; } if let Some(ref solc) = self.solc { let solc = match solc { @@ -1291,11 +1294,11 @@ impl Config { ) -> Option, UnresolvedEnvVarError>> { let mut endpoints = self.rpc_endpoints.clone().resolved(); if let Some(endpoint) = endpoints.remove(maybe_alias) { - return Some(endpoint.map(Cow::Owned)) + return Some(endpoint.map(Cow::Owned)); } if let Ok(Some(endpoint)) = mesc::get_endpoint_by_query(maybe_alias, Some("foundry")) { - return Some(Ok(Cow::Owned(endpoint.url))) + return Some(Ok(Cow::Owned(endpoint.url))); } None diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index f934be61f00b9..b2e37e32d9344 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -3,7 +3,7 @@ use foundry_common::compact_to_contract; use foundry_compilers::{ artifacts::{ sourcemap::{SourceElement, SourceMap}, - Bytecode, ContractBytecodeSome, Libraries, Source, + Bytecode, Contract, ContractBytecodeSome, Libraries, Source, }, multi::MultiCompilerLanguage, Artifact, Compiler, ProjectCompileOutput, @@ -137,7 +137,7 @@ impl ContractSources { Ok(sources) } - pub fn insert( + pub fn insert>( &mut self, output: &ProjectCompileOutput, root: &Path, diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 193e511836ba9..52ec97c48098f 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -266,7 +266,7 @@ impl CloneArgs { let remappings_txt_content = config.remappings.iter().map(|r| r.to_string()).collect::>().join("\n"); if fs::write(&remappings_txt, remappings_txt_content).is_err() { - return false + return false; } let profile = config.profile.as_str().as_str(); @@ -612,7 +612,7 @@ impl EtherscanClient for Client { mod tests { use super::*; use alloy_primitives::hex; - use foundry_compilers::Artifact; + use foundry_compilers::CompilerContract; use foundry_test_utils::rpc::next_mainnet_etherscan_api_key; use std::collections::BTreeMap; @@ -631,7 +631,7 @@ mod tests { contracts.iter().for_each(|(name, contract)| { if name == contract_name { let compiled_creation_code = - contract.get_bytecode_object().expect("creation code not found"); + contract.bin_ref().expect("creation code not found"); assert!( hex::encode(compiled_creation_code.as_ref()) .starts_with(stripped_creation_code), diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index c3d0545c28d99..65b4aad03f520 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -19,6 +19,7 @@ use foundry_compilers::{ artifacts::{ sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode, SolcLanguage, Source, }, + compilers::multi::MultiCompiler, Artifact, ArtifactId, Project, ProjectCompileOutput, }; use foundry_config::{Config, SolcReq}; @@ -245,7 +246,7 @@ impl CoverageArgs { .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .set_coverage(true) - .build(&root, output, env, evm_opts)?; + .build::(&root, output, env, evm_opts)?; let known_contracts = runner.known_contracts.clone(); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index dd6d04a98cde3..5f245d0027695 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -23,7 +23,10 @@ use foundry_cli::{ use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell, TestFunctionExt}; use foundry_compilers::{ artifacts::output_selection::OutputSelection, - compilers::{multi::MultiCompilerLanguage, Language}, + compilers::{ + multi::{MultiCompiler, MultiCompilerLanguage}, + Language, + }, utils::source_files_iter, ProjectCompileOutput, }; @@ -353,7 +356,7 @@ impl TestArgs { .with_fork(evm_opts.get_fork(&config, env.clone())) .enable_isolation(evm_opts.isolate) .alphanet(evm_opts.alphanet) - .build(project_root, &output, env, evm_opts)?; + .build::(project_root, &output, env, evm_opts)?; let mut maybe_override_mt = |flag, maybe_regex: Option<&Option>| { if let Some(Some(regex)) = maybe_regex { diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 0372becb208af..9240c6f27eaf1 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -8,7 +8,11 @@ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use foundry_common::{get_contract_name, shell::verbosity, ContractsByArtifact, TestFunctionExt}; -use foundry_compilers::{artifacts::Libraries, Artifact, ArtifactId, ProjectCompileOutput}; +use foundry_compilers::{ + artifacts::{Contract, Libraries}, + compilers::Compiler, + Artifact, ArtifactId, ProjectCompileOutput, +}; use foundry_config::{Config, InlineConfig}; use foundry_evm::{ backend::Backend, @@ -457,7 +461,7 @@ impl MultiContractRunnerBuilder { /// Given an EVM, proceeds to return a runner which is able to execute all tests /// against that evm - pub fn build( + pub fn build>( self, root: &Path, output: &ProjectCompileOutput, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 937f582f4e4ff..3c8500772b4a1 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -5,6 +5,7 @@ use alloy_primitives::U256; use forge::{revm::primitives::SpecId, MultiContractRunner, MultiContractRunnerBuilder}; use foundry_compilers::{ artifacts::{EvmVersion, Libraries, Settings}, + compilers::multi::MultiCompiler, utils::RuntimeOrHandle, Project, ProjectCompileOutput, SolcConfig, Vyper, }; @@ -212,7 +213,7 @@ impl ForgeTestData { builder .enable_isolation(opts.isolate) .sender(config.sender) - .build(root, &self.output, opts.local_evm_env(), opts) + .build::(root, &self.output, opts.local_evm_env(), opts) .unwrap() } @@ -221,7 +222,7 @@ impl ForgeTestData { let mut opts = config_evm_opts(&self.config); opts.verbosity = 5; self.base_runner() - .build(self.project.root(), &self.output, opts.local_evm_env(), opts) + .build::(self.project.root(), &self.output, opts.local_evm_env(), opts) .unwrap() } @@ -237,7 +238,7 @@ impl ForgeTestData { self.base_runner() .with_fork(fork) - .build(self.project.root(), &self.output, env, opts) + .build::(self.project.root(), &self.output, env, opts) .unwrap() } } diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index fb9eca587f4bc..e7410ed607edb 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -1,6 +1,7 @@ use crate::init_tracing; use eyre::{Result, WrapErr}; use foundry_compilers::{ + artifacts::Contract, cache::CompilerCache, compilers::multi::MultiCompiler, error::Result as SolcResult, @@ -420,7 +421,9 @@ pub fn setup_cast_project(test: TestProject) -> (TestProject, TestCommand) { /// /// Test projects are created from a global atomic counter to avoid duplicates. #[derive(Clone, Debug)] -pub struct TestProject { +pub struct TestProject< + T: ArtifactOutput + Default = ConfigurableArtifacts, +> { /// The directory in which this test executable is running. exe_root: PathBuf, /// The project in which the test should run. From 75fc63be4fc9241a1981a55c12b6e300fd82a51b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:26:23 +0100 Subject: [PATCH 1769/1963] chore(deps): bump foundry-compilers 0.12.6 (#9490) --- Cargo.lock | 20 ++++++++++---------- crates/cli/src/opts/global.rs | 10 +++++----- crates/forge/bin/cmd/coverage.rs | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e60060bfcb66f..51a6b026840c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3864,9 +3864,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611e6de7379c57fc353a53e718cd95844e9bd08b2e3ca79a34b76d4a84d38e48" +checksum = "186f601e89e36e2b82d3bc4a517287190846c990c1fd9f7b6f745bcbe65947e9" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3901,9 +3901,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "868df34b353da95395e61fd83e4a56cb075f462f58d9fa1150c9cf96ccb46637" +checksum = "9c32fbf90c191e5037818d9d42d85642d6da2ff6528283b1efb2a88b08a02a5d" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3911,9 +3911,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac37bffdf6d62cbc4ce03393cc45814d32274807b87486a808a370efbd08b67d" +checksum = "103d2d76d62a11b03d19e26fa6fbd996d2fac487a804392f57f96f0f677c469d" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3935,9 +3935,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c873d45485dc4b4f351f2f6c6acbb7f5ef8ec27f12e1bd0e6dc016cb9bdda2b" +checksum = "17cafd2720bd20428822421bfbf34cfb33806be75e1b0c6ffcd6a4b25d6ead16" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3950,9 +3950,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a605a29e2c0b9c54f14540ec3d03a2434fbaabdda8e6565451cdd38ae8fbd00" +checksum = "327f11092bf779c76b3fa588ebf37c2e3bb903d55ba49f8e73b69e4cb888d0cb" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/crates/cli/src/opts/global.rs b/crates/cli/src/opts/global.rs index c820ca2cff7e7..74ed15a65a549 100644 --- a/crates/cli/src/opts/global.rs +++ b/crates/cli/src/opts/global.rs @@ -50,11 +50,6 @@ impl GlobalOpts { Ok(()) } - /// Initialize the global thread pool. - pub fn force_init_thread_pool(&self) -> eyre::Result<()> { - init_thread_pool(self.threads.unwrap_or(0)) - } - /// Create a new shell instance. pub fn shell(&self) -> Shell { let mode = match self.quiet { @@ -69,6 +64,11 @@ impl GlobalOpts { Shell::new_with(format, mode, color, self.verbosity) } + + /// Initialize the global thread pool. + pub fn force_init_thread_pool(&self) -> eyre::Result<()> { + init_thread_pool(self.threads.unwrap_or(0)) + } } /// Initialize the global thread pool. diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 65b4aad03f520..4e99cb13f7dfb 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -182,7 +182,7 @@ impl CoverageArgs { // Get source maps and bytecodes let artifacts: Vec = output .artifact_ids() - .par_bridge() + .par_bridge() // This parses source maps, so we want to run it in parallel. .filter_map(|(id, artifact)| { let source_id = report.get_source_id(id.version.clone(), id.source.clone())?; ArtifactData::new(&id, source_id, artifact) From ce9fca2538eb90551b6b880b7e72fb94d4bb8259 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 5 Dec 2024 08:35:17 +0100 Subject: [PATCH 1770/1963] chore: rename alphanet to odyssey (#9491) * chore: rename alphanet to odyssey * fix weird change --- crates/anvil/src/cmd.rs | 8 +++--- crates/anvil/src/config.rs | 16 +++++------ crates/anvil/src/eth/backend/executor.rs | 18 ++++++------ crates/anvil/src/eth/backend/mem/mod.rs | 14 +++++----- crates/anvil/tests/it/anvil_api.rs | 6 ++-- crates/cast/bin/cmd/call.rs | 22 ++++++--------- crates/cast/bin/cmd/run.rs | 14 +++++----- crates/common/src/evm.rs | 10 +++---- crates/config/src/lib.rs | 9 +++--- crates/config/src/providers/ext.rs | 2 +- crates/config/src/utils.rs | 4 +-- crates/evm/core/src/lib.rs | 4 +-- crates/evm/core/src/opts.rs | 6 ++-- crates/evm/core/src/precompiles.rs | 12 ++++---- crates/evm/core/src/utils.rs | 16 +++++------ crates/evm/evm/src/executors/trace.rs | 11 +++----- crates/evm/evm/src/inspectors/stack.rs | 28 +++++++++---------- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/forge/src/multi_runner.rs | 22 +++++++-------- crates/forge/tests/cli/config.rs | 2 +- crates/forge/tests/cli/main.rs | 2 +- .../tests/cli/{alphanet.rs => odyssey.rs} | 0 crates/script/src/lib.rs | 2 +- crates/verify/src/utils.rs | 4 +-- 24 files changed, 113 insertions(+), 121 deletions(-) rename crates/forge/tests/cli/{alphanet.rs => odyssey.rs} (100%) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index eda36bb90c682..7b009a5928133 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -275,7 +275,7 @@ impl NodeArgs { .with_transaction_block_keeper(self.transaction_block_keeper) .with_max_persisted_states(self.max_persisted_states) .with_optimism(self.evm_opts.optimism) - .with_alphanet(self.evm_opts.alphanet) + .with_odyssey(self.evm_opts.odyssey) .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) .with_memory_limit(self.evm_opts.memory_limit) @@ -583,9 +583,9 @@ pub struct AnvilEvmArgs { #[arg(long)] pub memory_limit: Option, - /// Enable Alphanet features - #[arg(long, visible_alias = "odyssey")] - pub alphanet: bool, + /// Enable Odyssey features + #[arg(long, alias = "alphanet")] + pub odyssey: bool, } /// Resolves an alias passed as fork-url to the matching url defined in the rpc_endpoints section diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index b867aca266e4d..9e22adeed1691 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -187,8 +187,8 @@ pub struct NodeConfig { pub memory_limit: Option, /// Factory used by `anvil` to extend the EVM's precompiles. pub precompile_factory: Option>, - /// Enable Alphanet features. - pub alphanet: bool, + /// Enable Odyssey features. + pub odyssey: bool, /// Do not print log messages. pub silent: bool, /// The path where states are cached. @@ -467,7 +467,7 @@ impl Default for NodeConfig { slots_in_an_epoch: 32, memory_limit: None, precompile_factory: None, - alphanet: false, + odyssey: false, silent: false, cache_path: None, } @@ -507,7 +507,7 @@ impl NodeConfig { /// Returns the hardfork to use pub fn get_hardfork(&self) -> ChainHardfork { - if self.alphanet { + if self.odyssey { return ChainHardfork::Ethereum(EthereumHardfork::PragueEOF); } if let Some(hardfork) = self.hardfork { @@ -952,10 +952,10 @@ impl NodeConfig { self } - /// Sets whether to enable Alphanet support + /// Sets whether to enable Odyssey support #[must_use] - pub fn with_alphanet(mut self, alphanet: bool) -> Self { - self.alphanet = alphanet; + pub fn with_odyssey(mut self, odyssey: bool) -> Self { + self.odyssey = odyssey; self } @@ -1055,7 +1055,7 @@ impl NodeConfig { Arc::new(RwLock::new(fork)), self.enable_steps_tracing, self.print_logs, - self.alphanet, + self.odyssey, self.prune_history, self.max_persisted_states, self.transaction_block_keeper, diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index a00afd962878c..f4b20868f2950 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -28,7 +28,7 @@ use foundry_evm::{ }, }, traces::CallTraceNode, - utils::alphanet_handler_register, + utils::odyssey_handler_register, }; use revm::{db::WrapDatabaseRef, primitives::MAX_BLOB_GAS_PER_BLOCK}; use std::sync::Arc; @@ -106,7 +106,7 @@ pub struct TransactionExecutor<'a, Db: ?Sized, V: TransactionValidator> { /// Cumulative blob gas used by all executed transactions pub blob_gas_used: u64, pub enable_steps_tracing: bool, - pub alphanet: bool, + pub odyssey: bool, pub print_logs: bool, /// Precompiles to inject to the EVM. pub precompile_factory: Option>, @@ -314,7 +314,7 @@ impl Iterator for &mut TransactionExec } let exec_result = { - let mut evm = new_evm_with_inspector(&mut *self.db, env, &mut inspector, self.alphanet); + let mut evm = new_evm_with_inspector(&mut *self.db, env, &mut inspector, self.odyssey); if let Some(factory) = &self.precompile_factory { inject_precompiles(&mut evm, factory.precompiles()); } @@ -398,20 +398,20 @@ fn build_logs_bloom(logs: Vec, bloom: &mut Bloom) { } } -/// Creates a database with given database and inspector, optionally enabling alphanet features. +/// Creates a database with given database and inspector, optionally enabling odyssey features. pub fn new_evm_with_inspector( db: DB, env: EnvWithHandlerCfg, inspector: &mut dyn revm::Inspector, - alphanet: bool, + odyssey: bool, ) -> revm::Evm<'_, &mut dyn revm::Inspector, DB> { let EnvWithHandlerCfg { env, handler_cfg } = env; let mut handler = revm::Handler::new(handler_cfg); handler.append_handler_register_plain(revm::inspector_handle_register); - if alphanet { - handler.append_handler_register_plain(alphanet_handler_register); + if odyssey { + handler.append_handler_register_plain(odyssey_handler_register); } let context = revm::Context::new(revm::EvmContext::new_with_env(db, env), inspector); @@ -424,10 +424,10 @@ pub fn new_evm_with_inspector_ref<'a, DB>( db: DB, env: EnvWithHandlerCfg, inspector: &mut dyn revm::Inspector>, - alphanet: bool, + odyssey: bool, ) -> revm::Evm<'a, &mut dyn revm::Inspector>, WrapDatabaseRef> where DB: revm::DatabaseRef, { - new_evm_with_inspector(WrapDatabaseRef(db), env, inspector, alphanet) + new_evm_with_inspector(WrapDatabaseRef(db), env, inspector, odyssey) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 75888c130e4ae..26787cca60cf5 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -195,7 +195,7 @@ pub struct Backend { active_state_snapshots: Arc>>, enable_steps_tracing: bool, print_logs: bool, - alphanet: bool, + odyssey: bool, /// How to keep history state prune_state_history_config: PruneStateHistoryConfig, /// max number of blocks with transactions in memory @@ -223,7 +223,7 @@ impl Backend { fork: Arc>>, enable_steps_tracing: bool, print_logs: bool, - alphanet: bool, + odyssey: bool, prune_state_history_config: PruneStateHistoryConfig, max_persisted_states: Option, transaction_block_keeper: Option, @@ -275,7 +275,7 @@ impl Backend { (cfg.slots_in_an_epoch, cfg.precompile_factory.clone()) }; - let (capabilities, executor_wallet) = if alphanet { + let (capabilities, executor_wallet) = if odyssey { // Insert account that sponsors the delegated txs. And deploy P256 delegation contract. let mut db = db.write().await; @@ -326,7 +326,7 @@ impl Backend { active_state_snapshots: Arc::new(Mutex::new(Default::default())), enable_steps_tracing, print_logs, - alphanet, + odyssey, prune_state_history_config, transaction_block_keeper, node_config, @@ -999,7 +999,7 @@ impl Backend { &'i mut dyn revm::Inspector>>, WrapDatabaseRef<&'db dyn DatabaseRef>, > { - let mut evm = new_evm_with_inspector_ref(db, env, inspector, self.alphanet); + let mut evm = new_evm_with_inspector_ref(db, env, inspector, self.odyssey); if let Some(factory) = &self.precompile_factory { inject_precompiles(&mut evm, factory.precompiles()); } @@ -1080,7 +1080,7 @@ impl Backend { enable_steps_tracing: self.enable_steps_tracing, print_logs: self.print_logs, precompile_factory: self.precompile_factory.clone(), - alphanet: self.alphanet, + odyssey: self.odyssey, }; // create a new pending block @@ -1162,7 +1162,7 @@ impl Backend { blob_gas_used: 0, enable_steps_tracing: self.enable_steps_tracing, print_logs: self.print_logs, - alphanet: self.alphanet, + odyssey: self.odyssey, precompile_factory: self.precompile_factory.clone(), }; let executed_tx = executor.execute(); diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index b75b088b0e1f4..9eb44c69b5297 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -808,7 +808,7 @@ async fn test_reorg() { // === wallet endpoints === // #[tokio::test(flavor = "multi_thread")] async fn can_get_wallet_capabilities() { - let (api, handle) = spawn(NodeConfig::test().with_alphanet(true)).await; + let (api, handle) = spawn(NodeConfig::test().with_odyssey(true)).await; let provider = handle.http_provider(); @@ -834,7 +834,7 @@ async fn can_get_wallet_capabilities() { #[tokio::test(flavor = "multi_thread")] async fn can_add_capability() { - let (api, _handle) = spawn(NodeConfig::test().with_alphanet(true)).await; + let (api, _handle) = spawn(NodeConfig::test().with_odyssey(true)).await; let init_capabilities = api.get_capabilities().unwrap(); @@ -864,7 +864,7 @@ async fn can_add_capability() { #[tokio::test(flavor = "multi_thread")] async fn can_set_executor() { - let (api, _handle) = spawn(NodeConfig::test().with_alphanet(true)).await; + let (api, _handle) = spawn(NodeConfig::test().with_odyssey(true)).await; let expected_addr = address!("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"); let pk = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 1704247dc7068..1383bea2771b1 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -73,9 +73,9 @@ pub struct CallArgs { #[arg(long, short)] block: Option, - /// Enable Alphanet features. - #[arg(long, alias = "odyssey")] - pub alphanet: bool, + /// Enable Odyssey features. + #[arg(long, alias = "alphanet")] + pub odyssey: bool, #[command(subcommand)] command: Option, @@ -180,7 +180,7 @@ impl CallArgs { } let create2_deployer = evm_opts.create2_deployer; - let (mut env, fork, chain, alphanet) = + let (mut env, fork, chain, odyssey) = TracingExecutor::get_fork_material(&config, evm_opts).await?; // modify settings that usually set in eth_call @@ -195,14 +195,8 @@ impl CallArgs { InternalTraceMode::None }) .with_state_changes(shell::verbosity() > 4); - let mut executor = TracingExecutor::new( - env, - fork, - evm_version, - trace_mode, - alphanet, - create2_deployer, - ); + let mut executor = + TracingExecutor::new(env, fork, evm_version, trace_mode, odyssey, create2_deployer); let value = tx.value.unwrap_or_default(); let input = tx.inner.input.into_input().unwrap_or_default(); @@ -247,8 +241,8 @@ impl figment::Provider for CallArgs { fn data(&self) -> Result, figment::Error> { let mut map = Map::new(); - if self.alphanet { - map.insert("alphanet".into(), self.alphanet.into()); + if self.odyssey { + map.insert("odyssey".into(), self.odyssey.into()); } if let Some(evm_version) = self.evm_version { diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 62a41ca6c9982..7ab5ddd511f90 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -85,9 +85,9 @@ pub struct RunArgs { #[arg(long, value_name = "NO_RATE_LIMITS", visible_alias = "no-rpc-rate-limit")] pub no_rate_limit: bool, - /// Enables Alphanet features. - #[arg(long, alias = "odyssey")] - pub alphanet: bool, + /// Enables Odyssey features. + #[arg(long, alias = "alphanet")] + pub odyssey: bool, /// Use current project artifacts for trace decoding. #[arg(long, visible_alias = "la")] @@ -138,7 +138,7 @@ impl RunArgs { config.fork_block_number = Some(tx_block_number - 1); let create2_deployer = evm_opts.create2_deployer; - let (mut env, fork, chain, alphanet) = + let (mut env, fork, chain, odyssey) = TracingExecutor::get_fork_material(&config, evm_opts).await?; let mut evm_version = self.evm_version; @@ -176,7 +176,7 @@ impl RunArgs { fork, evm_version, trace_mode, - alphanet, + odyssey, create2_deployer, ); let mut env = @@ -283,8 +283,8 @@ impl figment::Provider for RunArgs { fn data(&self) -> Result, figment::Error> { let mut map = Map::new(); - if self.alphanet { - map.insert("alphanet".into(), self.alphanet.into()); + if self.odyssey { + map.insert("odyssey".into(), self.odyssey.into()); } if let Some(api_key) = &self.etherscan.key { diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index dbcaf02aff0ad..dac5e6d9adf00 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -140,10 +140,10 @@ pub struct EvmArgs { #[serde(skip)] pub isolate: bool, - /// Whether to enable Alphanet features. - #[arg(long, alias = "odyssey")] + /// Whether to enable Odyssey features. + #[arg(long, alias = "alphanet")] #[serde(skip)] - pub alphanet: bool, + pub odyssey: bool, } // Make this set of options a `figment::Provider` so that it can be merged into the `Config` @@ -170,8 +170,8 @@ impl Provider for EvmArgs { dict.insert("isolate".to_string(), self.isolate.into()); } - if self.alphanet { - dict.insert("alphanet".to_string(), self.alphanet.into()); + if self.odyssey { + dict.insert("odyssey".to_string(), self.odyssey.into()); } if self.always_use_create_2_factory { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 08c1ed0ee4093..805aaf7cd1634 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -490,8 +490,9 @@ pub struct Config { #[serde(default, skip_serializing_if = "Option::is_none")] pub eof_version: Option, - /// Whether to enable Alphanet features. - pub alphanet: bool, + /// Whether to enable Odyssey features. + #[serde(alias = "alphanet")] + pub odyssey: bool, /// Timeout for transactions in seconds. pub transaction_timeout: u64, @@ -1128,7 +1129,7 @@ impl Config { /// Returns the [SpecId] derived from the configured [EvmVersion] #[inline] pub fn evm_spec_id(&self) -> SpecId { - evm_spec_id(self.evm_version, self.alphanet) + evm_spec_id(self.evm_version, self.odyssey) } /// Returns whether the compiler version should be auto-detected @@ -2373,7 +2374,7 @@ impl Default for Config { warnings: vec![], extra_args: vec![], eof_version: None, - alphanet: false, + odyssey: false, transaction_timeout: 120, additional_compiler_profiles: Default::default(), compilation_restrictions: Default::default(), diff --git a/crates/config/src/providers/ext.rs b/crates/config/src/providers/ext.rs index 040f2127cbee0..58f4184690b46 100644 --- a/crates/config/src/providers/ext.rs +++ b/crates/config/src/providers/ext.rs @@ -166,7 +166,7 @@ impl Provider for BackwardsCompatTomlProvider

{ } if let Some(v) = dict.remove("odyssey") { - dict.insert("alphanet".to_string(), v); + dict.insert("odyssey".to_string(), v); } map.insert(profile, dict); } diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 19f70a939e020..43b9b746899f7 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -259,8 +259,8 @@ impl FromStr for Numeric { /// Returns the [SpecId] derived from [EvmVersion] #[inline] -pub fn evm_spec_id(evm_version: EvmVersion, alphanet: bool) -> SpecId { - if alphanet { +pub fn evm_spec_id(evm_version: EvmVersion, odyssey: bool) -> SpecId { + if odyssey { return SpecId::OSAKA; } match evm_version { diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 0bdc34cc92ce3..30986d16188df 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -52,8 +52,8 @@ pub trait InspectorExt: for<'a> Inspector<&'a mut dyn DatabaseExt> { /// Simulates `console.log` invocation. fn console_log(&mut self, _input: String) {} - /// Returns `true` if the current network is Alphanet. - fn is_alphanet(&self) -> bool { + /// Returns `true` if the current network is Odyssey. + fn is_odyssey(&self) -> bool { false } diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index fec780b0fe6f5..76be5937bfde5 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -65,8 +65,8 @@ pub struct EvmOpts { /// Whether to disable block gas limit checks. pub disable_block_gas_limit: bool, - /// whether to enable Alphanet features. - pub alphanet: bool, + /// whether to enable Odyssey features. + pub odyssey: bool, /// The CREATE2 deployer's address. pub create2_deployer: Address, @@ -91,7 +91,7 @@ impl Default for EvmOpts { memory_limit: 0, isolate: false, disable_block_gas_limit: false, - alphanet: false, + odyssey: false, create2_deployer: DEFAULT_CREATE2_DEPLOYER, } } diff --git a/crates/evm/core/src/precompiles.rs b/crates/evm/core/src/precompiles.rs index 2544258d34433..ceaf6d004e936 100644 --- a/crates/evm/core/src/precompiles.rs +++ b/crates/evm/core/src/precompiles.rs @@ -46,13 +46,13 @@ pub const PRECOMPILES: &[Address] = &[ EC_PAIRING, BLAKE_2F, POINT_EVALUATION, - ALPHANET_P256_ADDRESS, + ODYSSEY_P256_ADDRESS, ]; -/// [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212) secp256r1 precompile address on Alphanet. +/// [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212) secp256r1 precompile address on Odyssey. /// -/// -pub const ALPHANET_P256_ADDRESS: Address = address!("0000000000000000000000000000000000000014"); +/// +pub const ODYSSEY_P256_ADDRESS: Address = address!("0000000000000000000000000000000000000014"); /// Wrapper around revm P256 precompile, matching EIP-7212 spec. /// @@ -69,5 +69,5 @@ pub fn p256_verify(input: &Bytes, gas_limit: u64) -> PrecompileResult { } /// [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212#specification) secp256r1 precompile. -pub const ALPHANET_P256: PrecompileWithAddress = - PrecompileWithAddress(ALPHANET_P256_ADDRESS, Precompile::Standard(p256_verify)); +pub const ODYSSEY_P256: PrecompileWithAddress = + PrecompileWithAddress(ODYSSEY_P256_ADDRESS, Precompile::Standard(p256_verify)); diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 0841d93401471..5ec396a169710 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -1,6 +1,6 @@ pub use crate::ic::*; use crate::{ - backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER_CODEHASH, precompiles::ALPHANET_P256, + backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER_CODEHASH, precompiles::ODYSSEY_P256, InspectorExt, }; use alloy_consensus::BlockHeader; @@ -279,13 +279,13 @@ pub fn create2_handler_register( }); } -/// Adds Alphanet P256 precompile to the list of loaded precompiles. -pub fn alphanet_handler_register(handler: &mut EvmHandler<'_, EXT, DB>) { +/// Adds Odyssey P256 precompile to the list of loaded precompiles. +pub fn odyssey_handler_register(handler: &mut EvmHandler<'_, EXT, DB>) { let prev = handler.pre_execution.load_precompiles.clone(); handler.pre_execution.load_precompiles = Arc::new(move || { let mut loaded_precompiles = prev(); - loaded_precompiles.extend([ALPHANET_P256]); + loaded_precompiles.extend([ODYSSEY_P256]); loaded_precompiles }); @@ -314,8 +314,8 @@ pub fn new_evm_with_inspector<'evm, 'i, 'db, I: InspectorExt + ?Sized>( let mut handler = revm::Handler::new(handler_cfg); handler.append_handler_register_plain(revm::inspector_handle_register); - if inspector.is_alphanet() { - handler.append_handler_register_plain(alphanet_handler_register); + if inspector.is_odyssey() { + handler.append_handler_register_plain(odyssey_handler_register); } handler.append_handler_register_plain(create2_handler_register); @@ -332,8 +332,8 @@ pub fn new_evm_with_existing_context<'a>( let mut handler = revm::Handler::new(handler_cfg); handler.append_handler_register_plain(revm::inspector_handle_register); - if inspector.is_alphanet() { - handler.append_handler_register_plain(alphanet_handler_register); + if inspector.is_odyssey() { + handler.append_handler_register_plain(odyssey_handler_register); } handler.append_handler_register_plain(create2_handler_register); diff --git a/crates/evm/evm/src/executors/trace.rs b/crates/evm/evm/src/executors/trace.rs index d9c0d74f6e97f..b55517a672d57 100644 --- a/crates/evm/evm/src/executors/trace.rs +++ b/crates/evm/evm/src/executors/trace.rs @@ -18,7 +18,7 @@ impl TracingExecutor { fork: Option, version: Option, trace_mode: TraceMode, - alphanet: bool, + odyssey: bool, create2_deployer: Address, ) -> Self { let db = Backend::spawn(fork); @@ -27,12 +27,9 @@ impl TracingExecutor { // tracing will be enabled only for the targeted transaction executor: ExecutorBuilder::new() .inspectors(|stack| { - stack - .trace_mode(trace_mode) - .alphanet(alphanet) - .create2_deployer(create2_deployer) + stack.trace_mode(trace_mode).odyssey(odyssey).create2_deployer(create2_deployer) }) - .spec_id(evm_spec_id(version.unwrap_or_default(), alphanet)) + .spec_id(evm_spec_id(version.unwrap_or_default(), odyssey)) .build(env, db), } } @@ -54,7 +51,7 @@ impl TracingExecutor { let fork = evm_opts.get_fork(config, env.clone()); - Ok((env, fork, evm_opts.get_remote_chain_id().await, evm_opts.alphanet)) + Ok((env, fork, evm_opts.get_remote_chain_id().await, evm_opts.odyssey)) } } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 94ec349b1f53e..385623f5a07ab 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -55,8 +55,8 @@ pub struct InspectorStackBuilder { /// In isolation mode all top-level calls are executed as a separate transaction in a separate /// EVM context, enabling more precise gas accounting and transaction state changes. pub enable_isolation: bool, - /// Whether to enable Alphanet features. - pub alphanet: bool, + /// Whether to enable Odyssey features. + pub odyssey: bool, /// The wallets to set in the cheatcodes context. pub wallets: Option, /// The CREATE2 deployer address. @@ -150,11 +150,11 @@ impl InspectorStackBuilder { self } - /// Set whether to enable Alphanet features. + /// Set whether to enable Odyssey features. /// For description of call isolation, see [`InspectorStack::enable_isolation`]. #[inline] - pub fn alphanet(mut self, yes: bool) -> Self { - self.alphanet = yes; + pub fn odyssey(mut self, yes: bool) -> Self { + self.odyssey = yes; self } @@ -177,7 +177,7 @@ impl InspectorStackBuilder { print, chisel_state, enable_isolation, - alphanet, + odyssey, wallets, create2_deployer, } = self; @@ -205,7 +205,7 @@ impl InspectorStackBuilder { stack.tracing(trace_mode); stack.enable_isolation(enable_isolation); - stack.alphanet(alphanet); + stack.odyssey(odyssey); stack.set_create2_deployer(create2_deployer); // environment, must come after all of the inspectors @@ -291,7 +291,7 @@ pub struct InspectorStackInner { pub printer: Option, pub tracer: Option, pub enable_isolation: bool, - pub alphanet: bool, + pub odyssey: bool, pub create2_deployer: Address, /// Flag marking if we are in the inner EVM context. @@ -405,8 +405,8 @@ impl InspectorStack { /// Set whether to enable call isolation. #[inline] - pub fn alphanet(&mut self, yes: bool) { - self.alphanet = yes; + pub fn odyssey(&mut self, yes: bool) { + self.odyssey = yes; } /// Set the CREATE2 deployer address. @@ -1036,8 +1036,8 @@ impl InspectorExt for InspectorStackRefMut<'_> { )); } - fn is_alphanet(&self) -> bool { - self.inner.alphanet + fn is_odyssey(&self) -> bool { + self.inner.odyssey } fn create2_deployer(&self) -> Address { @@ -1142,8 +1142,8 @@ impl InspectorExt for InspectorStack { self.as_mut().should_use_create2_factory(ecx, inputs) } - fn is_alphanet(&self) -> bool { - self.alphanet + fn is_odyssey(&self) -> bool { + self.odyssey } fn create2_deployer(&self) -> Address { diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 5f245d0027695..75200f4b44966 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -355,7 +355,7 @@ impl TestArgs { .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .enable_isolation(evm_opts.isolate) - .alphanet(evm_opts.alphanet) + .odyssey(evm_opts.odyssey) .build::(project_root, &output, env, evm_opts)?; let mut maybe_override_mt = |flag, maybe_regex: Option<&Option>| { diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 9240c6f27eaf1..4de95d7b65559 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -288,8 +288,8 @@ pub struct TestRunnerConfig { pub decode_internal: InternalTraceMode, /// Whether to enable call isolation. pub isolation: bool, - /// Whether to enable Alphanet features. - pub alphanet: bool, + /// Whether to enable Odyssey features. + pub odyssey: bool, } impl TestRunnerConfig { @@ -305,7 +305,7 @@ impl TestRunnerConfig { // self.debug = N/A; // self.decode_internal = N/A; // self.isolation = N/A; - self.alphanet = config.alphanet; + self.odyssey = config.odyssey; self.config = config; } @@ -323,7 +323,7 @@ impl TestRunnerConfig { inspector.tracing(self.trace_mode()); inspector.collect_coverage(self.coverage); inspector.enable_isolation(self.isolation); - inspector.alphanet(self.alphanet); + inspector.odyssey(self.odyssey); // inspector.set_create2_deployer(self.evm_opts.create2_deployer); // executor.env_mut().clone_from(&self.env); @@ -353,7 +353,7 @@ impl TestRunnerConfig { .trace_mode(self.trace_mode()) .coverage(self.coverage) .enable_isolation(self.isolation) - .alphanet(self.alphanet) + .odyssey(self.odyssey) .create2_deployer(self.evm_opts.create2_deployer) }) .spec_id(self.spec_id) @@ -394,8 +394,8 @@ pub struct MultiContractRunnerBuilder { pub decode_internal: InternalTraceMode, /// Whether to enable call isolation pub isolation: bool, - /// Whether to enable Alphanet features. - pub alphanet: bool, + /// Whether to enable Odyssey features. + pub odyssey: bool, } impl MultiContractRunnerBuilder { @@ -410,7 +410,7 @@ impl MultiContractRunnerBuilder { debug: Default::default(), isolation: Default::default(), decode_internal: Default::default(), - alphanet: Default::default(), + odyssey: Default::default(), } } @@ -454,8 +454,8 @@ impl MultiContractRunnerBuilder { self } - pub fn alphanet(mut self, enable: bool) -> Self { - self.alphanet = enable; + pub fn odyssey(mut self, enable: bool) -> Self { + self.odyssey = enable; self } @@ -533,7 +533,7 @@ impl MultiContractRunnerBuilder { decode_internal: self.decode_internal, inline_config: Arc::new(InlineConfig::new_parsed(output, &self.config)?), isolation: self.isolation, - alphanet: self.alphanet, + odyssey: self.odyssey, config: self.config, }, diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 6f70f845c0454..545cebac87a8e 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -156,7 +156,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { legacy_assertions: false, extra_args: vec![], eof_version: None, - alphanet: false, + odyssey: false, transaction_timeout: 120, additional_compiler_profiles: Default::default(), compilation_restrictions: Default::default(), diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index d59dbc6bedd64..abcaf1803fee5 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -4,7 +4,6 @@ extern crate foundry_test_utils; pub mod constants; pub mod utils; -mod alphanet; mod bind_json; mod build; mod cache; @@ -20,6 +19,7 @@ mod eip712; mod geiger; mod inline_config; mod multi_script; +mod odyssey; mod script; mod soldeer; mod svm; diff --git a/crates/forge/tests/cli/alphanet.rs b/crates/forge/tests/cli/odyssey.rs similarity index 100% rename from crates/forge/tests/cli/alphanet.rs rename to crates/forge/tests/cli/odyssey.rs diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 7aa18dcbe5c78..ab59569c76e40 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -615,7 +615,7 @@ impl ScriptConfig { .inspectors(|stack| { stack .trace_mode(if debug { TraceMode::Debug } else { TraceMode::Call }) - .alphanet(self.evm_opts.alphanet) + .odyssey(self.evm_opts.odyssey) .create2_deployer(self.evm_opts.create2_deployer) }) .spec_id(self.config.evm_spec_id()) diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 824e784435994..6165fa71862ca 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -329,7 +329,7 @@ pub async fn get_tracing_executor( fork_config.evm_version = evm_version; let create2_deployer = evm_opts.create2_deployer; - let (env, fork, _chain, is_alphanet) = + let (env, fork, _chain, is_odyssey) = TracingExecutor::get_fork_material(fork_config, evm_opts).await?; let executor = TracingExecutor::new( @@ -337,7 +337,7 @@ pub async fn get_tracing_executor( fork, Some(fork_config.evm_version), TraceMode::Call, - is_alphanet, + is_odyssey, create2_deployer, ); From a4de7e812bca8962e7d30ab83890712adbf4a539 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:34:32 +0100 Subject: [PATCH 1771/1963] feat: add JSON compatibility for `forge test --summary +/ --detailed` + apply consistent table styling (#9485) * support summary reports in json * unify table style, when show_metrics is enabled and --json, do render * apply consistent formatting and ordering and spacing for tables * clean up * make tables consistent * update layouts, fix tests * clean up * change ReportKind::Markdown to ReportKind::Text as the output is not strictly Markdown compatible * json compatibility for invariant metrics is not necessary due to different branching and could be derived from JSON * remove redundant spacer * clean up, revert InvariantMetricsReporter --- crates/cast/bin/cmd/storage.rs | 18 +- crates/cast/tests/cli/main.rs | 25 +- crates/common/fmt/src/eof.rs | 6 +- crates/common/src/compile.rs | 40 +- crates/common/src/reports.rs | 4 +- crates/forge/bin/cmd/coverage.rs | 6 +- crates/forge/bin/cmd/inspect.rs | 24 +- crates/forge/bin/cmd/selectors.rs | 11 +- crates/forge/bin/cmd/test/mod.rs | 26 +- crates/forge/bin/cmd/test/summary.rs | 182 ++++++--- crates/forge/src/coverage.rs | 23 +- crates/forge/src/gas_report.rs | 52 +-- crates/forge/tests/cli/build.rs | 56 +-- crates/forge/tests/cli/cmd.rs | 502 +++++++++++++++++------- crates/forge/tests/cli/coverage.rs | 137 +++++-- crates/forge/tests/cli/inline_config.rs | 12 +- crates/forge/tests/it/invariant.rs | 38 +- 17 files changed, 796 insertions(+), 366 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 468f20b27ae1b..7121f1a98c416 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -6,7 +6,7 @@ use alloy_rpc_types::BlockId; use alloy_transport::Transport; use cast::Cast; use clap::Parser; -use comfy_table::{presets::ASCII_MARKDOWN, Table}; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Table}; use eyre::Result; use foundry_block_explorers::Client; use foundry_cli::{ @@ -288,8 +288,18 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) } let mut table = Table::new(); - table.load_preset(ASCII_MARKDOWN); - table.set_header(["Name", "Type", "Slot", "Offset", "Bytes", "Value", "Hex Value", "Contract"]); + table.apply_modifier(UTF8_ROUND_CORNERS); + + table.set_header(vec![ + Cell::new("Name"), + Cell::new("Type"), + Cell::new("Slot"), + Cell::new("Offset"), + Cell::new("Bytes"), + Cell::new("Value"), + Cell::new("Hex Value"), + Cell::new("Contract"), + ]); for (slot, storage_value) in layout.storage.into_iter().zip(values) { let storage_type = layout.types.get(&slot.storage_type); @@ -309,7 +319,7 @@ fn print_storage(layout: StorageLayout, values: Vec, pretty: bool) ]); } - sh_println!("{table}")?; + sh_println!("\n{table}\n")?; Ok(()) } diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index fe9309877b6aa..f2ee990095470 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1131,10 +1131,15 @@ casttest!(storage_layout_simple, |_prj, cmd| { ]) .assert_success() .stdout_eq(str![[r#" + +╭---------+---------+------+--------+-------+-------+--------------------------------------------------------------------+-----------------------------------------------╮ | Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | -|---------|---------|------|--------|-------|-------|--------------------------------------------------------------------|-----------------------------------------------| ++========================================================================================================================================================================+ | _owner | address | 0 | 0 | 20 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/Create2Deployer.sol:Create2Deployer | +|---------+---------+------+--------+-------+-------+--------------------------------------------------------------------+-----------------------------------------------| | _paused | bool | 0 | 20 | 1 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/Create2Deployer.sol:Create2Deployer | +╰---------+---------+------+--------+-------+-------+--------------------------------------------------------------------+-----------------------------------------------╯ + "#]]); }); @@ -1170,21 +1175,37 @@ casttest!(storage_layout_complex, |_prj, cmd| { ]) .assert_success() .stdout_eq(str![[r#" + +╭-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------╮ | Name | Type | Slot | Offset | Bytes | Value | Hex Value | Contract | -|-------------------------------|--------------------------------------------------------------------|------|--------|-------|--------------------------------------------------|--------------------------------------------------------------------|---------------------------------| ++======================================================================================================================================================================================================================================================================================+ | _status | uint256 | 0 | 0 | 32 | 1 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _generalPoolsBalances | mapping(bytes32 => struct EnumerableMap.IERC20ToBytes32Map) | 1 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _nextNonce | mapping(address => uint256) | 2 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _paused | bool | 3 | 0 | 1 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _authorizer | contract IAuthorizer | 3 | 1 | 20 | 549683469959765988649777481110995959958745616871 | 0x0000000000000000000000006048a8c631fb7e77eca533cf9c29784e482391e7 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _approvedRelayers | mapping(address => mapping(address => bool)) | 4 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _isPoolRegistered | mapping(bytes32 => bool) | 5 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _nextPoolNonce | uint256 | 6 | 0 | 32 | 1760 | 0x00000000000000000000000000000000000000000000000000000000000006e0 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _minimalSwapInfoPoolsBalances | mapping(bytes32 => mapping(contract IERC20 => bytes32)) | 7 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _minimalSwapInfoPoolsTokens | mapping(bytes32 => struct EnumerableSet.AddressSet) | 8 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _twoTokenPoolTokens | mapping(bytes32 => struct TwoTokenPoolsBalance.TwoTokenPoolTokens) | 9 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _poolAssetManagers | mapping(bytes32 => mapping(contract IERC20 => address)) | 10 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +|-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------| | _internalTokenBalance | mapping(address => mapping(contract IERC20 => uint256)) | 11 | 0 | 32 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/vault/Vault.sol:Vault | +╰-------------------------------+--------------------------------------------------------------------+------+--------+-------+--------------------------------------------------+--------------------------------------------------------------------+---------------------------------╯ + "#]]); }); diff --git a/crates/common/fmt/src/eof.rs b/crates/common/fmt/src/eof.rs index 639e175b45eaa..1ae9de70b6b3a 100644 --- a/crates/common/fmt/src/eof.rs +++ b/crates/common/fmt/src/eof.rs @@ -1,4 +1,4 @@ -use comfy_table::{ContentArrangement, Table}; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, ContentArrangement, Table}; use revm_primitives::{ eof::{EofBody, EofHeader}, Eof, @@ -24,6 +24,7 @@ pub fn pretty_eof(eof: &Eof) -> Result { let mut result = String::new(); let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); table.add_row(vec!["type_size", &types_size.to_string()]); table.add_row(vec!["num_code_sections", &code_sizes.len().to_string()]); if !code_sizes.is_empty() { @@ -39,6 +40,7 @@ pub fn pretty_eof(eof: &Eof) -> Result { if !code_section.is_empty() { let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); table.set_content_arrangement(ContentArrangement::Dynamic); table.set_header(vec!["", "Inputs", "Outputs", "Max stack height", "Code"]); for (idx, (code, type_section)) in code_section.iter().zip(types_section).enumerate() { @@ -56,6 +58,7 @@ pub fn pretty_eof(eof: &Eof) -> Result { if !container_section.is_empty() { let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); table.set_content_arrangement(ContentArrangement::Dynamic); for (idx, container) in container_section.iter().enumerate() { table.add_row(vec![&idx.to_string(), &container.to_string()]); @@ -66,6 +69,7 @@ pub fn pretty_eof(eof: &Eof) -> Result { if !data_section.is_empty() { let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); table.set_content_arrangement(ContentArrangement::Dynamic); table.add_row(vec![&data_section.to_string()]); write!(result, "\n\nData section:\n{table}")?; diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 47fe226d98db5..5f14c066125f2 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -6,7 +6,7 @@ use crate::{ term::SpinnerReporter, TestFunctionExt, }; -use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, Table}; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Color, Table}; use eyre::Result; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ @@ -341,9 +341,8 @@ impl SizeReport { impl Display for SizeReport { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { match self.report_kind { - ReportKind::Markdown => { - let table = self.format_table_output(); - writeln!(f, "{table}")?; + ReportKind::Text => { + writeln!(f, "\n{}", self.format_table_output())?; } ReportKind::JSON => { writeln!(f, "{}", self.format_json_output())?; @@ -378,13 +377,14 @@ impl SizeReport { fn format_table_output(&self) -> Table { let mut table = Table::new(); - table.load_preset(ASCII_MARKDOWN); - table.set_header([ - Cell::new("Contract").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Runtime Size (B)").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Initcode Size (B)").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Runtime Margin (B)").add_attribute(Attribute::Bold).fg(Color::Blue), - Cell::new("Initcode Margin (B)").add_attribute(Attribute::Bold).fg(Color::Blue), + table.apply_modifier(UTF8_ROUND_CORNERS); + + table.set_header(vec![ + Cell::new("Contract"), + Cell::new("Runtime Size (B)"), + Cell::new("Initcode Size (B)"), + Cell::new("Runtime Margin (B)"), + Cell::new("Initcode Margin (B)"), ]); // Filters out dev contracts (Test or Script) @@ -411,19 +411,11 @@ impl SizeReport { let locale = &Locale::en; table.add_row([ - Cell::new(name).fg(Color::Blue), - Cell::new(contract.runtime_size.to_formatted_string(locale)) - .set_alignment(CellAlignment::Right) - .fg(runtime_color), - Cell::new(contract.init_size.to_formatted_string(locale)) - .set_alignment(CellAlignment::Right) - .fg(init_color), - Cell::new(runtime_margin.to_formatted_string(locale)) - .set_alignment(CellAlignment::Right) - .fg(runtime_color), - Cell::new(init_margin.to_formatted_string(locale)) - .set_alignment(CellAlignment::Right) - .fg(init_color), + Cell::new(name), + Cell::new(contract.runtime_size.to_formatted_string(locale)).fg(runtime_color), + Cell::new(contract.init_size.to_formatted_string(locale)).fg(init_color), + Cell::new(runtime_margin.to_formatted_string(locale)).fg(runtime_color), + Cell::new(init_margin.to_formatted_string(locale)).fg(init_color), ]); } diff --git a/crates/common/src/reports.rs b/crates/common/src/reports.rs index adbdc11bf66a9..0fdf4502eb68b 100644 --- a/crates/common/src/reports.rs +++ b/crates/common/src/reports.rs @@ -5,7 +5,7 @@ use crate::shell; #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum ReportKind { #[default] - Markdown, + Text, JSON, } @@ -14,6 +14,6 @@ pub fn report_kind() -> ReportKind { if shell::is_json() { ReportKind::JSON } else { - ReportKind::Markdown + ReportKind::Text } } diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 4e99cb13f7dfb..48bc8349c633d 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -6,8 +6,8 @@ use forge::{ coverage::{ analysis::{SourceAnalysis, SourceAnalyzer, SourceFile, SourceFiles}, anchors::find_anchors, - BytecodeReporter, ContractId, CoverageReport, CoverageReporter, DebugReporter, ItemAnchor, - LcovReporter, SummaryReporter, + BytecodeReporter, ContractId, CoverageReport, CoverageReporter, CoverageSummaryReporter, + DebugReporter, ItemAnchor, LcovReporter, }, opts::EvmOpts, utils::IcPcMap, @@ -302,7 +302,7 @@ impl CoverageArgs { // Output final report for report_kind in self.report { match report_kind { - CoverageReportKind::Summary => SummaryReporter::default().report(&report), + CoverageReportKind::Summary => CoverageSummaryReporter::default().report(&report), CoverageReportKind::Lcov => { let path = root.join(self.report_file.as_deref().unwrap_or("lcov.info".as_ref())); diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 5c7c224f7fd56..426a8b36e04a6 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -1,10 +1,10 @@ use alloy_primitives::{hex, keccak256, Address}; use clap::Parser; -use comfy_table::{presets::ASCII_MARKDOWN, Table}; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Table}; use eyre::{Context, Result}; use forge::revm::primitives::Eof; use foundry_cli::opts::{CompilerArgs, CoreBuildArgs}; -use foundry_common::{compile::ProjectCompiler, fmt::pretty_eof}; +use foundry_common::{compile::ProjectCompiler, fmt::pretty_eof, shell}; use foundry_compilers::{ artifacts::{ output_selection::{ @@ -111,7 +111,7 @@ impl InspectArgs { print_json(&artifact.gas_estimates)?; } ContractArtifactField::StorageLayout => { - print_storage_layout(artifact.storage_layout.as_ref(), pretty)?; + print_storage_layout(artifact.storage_layout.as_ref())?; } ContractArtifactField::DevDoc => { print_json(&artifact.devdoc)?; @@ -176,18 +176,26 @@ impl InspectArgs { } } -pub fn print_storage_layout(storage_layout: Option<&StorageLayout>, pretty: bool) -> Result<()> { +pub fn print_storage_layout(storage_layout: Option<&StorageLayout>) -> Result<()> { let Some(storage_layout) = storage_layout else { eyre::bail!("Could not get storage layout"); }; - if !pretty { + if shell::is_json() { return print_json(&storage_layout) } let mut table = Table::new(); - table.load_preset(ASCII_MARKDOWN); - table.set_header(["Name", "Type", "Slot", "Offset", "Bytes", "Contract"]); + table.apply_modifier(UTF8_ROUND_CORNERS); + + table.set_header(vec![ + Cell::new("Name"), + Cell::new("Type"), + Cell::new("Slot"), + Cell::new("Offset"), + Cell::new("Bytes"), + Cell::new("Contract"), + ]); for slot in &storage_layout.storage { let storage_type = storage_layout.types.get(&slot.storage_type); @@ -201,7 +209,7 @@ pub fn print_storage_layout(storage_layout: Option<&StorageLayout>, pretty: bool ]); } - sh_println!("{table}")?; + sh_println!("\n{table}\n")?; Ok(()) } diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index f75dabaff449b..31992983d2f3d 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -1,6 +1,6 @@ use alloy_primitives::hex; use clap::Parser; -use comfy_table::Table; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Table}; use eyre::Result; use foundry_cli::{ opts::{CompilerArgs, CoreBuildArgs, ProjectPathsArgs}, @@ -198,6 +198,7 @@ impl SelectorsSubcommands { sh_println!("No colliding method selectors between the two contracts.")?; } else { let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); table.set_header([ String::from("Selector"), first_contract.name, @@ -207,7 +208,7 @@ impl SelectorsSubcommands { table.add_row([method.0, method.1, method.2]); } sh_println!("{} collisions found:", colliding_methods.len())?; - sh_println!("{table}")?; + sh_println!("\n{table}\n")?; } } Self::List { contract, project_paths } => { @@ -267,6 +268,7 @@ impl SelectorsSubcommands { sh_println!("{contract}")?; let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); table.set_header(["Type", "Signature", "Selector"]); @@ -288,7 +290,7 @@ impl SelectorsSubcommands { table.add_row(["Error", &sig, &hex::encode_prefixed(selector)]); } - sh_println!("{table}")?; + sh_println!("\n{table}\n")?; if artifacts.peek().is_some() { sh_println!()? @@ -320,6 +322,7 @@ impl SelectorsSubcommands { .collect::>(); let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); table.set_header(["Type", "Signature", "Selector", "Contract"]); @@ -365,7 +368,7 @@ impl SelectorsSubcommands { if table.row_count() > 0 { sh_println!("\nFound {} instance(s)...", table.row_count())?; - sh_println!("{table}")?; + sh_println!("\n{table}\n")?; } else { return Err(eyre::eyre!("\nSelector not found in the project.")); } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 75200f4b44966..c55eb520ae256 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -53,13 +53,10 @@ use yansi::Paint; mod filter; mod summary; - -use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; -use summary::TestSummaryReporter; - -use crate::cmd::test::summary::print_invariant_metrics; pub use filter::FilterArgs; use forge::{result::TestKind, traces::render_trace_arena_inner}; +use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; +use summary::{print_invariant_metrics, TestSummaryReport}; // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_args); @@ -471,7 +468,7 @@ impl TestArgs { trace!(target: "forge::test", "running all tests"); // If we need to render to a serialized format, we should not print anything else to stdout. - let silent = self.gas_report && shell::is_json(); + let silent = self.gas_report && shell::is_json() || self.summary && shell::is_json(); let num_filtered = runner.matching_test_functions(filter).count(); if num_filtered != 1 && (self.debug.is_some() || self.flamegraph || self.flamechart) { @@ -499,7 +496,7 @@ impl TestArgs { } // Run tests in a non-streaming fashion and collect results for serialization. - if !self.gas_report && shell::is_json() { + if !self.gas_report && !self.summary && shell::is_json() { let mut results = runner.test_collect(filter); results.values_mut().for_each(|suite_result| { for test_result in suite_result.test_results.values_mut() { @@ -609,9 +606,7 @@ impl TestArgs { sh_println!("{}", result.short_result(name))?; // Display invariant metrics if invariant kind. - if let TestKind::Invariant { runs: _, calls: _, reverts: _, metrics } = - &result.kind - { + if let TestKind::Invariant { metrics, .. } = &result.kind { print_invariant_metrics(metrics); } @@ -797,14 +792,13 @@ impl TestArgs { outcome.gas_report = Some(finalized); } - if !silent && !outcome.results.is_empty() { + if !self.summary && !shell::is_json() { sh_println!("{}", outcome.summary(duration))?; + } - if self.summary { - let mut summary_table = TestSummaryReporter::new(self.detailed); - sh_println!("\n\nTest Summary:")?; - summary_table.print_summary(&outcome); - } + if self.summary && !outcome.results.is_empty() { + let summary_report = TestSummaryReport::new(self.detailed, outcome.clone()); + sh_println!("{}", &summary_report)?; } // Reattach the task. diff --git a/crates/forge/bin/cmd/test/summary.rs b/crates/forge/bin/cmd/test/summary.rs index 1922ce53bf18b..eabf7bd9eaaa3 100644 --- a/crates/forge/bin/cmd/test/summary.rs +++ b/crates/forge/bin/cmd/test/summary.rs @@ -1,71 +1,99 @@ use crate::cmd::test::TestOutcome; -use comfy_table::{ - modifiers::UTF8_ROUND_CORNERS, presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, - Row, Table, -}; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Color, Row, Table}; +use foundry_common::reports::{report_kind, ReportKind}; use foundry_evm::executors::invariant::InvariantMetrics; use itertools::Itertools; -use std::collections::HashMap; +use serde_json::json; +use std::{collections::HashMap, fmt::Display}; + +/// Represents a test summary report. +pub struct TestSummaryReport { + /// The kind of report to generate. + report_kind: ReportKind, + /// Whether the report should be detailed. + is_detailed: bool, + /// The test outcome to report. + outcome: TestOutcome, +} -/// A simple summary reporter that prints the test results in a table. -pub struct TestSummaryReporter { - /// The test summary table. - pub(crate) table: Table, - pub(crate) is_detailed: bool, +impl TestSummaryReport { + pub fn new(is_detailed: bool, outcome: TestOutcome) -> Self { + Self { report_kind: report_kind(), is_detailed, outcome } + } } -impl TestSummaryReporter { - pub(crate) fn new(is_detailed: bool) -> Self { +impl Display for TestSummaryReport { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + match self.report_kind { + ReportKind::Text => { + writeln!(f, "\n{}", &self.format_table_output(&self.is_detailed, &self.outcome))?; + } + ReportKind::JSON => { + writeln!(f, "{}", &self.format_json_output(&self.is_detailed, &self.outcome))?; + } + } + + Ok(()) + } +} + +impl TestSummaryReport { + // Helper function to format the JSON output. + fn format_json_output(&self, is_detailed: &bool, outcome: &TestOutcome) -> String { + let output = json!({ + "results": outcome.results.iter().map(|(contract, suite)| { + let (suite_path, suite_name) = contract.split_once(':').unwrap(); + let passed = suite.successes().count(); + let failed = suite.failures().count(); + let skipped = suite.skips().count(); + let mut result = json!({ + "suite": suite_name, + "passed": passed, + "failed": failed, + "skipped": skipped, + }); + + if *is_detailed { + result["file_path"] = serde_json::Value::String(suite_path.to_string()); + result["duration"] = serde_json::Value::String(format!("{:.2?}", suite.duration)); + } + + result + }).collect::>(), + }); + + serde_json::to_string_pretty(&output).unwrap() + } + + fn format_table_output(&self, is_detailed: &bool, outcome: &TestOutcome) -> Table { let mut table = Table::new(); table.apply_modifier(UTF8_ROUND_CORNERS); + let mut row = Row::from(vec![ - Cell::new("Test Suite") - .set_alignment(CellAlignment::Center) - .add_attribute(Attribute::Bold), - Cell::new("Passed") - .set_alignment(CellAlignment::Center) - .add_attribute(Attribute::Bold) - .fg(Color::Green), - Cell::new("Failed") - .set_alignment(CellAlignment::Center) - .add_attribute(Attribute::Bold) - .fg(Color::Red), - Cell::new("Skipped") - .set_alignment(CellAlignment::Center) - .add_attribute(Attribute::Bold) - .fg(Color::Yellow), + Cell::new("Test Suite"), + Cell::new("Passed").fg(Color::Green), + Cell::new("Failed").fg(Color::Red), + Cell::new("Skipped").fg(Color::Yellow), ]); - if is_detailed { - row.add_cell( - Cell::new("File Path") - .set_alignment(CellAlignment::Center) - .add_attribute(Attribute::Bold), - ); - row.add_cell( - Cell::new("Duration") - .set_alignment(CellAlignment::Center) - .add_attribute(Attribute::Bold), - ); + if *is_detailed { + row.add_cell(Cell::new("File Path").fg(Color::Cyan)); + row.add_cell(Cell::new("Duration").fg(Color::Cyan)); } table.set_header(row); - Self { table, is_detailed } - } - - pub(crate) fn print_summary(&mut self, outcome: &TestOutcome) { // Traverse the test_results vector and build the table for (contract, suite) in &outcome.results { let mut row = Row::new(); let (suite_path, suite_name) = contract.split_once(':').unwrap(); let passed = suite.successes().count(); - let mut passed_cell = Cell::new(passed).set_alignment(CellAlignment::Center); + let mut passed_cell = Cell::new(passed); let failed = suite.failures().count(); - let mut failed_cell = Cell::new(failed).set_alignment(CellAlignment::Center); + let mut failed_cell = Cell::new(failed); let skipped = suite.skips().count(); - let mut skipped_cell = Cell::new(skipped).set_alignment(CellAlignment::Center); + let mut skipped_cell = Cell::new(skipped); row.add_cell(Cell::new(suite_name)); @@ -89,43 +117,75 @@ impl TestSummaryReporter { row.add_cell(Cell::new(format!("{:.2?}", suite.duration).to_string())); } - self.table.add_row(row); + table.add_row(row); } - let _ = sh_println!("\n{}", self.table); + table } } -/// Helper to create and render invariant metrics summary table: +/// Helper function to print the invariant metrics. +/// +/// ╭-----------------------+----------------+-------+---------+----------╮ /// | Contract | Selector | Calls | Reverts | Discards | -/// |-----------------------|----------------|-------|---------|----------| -/// | AnotherCounterHandler | doWork | 7451 | 123 | 4941 | -/// | AnotherCounterHandler | doWorkThing | 7279 | 137 | 4849 | -/// | CounterHandler | doAnotherThing | 7302 | 150 | 4794 | -/// | CounterHandler | doSomething | 7382 | 160 | 4830 | +/// +=====================================================================+ +/// | AnotherCounterHandler | doWork | 7451 | 123 | 4941 | +/// |-----------------------+----------------+-------+---------+----------| +/// | AnotherCounterHandler | doWorkThing | 7279 | 137 | 4849 | +/// |-----------------------+----------------+-------+---------+----------| +/// | CounterHandler | doAnotherThing | 7302 | 150 | 4794 | +/// |-----------------------+----------------+-------+---------+----------| +/// | CounterHandler | doSomething | 7382 | 160 |4794 | +/// ╰-----------------------+----------------+-------+---------+----------╯ pub(crate) fn print_invariant_metrics(test_metrics: &HashMap) { if !test_metrics.is_empty() { let mut table = Table::new(); - table.load_preset(ASCII_MARKDOWN); - table.set_header(["Contract", "Selector", "Calls", "Reverts", "Discards"]); + table.apply_modifier(UTF8_ROUND_CORNERS); + + table.set_header(vec![ + Cell::new("Contract"), + Cell::new("Selector"), + Cell::new("Calls").fg(Color::Green), + Cell::new("Reverts").fg(Color::Red), + Cell::new("Discards").fg(Color::Yellow), + ]); for name in test_metrics.keys().sorted() { if let Some((contract, selector)) = name.split_once(':').and_then(|(_, contract)| contract.split_once('.')) { let mut row = Row::new(); - row.add_cell(Cell::new(contract).set_alignment(CellAlignment::Left)); - row.add_cell(Cell::new(selector).set_alignment(CellAlignment::Left)); + row.add_cell(Cell::new(contract)); + row.add_cell(Cell::new(selector)); + if let Some(metrics) = test_metrics.get(name) { - row.add_cell(Cell::new(metrics.calls).set_alignment(CellAlignment::Center)); - row.add_cell(Cell::new(metrics.reverts).set_alignment(CellAlignment::Center)); - row.add_cell(Cell::new(metrics.discards).set_alignment(CellAlignment::Center)); + let calls_cell = Cell::new(metrics.calls).fg(if metrics.calls > 0 { + Color::Green + } else { + Color::White + }); + + let reverts_cell = Cell::new(metrics.reverts).fg(if metrics.reverts > 0 { + Color::Red + } else { + Color::White + }); + + let discards_cell = Cell::new(metrics.discards).fg(if metrics.discards > 0 { + Color::Yellow + } else { + Color::White + }); + + row.add_cell(calls_cell); + row.add_cell(reverts_cell); + row.add_cell(discards_cell); } table.add_row(row); } } - let _ = sh_println!("{table}\n"); + let _ = sh_println!("\n{table}\n"); } } diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 813480b405230..ff3cac46eb886 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -1,7 +1,7 @@ //! Coverage reports. use alloy_primitives::map::HashMap; -use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Row, Table}; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Attribute, Cell, Color, Row, Table}; use evm_disassembler::disassemble_bytes; use foundry_common::fs; use semver::Version; @@ -19,24 +19,31 @@ pub trait CoverageReporter { } /// A simple summary reporter that prints the coverage results in a table. -pub struct SummaryReporter { +pub struct CoverageSummaryReporter { /// The summary table. table: Table, /// The total coverage of the entire project. total: CoverageSummary, } -impl Default for SummaryReporter { +impl Default for CoverageSummaryReporter { fn default() -> Self { let mut table = Table::new(); - table.load_preset(ASCII_MARKDOWN); - table.set_header(["File", "% Lines", "% Statements", "% Branches", "% Funcs"]); + table.apply_modifier(UTF8_ROUND_CORNERS); + + table.set_header(vec![ + Cell::new("File"), + Cell::new("% Lines"), + Cell::new("% Statements"), + Cell::new("% Branches"), + Cell::new("% Funcs"), + ]); Self { table, total: CoverageSummary::default() } } } -impl SummaryReporter { +impl CoverageSummaryReporter { fn add_row(&mut self, name: impl Into, summary: CoverageSummary) { let mut row = Row::new(); row.add_cell(name.into()) @@ -48,7 +55,7 @@ impl SummaryReporter { } } -impl CoverageReporter for SummaryReporter { +impl CoverageReporter for CoverageSummaryReporter { fn report(mut self, report: &CoverageReport) -> eyre::Result<()> { for (path, summary) in report.summary_by_file() { self.total.merge(&summary); @@ -56,7 +63,7 @@ impl CoverageReporter for SummaryReporter { } self.add_row("Total", self.total.clone()); - sh_println!("{}", self.table)?; + sh_println!("\n{}", self.table)?; Ok(()) } } diff --git a/crates/forge/src/gas_report.rs b/crates/forge/src/gas_report.rs index 7e87af0770299..dc8527d5e3565 100644 --- a/crates/forge/src/gas_report.rs +++ b/crates/forge/src/gas_report.rs @@ -5,13 +5,14 @@ use crate::{ traces::{CallTraceArena, CallTraceDecoder, CallTraceNode, DecodedCallData}, }; use alloy_primitives::map::HashSet; -use comfy_table::{presets::ASCII_MARKDOWN, *}; +use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Color, Table}; use foundry_common::{ calc, reports::{report_kind, ReportKind}, TestFunctionExt, }; use foundry_evm::traces::CallKind; + use serde::{Deserialize, Serialize}; use serde_json::json; use std::{collections::BTreeMap, fmt::Display}; @@ -156,7 +157,7 @@ impl GasReport { impl Display for GasReport { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { match self.report_kind { - ReportKind::Markdown => { + ReportKind::Text => { for (name, contract) in &self.contracts { if contract.functions.is_empty() { trace!(name, "gas report contract without functions"); @@ -164,8 +165,7 @@ impl Display for GasReport { } let table = self.format_table_output(contract, name); - writeln!(f, "{table}")?; - writeln!(f, "\n")?; + writeln!(f, "\n{table}")?; } } ReportKind::JSON => { @@ -214,27 +214,31 @@ impl GasReport { .unwrap() } - // Helper function to format the table output fn format_table_output(&self, contract: &ContractInfo, name: &str) -> Table { let mut table = Table::new(); - table.load_preset(ASCII_MARKDOWN); - table.set_header([Cell::new(format!("{name} contract")) - .add_attribute(Attribute::Bold) - .fg(Color::Green)]); - - table.add_row([ - Cell::new("Deployment Cost").add_attribute(Attribute::Bold).fg(Color::Cyan), - Cell::new("Deployment Size").add_attribute(Attribute::Bold).fg(Color::Cyan), + table.apply_modifier(UTF8_ROUND_CORNERS); + + table.set_header(vec![Cell::new(format!("{name} Contract")).fg(Color::Magenta)]); + + table.add_row(vec![ + Cell::new("Deployment Cost").fg(Color::Cyan), + Cell::new("Deployment Size").fg(Color::Cyan), ]); - table.add_row([contract.gas.to_string(), contract.size.to_string()]); - - table.add_row([ - Cell::new("Function Name").add_attribute(Attribute::Bold).fg(Color::Magenta), - Cell::new("min").add_attribute(Attribute::Bold).fg(Color::Green), - Cell::new("avg").add_attribute(Attribute::Bold).fg(Color::Yellow), - Cell::new("median").add_attribute(Attribute::Bold).fg(Color::Yellow), - Cell::new("max").add_attribute(Attribute::Bold).fg(Color::Red), - Cell::new("# calls").add_attribute(Attribute::Bold), + table.add_row(vec![ + Cell::new(contract.gas.to_string()), + Cell::new(contract.size.to_string()), + ]); + + // Add a blank row to separate deployment info from function info. + table.add_row(vec![Cell::new("")]); + + table.add_row(vec![ + Cell::new("Function Name"), + Cell::new("Min").fg(Color::Green), + Cell::new("Avg").fg(Color::Yellow), + Cell::new("Median").fg(Color::Yellow), + Cell::new("Max").fg(Color::Red), + Cell::new("# Calls").fg(Color::Cyan), ]); contract.functions.iter().for_each(|(fname, sigs)| { @@ -243,8 +247,8 @@ impl GasReport { let display_name = if sigs.len() == 1 { fname.to_string() } else { sig.replace(':', "") }; - table.add_row([ - Cell::new(display_name).add_attribute(Attribute::Bold), + table.add_row(vec![ + Cell::new(display_name), Cell::new(gas_info.min.to_string()).fg(Color::Green), Cell::new(gas_info.mean.to_string()).fg(Color::Yellow), Cell::new(gas_info.median.to_string()).fg(Color::Yellow), diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index ca54ae0d03529..76dd718c60168 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -73,15 +73,19 @@ contract Dummy { forgetest!(initcode_size_exceeds_limit, |prj, cmd| { prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); - cmd.args(["build", "--sizes"]).assert_failure().stdout_eq(str![ - r#" -... + cmd.args(["build", "--sizes"]).assert_failure().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +╭--------------+------------------+-------------------+--------------------+---------------------╮ | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | -|--------------|------------------|-------------------|--------------------|---------------------| -| HugeContract | 194 | 49,344 | 24,382 | -192 | -... -"# - ]); ++================================================================================================+ +| HugeContract | 194 | 49,344 | 24,382 | -192 | +╰--------------+------------------+-------------------+--------------------+---------------------╯ + + +"#]]); cmd.forge_fuse().args(["build", "--sizes", "--json"]).assert_failure().stdout_eq( str![[r#" @@ -100,15 +104,19 @@ forgetest!(initcode_size_exceeds_limit, |prj, cmd| { forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); - cmd.args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq(str![ - r#" -... + cmd.args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +╭--------------+------------------+-------------------+--------------------+---------------------╮ | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | -|--------------|------------------|-------------------|--------------------|---------------------| -| HugeContract | 194 | 49,344 | 24,382 | -192 | -... -"# - ]); ++================================================================================================+ +| HugeContract | 194 | 49,344 | 24,382 | -192 | +╰--------------+------------------+-------------------+--------------------+---------------------╯ + + +"#]]); cmd.forge_fuse() .args(["build", "--sizes", "--ignore-eip-3860", "--json"]) @@ -145,15 +153,17 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { ..Default::default() }); - cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![ - r#" + cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" ... + +╭----------+------------------+-------------------+--------------------+---------------------╮ | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | -|----------|------------------|-------------------|--------------------|---------------------| -| Counter | 236 | 263 | 24,340 | 48,889 | -... -"# - ]); ++============================================================================================+ +| Counter | 236 | 263 | 24,340 | 48,889 | +╰----------+------------------+-------------------+--------------------+---------------------╯ + + +"#]]); cmd.forge_fuse().args(["build", "--sizes", "--json"]).assert_success().stdout_eq( str![[r#" diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 35f5c2314c16e..82d819b207ff2 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1584,29 +1584,50 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractOne contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractOne Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101532 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | foo | 45370 | 45370 | 45370 | 45370 | 1 | +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ - -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ - -| src/Contracts.sol:ContractTwo contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractTwo Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101520 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | bar | 64832 | 64832 | 64832 | 64832 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -1668,29 +1689,50 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractOne contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractOne Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101532 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | foo | 45370 | 45370 | 45370 | 45370 | 1 | +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ - -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ - -| src/Contracts.sol:ContractTwo contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractTwo Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101520 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | bar | 64832 | 64832 | 64832 | 64832 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -1752,29 +1794,50 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractOne contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractOne Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101532 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | foo | 45370 | 45370 | 45370 | 45370 | 1 | +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ - -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ - -| src/Contracts.sol:ContractTwo contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractTwo Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101520 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | bar | 64832 | 64832 | 64832 | 64832 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -1843,29 +1906,50 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractOne contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractOne Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101532 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | foo | 45370 | 45370 | 45370 | 45370 | 1 | +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ - -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ - -| src/Contracts.sol:ContractTwo contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractTwo Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101520 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | bar | 64832 | 64832 | 64832 | 64832 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -1934,13 +2018,22 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractOne contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractOne Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101532 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | foo | 45370 | 45370 | 45370 | 45370 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -1972,13 +2065,22 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractTwo contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractTwo Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101520 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | bar | 64832 | 64832 | 64832 | 64832 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -2013,13 +2115,22 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | -... +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -2060,21 +2171,36 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ - -| src/Contracts.sol:ContractTwo contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractTwo Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101520 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | bar | 64832 | 64832 | 64832 | 64832 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -2127,21 +2253,36 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractOne contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractOne Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101532 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | foo | 45370 | 45370 | 45370 | 45370 | 1 | +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ - -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | -... +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( @@ -2205,29 +2346,51 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { .assert_success() .stdout_eq(str![[r#" ... -| src/Contracts.sol:ContractOne contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractOne Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101532 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | foo | 45370 | 45370 | 45370 | 45370 | 1 | +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ - -| src/Contracts.sol:ContractThree contract | | | | | | -|------------------------------------------|-----------------|--------|--------|--------|---------| +╭------------------------------------------+-----------------+--------+--------+--------+---------╮ +| src/Contracts.sol:ContractThree Contract | | | | | | ++=================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| | 101748 | 242 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|------------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+--------+--------+--------+---------| | baz | 259210 | 259210 | 259210 | 259210 | 1 | +╰------------------------------------------+-----------------+--------+--------+--------+---------╯ - -| src/Contracts.sol:ContractTwo contract | | | | | | -|----------------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Contracts.sol:ContractTwo Contract | | | | | | ++=============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| | 101520 | 241 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------+-----------------+-------+--------+-------+---------| | bar | 64832 | 64832 | 64832 | 64832 | 1 | -... +╰----------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) + "#]]) .stderr_eq(str![[r#" ... @@ -2348,16 +2511,29 @@ contract CounterTest is DSTest { cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... -| src/Counter.sol:Counter contract | | | | | | -|----------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Counter.sol:Counter Contract | | | | | | ++=======================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------+-----------------+-------+--------+-------+---------| | 99711 | 240 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------+-----------------+-------+--------+-------+---------| | a | 2259 | 2259 | 2259 | 2259 | 1 | +|----------------------------------+-----------------+-------+--------+-------+---------| | b | 2304 | 2304 | 2304 | 2304 | 1 | +|----------------------------------+-----------------+-------+--------+-------+---------| | setNumber(int256) | 23646 | 33602 | 33602 | 43558 | 2 | +|----------------------------------+-----------------+-------+--------+-------+---------| | setNumber(uint256) | 23601 | 33557 | 33557 | 43513 | 2 | -... +╰----------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); cmd.forge_fuse().arg("test").arg("--gas-report").arg("--json").assert_success().stdout_eq( str![[r#" @@ -2462,39 +2638,38 @@ contract GasReportFallbackTest is Test { .assert_success() .stdout_eq(str![[r#" ... -Ran 1 test for test/DelegateProxyTest.sol:GasReportFallbackTest -[PASS] test_fallback_gas_report() ([GAS]) -Traces: - [327404] GasReportFallbackTest::test_fallback_gas_report() - ├─ [104475] → new ProxiedContract@[..] - │ └─ ← [Return] 236 bytes of code - ├─ [107054] → new DelegateProxy@[..] - │ └─ ← [Return] 135 bytes of code - ├─ [29384] DelegateProxy::fallback(100) - │ ├─ [3316] ProxiedContract::deposit(100) [delegatecall] - │ │ └─ ← [Stop] - │ └─ ← [Return] - ├─ [21159] DelegateProxy::deposit() - │ └─ ← [Stop] - └─ ← [Stop] - -Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] -| test/DelegateProxyTest.sol:DelegateProxy contract | | | | | | -|---------------------------------------------------|-----------------|-------|--------|-------|---------| +╭---------------------------------------------------+-----------------+-------+--------+-------+---------╮ +| test/DelegateProxyTest.sol:DelegateProxy Contract | | | | | | ++========================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|---------------------------------------------------+-----------------+-------+--------+-------+---------| | 107054 | 300 | | | | | -| Function Name | min | avg | median | max | # calls | +|---------------------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|---------------------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|---------------------------------------------------+-----------------+-------+--------+-------+---------| | deposit | 21159 | 21159 | 21159 | 21159 | 1 | +|---------------------------------------------------+-----------------+-------+--------+-------+---------| | fallback | 29384 | 29384 | 29384 | 29384 | 1 | +╰---------------------------------------------------+-----------------+-------+--------+-------+---------╯ - -| test/DelegateProxyTest.sol:ProxiedContract contract | | | | | | -|-----------------------------------------------------|-----------------|------|--------|------|---------| +╭-----------------------------------------------------+-----------------+------+--------+------+---------╮ +| test/DelegateProxyTest.sol:ProxiedContract Contract | | | | | | ++========================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|-----------------------------------------------------+-----------------+------+--------+------+---------| | 104475 | 263 | | | | | -| Function Name | min | avg | median | max | # calls | +|-----------------------------------------------------+-----------------+------+--------+------+---------| +| | | | | | | +|-----------------------------------------------------+-----------------+------+--------+------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|-----------------------------------------------------+-----------------+------+--------+------+---------| | deposit | 3316 | 3316 | 3316 | 3316 | 1 | -... +╰-----------------------------------------------------+-----------------+------+--------+------+---------╯ + + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); @@ -2587,32 +2762,51 @@ contract NestedDeploy is Test { .assert_success() .stdout_eq(str![[r#" ... -Ran 1 test for test/NestedDeployTest.sol:NestedDeploy -[PASS] test_nested_create_gas_report() ([GAS]) -Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] -| test/NestedDeployTest.sol:AnotherChild contract | | | | | | -|-------------------------------------------------|-----------------|-------|--------|-------|---------| +╭-------------------------------------------------+-----------------+-------+--------+-------+---------╮ +| test/NestedDeployTest.sol:AnotherChild Contract | | | | | | ++======================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|-------------------------------------------------+-----------------+-------+--------+-------+---------| | 0 | 124 | | | | | -| Function Name | min | avg | median | max | # calls | +|-------------------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|-------------------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|-------------------------------------------------+-----------------+-------+--------+-------+---------| | w | 21161 | 21161 | 21161 | 21161 | 1 | +╰-------------------------------------------------+-----------------+-------+--------+-------+---------╯ - -| test/NestedDeployTest.sol:Child contract | | | | | | -|------------------------------------------|-----------------|-----|--------|-----|---------| +╭------------------------------------------+-----------------+-----+--------+-----+---------╮ +| test/NestedDeployTest.sol:Child Contract | | | | | | ++===========================================================================================+ | Deployment Cost | Deployment Size | | | | | +|------------------------------------------+-----------------+-----+--------+-----+---------| | 0 | 477 | | | | | -| Function Name | min | avg | median | max | # calls | +|------------------------------------------+-----------------+-----+--------+-----+---------| +| | | | | | | +|------------------------------------------+-----------------+-----+--------+-----+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|------------------------------------------+-----------------+-----+--------+-----+---------| | child | 323 | 323 | 323 | 323 | 1 | +╰------------------------------------------+-----------------+-----+--------+-----+---------╯ - -| test/NestedDeployTest.sol:Parent contract | | | | | | -|-------------------------------------------|-----------------|-----|--------|-----|---------| +╭-------------------------------------------+-----------------+-----+--------+-----+---------╮ +| test/NestedDeployTest.sol:Parent Contract | | | | | | ++============================================================================================+ | Deployment Cost | Deployment Size | | | | | +|-------------------------------------------+-----------------+-----+--------+-----+---------| | 251997 | 739 | | | | | -| Function Name | min | avg | median | max | # calls | +|-------------------------------------------+-----------------+-----+--------+-----+---------| +| | | | | | | +|-------------------------------------------+-----------------+-----+--------+-----+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|-------------------------------------------+-----------------+-----+--------+-----+---------| | child | 181 | 181 | 181 | 181 | 1 | -... +╰-------------------------------------------+-----------------+-----+--------+-----+---------╯ + + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + "#]]); cmd.forge_fuse() @@ -2973,12 +3167,12 @@ forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { prj.clear_cache(); cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" -[COMPILING_FILES] with [SOLC_VERSION] -[SOLC_VERSION] [ELAPSED] -Compiler run successful! +... +╭----------+------------------+-------------------+--------------------+---------------------╮ | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | -|----------|------------------|-------------------|--------------------|---------------------| -| Counter | 236 | 263 | 24,340 | 48,889 | ++============================================================================================+ +| Counter | 236 | 263 | 24,340 | 48,889 | +╰----------+------------------+-------------------+--------------------+---------------------╯ "#]]); @@ -3044,24 +3238,42 @@ forgetest_init!(gas_report_include_tests, |prj, cmd| { cmd.args(["test", "--mt", "test_Increment", "--gas-report"]).assert_success().stdout_eq(str![ [r#" ... -| src/Counter.sol:Counter contract | | | | | | -|----------------------------------|-----------------|-------|--------|-------|---------| +╭----------------------------------+-----------------+-------+--------+-------+---------╮ +| src/Counter.sol:Counter Contract | | | | | | ++=======================================================================================+ | Deployment Cost | Deployment Size | | | | | +|----------------------------------+-----------------+-------+--------+-------+---------| | 104475 | 263 | | | | | -| Function Name | min | avg | median | max | # calls | +|----------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------+-----------------+-------+--------+-------+---------| | increment | 43401 | 43401 | 43401 | 43401 | 1 | +|----------------------------------+-----------------+-------+--------+-------+---------| | number | 281 | 281 | 281 | 281 | 1 | +|----------------------------------+-----------------+-------+--------+-------+---------| | setNumber | 23579 | 23579 | 23579 | 23579 | 1 | +╰----------------------------------+-----------------+-------+--------+-------+---------╯ - -| test/Counter.t.sol:CounterTest contract | | | | | | -|-----------------------------------------|-----------------|--------|--------|--------|---------| +╭-----------------------------------------+-----------------+--------+--------+--------+---------╮ +| test/Counter.t.sol:CounterTest Contract | | | | | | ++================================================================================================+ | Deployment Cost | Deployment Size | | | | | +|-----------------------------------------+-----------------+--------+--------+--------+---------| | 938190 | 4522 | | | | | -| Function Name | min | avg | median | max | # calls | +|-----------------------------------------+-----------------+--------+--------+--------+---------| +| | | | | | | +|-----------------------------------------+-----------------+--------+--------+--------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|-----------------------------------------+-----------------+--------+--------+--------+---------| | setUp | 165834 | 165834 | 165834 | 165834 | 1 | +|-----------------------------------------+-----------------+--------+--------+--------+---------| | test_Increment | 52357 | 52357 | 52357 | 52357 | 1 | -... +╰-----------------------------------------+-----------------+--------+--------+--------+---------╯ + + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#] ]); diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 141a9677dd503..c840a80362a0f 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -21,11 +21,16 @@ Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) Wrote LCOV report. + +╭----------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|----------------------|---------------|---------------|---------------|---------------| ++======================================================================================+ | script/Counter.s.sol | 0.00% (0/5) | 0.00% (0/3) | 100.00% (0/0) | 0.00% (0/2) | +|----------------------+---------------+---------------+---------------+---------------| | src/Counter.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +|----------------------+---------------+---------------+---------------+---------------| | Total | 44.44% (4/9) | 40.00% (2/5) | 100.00% (0/0) | 50.00% (2/4) | +╰----------------------+---------------+---------------+---------------+---------------╯ "# ]]); @@ -222,10 +227,13 @@ contract AContractTest is DSTest { // Assert 100% coverage (init function coverage called in setUp is accounted). cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]]); }); @@ -316,10 +324,13 @@ contract BContractTest is DSTest { cmd.arg("coverage").arg("--no-match-coverage=AContract").assert_success().stdout_eq(str![[ r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/BContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +╰-------------------+---------------+---------------+---------------+---------------╯ "# ]]); @@ -372,10 +383,13 @@ contract AContractTest is DSTest { cmd.arg("coverage").args(["--mt", "testAssertRevertBranch"]).assert_success().stdout_eq(str![ [r#" ... +╭-------------------+--------------+--------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|--------------|--------------|---------------|---------------| ++=================================================================================+ | src/AContract.sol | 66.67% (2/3) | 50.00% (1/2) | 100.00% (0/0) | 100.00% (1/1) | +|-------------------+--------------+--------------+---------------+---------------| | Total | 66.67% (2/3) | 50.00% (1/2) | 100.00% (0/0) | 100.00% (1/1) | +╰-------------------+--------------+--------------+---------------+---------------╯ "#] ]); @@ -384,10 +398,13 @@ contract AContractTest is DSTest { cmd.forge_fuse().arg("coverage").args(["--mt", "testAssertBranch"]).assert_success().stdout_eq( str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (3/3) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (3/3) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (1/1) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]], ); @@ -437,10 +454,13 @@ contract AContractTest is DSTest { // Assert 50% branch coverage if only revert tested. cmd.arg("coverage").args(["--mt", "testRequireRevert"]).assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+--------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|--------------|---------------| ++==================================================================================+ | src/AContract.sol | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +|-------------------+---------------+---------------+--------------+---------------| | Total | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +╰-------------------+---------------+---------------+--------------+---------------╯ "#]]); @@ -451,20 +471,26 @@ contract AContractTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+--------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|--------------|---------------| ++==================================================================================+ | src/AContract.sol | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +|-------------------+---------------+---------------+--------------+---------------| | Total | 100.00% (2/2) | 100.00% (1/1) | 50.00% (1/2) | 100.00% (1/1) | +╰-------------------+---------------+---------------+--------------+---------------╯ "#]]); // Assert 100% branch coverage. cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (2/2) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (2/2) | 100.00% (1/1) | 100.00% (2/2) | 100.00% (1/1) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]]); }); @@ -743,10 +769,13 @@ contract FooTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... +╭-------------+----------------+----------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------|----------------|----------------|---------------|---------------| ++===============================================================================+ | src/Foo.sol | 91.67% (33/36) | 90.00% (27/30) | 80.00% (8/10) | 100.00% (9/9) | +|-------------+----------------+----------------+---------------+---------------| | Total | 91.67% (33/36) | 90.00% (27/30) | 80.00% (8/10) | 100.00% (9/9) | +╰-------------+----------------+----------------+---------------+---------------╯ "#]]); @@ -757,20 +786,26 @@ contract FooTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... +╭-------------+----------------+----------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------|----------------|----------------|---------------|---------------| ++===============================================================================+ | src/Foo.sol | 97.22% (35/36) | 96.67% (29/30) | 90.00% (9/10) | 100.00% (9/9) | +|-------------+----------------+----------------+---------------+---------------| | Total | 97.22% (35/36) | 96.67% (29/30) | 90.00% (9/10) | 100.00% (9/9) | +╰-------------+----------------+----------------+---------------+---------------╯ "#]]); // Assert 100% coverage. cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------+-----------------+-----------------+-----------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------|-----------------|-----------------|-----------------|---------------| ++===================================================================================+ | src/Foo.sol | 100.00% (36/36) | 100.00% (30/30) | 100.00% (10/10) | 100.00% (9/9) | +|-------------+-----------------+-----------------+-----------------+---------------| | Total | 100.00% (36/36) | 100.00% (30/30) | 100.00% (10/10) | 100.00% (9/9) | +╰-------------+-----------------+-----------------+-----------------+---------------╯ "#]]); }); @@ -838,10 +873,13 @@ contract AContractTest is DSTest { // Assert 100% coverage. cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+-----------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|-----------------|---------------|---------------|---------------| ++=====================================================================================+ | src/AContract.sol | 100.00% (14/14) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | +|-------------------+-----------------+---------------+---------------+---------------| | Total | 100.00% (14/14) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (5/5) | +╰-------------------+-----------------+---------------+---------------+---------------╯ "#]]); }); @@ -937,20 +975,26 @@ contract FooTest is DSTest { // Assert coverage not 100% for happy paths only. cmd.arg("coverage").args(["--mt", "happy"]).assert_success().stdout_eq(str![[r#" ... +╭-------------+----------------+----------------+--------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------|----------------|----------------|--------------|---------------| ++==============================================================================+ | src/Foo.sol | 75.00% (15/20) | 66.67% (14/21) | 75.00% (3/4) | 100.00% (5/5) | +|-------------+----------------+----------------+--------------+---------------| | Total | 75.00% (15/20) | 66.67% (14/21) | 75.00% (3/4) | 100.00% (5/5) | +╰-------------+----------------+----------------+--------------+---------------╯ "#]]); // Assert 100% branch coverage (including clauses without body). cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------+-----------------+-----------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------|-----------------|-----------------|---------------|---------------| ++=================================================================================+ | src/Foo.sol | 100.00% (20/20) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | +|-------------+-----------------+-----------------+---------------+---------------| | Total | 100.00% (20/20) | 100.00% (21/21) | 100.00% (4/4) | 100.00% (5/5) | +╰-------------+-----------------+-----------------+---------------+---------------╯ "#]]); }); @@ -1050,10 +1094,13 @@ contract FooTest is DSTest { cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------+-----------------+-----------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------|-----------------|-----------------|---------------|---------------| ++=================================================================================+ | src/Foo.sol | 100.00% (30/30) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | +|-------------+-----------------+-----------------+---------------+---------------| | Total | 100.00% (30/30) | 100.00% (40/40) | 100.00% (1/1) | 100.00% (7/7) | +╰-------------+-----------------+-----------------+---------------+---------------╯ "#]]); }); @@ -1140,10 +1187,13 @@ contract FooTest is DSTest { cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------+-----------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------|-----------------|---------------|---------------|---------------| ++===============================================================================+ | src/Foo.sol | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | +|-------------+-----------------+---------------+---------------+---------------| | Total | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (4/4) | +╰-------------+-----------------+---------------+---------------+---------------╯ "#]]); }); @@ -1194,10 +1244,13 @@ contract AContractTest is DSTest { // Assert 50% coverage for true branches. cmd.arg("coverage").args(["--mt", "testTrueCoverage"]).assert_success().stdout_eq(str![[r#" ... +╭-------------------+--------------+--------------+--------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|--------------|--------------|--------------|---------------| ++================================================================================+ | src/AContract.sol | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +|-------------------+--------------+--------------+--------------+---------------| | Total | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +╰-------------------+--------------+--------------+--------------+---------------╯ "#]]); @@ -1208,20 +1261,26 @@ contract AContractTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... +╭-------------------+--------------+--------------+--------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|--------------|--------------|--------------|---------------| ++================================================================================+ | src/AContract.sol | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +|-------------------+--------------+--------------+--------------+---------------| | Total | 60.00% (3/5) | 50.00% (2/4) | 50.00% (2/4) | 100.00% (1/1) | +╰-------------------+--------------+--------------+--------------+---------------╯ "#]]); // Assert 100% coverage (true/false branches properly covered). cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (5/5) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (5/5) | 100.00% (4/4) | 100.00% (4/4) | 100.00% (1/1) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]]); }); @@ -1278,10 +1337,13 @@ contract AContractTest is DSTest { // Assert 50% coverage for true branches. cmd.arg("coverage").args(["--mt", "testTrueCoverage"]).assert_success().stdout_eq(str![[r#" ... +╭-------------------+--------------+--------------+--------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|--------------|--------------|--------------|---------------| ++================================================================================+ | src/AContract.sol | 80.00% (4/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +|-------------------+--------------+--------------+--------------+---------------| | Total | 80.00% (4/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +╰-------------------+--------------+--------------+--------------+---------------╯ "#]]); @@ -1292,20 +1354,26 @@ contract AContractTest is DSTest { .assert_success() .stdout_eq(str![[r#" ... +╭-------------------+--------------+--------------+--------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|--------------|--------------|--------------|---------------| ++================================================================================+ | src/AContract.sol | 60.00% (3/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +|-------------------+--------------+--------------+--------------+---------------| | Total | 60.00% (3/5) | 80.00% (4/5) | 50.00% (1/2) | 100.00% (1/1) | +╰-------------------+--------------+--------------+--------------+---------------╯ "#]]); // Assert 100% coverage (true/false branches properly covered). cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (5/5) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (5/5) | 100.00% (5/5) | 100.00% (2/2) | 100.00% (1/1) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]]); }); @@ -1371,10 +1439,13 @@ contract AContractTest is DSTest { cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+-----------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|-----------------|---------------|---------------|---------------| ++=====================================================================================+ | src/AContract.sol | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | +|-------------------+-----------------+---------------+---------------+---------------| | Total | 100.00% (12/12) | 100.00% (9/9) | 100.00% (0/0) | 100.00% (3/3) | +╰-------------------+-----------------+---------------+---------------+---------------╯ "#]]); }); @@ -1421,10 +1492,13 @@ contract AContractTest is DSTest { cmd.arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]]); }); @@ -1489,10 +1563,13 @@ end_of_record // Assert there's only one function (`increment`) reported. cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (1/1) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (1/1) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (1/1) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]]); }); @@ -1562,10 +1639,13 @@ end_of_record cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" ... +╭-------------------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|---------------|---------------|---------------|---------------| ++===================================================================================+ | src/AContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +|-------------------+---------------+---------------+---------------+---------------| | Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +╰-------------------+---------------+---------------+---------------+---------------╯ "#]]); }); @@ -1596,10 +1676,13 @@ contract AContract { // Assert coverage doesn't fail with `Error: Unknown key "inliner"`. cmd.arg("coverage").arg("--ir-minimum").assert_success().stdout_eq(str![[r#" ... +╭-------------------+-------------+--------------+---------------+-------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------------------|-------------|--------------|---------------|-------------| ++==============================================================================+ | src/AContract.sol | 0.00% (0/5) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | +|-------------------+-------------+--------------+---------------+-------------| | Total | 0.00% (0/5) | 0.00% (0/4) | 100.00% (0/0) | 0.00% (0/1) | +╰-------------------+-------------+--------------+---------------+-------------╯ "#]]); }); diff --git a/crates/forge/tests/cli/inline_config.rs b/crates/forge/tests/cli/inline_config.rs index 31da29d21ea86..5e02731952833 100644 --- a/crates/forge/tests/cli/inline_config.rs +++ b/crates/forge/tests/cli/inline_config.rs @@ -30,16 +30,24 @@ Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) // Make sure inline config is parsed in coverage too. cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" -... +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Analysing contracts... +Running tests... + Ran 2 tests for test/inline.sol:Inline [PASS] test1(bool) (runs: 2, [AVG_GAS]) [PASS] test2(bool) (runs: 3, [AVG_GAS]) Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) + +╭-------+---------------+---------------+---------------+---------------╮ | File | % Lines | % Statements | % Branches | % Funcs | -|-------|---------------|---------------|---------------|---------------| ++=======================================================================+ | Total | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | 100.00% (0/0) | +╰-------+---------------+---------------+---------------+---------------╯ "#]]); }); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 76afd5b36a772..ab04ae7b5499f 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -929,24 +929,38 @@ contract AnotherCounterHandler is Test { cmd.args(["test", "--mt", "invariant_"]).assert_success().stdout_eq(str![[r#" ... -Ran 2 tests for test/SelectorMetricsTest.t.sol:CounterTest [PASS] invariant_counter() (runs: 10, calls: 5000, reverts: [..]) + +╭-----------------------+----------------+-------+---------+----------╮ | Contract | Selector | Calls | Reverts | Discards | -|-----------------------|----------------|-------|---------|----------| -| AnotherCounterHandler | doWork | [..] | [..] | [..] | -| AnotherCounterHandler | doWorkThing | [..] | [..] | [..] | -| CounterHandler | doAnotherThing | [..] | [..] | [..] | -| CounterHandler | doSomething | [..] | [..] | [..] | ++=====================================================================+ +| AnotherCounterHandler | doWork | [..] | [..] | [..] | +|-----------------------+----------------+-------+---------+----------| +| AnotherCounterHandler | doWorkThing | [..] | [..] | [..] | +|-----------------------+----------------+-------+---------+----------| +| CounterHandler | doAnotherThing | [..] | [..] | [..] | +|-----------------------+----------------+-------+---------+----------| +| CounterHandler | doSomething | [..] | [..] | [..] | +╰-----------------------+----------------+-------+---------+----------╯ [PASS] invariant_counter2() (runs: 10, calls: 5000, reverts: [..]) + +╭-----------------------+----------------+-------+---------+----------╮ | Contract | Selector | Calls | Reverts | Discards | -|-----------------------|----------------|-------|---------|----------| -| AnotherCounterHandler | doWork | [..] | [..] | [..] | -| AnotherCounterHandler | doWorkThing | [..] | [..] | [..] | -| CounterHandler | doAnotherThing | [..] | [..] | [..] | -| CounterHandler | doSomething | [..] | [..] | [..] | ++=====================================================================+ +| AnotherCounterHandler | doWork | [..] | [..] | [..] | +|-----------------------+----------------+-------+---------+----------| +| AnotherCounterHandler | doWorkThing | [..] | [..] | [..] | +|-----------------------+----------------+-------+---------+----------| +| CounterHandler | doAnotherThing | [..] | [..] | [..] | +|-----------------------+----------------+-------+---------+----------| +| CounterHandler | doSomething | [..] | [..] | [..] | +╰-----------------------+----------------+-------+---------+----------╯ + +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 2 tests passed, 0 failed, 0 skipped (2 total tests) -... "#]]); }); From c161c7c9ed5f939adca5e88ff279654ae37c4a3d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 5 Dec 2024 11:11:37 +0100 Subject: [PATCH 1772/1963] fix: force `prevrandao` on Moonbeam networks (#9489) * chore: force prevrandao * add test for fix * fix forge fmt --------- Co-authored-by: zerosnacks Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/evm/core/src/utils.rs | 11 +++++++-- crates/forge/tests/it/repros.rs | 3 +++ crates/forge/tests/it/test_helpers.rs | 1 + testdata/default/repros/Issue4232.t.sol | 31 +++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 testdata/default/repros/Issue4232.t.sol diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 5ec396a169710..9a1dd8910c97b 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -6,7 +6,7 @@ use crate::{ use alloy_consensus::BlockHeader; use alloy_json_abi::{Function, JsonAbi}; use alloy_network::AnyTxEnvelope; -use alloy_primitives::{Address, Selector, TxKind, U256}; +use alloy_primitives::{Address, Selector, TxKind, B256, U256}; use alloy_provider::{network::BlockResponse, Network}; use alloy_rpc_types::{Transaction, TransactionRequest}; use foundry_config::NamedChain; @@ -34,11 +34,12 @@ pub fn apply_chain_and_block_specific_env_changes( env: &mut revm::primitives::Env, block: &N::BlockResponse, ) { + use NamedChain::*; if let Ok(chain) = NamedChain::try_from(env.cfg.chain_id) { let block_number = block.header().number(); match chain { - NamedChain::Mainnet => { + Mainnet => { // after merge difficulty is supplanted with prevrandao EIP-4399 if block_number >= 15_537_351u64 { env.block.difficulty = env.block.prevrandao.unwrap_or_default().into(); @@ -46,6 +47,12 @@ pub fn apply_chain_and_block_specific_env_changes( return; } + Moonbeam | Moonbase | Moonriver | MoonbeamDev => { + if env.block.prevrandao.is_none() { + // + env.block.prevrandao = Some(B256::random()); + } + } c if c.is_arbitrum() => { // on arbitrum `block.number` is the L1 block which is included in the // `l1BlockNumber` field diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 0e4adbbc281ef..96708bdf5548b 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -180,6 +180,9 @@ test_repro!(3753); // https://github.com/foundry-rs/foundry/issues/3792 test_repro!(3792); +// https://github.com/foundry-rs/foundry/issues/4232 +test_repro!(4232); + // https://github.com/foundry-rs/foundry/issues/4402 test_repro!(4402); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 3c8500772b4a1..af957ccdc0678 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -346,6 +346,7 @@ pub fn rpc_endpoints() -> RpcEndpoints { ("arbitrum", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Arbitrum))), ("polygon", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Polygon))), ("avaxTestnet", RpcEndpoint::Url("https://api.avax-test.network/ext/bc/C/rpc".into())), + ("moonbeam", RpcEndpoint::Url("https://moonbeam-rpc.publicnode.com".into())), ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".into())), ]) } diff --git a/testdata/default/repros/Issue4232.t.sol b/testdata/default/repros/Issue4232.t.sol new file mode 100644 index 0000000000000..0ac6a77c77076 --- /dev/null +++ b/testdata/default/repros/Issue4232.t.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/4232 +contract Issue4232Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testFork() public { + // Smoke test, worked previously as well + vm.createSelectFork("sepolia", 7215400); + vm.assertFalse(block.prevrandao == 0); + + // Would previously fail with: + // [FAIL: backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set; ] setUp() (gas: 0) + // + // Related fix: + // Moonbeam | Moonbase | Moonriver | MoonbeamDev => { + // if env.block.prevrandao.is_none() { + // // + // env.block.prevrandao = Some(B256::random()); + // } + // } + // + // Note: public RPC node used for `moonbeam` discards state quickly so we need to fork against the latest block + vm.createSelectFork("moonbeam"); + vm.assertFalse(block.prevrandao == 0); + } +} From 8c033184c8705d1a382ad190dbb552cb4ca7acd5 Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Thu, 5 Dec 2024 13:16:38 +0300 Subject: [PATCH 1773/1963] chore(cast): upgrade evmole to 0.6.1, use new style API (#9493) --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- crates/cast/src/lib.rs | 25 ++++++++++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51a6b026840c7..caaae04641eb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3265,9 +3265,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fcfb15a14bc209e2b3d2bd32291ec445b1e348d7d9d986aa61a09149350fd7" +checksum = "f58e21c69e0ae62877b65241d25cae9e28477818482fab8c1101d15289725a46" dependencies = [ "alloy-dyn-abi", "alloy-primitives", diff --git a/Cargo.toml b/Cargo.toml index 0fa4b4bdb33f4..0518bab796cbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -224,7 +224,7 @@ alloy-chains = "0.1" alloy-rlp = "0.3" alloy-trie = "0.6.0" -## op-alloy +## op-alloy op-alloy-rpc-types = "0.7.1" op-alloy-consensus = "0.7.1" @@ -260,7 +260,7 @@ color-eyre = "0.6" comfy-table = "7" dunce = "1" evm-disassembler = "0.5" -evmole = "0.5" +evmole = "0.6" eyre = "0.6" figment = "0.10" futures = "0.3" diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index b5b719e39ae84..01d7da6efc80f 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -2103,13 +2103,28 @@ impl SimpleCast { /// ``` pub fn extract_functions(bytecode: &str) -> Result> { let code = hex::decode(strip_0x(bytecode))?; - Ok(evmole::function_selectors(&code, 0) + let info = evmole::contract_info( + evmole::ContractInfoArgs::new(&code) + .with_selectors() + .with_arguments() + .with_state_mutability(), + ); + Ok(info + .functions + .expect("functions extraction was requested") .into_iter() - .map(|s| { + .map(|f| { ( - hex::encode_prefixed(s), - evmole::function_arguments(&code, &s, 0), - evmole::function_state_mutability(&code, &s, 0).as_json_str(), + hex::encode_prefixed(f.selector), + f.arguments + .expect("arguments extraction was requested") + .into_iter() + .map(|t| t.sol_type_name().to_string()) + .collect::>() + .join(","), + f.state_mutability + .expect("state_mutability extraction was requested") + .as_json_str(), ) }) .collect()) From e264381e8728eeee4cdf5b6d103655e60493a4f3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 5 Dec 2024 21:33:37 +0100 Subject: [PATCH 1774/1963] chore: bump compilers 0.12.7 (#9498) --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index caaae04641eb9..8ba03cf8066f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -3864,9 +3864,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186f601e89e36e2b82d3bc4a517287190846c990c1fd9f7b6f745bcbe65947e9" +checksum = "7235826f00dd9196bcbdbb9c168ea38235601db95883a78819ba2303dee34bb8" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3901,9 +3901,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c32fbf90c191e5037818d9d42d85642d6da2ff6528283b1efb2a88b08a02a5d" +checksum = "097bc5db7be5acf6d92938ad7daabf1932d7aa7c44326cdfc256531a53034d31" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3911,9 +3911,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "103d2d76d62a11b03d19e26fa6fbd996d2fac487a804392f57f96f0f677c469d" +checksum = "b4168053c1ad217866c677a074517e8d51988e5b1bad044b95f3c513aa5b6caa" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3935,9 +3935,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cafd2720bd20428822421bfbf34cfb33806be75e1b0c6ffcd6a4b25d6ead16" +checksum = "1b7beffe7182551d01d249f022a5eab17c36c73b39ae8efd404e0fb9c98b9f80" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3950,9 +3950,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327f11092bf779c76b3fa588ebf37c2e3bb903d55ba49f8e73b69e4cb888d0cb" +checksum = "ac5247875b96dfb99da12d0cd0f6ce98954116d1cf8a9188d613b2a35cd6937b" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 0518bab796cbe..7c4f565e171e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } -foundry-compilers = { version = "0.12.5", default-features = false } +foundry-compilers = { version = "0.12.7", default-features = false } foundry-fork-db = "0.8.0" solang-parser = "=0.3.3" solar-ast = { version = "=0.1.0", default-features = false } From 4f9f904a4780422cb7b0bfd6d4f425fc3aaea957 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:16:33 +0100 Subject: [PATCH 1775/1963] chore(deps): bump breaking deps (#9502) --- Cargo.lock | 92 +++++++++++++--------------- Cargo.toml | 2 +- crates/chisel/Cargo.toml | 2 +- crates/chisel/src/solidity_helper.rs | 4 +- crates/debugger/Cargo.toml | 2 +- crates/fmt/Cargo.toml | 2 +- crates/fmt/src/helpers.rs | 10 +-- crates/forge/Cargo.toml | 8 +-- 8 files changed, 56 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ba03cf8066f7..a175015f10ce8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "Inflector" @@ -995,7 +995,7 @@ dependencies = [ "serde_repr", "similar-asserts", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.3", "tikv-jemallocator", "tokio", "tower 0.4.13", @@ -1026,7 +1026,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.3", ] [[package]] @@ -1052,7 +1052,7 @@ dependencies = [ "pin-project 1.1.7", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio-util", "tower-http", "tracing", @@ -1075,9 +1075,9 @@ dependencies = [ [[package]] name = "ariadne" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44055e597c674aef7cb903b2b9f6e4cba1277ed0d2d61dae7cd52d7ffa81f8e2" +checksum = "31beedec3ce83ae6da3a79592b3d8d7afd146a5b15bb9bb940279aced60faa89" dependencies = [ "unicode-width 0.1.14", "yansi", @@ -3498,7 +3498,7 @@ dependencies = [ "strum", "svm-rs", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.3", "tikv-jemallocator", "tokio", "toml 0.8.19", @@ -3531,7 +3531,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "thiserror 1.0.69", + "thiserror 2.0.3", "toml 0.8.19", "tracing", ] @@ -3546,7 +3546,7 @@ dependencies = [ "itertools 0.13.0", "similar-asserts", "solang-parser", - "thiserror 1.0.69", + "thiserror 2.0.3", "toml 0.8.19", "tracing", "tracing-subscriber", @@ -3734,7 +3734,7 @@ dependencies = [ "revm-inspectors", "semver 1.0.23", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.3", "toml 0.8.19", "tracing", "vergen", @@ -3833,7 +3833,7 @@ dependencies = [ "serde_json", "similar-asserts", "terminal_size", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", "tower 0.4.13", "tracing", @@ -3999,7 +3999,7 @@ dependencies = [ "similar-asserts", "solang-parser", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.3", "toml 0.8.19", "toml_edit", "tracing", @@ -4048,7 +4048,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "thiserror 1.0.69", + "thiserror 2.0.3", "tracing", ] @@ -4094,7 +4094,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", "tracing", "url", @@ -4137,7 +4137,7 @@ dependencies = [ "rand", "revm", "serde", - "thiserror 1.0.69", + "thiserror 2.0.3", "tracing", ] @@ -4200,7 +4200,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "semver 1.0.23", - "thiserror 1.0.69", + "thiserror 2.0.3", ] [[package]] @@ -4262,7 +4262,7 @@ dependencies = [ "gcloud-sdk", "rpassword", "serde", - "thiserror 1.0.69", + "thiserror 2.0.3", "tokio", "tracing", ] @@ -5421,17 +5421,16 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "inferno" -version = "0.11.21" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" +checksum = "75a5d75fee4d36809e6b021e4b96b686e763d365ffdb03af2bd00786353f84fe" dependencies = [ "ahash", - "is-terminal", "itoa", "log", "num-format", "once_cell", - "quick-xml 0.26.0", + "quick-xml 0.37.1", "rgb", "str_stack", ] @@ -7195,15 +7194,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "quick-xml" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" -dependencies = [ - "memchr", -] - [[package]] name = "quick-xml" version = "0.37.1" @@ -7332,23 +7322,23 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" +checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ "bitflags 2.6.0", "cassowary", "compact_str", "crossterm", + "indoc", "instability", "itertools 0.13.0", "lru", "paste", "strum", - "strum_macros", "unicode-segmentation", "unicode-truncate", - "unicode-width 0.1.14", + "unicode-width 0.2.0", ] [[package]] @@ -7880,9 +7870,9 @@ dependencies = [ [[package]] name = "rustyline" -version = "14.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63" +checksum = "2ee1e066dc922e513bda599c6ccb5f3bb2b0ea5870a579448f2622993f0a9a2f" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -7892,12 +7882,12 @@ dependencies = [ "libc", "log", "memchr", - "nix 0.28.0", + "nix 0.29.0", "radix_trie", "unicode-segmentation", - "unicode-width 0.1.14", + "unicode-width 0.2.0", "utf8parse", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -9887,9 +9877,9 @@ dependencies = [ [[package]] name = "watchexec" -version = "4.1.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c635816bdb583dcd1cf58935899df38b5c5ffb1b9d0cc89f8d3c7b33e2c005e3" +checksum = "81e682bb1fe9526a6c78ffcfc6bb662ab36c213764fdd173babfbaf05cc56254" dependencies = [ "async-priority-channel", "async-recursion", @@ -9897,7 +9887,7 @@ dependencies = [ "futures", "ignore-files", "miette", - "nix 0.28.0", + "nix 0.29.0", "normalize-path", "notify", "once_cell", @@ -9913,34 +9903,34 @@ dependencies = [ [[package]] name = "watchexec-events" -version = "3.0.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce015ba32ff91a7f796cea3798e7998d3645411f03fc373ef0e7c7e564291bc" +checksum = "2404ed3aa5e4a8f6139a2ee137926886c9144234c945102143ef9bf65309a751" dependencies = [ - "nix 0.28.0", + "nix 0.29.0", "notify", "watchexec-signals", ] [[package]] name = "watchexec-signals" -version = "3.0.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7ccc54db7df8cbbe3251508321e46986ce179af4c4a03b4c70bda539d72755" +checksum = "be07d7855a3617d996ce0c7df4b6232159c526634dff668dd95491c22a9a7262" dependencies = [ "miette", - "nix 0.28.0", + "nix 0.29.0", "thiserror 1.0.69", ] [[package]] name = "watchexec-supervisor" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97efb9292bebdf72a777a0d6e400b69b32b4f3daee1ddd30214317a18ff20ab" +checksum = "6026815bdc9653d7820f6499b83ecadacd97a804dfabf2b2c55b061557f5f1f4" dependencies = [ "futures", - "nix 0.28.0", + "nix 0.29.0", "process-wrap", "tokio", "tracing", diff --git a/Cargo.toml b/Cargo.toml index 7c4f565e171e0..2967d8573a09b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -239,7 +239,7 @@ quote = "1.0" syn = "2.0" async-trait = "0.1" derive_more = { version = "1.0", features = ["full"] } -thiserror = "1" +thiserror = "2" # bench divan = "0.1" diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 5f098817c39d9..167329d45036d 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -53,7 +53,7 @@ eyre.workspace = true regex.workspace = true reqwest.workspace = true revm.workspace = true -rustyline = "14" +rustyline = "15" semver.workspace = true serde_json.workspace = true serde.workspace = true diff --git a/crates/chisel/src/solidity_helper.rs b/crates/chisel/src/solidity_helper.rs index c56f9e9eb7014..465b7b535c36e 100644 --- a/crates/chisel/src/solidity_helper.rs +++ b/crates/chisel/src/solidity_helper.rs @@ -9,7 +9,7 @@ use crate::{ }; use rustyline::{ completion::Completer, - highlight::Highlighter, + highlight::{CmdKind, Highlighter}, hint::Hinter, validate::{ValidationContext, ValidationResult, Validator}, Helper, @@ -188,7 +188,7 @@ impl Highlighter for SolidityHelper { self.highlight(line) } - fn highlight_char(&self, line: &str, pos: usize, _forced: bool) -> bool { + fn highlight_char(&self, line: &str, pos: usize, _kind: CmdKind) -> bool { pos == line.len() } diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.toml index 4fb417db5c1e5..4cf86e20a5045 100644 --- a/crates/debugger/Cargo.toml +++ b/crates/debugger/Cargo.toml @@ -23,7 +23,7 @@ alloy-primitives.workspace = true crossterm = "0.28" eyre.workspace = true -ratatui = { version = "0.28", default-features = false, features = [ +ratatui = { version = "0.29", default-features = false, features = [ "crossterm", ] } revm.workspace = true diff --git a/crates/fmt/Cargo.toml b/crates/fmt/Cargo.toml index 0bc3e06a6b806..bc1f44fdc5e03 100644 --- a/crates/fmt/Cargo.toml +++ b/crates/fmt/Cargo.toml @@ -17,7 +17,7 @@ foundry-config.workspace = true alloy-primitives.workspace = true -ariadne = "0.4" +ariadne = "0.5" itertools.workspace = true solang-parser.workspace = true thiserror.workspace = true diff --git a/crates/fmt/src/helpers.rs b/crates/fmt/src/helpers.rs index 7f05a9c093bf1..1d036ba6b66d0 100644 --- a/crates/fmt/src/helpers.rs +++ b/crates/fmt/src/helpers.rs @@ -97,20 +97,20 @@ pub fn format_diagnostics_report( path.map(|p| p.file_name().unwrap().to_string_lossy().to_string()).unwrap_or_default(); let mut s = Vec::new(); for diag in diagnostics { - let (start, end) = (diag.loc.start(), diag.loc.end()); - let mut report = Report::build(ReportKind::Error, &filename, start) + let span = (filename.as_str(), diag.loc.start()..diag.loc.end()); + let mut report = Report::build(ReportKind::Error, span.clone()) .with_message(format!("{:?}", diag.ty)) .with_label( - Label::new((&filename, start..end)) + Label::new(span) .with_color(Color::Red) - .with_message(format!("{}", diag.message.as_str().fg(Color::Red))), + .with_message(diag.message.as_str().fg(Color::Red)), ); for note in &diag.notes { report = report.with_note(¬e.message); } - report.finish().write((&filename, Source::from(content)), &mut s).unwrap(); + report.finish().write((filename.as_str(), Source::from(content)), &mut s).unwrap(); } String::from_utf8(s).unwrap() } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 208ea8430ab96..cbbfa814daf12 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -80,7 +80,7 @@ dialoguer = { version = "0.11", default-features = false } dunce.workspace = true futures.workspace = true indicatif = "0.17" -inferno = { version = "0.11", default-features = false } +inferno = { version = "0.12", default-features = false } itertools.workspace = true parking_lot.workspace = true regex = { workspace = true, default-features = false } @@ -96,9 +96,9 @@ thiserror.workspace = true tokio = { workspace = true, features = ["time"] } toml = { workspace = true, features = ["preserve_order"] } toml_edit = "0.22" -watchexec = "4.1" -watchexec-events = "3.0" -watchexec-signals = "3.0" +watchexec = "5.0" +watchexec-events = "4.0" +watchexec-signals = "4.0" clearscreen = "3.0" evm-disassembler.workspace = true From 43a033d39a42e7e329db482570933471829edd03 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:34:58 +0100 Subject: [PATCH 1776/1963] chore: improve Retry usage and warning (#9503) --- crates/common/src/retry.rs | 33 +++++++++---- crates/forge/tests/cli/verify.rs | 10 ++-- crates/verify/src/etherscan/mod.rs | 78 ++++++++++++++---------------- crates/verify/src/retry.rs | 7 +-- crates/verify/src/sourcify.rs | 16 +++--- crates/verify/src/verify.rs | 2 +- 6 files changed, 79 insertions(+), 67 deletions(-) diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs index 59ba2055f8a35..b79e095ceb831 100644 --- a/crates/common/src/retry.rs +++ b/crates/common/src/retry.rs @@ -16,23 +16,28 @@ pub enum RetryError { #[derive(Clone, Debug)] pub struct Retry { retries: u32, - delay: Option, + delay: Duration, } impl Retry { /// Creates a new `Retry` instance. - pub fn new(retries: u32, delay: Option) -> Self { + pub fn new(retries: u32, delay: Duration) -> Self { Self { retries, delay } } + /// Creates a new `Retry` instance with no delay between retries. + pub fn new_no_delay(retries: u32) -> Self { + Self::new(retries, Duration::ZERO) + } + /// Runs the given closure in a loop, retrying if it fails up to the specified number of times. pub fn run Result, T>(mut self, mut callback: F) -> Result { loop { match callback() { Err(e) if self.retries > 0 => { self.handle_err(e); - if let Some(delay) = self.delay { - std::thread::sleep(delay); + if !self.delay.is_zero() { + std::thread::sleep(self.delay); } } res => return res, @@ -51,8 +56,8 @@ impl Retry { match callback().await { Err(e) if self.retries > 0 => { self.handle_err(e); - if let Some(delay) = self.delay { - tokio::time::sleep(delay).await; + if !self.delay.is_zero() { + tokio::time::sleep(self.delay).await; } } res => return res, @@ -71,8 +76,8 @@ impl Retry { match callback().await { Err(RetryError::Retry(e)) if self.retries > 0 => { self.handle_err(e); - if let Some(delay) = self.delay { - tokio::time::sleep(delay).await; + if !self.delay.is_zero() { + tokio::time::sleep(self.delay).await; } } Err(RetryError::Retry(e) | RetryError::Break(e)) => return Err(e), @@ -82,7 +87,17 @@ impl Retry { } fn handle_err(&mut self, err: Error) { + debug_assert!(self.retries > 0); self.retries -= 1; - let _ = sh_warn!("{} ({} tries remaining)", err.root_cause(), self.retries); + let _ = sh_warn!( + "{msg}{delay} ({retries} tries remaining)", + msg = crate::errors::display_chain(&err), + delay = if self.delay.is_zero() { + String::new() + } else { + format!("; waiting {} seconds before trying again", self.delay.as_secs()) + }, + retries = self.retries, + ); } } diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index 154c74e30d84d..60a794477314a 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -75,9 +75,8 @@ contract Verify is Unique { #[allow(clippy::disallowed_macros)] fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Result<()> { - // give etherscan some time to verify the contract - let retry = Retry::new(retries, Some(Duration::from_secs(30))); - retry.run(|| -> eyre::Result<()> { + // Give Etherscan some time to verify the contract. + Retry::new(retries, Duration::from_secs(30)).run(|| -> eyre::Result<()> { let output = cmd.execute(); let out = String::from_utf8_lossy(&output.stdout); println!("{out}"); @@ -94,9 +93,8 @@ fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Resul fn await_verification_response(info: EnvExternalities, mut cmd: TestCommand) { let guid = { - // give etherscan some time to detect the transaction - let retry = Retry::new(5, Some(Duration::from_secs(60))); - retry + // Give Etherscan some time to detect the transaction. + Retry::new(5, Duration::from_secs(60)) .run(|| -> eyre::Result { let output = cmd.execute(); let out = String::from_utf8_lossy(&output.stdout); diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 78f39fe96dccc..26832e3b4ab52 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -15,14 +15,10 @@ use foundry_block_explorers::{ Client, }; use foundry_cli::utils::{get_provider, read_constructor_args_file, LoadConfig}; -use foundry_common::{ - abi::encode_function_args, - retry::{Retry, RetryError}, -}; +use foundry_common::{abi::encode_function_args, retry::RetryError}; use foundry_compilers::{artifacts::BytecodeObject, Artifact}; use foundry_config::{Chain, Config}; use foundry_evm::constants::DEFAULT_CREATE2_DEPLOYER; -use futures::FutureExt; use regex::Regex; use semver::{BuildMetadata, Version}; use std::{fmt::Debug, sync::LazyLock}; @@ -77,8 +73,9 @@ impl VerificationProvider for EtherscanVerificationProvider { trace!(?verify_args, "submitting verification request"); - let retry: Retry = args.retry.into(); - let resp = retry + let resp = args + .retry + .into_retry() .run_async(|| async { sh_println!( "\nSubmitting verification for [{}] {}.", @@ -157,48 +154,45 @@ impl VerificationProvider for EtherscanVerificationProvider { args.etherscan.key().as_deref(), &config, )?; - let retry: Retry = args.retry.into(); - retry - .run_async_until_break(|| { - async { - let resp = etherscan - .check_contract_verification_status(args.id.clone()) - .await - .wrap_err("Failed to request verification status") - .map_err(RetryError::Retry)?; - - trace!(?resp, "Received verification response"); - - let _ = sh_println!( - "Contract verification status:\nResponse: `{}`\nDetails: `{}`", - resp.message, - resp.result - ); + args.retry + .into_retry() + .run_async_until_break(|| async { + let resp = etherscan + .check_contract_verification_status(args.id.clone()) + .await + .wrap_err("Failed to request verification status") + .map_err(RetryError::Retry)?; - if resp.result == "Pending in queue" { - return Err(RetryError::Retry(eyre!("Verification is still pending...",))) - } + trace!(?resp, "Received verification response"); - if resp.result == "Unable to verify" { - return Err(RetryError::Retry(eyre!("Unable to verify.",))) - } + let _ = sh_println!( + "Contract verification status:\nResponse: `{}`\nDetails: `{}`", + resp.message, + resp.result + ); - if resp.result == "Already Verified" { - let _ = sh_println!("Contract source code already verified"); - return Ok(()) - } + if resp.result == "Pending in queue" { + return Err(RetryError::Retry(eyre!("Verification is still pending..."))) + } - if resp.status == "0" { - return Err(RetryError::Break(eyre!("Contract failed to verify.",))) - } + if resp.result == "Unable to verify" { + return Err(RetryError::Retry(eyre!("Unable to verify."))) + } - if resp.result == "Pass - Verified" { - let _ = sh_println!("Contract successfully verified"); - } + if resp.result == "Already Verified" { + let _ = sh_println!("Contract source code already verified"); + return Ok(()) + } - Ok(()) + if resp.status == "0" { + return Err(RetryError::Break(eyre!("Contract failed to verify."))) + } + + if resp.result == "Pass - Verified" { + let _ = sh_println!("Contract successfully verified"); } - .boxed() + + Ok(()) }) .await .wrap_err("Checking verification result failed") diff --git a/crates/verify/src/retry.rs b/crates/verify/src/retry.rs index 6067d9d85621d..a01b1c94522aa 100644 --- a/crates/verify/src/retry.rs +++ b/crates/verify/src/retry.rs @@ -35,9 +35,10 @@ impl Default for RetryArgs { } } -impl From for Retry { - fn from(r: RetryArgs) -> Self { - Self::new(r.retries, Some(Duration::from_secs(r.delay as u64))) +impl RetryArgs { + /// Converts the arguments into a `Retry` instance. + pub fn into_retry(self) -> Retry { + Retry::new(self.retries, Duration::from_secs(self.delay as u64)) } } diff --git a/crates/verify/src/sourcify.rs b/crates/verify/src/sourcify.rs index b215fd1afe69c..a57335d39398b 100644 --- a/crates/verify/src/sourcify.rs +++ b/crates/verify/src/sourcify.rs @@ -5,7 +5,7 @@ use crate::{ use alloy_primitives::map::HashMap; use async_trait::async_trait; use eyre::Result; -use foundry_common::{fs, retry::Retry}; +use foundry_common::fs; use futures::FutureExt; use reqwest::Url; use serde::{Deserialize, Serialize}; @@ -36,8 +36,9 @@ impl VerificationProvider for SourcifyVerificationProvider { let client = reqwest::Client::new(); - let retry: Retry = args.retry.into(); - let resp = retry + let resp = args + .retry + .into_retry() .run_async(|| { async { sh_println!( @@ -56,7 +57,9 @@ impl VerificationProvider for SourcifyVerificationProvider { if !status.is_success() { let error: serde_json::Value = response.json().await?; eyre::bail!( - "Sourcify verification request for address ({}) failed with status code {status}\nDetails: {error:#}", + "Sourcify verification request for address ({}) \ + failed with status code {status}\n\ + Details: {error:#}", args.address, ); } @@ -72,8 +75,9 @@ impl VerificationProvider for SourcifyVerificationProvider { } async fn check(&self, args: VerifyCheckArgs) -> Result<()> { - let retry: Retry = args.retry.into(); - let resp = retry + let resp = args + .retry + .into_retry() .run_async(|| { async { let url = Url::from_str( diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index 5a8efe4c65984..de7779ac33a85 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -50,7 +50,7 @@ impl Default for VerifierArgs { } } -/// CLI arguments for `forge verify`. +/// CLI arguments for `forge verify-contract`. #[derive(Clone, Debug, Parser)] pub struct VerifyArgs { /// The address of the contract to verify. From 92cd1650cedfe64b0985e224fcba7ebac38ba382 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:35:19 +0100 Subject: [PATCH 1777/1963] fix: restore lock version 3 (#9501) From e52076714ace23c7a68e14f0048a40be3c6c8f0b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:35:47 +0100 Subject: [PATCH 1778/1963] chore(deps): remove async_recursion (#9500) Native async recursion was stabilized in 1.77. --- Cargo.lock | 1 - crates/script/Cargo.toml | 1 - crates/script/src/execute.rs | 4 +--- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a175015f10ce8..37369e34ebae4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3568,7 +3568,6 @@ dependencies = [ "alloy-serde", "alloy-signer", "alloy-transport", - "async-recursion", "clap", "dialoguer", "dunce", diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index e1a6428d9f199..4322bbb0e4954 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -35,7 +35,6 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } semver.workspace = true futures.workspace = true tokio.workspace = true -async-recursion = "1.1" itertools.workspace = true parking_lot.workspace = true diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 3e6cc30a12423..4aad978d59121 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -12,7 +12,6 @@ use alloy_primitives::{ }; use alloy_provider::Provider; use alloy_rpc_types::TransactionInput; -use async_recursion::async_recursion; use eyre::{OptionExt, Result}; use foundry_cheatcodes::Wallets; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; @@ -101,7 +100,6 @@ pub struct PreExecutionState { impl PreExecutionState { /// Executes the script and returns the state after execution. /// Might require executing script twice in cases when we determine sender from execution. - #[async_recursion] pub async fn execute(mut self) -> Result { let mut runner = self .script_config @@ -127,7 +125,7 @@ impl PreExecutionState { build_data: self.build_data.build_data, }; - return state.link().await?.prepare_execution().await?.execute().await; + return Box::pin(state.link().await?.prepare_execution().await?.execute()).await; } Ok(ExecutedState { From 63484d0a65c56e3378cc3f282ed962d5d499a490 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 6 Dec 2024 12:04:05 +0530 Subject: [PATCH 1779/1963] feat(`cheatcodes`): count assertion for `expectRevert` (#9484) * expectRevert count overload boilerplate * introduce `count` variable * populate `ExpectedRevert` for count overloads * intro `actual_count` and make ExpectedRevert mut * increment `actual_account` on success and tests * handle non-zero count reverts separately * handle count for specific reverts * nit * more tests * fix: handle count > 1 with reverter specified * test: ExpectRevertCountWithReverter * expectRevert with reverter and count 0 * nit * reverter count with data * nit * cleanup * nit * nit * clippy * nit * cargo cheats --- crates/cheatcodes/assets/cheatcodes.json | 120 +++++++++ crates/cheatcodes/spec/src/vm.rs | 24 ++ crates/cheatcodes/src/inspector.rs | 40 ++- crates/cheatcodes/src/test/expect.rs | 273 ++++++++++++++++----- testdata/cheats/Vm.sol | 6 + testdata/default/cheats/ExpectRevert.t.sol | 214 +++++++++++++++- 6 files changed, 609 insertions(+), 68 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d8f8d21df67b6..54556043ac9df 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5051,6 +5051,46 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "expectRevert_10", + "description": "Expects a `count` number of reverts from the upcoming calls from the reverter address that match the revert data.", + "declaration": "function expectRevert(bytes4 revertData, address reverter, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes4,address,uint64)", + "selector": "0xb0762d73", + "selectorBytes": [ + 176, + 118, + 45, + 115 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_11", + "description": "Expects a `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data.", + "declaration": "function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes,address,uint64)", + "selector": "0xd345fb1f", + "selectorBytes": [ + 211, + 69, + 251, + 31 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "expectRevert_2", @@ -5131,6 +5171,86 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "expectRevert_6", + "description": "Expects a `count` number of reverts from the upcoming calls with any revert data or reverter.", + "declaration": "function expectRevert(uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(uint64)", + "selector": "0x4ee38244", + "selectorBytes": [ + 78, + 227, + 130, + 68 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_7", + "description": "Expects a `count` number of reverts from the upcoming calls that match the revert data.", + "declaration": "function expectRevert(bytes4 revertData, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes4,uint64)", + "selector": "0xe45ca72d", + "selectorBytes": [ + 228, + 92, + 167, + 45 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_8", + "description": "Expects a `count` number of reverts from the upcoming calls that exactly match the revert data.", + "declaration": "function expectRevert(bytes calldata revertData, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(bytes,uint64)", + "selector": "0x4994c273", + "selectorBytes": [ + 73, + 148, + 194, + 115 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectRevert_9", + "description": "Expects a `count` number of reverts from the upcoming calls from the reverter address.", + "declaration": "function expectRevert(address reverter, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectRevert(address,uint64)", + "selector": "0x1ff5f952", + "selectorBytes": [ + 31, + 245, + 249, + 82 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "expectSafeMemory", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 6b66d31ddb502..6954fd1e526d4 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1019,6 +1019,30 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectRevert(bytes calldata revertData, address reverter) external; + /// Expects a `count` number of reverts from the upcoming calls with any revert data or reverter. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(uint64 count) external; + + /// Expects a `count` number of reverts from the upcoming calls that match the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes4 revertData, uint64 count) external; + + /// Expects a `count` number of reverts from the upcoming calls that exactly match the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes calldata revertData, uint64 count) external; + + /// Expects a `count` number of reverts from the upcoming calls from the reverter address. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(address reverter, uint64 count) external; + + /// Expects a `count` number of reverts from the upcoming calls from the reverter address that match the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes4 revertData, address reverter, uint64 count) external; + + /// Expects a `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectRevert(bytes calldata revertData, address reverter, uint64 count) external; + /// Expects an error on next call that starts with the revert data. #[cheatcode(group = Testing, safety = Unsafe)] function expectPartialRevert(bytes4 revertData) external; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 4e2b91b9dd2d6..329b89d0ebc2f 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -754,16 +754,23 @@ where { if ecx.journaled_state.depth() <= expected_revert.depth && matches!(expected_revert.kind, ExpectedRevertKind::Default) { - let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - return match expect::handle_expect_revert( + let mut expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); + let handler_result = expect::handle_expect_revert( false, true, - &expected_revert, + &mut expected_revert, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, - ) { + ); + + return match handler_result { Ok((address, retdata)) => { + expected_revert.actual_count += 1; + if expected_revert.actual_count < expected_revert.count { + self.expected_revert = Some(expected_revert.clone()); + } + outcome.result.result = InstructionResult::Return; outcome.result.output = retdata; outcome.address = address; @@ -1302,6 +1309,14 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { expected_revert.reverted_by.is_none() { expected_revert.reverted_by = Some(call.target_address); + } else if outcome.result.is_revert() && + expected_revert.reverter.is_some() && + expected_revert.reverted_by.is_some() && + expected_revert.count > 1 + { + // If we're expecting more than one revert, we need to reset the reverted_by address + // to latest reverter. + expected_revert.reverted_by = Some(call.target_address); } if ecx.journaled_state.depth() <= expected_revert.depth { @@ -1315,15 +1330,20 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { }; if needs_processing { - let expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - return match expect::handle_expect_revert( + // Only `remove` the expected revert from state if `expected_revert.count` == + // `expected_revert.actual_count` + let mut expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); + + let handler_result = expect::handle_expect_revert( cheatcode_call, false, - &expected_revert, + &mut expected_revert, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, - ) { + ); + + return match handler_result { Err(error) => { trace!(expected=?expected_revert, ?error, status=?outcome.result.result, "Expected revert mismatch"); outcome.result.result = InstructionResult::Revert; @@ -1331,6 +1351,10 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { outcome } Ok((_, retdata)) => { + expected_revert.actual_count += 1; + if expected_revert.actual_count < expected_revert.count { + self.expected_revert = Some(expected_revert.clone()); + } outcome.result.result = InstructionResult::Return; outcome.result.output = retdata; outcome diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index 3ee58407a7e67..a3ddef8c16c97 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -87,6 +87,10 @@ pub struct ExpectedRevert { pub reverter: Option

, /// Actual reverter of the call. pub reverted_by: Option
, + /// Number of times this revert is expected. + pub count: u64, + /// Actual number of times this revert has been seen. + pub actual_count: u64, } #[derive(Clone, Debug)] @@ -295,7 +299,7 @@ impl Cheatcode for expectEmitAnonymous_3Call { impl Cheatcode for expectRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false, false, None) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false, false, None, 1) } } @@ -309,6 +313,7 @@ impl Cheatcode for expectRevert_1Call { false, false, None, + 1, ) } } @@ -323,6 +328,7 @@ impl Cheatcode for expectRevert_2Call { false, false, None, + 1, ) } } @@ -337,6 +343,7 @@ impl Cheatcode for expectRevert_3Call { false, false, Some(*reverter), + 1, ) } } @@ -351,6 +358,7 @@ impl Cheatcode for expectRevert_4Call { false, false, Some(*reverter), + 1, ) } } @@ -365,6 +373,89 @@ impl Cheatcode for expectRevert_5Call { false, false, Some(*reverter), + 1, + ) + } +} + +impl Cheatcode for expectRevert_6Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { count } = self; + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), false, false, None, *count) + } +} + +impl Cheatcode for expectRevert_7Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData, count } = self; + expect_revert( + ccx.state, + Some(revertData.as_ref()), + ccx.ecx.journaled_state.depth(), + false, + false, + None, + *count, + ) + } +} + +impl Cheatcode for expectRevert_8Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData, count } = self; + expect_revert( + ccx.state, + Some(revertData), + ccx.ecx.journaled_state.depth(), + false, + false, + None, + *count, + ) + } +} + +impl Cheatcode for expectRevert_9Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { reverter, count } = self; + expect_revert( + ccx.state, + None, + ccx.ecx.journaled_state.depth(), + false, + false, + Some(*reverter), + *count, + ) + } +} + +impl Cheatcode for expectRevert_10Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData, reverter, count } = self; + expect_revert( + ccx.state, + Some(revertData.as_ref()), + ccx.ecx.journaled_state.depth(), + false, + false, + Some(*reverter), + *count, + ) + } +} + +impl Cheatcode for expectRevert_11Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { revertData, reverter, count } = self; + expect_revert( + ccx.state, + Some(revertData), + ccx.ecx.journaled_state.depth(), + false, + false, + Some(*reverter), + *count, ) } } @@ -379,6 +470,7 @@ impl Cheatcode for expectPartialRevert_0Call { false, true, None, + 1, ) } } @@ -393,13 +485,14 @@ impl Cheatcode for expectPartialRevert_1Call { false, true, Some(*reverter), + 1, ) } } impl Cheatcode for _expectCheatcodeRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true, false, None) + expect_revert(ccx.state, None, ccx.ecx.journaled_state.depth(), true, false, None, 1) } } @@ -413,6 +506,7 @@ impl Cheatcode for _expectCheatcodeRevert_1Call { true, false, None, + 1, ) } } @@ -427,6 +521,7 @@ impl Cheatcode for _expectCheatcodeRevert_2Call { true, false, None, + 1, ) } } @@ -662,6 +757,7 @@ fn expect_revert( cheatcode: bool, partial_match: bool, reverter: Option
, + count: u64, ) -> Result { ensure!( state.expected_revert.is_none(), @@ -678,6 +774,8 @@ fn expect_revert( partial_match, reverter, reverted_by: None, + count, + actual_count: 0, }); Ok(Default::default()) } @@ -685,7 +783,7 @@ fn expect_revert( pub(crate) fn handle_expect_revert( is_cheatcode: bool, is_create: bool, - expected_revert: &ExpectedRevert, + expected_revert: &mut ExpectedRevert, status: InstructionResult, retdata: Bytes, known_contracts: &Option, @@ -698,72 +796,117 @@ pub(crate) fn handle_expect_revert( } }; - ensure!(!matches!(status, return_ok!()), "next call did not revert as expected"); - - // If expected reverter address is set then check it matches the actual reverter. - if let (Some(expected_reverter), Some(actual_reverter)) = - (expected_revert.reverter, expected_revert.reverted_by) - { - if expected_reverter != actual_reverter { - return Err(fmt_err!( - "Reverter != expected reverter: {} != {}", - actual_reverter, - expected_reverter - )); + let stringify = |data: &[u8]| { + if let Ok(s) = String::abi_decode(data, true) { + return s; } - } - - let expected_reason = expected_revert.reason.as_deref(); - // If None, accept any revert. - let Some(expected_reason) = expected_reason else { - return Ok(success_return()); + if data.is_ascii() { + return std::str::from_utf8(data).unwrap().to_owned(); + } + hex::encode_prefixed(data) }; - if !expected_reason.is_empty() && retdata.is_empty() { - bail!("call reverted as expected, but without data"); - } - - let mut actual_revert: Vec = retdata.into(); + if expected_revert.count == 0 { + if expected_revert.reverter.is_none() && expected_revert.reason.is_none() { + ensure!( + matches!(status, return_ok!()), + "call reverted when it was expected not to revert" + ); + return Ok(success_return()); + } - // Compare only the first 4 bytes if partial match. - if expected_revert.partial_match && actual_revert.get(..4) == expected_reason.get(..4) { - return Ok(success_return()) - } + // Flags to track if the reason and reverter match. + let mut reason_match = expected_revert.reason.as_ref().map(|_| false); + let mut reverter_match = expected_revert.reverter.as_ref().map(|_| false); - // Try decoding as known errors. - if matches!( - actual_revert.get(..4).map(|s| s.try_into().unwrap()), - Some(Vm::CheatcodeError::SELECTOR | alloy_sol_types::Revert::SELECTOR) - ) { - if let Ok(decoded) = Vec::::abi_decode(&actual_revert[4..], false) { - actual_revert = decoded; + // Reverter check + if let (Some(expected_reverter), Some(actual_reverter)) = + (expected_revert.reverter, expected_revert.reverted_by) + { + if expected_reverter == actual_reverter { + reverter_match = Some(true); + } } - } - if actual_revert == expected_reason || - (is_cheatcode && memchr::memmem::find(&actual_revert, expected_reason).is_some()) - { - Ok(success_return()) + // Reason check + let expected_reason = expected_revert.reason.as_deref(); + if let Some(expected_reason) = expected_reason { + let mut actual_revert: Vec = retdata.into(); + actual_revert = decode_revert(actual_revert); + + if actual_revert == expected_reason { + reason_match = Some(true); + } + }; + + match (reason_match, reverter_match) { + (Some(true), Some(true)) => Err(fmt_err!( + "expected 0 reverts with reason: {}, from address: {}, but got one", + &stringify(expected_reason.unwrap_or_default()), + expected_revert.reverter.unwrap() + )), + (Some(true), None) => Err(fmt_err!( + "expected 0 reverts with reason: {}, but got one", + &stringify(expected_reason.unwrap_or_default()) + )), + (None, Some(true)) => Err(fmt_err!( + "expected 0 reverts from address: {}, but got one", + expected_revert.reverter.unwrap() + )), + _ => Ok(success_return()), + } } else { - let (actual, expected) = if let Some(contracts) = known_contracts { - let decoder = RevertDecoder::new().with_abis(contracts.iter().map(|(_, c)| &c.abi)); - ( - &decoder.decode(actual_revert.as_slice(), Some(status)), - &decoder.decode(expected_reason, Some(status)), - ) + ensure!(!matches!(status, return_ok!()), "next call did not revert as expected"); + + // If expected reverter address is set then check it matches the actual reverter. + if let (Some(expected_reverter), Some(actual_reverter)) = + (expected_revert.reverter, expected_revert.reverted_by) + { + if expected_reverter != actual_reverter { + return Err(fmt_err!( + "Reverter != expected reverter: {} != {}", + actual_reverter, + expected_reverter + )); + } + } + + let expected_reason = expected_revert.reason.as_deref(); + // If None, accept any revert. + let Some(expected_reason) = expected_reason else { + return Ok(success_return()); + }; + + if !expected_reason.is_empty() && retdata.is_empty() { + bail!("call reverted as expected, but without data"); + } + + let mut actual_revert: Vec = retdata.into(); + + // Compare only the first 4 bytes if partial match. + if expected_revert.partial_match && actual_revert.get(..4) == expected_reason.get(..4) { + return Ok(success_return()) + } + + // Try decoding as known errors. + actual_revert = decode_revert(actual_revert); + + if actual_revert == expected_reason || + (is_cheatcode && memchr::memmem::find(&actual_revert, expected_reason).is_some()) + { + Ok(success_return()) } else { - let stringify = |data: &[u8]| { - if let Ok(s) = String::abi_decode(data, true) { - return s; - } - if data.is_ascii() { - return std::str::from_utf8(data).unwrap().to_owned(); - } - hex::encode_prefixed(data) + let (actual, expected) = if let Some(contracts) = known_contracts { + let decoder = RevertDecoder::new().with_abis(contracts.iter().map(|(_, c)| &c.abi)); + ( + &decoder.decode(actual_revert.as_slice(), Some(status)), + &decoder.decode(expected_reason, Some(status)), + ) + } else { + (&stringify(&actual_revert), &stringify(expected_reason)) }; - (&stringify(&actual_revert), &stringify(expected_reason)) - }; - Err(fmt_err!("Error != expected error: {} != {}", actual, expected,)) + Err(fmt_err!("Error != expected error: {} != {}", actual, expected,)) + } } } @@ -774,3 +917,15 @@ fn expect_safe_memory(state: &mut Cheatcodes, start: u64, end: u64, depth: u64) offsets.push(start..end); Ok(Default::default()) } + +fn decode_revert(revert: Vec) -> Vec { + if matches!( + revert.get(..4).map(|s| s.try_into().unwrap()), + Some(Vm::CheatcodeError::SELECTOR | alloy_sol_types::Revert::SELECTOR) + ) { + if let Ok(decoded) = Vec::::abi_decode(&revert[4..], false) { + return decoded; + } + } + revert +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index f6f66969f99fe..b3746b6bc3191 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -246,10 +246,16 @@ interface Vm { function expectPartialRevert(bytes4 revertData, address reverter) external; function expectRevert() external; function expectRevert(bytes4 revertData) external; + function expectRevert(bytes4 revertData, address reverter, uint64 count) external; + function expectRevert(bytes calldata revertData, address reverter, uint64 count) external; function expectRevert(bytes calldata revertData) external; function expectRevert(address reverter) external; function expectRevert(bytes4 revertData, address reverter) external; function expectRevert(bytes calldata revertData, address reverter) external; + function expectRevert(uint64 count) external; + function expectRevert(bytes4 revertData, uint64 count) external; + function expectRevert(bytes calldata revertData, uint64 count) external; + function expectRevert(address reverter, uint64 count) external; function expectSafeMemory(uint64 min, uint64 max) external; function expectSafeMemoryCall(uint64 min, uint64 max) external; function fee(uint256 newBasefee) external; diff --git a/testdata/default/cheats/ExpectRevert.t.sol b/testdata/default/cheats/ExpectRevert.t.sol index 18a90bac6e29c..fef4ebaf57900 100644 --- a/testdata/default/cheats/ExpectRevert.t.sol +++ b/testdata/default/cheats/ExpectRevert.t.sol @@ -30,6 +30,10 @@ contract Reverter { revert(message); } + function callThenNoRevert(Dummy dummy) public pure { + dummy.callMe(); + } + function revertWithoutReason() public pure { revert(); } @@ -188,7 +192,7 @@ contract ExpectRevertTest is DSTest { } function testexpectCheatcodeRevert() public { - vm._expectCheatcodeRevert("JSON value at \".a\" is not an object"); + vm._expectCheatcodeRevert('JSON value at ".a" is not an object'); vm.parseJsonKeys('{"a": "b"}', ".a"); } @@ -351,3 +355,211 @@ contract ExpectRevertWithReverterTest is DSTest { aContract.callAndRevert(); } } + +contract ExpectRevertCount is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testRevertCountAny() public { + uint64 count = 3; + Reverter reverter = new Reverter(); + vm.expectRevert(count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("revert2"); + reverter.revertWithMessage("revert3"); + + vm.expectRevert("revert"); + reverter.revertWithMessage("revert"); + } + + function testFailRevertCountAny() public { + uint64 count = 3; + Reverter reverter = new Reverter(); + vm.expectRevert(count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("revert2"); + } + + function testNoRevert() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert(count); + reverter.doNotRevert(); + } + + function testFailNoRevert() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert(count); + reverter.revertWithMessage("revert"); + } + + function testRevertCountSpecific() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("revert"); + } + + function testFailReverCountSpecifc() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("second-revert"); + } + + function testNoRevertSpecific() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", count); + reverter.doNotRevert(); + } + + function testFailNoRevertSpecific() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", count); + reverter.revertWithMessage("revert"); + } + + function testNoRevertSpecificButDiffRevert() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", count); + reverter.revertWithMessage("revert2"); + } + + function testRevertCountWithConstructor() public { + uint64 count = 1; + vm.expectRevert("constructor revert", count); + new ConstructorReverter("constructor revert"); + } + + function testNoRevertWithConstructor() public { + uint64 count = 0; + vm.expectRevert("constructor revert", count); + new CContract(); + } + + function testRevertCountNestedSpecific() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Reverter inner = new Reverter(); + + vm.expectRevert("nested revert", count); + reverter.revertWithMessage("nested revert"); + reverter.nestedRevert(inner, "nested revert"); + + vm.expectRevert("nested revert", count); + reverter.nestedRevert(inner, "nested revert"); + reverter.nestedRevert(inner, "nested revert"); + } + + function testRevertCountCallsThenReverts() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Dummy dummy = new Dummy(); + + vm.expectRevert("called a function and then reverted", count); + reverter.callThenRevert(dummy, "called a function and then reverted"); + reverter.callThenRevert(dummy, "called a function and then reverted"); + } + + function testFailRevertCountCallsThenReverts() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Dummy dummy = new Dummy(); + + vm.expectRevert("called a function and then reverted", count); + reverter.callThenRevert(dummy, "called a function and then reverted"); + reverter.callThenRevert(dummy, "wrong revert"); + } + + function testNoRevertCall() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + Dummy dummy = new Dummy(); + + vm.expectRevert("called a function and then reverted", count); + reverter.callThenNoRevert(dummy); + } +} + +contract ExpectRevertCountWithReverter is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testRevertCountWithReverter() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + vm.expectRevert(address(reverter), count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("revert"); + } + + function testFailRevertCountWithReverter() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Reverter reverter2 = new Reverter(); + vm.expectRevert(address(reverter), count); + reverter.revertWithMessage("revert"); + reverter2.revertWithMessage("revert"); + } + + function testNoRevertWithReverter() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert(address(reverter), count); + reverter.doNotRevert(); + } + + function testNoRevertWithWrongReverter() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + Reverter reverter2 = new Reverter(); + vm.expectRevert(address(reverter), count); + reverter2.revertWithMessage("revert"); // revert from wrong reverter + } + + function testFailNoRevertWithReverter() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert(address(reverter), count); + reverter.revertWithMessage("revert"); + } + + function testReverterCountWithData() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", address(reverter), count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("revert"); + } + + function testFailReverterCountWithWrongData() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", address(reverter), count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("wrong revert"); + } + + function testFailWrongReverterCountWithData() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Reverter reverter2 = new Reverter(); + vm.expectRevert("revert", address(reverter), count); + reverter.revertWithMessage("revert"); + reverter2.revertWithMessage("revert"); + } + + function testNoReverterCountWithData() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", address(reverter), count); + reverter.doNotRevert(); + + vm.expectRevert("revert", address(reverter), count); + reverter.revertWithMessage("revert2"); + } +} From 00efa0d5965269149f374ba142fb1c3c7edd6c94 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:03:32 +0200 Subject: [PATCH 1780/1963] feat(cheatcodes): add `vm.getStateDiff` to get state diffs as string (#9435) * feat(cheatcodes): add vm.getStateDiff() to get state diffs as string * Nit arrow * Add json output * Better json format * Rename to original and dirty * Changes after review: split in 2 cheatcodes, rename to prev/newValues * Slots as hex strings, add balance diffs, cleanup * Record balance diffs only if changed. Add nonce diff placeholder * Backoff nonce placeholder --- Cargo.lock | 1 + crates/cheatcodes/Cargo.toml | 1 + crates/cheatcodes/assets/cheatcodes.json | 40 +++++ crates/cheatcodes/spec/src/vm.rs | 8 + crates/cheatcodes/src/evm.rs | 143 +++++++++++++++++- testdata/cheats/Vm.sol | 2 + .../cheats/RecordAccountAccesses.t.sol | 37 +++++ 7 files changed, 231 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 37369e34ebae4..857f0a91536b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3732,6 +3732,7 @@ dependencies = [ "revm", "revm-inspectors", "semver 1.0.23", + "serde", "serde_json", "thiserror 2.0.3", "toml 0.8.19", diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index a06416160111b..e358fdce737b0 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -68,3 +68,4 @@ toml = { workspace = true, features = ["preserve_order"] } tracing.workspace = true walkdir.workspace = true proptest.workspace = true +serde.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 54556043ac9df..82a7de2aa509c 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5791,6 +5791,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "getStateDiff", + "description": "Returns state diffs from current `vm.startStateDiffRecording` session.", + "declaration": "function getStateDiff() external view returns (string memory diff);", + "visibility": "external", + "mutability": "view", + "signature": "getStateDiff()", + "selector": "0x80df01cc", + "selectorBytes": [ + 128, + 223, + 1, + 204 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "getStateDiffJson", + "description": "Returns state diffs from current `vm.startStateDiffRecording` session, in json format.", + "declaration": "function getStateDiffJson() external view returns (string memory diff);", + "visibility": "external", + "mutability": "view", + "signature": "getStateDiffJson()", + "selector": "0xf54fe009", + "selectorBytes": [ + 245, + 79, + 224, + 9 + ] + }, + "group": "evm", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "getWallets", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 6954fd1e526d4..4bc8c9b0344e3 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -384,6 +384,14 @@ interface Vm { #[cheatcode(group = Evm, safety = Safe)] function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses); + /// Returns state diffs from current `vm.startStateDiffRecording` session. + #[cheatcode(group = Evm, safety = Safe)] + function getStateDiff() external view returns (string memory diff); + + /// Returns state diffs from current `vm.startStateDiffRecording` session, in json format. + #[cheatcode(group = Evm, safety = Safe)] + function getStateDiffJson() external view returns (string memory diff); + // -------- Recording Map Writes -------- /// Starts recording all map SSTOREs for later retrieval. diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 723beb1cfc8ab..6c1a4718512d7 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -18,10 +18,15 @@ use foundry_evm_core::{ use foundry_evm_traces::StackSnapshotType; use rand::Rng; use revm::primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY}; -use std::{collections::BTreeMap, path::Path}; +use std::{ + collections::{btree_map::Entry, BTreeMap}, + fmt::Display, + path::Path, +}; mod record_debug_step; use record_debug_step::{convert_call_trace_to_debug_step, flatten_call_trace}; +use serde::Serialize; mod fork; pub(crate) mod mapping; @@ -76,6 +81,70 @@ pub struct DealRecord { pub new_balance: U256, } +/// Storage slot diff info. +#[derive(Serialize, Default)] +#[serde(rename_all = "camelCase")] +struct SlotStateDiff { + /// Initial storage value. + previous_value: B256, + /// Current storage value. + new_value: B256, +} + +/// Balance diff info. +#[derive(Serialize, Default)] +#[serde(rename_all = "camelCase")] +struct BalanceDiff { + /// Initial storage value. + previous_value: U256, + /// Current storage value. + new_value: U256, +} + +/// Account state diff info. +#[derive(Serialize, Default)] +#[serde(rename_all = "camelCase")] +struct AccountStateDiffs { + /// Address label, if any set. + label: Option, + /// Account balance changes. + balance_diff: Option, + /// State changes, per slot. + state_diff: BTreeMap, +} + +impl Display for AccountStateDiffs { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> eyre::Result<(), std::fmt::Error> { + // Print changed account. + if let Some(label) = &self.label { + writeln!(f, "label: {label}")?; + } + // Print balance diff if changed. + if let Some(balance_diff) = &self.balance_diff { + if balance_diff.previous_value != balance_diff.new_value { + writeln!( + f, + "- balance diff: {} → {}", + balance_diff.previous_value, balance_diff.new_value + )?; + } + } + // Print state diff if any. + if !&self.state_diff.is_empty() { + writeln!(f, "- state diff:")?; + for (slot, slot_changes) in &self.state_diff { + writeln!( + f, + "@ {slot}: {} → {}", + slot_changes.previous_value, slot_changes.new_value + )?; + } + } + + Ok(()) + } +} + impl Cheatcode for addrCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { privateKey } = self; @@ -683,6 +752,25 @@ impl Cheatcode for stopAndReturnStateDiffCall { } } +impl Cheatcode for getStateDiffCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let mut diffs = String::new(); + let state_diffs = get_recorded_state_diffs(state); + for (address, state_diffs) in state_diffs { + diffs.push_str(&format!("{address}\n")); + diffs.push_str(&format!("{state_diffs}\n")); + } + Ok(diffs.abi_encode()) + } +} + +impl Cheatcode for getStateDiffJsonCall { + fn apply(&self, state: &mut Cheatcodes) -> Result { + let state_diffs = get_recorded_state_diffs(state); + Ok(serde_json::to_string(&state_diffs)?.abi_encode()) + } +} + impl Cheatcode for broadcastRawTransactionCall { fn apply_full(&self, ccx: &mut CheatsCtxt, executor: &mut dyn CheatcodesExecutor) -> Result { let tx = TxEnvelope::decode(&mut self.data.as_ref()) @@ -1044,3 +1132,56 @@ fn genesis_account(account: &Account) -> GenesisAccount { private_key: None, } } + +/// Helper function to returns state diffs recorded for each changed account. +fn get_recorded_state_diffs(state: &mut Cheatcodes) -> BTreeMap { + let mut state_diffs: BTreeMap = BTreeMap::default(); + if let Some(records) = &state.recorded_account_diffs_stack { + records + .iter() + .flatten() + .filter(|account_access| { + !account_access.storageAccesses.is_empty() || + account_access.oldBalance != account_access.newBalance + }) + .for_each(|account_access| { + let account_diff = + state_diffs.entry(account_access.account).or_insert(AccountStateDiffs { + label: state.labels.get(&account_access.account).cloned(), + ..Default::default() + }); + + // Record account balance diffs. + if account_access.oldBalance != account_access.newBalance { + // Update balance diff. Do not overwrite the initial balance if already set. + if let Some(diff) = &mut account_diff.balance_diff { + diff.new_value = account_access.newBalance; + } else { + account_diff.balance_diff = Some(BalanceDiff { + previous_value: account_access.oldBalance, + new_value: account_access.newBalance, + }); + } + } + + // Record account state diffs. + for storage_access in &account_access.storageAccesses { + if storage_access.isWrite && !storage_access.reverted { + // Update state diff. Do not overwrite the initial value if already set. + match account_diff.state_diff.entry(storage_access.slot) { + Entry::Vacant(slot_state_diff) => { + slot_state_diff.insert(SlotStateDiff { + previous_value: storage_access.previousValue, + new_value: storage_access.newValue, + }); + } + Entry::Occupied(mut slot_state_diff) => { + slot_state_diff.get_mut().new_value = storage_access.newValue; + } + } + } + } + }); + } + state_diffs +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index b3746b6bc3191..bdbb68e372e84 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -283,6 +283,8 @@ interface Vm { function getNonce(address account) external view returns (uint64 nonce); function getNonce(Wallet calldata wallet) external returns (uint64 nonce); function getRecordedLogs() external returns (Log[] memory logs); + function getStateDiff() external view returns (string memory diff); + function getStateDiffJson() external view returns (string memory diff); function getWallets() external returns (address[] memory wallets); function indexOf(string calldata input, string calldata key) external pure returns (uint256); function isContext(ForgeContext context) external view returns (bool result); diff --git a/testdata/default/cheats/RecordAccountAccesses.t.sol b/testdata/default/cheats/RecordAccountAccesses.t.sol index 98b5843b2a7f8..8de7bcdc5bd31 100644 --- a/testdata/default/cheats/RecordAccountAccesses.t.sol +++ b/testdata/default/cheats/RecordAccountAccesses.t.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.18; import "ds-test/test.sol"; import "cheats/Vm.sol"; +import "../logs/console.sol"; /// @notice Helper contract with a construction that makes a call to itself then /// optionally reverts if zero-length data is passed @@ -261,6 +262,16 @@ contract RecordAccountAccessesTest is DSTest { two.write(bytes32(uint256(5678)), bytes32(uint256(123469))); two.write(bytes32(uint256(5678)), bytes32(uint256(1234))); + string memory diffs = cheats.getStateDiff(); + assertEq( + "0x5991A2dF15A8F6A256D3Ec51E99254Cd3fb576A9\n- state diff:\n@ 0x00000000000000000000000000000000000000000000000000000000000004d3: 0x0000000000000000000000000000000000000000000000000000000000000000 \xE2\x86\x92 0x000000000000000000000000000000000000000000000000000000000000162e\n\n0xc7183455a4C133Ae270771860664b6B7ec320bB1\n- state diff:\n@ 0x000000000000000000000000000000000000000000000000000000000000162e: 0x0000000000000000000000000000000000000000000000000000000000000000 \xE2\x86\x92 0x00000000000000000000000000000000000000000000000000000000000004d2\n\n", + diffs + ); + string memory diffsJson = cheats.getStateDiffJson(); + assertEq( + "{\"0x5991a2df15a8f6a256d3ec51e99254cd3fb576a9\":{\"label\":null,\"balanceDiff\":null,\"stateDiff\":{\"0x00000000000000000000000000000000000000000000000000000000000004d3\":{\"previousValue\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"newValue\":\"0x000000000000000000000000000000000000000000000000000000000000162e\"}}},\"0xc7183455a4c133ae270771860664b6b7ec320bb1\":{\"label\":null,\"balanceDiff\":null,\"stateDiff\":{\"0x000000000000000000000000000000000000000000000000000000000000162e\":{\"previousValue\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"newValue\":\"0x00000000000000000000000000000000000000000000000000000000000004d2\"}}}}", + diffsJson + ); Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 4, "incorrect length"); @@ -332,6 +343,15 @@ contract RecordAccountAccessesTest is DSTest { // contract calls to self in constructor SelfCaller caller = new SelfCaller{value: 2 ether}("hello2 world2"); + assertEq( + "0x000000000000000000000000000000000000162e\n- balance diff: 0 \xE2\x86\x92 1000000000000000000\n\n0x1d1499e622D69689cdf9004d05Ec547d650Ff211\n- balance diff: 0 \xE2\x86\x92 2000000000000000000\n\n", + cheats.getStateDiff() + ); + assertEq( + "{\"0x000000000000000000000000000000000000162e\":{\"label\":null,\"balanceDiff\":{\"previousValue\":\"0x0\",\"newValue\":\"0xde0b6b3a7640000\"},\"stateDiff\":{}},\"0x1d1499e622d69689cdf9004d05ec547d650ff211\":{\"label\":null,\"balanceDiff\":{\"previousValue\":\"0x0\",\"newValue\":\"0x1bc16d674ec80000\"},\"stateDiff\":{}}}", + cheats.getStateDiffJson() + ); + Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 6); assertEq( @@ -451,6 +471,14 @@ contract RecordAccountAccessesTest is DSTest { uint256 initBalance = address(this).balance; cheats.startStateDiffRecording(); try this.revertingCall{value: 1 ether}(address(1234), "") {} catch {} + assertEq( + "0x00000000000000000000000000000000000004d2\n- balance diff: 0 \xE2\x86\x92 100000000000000000\n\n", + cheats.getStateDiff() + ); + assertEq( + "{\"0x00000000000000000000000000000000000004d2\":{\"label\":null,\"balanceDiff\":{\"previousValue\":\"0x0\",\"newValue\":\"0x16345785d8a0000\"},\"stateDiff\":{}}}", + cheats.getStateDiffJson() + ); Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 2); assertEq( @@ -768,6 +796,15 @@ contract RecordAccountAccessesTest is DSTest { function testNestedStorage() public { cheats.startStateDiffRecording(); nestedStorer.run(); + cheats.label(address(nestedStorer), "NestedStorer"); + assertEq( + "0x2e234DAe75C793f67A35089C9d99245E1C58470b\nlabel: NestedStorer\n- state diff:\n@ 0x4566fa0cd03218c55bba914d793f5e6b9113172c1f684bb5f464c08c867e8977: 0x0000000000000000000000000000000000000000000000000000000000000000 \xE2\x86\x92 0x0000000000000000000000000000000000000000000000000000000000000001\n@ 0xbf57896b60daefa2c41de2feffecfc11debd98ea8c913a5170f60e53959ac00a: 0x0000000000000000000000000000000000000000000000000000000000000000 \xE2\x86\x92 0x0000000000000000000000000000000000000000000000000000000000000001\n@ 0xc664893a982d78bbeab379feef216ff517b7ea73626b280723be1ace370364cd: 0x0000000000000000000000000000000000000000000000000000000000000000 \xE2\x86\x92 0x0000000000000000000000000000000000000000000000000000000000000001\n@ 0xdc5330afa9872081253545dca3f448752688ff1b098b38c1abe4c4cdff4b0b0e: 0x0000000000000000000000000000000000000000000000000000000000000000 \xE2\x86\x92 0x0000000000000000000000000000000000000000000000000000000000000001\n\n", + cheats.getStateDiff() + ); + assertEq( + "{\"0x2e234dae75c793f67a35089c9d99245e1c58470b\":{\"label\":\"NestedStorer\",\"balanceDiff\":null,\"stateDiff\":{\"0x4566fa0cd03218c55bba914d793f5e6b9113172c1f684bb5f464c08c867e8977\":{\"previousValue\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"newValue\":\"0x0000000000000000000000000000000000000000000000000000000000000001\"},\"0xbf57896b60daefa2c41de2feffecfc11debd98ea8c913a5170f60e53959ac00a\":{\"previousValue\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"newValue\":\"0x0000000000000000000000000000000000000000000000000000000000000001\"},\"0xc664893a982d78bbeab379feef216ff517b7ea73626b280723be1ace370364cd\":{\"previousValue\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"newValue\":\"0x0000000000000000000000000000000000000000000000000000000000000001\"},\"0xdc5330afa9872081253545dca3f448752688ff1b098b38c1abe4c4cdff4b0b0e\":{\"previousValue\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"newValue\":\"0x0000000000000000000000000000000000000000000000000000000000000001\"}}}}", + cheats.getStateDiffJson() + ); Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 3, "incorrect account access length"); From 2e56b8f63beeffab36d8c6f8b7563b9e92601f71 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:35:56 +0200 Subject: [PATCH 1781/1963] fix(verify): cached artifacts by version (#9520) * fix(verify): cached artifacts by version * Comments --- crates/verify/src/verify.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index de7779ac33a85..c2ac287703bd5 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -20,6 +20,7 @@ use foundry_config::{figment, impl_figment_convert, impl_figment_convert_cast, C use itertools::Itertools; use reqwest::Url; use revm_primitives::HashSet; +use semver::BuildMetadata; use std::path::PathBuf; use crate::provider::VerificationContext; @@ -275,7 +276,7 @@ impl VerifyArgs { let cache = project.read_cache_file().ok(); - let version = if let Some(ref version) = self.compiler_version { + let mut version = if let Some(ref version) = self.compiler_version { version.trim_start_matches('v').parse()? } else if let Some(ref solc) = config.solc { match solc { @@ -321,7 +322,21 @@ impl VerifyArgs { let profiles = entry .artifacts .get(&contract.name) - .and_then(|artifacts| artifacts.get(&version)) + .and_then(|artifacts| { + let mut cached_artifacts = artifacts.get(&version); + // If we try to verify with specific build version and no cached artifacts + // found, then check if we have artifacts cached for same version but + // without any build metadata. + // This could happen when artifacts are built / cached + // with a version like `0.8.20` but verify is using a compiler-version arg + // as `0.8.20+commit.a1b79de6`. + // See . + if cached_artifacts.is_none() && version.build != BuildMetadata::EMPTY { + version.build = BuildMetadata::EMPTY; + cached_artifacts = artifacts.get(&version); + } + cached_artifacts + }) .map(|artifacts| artifacts.keys().collect::>()) .unwrap_or_default(); From aa69ed1e46dd61fbf9d73399396a4db4dd527431 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:06:46 +0100 Subject: [PATCH 1782/1963] ci: move deny to test (#9524) --- .github/workflows/deny.yml | 26 -------------------------- .github/workflows/test.yml | 8 ++++++++ 2 files changed, 8 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/deny.yml diff --git a/.github/workflows/deny.yml b/.github/workflows/deny.yml deleted file mode 100644 index e8e4d5b84b1e1..0000000000000 --- a/.github/workflows/deny.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: deny - -on: - push: - branches: [master] - paths: [Cargo.lock, deny.toml] - pull_request: - branches: [master] - paths: [Cargo.lock, deny.toml] - -env: - CARGO_TERM_COLOR: always - -jobs: - cargo-deny: - name: cargo deny check - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check all - # Clear out arguments to not pass `--all-features` to `cargo deny`. - # many crates have an `openssl` feature which enables banned dependencies - arguments: "" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d5a2eabb07c0e..3ca0daa177ab6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -110,6 +110,13 @@ jobs: cache-on-failure: true - run: cargo hack check + deny: + uses: ithacaxyz/ci/.github/workflows/deny.yml@main + with: + # Clear out arguments to not pass `--all-features` to `cargo deny`. + # Many crates have an `openssl` feature which enables banned dependencies. + deny-flags: "" + ci-success: runs-on: ubuntu-latest if: always() @@ -122,6 +129,7 @@ jobs: - rustfmt - forge-fmt - crate-checks + - deny timeout-minutes: 30 steps: - name: Decide whether the needed jobs succeeded or failed From fd9ee169e911c97f0c127a79ce8501e42b8ea4fc Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 10 Dec 2024 13:18:07 +0100 Subject: [PATCH 1783/1963] chore: bump alloy (#9496) * chore: bump alloy * chore: bump alloy 0.8 * use prim sig --- Cargo.lock | 482 +++++++++---------- Cargo.toml | 55 +-- crates/anvil/core/src/eth/transaction/mod.rs | 4 +- crates/cast/bin/cmd/wallet/mod.rs | 2 +- crates/common/fmt/src/ui.rs | 2 +- 5 files changed, 273 insertions(+), 272 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 857f0a91536b6..a69b2ddf3c9bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -68,9 +68,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" @@ -86,15 +86,15 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1ff8439834ab71a4b0ecd1a8ff80b3921c87615f158940c3364f399c732786" +checksum = "8ba14856660f31807ebb26ce8f667e814c72694e1077e97ef102e326ad580f3f" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", - "alloy-trie 0.7.4", + "alloy-trie", "auto_impl", "c-kzg", "derive_more", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "519a86faaa6729464365a90c04eba68539b6d3a30f426edb4b3dafd78920d42f" +checksum = "28666307e76441e7af37a2b90cde7391c28112121bea59f4e0d804df8b20057e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca2b353d8b7f160dc930dfa174557acefece6deab5ecd7e6230d38858579eea" +checksum = "f3510769905590b8991a8e63a5e0ab4aa72cf07a13ab5fbe23f12f4454d161da" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -134,14 +134,14 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] name = "alloy-dyn-abi" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80759b3f57b3b20fa7cd8fef6479930fc95461b58ff8adea6e87e618449c8a1d" +checksum = "41056bde53ae10ffbbf11618efbe1e0290859e5eab0fe9ef82ebdb62f12a866f" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dedb328c2114284f767e075589ca9de8d5e9c8a91333402f4804a584ed71a38" +checksum = "47e922d558006ba371681d484d12aa73fe673d84884f83747730af7433c0e86d" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -206,20 +206,21 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4841e8dd4e0f53d76b501fd4c6bc21d95d688bc8ebf0ea359fc6c7ab65b48742" +checksum = "5dca170827a7ca156b43588faebf9e9d27c27d0fb07cab82cfd830345e2b24f5" dependencies = [ "alloy-primitives", "alloy-serde", + "alloy-trie", "serde", ] [[package]] name = "alloy-json-abi" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac4b22b3e51cac09fd2adfcc73b55f447b4df669f983c13f7894ec82b607c63f" +checksum = "c357da577dfb56998d01f574d81ad7a1958d248740a7981b205d69d65a7da404" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -229,23 +230,23 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "254f770918f96dc4ec88a15e6e2e243358e1719d66b40ef814428e7697079d25" +checksum = "9335278f50b0273e0a187680ee742bb6b154a948adf036f448575bacc5ccb315" dependencies = [ "alloy-primitives", "alloy-sol-types", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", "tracing", ] [[package]] name = "alloy-network" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931dd176c6e33355f3dc0170ec69cf5b951f4d73870b276e2c837ab35f9c5136" +checksum = "ad4e6ad4230df8c4a254c20f8d6a84ab9df151bfca13f463177dbc96571cc1f8" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -263,14 +264,14 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] name = "alloy-network-primitives" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa6ec0f23be233e851e31c5e4badfedfa9c7bc177bc37f4e03616072cd40a806" +checksum = "c4df88a2f8020801e0fefce79471d3946d39ca3311802dbbd0ecfdeee5e972e3" dependencies = [ "alloy-consensus", "alloy-eips", @@ -281,9 +282,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bce85f0f67b2248c2eb42941bb75079ac53648569a668e8bfd7de5a831ec64" +checksum = "2db5cefbc736b2b26a960dcf82279c70a03695dd11a0032a6dc27601eeb29182" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -291,16 +292,16 @@ dependencies = [ "rand", "serde_json", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.4", "tracing", "url", ] [[package]] name = "alloy-primitives" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db948902dfbae96a73c2fbf1f7abec62af034ab883e4c777c3fd29702bd6e2c" +checksum = "6259a506ab13e1d658796c31e6e39d2e2ee89243bcc505ddc613b35732e0a430" dependencies = [ "alloy-rlp", "arbitrary", @@ -313,7 +314,7 @@ dependencies = [ "getrandom", "hashbrown 0.15.2", "hex-literal", - "indexmap 2.6.0", + "indexmap 2.7.0", "itoa", "k256", "keccak-asm", @@ -330,9 +331,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5545e2cbf2f8f24c68bb887ba0294fa12a2f816b9e72c4f226cd137b77d0e294" +checksum = "5115c74c037714e1b02a86f742289113afa5d494b5ea58308ba8aa378e739101" dependencies = [ "alloy-chains", "alloy-consensus", @@ -364,7 +365,7 @@ dependencies = [ "schnellru", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", "tokio", "tracing", "url", @@ -373,9 +374,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b633f7731a3df2f4f334001bf80436565113816c5aa5c136c1ded563051e049b" +checksum = "b073afa409698d1b9a30522565815f3bf7010e5b47b997cf399209e6110df097" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -414,9 +415,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aed9e40c2a73265ebf70f1e48303ee55920282e1ea5971e832873fb2d32cea74" +checksum = "5c6a0bd0ce5660ac48e4f3bb0c7c5c3a94db287a0be94971599d83928476cbcd" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -440,9 +441,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42dea20fa715a6f39ec7adc735cfd9567342870737270ac67795d55896527772" +checksum = "374ac12e35bb90ebccd86e7c943ddba9590149a6e35cc4d9cd860d6635fd1018" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -456,9 +457,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2750f4f694b27461915b9794df60177198bf733da38dde71aadfbe2946a3c0be" +checksum = "f0b85a5f5f5d99047544f4ec31330ee15121dcb8ef5af3e791a5207e6b92b05b" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -468,11 +469,10 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79d7620e22d6ed7c58451dd303d0501ade5a8bec9dc8daef0fbc48ceffabbae1" +checksum = "ea98f81bcd759dbfa3601565f9d7a02220d8ef1d294ec955948b90aaafbfd857" dependencies = [ - "alloy-consensus", "alloy-consensus-any", "alloy-rpc-types-eth", "alloy-serde", @@ -480,9 +480,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d2d4a265fb1198272cc43d8d418c0423cdfc1aebcd283be9105464874a1dda" +checksum = "4fd14f68a482e67dfba52d404dfff1d3b0d9fc3b4775bd0923f3175d7661c3bd" dependencies = [ "alloy-primitives", "serde", @@ -490,9 +490,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb843daa6feb011475f0db8c499fff5ac62e1e6012fc01d97477ddb3217a83f" +checksum = "9ca5898f753ff0d15a0dc955c169523d8fee57e05bb5a38a398b3451b0b988be" dependencies = [ "alloy-consensus", "alloy-eips", @@ -508,9 +508,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df34b88df4deeac9ecfc80ad7cbb26a33e57437b9db8be5b952792feef6134bc" +checksum = "0e518b0a7771e00728f18be0708f828b18a1cfc542a7153bef630966a26388e0" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -528,23 +528,23 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db32f30a55ea4fa9d893127a84eef52fc54d23acb34c1a5a39bfe9bd95fbc149" +checksum = "cdff93fa38be6982f8613a060e18fa0a37ce440d69ed3b7f37c6c69036ce1c53" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", "alloy-serde", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] name = "alloy-rpc-types-txpool" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1588d8d799095a9bd55d9045b76add042ab725c37316a77da933683754aa4b" +checksum = "2d9dc647985db41fd164e807577134da1179b9f5ba0959f8698d6587eaa568f5" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -554,9 +554,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a89fd4cc3f96b3c5c0dd1cebeb63323e4659bbdc837117fa3fd5ac168df7d9" +checksum = "ed3dc8d4a08ffc90c1381d39a4afa2227668259a42c97ab6eecf51cbd82a8761" dependencies = [ "alloy-primitives", "serde", @@ -565,9 +565,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532010243a96d1f8593c2246ec3971bc52303884fa1e43ca0a776798ba178910" +checksum = "16188684100f6e0f2a2b949968fe3007749c5be431549064a1bce4e7b3a196a9" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -576,14 +576,14 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] name = "alloy-signer-aws" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd0bdb5079a35d7559714d9f9690b2ebb462921b9ceea63488bd2bef5744c15a" +checksum = "fe06d524ac84fefce1184f2d1273704e62faade7ff1f29c17ac9d493d3ffbdbf" dependencies = [ "alloy-consensus", "alloy-network", @@ -593,15 +593,15 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 1.0.69", + "thiserror 2.0.4", "tracing", ] [[package]] name = "alloy-signer-gcp" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794e996552efa65a76b20c088f8a968da514f90f7e44cecc32fc544c8a66fd29" +checksum = "492cedcb4819a588aaef8d59edd5d65291f485d25f64b2aa0806dd86feeafd18" dependencies = [ "alloy-consensus", "alloy-network", @@ -611,15 +611,15 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 1.0.69", + "thiserror 2.0.4", "tracing", ] [[package]] name = "alloy-signer-ledger" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416fbc9f19bed61f722181b8f10bd4d89648c254d49f594e1617215f0a30ba46" +checksum = "426409a02587b98e118d2fd32dda3f423805e264a32f9e247a65164163bc0e9b" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -631,15 +631,15 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.23", - "thiserror 1.0.69", + "thiserror 2.0.4", "tracing", ] [[package]] name = "alloy-signer-local" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8080c0ab2dc729b0cbb183843d08e78d2a1629140c9fc16234d2272abb483bd" +checksum = "e2184dab8c9493ab3e1c9f6bd3bdb563ed322b79023d81531935e84a4fdf7cf1" dependencies = [ "alloy-consensus", "alloy-network", @@ -651,14 +651,14 @@ dependencies = [ "eth-keystore", "k256", "rand", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] name = "alloy-signer-trezor" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1862a5a0e883998e65b735c71560a7b9eaca57cab2165eeb80f0b9a01fff3348" +checksum = "290ead62e020b751761de95f60056340faba341b20493ae929013d1357b9ba5b" dependencies = [ "alloy-consensus", "alloy-network", @@ -666,16 +666,16 @@ dependencies = [ "alloy-signer", "async-trait", "semver 1.0.23", - "thiserror 1.0.69", + "thiserror 2.0.4", "tracing", "trezor-client", ] [[package]] name = "alloy-sol-macro" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfd7853b65a2b4f49629ec975fee274faf6dff15ab8894c620943398ef283c0" +checksum = "d9d64f851d95619233f74b310f12bcf16e0cbc27ee3762b6115c14a84809280a" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -687,15 +687,15 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82ec42f342d9a9261699f8078e57a7a4fda8aaa73c1a212ed3987080e6a9cd13" +checksum = "6bf7ed1574b699f48bf17caab4e6e54c6d12bc3c006ab33d58b1e227c1c3559f" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.6.0", + "indexmap 2.7.0", "proc-macro-error2", "proc-macro2", "quote", @@ -706,9 +706,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2c50e6a62ee2b4f7ab3c6d0366e5770a21cad426e109c2f40335a1b3aff3df" +checksum = "8c02997ccef5f34f9c099277d4145f183b422938ed5322dc57a089fe9b9ad9ee" dependencies = [ "alloy-json-abi", "const-hex", @@ -723,9 +723,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac17c6e89a50fb4a758012e4b409d9a0ba575228e69b539fe37d7a1bd507ca4a" +checksum = "ce13ff37285b0870d0a0746992a4ae48efaf34b766ae4c2640fa15e5305f8e73" dependencies = [ "serde", "winnow", @@ -733,9 +733,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9dc0fffe397aa17628160e16b89f704098bf3c9d74d5d369ebc239575936de5" +checksum = "1174cafd6c6d810711b4e00383037bdb458efc4fe3dbafafa16567e0320c54d8" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -746,9 +746,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6f295f4b745fb9e4e663d70bc57aed991288912c7aaaf25767def921050ee43" +checksum = "628be5b9b75e4f4c4f2a71d985bbaca4f23de356dc83f1625454c505f5eef4df" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -756,7 +756,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", "tokio", "tower 0.5.1", "tracing", @@ -766,9 +766,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39139015a5ec127d9c895b49b484608e27fe4538544f84cdf5eae0bd36339bc6" +checksum = "4e24412cf72f79c95cd9b1d9482e3a31f9d94c24b43c4b3b710cc8d4341eaab0" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -781,9 +781,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b4f865b13bb8648e93f812b19b74838b9165212a2beb95fc386188c443a5e3" +checksum = "0577a1f67ce70ece3f2b27cf1011da7222ef0a5701f7dcb558e5356278eeb531" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -802,14 +802,14 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af91e3521b8b3eac26809b1c6f9b86e3ed455dfab812f036836aabdf709b921" +checksum = "1ca46272d17f9647fdb56080ed26c72b3ea5078416831130f5ed46f3b4be0ed6" dependencies = [ "alloy-pubsub", "alloy-transport", "futures", - "http 1.1.0", + "http 1.2.0", "rustls 0.23.19", "serde_json", "tokio", @@ -820,30 +820,16 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9703ce68b97f8faae6f7739d1e003fc97621b856953cbcdbb2b515743f23288" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "derive_more", - "nybbles", - "serde", - "smallvec", - "tracing", -] - -[[package]] -name = "alloy-trie" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b2e366c0debf0af77766c23694a3f863b02633050e71e096e257ffbd395e50" +checksum = "3a5fd8fea044cc9a8c8a50bb6f28e31f0385d820f116c5b98f6f4e55d6e5590b" dependencies = [ "alloy-primitives", "alloy-rlp", "arrayvec", "derive_more", "nybbles", + "serde", "smallvec", "tracing", ] @@ -961,7 +947,7 @@ dependencies = [ "alloy-transport", "alloy-transport-ipc", "alloy-transport-ws", - "alloy-trie 0.6.0", + "alloy-trie", "anvil-core", "anvil-rpc", "anvil-server", @@ -995,7 +981,7 @@ dependencies = [ "serde_repr", "similar-asserts", "tempfile", - "thiserror 2.0.3", + "thiserror 2.0.4", "tikv-jemallocator", "tokio", "tower 0.4.13", @@ -1017,7 +1003,7 @@ dependencies = [ "alloy-rlp", "alloy-rpc-types", "alloy-serde", - "alloy-trie 0.6.0", + "alloy-trie", "bytes", "foundry-common", "foundry-evm", @@ -1026,7 +1012,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.4", ] [[package]] @@ -1052,7 +1038,7 @@ dependencies = [ "pin-project 1.1.7", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio-util", "tower-http", "tracing", @@ -1060,9 +1046,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "arbitrary" @@ -1212,6 +1198,9 @@ name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +dependencies = [ + "serde", +] [[package]] name = "ascii-canvas" @@ -1360,7 +1349,7 @@ dependencies = [ "aws-sdk-sts", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.60.7", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1391,9 +1380,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.4.3" +version = "1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a10d5c055aa540164d9561a0e2e74ad30f0dcf7393c3a92f6733ddf9c5762468" +checksum = "b5ac934720fbb46206292d2c75b57e67acfc56fe7dfd34fb9a02334af08409ea" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1416,15 +1405,15 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.50.0" +version = "1.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd059dacda4dfd5b57f2bd453fc6555f9acb496cb77508d517da24cf5d73167" +checksum = "3c30f6fd5646b99d9b45ec3a0c22e67112c175b2383100c960d7ee39d96c8d96" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1438,15 +1427,15 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09677244a9da92172c8dc60109b4a9658597d4d298b188dd0018b6a66b410ca4" +checksum = "05ca43a4ef210894f93096039ef1d6fa4ad3edfabb3be92b80908b9f2e4b4eab" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1460,15 +1449,15 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.50.0" +version = "1.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fea2f3a8bb3bd10932ae7ad59cc59f65f270fc9183a7e91f501dc5efbef7ee" +checksum = "abaf490c2e48eed0bb8e2da2fb08405647bd7f253996e0f93b981958ea0f73b0" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1482,15 +1471,15 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.50.0" +version = "1.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ada54e5f26ac246dc79727def52f7f8ed38915cb47781e2a72213957dc3a7d5" +checksum = "b68fde0d69c8bfdc1060ea7da21df3e39f6014da316783336deff0a9ec28f4bf" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-query", "aws-smithy-runtime", "aws-smithy-runtime-api", @@ -1505,9 +1494,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.5" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5619742a0d8f253be760bfbb8e8e8368c69e3587e4637af5754e488a611499b1" +checksum = "7d3820e0c08d0737872ff3c7c1f21ebbb6693d832312d6152bf18ef50a5471c2" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1518,7 +1507,7 @@ dependencies = [ "hex", "hmac", "http 0.2.12", - "http 1.1.0", + "http 1.2.0", "once_cell", "percent-encoding", "sha2", @@ -1566,6 +1555,15 @@ dependencies = [ "aws-smithy-types", ] +[[package]] +name = "aws-smithy-json" +version = "0.61.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4e69cc50921eb913c6b662f8d909131bb3e6ad6cb6090d3a39b66fc5c52095" +dependencies = [ + "aws-smithy-types", +] + [[package]] name = "aws-smithy-query" version = "0.60.7" @@ -1578,9 +1576,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.3" +version = "1.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be28bd063fa91fd871d131fc8b68d7cd4c5fa0869bea68daca50dcb1cbd76be2" +checksum = "9f20685047ca9d6f17b994a07f629c813f08b5bce65523e47124879e60103d45" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1613,7 +1611,7 @@ dependencies = [ "aws-smithy-types", "bytes", "http 0.2.12", - "http 1.1.0", + "http 1.2.0", "pin-project-lite", "tokio", "tracing", @@ -1630,7 +1628,7 @@ dependencies = [ "bytes", "bytes-utils", "http 0.2.12", - "http 1.1.0", + "http 1.2.0", "http-body 0.4.6", "http-body 1.0.1", "http-body-util", @@ -1677,7 +1675,7 @@ dependencies = [ "base64 0.22.1", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "hyper 1.5.1", @@ -1712,7 +1710,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "mime", @@ -1852,9 +1850,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e47d5c63335658326076cf7c81795af665c534ea552da69526d6cef51b12ed9" +checksum = "9276fe602371cd8a7f70fe68c4db55b2d3e92c570627d6ed0427646edfa5cf47" dependencies = [ "bon-macros", "rustversion", @@ -1862,9 +1860,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b162272b6d55562ea30cc937d74ef4d07399e507bfd6eb3860f6a845c7264eef" +checksum = "94828b84b32b4f3ac3865f692fcdbc46c7d0dd87b29658a391d58a244e1ce45a" dependencies = [ "darling", "ident_case", @@ -2204,9 +2202,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "69371e34337c4c984bbe322360c2547210bf632eb2814bbe78a6e87a2935bd2b" dependencies = [ "clap_builder", "clap_derive", @@ -2214,9 +2212,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "6e24c1b4099818523236a8ca881d2b45db98dadfb4625cf6608c12069fcbbde1" dependencies = [ "anstream", "anstyle", @@ -2925,9 +2923,9 @@ dependencies = [ [[package]] name = "divan" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccc40f214f0d9e897cfc72e2edfa5c225d3252f758c537f11ac0a80371c073a6" +checksum = "e0583193020b29b03682d8d33bb53a5b0f50df6daacece12ca99b904cfdcb8c4" dependencies = [ "cfg-if", "clap", @@ -2939,9 +2937,9 @@ dependencies = [ [[package]] name = "divan-macros" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bdb5411188f7f878a17964798c1264b6b0a9f915bd39b20bf99193c923e1b4e" +checksum = "8dc51d98e636f5e3b0759a39257458b22619cac7e96d932da6eeb052891bb67c" dependencies = [ "proc-macro2", "quote", @@ -3498,7 +3496,7 @@ dependencies = [ "strum", "svm-rs", "tempfile", - "thiserror 2.0.3", + "thiserror 2.0.4", "tikv-jemallocator", "tokio", "toml 0.8.19", @@ -3531,7 +3529,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "thiserror 2.0.3", + "thiserror 2.0.4", "toml 0.8.19", "tracing", ] @@ -3546,7 +3544,7 @@ dependencies = [ "itertools 0.13.0", "similar-asserts", "solang-parser", - "thiserror 2.0.3", + "thiserror 2.0.4", "toml 0.8.19", "tracing", "tracing-subscriber", @@ -3734,7 +3732,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.4", "toml 0.8.19", "tracing", "vergen", @@ -3833,7 +3831,7 @@ dependencies = [ "serde_json", "similar-asserts", "terminal_size", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "tower 0.4.13", "tracing", @@ -3892,7 +3890,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "tracing", "winnow", @@ -3926,7 +3924,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "tracing", "walkdir", @@ -3965,7 +3963,7 @@ dependencies = [ "serde_json", "svm-rs", "tempfile", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "walkdir", ] @@ -3999,7 +3997,7 @@ dependencies = [ "similar-asserts", "solang-parser", "tempfile", - "thiserror 2.0.3", + "thiserror 2.0.4", "toml 0.8.19", "toml_edit", "tracing", @@ -4048,7 +4046,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "thiserror 2.0.3", + "thiserror 2.0.4", "tracing", ] @@ -4094,7 +4092,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "tracing", "url", @@ -4130,14 +4128,14 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap 2.6.0", + "indexmap 2.7.0", "itertools 0.13.0", "parking_lot", "proptest", "rand", "revm", "serde", - "thiserror 2.0.3", + "thiserror 2.0.4", "tracing", ] @@ -4171,9 +4169,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3d9ee7669c2a184b83c05393abfa5c9f24ef99b9abefa627fe45660adee0ba" +checksum = "491e9f9f138086b3627a8c406730dfbb6afcdcf688e6da0eb15df52f0c8ed163" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -4187,7 +4185,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", "tokio", "tracing", "url", @@ -4200,7 +4198,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "semver 1.0.23", - "thiserror 2.0.3", + "thiserror 2.0.4", ] [[package]] @@ -4262,7 +4260,7 @@ dependencies = [ "gcloud-sdk", "rpassword", "serde", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "tracing", ] @@ -4439,9 +4437,9 @@ dependencies = [ [[package]] name = "generator" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb949699c3e4df3a183b1d2142cb24277057055ed23c68ed58894f76c517223" +checksum = "cc6bd114ceda131d3b1d665eba35788690ad37f5916457286b32ab6fd3c438dd" dependencies = [ "cfg-if", "libc", @@ -4525,7 +4523,7 @@ dependencies = [ "bstr", "gix-path", "libc", - "thiserror 2.0.3", + "thiserror 2.0.4", ] [[package]] @@ -4537,7 +4535,7 @@ dependencies = [ "bstr", "itoa", "jiff", - "thiserror 2.0.3", + "thiserror 2.0.4", ] [[package]] @@ -4628,7 +4626,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror 2.0.3", + "thiserror 2.0.4", ] [[package]] @@ -4700,7 +4698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr", - "thiserror 2.0.3", + "thiserror 2.0.4", ] [[package]] @@ -4745,7 +4743,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.6.0", + "indexmap 2.7.0", "slab", "tokio", "tokio-util", @@ -4763,8 +4761,8 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.1.0", - "indexmap 2.6.0", + "http 1.2.0", + "indexmap 2.7.0", "slab", "tokio", "tokio-util", @@ -4920,9 +4918,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -4947,7 +4945,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -4958,7 +4956,7 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "pin-project-lite", ] @@ -5031,7 +5029,7 @@ dependencies = [ "futures-channel", "futures-util", "h2 0.4.7", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "httparse", "httpdate", @@ -5065,7 +5063,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", - "http 1.1.0", + "http 1.2.0", "hyper 1.5.1", "hyper-util", "rustls 0.23.19", @@ -5115,7 +5113,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "hyper 1.5.1", "pin-project-lite", @@ -5390,9 +5388,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "arbitrary", "equivalent", @@ -6371,9 +6369,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75353c94e7515fac7d3c280bae56bff3375784a05cb44b317260606292ff6ba9" +checksum = "f9d95d0ec6457ad4d3d7fc0ad41db490b219587ed837ada87a26b28e535db15f" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6382,14 +6380,14 @@ dependencies = [ "alloy-serde", "derive_more", "serde", - "thiserror 2.0.3", + "thiserror 2.0.4", ] [[package]] name = "op-alloy-rpc-types" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "680a86b63fe4c45fbd5dbf1ac6779409565211c4b234d20af94cf1f79d11f23a" +checksum = "eba1b44e2035ec04cc61762cb9b5457d0ecd29d9af631e1a1c107ef571ce2318" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6522,29 +6520,28 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.7.0" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be4817d39f3272f69c59fe05d0535ae6456c2dc2fa1ba02910296c7e0a5c590" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", - "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.7.0" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8781a75c6205af67215f382092b6e0a4ff3734798523e69073d4bcd294ec767b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.90", + "syn 1.0.109", ] [[package]] @@ -6707,7 +6704,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.6.0", + "indexmap 2.7.0", ] [[package]] @@ -7039,7 +7036,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38ee68ae331824036479c84060534b18254c864fa73366c58d86db3b7b811619" dependencies = [ "futures", - "indexmap 2.6.0", + "indexmap 2.7.0", "nix 0.28.0", "tokio", "tracing", @@ -7177,11 +7174,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed1a693391a16317257103ad06a88c6529ac640846021da7c435a06fffdacd7" dependencies = [ "chrono", - "indexmap 2.6.0", + "indexmap 2.7.0", "newtype-uuid", "quick-xml 0.37.1", "strip-ansi-escapes", - "thiserror 2.0.3", + "thiserror 2.0.4", "uuid 1.11.0", ] @@ -7216,7 +7213,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.19", "socket2", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "tracing", ] @@ -7235,7 +7232,7 @@ dependencies = [ "rustls 0.23.19", "rustls-pki-types", "slab", - "thiserror 2.0.3", + "thiserror 2.0.4", "tinyvec", "tracing", "web-time", @@ -7449,7 +7446,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "hyper 1.5.1", @@ -7506,9 +7503,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41bbeb6004cc4ed48d27756f0479011df91a6f5642a3abab9309eda5ce67c4ad" +checksum = "8d056aaa21f36038ab35fe8ce940ee332903a0b4b992b8ca805fb60c85eb2086" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -7519,7 +7516,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] @@ -8193,7 +8190,7 @@ version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.7.0", "itoa", "memchr", "ryu", @@ -8444,6 +8441,9 @@ name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] [[package]] name = "smawk" @@ -8536,7 +8536,7 @@ checksum = "8b6e4eb0b72ed7adbb808897c85de08ea99609774a58c72e3dce55c758043ca2" dependencies = [ "bumpalo", "index_vec", - "indexmap 2.6.0", + "indexmap 2.7.0", "parking_lot", "rayon", "rustc-hash", @@ -8641,7 +8641,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror 2.0.3", + "thiserror 2.0.4", "tokio", "toml_edit", "uuid 1.11.0", @@ -8822,9 +8822,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0523f59468a2696391f2a772edc089342aacd53c3caa2ac3264e598edf119b" +checksum = "219389c1ebe89f8333df8bdfb871f6631c552ff399c23cac02480b6088aad8f0" dependencies = [ "paste", "proc-macro2", @@ -8950,11 +8950,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl 2.0.4", ] [[package]] @@ -8970,9 +8970,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" dependencies = [ "proc-macro2", "quote", @@ -9020,9 +9020,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", @@ -9043,9 +9043,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -9087,9 +9087,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -9187,9 +9187,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -9213,7 +9213,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.7.0", "serde", "serde_spanned", "toml_datetime", @@ -9235,7 +9235,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.7.0", "serde", "serde_spanned", "toml_datetime", @@ -9254,7 +9254,7 @@ dependencies = [ "base64 0.22.1", "bytes", "h2 0.4.7", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "hyper 1.5.1", @@ -9326,7 +9326,7 @@ dependencies = [ "bitflags 2.6.0", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "http-range-header", @@ -9499,7 +9499,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http 1.2.0", "httparse", "log", "rand", @@ -10491,9 +10491,9 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap 2.6.0", + "indexmap 2.7.0", "memchr", - "thiserror 2.0.3", + "thiserror 2.0.4", "zopfli", ] diff --git a/Cargo.toml b/Cargo.toml index 2967d8573a09b..68414b68384e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,7 +170,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } foundry-compilers = { version = "0.12.7", default-features = false } -foundry-fork-db = "0.8.0" +foundry-fork-db = "0.9.0" solang-parser = "=0.3.3" solar-ast = { version = "=0.1.0", default-features = false } solar-parse = { version = "=0.1.0", default-features = false } @@ -178,34 +178,35 @@ solar-parse = { version = "=0.1.0", default-features = false } ## revm revm = { version = "18.0.0", default-features = false } revm-primitives = { version = "14.0.0", default-features = false } -revm-inspectors = { version = "0.12.0", features = ["serde"] } +revm-inspectors = { version = "0.13.0", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.7.0", default-features = false } -alloy-contract = { version = "0.7.0", default-features = false } -alloy-eips = { version = "0.7.0", default-features = false } -alloy-genesis = { version = "0.7.0", default-features = false } -alloy-json-rpc = { version = "0.7.0", default-features = false } -alloy-network = { version = "0.7.0", default-features = false } -alloy-provider = { version = "0.7.0", default-features = false } -alloy-pubsub = { version = "0.7.0", default-features = false } -alloy-rpc-client = { version = "0.7.0", default-features = false } -alloy-rpc-types = { version = "0.7.0", default-features = true } -alloy-serde = { version = "0.7.0", default-features = false } -alloy-signer = { version = "0.7.0", default-features = false } -alloy-signer-aws = { version = "0.7.0", default-features = false } -alloy-signer-gcp = { version = "0.7.0", default-features = false } -alloy-signer-ledger = { version = "0.7.0", default-features = false } -alloy-signer-local = { version = "0.7.0", default-features = false } -alloy-signer-trezor = { version = "0.7.0", default-features = false } -alloy-transport = { version = "0.7.0", default-features = false } -alloy-transport-http = { version = "0.7.0", default-features = false } -alloy-transport-ipc = { version = "0.7.0", default-features = false } -alloy-transport-ws = { version = "0.7.0", default-features = false } -alloy-node-bindings = { version = "0.7.0", default-features = false } +alloy-consensus = { version = "0.8.0", default-features = false } +alloy-contract = { version = "0.8.0", default-features = false } +alloy-eips = { version = "0.8.0", default-features = false } +alloy-genesis = { version = "0.8.0", default-features = false } +alloy-json-rpc = { version = "0.8.0", default-features = false } +alloy-network = { version = "0.8.0", default-features = false } +alloy-provider = { version = "0.8.0", default-features = false } +alloy-pubsub = { version = "0.8.0", default-features = false } +alloy-rpc-client = { version = "0.8.0", default-features = false } +alloy-rpc-types = { version = "0.8.0", default-features = true } +alloy-serde = { version = "0.8.0", default-features = false } +alloy-signer = { version = "0.8.0", default-features = false } +alloy-signer-aws = { version = "0.8.0", default-features = false } +alloy-signer-gcp = { version = "0.8.0", default-features = false } +alloy-signer-ledger = { version = "0.8.0", default-features = false } +alloy-signer-local = { version = "0.8.0", default-features = false } +alloy-signer-trezor = { version = "0.8.0", default-features = false } +alloy-transport = { version = "0.8.0", default-features = false } +alloy-transport-http = { version = "0.8.0", default-features = false } +alloy-transport-ipc = { version = "0.8.0", default-features = false } +alloy-transport-ws = { version = "0.8.0", default-features = false } +alloy-node-bindings = { version = "0.8.0", default-features = false } +alloy-network-primitives = { version = "0.8.0", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.14" @@ -222,11 +223,11 @@ syn-solidity = "0.8.14" alloy-chains = "0.1" alloy-rlp = "0.3" -alloy-trie = "0.6.0" +alloy-trie = "0.7.0" ## op-alloy -op-alloy-rpc-types = "0.7.1" -op-alloy-consensus = "0.7.1" +op-alloy-rpc-types = "0.8.0" +op-alloy-consensus = "0.8.0" ## cli anstream = "0.6" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 4067aa6680fe6..29b8aee88d3c0 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -6,8 +6,8 @@ use alloy_consensus::{ eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, TxEip7702, }, - Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, TxEip2930, - TxEnvelope, TxLegacy, TxReceipt, + Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, TxEnvelope, TxLegacy, + TxReceipt, Typed2718, }; use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718}; use alloy_network::{AnyReceiptEnvelope, AnyRpcTransaction, AnyTransactionReceipt, AnyTxEnvelope}; diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index b6dea48e15c0b..7960cab6ea564 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,6 +1,6 @@ use alloy_chains::Chain; use alloy_dyn_abi::TypedData; -use alloy_primitives::{hex, Address, Signature, B256}; +use alloy_primitives::{hex, Address, PrimitiveSignature as Signature, B256}; use alloy_provider::Provider; use alloy_signer::Signer; use alloy_signer_local::{ diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 7ae6adea861ac..9962a858397fe 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -1,7 +1,7 @@ //! Helper trait and functions to format Ethereum types. use alloy_consensus::{ - Eip658Value, Receipt, ReceiptWithBloom, Transaction as TxTrait, TxEnvelope, TxType, + Eip658Value, Receipt, ReceiptWithBloom, Transaction as TxTrait, TxEnvelope, TxType, Typed2718, }; use alloy_network::{ AnyHeader, AnyReceiptEnvelope, AnyRpcBlock, AnyTransactionReceipt, AnyTxEnvelope, From b0906386497c03aef53f67b929ca6418aebe34ed Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 10 Dec 2024 15:33:36 +0200 Subject: [PATCH 1784/1963] fix(cheatcodes): clear orderings together with trace steps on debug trace stop (#9529) fix(cheatcodes): empty ordering and step logs too --- crates/cheatcodes/src/evm.rs | 3 ++- crates/forge/tests/cli/test_cmd.rs | 41 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 6c1a4718512d7..9f8eb27a489a3 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -855,11 +855,12 @@ impl Cheatcode for stopAndReturnDebugTraceRecordingCall { let debug_steps: Vec = steps.iter().map(|&step| convert_call_trace_to_debug_step(step)).collect(); - // Free up memory by clearing the steps if they are not recorded outside of cheatcode usage. if !record_info.original_tracer_config.record_steps { tracer.traces_mut().nodes_mut().iter_mut().for_each(|node| { node.trace.steps = Vec::new(); + node.logs = Vec::new(); + node.ordering = Vec::new(); }); } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index fa3d72e0dd5e4..6431c5424f79c 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2724,3 +2724,44 @@ Encountered a total of 1 failing tests, 0 tests succeeded "#]]); }); + +// Tests that `start/stopAndReturn` debugTraceRecording does not panic when running with +// verbosity > 3. +forgetest_init!(should_not_panic_on_debug_trace_verbose, |prj, cmd| { + prj.add_test( + "DebugTraceRecordingTest.t.sol", + r#" +import "forge-std/Test.sol"; +import {Counter} from "../src/Counter.sol"; + +contract DebugTraceRecordingTest is Test { + function test_start_stop_recording() public { + vm.startDebugTraceRecording(); + Counter counter = new Counter(); + counter.increment(); + vm.stopAndReturnDebugTraceRecording(); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "test_start_stop_recording", "-vvvv"]).assert_success().stdout_eq( + str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/DebugTraceRecordingTest.t.sol:DebugTraceRecordingTest +[PASS] test_start_stop_recording() ([GAS]) +Traces: + [476338] DebugTraceRecordingTest::test_start_stop_recording() + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]], + ); +}); From 0eff1ef18fa1d21ec1280ed2b8b0f6e1549250ff Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:32:21 +0200 Subject: [PATCH 1785/1963] feat(cheatcodes): skip test suite in setup (#9532) --- crates/forge/src/result.rs | 12 ++++++--- crates/forge/src/runner.rs | 13 +++++---- crates/forge/tests/cli/test_cmd.rs | 42 ++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 28b52d74c1f03..eed3f2977e90b 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -482,10 +482,10 @@ impl TestResult { Self { status: TestStatus::Failure, reason: Some(reason), ..Default::default() } } - /// Creates a failed test setup result. - pub fn setup_fail(setup: TestSetup) -> Self { + /// Creates a test setup result. + pub fn setup_result(setup: TestSetup) -> Self { Self { - status: TestStatus::Failure, + status: if setup.skipped { TestStatus::Skipped } else { TestStatus::Failure }, reason: setup.reason, logs: setup.logs, traces: setup.traces, @@ -755,6 +755,8 @@ pub struct TestSetup { /// The reason the setup failed, if it did. pub reason: Option, + /// Whether setup and entire test suite is skipped. + pub skipped: bool, } impl TestSetup { @@ -762,6 +764,10 @@ impl TestSetup { Self { reason: Some(reason), ..Default::default() } } + pub fn skipped(reason: String) -> Self { + Self { reason: Some(reason), skipped: true, ..Default::default() } + } + pub fn extend(&mut self, raw: RawCallResult, trace_kind: TraceKind) { self.logs.extend(raw.logs); self.labels.extend(raw.labels); diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 0948df6d1b0df..ef769c6625e32 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -98,10 +98,13 @@ impl<'a> ContractRunner<'a> { /// Deploys the test contract inside the runner from the sending account, and optionally runs /// the `setUp` function on the test contract. pub fn setup(&mut self, call_setup: bool) -> TestSetup { - match self._setup(call_setup) { - Ok(setup) => setup, - Err(err) => TestSetup::failed(err.to_string()), - } + self._setup(call_setup).unwrap_or_else(|err| { + if err.to_string().contains("skipped") { + TestSetup::skipped(err.to_string()) + } else { + TestSetup::failed(err.to_string()) + } + }) } fn _setup(&mut self, call_setup: bool) -> Result { @@ -333,7 +336,7 @@ impl<'a> ContractRunner<'a> { // The setup failed, so we return a single test result for `setUp` return SuiteResult::new( start.elapsed(), - [("setUp()".to_string(), TestResult::setup_fail(setup))].into(), + [("setUp()".to_string(), TestResult::setup_result(setup))].into(), warnings, ) } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 6431c5424f79c..e8da6a49035a0 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2026,6 +2026,48 @@ Ran 1 test suite [ELAPSED]: 0 tests passed, 0 failed, 6 skipped (6 total tests) "#]]); }); +forgetest_init!(skip_setup, |prj, cmd| { + prj.add_test( + "Counter.t.sol", + r#" +import "forge-std/Test.sol"; + +contract SkipCounterSetup is Test { + + function setUp() public { + vm.skip(true, "skip counter test"); + } + + function test_require1() public pure { + require(1 > 2); + } + + function test_require2() public pure { + require(1 > 2); + } + + function test_require3() public pure { + require(1 > 2); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mc", "SkipCounterSetup"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/Counter.t.sol:SkipCounterSetup +[SKIP: skipped: skip counter test] setUp() ([GAS]) +Suite result: ok. 0 passed; 0 failed; 1 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 0 tests passed, 0 failed, 1 skipped (1 total tests) + +"#]]); +}); + forgetest_init!(should_generate_junit_xml_report, |prj, cmd| { prj.wipe_contracts(); prj.insert_ds_test(); From 91030daee6e622dce6dd725fd4c48bcd36a54f46 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:35:50 +0100 Subject: [PATCH 1786/1963] fix: mark flag incompatibility (#9530) * enforce stricter command compatibility mode for forge test * add conflicting cases for anvil * revert anvil changes, derivation_path is not exclusive to mnemonics --- crates/anvil/src/cmd.rs | 4 ++-- crates/forge/bin/cmd/test/mod.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 7b009a5928133..19e9193f908b7 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -75,7 +75,7 @@ pub struct NodeArgs { /// The EVM hardfork to use. /// - /// Choose the hardfork by name, e.g. `shanghai`, `paris`, `london`, etc... + /// Choose the hardfork by name, e.g. `cancun`, `shanghai`, `paris`, `london`, etc... /// [default: latest] #[arg(long)] pub hardfork: Option, @@ -177,7 +177,7 @@ pub struct NodeArgs { /// Max number of states to persist on disk. /// /// Note that `prune_history` will overwrite `max_persisted_states` to 0. - #[arg(long)] + #[arg(long, conflicts_with = "prune_history")] pub max_persisted_states: Option, /// Number of blocks with transactions to keep in memory. diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index c55eb520ae256..85f75a19be2d5 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -79,7 +79,7 @@ pub struct TestArgs { /// /// If the matching test is a fuzz test, then it will open the debugger on the first failure /// case. If the fuzz test does not fail, it will open the debugger on the last fuzz case. - #[arg(long, value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] + #[arg(long, conflicts_with_all = ["flamegraph", "flamechart", "decode_internal", "rerun"], value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] debug: Option>, /// Generate a flamegraph for a single test. Implies `--decode-internal`. @@ -123,7 +123,7 @@ pub struct TestArgs { allow_failure: bool, /// Output test results as JUnit XML report. - #[arg(long, conflicts_with_all = ["quiet", "json", "gas_report"], help_heading = "Display options")] + #[arg(long, conflicts_with_all = ["quiet", "json", "gas_report", "summary", "list", "show_progress"], help_heading = "Display options")] pub junit: bool, /// Stop running tests after the first failure. @@ -135,7 +135,7 @@ pub struct TestArgs { etherscan_api_key: Option, /// List tests instead of running them. - #[arg(long, short, help_heading = "Display options")] + #[arg(long, short, conflicts_with_all = ["show_progress", "decode_internal", "summary"], help_heading = "Display options")] list: bool, /// Set seed used to generate randomness during your fuzz runs. @@ -154,7 +154,7 @@ pub struct TestArgs { pub fuzz_input_file: Option, /// Show test execution progress. - #[arg(long)] + #[arg(long, conflicts_with_all = ["quiet", "json"], help_heading = "Display options")] pub show_progress: bool, #[command(flatten)] From 09894efa7d8c0256d68cd0ec92b01ba3191bdfe8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 15:59:58 +0000 Subject: [PATCH 1787/1963] chore(deps): weekly `cargo update` (#9533) Locking 36 packages to latest compatible versions Updating alloy-chains v0.1.47 -> v0.1.48 Updating alloy-rlp v0.3.9 -> v0.3.10 Updating alloy-rlp-derive v0.3.9 -> v0.3.10 Updating annotate-snippets v0.11.4 -> v0.11.5 Updating bon v3.2.0 -> v3.3.0 Updating bon-macros v3.2.0 -> v3.3.0 Updating cc v1.2.2 -> v1.2.3 Updating chrono v0.4.38 -> v0.4.39 Updating clap v4.5.22 -> v4.5.23 Updating clap_builder v4.5.22 -> v4.5.23 Updating clap_lex v0.7.3 -> v0.7.4 Updating evmole v0.6.1 -> v0.6.2 Updating fastrand v2.2.0 -> v2.3.0 Updating js-sys v0.3.74 -> v0.3.76 Updating libc v0.2.167 -> v0.2.168 Updating pest v2.7.14 -> v2.7.15 Updating pest_derive v2.7.14 -> v2.7.15 Updating pest_generator v2.7.14 -> v2.7.15 Updating pest_meta v2.7.14 -> v2.7.15 Updating prost v0.13.3 -> v0.13.4 Updating prost-derive v0.13.3 -> v0.13.4 Updating prost-types v0.13.3 -> v0.13.4 Updating quinn-udp v0.5.7 -> v0.5.8 Updating rustix v0.38.41 -> v0.38.42 Updating thiserror v2.0.4 -> v2.0.6 Updating thiserror-impl v2.0.4 -> v2.0.6 Updating tokio-rustls v0.26.0 -> v0.26.1 Updating tokio-stream v0.1.16 -> v0.1.17 Updating tracy-client v0.17.4 -> v0.17.5 Updating wasm-bindgen v0.2.97 -> v0.2.99 Updating wasm-bindgen-backend v0.2.97 -> v0.2.99 Updating wasm-bindgen-futures v0.4.47 -> v0.4.49 Updating wasm-bindgen-macro v0.2.97 -> v0.2.99 Updating wasm-bindgen-macro-support v0.2.97 -> v0.2.99 Updating wasm-bindgen-shared v0.2.97 -> v0.2.99 Updating web-sys v0.3.74 -> v0.3.76 note: pass `--verbose` to see 10 unchanged dependencies behind latest Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 246 ++++++++++++++++++++++++++--------------------------- 1 file changed, 122 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a69b2ddf3c9bb..1422df4b05959 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.47" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18c5c520273946ecf715c0010b4e3503d7eba9893cd9ce6b7fff5654c4a3c470" +checksum = "a0161082e0edd9013d23083465cc04b20e44b7a15646d36ba7b0cdb7cd6fe18f" dependencies = [ "alloy-primitives", "num_enum", @@ -134,7 +134,7 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -238,7 +238,7 @@ dependencies = [ "alloy-sol-types", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", ] @@ -264,7 +264,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -292,7 +292,7 @@ dependencies = [ "rand", "serde_json", "tempfile", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", "url", ] @@ -365,7 +365,7 @@ dependencies = [ "schnellru", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tracing", "url", @@ -393,9 +393,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0822426598f95e45dd1ea32a738dac057529a709ee645fcc516ffa4cbde08f" +checksum = "f542548a609dca89fcd72b3b9f355928cf844d4363c5eed9c5273a3dd225e097" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -404,9 +404,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" +checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", @@ -537,7 +537,7 @@ dependencies = [ "alloy-serde", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -576,7 +576,7 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -593,7 +593,7 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", ] @@ -611,7 +611,7 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", ] @@ -631,7 +631,7 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.23", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", ] @@ -651,7 +651,7 @@ dependencies = [ "eth-keystore", "k256", "rand", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -666,7 +666,7 @@ dependencies = [ "alloy-signer", "async-trait", "semver 1.0.23", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", "trezor-client", ] @@ -756,7 +756,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tower 0.5.1", "tracing", @@ -864,12 +864,12 @@ dependencies = [ [[package]] name = "annotate-snippets" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e35ed54e5ea7997c14ed4c70ba043478db1112e98263b3b035907aa197d991" +checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4" dependencies = [ "anstyle", - "unicode-width 0.1.14", + "unicode-width 0.2.0", ] [[package]] @@ -981,7 +981,7 @@ dependencies = [ "serde_repr", "similar-asserts", "tempfile", - "thiserror 2.0.4", + "thiserror 2.0.6", "tikv-jemallocator", "tokio", "tower 0.4.13", @@ -1012,7 +1012,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -1038,7 +1038,7 @@ dependencies = [ "pin-project 1.1.7", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio-util", "tower-http", "tracing", @@ -1850,9 +1850,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9276fe602371cd8a7f70fe68c4db55b2d3e92c570627d6ed0427646edfa5cf47" +checksum = "f265cdb2e8501f1c952749e78babe8f1937be92c98120e5f78fc72d634682bad" dependencies = [ "bon-macros", "rustversion", @@ -1860,9 +1860,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94828b84b32b4f3ac3865f692fcdbc46c7d0dd87b29658a391d58a244e1ce45a" +checksum = "38aa5c627cd7706490e5b003d685f8b9d69bc343b1a00b9fdd01e75fdf6827cf" dependencies = [ "darling", "ident_case", @@ -2087,9 +2087,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" +checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" dependencies = [ "shlex", ] @@ -2152,9 +2152,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -2202,9 +2202,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.22" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69371e34337c4c984bbe322360c2547210bf632eb2814bbe78a6e87a2935bd2b" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -2212,9 +2212,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.22" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e24c1b4099818523236a8ca881d2b45db98dadfb4625cf6608c12069fcbbde1" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -2258,9 +2258,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "clearscreen" @@ -3263,9 +3263,9 @@ dependencies = [ [[package]] name = "evmole" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58e21c69e0ae62877b65241d25cae9e28477818482fab8c1101d15289725a46" +checksum = "c19906a94bb5656904a6c9c0f36d492cb1da96f284d59bb56f555bd472d96e51" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -3289,9 +3289,9 @@ checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fastrlp" @@ -3496,7 +3496,7 @@ dependencies = [ "strum", "svm-rs", "tempfile", - "thiserror 2.0.4", + "thiserror 2.0.6", "tikv-jemallocator", "tokio", "toml 0.8.19", @@ -3529,7 +3529,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "thiserror 2.0.4", + "thiserror 2.0.6", "toml 0.8.19", "tracing", ] @@ -3544,7 +3544,7 @@ dependencies = [ "itertools 0.13.0", "similar-asserts", "solang-parser", - "thiserror 2.0.4", + "thiserror 2.0.6", "toml 0.8.19", "tracing", "tracing-subscriber", @@ -3732,7 +3732,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", "toml 0.8.19", "tracing", "vergen", @@ -3831,7 +3831,7 @@ dependencies = [ "serde_json", "similar-asserts", "terminal_size", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tower 0.4.13", "tracing", @@ -3890,7 +3890,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tracing", "winnow", @@ -3924,7 +3924,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tracing", "walkdir", @@ -3963,7 +3963,7 @@ dependencies = [ "serde_json", "svm-rs", "tempfile", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "walkdir", ] @@ -3997,7 +3997,7 @@ dependencies = [ "similar-asserts", "solang-parser", "tempfile", - "thiserror 2.0.4", + "thiserror 2.0.6", "toml 0.8.19", "toml_edit", "tracing", @@ -4046,7 +4046,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", ] @@ -4092,7 +4092,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tracing", "url", @@ -4135,7 +4135,7 @@ dependencies = [ "rand", "revm", "serde", - "thiserror 2.0.4", + "thiserror 2.0.6", "tracing", ] @@ -4185,7 +4185,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tracing", "url", @@ -4198,7 +4198,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "semver 1.0.23", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -4260,7 +4260,7 @@ dependencies = [ "gcloud-sdk", "rpassword", "serde", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tracing", ] @@ -4523,7 +4523,7 @@ dependencies = [ "bstr", "gix-path", "libc", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -4535,7 +4535,7 @@ dependencies = [ "bstr", "itoa", "jiff", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -4626,7 +4626,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -4698,7 +4698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -5070,7 +5070,7 @@ dependencies = [ "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tower-service", "webpki-roots", ] @@ -5580,9 +5580,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.74" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ "once_cell", "wasm-bindgen", @@ -5718,9 +5718,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.167" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "libdbus-sys" @@ -6380,7 +6380,7 @@ dependencies = [ "alloy-serde", "derive_more", "serde", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -6654,20 +6654,20 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" +checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 1.0.69", + "thiserror 2.0.6", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" +checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e" dependencies = [ "pest", "pest_generator", @@ -6675,9 +6675,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" +checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b" dependencies = [ "pest", "pest_meta", @@ -6688,9 +6688,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" +checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea" dependencies = [ "once_cell", "pest", @@ -7093,9 +7093,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" dependencies = [ "bytes", "prost-derive", @@ -7103,9 +7103,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" dependencies = [ "anyhow", "itertools 0.13.0", @@ -7116,9 +7116,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" dependencies = [ "prost", ] @@ -7178,7 +7178,7 @@ dependencies = [ "newtype-uuid", "quick-xml 0.37.1", "strip-ansi-escapes", - "thiserror 2.0.4", + "thiserror 2.0.6", "uuid 1.11.0", ] @@ -7213,7 +7213,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.19", "socket2", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "tracing", ] @@ -7232,7 +7232,7 @@ dependencies = [ "rustls 0.23.19", "rustls-pki-types", "slab", - "thiserror 2.0.4", + "thiserror 2.0.6", "tinyvec", "tracing", "web-time", @@ -7240,9 +7240,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" +checksum = "52cd4b1eff68bf27940dd39811292c49e007f4d0b4c357358dc9b0197be6b527" dependencies = [ "cfg_aliases 0.2.1", "libc", @@ -7473,7 +7473,7 @@ dependencies = [ "sync_wrapper 1.0.2", "tokio", "tokio-native-tls", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tokio-socks", "tokio-util", "tower-service", @@ -7516,7 +7516,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -7737,15 +7737,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.41" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -8641,7 +8641,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror 2.0.4", + "thiserror 2.0.6", "tokio", "toml_edit", "uuid 1.11.0", @@ -8950,11 +8950,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.4" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" dependencies = [ - "thiserror-impl 2.0.4", + "thiserror-impl 2.0.6", ] [[package]] @@ -8970,9 +8970,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.4" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" dependencies = [ "proc-macro2", "quote", @@ -9136,12 +9136,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ "rustls 0.23.19", - "rustls-pki-types", "tokio", ] @@ -9159,9 +9158,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -9180,7 +9179,7 @@ dependencies = [ "rustls 0.23.19", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tungstenite", "webpki-roots", ] @@ -9267,7 +9266,7 @@ dependencies = [ "rustls-pemfile 2.2.0", "socket2", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tokio-stream", "tower 0.4.13", "tower-layer", @@ -9451,9 +9450,9 @@ dependencies = [ [[package]] name = "tracy-client" -version = "0.17.4" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "746b078c6a09ebfd5594609049e07116735c304671eaab06ce749854d23435bc" +checksum = "51e295eae54124872df35720dc3a5b1e827c7deee352b342ec7f7e626d0d0ef3" dependencies = [ "loom", "once_cell", @@ -9782,9 +9781,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -9793,13 +9792,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn 2.0.90", @@ -9808,9 +9806,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.47" +version = "0.4.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" +checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" dependencies = [ "cfg-if", "js-sys", @@ -9821,9 +9819,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9831,9 +9829,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -9844,9 +9842,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "wasm-streams" @@ -9940,9 +9938,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.74" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", @@ -10493,7 +10491,7 @@ dependencies = [ "flate2", "indexmap 2.7.0", "memchr", - "thiserror 2.0.4", + "thiserror 2.0.6", "zopfli", ] From 59f354c179f4e7f6d7292acb3d068815c79286d1 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:08:40 +0200 Subject: [PATCH 1788/1963] fix(fuzz): exclude exernal libraries addresses from fuzz inputs (#9527) --- crates/evm/evm/src/executors/fuzz/mod.rs | 14 ++++-- crates/evm/evm/src/executors/invariant/mod.rs | 11 +++-- crates/evm/fuzz/src/strategies/param.rs | 16 ++++++- crates/evm/fuzz/src/strategies/state.rs | 10 ++++- crates/forge/src/result.rs | 2 + crates/forge/src/runner.rs | 8 ++++ crates/forge/tests/it/core.rs | 4 +- crates/forge/tests/it/repros.rs | 3 ++ testdata/default/repros/Issue8639.t.sol | 43 +++++++++++++++++++ 9 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 testdata/default/repros/Issue8639.t.sol diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index 0d79f8fa49610..b99499cf3c5ba 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -77,10 +77,12 @@ impl FuzzedExecutor { /// test case. /// /// Returns a list of all the consumed gas and calldata of every fuzz case + #[allow(clippy::too_many_arguments)] pub fn fuzz( &self, func: &Function, fuzz_fixtures: &FuzzFixtures, + deployed_libs: &[Address], address: Address, should_fail: bool, rd: &RevertDecoder, @@ -88,7 +90,7 @@ impl FuzzedExecutor { ) -> FuzzTestResult { // Stores the fuzz test execution data. let execution_data = RefCell::new(FuzzTestData::default()); - let state = self.build_fuzz_state(); + let state = self.build_fuzz_state(deployed_libs); let dictionary_weight = self.config.dictionary.dictionary_weight.min(100); let strategy = proptest::prop_oneof![ 100 - dictionary_weight => fuzz_calldata(func.clone(), fuzz_fixtures), @@ -274,11 +276,15 @@ impl FuzzedExecutor { } /// Stores fuzz state for use with [fuzz_calldata_from_state] - pub fn build_fuzz_state(&self) -> EvmFuzzState { + pub fn build_fuzz_state(&self, deployed_libs: &[Address]) -> EvmFuzzState { if let Some(fork_db) = self.executor.backend().active_fork_db() { - EvmFuzzState::new(fork_db, self.config.dictionary) + EvmFuzzState::new(fork_db, self.config.dictionary, deployed_libs) } else { - EvmFuzzState::new(self.executor.backend().mem_db(), self.config.dictionary) + EvmFuzzState::new( + self.executor.backend().mem_db(), + self.config.dictionary, + deployed_libs, + ) } } } diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index d5fdb5668f5ee..4582e46822a8c 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -323,6 +323,7 @@ impl<'a> InvariantExecutor<'a> { &mut self, invariant_contract: InvariantContract<'_>, fuzz_fixtures: &FuzzFixtures, + deployed_libs: &[Address], progress: Option<&ProgressBar>, ) -> Result { // Throw an error to abort test run if the invariant function accepts input params @@ -331,7 +332,7 @@ impl<'a> InvariantExecutor<'a> { } let (invariant_test, invariant_strategy) = - self.prepare_test(&invariant_contract, fuzz_fixtures)?; + self.prepare_test(&invariant_contract, fuzz_fixtures, deployed_libs)?; // Start timer for this invariant test. let timer = FuzzTestTimer::new(self.config.timeout); @@ -506,6 +507,7 @@ impl<'a> InvariantExecutor<'a> { &mut self, invariant_contract: &InvariantContract<'_>, fuzz_fixtures: &FuzzFixtures, + deployed_libs: &[Address], ) -> Result<(InvariantTest, impl Strategy)> { // Finds out the chosen deployed contracts and/or senders. self.select_contract_artifacts(invariant_contract.address)?; @@ -513,8 +515,11 @@ impl<'a> InvariantExecutor<'a> { self.select_contracts_and_senders(invariant_contract.address)?; // Stores fuzz state for use with [fuzz_calldata_from_state]. - let fuzz_state = - EvmFuzzState::new(self.executor.backend().mem_db(), self.config.dictionary); + let fuzz_state = EvmFuzzState::new( + self.executor.backend().mem_db(), + self.config.dictionary, + deployed_libs, + ); // Creates the invariant strategy. let strategy = invariant_strat( diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 7e5218fd872ba..643c70bde3d47 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -130,7 +130,19 @@ pub fn fuzz_param_from_state( // Convert the value based on the parameter type match *param { DynSolType::Address => { - value().prop_map(move |value| DynSolValue::Address(Address::from_word(value))).boxed() + let deployed_libs = state.deployed_libs.clone(); + value() + .prop_filter_map("filter address fuzzed from state", move |value| { + let fuzzed_addr = Address::from_word(value); + // Do not use addresses of deployed libraries as fuzz input. + // See . + if !deployed_libs.contains(&fuzzed_addr) { + Some(DynSolValue::Address(fuzzed_addr)) + } else { + None + } + }) + .boxed() } DynSolType::Function => value() .prop_map(move |value| { @@ -217,7 +229,7 @@ mod tests { let f = "testArray(uint64[2] calldata values)"; let func = get_func(f).unwrap(); let db = CacheDB::new(EmptyDB::default()); - let state = EvmFuzzState::new(&db, FuzzDictionaryConfig::default()); + let state = EvmFuzzState::new(&db, FuzzDictionaryConfig::default(), &[]); let strategy = proptest::prop_oneof![ 60 => fuzz_calldata(func.clone(), &FuzzFixtures::default()), 40 => fuzz_calldata_from_state(func, &state), diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 4df55772c4367..b1c5d8e004243 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -27,10 +27,16 @@ const PUSH_BYTE_ANALYSIS_LIMIT: usize = 24 * 1024; #[derive(Clone, Debug)] pub struct EvmFuzzState { inner: Arc>, + /// Addresses of external libraries deployed in test setup, excluded from fuzz test inputs. + pub deployed_libs: Vec
, } impl EvmFuzzState { - pub fn new(db: &CacheDB, config: FuzzDictionaryConfig) -> Self { + pub fn new( + db: &CacheDB, + config: FuzzDictionaryConfig, + deployed_libs: &[Address], + ) -> Self { // Sort accounts to ensure deterministic dictionary generation from the same setUp state. let mut accs = db.accounts.iter().collect::>(); accs.sort_by_key(|(address, _)| *address); @@ -38,7 +44,7 @@ impl EvmFuzzState { // Create fuzz dictionary and insert values from db state. let mut dictionary = FuzzDictionary::new(config); dictionary.insert_db_values(accs); - Self { inner: Arc::new(RwLock::new(dictionary)) } + Self { inner: Arc::new(RwLock::new(dictionary)), deployed_libs: deployed_libs.to_vec() } } pub fn collect_values(&self, values: impl IntoIterator) { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index eed3f2977e90b..5b134194fe976 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -752,6 +752,8 @@ pub struct TestSetup { pub traces: Traces, /// Coverage info during setup. pub coverage: Option, + /// Addresses of external libraries deployed during setup. + pub deployed_libs: Vec
, /// The reason the setup failed, if it did. pub reason: Option, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index ef769c6625e32..7b1293a72824f 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -130,6 +130,12 @@ impl<'a> ContractRunner<'a> { U256::ZERO, Some(&self.mcr.revert_decoder), ); + + // Record deployed library address. + if let Ok(deployed) = &deploy_result { + result.deployed_libs.push(deployed.address); + } + let (raw, reason) = RawCallResult::from_evm_result(deploy_result.map(Into::into))?; result.extend(raw, TraceKind::Deployment); if reason.is_some() { @@ -614,6 +620,7 @@ impl<'a> FunctionRunner<'a> { let invariant_result = match evm.invariant_fuzz( invariant_contract.clone(), &self.setup.fuzz_fixtures, + &self.setup.deployed_libs, progress.as_ref(), ) { Ok(x) => x, @@ -728,6 +735,7 @@ impl<'a> FunctionRunner<'a> { let result = fuzzed_executor.fuzz( func, &self.setup.fuzz_fixtures, + &self.setup.deployed_libs, self.address, should_fail, &self.cr.mcr.revert_decoder, diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index a2b4916d3e7cf..94dc945e5938b 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -742,8 +742,8 @@ async fn test_trace() { assert_eq!( deployment_traces.count(), - 12, - "Test {test_name} did not have exactly 12 deployment trace." + 13, + "Test {test_name} did not have exactly 13 deployment trace." ); assert!(setup_traces.count() <= 1, "Test {test_name} had more than 1 setup trace."); assert_eq!( diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 96708bdf5548b..2a47d3d3efd16 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -386,3 +386,6 @@ test_repro!(8971; |config| { prj_config.isolate = true; config.runner.config = Arc::new(prj_config); }); + +// https://github.com/foundry-rs/foundry/issues/8639 +test_repro!(8639); diff --git a/testdata/default/repros/Issue8639.t.sol b/testdata/default/repros/Issue8639.t.sol new file mode 100644 index 0000000000000..6f0a7b526336f --- /dev/null +++ b/testdata/default/repros/Issue8639.t.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "ds-test/test.sol"; + +library ExternalLibrary { + function doWork(uint256 a) public returns (uint256) { + return a++; + } +} + +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + ExternalLibrary.doWork(1); + } + + function increment() public {} +} + +// https://github.com/foundry-rs/foundry/issues/8639 +contract Issue8639Test is DSTest { + Counter counter; + + function setUp() public { + counter = new Counter(); + } + + /// forge-config: default.fuzz.runs = 1000 + /// forge-config: default.fuzz.seed = '100' + function test_external_library_address(address test) public { + require(test != address(ExternalLibrary)); + } +} + +contract Issue8639AnotherTest is DSTest { + /// forge-config: default.fuzz.runs = 1000 + /// forge-config: default.fuzz.seed = '100' + function test_another_external_library_address(address test) public { + require(test != address(ExternalLibrary)); + } +} From c4fcf12d4f43368774748cab9775d9200be3a6c0 Mon Sep 17 00:00:00 2001 From: Jacob T Firek <106350168+jtfirek@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:18:24 -0500 Subject: [PATCH 1789/1963] Update incorrect documentation in the READ.me (#9538) Update README.md --- crates/config/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/config/README.md b/crates/config/README.md index 9fcd30ac99dc8..0aa2802e39528 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -159,7 +159,7 @@ use_literal_content = false # use ipfs method to generate the metadata hash, solc's default. # To not include the metadata hash, to allow for deterministic code: https://docs.soliditylang.org/en/latest/metadata.html, use "none" bytecode_hash = "ipfs" -# Whether to append the metadata hash to the bytecode +# Whether to append the CBOR-encoded metadata file. cbor_metadata = true # How to treat revert (and require) reason strings. # Possible values are: "default", "strip", "debug" and "verboseDebug". From 539760c2d158c91c28cc3d3400963e09f49882ba Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:26:18 +0530 Subject: [PATCH 1790/1963] fix(`anvil`): set `best_number` to `state.block.number` if greater (#9543) fix(`anvil`): set `best_number` correctly while loading state with fork activated --- crates/anvil/src/eth/backend/mem/mod.rs | 26 ++++++++++++++++--- crates/anvil/tests/it/state.rs | 33 ++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 26787cca60cf5..dfd96c72391a5 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -922,10 +922,28 @@ impl Backend { let fork_num_and_hash = self.get_fork().map(|f| (f.block_number(), f.block_hash())); if let Some((number, hash)) = fork_num_and_hash { - // If loading state file on a fork, set best number to the fork block number. - // Ref: https://github.com/foundry-rs/foundry/pull/9215#issue-2618681838 - self.blockchain.storage.write().best_number = U64::from(number); - self.blockchain.storage.write().best_hash = hash; + let best_number = state.best_block_number.unwrap_or(block.number.to::()); + trace!(target: "backend", state_block_number=?best_number, fork_block_number=?number); + // If the state.block_number is greater than the fork block number, set best number + // to the state block number. + // Ref: https://github.com/foundry-rs/foundry/issues/9539 + if best_number.to::() > number { + self.blockchain.storage.write().best_number = best_number; + let best_hash = + self.blockchain.storage.read().hash(best_number.into()).ok_or_else( + || { + BlockchainError::RpcError(RpcError::internal_error_with(format!( + "Best hash not found for best number {best_number}", + ))) + }, + )?; + self.blockchain.storage.write().best_hash = best_hash; + } else { + // If loading state file on a fork, set best number to the fork block number. + // Ref: https://github.com/foundry-rs/foundry/pull/9215#issue-2618681838 + self.blockchain.storage.write().best_number = U64::from(number); + self.blockchain.storage.write().best_hash = hash; + } } else { let best_number = state.best_block_number.unwrap_or(block.number.to::()); self.blockchain.storage.write().best_number = best_number; diff --git a/crates/anvil/tests/it/state.rs b/crates/anvil/tests/it/state.rs index f7736de2f4030..5337b36b561f5 100644 --- a/crates/anvil/tests/it/state.rs +++ b/crates/anvil/tests/it/state.rs @@ -2,7 +2,7 @@ use crate::abi::Greeter; use alloy_network::{ReceiptResponse, TransactionBuilder}; -use alloy_primitives::{address, utils::Unit, Bytes, Uint, U256}; +use alloy_primitives::{address, utils::Unit, Bytes, Uint, U256, U64}; use alloy_provider::Provider; use alloy_rpc_types::{BlockId, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -245,3 +245,34 @@ async fn test_fork_load_state() { assert_eq!(balance_alice + value, latest_balance_alice); } + +// +#[tokio::test(flavor = "multi_thread")] +async fn test_fork_load_state_with_greater_state_block() { + let (api, _handle) = spawn( + NodeConfig::test() + .with_eth_rpc_url(Some(next_http_rpc_endpoint())) + .with_fork_block_number(Some(21070682u64)), + ) + .await; + + api.mine_one().await; + + let block_number = api.block_number().unwrap(); + + let serialized_state = api.serialized_state(false).await.unwrap(); + + assert_eq!(serialized_state.best_block_number, Some(block_number.to::())); + + let (api, _handle) = spawn( + NodeConfig::test() + .with_eth_rpc_url(Some(next_http_rpc_endpoint())) + .with_fork_block_number(Some(21070682u64)) // Forked chain has moved forward + .with_init_state(Some(serialized_state)), + ) + .await; + + let new_block_number = api.block_number().unwrap(); + + assert_eq!(new_block_number, block_number); +} From 2eec0982c0640c6998c8dcd9cb57740fe4434168 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:40:40 +0530 Subject: [PATCH 1791/1963] fix(`cast`): reset `env.tx.caller` for impersonated txs (#9544) * fix(`cast`): reset `env.tx.caller` for impersonated txs * test --- crates/cast/bin/cmd/run.rs | 14 +++++++++++- crates/cast/tests/cli/main.rs | 41 +++++++++++++++++++++++++++++++--- crates/common/src/constants.rs | 23 ++++++++++++++++++- 3 files changed, 73 insertions(+), 5 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 7ab5ddd511f90..4b26c848ef66b 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -10,7 +10,7 @@ use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, utils::{handle_traces, init_progress, TraceResult}, }; -use foundry_common::{is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_impersonated_tx, is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{ figment::{ @@ -212,6 +212,12 @@ impl RunArgs { configure_tx_env(&mut env, &tx.inner); + if is_impersonated_tx(&tx.inner.inner) { + // If the transaction is impersonated, we need to set the caller to the from + // address Ref: https://github.com/foundry-rs/foundry/issues/9541 + env.tx.caller = tx.from; + } + if let Some(to) = Transaction::to(tx) { trace!(tx=?tx.tx_hash(),?to, "executing previous call transaction"); executor.transact_with_env(env.clone()).wrap_err_with(|| { @@ -251,6 +257,12 @@ impl RunArgs { configure_tx_env(&mut env, &tx.inner); + if is_impersonated_tx(&tx.inner.inner) { + // If the transaction is impersonated, we need to set the caller to the from address + // Ref: https://github.com/foundry-rs/foundry/issues/9541 + env.tx.caller = tx.from; + } + if let Some(to) = Transaction::to(&tx) { trace!(tx=?tx.tx_hash(), to=?to, "executing call transaction"); TraceResult::try_from(executor.transact_with_env(env))? diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index f2ee990095470..df98427224749 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1,9 +1,10 @@ //! Contains various tests for checking cast commands use alloy_chains::NamedChain; -use alloy_network::TransactionResponse; -use alloy_primitives::{b256, B256}; -use alloy_rpc_types::{BlockNumberOrTag, Index}; +use alloy_network::{TransactionBuilder, TransactionResponse}; +use alloy_primitives::{address, b256, Bytes, B256}; +use alloy_provider::{Provider, ProviderBuilder}; +use alloy_rpc_types::{BlockNumberOrTag, Index, TransactionRequest}; use anvil::{EthereumHardfork, NodeConfig}; use foundry_test_utils::{ casttest, file, forgetest, forgetest_async, @@ -1995,3 +1996,37 @@ forgetest_async!(cast_call_custom_chain_id, |_prj, cmd| { ]) .assert_success(); }); + +// https://github.com/foundry-rs/foundry/issues/9541 +forgetest_async!(cast_run_impersonated_tx, |_prj, cmd| { + let (_api, handle) = anvil::spawn( + NodeConfig::test() + .with_auto_impersonate(true) + .with_eth_rpc_url(Some("https://sepolia.base.org")), + ) + .await; + + let http_endpoint = handle.http_endpoint(); + + let provider = ProviderBuilder::new().on_http(http_endpoint.parse().unwrap()); + + // send impersonated tx + let tx = TransactionRequest::default() + .with_from(address!("041563c07028Fc89106788185763Fc73028e8511")) + .with_to(address!("F38aA5909D89F5d98fCeA857e708F6a6033f6CF8")) + .with_input( + Bytes::from_str( + "0x60fe47b1000000000000000000000000000000000000000000000000000000000000000c", + ) + .unwrap(), + ); + + let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); + + assert!(receipt.status()); + + // run impersonated tx + cmd.cast_fuse() + .args(["run", &receipt.transaction_hash.to_string(), "--rpc-url", &http_endpoint]) + .assert_success(); +}); diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 4ff3eb8d70fbb..c67131585ba29 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -1,6 +1,8 @@ //! Commonly used constants. -use alloy_primitives::{address, Address}; +use alloy_consensus::Typed2718; +use alloy_network::AnyTxEnvelope; +use alloy_primitives::{address, Address, PrimitiveSignature, B256}; use std::time::Duration; /// The dev chain-id, inherited from hardhat @@ -53,6 +55,25 @@ pub fn is_known_system_sender(sender: Address) -> bool { [ARBITRUM_SENDER, OPTIMISM_SYSTEM_ADDRESS].contains(&sender) } +pub fn is_impersonated_tx(tx: &AnyTxEnvelope) -> bool { + if let AnyTxEnvelope::Ethereum(tx) = tx { + return is_impersonated_sig(tx.signature(), tx.ty()); + } + false +} + +pub fn is_impersonated_sig(sig: &PrimitiveSignature, ty: u8) -> bool { + let impersonated_sig = PrimitiveSignature::from_scalars_and_parity( + B256::with_last_byte(1), + B256::with_last_byte(1), + false, + ); + if ty != SYSTEM_TRANSACTION_TYPE && sig == &impersonated_sig { + return true; + } + false +} + #[cfg(test)] mod tests { use super::*; From e22a9ec015c9462eb33f9c21d83eebcea13dee09 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:15:59 +0200 Subject: [PATCH 1792/1963] chore: Add GH attestation for foundry binaries (#9546) Add GH attestation --- .github/workflows/release.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1377e5d6e48e9..d6b2018d1d842 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,6 +67,10 @@ jobs: uses: ./.github/workflows/docker-publish.yml release: + permissions: + id-token: write + contents: read + attestations: write name: ${{ matrix.target }} (${{ matrix.runner }}) runs-on: ${{ matrix.runner }} timeout-minutes: 240 @@ -156,8 +160,18 @@ jobs: du -h "$bin" || true ldd "$bin" || true $bin --version || true + echo "${name}_bin_path=${bin}" >> $GITHUB_ENV done + - name: Binaries attestation + uses: actions/attest-build-provenance@v2 + with: + subject-path: | + ${{ env.anvil_bin_path }} + ${{ env.cast_bin_path }} + ${{ env.chisel_bin_path }} + ${{ env.forge_bin_path }} + - name: Archive binaries id: artifacts env: From 2f698e4c9747eb035a951186966cfda7aec7359c Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 13 Dec 2024 08:15:05 +0200 Subject: [PATCH 1793/1963] fix(release): allow contents write permission, run attestation after release created (#9550) fix(release): allow contents write permission, run attestation after release published --- .github/workflows/release.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d6b2018d1d842..3e2dac1e80019 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: release: permissions: id-token: write - contents: read + contents: write attestations: write name: ${{ matrix.target }} (${{ matrix.runner }}) runs-on: ${{ matrix.runner }} @@ -163,15 +163,6 @@ jobs: echo "${name}_bin_path=${bin}" >> $GITHUB_ENV done - - name: Binaries attestation - uses: actions/attest-build-provenance@v2 - with: - subject-path: | - ${{ env.anvil_bin_path }} - ${{ env.cast_bin_path }} - ${{ env.chisel_bin_path }} - ${{ env.forge_bin_path }} - - name: Archive binaries id: artifacts env: @@ -228,6 +219,15 @@ jobs: ${{ steps.artifacts.outputs.file_name }} ${{ steps.man.outputs.foundry_man }} + - name: Binaries attestation + uses: actions/attest-build-provenance@v2 + with: + subject-path: | + ${{ env.anvil_bin_path }} + ${{ env.cast_bin_path }} + ${{ env.chisel_bin_path }} + ${{ env.forge_bin_path }} + # If this is a nightly release, it also updates the release # tagged `nightly` for compatibility with `foundryup` - name: Update nightly release From 1276f58ea9ddcebb402fa6e999355bef65c300b9 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 13 Dec 2024 18:00:54 +0400 Subject: [PATCH 1794/1963] chore: bump compilers (#9554) * chore: bump compilers * clippy --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 2 +- crates/config/src/lib.rs | 16 +++++++++++++++- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1422df4b05959..7b650cec7e9ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3862,14 +3862,14 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7235826f00dd9196bcbdbb9c168ea38235601db95883a78819ba2303dee34bb8" +checksum = "d817beee8c566a99f4267f25ff63d0de46c442948496ecef91ead56e3383090c" dependencies = [ "alloy-json-abi", "alloy-primitives", "auto_impl", - "derivative", + "derive_more", "dirs 5.0.1", "dyn-clone", "foundry-compilers-artifacts", @@ -3899,9 +3899,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "097bc5db7be5acf6d92938ad7daabf1932d7aa7c44326cdfc256531a53034d31" +checksum = "bec784a3a809ba2ee723fcfeb737a6ac90b4fd1e4d048c2d49fed6723bd35547" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3909,9 +3909,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4168053c1ad217866c677a074517e8d51988e5b1bad044b95f3c513aa5b6caa" +checksum = "44549c33e5a03408c8d40c36d764b7e84d261258ef481c19e4a612e609fdf8a4" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3933,9 +3933,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b7beffe7182551d01d249f022a5eab17c36c73b39ae8efd404e0fb9c98b9f80" +checksum = "a438605ae74689752b2f717165daac15766f1b2a166d2095715d5f9407084b52" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3948,9 +3948,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac5247875b96dfb99da12d0cd0f6ce98954116d1cf8a9188d613b2a35cd6937b" +checksum = "04ac6d85c3e2d12585f8e698b12ed4880b02716ec7fde5d62de9a194e62f4e36" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 68414b68384e3..b8b0cfbebd008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,7 +169,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } -foundry-compilers = { version = "0.12.7", default-features = false } +foundry-compilers = { version = "0.12.8", default-features = false } foundry-fork-db = "0.9.0" solang-parser = "=0.3.3" solar-ast = { version = "=0.1.0", default-features = false } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 805aaf7cd1634..7264b63f88b03 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -949,6 +949,7 @@ impl Config { } /// Resolves globs and builds a mapping from individual source files to their restrictions + #[expect(clippy::disallowed_macros)] fn restrictions( &self, paths: &ProjectPathsConfig, @@ -977,7 +978,20 @@ impl Config { if !map.contains_key(source) { map.insert(source.clone(), res); } else { - map.get_mut(source.as_path()).unwrap().merge(res); + let value = map.remove(source.as_path()).unwrap(); + if let Some(merged) = value.clone().merge(res) { + map.insert(source.clone(), merged); + } else { + // `sh_warn!` is a circular dependency, preventing us from using it here. + eprintln!( + "{}", + yansi::Paint::yellow(&format!( + "Failed to merge compilation restrictions for {}", + source.display() + )) + ); + map.insert(source.clone(), value); + } } } } From dabacecdc14d074a108c18f97d1e1f63ade37a37 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 13 Dec 2024 20:07:19 +0530 Subject: [PATCH 1795/1963] fix: account for impersonated tx in configure_tx_env (#9553) * chore: account for impersonated tx in configure_tx_env * nit --- crates/cast/bin/cmd/run.rs | 14 +------------- crates/evm/core/src/backend/mod.rs | 2 +- crates/evm/core/src/utils.rs | 13 +++++++++++-- crates/verify/src/bytecode.rs | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 4b26c848ef66b..7ab5ddd511f90 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -10,7 +10,7 @@ use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, utils::{handle_traces, init_progress, TraceResult}, }; -use foundry_common::{is_impersonated_tx, is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE}; +use foundry_common::{is_known_system_sender, shell, SYSTEM_TRANSACTION_TYPE}; use foundry_compilers::artifacts::EvmVersion; use foundry_config::{ figment::{ @@ -212,12 +212,6 @@ impl RunArgs { configure_tx_env(&mut env, &tx.inner); - if is_impersonated_tx(&tx.inner.inner) { - // If the transaction is impersonated, we need to set the caller to the from - // address Ref: https://github.com/foundry-rs/foundry/issues/9541 - env.tx.caller = tx.from; - } - if let Some(to) = Transaction::to(tx) { trace!(tx=?tx.tx_hash(),?to, "executing previous call transaction"); executor.transact_with_env(env.clone()).wrap_err_with(|| { @@ -257,12 +251,6 @@ impl RunArgs { configure_tx_env(&mut env, &tx.inner); - if is_impersonated_tx(&tx.inner.inner) { - // If the transaction is impersonated, we need to set the caller to the from address - // Ref: https://github.com/foundry-rs/foundry/issues/9541 - env.tx.caller = tx.from; - } - if let Some(to) = Transaction::to(&tx) { trace!(tx=?tx.tx_hash(), to=?to, "executing call transaction"); TraceResult::try_from(executor.transact_with_env(env))? diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index cf6e7e8beb0bc..3d162c96f46c6 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1281,7 +1281,7 @@ impl DatabaseExt for Backend { self.commit(journaled_state.state.clone()); let res = { - configure_tx_req_env(&mut env, tx)?; + configure_tx_req_env(&mut env, tx, None)?; let env = self.env_with_handler_cfg(env); let mut db = self.clone(); diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 9a1dd8910c97b..0f29ec2a47540 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -9,6 +9,7 @@ use alloy_network::AnyTxEnvelope; use alloy_primitives::{Address, Selector, TxKind, B256, U256}; use alloy_provider::{network::BlockResponse, Network}; use alloy_rpc_types::{Transaction, TransactionRequest}; +use foundry_common::is_impersonated_tx; use foundry_config::NamedChain; use foundry_fork_db::DatabaseError; use revm::{ @@ -88,16 +89,21 @@ pub fn get_function<'a>( } /// Configures the env for the given RPC transaction. +/// Accounts for an impersonated transaction by resetting the `env.tx.caller` field to `tx.from`. pub fn configure_tx_env(env: &mut revm::primitives::Env, tx: &Transaction) { + let impersonated_from = is_impersonated_tx(&tx.inner).then_some(tx.from); if let AnyTxEnvelope::Ethereum(tx) = &tx.inner { - configure_tx_req_env(env, &tx.clone().into()).expect("cannot fail"); + configure_tx_req_env(env, &tx.clone().into(), impersonated_from).expect("cannot fail"); } } /// Configures the env for the given RPC transaction request. +/// `impersonated_from` is the address of the impersonated account. This helps account for an +/// impersonated transaction by resetting the `env.tx.caller` field to `impersonated_from`. pub fn configure_tx_req_env( env: &mut revm::primitives::Env, tx: &TransactionRequest, + impersonated_from: Option
, ) -> eyre::Result<()> { let TransactionRequest { nonce, @@ -120,7 +126,10 @@ pub fn configure_tx_req_env( // If no `to` field then set create kind: https://eips.ethereum.org/EIPS/eip-2470#deployment-transaction env.tx.transact_to = to.unwrap_or(TxKind::Create); - env.tx.caller = from.ok_or_else(|| eyre::eyre!("missing `from` field"))?; + // If the transaction is impersonated, we need to set the caller to the from + // address Ref: https://github.com/foundry-rs/foundry/issues/9541 + env.tx.caller = + impersonated_from.unwrap_or(from.ok_or_else(|| eyre::eyre!("missing `from` field"))?); env.tx.gas_limit = gas.ok_or_else(|| eyre::eyre!("missing `gas` field"))?; env.tx.nonce = nonce; env.tx.value = value.unwrap_or_default(); diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index d3079fae72cfd..01fcb488631ff 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -261,7 +261,7 @@ impl VerifyBytecodeArgs { // configure_tx_rq_env(&mut env, &gen_tx); - configure_tx_req_env(&mut env, &gen_tx_req) + configure_tx_req_env(&mut env, &gen_tx_req, None) .wrap_err("Failed to configure tx request env")?; // Seed deployer account with funds @@ -478,7 +478,7 @@ impl VerifyBytecodeArgs { } // configure_req__env(&mut env, &transaction.inner); - configure_tx_req_env(&mut env, &transaction) + configure_tx_req_env(&mut env, &transaction, None) .wrap_err("Failed to configure tx request env")?; let fork_address = crate::utils::deploy_contract( From 233bff2f8ef1f958e1676048c85a2bc37efa2241 Mon Sep 17 00:00:00 2001 From: anukul <44864521+anukul@users.noreply.github.com> Date: Sat, 14 Dec 2024 10:53:31 +0200 Subject: [PATCH 1796/1963] fix: read rpc config when using fork cheatcodes (#9547) * read rpc config when using fork cheatcodes * attempt to resolve failed environment variables again * nit: refactor * nit: refactor * fix clippy errors * fix rustfmt errors * run cargofmt * set auth header for fork * remove redundant clone() * Update crates/cheatcodes/src/config.rs --------- Co-authored-by: Matthias Seitz --- crates/cheatcodes/src/config.rs | 37 ++--- crates/cheatcodes/src/evm/fork.rs | 10 +- crates/cheatcodes/src/test.rs | 3 +- crates/chisel/src/dispatcher.rs | 6 +- crates/common/src/provider/mod.rs | 6 + crates/config/src/endpoints.rs | 226 ++++++++++++++++---------- crates/config/src/lib.rs | 95 +++++++---- crates/evm/core/src/fork/multi.rs | 1 + crates/evm/core/src/opts.rs | 4 + crates/forge/tests/it/test_helpers.rs | 20 +-- 10 files changed, 246 insertions(+), 162 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index e0463dfc45354..5bd76d7992514 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -5,7 +5,7 @@ use foundry_common::{fs::normalize_path, ContractsByArtifact}; use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, - ResolvedRpcEndpoints, + ResolvedRpcEndpoint, ResolvedRpcEndpoints, RpcEndpoint, RpcEndpointUrl, }; use foundry_evm_core::opts::EvmOpts; use semver::Version; @@ -185,33 +185,28 @@ impl CheatsConfig { /// - Returns an error if `url_or_alias` is a known alias but references an unresolved env var. /// - Returns an error if `url_or_alias` is not an alias but does not start with a `http` or /// `ws` `scheme` and is not a path to an existing file - pub fn rpc_url(&self, url_or_alias: &str) -> Result { - match self.rpc_endpoints.get(url_or_alias) { - Some(Ok(url)) => Ok(url.clone()), - Some(Err(err)) => { - // try resolve again, by checking if env vars are now set - err.try_resolve().map_err(Into::into) - } - None => { - // check if it's a URL or a path to an existing file to an ipc socket - if url_or_alias.starts_with("http") || - url_or_alias.starts_with("ws") || - // check for existing ipc file - Path::new(url_or_alias).exists() - { - Ok(url_or_alias.into()) - } else { - Err(fmt_err!("invalid rpc url: {url_or_alias}")) - } + pub fn rpc_endpoint(&self, url_or_alias: &str) -> Result { + if let Some(endpoint) = self.rpc_endpoints.get(url_or_alias) { + Ok(endpoint.clone().try_resolve()) + } else { + // check if it's a URL or a path to an existing file to an ipc socket + if url_or_alias.starts_with("http") || + url_or_alias.starts_with("ws") || + // check for existing ipc file + Path::new(url_or_alias).exists() + { + let url = RpcEndpointUrl::Env(url_or_alias.to_string()); + Ok(RpcEndpoint::new(url).resolve()) + } else { + Err(fmt_err!("invalid rpc url: {url_or_alias}")) } } } - /// Returns all the RPC urls and their alias. pub fn rpc_urls(&self) -> Result> { let mut urls = Vec::with_capacity(self.rpc_endpoints.len()); for alias in self.rpc_endpoints.keys() { - let url = self.rpc_url(alias)?; + let url = self.rpc_endpoint(alias)?.url()?; urls.push(Rpc { key: alias.clone(), url }); } Ok(urls) diff --git a/crates/cheatcodes/src/evm/fork.rs b/crates/cheatcodes/src/evm/fork.rs index 83942cdbefa5f..e78aa3be9f697 100644 --- a/crates/cheatcodes/src/evm/fork.rs +++ b/crates/cheatcodes/src/evm/fork.rs @@ -226,7 +226,7 @@ impl Cheatcode for rpc_0Call { impl Cheatcode for rpc_1Call { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { urlOrAlias, method, params } = self; - let url = state.config.rpc_url(urlOrAlias)?; + let url = state.config.rpc_endpoint(urlOrAlias)?.url()?; rpc_call(&url, method, params) } } @@ -326,9 +326,15 @@ fn create_fork_request( ) -> Result { persist_caller(ccx); - let url = ccx.state.config.rpc_url(url_or_alias)?; + let rpc_endpoint = ccx.state.config.rpc_endpoint(url_or_alias)?; + let url = rpc_endpoint.url()?; let mut evm_opts = ccx.state.config.evm_opts.clone(); evm_opts.fork_block_number = block; + evm_opts.fork_retries = rpc_endpoint.config.retries; + evm_opts.fork_retry_backoff = rpc_endpoint.config.retry_backoff; + if let Some(Ok(auth)) = rpc_endpoint.auth { + evm_opts.fork_headers = Some(vec![format!("Authorization: {auth}")]); + } let fork = CreateFork { enable_caching: !ccx.state.config.no_storage_caching && ccx.state.config.rpc_storage_caching.enable_for_endpoint(&url), diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index bd723c9312ea2..417ae69833f73 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -42,7 +42,8 @@ impl Cheatcode for getFoundryVersionCall { impl Cheatcode for rpcUrlCall { fn apply(&self, state: &mut Cheatcodes) -> Result { let Self { rpcAlias } = self; - state.config.rpc_url(rpcAlias).map(|url| url.abi_encode()) + let url = state.config.rpc_endpoint(rpcAlias)?.url()?.abi_encode(); + Ok(url) } } diff --git a/crates/chisel/src/dispatcher.rs b/crates/chisel/src/dispatcher.rs index 2a6a2fc3f567a..a445e99e744f7 100644 --- a/crates/chisel/src/dispatcher.rs +++ b/crates/chisel/src/dispatcher.rs @@ -13,7 +13,7 @@ use crate::{ use alloy_json_abi::{InternalType, JsonAbi}; use alloy_primitives::{hex, Address}; use forge_fmt::FormatterConfig; -use foundry_config::{Config, RpcEndpoint}; +use foundry_config::{Config, RpcEndpointUrl}; use foundry_evm::{ decode::decode_console_logs, traces::{ @@ -357,9 +357,9 @@ impl ChiselDispatcher { { endpoint.clone() } else { - RpcEndpoint::Env(arg.to_string()).into() + RpcEndpointUrl::Env(arg.to_string()).into() }; - let fork_url = match endpoint.resolve() { + let fork_url = match endpoint.resolve().url() { Ok(fork_url) => fork_url, Err(e) => { return DispatchResult::CommandFailed(Self::make_error(format!( diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index 75efdb869f9f2..cd34f94e95203 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -241,6 +241,12 @@ impl ProviderBuilder { self } + /// Sets http headers. If `None`, defaults to the already-set value. + pub fn maybe_headers(mut self, headers: Option>) -> Self { + self.headers = headers.unwrap_or(self.headers); + self + } + /// Constructs the `RetryProvider` taking all configs into account. pub fn build(self) -> Result { let Self { diff --git a/crates/config/src/endpoints.rs b/crates/config/src/endpoints.rs index 78cda4f7343b4..1758e6a4870bf 100644 --- a/crates/config/src/endpoints.rs +++ b/crates/config/src/endpoints.rs @@ -12,7 +12,7 @@ use std::{ #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(transparent)] pub struct RpcEndpoints { - endpoints: BTreeMap, + endpoints: BTreeMap, } impl RpcEndpoints { @@ -24,9 +24,7 @@ impl RpcEndpoints { endpoints: endpoints .into_iter() .map(|(name, e)| match e.into() { - RpcEndpointType::String(url) => { - (name.into(), RpcEndpointConfig { endpoint: url, ..Default::default() }) - } + RpcEndpointType::String(url) => (name.into(), RpcEndpoint::new(url)), RpcEndpointType::Config(config) => (name.into(), config), }) .collect(), @@ -38,29 +36,16 @@ impl RpcEndpoints { self.endpoints.is_empty() } - /// Returns all (alias -> url) pairs + /// Returns all (alias -> rpc_endpoint) pairs pub fn resolved(self) -> ResolvedRpcEndpoints { ResolvedRpcEndpoints { - endpoints: self - .endpoints - .clone() - .into_iter() - .map(|(name, e)| (name, e.resolve())) - .collect(), - auths: self - .endpoints - .into_iter() - .map(|(name, e)| match e.auth { - Some(auth) => (name, auth.resolve().map(Some)), - None => (name, Ok(None)), - }) - .collect(), + endpoints: self.endpoints.into_iter().map(|(name, e)| (name, e.resolve())).collect(), } } } impl Deref for RpcEndpoints { - type Target = BTreeMap; + type Target = BTreeMap; fn deref(&self) -> &Self::Target { &self.endpoints @@ -72,14 +57,14 @@ impl Deref for RpcEndpoints { #[serde(untagged)] pub enum RpcEndpointType { /// Raw Endpoint url string - String(RpcEndpoint), + String(RpcEndpointUrl), /// Config object - Config(RpcEndpointConfig), + Config(RpcEndpoint), } impl RpcEndpointType { /// Returns the string variant - pub fn as_endpoint_string(&self) -> Option<&RpcEndpoint> { + pub fn as_endpoint_string(&self) -> Option<&RpcEndpointUrl> { match self { Self::String(url) => Some(url), Self::Config(_) => None, @@ -87,7 +72,7 @@ impl RpcEndpointType { } /// Returns the config variant - pub fn as_endpoint_config(&self) -> Option<&RpcEndpointConfig> { + pub fn as_endpoint_config(&self) -> Option<&RpcEndpoint> { match self { Self::Config(config) => Some(config), Self::String(_) => None, @@ -134,7 +119,7 @@ impl TryFrom for String { /// value of the env var itself. /// In other words, this type does not resolve env vars when it's being deserialized #[derive(Clone, Debug, PartialEq, Eq)] -pub enum RpcEndpoint { +pub enum RpcEndpointUrl { /// A raw Url (ws, http) Url(String), /// An endpoint that contains at least one `${ENV_VAR}` placeholder @@ -143,7 +128,7 @@ pub enum RpcEndpoint { Env(String), } -impl RpcEndpoint { +impl RpcEndpointUrl { /// Returns the url variant pub fn as_url(&self) -> Option<&str> { match self { @@ -173,7 +158,7 @@ impl RpcEndpoint { } } -impl fmt::Display for RpcEndpoint { +impl fmt::Display for RpcEndpointUrl { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Url(url) => url.fmt(f), @@ -182,15 +167,15 @@ impl fmt::Display for RpcEndpoint { } } -impl TryFrom for String { +impl TryFrom for String { type Error = UnresolvedEnvVarError; - fn try_from(value: RpcEndpoint) -> Result { + fn try_from(value: RpcEndpointUrl) -> Result { value.resolve() } } -impl Serialize for RpcEndpoint { +impl Serialize for RpcEndpointUrl { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -199,7 +184,7 @@ impl Serialize for RpcEndpoint { } } -impl<'de> Deserialize<'de> for RpcEndpoint { +impl<'de> Deserialize<'de> for RpcEndpointUrl { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, @@ -211,14 +196,14 @@ impl<'de> Deserialize<'de> for RpcEndpoint { } } -impl From for RpcEndpointType { - fn from(endpoint: RpcEndpoint) -> Self { +impl From for RpcEndpointType { + fn from(endpoint: RpcEndpointUrl) -> Self { Self::String(endpoint) } } -impl From for RpcEndpointConfig { - fn from(endpoint: RpcEndpoint) -> Self { +impl From for RpcEndpoint { + fn from(endpoint: RpcEndpointUrl) -> Self { Self { endpoint, ..Default::default() } } } @@ -275,12 +260,9 @@ impl<'de> Deserialize<'de> for RpcAuth { } } -/// Rpc endpoint configuration variant -#[derive(Debug, Clone, PartialEq, Eq)] +// Rpc endpoint configuration +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct RpcEndpointConfig { - /// endpoint url or env - pub endpoint: RpcEndpoint, - /// The number of retries. pub retries: Option, @@ -291,23 +273,11 @@ pub struct RpcEndpointConfig { /// /// See also pub compute_units_per_second: Option, - - /// Token to be used as authentication - pub auth: Option, -} - -impl RpcEndpointConfig { - /// Returns the url this type holds, see [`RpcEndpoint::resolve`] - pub fn resolve(self) -> Result { - self.endpoint.resolve() - } } impl fmt::Display for RpcEndpointConfig { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let Self { endpoint, retries, retry_backoff, compute_units_per_second, auth } = self; - - write!(f, "{endpoint}")?; + let Self { retries, retry_backoff, compute_units_per_second } = self; if let Some(retries) = retries { write!(f, ", retries={retries}")?; @@ -321,38 +291,75 @@ impl fmt::Display for RpcEndpointConfig { write!(f, ", compute_units_per_second={compute_units_per_second}")?; } + Ok(()) + } +} + +/// Rpc endpoint configuration variant +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RpcEndpoint { + /// endpoint url or env + pub endpoint: RpcEndpointUrl, + + /// Token to be used as authentication + pub auth: Option, + + /// additional configuration + pub config: RpcEndpointConfig, +} + +impl RpcEndpoint { + pub fn new(endpoint: RpcEndpointUrl) -> Self { + Self { endpoint, ..Default::default() } + } + + /// Resolves environment variables in fields into their raw values + pub fn resolve(self) -> ResolvedRpcEndpoint { + ResolvedRpcEndpoint { + endpoint: self.endpoint.resolve(), + auth: self.auth.map(|auth| auth.resolve()), + config: self.config, + } + } +} + +impl fmt::Display for RpcEndpoint { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let Self { endpoint, auth, config } = self; + write!(f, "{endpoint}")?; + write!(f, "{config}")?; if let Some(auth) = auth { write!(f, ", auth={auth}")?; } - Ok(()) } } -impl Serialize for RpcEndpointConfig { +impl Serialize for RpcEndpoint { fn serialize(&self, serializer: S) -> Result where S: Serializer, { - if self.retries.is_none() && - self.retry_backoff.is_none() && - self.compute_units_per_second.is_none() + if self.config.retries.is_none() && + self.config.retry_backoff.is_none() && + self.config.compute_units_per_second.is_none() && + self.auth.is_none() { // serialize as endpoint if there's no additional config self.endpoint.serialize(serializer) } else { let mut map = serializer.serialize_map(Some(4))?; map.serialize_entry("endpoint", &self.endpoint)?; - map.serialize_entry("retries", &self.retries)?; - map.serialize_entry("retry_backoff", &self.retry_backoff)?; - map.serialize_entry("compute_units_per_second", &self.compute_units_per_second)?; + map.serialize_entry("retries", &self.config.retries)?; + map.serialize_entry("retry_backoff", &self.config.retry_backoff)?; + map.serialize_entry("compute_units_per_second", &self.config.compute_units_per_second)?; map.serialize_entry("auth", &self.auth)?; map.end() } } } -impl<'de> Deserialize<'de> for RpcEndpointConfig { +impl<'de> Deserialize<'de> for RpcEndpoint { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, @@ -368,7 +375,7 @@ impl<'de> Deserialize<'de> for RpcEndpointConfig { #[derive(Deserialize)] struct RpcEndpointConfigInner { #[serde(alias = "url")] - endpoint: RpcEndpoint, + endpoint: RpcEndpointUrl, retries: Option, retry_backoff: Option, compute_units_per_second: Option, @@ -383,46 +390,81 @@ impl<'de> Deserialize<'de> for RpcEndpointConfig { auth, } = serde_json::from_value(value).map_err(serde::de::Error::custom)?; - Ok(Self { endpoint, retries, retry_backoff, compute_units_per_second, auth }) + Ok(Self { + endpoint, + auth, + config: RpcEndpointConfig { retries, retry_backoff, compute_units_per_second }, + }) } } -impl From for RpcEndpointType { - fn from(config: RpcEndpointConfig) -> Self { +impl From for RpcEndpointType { + fn from(config: RpcEndpoint) -> Self { Self::Config(config) } } -impl Default for RpcEndpointConfig { +impl Default for RpcEndpoint { fn default() -> Self { Self { - endpoint: RpcEndpoint::Url("http://localhost:8545".to_string()), - retries: None, - retry_backoff: None, - compute_units_per_second: None, + endpoint: RpcEndpointUrl::Url("http://localhost:8545".to_string()), + config: RpcEndpointConfig::default(), auth: None, } } } -/// Container type for _resolved_ endpoints, see [`RpcEndpoint::resolve`]. +/// Rpc endpoint with environment variables resolved to values, see [`RpcEndpoint::resolve`]. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ResolvedRpcEndpoint { + pub endpoint: Result, + pub auth: Option>, + pub config: RpcEndpointConfig, +} + +impl ResolvedRpcEndpoint { + /// Returns the url this type holds, see [`RpcEndpoint::resolve`] + pub fn url(&self) -> Result { + self.endpoint.clone() + } + + // Returns true if all environment variables are resolved successfully + pub fn is_unresolved(&self) -> bool { + let endpoint_err = self.endpoint.is_err(); + let auth_err = self.auth.as_ref().map(|auth| auth.is_err()).unwrap_or(false); + endpoint_err || auth_err + } + + // Attempts to resolve unresolved environment variables into a new instance + pub fn try_resolve(mut self) -> Self { + if !self.is_unresolved() { + return self + } + if let Err(err) = self.endpoint { + self.endpoint = err.try_resolve() + } + if let Some(Err(err)) = self.auth { + self.auth = Some(err.try_resolve()) + } + self + } +} + +/// Container type for _resolved_ endpoints. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct ResolvedRpcEndpoints { - /// contains all named endpoints and their URL or an error if we failed to resolve the env var - /// alias - endpoints: BTreeMap>, - auths: BTreeMap, UnresolvedEnvVarError>>, + endpoints: BTreeMap, } impl ResolvedRpcEndpoints { /// Returns true if there's an endpoint that couldn't be resolved pub fn has_unresolved(&self) -> bool { - self.endpoints.values().any(|val| val.is_err()) + self.endpoints.values().any(|e| e.is_unresolved()) } } impl Deref for ResolvedRpcEndpoints { - type Target = BTreeMap>; + type Target = BTreeMap; fn deref(&self) -> &Self::Target { &self.endpoints @@ -448,27 +490,31 @@ mod tests { "compute_units_per_second": 100, "auth": "Bearer 123" }"#; - let config: RpcEndpointConfig = serde_json::from_str(s).unwrap(); + let config: RpcEndpoint = serde_json::from_str(s).unwrap(); assert_eq!( config, - RpcEndpointConfig { - endpoint: RpcEndpoint::Url("http://localhost:8545".to_string()), - retries: Some(5), - retry_backoff: Some(250), - compute_units_per_second: Some(100), + RpcEndpoint { + endpoint: RpcEndpointUrl::Url("http://localhost:8545".to_string()), + config: RpcEndpointConfig { + retries: Some(5), + retry_backoff: Some(250), + compute_units_per_second: Some(100), + }, auth: Some(RpcAuth::Raw("Bearer 123".to_string())), } ); let s = "\"http://localhost:8545\""; - let config: RpcEndpointConfig = serde_json::from_str(s).unwrap(); + let config: RpcEndpoint = serde_json::from_str(s).unwrap(); assert_eq!( config, - RpcEndpointConfig { - endpoint: RpcEndpoint::Url("http://localhost:8545".to_string()), - retries: None, - retry_backoff: None, - compute_units_per_second: None, + RpcEndpoint { + endpoint: RpcEndpointUrl::Url("http://localhost:8545".to_string()), + config: RpcEndpointConfig { + retries: None, + retry_backoff: None, + compute_units_per_second: None, + }, auth: None, } ); diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 7264b63f88b03..d31f2b96b0073 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -58,7 +58,9 @@ pub mod utils; pub use utils::*; mod endpoints; -pub use endpoints::{ResolvedRpcEndpoints, RpcEndpoint, RpcEndpoints}; +pub use endpoints::{ + ResolvedRpcEndpoint, ResolvedRpcEndpoints, RpcEndpoint, RpcEndpointUrl, RpcEndpoints, +}; mod etherscan; use etherscan::{ @@ -1309,7 +1311,7 @@ impl Config { ) -> Option, UnresolvedEnvVarError>> { let mut endpoints = self.rpc_endpoints.clone().resolved(); if let Some(endpoint) = endpoints.remove(maybe_alias) { - return Some(endpoint.map(Cow::Owned)); + return Some(endpoint.url().map(Cow::Owned)); } if let Ok(Some(endpoint)) = mesc::get_endpoint_by_query(maybe_alias, Some("foundry")) { @@ -2547,10 +2549,10 @@ mod tests { use super::*; use crate::{ cache::{CachedChains, CachedEndpoints}, - endpoints::{RpcEndpointConfig, RpcEndpointType}, + endpoints::{RpcEndpoint, RpcEndpointType}, etherscan::ResolvedEtherscanConfigs, }; - use endpoints::RpcAuth; + use endpoints::{RpcAuth, RpcEndpointConfig}; use figment::error::Kind::InvalidType; use foundry_compilers::artifacts::{ vyper::VyperOptimizationMode, ModelCheckerEngine, YulDetails, @@ -3220,17 +3222,19 @@ mod tests { RpcEndpoints::new([ ( "optimism", - RpcEndpointType::String(RpcEndpoint::Url( + RpcEndpointType::String(RpcEndpointUrl::Url( "https://example.com/".to_string() )) ), ( "mainnet", - RpcEndpointType::Config(RpcEndpointConfig { - endpoint: RpcEndpoint::Env("${_CONFIG_MAINNET}".to_string()), - retries: Some(3), - retry_backoff: Some(1000), - compute_units_per_second: Some(1000), + RpcEndpointType::Config(RpcEndpoint { + endpoint: RpcEndpointUrl::Env("${_CONFIG_MAINNET}".to_string()), + config: RpcEndpointConfig { + retries: Some(3), + retry_backoff: Some(1000), + compute_units_per_second: Some(1000), + }, auth: None, }) ), @@ -3241,10 +3245,23 @@ mod tests { let resolved = config.rpc_endpoints.resolved(); assert_eq!( RpcEndpoints::new([ - ("optimism", RpcEndpoint::Url("https://example.com/".to_string())), + ( + "optimism", + RpcEndpointType::String(RpcEndpointUrl::Url( + "https://example.com/".to_string() + )) + ), ( "mainnet", - RpcEndpoint::Url("https://eth-mainnet.alchemyapi.io/v2/123455".to_string()) + RpcEndpointType::Config(RpcEndpoint { + endpoint: RpcEndpointUrl::Env("${_CONFIG_MAINNET}".to_string()), + config: RpcEndpointConfig { + retries: Some(3), + retry_backoff: Some(1000), + compute_units_per_second: Some(1000), + }, + auth: None, + }) ), ]) .resolved(), @@ -3277,17 +3294,19 @@ mod tests { RpcEndpoints::new([ ( "optimism", - RpcEndpointType::String(RpcEndpoint::Url( + RpcEndpointType::String(RpcEndpointUrl::Url( "https://example.com/".to_string() )) ), ( "mainnet", - RpcEndpointType::Config(RpcEndpointConfig { - endpoint: RpcEndpoint::Env("${_CONFIG_MAINNET}".to_string()), - retries: Some(3), - retry_backoff: Some(1000), - compute_units_per_second: Some(1000), + RpcEndpointType::Config(RpcEndpoint { + endpoint: RpcEndpointUrl::Env("${_CONFIG_MAINNET}".to_string()), + config: RpcEndpointConfig { + retries: Some(3), + retry_backoff: Some(1000), + compute_units_per_second: Some(1000) + }, auth: Some(RpcAuth::Env("Bearer ${_CONFIG_AUTH}".to_string())), }) ), @@ -3299,19 +3318,21 @@ mod tests { RpcEndpoints::new([ ( "optimism", - RpcEndpointType::String(RpcEndpoint::Url( + RpcEndpointType::String(RpcEndpointUrl::Url( "https://example.com/".to_string() )) ), ( "mainnet", - RpcEndpointType::Config(RpcEndpointConfig { - endpoint: RpcEndpoint::Url( + RpcEndpointType::Config(RpcEndpoint { + endpoint: RpcEndpointUrl::Url( "https://eth-mainnet.alchemyapi.io/v2/123455".to_string() ), - retries: Some(3), - retry_backoff: Some(1000), - compute_units_per_second: Some(1000), + config: RpcEndpointConfig { + retries: Some(3), + retry_backoff: Some(1000), + compute_units_per_second: Some(1000) + }, auth: Some(RpcAuth::Raw("Bearer 123456".to_string())), }) ), @@ -3357,18 +3378,22 @@ mod tests { assert_eq!( endpoints, RpcEndpoints::new([ - ("optimism", RpcEndpoint::Url("https://example.com/".to_string())), + ("optimism", RpcEndpointUrl::Url("https://example.com/".to_string())), ( "mainnet", - RpcEndpoint::Url("https://eth-mainnet.alchemyapi.io/v2/123455".to_string()) + RpcEndpointUrl::Url( + "https://eth-mainnet.alchemyapi.io/v2/123455".to_string() + ) ), ( "mainnet_2", - RpcEndpoint::Url("https://eth-mainnet.alchemyapi.io/v2/123456".to_string()) + RpcEndpointUrl::Url( + "https://eth-mainnet.alchemyapi.io/v2/123456".to_string() + ) ), ( "mainnet_3", - RpcEndpoint::Url( + RpcEndpointUrl::Url( "https://eth-mainnet.alchemyapi.io/v2/123456/98765".to_string() ) ), @@ -3544,17 +3569,17 @@ mod tests { revert_strings: Some(RevertStrings::Strip), allow_paths: vec![PathBuf::from("allow"), PathBuf::from("paths")], rpc_endpoints: RpcEndpoints::new([ - ("optimism", RpcEndpoint::Url("https://example.com/".to_string())), - ("mainnet", RpcEndpoint::Env("${RPC_MAINNET}".to_string())), + ("optimism", RpcEndpointUrl::Url("https://example.com/".to_string())), + ("mainnet", RpcEndpointUrl::Env("${RPC_MAINNET}".to_string())), ( "mainnet_2", - RpcEndpoint::Env( + RpcEndpointUrl::Env( "https://eth-mainnet.alchemyapi.io/v2/${API_KEY}".to_string() ) ), ( "mainnet_3", - RpcEndpoint::Env( + RpcEndpointUrl::Env( "https://eth-mainnet.alchemyapi.io/v2/${API_KEY}/${ANOTHER_KEY}" .to_string() ) @@ -3678,11 +3703,11 @@ mod tests { assert_eq!( config.rpc_endpoints, RpcEndpoints::new([ - ("optimism", RpcEndpoint::Url("https://example.com/".to_string())), - ("mainnet", RpcEndpoint::Env("${RPC_MAINNET}".to_string())), + ("optimism", RpcEndpointUrl::Url("https://example.com/".to_string())), + ("mainnet", RpcEndpointUrl::Env("${RPC_MAINNET}".to_string())), ( "mainnet_2", - RpcEndpoint::Env( + RpcEndpointUrl::Env( "https://eth-mainnet.alchemyapi.io/v2/${API_KEY}".to_string() ) ), diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 112e1eeda7d4b..490ae7379ae59 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -514,6 +514,7 @@ async fn create_fork(mut fork: CreateFork) -> eyre::Result<(ForkId, CreatedFork, ProviderBuilder::new(fork.url.as_str()) .maybe_max_retry(fork.evm_opts.fork_retries) .maybe_initial_backoff(fork.evm_opts.fork_retry_backoff) + .maybe_headers(fork.evm_opts.fork_headers.clone()) .compute_units_per_second(fork.evm_opts.get_compute_units_per_second()) .build()?, ); diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 76be5937bfde5..4c13369b6ae6c 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -29,6 +29,9 @@ pub struct EvmOpts { /// Initial retry backoff. pub fork_retry_backoff: Option, + /// Headers to use with `fork_url` + pub fork_headers: Option>, + /// The available compute units per second. /// /// See also @@ -80,6 +83,7 @@ impl Default for EvmOpts { fork_block_number: None, fork_retries: None, fork_retry_backoff: None, + fork_headers: None, compute_units_per_second: None, no_rpc_rate_limit: false, no_storage_caching: false, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index af957ccdc0678..3dd38a418d6a4 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -11,7 +11,7 @@ use foundry_compilers::{ }; use foundry_config::{ fs_permissions::PathPermission, Config, FsPermissions, FuzzConfig, FuzzDictionaryConfig, - InvariantConfig, RpcEndpoint, RpcEndpoints, + InvariantConfig, RpcEndpointUrl, RpcEndpoints, }; use foundry_evm::{constants::CALLER, opts::EvmOpts}; use foundry_test_utils::{fd_lock, init_tracing, rpc::next_rpc_endpoint}; @@ -339,15 +339,15 @@ pub fn manifest_root() -> &'static Path { /// the RPC endpoints used during tests pub fn rpc_endpoints() -> RpcEndpoints { RpcEndpoints::new([ - ("mainnet", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Mainnet))), - ("mainnet2", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Mainnet))), - ("sepolia", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Sepolia))), - ("optimism", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Optimism))), - ("arbitrum", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Arbitrum))), - ("polygon", RpcEndpoint::Url(next_rpc_endpoint(NamedChain::Polygon))), - ("avaxTestnet", RpcEndpoint::Url("https://api.avax-test.network/ext/bc/C/rpc".into())), - ("moonbeam", RpcEndpoint::Url("https://moonbeam-rpc.publicnode.com".into())), - ("rpcEnvAlias", RpcEndpoint::Env("${RPC_ENV_ALIAS}".into())), + ("mainnet", RpcEndpointUrl::Url(next_rpc_endpoint(NamedChain::Mainnet))), + ("mainnet2", RpcEndpointUrl::Url(next_rpc_endpoint(NamedChain::Mainnet))), + ("sepolia", RpcEndpointUrl::Url(next_rpc_endpoint(NamedChain::Sepolia))), + ("optimism", RpcEndpointUrl::Url(next_rpc_endpoint(NamedChain::Optimism))), + ("arbitrum", RpcEndpointUrl::Url(next_rpc_endpoint(NamedChain::Arbitrum))), + ("polygon", RpcEndpointUrl::Url(next_rpc_endpoint(NamedChain::Polygon))), + ("avaxTestnet", RpcEndpointUrl::Url("https://api.avax-test.network/ext/bc/C/rpc".into())), + ("moonbeam", RpcEndpointUrl::Url("https://moonbeam-rpc.publicnode.com".into())), + ("rpcEnvAlias", RpcEndpointUrl::Env("${RPC_ENV_ALIAS}".into())), ]) } From 206dab285437bd6889463ab006b6a5fb984079d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Dec 2024 03:56:54 +0000 Subject: [PATCH 1797/1963] chore(deps): weekly `cargo update` (#9560) --- Cargo.lock | 236 ++++++++++++++++++++++++++--------------------------- 1 file changed, 115 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b650cec7e9ce..f58e168945bdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -134,7 +134,7 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -238,7 +238,7 @@ dependencies = [ "alloy-sol-types", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", "tracing", ] @@ -264,7 +264,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -292,7 +292,7 @@ dependencies = [ "rand", "serde_json", "tempfile", - "thiserror 2.0.6", + "thiserror 2.0.7", "tracing", "url", ] @@ -365,7 +365,7 @@ dependencies = [ "schnellru", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tracing", "url", @@ -387,7 +387,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.5.1", + "tower 0.5.2", "tracing", ] @@ -433,7 +433,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower 0.5.1", + "tower 0.5.2", "tracing", "url", "wasmtimer", @@ -537,7 +537,7 @@ dependencies = [ "alloy-serde", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -576,7 +576,7 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -593,7 +593,7 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 2.0.6", + "thiserror 2.0.7", "tracing", ] @@ -611,7 +611,7 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 2.0.6", + "thiserror 2.0.7", "tracing", ] @@ -630,8 +630,8 @@ dependencies = [ "async-trait", "coins-ledger", "futures-util", - "semver 1.0.23", - "thiserror 2.0.6", + "semver 1.0.24", + "thiserror 2.0.7", "tracing", ] @@ -651,7 +651,7 @@ dependencies = [ "eth-keystore", "k256", "rand", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -665,8 +665,8 @@ dependencies = [ "alloy-primitives", "alloy-signer", "async-trait", - "semver 1.0.23", - "thiserror 2.0.6", + "semver 1.0.24", + "thiserror 2.0.7", "tracing", "trezor-client", ] @@ -756,9 +756,9 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", - "tower 0.5.1", + "tower 0.5.2", "tracing", "url", "wasmtimer", @@ -774,7 +774,7 @@ dependencies = [ "alloy-transport", "reqwest", "serde_json", - "tower 0.5.1", + "tower 0.5.2", "tracing", "url", ] @@ -810,7 +810,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.2.0", - "rustls 0.23.19", + "rustls 0.23.20", "serde_json", "tokio", "tokio-tungstenite", @@ -981,7 +981,7 @@ dependencies = [ "serde_repr", "similar-asserts", "tempfile", - "thiserror 2.0.6", + "thiserror 2.0.7", "tikv-jemallocator", "tokio", "tower 0.4.13", @@ -1012,7 +1012,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -1038,7 +1038,7 @@ dependencies = [ "pin-project 1.1.7", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio-util", "tower-http", "tracing", @@ -1692,10 +1692,10 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tokio-tungstenite", - "tower 0.5.1", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", @@ -1716,7 +1716,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.2", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -1885,9 +1885,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" +checksum = "786a307d683a5bf92e6fd5fd69a7eb613751668d1d8d67d802846dfe367c62c8" dependencies = [ "memchr", "regex-automata 0.4.9", @@ -2005,7 +2005,7 @@ checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "thiserror 1.0.69", @@ -2065,7 +2065,7 @@ dependencies = [ "rayon", "regex", "rpassword", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "tempfile", @@ -2087,9 +2087,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.3" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" +checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" dependencies = [ "shlex", ] @@ -2134,7 +2134,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "serial_test", @@ -3484,7 +3484,7 @@ dependencies = [ "regex", "reqwest", "revm-inspectors", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "similar", @@ -3496,7 +3496,7 @@ dependencies = [ "strum", "svm-rs", "tempfile", - "thiserror 2.0.6", + "thiserror 2.0.7", "tikv-jemallocator", "tokio", "toml 0.8.19", @@ -3529,7 +3529,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "thiserror 2.0.6", + "thiserror 2.0.7", "toml 0.8.19", "tracing", ] @@ -3544,7 +3544,7 @@ dependencies = [ "itertools 0.13.0", "similar-asserts", "solang-parser", - "thiserror 2.0.6", + "thiserror 2.0.7", "toml 0.8.19", "tracing", "tracing-subscriber", @@ -3586,7 +3586,7 @@ dependencies = [ "itertools 0.13.0", "parking_lot", "revm-inspectors", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "tempfile", @@ -3654,7 +3654,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "tempfile", @@ -3683,7 +3683,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "reqwest", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "thiserror 1.0.69", @@ -3729,10 +3729,10 @@ dependencies = [ "rand", "revm", "revm-inspectors", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", "toml 0.8.19", "tracing", "vergen", @@ -3826,12 +3826,12 @@ dependencies = [ "itertools 0.13.0", "num-format", "reqwest", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "similar-asserts", "terminal_size", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tower 0.4.13", "tracing", @@ -3882,7 +3882,7 @@ dependencies = [ "path-slash", "rand", "rayon", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "sha2", @@ -3890,7 +3890,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tracing", "winnow", @@ -3920,11 +3920,11 @@ dependencies = [ "md-5", "path-slash", "rayon", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "serde_repr", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tracing", "walkdir", @@ -3942,7 +3942,7 @@ dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-core", "path-slash", - "semver 1.0.23", + "semver 1.0.24", "serde", ] @@ -3958,12 +3958,12 @@ dependencies = [ "fs_extra", "path-slash", "regex", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "svm-rs", "tempfile", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "walkdir", ] @@ -3990,14 +3990,14 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "serde_regex", "similar-asserts", "solang-parser", "tempfile", - "thiserror 2.0.6", + "thiserror 2.0.7", "toml 0.8.19", "toml_edit", "tracing", @@ -4046,7 +4046,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "thiserror 2.0.6", + "thiserror 2.0.7", "tracing", ] @@ -4092,7 +4092,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tracing", "url", @@ -4109,7 +4109,7 @@ dependencies = [ "foundry-evm-core", "rayon", "revm", - "semver 1.0.23", + "semver 1.0.24", "tracing", ] @@ -4135,7 +4135,7 @@ dependencies = [ "rand", "revm", "serde", - "thiserror 2.0.6", + "thiserror 2.0.7", "tracing", ] @@ -4185,7 +4185,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tracing", "url", @@ -4197,8 +4197,8 @@ version = "0.2.0" dependencies = [ "alloy-primitives", "foundry-compilers", - "semver 1.0.23", - "thiserror 2.0.6", + "semver 1.0.24", + "thiserror 2.0.7", ] [[package]] @@ -4260,7 +4260,7 @@ dependencies = [ "gcloud-sdk", "rpassword", "serde", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tracing", ] @@ -4428,7 +4428,7 @@ dependencies = [ "serde_json", "tokio", "tonic", - "tower 0.5.1", + "tower 0.5.2", "tower-layer", "tower-util", "tracing", @@ -4523,7 +4523,7 @@ dependencies = [ "bstr", "gix-path", "libc", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -4535,7 +4535,7 @@ dependencies = [ "bstr", "itoa", "jiff", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -4626,7 +4626,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -4698,7 +4698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -5066,7 +5066,7 @@ dependencies = [ "http 1.2.0", "hyper 1.5.1", "hyper-util", - "rustls 0.23.19", + "rustls 0.23.20", "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", @@ -6369,9 +6369,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d95d0ec6457ad4d3d7fc0ad41db490b219587ed837ada87a26b28e535db15f" +checksum = "848b3567a9a469ab0c9c712fca0fd6bbce13a9a0b723c94cb81214f53507cf07" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6380,14 +6380,14 @@ dependencies = [ "alloy-serde", "derive_more", "serde", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] name = "op-alloy-rpc-types" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba1b44e2035ec04cc61762cb9b5457d0ecd29d9af631e1a1c107ef571ce2318" +checksum = "8a555dd1bd39cbcdd60b92f03a21871767a16e3a2ce2f82a26cff9aade56d35f" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6659,7 +6659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.6", + "thiserror 2.0.7", "ucd-trie", ] @@ -7178,7 +7178,7 @@ dependencies = [ "newtype-uuid", "quick-xml 0.37.1", "strip-ansi-escapes", - "thiserror 2.0.6", + "thiserror 2.0.7", "uuid 1.11.0", ] @@ -7211,9 +7211,9 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.19", + "rustls 0.23.20", "socket2", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "tracing", ] @@ -7229,10 +7229,10 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.19", + "rustls 0.23.20", "rustls-pki-types", "slab", - "thiserror 2.0.6", + "thiserror 2.0.7", "tinyvec", "tracing", "web-time", @@ -7366,9 +7366,9 @@ checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ "bitflags 2.6.0", ] @@ -7463,14 +7463,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.19", + "rustls 0.23.20", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tokio-native-tls", "tokio-rustls 0.26.1", @@ -7516,7 +7516,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.6", + "thiserror 2.0.7", ] [[package]] @@ -7732,7 +7732,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.23", + "semver 1.0.24", ] [[package]] @@ -7762,9 +7762,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.19" +version = "0.23.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" +checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" dependencies = [ "log", "once_cell", @@ -7819,9 +7819,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" dependencies = [ "web-time", ] @@ -8131,9 +8131,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" dependencies = [ "serde", ] @@ -8155,18 +8155,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -8511,7 +8511,7 @@ dependencies = [ "either", "num-bigint", "num-rational", - "semver 1.0.23", + "semver 1.0.24", "solar-data-structures", "solar-interface", "solar-macros", @@ -8637,11 +8637,11 @@ dependencies = [ "regex", "reqwest", "sanitize-filename", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "sha2", - "thiserror 2.0.6", + "thiserror 2.0.7", "tokio", "toml_edit", "uuid 1.11.0", @@ -8775,7 +8775,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "reqwest", - "semver 1.0.23", + "semver 1.0.24", "serde", "serde_json", "sha2", @@ -8793,7 +8793,7 @@ checksum = "f2fa0f145894cb4d1c14446f08098ee5f21fc37ccbd1a7dd9dd355bbc806de3b" dependencies = [ "build_const", "const-hex", - "semver 1.0.23", + "semver 1.0.24", "serde_json", "svm-rs", ] @@ -8832,12 +8832,6 @@ dependencies = [ "syn 2.0.90", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.2" @@ -8950,11 +8944,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.6" +version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" +checksum = "93605438cbd668185516ab499d589afb7ee1859ea3d5fc8f6b0755e1c7443767" dependencies = [ - "thiserror-impl 2.0.6", + "thiserror-impl 2.0.7", ] [[package]] @@ -8970,9 +8964,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.6" +version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" +checksum = "e1d8749b4531af2117677a5fcd12b1348a3fe2b81e36e61ffeac5c4aa3273e36" dependencies = [ "proc-macro2", "quote", @@ -9140,7 +9134,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.19", + "rustls 0.23.20", "tokio", ] @@ -9176,7 +9170,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.19", + "rustls 0.23.20", "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", @@ -9302,14 +9296,14 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 0.1.2", + "sync_wrapper", "tokio", "tower-layer", "tower-service", @@ -9450,9 +9444,9 @@ dependencies = [ [[package]] name = "tracy-client" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e295eae54124872df35720dc3a5b1e827c7deee352b342ec7f7e626d0d0ef3" +checksum = "73202d787346a5418f8222eddb5a00f29ea47caf3c7d38a8f2f69f8455fa7c7e" dependencies = [ "loom", "once_cell", @@ -9461,9 +9455,9 @@ dependencies = [ [[package]] name = "tracy-client-sys" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3637e734239e12ab152cd269302500bd063f37624ee210cd04b4936ed671f3b1" +checksum = "69fff37da548239c3bf9e64a12193d261e8b22b660991c6fd2df057c168f435f" dependencies = [ "cc", "windows-targets 0.52.6", @@ -9502,7 +9496,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.19", + "rustls 0.23.20", "rustls-pki-types", "sha1", "thiserror 1.0.69", @@ -10491,7 +10485,7 @@ dependencies = [ "flate2", "indexmap 2.7.0", "memchr", - "thiserror 2.0.6", + "thiserror 2.0.7", "zopfli", ] From 681bddd631fc736129a358b6e59621b49f9af995 Mon Sep 17 00:00:00 2001 From: W Date: Tue, 17 Dec 2024 13:12:42 +0100 Subject: [PATCH 1798/1963] feat(cast): add support for beacon proxies in cast impl (#9567) * feat(cast): add support for beacon proxies in cast impl * test: pin test to current block --- crates/cast/bin/args.rs | 13 +++++++++--- crates/cast/bin/main.rs | 4 ++-- crates/cast/src/lib.rs | 27 +++++++++++++++++++---- crates/cast/tests/cli/main.rs | 40 +++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 9 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 47bf9a8849f60..d9c86e9019ab6 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -606,7 +606,8 @@ pub enum CastSubcommand { formula_id: String, }, - /// Fetch the EIP-1967 implementation account + /// Fetch the EIP-1967 implementation for a contract + /// Can read from the implementation slot or the beacon slot. #[command(visible_alias = "impl")] Implementation { /// The block height to query at. @@ -615,7 +616,13 @@ pub enum CastSubcommand { #[arg(long, short = 'B')] block: Option, - /// The address to get the nonce for. + /// Fetch the implementation from the beacon slot. + /// + /// If not specified, the implementation slot is used. + #[arg(long)] + beacon: bool, + + /// The address for which the implementation will be fetched. #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, @@ -632,7 +639,7 @@ pub enum CastSubcommand { #[arg(long, short = 'B')] block: Option, - /// The address to get the nonce for. + /// The address from which the admin account will be fetched. #[arg(value_parser = NameOrAddress::from_str)] who: NameOrAddress, diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 01bab16ac16ce..0d2de240024c5 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -425,11 +425,11 @@ async fn main_args(args: CastArgs) -> Result<()> { let id = stdin::unwrap_line(id)?; sh_println!("{}", foundry_common::erc7201(&id))?; } - CastSubcommand::Implementation { block, who, rpc } => { + CastSubcommand::Implementation { block, beacon, who, rpc } => { let config = Config::from(&rpc); let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; - sh_println!("{}", Cast::new(provider).implementation(who, block).await?)?; + sh_println!("{}", Cast::new(provider).implementation(who, beacon, block).await?)?; } CastSubcommand::Admin { block, who, rpc } => { let config = Config::from(&rpc); diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 01d7da6efc80f..72083b1f09954 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -571,14 +571,33 @@ where /// ProviderBuilder::<_, _, AnyNetwork>::default().on_builtin("http://localhost:8545").await?; /// let cast = Cast::new(provider); /// let addr = Address::from_str("0x7eD52863829AB99354F3a0503A622e82AcD5F7d3")?; - /// let implementation = cast.implementation(addr, None).await?; + /// let implementation = cast.implementation(addr, false, None).await?; /// println!("{}", implementation); /// # Ok(()) /// # } /// ``` - pub async fn implementation(&self, who: Address, block: Option) -> Result { - let slot = - B256::from_str("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")?; + pub async fn implementation( + &self, + who: Address, + is_beacon: bool, + block: Option, + ) -> Result { + let slot = match is_beacon { + true => { + // Use the beacon slot : bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1) + B256::from_str( + "0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50", + )? + } + false => { + // Use the implementation slot : + // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) + B256::from_str( + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", + )? + } + }; + let value = self .provider .get_storage_at(who, slot.into()) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index df98427224749..3c3096a363c97 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -627,6 +627,46 @@ casttest!(rlp, |_prj, cmd| { "#]]); }); +// test that `cast impl` works correctly for both the implementation slot and the beacon slot +casttest!(impl_slot, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + + // Call `cast impl` for the implementation slot (AAVE Proxy) + cmd.args([ + "impl", + "0x4965f6FA20fE9728deCf5165016fc338a5a85aBF", + "--rpc-url", + eth_rpc_url.as_str(), + "--block", + "21422087", + ]) + .assert_success() + .stdout_eq(str![[r#" +0xb61306c8eb34a2104d9eb8d84f1bb1001067fa4b + +"#]]); +}); + +casttest!(impl_slot_beacon, |_prj, cmd| { + let eth_rpc_url = next_http_rpc_endpoint(); + + // Call `cast impl` for the beacon slot + cmd.args([ + "impl", + "0xc63d9f0040d35f328274312fc8771a986fc4ba86", + "--beacon", + "--rpc-url", + eth_rpc_url.as_str(), + "--block", + "21422087", + ]) + .assert_success() + .stdout_eq(str![[r#" +0xa748ae65ba11606492a9c57effa0d4b7be551ec2 + +"#]]); +}); + // test for cast_rpc without arguments casttest!(rpc_no_args, |_prj, cmd| { let eth_rpc_url = next_http_rpc_endpoint(); From 6b07c77eb1c1d1c4b56ffa7f79240254b73236d2 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:26:19 +0200 Subject: [PATCH 1799/1963] feat(`cheatcodes`): count assertion for `expectEmit` (#9405) * introduce ExpectEmitTracker * cheats * account for emit accounts + simple testNoEmit * tests: expectCountEmits from specific address * fix * failure tests * fix * fix: account for log data * LogCountMap * fix * nit * test * fix * fix * fix: instantiate log count map in tracker only if log satisfies the checks * nit * nit * nits * doc nits * helper fn * nit * nits * fix * fix * nit * refactor count tests * fix * fix * fix --- crates/cheatcodes/assets/cheatcodes.json | 80 ++++++++ crates/cheatcodes/spec/src/vm.rs | 17 ++ crates/cheatcodes/src/inspector.rs | 63 +++++-- crates/cheatcodes/src/test/expect.rs | 230 +++++++++++++++++++---- testdata/cheats/Vm.sol | 4 + testdata/default/cheats/ExpectEmit.t.sol | 85 +++++++++ 6 files changed, 435 insertions(+), 44 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 82a7de2aa509c..d3a47288ff614 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -4971,6 +4971,86 @@ "status": "stable", "safety": "unsafe" }, + { + "func": { + "id": "expectEmit_4", + "description": "Expect a given number of logs with the provided topics.", + "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(bool,bool,bool,bool,uint64)", + "selector": "0x5e1d1c33", + "selectorBytes": [ + 94, + 29, + 28, + 51 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmit_5", + "description": "Expect a given number of logs from a specific emitter with the provided topics.", + "declaration": "function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(bool,bool,bool,bool,address,uint64)", + "selector": "0xc339d02c", + "selectorBytes": [ + 195, + 57, + 208, + 44 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmit_6", + "description": "Expect a given number of logs with all topic and data checks enabled.", + "declaration": "function expectEmit(uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(uint64)", + "selector": "0x4c74a335", + "selectorBytes": [ + 76, + 116, + 163, + 53 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, + { + "func": { + "id": "expectEmit_7", + "description": "Expect a given number of logs from a specific emitter with all topic and data checks enabled.", + "declaration": "function expectEmit(address emitter, uint64 count) external;", + "visibility": "external", + "mutability": "", + "signature": "expectEmit(address,uint64)", + "selector": "0xb43aece3", + "selectorBytes": [ + 180, + 58, + 236, + 227 + ] + }, + "group": "testing", + "status": "stable", + "safety": "unsafe" + }, { "func": { "id": "expectPartialRevert_0", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 4bc8c9b0344e3..47e0b625b4de0 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -982,6 +982,23 @@ interface Vm { #[cheatcode(group = Testing, safety = Unsafe)] function expectEmit(address emitter) external; + /// Expect a given number of logs with the provided topics. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external; + + /// Expect a given number of logs from a specific emitter with the provided topics. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count) + external; + + /// Expect a given number of logs with all topic and data checks enabled. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit(uint64 count) external; + + /// Expect a given number of logs from a specific emitter with all topic and data checks enabled. + #[cheatcode(group = Testing, safety = Unsafe)] + function expectEmit(address emitter, uint64 count) external; + /// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans). diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 329b89d0ebc2f..a0695d0d254f3 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -12,7 +12,7 @@ use crate::{ test::{ assume::AssumeNoRevert, expect::{ - self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmit, + self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmitTracker, ExpectedRevert, ExpectedRevertKind, }, }, @@ -428,7 +428,7 @@ pub struct Cheatcodes { /// Expected calls pub expected_calls: ExpectedCallTracker, /// Expected emits - pub expected_emits: VecDeque, + pub expected_emits: ExpectedEmitTracker, /// Map of context depths to memory offset ranges that may be written to within the call depth. pub allowed_mem_writes: HashMap>>, @@ -1442,21 +1442,63 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { let should_check_emits = self .expected_emits .iter() - .any(|expected| expected.depth == ecx.journaled_state.depth()) && + .any(|(expected, _)| expected.depth == ecx.journaled_state.depth()) && // Ignore staticcalls !call.is_static; if should_check_emits { + let expected_counts = self + .expected_emits + .iter() + .filter_map(|(expected, count_map)| { + let count = match expected.address { + Some(emitter) => match count_map.get(&emitter) { + Some(log_count) => expected + .log + .as_ref() + .map(|l| log_count.count(l)) + .unwrap_or_else(|| log_count.count_unchecked()), + None => 0, + }, + None => match &expected.log { + Some(log) => count_map.values().map(|logs| logs.count(log)).sum(), + None => count_map.values().map(|logs| logs.count_unchecked()).sum(), + }, + }; + + if count != expected.count { + Some((expected, count)) + } else { + None + } + }) + .collect::>(); + // Not all emits were matched. - if self.expected_emits.iter().any(|expected| !expected.found) { + if self.expected_emits.iter().any(|(expected, _)| !expected.found) { outcome.result.result = InstructionResult::Revert; outcome.result.output = "log != expected log".abi_encode().into(); return outcome; - } else { - // All emits were found, we're good. - // Clear the queue, as we expect the user to declare more events for the next call - // if they wanna match further events. - self.expected_emits.clear() } + + if !expected_counts.is_empty() { + let msg = if outcome.result.is_ok() { + let (expected, count) = expected_counts.first().unwrap(); + format!("log emitted {count} times, expected {}", expected.count) + } else { + "expected an emit, but the call reverted instead. \ + ensure you're testing the happy path when using `expectEmit`" + .to_string() + }; + + outcome.result.result = InstructionResult::Revert; + outcome.result.output = Error::encode(msg); + return outcome; + } + + // All emits were found, we're good. + // Clear the queue, as we expect the user to declare more events for the next call + // if they wanna match further events. + self.expected_emits.clear() } // this will ensure we don't have false positives when trying to diagnose reverts in fork @@ -1544,10 +1586,9 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { } } } - // Check if we have any leftover expected emits // First, if any emits were found at the root call, then we its ok and we remove them. - self.expected_emits.retain(|expected| !expected.found); + self.expected_emits.retain(|(expected, _)| expected.count > 0 && !expected.found); // If not empty, we got mismatched emits if !self.expected_emits.is_empty() { let msg = if outcome.result.is_ok() { diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index a3ddef8c16c97..e45298923cd69 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -1,7 +1,9 @@ +use std::collections::VecDeque; + use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result, Vm::*}; use alloy_primitives::{ address, hex, - map::{hash_map::Entry, HashMap}, + map::{hash_map::Entry, AddressHashMap, HashMap}, Address, Bytes, LogData as RawLog, U256, }; use alloy_sol_types::{SolError, SolValue}; @@ -113,6 +115,8 @@ pub struct ExpectedEmit { pub anonymous: bool, /// Whether the log was actually found in the subcalls pub found: bool, + /// Number of times the log is expected to be emitted + pub count: u64, } impl Cheatcode for expectCall_0Call { @@ -225,6 +229,7 @@ impl Cheatcode for expectEmit_0Call { [true, checkTopic1, checkTopic2, checkTopic3, checkData], None, false, + 1, ) } } @@ -238,6 +243,7 @@ impl Cheatcode for expectEmit_1Call { [true, checkTopic1, checkTopic2, checkTopic3, checkData], Some(emitter), false, + 1, ) } } @@ -245,14 +251,63 @@ impl Cheatcode for expectEmit_1Call { impl Cheatcode for expectEmit_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, false) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, false, 1) } } impl Cheatcode for expectEmit_3Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { emitter } = *self; - expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), false) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), false, 1) + } +} + +impl Cheatcode for expectEmit_4Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { checkTopic1, checkTopic2, checkTopic3, checkData, count } = *self; + expect_emit( + ccx.state, + ccx.ecx.journaled_state.depth(), + [true, checkTopic1, checkTopic2, checkTopic3, checkData], + None, + false, + count, + ) + } +} + +impl Cheatcode for expectEmit_5Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { checkTopic1, checkTopic2, checkTopic3, checkData, emitter, count } = *self; + expect_emit( + ccx.state, + ccx.ecx.journaled_state.depth(), + [true, checkTopic1, checkTopic2, checkTopic3, checkData], + Some(emitter), + false, + count, + ) + } +} + +impl Cheatcode for expectEmit_6Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { count } = *self; + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, false, count) + } +} + +impl Cheatcode for expectEmit_7Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { emitter, count } = *self; + expect_emit( + ccx.state, + ccx.ecx.journaled_state.depth(), + [true; 5], + Some(emitter), + false, + count, + ) } } @@ -265,6 +320,7 @@ impl Cheatcode for expectEmitAnonymous_0Call { [checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData], None, true, + 1, ) } } @@ -278,6 +334,7 @@ impl Cheatcode for expectEmitAnonymous_1Call { [checkTopic0, checkTopic1, checkTopic2, checkTopic3, checkData], Some(emitter), true, + 1, ) } } @@ -285,14 +342,14 @@ impl Cheatcode for expectEmitAnonymous_1Call { impl Cheatcode for expectEmitAnonymous_2Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self {} = self; - expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, true) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], None, true, 1) } } impl Cheatcode for expectEmitAnonymous_3Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let Self { emitter } = *self; - expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), true) + expect_emit(ccx.state, ccx.ecx.journaled_state.depth(), [true; 5], Some(emitter), true, 1) } } @@ -638,15 +695,17 @@ fn expect_emit( checks: [bool; 5], address: Option
, anonymous: bool, + count: u64, ) -> Result { - let expected_emit = ExpectedEmit { depth, checks, address, found: false, log: None, anonymous }; - if let Some(found_emit_pos) = state.expected_emits.iter().position(|emit| emit.found) { + let expected_emit = + ExpectedEmit { depth, checks, address, found: false, log: None, anonymous, count }; + if let Some(found_emit_pos) = state.expected_emits.iter().position(|(emit, _)| emit.found) { // The order of emits already found (back of queue) should not be modified, hence push any // new emit before first found emit. - state.expected_emits.insert(found_emit_pos, expected_emit); + state.expected_emits.insert(found_emit_pos, (expected_emit, Default::default())); } else { // If no expected emits then push new one at the back of queue. - state.expected_emits.push_back(expected_emit); + state.expected_emits.push_back((expected_emit, Default::default())); } Ok(Default::default()) @@ -667,18 +726,18 @@ pub(crate) fn handle_expect_emit( // First, we can return early if all events have been matched. // This allows a contract to arbitrarily emit more events than expected (additive behavior), // as long as all the previous events were matched in the order they were expected to be. - if state.expected_emits.iter().all(|expected| expected.found) { + if state.expected_emits.iter().all(|(expected, _)| expected.found) { return } - let should_fill_logs = state.expected_emits.iter().any(|expected| expected.log.is_none()); + let should_fill_logs = state.expected_emits.iter().any(|(expected, _)| expected.log.is_none()); let index_to_fill_or_check = if should_fill_logs { // If there's anything to fill, we start with the last event to match in the queue // (without taking into account events already matched). state .expected_emits .iter() - .position(|emit| emit.found) + .position(|(emit, _)| emit.found) .unwrap_or(state.expected_emits.len()) .saturating_sub(1) } else { @@ -687,7 +746,7 @@ pub(crate) fn handle_expect_emit( 0 }; - let mut event_to_fill_or_check = state + let (mut event_to_fill_or_check, mut count_map) = state .expected_emits .remove(index_to_fill_or_check) .expect("we should have an emit to fill or check"); @@ -698,7 +757,9 @@ pub(crate) fn handle_expect_emit( if event_to_fill_or_check.anonymous || !log.topics().is_empty() { event_to_fill_or_check.log = Some(log.data.clone()); // If we only filled the expected log then we put it back at the same position. - state.expected_emits.insert(index_to_fill_or_check, event_to_fill_or_check); + state + .expected_emits + .insert(index_to_fill_or_check, (event_to_fill_or_check, count_map)); } else { interpreter.instruction_result = InstructionResult::Revert; interpreter.next_action = InterpreterAction::Return { @@ -712,41 +773,120 @@ pub(crate) fn handle_expect_emit( return }; - event_to_fill_or_check.found = || -> bool { - // Topic count must match. - if expected.topics().len() != log.topics().len() { - return false + // Increment/set `count` for `log.address` and `log.data` + match count_map.entry(log.address) { + Entry::Occupied(mut entry) => { + // Checks and inserts the log into the map. + // If the log doesn't pass the checks, it is ignored and `count` is not incremented. + let log_count_map = entry.get_mut(); + log_count_map.insert(&log.data); } - // Match topics according to the checks. - if !log - .topics() - .iter() - .enumerate() - .filter(|(i, _)| event_to_fill_or_check.checks[*i]) - .all(|(i, topic)| topic == &expected.topics()[i]) - { + Entry::Vacant(entry) => { + let mut log_count_map = LogCountMap::new(&event_to_fill_or_check); + + if log_count_map.satisfies_checks(&log.data) { + log_count_map.insert(&log.data); + + // Entry is only inserted if it satisfies the checks. + entry.insert(log_count_map); + } + } + } + + event_to_fill_or_check.found = || -> bool { + if !checks_topics_and_data(event_to_fill_or_check.checks, expected, log) { return false } + // Maybe match source address. if event_to_fill_or_check.address.is_some_and(|addr| addr != log.address) { return false; } - // Maybe match data. - if event_to_fill_or_check.checks[4] && expected.data.as_ref() != log.data.data.as_ref() { - return false - } - true + let expected_count = event_to_fill_or_check.count; + + match event_to_fill_or_check.address { + Some(emitter) => count_map + .get(&emitter) + .is_some_and(|log_map| log_map.count(&log.data) >= expected_count), + None => count_map + .values() + .find(|log_map| log_map.satisfies_checks(&log.data)) + .is_some_and(|map| map.count(&log.data) >= expected_count), + } }(); // If we found the event, we can push it to the back of the queue // and begin expecting the next event. if event_to_fill_or_check.found { - state.expected_emits.push_back(event_to_fill_or_check); + state.expected_emits.push_back((event_to_fill_or_check, count_map)); } else { // We did not match this event, so we need to keep waiting for the right one to // appear. - state.expected_emits.push_front(event_to_fill_or_check); + state.expected_emits.push_front((event_to_fill_or_check, count_map)); + } +} + +/// Handles expected emits specified by the `expectEmit` cheatcodes. +/// +/// The second element of the tuple counts the number of times the log has been emitted by a +/// particular address +pub type ExpectedEmitTracker = VecDeque<(ExpectedEmit, AddressHashMap)>; + +#[derive(Clone, Debug, Default)] +pub struct LogCountMap { + checks: [bool; 5], + expected_log: RawLog, + map: HashMap, +} + +impl LogCountMap { + /// Instantiates `LogCountMap`. + fn new(expected_emit: &ExpectedEmit) -> Self { + Self { + checks: expected_emit.checks, + expected_log: expected_emit.log.clone().expect("log should be filled here"), + map: Default::default(), + } + } + + /// Inserts a log into the map and increments the count. + /// + /// The log must pass all checks against the expected log for the count to increment. + /// + /// Returns true if the log was inserted and count was incremented. + fn insert(&mut self, log: &RawLog) -> bool { + // If its already in the map, increment the count without checking. + if self.map.contains_key(log) { + self.map.entry(log.clone()).and_modify(|c| *c += 1); + + return true + } + + if !self.satisfies_checks(log) { + return false + } + + self.map.entry(log.clone()).and_modify(|c| *c += 1).or_insert(1); + + true + } + + /// Checks the incoming raw log against the expected logs topics and data. + fn satisfies_checks(&self, log: &RawLog) -> bool { + checks_topics_and_data(self.checks, &self.expected_log, log) + } + + pub fn count(&self, log: &RawLog) -> u64 { + if !self.satisfies_checks(log) { + return 0 + } + + self.count_unchecked() + } + + pub fn count_unchecked(&self) -> u64 { + self.map.values().sum() } } @@ -910,6 +1050,30 @@ pub(crate) fn handle_expect_revert( } } +fn checks_topics_and_data(checks: [bool; 5], expected: &RawLog, log: &RawLog) -> bool { + if log.topics().len() != expected.topics().len() { + return false + } + + // Check topics. + if !log + .topics() + .iter() + .enumerate() + .filter(|(i, _)| checks[*i]) + .all(|(i, topic)| topic == &expected.topics()[i]) + { + return false + } + + // Check data + if checks[4] && expected.data.as_ref() != log.data.as_ref() { + return false + } + + true +} + fn expect_safe_memory(state: &mut Cheatcodes, start: u64, end: u64, depth: u64) -> Result { ensure!(start < end, "memory range start ({start}) is greater than end ({end})"); #[allow(clippy::single_range_in_vec_init)] // Wanted behaviour diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index bdbb68e372e84..260b5bb385600 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -242,6 +242,10 @@ interface Vm { function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external; function expectEmit() external; function expectEmit(address emitter) external; + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external; + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count) external; + function expectEmit(uint64 count) external; + function expectEmit(address emitter, uint64 count) external; function expectPartialRevert(bytes4 revertData) external; function expectPartialRevert(bytes4 revertData, address reverter) external; function expectRevert() external; diff --git a/testdata/default/cheats/ExpectEmit.t.sol b/testdata/default/cheats/ExpectEmit.t.sol index b8fe5e4587c76..2503faf4bcf7a 100644 --- a/testdata/default/cheats/ExpectEmit.t.sol +++ b/testdata/default/cheats/ExpectEmit.t.sol @@ -28,6 +28,12 @@ contract Emitter { emit Something(topic1, topic2, topic3, data); } + function emitNEvents(uint256 topic1, uint256 topic2, uint256 topic3, uint256 data, uint256 n) public { + for (uint256 i = 0; i < n; i++) { + emit Something(topic1, topic2, topic3, data); + } + } + function emitMultiple( uint256[2] memory topic1, uint256[2] memory topic2, @@ -597,3 +603,82 @@ contract ExpectEmitTest is DSTest { // emitter.emitEvent(1, 2, 3, 4); // } } + +contract ExpectEmitCountTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Emitter emitter; + + event Something(uint256 indexed topic1, uint256 indexed topic2, uint256 indexed topic3, uint256 data); + + function setUp() public { + emitter = new Emitter(); + } + + function testCountNoEmit() public { + vm.expectEmit(0); + emit Something(1, 2, 3, 4); + emitter.doesNothing(); + } + + function testFailNoEmit() public { + vm.expectEmit(0); + emit Something(1, 2, 3, 4); + emitter.emitEvent(1, 2, 3, 4); + } + + function testCountNEmits() public { + uint64 count = 2; + vm.expectEmit(count); + emit Something(1, 2, 3, 4); + emitter.emitNEvents(1, 2, 3, 4, count); + } + + function testFailCountLessEmits() public { + uint64 count = 2; + vm.expectEmit(count); + emit Something(1, 2, 3, 4); + emitter.emitNEvents(1, 2, 3, 4, count - 1); + } + + function testCountMoreEmits() public { + uint64 count = 2; + vm.expectEmit(count); + emit Something(1, 2, 3, 4); + emitter.emitNEvents(1, 2, 3, 4, count + 1); + } + + /// Test zero emits from a specific address (emitter). + + function testCountNoEmitFromAddress() public { + vm.expectEmit(address(emitter), 0); + emit Something(1, 2, 3, 4); + emitter.doesNothing(); + } + + function testFailNoEmitFromAddress() public { + vm.expectEmit(address(emitter), 0); + emit Something(1, 2, 3, 4); + emitter.emitEvent(1, 2, 3, 4); + } + + function testCountEmitsFromAddress() public { + uint64 count = 2; + vm.expectEmit(address(emitter), count); + emit Something(1, 2, 3, 4); + emitter.emitNEvents(1, 2, 3, 4, count); + } + + function testFailCountEmitsFromAddress() public { + uint64 count = 3; + vm.expectEmit(address(emitter), count); + emit Something(1, 2, 3, 4); + emitter.emitNEvents(1, 2, 3, 4, count - 1); + } + + function testFailEmitSomethingElse() public { + uint64 count = 2; + vm.expectEmit(count); + emit Something(1, 2, 3, 4); + emitter.emitSomethingElse(23214); + } +} From 0086d041b8a8e348c4bb54eb1babc8a047d2ef71 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:07:51 +0200 Subject: [PATCH 1800/1963] fix(release): check `env.IS_NIGHTLY` as string (#9568) fix(release): check IS_NIGHTLY as string --- .github/workflows/release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e2dac1e80019..086ac31e4fd0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: - name: Compute release name and tag id: release_info run: | - if [[ $IS_NIGHTLY ]]; then + if [[ ${IS_NIGHTLY} == 'true' ]]; then echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT else @@ -43,7 +43,7 @@ jobs: # which allows users to roll back. It is also used to build # the changelog. - name: Create build-specific nightly tag - if: ${{ env.IS_NIGHTLY }} + if: ${{ env.IS_NIGHTLY == 'true' }} uses: actions/github-script@v7 env: TAG_NAME: ${{ steps.release_info.outputs.tag_name }} @@ -57,7 +57,7 @@ jobs: uses: mikepenz/release-changelog-builder-action@v4 with: configuration: "./.github/changelog.json" - fromTag: ${{ env.IS_NIGHTLY && 'nightly' || '' }} + fromTag: ${{ env.IS_NIGHTLY == 'true' && 'nightly' || '' }} toTag: ${{ steps.release_info.outputs.tag_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -168,7 +168,7 @@ jobs: env: PLATFORM_NAME: ${{ matrix.platform }} OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} ARCH: ${{ matrix.arch }} shell: bash run: | @@ -192,7 +192,7 @@ jobs: if: matrix.target == 'x86_64-unknown-linux-gnu' env: OUT_DIR: target/${{ matrix.target }}/${{ env.PROFILE }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash run: | sudo apt-get -y install help2man @@ -213,7 +213,7 @@ jobs: with: name: ${{ needs.prepare.outputs.release_name }} tag_name: ${{ needs.prepare.outputs.tag_name }} - prerelease: ${{ env.IS_NIGHTLY }} + prerelease: ${{ env.IS_NIGHTLY == 'true' }} body: ${{ needs.prepare.outputs.changelog }} files: | ${{ steps.artifacts.outputs.file_name }} @@ -231,7 +231,7 @@ jobs: # If this is a nightly release, it also updates the release # tagged `nightly` for compatibility with `foundryup` - name: Update nightly release - if: ${{ env.IS_NIGHTLY }} + if: ${{ env.IS_NIGHTLY == 'true' }} uses: softprops/action-gh-release@v2 with: name: "Nightly" @@ -253,7 +253,7 @@ jobs: # Moves the `nightly` tag to `HEAD` - name: Move nightly tag - if: ${{ env.IS_NIGHTLY }} + if: ${{ env.IS_NIGHTLY == 'true' }} uses: actions/github-script@v7 with: script: | From 8a08a3a92b0c842db2f254983cc3bd179300ad46 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:39:44 +0200 Subject: [PATCH 1801/1963] Run release workflow on stable tag push (#9575) --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 086ac31e4fd0f..2f4ed60e96450 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,7 @@ name: release on: push: tags: + - "stable" - "v*.*.*" schedule: - cron: "0 0 * * *" From 6c4af1d4e3eddae075c8b5c2616685b7d53b5c47 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 19 Dec 2024 09:05:25 +0200 Subject: [PATCH 1802/1963] chore: update release notes template (#9577) - feat / fixes category per binaries - breaking changes and perf category - restrict summary to max 60 days / max 100 PRs, add full diff and contributors --- .github/changelog.json | 62 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/.github/changelog.json b/.github/changelog.json index 4fe255e699ee4..e936ed9a3c111 100644 --- a/.github/changelog.json +++ b/.github/changelog.json @@ -1,16 +1,66 @@ { "categories": [ { - "title": "## Features", - "labels": ["T-feature"] + "title": "## Breaking changes", + "labels": ["T-likely-breaking "] }, { - "title": "## Fixes", - "labels": ["T-bug", "T-fix"] + "title": "## Anvil Features", + "labels": ["C-anvil", "T-feature"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Anvil Fixes", + "labels": ["C-anvil", "T-bug"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Cast Features", + "labels": ["C-cast", "T-feature"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Cast Fixes", + "labels": ["C-cast", "T-bug"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Chisel Features", + "labels": ["C-chisel", "T-feature"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Chisel Fixes", + "labels": ["C-chisel", "T-bug"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Forge Features", + "labels": ["C-forge", "T-feature"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Forge Fixes", + "labels": ["C-forge", "T-bug"], + "exhaustive": true, + "exhaustive_rules": false + }, + { + "title": "## Performance improvements", + "labels": ["T-perf"] } ], "ignore_labels": ["L-ignore"], - "template": "${{CHANGELOG}}\n## Other\n\n${{UNCATEGORIZED}}", + "template": "${{CHANGELOG}}\n## Other\n\n${{UNCATEGORIZED}}\n## Full diff:\n\n ${{RELEASE_DIFF}}\n## Contributors:\n\n${{CONTRIBUTORS}}", "pr_template": "- ${{TITLE}} (#${{NUMBER}})", - "empty_template": "- No changes" + "empty_template": "- No changes", + "max_pull_requests": 100, + "max_back_track_time_days": 60 } From a263a9280717b9247c4de7b54bd2180a4b6af6d1 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:27:09 +0200 Subject: [PATCH 1803/1963] chore: add contributors in release changelog (#9578) --- .github/changelog.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/changelog.json b/.github/changelog.json index e936ed9a3c111..aa548adc73777 100644 --- a/.github/changelog.json +++ b/.github/changelog.json @@ -58,8 +58,8 @@ } ], "ignore_labels": ["L-ignore"], - "template": "${{CHANGELOG}}\n## Other\n\n${{UNCATEGORIZED}}\n## Full diff:\n\n ${{RELEASE_DIFF}}\n## Contributors:\n\n${{CONTRIBUTORS}}", - "pr_template": "- ${{TITLE}} (#${{NUMBER}})", + "template": "${{CHANGELOG}}\n## Other\n\n${{UNCATEGORIZED}}\n## Full Changelog:\n ${{RELEASE_DIFF}}", + "pr_template": "- ${{TITLE}} (#${{NUMBER}}) by @${{AUTHOR}}", "empty_template": "- No changes", "max_pull_requests": 100, "max_back_track_time_days": 60 From af52b801d762f1f7aeb410282e59bc6d3556e22a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:28:48 +0200 Subject: [PATCH 1804/1963] feat(foundryup): allow multiple installed versions (#9551) * feat(foundryup): allow multiple installed versions * Changes after review: new line after version, -v renamed as -i, create version dir on untar * Update foundryup link repo and contribute URL * Fix --one-top-level not avail in bsd tar * Fix --one-top-level not avail in bsd tar * update docs * Err if no version provided to use --------- Co-authored-by: zerosnacks --- foundryup/README.md | 20 ++++++++++++--- foundryup/foundryup | 62 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/foundryup/README.md b/foundryup/README.md index 39a53288c001e..5504063abfe37 100644 --- a/foundryup/README.md +++ b/foundryup/README.md @@ -2,6 +2,8 @@ Update or revert to a specific Foundry branch with ease. +`foundryup` supports installing and managing multiple versions. + ## Installing ```sh @@ -16,10 +18,22 @@ To install the **nightly** version: foundryup ``` -To install a specific **version** (in this case the `nightly` version): +To **install** a specific **version** (in this case the `nightly` version): + +```sh +foundryup --install nightly +``` + +To **list** all **versions** installed: + +```sh +foundryup --list +``` + +To switch between different versions and **use**: ```sh -foundryup --version nightly +foundryup --use nightly-00efa0d5965269149f374ba142fb1c3c7edd6c94 ``` To install a specific **branch** (in this case the `release/0.1.0` branch's latest commit): @@ -62,6 +76,6 @@ foundryup --path ./git/foundry --- -**Tip**: All flags have a single character shorthand equivalent! You can use `-v` instead of `--version`, etc. +**Tip**: All flags have a single character shorthand equivalent! You can use `-i` instead of `--install`, etc. --- diff --git a/foundryup/foundryup b/foundryup/foundryup index 2dc94bfb49d3c..55b0b5a4b0530 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -3,6 +3,7 @@ set -eo pipefail BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} +FOUNDRY_VERSIONS_DIR="$FOUNDRY_DIR/versions" FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin" FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1" @@ -22,7 +23,9 @@ main() { -r|--repo) shift; FOUNDRYUP_REPO=$1;; -b|--branch) shift; FOUNDRYUP_BRANCH=$1;; - -v|--version) shift; FOUNDRYUP_VERSION=$1;; + -i|--install) shift; FOUNDRYUP_VERSION=$1;; + -l|--list) shift; list;; + -u|--use) shift; FOUNDRYUP_VERSION=$1; use;; -p|--path) shift; FOUNDRYUP_LOCAL_REPO=$1;; -P|--pr) shift; FOUNDRYUP_PR=$1;; -C|--commit) shift; FOUNDRYUP_COMMIT=$1;; @@ -137,15 +140,22 @@ main() { BIN_ARCHIVE_URL="${RELEASE_URL}foundry_${FOUNDRYUP_VERSION}_${PLATFORM}_${ARCHITECTURE}.$EXT" MAN_TARBALL_URL="${RELEASE_URL}foundry_man_${FOUNDRYUP_VERSION}.tar.gz" + ensure mkdir -p $FOUNDRY_VERSIONS_DIR # Download and extract the binaries archive - say "downloading latest forge, cast, anvil, and chisel" + say "downloading forge, cast, anvil, and chisel for $FOUNDRYUP_TAG version" if [ "$PLATFORM" = "win32" ]; then tmp="$(mktemp -d 2>/dev/null || echo ".")/foundry.zip" ensure download "$BIN_ARCHIVE_URL" "$tmp" - ensure unzip "$tmp" -d "$FOUNDRY_BIN_DIR" + ensure unzip "$tmp" -d "$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG" rm -f "$tmp" else - ensure download "$BIN_ARCHIVE_URL" | ensure tar -xzC "$FOUNDRY_BIN_DIR" + tmp="$(mktemp -d 2>/dev/null || echo ".")/foundry.tar.gz" + ensure download "$BIN_ARCHIVE_URL" "$tmp" + # Make sure it's a valid tar archive. + ensure tar tf $tmp 1> /dev/null + ensure mkdir -p $FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG + ensure tar -C "$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG" -xvf $tmp + rm -f "$tmp" fi # Optionally download the manuals @@ -159,6 +169,7 @@ main() { for bin in "${BINS[@]}"; do bin_path="$FOUNDRY_BIN_DIR/$bin" + cp $FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG/$bin $bin_path # Print installed msg say "installed - $(ensure "$bin_path" --version)" @@ -240,7 +251,9 @@ USAGE: OPTIONS: -h, --help Print help information - -v, --version Install a specific version from built binaries + -i, --install Install a specific version from built binaries + -l, --list List versions installed from built binaries + -u, --use Use a specific installed version from built binaries -b, --branch Build and install a specific branch -P, --pr Build and install a specific Pull Request -C, --commit Build and install a specific commit @@ -252,6 +265,41 @@ OPTIONS: EOF } +list() { + if [ -d "$FOUNDRY_VERSIONS_DIR" ]; then + for VERSION in $FOUNDRY_VERSIONS_DIR/*; do + say "${VERSION##*/}" + for bin in "${BINS[@]}"; do + bin_path="$VERSION/$bin" + say "- $(ensure "$bin_path" --version)" + done + printf "\n" + done + else + for bin in "${BINS[@]}"; do + bin_path="$FOUNDRY_BIN_DIR/$bin" + say "- $(ensure "$bin_path" --version)" + done + fi + exit 0 +} + +use() { + [ -z "$FOUNDRYUP_VERSION" ] && err "no version provided" + FOUNDRY_VERSION_DIR="$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_VERSION" + if [ -d "$FOUNDRY_VERSION_DIR" ]; then + for bin in "${BINS[@]}"; do + bin_path="$FOUNDRY_BIN_DIR/$bin" + cp $FOUNDRY_VERSION_DIR/$bin $bin_path + # Print usage msg + say "use - $(ensure "$bin_path" --version)" + done + exit 0 + else + err "version $FOUNDRYUP_VERSION not installed" + fi +} + say() { printf "foundryup: %s\n" "$1" } @@ -316,11 +364,11 @@ banner() { .xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx -Repo : https://github.com/foundry-rs/ +Repo : https://github.com/foundry-rs/foundry Book : https://book.getfoundry.sh/ Chat : https://t.me/foundry_rs/ Support : https://t.me/foundry_support/ -Contribute : https://github.com/orgs/foundry-rs/projects/2/ +Contribute : https://github.com/foundry-rs/foundry/blob/master/CONTRIBUTING.md .xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx From f3b5ac7ff29e7944884575de28c147f7f06ed41a Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:55:50 +0200 Subject: [PATCH 1805/1963] chore: bump workspace version to `0.3.0` (#9580) bump to 0.3.0 --- Cargo.lock | 60 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f58e168945bdd..9125707d1fd8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -923,7 +923,7 @@ dependencies = [ [[package]] name = "anvil" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -993,7 +993,7 @@ dependencies = [ [[package]] name = "anvil-core" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -1017,7 +1017,7 @@ dependencies = [ [[package]] name = "anvil-rpc" -version = "0.2.0" +version = "0.3.0" dependencies = [ "serde", "serde_json", @@ -1025,7 +1025,7 @@ dependencies = [ [[package]] name = "anvil-server" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anvil-rpc", "async-trait", @@ -2019,7 +2019,7 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cast" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -2114,7 +2114,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chisel" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3420,7 +3420,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "forge" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -3513,7 +3513,7 @@ dependencies = [ [[package]] name = "forge-doc" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-primitives", "derive_more", @@ -3536,7 +3536,7 @@ dependencies = [ [[package]] name = "forge-fmt" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-primitives", "ariadne", @@ -3552,7 +3552,7 @@ dependencies = [ [[package]] name = "forge-script" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -3597,7 +3597,7 @@ dependencies = [ [[package]] name = "forge-script-sequence" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-network", "alloy-primitives", @@ -3615,7 +3615,7 @@ dependencies = [ [[package]] name = "forge-sol-macro-gen" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-json-abi", "alloy-sol-macro-expander", @@ -3631,7 +3631,7 @@ dependencies = [ [[package]] name = "forge-verify" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3692,7 +3692,7 @@ dependencies = [ [[package]] name = "foundry-cheatcodes" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3741,7 +3741,7 @@ dependencies = [ [[package]] name = "foundry-cheatcodes-spec" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-sol-types", "foundry-macros", @@ -3752,7 +3752,7 @@ dependencies = [ [[package]] name = "foundry-cli" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-chains", "alloy-dyn-abi", @@ -3791,7 +3791,7 @@ dependencies = [ [[package]] name = "foundry-common" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-consensus", "alloy-contract", @@ -3842,7 +3842,7 @@ dependencies = [ [[package]] name = "foundry-common-fmt" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3970,7 +3970,7 @@ dependencies = [ [[package]] name = "foundry-config" -version = "0.2.0" +version = "0.3.0" dependencies = [ "Inflector", "alloy-chains", @@ -4007,7 +4007,7 @@ dependencies = [ [[package]] name = "foundry-debugger" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-primitives", "crossterm", @@ -4025,7 +4025,7 @@ dependencies = [ [[package]] name = "foundry-evm" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -4052,7 +4052,7 @@ dependencies = [ [[package]] name = "foundry-evm-abi" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -4065,7 +4065,7 @@ dependencies = [ [[package]] name = "foundry-evm-core" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -4100,7 +4100,7 @@ dependencies = [ [[package]] name = "foundry-evm-coverage" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-primitives", "eyre", @@ -4115,7 +4115,7 @@ dependencies = [ [[package]] name = "foundry-evm-fuzz" -version = "0.2.0" +version = "0.3.0" dependencies = [ "ahash", "alloy-dyn-abi", @@ -4141,7 +4141,7 @@ dependencies = [ [[package]] name = "foundry-evm-traces" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -4193,7 +4193,7 @@ dependencies = [ [[package]] name = "foundry-linking" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-primitives", "foundry-compilers", @@ -4203,7 +4203,7 @@ dependencies = [ [[package]] name = "foundry-macros" -version = "0.2.0" +version = "0.3.0" dependencies = [ "proc-macro-error", "proc-macro2", @@ -4213,7 +4213,7 @@ dependencies = [ [[package]] name = "foundry-test-utils" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-primitives", "alloy-provider", @@ -4236,7 +4236,7 @@ dependencies = [ [[package]] name = "foundry-wallets" -version = "0.2.0" +version = "0.3.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", diff --git a/Cargo.toml b/Cargo.toml index b8b0cfbebd008..b6f4fef690d59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.2.0" +version = "0.3.0" edition = "2021" # Remember to update clippy.toml as well rust-version = "1.83" From 7ac050264eea044458f2df1f1a3d5f6fc0bc6d28 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:15:53 +0200 Subject: [PATCH 1806/1963] Update CI workflow template to unpin from `nightly` explicitly, relying on `foundry-toolchain` default (#9573) * default CI workflow template to stable as opposed to nightly, related: https://github.com/foundry-rs/foundry-toolchain/pull/60 * remove pinning to stable in workflow file, rely on default in foundry-toolchain - now being nightly, becoming stable --- crates/forge/assets/workflowTemplate.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/forge/assets/workflowTemplate.yml b/crates/forge/assets/workflowTemplate.yml index 762a2966f7a69..34a4a527be6f9 100644 --- a/crates/forge/assets/workflowTemplate.yml +++ b/crates/forge/assets/workflowTemplate.yml @@ -22,8 +22,6 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - name: Show Forge version run: | From 5a8bd893eeeeb9489ea66dd52a02eeaa580e3af0 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:59:08 +0200 Subject: [PATCH 1807/1963] chore: testFail* deprecation warning (#9581) * chore: testFail* deprecation warning * test * fix --- crates/forge/src/runner.rs | 17 +++++++++++++++++ crates/forge/tests/cli/test_cmd.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 7b1293a72824f..467f1acd6bc17 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -402,6 +402,23 @@ impl<'a> ContractRunner<'a> { .collect::>(); let duration = start.elapsed(); + let test_fail_deprecations = self + .contract + .abi + .functions() + .filter_map(|func| { + TestFunctionKind::classify(&func.name, !func.inputs.is_empty()) + .is_any_test_fail() + .then_some(func.name.clone()) + }) + .collect::>() + .join(", "); + + if !test_fail_deprecations.is_empty() { + warnings.push(format!( + "`testFail*` has been deprecated and will be removed in the next release. Consider changing to test_Revert[If|When]_Condition and expecting a revert. Found deprecated testFail* function(s): {test_fail_deprecations}.", + )); + } SuiteResult::new(duration, test_results, warnings) } } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index e8da6a49035a0..20f865fc9e6c4 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2807,3 +2807,30 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]], ); }); + +forgetest!(test_fail_deprecation_warning, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source( + "WarnDeprecationTestFail.t.sol", + r#" + import "./test.sol"; + contract WarnDeprecationTestFail is DSTest { + function testFail_deprecated() public { + revert("deprecated"); + } + + function testFail_deprecated2() public { + revert("deprecated2"); + } + } + "#, + ) + .unwrap(); + + cmd.forge_fuse() + .args(["test", "--mc", "WarnDeprecationTestFail"]) + .assert_success() + .stderr_eq(r#"Warning: `testFail*` has been deprecated and will be removed in the next release. Consider changing to test_Revert[If|When]_Condition and expecting a revert. Found deprecated testFail* function(s): testFail_deprecated, testFail_deprecated2. +"#); +}); From 6091f257a72ffd8c072c624950286d1ff05ca310 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:35:57 +0200 Subject: [PATCH 1808/1963] chore(tests): bump forge-std version (#9584) * chore: bump forge-std version used for tests * run CI * fix tests * fix gas --------- Co-authored-by: DaniPopes Co-authored-by: zerosnacks --- crates/forge/tests/cli/cmd.rs | 4 ++-- crates/forge/tests/cli/script.rs | 2 +- testdata/forge-std-rev | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 82d819b207ff2..27aea6d8683f7 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2795,7 +2795,7 @@ contract NestedDeploy is Test { +============================================================================================+ | Deployment Cost | Deployment Size | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| -| 251997 | 739 | | | | | +| 251985 | 739 | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| | | | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| @@ -2850,7 +2850,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) { "contract": "test/NestedDeployTest.sol:Parent", "deployment": { - "gas": 251997, + "gas": 251985, "size": 739 }, "functions": { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 9cf3e746c9227..09df55668ed0d 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1956,7 +1956,7 @@ contract SimpleScript is Script { ]) .assert_success() .stdout_eq(str![[r#" -{"logs":[],"returns":{"success":{"internal_type":"bool","value":"true"}},"success":true,"raw_logs":[],"traces":[["Deployment",{"arena":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":false,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CREATE","value":"0x0","data":"0x6080604052600c805462ff00ff191662010001179055348015601f575f5ffd5b506101568061002d5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122060ba6332e526de9b6bc731fb4682b44e42845196324ec33068982984d700cdd964736f6c634300081b0033","output":"0x608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122060ba6332e526de9b6bc731fb4682b44e42845196324ec33068982984d700cdd964736f6c634300081b0033","gas_used":90639,"gas_limit":1073682810,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}],["Execution",{"arena":[{"parent":null,"children":[1,2],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0xc0406226","output":"0x0000000000000000000000000000000000000000000000000000000000000001","gas_used":3214,"gas_limit":1073720760,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[{"Call":0},{"Call":1}]},{"parent":0,"children":[],"idx":1,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x7109709ecfa91a80626ff3989d68f67f5b1dd12d","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x7fb5297f","output":"0x","gas_used":0,"gas_limit":1056940983,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]},{"parent":0,"children":[],"idx":2,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x0000000000000000000000000000000000000000","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1056940820,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}]],"gas_used":24278,"labeled_addresses":{},"returned":"0x0000000000000000000000000000000000000000000000000000000000000001","address":null} +{"logs":[],"returns":{"success":{"internal_type":"bool","value":"true"}},"success":true,"raw_logs":[],"traces":[["Deployment",{"arena":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":false,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CREATE","value":"0x0","data":"0x6080604052600c805462ff00ff191662010001179055348015601f575f5ffd5b506101568061002d5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122051a3965709e156763fe3847b1a8c4c2e1f5ad2088ccbc31509b98951c018fc8764736f6c634300081b0033","output":"0x608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122051a3965709e156763fe3847b1a8c4c2e1f5ad2088ccbc31509b98951c018fc8764736f6c634300081b0033","gas_used":90639,"gas_limit":1073682798,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}],["Execution",{"arena":[{"parent":null,"children":[1,2],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0xc0406226","output":"0x0000000000000000000000000000000000000000000000000000000000000001","gas_used":3214,"gas_limit":1073720760,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[{"Call":0},{"Call":1}]},{"parent":0,"children":[],"idx":1,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x7109709ecfa91a80626ff3989d68f67f5b1dd12d","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x7fb5297f","output":"0x","gas_used":0,"gas_limit":1056940983,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]},{"parent":0,"children":[],"idx":2,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x0000000000000000000000000000000000000000","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1056940820,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}]],"gas_used":24278,"labeled_addresses":{},"returned":"0x0000000000000000000000000000000000000000000000000000000000000001","address":null} {"chain":31337,"estimated_gas_price":"2.000000001","estimated_total_gas_used":29005,"estimated_amount_required":"0.000058010000029005"} {"chain":"anvil-hardhat","status":"success","tx_hash":"0x4f78afe915fceb282c7625a68eb350bc0bf78acb59ad893e5c62b710a37f3156","contract_address":null,"block_number":1,"gas_used":21000,"gas_price":1000000001} {"status":"success","transactions":"[..]/broadcast/Foo.sol/31337/run-latest.json","sensitive":"[..]/cache/Foo.sol/31337/run-latest.json"} diff --git a/testdata/forge-std-rev b/testdata/forge-std-rev index ff90d09c2b004..1a0142f7e970a 100644 --- a/testdata/forge-std-rev +++ b/testdata/forge-std-rev @@ -1 +1 @@ -1eea5bae12ae557d589f9f0f0edae2faa47cb262 \ No newline at end of file +b93cf4bc34ff214c099dc970b153f85ade8c9f66 \ No newline at end of file From 0d5ad758e08fc5ddbd2069f068093c4a94347d1c Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:03:20 +0200 Subject: [PATCH 1809/1963] chore(`foundryup`): default to stable if no specific version is passed in (#9585) * default to stable if no specific version is passed in * update mention, defaults to stable now --- foundryup/foundryup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 55b0b5a4b0530..710f7cce77788 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -89,7 +89,7 @@ main() { # Install by downloading binaries if [[ "$FOUNDRYUP_REPO" == "foundry-rs/foundry" && -z "$FOUNDRYUP_BRANCH" && -z "$FOUNDRYUP_COMMIT" ]]; then - FOUNDRYUP_VERSION=${FOUNDRYUP_VERSION:-nightly} + FOUNDRYUP_VERSION=${FOUNDRYUP_VERSION:-stable} FOUNDRYUP_TAG=$FOUNDRYUP_VERSION # Normalize versions (handle channels, versions without v prefix @@ -244,7 +244,7 @@ The installer for Foundry. Update or revert to a specific Foundry version with ease. -By default, the latest nightly version is installed from built binaries. +By default, the latest stable version is installed from built binaries. USAGE: foundryup From f922a340dae8e347d573fc6a403694bcb7fea106 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 22 Dec 2024 09:44:52 +0000 Subject: [PATCH 1810/1963] chore(deps): weekly `cargo update` (#9588) --- Cargo.lock | 486 +++++++++++++++++++++++++++-------------------------- 1 file changed, 245 insertions(+), 241 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9125707d1fd8f..d4027c358f686 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.48" +version = "0.1.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0161082e0edd9013d23083465cc04b20e44b7a15646d36ba7b0cdb7cd6fe18f" +checksum = "830045a4421ee38d3ab570d36d4d2b5152c066e72797139224da8de5d5981fd0" dependencies = [ "alloy-primitives", "num_enum", @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba14856660f31807ebb26ce8f667e814c72694e1077e97ef102e326ad580f3f" +checksum = "e88e1edea70787c33e11197d3f32ae380f3db19e6e061e539a5bcf8184a6b326" dependencies = [ "alloy-eips", "alloy-primitives", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28666307e76441e7af37a2b90cde7391c28112121bea59f4e0d804df8b20057e" +checksum = "57b1bb53f40c0273cd1975573cd457b39213e68584e36d1401d25fd0398a1d65" dependencies = [ "alloy-consensus", "alloy-eips", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3510769905590b8991a8e63a5e0ab4aa72cf07a13ab5fbe23f12f4454d161da" +checksum = "1b668c78c4b1f12f474ede5a85e8ce550d0aa1ef7d49fd1d22855a43b960e725" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -134,7 +134,7 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e922d558006ba371681d484d12aa73fe673d84884f83747730af7433c0e86d" +checksum = "5f9fadfe089e9ccc0650473f2d4ef0a28bc015bbca5631d9f0f09e49b557fdb3" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -206,9 +206,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dca170827a7ca156b43588faebf9e9d27c27d0fb07cab82cfd830345e2b24f5" +checksum = "2b2a4cf7b70f3495788e74ce1c765260ffe38820a2a774ff4aacb62e31ea73f9" dependencies = [ "alloy-primitives", "alloy-serde", @@ -230,23 +230,23 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9335278f50b0273e0a187680ee742bb6b154a948adf036f448575bacc5ccb315" +checksum = "e29040b9d5fe2fb70415531882685b64f8efd08dfbd6cc907120650504821105" dependencies = [ "alloy-primitives", "alloy-sol-types", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", ] [[package]] name = "alloy-network" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad4e6ad4230df8c4a254c20f8d6a84ab9df151bfca13f463177dbc96571cc1f8" +checksum = "510cc00b318db0dfccfdd2d032411cfae64fc144aef9679409e014145d3dacc4" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -264,14 +264,14 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] name = "alloy-network-primitives" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4df88a2f8020801e0fefce79471d3946d39ca3311802dbbd0ecfdeee5e972e3" +checksum = "9081c099e798b8a2bba2145eb82a9a146f01fc7a35e9ab6e7b43305051f97550" dependencies = [ "alloy-consensus", "alloy-eips", @@ -282,9 +282,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2db5cefbc736b2b26a960dcf82279c70a03695dd11a0032a6dc27601eeb29182" +checksum = "aef9849fb8bbb28f69f2cbdb4b0dac2f0e35c04f6078a00dfb8486469aed02de" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -292,7 +292,7 @@ dependencies = [ "rand", "serde_json", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", "url", ] @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5115c74c037714e1b02a86f742289113afa5d494b5ea58308ba8aa378e739101" +checksum = "dc2dfaddd9a30aa870a78a4e1316e3e115ec1e12e552cbc881310456b85c1f24" dependencies = [ "alloy-chains", "alloy-consensus", @@ -365,7 +365,7 @@ dependencies = [ "schnellru", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tracing", "url", @@ -374,9 +374,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b073afa409698d1b9a30522565815f3bf7010e5b47b997cf399209e6110df097" +checksum = "695809e743628d54510c294ad17a4645bd9f465aeb0d20ee9ce9877c9712dc9c" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -415,9 +415,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6a0bd0ce5660ac48e4f3bb0c7c5c3a94db287a0be94971599d83928476cbcd" +checksum = "531137b283547d5b9a5cafc96b006c64ef76810c681d606f28be9781955293b6" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -441,9 +441,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374ac12e35bb90ebccd86e7c943ddba9590149a6e35cc4d9cd860d6635fd1018" +checksum = "3410a472ce26c457e9780f708ee6bd540b30f88f1f31fdab7a11d00bd6aa1aee" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -457,9 +457,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b85a5f5f5d99047544f4ec31330ee15121dcb8ef5af3e791a5207e6b92b05b" +checksum = "9ed06bd8a5fc57b352a6cbac24eec52a4760f08ae2c1eb56ac49c8ed4b02c351" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -469,9 +469,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea98f81bcd759dbfa3601565f9d7a02220d8ef1d294ec955948b90aaafbfd857" +checksum = "ed98e1af55a7d856bfa385f30f63d8d56be2513593655c904a8f4a7ec963aa3e" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -480,9 +480,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fd14f68a482e67dfba52d404dfff1d3b0d9fc3b4775bd0923f3175d7661c3bd" +checksum = "e1dec1c1b65614ebd5834a7dfddf525a186962082023718e10f4f64ed2d02514" dependencies = [ "alloy-primitives", "serde", @@ -490,9 +490,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca5898f753ff0d15a0dc955c169523d8fee57e05bb5a38a398b3451b0b988be" +checksum = "03bd16fa4959255ebf4a7702df08f325e5631df5cdca07c8a8e58bdc10fe02e3" dependencies = [ "alloy-consensus", "alloy-eips", @@ -508,9 +508,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e518b0a7771e00728f18be0708f828b18a1cfc542a7153bef630966a26388e0" +checksum = "8737d7a6e37ca7bba9c23e9495c6534caec6760eb24abc9d5ffbaaba147818e1" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -528,23 +528,23 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdff93fa38be6982f8613a060e18fa0a37ce440d69ed3b7f37c6c69036ce1c53" +checksum = "db14a83665cd28ffd01939f04c2adf0e0fd9bb648b73ca651dcaa0869dae027f" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", "alloy-serde", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] name = "alloy-rpc-types-txpool" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d9dc647985db41fd164e807577134da1179b9f5ba0959f8698d6587eaa568f5" +checksum = "0a574e97dff62097d22d6cd360f898f3d069239ca0ca7bfc2e5e7b22815ec572" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -554,9 +554,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3dc8d4a08ffc90c1381d39a4afa2227668259a42c97ab6eecf51cbd82a8761" +checksum = "5851bf8d5ad33014bd0c45153c603303e730acc8a209450a7ae6b4a12c2789e2" dependencies = [ "alloy-primitives", "serde", @@ -565,9 +565,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16188684100f6e0f2a2b949968fe3007749c5be431549064a1bce4e7b3a196a9" +checksum = "7e10ca565da6500cca015ba35ee424d59798f2e1b85bc0dd8f81dafd401f029a" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -576,14 +576,14 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] name = "alloy-signer-aws" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe06d524ac84fefce1184f2d1273704e62faade7ff1f29c17ac9d493d3ffbdbf" +checksum = "1e774d4203ad7dbeba06876c8528a169b7cb56770bd900bc061e6a2c2756a736" dependencies = [ "alloy-consensus", "alloy-network", @@ -593,15 +593,15 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", ] [[package]] name = "alloy-signer-gcp" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "492cedcb4819a588aaef8d59edd5d65291f485d25f64b2aa0806dd86feeafd18" +checksum = "9843facd50077d2010ac0ef9e9176f8a06f2e2c8e653d83d82859803c623c6fc" dependencies = [ "alloy-consensus", "alloy-network", @@ -611,15 +611,15 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", ] [[package]] name = "alloy-signer-ledger" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426409a02587b98e118d2fd32dda3f423805e264a32f9e247a65164163bc0e9b" +checksum = "08367716d2eee6f15f0f7ee2e855decbfedd12be12fe5f490a2d2717deda95bf" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -631,15 +631,15 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.24", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", ] [[package]] name = "alloy-signer-local" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2184dab8c9493ab3e1c9f6bd3bdb563ed322b79023d81531935e84a4fdf7cf1" +checksum = "47fababf5a745133490cde927d48e50267f97d3d1209b9fc9f1d1d666964d172" dependencies = [ "alloy-consensus", "alloy-network", @@ -651,14 +651,14 @@ dependencies = [ "eth-keystore", "k256", "rand", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] name = "alloy-signer-trezor" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290ead62e020b751761de95f60056340faba341b20493ae929013d1357b9ba5b" +checksum = "cfbd920ad5dc03e1904827d30fd2ed874968c33885e254b2c2f59503b33e4bb8" dependencies = [ "alloy-consensus", "alloy-network", @@ -666,7 +666,7 @@ dependencies = [ "alloy-signer", "async-trait", "semver 1.0.24", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", "trezor-client", ] @@ -746,9 +746,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628be5b9b75e4f4c4f2a71d985bbaca4f23de356dc83f1625454c505f5eef4df" +checksum = "538a04a37221469cac0ce231b737fd174de2fdfcdd843bdd068cb39ed3e066ad" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -756,7 +756,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tower 0.5.2", "tracing", @@ -766,9 +766,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e24412cf72f79c95cd9b1d9482e3a31f9d94c24b43c4b3b710cc8d4341eaab0" +checksum = "2ed40eb1e1265b2911512f6aa1dcece9702d078f5a646730c45e39e2be00ac1c" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -781,9 +781,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0577a1f67ce70ece3f2b27cf1011da7222ef0a5701f7dcb558e5356278eeb531" +checksum = "a7a172a59d24706b26a79a837f86d51745cb26ca6f8524712acd0208a14cff95" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -802,9 +802,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca46272d17f9647fdb56080ed26c72b3ea5078416831130f5ed46f3b4be0ed6" +checksum = "fba0e39d181d13c266dbb8ca54ed584a2c66d6e9279afca89c7a6b1825e98abb" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -968,7 +968,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 1.5.1", + "hyper 1.5.2", "itertools 0.13.0", "k256", "op-alloy-consensus", @@ -981,7 +981,7 @@ dependencies = [ "serde_repr", "similar-asserts", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.9", "tikv-jemallocator", "tokio", "tower 0.4.13", @@ -1012,7 +1012,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -1038,7 +1038,7 @@ dependencies = [ "pin-project 1.1.7", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio-util", "tower-http", "tracing", @@ -1338,9 +1338,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.10" +version = "1.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b49afaa341e8dd8577e1a2200468f98956d6eda50bcf4a53246cc00174ba924" +checksum = "a5d1c2c88936a73c699225d0bc00684a534166b0cebc2659c3cdf08de8edc64c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1349,7 +1349,7 @@ dependencies = [ "aws-sdk-sts", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.60.7", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1380,9 +1380,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.4.4" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5ac934720fbb46206292d2c75b57e67acfc56fe7dfd34fb9a02334af08409ea" +checksum = "300a12520b4e6d08b73f77680f12c16e8ae43250d55100e0b2be46d78da16a48" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1405,15 +1405,15 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.51.0" +version = "1.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c30f6fd5646b99d9b45ec3a0c22e67112c175b2383100c960d7ee39d96c8d96" +checksum = "0ff4c717bf02350576b1542d7534edda68b95299b72700424978afd125b0b507" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1427,15 +1427,15 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.50.0" +version = "1.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ca43a4ef210894f93096039ef1d6fa4ad3edfabb3be92b80908b9f2e4b4eab" +checksum = "74995133da38f109a0eb8e8c886f9e80c713b6e9f2e6e5a6a1ba4450ce2ffc46" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1449,15 +1449,15 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.51.0" +version = "1.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abaf490c2e48eed0bb8e2da2fb08405647bd7f253996e0f93b981958ea0f73b0" +checksum = "e7062a779685cbf3b2401eb36151e2c6589fd5f3569b8a6bc2d199e5aaa1d059" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -1471,15 +1471,15 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.51.0" +version = "1.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b68fde0d69c8bfdc1060ea7da21df3e39f6014da316783336deff0a9ec28f4bf" +checksum = "299dae7b1dc0ee50434453fa5a229dc4b22bd3ee50409ff16becf1f7346e0193" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-query", "aws-smithy-runtime", "aws-smithy-runtime-api", @@ -1517,9 +1517,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" +checksum = "8aa8ff1492fd9fb99ae28e8467af0dbbb7c31512b16fabf1a0f10d7bb6ef78bb" dependencies = [ "futures-util", "pin-project-lite", @@ -1546,15 +1546,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "aws-smithy-json" -version = "0.60.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4683df9469ef09468dad3473d129960119a0d3593617542b7d52086c8486f2d6" -dependencies = [ - "aws-smithy-types", -] - [[package]] name = "aws-smithy-json" version = "0.61.1" @@ -1576,9 +1567,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.4" +version = "1.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f20685047ca9d6f17b994a07f629c813f08b5bce65523e47124879e60103d45" +checksum = "431a10d0e07e09091284ef04453dae4069283aa108d209974d67e77ae1caa658" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1591,7 +1582,7 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper 0.14.31", + "hyper 0.14.32", "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", @@ -1620,9 +1611,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.9" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd94a32b3a7d55d3806fe27d98d3ad393050439dd05eb53ece36ec5e3d3510" +checksum = "8ecbf4d5dfb169812e2b240a4350f15ad3c6b03a54074e5712818801615f2dc5" dependencies = [ "base64-simd", "bytes", @@ -1678,7 +1669,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "itoa", "matchit", @@ -1914,9 +1905,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" [[package]] name = "byteorder" @@ -2087,9 +2078,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.4" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" +checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" dependencies = [ "shlex", ] @@ -2227,9 +2218,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.38" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9647a559c112175f17cf724dc72d3645680a883c58481332779192b0d8e7a01" +checksum = "ac2e663e3e3bed2d32d065a8404024dad306e699a04263ec59919529f803aee9" dependencies = [ "clap", ] @@ -2448,15 +2439,15 @@ checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af" [[package]] name = "console" -version = "0.15.8" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "unicode-width 0.1.14", - "windows-sys 0.52.0", + "once_cell", + "unicode-width 0.2.0", + "windows-sys 0.59.0", ] [[package]] @@ -2543,18 +2534,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -2571,9 +2562,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crossterm" @@ -3052,9 +3043,9 @@ dependencies = [ [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "endian-type" @@ -3075,9 +3066,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -3085,9 +3076,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ "anstream", "anstyle", @@ -3304,6 +3295,17 @@ dependencies = [ "bytes", ] +[[package]] +name = "fastrlp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8dba4714ef14b8274c371879b175aa55b16b30f269663f19d576f380018dc4" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + [[package]] name = "fd-lock" version = "4.0.2" @@ -3388,7 +3390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide 0.8.2", ] [[package]] @@ -3399,9 +3401,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "foreign-types" @@ -3469,7 +3471,7 @@ dependencies = [ "futures", "globset", "humantime-serde", - "hyper 1.5.1", + "hyper 1.5.2", "indicatif", "inferno", "itertools 0.13.0", @@ -3496,7 +3498,7 @@ dependencies = [ "strum", "svm-rs", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.9", "tikv-jemallocator", "tokio", "toml 0.8.19", @@ -3529,7 +3531,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "thiserror 2.0.7", + "thiserror 2.0.9", "toml 0.8.19", "tracing", ] @@ -3544,7 +3546,7 @@ dependencies = [ "itertools 0.13.0", "similar-asserts", "solang-parser", - "thiserror 2.0.7", + "thiserror 2.0.9", "toml 0.8.19", "tracing", "tracing-subscriber", @@ -3732,7 +3734,7 @@ dependencies = [ "semver 1.0.24", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", "toml 0.8.19", "tracing", "vergen", @@ -3831,7 +3833,7 @@ dependencies = [ "serde_json", "similar-asserts", "terminal_size", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tower 0.4.13", "tracing", @@ -3890,7 +3892,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tracing", "winnow", @@ -3924,7 +3926,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tracing", "walkdir", @@ -3963,7 +3965,7 @@ dependencies = [ "serde_json", "svm-rs", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "walkdir", ] @@ -3997,7 +3999,7 @@ dependencies = [ "similar-asserts", "solang-parser", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.9", "toml 0.8.19", "toml_edit", "tracing", @@ -4046,7 +4048,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", ] @@ -4092,7 +4094,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tracing", "url", @@ -4135,7 +4137,7 @@ dependencies = [ "rand", "revm", "serde", - "thiserror 2.0.7", + "thiserror 2.0.9", "tracing", ] @@ -4185,7 +4187,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tracing", "url", @@ -4198,7 +4200,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "semver 1.0.24", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -4260,7 +4262,7 @@ dependencies = [ "gcloud-sdk", "rpassword", "serde", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tracing", ] @@ -4273,9 +4275,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "fs4" -version = "0.9.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c6b3bd49c37d2aa3f3f2220233b29a7cd23f79d1fe70e5337d25fb390793de" +checksum = "c29c30684418547d476f0b48e84f4821639119c483b1eccd566c8cd0cd05f521" dependencies = [ "rustix", "windows-sys 0.52.0", @@ -4417,7 +4419,7 @@ dependencies = [ "bytes", "chrono", "futures", - "hyper 1.5.1", + "hyper 1.5.2", "jsonwebtoken", "once_cell", "prost", @@ -4523,7 +4525,7 @@ dependencies = [ "bstr", "gix-path", "libc", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -4535,7 +4537,7 @@ dependencies = [ "bstr", "itoa", "jiff", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -4626,7 +4628,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -4698,7 +4700,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -4884,11 +4886,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4997,9 +4999,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.31" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ "bytes", "futures-channel", @@ -5021,9 +5023,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -5048,7 +5050,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.32", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -5058,13 +5060,13 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http 1.2.0", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "rustls 0.23.20", "rustls-native-certs 0.8.1", @@ -5081,7 +5083,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "pin-project-lite", "tokio", @@ -5096,7 +5098,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "native-tls", "tokio", @@ -5115,7 +5117,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.1", + "hyper 1.5.2", "pin-project-lite", "socket2", "tokio", @@ -5470,9 +5472,9 @@ dependencies = [ [[package]] name = "instability" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b829f37dead9dc39df40c2d3376c179fdfd2ac771f53f55d3c30dc096a3c0c6e" +checksum = "898e106451f7335950c9cc64f8ec67b5f65698679ac67ed00619aeef14e1cf75" dependencies = [ "darling", "indoc", @@ -5718,9 +5720,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.168" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libdbus-sys" @@ -5993,9 +5995,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] @@ -6369,9 +6371,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848b3567a9a469ab0c9c712fca0fd6bbce13a9a0b723c94cb81214f53507cf07" +checksum = "c698f80ee53e56d1b60a97e9d90ad09788b516c964c9c97fb5927860b812ef0d" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6380,14 +6382,14 @@ dependencies = [ "alloy-serde", "derive_more", "serde", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] name = "op-alloy-rpc-types" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a555dd1bd39cbcdd60b92f03a21871767a16e3a2ce2f82a26cff9aade56d35f" +checksum = "b5aef2128fe8979596b3a1f79a2454f3e32fd239889a03d50fe686b9a2f30a16" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6659,7 +6661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.7", + "thiserror 2.0.9", "ucd-trie", ] @@ -6885,9 +6887,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "predicates" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" dependencies = [ "anstyle", "predicates-core", @@ -6895,15 +6897,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" [[package]] name = "predicates-tree" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" dependencies = [ "predicates-core", "termtree", @@ -7082,9 +7084,9 @@ dependencies = [ [[package]] name = "proptest-derive" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" +checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", @@ -7178,7 +7180,7 @@ dependencies = [ "newtype-uuid", "quick-xml 0.37.1", "strip-ansi-escapes", - "thiserror 2.0.7", + "thiserror 2.0.9", "uuid 1.11.0", ] @@ -7213,7 +7215,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.20", "socket2", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "tracing", ] @@ -7232,7 +7234,7 @@ dependencies = [ "rustls 0.23.20", "rustls-pki-types", "slab", - "thiserror 2.0.7", + "thiserror 2.0.9", "tinyvec", "tracing", "web-time", @@ -7240,9 +7242,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52cd4b1eff68bf27940dd39811292c49e007f4d0b4c357358dc9b0197be6b527" +checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ "cfg_aliases 0.2.1", "libc", @@ -7449,8 +7451,8 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", - "hyper-rustls 0.27.3", + "hyper 1.5.2", + "hyper-rustls 0.27.5", "hyper-tls", "hyper-util", "ipnet", @@ -7516,7 +7518,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.7", + "thiserror 2.0.9", ] [[package]] @@ -7657,17 +7659,19 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.3" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" +checksum = "f5ef8fb1dd8de3870cb8400d51b4c2023854bbafd5431a3ac7e7317243e22d2f" dependencies = [ "alloy-rlp", "arbitrary", "ark-ff 0.3.0", "ark-ff 0.4.2", "bytes", - "fastrlp", + "fastrlp 0.3.1", + "fastrlp 0.4.0", "num-bigint", + "num-integer", "num-traits", "parity-scale-codec", "primitive-types", @@ -7796,7 +7800,7 @@ dependencies = [ "openssl-probe", "rustls-pki-types", "schannel", - "security-framework 3.0.1", + "security-framework 3.1.0", ] [[package]] @@ -7947,9 +7951,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" +checksum = "94b13f8ea6177672c49d12ed964cca44836f59621981b04a3e26b87e675181de" dependencies = [ "sdd", ] @@ -8034,9 +8038,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" +checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" [[package]] name = "sec1" @@ -8099,9 +8103,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" +checksum = "81d3f8c9bfcc3cbb6b0179eb57042d75b1582bdc65c3cb95f3fa999509c03cbc" dependencies = [ "bitflags 2.6.0", "core-foundation 0.10.0", @@ -8112,9 +8116,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -8186,9 +8190,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" dependencies = [ "indexmap 2.7.0", "itoa", @@ -8453,9 +8457,9 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "snapbox" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1373ce406dfad473059bbc31d807715642182bbc952a811952b58d1c9e41dcfa" +checksum = "96dcfc4581e3355d70ac2ee14cfdf81dce3d85c85f1ed9e2c1d3013f53b3436b" dependencies = [ "anstream", "anstyle", @@ -8641,7 +8645,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror 2.0.7", + "thiserror 2.0.9", "tokio", "toml_edit", "uuid 1.11.0", @@ -8767,9 +8771,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aebac1b1ef2b46e2e2bdf3c09db304800f2a77c1fa902bd5231490203042be8" +checksum = "a1e9bc6b09b8a7a919128f8c029ae4048d83f814af557e948115273c75864acf" dependencies = [ "const-hex", "dirs 5.0.1", @@ -8780,16 +8784,16 @@ dependencies = [ "serde_json", "sha2", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.9", "url", "zip", ] [[package]] name = "svm-rs-builds" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fa0f145894cb4d1c14446f08098ee5f21fc37ccbd1a7dd9dd355bbc806de3b" +checksum = "34d0964cd9dfcbf8bd21057c1a4aa293fefab208306461989ce723dd9c51e71e" dependencies = [ "build_const", "const-hex", @@ -8918,9 +8922,9 @@ dependencies = [ [[package]] name = "termtree" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] name = "textwrap" @@ -8944,11 +8948,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.7" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93605438cbd668185516ab499d589afb7ee1859ea3d5fc8f6b0755e1c7443767" +checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ - "thiserror-impl 2.0.7", + "thiserror-impl 2.0.9", ] [[package]] @@ -8964,9 +8968,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.7" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d8749b4531af2117677a5fcd12b1348a3fe2b81e36e61ffeac5c4aa3273e36" +checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", @@ -9066,9 +9070,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "tinyvec_macros", ] @@ -9250,7 +9254,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-timeout", "hyper-util", "percent-encoding", @@ -10473,9 +10477,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" +checksum = "ae9c1ea7b3a5e1f4b922ff856a129881167511563dc219869afe3787fc0c1a45" dependencies = [ "arbitrary", "bzip2", @@ -10485,7 +10489,7 @@ dependencies = [ "flate2", "indexmap 2.7.0", "memchr", - "thiserror 2.0.7", + "thiserror 2.0.9", "zopfli", ] From 3ba3d5f9e6008779c68b94ef9a0015ca2fe60b6a Mon Sep 17 00:00:00 2001 From: Delweng Date: Tue, 24 Dec 2024 16:27:43 +0800 Subject: [PATCH 1811/1963] feat(cast): pretty print other receipt fields (#9589) * fix(cast): pretty print other receipt fields Signed-off-by: jsvisa * feat(cast): add other receipt fields pretty test Signed-off-by: jsvisa * fix(ui): receipt column length 20 Signed-off-by: jsvisa * fmt Signed-off-by: jsvisa * fix receipt indent test Signed-off-by: jsvisa * fix test case /2 Signed-off-by: jsvisa * fix revert reason indent Signed-off-by: jsvisa --------- Signed-off-by: jsvisa --- crates/cast/tests/cli/main.rs | 74 +++++++++++------------ crates/common/fmt/src/ui.rs | 99 ++++++++++++++++++++++++------- crates/common/src/transactions.rs | 2 +- 3 files changed, 116 insertions(+), 59 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 3c3096a363c97..c87c5f7f26deb 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -810,24 +810,24 @@ casttest!(receipt_revert_reason, |_prj, cmd| { .assert_success() .stdout_eq(str![[r#" -blockHash 0x2cfe65be49863676b6dbc04d58176a14f39b123f1e2f4fea0383a2d82c2c50d0 -blockNumber 16239315 -contractAddress -cumulativeGasUsed 10743428 -effectiveGasPrice 10539984136 -from 0x199D5ED7F45F4eE35960cF22EAde2076e95B253F -gasUsed 21000 -logs [] -logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -root -status 1 (success) -transactionHash 0x44f2aaa351460c074f2cb1e5a9e28cbc7d83f33e425101d2de14331c7b7ec31e -transactionIndex 116 -type 0 -blobGasPrice -blobGasUsed -authorizationList -to 0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59c +blockHash 0x2cfe65be49863676b6dbc04d58176a14f39b123f1e2f4fea0383a2d82c2c50d0 +blockNumber 16239315 +contractAddress +cumulativeGasUsed 10743428 +effectiveGasPrice 10539984136 +from 0x199D5ED7F45F4eE35960cF22EAde2076e95B253F +gasUsed 21000 +logs [] +logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +root +status 1 (success) +transactionHash 0x44f2aaa351460c074f2cb1e5a9e28cbc7d83f33e425101d2de14331c7b7ec31e +transactionIndex 116 +type 0 +blobGasPrice +blobGasUsed +authorizationList +to 0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59c "#]]); @@ -844,25 +844,25 @@ to 0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59c .assert_success() .stdout_eq(str![[r#" -blockHash 0x883f974b17ca7b28cb970798d1c80f4d4bb427473dc6d39b2a7fe24edc02902d -blockNumber 14839405 -contractAddress -cumulativeGasUsed 20273649 -effectiveGasPrice 21491736378 -from 0x3cF412d970474804623bb4e3a42dE13F9bCa5436 -gasUsed 24952 -logs [] -logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -root -status 0 (failed) -transactionHash 0x0e07d8b53ed3d91314c80e53cf25bcde02084939395845cbb625b029d568135c -transactionIndex 173 -type 2 -blobGasPrice -blobGasUsed -authorizationList -to 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45 -revertReason Transaction too old, data: "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000135472616e73616374696f6e20746f6f206f6c6400000000000000000000000000" +blockHash 0x883f974b17ca7b28cb970798d1c80f4d4bb427473dc6d39b2a7fe24edc02902d +blockNumber 14839405 +contractAddress +cumulativeGasUsed 20273649 +effectiveGasPrice 21491736378 +from 0x3cF412d970474804623bb4e3a42dE13F9bCa5436 +gasUsed 24952 +logs [] +logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +root +status 0 (failed) +transactionHash 0x0e07d8b53ed3d91314c80e53cf25bcde02084939395845cbb625b029d568135c +transactionIndex 173 +type 2 +blobGasPrice +blobGasUsed +authorizationList +to 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45 +revertReason Transaction too old, data: "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000135472616e73616374696f6e20746f6f206f6c6400000000000000000000000000" "#]]); }); diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 9962a858397fe..0798967c6a0a0 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -193,23 +193,23 @@ impl UIfmt for AnyTransactionReceipt { let mut pretty = format!( " -blockHash {} -blockNumber {} -contractAddress {} -cumulativeGasUsed {} -effectiveGasPrice {} -from {} -gasUsed {} -logs {} -logsBloom {} -root {} -status {} -transactionHash {} -transactionIndex {} -type {} -blobGasPrice {} -blobGasUsed {} -authorizationList {}", +blockHash {} +blockNumber {} +contractAddress {} +cumulativeGasUsed {} +effectiveGasPrice {} +from {} +gasUsed {} +logs {} +logsBloom {} +root {} +status {} +transactionHash {} +transactionIndex {} +type {} +blobGasPrice {} +blobGasUsed {} +authorizationList {}", block_hash.pretty(), block_number.pretty(), contract_address.pretty(), @@ -233,13 +233,11 @@ authorizationList {}", ); if let Some(to) = to { - pretty.push_str(&format!("\nto {}", to.pretty())); + pretty.push_str(&format!("\nto {}", to.pretty())); } // additional captured fields - for (key, val) in other.iter() { - pretty.push_str(&format!("\n{key} {val}")); - } + pretty.push_str(&other.pretty()); pretty } @@ -1415,4 +1413,63 @@ value 0".to_string(); assert_eq!(Some("1424182926".to_string()), get_pretty_block_attr(&block, "timestamp")); assert_eq!(Some("163591".to_string()), get_pretty_block_attr(&block, "totalDifficulty")); } + + #[test] + fn test_receipt_other_fields_alignment() { + let receipt_json = serde_json::json!( + { + "status": "0x1", + "cumulativeGasUsed": "0x74e483", + "logs": [], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "transactionHash": "0x91181b0dca3b29aa136eeb2f536be5ce7b0aebc949be1c44b5509093c516097d", + "transactionIndex": "0x10", + "blockHash": "0x54bafb12e8cea9bb355fbf03a4ac49e42a2a1a80fa6cf4364b342e2de6432b5d", + "blockNumber": "0x7b1ab93", + "gasUsed": "0xc222", + "effectiveGasPrice": "0x18961", + "from": "0x2d815240a61731c75fa01b2793e1d3ed09f289d0", + "to": "0x4200000000000000000000000000000000000000", + "contractAddress": null, + "l1BaseFeeScalar": "0x146b", + "l1BlobBaseFee": "0x6a83078", + "l1BlobBaseFeeScalar": "0xf79c5", + "l1Fee": "0x51a9af7fd3", + "l1GasPrice": "0x972fe4acc", + "l1GasUsed": "0x640" + }); + + let receipt: AnyTransactionReceipt = serde_json::from_value(receipt_json).unwrap(); + let formatted = receipt.pretty(); + + let expected = r#" +blockHash 0x54bafb12e8cea9bb355fbf03a4ac49e42a2a1a80fa6cf4364b342e2de6432b5d +blockNumber 129084307 +contractAddress +cumulativeGasUsed 7660675 +effectiveGasPrice 100705 +from 0x2D815240A61731c75Fa01b2793E1D3eD09F289d0 +gasUsed 49698 +logs [] +logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +root +status 1 (success) +transactionHash 0x91181b0dca3b29aa136eeb2f536be5ce7b0aebc949be1c44b5509093c516097d +transactionIndex 16 +type 2 +blobGasPrice +blobGasUsed +authorizationList +to 0x4200000000000000000000000000000000000000 +l1BaseFeeScalar 5227 +l1BlobBaseFee 111685752 +l1BlobBaseFeeScalar 1014213 +l1Fee 350739202003 +l1GasPrice 40583973580 +l1GasUsed 1600 +"#; + + assert_eq!(formatted.trim(), expected.trim()); + } } diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index b725fc068b17f..9148cd6d9a0fd 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -88,7 +88,7 @@ impl UIfmt for TransactionReceiptWithRevertReason { if let Some(revert_reason) = &self.revert_reason { format!( "{} -revertReason {}", +revertReason {}", self.receipt.pretty(), revert_reason ) From 0caabdd3c8456a09604d9030fd9479ad8254346c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 29 Dec 2024 12:01:40 +0100 Subject: [PATCH 1812/1963] chore(deps): weekly `cargo update` (#9599) Locking 29 packages to latest compatible versions Updating alloy-chains v0.1.49 -> v0.1.51 Updating alloy-trie v0.7.6 -> v0.7.7 Updating anyhow v1.0.94 -> v1.0.95 Updating aws-config v1.5.11 -> v1.5.12 Updating aws-runtime v1.5.1 -> v1.5.2 Updating aws-sdk-kms v1.52.0 -> v1.53.0 Updating aws-sdk-sso v1.51.0 -> v1.52.0 Updating aws-sdk-ssooidc v1.52.0 -> v1.53.0 Updating aws-sdk-sts v1.52.0 -> v1.53.0 Updating aws-smithy-async v1.2.2 -> v1.2.3 Updating aws-smithy-runtime v1.7.5 -> v1.7.6 Updating aws-smithy-types v1.2.10 -> v1.2.11 Updating bon v3.3.0 -> v3.3.2 Updating bon-macros v3.3.0 -> v3.3.2 Updating cc v1.2.5 -> v1.2.6 Updating gix-date v0.9.2 -> v0.9.3 Updating glob v0.3.1 -> v0.3.2 Updating jiff v0.1.15 -> v0.1.16 Updating nybbles v0.2.1 -> v0.3.0 Updating quote v1.0.37 -> v1.0.38 Updating reqwest v0.12.9 -> v0.12.11 Updating rustversion v1.0.18 -> v1.0.19 Updating scc v2.2.6 -> v2.3.0 Updating serde v1.0.216 -> v1.0.217 Updating serde_derive v1.0.216 -> v1.0.217 Updating syn v2.0.90 -> v2.0.93 Updating tracing-tracy v0.11.3 -> v0.11.4 Updating tracy-client v0.17.6 -> v0.18.0 Updating unicase v2.8.0 -> v2.8.1 note: pass `--verbose` to see 13 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 250 +++++++++++++++++++++++++++-------------------------- 1 file changed, 126 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4027c358f686..2ff45031d5f11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.49" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830045a4421ee38d3ab570d36d4d2b5152c066e72797139224da8de5d5981fd0" +checksum = "d4e0f0136c085132939da6b753452ebed4efaa73fe523bb855b10c199c2ebfaf" dependencies = [ "alloy-primitives", "num_enum", @@ -410,7 +410,7 @@ checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -682,7 +682,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -699,7 +699,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "syn-solidity", "tiny-keccak", ] @@ -717,7 +717,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.90", + "syn 2.0.93", "syn-solidity", ] @@ -820,9 +820,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a5fd8fea044cc9a8c8a50bb6f28e31f0385d820f116c5b98f6f4e55d6e5590b" +checksum = "1e428104b2445a4f929030891b3dbf8c94433a8349ba6480946bf6af7975c2f6" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -1046,9 +1046,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arbitrary" @@ -1241,7 +1241,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1263,7 +1263,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1274,7 +1274,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1327,7 +1327,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -1338,9 +1338,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.11" +version = "1.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d1c2c88936a73c699225d0bc00684a534166b0cebc2659c3cdf08de8edc64c" +checksum = "649316840239f4e58df0b7f620c428f5fababbbca2d504488c641534050bd141" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1380,9 +1380,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300a12520b4e6d08b73f77680f12c16e8ae43250d55100e0b2be46d78da16a48" +checksum = "44f6f1124d6e19ab6daf7f2e615644305dc6cb2d706892a8a8c0b98db35de020" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1405,9 +1405,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.52.0" +version = "1.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ff4c717bf02350576b1542d7534edda68b95299b72700424978afd125b0b507" +checksum = "e349416a1998fde638deed85c18efeefd81af293439c16d676b7fce992904389" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1427,9 +1427,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.51.0" +version = "1.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74995133da38f109a0eb8e8c886f9e80c713b6e9f2e6e5a6a1ba4450ce2ffc46" +checksum = "cb25f7129c74d36afe33405af4517524df8f74b635af8c2c8e91c1552b8397b2" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1449,9 +1449,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.52.0" +version = "1.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7062a779685cbf3b2401eb36151e2c6589fd5f3569b8a6bc2d199e5aaa1d059" +checksum = "d03a3d5ef14851625eafd89660a751776f938bf32f309308b20dcca41c44b568" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1471,9 +1471,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.52.0" +version = "1.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299dae7b1dc0ee50434453fa5a229dc4b22bd3ee50409ff16becf1f7346e0193" +checksum = "cf3a9f073ae3a53b54421503063dfb87ff1ea83b876f567d92e8b8d9942ba91b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1517,9 +1517,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aa8ff1492fd9fb99ae28e8467af0dbbb7c31512b16fabf1a0f10d7bb6ef78bb" +checksum = "427cb637d15d63d6f9aae26358e1c9a9c09d5aa490d64b09354c8217cfef0f28" dependencies = [ "futures-util", "pin-project-lite", @@ -1567,9 +1567,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.5" +version = "1.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "431a10d0e07e09091284ef04453dae4069283aa108d209974d67e77ae1caa658" +checksum = "a05dd41a70fc74051758ee75b5c4db2c0ca070ed9229c3df50e9475cda1cb985" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1611,9 +1611,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.10" +version = "1.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecbf4d5dfb169812e2b240a4350f15ad3c6b03a54074e5712818801615f2dc5" +checksum = "38ddc9bd6c28aeb303477170ddd183760a956a03e083b3902a990238a7e3792d" dependencies = [ "base64-simd", "bytes", @@ -1841,9 +1841,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.3.0" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f265cdb2e8501f1c952749e78babe8f1937be92c98120e5f78fc72d634682bad" +checksum = "fe7acc34ff59877422326db7d6f2d845a582b16396b6b08194942bf34c6528ab" dependencies = [ "bon-macros", "rustversion", @@ -1851,9 +1851,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.3.0" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38aa5c627cd7706490e5b003d685f8b9d69bc343b1a00b9fdd01e75fdf6827cf" +checksum = "4159dd617a7fbc9be6a692fe69dc2954f8e6bb6bb5e4d7578467441390d77fd0" dependencies = [ "darling", "ident_case", @@ -1861,7 +1861,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2078,9 +2078,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.5" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" +checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" dependencies = [ "shlex", ] @@ -2244,7 +2244,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2659,7 +2659,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2670,7 +2670,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2743,7 +2743,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2764,7 +2764,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2774,7 +2774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2795,7 +2795,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "unicode-xid", ] @@ -2909,7 +2909,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -2934,7 +2934,7 @@ checksum = "8dc51d98e636f5e3b0759a39257458b22619cac7e96d932da6eeb052891bb67c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3061,7 +3061,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -3196,7 +3196,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.90", + "syn 2.0.93", "toml 0.8.19", "walkdir", ] @@ -3224,7 +3224,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.90", + "syn 2.0.93", "tempfile", "thiserror 1.0.69", "tiny-keccak", @@ -3628,7 +3628,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4210,7 +4210,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4370,7 +4370,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -4530,9 +4530,9 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691142b1a34d18e8ed6e6114bc1a2736516c5ad60ef3aa9bd1b694886e3ca92d" +checksum = "c57c477b645ee248b173bb1176b52dd528872f12c50375801a58aaf5ae91113f" dependencies = [ "bstr", "itoa", @@ -4705,9 +4705,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "globset" @@ -4904,7 +4904,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5263,7 +5263,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5363,7 +5363,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5481,7 +5481,7 @@ dependencies = [ "pretty_assertions", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -5557,11 +5557,12 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db69f08d4fb10524cacdb074c10b296299d71274ddbc830a8ee65666867002e9" +checksum = "24a46169c7a10358cdccfb179910e8a5a392fc291bdb409da9aeece5b19786d8" dependencies = [ "jiff-tzdb-platform", + "serde", "windows-sys 0.59.0", ] @@ -5959,7 +5960,7 @@ checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6049,7 +6050,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6323,7 +6324,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6343,9 +6344,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nybbles" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f06be0417d97f81fe4e5c86d7d01b392655a9cac9c19a848aa033e18937b23" +checksum = "55a62e678a89501192cc5ebf47dcbc656b608ae5e1c61c9251fe35230f119fe3" dependencies = [ "alloy-rlp", "const-hex", @@ -6463,7 +6464,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6626,7 +6627,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6685,7 +6686,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6769,7 +6770,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6827,7 +6828,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -6928,7 +6929,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -7006,7 +7007,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -7026,7 +7027,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "version_check", "yansi", ] @@ -7090,7 +7091,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -7113,7 +7114,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -7256,9 +7257,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -7438,9 +7439,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "7fe060fe50f524be480214aba758c71f99f90ee8c83c5a36b5e9e1d568eb4eb3" dependencies = [ "async-compression", "base64 0.22.1", @@ -7478,6 +7479,7 @@ dependencies = [ "tokio-rustls 0.26.1", "tokio-socks", "tokio-util", + "tower 0.5.2", "tower-service", "url", "wasm-bindgen", @@ -7853,9 +7855,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "rusty-fork" @@ -7946,14 +7948,14 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] name = "scc" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b13f8ea6177672c49d12ed964cca44836f59621981b04a3e26b87e675181de" +checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640" dependencies = [ "sdd", ] @@ -7988,7 +7990,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8159,22 +8161,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8185,7 +8187,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8229,7 +8231,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8275,7 +8277,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8583,7 +8585,7 @@ checksum = "f0cc54b74e214647c1bbfc098d080cc5deac77f8dcb99aca91747276b01a15ad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8747,7 +8749,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8815,9 +8817,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058" dependencies = [ "proc-macro2", "quote", @@ -8833,7 +8835,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8853,7 +8855,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8963,7 +8965,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -8974,7 +8976,7 @@ checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -9109,7 +9111,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -9383,7 +9385,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -9437,9 +9439,9 @@ dependencies = [ [[package]] name = "tracing-tracy" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc775fdaf33c3dfd19dc354729e65e87914bc67dcdc390ca1210807b8bee5902" +checksum = "0eaa1852afa96e0fe9e44caa53dc0bd2d9d05e0f2611ce09f97f8677af56e4ba" dependencies = [ "tracing-core", "tracing-subscriber", @@ -9448,9 +9450,9 @@ dependencies = [ [[package]] name = "tracy-client" -version = "0.17.6" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73202d787346a5418f8222eddb5a00f29ea47caf3c7d38a8f2f69f8455fa7c7e" +checksum = "d90a2c01305b02b76fdd89ac8608bae27e173c829a35f7d76a345ab5d33836db" dependencies = [ "loom", "once_cell", @@ -9554,9 +9556,9 @@ dependencies = [ [[package]] name = "unicase" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-bom" @@ -9798,7 +9800,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "wasm-bindgen-shared", ] @@ -9833,7 +9835,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -10074,7 +10076,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -10085,7 +10087,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -10096,7 +10098,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -10107,7 +10109,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -10387,7 +10389,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "synstructure", ] @@ -10409,7 +10411,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -10429,7 +10431,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", "synstructure", ] @@ -10450,7 +10452,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] @@ -10472,7 +10474,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.93", ] [[package]] From ffaa68fe083b945a12fc874b722079dda2c209da Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 29 Dec 2024 12:36:29 +0100 Subject: [PATCH 1813/1963] chore: make clippy happy (#9601) * chore: make clippy happy * allow literals tring with formatting args global --- Cargo.toml | 2 ++ crates/anvil/src/config.rs | 2 +- crates/anvil/src/eth/backend/db.rs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b6f4fef690d59..01a6eaa7de567 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,8 @@ uninlined-format-args = "warn" use-self = "warn" redundant-clone = "warn" octal-escapes = "allow" +# until is fixed +literal-string-with-formatting-args = "allow" [workspace.lints.rust] rust-2018-idioms = "warn" diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 9e22adeed1691..7ed1432fdcd60 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -800,7 +800,7 @@ impl NodeConfig { /// Sets the `fork_chain_id` to use to fork off local cache from #[must_use] pub fn with_fork_chain_id(mut self, fork_chain_id: Option) -> Self { - self.fork_chain_id = fork_chain_id.map(Into::into); + self.fork_chain_id = fork_chain_id; self } diff --git a/crates/anvil/src/eth/backend/db.rs b/crates/anvil/src/eth/backend/db.rs index db34d9c1995e9..55159f4d3460c 100644 --- a/crates/anvil/src/eth/backend/db.rs +++ b/crates/anvil/src/eth/backend/db.rs @@ -482,7 +482,7 @@ impl From for SerializableBlock { Self { header: block.header, transactions: block.transactions.into_iter().map(Into::into).collect(), - ommers: block.ommers.into_iter().map(Into::into).collect(), + ommers: block.ommers.into_iter().collect(), } } } @@ -492,7 +492,7 @@ impl From for Block { Self { header: block.header, transactions: block.transactions.into_iter().map(Into::into).collect(), - ommers: block.ommers.into_iter().map(Into::into).collect(), + ommers: block.ommers.into_iter().collect(), } } } From 4f22a38bd3b32c4017bcef4619b7833613dadc1d Mon Sep 17 00:00:00 2001 From: Delweng Date: Mon, 30 Dec 2024 17:06:29 +0800 Subject: [PATCH 1814/1963] chore(fmt): tx fields indent with the same whitespaces (#9603) chore(fmt): follow the same indent rules of other fields Signed-off-by: jsvisa --- crates/common/fmt/src/ui.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 0798967c6a0a0..af1bdd5df9082 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -507,8 +507,8 @@ impl UIfmt for AnyTxEnvelope { Self::Unknown(tx) => { format!( " -hash {} -type {} +hash {} +type {} {} ", tx.hash.pretty(), From e618b2c202ca442144c3d15591bffaf0bb52bbb6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:04:16 +0200 Subject: [PATCH 1815/1963] chore: fix flaky inline config test (#9591) --- crates/forge/tests/cli/inline_config.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/forge/tests/cli/inline_config.rs b/crates/forge/tests/cli/inline_config.rs index 5e02731952833..4e05d4b6002d7 100644 --- a/crates/forge/tests/cli/inline_config.rs +++ b/crates/forge/tests/cli/inline_config.rs @@ -254,14 +254,14 @@ forgetest_init!(evm_version, |prj, cmd| { ) .unwrap(); - cmd.arg("test").arg("--evm-version=cancun").assert_success().stdout_eq(str![[r#" + cmd.args(["test", "--evm-version=cancun", "-j1"]).assert_success().stdout_eq(str![[r#" ... -Ran 2 tests for test/inline.sol:FunctionConfig +Ran 2 tests for test/inline.sol:ContractConfig [PASS] test_new() ([GAS]) [PASS] test_old() ([GAS]) Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] -Ran 2 tests for test/inline.sol:ContractConfig +Ran 2 tests for test/inline.sol:FunctionConfig [PASS] test_new() ([GAS]) [PASS] test_old() ([GAS]) Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] From 68aff728b88bc5677aa11484ac998e13df63bd65 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 30 Dec 2024 16:44:51 +0100 Subject: [PATCH 1816/1963] feat: update revm 19 alloy 09 (#9605) * feat: update revm 19 alloy 09 * clippy * updata test * add back max data gas check --- Cargo.lock | 164 ++++++++++--------- Cargo.toml | 58 +++---- crates/anvil/core/src/eth/block.rs | 5 - crates/anvil/core/src/eth/transaction/mod.rs | 9 +- crates/anvil/src/config.rs | 7 +- crates/anvil/src/eth/api.rs | 2 +- crates/anvil/src/eth/backend/executor.rs | 6 +- crates/anvil/src/eth/backend/mem/mod.rs | 20 +-- crates/anvil/src/eth/backend/mem/storage.rs | 7 +- crates/anvil/src/eth/error.rs | 7 +- crates/anvil/src/eth/fees.rs | 11 +- crates/anvil/src/eth/otterscan/api.rs | 2 +- crates/anvil/tests/it/eip4844.rs | 6 +- crates/anvil/tests/it/eip7702.rs | 4 +- crates/anvil/tests/it/fork.rs | 4 +- crates/cast/bin/cmd/wallet/mod.rs | 4 +- crates/cast/bin/tx.rs | 9 +- crates/cast/tests/cli/main.rs | 1 - crates/cheatcodes/src/evm.rs | 5 +- crates/cheatcodes/src/script.rs | 8 +- crates/common/fmt/src/ui.rs | 6 +- crates/evm/core/src/backend/mod.rs | 3 +- crates/evm/evm/src/executors/mod.rs | 4 +- crates/script/src/broadcast.rs | 4 +- crates/script/src/receipts.rs | 2 +- 25 files changed, 181 insertions(+), 177 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ff45031d5f11..29742a2a1a8dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88e1edea70787c33e11197d3f32ae380f3db19e6e061e539a5bcf8184a6b326" +checksum = "db66918860ff33920fb9e6d648d1e8cee275321406ea255ac9320f6562e26fec" dependencies = [ "alloy-eips", "alloy-primitives", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b1bb53f40c0273cd1975573cd457b39213e68584e36d1401d25fd0398a1d65" +checksum = "04519b5157de8a2166bddb07d84a63590100f1d3e2b3682144e787f1c27ccdac" dependencies = [ "alloy-consensus", "alloy-eips", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b668c78c4b1f12f474ede5a85e8ce550d0aa1ef7d49fd1d22855a43b960e725" +checksum = "8ff00ab4dd371f53e648d65bd5af01057bdad8aaae8b3cd7cee75445575995c1" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c986539255fb839d1533c128e190e557e52ff652c9ef62939e233a81dd93f7e" +checksum = "cabf647eb4650c91a9d38cb6f972bb320009e7e9d61765fb688a86f1563b33e8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9fadfe089e9ccc0650473f2d4ef0a28bc015bbca5631d9f0f09e49b557fdb3" +checksum = "e56518f46b074d562ac345238343e2231b672a13aca18142d285f95cc055980b" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -206,10 +206,11 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2a4cf7b70f3495788e74ce1c765260ffe38820a2a774ff4aacb62e31ea73f9" +checksum = "2cf200fd4c28435995e47b26d4761a4cf6e1011a13b81f9a9afaf16a93d9fd09" dependencies = [ + "alloy-eips", "alloy-primitives", "alloy-serde", "alloy-trie", @@ -230,9 +231,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e29040b9d5fe2fb70415531882685b64f8efd08dfbd6cc907120650504821105" +checksum = "b17c5ada5faf0f9d2921e8b20971eced68abbc92a272b0502cac8b1d00f56777" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -244,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510cc00b318db0dfccfdd2d032411cfae64fc144aef9679409e014145d3dacc4" +checksum = "24f3117647e3262f6db9e18b371bf67c5810270c0cf915786c30fad3b1739561" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -269,9 +270,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9081c099e798b8a2bba2145eb82a9a146f01fc7a35e9ab6e7b43305051f97550" +checksum = "1535a4577648ec2fd3c446d4644d9b8e9e01e5816be53a5d515dc1624e2227b2" dependencies = [ "alloy-consensus", "alloy-eips", @@ -282,9 +283,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef9849fb8bbb28f69f2cbdb4b0dac2f0e35c04f6078a00dfb8486469aed02de" +checksum = "bf741e871fb62c80e0007041e8bc1e81978abfd98aafea8354472f06bfd4d309" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -331,9 +332,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc2dfaddd9a30aa870a78a4e1316e3e115ec1e12e552cbc881310456b85c1f24" +checksum = "fcfa2db03d4221b5ca14bff7dbed4712689cb87a3e826af522468783ff05ec5d" dependencies = [ "alloy-chains", "alloy-consensus", @@ -374,9 +375,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "695809e743628d54510c294ad17a4645bd9f465aeb0d20ee9ce9877c9712dc9c" +checksum = "4eace70e43b073d4bfc1de915c45993a50facd6526fd8da80204e0f83a9e233a" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -415,9 +416,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531137b283547d5b9a5cafc96b006c64ef76810c681d606f28be9781955293b6" +checksum = "d2ec6963b08f1c6ef8eacc01dbba20f2c6a1533550403f6b52dbbe0da0360834" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -441,9 +442,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3410a472ce26c457e9780f708ee6bd540b30f88f1f31fdab7a11d00bd6aa1aee" +checksum = "138ef78340b47f16ca4d04a4d75fe2ccdb3f1a4f748d5f3b2fbebc43581fd02e" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -457,9 +458,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed06bd8a5fc57b352a6cbac24eec52a4760f08ae2c1eb56ac49c8ed4b02c351" +checksum = "efbe94a1fcd071f19b313e4506d1affee0bd0b4a1cfbfd18a2541fda8e5487cf" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -469,9 +470,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed98e1af55a7d856bfa385f30f63d8d56be2513593655c904a8f4a7ec963aa3e" +checksum = "c64a83112b09bd293ef522bfa3800fa2d2df4d72f2bcd3a84b08490503b22e55" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -480,9 +481,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1dec1c1b65614ebd5834a7dfddf525a186962082023718e10f4f64ed2d02514" +checksum = "3cb36f68cc0c83120ecfbf0b1862b35f846da8e0cb95be3d10a3a08bfa711248" dependencies = [ "alloy-primitives", "serde", @@ -490,9 +491,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03bd16fa4959255ebf4a7702df08f325e5631df5cdca07c8a8e58bdc10fe02e3" +checksum = "2c9d87e5622ed4d471f1eefb99a400cd7e362a1889baa9bb4417742260ca43a8" dependencies = [ "alloy-consensus", "alloy-eips", @@ -508,9 +509,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8737d7a6e37ca7bba9c23e9495c6534caec6760eb24abc9d5ffbaaba147818e1" +checksum = "5fc1892a1ac0d2a49c063f0791aa6bde342f020c5d37aaaec14832b661802cb4" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -520,17 +521,17 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", - "derive_more", "itertools 0.13.0", "serde", "serde_json", + "thiserror 2.0.9", ] [[package]] name = "alloy-rpc-types-trace" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db14a83665cd28ffd01939f04c2adf0e0fd9bb648b73ca651dcaa0869dae027f" +checksum = "b25a5e0a7ae0127f20077b23319c8d4a416187c204bf3329ab28a0309ed45535" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -542,9 +543,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a574e97dff62097d22d6cd360f898f3d069239ca0ca7bfc2e5e7b22815ec572" +checksum = "64952ac1199868bcd05b3aae2d5e988e6bd171e42ae71580abe6718263061b27" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -554,9 +555,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5851bf8d5ad33014bd0c45153c603303e730acc8a209450a7ae6b4a12c2789e2" +checksum = "17939f6bef49268e4494158fce1ab8913cd6164ec3f9a4ada2c677b9b5a77f2f" dependencies = [ "alloy-primitives", "serde", @@ -565,9 +566,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e10ca565da6500cca015ba35ee424d59798f2e1b85bc0dd8f81dafd401f029a" +checksum = "77d1f0762a44338f0e05987103bd5919df52170d949080bfebfeb6aaaa867c39" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -581,9 +582,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e774d4203ad7dbeba06876c8528a169b7cb56770bd900bc061e6a2c2756a736" +checksum = "63cf9487165bcf15e15f033529ca8b8c63a26e5f9b435fbd239f786391ca2cb3" dependencies = [ "alloy-consensus", "alloy-network", @@ -599,9 +600,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9843facd50077d2010ac0ef9e9176f8a06f2e2c8e653d83d82859803c623c6fc" +checksum = "2a9f720296bf196732ecc6717aae33a4192c430b779b709557073329ae7ebeb4" dependencies = [ "alloy-consensus", "alloy-network", @@ -617,9 +618,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08367716d2eee6f15f0f7ee2e855decbfedd12be12fe5f490a2d2717deda95bf" +checksum = "3eaa7c88f704957cd9a8021be4d9e1d12da2cea55b8ce0551224805520ab0720" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -637,9 +638,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47fababf5a745133490cde927d48e50267f97d3d1209b9fc9f1d1d666964d172" +checksum = "59dd2f16055f532f83a8f8e3c13cf1e3b5ff78afdef82edb613946156e542272" dependencies = [ "alloy-consensus", "alloy-network", @@ -656,9 +657,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfbd920ad5dc03e1904827d30fd2ed874968c33885e254b2c2f59503b33e4bb8" +checksum = "9bd52d50f219e5160799cc569c1a7efd20d4d92cc2c2352a59874f71f02d642c" dependencies = [ "alloy-consensus", "alloy-network", @@ -746,9 +747,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "538a04a37221469cac0ce231b737fd174de2fdfcdd843bdd068cb39ed3e066ad" +checksum = "3a3827275a4eed3431ce876a59c76fd19effc2a8c09566b2603e3a3376d38af0" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -766,9 +767,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ed40eb1e1265b2911512f6aa1dcece9702d078f5a646730c45e39e2be00ac1c" +checksum = "958417ddf333c55b0627cb7fbee7c6666895061dee79f50404dd6dbdd8e9eba0" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -781,9 +782,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a172a59d24706b26a79a837f86d51745cb26ca6f8524712acd0208a14cff95" +checksum = "168abcf4337c3fbc0bf9030e62bbaca8b9a0fddf687ecc6585e2e6515dde8b0d" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -802,9 +803,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba0e39d181d13c266dbb8ca54ed584a2c66d6e9279afca89c7a6b1825e98abb" +checksum = "fcaf327f8d3e938272c2eace672094d3800e069e3f34137358e563faaa314f8a" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -4171,9 +4172,9 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "491e9f9f138086b3627a8c406730dfbb6afcdcf688e6da0eb15df52f0c8ed163" +checksum = "89a794c8a78ba20568a0c86b035768da7e81fed3c51cecea57f81523123cbcfa" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -6372,9 +6373,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c698f80ee53e56d1b60a97e9d90ad09788b516c964c9c97fb5927860b812ef0d" +checksum = "0adb232ec805af3aa35606c19329aa7dc44c4457ae318ed0b8fc7f799dd7dbfe" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6388,9 +6389,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aef2128fe8979596b3a1f79a2454f3e32fd239889a03d50fe686b9a2f30a16" +checksum = "e68d1a51fe3ee143f102b82f54fa237f21d12635da363276901e6d3ef6c65b7b" dependencies = [ "alloy-consensus", "alloy-eips", @@ -7492,13 +7493,14 @@ dependencies = [ [[package]] name = "revm" -version = "18.0.0" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15689a3c6a8d14b647b4666f2e236ef47b5a5133cdfd423f545947986fff7013" +checksum = "e8905d0c5f10e767f13ea7cb8e502d315f144071a60fe2bd83977922dd3afa26" dependencies = [ "auto_impl", "cfg-if", "dyn-clone", + "once_cell", "revm-interpreter", "revm-precompile", "serde", @@ -7507,9 +7509,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.13.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d056aaa21f36038ab35fe8ce940ee332903a0b4b992b8ca805fb60c85eb2086" +checksum = "dc873bc873e12a1723493e1a35804fa79b673a0bfb1c19cfee659d46def8be42" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -7525,9 +7527,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "14.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e3f11d0fed049a4a10f79820c59113a79b38aed4ebec786a79d5c667bfeb51" +checksum = "e5ff76b50b5a9fa861fbc236fc82ce1afdf58861f65012aea807d679e54630d6" dependencies = [ "revm-primitives", "serde", @@ -7535,9 +7537,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "15.0.0" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e381060af24b750069a2b2d2c54bba273d84e8f5f9e8026fc9262298e26cc336" +checksum = "6542fb37650dfdbf4b9186769e49c4a8bc1901a3280b2ebf32f915b6c8850f36" dependencies = [ "aurora-engine-modexp", "blst", @@ -7555,9 +7557,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "14.0.0" +version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3702f132bb484f4f0d0ca4f6fbde3c82cfd745041abbedd6eda67730e1868ef0" +checksum = "48faea1ecf2c9f80d9b043bbde0db9da616431faed84c4cfa3dd7393005598e6" dependencies = [ "alloy-eip2930", "alloy-eip7702", diff --git a/Cargo.toml b/Cargo.toml index 01a6eaa7de567..d4ccda8e5564f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,43 +172,43 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } foundry-compilers = { version = "0.12.8", default-features = false } -foundry-fork-db = "0.9.0" +foundry-fork-db = "0.10.0" solang-parser = "=0.3.3" solar-ast = { version = "=0.1.0", default-features = false } solar-parse = { version = "=0.1.0", default-features = false } ## revm -revm = { version = "18.0.0", default-features = false } -revm-primitives = { version = "14.0.0", default-features = false } -revm-inspectors = { version = "0.13.0", features = ["serde"] } +revm = { version = "19.0.0", default-features = false } +revm-primitives = { version = "15.1.0", default-features = false } +revm-inspectors = { version = "0.14.1", features = ["serde"] } ## ethers ethers-contract-abigen = { version = "2.0.14", default-features = false } ## alloy -alloy-consensus = { version = "0.8.0", default-features = false } -alloy-contract = { version = "0.8.0", default-features = false } -alloy-eips = { version = "0.8.0", default-features = false } -alloy-genesis = { version = "0.8.0", default-features = false } -alloy-json-rpc = { version = "0.8.0", default-features = false } -alloy-network = { version = "0.8.0", default-features = false } -alloy-provider = { version = "0.8.0", default-features = false } -alloy-pubsub = { version = "0.8.0", default-features = false } -alloy-rpc-client = { version = "0.8.0", default-features = false } -alloy-rpc-types = { version = "0.8.0", default-features = true } -alloy-serde = { version = "0.8.0", default-features = false } -alloy-signer = { version = "0.8.0", default-features = false } -alloy-signer-aws = { version = "0.8.0", default-features = false } -alloy-signer-gcp = { version = "0.8.0", default-features = false } -alloy-signer-ledger = { version = "0.8.0", default-features = false } -alloy-signer-local = { version = "0.8.0", default-features = false } -alloy-signer-trezor = { version = "0.8.0", default-features = false } -alloy-transport = { version = "0.8.0", default-features = false } -alloy-transport-http = { version = "0.8.0", default-features = false } -alloy-transport-ipc = { version = "0.8.0", default-features = false } -alloy-transport-ws = { version = "0.8.0", default-features = false } -alloy-node-bindings = { version = "0.8.0", default-features = false } -alloy-network-primitives = { version = "0.8.0", default-features = false } +alloy-consensus = { version = "0.9.0", default-features = false } +alloy-contract = { version = "0.9.0", default-features = false } +alloy-eips = { version = "0.9.0", default-features = false } +alloy-genesis = { version = "0.9.0", default-features = false } +alloy-json-rpc = { version = "0.9.0", default-features = false } +alloy-network = { version = "0.9.0", default-features = false } +alloy-provider = { version = "0.9.0", default-features = false } +alloy-pubsub = { version = "0.9.0", default-features = false } +alloy-rpc-client = { version = "0.9.0", default-features = false } +alloy-rpc-types = { version = "0.9.0", default-features = true } +alloy-serde = { version = "0.9.0", default-features = false } +alloy-signer = { version = "0.9.0", default-features = false } +alloy-signer-aws = { version = "0.9.0", default-features = false } +alloy-signer-gcp = { version = "0.9.0", default-features = false } +alloy-signer-ledger = { version = "0.9.0", default-features = false } +alloy-signer-local = { version = "0.9.0", default-features = false } +alloy-signer-trezor = { version = "0.9.0", default-features = false } +alloy-transport = { version = "0.9.0", default-features = false } +alloy-transport-http = { version = "0.9.0", default-features = false } +alloy-transport-ipc = { version = "0.9.0", default-features = false } +alloy-transport-ws = { version = "0.9.0", default-features = false } +alloy-node-bindings = { version = "0.9.0", default-features = false } +alloy-network-primitives = { version = "0.9.0", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.14" @@ -228,8 +228,8 @@ alloy-rlp = "0.3" alloy-trie = "0.7.0" ## op-alloy -op-alloy-rpc-types = "0.8.0" -op-alloy-consensus = "0.8.0" +op-alloy-rpc-types = "0.9.0" +op-alloy-consensus = "0.9.0" ## cli anstream = "0.6" diff --git a/crates/anvil/core/src/eth/block.rs b/crates/anvil/core/src/eth/block.rs index 50a9a66b331fc..c9f9048b81998 100644 --- a/crates/anvil/core/src/eth/block.rs +++ b/crates/anvil/core/src/eth/block.rs @@ -65,7 +65,6 @@ impl Block { nonce: partial_header.nonce, base_fee_per_gas: partial_header.base_fee, requests_hash: partial_header.requests_hash, - target_blobs_per_block: None, }, transactions, ommers: vec![], @@ -158,7 +157,6 @@ mod tests { parent_beacon_block_root: Default::default(), base_fee_per_gas: None, requests_hash: None, - target_blobs_per_block: None, }; let encoded = alloy_rlp::encode(&header); @@ -200,7 +198,6 @@ mod tests { nonce: B64::ZERO, base_fee_per_gas: None, requests_hash: None, - target_blobs_per_block: None, }; header.encode(&mut data); @@ -234,7 +231,6 @@ mod tests { parent_beacon_block_root: None, base_fee_per_gas: None, requests_hash: None, - target_blobs_per_block: None, }; let header = Header::decode(&mut data.as_slice()).unwrap(); assert_eq!(header, expected); @@ -267,7 +263,6 @@ mod tests { excess_blob_gas: None, parent_beacon_block_root: None, requests_hash: None, - target_blobs_per_block: None, }; assert_eq!(header.hash_slow(), expected_hash); } diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 29b8aee88d3c0..38eda60405d41 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -619,7 +619,6 @@ impl TryFrom for TypedTransaction { TxEnvelope::Eip1559(tx) => Ok(Self::EIP1559(tx)), TxEnvelope::Eip4844(tx) => Ok(Self::EIP4844(tx)), TxEnvelope::Eip7702(tx) => Ok(Self::EIP7702(tx)), - _ => Err(ConversionError::Custom("UnsupportedTxType".to_string())), }, AnyTxEnvelope::Unknown(mut tx) => { // Try to convert to deposit transaction @@ -1260,7 +1259,7 @@ impl From>> for OtsReceipt { } as u8; let receipt = ReceiptWithBloom::>::from(value); let status = receipt.status(); - let cumulative_gas_used = receipt.cumulative_gas_used() as u64; + let cumulative_gas_used = receipt.cumulative_gas_used(); let logs = receipt.logs().to_vec(); let logs_bloom = receipt.logs_bloom; @@ -1269,7 +1268,7 @@ impl From>> for OtsReceipt { } impl TypedReceipt { - pub fn cumulative_gas_used(&self) -> u128 { + pub fn cumulative_gas_used(&self) -> u64 { self.as_receipt_with_bloom().cumulative_gas_used() } @@ -1653,7 +1652,7 @@ mod tests { let receipt = TypedReceipt::Legacy(ReceiptWithBloom { receipt: Receipt { status: false.into(), - cumulative_gas_used: 0x1u128, + cumulative_gas_used: 0x1, logs: vec![Log { address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), data: LogData::new_unchecked( @@ -1688,7 +1687,7 @@ mod tests { let expected = TypedReceipt::Legacy(ReceiptWithBloom { receipt: Receipt { status: false.into(), - cumulative_gas_used: 0x1u128, + cumulative_gas_used: 0x1, logs: vec![Log { address: Address::from_str("0000000000000000000000000000000000000011").unwrap(), data: LogData::new_unchecked( diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 7ed1432fdcd60..247586bfdcc3a 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -498,10 +498,10 @@ impl NodeConfig { blob_excess_gas_and_price.clone() } else if let Some(excess_blob_gas) = self.genesis.as_ref().and_then(|g| g.excess_blob_gas) { - BlobExcessGasAndPrice::new(excess_blob_gas as u64) + BlobExcessGasAndPrice::new(excess_blob_gas, false) } else { // If no excess blob gas is configured, default to 0 - BlobExcessGasAndPrice::new(0) + BlobExcessGasAndPrice::new(0, false) } } @@ -1213,11 +1213,12 @@ latest block number: {latest_block}" (block.header.excess_blob_gas, block.header.blob_gas_used) { env.block.blob_excess_gas_and_price = - Some(BlobExcessGasAndPrice::new(blob_excess_gas)); + Some(BlobExcessGasAndPrice::new(blob_excess_gas, false)); let next_block_blob_excess_gas = fees .get_next_block_blob_excess_gas(blob_excess_gas as u128, blob_gas_used as u128); fees.set_blob_excess_gas_and_price(BlobExcessGasAndPrice::new( next_block_blob_excess_gas, + false, )); } } diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index daf9dc4a00f46..23aac74529134 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -2315,7 +2315,7 @@ impl EthApi { let to = tx.to(); let gas_price = tx.gas_price(); let value = tx.value(); - let gas = tx.gas_limit() as u128; + let gas = tx.gas_limit(); TxpoolInspectSummary { to, value, gas, gas_price } } diff --git a/crates/anvil/src/eth/backend/executor.rs b/crates/anvil/src/eth/backend/executor.rs index f4b20868f2950..c07bfab785e24 100644 --- a/crates/anvil/src/eth/backend/executor.rs +++ b/crates/anvil/src/eth/backend/executor.rs @@ -30,7 +30,7 @@ use foundry_evm::{ traces::CallTraceNode, utils::odyssey_handler_register, }; -use revm::{db::WrapDatabaseRef, primitives::MAX_BLOB_GAS_PER_BLOCK}; +use revm::db::WrapDatabaseRef; use std::sync::Arc; /// Represents an executed transaction (transacted on the DB) @@ -57,7 +57,7 @@ impl ExecutedTransaction { let status_code = u8::from(self.exit_reason as u8 <= InstructionResult::SelfDestruct as u8); let receipt_with_bloom: ReceiptWithBloom = Receipt { status: (status_code == 1).into(), - cumulative_gas_used: *cumulative_gas_used as u128, + cumulative_gas_used: *cumulative_gas_used, logs, } .into(); @@ -288,7 +288,7 @@ impl Iterator for &mut TransactionExec let max_blob_gas = self.blob_gas_used.saturating_add( transaction.pending_transaction.transaction.transaction.blob_gas().unwrap_or(0), ); - if max_blob_gas > MAX_BLOB_GAS_PER_BLOCK { + if max_blob_gas > alloy_eips::eip4844::MAX_DATA_GAS_PER_BLOCK { return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction)) } diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index dfd96c72391a5..154dae504e20f 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -97,9 +97,7 @@ use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; use parking_lot::{Mutex, RwLock}; use revm::{ db::WrapDatabaseRef, - primitives::{ - calc_blob_gasprice, BlobExcessGasAndPrice, HashMap, OptimismFields, ResultAndState, - }, + primitives::{BlobExcessGasAndPrice, HashMap, OptimismFields, ResultAndState}, }; use std::{ collections::BTreeMap, @@ -1289,8 +1287,10 @@ impl Backend { // update next base fee self.fees.set_base_fee(next_block_base_fee); - self.fees - .set_blob_excess_gas_and_price(BlobExcessGasAndPrice::new(next_block_excess_blob_gas)); + self.fees.set_blob_excess_gas_and_price(BlobExcessGasAndPrice::new( + next_block_excess_blob_gas, + false, + )); // notify all listeners self.notify_on_new_block(header, block_hash); @@ -2341,7 +2341,8 @@ impl Backend { // Cancun specific let excess_blob_gas = block.header.excess_blob_gas; - let blob_gas_price = calc_blob_gasprice(excess_blob_gas.unwrap_or_default()); + let blob_gas_price = + alloy_eips::eip4844::calc_blob_gasprice(excess_blob_gas.unwrap_or_default()); let blob_gas_used = transaction.blob_gas(); let effective_gas_price = match transaction.transaction { @@ -2409,14 +2410,14 @@ impl Backend { transaction_hash: info.transaction_hash, transaction_index: Some(info.transaction_index), block_number: Some(block.header.number), - gas_used: info.gas_used as u128, + gas_used: info.gas_used, contract_address: info.contract_address, effective_gas_price, block_hash: Some(block_hash), from: info.from, to: info.to, blob_gas_price: Some(blob_gas_price), - blob_gas_used: blob_gas_used.map(|g| g as u128), + blob_gas_used, authorization_list: None, }; @@ -2809,7 +2810,7 @@ impl TransactionValidator for Backend { // Ensure the tx does not exceed the max blobs per block. if blob_count > MAX_BLOBS_PER_BLOCK { - return Err(InvalidTransactionError::TooManyBlobs(MAX_BLOBS_PER_BLOCK, blob_count)) + return Err(InvalidTransactionError::TooManyBlobs(blob_count)) } // Check for any blob validation errors @@ -2984,7 +2985,6 @@ pub fn transaction_build( let new_signed = Signed::new_unchecked(t, sig, hash); AnyTxEnvelope::Ethereum(TxEnvelope::Eip7702(new_signed)) } - _ => unreachable!("unknown tx type"), }; let tx = Transaction { diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 5635a7accbd44..46429d4532b13 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -556,10 +556,7 @@ impl MinedTransaction { GethDebugBuiltInTracerType::CallTracer => { return match tracer_config.into_call_config() { Ok(call_config) => Ok(GethTraceBuilder::new(self.info.traces.clone()) - .geth_call_traces( - call_config, - self.receipt.cumulative_gas_used() as u64, - ) + .geth_call_traces(call_config, self.receipt.cumulative_gas_used()) .into()), Err(e) => Err(RpcError::invalid_params(e.to_string()).into()), }; @@ -578,7 +575,7 @@ impl MinedTransaction { // default structlog tracer Ok(GethTraceBuilder::new(self.info.traces.clone()) .geth_traces( - self.receipt.cumulative_gas_used() as u64, + self.receipt.cumulative_gas_used(), self.info.out.clone().unwrap_or_default(), config, ) diff --git a/crates/anvil/src/eth/error.rs b/crates/anvil/src/eth/error.rs index dda9b8bb26a9f..0c9723c40a65d 100644 --- a/crates/anvil/src/eth/error.rs +++ b/crates/anvil/src/eth/error.rs @@ -246,8 +246,8 @@ pub enum InvalidTransactionError { /// Thrown when there are no `blob_hashes` in the transaction, and it is an EIP-4844 tx. #[error("`blob_hashes` are required for EIP-4844 transactions")] NoBlobHashes, - #[error("too many blobs in one transaction, max: {0}, have: {1}")] - TooManyBlobs(usize, usize), + #[error("too many blobs in one transaction, have: {0}")] + TooManyBlobs(usize), /// Thrown when there's a blob validation error #[error(transparent)] BlobTransactionValidationError(#[from] alloy_consensus::BlobTransactionValidationError), @@ -297,7 +297,7 @@ impl From for InvalidTransactionError { InvalidTransaction::BlobCreateTransaction => Self::BlobCreateTransaction, InvalidTransaction::BlobVersionNotSupported => Self::BlobVersionNotSupported, InvalidTransaction::EmptyBlobs => Self::EmptyBlobs, - InvalidTransaction::TooManyBlobs { max, have } => Self::TooManyBlobs(max, have), + InvalidTransaction::TooManyBlobs { have } => Self::TooManyBlobs(have), InvalidTransaction::AuthorizationListNotSupported => { Self::AuthorizationListNotSupported } @@ -305,6 +305,7 @@ impl From for InvalidTransactionError { InvalidTransaction::OptimismError(_) | InvalidTransaction::EofCrateShouldHaveToAddress | InvalidTransaction::EmptyAuthorizationList => Self::Revm(err), + InvalidTransaction::GasFloorMoreThanGasLimit => Self::Revm(err), } } } diff --git a/crates/anvil/src/eth/fees.rs b/crates/anvil/src/eth/fees.rs index f41c51505ff62..bb405f62d1ef1 100644 --- a/crates/anvil/src/eth/fees.rs +++ b/crates/anvil/src/eth/fees.rs @@ -5,6 +5,7 @@ use crate::eth::{ use alloy_consensus::Header; use alloy_eips::{ calc_next_block_base_fee, eip1559::BaseFeeParams, eip4844::MAX_DATA_GAS_PER_BLOCK, + eip7840::BlobParams, }; use alloy_primitives::B256; use anvil_core::eth::transaction::TypedTransaction; @@ -172,7 +173,7 @@ impl FeeManager { /// Calculates the next block blob base fee, using the provided excess blob gas pub fn get_next_block_blob_base_fee_per_gas(&self, excess_blob_gas: u128) -> u128 { - crate::revm::primitives::calc_blob_gasprice(excess_blob_gas as u64) + alloy_eips::eip4844::calc_blob_gasprice(excess_blob_gas as u64) } /// Calculates the next block blob excess gas, using the provided parent blob gas used and @@ -182,7 +183,7 @@ impl FeeManager { blob_gas_used: u128, blob_excess_gas: u128, ) -> u64 { - crate::revm::primitives::calc_excess_blob_gas(blob_gas_used as u64, blob_excess_gas as u64) + alloy_eips::eip4844::calc_excess_blob_gas(blob_gas_used as u64, blob_excess_gas as u64) } } @@ -246,7 +247,7 @@ impl FeeHistoryService { let base_fee = header.base_fee_per_gas.map(|g| g as u128).unwrap_or_default(); let excess_blob_gas = header.excess_blob_gas.map(|g| g as u128); let blob_gas_used = header.blob_gas_used.map(|g| g as u128); - let base_fee_per_blob_gas = header.blob_fee(); + let base_fee_per_blob_gas = header.blob_fee(BlobParams::cancun()); let mut item = FeeHistoryCacheItem { base_fee, gas_used_ratio: 0f64, @@ -270,7 +271,7 @@ impl FeeHistoryService { blob_gas_used.map(|g| g / MAX_DATA_GAS_PER_BLOCK as f64).unwrap_or(0 as f64); // extract useful tx info (gas_used, effective_reward) - let mut transactions: Vec<(u128, u128)> = receipts + let mut transactions: Vec<(_, _)> = receipts .iter() .enumerate() .map(|(i, receipt)| { @@ -312,7 +313,7 @@ impl FeeHistoryService { item.rewards = reward_percentiles .into_iter() .filter_map(|p| { - let target_gas = (p * gas_used / 100f64) as u128; + let target_gas = (p * gas_used / 100f64) as u64; let mut sum_gas = 0; for (gas_used, effective_reward) in transactions.iter().cloned() { sum_gas += gas_used; diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index f9a7334e03765..703c53b53a8db 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -384,7 +384,7 @@ impl EthApi { let total_fees = receipts .iter() - .fold(0, |acc, receipt| acc + receipt.gas_used * receipt.effective_gas_price); + .fold(0, |acc, receipt| acc + (receipt.gas_used as u128) * receipt.effective_gas_price); let Block { header, uncles, transactions, withdrawals } = block.inner; diff --git a/crates/anvil/tests/it/eip4844.rs b/crates/anvil/tests/it/eip4844.rs index ea195f000b6d0..65bdba61163d2 100644 --- a/crates/anvil/tests/it/eip4844.rs +++ b/crates/anvil/tests/it/eip4844.rs @@ -78,7 +78,7 @@ async fn can_send_multiple_blobs_in_one_tx() { let receipt = provider.send_transaction(tx).await.unwrap().get_receipt().await.unwrap(); - assert_eq!(receipt.blob_gas_used, Some(MAX_DATA_GAS_PER_BLOCK as u128)); + assert_eq!(receipt.blob_gas_used, Some(MAX_DATA_GAS_PER_BLOCK)); assert_eq!(receipt.blob_gas_price, Some(0x1)); // 1 wei } @@ -250,7 +250,7 @@ async fn can_correctly_estimate_blob_gas_with_recommended_fillers() { assert_eq!(receipt.to, Some(bob)); assert_eq!( receipt.blob_gas_used.expect("Expected to be EIP-4844 transaction"), - DATA_GAS_PER_BLOB as u128 + DATA_GAS_PER_BLOB ); } @@ -296,6 +296,6 @@ async fn can_correctly_estimate_blob_gas_with_recommended_fillers_with_signer() assert_eq!(receipt.to, Some(bob)); assert_eq!( receipt.blob_gas_used.expect("Expected to be EIP-4844 transaction"), - DATA_GAS_PER_BLOB as u128 + DATA_GAS_PER_BLOB ); } diff --git a/crates/anvil/tests/it/eip7702.rs b/crates/anvil/tests/it/eip7702.rs index e10633d6c14d8..dfc93bfe08aa8 100644 --- a/crates/anvil/tests/it/eip7702.rs +++ b/crates/anvil/tests/it/eip7702.rs @@ -1,7 +1,7 @@ use crate::utils::http_provider; use alloy_consensus::{transaction::TxEip7702, SignableTransaction}; use alloy_network::{ReceiptResponse, TransactionBuilder, TxSignerSync}; -use alloy_primitives::bytes; +use alloy_primitives::{bytes, U256}; use alloy_provider::Provider; use alloy_rpc_types::{Authorization, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -44,7 +44,7 @@ async fn can_send_eip7702_tx() { let contract = receipt.contract_address.unwrap(); let authorization = Authorization { - chain_id: 31337u64, + chain_id: U256::from(31337u64), address: contract, nonce: provider.get_transaction_count(from).await.unwrap(), }; diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 8e7736b0df364..be91bbc126bff 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1503,7 +1503,9 @@ async fn test_fork_get_account() { assert_eq!( alice_acc.balance, - alice_bal - (U256::from(142) + U256::from(receipt.gas_used * receipt.effective_gas_price)), + alice_bal - + (U256::from(142) + + U256::from(receipt.gas_used as u128 * receipt.effective_gas_price)), ); assert_eq!(alice_acc.nonce, alice_nonce + 1); diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 7960cab6ea564..4234304f25bb4 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -1,6 +1,6 @@ use alloy_chains::Chain; use alloy_dyn_abi::TypedData; -use alloy_primitives::{hex, Address, PrimitiveSignature as Signature, B256}; +use alloy_primitives::{hex, Address, PrimitiveSignature as Signature, B256, U256}; use alloy_provider::Provider; use alloy_signer::Signer; use alloy_signer_local::{ @@ -380,7 +380,7 @@ impl WalletSubcommands { } else { provider.get_chain_id().await? }; - let auth = Authorization { chain_id, address, nonce }; + let auth = Authorization { chain_id: U256::from(chain_id), address, nonce }; let signature = wallet.sign_hash(&auth.signature_hash()).await?; let auth = auth.into_signed(signature); sh_println!("{}", hex::encode_prefixed(alloy_rlp::encode(&auth)))?; diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 29f8e2435186c..9cc98aedf4f93 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -3,7 +3,7 @@ use alloy_json_abi::Function; use alloy_network::{ AnyNetwork, TransactionBuilder, TransactionBuilder4844, TransactionBuilder7702, }; -use alloy_primitives::{hex, Address, Bytes, TxKind}; +use alloy_primitives::{hex, Address, Bytes, TxKind, U256}; use alloy_provider::Provider; use alloy_rpc_types::{AccessList, Authorization, TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; @@ -379,8 +379,11 @@ where let auth = match auth { CliAuthorizationList::Address(address) => { - let auth = - Authorization { chain_id: self.chain.id(), nonce: tx_nonce + 1, address }; + let auth = Authorization { + chain_id: U256::from(self.chain.id()), + nonce: tx_nonce + 1, + address, + }; let Some(signer) = sender.as_signer() else { eyre::bail!("No signer available to sign authorization"); diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index c87c5f7f26deb..f037cb166c47b 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -105,7 +105,6 @@ totalDifficulty [..] blobGasUsed [..] excessBlobGas [..] requestsHash [..] -targetBlobsPerBlock [..] transactions: [ ... ] diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 9f8eb27a489a3..f9d648bca6db9 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -485,7 +485,10 @@ impl Cheatcode for blobBaseFeeCall { "`blobBaseFee` is not supported before the Cancun hard fork; \ see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844" ); - ccx.ecx.env.block.set_blob_excess_gas_and_price((*newBlobBaseFee).to()); + ccx.ecx.env.block.set_blob_excess_gas_and_price( + (*newBlobBaseFee).to(), + ccx.ecx.spec_id() >= SpecId::PRAGUE, + ); Ok(Default::default()) } } diff --git a/crates/cheatcodes/src/script.rs b/crates/cheatcodes/src/script.rs index b28141ae002ec..0749d0d41ba48 100644 --- a/crates/cheatcodes/src/script.rs +++ b/crates/cheatcodes/src/script.rs @@ -40,7 +40,7 @@ impl Cheatcode for attachDelegationCall { let auth = Authorization { address: *implementation, nonce: *nonce, - chain_id: ccx.ecx.env.cfg.chain_id, + chain_id: U256::from(ccx.ecx.env.cfg.chain_id), }; let signed_auth = SignedAuthorization::new_unchecked( auth, @@ -87,7 +87,11 @@ fn create_auth( let authority_acc = ccx.ecx.journaled_state.load_account(authority, &mut ccx.ecx.db)?; let nonce = authority_acc.data.info.nonce; Ok(( - Authorization { address: implementation, nonce, chain_id: ccx.ecx.env.cfg.chain_id }, + Authorization { + address: implementation, + nonce, + chain_id: U256::from(ccx.ecx.env.cfg.chain_id), + }, nonce, )) } diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index af1bdd5df9082..bd3dbbd42987c 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -811,7 +811,6 @@ pub fn get_pretty_tx_attr(transaction: &Transaction, attr: &str) TxEnvelope::Eip4844(tx) => Some(tx.signature()), TxEnvelope::Eip7702(tx) => Some(tx.signature()), TxEnvelope::Legacy(tx) => Some(tx.signature()), - _ => None, }, _ => None, }; @@ -899,7 +898,6 @@ fn pretty_block_basics(block: &Block>) excess_blob_gas, parent_beacon_block_root, requests_hash, - target_blobs_per_block, }, }, uncles: _, @@ -931,8 +929,7 @@ withdrawalsRoot {} totalDifficulty {} blobGasUsed {} excessBlobGas {} -requestsHash {} -targetBlobsPerBlock {}", +requestsHash {}", base_fee_per_gas.pretty(), difficulty.pretty(), extra_data.pretty(), @@ -960,7 +957,6 @@ targetBlobsPerBlock {}", blob_gas_used.pretty(), excess_blob_gas.pretty(), requests_hash.pretty(), - target_blobs_per_block.pretty(), ) } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 3d162c96f46c6..12f39b1ee029a 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1921,7 +1921,8 @@ fn update_env_block(env: &mut Env, block: &AnyRpcBlock) { env.block.gas_limit = U256::from(block.header.gas_limit); env.block.number = U256::from(block.header.number); if let Some(excess_blob_gas) = block.header.excess_blob_gas { - env.block.blob_excess_gas_and_price = Some(BlobExcessGasAndPrice::new(excess_blob_gas)); + env.block.blob_excess_gas_and_price = + Some(BlobExcessGasAndPrice::new(excess_blob_gas, false)); } } diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index ada7cc7b0666f..187315d583c38 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -932,7 +932,7 @@ fn convert_executed_result( (reason.into(), 0_u64, gas_used, None, vec![]) } }; - let stipend = revm::interpreter::gas::validate_initial_tx_gas( + let gas = revm::interpreter::gas::calculate_initial_tx_gas( env.spec_id(), &env.tx.data, env.tx.transact_to.is_create(), @@ -964,7 +964,7 @@ fn convert_executed_result( result, gas_used, gas_refunded, - stipend, + stipend: gas.initial_gas, logs, labels, traces, diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 207754e5c9526..24368bc3d74c6 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -413,11 +413,11 @@ impl BundledState { let (total_gas, total_gas_price, total_paid) = sequence.receipts.iter().fold((0, 0, 0), |acc, receipt| { let gas_used = receipt.gas_used; - let gas_price = receipt.effective_gas_price; + let gas_price = receipt.effective_gas_price as u64; (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used * gas_price) }); let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); - let avg_gas_price = format_units(total_gas_price / sequence.receipts.len() as u128, 9) + let avg_gas_price = format_units(total_gas_price / sequence.receipts.len() as u64, 9) .unwrap_or_else(|_| "N/A".to_string()); seq_progress.inner.write().set_status(&format!( diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index cff893b55688b..ee1c7b46c8c31 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -106,7 +106,7 @@ pub fn format_receipt(chain: Chain, receipt: &AnyTransactionReceipt) -> String { gas = if gas_price == 0 { format!("Gas Used: {gas_used}") } else { - let paid = format_units(gas_used.saturating_mul(gas_price), 18) + let paid = format_units((gas_used as u128).saturating_mul(gas_price), 18) .unwrap_or_else(|_| "N/A".into()); let gas_price = format_units(U256::from(gas_price), 9).unwrap_or_else(|_| "N/A".into()); From 03ec595fb59f9c1eaf0f695f71c9771d8b106a0b Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 2 Jan 2025 01:58:30 +0100 Subject: [PATCH 1817/1963] chore(deps): bump alloys (#9613) --- Cargo.lock | 204 ++++++++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29742a2a1a8dd..9349acd2f1afc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db66918860ff33920fb9e6d648d1e8cee275321406ea255ac9320f6562e26fec" +checksum = "d802a6d579d924a2926d181bce43231aaab4699a7c206197e88fbc6b9dda846f" dependencies = [ "alloy-eips", "alloy-primitives", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04519b5157de8a2166bddb07d84a63590100f1d3e2b3682144e787f1c27ccdac" +checksum = "24b1bcb3e4810bff7e2a62ac0d741c70a7b5560e57b76eb0f0d33e1070735c60" dependencies = [ "alloy-consensus", "alloy-eips", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff00ab4dd371f53e648d65bd5af01057bdad8aaae8b3cd7cee75445575995c1" +checksum = "8e56bc4dc06ab205dc4106348c44b92e0d979148f8db751994c11caabf5ebbef" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41056bde53ae10ffbbf11618efbe1e0290859e5eab0fe9ef82ebdb62f12a866f" +checksum = "b0d2ea4d7f220a19c1f8c98822026d1d26a4b75a72e1a7308d02bab1f77c9a00" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e56518f46b074d562ac345238343e2231b672a13aca18142d285f95cc055980b" +checksum = "938bc1cf2ec42579e187834efc254e76dd3fa19f526b57872713e6b95f411305" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -206,9 +206,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cf200fd4c28435995e47b26d4761a4cf6e1011a13b81f9a9afaf16a93d9fd09" +checksum = "b648eac186485ead3da160985b929e610a45eb39903f750da9b35f58a91eef52" dependencies = [ "alloy-eips", "alloy-primitives", @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c357da577dfb56998d01f574d81ad7a1958d248740a7981b205d69d65a7da404" +checksum = "e79c6b4bcc1067a7394b5b2aec7da1bd829c8c476b796c73eb14da34392a07a7" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17c5ada5faf0f9d2921e8b20971eced68abbc92a272b0502cac8b1d00f56777" +checksum = "a1a38b4b49667a84ecad7cdaf431b8bd3f14ca496e5a021df1c26d5c4595dca6" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f3117647e3262f6db9e18b371bf67c5810270c0cf915786c30fad3b1739561" +checksum = "4fb5dc326960e88eec6b5e9add221a071f15cb8fa93b9e88ee9c76cd0e4e1009" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1535a4577648ec2fd3c446d4644d9b8e9e01e5816be53a5d515dc1624e2227b2" +checksum = "1535c89ae0648f2c15c0bf9b8b92670f6b3b8515b645425c8b46462563c0eae4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf741e871fb62c80e0007041e8bc1e81978abfd98aafea8354472f06bfd4d309" +checksum = "5af000a8d9aa22694c92a5c6ebd9113495d2eb78fb3579d02a715569b973cc26" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -300,9 +300,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6259a506ab13e1d658796c31e6e39d2e2ee89243bcc505ddc613b35732e0a430" +checksum = "0540fd0355d400b59633c27bd4b42173e59943f28e9d3376b77a24771d432d04" dependencies = [ "alloy-rlp", "arbitrary", @@ -332,9 +332,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcfa2db03d4221b5ca14bff7dbed4712689cb87a3e826af522468783ff05ec5d" +checksum = "a9a9d6ef38d75e4b0dce6737463099698f9b839d1c3f7c8883bfdfce8954374b" dependencies = [ "alloy-chains", "alloy-consensus", @@ -375,9 +375,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eace70e43b073d4bfc1de915c45993a50facd6526fd8da80204e0f83a9e233a" +checksum = "1be3b30bab565198a1bda090915dd165ca9211154eb0b37d046a22829418dcc0" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -416,9 +416,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ec6963b08f1c6ef8eacc01dbba20f2c6a1533550403f6b52dbbe0da0360834" +checksum = "f5ed1e9957edfc8d155e2610e2ff3e10b059b89a6103de9f01579f40d8926d47" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -442,9 +442,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138ef78340b47f16ca4d04a4d75fe2ccdb3f1a4f748d5f3b2fbebc43581fd02e" +checksum = "206749723862bd27d5468270e30fc987c5b4376240aefee728d7e64282c9d146" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -458,9 +458,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbe94a1fcd071f19b313e4506d1affee0bd0b4a1cfbfd18a2541fda8e5487cf" +checksum = "4ac98a9d17ec4d851ea38e556c27b92e1ff8c97664cf1feb77aec38dcba34579" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -470,9 +470,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c64a83112b09bd293ef522bfa3800fa2d2df4d72f2bcd3a84b08490503b22e55" +checksum = "5e6ff23d7bde6ddeea4c1ca98e7a5a728326d543bd7133735c04ea83ebde41d0" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -481,9 +481,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb36f68cc0c83120ecfbf0b1862b35f846da8e0cb95be3d10a3a08bfa711248" +checksum = "3d72085173d210806a27892eb72770a663f5b0c17598e37f18c6bb24f7583c3c" dependencies = [ "alloy-primitives", "serde", @@ -491,9 +491,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d87e5622ed4d471f1eefb99a400cd7e362a1889baa9bb4417742260ca43a8" +checksum = "ee96e9793d3ec528ead6e8580f24e9acc71f5c2bc35feefba24465044bb77d76" dependencies = [ "alloy-consensus", "alloy-eips", @@ -509,9 +509,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc1892a1ac0d2a49c063f0791aa6bde342f020c5d37aaaec14832b661802cb4" +checksum = "319a0ca31863bd6fb9aafeaa16425d0a2f1228da44bc24fd2f997ba50afe7e18" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -529,9 +529,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b25a5e0a7ae0127f20077b23319c8d4a416187c204bf3329ab28a0309ed45535" +checksum = "af2769894024f65ba252618e06a0ca22fc025377ade6d60d7f47a83ac9559680" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -543,9 +543,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64952ac1199868bcd05b3aae2d5e988e6bd171e42ae71580abe6718263061b27" +checksum = "69bfa0d7934827098cd386965a796e7765485dc86c6ae03cda262ad9ccb30e01" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -555,9 +555,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17939f6bef49268e4494158fce1ab8913cd6164ec3f9a4ada2c677b9b5a77f2f" +checksum = "81537867986734e5867a9131145bdc56301f5b37ef9c9fb4654d7f7691a4015d" dependencies = [ "alloy-primitives", "serde", @@ -566,9 +566,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77d1f0762a44338f0e05987103bd5919df52170d949080bfebfeb6aaaa867c39" +checksum = "0fdcbfe7079c877b3cb6ec43017e94f66432480f1c1779f736c064e6a8d422cc" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -582,9 +582,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63cf9487165bcf15e15f033529ca8b8c63a26e5f9b435fbd239f786391ca2cb3" +checksum = "6da52893079d9c16ad00b882f9b900bfe7517426c729e4858bf8404c2c593503" dependencies = [ "alloy-consensus", "alloy-network", @@ -600,9 +600,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a9f720296bf196732ecc6717aae33a4192c430b779b709557073329ae7ebeb4" +checksum = "04dd0cd5702c40b836db606575d4122388e415c30eac99937f8fb65c19c8f4a9" dependencies = [ "alloy-consensus", "alloy-network", @@ -618,9 +618,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eaa7c88f704957cd9a8021be4d9e1d12da2cea55b8ce0551224805520ab0720" +checksum = "e35a72689d2312268ba7b381633c8edf6f7aa4e18d7f2852f7cdcc7f0e2a7d1e" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -638,9 +638,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59dd2f16055f532f83a8f8e3c13cf1e3b5ff78afdef82edb613946156e542272" +checksum = "3f5175bd063463e25f1ffc6daaa223db15baf4b18e3d83d0d31fb95756aab6cc" dependencies = [ "alloy-consensus", "alloy-network", @@ -657,9 +657,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd52d50f219e5160799cc569c1a7efd20d4d92cc2c2352a59874f71f02d642c" +checksum = "312d26fc0ad8c0662bdda1cd68f0ecc4b16c27b8d3d3c228558349218c9f4de1" dependencies = [ "alloy-consensus", "alloy-network", @@ -674,9 +674,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d64f851d95619233f74b310f12bcf16e0cbc27ee3762b6115c14a84809280a" +checksum = "c6d1a14b4a9f6078ad9132775a2ebb465b06b387d60f7413ddc86d7bf7453408" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -688,9 +688,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf7ed1574b699f48bf17caab4e6e54c6d12bc3c006ab33d58b1e227c1c3559f" +checksum = "4436b4b96d265eb17daea26eb31525c3076d024d10901e446790afbd2f7eeaf5" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -707,9 +707,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c02997ccef5f34f9c099277d4145f183b422938ed5322dc57a089fe9b9ad9ee" +checksum = "e5f58698a18b96faa8513519de112b79a96010b4ff84264ce54a217c52a8e98b" dependencies = [ "alloy-json-abi", "const-hex", @@ -724,9 +724,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce13ff37285b0870d0a0746992a4ae48efaf34b766ae4c2640fa15e5305f8e73" +checksum = "1f3d6d2c490f650c5abd65a9a583b09a8c8931c265d3a55b18a8e349dd6d9d84" dependencies = [ "serde", "winnow", @@ -734,9 +734,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1174cafd6c6d810711b4e00383037bdb458efc4fe3dbafafa16567e0320c54d8" +checksum = "c766e4979fc19d70057150befe8e3ea3f0c4cbc6839b8eaaa250803451692305" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -747,9 +747,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a3827275a4eed3431ce876a59c76fd19effc2a8c09566b2603e3a3376d38af0" +checksum = "6121c7a8791d7984bd3e1a487aae55c62358b0bd94330126db41d795d942e24e" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -767,9 +767,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958417ddf333c55b0627cb7fbee7c6666895061dee79f50404dd6dbdd8e9eba0" +checksum = "15487cd2d7f2bfd8546e851d80db470603c2a1de82f7c39403078356b20d9a21" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -782,9 +782,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168abcf4337c3fbc0bf9030e62bbaca8b9a0fddf687ecc6585e2e6515dde8b0d" +checksum = "a74511d4703f571c2b4da85458b5634855d97e10a94407c05d97b2052ed5450b" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -803,9 +803,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf327f8d3e938272c2eace672094d3800e069e3f34137358e563faaa314f8a" +checksum = "f812a1f1ae7955964727d3040bf240955ca324d80383b9dd0ab21a6de3007386" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -821,9 +821,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e428104b2445a4f929030891b3dbf8c94433a8349ba6480946bf6af7975c2f6" +checksum = "6917c79e837aa7b77b7a6dae9f89cbe15313ac161c4d3cfaf8909ef21f3d22d8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -2411,9 +2411,9 @@ dependencies = [ [[package]] name = "compact_str" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644" +checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32" dependencies = [ "castaway", "cfg-if", @@ -5431,7 +5431,7 @@ dependencies = [ "log", "num-format", "once_cell", - "quick-xml 0.37.1", + "quick-xml 0.37.2", "rgb", "str_stack", ] @@ -5558,11 +5558,14 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a46169c7a10358cdccfb179910e8a5a392fc291bdb409da9aeece5b19786d8" +checksum = "d09ead9616bda43297ffc1fa32e01f5951c0f08cf5239a296a8d73f3b13fc2b6" dependencies = [ "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", "serde", "windows-sys 0.59.0", ] @@ -6345,9 +6348,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nybbles" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55a62e678a89501192cc5ebf47dcbc656b608ae5e1c61c9251fe35230f119fe3" +checksum = "a3409fc85ac27b27d971ea7cd1aabafd2eefa6de7e481c8d4f707225c117e81a" dependencies = [ "alloy-rlp", "const-hex", @@ -6866,6 +6869,15 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -7180,7 +7192,7 @@ dependencies = [ "chrono", "indexmap 2.7.0", "newtype-uuid", - "quick-xml 0.37.1", + "quick-xml 0.37.2", "strip-ansi-escapes", "thiserror 2.0.9", "uuid 1.11.0", @@ -7197,9 +7209,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.37.1" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22f29bdff3987b4d8632ef95fd6424ec7e4e0a57e2f4fc63e489e75357f6a03" +checksum = "165859e9e55f79d67b96c5d96f4e88b6f2695a1972849c15a6a3f5c59fc2c003" dependencies = [ "memchr", ] @@ -7440,9 +7452,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.11" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe060fe50f524be480214aba758c71f99f90ee8c83c5a36b5e9e1d568eb4eb3" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ "async-compression", "base64 0.22.1", @@ -8830,9 +8842,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219389c1ebe89f8333df8bdfb871f6631c552ff399c23cac02480b6088aad8f0" +checksum = "c74af950d86ec0f5b2ae2d7f1590bbfbcf4603a0a15742d8f98132ac4fe3efd4" dependencies = [ "paste", "proc-macro2", @@ -10303,9 +10315,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68" dependencies = [ "memchr", ] From 6cb41febfc989cbf7dc13c43ec6c3ce5fba1ea04 Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Thu, 2 Jan 2025 15:58:20 +0800 Subject: [PATCH 1818/1963] add comment to `-r` option about default value (#9571) add comment to -r option about default value --- crates/cli/src/opts/ethereum.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/ethereum.rs index 8d2601be16381..344efe73e8514 100644 --- a/crates/cli/src/opts/ethereum.rs +++ b/crates/cli/src/opts/ethereum.rs @@ -18,7 +18,7 @@ const FLASHBOTS_URL: &str = "https://rpc.flashbots.net/fast"; #[derive(Clone, Debug, Default, Parser)] pub struct RpcOpts { - /// The RPC endpoint. + /// The RPC endpoint, default value is http://localhost:8545. #[arg(short = 'r', long = "rpc-url", env = "ETH_RPC_URL")] pub url: Option, From 8555f162576c6deb57a719d767271a710d23cf82 Mon Sep 17 00:00:00 2001 From: Marquis Shanahan <29431502+9547@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:07:08 +0800 Subject: [PATCH 1819/1963] fix(anvil): ipc append a newline (#9608) * fix(anvil): ipc append a newline Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> * use put_u8 instead of extend from slice Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --------- Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --- crates/anvil/server/src/ipc.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index 8743f06424d0a..392eb47acfd46 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -2,7 +2,7 @@ use crate::{error::RequestError, pubsub::PubSubConnection, PubSubRpcHandler}; use anvil_rpc::request::Request; -use bytes::BytesMut; +use bytes::{BufMut, BytesMut}; use futures::{ready, Sink, Stream, StreamExt}; use interprocess::local_socket::{self as ls, tokio::prelude::*}; use std::{ @@ -171,6 +171,8 @@ impl tokio_util::codec::Encoder for JsonRpcCodec { fn encode(&mut self, msg: String, buf: &mut BytesMut) -> io::Result<()> { buf.extend_from_slice(msg.as_bytes()); + // Add newline character + buf.put_u8(b'\n'); Ok(()) } } From caf845575568d23b9b22357eb8e7257c717e088e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:08:17 +0100 Subject: [PATCH 1820/1963] chore: dedup errors in eyre handler (#9612) --- crates/cli/src/handler.rs | 11 ++++++----- crates/common/src/errors/mod.rs | 32 +++++++++++++++++++++++++++++--- crates/forge/tests/cli/cmd.rs | 4 ---- crates/forge/tests/cli/config.rs | 1 - 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index ed32fa16b8083..53485e2260b03 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -10,15 +10,16 @@ impl EyreHandler for Handler { if f.alternate() { return fmt::Debug::fmt(error, f) } + let errors = foundry_common::errors::dedup_chain(error); + + let (error, sources) = errors.split_first().unwrap(); write!(f, "{error}")?; - if let Some(cause) = error.source() { + if !sources.is_empty() { write!(f, "\n\nContext:")?; - let multiple = cause.source().is_some(); - let errors = std::iter::successors(Some(cause), |e| (*e).source()); - - for (n, error) in errors.enumerate() { + let multiple = sources.len() > 1; + for (n, error) in sources.iter().enumerate() { writeln!(f)?; if multiple { write!(f, "- Error #{n}: {error}")?; diff --git a/crates/common/src/errors/mod.rs b/crates/common/src/errors/mod.rs index c8b2c6bcc0239..5ecd1dcc04cb0 100644 --- a/crates/common/src/errors/mod.rs +++ b/crates/common/src/errors/mod.rs @@ -6,15 +6,41 @@ pub use fs::FsPathError; mod artifacts; pub use artifacts::*; +mod private { + use eyre::Chain; + use std::error::Error; + + pub trait ErrorChain { + fn chain(&self) -> Chain<'_>; + } + + impl ErrorChain for dyn Error + 'static { + fn chain(&self) -> Chain<'_> { + Chain::new(self) + } + } + + impl ErrorChain for eyre::Report { + fn chain(&self) -> Chain<'_> { + self.chain() + } + } +} + /// Displays a chain of errors in a single line. -pub fn display_chain(error: &eyre::Report) -> String { +pub fn display_chain(error: &E) -> String { + dedup_chain(error).join("; ") +} + +/// Deduplicates a chain of errors. +pub fn dedup_chain(error: &E) -> Vec { let mut causes = all_sources(error); // Deduplicate the common pattern `msg1: msg2; msg2` -> `msg1: msg2`. causes.dedup_by(|b, a| a.contains(b.as_str())); - causes.join("; ") + causes } -fn all_sources(err: &eyre::Report) -> Vec { +fn all_sources(err: &E) -> Vec { err.chain().map(|cause| cause.to_string().trim().to_string()).collect() } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 27aea6d8683f7..62b6de392a8e6 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1135,7 +1135,6 @@ Warning (1878): SPDX license identifier not provided in source file. Before publ Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. [FILE] - "#]]); // ignores error code and compiles @@ -1215,7 +1214,6 @@ Error (2314): Expected ';' but got identifier 7 | THIS WILL CAUSE AN ERROR | ^^^^^ - "#]]); // but ensure this cleaned cache and artifacts @@ -1231,7 +1229,6 @@ Error (2314): Expected ';' but got identifier 7 | THIS WILL CAUSE AN ERROR | ^^^^^ - "#]]); // resolve the error by replacing the file @@ -1271,7 +1268,6 @@ Error (2314): Expected ';' but got identifier 7 | THIS WILL CAUSE AN ERROR | ^^^^^ - "#]]); // ensure unchanged cache file diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 545cebac87a8e..61e63abf9336a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -448,7 +448,6 @@ Error (6553): The msize instruction cannot be used when the Yul optimizer is act 6 | assembly { | ^ (Relevant source part starts here and spans across multiple lines). - "#]]); // disable yul optimizer explicitly From f7bb427246360b21c85d2909fd3bd8a00e42aa32 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 3 Jan 2025 16:34:50 +0530 Subject: [PATCH 1821/1963] fix(`evm`): P256Verify address (#9618) --- crates/evm/core/src/precompiles.rs | 2 +- crates/evm/core/src/utils.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/evm/core/src/precompiles.rs b/crates/evm/core/src/precompiles.rs index ceaf6d004e936..c70dc06d21442 100644 --- a/crates/evm/core/src/precompiles.rs +++ b/crates/evm/core/src/precompiles.rs @@ -49,7 +49,7 @@ pub const PRECOMPILES: &[Address] = &[ ODYSSEY_P256_ADDRESS, ]; -/// [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212) secp256r1 precompile address on Odyssey. +/// [EIP-7212](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md) secp256r1 precompile address on Odyssey. /// /// pub const ODYSSEY_P256_ADDRESS: Address = address!("0000000000000000000000000000000000000014"); diff --git a/crates/evm/core/src/utils.rs b/crates/evm/core/src/utils.rs index 0f29ec2a47540..ac19e91555743 100644 --- a/crates/evm/core/src/utils.rs +++ b/crates/evm/core/src/utils.rs @@ -18,6 +18,7 @@ use revm::{ return_ok, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome, Gas, InstructionResult, InterpreterResult, }, + precompile::secp256r1::P256VERIFY, primitives::{CreateScheme, EVMError, HandlerCfg, SpecId, KECCAK_EMPTY}, FrameOrResult, FrameResult, }; @@ -301,7 +302,7 @@ pub fn odyssey_handler_register(handler: &mut EvmHandle handler.pre_execution.load_precompiles = Arc::new(move || { let mut loaded_precompiles = prev(); - loaded_precompiles.extend([ODYSSEY_P256]); + loaded_precompiles.extend([ODYSSEY_P256, P256VERIFY]); loaded_precompiles }); From 15940fc427e73f27ebd6e9df8673c005aad1e306 Mon Sep 17 00:00:00 2001 From: Marquis Shanahan <29431502+9547@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:02:23 +0800 Subject: [PATCH 1822/1963] typo: EtherScan -> Etherscan (#9607) Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> Co-authored-by: Matthias Seitz --- crates/cli/src/utils/abi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cli/src/utils/abi.rs b/crates/cli/src/utils/abi.rs index e903804ded91e..301200f701273 100644 --- a/crates/cli/src/utils/abi.rs +++ b/crates/cli/src/utils/abi.rs @@ -51,7 +51,7 @@ pub async fn parse_function_args Date: Fri, 3 Jan 2025 06:08:07 -0800 Subject: [PATCH 1823/1963] chore(git): enhance rust diffing (#9596) This has to be explicitly enabled for git to utilize its enhanced rust diffing, evidently. ref: https://github.com/rust-lang/rust/pull/78882 Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 0e34b8632d97e..0e0276a958df8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ crates/cheatcodes/assets/*.json linguist-generated testdata/cheats/Vm.sol linguist-generated + +# See +*.rs diff=rust From c66fd407926878f807dc1a96598d86425eb907bf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 5 Jan 2025 01:08:21 +0000 Subject: [PATCH 1824/1963] chore(deps): weekly `cargo update` (#9623) Locking 56 packages to latest compatible versions Updating alloy-chains v0.1.51 -> v0.1.52 Updating alloy-consensus v0.9.1 -> v0.9.2 Updating alloy-consensus-any v0.9.1 -> v0.9.2 Updating alloy-contract v0.9.1 -> v0.9.2 Updating alloy-dyn-abi v0.8.16 -> v0.8.18 Updating alloy-eips v0.9.1 -> v0.9.2 Updating alloy-genesis v0.9.1 -> v0.9.2 Updating alloy-json-abi v0.8.16 -> v0.8.18 Updating alloy-json-rpc v0.9.1 -> v0.9.2 Updating alloy-network v0.9.1 -> v0.9.2 Updating alloy-network-primitives v0.9.1 -> v0.9.2 Updating alloy-node-bindings v0.9.1 -> v0.9.2 Updating alloy-primitives v0.8.16 -> v0.8.18 Updating alloy-provider v0.9.1 -> v0.9.2 Updating alloy-pubsub v0.9.1 -> v0.9.2 Updating alloy-rpc-client v0.9.1 -> v0.9.2 Updating alloy-rpc-types v0.9.1 -> v0.9.2 Updating alloy-rpc-types-anvil v0.9.1 -> v0.9.2 Updating alloy-rpc-types-any v0.9.1 -> v0.9.2 Updating alloy-rpc-types-debug v0.9.1 -> v0.9.2 Updating alloy-rpc-types-engine v0.9.1 -> v0.9.2 Updating alloy-rpc-types-eth v0.9.1 -> v0.9.2 Updating alloy-rpc-types-trace v0.9.1 -> v0.9.2 Updating alloy-rpc-types-txpool v0.9.1 -> v0.9.2 Updating alloy-serde v0.9.1 -> v0.9.2 Updating alloy-signer v0.9.1 -> v0.9.2 Updating alloy-signer-aws v0.9.1 -> v0.9.2 Updating alloy-signer-gcp v0.9.1 -> v0.9.2 Updating alloy-signer-ledger v0.9.1 -> v0.9.2 Updating alloy-signer-local v0.9.1 -> v0.9.2 Updating alloy-signer-trezor v0.9.1 -> v0.9.2 Updating alloy-sol-macro v0.8.16 -> v0.8.18 Updating alloy-sol-macro-expander v0.8.16 -> v0.8.18 Updating alloy-sol-macro-input v0.8.16 -> v0.8.18 Updating alloy-sol-type-parser v0.8.16 -> v0.8.18 Updating alloy-sol-types v0.8.16 -> v0.8.18 Updating alloy-transport v0.9.1 -> v0.9.2 Updating alloy-transport-http v0.9.1 -> v0.9.2 Updating alloy-transport-ipc v0.9.1 -> v0.9.2 Updating alloy-transport-ws v0.9.1 -> v0.9.2 Updating async-trait v0.1.83 -> v0.1.84 Updating aws-config v1.5.12 -> v1.5.13 Updating aws-runtime v1.5.2 -> v1.5.3 Updating aws-sdk-kms v1.53.0 -> v1.54.0 Updating aws-sdk-sso v1.52.0 -> v1.53.0 Updating aws-sdk-ssooidc v1.53.0 -> v1.54.0 Updating aws-sdk-sts v1.53.0 -> v1.54.0 Updating bstr v1.11.1 -> v1.11.3 Updating cc v1.2.6 -> v1.2.7 Removing diff v0.1.13 Removing hex-literal v0.4.1 Updating instability v0.3.5 -> v0.3.6 Updating jiff v0.1.18 -> v0.1.21 Removing pretty_assertions v1.4.1 Updating schnellru v0.2.3 -> v0.2.4 Updating syn v2.0.93 -> v2.0.94 Updating syn-solidity v0.8.16 -> v0.8.18 Updating tempfile v3.14.0 -> v3.15.0 Updating winnow v0.6.21 -> v0.6.22 note: pass `--verbose` to see 12 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 381 +++++++++++++++++++++++++---------------------------- 1 file changed, 179 insertions(+), 202 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9349acd2f1afc..fdb0920861b8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4e0f0136c085132939da6b753452ebed4efaa73fe523bb855b10c199c2ebfaf" +checksum = "56f15afc5993458b42739ab3b69bdb6b4c8112acd3997dbea9bc092c9517137c" dependencies = [ "alloy-primitives", "num_enum", @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d802a6d579d924a2926d181bce43231aaab4699a7c206197e88fbc6b9dda846f" +checksum = "f4138dc275554afa6f18c4217262ac9388790b2fc393c2dfe03c51d357abf013" dependencies = [ "alloy-eips", "alloy-primitives", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1bcb3e4810bff7e2a62ac0d741c70a7b5560e57b76eb0f0d33e1070735c60" +checksum = "0fa04e1882c31288ce1028fdf31b6ea94cfa9eafa2e497f903ded631c8c6a42c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e56bc4dc06ab205dc4106348c44b92e0d979148f8db751994c11caabf5ebbef" +checksum = "5f21886c1fea0626f755a49b2ac653b396fb345233f6170db2da3d0ada31560c" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d2ea4d7f220a19c1f8c98822026d1d26a4b75a72e1a7308d02bab1f77c9a00" +checksum = "44e3b98c37b3218924cd1d2a8570666b89662be54e5b182643855f783ea68b33" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938bc1cf2ec42579e187834efc254e76dd3fa19f526b57872713e6b95f411305" +checksum = "52dd5869ed09e399003e0e0ec6903d981b2a92e74c5d37e6b40890bad2517526" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -206,9 +206,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b648eac186485ead3da160985b929e610a45eb39903f750da9b35f58a91eef52" +checksum = "e7d2a7fe5c1a9bd6793829ea21a636f30fc2b3f5d2e7418ba86d96e41dd1f460" dependencies = [ "alloy-eips", "alloy-primitives", @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79c6b4bcc1067a7394b5b2aec7da1bd829c8c476b796c73eb14da34392a07a7" +checksum = "731ea743b3d843bc657e120fb1d1e9cc94f5dab8107e35a82125a63e6420a102" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a38b4b49667a84ecad7cdaf431b8bd3f14ca496e5a021df1c26d5c4595dca6" +checksum = "2008bedb8159a255b46b7c8614516eda06679ea82f620913679afbd8031fea72" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb5dc326960e88eec6b5e9add221a071f15cb8fa93b9e88ee9c76cd0e4e1009" +checksum = "4556f01fe41d0677495df10a648ddcf7ce118b0e8aa9642a0e2b6dd1fb7259de" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1535c89ae0648f2c15c0bf9b8b92670f6b3b8515b645425c8b46462563c0eae4" +checksum = "f31c3c6b71340a1d076831823f09cb6e02de01de5c6630a9631bdb36f947ff80" dependencies = [ "alloy-consensus", "alloy-eips", @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5af000a8d9aa22694c92a5c6ebd9113495d2eb78fb3579d02a715569b973cc26" +checksum = "4520cd4bc5cec20c32c98e4bc38914c7fb96bf4a712105e44da186a54e65e3ba" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -300,9 +300,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0540fd0355d400b59633c27bd4b42173e59943f28e9d3376b77a24771d432d04" +checksum = "788bb18e8f61d5d9340b52143f27771daf7e1dccbaf2741621d2493f9debf52e" dependencies = [ "alloy-rlp", "arbitrary", @@ -314,7 +314,6 @@ dependencies = [ "foldhash", "getrandom", "hashbrown 0.15.2", - "hex-literal", "indexmap 2.7.0", "itoa", "k256", @@ -332,9 +331,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d6ef38d75e4b0dce6737463099698f9b839d1c3f7c8883bfdfce8954374b" +checksum = "5a22c4441b3ebe2d77fa9cf629ba68c3f713eb91779cff84275393db97eddd82" dependencies = [ "alloy-chains", "alloy-consensus", @@ -375,9 +374,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be3b30bab565198a1bda090915dd165ca9211154eb0b37d046a22829418dcc0" +checksum = "2269fd635f7b505f27c63a3cb293148cd02301efce4c8bdd9ff54fbfc4a20e23" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -411,14 +410,14 @@ checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] name = "alloy-rpc-client" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5ed1e9957edfc8d155e2610e2ff3e10b059b89a6103de9f01579f40d8926d47" +checksum = "d06a292b37e182e514903ede6e623b9de96420e8109ce300da288a96d88b7e4b" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -442,9 +441,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206749723862bd27d5468270e30fc987c5b4376240aefee728d7e64282c9d146" +checksum = "9383845dd924939e7ab0298bbfe231505e20928907d7905aa3bf112287305e06" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -458,9 +457,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac98a9d17ec4d851ea38e556c27b92e1ff8c97664cf1feb77aec38dcba34579" +checksum = "11495cb8c8d3141fc27556a4c9188b81531ad5ec3076a0394c61a6dcfbce9f34" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -470,9 +469,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ff23d7bde6ddeea4c1ca98e7a5a728326d543bd7133735c04ea83ebde41d0" +checksum = "ca445cef0eb6c2cf51cfb4e214fbf1ebd00893ae2e6f3b944c8101b07990f988" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -481,9 +480,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d72085173d210806a27892eb72770a663f5b0c17598e37f18c6bb24f7583c3c" +checksum = "358d6a8d7340b9eb1a7589a6c1fb00df2c9b26e90737fa5ed0108724dd8dac2c" dependencies = [ "alloy-primitives", "serde", @@ -491,9 +490,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee96e9793d3ec528ead6e8580f24e9acc71f5c2bc35feefba24465044bb77d76" +checksum = "4a5f821f30344862a0b6eb9a1c2eb91dfb2ff44c7489f37152a526cdcab79264" dependencies = [ "alloy-consensus", "alloy-eips", @@ -509,9 +508,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "319a0ca31863bd6fb9aafeaa16425d0a2f1228da44bc24fd2f997ba50afe7e18" +checksum = "0938bc615c02421bd86c1733ca7205cc3d99a122d9f9bff05726bd604b76a5c2" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -529,9 +528,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2769894024f65ba252618e06a0ca22fc025377ade6d60d7f47a83ac9559680" +checksum = "cd38207e056cc7d1372367fbb4560ddf9107cbd20731743f641246bf0dede149" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -543,9 +542,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69bfa0d7934827098cd386965a796e7765485dc86c6ae03cda262ad9ccb30e01" +checksum = "b7fd456a3fa9ea732d1c0611c9d52b5326ee29f4d02d01b07dac453ed68d9eb5" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -555,9 +554,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81537867986734e5867a9131145bdc56301f5b37ef9c9fb4654d7f7691a4015d" +checksum = "ae0465c71d4dced7525f408d84873aeebb71faf807d22d74c4a426430ccd9b55" dependencies = [ "alloy-primitives", "serde", @@ -566,9 +565,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdcbfe7079c877b3cb6ec43017e94f66432480f1c1779f736c064e6a8d422cc" +checksum = "9bfa395ad5cc952c82358d31e4c68b27bf4a89a5456d9b27e226e77dac50e4ff" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -582,9 +581,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da52893079d9c16ad00b882f9b900bfe7517426c729e4858bf8404c2c593503" +checksum = "0eb06810c34427d499863817eb506acf57cb9ded9224b374116cae4e22dbd4e9" dependencies = [ "alloy-consensus", "alloy-network", @@ -600,9 +599,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd0cd5702c40b836db606575d4122388e415c30eac99937f8fb65c19c8f4a9" +checksum = "d629e63fec8802ad53706d46e8eceeeae2b135c6648d0de41669a523bf17df4a" dependencies = [ "alloy-consensus", "alloy-network", @@ -618,9 +617,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35a72689d2312268ba7b381633c8edf6f7aa4e18d7f2852f7cdcc7f0e2a7d1e" +checksum = "b426789566a19252cb46b757d91543a6f8e70330c72f312b86c5878595d092ef" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -638,9 +637,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5175bd063463e25f1ffc6daaa223db15baf4b18e3d83d0d31fb95756aab6cc" +checksum = "fbdc63ce9eda1283fcbaca66ba4a414b841c0e3edbeef9c86a71242fc9e84ccc" dependencies = [ "alloy-consensus", "alloy-network", @@ -657,9 +656,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312d26fc0ad8c0662bdda1cd68f0ecc4b16c27b8d3d3c228558349218c9f4de1" +checksum = "6e7d0c000abd591c9cceac5c07f785f101c9a8c879c6ccd300feca1ae03bdef6" dependencies = [ "alloy-consensus", "alloy-network", @@ -674,23 +673,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6d1a14b4a9f6078ad9132775a2ebb465b06b387d60f7413ddc86d7bf7453408" +checksum = "a07b74d48661ab2e4b50bb5950d74dbff5e61dd8ed03bb822281b706d54ebacb" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4436b4b96d265eb17daea26eb31525c3076d024d10901e446790afbd2f7eeaf5" +checksum = "19cc9c7f20b90f9be1a8f71a3d8e283a43745137b0837b1a1cb13159d37cad72" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -700,16 +699,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f58698a18b96faa8513519de112b79a96010b4ff84264ce54a217c52a8e98b" +checksum = "713b7e6dfe1cb2f55c80fb05fd22ed085a1b4e48217611365ed0ae598a74c6ac" dependencies = [ "alloy-json-abi", "const-hex", @@ -718,15 +717,15 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.93", + "syn 2.0.94", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3d6d2c490f650c5abd65a9a583b09a8c8931c265d3a55b18a8e349dd6d9d84" +checksum = "1eda2711ab2e1fb517fc6e2ffa9728c9a232e296d16810810e6957b781a1b8bc" dependencies = [ "serde", "winnow", @@ -734,9 +733,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c766e4979fc19d70057150befe8e3ea3f0c4cbc6839b8eaaa250803451692305" +checksum = "e3b478bc9c0c4737a04cd976accde4df7eba0bdc0d90ad6ff43d58bc93cf79c1" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -747,9 +746,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6121c7a8791d7984bd3e1a487aae55c62358b0bd94330126db41d795d942e24e" +checksum = "d17722a198f33bbd25337660787aea8b8f57814febb7c746bc30407bdfc39448" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -767,9 +766,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15487cd2d7f2bfd8546e851d80db470603c2a1de82f7c39403078356b20d9a21" +checksum = "6e1509599021330a31c4a6816b655e34bf67acb1cc03c564e09fd8754ff6c5de" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -782,9 +781,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74511d4703f571c2b4da85458b5634855d97e10a94407c05d97b2052ed5450b" +checksum = "fa4da44bc9a5155ab599666d26decafcf12204b72a80eeaba7c5e234ee8ac205" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -803,9 +802,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f812a1f1ae7955964727d3040bf240955ca324d80383b9dd0ab21a6de3007386" +checksum = "58011745b2f17b334db40df9077d75b181f78360a5bc5c35519e15d4bfce15e2" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1242,7 +1241,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -1264,18 +1263,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -1328,7 +1327,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -1339,9 +1338,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.12" +version = "1.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649316840239f4e58df0b7f620c428f5fababbbca2d504488c641534050bd141" +checksum = "c03a50b30228d3af8865ce83376b4e99e1ffa34728220fe2860e4df0bb5278d6" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1381,9 +1380,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f6f1124d6e19ab6daf7f2e615644305dc6cb2d706892a8a8c0b98db35de020" +checksum = "b16d1aa50accc11a4b4d5c50f7fb81cc0cf60328259c587d0e6b0f11385bde46" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1406,9 +1405,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.53.0" +version = "1.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e349416a1998fde638deed85c18efeefd81af293439c16d676b7fce992904389" +checksum = "a6cf16c0e5853312995505557b876dd3f9fb9941e96d031383528ccef14ace57" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1428,9 +1427,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.52.0" +version = "1.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb25f7129c74d36afe33405af4517524df8f74b635af8c2c8e91c1552b8397b2" +checksum = "1605dc0bf9f0a4b05b451441a17fcb0bda229db384f23bf5cead3adbab0664ac" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1450,9 +1449,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.53.0" +version = "1.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03a3d5ef14851625eafd89660a751776f938bf32f309308b20dcca41c44b568" +checksum = "59f3f73466ff24f6ad109095e0f3f2c830bfb4cd6c8b12f744c8e61ebf4d3ba1" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1472,9 +1471,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.53.0" +version = "1.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3a9f073ae3a53b54421503063dfb87ff1ea83b876f567d92e8b8d9942ba91b" +checksum = "249b2acaa8e02fd4718705a9494e3eb633637139aa4bb09d70965b0448e865db" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1862,7 +1861,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -1877,9 +1876,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.11.1" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786a307d683a5bf92e6fd5fd69a7eb613751668d1d8d67d802846dfe367c62c8" +checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0" dependencies = [ "memchr", "regex-automata 0.4.9", @@ -2079,9 +2078,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.6" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" +checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" dependencies = [ "shlex", ] @@ -2245,7 +2244,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -2660,7 +2659,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -2671,7 +2670,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -2744,7 +2743,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -2765,7 +2764,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -2775,7 +2774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -2796,7 +2795,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", "unicode-xid", ] @@ -2813,12 +2812,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "diff" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" - [[package]] name = "digest" version = "0.9.0" @@ -2910,7 +2903,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -2935,7 +2928,7 @@ checksum = "8dc51d98e636f5e3b0759a39257458b22619cac7e96d932da6eeb052891bb67c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -3062,7 +3055,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -3197,7 +3190,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.93", + "syn 2.0.94", "toml 0.8.19", "walkdir", ] @@ -3225,7 +3218,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.93", + "syn 2.0.94", "tempfile", "thiserror 1.0.69", "tiny-keccak", @@ -3629,7 +3622,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -4211,7 +4204,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -4371,7 +4364,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -4858,12 +4851,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - [[package]] name = "hidapi-rusb" version = "1.3.3" @@ -4905,7 +4892,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -5264,7 +5251,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -5364,7 +5351,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -5473,16 +5460,15 @@ dependencies = [ [[package]] name = "instability" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898e106451f7335950c9cc64f8ec67b5f65698679ac67ed00619aeef14e1cf75" +checksum = "894813a444908c0c8c0e221b041771d107c4a21de1d317dc49bcc66e3c9e5b3f" dependencies = [ "darling", "indoc", - "pretty_assertions", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -5558,9 +5544,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.18" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09ead9616bda43297ffc1fa32e01f5951c0f08cf5239a296a8d73f3b13fc2b6" +checksum = "ed0ce60560149333a8e41ca7dc78799c47c5fd435e2bc18faf6a054382eec037" dependencies = [ "jiff-tzdb-platform", "log", @@ -5964,7 +5950,7 @@ checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6054,7 +6040,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6328,7 +6314,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6468,7 +6454,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6631,7 +6617,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6690,7 +6676,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6774,7 +6760,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6832,7 +6818,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -6925,16 +6911,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "pretty_assertions" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" -dependencies = [ - "diff", - "yansi", -] - [[package]] name = "prettyplease" version = "0.2.25" @@ -6942,7 +6918,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -7020,7 +6996,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -7040,7 +7016,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", "version_check", "yansi", ] @@ -7104,7 +7080,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -7127,7 +7103,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -7962,7 +7938,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8004,14 +7980,14 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] name = "schnellru" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" +checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" dependencies = [ "ahash", "cfg-if", @@ -8190,7 +8166,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8201,7 +8177,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8245,7 +8221,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8291,7 +8267,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8599,7 +8575,7 @@ checksum = "f0cc54b74e214647c1bbfc098d080cc5deac77f8dcb99aca91747276b01a15ad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8763,7 +8739,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8831,9 +8807,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.93" +version = "2.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058" +checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" dependencies = [ "proc-macro2", "quote", @@ -8842,14 +8818,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c74af950d86ec0f5b2ae2d7f1590bbfbcf4603a0a15742d8f98132ac4fe3efd4" +checksum = "31e89d8bf2768d277f40573c83a02a099e96d96dd3104e13ea676194e61ac4b0" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8869,7 +8845,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8880,12 +8856,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", @@ -8979,7 +8956,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -8990,7 +8967,7 @@ checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -9125,7 +9102,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -9399,7 +9376,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -9814,7 +9791,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", "wasm-bindgen-shared", ] @@ -9849,7 +9826,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -10090,7 +10067,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -10101,7 +10078,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -10112,7 +10089,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -10123,7 +10100,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -10315,9 +10292,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68" +checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" dependencies = [ "memchr", ] @@ -10403,7 +10380,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", "synstructure", ] @@ -10425,7 +10402,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -10445,7 +10422,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", "synstructure", ] @@ -10466,7 +10443,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] @@ -10488,7 +10465,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.93", + "syn 2.0.94", ] [[package]] From 2e9d84933a11bc497a87f7ff0c179136f315a514 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Sun, 5 Jan 2025 22:30:18 +0530 Subject: [PATCH 1825/1963] chore(`config`): use solar for inline config parsing (#9615) --- Cargo.lock | 3 +- crates/config/Cargo.toml | 3 +- crates/config/src/inline/natspec.rs | 180 ++++++++++++++---------- crates/forge/tests/cli/inline_config.rs | 2 +- 4 files changed, 109 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdb0920861b8a..e94ba19202f9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3991,7 +3991,8 @@ dependencies = [ "serde_json", "serde_regex", "similar-asserts", - "solang-parser", + "solar-ast", + "solar-parse", "tempfile", "thiserror 2.0.9", "toml 0.8.19", diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index ba01a1afbf4ca..560a178231ee4 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -21,7 +21,8 @@ alloy-chains = { workspace = true, features = ["serde"] } alloy-primitives = { workspace = true, features = ["serde"] } revm-primitives.workspace = true -solang-parser.workspace = true +solar-parse.workspace = true +solar-ast.workspace = true dirs-next = "2" dunce.workspace = true diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 5774d9e193f1b..013e53c10827b 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -6,7 +6,11 @@ use foundry_compilers::{ }; use itertools::Itertools; use serde_json::Value; -use solang_parser::{helpers::CodeLocation, pt}; +use solar_ast::{ + ast::{Arena, CommentKind, Item, ItemKind}, + interface::{self, Session}, +}; +use solar_parse::Parser; use std::{collections::BTreeMap, path::Path}; /// Convenient struct to hold in-line per-test configurations @@ -30,7 +34,7 @@ impl NatSpec { let mut natspecs: Vec = vec![]; let solc = SolcParser::new(); - let solang = SolangParser::new(); + let solar = SolarParser::new(); for (id, artifact) in output.artifact_ids() { let abs_path = id.source.as_path(); let path = abs_path.strip_prefix(root).unwrap_or(abs_path); @@ -48,7 +52,7 @@ impl NatSpec { if !used_solc_ast { if let Ok(src) = std::fs::read_to_string(abs_path) { - solang.parse(&mut natspecs, &src, &contract, contract_name); + solar.parse(&mut natspecs, &src, &contract, contract_name); } } } @@ -201,11 +205,11 @@ impl SolcParser { } } -struct SolangParser { +struct SolarParser { _private: (), } -impl SolangParser { +impl SolarParser { fn new() -> Self { Self { _private: () } } @@ -222,57 +226,85 @@ impl SolangParser { return; } - let Ok((pt, comments)) = solang_parser::parse(src, 0) else { return }; - - // Collects natspects from the given range. - let mut handle_docs = |contract: &str, func: Option<&str>, start, end| { - let docs = solang_parser::doccomment::parse_doccomments(&comments, start, end); - natspecs.extend( - docs.into_iter() - .flat_map(|doc| doc.into_comments()) - .filter(|doc| doc.value.contains(INLINE_CONFIG_PREFIX)) - .map(|doc| NatSpec { - // not possible to obtain correct value due to solang-parser bug - // https://github.com/hyperledger/solang/issues/1658 - line: "0:0:0".to_string(), - contract: contract.to_string(), - function: func.map(|f| f.to_string()), - docs: doc.value, - }), - ); + let mut handle_docs = |item: &Item<'_>| { + if item.docs.is_empty() { + return; + } + let lines = item + .docs + .iter() + .filter_map(|d| { + let s = d.symbol.as_str(); + if !s.contains(INLINE_CONFIG_PREFIX) { + return None + } + match d.kind { + CommentKind::Line => Some(s.trim().to_string()), + CommentKind::Block => Some( + s.lines() + .filter(|line| line.contains(INLINE_CONFIG_PREFIX)) + .map(|line| line.trim_start().trim_start_matches('*').trim()) + .collect::>() + .join("\n"), + ), + } + }) + .join("\n"); + if lines.is_empty() { + return; + } + let span = + item.docs.iter().map(|doc| doc.span).reduce(|a, b| a.to(b)).unwrap_or_default(); + natspecs.push(NatSpec { + contract: contract_id.to_string(), + function: if let ItemKind::Function(f) = &item.kind { + Some( + f.header + .name + .map(|sym| sym.to_string()) + .unwrap_or_else(|| f.kind.to_string()), + ) + } else { + None + }, + line: format!("{}:{}:0", span.lo().0, span.hi().0), + docs: lines, + }); }; - let mut prev_item_end = 0; - for item in &pt.0 { - let pt::SourceUnitPart::ContractDefinition(c) = item else { - prev_item_end = item.loc().end(); - continue - }; - let Some(id) = c.name.as_ref() else { - prev_item_end = item.loc().end(); - continue - }; - if id.name != contract_name { - prev_item_end = item.loc().end(); - continue - }; - - // Handle doc comments in between the previous contract and the current one. - handle_docs(contract_id, None, prev_item_end, item.loc().start()); - - let mut prev_end = c.loc.start(); - for part in &c.parts { - let pt::ContractPart::FunctionDefinition(f) = part else { continue }; - let start = f.loc.start(); - // Handle doc comments in between the previous function and the current one. - if let Some(name) = &f.name { - handle_docs(contract_id, Some(name.name.as_str()), prev_end, start); + let sess = Session::builder() + .with_silent_emitter(Some("Inline config parsing failed".to_string())) + .build(); + let _ = sess.enter(|| -> interface::Result<()> { + let arena = Arena::new(); + + let mut parser = Parser::from_source_code( + &sess, + &arena, + interface::source_map::FileName::Custom(contract_id.to_string()), + src.to_string(), + )?; + + let source_unit = parser.parse_file().map_err(|e| e.emit())?; + + for item in source_unit.items.iter() { + let ItemKind::Contract(c) = &item.kind else { continue }; + if c.name.as_str() != contract_name { + continue; + } + + // Handle contract level doc comments. + handle_docs(item); + + // Handle function level doc comments. + for item in c.body.iter() { + let ItemKind::Function(_) = &item.kind else { continue }; + handle_docs(item); } - prev_end = f.loc.end(); } - prev_item_end = item.loc().end(); - } + Ok(()) + }); } } @@ -318,7 +350,7 @@ mod tests { } #[test] - fn parse_solang() { + fn parse_solar() { let src = " contract C { /// forge-config: default.fuzz.runs = 600 @@ -336,10 +368,9 @@ function f2() {} /** forge-config: default.fuzz.runs = 800 */ function f3() {} } "; let mut natspecs = vec![]; - let solang = SolangParser::new(); let id = || "path.sol:C".to_string(); - let default_line = || "0:0:0".to_string(); - solang.parse(&mut natspecs, src, &id(), "C"); + let solar_parser = SolarParser::new(); + solar_parser.parse(&mut natspecs, src, &id(), "C"); assert_eq!( natspecs, [ @@ -347,28 +378,28 @@ function f2() {} /** forge-config: default.fuzz.runs = 800 */ function f3() {} NatSpec { contract: id(), function: Some("f1".to_string()), - line: default_line(), + line: "14:134:0".to_string(), docs: "forge-config: default.fuzz.runs = 600\nforge-config: default.fuzz.runs = 601".to_string(), }, // f2 NatSpec { contract: id(), function: Some("f2".to_string()), - line: default_line(), + line: "164:208:0".to_string(), docs: "forge-config: default.fuzz.runs = 700".to_string(), }, // f3 NatSpec { contract: id(), function: Some("f3".to_string()), - line: default_line(), + line: "226:270:0".to_string(), docs: "forge-config: default.fuzz.runs = 800".to_string(), }, // f4 NatSpec { contract: id(), function: Some("f4".to_string()), - line: default_line(), + line: "289:391:0".to_string(), docs: "forge-config: default.fuzz.runs = 1024\nforge-config: default.fuzz.max-test-rejects = 500".to_string(), }, ] @@ -376,7 +407,7 @@ function f2() {} /** forge-config: default.fuzz.runs = 800 */ function f3() {} } #[test] - fn parse_solang_2() { + fn parse_solar_2() { let src = r#" // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; @@ -394,17 +425,16 @@ contract FuzzInlineConf is DSTest { } "#; let mut natspecs = vec![]; - let solang = SolangParser::new(); + let solar = SolarParser::new(); let id = || "inline/FuzzInlineConf.t.sol:FuzzInlineConf".to_string(); - let default_line = || "0:0:0".to_string(); - solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); + solar.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); assert_eq!( natspecs, [ NatSpec { contract: id(), function: Some("testInlineConfFuzz".to_string()), - line: default_line(), + line: "141:255:0".to_string(), docs: "forge-config: default.fuzz.runs = 1024\nforge-config: default.fuzz.max-test-rejects = 500".to_string(), }, ] @@ -466,7 +496,7 @@ contract FuzzInlineConf is DSTest { } #[test] - fn parse_solang_multiple_contracts_from_same_file() { + fn parse_solar_multiple_contracts_from_same_file() { let src = r#" // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; @@ -484,29 +514,28 @@ contract FuzzInlineConf2 is DSTest { } "#; let mut natspecs = vec![]; - let solang = SolangParser::new(); + let solar = SolarParser::new(); let id = || "inline/FuzzInlineConf.t.sol:FuzzInlineConf".to_string(); - let default_line = || "0:0:0".to_string(); - solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); + solar.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); assert_eq!( natspecs, [NatSpec { contract: id(), function: Some("testInlineConfFuzz1".to_string()), - line: default_line(), + line: "142:181:0".to_string(), docs: "forge-config: default.fuzz.runs = 1".to_string(), },] ); let mut natspecs = vec![]; let id = || "inline/FuzzInlineConf2.t.sol:FuzzInlineConf2".to_string(); - solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf2"); + solar.parse(&mut natspecs, src, &id(), "FuzzInlineConf2"); assert_eq!( natspecs, [NatSpec { contract: id(), function: Some("testInlineConfFuzz2".to_string()), - line: default_line(), + line: "264:303:0".to_string(), // should not get config from previous contract docs: "forge-config: default.fuzz.runs = 2".to_string(), },] @@ -529,23 +558,22 @@ contract FuzzInlineConf is DSTest { function testInlineConfFuzz2() {} }"#; let mut natspecs = vec![]; - let solang = SolangParser::new(); + let solar = SolarParser::new(); let id = || "inline/FuzzInlineConf.t.sol:FuzzInlineConf".to_string(); - let default_line = || "0:0:0".to_string(); - solang.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); + solar.parse(&mut natspecs, src, &id(), "FuzzInlineConf"); assert_eq!( natspecs, [ NatSpec { contract: id(), function: None, - line: default_line(), + line: "101:140:0".to_string(), docs: "forge-config: default.fuzz.runs = 1".to_string(), }, NatSpec { contract: id(), function: Some("testInlineConfFuzz1".to_string()), - line: default_line(), + line: "181:220:0".to_string(), docs: "forge-config: default.fuzz.runs = 3".to_string(), } ] diff --git a/crates/forge/tests/cli/inline_config.rs b/crates/forge/tests/cli/inline_config.rs index 4e05d4b6002d7..085cc88a8634f 100644 --- a/crates/forge/tests/cli/inline_config.rs +++ b/crates/forge/tests/cli/inline_config.rs @@ -65,7 +65,7 @@ forgetest!(invalid_profile, |prj, cmd| { .unwrap(); cmd.arg("test").assert_failure().stderr_eq(str![[r#" -Error: Inline config error at test/inline.sol:0:0:0: invalid profile `unknown.fuzz.runs = 2`; valid profiles: default +Error: Inline config error at test/inline.sol:80:123:0: invalid profile `unknown.fuzz.runs = 2`; valid profiles: default "#]]); }); From a5c5be5cae42b4871d87469b913477f05bf380fe Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 6 Jan 2025 03:32:04 +0530 Subject: [PATCH 1826/1963] chore(`bind-json`): replace solang with solar (#9616) --- crates/forge/bin/cmd/bind_json.rs | 160 +++++++++++++++------------- crates/forge/tests/cli/bind_json.rs | 71 ++++++++++++ 2 files changed, 157 insertions(+), 74 deletions(-) diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index d8a361134f50b..efc58c6c7aba6 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -15,12 +15,15 @@ use foundry_compilers::{ }; use foundry_config::Config; use itertools::Itertools; -use rayon::prelude::*; -use solang_parser::pt as solang_ast; +use solar_ast::{ + ast::{self, Arena, FunctionKind, Span, VarMut}, + interface::source_map::FileName, + visit::Visit, +}; +use solar_parse::{interface::Session, Parser as SolarParser}; use std::{ collections::{BTreeMap, BTreeSet}, - fmt, - fmt::Write, + fmt::{self, Write}, path::PathBuf, sync::Arc, }; @@ -85,85 +88,94 @@ impl BindJsonArgs { .unwrap() .1; - // Insert empty bindings file + let sess = Session::builder().with_stderr_emitter().build(); + let result = sess.enter(|| -> solar_parse::interface::Result<()> { + // TODO: Switch back to par_iter_mut and `enter_parallel` after solar update. + sources.0.iter_mut().try_for_each(|(path, source)| { + let mut content = Arc::try_unwrap(std::mem::take(&mut source.content)).unwrap(); + + let arena = Arena::new(); + let mut parser = SolarParser::from_source_code( + &sess, + &arena, + FileName::Real(path.clone()), + content.to_string(), + )?; + let ast = parser.parse_file().map_err(|e| e.emit())?; + + let mut visitor = PreprocessorVisitor::new(); + visitor.visit_source_unit(&ast); + visitor.update(&sess, &mut content); + + source.content = Arc::new(content); + Ok(()) + }) + }); + eyre::ensure!(result.is_ok(), "failed parsing"); + + // Insert empty bindings file. sources.insert(target_path.clone(), Source::new("library JsonBindings {}")); - let sources = Sources( - sources - .0 - .into_par_iter() - .map(|(path, source)| { - let mut locs_to_update = Vec::new(); - let mut content = Arc::unwrap_or_clone(source.content); - let (parsed, _) = solang_parser::parse(&content, 0) - .map_err(|errors| eyre::eyre!("Parser failed: {errors:?}"))?; - - // All function definitions in the file - let mut functions = Vec::new(); - - for part in &parsed.0 { - if let solang_ast::SourceUnitPart::FunctionDefinition(def) = part { - functions.push(def); - } - if let solang_ast::SourceUnitPart::ContractDefinition(contract) = part { - for part in &contract.parts { - match part { - solang_ast::ContractPart::FunctionDefinition(def) => { - functions.push(def); - } - // Remove `immutable` attributes - solang_ast::ContractPart::VariableDefinition(def) => { - for attr in &def.attrs { - if let solang_ast::VariableAttribute::Immutable(loc) = - attr - { - locs_to_update.push(( - loc.start(), - loc.end(), - String::new(), - )); - } - } - } - _ => {} - } - } - }; - } + Ok(PreprocessedState { sources, target_path, project, config }) + } +} - for def in functions { - // If there's no body block, keep the function as is - let Some(solang_ast::Statement::Block { loc, .. }) = def.body else { - continue; - }; - let new_body = match def.ty { - solang_ast::FunctionTy::Modifier => "{ _; }", - _ => "{ revert(); }", - }; - let start = loc.start(); - let end = loc.end(); - locs_to_update.push((start, end + 1, new_body.to_string())); - } +struct PreprocessorVisitor { + updates: Vec<(Span, &'static str)>, +} + +impl PreprocessorVisitor { + fn new() -> Self { + Self { updates: Vec::new() } + } - locs_to_update.sort_by_key(|(start, _, _)| *start); + fn update(mut self, sess: &Session, content: &mut String) { + if self.updates.is_empty() { + return; + } - let mut shift = 0_i64; + let sf = sess.source_map().lookup_source_file(self.updates[0].0.lo()); + let base = sf.start_pos.0; - for (start, end, new) in locs_to_update { - let start = ((start as i64) - shift) as usize; - let end = ((end as i64) - shift) as usize; + self.updates.sort_by_key(|(span, _)| span.lo()); + let mut shift = 0_i64; + for (span, new) in self.updates { + let lo = span.lo() - base; + let hi = span.hi() - base; + let start = ((lo.0 as i64) - shift) as usize; + let end = ((hi.0 as i64) - shift) as usize; - content.replace_range(start..end, new.as_str()); - shift += (end - start) as i64; - shift -= new.len() as i64; - } + content.replace_range(start..end, new); + shift += (end - start) as i64; + shift -= new.len() as i64; + } + } +} - Ok((path, Source::new(content))) - }) - .collect::>>()?, - ); +impl<'ast> Visit<'ast> for PreprocessorVisitor { + fn visit_item_function(&mut self, func: &'ast ast::ItemFunction<'ast>) { + // Replace function bodies with a noop statement. + if let Some(block) = &func.body { + if !block.is_empty() { + let span = block.first().unwrap().span.to(block.last().unwrap().span); + let new_body = match func.kind { + FunctionKind::Modifier => "_;", + _ => "revert();", + }; + self.updates.push((span, new_body)); + } + } - Ok(PreprocessedState { sources, target_path, project, config }) + self.walk_item_function(func) + } + + fn visit_variable_definition(&mut self, var: &'ast ast::VariableDefinition<'ast>) { + // Remove `immutable` attributes. + if let Some(VarMut::Immutable) = var.mutability { + self.updates.push((var.span, "")); + } + + self.walk_variable_definition(var) } } diff --git a/crates/forge/tests/cli/bind_json.rs b/crates/forge/tests/cli/bind_json.rs index bdc8f0fa19ec9..fcc081f6b6f06 100644 --- a/crates/forge/tests/cli/bind_json.rs +++ b/crates/forge/tests/cli/bind_json.rs @@ -1,3 +1,5 @@ +use foundry_test_utils::snapbox; + // tests complete bind-json workflow // ensures that we can run forge-bind even if files are depending on yet non-existent bindings and // that generated bindings are correct @@ -50,5 +52,74 @@ contract BindJsonTest is Test { .unwrap(); cmd.arg("bind-json").assert_success(); + + snapbox::assert_data_eq!( + snapbox::Data::read_from(&prj.root().join("utils/JsonBindings.sol"), None), + snapbox::str![[r#" +// Automatically generated by forge bind-json. + +pragma solidity >=0.6.2 <0.9.0; +pragma experimental ABIEncoderV2; + +import {BindJsonTest, TopLevelStruct} from "test/JsonBindings.sol"; + +interface Vm { + 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 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); +} + +library JsonBindings { + Vm constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); + + string constant schema_TopLevelStruct = "TopLevelStruct(uint256 param1,int8 param2)"; + string constant schema_ContractLevelStruct = "ContractLevelStruct(address[][] param1,address addrParam)"; + + function serialize(TopLevelStruct memory value) internal pure returns (string memory) { + return vm.serializeJsonType(schema_TopLevelStruct, abi.encode(value)); + } + + function serialize(TopLevelStruct memory value, string memory objectKey, string memory valueKey) internal returns (string memory) { + return vm.serializeJsonType(objectKey, valueKey, schema_TopLevelStruct, abi.encode(value)); + } + + function deserializeTopLevelStruct(string memory json) public pure returns (TopLevelStruct memory) { + return abi.decode(vm.parseJsonType(json, schema_TopLevelStruct), (TopLevelStruct)); + } + + function deserializeTopLevelStruct(string memory json, string memory path) public pure returns (TopLevelStruct memory) { + return abi.decode(vm.parseJsonType(json, path, schema_TopLevelStruct), (TopLevelStruct)); + } + + function deserializeTopLevelStructArray(string memory json, string memory path) public pure returns (TopLevelStruct[] memory) { + return abi.decode(vm.parseJsonTypeArray(json, path, schema_TopLevelStruct), (TopLevelStruct[])); + } + + function serialize(BindJsonTest.ContractLevelStruct memory value) internal pure returns (string memory) { + return vm.serializeJsonType(schema_ContractLevelStruct, abi.encode(value)); + } + + function serialize(BindJsonTest.ContractLevelStruct memory value, string memory objectKey, string memory valueKey) internal returns (string memory) { + return vm.serializeJsonType(objectKey, valueKey, schema_ContractLevelStruct, abi.encode(value)); + } + + function deserializeContractLevelStruct(string memory json) public pure returns (BindJsonTest.ContractLevelStruct memory) { + return abi.decode(vm.parseJsonType(json, schema_ContractLevelStruct), (BindJsonTest.ContractLevelStruct)); + } + + function deserializeContractLevelStruct(string memory json, string memory path) public pure returns (BindJsonTest.ContractLevelStruct memory) { + return abi.decode(vm.parseJsonType(json, path, schema_ContractLevelStruct), (BindJsonTest.ContractLevelStruct)); + } + + function deserializeContractLevelStructArray(string memory json, string memory path) public pure returns (BindJsonTest.ContractLevelStruct[] memory) { + return abi.decode(vm.parseJsonTypeArray(json, path, schema_ContractLevelStruct), (BindJsonTest.ContractLevelStruct[])); + } +} + +"#]], + ); + cmd.forge_fuse().args(["test"]).assert_success(); }); From 15a9f177611fb0bdf8c8ff46b7405788fcee4279 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 6 Jan 2025 09:29:05 +0100 Subject: [PATCH 1827/1963] chore(deps): bump solar 0.1.1 (#9627) --- Cargo.lock | 49 +++++++++++++------------- Cargo.toml | 5 ++- crates/chisel/src/solidity_helper.rs | 2 +- crates/config/Cargo.toml | 1 - crates/config/src/inline/natspec.rs | 10 +++--- crates/evm/traces/src/debug/sources.rs | 5 +-- crates/forge/Cargo.toml | 1 - crates/forge/bin/cmd/bind_json.rs | 28 +++++++++------ crates/forge/bin/cmd/geiger.rs | 14 +++++--- 9 files changed, 61 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e94ba19202f9d..26cdab3bbc495 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -869,6 +869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4" dependencies = [ "anstyle", + "memchr", "unicode-width 0.2.0", ] @@ -3486,7 +3487,6 @@ dependencies = [ "similar", "similar-asserts", "solang-parser", - "solar-ast", "solar-parse", "soldeer-commands", "strum", @@ -3858,9 +3858,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d817beee8c566a99f4267f25ff63d0de46c442948496ecef91ead56e3383090c" +checksum = "f67e3eab56847dcf269eb186226f95874b171e262952cff6c910da36b1469e10" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3895,9 +3895,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec784a3a809ba2ee723fcfeb737a6ac90b4fd1e4d048c2d49fed6723bd35547" +checksum = "865b00448dc2a5d56bae287c36fa716379ffcdd937aefb7758bd20b62024d234" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3905,9 +3905,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44549c33e5a03408c8d40c36d764b7e84d261258ef481c19e4a612e609fdf8a4" +checksum = "668972ba511f80895ea12c75cd12fccd6627c26e64763799d83978b4e0916cae" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3929,9 +3929,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a438605ae74689752b2f717165daac15766f1b2a166d2095715d5f9407084b52" +checksum = "5a24f7f2a7458171e055c0cb33272f5eccaefbd96d791d74177d9a1fca048f74" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3944,9 +3944,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ac6d85c3e2d12585f8e698b12ed4880b02716ec7fde5d62de9a194e62f4e36" +checksum = "8005271a079bc6470c61d4145d2e390a827b1ccbb96abb7b69b088f17ffb95e0" dependencies = [ "alloy-primitives", "cfg-if", @@ -3991,7 +3991,6 @@ dependencies = [ "serde_json", "serde_regex", "similar-asserts", - "solar-ast", "solar-parse", "tempfile", "thiserror 2.0.9", @@ -8499,9 +8498,9 @@ dependencies = [ [[package]] name = "solar-ast" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5aeaf7a4bd326242c909bd287291226a540b62b36fa5824880248f4b1d4d6af" +checksum = "5d3f6c4a476a16dcd36933a70ecdb0a807f8949cc5f3c4c1984e3748666bd714" dependencies = [ "alloy-primitives", "bumpalo", @@ -8518,18 +8517,18 @@ dependencies = [ [[package]] name = "solar-config" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d00d672a40a1a3620d7696f01a2d3301abf883d8168e1a9da3bf83f0c8e343" +checksum = "d40434a61f2c14a9e3777fbc478167bddee9828532fc26c57e416e9277916b09" dependencies = [ "strum", ] [[package]] name = "solar-data-structures" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6e4eb0b72ed7adbb808897c85de08ea99609774a58c72e3dce55c758043ca2" +checksum = "71d07263243b313296eca18f18eda3a190902dc3284bf67ceff29b8b54dac3e6" dependencies = [ "bumpalo", "index_vec", @@ -8542,9 +8541,9 @@ dependencies = [ [[package]] name = "solar-interface" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21fb8925638f3da1bba7a9a6ebeac3511e5c6354f921f2bb2e1ddce4ac70c107" +checksum = "9a87009b6989b2cc44d8381e3b86ff3b90280d54a60321919b6416214cd602f3" dependencies = [ "annotate-snippets", "anstream", @@ -8563,16 +8562,16 @@ dependencies = [ "solar-config", "solar-data-structures", "solar-macros", - "thiserror 1.0.69", + "thiserror 2.0.9", "tracing", "unicode-width 0.2.0", ] [[package]] name = "solar-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0cc54b74e214647c1bbfc098d080cc5deac77f8dcb99aca91747276b01a15ad" +checksum = "970d7c774741f786d62cab78290e47d845b0b9c0c9d094a1642aced1d7946036" dependencies = [ "proc-macro2", "quote", @@ -8581,9 +8580,9 @@ dependencies = [ [[package]] name = "solar-parse" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82c3659c15975cd80e5e1c44591278c230c59ad89082d797837499a4784e1b" +checksum = "2e1e2d07fae218aca1b4cca81216e5c9ad7822516d48a28f11e2eaa8ffa5b249" dependencies = [ "alloy-primitives", "bitflags 2.6.0", diff --git a/Cargo.toml b/Cargo.toml index d4ccda8e5564f..de388f21b82e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,11 +171,10 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.9.0", default-features = false } -foundry-compilers = { version = "0.12.8", default-features = false } +foundry-compilers = { version = "0.12.9", default-features = false } foundry-fork-db = "0.10.0" solang-parser = "=0.3.3" -solar-ast = { version = "=0.1.0", default-features = false } -solar-parse = { version = "=0.1.0", default-features = false } +solar-parse = { version = "=0.1.1", default-features = false } ## revm revm = { version = "19.0.0", default-features = false } diff --git a/crates/chisel/src/solidity_helper.rs b/crates/chisel/src/solidity_helper.rs index 465b7b535c36e..c9df0c357214f 100644 --- a/crates/chisel/src/solidity_helper.rs +++ b/crates/chisel/src/solidity_helper.rs @@ -15,7 +15,7 @@ use rustyline::{ Helper, }; use solar_parse::{ - interface::{Pos, Session, SessionGlobals}, + interface::{Session, SessionGlobals}, token::{Token, TokenKind}, Lexer, }; diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 560a178231ee4..c7efcaec979a8 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -22,7 +22,6 @@ alloy-primitives = { workspace = true, features = ["serde"] } revm-primitives.workspace = true solar-parse.workspace = true -solar-ast.workspace = true dirs-next = "2" dunce.workspace = true diff --git a/crates/config/src/inline/natspec.rs b/crates/config/src/inline/natspec.rs index 013e53c10827b..2cb605f033d98 100644 --- a/crates/config/src/inline/natspec.rs +++ b/crates/config/src/inline/natspec.rs @@ -6,11 +6,13 @@ use foundry_compilers::{ }; use itertools::Itertools; use serde_json::Value; -use solar_ast::{ - ast::{Arena, CommentKind, Item, ItemKind}, - interface::{self, Session}, +use solar_parse::{ + ast::{ + interface::{self, Session}, + Arena, CommentKind, Item, ItemKind, + }, + Parser, }; -use solar_parse::Parser; use std::{collections::BTreeMap, path::Path}; /// Convenient struct to hold in-line per-test configurations diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index b2e37e32d9344..5c0caa5793c1a 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -11,10 +11,7 @@ use foundry_compilers::{ use foundry_evm_core::utils::PcIcMap; use foundry_linking::Linker; use rayon::prelude::*; -use solar_parse::{ - interface::{Pos, Session}, - Parser, -}; +use solar_parse::{interface::Session, Parser}; use std::{ collections::{BTreeMap, HashMap}, ops::Range, diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index cbbfa814daf12..8deafcd5d4dce 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -89,7 +89,6 @@ semver.workspace = true serde_json.workspace = true similar = { version = "2", features = ["inline"] } solang-parser.workspace = true -solar-ast.workspace = true solar-parse.workspace = true strum = { workspace = true, features = ["derive"] } thiserror.workspace = true diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index efc58c6c7aba6..5e63b14d84981 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -15,15 +15,16 @@ use foundry_compilers::{ }; use foundry_config::Config; use itertools::Itertools; -use solar_ast::{ - ast::{self, Arena, FunctionKind, Span, VarMut}, - interface::source_map::FileName, - visit::Visit, +use rayon::prelude::*; +use solar_parse::{ + ast::{self, interface::source_map::FileName, visit::Visit, Arena, FunctionKind, Span, VarMut}, + interface::Session, + Parser as SolarParser, }; -use solar_parse::{interface::Session, Parser as SolarParser}; use std::{ collections::{BTreeMap, BTreeSet}, fmt::{self, Write}, + ops::ControlFlow, path::PathBuf, sync::Arc, }; @@ -89,9 +90,8 @@ impl BindJsonArgs { .1; let sess = Session::builder().with_stderr_emitter().build(); - let result = sess.enter(|| -> solar_parse::interface::Result<()> { - // TODO: Switch back to par_iter_mut and `enter_parallel` after solar update. - sources.0.iter_mut().try_for_each(|(path, source)| { + let result = sess.enter_parallel(|| -> solar_parse::interface::Result<()> { + sources.0.par_iter_mut().try_for_each(|(path, source)| { let mut content = Arc::try_unwrap(std::mem::take(&mut source.content)).unwrap(); let arena = Arena::new(); @@ -153,7 +153,12 @@ impl PreprocessorVisitor { } impl<'ast> Visit<'ast> for PreprocessorVisitor { - fn visit_item_function(&mut self, func: &'ast ast::ItemFunction<'ast>) { + type BreakValue = solar_parse::interface::data_structures::Never; + + fn visit_item_function( + &mut self, + func: &'ast ast::ItemFunction<'ast>, + ) -> ControlFlow { // Replace function bodies with a noop statement. if let Some(block) = &func.body { if !block.is_empty() { @@ -169,7 +174,10 @@ impl<'ast> Visit<'ast> for PreprocessorVisitor { self.walk_item_function(func) } - fn visit_variable_definition(&mut self, var: &'ast ast::VariableDefinition<'ast>) { + fn visit_variable_definition( + &mut self, + var: &'ast ast::VariableDefinition<'ast>, + ) -> ControlFlow { // Remove `immutable` attributes. if let Some(VarMut::Immutable) = var.mutability { self.updates.push((var.span, "")); diff --git a/crates/forge/bin/cmd/geiger.rs b/crates/forge/bin/cmd/geiger.rs index 6d4c735a9909c..ace3bbe1af117 100644 --- a/crates/forge/bin/cmd/geiger.rs +++ b/crates/forge/bin/cmd/geiger.rs @@ -4,9 +4,11 @@ use foundry_cli::utils::LoadConfig; use foundry_compilers::{resolver::parse::SolData, Graph}; use foundry_config::{impl_figment_convert_basic, Config}; use itertools::Itertools; -use solar_ast::visit::Visit; -use solar_parse::{ast, interface::Session}; -use std::path::{Path, PathBuf}; +use solar_parse::{ast, ast::visit::Visit, interface::Session}; +use std::{ + ops::ControlFlow, + path::{Path, PathBuf}, +}; /// CLI arguments for `forge geiger`. #[derive(Clone, Debug, Parser)] @@ -144,7 +146,9 @@ impl<'a> Visitor<'a> { } impl<'ast> Visit<'ast> for Visitor<'_> { - fn visit_expr(&mut self, expr: &'ast ast::Expr<'ast>) { + type BreakValue = solar_parse::interface::data_structures::Never; + + fn visit_expr(&mut self, expr: &'ast ast::Expr<'ast>) -> ControlFlow { if let ast::ExprKind::Call(lhs, _args) = &expr.kind { if let ast::ExprKind::Member(_lhs, member) = &lhs.kind { if self.unsafe_cheatcodes.iter().any(|c| c.as_str() == member.as_str()) { @@ -154,6 +158,6 @@ impl<'ast> Visit<'ast> for Visitor<'_> { } } } - self.walk_expr(expr); + self.walk_expr(expr) } } From dc8d980ee312abdc24a0c92193cf433be23aa1df Mon Sep 17 00:00:00 2001 From: Marquis Shanahan <29431502+9547@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:02:33 +0800 Subject: [PATCH 1828/1963] chore(forge): remove `forge debug` subcommand (#9606) forge: rm subcommand debug Co-authored-by: 9547 Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/forge/bin/cmd/debug.rs | 69 ----------------------------------- crates/forge/bin/cmd/mod.rs | 1 - crates/forge/bin/main.rs | 1 - crates/forge/bin/opts.rs | 8 +--- 4 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 crates/forge/bin/cmd/debug.rs diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs deleted file mode 100644 index 5ccfc13d57d09..0000000000000 --- a/crates/forge/bin/cmd/debug.rs +++ /dev/null @@ -1,69 +0,0 @@ -use clap::{Parser, ValueHint}; -use forge_script::ScriptArgs; -use forge_verify::retry::RETRY_VERIFY_ON_CREATE; -use foundry_cli::opts::CoreBuildArgs; -use foundry_common::evm::EvmArgs; -use std::path::PathBuf; - -// Loads project's figment and merges the build cli arguments into it -foundry_config::impl_figment_convert!(DebugArgs, opts, evm_args); - -/// CLI arguments for `forge debug`. -#[derive(Clone, Debug, Parser)] -pub struct DebugArgs { - /// The contract you want to run. Either the file path or contract name. - /// - /// If multiple contracts exist in the same file you must specify the target contract with - /// --target-contract. - #[arg(value_hint = ValueHint::FilePath)] - pub path: PathBuf, - - /// Arguments to pass to the script function. - pub args: Vec, - - /// The name of the contract you want to run. - #[arg(long, visible_alias = "tc", value_name = "CONTRACT_NAME")] - pub target_contract: Option, - - /// The signature of the function you want to call in the contract, or raw calldata. - #[arg(long, short, default_value = "run()", value_name = "SIGNATURE")] - pub sig: String, - - /// Open the script in the debugger. - #[arg(long)] - pub debug: bool, - - /// File path to dump execution details as JSON. - #[arg( - long, - requires = "debug", - value_hint = ValueHint::FilePath, - value_name = "PATH" - )] - pub dump: Option, - - #[command(flatten)] - pub opts: CoreBuildArgs, - - #[command(flatten)] - pub evm_args: EvmArgs, -} - -impl DebugArgs { - pub async fn run(self) -> eyre::Result<()> { - let script = ScriptArgs { - path: self.path.to_str().expect("Invalid path string.").to_string(), - args: self.args, - target_contract: self.target_contract, - sig: self.sig, - gas_estimate_multiplier: 130, - opts: self.opts, - evm_args: self.evm_args, - debug: true, - dump: self.dump, - retry: RETRY_VERIFY_ON_CREATE, - ..Default::default() - }; - script.run_script().await - } -} diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index 427b25fb0c50d..d6a70c9da7a95 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -48,7 +48,6 @@ pub mod compiler; pub mod config; pub mod coverage; pub mod create; -pub mod debug; pub mod doc; pub mod eip712; pub mod flatten; diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index d60c1639a05a5..60a55af7a82d6 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -58,7 +58,6 @@ fn run() -> Result<()> { cmd.run().map(drop) } } - ForgeSubcommand::Debug(cmd) => utils::block_on(cmd.run()), ForgeSubcommand::VerifyContract(args) => utils::block_on(args.run()), ForgeSubcommand::VerifyCheck(args) => utils::block_on(args.run()), ForgeSubcommand::VerifyBytecode(cmd) => utils::block_on(cmd.run()), diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index 380cb61d403a5..f32ec02226547 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -1,7 +1,7 @@ use crate::cmd::{ bind::BindArgs, bind_json, build::BuildArgs, cache::CacheArgs, clone::CloneArgs, - compiler::CompilerArgs, config, coverage, create::CreateArgs, debug::DebugArgs, doc::DocArgs, - eip712, flatten, fmt::FmtArgs, geiger, generate, init::InitArgs, inspect, install::InstallArgs, + compiler::CompilerArgs, config, coverage, create::CreateArgs, doc::DocArgs, eip712, flatten, + fmt::FmtArgs, geiger, generate, init::InitArgs, inspect, install::InstallArgs, remappings::RemappingArgs, remove::RemoveArgs, selectors::SelectorsSubcommands, snapshot, soldeer, test, tree, update, }; @@ -61,10 +61,6 @@ pub enum ForgeSubcommand { /// Clone a contract from Etherscan. Clone(CloneArgs), - /// Debugs a single smart contract as a script. - #[command(visible_alias = "d")] - Debug(DebugArgs), - /// Update one or multiple dependencies. /// /// If no arguments are provided, then all dependencies are updated. From 782787b32127b33c5453f5e569d218c65f2db217 Mon Sep 17 00:00:00 2001 From: Marquis Shanahan <29431502+9547@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:32:00 +0800 Subject: [PATCH 1829/1963] feat(test): add repro issue8566 testcase (#9617) * feat(test): add Issue8566 testcase Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> * bump alloy to 0.8.18 Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --------- Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --- Cargo.toml | 14 +++++++------- crates/forge/tests/it/repros.rs | 3 +++ testdata/default/repros/Issue8566.t.sol | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 testdata/default/repros/Issue8566.t.sol diff --git a/Cargo.toml b/Cargo.toml index de388f21b82e1..304597c16236c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -210,17 +210,17 @@ alloy-node-bindings = { version = "0.9.0", default-features = false } alloy-network-primitives = { version = "0.9.0", default-features = false } ## alloy-core -alloy-dyn-abi = "0.8.14" -alloy-json-abi = "0.8.14" -alloy-primitives = { version = "0.8.14", features = [ +alloy-dyn-abi = "0.8.18" +alloy-json-abi = "0.8.18" +alloy-primitives = { version = "0.8.18", features = [ "getrandom", "rand", "map-foldhash", ] } -alloy-sol-macro-expander = "0.8.14" -alloy-sol-macro-input = "0.8.14" -alloy-sol-types = "0.8.14" -syn-solidity = "0.8.14" +alloy-sol-macro-expander = "0.8.18" +alloy-sol-macro-input = "0.8.18" +alloy-sol-types = "0.8.18" +syn-solidity = "0.8.18" alloy-chains = "0.1" alloy-rlp = "0.3" diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 2a47d3d3efd16..863b8b28479e4 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -389,3 +389,6 @@ test_repro!(8971; |config| { // https://github.com/foundry-rs/foundry/issues/8639 test_repro!(8639); + +// https://github.com/foundry-rs/foundry/issues/8566 +test_repro!(8566); diff --git a/testdata/default/repros/Issue8566.t.sol b/testdata/default/repros/Issue8566.t.sol new file mode 100644 index 0000000000000..f300d096f7a22 --- /dev/null +++ b/testdata/default/repros/Issue8566.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +// https://github.com/foundry-rs/foundry/issues/8566 +contract Issue8566Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testParseJsonUint() public { + string memory json = + "{ \"1284\": { \"addRewardInfo\": { \"amount\": 74258.225772486694040708e18, \"rewardPerSec\": 0.03069536448928848133e20 } } }"; + + assertEq(74258225772486694040708, vm.parseJsonUint(json, ".1284.addRewardInfo.amount")); + assertEq(3069536448928848133, vm.parseJsonUint(json, ".1284.addRewardInfo.rewardPerSec")); + } +} From e4fdc45558466ff24c347a179f678fb1b02c0bdc Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:46:26 +0100 Subject: [PATCH 1830/1963] chore: standardize use of `opts` / `args` (#9629) * globalopts -> globalargs * consistently use opts for configurations, args for command line arguments --- crates/anvil/src/anvil.rs | 8 +-- crates/anvil/src/cmd.rs | 80 +++++++++------------ crates/cast/bin/args.rs | 6 +- crates/cast/bin/cmd/storage.rs | 4 +- crates/chisel/bin/main.rs | 12 ++-- crates/cli/src/opts/build/core.rs | 22 +++--- crates/cli/src/opts/build/mod.rs | 16 ++--- crates/cli/src/opts/build/paths.rs | 8 +-- crates/cli/src/opts/global.rs | 6 +- crates/cli/src/opts/mod.rs | 4 +- crates/cli/src/opts/{ethereum.rs => rpc.rs} | 0 crates/forge/bin/cmd/bind.rs | 12 ++-- crates/forge/bin/cmd/bind_json.rs | 6 +- crates/forge/bin/cmd/build.rs | 8 +-- crates/forge/bin/cmd/clone.rs | 12 ++-- crates/forge/bin/cmd/config.rs | 6 +- crates/forge/bin/cmd/create.rs | 22 +++--- crates/forge/bin/cmd/debug.rs | 69 ++++++++++++++++++ crates/forge/bin/cmd/eip712.rs | 6 +- crates/forge/bin/cmd/flatten.rs | 8 +-- crates/forge/bin/cmd/init.rs | 12 ++-- crates/forge/bin/cmd/inspect.rs | 8 +-- crates/forge/bin/cmd/mod.rs | 4 +- crates/forge/bin/cmd/selectors.rs | 28 ++++---- crates/forge/bin/cmd/test/mod.rs | 37 +++++----- crates/forge/bin/cmd/tree.rs | 6 +- crates/forge/bin/cmd/watch.rs | 2 +- crates/forge/bin/opts.rs | 6 +- crates/script/src/execute.rs | 2 +- crates/script/src/lib.rs | 21 +++--- crates/script/src/verify.rs | 6 +- 31 files changed, 250 insertions(+), 197 deletions(-) rename crates/cli/src/opts/{ethereum.rs => rpc.rs} (100%) create mode 100644 crates/forge/bin/cmd/debug.rs diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 48e17ed44d291..ffdcc1755945b 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -3,7 +3,7 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; use eyre::Result; -use foundry_cli::{opts::GlobalOpts, utils}; +use foundry_cli::{opts::GlobalArgs, utils}; #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] @@ -13,9 +13,9 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[derive(Parser)] #[command(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] pub struct Anvil { - /// Include the global options. + /// Include the global arguments. #[command(flatten)] - pub global: GlobalOpts, + pub global: GlobalArgs, #[command(flatten)] pub node: NodeArgs, @@ -50,7 +50,7 @@ fn run() -> Result<()> { let mut args = Anvil::parse(); args.global.init()?; - args.node.evm_opts.resolve_rpc_alias(); + args.node.evm.resolve_rpc_alias(); if let Some(cmd) = &args.cmd { match cmd { diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 19e9193f908b7..8be6be750c54a 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -185,7 +185,7 @@ pub struct NodeArgs { pub transaction_block_keeper: Option, #[command(flatten)] - pub evm_opts: AnvilEvmArgs, + pub evm: AnvilEvmArgs, #[command(flatten)] pub server_config: ServerConfig, @@ -209,15 +209,12 @@ const DEFAULT_DUMP_INTERVAL: Duration = Duration::from_secs(60); impl NodeArgs { pub fn into_node_config(self) -> eyre::Result { let genesis_balance = Unit::ETHER.wei().saturating_mul(U256::from(self.balance)); - let compute_units_per_second = if self.evm_opts.no_rate_limit { - Some(u64::MAX) - } else { - self.evm_opts.compute_units_per_second - }; + let compute_units_per_second = + if self.evm.no_rate_limit { Some(u64::MAX) } else { self.evm.compute_units_per_second }; let hardfork = match &self.hardfork { Some(hf) => { - if self.evm_opts.optimism { + if self.evm.optimism { Some(OptimismHardfork::from_str(hf)?.into()) } else { Some(EthereumHardfork::from_str(hf)?.into()) @@ -227,9 +224,9 @@ impl NodeArgs { }; Ok(NodeConfig::default() - .with_gas_limit(self.evm_opts.gas_limit) - .disable_block_gas_limit(self.evm_opts.disable_block_gas_limit) - .with_gas_price(self.evm_opts.gas_price) + .with_gas_limit(self.evm.gas_limit) + .disable_block_gas_limit(self.evm.disable_block_gas_limit) + .with_gas_price(self.evm.gas_price) .with_hardfork(hardfork) .with_blocktime(self.block_time) .with_no_mining(self.no_mining) @@ -238,54 +235,50 @@ impl NodeArgs { .with_genesis_balance(genesis_balance) .with_genesis_timestamp(self.timestamp) .with_port(self.port) - .with_fork_choice( - match (self.evm_opts.fork_block_number, self.evm_opts.fork_transaction_hash) { - (Some(block), None) => Some(ForkChoice::Block(block)), - (None, Some(hash)) => Some(ForkChoice::Transaction(hash)), - _ => { - self.evm_opts.fork_url.as_ref().and_then(|f| f.block).map(ForkChoice::Block) - } - }, - ) - .with_fork_headers(self.evm_opts.fork_headers) - .with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from).map(U256::from)) - .fork_request_timeout(self.evm_opts.fork_request_timeout.map(Duration::from_millis)) - .fork_request_retries(self.evm_opts.fork_request_retries) - .fork_retry_backoff(self.evm_opts.fork_retry_backoff.map(Duration::from_millis)) + .with_fork_choice(match (self.evm.fork_block_number, self.evm.fork_transaction_hash) { + (Some(block), None) => Some(ForkChoice::Block(block)), + (None, Some(hash)) => Some(ForkChoice::Transaction(hash)), + _ => self.evm.fork_url.as_ref().and_then(|f| f.block).map(ForkChoice::Block), + }) + .with_fork_headers(self.evm.fork_headers) + .with_fork_chain_id(self.evm.fork_chain_id.map(u64::from).map(U256::from)) + .fork_request_timeout(self.evm.fork_request_timeout.map(Duration::from_millis)) + .fork_request_retries(self.evm.fork_request_retries) + .fork_retry_backoff(self.evm.fork_retry_backoff.map(Duration::from_millis)) .fork_compute_units_per_second(compute_units_per_second) - .with_eth_rpc_url(self.evm_opts.fork_url.map(|fork| fork.url)) - .with_base_fee(self.evm_opts.block_base_fee_per_gas) - .disable_min_priority_fee(self.evm_opts.disable_min_priority_fee) - .with_storage_caching(self.evm_opts.no_storage_caching) + .with_eth_rpc_url(self.evm.fork_url.map(|fork| fork.url)) + .with_base_fee(self.evm.block_base_fee_per_gas) + .disable_min_priority_fee(self.evm.disable_min_priority_fee) + .with_storage_caching(self.evm.no_storage_caching) .with_server_config(self.server_config) .with_host(self.host) .set_silent(shell::is_quiet()) .set_config_out(self.config_out) - .with_chain_id(self.evm_opts.chain_id) + .with_chain_id(self.evm.chain_id) .with_transaction_order(self.order) .with_genesis(self.init) - .with_steps_tracing(self.evm_opts.steps_tracing) - .with_print_logs(!self.evm_opts.disable_console_log) - .with_auto_impersonate(self.evm_opts.auto_impersonate) + .with_steps_tracing(self.evm.steps_tracing) + .with_print_logs(!self.evm.disable_console_log) + .with_auto_impersonate(self.evm.auto_impersonate) .with_ipc(self.ipc) - .with_code_size_limit(self.evm_opts.code_size_limit) - .disable_code_size_limit(self.evm_opts.disable_code_size_limit) + .with_code_size_limit(self.evm.code_size_limit) + .disable_code_size_limit(self.evm.disable_code_size_limit) .set_pruned_history(self.prune_history) .with_init_state(self.load_state.or_else(|| self.state.and_then(|s| s.state))) .with_transaction_block_keeper(self.transaction_block_keeper) .with_max_persisted_states(self.max_persisted_states) - .with_optimism(self.evm_opts.optimism) - .with_odyssey(self.evm_opts.odyssey) - .with_disable_default_create2_deployer(self.evm_opts.disable_default_create2_deployer) + .with_optimism(self.evm.optimism) + .with_odyssey(self.evm.odyssey) + .with_disable_default_create2_deployer(self.evm.disable_default_create2_deployer) .with_slots_in_an_epoch(self.slots_in_an_epoch) - .with_memory_limit(self.evm_opts.memory_limit) + .with_memory_limit(self.evm.memory_limit) .with_cache_path(self.cache_path)) } fn account_generator(&self) -> AccountGenerator { let mut gen = AccountGenerator::new(self.accounts as usize) .phrase(DEFAULT_MNEMONIC) - .chain_id(self.evm_opts.chain_id.unwrap_or_else(|| CHAIN_ID.into())); + .chain_id(self.evm.chain_id.unwrap_or_else(|| CHAIN_ID.into())); if let Some(ref mnemonic) = self.mnemonic { gen = gen.phrase(mnemonic); } else if let Some(count) = self.mnemonic_random { @@ -845,10 +838,7 @@ mod tests { "--fork-header", "Referrer: example.com", ]); - assert_eq!( - args.evm_opts.fork_headers, - vec!["User-Agent: test-agent", "Referrer: example.com"] - ); + assert_eq!(args.evm.fork_headers, vec!["User-Agent: test-agent", "Referrer: example.com"]); } #[test] @@ -869,7 +859,7 @@ mod tests { #[test] fn can_parse_disable_block_gas_limit() { let args: NodeArgs = NodeArgs::parse_from(["anvil", "--disable-block-gas-limit"]); - assert!(args.evm_opts.disable_block_gas_limit); + assert!(args.evm.disable_block_gas_limit); let args = NodeArgs::try_parse_from(["anvil", "--disable-block-gas-limit", "--gas-limit", "100"]); @@ -879,7 +869,7 @@ mod tests { #[test] fn can_parse_disable_code_size_limit() { let args: NodeArgs = NodeArgs::parse_from(["anvil", "--disable-code-size-limit"]); - assert!(args.evm_opts.disable_code_size_limit); + assert!(args.evm.disable_code_size_limit); let args = NodeArgs::try_parse_from([ "anvil", diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index d9c86e9019ab6..657fd02496734 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -9,7 +9,7 @@ use alloy_primitives::{Address, B256, U256}; use alloy_rpc_types::BlockId; use clap::{Parser, Subcommand, ValueHint}; use eyre::Result; -use foundry_cli::opts::{EtherscanOpts, GlobalOpts, RpcOpts}; +use foundry_cli::opts::{EtherscanOpts, GlobalArgs, RpcOpts}; use foundry_common::ens::NameOrAddress; use std::{path::PathBuf, str::FromStr}; @@ -31,9 +31,9 @@ const VERSION_MESSAGE: &str = concat!( next_display_order = None, )] pub struct Cast { - /// Include the global options. + /// Include the global arguments. #[command(flatten)] - pub global: GlobalOpts, + pub global: GlobalArgs, #[command(subcommand)] pub cmd: CastSubcommand, diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 7121f1a98c416..4499fea1cfc1e 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -10,7 +10,7 @@ use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Table}; use eyre::Result; use foundry_block_explorers::Client; use foundry_cli::{ - opts::{CoreBuildArgs, EtherscanOpts, RpcOpts}, + opts::{BuildOpts, EtherscanOpts, RpcOpts}, utils, }; use foundry_common::{ @@ -64,7 +64,7 @@ pub struct StorageArgs { etherscan: EtherscanOpts, #[command(flatten)] - build: CoreBuildArgs, + build: BuildOpts, } impl_figment_convert_cast!(StorageArgs); diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index ca3fc1ff593ec..797da8a1225e4 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -11,7 +11,7 @@ use clap::{Parser, Subcommand}; use eyre::Context; use foundry_cli::{ handler, - opts::{CoreBuildArgs, GlobalOpts}, + opts::{BuildOpts, GlobalArgs}, utils::{self, LoadConfig}, }; use foundry_common::{evm::EvmArgs, fs}; @@ -35,7 +35,7 @@ extern crate foundry_common; static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; // Loads project's figment and merges the build cli arguments into it -foundry_config::merge_impl_figment_convert!(Chisel, opts, evm_args); +foundry_config::merge_impl_figment_convert!(Chisel, build, evm); const VERSION_MESSAGE: &str = concat!( env!("CARGO_PKG_VERSION"), @@ -50,9 +50,9 @@ const VERSION_MESSAGE: &str = concat!( #[derive(Debug, Parser)] #[command(name = "chisel", version = VERSION_MESSAGE)] pub struct Chisel { - /// Include the global options. + /// Include the global arguments. #[command(flatten)] - pub global: GlobalOpts, + pub global: GlobalArgs, #[command(subcommand)] pub cmd: Option, @@ -73,10 +73,10 @@ pub struct Chisel { pub no_vm: bool, #[command(flatten)] - pub opts: CoreBuildArgs, + pub build: BuildOpts, #[command(flatten)] - pub evm_args: EvmArgs, + pub evm: EvmArgs, } /// Chisel binary subcommands diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 52a925ebb16af..9491ff35fb094 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -1,5 +1,5 @@ -use super::ProjectPathsArgs; -use crate::{opts::CompilerArgs, utils::LoadConfig}; +use super::ProjectPathOpts; +use crate::{opts::CompilerOpts, utils::LoadConfig}; use clap::{Parser, ValueHint}; use eyre::Result; use foundry_compilers::{ @@ -23,7 +23,7 @@ use std::path::PathBuf; #[derive(Clone, Debug, Default, Serialize, Parser)] #[command(next_help_heading = "Build options")] -pub struct CoreBuildArgs { +pub struct BuildOpts { /// Clear the cache and artifacts folder and recompile. #[arg(long, help_heading = "Cache options")] #[serde(skip)] @@ -138,14 +138,14 @@ pub struct CoreBuildArgs { #[command(flatten)] #[serde(flatten)] - pub compiler: CompilerArgs, + pub compiler: CompilerOpts, #[command(flatten)] #[serde(flatten)] - pub project_paths: ProjectPathsArgs, + pub project_paths: ProjectPathOpts, } -impl CoreBuildArgs { +impl BuildOpts { /// Returns the `Project` for the current workspace /// /// This loads the `foundry_config::Config` for the current workspace (see @@ -164,8 +164,8 @@ impl CoreBuildArgs { } // Loads project's figment and merges the build cli arguments into it -impl<'a> From<&'a CoreBuildArgs> for Figment { - fn from(args: &'a CoreBuildArgs) -> Self { +impl<'a> From<&'a BuildOpts> for Figment { + fn from(args: &'a BuildOpts) -> Self { let mut figment = if let Some(ref config_path) = args.project_paths.config_path { if !config_path.exists() { panic!("error: config-path `{}` does not exist", config_path.display()) @@ -196,8 +196,8 @@ impl<'a> From<&'a CoreBuildArgs> for Figment { } } -impl<'a> From<&'a CoreBuildArgs> for Config { - fn from(args: &'a CoreBuildArgs) -> Self { +impl<'a> From<&'a BuildOpts> for Config { + fn from(args: &'a BuildOpts) -> Self { let figment: Figment = args.into(); let mut config = Self::from_provider(figment).sanitized(); // if `--config-path` is set we need to adjust the config's root path to the actual root @@ -209,7 +209,7 @@ impl<'a> From<&'a CoreBuildArgs> for Config { } } -impl Provider for CoreBuildArgs { +impl Provider for BuildOpts { fn metadata(&self) -> Metadata { Metadata::named("Core Build Args Provider") } diff --git a/crates/cli/src/opts/build/mod.rs b/crates/cli/src/opts/build/mod.rs index fe50a3a9a2093..55c61dcbbedd7 100644 --- a/crates/cli/src/opts/build/mod.rs +++ b/crates/cli/src/opts/build/mod.rs @@ -3,10 +3,10 @@ use foundry_compilers::artifacts::{output_selection::ContractOutputSelection, Ev use serde::Serialize; mod core; -pub use self::core::CoreBuildArgs; +pub use self::core::BuildOpts; mod paths; -pub use self::paths::ProjectPathsArgs; +pub use self::paths::ProjectPathOpts; // A set of solc compiler settings that can be set via command line arguments, which are intended // to be merged into an existing `foundry_config::Config`. @@ -14,7 +14,7 @@ pub use self::paths::ProjectPathsArgs; // See also `BuildArgs`. #[derive(Clone, Debug, Default, Serialize, Parser)] #[command(next_help_heading = "Compiler options")] -pub struct CompilerArgs { +pub struct CompilerOpts { /// Includes the AST as JSON in the compiler output. #[arg(long, help_heading = "Compiler options")] #[serde(skip)] @@ -62,15 +62,15 @@ mod tests { #[test] fn can_parse_evm_version() { - let args: CompilerArgs = - CompilerArgs::parse_from(["foundry-cli", "--evm-version", "london"]); + let args: CompilerOpts = + CompilerOpts::parse_from(["foundry-cli", "--evm-version", "london"]); assert_eq!(args.evm_version, Some(EvmVersion::London)); } #[test] fn can_parse_extra_output() { - let args: CompilerArgs = - CompilerArgs::parse_from(["foundry-cli", "--extra-output", "metadata", "ir-optimized"]); + let args: CompilerOpts = + CompilerOpts::parse_from(["foundry-cli", "--extra-output", "metadata", "ir-optimized"]); assert_eq!( args.extra_output, vec![ContractOutputSelection::Metadata, ContractOutputSelection::IrOptimized] @@ -79,7 +79,7 @@ mod tests { #[test] fn can_parse_extra_output_files() { - let args: CompilerArgs = CompilerArgs::parse_from([ + let args: CompilerOpts = CompilerOpts::parse_from([ "foundry-cli", "--extra-output-files", "metadata", diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index aa070800a6003..7a4d83eeaf6e1 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -16,7 +16,7 @@ use std::path::PathBuf; /// Common arguments for a project's paths. #[derive(Clone, Debug, Default, Serialize, Parser)] #[command(next_help_heading = "Project options")] -pub struct ProjectPathsArgs { +pub struct ProjectPathOpts { /// The project's root path. /// /// By default root of the Git repository, if in one, @@ -63,7 +63,7 @@ pub struct ProjectPathsArgs { pub config_path: Option, } -impl ProjectPathsArgs { +impl ProjectPathOpts { /// Returns the root directory to use for configuring the project. /// /// This will be the `--root` argument if provided, otherwise see [`find_project_root`]. @@ -87,10 +87,10 @@ impl ProjectPathsArgs { } } -foundry_config::impl_figment_convert!(ProjectPathsArgs); +foundry_config::impl_figment_convert!(ProjectPathOpts); // Make this args a `figment::Provider` so that it can be merged into the `Config` -impl Provider for ProjectPathsArgs { +impl Provider for ProjectPathOpts { fn metadata(&self) -> Metadata { Metadata::named("Project Paths Args Provider") } diff --git a/crates/cli/src/opts/global.rs b/crates/cli/src/opts/global.rs index 74ed15a65a549..6dc34067f6198 100644 --- a/crates/cli/src/opts/global.rs +++ b/crates/cli/src/opts/global.rs @@ -2,9 +2,9 @@ use clap::{ArgAction, Parser}; use foundry_common::shell::{ColorChoice, OutputFormat, OutputMode, Shell, Verbosity}; use serde::{Deserialize, Serialize}; -/// Global options. +/// Global arguments for the CLI. #[derive(Clone, Debug, Default, Serialize, Deserialize, Parser)] -pub struct GlobalOpts { +pub struct GlobalArgs { /// Verbosity level of the log messages. /// /// Pass multiple times to increase the verbosity (e.g. -v, -vv, -vvv). @@ -36,7 +36,7 @@ pub struct GlobalOpts { threads: Option, } -impl GlobalOpts { +impl GlobalArgs { /// Initialize the global options. pub fn init(&self) -> eyre::Result<()> { // Set the global shell. diff --git a/crates/cli/src/opts/mod.rs b/crates/cli/src/opts/mod.rs index 4e5d355724389..3b6b914c14aaa 100644 --- a/crates/cli/src/opts/mod.rs +++ b/crates/cli/src/opts/mod.rs @@ -1,13 +1,13 @@ mod build; mod chain; mod dependency; -mod ethereum; mod global; +mod rpc; mod transaction; pub use build::*; pub use chain::*; pub use dependency::*; -pub use ethereum::*; pub use global::*; +pub use rpc::*; pub use transaction::*; diff --git a/crates/cli/src/opts/ethereum.rs b/crates/cli/src/opts/rpc.rs similarity index 100% rename from crates/cli/src/opts/ethereum.rs rename to crates/cli/src/opts/rpc.rs diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index ec6b13dfd49ae..33c497562536f 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -5,7 +5,7 @@ use ethers_contract_abigen::{ }; use eyre::{Result, WrapErr}; use forge_sol_macro_gen::{MultiSolMacroGen, SolMacroGen}; -use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; +use foundry_cli::{opts::BuildOpts, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs::json_files}; use foundry_config::impl_figment_convert; use regex::Regex; @@ -14,7 +14,7 @@ use std::{ path::{Path, PathBuf}, }; -impl_figment_convert!(BindArgs, build_args); +impl_figment_convert!(BindArgs, build); const DEFAULT_CRATE_NAME: &str = "foundry-contracts"; const DEFAULT_CRATE_VERSION: &str = "0.1.0"; @@ -95,13 +95,13 @@ pub struct BindArgs { ethers: bool, #[command(flatten)] - build_args: CoreBuildArgs, + build: BuildOpts, } impl BindArgs { pub fn run(self) -> Result<()> { if !self.skip_build { - let project = self.build_args.project()?; + let project = self.build.project()?; let _ = ProjectCompiler::new().compile(&project)?; } @@ -139,7 +139,7 @@ impl BindArgs { if !self.select.is_empty() { return Ok(SelectContracts::default().extend_regex(self.select.clone()).into()) } - if let Some(skip) = self.build_args.skip.as_ref().filter(|s| !s.is_empty()) { + if let Some(skip) = self.build.skip.as_ref().filter(|s| !s.is_empty()) { return Ok(ExcludeContracts::default() .extend_regex( skip.clone() @@ -174,7 +174,7 @@ impl BindArgs { return Ok(Filter::Select(self.select.clone())); } - if let Some(skip) = self.build_args.skip.as_ref().filter(|s| !s.is_empty()) { + if let Some(skip) = self.build.skip.as_ref().filter(|s| !s.is_empty()) { return Ok(Filter::Skip( skip.clone() .into_iter() diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index 5e63b14d84981..593380297c3eb 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -1,7 +1,7 @@ use super::eip712::Resolver; use clap::{Parser, ValueHint}; use eyre::Result; -use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; +use foundry_cli::{opts::BuildOpts, utils::LoadConfig}; use foundry_common::{compile::with_compilation_reporter, fs}; use foundry_compilers::{ artifacts::{ @@ -29,7 +29,7 @@ use std::{ sync::Arc, }; -foundry_config::impl_figment_convert!(BindJsonArgs, opts); +foundry_config::impl_figment_convert!(BindJsonArgs, build); /// CLI arguments for `forge bind-json`. #[derive(Clone, Debug, Parser)] @@ -39,7 +39,7 @@ pub struct BindJsonArgs { pub out: Option, #[command(flatten)] - opts: CoreBuildArgs, + build: BuildOpts, } impl BindJsonArgs { diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 7dea6b0068d03..6a627d1502124 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -1,7 +1,7 @@ use super::{install, watch::WatchArgs}; use clap::Parser; use eyre::Result; -use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; +use foundry_cli::{opts::BuildOpts, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, shell}; use foundry_compilers::{ compilers::{multi::MultiCompilerLanguage, Language}, @@ -20,7 +20,7 @@ use foundry_config::{ use serde::Serialize; use std::path::PathBuf; -foundry_config::merge_impl_figment_convert!(BuildArgs, args); +foundry_config::merge_impl_figment_convert!(BuildArgs, build); /// CLI arguments for `forge build`. /// @@ -68,7 +68,7 @@ pub struct BuildArgs { #[command(flatten)] #[serde(flatten)] - pub args: CoreBuildArgs, + pub build: BuildOpts, #[command(flatten)] #[serde(skip)] @@ -122,7 +122,7 @@ impl BuildArgs { /// [`utils::find_project_root`] and merges the cli `BuildArgs` into it before returning /// [`foundry_config::Config::project()`] pub fn project(&self) -> Result { - self.args.project() + self.build.project() } /// Returns whether `BuildArgs` was configured with `--watch` diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 52ec97c48098f..7f998a6d85ecd 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -87,12 +87,12 @@ pub struct CloneArgs { pub etherscan: EtherscanOpts, #[command(flatten)] - pub opts: DependencyInstallOpts, + pub install: DependencyInstallOpts, } impl CloneArgs { pub async fn run(self) -> Result<()> { - let Self { address, root, opts, etherscan, no_remappings_txt, keep_directory_structure } = + let Self { address, root, install, etherscan, no_remappings_txt, keep_directory_structure } = self; // step 0. get the chain and api key from the config @@ -107,7 +107,7 @@ impl CloneArgs { let meta = Self::collect_metadata_from_client(address, &client).await?; // step 2. initialize an empty project - Self::init_an_empty_project(&root, opts)?; + Self::init_an_empty_project(&root, install)?; // canonicalize the root path // note that at this point, the root directory must have been created let root = dunce::canonicalize(&root)?; @@ -127,7 +127,7 @@ impl CloneArgs { Self::collect_compilation_metadata(&meta, chain, address, &root, &client).await?; // step 5. git add and commit the changes if needed - if !opts.no_commit { + if !install.no_commit { let git = Git::new(&root); git.add(Some("--all"))?; let msg = format!("chore: forge clone {address}"); @@ -157,9 +157,9 @@ impl CloneArgs { /// * `root` - the root directory of the project. /// * `enable_git` - whether to enable git for the project. /// * `quiet` - whether to print messages. - pub(crate) fn init_an_empty_project(root: &Path, opts: DependencyInstallOpts) -> Result<()> { + pub(crate) fn init_an_empty_project(root: &Path, install: DependencyInstallOpts) -> Result<()> { // let's try to init the project with default init args - let init_args = InitArgs { root: root.to_path_buf(), opts, ..Default::default() }; + let init_args = InitArgs { root: root.to_path_buf(), install, ..Default::default() }; init_args.run().map_err(|e| eyre::eyre!("Project init error: {:?}", e))?; // remove the unnecessary example contracts diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index 0aa1fdb6322ac..42ab29ec26555 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -5,7 +5,7 @@ use foundry_cli::utils::LoadConfig; use foundry_common::{evm::EvmArgs, shell}; use foundry_config::fix::fix_tomls; -foundry_config::impl_figment_convert!(ConfigArgs, opts, evm_args); +foundry_config::impl_figment_convert!(ConfigArgs, build, evm); /// CLI arguments for `forge config`. #[derive(Clone, Debug, Parser)] @@ -20,10 +20,10 @@ pub struct ConfigArgs { // support nested build arguments #[command(flatten)] - opts: BuildArgs, + build: BuildArgs, #[command(flatten)] - evm_args: EvmArgs, + evm: EvmArgs, } impl ConfigArgs { diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 2294d511e9e8e..9886e6bafdf18 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -13,7 +13,7 @@ use clap::{Parser, ValueHint}; use eyre::{Context, Result}; use forge_verify::{RetryArgs, VerifierArgs, VerifyArgs}; use foundry_cli::{ - opts::{CoreBuildArgs, EthereumOpts, EtherscanOpts, TransactionOpts}, + opts::{BuildOpts, EthereumOpts, EtherscanOpts, TransactionOpts}, utils::{self, read_constructor_args_file, remove_contract, LoadConfig}, }; use foundry_common::{ @@ -35,7 +35,7 @@ use foundry_config::{ use serde_json::json; use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc}; -merge_impl_figment_convert!(CreateArgs, opts, eth); +merge_impl_figment_convert!(CreateArgs, build, eth); /// CLI arguments for `forge create`. #[derive(Clone, Debug, Parser)] @@ -85,7 +85,7 @@ pub struct CreateArgs { pub timeout: Option, #[command(flatten)] - opts: CoreBuildArgs, + build: BuildOpts, #[command(flatten)] tx: TransactionOpts, @@ -236,11 +236,11 @@ impl CreateArgs { skip_is_verified_check: true, watch: true, retry: self.retry, - libraries: self.opts.libraries.clone(), + libraries: self.build.libraries.clone(), root: None, verifier: self.verifier.clone(), - via_ir: self.opts.via_ir, - evm_version: self.opts.compiler.evm_version, + via_ir: self.build.via_ir, + evm_version: self.build.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, guess_constructor_args: false, compilation_profile: Some(id.profile.to_string()), @@ -397,8 +397,8 @@ impl CreateArgs { sh_println!("Starting contract verification...")?; - let num_of_optimizations = if self.opts.compiler.optimize.unwrap_or_default() { - self.opts.compiler.optimizer_runs + let num_of_optimizations = if self.build.compiler.optimize.unwrap_or_default() { + self.build.compiler.optimizer_runs } else { None }; @@ -416,11 +416,11 @@ impl CreateArgs { skip_is_verified_check: true, watch: true, retry: self.retry, - libraries: self.opts.libraries.clone(), + libraries: self.build.libraries.clone(), root: None, verifier: self.verifier, - via_ir: self.opts.via_ir, - evm_version: self.opts.compiler.evm_version, + via_ir: self.build.via_ir, + evm_version: self.build.compiler.evm_version, show_standard_json_input: self.show_standard_json_input, guess_constructor_args: false, compilation_profile: Some(id.profile.to_string()), diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs new file mode 100644 index 0000000000000..d4fa4b6df9570 --- /dev/null +++ b/crates/forge/bin/cmd/debug.rs @@ -0,0 +1,69 @@ +use clap::{Parser, ValueHint}; +use forge_script::ScriptArgs; +use forge_verify::retry::RETRY_VERIFY_ON_CREATE; +use foundry_cli::opts::BuildOpts; +use foundry_common::evm::EvmArgs; +use std::path::PathBuf; + +// Loads project's figment and merges the build cli arguments into it +foundry_config::impl_figment_convert!(DebugArgs, build, evm); + +/// CLI arguments for `forge debug`. +#[derive(Clone, Debug, Parser)] +pub struct DebugArgs { + /// The contract you want to run. Either the file path or contract name. + /// + /// If multiple contracts exist in the same file you must specify the target contract with + /// --target-contract. + #[arg(value_hint = ValueHint::FilePath)] + pub path: PathBuf, + + /// Arguments to pass to the script function. + pub args: Vec, + + /// The name of the contract you want to run. + #[arg(long, visible_alias = "tc", value_name = "CONTRACT_NAME")] + pub target_contract: Option, + + /// The signature of the function you want to call in the contract, or raw calldata. + #[arg(long, short, default_value = "run()", value_name = "SIGNATURE")] + pub sig: String, + + /// Open the script in the debugger. + #[arg(long)] + pub debug: bool, + + /// File path to dump execution details as JSON. + #[arg( + long, + requires = "debug", + value_hint = ValueHint::FilePath, + value_name = "PATH" + )] + pub dump: Option, + + #[command(flatten)] + pub build: BuildOpts, + + #[command(flatten)] + pub evm: EvmArgs, +} + +impl DebugArgs { + pub async fn run(self) -> eyre::Result<()> { + let script = ScriptArgs { + path: self.path.to_str().expect("Invalid path string.").to_string(), + args: self.args, + target_contract: self.target_contract, + sig: self.sig, + gas_estimate_multiplier: 130, + build: self.build, + evm: self.evm, + debug: true, + dump: self.dump, + retry: RETRY_VERIFY_ON_CREATE, + ..Default::default() + }; + script.run_script().await + } +} diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs index eb1d8dc1d3158..af329887753f9 100644 --- a/crates/forge/bin/cmd/eip712.rs +++ b/crates/forge/bin/cmd/eip712.rs @@ -1,6 +1,6 @@ use clap::{Parser, ValueHint}; use eyre::{Ok, OptionExt, Result}; -use foundry_cli::{opts::CoreBuildArgs, utils::LoadConfig}; +use foundry_cli::{opts::BuildOpts, utils::LoadConfig}; use foundry_common::compile::ProjectCompiler; use foundry_compilers::artifacts::{ output_selection::OutputSelection, @@ -9,7 +9,7 @@ use foundry_compilers::artifacts::{ }; use std::{collections::BTreeMap, fmt::Write, path::PathBuf}; -foundry_config::impl_figment_convert!(Eip712Args, opts); +foundry_config::impl_figment_convert!(Eip712Args, build); /// CLI arguments for `forge eip712`. #[derive(Clone, Debug, Parser)] @@ -19,7 +19,7 @@ pub struct Eip712Args { pub target_path: PathBuf, #[command(flatten)] - opts: CoreBuildArgs, + build: BuildOpts, } impl Eip712Args { diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 7bbb0d1e2d766..3a3fb905e5608 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -1,7 +1,7 @@ use clap::{Parser, ValueHint}; use eyre::Result; use foundry_cli::{ - opts::{CoreBuildArgs, ProjectPathsArgs}, + opts::{BuildOpts, ProjectPathOpts}, utils::LoadConfig, }; use foundry_common::{compile::with_compilation_reporter, fs}; @@ -31,7 +31,7 @@ pub struct FlattenArgs { pub output: Option, #[command(flatten)] - project_paths: ProjectPathsArgs, + project_paths: ProjectPathOpts, } impl FlattenArgs { @@ -39,8 +39,8 @@ impl FlattenArgs { let Self { target_path, output, project_paths } = self; // flatten is a subset of `BuildArgs` so we can reuse that to get the config - let build_args = CoreBuildArgs { project_paths, ..Default::default() }; - let config = build_args.try_load_config_emit_warnings()?; + let build = BuildOpts { project_paths, ..Default::default() }; + let config = build.try_load_config_emit_warnings()?; let project = config.create_project(false, true)?; let target_path = dunce::canonicalize(target_path)?; diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 472d575bd9a8e..f1a2166352655 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -38,13 +38,13 @@ pub struct InitArgs { pub vscode: bool, #[command(flatten)] - pub opts: DependencyInstallOpts, + pub install: DependencyInstallOpts, } impl InitArgs { pub fn run(self) -> Result<()> { - let Self { root, template, branch, opts, offline, force, vscode } = self; - let DependencyInstallOpts { shallow, no_git, no_commit } = opts; + let Self { root, template, branch, install, offline, force, vscode } = self; + let DependencyInstallOpts { shallow, no_git, no_commit } = install; // create the root dir if it does not exist if !root.exists() { @@ -134,7 +134,7 @@ impl InitArgs { if !dest.exists() { fs::write(dest, config.clone().into_basic().to_string_pretty()?)?; } - let git = self.opts.git(&config); + let git = self.install.git(&config); // set up the repo if !no_git { @@ -145,10 +145,10 @@ impl InitArgs { if !offline { if root.join("lib/forge-std").exists() { sh_warn!("\"lib/forge-std\" already exists, skipping install...")?; - self.opts.install(&mut config, vec![])?; + self.install.install(&mut config, vec![])?; } else { let dep = "https://github.com/foundry-rs/forge-std".parse()?; - self.opts.install(&mut config, vec![dep])?; + self.install.install(&mut config, vec![dep])?; } } diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 426a8b36e04a6..d1836c9bccf97 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -3,7 +3,7 @@ use clap::Parser; use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Table}; use eyre::{Context, Result}; use forge::revm::primitives::Eof; -use foundry_cli::opts::{CompilerArgs, CoreBuildArgs}; +use foundry_cli::opts::{BuildOpts, CompilerOpts}; use foundry_common::{compile::ProjectCompiler, fmt::pretty_eof, shell}; use foundry_compilers::{ artifacts::{ @@ -35,7 +35,7 @@ pub struct InspectArgs { /// All build arguments are supported #[command(flatten)] - build: CoreBuildArgs, + build: BuildOpts, } impl InspectArgs { @@ -58,8 +58,8 @@ impl InspectArgs { }; // Build modified Args - let modified_build_args = CoreBuildArgs { - compiler: CompilerArgs { extra_output: cos, optimize: optimized, ..build.compiler }, + let modified_build_args = BuildOpts { + compiler: CompilerOpts { extra_output: cos, optimize: optimized, ..build.compiler }, ..build }; diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index d6a70c9da7a95..6885819f81c63 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -24,9 +24,9 @@ //! #[derive(Clone, Debug, Parser)] //! pub struct MyArgs { //! #[command(flatten)] -//! evm_args: EvmArgs, +//! evm: EvmArgs, //! #[command(flatten)] -//! opts: BuildArgs, +//! build: BuildArgs, //! } //! //! // add `Figment` and `Config` converters diff --git a/crates/forge/bin/cmd/selectors.rs b/crates/forge/bin/cmd/selectors.rs index 31992983d2f3d..56c25cc003cd6 100644 --- a/crates/forge/bin/cmd/selectors.rs +++ b/crates/forge/bin/cmd/selectors.rs @@ -3,7 +3,7 @@ use clap::Parser; use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Table}; use eyre::Result; use foundry_cli::{ - opts::{CompilerArgs, CoreBuildArgs, ProjectPathsArgs}, + opts::{BuildOpts, CompilerOpts, ProjectPathOpts}, utils::{cache_local_signatures, FoundryPathExt}, }; use foundry_common::{ @@ -29,7 +29,7 @@ pub enum SelectorsSubcommands { second_contract: ContractInfo, #[command(flatten)] - build: Box, + build: Box, }, /// Upload selectors to registry @@ -44,7 +44,7 @@ pub enum SelectorsSubcommands { all: bool, #[command(flatten)] - project_paths: ProjectPathsArgs, + project_paths: ProjectPathOpts, }, /// List selectors from current workspace @@ -55,7 +55,7 @@ pub enum SelectorsSubcommands { contract: Option, #[command(flatten)] - project_paths: ProjectPathsArgs, + project_paths: ProjectPathOpts, }, /// Find if a selector is present in the project @@ -66,14 +66,14 @@ pub enum SelectorsSubcommands { selector: String, #[command(flatten)] - project_paths: ProjectPathsArgs, + project_paths: ProjectPathOpts, }, /// Cache project selectors (enables trace with local contracts functions and events). #[command(visible_alias = "c")] Cache { #[command(flatten)] - project_paths: ProjectPathsArgs, + project_paths: ProjectPathOpts, }, } @@ -82,9 +82,9 @@ impl SelectorsSubcommands { match self { Self::Cache { project_paths } => { sh_println!("Caching selectors for contracts in the project...")?; - let build_args = CoreBuildArgs { + let build_args = BuildOpts { project_paths, - compiler: CompilerArgs { + compiler: CompilerOpts { extra_output: vec![ContractOutputSelection::Abi], ..Default::default() }, @@ -97,9 +97,9 @@ impl SelectorsSubcommands { cache_local_signatures(&outcome, Config::foundry_cache_dir().unwrap())? } Self::Upload { contract, all, project_paths } => { - let build_args = CoreBuildArgs { + let build_args = BuildOpts { project_paths: project_paths.clone(), - compiler: CompilerArgs { + compiler: CompilerOpts { extra_output: vec![ContractOutputSelection::Abi], ..Default::default() }, @@ -213,9 +213,9 @@ impl SelectorsSubcommands { } Self::List { contract, project_paths } => { sh_println!("Listing selectors for contracts in the project...")?; - let build_args = CoreBuildArgs { + let build_args = BuildOpts { project_paths, - compiler: CompilerArgs { + compiler: CompilerOpts { extra_output: vec![ContractOutputSelection::Abi], ..Default::default() }, @@ -301,9 +301,9 @@ impl SelectorsSubcommands { Self::Find { selector, project_paths } => { sh_println!("Searching for selector {selector:?} in the project...")?; - let build_args = CoreBuildArgs { + let build_args = BuildOpts { project_paths, - compiler: CompilerArgs { + compiler: CompilerOpts { extra_output: vec![ContractOutputSelection::Abi], ..Default::default() }, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 85f75a19be2d5..9c8e3b4e71f47 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -17,7 +17,7 @@ use forge::{ MultiContractRunner, MultiContractRunnerBuilder, TestFilter, }; use foundry_cli::{ - opts::{CoreBuildArgs, GlobalOpts}, + opts::{BuildOpts, GlobalArgs}, utils::{self, LoadConfig}, }; use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs, shell, TestFunctionExt}; @@ -59,7 +59,7 @@ use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; use summary::{print_invariant_metrics, TestSummaryReport}; // Loads project's figment and merges the build cli arguments into it -foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_args); +foundry_config::merge_impl_figment_convert!(TestArgs, build, evm); /// CLI arguments for `forge test`. #[derive(Clone, Debug, Parser)] @@ -67,7 +67,7 @@ foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_args); pub struct TestArgs { // Include global options for users of this struct. #[command(flatten)] - pub global: GlobalOpts, + pub global: GlobalArgs, /// The contract file you want to test, it's a shortcut for --match-path. #[arg(value_hint = ValueHint::FilePath)] @@ -157,23 +157,11 @@ pub struct TestArgs { #[arg(long, conflicts_with_all = ["quiet", "json"], help_heading = "Display options")] pub show_progress: bool, - #[command(flatten)] - filter: FilterArgs, - /// Re-run recorded test failures from last run. /// If no failure recorded then regular test run is performed. #[arg(long)] pub rerun: bool, - #[command(flatten)] - evm_args: EvmArgs, - - #[command(flatten)] - opts: CoreBuildArgs, - - #[command(flatten)] - pub watch: WatchArgs, - /// Print test summary table. #[arg(long, help_heading = "Display options")] pub summary: bool, @@ -181,14 +169,21 @@ pub struct TestArgs { /// Print detailed test summary table. #[arg(long, help_heading = "Display options", requires = "summary")] pub detailed: bool, + + #[command(flatten)] + filter: FilterArgs, + + #[command(flatten)] + evm: EvmArgs, + + #[command(flatten)] + pub build: BuildOpts, + + #[command(flatten)] + pub watch: WatchArgs, } impl TestArgs { - /// Returns the flattened [`CoreBuildArgs`]. - pub fn build_args(&self) -> &CoreBuildArgs { - &self.opts - } - pub async fn run(self) -> Result { trace!(target: "forge::test", "executing test command"); self.execute_tests().await @@ -1002,7 +997,7 @@ mod tests { fn extract_chain() { let test = |arg: &str, expected: Chain| { let args = TestArgs::parse_from(["foundry-cli", arg]); - assert_eq!(args.evm_args.env.chain, Some(expected)); + assert_eq!(args.evm.env.chain, Some(expected)); let (config, evm_opts) = args.load_config_and_evm_opts().unwrap(); assert_eq!(config.chain, Some(expected)); assert_eq!(evm_opts.env.chain_id, Some(expected.id())); diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index 088975d8752e5..fe278e98cbdc1 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -1,6 +1,6 @@ use clap::Parser; use eyre::Result; -use foundry_cli::{opts::ProjectPathsArgs, utils::LoadConfig}; +use foundry_cli::{opts::ProjectPathOpts, utils::LoadConfig}; use foundry_compilers::{ resolver::{parse::SolData, Charset, TreeOptions}, Graph, @@ -20,10 +20,10 @@ pub struct TreeArgs { charset: Charset, #[command(flatten)] - opts: ProjectPathsArgs, + project_paths: ProjectPathOpts, } -foundry_config::impl_figment_convert!(TreeArgs, opts); +foundry_config::impl_figment_convert!(TreeArgs, project_paths); impl TreeArgs { pub fn run(self) -> Result<()> { diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 926aecdbadc2c..37ae267ede913 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -259,7 +259,7 @@ pub async fn watch_gas_snapshot(args: GasSnapshotArgs) -> Result<()> { /// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge /// test` pub async fn watch_test(args: TestArgs) -> Result<()> { - let config: Config = args.build_args().into(); + let config: Config = Config::from(&args.build); let filter = args.filter(&config); // Marker to check whether to override the command. let no_reconfigure = filter.args().test_pattern.is_some() || diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index f32ec02226547..e211d03b78f33 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -8,7 +8,7 @@ use crate::cmd::{ use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; use forge_verify::{VerifyArgs, VerifyBytecodeArgs, VerifyCheckArgs}; -use foundry_cli::opts::GlobalOpts; +use foundry_cli::opts::GlobalArgs; use std::path::PathBuf; const VERSION_MESSAGE: &str = concat!( @@ -29,9 +29,9 @@ const VERSION_MESSAGE: &str = concat!( next_display_order = None, )] pub struct Forge { - /// Include the global options. + /// Include the global arguments. #[command(flatten)] - pub global: GlobalOpts, + pub global: GlobalArgs, #[command(subcommand)] pub cmd: ForgeSubcommand, diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index 4aad978d59121..d7bf29c69f3ff 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -187,7 +187,7 @@ impl PreExecutionState { if let Some(txs) = transactions { // If the user passed a `--sender` don't check anything. if self.build_data.predeploy_libraries.libraries_count() > 0 && - self.args.evm_args.sender.is_none() + self.args.evm.sender.is_none() { for tx in txs.iter() { if tx.transaction.to().is_none() { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index ab59569c76e40..791a15429a114 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -25,9 +25,9 @@ use clap::{Parser, ValueHint}; use dialoguer::Confirm; use eyre::{ContextCompat, Result}; use forge_script_sequence::{AdditionalContract, NestedValue}; -use forge_verify::RetryArgs; +use forge_verify::{RetryArgs, VerifierArgs}; use foundry_cli::{ - opts::{CoreBuildArgs, GlobalOpts}, + opts::{BuildOpts, GlobalArgs}, utils::LoadConfig, }; use foundry_common::{ @@ -72,14 +72,14 @@ mod transaction; mod verify; // Loads project's figment and merges the build cli arguments into it -foundry_config::merge_impl_figment_convert!(ScriptArgs, opts, evm_args); +foundry_config::merge_impl_figment_convert!(ScriptArgs, build, evm); /// CLI arguments for `forge script`. #[derive(Clone, Debug, Default, Parser)] pub struct ScriptArgs { // Include global options for users of this struct. #[command(flatten)] - pub global: GlobalOpts, + pub global: GlobalArgs, /// The contract you want to run. Either the file path or contract name. /// @@ -203,16 +203,16 @@ pub struct ScriptArgs { pub timeout: Option, #[command(flatten)] - pub opts: CoreBuildArgs, + pub build: BuildOpts, #[command(flatten)] pub wallets: MultiWalletOpts, #[command(flatten)] - pub evm_args: EvmArgs, + pub evm: EvmArgs, #[command(flatten)] - pub verifier: forge_verify::VerifierArgs, + pub verifier: VerifierArgs, #[command(flatten)] pub retry: RetryArgs, @@ -220,8 +220,7 @@ pub struct ScriptArgs { impl ScriptArgs { pub async fn preprocess(self) -> Result { - let script_wallets = - Wallets::new(self.wallets.get_multi_wallet().await?, self.evm_args.sender); + let script_wallets = Wallets::new(self.wallets.get_multi_wallet().await?, self.evm.sender); let (config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; @@ -414,7 +413,7 @@ impl ScriptArgs { } let mut prompt_user = false; - let max_size = match self.evm_args.env.code_size_limit { + let max_size = match self.evm.env.code_size_limit { Some(size) => size, None => CONTRACT_MAX_SIZE, }; @@ -728,7 +727,7 @@ mod tests { "--code-size-limit", "50000", ]); - assert_eq!(args.evm_args.env.code_size_limit, Some(50000)); + assert_eq!(args.evm.env.code_size_limit, Some(50000)); } #[test] diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 220991703df7d..eeeee3d1153af 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -7,7 +7,7 @@ use alloy_primitives::{hex, Address}; use eyre::{eyre, Result}; use forge_script_sequence::{AdditionalContract, ScriptSequence}; use forge_verify::{provider::VerificationProviderType, RetryArgs, VerifierArgs, VerifyArgs}; -use foundry_cli::opts::{EtherscanOpts, ProjectPathsArgs}; +use foundry_cli::opts::{EtherscanOpts, ProjectPathOpts}; use foundry_common::ContractsByArtifact; use foundry_compilers::{info::ContractInfo, Project}; use foundry_config::{Chain, Config}; @@ -48,7 +48,7 @@ impl BroadcastedState { pub struct VerifyBundle { pub num_of_optimizations: Option, pub known_contracts: ContractsByArtifact, - pub project_paths: ProjectPathsArgs, + pub project_paths: ProjectPathOpts, pub etherscan: EtherscanOpts, pub retry: RetryArgs, pub verifier: VerifierArgs, @@ -68,7 +68,7 @@ impl VerifyBundle { let config_path = config.get_config_path(); - let project_paths = ProjectPathsArgs { + let project_paths = ProjectPathOpts { root: Some(project.paths.root.clone()), contracts: Some(project.paths.sources.clone()), remappings: project.paths.remappings.clone(), From e3ff6cbd44840aa51055c273ad4f638767db9d5e Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 6 Jan 2025 15:03:42 +0100 Subject: [PATCH 1831/1963] fix: re-remove forge `debug` file (#9631) fix re-remove debug file --- crates/forge/bin/cmd/debug.rs | 69 ----------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 crates/forge/bin/cmd/debug.rs diff --git a/crates/forge/bin/cmd/debug.rs b/crates/forge/bin/cmd/debug.rs deleted file mode 100644 index d4fa4b6df9570..0000000000000 --- a/crates/forge/bin/cmd/debug.rs +++ /dev/null @@ -1,69 +0,0 @@ -use clap::{Parser, ValueHint}; -use forge_script::ScriptArgs; -use forge_verify::retry::RETRY_VERIFY_ON_CREATE; -use foundry_cli::opts::BuildOpts; -use foundry_common::evm::EvmArgs; -use std::path::PathBuf; - -// Loads project's figment and merges the build cli arguments into it -foundry_config::impl_figment_convert!(DebugArgs, build, evm); - -/// CLI arguments for `forge debug`. -#[derive(Clone, Debug, Parser)] -pub struct DebugArgs { - /// The contract you want to run. Either the file path or contract name. - /// - /// If multiple contracts exist in the same file you must specify the target contract with - /// --target-contract. - #[arg(value_hint = ValueHint::FilePath)] - pub path: PathBuf, - - /// Arguments to pass to the script function. - pub args: Vec, - - /// The name of the contract you want to run. - #[arg(long, visible_alias = "tc", value_name = "CONTRACT_NAME")] - pub target_contract: Option, - - /// The signature of the function you want to call in the contract, or raw calldata. - #[arg(long, short, default_value = "run()", value_name = "SIGNATURE")] - pub sig: String, - - /// Open the script in the debugger. - #[arg(long)] - pub debug: bool, - - /// File path to dump execution details as JSON. - #[arg( - long, - requires = "debug", - value_hint = ValueHint::FilePath, - value_name = "PATH" - )] - pub dump: Option, - - #[command(flatten)] - pub build: BuildOpts, - - #[command(flatten)] - pub evm: EvmArgs, -} - -impl DebugArgs { - pub async fn run(self) -> eyre::Result<()> { - let script = ScriptArgs { - path: self.path.to_str().expect("Invalid path string.").to_string(), - args: self.args, - target_contract: self.target_contract, - sig: self.sig, - gas_estimate_multiplier: 130, - build: self.build, - evm: self.evm, - debug: true, - dump: self.dump, - retry: RETRY_VERIFY_ON_CREATE, - ..Default::default() - }; - script.run_script().await - } -} From 5e72c69e8414ec7b535eedb357e9b6db3e312b62 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:36:35 +0200 Subject: [PATCH 1832/1963] feat: remove ethers (#9412) Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 216 ----------------------------------- Cargo.toml | 3 - README.md | 5 +- crates/forge/Cargo.toml | 2 - crates/forge/bin/cmd/bind.rs | 152 ++---------------------- 5 files changed, 14 insertions(+), 364 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26cdab3bbc495..ec194355f5e76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1971,38 +1971,6 @@ 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.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.24", - "serde", - "serde_json", - "thiserror 1.0.69", -] - [[package]] name = "cassowary" version = "0.3.0" @@ -3126,106 +3094,6 @@ dependencies = [ "uuid 0.8.2", ] -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror 1.0.69", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-contract-abigen" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" -dependencies = [ - "Inflector", - "const-hex", - "dunce", - "ethers-core", - "eyre", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "serde", - "serde_json", - "syn 2.0.94", - "toml 0.8.19", - "walkdir", -] - -[[package]] -name = "ethers-core" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" -dependencies = [ - "arrayvec", - "bytes", - "cargo_metadata", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "once_cell", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum", - "syn 2.0.94", - "tempfile", - "thiserror 1.0.69", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "event-listener" version = "4.0.3" @@ -3444,7 +3312,6 @@ dependencies = [ "comfy-table", "dialoguer", "dunce", - "ethers-contract-abigen", "evm-disassembler", "eyre", "forge-doc", @@ -5325,24 +5192,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.3" @@ -6311,7 +6160,6 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.94", @@ -6394,31 +6242,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "opener" version = "0.7.2" @@ -6938,9 +6761,6 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", "uint", ] @@ -7613,21 +7433,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "rpassword" version = "7.3.1" @@ -7917,30 +7725,6 @@ dependencies = [ "regex", ] -[[package]] -name = "scale-info" -version = "2.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.94", -] - [[package]] name = "scc" version = "2.3.0" diff --git a/Cargo.toml b/Cargo.toml index 304597c16236c..636f4fd6291b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -181,9 +181,6 @@ revm = { version = "19.0.0", default-features = false } revm-primitives = { version = "15.1.0", default-features = false } revm-inspectors = { version = "0.14.1", features = ["serde"] } -## ethers -ethers-contract-abigen = { version = "2.0.14", default-features = false } - ## alloy alloy-consensus = { version = "0.9.0", default-features = false } alloy-contract = { version = "0.9.0", default-features = false } diff --git a/README.md b/README.md index ec0884aa2378f..bd93251911219 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ If you're experiencing any issues while installing, check out [Getting Help](#ge ### How Fast? -Forge is quite fast at both compiling (leveraging [ethers-solc]) and testing. +Forge is quite fast at both compiling (leveraging [foundry-compilers]) and testing. See the benchmarks below. More benchmarks can be found in the [v0.2.0 announcement post][benchmark-post] and in the [Convex Shutdown Simulation][convex] repository. @@ -127,7 +127,7 @@ If you want to contribute, or follow along with contributor discussion, you can ## Acknowledgements - Foundry is a clean-room rewrite of the testing framework [DappTools](https://github.com/dapphub/dapptools). None of this would have been possible without the DappHub team's work over the years. -- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. +- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] (now [foundry-compilers]) which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. - [Rohit Narurkar](https://twitter.com/rohitnarurkar): Created the Rust Solidity version manager [svm-rs](https://github.com/roynalnaruto/svm-rs) which we use to auto-detect and manage multiple Solidity versions. - [Brock Elmore](https://twitter.com/brockjelmore): For extending the VM's cheatcodes and implementing [structured call tracing](https://github.com/foundry-rs/foundry/pull/192), a critical feature for debugging smart contract calls. - All the other [contributors](https://github.com/foundry-rs/foundry/graphs/contributors) to the [ethers-rs](https://github.com/gakonst/ethers-rs) & [foundry](https://github.com/foundry-rs/foundry) repositories and chatrooms. @@ -135,6 +135,7 @@ If you want to contribute, or follow along with contributor discussion, you can [foundry-book]: https://book.getfoundry.sh [foundry-gha]: https://github.com/foundry-rs/foundry-toolchain [ethers-solc]: https://github.com/gakonst/ethers-rs/tree/master/ethers-solc/ +[foundry-compilers]: https://github.com/foundry-rs/foundry-compilers [solmate]: https://github.com/transmissions11/solmate/ [geb]: https://github.com/reflexer-labs/geb [vaults]: https://github.com/rari-capital/vaults diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 8deafcd5d4dce..a8b7f56c020df 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -35,8 +35,6 @@ foundry-wallets.workspace = true foundry-linking.workspace = true forge-script-sequence.workspace = true -ethers-contract-abigen = { workspace = true, features = ["providers"] } - revm-inspectors.workspace = true comfy-table.workspace = true diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 33c497562536f..c8763d08c024a 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -1,9 +1,6 @@ use alloy_primitives::map::HashSet; use clap::{Parser, ValueHint}; -use ethers_contract_abigen::{ - Abigen, ContractFilter, ExcludeContracts, MultiAbigen, SelectContracts, -}; -use eyre::{Result, WrapErr}; +use eyre::Result; use forge_sol_macro_gen::{MultiSolMacroGen, SolMacroGen}; use foundry_cli::{opts::BuildOpts, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs::json_files}; @@ -83,15 +80,15 @@ pub struct BindArgs { skip_extra_derives: bool, /// Generate bindings for the `alloy` library, instead of `ethers`. - #[arg(long, conflicts_with = "ethers")] + #[arg(long, hide = true)] alloy: bool, /// Specify the alloy version. - #[arg(long, value_name = "ALLOY_VERSION")] + #[arg(long)] alloy_version: Option, - /// Generate bindings for the `ethers` library, instead of `alloy` (default, deprecated). - #[arg(long)] + /// Generate bindings for the `ethers` library, instead of `alloy` (removed). + #[arg(long, hide = true)] ethers: bool, #[command(flatten)] @@ -100,17 +97,15 @@ pub struct BindArgs { impl BindArgs { pub fn run(self) -> Result<()> { + if self.ethers { + eyre::bail!("`--ethers` bindings have been removed. Use `--alloy` (default) instead."); + } + if !self.skip_build { let project = self.build.project()?; let _ = ProjectCompiler::new().compile(&project)?; } - if self.ethers { - sh_warn!( - "`--ethers` bindings are deprecated and will be removed in the future. Consider using `--alloy` (default) instead." - )?; - } - let config = self.try_load_config_emit_warnings()?; let artifacts = config.out; let bindings_root = self.bindings.clone().unwrap_or_else(|| artifacts.join("bindings")); @@ -131,40 +126,7 @@ impl BindArgs { Ok(()) } - /// Returns the filter to use for `MultiAbigen` - fn get_filter(&self) -> Result { - if self.select_all { - return Ok(ContractFilter::All) - } - if !self.select.is_empty() { - return Ok(SelectContracts::default().extend_regex(self.select.clone()).into()) - } - if let Some(skip) = self.build.skip.as_ref().filter(|s| !s.is_empty()) { - return Ok(ExcludeContracts::default() - .extend_regex( - skip.clone() - .into_iter() - .map(|s| Regex::new(s.file_pattern())) - .collect::, _>>()?, - ) - .into()) - } - // This excludes all Test/Script and forge-std contracts - Ok(ExcludeContracts::default() - .extend_pattern([ - ".*Test.*", - ".*Script", - "console[2]?", - "CommonBase", - "Components", - "[Ss]td(Chains|Math|Error|Json|Utils|Cheats|Style|Invariant|Assertions|Toml|Storage(Safe)?)", - "[Vv]m.*", - ]) - .extend_names(["IMulticall3"]) - .into()) - } - - fn get_alloy_filter(&self) -> Result { + fn get_filter(&self) -> Result { if self.select_all { // Select all json files return Ok(Filter::All); @@ -190,8 +152,6 @@ impl BindArgs { /// Returns an iterator over the JSON files and the contract name in the `artifacts` directory. fn get_json_files(&self, artifacts: &Path) -> Result> { let filter = self.get_filter()?; - let alloy_filter = self.get_alloy_filter()?; - let is_alloy = !self.ethers; Ok(json_files(artifacts) .filter_map(|path| { // Ignore the build info JSON. @@ -212,35 +172,7 @@ impl BindArgs { Some((name, path)) }) - .filter( - move |(name, _path)| { - if is_alloy { - alloy_filter.is_match(name) - } else { - filter.is_match(name) - } - }, - )) - } - - /// Instantiate the multi-abigen - fn get_multi(&self, artifacts: &Path) -> Result { - let abigens = self - .get_json_files(artifacts)? - .map(|(name, path)| { - trace!(?path, "parsing Abigen from file"); - let abi = Abigen::new(name, path.to_str().unwrap()) - .wrap_err_with(|| format!("failed to parse Abigen from file: {path:?}")); - if !self.skip_extra_derives { - abi?.add_derive("serde::Serialize")?.add_derive("serde::Deserialize") - } else { - abi - } - }) - .collect::, _>>()?; - let multi = MultiAbigen::from_abigens(abigens); - eyre::ensure!(!multi.is_empty(), "No contract artifacts found"); - Ok(multi) + .filter(move |(name, _path)| filter.is_match(name))) } fn get_solmacrogen(&self, artifacts: &Path) -> Result { @@ -264,40 +196,6 @@ impl BindArgs { /// Check that the existing bindings match the expected abigen output fn check_existing_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - if self.ethers { - return self.check_ethers(artifacts, bindings_root); - } - - self.check_alloy(artifacts, bindings_root) - } - - fn check_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - let bindings = self.get_multi(artifacts)?.build()?; - sh_println!("Checking bindings for {} contracts.", bindings.len())?; - if !self.module { - bindings - .ensure_consistent_crate( - &self.crate_name, - &self.crate_version, - bindings_root, - self.single_file, - !self.skip_cargo_toml, - ) - .map_err(|err| { - if !self.skip_cargo_toml && err.to_string().contains("Cargo.toml") { - err.wrap_err("To skip Cargo.toml consistency check, pass --skip-cargo-toml") - } else { - err - } - })?; - } else { - bindings.ensure_consistent_module(bindings_root, self.single_file)?; - } - sh_println!("OK.")?; - Ok(()) - } - - fn check_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut bindings = self.get_solmacrogen(artifacts)?; bindings.generate_bindings()?; sh_println!("Checking bindings for {} contracts", bindings.instances.len())?; @@ -316,34 +214,6 @@ impl BindArgs { /// Generate the bindings fn generate_bindings(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - if self.ethers { - return self.generate_ethers(artifacts, bindings_root); - } - - self.generate_alloy(artifacts, bindings_root) - } - - fn generate_ethers(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { - let mut bindings = self.get_multi(artifacts)?.build()?; - sh_println!("Generating bindings for {} contracts", bindings.len())?; - if !self.module { - trace!(single_file = self.single_file, "generating crate"); - if !self.skip_extra_derives { - bindings = bindings.dependencies([r#"serde = "1""#]) - } - bindings.write_to_crate( - &self.crate_name, - &self.crate_version, - bindings_root, - self.single_file, - ) - } else { - trace!(single_file = self.single_file, "generating module"); - bindings.write_to_module(bindings_root, self.single_file) - } - } - - fn generate_alloy(&self, artifacts: &Path, bindings_root: &Path) -> Result<()> { let mut solmacrogen = self.get_solmacrogen(artifacts)?; sh_println!("Generating bindings for {} contracts", solmacrogen.instances.len())?; From d2dbe3edbcd0234a98364f9105adb75d53b18a0d Mon Sep 17 00:00:00 2001 From: Marquis Shanahan <29431502+9547@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:36:45 +0800 Subject: [PATCH 1833/1963] fix(ens): don't resolve addr if doesn't contain . (#9635) * fix(ens): don't resolve addr if doesn't contain . Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> * fix invalid ens name Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --------- Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --- crates/cast/bin/cmd/storage.rs | 2 +- crates/common/src/ens.rs | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 4499fea1cfc1e..360e5d871335e 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -350,7 +350,7 @@ mod tests { #[test] fn parse_storage_etherscan_api_key() { let args = - StorageArgs::parse_from(["foundry-cli", "addr", "--etherscan-api-key", "dummykey"]); + StorageArgs::parse_from(["foundry-cli", "addr.eth", "--etherscan-api-key", "dummykey"]); assert_eq!(args.etherscan.key(), Some("dummykey".to_string())); std::env::set_var("ETHERSCAN_API_KEY", "FXY"); diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index 1c4eadeac5ad1..650cb068a39d7 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -96,10 +96,15 @@ impl FromStr for NameOrAddress { type Err =
::Err; fn from_str(s: &str) -> Result { - if let Ok(addr) = Address::from_str(s) { - Ok(Self::Address(addr)) - } else { - Ok(Self::Name(s.to_string())) + match Address::from_str(s) { + Ok(addr) => Ok(Self::Address(addr)), + Err(err) => { + if s.contains('.') { + Ok(Self::Name(s.to_string())) + } else { + Err(err) + } + } } } } @@ -236,4 +241,16 @@ mod test { assert_eq!(reverse_address(&addr.parse().unwrap()), expected, "{addr}"); } } + + #[test] + fn test_invalid_address() { + for addr in [ + "0x314618", + "0x000000000000000000000000000000000000000", // 41 + "0x00000000000000000000000000000000000000000", // 43 + "0x28679A1a632125fbBf7A68d850E50623194A709E123", // 44 + ] { + assert!(NameOrAddress::from_str(addr).is_err()); + } + } } From 95442fa522e338a0f7685ce90a1839c36c84b52e Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:55:54 +0530 Subject: [PATCH 1834/1963] feat(`verify`): default to sourcify if etherscan key not provided (#9630) * feat(`verify`): default to sourcify if etherscan key not provided * clippy * nit Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/forge/tests/cli/utils.rs | 10 ++++ crates/forge/tests/cli/verify.rs | 91 ++++++++++++++++++++++---------- crates/verify/src/provider.rs | 12 ++++- crates/verify/src/verify.rs | 4 +- 4 files changed, 86 insertions(+), 31 deletions(-) diff --git a/crates/forge/tests/cli/utils.rs b/crates/forge/tests/cli/utils.rs index 2b0bb627314ac..058390dceb7b7 100644 --- a/crates/forge/tests/cli/utils.rs +++ b/crates/forge/tests/cli/utils.rs @@ -109,6 +109,16 @@ impl EnvExternalities { }) } + pub fn sepolia_empty_verifier() -> Option { + Some(Self { + chain: NamedChain::Sepolia, + rpc: network_rpc_key("sepolia")?, + pk: network_private_key("sepolia")?, + etherscan: String::new(), + verifier: String::new(), + }) + } + /// Returns the arguments required to deploy the contract pub fn create_args(&self) -> Vec { vec![ diff --git a/crates/forge/tests/cli/verify.rs b/crates/forge/tests/cli/verify.rs index 60a794477314a..f4465834eb2d8 100644 --- a/crates/forge/tests/cli/verify.rs +++ b/crates/forge/tests/cli/verify.rs @@ -91,6 +91,29 @@ fn parse_verification_result(cmd: &mut TestCommand, retries: u32) -> eyre::Resul }) } +fn verify_check( + guid: String, + chain: String, + etherscan_api_key: Option, + verifier: Option, + mut cmd: TestCommand, +) { + let mut args = vec!["verify-check", &guid, "--chain-id", &chain]; + + if let Some(etherscan_api_key) = ðerscan_api_key { + args.push("--etherscan-api-key"); + args.push(etherscan_api_key); + } + + if let Some(verifier) = &verifier { + args.push("--verifier"); + args.push(verifier); + } + cmd.forge_fuse().args(args); + + parse_verification_result(&mut cmd, 6).expect("Failed to verify check") +} + fn await_verification_response(info: EnvExternalities, mut cmd: TestCommand) { let guid = { // Give Etherscan some time to detect the transaction. @@ -110,17 +133,29 @@ fn await_verification_response(info: EnvExternalities, mut cmd: TestCommand) { }; // verify-check - cmd.forge_fuse() - .arg("verify-check") - .arg(guid) - .arg("--chain-id") - .arg(info.chain.to_string()) - .arg("--etherscan-api-key") - .arg(info.etherscan) - .arg("--verifier") - .arg(info.verifier); + let etherscan = (!info.etherscan.is_empty()).then_some(info.etherscan.clone()); + let verifier = (!info.verifier.is_empty()).then_some(info.verifier.clone()); + verify_check(guid, info.chain.to_string(), etherscan, verifier, cmd); +} - parse_verification_result(&mut cmd, 6).expect("Failed to verify check") +fn deploy_contract( + info: &EnvExternalities, + contract_path: &str, + prj: TestProject, + cmd: &mut TestCommand, +) -> String { + add_unique(&prj); + add_verify_target(&prj); + let output = cmd + .forge_fuse() + .arg("create") + .args(info.create_args()) + .arg(contract_path) + .assert_success() + .get_output() + .stdout_lossy(); + utils::parse_deployed_address(output.as_str()) + .unwrap_or_else(|| panic!("Failed to parse deployer {output}")) } #[allow(clippy::disallowed_macros)] @@ -128,30 +163,27 @@ fn verify_on_chain(info: Option, prj: TestProject, mut cmd: Te // only execute if keys present if let Some(info) = info { println!("verifying on {}", info.chain); - add_unique(&prj); - add_verify_target(&prj); let contract_path = "src/Verify.sol:Verify"; - let output = cmd - .arg("create") - .args(info.create_args()) - .arg(contract_path) - .assert_success() - .get_output() - .stdout_lossy(); - let address = utils::parse_deployed_address(output.as_str()) - .unwrap_or_else(|| panic!("Failed to parse deployer {output}")); + let address = deploy_contract(&info, contract_path, prj, &mut cmd); - cmd.forge_fuse().arg("verify-contract").root_arg().args([ + let mut args = vec![ "--chain-id".to_string(), info.chain.to_string(), address, contract_path.to_string(), - "--etherscan-api-key".to_string(), - info.etherscan.to_string(), - "--verifier".to_string(), - info.verifier.to_string(), - ]); + ]; + + if !info.etherscan.is_empty() { + args.push("--etherscan-api-key".to_string()); + args.push(info.etherscan.clone()); + } + + if !info.verifier.is_empty() { + args.push("--verifier".to_string()); + args.push(info.verifier.clone()); + } + cmd.forge_fuse().arg("verify-contract").root_arg().args(args); await_verification_response(info, cmd) } @@ -247,3 +279,8 @@ forgetest!(can_create_verify_random_contract_sepolia, |prj, cmd| { forgetest!(can_guess_constructor_args, |prj, cmd| { guess_constructor_args(EnvExternalities::goerli(), prj, cmd); }); + +// tests `create && verify-contract && verify-check` on sepolia with default sourcify verifier +forgetest!(can_verify_random_contract_sepolia_default_sourcify, |prj, cmd| { + verify_on_chain(EnvExternalities::sepolia_empty_verifier(), prj, cmd); +}); diff --git a/crates/verify/src/provider.rs b/crates/verify/src/provider.rs index 9c619239b6d67..8b3c510b64a9d 100644 --- a/crates/verify/src/provider.rs +++ b/crates/verify/src/provider.rs @@ -158,8 +158,8 @@ impl fmt::Display for VerificationProviderType { #[derive(Clone, Debug, Default, PartialEq, Eq, clap::ValueEnum)] pub enum VerificationProviderType { - #[default] Etherscan, + #[default] Sourcify, Blockscout, Oklink, @@ -170,6 +170,9 @@ pub enum VerificationProviderType { impl VerificationProviderType { /// Returns the corresponding `VerificationProvider` for the key pub fn client(&self, key: &Option) -> Result> { + if key.as_ref().is_some_and(|k| !k.is_empty()) && matches!(self, Self::Sourcify) { + return Ok(Box::::default()); + } match self { Self::Etherscan => { if key.as_ref().is_none_or(|key| key.is_empty()) { @@ -177,7 +180,12 @@ impl VerificationProviderType { } Ok(Box::::default()) } - Self::Sourcify => Ok(Box::::default()), + Self::Sourcify => { + sh_println!( + "Attempting to verify on Sourcify, pass the --etherscan-api-key to verify on Etherscan OR use the --verifier flag to verify on any other provider" + )?; + Ok(Box::::default()) + } Self::Blockscout => Ok(Box::::default()), Self::Oklink => Ok(Box::::default()), Self::Custom => Ok(Box::::default()), diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index c2ac287703bd5..695a243c6afd0 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -29,7 +29,7 @@ use crate::provider::VerificationContext; #[derive(Clone, Debug, Parser)] pub struct VerifierArgs { /// The contract verification provider to use. - #[arg(long, help_heading = "Verifier options", default_value = "etherscan", value_enum)] + #[arg(long, help_heading = "Verifier options", default_value = "sourcify", value_enum)] pub verifier: VerificationProviderType, /// The verifier API KEY, if using a custom provider. @@ -44,7 +44,7 @@ pub struct VerifierArgs { impl Default for VerifierArgs { fn default() -> Self { Self { - verifier: VerificationProviderType::Etherscan, + verifier: VerificationProviderType::Sourcify, verifier_api_key: None, verifier_url: None, } From ad09bbe96a4c7b7d8ff2ad7a11ba453404a01988 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 8 Jan 2025 11:41:46 +0530 Subject: [PATCH 1835/1963] chore(`forge`): rm regex for --debug and --decode-internal (#9572) * chore(`forge`): rm regex for --debug and --decode-internal * fix * fix tests --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/forge/bin/cmd/test/mod.rs | 48 ++++++++---------------------- crates/forge/tests/cli/test_cmd.rs | 15 ++-------- 2 files changed, 16 insertions(+), 47 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 9c8e3b4e71f47..43181a01d53d4 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -79,8 +79,8 @@ pub struct TestArgs { /// /// If the matching test is a fuzz test, then it will open the debugger on the first failure /// case. If the fuzz test does not fail, it will open the debugger on the last fuzz case. - #[arg(long, conflicts_with_all = ["flamegraph", "flamechart", "decode_internal", "rerun"], value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] - debug: Option>, + #[arg(long, conflicts_with_all = ["flamegraph", "flamechart", "decode_internal", "rerun"])] + debug: bool, /// Generate a flamegraph for a single test. Implies `--decode-internal`. /// @@ -102,8 +102,8 @@ pub struct TestArgs { /// /// Parameters stored in memory (such as bytes or arrays) are currently decoded only when a /// single function is matched, similarly to `--debug`, for performance reasons. - #[arg(long, value_name = "DEPRECATED_TEST_FUNCTION_REGEX")] - decode_internal: Option>, + #[arg(long)] + decode_internal: bool, /// Dumps all debugger steps to file. #[arg( @@ -288,7 +288,7 @@ impl TestArgs { // Set up the project. let project = config.project()?; - let mut filter = self.filter(&config); + let filter = self.filter(&config); trace!(target: "forge::test", ?filter, "using filter"); let sources_to_compile = self.get_sources_to_compile(&config, &filter)?; @@ -312,7 +312,7 @@ impl TestArgs { } } - let should_debug = self.debug.is_some(); + let should_debug = self.debug; let should_draw = self.flamegraph || self.flamechart; // Determine print verbosity and executor verbosity. @@ -324,12 +324,12 @@ impl TestArgs { let env = evm_opts.evm_env().await?; // Enable internal tracing for more informative flamegraph. - if should_draw && self.decode_internal.is_none() { - self.decode_internal = Some(None); + if should_draw && !self.decode_internal { + self.decode_internal = true; } // Choose the internal function tracing mode, if --decode-internal is provided. - let decode_internal = if self.decode_internal.is_some() { + let decode_internal = if self.decode_internal { // If more than one function matched, we enable simple tracing. // If only one function matched, we enable full tracing. This is done in `run_tests`. InternalTraceMode::Simple @@ -350,28 +350,6 @@ impl TestArgs { .odyssey(evm_opts.odyssey) .build::(project_root, &output, env, evm_opts)?; - let mut maybe_override_mt = |flag, maybe_regex: Option<&Option>| { - if let Some(Some(regex)) = maybe_regex { - sh_warn!( - "specifying argument for --{flag} is deprecated and will be removed in the future, \ - use --match-test instead" - )?; - - let test_pattern = &mut filter.args_mut().test_pattern; - if test_pattern.is_some() { - eyre::bail!( - "Cannot specify both --{flag} and --match-test. \ - Use --match-contract and --match-path to further limit the search instead." - ); - } - *test_pattern = Some(regex.clone()); - } - - Ok(()) - }; - maybe_override_mt("debug", self.debug.as_ref())?; - maybe_override_mt("decode-internal", self.decode_internal.as_ref())?; - let libraries = runner.libraries.clone(); let mut outcome = self.run_tests(runner, config, verbosity, &filter, &output).await?; @@ -466,7 +444,7 @@ impl TestArgs { let silent = self.gas_report && shell::is_json() || self.summary && shell::is_json(); let num_filtered = runner.matching_test_functions(filter).count(); - if num_filtered != 1 && (self.debug.is_some() || self.flamegraph || self.flamechart) { + if num_filtered != 1 && (self.debug || self.flamegraph || self.flamechart) { let action = if self.flamegraph { "generate a flamegraph" } else if self.flamechart { @@ -486,7 +464,7 @@ impl TestArgs { } // If exactly one test matched, we enable full tracing. - if num_filtered == 1 && self.decode_internal.is_some() { + if num_filtered == 1 && self.decode_internal { runner.decode_internal = InternalTraceMode::Full; } @@ -549,7 +527,7 @@ impl TestArgs { )?); } - if self.decode_internal.is_some() { + if self.decode_internal { let sources = ContractSources::from_project_output(output, &config.root, Some(&libraries))?; builder = builder.with_debug_identifier(DebugTraceIdentifier::new(sources)); @@ -578,7 +556,7 @@ impl TestArgs { // We identify addresses if we're going to print *any* trace or gas report. let identify_addresses = verbosity >= 3 || self.gas_report || - self.debug.is_some() || + self.debug || self.flamegraph || self.flamechart; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 20f865fc9e6c4..64faff26dbe09 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -1322,8 +1322,7 @@ contract SimpleContractTest is Test { "#, ) .unwrap(); - cmd.args(["test", "-vvvv", "--decode-internal", "test"]).assert_success().stdout_eq(str![[ - r#" + cmd.args(["test", "-vvvv", "--decode-internal"]).assert_success().stdout_eq(str![[r#" ... Traces: [406629] SimpleContractTest::test() @@ -1335,8 +1334,7 @@ Traces: │ └─ ← [Stop] └─ ← [Stop] ... -"# - ]]); +"#]]); }); // tests that `forge test` with a seed produces deterministic random values for uint and addresses. @@ -2277,13 +2275,6 @@ Use --match-contract and --match-path to further limit the search. "#]]); }); -forgetest_init!(deprecated_regex_arg, |prj, cmd| { - cmd.args(["test", "--decode-internal", "test_Increment"]).assert_success().stderr_eq(str![[r#" -Warning: specifying argument for --decode-internal is deprecated and will be removed in the future, use --match-test instead - -"#]]); -}); - // Test a script that calls vm.rememberKeys forgetest_init!(script_testing, |prj, cmd| { prj @@ -2452,7 +2443,7 @@ contract Dummy { let dump_path = prj.root().join("dump.json"); - cmd.args(["test", "--debug", "testDummy", "--dump", dump_path.to_str().unwrap()]); + cmd.args(["test", "--mt", "testDummy", "--debug", "--dump", dump_path.to_str().unwrap()]); cmd.assert_success(); assert!(dump_path.exists()); From b3cd2abfa4554b5533e187731e2e5f9d1983d50d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 8 Jan 2025 19:10:17 +0200 Subject: [PATCH 1836/1963] fix(cheatcode): use storage access address instead account access (#9646) * fix(cheatcode): use storage access address instead account access * Update crates/cheatcodes/src/evm.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * Fix fmt --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/cheatcodes/src/evm.rs | 13 +++++-- crates/forge/tests/it/repros.rs | 3 ++ testdata/default/repros/Issue9643.t.sol | 49 +++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 testdata/default/repros/Issue9643.t.sol diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index f9d648bca6db9..ee661dd98d396 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1149,11 +1149,12 @@ fn get_recorded_state_diffs(state: &mut Cheatcodes) -> BTreeMap BTreeMap { diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 863b8b28479e4..d5d1fbbdb30a6 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -392,3 +392,6 @@ test_repro!(8639); // https://github.com/foundry-rs/foundry/issues/8566 test_repro!(8566); + +// https://github.com/foundry-rs/foundry/issues/9643 +test_repro!(9643); diff --git a/testdata/default/repros/Issue9643.t.sol b/testdata/default/repros/Issue9643.t.sol new file mode 100644 index 0000000000000..58688c72d4a22 --- /dev/null +++ b/testdata/default/repros/Issue9643.t.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Mock { + uint256 private counter; + + function setCounter(uint256 _counter) external { + counter = _counter; + } +} + +contract DelegateProxy { + address internal implementation; + + constructor(address mock) { + implementation = mock; + } + + fallback() external payable { + address addr = implementation; + + assembly { + calldatacopy(0, 0, calldatasize()) + let result := delegatecall(gas(), addr, 0, calldatasize(), 0, 0) + returndatacopy(0, 0, returndatasize()) + switch result + case 0 { revert(0, returndatasize()) } + default { return(0, returndatasize()) } + } + } +} + +contract Issue9643Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function test_storage_json_diff() public { + vm.startStateDiffRecording(); + Mock proxied = Mock(address(new DelegateProxy(address(new Mock())))); + proxied.setCounter(42); + string memory rawDiff = vm.getStateDiffJson(); + assertEq( + "{\"0x2e234dae75c793f67a35089c9d99245e1c58470b\":{\"label\":null,\"balanceDiff\":null,\"stateDiff\":{\"0x0000000000000000000000000000000000000000000000000000000000000000\":{\"previousValue\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"newValue\":\"0x000000000000000000000000000000000000000000000000000000000000002a\"}}},\"0x5615deb798bb3e4dfa0139dfa1b3d433cc23b72f\":{\"label\":null,\"balanceDiff\":null,\"stateDiff\":{}}}", + rawDiff + ); + } +} From 49392b53f21714c49b05ee98b24b4ec6b96ebb77 Mon Sep 17 00:00:00 2001 From: Cruz Molina Date: Wed, 8 Jan 2025 10:46:25 -0800 Subject: [PATCH 1837/1963] Feat: Add `cast chain` support for `ink` & `ink-sepolia` (#9652) feat: add `cast chain` support for `ink` & `ink-sepolia` --- crates/cast/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 72083b1f09954..21ee2f04ec9a5 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -454,6 +454,8 @@ where _ => "avalanche", } } + "0x23a2658170ba70d014ba0d0d2709f8fbfe2fa660cd868c5f282f991eecbe38ee" => "ink", + "0xe5fd5cf0be56af58ad5751b401410d6b7a09d830fa459789746a3d0dd1c79834" => "ink-sepolia", _ => "unknown", }) } From 70cd140131cd49875c6f31626bdfae08eba35386 Mon Sep 17 00:00:00 2001 From: Cruz Molina Date: Wed, 8 Jan 2025 12:10:40 -0800 Subject: [PATCH 1838/1963] chore(deps): bump `alloy-chains` (#9653) --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec194355f5e76..2143edba377c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.52" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f15afc5993458b42739ab3b69bdb6b4c8112acd3997dbea9bc092c9517137c" +checksum = "d38fdd69239714d7625cda1e3730773a3c1a8719d506370eb17bb0103b7c2e15" dependencies = [ "alloy-primitives", "num_enum", From 82cf61d1b2525754cb099e0ae46f3773d4557088 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:30:48 +0100 Subject: [PATCH 1839/1963] fix: do not remove `snapshots` directory before running the test suite (#9645) * do not remove snapshots directory before running the test suite, the side effect is that any custom group names or file name changes are not reflected - this is delegated to the end user * do not remove the `snapshots` directory upon running `forge clean` --- crates/config/src/lib.rs | 6 ------ crates/forge/bin/cmd/test/mod.rs | 11 ----------- 2 files changed, 17 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d31f2b96b0073..94fe5c2bca591 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1059,12 +1059,6 @@ impl Config { remove_test_dir(&self.fuzz.failure_persist_dir); remove_test_dir(&self.invariant.failure_persist_dir); - // Remove snapshot directory. - let snapshot_dir = project.root().join(&self.snapshots); - if snapshot_dir.exists() { - let _ = fs::remove_dir_all(&snapshot_dir); - } - Ok(()) } diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 43181a01d53d4..a1b05a2393fdf 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -301,17 +301,6 @@ impl TestArgs { // Create test options from general project settings and compiler output. let project_root = &project.paths.root; - // Remove the snapshots directory if it exists. - // This is to ensure that we don't have any stale snapshots. - // If `FORGE_SNAPSHOT_CHECK` is set, we don't remove the snapshots directory as it is - // required for comparison. - if std::env::var_os("FORGE_SNAPSHOT_CHECK").is_none() { - let snapshot_dir = project_root.join(&config.snapshots); - if snapshot_dir.exists() { - let _ = fs::remove_dir_all(project_root.join(&config.snapshots)); - } - } - let should_debug = self.debug; let should_draw = self.flamegraph || self.flamechart; From 6cbf3908e218a6a17432db380f204b9b4ed126a6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:07:53 +0200 Subject: [PATCH 1840/1963] fix(cheatcodes): record state diff only if balance changed (#9658) --- crates/cheatcodes/src/evm.rs | 14 +++++++------- testdata/default/repros/Issue9643.t.sol | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index ee661dd98d396..32d8cb50d0567 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1149,15 +1149,15 @@ fn get_recorded_state_diffs(state: &mut Cheatcodes) -> BTreeMap Date: Thu, 9 Jan 2025 15:11:52 +0200 Subject: [PATCH 1841/1963] fix(config): disable optimizer by default (#9657) * fix: disable optimizer by default * Set default optimizer runs to 200 --- crates/cast/tests/cli/main.rs | 10 ++++----- crates/config/README.md | 2 +- crates/config/src/lib.rs | 2 +- crates/forge/tests/cli/build.rs | 3 +++ crates/forge/tests/cli/cmd.rs | 31 ++++++++++++++++++++++---- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/create.rs | 4 ++-- crates/forge/tests/cli/script.rs | 32 ++++++++++++++------------- crates/forge/tests/cli/test_cmd.rs | 22 ++++++++++-------- crates/forge/tests/it/fuzz.rs | 3 +++ crates/forge/tests/it/inline.rs | 4 +++- crates/forge/tests/it/invariant.rs | 2 ++ crates/forge/tests/it/test_helpers.rs | 3 +++ 13 files changed, 81 insertions(+), 38 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index f037cb166c47b..2e6ed7cce8bfe 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1832,7 +1832,7 @@ Nothing to compile .stdout_eq(str![[r#" Executing previous transactions from the block. Traces: - [13520] → new @0x5FbDB2315678afecb367f032d93F642f64180aa3 + [..] → new @0x5FbDB2315678afecb367f032d93F642f64180aa3 ├─ emit topic 0: 0xa7263295d3a687d750d1fd377b5df47de69d7db8decc745aaa4bbee44dc1688d │ data: 0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266 └─ ← [Return] 62 bytes of code @@ -1852,7 +1852,7 @@ Executing previous transactions from the block. Compiling project to generate artifacts No files changed, compilation skipped Traces: - [13520] → new LocalProjectContract@0x5FbDB2315678afecb367f032d93F642f64180aa3 + [..] → new LocalProjectContract@0x5FbDB2315678afecb367f032d93F642f64180aa3 ├─ emit LocalProjectContractCreated(owner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266) └─ ← [Return] 62 bytes of code @@ -1914,7 +1914,7 @@ forgetest_async!(show_state_changes_in_traces, |prj, cmd| { .stdout_eq(str![[r#" Executing previous transactions from the block. Traces: - [22287] 0x5FbDB2315678afecb367f032d93F642f64180aa3::setNumber(111) + [..] 0x5FbDB2315678afecb367f032d93F642f64180aa3::setNumber(111) ├─ storage changes: │ @ 0: 0 → 111 └─ ← [Stop] @@ -2005,8 +2005,8 @@ contract CounterInExternalLibScript is Script { .stdout_eq(str![[r#" ... Traces: - [37739] → new @0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 - ├─ [22411] 0xfAb06527117d29EA121998AC4fAB9Fc88bF5f979::updateCounterInExternalLib(0, 100) [delegatecall] + [..] → new @0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 + ├─ [..] 0x52F3e85EC3F0f9D0a2200D646482fcD134D5adc9::updateCounterInExternalLib(0, 100) [delegatecall] │ └─ ← [Stop] └─ ← [Return] 62 bytes of code diff --git a/crates/config/README.md b/crates/config/README.md index 0aa2802e39528..be3055f5816f7 100644 --- a/crates/config/README.md +++ b/crates/config/README.md @@ -86,7 +86,7 @@ gas_reports_ignore = [] # solc = '0.8.10' auto_detect_solc = true offline = false -optimizer = true +optimizer = false optimizer_runs = 200 model_checker = { contracts = { 'a.sol' = [ 'A1', diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 94fe5c2bca591..f7392118d8494 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -2298,7 +2298,7 @@ impl Default for Config { vyper: Default::default(), auto_detect_solc: true, offline: false, - optimizer: true, + optimizer: false, optimizer_runs: 200, optimizer_details: None, model_checker: None, diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 76dd718c60168..15d630f857ba4 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -72,6 +72,7 @@ contract Dummy { }); forgetest!(initcode_size_exceeds_limit, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); cmd.args(["build", "--sizes"]).assert_failure().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -103,6 +104,7 @@ Compiler run successful! }); forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); cmd.args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -149,6 +151,7 @@ Compiler run successful! // tests build output is as expected forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { prj.write_config(Config { + optimizer: true, solc: Some(foundry_config::SolcReq::Version(semver::Version::new(0, 8, 27))), ..Default::default() }); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 62b6de392a8e6..4941a6ea5e614 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1573,6 +1573,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { // report for all prj.write_config(Config { + optimizer: true, gas_reports: (vec!["*".to_string()]), gas_reports_ignore: (vec![]), ..Default::default() @@ -1682,7 +1683,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { gas_reports: (vec![]), ..Default::default() }); + prj.write_config(Config { optimizer: true, gas_reports: (vec![]), ..Default::default() }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1787,7 +1788,11 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() }); + prj.write_config(Config { + optimizer: true, + gas_reports: (vec!["*".to_string()]), + ..Default::default() + }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1893,6 +1898,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); prj.write_config(Config { + optimizer: true, gas_reports: (vec![ "ContractOne".to_string(), "ContractTwo".to_string(), @@ -2010,7 +2016,11 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // report for One - prj.write_config(Config { gas_reports: vec!["ContractOne".to_string()], ..Default::default() }); + prj.write_config(Config { + optimizer: true, + gas_reports: vec!["ContractOne".to_string()], + ..Default::default() + }); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -2057,7 +2067,11 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); // report for Two - prj.write_config(Config { gas_reports: vec!["ContractTwo".to_string()], ..Default::default() }); + prj.write_config(Config { + optimizer: true, + gas_reports: vec!["ContractTwo".to_string()], + ..Default::default() + }); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -2105,6 +2119,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // report for Three prj.write_config(Config { + optimizer: true, gas_reports: vec!["ContractThree".to_string()], ..Default::default() }); @@ -2160,6 +2175,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { // ignore ContractOne prj.write_config(Config { + optimizer: true, gas_reports: (vec!["*".to_string()]), gas_reports_ignore: (vec!["ContractOne".to_string()]), ..Default::default() @@ -2242,6 +2258,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // ignore ContractTwo cmd.forge_fuse(); prj.write_config(Config { + optimizer: true, gas_reports: (vec![]), gas_reports_ignore: (vec!["ContractTwo".to_string()]), ..Default::default() @@ -2328,6 +2345,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // indicating the "double listing". cmd.forge_fuse(); prj.write_config(Config { + optimizer: true, gas_reports: (vec![ "ContractOne".to_string(), "ContractTwo".to_string(), @@ -2461,6 +2479,7 @@ Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. }); forgetest!(gas_report_flatten_multiple_selectors, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.insert_ds_test(); prj.add_source( "Counter.sol", @@ -2579,6 +2598,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_with_fallback, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_test( "DelegateProxyTest.sol", r#" @@ -2722,6 +2742,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_test( "NestedDeployTest.sol", r#" @@ -3160,6 +3181,7 @@ Error: No source files found in specified build paths. // checks that build --sizes includes all contracts even if unchanged forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.clear_cache(); cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" @@ -3226,6 +3248,7 @@ interface Counter { // checks that `clean` also works with the "out" value set in Config forgetest_init!(gas_report_include_tests, |prj, cmd| { prj.write_config(Config { + optimizer: true, gas_reports_include_tests: true, fuzz: FuzzConfig { runs: 1, ..Default::default() }, ..Default::default() diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 61e63abf9336a..e4c8e25a7ca1b 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -426,6 +426,7 @@ Compiler run successful! // test to ensure yul optimizer can be set as intended forgetest!(can_set_yul_optimizer, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source( "foo.sol", r" diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index 6a78f83231ef9..fab7eb720acd0 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -168,7 +168,7 @@ Transaction: { "to": null, "maxFeePerGas": "0x77359401", "maxPriorityFeePerGas": "0x1", - "gas": "0x17575", + "gas": "0x241e7", "input": "[..]", "nonce": "0x0", "chainId": "0x7a69" @@ -222,7 +222,7 @@ ABI: [ "to": null, "maxFeePerGas": "0x77359401", "maxPriorityFeePerGas": "0x1", - "gas": "0x17575", + "gas": "0x241e7", "input": "[..]", "nonce": "0x0", "chainId": "0x7a69" diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 09df55668ed0d..bfd7fde8f371d 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -4,6 +4,7 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{address, hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; use forge_script_sequence::ScriptSequence; +use foundry_config::Config; use foundry_test_utils::{ rpc, snapbox::IntoData, @@ -230,7 +231,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new GasWaster@[..] - │ └─ ← [Return] 221 bytes of code + │ └─ ← [Return] 415 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -242,10 +243,10 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [44291] → new GasWaster@[..] - └─ ← [Return] 221 bytes of code + [..] → new GasWaster@[..] + └─ ← [Return] 415 bytes of code - [224] GasWaster::wasteGas(200000 [2e5]) + [..] GasWaster::wasteGas(200000 [2e5]) └─ ← [Stop] @@ -336,7 +337,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new GasWaster@[..] - │ └─ ← [Return] 221 bytes of code + │ └─ ← [Return] 415 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) │ └─ ← [Stop] └─ ← [Stop] @@ -348,10 +349,10 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [44291] → new GasWaster@[..] - └─ ← [Return] 221 bytes of code + [..] → new GasWaster@[..] + └─ ← [Return] 415 bytes of code - [224] GasWaster::wasteGas(200000 [2e5]) + [..] GasWaster::wasteGas(200000 [2e5]) └─ ← [Stop] @@ -520,7 +521,7 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new HashChecker@[..] - │ └─ ← [Return] 368 bytes of code + │ └─ ← [Return] 718 bytes of code └─ ← [Stop] @@ -1925,6 +1926,7 @@ forgetest_async!(adheres_to_json_flag, |prj, cmd| { } foundry_test_utils::util::initialize(prj.root()); + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_script( "Foo", r#" @@ -2372,9 +2374,9 @@ Traces: ├─ [0] VM::startBroadcast() │ └─ ← [Return] ├─ [..] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 - │ └─ ← [Return] 116 bytes of code + │ └─ ← [Return] 175 bytes of code ├─ [..] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 - │ ├─ [145] A::getValue() [staticcall] + │ ├─ [..] A::getValue() [staticcall] │ │ └─ ← [Return] 100 │ └─ ← [Return] 62 bytes of code └─ ← [Stop] @@ -2386,11 +2388,11 @@ Script ran successfully. ========================== Simulated On-chain Traces: - [23273] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 - └─ ← [Return] 116 bytes of code + [..] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 + └─ ← [Return] 175 bytes of code - [15662] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 - ├─ [145] A::getValue() [staticcall] + [..] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 + ├─ [..] A::getValue() [staticcall] │ └─ ← [Return] 100 └─ ← [Return] 62 bytes of code ... diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 64faff26dbe09..f19eefeb92b9c 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -591,6 +591,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/6579 forgetest_init!(include_custom_types_in_traces, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -958,6 +959,7 @@ contract SetupFailureTest is Test { // https://github.com/foundry-rs/foundry/issues/7530 forgetest_init!(should_show_precompile_labels, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1214,9 +1216,6 @@ forgetest_init!(internal_functions_trace, |prj, cmd| { prj.wipe_contracts(); prj.clear(); - // Disable optimizer because for simple contract most functions will get inlined. - prj.write_config(Config { optimizer: false, ..Default::default() }); - prj.add_test( "Simple", r#" @@ -1264,7 +1263,7 @@ Compiler run successful! Ran 1 test for test/Simple.sol:SimpleContractTest [PASS] test() ([GAS]) Traces: - [244864] SimpleContractTest::test() + [..] SimpleContractTest::test() ├─ [165406] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 826 bytes of code ├─ [22630] SimpleContract::increment() @@ -1292,9 +1291,6 @@ forgetest_init!(internal_functions_trace_memory, |prj, cmd| { prj.wipe_contracts(); prj.clear(); - // Disable optimizer because for simple contract most functions will get inlined. - prj.write_config(Config { optimizer: false, ..Default::default() }); - prj.add_test( "Simple", r#" @@ -1325,7 +1321,7 @@ contract SimpleContractTest is Test { cmd.args(["test", "-vvvv", "--decode-internal"]).assert_success().stdout_eq(str![[r#" ... Traces: - [406629] SimpleContractTest::test() + [..] SimpleContractTest::test() ├─ [370554] → new SimpleContract@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 1737 bytes of code ├─ [2511] SimpleContract::setStr("new value") @@ -1421,6 +1417,7 @@ contract DeterministicRandomnessTest is Test { // Tests that `pauseGasMetering` used at the end of test does not produce meaningless values. // https://github.com/foundry-rs/foundry/issues/5491 forgetest_init!(gas_metering_pause_last_call, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1506,6 +1503,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/4523 forgetest_init!(gas_metering_gasleft, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1584,6 +1582,7 @@ contract ATest is Test { // tests `pauseTracing` and `resumeTracing` functions #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(pause_tracing, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.wipe_contracts(); prj.insert_ds_test(); prj.insert_vm(); @@ -2332,6 +2331,7 @@ Logs: // forgetest_init!(metadata_bytecode_traces, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source( "ParentProxy.sol", r#" @@ -2454,6 +2454,7 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test().silent()).await; + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.insert_vm(); prj.insert_ds_test(); prj.insert_console(); @@ -2702,6 +2703,8 @@ Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] // Tests that test traces display state changes when running with verbosity. #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(should_show_state_changes, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); + cmd.args(["test", "--mt", "test_Increment", "-vvvvv"]).assert_success().stdout_eq(str![[r#" ... Ran 1 test for test/Counter.t.sol:CounterTest @@ -2761,6 +2764,7 @@ Encountered a total of 1 failing tests, 0 tests succeeded // Tests that `start/stopAndReturn` debugTraceRecording does not panic when running with // verbosity > 3. forgetest_init!(should_not_panic_on_debug_trace_verbose, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_test( "DebugTraceRecordingTest.t.sol", r#" @@ -2788,7 +2792,7 @@ Compiler run successful! Ran 1 test for test/DebugTraceRecordingTest.t.sol:DebugTraceRecordingTest [PASS] test_start_stop_recording() ([GAS]) Traces: - [476338] DebugTraceRecordingTest::test_start_stop_recording() + [..] DebugTraceRecordingTest::test_start_stop_recording() └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 8b49d4accad31..627232df9bc56 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -7,6 +7,7 @@ use forge::{ fuzz::CounterExample, result::{SuiteResult, TestStatus}, }; +use foundry_config::Config; use foundry_test_utils::{forgetest_init, str, Filter}; use std::collections::BTreeMap; @@ -117,6 +118,7 @@ async fn test_persist_fuzz_failure() { () => { run_fail!(|config| {}) }; (|$config:ident| $e:expr) => {{ let mut runner = TEST_DATA_DEFAULT.runner_with(|$config| { + $config.optimizer = true; $config.fuzz.runs = 1000; $e }); @@ -161,6 +163,7 @@ async fn test_persist_fuzz_failure() { } forgetest_init!(test_can_scrape_bytecode, |prj, cmd| { + prj.write_config(Config { optimizer: true, ..Default::default() }); prj.add_source( "FuzzerDict.sol", r#" diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index eab7f9ec1bb16..0a1956c456bfc 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -7,7 +7,9 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner(); + let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { + config.optimizer = true; + }); let result = runner.test_collect(&filter); let results = result .into_iter() diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index ab04ae7b5499f..fc58805b48787 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -263,6 +263,7 @@ async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { config.fuzz.seed = Some(U256::from(119u32)); + config.optimizer = true; }); match get_counterexample!(runner, &filter) { @@ -795,6 +796,7 @@ contract AssumeTest is Test { // forgetest_init!(should_revert_with_assume_code, |prj, cmd| { let config = Config { + optimizer: true, invariant: { InvariantConfig { fail_on_revert: true, max_assume_rejects: 10, ..Default::default() } }, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 3dd38a418d6a4..68fb231f9da9c 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -89,6 +89,9 @@ impl ForgeTestProfile { config.prompt_timeout = 0; + config.optimizer = true; + config.optimizer_runs = 200; + config.gas_limit = u64::MAX.into(); config.chain = None; config.tx_origin = CALLER; From af9ceec4a0fb21c88e42f55e5915492b6ef09cec Mon Sep 17 00:00:00 2001 From: Drake Evans <31104161+DrakeEvans@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:10:14 -0500 Subject: [PATCH 1842/1963] fix: incorrect repo link in readme for foundry-compilers (#9660) fix: incorrect repo link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd93251911219..3a6b24f233122 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ If you want to contribute, or follow along with contributor discussion, you can [foundry-book]: https://book.getfoundry.sh [foundry-gha]: https://github.com/foundry-rs/foundry-toolchain [ethers-solc]: https://github.com/gakonst/ethers-rs/tree/master/ethers-solc/ -[foundry-compilers]: https://github.com/foundry-rs/foundry-compilers +[foundry-compilers]: https://github.com/foundry-rs/compilers [solmate]: https://github.com/transmissions11/solmate/ [geb]: https://github.com/reflexer-labs/geb [vaults]: https://github.com/rari-capital/vaults From 192aa2cbe10bcab61eb769dd714f80762a77a681 Mon Sep 17 00:00:00 2001 From: Delweng Date: Fri, 10 Jan 2025 02:59:28 +0800 Subject: [PATCH 1843/1963] feat: add arm64 docker image (#9614) * feat(docker): build arm64 image Signed-off-by: jsvisa * wip Signed-off-by: jsvisa * Revert "wip" This reverts commit a152a4c30b7aa510b95d32d5dc8d8d655e90d7f0. Signed-off-by: jsvisa * Revert "feat(docker): build arm64 image" This reverts commit 09adcbc0f4129f74831588a7e1665a7064eea2f6. Signed-off-by: jsvisa * feat(make): add cross docker build Signed-off-by: jsvisa * feat(make): multi tags Signed-off-by: jsvisa * feat(github): use cross build Signed-off-by: jsvisa * add Dockerfile.cross Signed-off-by: jsvisa * fix(make): don't recreate cross-builder Signed-off-by: jsvisa * make: add log Signed-off-by: jsvisa * fix: missing \ Signed-off-by: jsvisa * typo Signed-off-by: jsvisa * Update docker-publish.yml Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Signed-off-by: jsvisa Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- .github/workflows/docker-publish.yml | 152 ++++++++++++--------------- Dockerfile.cross | 21 ++++ Makefile | 49 ++++++++- 3 files changed, 136 insertions(+), 86 deletions(-) create mode 100644 Dockerfile.cross diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a4d2543c20846..ba8fc5b552c13 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,96 +1,78 @@ name: docker on: - push: - tags: - - "v*.*.*" - schedule: - - cron: "0 0 * * *" - # Trigger without any parameters a proactive rebuild - workflow_dispatch: {} - workflow_call: + push: + tags: + - "v*.*.*" + schedule: + - cron: "0 0 * * *" + # Trigger without any parameters a proactive rebuild + workflow_dispatch: {} + workflow_call: env: - REGISTRY: ghcr.io - # Will resolve to foundry-rs/foundry - IMAGE_NAME: ${{ github.repository }} + REGISTRY: ghcr.io + # Will resolve to foundry-rs/foundry + IMAGE_NAME: ${{ github.repository }} jobs: - container: - runs-on: Linux-20.04 - # https://docs.github.com/en/actions/reference/authentication-in-a-workflow - permissions: - id-token: write - packages: write - contents: read - timeout-minutes: 120 - steps: - - name: Checkout repository - id: checkout - uses: actions/checkout@v4 + build: + name: build and push + runs-on: Linux-20.04 + permissions: + id-token: write + packages: write + contents: read + timeout-minutes: 120 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - uses: taiki-e/install-action@cross + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Login into registry ${{ env.REGISTRY }} + # Ensure this doesn't trigger on PR's + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Install Docker BuildX - uses: docker/setup-buildx-action@v2 - id: buildx - with: - install: true + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - # Ensure this doesn't trigger on PR's - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # Creates an additional 'latest' or 'nightly' tag + # If the job is triggered via cron schedule, tag nightly and nightly-{SHA} + # If the job is triggered via workflow dispatch and on a master branch, tag branch and latest + # Otherwise, just tag as the branch name + - name: Finalize Docker Metadata + id: docker_tagging + run: | + if [[ "${{ github.event_name }}" == 'schedule' ]]; then + echo "cron trigger, assigning nightly tag" + echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT + elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then + echo "manual trigger from master/main branch, assigning latest tag" + echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT + else + echo "Neither scheduled nor manual release from main branch. Just tagging as branch name" + echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT + fi - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # Log docker metadata to explicitly know what is being pushed + - name: Inspect Docker Metadata + run: | + echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}" + echo "LABELS -> ${{ steps.meta.outputs.labels }}" - # Creates an additional 'latest' or 'nightly' tag - # If the job is triggered via cron schedule, tag nightly and nightly-{SHA} - # If the job is triggered via workflow dispatch and on a master branch, tag branch and latest - # Otherwise, just tag as the branch name - - name: Finalize Docker Metadata - id: docker_tagging - run: | - if [[ "${{ github.event_name }}" == 'schedule' ]]; then - echo "cron trigger, assigning nightly tag" - echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT - elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then - echo "manual trigger from master/main branch, assigning latest tag" - echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT - else - echo "Neither scheduled nor manual release from main branch. Just tagging as branch name" - echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT - fi - - # Log docker metadata to explicitly know what is being pushed - - name: Inspect Docker Metadata - run: | - echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}" - echo "LABELS -> ${{ steps.meta.outputs.labels }}" - - # Build and push Docker image - # https://github.com/docker/build-push-action - # https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ${{ steps.docker_tagging.outputs.docker_tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} - VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + - name: Build and push foundry image + run: make DOCKER_IMAGE_NAME=${{ steps.docker_tagging.outputs.docker_tags }} PROFILE=maxperf docker-build-push diff --git a/Dockerfile.cross b/Dockerfile.cross new file mode 100644 index 0000000000000..0ee87e33bf808 --- /dev/null +++ b/Dockerfile.cross @@ -0,0 +1,21 @@ +# This image is meant to enable cross-architecture builds. +# It assumes the foundry binaries have already been compiled for `$TARGETPLATFORM` and are +# locatable in `./dist/bin/$TARGETARCH` +FROM ubuntu:22.04 + +# Filled by docker buildx +ARG TARGETARCH + +COPY ./dist/bin/$TARGETARCH/* /usr/local/bin/ + +ENTRYPOINT ["/bin/sh", "-c"] + +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name="Foundry" \ + org.label-schema.description="Foundry" \ + org.label-schema.url="https://getfoundry.sh" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/foundry-rs/foundry.git" \ + org.label-schema.vendor="Foundry-rs" \ + org.label-schema.version=$VERSION \ + org.label-schema.schema-version="1.0" diff --git a/Makefile b/Makefile index 920e4de2d5fc4..79544ce85423d 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,10 @@ # Cargo profile for builds. PROFILE ?= dev +# The docker image name +DOCKER_IMAGE_NAME ?= ghcr.io/foundry-rs/foundry:latest +BIN_DIR = dist/bin +CARGO_TARGET_DIR ?= target # List of features to use when building. Can be overridden via the environment. # No jemalloc on Windows @@ -26,6 +30,49 @@ help: ## Display this help. build: ## Build the project. cargo build --features "$(FEATURES)" --profile "$(PROFILE)" +# The following commands use `cross` to build a cross-compile. +# +# These commands require that: +# +# - `cross` is installed (`cargo install cross`). +# - Docker is running. +# - The current user is in the `docker` group. +# +# The resulting binaries will be created in the `target/` directory. +build-%: + cross build --target $* --features "$(FEATURES)" --profile "$(PROFILE)" + +.PHONY: docker-build-push +docker-build-push: docker-build-prepare ## Build and push a cross-arch Docker image tagged with DOCKER_IMAGE_NAME. + $(MAKE) build-x86_64-unknown-linux-gnu + mkdir -p $(BIN_DIR)/amd64 + for bin in anvil cast chisel forge; do \ + cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/$$bin $(BIN_DIR)/amd64/; \ + done + + $(MAKE) build-aarch64-unknown-linux-gnu + mkdir -p $(BIN_DIR)/arm64 + for bin in anvil cast chisel forge; do \ + cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/$$bin $(BIN_DIR)/arm64/; \ + done + + docker buildx build --file ./Dockerfile.cross . \ + --platform linux/amd64,linux/arm64 \ + $(foreach tag,$(shell echo $(DOCKER_IMAGE_NAME) | tr ',' ' '),--tag $(tag)) \ + --provenance=false \ + --push + +.PHONY: docker-build-prepare +docker-build-prepare: ## Prepare the Docker build environment. + docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64 + @if ! docker buildx inspect cross-builder &> /dev/null; then \ + echo "Creating a new buildx builder instance"; \ + docker buildx create --use --driver docker-container --name cross-builder; \ + else \ + echo "Using existing buildx builder instance"; \ + docker buildx use cross-builder; \ + fi + ##@ Other .PHONY: clean @@ -69,4 +116,4 @@ test: ## Run all tests. pr: ## Run all tests and linters in preparation for a PR. make lint && \ - make test \ No newline at end of file + make test From 0cc535504a909dcee74694fa86f7faafa4cbf4bc Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 10 Jan 2025 09:43:56 +0200 Subject: [PATCH 1844/1963] chore: fix test isolate, different address for caller (#9663) --- .../default/cheats/RecordAccountAccesses.t.sol | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/testdata/default/cheats/RecordAccountAccesses.t.sol b/testdata/default/cheats/RecordAccountAccesses.t.sol index 8de7bcdc5bd31..63100f51f1284 100644 --- a/testdata/default/cheats/RecordAccountAccesses.t.sol +++ b/testdata/default/cheats/RecordAccountAccesses.t.sol @@ -343,14 +343,12 @@ contract RecordAccountAccessesTest is DSTest { // contract calls to self in constructor SelfCaller caller = new SelfCaller{value: 2 ether}("hello2 world2"); - assertEq( - "0x000000000000000000000000000000000000162e\n- balance diff: 0 \xE2\x86\x92 1000000000000000000\n\n0x1d1499e622D69689cdf9004d05Ec547d650Ff211\n- balance diff: 0 \xE2\x86\x92 2000000000000000000\n\n", - cheats.getStateDiff() - ); - assertEq( - "{\"0x000000000000000000000000000000000000162e\":{\"label\":null,\"balanceDiff\":{\"previousValue\":\"0x0\",\"newValue\":\"0xde0b6b3a7640000\"},\"stateDiff\":{}},\"0x1d1499e622d69689cdf9004d05ec547d650ff211\":{\"label\":null,\"balanceDiff\":{\"previousValue\":\"0x0\",\"newValue\":\"0x1bc16d674ec80000\"},\"stateDiff\":{}}}", - cheats.getStateDiffJson() - ); + string memory callerAddress = cheats.toString(address(caller)); + string memory expectedStateDiff = + "0x000000000000000000000000000000000000162e\n- balance diff: 0 \xE2\x86\x92 1000000000000000000\n\n"; + expectedStateDiff = string.concat(expectedStateDiff, callerAddress); + expectedStateDiff = string.concat(expectedStateDiff, "\n- balance diff: 0 \xE2\x86\x92 2000000000000000000\n\n"); + assertEq(expectedStateDiff, cheats.getStateDiff()); Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(cheats.stopAndReturnStateDiff()); assertEq(called.length, 6); From 6f81e768112e402e317565880889359dbf31055d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:12:49 +0200 Subject: [PATCH 1845/1963] fix: set debug none for release profile (#9664) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 636f4fd6291b5..5610368c6d374 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,7 +67,7 @@ split-debuginfo = "unpacked" [profile.release] opt-level = 3 lto = "thin" -debug = "line-tables-only" +debug = "none" strip = "debuginfo" panic = "abort" codegen-units = 16 From 761d9e17286c82808a3f92ea4760292fec713c3c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 12:32:23 +0100 Subject: [PATCH 1846/1963] chore(deps): weekly `cargo update` (#9668) Locking 41 packages to latest compatible versions Updating alloy-chains v0.1.54 -> v0.1.55 Updating async-trait v0.1.84 -> v0.1.85 Updating aws-sdk-sts v1.54.0 -> v1.54.1 Updating bitflags v2.6.0 -> v2.7.0 Updating cc v1.2.7 -> v1.2.8 Updating clap v4.5.23 -> v4.5.26 Updating clap_builder v4.5.23 -> v4.5.26 Updating clap_complete v4.5.40 -> v4.5.42 Updating clap_derive v4.5.18 -> v4.5.24 Updating handlebars v6.2.0 -> v6.3.0 Updating inferno v0.12.0 -> v0.12.1 Updating instability v0.3.6 -> v0.3.7 Adding itertools v0.14.0 Updating linux-raw-sys v0.4.14 -> v0.4.15 Updating nybbles v0.3.3 -> v0.3.4 Updating op-alloy-consensus v0.9.0 -> v0.9.2 Updating op-alloy-rpc-types v0.9.0 -> v0.9.2 Updating phf v0.11.2 -> v0.11.3 Updating phf_codegen v0.11.2 -> v0.11.3 Updating phf_generator v0.11.2 -> v0.11.3 Updating phf_macros v0.11.2 -> v0.11.3 Updating phf_shared v0.11.2 -> v0.11.3 Updating pin-project v1.1.7 -> v1.1.8 Updating pin-project-internal v1.1.7 -> v1.1.8 Updating pin-project-lite v0.2.15 -> v0.2.16 Updating prettyplease v0.2.25 -> v0.2.27 Updating proc-macro2 v1.0.92 -> v1.0.93 Updating revm v19.0.0 -> v19.2.0 Updating rustix v0.38.42 -> v0.38.43 Updating rustls v0.23.20 -> v0.23.21 Updating security-framework v3.1.0 -> v3.2.0 Updating security-framework-sys v2.13.0 -> v2.14.0 Updating serde_json v1.0.134 -> v1.0.135 Adding siphasher v1.0.1 Updating syn v2.0.94 -> v2.0.96 Updating thiserror v2.0.9 -> v2.0.11 Updating thiserror-impl v2.0.9 -> v2.0.11 Updating tokio v1.42.0 -> v1.43.0 Updating tokio-macros v2.4.0 -> v2.5.0 Updating uuid v1.11.0 -> v1.11.1 Updating winnow v0.6.22 -> v0.6.24 note: pass `--verbose` to see 12 unchanged dependencies behind latest Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 494 +++++++++++++++++++++++++++-------------------------- 1 file changed, 255 insertions(+), 239 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2143edba377c8..e1586fdb0ad0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.54" +version = "0.1.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38fdd69239714d7625cda1e3730773a3c1a8719d506370eb17bb0103b7c2e15" +checksum = "1e39f295f876b61a1222d937e1dd31f965e4a1acc3bba98e448dd7e84b1a4566" dependencies = [ "alloy-primitives", "num_enum", @@ -134,7 +134,7 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -239,7 +239,7 @@ dependencies = [ "alloy-sol-types", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", ] @@ -265,7 +265,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -293,7 +293,7 @@ dependencies = [ "rand", "serde_json", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", "url", ] @@ -360,12 +360,12 @@ dependencies = [ "futures-utils-wasm", "lru", "parking_lot", - "pin-project 1.1.7", + "pin-project 1.1.8", "reqwest", "schnellru", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tracing", "url", @@ -410,7 +410,7 @@ checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -427,7 +427,7 @@ dependencies = [ "alloy-transport-ipc", "alloy-transport-ws", "futures", - "pin-project 1.1.7", + "pin-project 1.1.8", "reqwest", "serde", "serde_json", @@ -523,7 +523,7 @@ dependencies = [ "itertools 0.13.0", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -537,7 +537,7 @@ dependencies = [ "alloy-serde", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -576,7 +576,7 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -593,7 +593,7 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", ] @@ -611,7 +611,7 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", ] @@ -631,7 +631,7 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.24", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", ] @@ -651,7 +651,7 @@ dependencies = [ "eth-keystore", "k256", "rand", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -666,7 +666,7 @@ dependencies = [ "alloy-signer", "async-trait", "semver 1.0.24", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", "trezor-client", ] @@ -682,7 +682,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -699,7 +699,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", "syn-solidity", "tiny-keccak", ] @@ -717,7 +717,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.94", + "syn 2.0.96", "syn-solidity", ] @@ -756,7 +756,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tower 0.5.2", "tracing", @@ -791,7 +791,7 @@ dependencies = [ "bytes", "futures", "interprocess", - "pin-project 1.1.7", + "pin-project 1.1.8", "serde", "serde_json", "tempfile", @@ -810,7 +810,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.2.0", - "rustls 0.23.20", + "rustls 0.23.21", "serde_json", "tokio", "tokio-tungstenite", @@ -982,7 +982,7 @@ dependencies = [ "serde_repr", "similar-asserts", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", "tikv-jemallocator", "tokio", "tower 0.4.13", @@ -1013,7 +1013,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -1036,10 +1036,10 @@ dependencies = [ "futures", "interprocess", "parking_lot", - "pin-project 1.1.7", + "pin-project 1.1.8", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio-util", "tower-http", "tracing", @@ -1242,7 +1242,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -1264,18 +1264,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] name = "async-trait" -version = "0.1.84" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -1328,7 +1328,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -1401,7 +1401,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.11.0", + "uuid 1.11.1", ] [[package]] @@ -1472,9 +1472,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.54.0" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "249b2acaa8e02fd4718705a9494e3eb633637139aa4bb09d70965b0448e865db" +checksum = "861d324ef69247c6f3c6823755f408a68877ffb1a9afaff6dd8b0057c760de60" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1798,9 +1798,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" dependencies = [ "arbitrary", "serde", @@ -1862,7 +1862,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2047,9 +2047,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.7" +version = "1.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" +checksum = "ad0cf6e91fde44c773c6ee7ec6bba798504641a8bc2eb7e37a04ffbf4dfaa55a" dependencies = [ "shlex", ] @@ -2162,9 +2162,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" dependencies = [ "clap_builder", "clap_derive", @@ -2172,9 +2172,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" dependencies = [ "anstream", "anstyle", @@ -2187,9 +2187,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.40" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2e663e3e3bed2d32d065a8404024dad306e699a04263ec59919529f803aee9" +checksum = "33a7e468e750fa4b6be660e8b5651ad47372e8fb114030b594c2d75d48c5ffd0" dependencies = [ "clap", ] @@ -2206,14 +2206,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2541,7 +2541,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "crossterm_winapi", "mio 1.0.3", "parking_lot", @@ -2628,7 +2628,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2639,7 +2639,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2712,7 +2712,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2733,7 +2733,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2743,7 +2743,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2764,7 +2764,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", "unicode-xid", ] @@ -2872,7 +2872,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -2897,7 +2897,7 @@ checksum = "8dc51d98e636f5e3b0759a39257458b22619cac7e96d932da6eeb052891bb67c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -3024,7 +3024,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -3359,7 +3359,7 @@ dependencies = [ "strum", "svm-rs", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", "tikv-jemallocator", "tokio", "toml 0.8.19", @@ -3392,7 +3392,7 @@ dependencies = [ "serde", "serde_json", "solang-parser", - "thiserror 2.0.9", + "thiserror 2.0.11", "toml 0.8.19", "tracing", ] @@ -3407,7 +3407,7 @@ dependencies = [ "itertools 0.13.0", "similar-asserts", "solang-parser", - "thiserror 2.0.9", + "thiserror 2.0.11", "toml 0.8.19", "tracing", "tracing-subscriber", @@ -3489,7 +3489,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -3595,7 +3595,7 @@ dependencies = [ "semver 1.0.24", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", "toml 0.8.19", "tracing", "vergen", @@ -3694,7 +3694,7 @@ dependencies = [ "serde_json", "similar-asserts", "terminal_size", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tower 0.4.13", "tracing", @@ -3753,7 +3753,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tracing", "winnow", @@ -3787,7 +3787,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tracing", "walkdir", @@ -3826,7 +3826,7 @@ dependencies = [ "serde_json", "svm-rs", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "walkdir", ] @@ -3860,7 +3860,7 @@ dependencies = [ "similar-asserts", "solar-parse", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", "toml 0.8.19", "toml_edit", "tracing", @@ -3909,7 +3909,7 @@ dependencies = [ "revm", "revm-inspectors", "serde", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", ] @@ -3955,7 +3955,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tracing", "url", @@ -3998,7 +3998,7 @@ dependencies = [ "rand", "revm", "serde", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", ] @@ -4048,7 +4048,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tracing", "url", @@ -4061,7 +4061,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "semver 1.0.24", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -4071,7 +4071,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -4123,7 +4123,7 @@ dependencies = [ "gcloud-sdk", "rpassword", "serde", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tracing", ] @@ -4231,7 +4231,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -4382,11 +4382,11 @@ version = "0.14.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49aaeef5d98390a3bcf9dbc6440b520b793d1bf3ed99317dc407b02be995b28e" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "bstr", "gix-path", "libc", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -4398,7 +4398,7 @@ dependencies = [ "bstr", "itoa", "jiff", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -4433,7 +4433,7 @@ version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74908b4bbc0a0a40852737e5d7889f676f081e340d5451a16e5b4c50d592f111" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "bstr", "gix-features", "gix-path", @@ -4489,7 +4489,7 @@ dependencies = [ "gix-trace", "home", "once_cell", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -4519,7 +4519,7 @@ version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8b876ef997a955397809a2ec398d6a45b7a55b4918f2446344330f778d14fd6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "gix-path", "libc", "windows-sys 0.52.0", @@ -4561,7 +4561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" dependencies = [ "bstr", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -4644,17 +4644,18 @@ dependencies = [ [[package]] name = "handlebars" -version = "6.2.0" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4ccde012831f9a071a637b0d4e31df31c0f6c525784b35ae76a9ac6bc1e315" +checksum = "3d6b224b95c1e668ac0270325ad563b2eef1469fbbb8959bc7c692c844b813d9" dependencies = [ + "derive_builder", "log", "num-order", "pest", "pest_derive", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] @@ -4759,7 +4760,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -4923,7 +4924,7 @@ dependencies = [ "http 1.2.0", "hyper 1.5.2", "hyper-util", - "rustls 0.23.20", + "rustls 0.23.21", "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", @@ -5118,7 +5119,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -5200,7 +5201,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -5258,9 +5259,9 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "inferno" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75a5d75fee4d36809e6b021e4b96b686e763d365ffdb03af2bd00786353f84fe" +checksum = "692eda1cc790750b9f5a5e3921ef9c117fd5498b97cfacbc910693e5b29002dc" dependencies = [ "ahash", "itoa", @@ -5309,15 +5310,15 @@ dependencies = [ [[package]] name = "instability" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "894813a444908c0c8c0e221b041771d107c4a21de1d317dc49bcc66e3c9e5b3f" +checksum = "0bf9fed6d91cfb734e7476a06bde8300a1b94e217e1b523b6f0cd1a01998c71d" dependencies = [ "darling", "indoc", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -5385,6 +5386,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.14" @@ -5586,7 +5596,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "libc", "redox_syscall", ] @@ -5605,9 +5615,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -5799,7 +5809,7 @@ checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -5889,7 +5899,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -5921,7 +5931,7 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8781e2ef64806278a55ad223f0bc875772fd40e1fe6e73e8adbf027817229d" dependencies = [ - "uuid 1.11.0", + "uuid 1.11.1", ] [[package]] @@ -5952,7 +5962,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "cfg-if", "cfg_aliases 0.1.1", "libc", @@ -5964,7 +5974,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "cfg-if", "cfg_aliases 0.2.1", "libc", @@ -6007,7 +6017,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "crossbeam-channel", "filetime", "fsevent-sys", @@ -6162,7 +6172,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6182,9 +6192,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nybbles" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3409fc85ac27b27d971ea7cd1aabafd2eefa6de7e481c8d4f707225c117e81a" +checksum = "8983bb634df7248924ee0c4c3a749609b5abcb082c28fffe3254b3eb3602b307" dependencies = [ "alloy-rlp", "const-hex", @@ -6210,9 +6220,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0adb232ec805af3aa35606c19329aa7dc44c4457ae318ed0b8fc7f799dd7dbfe" +checksum = "442518bf0ef88f4d79409527565b8cdee235c891f2e2a829497caec5ed9d8d1c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6221,14 +6231,14 @@ dependencies = [ "alloy-serde", "derive_more", "serde", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] name = "op-alloy-rpc-types" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e68d1a51fe3ee143f102b82f54fa237f21d12635da363276901e6d3ef6c65b7b" +checksum = "50223d61cad040db6721bcc2d489c924c1691ce3f5e674d4d8776131dab786a0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6260,7 +6270,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "cfg-if", "foreign-types", "libc", @@ -6277,7 +6287,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6440,7 +6450,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6475,7 +6485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.9", + "thiserror 2.0.11", "ucd-trie", ] @@ -6499,7 +6509,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6535,22 +6545,22 @@ dependencies = [ [[package]] name = "phf" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_macros", - "phf_shared 0.11.2", + "phf_shared 0.11.3", ] [[package]] name = "phf_codegen" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" dependencies = [ - "phf_generator 0.11.2", - "phf_shared 0.11.2", + "phf_generator 0.11.3", + "phf_shared 0.11.3", ] [[package]] @@ -6565,25 +6575,25 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ - "phf_shared 0.11.2", + "phf_shared 0.11.3", "rand", ] [[package]] name = "phf_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" dependencies = [ - "phf_generator 0.11.2", - "phf_shared 0.11.2", + "phf_generator 0.11.3", + "phf_shared 0.11.3", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6592,16 +6602,16 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" dependencies = [ - "siphasher", + "siphasher 0.3.11", ] [[package]] name = "phf_shared" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "siphasher", + "siphasher 1.0.1", ] [[package]] @@ -6615,11 +6625,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" dependencies = [ - "pin-project-internal 1.1.7", + "pin-project-internal 1.1.8", ] [[package]] @@ -6635,20 +6645,20 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -6736,12 +6746,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "483f8c21f64f3ea09fe0f30f5d48c3e8eefe5dac9129f0075f76593b4c1da705" dependencies = [ "proc-macro2", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6816,14 +6826,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -6836,7 +6846,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", "version_check", "yansi", ] @@ -6880,7 +6890,7 @@ checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.6.0", + "bitflags 2.7.0", "lazy_static", "num-traits", "rand", @@ -6900,7 +6910,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6923,7 +6933,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -6961,7 +6971,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "memchr", "pulldown-cmark-escape", "unicase", @@ -6990,8 +7000,8 @@ dependencies = [ "newtype-uuid", "quick-xml 0.37.2", "strip-ansi-escapes", - "thiserror 2.0.9", - "uuid 1.11.0", + "thiserror 2.0.11", + "uuid 1.11.1", ] [[package]] @@ -7023,9 +7033,9 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.20", + "rustls 0.23.21", "socket2", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "tracing", ] @@ -7041,10 +7051,10 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.20", + "rustls 0.23.21", "rustls-pki-types", "slab", - "thiserror 2.0.9", + "thiserror 2.0.11", "tinyvec", "tracing", "web-time", @@ -7135,7 +7145,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "cassowary", "compact_str", "crossterm", @@ -7182,7 +7192,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", ] [[package]] @@ -7275,7 +7285,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.20", + "rustls 0.23.21", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7301,9 +7311,9 @@ dependencies = [ [[package]] name = "revm" -version = "19.0.0" +version = "19.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8905d0c5f10e767f13ea7cb8e502d315f144071a60fe2bd83977922dd3afa26" +checksum = "8b829dc9d6e62c5a540dfdceb0c4d2217e445bf5f6f5ed3866817e7a9637c019" dependencies = [ "auto_impl", "cfg-if", @@ -7330,7 +7340,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.9", + "thiserror 2.0.11", ] [[package]] @@ -7373,7 +7383,7 @@ dependencies = [ "alloy-eip7702", "alloy-primitives", "auto_impl", - "bitflags 2.6.0", + "bitflags 2.7.0", "bitvec", "c-kzg", "cfg-if", @@ -7541,11 +7551,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "errno", "libc", "linux-raw-sys", @@ -7566,9 +7576,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.20" +version = "0.23.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" dependencies = [ "log", "once_cell", @@ -7600,7 +7610,7 @@ dependencies = [ "openssl-probe", "rustls-pki-types", "schannel", - "security-framework 3.1.0", + "security-framework 3.2.0", ] [[package]] @@ -7675,7 +7685,7 @@ version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee1e066dc922e513bda599c6ccb5f3bb2b0ea5870a579448f2622993f0a9a2f" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "cfg-if", "clipboard-win", "fd-lock", @@ -7764,7 +7774,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -7870,7 +7880,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -7879,11 +7889,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d3f8c9bfcc3cbb6b0179eb57042d75b1582bdc65c3cb95f3fa999509c03cbc" +checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "core-foundation 0.10.0", "core-foundation-sys", "libc", @@ -7892,9 +7902,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -7950,7 +7960,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -7961,14 +7971,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "indexmap 2.7.0", "itoa", @@ -8005,7 +8015,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8051,7 +8061,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8207,6 +8217,12 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "slab" version = "0.4.9" @@ -8335,7 +8351,7 @@ dependencies = [ "const-hex", "derive_builder", "dunce", - "itertools 0.13.0", + "itertools 0.14.0", "itoa", "lasso", "match_cfg", @@ -8346,7 +8362,7 @@ dependencies = [ "solar-config", "solar-data-structures", "solar-macros", - "thiserror 2.0.9", + "thiserror 2.0.11", "tracing", "unicode-width 0.2.0", ] @@ -8359,7 +8375,7 @@ checksum = "970d7c774741f786d62cab78290e47d845b0b9c0c9d094a1642aced1d7946036" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8369,9 +8385,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e1e2d07fae218aca1b4cca81216e5c9ad7822516d48a28f11e2eaa8ffa5b249" dependencies = [ "alloy-primitives", - "bitflags 2.6.0", + "bitflags 2.7.0", "bumpalo", - "itertools 0.13.0", + "itertools 0.14.0", "memchr", "num-bigint", "num-rational", @@ -8421,10 +8437,10 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror 2.0.9", + "thiserror 2.0.11", "tokio", "toml_edit", - "uuid 1.11.0", + "uuid 1.11.1", "zip", "zip-extract", ] @@ -8523,7 +8539,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8560,7 +8576,7 @@ dependencies = [ "serde_json", "sha2", "tempfile", - "thiserror 2.0.9", + "thiserror 2.0.11", "url", "zip", ] @@ -8591,9 +8607,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.94" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -8609,7 +8625,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8629,7 +8645,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8725,11 +8741,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.9", + "thiserror-impl 2.0.11", ] [[package]] @@ -8740,18 +8756,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] name = "thiserror-impl" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8862,9 +8878,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -8880,13 +8896,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -8915,7 +8931,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.20", + "rustls 0.23.21", "tokio", ] @@ -8951,7 +8967,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.20", + "rustls 0.23.21", "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", @@ -9035,7 +9051,7 @@ dependencies = [ "hyper-timeout", "hyper-util", "percent-encoding", - "pin-project 1.1.7", + "pin-project 1.1.8", "prost", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", @@ -9064,7 +9080,7 @@ dependencies = [ "futures-core", "futures-util", "indexmap 1.9.3", - "pin-project 1.1.7", + "pin-project 1.1.8", "pin-project-lite", "rand", "slab", @@ -9097,7 +9113,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "bytes", "futures-util", "http 1.2.0", @@ -9160,7 +9176,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -9277,7 +9293,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.20", + "rustls 0.23.21", "rustls-pki-types", "sha1", "thiserror 1.0.69", @@ -9456,9 +9472,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +checksum = "b913a3b5fe84142e269d63cc62b64319ccaf89b748fc31fe025177f767a756c4" dependencies = [ "getrandom", "serde", @@ -9575,7 +9591,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", "wasm-bindgen-shared", ] @@ -9610,7 +9626,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9851,7 +9867,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -9862,7 +9878,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -9873,7 +9889,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -9884,7 +9900,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -10076,9 +10092,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.22" +version = "0.6.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" dependencies = [ "memchr", ] @@ -10164,7 +10180,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", "synstructure", ] @@ -10186,7 +10202,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -10206,7 +10222,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", "synstructure", ] @@ -10227,7 +10243,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -10249,7 +10265,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.96", ] [[package]] @@ -10266,7 +10282,7 @@ dependencies = [ "flate2", "indexmap 2.7.0", "memchr", - "thiserror 2.0.9", + "thiserror 2.0.11", "zopfli", ] From be34f5b68d8b0b33ec136d8f8a5e8456469db052 Mon Sep 17 00:00:00 2001 From: Delweng Date: Mon, 13 Jan 2025 01:59:56 +0800 Subject: [PATCH 1847/1963] chore(clippy): use next_back instead of last for DoubleEndedIterator (#9666) * chore(clippy): use next_back instead of last for DoubleEndedIterator Signed-off-by: jsvisa * more cases Signed-off-by: jsvisa * last -> next_back Signed-off-by: jsvisa * len ==0 => is_empty Signed-off-by: jsvisa --------- Signed-off-by: jsvisa --- crates/anvil/src/eth/otterscan/api.rs | 2 +- crates/cli/src/opts/dependency.rs | 2 +- crates/config/src/invariant.rs | 2 +- crates/doc/src/builder.rs | 4 ++-- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/verify/src/utils.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/anvil/src/eth/otterscan/api.rs b/crates/anvil/src/eth/otterscan/api.rs index 703c53b53a8db..0392a938c304b 100644 --- a/crates/anvil/src/eth/otterscan/api.rs +++ b/crates/anvil/src/eth/otterscan/api.rs @@ -122,7 +122,7 @@ impl EthApi { pub async fn ots_has_code(&self, address: Address, block_number: BlockNumber) -> Result { node_info!("ots_hasCode"); let block_id = Some(BlockId::Number(block_number)); - Ok(self.get_code(address, block_id).await?.len() > 0) + Ok(!self.get_code(address, block_id).await?.is_empty()) } /// Trace a transaction and generate a trace call tree. diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index 6783e32d25cea..b7fe20abfc40b 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -120,7 +120,7 @@ impl FromStr for Dependency { let url = url.to_string(); let name = url .split('/') - .last() + .next_back() .ok_or_else(|| eyre::eyre!("no dependency name found"))? .to_string(); diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 334cf3b87b995..003b1bac93657 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -75,6 +75,6 @@ impl InvariantConfig { self.failure_persist_dir .unwrap() .join("failures") - .join(contract_name.split(':').last().unwrap()) + .join(contract_name.split(':').next_back().unwrap()) } } diff --git a/crates/doc/src/builder.rs b/crates/doc/src/builder.rs index 02a23ace5b4d5..6c2bec99d19f8 100644 --- a/crates/doc/src/builder.rs +++ b/crates/doc/src/builder.rs @@ -389,7 +389,7 @@ impl DocBuilder { } if let Some(path) = base_path { - let title = path.iter().last().unwrap().to_string_lossy(); + let title = path.iter().next_back().unwrap().to_string_lossy(); if depth == 1 { summary.write_title(&title)?; } else { @@ -444,7 +444,7 @@ impl DocBuilder { readme.write_link_list_item(ident, &readme_path.display().to_string(), 0)?; } } else { - let name = path.iter().last().unwrap().to_string_lossy(); + let name = path.iter().next_back().unwrap().to_string_lossy(); let readme_path = Path::new("/").join(&path).display().to_string(); readme.write_link_list_item(&name, &readme_path, 0)?; self.write_summary_section(summary, &files, Some(&path), depth + 1)?; diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index a1b05a2393fdf..adc2c8dcae133 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -358,7 +358,7 @@ impl TestArgs { let mut fst = folded_stack_trace::build(arena); let label = if self.flamegraph { "flamegraph" } else { "flamechart" }; - let contract = suite_name.split(':').last().unwrap(); + let contract = suite_name.split(':').next_back().unwrap(); let test_name = test_name.trim_end_matches("()"); let file_name = format!("cache/{label}_{contract}_{test_name}.svg"); let file = std::fs::File::create(&file_name).wrap_err("failed to create file")?; diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 6165fa71862ca..2f5a1fb8be99c 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -309,7 +309,7 @@ pub fn check_args_len( args: &Bytes, ) -> Result<(), eyre::ErrReport> { if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) { - if !constructor.inputs.is_empty() && args.len() == 0 { + if !constructor.inputs.is_empty() && args.is_empty() { eyre::bail!( "Contract expects {} constructor argument(s), but none were provided", constructor.inputs.len() From b6c094c5fc1f67f6c3d3a4fd54e63d6baefc34f8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:12:54 +0200 Subject: [PATCH 1848/1963] fix: error handling with retries when waiting for receipt (#9650) * fix: error handling with retries when waiting for receipt * Add RetryError::Continue variant, rework receipts tx check --- crates/common/src/retry.rs | 12 +++++++++ crates/script/src/receipts.rs | 47 ++++++++++++++--------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs index b79e095ceb831..8673c2306e9a8 100644 --- a/crates/common/src/retry.rs +++ b/crates/common/src/retry.rs @@ -6,6 +6,8 @@ use std::{future::Future, time::Duration}; /// Error type for Retry. #[derive(Debug, thiserror::Error)] pub enum RetryError { + /// Continues operation without decrementing retries. + Continue(E), /// Keeps retrying operation. Retry(E), /// Stops retrying operation immediately. @@ -74,6 +76,12 @@ impl Retry { { loop { match callback().await { + Err(RetryError::Continue(e)) => { + self.handle_continue(e); + if !self.delay.is_zero() { + tokio::time::sleep(self.delay).await; + } + } Err(RetryError::Retry(e)) if self.retries > 0 => { self.handle_err(e); if !self.delay.is_zero() { @@ -89,6 +97,10 @@ impl Retry { fn handle_err(&mut self, err: Error) { debug_assert!(self.retries > 0); self.retries -= 1; + self.handle_continue(err); + } + + fn handle_continue(&mut self, err: Error) { let _ = sh_warn!( "{msg}{delay} ({retries} tries remaining)", msg = crate::errors::display_chain(&err), diff --git a/crates/script/src/receipts.rs b/crates/script/src/receipts.rs index ee1c7b46c8c31..605cdf9ddb0de 100644 --- a/crates/script/src/receipts.rs +++ b/crates/script/src/receipts.rs @@ -2,8 +2,8 @@ use alloy_chains::Chain; use alloy_network::AnyTransactionReceipt; use alloy_primitives::{utils::format_units, TxHash, U256}; use alloy_provider::{PendingTransactionBuilder, PendingTransactionError, Provider, WatchTxError}; -use eyre::Result; -use foundry_common::{provider::RetryProvider, shell}; +use eyre::{eyre, Result}; +use foundry_common::{provider::RetryProvider, retry, retry::RetryError, shell}; use std::time::Duration; /// Convenience enum for internal signalling of transaction status @@ -30,39 +30,28 @@ pub async fn check_tx_status( hash: TxHash, timeout: u64, ) -> (TxHash, Result) { - // We use the inner future so that we can use ? operator in the future, but - // still neatly return the tuple - let result = async move { - // First check if there's a receipt - let receipt_opt = provider.get_transaction_receipt(hash).await?; - if let Some(receipt) = receipt_opt { - return Ok(receipt.into()); - } - - loop { + let result = retry::Retry::new_no_delay(3) + .run_async_until_break(|| async { match PendingTransactionBuilder::new(provider.clone(), hash) .with_timeout(Some(Duration::from_secs(timeout))) .get_receipt() .await { - Ok(receipt) => return Ok(receipt.into()), - // do nothing on timeout, we will check whether tx is dropped below - Err(PendingTransactionError::TxWatcher(WatchTxError::Timeout)) => {} - // treat other errors as fatal - Err(e) => return Err(e.into()), - } - - if provider.get_transaction_by_hash(hash).await?.is_some() { - trace!("tx is still known to the node, waiting for receipt"); - } else { - trace!("eth_getTransactionByHash returned null, assuming dropped"); - break + Ok(receipt) => Ok(receipt.into()), + Err(e) => match provider.get_transaction_by_hash(hash).await { + Ok(_) => match e { + PendingTransactionError::TxWatcher(WatchTxError::Timeout) => { + Err(RetryError::Continue(eyre!( + "tx is still known to the node, waiting for receipt" + ))) + } + _ => Err(RetryError::Retry(e.into())), + }, + Err(_) => Ok(TxStatus::Dropped), + }, } - } - - Ok(TxStatus::Dropped) - } - .await; + }) + .await; (hash, result) } From ba505dfabc501e490c5087520976b65a86fad3fa Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:35:24 +0100 Subject: [PATCH 1849/1963] chore: use "full" for debug (#9670) --- .gitignore | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5b61e32022994..9297bbbc7d4f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_STORE -/target +/target* out/ snapshots/ out.json diff --git a/Cargo.toml b/Cargo.toml index 5610368c6d374..646498cc7fb65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ codegen-units = 16 # e.g. `cargo build --profile profiling` [profile.profiling] inherits = "release" -debug = 2 +debug = "full" split-debuginfo = "unpacked" strip = false From c42d08db407bcc039b114ba3ceaf12fd0a400f1f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:54:12 +0100 Subject: [PATCH 1850/1963] chore: don't warn in RetryError::Continue (#9671) --- crates/common/src/retry.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs index 8673c2306e9a8..bfd85554a0f5b 100644 --- a/crates/common/src/retry.rs +++ b/crates/common/src/retry.rs @@ -77,7 +77,7 @@ impl Retry { loop { match callback().await { Err(RetryError::Continue(e)) => { - self.handle_continue(e); + self.log(e, false); if !self.delay.is_zero() { tokio::time::sleep(self.delay).await; } @@ -97,11 +97,11 @@ impl Retry { fn handle_err(&mut self, err: Error) { debug_assert!(self.retries > 0); self.retries -= 1; - self.handle_continue(err); + self.log(err, true); } - fn handle_continue(&mut self, err: Error) { - let _ = sh_warn!( + fn log(&self, err: Error, warn: bool) { + let msg = format!( "{msg}{delay} ({retries} tries remaining)", msg = crate::errors::display_chain(&err), delay = if self.delay.is_zero() { @@ -111,5 +111,10 @@ impl Retry { }, retries = self.retries, ); + if warn { + let _ = sh_warn!("{msg}"); + } else { + tracing::info!("{msg}"); + } } } From aa0161e8c513b2a686439cc1b9a07e20a5701120 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:56:06 +0100 Subject: [PATCH 1851/1963] test: increase nextest backoff (#9672) --- .config/nextest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 56f40c364142e..a90da8b186e19 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,5 +1,5 @@ [profile.default] -retries = { backoff = "exponential", count = 2, delay = "2s", jitter = true } +retries = { backoff = "exponential", count = 2, delay = "3s", jitter = true } slow-timeout = { period = "1m", terminate-after = 3 } [[profile.default.overrides]] From e7a069383cdbbe8eeab66ef0d710615afba3bea0 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:48:38 +0530 Subject: [PATCH 1852/1963] fix(`script`): use fork_block_number for init sender nonce (#9669) * fix(`script`): use fork_block_number for init sender nonce * test --- crates/forge/tests/cli/script.rs | 42 +++++++++++++++++++++++++++++++- crates/script/src/broadcast.rs | 12 ++++++--- crates/script/src/lib.rs | 4 +-- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index bfd7fde8f371d..d263132ca09b2 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -6,7 +6,7 @@ use anvil::{spawn, NodeConfig}; use forge_script_sequence::ScriptSequence; use foundry_config::Config; use foundry_test_utils::{ - rpc, + rpc::{self, next_http_rpc_endpoint}, snapbox::IntoData, util::{OTHER_SOLC_VERSION, SOLC_VERSION}, ScriptOutcome, ScriptTester, @@ -2445,3 +2445,43 @@ contract ContractScript is Script { assert_eq!(sequence.transactions.len(), 2); assert_eq!(sequence.transactions[1].additional_contracts.len(), 1); }); + +// +forgetest_async!(should_set_correct_sender_nonce_via_cli, |prj, cmd| { + foundry_test_utils::util::initialize(prj.root()); + prj.add_script( + "MyScript.s.sol", + r#" + import {Script, console} from "forge-std/Script.sol"; + + contract MyScript is Script { + function run() public view { + console.log("sender nonce", vm.getNonce(msg.sender)); + } + } + "#, + ) + .unwrap(); + + let rpc_url = next_http_rpc_endpoint(); + + let fork_bn = 21614115; + + cmd.forge_fuse() + .args([ + "script", + "MyScript", + "--sender", + "0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97", + "--fork-block-number", + &fork_bn.to_string(), + "--rpc-url", + &rpc_url, + ]) + .assert_success() + .stdout_eq(str![[r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +== Logs == + sender nonce 1124703[..]"#]]); +}); diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 24368bc3d74c6..3e17cd8efa6f8 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -4,7 +4,7 @@ use crate::{ }; use alloy_chains::Chain; use alloy_consensus::TxEnvelope; -use alloy_eips::eip2718::Encodable2718; +use alloy_eips::{eip2718::Encodable2718, BlockId}; use alloy_network::{AnyNetwork, EthereumWallet, TransactionBuilder}; use alloy_primitives::{ map::{AddressHashMap, AddressHashSet}, @@ -49,10 +49,16 @@ where Ok(()) } -pub async fn next_nonce(caller: Address, provider_url: &str) -> eyre::Result { +pub async fn next_nonce( + caller: Address, + provider_url: &str, + block_number: Option, +) -> eyre::Result { let provider = try_get_http_provider(provider_url) .wrap_err_with(|| format!("bad fork_url provider: {provider_url}"))?; - Ok(provider.get_transaction_count(caller).await?) + + let block_id = block_number.map_or(BlockId::latest(), BlockId::number); + Ok(provider.get_transaction_count(caller).block_id(block_id).await?) } pub async fn send_transaction( diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 791a15429a114..574618fd28863 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -550,7 +550,7 @@ pub struct ScriptConfig { impl ScriptConfig { pub async fn new(config: Config, evm_opts: EvmOpts) -> Result { let sender_nonce = if let Some(fork_url) = evm_opts.fork_url.as_ref() { - next_nonce(evm_opts.sender, fork_url).await? + next_nonce(evm_opts.sender, fork_url, evm_opts.fork_block_number).await? } else { // dapptools compatibility 1 @@ -561,7 +561,7 @@ impl ScriptConfig { pub async fn update_sender(&mut self, sender: Address) -> Result<()> { self.sender_nonce = if let Some(fork_url) = self.evm_opts.fork_url.as_ref() { - next_nonce(sender, fork_url).await? + next_nonce(sender, fork_url, None).await? } else { // dapptools compatibility 1 From 92fefaf6a138af5357138ef700f02303a61d581f Mon Sep 17 00:00:00 2001 From: Marquis Shanahan <29431502+9547@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:43:49 +0800 Subject: [PATCH 1853/1963] feat(foundryup): add foundryup self-update (#9609) * feat(foundryup):: add self-update Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> * renmae to --update Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> * download to tmp file first Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --------- Signed-off-by: 9547 <29431502+9547@users.noreply.github.com> --- foundryup/foundryup | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/foundryup/foundryup b/foundryup/foundryup index 710f7cce77788..53861f3513c5e 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -6,6 +6,8 @@ FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} FOUNDRY_VERSIONS_DIR="$FOUNDRY_DIR/versions" FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin" FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1" +FOUNDRY_BIN_URL="https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup" +FOUNDRY_BIN_PATH="$FOUNDRY_BIN_DIR/foundryup" FOUNDRYUP_JOBS="" @@ -30,6 +32,7 @@ main() { -P|--pr) shift; FOUNDRYUP_PR=$1;; -C|--commit) shift; FOUNDRYUP_COMMIT=$1;; -j|--jobs) shift; FOUNDRYUP_JOBS=$1;; + -U|--update) shift; update;; --arch) shift; FOUNDRYUP_ARCH=$1;; --platform) shift; FOUNDRYUP_PLATFORM=$1;; -h|--help) @@ -260,6 +263,7 @@ OPTIONS: -r, --repo Build and install from a remote GitHub repo (uses default branch if no other options are set) -p, --path Build and install a local repository -j, --jobs Number of CPUs to use for building Foundry (default: all CPUs) + -U, --update Update foundryup to the latest version --arch Install a specific architecture (supports amd64 and arm64) --platform Install a specific platform (supports win32, linux, and darwin) EOF @@ -300,6 +304,21 @@ use() { fi } +update() { + say "updating foundryup..." + + # Download to a temporary file first + tmp_file="$(mktemp)" + ensure download "$FOUNDRY_BIN_URL" "$tmp_file" + + # Replace the current foundryup with the downloaded file + ensure mv "$tmp_file" "$FOUNDRY_BIN_PATH" + ensure chmod +x "$FOUNDRY_BIN_PATH" + + say "successfully updated foundryup" + exit 0 +} + say() { printf "foundryup: %s\n" "$1" } From 017c59d6806ce11f1dc131f8607178efad79d84a Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 13 Jan 2025 20:25:43 +0530 Subject: [PATCH 1854/1963] fix(`config`): enable `optimizer` when `optimizer_runs` set in config (#9673) * fix(`config`): enable optimizer if `optimizer_runs` has been set * test * fix(`config`): change optimizer properties to Option * fix * nit Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * fix * nit --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/config/src/lib.rs | 25 +++++++++++------ crates/forge/tests/cli/build.rs | 6 ++--- crates/forge/tests/cli/cmd.rs | 30 ++++++++++----------- crates/forge/tests/cli/config.rs | 33 ++++++++++++++++++----- crates/forge/tests/cli/script.rs | 2 +- crates/forge/tests/cli/test_cmd.rs | 18 ++++++------- crates/forge/tests/cli/verify_bytecode.rs | 30 ++++++++++----------- crates/forge/tests/it/fuzz.rs | 4 +-- crates/forge/tests/it/inline.rs | 2 +- crates/forge/tests/it/invariant.rs | 4 +-- crates/forge/tests/it/test_helpers.rs | 4 +-- crates/script/src/verify.rs | 2 +- crates/verify/src/etherscan/mod.rs | 6 +++-- crates/verify/src/utils.rs | 12 ++++++--- 14 files changed, 107 insertions(+), 71 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index f7392118d8494..c7762fe6a5bfd 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -237,7 +237,7 @@ pub struct Config { /// install it pub offline: bool, /// Whether to activate optimizer - pub optimizer: bool, + pub optimizer: Option, /// The number of runs specifies roughly how often each opcode of the deployed code will be /// executed across the life-time of the contract. This means it is a trade-off parameter /// between code size (deploy cost) and code execution cost (cost after deployment). @@ -248,7 +248,7 @@ pub struct Config { /// A common misconception is that this parameter specifies the number of iterations of the /// optimizer. This is not true: The optimizer will always run as many times as it can /// still improve the code. - pub optimizer_runs: usize, + pub optimizer_runs: Option, /// Switch optimizer components on or off in detail. /// The "enabled" switch above provides two defaults which can be /// tweaked here. If "details" is given, "enabled" can be omitted. @@ -669,6 +669,15 @@ impl Config { add_profile(&Self::DEFAULT_PROFILE); add_profile(&config.profile); + // Ref: https://github.com/foundry-rs/foundry/issues/9665 + // Enables the optimizer if the `optimizer_runs` has been set. + let optimizer = config.optimizer(); + if optimizer.runs.is_some_and(|runs| runs > 0) && optimizer.enabled.is_none() { + config.optimizer = Some(true); + } else if optimizer.runs.is_none() && optimizer.enabled.is_some_and(|enabled| enabled) { + // Default optimizer runs set to 200 if `optimizer = true`. + config.optimizer_runs = Some(200); + }; Ok(config) } @@ -1466,8 +1475,8 @@ impl Config { /// and pub fn optimizer(&self) -> Optimizer { Optimizer { - enabled: Some(self.optimizer), - runs: Some(self.optimizer_runs), + enabled: self.optimizer, + runs: self.optimizer_runs, // we always set the details because `enabled` is effectively a specific details profile // that can still be modified details: self.optimizer_details.clone(), @@ -2298,8 +2307,8 @@ impl Default for Config { vyper: Default::default(), auto_detect_solc: true, offline: false, - optimizer: false, - optimizer_runs: 200, + optimizer: None, + optimizer_runs: None, optimizer_details: None, model_checker: None, extra_output: Default::default(), @@ -4066,8 +4075,8 @@ mod tests { assert_eq!(config.fuzz.runs, 420); assert_eq!(config.invariant.depth, 20); assert_eq!(config.fork_block_number, Some(100)); - assert_eq!(config.optimizer_runs, 999); - assert!(!config.optimizer); + assert_eq!(config.optimizer_runs, Some(999)); + assert!(!config.optimizer.unwrap()); Ok(()) }); diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 15d630f857ba4..7c9355471d150 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -72,7 +72,7 @@ contract Dummy { }); forgetest!(initcode_size_exceeds_limit, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); cmd.args(["build", "--sizes"]).assert_failure().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -104,7 +104,7 @@ Compiler run successful! }); forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); cmd.args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -151,7 +151,7 @@ Compiler run successful! // tests build output is as expected forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { prj.write_config(Config { - optimizer: true, + optimizer: Some(true), solc: Some(foundry_config::SolcReq::Version(semver::Version::new(0, 8, 27))), ..Default::default() }); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 4941a6ea5e614..f0774a36802ab 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -1573,7 +1573,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { // report for all prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: (vec!["*".to_string()]), gas_reports_ignore: (vec![]), ..Default::default() @@ -1683,7 +1683,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { optimizer: true, gas_reports: (vec![]), ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), gas_reports: (vec![]), ..Default::default() }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1789,7 +1789,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: (vec!["*".to_string()]), ..Default::default() }); @@ -1898,7 +1898,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: (vec![ "ContractOne".to_string(), "ContractTwo".to_string(), @@ -2017,7 +2017,7 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { // report for One prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: vec!["ContractOne".to_string()], ..Default::default() }); @@ -2068,7 +2068,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // report for Two prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: vec!["ContractTwo".to_string()], ..Default::default() }); @@ -2119,7 +2119,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // report for Three prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: vec!["ContractThree".to_string()], ..Default::default() }); @@ -2175,7 +2175,7 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { // ignore ContractOne prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: (vec!["*".to_string()]), gas_reports_ignore: (vec!["ContractOne".to_string()]), ..Default::default() @@ -2258,7 +2258,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // ignore ContractTwo cmd.forge_fuse(); prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: (vec![]), gas_reports_ignore: (vec!["ContractTwo".to_string()]), ..Default::default() @@ -2345,7 +2345,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // indicating the "double listing". cmd.forge_fuse(); prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports: (vec![ "ContractOne".to_string(), "ContractTwo".to_string(), @@ -2479,7 +2479,7 @@ Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. }); forgetest!(gas_report_flatten_multiple_selectors, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.insert_ds_test(); prj.add_source( "Counter.sol", @@ -2598,7 +2598,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_with_fallback, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_test( "DelegateProxyTest.sol", r#" @@ -2742,7 +2742,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_test( "NestedDeployTest.sol", r#" @@ -3181,7 +3181,7 @@ Error: No source files found in specified build paths. // checks that build --sizes includes all contracts even if unchanged forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.clear_cache(); cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" @@ -3248,7 +3248,7 @@ interface Counter { // checks that `clean` also works with the "out" value set in Config forgetest_init!(gas_report_include_tests, |prj, cmd| { prj.write_config(Config { - optimizer: true, + optimizer: Some(true), gas_reports_include_tests: true, fuzz: FuzzConfig { runs: 1, ..Default::default() }, ..Default::default() diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index e4c8e25a7ca1b..4035158ba7a10 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -50,8 +50,8 @@ forgetest!(can_extract_config_values, |prj, cmd| { auto_detect_solc: false, auto_detect_remappings: true, offline: true, - optimizer: false, - optimizer_runs: 1000, + optimizer: Some(false), + optimizer_runs: Some(1000), optimizer_details: Some(OptimizerDetails { yul: Some(false), yul_details: Some(YulDetails { stack_allocation: Some(true), ..Default::default() }), @@ -426,7 +426,7 @@ Compiler run successful! // test to ensure yul optimizer can be set as intended forgetest!(can_set_yul_optimizer, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_source( "foo.sol", r" @@ -476,14 +476,35 @@ forgetest_init!(can_parse_dapp_libraries, |_prj, cmd| { // test that optimizer runs works forgetest!(can_set_optimizer_runs, |prj, cmd| { // explicitly set optimizer runs - let config = Config { optimizer_runs: 1337, ..Default::default() }; + let config = Config { optimizer_runs: Some(1337), ..Default::default() }; prj.write_config(config); let config = cmd.config(); - assert_eq!(config.optimizer_runs, 1337); + assert_eq!(config.optimizer_runs, Some(1337)); let config = prj.config_from_output(["--optimizer-runs", "300"]); - assert_eq!(config.optimizer_runs, 300); + assert_eq!(config.optimizer_runs, Some(300)); +}); + +// +forgetest!(enable_optimizer_when_runs_set, |prj, cmd| { + // explicitly set optimizer runs + let config = Config { optimizer_runs: Some(1337), ..Default::default() }; + assert!(config.optimizer.is_none()); + prj.write_config(config); + + let config = cmd.config(); + assert!(config.optimizer.unwrap()); +}); + +// test `optimizer_runs` set to 200 by default if optimizer enabled +forgetest!(optimizer_runs_default, |prj, cmd| { + // explicitly set optimizer runs + let config = Config { optimizer: Some(true), ..Default::default() }; + prj.write_config(config); + + let config = cmd.config(); + assert_eq!(config.optimizer_runs, Some(200)); }); // test that gas_price can be set diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index d263132ca09b2..de155005e1e6f 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1926,7 +1926,7 @@ forgetest_async!(adheres_to_json_flag, |prj, cmd| { } foundry_test_utils::util::initialize(prj.root()); - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_script( "Foo", r#" diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index f19eefeb92b9c..de066297fd936 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -591,7 +591,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/6579 forgetest_init!(include_custom_types_in_traces, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -959,7 +959,7 @@ contract SetupFailureTest is Test { // https://github.com/foundry-rs/foundry/issues/7530 forgetest_init!(should_show_precompile_labels, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1417,7 +1417,7 @@ contract DeterministicRandomnessTest is Test { // Tests that `pauseGasMetering` used at the end of test does not produce meaningless values. // https://github.com/foundry-rs/foundry/issues/5491 forgetest_init!(gas_metering_pause_last_call, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1503,7 +1503,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/4523 forgetest_init!(gas_metering_gasleft, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1582,7 +1582,7 @@ contract ATest is Test { // tests `pauseTracing` and `resumeTracing` functions #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(pause_tracing, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.insert_ds_test(); prj.insert_vm(); @@ -2331,7 +2331,7 @@ Logs: // forgetest_init!(metadata_bytecode_traces, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_source( "ParentProxy.sol", r#" @@ -2454,7 +2454,7 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test().silent()).await; - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.insert_vm(); prj.insert_ds_test(); prj.insert_console(); @@ -2703,7 +2703,7 @@ Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] // Tests that test traces display state changes when running with verbosity. #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(should_show_state_changes, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); cmd.args(["test", "--mt", "test_Increment", "-vvvvv"]).assert_success().stdout_eq(str![[r#" ... @@ -2764,7 +2764,7 @@ Encountered a total of 1 failing tests, 0 tests succeeded // Tests that `start/stopAndReturn` debugTraceRecording does not panic when running with // verbosity > 3. forgetest_init!(should_not_panic_on_debug_trace_verbose, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_test( "DebugTraceRecordingTest.t.sol", r#" diff --git a/crates/forge/tests/cli/verify_bytecode.rs b/crates/forge/tests/cli/verify_bytecode.rs index 6e89f1e940f7c..68d1035601c4b 100644 --- a/crates/forge/tests/cli/verify_bytecode.rs +++ b/crates/forge/tests/cli/verify_bytecode.rs @@ -144,8 +144,8 @@ forgetest_async!(can_verify_bytecode_no_metadata, |prj, cmd| { None, Config { evm_version: EvmVersion::London, - optimizer_runs: 999999, - optimizer: true, + optimizer_runs: Some(999999), + optimizer: Some(true), cbor_metadata: false, bytecode_hash: BytecodeHash::None, ..Default::default() @@ -165,8 +165,8 @@ forgetest_async!(can_verify_bytecode_with_metadata, |prj, cmd| { None, Config { evm_version: EvmVersion::Paris, - optimizer_runs: 50000, - optimizer: true, + optimizer_runs: Some(50000), + optimizer: Some(true), ..Default::default() }, "etherscan", @@ -185,8 +185,8 @@ forgetest_async!(can_verify_bytecode_with_blockscout, |prj, cmd| { None, Config { evm_version: EvmVersion::London, - optimizer: true, - optimizer_runs: 200, + optimizer: Some(true), + optimizer_runs: Some(200), ..Default::default() }, "blockscout", @@ -205,8 +205,8 @@ forgetest_async!(can_vb_create2_with_blockscout, |prj, cmd| { None, Config { evm_version: EvmVersion::London, - optimizer_runs: 999999, - optimizer: true, + optimizer_runs: Some(999999), + optimizer: Some(true), cbor_metadata: false, bytecode_hash: BytecodeHash::None, ..Default::default() @@ -232,8 +232,8 @@ forgetest_async!(can_verify_bytecode_with_constructor_args, |prj, cmd| { Some(constructor_args), Config { evm_version: EvmVersion::London, - optimizer: true, - optimizer_runs: 200, + optimizer: Some(true), + optimizer_runs: Some(200), ..Default::default() }, "etherscan", @@ -251,8 +251,8 @@ forgetest_async!(can_ignore_creation, |prj, cmd| { "SystemConfig", Config { evm_version: EvmVersion::London, - optimizer_runs: 999999, - optimizer: true, + optimizer_runs: Some(999999), + optimizer: Some(true), cbor_metadata: false, bytecode_hash: BytecodeHash::None, ..Default::default() @@ -273,8 +273,8 @@ forgetest_async!(can_ignore_runtime, |prj, cmd| { "SystemConfig", Config { evm_version: EvmVersion::London, - optimizer_runs: 999999, - optimizer: true, + optimizer_runs: Some(999999), + optimizer: Some(true), cbor_metadata: false, bytecode_hash: BytecodeHash::None, ..Default::default() @@ -298,7 +298,7 @@ forgetest_async!(can_ignore_runtime, |prj, cmd| { // "WETH9", // Config { // evm_version: EvmVersion::default(), -// optimizer: true, +// optimizer: Some(true), // optimizer_runs: 10000, // cbor_metadata: true, // bytecode_hash: BytecodeHash::Bzzr1, diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 627232df9bc56..30b34dcd9df1f 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -118,7 +118,7 @@ async fn test_persist_fuzz_failure() { () => { run_fail!(|config| {}) }; (|$config:ident| $e:expr) => {{ let mut runner = TEST_DATA_DEFAULT.runner_with(|$config| { - $config.optimizer = true; + $config.optimizer = Some(true); $config.fuzz.runs = 1000; $e }); @@ -163,7 +163,7 @@ async fn test_persist_fuzz_failure() { } forgetest_init!(test_can_scrape_bytecode, |prj, cmd| { - prj.write_config(Config { optimizer: true, ..Default::default() }); + prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_source( "FuzzerDict.sol", r#" diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 0a1956c456bfc..991c556c7d681 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -8,7 +8,7 @@ use foundry_test_utils::Filter; async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { - config.optimizer = true; + config.optimizer = Some(true); }); let result = runner.test_collect(&filter); let results = result diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index fc58805b48787..df0cba0111486 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -263,7 +263,7 @@ async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { config.fuzz.seed = Some(U256::from(119u32)); - config.optimizer = true; + config.optimizer = Some(true); }); match get_counterexample!(runner, &filter) { @@ -796,7 +796,7 @@ contract AssumeTest is Test { // forgetest_init!(should_revert_with_assume_code, |prj, cmd| { let config = Config { - optimizer: true, + optimizer: Some(true), invariant: { InvariantConfig { fail_on_revert: true, max_assume_rejects: 10, ..Default::default() } }, diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 68fb231f9da9c..3488eca2fedf0 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -89,8 +89,8 @@ impl ForgeTestProfile { config.prompt_timeout = 0; - config.optimizer = true; - config.optimizer_runs = 200; + config.optimizer = Some(true); + config.optimizer_runs = Some(200); config.gas_limit = u64::MAX.into(); config.chain = None; diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index eeeee3d1153af..5c21e4f7ef1e9 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -64,7 +64,7 @@ impl VerifyBundle { verifier: VerifierArgs, ) -> Self { let num_of_optimizations = - if config.optimizer { Some(config.optimizer_runs) } else { None }; + if config.optimizer == Some(true) { config.optimizer_runs } else { None }; let config_path = config.get_config_path(); diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 26832e3b4ab52..7c6da1e1cb33f 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -324,8 +324,10 @@ impl EtherscanVerificationProvider { if code_format == CodeFormat::SingleFile { verify_args = if let Some(optimizations) = args.num_of_optimizations { verify_args.optimized().runs(optimizations as u32) - } else if context.config.optimizer { - verify_args.optimized().runs(context.config.optimizer_runs.try_into()?) + } else if context.config.optimizer == Some(true) { + verify_args + .optimized() + .runs(context.config.optimizer_runs.unwrap_or(200).try_into()?) } else { verify_args.not_optimized() }; diff --git a/crates/verify/src/utils.rs b/crates/verify/src/utils.rs index 2f5a1fb8be99c..132f0218f8d79 100644 --- a/crates/verify/src/utils.rs +++ b/crates/verify/src/utils.rs @@ -237,18 +237,22 @@ fn find_mismatch_in_settings( ); mismatches.push(str); } - let local_optimizer: u64 = if local_settings.optimizer { 1 } else { 0 }; + let local_optimizer: u64 = if local_settings.optimizer == Some(true) { 1 } else { 0 }; if etherscan_settings.optimization_used != local_optimizer { let str = format!( "Optimizer mismatch: local={}, onchain={}", - local_settings.optimizer, etherscan_settings.optimization_used + local_settings.optimizer.unwrap_or(false), + etherscan_settings.optimization_used ); mismatches.push(str); } - if etherscan_settings.runs != local_settings.optimizer_runs as u64 { + if local_settings.optimizer_runs.is_some_and(|runs| etherscan_settings.runs != runs as u64) || + (local_settings.optimizer_runs.is_none() && etherscan_settings.runs > 0) + { let str = format!( "Optimizer runs mismatch: local={}, onchain={}", - local_settings.optimizer_runs, etherscan_settings.runs + local_settings.optimizer_runs.unwrap(), + etherscan_settings.runs ); mismatches.push(str); } From 5b4a105a09b32a6d269ababa7056ef68275c8f5d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 14 Jan 2025 08:30:26 +0100 Subject: [PATCH 1855/1963] fix: propagate color config to TraceWriter (#9679) --- Cargo.lock | 38 +++++++++ crates/common/src/io/shell.rs | 5 ++ crates/evm/traces/src/lib.rs | 10 +++ crates/forge/tests/cli/test_cmd.rs | 7 ++ .../forge/tests/fixtures/colored_traces.svg | 82 +++++++++++++++++++ crates/test-utils/Cargo.toml | 2 +- 6 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 crates/forge/tests/fixtures/colored_traces.svg diff --git a/Cargo.lock b/Cargo.lock index e1586fdb0ad0b..6191cc9cfd7dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -894,6 +894,15 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +[[package]] +name = "anstyle-lossy" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934ff8719effd2023a48cf63e69536c1c3ced9d3895068f6f5cc9a4ff845e59b" +dependencies = [ + "anstyle", +] + [[package]] name = "anstyle-parse" version = "0.2.6" @@ -912,6 +921,19 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "anstyle-svg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3607949e9f6de49ea4bafe12f5e4fd73613ebf24795e48587302a8cc0e4bb35" +dependencies = [ + "anstream", + "anstyle", + "anstyle-lossy", + "html-escape", + "unicode-width 0.2.0", +] + [[package]] name = "anstyle-wincon" version = "3.0.6" @@ -4749,6 +4771,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "html-escape" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" +dependencies = [ + "utf8-width", +] + [[package]] name = "html5ever" version = "0.27.0" @@ -8255,6 +8286,7 @@ checksum = "96dcfc4581e3355d70ac2ee14cfdf81dce3d85c85f1ed9e2c1d3013f53b3436b" dependencies = [ "anstream", "anstyle", + "anstyle-svg", "normalize-line-endings", "regex", "serde", @@ -9448,6 +9480,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + [[package]] name = "utf8_iter" version = "1.0.4" diff --git a/crates/common/src/io/shell.rs b/crates/common/src/io/shell.rs index fd667ea682eb9..19b3ae07e7900 100644 --- a/crates/common/src/io/shell.rs +++ b/crates/common/src/io/shell.rs @@ -18,6 +18,11 @@ use std::{ }, }; +/// Returns the current color choice. +pub fn color_choice() -> ColorChoice { + Shell::get().color_choice() +} + /// Returns the currently set verbosity level. pub fn verbosity() -> Verbosity { Shell::get().verbosity() diff --git a/crates/evm/traces/src/lib.rs b/crates/evm/traces/src/lib.rs index f88efbb1b1953..0d22352ca9e3b 100644 --- a/crates/evm/traces/src/lib.rs +++ b/crates/evm/traces/src/lib.rs @@ -201,12 +201,22 @@ pub fn render_trace_arena_inner( } let mut w = TraceWriter::new(Vec::::new()) + .color_cheatcodes(true) + .use_colors(convert_color_choice(shell::color_choice())) .write_bytecodes(with_bytecodes) .with_storage_changes(with_storage_changes); w.write_arena(&arena.resolve_arena()).expect("Failed to write traces"); String::from_utf8(w.into_writer()).expect("trace writer wrote invalid UTF-8") } +fn convert_color_choice(choice: shell::ColorChoice) -> revm_inspectors::ColorChoice { + match choice { + shell::ColorChoice::Auto => revm_inspectors::ColorChoice::Auto, + shell::ColorChoice::Always => revm_inspectors::ColorChoice::Always, + shell::ColorChoice::Never => revm_inspectors::ColorChoice::Never, + } +} + /// Specifies the kind of trace. #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TraceKind { diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index de066297fd936..283be9a70d53b 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2829,3 +2829,10 @@ forgetest!(test_fail_deprecation_warning, |prj, cmd| { .stderr_eq(r#"Warning: `testFail*` has been deprecated and will be removed in the next release. Consider changing to test_Revert[If|When]_Condition and expecting a revert. Found deprecated testFail* function(s): testFail_deprecated, testFail_deprecated2. "#); }); + +#[cfg(not(feature = "isolate-by-default"))] +forgetest_init!(colored_traces, |prj, cmd| { + cmd.args(["test", "--mt", "test_Increment", "--color", "always", "-vvvvv"]) + .assert_success() + .stdout_eq(file!["../fixtures/colored_traces.svg": TermSvg]); +}); diff --git a/crates/forge/tests/fixtures/colored_traces.svg b/crates/forge/tests/fixtures/colored_traces.svg new file mode 100644 index 0000000000000..96726b528e936 --- /dev/null +++ b/crates/forge/tests/fixtures/colored_traces.svg @@ -0,0 +1,82 @@ + + + + + + + No files changed, compilation skipped + + + + Ran 1 test for test/Counter.t.sol:CounterTest + + [PASS] test_Increment() ([GAS]) + + Traces: + + [137242] CounterTest::setUp() + + ├─ [96345] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + + │ └─ ← [Return] 481 bytes of code + + ├─ [2592] Counter::setNumber(0) + + │ └─ ← [Stop] + + └─ ← [Stop] + + + + [31851] CounterTest::test_Increment() + + ├─ [22418] Counter::increment() + + │ ├─ storage changes: + + │ │ @ 0: 0 → 1 + + │ └─ ← [Stop] + + ├─ [424] Counter::number() [staticcall] + + │ └─ ← [Return] 1 + + ├─ [0] VM::assertEq(1, 1) [staticcall] + + │ └─ ← [Return] + + ├─ storage changes: + + │ @ 0: 0 → 1 + + └─ ← [Stop] + + + + Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + + + + Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + + + + + + diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index efe6d288ff9e0..3e6efdc1fda1c 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -30,7 +30,7 @@ serde_json.workspace = true tracing.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } rand.workspace = true -snapbox = { version = "0.6", features = ["json", "regex"] } +snapbox = { version = "0.6", features = ["json", "regex", "term-svg"] } tempfile.workspace = true [dev-dependencies] From ff2c5647d64ba154a6d06461ebf82a4f293e9437 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:41:01 +0200 Subject: [PATCH 1856/1963] feat(foundryup): check for running processes (#9680) --- foundryup/foundryup | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/foundryup/foundryup b/foundryup/foundryup index 53861f3513c5e..714ad9aa29734 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -63,6 +63,8 @@ main() { fi fi + check_bins_in_use + # Installs foundry from a local repository if --path parameter is provided if [[ -n "$FOUNDRYUP_LOCAL_REPO" ]]; then need_cmd cargo @@ -292,6 +294,9 @@ use() { [ -z "$FOUNDRYUP_VERSION" ] && err "no version provided" FOUNDRY_VERSION_DIR="$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_VERSION" if [ -d "$FOUNDRY_VERSION_DIR" ]; then + + check_bins_in_use + for bin in "${BINS[@]}"; do bin_path="$FOUNDRY_BIN_DIR/$bin" cp $FOUNDRY_VERSION_DIR/$bin $bin_path @@ -346,6 +351,18 @@ check_cmd() { command -v "$1" &>/dev/null } +check_bins_in_use() { + if check_cmd pgrep; then + for bin in "${BINS[@]}"; do + if pgrep -x "$bin" >/dev/null; then + err "Error: '$bin' is currently running. Please stop the process and try again." + fi + done + else + warn "Make sure no foundry process is running during the install process!" + fi +} + # Run a command that should never fail. If the command fails execution # will immediately terminate with an error showing the failing command. ensure() { From 41c6653e2adee0354ba6cdf7233c58294bcea3bf Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 14 Jan 2025 13:31:45 +0100 Subject: [PATCH 1857/1963] chore: add version number to `foundryup` (#9681) * add version number, display using --version * use say instead of echo * add input box for foundryup version to bug template --- .github/ISSUE_TEMPLATE/BUG-FORM.yml | 6 +++- foundryup/foundryup | 48 ++++++++++++++++++----------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG-FORM.yml b/.github/ISSUE_TEMPLATE/BUG-FORM.yml index b2575134d782d..5a5f7e7808994 100644 --- a/.github/ISSUE_TEMPLATE/BUG-FORM.yml +++ b/.github/ISSUE_TEMPLATE/BUG-FORM.yml @@ -32,6 +32,10 @@ body: attributes: label: What version of Foundry are you on? placeholder: "Run forge --version and paste the output here" + - type: input + attributes: + label: What version of Foundryup are you on? + placeholder: "Run foundryup --version and paste the output here" - type: input attributes: label: What command(s) is the bug in? @@ -51,4 +55,4 @@ body: label: Describe the bug description: Please include relevant Solidity snippets as well if relevant. validations: - required: true + required: true \ No newline at end of file diff --git a/foundryup/foundryup b/foundryup/foundryup index 714ad9aa29734..998abfeb1ae07 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -eo pipefail +# NOTE: if you make modifications to this script, please increment the version number. +# Major / minor: incremented for each stable release of Foundry. +# Patch: incremented for each change between stable releases. +FOUNDRYUP_INSTALLER_VERSION="0.3.0" + BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} FOUNDRY_VERSIONS_DIR="$FOUNDRY_DIR/versions" @@ -23,6 +28,8 @@ main() { case $1 in --) shift; break;; + -v|--version) shift; version;; + -U|--update) shift; update;; -r|--repo) shift; FOUNDRYUP_REPO=$1;; -b|--branch) shift; FOUNDRYUP_BRANCH=$1;; -i|--install) shift; FOUNDRYUP_VERSION=$1;; @@ -32,7 +39,6 @@ main() { -P|--pr) shift; FOUNDRYUP_PR=$1;; -C|--commit) shift; FOUNDRYUP_COMMIT=$1;; -j|--jobs) shift; FOUNDRYUP_JOBS=$1;; - -U|--update) shift; update;; --arch) shift; FOUNDRYUP_ARCH=$1;; --platform) shift; FOUNDRYUP_PLATFORM=$1;; -h|--help) @@ -71,7 +77,7 @@ main() { # Ignore branches/versions as we do not want to modify local git state if [ -n "$FOUNDRYUP_REPO" ] || [ -n "$FOUNDRYUP_BRANCH" ] || [ -n "$FOUNDRYUP_VERSION" ]; then - warn "--branch, --version, and --repo arguments are ignored during local install" + warn "--branch, --install, --use, and --repo arguments are ignored during local install" fi # Enter local repo and build @@ -256,6 +262,8 @@ USAGE: OPTIONS: -h, --help Print help information + -v, --version Print the version of foundryup + -U, --update Update foundryup to the latest version -i, --install Install a specific version from built binaries -l, --list List versions installed from built binaries -u, --use Use a specific installed version from built binaries @@ -265,12 +273,31 @@ OPTIONS: -r, --repo Build and install from a remote GitHub repo (uses default branch if no other options are set) -p, --path Build and install a local repository -j, --jobs Number of CPUs to use for building Foundry (default: all CPUs) - -U, --update Update foundryup to the latest version --arch Install a specific architecture (supports amd64 and arm64) --platform Install a specific platform (supports win32, linux, and darwin) EOF } +version() { + say "$FOUNDRYUP_INSTALLER_VERSION" + exit 0 +} + +update() { + say "updating foundryup..." + + # Download to a temporary file first + tmp_file="$(mktemp)" + ensure download "$FOUNDRY_BIN_URL" "$tmp_file" + + # Replace the current foundryup with the downloaded file + ensure mv "$tmp_file" "$FOUNDRY_BIN_PATH" + ensure chmod +x "$FOUNDRY_BIN_PATH" + + say "successfully updated foundryup" + exit 0 +} + list() { if [ -d "$FOUNDRY_VERSIONS_DIR" ]; then for VERSION in $FOUNDRY_VERSIONS_DIR/*; do @@ -309,21 +336,6 @@ use() { fi } -update() { - say "updating foundryup..." - - # Download to a temporary file first - tmp_file="$(mktemp)" - ensure download "$FOUNDRY_BIN_URL" "$tmp_file" - - # Replace the current foundryup with the downloaded file - ensure mv "$tmp_file" "$FOUNDRY_BIN_PATH" - ensure chmod +x "$FOUNDRY_BIN_PATH" - - say "successfully updated foundryup" - exit 0 -} - say() { printf "foundryup: %s\n" "$1" } From 98290544ff90fc420c4fbdc8d03ba4338e284aef Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:26:34 +0200 Subject: [PATCH 1858/1963] fix(config): normalize optimizer settings (#9689) --- crates/config/src/lib.rs | 57 +++-- crates/forge/bin/cmd/config.rs | 1 + crates/forge/tests/cli/config.rs | 400 +++++++++++++++++++++++++++++++ 3 files changed, 442 insertions(+), 16 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index c7762fe6a5bfd..e96ca60bd4366 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -669,15 +669,8 @@ impl Config { add_profile(&Self::DEFAULT_PROFILE); add_profile(&config.profile); - // Ref: https://github.com/foundry-rs/foundry/issues/9665 - // Enables the optimizer if the `optimizer_runs` has been set. - let optimizer = config.optimizer(); - if optimizer.runs.is_some_and(|runs| runs > 0) && optimizer.enabled.is_none() { - config.optimizer = Some(true); - } else if optimizer.runs.is_none() && optimizer.enabled.is_some_and(|enabled| enabled) { - // Default optimizer runs set to 200 if `optimizer = true`. - config.optimizer_runs = Some(200); - }; + config.normalize_optimizer_settings(); + Ok(config) } @@ -843,11 +836,37 @@ impl Config { self } + /// Normalizes optimizer settings. + /// See + pub fn normalized_optimizer_settings(mut self) -> Self { + self.normalize_optimizer_settings(); + self + } + /// Normalizes the evm version if a [SolcReq] is set to a valid version. pub fn normalize_evm_version(&mut self) { self.evm_version = self.get_normalized_evm_version(); } + /// Normalizes optimizer settings: + /// - with default settings, optimizer is set to false and optimizer runs to 200 + /// - if optimizer is set and optimizer runs not specified, then optimizer runs is set to 200 + /// - enable optimizer if not explicitly set and optimizer runs set to a value greater than 0 + pub fn normalize_optimizer_settings(&mut self) { + match (self.optimizer, self.optimizer_runs) { + // Default: set the optimizer to false and optimizer runs to 200. + (None, None) => { + self.optimizer = Some(false); + self.optimizer_runs = Some(200); + } + // Set the optimizer runs to 200 if the `optimizer` config set. + (Some(_), None) => self.optimizer_runs = Some(200), + // Enables optimizer if the `optimizer_runs` has been set with a value greater than 0. + (None, Some(runs)) => self.optimizer = Some(runs > 0), + _ => {} + } + } + /// Returns the normalized [EvmVersion] if a [SolcReq] is set to a valid version or if the solc /// path is a valid solc binary. /// @@ -2670,7 +2689,7 @@ mod tests { let roundtrip = Figment::from(Config::from_provider(&original)); for figment in &[original, roundtrip] { let config = Config::from_provider(figment); - assert_eq!(config, Config::default()); + assert_eq!(config, Config::default().normalized_optimizer_settings()); } Ok(()) }); @@ -2942,7 +2961,13 @@ mod tests { )?; let config = Config::load(); - assert_eq!(config, Config { gas_limit: gas.into(), ..Config::default() }); + assert_eq!( + config, + Config { + gas_limit: gas.into(), + ..Config::default().normalized_optimizer_settings() + } + ); Ok(()) }); @@ -3590,7 +3615,7 @@ mod tests { ]), build_info_path: Some("build-info".into()), always_use_create_2_factory: true, - ..Config::default() + ..Config::default().normalized_optimizer_settings() } ); @@ -3825,7 +3850,7 @@ mod tests { eth_rpc_url: Some("https://example.com/".to_string()), auto_detect_solc: false, evm_version: EvmVersion::Berlin, - ..Config::default() + ..Config::default().normalized_optimizer_settings() } ); @@ -3877,7 +3902,7 @@ mod tests { src: "mysrc".into(), out: "myout".into(), verbosity: 3, - ..Config::default() + ..Config::default().normalized_optimizer_settings() } ); @@ -3889,7 +3914,7 @@ mod tests { src: "other-src".into(), out: "myout".into(), verbosity: 3, - ..Config::default() + ..Config::default().normalized_optimizer_settings() } ); @@ -4192,7 +4217,7 @@ mod tests { #[test] fn config_roundtrip() { figment::Jail::expect_with(|jail| { - let default = Config::default(); + let default = Config::default().normalized_optimizer_settings(); let basic = default.clone().into_basic(); jail.create_file("foundry.toml", &basic.to_string_pretty().unwrap())?; diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index 42ab29ec26555..d1de49d5255b9 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -37,6 +37,7 @@ impl ConfigArgs { let config = self .try_load_config_unsanitized_emit_warnings()? + .normalized_optimizer_settings() // we explicitly normalize the version, so mimic the behavior when invoking solc .normalized_evm_version(); diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 4035158ba7a10..882e92681e1b3 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -910,3 +910,403 @@ contract CounterTest { .unwrap(); cmd.forge_fuse().args(["build"]).assert_success(); }); + +forgetest_init!(test_default_config, |prj, cmd| { + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +[profile.default] +src = "src" +test = "test" +script = "script" +out = "out" +libs = ["lib"] +remappings = ["forge-std/=lib/forge-std/src/"] +auto_detect_remappings = true +libraries = [] +cache = true +cache_path = "cache" +snapshots = "snapshots" +broadcast = "broadcast" +allow_paths = [] +include_paths = [] +skip = [] +force = false +evm_version = "cancun" +gas_reports = ["*"] +gas_reports_ignore = [] +gas_reports_include_tests = false +auto_detect_solc = true +offline = false +optimizer = false +optimizer_runs = 200 +verbosity = 0 +ignored_error_codes = [ + "license", + "code-size", + "init-code-size", + "transient-storage", +] +ignored_warnings_from = [] +deny_warnings = false +test_failures_file = "cache/test-failures" +show_progress = false +eof = false +transaction_timeout = 120 +ffi = false +always_use_create_2_factory = false +prompt_timeout = 120 +sender = "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38" +tx_origin = "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38" +initial_balance = "0xffffffffffffffffffffffff" +block_number = 1 +gas_limit = 1073741824 +block_base_fee_per_gas = 0 +block_coinbase = "0x0000000000000000000000000000000000000000" +block_timestamp = 1 +block_difficulty = 0 +block_prevrandao = "0x0000000000000000000000000000000000000000000000000000000000000000" +memory_limit = 134217728 +extra_output = [] +extra_output_files = [] +names = false +sizes = false +via_ir = false +ast = false +no_storage_caching = false +no_rpc_rate_limit = false +use_literal_content = false +bytecode_hash = "ipfs" +cbor_metadata = true +sparse_mode = false +build_info = false +compilation_restrictions = [] +additional_compiler_profiles = [] +assertions_revert = true +isolate = false +disable_block_gas_limit = false +odyssey = false +unchecked_cheatcode_artifacts = false +create2_library_salt = "0x0000000000000000000000000000000000000000000000000000000000000000" +create2_deployer = "0x4e59b44847b379578588920ca78fbf26c0b4956c" +legacy_assertions = false + +[[profile.default.fs_permissions]] +access = "read" +path = "out" + +[profile.default.rpc_storage_caching] +chains = "all" +endpoints = "all" + +[fmt] +line_length = 120 +tab_width = 4 +bracket_spacing = false +int_types = "long" +multiline_func_header = "attributes_first" +quote_style = "double" +number_underscore = "preserve" +hex_underscore = "remove" +single_line_statement_blocks = "preserve" +override_spacing = false +wrap_comments = false +ignore = [] +contract_new_lines = false +sort_imports = false + +[doc] +out = "docs" +title = "" +book = "book.toml" +homepage = "README.md" +ignore = [] + +[fuzz] +runs = 256 +max_test_rejects = 65536 +dictionary_weight = 40 +include_storage = true +include_push_bytes = true +max_fuzz_dictionary_addresses = 15728640 +max_fuzz_dictionary_values = 6553600 +gas_report_samples = 256 +failure_persist_dir = "cache/fuzz" +failure_persist_file = "failures" +show_logs = false + +[invariant] +runs = 256 +depth = 500 +fail_on_revert = false +call_override = false +dictionary_weight = 80 +include_storage = true +include_push_bytes = true +max_fuzz_dictionary_addresses = 15728640 +max_fuzz_dictionary_values = 6553600 +shrink_run_limit = 5000 +max_assume_rejects = 65536 +gas_report_samples = 256 +failure_persist_dir = "cache/invariant" +show_metrics = false + +[labels] + +[vyper] + +[bind_json] +out = "utils/JsonBindings.sol" +include = [] +exclude = [] + + +"#]]); + + cmd.forge_fuse().args(["config", "--json"]).assert_success().stdout_eq(str![[r#" +{ + "src": "src", + "test": "test", + "script": "script", + "out": "out", + "libs": [ + "lib" + ], + "remappings": [ + "forge-std/=lib/forge-std/src/" + ], + "auto_detect_remappings": true, + "libraries": [], + "cache": true, + "cache_path": "cache", + "snapshots": "snapshots", + "broadcast": "broadcast", + "allow_paths": [], + "include_paths": [], + "skip": [], + "force": false, + "evm_version": "cancun", + "gas_reports": [ + "*" + ], + "gas_reports_ignore": [], + "gas_reports_include_tests": false, + "solc": null, + "auto_detect_solc": true, + "offline": false, + "optimizer": false, + "optimizer_runs": 200, + "optimizer_details": null, + "model_checker": null, + "verbosity": 0, + "eth_rpc_url": null, + "eth_rpc_jwt": null, + "eth_rpc_timeout": null, + "eth_rpc_headers": null, + "etherscan_api_key": null, + "ignored_error_codes": [ + "license", + "code-size", + "init-code-size", + "transient-storage" + ], + "ignored_warnings_from": [], + "deny_warnings": false, + "match_test": null, + "no_match_test": null, + "match_contract": null, + "no_match_contract": null, + "match_path": null, + "no_match_path": null, + "no_match_coverage": null, + "test_failures_file": "cache/test-failures", + "threads": null, + "show_progress": false, + "fuzz": { + "runs": 256, + "max_test_rejects": 65536, + "seed": null, + "dictionary_weight": 40, + "include_storage": true, + "include_push_bytes": true, + "max_fuzz_dictionary_addresses": 15728640, + "max_fuzz_dictionary_values": 6553600, + "gas_report_samples": 256, + "failure_persist_dir": "cache/fuzz", + "failure_persist_file": "failures", + "show_logs": false, + "timeout": null + }, + "invariant": { + "runs": 256, + "depth": 500, + "fail_on_revert": false, + "call_override": false, + "dictionary_weight": 80, + "include_storage": true, + "include_push_bytes": true, + "max_fuzz_dictionary_addresses": 15728640, + "max_fuzz_dictionary_values": 6553600, + "shrink_run_limit": 5000, + "max_assume_rejects": 65536, + "gas_report_samples": 256, + "failure_persist_dir": "cache/invariant", + "show_metrics": false, + "timeout": null + }, + "ffi": false, + "always_use_create_2_factory": false, + "prompt_timeout": 120, + "sender": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", + "tx_origin": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", + "initial_balance": "0xffffffffffffffffffffffff", + "block_number": 1, + "fork_block_number": null, + "chain_id": null, + "gas_limit": 1073741824, + "code_size_limit": null, + "gas_price": null, + "block_base_fee_per_gas": 0, + "block_coinbase": "0x0000000000000000000000000000000000000000", + "block_timestamp": 1, + "block_difficulty": 0, + "block_prevrandao": "0x0000000000000000000000000000000000000000000000000000000000000000", + "block_gas_limit": null, + "memory_limit": 134217728, + "extra_output": [], + "extra_output_files": [], + "names": false, + "sizes": false, + "via_ir": false, + "ast": false, + "rpc_storage_caching": { + "chains": "all", + "endpoints": "all" + }, + "no_storage_caching": false, + "no_rpc_rate_limit": false, + "use_literal_content": false, + "bytecode_hash": "ipfs", + "cbor_metadata": true, + "revert_strings": null, + "sparse_mode": false, + "build_info": false, + "build_info_path": null, + "fmt": { + "line_length": 120, + "tab_width": 4, + "bracket_spacing": false, + "int_types": "long", + "multiline_func_header": "attributes_first", + "quote_style": "double", + "number_underscore": "preserve", + "hex_underscore": "remove", + "single_line_statement_blocks": "preserve", + "override_spacing": false, + "wrap_comments": false, + "ignore": [], + "contract_new_lines": false, + "sort_imports": false + }, + "doc": { + "out": "docs", + "title": "", + "book": "book.toml", + "homepage": "README.md", + "ignore": [] + }, + "bind_json": { + "out": "utils/JsonBindings.sol", + "include": [], + "exclude": [] + }, + "fs_permissions": [ + { + "access": "read", + "path": "out" + } + ], + "isolate": false, + "disable_block_gas_limit": false, + "labels": {}, + "unchecked_cheatcode_artifacts": false, + "create2_library_salt": "0x0000000000000000000000000000000000000000000000000000000000000000", + "create2_deployer": "0x4e59b44847b379578588920ca78fbf26c0b4956c", + "vyper": {}, + "dependencies": null, + "soldeer": null, + "assertions_revert": true, + "legacy_assertions": false, + "odyssey": false, + "transaction_timeout": 120, + "eof": false, + "additional_compiler_profiles": [], + "compilation_restrictions": [] +} + +"#]]); +}); + +forgetest_init!(test_optimizer_config, |prj, cmd| { + // Default settings: optimizer disabled, optimizer runs 200. + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +optimizer = false +optimizer_runs = 200 +... + +"#]]); + + // Optimizer set to true: optimizer runs set to default value of 200. + let config = Config { optimizer: Some(true), ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +optimizer = true +optimizer_runs = 200 +... + +"#]]); + + // Optimizer runs set to 0: optimizer should be disabled, runs set to 0. + let config = Config { optimizer_runs: Some(0), ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +optimizer = false +optimizer_runs = 0 +... + +"#]]); + + // Optimizer runs set to 500: optimizer should be enabled, runs set to 500. + let config = Config { optimizer_runs: Some(500), ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +optimizer = true +optimizer_runs = 500 +... + +"#]]); + + // Optimizer disabled and runs set to 500: optimizer should be disabled, runs set to 500. + let config = Config { optimizer: Some(false), optimizer_runs: Some(500), ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +optimizer = false +optimizer_runs = 500 +... + +"#]]); + + // Optimizer enabled and runs set to 0: optimizer should be enabled, runs set to 0. + let config = Config { optimizer: Some(true), optimizer_runs: Some(0), ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +optimizer = true +optimizer_runs = 0 +... + +"#]]); +}); From 55badd449588167cb96eb831ff32e80a17215a60 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:59:47 +0100 Subject: [PATCH 1859/1963] ci: use reusable cargo update workflow (#9690) --- .github/workflows/dependencies.yml | 53 ++++-------------------------- 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index ad87a4858767f..d22bbffcab714 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -9,53 +9,12 @@ on: workflow_dispatch: # Needed so we can run it manually -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: cargo-update - TITLE: "chore(deps): weekly `cargo update`" - BODY: | - Automation to keep dependencies in `Cargo.lock` current. - -
cargo update log -

- - ```log - $cargo_update_log - ``` - -

-
+permissions: + contents: write + pull-requests: write jobs: update: - name: Update - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - - - name: cargo update - # Remove first line that always just says "Updating crates.io index" - run: cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log - - - name: craft commit message and PR body - id: msg - run: | - export cargo_update_log="$(cat cargo_update.log)" - - echo "commit_message<> $GITHUB_OUTPUT - printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - echo "body<> $GITHUB_OUTPUT - echo "$BODY" | envsubst >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 - with: - add-paths: ./Cargo.lock - commit-message: ${{ steps.msg.outputs.commit_message }} - title: ${{ env.TITLE }} - body: ${{ steps.msg.outputs.body }} - branch: ${{ env.BRANCH }} + uses: ithacaxyz/ci/.github/workflows/cargo-update-pr.yml@main + secrets: + token: ${{ secrets.GITHUB_TOKEN }} From 73becfb5990d05446e9da0327e4073e486536873 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:33:57 +0100 Subject: [PATCH 1860/1963] chore(deps): bump svm 0.5.10 (#9700) --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6191cc9cfd7dc..8113d8882ec73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8595,9 +8595,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e9bc6b09b8a7a919128f8c029ae4048d83f814af557e948115273c75864acf" +checksum = "2079b44b2dc358e0aa611988e806f92a0d1f174206566de745a4a422a8009c65" dependencies = [ "const-hex", "dirs 5.0.1", @@ -8615,9 +8615,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d0964cd9dfcbf8bd21057c1a4aa293fefab208306461989ce723dd9c51e71e" +checksum = "9379e64a7d61f2a288e97c4b7d80a5cdcc893f24a83b6ec0ec18ffd36d58c6e2" dependencies = [ "build_const", "const-hex", From 00c944ba7608d481361353c11754839e320804e1 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 17 Jan 2025 14:55:25 +0200 Subject: [PATCH 1861/1963] fix(verify): strip profile from contract name (#9699) --- crates/script/src/verify.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/script/src/verify.rs b/crates/script/src/verify.rs index 5c21e4f7ef1e9..c2f9955434813 100644 --- a/crates/script/src/verify.rs +++ b/crates/script/src/verify.rs @@ -120,9 +120,14 @@ impl VerifyBundle { warn!("Skipping verification of Vyper contract: {}", artifact.name); } + // Strip artifact profile from contract name when creating contract info. let contract = ContractInfo { path: Some(artifact.source.to_string_lossy().to_string()), - name: artifact.name.clone(), + name: artifact + .name + .strip_suffix(&format!(".{}", &artifact.profile)) + .unwrap_or_else(|| &artifact.name) + .to_string(), }; // We strip the build metadadata information, since it can lead to From 1f48a34c97664a82dbbf821d492eb36c1f48028a Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Sat, 18 Jan 2025 01:06:14 +0530 Subject: [PATCH 1862/1963] feat(`forge`): `--watch` coverage (#9702) --- crates/forge/bin/cmd/coverage.rs | 10 +++++++++- crates/forge/bin/cmd/watch.rs | 16 ++++++++++++++-- crates/forge/bin/main.rs | 8 +++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 48bc8349c633d..909e8a16bd438 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -1,4 +1,4 @@ -use super::{install, test::TestArgs}; +use super::{install, test::TestArgs, watch::WatchArgs}; use alloy_primitives::{map::HashMap, Address, Bytes, U256}; use clap::{Parser, ValueEnum, ValueHint}; use eyre::{Context, Result}; @@ -319,6 +319,14 @@ impl CoverageArgs { } Ok(()) } + + pub(crate) fn is_watch(&self) -> bool { + self.test.is_watch() + } + + pub(crate) fn watch(&self) -> &WatchArgs { + &self.test.watch + } } /// Coverage reports to generate. diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 37ae267ede913..04aa7c722fd0b 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -1,8 +1,11 @@ -use super::{build::BuildArgs, doc::DocArgs, snapshot::GasSnapshotArgs, test::TestArgs}; +use super::{ + build::BuildArgs, coverage::CoverageArgs, doc::DocArgs, snapshot::GasSnapshotArgs, + test::TestArgs, +}; use alloy_primitives::map::HashSet; use clap::Parser; use eyre::Result; -use foundry_cli::utils::{self, FoundryPathExt}; +use foundry_cli::utils::{self, FoundryPathExt, LoadConfig}; use foundry_config::Config; use parking_lot::Mutex; use std::{ @@ -316,6 +319,15 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { Ok(()) } +pub async fn watch_coverage(args: CoverageArgs) -> Result<()> { + let config = args.load_config(); + let config = args.watch().watchexec_config(|| [config.test, config.src])?; + + run(config).await?; + + Ok(()) +} + /// Executes a [`Watchexec`] that listens for changes in the project's sources directory pub async fn watch_doc(args: DocArgs) -> Result<()> { let src_path = args.config()?.src; diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 60a55af7a82d6..87a108c836b76 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -49,7 +49,13 @@ fn run() -> Result<()> { } } ForgeSubcommand::Script(cmd) => utils::block_on(cmd.run_script()), - ForgeSubcommand::Coverage(cmd) => utils::block_on(cmd.run()), + ForgeSubcommand::Coverage(cmd) => { + if cmd.is_watch() { + utils::block_on(watch::watch_coverage(cmd)) + } else { + utils::block_on(cmd.run()) + } + } ForgeSubcommand::Bind(cmd) => cmd.run(), ForgeSubcommand::Build(cmd) => { if cmd.is_watch() { From b0630f97e3ee8f3244a29b882de123ff59d4a53b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Sun, 19 Jan 2025 01:15:26 +0400 Subject: [PATCH 1863/1963] feat: filter by profile in `vm.getCode` (#9714) feat: filter by profile in getCode --- crates/cheatcodes/src/config.rs | 27 +++++++-------------------- crates/cheatcodes/src/evm.rs | 2 +- crates/cheatcodes/src/fs.rs | 28 ++++++++++++++++++++-------- crates/chisel/src/executor.rs | 1 - crates/forge/src/multi_runner.rs | 3 +-- crates/script/src/lib.rs | 3 +-- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 5bd76d7992514..40e0633711c32 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -2,13 +2,12 @@ use super::Result; use crate::Vm::Rpc; use alloy_primitives::{map::AddressHashMap, U256}; use foundry_common::{fs::normalize_path, ContractsByArtifact}; -use foundry_compilers::{utils::canonicalize, ProjectPathsConfig}; +use foundry_compilers::{utils::canonicalize, ArtifactId, ProjectPathsConfig}; use foundry_config::{ cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions, ResolvedRpcEndpoint, ResolvedRpcEndpoints, RpcEndpoint, RpcEndpointUrl, }; use foundry_evm_core::opts::EvmOpts; -use semver::Version; use std::{ path::{Path, PathBuf}, time::Duration, @@ -49,10 +48,8 @@ pub struct CheatsConfig { /// If Some, `vm.getDeployedCode` invocations are validated to be in scope of this list. /// If None, no validation is performed. pub available_artifacts: Option, - /// Name of the script/test contract which is currently running. - pub running_contract: Option, - /// Version of the script/test contract which is currently running. - pub running_version: Option, + /// Currently running artifact. + pub running_artifact: Option, /// Whether to enable legacy (non-reverting) assertions. pub assertions_revert: bool, /// Optional seed for the RNG algorithm. @@ -65,8 +62,7 @@ impl CheatsConfig { config: &Config, evm_opts: EvmOpts, available_artifacts: Option, - running_contract: Option, - running_version: Option, + running_artifact: Option, ) -> Self { let mut allowed_paths = vec![config.root.clone()]; allowed_paths.extend(config.libs.iter().cloned()); @@ -94,8 +90,7 @@ impl CheatsConfig { evm_opts, labels: config.labels.clone(), available_artifacts, - running_contract, - running_version, + running_artifact, assertions_revert: config.assertions_revert, seed: config.fuzz.seed, } @@ -103,13 +98,7 @@ impl CheatsConfig { /// Returns a new `CheatsConfig` configured with the given `Config` and `EvmOpts`. pub fn clone_with(&self, config: &Config, evm_opts: EvmOpts) -> Self { - Self::new( - config, - evm_opts, - self.available_artifacts.clone(), - self.running_contract.clone(), - self.running_version.clone(), - ) + Self::new(config, evm_opts, self.available_artifacts.clone(), self.running_artifact.clone()) } /// Attempts to canonicalize (see [std::fs::canonicalize]) the path. @@ -230,8 +219,7 @@ impl Default for CheatsConfig { evm_opts: Default::default(), labels: Default::default(), available_artifacts: Default::default(), - running_contract: Default::default(), - running_version: Default::default(), + running_artifact: Default::default(), assertions_revert: true, seed: None, } @@ -249,7 +237,6 @@ mod tests { Default::default(), None, None, - None, ) } diff --git a/crates/cheatcodes/src/evm.rs b/crates/cheatcodes/src/evm.rs index 32d8cb50d0567..a002bc5f0ff43 100644 --- a/crates/cheatcodes/src/evm.rs +++ b/crates/cheatcodes/src/evm.rs @@ -1038,7 +1038,7 @@ fn derive_snapshot_name( name: Option, ) -> (String, String) { let group = group.unwrap_or_else(|| { - ccx.state.config.running_contract.clone().expect("expected running contract") + ccx.state.config.running_artifact.clone().expect("expected running contract").name }); let name = name.unwrap_or_else(|| "default".to_string()); (group, name) diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index b96a6d4d78bdb..e1cb472b803a0 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -413,19 +413,31 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result Err(fmt_err!("no matching artifact found")), - [artifact] => Ok(artifact), + [artifact] => Ok(*artifact), filtered => { + let mut filtered = filtered.to_vec(); // If we know the current script/test contract solc version, try to filter by it state .config - .running_version + .running_artifact .as_ref() - .and_then(|version| { - let filtered = filtered - .iter() - .filter(|(id, _)| id.version == *version) - .collect::>(); - (filtered.len() == 1).then(|| filtered[0]) + .and_then(|running| { + // Firstly filter by version + filtered.retain(|(id, _)| id.version == running.version); + + // Return artifact if only one matched + if filtered.len() == 1 { + return Some(filtered[0]) + } + + // Try filtering by profile as well + filtered.retain(|(id, _)| id.profile == running.profile); + + if filtered.len() == 1 { + Some(filtered[0]) + } else { + None + } }) .ok_or_else(|| fmt_err!("multiple matching artifacts found")) } diff --git a/crates/chisel/src/executor.rs b/crates/chisel/src/executor.rs index 71bf18e1ad6a7..1315cb779ba09 100644 --- a/crates/chisel/src/executor.rs +++ b/crates/chisel/src/executor.rs @@ -335,7 +335,6 @@ impl SessionSource { self.config.evm_opts.clone(), None, None, - Some(self.solc.version.clone()), ) .into(), ) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 4de95d7b65559..1b7f51a61f99b 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -343,8 +343,7 @@ impl TestRunnerConfig { &self.config, self.evm_opts.clone(), Some(known_contracts), - Some(artifact_id.name.clone()), - Some(artifact_id.version.clone()), + Some(artifact_id.clone()), )); ExecutorBuilder::new() .inspectors(|stack| { diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 574618fd28863..509e725a7195a 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -629,8 +629,7 @@ impl ScriptConfig { &self.config, self.evm_opts.clone(), Some(known_contracts), - Some(target.name), - Some(target.version), + Some(target), ) .into(), ) From 18cb6f9ee212a6c7a83828a0013872e905f7d490 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Sun, 19 Jan 2025 10:57:32 +0200 Subject: [PATCH 1864/1963] feat(chisel): determine proper path to Vm.sol based on proj remappings (#9703) --- Cargo.lock | 1 + crates/chisel/Cargo.toml | 1 + crates/chisel/src/session_source.rs | 30 ++++++++++++++++++++--------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8113d8882ec73..35af7f970c123 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2129,6 +2129,7 @@ dependencies = [ "tracing", "tracing-subscriber", "vergen", + "walkdir", "yansi", ] diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 167329d45036d..5975370d49e55 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -64,6 +64,7 @@ time = { version = "0.3", features = ["formatting"] } tokio = { workspace = true, features = ["full"] } yansi.workspace = true tracing.workspace = true +walkdir.workspace = true [target.'cfg(unix)'.dependencies] tikv-jemallocator = { workspace = true, optional = true } diff --git a/crates/chisel/src/session_source.rs b/crates/chisel/src/session_source.rs index 128873167a44c..f6e36395c507e 100644 --- a/crates/chisel/src/session_source.rs +++ b/crates/chisel/src/session_source.rs @@ -17,6 +17,7 @@ use semver::Version; use serde::{Deserialize, Serialize}; use solang_parser::{diagnostics::Diagnostic, pt}; use std::{fs, path::PathBuf}; +use walkdir::WalkDir; use yansi::Paint; /// The minimum Solidity version of the `Vm` interface. @@ -466,15 +467,26 @@ contract {contract_name} is Script {{ pub fn to_repl_source(&self) -> String { let Version { major, minor, patch, .. } = self.solc.version; let Self { contract_name, global_code, top_level_code, run_code, config, .. } = self; - - let (vm_import, vm_constant) = if !config.no_vm { - ( - "import {Vm} from \"forge-std/Vm.sol\";\n", - "Vm internal constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n" - ) - } else { - ("", "") - }; + let (mut vm_import, mut vm_constant) = (String::new(), String::new()); + if !config.no_vm { + // Check if there's any `forge-std` remapping and determine proper path to it by + // searching remapping path. + if let Some(remapping) = config + .foundry_config + .remappings + .iter() + .find(|remapping| remapping.name == "forge-std/") + { + if let Some(vm_path) = WalkDir::new(&remapping.path.path) + .into_iter() + .filter_map(|e| e.ok()) + .find(|e| e.file_name() == "Vm.sol") + { + vm_import = format!("import {{Vm}} from \"{}\";\n", vm_path.path().display()); + vm_constant = "Vm internal constant vm = Vm(address(uint160(uint256(keccak256(\"hevm cheat code\")))));\n".to_string(); + } + } + } format!( r#" From a038646cde347afaae67cc955c1e99c22dc23875 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 19 Jan 2025 12:17:49 +0000 Subject: [PATCH 1865/1963] chore(deps): weekly `cargo update` (#9715) --- Cargo.lock | 488 ++++++++++-------- Cargo.toml | 2 +- crates/anvil/Cargo.toml | 2 +- crates/anvil/core/Cargo.toml | 2 +- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- .../core/src/eth/transaction/optimism.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/eth/sign.rs | 2 +- 8 files changed, 293 insertions(+), 209 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35af7f970c123..1da66f4d8e892 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.55" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e39f295f876b61a1222d937e1dd31f965e4a1acc3bba98e448dd7e84b1a4566" +checksum = "a725039ef382d1b6b4e2ebcb15b1efff6cde9af48c47a1bdce6fb67b9456c34b" dependencies = [ "alloy-primitives", "num_enum", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44e3b98c37b3218924cd1d2a8570666b89662be54e5b182643855f783ea68b33" +checksum = "bc9138f4f0912793642d453523c3116bd5d9e11de73b70177aa7cb3e94b98ad2" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "731ea743b3d843bc657e120fb1d1e9cc94f5dab8107e35a82125a63e6420a102" +checksum = "24acd2f5ba97c7a320e67217274bc81fe3c3174b8e6144ec875d9d54e760e278" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -300,9 +300,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "788bb18e8f61d5d9340b52143f27771daf7e1dccbaf2741621d2493f9debf52e" +checksum = "ec878088ec6283ce1e90d280316aadd3d6ce3de06ff63d68953c855e7e447e92" dependencies = [ "alloy-rlp", "arbitrary", @@ -393,9 +393,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f542548a609dca89fcd72b3b9f355928cf844d4363c5eed9c5273a3dd225e097" +checksum = "3d6c1d995bff8d011f7cd6c81820d51825e6e06d6db73914c1630ecf544d83d6" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -404,9 +404,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" +checksum = "a40e1ef334153322fd878d07e86af7a529bcb86b2439525920a88eba87bcf943" dependencies = [ "proc-macro2", "quote", @@ -673,9 +673,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a07b74d48661ab2e4b50bb5950d74dbff5e61dd8ed03bb822281b706d54ebacb" +checksum = "8d039d267aa5cbb7732fa6ce1fd9b5e9e29368f580f80ba9d7a8450c794de4b2" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -687,9 +687,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19cc9c7f20b90f9be1a8f71a3d8e283a43745137b0837b1a1cb13159d37cad72" +checksum = "620ae5eee30ee7216a38027dec34e0585c55099f827f92f50d11e3d2d3a4a954" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -706,9 +706,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713b7e6dfe1cb2f55c80fb05fd22ed085a1b4e48217611365ed0ae598a74c6ac" +checksum = "ad9f7d057e00f8c5994e4ff4492b76532c51ead39353aa2ed63f8c50c0f4d52e" dependencies = [ "alloy-json-abi", "const-hex", @@ -723,9 +723,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eda2711ab2e1fb517fc6e2ffa9728c9a232e296d16810810e6957b781a1b8bc" +checksum = "74e60b084fe1aef8acecda2743ff2d93c18ff3eb67a2d3b12f62582a1e66ef5e" dependencies = [ "serde", "winnow", @@ -733,9 +733,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b478bc9c0c4737a04cd976accde4df7eba0bdc0d90ad6ff43d58bc93cf79c1" +checksum = "c1382302752cd751efd275f4d6ef65877ddf61e0e6f5ac84ef4302b79a33a31a" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -936,11 +936,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys 0.59.0", ] @@ -994,7 +995,7 @@ dependencies = [ "hyper 1.5.2", "itertools 0.13.0", "k256", - "op-alloy-consensus", + "maili-consensus", "op-alloy-rpc-types", "parking_lot", "rand", @@ -1030,7 +1031,7 @@ dependencies = [ "bytes", "foundry-common", "foundry-evm", - "op-alloy-consensus", + "maili-consensus", "rand", "revm", "serde", @@ -1344,9 +1345,9 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" +checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" dependencies = [ "proc-macro2", "quote", @@ -1361,9 +1362,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.13" +version = "1.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a50b30228d3af8865ce83376b4e99e1ffa34728220fe2860e4df0bb5278d6" +checksum = "9f40e82e858e02445402906e454a73e244c7f501fcae198977585946c48e8697" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1403,9 +1404,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16d1aa50accc11a4b4d5c50f7fb81cc0cf60328259c587d0e6b0f11385bde46" +checksum = "bee7643696e7fdd74c10f9eb42848a87fe469d35eae9c3323f80aa98f350baac" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1423,14 +1424,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.11.1", + "uuid 1.12.0", ] [[package]] name = "aws-sdk-kms" -version = "1.54.0" +version = "1.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cf16c0e5853312995505557b876dd3f9fb9941e96d031383528ccef14ace57" +checksum = "011f0f9ebfaa2f76f0cddcc05a6951c74c226af8a493c56ef7ca1a880e1de4ac" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1450,9 +1451,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.53.0" +version = "1.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1605dc0bf9f0a4b05b451441a17fcb0bda229db384f23bf5cead3adbab0664ac" +checksum = "921a13ed6aabe2d1258f65ef7804946255c799224440774c30e1a2c65cdf983a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1472,9 +1473,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.54.0" +version = "1.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f3f73466ff24f6ad109095e0f3f2c830bfb4cd6c8b12f744c8e61ebf4d3ba1" +checksum = "196c952738b05dfc917d82a3e9b5ba850822a6d6a86d677afda2a156cc172ceb" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1494,9 +1495,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.54.1" +version = "1.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "861d324ef69247c6f3c6823755f408a68877ffb1a9afaff6dd8b0057c760de60" +checksum = "33ef5b73a927ed80b44096f8c20fb4abae65469af15198367e179ae267256e9d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1517,9 +1518,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.6" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3820e0c08d0737872ff3c7c1f21ebbb6693d832312d6152bf18ef50a5471c2" +checksum = "690118821e46967b3c4501d67d7d52dd75106a9c54cf36cefa1985cedbe94e05" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1540,9 +1541,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.3" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427cb637d15d63d6f9aae26358e1c9a9c09d5aa490d64b09354c8217cfef0f28" +checksum = "fa59d1327d8b5053c54bf2eaae63bf629ba9e904434d0835a28ed3c0ed0a614e" dependencies = [ "futures-util", "pin-project-lite", @@ -1551,9 +1552,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.11" +version = "0.60.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8bc3e8fdc6b8d07d976e301c02fe553f72a39b7a9fea820e023268467d7ab6" +checksum = "7809c27ad8da6a6a68c454e651d4962479e81472aa19ae99e59f9aba1f9713cc" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -1571,9 +1572,9 @@ dependencies = [ [[package]] name = "aws-smithy-json" -version = "0.61.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4e69cc50921eb913c6b662f8d909131bb3e6ad6cb6090d3a39b66fc5c52095" +checksum = "623a51127f24c30776c8b374295f2df78d92517386f77ba30773f15a30ce1422" dependencies = [ "aws-smithy-types", ] @@ -1590,9 +1591,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.6" +version = "1.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05dd41a70fc74051758ee75b5c4db2c0ca070ed9229c3df50e9475cda1cb985" +checksum = "865f7050bbc7107a6c98a397a9fcd9413690c27fa718446967cf03b2d3ac517e" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1634,9 +1635,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.11" +version = "1.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ddc9bd6c28aeb303477170ddd183760a956a03e083b3902a990238a7e3792d" +checksum = "a28f6feb647fb5e0d5b50f0472c19a7db9462b74e2fec01bb0b44eedcc834e97" dependencies = [ "base64-simd", "bytes", @@ -1666,9 +1667,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5221b91b3e441e6675310829fd8984801b772cb1546ef6c0e54dec9f1ac13fef" +checksum = "b0df5a18c4f951c645300d365fec53a61418bcf4650f604f85fe2a665bfaa0c2" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1820,9 +1821,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" dependencies = [ "arbitrary", "serde", @@ -2069,9 +2070,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.8" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0cf6e91fde44c773c6ee7ec6bba798504641a8bc2eb7e37a04ffbf4dfaa55a" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ "shlex", ] @@ -2564,7 +2565,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "crossterm_winapi", "mio 1.0.3", "parking_lot", @@ -2681,9 +2682,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" [[package]] name = "dbus" @@ -3276,7 +3277,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.2", + "miniz_oxide 0.8.3", ] [[package]] @@ -4401,11 +4402,11 @@ dependencies = [ [[package]] name = "gix-config-value" -version = "0.14.10" +version = "0.14.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49aaeef5d98390a3bcf9dbc6440b520b793d1bf3ed99317dc407b02be995b28e" +checksum = "11365144ef93082f3403471dbaa94cfe4b5e72743bdb9560719a251d439f4cee" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "bstr", "gix-path", "libc", @@ -4456,7 +4457,7 @@ version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74908b4bbc0a0a40852737e5d7889f676f081e340d5451a16e5b4c50d592f111" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "bstr", "gix-features", "gix-path", @@ -4504,9 +4505,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.13" +version = "0.10.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc292ef1a51e340aeb0e720800338c805975724c1dfbd243185452efd8645b7" +checksum = "c40f12bb65a8299be0cfb90fe718e3be236b7a94b434877012980863a883a99f" dependencies = [ "bstr", "gix-trace", @@ -4538,11 +4539,11 @@ dependencies = [ [[package]] name = "gix-sec" -version = "0.10.10" +version = "0.10.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8b876ef997a955397809a2ec398d6a45b7a55b4918f2446344330f778d14fd6" +checksum = "d84dae13271f4313f8d60a166bf27e54c968c7c33e2ffd31c48cafe5da649875" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "gix-path", "libc", "windows-sys 0.52.0", @@ -4563,15 +4564,15 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bdde120c29f1fc23a24d3e115aeeea3d60d8e65bab92cc5f9d90d9302eb952" +checksum = "7c396a2036920c69695f760a65e7f2677267ccf483f25046977d87e4cb2665f7" [[package]] name = "gix-utils" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba427e3e9599508ed98a6ddf8ed05493db114564e338e41f6a996d2e4790335f" +checksum = "ff08f24e03ac8916c478c8419d7d3c33393da9bb41fa4c24455d5406aeefd35f" dependencies = [ "fastrand", "unicode-normalization", @@ -4579,9 +4580,9 @@ dependencies = [ [[package]] name = "gix-validate" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd520d09f9f585b34b32aba1d0b36ada89ab7fefb54a8ca3fe37fc482a750937" +checksum = "9eaa01c3337d885617c0a42e92823922a2aea71f4caeace6fe87002bdcadbd90" dependencies = [ "bstr", "thiserror 2.0.11", @@ -5435,9 +5436,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.21" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0ce60560149333a8e41ca7dc78799c47c5fd435e2bc18faf6a054382eec037" +checksum = "d2bb0c2e28117985a4d90e3bc70092bc8f226f434c7ec7e23dd9ff99c5c5721a" dependencies = [ "jiff-tzdb-platform", "log", @@ -5449,24 +5450,24 @@ dependencies = [ [[package]] name = "jiff-tzdb" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91335e575850c5c4c673b9bd467b0e025f164ca59d0564f69d0c2ee0ffad4653" +checksum = "cf2cec2f5d266af45a071ece48b1fb89f3b00b2421ac3a5fe10285a6caaa60d3" [[package]] name = "jiff-tzdb-platform" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9835f0060a626fe59f160437bc725491a6af23133ea906500027d1bd2f8f4329" +checksum = "a63c62e404e7b92979d2792352d885a7f8f83fd1d0d31eea582d77b2ceca697e" dependencies = [ "jiff-tzdb", ] [[package]] name = "js-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -5628,7 +5629,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "libc", "redox_syscall", ] @@ -5675,9 +5676,9 @@ checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "loom" @@ -5707,6 +5708,20 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" +[[package]] +name = "maili-consensus" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59cc5082a9b883b719fb3594257e56e9c6990cf49d7b41188adb51ab6c83cd1e" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "serde", +] + [[package]] name = "maplit" version = "1.0.2" @@ -5877,9 +5892,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", ] @@ -5959,11 +5974,11 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "newtype-uuid" -version = "1.1.3" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8781e2ef64806278a55ad223f0bc875772fd40e1fe6e73e8adbf027817229d" +checksum = "ee3224f0e8be7c2a1ebc77ef9c3eecb90f55c6594399ee825de964526b3c9056" dependencies = [ - "uuid 1.11.1", + "uuid 1.12.0", ] [[package]] @@ -5994,7 +6009,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "cfg-if", "cfg_aliases 0.1.1", "libc", @@ -6006,7 +6021,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "cfg-if", "cfg_aliases 0.2.1", "libc", @@ -6049,7 +6064,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "crossbeam-channel", "filetime", "fsevent-sys", @@ -6252,9 +6267,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442518bf0ef88f4d79409527565b8cdee235c891f2e2a829497caec5ed9d8d1c" +checksum = "9e51ae52013aca0aa1ca3df7ecf0d276eb4214ec44aeb9c48651333e1459b3b5" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6262,15 +6277,16 @@ dependencies = [ "alloy-rlp", "alloy-serde", "derive_more", + "maili-consensus", "serde", "thiserror 2.0.11", ] [[package]] name = "op-alloy-rpc-types" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50223d61cad040db6721bcc2d489c924c1691ce3f5e674d4d8776131dab786a0" +checksum = "071c64a4fa84544f60e2bc118f963dbb1976aa33509f185bee1b8a1a2842123c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6279,6 +6295,7 @@ dependencies = [ "alloy-rpc-types-eth", "alloy-serde", "derive_more", + "maili-consensus", "op-alloy-consensus", "serde", "serde_json", @@ -6302,7 +6319,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "cfg-if", "foreign-types", "libc", @@ -6348,9 +6365,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "outref" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" +checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e" [[package]] name = "overload" @@ -6778,9 +6795,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.27" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "483f8c21f64f3ea09fe0f30f5d48c3e8eefe5dac9129f0075f76593b4c1da705" +checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", "syn 2.0.96", @@ -6885,16 +6902,16 @@ dependencies = [ [[package]] name = "process-wrap" -version = "8.0.2" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ee68ae331824036479c84060534b18254c864fa73366c58d86db3b7b811619" +checksum = "d35f4dc9988d1326b065b4def5e950c3ed727aa03e3151b86cc9e2aec6b03f54" dependencies = [ "futures", "indexmap 2.7.0", - "nix 0.28.0", + "nix 0.29.0", "tokio", "tracing", - "windows 0.56.0", + "windows 0.59.0", ] [[package]] @@ -6922,7 +6939,7 @@ checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.7.0", + "bitflags 2.8.0", "lazy_static", "num-traits", "rand", @@ -7003,7 +7020,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "memchr", "pulldown-cmark-escape", "unicase", @@ -7033,7 +7050,7 @@ dependencies = [ "quick-xml 0.37.2", "strip-ansi-escapes", "thiserror 2.0.11", - "uuid 1.11.1", + "uuid 1.12.0", ] [[package]] @@ -7177,7 +7194,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "cassowary", "compact_str", "crossterm", @@ -7224,7 +7241,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", ] [[package]] @@ -7343,9 +7360,9 @@ dependencies = [ [[package]] name = "revm" -version = "19.2.0" +version = "19.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b829dc9d6e62c5a540dfdceb0c4d2217e445bf5f6f5ed3866817e7a9637c019" +checksum = "0a5a57589c308880c0f89ebf68d92aeef0d51e1ed88867474f895f6fd0f25c64" dependencies = [ "auto_impl", "cfg-if", @@ -7377,9 +7394,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "15.0.0" +version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ff76b50b5a9fa861fbc236fc82ce1afdf58861f65012aea807d679e54630d6" +checksum = "c0f632e761f171fb2f6ace8d1552a5793e0350578d4acec3e79ade1489f4c2a6" dependencies = [ "revm-primitives", "serde", @@ -7415,7 +7432,7 @@ dependencies = [ "alloy-eip7702", "alloy-primitives", "auto_impl", - "bitflags 2.7.0", + "bitflags 2.8.0", "bitvec", "c-kzg", "cfg-if", @@ -7587,7 +7604,7 @@ version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", @@ -7717,7 +7734,7 @@ version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee1e066dc922e513bda599c6ccb5f3bb2b0ea5870a579448f2622993f0a9a2f" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "cfg-if", "clipboard-win", "fd-lock", @@ -7912,7 +7929,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -7925,7 +7942,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "core-foundation 0.10.0", "core-foundation-sys", "libc", @@ -8008,9 +8025,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "336a0c23cf42a38d9eaa7cd22c7040d04e1228a19a933890805ffd00a16437d2" dependencies = [ "indexmap 2.7.0", "itoa", @@ -8233,13 +8250,13 @@ dependencies = [ [[package]] name = "simple_asn1" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" dependencies = [ "num-bigint", "num-traits", - "thiserror 1.0.69", + "thiserror 2.0.11", "time", ] @@ -8418,7 +8435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e1e2d07fae218aca1b4cca81216e5c9ad7822516d48a28f11e2eaa8ffa5b249" dependencies = [ "alloy-primitives", - "bitflags 2.7.0", + "bitflags 2.8.0", "bumpalo", "itertools 0.14.0", "memchr", @@ -8473,7 +8490,7 @@ dependencies = [ "thiserror 2.0.11", "tokio", "toml_edit", - "uuid 1.11.1", + "uuid 1.12.0", "zip", "zip-extract", ] @@ -8540,9 +8557,9 @@ dependencies = [ [[package]] name = "strip-ansi-escapes" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ff8ef943b384c414f54aefa961dd2bd853add74ec75e7ac74cf91dba62bcfa" +checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025" dependencies = [ "vte", ] @@ -8651,9 +8668,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e89d8bf2768d277f40573c83a02a099e96d96dd3104e13ea676194e61ac4b0" +checksum = "b84e4d83a0a6704561302b917a932484e1cae2d8c6354c64be8b7bac1c1fe057" dependencies = [ "paste", "proc-macro2", @@ -9146,7 +9163,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "bytes", "futures-util", "http 1.2.0", @@ -9511,9 +9528,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b913a3b5fe84142e269d63cc62b64319ccaf89b748fc31fe025177f767a756c4" +checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" dependencies = [ "getrandom", "serde", @@ -9521,9 +9538,9 @@ dependencies = [ [[package]] name = "valuable" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "vcpkg" @@ -9557,22 +9574,11 @@ checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" [[package]] name = "vte" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" -dependencies = [ - "utf8parse", - "vte_generate_state_changes", -] - -[[package]] -name = "vte_generate_state_changes" -version = "0.1.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" +checksum = "231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077" dependencies = [ - "proc-macro2", - "quote", + "memchr", ] [[package]] @@ -9611,20 +9617,21 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", @@ -9636,9 +9643,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.49" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", @@ -9649,9 +9656,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9659,9 +9666,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -9672,9 +9679,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-streams" @@ -9768,9 +9778,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -9846,22 +9856,22 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.56.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ - "windows-core 0.56.0", + "windows-core 0.58.0", "windows-targets 0.52.6", ] [[package]] name = "windows" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +checksum = "7f919aee0a93304be7f62e8e5027811bbba96bcb1de84d6618be56e43f8a32a1" dependencies = [ - "windows-core 0.58.0", - "windows-targets 0.52.6", + "windows-core 0.59.0", + "windows-targets 0.53.0", ] [[package]] @@ -9875,34 +9885,35 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.56.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "windows-implement 0.56.0", - "windows-interface 0.56.0", - "windows-result 0.1.2", + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce" dependencies = [ - "windows-implement 0.58.0", - "windows-interface 0.58.0", - "windows-result 0.2.0", - "windows-strings", - "windows-targets 0.52.6", + "windows-implement 0.59.0", + "windows-interface 0.59.0", + "windows-result 0.3.0", + "windows-strings 0.3.0", + "windows-targets 0.53.0", ] [[package]] name = "windows-implement" -version = "0.56.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", @@ -9911,9 +9922,9 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" dependencies = [ "proc-macro2", "quote", @@ -9922,9 +9933,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.56.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", @@ -9933,9 +9944,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +checksum = "cb26fd936d991781ea39e87c3a27285081e3c0da5ca0fcbc02d368cc6f52ff01" dependencies = [ "proc-macro2", "quote", @@ -9949,26 +9960,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result 0.2.0", - "windows-strings", + "windows-strings 0.1.0", "windows-targets 0.52.6", ] [[package]] name = "windows-result" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-result" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "d08106ce80268c4067c0571ca55a9b4e9516518eaa1a1fe9b37ca403ae1d1a34" dependencies = [ - "windows-targets 0.52.6", + "windows-targets 0.53.0", ] [[package]] @@ -9981,6 +9992,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-strings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b888f919960b42ea4e11c2f408fadb55f78a9f236d5eef084103c8ce52893491" +dependencies = [ + "windows-targets 0.53.0", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -10032,13 +10052,29 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -10051,6 +10087,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -10063,6 +10105,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -10075,12 +10123,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -10093,6 +10153,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -10105,6 +10171,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -10117,6 +10189,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -10129,6 +10207,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" version = "0.6.24" diff --git a/Cargo.toml b/Cargo.toml index 646498cc7fb65..aad4380bf53ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,7 +225,7 @@ alloy-trie = "0.7.0" ## op-alloy op-alloy-rpc-types = "0.9.0" -op-alloy-consensus = "0.9.0" +maili-consensus = "0.1.6" ## cli anstream = "0.6" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index b3389d2eccae4..414b56c5be5b5 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -67,7 +67,7 @@ alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true alloy-trie.workspace = true -op-alloy-consensus = { workspace = true, features = ["serde"] } +maili-consensus = { workspace = true, features = ["serde"] } # axum related axum.workspace = true diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index dacc7f20e0ea3..aeb6de3bd4f3d 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -30,7 +30,7 @@ alloy-eips.workspace = true alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-trie.workspace = true -op-alloy-consensus = { workspace = true, features = ["serde"] } +maili-consensus = { workspace = true, features = ["serde"] } alloy-network.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 38eda60405d41..c7126af9218f9 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -22,7 +22,7 @@ use alloy_rpc_types::{ use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; use foundry_evm::traces::CallTraceNode; -use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; +use maili_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; use revm::{ interpreter::InstructionResult, primitives::{OptimismFields, TxEnv}, diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 6bb4b2abb8a4f..3fa3ad1c43d05 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -1,6 +1,6 @@ use alloy_primitives::{Address, Bytes, TxKind, B256, U256}; use alloy_rlp::{Decodable, Encodable, Error as DecodeError, Header as RlpHeader}; -use op_alloy_consensus::TxDeposit; +use maili_consensus::TxDeposit; use serde::{Deserialize, Serialize}; pub const DEPOSIT_TX_TYPE_ID: u8 = 0x7E; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 154dae504e20f..f285338c17282 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -93,7 +93,7 @@ use foundry_evm::{ traces::TracingInspectorConfig, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; -use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; +use maili_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; use parking_lot::{Mutex, RwLock}; use revm::{ db::WrapDatabaseRef, diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index e2ea036a0cafb..275ff106929ab 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -8,7 +8,7 @@ use alloy_signer_local::PrivateKeySigner; use anvil_core::eth::transaction::{ optimism::DepositTransaction, TypedTransaction, TypedTransactionRequest, }; -use op_alloy_consensus::TxDeposit; +use maili_consensus::TxDeposit; /// A transaction signer #[async_trait::async_trait] From 90a5fdf4a47ea70d81b57b7c29910a6c1367ea0f Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 20 Jan 2025 09:07:43 +0300 Subject: [PATCH 1866/1963] Fix rewrite of User-Agent header (#9707) * Fix rewrite of User-Agent header * add test * add axym to dev deps * format * format * format * cleanup * cleanup * review fixes * use localhost address --- Cargo.lock | 1 + crates/common/Cargo.toml | 1 + .../common/src/provider/runtime_transport.rs | 41 ++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1da66f4d8e892..28fab1b428fc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3701,6 +3701,7 @@ dependencies = [ "anstream", "anstyle", "async-trait", + "axum", "clap", "comfy-table", "dunce", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index c09e23849ed50..8d2c8210c1dff 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -73,3 +73,4 @@ terminal_size.workspace = true foundry-macros.workspace = true similar-asserts.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } +axum = { workspace = true } \ No newline at end of file diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index 563cec3138505..e94d2f69336b0 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -176,7 +176,7 @@ impl RuntimeTransport { ); } - if !headers.iter().any(|(k, _v)| k.as_str().starts_with("User-Agent:")) { + if !headers.contains_key(reqwest::header::USER_AGENT) { headers.insert( reqwest::header::USER_AGENT, HeaderValue::from_str(DEFAULT_USER_AGENT) @@ -332,3 +332,42 @@ fn url_to_file_path(url: &Url) -> Result { fn url_to_file_path(url: &Url) -> Result { url.to_file_path() } + +#[cfg(test)] +mod tests { + use super::*; + use reqwest::header::HeaderMap; + + #[tokio::test] + async fn test_user_agent_header() { + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let url = Url::parse(&format!("http://{}", listener.local_addr().unwrap())).unwrap(); + + let http_handler = axum::routing::get(|actual_headers: HeaderMap| { + let user_agent = HeaderName::from_str("User-Agent").unwrap(); + assert_eq!(actual_headers[user_agent], HeaderValue::from_str("test-agent").unwrap()); + + async { "" } + }); + + let server_task = tokio::spawn(async move { + axum::serve(listener, http_handler.into_make_service()).await.unwrap() + }); + + let transport = RuntimeTransportBuilder::new(url.clone()) + .with_headers(vec!["User-Agent: test-agent".to_string()]) + .build(); + let inner = transport.connect_http().await.unwrap(); + + match inner { + InnerTransport::Http(http) => { + let _ = http.client().get(url).send().await.unwrap(); + + // assert inside http_handler + } + _ => unreachable!(), + } + + server_task.abort(); + } +} From 37398592bbf638f7edea16f7bbb957f5c5f748eb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 20 Jan 2025 11:19:15 +0100 Subject: [PATCH 1867/1963] refactor: properly handle config load errors (#9713) * refactor: properly handle config load errors * fix * doc --- crates/anvil/src/cmd.rs | 7 +- crates/cast/bin/cmd/access_list.rs | 5 +- crates/cast/bin/cmd/artifact.rs | 5 +- crates/cast/bin/cmd/call.rs | 2 +- crates/cast/bin/cmd/constructor_args.rs | 17 +- crates/cast/bin/cmd/creation_code.rs | 11 +- crates/cast/bin/cmd/estimate.rs | 5 +- crates/cast/bin/cmd/find_block.rs | 8 +- crates/cast/bin/cmd/interface.rs | 9 +- crates/cast/bin/cmd/logs.rs | 5 +- crates/cast/bin/cmd/mktx.rs | 5 +- crates/cast/bin/cmd/mod.rs | 2 +- crates/cast/bin/cmd/rpc.rs | 5 +- crates/cast/bin/cmd/run.rs | 2 +- crates/cast/bin/cmd/send.rs | 4 +- crates/cast/bin/cmd/storage.rs | 5 +- crates/cast/bin/cmd/wallet/mod.rs | 4 +- crates/cast/bin/main.rs | 50 ++--- crates/cli/src/opts/build/core.rs | 15 +- crates/cli/src/opts/build/paths.rs | 5 +- crates/cli/src/utils/cmd.rs | 117 ++++------- crates/cli/src/utils/mod.rs | 2 +- crates/common/src/compile.rs | 2 +- crates/common/src/evm.rs | 6 +- crates/common/src/term.rs | 6 +- crates/config/src/error.rs | 12 +- crates/config/src/lib.rs | 245 +++++++++++----------- crates/config/src/macros.rs | 45 +--- crates/config/src/providers/remappings.rs | 3 +- crates/config/src/utils.rs | 31 +-- crates/forge/bin/cmd/bind.rs | 2 +- crates/forge/bin/cmd/bind_json.rs | 2 +- crates/forge/bin/cmd/build.rs | 18 +- crates/forge/bin/cmd/clone.rs | 9 +- crates/forge/bin/cmd/compiler.rs | 2 +- crates/forge/bin/cmd/config.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 4 +- crates/forge/bin/cmd/create.rs | 6 +- crates/forge/bin/cmd/doc/mod.rs | 8 +- crates/forge/bin/cmd/eip712.rs | 2 +- crates/forge/bin/cmd/flatten.rs | 2 +- crates/forge/bin/cmd/fmt.rs | 2 +- crates/forge/bin/cmd/geiger.rs | 2 +- crates/forge/bin/cmd/init.rs | 2 +- crates/forge/bin/cmd/install.rs | 2 +- crates/forge/bin/cmd/mod.rs | 36 +--- crates/forge/bin/cmd/remappings.rs | 2 +- crates/forge/bin/cmd/remove.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 8 +- crates/forge/bin/cmd/tree.rs | 2 +- crates/forge/bin/cmd/update.rs | 2 +- crates/forge/bin/cmd/watch.rs | 37 ++-- crates/forge/bin/main.rs | 2 +- crates/forge/tests/cli/config.rs | 16 +- crates/script/src/lib.rs | 6 +- crates/verify/src/bytecode.rs | 2 +- crates/verify/src/etherscan/mod.rs | 8 +- crates/verify/src/verify.rs | 4 +- 58 files changed, 336 insertions(+), 496 deletions(-) diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 8be6be750c54a..0bf102e186b85 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -587,9 +587,10 @@ pub struct AnvilEvmArgs { impl AnvilEvmArgs { pub fn resolve_rpc_alias(&mut self) { if let Some(fork_url) = &self.fork_url { - let config = Config::load_with_providers(FigmentProviders::Anvil); - if let Some(Ok(url)) = config.get_rpc_url_with_alias(&fork_url.url) { - self.fork_url = Some(ForkUrl { url: url.to_string(), block: fork_url.block }); + if let Ok(config) = Config::load_with_providers(FigmentProviders::Anvil) { + if let Some(Ok(url)) = config.get_rpc_url_with_alias(&fork_url.url) { + self.fork_url = Some(ForkUrl { url: url.to_string(), block: fork_url.block }); + } } } } diff --git a/crates/cast/bin/cmd/access_list.rs b/crates/cast/bin/cmd/access_list.rs index c283f60c40b0b..4184912ffa697 100644 --- a/crates/cast/bin/cmd/access_list.rs +++ b/crates/cast/bin/cmd/access_list.rs @@ -5,10 +5,9 @@ use clap::Parser; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils, + utils::{self, LoadConfig}, }; use foundry_common::ens::NameOrAddress; -use foundry_config::Config; use std::str::FromStr; /// CLI arguments for `cast access-list`. @@ -46,7 +45,7 @@ impl AccessListArgs { pub async fn run(self) -> Result<()> { let Self { to, sig, args, tx, eth, block } = self; - let config = Config::from(ð); + let config = eth.load_config()?; let provider = utils::get_provider(&config)?; let sender = SenderKind::from_wallet_opts(eth.wallet).await?; diff --git a/crates/cast/bin/cmd/artifact.rs b/crates/cast/bin/cmd/artifact.rs index 2e7a7cae015cb..c95bd4d898da9 100644 --- a/crates/cast/bin/cmd/artifact.rs +++ b/crates/cast/bin/cmd/artifact.rs @@ -5,10 +5,9 @@ use eyre::Result; use foundry_block_explorers::Client; use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, - utils, + utils::{self, LoadConfig}, }; use foundry_common::fs; -use foundry_config::Config; use serde_json::json; use std::path::PathBuf; @@ -51,7 +50,7 @@ impl ArtifactArgs { let Self { contract, etherscan, rpc, output: output_location, abi_path } = self; let mut etherscan = etherscan; - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let api_key = etherscan.key().unwrap_or_default(); let chain = provider.get_chain_id().await?; diff --git a/crates/cast/bin/cmd/call.rs b/crates/cast/bin/cmd/call.rs index 1383bea2771b1..949e165c1dbc4 100644 --- a/crates/cast/bin/cmd/call.rs +++ b/crates/cast/bin/cmd/call.rs @@ -119,7 +119,7 @@ impl CallArgs { pub async fn run(self) -> Result<()> { let figment = Into::::into(&self.eth).merge(&self); let evm_opts = figment.extract::()?; - let mut config = Config::try_from(figment)?.sanitized(); + let mut config = Config::from_provider(figment)?.sanitized(); let Self { to, diff --git a/crates/cast/bin/cmd/constructor_args.rs b/crates/cast/bin/cmd/constructor_args.rs index 8fe42c93cf711..2775e2e99ecfd 100644 --- a/crates/cast/bin/cmd/constructor_args.rs +++ b/crates/cast/bin/cmd/constructor_args.rs @@ -1,3 +1,7 @@ +use super::{ + creation_code::fetch_creation_code, + interface::{fetch_abi_from_etherscan, load_abi_from_file}, +}; use alloy_dyn_abi::DynSolType; use alloy_primitives::{Address, Bytes}; use alloy_provider::Provider; @@ -6,13 +10,7 @@ use eyre::{eyre, OptionExt, Result}; use foundry_block_explorers::Client; use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, - utils, -}; -use foundry_config::Config; - -use super::{ - creation_code::fetch_creation_code, - interface::{fetch_abi_from_etherscan, load_abi_from_file}, + utils::{self, LoadConfig}, }; /// CLI arguments for `cast creation-args`. @@ -35,10 +33,9 @@ pub struct ConstructorArgsArgs { impl ConstructorArgsArgs { pub async fn run(self) -> Result<()> { - let Self { contract, etherscan, rpc, abi_path } = self; + let Self { contract, mut etherscan, rpc, abi_path } = self; - let mut etherscan = etherscan; - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let api_key = etherscan.key().unwrap_or_default(); let chain = provider.get_chain_id().await?; diff --git a/crates/cast/bin/cmd/creation_code.rs b/crates/cast/bin/cmd/creation_code.rs index b444bff3209a1..727e5f0d67fb5 100644 --- a/crates/cast/bin/cmd/creation_code.rs +++ b/crates/cast/bin/cmd/creation_code.rs @@ -1,3 +1,4 @@ +use super::interface::{fetch_abi_from_etherscan, load_abi_from_file}; use alloy_consensus::Transaction; use alloy_primitives::{Address, Bytes}; use alloy_provider::{ext::TraceApi, Provider}; @@ -8,12 +9,9 @@ use eyre::{eyre, OptionExt, Result}; use foundry_block_explorers::Client; use foundry_cli::{ opts::{EtherscanOpts, RpcOpts}, - utils, + utils::{self, LoadConfig}, }; use foundry_common::provider::RetryProvider; -use foundry_config::Config; - -use super::interface::{fetch_abi_from_etherscan, load_abi_from_file}; /// CLI arguments for `cast creation-code`. #[derive(Parser)] @@ -47,11 +45,10 @@ pub struct CreationCodeArgs { impl CreationCodeArgs { pub async fn run(self) -> Result<()> { - let Self { contract, etherscan, rpc, disassemble, without_args, only_args, abi_path } = + let Self { contract, mut etherscan, rpc, disassemble, without_args, only_args, abi_path } = self; - let mut etherscan = etherscan; - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let api_key = etherscan.key().unwrap_or_default(); let chain = provider.get_chain_id().await?; diff --git a/crates/cast/bin/cmd/estimate.rs b/crates/cast/bin/cmd/estimate.rs index 3454db197247c..af08cd220a661 100644 --- a/crates/cast/bin/cmd/estimate.rs +++ b/crates/cast/bin/cmd/estimate.rs @@ -6,10 +6,9 @@ use clap::Parser; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils::{self, parse_ether_value}, + utils::{self, parse_ether_value, LoadConfig}, }; use foundry_common::ens::NameOrAddress; -use foundry_config::Config; use std::str::FromStr; /// CLI arguments for `cast estimate`. @@ -69,7 +68,7 @@ impl EstimateArgs { pub async fn run(self) -> Result<()> { let Self { to, mut sig, mut args, mut tx, block, eth, command } = self; - let config = Config::from(ð); + let config = eth.load_config()?; let provider = utils::get_provider(&config)?; let sender = SenderKind::from_wallet_opts(eth.wallet).await?; diff --git a/crates/cast/bin/cmd/find_block.rs b/crates/cast/bin/cmd/find_block.rs index dc7750490b915..b77845e189cbf 100644 --- a/crates/cast/bin/cmd/find_block.rs +++ b/crates/cast/bin/cmd/find_block.rs @@ -2,8 +2,10 @@ use alloy_provider::Provider; use cast::Cast; use clap::Parser; use eyre::Result; -use foundry_cli::{opts::RpcOpts, utils}; -use foundry_config::Config; +use foundry_cli::{ + opts::RpcOpts, + utils::{self, LoadConfig}, +}; use futures::join; /// CLI arguments for `cast find-block`. @@ -21,7 +23,7 @@ impl FindBlockArgs { let Self { timestamp, rpc } = self; let ts_target = timestamp; - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let last_block_num = provider.get_block_number().await?; diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 659ce6ccaa4fa..28ce1ed31ec09 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -3,10 +3,10 @@ use alloy_primitives::Address; use clap::Parser; use eyre::{Context, Result}; use foundry_block_explorers::Client; -use foundry_cli::opts::EtherscanOpts; +use foundry_cli::{opts::EtherscanOpts, utils::LoadConfig}; use foundry_common::{compile::ProjectCompiler, fs, shell}; use foundry_compilers::{info::ContractInfo, utils::canonicalize}; -use foundry_config::{load_config_with_root, try_find_project_root, Config}; +use foundry_config::load_config; use itertools::Itertools; use serde_json::Value; use std::{ @@ -114,8 +114,7 @@ pub fn load_abi_from_file(path: &str, name: Option) -> Result Result> { - let root = try_find_project_root(None)?; - let config = load_config_with_root(Some(&root)); + let config = load_config()?; let project = config.project()?; let compiler = ProjectCompiler::new().quiet(true); @@ -139,7 +138,7 @@ pub async fn fetch_abi_from_etherscan( address: Address, etherscan: &EtherscanOpts, ) -> Result> { - let config = Config::from(etherscan); + let config = etherscan.load_config()?; let chain = config.chain.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); let client = Client::new(chain, api_key)?; diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index 154b5c9d21354..f6a756f69e622 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -6,9 +6,8 @@ use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, FilterBlockOption, Filt use cast::Cast; use clap::Parser; use eyre::Result; -use foundry_cli::{opts::EthereumOpts, utils}; +use foundry_cli::{opts::EthereumOpts, utils, utils::LoadConfig}; use foundry_common::ens::NameOrAddress; -use foundry_config::Config; use itertools::Itertools; use std::{io, str::FromStr}; @@ -58,7 +57,7 @@ impl LogsArgs { let Self { from_block, to_block, address, sig_or_topic, topics_or_args, subscribe, eth } = self; - let config = Config::from(ð); + let config = eth.load_config()?; let provider = utils::get_provider(&config)?; let cast = Cast::new(&provider); diff --git a/crates/cast/bin/cmd/mktx.rs b/crates/cast/bin/cmd/mktx.rs index 7837aaed0d657..085548d52d9fc 100644 --- a/crates/cast/bin/cmd/mktx.rs +++ b/crates/cast/bin/cmd/mktx.rs @@ -6,10 +6,9 @@ use clap::Parser; use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, - utils::get_provider, + utils::{get_provider, LoadConfig}, }; use foundry_common::ens::NameOrAddress; -use foundry_config::Config; use std::{path::PathBuf, str::FromStr}; /// CLI arguments for `cast mktx`. @@ -82,7 +81,7 @@ impl MakeTxArgs { None }; - let config = Config::from(ð); + let config = eth.load_config()?; // Retrieve the signer, and bail if it can't be constructed. let signer = eth.wallet.signer().await?; diff --git a/crates/cast/bin/cmd/mod.rs b/crates/cast/bin/cmd/mod.rs index 3f57b7668922d..223d133f12905 100644 --- a/crates/cast/bin/cmd/mod.rs +++ b/crates/cast/bin/cmd/mod.rs @@ -1,4 +1,4 @@ -//! Subcommands for cast +//! `cast` subcommands. //! //! All subcommands should respect the `foundry_config::Config`. //! If a subcommand accepts values that are supported by the `Config`, then the subcommand should diff --git a/crates/cast/bin/cmd/rpc.rs b/crates/cast/bin/cmd/rpc.rs index d901c760bed00..fa3facfd0879b 100644 --- a/crates/cast/bin/cmd/rpc.rs +++ b/crates/cast/bin/cmd/rpc.rs @@ -1,8 +1,7 @@ use cast::Cast; use clap::Parser; use eyre::Result; -use foundry_cli::{opts::RpcOpts, utils}; -use foundry_config::Config; +use foundry_cli::{opts::RpcOpts, utils, utils::LoadConfig}; use itertools::Itertools; /// CLI arguments for `cast rpc`. @@ -37,7 +36,7 @@ impl RpcArgs { pub async fn run(self) -> Result<()> { let Self { raw, method, params, rpc } = self; - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let params = if raw { diff --git a/crates/cast/bin/cmd/run.rs b/crates/cast/bin/cmd/run.rs index 7ab5ddd511f90..4ffaa2b77f7d8 100644 --- a/crates/cast/bin/cmd/run.rs +++ b/crates/cast/bin/cmd/run.rs @@ -103,7 +103,7 @@ impl RunArgs { pub async fn run(self) -> Result<()> { let figment = Into::::into(&self.rpc).merge(&self); let evm_opts = figment.extract::()?; - let mut config = Config::try_from(figment)?.sanitized(); + let mut config = Config::from_provider(figment)?.sanitized(); let compute_units_per_second = if self.no_rate_limit { Some(u64::MAX) } else { self.compute_units_per_second }; diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 0af83da1ae58d..7fe3677e34003 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -11,9 +11,9 @@ use eyre::Result; use foundry_cli::{ opts::{EthereumOpts, TransactionOpts}, utils, + utils::LoadConfig, }; use foundry_common::ens::NameOrAddress; -use foundry_config::Config; use std::{path::PathBuf, str::FromStr}; /// CLI arguments for `cast send`. @@ -115,7 +115,7 @@ impl SendTxArgs { None }; - let config = Config::from(ð); + let config = eth.load_config()?; let provider = utils::get_provider(&config)?; let builder = CastTxBuilder::new(&provider, tx, &config) diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 360e5d871335e..2c445712abcdc 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -12,6 +12,7 @@ use foundry_block_explorers::Client; use foundry_cli::{ opts::{BuildOpts, EtherscanOpts, RpcOpts}, utils, + utils::LoadConfig, }; use foundry_common::{ abi::find_source, @@ -85,7 +86,7 @@ impl figment::Provider for StorageArgs { impl StorageArgs { pub async fn run(self) -> Result<()> { - let config = Config::from(&self); + let config = self.load_config()?; let Self { address, slot, block, build, .. } = self; let provider = utils::get_provider(&config)?; @@ -354,7 +355,7 @@ mod tests { assert_eq!(args.etherscan.key(), Some("dummykey".to_string())); std::env::set_var("ETHERSCAN_API_KEY", "FXY"); - let config = Config::from(&args); + let config = args.load_config().unwrap(); std::env::remove_var("ETHERSCAN_API_KEY"); assert_eq!(config.etherscan_api_key, Some("dummykey".to_string())); diff --git a/crates/cast/bin/cmd/wallet/mod.rs b/crates/cast/bin/cmd/wallet/mod.rs index 4234304f25bb4..9d83c7e21a837 100644 --- a/crates/cast/bin/cmd/wallet/mod.rs +++ b/crates/cast/bin/cmd/wallet/mod.rs @@ -10,7 +10,7 @@ use alloy_signer_local::{ use cast::revm::primitives::Authorization; use clap::Parser; use eyre::{Context, Result}; -use foundry_cli::{opts::RpcOpts, utils}; +use foundry_cli::{opts::RpcOpts, utils, utils::LoadConfig}; use foundry_common::{fs, sh_println, shell}; use foundry_config::Config; use foundry_wallets::{RawWalletOpts, WalletOpts, WalletSigner}; @@ -369,7 +369,7 @@ impl WalletSubcommands { } Self::SignAuth { rpc, nonce, chain, wallet, address } => { let wallet = wallet.signer().await?; - let provider = utils::get_provider(&Config::from(&rpc))?; + let provider = utils::get_provider(&rpc.load_config()?)?; let nonce = if let Some(nonce) = nonce { nonce } else { diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 0d2de240024c5..86c0fa19c68ee 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -9,7 +9,7 @@ use cast::{Cast, SimpleCast}; use clap::{CommandFactory, Parser}; use clap_complete::generate; use eyre::Result; -use foundry_cli::{handler, utils}; +use foundry_cli::{handler, utils, utils::LoadConfig}; use foundry_common::{ abi::{get_error, get_event}, ens::{namehash, ProviderEnsExt}, @@ -287,7 +287,7 @@ async fn main_args(args: CastArgs) -> Result<()> { // Blockchain & RPC queries CastSubcommand::AccessList(cmd) => cmd.run().await?, CastSubcommand::Age { block, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!( "{}", @@ -295,7 +295,7 @@ async fn main_args(args: CastArgs) -> Result<()> { )? } CastSubcommand::Balance { block, who, ether, rpc, erc20 } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let account_addr = who.resolve(&provider).await?; @@ -316,7 +316,7 @@ async fn main_args(args: CastArgs) -> Result<()> { } } CastSubcommand::BaseFee { block, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!( "{}", @@ -324,7 +324,7 @@ async fn main_args(args: CastArgs) -> Result<()> { )? } CastSubcommand::Block { block, full, field, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!( "{}", @@ -334,7 +334,7 @@ async fn main_args(args: CastArgs) -> Result<()> { )? } CastSubcommand::BlockNumber { rpc, block } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let number = match block { Some(id) => { @@ -350,34 +350,34 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{number}")? } CastSubcommand::Chain { rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!("{}", Cast::new(provider).chain().await?)? } CastSubcommand::ChainId { rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!("{}", Cast::new(provider).chain_id().await?)? } CastSubcommand::Client { rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!("{}", provider.get_client_version().await?)? } CastSubcommand::Code { block, who, disassemble, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; sh_println!("{}", Cast::new(provider).code(who, block, disassemble).await?)? } CastSubcommand::Codesize { block, who, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; sh_println!("{}", Cast::new(provider).codesize(who, block).await?)? } CastSubcommand::ComputeAddress { address, nonce, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let address = stdin::unwrap_line(address)?; @@ -413,7 +413,7 @@ async fn main_args(args: CastArgs) -> Result<()> { } CastSubcommand::FindBlock(cmd) => cmd.run().await?, CastSubcommand::GasPrice { rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!("{}", Cast::new(provider).gas_price().await?)?; } @@ -426,37 +426,37 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{}", foundry_common::erc7201(&id))?; } CastSubcommand::Implementation { block, beacon, who, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; sh_println!("{}", Cast::new(provider).implementation(who, beacon, block).await?)?; } CastSubcommand::Admin { block, who, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; sh_println!("{}", Cast::new(provider).admin(who, block).await?)?; } CastSubcommand::Nonce { block, who, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; sh_println!("{}", Cast::new(provider).nonce(who, block).await?)?; } CastSubcommand::Codehash { block, who, slots, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; sh_println!("{}", Cast::new(provider).codehash(who, slots, block).await?)?; } CastSubcommand::StorageRoot { block, who, slots, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = who.resolve(&provider).await?; sh_println!("{}", Cast::new(provider).storage_root(who, slots, block).await?)?; } CastSubcommand::Proof { address, slots, rpc, block } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let address = address.resolve(&provider).await?; let value = provider @@ -473,7 +473,7 @@ async fn main_args(args: CastArgs) -> Result<()> { CastSubcommand::Estimate(cmd) => cmd.run().await?, CastSubcommand::MakeTx(cmd) => cmd.run().await?, CastSubcommand::PublishTx { raw_tx, cast_async, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let cast = Cast::new(&provider); let pending_tx = cast.publish(raw_tx).await?; @@ -487,7 +487,7 @@ async fn main_args(args: CastArgs) -> Result<()> { } } CastSubcommand::Receipt { tx_hash, field, cast_async, confirmations, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!( "{}", @@ -499,7 +499,7 @@ async fn main_args(args: CastArgs) -> Result<()> { CastSubcommand::Run(cmd) => cmd.run().await?, CastSubcommand::SendTx(cmd) => cmd.run().await?, CastSubcommand::Tx { tx_hash, field, raw, rpc } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; // Can use either --raw or specify raw as a field @@ -565,7 +565,7 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{}", namehash(&name))? } CastSubcommand::LookupAddress { who, rpc, verify } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = stdin::unwrap_line(who)?; @@ -580,7 +580,7 @@ async fn main_args(args: CastArgs) -> Result<()> { sh_println!("{name}")? } CastSubcommand::ResolveName { who, rpc, verify } => { - let config = Config::from(&rpc); + let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; let who = stdin::unwrap_line(who)?; @@ -631,7 +631,7 @@ async fn main_args(args: CastArgs) -> Result<()> { SimpleCast::right_shift(&value, &bits, base_in.as_deref(), &base_out)? )?, CastSubcommand::EtherscanSource { address, directory, etherscan, flatten } => { - let config = Config::from(ðerscan); + let config = etherscan.load_config()?; let chain = config.chain.unwrap_or_default(); let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); match (directory, flatten) { diff --git a/crates/cli/src/opts/build/core.rs b/crates/cli/src/opts/build/core.rs index 9491ff35fb094..b9de478c3f237 100644 --- a/crates/cli/src/opts/build/core.rs +++ b/crates/cli/src/opts/build/core.rs @@ -152,7 +152,7 @@ impl BuildOpts { /// `find_project_root` and merges the cli `BuildArgs` into it before returning /// [`foundry_config::Config::project()`]). pub fn project(&self) -> Result> { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; Ok(config.project()?) } @@ -196,19 +196,6 @@ impl<'a> From<&'a BuildOpts> for Figment { } } -impl<'a> From<&'a BuildOpts> for Config { - fn from(args: &'a BuildOpts) -> Self { - let figment: Figment = args.into(); - let mut config = Self::from_provider(figment).sanitized(); - // if `--config-path` is set we need to adjust the config's root path to the actual root - // path for the project, otherwise it will the parent dir of the `--config-path` - if args.project_paths.config_path.is_some() { - config.root = args.project_paths.project_root(); - } - config - } -} - impl Provider for BuildOpts { fn metadata(&self) -> Metadata { Metadata::named("Core Build Args Provider") diff --git a/crates/cli/src/opts/build/paths.rs b/crates/cli/src/opts/build/paths.rs index 7a4d83eeaf6e1..263e03c14881a 100644 --- a/crates/cli/src/opts/build/paths.rs +++ b/crates/cli/src/opts/build/paths.rs @@ -71,8 +71,11 @@ impl ProjectPathOpts { /// # Panics /// /// Panics if the project root directory cannot be found. See [`find_project_root`]. + #[track_caller] pub fn project_root(&self) -> PathBuf { - self.root.clone().unwrap_or_else(|| find_project_root(None)) + self.root + .clone() + .unwrap_or_else(|| find_project_root(None).expect("could not determine project root")) } /// Returns the remappings to add to the config diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index 0d2febf93d07e..eca7a7a3998af 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -191,58 +191,46 @@ pub fn has_batch_support(chain_id: u64) -> bool { /// Helpers for loading configuration. /// -/// This is usually implicitly implemented on a "&CmdArgs" struct via impl macros defined in -/// `forge_config` (see [`foundry_config::impl_figment_convert`] for more details) and the impl -/// definition on `T: Into + Into` below. +/// This is usually implemented through the macros defined in [`foundry_config`]. See +/// [`foundry_config::impl_figment_convert`] for more details. /// -/// Each function also has an `emit_warnings` form which does the same thing as its counterpart but -/// also prints `Config::__warnings` to stderr +/// By default each function will emit warnings generated during loading, unless the `_no_warnings` +/// variant is used. pub trait LoadConfig { - /// Load and sanitize the [`Config`] based on the options provided in self - /// - /// Returns an error if loading the config failed - fn try_load_config(self) -> Result; - /// Load and sanitize the [`Config`] based on the options provided in self - fn load_config(self) -> Config; - /// Load and sanitize the [`Config`], as well as extract [`EvmOpts`] from self - fn load_config_and_evm_opts(self) -> Result<(Config, EvmOpts)>; - /// Load [`Config`] but do not sanitize. See [`Config::sanitized`] for more information - fn load_config_unsanitized(self) -> Config; + /// Load the [`Config`] based on the options provided in self. + fn figment(&self) -> Figment; + + /// Load and sanitize the [`Config`] based on the options provided in self. + fn load_config(&self) -> Result { + self.load_config_no_warnings().inspect(emit_warnings) + } + + /// Same as [`LoadConfig::load_config`] but does not emit warnings. + fn load_config_no_warnings(&self) -> Result { + self.load_config_unsanitized_no_warnings().map(Config::sanitized) + } + /// Load [`Config`] but do not sanitize. See [`Config::sanitized`] for more information. - /// - /// Returns an error if loading failed - fn try_load_config_unsanitized(self) -> Result; - /// Same as [`LoadConfig::load_config`] but also emits warnings generated - fn load_config_emit_warnings(self) -> Config; - /// Same as [`LoadConfig::load_config`] but also emits warnings generated - /// - /// Returns an error if loading failed - fn try_load_config_emit_warnings(self) -> Result; - /// Same as [`LoadConfig::load_config_and_evm_opts`] but also emits warnings generated - fn load_config_and_evm_opts_emit_warnings(self) -> Result<(Config, EvmOpts)>; - /// Same as [`LoadConfig::load_config_unsanitized`] but also emits warnings generated - fn load_config_unsanitized_emit_warnings(self) -> Config; - fn try_load_config_unsanitized_emit_warnings(self) -> Result; -} + fn load_config_unsanitized(&self) -> Result { + self.load_config_unsanitized_no_warnings().inspect(emit_warnings) + } -impl LoadConfig for T -where - T: Into + Into, -{ - fn try_load_config(self) -> Result { - let figment: Figment = self.into(); - Ok(Config::try_from(figment)?.sanitized()) + /// Same as [`LoadConfig::load_config_unsanitized`] but also emits warnings generated + fn load_config_unsanitized_no_warnings(&self) -> Result { + Config::from_provider(self.figment()) } - fn load_config(self) -> Config { - self.into() + /// Load and sanitize the [`Config`], as well as extract [`EvmOpts`] from self + fn load_config_and_evm_opts(&self) -> Result<(Config, EvmOpts)> { + self.load_config_and_evm_opts_no_warnings().inspect(|(config, _)| emit_warnings(config)) } - fn load_config_and_evm_opts(self) -> Result<(Config, EvmOpts)> { - let figment: Figment = self.into(); + /// Same as [`LoadConfig::load_config_and_evm_opts`] but also emits warnings generated + fn load_config_and_evm_opts_no_warnings(&self) -> Result<(Config, EvmOpts)> { + let figment = self.figment(); let mut evm_opts = figment.extract::().map_err(ExtractConfigError::new)?; - let config = Config::try_from(figment)?.sanitized(); + let config = Config::from_provider(figment)?.sanitized(); // update the fork url if it was an alias if let Some(fork_url) = config.get_rpc_url() { @@ -252,45 +240,14 @@ where Ok((config, evm_opts)) } +} - fn load_config_unsanitized(self) -> Config { - let figment: Figment = self.into(); - Config::from_provider(figment) - } - - fn try_load_config_unsanitized(self) -> Result { - let figment: Figment = self.into(); - Config::try_from(figment) - } - - fn load_config_emit_warnings(self) -> Config { - let config = self.load_config(); - config.warnings.iter().for_each(|w| sh_warn!("{w}").unwrap()); - config - } - - fn try_load_config_emit_warnings(self) -> Result { - let config = self.try_load_config()?; - emit_warnings(&config); - Ok(config) - } - - fn load_config_and_evm_opts_emit_warnings(self) -> Result<(Config, EvmOpts)> { - let (config, evm_opts) = self.load_config_and_evm_opts()?; - emit_warnings(&config); - Ok((config, evm_opts)) - } - - fn load_config_unsanitized_emit_warnings(self) -> Config { - let config = self.load_config_unsanitized(); - emit_warnings(&config); - config - } - - fn try_load_config_unsanitized_emit_warnings(self) -> Result { - let config = self.try_load_config_unsanitized()?; - emit_warnings(&config); - Ok(config) +impl LoadConfig for T +where + for<'a> Figment: From<&'a T>, +{ + fn figment(&self) -> Figment { + self.into() } } diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 6bf8c5b5d1628..897487fb5b188 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -193,7 +193,7 @@ pub fn load_dotenv() { // we only want the .env file of the cwd and project root // `find_project_root` calls `current_dir` internally so both paths are either both `Ok` or // both `Err` - if let (Ok(cwd), Ok(prj_root)) = (std::env::current_dir(), try_find_project_root(None)) { + if let (Ok(cwd), Ok(prj_root)) = (std::env::current_dir(), find_project_root(None)) { load(&prj_root); if cwd != prj_root { // prj root and cwd can be identical diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index 5f14c066125f2..49edd1394253b 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -161,7 +161,7 @@ impl ProjectCompiler { /// /// ```ignore /// use foundry_common::compile::ProjectCompiler; - /// let config = foundry_config::Config::load(); + /// let config = foundry_config::Config::load().unwrap(); /// let prj = config.project().unwrap(); /// ProjectCompiler::new().compile_with(|| Ok(prj.compile()?)).unwrap(); /// ``` diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index dac5e6d9adf00..74b0c8f8056d7 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -300,7 +300,7 @@ mod tests { env: EnvArgs { chain: Some(NamedChain::Mainnet.into()), ..Default::default() }, ..Default::default() }; - let config = Config::from_provider(Config::figment().merge(args)); + let config = Config::from_provider(Config::figment().merge(args)).unwrap(); assert_eq!(config.chain, Some(NamedChain::Mainnet.into())); let env = EnvArgs::parse_from(["foundry-common", "--chain-id", "goerli"]); @@ -313,7 +313,7 @@ mod tests { env: EnvArgs { chain: Some(NamedChain::Mainnet.into()), ..Default::default() }, ..Default::default() }; - let config = Config::from_provider(Config::figment().merge(args)); + let config = Config::from_provider(Config::figment().merge(args)).unwrap(); assert_eq!(config.memory_limit, Config::default().memory_limit); let env = EnvArgs::parse_from(["foundry-common", "--memory-limit", "100"]); @@ -328,7 +328,7 @@ mod tests { let env = EnvArgs::parse_from(["foundry-common", "--chain-id", "mainnet"]); assert_eq!(env.chain, Some(Chain::mainnet())); let args = EvmArgs { env, ..Default::default() }; - let config = Config::from_provider(Config::figment().merge(args)); + let config = Config::from_provider(Config::figment().merge(args)).unwrap(); assert_eq!(config.chain, Some(Chain::mainnet())); } } diff --git a/crates/common/src/term.rs b/crates/common/src/term.rs index e673987454cb2..1ee62f8aedf6b 100644 --- a/crates/common/src/term.rs +++ b/crates/common/src/term.rs @@ -165,7 +165,11 @@ impl Reporter for SpinnerReporter { dirty_files .iter() .map(|path| { - let trimmed_path = path.strip_prefix(&project_root).unwrap_or(path); + let trimmed_path = if let Ok(project_root) = &project_root { + path.strip_prefix(project_root).unwrap_or(path) + } else { + path + }; format!("- {}", trimmed_path.display()) }) .sorted() diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index 09f21605d1103..eba84a57da0dc 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -3,11 +3,9 @@ use alloy_primitives::map::HashSet; use figment::providers::{Format, Toml}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{error::Error, fmt, str::FromStr}; -/// The message shown upon panic if the config could not be extracted from the figment -pub const FAILED_TO_EXTRACT_CONFIG_PANIC_MSG: &str = "failed to extract foundry config:"; /// Represents a failed attempt to extract `Config` from a `Figment` -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, PartialEq)] pub struct ExtractConfigError { /// error thrown when extracting the `Config` pub(crate) error: figment::Error, @@ -40,7 +38,7 @@ impl fmt::Display for ExtractConfigError { unique_errors.push(err); } } - writeln!(f, "{FAILED_TO_EXTRACT_CONFIG_PANIC_MSG}")?; + writeln!(f, "failed to extract foundry config:")?; for err in unique_errors { writeln!(f, "{err}")?; } @@ -48,6 +46,12 @@ impl fmt::Display for ExtractConfigError { } } +impl fmt::Debug for ExtractConfigError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + impl Error for ExtractConfigError { fn source(&self) -> Option<&(dyn Error + 'static)> { Error::source(&self.error) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index e96ca60bd4366..4252d2d163b99 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -581,40 +581,33 @@ impl Config { /// Docker image with eof-enabled solc binary pub const EOF_SOLC_IMAGE: &'static str = "ghcr.io/paradigmxyz/forge-eof@sha256:46f868ce5264e1190881a3a335d41d7f42d6f26ed20b0c823609c715e38d603f"; - /// Returns the current `Config` + /// Loads the `Config` from the current directory. /// /// See [`figment`](Self::figment) for more details. - #[track_caller] - pub fn load() -> Self { + pub fn load() -> Result { Self::from_provider(Self::figment()) } - /// Returns the current `Config` with the given `providers` preset + /// Loads the `Config` with the given `providers` preset. /// /// See [`figment`](Self::figment) for more details. - #[track_caller] - pub fn load_with_providers(providers: FigmentProviders) -> Self { + pub fn load_with_providers(providers: FigmentProviders) -> Result { Self::from_provider(Self::default().to_figment(providers)) } - /// Returns the current `Config` + /// Loads the `Config` from the given root directory. /// /// See [`figment_with_root`](Self::figment_with_root) for more details. #[track_caller] - pub fn load_with_root(root: impl AsRef) -> Self { + pub fn load_with_root(root: impl AsRef) -> Result { Self::from_provider(Self::figment_with_root(root.as_ref())) } - /// Extract a `Config` from `provider`, panicking if extraction fails. - /// - /// # Panics - /// - /// If extraction fails, prints an error message indicating the failure and - /// panics. For a version that doesn't panic, use [`Config::try_from()`]. + /// Attempts to extract a `Config` from `provider`, returning the result. /// /// # Example /// - /// ```no_run + /// ```rust /// use figment::providers::{Env, Format, Toml}; /// use foundry_config::Config; /// @@ -624,31 +617,19 @@ impl Config { /// /// let config = Config::from_provider(figment); /// ``` - #[track_caller] - pub fn from_provider(provider: T) -> Self { + #[doc(alias = "try_from")] + pub fn from_provider(provider: T) -> Result { trace!("load config with provider: {:?}", provider.metadata()); - Self::try_from(provider).unwrap_or_else(|err| panic!("{}", err)) + Self::from_figment(Figment::from(provider)) } - /// Attempts to extract a `Config` from `provider`, returning the result. - /// - /// # Example - /// - /// ```rust - /// use figment::providers::{Env, Format, Toml}; - /// use foundry_config::Config; - /// - /// // Use foundry's default `Figment`, but allow values from `other.toml` - /// // to supersede its values. - /// let figment = Config::figment().merge(Toml::file("other.toml").nested()); - /// - /// let config = Config::try_from(figment); - /// ``` + #[doc(hidden)] + #[deprecated(note = "use `Config::from_provider` instead")] pub fn try_from(provider: T) -> Result { - Self::try_from_figment(Figment::from(provider)) + Self::from_provider(provider) } - fn try_from_figment(figment: Figment) -> Result { + fn from_figment(figment: Figment) -> Result { let mut config = figment.extract::().map_err(ExtractConfigError::new)?; config.profile = figment.profile().clone(); @@ -949,8 +930,9 @@ impl Config { /// /// ``` /// use foundry_config::Config; - /// let config = Config::load_with_root(".").sanitized(); - /// let project = config.project(); + /// let config = Config::load_with_root(".")?.sanitized(); + /// let project = config.project()?; + /// # Ok::<_, eyre::Error>(()) /// ``` pub fn project(&self) -> Result, SolcError> { self.create_project(self.cache, false) @@ -1198,8 +1180,9 @@ impl Config { /// ``` /// use foundry_compilers::solc::Solc; /// use foundry_config::Config; - /// let config = Config::load_with_root(".").sanitized(); + /// let config = Config::load_with_root(".")?.sanitized(); /// let paths = config.project_paths::(); + /// # Ok::<_, eyre::Error>(()) /// ``` pub fn project_paths(&self) -> ProjectPathsConfig { let mut builder = ProjectPathsConfig::builder() @@ -1641,6 +1624,16 @@ impl Config { Self::with_root(root.as_ref()).into() } + #[doc(hidden)] + #[track_caller] + pub fn figment_with_root_opt(root: Option<&Path>) -> Figment { + let root = match root { + Some(root) => root, + None => &find_project_root(None).expect("could not determine project root"), + }; + Self::figment_with_root(root) + } + /// Creates a new Config that adds additional context extracted from the provided root. /// /// # Example @@ -1718,7 +1711,7 @@ impl Config { where F: FnOnce(&Self, &mut toml_edit::DocumentMut) -> bool, { - let config = Self::load_with_root(root).sanitized(); + let config = Self::load_with_root(root)?.sanitized(); config.update(|doc| f(&config, doc)) } @@ -2616,7 +2609,7 @@ mod tests { #[test] fn test_install_dir() { figment::Jail::expect_with(|jail| { - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.install_lib_dir(), PathBuf::from("lib")); jail.create_file( "foundry.toml", @@ -2625,7 +2618,7 @@ mod tests { libs = ['node_modules', 'lib'] ", )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.install_lib_dir(), PathBuf::from("lib")); jail.create_file( @@ -2635,7 +2628,7 @@ mod tests { libs = ['custom', 'node_modules', 'lib'] ", )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.install_lib_dir(), PathBuf::from("custom")); Ok(()) @@ -2674,7 +2667,7 @@ mod tests { ", )?; - let config = crate::Config::load(); + let config = crate::Config::load().unwrap(); let expected: &[figment::Profile] = &["ci".into(), "default".into(), "local".into()]; assert_eq!(config.profiles, expected); @@ -2686,9 +2679,9 @@ mod tests { fn test_default_round_trip() { figment::Jail::expect_with(|_| { let original = Config::figment(); - let roundtrip = Figment::from(Config::from_provider(&original)); + let roundtrip = Figment::from(Config::from_provider(&original).unwrap()); for figment in &[original, roundtrip] { - let config = Config::from_provider(figment); + let config = Config::from_provider(figment).unwrap(); assert_eq!(config, Config::default().normalized_optimizer_settings()); } Ok(()) @@ -2701,7 +2694,7 @@ mod tests { jail.set_env("FOUNDRY_FFI", "true"); jail.set_env("FFI", "true"); jail.set_env("DAPP_FFI", "true"); - let config = Config::load(); + let config = Config::load().unwrap(); assert!(!config.ffi); Ok(()) @@ -2729,7 +2722,7 @@ mod tests { ", )?; jail.set_env("FOUNDRY_PROFILE", "local"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.libs, vec![PathBuf::from("modules")]); Ok(()) @@ -2749,15 +2742,15 @@ mod tests { #[test] fn test_default_libs() { figment::Jail::expect_with(|jail| { - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.libs, vec![PathBuf::from("lib")]); fs::create_dir_all(jail.directory().join("node_modules")).unwrap(); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.libs, vec![PathBuf::from("node_modules")]); fs::create_dir_all(jail.directory().join("lib")).unwrap(); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.libs, vec![PathBuf::from("lib"), PathBuf::from("node_modules")]); Ok(()) @@ -2780,12 +2773,12 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.src, PathBuf::from("defaultsrc")); assert_eq!(config.libs, vec![PathBuf::from("lib"), PathBuf::from("node_modules")]); jail.set_env("FOUNDRY_PROFILE", "custom"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.src, PathBuf::from("customsrc")); assert_eq!(config.test, PathBuf::from("defaulttest")); assert_eq!(config.libs, vec![PathBuf::from("lib"), PathBuf::from("node_modules")]); @@ -2805,7 +2798,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); let paths_config = config.project_paths::(); assert_eq!(paths_config.tests, PathBuf::from(r"mytest")); Ok(()) @@ -2824,7 +2817,7 @@ mod tests { cache = true "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert!(config.remappings.is_empty()); jail.create_file( @@ -2835,7 +2828,7 @@ mod tests { ", )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.remappings, vec![ @@ -2845,7 +2838,7 @@ mod tests { ); jail.set_env("DAPP_REMAPPINGS", "ds-test=lib/ds-test/\nother/=lib/other/"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.remappings, @@ -2875,7 +2868,7 @@ mod tests { cache = true "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert!(config.remappings.is_empty()); jail.create_file( @@ -2886,7 +2879,7 @@ mod tests { ", )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.remappings, vec![ @@ -2896,7 +2889,7 @@ mod tests { ); jail.set_env("DAPP_REMAPPINGS", "ds-test/=lib/ds-test/src/\nenv-lib/=lib/env-lib/"); - let config = Config::load(); + let config = Config::load().unwrap(); // Remappings should now be: // - ds-test from environment (lib/ds-test/src/) @@ -2936,11 +2929,11 @@ mod tests { "#, )?; - let mut config = Config::load(); + let mut config = Config::load().unwrap(); config.libs.push("libs".into()); config.update_libs().unwrap(); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.libs, vec![PathBuf::from("node_modules"), PathBuf::from("libs"),]); Ok(()) }); @@ -2960,7 +2953,7 @@ mod tests { ), )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config, Config { @@ -2985,7 +2978,7 @@ mod tests { "#, )?; - let _config = Config::load(); + let _config = Config::load().unwrap(); Ok(()) }); @@ -2997,7 +2990,7 @@ mod tests { figment::Jail::expect_with(|jail| { jail.set_env("FOUNDRY_CONFIG", "this config does not exist"); - let _config = Config::load(); + let _config = Config::load().unwrap(); Ok(()) }); @@ -3018,7 +3011,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert!(config .get_etherscan_config_with_chain(Some(NamedChain::BinanceSmartChain.into())) .is_err()); @@ -3065,7 +3058,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert!(config.etherscan.clone().resolved().has_unresolved()); @@ -3118,7 +3111,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); let etherscan = config.get_etherscan_config().unwrap().unwrap(); assert_eq!(etherscan.chain, Some(NamedChain::Sepolia.into())); assert_eq!(etherscan.key, "FX42Z3BBJJEWXWGYV2X1CIPRSCN"); @@ -3141,7 +3134,7 @@ mod tests { )?; jail.set_env("_CONFIG_MAINNET", "https://eth-mainnet.alchemyapi.io/v2/123455"); - let mut config = Config::load(); + let mut config = Config::load().unwrap(); assert_eq!("http://localhost:8545", config.get_rpc_url_or_localhost_http().unwrap()); config.eth_rpc_url = Some("mainnet".to_string()); @@ -3170,7 +3163,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!("http://localhost:8545", config.get_rpc_url_or_localhost_http().unwrap()); Ok(()) @@ -3188,13 +3181,13 @@ mod tests { polygonMumbai = "https://polygon-mumbai.g.alchemy.com/v2/${_RESOLVE_RPC_ALIAS}" "#, )?; - let mut config = Config::load(); + let mut config = Config::load().unwrap(); config.eth_rpc_url = Some("polygonMumbai".to_string()); assert!(config.get_rpc_url().unwrap().is_err()); jail.set_env("_RESOLVE_RPC_ALIAS", "123455"); - let mut config = Config::load(); + let mut config = Config::load().unwrap(); config.eth_rpc_url = Some("polygonMumbai".to_string()); assert_eq!( "https://polygon-mumbai.g.alchemy.com/v2/123455", @@ -3222,7 +3215,7 @@ mod tests { jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARB_ONE", "123455"); jail.set_env("TEST_RESOLVE_RPC_ALIAS_ARBISCAN", "123455"); - let config = Config::load(); + let config = Config::load().unwrap(); let config = config.get_etherscan_config_with_chain(Some(NamedChain::Arbitrum.into())); assert!(config.is_err()); @@ -3245,7 +3238,7 @@ mod tests { )?; jail.set_env("_CONFIG_MAINNET", "https://eth-mainnet.alchemyapi.io/v2/123455"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( RpcEndpoints::new([ ( @@ -3313,7 +3306,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); jail.set_env("_CONFIG_AUTH", "123456"); jail.set_env("_CONFIG_MAINNET", "https://eth-mainnet.alchemyapi.io/v2/123455"); @@ -3389,7 +3382,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.get_rpc_url().unwrap().unwrap(), "https://example.com/"); @@ -3448,7 +3441,7 @@ mod tests { "#, )?; - let mut config = Config::load(); + let mut config = Config::load().unwrap(); let optimism = config.get_etherscan_api_key(Some(NamedChain::Optimism.into())); assert_eq!(optimism, Some("https://etherscan-optimism.com/".to_string())); @@ -3475,7 +3468,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); let mumbai = config .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai.into())) @@ -3500,7 +3493,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); let mumbai = config .get_etherscan_config_with_chain(Some(NamedChain::PolygonMumbai.into())) @@ -3530,7 +3523,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); let mumbai = config.get_etherscan_config_with_chain(None).unwrap().unwrap(); assert_eq!(mumbai.key, "https://etherscan-mumbai.com/".to_string()); @@ -3572,7 +3565,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config, Config { @@ -3634,7 +3627,7 @@ mod tests { ", )?; - let config = Config::load_with_root(jail.directory()); + let config = Config::load_with_root(jail.directory()).unwrap(); assert_eq!( config.remappings, vec![Remapping::from_str("nested/=lib/nested/").unwrap().into()] @@ -3719,7 +3712,7 @@ mod tests { "#, )?; - let config = Config::load_with_root(jail.directory()); + let config = Config::load_with_root(jail.directory()).unwrap(); assert_eq!(config.ignored_file_paths, vec![PathBuf::from("something")]); assert_eq!(config.fuzz.seed, Some(U256::from(1000))); @@ -3757,7 +3750,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 12)))); jail.create_file( @@ -3768,7 +3761,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 12)))); jail.create_file( @@ -3779,11 +3772,11 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.solc, Some(SolcReq::Local("path/to/local/solc".into()))); jail.set_env("FOUNDRY_SOLC_VERSION", "0.6.6"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 6, 6)))); Ok(()) }); @@ -3802,7 +3795,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 12)))); Ok(()) @@ -3817,7 +3810,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.solc, Some(SolcReq::Version(Version::new(0, 8, 20)))); Ok(()) @@ -3840,7 +3833,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config, Config { @@ -3870,7 +3863,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.extra_output, @@ -3895,7 +3888,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config, Config { @@ -3907,7 +3900,7 @@ mod tests { ); jail.set_env("FOUNDRY_SRC", r"other-src"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config, Config { @@ -3942,7 +3935,7 @@ mod tests { src = "other-src" "#, )?; - let loaded = Config::load(); + let loaded = Config::load().unwrap(); assert_eq!(loaded.evm_version, EvmVersion::Berlin); let base = loaded.into_basic(); let default = Config::default(); @@ -3983,7 +3976,7 @@ mod tests { dictionary_weight = 101 ", )?; - let _config = Config::load(); + let _config = Config::load().unwrap(); Ok(()) }); } @@ -4011,7 +4004,7 @@ mod tests { )?; let invariant_default = InvariantConfig::default(); - let config = Config::load(); + let config = Config::load().unwrap(); assert_ne!(config.invariant.runs, config.fuzz.runs); assert_eq!(config.invariant.runs, 420); @@ -4035,7 +4028,7 @@ mod tests { ); jail.set_env("FOUNDRY_PROFILE", "ci"); - let ci_config = Config::load(); + let ci_config = Config::load().unwrap(); assert_eq!(ci_config.fuzz.runs, 1); assert_eq!(ci_config.invariant.runs, 400); assert_eq!(ci_config.fuzz.dictionary.dictionary_weight, 5); @@ -4068,12 +4061,12 @@ mod tests { ", )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.fuzz.runs, 100); assert_eq!(config.invariant.runs, 120); jail.set_env("FOUNDRY_PROFILE", "ci"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.fuzz.runs, 420); assert_eq!(config.invariant.runs, 500); @@ -4093,7 +4086,7 @@ mod tests { jail.set_env("DAPP_BUILD_OPTIMIZE_RUNS", 999); jail.set_env("DAPP_BUILD_OPTIMIZE", 0); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.block_number, 1337); assert_eq!(config.sender, addr); @@ -4114,7 +4107,7 @@ mod tests { "DAPP_LIBRARIES", "[src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6]", ); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.libraries, vec!["src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6" @@ -4125,7 +4118,7 @@ mod tests { "DAPP_LIBRARIES", "src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6", ); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.libraries, vec!["src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6" @@ -4136,7 +4129,7 @@ mod tests { "DAPP_LIBRARIES", "src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6,src/DssSpell.sol:DssExecLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6", ); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.libraries, vec![ @@ -4167,7 +4160,7 @@ mod tests { ] ", )?; - let config = Config::load(); + let config = Config::load().unwrap(); let libs = config.parsed_libraries().unwrap().libs; @@ -4221,7 +4214,7 @@ mod tests { let basic = default.clone().into_basic(); jail.create_file("foundry.toml", &basic.to_string_pretty().unwrap())?; - let mut other = Config::load(); + let mut other = Config::load().unwrap(); clear_warning(&mut other); assert_eq!(default, other); @@ -4229,7 +4222,7 @@ mod tests { assert_eq!(basic, other); jail.create_file("foundry.toml", &default.to_string_pretty().unwrap())?; - let mut other = Config::load(); + let mut other = Config::load().unwrap(); clear_warning(&mut other); assert_eq!(default, other); @@ -4247,7 +4240,7 @@ mod tests { fs_permissions = [{ access = "read-write", path = "./"}] "#, )?; - let loaded = Config::load(); + let loaded = Config::load().unwrap(); assert_eq!( loaded.fs_permissions, @@ -4261,7 +4254,7 @@ mod tests { fs_permissions = [{ access = "none", path = "./"}] "#, )?; - let loaded = Config::load(); + let loaded = Config::load().unwrap(); assert_eq!(loaded.fs_permissions, FsPermissions::new(vec![PathPermission::none("./")])); Ok(()) @@ -4284,7 +4277,7 @@ mod tests { stackAllocation = true ", )?; - let mut loaded = Config::load(); + let mut loaded = Config::load().unwrap(); clear_warning(&mut loaded); assert_eq!( loaded.optimizer_details, @@ -4301,7 +4294,7 @@ mod tests { let s = loaded.to_string_pretty().unwrap(); jail.create_file("foundry.toml", &s)?; - let mut reloaded = Config::load(); + let mut reloaded = Config::load().unwrap(); clear_warning(&mut reloaded); assert_eq!(loaded, reloaded); @@ -4324,7 +4317,7 @@ mod tests { timeout = 10000 ", )?; - let mut loaded = Config::load(); + let mut loaded = Config::load().unwrap(); clear_warning(&mut loaded); assert_eq!( loaded.model_checker, @@ -4351,7 +4344,7 @@ mod tests { let s = loaded.to_string_pretty().unwrap(); jail.create_file("foundry.toml", &s)?; - let mut reloaded = Config::load(); + let mut reloaded = Config::load().unwrap(); clear_warning(&mut reloaded); assert_eq!(loaded, reloaded); @@ -4374,7 +4367,7 @@ mod tests { timeout = 10000 ", )?; - let loaded = Config::load().sanitized(); + let loaded = Config::load().unwrap().sanitized(); // NOTE(onbjerg): We have to canonicalize the path here using dunce because figment will // canonicalize the jail path using the standard library. The standard library *always* @@ -4426,7 +4419,7 @@ mod tests { bracket_spacing = true ", )?; - let loaded = Config::load().sanitized(); + let loaded = Config::load().unwrap().sanitized(); assert_eq!( loaded.fmt, FormatterConfig { @@ -4453,7 +4446,7 @@ mod tests { ", )?; - let loaded = Config::load().sanitized(); + let loaded = Config::load().unwrap().sanitized(); assert_eq!( loaded.invariant, InvariantConfig { @@ -4486,7 +4479,7 @@ mod tests { jail.set_env("FOUNDRY_FUZZ_DICTIONARY_WEIGHT", "99"); jail.set_env("FOUNDRY_INVARIANT_DEPTH", "5"); - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.fmt.line_length, 95); assert_eq!(config.fuzz.dictionary.dictionary_weight, 99); assert_eq!(config.invariant.depth, 5); @@ -4531,7 +4524,7 @@ mod tests { out = 'my-out' ", )?; - let loaded = Config::load().sanitized(); + let loaded = Config::load().unwrap().sanitized(); assert_eq!(loaded.src.file_name().unwrap(), "my-src"); assert_eq!(loaded.out.file_name().unwrap(), "my-out"); assert_eq!( @@ -4556,11 +4549,11 @@ mod tests { ", )?; jail.set_env("ETHERSCAN_API_KEY", ""); - let loaded = Config::load().sanitized(); + let loaded = Config::load().unwrap().sanitized(); assert!(loaded.etherscan_api_key.is_none()); jail.set_env("ETHERSCAN_API_KEY", "DUMMY"); - let loaded = Config::load().sanitized(); + let loaded = Config::load().unwrap().sanitized(); assert_eq!(loaded.etherscan_api_key, Some("DUMMY".into())); Ok(()) @@ -4582,7 +4575,7 @@ mod tests { let figment = Config::figment_with_root(jail.directory()) .merge(("etherscan_api_key", "USER_KEY")); - let loaded = Config::from_provider(figment); + let loaded = Config::from_provider(figment).unwrap(); assert_eq!(loaded.etherscan_api_key, Some("USER_KEY".into())); Ok(()) @@ -4600,7 +4593,7 @@ mod tests { ", )?; - let loaded = Config::load().sanitized(); + let loaded = Config::load().unwrap().sanitized(); assert_eq!(loaded.evm_version, EvmVersion::London); Ok(()) }); @@ -4656,7 +4649,6 @@ mod tests { } let _figment: Figment = From::from(&MyArgs::default()); - let _config: Config = From::from(&MyArgs::default()); #[derive(Default)] struct Outer { @@ -4667,7 +4659,6 @@ mod tests { impl_figment_convert!(Outer, start, other, another); let _figment: Figment = From::from(&Outer::default()); - let _config: Config = From::from(&Outer::default()); } #[test] @@ -4760,7 +4751,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.ignored_error_codes, vec![ @@ -4785,7 +4776,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.ignored_file_paths, vec![Path::new("something").to_path_buf()]); Ok(()) @@ -4803,7 +4794,7 @@ mod tests { ", )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!(config.optimizer_details, Some(OptimizerDetails::default())); Ok(()) @@ -4822,7 +4813,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.labels, AddressHashMap::from_iter(vec![ @@ -4854,7 +4845,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.vyper, VyperConfig { @@ -4884,7 +4875,7 @@ mod tests { "#, )?; - let config = Config::load(); + let config = Config::load().unwrap(); assert_eq!( config.soldeer, diff --git a/crates/config/src/macros.rs b/crates/config/src/macros.rs index b9261f03453ac..cb5dc9771abc9 100644 --- a/crates/config/src/macros.rs +++ b/crates/config/src/macros.rs @@ -40,7 +40,6 @@ /// } /// /// let figment: Figment = From::from(&MyArgs::default()); -/// let config: Config = From::from(&MyArgs::default()); /// /// // Use `impl_figment` on a type that has several nested `Provider` as fields but is _not_ a `Provider` itself /// @@ -53,23 +52,13 @@ /// impl_figment_convert!(Outer, start, second, third); /// /// let figment: Figment = From::from(&Outer::default()); -/// let config: Config = From::from(&Outer::default()); /// ``` #[macro_export] macro_rules! impl_figment_convert { ($name:ty) => { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { - let root = args.root.clone() - .unwrap_or_else(|| $crate::find_project_root(None)); - $crate::Config::figment_with_root(&root).merge(args) - } - } - - impl<'a> From<&'a $name> for $crate::Config { - fn from(args: &'a $name) -> Self { - let figment: $crate::figment::Figment = args.into(); - $crate::Config::from_provider(figment).sanitized() + $crate::Config::figment_with_root_opt(args.root.as_deref()).merge(args) } } }; @@ -83,13 +72,6 @@ macro_rules! impl_figment_convert { figment } } - - impl<'a> From<&'a $name> for $crate::Config { - fn from(args: &'a $name) -> Self { - let figment: $crate::figment::Figment = args.into(); - $crate::Config::from_provider(figment).sanitized() - } - } }; ($name:ty, self, $start:ident $(, $more:ident)*) => { impl<'a> From<&'a $name> for $crate::figment::Figment { @@ -102,13 +84,6 @@ macro_rules! impl_figment_convert { figment } } - - impl<'a> From<&'a $name> for $crate::Config { - fn from(args: &'a $name) -> Self { - let figment: $crate::figment::Figment = args.into(); - $crate::Config::from_provider(figment).sanitized() - } - } }; } @@ -173,13 +148,6 @@ macro_rules! merge_impl_figment_convert { figment } } - - impl<'a> From<&'a $name> for $crate::Config { - fn from(args: &'a $name) -> Self { - let figment: $crate::figment::Figment = args.into(); - $crate::Config::from_provider(figment).sanitized() - } - } }; } @@ -193,18 +161,13 @@ macro_rules! impl_figment_convert_cast { ($name:ty) => { impl<'a> From<&'a $name> for $crate::figment::Figment { fn from(args: &'a $name) -> Self { - $crate::Config::with_root(&$crate::find_project_root(None)) + let root = + $crate::find_project_root(None).expect("could not determine project root"); + $crate::Config::with_root(&root) .to_figment($crate::FigmentProviders::Cast) .merge(args) } } - - impl<'a> From<&'a $name> for $crate::Config { - fn from(args: &'a $name) -> Self { - let figment: $crate::figment::Figment = args.into(); - $crate::Config::from_provider(figment).sanitized() - } - } }; } diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 1d8a7b16368cb..385a2dc66860f 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -238,7 +238,8 @@ impl RemappingsProvider<'_> { }) .flat_map(|lib: PathBuf| { // load config, of the nested lib if it exists - let config = Config::load_with_root(&lib).sanitized(); + let Ok(config) = Config::load_with_root(&lib) else { return vec![] }; + let config = config.sanitized(); // if the configured _src_ directory is set to something that // [Remapping::find_many()] doesn't classify as a src directory (src, contracts, diff --git a/crates/config/src/utils.rs b/crates/config/src/utils.rs index 43b9b746899f7..94f4823dc7cb5 100644 --- a/crates/config/src/utils.rs +++ b/crates/config/src/utils.rs @@ -15,23 +15,20 @@ use std::{ str::FromStr, }; -/// Loads the config for the current project workspace -pub fn load_config() -> Config { +// TODO: Why do these exist separately from `Config::load`? + +/// Loads the config for the current project workspace. +pub fn load_config() -> eyre::Result { load_config_with_root(None) } /// Loads the config for the current project workspace or the provided root path. -/// -/// # Panics -/// -/// Panics if the project root cannot be found. See [`find_project_root`]. -#[track_caller] -pub fn load_config_with_root(root: Option<&Path>) -> Config { +pub fn load_config_with_root(root: Option<&Path>) -> eyre::Result { let root = match root { Some(root) => root, - None => &find_project_root(None), + None => &find_project_root(None)?, }; - Config::load_with_root(root).sanitized() + Ok(Config::load_with_root(root)?.sanitized()) } /// Returns the path of the top-level directory of the working git tree. @@ -59,20 +56,10 @@ pub fn find_git_root(relative_to: &Path) -> io::Result> { /// /// Returns `repo` or `cwd` if no `foundry.toml` is found in the tree. /// -/// # Panics -/// -/// Panics if: +/// Returns an error if: /// - `cwd` is `Some` and is not a valid directory; /// - `cwd` is `None` and the [`std::env::current_dir`] call fails. -#[track_caller] -pub fn find_project_root(cwd: Option<&Path>) -> PathBuf { - try_find_project_root(cwd).expect("Could not find project root") -} - -/// Returns the root path to set for the project root. -/// -/// Same as [`find_project_root`], but returns an error instead of panicking. -pub fn try_find_project_root(cwd: Option<&Path>) -> io::Result { +pub fn find_project_root(cwd: Option<&Path>) -> io::Result { let cwd = match cwd { Some(path) => path, None => &std::env::current_dir()?, diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index c8763d08c024a..2460f4ec518f6 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -106,7 +106,7 @@ impl BindArgs { let _ = ProjectCompiler::new().compile(&project)?; } - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; let artifacts = config.out; let bindings_root = self.bindings.clone().unwrap_or_else(|| artifacts.join("bindings")); diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index 593380297c3eb..8b0fba88e333d 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -65,7 +65,7 @@ impl BindJsonArgs { /// After that we'll still have enough information for bindings but compilation should succeed /// in most of the cases. fn preprocess(self) -> Result { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; let project = config.create_project(false, true)?; let target_path = config.root.join(self.out.as_ref().unwrap_or(&config.bind_json.out)); diff --git a/crates/forge/bin/cmd/build.rs b/crates/forge/bin/cmd/build.rs index 6a627d1502124..133e2f9ad70ca 100644 --- a/crates/forge/bin/cmd/build.rs +++ b/crates/forge/bin/cmd/build.rs @@ -28,16 +28,6 @@ foundry_config::merge_impl_figment_convert!(BuildArgs, build); /// In order to override them in the foundry `Config` they need to be merged into an existing /// `figment::Provider`, like `foundry_config::Config` is. /// -/// # Example -/// -/// ``` -/// use foundry_cli::cmd::forge::build::BuildArgs; -/// use foundry_config::Config; -/// # fn t(args: BuildArgs) { -/// let config = Config::from(&args); -/// # } -/// ``` -/// /// `BuildArgs` implements `figment::Provider` in which all config related fields are serialized and /// then merged into an existing `Config`, effectively overwriting them. /// @@ -77,11 +67,11 @@ pub struct BuildArgs { impl BuildArgs { pub fn run(self) -> Result { - let mut config = self.try_load_config_emit_warnings()?; + let mut config = self.load_config()?; if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings - config = self.load_config(); + config = self.load_config()?; } let project = config.project()?; @@ -136,9 +126,9 @@ impl BuildArgs { // Use the path arguments or if none where provided the `src`, `test` and `script` // directories as well as the `foundry.toml` configuration file. self.watch.watchexec_config(|| { - let config = Config::from(self); + let config = self.load_config()?; let foundry_toml: PathBuf = config.root.join(Config::FILE_NAME); - [config.src, config.test, config.script, foundry_toml] + Ok([config.src, config.test, config.script, foundry_toml]) }) } } diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 7f998a6d85ecd..b2dfebcd6b74a 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -7,7 +7,10 @@ use foundry_block_explorers::{ errors::EtherscanError, Client, }; -use foundry_cli::{opts::EtherscanOpts, utils::Git}; +use foundry_cli::{ + opts::EtherscanOpts, + utils::{Git, LoadConfig}, +}; use foundry_common::{compile::ProjectCompiler, fs}; use foundry_compilers::{ artifacts::{ @@ -96,7 +99,7 @@ impl CloneArgs { self; // step 0. get the chain and api key from the config - let config = Config::from(ðerscan); + let config = etherscan.load_config()?; let chain = config.chain.unwrap_or_default(); let etherscan_api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); let client = Client::new(chain, etherscan_api_key.clone())?; @@ -547,7 +550,7 @@ fn dump_sources(meta: &Metadata, root: &PathBuf, no_reorg: bool) -> Result Result { - let mut config = Config::load_with_root(root).sanitized(); + let mut config = Config::load_with_root(root)?.sanitized(); config.extra_output.push(ContractOutputSelection::StorageLayout); let project = config.project()?; let compiler = ProjectCompiler::new(); diff --git a/crates/forge/bin/cmd/compiler.rs b/crates/forge/bin/cmd/compiler.rs index f5d62b6714195..d80112311112a 100644 --- a/crates/forge/bin/cmd/compiler.rs +++ b/crates/forge/bin/cmd/compiler.rs @@ -59,7 +59,7 @@ impl ResolveArgs { let Self { root, skip } = self; let root = root.unwrap_or_else(|| PathBuf::from(".")); - let config = Config::load_with_root(&root); + let config = Config::load_with_root(&root)?; let project = config.project()?; let graph = Graph::resolve(&project.paths)?; diff --git a/crates/forge/bin/cmd/config.rs b/crates/forge/bin/cmd/config.rs index d1de49d5255b9..a85e2391346da 100644 --- a/crates/forge/bin/cmd/config.rs +++ b/crates/forge/bin/cmd/config.rs @@ -36,7 +36,7 @@ impl ConfigArgs { } let config = self - .try_load_config_unsanitized_emit_warnings()? + .load_config_unsanitized()? .normalized_optimizer_settings() // we explicitly normalize the version, so mimic the behavior when invoking solc .normalized_evm_version(); diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 909e8a16bd438..cf059265e9023 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -82,12 +82,12 @@ pub struct CoverageArgs { impl CoverageArgs { pub async fn run(self) -> Result<()> { - let (mut config, evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; + let (mut config, evm_opts) = self.load_config_and_evm_opts()?; // install missing dependencies if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings - config = self.load_config(); + config = self.load_config()?; } // Set fuzz seed so coverage reports are deterministic diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 9886e6bafdf18..5781ee7d2d0a9 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -103,12 +103,12 @@ pub struct CreateArgs { impl CreateArgs { /// Executes the command to create a contract pub async fn run(mut self) -> Result<()> { - let mut config = self.try_load_config_emit_warnings()?; + let mut config = self.load_config()?; // Install missing dependencies. if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings - config = self.load_config(); + config = self.load_config()?; } // Find Project & Compile @@ -248,7 +248,7 @@ impl CreateArgs { // Check config for Etherscan API Keys to avoid preflight check failing if no // ETHERSCAN_API_KEY value set. - let config = verify.load_config_emit_warnings(); + let config = verify.load_config()?; verify.etherscan.key = config.get_etherscan_config_with_chain(Some(chain.into()))?.map(|c| c.key); diff --git a/crates/forge/bin/cmd/doc/mod.rs b/crates/forge/bin/cmd/doc/mod.rs index 2fa996a04fe2f..73b78618cbb0e 100644 --- a/crates/forge/bin/cmd/doc/mod.rs +++ b/crates/forge/bin/cmd/doc/mod.rs @@ -6,7 +6,7 @@ use forge_doc::{ }; use foundry_cli::opts::GH_REPO_PREFIX_REGEX; use foundry_common::compile::ProjectCompiler; -use foundry_config::{find_project_root, load_config_with_root, Config}; +use foundry_config::{load_config_with_root, Config}; use std::{path::PathBuf, process::Command}; mod server; @@ -139,10 +139,6 @@ impl DocArgs { } pub fn config(&self) -> Result { - let root = match &self.root { - Some(root) => root, - None => &find_project_root(None), - }; - Ok(load_config_with_root(Some(root))) + load_config_with_root(self.root.as_deref()) } } diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs index af329887753f9..fe05d027a0f5d 100644 --- a/crates/forge/bin/cmd/eip712.rs +++ b/crates/forge/bin/cmd/eip712.rs @@ -24,7 +24,7 @@ pub struct Eip712Args { impl Eip712Args { pub fn run(self) -> Result<()> { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; let mut project = config.create_project(false, true)?; let target_path = dunce::canonicalize(self.target_path)?; project.update_output_selection(|selection| { diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 3a3fb905e5608..5a5e0cdafa980 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -40,7 +40,7 @@ impl FlattenArgs { // flatten is a subset of `BuildArgs` so we can reuse that to get the config let build = BuildOpts { project_paths, ..Default::default() }; - let config = build.try_load_config_emit_warnings()?; + let config = build.load_config()?; let project = config.create_project(false, true)?; let target_path = dunce::canonicalize(target_path)?; diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 137e139e6b32f..206eb7b960153 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -45,7 +45,7 @@ impl_figment_convert_basic!(FmtArgs); impl FmtArgs { pub fn run(self) -> Result<()> { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; // Expand ignore globs and canonicalize from the get go let ignored = expand_globs(&config.root, config.fmt.ignore.iter())? diff --git a/crates/forge/bin/cmd/geiger.rs b/crates/forge/bin/cmd/geiger.rs index ace3bbe1af117..57dac0eb26c65 100644 --- a/crates/forge/bin/cmd/geiger.rs +++ b/crates/forge/bin/cmd/geiger.rs @@ -91,7 +91,7 @@ impl GeigerArgs { sh_warn!("`--full` is deprecated as reports are not generated anymore\n")?; } - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; let sources = self.sources(&config).wrap_err("Failed to resolve files")?; if config.ffi { diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index f1a2166352655..6338dbbec1dcb 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -130,7 +130,7 @@ impl InitArgs { // write foundry.toml, if it doesn't exist already let dest = root.join(Config::FILE_NAME); - let mut config = Config::load_with_root(&root); + let mut config = Config::load_with_root(&root)?; if !dest.exists() { fs::write(dest, config.clone().into_basic().to_string_pretty()?)?; } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 3543caeea51b8..55eb4f5d4b6be 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -58,7 +58,7 @@ impl_figment_convert_basic!(InstallArgs); impl InstallArgs { pub fn run(self) -> Result<()> { - let mut config = self.try_load_config_emit_warnings()?; + let mut config = self.load_config()?; self.opts.install(&mut config, self.dependencies) } } diff --git a/crates/forge/bin/cmd/mod.rs b/crates/forge/bin/cmd/mod.rs index 6885819f81c63..d633564f69cf4 100644 --- a/crates/forge/bin/cmd/mod.rs +++ b/crates/forge/bin/cmd/mod.rs @@ -1,43 +1,9 @@ -//! Subcommands for forge +//! `forge` subcommands. //! //! All subcommands should respect the `foundry_config::Config`. //! If a subcommand accepts values that are supported by the `Config`, then the subcommand should //! implement `figment::Provider` which allows the subcommand to override the config's defaults, see //! [`foundry_config::Config`]. -//! -//! See [`BuildArgs`] for a reference implementation. -//! And [`DebugArgs`] for how to merge `Providers`. -//! -//! # Example -//! -//! create a `clap` subcommand into a `figment::Provider` and integrate it in the -//! `foundry_config::Config`: -//! -//! ``` -//! use clap::Parser; -//! use forge::executor::opts::EvmOpts; -//! use foundry_cli::cmd::forge::build::BuildArgs; -//! use foundry_common::evm::EvmArgs; -//! use foundry_config::{figment::Figment, *}; -//! -//! // A new clap subcommand that accepts both `EvmArgs` and `BuildArgs` -//! #[derive(Clone, Debug, Parser)] -//! pub struct MyArgs { -//! #[command(flatten)] -//! evm: EvmArgs, -//! #[command(flatten)] -//! build: BuildArgs, -//! } -//! -//! // add `Figment` and `Config` converters -//! foundry_config::impl_figment_convert!(MyArgs, opts, evm_opts); -//! let args = MyArgs::parse_from(["build"]); -//! -//! let figment: Figment = From::from(&args); -//! let evm_opts = figment.extract::().unwrap(); -//! -//! let config: Config = From::from(&args); -//! ``` pub mod bind; pub mod bind_json; diff --git a/crates/forge/bin/cmd/remappings.rs b/crates/forge/bin/cmd/remappings.rs index dfa667ccc9edd..c475e8199588e 100644 --- a/crates/forge/bin/cmd/remappings.rs +++ b/crates/forge/bin/cmd/remappings.rs @@ -21,7 +21,7 @@ impl_figment_convert_basic!(RemappingArgs); impl RemappingArgs { pub fn run(self) -> Result<()> { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; if self.pretty { let mut groups = BTreeMap::<_, Vec<_>>::new(); diff --git a/crates/forge/bin/cmd/remove.rs b/crates/forge/bin/cmd/remove.rs index da2f8b251119a..2033ad3a7c4ad 100644 --- a/crates/forge/bin/cmd/remove.rs +++ b/crates/forge/bin/cmd/remove.rs @@ -29,7 +29,7 @@ impl_figment_convert_basic!(RemoveArgs); impl RemoveArgs { pub fn run(self) -> Result<()> { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; let (root, paths) = super::update::dependencies_paths(&self.dependencies, &config)?; let git_modules = root.join(".git/modules"); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index adc2c8dcae133..6c854150a4017 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -268,7 +268,7 @@ impl TestArgs { /// Returns the test results for all matching tests. pub async fn execute_tests(mut self) -> Result { // Merge all configs. - let (mut config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; + let (mut config, mut evm_opts) = self.load_config_and_evm_opts()?; // Explicitly enable isolation for gas reports for more correct gas accounting. if self.gas_report { @@ -282,7 +282,7 @@ impl TestArgs { // Install missing dependencies. if install::install_missing_dependencies(&mut config) && config.auto_detect_remappings { // need to re-configure here to also catch additional remappings - config = self.load_config(); + config = self.load_config()?; } // Set up the project. @@ -803,8 +803,8 @@ impl TestArgs { /// bootstrap a new [`watchexe::Watchexec`] loop. pub(crate) fn watchexec_config(&self) -> Result { self.watch.watchexec_config(|| { - let config = Config::from(self); - [config.src, config.test] + let config = self.load_config()?; + Ok([config.src, config.test]) }) } } diff --git a/crates/forge/bin/cmd/tree.rs b/crates/forge/bin/cmd/tree.rs index fe278e98cbdc1..b97d7c8d98654 100644 --- a/crates/forge/bin/cmd/tree.rs +++ b/crates/forge/bin/cmd/tree.rs @@ -27,7 +27,7 @@ foundry_config::impl_figment_convert!(TreeArgs, project_paths); impl TreeArgs { pub fn run(self) -> Result<()> { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; let graph = Graph::::resolve(&config.project_paths())?; let opts = TreeOptions { charset: self.charset, no_dedupe: self.no_dedupe }; graph.print_with_options(opts); diff --git a/crates/forge/bin/cmd/update.rs b/crates/forge/bin/cmd/update.rs index c61b03d7a089c..5e965c34a9999 100644 --- a/crates/forge/bin/cmd/update.rs +++ b/crates/forge/bin/cmd/update.rs @@ -32,7 +32,7 @@ impl_figment_convert_basic!(UpdateArgs); impl UpdateArgs { pub fn run(self) -> Result<()> { - let config = self.try_load_config_emit_warnings()?; + let config = self.load_config()?; let (root, paths) = dependencies_paths(&self.dependencies, &config)?; // fetch the latest changes for each submodule (recursively if flag is set) let git = Git::new(&root); diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 04aa7c722fd0b..a7b0a1a025a70 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -73,7 +73,7 @@ impl WatchArgs { /// otherwise the path the closure returns will be used. pub fn watchexec_config, P: Into>( &self, - default_paths: impl FnOnce() -> PS, + default_paths: impl FnOnce() -> Result, ) -> Result { self.watchexec_config_generic(default_paths, None) } @@ -84,7 +84,7 @@ impl WatchArgs { /// otherwise the path the closure returns will be used. pub fn watchexec_config_with_override, P: Into>( &self, - default_paths: impl FnOnce() -> PS, + default_paths: impl FnOnce() -> Result, spawn_hook: impl Fn(&[Event], &mut TokioCommand) + Send + Sync + 'static, ) -> Result { self.watchexec_config_generic(default_paths, Some(Arc::new(spawn_hook))) @@ -92,13 +92,13 @@ impl WatchArgs { fn watchexec_config_generic, P: Into>( &self, - default_paths: impl FnOnce() -> PS, + default_paths: impl FnOnce() -> Result, spawn_hook: Option, ) -> Result { let mut paths = self.watch.as_deref().unwrap_or_default(); let storage: Vec<_>; if paths.is_empty() { - storage = default_paths().into_iter().map(Into::into).filter(|p| p.exists()).collect(); + storage = default_paths()?.into_iter().map(Into::into).filter(|p| p.exists()).collect(); paths = &storage; } self.watchexec_config_inner(paths, spawn_hook) @@ -262,7 +262,7 @@ pub async fn watch_gas_snapshot(args: GasSnapshotArgs) -> Result<()> { /// Executes a [`Watchexec`] that listens for changes in the project's src dir and reruns `forge /// test` pub async fn watch_test(args: TestArgs) -> Result<()> { - let config: Config = Config::from(&args.build); + let config: Config = args.build.load_config()?; let filter = args.filter(&config); // Marker to check whether to override the command. let no_reconfigure = filter.args().test_pattern.is_some() || @@ -273,7 +273,7 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { let last_test_files = Mutex::new(HashSet::::default()); let project_root = config.root.to_string_lossy().into_owned(); let config = args.watch.watchexec_config_with_override( - || [&config.test, &config.src], + || Ok([&config.test, &config.src]), move |events, command| { let mut changed_sol_test_files: HashSet<_> = events .iter() @@ -314,27 +314,24 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { } }, )?; - run(config).await?; - - Ok(()) + run(config).await } pub async fn watch_coverage(args: CoverageArgs) -> Result<()> { - let config = args.load_config(); - let config = args.watch().watchexec_config(|| [config.test, config.src])?; - - run(config).await?; - - Ok(()) + let config = args.watch().watchexec_config(|| { + let config = args.load_config()?; + Ok([config.test, config.src]) + })?; + run(config).await } /// Executes a [`Watchexec`] that listens for changes in the project's sources directory pub async fn watch_doc(args: DocArgs) -> Result<()> { - let src_path = args.config()?.src; - let config = args.watch.watchexec_config(|| [src_path])?; - run(config).await?; - - Ok(()) + let config = args.watch.watchexec_config(|| { + let config = args.config()?; + Ok([config.src]) + })?; + run(config).await } /// Converts a list of arguments to a `watchexec::Command`. diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index 87a108c836b76..a9c341f3bfd70 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -92,7 +92,7 @@ fn run() -> Result<()> { Ok(()) } ForgeSubcommand::Clean { root } => { - let config = utils::load_config_with_root(root.as_deref()); + let config = utils::load_config_with_root(root.as_deref())?; let project = config.project()?; config.cleanup(&project)?; Ok(()) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 882e92681e1b3..7e76a9cd76074 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -171,7 +171,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { // tests config gets printed to std out forgetest!(can_show_config, |prj, cmd| { let expected = - Config::load_with_root(prj.root()).to_string_pretty().unwrap().trim().to_string(); + Config::load_with_root(prj.root()).unwrap().to_string_pretty().unwrap().trim().to_string(); let output = cmd.arg("config").assert_success().get_output().stdout_lossy().trim().to_string(); assert_eq!(expected, output); }); @@ -185,7 +185,7 @@ forgetest_init!(can_override_config, |prj, cmd| { let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(foundry_toml.exists()); - let profile = Config::load_with_root(prj.root()); + let profile = Config::load_with_root(prj.root()).unwrap(); // ensure that the auto-generated internal remapping for forge-std's ds-test exists assert_eq!(profile.remappings.len(), 1); assert_eq!("forge-std/=lib/forge-std/src/", profile.remappings[0].to_string()); @@ -205,7 +205,7 @@ forgetest_init!(can_override_config, |prj, cmd| { // remappings work let remappings_txt = prj.create_file("remappings.txt", "ds-test/=lib/forge-std/lib/ds-test/from-file/"); - let config = forge_utils::load_config_with_root(Some(prj.root())); + let config = forge_utils::load_config_with_root(Some(prj.root())).unwrap(); assert_eq!( format!( "ds-test/={}/", @@ -251,7 +251,7 @@ forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { let foundry_toml = prj.root().join(Config::FILE_NAME); assert!(foundry_toml.exists()); - let profile = Config::load_with_root(prj.root()); + let profile = Config::load_with_root(prj.root()).unwrap(); // ensure that the auto-generated internal remapping for forge-std's ds-test exists assert_eq!(profile.remappings.len(), 1); let r = &profile.remappings[0]; @@ -275,13 +275,13 @@ Installing solmate in [..] (url: Some("https://github.com/transmissions11/solmat }; install(&mut cmd, "transmissions11/solmate"); - let profile = Config::load_with_root(prj.root()); + let profile = Config::load_with_root(prj.root()).unwrap(); // remappings work let remappings_txt = prj.create_file( "remappings.txt", "solmate/=lib/solmate/src/\nsolmate-contracts/=lib/solmate/src/", ); - let config = forge_utils::load_config_with_root(Some(prj.root())); + let config = forge_utils::load_config_with_root(Some(prj.root())).unwrap(); // trailing slashes are removed on windows `to_slash_lossy` let path = prj.root().join("lib/solmate/src/").to_slash_lossy().into_owned(); #[cfg(windows)] @@ -316,7 +316,7 @@ forgetest_init!(can_detect_config_vals, |prj, _cmd| { assert!(!config.auto_detect_solc); assert_eq!(config.eth_rpc_url, Some(url.to_string())); - let mut config = Config::load_with_root(prj.root()); + let mut config = Config::load_with_root(prj.root()).unwrap(); config.eth_rpc_url = Some("http://127.0.0.1:8545".to_string()); config.auto_detect_solc = false; // write to `foundry.toml` @@ -868,7 +868,7 @@ contract MyScript is BaseScript { let nested = prj.paths().libraries[0].join("another-dep"); pretty_err(&nested, fs::create_dir_all(&nested)); - let mut lib_config = Config::load_with_root(&nested); + let mut lib_config = Config::load_with_root(&nested).unwrap(); lib_config.remappings = vec![ Remapping::from_str("test/=test/").unwrap().into(), Remapping::from_str("script/=script/").unwrap().into(), diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 509e725a7195a..4aa23dae6545f 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -222,7 +222,7 @@ impl ScriptArgs { pub async fn preprocess(self) -> Result { let script_wallets = Wallets::new(self.wallets.get_multi_wallet().await?, self.evm.sender); - let (config, mut evm_opts) = self.load_config_and_evm_opts_emit_warnings()?; + let (config, mut evm_opts) = self.load_config_and_evm_opts()?; if let Some(sender) = self.maybe_load_private_key()? { evm_opts.sender = sender; @@ -688,7 +688,7 @@ mod tests { "--etherscan-api-key", "goerli", ]); - let config = args.load_config(); + let config = args.load_config().unwrap(); assert_eq!(config.etherscan_api_key, Some("goerli".to_string())); } @@ -753,7 +753,7 @@ mod tests { root.as_os_str().to_str().unwrap(), ]); - let config = args.load_config(); + let config = args.load_config().unwrap(); let mumbai = config.get_etherscan_api_key(Some(NamedChain::PolygonMumbai.into())); assert_eq!(mumbai, Some("https://etherscan-mumbai.com/".to_string())); } diff --git a/crates/verify/src/bytecode.rs b/crates/verify/src/bytecode.rs index 01fcb488631ff..3a1664f16367b 100644 --- a/crates/verify/src/bytecode.rs +++ b/crates/verify/src/bytecode.rs @@ -121,7 +121,7 @@ impl VerifyBytecodeArgs { /// bytecode. pub async fn run(mut self) -> Result<()> { // Setup - let config = self.load_config_emit_warnings(); + let config = self.load_config()?; let provider = utils::get_provider(&config)?; // If chain is not set, we try to get it from the RPC. diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 7c6da1e1cb33f..0602055985a14 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -147,7 +147,7 @@ impl VerificationProvider for EtherscanVerificationProvider { /// Executes the command to check verification status on Etherscan async fn check(&self, args: VerifyCheckArgs) -> Result<()> { - let config = args.try_load_config_emit_warnings()?; + let config = args.load_config()?; let etherscan = self.client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), @@ -215,7 +215,7 @@ impl EtherscanVerificationProvider { args: &VerifyArgs, context: &VerificationContext, ) -> Result<(Client, VerifyContract)> { - let config = args.try_load_config_emit_warnings()?; + let config = args.load_config()?; let etherscan = self.client( args.etherscan.chain.unwrap_or_default(), args.verifier.verifier_url.as_deref(), @@ -483,7 +483,7 @@ mod tests { root.as_os_str().to_str().unwrap(), ]); - let config = args.load_config(); + let config = args.load_config().unwrap(); let etherscan = EtherscanVerificationProvider::default(); let client = etherscan @@ -510,7 +510,7 @@ mod tests { root.as_os_str().to_str().unwrap(), ]); - let config = args.load_config(); + let config = args.load_config().unwrap(); let etherscan = EtherscanVerificationProvider::default(); let client = etherscan diff --git a/crates/verify/src/verify.rs b/crates/verify/src/verify.rs index 695a243c6afd0..e5b650c0e3630 100644 --- a/crates/verify/src/verify.rs +++ b/crates/verify/src/verify.rs @@ -187,7 +187,7 @@ impl figment::Provider for VerifyArgs { impl VerifyArgs { /// Run the verify command to submit the contract's source code for verification on etherscan pub async fn run(mut self) -> Result<()> { - let config = self.load_config_emit_warnings(); + let config = self.load_config()?; if self.guess_constructor_args && config.get_rpc_url().is_none() { eyre::bail!( @@ -262,7 +262,7 @@ impl VerifyArgs { /// Resolves [VerificationContext] object either from entered contract name or by trying to /// match bytecode located at given address. pub async fn resolve_context(&self) -> Result { - let mut config = self.load_config_emit_warnings(); + let mut config = self.load_config()?; config.libraries.extend(self.libraries.clone()); let project = config.project()?; From 1ef98bf9b4582f5b3eaa965b7693459e8b33251c Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:07:19 +0100 Subject: [PATCH 1868/1963] chore: bump version to 0.3.1 to make it easier to identify non-stable builds (#9718) * bump version number * bump lockfile --- Cargo.lock | 60 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28fab1b428fc0..6a2079b64ce10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -947,7 +947,7 @@ dependencies = [ [[package]] name = "anvil" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-chains", "alloy-consensus", @@ -1017,7 +1017,7 @@ dependencies = [ [[package]] name = "anvil-core" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "anvil-rpc" -version = "0.3.0" +version = "0.3.1" dependencies = [ "serde", "serde_json", @@ -1049,7 +1049,7 @@ dependencies = [ [[package]] name = "anvil-server" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anvil-rpc", "async-trait", @@ -2002,7 +2002,7 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cast" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-chains", "alloy-consensus", @@ -2097,7 +2097,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chisel" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3309,7 +3309,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "forge" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-chains", "alloy-consensus", @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "forge-doc" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-primitives", "derive_more", @@ -3423,7 +3423,7 @@ dependencies = [ [[package]] name = "forge-fmt" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-primitives", "ariadne", @@ -3439,7 +3439,7 @@ dependencies = [ [[package]] name = "forge-script" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-chains", "alloy-consensus", @@ -3484,7 +3484,7 @@ dependencies = [ [[package]] name = "forge-script-sequence" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-network", "alloy-primitives", @@ -3502,7 +3502,7 @@ dependencies = [ [[package]] name = "forge-sol-macro-gen" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-json-abi", "alloy-sol-macro-expander", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "forge-verify" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3579,7 +3579,7 @@ dependencies = [ [[package]] name = "foundry-cheatcodes" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3628,7 +3628,7 @@ dependencies = [ [[package]] name = "foundry-cheatcodes-spec" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-sol-types", "foundry-macros", @@ -3639,7 +3639,7 @@ dependencies = [ [[package]] name = "foundry-cli" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-chains", "alloy-dyn-abi", @@ -3678,7 +3678,7 @@ dependencies = [ [[package]] name = "foundry-common" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-consensus", "alloy-contract", @@ -3730,7 +3730,7 @@ dependencies = [ [[package]] name = "foundry-common-fmt" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3858,7 +3858,7 @@ dependencies = [ [[package]] name = "foundry-config" -version = "0.3.0" +version = "0.3.1" dependencies = [ "Inflector", "alloy-chains", @@ -3895,7 +3895,7 @@ dependencies = [ [[package]] name = "foundry-debugger" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-primitives", "crossterm", @@ -3913,7 +3913,7 @@ dependencies = [ [[package]] name = "foundry-evm" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3940,7 +3940,7 @@ dependencies = [ [[package]] name = "foundry-evm-abi" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -3953,7 +3953,7 @@ dependencies = [ [[package]] name = "foundry-evm-core" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3988,7 +3988,7 @@ dependencies = [ [[package]] name = "foundry-evm-coverage" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-primitives", "eyre", @@ -4003,7 +4003,7 @@ dependencies = [ [[package]] name = "foundry-evm-fuzz" -version = "0.3.0" +version = "0.3.1" dependencies = [ "ahash", "alloy-dyn-abi", @@ -4029,7 +4029,7 @@ dependencies = [ [[package]] name = "foundry-evm-traces" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -4081,7 +4081,7 @@ dependencies = [ [[package]] name = "foundry-linking" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-primitives", "foundry-compilers", @@ -4091,7 +4091,7 @@ dependencies = [ [[package]] name = "foundry-macros" -version = "0.3.0" +version = "0.3.1" dependencies = [ "proc-macro-error", "proc-macro2", @@ -4101,7 +4101,7 @@ dependencies = [ [[package]] name = "foundry-test-utils" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-primitives", "alloy-provider", @@ -4124,7 +4124,7 @@ dependencies = [ [[package]] name = "foundry-wallets" -version = "0.3.0" +version = "0.3.1" dependencies = [ "alloy-consensus", "alloy-dyn-abi", diff --git a/Cargo.toml b/Cargo.toml index aad4380bf53ce..4e32ea07f2d83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.3.0" +version = "0.3.1" edition = "2021" # Remember to update clippy.toml as well rust-version = "1.83" From 2ddea8743d24949b32db98853c387a1ef0c214d5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:04:31 +0200 Subject: [PATCH 1869/1963] fix(invariant): handle simple contract names in metrics table (#9724) --- crates/forge/bin/cmd/test/mod.rs | 6 +- crates/forge/bin/cmd/test/summary.rs | 125 +++++++++++++++++---------- 2 files changed, 84 insertions(+), 47 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 6c854150a4017..019e44e8c3255 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -56,7 +56,7 @@ mod summary; pub use filter::FilterArgs; use forge::{result::TestKind, traces::render_trace_arena_inner}; use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; -use summary::{print_invariant_metrics, TestSummaryReport}; +use summary::{format_invariant_metrics_table, TestSummaryReport}; // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(TestArgs, build, evm); @@ -569,7 +569,9 @@ impl TestArgs { // Display invariant metrics if invariant kind. if let TestKind::Invariant { metrics, .. } = &result.kind { - print_invariant_metrics(metrics); + if !metrics.is_empty() { + let _ = sh_println!("\n{}\n", format_invariant_metrics_table(metrics)); + } } // We only display logs at level 2 and above diff --git a/crates/forge/bin/cmd/test/summary.rs b/crates/forge/bin/cmd/test/summary.rs index eabf7bd9eaaa3..68ab3f4590b05 100644 --- a/crates/forge/bin/cmd/test/summary.rs +++ b/crates/forge/bin/cmd/test/summary.rs @@ -124,7 +124,7 @@ impl TestSummaryReport { } } -/// Helper function to print the invariant metrics. +/// Helper function to create the invariant metrics table. /// /// ╭-----------------------+----------------+-------+---------+----------╮ /// | Contract | Selector | Calls | Reverts | Discards | @@ -137,55 +137,90 @@ impl TestSummaryReport { /// |-----------------------+----------------+-------+---------+----------| /// | CounterHandler | doSomething | 7382 | 160 |4794 | /// ╰-----------------------+----------------+-------+---------+----------╯ -pub(crate) fn print_invariant_metrics(test_metrics: &HashMap) { - if !test_metrics.is_empty() { - let mut table = Table::new(); - table.apply_modifier(UTF8_ROUND_CORNERS); +pub(crate) fn format_invariant_metrics_table( + test_metrics: &HashMap, +) -> Table { + let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); + + table.set_header(vec![ + Cell::new("Contract"), + Cell::new("Selector"), + Cell::new("Calls").fg(Color::Green), + Cell::new("Reverts").fg(Color::Red), + Cell::new("Discards").fg(Color::Yellow), + ]); + + for name in test_metrics.keys().sorted() { + if let Some((contract, selector)) = + name.split_once(':').map_or(name.as_str(), |(_, contract)| contract).split_once('.') + { + let mut row = Row::new(); + row.add_cell(Cell::new(contract)); + row.add_cell(Cell::new(selector)); + + if let Some(metrics) = test_metrics.get(name) { + let calls_cell = Cell::new(metrics.calls).fg(if metrics.calls > 0 { + Color::Green + } else { + Color::White + }); - table.set_header(vec![ - Cell::new("Contract"), - Cell::new("Selector"), - Cell::new("Calls").fg(Color::Green), - Cell::new("Reverts").fg(Color::Red), - Cell::new("Discards").fg(Color::Yellow), - ]); + let reverts_cell = Cell::new(metrics.reverts).fg(if metrics.reverts > 0 { + Color::Red + } else { + Color::White + }); - for name in test_metrics.keys().sorted() { - if let Some((contract, selector)) = - name.split_once(':').and_then(|(_, contract)| contract.split_once('.')) - { - let mut row = Row::new(); - row.add_cell(Cell::new(contract)); - row.add_cell(Cell::new(selector)); - - if let Some(metrics) = test_metrics.get(name) { - let calls_cell = Cell::new(metrics.calls).fg(if metrics.calls > 0 { - Color::Green - } else { - Color::White - }); - - let reverts_cell = Cell::new(metrics.reverts).fg(if metrics.reverts > 0 { - Color::Red - } else { - Color::White - }); - - let discards_cell = Cell::new(metrics.discards).fg(if metrics.discards > 0 { - Color::Yellow - } else { - Color::White - }); - - row.add_cell(calls_cell); - row.add_cell(reverts_cell); - row.add_cell(discards_cell); - } + let discards_cell = Cell::new(metrics.discards).fg(if metrics.discards > 0 { + Color::Yellow + } else { + Color::White + }); - table.add_row(row); + row.add_cell(calls_cell); + row.add_cell(reverts_cell); + row.add_cell(discards_cell); } + + table.add_row(row); } + } + table +} - let _ = sh_println!("\n{table}\n"); +#[cfg(test)] +mod tests { + use crate::cmd::test::summary::format_invariant_metrics_table; + use foundry_evm::executors::invariant::InvariantMetrics; + use std::collections::HashMap; + + #[test] + fn test_invariant_metrics_table() { + let mut test_metrics = HashMap::new(); + test_metrics.insert( + "SystemConfig.setGasLimit".to_string(), + InvariantMetrics { calls: 10, reverts: 1, discards: 1 }, + ); + test_metrics.insert( + "src/universal/Proxy.sol:Proxy.changeAdmin".to_string(), + InvariantMetrics { calls: 20, reverts: 2, discards: 2 }, + ); + let table = format_invariant_metrics_table(&test_metrics); + assert_eq!(table.row_count(), 2); + + let mut first_row_content = table.row(0).unwrap().cell_iter(); + assert_eq!(first_row_content.next().unwrap().content(), "SystemConfig"); + assert_eq!(first_row_content.next().unwrap().content(), "setGasLimit"); + assert_eq!(first_row_content.next().unwrap().content(), "10"); + assert_eq!(first_row_content.next().unwrap().content(), "1"); + assert_eq!(first_row_content.next().unwrap().content(), "1"); + + let mut second_row_content = table.row(1).unwrap().cell_iter(); + assert_eq!(second_row_content.next().unwrap().content(), "Proxy"); + assert_eq!(second_row_content.next().unwrap().content(), "changeAdmin"); + assert_eq!(second_row_content.next().unwrap().content(), "20"); + assert_eq!(second_row_content.next().unwrap().content(), "2"); + assert_eq!(second_row_content.next().unwrap().content(), "2"); } } From 62147c8425fb5808c5e61037c7f38a2363c223eb Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:29:15 +0100 Subject: [PATCH 1870/1963] chore: display warning to user if running `nightly` version (#9683) * use shared compile time version builder * add warning message on nightly builds * display warning on nightly builds * derive nightly build from tag name * no need to pass IS_NIGHTLY in, derive from tag name * update warning message * fix rustfmt * fix clippy * clean up, default to always use `-dev` if not on tag * provide way for users to mute the warning by setting a FOUNDRY_DISABLE_NIGHTLY_WARNING environment variable * fix fmt * add profile to version * fix clippy * fix fmt * remove redundant build_timestamp as it is unused * unify build scripts, update cheatcodes build script, fix vm.getFoundryVersion() cheatcode * fix clippy * build timestamp not needed anymore, move to use single build script in foundry_common and export from there * clean up * add timestamp due to users / documentation relying on it * use verbose message format for cli --version, use SemVer compatible unix timestamp for cheatcode, fix nits * make IS_NIGHTLY_VERSION conditional * use semver for cheatcode * fix test * fix value * forge fmt * nits, update getFoundryVersion cheatcode docs * fix incorrect version passed to forge cli, add unix timestamp to human readable --version * add tests, add short version / long version, address feedback * prefer build_timestamp for short version too * fixes, add anvil tests for parsing * add back unix timestamp in full version * fix semver test --- .github/workflows/release.yml | 4 +- Cargo.lock | 102 +++++++++--------- crates/anvil/Cargo.toml | 7 -- crates/anvil/build.rs | 3 - crates/anvil/src/anvil.rs | 13 ++- crates/anvil/src/config.rs | 11 +- crates/cast/Cargo.toml | 7 -- crates/cast/bin/args.rs | 17 ++- crates/cast/build.rs | 3 - crates/cast/tests/cli/main.rs | 17 +++ crates/cheatcodes/Cargo.toml | 8 -- crates/cheatcodes/assets/cheatcodes.json | 2 +- crates/cheatcodes/build.rs | 3 - crates/cheatcodes/spec/src/vm.rs | 6 +- crates/cheatcodes/src/test.rs | 12 +-- crates/chisel/Cargo.toml | 7 -- crates/chisel/bin/main.rs | 17 ++- crates/chisel/build.rs | 3 - crates/cli/src/opts/global.rs | 13 ++- crates/common/Cargo.toml | 8 ++ crates/common/build.rs | 87 +++++++++++++++ crates/common/src/lib.rs | 1 + crates/common/src/version.rs | 27 +++++ crates/forge/Cargo.toml | 7 -- crates/forge/bin/opts.rs | 13 +-- crates/forge/build.rs | 3 - crates/forge/tests/cli/main.rs | 1 + crates/forge/tests/cli/version.rs | 18 ++++ .../default/cheats/GetFoundryVersion.t.sol | 33 ++++-- 29 files changed, 284 insertions(+), 169 deletions(-) delete mode 100644 crates/anvil/build.rs delete mode 100644 crates/cast/build.rs delete mode 100644 crates/cheatcodes/build.rs delete mode 100644 crates/chisel/build.rs create mode 100644 crates/common/build.rs create mode 100644 crates/common/src/version.rs delete mode 100644 crates/forge/build.rs create mode 100644 crates/forge/tests/cli/version.rs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f4ed60e96450..710c6d4ac7cda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,6 +74,8 @@ jobs: attestations: write name: ${{ matrix.target }} (${{ matrix.runner }}) runs-on: ${{ matrix.runner }} + env: + TAG_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} timeout-minutes: 240 needs: prepare strategy: @@ -272,7 +274,7 @@ jobs: issue: name: Open an issue runs-on: ubuntu-latest - needs: [prepare, release-docker, release, cleanup] + needs: [ prepare, release-docker, release, cleanup ] if: failure() steps: - uses: actions/checkout@v4 diff --git a/Cargo.lock b/Cargo.lock index 6a2079b64ce10..0848928d7c51d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -314,7 +314,7 @@ dependencies = [ "foldhash", "getrandom", "hashbrown 0.15.2", - "indexmap 2.7.0", + "indexmap 2.7.1", "itoa", "k256", "keccak-asm", @@ -630,7 +630,7 @@ dependencies = [ "async-trait", "coins-ledger", "futures-util", - "semver 1.0.24", + "semver 1.0.25", "thiserror 2.0.11", "tracing", ] @@ -665,7 +665,7 @@ dependencies = [ "alloy-primitives", "alloy-signer", "async-trait", - "semver 1.0.24", + "semver 1.0.25", "thiserror 2.0.11", "tracing", "trezor-client", @@ -695,7 +695,7 @@ dependencies = [ "alloy-sol-macro-input", "const-hex", "heck", - "indexmap 2.7.0", + "indexmap 2.7.1", "proc-macro-error2", "proc-macro2", "quote", @@ -1011,7 +1011,6 @@ dependencies = [ "tower 0.4.13", "tracing", "tracing-subscriber", - "vergen", "yansi", ] @@ -2048,14 +2047,13 @@ dependencies = [ "rayon", "regex", "rpassword", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "tempfile", "tikv-jemallocator", "tokio", "tracing", - "vergen", "yansi", ] @@ -2117,7 +2115,7 @@ dependencies = [ "reqwest", "revm", "rustyline", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "serial_test", @@ -2129,7 +2127,6 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "vergen", "walkdir", "yansi", ] @@ -3372,7 +3369,7 @@ dependencies = [ "regex", "reqwest", "revm-inspectors", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "similar", @@ -3391,7 +3388,6 @@ dependencies = [ "tower-http", "tracing", "tracing-subscriber", - "vergen", "watchexec", "watchexec-events", "watchexec-signals", @@ -3473,7 +3469,7 @@ dependencies = [ "itertools 0.13.0", "parking_lot", "revm-inspectors", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "tempfile", @@ -3541,7 +3537,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "tempfile", @@ -3570,7 +3566,7 @@ dependencies = [ "alloy-primitives", "foundry-compilers", "reqwest", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "thiserror 1.0.69", @@ -3594,7 +3590,6 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "base64 0.22.1", - "chrono", "dialoguer", "ecdsa", "eyre", @@ -3616,13 +3611,12 @@ dependencies = [ "rand", "revm", "revm-inspectors", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "thiserror 2.0.11", "toml 0.8.19", "tracing", - "vergen", "walkdir", ] @@ -3702,6 +3696,7 @@ dependencies = [ "anstyle", "async-trait", "axum", + "chrono", "clap", "comfy-table", "dunce", @@ -3714,7 +3709,7 @@ dependencies = [ "itertools 0.13.0", "num-format", "reqwest", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "similar-asserts", @@ -3724,6 +3719,7 @@ dependencies = [ "tower 0.4.13", "tracing", "url", + "vergen", "walkdir", "yansi", ] @@ -3770,7 +3766,7 @@ dependencies = [ "path-slash", "rand", "rayon", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "sha2", @@ -3808,7 +3804,7 @@ dependencies = [ "md-5", "path-slash", "rayon", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "serde_repr", @@ -3830,7 +3826,7 @@ dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-core", "path-slash", - "semver 1.0.24", + "semver 1.0.25", "serde", ] @@ -3846,7 +3842,7 @@ dependencies = [ "fs_extra", "path-slash", "regex", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "svm-rs", @@ -3878,7 +3874,7 @@ dependencies = [ "regex", "reqwest", "revm-primitives", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "serde_regex", @@ -3997,7 +3993,7 @@ dependencies = [ "foundry-evm-core", "rayon", "revm", - "semver 1.0.24", + "semver 1.0.25", "tracing", ] @@ -4016,7 +4012,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap 2.7.0", + "indexmap 2.7.1", "itertools 0.13.0", "parking_lot", "proptest", @@ -4085,7 +4081,7 @@ version = "0.3.1" dependencies = [ "alloy-primitives", "foundry-compilers", - "semver 1.0.24", + "semver 1.0.25", "thiserror 2.0.11", ] @@ -4631,7 +4627,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.7.0", + "indexmap 2.7.1", "slab", "tokio", "tokio-util", @@ -4650,7 +4646,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.2.0", - "indexmap 2.7.0", + "indexmap 2.7.1", "slab", "tokio", "tokio-util", @@ -5262,9 +5258,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "arbitrary", "equivalent", @@ -5372,9 +5368,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "is-terminal" @@ -6580,7 +6576,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.7.0", + "indexmap 2.7.1", ] [[package]] @@ -6908,7 +6904,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d35f4dc9988d1326b065b4def5e950c3ed727aa03e3151b86cc9e2aec6b03f54" dependencies = [ "futures", - "indexmap 2.7.0", + "indexmap 2.7.1", "nix 0.29.0", "tokio", "tracing", @@ -7046,7 +7042,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed1a693391a16317257103ad06a88c6529ac640846021da7c435a06fffdacd7" dependencies = [ "chrono", - "indexmap 2.7.0", + "indexmap 2.7.1", "newtype-uuid", "quick-xml 0.37.2", "strip-ansi-escapes", @@ -7596,7 +7592,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.24", + "semver 1.0.25", ] [[package]] @@ -7971,9 +7967,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" +checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" dependencies = [ "serde", ] @@ -8026,11 +8022,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "336a0c23cf42a38d9eaa7cd22c7040d04e1228a19a933890805ffd00a16437d2" +checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" dependencies = [ - "indexmap 2.7.0", + "indexmap 2.7.1", "itoa", "memchr", "ryu", @@ -8231,9 +8227,9 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "similar" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" dependencies = [ "bstr", "unicode-segmentation", @@ -8241,9 +8237,9 @@ dependencies = [ [[package]] name = "similar-asserts" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe85670573cd6f0fa97940f26e7e6601213c3b0555246c24234131f88c5709e" +checksum = "9f08357795f0d604ea7d7130f22c74b03838c959bdb14adde3142aab4d18a293" dependencies = [ "console", "similar", @@ -8358,7 +8354,7 @@ dependencies = [ "either", "num-bigint", "num-rational", - "semver 1.0.24", + "semver 1.0.25", "solar-data-structures", "solar-interface", "solar-macros", @@ -8383,7 +8379,7 @@ checksum = "71d07263243b313296eca18f18eda3a190902dc3284bf67ceff29b8b54dac3e6" dependencies = [ "bumpalo", "index_vec", - "indexmap 2.7.0", + "indexmap 2.7.1", "parking_lot", "rayon", "rustc-hash", @@ -8484,7 +8480,7 @@ dependencies = [ "regex", "reqwest", "sanitize-filename", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "sha2", @@ -8622,7 +8618,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "reqwest", - "semver 1.0.24", + "semver 1.0.25", "serde", "serde_json", "sha2", @@ -8640,7 +8636,7 @@ checksum = "9379e64a7d61f2a288e97c4b7d80a5cdcc893f24a83b6ec0ec18ffd36d58c6e2" dependencies = [ "build_const", "const-hex", - "semver 1.0.24", + "semver 1.0.25", "serde_json", "svm-rs", ] @@ -9054,7 +9050,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ - "indexmap 2.7.0", + "indexmap 2.7.1", "serde", "serde_spanned", "toml_datetime", @@ -9076,7 +9072,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.7.0", + "indexmap 2.7.1", "serde", "serde_spanned", "toml_datetime", @@ -10404,7 +10400,7 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap 2.7.0", + "indexmap 2.7.1", "memchr", "thiserror 2.0.11", "zopfli", diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index 414b56c5be5b5..e4add59916b0d 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -18,13 +18,6 @@ name = "anvil" path = "src/anvil.rs" required-features = ["cli"] -[build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } - [dependencies] # foundry internal anvil-core = { path = "core", features = ["serde", "impersonated-tx"] } diff --git a/crates/anvil/build.rs b/crates/anvil/build.rs deleted file mode 100644 index c2f550fb6f829..0000000000000 --- a/crates/anvil/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); -} diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index ffdcc1755945b..664fb19d2e1bc 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -4,6 +4,7 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; use eyre::Result; use foundry_cli::{opts::GlobalArgs, utils}; +use foundry_common::version::{LONG_VERSION, SHORT_VERSION}; #[cfg(all(feature = "jemalloc", unix))] #[global_allocator] @@ -11,7 +12,7 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; /// A fast local Ethereum development node. #[derive(Parser)] -#[command(name = "anvil", version = anvil::VERSION_MESSAGE, next_display_order = None)] +#[command(name = "anvil", version = SHORT_VERSION, long_version = LONG_VERSION, next_display_order = None)] pub struct Anvil { /// Include the global arguments. #[command(flatten)] @@ -90,6 +91,16 @@ mod tests { let _: Anvil = Anvil::parse_from(["anvil", "--help"]); } + #[test] + fn can_parse_short_version() { + let _: Anvil = Anvil::parse_from(["anvil", "-V"]); + } + + #[test] + fn can_parse_long_version() { + let _: Anvil = Anvil::parse_from(["anvil", "--version"]); + } + #[test] fn can_parse_completions() { let args: Anvil = Anvil::parse_from(["anvil", "completions", "bash"]); diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 247586bfdcc3a..21c7a4a87c833 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -57,6 +57,8 @@ use std::{ use tokio::sync::RwLock as TokioRwLock; use yansi::Paint; +pub use foundry_common::version::SHORT_VERSION as VERSION_MESSAGE; + /// Default port the rpc will open pub const NODE_PORT: u16 = 8545; /// Default chain id of the node @@ -69,15 +71,6 @@ pub const DEFAULT_MNEMONIC: &str = "test test test test test test test test test /// The default IPC endpoint pub const DEFAULT_IPC_ENDPOINT: &str = if cfg!(unix) { "/tmp/anvil.ipc" } else { r"\\.\pipe\anvil.ipc" }; -/// `anvil 0.1.0 (f01b232bc 2022-04-13T23:28:39.493201+00:00)` -pub const VERSION_MESSAGE: &str = concat!( - env!("CARGO_PKG_VERSION"), - " (", - env!("VERGEN_GIT_SHA"), - " ", - env!("VERGEN_BUILD_TIMESTAMP"), - ")" -); const BANNER: &str = r" _ _ diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index f6011831accbb..cb3862333892a 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -20,13 +20,6 @@ name = "cast" name = "cast" path = "bin/main.rs" -[build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } - [dependencies] # lib foundry-block-explorers.workspace = true diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index 657fd02496734..add3f55bc5b12 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -10,23 +10,18 @@ use alloy_rpc_types::BlockId; use clap::{Parser, Subcommand, ValueHint}; use eyre::Result; use foundry_cli::opts::{EtherscanOpts, GlobalArgs, RpcOpts}; -use foundry_common::ens::NameOrAddress; +use foundry_common::{ + ens::NameOrAddress, + version::{LONG_VERSION, SHORT_VERSION}, +}; use std::{path::PathBuf, str::FromStr}; -const VERSION_MESSAGE: &str = concat!( - env!("CARGO_PKG_VERSION"), - " (", - env!("VERGEN_GIT_SHA"), - " ", - env!("VERGEN_BUILD_TIMESTAMP"), - ")" -); - /// Perform Ethereum RPC calls from the comfort of your command line. #[derive(Parser)] #[command( name = "cast", - version = VERSION_MESSAGE, + version = SHORT_VERSION, + long_version = LONG_VERSION, after_help = "Find more information in the book: http://book.getfoundry.sh/reference/cast/cast.html", next_display_order = None, )] diff --git a/crates/cast/build.rs b/crates/cast/build.rs deleted file mode 100644 index c2f550fb6f829..0000000000000 --- a/crates/cast/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); -} diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 2e6ed7cce8bfe..f1868c81f7660 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -17,6 +17,23 @@ use foundry_test_utils::{ }; use std::{fs, io::Write, path::Path, str::FromStr}; +casttest!(print_short_version, |_prj, cmd| { + cmd.arg("-V").assert_success().stdout_eq(str![[r#" +cast [..]-[..] ([..] [..]) + +"#]]); +}); + +casttest!(print_long_version, |_prj, cmd| { + cmd.arg("--version").assert_success().stdout_eq(str![[r#" +cast Version: [..] +Commit SHA: [..] +Build Timestamp: [..] +Build Profile: [..] + +"#]]); +}); + // tests `--help` is printed to std out casttest!(print_help, |_prj, cmd| { cmd.arg("--help").assert_success().stdout_eq(str![[r#" diff --git a/crates/cheatcodes/Cargo.toml b/crates/cheatcodes/Cargo.toml index e358fdce737b0..6965ebe0b646c 100644 --- a/crates/cheatcodes/Cargo.toml +++ b/crates/cheatcodes/Cargo.toml @@ -14,13 +14,6 @@ exclude.workspace = true [lints] workspace = true -[build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } - [dependencies] foundry-cheatcodes-spec.workspace = true foundry-common.workspace = true @@ -49,7 +42,6 @@ alloy-network.workspace = true alloy-rlp.workspace = true base64.workspace = true -chrono.workspace = true dialoguer = "0.11" eyre.workspace = true itertools.workspace = true diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d3a47288ff614..0385e369d8e57 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5714,7 +5714,7 @@ { "func": { "id": "getFoundryVersion", - "description": "Returns the Foundry version.\nFormat: ++\nSample output: 0.2.0+faa94c384+202407110019\nNote: Build timestamps may vary slightly across platforms due to separate CI jobs.\nFor reliable version comparisons, use YYYYMMDD0000 format (e.g., >= 202407110000)\nto compare timestamps while ignoring minor time differences.", + "description": "Returns the Foundry version.\nFormat: -+..\nSample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug\nNote: Build timestamps may vary slightly across platforms due to separate CI jobs.\nFor reliable version comparisons, use UNIX format (e.g., >= 1700000000)\nto compare timestamps while ignoring minor time differences.", "declaration": "function getFoundryVersion() external view returns (string memory version);", "visibility": "external", "mutability": "view", diff --git a/crates/cheatcodes/build.rs b/crates/cheatcodes/build.rs deleted file mode 100644 index c2f550fb6f829..0000000000000 --- a/crates/cheatcodes/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); -} diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 47e0b625b4de0..84e529e8ac5e5 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -903,10 +903,10 @@ interface Vm { function breakpoint(string calldata char, bool value) external pure; /// Returns the Foundry version. - /// Format: ++ - /// Sample output: 0.2.0+faa94c384+202407110019 + /// Format: -+.. + /// Sample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs. - /// For reliable version comparisons, use YYYYMMDD0000 format (e.g., >= 202407110000) + /// For reliable version comparisons, use UNIX format (e.g., >= 1700000000) /// to compare timestamps while ignoring minor time differences. #[cheatcode(group = Testing, safety = Safe)] function getFoundryVersion() external view returns (string memory version); diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 417ae69833f73..5fa3f5e8fba8f 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -3,9 +3,8 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Result, Vm::*}; use alloy_primitives::Address; use alloy_sol_types::SolValue; -use chrono::DateTime; +use foundry_common::version::SEMVER_VERSION; use foundry_evm_core::constants::MAGIC_SKIP; -use std::env; pub(crate) mod assert; pub(crate) mod assume; @@ -28,14 +27,7 @@ impl Cheatcode for breakpoint_1Call { impl Cheatcode for getFoundryVersionCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self {} = self; - let cargo_version = env!("CARGO_PKG_VERSION"); - let git_sha = env!("VERGEN_GIT_SHA"); - let build_timestamp = DateTime::parse_from_rfc3339(env!("VERGEN_BUILD_TIMESTAMP")) - .expect("Invalid build timestamp format") - .format("%Y%m%d%H%M") - .to_string(); - let foundry_version = format!("{cargo_version}+{git_sha}+{build_timestamp}"); - Ok(foundry_version.abi_encode()) + Ok(SEMVER_VERSION.abi_encode()) } } diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 5975370d49e55..f0fea63a80a91 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -20,13 +20,6 @@ workspace = true name = "chisel" path = "bin/main.rs" -[build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } - [dependencies] # forge forge-fmt.workspace = true diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 797da8a1225e4..93b93d46e1c69 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -14,7 +14,11 @@ use foundry_cli::{ opts::{BuildOpts, GlobalArgs}, utils::{self, LoadConfig}, }; -use foundry_common::{evm::EvmArgs, fs}; +use foundry_common::{ + evm::EvmArgs, + fs, + version::{LONG_VERSION, SHORT_VERSION}, +}; use foundry_config::{ figment::{ value::{Dict, Map}, @@ -37,18 +41,9 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; // Loads project's figment and merges the build cli arguments into it foundry_config::merge_impl_figment_convert!(Chisel, build, evm); -const VERSION_MESSAGE: &str = concat!( - env!("CARGO_PKG_VERSION"), - " (", - env!("VERGEN_GIT_SHA"), - " ", - env!("VERGEN_BUILD_TIMESTAMP"), - ")" -); - /// Fast, utilitarian, and verbose Solidity REPL. #[derive(Debug, Parser)] -#[command(name = "chisel", version = VERSION_MESSAGE)] +#[command(name = "chisel", version = SHORT_VERSION, long_version = LONG_VERSION)] pub struct Chisel { /// Include the global arguments. #[command(flatten)] diff --git a/crates/chisel/build.rs b/crates/chisel/build.rs deleted file mode 100644 index c2f550fb6f829..0000000000000 --- a/crates/chisel/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); -} diff --git a/crates/cli/src/opts/global.rs b/crates/cli/src/opts/global.rs index 6dc34067f6198..665c504ab904d 100644 --- a/crates/cli/src/opts/global.rs +++ b/crates/cli/src/opts/global.rs @@ -1,5 +1,8 @@ use clap::{ArgAction, Parser}; -use foundry_common::shell::{ColorChoice, OutputFormat, OutputMode, Shell, Verbosity}; +use foundry_common::{ + shell::{ColorChoice, OutputFormat, OutputMode, Shell, Verbosity}, + version::{IS_NIGHTLY_VERSION, NIGHTLY_VERSION_WARNING_MESSAGE}, +}; use serde::{Deserialize, Serialize}; /// Global arguments for the CLI. @@ -47,6 +50,14 @@ impl GlobalArgs { self.force_init_thread_pool()?; } + // Display a warning message if the current version is not stable. + if std::env::var("FOUNDRY_DISABLE_NIGHTLY_WARNING").is_err() && + !self.json && + IS_NIGHTLY_VERSION + { + let _ = sh_warn!("{}", NIGHTLY_VERSION_WARNING_MESSAGE); + } + Ok(()) } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 8d2c8210c1dff..95530d26441a5 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -69,6 +69,14 @@ anstream.workspace = true anstyle.workspace = true terminal_size.workspace = true +[build-dependencies] +chrono.workspace = true +vergen = { workspace = true, features = [ + "build", + "git", + "gitcl", +] } + [dev-dependencies] foundry-macros.workspace = true similar-asserts.workspace = true diff --git a/crates/common/build.rs b/crates/common/build.rs new file mode 100644 index 0000000000000..d8c84ed35f6a5 --- /dev/null +++ b/crates/common/build.rs @@ -0,0 +1,87 @@ +use std::{env, error::Error}; + +use chrono::DateTime; +use vergen::EmitBuilder; + +#[allow(clippy::disallowed_macros)] +fn main() -> Result<(), Box> { + // Re-run the build script if the build script itself changes or if the + // environment variables change. + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=TAG_NAME"); + println!("cargo:rerun-if-env-changed=PROFILE"); + + EmitBuilder::builder() + .build_date() + .build_timestamp() + .git_describe(false, true, None) + .git_sha(false) + .emit_and_set()?; + + // Set the Git SHA of the latest commit. + let sha = env::var("VERGEN_GIT_SHA")?; + let sha_short = &sha[..10]; + + // Set the version suffix and whether the version is a nightly build. + // if not on a tag: 0.3.0-dev+ba03de0019.1737036656.debug + // if on a tag: 0.3.0-stable+ba03de0019.1737036656.release + let tag_name = env::var("TAG_NAME").unwrap_or_else(|_| String::from("dev")); + let (is_nightly, version_suffix) = if tag_name == "nightly" { + (true, "-nightly".to_string()) + } else { + (false, format!("-{tag_name}")) + }; + + // Whether the version is a nightly build. + if is_nightly { + println!("cargo:rustc-env=FOUNDRY_IS_NIGHTLY_VERSION=true"); + } + + // Set formatted version strings + let pkg_version = env::var("CARGO_PKG_VERSION")?; + + // Append the profile to the version string, defaulting to "debug". + let profile = env::var("PROFILE").unwrap_or_else(|_| String::from("debug")); + + // Set the build timestamp. + let build_timestamp = env::var("VERGEN_BUILD_TIMESTAMP")?; + let build_timestamp_unix = DateTime::parse_from_rfc3339(&build_timestamp)?.timestamp(); + + // The SemVer compatible version information for Foundry. + // - The latest version from Cargo.toml. + // - The short SHA of the latest commit. + // - The UNIX formatted build timestamp. + // - The build profile. + // Example: forge 0.3.0-nightly+3cb96bde9b.1737036656.debug + println!( + "cargo:rustc-env=FOUNDRY_SEMVER_VERSION={pkg_version}{version_suffix}+{sha_short}.{build_timestamp_unix}.{profile}" + ); + + // The short version information for the Foundry CLI. + // - The latest version from Cargo.toml + // - The short SHA of the latest commit. + // Example: 0.3.0-dev (3cb96bde9b) + println!("cargo:rustc-env=FOUNDRY_SHORT_VERSION={pkg_version}{version_suffix} ({sha_short} {build_timestamp})"); + + // The long version information for the Foundry CLI. + // - The latest version from Cargo.toml. + // - The long SHA of the latest commit. + // - The build timestamp in RFC3339 format and UNIX format in seconds. + // - The build profile. + // + // Example: + // + // ```text + // + // Version: 0.3.0-dev + // Commit SHA: 5186142d3bb4d1be7bb4ade548b77c8e2270717e + // Build Timestamp: 2025-01-16T15:04:03.522021223Z (1737039843) + // Build Profile: debug + // ``` + println!("cargo:rustc-env=FOUNDRY_LONG_VERSION_0=Version: {pkg_version}{version_suffix}"); + println!("cargo:rustc-env=FOUNDRY_LONG_VERSION_1=Commit SHA: {sha}"); + println!("cargo:rustc-env=FOUNDRY_LONG_VERSION_2=Build Timestamp: {build_timestamp} ({build_timestamp_unix})"); + println!("cargo:rustc-env=FOUNDRY_LONG_VERSION_3=Build Profile: {profile}"); + + Ok(()) +} diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 259e8fee2dac0..88643a67c8fd4 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -34,6 +34,7 @@ pub mod term; pub mod traits; pub mod transactions; mod utils; +pub mod version; pub use constants::*; pub use contracts::*; diff --git a/crates/common/src/version.rs b/crates/common/src/version.rs new file mode 100644 index 0000000000000..f69457bf7c1e3 --- /dev/null +++ b/crates/common/src/version.rs @@ -0,0 +1,27 @@ +//! Foundry version information. + +/// The SemVer compatible version information for Foundry. +pub const SEMVER_VERSION: &str = env!("FOUNDRY_SEMVER_VERSION"); + +/// The short version message information for the Foundry CLI. +pub const SHORT_VERSION: &str = env!("FOUNDRY_SHORT_VERSION"); + +/// The long version message information for the Foundry CLI. +pub const LONG_VERSION: &str = concat!( + env!("FOUNDRY_LONG_VERSION_0"), + "\n", + env!("FOUNDRY_LONG_VERSION_1"), + "\n", + env!("FOUNDRY_LONG_VERSION_2"), + "\n", + env!("FOUNDRY_LONG_VERSION_3"), +); + +/// Whether the version is a nightly build. +pub const IS_NIGHTLY_VERSION: bool = option_env!("FOUNDRY_IS_NIGHTLY_VERSION").is_some(); + +/// The warning message for nightly versions. +pub const NIGHTLY_VERSION_WARNING_MESSAGE: &str = + "This is a nightly build of Foundry. It is recommended to use the latest stable version. \ + Visit https://book.getfoundry.sh/announcements for more information. \n\ + To mute this warning set `FOUNDRY_DISABLE_NIGHTLY_WARNING` in your environment. \n"; diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index a8b7f56c020df..342f710369764 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -17,13 +17,6 @@ workspace = true name = "forge" path = "bin/main.rs" -[build-dependencies] -vergen = { workspace = true, default-features = false, features = [ - "build", - "git", - "gitcl", -] } - [dependencies] # lib foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } diff --git a/crates/forge/bin/opts.rs b/crates/forge/bin/opts.rs index e211d03b78f33..86a23d7408bc2 100644 --- a/crates/forge/bin/opts.rs +++ b/crates/forge/bin/opts.rs @@ -9,22 +9,15 @@ use clap::{Parser, Subcommand, ValueHint}; use forge_script::ScriptArgs; use forge_verify::{VerifyArgs, VerifyBytecodeArgs, VerifyCheckArgs}; use foundry_cli::opts::GlobalArgs; +use foundry_common::version::{LONG_VERSION, SHORT_VERSION}; use std::path::PathBuf; -const VERSION_MESSAGE: &str = concat!( - env!("CARGO_PKG_VERSION"), - " (", - env!("VERGEN_GIT_SHA"), - " ", - env!("VERGEN_BUILD_TIMESTAMP"), - ")" -); - /// Build, test, fuzz, debug and deploy Solidity contracts. #[derive(Parser)] #[command( name = "forge", - version = VERSION_MESSAGE, + version = SHORT_VERSION, + long_version = LONG_VERSION, after_help = "Find more information in the book: http://book.getfoundry.sh/reference/forge/forge.html", next_display_order = None, )] diff --git a/crates/forge/build.rs b/crates/forge/build.rs deleted file mode 100644 index c2f550fb6f829..0000000000000 --- a/crates/forge/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); -} diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index abcaf1803fee5..61bf0239abc9b 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -26,5 +26,6 @@ mod svm; mod test_cmd; mod verify; mod verify_bytecode; +mod version; mod ext_integration; diff --git a/crates/forge/tests/cli/version.rs b/crates/forge/tests/cli/version.rs new file mode 100644 index 0000000000000..0df88b83a501d --- /dev/null +++ b/crates/forge/tests/cli/version.rs @@ -0,0 +1,18 @@ +use foundry_test_utils::{forgetest, str}; + +forgetest!(print_short_version, |_prj, cmd| { + cmd.arg("-V").assert_success().stdout_eq(str![[r#" +forge [..]-[..] ([..] [..]) + +"#]]); +}); + +forgetest!(print_long_version, |_prj, cmd| { + cmd.arg("--version").assert_success().stdout_eq(str![[r#" +forge Version: [..] +Commit SHA: [..] +Build Timestamp: [..] +Build Profile: [..] + +"#]]); +}); diff --git a/testdata/default/cheats/GetFoundryVersion.t.sol b/testdata/default/cheats/GetFoundryVersion.t.sol index 34d9a74bb4537..eca5090db99c3 100644 --- a/testdata/default/cheats/GetFoundryVersion.t.sol +++ b/testdata/default/cheats/GetFoundryVersion.t.sol @@ -8,19 +8,38 @@ contract GetFoundryVersionTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function testGetFoundryVersion() public view { + // (e.g. 0.3.0-nightly+3cb96bde9b.1737036656.debug) string memory fullVersionString = vm.getFoundryVersion(); - string[] memory versionComponents = vm.split(fullVersionString, "+"); - require(versionComponents.length == 3, "Invalid version format"); + // Step 1: Split the version at "+" + string[] memory plusSplit = vm.split(fullVersionString, "+"); + require(plusSplit.length == 2, "Invalid version format: Missing '+' separator"); - string memory semanticVersion = versionComponents[0]; + // Step 2: Extract parts + string memory semanticVersion = plusSplit[0]; // "0.3.0-dev" + string memory metadata = plusSplit[1]; // "34389e7850.1737037814.debug" + + // Step 3: Further split metadata by "." + string[] memory metadataComponents = vm.split(metadata, "."); + require(metadataComponents.length == 3, "Invalid version format: Metadata should have 3 components"); + + // Step 4: Extract values + string memory commitHash = metadataComponents[0]; // "34389e7850" + string memory timestamp = metadataComponents[1]; // "1737037814" + string memory buildType = metadataComponents[2]; // "debug" + + // Validate semantic version (e.g., "0.3.0-stable" or "0.3.0-nightly") require(bytes(semanticVersion).length > 0, "Semantic version is empty"); - string memory commitHash = versionComponents[1]; - require(bytes(commitHash).length > 0, "Commit hash is empty"); + // Validate commit hash (should be exactly 10 characters) + require(bytes(commitHash).length == 10, "Invalid commit hash length"); - uint256 buildUnixTimestamp = vm.parseUint(versionComponents[2]); - uint256 minimumAcceptableTimestamp = 202406111234; + // Validate UNIX timestamp (numeric) + uint256 buildUnixTimestamp = vm.parseUint(timestamp); + uint256 minimumAcceptableTimestamp = 1700000000; // Adjust as needed require(buildUnixTimestamp >= minimumAcceptableTimestamp, "Build timestamp is too old"); + + // Validate build profile (e.g., "debug" or "release") + require(bytes(buildType).length > 0, "Build type is empty"); } } From f94ce465969c4b25df57aa3e72ed80d4f6d4599f Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 21 Jan 2025 12:53:56 +0200 Subject: [PATCH 1871/1963] fix(forge): allow install private deps with https and gh token (#9726) fix(forge): allow install deps with https and gh token --- crates/cli/src/opts/dependency.rs | 26 ++++++++++++++++++++++++-- crates/forge/bin/cmd/install.rs | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/opts/dependency.rs b/crates/cli/src/opts/dependency.rs index b7fe20abfc40b..c3d802dbe208d 100644 --- a/crates/cli/src/opts/dependency.rs +++ b/crates/cli/src/opts/dependency.rs @@ -8,7 +8,7 @@ static GH_REPO_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"[\w-]+/[\w /// Git repo prefix regex pub static GH_REPO_PREFIX_REGEX: LazyLock = LazyLock::new(|| { - Regex::new(r"((git@)|(git\+https://)|(https://)|(org-([A-Za-z0-9-])+@))?(?P[A-Za-z0-9-]+)\.(?P[A-Za-z0-9-]+)(/|:)") + Regex::new(r"((git@)|(git\+https://)|(https://)|https://(?P[^@]+)@|(org-([A-Za-z0-9-])+@))?(?P[A-Za-z0-9-]+)\.(?P[A-Za-z0-9-]+)(/|:)") .unwrap() }); @@ -81,7 +81,15 @@ impl FromStr for Dependency { let brand = captures.name("brand").unwrap().as_str(); let tld = captures.name("tld").unwrap().as_str(); let project = GH_REPO_PREFIX_REGEX.replace(dependency, ""); - Some(format!("https://{brand}.{tld}/{}", project.trim_end_matches(".git"))) + if let Some(token) = captures.name("token") { + Some(format!( + "https://{}@{brand}.{tld}/{}", + token.as_str(), + project.trim_end_matches(".git") + )) + } else { + Some(format!("https://{brand}.{tld}/{}", project.trim_end_matches(".git"))) + } } else { // If we don't have a URL and we don't have a valid // GitHub repository name, then we assume this is the alias. @@ -392,4 +400,18 @@ mod tests { assert_eq!(dep.tag, Some("80eb41b".to_string())); assert_eq!(dep.alias, None); } + + #[test] + fn can_parse_https_with_github_token() { + // + let dep = Dependency::from_str( + "https://ghp_mytoken@github.com/private-org/precompiles-solidity.git", + ) + .unwrap(); + assert_eq!(dep.name, "precompiles-solidity"); + assert_eq!( + dep.url, + Some("https://ghp_mytoken@github.com/private-org/precompiles-solidity".to_string()) + ); + } } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 55eb4f5d4b6be..ee1b3a4ab73a0 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -24,6 +24,7 @@ static DEPENDENCY_VERSION_TAG_REGEX: LazyLock = #[command(override_usage = "forge install [OPTIONS] [DEPENDENCIES]... forge install [OPTIONS] /@... forge install [OPTIONS] =/@... + forge install [OPTIONS] @git url>...)] forge install [OPTIONS] ...")] pub struct InstallArgs { /// The dependencies to install. From fea38858b0e8d97acb516ccff163a6f5e28f7fa1 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 21 Jan 2025 17:46:16 +0100 Subject: [PATCH 1872/1963] fix: release process (#9728) * fix env variable of tag name location * make tag name more robust, not just matching on strict "nightly" but containing nightly * prefer using short version in foundryup to avoid cluttering stdout * pass in tag name (cast to `nightly` if nightly build) during Docker build process * requires prepare step * use with instead of env * env not available in step * fix build tag * add test tag for Docker * pass down tag_name into Dockerfile.cross * revert docker specific changes, do that as a follow up to unblock * avoid whitespace diff --- .github/workflows/release.yml | 3 +-- crates/common/build.rs | 2 +- foundryup/foundryup | 10 +++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 710c6d4ac7cda..83b627d4a663c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,8 +74,6 @@ jobs: attestations: write name: ${{ matrix.target }} (${{ matrix.runner }}) runs-on: ${{ matrix.runner }} - env: - TAG_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} timeout-minutes: 240 needs: prepare strategy: @@ -136,6 +134,7 @@ jobs: - name: Build binaries env: + TAG_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }} PLATFORM_NAME: ${{ matrix.platform }} TARGET: ${{ matrix.target }} diff --git a/crates/common/build.rs b/crates/common/build.rs index d8c84ed35f6a5..acbac73bac108 100644 --- a/crates/common/build.rs +++ b/crates/common/build.rs @@ -26,7 +26,7 @@ fn main() -> Result<(), Box> { // if not on a tag: 0.3.0-dev+ba03de0019.1737036656.debug // if on a tag: 0.3.0-stable+ba03de0019.1737036656.release let tag_name = env::var("TAG_NAME").unwrap_or_else(|_| String::from("dev")); - let (is_nightly, version_suffix) = if tag_name == "nightly" { + let (is_nightly, version_suffix) = if tag_name.contains("nightly") { (true, "-nightly".to_string()) } else { (false, format!("-{tag_name}")) diff --git a/foundryup/foundryup b/foundryup/foundryup index 998abfeb1ae07..91d0c86ed6c89 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -4,7 +4,7 @@ set -eo pipefail # NOTE: if you make modifications to this script, please increment the version number. # Major / minor: incremented for each stable release of Foundry. # Patch: incremented for each change between stable releases. -FOUNDRYUP_INSTALLER_VERSION="0.3.0" +FOUNDRYUP_INSTALLER_VERSION="0.3.1" BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} @@ -183,7 +183,7 @@ main() { cp $FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG/$bin $bin_path # Print installed msg - say "installed - $(ensure "$bin_path" --version)" + say "installed - $(ensure "$bin_path" -V)" # Check if the default path of the binary is not in FOUNDRY_BIN_DIR which_path="$(command -v "$bin" || true)" @@ -304,14 +304,14 @@ list() { say "${VERSION##*/}" for bin in "${BINS[@]}"; do bin_path="$VERSION/$bin" - say "- $(ensure "$bin_path" --version)" + say "- $(ensure "$bin_path" -V)" done printf "\n" done else for bin in "${BINS[@]}"; do bin_path="$FOUNDRY_BIN_DIR/$bin" - say "- $(ensure "$bin_path" --version)" + say "- $(ensure "$bin_path" -V)" done fi exit 0 @@ -328,7 +328,7 @@ use() { bin_path="$FOUNDRY_BIN_DIR/$bin" cp $FOUNDRY_VERSION_DIR/$bin $bin_path # Print usage msg - say "use - $(ensure "$bin_path" --version)" + say "use - $(ensure "$bin_path" -V)" done exit 0 else From 5993795a90e32e880eb6c735166738cff21097b9 Mon Sep 17 00:00:00 2001 From: Delweng Date: Wed, 22 Jan 2025 01:14:22 +0800 Subject: [PATCH 1873/1963] feat: allow remapping of solidity files (#9604) * feat(remapping): support remapping of .sol files Signed-off-by: jsvisa * feat(remapping): add testcase Signed-off-by: jsvisa * typo Signed-off-by: jsvisa --------- Signed-off-by: jsvisa --- crates/config/src/providers/remappings.rs | 142 +++++++++++++++++++++- 1 file changed, 141 insertions(+), 1 deletion(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 385a2dc66860f..26d3cca8987b2 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -70,10 +70,22 @@ impl Remappings { /// Push an element to the remappings vector, but only if it's not already present. pub fn push(&mut self, remapping: Remapping) { + // Special handling for .sol file remappings, only allow one remapping per source file. + if remapping.name.ends_with(".sol") && !remapping.path.ends_with(".sol") { + return; + } + if self.remappings.iter().any(|existing| { + if remapping.name.ends_with(".sol") { + // For .sol files, only prevent duplicate source names in the same context + return existing.name == remapping.name && + existing.context == remapping.context && + existing.path == remapping.path + } + // What we're doing here is filtering for ambiguous paths. For example, if we have // @prb/math/=node_modules/@prb/math/src/ as existing, and - // @prb/=node_modules/@prb/ as the one being checked, + // @prb/=node_modules/@prb/ as the one being checked, // we want to keep the already existing one, which is the first one. This way we avoid // having to deal with ambiguous paths which is unwanted when autodetecting remappings. existing.name.starts_with(&remapping.name) && existing.context == remapping.context @@ -309,3 +321,131 @@ impl Provider for RemappingsProvider<'_> { Some(Config::selected_profile()) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_sol_file_remappings() { + let mut remappings = Remappings::new(); + + // First valid remapping + remappings.push(Remapping { + context: None, + name: "MyContract.sol".to_string(), + path: "implementations/Contract1.sol".to_string(), + }); + + // Same source to different target (should be rejected) + remappings.push(Remapping { + context: None, + name: "MyContract.sol".to_string(), + path: "implementations/Contract2.sol".to_string(), + }); + + // Different source to same target (should be allowed) + remappings.push(Remapping { + context: None, + name: "OtherContract.sol".to_string(), + path: "implementations/Contract1.sol".to_string(), + }); + + // Exact duplicate (should be silently ignored) + remappings.push(Remapping { + context: None, + name: "MyContract.sol".to_string(), + path: "implementations/Contract1.sol".to_string(), + }); + + // Invalid .sol remapping (target not .sol) + remappings.push(Remapping { + context: None, + name: "Invalid.sol".to_string(), + path: "implementations/Contract1.txt".to_string(), + }); + + let result = remappings.into_inner(); + assert_eq!(result.len(), 2, "Should only have 2 valid remappings"); + + // Verify the correct remappings exist + assert!( + result + .iter() + .any(|r| r.name == "MyContract.sol" && r.path == "implementations/Contract1.sol"), + "Should keep first mapping of MyContract.sol" + ); + assert!( + !result + .iter() + .any(|r| r.name == "MyContract.sol" && r.path == "implementations/Contract2.sol"), + "Should keep first mapping of MyContract.sol" + ); + assert!(result.iter().any(|r| r.name == "OtherContract.sol" && r.path == "implementations/Contract1.sol"), + "Should allow different source to same target"); + + // Verify the rejected remapping doesn't exist + assert!( + !result + .iter() + .any(|r| r.name == "MyContract.sol" && r.path == "implementations/Contract2.sol"), + "Should reject same source to different target" + ); + } + + #[test] + fn test_mixed_remappings() { + let mut remappings = Remappings::new(); + + remappings.push(Remapping { + context: None, + name: "@openzeppelin/".to_string(), + path: "lib/openzeppelin/".to_string(), + }); + remappings.push(Remapping { + context: None, + name: "@openzeppelin/contracts/".to_string(), + path: "lib/openzeppelin/contracts/".to_string(), + }); + + remappings.push(Remapping { + context: None, + name: "MyContract.sol".to_string(), + path: "os/Contract.sol".to_string(), + }); + + let result = remappings.into_inner(); + + assert_eq!(result.len(), 3, "Should have 3 remappings"); + assert!(result.iter().any( + |r| r.name == "@openzeppelin/contracts/" && r.path == "lib/openzeppelin/contracts/" + )); + assert!(result.iter().any(|r| r.name == "MyContract.sol" && r.path == "os/Contract.sol")); + } + + #[test] + fn test_remappings_with_context() { + let mut remappings = Remappings::new(); + + // Same name but different contexts + remappings.push(Remapping { + context: Some("test/".to_string()), + name: "MyContract.sol".to_string(), + path: "test/Contract.sol".to_string(), + }); + remappings.push(Remapping { + context: Some("prod/".to_string()), + name: "MyContract.sol".to_string(), + path: "prod/Contract.sol".to_string(), + }); + + let result = remappings.into_inner(); + assert_eq!(result.len(), 2, "Should allow same name with different contexts"); + assert!(result + .iter() + .any(|r| r.context == Some("test/".to_string()) && r.path == "test/Contract.sol")); + assert!(result + .iter() + .any(|r| r.context == Some("prod/".to_string()) && r.path == "prod/Contract.sol")); + } +} From 423644efa5955267c2df4461dca396079579c28f Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 21 Jan 2025 23:24:05 +0530 Subject: [PATCH 1874/1963] fix(`forge`): disable artifacts for coverage (#9692) * feat(`forge`): diff artifacts dir for coverage * nit * nit * flip `no_artifacts` to true * nit --- crates/forge/bin/cmd/coverage.rs | 10 ++++- crates/forge/tests/cli/coverage.rs | 62 +++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index cf059265e9023..0dffce4ed0a32 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -107,7 +107,8 @@ impl CoverageArgs { /// Builds the project. fn build(&self, config: &Config) -> Result<(Project, ProjectCompileOutput)> { // Set up the project - let mut project = config.create_project(false, false)?; + let mut project = config.create_project(false, true)?; + if self.ir_minimum { // print warning message sh_warn!("{}", concat!( @@ -138,6 +139,13 @@ impl CoverageArgs { project.settings.solc.optimizer.details = None; project.settings.solc.via_ir = None; } + let mut warning = + "optimizer settings have been disabled for accurate coverage reports".to_string(); + if !self.ir_minimum { + warning += ", if you encounter \"stack too deep\" errors, consider using `--ir-minimum` which enables viaIR with minimum optimization resolving most of the errors"; + } + + sh_warn!("{warning}")?; let output = ProjectCompiler::default() .compile(&project)? diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index c840a80362a0f..7f7c06299172b 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1,4 +1,4 @@ -use foundry_common::fs; +use foundry_common::fs::{self, files_with_ext}; use foundry_test_utils::{ snapbox::{Data, IntoData}, TestCommand, TestProject, @@ -1691,3 +1691,63 @@ contract AContract { fn assert_lcov(cmd: &mut TestCommand, data: impl IntoData) { cmd.args(["--report=lcov", "--report-file"]).assert_file(data.into_data()); } + +forgetest!(no_artifacts_written, |prj, cmd| { + prj.insert_ds_test(); + prj.add_source( + "AContract.sol", + r#" +contract AContract { + int public i; + + function init() public { + i = 0; + } + + function foo() public { + i = 1; + } +} + "#, + ) + .unwrap(); + + prj.add_source( + "AContractTest.sol", + r#" +import "./test.sol"; +import {AContract} from "./AContract.sol"; + +contract AContractTest is DSTest { + AContract a; + + function setUp() public { + a = new AContract(); + a.init(); + } + + function testFoo() public { + a.foo(); + } +} + "#, + ) + .unwrap(); + + cmd.forge_fuse().arg("coverage").assert_success().stdout_eq(str![[r#" +... +╭-------------------+---------------+---------------+---------------+---------------╮ +| File | % Lines | % Statements | % Branches | % Funcs | ++===================================================================================+ +| src/AContract.sol | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +|-------------------+---------------+---------------+---------------+---------------| +| Total | 100.00% (4/4) | 100.00% (2/2) | 100.00% (0/0) | 100.00% (2/2) | +╰-------------------+---------------+---------------+---------------+---------------╯ +... +"#]]); + + // no artifacts are to be written + let files = files_with_ext(prj.artifacts(), "json").collect::>(); + + assert!(files.is_empty()); +}); From 75462d9aa844a5bbe4a44d83b5195546ad55791e Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 21 Jan 2025 22:31:38 +0400 Subject: [PATCH 1875/1963] fix: respect `disable_block_gas_limit` config key (#9732) fix --- crates/common/src/evm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/common/src/evm.rs b/crates/common/src/evm.rs index 74b0c8f8056d7..493d638162f30 100644 --- a/crates/common/src/evm.rs +++ b/crates/common/src/evm.rs @@ -267,6 +267,7 @@ pub struct EnvArgs { /// Whether to disable the block gas limit checks. #[arg(long, visible_alias = "no-gas-limit")] + #[serde(skip_serializing_if = "std::ops::Not::not")] pub disable_block_gas_limit: bool, } From 5d16800a64e5357fbb2493e4cae061756d145981 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 22 Jan 2025 04:12:08 +0400 Subject: [PATCH 1876/1963] chore: bump compilers (#9735) --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 4 ++-- crates/forge/bin/cmd/bind_json.rs | 2 +- crates/forge/bin/cmd/compiler.rs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0848928d7c51d..f9424903f2c37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3557,9 +3557,9 @@ dependencies = [ [[package]] name = "foundry-block-explorers" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0faa449506113b4969029da2ac1df3a1b3201bf10c99a4a8e6d684977b80c938" +checksum = "0d7f2a3d90ff85c164c0eb05fdf19b22e68b9190b5449d1aa0eef8314c1874e9" dependencies = [ "alloy-chains", "alloy-json-abi", @@ -3746,9 +3746,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.12.9" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67e3eab56847dcf269eb186226f95874b171e262952cff6c910da36b1469e10" +checksum = "db0e0897aa7088fa1340d58c18a11b5be7f3a76e582c947a9bd86ee440e735b2" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3761,7 +3761,7 @@ dependencies = [ "fs_extra", "futures-util", "home", - "itertools 0.13.0", + "itertools 0.14.0", "md-5", "path-slash", "rand", @@ -3783,9 +3783,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.12.9" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865b00448dc2a5d56bae287c36fa716379ffcdd937aefb7758bd20b62024d234" +checksum = "8956905969f3610dc048a7748a8b8ffcefd5d868aeebf5769012574f9ee36077" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3793,9 +3793,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.12.9" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668972ba511f80895ea12c75cd12fccd6627c26e64763799d83978b4e0916cae" +checksum = "233e93be9079903ed3e72970cf28e156f69772782281d08a4d97a3dfa0693675" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3817,9 +3817,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.12.9" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a24f7f2a7458171e055c0cb33272f5eccaefbd96d791d74177d9a1fca048f74" +checksum = "b19f32fc5479271e31f7977a36ff7c0359e3ae2884cb3aaab95a28d2087245c4" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3832,9 +3832,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.12.9" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8005271a079bc6470c61d4145d2e390a827b1ccbb96abb7b69b088f17ffb95e0" +checksum = "eb8c5859a768b990f10bc17cd76e20d77965c352fd84822b5234345103c9dd88" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 4e32ea07f2d83..7442519027f70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,8 +170,8 @@ foundry-wallets = { path = "crates/wallets" } foundry-linking = { path = "crates/linking" } # solc & compilation utilities -foundry-block-explorers = { version = "0.9.0", default-features = false } -foundry-compilers = { version = "0.12.9", default-features = false } +foundry-block-explorers = { version = "0.11.0", default-features = false } +foundry-compilers = { version = "0.13.0", default-features = false } foundry-fork-db = "0.10.0" solang-parser = "=0.3.3" solar-parse = { version = "=0.1.1", default-features = false } diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index 8b0fba88e333d..891e019bc5f85 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -77,7 +77,7 @@ impl BindJsonArgs { let mut sources = graph // resolve graph into mapping language -> version -> sources .into_sources_by_version(&project)? - .0 + .sources .into_iter() // we are only interested in Solidity sources .find(|(lang, _)| *lang == MultiCompilerLanguage::Solc(SolcLanguage::Solidity)) diff --git a/crates/forge/bin/cmd/compiler.rs b/crates/forge/bin/cmd/compiler.rs index d80112311112a..19e4354ca9cb4 100644 --- a/crates/forge/bin/cmd/compiler.rs +++ b/crates/forge/bin/cmd/compiler.rs @@ -63,7 +63,7 @@ impl ResolveArgs { let project = config.project()?; let graph = Graph::resolve(&project.paths)?; - let (sources, _) = graph.into_sources_by_version(&project)?; + let sources = graph.into_sources_by_version(&project)?.sources; let mut output: BTreeMap> = BTreeMap::new(); From aa04294aba2a7760833bb480cc9c2052a9e40bf2 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 22 Jan 2025 00:00:04 -0800 Subject: [PATCH 1877/1963] feat(cheatcodes): add ability to ignore (multiple) specific and partial reverts in fuzz and invariant tests (#9179) * initial pass add support for multiple reasons, add tests appease clippy fix broken tests; fix some assume behavior remove comment and bad error-surfacing logic remove redundant param, rename revert.rs, create sol test file remove unnecessary tests from both test_cmd and AssumeNoRevert.t.sol use empty vec instead of option; remove commented test remove assumeNoPartialRevert; update assumeNoPartialRevert Simplify test, use snapbox assertion Redact number of runs implement assume_no_revert change * rebase and refactor * fix tests for overloaded; original failing * remove erroneous return type * appease clippy * allow combining expectRevert with assumeNoRevert * Apply suggestions from code review nit * remove magic string const * fix error string * improve invariant selectors weight test * nit --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: grandizzy --- crates/cheatcodes/assets/cheatcodes.json | 63 ++++- crates/cheatcodes/spec/src/lib.rs | 1 + crates/cheatcodes/spec/src/vm.rs | 20 ++ crates/cheatcodes/src/inspector.rs | 63 +++-- crates/cheatcodes/src/test.rs | 1 + crates/cheatcodes/src/test/assume.rs | 79 +++++- crates/cheatcodes/src/test/expect.rs | 179 ++------------ crates/cheatcodes/src/test/revert_handlers.rs | 234 ++++++++++++++++++ crates/forge/tests/cli/test.sol | 129 ++++++++++ crates/forge/tests/cli/test_cmd.rs | 191 ++++++++++++++ crates/forge/tests/it/invariant.rs | 95 +++++-- testdata/cheats/Vm.sol | 3 + testdata/default/cheats/AssumeNoRevert.t.sol | 153 ++++++++++++ .../common/InvariantSelectorsWeight.t.sol | 56 ----- 14 files changed, 1005 insertions(+), 262 deletions(-) create mode 100644 crates/cheatcodes/src/test/revert_handlers.rs create mode 100644 crates/forge/tests/cli/test.sol create mode 100644 testdata/default/cheats/AssumeNoRevert.t.sol delete mode 100644 testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 0385e369d8e57..cb49f2de1a27b 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -604,6 +604,27 @@ "description": "Address of the contract implementation that will be delegated to.\n Gets encoded into delegation code: 0xef0100 || implementation." } ] + }, + { + "name": "PotentialRevert", + "description": "Represents a \"potential\" revert reason from a single subsequent call when using `vm.assumeNoReverts`.\n Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced\n as normal.", + "fields": [ + { + "name": "reverter", + "ty": "address", + "description": "The allowed origin of the revert opcode; address(0) allows reverts from any address" + }, + { + "name": "partialMatch", + "ty": "bool", + "description": "When true, only matches on the beginning of the revert data, otherwise, matches on entire revert data" + }, + { + "name": "revertData", + "ty": "bytes", + "description": "The data to use to match encountered reverts" + } + ] } ], "cheatcodes": [ @@ -3089,7 +3110,7 @@ }, { "func": { - "id": "assumeNoRevert", + "id": "assumeNoRevert_0", "description": "Discard this run's fuzz inputs and generate new ones if next call reverted.", "declaration": "function assumeNoRevert() external pure;", "visibility": "external", @@ -3107,6 +3128,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "assumeNoRevert_1", + "description": "Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.", + "declaration": "function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assumeNoRevert((address,bool,bytes))", + "selector": "0xd8591eeb", + "selectorBytes": [ + 216, + 89, + 30, + 235 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "assumeNoRevert_2", + "description": "Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.", + "declaration": "function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;", + "visibility": "external", + "mutability": "pure", + "signature": "assumeNoRevert((address,bool,bytes)[])", + "selector": "0x8a4592cc", + "selectorBytes": [ + 138, + 69, + 146, + 204 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "attachDelegation", diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index c4d7e9868fe13..e39cfc2d7ba91 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -88,6 +88,7 @@ impl Cheatcodes<'static> { Vm::DebugStep::STRUCT.clone(), Vm::BroadcastTxSummary::STRUCT.clone(), Vm::SignedDelegation::STRUCT.clone(), + Vm::PotentialRevert::STRUCT.clone(), ]), enums: Cow::Owned(vec![ Vm::CallerMode::ENUM.clone(), diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 84e529e8ac5e5..cf9709276335d 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -324,6 +324,18 @@ interface Vm { address implementation; } + /// Represents a "potential" revert reason from a single subsequent call when using `vm.assumeNoReverts`. + /// Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced + /// as normal. + struct PotentialRevert { + /// The allowed origin of the revert opcode; address(0) allows reverts from any address + address reverter; + /// When true, only matches on the beginning of the revert data, otherwise, matches on entire revert data + bool partialMatch; + /// The data to use to match encountered reverts + bytes revertData; + } + // ======== EVM ======== /// Gets the address for a given private key. @@ -894,6 +906,14 @@ interface Vm { #[cheatcode(group = Testing, safety = Safe)] function assumeNoRevert() external pure; + /// Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters. + #[cheatcode(group = Testing, safety = Safe)] + function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure; + + /// Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters. + #[cheatcode(group = Testing, safety = Safe)] + function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure; + /// Writes a breakpoint to jump to in the debugger. #[cheatcode(group = Testing, safety = Safe)] function breakpoint(string calldata char) external pure; diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index a0695d0d254f3..3cb74c6ac8550 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -15,6 +15,7 @@ use crate::{ self, ExpectedCallData, ExpectedCallTracker, ExpectedCallType, ExpectedEmitTracker, ExpectedRevert, ExpectedRevertKind, }, + revert_handlers, }, utils::IgnoredTraces, CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result, @@ -755,16 +756,14 @@ where { matches!(expected_revert.kind, ExpectedRevertKind::Default) { let mut expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - let handler_result = expect::handle_expect_revert( + return match revert_handlers::handle_expect_revert( false, true, - &mut expected_revert, + &expected_revert, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, - ); - - return match handler_result { + ) { Ok((address, retdata)) => { expected_revert.actual_count += 1; if expected_revert.actual_count < expected_revert.count { @@ -1287,16 +1286,45 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { } } - // Handle assume not revert cheatcode. - if let Some(assume_no_revert) = &self.assume_no_revert { - if ecx.journaled_state.depth() == assume_no_revert.depth && !cheatcode_call { - // Discard run if we're at the same depth as cheatcode and call reverted. + // Handle assume no revert cheatcode. + if let Some(assume_no_revert) = &mut self.assume_no_revert { + // Record current reverter address before processing the expect revert if call reverted, + // expect revert is set with expected reverter address and no actual reverter set yet. + if outcome.result.is_revert() && assume_no_revert.reverted_by.is_none() { + assume_no_revert.reverted_by = Some(call.target_address); + } + // allow multiple cheatcode calls at the same depth + if ecx.journaled_state.depth() <= assume_no_revert.depth && !cheatcode_call { + // Discard run if we're at the same depth as cheatcode, call reverted, and no + // specific reason was supplied if outcome.result.is_revert() { - outcome.result.output = Error::from(MAGIC_ASSUME).abi_encode().into(); + let assume_no_revert = std::mem::take(&mut self.assume_no_revert).unwrap(); + return match revert_handlers::handle_assume_no_revert( + &assume_no_revert, + outcome.result.result, + &outcome.result.output, + &self.config.available_artifacts, + ) { + // if result is Ok, it was an anticipated revert; return an "assume" error + // to reject this run + Ok(_) => { + outcome.result.output = Error::from(MAGIC_ASSUME).abi_encode().into(); + outcome + } + // if result is Error, it was an unanticipated revert; should revert + // normally + Err(error) => { + trace!(expected=?assume_no_revert, ?error, status=?outcome.result.result, "Expected revert mismatch"); + outcome.result.result = InstructionResult::Revert; + outcome.result.output = error.abi_encode().into(); + outcome + } + } + } else { + // Call didn't revert, reset `assume_no_revert` state. + self.assume_no_revert = None; return outcome; } - // Call didn't revert, reset `assume_no_revert` state. - self.assume_no_revert = None; } } @@ -1330,20 +1358,15 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { }; if needs_processing { - // Only `remove` the expected revert from state if `expected_revert.count` == - // `expected_revert.actual_count` let mut expected_revert = std::mem::take(&mut self.expected_revert).unwrap(); - - let handler_result = expect::handle_expect_revert( + return match revert_handlers::handle_expect_revert( cheatcode_call, false, - &mut expected_revert, + &expected_revert, outcome.result.result, outcome.result.output.clone(), &self.config.available_artifacts, - ); - - return match handler_result { + ) { Err(error) => { trace!(expected=?expected_revert, ?error, status=?outcome.result.result, "Expected revert mismatch"); outcome.result.result = InstructionResult::Revert; diff --git a/crates/cheatcodes/src/test.rs b/crates/cheatcodes/src/test.rs index 5fa3f5e8fba8f..c12f4609bdef2 100644 --- a/crates/cheatcodes/src/test.rs +++ b/crates/cheatcodes/src/test.rs @@ -9,6 +9,7 @@ use foundry_evm_core::constants::MAGIC_SKIP; pub(crate) mod assert; pub(crate) mod assume; pub(crate) mod expect; +pub(crate) mod revert_handlers; impl Cheatcode for breakpoint_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { diff --git a/crates/cheatcodes/src/test/assume.rs b/crates/cheatcodes/src/test/assume.rs index a0321b5a1cd38..74bd79e0964b6 100644 --- a/crates/cheatcodes/src/test/assume.rs +++ b/crates/cheatcodes/src/test/assume.rs @@ -1,12 +1,46 @@ use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result}; +use alloy_primitives::Address; use foundry_evm_core::constants::MAGIC_ASSUME; -use spec::Vm::{assumeCall, assumeNoRevertCall}; +use spec::Vm::{ + assumeCall, assumeNoRevert_0Call, assumeNoRevert_1Call, assumeNoRevert_2Call, PotentialRevert, +}; use std::fmt::Debug; #[derive(Clone, Debug)] pub struct AssumeNoRevert { /// The call depth at which the cheatcode was added. pub depth: u64, + /// Acceptable revert parameters for the next call, to be thrown out if they are encountered; + /// reverts with parameters not specified here will count as normal reverts and not rejects + /// towards the counter. + pub reasons: Vec, + /// Address that reverted the call. + pub reverted_by: Option
, +} + +/// Parameters for a single anticipated revert, to be thrown out if encountered. +#[derive(Clone, Debug)] +pub struct AcceptableRevertParameters { + /// The expected revert data returned by the revert + pub reason: Vec, + /// If true then only the first 4 bytes of expected data returned by the revert are checked. + pub partial_match: bool, + /// Contract expected to revert next call. + pub reverter: Option
, +} + +impl AcceptableRevertParameters { + fn from(potential_revert: &PotentialRevert) -> Self { + Self { + reason: potential_revert.revertData.to_vec(), + partial_match: potential_revert.partialMatch, + reverter: if potential_revert.reverter == Address::ZERO { + None + } else { + Some(potential_revert.reverter) + }, + } + } } impl Cheatcode for assumeCall { @@ -20,10 +54,45 @@ impl Cheatcode for assumeCall { } } -impl Cheatcode for assumeNoRevertCall { +impl Cheatcode for assumeNoRevert_0Call { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - ccx.state.assume_no_revert = - Some(AssumeNoRevert { depth: ccx.ecx.journaled_state.depth() }); - Ok(Default::default()) + assume_no_revert(ccx.state, ccx.ecx.journaled_state.depth(), vec![]) } } + +impl Cheatcode for assumeNoRevert_1Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { potentialRevert } = self; + assume_no_revert( + ccx.state, + ccx.ecx.journaled_state.depth(), + vec![AcceptableRevertParameters::from(potentialRevert)], + ) + } +} + +impl Cheatcode for assumeNoRevert_2Call { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { potentialReverts } = self; + assume_no_revert( + ccx.state, + ccx.ecx.journaled_state.depth(), + potentialReverts.iter().map(AcceptableRevertParameters::from).collect(), + ) + } +} + +fn assume_no_revert( + state: &mut Cheatcodes, + depth: u64, + parameters: Vec, +) -> Result { + ensure!( + state.assume_no_revert.is_none(), + "you must make another external call prior to calling assumeNoRevert again" + ); + + state.assume_no_revert = Some(AssumeNoRevert { depth, reasons: parameters, reverted_by: None }); + + Ok(Default::default()) +} diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index e45298923cd69..f77eb4d402cff 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -2,29 +2,12 @@ use std::collections::VecDeque; use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result, Vm::*}; use alloy_primitives::{ - address, hex, map::{hash_map::Entry, AddressHashMap, HashMap}, Address, Bytes, LogData as RawLog, U256, }; -use alloy_sol_types::{SolError, SolValue}; -use foundry_common::ContractsByArtifact; -use foundry_evm_core::decode::RevertDecoder; -use revm::interpreter::{ - return_ok, InstructionResult, Interpreter, InterpreterAction, InterpreterResult, -}; -use spec::Vm; - -/// For some cheatcodes we may internally change the status of the call, i.e. in `expectRevert`. -/// Solidity will see a successful call and attempt to decode the return data. Therefore, we need -/// to populate the return with dummy bytes so the decode doesn't fail. -/// -/// 8192 bytes was arbitrarily chosen because it is long enough for return values up to 256 words in -/// size. -static DUMMY_CALL_OUTPUT: Bytes = Bytes::from_static(&[0u8; 8192]); - -/// Same reasoning as [DUMMY_CALL_OUTPUT], but for creates. -const DUMMY_CREATE_ADDRESS: Address = address!("0000000000000000000000000000000000000001"); +use revm::interpreter::{InstructionResult, Interpreter, InterpreterAction, InterpreterResult}; +use super::revert_handlers::RevertParameters; /// Tracks the expected calls per address. /// /// For each address, we track the expected calls per call data. We track it in such manner @@ -87,7 +70,7 @@ pub struct ExpectedRevert { pub partial_match: bool, /// Contract expected to revert next call. pub reverter: Option
, - /// Actual reverter of the call. + /// Address that reverted the call. pub reverted_by: Option
, /// Number of times this revert is expected. pub count: u64, @@ -605,6 +588,20 @@ impl Cheatcode for expectSafeMemoryCallCall { } } +impl RevertParameters for ExpectedRevert { + fn reverter(&self) -> Option
{ + self.reverter + } + + fn reason(&self) -> Option<&[u8]> { + self.reason.as_deref() + } + + fn partial_match(&self) -> bool { + self.partial_match + } +} + /// Handles expected calls specified by the `expectCall` cheatcodes. /// /// It can handle calls in two ways: @@ -920,136 +917,6 @@ fn expect_revert( Ok(Default::default()) } -pub(crate) fn handle_expect_revert( - is_cheatcode: bool, - is_create: bool, - expected_revert: &mut ExpectedRevert, - status: InstructionResult, - retdata: Bytes, - known_contracts: &Option, -) -> Result<(Option
, Bytes)> { - let success_return = || { - if is_create { - (Some(DUMMY_CREATE_ADDRESS), Bytes::new()) - } else { - (None, DUMMY_CALL_OUTPUT.clone()) - } - }; - - let stringify = |data: &[u8]| { - if let Ok(s) = String::abi_decode(data, true) { - return s; - } - if data.is_ascii() { - return std::str::from_utf8(data).unwrap().to_owned(); - } - hex::encode_prefixed(data) - }; - - if expected_revert.count == 0 { - if expected_revert.reverter.is_none() && expected_revert.reason.is_none() { - ensure!( - matches!(status, return_ok!()), - "call reverted when it was expected not to revert" - ); - return Ok(success_return()); - } - - // Flags to track if the reason and reverter match. - let mut reason_match = expected_revert.reason.as_ref().map(|_| false); - let mut reverter_match = expected_revert.reverter.as_ref().map(|_| false); - - // Reverter check - if let (Some(expected_reverter), Some(actual_reverter)) = - (expected_revert.reverter, expected_revert.reverted_by) - { - if expected_reverter == actual_reverter { - reverter_match = Some(true); - } - } - - // Reason check - let expected_reason = expected_revert.reason.as_deref(); - if let Some(expected_reason) = expected_reason { - let mut actual_revert: Vec = retdata.into(); - actual_revert = decode_revert(actual_revert); - - if actual_revert == expected_reason { - reason_match = Some(true); - } - }; - - match (reason_match, reverter_match) { - (Some(true), Some(true)) => Err(fmt_err!( - "expected 0 reverts with reason: {}, from address: {}, but got one", - &stringify(expected_reason.unwrap_or_default()), - expected_revert.reverter.unwrap() - )), - (Some(true), None) => Err(fmt_err!( - "expected 0 reverts with reason: {}, but got one", - &stringify(expected_reason.unwrap_or_default()) - )), - (None, Some(true)) => Err(fmt_err!( - "expected 0 reverts from address: {}, but got one", - expected_revert.reverter.unwrap() - )), - _ => Ok(success_return()), - } - } else { - ensure!(!matches!(status, return_ok!()), "next call did not revert as expected"); - - // If expected reverter address is set then check it matches the actual reverter. - if let (Some(expected_reverter), Some(actual_reverter)) = - (expected_revert.reverter, expected_revert.reverted_by) - { - if expected_reverter != actual_reverter { - return Err(fmt_err!( - "Reverter != expected reverter: {} != {}", - actual_reverter, - expected_reverter - )); - } - } - - let expected_reason = expected_revert.reason.as_deref(); - // If None, accept any revert. - let Some(expected_reason) = expected_reason else { - return Ok(success_return()); - }; - - if !expected_reason.is_empty() && retdata.is_empty() { - bail!("call reverted as expected, but without data"); - } - - let mut actual_revert: Vec = retdata.into(); - - // Compare only the first 4 bytes if partial match. - if expected_revert.partial_match && actual_revert.get(..4) == expected_reason.get(..4) { - return Ok(success_return()) - } - - // Try decoding as known errors. - actual_revert = decode_revert(actual_revert); - - if actual_revert == expected_reason || - (is_cheatcode && memchr::memmem::find(&actual_revert, expected_reason).is_some()) - { - Ok(success_return()) - } else { - let (actual, expected) = if let Some(contracts) = known_contracts { - let decoder = RevertDecoder::new().with_abis(contracts.iter().map(|(_, c)| &c.abi)); - ( - &decoder.decode(actual_revert.as_slice(), Some(status)), - &decoder.decode(expected_reason, Some(status)), - ) - } else { - (&stringify(&actual_revert), &stringify(expected_reason)) - }; - Err(fmt_err!("Error != expected error: {} != {}", actual, expected,)) - } - } -} - fn checks_topics_and_data(checks: [bool; 5], expected: &RawLog, log: &RawLog) -> bool { if log.topics().len() != expected.topics().len() { return false @@ -1081,15 +948,3 @@ fn expect_safe_memory(state: &mut Cheatcodes, start: u64, end: u64, depth: u64) offsets.push(start..end); Ok(Default::default()) } - -fn decode_revert(revert: Vec) -> Vec { - if matches!( - revert.get(..4).map(|s| s.try_into().unwrap()), - Some(Vm::CheatcodeError::SELECTOR | alloy_sol_types::Revert::SELECTOR) - ) { - if let Ok(decoded) = Vec::::abi_decode(&revert[4..], false) { - return decoded; - } - } - revert -} diff --git a/crates/cheatcodes/src/test/revert_handlers.rs b/crates/cheatcodes/src/test/revert_handlers.rs new file mode 100644 index 0000000000000..78297b38872aa --- /dev/null +++ b/crates/cheatcodes/src/test/revert_handlers.rs @@ -0,0 +1,234 @@ +use crate::{Error, Result}; +use alloy_primitives::{address, hex, Address, Bytes}; +use alloy_sol_types::{SolError, SolValue}; +use foundry_common::ContractsByArtifact; +use foundry_evm_core::decode::RevertDecoder; +use revm::interpreter::{return_ok, InstructionResult}; +use spec::Vm; + +use super::{ + assume::{AcceptableRevertParameters, AssumeNoRevert}, + expect::ExpectedRevert, +}; + +/// For some cheatcodes we may internally change the status of the call, i.e. in `expectRevert`. +/// Solidity will see a successful call and attempt to decode the return data. Therefore, we need +/// to populate the return with dummy bytes so the decode doesn't fail. +/// +/// 8192 bytes was arbitrarily chosen because it is long enough for return values up to 256 words in +/// size. +static DUMMY_CALL_OUTPUT: Bytes = Bytes::from_static(&[0u8; 8192]); + +/// Same reasoning as [DUMMY_CALL_OUTPUT], but for creates. +const DUMMY_CREATE_ADDRESS: Address = address!("0000000000000000000000000000000000000001"); + +fn stringify(data: &[u8]) -> String { + if let Ok(s) = String::abi_decode(data, true) { + return s; + } + if data.is_ascii() { + return std::str::from_utf8(data).unwrap().to_owned(); + } + hex::encode_prefixed(data) +} + +/// Common parameters for expected or assumed reverts. Allows for code reuse. +pub(crate) trait RevertParameters { + fn reverter(&self) -> Option
; + fn reason(&self) -> Option<&[u8]>; + fn partial_match(&self) -> bool; +} + +impl RevertParameters for AcceptableRevertParameters { + fn reverter(&self) -> Option
{ + self.reverter + } + + fn reason(&self) -> Option<&[u8]> { + Some(&self.reason) + } + + fn partial_match(&self) -> bool { + self.partial_match + } +} + +/// Core logic for handling reverts that may or may not be expected (or assumed). +fn handle_revert( + is_cheatcode: bool, + revert_params: &impl RevertParameters, + status: InstructionResult, + retdata: &Bytes, + known_contracts: &Option, + reverter: Option<&Address>, +) -> Result<(), Error> { + // If expected reverter address is set then check it matches the actual reverter. + if let (Some(expected_reverter), Some(&actual_reverter)) = (revert_params.reverter(), reverter) + { + if expected_reverter != actual_reverter { + return Err(fmt_err!( + "Reverter != expected reverter: {} != {}", + actual_reverter, + expected_reverter + )); + } + } + + let expected_reason = revert_params.reason(); + // If None, accept any revert. + let Some(expected_reason) = expected_reason else { + return Ok(()); + }; + + if !expected_reason.is_empty() && retdata.is_empty() { + bail!("call reverted as expected, but without data"); + } + + let mut actual_revert: Vec = retdata.to_vec(); + + // Compare only the first 4 bytes if partial match. + if revert_params.partial_match() && actual_revert.get(..4) == expected_reason.get(..4) { + return Ok(()); + } + + // Try decoding as known errors. + actual_revert = decode_revert(actual_revert); + + if actual_revert == expected_reason || + (is_cheatcode && memchr::memmem::find(&actual_revert, expected_reason).is_some()) + { + Ok(()) + } else { + let (actual, expected) = if let Some(contracts) = known_contracts { + let decoder = RevertDecoder::new().with_abis(contracts.iter().map(|(_, c)| &c.abi)); + ( + &decoder.decode(actual_revert.as_slice(), Some(status)), + &decoder.decode(expected_reason, Some(status)), + ) + } else { + (&stringify(&actual_revert), &stringify(expected_reason)) + }; + Err(fmt_err!("Error != expected error: {} != {}", actual, expected,)) + } +} + +pub(crate) fn handle_assume_no_revert( + assume_no_revert: &AssumeNoRevert, + status: InstructionResult, + retdata: &Bytes, + known_contracts: &Option, +) -> Result<()> { + // if a generic AssumeNoRevert, return Ok(). Otherwise, iterate over acceptable reasons and try + // to match against any, otherwise, return an Error with the revert data + if assume_no_revert.reasons.is_empty() { + Ok(()) + } else { + assume_no_revert + .reasons + .iter() + .find_map(|reason| { + handle_revert( + false, + reason, + status, + retdata, + known_contracts, + assume_no_revert.reverted_by.as_ref(), + ) + .ok() + }) + .ok_or_else(|| retdata.clone().into()) + } +} + +pub(crate) fn handle_expect_revert( + is_cheatcode: bool, + is_create: bool, + expected_revert: &ExpectedRevert, + status: InstructionResult, + retdata: Bytes, + known_contracts: &Option, +) -> Result<(Option
, Bytes)> { + let success_return = || { + if is_create { + (Some(DUMMY_CREATE_ADDRESS), Bytes::new()) + } else { + (None, DUMMY_CALL_OUTPUT.clone()) + } + }; + + if expected_revert.count == 0 { + if expected_revert.reverter.is_none() && expected_revert.reason.is_none() { + ensure!( + matches!(status, return_ok!()), + "call reverted when it was expected not to revert" + ); + return Ok(success_return()); + } + + // Flags to track if the reason and reverter match. + let mut reason_match = expected_revert.reason.as_ref().map(|_| false); + let mut reverter_match = expected_revert.reverter.as_ref().map(|_| false); + + // Reverter check + if let (Some(expected_reverter), Some(actual_reverter)) = + (expected_revert.reverter, expected_revert.reverted_by) + { + if expected_reverter == actual_reverter { + reverter_match = Some(true); + } + } + + // Reason check + let expected_reason = expected_revert.reason.as_deref(); + if let Some(expected_reason) = expected_reason { + let mut actual_revert: Vec = retdata.into(); + actual_revert = decode_revert(actual_revert); + + if actual_revert == expected_reason { + reason_match = Some(true); + } + }; + + match (reason_match, reverter_match) { + (Some(true), Some(true)) => Err(fmt_err!( + "expected 0 reverts with reason: {}, from address: {}, but got one", + &stringify(expected_reason.unwrap_or_default()), + expected_revert.reverter.unwrap() + )), + (Some(true), None) => Err(fmt_err!( + "expected 0 reverts with reason: {}, but got one", + &stringify(expected_reason.unwrap_or_default()) + )), + (None, Some(true)) => Err(fmt_err!( + "expected 0 reverts from address: {}, but got one", + expected_revert.reverter.unwrap() + )), + _ => Ok(success_return()), + } + } else { + ensure!(!matches!(status, return_ok!()), "next call did not revert as expected"); + + handle_revert( + is_cheatcode, + expected_revert, + status, + &retdata, + known_contracts, + expected_revert.reverted_by.as_ref(), + )?; + Ok(success_return()) + } +} + +fn decode_revert(revert: Vec) -> Vec { + if matches!( + revert.get(..4).map(|s| s.try_into().unwrap()), + Some(Vm::CheatcodeError::SELECTOR | alloy_sol_types::Revert::SELECTOR) + ) { + if let Ok(decoded) = Vec::::abi_decode(&revert[4..], false) { + return decoded; + } + } + revert +} diff --git a/crates/forge/tests/cli/test.sol b/crates/forge/tests/cli/test.sol new file mode 100644 index 0000000000000..0b44c7aa75b4c --- /dev/null +++ b/crates/forge/tests/cli/test.sol @@ -0,0 +1,129 @@ +import {Test} from "forge-std/Test.sol"; + +interface Vm { + struct PotentialRevert { + bytes revertData; + bool partialMatch; + address reverter; + } + function expectRevert() external; + function assumeNoRevert() external pure; + function assumeNoRevert(bytes4 revertData) external pure; + function assumeNoRevert(bytes calldata revertData) external pure; + function assumeNoRevert(bytes4 revertData, address reverter) external pure; + function assumeNoRevert(bytes calldata revertData, address reverter) external pure; +} + +contract ReverterB { + /// @notice has same error selectors as contract below to test the `reverter` param + error MyRevert(); + error SpecialRevertWithData(uint256 x); + + function revertIf2(uint256 x) public pure returns (bool) { + if (x == 2) { + revert MyRevert(); + } + return true; + } + + function revertWithData() public pure returns (bool) { + revert SpecialRevertWithData(2); + } +} + +contract Reverter { + error MyRevert(); + error RevertWithData(uint256 x); + error UnusedError(); + + ReverterB public immutable subReverter; + + constructor() { + subReverter = new ReverterB(); + } + + function myFunction() public pure returns (bool) { + revert MyRevert(); + } + + function revertIf2(uint256 value) public pure returns (bool) { + if (value == 2) { + revert MyRevert(); + } + return true; + } + + function revertWithDataIf2(uint256 value) public pure returns (bool) { + if (value == 2) { + revert RevertWithData(2); + } + return true; + } + + function twoPossibleReverts(uint256 x) public pure returns (bool) { + if (x == 2) { + revert MyRevert(); + } else if (x == 3) { + revert RevertWithData(3); + } + return true; + } +} + +contract ReverterTest is Test { + Reverter reverter; + Vm _vm = Vm(VM_ADDRESS); + + function setUp() public { + reverter = new Reverter(); + } + + /// @dev Test that `assumeNoRevert` does not reject an unanticipated error selector + function testAssume_wrongSelector_fails(uint256 x) public view { + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.UnusedError.selector), partialMatch: false, reverter: address(0)})); + reverter.revertIf2(x); + } + + /// @dev Test that `assumeNoRevert` does not reject an unanticipated error with extra data + function testAssume_wrongData_fails(uint256 x) public view { + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 3), partialMatch: false, reverter: address(0)})); + reverter.revertWithDataIf2(x); + } + + /// @dev Test that `assumeNoRevert` correctly rejects an error selector from a different contract + function testAssumeWithReverter_fails(uint256 x) public view { + ReverterB subReverter = (reverter.subReverter()); + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(reverter)})); + subReverter.revertIf2(x); + } + + /// @dev Test that `assumeNoRevert` correctly rejects one of two different error selectors when supplying a specific reverter + function testMultipleAssumes_OneWrong_fails(uint256 x) public view { + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(reverter)})); + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 4), partialMatch: false, reverter: address(reverter)})); + reverter.twoPossibleReverts(x); + } + + /// @dev Test that `assumeNoRevert` assumptions are cleared after the first non-cheatcode external call + function testMultipleAssumesClearAfterCall_fails(uint256 x) public view { + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(0)})); + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 4), partialMatch: false, reverter: address(reverter)})); + reverter.twoPossibleReverts(x); + + reverter.twoPossibleReverts(2); + } + + /// @dev Test that `assumeNoRevert` correctly rejects a generic assumeNoRevert call after any specific reason is provided + function testMultipleAssumes_ThrowOnGenericNoRevert_AfterSpecific_fails(bytes4 selector) public view { + _vm.assumeNoRevert(PotentialRevert({revertData: selector, partialMatch: false, reverter: address(0)})); + _vm.assumeNoRevert(); + reverter.twoPossibleReverts(2); + } + + /// @dev Test that calling `expectRevert` after `assumeNoRevert` results in an error + function testAssumeThenExpect_fails(uint256) public { + _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(0)})); + _vm.expectRevert(); + reverter.revertIf2(1); + } +} diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 283be9a70d53b..2a69ba0001f0a 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2449,6 +2449,197 @@ contract Dummy { assert!(dump_path.exists()); }); +forgetest_init!(test_assume_no_revert_with_data, |prj, cmd| { + let config = Config { + fuzz: { FuzzConfig { runs: 60, seed: Some(U256::from(100)), ..Default::default() } }, + ..Default::default() + }; + prj.write_config(config); + + prj.add_source( + "AssumeNoRevertTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +interface Vm { + struct PotentialRevert { + address reverter; + bool partialMatch; + bytes revertData; + } + function expectRevert() external; + function assumeNoRevert() external pure; + function assumeNoRevert(PotentialRevert calldata revertData) external pure; + function assumeNoRevert(PotentialRevert[] calldata revertData) external pure; + function expectRevert(bytes4 revertData, uint64 count) external; +} + +contract ReverterB { + /// @notice has same error selectors as contract below to test the `reverter` param + error MyRevert(); + error SpecialRevertWithData(uint256 x); + + function revertIf2(uint256 x) public pure returns (bool) { + if (x == 2) { + revert MyRevert(); + } + return true; + } + + function revertWithData() public pure returns (bool) { + revert SpecialRevertWithData(2); + } +} + +contract Reverter { + error MyRevert(); + error RevertWithData(uint256 x); + error UnusedError(); + error ExpectedRevertCountZero(); + + ReverterB public immutable subReverter; + + constructor() { + subReverter = new ReverterB(); + } + + function myFunction() public pure returns (bool) { + revert MyRevert(); + } + + function revertIf2(uint256 value) public pure returns (bool) { + if (value == 2) { + revert MyRevert(); + } + return true; + } + + function revertWithDataIf2(uint256 value) public pure returns (bool) { + if (value == 2) { + revert RevertWithData(2); + } + return true; + } + + function twoPossibleReverts(uint256 x) public pure returns (bool) { + if (x == 2) { + revert MyRevert(); + } else if (x == 3) { + revert RevertWithData(3); + } + return true; + } + + function revertIf2Or3ExpectedRevertZero(uint256 x) public pure returns (bool) { + if (x == 2) { + revert ExpectedRevertCountZero(); + } else if (x == 3) { + revert MyRevert(); + } + return true; + } +} + +contract ReverterTest is Test { + Reverter reverter; + Vm _vm = Vm(VM_ADDRESS); + + function setUp() public { + reverter = new Reverter(); + } + + /// @dev Test that `assumeNoRevert` does not reject an unanticipated error selector + function testAssume_wrongSelector_fails(uint256 x) public view { + _vm.assumeNoRevert(Vm.PotentialRevert({revertData: abi.encodeWithSelector(Reverter.UnusedError.selector), partialMatch: false, reverter: address(0)})); + reverter.revertIf2(x); + } + + /// @dev Test that `assumeNoRevert` does not reject an unanticipated error with extra data + function testAssume_wrongData_fails(uint256 x) public view { + _vm.assumeNoRevert(Vm.PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 3), partialMatch: false, reverter: address(0)})); + reverter.revertWithDataIf2(x); + } + + /// @dev Test that `assumeNoRevert` correctly rejects an error selector from a different contract + function testAssumeWithReverter_fails(uint256 x) public view { + ReverterB subReverter = (reverter.subReverter()); + _vm.assumeNoRevert(Vm.PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(reverter)})); + subReverter.revertIf2(x); + } + + /// @dev Test that `assumeNoRevert` correctly rejects one of two different error selectors when supplying a specific reverter + function testMultipleAssumes_OneWrong_fails(uint256 x) public view { + Vm.PotentialRevert[] memory revertData = new Vm.PotentialRevert[](2); + revertData[0] = Vm.PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(reverter)}); + revertData[1] = Vm.PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 4), partialMatch: false, reverter: address(reverter)}); + _vm.assumeNoRevert(revertData); + reverter.twoPossibleReverts(x); + } + + /// @dev Test that `assumeNoRevert` assumptions are cleared after the first non-cheatcode external call + function testMultipleAssumesClearAfterCall_fails(uint256 x) public view { + Vm.PotentialRevert[] memory revertData = new Vm.PotentialRevert[](2); + revertData[0] = Vm.PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(0)}); + revertData[1] = Vm.PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 4), partialMatch: false, reverter: address(reverter)}); + _vm.assumeNoRevert(revertData); + reverter.twoPossibleReverts(x); + + reverter.twoPossibleReverts(2); + } + + /// @dev Test that `assumeNoRevert` correctly rejects a generic assumeNoRevert call after any specific reason is provided + function testMultipleAssumes_ThrowOnGenericNoRevert_AfterSpecific_fails(bytes4 selector) public view { + _vm.assumeNoRevert(Vm.PotentialRevert({revertData: abi.encode(selector), partialMatch: false, reverter: address(0)})); + _vm.assumeNoRevert(); + reverter.twoPossibleReverts(2); + } + + function testAssumeThenExpectCountZeroFails(uint256 x) public { + _vm.assumeNoRevert( + Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), + partialMatch: false, + reverter: address(0) + }) + ); + _vm.expectRevert(Reverter.ExpectedRevertCountZero.selector, 0); + reverter.revertIf2Or3ExpectedRevertZero(x); + } + + function testExpectCountZeroThenAssumeFails(uint256 x) public { + _vm.expectRevert(Reverter.ExpectedRevertCountZero.selector, 0); + _vm.assumeNoRevert( + Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), + partialMatch: false, + reverter: address(0) + }) + ); + reverter.revertIf2Or3ExpectedRevertZero(x); + } + +}"#, + ) + .unwrap(); + cmd.args(["test", "--mc", "ReverterTest"]).assert_failure().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 8 tests for src/AssumeNoRevertTest.t.sol:ReverterTest +[FAIL: expected 0 reverts with reason: 0x92fa317b, but got one; counterexample: [..]] testAssumeThenExpectCountZeroFails(uint256) (runs: [..], [AVG_GAS]) +[FAIL: MyRevert(); counterexample: calldata=[..]] testAssumeWithReverter_fails(uint256) (runs: [..], [AVG_GAS]) +[FAIL: RevertWithData(2); counterexample: [..]] testAssume_wrongData_fails(uint256) (runs: [..], [AVG_GAS]) +[FAIL: MyRevert(); counterexample: [..]] testAssume_wrongSelector_fails(uint256) (runs: [..], [AVG_GAS]) +[FAIL: expected 0 reverts with reason: 0x92fa317b, but got one; counterexample: [..]] testExpectCountZeroThenAssumeFails(uint256) (runs: [..], [AVG_GAS]) +[FAIL: MyRevert(); counterexample: [..]] testMultipleAssumesClearAfterCall_fails(uint256) (runs: 0, [AVG_GAS]) +[FAIL: RevertWithData(3); counterexample: [..]] testMultipleAssumes_OneWrong_fails(uint256) (runs: [..], [AVG_GAS]) +[FAIL: vm.assumeNoRevert: you must make another external call prior to calling assumeNoRevert again; counterexample: [..]] testMultipleAssumes_ThrowOnGenericNoRevert_AfterSpecific_fails(bytes4) (runs: [..], [AVG_GAS]) +... + +"#]]); +}); + forgetest_async!(can_get_broadcast_txs, |prj, cmd| { foundry_test_utils::util::initialize(prj.root()); diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index df0cba0111486..6cd8482938181 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -687,24 +687,6 @@ async fn test_invariant_after_invariant() { ); } -#[tokio::test(flavor = "multi_thread")] -async fn test_invariant_selectors_weight() { - let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantSelectorsWeight.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { - config.fuzz.seed = Some(U256::from(119u32)); - config.invariant.runs = 1; - config.invariant.depth = 10; - }); - let results = runner.test_collect(&filter); - assert_multiple( - &results, - BTreeMap::from([( - "default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol:InvariantSelectorsWeightTest", - vec![("invariant_selectors_weight()", true, None, None, None)], - )]), - ) -} - #[tokio::test(flavor = "multi_thread")] async fn test_no_reverts_in_counterexample() { let filter = @@ -1015,3 +997,80 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); }); + +// Tests that selector hits are uniformly distributed +// +forgetest_init!(invariant_selectors_weight, |prj, cmd| { + prj.write_config(Config { + optimizer: Some(true), + invariant: { InvariantConfig { runs: 1, depth: 10, ..Default::default() } }, + ..Default::default() + }); + prj.add_source( + "InvariantHandlers.sol", + r#" +contract HandlerOne { + uint256 public hit1; + + function selector1() external { + hit1 += 1; + } +} + +contract HandlerTwo { + uint256 public hit2; + uint256 public hit3; + uint256 public hit4; + uint256 public hit5; + + function selector2() external { + hit2 += 1; + } + + function selector3() external { + hit3 += 1; + } + + function selector4() external { + hit4 += 1; + } + + function selector5() external { + hit5 += 1; + } +} + "#, + ) + .unwrap(); + + prj.add_test( + "InvariantSelectorsWeightTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; +import "src/InvariantHandlers.sol"; + +contract InvariantSelectorsWeightTest is Test { + HandlerOne handlerOne; + HandlerTwo handlerTwo; + + function setUp() public { + handlerOne = new HandlerOne(); + handlerTwo = new HandlerTwo(); + } + + function afterInvariant() public { + assertEq(handlerOne.hit1(), 2); + assertEq(handlerTwo.hit2(), 2); + assertEq(handlerTwo.hit3(), 3); + assertEq(handlerTwo.hit4(), 1); + assertEq(handlerTwo.hit5(), 2); + } + + function invariant_selectors_weight() public view {} +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--fuzz-seed", "119", "--mt", "invariant_selectors_weight"]).assert_success(); +}); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 260b5bb385600..d1a301e0f3df5 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -24,6 +24,7 @@ interface Vm { 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; } struct SignedDelegation { uint8 v; bytes32 r; bytes32 s; uint64 nonce; address implementation; } + struct PotentialRevert { address reverter; bool partialMatch; bytes revertData; } function _expectCheatcodeRevert() external; function _expectCheatcodeRevert(bytes4 revertData) external; function _expectCheatcodeRevert(bytes calldata revertData) external; @@ -149,6 +150,8 @@ interface Vm { function assertTrue(bool condition, string calldata error) external pure; function assume(bool condition) external pure; function assumeNoRevert() external pure; + function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure; + function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure; function attachDelegation(SignedDelegation calldata signedDelegation) external; function blobBaseFee(uint256 newBlobBaseFee) external; function blobhashes(bytes32[] calldata hashes) external; diff --git a/testdata/default/cheats/AssumeNoRevert.t.sol b/testdata/default/cheats/AssumeNoRevert.t.sol new file mode 100644 index 0000000000000..ea6d2d9747bdd --- /dev/null +++ b/testdata/default/cheats/AssumeNoRevert.t.sol @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import {DSTest as Test} from "ds-test/test.sol"; +import {Vm} from "cheats/Vm.sol"; + +contract ReverterB { + /// @notice has same error selectors as contract below to test the `reverter` param + error MyRevert(); + error SpecialRevertWithData(uint256 x); + + function revertIf2(uint256 x) public pure returns (bool) { + if (x == 2) { + revert MyRevert(); + } + return true; + } + + function revertWithData() public pure returns (bool) { + revert SpecialRevertWithData(2); + } +} + +contract Reverter { + error MyRevert(); + error RevertWithData(uint256 x); + error UnusedError(); + + ReverterB public immutable subReverter; + + constructor() { + subReverter = new ReverterB(); + } + + function myFunction() public pure returns (bool) { + revert MyRevert(); + } + + function revertIf2(uint256 value) public pure returns (bool) { + if (value == 2) { + revert MyRevert(); + } + return true; + } + + function revertWithDataIf2(uint256 value) public pure returns (bool) { + if (value == 2) { + revert RevertWithData(2); + } + return true; + } + + function twoPossibleReverts(uint256 x) public pure returns (bool) { + if (x == 2) { + revert MyRevert(); + } else if (x == 3) { + revert RevertWithData(3); + } + return true; + } +} + +contract ReverterTest is Test { + Reverter reverter; + Vm _vm = Vm(HEVM_ADDRESS); + + function setUp() public { + reverter = new Reverter(); + } + + /// @dev Test that `assumeNoRevert` anticipates and correctly rejects a specific error selector + function testAssumeSelector(uint256 x) public view { + _vm.assumeNoRevert( + Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), + partialMatch: false, + reverter: address(0) + }) + ); + reverter.revertIf2(x); + } + + /// @dev Test that `assumeNoRevert` anticipates and correctly rejects a specific error selector and data + function testAssumeWithDataSingle(uint256 x) public view { + _vm.assumeNoRevert( + Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 2), + partialMatch: false, + reverter: address(0) + }) + ); + reverter.revertWithDataIf2(x); + } + + /// @dev Test that `assumeNoRevert` anticipates and correctly rejects a specific error selector with any extra data (ie providing selector allows for arbitrary extra data) + function testAssumeWithDataPartial(uint256 x) public view { + _vm.assumeNoRevert( + Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector), + partialMatch: true, + reverter: address(0) + }) + ); + reverter.revertWithDataIf2(x); + } + + /// @dev Test that `assumeNoRevert` assumptions are not cleared after a cheatcode call + function testAssumeNotClearedAfterCheatcodeCall(uint256 x) public { + _vm.assumeNoRevert( + Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), + partialMatch: false, + reverter: address(0) + }) + ); + _vm.warp(block.timestamp + 1000); + reverter.revertIf2(x); + } + + /// @dev Test that `assumeNoRevert` correctly rejects two different error selectors + function testMultipleAssumesPasses(uint256 x) public view { + Vm.PotentialRevert[] memory revertData = new Vm.PotentialRevert[](2); + revertData[0] = Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), + partialMatch: false, + reverter: address(reverter) + }); + revertData[1] = Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 3), + partialMatch: false, + reverter: address(reverter) + }); + _vm.assumeNoRevert(revertData); + reverter.twoPossibleReverts(x); + } + + /// @dev Test that `assumeNoRevert` correctly interacts with itself when partially matching on the error selector + function testMultipleAssumes_Partial(uint256 x) public view { + Vm.PotentialRevert[] memory revertData = new Vm.PotentialRevert[](2); + revertData[0] = Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector), + partialMatch: true, + reverter: address(reverter) + }); + revertData[1] = Vm.PotentialRevert({ + revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), + partialMatch: false, + reverter: address(reverter) + }); + _vm.assumeNoRevert(revertData); + reverter.twoPossibleReverts(x); + } +} diff --git a/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol b/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol deleted file mode 100644 index aea46f41859b0..0000000000000 --- a/testdata/default/fuzz/invariant/common/InvariantSelectorsWeight.t.sol +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import "ds-test/test.sol"; - -contract HandlerOne { - uint256 public hit1; - - function selector1() external { - hit1 += 1; - } -} - -contract HandlerTwo { - uint256 public hit2; - uint256 public hit3; - uint256 public hit4; - uint256 public hit5; - - function selector2() external { - hit2 += 1; - } - - function selector3() external { - hit3 += 1; - } - - function selector4() external { - hit4 += 1; - } - - function selector5() external { - hit5 += 1; - } -} - -contract InvariantSelectorsWeightTest is DSTest { - HandlerOne handlerOne; - HandlerTwo handlerTwo; - - function setUp() public { - handlerOne = new HandlerOne(); - handlerTwo = new HandlerTwo(); - } - - function afterInvariant() public { - // selector hits uniformly distributed, see https://github.com/foundry-rs/foundry/issues/2986 - assertEq(handlerOne.hit1(), 2); - assertEq(handlerTwo.hit2(), 2); - assertEq(handlerTwo.hit3(), 3); - assertEq(handlerTwo.hit4(), 1); - assertEq(handlerTwo.hit5(), 2); - } - - function invariant_selectors_weight() public view {} -} From 36393fb7b7db3898eb6051c6d7dc0c182dfd8a3e Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 22 Jan 2025 03:07:10 -0500 Subject: [PATCH 1878/1963] fix: use custom build profile in --version (#9733) --- crates/common/build.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/common/build.rs b/crates/common/build.rs index acbac73bac108..b5637792876ca 100644 --- a/crates/common/build.rs +++ b/crates/common/build.rs @@ -40,8 +40,9 @@ fn main() -> Result<(), Box> { // Set formatted version strings let pkg_version = env::var("CARGO_PKG_VERSION")?; - // Append the profile to the version string, defaulting to "debug". - let profile = env::var("PROFILE").unwrap_or_else(|_| String::from("debug")); + // Append the profile to the version string + let out_dir = env::var("OUT_DIR").unwrap(); + let profile = out_dir.rsplit(std::path::MAIN_SEPARATOR).nth(3).unwrap(); // Set the build timestamp. let build_timestamp = env::var("VERGEN_BUILD_TIMESTAMP")?; From 9ac89d4842f23b9f462e3b3aad895ac134128f4f Mon Sep 17 00:00:00 2001 From: Delweng Date: Wed, 22 Jan 2025 16:29:47 +0800 Subject: [PATCH 1879/1963] feat(script): show the broadcasted transactions when verbose>=4 (#9655) * feat(script): add --dry-run Signed-off-by: jsvisa * feat(script): implement the tx print Signed-off-by: jsvisa * no newline if no args Signed-off-by: jsvisa * clippy Signed-off-by: jsvisa * add --dry-run --broadcast testcase Signed-off-by: jsvisa * lossy stdout test Signed-off-by: jsvisa * feat(script): print txs if --dry-run Signed-off-by: jsvisa * feat(script): make dry-run as the default behavior Signed-off-by: jsvisa * fix Signed-off-by: jsvisa * use writeln instead of push_str Signed-off-by: jsvisa * implment UIfmt for TransactionMaybeSigned Signed-off-by: jsvisa * dryrun: use UIfmt instead Signed-off-by: jsvisa * dryrun: print contract only if call Signed-off-by: jsvisa * use [..] to test Signed-off-by: jsvisa * update testcase Signed-off-by: jsvisa * feat(script): --dry-run --resume Signed-off-by: jsvisa * no long input Signed-off-by: jsvisa * no double newline Signed-off-by: jsvisa Revert "no double newline" This reverts commit 6337995e4735b7cb2965962d6a7cd29addf367f7. Signed-off-by: jsvisa wip Signed-off-by: jsvisa * print transaction if -vvvv Signed-off-by: jsvisa * Revert "update testcase" This reverts commit ed5201c78e61863a32cec46a5b52c8934ab539d7. Signed-off-by: jsvisa * update test for -vvvv broadcast Signed-off-by: jsvisa * no dryrun module Signed-off-by: jsvisa * test Signed-off-by: jsvisa --------- Signed-off-by: jsvisa Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/common/src/transactions.rs | 39 +++++++++ crates/forge/tests/cli/script.rs | 137 ++++++++++++++++++++++++++++++ crates/script/src/lib.rs | 5 ++ crates/script/src/sequence.rs | 52 +++++++++++- 4 files changed, 231 insertions(+), 2 deletions(-) diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 9148cd6d9a0fd..1f2ea555bfa0f 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -98,6 +98,45 @@ revertReason {}", } } +impl UIfmt for TransactionMaybeSigned { + fn pretty(&self) -> String { + match self { + Self::Signed { tx, .. } => tx.pretty(), + Self::Unsigned(tx) => format!( + " +accessList {} +chainId {} +gasLimit {} +gasPrice {} +input {} +maxFeePerBlobGas {} +maxFeePerGas {} +maxPriorityFeePerGas {} +nonce {} +to {} +type {} +value {}", + tx.access_list + .as_ref() + .map(|a| a.iter().collect::>()) + .unwrap_or_default() + .pretty(), + tx.chain_id.pretty(), + tx.gas_limit().unwrap_or_default(), + tx.gas_price.pretty(), + tx.input.input.pretty(), + tx.max_fee_per_blob_gas.pretty(), + tx.max_fee_per_gas.pretty(), + tx.max_priority_fee_per_gas.pretty(), + tx.nonce.pretty(), + tx.to.as_ref().map(|a| a.to()).unwrap_or_default().pretty(), + tx.transaction_type.unwrap_or_default(), + tx.value.pretty(), + ), + } + } +} + fn extract_revert_reason>(error_string: S) -> Option { let message_substr = "execution reverted: "; error_string diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index de155005e1e6f..a2952ee1d1f68 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2485,3 +2485,140 @@ forgetest_async!(should_set_correct_sender_nonce_via_cli, |prj, cmd| { == Logs == sender nonce 1124703[..]"#]]); }); + +forgetest_async!(dryrun_without_broadcast, |prj, cmd| { + let (_api, handle) = spawn(NodeConfig::test()).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_source( + "Foo", + r#" +import "forge-std/Script.sol"; + +contract Called { + event log_string(string); + uint256 public x; + uint256 public y; + function run(uint256 _x, uint256 _y) external { + x = _x; + y = _y; + emit log_string("script ran"); + } +} + +contract DryRunTest is Script { + function run() external { + vm.startBroadcast(); + Called called = new Called(); + called.run(123, 456); + } +} + "#, + ) + .unwrap(); + + cmd.arg("script") + .args([ + "DryRunTest", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + "-vvvv", + ]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Traces: + [..] DryRunTest::run() + ├─ [0] VM::startBroadcast() + │ └─ ← [Return] + ├─ [..] → new Called@0x5FbDB2315678afecb367f032d93F642f64180aa3 + │ └─ ← [Return] 567 bytes of code + ├─ [..] Called::run(123, 456) + │ ├─ emit log_string(val: "script ran") + │ └─ ← [Stop] + └─ ← [Stop] + + +Script ran successfully. + +== Logs == + script ran + +## Setting up 1 EVM. +========================== +Simulated On-chain Traces: + + [113557] → new Called@0x5FbDB2315678afecb367f032d93F642f64180aa3 + └─ ← [Return] 567 bytes of code + + [46595] Called::run(123, 456) + ├─ emit log_string(val: "script ran") + └─ ← [Stop] + + +========================== + +Chain 31337 + +[ESTIMATED_GAS_PRICE] + +[ESTIMATED_TOTAL_GAS_USED] + +[ESTIMATED_AMOUNT_REQUIRED] + +========================== + +=== Transactions that will be broadcast === + + +Chain 31337 + +### Transaction 1 ### + +accessList [] +chainId 31337 +gasLimit 228247 +gasPrice +input [..] +maxFeePerBlobGas +maxFeePerGas +maxPriorityFeePerGas +nonce 0 +to +type 0 +value 0 + +### Transaction 2 ### + +accessList [] +chainId 31337 +gasLimit 93856 +gasPrice +input 0x7357f5d2000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000001c8 +maxFeePerBlobGas +maxFeePerGas +maxPriorityFeePerGas +nonce 1 +to 0x5FbDB2315678afecb367f032d93F642f64180aa3 +type 0 +value 0 +contract: Called(0x5FbDB2315678afecb367f032d93F642f64180aa3) +data (decoded): run(uint256,uint256)( + 123, + 456 +) + + +SIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more. + +[SAVED_TRANSACTIONS] + +[SAVED_SENSITIVE_VALUES] + + +"#]]); +}); diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 4aa23dae6545f..807ff2a140005 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -303,6 +303,11 @@ impl ScriptArgs { // Exit early in case user didn't provide any broadcast/verify related flags. if !bundled.args.should_broadcast() { if !shell::is_json() { + if shell::verbosity() >= 4 { + sh_println!("\n=== Transactions that will be broadcast ===\n")?; + bundled.sequence.show_transactions()?; + } + sh_println!("\nSIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) to the previous command. See forge script --help for more.")?; } return Ok(()); diff --git a/crates/script/src/sequence.rs b/crates/script/src/sequence.rs index 8bdb35bb33872..adb205a87ed83 100644 --- a/crates/script/src/sequence.rs +++ b/crates/script/src/sequence.rs @@ -1,10 +1,44 @@ use crate::multi_sequence::MultiChainSequence; use eyre::Result; -use forge_script_sequence::ScriptSequence; +use forge_script_sequence::{ScriptSequence, TransactionWithMetadata}; use foundry_cli::utils::Git; +use foundry_common::fmt::UIfmt; use foundry_compilers::ArtifactId; use foundry_config::Config; -use std::path::Path; +use std::{ + fmt::{Error, Write}, + path::Path, +}; + +/// Format transaction details for display +fn format_transaction(index: usize, tx: &TransactionWithMetadata) -> Result { + let mut output = String::new(); + writeln!(output, "### Transaction {index} ###")?; + writeln!(output, "{}", tx.tx().pretty())?; + + // Show contract name and address if available + if !tx.opcode.is_any_create() { + if let (Some(name), Some(addr)) = (&tx.contract_name, &tx.contract_address) { + writeln!(output, "contract: {name}({addr})")?; + } + } + + // Show decoded function if available + if let (Some(func), Some(args)) = (&tx.function, &tx.arguments) { + if args.is_empty() { + writeln!(output, "data (decoded): {func}()")?; + } else { + writeln!(output, "data (decoded): {func}(")?; + for (i, arg) in args.iter().enumerate() { + writeln!(&mut output, " {}{}", arg, if i + 1 < args.len() { "," } else { "" })?; + } + writeln!(output, ")")?; + } + } + + writeln!(output)?; + Ok(output) +} /// Returns the commit hash of the project if it exists pub fn get_commit_hash(root: &Path) -> Option { @@ -57,6 +91,20 @@ impl ScriptSequenceKind { Ok(()) } + + pub fn show_transactions(&self) -> Result<()> { + for sequence in self.sequences() { + if !sequence.transactions.is_empty() { + sh_println!("\nChain {}\n", sequence.chain)?; + + for (i, tx) in sequence.transactions.iter().enumerate() { + sh_print!("{}", format_transaction(i + 1, tx)?)?; + } + } + } + + Ok(()) + } } impl Drop for ScriptSequenceKind { From a3bfdbdc11b2fc229d9cfe7bb8839868767b6ecb Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 22 Jan 2025 10:37:52 +0100 Subject: [PATCH 1880/1963] chore: remove redundant `test.sol` (#9736) remove redundant test.sol, follow up of https://github.com/foundry-rs/foundry/pull/9179 --- crates/forge/tests/cli/test.sol | 129 -------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 crates/forge/tests/cli/test.sol diff --git a/crates/forge/tests/cli/test.sol b/crates/forge/tests/cli/test.sol deleted file mode 100644 index 0b44c7aa75b4c..0000000000000 --- a/crates/forge/tests/cli/test.sol +++ /dev/null @@ -1,129 +0,0 @@ -import {Test} from "forge-std/Test.sol"; - -interface Vm { - struct PotentialRevert { - bytes revertData; - bool partialMatch; - address reverter; - } - function expectRevert() external; - function assumeNoRevert() external pure; - function assumeNoRevert(bytes4 revertData) external pure; - function assumeNoRevert(bytes calldata revertData) external pure; - function assumeNoRevert(bytes4 revertData, address reverter) external pure; - function assumeNoRevert(bytes calldata revertData, address reverter) external pure; -} - -contract ReverterB { - /// @notice has same error selectors as contract below to test the `reverter` param - error MyRevert(); - error SpecialRevertWithData(uint256 x); - - function revertIf2(uint256 x) public pure returns (bool) { - if (x == 2) { - revert MyRevert(); - } - return true; - } - - function revertWithData() public pure returns (bool) { - revert SpecialRevertWithData(2); - } -} - -contract Reverter { - error MyRevert(); - error RevertWithData(uint256 x); - error UnusedError(); - - ReverterB public immutable subReverter; - - constructor() { - subReverter = new ReverterB(); - } - - function myFunction() public pure returns (bool) { - revert MyRevert(); - } - - function revertIf2(uint256 value) public pure returns (bool) { - if (value == 2) { - revert MyRevert(); - } - return true; - } - - function revertWithDataIf2(uint256 value) public pure returns (bool) { - if (value == 2) { - revert RevertWithData(2); - } - return true; - } - - function twoPossibleReverts(uint256 x) public pure returns (bool) { - if (x == 2) { - revert MyRevert(); - } else if (x == 3) { - revert RevertWithData(3); - } - return true; - } -} - -contract ReverterTest is Test { - Reverter reverter; - Vm _vm = Vm(VM_ADDRESS); - - function setUp() public { - reverter = new Reverter(); - } - - /// @dev Test that `assumeNoRevert` does not reject an unanticipated error selector - function testAssume_wrongSelector_fails(uint256 x) public view { - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.UnusedError.selector), partialMatch: false, reverter: address(0)})); - reverter.revertIf2(x); - } - - /// @dev Test that `assumeNoRevert` does not reject an unanticipated error with extra data - function testAssume_wrongData_fails(uint256 x) public view { - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 3), partialMatch: false, reverter: address(0)})); - reverter.revertWithDataIf2(x); - } - - /// @dev Test that `assumeNoRevert` correctly rejects an error selector from a different contract - function testAssumeWithReverter_fails(uint256 x) public view { - ReverterB subReverter = (reverter.subReverter()); - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(reverter)})); - subReverter.revertIf2(x); - } - - /// @dev Test that `assumeNoRevert` correctly rejects one of two different error selectors when supplying a specific reverter - function testMultipleAssumes_OneWrong_fails(uint256 x) public view { - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(reverter)})); - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 4), partialMatch: false, reverter: address(reverter)})); - reverter.twoPossibleReverts(x); - } - - /// @dev Test that `assumeNoRevert` assumptions are cleared after the first non-cheatcode external call - function testMultipleAssumesClearAfterCall_fails(uint256 x) public view { - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(0)})); - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.RevertWithData.selector, 4), partialMatch: false, reverter: address(reverter)})); - reverter.twoPossibleReverts(x); - - reverter.twoPossibleReverts(2); - } - - /// @dev Test that `assumeNoRevert` correctly rejects a generic assumeNoRevert call after any specific reason is provided - function testMultipleAssumes_ThrowOnGenericNoRevert_AfterSpecific_fails(bytes4 selector) public view { - _vm.assumeNoRevert(PotentialRevert({revertData: selector, partialMatch: false, reverter: address(0)})); - _vm.assumeNoRevert(); - reverter.twoPossibleReverts(2); - } - - /// @dev Test that calling `expectRevert` after `assumeNoRevert` results in an error - function testAssumeThenExpect_fails(uint256) public { - _vm.assumeNoRevert(PotentialRevert({revertData: abi.encodeWithSelector(Reverter.MyRevert.selector), partialMatch: false, reverter: address(0)})); - _vm.expectRevert(); - reverter.revertIf2(1); - } -} From 712bf5fc97d167ac40002251b9217b084d7ad82d Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:11:30 +0200 Subject: [PATCH 1881/1963] chore: pass and read tag as `CARGO_TAG_NAME` for cross build (#9738) * chore: pass and read tag as CARGO_TAG_NAME for cross build * Nit --- .github/workflows/docker-publish.yml | 6 +++++- .github/workflows/release.yml | 3 +++ crates/common/build.rs | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ba8fc5b552c13..a1015c1ce0f67 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -9,6 +9,10 @@ on: # Trigger without any parameters a proactive rebuild workflow_dispatch: {} workflow_call: + inputs: + tag_name: + required: true + type: string env: REGISTRY: ghcr.io @@ -75,4 +79,4 @@ jobs: echo "LABELS -> ${{ steps.meta.outputs.labels }}" - name: Build and push foundry image - run: make DOCKER_IMAGE_NAME=${{ steps.docker_tagging.outputs.docker_tags }} PROFILE=maxperf docker-build-push + run: make DOCKER_IMAGE_NAME=${{ steps.docker_tagging.outputs.docker_tags }} CARGO_TAG_NAME=${{ inputs.tag_name }} PROFILE=maxperf docker-build-push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83b627d4a663c..b093ba77a283d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,7 +65,10 @@ jobs: release-docker: name: Release Docker + needs: prepare uses: ./.github/workflows/docker-publish.yml + with: + tag_name: ${{ needs.prepare.outputs.tag_name }} release: permissions: diff --git a/crates/common/build.rs b/crates/common/build.rs index b5637792876ca..54890ffdaff0f 100644 --- a/crates/common/build.rs +++ b/crates/common/build.rs @@ -25,7 +25,9 @@ fn main() -> Result<(), Box> { // Set the version suffix and whether the version is a nightly build. // if not on a tag: 0.3.0-dev+ba03de0019.1737036656.debug // if on a tag: 0.3.0-stable+ba03de0019.1737036656.release - let tag_name = env::var("TAG_NAME").unwrap_or_else(|_| String::from("dev")); + let tag_name = env::var("TAG_NAME") + .or_else(|_| env::var("CARGO_TAG_NAME")) + .unwrap_or_else(|_| String::from("dev")); let (is_nightly, version_suffix) = if tag_name.contains("nightly") { (true, "-nightly".to_string()) } else { From 34ab2354e91139c4f86bca4a340936600397968a Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:44:27 +0200 Subject: [PATCH 1882/1963] fix(remappings): ignore conflicting remappings (#9521) * fix(remappings): ignore conflicting remappings * Fix test, redundant remappings are not allowed anymore --- crates/config/src/providers/remappings.rs | 30 +++++++++---- crates/forge/tests/cli/config.rs | 51 +++++++++++++++++++++++ 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/crates/config/src/providers/remappings.rs b/crates/config/src/providers/remappings.rs index 26d3cca8987b2..c6eb55fe99f43 100644 --- a/crates/config/src/providers/remappings.rs +++ b/crates/config/src/providers/remappings.rs @@ -69,7 +69,7 @@ impl Remappings { } /// Push an element to the remappings vector, but only if it's not already present. - pub fn push(&mut self, remapping: Remapping) { + fn push(&mut self, remapping: Remapping) { // Special handling for .sol file remappings, only allow one remapping per source file. if remapping.name.ends_with(".sol") && !remapping.path.ends_with(".sol") { return; @@ -88,7 +88,18 @@ impl Remappings { // @prb/=node_modules/@prb/ as the one being checked, // we want to keep the already existing one, which is the first one. This way we avoid // having to deal with ambiguous paths which is unwanted when autodetecting remappings. - existing.name.starts_with(&remapping.name) && existing.context == remapping.context + // Remappings are added from root of the project down to libraries, so + // we also want to exclude any conflicting remappings added from libraries. For example, + // if we have `@utils/=src/` added in project remappings and `@utils/libraries/=src/` + // added in a dependency, we don't want to add the new one as it conflicts with project + // existing remapping. + let mut existing_name_path = existing.name.clone(); + if !existing_name_path.ends_with('/') { + existing_name_path.push('/') + } + let is_conflicting = remapping.name.starts_with(&existing_name_path) || + existing.name.starts_with(&remapping.name); + is_conflicting && existing.context == remapping.context }) { return; }; @@ -399,8 +410,8 @@ mod tests { remappings.push(Remapping { context: None, - name: "@openzeppelin/".to_string(), - path: "lib/openzeppelin/".to_string(), + name: "@openzeppelin-contracts/".to_string(), + path: "lib/openzeppelin-contracts/".to_string(), }); remappings.push(Remapping { context: None, @@ -415,12 +426,13 @@ mod tests { }); let result = remappings.into_inner(); - assert_eq!(result.len(), 3, "Should have 3 remappings"); - assert!(result.iter().any( - |r| r.name == "@openzeppelin/contracts/" && r.path == "lib/openzeppelin/contracts/" - )); - assert!(result.iter().any(|r| r.name == "MyContract.sol" && r.path == "os/Contract.sol")); + assert_eq!(result.first().unwrap().name, "@openzeppelin-contracts/"); + assert_eq!(result.first().unwrap().path, "lib/openzeppelin-contracts/"); + assert_eq!(result.get(1).unwrap().name, "@openzeppelin/contracts/"); + assert_eq!(result.get(1).unwrap().path, "lib/openzeppelin/contracts/"); + assert_eq!(result.get(2).unwrap().name, "MyContract.sol"); + assert_eq!(result.get(2).unwrap().path, "os/Contract.sol"); } #[test] diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 7e76a9cd76074..fe8a385a4f703 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -641,6 +641,57 @@ forgetest_init!(can_prioritise_closer_lib_remappings, |prj, cmd| { ); }); +// Test that remappings within root of the project have priority over remappings of sub-projects. +// E.g. `@utils/libraries` mapping from library shouldn't be added if project already has `@utils` +// remapping. +// See +// Test that +// - project defined `@openzeppelin/contracts` remapping is added +// - library defined `@openzeppelin/contracts-upgradeable` remapping is added +// - library defined `@openzeppelin/contracts/upgradeable` remapping is not added as it conflicts +// with project defined `@openzeppelin/contracts` remapping +// See +forgetest_init!(can_prioritise_project_remappings, |prj, cmd| { + let mut config = cmd.config(); + // Add `@utils/` remapping in project config. + config.remappings = vec![ + Remapping::from_str("@utils/=src/").unwrap().into(), + Remapping::from_str("@openzeppelin/contracts=lib/openzeppelin-contracts/").unwrap().into(), + ]; + let proj_toml_file = prj.paths().root.join("foundry.toml"); + pretty_err(&proj_toml_file, fs::write(&proj_toml_file, config.to_string_pretty().unwrap())); + + // Create a new lib in the `lib` folder with conflicting `@utils/libraries` remapping. + // This should be filtered out from final remappings as root project already has `@utils/`. + let nested = prj.paths().libraries[0].join("dep1"); + pretty_err(&nested, fs::create_dir_all(&nested)); + let mut lib_config = Config::load_with_root(&nested).unwrap(); + lib_config.remappings = vec![ + Remapping::from_str("@utils/libraries/=src/").unwrap().into(), + Remapping::from_str("@openzeppelin/contracts-upgradeable/=lib/openzeppelin-upgradeable/") + .unwrap() + .into(), + Remapping::from_str( + "@openzeppelin/contracts/upgradeable/=lib/openzeppelin-contracts/upgradeable/", + ) + .unwrap() + .into(), + ]; + let lib_toml_file = nested.join("foundry.toml"); + pretty_err(&lib_toml_file, fs::write(&lib_toml_file, lib_config.to_string_pretty().unwrap())); + + cmd.args(["remappings", "--pretty"]).assert_success().stdout_eq(str![[r#" +Global: +- @utils/=src/ +- @openzeppelin/contracts/=lib/openzeppelin-contracts/ +- @openzeppelin/contracts-upgradeable/=lib/dep1/lib/openzeppelin-upgradeable/ +- dep1/=lib/dep1/src/ +- forge-std/=lib/forge-std/src/ + + +"#]]); +}); + // test to check that foundry.toml libs section updates on install forgetest!(can_update_libs_section, |prj, cmd| { cmd.git_init(); From c22c4cc96b0535cd989ee94b79da1b19d236b8db Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Thu, 23 Jan 2025 14:07:28 +0530 Subject: [PATCH 1883/1963] feat(`forge`): inspect - default to pretty output (#9705) * fix(`forge`): inspect - mk --pretty default * print_table helper * print table method-identifier * print table errors * print errors events * nit * fix * rm pretty * fix * print abi as table * fix test * test * nit * clippy * dedup helpers and tests * fix --- crates/forge/bin/cmd/inspect.rs | 257 ++++++++++++++++++++++++-------- crates/forge/tests/cli/cmd.rs | 176 ++++++++++++++++++++-- 2 files changed, 358 insertions(+), 75 deletions(-) diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index d1836c9bccf97..42ba370b2edc1 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -1,3 +1,4 @@ +use alloy_json_abi::{EventParam, InternalType, JsonAbi, Param}; use alloy_primitives::{hex, keccak256, Address}; use clap::Parser; use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Table}; @@ -17,7 +18,8 @@ use foundry_compilers::{ utils::canonicalize, }; use regex::Regex; -use std::{fmt, sync::LazyLock}; +use serde_json::{Map, Value}; +use std::{collections::BTreeMap, fmt, sync::LazyLock}; /// CLI arguments for `forge inspect`. #[derive(Clone, Debug, Parser)] @@ -29,10 +31,6 @@ pub struct InspectArgs { #[arg(value_enum)] pub field: ContractArtifactField, - /// Pretty print the selected field, if supported. - #[arg(long)] - pub pretty: bool, - /// All build arguments are supported #[command(flatten)] build: BuildOpts, @@ -40,7 +38,7 @@ pub struct InspectArgs { impl InspectArgs { pub fn run(self) -> Result<()> { - let Self { contract, field, build, pretty } = self; + let Self { contract, field, build } = self; trace!(target: "forge", ?field, ?contract, "running forge inspect"); @@ -85,12 +83,7 @@ impl InspectArgs { .abi .as_ref() .ok_or_else(|| eyre::eyre!("Failed to fetch lossless ABI"))?; - if pretty { - let source = foundry_cli::utils::abi_to_solidity(abi, &contract.name)?; - sh_println!("{source}")?; - } else { - print_json(abi)?; - } + print_abi(abi)?; } ContractArtifactField::Bytecode => { print_json_str(&artifact.bytecode, Some("object"))?; @@ -105,7 +98,7 @@ impl InspectArgs { print_json_str(&artifact.legacy_assembly, None)?; } ContractArtifactField::MethodIdentifiers => { - print_json(&artifact.method_identifiers)?; + print_method_identifiers(&artifact.method_identifiers)?; } ContractArtifactField::GasEstimates => { print_json(&artifact.gas_estimates)?; @@ -117,10 +110,10 @@ impl InspectArgs { print_json(&artifact.devdoc)?; } ContractArtifactField::Ir => { - print_yul(artifact.ir.as_deref(), self.pretty)?; + print_yul(artifact.ir.as_deref())?; } ContractArtifactField::IrOptimized => { - print_yul(artifact.ir_optimized.as_deref(), self.pretty)?; + print_yul(artifact.ir_optimized.as_deref())?; } ContractArtifactField::Metadata => { print_json(&artifact.metadata)?; @@ -132,37 +125,12 @@ impl InspectArgs { print_json_str(&artifact.ewasm, None)?; } ContractArtifactField::Errors => { - let mut out = serde_json::Map::new(); - if let Some(abi) = &artifact.abi { - let abi = &abi; - // Print the signature of all errors. - for er in abi.errors.iter().flat_map(|(_, errors)| errors) { - let types = er.inputs.iter().map(|p| p.ty.clone()).collect::>(); - let sig = format!("{:x}", er.selector()); - let sig_trimmed = &sig[0..8]; - out.insert( - format!("{}({})", er.name, types.join(",")), - sig_trimmed.to_string().into(), - ); - } - } - print_json(&out)?; + let out = artifact.abi.as_ref().map_or(Map::new(), parse_errors); + print_errors_events(&out, true)?; } ContractArtifactField::Events => { - let mut out = serde_json::Map::new(); - if let Some(abi) = &artifact.abi { - let abi = &abi; - // Print the topic of all events including anonymous. - for ev in abi.events.iter().flat_map(|(_, events)| events) { - let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::>(); - let topic = hex::encode(keccak256(ev.signature())); - out.insert( - format!("{}({})", ev.name, types.join(",")), - format!("0x{topic}").into(), - ); - } - } - print_json(&out)?; + let out = artifact.abi.as_ref().map_or(Map::new(), parse_events); + print_errors_events(&out, false)?; } ContractArtifactField::Eof => { print_eof(artifact.deployed_bytecode.and_then(|b| b.bytecode))?; @@ -176,6 +144,127 @@ impl InspectArgs { } } +fn parse_errors(abi: &JsonAbi) -> Map { + let mut out = serde_json::Map::new(); + for er in abi.errors.iter().flat_map(|(_, errors)| errors) { + let types = get_ty_sig(&er.inputs); + let sig = format!("{:x}", er.selector()); + let sig_trimmed = &sig[0..8]; + out.insert(format!("{}({})", er.name, types), sig_trimmed.to_string().into()); + } + out +} + +fn parse_events(abi: &JsonAbi) -> Map { + let mut out = serde_json::Map::new(); + for ev in abi.events.iter().flat_map(|(_, events)| events) { + let types = parse_event_params(&ev.inputs); + let topic = hex::encode(keccak256(ev.signature())); + out.insert(format!("{}({})", ev.name, types), format!("0x{topic}").into()); + } + out +} + +fn parse_event_params(ev_params: &[EventParam]) -> String { + ev_params + .iter() + .map(|p| { + if let Some(ty) = p.internal_type() { + return internal_ty(ty) + } + p.ty.clone() + }) + .collect::>() + .join(",") +} + +fn print_abi(abi: &JsonAbi) -> Result<()> { + if shell::is_json() { + return print_json(abi) + } + + let headers = vec![Cell::new("Type"), Cell::new("Signature"), Cell::new("Selector")]; + print_table(headers, |table| { + // Print events + for ev in abi.events.iter().flat_map(|(_, events)| events) { + let types = parse_event_params(&ev.inputs); + let selector = ev.selector().to_string(); + table.add_row(["event", &format!("{}({})", ev.name, types), &selector]); + } + + // Print errors + for er in abi.errors.iter().flat_map(|(_, errors)| errors) { + let selector = er.selector().to_string(); + table.add_row([ + "error", + &format!("{}({})", er.name, get_ty_sig(&er.inputs)), + &selector, + ]); + } + + // Print functions + for func in abi.functions.iter().flat_map(|(_, f)| f) { + let selector = func.selector().to_string(); + let state_mut = func.state_mutability.as_json_str(); + let func_sig = if !func.outputs.is_empty() { + format!( + "{}({}) {state_mut} returns ({})", + func.name, + get_ty_sig(&func.inputs), + get_ty_sig(&func.outputs) + ) + } else { + format!("{}({}) {state_mut}", func.name, get_ty_sig(&func.inputs)) + }; + table.add_row(["function", &func_sig, &selector]); + } + + if let Some(constructor) = abi.constructor() { + let state_mut = constructor.state_mutability.as_json_str(); + table.add_row([ + "constructor", + &format!("constructor({}) {state_mut}", get_ty_sig(&constructor.inputs)), + "", + ]); + } + + if let Some(fallback) = &abi.fallback { + let state_mut = fallback.state_mutability.as_json_str(); + table.add_row(["fallback", &format!("fallback() {state_mut}"), ""]); + } + + if let Some(receive) = &abi.receive { + let state_mut = receive.state_mutability.as_json_str(); + table.add_row(["receive", &format!("receive() {state_mut}"), ""]); + } + }) +} + +fn get_ty_sig(inputs: &[Param]) -> String { + inputs + .iter() + .map(|p| { + if let Some(ty) = p.internal_type() { + return internal_ty(ty); + } + p.ty.clone() + }) + .collect::>() + .join(",") +} + +fn internal_ty(ty: &InternalType) -> String { + let contract_ty = + |c: &Option, ty: &String| c.clone().map_or(ty.clone(), |c| format!("{c}.{ty}")); + match ty { + InternalType::AddressPayable(addr) => addr.clone(), + InternalType::Contract(contract) => contract.clone(), + InternalType::Enum { contract, ty } => contract_ty(contract, ty), + InternalType::Struct { contract, ty } => contract_ty(contract, ty), + InternalType::Other { contract, ty } => contract_ty(contract, ty), + } +} + pub fn print_storage_layout(storage_layout: Option<&StorageLayout>) -> Result<()> { let Some(storage_layout) = storage_layout else { eyre::bail!("Could not get storage layout"); @@ -185,30 +274,70 @@ pub fn print_storage_layout(storage_layout: Option<&StorageLayout>) -> Result<() return print_json(&storage_layout) } - let mut table = Table::new(); - table.apply_modifier(UTF8_ROUND_CORNERS); - - table.set_header(vec![ + let headers = vec![ Cell::new("Name"), Cell::new("Type"), Cell::new("Slot"), Cell::new("Offset"), Cell::new("Bytes"), Cell::new("Contract"), - ]); - - for slot in &storage_layout.storage { - let storage_type = storage_layout.types.get(&slot.storage_type); - table.add_row([ - slot.label.as_str(), - storage_type.map_or("?", |t| &t.label), - &slot.slot, - &slot.offset.to_string(), - storage_type.map_or("?", |t| &t.number_of_bytes), - &slot.contract, - ]); + ]; + + print_table(headers, |table| { + for slot in &storage_layout.storage { + let storage_type = storage_layout.types.get(&slot.storage_type); + table.add_row([ + slot.label.as_str(), + storage_type.map_or("?", |t| &t.label), + &slot.slot, + &slot.offset.to_string(), + storage_type.map_or("?", |t| &t.number_of_bytes), + &slot.contract, + ]); + } + }) +} + +fn print_method_identifiers(method_identifiers: &Option>) -> Result<()> { + let Some(method_identifiers) = method_identifiers else { + eyre::bail!("Could not get method identifiers"); + }; + + if shell::is_json() { + return print_json(method_identifiers) + } + + let headers = vec![Cell::new("Method"), Cell::new("Identifier")]; + + print_table(headers, |table| { + for (method, identifier) in method_identifiers { + table.add_row([method, identifier]); + } + }) +} + +fn print_errors_events(map: &Map, is_err: bool) -> Result<()> { + if shell::is_json() { + return print_json(map); } + let headers = if is_err { + vec![Cell::new("Error"), Cell::new("Selector")] + } else { + vec![Cell::new("Event"), Cell::new("Topic")] + }; + print_table(headers, |table| { + for (method, selector) in map { + table.add_row([method, selector.as_str().unwrap()]); + } + }) +} + +fn print_table(headers: Vec, add_rows: impl FnOnce(&mut Table)) -> Result<()> { + let mut table = Table::new(); + table.apply_modifier(UTF8_ROUND_CORNERS); + table.set_header(headers); + add_rows(&mut table); sh_println!("\n{table}\n")?; Ok(()) } @@ -407,7 +536,7 @@ fn print_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result<()> Ok(()) } -fn print_yul(yul: Option<&str>, pretty: bool) -> Result<()> { +fn print_yul(yul: Option<&str>) -> Result<()> { let Some(yul) = yul else { eyre::bail!("Could not get IR output"); }; @@ -415,11 +544,7 @@ fn print_yul(yul: Option<&str>, pretty: bool) -> Result<()> { static YUL_COMMENTS: LazyLock = LazyLock::new(|| Regex::new(r"(///.*\n\s*)|(\s*/\*\*.*\*/)").unwrap()); - if pretty { - sh_println!("{}", YUL_COMMENTS.replace_all(yul, ""))?; - } else { - sh_println!("{yul}")?; - } + sh_println!("{}", YUL_COMMENTS.replace_all(yul, ""))?; Ok(()) } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index f0774a36802ab..35a7bd4411a7f 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -3230,19 +3230,177 @@ Compiler run successful! .stdout_eq(str![[r#""{...}""#]].is_json()); }); -// forgetest_init!(can_inspect_counter_pretty, |prj, cmd| { - cmd.args(["inspect", "src/Counter.sol:Counter", "abi", "--pretty"]).assert_success().stdout_eq( - str![[r#" -interface Counter { - function increment() external; - function number() external view returns (uint256); - function setNumber(uint256 newNumber) external; + cmd.args(["inspect", "src/Counter.sol:Counter", "abi"]).assert_success().stdout_eq(str![[r#" + +╭----------+---------------------------------+------------╮ +| Type | Signature | Selector | ++=========================================================+ +| function | increment() nonpayable | 0xd09de08a | +|----------+---------------------------------+------------| +| function | number() view returns (uint256) | 0x8381f58a | +|----------+---------------------------------+------------| +| function | setNumber(uint256) nonpayable | 0x3fb5c1cb | +╰----------+---------------------------------+------------╯ + + +"#]]); +}); + +const CUSTOM_COUNTER: &str = r#" + contract Counter { + uint256 public number; + uint64 public count; + struct MyStruct { + uint64 count; + } + struct ErrWithMsg { + string message; + } + + event Incremented(uint256 newValue); + event Decremented(uint256 newValue); + + error NumberIsZero(); + error CustomErr(ErrWithMsg e); + + constructor(uint256 _number) { + number = _number; + } + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() external { + number++; + } + + function decrement() public payable { + if (number == 0) { + return; + } + number--; + } + + function square() public { + number = number * number; + } + + fallback() external payable { + ErrWithMsg memory err = ErrWithMsg("Fallback function is not allowed"); + revert CustomErr(err); + } + + receive() external payable { + count++; + } + + function setStruct(MyStruct memory s, uint32 b) public { + count = s.count; + } } + "#; +forgetest!(inspect_custom_counter_abi, |prj, cmd| { + prj.add_source("Counter.sol", CUSTOM_COUNTER).unwrap(); + + cmd.args(["inspect", "Counter", "abi"]).assert_success().stdout_eq(str![[r#" + +╭-------------+-----------------------------------------------+--------------------------------------------------------------------╮ +| Type | Signature | Selector | ++==================================================================================================================================+ +| event | Decremented(uint256) | 0xc9118d86370931e39644ee137c931308fa3774f6c90ab057f0c3febf427ef94a | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| event | Incremented(uint256) | 0x20d8a6f5a693f9d1d627a598e8820f7a55ee74c183aa8f1a30e8d4e8dd9a8d84 | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| error | CustomErr(Counter.ErrWithMsg) | 0x0625625a | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| error | NumberIsZero() | 0xde5d32ac | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| function | count() view returns (uint64) | 0x06661abd | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| function | decrement() payable | 0x2baeceb7 | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| function | increment() nonpayable | 0xd09de08a | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| function | number() view returns (uint256) | 0x8381f58a | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| function | setNumber(uint256) nonpayable | 0x3fb5c1cb | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| function | setStruct(Counter.MyStruct,uint32) nonpayable | 0x08ef7366 | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| function | square() nonpayable | 0xd742cb01 | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| constructor | constructor(uint256) nonpayable | | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| fallback | fallback() payable | | +|-------------+-----------------------------------------------+--------------------------------------------------------------------| +| receive | receive() payable | | +╰-------------+-----------------------------------------------+--------------------------------------------------------------------╯ -"#]], - ); +"#]]); +}); + +forgetest!(inspect_custom_counter_events, |prj, cmd| { + prj.add_source("Counter.sol", CUSTOM_COUNTER).unwrap(); + + cmd.args(["inspect", "Counter", "events"]).assert_success().stdout_eq(str![[r#" + +╭----------------------+--------------------------------------------------------------------╮ +| Event | Topic | ++===========================================================================================+ +| Decremented(uint256) | 0xc9118d86370931e39644ee137c931308fa3774f6c90ab057f0c3febf427ef94a | +|----------------------+--------------------------------------------------------------------| +| Incremented(uint256) | 0x20d8a6f5a693f9d1d627a598e8820f7a55ee74c183aa8f1a30e8d4e8dd9a8d84 | +╰----------------------+--------------------------------------------------------------------╯ + + +"#]]); +}); + +forgetest!(inspect_custom_counter_errors, |prj, cmd| { + prj.add_source("Counter.sol", CUSTOM_COUNTER).unwrap(); + + cmd.args(["inspect", "Counter", "errors"]).assert_success().stdout_eq(str![[r#" + +╭-------------------------------+----------╮ +| Error | Selector | ++==========================================+ +| CustomErr(Counter.ErrWithMsg) | 0625625a | +|-------------------------------+----------| +| NumberIsZero() | de5d32ac | +╰-------------------------------+----------╯ + + +"#]]); +}); + +forgetest!(inspect_custom_counter_method_identifiers, |prj, cmd| { + prj.add_source("Counter.sol", CUSTOM_COUNTER).unwrap(); + + cmd.args(["inspect", "Counter", "method-identifiers"]).assert_success().stdout_eq(str![[r#" + +╭----------------------------+------------╮ +| Method | Identifier | ++=========================================+ +| count() | 06661abd | +|----------------------------+------------| +| decrement() | 2baeceb7 | +|----------------------------+------------| +| increment() | d09de08a | +|----------------------------+------------| +| number() | 8381f58a | +|----------------------------+------------| +| setNumber(uint256) | 3fb5c1cb | +|----------------------------+------------| +| setStruct((uint64),uint32) | 08ef7366 | +|----------------------------+------------| +| square() | d742cb01 | +╰----------------------------+------------╯ + + +"#]]); }); // checks that `clean` also works with the "out" value set in Config From b026f7aebf34e82186b8b7c009c8443c7ba8bcb1 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 23 Jan 2025 12:57:32 +0200 Subject: [PATCH 1884/1963] fix(invariant): lookup fuzz interface abi by name or identifier (#9744) --- crates/common/src/contracts.rs | 9 +++++++++ crates/evm/evm/src/executors/invariant/mod.rs | 9 +++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index bccac2f7867c4..9aac912d4f653 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -259,6 +259,15 @@ impl ContractsByArtifact { Ok(contracts.first().cloned()) } + /// Finds abi for contract which has the same contract name or identifier as `id`. + pub fn find_abi_by_name_or_identifier(&self, id: &str) -> Option { + self.iter() + .find(|(artifact, _)| { + artifact.name.split(".").next().unwrap() == id || artifact.identifier() == id + }) + .map(|(_, contract)| contract.abi.clone()) + } + /// Flattens the contracts into functions, events and errors. pub fn flatten(&self) -> (BTreeMap, BTreeMap, JsonAbi) { let mut funcs = BTreeMap::new(); diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 4582e46822a8c..b3ea7a982404c 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -767,8 +767,7 @@ impl<'a> InvariantExecutor<'a> { // Identifiers are specified as an array, so we loop through them. for identifier in artifacts { // Try to find the contract by name or identifier in the project's contracts. - if let Some((_, contract)) = - self.project_contracts.find_by_name_or_identifier(identifier)? + if let Some(abi) = self.project_contracts.find_abi_by_name_or_identifier(identifier) { combined // Check if there's an entry for the given key in the 'combined' map. @@ -776,12 +775,10 @@ impl<'a> InvariantExecutor<'a> { // If the entry exists, extends its ABI with the function list. .and_modify(|entry| { // Extend the ABI's function list with the new functions. - entry.abi.functions.extend(contract.abi.functions.clone()); + entry.abi.functions.extend(abi.functions.clone()); }) // Otherwise insert it into the map. - .or_insert_with(|| { - TargetedContract::new(identifier.to_string(), contract.abi.clone()) - }); + .or_insert_with(|| TargetedContract::new(identifier.to_string(), abi)); } } } From 6d9e61570a934ff4a935f3612bf0b46b90895d6f Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:30:35 +0200 Subject: [PATCH 1885/1963] feat(foundryup): manage custom built versions (#9746) --- foundryup/foundryup | 67 ++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 91d0c86ed6c89..a2f968ff27339 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -4,7 +4,7 @@ set -eo pipefail # NOTE: if you make modifications to this script, please increment the version number. # Major / minor: incremented for each stable release of Foundry. # Patch: incremented for each change between stable releases. -FOUNDRYUP_INSTALLER_VERSION="0.3.1" +FOUNDRYUP_INSTALLER_VERSION="0.3.2" BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} @@ -178,27 +178,8 @@ main() { say 'skipping manpage download: missing "tar"' fi - for bin in "${BINS[@]}"; do - bin_path="$FOUNDRY_BIN_DIR/$bin" - cp $FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG/$bin $bin_path - - # Print installed msg - say "installed - $(ensure "$bin_path" -V)" - - # Check if the default path of the binary is not in FOUNDRY_BIN_DIR - which_path="$(command -v "$bin" || true)" - if [ -n "$which_path" ] && [ "$which_path" != "$bin_path" ]; then - warn "" - cat 1>&2 <&2 < Date: Thu, 23 Jan 2025 18:49:42 +0200 Subject: [PATCH 1886/1963] fix(foundryup): set proper version for use call (#9750) --- foundryup/foundryup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index a2f968ff27339..72429b5b35d0c 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -4,7 +4,7 @@ set -eo pipefail # NOTE: if you make modifications to this script, please increment the version number. # Major / minor: incremented for each stable release of Foundry. # Patch: incremented for each change between stable releases. -FOUNDRYUP_INSTALLER_VERSION="0.3.2" +FOUNDRYUP_INSTALLER_VERSION="0.3.3" BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} @@ -179,6 +179,7 @@ main() { fi # Use newly installed version. + FOUNDRYUP_VERSION=$FOUNDRYUP_TAG use say "done!" From b03dd220acb3d032c36fd68ee635de92d095ca04 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 Jan 2025 11:05:37 +0100 Subject: [PATCH 1887/1963] chore: stop supporting legacy console.sol signatures (#8910) * feat: stop supporting legacy console.sol signatures * chore: update console.sol in tests * Fix test --------- Co-authored-by: grandizzy Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- .github/scripts/format.sh | 4 +- crates/cheatcodes/src/inspector.rs | 4 +- crates/cheatcodes/src/test/assert.rs | 8 +- .../src/{HardhatConsole.json => Console.json} | 0 crates/evm/abi/src/console.py | 40 +- crates/evm/abi/src/console/ds.rs | 83 ++ crates/evm/abi/src/console/hardhat.rs | 56 - crates/evm/abi/src/console/hh.rs | 14 + crates/evm/abi/src/console/mod.rs | 83 +- crates/evm/abi/src/console/patches.rs | 674 --------- crates/evm/abi/src/lib.rs | 3 +- crates/evm/core/src/decode.rs | 4 +- crates/evm/core/src/lib.rs | 4 +- crates/evm/evm/src/inspectors/logs.rs | 77 +- crates/evm/evm/src/inspectors/stack.rs | 4 +- crates/evm/traces/src/decoder/mod.rs | 34 +- crates/forge/tests/cli/test_cmd.rs | 2 +- .../fixtures/SimpleContractTestVerbose.json | 4 +- testdata/default/logs/HardhatLogs.t.sol | 10 +- testdata/default/logs/console.sol | 1245 +++++++++-------- 20 files changed, 805 insertions(+), 1548 deletions(-) rename crates/evm/abi/src/{HardhatConsole.json => Console.json} (100%) create mode 100644 crates/evm/abi/src/console/ds.rs delete mode 100644 crates/evm/abi/src/console/hardhat.rs create mode 100644 crates/evm/abi/src/console/hh.rs delete mode 100644 crates/evm/abi/src/console/patches.rs diff --git a/.github/scripts/format.sh b/.github/scripts/format.sh index aefb4c0ea2b47..9bd1f950fdeaf 100755 --- a/.github/scripts/format.sh +++ b/.github/scripts/format.sh @@ -3,5 +3,5 @@ set -eo pipefail # We have to ignore at shell level because testdata/ is not a valid Foundry project, # so running `forge fmt` with `--root testdata` won't actually check anything -shopt -s extglob -cargo run --bin forge -- fmt "$@" $(find testdata -name '*.sol' ! -name Vm.sol) +cargo run --bin forge -- fmt "$@" \ + $(find testdata -name '*.sol' ! -name Vm.sol ! -name console.sol) diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 3cb74c6ac8550..0ba163f8366cf 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -123,8 +123,8 @@ pub trait CheatcodesExecutor { }) } - fn console_log(&mut self, ccx: &mut CheatsCtxt, message: String) { - self.get_inspector(ccx.state).console_log(message); + fn console_log(&mut self, ccx: &mut CheatsCtxt, msg: &str) { + self.get_inspector(ccx.state).console_log(msg); } /// Returns a mutable reference to the tracing inspector if it is available. diff --git a/crates/cheatcodes/src/test/assert.rs b/crates/cheatcodes/src/test/assert.rs index b4b6652ac2970..a61cc4b2a2ece 100644 --- a/crates/cheatcodes/src/test/assert.rs +++ b/crates/cheatcodes/src/test/assert.rs @@ -1,7 +1,7 @@ use crate::{CheatcodesExecutor, CheatsCtxt, Result, Vm::*}; use alloy_primitives::{hex, I256, U256}; use foundry_evm_core::{ - abi::{format_units_int, format_units_uint}, + abi::console::{format_units_int, format_units_uint}, backend::GLOBAL_FAIL_SLOT, constants::CHEATCODE_ADDRESS, }; @@ -180,16 +180,16 @@ fn handle_assertion_result( match result { Ok(_) => Ok(Default::default()), Err(err) => { - let error_msg = error_msg.unwrap_or("assertion failed").to_string(); + let error_msg = error_msg.unwrap_or("assertion failed"); let msg = if format_error { format!("{error_msg}: {}", error_formatter(&err)) } else { - error_msg + error_msg.to_string() }; if ccx.state.config.assertions_revert { Err(msg.into()) } else { - executor.console_log(ccx, msg); + executor.console_log(ccx, &msg); ccx.ecx.sstore(CHEATCODE_ADDRESS, GLOBAL_FAIL_SLOT, U256::from(1))?; Ok(Default::default()) } diff --git a/crates/evm/abi/src/HardhatConsole.json b/crates/evm/abi/src/Console.json similarity index 100% rename from crates/evm/abi/src/HardhatConsole.json rename to crates/evm/abi/src/Console.json diff --git a/crates/evm/abi/src/console.py b/crates/evm/abi/src/console.py index e0ca8aa8991a0..2e28fece21e42 100755 --- a/crates/evm/abi/src/console.py +++ b/crates/evm/abi/src/console.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# Generates the JSON ABI for console.sol. import json import re @@ -7,12 +8,10 @@ def main(): - if len(sys.argv) < 4: - print( - f"Usage: {sys.argv[0]} " - ) + if len(sys.argv) != 3: + print(f"Usage: {sys.argv[0]} ") sys.exit(1) - [console_file, abi_file, patches_file] = sys.argv[1:4] + [console_file, abi_file] = sys.argv[1:3] # Parse signatures from `console.sol`'s string literals console_sol = open(console_file).read() @@ -41,37 +40,6 @@ def main(): abi = combined["contracts"][":HardhatConsole"]["abi"] open(abi_file, "w").write(json.dumps(abi, separators=(",", ":"), indent=None)) - # Make patches - patches = [] - for raw_sig in raw_sigs: - patched = raw_sig.replace("int", "int256") - if raw_sig != patched: - patches.append([raw_sig, patched]) - - # Generate the Rust patches map - codegen = "[\n" - for [original, patched] in patches: - codegen += f" // `{original}` -> `{patched}`\n" - - original_selector = selector(original) - patched_selector = selector(patched) - codegen += f" // `{original_selector.hex()}` -> `{patched_selector.hex()}`\n" - - codegen += ( - f" ({list(iter(original_selector))}, {list(iter(patched_selector))}),\n" - ) - codegen += "]\n" - open(patches_file, "w").write(codegen) - - -def keccak256(s): - r = subprocess.run(["cast", "keccak256", s], capture_output=True) - return bytes.fromhex(r.stdout.decode("utf8").strip()[2:]) - - -def selector(s): - return keccak256(s)[:4] - if __name__ == "__main__": main() diff --git a/crates/evm/abi/src/console/ds.rs b/crates/evm/abi/src/console/ds.rs new file mode 100644 index 0000000000000..444be0d77dce5 --- /dev/null +++ b/crates/evm/abi/src/console/ds.rs @@ -0,0 +1,83 @@ +//! DSTest log interface. + +use super::{format_units_int, format_units_uint}; +use alloy_primitives::hex; +use alloy_sol_types::sol; +use derive_more::Display; +use itertools::Itertools; + +// TODO: Use `UiFmt` + +sol! { +#[sol(abi)] +#[derive(Display)] +interface Console { + #[display("{val}")] + event log(string val); + + #[display("{}", hex::encode_prefixed(val))] + event logs(bytes val); + + #[display("{val}")] + event log_address(address val); + + #[display("{val}")] + event log_bytes32(bytes32 val); + + #[display("{val}")] + event log_int(int val); + + #[display("{val}")] + event log_uint(uint val); + + #[display("{}", hex::encode_prefixed(val))] + event log_bytes(bytes val); + + #[display("{val}")] + event log_string(string val); + + #[display("[{}]", val.iter().format(", "))] + event log_array(uint256[] val); + + #[display("[{}]", val.iter().format(", "))] + event log_array(int256[] val); + + #[display("[{}]", val.iter().format(", "))] + event log_array(address[] val); + + #[display("{key}: {val}")] + event log_named_address(string key, address val); + + #[display("{key}: {val}")] + event log_named_bytes32(string key, bytes32 val); + + #[display("{key}: {}", format_units_int(val, decimals))] + event log_named_decimal_int(string key, int val, uint decimals); + + #[display("{key}: {}", format_units_uint(val, decimals))] + event log_named_decimal_uint(string key, uint val, uint decimals); + + #[display("{key}: {val}")] + event log_named_int(string key, int val); + + #[display("{key}: {val}")] + event log_named_uint(string key, uint val); + + #[display("{key}: {}", hex::encode_prefixed(val))] + event log_named_bytes(string key, bytes val); + + #[display("{key}: {val}")] + event log_named_string(string key, string val); + + #[display("{key}: [{}]", val.iter().format(", "))] + event log_named_array(string key, uint256[] val); + + #[display("{key}: [{}]", val.iter().format(", "))] + event log_named_array(string key, int256[] val); + + #[display("{key}: [{}]", val.iter().format(", "))] + event log_named_array(string key, address[] val); +} +} + +pub use Console::*; diff --git a/crates/evm/abi/src/console/hardhat.rs b/crates/evm/abi/src/console/hardhat.rs deleted file mode 100644 index 8154c9ff79264..0000000000000 --- a/crates/evm/abi/src/console/hardhat.rs +++ /dev/null @@ -1,56 +0,0 @@ -use alloy_primitives::{map::HashMap, Selector}; -use alloy_sol_types::sol; -use foundry_common_fmt::*; -use foundry_macros::ConsoleFmt; -use std::sync::LazyLock; - -sol!( - #[sol(abi)] - #[derive(ConsoleFmt)] - HardhatConsole, - "src/HardhatConsole.json" -); - -/// Patches the given Hardhat `console` function selector to its ABI-normalized form. -/// -/// See [`HARDHAT_CONSOLE_SELECTOR_PATCHES`] for more details. -pub fn patch_hh_console_selector(input: &mut [u8]) { - if let Some(selector) = hh_console_selector(input) { - input[..4].copy_from_slice(selector.as_slice()); - } -} - -/// Returns the ABI-normalized selector for the given Hardhat `console` function selector. -/// -/// See [`HARDHAT_CONSOLE_SELECTOR_PATCHES`] for more details. -pub fn hh_console_selector(input: &[u8]) -> Option<&'static Selector> { - if let Some(selector) = input.get(..4) { - let selector: &[u8; 4] = selector.try_into().unwrap(); - HARDHAT_CONSOLE_SELECTOR_PATCHES.get(selector).map(Into::into) - } else { - None - } -} - -/// Maps all the `hardhat/console.log` log selectors that use the legacy ABI (`int`, `uint`) to -/// their normalized counterparts (`int256`, `uint256`). -/// -/// `hardhat/console.log` logs its events manually, and in functions that accept integers they're -/// encoded as `abi.encodeWithSignature("log(int)", p0)`, which is not the canonical ABI encoding -/// for `int` that Solidity and [`sol!`] use. -pub static HARDHAT_CONSOLE_SELECTOR_PATCHES: LazyLock> = - LazyLock::new(|| HashMap::from_iter(include!("./patches.rs"))); - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn hardhat_console_patch() { - for (hh, generated) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { - let mut hh = *hh; - patch_hh_console_selector(&mut hh); - assert_eq!(hh, *generated); - } - } -} diff --git a/crates/evm/abi/src/console/hh.rs b/crates/evm/abi/src/console/hh.rs new file mode 100644 index 0000000000000..3f4f6a240d182 --- /dev/null +++ b/crates/evm/abi/src/console/hh.rs @@ -0,0 +1,14 @@ +//! Hardhat `console.sol` interface. + +use alloy_sol_types::sol; +use foundry_common_fmt::*; +use foundry_macros::ConsoleFmt; + +sol!( + #[sol(abi)] + #[derive(ConsoleFmt)] + Console, + "src/Console.json" +); + +pub use Console::*; diff --git a/crates/evm/abi/src/console/mod.rs b/crates/evm/abi/src/console/mod.rs index 9ce96e4cea110..1e2b23d83ff7c 100644 --- a/crates/evm/abi/src/console/mod.rs +++ b/crates/evm/abi/src/console/mod.rs @@ -1,84 +1,7 @@ -use alloy_primitives::{hex, I256, U256}; -use alloy_sol_types::sol; -use derive_more::Display; -use itertools::Itertools; +use alloy_primitives::{I256, U256}; -mod hardhat; -pub use hardhat::*; - -// TODO: Use `UiFmt` - -sol! { -#[sol(abi)] -#[derive(Display)] -interface Console { - #[display("{val}")] - event log(string val); - - #[display("{}", hex::encode_prefixed(val))] - event logs(bytes val); - - #[display("{val}")] - event log_address(address val); - - #[display("{val}")] - event log_bytes32(bytes32 val); - - #[display("{val}")] - event log_int(int val); - - #[display("{val}")] - event log_uint(uint val); - - #[display("{}", hex::encode_prefixed(val))] - event log_bytes(bytes val); - - #[display("{val}")] - event log_string(string val); - - #[display("[{}]", val.iter().format(", "))] - event log_array(uint256[] val); - - #[display("[{}]", val.iter().format(", "))] - event log_array(int256[] val); - - #[display("[{}]", val.iter().format(", "))] - event log_array(address[] val); - - #[display("{key}: {val}")] - event log_named_address(string key, address val); - - #[display("{key}: {val}")] - event log_named_bytes32(string key, bytes32 val); - - #[display("{key}: {}", format_units_int(val, decimals))] - event log_named_decimal_int(string key, int val, uint decimals); - - #[display("{key}: {}", format_units_uint(val, decimals))] - event log_named_decimal_uint(string key, uint val, uint decimals); - - #[display("{key}: {val}")] - event log_named_int(string key, int val); - - #[display("{key}: {val}")] - event log_named_uint(string key, uint val); - - #[display("{key}: {}", hex::encode_prefixed(val))] - event log_named_bytes(string key, bytes val); - - #[display("{key}: {val}")] - event log_named_string(string key, string val); - - #[display("{key}: [{}]", val.iter().format(", "))] - event log_named_array(string key, uint256[] val); - - #[display("{key}: [{}]", val.iter().format(", "))] - event log_named_array(string key, int256[] val); - - #[display("{key}: [{}]", val.iter().format(", "))] - event log_named_array(string key, address[] val); -} -} +pub mod ds; +pub mod hh; pub fn format_units_int(x: &I256, decimals: &U256) -> String { let (sign, x) = x.into_sign_and_abs(); diff --git a/crates/evm/abi/src/console/patches.rs b/crates/evm/abi/src/console/patches.rs deleted file mode 100644 index ad63a9fe6d3da..0000000000000 --- a/crates/evm/abi/src/console/patches.rs +++ /dev/null @@ -1,674 +0,0 @@ -[ - // `log(int)` -> `log(int256)` - // `4e0c1d1d` -> `2d5b6cb9` - ([78, 12, 29, 29], [45, 91, 108, 185]), - // `log(uint)` -> `log(uint256)` - // `f5b1bba9` -> `f82c50f1` - ([245, 177, 187, 169], [248, 44, 80, 241]), - // `log(uint)` -> `log(uint256)` - // `f5b1bba9` -> `f82c50f1` - ([245, 177, 187, 169], [248, 44, 80, 241]), - // `log(int)` -> `log(int256)` - // `4e0c1d1d` -> `2d5b6cb9` - ([78, 12, 29, 29], [45, 91, 108, 185]), - // `log(uint,uint)` -> `log(uint256,uint256)` - // `6c0f6980` -> `f666715a` - ([108, 15, 105, 128], [246, 102, 113, 90]), - // `log(uint,string)` -> `log(uint256,string)` - // `0fa3f345` -> `643fd0df` - ([15, 163, 243, 69], [100, 63, 208, 223]), - // `log(uint,bool)` -> `log(uint256,bool)` - // `1e6dd4ec` -> `1c9d7eb3` - ([30, 109, 212, 236], [28, 157, 126, 179]), - // `log(uint,address)` -> `log(uint256,address)` - // `58eb860c` -> `69276c86` - ([88, 235, 134, 12], [105, 39, 108, 134]), - // `log(string,uint)` -> `log(string,uint256)` - // `9710a9d0` -> `b60e72cc` - ([151, 16, 169, 208], [182, 14, 114, 204]), - // `log(string,int)` -> `log(string,int256)` - // `af7faa38` -> `3ca6268e` - ([175, 127, 170, 56], [60, 166, 38, 142]), - // `log(bool,uint)` -> `log(bool,uint256)` - // `364b6a92` -> `399174d3` - ([54, 75, 106, 146], [57, 145, 116, 211]), - // `log(address,uint)` -> `log(address,uint256)` - // `2243cfa3` -> `8309e8a8` - ([34, 67, 207, 163], [131, 9, 232, 168]), - // `log(uint,uint,uint)` -> `log(uint256,uint256,uint256)` - // `e7820a74` -> `d1ed7a3c` - ([231, 130, 10, 116], [209, 237, 122, 60]), - // `log(uint,uint,string)` -> `log(uint256,uint256,string)` - // `7d690ee6` -> `71d04af2` - ([125, 105, 14, 230], [113, 208, 74, 242]), - // `log(uint,uint,bool)` -> `log(uint256,uint256,bool)` - // `67570ff7` -> `4766da72` - ([103, 87, 15, 247], [71, 102, 218, 114]), - // `log(uint,uint,address)` -> `log(uint256,uint256,address)` - // `be33491b` -> `5c96b331` - ([190, 51, 73, 27], [92, 150, 179, 49]), - // `log(uint,string,uint)` -> `log(uint256,string,uint256)` - // `5b6de83f` -> `37aa7d4c` - ([91, 109, 232, 63], [55, 170, 125, 76]), - // `log(uint,string,string)` -> `log(uint256,string,string)` - // `3f57c295` -> `b115611f` - ([63, 87, 194, 149], [177, 21, 97, 31]), - // `log(uint,string,bool)` -> `log(uint256,string,bool)` - // `46a7d0ce` -> `4ceda75a` - ([70, 167, 208, 206], [76, 237, 167, 90]), - // `log(uint,string,address)` -> `log(uint256,string,address)` - // `1f90f24a` -> `7afac959` - ([31, 144, 242, 74], [122, 250, 201, 89]), - // `log(uint,bool,uint)` -> `log(uint256,bool,uint256)` - // `5a4d9922` -> `20098014` - ([90, 77, 153, 34], [32, 9, 128, 20]), - // `log(uint,bool,string)` -> `log(uint256,bool,string)` - // `8b0e14fe` -> `85775021` - ([139, 14, 20, 254], [133, 119, 80, 33]), - // `log(uint,bool,bool)` -> `log(uint256,bool,bool)` - // `d5ceace0` -> `20718650` - ([213, 206, 172, 224], [32, 113, 134, 80]), - // `log(uint,bool,address)` -> `log(uint256,bool,address)` - // `424effbf` -> `35085f7b` - ([66, 78, 255, 191], [53, 8, 95, 123]), - // `log(uint,address,uint)` -> `log(uint256,address,uint256)` - // `884343aa` -> `5a9b5ed5` - ([136, 67, 67, 170], [90, 155, 94, 213]), - // `log(uint,address,string)` -> `log(uint256,address,string)` - // `ce83047b` -> `63cb41f9` - ([206, 131, 4, 123], [99, 203, 65, 249]), - // `log(uint,address,bool)` -> `log(uint256,address,bool)` - // `7ad0128e` -> `9b6ec042` - ([122, 208, 18, 142], [155, 110, 192, 66]), - // `log(uint,address,address)` -> `log(uint256,address,address)` - // `7d77a61b` -> `bcfd9be0` - ([125, 119, 166, 27], [188, 253, 155, 224]), - // `log(string,uint,uint)` -> `log(string,uint256,uint256)` - // `969cdd03` -> `ca47c4eb` - ([150, 156, 221, 3], [202, 71, 196, 235]), - // `log(string,uint,string)` -> `log(string,uint256,string)` - // `a3f5c739` -> `5970e089` - ([163, 245, 199, 57], [89, 112, 224, 137]), - // `log(string,uint,bool)` -> `log(string,uint256,bool)` - // `f102ee05` -> `ca7733b1` - ([241, 2, 238, 5], [202, 119, 51, 177]), - // `log(string,uint,address)` -> `log(string,uint256,address)` - // `e3849f79` -> `1c7ec448` - ([227, 132, 159, 121], [28, 126, 196, 72]), - // `log(string,string,uint)` -> `log(string,string,uint256)` - // `f362ca59` -> `5821efa1` - ([243, 98, 202, 89], [88, 33, 239, 161]), - // `log(string,bool,uint)` -> `log(string,bool,uint256)` - // `291bb9d0` -> `c95958d6` - ([41, 27, 185, 208], [201, 89, 88, 214]), - // `log(string,address,uint)` -> `log(string,address,uint256)` - // `07c81217` -> `0d26b925` - ([7, 200, 18, 23], [13, 38, 185, 37]), - // `log(bool,uint,uint)` -> `log(bool,uint256,uint256)` - // `3b5c03e0` -> `37103367` - ([59, 92, 3, 224], [55, 16, 51, 103]), - // `log(bool,uint,string)` -> `log(bool,uint256,string)` - // `c8397eb0` -> `c3fc3970` - ([200, 57, 126, 176], [195, 252, 57, 112]), - // `log(bool,uint,bool)` -> `log(bool,uint256,bool)` - // `1badc9eb` -> `e8defba9` - ([27, 173, 201, 235], [232, 222, 251, 169]), - // `log(bool,uint,address)` -> `log(bool,uint256,address)` - // `c4d23507` -> `088ef9d2` - ([196, 210, 53, 7], [8, 142, 249, 210]), - // `log(bool,string,uint)` -> `log(bool,string,uint256)` - // `c0382aac` -> `1093ee11` - ([192, 56, 42, 172], [16, 147, 238, 17]), - // `log(bool,bool,uint)` -> `log(bool,bool,uint256)` - // `b01365bb` -> `12f21602` - ([176, 19, 101, 187], [18, 242, 22, 2]), - // `log(bool,address,uint)` -> `log(bool,address,uint256)` - // `eb704baf` -> `5f7b9afb` - ([235, 112, 75, 175], [95, 123, 154, 251]), - // `log(address,uint,uint)` -> `log(address,uint256,uint256)` - // `8786135e` -> `b69bcaf6` - ([135, 134, 19, 94], [182, 155, 202, 246]), - // `log(address,uint,string)` -> `log(address,uint256,string)` - // `baf96849` -> `a1f2e8aa` - ([186, 249, 104, 73], [161, 242, 232, 170]), - // `log(address,uint,bool)` -> `log(address,uint256,bool)` - // `e54ae144` -> `678209a8` - ([229, 74, 225, 68], [103, 130, 9, 168]), - // `log(address,uint,address)` -> `log(address,uint256,address)` - // `97eca394` -> `7bc0d848` - ([151, 236, 163, 148], [123, 192, 216, 72]), - // `log(address,string,uint)` -> `log(address,string,uint256)` - // `1cdaf28a` -> `67dd6ff1` - ([28, 218, 242, 138], [103, 221, 111, 241]), - // `log(address,bool,uint)` -> `log(address,bool,uint256)` - // `2c468d15` -> `9c4f99fb` - ([44, 70, 141, 21], [156, 79, 153, 251]), - // `log(address,address,uint)` -> `log(address,address,uint256)` - // `6c366d72` -> `17fe6185` - ([108, 54, 109, 114], [23, 254, 97, 133]), - // `log(uint,uint,uint,uint)` -> `log(uint256,uint256,uint256,uint256)` - // `5ca0ad3e` -> `193fb800` - ([92, 160, 173, 62], [25, 63, 184, 0]), - // `log(uint,uint,uint,string)` -> `log(uint256,uint256,uint256,string)` - // `78ad7a0c` -> `59cfcbe3` - ([120, 173, 122, 12], [89, 207, 203, 227]), - // `log(uint,uint,uint,bool)` -> `log(uint256,uint256,uint256,bool)` - // `6452b9cb` -> `c598d185` - ([100, 82, 185, 203], [197, 152, 209, 133]), - // `log(uint,uint,uint,address)` -> `log(uint256,uint256,uint256,address)` - // `e0853f69` -> `fa8185af` - ([224, 133, 63, 105], [250, 129, 133, 175]), - // `log(uint,uint,string,uint)` -> `log(uint256,uint256,string,uint256)` - // `3894163d` -> `5da297eb` - ([56, 148, 22, 61], [93, 162, 151, 235]), - // `log(uint,uint,string,string)` -> `log(uint256,uint256,string,string)` - // `7c032a32` -> `27d8afd2` - ([124, 3, 42, 50], [39, 216, 175, 210]), - // `log(uint,uint,string,bool)` -> `log(uint256,uint256,string,bool)` - // `b22eaf06` -> `7af6ab25` - ([178, 46, 175, 6], [122, 246, 171, 37]), - // `log(uint,uint,string,address)` -> `log(uint256,uint256,string,address)` - // `433285a2` -> `42d21db7` - ([67, 50, 133, 162], [66, 210, 29, 183]), - // `log(uint,uint,bool,uint)` -> `log(uint256,uint256,bool,uint256)` - // `6c647c8c` -> `eb7f6fd2` - ([108, 100, 124, 140], [235, 127, 111, 210]), - // `log(uint,uint,bool,string)` -> `log(uint256,uint256,bool,string)` - // `efd9cbee` -> `a5b4fc99` - ([239, 217, 203, 238], [165, 180, 252, 153]), - // `log(uint,uint,bool,bool)` -> `log(uint256,uint256,bool,bool)` - // `94be3bb1` -> `ab085ae6` - ([148, 190, 59, 177], [171, 8, 90, 230]), - // `log(uint,uint,bool,address)` -> `log(uint256,uint256,bool,address)` - // `e117744f` -> `9a816a83` - ([225, 23, 116, 79], [154, 129, 106, 131]), - // `log(uint,uint,address,uint)` -> `log(uint256,uint256,address,uint256)` - // `610ba8c0` -> `88f6e4b2` - ([97, 11, 168, 192], [136, 246, 228, 178]), - // `log(uint,uint,address,string)` -> `log(uint256,uint256,address,string)` - // `d6a2d1de` -> `6cde40b8` - ([214, 162, 209, 222], [108, 222, 64, 184]), - // `log(uint,uint,address,bool)` -> `log(uint256,uint256,address,bool)` - // `a8e820ae` -> `15cac476` - ([168, 232, 32, 174], [21, 202, 196, 118]), - // `log(uint,uint,address,address)` -> `log(uint256,uint256,address,address)` - // `ca939b20` -> `56a5d1b1` - ([202, 147, 155, 32], [86, 165, 209, 177]), - // `log(uint,string,uint,uint)` -> `log(uint256,string,uint256,uint256)` - // `c0043807` -> `82c25b74` - ([192, 4, 56, 7], [130, 194, 91, 116]), - // `log(uint,string,uint,string)` -> `log(uint256,string,uint256,string)` - // `a2bc0c99` -> `b7b914ca` - ([162, 188, 12, 153], [183, 185, 20, 202]), - // `log(uint,string,uint,bool)` -> `log(uint256,string,uint256,bool)` - // `875a6e2e` -> `691a8f74` - ([135, 90, 110, 46], [105, 26, 143, 116]), - // `log(uint,string,uint,address)` -> `log(uint256,string,uint256,address)` - // `ab7bd9fd` -> `3b2279b4` - ([171, 123, 217, 253], [59, 34, 121, 180]), - // `log(uint,string,string,uint)` -> `log(uint256,string,string,uint256)` - // `76ec635e` -> `b028c9bd` - ([118, 236, 99, 94], [176, 40, 201, 189]), - // `log(uint,string,string,string)` -> `log(uint256,string,string,string)` - // `57dd0a11` -> `21ad0683` - ([87, 221, 10, 17], [33, 173, 6, 131]), - // `log(uint,string,string,bool)` -> `log(uint256,string,string,bool)` - // `12862b98` -> `b3a6b6bd` - ([18, 134, 43, 152], [179, 166, 182, 189]), - // `log(uint,string,string,address)` -> `log(uint256,string,string,address)` - // `cc988aa0` -> `d583c602` - ([204, 152, 138, 160], [213, 131, 198, 2]), - // `log(uint,string,bool,uint)` -> `log(uint256,string,bool,uint256)` - // `a4b48a7f` -> `cf009880` - ([164, 180, 138, 127], [207, 0, 152, 128]), - // `log(uint,string,bool,string)` -> `log(uint256,string,bool,string)` - // `8d489ca0` -> `d2d423cd` - ([141, 72, 156, 160], [210, 212, 35, 205]), - // `log(uint,string,bool,bool)` -> `log(uint256,string,bool,bool)` - // `51bc2bc1` -> `ba535d9c` - ([81, 188, 43, 193], [186, 83, 93, 156]), - // `log(uint,string,bool,address)` -> `log(uint256,string,bool,address)` - // `796f28a0` -> `ae2ec581` - ([121, 111, 40, 160], [174, 46, 197, 129]), - // `log(uint,string,address,uint)` -> `log(uint256,string,address,uint256)` - // `98e7f3f3` -> `e8d3018d` - ([152, 231, 243, 243], [232, 211, 1, 141]), - // `log(uint,string,address,string)` -> `log(uint256,string,address,string)` - // `f898577f` -> `9c3adfa1` - ([248, 152, 87, 127], [156, 58, 223, 161]), - // `log(uint,string,address,bool)` -> `log(uint256,string,address,bool)` - // `f93fff37` -> `90c30a56` - ([249, 63, 255, 55], [144, 195, 10, 86]), - // `log(uint,string,address,address)` -> `log(uint256,string,address,address)` - // `7fa5458b` -> `6168ed61` - ([127, 165, 69, 139], [97, 104, 237, 97]), - // `log(uint,bool,uint,uint)` -> `log(uint256,bool,uint256,uint256)` - // `56828da4` -> `c6acc7a8` - ([86, 130, 141, 164], [198, 172, 199, 168]), - // `log(uint,bool,uint,string)` -> `log(uint256,bool,uint256,string)` - // `e8ddbc56` -> `de03e774` - ([232, 221, 188, 86], [222, 3, 231, 116]), - // `log(uint,bool,uint,bool)` -> `log(uint256,bool,uint256,bool)` - // `d2abc4fd` -> `91a02e2a` - ([210, 171, 196, 253], [145, 160, 46, 42]), - // `log(uint,bool,uint,address)` -> `log(uint256,bool,uint256,address)` - // `4f40058e` -> `88cb6041` - ([79, 64, 5, 142], [136, 203, 96, 65]), - // `log(uint,bool,string,uint)` -> `log(uint256,bool,string,uint256)` - // `915fdb28` -> `2c1d0746` - ([145, 95, 219, 40], [44, 29, 7, 70]), - // `log(uint,bool,string,string)` -> `log(uint256,bool,string,string)` - // `a433fcfd` -> `68c8b8bd` - ([164, 51, 252, 253], [104, 200, 184, 189]), - // `log(uint,bool,string,bool)` -> `log(uint256,bool,string,bool)` - // `346eb8c7` -> `eb928d7f` - ([52, 110, 184, 199], [235, 146, 141, 127]), - // `log(uint,bool,string,address)` -> `log(uint256,bool,string,address)` - // `496e2bb4` -> `ef529018` - ([73, 110, 43, 180], [239, 82, 144, 24]), - // `log(uint,bool,bool,uint)` -> `log(uint256,bool,bool,uint256)` - // `bd25ad59` -> `7464ce23` - ([189, 37, 173, 89], [116, 100, 206, 35]), - // `log(uint,bool,bool,string)` -> `log(uint256,bool,bool,string)` - // `318ae59b` -> `dddb9561` - ([49, 138, 229, 155], [221, 219, 149, 97]), - // `log(uint,bool,bool,bool)` -> `log(uint256,bool,bool,bool)` - // `4e6c5315` -> `b6f577a1` - ([78, 108, 83, 21], [182, 245, 119, 161]), - // `log(uint,bool,bool,address)` -> `log(uint256,bool,bool,address)` - // `5306225d` -> `69640b59` - ([83, 6, 34, 93], [105, 100, 11, 89]), - // `log(uint,bool,address,uint)` -> `log(uint256,bool,address,uint256)` - // `41b5ef3b` -> `078287f5` - ([65, 181, 239, 59], [7, 130, 135, 245]), - // `log(uint,bool,address,string)` -> `log(uint256,bool,address,string)` - // `a230761e` -> `ade052c7` - ([162, 48, 118, 30], [173, 224, 82, 199]), - // `log(uint,bool,address,bool)` -> `log(uint256,bool,address,bool)` - // `91fb1242` -> `454d54a5` - ([145, 251, 18, 66], [69, 77, 84, 165]), - // `log(uint,bool,address,address)` -> `log(uint256,bool,address,address)` - // `86edc10c` -> `a1ef4cbb` - ([134, 237, 193, 12], [161, 239, 76, 187]), - // `log(uint,address,uint,uint)` -> `log(uint256,address,uint256,uint256)` - // `ca9a3eb4` -> `0c9cd9c1` - ([202, 154, 62, 180], [12, 156, 217, 193]), - // `log(uint,address,uint,string)` -> `log(uint256,address,uint256,string)` - // `3ed3bd28` -> `ddb06521` - ([62, 211, 189, 40], [221, 176, 101, 33]), - // `log(uint,address,uint,bool)` -> `log(uint256,address,uint256,bool)` - // `19f67369` -> `5f743a7c` - ([25, 246, 115, 105], [95, 116, 58, 124]), - // `log(uint,address,uint,address)` -> `log(uint256,address,uint256,address)` - // `fdb2ecd4` -> `15c127b5` - ([253, 178, 236, 212], [21, 193, 39, 181]), - // `log(uint,address,string,uint)` -> `log(uint256,address,string,uint256)` - // `a0c414e8` -> `46826b5d` - ([160, 196, 20, 232], [70, 130, 107, 93]), - // `log(uint,address,string,string)` -> `log(uint256,address,string,string)` - // `8d778624` -> `3e128ca3` - ([141, 119, 134, 36], [62, 18, 140, 163]), - // `log(uint,address,string,bool)` -> `log(uint256,address,string,bool)` - // `22a479a6` -> `cc32ab07` - ([34, 164, 121, 166], [204, 50, 171, 7]), - // `log(uint,address,string,address)` -> `log(uint256,address,string,address)` - // `cbe58efd` -> `9cba8fff` - ([203, 229, 142, 253], [156, 186, 143, 255]), - // `log(uint,address,bool,uint)` -> `log(uint256,address,bool,uint256)` - // `7b08e8eb` -> `5abd992a` - ([123, 8, 232, 235], [90, 189, 153, 42]), - // `log(uint,address,bool,string)` -> `log(uint256,address,bool,string)` - // `63f0e242` -> `90fb06aa` - ([99, 240, 226, 66], [144, 251, 6, 170]), - // `log(uint,address,bool,bool)` -> `log(uint256,address,bool,bool)` - // `7e27410d` -> `e351140f` - ([126, 39, 65, 13], [227, 81, 20, 15]), - // `log(uint,address,bool,address)` -> `log(uint256,address,bool,address)` - // `b6313094` -> `ef72c513` - ([182, 49, 48, 148], [239, 114, 197, 19]), - // `log(uint,address,address,uint)` -> `log(uint256,address,address,uint256)` - // `9a3cbf96` -> `736efbb6` - ([154, 60, 191, 150], [115, 110, 251, 182]), - // `log(uint,address,address,string)` -> `log(uint256,address,address,string)` - // `7943dc66` -> `031c6f73` - ([121, 67, 220, 102], [3, 28, 111, 115]), - // `log(uint,address,address,bool)` -> `log(uint256,address,address,bool)` - // `01550b04` -> `091ffaf5` - ([1, 85, 11, 4], [9, 31, 250, 245]), - // `log(uint,address,address,address)` -> `log(uint256,address,address,address)` - // `554745f9` -> `2488b414` - ([85, 71, 69, 249], [36, 136, 180, 20]), - // `log(string,uint,uint,uint)` -> `log(string,uint256,uint256,uint256)` - // `08ee5666` -> `a7a87853` - ([8, 238, 86, 102], [167, 168, 120, 83]), - // `log(string,uint,uint,string)` -> `log(string,uint256,uint256,string)` - // `a54ed4bd` -> `854b3496` - ([165, 78, 212, 189], [133, 75, 52, 150]), - // `log(string,uint,uint,bool)` -> `log(string,uint256,uint256,bool)` - // `f73c7e3d` -> `7626db92` - ([247, 60, 126, 61], [118, 38, 219, 146]), - // `log(string,uint,uint,address)` -> `log(string,uint256,uint256,address)` - // `bed728bf` -> `e21de278` - ([190, 215, 40, 191], [226, 29, 226, 120]), - // `log(string,uint,string,uint)` -> `log(string,uint256,string,uint256)` - // `a0c4b225` -> `c67ea9d1` - ([160, 196, 178, 37], [198, 126, 169, 209]), - // `log(string,uint,string,string)` -> `log(string,uint256,string,string)` - // `6c98dae2` -> `5ab84e1f` - ([108, 152, 218, 226], [90, 184, 78, 31]), - // `log(string,uint,string,bool)` -> `log(string,uint256,string,bool)` - // `e99f82cf` -> `7d24491d` - ([233, 159, 130, 207], [125, 36, 73, 29]), - // `log(string,uint,string,address)` -> `log(string,uint256,string,address)` - // `bb7235e9` -> `7c4632a4` - ([187, 114, 53, 233], [124, 70, 50, 164]), - // `log(string,uint,bool,uint)` -> `log(string,uint256,bool,uint256)` - // `550e6ef5` -> `e41b6f6f` - ([85, 14, 110, 245], [228, 27, 111, 111]), - // `log(string,uint,bool,string)` -> `log(string,uint256,bool,string)` - // `76cc6064` -> `abf73a98` - ([118, 204, 96, 100], [171, 247, 58, 152]), - // `log(string,uint,bool,bool)` -> `log(string,uint256,bool,bool)` - // `e37ff3d0` -> `354c36d6` - ([227, 127, 243, 208], [53, 76, 54, 214]), - // `log(string,uint,bool,address)` -> `log(string,uint256,bool,address)` - // `e5549d91` -> `e0e95b98` - ([229, 84, 157, 145], [224, 233, 91, 152]), - // `log(string,uint,address,uint)` -> `log(string,uint256,address,uint256)` - // `58497afe` -> `4f04fdc6` - ([88, 73, 122, 254], [79, 4, 253, 198]), - // `log(string,uint,address,string)` -> `log(string,uint256,address,string)` - // `3254c2e8` -> `9ffb2f93` - ([50, 84, 194, 232], [159, 251, 47, 147]), - // `log(string,uint,address,bool)` -> `log(string,uint256,address,bool)` - // `1106a8f7` -> `82112a42` - ([17, 6, 168, 247], [130, 17, 42, 66]), - // `log(string,uint,address,address)` -> `log(string,uint256,address,address)` - // `eac89281` -> `5ea2b7ae` - ([234, 200, 146, 129], [94, 162, 183, 174]), - // `log(string,string,uint,uint)` -> `log(string,string,uint256,uint256)` - // `d5cf17d0` -> `f45d7d2c` - ([213, 207, 23, 208], [244, 93, 125, 44]), - // `log(string,string,uint,string)` -> `log(string,string,uint256,string)` - // `8d142cdd` -> `5d1a971a` - ([141, 20, 44, 221], [93, 26, 151, 26]), - // `log(string,string,uint,bool)` -> `log(string,string,uint256,bool)` - // `e65658ca` -> `c3a8a654` - ([230, 86, 88, 202], [195, 168, 166, 84]), - // `log(string,string,uint,address)` -> `log(string,string,uint256,address)` - // `5d4f4680` -> `1023f7b2` - ([93, 79, 70, 128], [16, 35, 247, 178]), - // `log(string,string,string,uint)` -> `log(string,string,string,uint256)` - // `9fd009f5` -> `8eafb02b` - ([159, 208, 9, 245], [142, 175, 176, 43]), - // `log(string,string,bool,uint)` -> `log(string,string,bool,uint256)` - // `86818a7a` -> `d6aefad2` - ([134, 129, 138, 122], [214, 174, 250, 210]), - // `log(string,string,address,uint)` -> `log(string,string,address,uint256)` - // `4a81a56a` -> `7cc3c607` - ([74, 129, 165, 106], [124, 195, 198, 7]), - // `log(string,bool,uint,uint)` -> `log(string,bool,uint256,uint256)` - // `5dbff038` -> `64b5bb67` - ([93, 191, 240, 56], [100, 181, 187, 103]), - // `log(string,bool,uint,string)` -> `log(string,bool,uint256,string)` - // `42b9a227` -> `742d6ee7` - ([66, 185, 162, 39], [116, 45, 110, 231]), - // `log(string,bool,uint,bool)` -> `log(string,bool,uint256,bool)` - // `3cc5b5d3` -> `8af7cf8a` - ([60, 197, 181, 211], [138, 247, 207, 138]), - // `log(string,bool,uint,address)` -> `log(string,bool,uint256,address)` - // `71d3850d` -> `935e09bf` - ([113, 211, 133, 13], [147, 94, 9, 191]), - // `log(string,bool,string,uint)` -> `log(string,bool,string,uint256)` - // `34cb308d` -> `24f91465` - ([52, 203, 48, 141], [36, 249, 20, 101]), - // `log(string,bool,bool,uint)` -> `log(string,bool,bool,uint256)` - // `807531e8` -> `8e3f78a9` - ([128, 117, 49, 232], [142, 63, 120, 169]), - // `log(string,bool,address,uint)` -> `log(string,bool,address,uint256)` - // `28df4e96` -> `5d08bb05` - ([40, 223, 78, 150], [93, 8, 187, 5]), - // `log(string,address,uint,uint)` -> `log(string,address,uint256,uint256)` - // `daa394bd` -> `f8f51b1e` - ([218, 163, 148, 189], [248, 245, 27, 30]), - // `log(string,address,uint,string)` -> `log(string,address,uint256,string)` - // `4c55f234` -> `5a477632` - ([76, 85, 242, 52], [90, 71, 118, 50]), - // `log(string,address,uint,bool)` -> `log(string,address,uint256,bool)` - // `5ac1c13c` -> `fc4845f0` - ([90, 193, 193, 60], [252, 72, 69, 240]), - // `log(string,address,uint,address)` -> `log(string,address,uint256,address)` - // `a366ec80` -> `63fb8bc5` - ([163, 102, 236, 128], [99, 251, 139, 197]), - // `log(string,address,string,uint)` -> `log(string,address,string,uint256)` - // `8f624be9` -> `91d1112e` - ([143, 98, 75, 233], [145, 209, 17, 46]), - // `log(string,address,bool,uint)` -> `log(string,address,bool,uint256)` - // `c5d1bb8b` -> `3e9f866a` - ([197, 209, 187, 139], [62, 159, 134, 106]), - // `log(string,address,address,uint)` -> `log(string,address,address,uint256)` - // `6eb7943d` -> `8ef3f399` - ([110, 183, 148, 61], [142, 243, 243, 153]), - // `log(bool,uint,uint,uint)` -> `log(bool,uint256,uint256,uint256)` - // `32dfa524` -> `374bb4b2` - ([50, 223, 165, 36], [55, 75, 180, 178]), - // `log(bool,uint,uint,string)` -> `log(bool,uint256,uint256,string)` - // `da0666c8` -> `8e69fb5d` - ([218, 6, 102, 200], [142, 105, 251, 93]), - // `log(bool,uint,uint,bool)` -> `log(bool,uint256,uint256,bool)` - // `a41d81de` -> `be984353` - ([164, 29, 129, 222], [190, 152, 67, 83]), - // `log(bool,uint,uint,address)` -> `log(bool,uint256,uint256,address)` - // `f161b221` -> `00dd87b9` - ([241, 97, 178, 33], [0, 221, 135, 185]), - // `log(bool,uint,string,uint)` -> `log(bool,uint256,string,uint256)` - // `4180011b` -> `6a1199e2` - ([65, 128, 1, 27], [106, 17, 153, 226]), - // `log(bool,uint,string,string)` -> `log(bool,uint256,string,string)` - // `d32a6548` -> `f5bc2249` - ([211, 42, 101, 72], [245, 188, 34, 73]), - // `log(bool,uint,string,bool)` -> `log(bool,uint256,string,bool)` - // `91d2f813` -> `e5e70b2b` - ([145, 210, 248, 19], [229, 231, 11, 43]), - // `log(bool,uint,string,address)` -> `log(bool,uint256,string,address)` - // `a5c70d29` -> `fedd1fff` - ([165, 199, 13, 41], [254, 221, 31, 255]), - // `log(bool,uint,bool,uint)` -> `log(bool,uint256,bool,uint256)` - // `d3de5593` -> `7f9bbca2` - ([211, 222, 85, 147], [127, 155, 188, 162]), - // `log(bool,uint,bool,string)` -> `log(bool,uint256,bool,string)` - // `b6d569d4` -> `9143dbb1` - ([182, 213, 105, 212], [145, 67, 219, 177]), - // `log(bool,uint,bool,bool)` -> `log(bool,uint256,bool,bool)` - // `9e01f741` -> `ceb5f4d7` - ([158, 1, 247, 65], [206, 181, 244, 215]), - // `log(bool,uint,bool,address)` -> `log(bool,uint256,bool,address)` - // `4267c7f8` -> `9acd3616` - ([66, 103, 199, 248], [154, 205, 54, 22]), - // `log(bool,uint,address,uint)` -> `log(bool,uint256,address,uint256)` - // `caa5236a` -> `1537dc87` - ([202, 165, 35, 106], [21, 55, 220, 135]), - // `log(bool,uint,address,string)` -> `log(bool,uint256,address,string)` - // `18091341` -> `1bb3b09a` - ([24, 9, 19, 65], [27, 179, 176, 154]), - // `log(bool,uint,address,bool)` -> `log(bool,uint256,address,bool)` - // `65adf408` -> `b4c314ff` - ([101, 173, 244, 8], [180, 195, 20, 255]), - // `log(bool,uint,address,address)` -> `log(bool,uint256,address,address)` - // `8a2f90aa` -> `26f560a8` - ([138, 47, 144, 170], [38, 245, 96, 168]), - // `log(bool,string,uint,uint)` -> `log(bool,string,uint256,uint256)` - // `8e4ae86e` -> `28863fcb` - ([142, 74, 232, 110], [40, 134, 63, 203]), - // `log(bool,string,uint,string)` -> `log(bool,string,uint256,string)` - // `77a1abed` -> `1ad96de6` - ([119, 161, 171, 237], [26, 217, 109, 230]), - // `log(bool,string,uint,bool)` -> `log(bool,string,uint256,bool)` - // `20bbc9af` -> `6b0e5d53` - ([32, 187, 201, 175], [107, 14, 93, 83]), - // `log(bool,string,uint,address)` -> `log(bool,string,uint256,address)` - // `5b22b938` -> `1596a1ce` - ([91, 34, 185, 56], [21, 150, 161, 206]), - // `log(bool,string,string,uint)` -> `log(bool,string,string,uint256)` - // `5ddb2592` -> `7be0c3eb` - ([93, 219, 37, 146], [123, 224, 195, 235]), - // `log(bool,string,bool,uint)` -> `log(bool,string,bool,uint256)` - // `8d6f9ca5` -> `1606a393` - ([141, 111, 156, 165], [22, 6, 163, 147]), - // `log(bool,string,address,uint)` -> `log(bool,string,address,uint256)` - // `1b0b955b` -> `a5cada94` - ([27, 11, 149, 91], [165, 202, 218, 148]), - // `log(bool,bool,uint,uint)` -> `log(bool,bool,uint256,uint256)` - // `4667de8e` -> `0bb00eab` - ([70, 103, 222, 142], [11, 176, 14, 171]), - // `log(bool,bool,uint,string)` -> `log(bool,bool,uint256,string)` - // `50618937` -> `7dd4d0e0` - ([80, 97, 137, 55], [125, 212, 208, 224]), - // `log(bool,bool,uint,bool)` -> `log(bool,bool,uint256,bool)` - // `ab5cc1c4` -> `619e4d0e` - ([171, 92, 193, 196], [97, 158, 77, 14]), - // `log(bool,bool,uint,address)` -> `log(bool,bool,uint256,address)` - // `0bff950d` -> `54a7a9a0` - ([11, 255, 149, 13], [84, 167, 169, 160]), - // `log(bool,bool,string,uint)` -> `log(bool,bool,string,uint256)` - // `178b4685` -> `e3a9ca2f` - ([23, 139, 70, 133], [227, 169, 202, 47]), - // `log(bool,bool,bool,uint)` -> `log(bool,bool,bool,uint256)` - // `c248834d` -> `6d7045c1` - ([194, 72, 131, 77], [109, 112, 69, 193]), - // `log(bool,bool,address,uint)` -> `log(bool,bool,address,uint256)` - // `609386e7` -> `4c123d57` - ([96, 147, 134, 231], [76, 18, 61, 87]), - // `log(bool,address,uint,uint)` -> `log(bool,address,uint256,uint256)` - // `9bfe72bc` -> `7bf181a1` - ([155, 254, 114, 188], [123, 241, 129, 161]), - // `log(bool,address,uint,string)` -> `log(bool,address,uint256,string)` - // `a0685833` -> `51f09ff8` - ([160, 104, 88, 51], [81, 240, 159, 248]), - // `log(bool,address,uint,bool)` -> `log(bool,address,uint256,bool)` - // `ee8d8672` -> `d6019f1c` - ([238, 141, 134, 114], [214, 1, 159, 28]), - // `log(bool,address,uint,address)` -> `log(bool,address,uint256,address)` - // `68f158b5` -> `136b05dd` - ([104, 241, 88, 181], [19, 107, 5, 221]), - // `log(bool,address,string,uint)` -> `log(bool,address,string,uint256)` - // `0b99fc22` -> `c21f64c7` - ([11, 153, 252, 34], [194, 31, 100, 199]), - // `log(bool,address,bool,uint)` -> `log(bool,address,bool,uint256)` - // `4cb60fd1` -> `07831502` - ([76, 182, 15, 209], [7, 131, 21, 2]), - // `log(bool,address,address,uint)` -> `log(bool,address,address,uint256)` - // `5284bd6c` -> `0c66d1be` - ([82, 132, 189, 108], [12, 102, 209, 190]), - // `log(address,uint,uint,uint)` -> `log(address,uint256,uint256,uint256)` - // `3d0e9de4` -> `34f0e636` - ([61, 14, 157, 228], [52, 240, 230, 54]), - // `log(address,uint,uint,string)` -> `log(address,uint256,uint256,string)` - // `89340dab` -> `4a28c017` - ([137, 52, 13, 171], [74, 40, 192, 23]), - // `log(address,uint,uint,bool)` -> `log(address,uint256,uint256,bool)` - // `ec4ba8a2` -> `66f1bc67` - ([236, 75, 168, 162], [102, 241, 188, 103]), - // `log(address,uint,uint,address)` -> `log(address,uint256,uint256,address)` - // `1ef63434` -> `20e3984d` - ([30, 246, 52, 52], [32, 227, 152, 77]), - // `log(address,uint,string,uint)` -> `log(address,uint256,string,uint256)` - // `f512cf9b` -> `bf01f891` - ([245, 18, 207, 155], [191, 1, 248, 145]), - // `log(address,uint,string,string)` -> `log(address,uint256,string,string)` - // `7e56c693` -> `88a8c406` - ([126, 86, 198, 147], [136, 168, 196, 6]), - // `log(address,uint,string,bool)` -> `log(address,uint256,string,bool)` - // `a4024f11` -> `cf18105c` - ([164, 2, 79, 17], [207, 24, 16, 92]), - // `log(address,uint,string,address)` -> `log(address,uint256,string,address)` - // `dc792604` -> `5c430d47` - ([220, 121, 38, 4], [92, 67, 13, 71]), - // `log(address,uint,bool,uint)` -> `log(address,uint256,bool,uint256)` - // `698f4392` -> `22f6b999` - ([105, 143, 67, 146], [34, 246, 185, 153]), - // `log(address,uint,bool,string)` -> `log(address,uint256,bool,string)` - // `8e8e4e75` -> `c5ad85f9` - ([142, 142, 78, 117], [197, 173, 133, 249]), - // `log(address,uint,bool,bool)` -> `log(address,uint256,bool,bool)` - // `fea1d55a` -> `3bf5e537` - ([254, 161, 213, 90], [59, 245, 229, 55]), - // `log(address,uint,bool,address)` -> `log(address,uint256,bool,address)` - // `23e54972` -> `a31bfdcc` - ([35, 229, 73, 114], [163, 27, 253, 204]), - // `log(address,uint,address,uint)` -> `log(address,uint256,address,uint256)` - // `a5d98768` -> `100f650e` - ([165, 217, 135, 104], [16, 15, 101, 14]), - // `log(address,uint,address,string)` -> `log(address,uint256,address,string)` - // `5d71f39e` -> `1da986ea` - ([93, 113, 243, 158], [29, 169, 134, 234]), - // `log(address,uint,address,bool)` -> `log(address,uint256,address,bool)` - // `f181a1e9` -> `a1bcc9b3` - ([241, 129, 161, 233], [161, 188, 201, 179]), - // `log(address,uint,address,address)` -> `log(address,uint256,address,address)` - // `ec24846f` -> `478d1c62` - ([236, 36, 132, 111], [71, 141, 28, 98]), - // `log(address,string,uint,uint)` -> `log(address,string,uint256,uint256)` - // `a4c92a60` -> `1dc8e1b8` - ([164, 201, 42, 96], [29, 200, 225, 184]), - // `log(address,string,uint,string)` -> `log(address,string,uint256,string)` - // `5d1365c9` -> `448830a8` - ([93, 19, 101, 201], [68, 136, 48, 168]), - // `log(address,string,uint,bool)` -> `log(address,string,uint256,bool)` - // `7e250d5b` -> `0ef7e050` - ([126, 37, 13, 91], [14, 247, 224, 80]), - // `log(address,string,uint,address)` -> `log(address,string,uint256,address)` - // `dfd7d80b` -> `63183678` - ([223, 215, 216, 11], [99, 24, 54, 120]), - // `log(address,string,string,uint)` -> `log(address,string,string,uint256)` - // `a14fd039` -> `159f8927` - ([161, 79, 208, 57], [21, 159, 137, 39]), - // `log(address,string,bool,uint)` -> `log(address,string,bool,uint256)` - // `e720521c` -> `515e38b6` - ([231, 32, 82, 28], [81, 94, 56, 182]), - // `log(address,string,address,uint)` -> `log(address,string,address,uint256)` - // `8c1933a9` -> `457fe3cf` - ([140, 25, 51, 169], [69, 127, 227, 207]), - // `log(address,bool,uint,uint)` -> `log(address,bool,uint256,uint256)` - // `c210a01e` -> `386ff5f4` - ([194, 16, 160, 30], [56, 111, 245, 244]), - // `log(address,bool,uint,string)` -> `log(address,bool,uint256,string)` - // `9b588ecc` -> `0aa6cfad` - ([155, 88, 142, 204], [10, 166, 207, 173]), - // `log(address,bool,uint,bool)` -> `log(address,bool,uint256,bool)` - // `85cdc5af` -> `c4643e20` - ([133, 205, 197, 175], [196, 100, 62, 32]), - // `log(address,bool,uint,address)` -> `log(address,bool,uint256,address)` - // `0d8ce61e` -> `ccf790a1` - ([13, 140, 230, 30], [204, 247, 144, 161]), - // `log(address,bool,string,uint)` -> `log(address,bool,string,uint256)` - // `9e127b6e` -> `80e6a20b` - ([158, 18, 123, 110], [128, 230, 162, 11]), - // `log(address,bool,bool,uint)` -> `log(address,bool,bool,uint256)` - // `cfb58756` -> `8c4e5de6` - ([207, 181, 135, 86], [140, 78, 93, 230]), - // `log(address,bool,address,uint)` -> `log(address,bool,address,uint256)` - // `dc7116d2` -> `a75c59de` - ([220, 113, 22, 210], [167, 92, 89, 222]), - // `log(address,address,uint,uint)` -> `log(address,address,uint256,uint256)` - // `54fdf3e4` -> `be553481` - ([84, 253, 243, 228], [190, 85, 52, 129]), - // `log(address,address,uint,string)` -> `log(address,address,uint256,string)` - // `9dd12ead` -> `fdb4f990` - ([157, 209, 46, 173], [253, 180, 249, 144]), - // `log(address,address,uint,bool)` -> `log(address,address,uint256,bool)` - // `c2f688ec` -> `9b4254e2` - ([194, 246, 136, 236], [155, 66, 84, 226]), - // `log(address,address,uint,address)` -> `log(address,address,uint256,address)` - // `d6c65276` -> `8da6def5` - ([214, 198, 82, 118], [141, 166, 222, 245]), - // `log(address,address,string,uint)` -> `log(address,address,string,uint256)` - // `04289300` -> `ef1cefe7` - ([4, 40, 147, 0], [239, 28, 239, 231]), - // `log(address,address,bool,uint)` -> `log(address,address,bool,uint256)` - // `95d65f11` -> `3971e78c` - ([149, 214, 95, 17], [57, 113, 231, 140]), - // `log(address,address,address,uint)` -> `log(address,address,address,uint256)` - // `ed5eac87` -> `94250d77` - ([237, 94, 172, 135], [148, 37, 13, 119]), -] diff --git a/crates/evm/abi/src/lib.rs b/crates/evm/abi/src/lib.rs index 6a31fe5509b22..8e9313c2f516e 100644 --- a/crates/evm/abi/src/lib.rs +++ b/crates/evm/abi/src/lib.rs @@ -3,5 +3,4 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -mod console; -pub use console::*; +pub mod console; diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index c0ff331646dcb..ef1e54daba891 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -1,6 +1,6 @@ //! Various utilities to decode test results. -use crate::abi::{Console, Vm}; +use crate::abi::{console, Vm}; use alloy_dyn_abi::JsonAbiExt; use alloy_json_abi::{Error, JsonAbi}; use alloy_primitives::{hex, map::HashMap, Log, Selector}; @@ -52,7 +52,7 @@ pub fn decode_console_logs(logs: &[Log]) -> Vec { /// This function returns [None] if it is not a DSTest log or the result of a Hardhat /// `console.log`. pub fn decode_console_log(log: &Log) -> Option { - Console::ConsoleEvents::decode_log(log, false).ok().map(|decoded| decoded.to_string()) + console::ds::ConsoleEvents::decode_log(log, false).ok().map(|decoded| decoded.to_string()) } /// Decodes revert data. diff --git a/crates/evm/core/src/lib.rs b/crates/evm/core/src/lib.rs index 30986d16188df..cf678551e21d6 100644 --- a/crates/evm/core/src/lib.rs +++ b/crates/evm/core/src/lib.rs @@ -50,7 +50,9 @@ pub trait InspectorExt: for<'a> Inspector<&'a mut dyn DatabaseExt> { } /// Simulates `console.log` invocation. - fn console_log(&mut self, _input: String) {} + fn console_log(&mut self, msg: &str) { + let _ = msg; + } /// Returns `true` if the current network is Odyssey. fn is_odyssey(&self) -> bool { diff --git a/crates/evm/evm/src/inspectors/logs.rs b/crates/evm/evm/src/inspectors/logs.rs index 877101a8064f0..570fb47dbe238 100644 --- a/crates/evm/evm/src/inspectors/logs.rs +++ b/crates/evm/evm/src/inspectors/logs.rs @@ -1,11 +1,7 @@ -use alloy_primitives::{Bytes, Log}; +use alloy_primitives::Log; use alloy_sol_types::{SolEvent, SolInterface, SolValue}; use foundry_common::{fmt::ConsoleFmt, ErrorExt}; -use foundry_evm_core::{ - abi::{patch_hh_console_selector, Console, HardhatConsole}, - constants::HARDHAT_CONSOLE_ADDRESS, - InspectorExt, -}; +use foundry_evm_core::{abi::console, constants::HARDHAT_CONSOLE_ADDRESS, InspectorExt}; use revm::{ interpreter::{ CallInputs, CallOutcome, Gas, InstructionResult, Interpreter, InterpreterResult, @@ -15,28 +11,31 @@ use revm::{ /// An inspector that collects logs during execution. /// -/// The inspector collects logs from the `LOG` opcodes as well as Hardhat-style logs. +/// The inspector collects logs from the `LOG` opcodes as well as Hardhat-style `console.sol` logs. #[derive(Clone, Debug, Default)] pub struct LogCollector { - /// The collected logs. Includes both `LOG` opcodes and Hardhat-style logs. + /// The collected logs. Includes both `LOG` opcodes and Hardhat-style `console.sol` logs. pub logs: Vec, } impl LogCollector { - fn hardhat_log(&mut self, mut input: Vec) -> (InstructionResult, Bytes) { - // Patch the Hardhat-style selector (`uint` instead of `uint256`) - patch_hh_console_selector(&mut input); - - // Decode the call - let decoded = match HardhatConsole::HardhatConsoleCalls::abi_decode(&input, false) { - Ok(inner) => inner, - Err(err) => return (InstructionResult::Revert, err.abi_encode_revert()), - }; - - // Convert the decoded call to a DS `log(string)` event - self.logs.push(convert_hh_log_to_event(decoded)); + #[cold] + fn do_hardhat_log(&mut self, inputs: &CallInputs) -> Option { + if let Err(err) = self.hardhat_log(&inputs.input) { + let result = InstructionResult::Revert; + let output = err.abi_encode_revert(); + return Some(CallOutcome { + result: InterpreterResult { result, output, gas: Gas::new(inputs.gas_limit) }, + memory_offset: inputs.return_memory_offset.clone(), + }) + } + None + } - (InstructionResult::Continue, Bytes::new()) + fn hardhat_log(&mut self, data: &[u8]) -> alloy_sol_types::Result<()> { + let decoded = console::hh::ConsoleCalls::abi_decode(data, false)?; + self.logs.push(hh_to_ds(&decoded)); + Ok(()) } } @@ -51,40 +50,30 @@ impl Inspector for LogCollector { inputs: &mut CallInputs, ) -> Option { if inputs.target_address == HARDHAT_CONSOLE_ADDRESS { - let (res, out) = self.hardhat_log(inputs.input.to_vec()); - if res != InstructionResult::Continue { - return Some(CallOutcome { - result: InterpreterResult { - result: res, - output: out, - gas: Gas::new(inputs.gas_limit), - }, - memory_offset: inputs.return_memory_offset.clone(), - }); - } + return self.do_hardhat_log(inputs); } - None } } impl InspectorExt for LogCollector { - fn console_log(&mut self, input: String) { - self.logs.push(Log::new_unchecked( - HARDHAT_CONSOLE_ADDRESS, - vec![Console::log::SIGNATURE_HASH], - input.abi_encode().into(), - )); + fn console_log(&mut self, msg: &str) { + self.logs.push(new_console_log(msg)); } } -/// Converts a call to Hardhat's `console.log` to a DSTest `log(string)` event. -fn convert_hh_log_to_event(call: HardhatConsole::HardhatConsoleCalls) -> Log { +/// Converts a Hardhat `console.log` call to a DSTest `log(string)` event. +fn hh_to_ds(call: &console::hh::ConsoleCalls) -> Log { // Convert the parameters of the call to their string representation using `ConsoleFmt`. - let fmt = call.fmt(Default::default()); + let msg = call.fmt(Default::default()); + new_console_log(&msg) +} + +/// Creates a `console.log(string)` event. +fn new_console_log(msg: &str) -> Log { Log::new_unchecked( HARDHAT_CONSOLE_ADDRESS, - vec![Console::log::SIGNATURE_HASH], - fmt.abi_encode().into(), + vec![console::ds::log::SIGNATURE_HASH], + msg.abi_encode().into(), ) } diff --git a/crates/evm/evm/src/inspectors/stack.rs b/crates/evm/evm/src/inspectors/stack.rs index 385623f5a07ab..90879736c55b6 100644 --- a/crates/evm/evm/src/inspectors/stack.rs +++ b/crates/evm/evm/src/inspectors/stack.rs @@ -1030,9 +1030,9 @@ impl InspectorExt for InspectorStackRefMut<'_> { false } - fn console_log(&mut self, input: String) { + fn console_log(&mut self, msg: &str) { call_inspectors!([&mut self.log_collector], |inspector| InspectorExt::console_log( - inspector, input + inspector, msg )); } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 68ecbac29c7eb..f904bb46ecc5e 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -15,7 +15,7 @@ use foundry_common::{ abi::get_indexed_event, fmt::format_token, get_contract_name, ContractsByArtifact, SELECTOR_LEN, }; use foundry_evm_core::{ - abi::{Console, HardhatConsole, Vm, HARDHAT_CONSOLE_SELECTOR_PATCHES}, + abi::{console, Vm}, constants::{ CALLER, CHEATCODE_ADDRESS, DEFAULT_CREATE2_DEPLOYER, HARDHAT_CONSOLE_ADDRESS, TEST_CONTRACT_ADDRESS, @@ -153,23 +153,6 @@ impl CallTraceDecoder { } fn init() -> Self { - /// All functions from the Hardhat console ABI. - /// - /// See [`HARDHAT_CONSOLE_SELECTOR_PATCHES`] for more details. - fn hh_funcs() -> impl Iterator { - let functions = HardhatConsole::abi::functions(); - let mut functions: Vec<_> = - functions.into_values().flatten().map(|func| (func.selector(), func)).collect(); - let len = functions.len(); - // `functions` is the list of all patched functions; duplicate the unpatched ones - for (unpatched, patched) in HARDHAT_CONSOLE_SELECTOR_PATCHES.iter() { - if let Some((_, func)) = functions[..len].iter().find(|(sel, _)| sel == patched) { - functions.push((unpatched.into(), func.clone())); - } - } - functions.into_iter() - } - Self { contracts: Default::default(), labels: HashMap::from_iter([ @@ -192,16 +175,13 @@ impl CallTraceDecoder { receive_contracts: Default::default(), fallback_contracts: Default::default(), - functions: hh_funcs() - .chain( - Vm::abi::functions() - .into_values() - .flatten() - .map(|func| (func.selector(), func)), - ) - .map(|(selector, func)| (selector, vec![func])) + functions: console::hh::abi::functions() + .into_values() + .chain(Vm::abi::functions().into_values()) + .flatten() + .map(|func| (func.selector(), vec![func])) .collect(), - events: Console::abi::events() + events: console::ds::abi::events() .into_values() .flatten() .map(|event| ((event.selector(), indexed_inputs(&event)), vec![event])) diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 2a69ba0001f0a..15d60e0df7e76 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -291,7 +291,7 @@ contract SimpleContractTest is DSTest { function test() public { SimpleContract c = new SimpleContract(); c.setValues(100); - console.log("Value set: ", 100); + console.logUint(100); } } "#; diff --git a/crates/forge/tests/fixtures/SimpleContractTestVerbose.json b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json index 81803d949d36c..20324950fc240 100644 --- a/crates/forge/tests/fixtures/SimpleContractTestVerbose.json +++ b/crates/forge/tests/fixtures/SimpleContractTestVerbose.json @@ -12,11 +12,11 @@ "topics": [ "0x41304facd9323d75b11bcdd609cb38effffdb05710f7caf0e9b16c6d9d709f50" ], - "data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000f56616c7565207365743a20203130300000000000000000000000000000000000" + "data": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000033130300000000000000000000000000000000000000000000000000000000000" } ], "decoded_logs": [ - "Value set: 100" + "100" ], "kind": { "Unit": { diff --git a/testdata/default/logs/HardhatLogs.t.sol b/testdata/default/logs/HardhatLogs.t.sol index cc2f2b7859a78..a6226bbd665fe 100644 --- a/testdata/default/logs/HardhatLogs.t.sol +++ b/testdata/default/logs/HardhatLogs.t.sol @@ -25,10 +25,10 @@ contract HardhatLogsTest { } function testInts() public view { - console.log(0); - console.log(1); - console.log(2); - console.log(3); + console.log(uint256(0)); + console.log(uint256(1)); + console.log(uint256(2)); + console.log(uint256(3)); } function testStrings() public view { @@ -37,7 +37,7 @@ contract HardhatLogsTest { function testMisc() public view { console.log("testMisc", address(1)); - console.log("testMisc", 42); + console.log("testMisc", uint256(42)); } function testConsoleLog() public view { diff --git a/testdata/default/logs/console.sol b/testdata/default/logs/console.sol index feed58fb3b954..4fdb6679edf91 100644 --- a/testdata/default/logs/console.sol +++ b/testdata/default/logs/console.sol @@ -1,1531 +1,1560 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity 0.8; +// SPDX-License-Identifier: MIT +pragma solidity >=0.4.22 <0.9.0; library console { - address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); + address constant CONSOLE_ADDRESS = + 0x000000000000000000636F6e736F6c652e6c6f67; - function _sendLogPayload(bytes memory payload) private view { - uint256 payloadLength = payload.length; + function _sendLogPayloadImplementation(bytes memory payload) internal view { address consoleAddress = CONSOLE_ADDRESS; + /// @solidity memory-safe-assembly assembly { - let payloadStart := add(payload, 32) - let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) + pop( + staticcall( + gas(), + consoleAddress, + add(payload, 32), + mload(payload), + 0, + 0 + ) + ) } } - function log() internal view { + function _castToPure( + function(bytes memory) internal view fnIn + ) internal pure returns (function(bytes memory) pure fnOut) { + assembly { + fnOut := fnIn + } + } + + function _sendLogPayload(bytes memory payload) internal pure { + _castToPure(_sendLogPayloadImplementation)(payload); + } + + function log() internal pure { _sendLogPayload(abi.encodeWithSignature("log()")); } - function logInt(int256 p0) internal view { - _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); + function logInt(int256 p0) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(int256)", p0)); } - function logUint(uint256 p0) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); + function logUint(uint256 p0) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256)", p0)); } - function logString(string memory p0) internal view { + function logString(string memory p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } - function logBool(bool p0) internal view { + function logBool(bool p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } - function logAddress(address p0) internal view { + function logAddress(address p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } - function logBytes(bytes memory p0) internal view { + function logBytes(bytes memory p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } - function logBytes1(bytes1 p0) internal view { + function logBytes1(bytes1 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } - function logBytes2(bytes2 p0) internal view { + function logBytes2(bytes2 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } - function logBytes3(bytes3 p0) internal view { + function logBytes3(bytes3 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } - function logBytes4(bytes4 p0) internal view { + function logBytes4(bytes4 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } - function logBytes5(bytes5 p0) internal view { + function logBytes5(bytes5 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } - function logBytes6(bytes6 p0) internal view { + function logBytes6(bytes6 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } - function logBytes7(bytes7 p0) internal view { + function logBytes7(bytes7 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } - function logBytes8(bytes8 p0) internal view { + function logBytes8(bytes8 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } - function logBytes9(bytes9 p0) internal view { + function logBytes9(bytes9 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } - function logBytes10(bytes10 p0) internal view { + function logBytes10(bytes10 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } - function logBytes11(bytes11 p0) internal view { + function logBytes11(bytes11 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } - function logBytes12(bytes12 p0) internal view { + function logBytes12(bytes12 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } - function logBytes13(bytes13 p0) internal view { + function logBytes13(bytes13 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } - function logBytes14(bytes14 p0) internal view { + function logBytes14(bytes14 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } - function logBytes15(bytes15 p0) internal view { + function logBytes15(bytes15 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } - function logBytes16(bytes16 p0) internal view { + function logBytes16(bytes16 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } - function logBytes17(bytes17 p0) internal view { + function logBytes17(bytes17 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } - function logBytes18(bytes18 p0) internal view { + function logBytes18(bytes18 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } - function logBytes19(bytes19 p0) internal view { + function logBytes19(bytes19 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } - function logBytes20(bytes20 p0) internal view { + function logBytes20(bytes20 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } - function logBytes21(bytes21 p0) internal view { + function logBytes21(bytes21 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } - function logBytes22(bytes22 p0) internal view { + function logBytes22(bytes22 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } - function logBytes23(bytes23 p0) internal view { + function logBytes23(bytes23 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } - function logBytes24(bytes24 p0) internal view { + function logBytes24(bytes24 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } - function logBytes25(bytes25 p0) internal view { + function logBytes25(bytes25 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } - function logBytes26(bytes26 p0) internal view { + function logBytes26(bytes26 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } - function logBytes27(bytes27 p0) internal view { + function logBytes27(bytes27 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } - function logBytes28(bytes28 p0) internal view { + function logBytes28(bytes28 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } - function logBytes29(bytes29 p0) internal view { + function logBytes29(bytes29 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } - function logBytes30(bytes30 p0) internal view { + function logBytes30(bytes30 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } - function logBytes31(bytes31 p0) internal view { + function logBytes31(bytes31 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } - function logBytes32(bytes32 p0) internal view { + function logBytes32(bytes32 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } - function log(uint256 p0) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); + function log(uint256 p0) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256)", p0)); + } + + function log(int256 p0) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(int256)", p0)); } - function log(string memory p0) internal view { + function log(string memory p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } - function log(bool p0) internal view { + function log(bool p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } - function log(address p0) internal view { + function log(address p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } - function log(uint256 p0, uint256 p1) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); + function log(uint256 p0, uint256 p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256)", p0, p1)); + } + + function log(uint256 p0, string memory p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string)", p0, p1)); } - function log(uint256 p0, string memory p1) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); + function log(uint256 p0, bool p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool)", p0, p1)); } - function log(uint256 p0, bool p1) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); + function log(uint256 p0, address p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address)", p0, p1)); } - function log(uint256 p0, address p1) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); + function log(string memory p0, uint256 p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256)", p0, p1)); } - function log(string memory p0, uint256 p1) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); + function log(string memory p0, int256 p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,int256)", p0, p1)); } - function log(string memory p0, string memory p1) internal view { + function log(string memory p0, string memory p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } - function log(string memory p0, bool p1) internal view { + function log(string memory p0, bool p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } - function log(string memory p0, address p1) internal view { + function log(string memory p0, address p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } - function log(bool p0, uint256 p1) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); + function log(bool p0, uint256 p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256)", p0, p1)); } - function log(bool p0, string memory p1) internal view { + function log(bool p0, string memory p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } - function log(bool p0, bool p1) internal view { + function log(bool p0, bool p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } - function log(bool p0, address p1) internal view { + function log(bool p0, address p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } - function log(address p0, uint256 p1) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); + function log(address p0, uint256 p1) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256)", p0, p1)); } - function log(address p0, string memory p1) internal view { + function log(address p0, string memory p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } - function log(address p0, bool p1) internal view { + function log(address p0, bool p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } - function log(address p0, address p1) internal view { + function log(address p0, address p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } - function log(uint256 p0, uint256 p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); + function log(uint256 p0, uint256 p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256)", p0, p1, p2)); } - function log(uint256 p0, uint256 p1, string memory p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); + function log(uint256 p0, uint256 p1, string memory p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string)", p0, p1, p2)); } - function log(uint256 p0, uint256 p1, bool p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); + function log(uint256 p0, uint256 p1, bool p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool)", p0, p1, p2)); } - function log(uint256 p0, uint256 p1, address p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); + function log(uint256 p0, uint256 p1, address p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address)", p0, p1, p2)); } - function log(uint256 p0, string memory p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); + function log(uint256 p0, string memory p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256)", p0, p1, p2)); } - function log(uint256 p0, string memory p1, string memory p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); + function log(uint256 p0, string memory p1, string memory p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string)", p0, p1, p2)); } - function log(uint256 p0, string memory p1, bool p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); + function log(uint256 p0, string memory p1, bool p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool)", p0, p1, p2)); } - function log(uint256 p0, string memory p1, address p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); + function log(uint256 p0, string memory p1, address p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address)", p0, p1, p2)); } - function log(uint256 p0, bool p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); + function log(uint256 p0, bool p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256)", p0, p1, p2)); } - function log(uint256 p0, bool p1, string memory p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); + function log(uint256 p0, bool p1, string memory p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string)", p0, p1, p2)); } - function log(uint256 p0, bool p1, bool p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); + function log(uint256 p0, bool p1, bool p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool)", p0, p1, p2)); } - function log(uint256 p0, bool p1, address p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); + function log(uint256 p0, bool p1, address p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address)", p0, p1, p2)); } - function log(uint256 p0, address p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); + function log(uint256 p0, address p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256)", p0, p1, p2)); } - function log(uint256 p0, address p1, string memory p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); + function log(uint256 p0, address p1, string memory p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string)", p0, p1, p2)); } - function log(uint256 p0, address p1, bool p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); + function log(uint256 p0, address p1, bool p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool)", p0, p1, p2)); } - function log(uint256 p0, address p1, address p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); + function log(uint256 p0, address p1, address p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address)", p0, p1, p2)); } - function log(string memory p0, uint256 p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); + function log(string memory p0, uint256 p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256)", p0, p1, p2)); } - function log(string memory p0, uint256 p1, string memory p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); + function log(string memory p0, uint256 p1, string memory p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string)", p0, p1, p2)); } - function log(string memory p0, uint256 p1, bool p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); + function log(string memory p0, uint256 p1, bool p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool)", p0, p1, p2)); } - function log(string memory p0, uint256 p1, address p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); + function log(string memory p0, uint256 p1, address p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address)", p0, p1, p2)); } - function log(string memory p0, string memory p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); + function log(string memory p0, string memory p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256)", p0, p1, p2)); } - function log(string memory p0, string memory p1, string memory p2) internal view { + function log(string memory p0, string memory p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } - function log(string memory p0, string memory p1, bool p2) internal view { + function log(string memory p0, string memory p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } - function log(string memory p0, string memory p1, address p2) internal view { + function log(string memory p0, string memory p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } - function log(string memory p0, bool p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); + function log(string memory p0, bool p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256)", p0, p1, p2)); } - function log(string memory p0, bool p1, string memory p2) internal view { + function log(string memory p0, bool p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } - function log(string memory p0, bool p1, bool p2) internal view { + function log(string memory p0, bool p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } - function log(string memory p0, bool p1, address p2) internal view { + function log(string memory p0, bool p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } - function log(string memory p0, address p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); + function log(string memory p0, address p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256)", p0, p1, p2)); } - function log(string memory p0, address p1, string memory p2) internal view { + function log(string memory p0, address p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } - function log(string memory p0, address p1, bool p2) internal view { + function log(string memory p0, address p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } - function log(string memory p0, address p1, address p2) internal view { + function log(string memory p0, address p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } - function log(bool p0, uint256 p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); + function log(bool p0, uint256 p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256)", p0, p1, p2)); } - function log(bool p0, uint256 p1, string memory p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); + function log(bool p0, uint256 p1, string memory p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string)", p0, p1, p2)); } - function log(bool p0, uint256 p1, bool p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); + function log(bool p0, uint256 p1, bool p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool)", p0, p1, p2)); } - function log(bool p0, uint256 p1, address p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); + function log(bool p0, uint256 p1, address p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address)", p0, p1, p2)); } - function log(bool p0, string memory p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); + function log(bool p0, string memory p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256)", p0, p1, p2)); } - function log(bool p0, string memory p1, string memory p2) internal view { + function log(bool p0, string memory p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } - function log(bool p0, string memory p1, bool p2) internal view { + function log(bool p0, string memory p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } - function log(bool p0, string memory p1, address p2) internal view { + function log(bool p0, string memory p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } - function log(bool p0, bool p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); + function log(bool p0, bool p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256)", p0, p1, p2)); } - function log(bool p0, bool p1, string memory p2) internal view { + function log(bool p0, bool p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } - function log(bool p0, bool p1, bool p2) internal view { + function log(bool p0, bool p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } - function log(bool p0, bool p1, address p2) internal view { + function log(bool p0, bool p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } - function log(bool p0, address p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); + function log(bool p0, address p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256)", p0, p1, p2)); } - function log(bool p0, address p1, string memory p2) internal view { + function log(bool p0, address p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } - function log(bool p0, address p1, bool p2) internal view { + function log(bool p0, address p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } - function log(bool p0, address p1, address p2) internal view { + function log(bool p0, address p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } - function log(address p0, uint256 p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); + function log(address p0, uint256 p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256)", p0, p1, p2)); } - function log(address p0, uint256 p1, string memory p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); + function log(address p0, uint256 p1, string memory p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string)", p0, p1, p2)); } - function log(address p0, uint256 p1, bool p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); + function log(address p0, uint256 p1, bool p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool)", p0, p1, p2)); } - function log(address p0, uint256 p1, address p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); + function log(address p0, uint256 p1, address p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address)", p0, p1, p2)); } - function log(address p0, string memory p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); + function log(address p0, string memory p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256)", p0, p1, p2)); } - function log(address p0, string memory p1, string memory p2) internal view { + function log(address p0, string memory p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } - function log(address p0, string memory p1, bool p2) internal view { + function log(address p0, string memory p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } - function log(address p0, string memory p1, address p2) internal view { + function log(address p0, string memory p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } - function log(address p0, bool p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); + function log(address p0, bool p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256)", p0, p1, p2)); } - function log(address p0, bool p1, string memory p2) internal view { + function log(address p0, bool p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } - function log(address p0, bool p1, bool p2) internal view { + function log(address p0, bool p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } - function log(address p0, bool p1, address p2) internal view { + function log(address p0, bool p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } - function log(address p0, address p1, uint256 p2) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); + function log(address p0, address p1, uint256 p2) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256)", p0, p1, p2)); } - function log(address p0, address p1, string memory p2) internal view { + function log(address p0, address p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } - function log(address p0, address p1, bool p2) internal view { + function log(address p0, address p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } - function log(address p0, address p1, address p2) internal view { + function log(address p0, address p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } - function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,string)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,address)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,string)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, string memory p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,address)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,string)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, bool p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, bool p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,address)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, address p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,string)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, address p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, uint256 p1, address p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); + function log(uint256 p0, uint256 p1, address p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,address)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,string)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,address)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,string)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, string memory p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, string memory p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,address)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, bool p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,string)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, bool p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, bool p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, bool p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,address)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, address p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,string)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, address p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, address p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, string memory p1, address p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); + function log(uint256 p0, string memory p1, address p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,address)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,string)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,address)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, string memory p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,string)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, string memory p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, string memory p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, string memory p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,address)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, bool p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,string)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, bool p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, bool p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, bool p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, bool p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,address)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, address p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, address p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,string)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, address p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, address p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, bool p1, address p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); + function log(uint256 p0, bool p1, address p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,address)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,string)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,address)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, string memory p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,string)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, string memory p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, string memory p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, string memory p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, string memory p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,address)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, bool p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, bool p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,string)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, bool p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, bool p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, bool p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, bool p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,address)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,uint256)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, address p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, address p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,string)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, address p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, address p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,bool)", p0, p1, p2, p3)); } - function log(uint256 p0, address p1, address p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); + function log(uint256 p0, address p1, address p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,address)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,string)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,bool)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,address)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,string)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, string memory p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,bool)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, string memory p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,address)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, bool p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,string)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, bool p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,bool)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, bool p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, bool p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,address)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, address p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,string)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, address p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, address p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,bool)", p0, p1, p2, p3)); } - function log(string memory p0, uint256 p1, address p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); + function log(string memory p0, uint256 p1, address p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,address)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); + function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); + function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,string)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); + function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,bool)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); + function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,address)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); + function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { + function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { + function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, string memory p2, address p3) internal view { + function log(string memory p0, string memory p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); + function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { + function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, bool p2, bool p3) internal view { + function log(string memory p0, string memory p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, bool p2, address p3) internal view { + function log(string memory p0, string memory p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); + function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, address p2, string memory p3) internal view { + function log(string memory p0, string memory p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, address p2, bool p3) internal view { + function log(string memory p0, string memory p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } - function log(string memory p0, string memory p1, address p2, address p3) internal view { + function log(string memory p0, string memory p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); + function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); + function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,string)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); + function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,bool)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); + function log(string memory p0, bool p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,address)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); + function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { + function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, string memory p2, bool p3) internal view { + function log(string memory p0, bool p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, string memory p2, address p3) internal view { + function log(string memory p0, bool p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); + function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, bool p2, string memory p3) internal view { + function log(string memory p0, bool p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, bool p2, bool p3) internal view { + function log(string memory p0, bool p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, bool p2, address p3) internal view { + function log(string memory p0, bool p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); + function log(string memory p0, bool p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, address p2, string memory p3) internal view { + function log(string memory p0, bool p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, address p2, bool p3) internal view { + function log(string memory p0, bool p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } - function log(string memory p0, bool p1, address p2, address p3) internal view { + function log(string memory p0, bool p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); + function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); + function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,string)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); + function log(string memory p0, address p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,bool)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); + function log(string memory p0, address p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,address)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); + function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, string memory p2, string memory p3) internal view { + function log(string memory p0, address p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, string memory p2, bool p3) internal view { + function log(string memory p0, address p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, string memory p2, address p3) internal view { + function log(string memory p0, address p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); + function log(string memory p0, address p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, bool p2, string memory p3) internal view { + function log(string memory p0, address p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, bool p2, bool p3) internal view { + function log(string memory p0, address p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, bool p2, address p3) internal view { + function log(string memory p0, address p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); + function log(string memory p0, address p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint256)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, address p2, string memory p3) internal view { + function log(string memory p0, address p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, address p2, bool p3) internal view { + function log(string memory p0, address p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } - function log(string memory p0, address p1, address p2, address p3) internal view { + function log(string memory p0, address p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,uint256)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,string)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,bool)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,address)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,uint256)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, string memory p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,string)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, string memory p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,bool)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, string memory p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, string memory p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,address)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,uint256)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, bool p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,string)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, bool p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, bool p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,bool)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, bool p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, bool p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,address)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,uint256)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, address p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, address p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,string)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, address p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, address p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,bool)", p0, p1, p2, p3)); } - function log(bool p0, uint256 p1, address p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); + function log(bool p0, uint256 p1, address p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,address)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); + function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,uint256)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); + function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,string)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); + function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,bool)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); + function log(bool p0, string memory p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,address)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); + function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint256)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { + function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, string memory p2, bool p3) internal view { + function log(bool p0, string memory p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, string memory p2, address p3) internal view { + function log(bool p0, string memory p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); + function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint256)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, bool p2, string memory p3) internal view { + function log(bool p0, string memory p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, bool p2, bool p3) internal view { + function log(bool p0, string memory p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, bool p2, address p3) internal view { + function log(bool p0, string memory p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); + function log(bool p0, string memory p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint256)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, address p2, string memory p3) internal view { + function log(bool p0, string memory p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, address p2, bool p3) internal view { + function log(bool p0, string memory p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } - function log(bool p0, string memory p1, address p2, address p3) internal view { + function log(bool p0, string memory p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); + function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,uint256)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); + function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,string)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); + function log(bool p0, bool p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,bool)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); + function log(bool p0, bool p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,address)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); + function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint256)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, string memory p2, string memory p3) internal view { + function log(bool p0, bool p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, string memory p2, bool p3) internal view { + function log(bool p0, bool p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, string memory p2, address p3) internal view { + function log(bool p0, bool p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); + function log(bool p0, bool p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint256)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, bool p2, string memory p3) internal view { + function log(bool p0, bool p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, bool p2, bool p3) internal view { + function log(bool p0, bool p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, bool p2, address p3) internal view { + function log(bool p0, bool p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); + function log(bool p0, bool p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint256)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, address p2, string memory p3) internal view { + function log(bool p0, bool p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, address p2, bool p3) internal view { + function log(bool p0, bool p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } - function log(bool p0, bool p1, address p2, address p3) internal view { + function log(bool p0, bool p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } - function log(bool p0, address p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); + function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,uint256)", p0, p1, p2, p3)); } - function log(bool p0, address p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); + function log(bool p0, address p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,string)", p0, p1, p2, p3)); } - function log(bool p0, address p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); + function log(bool p0, address p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,bool)", p0, p1, p2, p3)); } - function log(bool p0, address p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); + function log(bool p0, address p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,address)", p0, p1, p2, p3)); } - function log(bool p0, address p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); + function log(bool p0, address p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint256)", p0, p1, p2, p3)); } - function log(bool p0, address p1, string memory p2, string memory p3) internal view { + function log(bool p0, address p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } - function log(bool p0, address p1, string memory p2, bool p3) internal view { + function log(bool p0, address p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } - function log(bool p0, address p1, string memory p2, address p3) internal view { + function log(bool p0, address p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } - function log(bool p0, address p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); + function log(bool p0, address p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint256)", p0, p1, p2, p3)); } - function log(bool p0, address p1, bool p2, string memory p3) internal view { + function log(bool p0, address p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } - function log(bool p0, address p1, bool p2, bool p3) internal view { + function log(bool p0, address p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } - function log(bool p0, address p1, bool p2, address p3) internal view { + function log(bool p0, address p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } - function log(bool p0, address p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); + function log(bool p0, address p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint256)", p0, p1, p2, p3)); } - function log(bool p0, address p1, address p2, string memory p3) internal view { + function log(bool p0, address p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } - function log(bool p0, address p1, address p2, bool p3) internal view { + function log(bool p0, address p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } - function log(bool p0, address p1, address p2, address p3) internal view { + function log(bool p0, address p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,uint256)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,string)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,bool)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,address)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,uint256)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, string memory p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,string)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, string memory p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, string memory p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,bool)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, string memory p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, string memory p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,address)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,uint256)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, bool p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, bool p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,string)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, bool p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, bool p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,bool)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, bool p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, bool p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,address)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,uint256)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, address p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, address p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,string)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, address p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, address p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,bool)", p0, p1, p2, p3)); } - function log(address p0, uint256 p1, address p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); + function log(address p0, uint256 p1, address p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,address)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); + function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,uint256)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); + function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,string)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); + function log(address p0, string memory p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,bool)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); + function log(address p0, string memory p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,address)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); + function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint256)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, string memory p2, string memory p3) internal view { + function log(address p0, string memory p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, string memory p2, bool p3) internal view { + function log(address p0, string memory p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, string memory p2, address p3) internal view { + function log(address p0, string memory p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); + function log(address p0, string memory p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint256)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, bool p2, string memory p3) internal view { + function log(address p0, string memory p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, bool p2, bool p3) internal view { + function log(address p0, string memory p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, bool p2, address p3) internal view { + function log(address p0, string memory p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); + function log(address p0, string memory p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint256)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, address p2, string memory p3) internal view { + function log(address p0, string memory p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, address p2, bool p3) internal view { + function log(address p0, string memory p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } - function log(address p0, string memory p1, address p2, address p3) internal view { + function log(address p0, string memory p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } - function log(address p0, bool p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); + function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,uint256)", p0, p1, p2, p3)); } - function log(address p0, bool p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); + function log(address p0, bool p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,string)", p0, p1, p2, p3)); } - function log(address p0, bool p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); + function log(address p0, bool p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,bool)", p0, p1, p2, p3)); } - function log(address p0, bool p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); + function log(address p0, bool p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,address)", p0, p1, p2, p3)); } - function log(address p0, bool p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); + function log(address p0, bool p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint256)", p0, p1, p2, p3)); } - function log(address p0, bool p1, string memory p2, string memory p3) internal view { + function log(address p0, bool p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } - function log(address p0, bool p1, string memory p2, bool p3) internal view { + function log(address p0, bool p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } - function log(address p0, bool p1, string memory p2, address p3) internal view { + function log(address p0, bool p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } - function log(address p0, bool p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); + function log(address p0, bool p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint256)", p0, p1, p2, p3)); } - function log(address p0, bool p1, bool p2, string memory p3) internal view { + function log(address p0, bool p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } - function log(address p0, bool p1, bool p2, bool p3) internal view { + function log(address p0, bool p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } - function log(address p0, bool p1, bool p2, address p3) internal view { + function log(address p0, bool p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } - function log(address p0, bool p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); + function log(address p0, bool p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint256)", p0, p1, p2, p3)); } - function log(address p0, bool p1, address p2, string memory p3) internal view { + function log(address p0, bool p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } - function log(address p0, bool p1, address p2, bool p3) internal view { + function log(address p0, bool p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } - function log(address p0, bool p1, address p2, address p3) internal view { + function log(address p0, bool p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } - function log(address p0, address p1, uint256 p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); + function log(address p0, address p1, uint256 p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,uint256)", p0, p1, p2, p3)); } - function log(address p0, address p1, uint256 p2, string memory p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); + function log(address p0, address p1, uint256 p2, string memory p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,string)", p0, p1, p2, p3)); } - function log(address p0, address p1, uint256 p2, bool p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); + function log(address p0, address p1, uint256 p2, bool p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,bool)", p0, p1, p2, p3)); } - function log(address p0, address p1, uint256 p2, address p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); + function log(address p0, address p1, uint256 p2, address p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,address)", p0, p1, p2, p3)); } - function log(address p0, address p1, string memory p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); + function log(address p0, address p1, string memory p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint256)", p0, p1, p2, p3)); } - function log(address p0, address p1, string memory p2, string memory p3) internal view { + function log(address p0, address p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } - function log(address p0, address p1, string memory p2, bool p3) internal view { + function log(address p0, address p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } - function log(address p0, address p1, string memory p2, address p3) internal view { + function log(address p0, address p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } - function log(address p0, address p1, bool p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); + function log(address p0, address p1, bool p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint256)", p0, p1, p2, p3)); } - function log(address p0, address p1, bool p2, string memory p3) internal view { + function log(address p0, address p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } - function log(address p0, address p1, bool p2, bool p3) internal view { + function log(address p0, address p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } - function log(address p0, address p1, bool p2, address p3) internal view { + function log(address p0, address p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } - function log(address p0, address p1, address p2, uint256 p3) internal view { - _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); + function log(address p0, address p1, address p2, uint256 p3) internal pure { + _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint256)", p0, p1, p2, p3)); } - function log(address p0, address p1, address p2, string memory p3) internal view { + function log(address p0, address p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } - function log(address p0, address p1, address p2, bool p3) internal view { + function log(address p0, address p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } - function log(address p0, address p1, address p2, address p3) internal view { + function log(address p0, address p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } From 082104867cc0d587196eec715a75736d61dbd9fa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 26 Jan 2025 05:31:26 +0000 Subject: [PATCH 1888/1963] chore(deps): weekly `cargo update` (#9755) --- Cargo.lock | 96 ++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9424903f2c37..c3f8f8131e8d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a725039ef382d1b6b4e2ebcb15b1efff6cde9af48c47a1bdce6fb67b9456c34b" +checksum = "4ab9d1367c6ffb90c93fb4a9a4989530aa85112438c6f73a734067255d348469" dependencies = [ "alloy-primitives", "num_enum", @@ -1361,9 +1361,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.14" +version = "1.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f40e82e858e02445402906e454a73e244c7f501fcae198977585946c48e8697" +checksum = "dc47e70fc35d054c8fcd296d47a61711f043ac80534a10b4f741904f81e73a90" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1423,14 +1423,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.12.0", + "uuid 1.12.1", ] [[package]] name = "aws-sdk-kms" -version = "1.55.0" +version = "1.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "011f0f9ebfaa2f76f0cddcc05a6951c74c226af8a493c56ef7ca1a880e1de4ac" +checksum = "f7b2cd8354dcccf1ae003100a41c7b862837cfd7af14a42b1e3ed98a8c3e487b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1450,9 +1450,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.54.0" +version = "1.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921a13ed6aabe2d1258f65ef7804946255c799224440774c30e1a2c65cdf983a" +checksum = "12e057fdcb8842de9b83592a70f5b4da0ee10bc0ad278247da1425a742a444d7" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1472,9 +1472,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.55.0" +version = "1.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196c952738b05dfc917d82a3e9b5ba850822a6d6a86d677afda2a156cc172ceb" +checksum = "a120ade4a44691b3c5c2ff2fa61b14ed331fdc218397f61ab48d66593012ae2a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1494,9 +1494,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.55.0" +version = "1.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ef5b73a927ed80b44096f8c20fb4abae65469af15198367e179ae267256e9d" +checksum = "115fd4fb663817ed595a5ee4f1649d7aacd861d47462323cb37576ce89271b93" dependencies = [ "aws-credential-types", "aws-runtime", @@ -2183,9 +2183,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.26" +version = "4.5.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" +checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" dependencies = [ "clap_builder", "clap_derive", @@ -2193,9 +2193,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.26" +version = "4.5.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" +checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" dependencies = [ "anstream", "anstyle", @@ -2506,9 +2506,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -2583,9 +2583,9 @@ dependencies = [ [[package]] name = "crunchy" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" [[package]] name = "crypto-bigint" @@ -5374,13 +5374,13 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "is-terminal" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" dependencies = [ "hermit-abi 0.4.0", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5433,9 +5433,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.24" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bb0c2e28117985a4d90e3bc70092bc8f226f434c7ec7e23dd9ff99c5c5721a" +checksum = "a85348106ab244d90fe2d70faad939b71c5dad1258e5da9116e176064fc6c078" dependencies = [ "jiff-tzdb-platform", "log", @@ -5707,9 +5707,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "maili-consensus" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59cc5082a9b883b719fb3594257e56e9c6990cf49d7b41188adb51ab6c83cd1e" +checksum = "f6c278346ab9cfef7688510e28a042d8a23c953380e7361a1286920ccbd0d847" dependencies = [ "alloy-consensus", "alloy-eips", @@ -5948,9 +5948,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +checksum = "0dab59f8e050d5df8e4dd87d9206fb6f65a483e20ac9fda365ade4fab353196c" dependencies = [ "libc", "log", @@ -5975,7 +5975,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee3224f0e8be7c2a1ebc77ef9c3eecb90f55c6594399ee825de964526b3c9056" dependencies = [ - "uuid 1.12.0", + "uuid 1.12.1", ] [[package]] @@ -6264,9 +6264,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e51ae52013aca0aa1ca3df7ecf0d276eb4214ec44aeb9c48651333e1459b3b5" +checksum = "e28dc4e397dd8969f7f98ea6454a5c531349a58c76e12448b0c2de6581df7b8c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6274,16 +6274,15 @@ dependencies = [ "alloy-rlp", "alloy-serde", "derive_more", - "maili-consensus", "serde", "thiserror 2.0.11", ] [[package]] name = "op-alloy-rpc-types" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071c64a4fa84544f60e2bc118f963dbb1976aa33509f185bee1b8a1a2842123c" +checksum = "4b9c83c664b953d474d6b58825800b6ff1d61876a686407e646cbf76891c1f9b" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6292,7 +6291,6 @@ dependencies = [ "alloy-rpc-types-eth", "alloy-serde", "derive_more", - "maili-consensus", "op-alloy-consensus", "serde", "serde_json", @@ -6312,9 +6310,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "f5e534d133a060a3c19daec1eb3e98ec6f4685978834f2dbadfe2ec215bab64e" dependencies = [ "bitflags 2.8.0", "cfg-if", @@ -6338,9 +6336,9 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" @@ -7047,7 +7045,7 @@ dependencies = [ "quick-xml 0.37.2", "strip-ansi-escapes", "thiserror 2.0.11", - "uuid 1.12.0", + "uuid 1.12.1", ] [[package]] @@ -7597,9 +7595,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.43" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags 2.8.0", "errno", @@ -8487,7 +8485,7 @@ dependencies = [ "thiserror 2.0.11", "tokio", "toml_edit", - "uuid 1.12.0", + "uuid 1.12.1", "zip", "zip-extract", ] @@ -9406,9 +9404,9 @@ checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "11cd88e12b17c6494200a9c1b683a04fcac9573ed74cd1b62aeb2727c5592243" [[package]] name = "unicode-linebreak" @@ -9525,9 +9523,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" +checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" dependencies = [ "getrandom", "serde", From ca466ae80b84eb4045e6b9075955632c4a7392ca Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 27 Jan 2025 07:53:44 +0200 Subject: [PATCH 1889/1963] fix(cheatcode): expect revert only for calls with greater depth than test (#9537) * fix(cheatcode): expect revert only for calls with greater depth * Add config to allow expect revert for internal calls * Fix default config test * Update crates/cheatcodes/src/inspector.rs Co-authored-by: Matthias Seitz --------- Co-authored-by: Matthias Seitz --- crates/cheatcodes/src/config.rs | 4 ++ crates/cheatcodes/src/inspector.rs | 34 ++++++----- crates/cheatcodes/src/test/expect.rs | 3 + crates/cheatcodes/src/test/revert_handlers.rs | 9 +++ crates/config/src/lib.rs | 3 + crates/forge/tests/cli/config.rs | 3 + crates/forge/tests/it/repros.rs | 3 + crates/test-utils/src/util.rs | 1 + .../default/cheats/AttachDelegation.t.sol | 3 +- .../cheats/BroadcastRawTransaction.t.sol | 4 +- testdata/default/cheats/MemSafety.t.sol | 2 + testdata/default/cheats/MockCall.t.sol | 56 +++++++++++++------ .../default/cheats/RandomCheatcodes.t.sol | 6 +- testdata/default/repros/Issue7238.t.sol | 51 +++++++++++++++++ testdata/default/repros/Issue7457.t.sol | 1 + testdata/paris/cheats/LastCallGas.t.sol | 2 +- 16 files changed, 147 insertions(+), 38 deletions(-) create mode 100644 testdata/default/repros/Issue7238.t.sol diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 40e0633711c32..3ab70f6e053fb 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -54,6 +54,8 @@ pub struct CheatsConfig { pub assertions_revert: bool, /// Optional seed for the RNG algorithm. pub seed: Option, + /// Whether to allow `expectRevert` to work for internal calls. + pub internal_expect_revert: bool, } impl CheatsConfig { @@ -93,6 +95,7 @@ impl CheatsConfig { running_artifact, assertions_revert: config.assertions_revert, seed: config.fuzz.seed, + internal_expect_revert: config.allow_internal_expect_revert, } } @@ -222,6 +225,7 @@ impl Default for CheatsConfig { running_artifact: Default::default(), assertions_revert: true, seed: None, + internal_expect_revert: false, } } } diff --git a/crates/cheatcodes/src/inspector.rs b/crates/cheatcodes/src/inspector.rs index 0ba163f8366cf..cf6248c8f02bf 100644 --- a/crates/cheatcodes/src/inspector.rs +++ b/crates/cheatcodes/src/inspector.rs @@ -55,6 +55,7 @@ use revm::{ }; use serde_json::Value; use std::{ + cmp::max, collections::{BTreeMap, VecDeque}, fs::File, io::BufReader, @@ -759,6 +760,7 @@ where { return match revert_handlers::handle_expect_revert( false, true, + self.config.internal_expect_revert, &expected_revert, outcome.result.result, outcome.result.output.clone(), @@ -1175,6 +1177,11 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { if self.gas_metering.paused { self.gas_metering.paused_frames.push(interpreter.gas); } + + // `expectRevert`: track the max call depth during `expectRevert` + if let Some(expected) = &mut self.expected_revert { + expected.max_depth = max(ecx.journaled_state.depth(), expected.max_depth); + } } #[inline] @@ -1330,21 +1337,17 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { // Handle expected reverts. if let Some(expected_revert) = &mut self.expected_revert { - // Record current reverter address before processing the expect revert if call reverted, - // expect revert is set with expected reverter address and no actual reverter set yet. - if outcome.result.is_revert() && - expected_revert.reverter.is_some() && - expected_revert.reverted_by.is_none() - { - expected_revert.reverted_by = Some(call.target_address); - } else if outcome.result.is_revert() && - expected_revert.reverter.is_some() && - expected_revert.reverted_by.is_some() && - expected_revert.count > 1 - { - // If we're expecting more than one revert, we need to reset the reverted_by address - // to latest reverter. - expected_revert.reverted_by = Some(call.target_address); + // Record current reverter address and call scheme before processing the expect revert + // if call reverted. + if outcome.result.is_revert() { + // 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) + { + expected_revert.reverted_by = Some(call.target_address); + } } if ecx.journaled_state.depth() <= expected_revert.depth { @@ -1362,6 +1365,7 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes { return match revert_handlers::handle_expect_revert( cheatcode_call, false, + self.config.internal_expect_revert, &expected_revert, outcome.result.result, outcome.result.output.clone(), diff --git a/crates/cheatcodes/src/test/expect.rs b/crates/cheatcodes/src/test/expect.rs index f77eb4d402cff..11d0e65a02379 100644 --- a/crates/cheatcodes/src/test/expect.rs +++ b/crates/cheatcodes/src/test/expect.rs @@ -72,6 +72,8 @@ pub struct ExpectedRevert { pub reverter: Option
, /// Address that reverted the call. pub reverted_by: Option
, + /// Max call depth reached during next call execution. + pub max_depth: u64, /// Number of times this revert is expected. pub count: u64, /// Actual number of times this revert has been seen. @@ -911,6 +913,7 @@ fn expect_revert( partial_match, reverter, reverted_by: None, + max_depth: depth, count, actual_count: 0, }); diff --git a/crates/cheatcodes/src/test/revert_handlers.rs b/crates/cheatcodes/src/test/revert_handlers.rs index 78297b38872aa..4368d0dc2a261 100644 --- a/crates/cheatcodes/src/test/revert_handlers.rs +++ b/crates/cheatcodes/src/test/revert_handlers.rs @@ -144,6 +144,7 @@ pub(crate) fn handle_assume_no_revert( pub(crate) fn handle_expect_revert( is_cheatcode: bool, is_create: bool, + internal_expect_revert: bool, expected_revert: &ExpectedRevert, status: InstructionResult, retdata: Bytes, @@ -157,6 +158,14 @@ pub(crate) fn handle_expect_revert( } }; + // Check depths if it's not an expect cheatcode call and if internal expect reverts not enabled. + if !is_cheatcode && !internal_expect_revert { + ensure!( + expected_revert.max_depth > expected_revert.depth, + "call didn't revert at a lower depth than cheatcode call depth" + ); + } + if expected_revert.count == 0 { if expected_revert.reverter.is_none() && expected_revert.reason.is_none() { ensure!( diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 4252d2d163b99..98ae60a77ef66 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -317,6 +317,8 @@ pub struct Config { pub invariant: InvariantConfig, /// Whether to allow ffi cheatcodes in test pub ffi: bool, + /// Whether to allow `expectRevert` for internal functions. + pub allow_internal_expect_revert: bool, /// Use the create 2 factory in all cases including tests and non-broadcasting scripts. pub always_use_create_2_factory: bool, /// Sets a timeout in seconds for vm.prompt cheatcodes @@ -2341,6 +2343,7 @@ impl Default for Config { invariant: InvariantConfig::new("cache/invariant".into()), always_use_create_2_factory: false, ffi: false, + allow_internal_expect_revert: false, prompt_timeout: 120, sender: Self::DEFAULT_SENDER, tx_origin: Self::DEFAULT_SENDER, diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index fe8a385a4f703..3941d3f6f804d 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -87,6 +87,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { ..Default::default() }, ffi: true, + allow_internal_expect_revert: false, always_use_create_2_factory: false, prompt_timeout: 0, sender: "00a329c0648769A73afAc7F9381D08FB43dBEA72".parse().unwrap(), @@ -1003,6 +1004,7 @@ show_progress = false eof = false transaction_timeout = 120 ffi = false +allow_internal_expect_revert = false always_use_create_2_factory = false prompt_timeout = 120 sender = "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38" @@ -1204,6 +1206,7 @@ exclude = [] "timeout": null }, "ffi": false, + "allow_internal_expect_revert": false, "always_use_create_2_factory": false, "prompt_timeout": 120, "sender": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index d5d1fbbdb30a6..c2ebb32518d65 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -395,3 +395,6 @@ test_repro!(8566); // https://github.com/foundry-rs/foundry/issues/9643 test_repro!(9643); + +// https://github.com/foundry-rs/foundry/issues/7238 +test_repro!(7238); diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index e7410ed607edb..17bffcb6451a8 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -207,6 +207,7 @@ impl ExtTester { test_cmd.env("FOUNDRY_FORK_BLOCK_NUMBER", fork_block.to_string()); } test_cmd.env("FOUNDRY_INVARIANT_DEPTH", "15"); + test_cmd.env("FOUNDRY_ALLOW_INTERNAL_EXPECT_REVERT", "true"); test_cmd.assert_success(); } diff --git a/testdata/default/cheats/AttachDelegation.t.sol b/testdata/default/cheats/AttachDelegation.t.sol index 7befc9a32047c..2b2e829ae350d 100644 --- a/testdata/default/cheats/AttachDelegation.t.sol +++ b/testdata/default/cheats/AttachDelegation.t.sol @@ -86,6 +86,7 @@ contract AttachDelegationTest is DSTest { assertEq(token.balanceOf(bob), 200); } + /// forge-config: default.allow_internal_expect_revert = true function testAttachDelegationRevertInvalidSignature() public { Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); // change v from 1 to 0 @@ -109,7 +110,7 @@ contract AttachDelegationTest is DSTest { // send tx to increment alice's nonce token.mint(1, bob); - vm.expectRevert("vm.attachDelegation: invalid nonce"); + vm._expectCheatcodeRevert("vm.attachDelegation: invalid nonce"); vm.attachDelegation(signedDelegation); } diff --git a/testdata/default/cheats/BroadcastRawTransaction.t.sol b/testdata/default/cheats/BroadcastRawTransaction.t.sol index 5bd400a9f71e3..36682bc893359 100644 --- a/testdata/default/cheats/BroadcastRawTransaction.t.sol +++ b/testdata/default/cheats/BroadcastRawTransaction.t.sol @@ -117,8 +117,8 @@ contract BroadcastRawTransactionTest is DSTest { assertEq(address(from).balance, balance - (gasPrice * 21_000) - amountSent); assertEq(address(to).balance, amountSent); - vm.expectRevert(); - assert(3 == 4); + vm._expectCheatcodeRevert(); + vm.assertFalse(true); } function test_execute_multiple_signed_tx() public { diff --git a/testdata/default/cheats/MemSafety.t.sol b/testdata/default/cheats/MemSafety.t.sol index a5c0a5a4ff614..2093c20fd56ec 100644 --- a/testdata/default/cheats/MemSafety.t.sol +++ b/testdata/default/cheats/MemSafety.t.sol @@ -413,6 +413,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` /// will cause the test to fail while using the `MLOAD` opcode. + /// forge-config: default.allow_internal_expect_revert = true function testExpectSafeMemory_MLOAD_REVERT() public { vm.expectSafeMemory(0x80, 0x100); @@ -504,6 +505,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` /// will cause the test to fail while using the `LOG0` opcode. + /// forge-config: default.allow_internal_expect_revert = true function testExpectSafeMemory_LOG0_REVERT() public { vm.expectSafeMemory(0x80, 0x100); vm.expectRevert(); diff --git a/testdata/default/cheats/MockCall.t.sol b/testdata/default/cheats/MockCall.t.sol index f85e9c8239bdc..f11fd20984571 100644 --- a/testdata/default/cheats/MockCall.t.sol +++ b/testdata/default/cheats/MockCall.t.sol @@ -201,8 +201,11 @@ contract MockCallRevertTest is DSTest { // post-mock assertEq(target.numberA(), 1); - vm.expectRevert(); - target.numberB(); + try target.numberB() { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(ERROR_MESSAGE)); + } } function testMockRevertWithCustomError() public { @@ -216,8 +219,11 @@ contract MockCallRevertTest is DSTest { vm.mockCallRevert(address(target), abi.encodeWithSelector(target.numberB.selector), customError); assertEq(target.numberA(), 1); - vm.expectRevert(customError); - target.numberB(); + try target.numberB() { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(customError)); + } } function testMockNestedRevert() public { @@ -228,8 +234,11 @@ contract MockCallRevertTest is DSTest { vm.mockCallRevert(address(inner), abi.encodeWithSelector(inner.numberB.selector), ERROR_MESSAGE); - vm.expectRevert(ERROR_MESSAGE); - target.sum(); + try target.sum() { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(ERROR_MESSAGE)); + } } function testMockCalldataRevert() public { @@ -241,8 +250,11 @@ contract MockCallRevertTest is DSTest { assertEq(target.add(6, 4), 10); - vm.expectRevert(ERROR_MESSAGE); - target.add(5, 5); + try target.add(5, 5) { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(ERROR_MESSAGE)); + } } function testClearMockRevertedCalls() public { @@ -263,8 +275,11 @@ contract MockCallRevertTest is DSTest { assertEq(mock.add(1, 2), 3); - vm.expectRevert(ERROR_MESSAGE); - mock.add(2, 3); + try mock.add(2, 3) { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(ERROR_MESSAGE)); + } } function testMockCallRevertWithValue() public { @@ -275,8 +290,11 @@ contract MockCallRevertTest is DSTest { assertEq(mock.pay(1), 1); assertEq(mock.pay(2), 2); - vm.expectRevert(ERROR_MESSAGE); - mock.pay{value: 10}(1); + try mock.pay{value: 10}(1) { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(ERROR_MESSAGE)); + } } function testMockCallResetsMockCallRevert() public { @@ -296,8 +314,11 @@ contract MockCallRevertTest is DSTest { vm.mockCallRevert(address(mock), abi.encodeWithSelector(mock.add.selector), ERROR_MESSAGE); - vm.expectRevert(ERROR_MESSAGE); - mock.add(2, 3); + try mock.add(2, 3) { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(ERROR_MESSAGE)); + } } function testMockCallRevertWithCall() public { @@ -317,7 +338,10 @@ contract MockCallRevertTest is DSTest { vm.mockCallRevert(address(mock), abi.encodeWithSelector(mock.add.selector), ERROR_MESSAGE); - vm.expectRevert(ERROR_MESSAGE); - mock.add(1, 2); + try mock.add(2, 3) { + revert(); + } catch (bytes memory err) { + require(keccak256(err) == keccak256(ERROR_MESSAGE)); + } } } diff --git a/testdata/default/cheats/RandomCheatcodes.t.sol b/testdata/default/cheats/RandomCheatcodes.t.sol index beeee9862bbb6..4c3e1fffdfde0 100644 --- a/testdata/default/cheats/RandomCheatcodes.t.sol +++ b/testdata/default/cheats/RandomCheatcodes.t.sol @@ -11,7 +11,7 @@ contract RandomCheatcodesTest is DSTest { int128 constant max = 170141183460469231731687303715884105727; function test_int128() public { - vm.expectRevert("vm.randomInt: number of bits cannot exceed 256"); + vm._expectCheatcodeRevert("vm.randomInt: number of bits cannot exceed 256"); int256 val = vm.randomInt(type(uint256).max); val = vm.randomInt(128); @@ -31,7 +31,7 @@ contract RandomCheatcodesTest is DSTest { } function test_randomUintLimit() public { - vm.expectRevert("vm.randomUint: number of bits cannot exceed 256"); + vm._expectCheatcodeRevert("vm.randomUint: number of bits cannot exceed 256"); uint256 val = vm.randomUint(type(uint256).max); } @@ -67,7 +67,7 @@ contract RandomBytesTest is DSTest { } function test_symbolic_bytes_revert() public { - vm.expectRevert(); + vm._expectCheatcodeRevert(); bytes memory val = vm.randomBytes(type(uint256).max); } diff --git a/testdata/default/repros/Issue7238.t.sol b/testdata/default/repros/Issue7238.t.sol new file mode 100644 index 0000000000000..73befa3eaaab0 --- /dev/null +++ b/testdata/default/repros/Issue7238.t.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract Reverter { + function doNotRevert() public {} + + function revertWithMessage(string calldata message) public { + revert(message); + } +} + +// https://github.com/foundry-rs/foundry/issues/7238 +contract Issue7238Test is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testExpectRevertString() public { + Reverter reverter = new Reverter(); + vm.expectRevert("revert"); + reverter.revertWithMessage("revert"); + } + + // FAIL + function testFailRevertNotOnImmediateNextCall() public { + Reverter reverter = new Reverter(); + // expectRevert should only work for the next call. However, + // we do not inmediately revert, so, + // we fail. + vm.expectRevert("revert"); + reverter.doNotRevert(); + reverter.revertWithMessage("revert"); + } + + // FAIL + function testFailCheatcodeRevert() public { + // This expectRevert is hanging, as the next cheatcode call is ignored. + vm.expectRevert(); + vm.fsMetadata("something/something"); // try to go to some non-existent path to cause a revert + } + + function testFailEarlyRevert() public { + vm.expectRevert(); + rever(); + } + + function rever() internal { + revert(); + } +} diff --git a/testdata/default/repros/Issue7457.t.sol b/testdata/default/repros/Issue7457.t.sol index 1836c48254d55..d95f79c4835f2 100644 --- a/testdata/default/repros/Issue7457.t.sol +++ b/testdata/default/repros/Issue7457.t.sol @@ -61,6 +61,7 @@ contract Issue7457Test is DSTest, ITarget { target.emitAnonymousEventEmpty(); } + /// forge-config: default.allow_internal_expect_revert = true function testEmitEventNonIndexedReverts() public { vm.expectEmit(false, false, false, true); vm.expectRevert("use vm.expectEmitAnonymous to match anonymous events"); diff --git a/testdata/paris/cheats/LastCallGas.t.sol b/testdata/paris/cheats/LastCallGas.t.sol index bc7ac42639505..23f6df224963f 100644 --- a/testdata/paris/cheats/LastCallGas.t.sol +++ b/testdata/paris/cheats/LastCallGas.t.sol @@ -39,7 +39,7 @@ abstract contract LastCallGasFixture is DSTest { } function testRevertNoCachedLastCallGas() public { - vm.expectRevert(); + vm._expectCheatcodeRevert(); vm.lastCallGas(); } From b081d66d1145f2a34e929cceb6e225619f77431b Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:37:20 +0530 Subject: [PATCH 1890/1963] fix(`forge bind`): prefix keyword mod names with `r#` (#9761) * fix(`forge bind`): prefix keyword mod names with r# * nit * is_ok --- crates/forge/tests/cli/cmd.rs | 31 +++++++++++++++++++++++ crates/sol-macro-gen/src/sol_macro_gen.rs | 25 +++++++++--------- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 35a7bd4411a7f..1f82a6be95e29 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -3519,3 +3519,34 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) .is_json(), ); }); + +// +forgetest_init!(can_bind_enum_modules, |prj, cmd| { + prj.clear(); + + prj.add_source( + "Enum.sol", + r#" + contract Enum { + enum MyEnum { A, B, C } + } + "#, + ) + .unwrap(); + + prj.add_source( + "UseEnum.sol", + r#" + import "./Enum.sol"; + contract UseEnum { + Enum.MyEnum public myEnum; + }"#, + ) + .unwrap(); + + cmd.arg("bind").assert_success().stdout_eq(str![[r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! +Generating bindings for 11 contracts +Bindings have been generated to [..]"#]]); +}); diff --git a/crates/sol-macro-gen/src/sol_macro_gen.rs b/crates/sol-macro-gen/src/sol_macro_gen.rs index 8c146aa05ddac..9b907eb3ad087 100644 --- a/crates/sol-macro-gen/src/sol_macro_gen.rs +++ b/crates/sol-macro-gen/src/sol_macro_gen.rs @@ -165,7 +165,7 @@ edition = "2021" write!(&mut lib_contents, "{contents}")?; } else { fs::write(path, contents).wrap_err("failed to write to file")?; - writeln!(&mut lib_contents, "pub mod {name};")?; + write_mod_name(&mut lib_contents, &name)?; } } @@ -194,12 +194,7 @@ edition = "2021" let name = instance.name.to_lowercase(); if !single_file { // Module - write!( - mod_contents, - r#"pub mod {}; - "#, - instance.name.to_lowercase() - )?; + write_mod_name(&mut mod_contents, &name)?; let mut contents = String::new(); write!(contents, "{}", instance.expansion.as_ref().unwrap())?; @@ -270,12 +265,7 @@ edition = "2021" .to_string(); self.check_file_contents(&path, &tokens)?; - - write!( - &mut super_contents, - r#"pub mod {name}; - "# - )?; + write_mod_name(&mut super_contents, &name)?; } let super_path = @@ -344,3 +334,12 @@ edition = "2021" Ok(()) } } + +fn write_mod_name(contents: &mut String, name: &str) -> Result<()> { + if syn::parse_str::(&format!("pub mod {name};")).is_ok() { + write!(contents, "pub mod {name};")?; + } else { + write!(contents, "pub mod r#{name};")?; + } + Ok(()) +} From 5261dc1adf59339ad0af8490e0bedfcb9ffe8787 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 27 Jan 2025 23:06:14 +0530 Subject: [PATCH 1891/1963] feat(`cast source`): support alternative explorers (#9762) * feat(`cast`): support alternative explorers in `source` * fix * fix --- crates/cast/bin/args.rs | 13 +++++- crates/cast/bin/cmd/bind.rs | 2 +- crates/cast/bin/main.rs | 46 +++++++++++++++---- crates/cast/src/lib.rs | 55 +++++++++++++++++++---- crates/cast/tests/cli/main.rs | 40 +++++++++++++++++ crates/forge/tests/cli/verify_bytecode.rs | 4 +- 6 files changed, 138 insertions(+), 22 deletions(-) diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index add3f55bc5b12..e8be1da5eb226 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -921,9 +921,9 @@ pub enum CastSubcommand { rpc: RpcOpts, }, - /// Get the source code of a contract from Etherscan. + /// Get the source code of a contract from a block explorer. #[command(visible_aliases = &["et", "src"])] - EtherscanSource { + Source { /// The contract's address. address: String, @@ -937,6 +937,15 @@ pub enum CastSubcommand { #[command(flatten)] etherscan: EtherscanOpts, + + /// Alternative explorer API URL to use that adheres to the Etherscan API. If not provided, + /// defaults to Etherscan. + #[arg(long, env = "EXPLORER_API_URL")] + explorer_api_url: Option, + + /// Alternative explorer browser URL. + #[arg(long, env = "EXPLORER_URL")] + explorer_url: Option, }, /// Wallet management utilities. diff --git a/crates/cast/bin/cmd/bind.rs b/crates/cast/bin/cmd/bind.rs index 942c441f6c1ff..159302344e528 100644 --- a/crates/cast/bin/cmd/bind.rs +++ b/crates/cast/bin/cmd/bind.rs @@ -57,7 +57,7 @@ impl BindArgs { pub async fn run(self) -> Result<()> { Err(eyre::eyre!( "`cast bind` has been removed.\n\ - Please use `cast etherscan-source` to create a Forge project from an Etherscan source\n\ + Please use `cast source` to create a Forge project from a block explorer source\n\ and `forge bind` to generate the bindings to it instead." )) } diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 86c0fa19c68ee..2f5f9afb2fe17 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -630,20 +630,50 @@ async fn main_args(args: CastArgs) -> Result<()> { "{}", SimpleCast::right_shift(&value, &bits, base_in.as_deref(), &base_out)? )?, - CastSubcommand::EtherscanSource { address, directory, etherscan, flatten } => { + CastSubcommand::Source { + address, + directory, + explorer_api_url, + explorer_url, + etherscan, + flatten, + } => { let config = etherscan.load_config()?; let chain = config.chain.unwrap_or_default(); - let api_key = config.get_etherscan_api_key(Some(chain)).unwrap_or_default(); + let api_key = config.get_etherscan_api_key(Some(chain)); match (directory, flatten) { (Some(dir), false) => { - SimpleCast::expand_etherscan_source_to_directory(chain, address, api_key, dir) - .await? - } - (None, false) => { - sh_println!("{}", SimpleCast::etherscan_source(chain, address, api_key).await?)? + SimpleCast::expand_etherscan_source_to_directory( + chain, + address, + api_key, + dir, + explorer_api_url, + explorer_url, + ) + .await? } + (None, false) => sh_println!( + "{}", + SimpleCast::etherscan_source( + chain, + address, + api_key, + explorer_api_url, + explorer_url + ) + .await? + )?, (dir, true) => { - SimpleCast::etherscan_source_flatten(chain, address, api_key, dir).await?; + SimpleCast::etherscan_source_flatten( + chain, + address, + api_key, + dir, + explorer_api_url, + explorer_url, + ) + .await?; } } } diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 21ee2f04ec9a5..6d51bd9303ced 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -21,7 +21,7 @@ use alloy_sol_types::sol; use alloy_transport::Transport; use base::{Base, NumberWithBase, ToBase}; use chrono::DateTime; -use eyre::{Context, ContextCompat, Result}; +use eyre::{Context, ContextCompat, OptionExt, Result}; use foundry_block_explorers::Client; use foundry_common::{ abi::{encode_function_args, get_func}, @@ -1937,7 +1937,9 @@ impl SimpleCast { /// Cast::etherscan_source( /// NamedChain::Mainnet.into(), /// "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), - /// "".to_string() + /// Some("".to_string()), + /// None, + /// None /// ) /// .await /// .unwrap() @@ -1949,9 +1951,11 @@ impl SimpleCast { pub async fn etherscan_source( chain: Chain, contract_address: String, - etherscan_api_key: String, + etherscan_api_key: Option, + explorer_api_url: Option, + explorer_url: Option, ) -> Result { - let client = Client::new(chain, etherscan_api_key)?; + let client = explorer_client(chain, etherscan_api_key, explorer_api_url, explorer_url)?; let metadata = client.contract_source_code(contract_address.parse()?).await?; Ok(metadata.source_code()) } @@ -1969,8 +1973,10 @@ impl SimpleCast { /// Cast::expand_etherscan_source_to_directory( /// NamedChain::Mainnet.into(), /// "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".to_string(), - /// "".to_string(), + /// Some("".to_string()), /// PathBuf::from("output_dir"), + /// None, + /// None, /// ) /// .await?; /// # Ok(()) @@ -1979,10 +1985,12 @@ impl SimpleCast { pub async fn expand_etherscan_source_to_directory( chain: Chain, contract_address: String, - etherscan_api_key: String, + etherscan_api_key: Option, output_directory: PathBuf, + explorer_api_url: Option, + explorer_url: Option, ) -> eyre::Result<()> { - let client = Client::new(chain, etherscan_api_key)?; + let client = explorer_client(chain, etherscan_api_key, explorer_api_url, explorer_url)?; let meta = client.contract_source_code(contract_address.parse()?).await?; let source_tree = meta.source_tree(); source_tree.write_to(&output_directory)?; @@ -1994,10 +2002,12 @@ impl SimpleCast { pub async fn etherscan_source_flatten( chain: Chain, contract_address: String, - etherscan_api_key: String, + etherscan_api_key: Option, output_path: Option, + explorer_api_url: Option, + explorer_url: Option, ) -> Result<()> { - let client = Client::new(chain, etherscan_api_key)?; + let client = explorer_client(chain, etherscan_api_key, explorer_api_url, explorer_url)?; let metadata = client.contract_source_code(contract_address.parse()?).await?; let Some(metadata) = metadata.items.first() else { eyre::bail!("Empty contract source code") @@ -2191,6 +2201,33 @@ fn strip_0x(s: &str) -> &str { s.strip_prefix("0x").unwrap_or(s) } +fn explorer_client( + chain: Chain, + api_key: Option, + api_url: Option, + explorer_url: Option, +) -> Result { + let mut builder = Client::builder().with_chain_id(chain); + + let deduced = chain.etherscan_urls(); + + let explorer_url = explorer_url + .or(deduced.map(|d| d.1.to_string())) + .ok_or_eyre("Please provide the explorer browser URL using `--explorer-url`")?; + builder = builder.with_url(explorer_url)?; + + let api_url = api_url + .or(deduced.map(|d| d.0.to_string())) + .ok_or_eyre("Please provide the explorer API URL using `--explorer-api-url`")?; + builder = builder.with_api_url(api_url)?; + + if let Some(api_key) = api_key { + builder = builder.with_api_key(api_key); + } + + builder.build().map_err(Into::into) +} + #[cfg(test)] mod tests { use super::SimpleCast as Cast; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index f1868c81f7660..2b29fdf9b3744 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -2086,3 +2086,43 @@ forgetest_async!(cast_run_impersonated_tx, |_prj, cmd| { .args(["run", &receipt.transaction_hash.to_string(), "--rpc-url", &http_endpoint]) .assert_success(); }); + +// +casttest!(fetch_src_blockscout, |_prj, cmd| { + let url = "https://eth.blockscout.com/api"; + + let weth = address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); + + cmd.args([ + "source", + &weth.to_string(), + "--chain-id", + "1", + "--explorer-api-url", + url, + "--flatten", + ]) + .assert_success() + .stdout_eq(str![[r#" +... +contract WETH9 { + string public name = "Wrapped Ether"; + string public symbol = "WETH"; + uint8 public decimals = 18; +..."#]]); +}); + +casttest!(fetch_src_default, |_prj, cmd| { + let weth = address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); + let etherscan_api_key = next_mainnet_etherscan_api_key(); + + cmd.args(["source", &weth.to_string(), "--flatten", "--etherscan-api-key", ðerscan_api_key]) + .assert_success() + .stdout_eq(str![[r#" +... +contract WETH9 { + string public name = "Wrapped Ether"; + string public symbol = "WETH"; + uint8 public decimals = 18; +..."#]]); +}); diff --git a/crates/forge/tests/cli/verify_bytecode.rs b/crates/forge/tests/cli/verify_bytecode.rs index 68d1035601c4b..127765bbfdccb 100644 --- a/crates/forge/tests/cli/verify_bytecode.rs +++ b/crates/forge/tests/cli/verify_bytecode.rs @@ -25,7 +25,7 @@ fn test_verify_bytecode( // fetch and flatten source code let source_code = cmd .cast_fuse() - .args(["etherscan-source", addr, "--flatten", "--etherscan-api-key", ðerscan_key]) + .args(["source", addr, "--flatten", "--etherscan-api-key", ðerscan_key]) .assert_success() .get_output() .stdout_lossy(); @@ -81,7 +81,7 @@ fn test_verify_bytecode_with_ignore( let source_code = cmd .cast_fuse() .args([ - "etherscan-source", + "source", addr, "--flatten", "--etherscan-api-key", From 66e3648c2015aaa45ed7f022e4d8cbf484c85fdb Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:26:04 +0100 Subject: [PATCH 1892/1963] feat: override the eyre display handler globally (#9766) * feat: override the eyre display handler globally * chore: install handler in anvil * msg --- Cargo.lock | 1 + clippy.toml | 7 ++- crates/anvil/src/anvil.rs | 4 +- crates/cheatcodes/src/error.rs | 7 +-- crates/cli/Cargo.toml | 1 + crates/cli/src/handler.rs | 57 +++++++++++++++---- crates/common/src/retry.rs | 3 +- crates/evm/core/src/fork/init.rs | 9 ++- crates/evm/core/src/opts.rs | 2 +- crates/evm/evm/src/executors/invariant/mod.rs | 14 ++--- crates/evm/evm/src/executors/mod.rs | 4 +- crates/forge/tests/cli/test_cmd.rs | 2 +- 12 files changed, 72 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3f8f8131e8d3..9a7cf2427884e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3656,6 +3656,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", + "itertools 0.13.0", "rayon", "regex", "serde", diff --git a/clippy.toml b/clippy.toml index 8581063b6ce99..69dfa469ce10b 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,10 +1,11 @@ msrv = "1.83" -# bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, -# so it is safe to ignore it as well + +# `bytes::Bytes` is included by default and `alloy_primitives::Bytes` is a wrapper around it, +# so it is safe to ignore it as well. ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] disallowed-macros = [ - # See `foundry_common::shell` + # See `foundry_common::shell`. { path = "std::print", reason = "use `sh_print` or similar macros instead" }, { path = "std::eprint", reason = "use `sh_eprint` or similar macros instead" }, { path = "std::println", reason = "use `sh_println` or similar macros instead" }, diff --git a/crates/anvil/src/anvil.rs b/crates/anvil/src/anvil.rs index 664fb19d2e1bc..e8e1b9edd5258 100644 --- a/crates/anvil/src/anvil.rs +++ b/crates/anvil/src/anvil.rs @@ -3,7 +3,7 @@ use anvil::cmd::NodeArgs; use clap::{CommandFactory, Parser, Subcommand}; use eyre::Result; -use foundry_cli::{opts::GlobalArgs, utils}; +use foundry_cli::{handler, opts::GlobalArgs, utils}; use foundry_common::version::{LONG_VERSION, SHORT_VERSION}; #[cfg(all(feature = "jemalloc", unix))] @@ -47,7 +47,9 @@ fn main() { } fn run() -> Result<()> { + handler::install(); utils::load_dotenv(); + utils::enable_paint(); let mut args = Anvil::parse(); args.global.init()?; diff --git a/crates/cheatcodes/src/error.rs b/crates/cheatcodes/src/error.rs index c2c220edfed32..b77c889d59ab7 100644 --- a/crates/cheatcodes/src/error.rs +++ b/crates/cheatcodes/src/error.rs @@ -283,6 +283,7 @@ impl_from!( alloy_sol_types::Error, alloy_dyn_abi::Error, alloy_primitives::SignatureError, + eyre::Report, FsPathError, hex::FromHexError, BackendError, @@ -306,12 +307,6 @@ impl> From> for Error { } } -impl From for Error { - fn from(err: eyre::Report) -> Self { - Self::from(foundry_common::errors::display_chain(&err)) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 8b741937d7c65..638005ebd5ca9 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -37,6 +37,7 @@ dotenvy = "0.15" eyre.workspace = true futures.workspace = true indicatif = "0.17" +itertools.workspace = true rayon.workspace = true regex = { workspace = true, default-features = false } serde_json.workspace = true diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index 53485e2260b03..147d2461f407f 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -1,12 +1,42 @@ use eyre::EyreHandler; +use itertools::Itertools; use std::{error::Error, fmt}; -/// A custom context type for Foundry specific error reporting via `eyre` -#[derive(Debug)] -pub struct Handler; +/// A custom context type for Foundry specific error reporting via `eyre`. +pub struct Handler { + debug_handler: Option>, +} + +impl Default for Handler { + fn default() -> Self { + Self::new() + } +} + +impl Handler { + /// Create a new instance of the `Handler`. + pub fn new() -> Self { + Self { debug_handler: None } + } + + /// Override the debug handler with a custom one. + pub fn debug_handler(mut self, debug_handler: Option>) -> Self { + self.debug_handler = debug_handler; + self + } +} impl EyreHandler for Handler { + fn display(&self, error: &(dyn Error + 'static), f: &mut fmt::Formatter<'_>) -> fmt::Result { + use fmt::Display; + foundry_common::errors::dedup_chain(error).into_iter().format("; ").fmt(f) + } + fn debug(&self, error: &(dyn Error + 'static), f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some(debug_handler) = &self.debug_handler { + return debug_handler.debug(error, f); + } + if f.alternate() { return fmt::Debug::fmt(error, f) } @@ -31,9 +61,15 @@ impl EyreHandler for Handler { Ok(()) } + + fn track_caller(&mut self, location: &'static std::panic::Location<'static>) { + if let Some(debug_handler) = &mut self.debug_handler { + debug_handler.track_caller(location); + } + } } -/// Installs the Foundry [eyre] and [panic](mod@std::panic) hooks as the global ones. +/// Installs the Foundry [`eyre`] and [`panic`](mod@std::panic) hooks as the global ones. /// /// # Details /// @@ -49,15 +85,14 @@ pub fn install() { let panic_section = "This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry"; - let (panic_hook, debug_eyre_hook) = + let (panic_hook, debug_hook) = color_eyre::config::HookBuilder::default().panic_section(panic_section).into_hooks(); panic_hook.install(); - let eyre_install_result = if std::env::var_os("FOUNDRY_DEBUG").is_some() { - debug_eyre_hook.install() - } else { - eyre::set_hook(Box::new(|_| Box::new(Handler))) - }; - if let Err(e) = eyre_install_result { + let debug_hook = debug_hook.into_eyre_hook(); + let debug = std::env::var_os("FOUNDRY_DEBUG").is_some(); + if let Err(e) = eyre::set_hook(Box::new(move |e| { + Box::new(Handler::new().debug_handler(debug.then(|| debug_hook(e)))) + })) { debug!("failed to install eyre error hook: {e}"); } } diff --git a/crates/common/src/retry.rs b/crates/common/src/retry.rs index bfd85554a0f5b..49eab352b7f09 100644 --- a/crates/common/src/retry.rs +++ b/crates/common/src/retry.rs @@ -102,8 +102,7 @@ impl Retry { fn log(&self, err: Error, warn: bool) { let msg = format!( - "{msg}{delay} ({retries} tries remaining)", - msg = crate::errors::display_chain(&err), + "{err}{delay} ({retries} tries remaining)", delay = if self.delay.is_zero() { String::new() } else { diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index ae3f9b7a04b14..7730eb6afbe4c 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -23,7 +23,7 @@ pub async fn environment>( let block_number = if let Some(pin_block) = pin_block { pin_block } else { - provider.get_block_number().await.wrap_err("Failed to get latest block number")? + provider.get_block_number().await.wrap_err("failed to get latest block number")? }; let (fork_gas_price, rpc_chain_id, block) = tokio::try_join!( provider.get_gas_price(), @@ -44,12 +44,11 @@ pub async fn environment>( error!("{NON_ARCHIVE_NODE_WARNING}"); } eyre::bail!( - "Failed to get block for block number: {}\nlatest block number: {}", - block_number, - latest_block + "failed to get block for block number: {block_number}; \ + latest block number: {latest_block}" ); } - eyre::bail!("Failed to get block for block number: {}", block_number) + eyre::bail!("failed to get block for block number: {block_number}") }; let mut cfg = CfgEnv::default(); diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 4c13369b6ae6c..d135cceb904f9 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -134,7 +134,7 @@ impl EvmOpts { ) .await .wrap_err_with(|| { - let mut msg = "Could not instantiate forked environment".to_string(); + let mut msg = "could not instantiate forked environment".to_string(); if let Ok(url) = Url::parse(fork_url) { if let Some(provider) = url.host() { write!(msg, " with provider {provider}").unwrap(); diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index b3ea7a982404c..42c426aa55b1f 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -348,7 +348,7 @@ impl<'a> InvariantExecutor<'a> { // We stop the run immediately if we have reverted, and `fail_on_revert` is set. if self.config.fail_on_revert && invariant_test.reverts() > 0 { - return Err(TestCaseError::fail("Revert occurred.")) + return Err(TestCaseError::fail("call reverted")) } while current_run.depth < self.config.depth { @@ -362,7 +362,7 @@ impl<'a> InvariantExecutor<'a> { } let tx = current_run.inputs.last().ok_or_else(|| { - TestCaseError::fail("No input generated to call fuzzed target.") + TestCaseError::fail("no input generated to called fuzz target") })?; // Execute call from the randomly generated sequence without committing state. @@ -375,9 +375,7 @@ impl<'a> InvariantExecutor<'a> { tx.call_details.calldata.clone(), U256::ZERO, ) - .map_err(|e| { - TestCaseError::fail(format!("Could not make raw evm call: {e}")) - })?; + .map_err(|e| TestCaseError::fail(e.to_string()))?; let discarded = call_result.result.as_ref() == MAGIC_ASSUME; if self.config.show_metrics { @@ -394,7 +392,9 @@ impl<'a> InvariantExecutor<'a> { invariant_test.set_error(InvariantFuzzError::MaxAssumeRejects( self.config.max_assume_rejects, )); - return Err(TestCaseError::fail("Max number of vm.assume rejects reached.")) + return Err(TestCaseError::fail( + "reached maximum number of `vm.assume` rejects", + )); } } else { // Commit executed call result. @@ -446,7 +446,7 @@ impl<'a> InvariantExecutor<'a> { } // If test cannot continue then stop current run and exit test suite. if !result.can_continue { - return Err(TestCaseError::fail("Test cannot continue.")) + return Err(TestCaseError::fail("test cannot continue")) } invariant_test.set_last_call_results(result.call_result); diff --git a/crates/evm/evm/src/executors/mod.rs b/crates/evm/evm/src/executors/mod.rs index 187315d583c38..5c26a6d6cdc5d 100644 --- a/crates/evm/evm/src/executors/mod.rs +++ b/crates/evm/evm/src/executors/mod.rs @@ -705,10 +705,10 @@ pub enum EvmError { #[error(transparent)] Abi(#[from] alloy_dyn_abi::Error), /// Error caused which occurred due to calling the `skip` cheatcode. - #[error("{_0}")] + #[error("{0}")] Skip(SkipReason), /// Any other error. - #[error("{}", foundry_common::errors::display_chain(.0))] + #[error("{0}")] Eyre( #[from] #[source] diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 15d60e0df7e76..36b8d514e4503 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2884,7 +2884,7 @@ contract ForkTest is Test { cmd.args(["test", "--mt", "test_fork_err_message"]).assert_failure().stdout_eq(str![[r#" ... Ran 1 test for test/ForkTest.t.sol:ForkTest -[FAIL: vm.createSelectFork: Could not instantiate forked environment with provider eth-mainnet.g.alchemy.com] test_fork_err_message() ([GAS]) +[FAIL: vm.createSelectFork: could not instantiate forked environment with provider eth-mainnet.g.alchemy.com; failed to get latest block number; [..]] test_fork_err_message() ([GAS]) Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] ... From 58166caa8e274d6405a5f9767b9bf6980f26fc5d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:38:02 +0100 Subject: [PATCH 1893/1963] ci: set RUST_BACKTRACE=full (#9767) --- .github/workflows/nextest.yml | 1 + .github/workflows/test.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/nextest.yml b/.github/workflows/nextest.yml index 6fc1a6703901f..522ebb5a1a6a7 100644 --- a/.github/workflows/nextest.yml +++ b/.github/workflows/nextest.yml @@ -15,6 +15,7 @@ concurrency: env: CARGO_TERM_COLOR: always + RUST_BACKTRACE: full jobs: matrices: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ca0daa177ab6..c9dc93e6f7f3e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,7 @@ concurrency: env: CARGO_TERM_COLOR: always + RUST_BACKTRACE: full jobs: nextest: From 4d1f72b78f1fdafa7dc6b8650dd0f537b8eaee55 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:54:38 +0100 Subject: [PATCH 1894/1963] perf(coverage): use u32 for IDs, improve analysis (#9763) * refactor(debugger): renames, less clones * perf(coverage): use u32 for IDs, improve analysis * perf: don't keep source maps around, shrink_to_fit * chore: clippy * fmt --- Cargo.toml | 1 + crates/common/src/fs.rs | 6 +- crates/debugger/src/debugger.rs | 10 +- crates/debugger/src/dump.rs | 148 +++++++++++++++++++++ crates/debugger/src/file_dumper.rs | 172 ------------------------- crates/debugger/src/lib.rs | 3 +- crates/debugger/src/tui/draw.rs | 2 +- crates/evm/core/src/ic.rs | 46 ++++--- crates/evm/coverage/src/analysis.rs | 102 +++++++++++---- crates/evm/coverage/src/anchors.rs | 72 ++++------- crates/evm/coverage/src/inspector.rs | 2 +- crates/evm/coverage/src/lib.rs | 65 +++++----- crates/evm/traces/src/debug/mod.rs | 2 +- crates/evm/traces/src/debug/sources.rs | 8 +- crates/forge/bin/cmd/coverage.rs | 157 +++++++++++----------- crates/forge/src/coverage.rs | 115 ++++++++++------- crates/script/src/execute.rs | 4 +- crates/script/src/lib.rs | 2 +- 18 files changed, 469 insertions(+), 448 deletions(-) create mode 100644 crates/debugger/src/dump.rs delete mode 100644 crates/debugger/src/file_dumper.rs diff --git a/Cargo.toml b/Cargo.toml index 7442519027f70..e4e124d7c8caa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -212,6 +212,7 @@ alloy-json-abi = "0.8.18" alloy-primitives = { version = "0.8.18", features = [ "getrandom", "rand", + "map-fxhash", "map-foldhash", ] } alloy-sol-macro-expander = "0.8.18" diff --git a/crates/common/src/fs.rs b/crates/common/src/fs.rs index 71a62d13a7ae7..3d061759c50cf 100644 --- a/crates/common/src/fs.rs +++ b/crates/common/src/fs.rs @@ -1,4 +1,5 @@ -//! Contains various `std::fs` wrapper functions that also contain the target path in their errors +//! Contains various `std::fs` wrapper functions that also contain the target path in their errors. + use crate::errors::FsPathError; use serde::{de::DeserializeOwned, Serialize}; use std::{ @@ -7,7 +8,8 @@ use std::{ path::{Component, Path, PathBuf}, }; -type Result = std::result::Result; +/// The [`fs`](self) result type. +pub type Result = std::result::Result; /// Wrapper for [`File::create`]. pub fn create_file(path: impl AsRef) -> Result { diff --git a/crates/debugger/src/debugger.rs b/crates/debugger/src/debugger.rs index 469225118e30f..907232cad7e98 100644 --- a/crates/debugger/src/debugger.rs +++ b/crates/debugger/src/debugger.rs @@ -1,11 +1,11 @@ //! Debugger implementation. -use crate::{tui::TUI, DebugNode, DebuggerBuilder, ExitReason, FileDumper}; +use crate::{tui::TUI, DebugNode, DebuggerBuilder, ExitReason}; use alloy_primitives::map::AddressHashMap; use eyre::Result; use foundry_common::evm::Breakpoints; use foundry_evm_traces::debug::ContractSources; -use std::path::PathBuf; +use std::path::Path; pub struct DebuggerContext { pub debug_arena: Vec, @@ -64,10 +64,8 @@ impl Debugger { } /// Dumps debugger data to file. - pub fn dump_to_file(&mut self, path: &PathBuf) -> Result<()> { + pub fn dump_to_file(&mut self, path: &Path) -> Result<()> { eyre::ensure!(!self.context.debug_arena.is_empty(), "debug arena is empty"); - - let mut file_dumper = FileDumper::new(path, &mut self.context); - file_dumper.run() + crate::dump::dump(path, &self.context) } } diff --git a/crates/debugger/src/dump.rs b/crates/debugger/src/dump.rs new file mode 100644 index 0000000000000..83af7b0e777f7 --- /dev/null +++ b/crates/debugger/src/dump.rs @@ -0,0 +1,148 @@ +use crate::{debugger::DebuggerContext, DebugNode}; +use alloy_primitives::map::AddressMap; +use foundry_common::fs::write_json_file; +use foundry_compilers::{ + artifacts::sourcemap::{Jump, SourceElement}, + multi::MultiCompilerLanguage, +}; +use foundry_evm_core::utils::PcIcMap; +use foundry_evm_traces::debug::{ArtifactData, ContractSources, SourceData}; +use serde::Serialize; +use std::{collections::HashMap, path::Path}; + +/// Dumps debugger data to a JSON file. +pub(crate) fn dump(path: &Path, context: &DebuggerContext) -> eyre::Result<()> { + write_json_file(path, &DebuggerDump::new(context))?; + Ok(()) +} + +/// Holds info of debugger dump. +#[derive(Serialize)] +struct DebuggerDump<'a> { + contracts: ContractsDump<'a>, + debug_arena: &'a [DebugNode], +} + +impl<'a> DebuggerDump<'a> { + fn new(debugger_context: &'a DebuggerContext) -> Self { + Self { + contracts: ContractsDump::new(debugger_context), + debug_arena: &debugger_context.debug_arena, + } + } +} + +#[derive(Serialize)] +struct SourceElementDump { + offset: u32, + length: u32, + index: i32, + jump: u32, + modifier_depth: u32, +} + +impl SourceElementDump { + fn new(v: &SourceElement) -> Self { + Self { + offset: v.offset(), + length: v.length(), + index: v.index_i32(), + jump: match v.jump() { + Jump::In => 0, + Jump::Out => 1, + Jump::Regular => 2, + }, + modifier_depth: v.modifier_depth(), + } + } +} + +#[derive(Serialize)] +struct ContractsDump<'a> { + identified_contracts: &'a AddressMap, + sources: ContractsSourcesDump<'a>, +} + +impl<'a> ContractsDump<'a> { + fn new(debugger_context: &'a DebuggerContext) -> Self { + Self { + identified_contracts: &debugger_context.identified_contracts, + sources: ContractsSourcesDump::new(&debugger_context.contracts_sources), + } + } +} + +#[derive(Serialize)] +struct ContractsSourcesDump<'a> { + sources_by_id: HashMap<&'a str, HashMap>>, + artifacts_by_name: HashMap<&'a str, Vec>>, +} + +impl<'a> ContractsSourcesDump<'a> { + fn new(contracts_sources: &'a ContractSources) -> Self { + Self { + sources_by_id: contracts_sources + .sources_by_id + .iter() + .map(|(name, inner_map)| { + ( + name.as_str(), + inner_map + .iter() + .map(|(id, source_data)| (*id, SourceDataDump::new(source_data))) + .collect(), + ) + }) + .collect(), + artifacts_by_name: contracts_sources + .artifacts_by_name + .iter() + .map(|(name, data)| { + (name.as_str(), data.iter().map(ArtifactDataDump::new).collect()) + }) + .collect(), + } + } +} + +#[derive(Serialize)] +struct SourceDataDump<'a> { + source: &'a str, + language: MultiCompilerLanguage, + path: &'a Path, +} + +impl<'a> SourceDataDump<'a> { + fn new(v: &'a SourceData) -> Self { + Self { source: &v.source, language: v.language, path: &v.path } + } +} + +#[derive(Serialize)] +struct ArtifactDataDump<'a> { + source_map: Option>, + source_map_runtime: Option>, + pc_ic_map: Option<&'a PcIcMap>, + pc_ic_map_runtime: Option<&'a PcIcMap>, + build_id: &'a str, + file_id: u32, +} + +impl<'a> ArtifactDataDump<'a> { + fn new(v: &'a ArtifactData) -> Self { + Self { + source_map: v + .source_map + .as_ref() + .map(|source_map| source_map.iter().map(SourceElementDump::new).collect()), + source_map_runtime: v + .source_map_runtime + .as_ref() + .map(|source_map| source_map.iter().map(SourceElementDump::new).collect()), + pc_ic_map: v.pc_ic_map.as_ref(), + pc_ic_map_runtime: v.pc_ic_map_runtime.as_ref(), + build_id: &v.build_id, + file_id: v.file_id, + } + } +} diff --git a/crates/debugger/src/file_dumper.rs b/crates/debugger/src/file_dumper.rs deleted file mode 100644 index 909530c421595..0000000000000 --- a/crates/debugger/src/file_dumper.rs +++ /dev/null @@ -1,172 +0,0 @@ -//! The debug file dumper implementation. - -use crate::{debugger::DebuggerContext, DebugNode}; -use alloy_primitives::Address; -use eyre::Result; -use foundry_common::fs::write_json_file; -use foundry_compilers::{ - artifacts::sourcemap::{Jump, SourceElement}, - multi::MultiCompilerLanguage, -}; -use foundry_evm_traces::debug::{ArtifactData, ContractSources, SourceData}; -use serde::Serialize; -use std::{collections::HashMap, ops::Deref, path::PathBuf}; - -/// Generates and writes debugger dump in a json file. -pub struct FileDumper<'a> { - /// Path to json file to write dump into. - path: &'a PathBuf, - /// Debugger context to generate dump for. - debugger_context: &'a mut DebuggerContext, -} - -impl<'a> FileDumper<'a> { - pub fn new(path: &'a PathBuf, debugger_context: &'a mut DebuggerContext) -> Self { - Self { path, debugger_context } - } - - pub fn run(&mut self) -> Result<()> { - let data = DebuggerDump::from(self.debugger_context); - write_json_file(self.path, &data).unwrap(); - Ok(()) - } -} - -/// Holds info of debugger dump. -#[derive(Serialize)] -struct DebuggerDump { - contracts: ContractsDump, - debug_arena: Vec, -} - -impl DebuggerDump { - fn from(debugger_context: &DebuggerContext) -> Self { - Self { - contracts: ContractsDump::new(debugger_context), - debug_arena: debugger_context.debug_arena.clone(), - } - } -} - -#[derive(Serialize)] -pub struct SourceElementDump { - offset: u32, - length: u32, - index: i32, - jump: u32, - modifier_depth: u32, -} - -impl SourceElementDump { - pub fn new(v: &SourceElement) -> Self { - Self { - offset: v.offset(), - length: v.length(), - index: v.index_i32(), - jump: match v.jump() { - Jump::In => 0, - Jump::Out => 1, - Jump::Regular => 2, - }, - modifier_depth: v.modifier_depth(), - } - } -} - -#[derive(Serialize)] -struct ContractsDump { - // Map of call address to contract name - identified_contracts: HashMap, - sources: ContractsSourcesDump, -} - -impl ContractsDump { - pub fn new(debugger_context: &DebuggerContext) -> Self { - Self { - identified_contracts: debugger_context - .identified_contracts - .iter() - .map(|(k, v)| (*k, v.clone())) - .collect(), - sources: ContractsSourcesDump::new(&debugger_context.contracts_sources), - } - } -} - -#[derive(Serialize)] -struct ContractsSourcesDump { - sources_by_id: HashMap>, - artifacts_by_name: HashMap>, -} - -impl ContractsSourcesDump { - pub fn new(contracts_sources: &ContractSources) -> Self { - Self { - sources_by_id: contracts_sources - .sources_by_id - .iter() - .map(|(name, inner_map)| { - ( - name.clone(), - inner_map - .iter() - .map(|(id, source_data)| (*id, SourceDataDump::new(source_data))) - .collect(), - ) - }) - .collect(), - artifacts_by_name: contracts_sources - .artifacts_by_name - .iter() - .map(|(name, data)| { - (name.clone(), data.iter().map(ArtifactDataDump::new).collect()) - }) - .collect(), - } - } -} - -#[derive(Serialize)] -struct SourceDataDump { - source: String, - language: MultiCompilerLanguage, - path: PathBuf, -} - -impl SourceDataDump { - pub fn new(v: &SourceData) -> Self { - Self { source: v.source.deref().clone(), language: v.language, path: v.path.clone() } - } -} - -#[derive(Serialize)] -struct ArtifactDataDump { - pub source_map: Option>, - pub source_map_runtime: Option>, - pub pc_ic_map: Option>, - pub pc_ic_map_runtime: Option>, - pub build_id: String, - pub file_id: u32, -} - -impl ArtifactDataDump { - pub fn new(v: &ArtifactData) -> Self { - Self { - source_map: v - .source_map - .clone() - .map(|source_map| source_map.iter().map(SourceElementDump::new).collect()), - source_map_runtime: v - .source_map_runtime - .clone() - .map(|source_map| source_map.iter().map(SourceElementDump::new).collect()), - pc_ic_map: v.pc_ic_map.clone().map(|v| v.inner.iter().map(|(k, v)| (*k, *v)).collect()), - pc_ic_map_runtime: v - .pc_ic_map_runtime - .clone() - .map(|v| v.inner.iter().map(|(k, v)| (*k, *v)).collect()), - build_id: v.build_id.clone(), - file_id: v.file_id, - } - } -} diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rs index 67c9ee9845073..1c1bf9614ee2e 100644 --- a/crates/debugger/src/lib.rs +++ b/crates/debugger/src/lib.rs @@ -15,7 +15,7 @@ mod op; mod builder; mod debugger; -mod file_dumper; +mod dump; mod tui; mod node; @@ -24,5 +24,4 @@ pub use node::DebugNode; pub use builder::DebuggerBuilder; pub use debugger::Debugger; -pub use file_dumper::FileDumper; pub use tui::{ExitReason, TUI}; diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index 18b58927966d0..a918bc89ea733 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -351,7 +351,7 @@ impl TUIContext<'_> { .contracts_sources .find_source_mapping( contract_name, - self.current_step().pc, + self.current_step().pc as u32, self.debug_call().kind.is_any_create(), ) .ok_or_else(|| format!("No source map for contract {contract_name}")) diff --git a/crates/evm/core/src/ic.rs b/crates/evm/core/src/ic.rs index fcabf2a18b41c..80fef528c9ac5 100644 --- a/crates/evm/core/src/ic.rs +++ b/crates/evm/core/src/ic.rs @@ -1,17 +1,19 @@ -use alloy_primitives::map::HashMap; +use alloy_primitives::map::rustc_hash::FxHashMap; use eyre::Result; use revm::interpreter::{ opcode::{PUSH0, PUSH1, PUSH32}, OpCode, }; use revm_inspectors::opcode::immediate_size; +use serde::Serialize; /// Maps from program counter to instruction counter. /// /// Inverse of [`IcPcMap`]. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] +#[serde(transparent)] pub struct PcIcMap { - pub inner: HashMap, + pub inner: FxHashMap, } impl PcIcMap { @@ -31,7 +33,7 @@ impl PcIcMap { } /// Returns the instruction counter for the given program counter. - pub fn get(&self, pc: usize) -> Option { + pub fn get(&self, pc: u32) -> Option { self.inner.get(&pc).copied() } } @@ -40,7 +42,7 @@ impl PcIcMap { /// /// Inverse of [`PcIcMap`]. pub struct IcPcMap { - pub inner: HashMap, + pub inner: FxHashMap, } impl IcPcMap { @@ -60,22 +62,24 @@ impl IcPcMap { } /// Returns the program counter for the given instruction counter. - pub fn get(&self, ic: usize) -> Option { + pub fn get(&self, ic: u32) -> Option { self.inner.get(&ic).copied() } } -fn make_map(code: &[u8]) -> HashMap { - let mut map = HashMap::default(); +fn make_map(code: &[u8]) -> FxHashMap { + assert!(code.len() <= u32::MAX as usize, "bytecode is too big"); - let mut pc = 0; - let mut cumulative_push_size = 0; + let mut map = FxHashMap::with_capacity_and_hasher(code.len(), Default::default()); + + let mut pc = 0usize; + let mut cumulative_push_size = 0usize; while pc < code.len() { let ic = pc - cumulative_push_size; if PC_FIRST { - map.insert(pc, ic); + map.insert(pc as u32, ic as u32); } else { - map.insert(ic, pc); + map.insert(ic as u32, pc as u32); } if (PUSH1..=PUSH32).contains(&code[pc]) { @@ -87,6 +91,9 @@ fn make_map(code: &[u8]) -> HashMap { pc += 1; } + + map.shrink_to_fit(); + map } @@ -97,25 +104,28 @@ pub struct Instruction<'a> { /// Immediate data following the opcode. pub immediate: &'a [u8], /// Program counter of the opcode. - pub pc: usize, + pub pc: u32, } /// Decodes raw opcode bytes into [`Instruction`]s. pub fn decode_instructions(code: &[u8]) -> Result>> { - let mut pc = 0; + assert!(code.len() <= u32::MAX as usize, "bytecode is too big"); + + let mut pc = 0usize; let mut steps = Vec::new(); while pc < code.len() { let op = OpCode::new(code[pc]); - let immediate_size = op.map(|op| immediate_size(op, &code[pc + 1..])).unwrap_or(0) as usize; + pc += 1; + let immediate_size = op.map(|op| immediate_size(op, &code[pc..])).unwrap_or(0) as usize; - if pc + 1 + immediate_size > code.len() { + if pc + immediate_size > code.len() { eyre::bail!("incomplete sequence of bytecode"); } - steps.push(Instruction { op, pc, immediate: &code[pc + 1..pc + 1 + immediate_size] }); + steps.push(Instruction { op, pc: pc as u32, immediate: &code[pc..pc + immediate_size] }); - pc += 1 + immediate_size; + pc += immediate_size; } Ok(steps) diff --git a/crates/evm/coverage/src/analysis.rs b/crates/evm/coverage/src/analysis.rs index f8cc746c5a10e..89374668031a8 100644 --- a/crates/evm/coverage/src/analysis.rs +++ b/crates/evm/coverage/src/analysis.rs @@ -12,7 +12,7 @@ use std::sync::Arc; #[derive(Clone, Debug)] pub struct ContractVisitor<'a> { /// The source ID of the contract. - source_id: usize, + source_id: u32, /// The source code that contains the AST being walked. source: &'a str, @@ -20,7 +20,7 @@ pub struct ContractVisitor<'a> { contract_name: &'a Arc, /// The current branch ID - branch_id: usize, + branch_id: u32, /// Stores the last line we put in the items collection to ensure we don't push duplicate lines last_line: u32, @@ -30,7 +30,14 @@ pub struct ContractVisitor<'a> { impl<'a> ContractVisitor<'a> { pub fn new(source_id: usize, source: &'a str, contract_name: &'a Arc) -> Self { - Self { source_id, source, contract_name, branch_id: 0, last_line: 0, items: Vec::new() } + Self { + source_id: source_id.try_into().expect("too many sources"), + source, + contract_name, + branch_id: 0, + last_line: 0, + items: Vec::new(), + } } pub fn visit_contract(&mut self, node: &Node) -> eyre::Result<()> { @@ -484,7 +491,7 @@ impl<'a> ContractVisitor<'a> { let n_lines = self.source[bytes.start as usize..bytes.end as usize].lines().count() as u32; let lines = start_line..start_line + n_lines; SourceLocation { - source_id: self.source_id, + source_id: self.source_id as usize, contract_name: self.contract_name.clone(), bytes, lines, @@ -508,25 +515,16 @@ fn has_statements(node: &Node) -> bool { } } -/// [`SourceAnalyzer`] result type. -#[derive(Debug)] +/// Coverage source analysis. +#[derive(Clone, Debug, Default)] pub struct SourceAnalysis { - /// A collection of coverage items. - pub items: Vec, -} - -/// Analyzes a set of sources to find coverage items. -#[derive(Debug)] -pub struct SourceAnalyzer<'a> { - sources: &'a SourceFiles<'a>, + /// All the coverage items. + all_items: Vec, + /// Source ID to `(offset, len)` into `all_items`. + map: Vec<(u32, u32)>, } -impl<'a> SourceAnalyzer<'a> { - /// Creates a new source analyzer. - pub fn new(data: &'a SourceFiles<'a>) -> Self { - Self { sources: data } - } - +impl SourceAnalysis { /// Analyzes contracts in the sources held by the source analyzer. /// /// Coverage items are found by: @@ -540,13 +538,12 @@ impl<'a> SourceAnalyzer<'a> { /// Note: Source IDs are only unique per compilation job; that is, a code base compiled with /// two different solc versions will produce overlapping source IDs if the compiler version is /// not taken into account. - pub fn analyze(&self) -> eyre::Result { - let items = self - .sources + pub fn new(data: &SourceFiles<'_>) -> eyre::Result { + let mut sourced_items = data .sources .par_iter() .flat_map_iter(|(&source_id, SourceFile { source, ast })| { - ast.nodes.iter().map(move |node| { + let items = ast.nodes.iter().map(move |node| { if !matches!(node.node_type, NodeType::ContractDefinition) { return Ok(vec![]); } @@ -579,10 +576,61 @@ impl<'a> SourceAnalyzer<'a> { } Ok(items) - }) + }); + items.map(move |items| items.map(|items| (source_id, items))) }) - .collect::>>>()?; - Ok(SourceAnalysis { items: items.concat() }) + .collect::)>>>()?; + + // Create mapping and merge items. + sourced_items.sort_by_key(|(id, items)| (*id, items.first().map(|i| i.loc.bytes.start))); + let Some(&(max_idx, _)) = sourced_items.last() else { return Ok(Self::default()) }; + let len = max_idx + 1; + let mut all_items = Vec::new(); + let mut map = vec![(u32::MAX, 0); len]; + for (idx, items) in sourced_items { + // Assumes that all `idx` items are consecutive, guaranteed by the sort above. + if map[idx].0 == u32::MAX { + map[idx].0 = all_items.len() as u32; + } + map[idx].1 += items.len() as u32; + all_items.extend(items); + } + + Ok(Self { all_items, map }) + } + + /// Returns all the coverage items. + pub fn all_items(&self) -> &[CoverageItem] { + &self.all_items + } + + /// Returns all the mutable coverage items. + pub fn all_items_mut(&mut self) -> &mut Vec { + &mut self.all_items + } + + /// Returns an iterator over the coverage items and their IDs for the given source. + pub fn items_for_source_enumerated( + &self, + source_id: u32, + ) -> impl Iterator { + let (base_id, items) = self.items_for_source(source_id); + items.iter().enumerate().map(move |(idx, item)| (base_id + idx as u32, item)) + } + + /// Returns the base item ID and all the coverage items for the given source. + pub fn items_for_source(&self, source_id: u32) -> (u32, &[CoverageItem]) { + let (mut offset, len) = self.map.get(source_id as usize).copied().unwrap_or_default(); + if offset == u32::MAX { + offset = 0; + } + (offset, &self.all_items[offset as usize..][..len as usize]) + } + + /// Returns the coverage item for the given item ID. + #[inline] + pub fn get(&self, item_id: u32) -> Option<&CoverageItem> { + self.all_items.get(item_id as usize) } } diff --git a/crates/evm/coverage/src/anchors.rs b/crates/evm/coverage/src/anchors.rs index ee723d95cc5c8..3d46065518c1b 100644 --- a/crates/evm/coverage/src/anchors.rs +++ b/crates/evm/coverage/src/anchors.rs @@ -1,5 +1,6 @@ -use super::{CoverageItem, CoverageItemKind, ItemAnchor, SourceLocation}; -use alloy_primitives::map::{DefaultHashBuilder, HashMap, HashSet}; +use super::{CoverageItemKind, ItemAnchor, SourceLocation}; +use crate::analysis::SourceAnalysis; +use alloy_primitives::map::rustc_hash::FxHashSet; use eyre::ensure; use foundry_compilers::artifacts::sourcemap::{SourceElement, SourceMap}; use foundry_evm_core::utils::IcPcMap; @@ -10,49 +11,29 @@ pub fn find_anchors( bytecode: &[u8], source_map: &SourceMap, ic_pc_map: &IcPcMap, - items: &[CoverageItem], - items_by_source_id: &HashMap>, + analysis: &SourceAnalysis, ) -> Vec { - let mut seen = HashSet::with_hasher(DefaultHashBuilder::default()); + let mut seen_sources = FxHashSet::default(); source_map .iter() - .filter_map(|element| items_by_source_id.get(&(element.index()? as usize))) - .flatten() - .filter_map(|&item_id| { - if !seen.insert(item_id) { - return None; - } - - let item = &items[item_id]; - let find_anchor_by_first_opcode = |item: &CoverageItem| match find_anchor_simple( - source_map, ic_pc_map, item_id, &item.loc, - ) { - Ok(anchor) => Some(anchor), - Err(e) => { - warn!("Could not find anchor for item {item}: {e}"); - None - } - }; + .filter_map(|element| element.index()) + .filter(|&source| seen_sources.insert(source)) + .flat_map(|source| analysis.items_for_source_enumerated(source)) + .filter_map(|(item_id, item)| { match item.kind { - CoverageItemKind::Branch { path_id, is_first_opcode, .. } => { - if is_first_opcode { - find_anchor_by_first_opcode(item) - } else { - match find_anchor_branch(bytecode, source_map, item_id, &item.loc) { - Ok(anchors) => match path_id { - 0 => Some(anchors.0), - 1 => Some(anchors.1), - _ => panic!("Too many paths for branch"), - }, - Err(e) => { - warn!("Could not find anchor for item {item}: {e}"); - None - } + CoverageItemKind::Branch { path_id, is_first_opcode: false, .. } => { + find_anchor_branch(bytecode, source_map, item_id, &item.loc).map(|anchors| { + match path_id { + 0 => anchors.0, + 1 => anchors.1, + _ => panic!("too many path IDs for branch"), } - } + }) } - _ => find_anchor_by_first_opcode(item), + _ => find_anchor_simple(source_map, ic_pc_map, item_id, &item.loc), } + .inspect_err(|err| warn!(%item, %err, "could not find anchor")) + .ok() }) .collect() } @@ -61,7 +42,7 @@ pub fn find_anchors( pub fn find_anchor_simple( source_map: &SourceMap, ic_pc_map: &IcPcMap, - item_id: usize, + item_id: u32, loc: &SourceLocation, ) -> eyre::Result { let instruction = @@ -70,7 +51,7 @@ pub fn find_anchor_simple( )?; Ok(ItemAnchor { - instruction: ic_pc_map.get(instruction).ok_or_else(|| { + instruction: ic_pc_map.get(instruction as u32).ok_or_else(|| { eyre::eyre!("We found an anchor, but we can't translate it to a program counter") })?, item_id, @@ -108,12 +89,9 @@ pub fn find_anchor_simple( pub fn find_anchor_branch( bytecode: &[u8], source_map: &SourceMap, - item_id: usize, + item_id: u32, loc: &SourceLocation, ) -> eyre::Result<(ItemAnchor, ItemAnchor)> { - // NOTE(onbjerg): We use `SpecId::LATEST` here since it does not matter; the only difference - // is the gas cost. - let mut anchors: Option<(ItemAnchor, ItemAnchor)> = None; let mut pc = 0; let mut cumulative_push_size = 0; @@ -151,12 +129,12 @@ pub fn find_anchor_branch( let mut pc_bytes = [0u8; 8]; pc_bytes[8 - push_size..].copy_from_slice(push_bytes); let pc_jump = u64::from_be_bytes(pc_bytes); - let pc_jump = usize::try_from(pc_jump).expect("PC is too big"); + let pc_jump = u32::try_from(pc_jump).expect("PC is too big"); anchors = Some(( ItemAnchor { item_id, // The first branch is the opcode directly after JUMPI - instruction: pc + 2, + instruction: (pc + 2) as u32, }, ItemAnchor { item_id, instruction: pc_jump }, )); @@ -171,7 +149,7 @@ pub fn find_anchor_branch( /// Calculates whether `element` is within the range of the target `location`. fn is_in_source_range(element: &SourceElement, location: &SourceLocation) -> bool { // Source IDs must match. - let source_ids_match = element.index().is_some_and(|a| a as usize == location.source_id); + let source_ids_match = element.index_i32() == location.source_id as i32; if !source_ids_match { return false; } diff --git a/crates/evm/coverage/src/inspector.rs b/crates/evm/coverage/src/inspector.rs index bc3a40e5638b4..6a6c50b093c8f 100644 --- a/crates/evm/coverage/src/inspector.rs +++ b/crates/evm/coverage/src/inspector.rs @@ -38,7 +38,7 @@ impl Inspector for CoverageCollector { #[inline] fn step(&mut self, interpreter: &mut Interpreter, _context: &mut EvmContext) { let map = self.get_or_insert_map(interpreter); - map.hit(interpreter.program_counter()); + map.hit(interpreter.program_counter() as u32); } } diff --git a/crates/evm/coverage/src/lib.rs b/crates/evm/coverage/src/lib.rs index 52ec329add140..793e0ee56670c 100644 --- a/crates/evm/coverage/src/lib.rs +++ b/crates/evm/coverage/src/lib.rs @@ -12,6 +12,7 @@ use alloy_primitives::{ map::{B256HashMap, HashMap}, Bytes, }; +use analysis::SourceAnalysis; use eyre::Result; use foundry_compilers::artifacts::sourcemap::SourceMap; use semver::Version; @@ -41,7 +42,7 @@ pub struct CoverageReport { /// A map of source paths to source IDs. pub source_paths_to_ids: HashMap<(Version, PathBuf), usize>, /// All coverage items for the codebase, keyed by the compiler version. - pub items: HashMap>, + pub analyses: HashMap, /// All item anchors for the codebase, keyed by their contract ID. pub anchors: HashMap, Vec)>, /// All the bytecode hits for the codebase. @@ -70,9 +71,9 @@ impl CoverageReport { self.source_maps.extend(source_maps); } - /// Add coverage items to this report. - pub fn add_items(&mut self, version: Version, items: impl IntoIterator) { - self.items.entry(version).or_default().extend(items); + /// Add a [`SourceAnalysis`] to this report. + pub fn add_analysis(&mut self, version: Version, analysis: SourceAnalysis) { + self.analyses.insert(version, analysis); } /// Add anchors to this report. @@ -98,8 +99,8 @@ impl CoverageReport { mut f: impl FnMut(&mut T, &'a CoverageItem), ) -> impl Iterator { let mut by_file: BTreeMap<&Path, T> = BTreeMap::new(); - for (version, items) in &self.items { - for item in items { + for (version, items) in &self.analyses { + for item in items.all_items() { let key = (version.clone(), item.loc.source_id); let Some(path) = self.source_paths.get(&key) else { continue }; f(by_file.entry(path).or_default(), item); @@ -119,41 +120,42 @@ impl CoverageReport { hit_map: &HitMap, is_deployed_code: bool, ) -> Result<()> { - // Add bytecode level hits + // Add bytecode level hits. self.bytecode_hits .entry(contract_id.clone()) .and_modify(|m| m.merge(hit_map)) .or_insert_with(|| hit_map.clone()); - // Add source level hits + // Add source level hits. if let Some(anchors) = self.anchors.get(contract_id) { let anchors = if is_deployed_code { &anchors.1 } else { &anchors.0 }; for anchor in anchors { if let Some(hits) = hit_map.get(anchor.instruction) { - self.items + self.analyses .get_mut(&contract_id.version) - .and_then(|items| items.get_mut(anchor.item_id)) + .and_then(|items| items.all_items_mut().get_mut(anchor.item_id as usize)) .expect("Anchor refers to non-existent coverage item") .hits += hits.get(); } } } + Ok(()) } - /// Removes all the coverage items that should be ignored by the filter. + /// Retains all the coverage items specified by `predicate`. /// /// This function should only be called after all the sources were used, otherwise, the output /// will be missing the ones that are dependent on them. - pub fn filter_out_ignored_sources(&mut self, filter: impl Fn(&Path) -> bool) { - self.items.retain(|version, items| { - items.retain(|item| { + pub fn retain_sources(&mut self, mut predicate: impl FnMut(&Path) -> bool) { + self.analyses.retain(|version, analysis| { + analysis.all_items_mut().retain(|item| { self.source_paths .get(&(version.clone(), item.loc.source_id)) - .map(|path| filter(path)) + .map(|path| predicate(path)) .unwrap_or(false) }); - !items.is_empty() + !analysis.all_items().is_empty() }); } } @@ -225,20 +227,20 @@ impl HitMap { /// Returns the number of hits for the given program counter. #[inline] - pub fn get(&self, pc: usize) -> Option { - NonZeroU32::new(self.hits.get(&Self::cvt_pc(pc)).copied().unwrap_or(0)) + pub fn get(&self, pc: u32) -> Option { + NonZeroU32::new(self.hits.get(&pc).copied().unwrap_or(0)) } /// Increase the hit counter by 1 for the given program counter. #[inline] - pub fn hit(&mut self, pc: usize) { + pub fn hit(&mut self, pc: u32) { self.hits(pc, 1) } /// Increase the hit counter by `hits` for the given program counter. #[inline] - pub fn hits(&mut self, pc: usize, hits: u32) { - *self.hits.entry(Self::cvt_pc(pc)).or_default() += hits; + pub fn hits(&mut self, pc: u32, hits: u32) { + *self.hits.entry(pc).or_default() += hits; } /// Merge another hitmap into this, assuming the bytecode is consistent @@ -251,8 +253,8 @@ impl HitMap { /// Returns an iterator over all the program counters and their hit counts. #[inline] - pub fn iter(&self) -> impl Iterator + '_ { - self.hits.iter().map(|(&pc, &hits)| (pc as usize, hits)) + pub fn iter(&self) -> impl Iterator + '_ { + self.hits.iter().map(|(&pc, &hits)| (pc, hits)) } /// Returns the number of program counters hit in the hitmap. @@ -266,11 +268,6 @@ impl HitMap { pub fn is_empty(&self) -> bool { self.hits.is_empty() } - - #[inline] - fn cvt_pc(pc: usize) -> u32 { - pc.try_into().expect("4GiB bytecode") - } } /// A unique identifier for a contract @@ -294,10 +291,10 @@ impl Display for ContractId { /// An item anchor describes what instruction marks a [CoverageItem] as covered. #[derive(Clone, Debug)] pub struct ItemAnchor { - /// The program counter for the opcode of this anchor - pub instruction: usize, - /// The item ID this anchor points to - pub item_id: usize, + /// The program counter for the opcode of this anchor. + pub instruction: u32, + /// The item ID this anchor points to. + pub item_id: u32, } impl Display for ItemAnchor { @@ -318,11 +315,11 @@ pub enum CoverageItemKind { /// /// There may be multiple items with the same branch ID - they belong to the same branch, /// but represent different paths. - branch_id: usize, + branch_id: u32, /// The path ID for this branch. /// /// The first path has ID 0, the next ID 1, and so on. - path_id: usize, + path_id: u32, /// If true, then the branch anchor is the first opcode within the branch source range. is_first_opcode: bool, }, diff --git a/crates/evm/traces/src/debug/mod.rs b/crates/evm/traces/src/debug/mod.rs index a56f4ab2bff1e..1f3fb0b2faedd 100644 --- a/crates/evm/traces/src/debug/mod.rs +++ b/crates/evm/traces/src/debug/mod.rs @@ -80,7 +80,7 @@ impl<'a> DebugStepsWalker<'a> { fn src_map(&self, step: usize) -> Option<(SourceElement, &SourceData)> { self.sources.find_source_mapping( self.contract_name, - self.node.trace.steps[step].pc, + self.node.trace.steps[step].pc as u32, self.node.trace.kind.is_any_create(), ) } diff --git a/crates/evm/traces/src/debug/sources.rs b/crates/evm/traces/src/debug/sources.rs index 5c0caa5793c1a..d01c0743946e1 100644 --- a/crates/evm/traces/src/debug/sources.rs +++ b/crates/evm/traces/src/debug/sources.rs @@ -245,7 +245,7 @@ impl ContractSources { pub fn find_source_mapping( &self, contract_name: &str, - pc: usize, + pc: u32, init_code: bool, ) -> Option<(SourceElement, &SourceData)> { self.get_sources(contract_name)?.find_map(|(artifact, source)| { @@ -265,10 +265,10 @@ impl ContractSources { }?; let ic = pc_ic_map.get(pc)?; - source_map.get(ic)? + source_map.get(ic as usize) } else { - source_map.get(pc)? - }; + source_map.get(pc as usize) + }?; // if the source element has an index, find the sourcemap for that index let res = source_element .index() diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index 0dffce4ed0a32..a1eab26282688 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -4,7 +4,7 @@ use clap::{Parser, ValueEnum, ValueHint}; use eyre::{Context, Result}; use forge::{ coverage::{ - analysis::{SourceAnalysis, SourceAnalyzer, SourceFile, SourceFiles}, + analysis::{SourceAnalysis, SourceFile, SourceFiles}, anchors::find_anchors, BytecodeReporter, ContractId, CoverageReport, CoverageReporter, CoverageSummaryReporter, DebugReporter, ItemAnchor, LcovReporter, @@ -14,19 +14,18 @@ use forge::{ MultiContractRunnerBuilder, }; use foundry_cli::utils::{LoadConfig, STATIC_FUZZ_SEED}; -use foundry_common::{compile::ProjectCompiler, fs}; +use foundry_common::compile::ProjectCompiler; use foundry_compilers::{ artifacts::{ sourcemap::SourceMap, CompactBytecode, CompactDeployedBytecode, SolcLanguage, Source, }, compilers::multi::MultiCompiler, - Artifact, ArtifactId, Project, ProjectCompileOutput, + Artifact, ArtifactId, Project, ProjectCompileOutput, ProjectPathsConfig, }; use foundry_config::{Config, SolcReq}; use rayon::prelude::*; use semver::{Version, VersionReq}; use std::{ - io, path::{Path, PathBuf}, sync::Arc, }; @@ -35,7 +34,7 @@ use std::{ foundry_config::impl_figment_convert!(CoverageArgs, test); /// CLI arguments for `forge coverage`. -#[derive(Clone, Debug, Parser)] +#[derive(Parser)] pub struct CoverageArgs { /// The report type to use for coverage. /// @@ -76,12 +75,16 @@ pub struct CoverageArgs { #[arg(long)] include_libs: bool, + /// The coverage reporters to use. Constructed from the other fields. + #[arg(skip)] + reporters: Vec>, + #[command(flatten)] test: TestArgs, } impl CoverageArgs { - pub async fn run(self) -> Result<()> { + pub async fn run(mut self) -> Result<()> { let (mut config, evm_opts) = self.load_config_and_evm_opts()?; // install missing dependencies @@ -96,12 +99,40 @@ impl CoverageArgs { // Coverage analysis requires the Solc AST output. config.ast = true; - let (project, output) = self.build(&config)?; + let (paths, output) = { + let (project, output) = self.build(&config)?; + (project.paths, output) + }; + + self.populate_reporters(&paths.root); + sh_println!("Analysing contracts...")?; - let report = self.prepare(&project, &output)?; + let report = self.prepare(&paths, &output)?; sh_println!("Running tests...")?; - self.collect(project, &output, report, Arc::new(config), evm_opts).await + self.collect(&paths.root, &output, report, Arc::new(config), evm_opts).await + } + + fn populate_reporters(&mut self, root: &Path) { + self.reporters = self + .report + .iter() + .map(|report_kind| match report_kind { + CoverageReportKind::Summary => { + Box::::default() as Box + } + CoverageReportKind::Lcov => { + let path = + root.join(self.report_file.as_deref().unwrap_or("lcov.info".as_ref())); + Box::new(LcovReporter::new(path, self.lcov_version.clone())) + } + CoverageReportKind::Bytecode => Box::new(BytecodeReporter::new( + root.to_path_buf(), + root.join("bytecode-coverage"), + )), + CoverageReportKind::Debug => Box::new(DebugReporter), + }) + .collect::>(); } /// Builds the project. @@ -156,16 +187,19 @@ impl CoverageArgs { /// Builds the coverage report. #[instrument(name = "prepare", skip_all)] - fn prepare(&self, project: &Project, output: &ProjectCompileOutput) -> Result { + fn prepare( + &self, + project_paths: &ProjectPathsConfig, + output: &ProjectCompileOutput, + ) -> Result { let mut report = CoverageReport::default(); // Collect source files. - let project_paths = &project.paths; let mut versioned_sources = HashMap::>::default(); for (path, source_file, version) in output.output().sources.sources_with_version() { report.add_source(version.clone(), source_file.id as usize, path.clone()); - // Filter out dependencies + // Filter out dependencies. if !self.include_libs && project_paths.has_library_ancestor(path) { continue; } @@ -187,7 +221,7 @@ impl CoverageArgs { } } - // Get source maps and bytecodes + // Get source maps and bytecodes. let artifacts: Vec = output .artifact_ids() .par_bridge() // This parses source maps, so we want to run it in parallel. @@ -197,53 +231,40 @@ impl CoverageArgs { }) .collect(); - // Add coverage items + // Add coverage items. for (version, sources) in &versioned_sources { - let source_analysis = SourceAnalyzer::new(sources).analyze()?; - - // Build helper mapping used by `find_anchors` - let mut items_by_source_id = HashMap::<_, Vec<_>>::with_capacity_and_hasher( - source_analysis.items.len(), - Default::default(), - ); - - for (item_id, item) in source_analysis.items.iter().enumerate() { - items_by_source_id.entry(item.loc.source_id).or_default().push(item_id); - } - + let source_analysis = SourceAnalysis::new(sources)?; let anchors = artifacts .par_iter() .filter(|artifact| artifact.contract_id.version == *version) .map(|artifact| { - let creation_code_anchors = - artifact.creation.find_anchors(&source_analysis, &items_by_source_id); - let deployed_code_anchors = - artifact.deployed.find_anchors(&source_analysis, &items_by_source_id); + let creation_code_anchors = artifact.creation.find_anchors(&source_analysis); + let deployed_code_anchors = artifact.deployed.find_anchors(&source_analysis); (artifact.contract_id.clone(), (creation_code_anchors, deployed_code_anchors)) }) - .collect::>(); - - report.add_anchors(anchors); - report.add_items(version.clone(), source_analysis.items); + .collect_vec_list(); + report.add_anchors(anchors.into_iter().flatten()); + report.add_analysis(version.clone(), source_analysis); } - report.add_source_maps(artifacts.into_iter().map(|artifact| { - (artifact.contract_id, (artifact.creation.source_map, artifact.deployed.source_map)) - })); + if self.reporters.iter().any(|reporter| reporter.needs_source_maps()) { + report.add_source_maps(artifacts.into_iter().map(|artifact| { + (artifact.contract_id, (artifact.creation.source_map, artifact.deployed.source_map)) + })); + } Ok(report) } /// Runs tests, collects coverage data and generates the final report. async fn collect( - self, - project: Project, + mut self, + root: &Path, output: &ProjectCompileOutput, mut report: CoverageReport, config: Arc, evm_opts: EvmOpts, ) -> Result<()> { - let root = project.paths.root; let verbosity = evm_opts.verbosity; // Build the contract runner @@ -254,13 +275,12 @@ impl CoverageArgs { .sender(evm_opts.sender) .with_fork(evm_opts.get_fork(&config, env.clone())) .set_coverage(true) - .build::(&root, output, env, evm_opts)?; + .build::(root, output, env, evm_opts)?; let known_contracts = runner.known_contracts.clone(); let filter = self.test.filter(&config); - let outcome = - self.test.run_tests(runner, config.clone(), verbosity, &filter, output).await?; + let outcome = self.test.run_tests(runner, config, verbosity, &filter, output).await?; outcome.ensure_ok(false)?; @@ -298,33 +318,20 @@ impl CoverageArgs { } } - // Filter out ignored sources from the report - let file_pattern = filter.args().coverage_pattern_inverse.as_ref(); - let file_root = &filter.paths().root; - report.filter_out_ignored_sources(|path: &Path| { - file_pattern.is_none_or(|re| { - !re.is_match(&path.strip_prefix(file_root).unwrap_or(path).to_string_lossy()) - }) - }); + // Filter out ignored sources from the report. + if let Some(not_re) = &filter.args().coverage_pattern_inverse { + let file_root = filter.paths().root.as_path(); + report.retain_sources(|path: &Path| { + let path = path.strip_prefix(file_root).unwrap_or(path); + !not_re.is_match(&path.to_string_lossy()) + }); + } - // Output final report - for report_kind in self.report { - match report_kind { - CoverageReportKind::Summary => CoverageSummaryReporter::default().report(&report), - CoverageReportKind::Lcov => { - let path = - root.join(self.report_file.as_deref().unwrap_or("lcov.info".as_ref())); - let mut file = io::BufWriter::new(fs::create_file(path)?); - LcovReporter::new(&mut file, self.lcov_version.clone()).report(&report) - } - CoverageReportKind::Bytecode => { - let destdir = root.join("bytecode-coverage"); - fs::create_dir_all(&destdir)?; - BytecodeReporter::new(root.clone(), destdir).report(&report) - } - CoverageReportKind::Debug => DebugReporter.report(&report), - }?; + // Output final reports. + for reporter in &mut self.reporters { + reporter.report(&report)?; } + Ok(()) } @@ -418,18 +425,8 @@ impl BytecodeData { Self { source_map, bytecode, ic_pc_map } } - pub fn find_anchors( - &self, - source_analysis: &SourceAnalysis, - items_by_source_id: &HashMap>, - ) -> Vec { - find_anchors( - &self.bytecode, - &self.source_map, - &self.ic_pc_map, - &source_analysis.items, - items_by_source_id, - ) + pub fn find_anchors(&self, source_analysis: &SourceAnalysis) -> Vec { + find_anchors(&self.bytecode, &self.source_map, &self.ic_pc_map, source_analysis) } } diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index ff3cac46eb886..9fc29bd2b8aa8 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -15,7 +15,13 @@ pub use foundry_evm::coverage::*; /// A coverage reporter. pub trait CoverageReporter { - fn report(self, report: &CoverageReport) -> eyre::Result<()>; + /// Returns `true` if the reporter needs source maps for the final report. + fn needs_source_maps(&self) -> bool { + false + } + + /// Runs the reporter. + fn report(&mut self, report: &CoverageReport) -> eyre::Result<()>; } /// A simple summary reporter that prints the coverage results in a table. @@ -56,7 +62,7 @@ impl CoverageSummaryReporter { } impl CoverageReporter for CoverageSummaryReporter { - fn report(mut self, report: &CoverageReport) -> eyre::Result<()> { + fn report(&mut self, report: &CoverageReport) -> eyre::Result<()> { for (path, summary) in report.summary_by_file() { self.total.merge(&summary); self.add_row(path.display(), summary); @@ -89,26 +95,28 @@ fn format_cell(hits: usize, total: usize) -> Cell { /// /// [LCOV]: https://github.com/linux-test-project/lcov /// [tracefile format]: https://man.archlinux.org/man/geninfo.1.en#TRACEFILE_FORMAT -pub struct LcovReporter<'a> { - out: &'a mut (dyn Write + 'a), +pub struct LcovReporter { + path: PathBuf, version: Version, } -impl<'a> LcovReporter<'a> { +impl LcovReporter { /// Create a new LCOV reporter. - pub fn new(out: &'a mut (dyn Write + 'a), version: Version) -> Self { - Self { out, version } + pub fn new(path: PathBuf, version: Version) -> Self { + Self { path, version } } } -impl CoverageReporter for LcovReporter<'_> { - fn report(self, report: &CoverageReport) -> eyre::Result<()> { +impl CoverageReporter for LcovReporter { + fn report(&mut self, report: &CoverageReport) -> eyre::Result<()> { + let mut out = std::io::BufWriter::new(fs::create_file(&self.path)?); + let mut fn_index = 0usize; for (path, items) in report.items_by_file() { let summary = CoverageSummary::from_items(items.iter().copied()); - writeln!(self.out, "TN:")?; - writeln!(self.out, "SF:{}", path.display())?; + writeln!(out, "TN:")?; + writeln!(out, "SF:{}", path.display())?; for item in items { let line = item.loc.lines.start; @@ -120,24 +128,24 @@ impl CoverageReporter for LcovReporter<'_> { let name = format!("{}.{name}", item.loc.contract_name); if self.version >= Version::new(2, 2, 0) { // v2.2 changed the FN format. - writeln!(self.out, "FNL:{fn_index},{line},{end_line}")?; - writeln!(self.out, "FNA:{fn_index},{hits},{name}")?; + writeln!(out, "FNL:{fn_index},{line},{end_line}")?; + writeln!(out, "FNA:{fn_index},{hits},{name}")?; fn_index += 1; } else if self.version >= Version::new(2, 0, 0) { // v2.0 added end_line to FN. - writeln!(self.out, "FN:{line},{end_line},{name}")?; - writeln!(self.out, "FNDA:{hits},{name}")?; + writeln!(out, "FN:{line},{end_line},{name}")?; + writeln!(out, "FNDA:{hits},{name}")?; } else { - writeln!(self.out, "FN:{line},{name}")?; - writeln!(self.out, "FNDA:{hits},{name}")?; + writeln!(out, "FN:{line},{name}")?; + writeln!(out, "FNDA:{hits},{name}")?; } } CoverageItemKind::Line => { - writeln!(self.out, "DA:{line},{hits}")?; + writeln!(out, "DA:{line},{hits}")?; } CoverageItemKind::Branch { branch_id, path_id, .. } => { writeln!( - self.out, + out, "BRDA:{line},{branch_id},{path_id},{}", if hits == 0 { "-".to_string() } else { hits.to_string() } )?; @@ -149,20 +157,21 @@ impl CoverageReporter for LcovReporter<'_> { } // Function summary - writeln!(self.out, "FNF:{}", summary.function_count)?; - writeln!(self.out, "FNH:{}", summary.function_hits)?; + writeln!(out, "FNF:{}", summary.function_count)?; + writeln!(out, "FNH:{}", summary.function_hits)?; // Line summary - writeln!(self.out, "LF:{}", summary.line_count)?; - writeln!(self.out, "LH:{}", summary.line_hits)?; + writeln!(out, "LF:{}", summary.line_count)?; + writeln!(out, "LH:{}", summary.line_hits)?; // Branch summary - writeln!(self.out, "BRF:{}", summary.branch_count)?; - writeln!(self.out, "BRH:{}", summary.branch_hits)?; + writeln!(out, "BRF:{}", summary.branch_count)?; + writeln!(out, "BRH:{}", summary.branch_hits)?; - writeln!(self.out, "end_of_record")?; + writeln!(out, "end_of_record")?; } + out.flush()?; sh_println!("Wrote LCOV report.")?; Ok(()) @@ -173,40 +182,40 @@ impl CoverageReporter for LcovReporter<'_> { pub struct DebugReporter; impl CoverageReporter for DebugReporter { - fn report(self, report: &CoverageReport) -> eyre::Result<()> { + fn report(&mut self, report: &CoverageReport) -> eyre::Result<()> { for (path, items) in report.items_by_file() { sh_println!("Uncovered for {}:", path.display())?; - items.iter().for_each(|item| { + for item in items { if item.hits == 0 { - let _ = sh_println!("- {item}"); + sh_println!("- {item}")?; } - }); + } sh_println!()?; } for (contract_id, anchors) in &report.anchors { sh_println!("Anchors for {contract_id}:")?; - anchors + let anchors = anchors .0 .iter() .map(|anchor| (false, anchor)) - .chain(anchors.1.iter().map(|anchor| (true, anchor))) - .for_each(|(is_deployed, anchor)| { - let _ = sh_println!("- {anchor}"); - if is_deployed { - let _ = sh_println!("- Creation code"); - } else { - let _ = sh_println!("- Runtime code"); - } - let _ = sh_println!( - " - Refers to item: {}", - report - .items - .get(&contract_id.version) - .and_then(|items| items.get(anchor.item_id)) - .map_or("None".to_owned(), |item| item.to_string()) - ); - }); + .chain(anchors.1.iter().map(|anchor| (true, anchor))); + for (is_deployed, anchor) in anchors { + sh_println!("- {anchor}")?; + if is_deployed { + sh_println!("- Creation code")?; + } else { + sh_println!("- Runtime code")?; + } + sh_println!( + " - Refers to item: {}", + report + .analyses + .get(&contract_id.version) + .and_then(|items| items.get(anchor.item_id)) + .map_or_else(|| "None".to_owned(), |item| item.to_string()) + )?; + } sh_println!()?; } @@ -226,9 +235,15 @@ impl BytecodeReporter { } impl CoverageReporter for BytecodeReporter { - fn report(self, report: &CoverageReport) -> eyre::Result<()> { + fn needs_source_maps(&self) -> bool { + true + } + + fn report(&mut self, report: &CoverageReport) -> eyre::Result<()> { use std::fmt::Write; + fs::create_dir_all(&self.destdir)?; + let no_source_elements = Vec::new(); let mut line_number_cache = LineNumberCache::new(self.root.clone()); @@ -241,7 +256,7 @@ impl CoverageReporter for BytecodeReporter { for (code, source_element) in std::iter::zip(ops.iter(), source_elements) { let hits = hits - .get(code.offset as usize) + .get(code.offset) .map(|h| format!("[{h:03}]")) .unwrap_or(" ".to_owned()); let source_id = source_element.index(); diff --git a/crates/script/src/execute.rs b/crates/script/src/execute.rs index d7bf29c69f3ff..863044f548b0e 100644 --- a/crates/script/src/execute.rs +++ b/crates/script/src/execute.rs @@ -33,7 +33,7 @@ use foundry_evm::{ }; use futures::future::join_all; use itertools::Itertools; -use std::path::PathBuf; +use std::path::Path; use yansi::Paint; /// State after linking, contains the linked build data along with library addresses and optional @@ -495,7 +495,7 @@ impl PreSimulationState { Ok(()) } - pub fn run_debug_file_dumper(self, path: &PathBuf) -> Result<()> { + pub fn dump_debugger(self, path: &Path) -> Result<()> { self.create_debugger().dump_to_file(path)?; Ok(()) } diff --git a/crates/script/src/lib.rs b/crates/script/src/lib.rs index 807ff2a140005..60a68990bbdf7 100644 --- a/crates/script/src/lib.rs +++ b/crates/script/src/lib.rs @@ -260,7 +260,7 @@ impl ScriptArgs { if pre_simulation.args.debug { return match pre_simulation.args.dump.clone() { - Some(ref path) => pre_simulation.run_debug_file_dumper(path), + Some(path) => pre_simulation.dump_debugger(&path), None => pre_simulation.run_debugger(), }; } From 58900d88d746ff6045a93e4c4a1a7df68f3204b0 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 28 Jan 2025 11:38:48 +0100 Subject: [PATCH 1895/1963] fix(coverage): keep EVM version when normalizing for ir-minimum (#9768) --- crates/config/src/lib.rs | 22 ++++++++++++++-------- crates/forge/bin/cmd/coverage.rs | 25 +++++++++++-------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 98ae60a77ef66..024617a3a7b89 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -226,8 +226,11 @@ pub struct Config { /// /// **Note** for backwards compatibility reasons this also accepts solc_version from the toml /// file, see `BackwardsCompatTomlProvider`. + /// + /// Avoid using this field directly; call the related `solc` methods instead. + #[doc(hidden)] pub solc: Option, - /// whether to autodetect the solc compiler version to use + /// Whether to autodetect the solc compiler version to use. pub auto_detect_solc: bool, /// Offline mode, if set, network access (downloading solc) is disallowed. /// @@ -801,7 +804,7 @@ impl Config { self.fs_permissions.join_all(&root); - if let Some(ref mut model_checker) = self.model_checker { + if let Some(model_checker) = &mut self.model_checker { model_checker.contracts = std::mem::take(&mut model_checker.contracts) .into_iter() .map(|(path, contracts)| { @@ -850,12 +853,9 @@ impl Config { } } - /// Returns the normalized [EvmVersion] if a [SolcReq] is set to a valid version or if the solc - /// path is a valid solc binary. - /// - /// Otherwise it returns the configured [EvmVersion]. + /// Returns the normalized [EvmVersion] for the current solc version, or the configured one. pub fn get_normalized_evm_version(&self) -> EvmVersion { - if let Some(version) = self.solc.as_ref().and_then(|solc| solc.try_version().ok()) { + if let Some(version) = self.solc_version() { if let Some(evm_version) = self.evm_version.normalize_version_solc(&version) { return evm_version; } @@ -1118,7 +1118,8 @@ impl Config { Err(RecvTimeoutError::Disconnected) => panic!("sender dropped"), }; } - if let Some(ref solc) = self.solc { + + if let Some(solc) = &self.solc { let solc = match solc { SolcReq::Version(version) => { if let Some(solc) = Solc::find_svm_installed_version(version)? { @@ -1216,6 +1217,11 @@ impl Config { } } + /// Returns the solc version, if any. + pub fn solc_version(&self) -> Option { + self.solc.as_ref().and_then(|solc| solc.try_version().ok()) + } + /// Returns configured [Vyper] compiler. pub fn vyper_compiler(&self) -> Result, SolcError> { // Only instantiate Vyper if there are any Vyper files in the project. diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index a1eab26282688..f8952f8504515 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -22,7 +22,7 @@ use foundry_compilers::{ compilers::multi::MultiCompiler, Artifact, ArtifactId, Project, ProjectCompileOutput, ProjectPathsConfig, }; -use foundry_config::{Config, SolcReq}; +use foundry_config::Config; use rayon::prelude::*; use semver::{Version, VersionReq}; use std::{ @@ -150,32 +150,29 @@ impl CoverageArgs { "See more: https://github.com/foundry-rs/foundry/issues/3357", ))?; - // Enable viaIR with minimum optimization - // https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 - // And also in new releases of solidity: - // https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 + // Enable viaIR with minimum optimization: https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 + // And also in new releases of Solidity: https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 project.settings.solc.settings = project.settings.solc.settings.with_via_ir_minimum_optimization(); - let version = if let Some(SolcReq::Version(version)) = &config.solc { - version - } else { - // Sanitize settings for solc 0.8.4 if version cannot be detected. - // See . - &Version::new(0, 8, 4) - }; - project.settings.solc.settings.sanitize(version, SolcLanguage::Solidity); + + // Sanitize settings for solc 0.8.4 if version cannot be detected: https://github.com/foundry-rs/foundry/issues/9322 + // But keep the EVM version: https://github.com/ethereum/solidity/issues/15775 + let evm_version = project.settings.solc.evm_version; + let version = config.solc_version().unwrap_or_else(|| Version::new(0, 8, 4)); + project.settings.solc.settings.sanitize(&version, SolcLanguage::Solidity); + project.settings.solc.evm_version = evm_version; } else { project.settings.solc.optimizer.disable(); project.settings.solc.optimizer.runs = None; project.settings.solc.optimizer.details = None; project.settings.solc.via_ir = None; } + let mut warning = "optimizer settings have been disabled for accurate coverage reports".to_string(); if !self.ir_minimum { warning += ", if you encounter \"stack too deep\" errors, consider using `--ir-minimum` which enables viaIR with minimum optimization resolving most of the errors"; } - sh_warn!("{warning}")?; let output = ProjectCompiler::default() From 9b3d2d79f7e5c356e20b011009a71be79e8c5a60 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 28 Jan 2025 13:14:40 +0100 Subject: [PATCH 1896/1963] chore: update README for `1.0` (#9540) * start adding new benchmarks and recording * add benchmarks * add solady compilation benchmark * crop demo gif to scale better * clean up * fix morpho-blue integration test, skewed because of create2 mining * add compilation comparison for openzeppelin * add very basic getting started * add basic examples for each tool * clean up * clean up * use default MIT and Apache 2.0 licenses for auto-recognition by Github * apply default format of license, using existing fields * clean up, point to book as primary source rather than crates * clean up dev docs * spell fix * clean up * nits * nits * revert to previous license version, updated format was not necessary - possibly Github related data issue yesterday * Apply suggestions from code review Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * note dual support * fix link to actions Co-authored-by: Lubov66 * link directly to existing references rather than overviews * add designed benchmarks * improve size slightly * use center alignment * fix spacing * fix spacing * update image paths * remove outdated Foundry docs, users should refer to the book * remove outdated docs, Foundry book should serve as primary source until we actually focus on Foundry as a library * move demo.gif, remove unused logo * fix build * update table in fmt, restore docs for crate * try fixing rpc that is down --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Lubov66 --- .github/assets/banner.png | Bin 0 -> 559043 bytes .../build_benchmark_openzeppelin_dark.png | Bin 0 -> 73955 bytes .../build_benchmark_openzeppelin_light.png | Bin 0 -> 73291 bytes .../assets/build_benchmark_solady_dark.png | Bin 0 -> 72404 bytes .../assets/build_benchmark_solady_light.png | Bin 0 -> 72066 bytes .github/assets/demo.gif | Bin 0 -> 1712188 bytes .github/demo.gif | Bin 997606 -> 0 bytes .github/logo.png | Bin 14491 -> 0 bytes Cargo.lock | 2 - LICENSE-APACHE | 2 +- LICENSE-MIT | 2 +- README.md | 356 +++++++++++--- crates/anvil/README.md | 103 ---- crates/anvil/src/lib.rs | 3 +- crates/cast/README.md | 5 - crates/cast/bin/args.rs | 2 +- crates/cast/src/lib.rs | 3 +- crates/cast/tests/cli/main.rs | 2 +- crates/cheatcodes/spec/README.md | 3 - crates/cheatcodes/spec/src/lib.rs | 3 +- crates/chisel/Cargo.toml | 2 - crates/chisel/README.md | 216 --------- crates/chisel/src/lib.rs | 16 +- crates/fmt/README.md | 60 ++- crates/forge/README.md | 446 ------------------ crates/forge/src/lib.rs | 3 +- docs/dev/README.md | 90 +++- docs/dev/architecture.md | 1 + docs/dev/cheatcodes.md | 3 + docs/dev/debugging.md | 19 +- docs/dev/scripting.md | 25 +- testdata/default/repros/Issue3708.t.sol | 3 +- 32 files changed, 435 insertions(+), 935 deletions(-) create mode 100644 .github/assets/banner.png create mode 100644 .github/assets/build_benchmark_openzeppelin_dark.png create mode 100644 .github/assets/build_benchmark_openzeppelin_light.png create mode 100644 .github/assets/build_benchmark_solady_dark.png create mode 100644 .github/assets/build_benchmark_solady_light.png create mode 100644 .github/assets/demo.gif delete mode 100644 .github/demo.gif delete mode 100644 .github/logo.png delete mode 100644 crates/anvil/README.md delete mode 100644 crates/cast/README.md delete mode 100644 crates/cheatcodes/spec/README.md delete mode 100644 crates/chisel/README.md delete mode 100644 crates/forge/README.md diff --git a/.github/assets/banner.png b/.github/assets/banner.png new file mode 100644 index 0000000000000000000000000000000000000000..2a3752b97fc0c082483daaa3e94a29cec296599b GIT binary patch literal 559043 zcmXt9RaDdu6aDQjv2-^`x3nNqyCB^y(h|}k-MfT>bV+xKA}JyztO`g-cO%{1vHSgB zzNb5{bIzQZd+xpSURPU%2%jDw001I2RYiROfc{rvL7|ZUpeA;J;Xgp>Y8on0&@y4r z1@SRKn4Q;x9LzmAK^V*s0Wl@F&{HN>9#(D<^hFROC3$hE73Lux27tWWLiUrr?t3GfkrW`9}5g~4>}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ZSanz@%TILg zET)(>WrmFIG~;M&!dJKt67f+``Qq?x>%gWr9+-zwip0Accin|I-wt0v2casr28p0b zJl>z2vmsf)ozz~hm|qX9*}7%A@cH5j?F$9x`IzwQIS)?v=7LVbU;2aB%)4t9vC2eN zVMPq(kI5n&zWFGxjPzSYvD7d5LRXGy|CxHiU2CWN zl}0Vv=LzW^ZA%@%QMt`6%p@L60$^XvYjlF_*n9Ls8}>6N^3PbVt4?F@+o}Y8I&8vz zh+WeTj#nKmsjc*G`F~n*qNJ>D9jE;u zc*o)~VQjE%q>olb0VlOcQ_W}Kt zprLN*Ztt?_7cHMoG1r2&-iUA&Uj20Y=19Iv`Qp$bACcwZ+sSZ-_a1VwuiIt#Uxd5k z<%a`03Zmi2VNeqDrZ!rq^Xjn!97$Vl9H$a?D)jqJj(0MSiNxuPfl;E^xduF`QqPg%@4X zqlmYOfiiB=2tP3Z)=d!P-~As%0*wAysde;x|3q=oYS8)nvSQa3v#1t{sl^$N5`ban l<5_i2G&9banYsf8V83UP4*tby(M?_u*z7-OQEuiL|3BTs8$bX6 literal 0 HcmV?d00001 diff --git a/.github/assets/build_benchmark_openzeppelin_dark.png b/.github/assets/build_benchmark_openzeppelin_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..75d80d127c3771fc506032845481b431638b552b GIT binary patch literal 73955 zcmeFYXH-*r^aU8OAS&R~rzq8iC|!CH5D`(T(h(9snxRYR5WokbPXt6t=!hDS7J7h$ zqVOa_fCwRk7K#BP2>~P|bePL~^Ix-Otyyb6%(q#8@`1Z@?@jKnoOAZxXXo#SW`=yn zg^q(jAif9p?^=LBJjXzwL#xM*0`EK}CDK7$7t0>p)w2rYTHHO+s~ifK+&EY9^)Qt@ zsW4LT^~>SKlj!I6C@$A)fBPImU*h`8%avBaEqwUe6$!Vi3OU)@T4!9|Ub|#?{HVl< z?s;d=ZlM=>0VlG~D4y3hIU4c>acn&HtD8^SiMBudu5fnIrHBanW@u4!HDxN6yNJELjSuT}6|LNH)C-t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#McQ{r|l&}>>kXa&wUg}<0zmpHMKzn-|oy6(|bx0ravFNiQh zTrY|_8bO^q&MU-PpgAv8UyW|y$>|`HSKcKU$M@ESjauiceN~)F>D$(m+BVx;vBvP! z?$5M{-L7IqPR&c$2+ap{&7(FiKklFt*^m|A27`3$*y+2~n*9g2`?OM*!}){c3?O%k z{TgAIBPJr&xZ^|aTOCp9r`R(UkK?^o5ROB)HhR$3;v_YjzRrZ_Egs+6&hU^f#oMpR z5*<^!x8A8E-$%y5(-(_ig^9)hZQlLSNC9k5-^{xBaoyi#x%RZ^%M^LPhF{^*%ueBM zk5SgWcR5DA2FE9@#cVTm6}WY1|DsohRncyNds#TAP)6>fz+A@37=J^B=RG6Lai%XU zx{4%uPL>ir-}ohW=^3?3NCw)su-kfKA6HT0t$D!Lt@V~BRcOx6&ekZfE>RfN(yXu6 zJgH+1Xv934{5*5Ph{{8)S~|SmcGuO^a;$mw!C3!f=9x;r7~CkO@MqVBhw-4g*KaeP z@7`2;&G%z)M>ayC-(Ky=6N~uB1eOuGO!aX4lcO zTcadX76pe*8%FxU?$$_z>?I0PznfDx*sTsp$K6^rQY(M``R?s`p@^l)fzGJX%kwUc z`Ci*$=%eye^`*_>9?_SFPN-E>X|DgBBCL(`Dd-Vgt-9Q=vC7M2J`(ZDMrRbJGa)Cb z4YRiC{m3A8Dqxy2ej2Ajm+12rjh%P<3`IGGv@g`Y|-v(Ibtg z{^){Z{=d_9{vUy${%;i(Id=wTAbZ`~bcB!!LBfXW+iWGz@FwO2Ps+R<5Ev&`?qr9Mn#fH0g}#vY+F&&+ z#?a)-gW2u(`6;?;sdq2>5TvRNYGYX-8x9hWYirTMzGxOmQ5w4I@J|%PwR4aA$=5En Uk6Xnw#xaK1%>J&?ca8hM0A_NafB*mh literal 0 HcmV?d00001 diff --git a/.github/assets/build_benchmark_solady_dark.png b/.github/assets/build_benchmark_solady_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..123c51f9132f8e3fe3230e52fb14145ce79db47c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kpdc3_81eG2;*NQH#r3Qn??#n2_9oqbx2F&}J0$KbE^wj5f(NKv~F z9{@3na6Dn4Ru)WZbK41P>HXBmw`MBt=!a`LR9;K3(6|i2Um`#kY(w*z$BB*mCDsb5 z6K{mvPGpgEU=KSyqS4ihIACk711Qq{NV@}W?O;#PMbe1aVqUhWtjE&mgBNNlYz1;j_z1eQ;m2Zh{7I*`4~S3AwB zYC+7!#M_IAlU;xXE$c%n7d!H8qV;HKY-T%CqU~TneKl#=Q#grSqZFjw(v(YfUko4{7Gz1WX5sS1kN8saCaSH$)BTa(m_XUqM0byBDA6)LS7#^f~{wKg0 zr%VsCZ8kybUO2d4|AucM{4W?g4~|1Bh~{B0Hj`diTw{PRVfU&EtRWE9qP=tNRQPc_ YmoT5Lwbl9cH#Vk!?bcsqx(*Nj7w)&b-2eap literal 0 HcmV?d00001 diff --git a/.github/assets/demo.gif b/.github/assets/demo.gif new file mode 100644 index 0000000000000000000000000000000000000000..bebdb8148ce19b4f132edc09db205812641af07e GIT binary patch literal 1712188 zcmd@5S5%W>7d48$2?0Vt2t8CoM~YG<6fyMPI|x#hrh+0J4WT8}P^6boqzOn9LQw&c z-bI>-fG9{&K)Ol}-}n7{jI+l$<6Q2Wor_#PYdveuweqg{&gkfAqZD2AAbOBv01y?s zesZ$k`~IE0f;u5JJcXlrZT%I3DXg7Q@<6-mvTQf3-5PC7D9y7E4T3c;qj`j$#DmMUp>H;WwA zYFxDYy!AfZH{J;{JqyFfCue5mUYA74E2wBlDfyz%Axi3MnraSChIf6;0)lN~Z)j$q zwTm@$J9Q1$OwGtvR+yMuIYoDeKZK8b2;VzP?CpK0*>=ZCUUkOE#9;Z6@(tZ|w03<% zndotFN-g~i%V+?&3@2Y!K#ZT@C5D#m8o zkAkhA#@w1)#x}M2zwHb9wiCB!Zt+q}f5^Z%G0mm4^!Wq-zz6<8_6}}!FYBMz_=Z2h z+6_f`kuyB@lcluO6`hT>aJS7~`s+ROSo-oQDjH|+WZ>%V?d9z!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GWfTrX0}8je}=2KXR53P=u=s{wOwnpQJ1tJyR0cIp+P0Nd5izJ>j$|B=mt)U4(tH6 z!f362ij3i>95JV}6M3TF`m;Q=Q7JLB=R%D|CJAnE1{w2ft0sd2YL6DWZwl93?lyeB zB~mX|u)xNWy9gJ-3vz!q1hfWgZqNo=D>oxGy&d_l63V=j>TMqvQ^vu&QU$!yJG?sR zWnN~b`sHl#OT0GGy$bie;fr$5>x#mLVfFi^Xhpvtwi(<@Zw=!Tc+{XRyKS3ZZp+k`r9O4++8KtAgqVYcyLXu}c(a z0&_UGt#C+lF_$JR^?f~CsJW}VI)qiCcxuDR5(oE?b=Lo2|EshNmu3wt1XP0?_vK(Q zHXAPHW$gAMZBU(2e1J);8Xgu?4$_wgXEp24#TdqJXq$m?rf_#AV%_GPU4~&?nZjl4 z9!+e2_azBIXIWx6z=p|-YkV7Lti{g}WEeKc2Fwm~tjES-mT}s~V*H1J49Suin`9h? zJP^iSY>iKh31eJ(iArm2QP=YD_(%SS6EG=9xUDMYz(j^@a?`+dNT}*_gdcw6NKn-PxX<*`TdRo<0BCogLbyZAhe@+NZtRf|S~%&DyZ-N3K2E zv0dAGG~1tT+qzvxxLw-2{o8TW+nf#D#O+4Hz1hW`+-h{(w4mJ1ZAQ%f+|n&Z(LLSP z-9^=X-P(;s*}dJ~Jw@I9-Qw*;;XU5wokZn*-s(+6>Al|W{X^~j-tw(O@jc)6T|@PK z-}((h`Mux%y+Zx{-vVwz0Y2ac9zq3v;0o?Q3BKSCen1WW;1V7`5kBD-PCgZW;Tm2& z8NT5j?mHd+;Ua!JAwJ?JJ~}0S;wtVrDZb(^4l*tN;xaztG+yI2e&aZv<2t_MJl^9z f{^LL%+cN diff --git a/.github/logo.png b/.github/logo.png deleted file mode 100644 index 8e24b87ef689e559f913575513a21af749593214..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14491 zcmZ{LWmHvN*EZcL-Q6MGAl(hZp+g!3LAs?Iq>=6}>6Gs75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#;0xn|5o<=gYLHx gQU5amdxkGBi8wWEI+y*!;2%&5GOE%wlBPlb50REec>n+a diff --git a/Cargo.lock b/Cargo.lock index 9a7cf2427884e..b7115c912c49e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2100,12 +2100,10 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "alloy-rpc-types", "clap", "dirs 5.0.1", "eyre", "forge-fmt", - "foundry-block-explorers", "foundry-cli", "foundry-common", "foundry-compilers", diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 3c4dfe081ce47..a7b8b5e6a6dc5 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -184,4 +184,4 @@ comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier - identification within third-party archives. + identification within third-party archives. \ No newline at end of file diff --git a/LICENSE-MIT b/LICENSE-MIT index 8dce0ba55e1c8..38bfa706247e8 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 3a6b24f233122..4fa5510481304 100644 --- a/README.md +++ b/README.md @@ -1,112 +1,312 @@ -Foundry logo +

      + Foundry banner -## Foundry +  -![Github Actions][gha-badge] [![Telegram Chat][tg-badge]][tg-url] [![Telegram Support][tg-support-badge]][tg-support-url] +[![Github Actions][gha-badge]][gha-url] [![Telegram Chat][tg-badge]][tg-url] [![Telegram Support][tg-support-badge]][tg-support-url] ![Foundry](https://img.shields.io/badge/Foundry-grey?style=flat&logo=data:image/png;base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IPn69esZTdMIgM+ePUNXVxdu376NsrIyuN1uXLp0CWazGcPDw3C5XFBVFWfPnkVNTQ18Pp+ezWY5MzPzO4DfAABHjhzpJslUKqVdvHiR4+PjbG9vZy6XI0kuLS0xmUxSCEGS9Pv9LC0tpdFoZGVlpSaEoM/nuwIAKx/7q5GRkb9CoZBQVVWcP3+ez58/J0mm02kODg7ywoULjMViTKfTtNvtXLt2LTdt2qTncrnlsbGxLICvSUqfrl5HJBLh1NTUkhBCJ8mFhQX29/dTVVUWFBTwwYMH1HWdly9fpqIoeiKRWJqfn2d1dXWnLMuf7zMAHD16tGd+fn7FZy2bzYrKykodAAFQVVV9cXFRkNTevn3Lubk5trS0XPnfxHE4HN8ODw+nV/yanp6mx+Ohx+P5aIMQgmNjY3/W1tZ+t5rsSwG7+fjx4/76+vrm7du32woLC00AkE6n38fj8ZmHDx/+cuPGjR8BJL8YsCtYdQIMALYqilKvKEo9APuHty+egH8A3GfFDJXmxmMAAAAASUVORK5CYII%3D&link=https%3A%2F%2Fbook.getfoundry.sh%2F) [gha-badge]: https://img.shields.io/github/actions/workflow/status/foundry-rs/foundry/test.yml?branch=master +[gha-url]: https://github.com/foundry-rs/foundry/actions [tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Ffoundry_rs [tg-url]: https://t.me/foundry_rs [tg-support-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=support&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Ffoundry_support [tg-support-url]: https://t.me/foundry_support **[Install](https://book.getfoundry.sh/getting-started/installation)** -| [User Book](https://book.getfoundry.sh) -| [Developer Docs](./docs/dev/) -| [Crate Docs](https://foundry-rs.github.io/foundry) +| [User Book][foundry-book] +| [Developer Docs](./docs/dev/README.md) +| [Contributing](./CONTRIBUTING.md) -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** +
      + +--- + +### Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust. Foundry consists of: -- [**Forge**](./crates/forge): Ethereum testing framework (like Truffle, Hardhat and DappTools). -- [**Cast**](./crates/cast): Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. -- [**Anvil**](./crates/anvil): Local Ethereum node, akin to Ganache, Hardhat Network. -- [**Chisel**](./crates/chisel): Fast, utilitarian, and verbose solidity REPL. +- [**Forge**](#forge): Build, test, fuzz, debug and deploy [Solidity][solidity] contracts, like Hardhat, Brownie, Ape. +- [**Cast**](#cast): A Swiss Army knife for interacting with EVM smart contracts, sending transactions and getting chain data. +- [**Anvil**](#anvil): Fast local Ethereum development node, akin to Hardhat Network, Tenderly. +- [**Chisel**](#chisel): Fast, utilitarian, and verbose Solidity REPL. + +**Need help getting started with Foundry? Read the [📖 Foundry Book][foundry-book]!** + +![Demo](.github/assets/demo.gif) + +## Features + +- **High-Performance Compilation** + + - **Fast and Flexible**: Automatically detects and installs the required Solidity compiler version. + - **Solidity and Vyper Support**: Fully supports both Solidity and Vyper out-of-the-box. + - **Incremental Compilation**: Re-compiles only changed files, saving time. + - **Parallelized Pipeline**: Leverages multi-core systems for ultra-fast builds. + - **Broad Compatibility**: Supports non-standard directory structures, including [Hardhat repos](https://twitter.com/gakonst/status/1461289225337421829). + +- **Advanced Testing** + + - **No Context Switching**: Write tests directly in Solidity. + - **Fuzz Testing**: Quickly identify edge cases with input shrinking and counter-example generation. + - **Invariant Testing**: Ensure complex system properties hold across a wide range of inputs. + - **Debugging Made Easy**: Use [forge-std](https://github.com/foundry-rs/forge-std)'s `console.sol` for flexible debug logging. + - **Interactive Debugger**: Step through your Solidity code with Foundry's interactive debugger, making it easy to pinpoint issues. -**Need help getting started with Foundry? Read the [📖 Foundry Book][foundry-book] (WIP)!** +- **Powerful Runtime Features** -![Demo](.github/demo.gif) + - **RPC Forking**: Fast and efficient remote RPC forking backed by [Alloy][alloy]. + - **Lightweight & Portable**: No dependency on Nix or other package managers for installation. + +- **Streamlined CI/CD** + + - **Optimized CI**: Accelerate builds, run tests and execute scripts using [Foundry's GitHub action][foundry-gha]. ## Installation -See the [installation guide](https://book.getfoundry.sh/getting-started/installation) in the book. +Getting started is very easy: + +Install `foundryup`: + +``` +curl -L https://foundry.paradigm.xyz | bash +``` + +Next, run `foundryup`. + +It will automatically install the latest version of the precompiled binaries: [`forge`](#forge), [`cast`](#cast), [`anvil`](#anvil), and [`chisel`](#chisel). + +``` +foundryup +``` + +**Done!** + +For additional details see the [installation guide](https://book.getfoundry.sh/getting-started/installation) in the [Foundry Book][foundry-book]. If you're experiencing any issues while installing, check out [Getting Help](#getting-help) and the [FAQ](https://book.getfoundry.sh/faq). +## How Fast? + +Forge is quite fast at both compiling (leveraging `solc` with [foundry-compilers]) and testing. + +See the benchmarks below. Older benchmarks against [DappTools][dapptools] can be found in the [v0.2.0 announcement post][benchmark-post] and in the [Convex Shutdown Simulation][convex] repository. + +### Testing Benchmarks + +| Project | Type | [Forge 1.0][foundry-1.0] | [Forge 0.2][foundry-0.2] | DappTools | Speedup | +| --------------------------------------------- | -------------------- | ------------------------ | ------------------------ | --------- | -------------- | +| [vectorized/solady][solady] | Unit / Fuzz | 0.9s | 2.3s | - | 2.6x | +| [morpho-org/morpho-blue][morpho-blue] | Invariant | 0.7s | 1m43s | - | 147.1x | +| [morpho-org/morpho-blue-oracles][morpho-blue] | Integration (Cold) | 6.1s | 6.3s | - | 1.04x | +| [morpho-org/morpho-blue-oracles][morpho-blue] | Integration (Cached) | 0.6s | 0.9s | - | 1.50x | +| [transmissions11/solmate][solmate] | Unit / Fuzz | 2.7s | 2.8s | 6m34s | 1.03x / 140.0x | +| [reflexer-labs/geb][geb] | Unit / Fuzz | 0.2s | 0.4s | 23s | 2.0x / 57.5x | + +_In the above benchmarks, compilation was always skipped_ + +**Takeaway: Forge dramatically outperforms the competition, delivering blazing-fast execution speeds while continuously expanding its robust feature set.** + +### Compilation Benchmarks + +
      + + + + + + + + + + +  + +
      + +**Takeaway: Forge compilation is consistently faster than Hardhat by a factor of `2.1x` to `5.2x`, depending on the amount of caching involved.** + ## Forge -### Features +Forge helps you build, test, fuzz, debug and deploy Solidity contracts. + +The best way to understand Forge is to simply try it (in less than 30 seconds!). + +First, let's initialize a new `counter` example repository: + +```sh +forge init counter +``` + +Next `cd` into `counter` and build : + +```sh +forge build +``` -- **Fast & flexible compilation pipeline** - - Automatic Solidity compiler version detection & installation - - **Incremental compilation & caching**: Only changed files are re-compiled - - Parallel compilation - - Non-standard directory structures support (e.g. [Hardhat repos](https://twitter.com/gakonst/status/1461289225337421829)) -- **Tests are written in Solidity** (like in DappTools) -- **Fast fuzz testing** with shrinking of inputs & printing of counter-examples -- **Fast remote RPC forking mode**, leveraging Rust's async infrastructure like tokio -- **Flexible debug logging** - - DappTools-style, using `DsTest`'s emitted logs - - Hardhat-style, using the popular `console.sol` contract -- **Portable (5-10MB) & easy to install** without requiring Nix or any other package manager -- **Fast CI** with the [Foundry GitHub action][foundry-gha]. +```console +[⠊] Compiling... +[⠔] Compiling 27 files with Solc 0.8.28 +[⠒] Solc 0.8.28 finished in 452.13ms +Compiler run successful! +``` -### How Fast? +Let's [test](https://book.getfoundry.sh/forge/tests#tests) our contracts: -Forge is quite fast at both compiling (leveraging [foundry-compilers]) and testing. +```sh +forge test +``` -See the benchmarks below. More benchmarks can be found in the [v0.2.0 announcement post][benchmark-post] and in the [Convex Shutdown Simulation][convex] repository. +```console +[⠊] Compiling... +No files changed, compilation skipped -**Testing Benchmarks** +Ran 2 tests for test/Counter.t.sol:CounterTest +[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 31121, ~: 31277) +[PASS] test_Increment() (gas: 31293) +Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 5.35ms (4.86ms CPU time) -| Project | Forge | DappTools | Speedup | -| ---------------------------------- | ----- | --------- | ------- | -| [transmissions11/solmate][solmate] | 2.8s | 6m34s | 140x | -| [reflexer-labs/geb][geb] | 0.4s | 23s | 57.5x | -| [Rari-Capital/vaults][vaults] | 0.28s | 6.5s | 23x | +Ran 1 test suite in 5.91ms (5.35ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests) +``` -_Note: In the above benchmarks, compilation was always skipped_ +Finally, let's run our deployment script: -**Compilation Benchmarks** +```sh +forge script script/Counter.s.sol +``` -Compilation benchmarks +```console +[⠊] Compiling... +No files changed, compilation skipped +Script ran successfully. +Gas used: 109037 -**Takeaway: Forge compilation is consistently faster by a factor of 1.7-11.3x, depending on the amount of caching involved.** +If you wish to simulate on-chain transactions pass a RPC URL. +``` + +Run `forge --help` to explore the full list of available subcommands and their usage. + +More documentation can be found in the [forge][foundry-book-forge] section of the Foundry Book. ## Cast -Cast is a swiss army knife for interacting with Ethereum applications from the command line. +Cast is a Swiss Army knife for interacting with Ethereum applications from the command line. -More documentation can be found in the [cast package](./crates/cast). +Here are a few examples of what you can do: -## Configuration +**Check the latest block on Ethereum Mainnet**: + +```sh +cast block-number --rpc-url https://eth.merkle.io +``` + +**Check the Ether balance of `vitalik.eth`** + +```sh +cast balance vitalik.eth --ether --rpc-url https://eth.merkle.io +``` + +**Replay and trace a transaction** + +```sh +cast run 0x9c32042f5e997e27e67f82583839548eb19dc78c4769ad6218657c17f2a5ed31 --rpc-url https://eth.merkle.io +``` + +Optionally, pass `--etherscan-api-key ` to decode transaction traces using verified source maps, providing more detailed and human-readable information. + +--- + +Run `cast --help` to explore the full list of available subcommands and their usage. + +More documentation can be found in the [cast][foundry-book-cast] section of the Foundry Book. + +## Anvil + +Anvil is a fast local Ethereum development node. + +Let's fork Ethereum mainnet at the latest block: + +```sh +anvil --fork-url https://eth.merkle.io +``` + +You can use those same `cast` subcommands against your `anvil` instance: + +```sh +cast block-number +``` -### Using `foundry.toml` +--- -Foundry is designed to be very configurable. You can configure Foundry using a file called [`foundry.toml`](./crates/config) in the root of your project, or any other parent directory. See [config package](./crates/config/README.md#all-options) for all available options. +Run `anvil --help` to explore the full list of available features and their usage. -Configuration can be arbitrarily namespaced by profiles. The default profile is named `default` (see ["Default Profile"](./crates/config/README.md#default-profile)). +More documentation can be found in the [anvil][foundry-book-anvil] section of the Foundry Book. -You can select another profile using the `FOUNDRY_PROFILE` environment variable. You can also override parts of your configuration using `FOUNDRY_` or `DAPP_` prefixed environment variables, like `FOUNDRY_SRC`. +## Chisel -`forge init` creates a basic, extendable `foundry.toml` file. +Chisel is a fast, utilitarian, and verbose Solidity REPL. -To see your current configuration, run `forge config`. To see only basic options (as set with `forge init`), run `forge config --basic`. This can be used to create a new `foundry.toml` file with `forge config --basic > foundry.toml`. +To use Chisel, simply type `chisel`. -By default `forge config` shows the currently selected foundry profile and its values. It also accepts the same arguments as `forge build`. +```sh +chisel +``` -### DappTools Compatibility +From here, start writing Solidity code! Chisel will offer verbose feedback on each input. -You can reuse your `.dapprc` environment variables by running `source .dapprc` before using a Foundry tool. +Create a variable `a` and query it: -### Additional Configuration +```console +➜ uint256 a = 123; +➜ a +Type: uint256 +├ Hex: 0x7b +├ Hex (full word): 0x000000000000000000000000000000000000000000000000000000000000007b +└ Decimal: 123 +``` -You can find additional setup and configurations guides in the [Foundry Book][foundry-book]: +Finally, run `!source` to see `a` was applied: -- [Setting up VSCode][vscode-setup] -- [Shell autocompletions][shell-setup] +```solidity +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.28; + +import {Vm} from "forge-std/Vm.sol"; + +contract REPL { + Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); + + /// @notice REPL contract entry point + function run() public { + uint256 a = 123; + } +} +``` + +--- + +Run `chisel --help` to explore the full list of available features and their usage. + +More documentation can be found in the [chisel][foundry-book-chisel] section of the Foundry Book. + +## Configuration + +Foundry is highly configurable, allowing you to tailor it to your needs. Configuration is managed via a file called [`foundry.toml`](./crates/config) located in the root of your project or any parent directory. For a full list of configuration options, refer to the [config package documentation](./crates/config/README.md#all-options). + +**Profiles and Namespaces** + +- Configuration can be organized into **profiles**, which are arbitrarily namespaced for flexibility. +- The default profile is named `default`. Learn more in the [Default Profile section](./crates/config/README.md#default-profile). +- To select a different profile, set the `FOUNDRY_PROFILE` environment variable. +- Override specific settings using environment variables prefixed with `FOUNDRY_` (e.g., `FOUNDRY_SRC`). + +--- + +You can find additional [setup and configurations guides][foundry-book-config] in the [Foundry Book][foundry-book] and in the [config crate](./crates/config/README.md): + +- [Configuring with `foundry.toml`](https://book.getfoundry.sh/config/) +- [Setting up VSCode][vscode-setup] +- [Shell autocompletions][shell-setup] ## Contributing @@ -114,32 +314,54 @@ See our [contributing guidelines](./CONTRIBUTING.md). ## Getting Help -First, see if the answer to your question can be found in [book][foundry-book], or in the relevant crate. +First, see if the answer to your question can be found in the [Foundy Book][foundry-book], or in the relevant crate. If the answer is not there: -- Join the [support Telegram][tg-support-url] to get help, or -- Open a [discussion](https://github.com/foundry-rs/foundry/discussions/new) with your question, or -- Open an issue with [the bug](https://github.com/foundry-rs/foundry/issues/new) +- Join the [support Telegram][tg-support-url] to get help, or +- Open a [discussion](https://github.com/foundry-rs/foundry/discussions/new) with your question, or +- Open an issue with [the bug](https://github.com/foundry-rs/foundry/issues/new) If you want to contribute, or follow along with contributor discussion, you can use our [main telegram](https://t.me/foundry_rs) to chat with us about the development of Foundry! +## License + +Licensed under either of [Apache License](./LICENSE-APACHE), Version +2.0 or [MIT License](./LICENSE-MIT) at your option. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in these crates by you, as defined in the Apache-2.0 license, +shall be dual licensed as above, without any additional terms or conditions. + ## Acknowledgements -- Foundry is a clean-room rewrite of the testing framework [DappTools](https://github.com/dapphub/dapptools). None of this would have been possible without the DappHub team's work over the years. -- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] (now [foundry-compilers]) which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. -- [Rohit Narurkar](https://twitter.com/rohitnarurkar): Created the Rust Solidity version manager [svm-rs](https://github.com/roynalnaruto/svm-rs) which we use to auto-detect and manage multiple Solidity versions. -- [Brock Elmore](https://twitter.com/brockjelmore): For extending the VM's cheatcodes and implementing [structured call tracing](https://github.com/foundry-rs/foundry/pull/192), a critical feature for debugging smart contract calls. -- All the other [contributors](https://github.com/foundry-rs/foundry/graphs/contributors) to the [ethers-rs](https://github.com/gakonst/ethers-rs) & [foundry](https://github.com/foundry-rs/foundry) repositories and chatrooms. +- Foundry is a clean-room rewrite of the testing framework [DappTools][dapptools]. None of this would have been possible without the DappHub team's work over the years. +- [Matthias Seitz](https://twitter.com/mattsse_): Created [ethers-solc] (now [foundry-compilers]) which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the `abigen` macros. +- [Rohit Narurkar](https://twitter.com/rohitnarurkar): Created the Rust Solidity version manager [svm-rs](https://github.com/roynalnaruto/svm-rs) which we use to auto-detect and manage multiple Solidity versions. +- [Brock Elmore](https://twitter.com/brockjelmore): For extending the VM's cheatcodes and implementing [structured call tracing](https://github.com/foundry-rs/foundry/pull/192), a critical feature for debugging smart contract calls. +- All the other [contributors](https://github.com/foundry-rs/foundry/graphs/contributors) to the [ethers-rs](https://github.com/gakonst/ethers-rs), [alloy][alloy] & [foundry](https://github.com/foundry-rs/foundry) repositories and chatrooms. +[solidity]: https://soliditylang.org/ [foundry-book]: https://book.getfoundry.sh +[foundry-book-config]: https://book.getfoundry.sh/config/ +[foundry-book-forge]: https://book.getfoundry.sh/reference/forge/ +[foundry-book-anvil]: https://book.getfoundry.sh/reference/anvil/ +[foundry-book-cast]: https://book.getfoundry.sh/reference/cast/ +[foundry-book-chisel]: https://book.getfoundry.sh/reference/chisel/ [foundry-gha]: https://github.com/foundry-rs/foundry-toolchain +[foundry-compilers]: https://github.com/foundry-rs/compilers [ethers-solc]: https://github.com/gakonst/ethers-rs/tree/master/ethers-solc/ +[solady]: https://github.com/Vectorized/solady +[openzeppelin]: https://github.com/OpenZeppelin/openzeppelin-contracts/tree/release-v5.1 +[morpho-blue]: https://github.com/morpho-org/morpho-blue [foundry-compilers]: https://github.com/foundry-rs/compilers [solmate]: https://github.com/transmissions11/solmate/ [geb]: https://github.com/reflexer-labs/geb -[vaults]: https://github.com/rari-capital/vaults [benchmark-post]: https://www.paradigm.xyz/2022/03/foundry-02#blazing-fast-compilation--testing [convex]: https://github.com/mds1/convex-shutdown-simulation [vscode-setup]: https://book.getfoundry.sh/config/vscode.html [shell-setup]: https://book.getfoundry.sh/config/shell-autocompletion.html +[foundry-0.2]: https://github.com/foundry-rs/foundry/releases/tag/nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a +[foundry-1.0]: https://github.com/foundry-rs/foundry/releases/tag/nightly-59f354c179f4e7f6d7292acb3d068815c79286d1 +[dapptools]: https://github.com/dapphub/dapptools +[alloy]: https://github.com/alloy-rs/alloy diff --git a/crates/anvil/README.md b/crates/anvil/README.md deleted file mode 100644 index efb0f9e2e5c9a..0000000000000 --- a/crates/anvil/README.md +++ /dev/null @@ -1,103 +0,0 @@ -## Anvil - -A local Ethereum node, akin to Ganache, designed for development with [**Forge**](../../bin/forge). - -## Features - -- Network forking: fork any EVM-compatible blockchain, same as in `forge` -- [Ethereum JSON-RPC](https://ethereum.org/developers/docs/apis/json-rpc/) support -- Additional JSON-RPC endpoints, compatible with ganache and hardhat - - snapshot/revert state - - mining modes: auto, interval, manual, none - - ... - -## Supported Versions - -- **anvil**: - - **evm**: Cancun -- **forge**: - - **solc**: Latest - - **evm**: Cancun - - -## Installation - -`anvil` binary is available via [`foundryup`](../../README.md#installation). - -### Installing from source - -```sh -cargo install --git https://github.com/foundry-rs/foundry anvil --locked --force -``` - -## Getting started - -```console -$ anvil - - _ _ - (_) | | - __ _ _ __ __ __ _ | | - / _` | | '_ \ \ \ / / | | | | - | (_| | | | | | \ V / | | | | - \__,_| |_| |_| \_/ |_| |_| - - 0.1.0 (8d507b4 2023-08-05T00:20:34.048397801Z) - https://github.com/foundry-rs/foundry - -Available Accounts -================== - -(0) "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" (10000.000000000000000000 ETH) -(1) "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" (10000.000000000000000000 ETH) -(2) "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" (10000.000000000000000000 ETH) -(3) "0x90F79bf6EB2c4f870365E785982E1f101E93b906" (10000.000000000000000000 ETH) -(4) "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65" (10000.000000000000000000 ETH) -(5) "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc" (10000.000000000000000000 ETH) -(6) "0x976EA74026E726554dB657fA54763abd0C3a0aa9" (10000.000000000000000000 ETH) -(7) "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955" (10000.000000000000000000 ETH) -(8) "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f" (10000.000000000000000000 ETH) -(9) "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720" (10000.000000000000000000 ETH) - -Private Keys -================== - -(0) 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -(1) 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d -(2) 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a -(3) 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 -(4) 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a -(5) 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba -(6) 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e -(7) 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 -(8) 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 -(9) 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 - -Wallet -================== -Mnemonic: test test test test test test test test test test test junk -Derivation path: m/44'/60'/0'/0/ - - -Chain ID -================== - -31337 - -Base Fee -================== - -1000000000 - -Gas Limit -================== - -30000000 - -Genesis Timestamp -================== - -1692087429 - -Listening on 127.0.0.1:8545 -``` diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 6d2e6d5e465e0..c9d2598e1dfee 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -1,4 +1,5 @@ -#![doc = include_str!("../README.md")] +//! Anvil is a fast local Ethereum development node. + #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use crate::{ diff --git a/crates/cast/README.md b/crates/cast/README.md deleted file mode 100644 index 32de3fd74c215..0000000000000 --- a/crates/cast/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# `cast` - -Cast is a command-line tool for performing Ethereum RPC calls. You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line! - -For more information, see the [📖 Foundry Book (Cast Guide)](https://book.getfoundry.sh/cast/index.html). diff --git a/crates/cast/bin/args.rs b/crates/cast/bin/args.rs index e8be1da5eb226..eeeb5d8531d16 100644 --- a/crates/cast/bin/args.rs +++ b/crates/cast/bin/args.rs @@ -16,7 +16,7 @@ use foundry_common::{ }; use std::{path::PathBuf, str::FromStr}; -/// Perform Ethereum RPC calls from the comfort of your command line. +/// A Swiss Army knife for interacting with Ethereum applications from the command line. #[derive(Parser)] #[command( name = "cast", diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 6d51bd9303ced..fb5cc9f84df28 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1,4 +1,5 @@ -#![doc = include_str!("../README.md")] +//! Cast is a Swiss Army knife for interacting with Ethereum applications from the command line. + #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use alloy_consensus::TxEnvelope; diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 2b29fdf9b3744..19dfd7433647f 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -37,7 +37,7 @@ Build Profile: [..] // tests `--help` is printed to std out casttest!(print_help, |_prj, cmd| { cmd.arg("--help").assert_success().stdout_eq(str![[r#" -Perform Ethereum RPC calls from the comfort of your command line +A Swiss Army knife for interacting with Ethereum applications from the command line Usage: cast[..] diff --git a/crates/cheatcodes/spec/README.md b/crates/cheatcodes/spec/README.md deleted file mode 100644 index 0b0aecebed6d1..0000000000000 --- a/crates/cheatcodes/spec/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# foundry-cheatcodes-spec - -Minimal crate to provide a cheatcodes specification. diff --git a/crates/cheatcodes/spec/src/lib.rs b/crates/cheatcodes/spec/src/lib.rs index e39cfc2d7ba91..6dd6ee769f6b9 100644 --- a/crates/cheatcodes/spec/src/lib.rs +++ b/crates/cheatcodes/spec/src/lib.rs @@ -1,4 +1,5 @@ -#![doc = include_str!("../README.md")] +//! Cheatcode specification for Foundry. + #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index f0fea63a80a91..ca025a05ad829 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -23,7 +23,6 @@ path = "bin/main.rs" [dependencies] # forge forge-fmt.workspace = true -foundry-block-explorers.workspace = true foundry-cli.workspace = true foundry-common.workspace = true foundry-compilers = { workspace = true, features = ["project-util", "full"] } @@ -38,7 +37,6 @@ alloy-primitives = { workspace = true, features = [ "rlp", ] } alloy-json-abi.workspace = true -alloy-rpc-types.workspace = true clap = { version = "4", features = ["derive", "env", "wrap_help"] } dirs = "5" diff --git a/crates/chisel/README.md b/crates/chisel/README.md deleted file mode 100644 index 8ea2840aa36a8..0000000000000 --- a/crates/chisel/README.md +++ /dev/null @@ -1,216 +0,0 @@ -# `chisel` - -Chisel is a fast, utilitarian, and verbose Solidity REPL. It is heavily inspired by the incredible work done in [soli](https://github.com/jpopesculian/soli) and [solidity-shell](https://github.com/tintinweb/solidity-shell)! - -![preview](./assets/preview.gif) - -## Why? - -Ever wanted to quickly test a small feature in solidity? - -Perhaps to test how custom errors work, or how to write inline assembly? - -Chisel is a fully-functional Solidity REPL, allowing you to write, execute, and debug Solidity directly in the command line. - -Once you finish testing, Chisel even lets you export your code to a new solidity file! - -In this sense, Chisel even serves as a Foundry script generator. - -## Feature Completion - -[soli](https://github.com/jpopesculian/soli) and [solidity-shell](https://github.com/tintinweb/solidity-shell) both provide a great solidity REPL, achieving: - -- Statement support -- Custom events, errors, functions, imports -- Inspecting variables -- Forking remote chains -- Session caching - -Chisel aims to improve upon existing Solidity REPLs by integrating with foundry as well as offering additional functionality: - -- More verbose variable / state inspection -- Improved error messages -- Foundry-style call traces -- In-depth environment configuration -- ... and many more future features! - -### Migrating from [soli](https://github.com/jpopesculian/soli) or [solidity-shell](https://github.com/tintinweb/solidity-shell) - -Migration from existing Solidity REPLs such as [soli](https://github.com/jpopesculian/soli) or [solidity-shell](https://github.com/tintinweb/solidity-shell) is as -simple as installing Chisel via `foundryup`. For information on features, usage, and configuration, see the [Usage](#usage) section as well as the chisel manpage (`man chisel` or `chisel --help`). - -## Installation - -To install `chisel`, simply run `foundryup`! - -If you do not have `foundryup` installed, reference the Foundry [installation guide](../../README.md#installation). - -## Usage - -### REPL Commands - -```text -⚒️ Chisel help -============= -General - !help | !h - Display all commands - !quit | !q - Quit Chisel - !exec [args] | !e [args] - Execute a shell command and print the output - -Session - !clear | !c - Clear current session source - !source | !so - Display the source code of the current session - !save [id] | !s [id] - Save the current session to cache - !load | !l - Load a previous session ID from cache - !list | !ls - List all cached sessions - !clearcache | !cc - Clear the chisel cache of all stored sessions - !export | !ex - Export the current session source to a script file - !fetch | !fe - Fetch the interface of a verified contract on Etherscan - !edit - Open the current session in an editor - -Environment - !fork | !f - Fork an RPC for the current session. Supply 0 arguments to return to a local network - !traces | !t - Enable / disable traces for the current session - !calldata [data] | !cd [data] - Set calldata (`msg.data`) for the current session (appended after function selector). Clears it if no argument provided. - -Debug - !memdump | !md - Dump the raw memory of the current state - !stackdump | !sd - Dump the raw stack of the current state - !rawstack | !rs - Display the raw value of a variable's stack allocation. For variables that are > 32 bytes in length, this will display their memory pointer. -``` - -### Cache Session - -While chisel sessions are not persistent by default, they can be saved to the cache via the builtin `save` command from within the REPL. - -Sessions can also be named by supplying a single argument to the `save` command, i.e. `!save my_session`. - -```text -$ chisel -➜ uint a = 1; -➜ uint b = a << 0x08; -➜ !save -Saved session to cache with ID = 0. -``` - -### Loading a Previous Session - -Chisel allows you to load a previous session from your history. - -To view your history, you can run `chisel list` or `!list`. This will print a list of your previous sessions, identifiable by their index. - -You can also run `chisel view ` or `!view ` to view the contents of a specific session. - -To load a session, run `chisel load ` or use the `!load ` where `` is a valid session index (eg 2 in the example below). - -```text -$ chisel list -⚒️ Chisel Sessions -"2022-10-27 14:46:29" - chisel-0.json -"2022-10-27 14:46:29" - chisel-1.json -$ chisel view 1 -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.17; - -contract REPL { - event KeccakEvent(bytes32 hash); - - function run() public { - emit KeccakEvent(keccak256(abi.encode("Hello, world!"))); - } -} -$ chisel load 1 -➜ ... -``` - -### Clearing the Cache - -To clear Chisel's cache (stored in `~/.foundry/cache/chisel`), use the `chisel clear-cache` or `!clearcache` command. - -```text -➜ !clearcache -Cleared chisel cache! -``` - -### Toggling Traces - -By default, traces will only be shown if an input causes the call to the REPL contract to revert. To turn traces on -regardless of the call result, use the `!traces` command or pass in a verbosity option of any level (`-v`) to -the chisel binary. - -```text -➜ uint a -➜ contract Test { - function get() external view returns (uint) { - return 256; - } -} -➜ Test t = new Test() -➜ !traces -Successfully enabled traces! -➜ a = t.get() -Traces: - [69808] 0xBd770416a3345F91E4B34576cb804a576fa48EB1::run() - ├─ [36687] → new @0xf4D9599aFd90B5038b18e3B551Bc21a97ed21c37 - │ └─ ← 183 bytes of code - ├─ [315] 0xf4D9599aFd90B5038b18e3B551Bc21a97ed21c37::get() [staticcall] - │ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000100 - └─ ← () - -➜ a -Type: uint -├ Hex: 0x100 -└ Decimal: 256 -``` - -### Forking a Network - -To fork a network within your chisel session, use the `!fork ` command or supply a `--fork-url ` flag -to the chisel binary. The `!fork` command also accepts aliases from the `[rpc_endpoints]` section of your `foundry.toml` -if chisel was launched in the root of a foundry project (ex. `!fork mainnet`), as well as interpolated environment variables -(ex. `!fork https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`). - -### Fetching an Interface of a Verified Contract - -To fetch an interface of a verified contract on Etherscan, use the `!fetch` / `!f` command. - -> **Note** -> At the moment, only contracts that are deployed and verified on mainnet can be fetched. Support for other -> networks with Etherscan explorers coming soon. - -```text -➜ !fetch 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 IWETH -Added 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2's interface to source as `IWETH` -``` - -### Executing a Shell Command - -Shell commands can be executed within Chisel with the `!exec` / `!e` command. - -```text -➜ !e ls -anvil -binder -Cargo.lock -Cargo.toml -cast -chisel -cli -common -config -CONTRIBUTING.md -Dockerfile -docs -evm -fmt -forge -foundryup -LICENSE-APACHE -LICENSE-MIT -README.md -rustfmt.toml -target -testdata -ui -utils -``` diff --git a/crates/chisel/src/lib.rs b/crates/chisel/src/lib.rs index ccae2db2ddbee..5eeedada69bbf 100644 --- a/crates/chisel/src/lib.rs +++ b/crates/chisel/src/lib.rs @@ -1,23 +1,17 @@ -#![doc = include_str!("../README.md")] +//! Chisel is a fast, utilitarian, and verbose Solidity REPL. + #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] extern crate foundry_common; -pub mod dispatcher; - pub mod cmd; - +pub mod dispatcher; +pub mod executor; pub mod history; - +pub mod runner; pub mod session; - pub mod session_source; - -pub mod runner; - -pub mod executor; - pub mod solidity_helper; pub mod prelude { diff --git a/crates/fmt/README.md b/crates/fmt/README.md index 11e0c5ea3024b..1fc2712ad6e0e 100644 --- a/crates/fmt/README.md +++ b/crates/fmt/README.md @@ -1,6 +1,7 @@ # Formatter (`fmt`) -Solidity formatter that respects (some parts of) the [Style Guide](https://docs.soliditylang.org/en/latest/style-guide.html) and +Solidity formatter that respects (some parts of) +the [Style Guide](https://docs.soliditylang.org/en/latest/style-guide.html) and is tested on the [Prettier Solidity Plugin](https://github.com/prettier-solidity/prettier-plugin-solidity) cases. ## Architecture @@ -17,13 +18,19 @@ and works as following: 1. Implement `Formatter` callback functions for each PT node type. Every callback function should write formatted output for the current node and call `Visitable::visit` function for child nodes delegating the output writing. -1. Implement `Visitable` trait and its `visit` function for each PT node type. Every `visit` function should call corresponding `Formatter`'s callback function. +1. Implement `Visitable` trait and its `visit` function for each PT node type. Every `visit` function should call + corresponding `Formatter`'s callback function. ### Output -The formatted output is written into the output buffer in _chunks_. The `Chunk` struct holds the content to be written & metadata for it. This includes the comments surrounding the content as well as the `needs_space` flag specifying whether this _chunk_ needs a space. The flag overrides the default behavior of `Formatter::next_char_needs_space` method. +The formatted output is written into the output buffer in _chunks_. The `Chunk` struct holds the content to be written & +metadata for it. This includes the comments surrounding the content as well as the `needs_space` flag specifying whether +this _chunk_ needs a space. The flag overrides the default behavior of `Formatter::next_char_needs_space` method. -The content gets written into the `FormatBuffer` which contains the information about the current indentation level, indentation length, current state as well as the other data determining the rules for writing the content. `FormatBuffer` implements the `std::fmt::Write` trait where it evaluates the current information and decides how the content should be written to the destination. +The content gets written into the `FormatBuffer` which contains the information about the current indentation level, +indentation length, current state as well as the other data determining the rules for writing the content. +`FormatBuffer` implements the `std::fmt::Write` trait where it evaluates the current information and decides how the +content should be written to the destination. ### Comments @@ -107,17 +114,22 @@ event Greet(string indexed name); The formatter supports multiple configuration options defined in `FormatterConfig`. -| Option | Default | Description | -| -------------------------------- | -------- | ---------------------------------------------------------------------------------------------- | -| line_length | 120 | Maximum line length where formatter will try to wrap the line | -| tab_width | 4 | Number of spaces per indentation level | -| bracket_spacing | false | Print spaces between brackets | -| int_types | long | Style of uint/int256 types. Available options: `long`, `short`, `preserve` | -| func_attrs_with_params_multiline | true | If function parameters are multiline then always put the function attributes on separate lines | -| quote_style | double | Style of quotation marks. Available options: `double`, `single`, `preserve` | -| number_underscore | preserve | Style of underscores in number literals. Available options: `remove`, `thousands`, `preserve` | - -TODO: update ^ +| Option | Default | Description | +|------------------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| +| line_length | 120 | Maximum line length where formatter will try to wrap the line | +| tab_width | 4 | Number of spaces per indentation level | +| bracket_spacing | false | Print spaces between brackets | +| int_types | long | Style of uint/int256 types. Available options: `long`, `short`, `preserve` | +| multiline_func_header | attributes_first | Style of multiline function header in case it doesn't fit. Available options: `params_first`, `params_first_multi`, `attributes_first`, `all`, `all_params` | +| quote_style | double | Style of quotation marks. Available options: `double`, `single`, `preserve` | +| number_underscore | preserve | Style of underscores in number literals. Available options: `preserve`, `remove`, `thousands` | +| hex_underscore | remove | Style of underscores in hex literals. Available options: `preserve`, `remove`, `bytes` | +| single_line_statement_blocks | preserve | Style of single line blocks in statements. Available options: `single`, `multi`, `preserve` | +| override_spacing | false | Print space in state variable, function and modifier `override` attribute | +| wrap_comments | false | Wrap comments on `line_length` reached | +| ignore | [] | Globs to ignore | +| contract_new_lines | false | Add new line at start and end of contract declarations | +| sort_imports | false | Sort import statements alphabetically in groups | ### Disable Line @@ -128,7 +140,8 @@ The formatter can be disabled on specific lines by adding a comment `// forgefmt uint x = 100; ``` -Alternatively, the comment can also be placed at the end of the line. In this case, you'd have to use `disable-line` instead: +Alternatively, the comment can also be placed at the end of the line. In this case, you'd have to use `disable-line` +instead: ```solidity uint x = 100; // forgefmt: disable-line @@ -136,7 +149,8 @@ uint x = 100; // forgefmt: disable-line ### Disable Block -The formatter can be disabled for a section of code by adding a comment `// forgefmt: disable-start` before and a comment `// forgefmt: disable-end` after, like this: +The formatter can be disabled for a section of code by adding a comment `// forgefmt: disable-start` before and a +comment `// forgefmt: disable-end` after, like this: ```solidity // forgefmt: disable-start @@ -147,15 +161,19 @@ uint y = 101; ### Testing -Tests reside under the `fmt/testdata` folder and specify the malformatted & expected Solidity code. The source code file is named `original.sol` and expected file(s) are named in a format `({prefix}.)?fmt.sol`. Multiple expected files are needed for tests covering available configuration options. +Tests reside under the `fmt/testdata` folder and specify the malformatted & expected Solidity code. The source code file +is named `original.sol` and expected file(s) are named in a format `({prefix}.)?fmt.sol`. Multiple expected files are +needed for tests covering available configuration options. -The default configuration values can be overridden from within the expected file by adding a comment in the format `// config: {config_entry} = {config_value}`. For example: +The default configuration values can be overridden from within the expected file by adding a comment in the format +`// config: {config_entry} = {config_value}`. For example: ```solidity // config: line_length = 160 ``` -The `test_directory` macro is used to specify a new folder with source files for the test suite. Each test suite has the following process: +The `test_directory` macro is used to specify a new folder with source files for the test suite. Each test suite has the +following process: 1. Preparse comments with config values 2. Parse and compare the AST for source & expected files. @@ -201,4 +219,4 @@ Guidelines for contributing to `forge fmt`: 3. Provide the test coverage for the new feature. These should include: - Adding malformatted & expected solidity code under `fmt/testdata/$dir/` - Testing the behavior of pre and postfix comments - - If it's a new config value, tests covering **all** available options + - If it's a new config value, tests covering **all** available options \ No newline at end of file diff --git a/crates/forge/README.md b/crates/forge/README.md deleted file mode 100644 index a40a852db54ec..0000000000000 --- a/crates/forge/README.md +++ /dev/null @@ -1,446 +0,0 @@ -# `forge` - -Forge is a fast and flexible Ethereum testing framework, inspired by -[Dapp](https://github.com/dapphub/dapptools/tree/master/src/dapp). - -If you are looking into how to consume the software as an end user, check the -[CLI README](../cli/README.md). - -For more context on how the package works under the hood, look in the -[code docs](./src/lib.rs). - -**Need help with Forge? Read the [📖 Foundry Book (Forge Guide)][foundry-book-forge-guide] (WIP)!** - -[foundry-book-forge-guide]: https://book.getfoundry.sh/forge/ - -## Why? - -### Write your tests in Solidity to minimize context switching - -Writing tests in Javascript/Typescript while writing your smart contracts in -Solidity can be confusing. Forge lets you write your tests in Solidity, so you -can focus on what matters. - -```solidity -contract Foo { - uint256 public x = 1; - function set(uint256 _x) external { - x = _x; - } - - function double() external { - x = 2 * x; - } -} - -contract FooTest { - Foo foo; - - // The state of the contract gets reset before each - // test is run, with the `setUp()` function being called - // each time after deployment. - function setUp() public { - foo = new Foo(); - } - - // A simple unit test - function testDouble() public { - require(foo.x() == 1); - foo.double(); - require(foo.x() == 2); - } -} -``` - -### Fuzzing: Go beyond unit testing - -When testing smart contracts, fuzzing can uncover edge cases which would be hard -to manually detect with manual unit testing. We support fuzzing natively, where -any test function that takes >0 arguments will be fuzzed, using the -[proptest](https://docs.rs/proptest/1.0.0/proptest/) crate. - -An example of how a fuzzed test would look like can be seen below: - -```solidity -function testDoubleWithFuzzing(uint256 x) public { - foo.set(x); - require(foo.x() == x); - foo.double(); - require(foo.x() == 2 * x); -} -``` - -## Features - -- [ ] test - - [x] Simple unit tests - - [x] Gas costs - - [x] DappTools style test output - - [x] JSON test output - - [x] Matching on regex - - [x] DSTest-style assertions support - - [x] Fuzzing - - [ ] Symbolic execution - - [ ] Coverage - - [x] HEVM-style Solidity cheatcodes - - [ ] Structured tracing with abi decoding - - [ ] Per-line gas profiling - - [x] Forking mode - - [x] Automatic solc selection -- [x] build - - [x] Can read DappTools-style .sol.json artifacts - - [x] Manual remappings - - [x] Automatic remappings - - [x] Multiple compiler versions - - [x] Incremental compilation - - [ ] Can read Hardhat-style artifacts - - [ ] Can read Truffle-style artifacts -- [x] install -- [x] update -- [ ] debug -- [x] CLI Tracing with `RUST_LOG=forge=trace` - -### Gas Report - -Foundry will show you a comprehensive gas report about your contracts. It returns the `min`, `average`, `median` and, `max` gas cost for every function. - -It looks at **all** the tests that make a call to a given function and records the associated gas costs. For example, if something calls a function and it reverts, that's probably the `min` value. Another example is the `max` value that is generated usually during the first call of the function (as it has to initialise storage, variables, etc.) - -Usually, the `median` value is what your users will probably end up paying. `max` and `min` concern edge cases that you might want to explicitly test against, but users will probably never encounter. - -image - -### Cheat codes - -_The below is modified from -[Dapp's README](https://github.com/dapphub/dapptools/blob/master/src/hevm/README.md#cheat-codes)_ - -We allow modifying blockchain state with "cheat codes". These can be accessed by -calling into a contract at address `0x7109709ECfa91a80626fF3989D68f67F5b1DD12D`, -which implements the following methods: - -- `function warp(uint x) public` Sets the block timestamp to `x`. - -- `function difficulty(uint x) public` Sets the block difficulty to `x`. - -- `function roll(uint x) public` Sets the block number to `x`. - -- `function coinbase(address c) public` Sets the block coinbase to `c`. - -- `function store(address c, bytes32 loc, bytes32 val) public` Sets the slot - `loc` of contract `c` to `val`. - -- `function load(address c, bytes32 loc) public returns (bytes32 val)` Reads the - slot `loc` of contract `c`. - -- `function sign(uint sk, bytes32 digest) public returns (uint8 v, bytes32 r, bytes32 s)` - Signs the `digest` using the private key `sk`. Note that signatures produced - via `hevm.sign` will leak the private key. - -- `function addr(uint sk) public returns (address addr)` Derives an ethereum - address from the private key `sk`. Note that `hevm.addr(0)` will fail with - `BadCheatCode` as `0` is an invalid ECDSA private key. `sk` values above the - secp256k1 curve order, near the max uint256 value will also fail. - -- `function ffi(string[] calldata) external returns (bytes memory)` Executes the - arguments as a command in the system shell and returns stdout. Note that this - cheatcode means test authors can execute arbitrary code on user machines as - part of a call to `forge test`, for this reason all calls to `ffi` will fail - unless the `--ffi` flag is passed. - -- `function deal(address who, uint256 amount)`: Sets an account's balance - -- `function etch(address where, bytes memory what)`: Sets the contract code at - some address contract code - -- `function prank(address sender)`: Performs the next smart contract call as another address (prank just changes msg.sender. Tx still occurs as normal) - -- `function prank(address sender, address origin)`: Performs the next smart contract call setting both `msg.sender` and `tx.origin`. - -- `function startPrank(address sender)`: Performs smart contract calls as another address. The account impersonation lasts until the end of the transaction, or until `stopPrank` is called. - -- `function startPrank(address sender, address origin)`: Performs smart contract calls as another address, while also setting `tx.origin`. The account impersonation lasts until the end of the transaction, or until `stopPrank` is called. - -- `function stopPrank()`: Stop calling smart contracts with the address set at `startPrank` - -- `function expectRevert( expectedError)`: - Tells the evm to expect that the next call reverts with specified error bytes. Valid input types: `bytes`, and `bytes4`. Implicitly, strings get converted to bytes except when shorter than 4, in which case you will need to cast explicitly to `bytes`. -- `function expectEmit(bool,bool,bool,bool) external`: Expects the next emitted event. Params check topic 1, topic 2, topic 3 and data are the same. - -- `function expectEmit(bool,bool,bool,bool,address) external`: Expects the next emitted event. Params check topic 1, topic 2, topic 3 and data are the same. Also checks supplied address against address of originating contract. - -- `function getCode(string calldata) external returns (bytes memory)`: Fetches bytecode from a contract artifact. The parameter can either be in the form `ContractFile.sol` (if the filename and contract name are the same), `ContractFile.sol:ContractName`, or `./path/to/artifact.json`. - -- `function label(address addr, string calldata label) external`: Label an address in test traces. - -- `function assume(bool) external`: When fuzzing, generate new inputs if conditional not met - -- `function setNonce(address account, uint64 nonce) external`: Set nonce for an account, increment only. - -- `function getNonce(address account)`: Get nonce for an account. - -- `function chainId(uint x) public` Sets the block chainid to `x`. - -The below example uses the `warp` cheatcode to override the timestamp & `expectRevert` to expect a specific revert string: - -```solidity -interface Vm { - function warp(uint256 x) external; - function expectRevert(bytes calldata) external; -} - -contract Foo { - function bar(uint256 a) public returns (uint256) { - require(a < 100, "My expected revert string"); - return a; - } -} - -contract MyTest { - Vm vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); - - function testWarp() public { - vm.warp(100); - require(block.timestamp == 100); - } - - function testBarExpectedRevert() public { - vm.expectRevert("My expected revert string"); - // This would fail *if* we didn't expect revert. Since we expect the revert, - // it doesn't, unless the revert string is wrong. - foo.bar(101); - } - - function testFailBar() public { - // this call would revert, causing this test to pass - foo.bar(101); - } -} -``` - -Below is another example using the `expectEmit` cheatcode to check events: - -```solidity -interface Vm { - function expectEmit(bool,bool,bool,bool) external; - function expectEmit(bool,bool,bool,bool,address) external; -} - -contract T is DSTest { - Vm vm = Vm(HEVM_ADDRESS); - event Transfer(address indexed from,address indexed to, uint256 amount); - function testExpectEmit() public { - ExpectEmit emitter = new ExpectEmit(); - // check topic 1, topic 2, and data are the same as the following emitted event - vm.expectEmit(true,true,false,true); - emit Transfer(address(this), address(1337), 1337); - emitter.t(); - } - - function testExpectEmitWithAddress() public { - ExpectEmit emitter = new ExpectEmit(); - // do the same as above and check emitting address - vm.expectEmit(true,true,false,true,address(emitter)); - emit Transfer(address(this), address(1337), 1337); - emitter.t(); - } -} - -contract ExpectEmit { - event Transfer(address indexed from,address indexed to, uint256 amount); - function t() public { - emit Transfer(msg.sender, address(1337), 1337); - } -} -``` - -A full interface for all cheatcodes is here: - -```solidity -interface Hevm { - // Set block.timestamp (newTimestamp) - function warp(uint256) external; - // Set block.height (newHeight) - function roll(uint256) external; - // Set block.basefee (newBasefee) - function fee(uint256) external; - // Set block.coinbase (who) - function coinbase(address) external; - // Loads a storage slot from an address (who, slot) - function load(address,bytes32) external returns (bytes32); - // Stores a value to an address' storage slot, (who, slot, value) - function store(address,bytes32,bytes32) external; - // Signs data, (privateKey, digest) => (v, r, s) - function sign(uint256,bytes32) external returns (uint8,bytes32,bytes32); - // Gets address for a given private key, (privateKey) => (address) - function addr(uint256) external returns (address); - // Performs a foreign function call via terminal, (stringInputs) => (result) - function ffi(string[] calldata) external returns (bytes memory); - // Sets the *next* call's msg.sender to be the input address - function prank(address) external; - // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called - function startPrank(address) external; - // Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input - function prank(address,address) external; - // Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and the tx.origin to be the second input - function startPrank(address,address) external; - // Resets subsequent calls' msg.sender to be `address(this)` - function stopPrank() external; - // Sets an address' balance, (who, newBalance) - function deal(address, uint256) external; - // Sets an address' code, (who, newCode) - function etch(address, bytes calldata) external; - // Expects an error on next call - function expectRevert() external; - function expectRevert(bytes calldata) external; - function expectRevert(bytes4) external; - // Record all storage reads and writes - function record() external; - // Gets all accessed reads and write slot from a recording session, for a given address - function accesses(address) external returns (bytes32[] memory reads, bytes32[] memory writes); - // Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData). - // Call this function, then emit an event, then call a function. Internally after the call, we check if - // logs were emitted in the expected order with the expected topics and data (as specified by the booleans) - function expectEmit(bool,bool,bool,bool) external; - // Mocks a call to an address, returning specified data. - // Calldata can either be strict or a partial match, e.g. if you only - // pass a Solidity selector to the expected calldata, then the entire Solidity - // function will be mocked. - function mockCall(address,bytes calldata,bytes calldata) external; - // Mocks a call to an address with a specific msg.value, returning specified data. - // Calldata match takes precedence over msg.value in case of ambiguity. - function mockCall(address,uint256,bytes calldata,bytes calldata) external; - // Reverts a call to an address with specified revert data. - function mockCallRevert(address, bytes calldata, bytes calldata) external; - // Reverts a call to an address with a specific msg.value, with specified revert data. - function mockCallRevert(address, uint256 msgValue, bytes calldata, bytes calldata) external; - // Clears all mocked and reverted mocked calls - function clearMockedCalls() external; - // Expect a call to an address with the specified calldata. - // Calldata can either be strict or a partial match - function expectCall(address, bytes calldata) external; - // Expect given number of calls to an address with the specified calldata. - // Calldata can either be strict or a partial match - function expectCall(address, bytes calldata, uint64) external; - // Expect a call to an address with the specified msg.value and calldata - function expectCall(address, uint256, bytes calldata) external; - // Expect a given number of calls to an address with the specified msg.value and calldata - function expectCall(address, uint256, bytes calldata, uint64) external; - // Expect a call to an address with the specified msg.value, gas, and calldata. - function expectCall(address, uint256, uint64, bytes calldata) external; - // Expect a given number of calls to an address with the specified msg.value, gas, and calldata. - function expectCall(address, uint256, uint64, bytes calldata, uint64) external; - // Expect a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas. - function expectCallMinGas(address, uint256, uint64, bytes calldata) external; - // Expect a given number of calls to an address with the specified msg.value and calldata, and a *minimum* amount of gas. - function expectCallMinGas(address, uint256, uint64, bytes calldata, uint64) external; - - // Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other - // memory is written to, the test will fail. - function expectSafeMemory(uint64, uint64) external; - // Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. - // If any other memory is written to, the test will fail. - function expectSafeMemoryCall(uint64, uint64) external; - // Fetches the contract bytecode from its artifact file - function getCode(string calldata) external returns (bytes memory); - // Label an address in test traces - function label(address addr, string calldata label) external; - // When fuzzing, generate new inputs if conditional not met - function assume(bool) external; - // Set nonce for an account, increment only - function setNonce(address,uint64) external; - // Get nonce for an account - function getNonce(address) external returns(uint64); -} -``` - -### `console.log` - -We support the logging functionality from Hardhat's `console.log`. - -If you are on a hardhat project, `import hardhat/console.sol` should just work if you use `forge test --hh`. - -If no, there is an implementation contract [here](https://raw.githubusercontent.com/NomicFoundation/hardhat/master/packages/hardhat-core/console.sol). We currently recommend that you copy this contract, place it in your `test` folder, and import it into the contract where you wish to use `console.log`, though there should be more streamlined functionality soon. - -Usage follows the same format as [Hardhat](https://hardhat.org/hardhat-network/reference/#console-log): - -```solidity -import "./console.sol"; -... -console.log(someValue); - -``` - -Note: to make logs visible in `stdout`, you must use at least level 2 verbosity. - -```bash -$> forge test -vv -[PASS] test1() (gas: 7683) -... -Logs: - - ... -``` - -## Remappings - -If you are working in a repo with NPM-style imports, like - -```solidity -import "@openzeppelin/contracts/access/Ownable.sol"; -``` - -then you will need to create a `remappings.txt` file at the top level of your project directory, so that Forge knows where to find these dependencies. - -For example, if you have `@openzeppelin` imports, you would - -1. `forge install openzeppelin/openzeppelin-contracts` (this will add the repo to `lib/openzepplin-contracts`) -2. Create a remappings file: `touch remappings.txt` -3. Add this line to `remappings.txt` - -```text -@openzeppelin/=lib/openzeppelin-contracts/ -``` - -## Github Actions CI - -We recommend using the [Github Actions CI setup](https://book.getfoundry.sh/config/continuous-integration) from the [📖 Foundry Book](https://book.getfoundry.sh/index.html). - -## Future Features - -### Dapptools feature parity - -Over the next months, we intend to add the following features which are -available in upstream dapptools: - -1. Stack Traces: Currently we do not provide any debug information when a call - fails. We intend to add a structured printer (something like - [this](https://twitter.com/gakonst/status/1434337110111182848) which will - show all the calls, logs and arguments passed across intermediate smart - contract calls, which should help with debugging. -1. [Invariant Tests](https://github.com/dapphub/dapptools/blob/master/src/dapp/README.md#invariant-testing) -1. [Interactive Debugger](https://github.com/dapphub/dapptools/blob/master/src/hevm/README.md#interactive-debugger-key-bindings) -1. [Code coverage](https://twitter.com/dapptools/status/1435973810545729536) -1. [Gas snapshots](https://github.com/dapphub/dapptools/pull/850/files) -1. [Symbolic EVM](https://fv.ethereum.org/2020/07/28/symbolic-hevm-release/) - -### Unique features? - -We also intend to add features which are not available in dapptools: - -1. Even faster tests with parallel EVM execution that produces state diffs - instead of modifying the state -1. Improved UX for assertions: - 1. Check revert error or reason on a Solidity call - 1. Check that an event was emitted with expected arguments -1. Support more EVM backends ([revm](https://github.com/bluealloy/revm/), geth's - evm, hevm etc.) & benchmark performance across them -1. Declarative deployment system based on a config file -1. Formatting & Linting (maybe powered by - [Solang](https://github.com/hyperledger-labs/solang)) - 1. `forge fmt`, an automatic code formatter according to standard rules (like - [`prettier-plugin-solidity`](https://github.com/prettier-solidity/prettier-plugin-solidity)) - 1. `forge lint`, a linter + static analyzer, like a combination of - [`solhint`](https://github.com/protofire/solhint) and - [slither](https://github.com/crytic/slither/) -1. Flamegraphs for gas profiling diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index ddeada0a69c23..27dd63738f2ee 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -1,4 +1,5 @@ -#![doc = include_str!("../README.md")] +//! Forge is a fast and flexible Ethereum testing framework. + #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #[macro_use] diff --git a/docs/dev/README.md b/docs/dev/README.md index db7cc3f537c73..cde2a01c31d49 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -1,42 +1,82 @@ -# Contributing Quick Start +# Developer Docs -The foundry Rust project is organized as a regular [Cargo workspace][cargo-workspace]. +The Foundry project is organized as a regular [Cargo workspace][cargo-workspace]. -Simply running +## Installation requirements +- [Rust](https://rustup.rs/) +- Make + +We use `cargo-nextest` as test runner (both locally and in the [CI](#ci)): + +- [Nextest](https://nexte.st/docs/installation/pre-built-binaries/#with-cargo-binstall) + +## Recommended + +If you are working in VSCode, we recommend you install the [rust-analyzer](https://rust-analyzer.github.io/) extension, and use the following VSCode user settings: + +```json +"editor.formatOnSave": true, +"rust-analyzer.rustfmt.extraArgs": ["+nightly"], +"[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer" +} +``` + +Note that we use Rust's latest `nightly` for formatting. If you see `;` being inserted by your code editor it is a good indication you are on `stable`. + +## Getting started + +Build the project. + +```sh +$ make build +``` + +Run all tests. + +```sh +$ make test ``` -$ cargo test + +Run all tests and linters in preparation for a PR. + +```sh +$ make pr ``` -should be enough to get you started! +## Contents + +- [Architecture](./architecture.md) +- [Cheatcodes](./cheatcodes.md) +- [Debugging](./debugging.md) +- [Scripting](./scripting.md) -To learn more about how foundry's tools works, see [./architecture.md](./architecture.md). -It also explains the high-level layout of some aspects of the source code. -To read more about how to use it, see [📖 Foundry Book][foundry-book] -Note though, that the internal documentation is very incomplete. +_Note: This is incomplete and possibly outdated_ -# Getting in Touch +## Getting in Touch See also [Getting Help](../../README.md#getting-help) -# Issue Labels +## Issue Labels + +Whenever a ticket is initially opened a [`T-needs-triage`](https://github.com/foundry-rs/foundry/issues?q=is%3Aissue+is%3Aopen+label%3AT-needs-triage) label is assigned. This means that a member has yet to correctly label it. + +If this is your first time contributing have a look at our [`first-issue`](https://github.com/foundry-rs/foundry/issues?q=is%3Aissue+is%3Aopen+label%3A%22first+issue%22) tickets. These are tickets we think are a good way to get familiar with the codebase. + +We classify the tickets in two major categories: [`T-feature`](https://github.com/foundry-rs/foundry/issues?q=is%3Aissue+is%3Aopen+label%3AT-feature) and [`T-bug`](https://github.com/foundry-rs/foundry/issues?q=is%3Aissue+is%3Aopen+label%3AT-bug). Additional labels are usually applied to help categorize the ticket for future reference. + +We also make use of [`T-meta`](https://github.com/foundry-rs/foundry/issues?q=is%3Aissue+is%3Aopen+label%3AT-meta) aggregation tickets. These tickets are tickets to collect related features and bugs. + +We also have [`T-discuss`](https://github.com/foundry-rs/foundry/issues?q=is%3Aissue+is%3Aopen+label%3AT-to-discuss) tickets that require further discussion before proceeding on an implementation. Feel free to jump into the conversation! + +## CI -- [good-first-issue](https://github.com/foundry-rs/foundry/labels/good%20first%20issue) - are good issues to get into the project. -- [D-easy](https://github.com/foundry-rs/foundry/issues?q=is%3Aopen+is%3Aissue+label%3AD-easy), - [D-average](https://github.com/foundry-rs/foundry/issues?q=is%3Aopen+is%3Aissue+label%3AD-medium), - [D-hard](https://github.com/foundry-rs/foundry/issues?q=is%3Aopen+is%3Aissue+label%3AD-hard), - [D-chore](https://github.com/foundry-rs/foundry/issues?q=is%3Aopen+is%3Aissue+label%3AD-chore), - labels indicate how hard it would be to write a fix or add a feature. +We use GitHub Actions for continuous integration (CI). -# CI +We use [cargo-nextest][nextest] as the test runner. -We use GitHub Actions for CI. -We use [cargo-nextest][nextest] as the test runner -If `cargo test` passes locally, that's a good sign that CI will be green as well. -We also have tests that make use of forking mode which can be long running if the required state is not already cached locally. -Forking-related tests are executed exclusively in a separate CI job, they are identified by `fork` in their name. -So all of them can be easily skipped by `cargo t -- --skip fork` +If `make test` passes locally, that's a good sign that CI will be green as well. [foundry-book]: https://book.getfoundry.sh [cargo-workspace]: https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 32b922d49dfeb..d0b9640605550 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -6,6 +6,7 @@ This document describes the high-level architecture of Foundry. Foundry's EVM tooling. This is built around [`revm`](https://github.com/bluealloy/revm) and has additional implementation of: + - [cheatcodes](./cheatcodes.md) a set of solidity calls dedicated to testing which can manipulate the environment in which the execution is run ### `config/` diff --git a/docs/dev/cheatcodes.md b/docs/dev/cheatcodes.md index 1e95bf7f266cb..0815ca66bef50 100644 --- a/docs/dev/cheatcodes.md +++ b/docs/dev/cheatcodes.md @@ -18,6 +18,7 @@ current state of the EVM. ## [Foundry inspectors](../../crates/evm/evm/src/inspectors/) The [`evm`](../../crates/evm/evm/) crate has a variety of inspectors for different use cases, such as + - coverage - tracing - debugger @@ -117,6 +118,7 @@ The `Cheatcode` derive macro also parses the `#[cheatcode(...)]` attributes on f used to specify additional properties of the JSON interface. These are all the attributes that can be specified on cheatcode functions: + - `#[cheatcode(group = )]`: The group that the cheatcode belongs to. Required. - `#[cheatcode(status = )]`: The current status of the cheatcode. E.g. whether it is stable or experimental, etc. Defaults to `Stable`. - `#[cheatcode(safety = )]`: Whether the cheatcode is safe to use inside of scripts. E.g. it does not change state in an unexpected way. Defaults to the group's safety if unspecified. If the group is ambiguous, then it must be specified manually. @@ -127,6 +129,7 @@ Multiple attributes can be specified by separating them with commas, e.g. `#[che This trait defines the interface that all cheatcode implementations must implement. There are two methods that can be implemented: + - `apply`: implemented when the cheatcode is pure and does not need to access EVM data - `apply_stateful`: implemented when the cheatcode needs to access EVM data - `apply_full`: implemented when the cheatcode needs to access EVM data and the EVM executor itself, for example to recursively call back into the EVM to execute an arbitrary transaction diff --git a/docs/dev/debugging.md b/docs/dev/debugging.md index df8664440dc40..f72b8f4bfbae3 100644 --- a/docs/dev/debugging.md +++ b/docs/dev/debugging.md @@ -1,8 +1,8 @@ -## Debugging Foundry tools +# Debugging This is a working document intended to outline some commands contributors can use to debug various parts of Foundry. -### Logs +## Logs All crates use [tracing](https://docs.rs/tracing/latest/tracing/) for logging. A console formatter is installed in each binary (`cast`, `forge`, `anvil`). @@ -10,15 +10,12 @@ By setting `RUST_LOG=` you can get a lot more info out of Forge and Cast The most basic valid filter is a log level, of which these are valid: -- `error` -- `warn` -- `info` -- `debug` -- `trace` +- `error` +- `warn` +- `info` +- `debug` +- `trace` Filters are explained in detail in the [`env_logger` crate docs](https://docs.rs/env_logger). -### Compiler input and output - -You can get the compiler input JSON and output JSON by passing the `--build-info` flag. -This will create two files: one for the input and one for the output. +You can also use the `dbg!` macro from Rust's standard library. diff --git a/docs/dev/scripting.md b/docs/dev/scripting.md index 8e5fc03ca1b2a..cdface73a28e5 100644 --- a/docs/dev/scripting.md +++ b/docs/dev/scripting.md @@ -1,10 +1,10 @@ +# Scripting -# Scripting - Flow Diagrams - -1. [High level overview](#high-level-overview) - 1. [Notes](#notes) -2. [Script Execution](#script-execution) -3. [Nonce Management](#nonce-management) +- [Scripting](#scripting) + - [High level overview](#high-level-overview) + - [Notes](#notes) + - [Script Execution](#script-execution) + - [Nonce Management](#nonce-management) ## High level overview @@ -48,19 +48,20 @@ graph TD; ``` ### Notes -1) `[..]` - concurrently executed -2) The bit below does not actually influence the state initially defined by `--broadcast`. It only happens because there might be private keys declared inside the script that need to be collected again. `--resume` only resumes **publishing** the transactions, nothing more! +1. `[..]` - concurrently executed + +2. The bit below does not actually influence the state initially defined by `--broadcast`. It only happens because there might be private keys declared inside the script that need to be collected again. `--resume` only resumes **publishing** the transactions, nothing more! ```mermaid graph TD; ScriptArgs::execute-- "(resume || verify) && !broadcast" -->ScriptArgs::resume_deployment; ``` -3) `ScriptArgs::execute` executes the script, while `ScriptArgs::onchain_simulation` only executes the broadcastable transactions collected by `ScriptArgs::execute`. - +3. `ScriptArgs::execute` executes the script, while `ScriptArgs::onchain_simulation` only executes the broadcastable transactions collected by `ScriptArgs::execute`. ## Script Execution + ```mermaid graph TD; subgraph ScriptArgs::execute @@ -85,7 +86,6 @@ Executor::call-. BroadcastableTransactions .->ScriptArgs::handle_broadcastable_t ``` - ## Nonce Management During the first execution stage on `forge script`, foundry has to adjust the nonce from the sender to make sure the execution and state are as close as possible to its on-chain representation. @@ -94,7 +94,6 @@ Making sure that `msg.sender` is our signer when calling `setUp()` and `run()` a We skip this, if the user hasn't set a sender and they're using the `Config::DEFAULT_SENDER`. - ```mermaid graph TD @@ -135,4 +134,4 @@ graph TD L-->M[cheatcode.corrected_nonce=true]; M-->continue_run; continue_run-->end_run; -``` \ No newline at end of file +``` diff --git a/testdata/default/repros/Issue3708.t.sol b/testdata/default/repros/Issue3708.t.sol index 1e9a337f195cf..53a7c461f873f 100644 --- a/testdata/default/repros/Issue3708.t.sol +++ b/testdata/default/repros/Issue3708.t.sol @@ -11,8 +11,7 @@ contract Issue3708Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); function setUp() public { - string memory RPC_URL = "https://mainnet.optimism.io"; - uint256 forkId = vm.createSelectFork(RPC_URL); + uint256 forkId = vm.createSelectFork("optimism"); bytes memory code = hex"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"; From 7e58d591545467237078b6252e65e33df29926db Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 28 Jan 2025 13:53:49 +0100 Subject: [PATCH 1897/1963] chore: remove ahash (#9769) --- Cargo.lock | 2 -- Cargo.toml | 1 - crates/evm/fuzz/Cargo.toml | 5 ++--- crates/evm/fuzz/src/strategies/state.rs | 20 ++++++++++---------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7115c912c49e..7ec302bce4b0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4000,7 +4000,6 @@ dependencies = [ name = "foundry-evm-fuzz" version = "0.3.1" dependencies = [ - "ahash", "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", @@ -4011,7 +4010,6 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "indexmap 2.7.1", "itertools 0.13.0", "parking_lot", "proptest", diff --git a/Cargo.toml b/Cargo.toml index e4e124d7c8caa..168c2fbebd6b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -249,7 +249,6 @@ auto_impl = "1" bytes = "1.8" walkdir = "2" prettyplease = "0.2" -ahash = "0.8" base64 = "0.22" chrono = { version = "0.4", default-features = false, features = [ "clock", diff --git a/crates/evm/fuzz/Cargo.toml b/crates/evm/fuzz/Cargo.toml index 124514b561fe3..452eb49790f9e 100644 --- a/crates/evm/fuzz/Cargo.toml +++ b/crates/evm/fuzz/Cargo.toml @@ -28,6 +28,7 @@ alloy-primitives = { workspace = true, features = [ "getrandom", "arbitrary", "rlp", + "map-indexmap", ] } revm = { workspace = true, features = [ "std", @@ -39,7 +40,7 @@ revm = { workspace = true, features = [ "arbitrary", ] } -eyre .workspace = true +eyre.workspace = true itertools.workspace = true parking_lot.workspace = true proptest.workspace = true @@ -47,5 +48,3 @@ rand.workspace = true serde.workspace = true thiserror.workspace = true tracing.workspace = true -indexmap.workspace = true -ahash.workspace = true diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index b1c5d8e004243..9bcca6aa16d2e 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -1,10 +1,12 @@ use crate::invariant::{BasicTxDetails, FuzzRunIdentifiedContracts}; use alloy_dyn_abi::{DynSolType, DynSolValue, EventExt, FunctionExt}; use alloy_json_abi::{Function, JsonAbi}; -use alloy_primitives::{map::HashMap, Address, Bytes, Log, B256, U256}; +use alloy_primitives::{ + map::{AddressIndexSet, B256IndexSet, HashMap}, + Address, Bytes, Log, B256, U256, +}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; -use indexmap::IndexSet; use parking_lot::{lock_api::RwLockReadGuard, RawRwLock, RwLock}; use revm::{ db::{CacheDB, DatabaseRef, DbAccount}, @@ -13,8 +15,6 @@ use revm::{ }; use std::{collections::BTreeMap, fmt, sync::Arc}; -type AIndexSet = IndexSet>; - /// The maximum number of bytes we will look at in bytecodes to find push bytes (24 KiB). /// /// This is to limit the performance impact of fuzz tests that might deploy arbitrarily sized @@ -98,9 +98,9 @@ impl EvmFuzzState { #[derive(Default)] pub struct FuzzDictionary { /// Collected state values. - state_values: AIndexSet, + state_values: B256IndexSet, /// Addresses that already had their PUSH bytes collected. - addresses: AIndexSet
      , + addresses: AddressIndexSet, /// Configuration for the dictionary. config: FuzzDictionaryConfig, /// Number of state values initially collected from db. @@ -110,7 +110,7 @@ pub struct FuzzDictionary { /// Used to revert new collected addresses at the end of each run. db_addresses: usize, /// Sample typed values that are collected from call result and used across invariant runs. - sample_values: HashMap>, + sample_values: HashMap, misses: usize, hits: usize, @@ -345,7 +345,7 @@ impl FuzzDictionary { } } - pub fn values(&self) -> &AIndexSet { + pub fn values(&self) -> &B256IndexSet { &self.state_values } @@ -358,12 +358,12 @@ impl FuzzDictionary { } #[inline] - pub fn samples(&self, param_type: &DynSolType) -> Option<&AIndexSet> { + pub fn samples(&self, param_type: &DynSolType) -> Option<&B256IndexSet> { self.sample_values.get(param_type) } #[inline] - pub fn addresses(&self) -> &AIndexSet
      { + pub fn addresses(&self) -> &AddressIndexSet { &self.addresses } From 2509ce26e12979cfa694b1ea820a405479ce7998 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:52:17 +0100 Subject: [PATCH 1898/1963] chore(deps): breaking bumps (#9773) --- Cargo.lock | 133 +++++++++++++++++++-------------------- Cargo.toml | 7 ++- crates/chisel/Cargo.toml | 2 +- crates/config/Cargo.toml | 2 +- crates/config/src/fix.rs | 4 +- crates/config/src/lib.rs | 4 +- crates/forge/Cargo.toml | 2 +- 7 files changed, 77 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ec302bce4b0f..1251cc01e3172 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -993,7 +993,7 @@ dependencies = [ "foundry-test-utils", "futures", "hyper 1.5.2", - "itertools 0.13.0", + "itertools 0.14.0", "k256", "maili-consensus", "op-alloy-rpc-types", @@ -1008,7 +1008,7 @@ dependencies = [ "thiserror 2.0.11", "tikv-jemallocator", "tokio", - "tower 0.4.13", + "tower 0.5.2", "tracing", "tracing-subscriber", "yansi", @@ -2042,7 +2042,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.13.0", + "itertools 0.14.0", "rand", "rayon", "regex", @@ -2081,12 +2081,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - [[package]] name = "cfg_aliases" version = "0.2.1" @@ -2101,7 +2095,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "clap", - "dirs 5.0.1", + "dirs 6.0.0", "eyre", "forge-fmt", "foundry-cli", @@ -2243,15 +2237,15 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "clearscreen" -version = "3.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f8c93eb5f77c9050c7750e14f13ef1033a40a0aac70c6371535b6763a01438c" +checksum = "8c41dc435a7b98e4608224bbf65282309f5403719df9113621b30f8b6f74e2f4" dependencies = [ - "nix 0.28.0", + "nix 0.29.0", "terminfo", - "thiserror 1.0.69", + "thiserror 2.0.11", "which", - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -2823,20 +2817,20 @@ dependencies = [ [[package]] name = "dirs" -version = "4.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "dirs-sys 0.3.7", + "dirs-sys 0.4.1", ] [[package]] name = "dirs" -version = "5.0.1" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" dependencies = [ - "dirs-sys 0.4.1", + "dirs-sys 0.5.0", ] [[package]] @@ -2851,25 +2845,26 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", - "redox_users", - "winapi", + "option-ext", + "redox_users 0.4.6", + "windows-sys 0.48.0", ] [[package]] name = "dirs-sys" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" dependencies = [ "libc", "option-ext", - "redox_users", - "windows-sys 0.48.0", + "redox_users 0.5.0", + "windows-sys 0.59.0", ] [[package]] @@ -2879,7 +2874,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", - "redox_users", + "redox_users 0.4.6", "winapi", ] @@ -3056,6 +3051,12 @@ dependencies = [ "regex", ] +[[package]] +name = "env_home" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" + [[package]] name = "env_logger" version = "0.11.6" @@ -3355,7 +3356,7 @@ dependencies = [ "hyper 1.5.2", "indicatif", "inferno", - "itertools 0.13.0", + "itertools 0.14.0", "mockall", "opener", "parking_lot", @@ -3403,7 +3404,7 @@ dependencies = [ "foundry-common", "foundry-compilers", "foundry-config", - "itertools 0.13.0", + "itertools 0.14.0", "mdbook", "rayon", "regex", @@ -3422,7 +3423,7 @@ dependencies = [ "alloy-primitives", "ariadne", "foundry-config", - "itertools 0.13.0", + "itertools 0.14.0", "similar-asserts", "solang-parser", "thiserror 2.0.11", @@ -3464,7 +3465,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.13.0", + "itertools 0.14.0", "parking_lot", "revm-inspectors", "semver 1.0.25", @@ -3531,7 +3532,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "itertools 0.13.0", + "itertools 0.14.0", "regex", "reqwest", "revm-primitives", @@ -3599,7 +3600,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-traces", "foundry-wallets", - "itertools 0.13.0", + "itertools 0.14.0", "jsonpath_lib", "k256", "memchr", @@ -3654,7 +3655,7 @@ dependencies = [ "foundry-wallets", "futures", "indicatif", - "itertools 0.13.0", + "itertools 0.14.0", "rayon", "regex", "serde", @@ -3705,7 +3706,7 @@ dependencies = [ "foundry-compilers", "foundry-config", "foundry-macros", - "itertools 0.13.0", + "itertools 0.14.0", "num-format", "reqwest", "semver 1.0.25", @@ -3715,7 +3716,7 @@ dependencies = [ "terminal_size", "thiserror 2.0.11", "tokio", - "tower 0.4.13", + "tower 0.5.2", "tracing", "url", "vergen", @@ -3858,7 +3859,7 @@ dependencies = [ "Inflector", "alloy-chains", "alloy-primitives", - "dirs-next", + "dirs 6.0.0", "dunce", "eyre", "figment", @@ -3866,7 +3867,7 @@ dependencies = [ "foundry-compilers", "glob", "globset", - "itertools 0.13.0", + "itertools 0.14.0", "mesc", "number_prefix", "path-slash", @@ -3943,7 +3944,7 @@ dependencies = [ "foundry-common-fmt", "foundry-macros", "foundry-test-utils", - "itertools 0.13.0", + "itertools 0.14.0", ] [[package]] @@ -3969,7 +3970,7 @@ dependencies = [ "foundry-fork-db", "foundry-test-utils", "futures", - "itertools 0.13.0", + "itertools 0.14.0", "parking_lot", "revm", "revm-inspectors", @@ -4010,7 +4011,7 @@ dependencies = [ "foundry-evm-core", "foundry-evm-coverage", "foundry-evm-traces", - "itertools 0.13.0", + "itertools 0.14.0", "parking_lot", "proptest", "rand", @@ -4036,7 +4037,7 @@ dependencies = [ "foundry-evm-core", "foundry-linking", "futures", - "itertools 0.13.0", + "itertools 0.14.0", "rayon", "revm", "revm-inspectors", @@ -5997,18 +5998,6 @@ dependencies = [ "pin-utils", ] -[[package]] -name = "nix" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" -dependencies = [ - "bitflags 2.8.0", - "cfg-if", - "cfg_aliases 0.1.1", - "libc", -] - [[package]] name = "nix" version = "0.29.0" @@ -6017,7 +6006,7 @@ checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.8.0", "cfg-if", - "cfg_aliases 0.2.1", + "cfg_aliases", "libc", ] @@ -7107,7 +7096,7 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ - "cfg_aliases 0.2.1", + "cfg_aliases", "libc", "once_cell", "socket2", @@ -7247,6 +7236,17 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "redox_users" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" +dependencies = [ + "getrandom", + "libredox", + "thiserror 2.0.11", +] + [[package]] name = "regex" version = "1.11.1" @@ -8744,11 +8744,10 @@ dependencies = [ [[package]] name = "terminfo" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666cd3a6681775d22b200409aad3b089c5b99fb11ecdd8a204d9d62f8148498f" +checksum = "d4ea810f0692f9f51b382fff5893887bb4580f5fa246fde546e0b13e7fcee662" dependencies = [ - "dirs 4.0.0", "fnv", "nom", "phf", @@ -9151,9 +9150,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.5.2" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" dependencies = [ "bitflags 2.8.0", "bytes", @@ -9799,12 +9798,12 @@ dependencies = [ [[package]] name = "which" -version = "6.0.3" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" +checksum = "fb4a9e33648339dc1642b0e36e21b3385e6148e289226f657c809dee59df5028" dependencies = [ "either", - "home", + "env_home", "rustix", "winsafe", ] diff --git a/Cargo.toml b/Cargo.toml index 168c2fbebd6b0..293a71be5c543 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -257,6 +257,7 @@ chrono = { version = "0.4", default-features = false, features = [ axum = "0.7" color-eyre = "0.6" comfy-table = "7" +dirs = "6" dunce = "1" evm-disassembler = "0.5" evmole = "0.6" @@ -265,7 +266,7 @@ figment = "0.10" futures = "0.3" hyper = "1.5" indexmap = "2.6" -itertools = "0.13" +itertools = "0.14" jsonpath_lib = "0.3" k256 = "0.13" mesc = "0.3" @@ -286,8 +287,8 @@ tempfile = "3.13" tikv-jemallocator = "0.6" tokio = "1" toml = "0.8" -tower = "0.4" -tower-http = "0.5" +tower = "0.5" +tower-http = "0.6" tracing = "0.1" tracing-subscriber = "0.3" url = "2" diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index ca025a05ad829..e25e73be79dcb 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -39,7 +39,7 @@ alloy-primitives = { workspace = true, features = [ alloy-json-abi.workspace = true clap = { version = "4", features = ["derive", "env", "wrap_help"] } -dirs = "5" +dirs.workspace = true eyre.workspace = true regex.workspace = true reqwest.workspace = true diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index c7efcaec979a8..e0e52162cab13 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -23,7 +23,7 @@ revm-primitives.workspace = true solar-parse.workspace = true -dirs-next = "2" +dirs.workspace = true dunce.workspace = true eyre.workspace = true figment = { workspace = true, features = ["toml", "env"] } diff --git a/crates/config/src/fix.rs b/crates/config/src/fix.rs index f3ec1271feafb..8181339a2d3e6 100644 --- a/crates/config/src/fix.rs +++ b/crates/config/src/fix.rs @@ -230,7 +230,7 @@ mod tests { fn $name() { Jail::expect_with(|jail| { // setup home directory, - // **Note** this only has an effect on unix, as [`dirs_next::home_dir()`] on windows uses `FOLDERID_Profile` + // **Note** this only has an effect on unix, as [`dirs::home_dir()`] on windows uses `FOLDERID_Profile` jail.set_env("HOME", jail.directory().display().to_string()); std::fs::create_dir(jail.directory().join(".foundry")).unwrap(); @@ -302,7 +302,7 @@ mod tests { Ok(()) }); - // mocking the `$HOME` has no effect on windows, see [`dirs_next::home_dir()`] + // mocking the `$HOME` has no effect on windows, see [`dirs::home_dir()`] fix_test!( #[cfg(not(windows))] test_global_toml_is_edited, diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 024617a3a7b89..891fd163b0194 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1838,7 +1838,7 @@ impl Config { /// Returns the path to foundry's config dir: `~/.foundry/`. pub fn foundry_dir() -> Option { - dirs_next::home_dir().map(|p| p.join(Self::FOUNDRY_DIR_NAME)) + dirs::home_dir().map(|p| p.join(Self::FOUNDRY_DIR_NAME)) } /// Returns the path to foundry's cache dir: `~/.foundry/cache`. @@ -1891,7 +1891,7 @@ impl Config { /// | macOS | `$HOME`/Library/Application Support/foundry | /Users/Alice/Library/Application Support/foundry | /// | Windows | `{FOLDERID_RoamingAppData}/foundry` | C:\Users\Alice\AppData\Roaming/foundry | pub fn data_dir() -> eyre::Result { - let path = dirs_next::data_dir().wrap_err("Failed to find data directory")?.join("foundry"); + let path = dirs::data_dir().wrap_err("Failed to find data directory")?.join("foundry"); std::fs::create_dir_all(&path).wrap_err("Failed to create module directory")?; Ok(path) } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 342f710369764..fc6455f0f0678 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -89,7 +89,7 @@ toml_edit = "0.22" watchexec = "5.0" watchexec-events = "4.0" watchexec-signals = "4.0" -clearscreen = "3.0" +clearscreen = "4.0" evm-disassembler.workspace = true # doc server From f3548cb4d06b5eec81f2482e9fc3c16e58f7efe5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:17:48 +0200 Subject: [PATCH 1899/1963] chore: install deps and create foundry user in cross built image (#9775) --- Dockerfile.cross | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile.cross b/Dockerfile.cross index 0ee87e33bf808..ddd17218dc9f0 100644 --- a/Dockerfile.cross +++ b/Dockerfile.cross @@ -1,13 +1,17 @@ # This image is meant to enable cross-architecture builds. # It assumes the foundry binaries have already been compiled for `$TARGETPLATFORM` and are # locatable in `./dist/bin/$TARGETARCH` -FROM ubuntu:22.04 +FROM alpine:3.20 # Filled by docker buildx ARG TARGETARCH +RUN apk add --no-cache git + COPY ./dist/bin/$TARGETARCH/* /usr/local/bin/ +RUN adduser -Du 1000 foundry + ENTRYPOINT ["/bin/sh", "-c"] LABEL org.label-schema.build-date=$BUILD_DATE \ From c9b16c089636ca22c3ef9e2711c37d66e39ad941 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:56:58 +0200 Subject: [PATCH 1900/1963] chore: fix isolate tests (#9776) --- crates/forge/tests/cli/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 3941d3f6f804d..cd33ce79303e6 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -963,6 +963,7 @@ contract CounterTest { cmd.forge_fuse().args(["build"]).assert_success(); }); +#[cfg(not(feature = "isolate-by-default"))] forgetest_init!(test_default_config, |prj, cmd| { cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" [profile.default] From 9d7c40e42257d0a5dd408e6d847c9921b1989354 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:16:16 +0100 Subject: [PATCH 1901/1963] fix: correctly set `gas_limit` reported by Anvil (#9774) fix gas_limit reported by anvil --- crates/anvil/src/config.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 21c7a4a87c833..2286e37dec5b5 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -1173,6 +1173,8 @@ latest block number: {latest_block}" }; let gas_limit = self.fork_gas_limit(&block); + self.gas_limit = Some(gas_limit); + env.block = BlockEnv { number: U256::from(fork_block_number), timestamp: U256::from(block.header.timestamp), From ca4740e0c56754809b70bf85110a2cac27ca47c5 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 29 Jan 2025 11:47:58 +0200 Subject: [PATCH 1902/1963] fix(docker): revert to use ubuntu:22.04 as base image (#9777) fix: use ubuntu:22.04 --- Dockerfile.cross | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile.cross b/Dockerfile.cross index ddd17218dc9f0..3efdde14ae7c0 100644 --- a/Dockerfile.cross +++ b/Dockerfile.cross @@ -1,16 +1,19 @@ # This image is meant to enable cross-architecture builds. # It assumes the foundry binaries have already been compiled for `$TARGETPLATFORM` and are # locatable in `./dist/bin/$TARGETARCH` -FROM alpine:3.20 +FROM ubuntu:22.04 # Filled by docker buildx ARG TARGETARCH -RUN apk add --no-cache git +RUN apt update && apt install -y git COPY ./dist/bin/$TARGETARCH/* /usr/local/bin/ -RUN adduser -Du 1000 foundry +RUN groupadd -g 1000 foundry && \ + useradd -m -u 1000 -g foundry foundry + +USER foundry ENTRYPOINT ["/bin/sh", "-c"] From ed63f34d53d0fa87122fc813caa5881a7a93cb67 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:10:16 +0200 Subject: [PATCH 1903/1963] fix(cheatcode): support new 7702 spec (#9779) fix(cheatcode): update revm with support for updated 7702 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1251cc01e3172..e5c3706f53e9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7352,9 +7352,9 @@ dependencies = [ [[package]] name = "revm" -version = "19.3.0" +version = "19.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5a57589c308880c0f89ebf68d92aeef0d51e1ed88867474f895f6fd0f25c64" +checksum = "1538aea4d103a8044820eede9b1254e1b5a2a2abaf3f9a67bef19f8865cf1826" dependencies = [ "auto_impl", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 293a71be5c543..60155fd7a93f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -177,7 +177,7 @@ solang-parser = "=0.3.3" solar-parse = { version = "=0.1.1", default-features = false } ## revm -revm = { version = "19.0.0", default-features = false } +revm = { version = "19.4.0", default-features = false } revm-primitives = { version = "15.1.0", default-features = false } revm-inspectors = { version = "0.14.1", features = ["serde"] } From 9f11e6df38f6b38173eba0cc1134ea14413a6ce8 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Wed, 29 Jan 2025 13:16:33 +0100 Subject: [PATCH 1904/1963] fix: avoid returning None for library addresses during fuzzing (#9771) * avoid returning None for library addresses during fuzzing * cargo fmt * randomize address if it belongs to a deployed lib * return early in happy path --- crates/evm/evm/src/executors/invariant/mod.rs | 6 +++++ crates/evm/fuzz/src/strategies/param.rs | 25 ++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/crates/evm/evm/src/executors/invariant/mod.rs b/crates/evm/evm/src/executors/invariant/mod.rs index 42c426aa55b1f..3837e2b841139 100644 --- a/crates/evm/evm/src/executors/invariant/mod.rs +++ b/crates/evm/evm/src/executors/invariant/mod.rs @@ -401,6 +401,12 @@ impl<'a> InvariantExecutor<'a> { current_run.executor.commit(&mut call_result); // Collect data for fuzzing from the state changeset. + // This step updates the state dictionary and therefore invalidates the + // ValueTree in use by the current run. This manifestsitself in proptest + // observing a different input case than what it was called with, and creates + // inconsistencies whenever proptest tries to use the input case after test + // execution. + // See . let mut state_changeset = call_result.state_changeset.clone(); if !call_result.reverted { collect_data( diff --git a/crates/evm/fuzz/src/strategies/param.rs b/crates/evm/fuzz/src/strategies/param.rs index 643c70bde3d47..43dcdae7b00f3 100644 --- a/crates/evm/fuzz/src/strategies/param.rs +++ b/crates/evm/fuzz/src/strategies/param.rs @@ -2,6 +2,7 @@ use super::state::EvmFuzzState; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::{Address, B256, I256, U256}; use proptest::prelude::*; +use rand::{rngs::StdRng, SeedableRng}; /// The max length of arrays we fuzz for is 256. const MAX_ARRAY_LEN: usize = 256; @@ -132,14 +133,26 @@ pub fn fuzz_param_from_state( DynSolType::Address => { let deployed_libs = state.deployed_libs.clone(); value() - .prop_filter_map("filter address fuzzed from state", move |value| { - let fuzzed_addr = Address::from_word(value); - // Do not use addresses of deployed libraries as fuzz input. - // See . + .prop_map(move |value| { + let mut fuzzed_addr = Address::from_word(value); if !deployed_libs.contains(&fuzzed_addr) { - Some(DynSolValue::Address(fuzzed_addr)) + DynSolValue::Address(fuzzed_addr) } else { - None + let mut rng = StdRng::seed_from_u64(0x1337); // use deterministic rng + + // Do not use addresses of deployed libraries as fuzz input, instead return + // a deterministically random address. We cannot filter out this value (via + // `prop_filter_map`) as proptest can invoke this closure after test + // execution, and returning a `None` will cause it to panic. + // See and . + loop { + fuzzed_addr.randomize_with(&mut rng); + if !deployed_libs.contains(&fuzzed_addr) { + break; + } + } + + DynSolValue::Address(fuzzed_addr) } }) .boxed() From 19042161488401c2f42c2a1923c438eefe63b1d8 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 30 Jan 2025 14:05:49 +0200 Subject: [PATCH 1905/1963] chore: fix clippy (#9790) --- crates/anvil/tests/it/anvil_api.rs | 2 +- crates/anvil/tests/it/transaction.rs | 3 +-- crates/common/fmt/src/ui.rs | 2 +- crates/fmt/src/buffer.rs | 2 +- crates/forge/src/coverage.rs | 2 +- crates/wallets/src/multi_wallet.rs | 7 +++++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 9eb44c69b5297..6abc4a3a2d91b 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -284,7 +284,7 @@ async fn can_mine_manually() { let start_num = provider.get_block_number().await.unwrap(); - for (idx, _) in std::iter::repeat(()).take(10).enumerate() { + for (idx, _) in std::iter::repeat_n((), 10).enumerate() { api.evm_mine(None).await.unwrap(); let num = provider.get_block_number().await.unwrap(); assert_eq!(num, start_num + idx as u64 + 1); diff --git a/crates/anvil/tests/it/transaction.rs b/crates/anvil/tests/it/transaction.rs index 0afce986b5e88..6aaada01048d9 100644 --- a/crates/anvil/tests/it/transaction.rs +++ b/crates/anvil/tests/it/transaction.rs @@ -897,8 +897,7 @@ async fn can_stream_pending_transactions() { TransactionRequest::default().from(accounts[0]).to(accounts[0]).value(U256::from(1e18)); let mut sending = futures::future::join_all( - std::iter::repeat(tx.clone()) - .take(num_txs) + std::iter::repeat_n(tx.clone(), num_txs) .enumerate() .map(|(nonce, tx)| tx.nonce(nonce as u64)) .map(|tx| async { diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index bd3dbbd42987c..2f29ec19808c4 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -301,7 +301,7 @@ impl UIfmt for OtherFields { let val = EthValue::from(value.clone()).pretty(); let offset = NAME_COLUMN_LEN.saturating_sub(key.len()); s.push_str(key); - s.extend(std::iter::repeat(' ').take(offset + 1)); + s.extend(std::iter::repeat_n(' ', offset + 1)); s.push_str(&val); s.push('\n'); } diff --git a/crates/fmt/src/buffer.rs b/crates/fmt/src/buffer.rs index 9226d5f6b54f7..cd92809a49650 100644 --- a/crates/fmt/src/buffer.rs +++ b/crates/fmt/src/buffer.rs @@ -88,7 +88,7 @@ impl FormatBuffer { /// Indent the buffer by delta pub fn indent(&mut self, delta: usize) { - self.indents.extend(std::iter::repeat(IndentGroup::default()).take(delta)); + self.indents.extend(std::iter::repeat_n(IndentGroup::default(), delta)); } /// Dedent the buffer by delta diff --git a/crates/forge/src/coverage.rs b/crates/forge/src/coverage.rs index 9fc29bd2b8aa8..22c1bbb0701d1 100644 --- a/crates/forge/src/coverage.rs +++ b/crates/forge/src/coverage.rs @@ -152,7 +152,7 @@ impl CoverageReporter for LcovReporter { } // Statements are not in the LCOV format. // We don't add them in order to avoid doubling line hits. - CoverageItemKind::Statement { .. } => {} + CoverageItemKind::Statement => {} } } diff --git a/crates/wallets/src/multi_wallet.rs b/crates/wallets/src/multi_wallet.rs index c593e67e3d510..19dbd978691ea 100644 --- a/crates/wallets/src/multi_wallet.rs +++ b/crates/wallets/src/multi_wallet.rs @@ -9,7 +9,7 @@ use derive_builder::Builder; use eyre::Result; use foundry_config::Config; use serde::Serialize; -use std::{iter::repeat, path::PathBuf}; +use std::path::PathBuf; /// Container for multiple wallets. #[derive(Debug, Default)] @@ -249,7 +249,10 @@ impl MultiWalletOpts { signers.extend(mnemonics); } if self.interactives > 0 { - pending.extend(repeat(PendingSigner::Interactive).take(self.interactives as usize)); + pending.extend(std::iter::repeat_n( + PendingSigner::Interactive, + self.interactives as usize, + )); } Ok(MultiWallet::new(pending, signers)) From fbfd9bc6c52946bfc79c30384dde22efb81bafd5 Mon Sep 17 00:00:00 2001 From: Jorge Silva Date: Thu, 30 Jan 2025 12:25:58 +0000 Subject: [PATCH 1906/1963] feat(anvil): implement `anvil_rollback` (#9783) * implement anvil_rollback * PR improvements --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/anvil/core/src/eth/mod.rs | 4 ++ crates/anvil/src/eth/api.rs | 31 +++++++++++++++ crates/anvil/src/eth/backend/mem/mod.rs | 50 +++++++++++++------------ crates/anvil/tests/it/anvil_api.rs | 32 ++++++++++++++++ 4 files changed, 94 insertions(+), 23 deletions(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index b1d3b85221bee..950b9fcfba864 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -777,6 +777,10 @@ pub enum EthRequest { #[cfg_attr(feature = "serde", serde(rename = "anvil_reorg",))] Reorg(ReorgOptions), + /// Rollback the chain + #[cfg_attr(feature = "serde", serde(rename = "anvil_rollback",))] + Rollback(Option), + /// Wallet #[cfg_attr(feature = "serde", serde(rename = "wallet_getCapabilities", with = "empty_params"))] WalletGetCapabilities(()), diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 23aac74529134..7f18f251c38ea 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -456,6 +456,7 @@ impl EthApi { EthRequest::Reorg(reorg_options) => { self.anvil_reorg(reorg_options).await.to_rpc_result() } + EthRequest::Rollback(depth) => self.anvil_rollback(depth).await.to_rpc_result(), EthRequest::WalletGetCapabilities(()) => self.get_capabilities().to_rpc_result(), EthRequest::WalletSendTransaction(tx) => { self.wallet_send_transaction(*tx).await.to_rpc_result() @@ -2067,6 +2068,36 @@ impl EthApi { Ok(()) } + /// Rollback the chain to a specific depth. + /// + /// e.g depth = 3 + /// A -> B -> C -> D -> E + /// A -> B + /// + /// Depth specifies the height to rollback the chain back to. Depth must not exceed the current + /// chain height, i.e. can't rollback past the genesis block. + /// + /// Handler for RPC call: `anvil_rollback` + pub async fn anvil_rollback(&self, depth: Option) -> Result<()> { + node_info!("anvil_rollback"); + let depth = depth.unwrap_or(1); + + // Check reorg depth doesn't exceed current chain height + let current_height = self.backend.best_number(); + let common_height = current_height.checked_sub(depth).ok_or(BlockchainError::RpcError( + RpcError::invalid_params(format!( + "Rollback depth must not exceed current chain height: current height {current_height}, depth {depth}" + )), + ))?; + + // Get the common ancestor block + let common_block = + self.backend.get_block(common_height).ok_or(BlockchainError::BlockNotFound)?; + + self.backend.rollback(common_block).await?; + Ok(()) + } + /// Snapshot the state of the blockchain at the current block. /// /// Handler for RPC call: `evm_snapshot` diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index f285338c17282..b7cd30b63c3d4 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2631,6 +2631,27 @@ impl Backend { tx_pairs: HashMap>>, common_block: Block, ) -> Result<(), BlockchainError> { + self.rollback(common_block).await?; + // Create the new reorged chain, filling the blocks with transactions if supplied + for i in 0..depth { + let to_be_mined = tx_pairs.get(&i).cloned().unwrap_or_else(Vec::new); + let outcome = self.do_mine_block(to_be_mined).await; + node_info!( + " Mined reorg block number {}. With {} valid txs and with invalid {} txs", + outcome.block_number, + outcome.included.len(), + outcome.invalid.len() + ); + } + + Ok(()) + } + + /// Rollback the chain to a common height. + /// + /// The state of the chain is rewound using `rewind` to the common block, including the db, + /// storage, and env. + pub async fn rollback(&self, common_block: Block) -> Result<(), BlockchainError> { // Get the database at the common block let common_state = { let mut state = self.states.write(); @@ -2661,31 +2682,14 @@ impl Backend { // Set environment back to common block let mut env = self.env.write(); - env.block = BlockEnv { - number: U256::from(common_block.header.number), - timestamp: U256::from(common_block.header.timestamp), - gas_limit: U256::from(common_block.header.gas_limit), - difficulty: common_block.header.difficulty, - prevrandao: Some(common_block.header.mix_hash), - coinbase: env.block.coinbase, - basefee: env.block.basefee, - ..env.block.clone() - }; - self.time.reset(env.block.timestamp.to::()); - } + env.block.number = U256::from(common_block.header.number); + env.block.timestamp = U256::from(common_block.header.timestamp); + env.block.gas_limit = U256::from(common_block.header.gas_limit); + env.block.difficulty = common_block.header.difficulty; + env.block.prevrandao = Some(common_block.header.mix_hash); - // Create the new reorged chain, filling the blocks with transactions if supplied - for i in 0..depth { - let to_be_mined = tx_pairs.get(&i).cloned().unwrap_or_else(Vec::new); - let outcome = self.do_mine_block(to_be_mined).await; - node_info!( - " Mined reorg block number {}. With {} valid txs and with invalid {} txs", - outcome.block_number, - outcome.included.len(), - outcome.invalid.len() - ); + self.time.reset(env.block.timestamp.to::()); } - Ok(()) } } diff --git a/crates/anvil/tests/it/anvil_api.rs b/crates/anvil/tests/it/anvil_api.rs index 6abc4a3a2d91b..af37bd64e6a37 100644 --- a/crates/anvil/tests/it/anvil_api.rs +++ b/crates/anvil/tests/it/anvil_api.rs @@ -805,6 +805,38 @@ async fn test_reorg() { assert!(res.is_err()); } +#[tokio::test(flavor = "multi_thread")] +async fn test_rollback() { + let (api, handle) = spawn(NodeConfig::test()).await; + let provider = handle.http_provider(); + + // Mine 5 blocks + for _ in 0..5 { + api.mine_one().await; + } + + // Get block 4 for later comparison + let block4 = provider.get_block(4.into(), false.into()).await.unwrap().unwrap(); + + // Rollback with None should rollback 1 block + api.anvil_rollback(None).await.unwrap(); + + // Assert we're at block 4 and the block contents are kept the same + let head = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + assert_eq!(head, block4); + + // Get block 1 for comparison + let block1 = provider.get_block(1.into(), false.into()).await.unwrap().unwrap(); + + // Rollback to block 1 + let depth = 3; // from block 4 to block 1 + api.anvil_rollback(Some(depth)).await.unwrap(); + + // Assert we're at block 1 and the block contents are kept the same + let head = provider.get_block(BlockId::latest(), false.into()).await.unwrap().unwrap(); + assert_eq!(head, block1); +} + // === wallet endpoints === // #[tokio::test(flavor = "multi_thread")] async fn can_get_wallet_capabilities() { From dbf1c2af869a50b5ada14e54dfd5ded56baa66fe Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 30 Jan 2025 14:16:55 +0100 Subject: [PATCH 1907/1963] docs(cast): clean up index docs (#9792) --- crates/cast/src/lib.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index fb5cc9f84df28..43f39e661d6c0 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -1771,10 +1771,11 @@ impl SimpleCast { Ok(hex::encode_prefixed(calldata)) } - /// Prints the slot number for the specified mapping type and input data. + /// Returns the slot number for a given mapping key and slot. /// - /// For value types `v`, slot number of `v` is `keccak256(concat(h(v), p))` where `h` is the - /// padding function for `v`'s type, and `p` is slot number of the mapping. + /// Given `mapping(k => v) m`, for a key `k` the slot number of its associated `v` is + /// `keccak256(concat(h(k), p))`, where `h` is the padding function for `k`'s type, and `p` + /// is slot number of the mapping `m`. /// /// See [the Solidity documentation](https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#mappings-and-dynamic-arrays) /// for more details. @@ -1801,12 +1802,12 @@ impl SimpleCast { /// ); /// # Ok::<_, eyre::Report>(()) /// ``` - pub fn index(from_type: &str, from_value: &str, slot_number: &str) -> Result { + pub fn index(key_type: &str, key: &str, slot_number: &str) -> Result { let mut hasher = Keccak256::new(); - let v_ty = DynSolType::parse(from_type).wrap_err("Could not parse type")?; - let v = v_ty.coerce_str(from_value).wrap_err("Could not parse value")?; - match v_ty { + let k_ty = DynSolType::parse(key_type).wrap_err("Could not parse type")?; + let k = k_ty.coerce_str(key).wrap_err("Could not parse value")?; + match k_ty { // For value types, `h` pads the value to 32 bytes in the same way as when storing the // value in memory. DynSolType::Bool | @@ -1814,16 +1815,16 @@ impl SimpleCast { DynSolType::Uint(_) | DynSolType::FixedBytes(_) | DynSolType::Address | - DynSolType::Function => hasher.update(v.as_word().unwrap()), + DynSolType::Function => hasher.update(k.as_word().unwrap()), // For strings and byte arrays, `h(k)` is just the unpadded data. - DynSolType::String | DynSolType::Bytes => hasher.update(v.as_packed_seq().unwrap()), + DynSolType::String | DynSolType::Bytes => hasher.update(k.as_packed_seq().unwrap()), DynSolType::Array(..) | DynSolType::FixedArray(..) | DynSolType::Tuple(..) | DynSolType::CustomStruct { .. } => { - eyre::bail!("Type `{v_ty}` is not supported as a mapping key") + eyre::bail!("Type `{k_ty}` is not supported as a mapping key") } } From fe92e7ef225c6380e657e49452ce931871ae56bc Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:09:01 +0100 Subject: [PATCH 1908/1963] feat: add `gas_snapshot_check` flag to config, fix `FORGE_SNAPSHOT_CHECK` behavior (#9791) * add gas_snapshot_check configuration option w/ FORGE_SNAPSHOT_CHECK, checking for bool value - not just existence * add additional test to display behaviour * improve docs * fix clippy * improve test suite, tests all combinations exhaustively * fix failing test * fix nit * small nits --- crates/config/src/lib.rs | 3 + crates/forge/bin/cmd/test/mod.rs | 17 ++- crates/forge/tests/cli/config.rs | 179 +++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 2 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 891fd163b0194..de4cefc83c5d3 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -200,6 +200,8 @@ pub struct Config { pub cache_path: PathBuf, /// where the gas snapshots are stored pub snapshots: PathBuf, + /// whether to check for differences against previously stored gas snapshots + pub gas_snapshot_check: bool, /// where the broadcast logs are stored pub broadcast: PathBuf, /// additional solc allow paths for `--allow-paths` @@ -2316,6 +2318,7 @@ impl Default for Config { cache_path: "cache".into(), broadcast: "broadcast".into(), snapshots: "snapshots".into(), + gas_snapshot_check: false, allow_paths: vec![], include_paths: vec![], force: false, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 019e44e8c3255..87ba45f1936db 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -118,6 +118,10 @@ pub struct TestArgs { #[arg(long, env = "FORGE_GAS_REPORT")] gas_report: bool, + /// Check gas snapshots against previous runs. + #[arg(long, env = "FORGE_SNAPSHOT_CHECK")] + gas_snapshot_check: Option, + /// Exit with code 0 even if a test fails. #[arg(long, env = "FORGE_ALLOW_FAILURE")] allow_failure: bool, @@ -662,9 +666,18 @@ impl TestArgs { // Write gas snapshots to disk if any were collected. if !gas_snapshots.is_empty() { - // Check for differences in gas snapshots if `FORGE_SNAPSHOT_CHECK` is set. + // By default `gas_snapshot_check` is set to `false` in the config. + // + // The user can either: + // - Set `FORGE_SNAPSHOT_CHECK=true` in the environment. + // - Pass `--gas-snapshot-check=true` as a CLI argument. + // - Set `gas_snapshot_check = true` in the config. + // + // If the user passes `--gas-snapshot-check=` then it will override the config + // and the environment variable, disabling the check if `false` is passed. + // // Exiting early with code 1 if differences are found. - if std::env::var("FORGE_SNAPSHOT_CHECK").is_ok() { + if self.gas_snapshot_check.unwrap_or(config.gas_snapshot_check) { let differences_found = gas_snapshots.clone().into_iter().fold( false, |mut found, (group, snapshots)| { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index cd33ce79303e6..d8e8810e9a682 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -40,6 +40,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { cache: true, cache_path: "test-cache".into(), snapshots: "snapshots".into(), + gas_snapshot_check: false, broadcast: "broadcast".into(), force: true, evm_version: EvmVersion::Byzantium, @@ -978,6 +979,7 @@ libraries = [] cache = true cache_path = "cache" snapshots = "snapshots" +gas_snapshot_check = false broadcast = "broadcast" allow_paths = [] include_paths = [] @@ -1132,6 +1134,7 @@ exclude = [] "cache": true, "cache_path": "cache", "snapshots": "snapshots", + "gas_snapshot_check": false, "broadcast": "broadcast", "allow_paths": [], "include_paths": [], @@ -1365,3 +1368,179 @@ optimizer_runs = 0 "#]]); }); + +forgetest_init!(test_gas_snapshot_check_config, |prj, cmd| { + // Default settings: gas_snapshot_check disabled. + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +gas_snapshot_check = false +... + +"#]]); + + prj.insert_ds_test(); + + prj.add_source( + "Flare.sol", + r#" +contract Flare { + bytes32[] public data; + + function run(uint256 n_) public { + for (uint256 i = 0; i < n_; i++) { + data.push(keccak256(abi.encodePacked(i))); + } + } +} + "#, + ) + .unwrap(); + + let test_contract = |n: u32| { + format!( + r#" +import "./test.sol"; +import "./Flare.sol"; + +interface Vm {{ + function startSnapshotGas(string memory name) external; + function stopSnapshotGas() external returns (uint256); +}} + +contract GasSnapshotCheckTest is DSTest {{ + Vm constant vm = Vm(HEVM_ADDRESS); + + Flare public flare; + + function setUp() public {{ + flare = new Flare(); + }} + + function testSnapshotGasSectionExternal() public {{ + vm.startSnapshotGas("testAssertGasExternal"); + flare.run({n}); + vm.stopSnapshotGas(); + }} +}} + "# + ) + }; + + // Assert that gas_snapshot_check is disabled by default. + prj.add_source("GasSnapshotCheckTest.sol", &test_contract(1)).unwrap(); + cmd.forge_fuse().args(["test"]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/GasSnapshotCheckTest.sol:GasSnapshotCheckTest +[PASS] testSnapshotGasSectionExternal() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +... +"#]]); + + // Enable gas_snapshot_check. + let config = Config { gas_snapshot_check: true, ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +gas_snapshot_check = true +... + +"#]]); + + // Replace the test contract with a new one that will fail the gas snapshot check. + prj.add_source("GasSnapshotCheckTest.sol", &test_contract(2)).unwrap(); + cmd.forge_fuse().args(["test"]).assert_failure().stderr_eq(str![[r#" +... +[GasSnapshotCheckTest] Failed to match snapshots: +- [testAssertGasExternal] [..] → [..] + +Error: Snapshots differ from previous run +... +"#]]); + + // Disable gas_snapshot_check, assert that running the test will pass. + let config = Config { gas_snapshot_check: false, ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["test"]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/GasSnapshotCheckTest.sol:GasSnapshotCheckTest +[PASS] testSnapshotGasSectionExternal() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +... +"#]]); + + // Re-enable gas_snapshot_check + // Assert that the new value has been stored from the previous run and re-run the test. + let config = Config { gas_snapshot_check: true, ..Default::default() }; + prj.write_config(config); + cmd.forge_fuse().args(["test"]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/GasSnapshotCheckTest.sol:GasSnapshotCheckTest +[PASS] testSnapshotGasSectionExternal() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +... +"#]]); + + // Replace the test contract with a new one that will fail the gas_snapshot_check. + prj.add_source("GasSnapshotCheckTest.sol", &test_contract(3)).unwrap(); + cmd.forge_fuse().args(["test"]).assert_failure().stderr_eq(str![[r#" +... +[GasSnapshotCheckTest] Failed to match snapshots: +- [testAssertGasExternal] [..] → [..] + +Error: Snapshots differ from previous run +... +"#]]); + + // Test that `--gas-snapshot-check=false` flag can be used to disable the gas_snapshot_check. + cmd.forge_fuse().args(["test", "--gas-snapshot-check=false"]).assert_success().stdout_eq(str![ + [r#" +... +Ran 1 test for src/GasSnapshotCheckTest.sol:GasSnapshotCheckTest +[PASS] testSnapshotGasSectionExternal() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +... +"#] + ]); + + // Disable gas_snapshot_check in the config file. + // Enable using `FORGE_SNAPSHOT_CHECK` environment variable. + // Assert that this will override the config file value. + let config = Config { gas_snapshot_check: false, ..Default::default() }; + prj.write_config(config); + prj.add_source("GasSnapshotCheckTest.sol", &test_contract(4)).unwrap(); + cmd.forge_fuse(); + cmd.env("FORGE_SNAPSHOT_CHECK", "true"); + cmd.args(["test"]).assert_failure().stderr_eq(str![[r#" +... +[GasSnapshotCheckTest] Failed to match snapshots: +- [testAssertGasExternal] [..] → [..] + +Error: Snapshots differ from previous run +... +"#]]); + + // Assert that `--gas-snapshot-check=true` flag can be used to enable the gas_snapshot_check + // even when `FORGE_SNAPSHOT_CHECK` is set to false in the environment variable. + cmd.forge_fuse(); + cmd.env("FORGE_SNAPSHOT_CHECK", "false"); + cmd.args(["test", "--gas-snapshot-check=true"]).assert_failure().stderr_eq(str![[r#" +... +[GasSnapshotCheckTest] Failed to match snapshots: +- [testAssertGasExternal] [..] → [..] + +Error: Snapshots differ from previous run +... +"#]]); + + // Finally assert that `--gas-snapshot-check=false` flag can be used to disable the + // gas_snapshot_check even when `FORGE_SNAPSHOT_CHECK` is set to true + cmd.forge_fuse(); + cmd.env("FORGE_SNAPSHOT_CHECK", "true"); + cmd.args(["test", "--gas-snapshot-check=false"]).assert_success().stdout_eq(str![[r#" +... +Ran 1 test for src/GasSnapshotCheckTest.sol:GasSnapshotCheckTest +[PASS] testSnapshotGasSectionExternal() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] +... +"#]]); +}); From abf269ea4f79307b796174e50c0233d1cd9d512f Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 31 Jan 2025 13:38:37 +0530 Subject: [PATCH 1909/1963] feat(`forge`): remove `testFail*` (#9574) * debt(`forge`): deprecate `testFail*` * fix tests using testFail* * fix * refactor: expect revert failures tests to cli * rm `testFail` from ExpectRevert.t.sol Moved to ExpectRevertFailures.t.sol in cli tests * mv ExpectCall.t.sol failure tests to ExpectCallFailures.t.sol in forge cli tests * mv ExpectEmit.t.sol `testFail` to ExpectEmitFailures.t.sol as cli test * mv MemSafety failure tests * fmt * mv DSStyleTest failling assertion to cli test * failure_assertions * failing setup test * multiple aftertInvariants * multiple setups * emit diff anonymous * Err out on `testFail * fix: test_core * fix * fix: test_logs * fix: test_fuzz * fix: repro_7481 * fix: testShouldFailRevertNotOnImmediateNextCall, mv to failure_assertions * fix + forge fmt * clippy * chore: update and document external tests (#9644) * rm `should_fail` from runner and TestFunctionKind * update, document and add additional external tests * remove newly added morpho for now * fix --------- Co-authored-by: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> * ignore solmate tests * nit * rm should_fail from run_unit_test & run_fuzz_test * fix fmt * fmt * forge fmt * fix * rm * fix tests * fix: repro_7238 * fix tests * forge fmt * fix: repro tests * bump snekmate ext test * revert snekmate bump * bump snekmate * Revert "bump snekmate" This reverts commit a9e7568c6a0fea1533ab1e128a69da16df78f3c3. * ignore ERC4626VaultTest in snekmate * remove solmate ext_test --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Co-authored-by: zerosnacks Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/evm/evm/src/executors/fuzz/mod.rs | 6 +- crates/forge/src/runner.rs | 48 +- crates/forge/tests/cli/ext_integration.rs | 90 ++-- crates/forge/tests/cli/failure_assertions.rs | 438 ++++++++++++++++++ crates/forge/tests/cli/main.rs | 1 + crates/forge/tests/cli/test_cmd.rs | 27 -- .../tests/fixtures/ExpectCallFailures.t.sol | 220 +++++++++ .../tests/fixtures/ExpectEmitFailures.t.sol | 371 +++++++++++++++ .../tests/fixtures/ExpectRevertFailures.t.sol | 317 +++++++++++++ .../tests/fixtures/MemSafetyFailures.t.sol | 383 +++++++++++++++ crates/forge/tests/it/core.rs | 203 ++++---- testdata/default/cheats/Addr.t.sol | 4 +- testdata/default/cheats/Broadcast.t.sol | 8 +- testdata/default/cheats/ExpectCall.t.sol | 125 ----- testdata/default/cheats/ExpectEmit.t.sol | 222 --------- testdata/default/cheats/ExpectRevert.t.sol | 127 +---- testdata/default/cheats/GetCode.t.sol | 4 +- testdata/default/cheats/MemSafety.t.sol | 295 ------------ testdata/default/cheats/Prank.t.sol | 12 +- .../default/cheats/RandomCheatcodes.t.sol | 6 +- testdata/default/cheats/SetNonce.t.sol | 6 +- testdata/default/cheats/Skip.t.sol | 8 +- testdata/default/core/DSStyle.t.sol | 14 - testdata/default/core/FailingSetup.t.sol | 17 - .../default/core/MultipleAfterInvariant.t.sol | 14 - testdata/default/core/MultipleSetup.t.sol | 14 - testdata/default/core/Reverting.t.sol | 11 +- testdata/default/fuzz/Fuzz.t.sol | 10 +- testdata/default/logs/DebugLogs.t.sol | 10 +- testdata/default/logs/console.sol | 22 +- testdata/default/repros/Issue7238.t.sol | 17 +- testdata/default/repros/Issue7457.t.sol | 12 - testdata/default/repros/Issue7481.t.sol | 5 +- 33 files changed, 1967 insertions(+), 1100 deletions(-) create mode 100644 crates/forge/tests/cli/failure_assertions.rs create mode 100644 crates/forge/tests/fixtures/ExpectCallFailures.t.sol create mode 100644 crates/forge/tests/fixtures/ExpectEmitFailures.t.sol create mode 100644 crates/forge/tests/fixtures/ExpectRevertFailures.t.sol create mode 100644 crates/forge/tests/fixtures/MemSafetyFailures.t.sol delete mode 100644 testdata/default/core/DSStyle.t.sol delete mode 100644 testdata/default/core/FailingSetup.t.sol delete mode 100644 testdata/default/core/MultipleAfterInvariant.t.sol delete mode 100644 testdata/default/core/MultipleSetup.t.sol diff --git a/crates/evm/evm/src/executors/fuzz/mod.rs b/crates/evm/evm/src/executors/fuzz/mod.rs index b99499cf3c5ba..889013f2d1027 100644 --- a/crates/evm/evm/src/executors/fuzz/mod.rs +++ b/crates/evm/evm/src/executors/fuzz/mod.rs @@ -84,7 +84,6 @@ impl FuzzedExecutor { fuzz_fixtures: &FuzzFixtures, deployed_libs: &[Address], address: Address, - should_fail: bool, rd: &RevertDecoder, progress: Option<&ProgressBar>, ) -> FuzzTestResult { @@ -109,7 +108,7 @@ impl FuzzedExecutor { return Err(TestCaseError::fail(TEST_TIMEOUT)); } - let fuzz_res = self.single_fuzz(address, should_fail, calldata)?; + let fuzz_res = self.single_fuzz(address, calldata)?; // If running with progress then increment current run. if let Some(progress) = progress { @@ -238,7 +237,6 @@ impl FuzzedExecutor { pub fn single_fuzz( &self, address: Address, - should_fail: bool, calldata: alloy_primitives::Bytes, ) -> Result { let mut call = self @@ -256,7 +254,7 @@ impl FuzzedExecutor { (cheats.breakpoints.clone(), cheats.deprecated.clone()) }); - let success = self.executor.is_raw_call_mut_success(address, &mut call, should_fail); + let success = self.executor.is_raw_call_mut_success(address, &mut call, false); if success { Ok(FuzzOutcome::Case(CaseOutcome { case: FuzzCase { calldata, gas: call.gas_used, stipend: call.stipend }, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 467f1acd6bc17..ba6697958ab5e 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -366,6 +366,26 @@ impl<'a> ContractRunner<'a> { let identified_contracts = has_invariants.then(|| { load_contracts(setup.traces.iter().map(|(_, t)| &t.arena), &self.mcr.known_contracts) }); + + let test_fail_instances = functions + .iter() + .filter_map(|func| { + TestFunctionKind::classify(&func.name, !func.inputs.is_empty()) + .is_any_test_fail() + .then_some(func.name.clone()) + }) + .collect::>(); + + if !test_fail_instances.is_empty() { + let instances = format!( + "Found {} instances: {}", + test_fail_instances.len(), + test_fail_instances.join(", ") + ); + let fail = TestResult::fail("`testFail*` has been removed. Consider changing to test_Revert[If|When]_Condition and expecting a revert".to_string()); + return SuiteResult::new(start.elapsed(), [(instances, fail)].into(), warnings) + } + let test_results = functions .par_iter() .map(|&func| { @@ -402,23 +422,6 @@ impl<'a> ContractRunner<'a> { .collect::>(); let duration = start.elapsed(); - let test_fail_deprecations = self - .contract - .abi - .functions() - .filter_map(|func| { - TestFunctionKind::classify(&func.name, !func.inputs.is_empty()) - .is_any_test_fail() - .then_some(func.name.clone()) - }) - .collect::>() - .join(", "); - - if !test_fail_deprecations.is_empty() { - warnings.push(format!( - "`testFail*` has been deprecated and will be removed in the next release. Consider changing to test_Revert[If|When]_Condition and expecting a revert. Found deprecated testFail* function(s): {test_fail_deprecations}.", - )); - } SuiteResult::new(duration, test_results, warnings) } } @@ -490,8 +493,8 @@ impl<'a> FunctionRunner<'a> { } match kind { - TestFunctionKind::UnitTest { should_fail } => self.run_unit_test(func, should_fail), - TestFunctionKind::FuzzTest { should_fail } => self.run_fuzz_test(func, should_fail), + TestFunctionKind::UnitTest { .. } => self.run_unit_test(func), + TestFunctionKind::FuzzTest { .. } => self.run_fuzz_test(func), TestFunctionKind::InvariantTest => { self.run_invariant_test(func, call_after_invariant, identified_contracts.unwrap()) } @@ -507,7 +510,7 @@ impl<'a> FunctionRunner<'a> { /// (therefore the unit test call will be made on modified state). /// State modifications of before test txes and unit test function call are discarded after /// test ends, similar to `eth_call`. - fn run_unit_test(mut self, func: &Function, should_fail: bool) -> TestResult { + fn run_unit_test(mut self, func: &Function) -> TestResult { // Prepare unit test execution. if self.prepare_test(func).is_err() { return self.result; @@ -535,7 +538,7 @@ impl<'a> FunctionRunner<'a> { }; let success = - self.executor.is_raw_call_mut_success(self.address, &mut raw_call_result, should_fail); + self.executor.is_raw_call_mut_success(self.address, &mut raw_call_result, false); self.result.single_result(success, reason, raw_call_result); self.result } @@ -734,7 +737,7 @@ impl<'a> FunctionRunner<'a> { /// (therefore the fuzz test will use the modified state). /// State modifications of before test txes and fuzz test are discarded after test ends, /// similar to `eth_call`. - fn run_fuzz_test(mut self, func: &Function, should_fail: bool) -> TestResult { + fn run_fuzz_test(mut self, func: &Function) -> TestResult { // Prepare fuzz test execution. if self.prepare_test(func).is_err() { return self.result; @@ -754,7 +757,6 @@ impl<'a> FunctionRunner<'a> { &self.setup.fuzz_fixtures, &self.setup.deployed_libs, self.address, - should_fail, &self.cr.mcr.revert_decoder, progress.as_ref(), ); diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 2e5e383e5bbbf..23bd0bd29a566 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -1,50 +1,44 @@ use foundry_test_utils::util::ExtTester; +// Actively maintained tests + +// #[test] fn forge_std() { - ExtTester::new("foundry-rs", "forge-std", "2b59872eee0b8088ddcade39fe8c041e17bb79c0") + ExtTester::new("foundry-rs", "forge-std", "08d6af5d6c8a9a60e308b689cd19751876d321e0") // Skip fork tests. .args(["--nmc", "Fork"]) .run(); } -#[test] -fn solmate() { - let mut tester = - ExtTester::new("transmissions11", "solmate", "c892309933b25c03d32b1b0d674df7ae292ba925"); - - if cfg!(feature = "isolate-by-default") { - tester = tester.args(["--nmc", "ReentrancyGuardTest"]); - } - - tester.run(); -} - +// #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn prb_math() { - ExtTester::new("PaulRBerg", "prb-math", "5b6279a0cf7c1b1b6a5cc96082811f7ef620cf60") + ExtTester::new("PaulRBerg", "prb-math", "b03f814a03558ed5b62f89a57bcc8d720a393f67") .install_command(&["bun", "install", "--prefer-offline"]) // Try npm if bun fails / is not installed. .install_command(&["npm", "install", "--prefer-offline"]) .run(); } +// #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] fn prb_proxy() { - ExtTester::new("PaulRBerg", "prb-proxy", "fa13cf09fbf544a2d575b45884b8e94a79a02c06") + ExtTester::new("PaulRBerg", "prb-proxy", "e45f5325d4b6003227a6c4bdaefac9453f89de2e") .install_command(&["bun", "install", "--prefer-offline"]) // Try npm if bun fails / is not installed. .install_command(&["npm", "install", "--prefer-offline"]) .run(); } +// #[test] #[cfg_attr(windows, ignore = "Windows cannot find installed programs")] -fn sablier_v2() { +fn sablier_v2_core() { let mut tester = - ExtTester::new("sablier-labs", "v2-core", "84758a40077bf3ccb1c8f7bb8d00278e672fbfef") + ExtTester::new("sablier-labs", "v2-core", "43cf7c9d968e61a5a03e9237a71a27165b125414") // Skip fork tests. .args(["--nmc", "Fork"]) // Increase the gas limit: https://github.com/sablier-labs/v2-core/issues/956 @@ -64,72 +58,55 @@ fn sablier_v2() { tester.run(); } +// #[test] fn solady() { - ExtTester::new("Vectorized", "solady", "54ea1543a229b88b44ccb6ec5ea570135811a7d9").run(); + ExtTester::new("Vectorized", "solady", "de9aee59648862bb98affd578248d1e75c7073ad").run(); } +// #[test] -#[cfg_attr(windows, ignore = "weird git fail")] +#[cfg_attr(windows, ignore = "Windows cannot find installed programs")] #[cfg(not(feature = "isolate-by-default"))] -fn geb() { - ExtTester::new("reflexer-labs", "geb", "1a59f16a377386c49f520006ed0f7fd9d128cb09") - .env("FOUNDRY_LEGACY_ASSERTIONS", "true") - .args(["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"]) +fn snekmate() { + ExtTester::new("pcaversaccio", "snekmate", "df226f4a45e86c8f8c3ff1f9fa3443d260002050") + .args(["--nmc", "ERC4626VaultTest"]) + .install_command(&["pnpm", "install", "--prefer-offline"]) + // Try npm if pnpm fails / is not installed. + .install_command(&["npm", "install", "--prefer-offline"]) .run(); } +// #[test] -fn stringutils() { - ExtTester::new("Arachnid", "solidity-stringutils", "4b2fcc43fa0426e19ce88b1f1ec16f5903a2e461") - .run(); +fn mds1_multicall3() { + ExtTester::new("mds1", "multicall", "f534fbc9f98386a217eaaf9b29d3d4f6f920d5ec").run(); } +// Legacy tests + +// #[test] -fn lootloose() { - ExtTester::new("gakonst", "lootloose", "7b639efe97836155a6a6fc626bf1018d4f8b2495") - .install_command(&["make", "install"]) - .args(["--evm-version", "paris"]) +fn solidity_stringutils() { + ExtTester::new("Arachnid", "solidity-stringutils", "4b2fcc43fa0426e19ce88b1f1ec16f5903a2e461") .run(); } +// #[test] fn lil_web3() { ExtTester::new("m1guelpf", "lil-web3", "7346bd28c2586da3b07102d5290175a276949b15").run(); } -#[test] -#[cfg_attr(windows, ignore = "Windows cannot find installed programs")] -#[cfg(not(feature = "isolate-by-default"))] -fn snekmate() { - ExtTester::new("pcaversaccio", "snekmate", "df226f4a45e86c8f8c3ff1f9fa3443d260002050") - .install_command(&["pnpm", "install", "--prefer-offline"]) - // Try npm if pnpm fails / is not installed. - .install_command(&["npm", "install", "--prefer-offline"]) - .run(); -} - +// #[test] fn makerdao_multicall() { ExtTester::new("makerdao", "multicall", "103a8a28e4e372d582d6539b30031bda4cd48e21").run(); } -#[test] -fn mds1_multicall() { - ExtTester::new("mds1", "multicall", "263ef67f29ab9e450142b42dde617ad69adbf211").run(); -} - -// Forking tests - -#[test] -fn drai() { - ExtTester::new("mds1", "drai", "f31ce4fb15bbb06c94eefea2a3a43384c75b95cf") - .args(["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"]) - .env("FOUNDRY_LEGACY_ASSERTIONS", "true") - .fork_block(13633752) - .run(); -} +// Legacy forking tests +// #[test] fn gunilev() { ExtTester::new("hexonaut", "guni-lev", "15ee8b4c2d28e553c5cd5ba9a2a274af97563bc4") @@ -137,6 +114,7 @@ fn gunilev() { .run(); } +// #[test] fn convex_shutdown_simulation() { ExtTester::new( diff --git a/crates/forge/tests/cli/failure_assertions.rs b/crates/forge/tests/cli/failure_assertions.rs new file mode 100644 index 0000000000000..611d4d0bd221b --- /dev/null +++ b/crates/forge/tests/cli/failure_assertions.rs @@ -0,0 +1,438 @@ +// Tests in which we want to assert failures. + +forgetest!(test_fail_deprecation, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source( + "DeprecationTestFail.t.sol", + r#" + import "./test.sol"; + contract DeprecationTestFail is DSTest { + function testFail_deprecated() public { + revert("deprecated"); + } + + function testFail_deprecated2() public { + revert("deprecated2"); + } + } + "#, + ) + .unwrap(); + + cmd.forge_fuse().args(["test", "--mc", "DeprecationTestFail"]).assert_failure().stdout_eq( + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: `testFail*` has been removed. Consider changing to test_Revert[If|When]_Condition and expecting a revert] Found 2 instances: testFail_deprecated, testFail_deprecated2 ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +... +"#, + ); +}); + +forgetest!(expect_revert_tests_should_fail, |prj, cmd| { + prj.insert_ds_test(); + prj.insert_vm(); + let expect_revert_failure_tests = include_str!("../fixtures/ExpectRevertFailures.t.sol"); + + prj.add_source("ExpectRevertFailures.sol", expect_revert_failure_tests).unwrap(); + + cmd.forge_fuse() + .args(["test", "--mc", "ExpectRevertFailureTest"]) + .assert_failure() + .stdout_eq( + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: next call did not revert as expected] testShouldFailExpectRevertAnyRevertDidNotRevert() ([GAS]) +[FAIL: next call did not revert as expected] testShouldFailExpectRevertDangling() ([GAS]) +[FAIL: next call did not revert as expected] testShouldFailExpectRevertDidNotRevert() ([GAS]) +[FAIL: Error != expected error: but reverts with this message != should revert with this message] testShouldFailExpectRevertErrorDoesNotMatch() ([GAS]) +[FAIL: next call did not revert as expected] testShouldFailRevertNotOnImmediateNextCall() ([GAS]) +[FAIL: revert: some message] testShouldFailexpectCheatcodeRevertForCreate() ([GAS]) +[FAIL: revert: revert] testShouldFailexpectCheatcodeRevertForExtCall() ([GAS]) +Suite result: FAILED. 0 passed; 7 failed; 0 skipped; [ELAPSED] +... +"#, + ); + + cmd.forge_fuse() + .args(["test", "--mc", "ExpectRevertWithReverterFailureTest"]) + .assert_failure() + .stdout_eq( + r#"No files changed, compilation skipped +... +[FAIL: next call did not revert as expected] testShouldFailExpectRevertsNotOnImmediateNextCall() ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +... +"#, + ); + + cmd.forge_fuse() + .args(["test", "--mc", "ExpectRevertCountFailureTest"]) + .assert_failure() + .stdout_eq( + r#"No files changed, compilation skipped +... +[FAIL: call reverted when it was expected not to revert] testShouldFailNoRevert() ([GAS]) +[FAIL: expected 0 reverts with reason: revert, but got one] testShouldFailNoRevertSpecific() ([GAS]) +[FAIL: Error != expected error: second-revert != revert] testShouldFailReverCountSpecifc() ([GAS]) +[FAIL: next call did not revert as expected] testShouldFailRevertCountAny() ([GAS]) +[FAIL: Error != expected error: wrong revert != called a function and then reverted] testShouldFailRevertCountCallsThenReverts() ([GAS]) +Suite result: FAILED. 0 passed; 5 failed; 0 skipped; [ELAPSED] +... +"#, + ); + + cmd.forge_fuse() + .args(["test", "--mc", "ExpectRevertCountWithReverterFailures"]) + .assert_failure() + .stdout_eq(r#"No files changed, compilation skipped +... +[FAIL: expected 0 reverts from address: 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f, but got one] testShouldFailNoRevertWithReverter() ([GAS]) +[FAIL: Reverter != expected reverter: 0x2e234DAe75C793f67A35089C9d99245E1C58470b != 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f] testShouldFailRevertCountWithReverter() ([GAS]) +[FAIL: Error != expected error: wrong revert != revert] testShouldFailReverterCountWithWrongData() ([GAS]) +[FAIL: Reverter != expected reverter: 0x2e234DAe75C793f67A35089C9d99245E1C58470b != 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f] testShouldFailWrongReverterCountWithData() ([GAS]) +Suite result: FAILED. 0 passed; 4 failed; 0 skipped; [ELAPSED] +... +"#); +}); + +forgetest!(expect_call_tests_should_fail, |prj, cmd| { + prj.insert_ds_test(); + prj.insert_vm(); + + let expect_call_failure_tests = include_str!("../fixtures/ExpectCallFailures.t.sol"); + + prj.add_source("ExpectCallFailures.sol", expect_call_failure_tests).unwrap(); + + cmd.forge_fuse().args(["test", "--mc", "ExpectCallFailureTest"]).assert_failure().stdout_eq( + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0xc290d6910000000000000000000000000000000000000000000000000000000000000002, value 1 to be called 1 time, but was called 0 times] testShouldFailExpectCallValue() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002 to be called 1 time, but was called 0 times] testShouldFailExpectCallWithData() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f7000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003 to be called 1 time, but was called 0 times] testShouldFailExpectCallWithMoreParameters() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001, value 0, gas 25000 to be called 1 time, but was called 0 times] testShouldFailExpectCallWithNoValueAndWrongGas() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001, value 0, minimum gas 50001 to be called 1 time, but was called 0 times] testShouldFailExpectCallWithNoValueAndWrongMinGas() ([GAS]) +[FAIL: next call did not revert as expected] testShouldFailExpectCallWithRevertDisallowed() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x3fc7c698 to be called 1 time, but was called 0 times] testShouldFailExpectInnerCall() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002 to be called 3 times, but was called 2 times] testShouldFailExpectMultipleCallsWithDataAdditive() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f7 to be called 1 time, but was called 0 times] testShouldFailExpectSelectorCall() ([GAS]) +Suite result: FAILED. 0 passed; 9 failed; 0 skipped; [ELAPSED] +... +"#, + ); + + cmd.forge_fuse() + .args(["test", "--mc", "ExpectCallCountFailureTest"]) + .assert_failure() + .stdout_eq( + r#"No files changed, compilation skipped +... +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0xc290d6910000000000000000000000000000000000000000000000000000000000000002, value 1 to be called 1 time, but was called 0 times] testShouldFailExpectCallCountValue() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001, value 0, gas 25000 to be called 2 times, but was called 0 times] testShouldFailExpectCallCountWithNoValueAndWrongGas() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001, value 0, minimum gas 50001 to be called 1 time, but was called 0 times] testShouldFailExpectCallCountWithNoValueAndWrongMinGas() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x771602f700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002 to be called 2 times, but was called 1 time] testShouldFailExpectCallCountWithWrongCount() ([GAS]) +[FAIL: expected call to 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f with data 0x3fc7c698 to be called 1 time, but was called 0 times] testShouldFailExpectCountInnerCall() ([GAS]) +Suite result: FAILED. 0 passed; 5 failed; 0 skipped; [ELAPSED] +... +"#, + ); + + cmd.forge_fuse() + .args(["test", "--mc", "ExpectCallMixedFailureTest"]) + .assert_failure() + .stdout_eq( + r#"No files changed, compilation skipped +... +[FAIL: vm.expectCall: counted expected calls can only bet set once] testShouldFailOverrideCountWithCount() ([GAS]) +[FAIL: vm.expectCall: cannot overwrite a counted expectCall with a non-counted expectCall] testShouldFailOverrideCountWithNoCount() ([GAS]) +[FAIL: vm.expectCall: counted expected calls can only bet set once] testShouldFailOverrideNoCountWithCount() ([GAS]) +Suite result: FAILED. 0 passed; 3 failed; 0 skipped; [ELAPSED] +... +"#, + ); +}); + +forgetest!(expect_emit_tests_should_fail, |prj, cmd| { + prj.insert_ds_test(); + prj.insert_vm(); + + let expect_emit_failure_tests = include_str!("../fixtures/ExpectEmitFailures.t.sol"); + + prj.add_source("ExpectEmitFailures.sol", expect_emit_failure_tests).unwrap(); + + cmd.forge_fuse().args(["test", "--mc", "ExpectEmitFailureTest"]).assert_failure().stdout_eq( + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: log != expected log] testShouldFailCanMatchConsecutiveEvents() ([GAS]) +[FAIL: log != expected log] testShouldFailDifferentIndexedParameters() ([GAS]) +[FAIL: log != expected log] testShouldFailEmitOnlyAppliesToNextCall() ([GAS]) +[FAIL: next call did not revert as expected] testShouldFailEmitWindowWithRevertDisallowed() ([GAS]) +[FAIL: log != expected log] testShouldFailEventsOnTwoCalls() ([GAS]) +[FAIL: log != expected log; counterexample: calldata=[..] args=[..]] testShouldFailExpectEmit(bool,bool,bool,bool,uint128,uint128,uint128,uint128) (runs: 0, [AVG_GAS]) +[FAIL: log != expected log] testShouldFailExpectEmitAddress() ([GAS]) +[FAIL: log != expected log] testShouldFailExpectEmitAddressWithArgs() ([GAS]) +[FAIL: log != expected log] testShouldFailExpectEmitCanMatchWithoutExactOrder() ([GAS]) +[FAIL: expected an emit, but no logs were emitted afterwards. you might have mismatched events or not enough events were emitted] testShouldFailExpectEmitDanglingNoReference() ([GAS]) +[FAIL: expected an emit, but no logs were emitted afterwards. you might have mismatched events or not enough events were emitted] testShouldFailExpectEmitDanglingWithReference() ([GAS]) +[FAIL: log != expected log; counterexample: calldata=[..] args=[..]] testShouldFailExpectEmitNested(bool,bool,bool,bool,uint128,uint128,uint128,uint128) (runs: 0, [AVG_GAS]) +[FAIL: log != expected log] testShouldFailLowLevelWithoutEmit() ([GAS]) +[FAIL: log != expected log] testShouldFailMatchRepeatedEventsOutOfOrder() ([GAS]) +[FAIL: log != expected log] testShouldFailNoEmitDirectlyOnNextCall() ([GAS]) +Suite result: FAILED. 0 passed; 15 failed; 0 skipped; [ELAPSED] +... +"#, + ); + + cmd.forge_fuse() + .args(["test", "--mc", "ExpectEmitCountFailureTest"]) + .assert_failure() + .stdout_eq( + r#"No files changed, compilation skipped +... +[FAIL: log != expected log] testShouldFailCountEmitsFromAddress() ([GAS]) +[FAIL: log != expected log] testShouldFailCountLessEmits() ([GAS]) +[FAIL: log != expected log] testShouldFailEmitSomethingElse() ([GAS]) +[FAIL: log emitted 1 times, expected 0] testShouldFailNoEmit() ([GAS]) +[FAIL: log emitted 1 times, expected 0] testShouldFailNoEmitFromAddress() ([GAS]) +Suite result: FAILED. 0 passed; 5 failed; 0 skipped; [ELAPSED] +... +"#, + ); +}); + +forgetest!(mem_safety_test_should_fail, |prj, cmd| { + prj.insert_ds_test(); + prj.insert_vm(); + + let mem_safety_failure_tests = include_str!("../fixtures/MemSafetyFailures.t.sol"); + + prj.add_source("MemSafetyFailures.sol", mem_safety_failure_tests).unwrap(); + + cmd.forge_fuse().args(["test", "--mc", "MemSafetyFailureTest"]).assert_failure().stdout_eq( + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: revert: Expected call to fail] testShouldFailExpectSafeMemoryCall() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x60 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_CALL() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x60 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_CALLCODE() ([GAS]) +[FAIL: memory write at offset 0xA0 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0xA0]; counterexample: calldata=[..] args=[..]] testShouldFailExpectSafeMemory_CALLDATACOPY(uint256) (runs: 0, [AVG_GAS]) +[FAIL: memory write at offset 0x80 of size [..] not allowed; safe range: (0x00, 0x60] U (0x80, 0xA0]] testShouldFailExpectSafeMemory_CODECOPY() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_CREATE() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_CREATE2() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x60 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_DELEGATECALL() ([GAS]) +[FAIL: memory write at offset 0xA0 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0xA0]] testShouldFailExpectSafeMemory_EXTCODECOPY() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_LOG0() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_MLOAD() ([GAS]) +[FAIL: memory write at offset 0x81 of size 0x01 not allowed; safe range: (0x00, 0x60] U (0x80, 0x81]] testShouldFailExpectSafeMemory_MSTORE8_High() ([GAS]) +[FAIL: memory write at offset 0x60 of size 0x01 not allowed; safe range: (0x00, 0x60] U (0x80, 0x81]] testShouldFailExpectSafeMemory_MSTORE8_Low() ([GAS]) +[FAIL: memory write at offset 0xA0 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0xA0]] testShouldFailExpectSafeMemory_MSTORE_High() ([GAS]) +[FAIL: memory write at offset 0x60 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0xA0]] testShouldFailExpectSafeMemory_MSTORE_Low() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_RETURN() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x60 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_RETURNDATACOPY() ([GAS]) +[FAIL: EvmError: Revert] testShouldFailExpectSafeMemory_REVERT() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_SHA3() ([GAS]) +[FAIL: memory write at offset 0x100 of size 0x60 not allowed; safe range: (0x00, 0x60] U (0x80, 0x100]] testShouldFailExpectSafeMemory_STATICCALL() ([GAS]) +[FAIL: memory write at offset 0xA0 of size 0x20 not allowed; safe range: (0x00, 0x60] U (0x80, 0xA0]] testShouldFailStopExpectSafeMemory() ([GAS]) +Suite result: FAILED. 0 passed; 21 failed; 0 skipped; [ELAPSED] +... +"#, + ); +}); + +forgetest!(ds_style_test_failing, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source( + "DSStyleTest.t.sol", + r#" + import "./test.sol"; + + contract DSStyleTest is DSTest { + function testDSTestFailingAssertions() public { + emit log_string("assertionOne"); + assertEq(uint256(1), uint256(2)); + emit log_string("assertionTwo"); + assertEq(uint256(3), uint256(4)); + emit log_string("done"); + } + } + "#, + ) + .unwrap(); + + cmd.forge_fuse().args(["test", "--mc", "DSStyleTest", "-vv"]).assert_failure().stdout_eq( + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL] testDSTestFailingAssertions() ([GAS]) +Logs: + assertionOne + Error: a == b not satisfied [uint] + Expected: 2 + Actual: 1 + assertionTwo + Error: a == b not satisfied [uint] + Expected: 4 + Actual: 3 + done + +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +... +"#, + ); +}); + +forgetest!(failing_setup, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source( + "FailingSetupTest.t.sol", + r#" +import "./test.sol"; + +contract FailingSetupTest is DSTest { + event Test(uint256 n); + + function setUp() public { + emit Test(42); + require(false, "setup failed predictably"); + } + + function testShouldBeMarkedAsFailedBecauseOfSetup() public { + emit log("setup did not fail"); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mc", "FailingSetupTest"]).assert_failure().stdout_eq(str![[ + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: revert: setup failed predictably] setUp() ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +... +"# + ]]); +}); + +forgetest!(multiple_after_invariants, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source( + "MultipleAfterInvariantsTest.t.sol", + r#" +import "./test.sol"; + +contract MultipleAfterInvariant is DSTest { + function afterInvariant() public {} + + function afterinvariant() public {} + + function testFailShouldBeMarkedAsFailedBecauseOfAfterInvariant() + public + pure + { + assert(true); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mc", "MultipleAfterInvariant"]).assert_failure().stdout_eq(str![[ + r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: multiple afterInvariant functions] afterInvariant() ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +... +"# + ]]); +}); + +forgetest!(multiple_setups, |prj, cmd| { + prj.insert_ds_test(); + + prj.add_source( + "MultipleSetupsTest.t.sol", + r#" + +import "./test.sol"; + +contract MultipleSetup is DSTest { + function setUp() public {} + + function setup() public {} + + function testFailShouldBeMarkedAsFailedBecauseOfSetup() public { + assert(true); + } +} + + "#, + ) + .unwrap(); + + cmd.forge_fuse().args(["test", "--mc", "MultipleSetup"]).assert_failure().stdout_eq(str![[ + r#"[COMPILING_FILES] with [SOLC_VERSION] +... +[FAIL: multiple setUp functions] setUp() ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +..."# + ]]); +}); + +forgetest!(emit_diff_anonymous, |prj, cmd| { + prj.insert_ds_test(); + prj.insert_vm(); + prj.add_source( + "EmitDiffAnonymousTest.t.sol", + r#" + import "./test.sol"; + import "./Vm.sol"; + + contract Target { + event AnonymousEventNonIndexed(uint256 a) anonymous; + + function emitAnonymousEventNonIndexed(uint256 a) external { + emit AnonymousEventNonIndexed(a); + } + } + + contract EmitDiffAnonymousTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Target target; + + event DifferentAnonymousEventNonIndexed(string a) anonymous; + + function setUp() public { + target = new Target(); + } + + function testShouldFailEmitDifferentEventNonIndexed() public { + vm.expectEmitAnonymous(false, false, false, false, true); + emit DifferentAnonymousEventNonIndexed("1"); + target.emitAnonymousEventNonIndexed(1); + } + } + "#, + ) + .unwrap(); + + cmd.forge_fuse().args(["test", "--mc", "EmitDiffAnonymousTest"]).assert_failure().stdout_eq( + str![[r#"[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +... +[FAIL: log != expected log] testShouldFailEmitDifferentEventNonIndexed() ([GAS]) +Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] +... +"#]], + ); +}); diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 61bf0239abc9b..cd12f45ab7143 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -16,6 +16,7 @@ mod create; mod debug; mod doc; mod eip712; +mod failure_assertions; mod geiger; mod inline_config; mod multi_script; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 36b8d514e4503..53ca49bf1016a 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2994,33 +2994,6 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) ); }); -forgetest!(test_fail_deprecation_warning, |prj, cmd| { - prj.insert_ds_test(); - - prj.add_source( - "WarnDeprecationTestFail.t.sol", - r#" - import "./test.sol"; - contract WarnDeprecationTestFail is DSTest { - function testFail_deprecated() public { - revert("deprecated"); - } - - function testFail_deprecated2() public { - revert("deprecated2"); - } - } - "#, - ) - .unwrap(); - - cmd.forge_fuse() - .args(["test", "--mc", "WarnDeprecationTestFail"]) - .assert_success() - .stderr_eq(r#"Warning: `testFail*` has been deprecated and will be removed in the next release. Consider changing to test_Revert[If|When]_Condition and expecting a revert. Found deprecated testFail* function(s): testFail_deprecated, testFail_deprecated2. -"#); -}); - #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(colored_traces, |prj, cmd| { cmd.args(["test", "--mt", "test_Increment", "--color", "always", "-vvvvv"]) diff --git a/crates/forge/tests/fixtures/ExpectCallFailures.t.sol b/crates/forge/tests/fixtures/ExpectCallFailures.t.sol new file mode 100644 index 0000000000000..a917e5de1565f --- /dev/null +++ b/crates/forge/tests/fixtures/ExpectCallFailures.t.sol @@ -0,0 +1,220 @@ +// Note Used in forge-cli tests to assert failures. +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "./test.sol"; +import "./Vm.sol"; + +contract Contract { + function numberA() public pure returns (uint256) { + return 1; + } + + function numberB() public pure returns (uint256) { + return 2; + } + + function add(uint256 a, uint256 b) public pure returns (uint256) { + return a + b; + } + + function pay(uint256 a) public payable returns (uint256) { + return a; + } +} + +contract NestedContract { + Contract private inner; + + constructor(Contract _inner) { + inner = _inner; + } + + function sum() public view returns (uint256) { + return inner.numberA() + inner.numberB(); + } + + function forwardPay() public payable returns (uint256) { + return inner.pay{gas: 50_000, value: 1}(1); + } + + function addHardGasLimit() public view returns (uint256) { + return inner.add{gas: 50_000}(1, 1); + } + + function hello() public pure returns (string memory) { + return "hi"; + } + + function sumInPlace(uint256 a, uint256 b) public view returns (uint256) { + return a + b + 42; + } +} + +contract ExpectCallFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function exposed_callTargetNTimes(Contract target, uint256 a, uint256 b, uint256 times) public pure { + for (uint256 i = 0; i < times; i++) { + target.add(a, b); + } + } + + function exposed_failExpectInnerCall(NestedContract target) public { + // this function does not call inner + target.hello(); + } + + function testShouldFailExpectMultipleCallsWithDataAdditive() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + // Not enough calls to satisfy the additive expectCall, which expects 3 calls. + this.exposed_callTargetNTimes(target, 1, 2, 2); + } + + function testShouldFailExpectCallWithData() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 1); + this.exposed_callTargetNTimes(target, 3, 3, 1); + } + + function testShouldFailExpectInnerCall() public { + Contract inner = new Contract(); + NestedContract target = new NestedContract(inner); + + vm.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector)); + + this.exposed_failExpectInnerCall(target); + } + + function testShouldFailExpectSelectorCall() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); + } + + function testShouldFailExpectCallWithMoreParameters() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 3, 3, 3)); + target.add(3, 3); + this.exposed_callTargetNTimes(target, 3, 3, 1); + } + + function testShouldFailExpectCallValue() public { + Contract target = new Contract(); + vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2)); + } + + function exposed_addHardGasLimit(NestedContract target) public { + target.addHardGasLimit(); + } + + function testShouldFailExpectCallWithNoValueAndWrongGas() public { + Contract inner = new Contract(); + NestedContract target = new NestedContract(inner); + vm.expectCall(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1)); + this.exposed_addHardGasLimit(target); + } + + function testShouldFailExpectCallWithNoValueAndWrongMinGas() public { + Contract inner = new Contract(); + NestedContract target = new NestedContract(inner); + vm.expectCallMinGas(address(inner), 0, 50_001, abi.encodeWithSelector(inner.add.selector, 1, 1)); + this.exposed_addHardGasLimit(target); + } + + /// Ensure that you cannot use expectCall with an expectRevert. + function testShouldFailExpectCallWithRevertDisallowed() public { + Contract target = new Contract(); + vm.expectRevert(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); + this.exposed_callTargetNTimes(target, 5, 5, 1); + } +} + +contract ExpectCallCountFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testShouldFailExpectCallCountWithWrongCount() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); + target.add(1, 2); + } + + function testShouldFailExpectCountInnerCall() public { + Contract inner = new Contract(); + NestedContract target = new NestedContract(inner); + + vm.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector), 1); + + // this function does not call inner + target.hello(); + } + + function exposed_pay(Contract target, uint256 value, uint256 amount) public payable { + target.pay{value: value}(amount); + } + + function testShouldFailExpectCallCountValue() public { + Contract target = new Contract(); + vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2), 1); + this.exposed_pay{value: 2}(target, 2, 2); + } + + function exposed_addHardGasLimit(NestedContract target, uint256 times) public { + for (uint256 i = 0; i < times; i++) { + target.addHardGasLimit(); + } + } + + function testShouldFailExpectCallCountWithNoValueAndWrongGas() public { + Contract inner = new Contract(); + NestedContract target = new NestedContract(inner); + vm.expectCall(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 2); + this.exposed_addHardGasLimit(target, 2); + } + + function testShouldFailExpectCallCountWithNoValueAndWrongMinGas() public { + Contract inner = new Contract(); + NestedContract target = new NestedContract(inner); + vm.expectCallMinGas(address(inner), 0, 50_001, abi.encodeWithSelector(inner.add.selector, 1, 1), 1); + this.exposed_addHardGasLimit(target, 1); + } +} + +contract ExpectCallMixedFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function exposed_callTargetNTimes(Contract target, uint256 a, uint256 b, uint256 times) public { + for (uint256 i = 0; i < times; i++) { + target.add(1, 2); + } + } + + function testShouldFailOverrideNoCountWithCount() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + // You should not be able to overwrite a expectCall that had no count with some count. + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); + this.exposed_callTargetNTimes(target, 1, 2, 2); + } + + function testShouldFailOverrideCountWithCount() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); + // You should not be able to overwrite a expectCall that had a count with some count. + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 1); + target.add(1, 2); + target.add(1, 2); + } + + function testShouldFailOverrideCountWithNoCount() public { + Contract target = new Contract(); + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); + // You should not be able to overwrite a expectCall that had a count with no count. + vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + target.add(1, 2); + target.add(1, 2); + } +} diff --git a/crates/forge/tests/fixtures/ExpectEmitFailures.t.sol b/crates/forge/tests/fixtures/ExpectEmitFailures.t.sol new file mode 100644 index 0000000000000..8d7918e364766 --- /dev/null +++ b/crates/forge/tests/fixtures/ExpectEmitFailures.t.sol @@ -0,0 +1,371 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "./test.sol"; +import "./Vm.sol"; + +contract Emitter { + uint256 public thing; + + event Something(uint256 indexed topic1, uint256 indexed topic2, uint256 indexed topic3, uint256 data); + event A(uint256 indexed topic1); + event B(uint256 indexed topic1); + event C(uint256 indexed topic1); + event D(uint256 indexed topic1); + event E(uint256 indexed topic1); + + /// This event has 0 indexed topics, but the one in our tests + /// has exactly one indexed topic. Even though both of these + /// events have the same topic 0, they are different and should + /// be non-comparable. + /// + /// Ref: issue #760 + event SomethingElse(uint256 data); + + event SomethingNonIndexed(uint256 data); + + function emitEvent(uint256 topic1, uint256 topic2, uint256 topic3, uint256 data) public { + emit Something(topic1, topic2, topic3, data); + } + + function emitNEvents(uint256 topic1, uint256 topic2, uint256 topic3, uint256 data, uint256 n) public { + for (uint256 i = 0; i < n; i++) { + emit Something(topic1, topic2, topic3, data); + } + } + + function emitMultiple( + uint256[2] memory topic1, + uint256[2] memory topic2, + uint256[2] memory topic3, + uint256[2] memory data + ) public { + emit Something(topic1[0], topic2[0], topic3[0], data[0]); + emit Something(topic1[1], topic2[1], topic3[1], data[1]); + } + + function emitAndNest() public { + emit Something(1, 2, 3, 4); + emitNested(Emitter(address(this)), 1, 2, 3, 4); + } + + function emitOutOfExactOrder() public { + emit SomethingNonIndexed(1); + emit Something(1, 2, 3, 4); + emit Something(1, 2, 3, 4); + emit Something(1, 2, 3, 4); + } + + function emitNested(Emitter inner, uint256 topic1, uint256 topic2, uint256 topic3, uint256 data) public { + inner.emitEvent(topic1, topic2, topic3, data); + } + + function getVar() public pure returns (uint256) { + return 1; + } + + /// Used to test matching of consecutive different events, + /// even if they're not emitted right after the other. + function emitWindow() public { + emit A(1); + emit B(2); + emit C(3); + emit D(4); + emit E(5); + } + + function emitNestedWindow() public { + emit A(1); + emit C(3); + emit E(5); + this.emitWindow(); + } + + // Used to test matching of consecutive different events + // split across subtree calls. + function emitSplitWindow() public { + this.emitWindow(); + this.emitWindow(); + } + + function emitWindowAndOnTest(ExpectEmitFailureTest t) public { + this.emitWindow(); + t.emitLocal(); + } + + /// Ref: issue #1214 + function doesNothing() public pure {} + + function changeThing(uint256 num) public { + thing = num; + } + + /// Ref: issue #760 + function emitSomethingElse(uint256 data) public { + emit SomethingElse(data); + } +} + +/// Emulates `Emitter` in #760 +contract LowLevelCaller { + function f() external { + address(this).call(abi.encodeWithSignature("g()")); + } + + function g() public {} +} + +contract ExpectEmitFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Emitter emitter; + + event Something(uint256 indexed topic1, uint256 indexed topic2, uint256 indexed topic3, uint256 data); + + event SomethingElse(uint256 indexed topic1); + + event A(uint256 indexed topic1); + event B(uint256 indexed topic1); + event C(uint256 indexed topic1); + event D(uint256 indexed topic1); + event E(uint256 indexed topic1); + + function setUp() public { + emitter = new Emitter(); + } + + function emitLocal() public { + emit A(1); + } + + function testShouldFailExpectEmitDanglingNoReference() public { + vm.expectEmit(false, false, false, false); + } + + function testShouldFailExpectEmitDanglingWithReference() public { + vm.expectEmit(false, false, false, false); + emit Something(1, 2, 3, 4); + } + + /// The topics that are checked are altered to be incorrect + /// compared to the reference. + function testShouldFailExpectEmit( + bool checkTopic1, + bool checkTopic2, + bool checkTopic3, + bool checkData, + uint128 topic1, + uint128 topic2, + uint128 topic3, + uint128 data + ) public { + vm.assume(checkTopic1 || checkTopic2 || checkTopic3 || checkData); + + uint256 transformedTopic1 = checkTopic1 ? uint256(topic1) + 1 : uint256(topic1); + uint256 transformedTopic2 = checkTopic2 ? uint256(topic2) + 1 : uint256(topic2); + uint256 transformedTopic3 = checkTopic3 ? uint256(topic3) + 1 : uint256(topic3); + uint256 transformedData = checkData ? uint256(data) + 1 : uint256(data); + + vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); + + emit Something(topic1, topic2, topic3, data); + emitter.emitEvent(transformedTopic1, transformedTopic2, transformedTopic3, transformedData); + } + + /// The topics that are checked are altered to be incorrect + /// compared to the reference. + function testShouldFailExpectEmitNested( + bool checkTopic1, + bool checkTopic2, + bool checkTopic3, + bool checkData, + uint128 topic1, + uint128 topic2, + uint128 topic3, + uint128 data + ) public { + vm.assume(checkTopic1 || checkTopic2 || checkTopic3 || checkData); + Emitter inner = new Emitter(); + + uint256 transformedTopic1 = checkTopic1 ? uint256(topic1) + 1 : uint256(topic1); + uint256 transformedTopic2 = checkTopic2 ? uint256(topic2) + 1 : uint256(topic2); + uint256 transformedTopic3 = checkTopic3 ? uint256(topic3) + 1 : uint256(topic3); + uint256 transformedData = checkData ? uint256(data) + 1 : uint256(data); + + vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); + + emit Something(topic1, topic2, topic3, data); + emitter.emitNested(inner, transformedTopic1, transformedTopic2, transformedTopic3, transformedData); + } + + function testShouldFailExpectEmitCanMatchWithoutExactOrder() public { + vm.expectEmit(true, true, true, true); + emit Something(1, 2, 3, 4); + // This should fail, as this event is never emitted + // in between the other two Something events. + vm.expectEmit(true, true, true, true); + emit SomethingElse(1); + vm.expectEmit(true, true, true, true); + emit Something(1, 2, 3, 4); + + emitter.emitOutOfExactOrder(); + } + + function testShouldFailExpectEmitAddress() public { + vm.expectEmit(address(0)); + emit Something(1, 2, 3, 4); + + emitter.emitEvent(1, 2, 3, 4); + } + + function testShouldFailExpectEmitAddressWithArgs() public { + vm.expectEmit(true, true, true, true, address(0)); + emit Something(1, 2, 3, 4); + + emitter.emitEvent(1, 2, 3, 4); + } + + /// Ref: issue #760 + function testShouldFailLowLevelWithoutEmit() public { + LowLevelCaller caller = new LowLevelCaller(); + + vm.expectEmit(true, true, true, true); + emit Something(1, 2, 3, 4); + + // This does not emit an event, so this test should fail + caller.f(); + } + + function testShouldFailNoEmitDirectlyOnNextCall() public { + LowLevelCaller caller = new LowLevelCaller(); + + vm.expectEmit(true, true, true, true); + emit Something(1, 2, 3, 4); + + // This call does not emit. As emit expects the next call to emit, this should fail. + caller.f(); + // This call does emit, but it is a call later than expected. + emitter.emitEvent(1, 2, 3, 4); + } + + /// Ref: issue #760 + function testShouldFailDifferentIndexedParameters() public { + vm.expectEmit(true, false, false, false); + emit SomethingElse(1); + + // This should fail since `SomethingElse` in the test + // and in the `Emitter` contract have differing + // amounts of indexed topics. + emitter.emitSomethingElse(1); + } + + /// This test should fail, as the call to `changeThing` is not a static call. + /// While we can ignore static calls, we cannot ignore normal calls. + function testShouldFailEmitOnlyAppliesToNextCall() public { + vm.expectEmit(true, true, true, true); + emit Something(1, 2, 3, 4); + // This works because it's a staticcall. + emitter.doesNothing(); + // This should make the test fail as it's a normal call. + emitter.changeThing(block.timestamp); + + emitter.emitEvent(1, 2, 3, 4); + } + + /// emitWindow() emits events A, B, C, D, E. + /// We should not be able to match [B, A, C, D, E] as B and A are flipped. + function testShouldFailCanMatchConsecutiveEvents() public { + vm.expectEmit(true, false, false, true); + emit B(2); + vm.expectEmit(true, false, false, true); + emit A(1); + vm.expectEmit(true, false, false, true); + emit C(3); + vm.expectEmit(true, false, false, true); + emit D(4); + vm.expectEmit(true, false, false, true); + emit E(5); + + emitter.emitWindow(); + } + + /// emitWindowNested() emits events A, C, E, A, B, C, D, E, the last 5 on an external call. + /// We should NOT be able to match [A, A, E, E], as while we're matching the correct amount + /// of events, they're not in the correct order. It should be [A, E, A, E]. + function testShouldFailMatchRepeatedEventsOutOfOrder() public { + vm.expectEmit(true, false, false, true); + emit A(1); + vm.expectEmit(true, false, false, true); + emit A(1); + vm.expectEmit(true, false, false, true); + emit E(5); + vm.expectEmit(true, false, false, true); + emit E(5); + + emitter.emitNestedWindow(); + } + + /// emitWindow() emits events A, B, C, D, E. + /// We should not be able to match [A, A] even if emitWindow() is called twice, + /// as expectEmit() only works for the next call. + function testShouldFailEventsOnTwoCalls() public { + vm.expectEmit(true, false, false, true); + emit A(1); + vm.expectEmit(true, false, false, true); + emit A(1); + emitter.emitWindow(); + emitter.emitWindow(); + } + + /// We should not be able to expect emits if we're expecting the function reverts, no matter + /// if the function reverts or not. + function testShouldFailEmitWindowWithRevertDisallowed() public { + vm.expectRevert(); + vm.expectEmit(true, false, false, true); + emit A(1); + emitter.emitWindow(); + } +} + +contract ExpectEmitCountFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + Emitter emitter; + + event Something(uint256 indexed topic1, uint256 indexed topic2, uint256 indexed topic3, uint256 data); + + function setUp() public { + emitter = new Emitter(); + } + + function testShouldFailNoEmit() public { + vm.expectEmit(0); + emit Something(1, 2, 3, 4); + emitter.emitEvent(1, 2, 3, 4); + } + + function testShouldFailCountLessEmits() public { + uint64 count = 2; + vm.expectEmit(count); + emit Something(1, 2, 3, 4); + emitter.emitNEvents(1, 2, 3, 4, count - 1); + } + + function testShouldFailNoEmitFromAddress() public { + vm.expectEmit(address(emitter), 0); + emit Something(1, 2, 3, 4); + emitter.emitEvent(1, 2, 3, 4); + } + + function testShouldFailCountEmitsFromAddress() public { + uint64 count = 3; + vm.expectEmit(address(emitter), count); + emit Something(1, 2, 3, 4); + emitter.emitNEvents(1, 2, 3, 4, count - 1); + } + + function testShouldFailEmitSomethingElse() public { + uint64 count = 2; + vm.expectEmit(count); + emit Something(1, 2, 3, 4); + emitter.emitSomethingElse(23214); + } +} diff --git a/crates/forge/tests/fixtures/ExpectRevertFailures.t.sol b/crates/forge/tests/fixtures/ExpectRevertFailures.t.sol new file mode 100644 index 0000000000000..4eca811f0c465 --- /dev/null +++ b/crates/forge/tests/fixtures/ExpectRevertFailures.t.sol @@ -0,0 +1,317 @@ +// Note Used in forge-cli tests to assert failures. +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "./test.sol"; +import "./Vm.sol"; + +contract Reverter { + error CustomError(); + + function revertWithMessage(string memory message) public pure { + revert(message); + } + + function doNotRevert() public pure {} + + function panic() public pure returns (uint256) { + return uint256(100) - uint256(101); + } + + function revertWithCustomError() public pure { + revert CustomError(); + } + + function nestedRevert(Reverter inner, string memory message) public pure { + inner.revertWithMessage(message); + } + + function callThenRevert(Dummy dummy, string memory message) public pure { + dummy.callMe(); + revert(message); + } + + function callThenNoRevert(Dummy dummy) public pure { + dummy.callMe(); + } + + function revertWithoutReason() public pure { + revert(); + } +} + +contract ConstructorReverter { + constructor(string memory message) { + revert(message); + } +} + +/// Used to ensure that the dummy data from `vm.expectRevert` +/// is large enough to decode big structs. +/// +/// The struct is based on issue #2454 +struct LargeDummyStruct { + address a; + uint256 b; + bool c; + address d; + address e; + string f; + address[8] g; + address h; + uint256 i; +} + +contract Dummy { + function callMe() public pure returns (string memory) { + return "thanks for calling"; + } + + function largeReturnType() public pure returns (LargeDummyStruct memory) { + revert("reverted with large return type"); + } +} + +contract ExpectRevertFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testShouldFailExpectRevertErrorDoesNotMatch() public { + Reverter reverter = new Reverter(); + vm.expectRevert("should revert with this message"); + reverter.revertWithMessage("but reverts with this message"); + } + + function testShouldFailRevertNotOnImmediateNextCall() public { + Reverter reverter = new Reverter(); + // expectRevert should only work for the next call. However, + // we do not immediately revert, so, + // we fail. + vm.expectRevert("revert"); + reverter.doNotRevert(); + reverter.revertWithMessage("revert"); + } + + function testShouldFailExpectRevertDidNotRevert() public { + Reverter reverter = new Reverter(); + vm.expectRevert("does not revert, but we think it should"); + reverter.doNotRevert(); + } + + function testShouldFailExpectRevertAnyRevertDidNotRevert() public { + Reverter reverter = new Reverter(); + vm.expectRevert(); + reverter.doNotRevert(); + } + + /// forge-config: default.allow_internal_expect_revert = true + function testShouldFailExpectRevertDangling() public { + vm.expectRevert("dangling"); + } + + function testShouldFailexpectCheatcodeRevertForExtCall() public { + Reverter reverter = new Reverter(); + vm._expectCheatcodeRevert(); + reverter.revertWithMessage("revert"); + } + + function testShouldFailexpectCheatcodeRevertForCreate() public { + vm._expectCheatcodeRevert(); + new ConstructorReverter("some message"); + } +} + +contract AContract { + BContract bContract; + CContract cContract; + + constructor(BContract _bContract, CContract _cContract) { + bContract = _bContract; + cContract = _cContract; + } + + function callAndRevert() public pure { + require(1 > 2, "Reverted by AContract"); + } + + function callAndRevertInBContract() public { + bContract.callAndRevert(); + } + + function callAndRevertInCContract() public { + cContract.callAndRevert(); + } + + function callAndRevertInCContractThroughBContract() public { + bContract.callAndRevertInCContract(); + } + + function createDContract() public { + new DContract(); + } + + function createDContractThroughBContract() public { + bContract.createDContract(); + } + + function createDContractThroughCContract() public { + cContract.createDContract(); + } + + function doNotRevert() public {} +} + +contract BContract { + CContract cContract; + + constructor(CContract _cContract) { + cContract = _cContract; + } + + function callAndRevert() public pure { + require(1 > 2, "Reverted by BContract"); + } + + function callAndRevertInCContract() public { + this.doNotRevert(); + cContract.doNotRevert(); + cContract.callAndRevert(); + } + + function createDContract() public { + this.doNotRevert(); + cContract.doNotRevert(); + new DContract(); + } + + function createDContractThroughCContract() public { + this.doNotRevert(); + cContract.doNotRevert(); + cContract.createDContract(); + } + + function doNotRevert() public {} +} + +contract CContract { + error CContractError(string reason); + + function callAndRevert() public pure { + revert CContractError("Reverted by CContract"); + } + + function createDContract() public { + new DContract(); + } + + function doNotRevert() public {} +} + +contract DContract { + constructor() { + require(1 > 2, "Reverted by DContract"); + } +} + +contract ExpectRevertWithReverterFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + error CContractError(string reason); + + AContract aContract; + BContract bContract; + CContract cContract; + + function setUp() public { + cContract = new CContract(); + bContract = new BContract(cContract); + aContract = new AContract(bContract, cContract); + } + + function testShouldFailExpectRevertsNotOnImmediateNextCall() public { + // Test expect revert with reverter fails if next call doesn't revert. + vm.expectRevert(address(aContract)); + aContract.doNotRevert(); + aContract.callAndRevert(); + } +} + +contract ExpectRevertCountFailureTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testShouldFailRevertCountAny() public { + uint64 count = 3; + Reverter reverter = new Reverter(); + vm.expectRevert(count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("revert2"); + } + + function testShouldFailNoRevert() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert(count); + reverter.revertWithMessage("revert"); + } + + function testShouldFailReverCountSpecifc() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("second-revert"); + } + + function testShouldFailNoRevertSpecific() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", count); + reverter.revertWithMessage("revert"); + } + + function testShouldFailRevertCountCallsThenReverts() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Dummy dummy = new Dummy(); + + vm.expectRevert("called a function and then reverted", count); + reverter.callThenRevert(dummy, "called a function and then reverted"); + reverter.callThenRevert(dummy, "wrong revert"); + } +} + +contract ExpectRevertCountWithReverterFailures is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testShouldFailRevertCountWithReverter() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Reverter reverter2 = new Reverter(); + vm.expectRevert(address(reverter), count); + reverter.revertWithMessage("revert"); + reverter2.revertWithMessage("revert"); + } + + function testShouldFailNoRevertWithReverter() public { + uint64 count = 0; + Reverter reverter = new Reverter(); + vm.expectRevert(address(reverter), count); + reverter.revertWithMessage("revert"); + } + + function testShouldFailReverterCountWithWrongData() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + vm.expectRevert("revert", address(reverter), count); + reverter.revertWithMessage("revert"); + reverter.revertWithMessage("wrong revert"); + } + + function testShouldFailWrongReverterCountWithData() public { + uint64 count = 2; + Reverter reverter = new Reverter(); + Reverter reverter2 = new Reverter(); + vm.expectRevert("revert", address(reverter), count); + reverter.revertWithMessage("revert"); + reverter2.revertWithMessage("revert"); + } +} diff --git a/crates/forge/tests/fixtures/MemSafetyFailures.t.sol b/crates/forge/tests/fixtures/MemSafetyFailures.t.sol new file mode 100644 index 0000000000000..e73033eec1d63 --- /dev/null +++ b/crates/forge/tests/fixtures/MemSafetyFailures.t.sol @@ -0,0 +1,383 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import "./test.sol"; +import "./Vm.sol"; + +contract MemSafetyFailureTest is DSTest { + Vm constant vm = Vm(address(HEVM_ADDRESS)); + + /// @dev Tests that writing to memory before the range given to `expectSafeMemory` + /// will cause the test to fail while using the `MSTORE` opcode. + function testShouldFailExpectSafeMemory_MSTORE_Low() public { + // Allow memory writes in the range of [0x80, 0xA0) within this context + vm.expectSafeMemory(0x80, 0xA0); + + // Attempt to write to memory outside of the range using `MSTORE` + assembly { + mstore(0x60, 0xc0ffee) + } + } + + /// @dev Tests that writing to memory after the range given to `expectSafeMemory` + /// will cause the test to fail while using the `MSTORE` opcode. + function testShouldFailExpectSafeMemory_MSTORE_High() public { + // Allow memory writes in the range of [0x80, 0xA0) within this context + vm.expectSafeMemory(0x80, 0xA0); + + // Attempt to write to memory outside of the range using `MSTORE` + assembly { + mstore(0xA0, 0xc0ffee) + } + } + + /// @dev Tests that writing to memory before the range given to `expectSafeMemory` + /// will cause the test to fail while using the `MSTORE8` opcode. + function testShouldFailExpectSafeMemory_MSTORE8_Low() public { + // Allow memory writes in the range of [0x80, 0x81) within this context + vm.expectSafeMemory(0x80, 0x81); + + // Attempt to write to memory outside of the range using `MSTORE8` + assembly { + mstore8(0x60, 0xFF) + } + } + + /// @dev Tests that writing to memory after the range given to `expectSafeMemory` + /// will cause the test to fail while using the `MSTORE8` opcode. + function testShouldFailExpectSafeMemory_MSTORE8_High() public { + // Allow memory writes in the range of [0x80, 0x81) within this context + vm.expectSafeMemory(0x80, 0x81); + + // Attempt to write to memory outside of the range using `MSTORE8` + assembly { + mstore8(0x81, 0xFF) + } + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `CALLDATACOPY` opcode. + function testShouldFailExpectSafeMemory_CALLDATACOPY(uint256 _x) public { + // Allow memory writes in the range of [0x80, 0xA0) within this context + vm.expectSafeMemory(0x80, 0xA0); + + // Write to memory outside the range using `CALLDATACOPY` + assembly { + calldatacopy(0xA0, 0x04, 0x20) + } + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `CODECOPY` opcode. + function testShouldFailExpectSafeMemory_CODECOPY() public { + // Allow memory writes in the range of [0x80, 0xA0) within this context + vm.expectSafeMemory(0x80, 0xA0); + + // Attempt to write to memory outside of the range using `CODECOPY` + assembly { + let size := extcodesize(address()) + codecopy(0x80, 0x00, size) + } + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `RETURNDATACOPY` opcode. + function testShouldFailExpectSafeMemory_RETURNDATACOPY() public { + // Create a new SubContext contract + SubContext sc = new SubContext(); + + // Create a payload to call `giveReturndata` on the SubContext contract + bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); + + // Allow memory writes in the range of [0x80, 0x100) within this context + vm.expectSafeMemory(0x80, 0x100); + + // Create a new SubContext contract and call `giveReturndata` on it. + _doCallReturnData(address(sc), payload, 0x80, 0x60); + + // Write to memory outside of the range using `RETURNDATACOPY` + assembly { + returndatacopy(0x100, 0x00, 0x60) + } + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will not cause the test to fail while using the `EXTCODECOPY` opcode. + function testShouldFailExpectSafeMemory_EXTCODECOPY() public { + // Allow memory writes in the range of [0x80, 0xA0) within this context + vm.expectSafeMemory(0x80, 0xA0); + + // Attempt to write to memory outside of the range using `EXTCODECOPY` + assembly { + let size := extcodesize(address()) + extcodecopy(address(), 0xA0, 0x00, 0x20) + } + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `CALL` opcode. + function testShouldFailExpectSafeMemory_CALL() public { + // Create a new SubContext contract + SubContext sc = new SubContext(); + + // Create a payload to call `giveReturndata` on the SubContext contract + bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); + + // Allow memory writes in the range of [0x80, 0x100) within this context + vm.expectSafeMemory(0x80, 0x100); + + // Create a new SubContext contract and call `giveReturndata` on it. + _doCallReturnData(address(sc), payload, 0x100, 0x60); + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `CALLCODE` opcode. + function testShouldFailExpectSafeMemory_CALLCODE() public { + // Create a new SubContext contract + SubContext sc = new SubContext(); + + // Create a payload to call `giveReturndata` on the SubContext contract + bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); + + // Allow memory writes in the range of [0x80, 0x100) within this context + vm.expectSafeMemory(0x80, 0x100); + + // Create a new SubContext contract and call `giveReturndata` on it. + _doCallCodeReturnData(address(sc), payload, 0x100, 0x60); + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `STATICCALL` opcode. + function testShouldFailExpectSafeMemory_STATICCALL() public { + // Create a new SubContext contract + SubContext sc = new SubContext(); + + // Create a payload to call `giveReturndata` on the SubContext contract + bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); + + // Allow memory writes in the range of [0x80, 0x100) within this context + vm.expectSafeMemory(0x80, 0x100); + + // Create a new SubContext contract and call `giveReturndata` on it. + _doStaticCallReturnData(address(sc), payload, 0x100, 0x60); + } + + /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `DELEGATECALL` opcode. + function testShouldFailExpectSafeMemory_DELEGATECALL() public { + // Create a new SubContext contract + SubContext sc = new SubContext(); + + // Create a payload to call `giveReturndata` on the SubContext contract + bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); + + // Allow memory writes in the range of [0x80, 0x100) within this context + vm.expectSafeMemory(0x80, 0x100); + + // Create a new SubContext contract and call `giveReturndata` on it. + _doDelegateCallReturnData(address(sc), payload, 0x100, 0x60); + } + + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `MLOAD` opcode. + function testShouldFailExpectSafeMemory_MLOAD() public { + vm.expectSafeMemory(0x80, 0x100); + + // This should revert. Ugly hack to make sure the mload isn't optimized + // out. + uint256 a; + assembly { + a := mload(0x100) + } + uint256 b = a + 1; + } + + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `SHA3` opcode. + function testShouldFailExpectSafeMemory_SHA3() public { + vm.expectSafeMemory(0x80, 0x100); + + // This should revert. Ugly hack to make sure the sha3 isn't optimized + // out. + uint256 a; + assembly { + a := keccak256(0x100, 0x20) + } + uint256 b = a + 1; + } + + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `LOG0` opcode. + function testShouldFailExpectSafeMemory_LOG0() public { + vm.expectSafeMemory(0x80, 0x100); + + // This should revert. + assembly { + log0(0x100, 0x20) + } + } + + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `CREATE` opcode. + function testShouldFailExpectSafeMemory_CREATE() public { + vm.expectSafeMemory(0x80, 0x100); + + // This should revert. + assembly { + pop(create(0, 0x100, 0x20)) + } + } + + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `CREATE2` opcode. + function testShouldFailExpectSafeMemory_CREATE2() public { + vm.expectSafeMemory(0x80, 0x100); + + // This should revert. + assembly { + pop(create2(0, 0x100, 0x20, 0x00)) + } + } + + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `RETURN` opcode. + function testShouldFailExpectSafeMemory_RETURN() public { + vm.expectSafeMemory(0x80, 0x100); + + // This should revert. + assembly { + return(0x100, 0x20) + } + } + + /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` + /// will cause the test to fail while using the `REVERT` opcode. + function testShouldFailExpectSafeMemory_REVERT() public { + // Create a new SubContext contract + SubContext sc = new SubContext(); + + // Create a payload to call `doRevert` on the SubContext contract + bytes memory payload = abi.encodeWithSelector(SubContext.doRevert.selector, 0x120, 0x20); + + // Expect memory in the range of [0x00, 0x120] to be safe in the next subcontext + vm.expectSafeMemoryCall(0x00, 0x120); + + // Call `doRevert` on the SubContext contract and ensure it did not revert with + // zero data. + _doCallReturnData(address(sc), payload, 0x200, 0x20); + assembly { + if iszero(eq(keccak256(0x60, 0x20), keccak256(0x200, returndatasize()))) { revert(0x00, 0x00) } + } + } + + /// @dev Tests that the `expectSafeMemoryCall` cheatcode works as expected. + function testShouldFailExpectSafeMemoryCall() public { + // Create a new SubContext contract + SubContext sc = new SubContext(); + // Create a payload to call `doMstore8` on the SubContext contract + bytes memory payload = abi.encodeWithSelector(SubContext.doMstore.selector, 0xA0, 0xc0ffee); + + // Allow memory writes in the range of [0x80, 0xA0) within the next created subcontext + vm.expectSafeMemoryCall(0x80, 0xA0); + + // Should revert. The memory write in this subcontext is outside of the allowed range. + if (!_doCall(address(sc), payload)) { + revert("Expected call to fail"); + } + } + + /// @dev Tests that the `stopExpectSafeMemory` cheatcode does not cause violations not being noticed. + function testShouldFailStopExpectSafeMemory() public { + uint64 initPtr; + assembly { + initPtr := mload(0x40) + } + + vm.expectSafeMemory(initPtr, initPtr + 0x20); + assembly { + // write outside of allowed range, this should revert + mstore(add(initPtr, 0x20), 0x01) + } + + vm.stopExpectSafeMemory(); + } + + // Helpers + + /// @dev Performs a call without copying any returndata. + function _doCall(address _target, bytes memory _payload) internal returns (bool _success) { + assembly { + _success := call(gas(), _target, 0x00, add(_payload, 0x20), mload(_payload), 0x00, 0x00) + } + } + + /// @dev Performs a call and copies returndata to memory. + function _doCallReturnData(address _target, bytes memory _payload, uint256 returnDataDest, uint256 returnDataSize) + internal + { + assembly { + pop(call(gas(), _target, 0x00, add(_payload, 0x20), mload(_payload), returnDataDest, returnDataSize)) + } + } + + /// @dev Performs a staticcall and copies returndata to memory. + function _doStaticCallReturnData( + address _target, + bytes memory _payload, + uint256 returnDataDest, + uint256 returnDataSize + ) internal { + assembly { + pop(staticcall(gas(), _target, add(_payload, 0x20), mload(_payload), returnDataDest, returnDataSize)) + } + } + + /// @dev Performs a delegatecall and copies returndata to memory. + function _doDelegateCallReturnData( + address _target, + bytes memory _payload, + uint256 returnDataDest, + uint256 returnDataSize + ) internal { + assembly { + pop(delegatecall(gas(), _target, add(_payload, 0x20), mload(_payload), returnDataDest, returnDataSize)) + } + } + + /// @dev Performs a callcode and copies returndata to memory. + function _doCallCodeReturnData( + address _target, + bytes memory _payload, + uint256 returnDataDest, + uint256 returnDataSize + ) internal { + assembly { + pop(callcode(gas(), _target, 0x00, add(_payload, 0x20), mload(_payload), returnDataDest, returnDataSize)) + } + } +} + +/// @dev A simple contract for testing the `expectSafeMemory` & `expectSafeMemoryCall` cheatcodes. +contract SubContext { + function doMstore(uint256 offset, uint256 val) external { + assembly { + mstore(offset, val) + } + } + + function doMstore8(uint256 offset, uint8 val) external { + assembly { + mstore8(offset, val) + } + } + + function giveReturndata() external view returns (bytes memory _returndata) { + return hex"7dc4acc68d77c9c85b5cb0f53ab9ceea175f7964390758e4409013ce80643f84"; + } + + function doRevert(uint256 offset, uint256 size) external { + assembly { + revert(offset, size) + } + } +} diff --git a/crates/forge/tests/it/core.rs b/crates/forge/tests/it/core.rs index 94dc945e5938b..392cb90998bcd 100644 --- a/crates/forge/tests/it/core.rs +++ b/crates/forge/tests/it/core.rs @@ -18,29 +18,9 @@ async fn test_core() { assert_multiple( &results, BTreeMap::from([ - ( - "default/core/FailingSetup.t.sol:FailingSetupTest", - vec![( - "setUp()", - false, - Some("revert: setup failed predictably".to_string()), - None, - None, - )], - ), - ( - "default/core/MultipleSetup.t.sol:MultipleSetup", - vec![( - "setUp()", - false, - Some("multiple setUp functions".to_string()), - None, - Some(1), - )], - ), ( "default/core/Reverting.t.sol:RevertingTest", - vec![("testFailRevert()", true, None, None, None)], + vec![("testRevert()", true, None, None, None)], ), ( "default/core/SetupConsistency.t.sol:SetupConsistencyCheck", @@ -49,10 +29,6 @@ async fn test_core() { ("testMultiply()", true, None, None, None), ], ), - ( - "default/core/DSStyle.t.sol:DSStyleTest", - vec![("testFailingAssertions()", true, None, None, None)], - ), ( "default/core/ContractEnvironment.t.sol:ContractEnvironmentTest", vec![ @@ -72,16 +48,6 @@ async fn test_core() { "default/core/FailingTestAfterFailedSetup.t.sol:FailingTestAfterFailedSetupTest", vec![("setUp()", false, Some("execution error".to_string()), None, None)], ), - ( - "default/core/MultipleAfterInvariant.t.sol:MultipleAfterInvariant", - vec![( - "afterInvariant()", - false, - Some("multiple afterInvariant functions".to_string()), - None, - None, - )], - ), ( "default/core/BadSigAfterInvariant.t.sol:BadSigAfterInvariant", vec![("testShouldPassWithWarning()", true, None, None, None)], @@ -153,29 +119,17 @@ async fn test_logs() { ( "default/logs/DebugLogs.t.sol:DebugLogsTest", vec![ + ("test1()", true, None, Some(vec!["0".into(), "1".into(), "2".into()]), None), + ("test2()", true, None, Some(vec!["0".into(), "1".into(), "3".into()]), None), ( - "test1()", - true, - None, - Some(vec!["0".into(), "1".into(), "2".into()]), - None, - ), - ( - "test2()", - true, - None, - Some(vec!["0".into(), "1".into(), "3".into()]), - None, - ), - ( - "testFailWithRequire()", + "testRevertIfWithRequire()", true, None, Some(vec!["0".into(), "1".into(), "5".into()]), None, ), ( - "testFailWithRevert()", + "testRevertIfWithRevert()", true, None, Some(vec!["0".into(), "1".into(), "4".into(), "100".into()]), @@ -213,7 +167,9 @@ async fn test_logs() { Some(vec![ "0".into(), "1".into(), - "0x6162636400000000000000000000000000000000000000000000000000000000".into()]), + "0x6162636400000000000000000000000000000000000000000000000000000000" + .into(), + ]), None, ), ( @@ -244,7 +200,8 @@ async fn test_logs() { Some(vec![ "0".into(), "1".into(), - "address: 0x0000000000000000000000000000000000000001".into()]), + "address: 0x0000000000000000000000000000000000000001".into(), + ]), None, ), ( @@ -252,69 +209,53 @@ async fn test_logs() { true, None, Some(vec![ - "0".into(), - "1".into(), - "abcd: 0x6162636400000000000000000000000000000000000000000000000000000000".into()]), + "0".into(), + "1".into(), + "abcd: 0x6162636400000000000000000000000000000000000000000000000000000000" + .into(), + ]), None, ), ( "testLogNamedDecimalInt()", true, None, - Some(vec![ - "0".into(), - "1".into(), - "amount: -0.000000000000031337".into()]), + Some(vec!["0".into(), "1".into(), "amount: -0.000000000000031337".into()]), None, ), ( "testLogNamedDecimalUint()", true, None, - Some(vec![ - "0".into(), - "1".into(), - "amount: 1.000000000000000000".into()]), + Some(vec!["0".into(), "1".into(), "amount: 1.000000000000000000".into()]), None, ), ( "testLogNamedInt()", true, None, - Some(vec![ - "0".into(), - "1".into(), - "amount: -31337".into()]), + Some(vec!["0".into(), "1".into(), "amount: -31337".into()]), None, ), ( "testLogNamedUint()", true, None, - Some(vec![ - "0".into(), - "1".into(), - "amount: 1000000000000000000".into()]), + Some(vec!["0".into(), "1".into(), "amount: 1000000000000000000".into()]), None, ), ( "testLogNamedBytes()", true, None, - Some(vec![ - "0".into(), - "1".into(), - "abcd: 0x61626364".into()]), + Some(vec!["0".into(), "1".into(), "abcd: 0x61626364".into()]), None, ), ( "testLogNamedString()", true, None, - Some(vec![ - "0".into(), - "1".into(), - "key: val".into()]), + Some(vec!["0".into(), "1".into(), "key: val".into()]), None, ), ], @@ -392,7 +333,10 @@ async fn test_logs() { "testLogAddress()", true, None, - Some(vec!["constructor".into(), "0x0000000000000000000000000000000000000001".into()]), + Some(vec![ + "constructor".into(), + "0x0000000000000000000000000000000000000001".into(), + ]), None, ), ( @@ -511,119 +455,172 @@ async fn test_logs() { "testLogBytes16()", true, None, - Some(vec!["constructor".into(), "0x61000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x61000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes17()", true, None, - Some(vec!["constructor".into(), "0x6100000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x6100000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes18()", true, None, - Some(vec!["constructor".into(), "0x610000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x610000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes19()", true, None, - Some(vec!["constructor".into(), "0x61000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x61000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes20()", true, None, - Some(vec!["constructor".into(), "0x6100000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x6100000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes21()", true, None, - Some(vec!["constructor".into(), "0x610000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x610000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes22()", true, None, - Some(vec!["constructor".into(), "0x61000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x61000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes23()", true, None, - Some(vec!["constructor".into(), "0x6100000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x6100000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes24()", true, None, - Some(vec!["constructor".into(), "0x610000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x610000000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes25()", true, None, - Some(vec!["constructor".into(), "0x61000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x61000000000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes26()", true, None, - Some(vec!["constructor".into(), "0x6100000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x6100000000000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes27()", true, None, - Some(vec!["constructor".into(), "0x610000000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x610000000000000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes28()", true, None, - Some(vec!["constructor".into(), "0x61000000000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x61000000000000000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes29()", true, None, - Some(vec!["constructor".into(), "0x6100000000000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x6100000000000000000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes30()", true, None, - Some(vec!["constructor".into(), "0x610000000000000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x610000000000000000000000000000000000000000000000000000000000".into(), + ]), None, ), ( "testLogBytes31()", true, None, - Some(vec!["constructor".into(), "0x61000000000000000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x61000000000000000000000000000000000000000000000000000000000000" + .into(), + ]), None, ), ( "testLogBytes32()", true, None, - Some(vec!["constructor".into(), "0x6100000000000000000000000000000000000000000000000000000000000000".into()]), + Some(vec![ + "constructor".into(), + "0x6100000000000000000000000000000000000000000000000000000000000000" + .into(), + ]), None, ), ( @@ -651,7 +648,10 @@ async fn test_logs() { "testConsoleLogAddress()", true, None, - Some(vec!["constructor".into(), "0x0000000000000000000000000000000000000001".into()]), + Some(vec![ + "constructor".into(), + "0x0000000000000000000000000000000000000001".into(), + ]), None, ), ( @@ -672,7 +672,10 @@ async fn test_logs() { "testConsoleLogFormatAddress()", true, None, - Some(vec!["constructor".into(), "formatted log addr=0x0000000000000000000000000000000000000001".into()]), + Some(vec![ + "constructor".into(), + "formatted log addr=0x0000000000000000000000000000000000000001".into(), + ]), None, ), ( diff --git a/testdata/default/cheats/Addr.t.sol b/testdata/default/cheats/Addr.t.sol index 3f791583dbb9e..b0b3fefbdba79 100644 --- a/testdata/default/cheats/Addr.t.sol +++ b/testdata/default/cheats/Addr.t.sol @@ -7,7 +7,9 @@ import "cheats/Vm.sol"; contract AddrTest is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - function testFailPrivKeyZero() public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfPkZero() public { + vm.expectRevert("vm.addr: private key cannot be 0"); vm.addr(0); } diff --git a/testdata/default/cheats/Broadcast.t.sol b/testdata/default/cheats/Broadcast.t.sol index 97b9d52752d79..6486049b03b3e 100644 --- a/testdata/default/cheats/Broadcast.t.sol +++ b/testdata/default/cheats/Broadcast.t.sol @@ -155,9 +155,11 @@ contract BroadcastTest is DSTest { vm.stopBroadcast(); } - function testFailNoBroadcast() public { - vm.stopBroadcast(); - } + /// forge-config: default.allow_internal_expect_revert = true + // function testRevertIfNoBroadcast() public { + // vm.expectRevert(); + // vm.stopBroadcast(); + // } } contract NoLink is DSTest { diff --git a/testdata/default/cheats/ExpectCall.t.sol b/testdata/default/cheats/ExpectCall.t.sol index f2624fd2e237f..01a95b4277e01 100644 --- a/testdata/default/cheats/ExpectCall.t.sol +++ b/testdata/default/cheats/ExpectCall.t.sol @@ -100,21 +100,6 @@ contract ExpectCallTest is DSTest { this.exposed_callTargetNTimes(target, 1, 2, 3); } - function testFailExpectMultipleCallsWithDataAdditive() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); - // Not enough calls to satisfy the additive expectCall, which expects 3 calls. - this.exposed_callTargetNTimes(target, 1, 2, 2); - } - - function testFailExpectCallWithData() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 1); - this.exposed_callTargetNTimes(target, 3, 3, 1); - } - function testExpectInnerCall() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); @@ -126,15 +111,6 @@ contract ExpectCallTest is DSTest { target.sum(); } - function testFailExpectInnerCall() public { - Contract inner = new Contract(); - NestedContract target = new NestedContract(inner); - - vm.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector)); - - this.exposed_failExpectInnerCall(target); - } - function exposed_failExpectInnerCall(NestedContract target) public { // this function does not call inner target.hello(); @@ -173,29 +149,12 @@ contract ExpectCallTest is DSTest { this.exposed_callTargetNTimes(target, 5, 5, 1); } - function testFailExpectSelectorCall() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); - } - - function testFailExpectCallWithMoreParameters() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 3, 3, 3)); - target.add(3, 3); - this.exposed_callTargetNTimes(target, 3, 3, 1); - } - function testExpectCallWithValue() public { Contract target = new Contract(); vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2)); this.exposed_expectCallWithValue(target, 1, 2); } - function testFailExpectCallValue() public { - Contract target = new Contract(); - vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2)); - } - function testExpectCallWithValueWithoutParameters() public { Contract target = new Contract(); vm.expectCall(address(target), 3, abi.encodeWithSelector(target.pay.selector)); @@ -224,13 +183,6 @@ contract ExpectCallTest is DSTest { target.addHardGasLimit(); } - function testFailExpectCallWithNoValueAndWrongGas() public { - Contract inner = new Contract(); - NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1)); - this.exposed_addHardGasLimit(target); - } - function testExpectCallWithValueAndMinGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); @@ -245,21 +197,6 @@ contract ExpectCallTest is DSTest { this.exposed_addHardGasLimit(target); } - function testFailExpectCallWithNoValueAndWrongMinGas() public { - Contract inner = new Contract(); - NestedContract target = new NestedContract(inner); - vm.expectCallMinGas(address(inner), 0, 50_001, abi.encodeWithSelector(inner.add.selector, 1, 1)); - this.exposed_addHardGasLimit(target); - } - - /// Ensure that you cannot use expectCall with an expectRevert. - function testFailExpectCallWithRevertDisallowed() public { - Contract target = new Contract(); - vm.expectRevert(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); - this.exposed_callTargetNTimes(target, 5, 5, 1); - } - /// Ensure expectCall works for Proxy DelegateCalls. Ref: function testExpectCallForProxyDelegateCall() public { ProxyWithDelegateCall proxyWithDelegateCall = new ProxyWithDelegateCall(); @@ -290,12 +227,6 @@ contract ExpectCallCountTest is DSTest { target.add(3, 3); } - function testFailExpectCallCountWithWrongCount() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); - target.add(1, 2); - } - function testExpectCountInnerCall() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); @@ -303,16 +234,6 @@ contract ExpectCallCountTest is DSTest { target.sum(); } - function testFailExpectCountInnerCall() public { - Contract inner = new Contract(); - NestedContract target = new NestedContract(inner); - - vm.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector), 1); - - // this function does not call inner - target.hello(); - } - function testExpectCountInnerAndOuterCalls() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); @@ -341,12 +262,6 @@ contract ExpectCallCountTest is DSTest { this.exposed_pay{value: 2}(target, 2, 2); } - function testFailExpectCallCountValue() public { - Contract target = new Contract(); - vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2), 1); - this.exposed_pay{value: 2}(target, 2, 2); - } - function testExpectCallCountWithValueWithoutParameters() public { Contract target = new Contract(); vm.expectCall(address(target), 3, abi.encodeWithSelector(target.pay.selector), 3); @@ -391,13 +306,6 @@ contract ExpectCallCountTest is DSTest { this.exposed_addHardGasLimit(target, 1); } - function testFailExpectCallCountWithNoValueAndWrongGas() public { - Contract inner = new Contract(); - NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 2); - this.exposed_addHardGasLimit(target, 2); - } - function testExpectCallCountWithValueAndMinGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); @@ -422,13 +330,6 @@ contract ExpectCallCountTest is DSTest { vm.expectCallMinGas(address(inner), 0, 50_001, abi.encodeWithSelector(inner.add.selector, 1, 1), 0); this.exposed_addHardGasLimit(target, 1); } - - function testFailExpectCallCountWithNoValueAndWrongMinGas() public { - Contract inner = new Contract(); - NestedContract target = new NestedContract(inner); - vm.expectCallMinGas(address(inner), 0, 50_001, abi.encodeWithSelector(inner.add.selector, 1, 1), 1); - this.exposed_addHardGasLimit(target, 1); - } } contract ExpectCallMixedTest is DSTest { @@ -440,32 +341,6 @@ contract ExpectCallMixedTest is DSTest { } } - function testFailOverrideNoCountWithCount() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); - // You should not be able to overwrite a expectCall that had no count with some count. - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); - this.exposed_callTargetNTimes(target, 1, 2, 2); - } - - function testFailOverrideCountWithCount() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); - // You should not be able to overwrite a expectCall that had a count with some count. - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 1); - target.add(1, 2); - target.add(1, 2); - } - - function testFailOverrideCountWithNoCount() public { - Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); - // You should not be able to overwrite a expectCall that had a count with no count. - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); - target.add(1, 2); - target.add(1, 2); - } - function testExpectMatchPartialAndFull() public { Contract target = new Contract(); vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector), 2); diff --git a/testdata/default/cheats/ExpectEmit.t.sol b/testdata/default/cheats/ExpectEmit.t.sol index 2503faf4bcf7a..b6b09a8a8db70 100644 --- a/testdata/default/cheats/ExpectEmit.t.sol +++ b/testdata/default/cheats/ExpectEmit.t.sol @@ -139,15 +139,6 @@ contract ExpectEmitTest is DSTest { emit A(1); } - function testFailExpectEmitDanglingNoReference() public { - vm.expectEmit(false, false, false, false); - } - - function testFailExpectEmitDanglingWithReference() public { - vm.expectEmit(false, false, false, false); - emit Something(1, 2, 3, 4); - } - /// The topics that are not checked are altered to be incorrect /// compared to the reference. function testExpectEmit( @@ -171,31 +162,6 @@ contract ExpectEmitTest is DSTest { emitter.emitEvent(transformedTopic1, transformedTopic2, transformedTopic3, transformedData); } - /// The topics that are checked are altered to be incorrect - /// compared to the reference. - function testFailExpectEmit( - bool checkTopic1, - bool checkTopic2, - bool checkTopic3, - bool checkData, - uint128 topic1, - uint128 topic2, - uint128 topic3, - uint128 data - ) public { - vm.assume(checkTopic1 || checkTopic2 || checkTopic3 || checkData); - - uint256 transformedTopic1 = checkTopic1 ? uint256(topic1) + 1 : uint256(topic1); - uint256 transformedTopic2 = checkTopic2 ? uint256(topic2) + 1 : uint256(topic2); - uint256 transformedTopic3 = checkTopic3 ? uint256(topic3) + 1 : uint256(topic3); - uint256 transformedData = checkData ? uint256(data) + 1 : uint256(data); - - vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); - - emit Something(topic1, topic2, topic3, data); - emitter.emitEvent(transformedTopic1, transformedTopic2, transformedTopic3, transformedData); - } - /// The topics that are checked are altered to be incorrect /// compared to the reference. function testExpectEmitNested( @@ -221,32 +187,6 @@ contract ExpectEmitTest is DSTest { emitter.emitNested(inner, transformedTopic1, transformedTopic2, transformedTopic3, transformedData); } - /// The topics that are checked are altered to be incorrect - /// compared to the reference. - function testFailExpectEmitNested( - bool checkTopic1, - bool checkTopic2, - bool checkTopic3, - bool checkData, - uint128 topic1, - uint128 topic2, - uint128 topic3, - uint128 data - ) public { - vm.assume(checkTopic1 || checkTopic2 || checkTopic3 || checkData); - Emitter inner = new Emitter(); - - uint256 transformedTopic1 = checkTopic1 ? uint256(topic1) + 1 : uint256(topic1); - uint256 transformedTopic2 = checkTopic2 ? uint256(topic2) + 1 : uint256(topic2); - uint256 transformedTopic3 = checkTopic3 ? uint256(topic3) + 1 : uint256(topic3); - uint256 transformedData = checkData ? uint256(data) + 1 : uint256(data); - - vm.expectEmit(checkTopic1, checkTopic2, checkTopic3, checkData); - - emit Something(topic1, topic2, topic3, data); - emitter.emitNested(inner, transformedTopic1, transformedTopic2, transformedTopic3, transformedData); - } - function testExpectEmitMultiple() public { vm.expectEmit(); emit Something(1, 2, 3, 4); @@ -287,19 +227,6 @@ contract ExpectEmitTest is DSTest { emitter.emitOutOfExactOrder(); } - function testFailExpectEmitCanMatchWithoutExactOrder() public { - vm.expectEmit(true, true, true, true); - emit Something(1, 2, 3, 4); - // This should fail, as this event is never emitted - // in between the other two Something events. - vm.expectEmit(true, true, true, true); - emit SomethingElse(1); - vm.expectEmit(true, true, true, true); - emit Something(1, 2, 3, 4); - - emitter.emitOutOfExactOrder(); - } - function testExpectEmitCanMatchWithoutExactOrder2() public { vm.expectEmit(true, true, true, true); emit SomethingNonIndexed(1); @@ -323,54 +250,6 @@ contract ExpectEmitTest is DSTest { emitter.emitEvent(1, 2, 3, 4); } - function testFailExpectEmitAddress() public { - vm.expectEmit(address(0)); - emit Something(1, 2, 3, 4); - - emitter.emitEvent(1, 2, 3, 4); - } - - function testFailExpectEmitAddressWithArgs() public { - vm.expectEmit(true, true, true, true, address(0)); - emit Something(1, 2, 3, 4); - - emitter.emitEvent(1, 2, 3, 4); - } - - /// Ref: issue #760 - function testFailLowLevelWithoutEmit() public { - LowLevelCaller caller = new LowLevelCaller(); - - vm.expectEmit(true, true, true, true); - emit Something(1, 2, 3, 4); - - // This does not emit an event, so this test should fail - caller.f(); - } - - function testFailNoEmitDirectlyOnNextCall() public { - LowLevelCaller caller = new LowLevelCaller(); - - vm.expectEmit(true, true, true, true); - emit Something(1, 2, 3, 4); - - // This call does not emit. As emit expects the next call to emit, this should fail. - caller.f(); - // This call does emit, but it is a call later than expected. - emitter.emitEvent(1, 2, 3, 4); - } - - /// Ref: issue #760 - function testFailDifferentIndexedParameters() public { - vm.expectEmit(true, false, false, false); - emit SomethingElse(1); - - // This should fail since `SomethingElse` in the test - // and in the `Emitter` contract have differing - // amounts of indexed topics. - emitter.emitSomethingElse(1); - } - function testCanDoStaticCall() public { vm.expectEmit(true, true, true, true); emit Something(emitter.getVar(), 2, 3, 4); @@ -389,19 +268,6 @@ contract ExpectEmitTest is DSTest { ); } - /// This test should fail, as the call to `changeThing` is not a static call. - /// While we can ignore static calls, we cannot ignore normal calls. - function testFailEmitOnlyAppliesToNextCall() public { - vm.expectEmit(true, true, true, true); - emit Something(1, 2, 3, 4); - // This works because it's a staticcall. - emitter.doesNothing(); - // This should make the test fail as it's a normal call. - emitter.changeThing(block.timestamp); - - emitter.emitEvent(1, 2, 3, 4); - } - /// emitWindow() emits events A, B, C, D, E. /// We should be able to match [A, B, C, D, E] in the correct order. function testCanMatchConsecutiveEvents() public { @@ -455,23 +321,6 @@ contract ExpectEmitTest is DSTest { emitter.emitWindow(); } - /// emitWindow() emits events A, B, C, D, E. - /// We should not be able to match [B, A, C, D, E] as B and A are flipped. - function testFailCanMatchConsecutiveEvents() public { - vm.expectEmit(true, false, false, true); - emit B(2); - vm.expectEmit(true, false, false, true); - emit A(1); - vm.expectEmit(true, false, false, true); - emit C(3); - vm.expectEmit(true, false, false, true); - emit D(4); - vm.expectEmit(true, false, false, true); - emit E(5); - - emitter.emitWindow(); - } - /// emitWindowNested() emits events A, C, E, A, B, C, D, E, the last 5 on an external call. /// We should be able to match the whole event sequence in order no matter if the events /// were emitted deeper into the call tree. @@ -536,34 +385,6 @@ contract ExpectEmitTest is DSTest { emitter.emitNestedWindow(); } - /// emitWindowNested() emits events A, C, E, A, B, C, D, E, the last 5 on an external call. - /// We should NOT be able to match [A, A, E, E], as while we're matching the correct amount - /// of events, they're not in the correct order. It should be [A, E, A, E]. - function testFailMatchRepeatedEventsOutOfOrder() public { - vm.expectEmit(true, false, false, true); - emit A(1); - vm.expectEmit(true, false, false, true); - emit A(1); - vm.expectEmit(true, false, false, true); - emit E(5); - vm.expectEmit(true, false, false, true); - emit E(5); - - emitter.emitNestedWindow(); - } - - /// emitWindow() emits events A, B, C, D, E. - /// We should not be able to match [A, A] even if emitWindow() is called twice, - /// as expectEmit() only works for the next call. - function testFailEventsOnTwoCalls() public { - vm.expectEmit(true, false, false, true); - emit A(1); - vm.expectEmit(true, false, false, true); - emit A(1); - emitter.emitWindow(); - emitter.emitWindow(); - } - /// emitWindowAndOnTest emits [[A, B, C, D, E], [A]]. The interesting bit is that the /// second call that emits [A] is on this same contract. We should still be able to match /// [A, A] as the call made to this contract is still external. @@ -575,15 +396,6 @@ contract ExpectEmitTest is DSTest { emitter.emitWindowAndOnTest(this); } - /// We should not be able to expect emits if we're expecting the function reverts, no matter - /// if the function reverts or not. - function testFailEmitWindowWithRevertDisallowed() public { - vm.expectRevert(); - vm.expectEmit(true, false, false, true); - emit A(1); - emitter.emitWindow(); - } - /// This test will fail if we check that all expected logs were emitted /// after every call from the same depth as the call that invoked the cheatcode. /// @@ -620,12 +432,6 @@ contract ExpectEmitCountTest is DSTest { emitter.doesNothing(); } - function testFailNoEmit() public { - vm.expectEmit(0); - emit Something(1, 2, 3, 4); - emitter.emitEvent(1, 2, 3, 4); - } - function testCountNEmits() public { uint64 count = 2; vm.expectEmit(count); @@ -633,13 +439,6 @@ contract ExpectEmitCountTest is DSTest { emitter.emitNEvents(1, 2, 3, 4, count); } - function testFailCountLessEmits() public { - uint64 count = 2; - vm.expectEmit(count); - emit Something(1, 2, 3, 4); - emitter.emitNEvents(1, 2, 3, 4, count - 1); - } - function testCountMoreEmits() public { uint64 count = 2; vm.expectEmit(count); @@ -648,37 +447,16 @@ contract ExpectEmitCountTest is DSTest { } /// Test zero emits from a specific address (emitter). - function testCountNoEmitFromAddress() public { vm.expectEmit(address(emitter), 0); emit Something(1, 2, 3, 4); emitter.doesNothing(); } - function testFailNoEmitFromAddress() public { - vm.expectEmit(address(emitter), 0); - emit Something(1, 2, 3, 4); - emitter.emitEvent(1, 2, 3, 4); - } - function testCountEmitsFromAddress() public { uint64 count = 2; vm.expectEmit(address(emitter), count); emit Something(1, 2, 3, 4); emitter.emitNEvents(1, 2, 3, 4, count); } - - function testFailCountEmitsFromAddress() public { - uint64 count = 3; - vm.expectEmit(address(emitter), count); - emit Something(1, 2, 3, 4); - emitter.emitNEvents(1, 2, 3, 4, count - 1); - } - - function testFailEmitSomethingElse() public { - uint64 count = 2; - vm.expectEmit(count); - emit Something(1, 2, 3, 4); - emitter.emitSomethingElse(23214); - } } diff --git a/testdata/default/cheats/ExpectRevert.t.sol b/testdata/default/cheats/ExpectRevert.t.sol index fef4ebaf57900..249fcc7bb3f4c 100644 --- a/testdata/default/cheats/ExpectRevert.t.sol +++ b/testdata/default/cheats/ExpectRevert.t.sol @@ -84,22 +84,12 @@ contract ExpectRevertTest is DSTest { reverter.revertWithMessage("revert"); } - function testFailExpectRevertWrongString() public { + function testShouldFailIfExpectRevertWrongString() public { Reverter reverter = new Reverter(); - vm.expectRevert("my not so cool error"); + vm.expectRevert("my not so cool error", 0); reverter.revertWithMessage("my cool error"); } - function testFailRevertNotOnImmediateNextCall() public { - Reverter reverter = new Reverter(); - // expectRevert should only work for the next call. However, - // we do not immediately revert, so, - // we fail. - vm.expectRevert("revert"); - reverter.doNotRevert(); - reverter.revertWithMessage("revert"); - } - function testExpectRevertConstructor() public { vm.expectRevert("constructor revert"); new ConstructorReverter("constructor revert"); @@ -137,18 +127,6 @@ contract ExpectRevertTest is DSTest { dummy.largeReturnType(); } - function testFailExpectRevertErrorDoesNotMatch() public { - Reverter reverter = new Reverter(); - vm.expectRevert("should revert with this message"); - reverter.revertWithMessage("but reverts with this message"); - } - - function testFailExpectRevertDidNotRevert() public { - Reverter reverter = new Reverter(); - vm.expectRevert("does not revert, but we think it should"); - reverter.doNotRevert(); - } - function testExpectRevertNoReason() public { Reverter reverter = new Reverter(); vm.expectRevert(bytes("")); @@ -181,31 +159,10 @@ contract ExpectRevertTest is DSTest { reverter.revertWithoutReason(); } - function testFailExpectRevertAnyRevertDidNotRevert() public { - Reverter reverter = new Reverter(); - vm.expectRevert(); - reverter.doNotRevert(); - } - - function testFailExpectRevertDangling() public { - vm.expectRevert("dangling"); - } - function testexpectCheatcodeRevert() public { vm._expectCheatcodeRevert('JSON value at ".a" is not an object'); vm.parseJsonKeys('{"a": "b"}', ".a"); } - - function testFailexpectCheatcodeRevertForExtCall() public { - Reverter reverter = new Reverter(); - vm._expectCheatcodeRevert(); - reverter.revertWithMessage("revert"); - } - - function testFailexpectCheatcodeRevertForCreate() public { - vm._expectCheatcodeRevert(); - new ConstructorReverter("some message"); - } } contract AContract { @@ -347,13 +304,6 @@ contract ExpectRevertWithReverterTest is DSTest { vm.expectRevert(address(cContract)); aContract.createDContractThroughCContract(); } - - function testFailExpectRevertsNotOnImmediateNextCall() public { - // Test expect revert with reverter fails if next call doesn't revert. - vm.expectRevert(address(aContract)); - aContract.doNotRevert(); - aContract.callAndRevert(); - } } contract ExpectRevertCount is DSTest { @@ -371,14 +321,6 @@ contract ExpectRevertCount is DSTest { reverter.revertWithMessage("revert"); } - function testFailRevertCountAny() public { - uint64 count = 3; - Reverter reverter = new Reverter(); - vm.expectRevert(count); - reverter.revertWithMessage("revert"); - reverter.revertWithMessage("revert2"); - } - function testNoRevert() public { uint64 count = 0; Reverter reverter = new Reverter(); @@ -386,13 +328,6 @@ contract ExpectRevertCount is DSTest { reverter.doNotRevert(); } - function testFailNoRevert() public { - uint64 count = 0; - Reverter reverter = new Reverter(); - vm.expectRevert(count); - reverter.revertWithMessage("revert"); - } - function testRevertCountSpecific() public { uint64 count = 2; Reverter reverter = new Reverter(); @@ -401,14 +336,6 @@ contract ExpectRevertCount is DSTest { reverter.revertWithMessage("revert"); } - function testFailReverCountSpecifc() public { - uint64 count = 2; - Reverter reverter = new Reverter(); - vm.expectRevert("revert", count); - reverter.revertWithMessage("revert"); - reverter.revertWithMessage("second-revert"); - } - function testNoRevertSpecific() public { uint64 count = 0; Reverter reverter = new Reverter(); @@ -416,13 +343,6 @@ contract ExpectRevertCount is DSTest { reverter.doNotRevert(); } - function testFailNoRevertSpecific() public { - uint64 count = 0; - Reverter reverter = new Reverter(); - vm.expectRevert("revert", count); - reverter.revertWithMessage("revert"); - } - function testNoRevertSpecificButDiffRevert() public { uint64 count = 0; Reverter reverter = new Reverter(); @@ -466,16 +386,6 @@ contract ExpectRevertCount is DSTest { reverter.callThenRevert(dummy, "called a function and then reverted"); } - function testFailRevertCountCallsThenReverts() public { - uint64 count = 2; - Reverter reverter = new Reverter(); - Dummy dummy = new Dummy(); - - vm.expectRevert("called a function and then reverted", count); - reverter.callThenRevert(dummy, "called a function and then reverted"); - reverter.callThenRevert(dummy, "wrong revert"); - } - function testNoRevertCall() public { uint64 count = 0; Reverter reverter = new Reverter(); @@ -497,15 +407,6 @@ contract ExpectRevertCountWithReverter is DSTest { reverter.revertWithMessage("revert"); } - function testFailRevertCountWithReverter() public { - uint64 count = 2; - Reverter reverter = new Reverter(); - Reverter reverter2 = new Reverter(); - vm.expectRevert(address(reverter), count); - reverter.revertWithMessage("revert"); - reverter2.revertWithMessage("revert"); - } - function testNoRevertWithReverter() public { uint64 count = 0; Reverter reverter = new Reverter(); @@ -521,13 +422,6 @@ contract ExpectRevertCountWithReverter is DSTest { reverter2.revertWithMessage("revert"); // revert from wrong reverter } - function testFailNoRevertWithReverter() public { - uint64 count = 0; - Reverter reverter = new Reverter(); - vm.expectRevert(address(reverter), count); - reverter.revertWithMessage("revert"); - } - function testReverterCountWithData() public { uint64 count = 2; Reverter reverter = new Reverter(); @@ -536,23 +430,6 @@ contract ExpectRevertCountWithReverter is DSTest { reverter.revertWithMessage("revert"); } - function testFailReverterCountWithWrongData() public { - uint64 count = 2; - Reverter reverter = new Reverter(); - vm.expectRevert("revert", address(reverter), count); - reverter.revertWithMessage("revert"); - reverter.revertWithMessage("wrong revert"); - } - - function testFailWrongReverterCountWithData() public { - uint64 count = 2; - Reverter reverter = new Reverter(); - Reverter reverter2 = new Reverter(); - vm.expectRevert("revert", address(reverter), count); - reverter.revertWithMessage("revert"); - reverter2.revertWithMessage("revert"); - } - function testNoReverterCountWithData() public { uint64 count = 0; Reverter reverter = new Reverter(); diff --git a/testdata/default/cheats/GetCode.t.sol b/testdata/default/cheats/GetCode.t.sol index b258b6271efab..6020e4f1fd5bb 100644 --- a/testdata/default/cheats/GetCode.t.sol +++ b/testdata/default/cheats/GetCode.t.sol @@ -71,7 +71,9 @@ contract GetCodeTest is DSTest { } */ - function testFailGetUnlinked() public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfGetUnlinked() public { + vm.expectRevert("vm.getCode: no matching artifact found"); vm.getCode("UnlinkedContract.sol"); } diff --git a/testdata/default/cheats/MemSafety.t.sol b/testdata/default/cheats/MemSafety.t.sol index 2093c20fd56ec..b18673e93e081 100644 --- a/testdata/default/cheats/MemSafety.t.sol +++ b/testdata/default/cheats/MemSafety.t.sol @@ -37,30 +37,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that writing to memory before the range given to `expectSafeMemory` - /// will cause the test to fail while using the `MSTORE` opcode. - function testFailExpectSafeMemory_MSTORE_Low() public { - // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); - - // Attempt to write to memory outside of the range using `MSTORE` - assembly { - mstore(0x60, 0xc0ffee) - } - } - - /// @dev Tests that writing to memory after the range given to `expectSafeMemory` - /// will cause the test to fail while using the `MSTORE` opcode. - function testFailExpectSafeMemory_MSTORE_High() public { - // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); - - // Attempt to write to memory outside of the range using `MSTORE` - assembly { - mstore(0xA0, 0xc0ffee) - } - } - //////////////////////////////////////////////////////////////// // MSTORE8 // //////////////////////////////////////////////////////////////// @@ -91,30 +67,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that writing to memory before the range given to `expectSafeMemory` - /// will cause the test to fail while using the `MSTORE8` opcode. - function testFailExpectSafeMemory_MSTORE8_Low() public { - // Allow memory writes in the range of [0x80, 0x81) within this context - vm.expectSafeMemory(0x80, 0x81); - - // Attempt to write to memory outside of the range using `MSTORE8` - assembly { - mstore8(0x60, 0xFF) - } - } - - /// @dev Tests that writing to memory after the range given to `expectSafeMemory` - /// will cause the test to fail while using the `MSTORE8` opcode. - function testFailExpectSafeMemory_MSTORE8_High() public { - // Allow memory writes in the range of [0x80, 0x81) within this context - vm.expectSafeMemory(0x80, 0x81); - - // Attempt to write to memory outside of the range using `MSTORE8` - assembly { - mstore8(0x81, 0xFF) - } - } - //////////////////////////////////////////////////////////////// // CALLDATACOPY // //////////////////////////////////////////////////////////////// @@ -131,18 +83,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `CALLDATACOPY` opcode. - function testFailExpectSafeMemory_CALLDATACOPY(uint256 _x) public { - // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); - - // Write to memory outside the range using `CALLDATACOPY` - assembly { - calldatacopy(0xA0, 0x04, 0x20) - } - } - //////////////////////////////////////////////////////////////// // CODECOPY // //////////////////////////////////////////////////////////////// @@ -160,19 +100,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `CODECOPY` opcode. - function testFailExpectSafeMemory_CODECOPY() public { - // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); - - // Attempt to write to memory outside of the range using `CODECOPY` - assembly { - let size := extcodesize(address()) - codecopy(0x80, 0x00, size) - } - } - //////////////////////////////////////////////////////////////// // RETURNDATACOPY // //////////////////////////////////////////////////////////////// @@ -198,27 +125,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `RETURNDATACOPY` opcode. - function testFailExpectSafeMemory_RETURNDATACOPY() public { - // Create a new SubContext contract - SubContext sc = new SubContext(); - - // Create a payload to call `giveReturndata` on the SubContext contract - bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); - - // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); - - // Create a new SubContext contract and call `giveReturndata` on it. - _doCallReturnData(address(sc), payload, 0x80, 0x60); - - // Write to memory outside of the range using `RETURNDATACOPY` - assembly { - returndatacopy(0x100, 0x00, 0x60) - } - } - //////////////////////////////////////////////////////////////// // EXTCODECOPY // //////////////////////////////////////////////////////////////// @@ -236,19 +142,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will not cause the test to fail while using the `EXTCODECOPY` opcode. - function testFailExpectSafeMemory_EXTCODECOPY() public { - // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); - - // Attempt to write to memory outside of the range using `EXTCODECOPY` - assembly { - let size := extcodesize(address()) - extcodecopy(address(), 0xA0, 0x00, 0x20) - } - } - //////////////////////////////////////////////////////////////// // CALL // //////////////////////////////////////////////////////////////// @@ -269,22 +162,6 @@ contract MemSafetyTest is DSTest { _doCallReturnData(address(sc), payload, 0x80, 0x60); } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `CALL` opcode. - function testFailExpectSafeMemory_CALL() public { - // Create a new SubContext contract - SubContext sc = new SubContext(); - - // Create a payload to call `giveReturndata` on the SubContext contract - bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); - - // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); - - // Create a new SubContext contract and call `giveReturndata` on it. - _doCallReturnData(address(sc), payload, 0x100, 0x60); - } - //////////////////////////////////////////////////////////////// // CALLCODE // //////////////////////////////////////////////////////////////// @@ -305,22 +182,6 @@ contract MemSafetyTest is DSTest { _doCallCodeReturnData(address(sc), payload, 0x80, 0x60); } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `CALLCODE` opcode. - function testFailExpectSafeMemory_CALLCODE() public { - // Create a new SubContext contract - SubContext sc = new SubContext(); - - // Create a payload to call `giveReturndata` on the SubContext contract - bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); - - // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); - - // Create a new SubContext contract and call `giveReturndata` on it. - _doCallCodeReturnData(address(sc), payload, 0x100, 0x60); - } - //////////////////////////////////////////////////////////////// // STATICCALL // //////////////////////////////////////////////////////////////// @@ -341,22 +202,6 @@ contract MemSafetyTest is DSTest { _doStaticCallReturnData(address(sc), payload, 0x80, 0x60); } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `STATICCALL` opcode. - function testFailExpectSafeMemory_STATICCALL() public { - // Create a new SubContext contract - SubContext sc = new SubContext(); - - // Create a payload to call `giveReturndata` on the SubContext contract - bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); - - // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); - - // Create a new SubContext contract and call `giveReturndata` on it. - _doStaticCallReturnData(address(sc), payload, 0x100, 0x60); - } - //////////////////////////////////////////////////////////////// // DELEGATECALL // //////////////////////////////////////////////////////////////// @@ -377,22 +222,6 @@ contract MemSafetyTest is DSTest { _doDelegateCallReturnData(address(sc), payload, 0x80, 0x60); } - /// @dev Tests that writing to memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `DELEGATECALL` opcode. - function testFailExpectSafeMemory_DELEGATECALL() public { - // Create a new SubContext contract - SubContext sc = new SubContext(); - - // Create a payload to call `giveReturndata` on the SubContext contract - bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); - - // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); - - // Create a new SubContext contract and call `giveReturndata` on it. - _doDelegateCallReturnData(address(sc), payload, 0x100, 0x60); - } - //////////////////////////////////////////////////////////////// // MLOAD (Read Expansion) // //////////////////////////////////////////////////////////////// @@ -428,20 +257,6 @@ contract MemSafetyTest is DSTest { uint256 b = a + 1; } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `MLOAD` opcode. - function testFailExpectSafeMemory_MLOAD() public { - vm.expectSafeMemory(0x80, 0x100); - - // This should revert. Ugly hack to make sure the mload isn't optimized - // out. - uint256 a; - assembly { - a := mload(0x100) - } - uint256 b = a + 1; - } - //////////////////////////////////////////////////////////////// // SHA3 (Read Expansion) // //////////////////////////////////////////////////////////////// @@ -460,20 +275,6 @@ contract MemSafetyTest is DSTest { uint256 b = a + 1; } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `SHA3` opcode. - function testFailExpectSafeMemory_SHA3() public { - vm.expectSafeMemory(0x80, 0x100); - - // This should revert. Ugly hack to make sure the sha3 isn't optimized - // out. - uint256 a; - assembly { - a := keccak256(0x100, 0x20) - } - uint256 b = a + 1; - } - //////////////////////////////////////////////////////////////// // LOG(0-4) (Read Expansion) // //////////////////////////////////////////////////////////////// @@ -492,17 +293,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `LOG0` opcode. - function testFailExpectSafeMemory_LOG0() public { - vm.expectSafeMemory(0x80, 0x100); - - // This should revert. - assembly { - log0(0x100, 0x20) - } - } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` /// will cause the test to fail while using the `LOG0` opcode. /// forge-config: default.allow_internal_expect_revert = true @@ -530,17 +320,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `CREATE` opcode. - function testFailExpectSafeMemory_CREATE() public { - vm.expectSafeMemory(0x80, 0x100); - - // This should revert. - assembly { - pop(create(0, 0x100, 0x20)) - } - } - /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `CREATE2` opcode. function testExpectSafeMemory_CREATE2() public { @@ -552,17 +331,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `CREATE2` opcode. - function testFailExpectSafeMemory_CREATE2() public { - vm.expectSafeMemory(0x80, 0x100); - - // This should revert. - assembly { - pop(create2(0, 0x100, 0x20, 0x00)) - } - } - //////////////////////////////////////////////////////////////// // RETURN/REVERT (Read Expansion) // //////////////////////////////////////////////////////////////// @@ -578,17 +346,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `RETURN` opcode. - function testFailExpectSafeMemory_RETURN() public { - vm.expectSafeMemory(0x80, 0x100); - - // This should revert. - assembly { - return(0x100, 0x20) - } - } - /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `REVERT` opcode. function testExpectSafeMemory_REVERT() public { @@ -609,26 +366,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that expanding memory outside of the range given to `expectSafeMemory` - /// will cause the test to fail while using the `REVERT` opcode. - function testFailExpectSafeMemory_REVERT() public { - // Create a new SubContext contract - SubContext sc = new SubContext(); - - // Create a payload to call `doRevert` on the SubContext contract - bytes memory payload = abi.encodeWithSelector(SubContext.doRevert.selector, 0x120, 0x20); - - // Expect memory in the range of [0x00, 0x120] to be safe in the next subcontext - vm.expectSafeMemoryCall(0x00, 0x120); - - // Call `doRevert` on the SubContext contract and ensure it did not revert with - // zero data. - _doCallReturnData(address(sc), payload, 0x200, 0x20); - assembly { - if iszero(eq(keccak256(0x60, 0x20), keccak256(0x200, returndatasize()))) { revert(0x00, 0x00) } - } - } - //////////////////////////////////////////////////////////////// // Context Depth Tests // //////////////////////////////////////////////////////////////// @@ -683,22 +420,6 @@ contract MemSafetyTest is DSTest { _doCall(address(sc), payload); } - /// @dev Tests that the `expectSafeMemoryCall` cheatcode works as expected. - function testFailExpectSafeMemoryCall() public { - // Create a new SubContext contract - SubContext sc = new SubContext(); - // Create a payload to call `doMstore8` on the SubContext contract - bytes memory payload = abi.encodeWithSelector(SubContext.doMstore.selector, 0xA0, 0xc0ffee); - - // Allow memory writes in the range of [0x80, 0xA0) within the next created subcontext - vm.expectSafeMemoryCall(0x80, 0xA0); - - // Should revert. The memory write in this subcontext is outside of the allowed range. - if (!_doCall(address(sc), payload)) { - revert("Expected call to fail"); - } - } - //////////////////////////////////////////////////////////////// // `stopExpectSafeMemory` cheatcode // //////////////////////////////////////////////////////////////// @@ -724,22 +445,6 @@ contract MemSafetyTest is DSTest { } } - /// @dev Tests that the `stopExpectSafeMemory` cheatcode does not cause violations not being noticed. - function testFailStopExpectSafeMemory() public { - uint64 initPtr; - assembly { - initPtr := mload(0x40) - } - - vm.expectSafeMemory(initPtr, initPtr + 0x20); - assembly { - // write outside of allowed range, this should revert - mstore(add(initPtr, 0x20), 0x01) - } - - vm.stopExpectSafeMemory(); - } - /// @dev Tests that the `stopExpectSafeMemory` cheatcode can still be called if the free memory pointer was /// updated to the exclusive upper boundary during execution. function testStopExpectSafeMemory_freeMemUpdate() public { diff --git a/testdata/default/cheats/Prank.t.sol b/testdata/default/cheats/Prank.t.sol index 130e819606a28..3a6bf756fb176 100644 --- a/testdata/default/cheats/Prank.t.sol +++ b/testdata/default/cheats/Prank.t.sol @@ -193,10 +193,12 @@ contract PrankTest is DSTest { vm.stopPrank(); } - function testFailPrankDelegateCallToEOA() public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfPrankDelegateCalltoEOA() public { uint256 privateKey = uint256(keccak256(abi.encodePacked("alice"))); address alice = vm.addr(privateKey); ImplementationTest impl = new ImplementationTest(); + vm.expectRevert("vm.prank: cannot `prank` delegate call from an EOA"); vm.prank(alice, true); // Should fail when EOA pranked with delegatecall. address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", alice)); @@ -336,16 +338,19 @@ contract PrankTest is DSTest { ); } - function testFailOverwriteUnusedPrank(address sender, address origin) public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfOverwriteUnusedPrank(address sender, address origin) public { // Set the prank, but not use it address oldOrigin = tx.origin; Victim victim = new Victim(); vm.startPrank(sender, origin); // try to overwrite the prank. This should fail. + vm.expectRevert("vm.startPrank: cannot overwrite a prank until it is applied at least once"); vm.startPrank(address(this), origin); } - function testFailOverwriteUnusedPrankAfterSuccessfulPrank(address sender, address origin) public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfOverwriteUnusedPrankAfterSuccessfulPrank(address sender, address origin) public { // Set the prank, but not use it address oldOrigin = tx.origin; Victim victim = new Victim(); @@ -355,6 +360,7 @@ contract PrankTest is DSTest { ); vm.startPrank(address(this), origin); // try to overwrite the prank. This should fail. + vm.expectRevert("vm.startPrank: cannot overwrite a prank until it is applied at least once"); vm.startPrank(sender, origin); } diff --git a/testdata/default/cheats/RandomCheatcodes.t.sol b/testdata/default/cheats/RandomCheatcodes.t.sol index 4c3e1fffdfde0..c42b4310012f1 100644 --- a/testdata/default/cheats/RandomCheatcodes.t.sol +++ b/testdata/default/cheats/RandomCheatcodes.t.sol @@ -19,9 +19,11 @@ contract RandomCheatcodesTest is DSTest { assertLe(val, max); } - function testFail_int128() public { + /// forge-config: default.allow_internal_expect_revert = true + function testReverttIf_int128() public { int256 val = vm.randomInt(128); - assertGt(val, max); + vm.expectRevert("Error: a > b not satisfied [int]"); + require(val > max, "Error: a > b not satisfied [int]"); } function test_address() public { diff --git a/testdata/default/cheats/SetNonce.t.sol b/testdata/default/cheats/SetNonce.t.sol index 83e3830abc3f9..e0fda6aaec688 100644 --- a/testdata/default/cheats/SetNonce.t.sol +++ b/testdata/default/cheats/SetNonce.t.sol @@ -26,9 +26,13 @@ contract SetNonceTest is DSTest { foo.f(); } - function testFailInvalidNonce() public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfInvalidNonce() public { vm.setNonce(address(foo), 10); // set lower nonce should fail + vm.expectRevert( + "vm.setNonce: new nonce (5) must be strictly equal to or higher than the account's current nonce (10)" + ); vm.setNonce(address(foo), 5); } } diff --git a/testdata/default/cheats/Skip.t.sol b/testdata/default/cheats/Skip.t.sol index e2b0fc18113e3..d7e75fa0f51af 100644 --- a/testdata/default/cheats/Skip.t.sol +++ b/testdata/default/cheats/Skip.t.sol @@ -12,8 +12,10 @@ contract SkipTest is DSTest { revert("Should not reach this revert"); } - function testFailNotSkip() public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfNotSkip() public { vm.skip(false); + vm.expectRevert("This test should fail"); revert("This test should fail"); } @@ -22,8 +24,10 @@ contract SkipTest is DSTest { revert("Should not reach revert"); } - function testFailFuzzSkip(uint256 x) public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfFuzzSkip(uint256 x) public { vm.skip(false); + vm.expectRevert("This test should fail"); revert("This test should fail"); } diff --git a/testdata/default/core/DSStyle.t.sol b/testdata/default/core/DSStyle.t.sol deleted file mode 100644 index 1eaf83969f1ed..0000000000000 --- a/testdata/default/core/DSStyle.t.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity ^0.8.18; - -import "ds-test/test.sol"; - -contract DSStyleTest is DSTest { - function testFailingAssertions() public { - emit log_string("assertionOne"); - assertEq(uint256(1), uint256(2)); - emit log_string("assertionTwo"); - assertEq(uint256(3), uint256(4)); - emit log_string("done"); - } -} diff --git a/testdata/default/core/FailingSetup.t.sol b/testdata/default/core/FailingSetup.t.sol deleted file mode 100644 index d5e24e131c3fa..0000000000000 --- a/testdata/default/core/FailingSetup.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity ^0.8.18; - -import "ds-test/test.sol"; - -contract FailingSetupTest is DSTest { - event Test(uint256 n); - - function setUp() public { - emit Test(42); - require(false, "setup failed predictably"); - } - - function testFailShouldBeMarkedAsFailedBecauseOfSetup() public { - emit log("setup did not fail"); - } -} diff --git a/testdata/default/core/MultipleAfterInvariant.t.sol b/testdata/default/core/MultipleAfterInvariant.t.sol deleted file mode 100644 index b23b0996a9242..0000000000000 --- a/testdata/default/core/MultipleAfterInvariant.t.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity ^0.8.18; - -import "ds-test/test.sol"; - -contract MultipleAfterInvariant is DSTest { - function afterInvariant() public {} - - function afterinvariant() public {} - - function testFailShouldBeMarkedAsFailedBecauseOfAfterInvariant() public { - assert(true); - } -} diff --git a/testdata/default/core/MultipleSetup.t.sol b/testdata/default/core/MultipleSetup.t.sol deleted file mode 100644 index 73cbaf1a99bd0..0000000000000 --- a/testdata/default/core/MultipleSetup.t.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity ^0.8.18; - -import "ds-test/test.sol"; - -contract MultipleSetup is DSTest { - function setUp() public {} - - function setup() public {} - - function testFailShouldBeMarkedAsFailedBecauseOfSetup() public { - assert(true); - } -} diff --git a/testdata/default/core/Reverting.t.sol b/testdata/default/core/Reverting.t.sol index 91022e6ad20c4..73877cab0b542 100644 --- a/testdata/default/core/Reverting.t.sol +++ b/testdata/default/core/Reverting.t.sol @@ -1,8 +1,15 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity ^0.8.18; -contract RevertingTest { - function testFailRevert() public pure { +import "ds-test/test.sol"; +import "cheats/Vm.sol"; + +contract RevertingTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + /// forge-config: default.allow_internal_expect_revert = true + function testRevert() public { + vm.expectRevert("should revert here"); require(false, "should revert here"); } } diff --git a/testdata/default/fuzz/Fuzz.t.sol b/testdata/default/fuzz/Fuzz.t.sol index 24c8d1750e366..b1cf54716be93 100644 --- a/testdata/default/fuzz/Fuzz.t.sol +++ b/testdata/default/fuzz/Fuzz.t.sol @@ -2,21 +2,20 @@ pragma solidity ^0.8.18; import "ds-test/test.sol"; - -interface Vm { - function toString(bytes32) external returns (string memory); -} +import "cheats/Vm.sol"; contract FuzzTest is DSTest { constructor() { emit log("constructor"); } + Vm constant vm = Vm(HEVM_ADDRESS); + function setUp() public { emit log("setUp"); } - function testFailFuzz(uint8 x) public { + function testShouldFailFuzz(uint8 x) public { emit log("testFailFuzz"); require(x > 128, "should revert"); } @@ -27,7 +26,6 @@ contract FuzzTest is DSTest { } function testToStringFuzz(bytes32 data) public { - Vm vm = Vm(HEVM_ADDRESS); vm.toString(data); } } diff --git a/testdata/default/logs/DebugLogs.t.sol b/testdata/default/logs/DebugLogs.t.sol index 3e307d173dfa3..b560fd2bfb9ca 100644 --- a/testdata/default/logs/DebugLogs.t.sol +++ b/testdata/default/logs/DebugLogs.t.sol @@ -1,8 +1,11 @@ pragma solidity ^0.8.18; import "ds-test/test.sol"; +import "cheats/Vm.sol"; contract DebugLogsTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + constructor() { emit log_uint(0); } @@ -19,14 +22,17 @@ contract DebugLogsTest is DSTest { emit log_uint(3); } - function testFailWithRevert() public { + function testRevertIfWithRevert() public { Fails fails = new Fails(); emit log_uint(4); + vm.expectRevert(); fails.failure(); } - function testFailWithRequire() public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertIfWithRequire() public { emit log_uint(5); + vm.expectRevert(); require(false); } diff --git a/testdata/default/logs/console.sol b/testdata/default/logs/console.sol index 4fdb6679edf91..e6b267184b96d 100644 --- a/testdata/default/logs/console.sol +++ b/testdata/default/logs/console.sol @@ -2,29 +2,21 @@ pragma solidity >=0.4.22 <0.9.0; library console { - address constant CONSOLE_ADDRESS = - 0x000000000000000000636F6e736F6c652e6c6f67; + address constant CONSOLE_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67; function _sendLogPayloadImplementation(bytes memory payload) internal view { address consoleAddress = CONSOLE_ADDRESS; /// @solidity memory-safe-assembly assembly { - pop( - staticcall( - gas(), - consoleAddress, - add(payload, 32), - mload(payload), - 0, - 0 - ) - ) + pop(staticcall(gas(), consoleAddress, add(payload, 32), mload(payload), 0, 0)) } } - function _castToPure( - function(bytes memory) internal view fnIn - ) internal pure returns (function(bytes memory) pure fnOut) { + function _castToPure(function(bytes memory) internal view fnIn) + internal + pure + returns (function(bytes memory) pure fnOut) + { assembly { fnOut := fnIn } diff --git a/testdata/default/repros/Issue7238.t.sol b/testdata/default/repros/Issue7238.t.sol index 73befa3eaaab0..a2227fabed8bc 100644 --- a/testdata/default/repros/Issue7238.t.sol +++ b/testdata/default/repros/Issue7238.t.sol @@ -23,24 +23,15 @@ contract Issue7238Test is DSTest { } // FAIL - function testFailRevertNotOnImmediateNextCall() public { - Reverter reverter = new Reverter(); - // expectRevert should only work for the next call. However, - // we do not inmediately revert, so, - // we fail. - vm.expectRevert("revert"); - reverter.doNotRevert(); - reverter.revertWithMessage("revert"); - } - - // FAIL - function testFailCheatcodeRevert() public { + /// forge-config: default.allow_internal_expect_revert = true + function testShouldFailCheatcodeRevert() public { // This expectRevert is hanging, as the next cheatcode call is ignored. vm.expectRevert(); vm.fsMetadata("something/something"); // try to go to some non-existent path to cause a revert } - function testFailEarlyRevert() public { + /// forge-config: default.allow_internal_expect_revert = true + function testShouldFailEarlyRevert() public { vm.expectRevert(); rever(); } diff --git a/testdata/default/repros/Issue7457.t.sol b/testdata/default/repros/Issue7457.t.sol index d95f79c4835f2..13cd033afac9a 100644 --- a/testdata/default/repros/Issue7457.t.sol +++ b/testdata/default/repros/Issue7457.t.sol @@ -74,18 +74,6 @@ contract Issue7457Test is DSTest, ITarget { target.emitAnonymousEventNonIndexed(1); } - // function testFailEmitDifferentEvent() public { - // vm.expectEmitAnonymous(false, false, false, true); - // emit DifferentAnonymousEventEmpty(); - // target.emitAnonymousEventEmpty(); - // } - - function testFailEmitDifferentEventNonIndexed() public { - vm.expectEmitAnonymous(false, false, false, false, true); - emit DifferentAnonymousEventNonIndexed("1"); - target.emitAnonymousEventNonIndexed(1); - } - function testEmitEventWith1Topic() public { vm.expectEmitAnonymous(true, false, false, false, true); emit AnonymousEventWith1Topic(1, 2); diff --git a/testdata/default/repros/Issue7481.t.sol b/testdata/default/repros/Issue7481.t.sol index 46b24b1d5142a..c8116b8095aeb 100644 --- a/testdata/default/repros/Issue7481.t.sol +++ b/testdata/default/repros/Issue7481.t.sol @@ -9,7 +9,9 @@ import "cheats/Vm.sol"; contract Issue7481Test is DSTest { Vm constant vm = Vm(HEVM_ADDRESS); - function testFailTransact() public { + /// forge-config: default.allow_internal_expect_revert = true + function testRevertTransact() public { + vm.expectRevert("vm.createSelectFork: invalid rpc url: mainnet"); vm.createSelectFork("mainnet", 19514903); // Transfer some funds to sender of tx being transacted to ensure that it appears in journaled state @@ -17,6 +19,7 @@ contract Issue7481Test is DSTest { vm.transact(0xccfd66fc409a633a99b5b75b0e9a2040fcf562d03d9bee3fefc1a5c0eb49c999); // Revert the current call to ensure that revm can revert state journal + vm.expectRevert(); revert("HERE"); } } From 7c3bf09ce34822b704fc18db5b554dbf032f4535 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 31 Jan 2025 10:45:00 +0100 Subject: [PATCH 1910/1963] fix: use sequence for rollback (#9795) --- crates/anvil/core/src/eth/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 950b9fcfba864..587b73a3acaf1 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -778,7 +778,7 @@ pub enum EthRequest { Reorg(ReorgOptions), /// Rollback the chain - #[cfg_attr(feature = "serde", serde(rename = "anvil_rollback",))] + #[cfg_attr(feature = "serde", serde(rename = "anvil_rollback", with = "sequence"))] Rollback(Option), /// Wallet From 685631bb9964de8839fd6cdf22ba587fc6870549 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 31 Jan 2025 12:15:22 +0200 Subject: [PATCH 1911/1963] chore: ignore solady CI failure in win (#9797) --- crates/forge/tests/cli/ext_integration.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 23bd0bd29a566..8a60f722416fd 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -59,7 +59,10 @@ fn sablier_v2_core() { } // +// Fails on windows because "/*Transient*" does not skip transient contracts +// (should be "*/*Transient*"). #[test] +#[cfg_attr(windows, ignore = "Windows cannot skip transient pattern")] fn solady() { ExtTester::new("Vectorized", "solady", "de9aee59648862bb98affd578248d1e75c7073ad").run(); } From 3d480003b71d1cab59ba44191eed8905ded8ce37 Mon Sep 17 00:00:00 2001 From: "Daniel N. Werner" <1497784+dwerner@users.noreply.github.com> Date: Fri, 31 Jan 2025 03:55:45 -0800 Subject: [PATCH 1912/1963] fix(trace_filter): allow params to be object or array with len 1 (#9793) fix(trace_filter): change params objects to deserialize only an array --- crates/anvil/core/src/eth/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/core/src/eth/mod.rs b/crates/anvil/core/src/eth/mod.rs index 587b73a3acaf1..1dc2fac312e48 100644 --- a/crates/anvil/core/src/eth/mod.rs +++ b/crates/anvil/core/src/eth/mod.rs @@ -321,7 +321,7 @@ pub enum EthRequest { TraceBlock(BlockNumber), // Return filtered traces over blocks - #[cfg_attr(feature = "serde", serde(rename = "trace_filter",))] + #[cfg_attr(feature = "serde", serde(rename = "trace_filter", with = "sequence"))] TraceFilter(TraceFilter), // Custom endpoints, they're not extracted to a separate type out of serde convenience From 56c1670853d952220ea5d99725d41d63ab737a30 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:31:41 +0200 Subject: [PATCH 1913/1963] chore: point forge-std ext test to latest main (#9799) chore: point forgestd ext to latest --- crates/forge/tests/cli/ext_integration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index 8a60f722416fd..b2fd1808701ff 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -5,7 +5,7 @@ use foundry_test_utils::util::ExtTester; // #[test] fn forge_std() { - ExtTester::new("foundry-rs", "forge-std", "08d6af5d6c8a9a60e308b689cd19751876d321e0") + ExtTester::new("foundry-rs", "forge-std", "464587138602dd194ed0eb5aab15b4721859d422") // Skip fork tests. .args(["--nmc", "Fork"]) .run(); From 9517128c3c984772490001eac614e03cd616b588 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 31 Jan 2025 15:24:32 +0200 Subject: [PATCH 1914/1963] chore: generate release notes from latest stable (#9801) --- .github/changelog.json | 4 ++-- .github/workflows/release.yml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/changelog.json b/.github/changelog.json index aa548adc73777..6c84eb1b8e5d4 100644 --- a/.github/changelog.json +++ b/.github/changelog.json @@ -61,6 +61,6 @@ "template": "${{CHANGELOG}}\n## Other\n\n${{UNCATEGORIZED}}\n## Full Changelog:\n ${{RELEASE_DIFF}}", "pr_template": "- ${{TITLE}} (#${{NUMBER}}) by @${{AUTHOR}}", "empty_template": "- No changes", - "max_pull_requests": 100, - "max_back_track_time_days": 60 + "max_pull_requests": 500, + "max_back_track_time_days": 120 } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b093ba77a283d..179d668199488 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,7 @@ env: CARGO_TERM_COLOR: always IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} PROFILE: maxperf + STABLE_VERSION: 'v0.3.0' jobs: prepare: @@ -58,7 +59,7 @@ jobs: uses: mikepenz/release-changelog-builder-action@v4 with: configuration: "./.github/changelog.json" - fromTag: ${{ env.IS_NIGHTLY == 'true' && 'nightly' || '' }} + fromTag: ${{ env.IS_NIGHTLY == 'true' && 'nightly' || env.STABLE_VERSION }} toTag: ${{ steps.release_info.outputs.tag_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 871eaaa6d621c4fae67380bc8306d049ad5168b7 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 31 Jan 2025 15:53:13 +0100 Subject: [PATCH 1915/1963] chore: update version numbers for `v1.0.0-rc` (#9802) update version numbers for 1.0.0-rc --- Cargo.lock | 60 ++++++++++++++++++++++----------------------- Cargo.toml | 2 +- foundryup/foundryup | 2 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5c3706f53e9f..16be5d8aa7cd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -947,7 +947,7 @@ dependencies = [ [[package]] name = "anvil" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -1016,7 +1016,7 @@ dependencies = [ [[package]] name = "anvil-core" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -1040,7 +1040,7 @@ dependencies = [ [[package]] name = "anvil-rpc" -version = "0.3.1" +version = "1.0.0" dependencies = [ "serde", "serde_json", @@ -1048,7 +1048,7 @@ dependencies = [ [[package]] name = "anvil-server" -version = "0.3.1" +version = "1.0.0" dependencies = [ "anvil-rpc", "async-trait", @@ -2001,7 +2001,7 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cast" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -2089,7 +2089,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chisel" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3305,7 +3305,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "forge" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -3395,7 +3395,7 @@ dependencies = [ [[package]] name = "forge-doc" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-primitives", "derive_more", @@ -3418,7 +3418,7 @@ dependencies = [ [[package]] name = "forge-fmt" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-primitives", "ariadne", @@ -3434,7 +3434,7 @@ dependencies = [ [[package]] name = "forge-script" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-chains", "alloy-consensus", @@ -3479,7 +3479,7 @@ dependencies = [ [[package]] name = "forge-script-sequence" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-network", "alloy-primitives", @@ -3497,7 +3497,7 @@ dependencies = [ [[package]] name = "forge-sol-macro-gen" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-json-abi", "alloy-sol-macro-expander", @@ -3513,7 +3513,7 @@ dependencies = [ [[package]] name = "forge-verify" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3574,7 +3574,7 @@ dependencies = [ [[package]] name = "foundry-cheatcodes" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3621,7 +3621,7 @@ dependencies = [ [[package]] name = "foundry-cheatcodes-spec" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-sol-types", "foundry-macros", @@ -3632,7 +3632,7 @@ dependencies = [ [[package]] name = "foundry-cli" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-chains", "alloy-dyn-abi", @@ -3672,7 +3672,7 @@ dependencies = [ [[package]] name = "foundry-common" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-consensus", "alloy-contract", @@ -3726,7 +3726,7 @@ dependencies = [ [[package]] name = "foundry-common-fmt" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3854,7 +3854,7 @@ dependencies = [ [[package]] name = "foundry-config" -version = "0.3.1" +version = "1.0.0" dependencies = [ "Inflector", "alloy-chains", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "foundry-debugger" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-primitives", "crossterm", @@ -3909,7 +3909,7 @@ dependencies = [ [[package]] name = "foundry-evm" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -3936,7 +3936,7 @@ dependencies = [ [[package]] name = "foundry-evm-abi" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -3949,7 +3949,7 @@ dependencies = [ [[package]] name = "foundry-evm-core" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -3984,7 +3984,7 @@ dependencies = [ [[package]] name = "foundry-evm-coverage" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-primitives", "eyre", @@ -3999,7 +3999,7 @@ dependencies = [ [[package]] name = "foundry-evm-fuzz" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -4023,7 +4023,7 @@ dependencies = [ [[package]] name = "foundry-evm-traces" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -4075,7 +4075,7 @@ dependencies = [ [[package]] name = "foundry-linking" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-primitives", "foundry-compilers", @@ -4085,7 +4085,7 @@ dependencies = [ [[package]] name = "foundry-macros" -version = "0.3.1" +version = "1.0.0" dependencies = [ "proc-macro-error", "proc-macro2", @@ -4095,7 +4095,7 @@ dependencies = [ [[package]] name = "foundry-test-utils" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-primitives", "alloy-provider", @@ -4118,7 +4118,7 @@ dependencies = [ [[package]] name = "foundry-wallets" -version = "0.3.1" +version = "1.0.0" dependencies = [ "alloy-consensus", "alloy-dyn-abi", diff --git a/Cargo.toml b/Cargo.toml index 60155fd7a93f9..adb2ec5ad188f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.3.1" +version = "1.0.0" edition = "2021" # Remember to update clippy.toml as well rust-version = "1.83" diff --git a/foundryup/foundryup b/foundryup/foundryup index 72429b5b35d0c..2c8ae0605bfea 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -4,7 +4,7 @@ set -eo pipefail # NOTE: if you make modifications to this script, please increment the version number. # Major / minor: incremented for each stable release of Foundry. # Patch: incremented for each change between stable releases. -FOUNDRYUP_INSTALLER_VERSION="0.3.3" +FOUNDRYUP_INSTALLER_VERSION="1.0.0" BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} From 14e09e333637fc4ec4d78dca148dc0ce65bb835b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:09:22 +0100 Subject: [PATCH 1916/1963] feat(cast): update polygon testnet chain and add polygon zkevm chains (#9803) * feat: add polygon-amoy chain and remove polygon-mumbai * feat: add polygon zkevm mainnet and cardona testnet chains --- crates/cast/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 43f39e661d6c0..1139cd38a67c8 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -439,9 +439,13 @@ where "0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177" => "rinkeby", "0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a" => "goerli", "0x14c2283285a88fe5fce9bf5c573ab03d6616695d717b12a127188bcacfc743c4" => "kotti", - "0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b" => "polygon", - "0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7" => { - "polygon-mumbai" + "0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b" => "polygon-pos", + "0x7202b2b53c5a0836e773e319d18922cc756dd67432f9a1f65352b61f4406c697" => { + "polygon-pos-amoy-testnet" + } + "0x81005434635456a16f74ff7023fbe0bf423abbc8a8deb093ffff455c0ad3b741" => "polygon-zkevm", + "0x676c1a76a6c5855a32bdf7c61977a0d1510088a4eeac1330466453b3d08b60b9" => { + "polygon-zkevm-cardona-testnet" } "0x4f1dd23188aab3a76b463e4af801b52b1248ef073c648cbdc4c9333d3da79756" => "gnosis", "0xada44fd8d2ecab8b08f256af07ad3e777f17fb434f8f8e678b312f576212ba9a" => "chiado", From 8692e926198056d0228c1e166b1b6c34a5bed66c Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:43:48 +0200 Subject: [PATCH 1917/1963] chore: ci release on rc tag (#9805) --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 179d668199488..5a5a64f6ec387 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: tags: - "stable" + - "rc" - "v*.*.*" schedule: - cron: "0 0 * * *" From 60f0b692acae47a4933bb4a0bc4a29cab8831ba1 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 31 Jan 2025 18:53:49 +0100 Subject: [PATCH 1918/1963] chore: update pull request template (#9804) --- .github/PULL_REQUEST_TEMPLATE.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ef4a037ad501d..16e0182b117ac 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,8 +3,15 @@ Thank you for your Pull Request. Please provide a description above and review the requirements below. Bug fixes and new features should include tests. + +Contributors guide: https://github.com/foundry-rs/foundry/blob/master/CONTRIBUTING.md + +The contributors guide includes instructions for running rustfmt and building the +documentation. --> + + ## Motivation + +## PR Checklist + +- [ ] Added Tests +- [ ] Added Documentation +- [ ] Breaking changes \ No newline at end of file From f126beb0e2c9b3a837487efdb8dba47f1eba27be Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 2 Feb 2025 11:48:41 +0100 Subject: [PATCH 1919/1963] chore(deps): weekly `cargo update` (#9809) Locking 35 packages to latest compatible versions Updating alloy-chains v0.1.57 -> v0.1.58 Unchanged alloy-consensus v0.9.2 (available: v0.11.0) Unchanged alloy-contract v0.9.2 (available: v0.11.0) Unchanged alloy-eips v0.9.2 (available: v0.11.0) Unchanged alloy-genesis v0.9.2 (available: v0.11.0) Unchanged alloy-json-rpc v0.9.2 (available: v0.11.0) Unchanged alloy-network v0.9.2 (available: v0.11.0) Unchanged alloy-node-bindings v0.9.2 (available: v0.11.0) Unchanged alloy-provider v0.9.2 (available: v0.11.0) Unchanged alloy-pubsub v0.9.2 (available: v0.11.0) Unchanged alloy-rpc-client v0.9.2 (available: v0.11.0) Unchanged alloy-rpc-types v0.9.2 (available: v0.11.0) Unchanged alloy-serde v0.9.2 (available: v0.11.0) Unchanged alloy-signer v0.9.2 (available: v0.11.0) Unchanged alloy-signer-aws v0.9.2 (available: v0.11.0) Unchanged alloy-signer-gcp v0.9.2 (available: v0.11.0) Unchanged alloy-signer-ledger v0.9.2 (available: v0.11.0) Unchanged alloy-signer-local v0.9.2 (available: v0.11.0) Unchanged alloy-signer-trezor v0.9.2 (available: v0.11.0) Unchanged alloy-transport v0.9.2 (available: v0.11.0) Unchanged alloy-transport-http v0.9.2 (available: v0.11.0) Unchanged alloy-transport-ipc v0.9.2 (available: v0.11.0) Unchanged alloy-transport-ws v0.9.2 (available: v0.11.0) Updating async-trait v0.1.85 -> v0.1.86 Updating aws-sdk-kms v1.57.0 -> v1.58.0 Updating aws-sdk-sso v1.56.0 -> v1.57.0 Updating aws-sdk-ssooidc v1.57.1 -> v1.58.0 Updating aws-sdk-sts v1.57.0 -> v1.58.0 Unchanged axum v0.7.9 (available: v0.8.1) Unchanged backtrace v0.3.71 (available: v0.3.74) Updating bumpalo v3.16.0 -> v3.17.0 Updating cc v1.2.10 -> v1.2.11 Updating clap_complete v4.5.42 -> v4.5.44 Updating dyn-clone v1.0.17 -> v1.0.18 Unchanged foundry-fork-db v0.10.0 (available: v0.11.0) Unchanged gcloud-sdk v0.25.8 (available: v0.26.2) Adding getrandom v0.3.1 Updating httparse v1.9.5 -> v1.10.0 Updating hyper v1.5.2 -> v1.6.0 Updating indicatif v0.17.9 -> v0.17.11 Updating jiff v0.1.27 -> v0.1.28 Updating mdbook v0.4.43 -> v0.4.44 Updating miette v7.4.0 -> v7.5.0 Updating miette-derive v7.4.0 -> v7.5.0 Unchanged op-alloy-rpc-types v0.9.6 (available: v0.10.0) Removing phf_generator v0.10.0 Removing phf_shared v0.10.0 Unchanged proptest v1.5.0 (available: v1.6.0) Unchanged protobuf v3.3.0 (available: v3.7.1) Unchanged protobuf-support v3.3.0 (available: v3.7.1) Unchanged rand v0.8.5 (available: v0.9.0) Unchanged revm-inspectors v0.14.1 (available: v0.15.0) Updating rustls v0.23.21 -> v0.23.22 Updating rustls-pki-types v1.10.1 -> v1.11.0 Updating ryu v1.0.18 -> v1.0.19 Updating serde_json v1.0.137 -> v1.0.138 Removing siphasher v0.3.11 Unchanged solang-parser v0.3.3 (available: v0.3.4) Updating string_cache v0.8.7 -> v0.8.8 Updating string_cache_codegen v0.5.2 -> v0.5.3 Updating svm-rs v0.5.10 -> v0.5.11 Updating svm-rs-builds v0.5.10 -> v0.5.11 Updating syn v2.0.96 -> v2.0.97 Updating tempfile v3.15.0 -> v3.16.0 Updating toml_edit v0.22.22 -> v0.22.23 Updating unicode-ident v1.0.15 -> v1.0.16 Unchanged vergen v8.3.2 (available: v9.0.4) Adding wasi v0.13.3+wasi-0.2.2 Updating webpki-roots v0.26.7 -> v0.26.8 Removing winnow v0.6.24 Adding winnow v0.6.26 Adding winnow v0.7.0 Adding wit-bindgen-rt v0.33.0 note: to see how you depend on a package, run `cargo tree --invert --package @` Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 415 +++++++++++++++++++++++++++-------------------------- 1 file changed, 214 insertions(+), 201 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16be5d8aa7cd5..7d1257e806a2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,7 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.2.15", "once_cell", "version_check", "zerocopy", @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab9d1367c6ffb90c93fb4a9a4989530aa85112438c6f73a734067255d348469" +checksum = "5d0d6c784abf2e061139798d51299da278fc8f02d7b7546662b898d9b22ab5e9" dependencies = [ "alloy-primitives", "num_enum", @@ -155,7 +155,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow", + "winnow 0.6.26", ] [[package]] @@ -312,7 +312,7 @@ dependencies = [ "derive_arbitrary", "derive_more", "foldhash", - "getrandom", + "getrandom 0.2.15", "hashbrown 0.15.2", "indexmap 2.7.1", "itoa", @@ -410,7 +410,7 @@ checksum = "a40e1ef334153322fd878d07e86af7a529bcb86b2439525920a88eba87bcf943" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -682,7 +682,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -699,7 +699,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", "syn-solidity", "tiny-keccak", ] @@ -717,7 +717,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.96", + "syn 2.0.97", "syn-solidity", ] @@ -728,7 +728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74e60b084fe1aef8acecda2743ff2d93c18ff3eb67a2d3b12f62582a1e66ef5e" dependencies = [ "serde", - "winnow", + "winnow 0.6.26", ] [[package]] @@ -810,7 +810,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.2.0", - "rustls 0.23.21", + "rustls 0.23.22", "serde_json", "tokio", "tokio-tungstenite", @@ -992,7 +992,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 1.5.2", + "hyper 1.6.0", "itertools 0.14.0", "k256", "maili-consensus", @@ -1264,7 +1264,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -1286,18 +1286,18 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] name = "async-trait" -version = "0.1.85" +version = "0.1.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" +checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -1350,7 +1350,7 @@ checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -1428,9 +1428,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.57.0" +version = "1.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b2cd8354dcccf1ae003100a41c7b862837cfd7af14a42b1e3ed98a8c3e487b" +checksum = "40b7a24700ac548025a47a5c579886f5198895bb1eccd8964dfd71cd66c16912" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1450,9 +1450,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.56.0" +version = "1.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e057fdcb8842de9b83592a70f5b4da0ee10bc0ad278247da1425a742a444d7" +checksum = "c54bab121fe1881a74c338c5f723d1592bf3b53167f80268a1274f404e1acc38" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1472,9 +1472,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.57.1" +version = "1.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a120ade4a44691b3c5c2ff2fa61b14ed331fdc218397f61ab48d66593012ae2a" +checksum = "8c8234fd024f7ac61c4e44ea008029bde934250f371efe7d4a39708397b1080c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1494,9 +1494,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.57.0" +version = "1.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115fd4fb663817ed595a5ee4f1649d7aacd861d47462323cb37576ce89271b93" +checksum = "ba60e1d519d6f23a9df712c04fdeadd7872ac911c84b2f62a8bda92e129b7962" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1692,7 +1692,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-util", "itoa", "matchit", @@ -1884,7 +1884,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -1916,9 +1916,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "byte-slice-cast" @@ -2068,9 +2068,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.10" +version = "1.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" dependencies = [ "shlex", ] @@ -2200,9 +2200,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.42" +version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33a7e468e750fa4b6be660e8b5651ad47372e8fb114030b594c2d75d48c5ffd0" +checksum = "375f9d8255adeeedd51053574fd8d4ba875ea5fa558e86617b07f09f1680c8b6" dependencies = [ "clap", ] @@ -2226,7 +2226,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2332,7 +2332,7 @@ dependencies = [ "byteorder", "cfg-if", "const-hex", - "getrandom", + "getrandom 0.2.15", "hidapi-rusb", "js-sys", "log", @@ -2641,7 +2641,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2652,7 +2652,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2725,7 +2725,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2746,7 +2746,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2756,7 +2756,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2777,7 +2777,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", "unicode-xid", ] @@ -2886,7 +2886,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2911,7 +2911,7 @@ checksum = "8dc51d98e636f5e3b0759a39257458b22619cac7e96d932da6eeb052891bb67c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -2940,9 +2940,9 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "dyn-clone" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +checksum = "feeef44e73baff3a26d371801df019877a9866a8c493d315ab00177843314f35" [[package]] name = "ecdsa" @@ -3038,7 +3038,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -3353,7 +3353,7 @@ dependencies = [ "futures", "globset", "humantime-serde", - "hyper 1.5.2", + "hyper 1.6.0", "indicatif", "inferno", "itertools 0.14.0", @@ -3508,7 +3508,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -3777,7 +3777,7 @@ dependencies = [ "thiserror 2.0.11", "tokio", "tracing", - "winnow", + "winnow 0.6.26", "yansi", ] @@ -4090,7 +4090,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -4250,7 +4250,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -4299,7 +4299,7 @@ dependencies = [ "bytes", "chrono", "futures", - "hyper 1.5.2", + "hyper 1.6.0", "jsonwebtoken", "once_cell", "prost", @@ -4350,10 +4350,22 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.6", +] + [[package]] name = "gimli" version = "0.28.1" @@ -4371,7 +4383,7 @@ dependencies = [ "gix-utils", "itoa", "thiserror 1.0.69", - "winnow", + "winnow 0.6.26", ] [[package]] @@ -4392,7 +4404,7 @@ dependencies = [ "smallvec", "thiserror 1.0.69", "unicode-bom", - "winnow", + "winnow 0.6.26", ] [[package]] @@ -4495,7 +4507,7 @@ dependencies = [ "itoa", "smallvec", "thiserror 1.0.69", - "winnow", + "winnow 0.6.26", ] [[package]] @@ -4529,7 +4541,7 @@ dependencies = [ "gix-validate", "memmap2", "thiserror 1.0.69", - "winnow", + "winnow 0.6.26", ] [[package]] @@ -4788,7 +4800,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -4855,9 +4867,9 @@ checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" [[package]] name = "httpdate" @@ -4907,9 +4919,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", @@ -4950,9 +4962,9 @@ checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http 1.2.0", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-util", - "rustls 0.23.21", + "rustls 0.23.22", "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", @@ -4967,7 +4979,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.2", + "hyper 1.6.0", "hyper-util", "pin-project-lite", "tokio", @@ -4982,7 +4994,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-util", "native-tls", "tokio", @@ -5001,7 +5013,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.2", + "hyper 1.6.0", "pin-project-lite", "socket2", "tokio", @@ -5147,7 +5159,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -5229,7 +5241,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -5268,9 +5280,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.9" +version = "0.17.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" +checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" dependencies = [ "console", "number_prefix", @@ -5346,7 +5358,7 @@ dependencies = [ "indoc", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -5431,9 +5443,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85348106ab244d90fe2d70faad939b71c5dad1258e5da9116e176064fc6c078" +checksum = "c607c728e28764fecde611a2764a3a5db19ae21dcec46f292244f5cc5c085a81" dependencies = [ "jiff-tzdb-platform", "log", @@ -5770,9 +5782,9 @@ dependencies = [ [[package]] name = "mdbook" -version = "0.4.43" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe1f98b8d66e537d2f0ba06e7dec4f44001deec539a2d18bfc102d6a86189148" +checksum = "f9da1e54401fe5d45a664c57e112e70f18e8c5a73e268c179305b932ee864574" dependencies = [ "ammonia", "anyhow", @@ -5833,9 +5845,9 @@ dependencies = [ [[package]] name = "miette" -version = "7.4.0" +version = "7.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317f146e2eb7021892722af37cf1b971f0a70c8406f487e24952667616192c64" +checksum = "1a955165f87b37fd1862df2a59547ac542c77ef6d17c666f619d1ad22dd89484" dependencies = [ "cfg-if", "miette-derive", @@ -5845,13 +5857,13 @@ dependencies = [ [[package]] name = "miette-derive" -version = "7.4.0" +version = "7.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" +checksum = "bf45bf44ab49be92fd1227a3be6fc6f617f1a337c06af54981048574d8783147" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -5902,7 +5914,7 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] @@ -5914,7 +5926,7 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -5941,7 +5953,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6202,7 +6214,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6317,7 +6329,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6480,7 +6492,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6539,7 +6551,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6580,7 +6592,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_macros", - "phf_shared 0.11.3", + "phf_shared", ] [[package]] @@ -6589,18 +6601,8 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" dependencies = [ - "phf_generator 0.11.3", - "phf_shared 0.11.3", -] - -[[package]] -name = "phf_generator" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" -dependencies = [ - "phf_shared 0.10.0", - "rand", + "phf_generator", + "phf_shared", ] [[package]] @@ -6609,7 +6611,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ - "phf_shared 0.11.3", + "phf_shared", "rand", ] @@ -6619,20 +6621,11 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" dependencies = [ - "phf_generator 0.11.3", - "phf_shared 0.11.3", + "phf_generator", + "phf_shared", "proc-macro2", "quote", - "syn 2.0.96", -] - -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher 0.3.11", + "syn 2.0.97", ] [[package]] @@ -6641,7 +6634,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "siphasher 1.0.1", + "siphasher", ] [[package]] @@ -6681,7 +6674,7 @@ checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6781,7 +6774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6856,7 +6849,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6876,7 +6869,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", "version_check", "yansi", ] @@ -6940,7 +6933,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -6963,7 +6956,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -7063,7 +7056,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.21", + "rustls 0.23.22", "socket2", "thiserror 2.0.11", "tokio", @@ -7077,11 +7070,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", - "getrandom", + "getrandom 0.2.15", "rand", "ring", "rustc-hash", - "rustls 0.23.21", + "rustls 0.23.22", "rustls-pki-types", "slab", "thiserror 2.0.11", @@ -7157,7 +7150,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -7231,7 +7224,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom", + "getrandom 0.2.15", "libredox", "thiserror 1.0.69", ] @@ -7242,7 +7235,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ - "getrandom", + "getrandom 0.2.15", "libredox", "thiserror 2.0.11", ] @@ -7312,7 +7305,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-rustls 0.27.5", "hyper-tls", "hyper-util", @@ -7326,7 +7319,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.21", + "rustls 0.23.22", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7461,7 +7454,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "spin", "untrusted", @@ -7617,9 +7610,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.21" +version = "0.23.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +checksum = "9fb9263ab4eb695e42321db096e3b8fbd715a59b154d5c88d82db2175b681ba7" dependencies = [ "log", "once_cell", @@ -7674,9 +7667,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" dependencies = [ "web-time", ] @@ -7744,9 +7737,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "salsa20" @@ -7815,7 +7808,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8001,7 +7994,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8012,14 +8005,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] name = "serde_json" -version = "1.0.137" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "indexmap 2.7.1", "itoa", @@ -8056,7 +8049,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8102,7 +8095,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8252,12 +8245,6 @@ dependencies = [ "time", ] -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - [[package]] name = "siphasher" version = "1.0.1" @@ -8417,7 +8404,7 @@ checksum = "970d7c774741f786d62cab78290e47d845b0b9c0c9d094a1642aced1d7946036" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8523,26 +8510,25 @@ checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" [[package]] name = "string_cache" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +checksum = "938d512196766101d333398efde81bc1f37b00cb42c2f8350e5df639f040bbbe" dependencies = [ "new_debug_unreachable", - "once_cell", "parking_lot", - "phf_shared 0.10.0", + "phf_shared", "precomputed-hash", "serde", ] [[package]] name = "string_cache_codegen" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" +checksum = "244292f3441c89febe5b5bdfbb6863aeaf4f64da810ea3050fd927b27b8d92ce" dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", + "phf_generator", + "phf_shared", "proc-macro2", "quote", ] @@ -8581,7 +8567,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8605,9 +8591,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svm-rs" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2079b44b2dc358e0aa611988e806f92a0d1f174206566de745a4a422a8009c65" +checksum = "4197826bb07b996788b9860a95a1fe2c1307b2404a8c66f5ba825c42532b7c3c" dependencies = [ "const-hex", "dirs 5.0.1", @@ -8625,9 +8611,9 @@ dependencies = [ [[package]] name = "svm-rs-builds" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9379e64a7d61f2a288e97c4b7d80a5cdcc893f24a83b6ec0ec18ffd36d58c6e2" +checksum = "074faea21171905847a96135b3896e2e0b74373758ca07b96a41c646cc04a8e5" dependencies = [ "build_const", "const-hex", @@ -8649,9 +8635,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.96" +version = "2.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "5dabd04e3b9a8c3c03d5e743f5ef5e1207befc9de704d477f7198cc28049763e" dependencies = [ "proc-macro2", "quote", @@ -8667,7 +8653,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8687,7 +8673,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8698,13 +8684,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.15.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" dependencies = [ "cfg-if", "fastrand", - "getrandom", + "getrandom 0.3.1", "once_cell", "rustix", "windows-sys 0.59.0", @@ -8797,7 +8783,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8808,7 +8794,7 @@ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8943,7 +8929,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -8972,7 +8958,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.21", + "rustls 0.23.22", "tokio", ] @@ -9008,7 +8994,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.21", + "rustls 0.23.22", "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", @@ -9062,15 +9048,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" dependencies = [ "indexmap 2.7.1", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.7.0", ] [[package]] @@ -9088,7 +9074,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-timeout", "hyper-util", "percent-encoding", @@ -9217,7 +9203,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -9334,7 +9320,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.21", + "rustls 0.23.22", "rustls-pki-types", "sha1", "thiserror 1.0.69", @@ -9400,9 +9386,9 @@ checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" [[package]] name = "unicode-ident" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11cd88e12b17c6494200a9c1b683a04fcac9573ed74cd1b62aeb2727c5592243" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "unicode-linebreak" @@ -9513,7 +9499,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom", + "getrandom 0.2.15", "serde", ] @@ -9523,7 +9509,7 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" dependencies = [ - "getrandom", + "getrandom 0.2.15", "serde", ] @@ -9606,6 +9592,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -9628,7 +9623,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", "wasm-bindgen-shared", ] @@ -9663,7 +9658,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9789,9 +9784,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.7" +version = "0.26.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" +checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" dependencies = [ "rustls-pki-types", ] @@ -9908,7 +9903,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -9919,7 +9914,7 @@ checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -9930,7 +9925,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -9941,7 +9936,7 @@ checksum = "cb26fd936d991781ea39e87c3a27285081e3c0da5ca0fcbc02d368cc6f52ff01" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -10206,9 +10201,18 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" -version = "0.6.24" +version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +checksum = "1e90edd2ac1aa278a5c4599b1d89cf03074b610800f866d4026dc199d7929a28" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" dependencies = [ "memchr", ] @@ -10219,6 +10223,15 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.8.0", +] + [[package]] name = "write16" version = "1.0.0" @@ -10294,7 +10307,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", "synstructure", ] @@ -10316,7 +10329,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -10336,7 +10349,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", "synstructure", ] @@ -10357,7 +10370,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] @@ -10379,7 +10392,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.97", ] [[package]] From 79e3ee85fce7be7e045ee443da57bd89582125a2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 2 Feb 2025 12:24:56 +0100 Subject: [PATCH 1920/1963] chore: replace maili with op-alloy (#9810) --- Cargo.lock | 18 ++---------------- Cargo.toml | 2 +- crates/anvil/Cargo.toml | 2 +- crates/anvil/core/Cargo.toml | 2 +- crates/anvil/core/src/eth/transaction/mod.rs | 2 +- .../anvil/core/src/eth/transaction/optimism.rs | 2 +- crates/anvil/src/eth/backend/mem/mod.rs | 2 +- crates/anvil/src/eth/sign.rs | 2 +- 8 files changed, 9 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d1257e806a2c..8929a2d42035c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -995,7 +995,7 @@ dependencies = [ "hyper 1.6.0", "itertools 0.14.0", "k256", - "maili-consensus", + "op-alloy-consensus", "op-alloy-rpc-types", "parking_lot", "rand", @@ -1030,7 +1030,7 @@ dependencies = [ "bytes", "foundry-common", "foundry-evm", - "maili-consensus", + "op-alloy-consensus", "rand", "revm", "serde", @@ -5715,20 +5715,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" -[[package]] -name = "maili-consensus" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6c278346ab9cfef7688510e28a042d8a23c953380e7361a1286920ccbd0d847" -dependencies = [ - "alloy-consensus", - "alloy-eips", - "alloy-primitives", - "alloy-rlp", - "alloy-serde", - "serde", -] - [[package]] name = "maplit" version = "1.0.2" diff --git a/Cargo.toml b/Cargo.toml index adb2ec5ad188f..00adb3ed64642 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,8 +225,8 @@ alloy-rlp = "0.3" alloy-trie = "0.7.0" ## op-alloy +op-alloy-consensus = "0.9.0" op-alloy-rpc-types = "0.9.0" -maili-consensus = "0.1.6" ## cli anstream = "0.6" diff --git a/crates/anvil/Cargo.toml b/crates/anvil/Cargo.toml index e4add59916b0d..4b6356d981dae 100644 --- a/crates/anvil/Cargo.toml +++ b/crates/anvil/Cargo.toml @@ -60,7 +60,7 @@ alloy-transport.workspace = true alloy-chains.workspace = true alloy-genesis.workspace = true alloy-trie.workspace = true -maili-consensus = { workspace = true, features = ["serde"] } +op-alloy-consensus = { workspace = true, features = ["serde"] } # axum related axum.workspace = true diff --git a/crates/anvil/core/Cargo.toml b/crates/anvil/core/Cargo.toml index aeb6de3bd4f3d..dacc7f20e0ea3 100644 --- a/crates/anvil/core/Cargo.toml +++ b/crates/anvil/core/Cargo.toml @@ -30,7 +30,7 @@ alloy-eips.workspace = true alloy-consensus = { workspace = true, features = ["k256", "kzg"] } alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] } alloy-trie.workspace = true -maili-consensus = { workspace = true, features = ["serde"] } +op-alloy-consensus = { workspace = true, features = ["serde"] } alloy-network.workspace = true serde = { workspace = true, optional = true } serde_json.workspace = true diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index c7126af9218f9..38eda60405d41 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -22,7 +22,7 @@ use alloy_rpc_types::{ use alloy_serde::{OtherFields, WithOtherFields}; use bytes::BufMut; use foundry_evm::traces::CallTraceNode; -use maili_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; +use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; use revm::{ interpreter::InstructionResult, primitives::{OptimismFields, TxEnv}, diff --git a/crates/anvil/core/src/eth/transaction/optimism.rs b/crates/anvil/core/src/eth/transaction/optimism.rs index 3fa3ad1c43d05..6bb4b2abb8a4f 100644 --- a/crates/anvil/core/src/eth/transaction/optimism.rs +++ b/crates/anvil/core/src/eth/transaction/optimism.rs @@ -1,6 +1,6 @@ use alloy_primitives::{Address, Bytes, TxKind, B256, U256}; use alloy_rlp::{Decodable, Encodable, Error as DecodeError, Header as RlpHeader}; -use maili_consensus::TxDeposit; +use op_alloy_consensus::TxDeposit; use serde::{Deserialize, Serialize}; pub const DEPOSIT_TX_TYPE_ID: u8 = 0x7E; diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index b7cd30b63c3d4..127eae8e66225 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -93,7 +93,7 @@ use foundry_evm::{ traces::TracingInspectorConfig, }; use futures::channel::mpsc::{unbounded, UnboundedSender}; -use maili_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; +use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID}; use parking_lot::{Mutex, RwLock}; use revm::{ db::WrapDatabaseRef, diff --git a/crates/anvil/src/eth/sign.rs b/crates/anvil/src/eth/sign.rs index 275ff106929ab..e2ea036a0cafb 100644 --- a/crates/anvil/src/eth/sign.rs +++ b/crates/anvil/src/eth/sign.rs @@ -8,7 +8,7 @@ use alloy_signer_local::PrivateKeySigner; use anvil_core::eth::transaction::{ optimism::DepositTransaction, TypedTransaction, TypedTransactionRequest, }; -use maili_consensus::TxDeposit; +use op_alloy_consensus::TxDeposit; /// A transaction signer #[async_trait::async_trait] From 07db82e4cec08f75b8a04cec218639f157872d0c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 2 Feb 2025 14:13:44 +0100 Subject: [PATCH 1921/1963] chore(deps): bump alloy 0.11 (#9798) * wip: bump alloy * wip * fix: unused fields * fixes * fmt * chore: nextest config * update tests * update tests * fix --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 443 ++++++++++-------- Cargo.toml | 54 +-- crates/anvil/core/src/eth/transaction/mod.rs | 28 +- crates/anvil/src/config.rs | 4 +- crates/anvil/src/eth/api.rs | 8 +- crates/anvil/src/eth/backend/mem/mod.rs | 23 +- crates/anvil/src/tasks/mod.rs | 21 +- crates/anvil/tests/it/utils.rs | 24 +- crates/cast/bin/cmd/send.rs | 3 +- crates/cast/bin/cmd/storage.rs | 5 +- crates/cast/bin/tx.rs | 34 +- crates/cast/src/lib.rs | 19 +- crates/cast/tests/cli/main.rs | 6 +- crates/cli/Cargo.toml | 1 - crates/cli/src/utils/abi.rs | 8 +- crates/cli/src/utils/mod.rs | 9 +- crates/common/fmt/src/ui.rs | 11 +- crates/common/src/ens.rs | 14 +- crates/common/src/provider/mod.rs | 11 +- .../common/src/provider/runtime_transport.rs | 23 +- crates/common/src/transactions.rs | 5 +- crates/evm/core/Cargo.toml | 1 - crates/evm/core/src/fork/init.rs | 4 +- crates/evm/core/src/fork/multi.rs | 7 +- crates/forge/bin/cmd/create.rs | 105 +---- crates/forge/tests/cli/config.rs | 1 + crates/forge/tests/cli/odyssey.rs | 1 - crates/forge/tests/cli/script.rs | 86 ++-- crates/forge/tests/cli/test_cmd.rs | 86 ++-- .../forge/tests/fixtures/colored_traces.svg | 14 +- crates/script/Cargo.toml | 1 - crates/script/src/broadcast.rs | 9 +- crates/test-utils/src/lib.rs | 4 +- crates/test-utils/src/util.rs | 24 +- crates/wallets/Cargo.toml | 2 +- 35 files changed, 494 insertions(+), 605 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8929a2d42035c..0ed5b608a718a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4138dc275554afa6f18c4217262ac9388790b2fc393c2dfe03c51d357abf013" +checksum = "ce20c85f6b24a5da40b2350a748e348417f0465dedbb523a4d149143bc4a41ce" dependencies = [ "alloy-eips", "alloy-primitives", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa04e1882c31288ce1028fdf31b6ea94cfa9eafa2e497f903ded631c8c6a42c" +checksum = "8e23af02ccded0031ef2b70df4fe9965b1c742c5d5384c8c767ae0311f7e62b9" dependencies = [ "alloy-consensus", "alloy-eips", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f21886c1fea0626f755a49b2ac653b396fb345233f6170db2da3d0ada31560c" +checksum = "71c7a59f261333db00fa10a3de9480f31121bb919ad38487040d7833d5982203" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9138f4f0912793642d453523c3116bd5d9e11de73b70177aa7cb3e94b98ad2" +checksum = "7f2d547eba3f2d331b0e08f64a24e202f66d4f291e2a3e0073914c0e1400ced3" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -155,7 +155,19 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.6.26", + "winnow 0.7.0", +] + +[[package]] +name = "alloy-eip2124" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "675264c957689f0fd75f5993a73123c2cc3b5c235a38f5b9037fe6c826bfb2c0" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "crc", + "thiserror 2.0.11", ] [[package]] @@ -188,15 +200,17 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52dd5869ed09e399003e0e0ec6903d981b2a92e74c5d37e6b40890bad2517526" +checksum = "7149e011edbd588f6df6564b369c75f6b538d76db14053d95e0b43b2d92e4266" dependencies = [ + "alloy-eip2124", "alloy-eip2930", "alloy-eip7702", "alloy-primitives", "alloy-rlp", "alloy-serde", + "auto_impl", "c-kzg", "derive_more", "once_cell", @@ -206,9 +220,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d2a7fe5c1a9bd6793829ea21a636f30fc2b3f5d2e7418ba86d96e41dd1f460" +checksum = "acaec0cc4c1489d61d6f33d0c3dd522c750025f4b5c8f59cd546221e4df660e5" dependencies = [ "alloy-eips", "alloy-primitives", @@ -219,9 +233,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24acd2f5ba97c7a320e67217274bc81fe3c3174b8e6144ec875d9d54e760e278" +checksum = "d62cf1b25f5a50ca2d329b0b4aeb0a0dedeaf225ad3c5099d83b1a4c4616186e" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -231,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2008bedb8159a255b46b7c8614516eda06679ea82f620913679afbd8031fea72" +checksum = "c0c5c9651fd20a2fd4a57606b6a570d1c17ab86e686b962b2f1ecac68b51e020" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -245,9 +259,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4556f01fe41d0677495df10a648ddcf7ce118b0e8aa9642a0e2b6dd1fb7259de" +checksum = "b02ed56783fb2c086a4ac8961175dd6d3ad163e6cf6125f0b83f7de03379b607" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -270,9 +284,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31c3c6b71340a1d076831823f09cb6e02de01de5c6630a9631bdb36f947ff80" +checksum = "a0624cfa9311aa8283cd3bf5eed883d0d1e823e2a4d57b30e1b49af4b3678a6b" dependencies = [ "alloy-consensus", "alloy-eips", @@ -283,9 +297,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4520cd4bc5cec20c32c98e4bc38914c7fb96bf4a712105e44da186a54e65e3ba" +checksum = "c96f1a87e3b2842d6a35bbebedf2bd48a49ee757ec63d0cfc1f3cb86338e972c" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -300,9 +314,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec878088ec6283ce1e90d280316aadd3d6ce3de06ff63d68953c855e7e447e92" +checksum = "bc1360603efdfba91151e623f13a4f4d3dc4af4adc1cbd90bf37c81e84db4c77" dependencies = [ "alloy-rlp", "arbitrary", @@ -331,9 +345,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22c4441b3ebe2d77fa9cf629ba68c3f713eb91779cff84275393db97eddd82" +checksum = "07c68df5354225da542efeb6d9388b65773b3304309b437416146e9d1e2bc1bd" dependencies = [ "alloy-chains", "alloy-consensus", @@ -358,11 +372,10 @@ dependencies = [ "dashmap", "futures", "futures-utils-wasm", - "lru", + "lru 0.13.0", "parking_lot", "pin-project 1.1.8", "reqwest", - "schnellru", "serde", "serde_json", "thiserror 2.0.11", @@ -374,9 +387,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2269fd635f7b505f27c63a3cb293148cd02301efce4c8bdd9ff54fbfc4a20e23" +checksum = "7ef6ef167ea24e7aac569dfd90b668c1f7dca0e48214e70364586d5341a89431" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -410,14 +423,14 @@ checksum = "a40e1ef334153322fd878d07e86af7a529bcb86b2439525920a88eba87bcf943" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] name = "alloy-rpc-client" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06a292b37e182e514903ede6e623b9de96420e8109ce300da288a96d88b7e4b" +checksum = "0371aae9b44a35e374c94c7e1df5cbccf0f52b2ef7c782291ed56e86d88ec106" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -441,9 +454,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9383845dd924939e7ab0298bbfe231505e20928907d7905aa3bf112287305e06" +checksum = "1428d64569961b00373c503a3de306656e94ef1f2a474e93fd41a6daae0d6ac7" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -457,9 +470,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11495cb8c8d3141fc27556a4c9188b81531ad5ec3076a0394c61a6dcfbce9f34" +checksum = "d721727cc493a58bd197a3ebbd42b88c0393c1f30da905bb7a31686c820f4c2d" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -469,9 +482,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca445cef0eb6c2cf51cfb4e214fbf1ebd00893ae2e6f3b944c8101b07990f988" +checksum = "66e119337400d8b0348e1576ab37ffa56d1a04cbc977a84d4fa0a527d7cb0c21" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -480,9 +493,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "358d6a8d7340b9eb1a7589a6c1fb00df2c9b26e90737fa5ed0108724dd8dac2c" +checksum = "fea98e1c4ac005ffe5f8691164f5f2ef5ee8dda50b1fdba173d44892141909e2" dependencies = [ "alloy-primitives", "serde", @@ -490,9 +503,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f821f30344862a0b6eb9a1c2eb91dfb2ff44c7489f37152a526cdcab79264" +checksum = "b582c59b6f493d9b15bea32f44f662fa6749e5464ef5305d8429a864ace60684" dependencies = [ "alloy-consensus", "alloy-eips", @@ -508,9 +521,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0938bc615c02421bd86c1733ca7205cc3d99a122d9f9bff05726bd604b76a5c2" +checksum = "8a4a43d8b1344e3ef115ed7a2cee934876e4a64d2b9d9bee8738f9806900757e" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -520,7 +533,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", - "itertools 0.13.0", + "itertools 0.14.0", "serde", "serde_json", "thiserror 2.0.11", @@ -528,9 +541,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd38207e056cc7d1372367fbb4560ddf9107cbd20731743f641246bf0dede149" +checksum = "ac383c60b09660b7695a4f210cd11ab05887d058dfc669efd814904dbbaead82" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -542,9 +555,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7fd456a3fa9ea732d1c0611c9d52b5326ee29f4d02d01b07dac453ed68d9eb5" +checksum = "ac39b1a583bb59dcf7d856604867acf704a7cf70b76a42f895652d566aa6f17c" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -554,9 +567,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae0465c71d4dced7525f408d84873aeebb71faf807d22d74c4a426430ccd9b55" +checksum = "86aa42c36e3c0db5bd9a7314e98aa261a61d5e3d6a0bd7e51fb8b0a3d6438481" dependencies = [ "alloy-primitives", "serde", @@ -565,9 +578,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bfa395ad5cc952c82358d31e4c68b27bf4a89a5456d9b27e226e77dac50e4ff" +checksum = "c613222abd016e03ba548f41db938a2c99108b59c0c66ca105eab1b7a2e6b40a" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -581,9 +594,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eb06810c34427d499863817eb506acf57cb9ded9224b374116cae4e22dbd4e9" +checksum = "729df0003039c90f66f52a67b3dda8dbdcb6439585eeb72f0e0019950329a6ed" dependencies = [ "alloy-consensus", "alloy-network", @@ -599,9 +612,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d629e63fec8802ad53706d46e8eceeeae2b135c6648d0de41669a523bf17df4a" +checksum = "39653f75284f17300bc8bbe74925db0adf59850f6c674c2db0ed6fd3b7a23ee0" dependencies = [ "alloy-consensus", "alloy-network", @@ -617,9 +630,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b426789566a19252cb46b757d91543a6f8e70330c72f312b86c5878595d092ef" +checksum = "107758cf1e537461551b56260253338999bc1474e92fb765f6f7c8a57d968ae4" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -637,9 +650,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdc63ce9eda1283fcbaca66ba4a414b841c0e3edbeef9c86a71242fc9e84ccc" +checksum = "39163b956c81e8fd9605194d6b5b92dd93b0e0252810e69f9a4cebe3a8614f46" dependencies = [ "alloy-consensus", "alloy-network", @@ -656,9 +669,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7d0c000abd591c9cceac5c07f785f101c9a8c879c6ccd300feca1ae03bdef6" +checksum = "2131526594806a231502c0c57ddca0b63cfc9384c677c2a8cf01b49b335b546a" dependencies = [ "alloy-consensus", "alloy-network", @@ -673,23 +686,23 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d039d267aa5cbb7732fa6ce1fd9b5e9e29368f580f80ba9d7a8450c794de4b2" +checksum = "13f28f2131dc3a7b8e2cda882758ad4d5231ca26281b9861d4b18c700713e2da" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620ae5eee30ee7216a38027dec34e0585c55099f827f92f50d11e3d2d3a4a954" +checksum = "1ee2da033256a3b27131c030933eab0460a709fbcc4d4bd57bf9a5650b2441c5" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -699,16 +712,16 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad9f7d057e00f8c5994e4ff4492b76532c51ead39353aa2ed63f8c50c0f4d52e" +checksum = "4e9d9918b0abb632818bf27e2dfb86b209be8433baacf22100b190bbc0904bd4" dependencies = [ "alloy-json-abi", "const-hex", @@ -717,25 +730,25 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.97", + "syn 2.0.98", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e60b084fe1aef8acecda2743ff2d93c18ff3eb67a2d3b12f62582a1e66ef5e" +checksum = "a971129d242338d92009470a2f750d3b2630bc5da00a40a94d51f5d456b5712f" dependencies = [ "serde", - "winnow 0.6.26", + "winnow 0.7.0", ] [[package]] name = "alloy-sol-types" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1382302752cd751efd275f4d6ef65877ddf61e0e6f5ac84ef4302b79a33a31a" +checksum = "75f306fc801b3aa2e3c4785b7b5252ec8b19f77b30e3b75babfd23849c81bd8c" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -746,13 +759,12 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17722a198f33bbd25337660787aea8b8f57814febb7c746bc30407bdfc39448" +checksum = "40e2f34fcd849676c8fe274a6e72f0664dfede7ce06d12daa728d2e72f1b4393" dependencies = [ "alloy-json-rpc", "base64 0.22.1", - "futures-util", "futures-utils-wasm", "serde", "serde_json", @@ -766,9 +778,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1509599021330a31c4a6816b655e34bf67acb1cc03c564e09fd8754ff6c5de" +checksum = "6e291c97c3c0ebb5d03c34e3a55c0f7c5bfa307536a2efaaa6fae4b3a4d09851" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -781,9 +793,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4da44bc9a5155ab599666d26decafcf12204b72a80eeaba7c5e234ee8ac205" +checksum = "8d3e991f40d2d81c6ee036a34d81127bfec5fadf7e649791b5225181126c1959" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -802,9 +814,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58011745b2f17b334db40df9077d75b181f78360a5bc5c35519e15d4bfce15e2" +checksum = "fc8c544f7dc764735664756805f8b8b770020cc295a0b96b09cbefd099c172c7" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -813,7 +825,7 @@ dependencies = [ "rustls 0.23.22", "serde_json", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.26.1", "tracing", "ws_stream_wasm", ] @@ -1264,7 +1276,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -1286,7 +1298,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -1297,7 +1309,7 @@ checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -1350,7 +1362,7 @@ checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -1708,7 +1720,7 @@ dependencies = [ "sha1", "sync_wrapper", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.24.0", "tower 0.5.2", "tower-layer", "tower-service", @@ -1884,7 +1896,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2226,7 +2238,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2505,6 +2517,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.2" @@ -2641,7 +2668,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2652,7 +2679,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2725,7 +2752,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2746,7 +2773,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2756,7 +2783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2777,7 +2804,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", "unicode-xid", ] @@ -2886,7 +2913,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -2911,7 +2938,7 @@ checksum = "8dc51d98e636f5e3b0759a39257458b22619cac7e96d932da6eeb052891bb67c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -3038,7 +3065,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -3447,7 +3474,6 @@ dependencies = [ "alloy-rpc-types", "alloy-serde", "alloy-signer", - "alloy-transport", "clap", "dialoguer", "dunce", @@ -3508,7 +3534,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -3641,7 +3667,6 @@ dependencies = [ "alloy-primitives", "alloy-provider", "alloy-rlp", - "alloy-transport", "clap", "color-eyre", "dotenvy", @@ -3746,15 +3771,15 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db0e0897aa7088fa1340d58c18a11b5be7f3a76e582c947a9bd86ee440e735b2" +checksum = "203e96bd596350ec8d9aedfca7eff573e9347e2b2fe50eedfbf78532dabe418e" dependencies = [ "alloy-json-abi", "alloy-primitives", "auto_impl", "derive_more", - "dirs 5.0.1", + "dirs 6.0.0", "dyn-clone", "foundry-compilers-artifacts", "foundry-compilers-core", @@ -3777,15 +3802,15 @@ dependencies = [ "thiserror 2.0.11", "tokio", "tracing", - "winnow 0.6.26", + "winnow 0.7.0", "yansi", ] [[package]] name = "foundry-compilers-artifacts" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8956905969f3610dc048a7748a8b8ffcefd5d868aeebf5769012574f9ee36077" +checksum = "be8ba2ccf8a4bf7730b2ad2815984c1af8e5b8c492420f1cf1d26a8be29cc9e4" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3793,9 +3818,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233e93be9079903ed3e72970cf28e156f69772782281d08a4d97a3dfa0693675" +checksum = "5889eeb7d6729afbbbb1313b22e8f58aa909fcf38aa6b2f9c9b2443ca0765c59" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3817,9 +3842,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b19f32fc5479271e31f7977a36ff7c0359e3ae2884cb3aaab95a28d2087245c4" +checksum = "b01048f354b4e98bf5fb4810e0607c87d4b8cc7fe6305a42103ce192e33b2da7" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3832,9 +3857,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb8c5859a768b990f10bc17cd76e20d77965c352fd84822b5234345103c9dd88" +checksum = "079b80a4f188af9c273b081547d1a95a0a33f782851a99e21aa4eba06e47fa34" dependencies = [ "alloy-primitives", "cfg-if", @@ -3960,7 +3985,6 @@ dependencies = [ "alloy-provider", "alloy-rpc-types", "alloy-sol-types", - "alloy-transport", "auto_impl", "eyre", "foundry-cheatcodes-spec", @@ -4051,16 +4075,15 @@ dependencies = [ [[package]] name = "foundry-fork-db" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89a794c8a78ba20568a0c86b035768da7e81fed3c51cecea57f81523123cbcfa" +checksum = "a8e9c37fd94d2b6ac89c9b83ec3e4fca43fa04866002da250aa97255ff261778" dependencies = [ "alloy-consensus", "alloy-primitives", "alloy-provider", "alloy-rpc-types", "alloy-serde", - "alloy-transport", "eyre", "futures", "parking_lot", @@ -4090,7 +4113,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -4250,7 +4273,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -4291,9 +4314,9 @@ checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" [[package]] name = "gcloud-sdk" -version = "0.25.8" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0775bfa745cdf7287ae9765a685a813b91049b6b6d5ca3de20a3d5d16a80d8b2" +checksum = "7a771db7ee43ad84638d0e6131cb514e402af6a5a96051f4425d66dc0ee527d8" dependencies = [ "async-trait", "bytes", @@ -4695,12 +4718,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" - [[package]] name = "hashbrown" version = "0.14.5" @@ -4800,7 +4817,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -5159,7 +5176,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -5241,7 +5258,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -5358,7 +5375,7 @@ dependencies = [ "indoc", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -5709,6 +5726,15 @@ dependencies = [ "hashbrown 0.15.2", ] +[[package]] +name = "lru" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" +dependencies = [ + "hashbrown 0.15.2", +] + [[package]] name = "mac" version = "0.1.1" @@ -5849,7 +5875,7 @@ checksum = "bf45bf44ab49be92fd1227a3be6fc6f617f1a337c06af54981048574d8783147" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -5939,7 +5965,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6200,7 +6226,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6248,9 +6274,9 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "op-alloy-consensus" -version = "0.9.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28dc4e397dd8969f7f98ea6454a5c531349a58c76e12448b0c2de6581df7b8c" +checksum = "36e8e67b41afd338096ca31f24c5e7800797858b963490be2e8971d17d733f49" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6264,9 +6290,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.9.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9c83c664b953d474d6b58825800b6ff1d61876a686407e646cbf76891c1f9b" +checksum = "06d55acda15bd273d1d9a052536cf46c3520f597ac9884376c9c56241f2f5e9b" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6315,7 +6341,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6478,7 +6504,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6537,7 +6563,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6611,7 +6637,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6660,7 +6686,7 @@ checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6760,7 +6786,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6835,7 +6861,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6855,7 +6881,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", "version_check", "yansi", ] @@ -6919,7 +6945,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -6942,7 +6968,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -7161,7 +7187,7 @@ dependencies = [ "indoc", "instability", "itertools 0.13.0", - "lru", + "lru 0.12.5", "paste", "strum", "unicode-segmentation", @@ -7347,9 +7373,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc873bc873e12a1723493e1a35804fa79b673a0bfb1c19cfee659d46def8be42" +checksum = "6d87cdf1c0d878b48423f8a86232950657abaf72a2d0d14af609467542313b1a" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -7794,18 +7820,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.97", -] - -[[package]] -name = "schnellru" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" -dependencies = [ - "ahash", - "cfg-if", - "hashbrown 0.13.2", + "syn 2.0.98", ] [[package]] @@ -7980,7 +7995,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -7991,7 +8006,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8035,7 +8050,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8081,7 +8096,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8390,7 +8405,7 @@ checksum = "970d7c774741f786d62cab78290e47d845b0b9c0c9d094a1642aced1d7946036" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8553,7 +8568,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8621,9 +8636,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.97" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dabd04e3b9a8c3c03d5e743f5ef5e1207befc9de704d477f7198cc28049763e" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -8632,14 +8647,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84e4d83a0a6704561302b917a932484e1cae2d8c6354c64be8b7bac1c1fe057" +checksum = "b7f6a4b9002584ea56d0a19713b65da44cbbf6070aca9ae0360577cba5c4db68" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8659,7 +8674,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8769,7 +8784,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8780,7 +8795,7 @@ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8915,7 +8930,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -8977,6 +8992,18 @@ name = "tokio-tungstenite" version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.24.0", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4bf6fecd69fcdede0ec680aaf474cdab988f9de6bc73d3758f0160e3b7025a" dependencies = [ "futures-util", "log", @@ -8984,7 +9011,7 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", - "tungstenite", + "tungstenite 0.26.1", "webpki-roots", ] @@ -9189,7 +9216,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -9298,6 +9325,24 @@ name = "tungstenite" version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.2.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror 1.0.69", + "utf-8", +] + +[[package]] +name = "tungstenite" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413083a99c579593656008130e29255e54dcaae495be556cc26888f211648c24" dependencies = [ "byteorder", "bytes", @@ -9309,7 +9354,7 @@ dependencies = [ "rustls 0.23.22", "rustls-pki-types", "sha1", - "thiserror 1.0.69", + "thiserror 2.0.11", "utf-8", ] @@ -9609,7 +9654,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", "wasm-bindgen-shared", ] @@ -9644,7 +9689,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9889,7 +9934,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -9900,7 +9945,7 @@ checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -9911,7 +9956,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -9922,7 +9967,7 @@ checksum = "cb26fd936d991781ea39e87c3a27285081e3c0da5ca0fcbc02d368cc6f52ff01" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -10293,7 +10338,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", "synstructure", ] @@ -10315,7 +10360,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -10335,7 +10380,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", "synstructure", ] @@ -10356,7 +10401,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] @@ -10378,7 +10423,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.97", + "syn 2.0.98", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 00adb3ed64642..aa401962461c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,39 +172,39 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.11.0", default-features = false } foundry-compilers = { version = "0.13.0", default-features = false } -foundry-fork-db = "0.10.0" +foundry-fork-db = "0.11.0" solang-parser = "=0.3.3" solar-parse = { version = "=0.1.1", default-features = false } ## revm revm = { version = "19.4.0", default-features = false } revm-primitives = { version = "15.1.0", default-features = false } -revm-inspectors = { version = "0.14.1", features = ["serde"] } +revm-inspectors = { version = "0.15.0", features = ["serde"] } ## alloy -alloy-consensus = { version = "0.9.0", default-features = false } -alloy-contract = { version = "0.9.0", default-features = false } -alloy-eips = { version = "0.9.0", default-features = false } -alloy-genesis = { version = "0.9.0", default-features = false } -alloy-json-rpc = { version = "0.9.0", default-features = false } -alloy-network = { version = "0.9.0", default-features = false } -alloy-provider = { version = "0.9.0", default-features = false } -alloy-pubsub = { version = "0.9.0", default-features = false } -alloy-rpc-client = { version = "0.9.0", default-features = false } -alloy-rpc-types = { version = "0.9.0", default-features = true } -alloy-serde = { version = "0.9.0", default-features = false } -alloy-signer = { version = "0.9.0", default-features = false } -alloy-signer-aws = { version = "0.9.0", default-features = false } -alloy-signer-gcp = { version = "0.9.0", default-features = false } -alloy-signer-ledger = { version = "0.9.0", default-features = false } -alloy-signer-local = { version = "0.9.0", default-features = false } -alloy-signer-trezor = { version = "0.9.0", default-features = false } -alloy-transport = { version = "0.9.0", default-features = false } -alloy-transport-http = { version = "0.9.0", default-features = false } -alloy-transport-ipc = { version = "0.9.0", default-features = false } -alloy-transport-ws = { version = "0.9.0", default-features = false } -alloy-node-bindings = { version = "0.9.0", default-features = false } -alloy-network-primitives = { version = "0.9.0", default-features = false } +alloy-consensus = { version = "0.11.0", default-features = false } +alloy-contract = { version = "0.11.0", default-features = false } +alloy-eips = { version = "0.11.0", default-features = false } +alloy-genesis = { version = "0.11.0", default-features = false } +alloy-json-rpc = { version = "0.11.0", default-features = false } +alloy-network = { version = "0.11.0", default-features = false } +alloy-provider = { version = "0.11.0", default-features = false } +alloy-pubsub = { version = "0.11.0", default-features = false } +alloy-rpc-client = { version = "0.11.0", default-features = false } +alloy-rpc-types = { version = "0.11.0", default-features = true } +alloy-serde = { version = "0.11.0", default-features = false } +alloy-signer = { version = "0.11.0", default-features = false } +alloy-signer-aws = { version = "0.11.0", default-features = false } +alloy-signer-gcp = { version = "0.11.0", default-features = false } +alloy-signer-ledger = { version = "0.11.0", default-features = false } +alloy-signer-local = { version = "0.11.0", default-features = false } +alloy-signer-trezor = { version = "0.11.0", default-features = false } +alloy-transport = { version = "0.11.0", default-features = false } +alloy-transport-http = { version = "0.11.0", default-features = false } +alloy-transport-ipc = { version = "0.11.0", default-features = false } +alloy-transport-ws = { version = "0.11.0", default-features = false } +alloy-node-bindings = { version = "0.11.0", default-features = false } +alloy-network-primitives = { version = "0.11.0", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.18" @@ -225,8 +225,8 @@ alloy-rlp = "0.3" alloy-trie = "0.7.0" ## op-alloy -op-alloy-consensus = "0.9.0" -op-alloy-rpc-types = "0.9.0" +op-alloy-consensus = "0.10.0" +op-alloy-rpc-types = "0.10.0" ## cli anstream = "0.6" diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 38eda60405d41..9a4bf1b0d7480 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1011,11 +1011,13 @@ impl Decodable for TypedTransaction { } } -impl Encodable2718 for TypedTransaction { - fn type_flag(&self) -> Option { - self.r#type() +impl Typed2718 for TypedTransaction { + fn ty(&self) -> u8 { + self.r#type().unwrap_or(0) } +} +impl Encodable2718 for TypedTransaction { fn encode_2718_len(&self) -> usize { match self { Self::Legacy(tx) => TxEnvelope::from(tx.clone()).encode_2718_len(), @@ -1379,18 +1381,20 @@ impl Decodable for TypedReceipt { } } -impl Encodable2718 for TypedReceipt { - fn type_flag(&self) -> Option { +impl Typed2718 for TypedReceipt { + fn ty(&self) -> u8 { match self { - Self::Legacy(_) => None, - Self::EIP2930(_) => Some(1), - Self::EIP1559(_) => Some(2), - Self::EIP4844(_) => Some(3), - Self::EIP7702(_) => Some(4), - Self::Deposit(_) => Some(0x7E), + Self::Legacy(_) => alloy_consensus::constants::LEGACY_TX_TYPE_ID, + Self::EIP2930(_) => alloy_consensus::constants::EIP2930_TX_TYPE_ID, + Self::EIP1559(_) => alloy_consensus::constants::EIP1559_TX_TYPE_ID, + Self::EIP4844(_) => alloy_consensus::constants::EIP4844_TX_TYPE_ID, + Self::EIP7702(_) => alloy_consensus::constants::EIP7702_TX_TYPE_ID, + Self::Deposit(_) => DEPOSIT_TX_TYPE_ID, } } +} +impl Encodable2718 for TypedReceipt { fn encode_2718_len(&self) -> usize { match self { Self::Legacy(r) => ReceiptEnvelope::Legacy(r.clone()).encode_2718_len(), @@ -1456,7 +1460,6 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option Option TypedReceipt::Legacy(receipt_with_bloom), 0x01 => TypedReceipt::EIP2930(receipt_with_bloom), diff --git a/crates/anvil/src/config.rs b/crates/anvil/src/config.rs index 2286e37dec5b5..9b0eaa56e088c 100644 --- a/crates/anvil/src/config.rs +++ b/crates/anvil/src/config.rs @@ -26,7 +26,7 @@ use alloy_signer_local::{ coins_bip39::{English, Mnemonic}, MnemonicBuilder, PrivateKeySigner, }; -use alloy_transport::{Transport, TransportError}; +use alloy_transport::TransportError; use anvil_server::ServerConfig; use eyre::{Context, Result}; use foundry_common::{ @@ -1512,7 +1512,7 @@ pub fn anvil_tmp_dir() -> Option { /// /// This fetches the "latest" block and checks whether the `Block` is fully populated (`hash` field /// is present). This prevents edge cases where anvil forks the "latest" block but `eth_getBlockByNumber` still returns a pending block, -async fn find_latest_fork_block, T: Transport + Clone>( +async fn find_latest_fork_block>( provider: P, ) -> Result { let mut num = provider.get_block_number().await?; diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 7f18f251c38ea..147237a744ef4 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -1903,10 +1903,10 @@ impl EthApi { TransactionOrder::Fees => "fees".to_string(), }, environment: NodeEnvironment { - base_fee: U256::from(self.backend.base_fee()), + base_fee: self.backend.base_fee() as u128, chain_id: self.backend.chain_id().to::(), - gas_limit: U256::from(self.backend.gas_limit()), - gas_price: U256::from(self.gas_price()), + gas_limit: self.backend.gas_limit(), + gas_price: self.gas_price(), }, fork_config: fork_config .map(|fork| { @@ -2865,7 +2865,7 @@ impl EthApi { let max_fee_per_blob_gas = request.max_fee_per_blob_gas; let gas_price = request.gas_price; - let gas_limit = request.gas.unwrap_or(self.backend.gas_limit() as u64); + let gas_limit = request.gas.unwrap_or_else(|| self.backend.gas_limit()); let request = match transaction_request_to_typed(request) { Some(TypedTransactionRequest::Legacy(mut m)) => { diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 127eae8e66225..ce5c960c5e2dc 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -756,12 +756,12 @@ impl Backend { } /// Returns the block gas limit - pub fn gas_limit(&self) -> u128 { - self.env.read().block.gas_limit.to() + pub fn gas_limit(&self) -> u64 { + self.env.read().block.gas_limit.saturating_to() } /// Sets the block gas limit - pub fn set_gas_limit(&self, gas_limit: u128) { + pub fn set_gas_limit(&self, gas_limit: u64) { self.env.write().block.gas_limit = U256::from(gas_limit); } @@ -1567,20 +1567,8 @@ impl Backend { fee_details: FeeDetails, block_env: BlockEnv, ) -> Result<(InstructionResult, Option, u64, AccessList), BlockchainError> { - let from = request.from.unwrap_or_default(); - let to = if let Some(TxKind::Call(to)) = request.to { - to - } else { - let nonce = state.basic_ref(from)?.unwrap_or_default().nonce; - from.create(nonce) - }; - - let mut inspector = AccessListInspector::new( - request.access_list.clone().unwrap_or_default(), - from, - to, - self.precompiles(), - ); + let mut inspector = + AccessListInspector::new(request.access_list.clone().unwrap_or_default()); let env = self.build_call_env(request, fee_details, block_env); let mut evm = self.new_evm_with_inspector_ref(state, env, &mut inspector); @@ -2418,7 +2406,6 @@ impl Backend { to: info.to, blob_gas_price: Some(blob_gas_price), blob_gas_used, - authorization_list: None, }; Some(MinedTransactionReceipt { inner, out: info.out.map(|o| o.0.into()) }) diff --git a/crates/anvil/src/tasks/mod.rs b/crates/anvil/src/tasks/mod.rs index 022e7dd978427..2778689893817 100644 --- a/crates/anvil/src/tasks/mod.rs +++ b/crates/anvil/src/tasks/mod.rs @@ -7,7 +7,6 @@ use alloy_network::{AnyHeader, AnyNetwork}; use alloy_primitives::B256; use alloy_provider::Provider; use alloy_rpc_types::anvil::Forking; -use alloy_transport::Transport; use futures::StreamExt; use std::{fmt, future::Future}; use tokio::{runtime::Handle, task::JoinHandle}; @@ -64,10 +63,9 @@ impl TaskManager { /// handle.task_manager().spawn_reset_on_new_polled_blocks(provider, api); /// # } /// ``` - pub fn spawn_reset_on_new_polled_blocks(&self, provider: P, api: EthApi) + pub fn spawn_reset_on_new_polled_blocks

      (&self, provider: P, api: EthApi) where - P: Provider + Clone + Unpin + 'static, - T: Transport + Clone, + P: Provider + Clone + Unpin + 'static, { self.spawn_block_poll_listener(provider.clone(), move |hash| { let provider = provider.clone(); @@ -88,10 +86,9 @@ impl TaskManager { /// Spawns a new [`BlockListener`] task that listens for new blocks (poll-based) See also /// [`Provider::watch_blocks`] and executes the future the `task_factory` returns for the new /// block hash - pub fn spawn_block_poll_listener(&self, provider: P, task_factory: F) + pub fn spawn_block_poll_listener(&self, provider: P, task_factory: F) where - P: Provider + 'static, - T: Transport + Clone, + P: Provider + 'static, F: Fn(B256) -> Fut + Unpin + Send + Sync + 'static, Fut: Future + Send, { @@ -124,10 +121,9 @@ impl TaskManager { /// /// # } /// ``` - pub fn spawn_reset_on_subscribed_blocks(&self, provider: P, api: EthApi) + pub fn spawn_reset_on_subscribed_blocks

      (&self, provider: P, api: EthApi) where - P: Provider + 'static, - T: Transport + Clone, + P: Provider + 'static, { self.spawn_block_subscription(provider, move |header| { let api = api.clone(); @@ -145,10 +141,9 @@ impl TaskManager { /// Spawns a new [`BlockListener`] task that listens for new blocks (via subscription) See also /// [`Provider::subscribe_blocks()`] and executes the future the `task_factory` returns for the /// new block hash - pub fn spawn_block_subscription(&self, provider: P, task_factory: F) + pub fn spawn_block_subscription(&self, provider: P, task_factory: F) where - P: Provider + 'static, - T: Transport + Clone, + P: Provider + 'static, F: Fn(alloy_rpc_types::Header) -> Fut + Unpin + Send + Sync + 'static, Fut: Future + Send, { diff --git a/crates/anvil/tests/it/utils.rs b/crates/anvil/tests/it/utils.rs index 3d6ae700928c8..abee87f26cfcc 100644 --- a/crates/anvil/tests/it/utils.rs +++ b/crates/anvil/tests/it/utils.rs @@ -1,4 +1,8 @@ use alloy_network::{Ethereum, EthereumWallet}; +use alloy_provider::{ + fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, WalletFiller}, + Identity, RootProvider, +}; use foundry_common::provider::{ get_http_provider, ProviderBuilder, RetryProvider, RetryProviderWithSigner, }; @@ -26,16 +30,10 @@ pub fn ws_provider_with_signer( } /// Currently required to get around -pub async fn connect_pubsub(conn_str: &str) -> RootProvider { - alloy_provider::ProviderBuilder::new().on_builtin(conn_str).await.unwrap() +pub async fn connect_pubsub(conn_str: &str) -> RootProvider { + alloy_provider::ProviderBuilder::default().on_builtin(conn_str).await.unwrap() } -use alloy_provider::{ - fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, WalletFiller}, - Identity, RootProvider, -}; -use alloy_transport::BoxTransport; - type PubsubSigner = FillProvider< JoinFill< JoinFill< @@ -50,18 +48,12 @@ type PubsubSigner = FillProvider< >, WalletFiller, >, - RootProvider, - BoxTransport, + RootProvider, Ethereum, >; pub async fn connect_pubsub_with_wallet(conn_str: &str, wallet: EthereumWallet) -> PubsubSigner { - alloy_provider::ProviderBuilder::new() - .with_recommended_fillers() - .wallet(wallet) - .on_builtin(conn_str) - .await - .unwrap() + alloy_provider::ProviderBuilder::new().wallet(wallet).on_builtin(conn_str).await.unwrap() } pub async fn ipc_provider_with_wallet( diff --git a/crates/cast/bin/cmd/send.rs b/crates/cast/bin/cmd/send.rs index 7fe3677e34003..5f1df6704e019 100644 --- a/crates/cast/bin/cmd/send.rs +++ b/crates/cast/bin/cmd/send.rs @@ -4,7 +4,6 @@ use alloy_provider::{Provider, ProviderBuilder}; use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; use alloy_signer::Signer; -use alloy_transport::Transport; use cast::Cast; use clap::Parser; use eyre::Result; @@ -178,7 +177,7 @@ impl SendTxArgs { } } -async fn cast_send, T: Transport + Clone>( +async fn cast_send>( provider: P, tx: WithOtherFields, cast_async: bool, diff --git a/crates/cast/bin/cmd/storage.rs b/crates/cast/bin/cmd/storage.rs index 2c445712abcdc..c7a90ad2f06b5 100644 --- a/crates/cast/bin/cmd/storage.rs +++ b/crates/cast/bin/cmd/storage.rs @@ -3,7 +3,6 @@ use alloy_network::AnyNetwork; use alloy_primitives::{Address, B256, U256}; use alloy_provider::Provider; use alloy_rpc_types::BlockId; -use alloy_transport::Transport; use cast::Cast; use clap::Parser; use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Table}; @@ -229,7 +228,7 @@ struct StorageReport { values: Vec, } -async fn fetch_and_print_storage, T: Transport + Clone>( +async fn fetch_and_print_storage>( provider: P, address: Address, block: Option, @@ -246,7 +245,7 @@ async fn fetch_and_print_storage, T: Transport + Clon } } -async fn fetch_storage_slots, T: Transport + Clone>( +async fn fetch_storage_slots>( provider: P, address: Address, block: Option, diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index 9cc98aedf4f93..fc5632ea07f76 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -8,7 +8,6 @@ use alloy_provider::Provider; use alloy_rpc_types::{AccessList, Authorization, TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_signer::Signer; -use alloy_transport::Transport; use eyre::Result; use foundry_cli::{ opts::{CliAuthorizationList, TransactionOpts}, @@ -126,7 +125,7 @@ pub struct InputState { /// It is implemented as a stateful builder with expected state transition of [InitState] -> /// [TxKindState] -> [InputState]. #[derive(Debug)] -pub struct CastTxBuilder { +pub struct CastTxBuilder { provider: P, tx: WithOtherFields, legacy: bool, @@ -136,14 +135,9 @@ pub struct CastTxBuilder { etherscan_api_key: Option, access_list: Option>, state: S, - _t: std::marker::PhantomData, } -impl CastTxBuilder -where - P: Provider, - T: Transport + Clone, -{ +impl> CastTxBuilder { /// Creates a new instance of [CastTxBuilder] filling transaction with fields present in /// provided [TransactionOpts]. pub async fn new(provider: P, tx_opts: TransactionOpts, config: &Config) -> Result { @@ -193,12 +187,11 @@ where auth: tx_opts.auth, access_list: tx_opts.access_list, state: InitState, - _t: std::marker::PhantomData, }) } /// Sets [TxKind] for this builder and changes state to [TxKindState]. - pub async fn with_to(self, to: Option) -> Result> { + pub async fn with_to(self, to: Option) -> Result> { let to = if let Some(to) = to { Some(to.resolve(&self.provider).await?) } else { None }; Ok(CastTxBuilder { provider: self.provider, @@ -210,16 +203,11 @@ where auth: self.auth, access_list: self.access_list, state: ToState { to }, - _t: self._t, }) } } -impl CastTxBuilder -where - P: Provider, - T: Transport + Clone, -{ +impl> CastTxBuilder { /// Accepts user-provided code, sig and args params and constructs calldata for the transaction. /// If code is present, input will be set to code + encoded constructor arguments. If no code is /// present, input is set to just provided arguments. @@ -228,7 +216,7 @@ where code: Option, sig: Option, args: Vec, - ) -> Result> { + ) -> Result> { let (mut args, func) = if let Some(sig) = sig { parse_function_args( &sig, @@ -271,16 +259,11 @@ where auth: self.auth, access_list: self.access_list, state: InputState { kind: self.state.to.into(), input, func }, - _t: self._t, }) } } -impl CastTxBuilder -where - P: Provider, - T: Transport + Clone, -{ +impl> CastTxBuilder { /// Builds [TransactionRequest] and fiils missing fields. Returns a transaction which is ready /// to be broadcasted. pub async fn build( @@ -401,10 +384,9 @@ where } } -impl CastTxBuilder +impl CastTxBuilder where - P: Provider, - T: Transport + Clone, + P: Provider, { pub fn with_blob_data(mut self, blob_data: Option>) -> Result { let Some(blob_data) = blob_data else { return Ok(self) }; diff --git a/crates/cast/src/lib.rs b/crates/cast/src/lib.rs index 1139cd38a67c8..40b1e6dae93f3 100644 --- a/crates/cast/src/lib.rs +++ b/crates/cast/src/lib.rs @@ -19,7 +19,6 @@ use alloy_rlp::Decodable; use alloy_rpc_types::{BlockId, BlockNumberOrTag, Filter, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_sol_types::sol; -use alloy_transport::Transport; use base::{Base, NumberWithBase, ToBase}; use chrono::DateTime; use eyre::{Context, ContextCompat, OptionExt, Result}; @@ -39,7 +38,6 @@ use std::{ borrow::Cow, fmt::Write, io, - marker::PhantomData, path::PathBuf, str::FromStr, sync::atomic::{AtomicBool, Ordering}, @@ -70,16 +68,11 @@ sol! { } } -pub struct Cast { +pub struct Cast

      { provider: P, - transport: PhantomData, } -impl Cast -where - T: Transport + Clone, - P: Provider, -{ +impl> Cast

      { /// Creates a new Cast instance from the provided client /// /// # Example @@ -96,7 +89,7 @@ where /// # } /// ``` pub fn new(provider: P) -> Self { - Self { provider, transport: PhantomData } + Self { provider } } /// Makes a read-only call to the specified address @@ -281,7 +274,7 @@ where pub async fn send( &self, tx: WithOtherFields, - ) -> Result> { + ) -> Result> { let res = self.provider.send_transaction(tx).await?; Ok(res) @@ -307,7 +300,7 @@ where pub async fn publish( &self, mut raw_tx: String, - ) -> Result> { + ) -> Result> { raw_tx = match raw_tx.strip_prefix("0x") { Some(s) => s.to_string(), None => raw_tx, @@ -849,7 +842,7 @@ where /// ``` pub async fn rpc(&self, method: &str, params: V) -> Result where - V: alloy_json_rpc::RpcParam, + V: alloy_json_rpc::RpcSend, { let res = self .provider diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 19dfd7433647f..7fcd7f5b3fc35 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -842,7 +842,6 @@ transactionIndex 116 type 0 blobGasPrice blobGasUsed -authorizationList to 0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59c "#]]); @@ -876,7 +875,6 @@ transactionIndex 173 type 2 blobGasPrice blobGasUsed -authorizationList to 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45 revertReason Transaction too old, data: "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000135472616e73616374696f6e20746f6f206f6c6400000000000000000000000000" @@ -1934,7 +1932,7 @@ Traces: [..] 0x5FbDB2315678afecb367f032d93F642f64180aa3::setNumber(111) ├─ storage changes: │ @ 0: 0 → 111 - └─ ← [Stop] + └─ ← [Stop] Transaction successfully executed. @@ -2024,7 +2022,7 @@ contract CounterInExternalLibScript is Script { Traces: [..] → new @0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 ├─ [..] 0x52F3e85EC3F0f9D0a2200D646482fcD134D5adc9::updateCounterInExternalLib(0, 100) [delegatecall] - │ └─ ← [Stop] + │ └─ ← [Stop] └─ ← [Return] 62 bytes of code diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 638005ebd5ca9..c4323d62b8e50 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -28,7 +28,6 @@ alloy-json-abi.workspace = true alloy-primitives.workspace = true alloy-provider.workspace = true alloy-rlp.workspace = true -alloy-transport.workspace = true alloy-chains.workspace = true clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } diff --git a/crates/cli/src/utils/abi.rs b/crates/cli/src/utils/abi.rs index 301200f701273..c7f4d260416d7 100644 --- a/crates/cli/src/utils/abi.rs +++ b/crates/cli/src/utils/abi.rs @@ -2,7 +2,6 @@ use alloy_chains::Chain; use alloy_json_abi::Function; use alloy_primitives::{hex, Address}; use alloy_provider::{network::AnyNetwork, Provider}; -use alloy_transport::Transport; use eyre::{OptionExt, Result}; use foundry_common::{ abi::{encode_function_args, get_func, get_func_etherscan}, @@ -10,10 +9,7 @@ use foundry_common::{ }; use futures::future::join_all; -async fn resolve_name_args>( - args: &[String], - provider: &P, -) -> Vec { +async fn resolve_name_args>(args: &[String], provider: &P) -> Vec { join_all(args.iter().map(|arg| async { if arg.contains('.') { let addr = NameOrAddress::Name(arg.to_string()).resolve(provider).await; @@ -28,7 +24,7 @@ async fn resolve_name_args>( .await } -pub async fn parse_function_args>( +pub async fn parse_function_args>( sig: &str, args: Vec, to: Option

      , diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index 897487fb5b188..ec1cba87586b5 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -1,7 +1,6 @@ use alloy_json_abi::JsonAbi; use alloy_primitives::U256; use alloy_provider::{network::AnyNetwork, Provider}; -use alloy_transport::Transport; use eyre::{ContextCompat, Result}; use foundry_common::{ provider::{ProviderBuilder, RetryProvider}, @@ -101,8 +100,7 @@ pub fn get_provider_builder(config: &Config) -> Result { builder = builder.chain(chain); } - let jwt = config.get_rpc_jwt_secret()?; - if let Some(jwt) = jwt { + if let Some(jwt) = config.get_rpc_jwt_secret()? { builder = builder.jwt(jwt.as_ref()); } @@ -117,10 +115,9 @@ pub fn get_provider_builder(config: &Config) -> Result { Ok(builder) } -pub async fn get_chain(chain: Option, provider: P) -> Result +pub async fn get_chain

      (chain: Option, provider: P) -> Result where - P: Provider, - T: Transport + Clone, + P: Provider, { match chain { Some(chain) => Ok(chain), diff --git a/crates/common/fmt/src/ui.rs b/crates/common/fmt/src/ui.rs index 2f29ec19808c4..1fa58ff088c99 100644 --- a/crates/common/fmt/src/ui.rs +++ b/crates/common/fmt/src/ui.rs @@ -186,7 +186,6 @@ impl UIfmt for AnyTransactionReceipt { }, blob_gas_price, blob_gas_used, - authorization_list, }, other, } = self; @@ -208,8 +207,7 @@ transactionHash {} transactionIndex {} type {} blobGasPrice {} -blobGasUsed {} -authorizationList {}", +blobGasUsed {}", block_hash.pretty(), block_number.pretty(), contract_address.pretty(), @@ -225,11 +223,7 @@ authorizationList {}", transaction_index.pretty(), transaction_type, blob_gas_price.pretty(), - blob_gas_used.pretty(), - authorization_list - .as_ref() - .map(|l| serde_json::to_string(&l).unwrap()) - .unwrap_or_default(), + blob_gas_used.pretty() ); if let Some(to) = to { @@ -1456,7 +1450,6 @@ transactionIndex 16 type 2 blobGasPrice blobGasUsed -authorizationList to 0x4200000000000000000000000000000000000000 l1BaseFeeScalar 5227 l1BlobBaseFee 111685752 diff --git a/crates/common/src/ens.rs b/crates/common/src/ens.rs index 650cb068a39d7..bff7c4c882662 100644 --- a/crates/common/src/ens.rs +++ b/crates/common/src/ens.rs @@ -6,7 +6,6 @@ use self::EnsResolver::EnsResolverInstance; use alloy_primitives::{address, Address, Keccak256, B256}; use alloy_provider::{Network, Provider}; use alloy_sol_types::sol; -use alloy_transport::Transport; use async_trait::async_trait; use std::{borrow::Cow, str::FromStr}; @@ -63,7 +62,7 @@ pub enum NameOrAddress { impl NameOrAddress { /// Resolves the name to an Ethereum Address. - pub async fn resolve>( + pub async fn resolve>( &self, provider: &P, ) -> Result { @@ -111,13 +110,13 @@ impl FromStr for NameOrAddress { /// Extension trait for ENS contract calls. #[async_trait] -pub trait ProviderEnsExt> { +pub trait ProviderEnsExt> { /// Returns the resolver for the specified node. The `&str` is only used for error messages. async fn get_resolver( &self, node: B256, error_name: &str, - ) -> Result, EnsError>; + ) -> Result, EnsError>; /// Performs a forward lookup of an ENS name to an address. async fn resolve_name(&self, name: &str) -> Result { @@ -146,17 +145,16 @@ pub trait ProviderEnsExt> { } #[async_trait] -impl ProviderEnsExt for P +impl ProviderEnsExt for P where - P: Provider, + P: Provider, N: Network, - T: Transport + Clone, { async fn get_resolver( &self, node: B256, error_name: &str, - ) -> Result, EnsError> { + ) -> Result, EnsError> { let registry = EnsRegistry::new(ENS_ADDRESS, self); let address = registry.resolver(node).call().await.map_err(EnsError::Resolver)?._0; if address == Address::ZERO { diff --git a/crates/common/src/provider/mod.rs b/crates/common/src/provider/mod.rs index cd34f94e95203..6c2d561ba0c1f 100644 --- a/crates/common/src/provider/mod.rs +++ b/crates/common/src/provider/mod.rs @@ -11,14 +11,10 @@ use alloy_provider::{ Identity, ProviderBuilder as AlloyProviderBuilder, RootProvider, }; use alloy_rpc_client::ClientBuilder; -use alloy_transport::{ - layers::{RetryBackoffLayer, RetryBackoffService}, - utils::guess_local_url, -}; +use alloy_transport::{layers::RetryBackoffLayer, utils::guess_local_url}; use eyre::{Result, WrapErr}; use foundry_config::NamedChain; use reqwest::Url; -use runtime_transport::RuntimeTransport; use std::{ net::SocketAddr, path::{Path, PathBuf}, @@ -35,7 +31,7 @@ const DEFAULT_UNKNOWN_CHAIN_BLOCK_TIME: Duration = Duration::from_secs(3); const POLL_INTERVAL_BLOCK_TIME_SCALE_FACTOR: f32 = 0.6; /// Helper type alias for a retry provider -pub type RetryProvider = RootProvider, N>; +pub type RetryProvider = RootProvider; /// Helper type alias for a retry provider with a signer pub type RetryProviderWithSigner = FillProvider< @@ -52,8 +48,7 @@ pub type RetryProviderWithSigner = FillProvider< >, WalletFiller, >, - RootProvider, N>, - RetryBackoffService, + RootProvider, N, >; diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index e94d2f69336b0..a3c8a3958763e 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -64,9 +64,9 @@ pub enum RuntimeTransportError { /// Runtime transport that only connects on first request. /// -/// A runtime transport is a custom [alloy_transport::Transport] that only connects when the *first* -/// request is made. When the first request is made, it will connect to the runtime using either an -/// HTTP WebSocket, or IPC transport depending on the URL used. +/// A runtime transport is a custom [`alloy_transport::Transport`] that only connects when the +/// *first* request is made. When the first request is made, it will connect to the runtime using +/// either an HTTP WebSocket, or IPC transport depending on the URL used. /// It also supports retries for rate-limiting and timeout-related errors. #[derive(Clone, Debug, Error)] pub struct RuntimeTransport { @@ -237,19 +237,10 @@ impl RuntimeTransport { } // SAFETY: We just checked that the inner transport exists. - match inner.as_ref().expect("must've been initialized") { - InnerTransport::Http(http) => { - let mut http = http; - http.call(req) - } - InnerTransport::Ws(ws) => { - let mut ws = ws; - ws.call(req) - } - InnerTransport::Ipc(ipc) => { - let mut ipc = ipc; - ipc.call(req) - } + match inner.clone().expect("must've been initialized") { + InnerTransport::Http(mut http) => http.call(req), + InnerTransport::Ws(mut ws) => ws.call(req), + InnerTransport::Ipc(mut ipc) => ipc.call(req), } .await }) diff --git a/crates/common/src/transactions.rs b/crates/common/src/transactions.rs index 1f2ea555bfa0f..128db763b71f0 100644 --- a/crates/common/src/transactions.rs +++ b/crates/common/src/transactions.rs @@ -10,7 +10,6 @@ use alloy_provider::{ }; use alloy_rpc_types::{BlockId, TransactionRequest}; use alloy_serde::WithOtherFields; -use alloy_transport::Transport; use eyre::Result; use foundry_common_fmt::UIfmt; use serde::{Deserialize, Serialize}; @@ -35,7 +34,7 @@ impl TransactionReceiptWithRevertReason { /// Updates the revert reason field using `eth_call` and returns an Err variant if the revert /// reason was not successfully updated - pub async fn update_revert_reason>( + pub async fn update_revert_reason>( &mut self, provider: &P, ) -> Result<()> { @@ -43,7 +42,7 @@ impl TransactionReceiptWithRevertReason { Ok(()) } - async fn fetch_revert_reason>( + async fn fetch_revert_reason>( &self, provider: &P, ) -> Result> { diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 2abf9b22fed50..5730e6fb3ab4a 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -33,7 +33,6 @@ alloy-network.workspace = true alloy-consensus.workspace = true alloy-rpc-types.workspace = true alloy-sol-types.workspace = true -alloy-transport.workspace = true foundry-fork-db.workspace = true revm = { workspace = true, features = [ diff --git a/crates/evm/core/src/fork/init.rs b/crates/evm/core/src/fork/init.rs index 7730eb6afbe4c..e900192248354 100644 --- a/crates/evm/core/src/fork/init.rs +++ b/crates/evm/core/src/fork/init.rs @@ -3,15 +3,13 @@ use alloy_consensus::BlockHeader; use alloy_primitives::{Address, U256}; use alloy_provider::{network::BlockResponse, Network, Provider}; use alloy_rpc_types::{BlockNumberOrTag, BlockTransactionsKind}; -use alloy_transport::Transport; use eyre::WrapErr; use foundry_common::NON_ARCHIVE_NODE_WARNING; - use revm::primitives::{BlockEnv, CfgEnv, Env, TxEnv}; /// Initializes a REVM block environment based on a forked /// ethereum provider. -pub async fn environment>( +pub async fn environment>( provider: &P, memory_limit: u64, gas_price: Option, diff --git a/crates/evm/core/src/fork/multi.rs b/crates/evm/core/src/fork/multi.rs index 490ae7379ae59..56bd7f3a3ce34 100644 --- a/crates/evm/core/src/fork/multi.rs +++ b/crates/evm/core/src/fork/multi.rs @@ -7,10 +7,7 @@ use super::CreateFork; use alloy_consensus::BlockHeader; use alloy_primitives::{map::HashMap, U256}; use alloy_provider::network::BlockResponse; -use alloy_transport::layers::RetryBackoffService; -use foundry_common::provider::{ - runtime_transport::RuntimeTransport, ProviderBuilder, RetryProvider, -}; +use foundry_common::provider::{ProviderBuilder, RetryProvider}; use foundry_config::Config; use foundry_fork_db::{cache::BlockchainDbMeta, BackendHandler, BlockchainDb, SharedBackend}; use futures::{ @@ -184,7 +181,7 @@ impl MultiFork { } } -type Handler = BackendHandler, Arc>; +type Handler = BackendHandler>; type CreateFuture = Pin> + Send>>; diff --git a/crates/forge/bin/cmd/create.rs b/crates/forge/bin/cmd/create.rs index 5781ee7d2d0a9..ab3eb2c41cff7 100644 --- a/crates/forge/bin/cmd/create.rs +++ b/crates/forge/bin/cmd/create.rs @@ -8,7 +8,7 @@ use alloy_provider::{PendingTransactionError, Provider, ProviderBuilder}; use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; use alloy_signer::Signer; -use alloy_transport::{Transport, TransportError}; +use alloy_transport::TransportError; use clap::{Parser, ValueHint}; use eyre::{Context, Result}; use forge_verify::{RetryArgs, VerifierArgs, VerifyArgs}; @@ -33,7 +33,7 @@ use foundry_config::{ merge_impl_figment_convert, Config, }; use serde_json::json; -use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc}; +use std::{borrow::Borrow, marker::PhantomData, path::PathBuf, sync::Arc, time::Duration}; merge_impl_figment_convert!(CreateArgs, build, eth); @@ -260,7 +260,7 @@ impl CreateArgs { /// Deploys the contract #[allow(clippy::too_many_arguments)] - async fn deploy, T: Transport + Clone>( + async fn deploy>( self, abi: JsonAbi, bin: BytecodeObject, @@ -470,7 +470,7 @@ impl figment::Provider for CreateArgs { /// compatibility with less-abstract Contracts. /// /// For full usage docs, see [`DeploymentTxFactory`]. -pub type ContractFactory = DeploymentTxFactory, P, T>; +pub type ContractFactory

      = DeploymentTxFactory

      ; /// Helper which manages the deployment transaction of a smart contract. It /// wraps a deployment transaction, and retrieves the contract address output @@ -479,67 +479,39 @@ pub type ContractFactory = DeploymentTxFactory, P, T>; /// Currently, we recommend using the [`ContractDeployer`] type alias. #[derive(Debug)] #[must_use = "ContractDeploymentTx does nothing unless you `send` it"] -pub struct ContractDeploymentTx { +pub struct ContractDeploymentTx { /// the actual deployer, exposed for overriding the defaults - pub deployer: Deployer, + pub deployer: Deployer

      , /// marker for the `Contract` type to create afterwards /// /// this type will be used to construct it via `From::from(Contract)` _contract: PhantomData, } -impl Clone for ContractDeploymentTx -where - B: Clone, -{ +impl Clone for ContractDeploymentTx { fn clone(&self) -> Self { Self { deployer: self.deployer.clone(), _contract: self._contract } } } -impl From> for ContractDeploymentTx { - fn from(deployer: Deployer) -> Self { +impl From> for ContractDeploymentTx { + fn from(deployer: Deployer

      ) -> Self { Self { deployer, _contract: PhantomData } } } /// Helper which manages the deployment transaction of a smart contract -#[derive(Debug)] +#[derive(Clone, Debug)] #[must_use = "Deployer does nothing unless you `send` it"] -pub struct Deployer { +pub struct Deployer

      { /// The deployer's transaction, exposed for overriding the defaults pub tx: WithOtherFields, - abi: JsonAbi, - client: B, + client: P, confs: usize, timeout: u64, - _p: PhantomData

      , - _t: PhantomData, -} - -impl Clone for Deployer -where - B: Clone, -{ - fn clone(&self) -> Self { - Self { - tx: self.tx.clone(), - abi: self.abi.clone(), - client: self.client.clone(), - confs: self.confs, - timeout: self.timeout, - _p: PhantomData, - _t: PhantomData, - } - } } -impl Deployer -where - B: Borrow

      + Clone, - P: Provider, - T: Transport + Clone, -{ +impl> Deployer

      { /// Broadcasts the contract deployment transaction and after waiting for it to /// be sufficiently confirmed (default: 1), it returns a tuple with /// the [`Contract`](crate::Contract) struct at the deployed contract's address @@ -553,6 +525,7 @@ where .send_transaction(self.tx) .await? .with_required_confirmations(self.confs as u64) + .with_timeout(Some(Duration::from_secs(self.timeout))) .get_receipt() .await?; @@ -599,43 +572,20 @@ where /// println!("{}", contract.address()); /// # Ok(()) /// # } -#[derive(Debug)] -pub struct DeploymentTxFactory { - client: B, +#[derive(Clone, Debug)] +pub struct DeploymentTxFactory

      { + client: P, abi: JsonAbi, bytecode: Bytes, timeout: u64, - _p: PhantomData

      , - _t: PhantomData, -} - -impl Clone for DeploymentTxFactory -where - B: Clone, -{ - fn clone(&self) -> Self { - Self { - client: self.client.clone(), - abi: self.abi.clone(), - bytecode: self.bytecode.clone(), - timeout: self.timeout, - _p: PhantomData, - _t: PhantomData, - } - } } -impl DeploymentTxFactory -where - B: Borrow

      + Clone, - P: Provider, - T: Transport + Clone, -{ +impl + Clone> DeploymentTxFactory

      { /// Creates a factory for deployment of the Contract with bytecode, and the /// constructor defined in the abi. The client will be used to send any deployment /// transaction. - pub fn new(abi: JsonAbi, bytecode: Bytes, client: B, timeout: u64) -> Self { - Self { client, abi, bytecode, timeout, _p: PhantomData, _t: PhantomData } + pub fn new(abi: JsonAbi, bytecode: Bytes, client: P, timeout: u64) -> Self { + Self { client, abi, bytecode, timeout } } /// Create a deployment tx using the provided tokens as constructor @@ -643,10 +593,7 @@ where pub fn deploy_tokens( self, params: Vec, - ) -> Result, ContractDeploymentError> - where - B: Clone, - { + ) -> Result, ContractDeploymentError> { // Encode the constructor args & concatenate with the bytecode if necessary let data: Bytes = match (self.abi.constructor(), params.is_empty()) { (None, false) => return Err(ContractDeploymentError::ConstructorError), @@ -664,15 +611,7 @@ where // create the tx object. Since we're deploying a contract, `to` is `None` let tx = WithOtherFields::new(TransactionRequest::default().input(data.into())); - Ok(Deployer { - client: self.client.clone(), - abi: self.abi, - tx, - confs: 1, - timeout: self.timeout, - _p: PhantomData, - _t: PhantomData, - }) + Ok(Deployer { client: self.client.clone(), tx, confs: 1, timeout: self.timeout }) } } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index d8e8810e9a682..b0524e15fbbf6 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -966,6 +966,7 @@ contract CounterTest { #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(test_default_config, |prj, cmd| { + prj.write_config(Config::default()); cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" [profile.default] src = "src" diff --git a/crates/forge/tests/cli/odyssey.rs b/crates/forge/tests/cli/odyssey.rs index 49b8c01fc7d29..7d98e79fcf082 100644 --- a/crates/forge/tests/cli/odyssey.rs +++ b/crates/forge/tests/cli/odyssey.rs @@ -11,7 +11,6 @@ forgetest_init!(test_eof_flag, |prj, cmd| { Compiler run successful with warnings: Warning (3805): This is a pre-release compiler version, please do not use it in production. - Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, [AVG_GAS]) [PASS] test_Increment() ([GAS]) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index a2952ee1d1f68..88c5275f9e63d 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -229,12 +229,12 @@ Compiler run successful! Traces: [..] DeployScript::run() ├─ [0] VM::startBroadcast() - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] → new GasWaster@[..] │ └─ ← [Return] 415 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) - │ └─ ← [Stop] - └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] Script ran successfully. @@ -247,7 +247,7 @@ Simulated On-chain Traces: └─ ← [Return] 415 bytes of code [..] GasWaster::wasteGas(200000 [2e5]) - └─ ← [Stop] + └─ ← [Stop] ========================== @@ -335,12 +335,12 @@ Warning (2018): Function state mutability can be restricted to view Traces: [..] DeployScript::run() ├─ [0] VM::startBroadcast() - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] → new GasWaster@[..] │ └─ ← [Return] 415 bytes of code ├─ [..] GasWaster::wasteGas(200000 [2e5]) - │ └─ ← [Stop] - └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] Script ran successfully. @@ -353,7 +353,7 @@ Simulated On-chain Traces: └─ ← [Return] 415 bytes of code [..] GasWaster::wasteGas(200000 [2e5]) - └─ ← [Stop] + └─ ← [Stop] ========================== @@ -519,10 +519,10 @@ Compiler run successful! Traces: [..] DeployScript::run() ├─ [0] VM::startBroadcast() - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] → new HashChecker@[..] │ └─ ← [Return] 718 bytes of code - └─ ← [Stop] + └─ ← [Stop] Script ran successfully. @@ -599,58 +599,58 @@ Compiler run successful! Traces: [..] RunScript::run() ├─ [0] VM::startBroadcast() - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [0] VM::roll([..]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] [..]::update() - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [..] [..]::checkLastHash() [staticcall] - │ └─ ← [Stop] - └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] Script ran successfully. @@ -2372,14 +2372,14 @@ Compiler run successful! Traces: [..] SimpleScript::run() ├─ [0] VM::startBroadcast() - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] → new A@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519 │ └─ ← [Return] 175 bytes of code ├─ [..] → new B@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496 │ ├─ [..] A::getValue() [staticcall] │ │ └─ ← [Return] 100 │ └─ ← [Return] 62 bytes of code - └─ ← [Stop] + └─ ← [Stop] Script ran successfully. @@ -2534,13 +2534,13 @@ Compiler run successful! Traces: [..] DryRunTest::run() ├─ [0] VM::startBroadcast() - │ └─ ← [Return] + │ └─ ← [Return] ├─ [..] → new Called@0x5FbDB2315678afecb367f032d93F642f64180aa3 │ └─ ← [Return] 567 bytes of code ├─ [..] Called::run(123, 456) │ ├─ emit log_string(val: "script ran") - │ └─ ← [Stop] - └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] Script ran successfully. @@ -2557,7 +2557,7 @@ Simulated On-chain Traces: [46595] Called::run(123, 456) ├─ emit log_string(val: "script ran") - └─ ← [Stop] + └─ ← [Stop] ========================== diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 53ca49bf1016a..a1abaa6168bc2 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -580,7 +580,7 @@ Traces: │ └─ ← [Return] 0 ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] │ └─ ← [Return] "Tether USD" - └─ ← [Stop] + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -629,7 +629,7 @@ Traces: Traces: [1267] CustomTypesTest::testEvent() ├─ emit MyEvent(a: 100) - └─ ← [Stop] + └─ ← [Stop] Suite result: FAILED. 1 passed; 1 failed; 0 skipped; [ELAPSED] @@ -1000,36 +1000,36 @@ Ran 1 test for test/Contract.t.sol:PrecompileLabelsTest Traces: [9383] PrecompileLabelsTest::testPrecompileLabels() ├─ [0] VM::deal(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(console: [0x000000000000000000636F6e736F6c652e6c6f67], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(Create2Deployer: [0x4e59b44847b379578588920cA78FbF26c0B4956C], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(DefaultSender: [0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(DefaultTestContract: [0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(ECRecover: [0x0000000000000000000000000000000000000001], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(SHA-256: [0x0000000000000000000000000000000000000002], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(RIPEMD-160: [0x0000000000000000000000000000000000000003], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(Identity: [0x0000000000000000000000000000000000000004], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(ModExp: [0x0000000000000000000000000000000000000005], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(ECAdd: [0x0000000000000000000000000000000000000006], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(ECMul: [0x0000000000000000000000000000000000000007], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(ECPairing: [0x0000000000000000000000000000000000000008], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(Blake2F: [0x0000000000000000000000000000000000000009], 1000000000000000000 [1e18]) - │ └─ ← [Return] + │ └─ ← [Return] ├─ [0] VM::deal(PointEvaluation: [0x000000000000000000000000000000000000000A], 1000000000000000000 [1e18]) - │ └─ ← [Return] - └─ ← [Stop] + │ └─ ← [Return] + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -1269,14 +1269,14 @@ Traces: ├─ [22630] SimpleContract::increment() │ ├─ [20147] SimpleContract::_setNum(1) │ │ └─ ← 0 - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [23204] SimpleContract::setValues(100, 0x0000000000000000000000000000000000000123) │ ├─ [247] SimpleContract::_setNum(100) │ │ └─ ← 1 │ ├─ [22336] SimpleContract::_setAddr(0x0000000000000000000000000000000000000123) │ │ └─ ← 0x0000000000000000000000000000000000000000 - │ └─ ← [Stop] - └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -1327,8 +1327,8 @@ Traces: ├─ [2511] SimpleContract::setStr("new value") │ ├─ [1588] SimpleContract::_setStr("new value") │ │ └─ ← "initial value" - │ └─ ← [Stop] - └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] ... "#]]); }); @@ -1635,34 +1635,34 @@ Traces: [7282] PauseTracingTest::setUp() ├─ emit DummyEvent(i: 1) ├─ [0] VM::pauseTracing() [staticcall] - │ └─ ← [Return] - └─ ← [Stop] + │ └─ ← [Return] + └─ ← [Stop] [282512] PauseTracingTest::test() ├─ [0] VM::resumeTracing() [staticcall] - │ └─ ← [Return] + │ └─ ← [Return] ├─ [18327] TraceGenerator::generate() │ ├─ [1278] TraceGenerator::call(0) │ │ ├─ emit DummyEvent(i: 0) - │ │ └─ ← [Stop] + │ │ └─ ← [Stop] │ ├─ [1278] TraceGenerator::call(1) │ │ ├─ emit DummyEvent(i: 1) - │ │ └─ ← [Stop] + │ │ └─ ← [Stop] │ ├─ [1278] TraceGenerator::call(2) │ │ ├─ emit DummyEvent(i: 2) - │ │ └─ ← [Stop] + │ │ └─ ← [Stop] │ ├─ [0] VM::pauseTracing() [staticcall] - │ │ └─ ← [Return] + │ │ └─ ← [Return] │ ├─ [0] VM::resumeTracing() [staticcall] - │ │ └─ ← [Return] + │ │ └─ ← [Return] │ ├─ [1278] TraceGenerator::call(8) │ │ ├─ emit DummyEvent(i: 8) - │ │ └─ ← [Stop] + │ │ └─ ← [Stop] │ ├─ [1278] TraceGenerator::call(9) │ │ ├─ emit DummyEvent(i: 9) - │ │ └─ ← [Stop] - │ └─ ← [Stop] - └─ ← [Stop] + │ │ └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] ... "#]]); }); @@ -2395,7 +2395,7 @@ Traces: │ └─ ← [Return] 236 bytes of code ├─ [..] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b │ └─ ← [Return] 62 bytes of code - └─ ← [Stop] + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -2420,7 +2420,7 @@ Traces: │ └─ ← [Return] 182 bytes of code ├─ [..] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b │ └─ ← [Return] 8 bytes of code - └─ ← [Stop] + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -2905,21 +2905,21 @@ Traces: ├─ [47297] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f │ └─ ← [Return] 236 bytes of code ├─ [2387] Counter::setNumber(0) - │ └─ ← [Stop] - └─ ← [Stop] + │ └─ ← [Stop] + └─ ← [Stop] [31293] CounterTest::test_Increment() ├─ [22337] Counter::increment() │ ├─ storage changes: │ │ @ 0: 0 → 1 - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [281] Counter::number() [staticcall] │ └─ ← [Return] 1 ├─ [0] VM::assertEq(1, 1) [staticcall] - │ └─ ← [Return] + │ └─ ← [Return] ├─ storage changes: │ @ 0: 0 → 1 - └─ ← [Stop] + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] @@ -2984,7 +2984,7 @@ Ran 1 test for test/DebugTraceRecordingTest.t.sol:DebugTraceRecordingTest [PASS] test_start_stop_recording() ([GAS]) Traces: [..] DebugTraceRecordingTest::test_start_stop_recording() - └─ ← [Stop] + └─ ← [Stop] Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] diff --git a/crates/forge/tests/fixtures/colored_traces.svg b/crates/forge/tests/fixtures/colored_traces.svg index 96726b528e936..4b2be87d03df7 100644 --- a/crates/forge/tests/fixtures/colored_traces.svg +++ b/crates/forge/tests/fixtures/colored_traces.svg @@ -33,13 +33,13 @@ ├─ [96345] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 481 bytes of code + │ └─ ← [Return] 481 bytes of code ├─ [2592] Counter::setNumber(0) - │ └─ ← [Stop] + │ └─ ← [Stop] - └─ ← [Stop] + └─ ← [Stop] @@ -51,21 +51,21 @@ │ │ @ 0: 0 → 1 - │ └─ ← [Stop] + │ └─ ← [Stop] ├─ [424] Counter::number() [staticcall] - │ └─ ← [Return] 1 + │ └─ ← [Return] 1 ├─ [0] VM::assertEq(1, 1) [staticcall] - │ └─ ← [Return] + │ └─ ← [Return] ├─ storage changes: │ @ 0: 0 → 1 - └─ ← [Stop] + └─ ← [Stop] diff --git a/crates/script/Cargo.toml b/crates/script/Cargo.toml index 4322bbb0e4954..99c99c35fa682 100644 --- a/crates/script/Cargo.toml +++ b/crates/script/Cargo.toml @@ -53,7 +53,6 @@ alloy-chains.workspace = true alloy-dyn-abi.workspace = true alloy-primitives.workspace = true alloy-eips.workspace = true -alloy-transport.workspace = true alloy-consensus.workspace = true [dev-dependencies] diff --git a/crates/script/src/broadcast.rs b/crates/script/src/broadcast.rs index 3e17cd8efa6f8..6e828bc8619f7 100644 --- a/crates/script/src/broadcast.rs +++ b/crates/script/src/broadcast.rs @@ -14,7 +14,6 @@ use alloy_primitives::{ use alloy_provider::{utils::Eip1559Estimation, Provider}; use alloy_rpc_types::TransactionRequest; use alloy_serde::WithOtherFields; -use alloy_transport::Transport; use eyre::{bail, Context, Result}; use forge_verify::provider::VerificationProviderType; use foundry_cheatcodes::Wallets; @@ -28,15 +27,11 @@ use futures::{future::join_all, StreamExt}; use itertools::Itertools; use std::{cmp::Ordering, sync::Arc}; -pub async fn estimate_gas( +pub async fn estimate_gas>( tx: &mut WithOtherFields, provider: &P, estimate_multiplier: u64, -) -> Result<()> -where - P: Provider, - T: Transport + Clone, -{ +) -> Result<()> { // if already set, some RPC endpoints might simply return the gas value that is already // set in the request and omit the estimate altogether, so we remove it here tx.gas = None; diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index e51e911f32b2d..2fda786c5deaf 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -4,11 +4,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +// Shouldn't use sh_* macros here, as they don't get captured by the test runner. #![allow(clippy::disallowed_macros)] -#[macro_use] -extern crate foundry_common; - #[macro_use] extern crate tracing; diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 17bffcb6451a8..15d5b81a7199b 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -142,7 +142,7 @@ impl ExtTester { pub fn run(&self) { // Skip fork tests if the RPC url is not set. if self.fork_block.is_some() && std::env::var_os("ETH_RPC_URL").is_none() { - let _ = sh_eprintln!("ETH_RPC_URL is not set; skipping"); + eprintln!("ETH_RPC_URL is not set; skipping"); return; } @@ -160,7 +160,7 @@ impl ExtTester { if self.rev.is_empty() { let mut git = Command::new("git"); git.current_dir(root).args(["log", "-n", "1"]); - let _ = sh_println!("$ {git:?}"); + println!("$ {git:?}"); let output = git.output().unwrap(); if !output.status.success() { panic!("git log failed: {output:?}"); @@ -171,7 +171,7 @@ impl ExtTester { } else { let mut git = Command::new("git"); git.current_dir(root).args(["checkout", self.rev]); - let _ = sh_println!("$ {git:?}"); + println!("$ {git:?}"); let status = git.status().unwrap(); if !status.success() { panic!("git checkout failed: {status}"); @@ -182,16 +182,16 @@ impl ExtTester { for install_command in &self.install_commands { let mut install_cmd = Command::new(&install_command[0]); install_cmd.args(&install_command[1..]).current_dir(root); - let _ = sh_println!("cd {root}; {install_cmd:?}"); + println!("cd {root}; {install_cmd:?}"); match install_cmd.status() { Ok(s) => { - let _ = sh_println!("\n\n{install_cmd:?}: {s}"); + println!("\n\n{install_cmd:?}: {s}"); if s.success() { break; } } Err(e) => { - let _ = sh_eprintln!("\n\n{install_cmd:?}: {e}"); + eprintln!("\n\n{install_cmd:?}: {e}"); } } } @@ -259,6 +259,10 @@ pub fn initialize(target: &Path) { println!("- initializing template dir in {}", prj.root().display()); cmd.args(["init", "--force"]).assert_success(); + prj.write_config(Config { + solc: Some(foundry_config::SolcReq::Version(SOLC_VERSION.parse().unwrap())), + ..Default::default() + }); // checkout forge-std assert!(Command::new("git") .current_dir(prj.root().join("lib/forge-std")) @@ -267,7 +271,7 @@ pub fn initialize(target: &Path) { .expect("failed to checkout forge-std") .status .success()); - cmd.forge_fuse().args(["build", "--use", SOLC_VERSION]).assert_success(); + cmd.forge_fuse().arg("build").assert_success(); // Remove the existing template, if any. let _ = fs::remove_dir_all(tpath); @@ -296,12 +300,12 @@ pub fn clone_remote(repo_url: &str, target_dir: &str) { let mut cmd = Command::new("git"); cmd.args(["clone", "--no-tags", "--recursive", "--shallow-submodules"]); cmd.args([repo_url, target_dir]); - let _ = sh_println!("{cmd:?}"); + println!("{cmd:?}"); let status = cmd.status().unwrap(); if !status.success() { panic!("git clone failed: {status}"); } - let _ = sh_println!(); + println!(); } /// Setup an empty test project and return a command pointing to the forge @@ -960,7 +964,7 @@ impl TestCommand { #[track_caller] pub fn try_execute(&mut self) -> std::io::Result { - let _ = sh_println!("executing {:?}", self.cmd); + println!("executing {:?}", self.cmd); let mut child = self.cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::piped()).spawn()?; if let Some(fun) = self.stdin_fun.take() { diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index 0de57f0952141..f5b773762298c 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -32,7 +32,7 @@ aws-sdk-kms = { version = "1", default-features = false, optional = true } # gcp-kms alloy-signer-gcp = { workspace = true, features = ["eip712"], optional = true } -gcloud-sdk = { version = "0.25", features = [ +gcloud-sdk = { version = "0.26", features = [ "google-cloud-kms-v1", "google-longrunning", ], optional = true } From 3c6d0ecb7697e586517cf1e3e52158822852d22d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 2 Feb 2025 14:14:00 +0100 Subject: [PATCH 1922/1963] chore(tests): bump forge-std version (#9808) * chore: bump forge-std version used for tests * Fix gas and bind test --------- Co-authored-by: DaniPopes Co-authored-by: grandizzy --- crates/forge/tests/cli/cmd.rs | 18 ++++++++++-------- crates/forge/tests/cli/script.rs | 2 +- testdata/forge-std-rev | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 1f82a6be95e29..43e240821fced 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2675,7 +2675,7 @@ contract GasReportFallbackTest is Test { +========================================================================================================+ | Deployment Cost | Deployment Size | | | | | |-----------------------------------------------------+-----------------+------+--------+------+---------| -| 104475 | 263 | | | | | +| 104463 | 263 | | | | | |-----------------------------------------------------+-----------------+------+--------+------+---------| | | | | | | | |-----------------------------------------------------+-----------------+------+--------+------+---------| @@ -2721,7 +2721,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) { "contract": "test/DelegateProxyTest.sol:ProxiedContract", "deployment": { - "gas": 104475, + "gas": 104463, "size": 263 }, "functions": { @@ -2812,7 +2812,7 @@ contract NestedDeploy is Test { +============================================================================================+ | Deployment Cost | Deployment Size | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| -| 251985 | 739 | | | | | +| 251997 | 739 | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| | | | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| @@ -2867,7 +2867,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) { "contract": "test/NestedDeployTest.sol:Parent", "deployment": { - "gas": 251985, + "gas": 251997, "size": 739 }, "functions": { @@ -2899,7 +2899,7 @@ forgetest_init!(can_use_absolute_imports, |prj, cmd| { prj.add_lib( "myDependency/src/interfaces/IConfig.sol", r" - + interface IConfig {} ", ) @@ -3544,9 +3544,11 @@ forgetest_init!(can_bind_enum_modules, |prj, cmd| { ) .unwrap(); - cmd.arg("bind").assert_success().stdout_eq(str![[r#"[COMPILING_FILES] with [SOLC_VERSION] + cmd.args(["bind", "--select", "^Enum$"]).assert_success().stdout_eq(str![[ + r#"[COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! -Generating bindings for 11 contracts -Bindings have been generated to [..]"#]]); +Generating bindings for 1 contracts +Bindings have been generated to [..]"# + ]]); }); diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 88c5275f9e63d..dd3dae5439d6b 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -1958,7 +1958,7 @@ contract SimpleScript is Script { ]) .assert_success() .stdout_eq(str![[r#" -{"logs":[],"returns":{"success":{"internal_type":"bool","value":"true"}},"success":true,"raw_logs":[],"traces":[["Deployment",{"arena":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":false,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CREATE","value":"0x0","data":"0x6080604052600c805462ff00ff191662010001179055348015601f575f5ffd5b506101568061002d5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122051a3965709e156763fe3847b1a8c4c2e1f5ad2088ccbc31509b98951c018fc8764736f6c634300081b0033","output":"0x608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea264697066735822122051a3965709e156763fe3847b1a8c4c2e1f5ad2088ccbc31509b98951c018fc8764736f6c634300081b0033","gas_used":90639,"gas_limit":1073682798,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}],["Execution",{"arena":[{"parent":null,"children":[1,2],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0xc0406226","output":"0x0000000000000000000000000000000000000000000000000000000000000001","gas_used":3214,"gas_limit":1073720760,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[{"Call":0},{"Call":1}]},{"parent":0,"children":[],"idx":1,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x7109709ecfa91a80626ff3989d68f67f5b1dd12d","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x7fb5297f","output":"0x","gas_used":0,"gas_limit":1056940983,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]},{"parent":0,"children":[],"idx":2,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x0000000000000000000000000000000000000000","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1056940820,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}]],"gas_used":24278,"labeled_addresses":{},"returned":"0x0000000000000000000000000000000000000000000000000000000000000001","address":null} +{"logs":[],"returns":{"success":{"internal_type":"bool","value":"true"}},"success":true,"raw_logs":[],"traces":[["Deployment",{"arena":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":false,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CREATE","value":"0x0","data":"0x6080604052600c805462ff00ff191662010001179055348015601f575f5ffd5b506101568061002d5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea26469706673582212205a6c0bb866f700ff9980dc254cb6ededdb9034f66b5a30bdc5cc4738d441b8dd64736f6c634300081b0033","output":"0x608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea26469706673582212205a6c0bb866f700ff9980dc254cb6ededdb9034f66b5a30bdc5cc4738d441b8dd64736f6c634300081b0033","gas_used":90639,"gas_limit":1073682810,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}],["Execution",{"arena":[{"parent":null,"children":[1,2],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0xc0406226","output":"0x0000000000000000000000000000000000000000000000000000000000000001","gas_used":3214,"gas_limit":1073720760,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[{"Call":0},{"Call":1}]},{"parent":0,"children":[],"idx":1,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x7109709ecfa91a80626ff3989d68f67f5b1dd12d","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x7fb5297f","output":"0x","gas_used":0,"gas_limit":1056940983,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]},{"parent":0,"children":[],"idx":2,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x0000000000000000000000000000000000000000","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1056940820,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}]],"gas_used":24278,"labeled_addresses":{},"returned":"0x0000000000000000000000000000000000000000000000000000000000000001","address":null} {"chain":31337,"estimated_gas_price":"2.000000001","estimated_total_gas_used":29005,"estimated_amount_required":"0.000058010000029005"} {"chain":"anvil-hardhat","status":"success","tx_hash":"0x4f78afe915fceb282c7625a68eb350bc0bf78acb59ad893e5c62b710a37f3156","contract_address":null,"block_number":1,"gas_used":21000,"gas_price":1000000001} {"status":"success","transactions":"[..]/broadcast/Foo.sol/31337/run-latest.json","sensitive":"[..]/cache/Foo.sol/31337/run-latest.json"} diff --git a/testdata/forge-std-rev b/testdata/forge-std-rev index 1a0142f7e970a..ac11c37c7c648 100644 --- a/testdata/forge-std-rev +++ b/testdata/forge-std-rev @@ -1 +1 @@ -b93cf4bc34ff214c099dc970b153f85ade8c9f66 \ No newline at end of file +3b20d60d14b343ee4f908cb8079495c07f5e8981 \ No newline at end of file From aee9f47eabea0a79409f3b802f53aa14fba7a4a8 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 2 Feb 2025 16:12:34 +0100 Subject: [PATCH 1923/1963] test: misc test improvements (#9812) * more opts * ignore can_disable_block_gas_limit * move selector tests to integration tests * reduce sleep * rm unnecessary test, already tested with openchain/4byte commands * rm needless_return allows * chore: clippy * move gas_report_fuzz_invariant to integration --- Cargo.toml | 27 ++- crates/anvil/src/eth/backend/mem/cache.rs | 2 +- crates/anvil/src/eth/backend/mem/storage.rs | 5 +- crates/anvil/tests/it/main.rs | 2 - crates/cast/bin/main.rs | 1 - crates/cast/tests/cli/main.rs | 163 +-------------- crates/cast/tests/cli/selectors.rs | 195 ++++++++++++++++++ crates/chisel/bin/main.rs | 1 - .../common/src/provider/runtime_transport.rs | 11 +- crates/common/src/selectors.rs | 129 +----------- crates/evm/core/src/backend/mod.rs | 1 - crates/evm/core/src/fork/database.rs | 1 - .../evm/traces/src/identifier/signatures.rs | 37 ---- crates/forge/bin/cmd/clone.rs | 1 - crates/forge/bin/cmd/doc/server.rs | 1 - crates/forge/bin/cmd/soldeer.rs | 1 - crates/forge/bin/cmd/test/mod.rs | 66 +----- crates/forge/tests/cli/cmd.rs | 44 ++++ crates/forge/tests/cli/test_cmd.rs | 27 +-- crates/forge/tests/it/main.rs | 2 - crates/test-utils/src/rpc.rs | 2 +- crates/verify/src/etherscan/mod.rs | 1 - crates/wallets/src/wallet.rs | 4 +- 23 files changed, 304 insertions(+), 420 deletions(-) create mode 100644 crates/cast/tests/cli/selectors.rs diff --git a/Cargo.toml b/Cargo.toml index aa401962461c5..3f7f95fd4343a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,13 +90,22 @@ codegen-units = 1 # Speed up tests and dev build. [profile.dev.package] -# Solc and artifacts +# Solc and artifacts. +foundry-compilers-artifacts-solc.opt-level = 3 +foundry-compilers-core.opt-level = 3 foundry-compilers.opt-level = 3 +serde_json.opt-level = 3 +serde.opt-level = 3 + solang-parser.opt-level = 3 lalrpop-util.opt-level = 3 -serde_json.opt-level = 3 -# EVM +solar-ast.opt-level = 3 +solar-data-structures.opt-level = 3 +solar-interface.opt-level = 3 +solar-parse.opt-level = 3 + +# EVM. alloy-dyn-abi.opt-level = 3 alloy-json-abi.opt-level = 3 alloy-primitives.opt-level = 3 @@ -114,16 +123,22 @@ sha3.opt-level = 3 tiny-keccak.opt-level = 3 bitvec.opt-level = 3 -# fuzzing +# Fuzzing. proptest.opt-level = 3 foundry-evm-fuzz.opt-level = 3 -# forking +# Forking. axum.opt-level = 3 -# keystores +# Keystores. scrypt.opt-level = 3 +# Misc. +rayon.opt-level = 3 +regex.opt-level = 3 +regex-syntax.opt-level = 3 +regex-automata.opt-level = 3 + # Override packages which aren't perf-sensitive for faster compilation speed and smaller binary size. [profile.release.package] alloy-sol-macro-expander.opt-level = "z" diff --git a/crates/anvil/src/eth/backend/mem/cache.rs b/crates/anvil/src/eth/backend/mem/cache.rs index 51b92c3d65d76..d4b2779da32b6 100644 --- a/crates/anvil/src/eth/backend/mem/cache.rs +++ b/crates/anvil/src/eth/backend/mem/cache.rs @@ -47,7 +47,7 @@ impl DiskStateCache { } } } - if let Some(ref temp_dir) = self.temp_dir { + if let Some(temp_dir) = &self.temp_dir { let path = temp_dir.path().join(format!("{hash:?}.json")); Some(f(path)) } else { diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index 46429d4532b13..276cba95c62e8 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -593,7 +593,6 @@ pub struct MinedTransactionReceipt { } #[cfg(test)] -#[allow(clippy::needless_return)] mod tests { use super::*; use crate::eth::backend::db::Db; @@ -652,7 +651,7 @@ mod tests { storage.insert(two, StateDb::new(MemDb::default())); // wait for files to be flushed - tokio::time::sleep(std::time::Duration::from_secs(2)).await; + tokio::time::sleep(std::time::Duration::from_secs(1)).await; assert_eq!(storage.on_disk_states.len(), 1); assert!(storage.on_disk_states.contains_key(&one)); @@ -680,7 +679,7 @@ mod tests { } // wait for files to be flushed - tokio::time::sleep(std::time::Duration::from_secs(2)).await; + tokio::time::sleep(std::time::Duration::from_secs(1)).await; assert_eq!(storage.on_disk_states.len(), num_states - storage.min_in_memory_limit); assert_eq!(storage.present.len(), storage.min_in_memory_limit); diff --git a/crates/anvil/tests/it/main.rs b/crates/anvil/tests/it/main.rs index 256edb813898b..f3f5eca157707 100644 --- a/crates/anvil/tests/it/main.rs +++ b/crates/anvil/tests/it/main.rs @@ -1,5 +1,3 @@ -#![allow(clippy::needless_return)] - mod abi; mod anvil; mod anvil_api; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 2f5f9afb2fe17..1663606260194 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -57,7 +57,6 @@ fn run() -> Result<()> { main_args(args) } -#[allow(clippy::needless_return)] #[tokio::main] async fn main_args(args: CastArgs) -> Result<()> { match args.cmd { diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 7fcd7f5b3fc35..98440d68b3289 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -7,7 +7,6 @@ use alloy_provider::{Provider, ProviderBuilder}; use alloy_rpc_types::{BlockNumberOrTag, Index, TransactionRequest}; use anvil::{EthereumHardfork, NodeConfig}; use foundry_test_utils::{ - casttest, file, forgetest, forgetest_async, rpc::{ next_etherscan_api_key, next_http_rpc_endpoint, next_mainnet_etherscan_api_key, next_rpc_endpoint, next_ws_rpc_endpoint, @@ -17,6 +16,11 @@ use foundry_test_utils::{ }; use std::{fs, io::Write, path::Path, str::FromStr}; +#[macro_use] +extern crate foundry_test_utils; + +mod selectors; + casttest!(print_short_version, |_prj, cmd| { cmd.arg("-V").assert_success().stdout_eq(str![[r#" cast [..]-[..] ([..] [..]) @@ -565,68 +569,6 @@ casttest!(estimate_contract_deploy_gas, |_prj, cmd| { assert!(output > 0); }); -// tests that the `cast upload-signatures` command works correctly -casttest!(upload_signatures, |_prj, cmd| { - // test no prefix is accepted as function - let output = cmd - .args(["upload-signature", "transfer(address,uint256)"]) - .assert_success() - .get_output() - .stdout_lossy(); - assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); - - // test event prefix - cmd.args(["upload-signature", "event Transfer(address,uint256)"]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); - - // test error prefix - cmd.args(["upload-signature", "error ERC20InsufficientBalance(address,uint256,uint256)"]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!( - output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), - "{}", - output - ); // Custom error is interpreted as function - - // test multiple sigs - cmd.args([ - "upload-signature", - "event Transfer(address,uint256)", - "transfer(address,uint256)", - "approve(address,uint256)", - ]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); - assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); - assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); - - // test abi - cmd.args([ - "upload-signature", - "event Transfer(address,uint256)", - "transfer(address,uint256)", - "error ERC20InsufficientBalance(address,uint256,uint256)", - Path::new(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/ERC20Artifact.json") - .into_os_string() - .into_string() - .unwrap() - .as_str(), - ]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); - assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); - assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); - assert!(output.contains("Function decimals(): 0x313ce567"), "{}", output); - assert!(output.contains("Function allowance(address,address): 0xdd62ed3e"), "{}", output); - assert!( - output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), - "{}", - output - ); -}); - // tests that the `cast to-rlp` and `cast from-rlp` commands work correctly casttest!(rlp, |_prj, cmd| { cmd.args(["--to-rlp", "[\"0xaa\", [[\"bb\"]], \"0xcc\"]"]).assert_success().stdout_eq(str![[ @@ -1551,101 +1493,6 @@ casttest!(string_decode, |_prj, cmd| { "#]]); }); -// tests cast can decode event with provided signature -casttest!(event_decode_with_sig, |_prj, cmd| { - cmd.args(["decode-event", "--sig", "MyEvent(uint256,address)", "0x000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000d0004f"]).assert_success().stdout_eq(str![[r#" -78 -0x0000000000000000000000000000000000D0004F - -"#]]); - - cmd.args(["--json"]).assert_success().stdout_eq(str![[r#" -[ - "78", - "0x0000000000000000000000000000000000D0004F" -] - -"#]]); -}); - -// tests cast can decode event with Openchain API -casttest!(event_decode_with_openchain, |prj, cmd| { - prj.clear_cache(); - cmd.args(["decode-event", "0xe27c4c1372396a3d15a9922f74f9dfc7c72b1ad6d63868470787249c356454c1000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]).assert_success().stdout_eq(str![[r#" -BaseCurrencySet(address,uint256) -0x000000000000000000000000000000000000004e -15187004358734 [1.518e13] - -"#]]); -}); - -// tests cast can decode error with provided signature -casttest!(error_decode_with_sig, |_prj, cmd| { - cmd.args(["decode-error", "--sig", "AnotherValueTooHigh(uint256,address)", "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F"]).assert_success().stdout_eq(str![[r#" -101 -0x0000000000000000000000000000000000D0004F - -"#]]); - - cmd.args(["--json"]).assert_success().stdout_eq(str![[r#" -[ - "101", - "0x0000000000000000000000000000000000D0004F" -] - -"#]]); -}); - -// tests cast can decode error with Openchain API -casttest!(error_decode_with_openchain, |prj, cmd| { - prj.clear_cache(); - cmd.args(["decode-error", "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"]).assert_success().stdout_eq(str![[r#" -ValueTooHigh(uint256,uint256) -101 -100 - -"#]]); -}); - -// tests cast can decode error and event when using local sig identifiers cache -forgetest!(error_event_decode_with_cache, |prj, cmd| { - prj.clear_cache(); - foundry_test_utils::util::initialize(prj.root()); - prj.add_source( - "LocalProjectContract", - r#" -contract ContractWithCustomError { - error AnotherValueTooHigh(uint256, address); - event MyUniqueEventWithinLocalProject(uint256 a, address b); -} - "#, - ) - .unwrap(); - // Store selectors in local cache. - cmd.forge_fuse().args(["selectors", "cache"]).assert_success(); - - // Assert cast can decode custom error with local cache. - cmd.cast_fuse() - .args(["decode-error", "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F"]) - .assert_success() - .stdout_eq(str![[r#" -AnotherValueTooHigh(uint256,address) -101 -0x0000000000000000000000000000000000D0004F - -"#]]); - // Assert cast can decode event with local cache. - cmd.cast_fuse() - .args(["decode-event", "0xbd3699995dcc867b64dbb607be2c33be38df9134bef1178df13bfb9446e73104000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]) - .assert_success() - .stdout_eq(str![[r#" -MyUniqueEventWithinLocalProject(uint256,address) -78 -0x00000000000000000000000000000DD00000004e - -"#]]); -}); - casttest!(format_units, |_prj, cmd| { cmd.args(["format-units", "1000000", "6"]).assert_success().stdout_eq(str![[r#" 1 diff --git a/crates/cast/tests/cli/selectors.rs b/crates/cast/tests/cli/selectors.rs new file mode 100644 index 0000000000000..c427f24f566d3 --- /dev/null +++ b/crates/cast/tests/cli/selectors.rs @@ -0,0 +1,195 @@ +use foundry_test_utils::util::OutputExt; +use std::path::Path; + +casttest!(error_decode_with_openchain, |prj, cmd| { + prj.clear_cache(); + cmd.args(["decode-error", "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"]).assert_success().stdout_eq(str![[r#" +ValueTooHigh(uint256,uint256) +101 +100 + +"#]]); +}); + +casttest!(fourbyte, |_prj, cmd| { + cmd.args(["4byte", "0xa9059cbb"]).assert_success().stdout_eq(str![[r#" +transfer(address,uint256) + +"#]]); +}); + +casttest!(fourbyte_invalid, |_prj, cmd| { + cmd.args(["4byte", "0xa9059c"]).assert_failure().stderr_eq(str![[r#" +Error: Invalid selector 0xa9059c: expected 10 characters (including 0x prefix). + +"#]]); +}); + +casttest!(fourbyte_decode, |_prj, cmd| { + cmd.args(["4byte-decode", "0xa9059cbb0000000000000000000000000a2ac0c368dc8ec680a0c98c907656bd970675950000000000000000000000000000000000000000000000000000000767954a79"]).assert_success().stdout_eq(str![[r#" +1) "transfer(address,uint256)" +0x0A2AC0c368Dc8eC680a0c98C907656BD97067595 +31802608249 [3.18e10] + +"#]]); +}); + +casttest!(fourbyte_event, |_prj, cmd| { + cmd.args(["4byte-event", "0x7e1db2a1cd12f0506ecd806dba508035b290666b84b096a87af2fd2a1516ede6"]) + .assert_success() + .stdout_eq(str![[r#" +updateAuthority(address,uint8) + +"#]]); +}); + +casttest!(fourbyte_event_2, |_prj, cmd| { + cmd.args(["4byte-event", "0xb7009613e63fb13fd59a2fa4c206a992c1f090a44e5d530be255aa17fed0b3dd"]) + .assert_success() + .stdout_eq(str![[r#" +canCall(address,address,bytes4) + +"#]]); +}); + +casttest!(upload_signatures, |_prj, cmd| { + // test no prefix is accepted as function + let output = cmd + .args(["upload-signature", "transfer(address,uint256)"]) + .assert_success() + .get_output() + .stdout_lossy(); + assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); + + // test event prefix + cmd.args(["upload-signature", "event Transfer(address,uint256)"]); + let output = cmd.assert_success().get_output().stdout_lossy(); + assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); + + // test error prefix + cmd.args(["upload-signature", "error ERC20InsufficientBalance(address,uint256,uint256)"]); + let output = cmd.assert_success().get_output().stdout_lossy(); + assert!( + output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), + "{}", + output + ); // Custom error is interpreted as function + + // test multiple sigs + cmd.args([ + "upload-signature", + "event Transfer(address,uint256)", + "transfer(address,uint256)", + "approve(address,uint256)", + ]); + let output = cmd.assert_success().get_output().stdout_lossy(); + assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); + assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); + assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); + + // test abi + cmd.args([ + "upload-signature", + "event Transfer(address,uint256)", + "transfer(address,uint256)", + "error ERC20InsufficientBalance(address,uint256,uint256)", + Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/ERC20Artifact.json") + .as_os_str() + .to_str() + .unwrap(), + ]); + let output = cmd.assert_success().get_output().stdout_lossy(); + assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); + assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); + assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); + assert!(output.contains("Function decimals(): 0x313ce567"), "{}", output); + assert!(output.contains("Function allowance(address,address): 0xdd62ed3e"), "{}", output); + assert!( + output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), + "{}", + output + ); +}); + +// tests cast can decode event with provided signature +casttest!(event_decode_with_sig, |_prj, cmd| { + cmd.args(["decode-event", "--sig", "MyEvent(uint256,address)", "0x000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000d0004f"]).assert_success().stdout_eq(str![[r#" +78 +0x0000000000000000000000000000000000D0004F + +"#]]); + + cmd.args(["--json"]).assert_success().stdout_eq(str![[r#" +[ + "78", + "0x0000000000000000000000000000000000D0004F" +] + +"#]]); +}); + +// tests cast can decode event with Openchain API +casttest!(event_decode_with_openchain, |prj, cmd| { + prj.clear_cache(); + cmd.args(["decode-event", "0xe27c4c1372396a3d15a9922f74f9dfc7c72b1ad6d63868470787249c356454c1000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]).assert_success().stdout_eq(str![[r#" +BaseCurrencySet(address,uint256) +0x000000000000000000000000000000000000004e +15187004358734 [1.518e13] + +"#]]); +}); + +// tests cast can decode error with provided signature +casttest!(error_decode_with_sig, |_prj, cmd| { + cmd.args(["decode-error", "--sig", "AnotherValueTooHigh(uint256,address)", "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F"]).assert_success().stdout_eq(str![[r#" +101 +0x0000000000000000000000000000000000D0004F + +"#]]); + + cmd.args(["--json"]).assert_success().stdout_eq(str![[r#" +[ + "101", + "0x0000000000000000000000000000000000D0004F" +] + +"#]]); +}); + +// tests cast can decode error and event when using local sig identifiers cache +forgetest_init!(error_event_decode_with_cache, |prj, cmd| { + prj.add_source( + "LocalProjectContract", + r#" +contract ContractWithCustomError { + error AnotherValueTooHigh(uint256, address); + event MyUniqueEventWithinLocalProject(uint256 a, address b); +} + "#, + ) + .unwrap(); + // Store selectors in local cache. + cmd.forge_fuse().args(["selectors", "cache"]).assert_success(); + + // Assert cast can decode custom error with local cache. + cmd.cast_fuse() + .args(["decode-error", "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F"]) + .assert_success() + .stdout_eq(str![[r#" +AnotherValueTooHigh(uint256,address) +101 +0x0000000000000000000000000000000000D0004F + +"#]]); + // Assert cast can decode event with local cache. + cmd.cast_fuse() + .args(["decode-event", "0xbd3699995dcc867b64dbb607be2c33be38df9134bef1178df13bfb9446e73104000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]) + .assert_success() + .stdout_eq(str![[r#" +MyUniqueEventWithinLocalProject(uint256,address) +78 +0x00000000000000000000000000000DD00000004e + +"#]]); +}); diff --git a/crates/chisel/bin/main.rs b/crates/chisel/bin/main.rs index 93b93d46e1c69..3af1470ffc8d1 100644 --- a/crates/chisel/bin/main.rs +++ b/crates/chisel/bin/main.rs @@ -119,7 +119,6 @@ fn run() -> eyre::Result<()> { main_args(args) } -#[allow(clippy::needless_return)] #[tokio::main] async fn main_args(args: Chisel) -> eyre::Result<()> { // Keeps track of whether or not an interrupt was the last input diff --git a/crates/common/src/provider/runtime_transport.rs b/crates/common/src/provider/runtime_transport.rs index a3c8a3958763e..07ab62af58a47 100644 --- a/crates/common/src/provider/runtime_transport.rs +++ b/crates/common/src/provider/runtime_transport.rs @@ -145,8 +145,8 @@ impl RuntimeTransport { } } - /// Connects to an HTTP [alloy_transport_http::Http] transport. - async fn connect_http(&self) -> Result { + /// Creates a new reqwest client from this transport. + pub fn reqwest_client(&self) -> Result { let mut client_builder = reqwest::Client::builder() .timeout(self.timeout) .tls_built_in_root_certs(self.url.scheme() == "https"); @@ -186,9 +186,12 @@ impl RuntimeTransport { client_builder = client_builder.default_headers(headers); - let client = - client_builder.build().map_err(RuntimeTransportError::HttpConstructionError)?; + Ok(client_builder.build()?) + } + /// Connects to an HTTP [alloy_transport_http::Http] transport. + async fn connect_http(&self) -> Result { + let client = self.reqwest_client()?; Ok(InnerTransport::Http(Http::with_client(client, self.url.clone()))) } diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index cb59e1f32e373..c360a353c35c3 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -2,11 +2,10 @@ #![allow(missing_docs)] -use crate::abi::abi_decode_calldata; +use crate::{abi::abi_decode_calldata, provider::runtime_transport::RuntimeTransportBuilder}; use alloy_json_abi::JsonAbi; use alloy_primitives::map::HashMap; use eyre::Context; -use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{ fmt, @@ -16,6 +15,8 @@ use std::{ }, time::Duration, }; + +const BASE_URL: &str = "https://api.openchain.xyz"; const SELECTOR_LOOKUP_URL: &str = "https://api.openchain.xyz/signature-database/v1/lookup"; const SELECTOR_IMPORT_URL: &str = "https://api.openchain.xyz/signature-database/v1/import"; @@ -38,20 +39,17 @@ pub struct OpenChainClient { } impl OpenChainClient { - /// Creates a new client with default settings + /// Creates a new client with default settings. pub fn new() -> eyre::Result { - let inner = reqwest::Client::builder() - .default_headers(HeaderMap::from_iter([( - HeaderName::from_static("user-agent"), - HeaderValue::from_static("forge"), - )])) - .timeout(REQ_TIMEOUT) + let inner = RuntimeTransportBuilder::new(BASE_URL.parse().unwrap()) + .with_timeout(REQ_TIMEOUT) .build() + .reqwest_client() .wrap_err("failed to build OpenChain client")?; Ok(Self { inner, - spurious_connection: Arc::new(Default::default()), - timedout_requests: Arc::new(Default::default()), + spurious_connection: Default::default(), + timedout_requests: Default::default(), max_timedout_requests: MAX_TIMEDOUT_REQ, }) } @@ -577,62 +575,11 @@ pub fn parse_signatures(tokens: Vec) -> ParsedSignatures { } #[cfg(test)] -#[allow(clippy::disallowed_macros)] -#[allow(clippy::needless_return)] mod tests { use super::*; - #[tokio::test(flavor = "multi_thread")] - async fn test_decode_selector() { - let sigs = decode_function_selector("0xa9059cbb").await; - assert_eq!(sigs.unwrap()[0], "transfer(address,uint256)".to_string()); - - let sigs = decode_function_selector("a9059cbb").await; - assert_eq!(sigs.unwrap()[0], "transfer(address,uint256)".to_string()); - - // invalid signature - decode_function_selector("0xa9059c") - .await - .map_err(|e| { - assert_eq!( - e.to_string(), - "Invalid selector 0xa9059c: expected 10 characters (including 0x prefix)." - ) - }) - .map(|_| panic!("Expected fourbyte error")) - .ok(); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_decode_calldata() { - let decoded = decode_calldata("0xa9059cbb0000000000000000000000000a2ac0c368dc8ec680a0c98c907656bd970675950000000000000000000000000000000000000000000000000000000767954a79").await; - assert_eq!(decoded.unwrap()[0], "transfer(address,uint256)".to_string()); - - let decoded = decode_calldata("a9059cbb0000000000000000000000000a2ac0c368dc8ec680a0c98c907656bd970675950000000000000000000000000000000000000000000000000000000767954a79").await; - assert_eq!(decoded.unwrap()[0], "transfer(address,uint256)".to_string()); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_import_selectors() { - let mut data = RawSelectorImportData::default(); - data.function.push("transfer(address,uint256)".to_string()); - let result = import_selectors(SelectorImportData::Raw(data)).await; - assert_eq!( - result.unwrap().result.function.duplicated.get("transfer(address,uint256)").unwrap(), - "0xa9059cbb" - ); - - let abi: JsonAbi = serde_json::from_str(r#"[{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function", "methodIdentifiers": {"transfer(address,uint256)(uint256)": "0xa9059cbb"}}]"#).unwrap(); - let result = import_selectors(SelectorImportData::Abi(vec![abi])).await; - println!("{result:?}"); - assert_eq!( - result.unwrap().result.function.duplicated.get("transfer(address,uint256)").unwrap(), - "0xa9059cbb" - ); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_parse_signatures() { + #[test] + fn test_parse_signatures() { let result = parse_signatures(vec!["transfer(address,uint256)".to_string()]); assert_eq!( result, @@ -687,58 +634,4 @@ mod tests { ParsedSignatures { signatures: Default::default(), ..Default::default() } ); } - - #[tokio::test(flavor = "multi_thread")] - async fn test_decode_event_topic() { - let decoded = decode_event_topic( - "0x7e1db2a1cd12f0506ecd806dba508035b290666b84b096a87af2fd2a1516ede6", - ) - .await; - assert_eq!(decoded.unwrap()[0], "updateAuthority(address,uint8)".to_string()); - - let decoded = - decode_event_topic("7e1db2a1cd12f0506ecd806dba508035b290666b84b096a87af2fd2a1516ede6") - .await; - assert_eq!(decoded.unwrap()[0], "updateAuthority(address,uint8)".to_string()); - - let decoded = decode_event_topic( - "0xb7009613e63fb13fd59a2fa4c206a992c1f090a44e5d530be255aa17fed0b3dd", - ) - .await; - assert_eq!(decoded.unwrap()[0], "canCall(address,address,bytes4)".to_string()); - - let decoded = - decode_event_topic("b7009613e63fb13fd59a2fa4c206a992c1f090a44e5d530be255aa17fed0b3dd") - .await; - assert_eq!(decoded.unwrap()[0], "canCall(address,address,bytes4)".to_string()); - } - - #[tokio::test(flavor = "multi_thread")] - async fn test_decode_selectors() { - let event_topics = vec![ - "7e1db2a1cd12f0506ecd806dba508035b290666b84b096a87af2fd2a1516ede6", - "0xb7009613e63fb13fd59a2fa4c206a992c1f090a44e5d530be255aa17fed0b3dd", - ]; - let decoded = decode_selectors(SelectorType::Event, event_topics).await; - let decoded = decoded.unwrap(); - assert_eq!( - decoded, - vec![ - Some(vec!["updateAuthority(address,uint8)".to_string()]), - Some(vec!["canCall(address,address,bytes4)".to_string()]), - ] - ); - - let function_selectors = vec!["0xa9059cbb", "0x70a08231", "313ce567"]; - let decoded = decode_selectors(SelectorType::Function, function_selectors).await; - let decoded = decoded.unwrap(); - assert_eq!( - decoded, - vec![ - Some(vec!["transfer(address,uint256)".to_string()]), - Some(vec!["balanceOf(address)".to_string()]), - Some(vec!["decimals()".to_string()]), - ] - ); - } } diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index 12f39b1ee029a..22e29bb13b47b 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -1994,7 +1994,6 @@ fn apply_state_changeset( } #[cfg(test)] -#[allow(clippy::needless_return)] mod tests { use crate::{backend::Backend, fork::CreateFork, opts::EvmOpts}; use alloy_primitives::{Address, U256}; diff --git a/crates/evm/core/src/fork/database.rs b/crates/evm/core/src/fork/database.rs index 29dccb9c7dec0..53595e451fd2f 100644 --- a/crates/evm/core/src/fork/database.rs +++ b/crates/evm/core/src/fork/database.rs @@ -262,7 +262,6 @@ impl DatabaseRef for ForkDbStateSnapshot { } #[cfg(test)] -#[allow(clippy::needless_return)] mod tests { use super::*; use crate::backend::BlockchainDbMeta; diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 801f9da373d5c..d1c6f61aa3571 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -179,40 +179,3 @@ impl Drop for SignaturesIdentifier { self.save(); } } - -#[cfg(test)] -#[allow(clippy::needless_return)] -mod tests { - use super::*; - - #[tokio::test(flavor = "multi_thread")] - async fn can_query_signatures() { - let tmp = tempfile::tempdir().unwrap(); - { - let sigs = SignaturesIdentifier::new(Some(tmp.path().into()), false).unwrap(); - - assert!(sigs.read().await.cached.events.is_empty()); - assert!(sigs.read().await.cached.functions.is_empty()); - - let func = sigs.write().await.identify_function(&[35, 184, 114, 221]).await.unwrap(); - let event = sigs - .write() - .await - .identify_event(&[ - 39, 119, 42, 220, 99, 219, 7, 170, 231, 101, 183, 30, 178, 181, 51, 6, 79, 167, - 129, 189, 87, 69, 126, 27, 19, 133, 146, 216, 25, 141, 9, 89, - ]) - .await - .unwrap(); - - assert_eq!(func, get_func("transferFrom(address,address,uint256)").unwrap()); - assert_eq!(event, get_event("Transfer(address,address,uint128)").unwrap()); - - // dropping saves the cache - } - - let sigs = SignaturesIdentifier::new(Some(tmp.path().into()), false).unwrap(); - assert_eq!(sigs.read().await.cached.events.len(), 1); - assert_eq!(sigs.read().await.cached.functions.len(), 1); - } -} diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index b2dfebcd6b74a..32861a78e4bde 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -611,7 +611,6 @@ impl EtherscanClient for Client { } #[cfg(test)] -#[allow(clippy::needless_return)] mod tests { use super::*; use alloy_primitives::hex; diff --git a/crates/forge/bin/cmd/doc/server.rs b/crates/forge/bin/cmd/doc/server.rs index b42106d99ed68..09662270a4514 100644 --- a/crates/forge/bin/cmd/doc/server.rs +++ b/crates/forge/bin/cmd/doc/server.rs @@ -90,7 +90,6 @@ impl Server { } } -#[allow(clippy::needless_return)] #[tokio::main] async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) -> io::Result<()> { let file_404 = build_dir.join(file_404); diff --git a/crates/forge/bin/cmd/soldeer.rs b/crates/forge/bin/cmd/soldeer.rs index b2c9a77f10747..a43600cf10406 100644 --- a/crates/forge/bin/cmd/soldeer.rs +++ b/crates/forge/bin/cmd/soldeer.rs @@ -40,7 +40,6 @@ mod tests { use soldeer_commands::{commands::Version, Command}; #[tokio::test] - #[allow(clippy::needless_return)] async fn test_soldeer_version() { let command = Command::Version(Version::default()); assert!(soldeer_commands::run(command).await.is_ok()); diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 87ba45f1936db..884914df4eddf 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -952,8 +952,7 @@ fn junit_xml_report(results: &BTreeMap, verbosity: u8) -> R #[cfg(test)] mod tests { use super::*; - use foundry_config::{Chain, InvariantConfig}; - use foundry_test_utils::forgetest_async; + use foundry_config::Chain; #[test] fn watch_parse() { @@ -987,67 +986,4 @@ mod tests { test("--chain-id=1", Chain::mainnet()); test("--chain-id=42", Chain::from_id(42)); } - - forgetest_async!(gas_report_fuzz_invariant, |prj, _cmd| { - // speed up test by running with depth of 15 - let config = Config { - invariant: { InvariantConfig { depth: 15, ..Default::default() } }, - ..Default::default() - }; - prj.write_config(config); - - prj.insert_ds_test(); - prj.add_source( - "Contracts.sol", - r#" -//SPDX-license-identifier: MIT - -import "./test.sol"; - -contract Foo { - function foo() public {} -} - -contract Bar { - function bar() public {} -} - - -contract FooBarTest is DSTest { - Foo public targetContract; - - function setUp() public { - targetContract = new Foo(); - } - - function invariant_dummy() public { - assertTrue(true); - } - - function testFuzz_bar(uint256 _val) public { - (new Bar()).bar(); - } -} - "#, - ) - .unwrap(); - - let args = TestArgs::parse_from([ - "foundry-cli", - "--gas-report", - "--root", - &prj.root().to_string_lossy(), - ]); - let outcome = args.run().await.unwrap(); - let gas_report = outcome.gas_report.as_ref().unwrap(); - - assert_eq!(gas_report.contracts.len(), 3, "{}", outcome.summary(Default::default())); - let call_cnts = gas_report - .contracts - .values() - .flat_map(|c| c.functions.values().flat_map(|f| f.values().map(|v| v.frames.len()))) - .collect::>(); - // assert that all functions were called at least 100 times - assert!(call_cnts.iter().all(|c| *c > 100)); - }); } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 43e240821fced..b964ac9bbac57 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -3520,6 +3520,50 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) ); }); +forgetest_async!(gas_report_fuzz_invariant, |prj, cmd| { + // speed up test by running with depth of 15 + let config = Config { + invariant: { InvariantConfig { depth: 15, ..Default::default() } }, + ..Default::default() + }; + prj.write_config(config); + + prj.insert_ds_test(); + prj.add_source( + "Contracts.sol", + r#" +import "./test.sol"; + +contract Foo { + function foo() public {} +} + +contract Bar { + function bar() public {} +} + +contract FooBarTest is DSTest { + Foo public targetContract; + + function setUp() public { + targetContract = new Foo(); + } + + function invariant_dummy() public { + assertTrue(true); + } + + function testFuzz_bar(uint256 _val) public { + (new Bar()).bar(); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--gas-report"]).assert_success(); +}); + // forgetest_init!(can_bind_enum_modules, |prj, cmd| { prj.clear(); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index a1abaa6168bc2..dbd9b3d8c4e37 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -689,7 +689,6 @@ contract TransientTest is Test { assertEq(t.locked(), false); } } - "#, ) .unwrap(); @@ -697,14 +696,17 @@ contract TransientTest is Test { cmd.args(["test", "-vvvv", "--isolate", "--evm-version", "cancun"]).assert_success(); }); -forgetest_init!(can_disable_block_gas_limit, |prj, cmd| { - prj.wipe_contracts(); +forgetest_init!( + #[ignore = "Too slow"] + can_disable_block_gas_limit, + |prj, cmd| { + prj.wipe_contracts(); - let endpoint = rpc::next_http_archive_rpc_url(); + let endpoint = rpc::next_http_archive_rpc_url(); - prj.add_test( - "Contract.t.sol", - &r#" + prj.add_test( + "Contract.t.sol", + &r#" import {Test} from "forge-std/Test.sol"; contract C is Test {} @@ -726,12 +728,13 @@ contract GasLimitTest is Test { } } "# - .replace("", &endpoint), - ) - .unwrap(); + .replace("", &endpoint), + ) + .unwrap(); - cmd.args(["test", "-vvvv", "--isolate", "--disable-block-gas-limit"]).assert_success(); -}); + cmd.args(["test", "-vvvv", "--isolate", "--disable-block-gas-limit"]).assert_success(); + } +); forgetest!(test_match_path, |prj, cmd| { prj.add_source( diff --git a/crates/forge/tests/it/main.rs b/crates/forge/tests/it/main.rs index ba1cff382da69..aaa129796a39a 100644 --- a/crates/forge/tests/it/main.rs +++ b/crates/forge/tests/it/main.rs @@ -1,5 +1,3 @@ -#![allow(clippy::needless_return)] - pub mod config; pub mod test_helpers; diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index ed0dfaa3c4a42..c10abcbd21280 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -275,7 +275,7 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String { } #[cfg(test)] -#[allow(clippy::needless_return, clippy::disallowed_macros)] +#[allow(clippy::disallowed_macros)] mod tests { use super::*; use alloy_primitives::address; diff --git a/crates/verify/src/etherscan/mod.rs b/crates/verify/src/etherscan/mod.rs index 0602055985a14..5a86c02a35e97 100644 --- a/crates/verify/src/etherscan/mod.rs +++ b/crates/verify/src/etherscan/mod.rs @@ -450,7 +450,6 @@ async fn ensure_solc_build_metadata(version: Version) -> Result { } #[cfg(test)] -#[allow(clippy::needless_return)] mod tests { use super::*; use clap::Parser; diff --git a/crates/wallets/src/wallet.rs b/crates/wallets/src/wallet.rs index 01a2328951127..29ce54438586d 100644 --- a/crates/wallets/src/wallet.rs +++ b/crates/wallets/src/wallet.rs @@ -148,13 +148,11 @@ impl From for WalletOpts { } #[cfg(test)] -#[allow(clippy::needless_return)] mod tests { + use super::*; use alloy_signer::Signer; use std::{path::Path, str::FromStr}; - use super::*; - #[tokio::test] async fn find_keystore() { let keystore = From 0e519ffde8ab5babde7dffa96fca28cfa3608b59 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 2 Feb 2025 21:58:16 +0100 Subject: [PATCH 1924/1963] chore: tweak coverage warnings (#9814) --- crates/config/src/lib.rs | 6 ++++-- crates/forge/bin/cmd/bind_json.rs | 2 +- crates/forge/bin/cmd/coverage.rs | 30 ++++++++++++++---------------- crates/forge/bin/cmd/eip712.rs | 2 +- crates/forge/bin/cmd/flatten.rs | 2 +- crates/forge/tests/cli/coverage.rs | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index de4cefc83c5d3..fa3dae1b97d1c 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -944,7 +944,7 @@ impl Config { /// Same as [`Self::project()`] but sets configures the project to not emit artifacts and ignore /// cache. - pub fn ephemeral_no_artifacts_project(&self) -> Result, SolcError> { + pub fn ephemeral_project(&self) -> Result, SolcError> { self.create_project(false, true) } @@ -1015,7 +1015,9 @@ impl Config { Ok(map) } - /// Creates a [Project] with the given `cached` and `no_artifacts` flags + /// Creates a [`Project`] with the given `cached` and `no_artifacts` flags. + /// + /// Prefer using [`Self::project`] or [`Self::ephemeral_project`] instead. pub fn create_project(&self, cached: bool, no_artifacts: bool) -> Result { let settings = self.compiler_settings()?; let paths = self.project_paths(); diff --git a/crates/forge/bin/cmd/bind_json.rs b/crates/forge/bin/cmd/bind_json.rs index 891e019bc5f85..918882aaa50f0 100644 --- a/crates/forge/bin/cmd/bind_json.rs +++ b/crates/forge/bin/cmd/bind_json.rs @@ -66,7 +66,7 @@ impl BindJsonArgs { /// in most of the cases. fn preprocess(self) -> Result { let config = self.load_config()?; - let project = config.create_project(false, true)?; + let project = config.ephemeral_project()?; let target_path = config.root.join(self.out.as_ref().unwrap_or(&config.bind_json.out)); diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index f8952f8504515..3a533131f3ff6 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -137,18 +137,17 @@ impl CoverageArgs { /// Builds the project. fn build(&self, config: &Config) -> Result<(Project, ProjectCompileOutput)> { - // Set up the project - let mut project = config.create_project(false, true)?; + let mut project = config.ephemeral_project()?; if self.ir_minimum { // print warning message - sh_warn!("{}", concat!( - "`--ir-minimum` enables viaIR with minimum optimization, \ - which can result in inaccurate source mappings.\n", - "Only use this flag as a workaround if you are experiencing \"stack too deep\" errors.\n", - "Note that \"viaIR\" is production ready since Solidity 0.8.13 and above.\n", - "See more: https://github.com/foundry-rs/foundry/issues/3357", - ))?; + sh_warn!( + "`--ir-minimum` enables `viaIR` with minimum optimization, \ + which can result in inaccurate source mappings.\n\ + Only use this flag as a workaround if you are experiencing \"stack too deep\" errors.\n\ + Note that `viaIR` is production ready since Solidity 0.8.13 and above.\n\ + See more: https://github.com/foundry-rs/foundry/issues/3357" + )?; // Enable viaIR with minimum optimization: https://github.com/ethereum/solidity/issues/12533#issuecomment-1013073350 // And also in new releases of Solidity: https://github.com/ethereum/solidity/issues/13972#issuecomment-1628632202 @@ -162,19 +161,18 @@ impl CoverageArgs { project.settings.solc.settings.sanitize(&version, SolcLanguage::Solidity); project.settings.solc.evm_version = evm_version; } else { + sh_warn!( + "optimizer settings and `viaIR` have been disabled for accurate coverage reports.\n\ + If you encounter \"stack too deep\" errors, consider using `--ir-minimum` which \ + enables `viaIR` with minimum optimization resolving most of the errors" + )?; + project.settings.solc.optimizer.disable(); project.settings.solc.optimizer.runs = None; project.settings.solc.optimizer.details = None; project.settings.solc.via_ir = None; } - let mut warning = - "optimizer settings have been disabled for accurate coverage reports".to_string(); - if !self.ir_minimum { - warning += ", if you encounter \"stack too deep\" errors, consider using `--ir-minimum` which enables viaIR with minimum optimization resolving most of the errors"; - } - sh_warn!("{warning}")?; - let output = ProjectCompiler::default() .compile(&project)? .with_stripped_file_prefixes(project.root()); diff --git a/crates/forge/bin/cmd/eip712.rs b/crates/forge/bin/cmd/eip712.rs index fe05d027a0f5d..6211695ab48d5 100644 --- a/crates/forge/bin/cmd/eip712.rs +++ b/crates/forge/bin/cmd/eip712.rs @@ -25,7 +25,7 @@ pub struct Eip712Args { impl Eip712Args { pub fn run(self) -> Result<()> { let config = self.load_config()?; - let mut project = config.create_project(false, true)?; + let mut project = config.ephemeral_project()?; let target_path = dunce::canonicalize(self.target_path)?; project.update_output_selection(|selection| { *selection = OutputSelection::ast_output_selection(); diff --git a/crates/forge/bin/cmd/flatten.rs b/crates/forge/bin/cmd/flatten.rs index 5a5e0cdafa980..8bc5d44724619 100644 --- a/crates/forge/bin/cmd/flatten.rs +++ b/crates/forge/bin/cmd/flatten.rs @@ -41,7 +41,7 @@ impl FlattenArgs { // flatten is a subset of `BuildArgs` so we can reuse that to get the config let build = BuildOpts { project_paths, ..Default::default() }; let config = build.load_config()?; - let project = config.create_project(false, true)?; + let project = config.ephemeral_project()?; let target_path = dunce::canonicalize(target_path)?; diff --git a/crates/forge/tests/cli/coverage.rs b/crates/forge/tests/cli/coverage.rs index 7f7c06299172b..d06c9e37fa9cd 100644 --- a/crates/forge/tests/cli/coverage.rs +++ b/crates/forge/tests/cli/coverage.rs @@ -1687,11 +1687,6 @@ contract AContract { "#]]); }); -#[track_caller] -fn assert_lcov(cmd: &mut TestCommand, data: impl IntoData) { - cmd.args(["--report=lcov", "--report-file"]).assert_file(data.into_data()); -} - forgetest!(no_artifacts_written, |prj, cmd| { prj.insert_ds_test(); prj.add_source( @@ -1751,3 +1746,8 @@ contract AContractTest is DSTest { assert!(files.is_empty()); }); + +#[track_caller] +fn assert_lcov(cmd: &mut TestCommand, data: impl IntoData) { + cmd.args(["--report=lcov", "--report-file"]).assert_file(data.into_data()); +} From d071cb10f24438b28f3f61e91001fc52f4e42f02 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 3 Feb 2025 07:08:05 +0100 Subject: [PATCH 1925/1963] test: update config with a closure (#9813) --- .github/scripts/matrices.py | 6 +- Cargo.toml | 1 + Makefile | 2 +- crates/forge/tests/cli/build.rs | 90 ++-- crates/forge/tests/cli/cmd.rs | 739 ++++++++++++++--------------- crates/forge/tests/cli/config.rs | 116 ++--- crates/forge/tests/cli/create.rs | 33 +- crates/forge/tests/cli/script.rs | 12 +- crates/forge/tests/cli/test_cmd.rs | 179 ++++--- crates/forge/tests/cli/utils.rs | 41 +- crates/forge/tests/it/fuzz.rs | 6 +- crates/forge/tests/it/inline.rs | 4 +- crates/forge/tests/it/invariant.rs | 40 +- crates/test-utils/src/util.rs | 35 +- 14 files changed, 608 insertions(+), 696 deletions(-) diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py index 51fc69123cdfc..4ad0c3acc34dc 100755 --- a/.github/scripts/matrices.py +++ b/.github/scripts/matrices.py @@ -83,19 +83,19 @@ def __init__( ), Case( name="integration", - filter="kind(test) & !test(/issue|forge_std|ext_integration/)", + filter="kind(test) & !test(/\\b(issue|ext_integration)/)", n_partitions=3, pr_cross_platform=True, ), Case( name="integration / issue-repros", - filter="package(=forge) & test(~issue)", + filter="package(=forge) & test(/\\bissue/)", n_partitions=2, pr_cross_platform=False, ), Case( name="integration / external", - filter="package(=forge) & test(~ext_integration)", + filter="package(=forge) & test(/\\bext_integration/)", n_partitions=2, pr_cross_platform=False, ), diff --git a/Cargo.toml b/Cargo.toml index 3f7f95fd4343a..a1ee42396be90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,6 +112,7 @@ alloy-primitives.opt-level = 3 alloy-sol-type-parser.opt-level = 3 alloy-sol-types.opt-level = 3 hashbrown.opt-level = 3 +foldhash.opt-level = 3 keccak.opt-level = 3 revm-interpreter.opt-level = 3 revm-precompile.opt-level = 3 diff --git a/Makefile b/Makefile index 79544ce85423d..429e6721fee67 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,7 @@ lint: ## Run all linters. ## Testing test-foundry: - cargo nextest run -E 'kind(test) & !test(/issue|forge_std|ext_integration/)' + cargo nextest run -E 'kind(test) & !test(/\b(issue|ext_integration)/)' test-doc: cargo test --doc --workspace diff --git a/crates/forge/tests/cli/build.rs b/crates/forge/tests/cli/build.rs index 7c9355471d150..c586db4a66525 100644 --- a/crates/forge/tests/cli/build.rs +++ b/crates/forge/tests/cli/build.rs @@ -1,5 +1,4 @@ -use crate::utils::generate_large_contract; -use foundry_config::Config; +use crate::utils::generate_large_init_contract; use foundry_test_utils::{forgetest, snapbox::IntoData, str}; use globset::Glob; @@ -72,18 +71,17 @@ contract Dummy { }); forgetest!(initcode_size_exceeds_limit, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); - prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); + prj.add_source("LargeContract.sol", generate_large_init_contract(50_000).as_str()).unwrap(); cmd.args(["build", "--sizes"]).assert_failure().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] Compiler run successful! -╭--------------+------------------+-------------------+--------------------+---------------------╮ -| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | -+================================================================================================+ -| HugeContract | 194 | 49,344 | 24,382 | -192 | -╰--------------+------------------+-------------------+--------------------+---------------------╯ +╭---------------+------------------+-------------------+--------------------+---------------------╮ +| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | ++=================================================================================================+ +| LargeContract | 62 | 50,125 | 24,514 | -973 | +╰---------------+------------------+-------------------+--------------------+---------------------╯ "#]]); @@ -91,34 +89,32 @@ Compiler run successful! cmd.forge_fuse().args(["build", "--sizes", "--json"]).assert_failure().stdout_eq( str![[r#" { - "HugeContract":{ - "runtime_size":194, - "init_size":49344, - "runtime_margin":24382, - "init_margin":-192 - } + "LargeContract": { + "runtime_size": 62, + "init_size": 50125, + "runtime_margin": 24514, + "init_margin": -973 + } } "#]] .is_json(), ); -}); -forgetest!(initcode_size_limit_can_be_ignored, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); - prj.add_source("LargeContract", generate_large_contract(5450).as_str()).unwrap(); - cmd.args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq(str![[r#" -[COMPILING_FILES] with [SOLC_VERSION] -[SOLC_VERSION] [ELAPSED] -Compiler run successful! + // Ignore EIP-3860 -╭--------------+------------------+-------------------+--------------------+---------------------╮ -| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | -+================================================================================================+ -| HugeContract | 194 | 49,344 | 24,382 | -192 | -╰--------------+------------------+-------------------+--------------------+---------------------╯ + cmd.forge_fuse().args(["build", "--sizes", "--ignore-eip-3860"]).assert_success().stdout_eq( + str![[r#" +No files changed, compilation skipped +╭---------------+------------------+-------------------+--------------------+---------------------╮ +| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | ++=================================================================================================+ +| LargeContract | 62 | 50,125 | 24,514 | -973 | +╰---------------+------------------+-------------------+--------------------+---------------------╯ -"#]]); + +"#]], + ); cmd.forge_fuse() .args(["build", "--sizes", "--ignore-eip-3860", "--json"]) @@ -126,13 +122,13 @@ Compiler run successful! .stdout_eq( str![[r#" { - "HugeContract": { - "runtime_size": 194, - "init_size": 49344, - "runtime_margin": 24382, - "init_margin": -192 + "LargeContract": { + "runtime_size": 62, + "init_size": 50125, + "runtime_margin": 24514, + "init_margin": -973 } -} +} "#]] .is_json(), ); @@ -150,10 +146,8 @@ Compiler run successful! // tests build output is as expected forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { - prj.write_config(Config { - optimizer: Some(true), - solc: Some(foundry_config::SolcReq::Version(semver::Version::new(0, 8, 27))), - ..Default::default() + prj.update_config(|config| { + config.solc = Some(foundry_config::SolcReq::Version(semver::Version::new(0, 8, 27))); }); cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" @@ -162,7 +156,7 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { ╭----------+------------------+-------------------+--------------------+---------------------╮ | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | +============================================================================================+ -| Counter | 236 | 263 | 24,340 | 48,889 | +| Counter | 481 | 509 | 24,095 | 48,643 | ╰----------+------------------+-------------------+--------------------+---------------------╯ @@ -172,10 +166,10 @@ forgetest_init!(build_sizes_no_forge_std, |prj, cmd| { str![[r#" { "Counter": { - "runtime_size": 236, - "init_size": 263, - "runtime_margin": 24340, - "init_margin": 48889 + "runtime_size": 481, + "init_size": 509, + "runtime_margin": 24095, + "init_margin": 48643 } } "#]] @@ -203,11 +197,9 @@ contract ValidContract {} ) .unwrap(); - let config = Config { - skip: vec![Glob::new("src/InvalidContract.sol").unwrap().into()], - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.skip = vec![Glob::new("src/InvalidContract.sol").unwrap().into()]; + }); cmd.args(["build"]).assert_success(); }); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index b964ac9bbac57..7f2f5c3d570cc 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -723,8 +723,7 @@ forgetest!(can_clean_hardhat, PathStyle::HardHat, |prj, cmd| { // checks that `clean` also works with the "out" value set in Config forgetest_init!(can_clean_config, |prj, cmd| { - let config = Config { out: "custom-out".into(), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.out = "custom-out".into()); cmd.arg("build").assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] [SOLC_VERSION] [ELAPSED] @@ -742,12 +741,10 @@ Compiler run successful! // checks that `clean` removes fuzz and invariant cache dirs forgetest_init!(can_clean_test_cache, |prj, cmd| { - let config = Config { - fuzz: FuzzConfig::new("cache/fuzz".into()), - invariant: InvariantConfig::new("cache/invariant".into()), - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz = FuzzConfig::new("cache/fuzz".into()); + config.invariant = InvariantConfig::new("cache/invariant".into()); + }); // default test contract is written in custom out directory let fuzz_cache_dir = prj.root().join("cache/fuzz"); let _ = fs::create_dir(fuzz_cache_dir.clone()); @@ -1016,10 +1013,9 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // test that `forge build` does not print `(with warnings)` if file path is ignored forgetest!(can_compile_without_warnings_ignored_file_paths, |prj, cmd| { // Ignoring path and setting empty error_codes as default would set would set some error codes - prj.write_config(Config { - ignored_file_paths: vec![Path::new("src").to_path_buf()], - ignored_error_codes: vec![], - ..Default::default() + prj.update_config(|config| { + config.ignored_file_paths = vec![Path::new("src").to_path_buf()]; + config.ignored_error_codes = vec![]; }); prj.add_raw_source( @@ -1041,8 +1037,7 @@ Compiler run successful! "#]]); // Reconfigure without ignored paths or error codes and check for warnings - // need to reset empty error codes as default would set some error codes - prj.write_config(Config { ignored_error_codes: vec![], ..Default::default() }); + prj.update_config(|config| config.ignored_file_paths = vec![]); cmd.forge_fuse().args(["build", "--force"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -1058,11 +1053,9 @@ Warning: SPDX license identifier not provided in source file. Before publishing, // test that `forge build` does not print `(with warnings)` if there aren't any forgetest!(can_compile_without_warnings, |prj, cmd| { - let config = Config { - ignored_error_codes: vec![SolidityErrorCode::SpdxLicenseNotProvided], - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.ignored_error_codes = vec![SolidityErrorCode::SpdxLicenseNotProvided]; + }); prj.add_raw_source( "A", r" @@ -1082,8 +1075,9 @@ Compiler run successful! "#]]); // don't ignore errors - let config = Config { ignored_error_codes: vec![], ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.ignored_error_codes = vec![]; + }); cmd.forge_fuse().args(["build", "--force"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -1100,8 +1094,10 @@ Warning: SPDX license identifier not provided in source file. Before publishing, // test that `forge build` compiles when severity set to error, fails when set to warning, and // handles ignored error codes as an exception forgetest!(can_fail_compile_with_warnings, |prj, cmd| { - let config = Config { ignored_error_codes: vec![], deny_warnings: false, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.ignored_error_codes = vec![]; + config.deny_warnings = false; + }); prj.add_raw_source( "A", r" @@ -1126,8 +1122,10 @@ Warning: SPDX license identifier not provided in source file. Before publishing, "#]]); // warning fails to compile - let config = Config { ignored_error_codes: vec![], deny_warnings: true, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.ignored_error_codes = vec![]; + config.deny_warnings = true; + }); cmd.forge_fuse().args(["build", "--force"]).assert_failure().stderr_eq(str![[r#" Error: Compiler run failed: @@ -1138,12 +1136,10 @@ Warning: SPDX license identifier not provided in source file. Before publishing, "#]]); // ignores error code and compiles - let config = Config { - ignored_error_codes: vec![SolidityErrorCode::SpdxLicenseNotProvided], - deny_warnings: true, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.ignored_error_codes = vec![SolidityErrorCode::SpdxLicenseNotProvided]; + config.deny_warnings = true; + }); cmd.forge_fuse().args(["build", "--force"]).assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -1446,8 +1442,8 @@ Installing forge-5980-test in [..] (url: Some("https://github.com/evalir/forge-5 cmd.forge_fuse().args(["update", "lib/forge-5980-test"]).assert_empty_stdout(); // add explicit remappings for test file - let config = Config { - remappings: vec![ + prj.update_config(|config| { + config.remappings = vec![ Remapping::from_str("forge-5980-test/=lib/forge-5980-test/src/").unwrap().into(), // explicit remapping for sub-dependendy seems necessary for some reason Remapping::from_str( @@ -1455,10 +1451,8 @@ Installing forge-5980-test in [..] (url: Some("https://github.com/evalir/forge-5 ) .unwrap() .into(), - ], - ..Default::default() - }; - prj.write_config(config); + ]; + }); // create test file that uses the top-level dependency; if the sub-dependency is updated, // compilation will fail @@ -1572,11 +1566,9 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // report for all - prj.write_config(Config { - optimizer: Some(true), - gas_reports: (vec!["*".to_string()]), - gas_reports_ignore: (vec![]), - ..Default::default() + prj.update_config(|config| { + config.gas_reports = vec!["*".to_string()]; + config.gas_reports_ignore = vec![]; }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" @@ -1586,13 +1578,13 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101532 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| foo | 45370 | 45370 | 45370 | 45370 | 1 | +| foo | 45656 | 45656 | 45656 | 45656 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ ╭------------------------------------------+-----------------+--------+--------+--------+---------╮ @@ -1600,13 +1592,13 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1614,13 +1606,13 @@ forgetest!(gas_report_all_contracts, |prj, cmd| { +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101520 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| bar | 64832 | 64832 | 64832 | 64832 | 1 | +| bar | 67683 | 67683 | 67683 | 67683 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -1633,48 +1625,48 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 101532, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "foo()": { "calls": 1, - "min": 45370, - "mean": 45370, - "median": 45370, - "max": 45370 + "min": 45656, + "mean": 45656, + "median": 45656, + "max": 45656 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 101520, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "bar()": { "calls": 1, - "min": 64832, - "mean": 64832, - "median": 64832, - "max": 64832 + "min": 67683, + "mean": 67683, + "median": 67683, + "max": 67683 } } } @@ -1683,7 +1675,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { optimizer: Some(true), gas_reports: (vec![]), ..Default::default() }); + prj.update_config(|config| config.gas_reports = vec![]); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1691,13 +1683,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101532 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| foo | 45370 | 45370 | 45370 | 45370 | 1 | +| foo | 45656 | 45656 | 45656 | 45656 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ ╭------------------------------------------+-----------------+--------+--------+--------+---------╮ @@ -1705,13 +1697,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1719,13 +1711,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101520 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| bar | 64832 | 64832 | 64832 | 64832 | 1 | +| bar | 67683 | 67683 | 67683 | 67683 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -1738,48 +1730,48 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 101532, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "foo()": { "calls": 1, - "min": 45370, - "mean": 45370, - "median": 45370, - "max": 45370 + "min": 45656, + "mean": 45656, + "median": 45656, + "max": 45656 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 101520, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "bar()": { "calls": 1, - "min": 64832, - "mean": 64832, - "median": 64832, - "max": 64832 + "min": 67683, + "mean": 67683, + "median": 67683, + "max": 67683 } } } @@ -1788,11 +1780,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { - optimizer: Some(true), - gas_reports: (vec!["*".to_string()]), - ..Default::default() - }); + prj.update_config(|config| config.gas_reports = vec!["*".to_string()]); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1800,13 +1788,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101532 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| foo | 45370 | 45370 | 45370 | 45370 | 1 | +| foo | 45656 | 45656 | 45656 | 45656 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ ╭------------------------------------------+-----------------+--------+--------+--------+---------╮ @@ -1814,13 +1802,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1828,13 +1816,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101520 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| bar | 64832 | 64832 | 64832 | 64832 | 1 | +| bar | 67683 | 67683 | 67683 | 67683 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -1847,48 +1835,48 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 101532, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "foo()": { "calls": 1, - "min": 45370, - "mean": 45370, - "median": 45370, - "max": 45370 + "min": 45656, + "mean": 45656, + "median": 45656, + "max": 45656 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 101520, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "bar()": { "calls": 1, - "min": 64832, - "mean": 64832, - "median": 64832, - "max": 64832 + "min": 67683, + "mean": 67683, + "median": 67683, + "max": 67683 } } } @@ -1897,14 +1885,9 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) .is_json(), ); - prj.write_config(Config { - optimizer: Some(true), - gas_reports: (vec![ - "ContractOne".to_string(), - "ContractTwo".to_string(), - "ContractThree".to_string(), - ]), - ..Default::default() + prj.update_config(|config| { + config.gas_reports = + vec!["ContractOne".to_string(), "ContractTwo".to_string(), "ContractThree".to_string()]; }); cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -1913,13 +1896,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101532 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| foo | 45370 | 45370 | 45370 | 45370 | 1 | +| foo | 45656 | 45656 | 45656 | 45656 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ ╭------------------------------------------+-----------------+--------+--------+--------+---------╮ @@ -1927,13 +1910,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -1941,13 +1924,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101520 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| bar | 64832 | 64832 | 64832 | 64832 | 1 | +| bar | 67683 | 67683 | 67683 | 67683 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -1960,48 +1943,48 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 101532, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "foo()": { "calls": 1, - "min": 45370, - "mean": 45370, - "median": 45370, - "max": 45370 + "min": 45656, + "mean": 45656, + "median": 45656, + "max": 45656 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 101520, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "bar()": { "calls": 1, - "min": 64832, - "mean": 64832, - "median": 64832, - "max": 64832 + "min": 67683, + "mean": 67683, + "median": 67683, + "max": 67683 } } } @@ -2016,11 +1999,7 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // report for One - prj.write_config(Config { - optimizer: Some(true), - gas_reports: vec!["ContractOne".to_string()], - ..Default::default() - }); + prj.update_config(|config| config.gas_reports = vec!["ContractOne".to_string()]); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -2029,13 +2008,13 @@ forgetest!(gas_report_some_contracts, |prj, cmd| { +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101532 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| foo | 45370 | 45370 | 45370 | 45370 | 1 | +| foo | 45656 | 45656 | 45656 | 45656 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -2048,16 +2027,16 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 101532, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "foo()": { "calls": 1, - "min": 45370, - "mean": 45370, - "median": 45370, - "max": 45370 + "min": 45656, + "mean": 45656, + "median": 45656, + "max": 45656 } } } @@ -2067,11 +2046,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); // report for Two - prj.write_config(Config { - optimizer: Some(true), - gas_reports: vec!["ContractTwo".to_string()], - ..Default::default() - }); + prj.update_config(|config| config.gas_reports = vec!["ContractTwo".to_string()]); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -2080,13 +2055,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101520 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| bar | 64832 | 64832 | 64832 | 64832 | 1 | +| bar | 67683 | 67683 | 67683 | 67683 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -2099,16 +2074,16 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 101520, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "bar()": { "calls": 1, - "min": 64832, - "mean": 64832, - "median": 64832, - "max": 64832 + "min": 67683, + "mean": 67683, + "median": 67683, + "max": 67683 } } } @@ -2118,11 +2093,7 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) ); // report for Three - prj.write_config(Config { - optimizer: Some(true), - gas_reports: vec!["ContractThree".to_string()], - ..Default::default() - }); + prj.update_config(|config| config.gas_reports = vec!["ContractThree".to_string()]); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" ... @@ -2131,13 +2102,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ @@ -2150,16 +2121,16 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } } @@ -2174,11 +2145,9 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap(); // ignore ContractOne - prj.write_config(Config { - optimizer: Some(true), - gas_reports: (vec!["*".to_string()]), - gas_reports_ignore: (vec!["ContractOne".to_string()]), - ..Default::default() + prj.update_config(|config| { + config.gas_reports = vec!["*".to_string()]; + config.gas_reports_ignore = vec!["ContractOne".to_string()]; }); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" @@ -2188,13 +2157,13 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -2202,13 +2171,13 @@ forgetest!(gas_report_ignore_some_contracts, |prj, cmd| { +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101520 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| bar | 64832 | 64832 | 64832 | 64832 | 1 | +| bar | 67683 | 67683 | 67683 | 67683 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -2221,32 +2190,32 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 101520, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "bar()": { "calls": 1, - "min": 64832, - "mean": 64832, - "median": 64832, - "max": 64832 + "min": 67683, + "mean": 67683, + "median": 67683, + "max": 67683 } } } @@ -2257,11 +2226,9 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // ignore ContractTwo cmd.forge_fuse(); - prj.write_config(Config { - optimizer: Some(true), - gas_reports: (vec![]), - gas_reports_ignore: (vec!["ContractTwo".to_string()]), - ..Default::default() + prj.update_config(|config| { + config.gas_reports = vec![]; + config.gas_reports_ignore = vec!["ContractTwo".to_string()]; }); cmd.forge_fuse(); cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#" @@ -2271,13 +2238,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101532 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| foo | 45370 | 45370 | 45370 | 45370 | 1 | +| foo | 45656 | 45656 | 45656 | 45656 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ ╭------------------------------------------+-----------------+--------+--------+--------+---------╮ @@ -2285,13 +2252,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ @@ -2304,32 +2271,32 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 101532, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "foo()": { "calls": 1, - "min": 45370, - "mean": 45370, - "median": 45370, - "max": 45370 + "min": 45656, + "mean": 45656, + "median": 45656, + "max": 45656 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } } @@ -2344,15 +2311,10 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) // preferable than not getting one you expect. A warning is printed to stderr // indicating the "double listing". cmd.forge_fuse(); - prj.write_config(Config { - optimizer: Some(true), - gas_reports: (vec![ - "ContractOne".to_string(), - "ContractTwo".to_string(), - "ContractThree".to_string(), - ]), - gas_reports_ignore: (vec!["ContractThree".to_string()]), - ..Default::default() + prj.update_config(|config| { + config.gas_reports = + vec!["ContractOne".to_string(), "ContractTwo".to_string(), "ContractThree".to_string()]; + config.gas_reports_ignore = vec!["ContractThree".to_string()]; }); cmd.forge_fuse(); cmd.arg("test") @@ -2365,13 +2327,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101532 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| foo | 45370 | 45370 | 45370 | 45370 | 1 | +| foo | 45656 | 45656 | 45656 | 45656 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ ╭------------------------------------------+-----------------+--------+--------+--------+---------╮ @@ -2379,13 +2341,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=================================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| -| 101748 | 242 | | | | | +| 133243 | 395 | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |------------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+--------+--------+--------+---------| -| baz | 259210 | 259210 | 259210 | 259210 | 1 | +| baz | 287711 | 287711 | 287711 | 287711 | 1 | ╰------------------------------------------+-----------------+--------+--------+--------+---------╯ ╭----------------------------------------+-----------------+-------+--------+-------+---------╮ @@ -2393,13 +2355,13 @@ Ran 3 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) +=============================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| -| 101520 | 241 | | | | | +| 133027 | 394 | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------------+-----------------+-------+--------+-------+---------| -| bar | 64832 | 64832 | 64832 | 64832 | 1 | +| bar | 67683 | 67683 | 67683 | 67683 | 1 | ╰----------------------------------------+-----------------+-------+--------+-------+---------╯ @@ -2422,48 +2384,48 @@ Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. { "contract": "src/Contracts.sol:ContractOne", "deployment": { - "gas": 101532, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "foo()": { "calls": 1, - "min": 45370, - "mean": 45370, - "median": 45370, - "max": 45370 + "min": 45656, + "mean": 45656, + "median": 45656, + "max": 45656 } } }, { "contract": "src/Contracts.sol:ContractThree", "deployment": { - "gas": 101748, - "size": 242 + "gas": 133243, + "size": 395 }, "functions": { "baz()": { "calls": 1, - "min": 259210, - "mean": 259210, - "median": 259210, - "max": 259210 + "min": 287711, + "mean": 287711, + "median": 287711, + "max": 287711 } } }, { "contract": "src/Contracts.sol:ContractTwo", "deployment": { - "gas": 101520, - "size": 241 + "gas": 133027, + "size": 394 }, "functions": { "bar()": { "calls": 1, - "min": 64832, - "mean": 64832, - "median": 64832, - "max": 64832 + "min": 67683, + "mean": 67683, + "median": 67683, + "max": 67683 } } } @@ -2479,7 +2441,6 @@ Warning: ContractThree is listed in both 'gas_reports' and 'gas_reports_ignore'. }); forgetest!(gas_report_flatten_multiple_selectors, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.insert_ds_test(); prj.add_source( "Counter.sol", @@ -2531,19 +2492,19 @@ contract CounterTest is DSTest { +=======================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------+-----------------+-------+--------+-------+---------| -| 99711 | 240 | | | | | +| 172107 | 578 | | | | | |----------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------+-----------------+-------+--------+-------+---------| -| a | 2259 | 2259 | 2259 | 2259 | 1 | +| a | 2402 | 2402 | 2402 | 2402 | 1 | |----------------------------------+-----------------+-------+--------+-------+---------| -| b | 2304 | 2304 | 2304 | 2304 | 1 | +| b | 2447 | 2447 | 2447 | 2447 | 1 | |----------------------------------+-----------------+-------+--------+-------+---------| -| setNumber(int256) | 23646 | 33602 | 33602 | 43558 | 2 | +| setNumber(int256) | 23851 | 33807 | 33807 | 43763 | 2 | |----------------------------------+-----------------+-------+--------+-------+---------| -| setNumber(uint256) | 23601 | 33557 | 33557 | 43513 | 2 | +| setNumber(uint256) | 23806 | 33762 | 33762 | 43718 | 2 | ╰----------------------------------+-----------------+-------+--------+-------+---------╯ @@ -2556,37 +2517,37 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) { "contract": "src/Counter.sol:Counter", "deployment": { - "gas": 99711, - "size": 240 + "gas": 172107, + "size": 578 }, "functions": { "a()": { "calls": 1, - "min": 2259, - "mean": 2259, - "median": 2259, - "max": 2259 + "min": 2402, + "mean": 2402, + "median": 2402, + "max": 2402 }, "b()": { "calls": 1, - "min": 2304, - "mean": 2304, - "median": 2304, - "max": 2304 + "min": 2447, + "mean": 2447, + "median": 2447, + "max": 2447 }, "setNumber(int256)": { "calls": 2, - "min": 23646, - "mean": 33602, - "median": 33602, - "max": 43558 + "min": 23851, + "mean": 33807, + "median": 33807, + "max": 43763 }, "setNumber(uint256)": { "calls": 2, - "min": 23601, - "mean": 33557, - "median": 33557, - "max": 43513 + "min": 23806, + "mean": 33762, + "median": 33762, + "max": 43718 } } } @@ -2598,7 +2559,6 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_with_fallback, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_test( "DelegateProxyTest.sol", r#" @@ -2659,15 +2619,15 @@ contract GasReportFallbackTest is Test { +========================================================================================================+ | Deployment Cost | Deployment Size | | | | | |---------------------------------------------------+-----------------+-------+--------+-------+---------| -| 107054 | 300 | | | | | +| 117171 | 471 | | | | | |---------------------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |---------------------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |---------------------------------------------------+-----------------+-------+--------+-------+---------| -| deposit | 21159 | 21159 | 21159 | 21159 | 1 | +| deposit | 21185 | 21185 | 21185 | 21185 | 1 | |---------------------------------------------------+-----------------+-------+--------+-------+---------| -| fallback | 29384 | 29384 | 29384 | 29384 | 1 | +| fallback | 29758 | 29758 | 29758 | 29758 | 1 | ╰---------------------------------------------------+-----------------+-------+--------+-------+---------╯ ╭-----------------------------------------------------+-----------------+------+--------+------+---------╮ @@ -2675,13 +2635,13 @@ contract GasReportFallbackTest is Test { +========================================================================================================+ | Deployment Cost | Deployment Size | | | | | |-----------------------------------------------------+-----------------+------+--------+------+---------| -| 104463 | 263 | | | | | +| 153531 | 494 | | | | | |-----------------------------------------------------+-----------------+------+--------+------+---------| | | | | | | | |-----------------------------------------------------+-----------------+------+--------+------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |-----------------------------------------------------+-----------------+------+--------+------+---------| -| deposit | 3316 | 3316 | 3316 | 3316 | 1 | +| deposit | 3661 | 3661 | 3661 | 3661 | 1 | ╰-----------------------------------------------------+-----------------+------+--------+------+---------╯ @@ -2698,39 +2658,39 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) { "contract": "test/DelegateProxyTest.sol:DelegateProxy", "deployment": { - "gas": 107054, - "size": 300 + "gas": 117171, + "size": 471 }, "functions": { "deposit()": { "calls": 1, - "min": 21159, - "mean": 21159, - "median": 21159, - "max": 21159 + "min": 21185, + "mean": 21185, + "median": 21185, + "max": 21185 }, "fallback()": { "calls": 1, - "min": 29384, - "mean": 29384, - "median": 29384, - "max": 29384 + "min": 29758, + "mean": 29758, + "median": 29758, + "max": 29758 } } }, { "contract": "test/DelegateProxyTest.sol:ProxiedContract", "deployment": { - "gas": 104463, - "size": 263 + "gas": 153531, + "size": 494 }, "functions": { "deposit(uint256)": { "calls": 1, - "min": 3316, - "mean": 3316, - "median": 3316, - "max": 3316 + "min": 3661, + "mean": 3661, + "median": 3661, + "max": 3661 } } } @@ -2742,7 +2702,6 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_test( "NestedDeployTest.sol", r#" @@ -2784,13 +2743,13 @@ contract NestedDeploy is Test { +======================================================================================================+ | Deployment Cost | Deployment Size | | | | | |-------------------------------------------------+-----------------+-------+--------+-------+---------| -| 0 | 124 | | | | | +| 0 | 132 | | | | | |-------------------------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |-------------------------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |-------------------------------------------------+-----------------+-------+--------+-------+---------| -| w | 21161 | 21161 | 21161 | 21161 | 1 | +| w | 21185 | 21185 | 21185 | 21185 | 1 | ╰-------------------------------------------------+-----------------+-------+--------+-------+---------╯ ╭------------------------------------------+-----------------+-----+--------+-----+---------╮ @@ -2798,13 +2757,13 @@ contract NestedDeploy is Test { +===========================================================================================+ | Deployment Cost | Deployment Size | | | | | |------------------------------------------+-----------------+-----+--------+-----+---------| -| 0 | 477 | | | | | +| 0 | 731 | | | | | |------------------------------------------+-----------------+-----+--------+-----+---------| | | | | | | | |------------------------------------------+-----------------+-----+--------+-----+---------| | Function Name | Min | Avg | Median | Max | # Calls | |------------------------------------------+-----------------+-----+--------+-----+---------| -| child | 323 | 323 | 323 | 323 | 1 | +| child | 681 | 681 | 681 | 681 | 1 | ╰------------------------------------------+-----------------+-----+--------+-----+---------╯ ╭-------------------------------------------+-----------------+-----+--------+-----+---------╮ @@ -2812,13 +2771,13 @@ contract NestedDeploy is Test { +============================================================================================+ | Deployment Cost | Deployment Size | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| -| 251997 | 739 | | | | | +| 328961 | 1163 | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| | | | | | | | |-------------------------------------------+-----------------+-----+--------+-----+---------| | Function Name | Min | Avg | Median | Max | # Calls | |-------------------------------------------+-----------------+-----+--------+-----+---------| -| child | 181 | 181 | 181 | 181 | 1 | +| child | 525 | 525 | 525 | 525 | 1 | ╰-------------------------------------------+-----------------+-----+--------+-----+---------╯ @@ -2836,15 +2795,15 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "contract": "test/NestedDeployTest.sol:AnotherChild", "deployment": { "gas": 0, - "size": 124 + "size": 132 }, "functions": { "w()": { "calls": 1, - "min": 21161, - "mean": 21161, - "median": 21161, - "max": 21161 + "min": 21185, + "mean": 21185, + "median": 21185, + "max": 21185 } } }, @@ -2852,31 +2811,31 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "contract": "test/NestedDeployTest.sol:Child", "deployment": { "gas": 0, - "size": 477 + "size": 731 }, "functions": { "child()": { "calls": 1, - "min": 323, - "mean": 323, - "median": 323, - "max": 323 + "min": 681, + "mean": 681, + "median": 681, + "max": 681 } } }, { "contract": "test/NestedDeployTest.sol:Parent", "deployment": { - "gas": 251997, - "size": 739 + "gas": 328961, + "size": 1163 }, "functions": { "child()": { "calls": 1, - "min": 181, - "mean": 181, - "median": 181, - "max": 181 + "min": 525, + "mean": 525, + "median": 525, + "max": 525 } } } @@ -2887,14 +2846,13 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) }); forgetest_init!(can_use_absolute_imports, |prj, cmd| { - let remapping = prj.paths().libraries[0].join("myDependency"); - let config = Config { - remappings: vec![Remapping::from_str(&format!("myDependency/={}", remapping.display())) - .unwrap() - .into()], - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + let remapping = prj.paths().libraries[0].join("myDependency"); + config.remappings = + vec![Remapping::from_str(&format!("myDependency/={}", remapping.display())) + .unwrap() + .into()]; + }); prj.add_lib( "myDependency/src/interfaces/IConfig.sol", @@ -3181,7 +3139,6 @@ Error: No source files found in specified build paths. // checks that build --sizes includes all contracts even if unchanged forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.clear_cache(); cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#" @@ -3189,7 +3146,7 @@ forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { ╭----------+------------------+-------------------+--------------------+---------------------╮ | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) | +============================================================================================+ -| Counter | 236 | 263 | 24,340 | 48,889 | +| Counter | 481 | 509 | 24,095 | 48,643 | ╰----------+------------------+-------------------+--------------------+---------------------╯ @@ -3199,10 +3156,10 @@ forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| { str![[r#" { "Counter": { - "runtime_size": 236, - "init_size": 263, - "runtime_margin": 24340, - "init_margin": 48889 + "runtime_size": 481, + "init_size": 509, + "runtime_margin": 24095, + "init_margin": 48643 } } "#]] @@ -3405,32 +3362,31 @@ forgetest!(inspect_custom_counter_method_identifiers, |prj, cmd| { // checks that `clean` also works with the "out" value set in Config forgetest_init!(gas_report_include_tests, |prj, cmd| { - prj.write_config(Config { - optimizer: Some(true), - gas_reports_include_tests: true, - fuzz: FuzzConfig { runs: 1, ..Default::default() }, - ..Default::default() + prj.update_config(|config| { + config.gas_reports_include_tests = true; + config.fuzz.runs = 1; }); - cmd.args(["test", "--mt", "test_Increment", "--gas-report"]).assert_success().stdout_eq(str![ - [r#" + cmd.args(["test", "--match-test", "test_Increment", "--gas-report"]) + .assert_success() + .stdout_eq(str![[r#" ... ╭----------------------------------+-----------------+-------+--------+-------+---------╮ | src/Counter.sol:Counter Contract | | | | | | +=======================================================================================+ | Deployment Cost | Deployment Size | | | | | |----------------------------------+-----------------+-------+--------+-------+---------| -| 104475 | 263 | | | | | +| 156813 | 509 | | | | | |----------------------------------+-----------------+-------+--------+-------+---------| | | | | | | | |----------------------------------+-----------------+-------+--------+-------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |----------------------------------+-----------------+-------+--------+-------+---------| -| increment | 43401 | 43401 | 43401 | 43401 | 1 | +| increment | 43482 | 43482 | 43482 | 43482 | 1 | |----------------------------------+-----------------+-------+--------+-------+---------| -| number | 281 | 281 | 281 | 281 | 1 | +| number | 424 | 424 | 424 | 424 | 1 | |----------------------------------+-----------------+-------+--------+-------+---------| -| setNumber | 23579 | 23579 | 23579 | 23579 | 1 | +| setNumber | 23784 | 23784 | 23784 | 23784 | 1 | ╰----------------------------------+-----------------+-------+--------+-------+---------╯ ╭-----------------------------------------+-----------------+--------+--------+--------+---------╮ @@ -3438,22 +3394,21 @@ forgetest_init!(gas_report_include_tests, |prj, cmd| { +================================================================================================+ | Deployment Cost | Deployment Size | | | | | |-----------------------------------------+-----------------+--------+--------+--------+---------| -| 938190 | 4522 | | | | | +| 1545498 | 7578 | | | | | |-----------------------------------------+-----------------+--------+--------+--------+---------| | | | | | | | |-----------------------------------------+-----------------+--------+--------+--------+---------| | Function Name | Min | Avg | Median | Max | # Calls | |-----------------------------------------+-----------------+--------+--------+--------+---------| -| setUp | 165834 | 165834 | 165834 | 165834 | 1 | +| setUp | 218902 | 218902 | 218902 | 218902 | 1 | |-----------------------------------------+-----------------+--------+--------+--------+---------| -| test_Increment | 52357 | 52357 | 52357 | 52357 | 1 | +| test_Increment | 52915 | 52915 | 52915 | 52915 | 1 | ╰-----------------------------------------+-----------------+--------+--------+--------+---------╯ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) -"#] - ]); +"#]]); cmd.forge_fuse() .args(["test", "--mt", "test_Increment", "--gas-report", "--json"]) @@ -3464,53 +3419,53 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) { "contract": "src/Counter.sol:Counter", "deployment": { - "gas": 104475, - "size": 263 + "gas": 156813, + "size": 509 }, "functions": { "increment()": { "calls": 1, - "min": 43401, - "mean": 43401, - "median": 43401, - "max": 43401 + "min": 43482, + "mean": 43482, + "median": 43482, + "max": 43482 }, "number()": { "calls": 1, - "min": 281, - "mean": 281, - "median": 281, - "max": 281 + "min": 424, + "mean": 424, + "median": 424, + "max": 424 }, "setNumber(uint256)": { "calls": 1, - "min": 23579, - "mean": 23579, - "median": 23579, - "max": 23579 + "min": 23784, + "mean": 23784, + "median": 23784, + "max": 23784 } } }, { "contract": "test/Counter.t.sol:CounterTest", "deployment": { - "gas": 938190, - "size": 4522 + "gas": 1545498, + "size": 7578 }, "functions": { "setUp()": { "calls": 1, - "min": 165834, - "mean": 165834, - "median": 165834, - "max": 165834 + "min": 218902, + "mean": 218902, + "median": 218902, + "max": 218902 }, "test_Increment()": { "calls": 1, - "min": 52357, - "mean": 52357, - "median": 52357, - "max": 52357 + "min": 52915, + "mean": 52915, + "median": 52915, + "max": 52915 } } } @@ -3522,11 +3477,7 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) forgetest_async!(gas_report_fuzz_invariant, |prj, cmd| { // speed up test by running with depth of 15 - let config = Config { - invariant: { InvariantConfig { depth: 15, ..Default::default() } }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| config.invariant.depth = 15); prj.insert_ds_test(); prj.add_source( diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index b0524e15fbbf6..350a2fed51570 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -364,8 +364,9 @@ contract Greeter {} ) .unwrap(); - let config = Config { solc: Some(OTHER_SOLC_VERSION.into()), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.solc = Some(OTHER_SOLC_VERSION.into()); + }); cmd.arg("build").assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -428,7 +429,7 @@ Compiler run successful! // test to ensure yul optimizer can be set as intended forgetest!(can_set_yul_optimizer, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); + prj.update_config(|config| config.optimizer = Some(true)); prj.add_source( "foo.sol", r" @@ -454,11 +455,7 @@ Error (6553): The msize instruction cannot be used when the Yul optimizer is act "#]]); // disable yul optimizer explicitly - let config = Config { - optimizer_details: Some(OptimizerDetails { yul: Some(false), ..Default::default() }), - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| config.optimizer_details.get_or_insert_default().yul = Some(false)); cmd.assert_success(); }); @@ -478,8 +475,7 @@ forgetest_init!(can_parse_dapp_libraries, |_prj, cmd| { // test that optimizer runs works forgetest!(can_set_optimizer_runs, |prj, cmd| { // explicitly set optimizer runs - let config = Config { optimizer_runs: Some(1337), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.optimizer_runs = Some(1337)); let config = cmd.config(); assert_eq!(config.optimizer_runs, Some(1337)); @@ -491,9 +487,7 @@ forgetest!(can_set_optimizer_runs, |prj, cmd| { // forgetest!(enable_optimizer_when_runs_set, |prj, cmd| { // explicitly set optimizer runs - let config = Config { optimizer_runs: Some(1337), ..Default::default() }; - assert!(config.optimizer.is_none()); - prj.write_config(config); + prj.update_config(|config| config.optimizer_runs = Some(1337)); let config = cmd.config(); assert!(config.optimizer.unwrap()); @@ -501,9 +495,8 @@ forgetest!(enable_optimizer_when_runs_set, |prj, cmd| { // test `optimizer_runs` set to 200 by default if optimizer enabled forgetest!(optimizer_runs_default, |prj, cmd| { - // explicitly set optimizer runs - let config = Config { optimizer: Some(true), ..Default::default() }; - prj.write_config(config); + // explicitly set optimizer + prj.update_config(|config| config.optimizer = Some(true)); let config = cmd.config(); assert_eq!(config.optimizer_runs, Some(200)); @@ -512,8 +505,7 @@ forgetest!(optimizer_runs_default, |prj, cmd| { // test that gas_price can be set forgetest!(can_set_gas_price, |prj, cmd| { // explicitly set gas_price - let config = Config { gas_price: Some(1337), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.gas_price = Some(1337)); let config = cmd.config(); assert_eq!(config.gas_price, Some(1337)); @@ -699,8 +691,7 @@ forgetest!(can_update_libs_section, |prj, cmd| { cmd.git_init(); // explicitly set gas_price - let init = Config { libs: vec!["node_modules".into()], ..Default::default() }; - prj.write_config(init); + prj.update_config(|config| config.libs = vec!["node_modules".into()]); cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]).assert_success().stdout_eq(str![ [r#" @@ -760,12 +751,10 @@ Please use [profile.default] instead or run `forge config --fix`. forgetest_init!(can_skip_remappings_auto_detection, |prj, cmd| { // explicitly set remapping and libraries - let config = Config { - remappings: vec![Remapping::from_str("remapping/=lib/remapping/").unwrap().into()], - auto_detect_remappings: false, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.remappings = vec![Remapping::from_str("remapping/=lib/remapping/").unwrap().into()]; + config.auto_detect_remappings = false; + }); let config = cmd.config(); @@ -785,14 +774,13 @@ forgetest_init!(can_parse_default_fs_permissions, |_prj, cmd| { forgetest_init!(can_parse_custom_fs_permissions, |prj, cmd| { // explicitly set fs permissions - let custom_permissions = FsPermissions::new(vec![ - PathPermission::read("./read"), - PathPermission::write("./write"), - PathPermission::read_write("./write/contracts"), - ]); - - let config = Config { fs_permissions: custom_permissions, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.fs_permissions = FsPermissions::new(vec![ + PathPermission::read("./read"), + PathPermission::write("./write"), + PathPermission::read_write("./write/contracts"), + ]); + }); let config = cmd.config(); @@ -832,10 +820,10 @@ forgetest_init!(can_resolve_symlink_fs_permissions, |prj, cmd| { .unwrap(); // write config, give read access to links/ symlink to packages/files/ - let permissions = - FsPermissions::new(vec![PathPermission::read(Path::new("./links/config.json"))]); - let config = Config { fs_permissions: permissions, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.fs_permissions = + FsPermissions::new(vec![PathPermission::read(Path::new("./links/config.json"))]); + }); let config = cmd.config(); let mut fs_permissions = config.fs_permissions; @@ -935,14 +923,11 @@ contract MyScript is BaseScript { // For `src=src/contracts` config, remapping should be `src/contracts/ = src/contracts/`. // For `src=src` config, remapping should be `src/ = src/`. // -forgetest!(test_project_remappings, |prj, cmd| { - foundry_test_utils::util::initialize(prj.root()); - let config = Config { - src: "src/contracts".into(), - remappings: vec![Remapping::from_str("contracts/=src/contracts/").unwrap().into()], - ..Default::default() - }; - prj.write_config(config); +forgetest_init!(test_project_remappings, |prj, cmd| { + prj.update_config(|config| { + config.src = "src/contracts".into(); + config.remappings = vec![Remapping::from_str("contracts/=src/contracts/").unwrap().into()]; + }); // Add Counter.sol in `src/contracts` project dir. let src_dir = &prj.root().join("src/contracts"); @@ -1315,8 +1300,7 @@ optimizer_runs = 200 "#]]); // Optimizer set to true: optimizer runs set to default value of 200. - let config = Config { optimizer: Some(true), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.optimizer = Some(true)); cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" ... optimizer = true @@ -1326,8 +1310,10 @@ optimizer_runs = 200 "#]]); // Optimizer runs set to 0: optimizer should be disabled, runs set to 0. - let config = Config { optimizer_runs: Some(0), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.optimizer = None; + config.optimizer_runs = Some(0); + }); cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" ... optimizer = false @@ -1337,8 +1323,10 @@ optimizer_runs = 0 "#]]); // Optimizer runs set to 500: optimizer should be enabled, runs set to 500. - let config = Config { optimizer_runs: Some(500), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.optimizer = None; + config.optimizer_runs = Some(500); + }); cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" ... optimizer = true @@ -1348,8 +1336,10 @@ optimizer_runs = 500 "#]]); // Optimizer disabled and runs set to 500: optimizer should be disabled, runs set to 500. - let config = Config { optimizer: Some(false), optimizer_runs: Some(500), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.optimizer = Some(false); + config.optimizer_runs = Some(500); + }); cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" ... optimizer = false @@ -1359,8 +1349,10 @@ optimizer_runs = 500 "#]]); // Optimizer enabled and runs set to 0: optimizer should be enabled, runs set to 0. - let config = Config { optimizer: Some(true), optimizer_runs: Some(0), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.optimizer = Some(true); + config.optimizer_runs = Some(0); + }); cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" ... optimizer = true @@ -1438,8 +1430,7 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] "#]]); // Enable gas_snapshot_check. - let config = Config { gas_snapshot_check: true, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.gas_snapshot_check = true); cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" ... gas_snapshot_check = true @@ -1459,8 +1450,7 @@ Error: Snapshots differ from previous run "#]]); // Disable gas_snapshot_check, assert that running the test will pass. - let config = Config { gas_snapshot_check: false, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.gas_snapshot_check = false); cmd.forge_fuse().args(["test"]).assert_success().stdout_eq(str![[r#" ... Ran 1 test for src/GasSnapshotCheckTest.sol:GasSnapshotCheckTest @@ -1471,8 +1461,7 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] // Re-enable gas_snapshot_check // Assert that the new value has been stored from the previous run and re-run the test. - let config = Config { gas_snapshot_check: true, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.gas_snapshot_check = true); cmd.forge_fuse().args(["test"]).assert_success().stdout_eq(str![[r#" ... Ran 1 test for src/GasSnapshotCheckTest.sol:GasSnapshotCheckTest @@ -1506,8 +1495,7 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] // Disable gas_snapshot_check in the config file. // Enable using `FORGE_SNAPSHOT_CHECK` environment variable. // Assert that this will override the config file value. - let config = Config { gas_snapshot_check: false, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.gas_snapshot_check = false); prj.add_source("GasSnapshotCheckTest.sol", &test_contract(4)).unwrap(); cmd.forge_fuse(); cmd.env("FORGE_SNAPSHOT_CHECK", "true"); diff --git a/crates/forge/tests/cli/create.rs b/crates/forge/tests/cli/create.rs index fab7eb720acd0..d20e9130c602c 100644 --- a/crates/forge/tests/cli/create.rs +++ b/crates/forge/tests/cli/create.rs @@ -7,7 +7,6 @@ use crate::{ use alloy_primitives::{hex, Address}; use anvil::{spawn, NodeConfig}; use foundry_compilers::artifacts::{remappings::Remapping, BytecodeHash}; -use foundry_config::Config; use foundry_test_utils::{ forgetest, forgetest_async, snapbox::IntoData, @@ -26,12 +25,10 @@ use std::str::FromStr; /// returns the contract argument for the create command fn setup_with_simple_remapping(prj: &TestProject) -> String { // explicitly set remapping and libraries - let config = Config { - remappings: vec![Remapping::from_str("remapping/=lib/remapping/").unwrap().into()], - libraries: vec![format!("remapping/MyLib.sol:MyLib:{:?}", Address::random())], - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.remappings = vec![Remapping::from_str("remapping/=lib/remapping/").unwrap().into()]; + config.libraries = vec![format!("remapping/MyLib.sol:MyLib:{:?}", Address::random())]; + }); prj.add_source( "LinkTest", @@ -62,14 +59,12 @@ library MyLib { } fn setup_oracle(prj: &TestProject) -> String { - let config = Config { - libraries: vec![format!( + prj.update_config(|c| { + c.libraries = vec![format!( "./src/libraries/ChainlinkTWAP.sol:ChainlinkTWAP:{:?}", Address::random() - )], - ..Default::default() - }; - prj.write_config(config); + )]; + }); prj.add_source( "Contract", @@ -144,8 +139,7 @@ forgetest_async!(can_create_template_contract, |prj, cmd| { let pk = hex::encode(wallet.credential().to_bytes()); // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); + prj.update_config(|c| c.bytecode_hash = BytecodeHash::None); // Dry-run without the `--broadcast` flag cmd.forge_fuse().args([ @@ -296,8 +290,7 @@ forgetest_async!(can_create_using_unlocked, |prj, cmd| { let dev = handle.dev_accounts().next().unwrap(); // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); + prj.update_config(|c| c.bytecode_hash = BytecodeHash::None); cmd.forge_fuse().args([ "create", @@ -339,8 +332,7 @@ forgetest_async!(can_create_with_constructor_args, |prj, cmd| { let pk = hex::encode(wallet.credential().to_bytes()); // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); + prj.update_config(|c| c.bytecode_hash = BytecodeHash::None); prj.add_source( "ConstructorContract", @@ -428,8 +420,7 @@ forgetest_async!(can_create_and_call, |prj, cmd| { let pk = hex::encode(wallet.credential().to_bytes()); // explicitly byte code hash for consistent checks - let config = Config { bytecode_hash: BytecodeHash::None, ..Default::default() }; - prj.write_config(config); + prj.update_config(|c| c.bytecode_hash = BytecodeHash::None); prj.add_source( "UniswapV2Swap", diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index dd3dae5439d6b..fb17349be11bf 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -4,7 +4,6 @@ use crate::constants::TEMPLATE_CONTRACT; use alloy_primitives::{address, hex, Address, Bytes}; use anvil::{spawn, NodeConfig}; use forge_script_sequence::ScriptSequence; -use foundry_config::Config; use foundry_test_utils::{ rpc::{self, next_http_rpc_endpoint}, snapbox::IntoData, @@ -1921,12 +1920,7 @@ contract SimpleScript is Script { // Asserts that the script runs with expected non-output using `--quiet` flag forgetest_async!(adheres_to_json_flag, |prj, cmd| { - if cfg!(feature = "isolate-by-default") { - return; - } - foundry_test_utils::util::initialize(prj.root()); - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_script( "Foo", r#" @@ -1958,9 +1952,9 @@ contract SimpleScript is Script { ]) .assert_success() .stdout_eq(str![[r#" -{"logs":[],"returns":{"success":{"internal_type":"bool","value":"true"}},"success":true,"raw_logs":[],"traces":[["Deployment",{"arena":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":false,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CREATE","value":"0x0","data":"0x6080604052600c805462ff00ff191662010001179055348015601f575f5ffd5b506101568061002d5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea26469706673582212205a6c0bb866f700ff9980dc254cb6ededdb9034f66b5a30bdc5cc4738d441b8dd64736f6c634300081b0033","output":"0x608060405234801561000f575f5ffd5b5060043610610034575f3560e01c8063c040622614610038578063f8ccbf4714610054575b5f5ffd5b610040610067565b604051901515815260200160405180910390f35b600c546100409062010000900460ff1681565b5f7f885cb69240a935d632d79c317109709ecfa91a80626ff3989d68f67f5b1dd12d5f1c6001600160a01b0316637fb5297f6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156100c2575f5ffd5b505af11580156100d4573d5f5f3e3d5ffd5b50506040515f925090508181818181805af19150503d805f8114610113576040519150601f19603f3d011682016040523d82523d5f602084013e610118565b606091505b50909291505056fea26469706673582212205a6c0bb866f700ff9980dc254cb6ededdb9034f66b5a30bdc5cc4738d441b8dd64736f6c634300081b0033","gas_used":90639,"gas_limit":1073682810,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}],["Execution",{"arena":[{"parent":null,"children":[1,2],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0xc0406226","output":"0x0000000000000000000000000000000000000000000000000000000000000001","gas_used":3214,"gas_limit":1073720760,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[{"Call":0},{"Call":1}]},{"parent":0,"children":[],"idx":1,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x7109709ecfa91a80626ff3989d68f67f5b1dd12d","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x7fb5297f","output":"0x","gas_used":0,"gas_limit":1056940983,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]},{"parent":0,"children":[],"idx":2,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x0000000000000000000000000000000000000000","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":0,"gas_limit":1056940820,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}]],"gas_used":24278,"labeled_addresses":{},"returned":"0x0000000000000000000000000000000000000000000000000000000000000001","address":null} -{"chain":31337,"estimated_gas_price":"2.000000001","estimated_total_gas_used":29005,"estimated_amount_required":"0.000058010000029005"} -{"chain":"anvil-hardhat","status":"success","tx_hash":"0x4f78afe915fceb282c7625a68eb350bc0bf78acb59ad893e5c62b710a37f3156","contract_address":null,"block_number":1,"gas_used":21000,"gas_price":1000000001} +{"logs":[],"returns":{"success":{"internal_type":"bool","value":"true"}},"success":true,"raw_logs":[],"traces":[["Deployment",{"arena":[{"parent":null,"children":[],"idx":0,"trace":{"depth":0,"success":true,"caller":"0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":false,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CREATE","value":"0x0","data":"[..]","output":"[..]","gas_used":"{...}","gas_limit":"{...}","status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}],["Execution",{"arena":[{"parent":null,"children":[1,2],"idx":0,"trace":{"depth":0,"success":true,"caller":"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266","address":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0xc0406226","output":"0x0000000000000000000000000000000000000000000000000000000000000001","gas_used":"{...}","gas_limit":1073720760,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[{"Call":0},{"Call":1}]},{"parent":0,"children":[],"idx":1,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x7109709ecfa91a80626ff3989d68f67f5b1dd12d","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x7fb5297f","output":"0x","gas_used":"{...}","gas_limit":1056940994,"status":"Return","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]},{"parent":0,"children":[],"idx":2,"trace":{"depth":1,"success":true,"caller":"0x5b73c5498c1e3b4dba84de0f1833c4a029d90519","address":"0x0000000000000000000000000000000000000000","maybe_precompile":null,"selfdestruct_address":null,"selfdestruct_refund_target":null,"selfdestruct_transferred_value":null,"kind":"CALL","value":"0x0","data":"0x","output":"0x","gas_used":"{...}","gas_limit":1056940645,"status":"Stop","steps":[],"decoded":{"label":null,"return_data":null,"call_data":null}},"logs":[],"ordering":[]}]}]],"gas_used":"{...}","labeled_addresses":{},"returned":"0x0000000000000000000000000000000000000000000000000000000000000001","address":null} +{"chain":31337,"estimated_gas_price":"{...}","estimated_total_gas_used":"{...}","estimated_amount_required":"{...}"} +{"chain":"anvil-hardhat","status":"success","tx_hash":"0x4f78afe915fceb282c7625a68eb350bc0bf78acb59ad893e5c62b710a37f3156","contract_address":null,"block_number":1,"gas_used":"{...}","gas_price":"{...}"} {"status":"success","transactions":"[..]/broadcast/Foo.sol/31337/run-latest.json","sensitive":"[..]/cache/Foo.sol/31337/run-latest.json"} "#]].is_jsonlines()); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index dbd9b3d8c4e37..7a366f1cc2010 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2,7 +2,6 @@ use alloy_primitives::U256; use anvil::{spawn, NodeConfig}; -use foundry_config::{Config, FuzzConfig}; use foundry_test_utils::{ rpc, str, util::{OutputExt, OTHER_SOLC_VERSION, SOLC_VERSION}, @@ -16,17 +15,15 @@ forgetest!(can_set_filter_values, |prj, cmd| { let glob = globset::Glob::from_str("foo/bar/baz*").unwrap(); // explicitly set patterns - let config = Config { - test_pattern: Some(patt.clone().into()), - test_pattern_inverse: None, - contract_pattern: Some(patt.clone().into()), - contract_pattern_inverse: None, - path_pattern: Some(glob.clone()), - path_pattern_inverse: None, - coverage_pattern_inverse: None, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.test_pattern = Some(patt.clone().into()); + config.test_pattern_inverse = None; + config.contract_pattern = Some(patt.clone().into()); + config.contract_pattern_inverse = None; + config.path_pattern = Some(glob.clone()); + config.path_pattern_inverse = None; + config.coverage_pattern_inverse = None; + }); let config = cmd.config(); @@ -325,8 +322,8 @@ forgetest!(can_run_test_in_custom_test_folder, |prj, cmd| { prj.insert_ds_test(); // explicitly set the test folder - let config = Config { test: "nested/forge-tests".into(), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| config.test = "nested/forge-tests".into()); + let config = cmd.config(); assert_eq!(config.test, PathBuf::from("nested/forge-tests")); @@ -414,8 +411,9 @@ contract ContractTest is DSTest { .unwrap(); // pin version - let config = Config { solc: Some(SOLC_VERSION.into()), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.solc = Some(SOLC_VERSION.into()); + }); cmd.arg("test").assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -431,8 +429,9 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) "#]]); // pin version - let config = Config { solc: Some(OTHER_SOLC_VERSION.into()), ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.solc = Some(OTHER_SOLC_VERSION.into()); + }); cmd.forge_fuse().arg("test").assert_success().stdout_eq(str![[r#" [COMPILING_FILES] with [SOLC_VERSION] @@ -591,7 +590,6 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/6579 forgetest_init!(include_custom_types_in_traces, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -622,12 +620,12 @@ Compiler run successful! Ran 2 tests for test/Contract.t.sol:CustomTypesTest [FAIL: PoolNotInitialized()] testErr() ([GAS]) Traces: - [253] CustomTypesTest::testErr() + [247] CustomTypesTest::testErr() └─ ← [Revert] PoolNotInitialized() [PASS] testEvent() ([GAS]) Traces: - [1267] CustomTypesTest::testEvent() + [1524] CustomTypesTest::testEvent() ├─ emit MyEvent(a: 100) └─ ← [Stop] @@ -755,11 +753,10 @@ forgetest_init!(should_not_shrink_fuzz_failure, |prj, cmd| { prj.wipe_contracts(); // deterministic test so we always have 54 runs until test fails with overflow - let config = Config { - fuzz: { FuzzConfig { runs: 256, seed: Some(U256::from(100)), ..Default::default() } }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz.runs = 256; + config.fuzz.seed = Some(U256::from(100)); + }); prj.add_test( "CounterFuzz.t.sol", @@ -962,7 +959,6 @@ contract SetupFailureTest is Test { // https://github.com/foundry-rs/foundry/issues/7530 forgetest_init!(should_show_precompile_labels, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1001,7 +997,7 @@ Compiler run successful! Ran 1 test for test/Contract.t.sol:PrecompileLabelsTest [PASS] testPrecompileLabels() ([GAS]) Traces: - [9383] PrecompileLabelsTest::testPrecompileLabels() + [14048] PrecompileLabelsTest::testPrecompileLabels() ├─ [0] VM::deal(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 1000000000000000000 [1e18]) │ └─ ← [Return] ├─ [0] VM::deal(console: [0x000000000000000000636F6e736F6c652e6c6f67], 1000000000000000000 [1e18]) @@ -1047,11 +1043,10 @@ forgetest_init!(should_show_logs_when_fuzz_test, |prj, cmd| { prj.wipe_contracts(); // run fuzz test 3 times - let config = Config { - fuzz: { FuzzConfig { runs: 3, show_logs: true, ..Default::default() } }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz.runs = 3; + config.fuzz.show_logs = true; + }); let config = cmd.config(); assert_eq!(config.fuzz.runs, 3); @@ -1093,9 +1088,9 @@ forgetest_init!(should_show_logs_when_fuzz_test_inline_config, |prj, cmd| { prj.wipe_contracts(); // run fuzz test 3 times - let config = - Config { fuzz: { FuzzConfig { runs: 3, ..Default::default() } }, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz.runs = 3; + }); let config = cmd.config(); assert_eq!(config.fuzz.runs, 3); @@ -1138,11 +1133,10 @@ forgetest_init!(should_not_show_logs_when_fuzz_test, |prj, cmd| { prj.wipe_contracts(); // run fuzz test 3 times - let config = Config { - fuzz: { FuzzConfig { runs: 3, show_logs: false, ..Default::default() } }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz.runs = 3; + config.fuzz.show_logs = false; + }); let config = cmd.config(); assert_eq!(config.fuzz.runs, 3); @@ -1179,9 +1173,9 @@ forgetest_init!(should_not_show_logs_when_fuzz_test_inline_config, |prj, cmd| { prj.wipe_contracts(); // run fuzz test 3 times - let config = - Config { fuzz: { FuzzConfig { runs: 3, ..Default::default() } }, ..Default::default() }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz.runs = 3; + }); let config = cmd.config(); assert_eq!(config.fuzz.runs, 3); @@ -1420,7 +1414,6 @@ contract DeterministicRandomnessTest is Test { // Tests that `pauseGasMetering` used at the end of test does not produce meaningless values. // https://github.com/foundry-rs/foundry/issues/5491 forgetest_init!(gas_metering_pause_last_call, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1458,10 +1451,10 @@ contract ATest is Test { cmd.args(["test"]).with_no_redact().assert_success().stdout_eq(str![[r#" ... -[PASS] testNormalGas() (gas: 3194) -[PASS] testWeirdGas1() (gas: 3032) -[PASS] testWeirdGas2() (gas: 3139) -[PASS] testWithAssembly() (gas: 3075) +[PASS] testNormalGas() (gas: 3153) +[PASS] testWeirdGas1() (gas: 2991) +[PASS] testWeirdGas2() (gas: 3218) +[PASS] testWithAssembly() (gas: 3034) ... "#]]); }); @@ -1506,7 +1499,6 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // https://github.com/foundry-rs/foundry/issues/4523 forgetest_init!(gas_metering_gasleft, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.add_test( @@ -1547,9 +1539,22 @@ contract ATest is Test { cmd.args(["test", "-vvvv"]).with_no_redact().assert_success().stdout_eq(str![[r#" ... Logs: - Gas cost: 34367 -... -[PASS] test_GasMeter() (gas: 37407) + Gas cost: 50068 + +Traces: + [2303684] ATest::test_GasLeft() + ├─ [0] console::log("Gas cost:", 50068 [5.006e4]) [staticcall] + │ └─ ← [Stop] + └─ ← [Stop] + +[PASS] test_GasMeter() (gas: 53102) +Traces: + [53102] ATest::test_GasMeter() + ├─ [0] VM::pauseGasMetering() + │ └─ ← [Return] + ├─ [0] VM::resumeGasMetering() + │ └─ ← [Return] + └─ ← [Stop] ... "#]]); }); @@ -1585,7 +1590,6 @@ contract ATest is Test { // tests `pauseTracing` and `resumeTracing` functions #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(pause_tracing, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.wipe_contracts(); prj.insert_ds_test(); prj.insert_vm(); @@ -1635,33 +1639,33 @@ contract PauseTracingTest is DSTest { cmd.args(["test", "-vvvvv"]).assert_success().stdout_eq(str![[r#" ... Traces: - [7282] PauseTracingTest::setUp() + [7757] PauseTracingTest::setUp() ├─ emit DummyEvent(i: 1) ├─ [0] VM::pauseTracing() [staticcall] │ └─ ← [Return] └─ ← [Stop] - [282512] PauseTracingTest::test() + [449649] PauseTracingTest::test() ├─ [0] VM::resumeTracing() [staticcall] │ └─ ← [Return] - ├─ [18327] TraceGenerator::generate() - │ ├─ [1278] TraceGenerator::call(0) + ├─ [22896] TraceGenerator::generate() + │ ├─ [1589] TraceGenerator::call(0) │ │ ├─ emit DummyEvent(i: 0) │ │ └─ ← [Stop] - │ ├─ [1278] TraceGenerator::call(1) + │ ├─ [1589] TraceGenerator::call(1) │ │ ├─ emit DummyEvent(i: 1) │ │ └─ ← [Stop] - │ ├─ [1278] TraceGenerator::call(2) + │ ├─ [1589] TraceGenerator::call(2) │ │ ├─ emit DummyEvent(i: 2) │ │ └─ ← [Stop] │ ├─ [0] VM::pauseTracing() [staticcall] │ │ └─ ← [Return] │ ├─ [0] VM::resumeTracing() [staticcall] │ │ └─ ← [Return] - │ ├─ [1278] TraceGenerator::call(8) + │ ├─ [1589] TraceGenerator::call(8) │ │ ├─ emit DummyEvent(i: 8) │ │ └─ ← [Stop] - │ ├─ [1278] TraceGenerator::call(9) + │ ├─ [1589] TraceGenerator::call(9) │ │ ├─ emit DummyEvent(i: 9) │ │ └─ ← [Stop] │ └─ ← [Stop] @@ -1891,11 +1895,10 @@ forgetest_init!(test_assume_no_revert, |prj, cmd| { prj.insert_vm(); prj.clear(); - let config = Config { - fuzz: { FuzzConfig { runs: 100, seed: Some(U256::from(100)), ..Default::default() } }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz.runs = 100; + config.fuzz.seed = Some(U256::from(100)); + }); prj.add_source( "Counter.t.sol", @@ -2334,7 +2337,6 @@ Logs: // forgetest_init!(metadata_bytecode_traces, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_source( "ParentProxy.sol", r#" @@ -2395,7 +2397,7 @@ Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest Traces: [..] MetadataTraceTest::test_proxy_trace() ├─ [..] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 236 bytes of code + │ └─ ← [Return] 481 bytes of code ├─ [..] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b │ └─ ← [Return] 62 bytes of code └─ ← [Stop] @@ -2420,7 +2422,7 @@ Ran 1 test for test/MetadataTraceTest.t.sol:MetadataTraceTest Traces: [..] MetadataTraceTest::test_proxy_trace() ├─ [..] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 182 bytes of code + │ └─ ← [Return] 427 bytes of code ├─ [..] → new Proxy@0x2e234DAe75C793f67A35089C9d99245E1C58470b │ └─ ← [Return] 8 bytes of code └─ ← [Stop] @@ -2453,11 +2455,10 @@ contract Dummy { }); forgetest_init!(test_assume_no_revert_with_data, |prj, cmd| { - let config = Config { - fuzz: { FuzzConfig { runs: 60, seed: Some(U256::from(100)), ..Default::default() } }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.fuzz.runs = 60; + config.fuzz.seed = Some(U256::from(100)); + }); prj.add_source( "AssumeNoRevertTest.t.sol", @@ -2596,7 +2597,7 @@ contract ReverterTest is Test { _vm.assumeNoRevert(); reverter.twoPossibleReverts(2); } - + function testAssumeThenExpectCountZeroFails(uint256 x) public { _vm.assumeNoRevert( Vm.PotentialRevert({ @@ -2648,7 +2649,6 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { let (_api, handle) = spawn(NodeConfig::test().silent()).await; - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.insert_vm(); prj.insert_ds_test(); prj.insert_console(); @@ -2724,7 +2724,6 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { import {console} from "../src/console.sol"; contract GetBroadcastTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); function test_getLatestBroacast() external { @@ -2787,9 +2786,9 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { address deployedAddress = vm.getDeployment( "Counter", 31337 - ); + ); - assertEq(deployedAddress, address(0x78280279172ED4C0E65BCE5Ee9DFdcd828f837DB)); + assertEq(deployedAddress, address(0x90d4E26f2e78feDf488c7F3C46B8053a0515c71F)); } function test_getDeployments() public { @@ -2799,10 +2798,9 @@ forgetest_async!(can_get_broadcast_txs, |prj, cmd| { ); assertEq(deployments.length, 2); - assertEq(deployments[0], address(0x78280279172ED4C0E65BCE5Ee9DFdcd828f837DB)); // Create2 address - latest deployment + assertEq(deployments[0], address(0x90d4E26f2e78feDf488c7F3C46B8053a0515c71F)); // Create2 address - latest deployment assertEq(deployments[1], address(0x5FbDB2315678afecb367f032d93F642f64180aa3)); // Create address - oldest deployment } - } "#; @@ -2897,26 +2895,24 @@ Suite result: FAILED. 0 passed; 1 failed; 0 skipped; [ELAPSED] // Tests that test traces display state changes when running with verbosity. #[cfg(not(feature = "isolate-by-default"))] forgetest_init!(should_show_state_changes, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); - cmd.args(["test", "--mt", "test_Increment", "-vvvvv"]).assert_success().stdout_eq(str![[r#" ... Ran 1 test for test/Counter.t.sol:CounterTest [PASS] test_Increment() ([GAS]) Traces: - [87464] CounterTest::setUp() - ├─ [47297] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f - │ └─ ← [Return] 236 bytes of code - ├─ [2387] Counter::setNumber(0) + [137242] CounterTest::setUp() + ├─ [96345] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 481 bytes of code + ├─ [2592] Counter::setNumber(0) │ └─ ← [Stop] └─ ← [Stop] - [31293] CounterTest::test_Increment() - ├─ [22337] Counter::increment() + [31851] CounterTest::test_Increment() + ├─ [22418] Counter::increment() │ ├─ storage changes: │ │ @ 0: 0 → 1 │ └─ ← [Stop] - ├─ [281] Counter::number() [staticcall] + ├─ [424] Counter::number() [staticcall] │ └─ ← [Return] 1 ├─ [0] VM::assertEq(1, 1) [staticcall] │ └─ ← [Return] @@ -2958,7 +2954,6 @@ Encountered a total of 1 failing tests, 0 tests succeeded // Tests that `start/stopAndReturn` debugTraceRecording does not panic when running with // verbosity > 3. forgetest_init!(should_not_panic_on_debug_trace_verbose, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); prj.add_test( "DebugTraceRecordingTest.t.sol", r#" diff --git a/crates/forge/tests/cli/utils.rs b/crates/forge/tests/cli/utils.rs index 058390dceb7b7..cdd93f7abeeea 100644 --- a/crates/forge/tests/cli/utils.rs +++ b/crates/forge/tests/cli/utils.rs @@ -151,27 +151,22 @@ pub fn parse_verification_guid(out: &str) -> Option { None } -// Generates a string containing the code of a Solidity contract -// with a variable init code size. -pub fn generate_large_contract(num_elements: usize) -> String { - let mut contract_code = String::new(); - - contract_code.push_str( - "// Auto-generated Solidity contract to inflate initcode size\ncontract HugeContract {\n uint256 public number;\n" - ); - - contract_code.push_str(" uint256[] public largeArray;\n\n constructor() {\n"); - contract_code.push_str(" largeArray = ["); - - for i in 0..num_elements { - if i != 0 { - contract_code.push_str(", "); - } - contract_code.push_str(&i.to_string()); - } - - contract_code.push_str("];\n"); - contract_code.push_str(" }\n}"); - - contract_code +/// Generates a string containing the code of a Solidity contract. +/// +/// This contract compiles to a large init bytecode size, but small runtime size. +pub fn generate_large_init_contract(n: usize) -> String { + let data = vec![0xff; n]; + let hex = alloy_primitives::hex::encode(data); + format!( + "\ +contract LargeContract {{ + constructor() {{ + bytes memory data = hex\"{hex}\"; + assembly {{ + pop(mload(data)) + }} + }} +}} +" + ) } diff --git a/crates/forge/tests/it/fuzz.rs b/crates/forge/tests/it/fuzz.rs index 30b34dcd9df1f..2855a7f25ced1 100644 --- a/crates/forge/tests/it/fuzz.rs +++ b/crates/forge/tests/it/fuzz.rs @@ -7,7 +7,6 @@ use forge::{ fuzz::CounterExample, result::{SuiteResult, TestStatus}, }; -use foundry_config::Config; use foundry_test_utils::{forgetest_init, str, Filter}; use std::collections::BTreeMap; @@ -118,7 +117,6 @@ async fn test_persist_fuzz_failure() { () => { run_fail!(|config| {}) }; (|$config:ident| $e:expr) => {{ let mut runner = TEST_DATA_DEFAULT.runner_with(|$config| { - $config.optimizer = Some(true); $config.fuzz.runs = 1000; $e }); @@ -163,7 +161,7 @@ async fn test_persist_fuzz_failure() { } forgetest_init!(test_can_scrape_bytecode, |prj, cmd| { - prj.write_config(Config { optimizer: Some(true), ..Default::default() }); + prj.update_config(|config| config.optimizer = Some(true)); prj.add_source( "FuzzerDict.sol", r#" @@ -230,7 +228,7 @@ import {Test} from "forge-std/Test.sol"; contract InlineMaxRejectsTest is Test { /// forge-config: default.fuzz.max-test-rejects = 1 function test_fuzz_bound(uint256 a) public { - vm.assume(a == 0); + vm.assume(false); } } "#, diff --git a/crates/forge/tests/it/inline.rs b/crates/forge/tests/it/inline.rs index 991c556c7d681..eab7f9ec1bb16 100644 --- a/crates/forge/tests/it/inline.rs +++ b/crates/forge/tests/it/inline.rs @@ -7,9 +7,7 @@ use foundry_test_utils::Filter; #[tokio::test(flavor = "multi_thread")] async fn inline_config_run_fuzz() { let filter = Filter::new(".*", ".*", ".*inline/FuzzInlineConf.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { - config.optimizer = Some(true); - }); + let mut runner = TEST_DATA_DEFAULT.runner(); let result = runner.test_collect(&filter); let results = result .into_iter() diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 6cd8482938181..6b20688644cc5 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -3,7 +3,6 @@ use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; use alloy_primitives::U256; use forge::fuzz::CounterExample; -use foundry_config::{Config, InvariantConfig}; use foundry_test_utils::{forgetest_init, str, Filter}; use std::collections::BTreeMap; @@ -261,10 +260,8 @@ async fn test_invariant_inner_contract() { #[cfg_attr(windows, ignore = "for some reason there's different rng")] async fn test_invariant_shrink() { let filter = Filter::new(".*", ".*", ".*fuzz/invariant/common/InvariantInnerContract.t.sol"); - let mut runner = TEST_DATA_DEFAULT.runner_with(|config| { - config.fuzz.seed = Some(U256::from(119u32)); - config.optimizer = Some(true); - }); + let mut runner = + TEST_DATA_DEFAULT.runner_with(|config| config.fuzz.seed = Some(U256::from(119u32))); match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), @@ -708,13 +705,10 @@ async fn test_no_reverts_in_counterexample() { // Tests that a persisted failure doesn't fail due to assume revert if test driver is changed. forgetest_init!(should_not_fail_replay_assume, |prj, cmd| { - let config = Config { - invariant: { - InvariantConfig { fail_on_revert: true, max_assume_rejects: 10, ..Default::default() } - }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.invariant.fail_on_revert = true; + config.invariant.max_assume_rejects = 10; + }); // Add initial test that breaks invariant. prj.add_test( @@ -777,14 +771,11 @@ contract AssumeTest is Test { // Test too many inputs rejected for `assumePrecompile`/`assumeForgeAddress`. // forgetest_init!(should_revert_with_assume_code, |prj, cmd| { - let config = Config { - optimizer: Some(true), - invariant: { - InvariantConfig { fail_on_revert: true, max_assume_rejects: 10, ..Default::default() } - }, - ..Default::default() - }; - prj.write_config(config); + prj.update_config(|config| { + config.invariant.fail_on_revert = true; + config.invariant.max_assume_rejects = 10; + config.fuzz.seed = Some(U256::from(100u32)); + }); // Add initial test that breaks invariant. prj.add_test( @@ -824,7 +815,7 @@ contract BalanceAssumeTest is Test { cmd.args(["test", "--mt", "invariant_balance"]).assert_failure().stdout_eq(str![[r#" ... -[FAIL: `vm.assume` rejected too many inputs (10 allowed)] invariant_balance() (runs: 0, calls: 0, reverts: 0) +[FAIL: `vm.assume` rejected too many inputs (10 allowed)] invariant_balance() (runs: 1, calls: 500, reverts: 0) ... "#]]); }); @@ -1001,10 +992,9 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) // Tests that selector hits are uniformly distributed // forgetest_init!(invariant_selectors_weight, |prj, cmd| { - prj.write_config(Config { - optimizer: Some(true), - invariant: { InvariantConfig { runs: 1, depth: 10, ..Default::default() } }, - ..Default::default() + prj.update_config(|config| { + config.invariant.runs = 1; + config.invariant.depth = 10; }); prj.add_source( "InvariantHandlers.sol", diff --git a/crates/test-utils/src/util.rs b/crates/test-utils/src/util.rs index 15d5b81a7199b..f2b71064f1f56 100644 --- a/crates/test-utils/src/util.rs +++ b/crates/test-utils/src/util.rs @@ -263,14 +263,16 @@ pub fn initialize(target: &Path) { solc: Some(foundry_config::SolcReq::Version(SOLC_VERSION.parse().unwrap())), ..Default::default() }); - // checkout forge-std - assert!(Command::new("git") + + // Checkout forge-std. + let output = Command::new("git") .current_dir(prj.root().join("lib/forge-std")) .args(["checkout", FORGE_STD_REVISION]) .output() - .expect("failed to checkout forge-std") - .status - .success()); + .expect("failed to checkout forge-std"); + assert!(output.status.success(), "{output:#?}"); + + // Build the project. cmd.forge_fuse().arg("build").assert_success(); // Remove the existing template, if any. @@ -493,7 +495,25 @@ impl TestProject { let _ = fs::remove_dir_all(self.artifacts()); } + /// Updates the project's config with the given function. + pub fn update_config(&self, f: impl FnOnce(&mut Config)) { + self._update_config(Box::new(f)); + } + + fn _update_config(&self, f: Box) { + let mut config = self + .config() + .exists() + .then_some(()) + .and_then(|()| Config::load_with_root(self.root()).ok()) + .unwrap_or_default(); + config.remappings.clear(); + f(&mut config); + self.write_config(config); + } + /// Writes the given config as toml to `foundry.toml`. + #[doc(hidden)] // Prefer `update_config`. pub fn write_config(&self, config: Config) { let file = self.config(); pretty_err(&file, fs::write(&file, config.to_string_pretty().unwrap())); @@ -666,7 +686,7 @@ impl TestProject { let forge = forge.canonicalize().unwrap_or_else(|_| forge.clone()); let mut cmd = Command::new(forge); cmd.current_dir(self.inner.root()); - // disable color output for comparisons + // Disable color output for comparisons; can be overridden with `--color always`. cmd.env("NO_COLOR", "1"); cmd } @@ -851,9 +871,8 @@ impl TestCommand { pub fn config(&mut self) -> Config { self.cmd.args(["config", "--json"]); let output = self.assert().success().get_output().stdout_lossy(); - let config = serde_json::from_str(output.as_ref()).unwrap(); self.forge_fuse(); - config + serde_json::from_str(output.as_ref()).unwrap() } /// Runs `git init` inside the project's dir From 1b7b6c2e8bc597256395692466ba068e37a893a6 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 3 Feb 2025 10:41:52 +0200 Subject: [PATCH 1926/1963] chore: update ext integration tests (#9811) * chore: update ext integration tests * Snekmate requires unreleased vyper 4.1 --- crates/forge/tests/cli/ext_integration.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs index b2fd1808701ff..5dcdf4be132b4 100644 --- a/crates/forge/tests/cli/ext_integration.rs +++ b/crates/forge/tests/cli/ext_integration.rs @@ -59,12 +59,9 @@ fn sablier_v2_core() { } // -// Fails on windows because "/*Transient*" does not skip transient contracts -// (should be "*/*Transient*"). #[test] -#[cfg_attr(windows, ignore = "Windows cannot skip transient pattern")] fn solady() { - ExtTester::new("Vectorized", "solady", "de9aee59648862bb98affd578248d1e75c7073ad").run(); + ExtTester::new("Vectorized", "solady", "66162801e022c268a2a0f621ac5eb0df4986f6eb").run(); } // From 6e919af69d7a9bb0dbb7508ac5402348140354c8 Mon Sep 17 00:00:00 2001 From: antazoey Date: Mon, 3 Feb 2025 06:59:53 -0600 Subject: [PATCH 1927/1963] fix(forge): allow `forge init --template` to work with `--no-commit` (#9815) fix: allow init from template not commit Co-authored-by: antazoey --- crates/forge/bin/cmd/init.rs | 21 ++++++++++++--------- crates/forge/tests/cli/cmd.rs | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 6338dbbec1dcb..269af31c1a3fa 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -69,15 +69,18 @@ impl InitArgs { // fetch the template - always fetch shallow for templates since git history will be // collapsed. gitmodules will be initialized after the template is fetched git.fetch(true, &template, branch)?; - // reset git history to the head of the template - // first get the commit hash that was fetched - let commit_hash = git.commit_hash(true, "FETCH_HEAD")?; - // format a commit message for the new repo - let commit_msg = format!("chore: init from {template} at {commit_hash}"); - // get the hash of the FETCH_HEAD with the new commit message - let new_commit_hash = git.commit_tree("FETCH_HEAD^{tree}", Some(commit_msg))?; - // reset head of this repo to be the head of the template repo - git.reset(true, new_commit_hash)?; + + if !no_commit { + // reset git history to the head of the template + // first get the commit hash that was fetched + let commit_hash = git.commit_hash(true, "FETCH_HEAD")?; + // format a commit message for the new repo + let commit_msg = format!("chore: init from {template} at {commit_hash}"); + // get the hash of the FETCH_HEAD with the new commit message + let new_commit_hash = git.commit_tree("FETCH_HEAD^{tree}", Some(commit_msg))?; + // reset head of this repo to be the head of the template repo + git.reset(true, new_commit_hash)?; + } // if shallow, just initialize submodules if shallow { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 7f2f5c3d570cc..b57c5890b4f9c 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -584,6 +584,31 @@ Error: git fetch exited with code 128 "#]]); }); +// checks that `forge init --template [template] work with --no-commit +forgetest!(can_init_template_with_no_commit, |prj, cmd| { + prj.wipe(); + cmd.args(["init", "--template", "foundry-rs/forge-template", "--no-commit"]) + .arg(prj.root()) + .assert_success() + .stdout_eq(str![[r#" +Initializing [..] from https://github.com/foundry-rs/forge-template... + Initialized forge project + +"#]]); + + // show the latest commit message was not changed + let output = Command::new("git") + .args(["log", "-1", "--pretty=%s"]) // Get the latest commit message + .output() + .expect("Failed to execute git command"); + + let commit_message = String::from_utf8_lossy(&output.stdout); + assert!( + !commit_message.starts_with("chore: init from foundry-rs/forge-template"), + "Commit message should not start with 'chore: init from foundry-rs/forge-template'" + ); +}); + // checks that clone works forgetest!(can_clone, |prj, cmd| { prj.wipe(); From f6133f9e5fbd37864958cc58457f795ce35cd469 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 3 Feb 2025 19:50:47 +0200 Subject: [PATCH 1928/1963] feat(invariant): on failures show original and current sequence len (#9816) --- crates/evm/fuzz/src/lib.rs | 4 +-- crates/forge/src/result.rs | 12 ++++++-- crates/forge/src/runner.rs | 13 ++++++-- crates/forge/tests/it/invariant.rs | 48 ++++++++++++++++++++++++++---- 4 files changed, 64 insertions(+), 13 deletions(-) diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index 276958ecf6fd5..c1854f55c1e49 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -35,8 +35,8 @@ pub use inspector::Fuzzer; pub enum CounterExample { /// Call used as a counter example for fuzz tests. Single(BaseCounterExample), - /// Sequence of calls used as a counter example for invariant tests. - Sequence(Vec), + /// Original sequence size and sequence of calls used as a counter example for invariant tests. + Sequence(usize, Vec), } #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 5b134194fe976..58b0f314599b7 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -446,8 +446,14 @@ impl fmt::Display for TestResult { CounterExample::Single(ex) => { write!(s, "; counterexample: {ex}]").unwrap(); } - CounterExample::Sequence(sequence) => { - s.push_str("]\n\t[Sequence]\n"); + CounterExample::Sequence(original, sequence) => { + s.push_str( + format!( + "]\n\t[Sequence] (original: {original}, shrunk: {})\n", + sequence.len() + ) + .as_str(), + ); for ex in sequence { writeln!(s, "\t\t{ex}").unwrap(); } @@ -593,7 +599,7 @@ impl TestResult { } else { Some(format!("{invariant_name} persisted failure revert")) }; - self.counterexample = Some(CounterExample::Sequence(call_sequence)); + self.counterexample = Some(CounterExample::Sequence(call_sequence.len(), call_sequence)); } /// Returns the fail result for invariant test setup. diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index ba6697958ab5e..495b84f3d10c3 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -31,7 +31,7 @@ use foundry_evm::{ traces::{load_contracts, TraceKind, TraceMode}, }; use proptest::test_runner::{ - FailurePersistence, FileFailurePersistence, RngAlgorithm, TestRng, TestRunner, + FailurePersistence, FileFailurePersistence, RngAlgorithm, TestError, TestRng, TestRunner, }; use rayon::prelude::*; use std::{borrow::Cow, cmp::min, collections::BTreeMap, sync::Arc, time::Instant}; @@ -686,7 +686,16 @@ impl<'a> FunctionRunner<'a> { ) { error!(%err, "Failed to record call sequence"); } - counterexample = Some(CounterExample::Sequence(call_sequence)) + + let original_seq_len = + if let TestError::Fail(_, calls) = &case_data.test_error { + calls.len() + } else { + call_sequence.len() + }; + + counterexample = + Some(CounterExample::Sequence(original_seq_len, call_sequence)) } } Err(err) => { diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index 6b20688644cc5..fb2a9979f0f31 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -266,7 +266,7 @@ async fn test_invariant_shrink() { match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), // `fuzz_seed` at 119 makes this sequence shrinkable from 4 to 2. - CounterExample::Sequence(sequence) => { + CounterExample::Sequence(_, sequence) => { assert!(sequence.len() <= 3); if sequence.len() == 2 { @@ -314,7 +314,7 @@ async fn check_shrink_sequence(test_pattern: &str, expected_len: usize) { match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), - CounterExample::Sequence(sequence) => { + CounterExample::Sequence(_, sequence) => { assert_eq!(sequence.len(), expected_len); } }; @@ -346,7 +346,7 @@ async fn test_shrink_big_sequence() { let initial_sequence = match initial_counterexample { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), - CounterExample::Sequence(sequence) => sequence, + CounterExample::Sequence(_, sequence) => sequence, }; // ensure shrinks to same sequence of 77 assert_eq!(initial_sequence.len(), 77); @@ -379,7 +379,7 @@ async fn test_shrink_big_sequence() { .unwrap() { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), - CounterExample::Sequence(sequence) => sequence, + CounterExample::Sequence(_, sequence) => sequence, }; // ensure shrinks to same sequence of 77 assert_eq!(new_sequence.len(), 77); @@ -407,7 +407,7 @@ async fn test_shrink_fail_on_revert() { match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), - CounterExample::Sequence(sequence) => { + CounterExample::Sequence(_, sequence) => { // ensure shrinks to sequence of 10 assert_eq!(sequence.len(), 10); } @@ -696,7 +696,7 @@ async fn test_no_reverts_in_counterexample() { match get_counterexample!(runner, &filter) { CounterExample::Single(_) => panic!("CounterExample should be a sequence."), - CounterExample::Sequence(sequence) => { + CounterExample::Sequence(_, sequence) => { // ensure original counterexample len is 10 (even without shrinking) assert_eq!(sequence.len(), 10); } @@ -1064,3 +1064,39 @@ contract InvariantSelectorsWeightTest is Test { cmd.args(["test", "--fuzz-seed", "119", "--mt", "invariant_selectors_weight"]).assert_success(); }); + +// Tests original and new counterexample lengths are displayed on failure. +forgetest_init!(invariant_sequence_len, |prj, cmd| { + prj.update_config(|config| { + config.fuzz.seed = Some(U256::from(100u32)); + }); + + prj.add_test( + "InvariantSequenceLenTest.t.sol", + r#" +import {Test} from "forge-std/Test.sol"; +import "src/Counter.sol"; + +contract InvariantSequenceLenTest is Test { + Counter public counter; + + function setUp() public { + counter = new Counter(); + targetContract(address(counter)); + } + + function invariant_increment() public { + require(counter.number() / 2 < 100000000000000000000000000000000, "invariant increment failure"); + } +} + "#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "invariant_increment"]).assert_failure().stdout_eq(str![[r#" +... +[FAIL: revert: invariant increment failure] + [Sequence] (original: 4, shrunk: 1) +... +"#]]); +}); From be5e7147bf60fb679a7b0016453dda49a4c6dac7 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:22:18 +0200 Subject: [PATCH 1929/1963] fix(cast): try decoding custom errors when execution reverted in cast send (#9794) * fix(cast): try decoding custom errors when gas estimation in cast send * Changes after review: use serde_json::from_str, use itertools format * Nits * More nits --- crates/cast/bin/tx.rs | 58 ++++++++++++++++++++++++++-- crates/cast/tests/cli/main.rs | 71 +++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 3 deletions(-) diff --git a/crates/cast/bin/tx.rs b/crates/cast/bin/tx.rs index fc5632ea07f76..945cd56d3d939 100644 --- a/crates/cast/bin/tx.rs +++ b/crates/cast/bin/tx.rs @@ -1,4 +1,5 @@ use alloy_consensus::{SidecarBuilder, SimpleCoder}; +use alloy_dyn_abi::ErrorExt; use alloy_json_abi::Function; use alloy_network::{ AnyNetwork, TransactionBuilder, TransactionBuilder4844, TransactionBuilder7702, @@ -8,21 +9,26 @@ use alloy_provider::Provider; use alloy_rpc_types::{AccessList, Authorization, TransactionInput, TransactionRequest}; use alloy_serde::WithOtherFields; use alloy_signer::Signer; +use alloy_transport::TransportError; +use cast::traces::identifier::SignaturesIdentifier; use eyre::Result; use foundry_cli::{ opts::{CliAuthorizationList, TransactionOpts}, utils::{self, parse_function_args}, }; -use foundry_common::ens::NameOrAddress; +use foundry_common::{ens::NameOrAddress, fmt::format_tokens}; use foundry_config::{Chain, Config}; use foundry_wallets::{WalletOpts, WalletSigner}; +use itertools::Itertools; +use serde_json::value::RawValue; +use std::fmt::Write; /// Different sender kinds used by [`CastTxBuilder`]. pub enum SenderKind<'a> { /// An address without signer. Used for read-only calls and transactions sent through unlocked /// accounts. Address(Address), - /// A refersnce to a signer. + /// A reference to a signer. Signer(&'a WalletSigner), /// An owned signer. OwnedSigner(WalletSigner), @@ -350,12 +356,36 @@ impl> CastTxBuilder { } if self.tx.gas.is_none() { - self.tx.gas = Some(self.provider.estimate_gas(&self.tx).await?); + self.estimate_gas().await?; } Ok((self.tx, self.state.func)) } + /// Estimate tx gas from provider call. Tries to decode custom error if execution reverted. + async fn estimate_gas(&mut self) -> Result<()> { + match self.provider.estimate_gas(&self.tx).await { + Ok(estimated) => { + self.tx.gas = Some(estimated); + Ok(()) + } + Err(err) => { + if let TransportError::ErrorResp(payload) = &err { + // If execution reverted with code 3 during provider gas estimation then try + // to decode custom errors and append it to the error message. + if payload.code == 3 { + if let Some(data) = &payload.data { + if let Ok(Some(decoded_error)) = decode_execution_revert(data).await { + eyre::bail!("Failed to estimate gas: {}: {}", err, decoded_error) + } + } + } + } + eyre::bail!("Failed to estimate gas: {}", err) + } + } + } + /// Parses the passed --auth value and sets the authorization list on the transaction. async fn resolve_auth(&mut self, sender: SenderKind<'_>, tx_nonce: u64) -> Result<()> { let Some(auth) = self.auth.take() else { return Ok(()) }; @@ -401,3 +431,25 @@ where Ok(self) } } + +/// Helper function that tries to decode custom error name and inputs from error payload data. +async fn decode_execution_revert(data: &RawValue) -> Result> { + if let Some(err_data) = serde_json::from_str::(data.get())?.strip_prefix("0x") { + let selector = err_data.get(..8).unwrap(); + if let Some(known_error) = SignaturesIdentifier::new(Config::foundry_cache_dir(), false)? + .write() + .await + .identify_error(&hex::decode(selector)?) + .await + { + let mut decoded_error = known_error.name.clone(); + if !known_error.inputs.is_empty() { + if let Ok(error) = known_error.decode_error(&hex::decode(err_data)?) { + write!(decoded_error, "({})", format_tokens(&error.body).format(", "))?; + } + } + return Ok(Some(decoded_error)) + } + } + Ok(None) +} diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 98440d68b3289..3d19bf033be69 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1971,3 +1971,74 @@ contract WETH9 { uint8 public decimals = 18; ..."#]]); }); + +// tests cast send gas estimate execution failure message contains decoded custom error +// +forgetest_async!(cast_send_estimate_gas_error, |prj, cmd| { + let (_, handle) = anvil::spawn(NodeConfig::test()).await; + + foundry_test_utils::util::initialize(prj.root()); + prj.add_source( + "SimpleStorage", + r#" +contract SimpleStorage { + uint256 private storedValue; + error AddressInsufficientBalance(address account, uint256 newValue); + function setValue(uint256 _newValue) public { + if (_newValue > 100) { + revert AddressInsufficientBalance(msg.sender, _newValue); + } + storedValue = _newValue; + } +} + "#, + ) + .unwrap(); + prj.add_script( + "SimpleStorageScript", + r#" +import "forge-std/Script.sol"; +import {SimpleStorage} from "../src/SimpleStorage.sol"; +contract SimpleStorageScript is Script { + function run() public { + vm.startBroadcast(); + new SimpleStorage(); + vm.stopBroadcast(); + } +} + "#, + ) + .unwrap(); + + cmd.args([ + "script", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + "--broadcast", + "SimpleStorageScript", + ]) + .assert_success(); + + // Cache project selectors. + cmd.forge_fuse().set_current_dir(prj.root()); + cmd.forge_fuse().args(["selectors", "cache"]).assert_success(); + + // Assert cast send can decode custom error on estimate gas execution failure. + cmd.cast_fuse() + .args([ + "send", + "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "setValue(uint256)", + "1000", + "--private-key", + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "--rpc-url", + &handle.http_endpoint(), + ]) + .assert_failure().stderr_eq(str![[r#" +Error: Failed to estimate gas: server returned an error response: error code 3: execution reverted: custom error 0x6786ad34: 000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e8, data: "0x6786ad34000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e8": AddressInsufficientBalance(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, 1000) + +"#]]); +}); From fec2064cadd443fef491c9d02461e1a5f455232f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 4 Feb 2025 16:21:40 +0100 Subject: [PATCH 1930/1963] chore: remove rustls/openssl features (#9824) --- .github/workflows/release.yml | 6 +-- .github/workflows/test.yml | 4 -- Cargo.lock | 99 ----------------------------------- Cargo.toml | 5 +- Makefile | 4 +- crates/cast/Cargo.toml | 4 +- crates/chisel/Cargo.toml | 4 +- crates/cli/Cargo.toml | 4 -- crates/common/Cargo.toml | 8 +-- crates/config/Cargo.toml | 2 - crates/forge/Cargo.toml | 9 +--- crates/wallets/Cargo.toml | 4 +- deny.toml | 5 -- 13 files changed, 15 insertions(+), 143 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a5a64f6ec387..468fdad6893ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ env: CARGO_TERM_COLOR: always IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} PROFILE: maxperf - STABLE_VERSION: 'v0.3.0' + STABLE_VERSION: "v0.3.0" jobs: prepare: @@ -148,7 +148,7 @@ jobs: run: | set -eo pipefail flags=(--target $TARGET --profile $PROFILE --bins - --no-default-features --features rustls,aws-kms,cli,asm-keccak) + --no-default-features --features aws-kms,cli,asm-keccak) # `jemalloc` is not fully supported on MSVC or aarch64 Linux. if [[ "$TARGET" != *msvc* && "$TARGET" != "aarch64-unknown-linux-gnu" ]]; then @@ -278,7 +278,7 @@ jobs: issue: name: Open an issue runs-on: ubuntu-latest - needs: [ prepare, release-docker, release, cleanup ] + needs: [prepare, release-docker, release, cleanup] if: failure() steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c9dc93e6f7f3e..d5e21a495e6b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -113,10 +113,6 @@ jobs: deny: uses: ithacaxyz/ci/.github/workflows/deny.yml@main - with: - # Clear out arguments to not pass `--all-features` to `cargo deny`. - # Many crates have an `openssl` feature which enables banned dependencies. - deny-flags: "" ci-success: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 0ed5b608a718a..06196f4cf276a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3315,21 +3315,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "forge" version = "1.0.0" @@ -5003,22 +4988,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper 1.6.0", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.10" @@ -5968,23 +5937,6 @@ dependencies = [ "syn 2.0.98", ] -[[package]] -name = "native-tls" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dab59f8e050d5df8e4dd87d9206fb6f65a483e20ac9fda365ade4fab353196c" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework 2.11.1", - "security-framework-sys", - "tempfile", -] - [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -6318,50 +6270,12 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "openssl" -version = "0.10.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e534d133a060a3c19daec1eb3e98ec6f4685978834f2dbadfe2ec215bab64e" -dependencies = [ - "bitflags 2.8.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.98", -] - [[package]] name = "openssl-probe" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" -[[package]] -name = "openssl-sys" -version = "0.9.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -7319,14 +7233,12 @@ dependencies = [ "http-body-util", "hyper 1.6.0", "hyper-rustls 0.27.5", - "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", "mime_guess", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -7340,7 +7252,6 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "tokio", - "tokio-native-tls", "tokio-rustls 0.26.1", "tokio-socks", "tokio-util", @@ -8933,16 +8844,6 @@ dependencies = [ "syn 2.0.98", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.24.1" diff --git a/Cargo.toml b/Cargo.toml index a1ee42396be90..f152898f64c29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -292,7 +292,10 @@ proptest = "1" rand = "0.8" rayon = "1" regex = { version = "1", default-features = false } -reqwest = { version = "0.12", default-features = false } +reqwest = { version = "0.12", default-features = false, features = [ + "rustls-tls", + "rustls-tls-native-roots", +] } semver = "1" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["arbitrary_precision"] } diff --git a/Makefile b/Makefile index 429e6721fee67..78658fad0cc26 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,9 @@ CARGO_TARGET_DIR ?= target # List of features to use when building. Can be overridden via the environment. # No jemalloc on Windows ifeq ($(OS),Windows_NT) - FEATURES ?= rustls aws-kms cli asm-keccak + FEATURES ?= aws-kms cli asm-keccak else - FEATURES ?= jemalloc rustls aws-kms cli asm-keccak + FEATURES ?= jemalloc aws-kms cli asm-keccak endif ##@ Help diff --git a/crates/cast/Cargo.toml b/crates/cast/Cargo.toml index cb3862333892a..bf51e20f32c1d 100644 --- a/crates/cast/Cargo.toml +++ b/crates/cast/Cargo.toml @@ -93,9 +93,7 @@ async-trait.workspace = true divan.workspace = true [features] -default = ["rustls", "jemalloc"] -rustls = ["foundry-cli/rustls", "foundry-wallets/rustls"] -openssl = ["foundry-cli/openssl"] +default = ["jemalloc"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] aws-kms = ["foundry-wallets/aws-kms", "dep:aws-sdk-kms"] diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index e25e73be79dcb..78acd8faaa62b 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -65,8 +65,6 @@ serial_test = "3" tracing-subscriber.workspace = true [features] -default = ["rustls", "jemalloc"] -rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] -openssl = ["foundry-compilers/openssl", "reqwest/default-tls"] +default = ["jemalloc"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index c4323d62b8e50..7fe67041e3f1b 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -54,8 +54,4 @@ tracing-tracy = { version = "0.11", optional = true } tempfile.workspace = true [features] -default = ["rustls"] -rustls = ["foundry-wallets/rustls"] -openssl = ["foundry-compilers/openssl"] - tracy = ["dep:tracing-tracy"] diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 95530d26441a5..985809bec96e9 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -71,14 +71,10 @@ terminal_size.workspace = true [build-dependencies] chrono.workspace = true -vergen = { workspace = true, features = [ - "build", - "git", - "gitcl", -] } +vergen = { workspace = true, features = ["build", "git", "gitcl"] } [dev-dependencies] foundry-macros.workspace = true similar-asserts.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } -axum = { workspace = true } \ No newline at end of file +axum = { workspace = true } diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index e0e52162cab13..2d2b80b4ad695 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -55,6 +55,4 @@ figment = { workspace = true, features = ["test"] } tempfile.workspace = true [features] -default = ["rustls"] -rustls = ["reqwest/rustls-tls-native-roots"] isolate-by-default = [] diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index fc6455f0f0678..d743c9cd4f7d2 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -123,14 +123,7 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } alloy-signer-local.workspace = true [features] -default = ["rustls", "jemalloc"] -rustls = [ - "foundry-cli/rustls", - "foundry-wallets/rustls", - "reqwest/rustls-tls", - "reqwest/rustls-tls-native-roots", -] -openssl = ["foundry-cli/openssl", "reqwest/default-tls"] +default = ["jemalloc"] asm-keccak = ["alloy-primitives/asm-keccak"] jemalloc = ["dep:tikv-jemallocator"] aws-kms = ["foundry-wallets/aws-kms"] diff --git a/crates/wallets/Cargo.toml b/crates/wallets/Cargo.toml index f5b773762298c..b1310b98e86a8 100644 --- a/crates/wallets/Cargo.toml +++ b/crates/wallets/Cargo.toml @@ -27,7 +27,7 @@ alloy-dyn-abi.workspace = true # aws-kms alloy-signer-aws = { workspace = true, features = ["eip712"], optional = true } -aws-config = { version = "1", optional = true } # default-features are necessary +aws-config = { version = "1", default-features = true, optional = true } aws-sdk-kms = { version = "1", default-features = false, optional = true } # gcp-kms @@ -51,7 +51,5 @@ eth-keystore = "0.5.0" tokio = { workspace = true, features = ["macros"] } [features] -default = ["rustls"] -rustls = ["aws-sdk-kms?/rustls"] aws-kms = ["dep:alloy-signer-aws", "dep:aws-config", "dep:aws-sdk-kms"] gcp-kms = ["dep:alloy-signer-gcp", "dep:gcloud-sdk"] diff --git a/deny.toml b/deny.toml index 031bc56e2fbe5..b107bf5282c41 100644 --- a/deny.toml +++ b/deny.toml @@ -7,10 +7,6 @@ yanked = "warn" ignore = [ # proc-macro-error is unmaintained "RUSTSEC-2024-0370", - # instant is unmaintained - "RUSTSEC-2024-0384", - # derivative is unmaintained - "RUSTSEC-2024-0388", ] # This section is considered when running `cargo deny check bans`. @@ -47,7 +43,6 @@ allow = [ "BSD-3-Clause", "ISC", "Unicode-3.0", - "Unicode-DFS-2016", "OpenSSL", "Unlicense", "WTFPL", From 96fc6b99078fd50a5e257db1c19d7ad77b267963 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 5 Feb 2025 08:17:38 +0200 Subject: [PATCH 1931/1963] chore: fix base gas limit test (#9826) --- crates/anvil/tests/it/fork.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index be91bbc126bff..e1dc19f6f94de 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -1306,8 +1306,8 @@ async fn test_base_fork_gas_limit() { .unwrap() .unwrap(); - assert!(api.gas_limit() >= uint!(132_000_000_U256)); - assert!(block.header.gas_limit >= 132_000_000_u64); + assert!(api.gas_limit() >= uint!(96_000_000_U256)); + assert!(block.header.gas_limit >= 96_000_000_u64); } // From d65ede582153cc3f9319067bb7bf7a5adbf88c15 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 6 Feb 2025 03:31:09 +0100 Subject: [PATCH 1932/1963] fix: mark metis as different gas calc (#9834) --- crates/cli/src/utils/cmd.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index eca7a7a3998af..c226054dd7313 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -175,7 +175,8 @@ pub fn has_different_gas_calc(chain_id: u64) -> bool { NamedChain::Moonbase | NamedChain::Moonbeam | NamedChain::MoonbeamDev | - NamedChain::Moonriver + NamedChain::Moonriver | + NamedChain::Metis ); } false From 1baa9e6aa2c3fac588564fc7339e3b5ff5d2f3a1 Mon Sep 17 00:00:00 2001 From: Jay White Date: Thu, 6 Feb 2025 02:37:06 -0500 Subject: [PATCH 1933/1963] feat: add mathjax support to forge doc mdbook config (#9829) --- crates/doc/static/book.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/doc/static/book.toml b/crates/doc/static/book.toml index 11c8d042906b8..617db3095a4b9 100644 --- a/crates/doc/static/book.toml +++ b/crates/doc/static/book.toml @@ -6,6 +6,7 @@ src = "src" no-section-label = true additional-js = ["solidity.min.js"] additional-css = ["book.css"] +mathjax-support = true [output.html.fold] enable = true From 867484fc9338a0174d637435283774e5da783f27 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:00:20 +0200 Subject: [PATCH 1934/1963] fix(foundryup): install for user names with empty space (#9835) --- foundryup/foundryup | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/foundryup/foundryup b/foundryup/foundryup index 2c8ae0605bfea..a3a6d1bb58823 100755 --- a/foundryup/foundryup +++ b/foundryup/foundryup @@ -4,7 +4,7 @@ set -eo pipefail # NOTE: if you make modifications to this script, please increment the version number. # Major / minor: incremented for each stable release of Foundry. # Patch: incremented for each change between stable releases. -FOUNDRYUP_INSTALLER_VERSION="1.0.0" +FOUNDRYUP_INSTALLER_VERSION="1.0.1" BASE_DIR=${XDG_CONFIG_HOME:-$HOME} FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"} @@ -151,7 +151,7 @@ main() { BIN_ARCHIVE_URL="${RELEASE_URL}foundry_${FOUNDRYUP_VERSION}_${PLATFORM}_${ARCHITECTURE}.$EXT" MAN_TARBALL_URL="${RELEASE_URL}foundry_man_${FOUNDRYUP_VERSION}.tar.gz" - ensure mkdir -p $FOUNDRY_VERSIONS_DIR + ensure mkdir -p "$FOUNDRY_VERSIONS_DIR" # Download and extract the binaries archive say "downloading forge, cast, anvil, and chisel for $FOUNDRYUP_TAG version" if [ "$PLATFORM" = "win32" ]; then @@ -164,7 +164,7 @@ main() { ensure download "$BIN_ARCHIVE_URL" "$tmp" # Make sure it's a valid tar archive. ensure tar tf $tmp 1> /dev/null - ensure mkdir -p $FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG + ensure mkdir -p "$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG" ensure tar -C "$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_TAG" -xvf $tmp rm -f "$tmp" fi @@ -224,7 +224,7 @@ main() { # Build the repo. ensure cargo build --bins "${CARGO_BUILD_ARGS[@]}" # Create foundry custom version directory. - ensure mkdir -p $FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_VERSION + ensure mkdir -p "$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_VERSION" for bin in "${BINS[@]}"; do for try_path in target/release/$bin target/release/$bin.exe; do if [ -f "$try_path" ]; then @@ -324,7 +324,7 @@ use() { for bin in "${BINS[@]}"; do bin_path="$FOUNDRY_BIN_DIR/$bin" - cp $FOUNDRY_VERSION_DIR/$bin $bin_path + cp "$FOUNDRY_VERSION_DIR/$bin" "$bin_path" # Print usage msg say "use - $(ensure "$bin_path" -V)" From c4ae68826405e2ecb4ab4c27cbce5ac4e21bf1a3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:04:11 +0200 Subject: [PATCH 1935/1963] feat(invariant): generate failed call sequence as solidity (#9827) * feat(invariant): generate failed call sequence as solidity * Fix test, format * Tests nits --- crates/config/src/invariant.rs | 4 + .../evm/evm/src/executors/invariant/replay.rs | 4 + crates/evm/fuzz/src/lib.rs | 55 ++++++++++++-- crates/forge/src/result.rs | 2 +- crates/forge/src/runner.rs | 23 ++++-- crates/forge/tests/cli/config.rs | 4 +- crates/forge/tests/it/invariant.rs | 73 +++++++++++++++++++ crates/forge/tests/it/test_helpers.rs | 1 + 8 files changed, 148 insertions(+), 18 deletions(-) diff --git a/crates/config/src/invariant.rs b/crates/config/src/invariant.rs index 003b1bac93657..3fb3b8f7e1d49 100644 --- a/crates/config/src/invariant.rs +++ b/crates/config/src/invariant.rs @@ -32,6 +32,8 @@ pub struct InvariantConfig { pub show_metrics: bool, /// Optional timeout (in seconds) for each invariant test. pub timeout: Option, + /// Display counterexample as solidity calls. + pub show_solidity: bool, } impl Default for InvariantConfig { @@ -48,6 +50,7 @@ impl Default for InvariantConfig { failure_persist_dir: None, show_metrics: false, timeout: None, + show_solidity: false, } } } @@ -67,6 +70,7 @@ impl InvariantConfig { failure_persist_dir: Some(cache_dir), show_metrics: false, timeout: None, + show_solidity: false, } } diff --git a/crates/evm/evm/src/executors/invariant/replay.rs b/crates/evm/evm/src/executors/invariant/replay.rs index 36192a6d69142..24897f8e5fbaa 100644 --- a/crates/evm/evm/src/executors/invariant/replay.rs +++ b/crates/evm/evm/src/executors/invariant/replay.rs @@ -32,6 +32,7 @@ pub fn replay_run( coverage: &mut Option, deprecated_cheatcodes: &mut HashMap<&'static str, Option<&'static str>>, inputs: &[BasicTxDetails], + show_solidity: bool, ) -> Result> { // We want traces for a failed case. if executor.inspector().tracer.is_none() { @@ -64,6 +65,7 @@ pub fn replay_run( &tx.call_details.calldata, &ided_contracts, call_result.traces, + show_solidity, )); } @@ -110,6 +112,7 @@ pub fn replay_error( coverage: &mut Option, deprecated_cheatcodes: &mut HashMap<&'static str, Option<&'static str>>, progress: Option<&ProgressBar>, + show_solidity: bool, ) -> Result> { match failed_case.test_error { // Don't use at the moment. @@ -137,6 +140,7 @@ pub fn replay_error( coverage, deprecated_cheatcodes, &calls, + show_solidity, ) } } diff --git a/crates/evm/fuzz/src/lib.rs b/crates/evm/fuzz/src/lib.rs index c1854f55c1e49..65ef76f16c989 100644 --- a/crates/evm/fuzz/src/lib.rs +++ b/crates/evm/fuzz/src/lib.rs @@ -41,21 +41,28 @@ pub enum CounterExample { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct BaseCounterExample { - /// Address which makes the call + /// Address which makes the call. pub sender: Option

      , - /// Address to which to call to + /// Address to which to call to. pub addr: Option
      , - /// The data to provide + /// The data to provide. pub calldata: Bytes, - /// Contract name if it exists + /// Contract name if it exists. pub contract_name: Option, - /// Function signature if it exists + /// Function name if it exists. + pub func_name: Option, + /// Function signature if it exists. pub signature: Option, - /// Args used to call the function + /// Pretty formatted args used to call the function. pub args: Option, - /// Traces + /// Unformatted args used to call the function. + pub raw_args: Option, + /// Counter example traces. #[serde(skip)] pub traces: Option, + /// Whether to display sequence as solidity. + #[serde(skip)] + pub show_solidity: bool, } impl BaseCounterExample { @@ -66,6 +73,7 @@ impl BaseCounterExample { bytes: &Bytes, contracts: &ContractsByAddress, traces: Option, + show_solidity: bool, ) -> Self { if let Some((name, abi)) = &contracts.get(&addr) { if let Some(func) = abi.functions().find(|f| f.selector() == bytes[..4]) { @@ -76,11 +84,16 @@ impl BaseCounterExample { addr: Some(addr), calldata: bytes.clone(), contract_name: Some(name.clone()), + func_name: Some(func.name.clone()), signature: Some(func.signature()), args: Some( foundry_common::fmt::format_tokens(&args).format(", ").to_string(), ), + raw_args: Some( + foundry_common::fmt::format_tokens_raw(&args).format(", ").to_string(), + ), traces, + show_solidity, }; } } @@ -91,9 +104,12 @@ impl BaseCounterExample { addr: Some(addr), calldata: bytes.clone(), contract_name: None, + func_name: None, signature: None, args: None, + raw_args: None, traces, + show_solidity: false, } } @@ -108,17 +124,40 @@ impl BaseCounterExample { addr: None, calldata: bytes, contract_name: None, + func_name: None, signature: None, args: Some(foundry_common::fmt::format_tokens(&args).format(", ").to_string()), + raw_args: Some(foundry_common::fmt::format_tokens_raw(&args).format(", ").to_string()), traces, + show_solidity: false, } } } impl fmt::Display for BaseCounterExample { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Display counterexample as solidity. + if self.show_solidity { + if let (Some(sender), Some(contract), Some(address), Some(func_name), Some(args)) = + (&self.sender, &self.contract_name, &self.addr, &self.func_name, &self.raw_args) + { + writeln!(f, "\t\tvm.prank({sender});")?; + write!( + f, + "\t\t{}({}).{}({});", + contract.split_once(':').map_or(contract.as_str(), |(_, contract)| contract), + address, + func_name, + args + )?; + + return Ok(()) + } + } + + // Regular counterexample display. if let Some(sender) = self.sender { - write!(f, "sender={sender} addr=")? + write!(f, "\t\tsender={sender} addr=")? } if let Some(name) = &self.contract_name { diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 58b0f314599b7..0b1ebff19d749 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -455,7 +455,7 @@ impl fmt::Display for TestResult { .as_str(), ); for ex in sequence { - writeln!(s, "\t\t{ex}").unwrap(); + writeln!(s, "{ex}").unwrap(); } } } diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 495b84f3d10c3..1b30dcebe6cee 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -581,20 +581,24 @@ impl<'a> FunctionRunner<'a> { let failure_dir = invariant_config.clone().failure_dir(self.cr.name); let failure_file = failure_dir.join(&invariant_contract.invariant_function.name); + let show_solidity = invariant_config.clone().show_solidity; // Try to replay recorded failure if any. - if let Ok(call_sequence) = + if let Ok(mut call_sequence) = foundry_common::fs::read_json_file::>(failure_file.as_path()) { // Create calls from failed sequence and check if invariant still broken. let txes = call_sequence - .iter() - .map(|seq| BasicTxDetails { - sender: seq.sender.unwrap_or_default(), - call_details: CallDetails { - target: seq.addr.unwrap_or_default(), - calldata: seq.calldata.clone(), - }, + .iter_mut() + .map(|seq| { + seq.show_solidity = show_solidity; + BasicTxDetails { + sender: seq.sender.unwrap_or_default(), + call_details: CallDetails { + target: seq.addr.unwrap_or_default(), + calldata: seq.calldata.clone(), + }, + } }) .collect::>(); if let Ok((success, replayed_entirely)) = check_sequence( @@ -624,6 +628,7 @@ impl<'a> FunctionRunner<'a> { &mut self.result.coverage, &mut self.result.deprecated_cheatcodes, &txes, + show_solidity, ); self.result.invariant_replay_fail( replayed_entirely, @@ -674,6 +679,7 @@ impl<'a> FunctionRunner<'a> { &mut self.result.coverage, &mut self.result.deprecated_cheatcodes, progress.as_ref(), + show_solidity, ) { Ok(call_sequence) => { if !call_sequence.is_empty() { @@ -719,6 +725,7 @@ impl<'a> FunctionRunner<'a> { &mut self.result.coverage, &mut self.result.deprecated_cheatcodes, &invariant_result.last_run_inputs, + show_solidity, ) { error!(%err, "Failed to replay last invariant run"); } diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 350a2fed51570..5952da4b38f2a 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -1090,6 +1090,7 @@ max_assume_rejects = 65536 gas_report_samples = 256 failure_persist_dir = "cache/invariant" show_metrics = false +show_solidity = false [labels] @@ -1193,7 +1194,8 @@ exclude = [] "gas_report_samples": 256, "failure_persist_dir": "cache/invariant", "show_metrics": false, - "timeout": null + "timeout": null, + "show_solidity": false }, "ffi": false, "allow_internal_expect_revert": false, diff --git a/crates/forge/tests/it/invariant.rs b/crates/forge/tests/it/invariant.rs index fb2a9979f0f31..a88ed3db21c49 100644 --- a/crates/forge/tests/it/invariant.rs +++ b/crates/forge/tests/it/invariant.rs @@ -1066,6 +1066,7 @@ contract InvariantSelectorsWeightTest is Test { }); // Tests original and new counterexample lengths are displayed on failure. +// Tests switch from regular sequence output to solidity. forgetest_init!(invariant_sequence_len, |prj, cmd| { prj.update_config(|config| { config.fuzz.seed = Some(U256::from(100u32)); @@ -1099,4 +1100,76 @@ contract InvariantSequenceLenTest is Test { [Sequence] (original: 4, shrunk: 1) ... "#]]); + + // Check regular sequence output. Shrink disabled to show several lines. + cmd.forge_fuse().arg("clean").assert_success(); + prj.update_config(|config| { + config.invariant.shrink_run_limit = 0; + }); + cmd.forge_fuse().args(["test", "--mt", "invariant_increment"]).assert_failure().stdout_eq( + str![[r#" +... +Failing tests: +Encountered 1 failing test in test/InvariantSequenceLenTest.t.sol:InvariantSequenceLenTest +[FAIL: revert: invariant increment failure] + [Sequence] (original: 4, shrunk: 4) + sender=0x00000000000000000000000000000000000018dE addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=setNumber(uint256) args=[1931387396117645594923 [1.931e21]] + sender=0x00000000000000000000000000000000000009d5 addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=increment() args=[] + sender=0x0000000000000000000000000000000000000105 addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=increment() args=[] + sender=0x00000000000000000000000000000000000009B2 addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=setNumber(uint256) args=[996881781832960761274744263729582347 [9.968e35]] + invariant_increment() (runs: 0, calls: 0, reverts: 0) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]], + ); + + // Check solidity sequence output on same failure. + cmd.forge_fuse().arg("clean").assert_success(); + prj.update_config(|config| { + config.invariant.show_solidity = true; + }); + cmd.forge_fuse().args(["test", "--mt", "invariant_increment"]).assert_failure().stdout_eq( + str![[r#" +... +Failing tests: +Encountered 1 failing test in test/InvariantSequenceLenTest.t.sol:InvariantSequenceLenTest +[FAIL: revert: invariant increment failure] + [Sequence] (original: 4, shrunk: 4) + vm.prank(0x00000000000000000000000000000000000018dE); + Counter(0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f).setNumber(1931387396117645594923); + vm.prank(0x00000000000000000000000000000000000009d5); + Counter(0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f).increment(); + vm.prank(0x0000000000000000000000000000000000000105); + Counter(0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f).increment(); + vm.prank(0x00000000000000000000000000000000000009B2); + Counter(0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f).setNumber(996881781832960761274744263729582347); + invariant_increment() (runs: 0, calls: 0, reverts: 0) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]], + ); + + // Persisted failures should be able to switch output. + prj.update_config(|config| { + config.invariant.show_solidity = false; + }); + cmd.forge_fuse().args(["test", "--mt", "invariant_increment"]).assert_failure().stdout_eq( + str![[r#" +... +Failing tests: +Encountered 1 failing test in test/InvariantSequenceLenTest.t.sol:InvariantSequenceLenTest +[FAIL: invariant_increment replay failure] + [Sequence] (original: 4, shrunk: 4) + sender=0x00000000000000000000000000000000000018dE addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=setNumber(uint256) args=[1931387396117645594923 [1.931e21]] + sender=0x00000000000000000000000000000000000009d5 addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=increment() args=[] + sender=0x0000000000000000000000000000000000000105 addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=increment() args=[] + sender=0x00000000000000000000000000000000000009B2 addr=[src/Counter.sol:Counter]0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f calldata=setNumber(uint256) args=[996881781832960761274744263729582347 [9.968e35]] + invariant_increment() (runs: 1, calls: 1, reverts: 1) + +Encountered a total of 1 failing tests, 0 tests succeeded + +"#]], + ); }); diff --git a/crates/forge/tests/it/test_helpers.rs b/crates/forge/tests/it/test_helpers.rs index 3488eca2fedf0..0712ea73bd976 100644 --- a/crates/forge/tests/it/test_helpers.rs +++ b/crates/forge/tests/it/test_helpers.rs @@ -149,6 +149,7 @@ impl ForgeTestProfile { ), show_metrics: false, timeout: None, + show_solidity: false, }; config.sanitized() From 1d5fa644df2dd6b141db15bed37d42f8fb7600b3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:53:20 +0200 Subject: [PATCH 1936/1963] chore: bump compilers, fix #9788 (#9836) --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 06196f4cf276a..df5e5a80a8a01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3756,9 +3756,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203e96bd596350ec8d9aedfca7eff573e9347e2b2fe50eedfbf78532dabe418e" +checksum = "de23802550de5204eec1a6297296d2fef6b86ea61f33b1667eebd886577caa34" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3793,9 +3793,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8ba2ccf8a4bf7730b2ad2815984c1af8e5b8c492420f1cf1d26a8be29cc9e4" +checksum = "27f065a1c785b3ec556a7a49a27016fc723bd9a4d8623f521c326f8396df64a6" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3803,9 +3803,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5889eeb7d6729afbbbb1313b22e8f58aa909fcf38aa6b2f9c9b2443ca0765c59" +checksum = "127e0e788765bc0103eb6b92067843c6ffe660090b2f6fbff1a1441a51939aa0" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3827,9 +3827,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01048f354b4e98bf5fb4810e0607c87d4b8cc7fe6305a42103ce192e33b2da7" +checksum = "8764f450332267305440ec399560919e01aa98f23af2c36ac952f9216449cdca" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3842,9 +3842,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079b80a4f188af9c273b081547d1a95a0a33f782851a99e21aa4eba06e47fa34" +checksum = "c59caebbeaeb0e34564c1a404081478a0aadaa8999b57f0befd85965252e074a" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index f152898f64c29..9d14ed5925e3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -187,7 +187,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.11.0", default-features = false } -foundry-compilers = { version = "0.13.0", default-features = false } +foundry-compilers = { version = "0.13.2", default-features = false } foundry-fork-db = "0.11.0" solang-parser = "=0.3.3" solar-parse = { version = "=0.1.1", default-features = false } From 5f6bd2087d9a595196e5c1a1491b416d51692d9f Mon Sep 17 00:00:00 2001 From: the letter L <134443988+turbocrime@users.noreply.github.com> Date: Fri, 7 Feb 2025 07:05:24 -0800 Subject: [PATCH 1937/1963] feat: add way to disable emitting of gas snapshots to disk (#9710) * feat: gas snapshot emit config * review change comment --------- Co-authored-by: turbocrime --- crates/config/src/lib.rs | 3 + crates/forge/bin/cmd/test/mod.rs | 37 +++++++---- crates/forge/tests/cli/config.rs | 105 +++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 11 deletions(-) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index fa3dae1b97d1c..2ed709d56c5ec 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -202,6 +202,8 @@ pub struct Config { pub snapshots: PathBuf, /// whether to check for differences against previously stored gas snapshots pub gas_snapshot_check: bool, + /// whether to emit gas snapshots to disk + pub gas_snapshot_emit: bool, /// where the broadcast logs are stored pub broadcast: PathBuf, /// additional solc allow paths for `--allow-paths` @@ -2321,6 +2323,7 @@ impl Default for Config { broadcast: "broadcast".into(), snapshots: "snapshots".into(), gas_snapshot_check: false, + gas_snapshot_emit: true, allow_paths: vec![], include_paths: vec![], force: false, diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index 884914df4eddf..f4761dde1ccb6 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -122,6 +122,10 @@ pub struct TestArgs { #[arg(long, env = "FORGE_SNAPSHOT_CHECK")] gas_snapshot_check: Option, + /// Enable/disable recording of gas snapshot results. + #[arg(long, env = "FORGE_SNAPSHOT_EMIT")] + gas_snapshot_emit: Option, + /// Exit with code 0 even if a test fails. #[arg(long, env = "FORGE_ALLOW_FAILURE")] allow_failure: bool, @@ -732,17 +736,28 @@ impl TestArgs { } } - // Create `snapshots` directory if it doesn't exist. - fs::create_dir_all(&config.snapshots)?; - - // Write gas snapshots to disk per group. - gas_snapshots.clone().into_iter().for_each(|(group, snapshots)| { - fs::write_pretty_json_file( - &config.snapshots.join(format!("{group}.json")), - &snapshots, - ) - .expect("Failed to write gas snapshots to disk"); - }); + // By default `gas_snapshot_emit` is set to `true` in the config. + // + // The user can either: + // - Set `FORGE_SNAPSHOT_EMIT=false` in the environment. + // - Pass `--gas-snapshot-emit=false` as a CLI argument. + // - Set `gas_snapshot_emit = false` in the config. + // + // If the user passes `--gas-snapshot-emit=` then it will override the config + // and the environment variable, enabling the check if `true` is passed. + if self.gas_snapshot_emit.unwrap_or(config.gas_snapshot_emit) { + // Create `snapshots` directory if it doesn't exist. + fs::create_dir_all(&config.snapshots)?; + + // Write gas snapshots to disk per group. + gas_snapshots.clone().into_iter().for_each(|(group, snapshots)| { + fs::write_pretty_json_file( + &config.snapshots.join(format!("{group}.json")), + &snapshots, + ) + .expect("Failed to write gas snapshots to disk"); + }); + } } // Print suite summary. diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 5952da4b38f2a..a0f475a018924 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -41,6 +41,7 @@ forgetest!(can_extract_config_values, |prj, cmd| { cache_path: "test-cache".into(), snapshots: "snapshots".into(), gas_snapshot_check: false, + gas_snapshot_emit: true, broadcast: "broadcast".into(), force: true, evm_version: EvmVersion::Byzantium, @@ -966,6 +967,7 @@ cache = true cache_path = "cache" snapshots = "snapshots" gas_snapshot_check = false +gas_snapshot_emit = true broadcast = "broadcast" allow_paths = [] include_paths = [] @@ -1122,6 +1124,7 @@ exclude = [] "cache_path": "cache", "snapshots": "snapshots", "gas_snapshot_check": false, + "gas_snapshot_emit": true, "broadcast": "broadcast", "allow_paths": [], "include_paths": [], @@ -1535,3 +1538,105 @@ Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] ... "#]]); }); + +forgetest_init!(test_gas_snapshot_emit_config, |prj, cmd| { + // Default settings: gas_snapshot_emit enabled. + cmd.forge_fuse().args(["config"]).assert_success().stdout_eq(str![[r#" +... +gas_snapshot_emit = true +... +"#]]); + + prj.insert_ds_test(); + + prj.add_source( + "GasSnapshotEmitTest.sol", + r#" +import "./test.sol"; + +interface Vm { + function startSnapshotGas(string memory name) external; + function stopSnapshotGas() external returns (uint256); +} + +contract GasSnapshotEmitTest is DSTest { + Vm constant vm = Vm(HEVM_ADDRESS); + + function testSnapshotGasSection() public { + vm.startSnapshotGas("testSection"); + int n = 1; + vm.stopSnapshotGas(); + } +} + "#, + ) + .unwrap(); + + // Assert that gas_snapshot_emit is enabled by default. + cmd.forge_fuse().args(["test"]).assert_success(); + // Assert that snapshots were emitted to disk. + assert!(prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); + + // Remove the snapshot file. + fs::remove_file(prj.root().join("snapshots/GasSnapshotEmitTest.json")).unwrap(); + + // Test that `--gas-snapshot-emit=false` flag can be used to disable writing snapshots. + cmd.forge_fuse().args(["test", "--gas-snapshot-emit=false"]).assert_success(); + // Assert that snapshots were not emitted to disk. + assert!(!prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); + + // Test that environment variable `FORGE_SNAPSHOT_EMIT` can be used to disable writing + // snapshots. + cmd.forge_fuse(); + cmd.env("FORGE_SNAPSHOT_EMIT", "false"); + cmd.args(["test"]).assert_success(); + // Assert that snapshots were not emitted to disk. + assert!(!prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); + + // Test that `--gas-snapshot-emit=true` flag can be used to enable writing snapshots, even when + // `FORGE_SNAPSHOT_EMIT` is set to false. + cmd.forge_fuse(); + cmd.env("FORGE_SNAPSHOT_EMIT", "false"); + cmd.args(["test", "--gas-snapshot-emit=true"]).assert_success(); + // Assert that snapshots were emitted to disk. + assert!(prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); + + // Remove the snapshot file. + fs::remove_file(prj.root().join("snapshots/GasSnapshotEmitTest.json")).unwrap(); + + // Disable gas_snapshot_emit in the config file. + prj.update_config(|config| config.gas_snapshot_emit = false); + cmd.forge_fuse().args(["config"]).assert_success(); + + // Test that snapshots are not emitted to disk, when disabled by config. + cmd.forge_fuse().args(["test"]).assert_success(); + // Assert that snapshots were not emitted to disk. + assert!(!prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); + + // Test that `--gas-snapshot-emit=true` flag can be used to enable writing snapshots, when + // disabled by config. + cmd.forge_fuse(); + cmd.args(["test", "--gas-snapshot-emit=true"]).assert_success(); + // Assert that snapshots were emitted to disk. + assert!(prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); + + // Remove the snapshot file. + fs::remove_file(prj.root().join("snapshots/GasSnapshotEmitTest.json")).unwrap(); + + // Test that environment variable `FORGE_SNAPSHOT_EMIT` can be used to enable writing snapshots. + cmd.forge_fuse(); + cmd.env("FORGE_SNAPSHOT_EMIT", "true"); + cmd.args(["test"]).assert_success(); + // Assert that snapshots were emitted to disk. + assert!(prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); + + // Remove the snapshot file. + fs::remove_file(prj.root().join("snapshots/GasSnapshotEmitTest.json")).unwrap(); + + // Test that `--gas-snapshot-emit=false` flag can be used to disable writing snapshots, + // even when `FORGE_SNAPSHOT_EMIT` is set to true. + cmd.forge_fuse().args(["test", "--gas-snapshot-emit=false"]).assert_success(); + + // Assert that snapshots were not emitted to disk. + assert!(!prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); +}); From 2b107e5c99a1e16607820f15036e36e115a0bcbf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Feb 2025 11:30:20 +0000 Subject: [PATCH 1938/1963] chore(deps): weekly `cargo update` (#9843) Locking 38 packages to latest compatible versions Updating alloy-chains v0.1.58 -> v0.1.59 Updating alloy-trie v0.7.8 -> v0.7.9 Updating aurora-engine-modexp v1.1.0 -> v1.2.0 Updating aws-config v1.5.15 -> v1.5.16 Updating aws-runtime v1.5.4 -> v1.5.5 Updating aws-sdk-kms v1.58.0 -> v1.59.0 Updating aws-sdk-sso v1.57.0 -> v1.58.0 Updating aws-sdk-ssooidc v1.58.0 -> v1.59.0 Updating aws-sdk-sts v1.58.0 -> v1.59.0 Updating aws-sigv4 v1.2.7 -> v1.2.8 Updating aws-smithy-runtime v1.7.7 -> v1.7.8 Updating aws-smithy-types v1.2.12 -> v1.2.13 Updating aws-types v1.3.4 -> v1.3.5 Unchanged axum v0.7.9 (available: v0.8.1) Unchanged backtrace v0.3.71 (available: v0.3.74) Updating bytes v1.9.0 -> v1.10.0 Updating cc v1.2.11 -> v1.2.13 Updating clap v4.5.27 -> v4.5.28 Updating clap_derive v4.5.24 -> v4.5.28 Updating comfy-table v7.1.3 -> v7.1.4 Adding const_format v0.2.34 Adding const_format_proc_macros v0.2.34 Unchanged derive_more v1.0.0 (available: v2.0.1) Unchanged evmole v0.6.2 (available: v0.7.0) Updating gcloud-sdk v0.26.2 -> v0.26.3 Updating jiff v0.1.28 -> v0.1.29 Updating jsonwebtoken v9.3.0 -> v9.3.1 Updating once_cell v1.20.2 -> v1.20.3 Updating op-alloy-consensus v0.10.0 -> v0.10.2 Updating op-alloy-rpc-types v0.10.0 -> v0.10.2 Updating parity-scale-codec v3.6.12 -> v3.7.4 Updating parity-scale-codec-derive v3.6.12 -> v3.7.4 Updating pin-project v1.1.8 -> v1.1.9 Updating pin-project-internal v1.1.8 -> v1.1.9 Unchanged proptest v1.5.0 (available: v1.6.0) Unchanged protobuf v3.3.0 (available: v3.7.1) Unchanged protobuf-support v3.3.0 (available: v3.7.1) Unchanged rand v0.8.5 (available: v0.9.0) Updating rustc-hash v2.1.0 -> v2.1.1 Updating scc v2.3.0 -> v2.3.3 Updating sdd v3.0.5 -> v3.0.7 Unchanged solang-parser v0.3.3 (available: v0.3.4) Unchanged strum v0.26.3 (available: v0.27.0) Updating toml v0.8.19 -> v0.8.20 Updating uuid v1.12.1 -> v1.13.1 Unchanged vergen v8.3.2 (available: v9.0.4) Updating wait-timeout v0.2.0 -> v0.2.1 Updating which v7.0.1 -> v7.0.2 Updating winnow v0.7.0 -> v0.7.1 note: to see how you depend on a package, run `cargo tree --invert --package @` Co-authored-by: mattsse <19890894+mattsse@users.noreply.github.com> --- Cargo.lock | 217 +++++++++++++++++-------------- crates/forge/tests/cli/config.rs | 12 +- 2 files changed, 125 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df5e5a80a8a01..6d51784632237 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0d6c784abf2e061139798d51299da278fc8f02d7b7546662b898d9b22ab5e9" +checksum = "4d37bc62b68c056e3742265ab73c73d413d07357909e0e4ea1e95453066a7469" dependencies = [ "alloy-primitives", "num_enum", @@ -155,7 +155,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.7.0", + "winnow 0.7.1", ] [[package]] @@ -374,7 +374,7 @@ dependencies = [ "futures-utils-wasm", "lru 0.13.0", "parking_lot", - "pin-project 1.1.8", + "pin-project 1.1.9", "reqwest", "serde", "serde_json", @@ -440,7 +440,7 @@ dependencies = [ "alloy-transport-ipc", "alloy-transport-ws", "futures", - "pin-project 1.1.8", + "pin-project 1.1.9", "reqwest", "serde", "serde_json", @@ -741,7 +741,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a971129d242338d92009470a2f750d3b2630bc5da00a40a94d51f5d456b5712f" dependencies = [ "serde", - "winnow 0.7.0", + "winnow 0.7.1", ] [[package]] @@ -803,7 +803,7 @@ dependencies = [ "bytes", "futures", "interprocess", - "pin-project 1.1.8", + "pin-project 1.1.9", "serde", "serde_json", "tempfile", @@ -832,9 +832,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6917c79e837aa7b77b7a6dae9f89cbe15313ac161c4d3cfaf8909ef21f3d22d8" +checksum = "d95a94854e420f07e962f7807485856cde359ab99ab6413883e15235ad996e8b" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -1070,7 +1070,7 @@ dependencies = [ "futures", "interprocess", "parking_lot", - "pin-project 1.1.8", + "pin-project 1.1.9", "serde", "serde_json", "thiserror 2.0.11", @@ -1346,9 +1346,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "aurora-engine-modexp" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aef7712851e524f35fbbb74fa6599c5cd8692056a1c36f9ca0d2001b670e7e5" +checksum = "518bc5745a6264b5fd7b09dffb9667e400ee9e2bbe18555fac75e1fe9afa0df9" dependencies = [ "hex", "num", @@ -1373,9 +1373,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.15" +version = "1.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc47e70fc35d054c8fcd296d47a61711f043ac80534a10b4f741904f81e73a90" +checksum = "50236e4d60fe8458de90a71c0922c761e41755adf091b1b03de1cef537179915" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1415,9 +1415,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee7643696e7fdd74c10f9eb42848a87fe469d35eae9c3323f80aa98f350baac" +checksum = "76dd04d39cc12844c0994f2c9c5a6f5184c22e9188ec1ff723de41910a21dcad" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1435,14 +1435,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] name = "aws-sdk-kms" -version = "1.58.0" +version = "1.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b7a24700ac548025a47a5c579886f5198895bb1eccd8964dfd71cd66c16912" +checksum = "2da21a543bfc06001637785ec6ed7b4bec9a3d737f0abca3ddd8d7b962e71fb1" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1462,9 +1462,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.57.0" +version = "1.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54bab121fe1881a74c338c5f723d1592bf3b53167f80268a1274f404e1acc38" +checksum = "16ff718c9ee45cc1ebd4774a0e086bb80a6ab752b4902edf1c9f56b86ee1f770" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1484,9 +1484,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.58.0" +version = "1.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c8234fd024f7ac61c4e44ea008029bde934250f371efe7d4a39708397b1080c" +checksum = "5183e088715cc135d8d396fdd3bc02f018f0da4c511f53cb8d795b6a31c55809" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1506,9 +1506,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.58.0" +version = "1.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba60e1d519d6f23a9df712c04fdeadd7872ac911c84b2f62a8bda92e129b7962" +checksum = "c9f944ef032717596639cea4a2118a3a457268ef51bbb5fde9637e54c465da00" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1529,9 +1529,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.7" +version = "1.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "690118821e46967b3c4501d67d7d52dd75106a9c54cf36cefa1985cedbe94e05" +checksum = "0bc5bbd1e4a2648fd8c5982af03935972c24a2f9846b396de661d351ee3ce837" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1602,9 +1602,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.7" +version = "1.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865f7050bbc7107a6c98a397a9fcd9413690c27fa718446967cf03b2d3ac517e" +checksum = "d526a12d9ed61fadefda24abe2e682892ba288c2018bcb38b1b4c111d13f6d92" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1646,9 +1646,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.12" +version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28f6feb647fb5e0d5b50f0472c19a7db9462b74e2fec01bb0b44eedcc834e97" +checksum = "c7b8a53819e42f10d0821f56da995e1470b199686a1809168db6ca485665f042" dependencies = [ "base64-simd", "bytes", @@ -1678,9 +1678,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0df5a18c4f951c645300d365fec53a61418bcf4650f604f85fe2a665bfaa0c2" +checksum = "dfbd0a668309ec1f66c0f6bda4840dd6d4796ae26d699ebc266d7cc95c6d040f" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1952,9 +1952,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" dependencies = [ "serde", ] @@ -2080,9 +2080,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.11" +version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" +checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" dependencies = [ "shlex", ] @@ -2187,9 +2187,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.27" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" +checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" dependencies = [ "clap_builder", "clap_derive", @@ -2231,9 +2231,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" dependencies = [ "heck", "proc-macro2", @@ -2392,13 +2392,12 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comfy-table" -version = "7.1.3" +version = "7.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f165e7b643266ea80cb858aed492ad9280e3e05ce24d4a99d7d7b889b6a4d9" +checksum = "4a65ebfec4fb190b6f90e944a817d60499ee0744e582530e2c9900a22e591d9a" dependencies = [ "crossterm", - "strum", - "strum_macros", + "unicode-segmentation", "unicode-width 0.2.0", ] @@ -2473,6 +2472,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_format" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "convert_case" version = "0.6.0" @@ -3258,7 +3277,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml 0.8.19", + "toml 0.8.20", "uncased", "version_check", ] @@ -3394,7 +3413,7 @@ dependencies = [ "thiserror 2.0.11", "tikv-jemallocator", "tokio", - "toml 0.8.19", + "toml 0.8.20", "toml_edit", "tower-http", "tracing", @@ -3424,7 +3443,7 @@ dependencies = [ "serde_json", "solang-parser", "thiserror 2.0.11", - "toml 0.8.19", + "toml 0.8.20", "tracing", ] @@ -3439,7 +3458,7 @@ dependencies = [ "similar-asserts", "solang-parser", "thiserror 2.0.11", - "toml 0.8.19", + "toml 0.8.20", "tracing", "tracing-subscriber", ] @@ -3625,7 +3644,7 @@ dependencies = [ "serde", "serde_json", "thiserror 2.0.11", - "toml 0.8.19", + "toml 0.8.20", "tracing", "walkdir", ] @@ -3787,7 +3806,7 @@ dependencies = [ "thiserror 2.0.11", "tokio", "tracing", - "winnow 0.7.0", + "winnow 0.7.1", "yansi", ] @@ -3892,7 +3911,7 @@ dependencies = [ "solar-parse", "tempfile", "thiserror 2.0.11", - "toml 0.8.19", + "toml 0.8.20", "toml_edit", "tracing", "walkdir", @@ -4299,9 +4318,9 @@ checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" [[package]] name = "gcloud-sdk" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a771db7ee43ad84638d0e6131cb514e402af6a5a96051f4425d66dc0ee527d8" +checksum = "a6392faf01950e198a204b13034efd7aadda1877e7c174f5442ee39bad5d99bd" dependencies = [ "async-trait", "bytes", @@ -5429,9 +5448,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jiff" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c607c728e28764fecde611a2764a3a5db19ae21dcec46f292244f5cc5c085a81" +checksum = "c04ef77ae73f3cf50510712722f0c4e8b46f5aaa1bf5ffad2ae213e6495e78e5" dependencies = [ "jiff-tzdb-platform", "log", @@ -5479,11 +5498,11 @@ dependencies = [ [[package]] name = "jsonwebtoken" -version = "9.3.0" +version = "9.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" +checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "js-sys", "pem", "ring", @@ -5949,7 +5968,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee3224f0e8be7c2a1ebc77ef9c3eecb90f55c6594399ee825de964526b3c9056" dependencies = [ - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -6220,15 +6239,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "op-alloy-consensus" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e8e67b41afd338096ca31f24c5e7800797858b963490be2e8971d17d733f49" +checksum = "1363dd2454f473e2a2a6ee5eda585ecf94209319e35529bd703ddc5072798eb4" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6242,9 +6261,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d55acda15bd273d1d9a052536cf46c3520f597ac9884376c9c56241f2f5e9b" +checksum = "77979abf2b8b2be8996da3b434b09d770edbcceccd59251c3373ef553e743cf0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6314,28 +6333,30 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.12" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +checksum = "c9fde3d0718baf5bc92f577d652001da0f8d54cd03a7974e118d04fc888dc23d" dependencies = [ "arrayvec", "bitvec", "byte-slice-cast", + "const_format", "impl-trait-for-tuples", "parity-scale-codec-derive", + "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.6.12" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +checksum = "581c837bb6b9541ce7faa9377c20616e4fb7650f6b0f68bc93c827ee504fb7b3" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.98", ] [[package]] @@ -6574,11 +6595,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" +checksum = "dfe2e71e1471fe07709406bf725f710b02927c9c54b2b5b2ec0e8087d97c327d" dependencies = [ - "pin-project-internal 1.1.8", + "pin-project-internal 1.1.9", ] [[package]] @@ -6594,9 +6615,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" +checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67" dependencies = [ "proc-macro2", "quote", @@ -6950,7 +6971,7 @@ dependencies = [ "quick-xml 0.37.2", "strip-ansi-escapes", "thiserror 2.0.11", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] @@ -7475,9 +7496,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" dependencies = [ "rand", ] @@ -7694,9 +7715,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.3.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640" +checksum = "ea091f6cac2595aa38993f04f4ee692ed43757035c36e67c180b6828356385b1" dependencies = [ "sdd", ] @@ -7770,9 +7791,9 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.5" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" +checksum = "b07779b9b918cc05650cb30f404d4d7835d26df37c235eded8a6832e2fb82cca" [[package]] name = "sec1" @@ -8381,7 +8402,7 @@ dependencies = [ "thiserror 2.0.11", "tokio", "toml_edit", - "uuid 1.12.1", + "uuid 1.13.1", "zip", "zip-extract", ] @@ -8940,9 +8961,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "indexmap 2.7.1", "serde", @@ -8970,7 +8991,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.7.0", + "winnow 0.7.1", ] [[package]] @@ -8992,7 +9013,7 @@ dependencies = [ "hyper-timeout", "hyper-util", "percent-encoding", - "pin-project 1.1.8", + "pin-project 1.1.9", "prost", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", @@ -9021,7 +9042,7 @@ dependencies = [ "futures-core", "futures-util", "indexmap 1.9.3", - "pin-project 1.1.8", + "pin-project 1.1.9", "pin-project-lite", "rand", "slab", @@ -9437,11 +9458,11 @@ dependencies = [ [[package]] name = "uuid" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.3.1", "serde", ] @@ -9492,9 +9513,9 @@ dependencies = [ [[package]] name = "wait-timeout" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" dependencies = [ "libc", ] @@ -9725,9 +9746,9 @@ dependencies = [ [[package]] name = "which" -version = "7.0.1" +version = "7.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a9e33648339dc1642b0e36e21b3385e6148e289226f657c809dee59df5028" +checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283" dependencies = [ "either", "env_home", @@ -10142,9 +10163,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" +checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" dependencies = [ "memchr", ] diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index a0f475a018924..fc7252e0a6e83 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -992,8 +992,6 @@ ignored_warnings_from = [] deny_warnings = false test_failures_file = "cache/test-failures" show_progress = false -eof = false -transaction_timeout = 120 ffi = false allow_internal_expect_revert = false always_use_create_2_factory = false @@ -1022,16 +1020,18 @@ bytecode_hash = "ipfs" cbor_metadata = true sparse_mode = false build_info = false -compilation_restrictions = [] -additional_compiler_profiles = [] -assertions_revert = true isolate = false disable_block_gas_limit = false -odyssey = false unchecked_cheatcode_artifacts = false create2_library_salt = "0x0000000000000000000000000000000000000000000000000000000000000000" create2_deployer = "0x4e59b44847b379578588920ca78fbf26c0b4956c" +assertions_revert = true legacy_assertions = false +odyssey = false +transaction_timeout = 120 +eof = false +additional_compiler_profiles = [] +compilation_restrictions = [] [[profile.default.fs_permissions]] access = "read" From 67be473b54778ba15b454e597e3d50960b920900 Mon Sep 17 00:00:00 2001 From: Panagiotis Ganelis <50522617+PanGan21@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:55:03 +0100 Subject: [PATCH 1939/1963] feat(`forge fmt`): add watch mode (#9838) * feat(forge): add watch mode to forge fmt * keen fmt run sync --- crates/forge/bin/cmd/fmt.rs | 9 +++++++++ crates/forge/bin/cmd/watch.rs | 12 ++++++++++-- crates/forge/bin/main.rs | 8 +++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/crates/forge/bin/cmd/fmt.rs b/crates/forge/bin/cmd/fmt.rs index 206eb7b960153..26f601d7bbac1 100644 --- a/crates/forge/bin/cmd/fmt.rs +++ b/crates/forge/bin/cmd/fmt.rs @@ -1,3 +1,4 @@ +use super::watch::WatchArgs; use clap::{Parser, ValueHint}; use eyre::{Context, Result}; use forge_fmt::{format_to, parse}; @@ -39,6 +40,9 @@ pub struct FmtArgs { /// In 'check' and stdin modes, outputs raw formatted code instead of the diff. #[arg(long, short)] raw: bool, + + #[command(flatten)] + pub watch: WatchArgs, } impl_figment_convert_basic!(FmtArgs); @@ -186,6 +190,11 @@ impl FmtArgs { Ok(()) } + + /// Returns whether `FmtArgs` was configured with `--watch` + pub fn is_watch(&self) -> bool { + self.watch.watch.is_some() + } } struct Line(Option); diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index a7b0a1a025a70..62bb4ebac6a8d 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -1,6 +1,6 @@ use super::{ - build::BuildArgs, coverage::CoverageArgs, doc::DocArgs, snapshot::GasSnapshotArgs, - test::TestArgs, + build::BuildArgs, coverage::CoverageArgs, doc::DocArgs, fmt::FmtArgs, + snapshot::GasSnapshotArgs, test::TestArgs, }; use alloy_primitives::map::HashSet; use clap::Parser; @@ -325,6 +325,14 @@ pub async fn watch_coverage(args: CoverageArgs) -> Result<()> { run(config).await } +pub async fn watch_fmt(args: FmtArgs) -> Result<()> { + let config = args.watch.watchexec_config(|| { + let config = args.load_config()?; + Ok([config.src, config.test, config.script]) + })?; + run(config).await +} + /// Executes a [`Watchexec`] that listens for changes in the project's sources directory pub async fn watch_doc(args: DocArgs) -> Result<()> { let config = args.watch.watchexec_config(|| { diff --git a/crates/forge/bin/main.rs b/crates/forge/bin/main.rs index a9c341f3bfd70..82463d64e72a1 100644 --- a/crates/forge/bin/main.rs +++ b/crates/forge/bin/main.rs @@ -104,7 +104,13 @@ fn run() -> Result<()> { utils::block_on(cmd.run()) } } - ForgeSubcommand::Fmt(cmd) => cmd.run(), + ForgeSubcommand::Fmt(cmd) => { + if cmd.is_watch() { + utils::block_on(watch::watch_fmt(cmd)) + } else { + cmd.run() + } + } ForgeSubcommand::Config(cmd) => cmd.run(), ForgeSubcommand::Flatten(cmd) => cmd.run(), ForgeSubcommand::Inspect(cmd) => cmd.run(), From db3d9fc95398450dbed83d4841042c62c155bcfc Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Mon, 10 Feb 2025 17:51:17 +0530 Subject: [PATCH 1940/1963] feat(`common`): `PathOrContractInfo` arg type (#9770) * feat(`common`): `PathOrContractInfo` * fix * docs * nit * test * move find abi helper to ContractsByArtifact * nit * fix * nit * fix * nit * ensure sol file * account for vyper contracts * nit --- crates/cast/bin/cmd/interface.rs | 33 ++++++----- crates/common/src/compile.rs | 91 ++++++++++++++++++++++++++++++ crates/common/src/contracts.rs | 97 ++++++++++++++++++++++++++++++-- crates/common/src/utils.rs | 1 - crates/config/src/lib.rs | 2 +- crates/forge/bin/cmd/inspect.rs | 36 ++++++------ crates/forge/tests/cli/cmd.rs | 43 ++++++++++++++ 7 files changed, 262 insertions(+), 41 deletions(-) diff --git a/crates/cast/bin/cmd/interface.rs b/crates/cast/bin/cmd/interface.rs index 28ce1ed31ec09..10b7e42500288 100644 --- a/crates/cast/bin/cmd/interface.rs +++ b/crates/cast/bin/cmd/interface.rs @@ -4,8 +4,10 @@ use clap::Parser; use eyre::{Context, Result}; use foundry_block_explorers::Client; use foundry_cli::{opts::EtherscanOpts, utils::LoadConfig}; -use foundry_common::{compile::ProjectCompiler, fs, shell}; -use foundry_compilers::{info::ContractInfo, utils::canonicalize}; +use foundry_common::{ + compile::{PathOrContractInfo, ProjectCompiler}, + find_target_path, fs, shell, ContractsByArtifact, +}; use foundry_config::load_config; use itertools::Itertools; use serde_json::Value; @@ -118,19 +120,20 @@ fn load_abi_from_artifact(path_or_contract: &str) -> Result(quiet: bool, f: impl FnOnce() -> O) -> O { foundry_compilers::report::with_scoped(&reporter, f) } + +/// Container type for parsing contract identifiers from CLI. +/// +/// Passed string can be of the following forms: +/// - `src/Counter.sol` - path to the contract file, in the case where it only contains one contract +/// - `src/Counter.sol:Counter` - path to the contract file and the contract name +/// - `Counter` - contract name only +#[derive(Clone, PartialEq, Eq)] +pub enum PathOrContractInfo { + /// Non-canoncalized path provided via CLI. + Path(PathBuf), + /// Contract info provided via CLI. + ContractInfo(CompilerContractInfo), +} + +impl PathOrContractInfo { + /// Returns the path to the contract file if provided. + pub fn path(&self) -> Option { + match self { + Self::Path(path) => Some(path.to_path_buf()), + Self::ContractInfo(info) => info.path.as_ref().map(PathBuf::from), + } + } + + /// Returns the contract name if provided. + pub fn name(&self) -> Option<&str> { + match self { + Self::Path(_) => None, + Self::ContractInfo(info) => Some(&info.name), + } + } +} + +impl FromStr for PathOrContractInfo { + type Err = eyre::Error; + + fn from_str(s: &str) -> Result { + if let Ok(contract) = CompilerContractInfo::from_str(s) { + return Ok(Self::ContractInfo(contract)); + } + let path = PathBuf::from(s); + if path.extension().is_some_and(|ext| ext == "sol" || ext == "vy") { + return Ok(Self::Path(path)); + } + Err(eyre::eyre!("Invalid contract identifier, file is not *.sol or *.vy: {}", s)) + } +} + +impl std::fmt::Debug for PathOrContractInfo { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Path(path) => write!(f, "Path({})", path.display()), + Self::ContractInfo(info) => { + write!(f, "ContractInfo({info})") + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_contract_identifiers() { + let t = ["src/Counter.sol", "src/Counter.sol:Counter", "Counter"]; + + let i1 = PathOrContractInfo::from_str(t[0]).unwrap(); + assert_eq!(i1, PathOrContractInfo::Path(PathBuf::from(t[0]))); + + let i2 = PathOrContractInfo::from_str(t[1]).unwrap(); + assert_eq!( + i2, + PathOrContractInfo::ContractInfo(CompilerContractInfo { + path: Some("src/Counter.sol".to_string()), + name: "Counter".to_string() + }) + ); + + let i3 = PathOrContractInfo::from_str(t[2]).unwrap(); + assert_eq!( + i3, + PathOrContractInfo::ContractInfo(CompilerContractInfo { + path: None, + name: "Counter".to_string() + }) + ); + } +} diff --git a/crates/common/src/contracts.rs b/crates/common/src/contracts.rs index 9aac912d4f653..1e78751fde964 100644 --- a/crates/common/src/contracts.rs +++ b/crates/common/src/contracts.rs @@ -1,16 +1,24 @@ //! Commonly used contract types and functions. +use crate::compile::PathOrContractInfo; use alloy_json_abi::{Event, Function, JsonAbi}; use alloy_primitives::{hex, Address, Bytes, Selector, B256}; -use eyre::Result; +use eyre::{OptionExt, Result}; use foundry_compilers::{ artifacts::{ BytecodeObject, CompactBytecode, CompactContractBytecode, CompactDeployedBytecode, - ContractBytecodeSome, Offsets, + ConfigurableContractArtifact, ContractBytecodeSome, Offsets, }, - ArtifactId, + utils::canonicalized, + ArtifactId, Project, ProjectCompileOutput, +}; +use std::{ + collections::BTreeMap, + ops::Deref, + path::{Path, PathBuf}, + str::FromStr, + sync::Arc, }; -use std::{collections::BTreeMap, ops::Deref, str::FromStr, sync::Arc}; /// Libraries' runtime code always starts with the following instruction: /// `PUSH20 0x0000000000000000000000000000000000000000` @@ -268,6 +276,17 @@ impl ContractsByArtifact { .map(|(_, contract)| contract.abi.clone()) } + /// Finds abi by name or source path + /// + /// Returns the abi and the contract name. + pub fn find_abi_by_name_or_src_path(&self, name_or_path: &str) -> Option<(JsonAbi, String)> { + self.iter() + .find(|(artifact, _)| { + artifact.name == name_or_path || artifact.source == PathBuf::from(name_or_path) + }) + .map(|(_, contract)| (contract.abi.clone(), contract.name.clone())) + } + /// Flattens the contracts into functions, events and errors. pub fn flatten(&self) -> (BTreeMap, BTreeMap, JsonAbi) { let mut funcs = BTreeMap::new(); @@ -288,6 +307,21 @@ impl ContractsByArtifact { } } +impl From for ContractsByArtifact { + fn from(value: ProjectCompileOutput) -> Self { + Self::new(value.into_artifacts().map(|(id, ar)| { + ( + id, + CompactContractBytecode { + abi: ar.abi, + bytecode: ar.bytecode, + deployed_bytecode: ar.deployed_bytecode, + }, + ) + })) + } +} + impl Deref for ContractsByArtifact { type Target = BTreeMap; @@ -399,6 +433,61 @@ pub fn compact_to_contract(contract: CompactContractBytecode) -> Result Result { + match identifier { + PathOrContractInfo::Path(path) => Ok(canonicalized(project.root().join(path))), + PathOrContractInfo::ContractInfo(info) => { + let path = project.find_contract_path(&info.name)?; + Ok(path) + } + } +} + +/// Returns the target artifact given the path and name. +pub fn find_matching_contract_artifact( + output: &mut ProjectCompileOutput, + target_path: &Path, + target_name: Option<&str>, +) -> eyre::Result { + if let Some(name) = target_name { + output + .remove(target_path, name) + .ok_or_eyre(format!("Could not find artifact `{name}` in the compiled artifacts")) + } else { + 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 { + return Ok(target_artifact.clone()); + } + + // 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.clone()) + } +} #[cfg(test)] mod tests { use super::*; diff --git a/crates/common/src/utils.rs b/crates/common/src/utils.rs index 2676807478b61..6e8c374ebc047 100644 --- a/crates/common/src/utils.rs +++ b/crates/common/src/utils.rs @@ -1,7 +1,6 @@ //! Uncategorised utilities. use alloy_primitives::{keccak256, B256, U256}; - /// Block on a future using the current tokio runtime on the current thread. pub fn block_on(future: F) -> F::Output { block_on_handle(&tokio::runtime::Handle::current(), future) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 2ed709d56c5ec..62df691ac2ef6 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -122,7 +122,7 @@ mod bind_json; use bind_json::BindJsonConfig; mod compilation; -use compilation::{CompilationRestrictions, SettingsOverrides}; +pub use compilation::{CompilationRestrictions, SettingsOverrides}; /// Foundry configuration /// diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 42ba370b2edc1..8474b396cf38b 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -5,27 +5,29 @@ use comfy_table::{modifiers::UTF8_ROUND_CORNERS, Cell, Table}; use eyre::{Context, Result}; use forge::revm::primitives::Eof; use foundry_cli::opts::{BuildOpts, CompilerOpts}; -use foundry_common::{compile::ProjectCompiler, fmt::pretty_eof, shell}; -use foundry_compilers::{ - artifacts::{ - output_selection::{ - BytecodeOutputSelection, ContractOutputSelection, DeployedBytecodeOutputSelection, - EvmOutputSelection, EwasmOutputSelection, - }, - CompactBytecode, StorageLayout, +use foundry_common::{ + compile::{PathOrContractInfo, ProjectCompiler}, + find_matching_contract_artifact, find_target_path, + fmt::pretty_eof, + shell, +}; +use foundry_compilers::artifacts::{ + output_selection::{ + BytecodeOutputSelection, ContractOutputSelection, DeployedBytecodeOutputSelection, + EvmOutputSelection, EwasmOutputSelection, }, - info::ContractInfo, - utils::canonicalize, + CompactBytecode, StorageLayout, }; use regex::Regex; use serde_json::{Map, Value}; -use std::{collections::BTreeMap, fmt, sync::LazyLock}; +use std::{collections::BTreeMap, fmt, str::FromStr, sync::LazyLock}; /// CLI arguments for `forge inspect`. #[derive(Clone, Debug, Parser)] pub struct InspectArgs { /// The identifier of the contract to inspect in the form `(:)?`. - pub contract: ContractInfo, + #[arg(value_parser = PathOrContractInfo::from_str)] + pub contract: PathOrContractInfo, /// The contract artifact field to inspect. #[arg(value_enum)] @@ -64,17 +66,11 @@ impl InspectArgs { // Build the project let project = modified_build_args.project()?; let compiler = ProjectCompiler::new().quiet(true); - let target_path = if let Some(path) = &contract.path { - canonicalize(project.root().join(path))? - } else { - project.find_contract_path(&contract.name)? - }; + let target_path = find_target_path(&project, &contract)?; let mut output = compiler.files([target_path.clone()]).compile(&project)?; // Find the artifact - let artifact = output.remove(&target_path, &contract.name).ok_or_else(|| { - eyre::eyre!("Could not find artifact `{contract}` in the compiled artifacts") - })?; + let artifact = find_matching_contract_artifact(&mut output, &target_path, contract.name())?; // Match on ContractArtifactFields and pretty-print match field { diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index b57c5890b4f9c..59ab2ba080256 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -3283,6 +3283,12 @@ const CUSTOM_COUNTER: &str = r#" } } "#; + +const ANOTHER_COUNTER: &str = r#" + contract AnotherCounter is Counter { + constructor(uint256 _number) Counter(_number) {} + } +"#; forgetest!(inspect_custom_counter_abi, |prj, cmd| { prj.add_source("Counter.sol", CUSTOM_COUNTER).unwrap(); @@ -3355,6 +3361,43 @@ forgetest!(inspect_custom_counter_errors, |prj, cmd| { ╰-------------------------------+----------╯ +"#]]); +}); + +forgetest!(inspect_path_only_identifier, |prj, cmd| { + prj.add_source("Counter.sol", CUSTOM_COUNTER).unwrap(); + + cmd.args(["inspect", "src/Counter.sol", "errors"]).assert_success().stdout_eq(str![[r#" + +╭-------------------------------+----------╮ +| Error | Selector | ++==========================================+ +| CustomErr(Counter.ErrWithMsg) | 0625625a | +|-------------------------------+----------| +| NumberIsZero() | de5d32ac | +╰-------------------------------+----------╯ + + +"#]]); +}); + +forgetest!(test_inspect_contract_with_same_name, |prj, cmd| { + let source = format!("{CUSTOM_COUNTER}\n{ANOTHER_COUNTER}"); + prj.add_source("Counter.sol", &source).unwrap(); + + cmd.args(["inspect", "src/Counter.sol", "errors"]).assert_failure().stderr_eq(str![[r#"Error: Multiple contracts found in the same file, please specify the target : or [..]"#]]); + + cmd.forge_fuse().args(["inspect", "Counter", "errors"]).assert_success().stdout_eq(str![[r#" + +╭-------------------------------+----------╮ +| Error | Selector | ++==========================================+ +| CustomErr(Counter.ErrWithMsg) | 0625625a | +|-------------------------------+----------| +| NumberIsZero() | de5d32ac | +╰-------------------------------+----------╯ + + "#]]); }); From 55785b73f026576234f02e1eb6e9605c74643017 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 11 Feb 2025 10:14:24 +0200 Subject: [PATCH 1941/1963] fix(forge): decode fallbacks with calldata (#9859) --- crates/evm/traces/src/decoder/mod.rs | 12 +++- crates/forge/tests/cli/cmd.rs | 99 ++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 3 deletions(-) diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index f904bb46ecc5e..d96e8d5dc6c82 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -366,7 +366,12 @@ impl CallTraceDecoder { let [func, ..] = &functions[..] else { return DecodedCallTrace { label, - call_data: None, + call_data: self.fallback_contracts.get(&trace.address).map(|_| { + DecodedCallData { + signature: "fallback()".to_string(), + args: vec![cdata.to_string()], + } + }), return_data: self.default_return_data(trace), }; }; @@ -376,7 +381,7 @@ impl CallTraceDecoder { let mut call_data = self.decode_function_input(trace, func); if let Some(fallback_functions) = self.fallback_contracts.get(&trace.address) { if !fallback_functions.contains(&func.signature()) { - call_data.signature = "fallback()".into(); + call_data.signature = "fallback()".to_string(); } } @@ -388,7 +393,8 @@ impl CallTraceDecoder { } else { let has_receive = self.receive_contracts.contains(&trace.address); let signature = - if cdata.is_empty() && has_receive { "receive()" } else { "fallback()" }.into(); + if cdata.is_empty() && has_receive { "receive()" } else { "fallback()" } + .to_string(); let args = if cdata.is_empty() { Vec::new() } else { vec![cdata.to_string()] }; DecodedCallTrace { label, diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 59ab2ba080256..67327b0dc0b56 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -2725,6 +2725,105 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) ); }); +// +forgetest_init!(gas_report_fallback_with_calldata, |prj, cmd| { + prj.add_test( + "FallbackWithCalldataTest.sol", + r#" +import {Test} from "forge-std/Test.sol"; + +contract CounterWithFallback { + uint256 public number; + + function increment() public { + number++; + } + + fallback() external { + number++; + } +} + +contract CounterWithFallbackTest is Test { + CounterWithFallback public counter; + + function setUp() public { + counter = new CounterWithFallback(); + } + + function test_fallback_with_calldata() public { + (bool success,) = address(counter).call("hello"); + require(success); + } +} +"#, + ) + .unwrap(); + + cmd.args(["test", "--mt", "test_fallback_with_calldata", "-vvvv", "--gas-report"]) + .assert_success() + .stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/FallbackWithCalldataTest.sol:CounterWithFallbackTest +[PASS] test_fallback_with_calldata() ([GAS]) +Traces: + [48777] CounterWithFallbackTest::test_fallback_with_calldata() + ├─ [43461] CounterWithFallback::fallback(0x68656c6c6f) + │ └─ ← [Stop] + └─ ← [Stop] + +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +╭----------------------------------------------------------------+-----------------+-------+--------+-------+---------╮ +| test/FallbackWithCalldataTest.sol:CounterWithFallback Contract | | | | | | ++=====================================================================================================================+ +| Deployment Cost | Deployment Size | | | | | +|----------------------------------------------------------------+-----------------+-------+--------+-------+---------| +| 132471 | 396 | | | | | +|----------------------------------------------------------------+-----------------+-------+--------+-------+---------| +| | | | | | | +|----------------------------------------------------------------+-----------------+-------+--------+-------+---------| +| Function Name | Min | Avg | Median | Max | # Calls | +|----------------------------------------------------------------+-----------------+-------+--------+-------+---------| +| fallback | 43461 | 43461 | 43461 | 43461 | 1 | +╰----------------------------------------------------------------+-----------------+-------+--------+-------+---------╯ + + +Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests) + +"#]]); + + cmd.forge_fuse() + .args(["test", "--mt", "test_fallback_with_calldata", "--gas-report", "--json"]) + .assert_success() + .stdout_eq( + str![[r#" +[ + { + "contract": "test/FallbackWithCalldataTest.sol:CounterWithFallback", + "deployment": { + "gas": 132471, + "size": 396 + }, + "functions": { + "fallback()": { + "calls": 1, + "min": 43461, + "mean": 43461, + "median": 43461, + "max": 43461 + } + } + } +] +"#]] + .is_json(), + ); +}); + // forgetest_init!(gas_report_size_for_nested_create, |prj, cmd| { prj.add_test( From 1bcd17c8299d7c0792a77b2d4a0cf2c531a5cab2 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 11 Feb 2025 12:32:38 +0100 Subject: [PATCH 1942/1963] feat: add `--alloy-rev` and fix `forge bind` re-run on built project (#9861) * add --alloy-rev, marked as conflicting with --alloy-version, updated --alloy-version to use crates.io whereas rev uses git * fix forge bind upon re-run after crate was built * clarify github / crates target * minor doc fixes * dedupe dep check * fix fmt --- crates/forge/bin/cmd/bind.rs | 15 +++++++-- crates/sol-macro-gen/src/sol_macro_gen.rs | 38 ++++++++++++++--------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/crates/forge/bin/cmd/bind.rs b/crates/forge/bin/cmd/bind.rs index 2460f4ec518f6..1198a89af5199 100644 --- a/crates/forge/bin/cmd/bind.rs +++ b/crates/forge/bin/cmd/bind.rs @@ -83,11 +83,15 @@ pub struct BindArgs { #[arg(long, hide = true)] alloy: bool, - /// Specify the alloy version. + /// Specify the `alloy` version on Crates. #[arg(long)] alloy_version: Option, - /// Generate bindings for the `ethers` library, instead of `alloy` (removed). + /// Specify the `alloy` revision on GitHub. + #[arg(long, conflicts_with = "alloy_version")] + alloy_rev: Option, + + /// Generate bindings for the `ethers` library (removed), instead of `alloy`. #[arg(long, hide = true)] ethers: bool, @@ -159,6 +163,11 @@ impl BindArgs { return None; } + // Ignore the `target` directory in case the user has built the project. + if path.iter().any(|comp| comp == "target") { + return None; + } + // We don't want `.metadata.json` files. let stem = path.file_stem()?.to_str()?; if stem.ends_with(".metadata") { @@ -207,6 +216,7 @@ impl BindArgs { !self.skip_cargo_toml, self.module, self.alloy_version.clone(), + self.alloy_rev.clone(), )?; sh_println!("OK.")?; Ok(()) @@ -225,6 +235,7 @@ impl BindArgs { bindings_root, self.single_file, self.alloy_version.clone(), + self.alloy_rev.clone(), )?; } else { trace!(single_file = self.single_file, "generating module"); diff --git a/crates/sol-macro-gen/src/sol_macro_gen.rs b/crates/sol-macro-gen/src/sol_macro_gen.rs index 9b907eb3ad087..6ec534b965759 100644 --- a/crates/sol-macro-gen/src/sol_macro_gen.rs +++ b/crates/sol-macro-gen/src/sol_macro_gen.rs @@ -108,6 +108,7 @@ impl MultiSolMacroGen { bindings_path: &Path, single_file: bool, alloy_version: Option, + alloy_rev: Option, ) -> Result<()> { self.generate_bindings()?; @@ -127,13 +128,7 @@ edition = "2021" "# ); - let alloy_dep = if let Some(alloy_version) = alloy_version { - format!( - r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{alloy_version}", features = ["sol-types", "contract"] }}"# - ) - } else { - r#"alloy = { git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }"#.to_string() - }; + let alloy_dep = Self::get_alloy_dep(alloy_version, alloy_rev); write!(toml_contents, "{alloy_dep}")?; fs::write(cargo_toml_path, toml_contents).wrap_err("Failed to write Cargo.toml")?; @@ -235,9 +230,10 @@ edition = "2021" check_cargo_toml: bool, is_mod: bool, alloy_version: Option, + alloy_rev: Option, ) -> Result<()> { if check_cargo_toml { - self.check_cargo_toml(name, version, crate_path, alloy_version)?; + self.check_cargo_toml(name, version, crate_path, alloy_version, alloy_rev)?; } let mut super_contents = String::new(); @@ -304,6 +300,7 @@ edition = "2021" version: &str, crate_path: &Path, alloy_version: Option, + alloy_rev: Option, ) -> Result<()> { eyre::ensure!(crate_path.is_dir(), "Crate path must be a directory"); @@ -315,13 +312,7 @@ edition = "2021" let name_check = format!("name = \"{name}\""); let version_check = format!("version = \"{version}\""); - let alloy_dep_check = if let Some(version) = alloy_version { - format!( - r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{version}", features = ["sol-types", "contract"] }}"#, - ) - } else { - r#"alloy = { git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }"#.to_string() - }; + let alloy_dep_check = Self::get_alloy_dep(alloy_version, alloy_rev); let toml_consistent = cargo_toml_contents.contains(&name_check) && cargo_toml_contents.contains(&version_check) && cargo_toml_contents.contains(&alloy_dep_check); @@ -333,6 +324,23 @@ edition = "2021" Ok(()) } + + /// Returns the `alloy` dependency string for the Cargo.toml file. + /// If `alloy_version` is provided, it will use that version from crates.io. + /// If `alloy_rev` is provided, it will use that revision from the GitHub repository. + fn get_alloy_dep(alloy_version: Option, alloy_rev: Option) -> String { + if let Some(alloy_version) = alloy_version { + format!( + r#"alloy = {{ version = "{alloy_version}", features = ["sol-types", "contract"] }}"#, + ) + } else if let Some(alloy_rev) = alloy_rev { + format!( + r#"alloy = {{ git = "https://github.com/alloy-rs/alloy", rev = "{alloy_rev}", features = ["sol-types", "contract"] }}"#, + ) + } else { + r#"alloy = { git = "https://github.com/alloy-rs/alloy", features = ["sol-types", "contract"] }"#.to_string() + } + } } fn write_mod_name(contents: &mut String, name: &str) -> Result<()> { From e88e5631450e63b46b2d68cf8507974992756012 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 12 Feb 2025 11:38:18 +0200 Subject: [PATCH 1943/1963] feat(forge): add option to suppress successful tests traces (#9865) --- crates/forge/bin/cmd/test/mod.rs | 10 ++- crates/forge/tests/cli/test_cmd.rs | 138 +++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index f4761dde1ccb6..709908d6698fd 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -130,6 +130,10 @@ pub struct TestArgs { #[arg(long, env = "FORGE_ALLOW_FAILURE")] allow_failure: bool, + /// Suppress successful test traces and show only traces for failures. + #[arg(long, short, env = "FORGE_SUPPRESS_SUCCESSFUL_TRACES", help_heading = "Display options")] + suppress_successful_traces: bool, + /// Output test results as JUnit XML report. #[arg(long, conflicts_with_all = ["quiet", "json", "gas_report", "summary", "list", "show_progress"], help_heading = "Display options")] pub junit: bool, @@ -572,6 +576,8 @@ impl TestArgs { // Process individual test results, printing logs and traces when necessary. for (name, result) in tests { + let show_traces = + !self.suppress_successful_traces || result.status == TestStatus::Failure; if !silent { sh_println!("{}", result.short_result(name))?; @@ -583,7 +589,7 @@ impl TestArgs { } // We only display logs at level 2 and above - if verbosity >= 2 { + if verbosity >= 2 && show_traces { // We only decode logs from Hardhat and DS-style console events let console_logs = decode_console_logs(&result.logs); if !console_logs.is_empty() { @@ -634,7 +640,7 @@ impl TestArgs { } } - if !silent && !decoded_traces.is_empty() { + if !silent && show_traces && !decoded_traces.is_empty() { sh_println!("Traces:")?; for trace in &decoded_traces { sh_println!("{trace}")?; diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 7a366f1cc2010..4ec137a859376 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -2998,3 +2998,141 @@ forgetest_init!(colored_traces, |prj, cmd| { .assert_success() .stdout_eq(file!["../fixtures/colored_traces.svg": TermSvg]); }); + +// Tests that traces for successful tests can be suppressed by using `-s` flag. +// +forgetest_init!(should_only_show_failed_tests_trace, |prj, cmd| { + prj.add_test( + "SuppressTracesTest.t.sol", + r#" +import "forge-std/Test.sol"; +import {Counter} from "../src/Counter.sol"; + +contract SuppressTracesTest is Test { + Counter public counter; + + function setUp() public { + counter = new Counter(); + counter.setNumber(0); + } + + function test_increment_success() public { + console.log("test increment success"); + counter.increment(); + assertEq(counter.number(), 1); + } + + function test_increment_failure() public { + console.log("test increment failure"); + counter.increment(); + assertEq(counter.number(), 100); + } +} + "#, + ) + .unwrap(); + + // Show traces and logs for failed test only. + cmd.args(["test", "--mc", "SuppressTracesTest", "-vvvv", "-s"]).assert_failure().stdout_eq( + str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 2 tests for test/SuppressTracesTest.t.sol:SuppressTracesTest +[FAIL: assertion failed: 1 != 100] test_increment_failure() ([GAS]) +Logs: + test increment failure + +Traces: + [137242] SuppressTracesTest::setUp() + ├─ [96345] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 481 bytes of code + ├─ [2592] Counter::setNumber(0) + │ └─ ← [Stop] + └─ ← [Stop] + + [35178] SuppressTracesTest::test_increment_failure() + ├─ [0] console::log("test increment failure") [staticcall] + │ └─ ← [Stop] + ├─ [22418] Counter::increment() + │ └─ ← [Stop] + ├─ [424] Counter::number() [staticcall] + │ └─ ← [Return] 1 + ├─ [0] VM::assertEq(1, 100) [staticcall] + │ └─ ← [Revert] assertion failed: 1 != 100 + └─ ← [Revert] assertion failed: 1 != 100 + +[PASS] test_increment_success() ([GAS]) +Suite result: FAILED. 1 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 1 failed, 0 skipped (2 total tests) + +Failing tests: +Encountered 1 failing test in test/SuppressTracesTest.t.sol:SuppressTracesTest +[FAIL: assertion failed: 1 != 100] test_increment_failure() ([GAS]) + +Encountered a total of 1 failing tests, 1 tests succeeded + +"#]], + ); + + // Show traces and logs for all tests. + cmd.forge_fuse() + .args(["test", "--mc", "SuppressTracesTest", "-vvvv"]) + .assert_failure() + .stdout_eq(str![[r#" +No files changed, compilation skipped + +Ran 2 tests for test/SuppressTracesTest.t.sol:SuppressTracesTest +[FAIL: assertion failed: 1 != 100] test_increment_failure() ([GAS]) +Logs: + test increment failure + +Traces: + [137242] SuppressTracesTest::setUp() + ├─ [96345] → new Counter@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f + │ └─ ← [Return] 481 bytes of code + ├─ [2592] Counter::setNumber(0) + │ └─ ← [Stop] + └─ ← [Stop] + + [35178] SuppressTracesTest::test_increment_failure() + ├─ [0] console::log("test increment failure") [staticcall] + │ └─ ← [Stop] + ├─ [22418] Counter::increment() + │ └─ ← [Stop] + ├─ [424] Counter::number() [staticcall] + │ └─ ← [Return] 1 + ├─ [0] VM::assertEq(1, 100) [staticcall] + │ └─ ← [Revert] assertion failed: 1 != 100 + └─ ← [Revert] assertion failed: 1 != 100 + +[PASS] test_increment_success() ([GAS]) +Logs: + test increment success + +Traces: + [35229] SuppressTracesTest::test_increment_success() + ├─ [0] console::log("test increment success") [staticcall] + │ └─ ← [Stop] + ├─ [22418] Counter::increment() + │ └─ ← [Stop] + ├─ [424] Counter::number() [staticcall] + │ └─ ← [Return] 1 + ├─ [0] VM::assertEq(1, 1) [staticcall] + │ └─ ← [Return] + └─ ← [Stop] + +Suite result: FAILED. 1 passed; 1 failed; 0 skipped; [ELAPSED] + +Ran 1 test suite [ELAPSED]: 1 tests passed, 1 failed, 0 skipped (2 total tests) + +Failing tests: +Encountered 1 failing test in test/SuppressTracesTest.t.sol:SuppressTracesTest +[FAIL: assertion failed: 1 != 100] test_increment_failure() ([GAS]) + +Encountered a total of 1 failing tests, 1 tests succeeded + +"#]]); +}); From 04937cd0631b210a7632e4c427b301303529efd2 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:05:37 +0530 Subject: [PATCH 1944/1963] chore(deps): bump alloy to `0.11.1` (#9866) --- Cargo.lock | 93 ++++++++++++++++++++++++++++-------------------------- Cargo.toml | 46 +++++++++++++-------------- 2 files changed, 72 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d51784632237..fe7f225d435b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce20c85f6b24a5da40b2350a748e348417f0465dedbb523a4d149143bc4a41ce" +checksum = "69e32ef5c74bbeb1733c37f4ac7f866f8c8af208b7b4265e21af609dcac5bd5e" dependencies = [ "alloy-eips", "alloy-primitives", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71c7a59f261333db00fa10a3de9480f31121bb919ad38487040d7833d5982203" +checksum = "ee6180fb232becdea70fad57c63b6967f01f74ab9595671b870f504116dd29de" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -200,9 +200,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7149e011edbd588f6df6564b369c75f6b538d76db14053d95e0b43b2d92e4266" +checksum = "5591581ca2ab0b3e7226a4047f9a1bfcf431da1d0cce3752fda609fea3c27e37" dependencies = [ "alloy-eip2124", "alloy-eip2930", @@ -220,9 +220,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acaec0cc4c1489d61d6f33d0c3dd522c750025f4b5c8f59cd546221e4df660e5" +checksum = "0cded3a2d4bd7173f696458c5d4c98c18a628dfcc9f194385e80a486e412e2e0" dependencies = [ "alloy-eips", "alloy-primitives", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c5c9651fd20a2fd4a57606b6a570d1c17ab86e686b962b2f1ecac68b51e020" +checksum = "762414662d793d7aaa36ee3af6928b6be23227df1681ce9c039f6f11daadef64" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -259,9 +259,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b02ed56783fb2c086a4ac8961175dd6d3ad163e6cf6125f0b83f7de03379b607" +checksum = "8be03f2ebc00cf88bd06d3c6caf387dceaa9c7e6b268216779fa68a9bf8ab4e6" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -297,12 +297,15 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96f1a87e3b2842d6a35bbebedf2bd48a49ee757ec63d0cfc1f3cb86338e972c" +checksum = "81a3906afb50446392eb798dae4b918ba4ffcca47542efda7215776ddc8b5037" dependencies = [ "alloy-genesis", + "alloy-network", "alloy-primitives", + "alloy-signer", + "alloy-signer-local", "k256", "rand", "serde_json", @@ -345,9 +348,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c68df5354225da542efeb6d9388b65773b3304309b437416146e9d1e2bc1bd" +checksum = "cbe0a2acff0c4bd1669c71251ce10fc455cbffa1b4d0a817d5ea4ba7e5bb3db7" dependencies = [ "alloy-chains", "alloy-consensus", @@ -362,6 +365,7 @@ dependencies = [ "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-rpc-types-txpool", + "alloy-sol-types", "alloy-transport", "alloy-transport-http", "alloy-transport-ipc", @@ -387,9 +391,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef6ef167ea24e7aac569dfd90b668c1f7dca0e48214e70364586d5341a89431" +checksum = "de3a68996f193f542f9e29c88dfa8ed1369d6ee04fa764c1bf23dc11b2f9e4a2" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -428,9 +432,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0371aae9b44a35e374c94c7e1df5cbccf0f52b2ef7c782291ed56e86d88ec106" +checksum = "b37cc3c7883dc41be1b01460127ad7930466d0a4bb6ba15a02ee34d2745e2d7c" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -454,9 +458,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1428d64569961b00373c503a3de306656e94ef1f2a474e93fd41a6daae0d6ac7" +checksum = "6f18e68a3882f372e045ddc89eb455469347767d17878ca492cfbac81e71a111" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", @@ -567,9 +571,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86aa42c36e3c0db5bd9a7314e98aa261a61d5e3d6a0bd7e51fb8b0a3d6438481" +checksum = "8732058f5ca28c1d53d241e8504620b997ef670315d7c8afab856b3e3b80d945" dependencies = [ "alloy-primitives", "serde", @@ -578,15 +582,16 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c613222abd016e03ba548f41db938a2c99108b59c0c66ca105eab1b7a2e6b40a" +checksum = "f96b3526fdd779a4bd0f37319cfb4172db52a7ac24cdbb8804b72091c18e1701" dependencies = [ "alloy-dyn-abi", "alloy-primitives", "alloy-sol-types", "async-trait", "auto_impl", + "either", "elliptic-curve", "k256", "thiserror 2.0.11", @@ -594,9 +599,9 @@ dependencies = [ [[package]] name = "alloy-signer-aws" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729df0003039c90f66f52a67b3dda8dbdcb6439585eeb72f0e0019950329a6ed" +checksum = "f6f7fae8dec636317c89e08498675c9421a214f1791a59dcaea2094c1a2dbf07" dependencies = [ "alloy-consensus", "alloy-network", @@ -612,9 +617,9 @@ dependencies = [ [[package]] name = "alloy-signer-gcp" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39653f75284f17300bc8bbe74925db0adf59850f6c674c2db0ed6fd3b7a23ee0" +checksum = "d7fcc881fb827d16c1379d375e7f5f26159039fb6956b9f1408989be6bf91444" dependencies = [ "alloy-consensus", "alloy-network", @@ -630,9 +635,9 @@ dependencies = [ [[package]] name = "alloy-signer-ledger" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "107758cf1e537461551b56260253338999bc1474e92fb765f6f7c8a57d968ae4" +checksum = "327a0cfa3d68a60862aeaa42fbdfb5cc7d66275a79e01a3f9cfe38d293b6215a" dependencies = [ "alloy-consensus", "alloy-dyn-abi", @@ -650,9 +655,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39163b956c81e8fd9605194d6b5b92dd93b0e0252810e69f9a4cebe3a8614f46" +checksum = "fe8f78cd6b7501c7e813a1eb4a087b72d23af51f5bb66d4e948dc840bdd207d8" dependencies = [ "alloy-consensus", "alloy-network", @@ -669,9 +674,9 @@ dependencies = [ [[package]] name = "alloy-signer-trezor" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2131526594806a231502c0c57ddca0b63cfc9384c677c2a8cf01b49b335b546a" +checksum = "0bc3cf38010eeadfe37b34b58d0a53e36f3289dca68d16cbfaa62018e610b2ad" dependencies = [ "alloy-consensus", "alloy-network", @@ -759,9 +764,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40e2f34fcd849676c8fe274a6e72f0664dfede7ce06d12daa728d2e72f1b4393" +checksum = "5a8d762eadce3e9b65eac09879430c6f4fce3736cac3cac123f9b1bf435ddd13" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -778,9 +783,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e291c97c3c0ebb5d03c34e3a55c0f7c5bfa307536a2efaaa6fae4b3a4d09851" +checksum = "20819c4cb978fb39ce6ac31991ba90f386d595f922f42ef888b4a18be190713e" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -793,9 +798,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3e991f40d2d81c6ee036a34d81127bfec5fadf7e649791b5225181126c1959" +checksum = "5e88304aa8b796204e5e2500dfe235933ed692745e3effd94c3733643db6d218" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -814,9 +819,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc8c544f7dc764735664756805f8b8b770020cc295a0b96b09cbefd099c172c7" +checksum = "b9653ea9aa06d0e02fcbe2f04f1c47f35a85c378ccefa98e54ae85210bc8bbfa" dependencies = [ "alloy-pubsub", "alloy-transport", diff --git a/Cargo.toml b/Cargo.toml index 9d14ed5925e3c..0ad21d6c143ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -198,29 +198,29 @@ revm-primitives = { version = "15.1.0", default-features = false } revm-inspectors = { version = "0.15.0", features = ["serde"] } ## alloy -alloy-consensus = { version = "0.11.0", default-features = false } -alloy-contract = { version = "0.11.0", default-features = false } -alloy-eips = { version = "0.11.0", default-features = false } -alloy-genesis = { version = "0.11.0", default-features = false } -alloy-json-rpc = { version = "0.11.0", default-features = false } -alloy-network = { version = "0.11.0", default-features = false } -alloy-provider = { version = "0.11.0", default-features = false } -alloy-pubsub = { version = "0.11.0", default-features = false } -alloy-rpc-client = { version = "0.11.0", default-features = false } -alloy-rpc-types = { version = "0.11.0", default-features = true } -alloy-serde = { version = "0.11.0", default-features = false } -alloy-signer = { version = "0.11.0", default-features = false } -alloy-signer-aws = { version = "0.11.0", default-features = false } -alloy-signer-gcp = { version = "0.11.0", default-features = false } -alloy-signer-ledger = { version = "0.11.0", default-features = false } -alloy-signer-local = { version = "0.11.0", default-features = false } -alloy-signer-trezor = { version = "0.11.0", default-features = false } -alloy-transport = { version = "0.11.0", default-features = false } -alloy-transport-http = { version = "0.11.0", default-features = false } -alloy-transport-ipc = { version = "0.11.0", default-features = false } -alloy-transport-ws = { version = "0.11.0", default-features = false } -alloy-node-bindings = { version = "0.11.0", default-features = false } -alloy-network-primitives = { version = "0.11.0", default-features = false } +alloy-consensus = { version = "0.11.1", default-features = false } +alloy-contract = { version = "0.11.1", default-features = false } +alloy-eips = { version = "0.11.1", default-features = false } +alloy-genesis = { version = "0.11.1", default-features = false } +alloy-json-rpc = { version = "0.11.1", default-features = false } +alloy-network = { version = "0.11.1", default-features = false } +alloy-provider = { version = "0.11.1", default-features = false } +alloy-pubsub = { version = "0.11.1", default-features = false } +alloy-rpc-client = { version = "0.11.1", default-features = false } +alloy-rpc-types = { version = "0.11.1", default-features = true } +alloy-serde = { version = "0.11.1", default-features = false } +alloy-signer = { version = "0.11.1", default-features = false } +alloy-signer-aws = { version = "0.11.1", default-features = false } +alloy-signer-gcp = { version = "0.11.1", default-features = false } +alloy-signer-ledger = { version = "0.11.1", default-features = false } +alloy-signer-local = { version = "0.11.1", default-features = false } +alloy-signer-trezor = { version = "0.11.1", default-features = false } +alloy-transport = { version = "0.11.1", default-features = false } +alloy-transport-http = { version = "0.11.1", default-features = false } +alloy-transport-ipc = { version = "0.11.1", default-features = false } +alloy-transport-ws = { version = "0.11.1", default-features = false } +alloy-node-bindings = { version = "0.11.1", default-features = false } +alloy-network-primitives = { version = "0.11.1", default-features = false } ## alloy-core alloy-dyn-abi = "0.8.18" From 330c9b9678b484f4ce8c9a2cc938857f18ba427b Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:48:06 +0100 Subject: [PATCH 1945/1963] chore: fix release flow (#9869) fix release flow --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 468fdad6893ac..9d2411fd7b098 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,7 +99,7 @@ jobs: svm_target_platform: linux-aarch64 platform: linux arch: arm64 - - runner: macos-12-large + - runner: macos-latest-large target: x86_64-apple-darwin svm_target_platform: macosx-amd64 platform: darwin @@ -278,7 +278,7 @@ jobs: issue: name: Open an issue runs-on: ubuntu-latest - needs: [prepare, release-docker, release, cleanup] + needs: [ prepare, release-docker, release, cleanup ] if: failure() steps: - uses: actions/checkout@v4 From c0664e8873c869b656cc66f6c97856ab06bc5838 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Wed, 12 Feb 2025 14:27:06 +0100 Subject: [PATCH 1946/1963] fix: pin to `macos-13-large` for release flow to support old SDK versions (#9870) --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d2411fd7b098..793502fd2ea90 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,7 +99,9 @@ jobs: svm_target_platform: linux-aarch64 platform: linux arch: arm64 - - runner: macos-latest-large + # This is pinned to `macos-13-large` to support old SDK versions. + # If the runner is deprecated it should be pinned to the oldest available version of the runner. + - runner: macos-13-large target: x86_64-apple-darwin svm_target_platform: macosx-amd64 platform: darwin From d158b9ce486022c8a9dcc4d6a61276bdb984f701 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Wed, 12 Feb 2025 18:25:20 +0200 Subject: [PATCH 1947/1963] fix release: Pin tonistiigi/binfmt iamge (#9872) Pin tonistiigi/binfmt iamge --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 78658fad0cc26..15c7798a2cefb 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ docker-build-push: docker-build-prepare ## Build and push a cross-arch Docker im .PHONY: docker-build-prepare docker-build-prepare: ## Prepare the Docker build environment. - docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64 + docker run --privileged --rm tonistiigi/binfmt:qemu-v7.0.0-28 --install amd64,arm64 @if ! docker buildx inspect cross-builder &> /dev/null; then \ echo "Creating a new buildx builder instance"; \ docker buildx create --use --driver docker-container --name cross-builder; \ From aece6f42e5787fde39356b1fdee8879ff0dc3881 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Thu, 13 Feb 2025 07:43:31 +0200 Subject: [PATCH 1948/1963] chore: fix isolate tests (#9877) --- crates/forge/tests/cli/test_cmd.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index 4ec137a859376..d3a7eb9179be3 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -3001,6 +3001,7 @@ forgetest_init!(colored_traces, |prj, cmd| { // Tests that traces for successful tests can be suppressed by using `-s` flag. // +#[cfg(not(feature = "isolate-by-default"))] forgetest_init!(should_only_show_failed_tests_trace, |prj, cmd| { prj.add_test( "SuppressTracesTest.t.sol", From e5ec47b88208fdc48575359e0a5c44f85570ef63 Mon Sep 17 00:00:00 2001 From: James Kim Date: Thu, 13 Feb 2025 12:50:17 -0800 Subject: [PATCH 1949/1963] fix(anvil): return nonce and signature for deposit tx type (#9883) * return nonce and signature for deposit tx type * fix clippy --- crates/anvil/src/eth/backend/mem/mod.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index ce5c960c5e2dc..f6cb5e993ef16 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -2866,7 +2866,7 @@ pub fn transaction_build( ) -> AnyRpcTransaction { if let TypedTransaction::Deposit(ref deposit_tx) = eth_transaction.transaction { let DepositTransaction { - nonce: _, + nonce, source_hash, from, kind, @@ -2892,7 +2892,17 @@ pub fn transaction_build( let maybe_deposit_fields = OtherFields::try_from(ser); match maybe_deposit_fields { - Ok(fields) => { + Ok(mut fields) => { + // Add zeroed signature fields for backwards compatibility + // https://specs.optimism.io/protocol/deposits.html#the-deposited-transaction-type + fields.insert("v".to_string(), serde_json::to_value("0x0").unwrap()); + fields.insert("r".to_string(), serde_json::to_value(B256::ZERO).unwrap()); + fields.insert(String::from("s"), serde_json::to_value(B256::ZERO).unwrap()); + fields.insert( + String::from("nonce"), + serde_json::to_value(format!("0x{nonce}")).unwrap(), + ); + let inner = UnknownTypedTransaction { ty: AnyTxType(DEPOSIT_TX_TYPE_ID), fields, From 6b3cf56e38fada3e468f6018b456be94d5c032e6 Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Fri, 14 Feb 2025 17:06:43 +0530 Subject: [PATCH 1950/1963] feat(`forge`): don't commit installations by default (#9884) * feat(`forge`)!: flip `no_commit` to `commit` + don't commit installations by default * fix tests + always commit when initialized via template * fix * nit --- Cargo.lock | 297 ++++++++++++++++--------------- crates/cast/tests/cli/main.rs | 2 +- crates/cli/src/utils/mod.rs | 2 +- crates/forge/bin/cmd/clone.rs | 2 +- crates/forge/bin/cmd/init.rs | 32 ++-- crates/forge/bin/cmd/install.rs | 31 ++-- crates/forge/tests/cli/cmd.rs | 28 ++- crates/forge/tests/cli/config.rs | 23 +-- 8 files changed, 212 insertions(+), 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe7f225d435b4..96322731759cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-chains" -version = "0.1.59" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d37bc62b68c056e3742265ab73c73d413d07357909e0e4ea1e95453066a7469" +checksum = "3a754dbb534198644cb8355b8c23f4aaecf03670fb9409242be1fa1e25897ee9" dependencies = [ "alloy-primitives", "num_enum", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e23af02ccded0031ef2b70df4fe9965b1c742c5d5384c8c767ae0311f7e62b9" +checksum = "0fa13b7b1e1e3fedc42f0728103bfa3b4d566d3d42b606db449504d88dbdbdcf" dependencies = [ "alloy-consensus", "alloy-eips", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2d547eba3f2d331b0e08f64a24e202f66d4f291e2a3e0073914c0e1400ced3" +checksum = "555896f0b8578adb522b1453b6e6cc6704c3027bd0af20058befdde992cee8e9" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -155,7 +155,7 @@ dependencies = [ "proptest", "serde", "serde_json", - "winnow 0.7.1", + "winnow 0.7.2", ] [[package]] @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d62cf1b25f5a50ca2d329b0b4aeb0a0dedeaf225ad3c5099d83b1a4c4616186e" +checksum = "4012581681b186ba0882007ed873987cc37f86b1b488fe6b91d5efd0b585dc41" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -284,9 +284,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0624cfa9311aa8283cd3bf5eed883d0d1e823e2a4d57b30e1b49af4b3678a6b" +checksum = "3a00ce618ae2f78369918be0c20f620336381502c83b6ed62c2f7b2db27698b0" dependencies = [ "alloy-consensus", "alloy-eips", @@ -317,9 +317,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc1360603efdfba91151e623f13a4f4d3dc4af4adc1cbd90bf37c81e84db4c77" +checksum = "478bedf4d24e71ea48428d1bc278553bd7c6ae07c30ca063beb0b09fe58a9e74" dependencies = [ "alloy-rlp", "arbitrary", @@ -474,9 +474,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d721727cc493a58bd197a3ebbd42b88c0393c1f30da905bb7a31686c820f4c2d" +checksum = "10d06300df4a87d960add35909240fc72da355dd2ac926fa6999f9efafbdc5a7" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -486,9 +486,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66e119337400d8b0348e1576ab37ffa56d1a04cbc977a84d4fa0a527d7cb0c21" +checksum = "318ae46dd12456df42527c3b94c1ae9001e1ceb707f7afe2c7807ac4e49ebad9" dependencies = [ "alloy-consensus-any", "alloy-rpc-types-eth", @@ -497,9 +497,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea98e1c4ac005ffe5f8691164f5f2ef5ee8dda50b1fdba173d44892141909e2" +checksum = "2834b7012054cb2f90ee9893b7cc97702edca340ec1ef386c30c42e55e6cd691" dependencies = [ "alloy-primitives", "serde", @@ -507,9 +507,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b582c59b6f493d9b15bea32f44f662fa6749e5464ef5305d8429a864ace60684" +checksum = "e83dde9fcf1ccb9b815cc0c89bba26bbbbaae5150a53ae624ed0fc63cb3676c1" dependencies = [ "alloy-consensus", "alloy-eips", @@ -525,9 +525,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a4a43d8b1344e3ef115ed7a2cee934876e4a64d2b9d9bee8738f9806900757e" +checksum = "8b4dbee4d82f8a22dde18c28257bed759afeae7ba73da4a1479a039fd1445d04" dependencies = [ "alloy-consensus", "alloy-consensus-any", @@ -545,9 +545,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac383c60b09660b7695a4f210cd11ab05887d058dfc669efd814904dbbaead82" +checksum = "7bd951155515fa452a2ca4b5434d4b3ab742bcd3d1d1b9a91704bcef5b8d2604" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -559,9 +559,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac39b1a583bb59dcf7d856604867acf704a7cf70b76a42f895652d566aa6f17c" +checksum = "21d8dd5bd94993eda3d56a8c4c0d693548183a35462523ffc4385c0b020d3b0c" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -691,9 +691,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13f28f2131dc3a7b8e2cda882758ad4d5231ca26281b9861d4b18c700713e2da" +checksum = "a2708e27f58d747423ae21d31b7a6625159bd8d867470ddd0256f396a68efa11" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -705,9 +705,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee2da033256a3b27131c030933eab0460a709fbcc4d4bd57bf9a5650b2441c5" +checksum = "c6b7984d7e085dec382d2c5ef022b533fcdb1fe6129200af30ebf5afddb6a361" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -724,9 +724,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9d9918b0abb632818bf27e2dfb86b209be8433baacf22100b190bbc0904bd4" +checksum = "33d6a9fc4ed1a3c70bdb2357bec3924551c1a59f24e5a04a74472c755b37f87d" dependencies = [ "alloy-json-abi", "const-hex", @@ -741,19 +741,19 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a971129d242338d92009470a2f750d3b2630bc5da00a40a94d51f5d456b5712f" +checksum = "1b1b3e9a48a6dd7bb052a111c8d93b5afc7956ed5e2cb4177793dc63bb1d2a36" dependencies = [ "serde", - "winnow 0.7.1", + "winnow 0.7.2", ] [[package]] name = "alloy-sol-types" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f306fc801b3aa2e3c4785b7b5252ec8b19f77b30e3b75babfd23849c81bd8c" +checksum = "6044800da35c38118fd4b98e18306bd3b91af5dedeb54c1b768cf1b4fb68f549" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -827,7 +827,7 @@ dependencies = [ "alloy-transport", "futures", "http 1.2.0", - "rustls 0.23.22", + "rustls 0.23.23", "serde_json", "tokio", "tokio-tungstenite 0.26.1", @@ -1445,9 +1445,9 @@ dependencies = [ [[package]] name = "aws-sdk-kms" -version = "1.59.0" +version = "1.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da21a543bfc06001637785ec6ed7b4bec9a3d737f0abca3ddd8d7b962e71fb1" +checksum = "adc36035f7393a24719069c9a2f52e20972f7ee8472bd788e863968736acc449" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1467,9 +1467,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.58.0" +version = "1.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ff718c9ee45cc1ebd4774a0e086bb80a6ab752b4902edf1c9f56b86ee1f770" +checksum = "00a35fc7e74f5be45839eb753568535c074a592185dd0a2d406685018d581c43" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1489,9 +1489,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.59.0" +version = "1.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5183e088715cc135d8d396fdd3bc02f018f0da4c511f53cb8d795b6a31c55809" +checksum = "f8fa655b4f313124ce272cbc38c5fef13793c832279cec750103e5e6b71a54b8" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1511,9 +1511,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.59.0" +version = "1.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9f944ef032717596639cea4a2118a3a457268ef51bbb5fde9637e54c465da00" +checksum = "dc1cfe5e16b90421ea031f4c6348b534ef442e76f6bf4a1b2b592c12cc2c6af9" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1534,9 +1534,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.8" +version = "1.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bc5bbd1e4a2648fd8c5982af03935972c24a2f9846b396de661d351ee3ce837" +checksum = "9bfe75fad52793ce6dec0dc3d4b1f388f038b5eb866c8d4d7f3a8e21b5ea5051" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -1869,9 +1869,9 @@ dependencies = [ [[package]] name = "blst" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874" +checksum = "47c79a94619fade3c0b887670333513a67ac28a6a7e653eb260bf0d4103db38d" dependencies = [ "cc", "glob", @@ -1986,9 +1986,9 @@ dependencies = [ [[package]] name = "bzip2-sys" -version = "0.1.11+1.0.8" +version = "0.1.12+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +checksum = "72ebc2f1a417f01e1da30ef264ee86ae31d2dcd2d603ea283d3c244a883ca2a9" dependencies = [ "cc", "libc", @@ -2192,9 +2192,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.28" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" +checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" dependencies = [ "clap_builder", "clap_derive", @@ -2202,9 +2202,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.27" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" dependencies = [ "anstream", "anstyle", @@ -2722,9 +2722,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" +checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" [[package]] name = "dbus" @@ -3211,6 +3211,9 @@ name = "faster-hex" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" +dependencies = [ + "serde", +] [[package]] name = "fastrand" @@ -3324,7 +3327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.3", + "miniz_oxide 0.8.4", ] [[package]] @@ -3811,7 +3814,7 @@ dependencies = [ "thiserror 2.0.11", "tokio", "tracing", - "winnow 0.7.1", + "winnow 0.7.2", "yansi", ] @@ -4406,23 +4409,23 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gix-actor" -version = "0.32.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc19e312cd45c4a66cd003f909163dc2f8e1623e30a0c0c6df3776e89b308665" +checksum = "20018a1a6332e065f1fcc8305c1c932c6b8c9985edea2284b3c79dc6fa3ee4b2" dependencies = [ "bstr", "gix-date", "gix-utils", "itoa", - "thiserror 1.0.69", + "thiserror 2.0.11", "winnow 0.6.26", ] [[package]] name = "gix-config" -version = "0.40.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78e797487e6ca3552491de1131b4f72202f282fb33f198b1c34406d765b42bb0" +checksum = "6649b406ca1f99cb148959cf00468b231f07950f8ec438cc0903cda563606f19" dependencies = [ "bstr", "gix-config-value", @@ -4434,7 +4437,7 @@ dependencies = [ "memchr", "once_cell", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.11", "unicode-bom", "winnow 0.6.26", ] @@ -4466,9 +4469,9 @@ dependencies = [ [[package]] name = "gix-features" -version = "0.38.2" +version = "0.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac7045ac9fe5f9c727f38799d002a7ed3583cd777e3322a7c4b43e3cf437dc69" +checksum = "7d85d673f2e022a340dba4713bed77ef2cf4cd737d2f3e0f159d45e0935fd81f" dependencies = [ "gix-hash", "gix-trace", @@ -4481,9 +4484,9 @@ dependencies = [ [[package]] name = "gix-fs" -version = "0.11.3" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2bfe6249cfea6d0c0e0990d5226a4cb36f030444ba9e35e0639275db8f98575" +checksum = "3b3d4fac505a621f97e5ce2c69fdc425742af00c0920363ca4074f0eb48b1db9" dependencies = [ "fastrand", "gix-features", @@ -4492,9 +4495,9 @@ dependencies = [ [[package]] name = "gix-glob" -version = "0.16.5" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74908b4bbc0a0a40852737e5d7889f676f081e340d5451a16e5b4c50d592f111" +checksum = "aaf69a6bec0a3581567484bf99a4003afcaf6c469fd4214352517ea355cf3435" dependencies = [ "bitflags 2.8.0", "bstr", @@ -4504,41 +4507,54 @@ dependencies = [ [[package]] name = "gix-hash" -version = "0.14.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" +checksum = "0b5eccc17194ed0e67d49285e4853307e4147e95407f91c1c3e4a13ba9f4e4ce" dependencies = [ "faster-hex", - "thiserror 1.0.69", + "thiserror 2.0.11", +] + +[[package]] +name = "gix-hashtable" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef65b256631078ef733bc5530c4e6b1c2e7d5c2830b75d4e9034ab3997d18fe" +dependencies = [ + "gix-hash", + "hashbrown 0.14.5", + "parking_lot", ] [[package]] name = "gix-lock" -version = "14.0.0" +version = "15.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bc7fe297f1f4614774989c00ec8b1add59571dc9b024b4c00acb7dedd4e19d" +checksum = "1cd3ab68a452db63d9f3ebdacb10f30dba1fa0d31ac64f4203d395ed1102d940" dependencies = [ "gix-tempfile", "gix-utils", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] name = "gix-object" -version = "0.44.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5b801834f1de7640731820c2df6ba88d95480dc4ab166a5882f8ff12b88efa" +checksum = "e42d58010183ef033f31088479b4eb92b44fe341b35b62d39eb8b185573d77ea" dependencies = [ "bstr", "gix-actor", "gix-date", "gix-features", "gix-hash", + "gix-hashtable", + "gix-path", "gix-utils", "gix-validate", "itoa", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.11", "winnow 0.6.26", ] @@ -4557,9 +4573,9 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.47.0" +version = "0.49.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae0d8406ebf9aaa91f55a57f053c5a1ad1a39f60fdf0303142b7be7ea44311e5" +checksum = "a91b61776c839d0f1b7114901179afb0947aa7f4d30793ca1c56d335dfef485f" dependencies = [ "gix-actor", "gix-features", @@ -4572,7 +4588,7 @@ dependencies = [ "gix-utils", "gix-validate", "memmap2", - "thiserror 1.0.69", + "thiserror 2.0.11", "winnow 0.6.26", ] @@ -4590,9 +4606,9 @@ dependencies = [ [[package]] name = "gix-tempfile" -version = "14.0.2" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046b4927969fa816a150a0cda2e62c80016fe11fb3c3184e4dddf4e542f108aa" +checksum = "2feb86ef094cc77a4a9a5afbfe5de626897351bbbd0de3cb9314baf3049adb82" dependencies = [ "gix-fs", "libc", @@ -4707,9 +4723,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "6.3.0" +version = "6.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6b224b95c1e668ac0270325ad563b2eef1469fbbb8959bc7c692c844b813d9" +checksum = "d752747ddabc4c1a70dd28e72f2e3c218a816773e0d7faf67433f1acfa6cba7c" dependencies = [ "derive_builder", "log", @@ -4990,7 +5006,7 @@ dependencies = [ "http 1.2.0", "hyper 1.6.0", "hyper-util", - "rustls 0.23.22", + "rustls 0.23.23", "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", @@ -5217,9 +5233,9 @@ dependencies = [ [[package]] name = "ignore-files" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ce3a1903263527cf3b6512a12f338ae63f425b66c1a3d7a24c3121e8557dbe" +checksum = "0a20552979c32c84b0c7f6bb8d3e235627011e68eb9f6d59592f14a76b6b48ea" dependencies = [ "dunce", "futures", @@ -5229,7 +5245,7 @@ dependencies = [ "normalize-path", "project-origins", "radix_trie", - "thiserror 1.0.69", + "thiserror 2.0.11", "tokio", "tracing", ] @@ -5904,9 +5920,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" dependencies = [ "adler2", ] @@ -6250,9 +6266,9 @@ checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "op-alloy-consensus" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1363dd2454f473e2a2a6ee5eda585ecf94209319e35529bd703ddc5072798eb4" +checksum = "23f7ff02e5f3ba62c8dd5d9a630c818f50147bca7b0d78e89de59ed46b5d02e1" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6266,9 +6282,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77979abf2b8b2be8996da3b434b09d770edbcceccd59251c3373ef553e743cf0" +checksum = "9ed9af4583c4b3ea93f54092ebfe41172974de2042672e9850500f4d1f99844e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6842,15 +6858,19 @@ dependencies = [ [[package]] name = "prodash" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744a264d26b88a6a7e37cbad97953fa233b94d585236310bcbc88474b4092d79" +checksum = "a266d8d6020c61a437be704c5e618037588e1985c7dbb7bf8d265db84cffe325" +dependencies = [ + "log", + "parking_lot", +] [[package]] name = "project-origins" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "735c6b4b1c67863c2211cac24badb0dca9fabfe1098209834fc5e0f92eda6c2c" +checksum = "f1a0207163ace81dd9ff23a5225188a4eef8eb7de7b570f609407e521a8c9c2c" dependencies = [ "futures", "tokio", @@ -6890,9 +6910,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" dependencies = [ "bytes", "prost-derive", @@ -6900,12 +6920,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.14.0", "proc-macro2", "quote", "syn 2.0.98", @@ -6913,9 +6933,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" dependencies = [ "prost", ] @@ -7008,7 +7028,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.22", + "rustls 0.23.23", "socket2", "thiserror 2.0.11", "tokio", @@ -7026,7 +7046,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.22", + "rustls 0.23.23", "rustls-pki-types", "slab", "thiserror 2.0.11", @@ -7269,7 +7289,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.22", + "rustls 0.23.23", "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -7294,9 +7314,9 @@ dependencies = [ [[package]] name = "revm" -version = "19.4.0" +version = "19.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1538aea4d103a8044820eede9b1254e1b5a2a2abaf3f9a67bef19f8865cf1826" +checksum = "dfc5bef3c95fadf3b6a24a253600348380c169ef285f9780a793bb7090c8990d" dependencies = [ "auto_impl", "cfg-if", @@ -7328,9 +7348,9 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "15.1.0" +version = "15.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f632e761f171fb2f6ace8d1552a5793e0350578d4acec3e79ade1489f4c2a6" +checksum = "7dcab7ef2064057acfc84731205f4bc77f4ec1b35630800b26ff6a185731c5ab" dependencies = [ "revm-primitives", "serde", @@ -7338,9 +7358,9 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "16.0.0" +version = "16.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6542fb37650dfdbf4b9186769e49c4a8bc1901a3280b2ebf32f915b6c8850f36" +checksum = "6caa1a7ff2cc4a09a263fcf9de99151706f323d30f33d519ed329f017a02b046" dependencies = [ "aurora-engine-modexp", "blst", @@ -7358,9 +7378,9 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "15.1.0" +version = "15.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48faea1ecf2c9f80d9b043bbde0db9da616431faed84c4cfa3dd7393005598e6" +checksum = "f0f987564210317706def498421dfba2ae1af64a8edce82c6102758b48133fcb" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -7397,15 +7417,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24" dependencies = [ "cc", "cfg-if", "getrandom 0.2.15", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -7559,9 +7578,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.22" +version = "0.23.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9263ab4eb695e42321db096e3b8fbd715a59b154d5c88d82db2175b681ba7" +checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" dependencies = [ "log", "once_cell", @@ -8584,9 +8603,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f6a4b9002584ea56d0a19713b65da44cbbf6070aca9ae0360577cba5c4db68" +checksum = "9c2de690018098e367beeb793991c7d4dc7270f42c9d2ac4ccc876c1368ca430" dependencies = [ "paste", "proc-macro2", @@ -8886,7 +8905,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.22", + "rustls 0.23.23", "tokio", ] @@ -8934,7 +8953,7 @@ checksum = "be4bf6fecd69fcdede0ec680aaf474cdab988f9de6bc73d3758f0160e3b7025a" dependencies = [ "futures-util", "log", - "rustls 0.23.22", + "rustls 0.23.23", "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", @@ -8988,15 +9007,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.23" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap 2.7.1", "serde", "serde_spanned", "toml_datetime", - "winnow 0.7.1", + "winnow 0.7.2", ] [[package]] @@ -9278,7 +9297,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.23.22", + "rustls 0.23.23", "rustls-pki-types", "sha1", "thiserror 2.0.11", @@ -9696,13 +9715,13 @@ dependencies = [ [[package]] name = "watchexec-signals" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be07d7855a3617d996ce0c7df4b6232159c526634dff668dd95491c22a9a7262" +checksum = "8834ddd08f1ce18ea85e4ccbdafaea733851c7dc6afefd50037aea17845a861a" dependencies = [ "miette", "nix 0.29.0", - "thiserror 1.0.69", + "thiserror 2.0.11", ] [[package]] @@ -10168,9 +10187,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 3d19bf033be69..574488d445a45 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -818,7 +818,7 @@ type 2 blobGasPrice blobGasUsed to 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45 -revertReason Transaction too old, data: "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000135472616e73616374696f6e20746f6f206f6c6400000000000000000000000000" +revertReason [..]Transaction too old, data: "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000135472616e73616374696f6e20746f6f206f6c6400000000000000000000000000" "#]]); }); diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index ec1cba87586b5..42582e8de59d2 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -460,7 +460,7 @@ and it requires clean working and staging areas, including no untracked files. Check the current git repository's status with `git status`. Then, you can track files with `git add ...` and then commit them with `git commit`, -ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag." +ignore them in the `.gitignore` file." )) } } diff --git a/crates/forge/bin/cmd/clone.rs b/crates/forge/bin/cmd/clone.rs index 32861a78e4bde..481b68632e840 100644 --- a/crates/forge/bin/cmd/clone.rs +++ b/crates/forge/bin/cmd/clone.rs @@ -130,7 +130,7 @@ impl CloneArgs { Self::collect_compilation_metadata(&meta, chain, address, &root, &client).await?; // step 5. git add and commit the changes if needed - if !install.no_commit { + if install.commit { let git = Git::new(&root); git.add(Some("--all"))?; let msg = format!("chore: forge clone {address}"); diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 269af31c1a3fa..d0156ab750dee 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -44,7 +44,7 @@ pub struct InitArgs { impl InitArgs { pub fn run(self) -> Result<()> { let Self { root, template, branch, install, offline, force, vscode } = self; - let DependencyInstallOpts { shallow, no_git, no_commit } = install; + let DependencyInstallOpts { shallow, no_git, commit } = install; // create the root dir if it does not exist if !root.exists() { @@ -70,17 +70,15 @@ impl InitArgs { // collapsed. gitmodules will be initialized after the template is fetched git.fetch(true, &template, branch)?; - if !no_commit { - // reset git history to the head of the template - // first get the commit hash that was fetched - let commit_hash = git.commit_hash(true, "FETCH_HEAD")?; - // format a commit message for the new repo - let commit_msg = format!("chore: init from {template} at {commit_hash}"); - // get the hash of the FETCH_HEAD with the new commit message - let new_commit_hash = git.commit_tree("FETCH_HEAD^{tree}", Some(commit_msg))?; - // reset head of this repo to be the head of the template repo - git.reset(true, new_commit_hash)?; - } + // reset git history to the head of the template + // first get the commit hash that was fetched + let commit_hash = git.commit_hash(true, "FETCH_HEAD")?; + // format a commit message for the new repo + let commit_msg = format!("chore: init from {template} at {commit_hash}"); + // get the hash of the FETCH_HEAD with the new commit message + let new_commit_hash = git.commit_tree("FETCH_HEAD^{tree}", Some(commit_msg))?; + // reset head of this repo to be the head of the template repo + git.reset(true, new_commit_hash)?; // if shallow, just initialize submodules if shallow { @@ -102,7 +100,7 @@ impl InitArgs { } // ensure git status is clean before generating anything - if !no_git && !no_commit && !force && git.is_in_repo()? { + if !no_git && commit && !force && git.is_in_repo()? { git.ensure_clean()?; } @@ -141,7 +139,7 @@ impl InitArgs { // set up the repo if !no_git { - init_git_repo(git, no_commit)?; + init_git_repo(git, commit)?; } // install forge-std @@ -170,8 +168,8 @@ impl InitArgs { /// /// Creates `.gitignore` and `.github/workflows/test.yml`, if they don't exist already. /// -/// Commits everything in `root` if `no_commit` is false. -fn init_git_repo(git: Git<'_>, no_commit: bool) -> Result<()> { +/// Commits everything in `root` if `commit` is true. +fn init_git_repo(git: Git<'_>, commit: bool) -> Result<()> { // git init if !git.is_in_repo()? { git.init()?; @@ -191,7 +189,7 @@ fn init_git_repo(git: Git<'_>, no_commit: bool) -> Result<()> { } // commit everything - if !no_commit { + if commit { git.add(Some("--all"))?; git.commit("chore: forge init")?; } diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index ee1b3a4ab73a0..5390f1f0ce6a9 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -76,9 +76,9 @@ pub struct DependencyInstallOpts { #[arg(long)] pub no_git: bool, - /// Do not create a commit. + /// Create a commit after installing the dependencies. #[arg(long)] - pub no_commit: bool, + pub commit: bool, } impl DependencyInstallOpts { @@ -91,12 +91,11 @@ impl DependencyInstallOpts { /// See also [`Self::install`]. /// /// Returns true if any dependency was installed. - pub fn install_missing_dependencies(mut self, config: &mut Config) -> bool { + pub fn install_missing_dependencies(self, config: &mut Config) -> bool { let lib = config.install_lib_dir(); if self.git(config).has_missing_dependencies(Some(lib)).unwrap_or(false) { // The extra newline is needed, otherwise the compiler output will overwrite the message let _ = sh_println!("Missing dependencies found. Installing now...\n"); - self.no_commit = true; if self.install(config, Vec::new()).is_err() { let _ = sh_warn!("Your project has missing dependencies that could not be installed."); @@ -109,7 +108,7 @@ impl DependencyInstallOpts { /// Installs all dependencies pub fn install(self, config: &mut Config, dependencies: Vec) -> Result<()> { - let Self { no_git, no_commit, .. } = self; + let Self { no_git, commit, .. } = self; let git = self.git(config); @@ -138,7 +137,7 @@ impl DependencyInstallOpts { fs::create_dir_all(&libs)?; - let installer = Installer { git, no_commit }; + let installer = Installer { git, commit }; for dep in dependencies { let path = libs.join(dep.name()); let rel_path = path @@ -157,7 +156,7 @@ impl DependencyInstallOpts { if no_git { installed_tag = installer.install_as_folder(&dep, &path)?; } else { - if !no_commit { + if commit { git.ensure_clean()?; } installed_tag = installer.install_as_submodule(&dep, &path)?; @@ -173,14 +172,16 @@ impl DependencyInstallOpts { .exec()?; } - // update .gitmodules which is at the root of the repo, - // not necessarily at the root of the current Foundry project - let root = Git::root_of(git.root)?; - git.root(&root).add(Some(".gitmodules"))?; + if commit { + // update .gitmodules which is at the root of the repo, + // not necessarily at the root of the current Foundry project + let root = Git::root_of(git.root)?; + git.root(&root).add(Some(".gitmodules"))?; + } } // commit the installation - if !no_commit { + if commit { let mut msg = String::with_capacity(128); msg.push_str("forge install: "); msg.push_str(dep.name()); @@ -216,7 +217,7 @@ pub fn install_missing_dependencies(config: &mut Config) -> bool { #[derive(Clone, Copy, Debug)] struct Installer<'a> { git: Git<'a>, - no_commit: bool, + commit: bool, } impl Installer<'_> { @@ -275,7 +276,7 @@ impl Installer<'_> { std::iter::empty::(), )?; - if !self.no_commit { + if self.commit { self.git.add(Some(path))?; } @@ -522,7 +523,7 @@ mod tests { fn get_oz_tags() { let tmp = tempdir().unwrap(); let git = Git::new(tmp.path()); - let installer = Installer { git, no_commit: true }; + let installer = Installer { git, commit: false }; git.init().unwrap(); diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 67327b0dc0b56..4cefe790b3803 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -295,13 +295,13 @@ forgetest!(can_detect_dirty_git_status_on_init, |prj, cmd| { fs::create_dir_all(&nested).unwrap(); cmd.current_dir(&nested); - cmd.arg("init").assert_failure().stderr_eq(str![[r#" + cmd.args(["init", "--commit"]).assert_failure().stderr_eq(str![[r#" Error: The target directory is a part of or on its own an already initialized git repository, and it requires clean working and staging areas, including no untracked files. Check the current git repository's status with `git status`. Then, you can track files with `git add ...` and then commit them with `git commit`, -ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag. +ignore them in the `.gitignore` file. "#]]); @@ -584,10 +584,10 @@ Error: git fetch exited with code 128 "#]]); }); -// checks that `forge init --template [template] work with --no-commit +// checks that `forge init --template [template] works by default i.e without committing forgetest!(can_init_template_with_no_commit, |prj, cmd| { prj.wipe(); - cmd.args(["init", "--template", "foundry-rs/forge-template", "--no-commit"]) + cmd.args(["init", "--template", "foundry-rs/forge-template"]) .arg(prj.root()) .assert_success() .stdout_eq(str![[r#" @@ -1308,14 +1308,13 @@ forgetest!(can_install_and_remove, |prj, cmd| { let forge_std_mod = git_mod.join("forge-std"); let install = |cmd: &mut TestCommand| { - cmd.forge_fuse() - .args(["install", "foundry-rs/forge-std", "--no-commit"]) - .assert_success() - .stdout_eq(str![[r#" + cmd.forge_fuse().args(["install", "foundry-rs/forge-std"]).assert_success().stdout_eq( + str![[r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] -"#]]); +"#]], + ); assert!(forge_std.exists()); assert!(forge_std_mod.exists()); @@ -1376,14 +1375,13 @@ forgetest!(can_reinstall_after_manual_remove, |prj, cmd| { let forge_std_mod = git_mod.join("forge-std"); let install = |cmd: &mut TestCommand| { - cmd.forge_fuse() - .args(["install", "foundry-rs/forge-std", "--no-commit"]) - .assert_success() - .stdout_eq(str![[r#" + cmd.forge_fuse().args(["install", "foundry-rs/forge-std"]).assert_success().stdout_eq( + str![[r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] -"#]]); +"#]], + ); assert!(forge_std.exists()); assert!(forge_std_mod.exists()); @@ -1446,7 +1444,7 @@ forgetest!( // install main dependency cmd.forge_fuse() - .args(["install", "evalir/forge-5980-test", "--no-commit"]) + .args(["install", "evalir/forge-5980-test"]) .assert_success() .stdout_eq(str![[r#" Installing forge-5980-test in [..] (url: Some("https://github.com/evalir/forge-5980-test"), tag: None) diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index fc7252e0a6e83..7c153d10bbe4b 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -268,13 +268,11 @@ forgetest_init!(can_parse_remappings_correctly, |prj, cmd| { assert_eq!(expected, output); let install = |cmd: &mut TestCommand, dep: &str| { - cmd.forge_fuse().args(["install", dep, "--no-commit"]).assert_success().stdout_eq(str![[ - r#" + cmd.forge_fuse().args(["install", dep]).assert_success().stdout_eq(str![[r#" Installing solmate in [..] (url: Some("https://github.com/transmissions11/solmate"), tag: None) Installed solmate[..] -"# - ]]); +"#]]); }; install(&mut cmd, "transmissions11/solmate"); @@ -694,13 +692,11 @@ forgetest!(can_update_libs_section, |prj, cmd| { // explicitly set gas_price prj.update_config(|config| config.libs = vec!["node_modules".into()]); - cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]).assert_success().stdout_eq(str![ - [r#" + cmd.args(["install", "foundry-rs/forge-std"]).assert_success().stdout_eq(str![[r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] -"#] - ]); +"#]]); let config = cmd.forge_fuse().config(); // `lib` was added automatically @@ -708,10 +704,7 @@ Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std assert_eq!(config.libs, expected); // additional install don't edit `libs` - cmd.forge_fuse() - .args(["install", "dapphub/ds-test", "--no-commit"]) - .assert_success() - .stdout_eq(str![[r#" + cmd.forge_fuse().args(["install", "dapphub/ds-test"]).assert_success().stdout_eq(str![[r#" Installing ds-test in [..] (url: Some("https://github.com/dapphub/ds-test"), tag: None) Installed ds-test @@ -726,13 +719,11 @@ Installing ds-test in [..] (url: Some("https://github.com/dapphub/ds-test"), tag forgetest!(config_emit_warnings, |prj, cmd| { cmd.git_init(); - cmd.args(["install", "foundry-rs/forge-std", "--no-commit"]).assert_success().stdout_eq(str![ - [r#" + cmd.args(["install", "foundry-rs/forge-std"]).assert_success().stdout_eq(str![[r#" Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Installed forge-std[..] -"#] - ]); +"#]]); let faulty_toml = r"[default] src = 'src' From 24d18e2712733661bbe6eaf246baab6385db04d3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 14 Feb 2025 13:52:26 +0200 Subject: [PATCH 1951/1963] chore: fix flaky tests due to different totalDifficulty reported (#9889) --- crates/cast/tests/cli/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index 574488d445a45..a28cf27f3c66a 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -658,7 +658,7 @@ casttest!(rpc_with_args, |_prj, cmd| { // Call `cast rpc eth_getBlockByNumber 0x123 false` cmd.args(["rpc", "--rpc-url", eth_rpc_url.as_str(), "eth_getBlockByNumber", "0x123", "false"]) .assert_json_stdout(str![[r#" -{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} +{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"[..]","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} "#]]); }); @@ -677,7 +677,7 @@ casttest!(rpc_raw_params, |_prj, cmd| { r#"["0x123", false]"#, ]) .assert_json_stdout(str![[r#" -{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} +{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"[..]","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} "#]]); }); @@ -693,7 +693,7 @@ casttest!(rpc_raw_params_stdin, |_prj, cmd| { }, ) .assert_json_stdout(str![[r#" -{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"0x4dea420908b","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} +{"number":"0x123","hash":"0xc5dab4e189004a1312e9db43a40abb2de91ad7dd25e75880bf36016d8e9df524","transactions":[],"totalDifficulty":"[..]","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","nonce":"0x29d6547c196e00e0","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","difficulty":"0x494433b31","gasLimit":"0x1388","gasUsed":"0x0","uncles":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","stateRoot":"0x3fe6bd17aa85376c7d566df97d9f2e536f37f7a87abb3a6f9e2891cf9442f2e4","mixHash":"0x943056aa305aa6d22a3c06110942980342d1f4d4b11c17711961436a0f963ea0","parentHash":"0x7abfd11e862ccde76d6ea8ee20978aac26f4bcb55de1188cc0335be13e817017","timestamp":"0x55ba4564"} "#]]); }); From 91740aa82f7b43f142ccfec87148340f520ba153 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 14 Feb 2025 14:59:23 +0200 Subject: [PATCH 1952/1963] fix(inspect): add flag to strip ir comments (#9825) * fix(inspect): do not strip comments when yul print * Update crates/forge/bin/cmd/inspect.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- crates/forge/bin/cmd/inspect.rs | 20 +++++++++----- crates/forge/tests/cli/cmd.rs | 46 ++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/crates/forge/bin/cmd/inspect.rs b/crates/forge/bin/cmd/inspect.rs index 8474b396cf38b..fe8ba67a7d509 100644 --- a/crates/forge/bin/cmd/inspect.rs +++ b/crates/forge/bin/cmd/inspect.rs @@ -36,11 +36,15 @@ pub struct InspectArgs { /// All build arguments are supported #[command(flatten)] build: BuildOpts, + + /// Whether to remove comments when inspecting `ir` and `irOptimized` artifact fields. + #[arg(long, short, help_heading = "Display options")] + pub strip_yul_comments: bool, } impl InspectArgs { pub fn run(self) -> Result<()> { - let Self { contract, field, build } = self; + let Self { contract, field, build, strip_yul_comments } = self; trace!(target: "forge", ?field, ?contract, "running forge inspect"); @@ -106,10 +110,10 @@ impl InspectArgs { print_json(&artifact.devdoc)?; } ContractArtifactField::Ir => { - print_yul(artifact.ir.as_deref())?; + print_yul(artifact.ir.as_deref(), strip_yul_comments)?; } ContractArtifactField::IrOptimized => { - print_yul(artifact.ir_optimized.as_deref())?; + print_yul(artifact.ir_optimized.as_deref(), strip_yul_comments)?; } ContractArtifactField::Metadata => { print_json(&artifact.metadata)?; @@ -532,15 +536,19 @@ fn print_json_str(obj: &impl serde::Serialize, key: Option<&str>) -> Result<()> Ok(()) } -fn print_yul(yul: Option<&str>) -> Result<()> { +fn print_yul(yul: Option<&str>, strip_comments: bool) -> Result<()> { let Some(yul) = yul else { eyre::bail!("Could not get IR output"); }; static YUL_COMMENTS: LazyLock = - LazyLock::new(|| Regex::new(r"(///.*\n\s*)|(\s*/\*\*.*\*/)").unwrap()); + LazyLock::new(|| Regex::new(r"(///.*\n\s*)|(\s*/\*\*.*?\*/)").unwrap()); - sh_println!("{}", YUL_COMMENTS.replace_all(yul, ""))?; + if strip_comments { + sh_println!("{}", YUL_COMMENTS.replace_all(yul, ""))?; + } else { + sh_println!("{yul}")?; + } Ok(()) } diff --git a/crates/forge/tests/cli/cmd.rs b/crates/forge/tests/cli/cmd.rs index 4cefe790b3803..9d37c09977a92 100644 --- a/crates/forge/tests/cli/cmd.rs +++ b/crates/forge/tests/cli/cmd.rs @@ -3062,7 +3062,51 @@ Compiler run successful! // checks `forge inspect irOptimized works forgetest_init!(can_inspect_ir_optimized, |_prj, cmd| { cmd.args(["inspect", TEMPLATE_CONTRACT, "irOptimized"]); - cmd.assert_success(); + cmd.assert_success().stdout_eq(str![[r#" +/// @use-src 0:"src/Counter.sol" +object "Counter_21" { + code { + { + /// @src 0:65:257 "contract Counter {..." + mstore(64, memoryguard(0x80)) +... +"#]]); + + // check inspect with strip comments + cmd.forge_fuse().args(["inspect", TEMPLATE_CONTRACT, "irOptimized", "-s"]); + cmd.assert_success().stdout_eq(str![[r#" +object "Counter_21" { + code { + { + mstore(64, memoryguard(0x80)) + if callvalue() +... +"#]]); +}); + +// checks `forge inspect irOptimized works +forgetest_init!(can_inspect_ir, |_prj, cmd| { + cmd.args(["inspect", TEMPLATE_CONTRACT, "ir"]); + cmd.assert_success().stdout_eq(str![[r#" + +/// @use-src 0:"src/Counter.sol" +object "Counter_21" { + code { + /// @src 0:65:257 "contract Counter {..." + mstore(64, memoryguard(128)) +... +"#]]); + + // check inspect with strip comments + cmd.forge_fuse().args(["inspect", TEMPLATE_CONTRACT, "ir", "-s"]); + cmd.assert_success().stdout_eq(str![[r#" + +object "Counter_21" { + code { + mstore(64, memoryguard(128)) + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } +... +"#]]); }); // checks forge bind works correctly on the default project From 29cba10c737636d0000ef6ad5de8d08df267ac60 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:15:52 +0200 Subject: [PATCH 1953/1963] fix(forge): flatten fails on top-level event declarations (#9892) --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96322731759cb..68d004f1b04f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3783,9 +3783,9 @@ dependencies = [ [[package]] name = "foundry-compilers" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de23802550de5204eec1a6297296d2fef6b86ea61f33b1667eebd886577caa34" +checksum = "ac8f0bab060fd7c1764c4be2563e6933d39ec8c2b8a8d6c08aaf45ab29d08310" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3820,9 +3820,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f065a1c785b3ec556a7a49a27016fc723bd9a4d8623f521c326f8396df64a6" +checksum = "b102dd131e939d80cc5c85214d2f0f6ba20ed75cf098019c4d995791b4ebae05" dependencies = [ "foundry-compilers-artifacts-solc", "foundry-compilers-artifacts-vyper", @@ -3830,9 +3830,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-solc" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "127e0e788765bc0103eb6b92067843c6ffe660090b2f6fbff1a1441a51939aa0" +checksum = "db9ef02de4fda04ae3ed098afb6e16edd742d1073f972197a4566836b453bdcd" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3854,9 +3854,9 @@ dependencies = [ [[package]] name = "foundry-compilers-artifacts-vyper" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764f450332267305440ec399560919e01aa98f23af2c36ac952f9216449cdca" +checksum = "3bd9d33cbeda448af917105920fefdc3ac42f9ffdaa2d840d58207db7807ea29" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -3869,9 +3869,9 @@ dependencies = [ [[package]] name = "foundry-compilers-core" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59caebbeaeb0e34564c1a404081478a0aadaa8999b57f0befd85965252e074a" +checksum = "746d121f7b86b84b20e582a27a56c49435768ad3b8005e9afeaf68b53a77fb5c" dependencies = [ "alloy-primitives", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 0ad21d6c143ba..44e561c79a365 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -187,7 +187,7 @@ foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.11.0", default-features = false } -foundry-compilers = { version = "0.13.2", default-features = false } +foundry-compilers = { version = "0.13.3", default-features = false } foundry-fork-db = "0.11.0" solang-parser = "=0.3.3" solar-parse = { version = "=0.1.1", default-features = false } From 51b75c83045a963a48f9cd8d765e0f2e775acb3e Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Fri, 14 Feb 2025 17:45:38 +0100 Subject: [PATCH 1954/1963] feat(`anvil`): emit warning server side on failing request (#9890) * log error if request response fails * use warning as it is not a server side failure but a failing client request * prefer using node_info! macro * improve error format --- crates/anvil/src/eth/api.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 147237a744ef4..8a69a070cacc7 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -161,7 +161,7 @@ impl EthApi { /// Executes the [EthRequest] and returns an RPC [ResponseResult]. pub async fn execute(&self, request: EthRequest) -> ResponseResult { trace!(target: "rpc::api", "executing eth request"); - match request { + let response = match request.clone() { EthRequest::Web3ClientVersion(()) => self.client_version().to_rpc_result(), EthRequest::Web3Sha3(content) => self.sha3(content).to_rpc_result(), EthRequest::EthGetAccount(addr, block) => { @@ -465,7 +465,15 @@ impl EthApi { EthRequest::AnvilSetExecutor(executor_pk) => { self.anvil_set_executor(executor_pk).to_rpc_result() } + }; + + if let ResponseResult::Error(err) = &response { + node_info!("\nRPC request failed:"); + node_info!(" Request: {:?}", request); + node_info!(" Error: {}\n", err); } + + response } fn sign_request( From 5af4630a640db2edc06d041e642493d6305e7460 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 08:15:12 +0000 Subject: [PATCH 1955/1963] chore(deps): weekly `cargo update` (#9898) --- Cargo.lock | 16 ++++++++-------- crates/test-utils/src/rpc.rs | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68d004f1b04f6..d4729c9262e22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2085,9 +2085,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.13" +version = "1.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" dependencies = [ "shlex", ] @@ -3123,9 +3123,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -7057,9 +7057,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" +checksum = "e46f3055866785f6b92bc6164b76be02ca8f2eb4b002c0354b28cf4c119e5944" dependencies = [ "cfg_aliases", "libc", @@ -8219,9 +8219,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" dependencies = [ "serde", ] diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index c10abcbd21280..ba1581e69c564 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -48,18 +48,18 @@ static ALCHEMY_KEYS: LazyLock> = LazyLock::new(|| { "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", + // "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", + // "UVatYU2Ax0rX6bDiqddeTRDdcCxzdpoE", "bVjX9v-FpmUhf5R_oHIgwJx2kXvYPRbx", ]; keys.shuffle(&mut rand::thread_rng()); From b184ebd0f5214dd69f1fc3353e41bf334d471e00 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Mon, 17 Feb 2025 15:00:38 +0100 Subject: [PATCH 1956/1963] fix: add support for inline `isolate` configuration (#9904) * add test for inline isolate configuration * clean up docs * clarify * prefer config, add comment --- crates/forge/src/multi_runner.rs | 11 +- crates/forge/tests/cli/inline_config.rs | 133 +++++++++++++++++++++++- 2 files changed, 139 insertions(+), 5 deletions(-) diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 1b7f51a61f99b..8ecb0e63a6152 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -294,18 +294,21 @@ pub struct TestRunnerConfig { impl TestRunnerConfig { /// Reconfigures all fields using the given `config`. + /// This is for example used to override the configuration with inline config. pub fn reconfigure_with(&mut self, config: Arc) { debug_assert!(!Arc::ptr_eq(&self.config, &config)); - // TODO: self.evm_opts - // TODO: self.env self.spec_id = config.evm_spec_id(); self.sender = config.sender; + self.odyssey = config.odyssey; + self.isolation = config.isolate; + + // Specific to Forge, not present in config. + // TODO: self.evm_opts + // TODO: self.env // self.coverage = N/A; // self.debug = N/A; // self.decode_internal = N/A; - // self.isolation = N/A; - self.odyssey = config.odyssey; self.config = config; } diff --git a/crates/forge/tests/cli/inline_config.rs b/crates/forge/tests/cli/inline_config.rs index 085cc88a8634f..ad3f529b17ff4 100644 --- a/crates/forge/tests/cli/inline_config.rs +++ b/crates/forge/tests/cli/inline_config.rs @@ -1,3 +1,7 @@ +use std::{fs, path::Path}; + +use serde::{Deserialize, Deserializer}; + forgetest!(runs, |prj, cmd| { prj.add_test( "inline.sol", @@ -201,7 +205,134 @@ Encountered a total of 1 failing tests, 0 tests succeeded "#]]); }); -forgetest_init!(evm_version, |prj, cmd| { +forgetest_init!(config_inline_isolate, |prj, cmd| { + prj.wipe_contracts(); + prj.add_test( + "inline.sol", + r#" + import {Test} from "forge-std/Test.sol"; + + contract Dummy { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + } + + contract FunctionConfig is Test { + Dummy dummy; + + function setUp() public { + dummy = new Dummy(); + } + + /// forge-config: default.isolate = true + function test_isolate() public { + vm.startSnapshotGas("testIsolatedFunction"); + dummy.setNumber(1); + vm.stopSnapshotGas(); + } + + function test_non_isolate() public { + vm.startSnapshotGas("testNonIsolatedFunction"); + dummy.setNumber(2); + vm.stopSnapshotGas(); + } + } + + /// forge-config: default.isolate = true + contract ContractConfig is Test { + Dummy dummy; + + function setUp() public { + dummy = new Dummy(); + } + + function test_non_isolate() public { + vm.startSnapshotGas("testIsolatedContract"); + dummy.setNumber(3); + vm.stopSnapshotGas(); + } + } + "#, + ) + .unwrap(); + + cmd.args(["test", "-j1"]).assert_success().stdout_eq(str![[r#" +[COMPILING_FILES] with [SOLC_VERSION] +[SOLC_VERSION] [ELAPSED] +Compiler run successful! + +Ran 1 test for test/inline.sol:ContractConfig +[PASS] test_non_isolate() ([GAS]) +Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 2 tests for test/inline.sol:FunctionConfig +[PASS] test_isolate() ([GAS]) +[PASS] test_non_isolate() ([GAS]) +Suite result: ok. 2 passed; 0 failed; 0 skipped; [ELAPSED] + +Ran 2 test suites [ELAPSED]: 3 tests passed, 0 failed, 0 skipped (3 total tests) + +"#]]); + + assert!(prj.root().join("snapshots/FunctionConfig.json").exists()); + assert!(prj.root().join("snapshots/ContractConfig.json").exists()); + + #[derive(Debug, Deserialize)] + #[serde(rename_all = "camelCase")] + struct FunctionConfig { + #[serde(deserialize_with = "string_to_u64")] + test_isolated_function: u64, + + #[serde(deserialize_with = "string_to_u64")] + test_non_isolated_function: u64, + } + + #[derive(Debug, Deserialize)] + #[serde(rename_all = "camelCase")] + struct ContractConfig { + #[serde(deserialize_with = "string_to_u64")] + test_isolated_contract: u64, + } + + fn string_to_u64<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: serde_json::Value = Deserialize::deserialize(deserializer)?; + match s { + serde_json::Value::String(s) => s.parse::().map_err(serde::de::Error::custom), + serde_json::Value::Number(n) if n.is_u64() => Ok(n.as_u64().unwrap()), + _ => Err(serde::de::Error::custom("Expected a string or number")), + } + } + + fn read_snapshot Deserialize<'de>>(path: &Path) -> T { + let content = fs::read_to_string(path).expect("Failed to read file"); + serde_json::from_str(&content).expect("Failed to parse snapshot") + } + + let function_config: FunctionConfig = + read_snapshot(&prj.root().join("snapshots/FunctionConfig.json")); + let contract_config: ContractConfig = + read_snapshot(&prj.root().join("snapshots/ContractConfig.json")); + + // FunctionConfig { + // test_isolated_function: 48926, + // test_non_isolated_function: 27722, + // } + + // ContractConfig { + // test_isolated_contract: 48926, + // } + + assert!(function_config.test_isolated_function > function_config.test_non_isolated_function); + assert_eq!(function_config.test_isolated_function, contract_config.test_isolated_contract); +}); + +forgetest_init!(config_inline_evm_version, |prj, cmd| { prj.wipe_contracts(); prj.add_test( "inline.sol", From 3d393b6f1266c71f3b422a99b1a08852534d4db3 Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Mon, 17 Feb 2025 18:41:46 +0200 Subject: [PATCH 1957/1963] fix(config): enable optimizer if optimizer runs > 0 in additional profiles (#9901) * fix(config): enable optimizer if optimizer runs > 0 in additional profiles * Improved test --- crates/config/src/compilation.rs | 4 + crates/forge/tests/cli/config.rs | 164 ++++++++++++++++++++++++++++++- 2 files changed, 167 insertions(+), 1 deletion(-) diff --git a/crates/config/src/compilation.rs b/crates/config/src/compilation.rs index b4f00b91b0d92..8bb48f525bb54 100644 --- a/crates/config/src/compilation.rs +++ b/crates/config/src/compilation.rs @@ -40,6 +40,10 @@ impl SettingsOverrides { if let Some(optimizer_runs) = self.optimizer_runs { settings.solc.optimizer.runs = Some(optimizer_runs); + // Enable optimizer in optimizer runs set to a higher value than 0. + if optimizer_runs > 0 && self.optimizer.is_none() { + settings.solc.optimizer.enabled = Some(true); + } } if let Some(bytecode_hash) = self.bytecode_hash { diff --git a/crates/forge/tests/cli/config.rs b/crates/forge/tests/cli/config.rs index 7c153d10bbe4b..23b72a86526ff 100644 --- a/crates/forge/tests/cli/config.rs +++ b/crates/forge/tests/cli/config.rs @@ -8,8 +8,10 @@ use foundry_compilers::{ }; use foundry_config::{ cache::{CachedChains, CachedEndpoints, StorageCachingConfig}, + filter::GlobMatcher, fs_permissions::{FsAccessPermission, PathPermission}, - Config, FsPermissions, FuzzConfig, InvariantConfig, SolcReq, + CompilationRestrictions, Config, FsPermissions, FuzzConfig, InvariantConfig, SettingsOverrides, + SolcReq, }; use foundry_evm::opts::EvmOpts; use foundry_test_utils::{ @@ -17,6 +19,8 @@ use foundry_test_utils::{ util::{pretty_err, OutputExt, TestCommand, OTHER_SOLC_VERSION}, }; use path_slash::PathBufExt; +use semver::VersionReq; +use serde_json::Value; use similar_asserts::assert_eq; use std::{ fs, @@ -1631,3 +1635,161 @@ contract GasSnapshotEmitTest is DSTest { // Assert that snapshots were not emitted to disk. assert!(!prj.root().join("snapshots/GasSnapshotEmitTest.json").exists()); }); + +// Tests compilation restrictions enables optimizer if optimizer runs set to a value higher than 0. +forgetest_init!(test_additional_compiler_profiles, |prj, cmd| { + prj.add_source( + "v1/Counter.sol", + r#" +contract Counter { +} + "#, + ) + .unwrap(); + + prj.add_source( + "v2/Counter.sol", + r#" +contract Counter { +} + "#, + ) + .unwrap(); + + prj.add_source( + "v3/Counter.sol", + r#" +contract Counter { +} + "#, + ) + .unwrap(); + + // Additional profiles are defined with optimizer runs but without explicitly enabling + // optimizer + // + // additional_compiler_profiles = [ + // { name = "v1", optimizer_runs = 44444444, via_ir = true, evm_version = "cancun" }, + // { name = "v2", optimizer_runs = 111, via_ir = true }, + // { name = "v3", optimizer_runs = 800, evm_version = "istanbul", via_ir = false }, + // ] + // + // compilation_restrictions = [ + // # v1 + // { paths = "src/v1/[!i]*.sol", version = "0.8.16", optimizer_runs = 44444444 }, + // # v2 + // { paths = "src/v2/{Counter}.sol", optimizer_runs = 111 }, + // # v3 + // { paths = "src/v3/*", optimizer_runs = 800 }, + // ] + let v1_profile = SettingsOverrides { + name: "v1".to_string(), + via_ir: Some(true), + evm_version: Some(EvmVersion::Cancun), + optimizer: None, + optimizer_runs: Some(44444444), + bytecode_hash: None, + }; + let v1_restrictions = CompilationRestrictions { + paths: GlobMatcher::from_str("src/v1/[!i]*.sol").unwrap(), + version: Some(VersionReq::from_str("0.8.16").unwrap()), + via_ir: None, + bytecode_hash: None, + min_optimizer_runs: None, + optimizer_runs: Some(44444444), + max_optimizer_runs: None, + min_evm_version: None, + evm_version: None, + max_evm_version: None, + }; + let v2_profile = SettingsOverrides { + name: "v2".to_string(), + via_ir: Some(true), + evm_version: None, + optimizer: None, + optimizer_runs: Some(111), + bytecode_hash: None, + }; + let v2_restrictions = CompilationRestrictions { + paths: GlobMatcher::from_str("src/v2/{Counter}.sol").unwrap(), + version: None, + via_ir: None, + bytecode_hash: None, + min_optimizer_runs: None, + optimizer_runs: Some(111), + max_optimizer_runs: None, + min_evm_version: None, + evm_version: None, + max_evm_version: None, + }; + let v3_profile = SettingsOverrides { + name: "v3".to_string(), + via_ir: Some(false), + evm_version: Some(EvmVersion::Istanbul), + optimizer: None, + optimizer_runs: Some(800), + bytecode_hash: None, + }; + let v3_restrictions = CompilationRestrictions { + paths: GlobMatcher::from_str("src/v3/*").unwrap(), + version: None, + via_ir: None, + bytecode_hash: None, + min_optimizer_runs: None, + optimizer_runs: Some(800), + max_optimizer_runs: None, + min_evm_version: None, + evm_version: None, + max_evm_version: None, + }; + let additional_compiler_profiles = vec![v1_profile, v2_profile, v3_profile]; + let compilation_restrictions = vec![v1_restrictions, v2_restrictions, v3_restrictions]; + prj.update_config(|config| { + config.additional_compiler_profiles = additional_compiler_profiles; + config.compilation_restrictions = compilation_restrictions; + }); + // Should find and build all profiles satisfying settings restrictions. + cmd.forge_fuse().args(["build"]).assert_success(); + prj.assert_artifacts_dir_exists(); + + let artifact_settings = + |artifact| -> (Option, Option, Option, Option) { + let artifact: serde_json::Value = serde_json::from_reader( + fs::File::open(prj.artifacts().join(artifact)).expect("no artifact"), + ) + .expect("invalid artifact"); + let settings = + artifact.get("metadata").unwrap().get("settings").unwrap().as_object().unwrap(); + let optimizer = settings.get("optimizer").unwrap(); + ( + settings.get("viaIR").cloned(), + settings.get("evmVersion").cloned(), + optimizer.get("enabled").cloned(), + optimizer.get("runs").cloned(), + ) + }; + + let (via_ir, evm_version, enabled, runs) = artifact_settings("Counter.sol/Counter.json"); + assert_eq!(None, via_ir); + assert_eq!("\"cancun\"", evm_version.unwrap().to_string()); + assert_eq!("false", enabled.unwrap().to_string()); + assert_eq!("200", runs.unwrap().to_string()); + + let (via_ir, evm_version, enabled, runs) = artifact_settings("v1/Counter.sol/Counter.json"); + assert_eq!("true", via_ir.unwrap().to_string()); + assert_eq!("\"cancun\"", evm_version.unwrap().to_string()); + assert_eq!("true", enabled.unwrap().to_string()); + assert_eq!("44444444", runs.unwrap().to_string()); + + let (via_ir, evm_version, enabled, runs) = artifact_settings("v2/Counter.sol/Counter.json"); + assert_eq!("true", via_ir.unwrap().to_string()); + assert_eq!("\"cancun\"", evm_version.unwrap().to_string()); + assert_eq!("true", enabled.unwrap().to_string()); + assert_eq!("111", runs.unwrap().to_string()); + + let (via_ir, evm_version, enabled, runs) = artifact_settings("v3/Counter.sol/Counter.json"); + assert_eq!(None, via_ir); + assert_eq!("\"istanbul\"", evm_version.unwrap().to_string()); + assert_eq!("true", enabled.unwrap().to_string()); + assert_eq!("800", runs.unwrap().to_string()); +}); From ac982da859b2950f1d1dcfb4230611377beb7c27 Mon Sep 17 00:00:00 2001 From: Giovanni Napoli Date: Tue, 18 Feb 2025 06:24:58 +0100 Subject: [PATCH 1958/1963] feat: bump `alpine=3.21` in Dockerfile (#9907) --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b425f6ef4d1aa..08b997d369050 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM alpine:3.20 as build-environment +FROM alpine:3.21 as build-environment ARG TARGETARCH WORKDIR /opt @@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/r && strip out/chisel \ && strip out/anvil; -FROM alpine:3.20 as foundry-client +FROM alpine:3.21 as foundry-client RUN apk add --no-cache linux-headers git gcompat libstdc++ From 1946c2d6fcdc087b1adae251c6b016a3e8fec6ec Mon Sep 17 00:00:00 2001 From: grandizzy <38490174+grandizzy@users.noreply.github.com> Date: Tue, 18 Feb 2025 09:27:25 +0200 Subject: [PATCH 1959/1963] chore: update rpc keys (#9910) remove keys --- crates/test-utils/src/rpc.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/test-utils/src/rpc.rs b/crates/test-utils/src/rpc.rs index ba1581e69c564..12762324dd2bb 100644 --- a/crates/test-utils/src/rpc.rs +++ b/crates/test-utils/src/rpc.rs @@ -34,11 +34,11 @@ static INFURA_KEYS: LazyLock> = LazyLock::new(|| { // List of alchemy keys for mainnet static ALCHEMY_KEYS: LazyLock> = LazyLock::new(|| { let mut keys = vec![ - "ib1f4u1ojm-9lJJypwkeZeG-75TJRB7O", - "7mTtk6IW4DwroGnKmG_bOWri2hyaGYhX", - "GL4M0hfzSYGU5e1_t804HoUDOObWP-FA", - "WV407BEiBmjNJfKo9Uo_55u0z0ITyCOX", - "Ge56dH9siMF4T0whP99sQXOcr2mFs8wZ", + // "ib1f4u1ojm-9lJJypwkeZeG-75TJRB7O", + // "7mTtk6IW4DwroGnKmG_bOWri2hyaGYhX", + // "GL4M0hfzSYGU5e1_t804HoUDOObWP-FA", + // "WV407BEiBmjNJfKo9Uo_55u0z0ITyCOX", + // "Ge56dH9siMF4T0whP99sQXOcr2mFs8wZ", // "QC55XC151AgkS3FNtWvz9VZGeu9Xd9lb", // "pwc5rmJhrdoaSEfimoKEmsvOjKSmPDrP", // "A5sZ85MIr4SzCMkT0zXh2eeamGIq3vGL", From 087c676e65a425eb02efc99680e452a09da98fa5 Mon Sep 17 00:00:00 2001 From: zerosnacks <95942363+zerosnacks@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:01:56 +0100 Subject: [PATCH 1960/1963] feat(`cast age`): clarify block timestamp is UTC to allow for `date` compatibility (#9913) clarify block timestamp is always UTC --- crates/cast/bin/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 1663606260194..7febaae97fb5b 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -289,7 +289,7 @@ async fn main_args(args: CastArgs) -> Result<()> { let config = rpc.load_config()?; let provider = utils::get_provider(&config)?; sh_println!( - "{}", + "{} UTC", Cast::new(provider).age(block.unwrap_or(BlockId::Number(Latest))).await? )? } From fdd78d9966c8ef553c2045842c982188fe54645b Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 18 Feb 2025 20:57:32 +0530 Subject: [PATCH 1961/1963] fix(`forge`): catch faulty test constructors (#9909) * fix(`forge`): catch test contract deployment failures * nit * test * fix * nit * Revert "nit" This reverts commit 5712a93af62070c8879760e4b509bcdcf828d79d. * Revert "fix" This reverts commit 9f6bee14a089ffb76ff7b64988c34c004e417d63. * fix test * cleaner * nit Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --------- Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com> --- crates/forge/src/result.rs | 2 ++ crates/forge/src/runner.rs | 10 +++++++++- crates/forge/tests/cli/test_cmd.rs | 31 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/forge/src/result.rs b/crates/forge/src/result.rs index 0b1ebff19d749..02ca64fde18ad 100644 --- a/crates/forge/src/result.rs +++ b/crates/forge/src/result.rs @@ -765,6 +765,8 @@ pub struct TestSetup { pub reason: Option, /// Whether setup and entire test suite is skipped. pub skipped: bool, + /// Whether the test failed to deploy. + pub deployment_failure: bool, } impl TestSetup { diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 1b30dcebe6cee..893c74baf449f 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -158,6 +158,9 @@ impl<'a> ContractRunner<'a> { U256::ZERO, Some(&self.mcr.revert_decoder), ); + + result.deployment_failure = deploy_result.is_err(); + if let Ok(dr) = &deploy_result { debug_assert_eq!(dr.address, address); } @@ -340,9 +343,14 @@ impl<'a> ContractRunner<'a> { if setup.reason.is_some() { // The setup failed, so we return a single test result for `setUp` + let fail_msg = if !setup.deployment_failure { + "setUp()".to_string() + } else { + "constructor()".to_string() + }; return SuiteResult::new( start.elapsed(), - [("setUp()".to_string(), TestResult::setup_result(setup))].into(), + [(fail_msg, TestResult::setup_result(setup))].into(), warnings, ) } diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index d3a7eb9179be3..c0e9750163504 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -3137,3 +3137,34 @@ Encountered a total of 1 failing tests, 1 tests succeeded "#]]); }); + +forgetest_init!(catch_test_deployment_failure, |prj, cmd| { + prj.add_test( + "TestDeploymentFailure.t.sol", + r#" +import "forge-std/Test.sol"; +contract TestDeploymentFailure is Test { + + constructor() { + require(false); + } + + function setUp() public { + require(true); + } + + function test_something() public { + require(1 == 1); + } +} + "#, + ) + .unwrap(); + + cmd.args(["t", "--mt", "test_something"]).assert_failure().stdout_eq(str![[r#" +... +Failing tests: +Encountered 1 failing test in test/TestDeploymentFailure.t.sol:TestDeploymentFailure +[FAIL: EvmError: Revert] constructor() ([GAS]) +..."#]]); +}); From 7e8c6e937848be26ae486f00a164ab200830fc66 Mon Sep 17 00:00:00 2001 From: Sumit <106421807+startup-dreamer@users.noreply.github.com> Date: Tue, 18 Feb 2025 21:01:12 +0530 Subject: [PATCH 1962/1963] feat: add `vm.foundryVersionCmp` and `vm.foundryVersionAtLeast` cheatcodes (#9845) * feat: add foundryVersionCmp and foundryVersionAtLeast cheatcode * fix: change the acceptable version string in version cmp cheatcodes to major.minor.patch --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> --- crates/cheatcodes/assets/cheatcodes.json | 40 +++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 15 ++++++ crates/cheatcodes/src/lib.rs | 2 + crates/cheatcodes/src/version.rs | 51 +++++++++++++++++++ testdata/cheats/Vm.sol | 2 + .../default/cheats/GetFoundryVersion.t.sol | 45 ++++++++++++++++ 6 files changed, 155 insertions(+) create mode 100644 crates/cheatcodes/src/version.rs diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index cb49f2de1a27b..ac53a1f56476e 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5472,6 +5472,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "foundryVersionAtLeast", + "description": "Returns true if the current Foundry version is at least the given version.\nVersion string can be in the format `major.minor.patch`.", + "declaration": "function foundryVersionAtLeast(string calldata version) external view returns (bool);", + "visibility": "external", + "mutability": "view", + "signature": "foundryVersionAtLeast(string)", + "selector": "0x6248be1f", + "selectorBytes": [ + 98, + 72, + 190, + 31 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "foundryVersionCmp", + "description": "Compares the current Foundry version with the given version string.\nVersion string can be in the format `major.minor.patch`.\nReturns:\n-1 if current version is less than the given version\n0 if current version equals the given version\n1 if current version is greater than the given version", + "declaration": "function foundryVersionCmp(string calldata version) external view returns (int256);", + "visibility": "external", + "mutability": "view", + "signature": "foundryVersionCmp(string)", + "selector": "0xca7b0a09", + "selectorBytes": [ + 202, + 123, + 10, + 9 + ] + }, + "group": "testing", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "fsMetadata", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index cf9709276335d..29fb986768d80 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1677,6 +1677,21 @@ interface Vm { string calldata error ) external pure; + /// Returns true if the current Foundry version is at least the given version. + /// Version string can be in the format `major.minor.patch`. + #[cheatcode(group = Testing, safety = Safe)] + function foundryVersionAtLeast(string calldata version) external view returns (bool); + + /// Compares the current Foundry version with the given version string. + /// Version string can be in the format `major.minor.patch`. + /// Returns: + /// -1 if current version is less than the given version + /// 0 if current version equals the given version + /// 1 if current version is greater than the given version + #[cheatcode(group = Testing, safety = Safe)] + function foundryVersionCmp(string calldata version) external view returns (int256); + + // ======== OS and Filesystem ======== // -------- Metadata -------- diff --git a/crates/cheatcodes/src/lib.rs b/crates/cheatcodes/src/lib.rs index 95d04cab88e31..732f55d7e2533 100644 --- a/crates/cheatcodes/src/lib.rs +++ b/crates/cheatcodes/src/lib.rs @@ -37,6 +37,8 @@ mod config; mod crypto; +mod version; + mod env; pub use env::set_execution_context; diff --git a/crates/cheatcodes/src/version.rs b/crates/cheatcodes/src/version.rs new file mode 100644 index 0000000000000..6a5a2793456ac --- /dev/null +++ b/crates/cheatcodes/src/version.rs @@ -0,0 +1,51 @@ +use crate::{Cheatcode, Cheatcodes, Result, Vm::*}; +use alloy_sol_types::SolValue; +use foundry_common::version::SEMVER_VERSION; +use semver::Version; +use std::cmp::Ordering; + +impl Cheatcode for foundryVersionCmpCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { version } = self; + + if version.contains("+") || version.contains("-") { + return Err(fmt_err!("Version must be in only major.minor.patch format")); + } + + let parsed_version = Version::parse(version) + .map_err(|e| fmt_err!("Invalid semver format '{}': {}", version, e))?; + let current_semver = Version::parse(SEMVER_VERSION) + .map_err(|_| fmt_err!("Invalid current version format"))?; + + let current_version = + Version::new(current_semver.major, current_semver.minor, current_semver.patch); + // Note: returns -1 if current < provided, 0 if equal, 1 if current > provided. + let cmp_result = match current_version.cmp(&parsed_version) { + Ordering::Less => -1i32, + Ordering::Equal => 0i32, + Ordering::Greater => 1i32, + }; + Ok(cmp_result.abi_encode()) + } +} + +impl Cheatcode for foundryVersionAtLeastCall { + fn apply(&self, _state: &mut Cheatcodes) -> Result { + let Self { version } = self; + + if version.contains("+") || version.contains("-") { + return Err(fmt_err!("Version must be in only major.minor.patch format")); + } + + let parsed_version = + Version::parse(version).map_err(|_| fmt_err!("Invalid version format"))?; + let current_semver = Version::parse(SEMVER_VERSION) + .map_err(|_| fmt_err!("Invalid current version format"))?; + + let current_version = + Version::new(current_semver.major, current_semver.minor, current_semver.patch); + + let at_least = current_version.cmp(&parsed_version) != Ordering::Less; + Ok(at_least.abi_encode()) + } +} diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index d1a301e0f3df5..cc873d3e1be21 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -267,6 +267,8 @@ interface Vm { function expectSafeMemoryCall(uint64 min, uint64 max) external; function fee(uint256 newBasefee) external; function ffi(string[] calldata commandInput) external returns (bytes memory result); + function foundryVersionAtLeast(string calldata version) external view returns (bool); + function foundryVersionCmp(string calldata version) external view returns (int256); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); function getArtifactPathByCode(bytes calldata code) external view returns (string memory path); function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path); diff --git a/testdata/default/cheats/GetFoundryVersion.t.sol b/testdata/default/cheats/GetFoundryVersion.t.sol index eca5090db99c3..ac30bb8491874 100644 --- a/testdata/default/cheats/GetFoundryVersion.t.sol +++ b/testdata/default/cheats/GetFoundryVersion.t.sol @@ -42,4 +42,49 @@ contract GetFoundryVersionTest is DSTest { // Validate build profile (e.g., "debug" or "release") require(bytes(buildType).length > 0, "Build type is empty"); } + + function testFoundryVersionCmp() public { + // Should return -1 if current version is less than argument + assertEq(vm.foundryVersionCmp("99.0.0"), -1); + + // (e.g. 0.3.0-nightly+3cb96bde9b.1737036656.debug) + string memory fullVersionString = vm.getFoundryVersion(); + + // Step 1: Split the version at "+" + string[] memory plusSplit = vm.split(fullVersionString, "+"); + require(plusSplit.length == 2, "Invalid version format: Missing '+' separator"); + + // Step 2: Extract parts + string memory semanticVersion = plusSplit[0]; // "0.3.0-dev" + string[] memory semanticSplit = vm.split(semanticVersion, "-"); + + semanticVersion = semanticSplit[0]; // "0.3.0" + // Should return 0 if current version is equal to argument + assertEq(vm.foundryVersionCmp(semanticVersion), 0); + + // Should return 1 if current version is greater than argument + assertEq(vm.foundryVersionCmp("0.0.1"), 1); + } + + function testFoundryVersionAtLeast() public { + // Should return false for future versions + assertEq(vm.foundryVersionAtLeast("99.0.0"), false); + + // (e.g. 0.3.0-nightly+3cb96bde9b.1737036656.debug) + string memory fullVersionString = vm.getFoundryVersion(); + + // Step 1: Split the version at "+" + string[] memory plusSplit = vm.split(fullVersionString, "+"); + require(plusSplit.length == 2, "Invalid version format: Missing '+' separator"); + + // Step 2: Extract parts + string memory semanticVersion = plusSplit[0]; // "0.3.0-dev" + string[] memory semanticSplit = vm.split(semanticVersion, "-"); + + semanticVersion = semanticSplit[0]; // "0.3.0" + assertTrue(vm.foundryVersionAtLeast(semanticVersion)); + + // Should return true for past versions + assertTrue(vm.foundryVersionAtLeast("0.2.0")); + } } From 97e2ebbb7f74189b65943ae0b8537415d709608c Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:25:33 +0100 Subject: [PATCH 1963/1963] chore: version cmp cheatcodes clean up (#9914) --- crates/cheatcodes/assets/cheatcodes.json | 4 +- crates/cheatcodes/spec/src/vm.rs | 20 +++++---- crates/cheatcodes/src/version.rs | 52 ++++++++++-------------- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index ac53a1f56476e..3d528b903bf18 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5475,7 +5475,7 @@ { "func": { "id": "foundryVersionAtLeast", - "description": "Returns true if the current Foundry version is at least the given version.\nVersion string can be in the format `major.minor.patch`.", + "description": "Returns true if the current Foundry version is greater than or equal to the given version.\nThe given version string must be in the format `major.minor.patch`.\nThis is equivalent to `foundryVersionCmp(version) >= 0`.", "declaration": "function foundryVersionAtLeast(string calldata version) external view returns (bool);", "visibility": "external", "mutability": "view", @@ -5495,7 +5495,7 @@ { "func": { "id": "foundryVersionCmp", - "description": "Compares the current Foundry version with the given version string.\nVersion string can be in the format `major.minor.patch`.\nReturns:\n-1 if current version is less than the given version\n0 if current version equals the given version\n1 if current version is greater than the given version", + "description": "Compares the current Foundry version with the given version string.\nThe given version string must be in the format `major.minor.patch`.\nReturns:\n-1 if current Foundry version is less than the given version\n0 if current Foundry version equals the given version\n1 if current Foundry version is greater than the given version\nThis result can then be used with a comparison operator against `0`.\nFor example, to check if the current Foundry version is greater than or equal to `1.0.0`:\n`if (foundryVersionCmp(\"1.0.0\") >= 0) { ... }`", "declaration": "function foundryVersionCmp(string calldata version) external view returns (int256);", "visibility": "external", "mutability": "view", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 29fb986768d80..f2eaeb697a183 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -1677,21 +1677,27 @@ interface Vm { string calldata error ) external pure; - /// Returns true if the current Foundry version is at least the given version. - /// Version string can be in the format `major.minor.patch`. + /// Returns true if the current Foundry version is greater than or equal to the given version. + /// The given version string must be in the format `major.minor.patch`. + /// + /// This is equivalent to `foundryVersionCmp(version) >= 0`. #[cheatcode(group = Testing, safety = Safe)] function foundryVersionAtLeast(string calldata version) external view returns (bool); /// Compares the current Foundry version with the given version string. - /// Version string can be in the format `major.minor.patch`. + /// The given version string must be in the format `major.minor.patch`. + /// /// Returns: - /// -1 if current version is less than the given version - /// 0 if current version equals the given version - /// 1 if current version is greater than the given version + /// -1 if current Foundry version is less than the given version + /// 0 if current Foundry version equals the given version + /// 1 if current Foundry version is greater than the given version + /// + /// This result can then be used with a comparison operator against `0`. + /// For example, to check if the current Foundry version is greater than or equal to `1.0.0`: + /// `if (foundryVersionCmp("1.0.0") >= 0) { ... }` #[cheatcode(group = Testing, safety = Safe)] function foundryVersionCmp(string calldata version) external view returns (int256); - // ======== OS and Filesystem ======== // -------- Metadata -------- diff --git a/crates/cheatcodes/src/version.rs b/crates/cheatcodes/src/version.rs index 6a5a2793456ac..d88fa09df0f76 100644 --- a/crates/cheatcodes/src/version.rs +++ b/crates/cheatcodes/src/version.rs @@ -7,45 +7,35 @@ use std::cmp::Ordering; impl Cheatcode for foundryVersionCmpCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { version } = self; - - if version.contains("+") || version.contains("-") { - return Err(fmt_err!("Version must be in only major.minor.patch format")); - } - - let parsed_version = Version::parse(version) - .map_err(|e| fmt_err!("Invalid semver format '{}': {}", version, e))?; - let current_semver = Version::parse(SEMVER_VERSION) - .map_err(|_| fmt_err!("Invalid current version format"))?; - - let current_version = - Version::new(current_semver.major, current_semver.minor, current_semver.patch); - // Note: returns -1 if current < provided, 0 if equal, 1 if current > provided. - let cmp_result = match current_version.cmp(&parsed_version) { - Ordering::Less => -1i32, - Ordering::Equal => 0i32, - Ordering::Greater => 1i32, - }; - Ok(cmp_result.abi_encode()) + foundry_version_cmp(version).map(|cmp| (cmp as i8).abi_encode()) } } impl Cheatcode for foundryVersionAtLeastCall { fn apply(&self, _state: &mut Cheatcodes) -> Result { let Self { version } = self; + foundry_version_cmp(version).map(|cmp| cmp.is_ge().abi_encode()) + } +} - if version.contains("+") || version.contains("-") { - return Err(fmt_err!("Version must be in only major.minor.patch format")); - } - - let parsed_version = - Version::parse(version).map_err(|_| fmt_err!("Invalid version format"))?; - let current_semver = Version::parse(SEMVER_VERSION) - .map_err(|_| fmt_err!("Invalid current version format"))?; +fn foundry_version_cmp(version: &str) -> Result { + version_cmp(SEMVER_VERSION.split('-').next().unwrap(), version) +} - let current_version = - Version::new(current_semver.major, current_semver.minor, current_semver.patch); +fn version_cmp(version_a: &str, version_b: &str) -> Result { + let version_a = parse_version(version_a)?; + let version_b = parse_version(version_b)?; + Ok(version_a.cmp(&version_b)) +} - let at_least = current_version.cmp(&parsed_version) != Ordering::Less; - Ok(at_least.abi_encode()) +fn parse_version(version: &str) -> Result { + let version = + Version::parse(version).map_err(|e| fmt_err!("invalid version `{version}`: {e}"))?; + if !version.pre.is_empty() { + return Err(fmt_err!("invalid version `{version}`: pre-release versions are not supported")); + } + if !version.build.is_empty() { + return Err(fmt_err!("invalid version `{version}`: build metadata is not supported")); } + Ok(version) }

    it9(XqIfEXhy^8#7)4PU?TPPTz@CV(;HXiA5YWglDxHa#&%>P2=oV`tk4s}X!4Og&ZBi$# z3?GdQ@xZnz{fH_}t`n0;$GFlb?NTrOQZNluF&$GfEmJc+Q#4IeHC642?NdMfQ$P(=K^;^=EmT82R76cwMO{=zZB$2nR7j0fNfnHX z>_w)CQW|NE$ZHYu%MIMn)T8iJp}^EhEmfGfQ6C8otI!giB;~P zRm=L0@Nm!n^59kUP#wkbRf&iY$T}kEtOy195AwqtU=5HV1qo8cQX)y#!#g)jC04wP zRyuP(hnNtIz}Choor1&AU0v3YphpEWP(L)Ut|$>1Are(X59T?$q;S_0VWi2qPkA-T zMiWiQp{03!)}OFfeRZ+enUU5C*z!48(bFMwwFnU%tyKMvT|ggp7?KM)lJDTUE7Dlw z;MfwC5{vrY93@ozHVdJp{dq}pi9|M*OAcH)-gOwMNN1i**T$Ckr)&z$xkma z*>00r-%(K*HQAmu4NC)*j_}#9Sfv&TmPu)mgV4x7atf$Ll^yBv*+Lr`6!8#U+B?)D@Af35Rn!!r1_?Lij#q$u-iD{Vo$q-^h9H`J;b%@;aFc^fP zM@!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